From 5e13fd354a39d637df9b25edcb2964edf4a7c534 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 13 Dec 2011 17:19:57 +0530 Subject: [PATCH 0001/1846] ath6kl: Use cfg80211_roamed_bss() to report roaming event This is to avoid the scenario where the bss entry of the AP got expired when reporting roaming event to current AP. As the bss entry for the current bss is available in driver, pass this bss to cfg80211. This fixes WARNING: at net/wireless/sme.c:586. This patch depends on the following patch in cfg80211 "cfg80211: Fix race in bss timeout". Reported-by: Kalle Valo Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 6c59a217b1a1..85c24dd01565 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -605,11 +605,13 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, return 0; } -static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, - enum network_type nw_type, - const u8 *bssid, - struct ieee80211_channel *chan, - const u8 *beacon_ie, size_t beacon_ie_len) +static struct cfg80211_bss * +ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, + enum network_type nw_type, + const u8 *bssid, + struct ieee80211_channel *chan, + const u8 *beacon_ie, + size_t beacon_ie_len) { struct ath6kl *ar = vif->ar; struct cfg80211_bss *bss; @@ -638,7 +640,7 @@ static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, */ ie = kmalloc(2 + vif->ssid_len + beacon_ie_len, GFP_KERNEL); if (ie == NULL) - return -ENOMEM; + return NULL; ie[0] = WLAN_EID_SSID; ie[1] = vif->ssid_len; memcpy(ie + 2, vif->ssid, vif->ssid_len); @@ -652,15 +654,9 @@ static int ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, "cfg80211\n", bssid); kfree(ie); } else - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "cfg80211 already has a bss " - "entry\n"); - - if (bss == NULL) - return -ENOMEM; + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "cfg80211 already has a bss\n"); - cfg80211_put_bss(bss); - - return 0; + return bss; } void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, @@ -672,6 +668,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, { struct ieee80211_channel *chan; struct ath6kl *ar = vif->ar; + struct cfg80211_bss *bss; /* capinfo + listen interval */ u8 assoc_req_ie_offset = sizeof(u16) + sizeof(u16); @@ -712,8 +709,9 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, chan = ieee80211_get_channel(ar->wiphy, (int) channel); - if (ath6kl_add_bss_if_needed(vif, nw_type, bssid, chan, assoc_info, - beacon_ie_len) < 0) { + bss = ath6kl_add_bss_if_needed(vif, nw_type, bssid, chan, + assoc_info, beacon_ie_len); + if (!bss) { ath6kl_err("could not add cfg80211 bss entry\n"); return; } @@ -722,6 +720,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "ad-hoc %s selected\n", nw_type & ADHOC_CREATOR ? "creator" : "joiner"); cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL); + cfg80211_put_bss(bss); return; } @@ -732,11 +731,11 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, assoc_req_ie, assoc_req_len, assoc_resp_ie, assoc_resp_len, WLAN_STATUS_SUCCESS, GFP_KERNEL); + cfg80211_put_bss(bss); } else if (vif->sme_state == SME_CONNECTED) { /* inform roam event to cfg80211 */ - cfg80211_roamed(vif->ndev, chan, bssid, - assoc_req_ie, assoc_req_len, - assoc_resp_ie, assoc_resp_len, GFP_KERNEL); + cfg80211_roamed_bss(vif->ndev, bss, assoc_req_ie, assoc_req_len, + assoc_resp_ie, assoc_resp_len, GFP_KERNEL); } } -- GitLab From 6e786cb1e514dc87647beccaa96bd8a255d97a0c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 15 Dec 2011 14:16:00 +0200 Subject: [PATCH 0002/1846] ath6kl: Fix connect command to clear previously used IEs Empty IE buffer means that the new association is not supposed to include extra IEs. Make sure any previously configured (Re)Association Request frame IEs get cleared in such a case. This is based on a patch from Shuibing. Cc: Dai Shuibing Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 85c24dd01565..1a06a04c5106 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -461,13 +461,13 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } } - if (sme->ie && (sme->ie_len > 0)) { - status = ath6kl_set_assoc_req_ies(vif, sme->ie, sme->ie_len); - if (status) { - up(&ar->sem); - return status; - } - } else + status = ath6kl_set_assoc_req_ies(vif, sme->ie, sme->ie_len); + if (status) { + up(&ar->sem); + return status; + } + + if (sme->ie == NULL || sme->ie_len == 0) ar->connect_ctrl_flags &= ~CONNECT_WPS_FLAG; if (test_bit(CONNECTED, &vif->flags) && -- GitLab From ca1d16a08fc2c26b693e65ad92fa37a4c778e60d Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Fri, 16 Dec 2011 14:24:23 +0530 Subject: [PATCH 0003/1846] ath6kl: Avoid taking struct as argument in ath6kl_wmi_set_ip_cmd In this way, caller is free to pass only the value of IP addr to configure. In addition to this, * 'ips' variable data type in struct wmi_set_ip_cmd is changed from __le32 to __be32 in order to match network byte order. * ipv4_is_multicast() is used to validate multicast ip addr. * New argument if_idx is added to supply correct vif index to ath6kl_wmi_cmd_send(). This will be used in the next patch. Signed-off-by: Raja Mani Signed-off-by: Thirumalai Pachamuthu Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/wmi.c | 12 +++++++----- drivers/net/wireless/ath/ath6kl/wmi.h | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index f6f2aa27fc20..1e31c38abb4f 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2479,15 +2479,16 @@ int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, return ret; } -int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) +int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx, + __be32 ips0, __be32 ips1) { struct sk_buff *skb; struct wmi_set_ip_cmd *cmd; int ret; /* Multicast address are not valid */ - if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || - (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) + if (ipv4_is_multicast(ips0) || + ipv4_is_multicast(ips1)) return -EINVAL; skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); @@ -2495,9 +2496,10 @@ int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) return -ENOMEM; cmd = (struct wmi_set_ip_cmd *) skb->data; - memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); + cmd->ips[0] = ips0; + cmd->ips[1] = ips1; - ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_IP_CMDID, + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); return ret; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 42ac311eda4e..96e3cc10cab2 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1903,7 +1903,7 @@ struct wow_filter { struct wmi_set_ip_cmd { /* IP in network byte order */ - __le32 ips[MAX_IP_ADDRS]; + __be32 ips[MAX_IP_ADDRS]; } __packed; enum ath6kl_wow_filters { @@ -2417,7 +2417,8 @@ int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len); s32 ath6kl_wmi_get_rate(s8 rate_index); -int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd); +int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx, + __be32 ips0, __be32 ips1); int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, enum ath6kl_host_mode host_mode); int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, -- GitLab From c08631c6e43e7ce91bca6b2d3466bb22a85fe724 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Fri, 16 Dec 2011 14:24:24 +0530 Subject: [PATCH 0004/1846] ath6kl: Send own IP addr to the firmware during WOW suspend Firmware ARP module requires own IP addr in order to respond to the outside world when the target is in WOW suspend state. At present, firmware ARP module has capability to hold 2 IP addr. So, WOW mode will be disabled if the total IP addr configured in net_dev for our device is greater than firmware limit (MAX_IP_ADDRS) which is 2 at this moment. Signed-off-by: Raja Mani Signed-off-by: Thirumalai Pachamuthu Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 1a06a04c5106..45b0d974e4f7 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -15,6 +15,7 @@ */ #include +#include #include "core.h" #include "cfg80211.h" @@ -1729,11 +1730,14 @@ static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) { + struct in_device *in_dev; + struct in_ifaddr *ifa; struct ath6kl_vif *vif; int ret, pos, left; u32 filter = 0; u16 i; - u8 mask[WOW_MASK_SIZE]; + u8 mask[WOW_MASK_SIZE], index = 0; + __be32 ips[MAX_IP_ADDRS]; vif = ath6kl_vif_first(ar); if (!vif) @@ -1780,6 +1784,33 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) return ret; } + /* Setup own IP addr for ARP agent. */ + in_dev = __in_dev_get_rtnl(vif->ndev); + if (!in_dev) + goto skip_arp; + + ifa = in_dev->ifa_list; + memset(&ips, 0, sizeof(ips)); + + /* Configure IP addr only if IP address count < MAX_IP_ADDRS */ + while (index < MAX_IP_ADDRS && ifa) { + ips[index] = ifa->ifa_local; + ifa = ifa->ifa_next; + index++; + } + + if (ifa) { + ath6kl_err("total IP addr count is exceeding fw limit\n"); + return -EINVAL; + } + + ret = ath6kl_wmi_set_ip_cmd(ar->wmi, vif->fw_vif_idx, ips[0], ips[1]); + if (ret) { + ath6kl_err("fail to setup ip for arp agent\n"); + return ret; + } + +skip_arp: if (wow->disconnect) filter |= WOW_FILTER_OPTION_NWK_DISASSOC; -- GitLab From c0038972b1253ad7f3ab7cc35ed57a830f5c8568 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 16 Dec 2011 20:53:31 +0200 Subject: [PATCH 0005/1846] ath6kl: handle firmware names more dynamically Currently ath6kl has just hardcoded paths to each firmware file. Change this more dynamic by separating the the directory and file name from each other. That way it's easier to dynamically create full paths to firmware and code looks better. And now it's possible to remove a function needed by devicetree code. While at it add a structure inside struct ath6kl_hw to contain all firmware names. I deliberately omitted board file support as those will be handled later. This is needed for firmware API 3. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 45 ++++++------ drivers/net/wireless/ath/ath6kl/init.c | 95 ++++++++++++++------------ drivers/net/wireless/ath/ath6kl/sdio.c | 16 ++--- drivers/net/wireless/ath/ath6kl/usb.c | 5 +- 4 files changed, 87 insertions(+), 74 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index c863a28f2e0c..267957712564 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -97,45 +97,46 @@ struct ath6kl_fw_ie { u8 data[0]; }; +#define ATH6KL_FW_API2_FILE "fw-2.bin" + /* AR6003 1.0 definitions */ #define AR6003_HW_1_0_VERSION 0x300002ba /* AR6003 2.0 definitions */ #define AR6003_HW_2_0_VERSION 0x30000384 #define AR6003_HW_2_0_PATCH_DOWNLOAD_ADDRESS 0x57e910 -#define AR6003_HW_2_0_OTP_FILE "ath6k/AR6003/hw2.0/otp.bin.z77" -#define AR6003_HW_2_0_FIRMWARE_FILE "ath6k/AR6003/hw2.0/athwlan.bin.z77" -#define AR6003_HW_2_0_TCMD_FIRMWARE_FILE "ath6k/AR6003/hw2.0/athtcmd_ram.bin" -#define AR6003_HW_2_0_PATCH_FILE "ath6k/AR6003/hw2.0/data.patch.bin" -#define AR6003_HW_2_0_FIRMWARE_2_FILE "ath6k/AR6003/hw2.0/fw-2.bin" +#define AR6003_HW_2_0_FW_DIR "ath6k/AR6003/hw2.0" +#define AR6003_HW_2_0_OTP_FILE "otp.bin.z77" +#define AR6003_HW_2_0_FIRMWARE_FILE "athwlan.bin.z77" +#define AR6003_HW_2_0_TCMD_FIRMWARE_FILE "athtcmd_ram.bin" +#define AR6003_HW_2_0_PATCH_FILE "data.patch.bin" #define AR6003_HW_2_0_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.bin" #define AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE \ "ath6k/AR6003/hw2.0/bdata.SD31.bin" /* AR6003 3.0 definitions */ #define AR6003_HW_2_1_1_VERSION 0x30000582 -#define AR6003_HW_2_1_1_OTP_FILE "ath6k/AR6003/hw2.1.1/otp.bin" -#define AR6003_HW_2_1_1_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/athwlan.bin" -#define AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE \ - "ath6k/AR6003/hw2.1.1/athtcmd_ram.bin" -#define AR6003_HW_2_1_1_PATCH_FILE "ath6k/AR6003/hw2.1.1/data.patch.bin" -#define AR6003_HW_2_1_1_FIRMWARE_2_FILE "ath6k/AR6003/hw2.1.1/fw-2.bin" +#define AR6003_HW_2_1_1_FW_DIR "ath6k/AR6003/hw2.1.1" +#define AR6003_HW_2_1_1_OTP_FILE "otp.bin" +#define AR6003_HW_2_1_1_FIRMWARE_FILE "athwlan.bin" +#define AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE "athtcmd_ram.bin" +#define AR6003_HW_2_1_1_PATCH_FILE "data.patch.bin" #define AR6003_HW_2_1_1_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.bin" #define AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE \ "ath6k/AR6003/hw2.1.1/bdata.SD31.bin" /* AR6004 1.0 definitions */ #define AR6004_HW_1_0_VERSION 0x30000623 -#define AR6004_HW_1_0_FIRMWARE_2_FILE "ath6k/AR6004/hw1.0/fw-2.bin" -#define AR6004_HW_1_0_FIRMWARE_FILE "ath6k/AR6004/hw1.0/fw.ram.bin" +#define AR6004_HW_1_0_FW_DIR "ath6k/AR6004/hw1.0" +#define AR6004_HW_1_0_FIRMWARE_FILE "fw.ram.bin" #define AR6004_HW_1_0_BOARD_DATA_FILE "ath6k/AR6004/hw1.0/bdata.bin" #define AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE \ "ath6k/AR6004/hw1.0/bdata.DB132.bin" /* AR6004 1.1 definitions */ #define AR6004_HW_1_1_VERSION 0x30000001 -#define AR6004_HW_1_1_FIRMWARE_2_FILE "ath6k/AR6004/hw1.1/fw-2.bin" -#define AR6004_HW_1_1_FIRMWARE_FILE "ath6k/AR6004/hw1.1/fw.ram.bin" +#define AR6004_HW_1_1_FW_DIR "ath6k/AR6004/hw1.1" +#define AR6004_HW_1_1_FIRMWARE_FILE "fw.ram.bin" #define AR6004_HW_1_1_BOARD_DATA_FILE "ath6k/AR6004/hw1.1/bdata.bin" #define AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE \ "ath6k/AR6004/hw1.1/bdata.DB132.bin" @@ -575,11 +576,15 @@ struct ath6kl { u32 refclk_hz; u32 uarttx_pin; - const char *fw_otp; - const char *fw; - const char *fw_tcmd; - const char *fw_patch; - const char *fw_api2; + struct ath6kl_hw_fw { + const char *dir; + const char *otp; + const char *fw; + const char *tcmd; + const char *patch; + const char *api2; + } fw; + const char *fw_board; const char *fw_default_board; } hw; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 368ecbd172a3..7b802e99851c 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -47,11 +47,15 @@ static const struct ath6kl_hw hw_list[] = { /* hw2.0 needs override address hardcoded */ .app_start_override_addr = 0x944C00, - .fw_otp = AR6003_HW_2_0_OTP_FILE, - .fw = AR6003_HW_2_0_FIRMWARE_FILE, - .fw_tcmd = AR6003_HW_2_0_TCMD_FIRMWARE_FILE, - .fw_patch = AR6003_HW_2_0_PATCH_FILE, - .fw_api2 = AR6003_HW_2_0_FIRMWARE_2_FILE, + .fw = { + .dir = AR6003_HW_2_0_FW_DIR, + .otp = AR6003_HW_2_0_OTP_FILE, + .fw = AR6003_HW_2_0_FIRMWARE_FILE, + .tcmd = AR6003_HW_2_0_TCMD_FIRMWARE_FILE, + .patch = AR6003_HW_2_0_PATCH_FILE, + .api2 = ATH6KL_FW_API2_FILE, + }, + .fw_board = AR6003_HW_2_0_BOARD_DATA_FILE, .fw_default_board = AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE, }, @@ -65,11 +69,15 @@ static const struct ath6kl_hw hw_list[] = { .refclk_hz = 26000000, .uarttx_pin = 8, - .fw_otp = AR6003_HW_2_1_1_OTP_FILE, - .fw = AR6003_HW_2_1_1_FIRMWARE_FILE, - .fw_tcmd = AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE, - .fw_patch = AR6003_HW_2_1_1_PATCH_FILE, - .fw_api2 = AR6003_HW_2_1_1_FIRMWARE_2_FILE, + .fw = { + .dir = AR6003_HW_2_1_1_FW_DIR, + .otp = AR6003_HW_2_1_1_OTP_FILE, + .fw = AR6003_HW_2_1_1_FIRMWARE_FILE, + .tcmd = AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE, + .patch = AR6003_HW_2_1_1_PATCH_FILE, + .api2 = ATH6KL_FW_API2_FILE, + }, + .fw_board = AR6003_HW_2_1_1_BOARD_DATA_FILE, .fw_default_board = AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE, }, @@ -84,8 +92,12 @@ static const struct ath6kl_hw hw_list[] = { .refclk_hz = 26000000, .uarttx_pin = 11, - .fw = AR6004_HW_1_0_FIRMWARE_FILE, - .fw_api2 = AR6004_HW_1_0_FIRMWARE_2_FILE, + .fw = { + .dir = AR6004_HW_1_0_FW_DIR, + .fw = AR6004_HW_1_0_FIRMWARE_FILE, + .api2 = ATH6KL_FW_API2_FILE, + }, + .fw_board = AR6004_HW_1_0_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE, }, @@ -100,8 +112,12 @@ static const struct ath6kl_hw hw_list[] = { .refclk_hz = 40000000, .uarttx_pin = 11, - .fw = AR6004_HW_1_1_FIRMWARE_FILE, - .fw_api2 = AR6004_HW_1_1_FIRMWARE_2_FILE, + .fw = { + .dir = AR6004_HW_1_1_FW_DIR, + .fw = AR6004_HW_1_1_FIRMWARE_FILE, + .api2 = ATH6KL_FW_API2_FILE, + }, + .fw_board = AR6004_HW_1_1_BOARD_DATA_FILE, .fw_default_board = AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE, }, @@ -626,21 +642,6 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename, } #ifdef CONFIG_OF -static const char *get_target_ver_dir(const struct ath6kl *ar) -{ - switch (ar->version.target_ver) { - case AR6003_HW_1_0_VERSION: - return "ath6k/AR6003/hw1.0"; - case AR6003_HW_2_0_VERSION: - return "ath6k/AR6003/hw2.0"; - case AR6003_HW_2_1_1_VERSION: - return "ath6k/AR6003/hw2.1.1"; - } - ath6kl_warn("%s: unsupported target version 0x%x.\n", __func__, - ar->version.target_ver); - return NULL; -} - /* * Check the device tree for a board-id and use it to construct * the pathname to the firmware file. Used (for now) to find a @@ -663,7 +664,7 @@ static bool check_device_tree(struct ath6kl *ar) continue; } snprintf(board_filename, sizeof(board_filename), - "%s/bdata.%s.bin", get_target_ver_dir(ar), board_id); + "%s/bdata.%s.bin", ar->hw.fw.dir, board_id); ret = ath6kl_get_fw(ar, board_filename, &ar->fw_board, &ar->fw_board_len); @@ -730,19 +731,20 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar) static int ath6kl_fetch_otp_file(struct ath6kl *ar) { - const char *filename; + char filename[100]; int ret; if (ar->fw_otp != NULL) return 0; - if (ar->hw.fw_otp == NULL) { + if (ar->hw.fw.otp == NULL) { ath6kl_dbg(ATH6KL_DBG_BOOT, "no OTP file configured for this hw\n"); return 0; } - filename = ar->hw.fw_otp; + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.otp); ret = ath6kl_get_fw(ar, filename, &ar->fw_otp, &ar->fw_otp_len); @@ -757,29 +759,32 @@ static int ath6kl_fetch_otp_file(struct ath6kl *ar) static int ath6kl_fetch_fw_file(struct ath6kl *ar) { - const char *filename; + char filename[100]; int ret; if (ar->fw != NULL) return 0; if (testmode) { - if (ar->hw.fw_tcmd == NULL) { + if (ar->hw.fw.tcmd == NULL) { ath6kl_warn("testmode not supported\n"); return -EOPNOTSUPP; } - filename = ar->hw.fw_tcmd; + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.tcmd); set_bit(TESTMODE, &ar->flag); goto get_fw; } - if (WARN_ON(ar->hw.fw == NULL)) + /* FIXME: remove WARN_ON() as we won't support FW API 1 for long */ + if (WARN_ON(ar->hw.fw.fw == NULL)) return -EINVAL; - filename = ar->hw.fw; + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.fw); get_fw: ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len); @@ -794,16 +799,17 @@ static int ath6kl_fetch_fw_file(struct ath6kl *ar) static int ath6kl_fetch_patch_file(struct ath6kl *ar) { - const char *filename; + char filename[100]; int ret; if (ar->fw_patch != NULL) return 0; - if (ar->hw.fw_patch == NULL) + if (ar->hw.fw.patch == NULL) return 0; - filename = ar->hw.fw_patch; + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.patch); ret = ath6kl_get_fw(ar, filename, &ar->fw_patch, &ar->fw_patch_len); @@ -840,15 +846,16 @@ static int ath6kl_fetch_fw_api2(struct ath6kl *ar) size_t magic_len, len, ie_len; const struct firmware *fw; struct ath6kl_fw_ie *hdr; - const char *filename; + char filename[100]; const u8 *data; int ret, ie_id, i, index, bit; __le32 *val; - if (ar->hw.fw_api2 == NULL) + if (ar->hw.fw.api2 == NULL) return -EOPNOTSUPP; - filename = ar->hw.fw_api2; + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.api2); ret = request_firmware(&fw, filename, ar->dev); if (ret) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 15c3f56caf4f..278a9f30795a 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1362,19 +1362,19 @@ MODULE_AUTHOR("Atheros Communications, Inc."); MODULE_DESCRIPTION("Driver support for Atheros AR600x SDIO devices"); MODULE_LICENSE("Dual BSD/GPL"); -MODULE_FIRMWARE(AR6003_HW_2_0_OTP_FILE); -MODULE_FIRMWARE(AR6003_HW_2_0_FIRMWARE_FILE); -MODULE_FIRMWARE(AR6003_HW_2_0_PATCH_FILE); +MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_OTP_FILE); +MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_PATCH_FILE); MODULE_FIRMWARE(AR6003_HW_2_0_BOARD_DATA_FILE); MODULE_FIRMWARE(AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE); -MODULE_FIRMWARE(AR6003_HW_2_1_1_OTP_FILE); -MODULE_FIRMWARE(AR6003_HW_2_1_1_FIRMWARE_FILE); -MODULE_FIRMWARE(AR6003_HW_2_1_1_PATCH_FILE); +MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_OTP_FILE); +MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_PATCH_FILE); MODULE_FIRMWARE(AR6003_HW_2_1_1_BOARD_DATA_FILE); MODULE_FIRMWARE(AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE); -MODULE_FIRMWARE(AR6004_HW_1_0_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_HW_1_0_FW_DIR "/" AR6004_HW_1_0_FIRMWARE_FILE); MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE); MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE); -MODULE_FIRMWARE(AR6004_HW_1_1_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_HW_1_1_FW_DIR "/" AR6004_HW_1_1_FIRMWARE_FILE); MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE); MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE); diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c index e3cf397fcafe..bb341796dc81 100644 --- a/drivers/net/wireless/ath/ath6kl/usb.c +++ b/drivers/net/wireless/ath/ath6kl/usb.c @@ -423,9 +423,10 @@ module_exit(ath6kl_usb_exit); MODULE_AUTHOR("Atheros Communications, Inc."); MODULE_DESCRIPTION("Driver support for Atheros AR600x USB devices"); MODULE_LICENSE("Dual BSD/GPL"); -MODULE_FIRMWARE(AR6004_HW_1_0_FIRMWARE_FILE); + +MODULE_FIRMWARE(AR6004_HW_1_0_FW_DIR "/" AR6004_HW_1_0_FIRMWARE_FILE); MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE); MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE); -MODULE_FIRMWARE(AR6004_HW_1_1_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_HW_1_1_FW_DIR "/" AR6004_HW_1_1_FIRMWARE_FILE); MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE); MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE); -- GitLab From 65a8b4cc511b68712799e91137324f2abece7d3e Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Fri, 16 Dec 2011 20:53:41 +0200 Subject: [PATCH 0006/1846] ath6kl: add support for FW API 3 As firmware starting from 3.2.0.12 has some API changes and doesn't work with older versions of ath6kl we need to bump up the API version. This way we don't break anything. Also store which version of API is used and print that during boot: ath6kl: ar6003 hw 2.1.1 sdio fw 3.2.0.13 api 3 Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 3 ++- drivers/net/wireless/ath/ath6kl/init.c | 32 ++++++++++++++------------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 267957712564..c095fafa278f 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -98,6 +98,7 @@ struct ath6kl_fw_ie { }; #define ATH6KL_FW_API2_FILE "fw-2.bin" +#define ATH6KL_FW_API3_FILE "fw-3.bin" /* AR6003 1.0 definitions */ #define AR6003_HW_1_0_VERSION 0x300002ba @@ -582,7 +583,6 @@ struct ath6kl { const char *fw; const char *tcmd; const char *patch; - const char *api2; } fw; const char *fw_board; @@ -608,6 +608,7 @@ struct ath6kl { u8 *fw_patch; size_t fw_patch_len; + unsigned int fw_api; unsigned long fw_capabilities[ATH6KL_CAPABILITY_LEN]; struct workqueue_struct *ath6kl_wq; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 7b802e99851c..57e0312c4cb9 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -53,7 +53,6 @@ static const struct ath6kl_hw hw_list[] = { .fw = AR6003_HW_2_0_FIRMWARE_FILE, .tcmd = AR6003_HW_2_0_TCMD_FIRMWARE_FILE, .patch = AR6003_HW_2_0_PATCH_FILE, - .api2 = ATH6KL_FW_API2_FILE, }, .fw_board = AR6003_HW_2_0_BOARD_DATA_FILE, @@ -75,7 +74,6 @@ static const struct ath6kl_hw hw_list[] = { .fw = AR6003_HW_2_1_1_FIRMWARE_FILE, .tcmd = AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE, .patch = AR6003_HW_2_1_1_PATCH_FILE, - .api2 = ATH6KL_FW_API2_FILE, }, .fw_board = AR6003_HW_2_1_1_BOARD_DATA_FILE, @@ -95,7 +93,6 @@ static const struct ath6kl_hw hw_list[] = { .fw = { .dir = AR6004_HW_1_0_FW_DIR, .fw = AR6004_HW_1_0_FIRMWARE_FILE, - .api2 = ATH6KL_FW_API2_FILE, }, .fw_board = AR6004_HW_1_0_BOARD_DATA_FILE, @@ -115,7 +112,6 @@ static const struct ath6kl_hw hw_list[] = { .fw = { .dir = AR6004_HW_1_1_FW_DIR, .fw = AR6004_HW_1_1_FIRMWARE_FILE, - .api2 = ATH6KL_FW_API2_FILE, }, .fw_board = AR6004_HW_1_1_BOARD_DATA_FILE, @@ -841,7 +837,7 @@ static int ath6kl_fetch_fw_api1(struct ath6kl *ar) return 0; } -static int ath6kl_fetch_fw_api2(struct ath6kl *ar) +static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name) { size_t magic_len, len, ie_len; const struct firmware *fw; @@ -851,11 +847,7 @@ static int ath6kl_fetch_fw_api2(struct ath6kl *ar) int ret, ie_id, i, index, bit; __le32 *val; - if (ar->hw.fw.api2 == NULL) - return -EOPNOTSUPP; - - snprintf(filename, sizeof(filename), "%s/%s", - ar->hw.fw.dir, ar->hw.fw.api2); + snprintf(filename, sizeof(filename), "%s/%s", ar->hw.fw.dir, name); ret = request_firmware(&fw, filename, ar->dev); if (ret) @@ -1025,17 +1017,26 @@ static int ath6kl_fetch_firmwares(struct ath6kl *ar) if (ret) return ret; - ret = ath6kl_fetch_fw_api2(ar); + ret = ath6kl_fetch_fw_apin(ar, ATH6KL_FW_API3_FILE); if (ret == 0) { - ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 2\n"); - return 0; + ar->fw_api = 3; + goto out; + } + + ret = ath6kl_fetch_fw_apin(ar, ATH6KL_FW_API2_FILE); + if (ret == 0) { + ar->fw_api = 2; + goto out; } ret = ath6kl_fetch_fw_api1(ar); if (ret) return ret; - ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 1\n"); + ar->fw_api = 1; + +out: + ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api %d\n", ar->fw_api); return 0; } @@ -1488,10 +1489,11 @@ int ath6kl_init_hw_start(struct ath6kl *ar) if (test_and_clear_bit(FIRST_BOOT, &ar->flag)) { - ath6kl_info("%s %s fw %s%s\n", + ath6kl_info("%s %s fw %s api %d%s\n", ar->hw.name, ath6kl_init_get_hif_name(ar->hif_type), ar->wiphy->fw_version, + ar->fw_api, test_bit(TESTMODE, &ar->flag) ? " testmode" : ""); } -- GitLab From e68f67509d92114c55938898643600c23f88b4c1 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 22 Dec 2011 12:15:27 +0530 Subject: [PATCH 0007/1846] ath6kl: Fix panic when setting a channel cfg80211 could pass a NULL net_device to the driver via the set_channel() callback, when it receives a request to set the device's channel. Not handling this case properly results in this panic: BUG: unable to handle kernel NULL pointer dereference at 0000000000000cb0 IP: [] ath6kl_cfg80211_ready+0x9/0x70 [ath6kl_sdio] Call Trace: [] ath6kl_set_channel+0x27/0x90 [ath6kl_sdio] [] cfg80211_set_freq+0xff/0x1d0 [cfg80211] [] ? nl80211_set_wiphy+0x85/0x660 [cfg80211] [] __nl80211_set_channel.isra.39+0x118/0x140 [cfg80211] [] nl80211_set_wiphy+0x303/0x660 [cfg80211] [] ? rtnl_lock+0x17/0x20 [] ? nl80211_pre_doit+0xb5/0x150 [cfg80211] [] genl_rcv_msg+0x1d5/0x250 [] ? genl_rcv+0x40/0x40 [] netlink_rcv_skb+0xa9/0xd0 [] genl_rcv+0x25/0x40 [] ? might_fault+0x40/0x90 [] netlink_unicast+0x2d9/0x320 [] netlink_sendmsg+0x2c6/0x320 [] ? sock_update_classid+0xb0/0x110 [] sock_sendmsg+0x10e/0x130 [] ? mem_cgroup_update_page_stat+0x193/0x250 [] ? might_fault+0x40/0x90 [] ? might_fault+0x40/0x90 [] ? might_fault+0x89/0x90 [] ? might_fault+0x40/0x90 [] ? verify_iovec+0x56/0xd0 [] __sys_sendmsg+0x396/0x3b0 [] ? up_read+0x23/0x40 [] ? do_page_fault+0x208/0x4e0 [] ? vfsmount_lock_local_unlock+0x21/0x60 [] ? mntput_no_expire+0x30/0xe0 [] ? mntput+0x1f/0x30 [] sys_sendmsg+0x49/0x90 [] system_call_fastpath+0x16/0x1b Signed-off-by: Sujith Manoharan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 45b0d974e4f7..d6806be5895b 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2044,7 +2044,18 @@ static int ath6kl_set_channel(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) { - struct ath6kl_vif *vif = netdev_priv(dev); + struct ath6kl_vif *vif; + + /* + * 'dev' could be NULL if a channel change is required for the hardware + * device itself, instead of a particular VIF. + * + * FIXME: To be handled properly when monitor mode is supported. + */ + if (!dev) + return -EBUSY; + + vif = netdev_priv(dev); if (!ath6kl_cfg80211_ready(vif)) return -EIO; -- GitLab From 33e5308d8a0fb857a57c38def36ccf7b14ebf1c1 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 27 Dec 2011 11:02:56 +0200 Subject: [PATCH 0008/1846] ath6kl: Add del_station cfg80211_ops hostapd/wpa_supplicant AP mode uses this operation to flush the station entries. Implement this in ath6kl to avoid unnecessary warnings from NL80211_CMD_DEL_STATION failing. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d6806be5895b..f74762ed619d 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2300,6 +2300,19 @@ static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev) return 0; } +static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + +static int ath6kl_del_station(struct wiphy *wiphy, struct net_device *dev, + u8 *mac) +{ + struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); + const u8 *addr = mac ? mac : bcast_addr; + + return ath6kl_wmi_ap_set_mlme(ar->wmi, vif->fw_vif_idx, WMI_AP_DEAUTH, + addr, WLAN_REASON_PREV_AUTH_NOT_VALID); +} + static int ath6kl_change_station(struct wiphy *wiphy, struct net_device *dev, u8 *mac, struct station_parameters *params) { @@ -2603,6 +2616,7 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = { .add_beacon = ath6kl_add_beacon, .set_beacon = ath6kl_set_beacon, .del_beacon = ath6kl_del_beacon, + .del_station = ath6kl_del_station, .change_station = ath6kl_change_station, .remain_on_channel = ath6kl_remain_on_channel, .cancel_remain_on_channel = ath6kl_cancel_remain_on_channel, -- GitLab From ba1f6fe393c329230d2589ea508cbf90ff3cc9ce Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 27 Dec 2011 11:03:53 +0200 Subject: [PATCH 0009/1846] ath6kl: Advertise TX/RX support for frames in AP mode This is needed to fix current hostapd/wpa_supplicant AP operations for frame registration. P2P GO mode already advertised these, but AP mode was forgotten and could not be used after the hostapd/wpa_supplicant frame registration changes. Signed-off-by: Jouni Malinen Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index f74762ed619d..c756425abf73 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2572,6 +2572,12 @@ ath6kl_mgmt_stypes[NUM_NL80211_IFTYPES] = { .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) }, + [NL80211_IFTYPE_AP] = { + .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | + BIT(IEEE80211_STYPE_PROBE_RESP >> 4), + .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) + }, [NL80211_IFTYPE_P2P_CLIENT] = { .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | BIT(IEEE80211_STYPE_PROBE_RESP >> 4), -- GitLab From bc48ad31c5814feb4ff8faca9a8d422279593cb1 Mon Sep 17 00:00:00 2001 From: Rishi Panjwani Date: Tue, 27 Dec 2011 14:28:00 -0800 Subject: [PATCH 0010/1846] ath6kl: Support for TCP checksum offload to firmware The change enables offloading TCP checksum calculation to firmware. There are still some issues with the checksum offload so better to disable it by default until the issues are resolved. To enable TCP checksum offload for tx and rx paths, use the ethtool as follows: ethtool -K tx on ethtool -K rx on To disable TCP checksum offload, for tx and rx paths, use the ethtool as follows: ethtool -K tx off ethtool -K rx off kvalo: indentation changes Signed-off-by: Rishi Panjwani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 2 ++ drivers/net/wireless/ath/ath6kl/main.c | 33 ++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/txrx.c | 38 +++++++++++++++++++++++--- drivers/net/wireless/ath/ath6kl/wmi.h | 3 ++ 4 files changed, 72 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 57e0312c4cb9..e74279372ef8 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1686,6 +1686,8 @@ int ath6kl_core_init(struct ath6kl *ar) set_bit(FIRST_BOOT, &ar->flag); + ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; + ret = ath6kl_init_hw_start(ar); if (ret) { ath6kl_err("Failed to start hardware: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index eea3c747653e..f3d0184a5cea 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1020,11 +1020,44 @@ static struct net_device_stats *ath6kl_get_stats(struct net_device *dev) return &vif->net_stats; } +static int ath6kl_set_features(struct net_device *dev, u32 features) +{ + struct ath6kl_vif *vif = netdev_priv(dev); + struct ath6kl *ar = vif->ar; + int err = 0; + + if ((features & NETIF_F_RXCSUM) && + (ar->rx_meta_ver != WMI_META_VERSION_2)) { + ar->rx_meta_ver = WMI_META_VERSION_2; + err = ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, + vif->fw_vif_idx, + ar->rx_meta_ver, 0, 0); + if (err) { + dev->features = features & ~NETIF_F_RXCSUM; + return err; + } + } else if (!(features & NETIF_F_RXCSUM) && + (ar->rx_meta_ver == WMI_META_VERSION_2)) { + ar->rx_meta_ver = 0; + err = ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, + vif->fw_vif_idx, + ar->rx_meta_ver, 0, 0); + if (err) { + dev->features = features | NETIF_F_RXCSUM; + return err; + } + + } + + return err; +} + static struct net_device_ops ath6kl_netdev_ops = { .ndo_open = ath6kl_open, .ndo_stop = ath6kl_close, .ndo_start_xmit = ath6kl_data_tx, .ndo_get_stats = ath6kl_get_stats, + .ndo_set_features = ath6kl_set_features, }; void init_netdev(struct net_device *dev) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 506a3031a885..78bd57306f74 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -244,6 +244,10 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) u8 ac = 99 ; /* initialize to unmapped ac */ bool chk_adhoc_ps_mapping = false, more_data = false; int ret; + struct wmi_tx_meta_v2 meta_v2; + void *meta; + u8 csum_start = 0, csum_dest = 0, csum = skb->ip_summed; + u8 meta_ver = 0; ath6kl_dbg(ATH6KL_DBG_WLAN_TX, "%s: skb=0x%p, data=0x%p, len=0x%x\n", __func__, @@ -265,6 +269,14 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) } if (test_bit(WMI_ENABLED, &ar->flag)) { + if ((dev->features & NETIF_F_IP_CSUM) && + (csum == CHECKSUM_PARTIAL)) { + csum_start = skb->csum_start - + (skb_network_header(skb) - skb->head) + + sizeof(struct ath6kl_llc_snap_hdr); + csum_dest = skb->csum_offset + csum_start; + } + if (skb_headroom(skb) < dev->needed_headroom) { struct sk_buff *tmp_skb = skb; @@ -281,10 +293,28 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) goto fail_tx; } - if (ath6kl_wmi_data_hdr_add(ar->wmi, skb, DATA_MSGTYPE, - more_data, 0, 0, NULL, - vif->fw_vif_idx)) { - ath6kl_err("wmi_data_hdr_add failed\n"); + if ((dev->features & NETIF_F_IP_CSUM) && + (csum == CHECKSUM_PARTIAL)) { + meta_v2.csum_start = csum_start; + meta_v2.csum_dest = csum_dest; + + /* instruct target to calculate checksum */ + meta_v2.csum_flags = WMI_META_V2_FLAG_CSUM_OFFLOAD; + meta_ver = WMI_META_VERSION_2; + meta = &meta_v2; + } else { + meta_ver = 0; + meta = NULL; + } + + ret = ath6kl_wmi_data_hdr_add(ar->wmi, skb, + DATA_MSGTYPE, more_data, 0, + meta_ver, + meta, vif->fw_vif_idx); + + if (ret) { + ath6kl_warn("failed to add wmi data header:%d\n" + , ret); goto fail_tx; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 96e3cc10cab2..9f8425b97db7 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -257,6 +257,9 @@ static inline u8 wmi_data_hdr_get_if_idx(struct wmi_data_hdr *dhdr) #define WMI_META_VERSION_1 0x01 #define WMI_META_VERSION_2 0x02 +/* Flag to signal to FW to calculate TCP checksum */ +#define WMI_META_V2_FLAG_CSUM_OFFLOAD 0x01 + struct wmi_tx_meta_v1 { /* packet ID to identify the tx request */ u8 pkt_id; -- GitLab From 351de2835d6429548feb8cca9a17497ec3474f41 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Thu, 29 Dec 2011 16:05:37 +0530 Subject: [PATCH 0011/1846] ath6kl: Remove few unnecessary spin_locks around set_bit() Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/txrx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 78bd57306f74..fcea82479cde 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -479,9 +479,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, * WMI queue with too many commands the only exception to * this is during testing using endpointping. */ - spin_lock_bh(&ar->lock); set_bit(WMI_CTRL_EP_FULL, &ar->flag); - spin_unlock_bh(&ar->lock); ath6kl_err("wmi ctrl ep is full\n"); return action; } @@ -509,9 +507,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, action != HTC_SEND_FULL_DROP) { spin_unlock_bh(&ar->list_lock); - spin_lock_bh(&vif->if_lock); set_bit(NETQ_STOPPED, &vif->flags); - spin_unlock_bh(&vif->if_lock); netif_stop_queue(vif->ndev); return action; -- GitLab From a10e2f2f6db8f86eaca1cf3d00269463da4d6434 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Thu, 29 Dec 2011 16:05:38 +0530 Subject: [PATCH 0012/1846] ath6kl: Add a module parameter to enable uart debug To enable firmware debug messages through uart interface, modprobe ath6kl_sdio uart_debug=1. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index e74279372ef8..a481b6a1715d 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -28,10 +28,12 @@ unsigned int debug_mask; static unsigned int testmode; static bool suspend_cutpower; +static unsigned int uart_debug; module_param(debug_mask, uint, 0644); module_param(testmode, uint, 0644); module_param(suspend_cutpower, bool, 0444); +module_param(uart_debug, uint, 0644); static const struct ath6kl_hw hw_list[] = { { @@ -464,6 +466,13 @@ int ath6kl_configure_target(struct ath6kl *ar) u8 fw_iftype, fw_mode = 0, fw_submode = 0; int i, status; + param = uart_debug; + if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, + HI_ITEM(hi_serial_enable)), (u8 *)¶m, 4)) { + ath6kl_err("bmi_write_memory for uart debug failed\n"); + return -EIO; + } + /* * Note: Even though the firmware interface type is * chosen as BSS_STA for all three interfaces, can -- GitLab From 792ecb33080f4e315695e0fe21cf3a3c2a514dd0 Mon Sep 17 00:00:00 2001 From: Vivek Natarajan Date: Thu, 29 Dec 2011 16:18:39 +0530 Subject: [PATCH 0013/1846] ath6kl: Remove redundant key_index check. Less-than-zero comparison of an unsigned value is never true. kvalo: remove WMI_MIN_KEY_INDEX altogether, it's useless Signed-off-by: Vivek Natarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 11 +++++------ drivers/net/wireless/ath/ath6kl/main.c | 2 +- drivers/net/wireless/ath/ath6kl/wmi.h | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index c756425abf73..2a166cc7cc3c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -524,8 +524,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, (vif->prwise_crypto == WEP_CRYPT)) { struct ath6kl_key *key = NULL; - if (sme->key_idx < WMI_MIN_KEY_INDEX || - sme->key_idx > WMI_MAX_KEY_INDEX) { + if (sme->key_idx > WMI_MAX_KEY_INDEX) { ath6kl_err("key index %d out of bounds\n", sme->key_idx); up(&ar->sem); @@ -997,7 +996,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, params->key); } - if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { + if (key_index > WMI_MAX_KEY_INDEX) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: key index %d out of bounds\n", __func__, key_index); @@ -1115,7 +1114,7 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, if (!ath6kl_cfg80211_ready(vif)) return -EIO; - if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { + if (key_index > WMI_MAX_KEY_INDEX) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: key index %d out of bounds\n", __func__, key_index); @@ -1148,7 +1147,7 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, if (!ath6kl_cfg80211_ready(vif)) return -EIO; - if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { + if (key_index > WMI_MAX_KEY_INDEX) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: key index %d out of bounds\n", __func__, key_index); @@ -1184,7 +1183,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy, if (!ath6kl_cfg80211_ready(vif)) return -EIO; - if (key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) { + if (key_index > WMI_MAX_KEY_INDEX) { ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: key index %d out of bounds\n", __func__, key_index); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index f3d0184a5cea..f74986d62098 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -363,7 +363,7 @@ static void ath6kl_install_static_wep_keys(struct ath6kl_vif *vif) u8 index; u8 keyusage; - for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) { + for (index = 0; index <= WMI_MAX_KEY_INDEX; index++) { if (vif->wep_key_list[index].key_len) { keyusage = GROUP_USAGE; if (index == vif->def_txkey_index) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 9f8425b97db7..2b435994b013 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -649,7 +649,6 @@ enum auth_mode { WPA2_AUTH_CCKM = 0x40, }; -#define WMI_MIN_KEY_INDEX 0 #define WMI_MAX_KEY_INDEX 3 #define WMI_MAX_KEY_LEN 32 -- GitLab From 4f34dacea117029dbad1f0f50d68207b97546d1e Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Fri, 30 Dec 2011 01:57:00 -0800 Subject: [PATCH 0014/1846] ath6kl: send TCMD response through testmode events ath6kl no longer knows what it is transmitting through cfg80211_testmode, and simply passes opaque buffers between userspace and the firmware. Leave the CONT_RX enum for backwards compatibility. kvalo: change ATH6KL_TM_CMD_RX_REPORT to return -EOPNOTSUPP Signed-off-by: Thomas Pedersen Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/testmode.c | 102 ++++----------------- drivers/net/wireless/ath/ath6kl/testmode.h | 6 +- drivers/net/wireless/ath/ath6kl/wmi.c | 6 +- 3 files changed, 23 insertions(+), 91 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/testmode.c b/drivers/net/wireless/ath/ath6kl/testmode.c index 381eb66a605f..f0cd61d6188a 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.c +++ b/drivers/net/wireless/ath/ath6kl/testmode.c @@ -15,6 +15,7 @@ */ #include "testmode.h" +#include "debug.h" #include @@ -30,7 +31,7 @@ enum ath6kl_tm_attr { enum ath6kl_tm_cmd { ATH6KL_TM_CMD_TCMD = 0, - ATH6KL_TM_CMD_RX_REPORT = 1, + ATH6KL_TM_CMD_RX_REPORT = 1, /* not used anymore */ }; #define ATH6KL_TM_DATA_MAX_LEN 5000 @@ -41,84 +42,33 @@ static const struct nla_policy ath6kl_tm_policy[ATH6KL_TM_ATTR_MAX + 1] = { .len = ATH6KL_TM_DATA_MAX_LEN }, }; -void ath6kl_tm_rx_report_event(struct ath6kl *ar, void *buf, size_t buf_len) +void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, size_t buf_len) { - if (down_interruptible(&ar->sem)) - return; - - kfree(ar->tm.rx_report); - - ar->tm.rx_report = kmemdup(buf, buf_len, GFP_KERNEL); - ar->tm.rx_report_len = buf_len; - - up(&ar->sem); - - wake_up(&ar->event_wq); -} - -static int ath6kl_tm_rx_report(struct ath6kl *ar, void *buf, size_t buf_len, - struct sk_buff *skb) -{ - int ret = 0; - long left; - - if (down_interruptible(&ar->sem)) - return -ERESTARTSYS; - - if (!test_bit(WMI_READY, &ar->flag)) { - ret = -EIO; - goto out; - } - - if (test_bit(DESTROY_IN_PROGRESS, &ar->flag)) { - ret = -EBUSY; - goto out; - } - - if (ath6kl_wmi_test_cmd(ar->wmi, buf, buf_len) < 0) { - up(&ar->sem); - return -EIO; - } - - left = wait_event_interruptible_timeout(ar->event_wq, - ar->tm.rx_report != NULL, - WMI_TIMEOUT); + struct sk_buff *skb; - if (left == 0) { - ret = -ETIMEDOUT; - goto out; - } else if (left < 0) { - ret = left; - goto out; - } + if (!buf || buf_len == 0) + return; - if (ar->tm.rx_report == NULL || ar->tm.rx_report_len == 0) { - ret = -EINVAL; - goto out; + skb = cfg80211_testmode_alloc_event_skb(ar->wiphy, buf_len, GFP_KERNEL); + if (!skb) { + ath6kl_warn("failed to allocate testmode rx skb!\n"); + return; } - - NLA_PUT(skb, ATH6KL_TM_ATTR_DATA, ar->tm.rx_report_len, - ar->tm.rx_report); - - kfree(ar->tm.rx_report); - ar->tm.rx_report = NULL; - -out: - up(&ar->sem); - - return ret; + NLA_PUT_U32(skb, ATH6KL_TM_ATTR_CMD, ATH6KL_TM_CMD_TCMD); + NLA_PUT(skb, ATH6KL_TM_ATTR_DATA, buf_len, buf); + cfg80211_testmode_event(skb, GFP_KERNEL); + return; nla_put_failure: - ret = -ENOBUFS; - goto out; + kfree_skb(skb); + ath6kl_warn("nla_put failed on testmode rx skb!\n"); } int ath6kl_tm_cmd(struct wiphy *wiphy, void *data, int len) { struct ath6kl *ar = wiphy_priv(wiphy); struct nlattr *tb[ATH6KL_TM_ATTR_MAX + 1]; - int err, buf_len, reply_len; - struct sk_buff *skb; + int err, buf_len; void *buf; err = nla_parse(tb, ATH6KL_TM_ATTR_MAX, data, len, @@ -143,24 +93,6 @@ int ath6kl_tm_cmd(struct wiphy *wiphy, void *data, int len) break; case ATH6KL_TM_CMD_RX_REPORT: - if (!tb[ATH6KL_TM_ATTR_DATA]) - return -EINVAL; - - buf = nla_data(tb[ATH6KL_TM_ATTR_DATA]); - buf_len = nla_len(tb[ATH6KL_TM_ATTR_DATA]); - - reply_len = nla_total_size(ATH6KL_TM_DATA_MAX_LEN); - skb = cfg80211_testmode_alloc_reply_skb(wiphy, reply_len); - if (!skb) - return -ENOMEM; - - err = ath6kl_tm_rx_report(ar, buf, buf_len, skb); - if (err < 0) { - kfree_skb(skb); - return err; - } - - return cfg80211_testmode_reply(skb); default: return -EOPNOTSUPP; } diff --git a/drivers/net/wireless/ath/ath6kl/testmode.h b/drivers/net/wireless/ath/ath6kl/testmode.h index 43dffcc11fb1..7fd47a62d078 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.h +++ b/drivers/net/wireless/ath/ath6kl/testmode.h @@ -18,13 +18,13 @@ #ifdef CONFIG_NL80211_TESTMODE -void ath6kl_tm_rx_report_event(struct ath6kl *ar, void *buf, size_t buf_len); +void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, size_t buf_len); int ath6kl_tm_cmd(struct wiphy *wiphy, void *data, int len); #else -static inline void ath6kl_tm_rx_report_event(struct ath6kl *ar, void *buf, - size_t buf_len) +static inline void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, + size_t buf_len) { } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 1e31c38abb4f..c6ca660d270a 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -1145,9 +1145,9 @@ static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) return 0; } -static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len) +static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len) { - ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len); + ath6kl_tm_rx_event(wmi->parent_dev, datap, len); return 0; } @@ -3402,7 +3402,7 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) break; case WMI_TEST_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); - ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len); + ret = ath6kl_wmi_test_rx(wmi, datap, len); break; case WMI_GET_FIXRATES_CMDID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); -- GitLab From 9c636baf8518d0f986004b40669b75506459beac Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 5 Jan 2012 17:19:45 +0000 Subject: [PATCH 0015/1846] sfc: Fix some formatting errors reported by checkpatch Fix the following errors and warnings: ERROR: trailing whitespace ERROR: spaces required around that '=' (ctx:VxV) WARNING: please, no space before tabs Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/bitfield.h | 18 +++++++++--------- drivers/net/ethernet/sfc/efx.c | 16 ++++++++-------- drivers/net/ethernet/sfc/ethtool.c | 4 ++-- drivers/net/ethernet/sfc/falcon_xmac.c | 2 +- drivers/net/ethernet/sfc/mcdi_mac.c | 2 +- drivers/net/ethernet/sfc/mcdi_phy.c | 2 +- drivers/net/ethernet/sfc/mdio_10g.c | 2 +- drivers/net/ethernet/sfc/nic.c | 2 +- drivers/net/ethernet/sfc/qt202x_phy.c | 6 +++--- drivers/net/ethernet/sfc/selftest.c | 2 +- drivers/net/ethernet/sfc/spi.h | 2 +- drivers/net/ethernet/sfc/tenxpress.c | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/sfc/bitfield.h b/drivers/net/ethernet/sfc/bitfield.h index 098ac2ad757d..a2a9f40b90cf 100644 --- a/drivers/net/ethernet/sfc/bitfield.h +++ b/drivers/net/ethernet/sfc/bitfield.h @@ -448,40 +448,40 @@ typedef union efx_oword { EFX_INSERT32(min, max, low, high, EFX_MASK32(high + 1 - low)) #define EFX_SET_OWORD64(oword, low, high, value) do { \ - (oword).u64[0] = (((oword).u64[0] \ + (oword).u64[0] = (((oword).u64[0] \ & ~EFX_INPLACE_MASK64(0, 63, low, high)) \ | EFX_INSERT64(0, 63, low, high, value)); \ - (oword).u64[1] = (((oword).u64[1] \ + (oword).u64[1] = (((oword).u64[1] \ & ~EFX_INPLACE_MASK64(64, 127, low, high)) \ | EFX_INSERT64(64, 127, low, high, value)); \ } while (0) #define EFX_SET_QWORD64(qword, low, high, value) do { \ - (qword).u64[0] = (((qword).u64[0] \ + (qword).u64[0] = (((qword).u64[0] \ & ~EFX_INPLACE_MASK64(0, 63, low, high)) \ | EFX_INSERT64(0, 63, low, high, value)); \ } while (0) #define EFX_SET_OWORD32(oword, low, high, value) do { \ - (oword).u32[0] = (((oword).u32[0] \ + (oword).u32[0] = (((oword).u32[0] \ & ~EFX_INPLACE_MASK32(0, 31, low, high)) \ | EFX_INSERT32(0, 31, low, high, value)); \ - (oword).u32[1] = (((oword).u32[1] \ + (oword).u32[1] = (((oword).u32[1] \ & ~EFX_INPLACE_MASK32(32, 63, low, high)) \ | EFX_INSERT32(32, 63, low, high, value)); \ - (oword).u32[2] = (((oword).u32[2] \ + (oword).u32[2] = (((oword).u32[2] \ & ~EFX_INPLACE_MASK32(64, 95, low, high)) \ | EFX_INSERT32(64, 95, low, high, value)); \ - (oword).u32[3] = (((oword).u32[3] \ + (oword).u32[3] = (((oword).u32[3] \ & ~EFX_INPLACE_MASK32(96, 127, low, high)) \ | EFX_INSERT32(96, 127, low, high, value)); \ } while (0) #define EFX_SET_QWORD32(qword, low, high, value) do { \ - (qword).u32[0] = (((qword).u32[0] \ + (qword).u32[0] = (((qword).u32[0] \ & ~EFX_INPLACE_MASK32(0, 31, low, high)) \ | EFX_INSERT32(0, 31, low, high, value)); \ - (qword).u32[1] = (((qword).u32[1] \ + (qword).u32[1] = (((qword).u32[1] \ & ~EFX_INPLACE_MASK32(32, 63, low, high)) \ | EFX_INSERT32(32, 63, low, high, value)); \ } while (0) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index e43702f33b62..11cc585c36a4 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -44,9 +44,9 @@ const char *efx_loopback_mode_names[] = { [LOOPBACK_GMAC] = "GMAC", [LOOPBACK_XGMII] = "XGMII", [LOOPBACK_XGXS] = "XGXS", - [LOOPBACK_XAUI] = "XAUI", - [LOOPBACK_GMII] = "GMII", - [LOOPBACK_SGMII] = "SGMII", + [LOOPBACK_XAUI] = "XAUI", + [LOOPBACK_GMII] = "GMII", + [LOOPBACK_SGMII] = "SGMII", [LOOPBACK_XGBR] = "XGBR", [LOOPBACK_XFI] = "XFI", [LOOPBACK_XAUI_FAR] = "XAUI_FAR", @@ -55,17 +55,17 @@ const char *efx_loopback_mode_names[] = { [LOOPBACK_XFI_FAR] = "XFI_FAR", [LOOPBACK_GPHY] = "GPHY", [LOOPBACK_PHYXS] = "PHYXS", - [LOOPBACK_PCS] = "PCS", - [LOOPBACK_PMAPMD] = "PMA/PMD", + [LOOPBACK_PCS] = "PCS", + [LOOPBACK_PMAPMD] = "PMA/PMD", [LOOPBACK_XPORT] = "XPORT", [LOOPBACK_XGMII_WS] = "XGMII_WS", - [LOOPBACK_XAUI_WS] = "XAUI_WS", + [LOOPBACK_XAUI_WS] = "XAUI_WS", [LOOPBACK_XAUI_WS_FAR] = "XAUI_WS_FAR", [LOOPBACK_XAUI_WS_NEAR] = "XAUI_WS_NEAR", - [LOOPBACK_GMII_WS] = "GMII_WS", + [LOOPBACK_GMII_WS] = "GMII_WS", [LOOPBACK_XFI_WS] = "XFI_WS", [LOOPBACK_XFI_WS_FAR] = "XFI_WS_FAR", - [LOOPBACK_PHYXS_WS] = "PHYXS_WS", + [LOOPBACK_PHYXS_WS] = "PHYXS_WS", }; const unsigned int efx_reset_type_max = RESET_TYPE_MAX; diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 29b2ebfef19f..c090de4e66c3 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -68,11 +68,11 @@ static u64 efx_get_atomic_stat(void *field) } #define EFX_ETHTOOL_ULONG_MAC_STAT(field) \ - EFX_ETHTOOL_STAT(field, mac_stats, field, \ + EFX_ETHTOOL_STAT(field, mac_stats, field, \ unsigned long, efx_get_ulong_stat) #define EFX_ETHTOOL_U64_MAC_STAT(field) \ - EFX_ETHTOOL_STAT(field, mac_stats, field, \ + EFX_ETHTOOL_STAT(field, mac_stats, field, \ u64, efx_get_u64_stat) #define EFX_ETHTOOL_UINT_NIC_STAT(name) \ diff --git a/drivers/net/ethernet/sfc/falcon_xmac.c b/drivers/net/ethernet/sfc/falcon_xmac.c index 9516452c079c..57434593f07b 100644 --- a/drivers/net/ethernet/sfc/falcon_xmac.c +++ b/drivers/net/ethernet/sfc/falcon_xmac.c @@ -139,7 +139,7 @@ static bool falcon_xmac_link_ok(struct efx_nic *efx) return (efx->loopback_mode == LOOPBACK_XGMII || falcon_xgxs_link_ok(efx)) && (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) || - LOOPBACK_INTERNAL(efx) || + LOOPBACK_INTERNAL(efx) || efx_mdio_phyxgxs_lane_sync(efx)); } diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index 50c20777a564..aa4052c500fa 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -141,5 +141,5 @@ static bool efx_mcdi_mac_check_fault(struct efx_nic *efx) const struct efx_mac_operations efx_mcdi_mac_operations = { .reconfigure = efx_mcdi_mac_reconfigure, .update_stats = efx_port_dummy_op_void, - .check_fault = efx_mcdi_mac_check_fault, + .check_fault = efx_mcdi_mac_check_fault, }; diff --git a/drivers/net/ethernet/sfc/mcdi_phy.c b/drivers/net/ethernet/sfc/mcdi_phy.c index 6c63ab0710af..3077bf1e7dfe 100644 --- a/drivers/net/ethernet/sfc/mcdi_phy.c +++ b/drivers/net/ethernet/sfc/mcdi_phy.c @@ -741,7 +741,7 @@ static const char *efx_mcdi_phy_test_name(struct efx_nic *efx, const struct efx_phy_operations efx_mcdi_phy_ops = { .probe = efx_mcdi_phy_probe, - .init = efx_port_dummy_op_int, + .init = efx_port_dummy_op_int, .reconfigure = efx_mcdi_phy_reconfigure, .poll = efx_mcdi_phy_poll, .fini = efx_port_dummy_op_void, diff --git a/drivers/net/ethernet/sfc/mdio_10g.c b/drivers/net/ethernet/sfc/mdio_10g.c index 7ab385c8136d..9acfd6696ffb 100644 --- a/drivers/net/ethernet/sfc/mdio_10g.c +++ b/drivers/net/ethernet/sfc/mdio_10g.c @@ -228,7 +228,7 @@ void efx_mdio_set_mmds_lpower(struct efx_nic *efx, /** * efx_mdio_set_settings - Set (some of) the PHY settings over MDIO. * @efx: Efx NIC - * @ecmd: New settings + * @ecmd: New settings */ int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) { diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 3edfbaf5f022..b1df2f39c8f0 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -1837,7 +1837,7 @@ struct efx_nic_reg_table { REGISTER_REVISION_ ## min_rev, REGISTER_REVISION_ ## max_rev, \ step, rows \ } -#define REGISTER_TABLE(name, min_rev, max_rev) \ +#define REGISTER_TABLE(name, min_rev, max_rev) \ REGISTER_TABLE_DIMENSIONS( \ name, FR_ ## min_rev ## max_rev ## _ ## name, \ min_rev, max_rev, \ diff --git a/drivers/net/ethernet/sfc/qt202x_phy.c b/drivers/net/ethernet/sfc/qt202x_phy.c index 7ad97e397406..8a7caf88ffb6 100644 --- a/drivers/net/ethernet/sfc/qt202x_phy.c +++ b/drivers/net/ethernet/sfc/qt202x_phy.c @@ -47,7 +47,7 @@ #define PMA_PMD_FTX_STATIC_LBN 13 #define PMA_PMD_VEND1_REG 0xc001 #define PMA_PMD_VEND1_LBTXD_LBN 15 -#define PCS_VEND1_REG 0xc000 +#define PCS_VEND1_REG 0xc000 #define PCS_VEND1_LBTXD_LBN 5 void falcon_qt202x_set_led(struct efx_nic *p, int led, int mode) @@ -453,9 +453,9 @@ const struct efx_phy_operations falcon_qt202x_phy_ops = { .probe = qt202x_phy_probe, .init = qt202x_phy_init, .reconfigure = qt202x_phy_reconfigure, - .poll = qt202x_phy_poll, + .poll = qt202x_phy_poll, .fini = efx_port_dummy_op_void, - .remove = qt202x_phy_remove, + .remove = qt202x_phy_remove, .get_settings = qt202x_phy_get_settings, .set_settings = efx_mdio_set_settings, .test_alive = efx_mdio_test_alive, diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 52edd24fcde3..fc62fe2f766f 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -445,7 +445,7 @@ static int efx_end_loopback(struct efx_tx_queue *tx_queue, /* Count the number of tx completions, and decrement the refcnt. Any * skbs not already completed will be free'd when the queue is flushed */ - for (i=0; i < state->packet_count; i++) { + for (i = 0; i < state->packet_count; i++) { skb = state->skbs[i]; if (skb && !skb_shared(skb)) ++tx_done; diff --git a/drivers/net/ethernet/sfc/spi.h b/drivers/net/ethernet/sfc/spi.h index 71f2e3ebe1c7..5431a1bbff5c 100644 --- a/drivers/net/ethernet/sfc/spi.h +++ b/drivers/net/ethernet/sfc/spi.h @@ -68,7 +68,7 @@ static inline bool efx_spi_present(const struct efx_spi_device *spi) int falcon_spi_cmd(struct efx_nic *efx, const struct efx_spi_device *spi, unsigned int command, - int address, const void* in, void *out, size_t len); + int address, const void *in, void *out, size_t len); int falcon_spi_wait_write(struct efx_nic *efx, const struct efx_spi_device *spi); int falcon_spi_read(struct efx_nic *efx, diff --git a/drivers/net/ethernet/sfc/tenxpress.c b/drivers/net/ethernet/sfc/tenxpress.c index 7b0fd89e7b85..d37cb5017129 100644 --- a/drivers/net/ethernet/sfc/tenxpress.c +++ b/drivers/net/ethernet/sfc/tenxpress.c @@ -121,7 +121,7 @@ #define GPHY_XCONTROL_REG 49152 #define GPHY_ISOLATE_LBN 10 #define GPHY_ISOLATE_WIDTH 1 -#define GPHY_DUPLEX_LBN 8 +#define GPHY_DUPLEX_LBN 8 #define GPHY_DUPLEX_WIDTH 1 #define GPHY_LOOPBACK_NEAR_LBN 14 #define GPHY_LOOPBACK_NEAR_WIDTH 1 -- GitLab From e9e01846c7e18a3b5682b54e50f1005949737bd9 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 5 Jan 2012 18:50:29 +0000 Subject: [PATCH 0016/1846] sfc: Avoid assignment in an if-statement, reported by checkpatch Fix the following error: ERROR: do not use assignment in if condition Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 11cc585c36a4..0539a8d88a23 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1069,9 +1069,11 @@ static int efx_init_io(struct efx_nic *efx) * masks event though they reject 46 bit masks. */ while (dma_mask > 0x7fffffffUL) { - if (pci_dma_supported(pci_dev, dma_mask) && - ((rc = pci_set_dma_mask(pci_dev, dma_mask)) == 0)) - break; + if (pci_dma_supported(pci_dev, dma_mask)) { + rc = pci_set_dma_mask(pci_dev, dma_mask); + if (rc == 0) + break; + } dma_mask >>= 1; } if (rc) { -- GitLab From 0beaca2ca0b3c12dabab046f1541b09179ec449c Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 5 Jan 2012 18:54:04 +0000 Subject: [PATCH 0017/1846] sfc: Remove parentheses around return expressions, reported by checkpatch Fix the following error: ERROR: return is not a function, parentheses are not required Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/rx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index aca349861767..3572c34a79fb 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -98,8 +98,8 @@ static inline unsigned int efx_rx_buf_offset(struct efx_nic *efx, /* Offset is always within one page, so we don't need to consider * the page order. */ - return (((__force unsigned long) buf->dma_addr & (PAGE_SIZE - 1)) + - efx->type->rx_buffer_hash_size); + return ((__force unsigned long) buf->dma_addr & (PAGE_SIZE - 1)) + + efx->type->rx_buffer_hash_size; } static inline unsigned int efx_rx_buf_size(struct efx_nic *efx) { @@ -111,8 +111,7 @@ static u8 *efx_rx_buf_eh(struct efx_nic *efx, struct efx_rx_buffer *buf) if (buf->is_page) return page_address(buf->u.page) + efx_rx_buf_offset(efx, buf); else - return ((u8 *)buf->u.skb->data + - efx->type->rx_buffer_hash_size); + return (u8 *)buf->u.skb->data + efx->type->rx_buffer_hash_size; } static inline u32 efx_rx_buf_hash(const u8 *eh) @@ -122,10 +121,10 @@ static inline u32 efx_rx_buf_hash(const u8 *eh) return __le32_to_cpup((const __le32 *)(eh - 4)); #else const u8 *data = eh - 4; - return ((u32)data[0] | - (u32)data[1] << 8 | - (u32)data[2] << 16 | - (u32)data[3] << 24); + return (u32)data[0] | + (u32)data[1] << 8 | + (u32)data[2] << 16 | + (u32)data[3] << 24; #endif } -- GitLab From 64eeacb7f0317e5f3d6f0f63399ed00b4b2b7dc0 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 16 Dec 2011 09:31:14 -0800 Subject: [PATCH 0018/1846] iwlwifi: don't process the info from uCode if does not has ownership When enable the testmode from user space and working with uCode, driver does not own the uCode and should not process the notifications or pkts from uCode Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index b22b2976f899..eda95ae88ef1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1172,20 +1172,22 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, wake_up_all(&priv->shrd->notif_waitq); } - if (priv->pre_rx_handler) + if (priv->pre_rx_handler && + priv->shrd->ucode_owner == IWL_OWNERSHIP_TM) priv->pre_rx_handler(priv, rxb); - - /* Based on type of command response or notification, - * handle those that need handling via function in - * rx_handlers table. See iwl_setup_rx_handlers() */ - if (priv->rx_handlers[pkt->hdr.cmd]) { - priv->rx_handlers_stats[pkt->hdr.cmd]++; - err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd); - } else { - /* No handling needed */ - IWL_DEBUG_RX(priv, - "No handler needed for %s, 0x%02x\n", - get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + else { + /* Based on type of command response or notification, + * handle those that need handling via function in + * rx_handlers table. See iwl_setup_rx_handlers() */ + if (priv->rx_handlers[pkt->hdr.cmd]) { + priv->rx_handlers_stats[pkt->hdr.cmd]++; + err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd); + } else { + /* No handling needed */ + IWL_DEBUG_RX(priv, + "No handler needed for %s, 0x%02x\n", + get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + } } return err; } -- GitLab From d75140120971964dca1eee9aa5c9ab25bf0f664f Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 16 Dec 2011 07:31:35 -0800 Subject: [PATCH 0019/1846] iwlwifi: Sanity check for sta_id On my testing, I saw some strange behavior [ 421.739708] iwlwifi 0000:01:00.0: ACTIVATE a non DRIVER active station id 148 addr 00:00:00:00:00:00 [ 421.739719] iwlwifi 0000:01:00.0: iwl_sta_ucode_activate Added STA id 148 addr 00:00:00:00:00:00 to uCode not sure how it happen, but adding the sanity check to prevent memory corruption Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 7353826095f1..8d4353a42568 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -35,9 +35,12 @@ #include "iwl-trans.h" /* priv->shrd->sta_lock must be held */ -static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) +static int iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) { - + if (sta_id >= IWLAGN_STATION_COUNT) { + IWL_ERR(priv, "invalid sta_id %u", sta_id); + return -EINVAL; + } if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u " "addr %pM\n", @@ -53,6 +56,7 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", sta_id, priv->stations[sta_id].sta.sta.addr); } + return 0; } static int iwl_process_add_sta_resp(struct iwl_priv *priv, @@ -77,8 +81,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); - iwl_sta_ucode_activate(priv, sta_id); - ret = 0; + ret = iwl_sta_ucode_activate(priv, sta_id); break; case ADD_STA_NO_ROOM_IN_TABLE: IWL_ERR(priv, "Adding station %d failed, no room in table.\n", -- GitLab From c381be2853bbe4bc1bd6fee88f0a33041de65d06 Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Fri, 23 Dec 2011 14:50:48 +0800 Subject: [PATCH 0020/1846] iwlwifi: update testmode command of direct register access In order to make sure the testcommand function of direct register access can be performed even NIC is asleep, replace corresponding handler iwl_read32 and iwl_write32 by using iwl_direct_read32 and iwl_direct_write32. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 4a5cddd2d56b..2fc20675dc7b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -299,7 +299,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - val32 = iwl_read32(bus(priv), ofs); + val32 = iwl_read_direct32(bus(priv), ofs); IWL_INFO(priv, "32bit value to read 0x%x\n", val32); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); @@ -321,7 +321,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) } 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); + iwl_write_direct32(bus(priv), ofs, val32); } break; case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: -- GitLab From 25324caf6e3fc8134444af74fc85182862d520cc Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Tue, 27 Dec 2011 08:18:31 -0800 Subject: [PATCH 0021/1846] iwlwifi: enhance testmode command sram_read This patch enables SRAM read function to support entire target memory. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 7 +++---- drivers/net/wireless/iwlwifi/iwl-testmode.h | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 2fc20675dc7b..58575fdc4504 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -733,7 +733,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, maxsize; + u32 ofs, size, maxsize; if (priv->testmode_sram.sram_readed) return -EBUSY; @@ -765,7 +765,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); return -ENOSYS; } - if ((ofs + size) > maxsize) { + if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) { IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); return -EINVAL; } @@ -776,8 +776,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) IWL_DEBUG_INFO(priv, "Error allocating memory\n"); return -ENOMEM; } - base = 0x800000; - _iwl_read_targ_mem_words(bus(priv), base + ofs, + _iwl_read_targ_mem_words(bus(priv), ofs, priv->testmode_sram.buff_addr, priv->testmode_sram.buff_size / 4); priv->testmode_sram.num_chunks = diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 26138f110340..9c6a67ab5c34 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -271,4 +271,7 @@ enum iwl_tm_attr_t { /* Maximum data size of each dump it packet */ #define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024) +/* Address offset of data segment in SRAM */ +#define SRAM_DATA_SEG_OFFSET 0x800000 + #endif -- GitLab From 22b48087ea4df1841c2507173c98e6b4f26fe64d Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Tue, 27 Dec 2011 08:27:52 -0800 Subject: [PATCH 0022/1846] iwlwifi: update error dump in testmode command sram_read The error message will be show up by using IWL_ERR insteads of IWl_DEBUG_INFO. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 58575fdc4504..b56cd900805c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -759,21 +759,21 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) maxsize = trans(priv)->ucode_wowlan.data.len; break; case IWL_UCODE_NONE: - IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); + IWL_ERR(priv, "Error, uCode does not been loaded\n"); return -ENOSYS; default: - IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); + IWL_ERR(priv, "Error, unsupported uCode type\n"); return -ENOSYS; } if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) { - IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); + IWL_ERR(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"); + IWL_ERR(priv, "Error allocating memory\n"); return -ENOMEM; } _iwl_read_targ_mem_words(bus(priv), ofs, -- GitLab From aca9b5f34352248a23c4d776afebf171e711090b Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Sat, 24 Dec 2011 12:12:12 +0800 Subject: [PATCH 0023/1846] iwlwifi: add testmode cmd IWL_TM_CMD_APP2DEV_GET_FW_INFO Add new testmode command IWL_TM_CMD_APP2DEV_GET_FW_INFO for reporting the following information of existing loaded uCode image. + uCode type + Instruction section size + Data section size Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 41 ++++++++++++++++++++- drivers/net/wireless/iwlwifi/iwl-testmode.h | 19 +++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index b56cd900805c..7684c0e2f21a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -115,6 +115,9 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, }, + [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, }, }; /* @@ -422,7 +425,7 @@ 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; - u32 devid; + u32 devid, inst_size = 0, data_size = 0; switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: @@ -548,6 +551,41 @@ 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_FW_INFO: + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + switch (priv->shrd->ucode_type) { + case IWL_UCODE_REGULAR: + inst_size = trans(priv)->ucode_rt.code.len; + data_size = trans(priv)->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + inst_size = trans(priv)->ucode_init.code.len; + data_size = trans(priv)->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + inst_size = trans(priv)->ucode_wowlan.code.len; + data_size = trans(priv)->ucode_wowlan.data.len; + break; + case IWL_UCODE_NONE: + IWL_DEBUG_INFO(priv, "The uCode has not been loaded\n"); + break; + default: + IWL_DEBUG_INFO(priv, "Unsupported uCode type\n"); + break; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type); + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size); + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size); + 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; @@ -881,6 +919,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: + case IWL_TM_CMD_APP2DEV_GET_FW_INFO: 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 9c6a67ab5c34..cb0cf35f91b5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -120,6 +120,8 @@ * @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 + * @IWL_TM_CMD_APP2DEV_GET_FW_INFO: + * retrieve informration of existing loaded uCode image * */ enum iwl_tm_cmd_t { @@ -147,7 +149,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23, IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24, - IWL_TM_CMD_MAX = 25, + IWL_TM_CMD_APP2DEV_GET_FW_INFO = 25, + IWL_TM_CMD_MAX = 26, }; /* @@ -237,6 +240,15 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_DEVICE_ID, * IWL_TM_ATTR_DEVICE_ID for the device ID information * + * @IWL_TM_ATTR_FW_TYPE: + * @IWL_TM_ATTR_FW_INST_SIZE: + * @IWL_TM_ATTR_FW_DATA_SIZE: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_INFO, + * The mandatory fields are: + * IWL_TM_ATTR_FW_TYPE for the uCode type (INIT/RUNTIME/...) + * IWL_TM_ATTR_FW_INST_SIZE for the size of instruction section + * IWL_TM_ATTR_FW_DATA_SIZE for the size of data section + * */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -259,7 +271,10 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_SRAM_DUMP = 17, IWL_TM_ATTR_FW_VERSION = 18, IWL_TM_ATTR_DEVICE_ID = 19, - IWL_TM_ATTR_MAX = 20, + IWL_TM_ATTR_FW_TYPE = 20, + IWL_TM_ATTR_FW_INST_SIZE = 21, + IWL_TM_ATTR_FW_DATA_SIZE = 22, + IWL_TM_ATTR_MAX = 23, }; /* uCode trace buffer */ -- GitLab From 4e3182626a914443a5e0fbe014813f03e51a75df Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Tue, 27 Dec 2011 11:21:32 -0800 Subject: [PATCH 0024/1846] iwlwifi: update Copyright Update Copyright to 2012 Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-1000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-2000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-5000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-6000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-calib.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-hw.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.h | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.h | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-bus.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-cfg.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-commands.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-core.c | 2 +- drivers/net/wireless/iwlwifi/iwl-core.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-csr.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-debug.h | 2 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +- drivers/net/wireless/iwlwifi/iwl-devtrace.c | 2 +- drivers/net/wireless/iwlwifi/iwl-devtrace.h | 2 +- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-eeprom.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-fh.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-io.c | 2 +- drivers/net/wireless/iwlwifi/iwl-io.h | 2 +- drivers/net/wireless/iwlwifi/iwl-led.c | 2 +- drivers/net/wireless/iwlwifi/iwl-led.h | 2 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- drivers/net/wireless/iwlwifi/iwl-pci.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-power.c | 2 +- drivers/net/wireless/iwlwifi/iwl-power.h | 2 +- drivers/net/wireless/iwlwifi/iwl-prph.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-scan.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 6 +++--- drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-testmode.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-wifi.h | 4 ++-- 53 files changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 1ef7bfc2ab25..cc04cce11567 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 094693328dbb..00db092d8cd0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index b3a365fea7bb..47fd98b3652c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 54b753399e6e..ab62c018fcdb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 50ff849c9f67..6aa009827865 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h index 10275ce92bde..9ed6683314a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h index 123ef5e129d5..d0ec0abd3c89 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 64cf439035c3..a8f7689aaacf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 334b5ae8fdd4..b9ba404d15c1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h index 6675b3c816d9..203b1c13c491 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index eda95ae88ef1..f127f913e5a6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portionhelp of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 1c6659416621..8ca9570ec365 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 8d4353a42568..d6aab00272b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index b0dff7a753a5..56c6def015a4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.h b/drivers/net/wireless/iwlwifi/iwl-agn-tt.h index 7282a23e8f1c..86bbf47501c1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index c664c2726553..a8c6880af34b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index b5c7c5f0a753..7321e7d31406 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index f84fb3c53563..39cbe1a1577c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 940d5038b39c..941b9cb23442 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h index e1d78257e4a9..957bc00cdaf0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-cfg.h +++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 265de39d394c..b4779c25a4b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 7bcfa781e0b9..7d6eef96454a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 7bf76ab94dd2..63f29111da13 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h index fbc3095c7b44..5f96ce105f08 100644 --- a/drivers/net/wireless/iwlwifi/iwl-csr.h +++ b/drivers/net/wireless/iwlwifi/iwl-csr.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index f8fc2393dd4c..6f7612781e03 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project. * diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 04a3343f4610..f837f32bb71c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index e54a4d11e584..4579d61da25e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/iwlwifi/iwl-devtrace.c index 2a2c8de64a04..91f45e71e0a2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.c +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h index 9b212a8f30bb..4d892211ce4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index c1eda9724f42..e27d9f55267b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 9fa937ec35e3..13f2d3928ef8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h index 5bede9d7f955..90208094b8eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fh.h +++ b/drivers/net/wireless/iwlwifi/iwl-fh.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index d57ea6484bbe..83fdff381150 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project. * diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index aae2eeb331a8..427d065435c8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project. * diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 14dcbfcdc0fd..eca79087afb8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h index 2550b3c7dcbf..b02a853103d3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.h +++ b/drivers/net/wireless/iwlwifi/iwl-led.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index f980e574e1f9..965d0475affd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index fb30ea7ca96b..03702a2e913a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index 2b188a6025b3..c7394ef2e490 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h index 5f7b720cf1a4..07a19fce5fdc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.h +++ b/drivers/net/wireless/iwlwifi/iwl-power.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h index bebdd828f324..a4d11016c3b4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-prph.h +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 084aa2c4ccfb..2cd5b4f59931 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index dc55cc4a8108..e406d49f4189 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,7 @@ struct iwl_trans_ops; #define DRV_NAME "iwlwifi" #define IWLWIFI_VERSION "in-tree:" -#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" +#define DRV_COPYRIGHT "Copyright(c) 2003-2012 Intel Corporation" #define DRV_AUTHOR "" extern struct iwl_mod_params iwlagn_mod_params; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 7684c0e2f21a..a56a77b8f926 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index cb0cf35f91b5..185b69ef7539 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index f6debf91d7b5..0ac9b4d30271 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 752493f00406..848c598bfadb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index bd29568177e6..30814b55705e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 67d6e324e26f..5e6af4ba9652 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c index 1b20c4fb791b..506c062343b2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index e6bf3f554772..42a9f303f543 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 36a1b5b25858..2edf0ef65a5b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index 18501101a530..7e6eb20823cf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- GitLab From 3f3c4ee735ff0957a53b9dccae66c8e5ead25b17 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 3 Jan 2012 14:41:59 +0530 Subject: [PATCH 0025/1846] ath6kl: Add a function in wmi to send WMI_MCAST_FILTER_CMDID This will be used to disable/enable multicast receive. Signed-off-by: Vasanthakumar Thiagarajan --- drivers/net/wireless/ath/ath6kl/wmi.c | 17 +++++++++++++++++ drivers/net/wireless/ath/ath6kl/wmi.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index c6ca660d270a..d3eec0761eaa 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2855,6 +2855,23 @@ int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) return ret; } +int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on) +{ + struct sk_buff *skb; + struct wmi_mcast_filter_cmd *cmd; + int ret; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_mcast_filter_cmd *) skb->data; + cmd->mcast_all_enable = mc_all_on; + + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID, + NO_SYNC_WMIFLAG); + return ret; +} s32 ath6kl_wmi_get_rate(s8 rate_index) { diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 2b435994b013..dc7045711551 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1239,6 +1239,10 @@ enum target_event_report_config { NO_DISCONN_EVT_IN_RECONN }; +struct wmi_mcast_filter_cmd { + u8 mcast_all_enable; +} __packed; + /* Command Replies */ /* WMI_GET_CHANNEL_LIST_CMDID reply */ @@ -2434,6 +2438,7 @@ int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi); int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid); int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode); +int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on); /* AP mode */ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, -- GitLab From f914edd38920369d8926261f9ab72da6756c3e0c Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 3 Jan 2012 14:42:00 +0530 Subject: [PATCH 0026/1846] ath6kl: Add a function in wmi.c to add/delete a multicast filter Signed-off-by: Vasanthakumar Thiagarajan --- drivers/net/wireless/ath/ath6kl/wmi.c | 28 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/wmi.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index d3eec0761eaa..08fbd9a9be4b 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2873,6 +2873,34 @@ int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on) return ret; } +int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, + u8 *filter, bool add_filter) +{ + struct sk_buff *skb; + struct wmi_mcast_filter_add_del_cmd *cmd; + int ret; + + if ((filter[0] != 0x33 || filter[1] != 0x33) && + (filter[0] != 0x01 || filter[1] != 0x00 || + filter[2] != 0x5e || filter[3] > 0x7f)) { + ath6kl_warn("invalid multicast filter address\n"); + return -EINVAL; + } + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data; + memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE); + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, + add_filter ? WMI_SET_MCAST_FILTER_CMDID : + WMI_DEL_MCAST_FILTER_CMDID, + NO_SYNC_WMIFLAG); + + return ret; +} + s32 ath6kl_wmi_get_rate(s8 rate_index) { if (rate_index == RATE_AUTO) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index dc7045711551..eae0e4e065c4 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1243,6 +1243,11 @@ struct wmi_mcast_filter_cmd { u8 mcast_all_enable; } __packed; +#define ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE 6 +struct wmi_mcast_filter_add_del_cmd { + u8 mcast_mac[ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE]; +} __packed; + /* Command Replies */ /* WMI_GET_CHANNEL_LIST_CMDID reply */ @@ -2439,6 +2444,8 @@ int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi); int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid); int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode); int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on); +int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, + u8 *filter, bool add_filter); /* AP mode */ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, -- GitLab From 80abaf9b4c920cab044e185ed4327f801c1ff99d Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 3 Jan 2012 14:42:01 +0530 Subject: [PATCH 0027/1846] ath6kl: Implement ndo_set_rx_mode() There are maximum of seven multicast filter are supported by hw. When the requested number of filters exceeds the maximum supported one, multicast filtering is completely disabled, the requested filters will be configured in firmware and the only multicast frames that host is interested in will be passed to host for further processing otherwise. Signed-off-by: Vasanthakumar Thiagarajan --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 8 ++ drivers/net/wireless/ath/ath6kl/core.h | 9 ++ drivers/net/wireless/ath/ath6kl/main.c | 110 +++++++++++++++++++++ 3 files changed, 127 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2a166cc7cc3c..14f180eac485 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2818,12 +2818,15 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif) set_bit(WMM_ENABLED, &vif->flags); spin_lock_init(&vif->if_lock); + INIT_LIST_HEAD(&vif->mc_filter); + return 0; } void ath6kl_deinit_if_data(struct ath6kl_vif *vif) { struct ath6kl *ar = vif->ar; + struct ath6kl_mc_filter *mc_filter, *tmp; aggr_module_destroy(vif->aggr_cntxt); @@ -2832,6 +2835,11 @@ void ath6kl_deinit_if_data(struct ath6kl_vif *vif) if (vif->nw_type == ADHOC_NETWORK) ar->ibss_if_active = false; + list_for_each_entry_safe(mc_filter, tmp, &vif->mc_filter, list) { + list_del(&mc_filter->list); + kfree(mc_filter); + } + unregister_netdevice(vif->ndev); ar->num_vif--; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index c095fafa278f..793c6a58f0fd 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -410,6 +410,13 @@ enum ath6kl_hif_type { ATH6KL_HIF_TYPE_USB, }; +/* Max number of filters that hw supports */ +#define ATH6K_MAX_MC_FILTERS_PER_LIST 7 +struct ath6kl_mc_filter { + struct list_head list; + char hw_addr[ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE]; +}; + /* * Driver's maximum limit, note that some firmwares support only one vif * and the runtime (current) limit must be checked from ar->vif_max. @@ -473,6 +480,8 @@ struct ath6kl_vif { u8 assoc_bss_dtim_period; struct net_device_stats net_stats; struct target_stats target_stats; + + struct list_head mc_filter; }; #define WOW_LIST_ID 0 diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index f74986d62098..cffbc62ee793 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1052,12 +1052,122 @@ static int ath6kl_set_features(struct net_device *dev, u32 features) return err; } +static void ath6kl_set_multicast_list(struct net_device *ndev) +{ + struct ath6kl_vif *vif = netdev_priv(ndev); + bool mc_all_on = false, mc_all_off = false; + int mc_count = netdev_mc_count(ndev); + struct netdev_hw_addr *ha; + bool found; + struct ath6kl_mc_filter *mc_filter, *tmp; + struct list_head mc_filter_new; + int ret; + + if (!test_bit(WMI_READY, &vif->ar->flag) || + !test_bit(WLAN_ENABLED, &vif->flags)) + return; + + mc_all_on = !!(ndev->flags & IFF_PROMISC) || + !!(ndev->flags & IFF_ALLMULTI) || + !!(mc_count > ATH6K_MAX_MC_FILTERS_PER_LIST); + + mc_all_off = !(ndev->flags & IFF_MULTICAST) || mc_count == 0; + + if (mc_all_on || mc_all_off) { + /* Enable/disable all multicast */ + ath6kl_dbg(ATH6KL_DBG_TRC, "%s multicast filter\n", + mc_all_on ? "enabling" : "disabling"); + ret = ath6kl_wmi_mcast_filter_cmd(vif->ar->wmi, vif->fw_vif_idx, + mc_all_on); + if (ret) + ath6kl_warn("Failed to %s multicast receive\n", + mc_all_on ? "enable" : "disable"); + return; + } + + list_for_each_entry_safe(mc_filter, tmp, &vif->mc_filter, list) { + found = false; + netdev_for_each_mc_addr(ha, ndev) { + if (memcmp(ha->addr, mc_filter->hw_addr, + ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE) == 0) { + found = true; + break; + } + } + + if (!found) { + /* + * Delete the filter which was previously set + * but not in the new request. + */ + ath6kl_dbg(ATH6KL_DBG_TRC, + "Removing %pM from multicast filter\n", + mc_filter->hw_addr); + ret = ath6kl_wmi_add_del_mcast_filter_cmd(vif->ar->wmi, + vif->fw_vif_idx, mc_filter->hw_addr, + false); + if (ret) { + ath6kl_warn("Failed to remove multicast filter:%pM\n", + mc_filter->hw_addr); + return; + } + + list_del(&mc_filter->list); + kfree(mc_filter); + } + } + + INIT_LIST_HEAD(&mc_filter_new); + + netdev_for_each_mc_addr(ha, ndev) { + found = false; + list_for_each_entry(mc_filter, &vif->mc_filter, list) { + if (memcmp(ha->addr, mc_filter->hw_addr, + ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE) == 0) { + found = true; + break; + } + } + + if (!found) { + mc_filter = kzalloc(sizeof(struct ath6kl_mc_filter), + GFP_ATOMIC); + if (!mc_filter) { + WARN_ON(1); + goto out; + } + + memcpy(mc_filter->hw_addr, ha->addr, + ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE); + /* Set the multicast filter */ + ath6kl_dbg(ATH6KL_DBG_TRC, + "Adding %pM to multicast filter list\n", + mc_filter->hw_addr); + ret = ath6kl_wmi_add_del_mcast_filter_cmd(vif->ar->wmi, + vif->fw_vif_idx, mc_filter->hw_addr, + true); + if (ret) { + ath6kl_warn("Failed to add multicast filter :%pM\n", + mc_filter->hw_addr); + kfree(mc_filter); + goto out; + } + + list_add_tail(&mc_filter->list, &mc_filter_new); + } + } + +out: + list_splice_tail(&mc_filter_new, &vif->mc_filter); +} + static struct net_device_ops ath6kl_netdev_ops = { .ndo_open = ath6kl_open, .ndo_stop = ath6kl_close, .ndo_start_xmit = ath6kl_data_tx, .ndo_get_stats = ath6kl_get_stats, .ndo_set_features = ath6kl_set_features, + .ndo_set_rx_mode = ath6kl_set_multicast_list, }; void init_netdev(struct net_device *dev) -- GitLab From 3d6aba260bcd5a5f9d47056cac2e313ce986ad12 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 3 Jan 2012 15:19:02 +0530 Subject: [PATCH 0028/1846] ath6kl: Remove deadcode in main.c In ath6kl_reset_device(), since control can never reach switch..case when the target_type is neither TARGET_TYPE_AR6003 nor TARGET_TYPE_AR6004, remove the default option of switch statement. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index cffbc62ee793..d764768f8f7a 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -347,9 +347,6 @@ void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, case TARGET_TYPE_AR6004: address = AR6004_RESET_CONTROL_ADDRESS; break; - default: - address = AR6003_RESET_CONTROL_ADDRESS; - break; } status = ath6kl_diag_write32(ar, address, data); -- GitLab From 982767b8c94482b4b7f694e2ab2074c95fbf3e0e Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 3 Jan 2012 15:28:53 +0530 Subject: [PATCH 0029/1846] ath6kl: Change ielen in ath6kl_add_new_sta() from u8 to size_t Otherwise if (ielen <= ATH6KL_MAX_IE) is dead code. It looks safe to change the type of ielen from u8 to size_t instead of removing this if check, this ielen can have the length of more than one ies in future. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index d764768f8f7a..325d316f40ec 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -53,7 +53,7 @@ struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid) } static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie, - u8 ielen, u8 keymgmt, u8 ucipher, u8 auth) + size_t ielen, u8 keymgmt, u8 ucipher, u8 auth) { struct ath6kl_sta *sta; u8 free_slot; -- GitLab From 9d82682d45ef7407474e0ae043a587cb33a7fa26 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Wed, 4 Jan 2012 15:57:19 +0530 Subject: [PATCH 0030/1846] ath6kl: Use a mutex_lock to avoid race in diabling and handling irq Currently this race is handled but in a messy way an atomic variable is being checked in a loop which sleeps upto ms in every iteration. Remove this logic and use a mutex to make sure irq is not disabled when irq handling is in progress. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 278a9f30795a..8b36904ec3ec 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -49,11 +49,13 @@ struct ath6kl_sdio { /* scatter request list head */ struct list_head scat_req; + /* Avoids disabling irq while the interrupts being handled */ + struct mutex mtx_irq; + spinlock_t scat_lock; bool scatter_enabled; bool is_disabled; - atomic_t irq_handling; const struct sdio_device_id *id; struct work_struct wr_async_work; struct list_head wr_asyncq; @@ -460,8 +462,7 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func) ath6kl_dbg(ATH6KL_DBG_SDIO, "irq\n"); ar_sdio = sdio_get_drvdata(func); - atomic_set(&ar_sdio->irq_handling, 1); - + mutex_lock(&ar_sdio->mtx_irq); /* * Release the host during interrups so we can pick it back up when * we process commands. @@ -470,7 +471,7 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func) status = ath6kl_hif_intr_bh_handler(ar_sdio->ar); sdio_claim_host(ar_sdio->func); - atomic_set(&ar_sdio->irq_handling, 0); + mutex_unlock(&ar_sdio->mtx_irq); WARN_ON(status && status != -ECANCELED); } @@ -578,17 +579,14 @@ static void ath6kl_sdio_irq_disable(struct ath6kl *ar) sdio_claim_host(ar_sdio->func); - /* Mask our function IRQ */ - while (atomic_read(&ar_sdio->irq_handling)) { - sdio_release_host(ar_sdio->func); - schedule_timeout(HZ / 10); - sdio_claim_host(ar_sdio->func); - } + mutex_lock(&ar_sdio->mtx_irq); ret = sdio_release_irq(ar_sdio->func); if (ret) ath6kl_err("Failed to release sdio irq: %d\n", ret); + mutex_unlock(&ar_sdio->mtx_irq); + sdio_release_host(ar_sdio->func); } @@ -1253,6 +1251,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, spin_lock_init(&ar_sdio->scat_lock); spin_lock_init(&ar_sdio->wr_async_lock); mutex_init(&ar_sdio->dma_buffer_mutex); + mutex_init(&ar_sdio->mtx_irq); INIT_LIST_HEAD(&ar_sdio->scat_req); INIT_LIST_HEAD(&ar_sdio->bus_req_freeq); -- GitLab From 4269a930548966014dd4186a15c8e023ca4abc29 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 5 Jan 2012 10:39:48 -0800 Subject: [PATCH 0031/1846] ath6kl: make net_device_ops const Signed-off-by: Stephen Hemminger Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 325d316f40ec..8742eaa78186 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1158,7 +1158,7 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) list_splice_tail(&mc_filter_new, &vif->mc_filter); } -static struct net_device_ops ath6kl_netdev_ops = { +static const struct net_device_ops ath6kl_netdev_ops = { .ndo_open = ath6kl_open, .ndo_stop = ath6kl_close, .ndo_start_xmit = ath6kl_data_tx, -- GitLab From 18e83e4cd144e30fb38bf1f714914182c6c8bced Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 5 Jan 2012 19:05:20 +0000 Subject: [PATCH 0032/1846] sfc: Const-qualify static data as appropriate, partly prompted by checkpatch Fix the following warnings: WARNING: struct dev_pm_ops should normally be const WARNING: static const char * array should probably be static const char * const Similarly const-qualify struct i2c_board_info, struct i2c_algo_bit_data, struct efx_ethtool_stat, struct efx_mtd_ops and struct siena_nvram_type_info. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 6 +++--- drivers/net/ethernet/sfc/ethtool.c | 4 ++-- drivers/net/ethernet/sfc/falcon.c | 2 +- drivers/net/ethernet/sfc/falcon_boards.c | 12 ++++++------ drivers/net/ethernet/sfc/mcdi.c | 4 ++-- drivers/net/ethernet/sfc/mtd.c | 8 ++++---- drivers/net/ethernet/sfc/net_driver.h | 4 ++-- drivers/net/ethernet/sfc/selftest.c | 2 +- drivers/net/ethernet/sfc/txc43128_phy.c | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 0539a8d88a23..9ca5dcdf5a86 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -38,7 +38,7 @@ /* Loopback mode names (see LOOPBACK_MODE()) */ const unsigned int efx_loopback_mode_max = LOOPBACK_MAX; -const char *efx_loopback_mode_names[] = { +const char *const efx_loopback_mode_names[] = { [LOOPBACK_NONE] = "NONE", [LOOPBACK_DATA] = "DATAPATH", [LOOPBACK_GMAC] = "GMAC", @@ -69,7 +69,7 @@ const char *efx_loopback_mode_names[] = { }; const unsigned int efx_reset_type_max = RESET_TYPE_MAX; -const char *efx_reset_type_names[] = { +const char *const efx_reset_type_names[] = { [RESET_TYPE_INVISIBLE] = "INVISIBLE", [RESET_TYPE_ALL] = "ALL", [RESET_TYPE_WORLD] = "WORLD", @@ -2660,7 +2660,7 @@ static int efx_pm_suspend(struct device *dev) return rc; } -static struct dev_pm_ops efx_pm_ops = { +static const struct dev_pm_ops efx_pm_ops = { .suspend = efx_pm_suspend, .resume = efx_pm_resume, .freeze = efx_pm_freeze, diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index c090de4e66c3..52c9ee4c8aa3 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -91,7 +91,7 @@ static u64 efx_get_atomic_stat(void *field) EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \ unsigned int, efx_get_uint_stat) -static struct efx_ethtool_stat efx_ethtool_stats[] = { +static const struct efx_ethtool_stat efx_ethtool_stats[] = { EFX_ETHTOOL_U64_MAC_STAT(tx_bytes), EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes), EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes), @@ -486,7 +486,7 @@ static void efx_ethtool_get_stats(struct net_device *net_dev, { struct efx_nic *efx = netdev_priv(net_dev); struct efx_mac_stats *mac_stats = &efx->mac_stats; - struct efx_ethtool_stat *stat; + const struct efx_ethtool_stat *stat; struct efx_channel *channel; struct efx_tx_queue *tx_queue; struct rtnl_link_stats64 temp; diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index 8ae1ebd35397..5c7548959dd7 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -89,7 +89,7 @@ static int falcon_getscl(void *data) return EFX_OWORD_FIELD(reg, FRF_AB_GPIO0_IN); } -static struct i2c_algo_bit_data falcon_i2c_bit_operations = { +static const struct i2c_algo_bit_data falcon_i2c_bit_operations = { .setsda = falcon_setsda, .setscl = falcon_setscl, .getsda = falcon_getsda, diff --git a/drivers/net/ethernet/sfc/falcon_boards.c b/drivers/net/ethernet/sfc/falcon_boards.c index 6cc16b8cc6f4..2084cc6ede52 100644 --- a/drivers/net/ethernet/sfc/falcon_boards.c +++ b/drivers/net/ethernet/sfc/falcon_boards.c @@ -87,7 +87,7 @@ static const u8 falcon_lm87_common_regs[] = { 0 }; -static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, +static int efx_init_lm87(struct efx_nic *efx, const struct i2c_board_info *info, const u8 *reg_values) { struct falcon_board *board = falcon_board(efx); @@ -179,7 +179,7 @@ static int efx_check_lm87(struct efx_nic *efx, unsigned mask) #else /* !CONFIG_SENSORS_LM87 */ static inline int -efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, +efx_init_lm87(struct efx_nic *efx, const struct i2c_board_info *info, const u8 *reg_values) { return 0; @@ -442,7 +442,7 @@ static int sfe4001_check_hw(struct efx_nic *efx) return (status < 0) ? -EIO : -ERANGE; } -static struct i2c_board_info sfe4001_hwmon_info = { +static const struct i2c_board_info sfe4001_hwmon_info = { I2C_BOARD_INFO("max6647", 0x4e), }; @@ -522,7 +522,7 @@ static const u8 sfe4002_lm87_regs[] = { 0 }; -static struct i2c_board_info sfe4002_hwmon_info = { +static const struct i2c_board_info sfe4002_hwmon_info = { I2C_BOARD_INFO("lm87", 0x2e), .platform_data = &sfe4002_lm87_channel, }; @@ -591,7 +591,7 @@ static const u8 sfn4112f_lm87_regs[] = { 0 }; -static struct i2c_board_info sfn4112f_hwmon_info = { +static const struct i2c_board_info sfn4112f_hwmon_info = { I2C_BOARD_INFO("lm87", 0x2e), .platform_data = &sfn4112f_lm87_channel, }; @@ -653,7 +653,7 @@ static const u8 sfe4003_lm87_regs[] = { 0 }; -static struct i2c_board_info sfe4003_hwmon_info = { +static const struct i2c_board_info sfe4003_hwmon_info = { I2C_BOARD_INFO("lm87", 0x2e), .platform_data = &sfe4003_lm87_channel, }; diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index 81a425397468..b1de400ca24e 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -502,7 +502,7 @@ static void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev) efx_link_status_changed(efx); } -static const char *sensor_names[] = { +static const char *const sensor_names[] = { [MC_CMD_SENSOR_CONTROLLER_TEMP] = "Controller temp. sensor", [MC_CMD_SENSOR_PHY_COMMON_TEMP] = "PHY shared temp. sensor", [MC_CMD_SENSOR_CONTROLLER_COOLING] = "Controller cooling", @@ -518,7 +518,7 @@ static const char *sensor_names[] = { [MC_CMD_SENSOR_IN_12V0] = "12V supply sensor" }; -static const char *sensor_status_names[] = { +static const char *const sensor_status_names[] = { [MC_CMD_SENSOR_STATE_OK] = "OK", [MC_CMD_SENSOR_STATE_WARNING] = "Warning", [MC_CMD_SENSOR_STATE_FATAL] = "Fatal", diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index bc9dcd6b30d7..13f61fba731f 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c @@ -382,7 +382,7 @@ static int falcon_mtd_sync(struct mtd_info *mtd) return rc; } -static struct efx_mtd_ops falcon_mtd_ops = { +static const struct efx_mtd_ops falcon_mtd_ops = { .read = falcon_mtd_read, .erase = falcon_mtd_erase, .write = falcon_mtd_write, @@ -560,7 +560,7 @@ static int siena_mtd_sync(struct mtd_info *mtd) return rc; } -static struct efx_mtd_ops siena_mtd_ops = { +static const struct efx_mtd_ops siena_mtd_ops = { .read = siena_mtd_read, .erase = siena_mtd_erase, .write = siena_mtd_write, @@ -572,7 +572,7 @@ struct siena_nvram_type_info { const char *name; }; -static struct siena_nvram_type_info siena_nvram_types[] = { +static const struct siena_nvram_type_info siena_nvram_types[] = { [MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO] = { 0, "sfc_dummy_phy" }, [MC_CMD_NVRAM_TYPE_MC_FW] = { 0, "sfc_mcfw" }, [MC_CMD_NVRAM_TYPE_MC_FW_BACKUP] = { 0, "sfc_mcfw_backup" }, @@ -593,7 +593,7 @@ static int siena_mtd_probe_partition(struct efx_nic *efx, unsigned int type) { struct efx_mtd_partition *part = &efx_mtd->part[part_id]; - struct siena_nvram_type_info *info; + const struct siena_nvram_type_info *info; size_t size, erase_size; bool protected; int rc; diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index c49502bab6a3..9353ce801752 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -395,12 +395,12 @@ enum efx_led_mode { #define STRING_TABLE_LOOKUP(val, member) \ ((val) < member ## _max) ? member ## _names[val] : "(invalid)" -extern const char *efx_loopback_mode_names[]; +extern const char *const efx_loopback_mode_names[]; extern const unsigned int efx_loopback_mode_max; #define LOOPBACK_MODE(efx) \ STRING_TABLE_LOOKUP((efx)->loopback_mode, efx_loopback_mode) -extern const char *efx_reset_type_names[]; +extern const char *const efx_reset_type_names[]; extern const unsigned int efx_reset_type_max; #define RESET_TYPE(type) \ STRING_TABLE_LOOKUP(type, efx_reset_type) diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index fc62fe2f766f..17ff9b399957 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -50,7 +50,7 @@ static const char payload_msg[] = /* Interrupt mode names */ static const unsigned int efx_interrupt_mode_max = EFX_INT_MODE_MAX; -static const char *efx_interrupt_mode_names[] = { +static const char *const efx_interrupt_mode_names[] = { [EFX_INT_MODE_MSIX] = "MSI-X", [EFX_INT_MODE_MSI] = "MSI", [EFX_INT_MODE_LEGACY] = "legacy", diff --git a/drivers/net/ethernet/sfc/txc43128_phy.c b/drivers/net/ethernet/sfc/txc43128_phy.c index 7c21b334a75b..29bb3f9941c0 100644 --- a/drivers/net/ethernet/sfc/txc43128_phy.c +++ b/drivers/net/ethernet/sfc/txc43128_phy.c @@ -512,7 +512,7 @@ static bool txc43128_phy_poll(struct efx_nic *efx) return efx->link_state.up != was_up; } -static const char *txc43128_test_names[] = { +static const char *const txc43128_test_names[] = { "bist" }; -- GitLab From 783b6bb66d4289826b3d022ad7b8ac3666951bb6 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 5 Jan 2012 19:09:24 +0000 Subject: [PATCH 0033/1846] sfc: Remove unnecessary inclusion of , prompted by checkpatch Fix the warning: WARNING: Use #include instead of There is no need for selftest.c to include the file at all. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/selftest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 17ff9b399957..5226d9857f30 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -19,7 +19,6 @@ #include #include #include -#include #include "net_driver.h" #include "efx.h" #include "nic.h" -- GitLab From 05a9320f7e64b69cbf612a69b7358546519ffc30 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 20 Dec 2011 00:44:06 +0000 Subject: [PATCH 0034/1846] sfc: Update MCDI (firmware interface) definitions Some commands and constants have been renamed; adjust the code accordingly. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mcdi.c | 15 +- drivers/net/ethernet/sfc/mcdi_mac.c | 16 +- drivers/net/ethernet/sfc/mcdi_pcol.h | 3542 +++++++++++++++----------- drivers/net/ethernet/sfc/mcdi_phy.c | 34 +- drivers/net/ethernet/sfc/mtd.c | 3 +- 5 files changed, 2119 insertions(+), 1491 deletions(-) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index b1de400ca24e..7c405d16692e 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -604,7 +604,7 @@ void efx_mcdi_process_event(struct efx_channel *channel, void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len) { - u8 outbuf[ALIGN(MC_CMD_GET_VERSION_V1_OUT_LEN, 4)]; + u8 outbuf[ALIGN(MC_CMD_GET_VERSION_OUT_LEN, 4)]; size_t outlength; const __le16 *ver_words; int rc; @@ -616,7 +616,7 @@ void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len) if (rc) goto fail; - if (outlength < MC_CMD_GET_VERSION_V1_OUT_LEN) { + if (outlength < MC_CMD_GET_VERSION_OUT_LEN) { rc = -EIO; goto fail; } @@ -665,7 +665,7 @@ int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, u16 *fw_subtype_list) { - uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LEN]; + uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMIN]; size_t outlen; int port_num = efx_port_num(efx); int offset; @@ -678,7 +678,7 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, if (rc) goto fail; - if (outlen < MC_CMD_GET_BOARD_CFG_OUT_LEN) { + if (outlen < MC_CMD_GET_BOARD_CFG_OUT_LENMIN) { rc = -EIO; goto fail; } @@ -691,7 +691,8 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, if (fw_subtype_list) memcpy(fw_subtype_list, outbuf + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST, - MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN); + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM * + sizeof(fw_subtype_list[0])); return 0; @@ -779,7 +780,7 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type, *size_out = MCDI_DWORD(outbuf, NVRAM_INFO_OUT_SIZE); *erase_size_out = MCDI_DWORD(outbuf, NVRAM_INFO_OUT_ERASESIZE); *protected_out = !!(MCDI_DWORD(outbuf, NVRAM_INFO_OUT_FLAGS) & - (1 << MC_CMD_NVRAM_PROTECTED_LBN)); + (1 << MC_CMD_NVRAM_INFO_OUT_PROTECTED_LBN)); return 0; fail: @@ -1060,7 +1061,7 @@ void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) int efx_mcdi_reset_port(struct efx_nic *efx) { - int rc = efx_mcdi_rpc(efx, MC_CMD_PORT_RESET, NULL, 0, NULL, 0, NULL); + int rc = efx_mcdi_rpc(efx, MC_CMD_ENTITY_RESET, NULL, 0, NULL, 0, NULL); if (rc) netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index aa4052c500fa..85fe24f86396 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -84,7 +84,7 @@ int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, u32 addr_hi; u32 addr_lo; - BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_LEN != 0); + BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_DMA_LEN != 0); addr_lo = ((u64)dma_addr) >> 0; addr_hi = ((u64)dma_addr) >> 32; @@ -93,13 +93,13 @@ int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_HI, addr_hi); cmd_ptr = (efx_dword_t *)MCDI_PTR(inbuf, MAC_STATS_IN_CMD); EFX_POPULATE_DWORD_7(*cmd_ptr, - MC_CMD_MAC_STATS_CMD_DMA, !!enable, - MC_CMD_MAC_STATS_CMD_CLEAR, clear, - MC_CMD_MAC_STATS_CMD_PERIODIC_CHANGE, 1, - MC_CMD_MAC_STATS_CMD_PERIODIC_ENABLE, !!enable, - MC_CMD_MAC_STATS_CMD_PERIODIC_CLEAR, 0, - MC_CMD_MAC_STATS_CMD_PERIODIC_NOEVENT, 1, - MC_CMD_MAC_STATS_CMD_PERIOD_MS, period); + MC_CMD_MAC_STATS_IN_DMA, !!enable, + MC_CMD_MAC_STATS_IN_CLEAR, clear, + MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE, 1, + MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE, !!enable, + MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR, 0, + MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT, 1, + MC_CMD_MAC_STATS_IN_PERIOD_MS, period); MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len); rc = efx_mcdi_rpc(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), diff --git a/drivers/net/ethernet/sfc/mcdi_pcol.h b/drivers/net/ethernet/sfc/mcdi_pcol.h index 41fe06fa0600..0310b9f08c9b 100644 --- a/drivers/net/ethernet/sfc/mcdi_pcol.h +++ b/drivers/net/ethernet/sfc/mcdi_pcol.h @@ -22,6 +22,18 @@ /* The Scheduler has started. */ #define MC_FW_STATE_SCHED (8) +/* Siena MC shared memmory offsets */ +/* The 'doorbell' addresses are hard-wired to alert the MC when written */ +#define MC_SMEM_P0_DOORBELL_OFST 0x000 +#define MC_SMEM_P1_DOORBELL_OFST 0x004 +/* The rest of these are firmware-defined */ +#define MC_SMEM_P0_PDU_OFST 0x008 +#define MC_SMEM_P1_PDU_OFST 0x108 +#define MC_SMEM_PDU_LEN 0x100 +#define MC_SMEM_P0_PTP_TIME_OFST 0x7f0 +#define MC_SMEM_P0_STATUS_OFST 0x7f8 +#define MC_SMEM_P1_STATUS_OFST 0x7fc + /* Values to be written to the per-port status dword in shared * memory on reboot and assert */ #define MC_STATUS_DWORD_REBOOT (0xb007b007) @@ -34,6 +46,8 @@ */ #define MCDI_PCOL_VERSION 1 +/* Unused commands: 0x23, 0x27, 0x30, 0x31 */ + /** * MCDI version 1 * @@ -131,53 +145,6 @@ */ #define FSE_AZ_EV_CODE_MCDI_EVRESPONSE 0xc -#define MCDI_EVENT_DATA_LBN 0 -#define MCDI_EVENT_DATA_WIDTH 32 -#define MCDI_EVENT_CONT_LBN 32 -#define MCDI_EVENT_CONT_WIDTH 1 -#define MCDI_EVENT_LEVEL_LBN 33 -#define MCDI_EVENT_LEVEL_WIDTH 3 -#define MCDI_EVENT_LEVEL_INFO (0) -#define MCDI_EVENT_LEVEL_WARN (1) -#define MCDI_EVENT_LEVEL_ERR (2) -#define MCDI_EVENT_LEVEL_FATAL (3) -#define MCDI_EVENT_SRC_LBN 36 -#define MCDI_EVENT_SRC_WIDTH 8 -#define MCDI_EVENT_CODE_LBN 44 -#define MCDI_EVENT_CODE_WIDTH 8 -#define MCDI_EVENT_CODE_BADSSERT (1) -#define MCDI_EVENT_CODE_PMNOTICE (2) -#define MCDI_EVENT_CODE_CMDDONE (3) -#define MCDI_EVENT_CMDDONE_SEQ_LBN 0 -#define MCDI_EVENT_CMDDONE_SEQ_WIDTH 8 -#define MCDI_EVENT_CMDDONE_DATALEN_LBN 8 -#define MCDI_EVENT_CMDDONE_DATALEN_WIDTH 8 -#define MCDI_EVENT_CMDDONE_ERRNO_LBN 16 -#define MCDI_EVENT_CMDDONE_ERRNO_WIDTH 8 -#define MCDI_EVENT_CODE_LINKCHANGE (4) -#define MCDI_EVENT_LINKCHANGE_LP_CAP_LBN 0 -#define MCDI_EVENT_LINKCHANGE_LP_CAP_WIDTH 16 -#define MCDI_EVENT_LINKCHANGE_SPEED_LBN 16 -#define MCDI_EVENT_LINKCHANGE_SPEED_WIDTH 4 -#define MCDI_EVENT_LINKCHANGE_SPEED_100M 1 -#define MCDI_EVENT_LINKCHANGE_SPEED_1G 2 -#define MCDI_EVENT_LINKCHANGE_SPEED_10G 3 -#define MCDI_EVENT_LINKCHANGE_FCNTL_LBN 20 -#define MCDI_EVENT_LINKCHANGE_FCNTL_WIDTH 4 -#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_LBN 24 -#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_WIDTH 8 -#define MCDI_EVENT_CODE_SENSOREVT (5) -#define MCDI_EVENT_SENSOREVT_MONITOR_LBN 0 -#define MCDI_EVENT_SENSOREVT_MONITOR_WIDTH 8 -#define MCDI_EVENT_SENSOREVT_STATE_LBN 8 -#define MCDI_EVENT_SENSOREVT_STATE_WIDTH 8 -#define MCDI_EVENT_SENSOREVT_VALUE_LBN 16 -#define MCDI_EVENT_SENSOREVT_VALUE_WIDTH 16 -#define MCDI_EVENT_CODE_SCHEDERR (6) -#define MCDI_EVENT_CODE_REBOOT (7) -#define MCDI_EVENT_CODE_MAC_STATS_DMA (8) -#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_LBN 0 -#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_WIDTH 32 /* Non-existent command target */ #define MC_CMD_ERR_ENOENT 2 @@ -198,121 +165,24 @@ #define MC_CMD_ERR_CODE_OFST 0 +/* We define 8 "escape" commands to allow + for command number space extension */ + +#define MC_CMD_CMD_SPACE_ESCAPE_0 0x78 +#define MC_CMD_CMD_SPACE_ESCAPE_1 0x79 +#define MC_CMD_CMD_SPACE_ESCAPE_2 0x7A +#define MC_CMD_CMD_SPACE_ESCAPE_3 0x7B +#define MC_CMD_CMD_SPACE_ESCAPE_4 0x7C +#define MC_CMD_CMD_SPACE_ESCAPE_5 0x7D +#define MC_CMD_CMD_SPACE_ESCAPE_6 0x7E +#define MC_CMD_CMD_SPACE_ESCAPE_7 0x7F + +/* Vectors in the boot ROM */ +/* Point to the copycode entry point. */ +#define MC_BOOTROM_COPYCODE_VEC (0x7f4) +/* Points to the recovery mode entry point. */ +#define MC_BOOTROM_NOFLASH_VEC (0x7f8) -/* MC_CMD_READ32: (debug, variadic out) - * Read multiple 32byte words from MC memory - */ -#define MC_CMD_READ32 0x01 -#define MC_CMD_READ32_IN_LEN 8 -#define MC_CMD_READ32_IN_ADDR_OFST 0 -#define MC_CMD_READ32_IN_NUMWORDS_OFST 4 -#define MC_CMD_READ32_OUT_LEN(_numwords) \ - (4 * (_numwords)) -#define MC_CMD_READ32_OUT_BUFFER_OFST 0 - -/* MC_CMD_WRITE32: (debug, variadic in) - * Write multiple 32byte words to MC memory - */ -#define MC_CMD_WRITE32 0x02 -#define MC_CMD_WRITE32_IN_LEN(_numwords) (((_numwords) * 4) + 4) -#define MC_CMD_WRITE32_IN_ADDR_OFST 0 -#define MC_CMD_WRITE32_IN_BUFFER_OFST 4 -#define MC_CMD_WRITE32_OUT_LEN 0 - -/* MC_CMD_COPYCODE: (debug) - * Copy MC code between two locations and jump - */ -#define MC_CMD_COPYCODE 0x03 -#define MC_CMD_COPYCODE_IN_LEN 16 -#define MC_CMD_COPYCODE_IN_SRC_ADDR_OFST 0 -#define MC_CMD_COPYCODE_IN_DEST_ADDR_OFST 4 -#define MC_CMD_COPYCODE_IN_NUMWORDS_OFST 8 -#define MC_CMD_COPYCODE_IN_JUMP_OFST 12 -/* Control should return to the caller rather than jumping */ -#define MC_CMD_COPYCODE_JUMP_NONE 1 -#define MC_CMD_COPYCODE_OUT_LEN 0 - -/* MC_CMD_SET_FUNC: (debug) - * Select function for function-specific commands. - */ -#define MC_CMD_SET_FUNC 0x04 -#define MC_CMD_SET_FUNC_IN_LEN 4 -#define MC_CMD_SET_FUNC_IN_FUNC_OFST 0 -#define MC_CMD_SET_FUNC_OUT_LEN 0 - -/* MC_CMD_GET_BOOT_STATUS: - * Get the instruction address from which the MC booted. - */ -#define MC_CMD_GET_BOOT_STATUS 0x05 -#define MC_CMD_GET_BOOT_STATUS_IN_LEN 0 -#define MC_CMD_GET_BOOT_STATUS_OUT_LEN 8 -#define MC_CMD_GET_BOOT_STATUS_OUT_BOOT_OFFSET_OFST 0 -#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_OFST 4 -/* Reboot caused by watchdog */ -#define MC_CMD_GET_BOOT_STATUS_FLAGS_WATCHDOG_LBN (0) -#define MC_CMD_GET_BOOT_STATUS_FLAGS_WATCHDOG_WIDTH (1) -/* MC booted from primary flash partition */ -#define MC_CMD_GET_BOOT_STATUS_FLAGS_PRIMARY_LBN (1) -#define MC_CMD_GET_BOOT_STATUS_FLAGS_PRIMARY_WIDTH (1) -/* MC booted from backup flash partition */ -#define MC_CMD_GET_BOOT_STATUS_FLAGS_BACKUP_LBN (2) -#define MC_CMD_GET_BOOT_STATUS_FLAGS_BACKUP_WIDTH (1) - -/* MC_CMD_GET_ASSERTS: (debug, variadic out) - * Get (and optionally clear) the current assertion status. - * - * Only OUT.GLOBAL_FLAGS is guaranteed to exist in the completion - * payload. The other fields will only be present if - * OUT.GLOBAL_FLAGS != NO_FAILS - */ -#define MC_CMD_GET_ASSERTS 0x06 -#define MC_CMD_GET_ASSERTS_IN_LEN 4 -#define MC_CMD_GET_ASSERTS_IN_CLEAR_OFST 0 -#define MC_CMD_GET_ASSERTS_OUT_LEN 140 -/* Assertion status flag */ -#define MC_CMD_GET_ASSERTS_OUT_GLOBAL_FLAGS_OFST 0 -/*! No assertions have failed. */ -#define MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS 1 -/*! A system-level assertion has failed. */ -#define MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL 2 -/*! A thread-level assertion has failed. */ -#define MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL 3 -/*! The system was reset by the watchdog. */ -#define MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED 4 -/* Failing PC value */ -#define MC_CMD_GET_ASSERTS_OUT_SAVED_PC_OFFS_OFST 4 -/* Saved GP regs */ -#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST 8 -#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_LEN 124 -/* Failing thread address */ -#define MC_CMD_GET_ASSERTS_OUT_THREAD_OFFS_OFST 132 - -/* MC_CMD_LOG_CTRL: - * Determine the output stream for various events and messages - */ -#define MC_CMD_LOG_CTRL 0x07 -#define MC_CMD_LOG_CTRL_IN_LEN 8 -#define MC_CMD_LOG_CTRL_IN_LOG_DEST_OFST 0 -#define MC_CMD_LOG_CTRL_IN_LOG_DEST_UART (1) -#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ (2) -#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ_OFST 4 -#define MC_CMD_LOG_CTRL_OUT_LEN 0 - -/* MC_CMD_GET_VERSION: - * Get version information about the MC firmware - */ -#define MC_CMD_GET_VERSION 0x08 -#define MC_CMD_GET_VERSION_IN_LEN 0 -#define MC_CMD_GET_VERSION_V0_OUT_LEN 4 -#define MC_CMD_GET_VERSION_V1_OUT_LEN 32 -#define MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 -/* Reserved version number to indicate "any" version. */ -#define MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff -/* The version response of a boot ROM awaiting rescue */ -#define MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM 0xb0070000 -#define MC_CMD_GET_VERSION_V1_OUT_PCOL_OFST 4 -/* 128bit mask of functions supported by the current firmware */ -#define MC_CMD_GET_VERSION_V1_OUT_SUPPORTED_FUNCS_OFST 8 /* The command set exported by the boot ROM (MCDI v0) */ #define MC_CMD_GET_VERSION_V0_SUPPORTED_FUNCS { \ (1 << MC_CMD_READ32) | \ @@ -320,1456 +190,2214 @@ (1 << MC_CMD_COPYCODE) | \ (1 << MC_CMD_GET_VERSION), \ 0, 0, 0 } -#define MC_CMD_GET_VERSION_OUT_VERSION_OFST 24 -/* Vectors in the boot ROM */ -/* Point to the copycode entry point. */ -#define MC_BOOTROM_COPYCODE_VEC (0x7f4) -/* Points to the recovery mode entry point. */ -#define MC_BOOTROM_NOFLASH_VEC (0x7f8) +#define MC_CMD_SENSOR_INFO_OUT_OFFSET_OFST(_x) \ + (MC_CMD_SENSOR_ENTRY_OFST + (_x)) + +#define MC_CMD_DBI_WRITE_IN_ADDRESS_OFST(n) \ + (MC_CMD_DBI_WRITE_IN_DBIWROP_OFST + \ + MC_CMD_DBIWROP_TYPEDEF_ADDRESS_OFST + \ + (n) * MC_CMD_DBIWROP_TYPEDEF_LEN) + +#define MC_CMD_DBI_WRITE_IN_BYTE_MASK_OFST(n) \ + (MC_CMD_DBI_WRITE_IN_DBIWROP_OFST + \ + MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_OFST + \ + (n) * MC_CMD_DBIWROP_TYPEDEF_LEN) + +#define MC_CMD_DBI_WRITE_IN_VALUE_OFST(n) \ + (MC_CMD_DBI_WRITE_IN_DBIWROP_OFST + \ + MC_CMD_DBIWROP_TYPEDEF_VALUE_OFST + \ + (n) * MC_CMD_DBIWROP_TYPEDEF_LEN) + + +/* MCDI_EVENT structuredef */ +#define MCDI_EVENT_LEN 8 +#define MCDI_EVENT_CONT_LBN 32 +#define MCDI_EVENT_CONT_WIDTH 1 +#define MCDI_EVENT_LEVEL_LBN 33 +#define MCDI_EVENT_LEVEL_WIDTH 3 +#define MCDI_EVENT_LEVEL_INFO 0x0 /* enum */ +#define MCDI_EVENT_LEVEL_WARN 0x1 /* enum */ +#define MCDI_EVENT_LEVEL_ERR 0x2 /* enum */ +#define MCDI_EVENT_LEVEL_FATAL 0x3 /* enum */ +#define MCDI_EVENT_DATA_OFST 0 +#define MCDI_EVENT_CMDDONE_SEQ_LBN 0 +#define MCDI_EVENT_CMDDONE_SEQ_WIDTH 8 +#define MCDI_EVENT_CMDDONE_DATALEN_LBN 8 +#define MCDI_EVENT_CMDDONE_DATALEN_WIDTH 8 +#define MCDI_EVENT_CMDDONE_ERRNO_LBN 16 +#define MCDI_EVENT_CMDDONE_ERRNO_WIDTH 8 +#define MCDI_EVENT_LINKCHANGE_LP_CAP_LBN 0 +#define MCDI_EVENT_LINKCHANGE_LP_CAP_WIDTH 16 +#define MCDI_EVENT_LINKCHANGE_SPEED_LBN 16 +#define MCDI_EVENT_LINKCHANGE_SPEED_WIDTH 4 +#define MCDI_EVENT_LINKCHANGE_SPEED_100M 0x1 /* enum */ +#define MCDI_EVENT_LINKCHANGE_SPEED_1G 0x2 /* enum */ +#define MCDI_EVENT_LINKCHANGE_SPEED_10G 0x3 /* enum */ +#define MCDI_EVENT_LINKCHANGE_FCNTL_LBN 20 +#define MCDI_EVENT_LINKCHANGE_FCNTL_WIDTH 4 +#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_LBN 24 +#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_WIDTH 8 +#define MCDI_EVENT_SENSOREVT_MONITOR_LBN 0 +#define MCDI_EVENT_SENSOREVT_MONITOR_WIDTH 8 +#define MCDI_EVENT_SENSOREVT_STATE_LBN 8 +#define MCDI_EVENT_SENSOREVT_STATE_WIDTH 8 +#define MCDI_EVENT_SENSOREVT_VALUE_LBN 16 +#define MCDI_EVENT_SENSOREVT_VALUE_WIDTH 16 +#define MCDI_EVENT_FWALERT_DATA_LBN 8 +#define MCDI_EVENT_FWALERT_DATA_WIDTH 24 +#define MCDI_EVENT_FWALERT_REASON_LBN 0 +#define MCDI_EVENT_FWALERT_REASON_WIDTH 8 +#define MCDI_EVENT_FWALERT_REASON_SRAM_ACCESS 0x1 /* enum */ +#define MCDI_EVENT_FLR_VF_LBN 0 +#define MCDI_EVENT_FLR_VF_WIDTH 8 +#define MCDI_EVENT_TX_ERR_TXQ_LBN 0 +#define MCDI_EVENT_TX_ERR_TXQ_WIDTH 12 +#define MCDI_EVENT_TX_ERR_TYPE_LBN 12 +#define MCDI_EVENT_TX_ERR_TYPE_WIDTH 4 +#define MCDI_EVENT_TX_ERR_DL_FAIL 0x1 /* enum */ +#define MCDI_EVENT_TX_ERR_NO_EOP 0x2 /* enum */ +#define MCDI_EVENT_TX_ERR_2BIG 0x3 /* enum */ +#define MCDI_EVENT_TX_ERR_INFO_LBN 16 +#define MCDI_EVENT_TX_ERR_INFO_WIDTH 16 +#define MCDI_EVENT_TX_FLUSH_TXQ_LBN 0 +#define MCDI_EVENT_TX_FLUSH_TXQ_WIDTH 12 +#define MCDI_EVENT_PTP_ERR_TYPE_LBN 0 +#define MCDI_EVENT_PTP_ERR_TYPE_WIDTH 8 +#define MCDI_EVENT_PTP_ERR_PLL_LOST 0x1 /* enum */ +#define MCDI_EVENT_PTP_ERR_FILTER 0x2 /* enum */ +#define MCDI_EVENT_PTP_ERR_FIFO 0x3 /* enum */ +#define MCDI_EVENT_PTP_ERR_QUEUE 0x4 /* enum */ +#define MCDI_EVENT_DATA_LBN 0 +#define MCDI_EVENT_DATA_WIDTH 32 +#define MCDI_EVENT_SRC_LBN 36 +#define MCDI_EVENT_SRC_WIDTH 8 +#define MCDI_EVENT_EV_CODE_LBN 60 +#define MCDI_EVENT_EV_CODE_WIDTH 4 +#define MCDI_EVENT_CODE_LBN 44 +#define MCDI_EVENT_CODE_WIDTH 8 +#define MCDI_EVENT_CODE_BADSSERT 0x1 /* enum */ +#define MCDI_EVENT_CODE_PMNOTICE 0x2 /* enum */ +#define MCDI_EVENT_CODE_CMDDONE 0x3 /* enum */ +#define MCDI_EVENT_CODE_LINKCHANGE 0x4 /* enum */ +#define MCDI_EVENT_CODE_SENSOREVT 0x5 /* enum */ +#define MCDI_EVENT_CODE_SCHEDERR 0x6 /* enum */ +#define MCDI_EVENT_CODE_REBOOT 0x7 /* enum */ +#define MCDI_EVENT_CODE_MAC_STATS_DMA 0x8 /* enum */ +#define MCDI_EVENT_CODE_FWALERT 0x9 /* enum */ +#define MCDI_EVENT_CODE_FLR 0xa /* enum */ +#define MCDI_EVENT_CODE_TX_ERR 0xb /* enum */ +#define MCDI_EVENT_CODE_TX_FLUSH 0xc /* enum */ +#define MCDI_EVENT_CODE_PTP_RX 0xd /* enum */ +#define MCDI_EVENT_CODE_PTP_FAULT 0xe /* enum */ +#define MCDI_EVENT_CMDDONE_DATA_OFST 0 +#define MCDI_EVENT_CMDDONE_DATA_LBN 0 +#define MCDI_EVENT_CMDDONE_DATA_WIDTH 32 +#define MCDI_EVENT_LINKCHANGE_DATA_OFST 0 +#define MCDI_EVENT_LINKCHANGE_DATA_LBN 0 +#define MCDI_EVENT_LINKCHANGE_DATA_WIDTH 32 +#define MCDI_EVENT_SENSOREVT_DATA_OFST 0 +#define MCDI_EVENT_SENSOREVT_DATA_LBN 0 +#define MCDI_EVENT_SENSOREVT_DATA_WIDTH 32 +#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_OFST 0 +#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_LBN 0 +#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_WIDTH 32 +#define MCDI_EVENT_TX_ERR_DATA_OFST 0 +#define MCDI_EVENT_TX_ERR_DATA_LBN 0 +#define MCDI_EVENT_TX_ERR_DATA_WIDTH 32 +#define MCDI_EVENT_PTP_SECONDS_OFST 0 +#define MCDI_EVENT_PTP_SECONDS_LBN 0 +#define MCDI_EVENT_PTP_SECONDS_WIDTH 32 +#define MCDI_EVENT_PTP_NANOSECONDS_OFST 0 +#define MCDI_EVENT_PTP_NANOSECONDS_LBN 0 +#define MCDI_EVENT_PTP_NANOSECONDS_WIDTH 32 +#define MCDI_EVENT_PTP_UUID_OFST 0 +#define MCDI_EVENT_PTP_UUID_LBN 0 +#define MCDI_EVENT_PTP_UUID_WIDTH 32 + + +/***********************************/ +/* MC_CMD_READ32 + * Read multiple 32byte words from MC memory. + */ +#define MC_CMD_READ32 0x1 + +/* MC_CMD_READ32_IN msgrequest */ +#define MC_CMD_READ32_IN_LEN 8 +#define MC_CMD_READ32_IN_ADDR_OFST 0 +#define MC_CMD_READ32_IN_NUMWORDS_OFST 4 + +/* MC_CMD_READ32_OUT msgresponse */ +#define MC_CMD_READ32_OUT_LENMIN 4 +#define MC_CMD_READ32_OUT_LENMAX 252 +#define MC_CMD_READ32_OUT_LEN(num) (0+4*(num)) +#define MC_CMD_READ32_OUT_BUFFER_OFST 0 +#define MC_CMD_READ32_OUT_BUFFER_LEN 4 +#define MC_CMD_READ32_OUT_BUFFER_MINNUM 1 +#define MC_CMD_READ32_OUT_BUFFER_MAXNUM 63 + + +/***********************************/ +/* MC_CMD_WRITE32 + * Write multiple 32byte words to MC memory. + */ +#define MC_CMD_WRITE32 0x2 + +/* MC_CMD_WRITE32_IN msgrequest */ +#define MC_CMD_WRITE32_IN_LENMIN 8 +#define MC_CMD_WRITE32_IN_LENMAX 252 +#define MC_CMD_WRITE32_IN_LEN(num) (4+4*(num)) +#define MC_CMD_WRITE32_IN_ADDR_OFST 0 +#define MC_CMD_WRITE32_IN_BUFFER_OFST 4 +#define MC_CMD_WRITE32_IN_BUFFER_LEN 4 +#define MC_CMD_WRITE32_IN_BUFFER_MINNUM 1 +#define MC_CMD_WRITE32_IN_BUFFER_MAXNUM 62 + +/* MC_CMD_WRITE32_OUT msgresponse */ +#define MC_CMD_WRITE32_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_COPYCODE + * Copy MC code between two locations and jump. + */ +#define MC_CMD_COPYCODE 0x3 + +/* MC_CMD_COPYCODE_IN msgrequest */ +#define MC_CMD_COPYCODE_IN_LEN 16 +#define MC_CMD_COPYCODE_IN_SRC_ADDR_OFST 0 +#define MC_CMD_COPYCODE_IN_DEST_ADDR_OFST 4 +#define MC_CMD_COPYCODE_IN_NUMWORDS_OFST 8 +#define MC_CMD_COPYCODE_IN_JUMP_OFST 12 +#define MC_CMD_COPYCODE_JUMP_NONE 0x1 /* enum */ + +/* MC_CMD_COPYCODE_OUT msgresponse */ +#define MC_CMD_COPYCODE_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_SET_FUNC + */ +#define MC_CMD_SET_FUNC 0x4 + +/* MC_CMD_SET_FUNC_IN msgrequest */ +#define MC_CMD_SET_FUNC_IN_LEN 4 +#define MC_CMD_SET_FUNC_IN_FUNC_OFST 0 + +/* MC_CMD_SET_FUNC_OUT msgresponse */ +#define MC_CMD_SET_FUNC_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_GET_BOOT_STATUS + */ +#define MC_CMD_GET_BOOT_STATUS 0x5 + +/* MC_CMD_GET_BOOT_STATUS_IN msgrequest */ +#define MC_CMD_GET_BOOT_STATUS_IN_LEN 0 + +/* MC_CMD_GET_BOOT_STATUS_OUT msgresponse */ +#define MC_CMD_GET_BOOT_STATUS_OUT_LEN 8 +#define MC_CMD_GET_BOOT_STATUS_OUT_BOOT_OFFSET_OFST 0 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_OFST 4 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_WATCHDOG_LBN 0 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_WATCHDOG_WIDTH 1 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_PRIMARY_LBN 1 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_PRIMARY_WIDTH 1 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_BACKUP_LBN 2 +#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_BACKUP_WIDTH 1 -/* Test execution limits */ -#define MC_TESTEXEC_VARIANT_COUNT 16 -#define MC_TESTEXEC_RESULT_COUNT 7 -/* MC_CMD_SET_TESTVARS: (debug, variadic in) - * Write variant words for test. - * - * The user supplies a bitmap of the variants they wish to set. - * They must ensure that IN.LEN >= 4 + 4 * ffs(BITMAP) - */ -#define MC_CMD_SET_TESTVARS 0x09 -#define MC_CMD_SET_TESTVARS_IN_LEN(_numwords) \ - (4 + 4*(_numwords)) -#define MC_CMD_SET_TESTVARS_IN_ARGS_BITMAP_OFST 0 -/* Up to MC_TESTEXEC_VARIANT_COUNT of 32byte words start here */ -#define MC_CMD_SET_TESTVARS_IN_ARGS_BUFFER_OFST 4 -#define MC_CMD_SET_TESTVARS_OUT_LEN 0 - -/* MC_CMD_GET_TESTRCS: (debug, variadic out) - * Return result words from test. - */ -#define MC_CMD_GET_TESTRCS 0x0a -#define MC_CMD_GET_TESTRCS_IN_LEN 4 -#define MC_CMD_GET_TESTRCS_IN_NUMWORDS_OFST 0 -#define MC_CMD_GET_TESTRCS_OUT_LEN(_numwords) \ - (4 * (_numwords)) -#define MC_CMD_GET_TESTRCS_OUT_BUFFER_OFST 0 - -/* MC_CMD_RUN_TEST: (debug) - * Run the test exported by this firmware image - */ -#define MC_CMD_RUN_TEST 0x0b -#define MC_CMD_RUN_TEST_IN_LEN 0 -#define MC_CMD_RUN_TEST_OUT_LEN 0 - -/* MC_CMD_CSR_READ32: (debug, variadic out) - * Read 32bit words from the indirect memory map - */ -#define MC_CMD_CSR_READ32 0x0c -#define MC_CMD_CSR_READ32_IN_LEN 12 -#define MC_CMD_CSR_READ32_IN_ADDR_OFST 0 -#define MC_CMD_CSR_READ32_IN_STEP_OFST 4 -#define MC_CMD_CSR_READ32_IN_NUMWORDS_OFST 8 -#define MC_CMD_CSR_READ32_OUT_LEN(_numwords) \ - (((_numwords) * 4) + 4) -/* IN.NUMWORDS of 32bit words start here */ -#define MC_CMD_CSR_READ32_OUT_BUFFER_OFST 0 -#define MC_CMD_CSR_READ32_OUT_IREG_STATUS_OFST(_numwords) \ - ((_numwords) * 4) - -/* MC_CMD_CSR_WRITE32: (debug, variadic in) - * Write 32bit dwords to the indirect memory map - */ -#define MC_CMD_CSR_WRITE32 0x0d -#define MC_CMD_CSR_WRITE32_IN_LEN(_numwords) \ - (((_numwords) * 4) + 8) -#define MC_CMD_CSR_WRITE32_IN_ADDR_OFST 0 -#define MC_CMD_CSR_WRITE32_IN_STEP_OFST 4 -/* Multiple 32bit words of data to write start here */ -#define MC_CMD_CSR_WRITE32_IN_BUFFER_OFST 8 -#define MC_CMD_CSR_WRITE32_OUT_LEN 4 -#define MC_CMD_CSR_WRITE32_OUT_STATUS_OFST 0 - -/* MC_CMD_JTAG_WORK: (debug, fpga only) - * Process JTAG work buffer for RBF acceleration. - * - * Host: bit count, (up to) 32 words of data to clock out to JTAG - * (bits 1,0=TMS,TDO for first bit; bits 3,2=TMS,TDO for second bit, etc.) - * MC: bit count, (up to) 32 words of data clocked in from JTAG - * (bit 0=TDI for first bit, bit 1=TDI for second bit, etc.; [31:16] unused) +/***********************************/ +/* MC_CMD_GET_ASSERTS + * Get and clear any assertion status. */ -#define MC_CMD_JTAG_WORK 0x0e +#define MC_CMD_GET_ASSERTS 0x6 -/* MC_CMD_STACKINFO: (debug, variadic out) - * Get stack information - * - * Host: nothing - * MC: (thread ptr, stack size, free space) for each thread in system - */ -#define MC_CMD_STACKINFO 0x0f +/* MC_CMD_GET_ASSERTS_IN msgrequest */ +#define MC_CMD_GET_ASSERTS_IN_LEN 4 +#define MC_CMD_GET_ASSERTS_IN_CLEAR_OFST 0 + +/* MC_CMD_GET_ASSERTS_OUT msgresponse */ +#define MC_CMD_GET_ASSERTS_OUT_LEN 140 +#define MC_CMD_GET_ASSERTS_OUT_GLOBAL_FLAGS_OFST 0 +#define MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS 0x1 /* enum */ +#define MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL 0x2 /* enum */ +#define MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL 0x3 /* enum */ +#define MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED 0x4 /* enum */ +#define MC_CMD_GET_ASSERTS_OUT_SAVED_PC_OFFS_OFST 4 +#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST 8 +#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_LEN 4 +#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_NUM 31 +#define MC_CMD_GET_ASSERTS_OUT_THREAD_OFFS_OFST 132 +#define MC_CMD_GET_ASSERTS_OUT_RESERVED_OFST 136 -/* MC_CMD_MDIO_READ: - * MDIO register read + +/***********************************/ +/* MC_CMD_LOG_CTRL + * Configure the output stream for various events and messages. + */ +#define MC_CMD_LOG_CTRL 0x7 + +/* MC_CMD_LOG_CTRL_IN msgrequest */ +#define MC_CMD_LOG_CTRL_IN_LEN 8 +#define MC_CMD_LOG_CTRL_IN_LOG_DEST_OFST 0 +#define MC_CMD_LOG_CTRL_IN_LOG_DEST_UART 0x1 /* enum */ +#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ 0x2 /* enum */ +#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ_OFST 4 + +/* MC_CMD_LOG_CTRL_OUT msgresponse */ +#define MC_CMD_LOG_CTRL_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_GET_VERSION + * Get version information about the MC firmware. + */ +#define MC_CMD_GET_VERSION 0x8 + +/* MC_CMD_GET_VERSION_IN msgrequest */ +#define MC_CMD_GET_VERSION_IN_LEN 0 + +/* MC_CMD_GET_VERSION_V0_OUT msgresponse */ +#define MC_CMD_GET_VERSION_V0_OUT_LEN 4 +#define MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 +#define MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff /* enum */ +#define MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM 0xb0070000 /* enum */ + +/* MC_CMD_GET_VERSION_OUT msgresponse */ +#define MC_CMD_GET_VERSION_OUT_LEN 32 +/* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ +/* Enum values, see field(s): */ +/* MC_CMD_GET_VERSION_V0_OUT/MC_CMD_GET_VERSION_OUT_FIRMWARE */ +#define MC_CMD_GET_VERSION_OUT_PCOL_OFST 4 +#define MC_CMD_GET_VERSION_OUT_SUPPORTED_FUNCS_OFST 8 +#define MC_CMD_GET_VERSION_OUT_SUPPORTED_FUNCS_LEN 16 +#define MC_CMD_GET_VERSION_OUT_VERSION_OFST 24 +#define MC_CMD_GET_VERSION_OUT_VERSION_LEN 8 +#define MC_CMD_GET_VERSION_OUT_VERSION_LO_OFST 24 +#define MC_CMD_GET_VERSION_OUT_VERSION_HI_OFST 28 + + +/***********************************/ +/* MC_CMD_GET_FPGAREG + * Read multiple bytes from PTP FPGA. + */ +#define MC_CMD_GET_FPGAREG 0x9 + +/* MC_CMD_GET_FPGAREG_IN msgrequest */ +#define MC_CMD_GET_FPGAREG_IN_LEN 8 +#define MC_CMD_GET_FPGAREG_IN_ADDR_OFST 0 +#define MC_CMD_GET_FPGAREG_IN_NUMBYTES_OFST 4 + +/* MC_CMD_GET_FPGAREG_OUT msgresponse */ +#define MC_CMD_GET_FPGAREG_OUT_LENMIN 1 +#define MC_CMD_GET_FPGAREG_OUT_LENMAX 255 +#define MC_CMD_GET_FPGAREG_OUT_LEN(num) (0+1*(num)) +#define MC_CMD_GET_FPGAREG_OUT_BUFFER_OFST 0 +#define MC_CMD_GET_FPGAREG_OUT_BUFFER_LEN 1 +#define MC_CMD_GET_FPGAREG_OUT_BUFFER_MINNUM 1 +#define MC_CMD_GET_FPGAREG_OUT_BUFFER_MAXNUM 255 + + +/***********************************/ +/* MC_CMD_PUT_FPGAREG + * Write multiple bytes to PTP FPGA. + */ +#define MC_CMD_PUT_FPGAREG 0xa + +/* MC_CMD_PUT_FPGAREG_IN msgrequest */ +#define MC_CMD_PUT_FPGAREG_IN_LENMIN 5 +#define MC_CMD_PUT_FPGAREG_IN_LENMAX 255 +#define MC_CMD_PUT_FPGAREG_IN_LEN(num) (4+1*(num)) +#define MC_CMD_PUT_FPGAREG_IN_ADDR_OFST 0 +#define MC_CMD_PUT_FPGAREG_IN_BUFFER_OFST 4 +#define MC_CMD_PUT_FPGAREG_IN_BUFFER_LEN 1 +#define MC_CMD_PUT_FPGAREG_IN_BUFFER_MINNUM 1 +#define MC_CMD_PUT_FPGAREG_IN_BUFFER_MAXNUM 251 + +/* MC_CMD_PUT_FPGAREG_OUT msgresponse */ +#define MC_CMD_PUT_FPGAREG_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_PTP + * Perform PTP operation + */ +#define MC_CMD_PTP 0xb + +/* MC_CMD_PTP_IN msgrequest */ +#define MC_CMD_PTP_IN_LEN 1 +#define MC_CMD_PTP_IN_OP_OFST 0 +#define MC_CMD_PTP_IN_OP_LEN 1 +#define MC_CMD_PTP_OP_ENABLE 0x1 /* enum */ +#define MC_CMD_PTP_OP_DISABLE 0x2 /* enum */ +#define MC_CMD_PTP_OP_TRANSMIT 0x3 /* enum */ +#define MC_CMD_PTP_OP_READ_NIC_TIME 0x4 /* enum */ +#define MC_CMD_PTP_OP_STATUS 0x5 /* enum */ +#define MC_CMD_PTP_OP_ADJUST 0x6 /* enum */ +#define MC_CMD_PTP_OP_SYNCHRONIZE 0x7 /* enum */ +#define MC_CMD_PTP_OP_MANFTEST_BASIC 0x8 /* enum */ +#define MC_CMD_PTP_OP_MANFTEST_PACKET 0x9 /* enum */ +#define MC_CMD_PTP_OP_RESET_STATS 0xa /* enum */ +#define MC_CMD_PTP_OP_DEBUG 0xb /* enum */ +#define MC_CMD_PTP_OP_MAX 0xc /* enum */ + +/* MC_CMD_PTP_IN_ENABLE msgrequest */ +#define MC_CMD_PTP_IN_ENABLE_LEN 16 +#define MC_CMD_PTP_IN_CMD_OFST 0 +#define MC_CMD_PTP_IN_PERIPH_ID_OFST 4 +#define MC_CMD_PTP_IN_ENABLE_QUEUE_OFST 8 +#define MC_CMD_PTP_IN_ENABLE_MODE_OFST 12 +#define MC_CMD_PTP_MODE_V1 0x0 /* enum */ +#define MC_CMD_PTP_MODE_V1_VLAN 0x1 /* enum */ +#define MC_CMD_PTP_MODE_V2 0x2 /* enum */ +#define MC_CMD_PTP_MODE_V2_VLAN 0x3 /* enum */ + +/* MC_CMD_PTP_IN_DISABLE msgrequest */ +#define MC_CMD_PTP_IN_DISABLE_LEN 8 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ + +/* MC_CMD_PTP_IN_TRANSMIT msgrequest */ +#define MC_CMD_PTP_IN_TRANSMIT_LENMIN 13 +#define MC_CMD_PTP_IN_TRANSMIT_LENMAX 255 +#define MC_CMD_PTP_IN_TRANSMIT_LEN(num) (12+1*(num)) +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ +#define MC_CMD_PTP_IN_TRANSMIT_LENGTH_OFST 8 +#define MC_CMD_PTP_IN_TRANSMIT_PACKET_OFST 12 +#define MC_CMD_PTP_IN_TRANSMIT_PACKET_LEN 1 +#define MC_CMD_PTP_IN_TRANSMIT_PACKET_MINNUM 1 +#define MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM 243 + +/* MC_CMD_PTP_IN_READ_NIC_TIME msgrequest */ +#define MC_CMD_PTP_IN_READ_NIC_TIME_LEN 8 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ + +/* MC_CMD_PTP_IN_STATUS msgrequest */ +#define MC_CMD_PTP_IN_STATUS_LEN 8 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ + +/* MC_CMD_PTP_IN_ADJUST msgrequest */ +#define MC_CMD_PTP_IN_ADJUST_LEN 24 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ +#define MC_CMD_PTP_IN_ADJUST_FREQ_OFST 8 +#define MC_CMD_PTP_IN_ADJUST_FREQ_LEN 8 +#define MC_CMD_PTP_IN_ADJUST_FREQ_LO_OFST 8 +#define MC_CMD_PTP_IN_ADJUST_FREQ_HI_OFST 12 +#define MC_CMD_PTP_IN_ADJUST_BITS 0x28 /* enum */ +#define MC_CMD_PTP_IN_ADJUST_SECONDS_OFST 16 +#define MC_CMD_PTP_IN_ADJUST_NANOSECONDS_OFST 20 + +/* MC_CMD_PTP_IN_SYNCHRONIZE msgrequest */ +#define MC_CMD_PTP_IN_SYNCHRONIZE_LEN 20 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ +#define MC_CMD_PTP_IN_SYNCHRONIZE_NUMTIMESETS_OFST 8 +#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_OFST 12 +#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LEN 8 +#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LO_OFST 12 +#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_HI_OFST 16 + +/* MC_CMD_PTP_IN_MANFTEST_BASIC msgrequest */ +#define MC_CMD_PTP_IN_MANFTEST_BASIC_LEN 8 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ + +/* MC_CMD_PTP_IN_MANFTEST_PACKET msgrequest */ +#define MC_CMD_PTP_IN_MANFTEST_PACKET_LEN 12 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ +#define MC_CMD_PTP_IN_MANFTEST_PACKET_TEST_ENABLE_OFST 8 + +/* MC_CMD_PTP_IN_RESET_STATS msgrequest */ +#define MC_CMD_PTP_IN_RESET_STATS_LEN 8 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ + +/* MC_CMD_PTP_IN_DEBUG msgrequest */ +#define MC_CMD_PTP_IN_DEBUG_LEN 12 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ +#define MC_CMD_PTP_IN_DEBUG_DEBUG_PARAM_OFST 8 + +/* MC_CMD_PTP_OUT msgresponse */ +#define MC_CMD_PTP_OUT_LEN 0 + +/* MC_CMD_PTP_OUT_TRANSMIT msgresponse */ +#define MC_CMD_PTP_OUT_TRANSMIT_LEN 8 +#define MC_CMD_PTP_OUT_TRANSMIT_SECONDS_OFST 0 +#define MC_CMD_PTP_OUT_TRANSMIT_NANOSECONDS_OFST 4 + +/* MC_CMD_PTP_OUT_READ_NIC_TIME msgresponse */ +#define MC_CMD_PTP_OUT_READ_NIC_TIME_LEN 8 +#define MC_CMD_PTP_OUT_READ_NIC_TIME_SECONDS_OFST 0 +#define MC_CMD_PTP_OUT_READ_NIC_TIME_NANOSECONDS_OFST 4 + +/* MC_CMD_PTP_OUT_STATUS msgresponse */ +#define MC_CMD_PTP_OUT_STATUS_LEN 64 +#define MC_CMD_PTP_OUT_STATUS_CLOCK_FREQ_OFST 0 +#define MC_CMD_PTP_OUT_STATUS_STATS_TX_OFST 4 +#define MC_CMD_PTP_OUT_STATUS_STATS_RX_OFST 8 +#define MC_CMD_PTP_OUT_STATUS_STATS_TS_OFST 12 +#define MC_CMD_PTP_OUT_STATUS_STATS_FM_OFST 16 +#define MC_CMD_PTP_OUT_STATUS_STATS_NFM_OFST 20 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFLOW_OFST 24 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_BAD_OFST 28 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MIN_OFST 32 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MAX_OFST 36 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_LAST_OFST 40 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MEAN_OFST 44 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MIN_OFST 48 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MAX_OFST 52 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_LAST_OFST 56 +#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MEAN_OFST 60 + +/* MC_CMD_PTP_OUT_SYNCHRONIZE msgresponse */ +#define MC_CMD_PTP_OUT_SYNCHRONIZE_LENMIN 20 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_LENMAX 240 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_LEN(num) (0+20*(num)) +#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_OFST 0 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN 20 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MINNUM 1 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM 12 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTSTART_OFST 0 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_SECONDS_OFST 4 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_NANOSECONDS_OFST 8 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTEND_OFST 12 +#define MC_CMD_PTP_OUT_SYNCHRONIZE_WAITNS_OFST 16 + +/* MC_CMD_PTP_OUT_MANFTEST_BASIC msgresponse */ +#define MC_CMD_PTP_OUT_MANFTEST_BASIC_LEN 8 +#define MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_RESULT_OFST 0 +#define MC_CMD_PTP_MANF_SUCCESS 0x0 /* enum */ +#define MC_CMD_PTP_MANF_FPGA_LOAD 0x1 /* enum */ +#define MC_CMD_PTP_MANF_FPGA_VERSION 0x2 /* enum */ +#define MC_CMD_PTP_MANF_FPGA_REGISTERS 0x3 /* enum */ +#define MC_CMD_PTP_MANF_OSCILLATOR 0x4 /* enum */ +#define MC_CMD_PTP_MANF_TIMESTAMPS 0x5 /* enum */ +#define MC_CMD_PTP_MANF_PACKET_COUNT 0x6 /* enum */ +#define MC_CMD_PTP_MANF_FILTER_COUNT 0x7 /* enum */ +#define MC_CMD_PTP_MANF_PACKET_ENOUGH 0x8 /* enum */ +#define MC_CMD_PTP_MANF_GPIO_TRIGGER 0x9 /* enum */ +#define MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_EXTOSC_OFST 4 + +/* MC_CMD_PTP_OUT_MANFTEST_PACKET msgresponse */ +#define MC_CMD_PTP_OUT_MANFTEST_PACKET_LEN 12 +#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_RESULT_OFST 0 +#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FPGACOUNT_OFST 4 +#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FILTERCOUNT_OFST 8 + + +/***********************************/ +/* MC_CMD_CSR_READ32 + * Read 32bit words from the indirect memory map. + */ +#define MC_CMD_CSR_READ32 0xc + +/* MC_CMD_CSR_READ32_IN msgrequest */ +#define MC_CMD_CSR_READ32_IN_LEN 12 +#define MC_CMD_CSR_READ32_IN_ADDR_OFST 0 +#define MC_CMD_CSR_READ32_IN_STEP_OFST 4 +#define MC_CMD_CSR_READ32_IN_NUMWORDS_OFST 8 + +/* MC_CMD_CSR_READ32_OUT msgresponse */ +#define MC_CMD_CSR_READ32_OUT_LENMIN 4 +#define MC_CMD_CSR_READ32_OUT_LENMAX 252 +#define MC_CMD_CSR_READ32_OUT_LEN(num) (0+4*(num)) +#define MC_CMD_CSR_READ32_OUT_BUFFER_OFST 0 +#define MC_CMD_CSR_READ32_OUT_BUFFER_LEN 4 +#define MC_CMD_CSR_READ32_OUT_BUFFER_MINNUM 1 +#define MC_CMD_CSR_READ32_OUT_BUFFER_MAXNUM 63 + + +/***********************************/ +/* MC_CMD_CSR_WRITE32 + * Write 32bit dwords to the indirect memory map. + */ +#define MC_CMD_CSR_WRITE32 0xd + +/* MC_CMD_CSR_WRITE32_IN msgrequest */ +#define MC_CMD_CSR_WRITE32_IN_LENMIN 12 +#define MC_CMD_CSR_WRITE32_IN_LENMAX 252 +#define MC_CMD_CSR_WRITE32_IN_LEN(num) (8+4*(num)) +#define MC_CMD_CSR_WRITE32_IN_ADDR_OFST 0 +#define MC_CMD_CSR_WRITE32_IN_STEP_OFST 4 +#define MC_CMD_CSR_WRITE32_IN_BUFFER_OFST 8 +#define MC_CMD_CSR_WRITE32_IN_BUFFER_LEN 4 +#define MC_CMD_CSR_WRITE32_IN_BUFFER_MINNUM 1 +#define MC_CMD_CSR_WRITE32_IN_BUFFER_MAXNUM 61 + +/* MC_CMD_CSR_WRITE32_OUT msgresponse */ +#define MC_CMD_CSR_WRITE32_OUT_LEN 4 +#define MC_CMD_CSR_WRITE32_OUT_STATUS_OFST 0 + + +/***********************************/ +/* MC_CMD_STACKINFO + * Get stack information. + */ +#define MC_CMD_STACKINFO 0xf + +/* MC_CMD_STACKINFO_IN msgrequest */ +#define MC_CMD_STACKINFO_IN_LEN 0 + +/* MC_CMD_STACKINFO_OUT msgresponse */ +#define MC_CMD_STACKINFO_OUT_LENMIN 12 +#define MC_CMD_STACKINFO_OUT_LENMAX 252 +#define MC_CMD_STACKINFO_OUT_LEN(num) (0+12*(num)) +#define MC_CMD_STACKINFO_OUT_THREAD_INFO_OFST 0 +#define MC_CMD_STACKINFO_OUT_THREAD_INFO_LEN 12 +#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MINNUM 1 +#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MAXNUM 21 + + +/***********************************/ +/* MC_CMD_MDIO_READ + * MDIO register read. */ #define MC_CMD_MDIO_READ 0x10 -#define MC_CMD_MDIO_READ_IN_LEN 16 -#define MC_CMD_MDIO_READ_IN_BUS_OFST 0 -#define MC_CMD_MDIO_READ_IN_PRTAD_OFST 4 -#define MC_CMD_MDIO_READ_IN_DEVAD_OFST 8 -#define MC_CMD_MDIO_READ_IN_ADDR_OFST 12 -#define MC_CMD_MDIO_READ_OUT_LEN 8 -#define MC_CMD_MDIO_READ_OUT_VALUE_OFST 0 -#define MC_CMD_MDIO_READ_OUT_STATUS_OFST 4 - -/* MC_CMD_MDIO_WRITE: - * MDIO register write - */ -#define MC_CMD_MDIO_WRITE 0x11 -#define MC_CMD_MDIO_WRITE_IN_LEN 20 -#define MC_CMD_MDIO_WRITE_IN_BUS_OFST 0 -#define MC_CMD_MDIO_WRITE_IN_PRTAD_OFST 4 -#define MC_CMD_MDIO_WRITE_IN_DEVAD_OFST 8 -#define MC_CMD_MDIO_WRITE_IN_ADDR_OFST 12 -#define MC_CMD_MDIO_WRITE_IN_VALUE_OFST 16 -#define MC_CMD_MDIO_WRITE_OUT_LEN 4 -#define MC_CMD_MDIO_WRITE_OUT_STATUS_OFST 0 -/* By default all the MCDI MDIO operations perform clause45 mode. - * If you want to use clause22 then set DEVAD = MC_CMD_MDIO_CLAUSE22. - */ -#define MC_CMD_MDIO_CLAUSE22 32 +/* MC_CMD_MDIO_READ_IN msgrequest */ +#define MC_CMD_MDIO_READ_IN_LEN 16 +#define MC_CMD_MDIO_READ_IN_BUS_OFST 0 +#define MC_CMD_MDIO_BUS_INTERNAL 0x0 /* enum */ +#define MC_CMD_MDIO_BUS_EXTERNAL 0x1 /* enum */ +#define MC_CMD_MDIO_READ_IN_PRTAD_OFST 4 +#define MC_CMD_MDIO_READ_IN_DEVAD_OFST 8 +#define MC_CMD_MDIO_CLAUSE22 0x20 /* enum */ +#define MC_CMD_MDIO_READ_IN_ADDR_OFST 12 -/* There are two MDIO buses: one for the internal PHY, and one for external - * devices. - */ -#define MC_CMD_MDIO_BUS_INTERNAL 0 -#define MC_CMD_MDIO_BUS_EXTERNAL 1 +/* MC_CMD_MDIO_READ_OUT msgresponse */ +#define MC_CMD_MDIO_READ_OUT_LEN 8 +#define MC_CMD_MDIO_READ_OUT_VALUE_OFST 0 +#define MC_CMD_MDIO_READ_OUT_STATUS_OFST 4 +#define MC_CMD_MDIO_STATUS_GOOD 0x8 /* enum */ -/* The MDIO commands return the raw status bits from the MDIO block. A "good" - * transaction should have the DONE bit set and all other bits clear. + +/***********************************/ +/* MC_CMD_MDIO_WRITE + * MDIO register write. */ -#define MC_CMD_MDIO_STATUS_GOOD 0x08 +#define MC_CMD_MDIO_WRITE 0x11 +/* MC_CMD_MDIO_WRITE_IN msgrequest */ +#define MC_CMD_MDIO_WRITE_IN_LEN 20 +#define MC_CMD_MDIO_WRITE_IN_BUS_OFST 0 +/* MC_CMD_MDIO_BUS_INTERNAL 0x0 */ +/* MC_CMD_MDIO_BUS_EXTERNAL 0x1 */ +#define MC_CMD_MDIO_WRITE_IN_PRTAD_OFST 4 +#define MC_CMD_MDIO_WRITE_IN_DEVAD_OFST 8 +/* MC_CMD_MDIO_CLAUSE22 0x20 */ +#define MC_CMD_MDIO_WRITE_IN_ADDR_OFST 12 +#define MC_CMD_MDIO_WRITE_IN_VALUE_OFST 16 -/* MC_CMD_DBI_WRITE: (debug) - * Write DBI register(s) - * - * Host: address, byte-enables (and VF selection, and cs2 flag), - * value [,address ...] - * MC: nothing +/* MC_CMD_MDIO_WRITE_OUT msgresponse */ +#define MC_CMD_MDIO_WRITE_OUT_LEN 4 +#define MC_CMD_MDIO_WRITE_OUT_STATUS_OFST 0 +/* MC_CMD_MDIO_STATUS_GOOD 0x8 */ + + +/***********************************/ +/* MC_CMD_DBI_WRITE + * Write DBI register(s). */ #define MC_CMD_DBI_WRITE 0x12 -#define MC_CMD_DBI_WRITE_IN_LEN(_numwords) \ - (12 * (_numwords)) -#define MC_CMD_DBI_WRITE_IN_ADDRESS_OFST(_word) \ - (((_word) * 12) + 0) -#define MC_CMD_DBI_WRITE_IN_BYTE_MASK_OFST(_word) \ - (((_word) * 12) + 4) -#define MC_CMD_DBI_WRITE_IN_VALUE_OFST(_word) \ - (((_word) * 12) + 8) -#define MC_CMD_DBI_WRITE_OUT_LEN 0 - -/* MC_CMD_DBI_READ: (debug) - * Read DBI register(s) - * - * Host: address, [,address ...] - * MC: value [,value ...] - * (note: this does not support reading from VFs, but is retained for backwards - * compatibility; see MC_CMD_DBI_READX below) - */ -#define MC_CMD_DBI_READ 0x13 -#define MC_CMD_DBI_READ_IN_LEN(_numwords) \ - (4 * (_numwords)) -#define MC_CMD_DBI_READ_OUT_LEN(_numwords) \ - (4 * (_numwords)) - -/* MC_CMD_PORT_READ32: (debug) + +/* MC_CMD_DBI_WRITE_IN msgrequest */ +#define MC_CMD_DBI_WRITE_IN_LENMIN 12 +#define MC_CMD_DBI_WRITE_IN_LENMAX 252 +#define MC_CMD_DBI_WRITE_IN_LEN(num) (0+12*(num)) +#define MC_CMD_DBI_WRITE_IN_DBIWROP_OFST 0 +#define MC_CMD_DBI_WRITE_IN_DBIWROP_LEN 12 +#define MC_CMD_DBI_WRITE_IN_DBIWROP_MINNUM 1 +#define MC_CMD_DBI_WRITE_IN_DBIWROP_MAXNUM 21 + +/* MC_CMD_DBI_WRITE_OUT msgresponse */ +#define MC_CMD_DBI_WRITE_OUT_LEN 0 + +/* MC_CMD_DBIWROP_TYPEDEF structuredef */ +#define MC_CMD_DBIWROP_TYPEDEF_LEN 12 +#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_OFST 0 +#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_LBN 0 +#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_WIDTH 32 +#define MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_OFST 4 +#define MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_LBN 32 +#define MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_WIDTH 32 +#define MC_CMD_DBIWROP_TYPEDEF_VALUE_OFST 8 +#define MC_CMD_DBIWROP_TYPEDEF_VALUE_LBN 64 +#define MC_CMD_DBIWROP_TYPEDEF_VALUE_WIDTH 32 + + +/***********************************/ +/* MC_CMD_PORT_READ32 * Read a 32-bit register from the indirect port register map. - * - * The port to access is implied by the Shared memory channel used. */ #define MC_CMD_PORT_READ32 0x14 -#define MC_CMD_PORT_READ32_IN_LEN 4 -#define MC_CMD_PORT_READ32_IN_ADDR_OFST 0 -#define MC_CMD_PORT_READ32_OUT_LEN 8 -#define MC_CMD_PORT_READ32_OUT_VALUE_OFST 0 -#define MC_CMD_PORT_READ32_OUT_STATUS_OFST 4 -/* MC_CMD_PORT_WRITE32: (debug) +/* MC_CMD_PORT_READ32_IN msgrequest */ +#define MC_CMD_PORT_READ32_IN_LEN 4 +#define MC_CMD_PORT_READ32_IN_ADDR_OFST 0 + +/* MC_CMD_PORT_READ32_OUT msgresponse */ +#define MC_CMD_PORT_READ32_OUT_LEN 8 +#define MC_CMD_PORT_READ32_OUT_VALUE_OFST 0 +#define MC_CMD_PORT_READ32_OUT_STATUS_OFST 4 + + +/***********************************/ +/* MC_CMD_PORT_WRITE32 * Write a 32-bit register to the indirect port register map. - * - * The port to access is implied by the Shared memory channel used. */ #define MC_CMD_PORT_WRITE32 0x15 -#define MC_CMD_PORT_WRITE32_IN_LEN 8 -#define MC_CMD_PORT_WRITE32_IN_ADDR_OFST 0 -#define MC_CMD_PORT_WRITE32_IN_VALUE_OFST 4 -#define MC_CMD_PORT_WRITE32_OUT_LEN 4 -#define MC_CMD_PORT_WRITE32_OUT_STATUS_OFST 0 - -/* MC_CMD_PORT_READ128: (debug) - * Read a 128-bit register from indirect port register map - * - * The port to access is implied by the Shared memory channel used. + +/* MC_CMD_PORT_WRITE32_IN msgrequest */ +#define MC_CMD_PORT_WRITE32_IN_LEN 8 +#define MC_CMD_PORT_WRITE32_IN_ADDR_OFST 0 +#define MC_CMD_PORT_WRITE32_IN_VALUE_OFST 4 + +/* MC_CMD_PORT_WRITE32_OUT msgresponse */ +#define MC_CMD_PORT_WRITE32_OUT_LEN 4 +#define MC_CMD_PORT_WRITE32_OUT_STATUS_OFST 0 + + +/***********************************/ +/* MC_CMD_PORT_READ128 + * Read a 128-bit register from the indirect port register map. */ #define MC_CMD_PORT_READ128 0x16 -#define MC_CMD_PORT_READ128_IN_LEN 4 -#define MC_CMD_PORT_READ128_IN_ADDR_OFST 0 -#define MC_CMD_PORT_READ128_OUT_LEN 20 -#define MC_CMD_PORT_READ128_OUT_VALUE_OFST 0 -#define MC_CMD_PORT_READ128_OUT_STATUS_OFST 16 - -/* MC_CMD_PORT_WRITE128: (debug) - * Write a 128-bit register to indirect port register map. - * - * The port to access is implied by the Shared memory channel used. + +/* MC_CMD_PORT_READ128_IN msgrequest */ +#define MC_CMD_PORT_READ128_IN_LEN 4 +#define MC_CMD_PORT_READ128_IN_ADDR_OFST 0 + +/* MC_CMD_PORT_READ128_OUT msgresponse */ +#define MC_CMD_PORT_READ128_OUT_LEN 20 +#define MC_CMD_PORT_READ128_OUT_VALUE_OFST 0 +#define MC_CMD_PORT_READ128_OUT_VALUE_LEN 16 +#define MC_CMD_PORT_READ128_OUT_STATUS_OFST 16 + + +/***********************************/ +/* MC_CMD_PORT_WRITE128 + * Write a 128-bit register to the indirect port register map. */ #define MC_CMD_PORT_WRITE128 0x17 -#define MC_CMD_PORT_WRITE128_IN_LEN 20 -#define MC_CMD_PORT_WRITE128_IN_ADDR_OFST 0 -#define MC_CMD_PORT_WRITE128_IN_VALUE_OFST 4 -#define MC_CMD_PORT_WRITE128_OUT_LEN 4 -#define MC_CMD_PORT_WRITE128_OUT_STATUS_OFST 0 - -/* MC_CMD_GET_BOARD_CFG: - * Returns the MC firmware configuration structure - * - * The FW_SUBTYPE_LIST contains a 16-bit value for each of the 12 types of - * NVRAM area. The values are defined in the firmware/mc/platform/.c file - * for a specific board type, but otherwise have no meaning to the MC; they - * are used by the driver to manage selection of appropriate firmware updates. + +/* MC_CMD_PORT_WRITE128_IN msgrequest */ +#define MC_CMD_PORT_WRITE128_IN_LEN 20 +#define MC_CMD_PORT_WRITE128_IN_ADDR_OFST 0 +#define MC_CMD_PORT_WRITE128_IN_VALUE_OFST 4 +#define MC_CMD_PORT_WRITE128_IN_VALUE_LEN 16 + +/* MC_CMD_PORT_WRITE128_OUT msgresponse */ +#define MC_CMD_PORT_WRITE128_OUT_LEN 4 +#define MC_CMD_PORT_WRITE128_OUT_STATUS_OFST 0 + + +/***********************************/ +/* MC_CMD_GET_BOARD_CFG + * Returns the MC firmware configuration structure. */ #define MC_CMD_GET_BOARD_CFG 0x18 -#define MC_CMD_GET_BOARD_CFG_IN_LEN 0 -#define MC_CMD_GET_BOARD_CFG_OUT_LEN 96 -#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_TYPE_OFST 0 -#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_OFST 4 -#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_LEN 32 -#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT0_OFST 36 -#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT1_OFST 40 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST 44 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_LEN 6 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_OFST 50 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_LEN 6 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT0_OFST 56 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT1_OFST 60 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT0_OFST 64 -#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT1_OFST 68 -#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST 72 -#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN 24 - -/* MC_CMD_DBI_READX: (debug) - * Read DBI register(s) -- extended functionality - * - * Host: vf selection, address, [,vf selection ...] - * MC: value [,value ...] + +/* MC_CMD_GET_BOARD_CFG_IN msgrequest */ +#define MC_CMD_GET_BOARD_CFG_IN_LEN 0 + +/* MC_CMD_GET_BOARD_CFG_OUT msgresponse */ +#define MC_CMD_GET_BOARD_CFG_OUT_LENMIN 96 +#define MC_CMD_GET_BOARD_CFG_OUT_LENMAX 136 +#define MC_CMD_GET_BOARD_CFG_OUT_LEN(num) (72+2*(num)) +#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_TYPE_OFST 0 +#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_OFST 4 +#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_LEN 32 +#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT0_OFST 36 +#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_LBN 0x0 /* enum */ +#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_WIDTH 0x1 /* enum */ +#define MC_CMD_CAPABILITIES_TURBO_LBN 0x1 /* enum */ +#define MC_CMD_CAPABILITIES_TURBO_WIDTH 0x1 /* enum */ +#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN 0x2 /* enum */ +#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_WIDTH 0x1 /* enum */ +#define MC_CMD_CAPABILITIES_PTP_LBN 0x3 /* enum */ +#define MC_CMD_CAPABILITIES_PTP_WIDTH 0x1 /* enum */ +#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT1_OFST 40 +/* Enum values, see field(s): */ +/* CAPABILITIES_PORT0 */ +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST 44 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_LEN 6 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_OFST 50 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_LEN 6 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT0_OFST 56 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT1_OFST 60 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT0_OFST 64 +#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT1_OFST 68 +#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST 72 +#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN 2 +#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM 12 +#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM 32 + + +/***********************************/ +/* MC_CMD_DBI_READX + * Read DBI register(s). */ #define MC_CMD_DBI_READX 0x19 -#define MC_CMD_DBI_READX_IN_LEN(_numwords) \ - (8*(_numwords)) -#define MC_CMD_DBI_READX_OUT_LEN(_numwords) \ - (4*(_numwords)) -/* MC_CMD_SET_RAND_SEED: - * Set the 16byte seed for the MC pseudo-random generator +/* MC_CMD_DBI_READX_IN msgrequest */ +#define MC_CMD_DBI_READX_IN_LENMIN 8 +#define MC_CMD_DBI_READX_IN_LENMAX 248 +#define MC_CMD_DBI_READX_IN_LEN(num) (0+8*(num)) +#define MC_CMD_DBI_READX_IN_DBIRDOP_OFST 0 +#define MC_CMD_DBI_READX_IN_DBIRDOP_LEN 8 +#define MC_CMD_DBI_READX_IN_DBIRDOP_LO_OFST 0 +#define MC_CMD_DBI_READX_IN_DBIRDOP_HI_OFST 4 +#define MC_CMD_DBI_READX_IN_DBIRDOP_MINNUM 1 +#define MC_CMD_DBI_READX_IN_DBIRDOP_MAXNUM 31 + +/* MC_CMD_DBI_READX_OUT msgresponse */ +#define MC_CMD_DBI_READX_OUT_LENMIN 4 +#define MC_CMD_DBI_READX_OUT_LENMAX 252 +#define MC_CMD_DBI_READX_OUT_LEN(num) (0+4*(num)) +#define MC_CMD_DBI_READX_OUT_VALUE_OFST 0 +#define MC_CMD_DBI_READX_OUT_VALUE_LEN 4 +#define MC_CMD_DBI_READX_OUT_VALUE_MINNUM 1 +#define MC_CMD_DBI_READX_OUT_VALUE_MAXNUM 63 + + +/***********************************/ +/* MC_CMD_SET_RAND_SEED + * Set the 16byte seed for the MC pseudo-random generator. */ #define MC_CMD_SET_RAND_SEED 0x1a -#define MC_CMD_SET_RAND_SEED_IN_LEN 16 -#define MC_CMD_SET_RAND_SEED_IN_SEED_OFST 0 -#define MC_CMD_SET_RAND_SEED_OUT_LEN 0 -/* MC_CMD_LTSSM_HIST: (debug) - * Retrieve the history of the LTSSM, if the build supports it. - * - * Host: nothing - * MC: variable number of LTSSM values, as bytes - * The history is read-to-clear. +/* MC_CMD_SET_RAND_SEED_IN msgrequest */ +#define MC_CMD_SET_RAND_SEED_IN_LEN 16 +#define MC_CMD_SET_RAND_SEED_IN_SEED_OFST 0 +#define MC_CMD_SET_RAND_SEED_IN_SEED_LEN 16 + +/* MC_CMD_SET_RAND_SEED_OUT msgresponse */ +#define MC_CMD_SET_RAND_SEED_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_LTSSM_HIST + * Retrieve the history of the PCIE LTSSM. */ #define MC_CMD_LTSSM_HIST 0x1b -/* MC_CMD_DRV_ATTACH: - * Inform MCPU that this port is managed on the host (i.e. driver active) +/* MC_CMD_LTSSM_HIST_IN msgrequest */ +#define MC_CMD_LTSSM_HIST_IN_LEN 0 + +/* MC_CMD_LTSSM_HIST_OUT msgresponse */ +#define MC_CMD_LTSSM_HIST_OUT_LENMIN 0 +#define MC_CMD_LTSSM_HIST_OUT_LENMAX 252 +#define MC_CMD_LTSSM_HIST_OUT_LEN(num) (0+4*(num)) +#define MC_CMD_LTSSM_HIST_OUT_DATA_OFST 0 +#define MC_CMD_LTSSM_HIST_OUT_DATA_LEN 4 +#define MC_CMD_LTSSM_HIST_OUT_DATA_MINNUM 0 +#define MC_CMD_LTSSM_HIST_OUT_DATA_MAXNUM 63 + + +/***********************************/ +/* MC_CMD_DRV_ATTACH + * Inform MCPU that this port is managed on the host. */ #define MC_CMD_DRV_ATTACH 0x1c -#define MC_CMD_DRV_ATTACH_IN_LEN 8 -#define MC_CMD_DRV_ATTACH_IN_NEW_STATE_OFST 0 -#define MC_CMD_DRV_ATTACH_IN_UPDATE_OFST 4 -#define MC_CMD_DRV_ATTACH_OUT_LEN 4 -#define MC_CMD_DRV_ATTACH_OUT_OLD_STATE_OFST 0 -/* MC_CMD_NCSI_PROD: (debug) - * Trigger an NC-SI event (and possibly an AEN in response) +/* MC_CMD_DRV_ATTACH_IN msgrequest */ +#define MC_CMD_DRV_ATTACH_IN_LEN 8 +#define MC_CMD_DRV_ATTACH_IN_NEW_STATE_OFST 0 +#define MC_CMD_DRV_ATTACH_IN_UPDATE_OFST 4 + +/* MC_CMD_DRV_ATTACH_OUT msgresponse */ +#define MC_CMD_DRV_ATTACH_OUT_LEN 4 +#define MC_CMD_DRV_ATTACH_OUT_OLD_STATE_OFST 0 + + +/***********************************/ +/* MC_CMD_NCSI_PROD + * Trigger an NC-SI event. */ #define MC_CMD_NCSI_PROD 0x1d -#define MC_CMD_NCSI_PROD_IN_LEN 4 -#define MC_CMD_NCSI_PROD_IN_EVENTS_OFST 0 -#define MC_CMD_NCSI_PROD_LINKCHANGE_LBN 0 -#define MC_CMD_NCSI_PROD_LINKCHANGE_WIDTH 1 -#define MC_CMD_NCSI_PROD_RESET_LBN 1 -#define MC_CMD_NCSI_PROD_RESET_WIDTH 1 -#define MC_CMD_NCSI_PROD_DRVATTACH_LBN 2 -#define MC_CMD_NCSI_PROD_DRVATTACH_WIDTH 1 -#define MC_CMD_NCSI_PROD_OUT_LEN 0 - -/* Enumeration */ -#define MC_CMD_NCSI_PROD_LINKCHANGE 0 -#define MC_CMD_NCSI_PROD_RESET 1 -#define MC_CMD_NCSI_PROD_DRVATTACH 2 - -/* MC_CMD_DEVEL: (debug) - * Reserved for development - */ -#define MC_CMD_DEVEL 0x1e - -/* MC_CMD_SHMUART: (debug) + +/* MC_CMD_NCSI_PROD_IN msgrequest */ +#define MC_CMD_NCSI_PROD_IN_LEN 4 +#define MC_CMD_NCSI_PROD_IN_EVENTS_OFST 0 +#define MC_CMD_NCSI_PROD_LINKCHANGE 0x0 /* enum */ +#define MC_CMD_NCSI_PROD_RESET 0x1 /* enum */ +#define MC_CMD_NCSI_PROD_DRVATTACH 0x2 /* enum */ +#define MC_CMD_NCSI_PROD_IN_LINKCHANGE_LBN 0 +#define MC_CMD_NCSI_PROD_IN_LINKCHANGE_WIDTH 1 +#define MC_CMD_NCSI_PROD_IN_RESET_LBN 1 +#define MC_CMD_NCSI_PROD_IN_RESET_WIDTH 1 +#define MC_CMD_NCSI_PROD_IN_DRVATTACH_LBN 2 +#define MC_CMD_NCSI_PROD_IN_DRVATTACH_WIDTH 1 + +/* MC_CMD_NCSI_PROD_OUT msgresponse */ +#define MC_CMD_NCSI_PROD_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_SHMUART * Route UART output to circular buffer in shared memory instead. */ #define MC_CMD_SHMUART 0x1f -#define MC_CMD_SHMUART_IN_FLAG_OFST 0 -#define MC_CMD_SHMUART_IN_LEN 4 -#define MC_CMD_SHMUART_OUT_LEN 0 -/* MC_CMD_PORT_RESET: - * Generic per-port reset. There is no equivalent for per-board reset. - * - * Locks required: None - * Return code: 0, ETIME - */ -#define MC_CMD_PORT_RESET 0x20 -#define MC_CMD_PORT_RESET_IN_LEN 0 -#define MC_CMD_PORT_RESET_OUT_LEN 0 - -/* MC_CMD_RESOURCE_LOCK: - * Generic resource lock/unlock interface. - * - * Locks required: None - * Return code: 0, - * EBUSY (if trylock is contended by other port), - * EDEADLK (if trylock is already acquired by this port) - * EINVAL (if unlock doesn't own the lock) - */ -#define MC_CMD_RESOURCE_LOCK 0x21 -#define MC_CMD_RESOURCE_LOCK_IN_LEN 8 -#define MC_CMD_RESOURCE_LOCK_IN_ACTION_OFST 0 -#define MC_CMD_RESOURCE_LOCK_ACTION_TRYLOCK 1 -#define MC_CMD_RESOURCE_LOCK_ACTION_UNLOCK 0 -#define MC_CMD_RESOURCE_LOCK_IN_RESOURCE_OFST 4 -#define MC_CMD_RESOURCE_LOCK_I2C 2 -#define MC_CMD_RESOURCE_LOCK_PHY 3 -#define MC_CMD_RESOURCE_LOCK_OUT_LEN 0 - -/* MC_CMD_SPI_COMMAND: (variadic in, variadic out) - * Read/Write to/from the SPI device. - * - * Locks required: SPI_LOCK - * Return code: 0, ETIME, EINVAL, EACCES (if SPI_LOCK is not held) - */ -#define MC_CMD_SPI_COMMAND 0x22 -#define MC_CMD_SPI_COMMAND_IN_LEN(_write_bytes) (12 + (_write_bytes)) -#define MC_CMD_SPI_COMMAND_IN_ARGS_OFST 0 -#define MC_CMD_SPI_COMMAND_IN_ARGS_ADDRESS_OFST 0 -#define MC_CMD_SPI_COMMAND_IN_ARGS_READ_BYTES_OFST 4 -#define MC_CMD_SPI_COMMAND_IN_ARGS_CHIP_SELECT_OFST 8 -/* Data to write here */ -#define MC_CMD_SPI_COMMAND_IN_WRITE_BUFFER_OFST 12 -#define MC_CMD_SPI_COMMAND_OUT_LEN(_read_bytes) (_read_bytes) -/* Data read here */ -#define MC_CMD_SPI_COMMAND_OUT_READ_BUFFER_OFST 0 - -/* MC_CMD_I2C_READ_WRITE: (variadic in, variadic out) - * Read/Write to/from the I2C bus. - * - * Locks required: I2C_LOCK - * Return code: 0, ETIME, EINVAL, EACCES (if I2C_LOCK is not held) - */ -#define MC_CMD_I2C_RW 0x23 -#define MC_CMD_I2C_RW_IN_LEN(_write_bytes) (8 + (_write_bytes)) -#define MC_CMD_I2C_RW_IN_ARGS_OFST 0 -#define MC_CMD_I2C_RW_IN_ARGS_ADDR_OFST 0 -#define MC_CMD_I2C_RW_IN_ARGS_READ_BYTES_OFST 4 -/* Data to write here */ -#define MC_CMD_I2C_RW_IN_WRITE_BUFFER_OFSET 8 -#define MC_CMD_I2C_RW_OUT_LEN(_read_bytes) (_read_bytes) -/* Data read here */ -#define MC_CMD_I2C_RW_OUT_READ_BUFFER_OFST 0 - -/* Generic phy capability bitmask */ -#define MC_CMD_PHY_CAP_10HDX_LBN 1 -#define MC_CMD_PHY_CAP_10HDX_WIDTH 1 -#define MC_CMD_PHY_CAP_10FDX_LBN 2 -#define MC_CMD_PHY_CAP_10FDX_WIDTH 1 -#define MC_CMD_PHY_CAP_100HDX_LBN 3 -#define MC_CMD_PHY_CAP_100HDX_WIDTH 1 -#define MC_CMD_PHY_CAP_100FDX_LBN 4 -#define MC_CMD_PHY_CAP_100FDX_WIDTH 1 -#define MC_CMD_PHY_CAP_1000HDX_LBN 5 -#define MC_CMD_PHY_CAP_1000HDX_WIDTH 1 -#define MC_CMD_PHY_CAP_1000FDX_LBN 6 -#define MC_CMD_PHY_CAP_1000FDX_WIDTH 1 -#define MC_CMD_PHY_CAP_10000FDX_LBN 7 -#define MC_CMD_PHY_CAP_10000FDX_WIDTH 1 -#define MC_CMD_PHY_CAP_PAUSE_LBN 8 -#define MC_CMD_PHY_CAP_PAUSE_WIDTH 1 -#define MC_CMD_PHY_CAP_ASYM_LBN 9 -#define MC_CMD_PHY_CAP_ASYM_WIDTH 1 -#define MC_CMD_PHY_CAP_AN_LBN 10 -#define MC_CMD_PHY_CAP_AN_WIDTH 1 - -/* Generic loopback enumeration */ -#define MC_CMD_LOOPBACK_NONE 0 -#define MC_CMD_LOOPBACK_DATA 1 -#define MC_CMD_LOOPBACK_GMAC 2 -#define MC_CMD_LOOPBACK_XGMII 3 -#define MC_CMD_LOOPBACK_XGXS 4 -#define MC_CMD_LOOPBACK_XAUI 5 -#define MC_CMD_LOOPBACK_GMII 6 -#define MC_CMD_LOOPBACK_SGMII 7 -#define MC_CMD_LOOPBACK_XGBR 8 -#define MC_CMD_LOOPBACK_XFI 9 -#define MC_CMD_LOOPBACK_XAUI_FAR 10 -#define MC_CMD_LOOPBACK_GMII_FAR 11 -#define MC_CMD_LOOPBACK_SGMII_FAR 12 -#define MC_CMD_LOOPBACK_XFI_FAR 13 -#define MC_CMD_LOOPBACK_GPHY 14 -#define MC_CMD_LOOPBACK_PHYXS 15 -#define MC_CMD_LOOPBACK_PCS 16 -#define MC_CMD_LOOPBACK_PMAPMD 17 -#define MC_CMD_LOOPBACK_XPORT 18 -#define MC_CMD_LOOPBACK_XGMII_WS 19 -#define MC_CMD_LOOPBACK_XAUI_WS 20 -#define MC_CMD_LOOPBACK_XAUI_WS_FAR 21 -#define MC_CMD_LOOPBACK_XAUI_WS_NEAR 22 -#define MC_CMD_LOOPBACK_GMII_WS 23 -#define MC_CMD_LOOPBACK_XFI_WS 24 -#define MC_CMD_LOOPBACK_XFI_WS_FAR 25 -#define MC_CMD_LOOPBACK_PHYXS_WS 26 - -/* Generic PHY statistics enumeration */ -#define MC_CMD_OUI 0 -#define MC_CMD_PMA_PMD_LINK_UP 1 -#define MC_CMD_PMA_PMD_RX_FAULT 2 -#define MC_CMD_PMA_PMD_TX_FAULT 3 -#define MC_CMD_PMA_PMD_SIGNAL 4 -#define MC_CMD_PMA_PMD_SNR_A 5 -#define MC_CMD_PMA_PMD_SNR_B 6 -#define MC_CMD_PMA_PMD_SNR_C 7 -#define MC_CMD_PMA_PMD_SNR_D 8 -#define MC_CMD_PCS_LINK_UP 9 -#define MC_CMD_PCS_RX_FAULT 10 -#define MC_CMD_PCS_TX_FAULT 11 -#define MC_CMD_PCS_BER 12 -#define MC_CMD_PCS_BLOCK_ERRORS 13 -#define MC_CMD_PHYXS_LINK_UP 14 -#define MC_CMD_PHYXS_RX_FAULT 15 -#define MC_CMD_PHYXS_TX_FAULT 16 -#define MC_CMD_PHYXS_ALIGN 17 -#define MC_CMD_PHYXS_SYNC 18 -#define MC_CMD_AN_LINK_UP 19 -#define MC_CMD_AN_COMPLETE 20 -#define MC_CMD_AN_10GBT_STATUS 21 -#define MC_CMD_CL22_LINK_UP 22 -#define MC_CMD_PHY_NSTATS 23 - -/* MC_CMD_GET_PHY_CFG: - * Report PHY configuration. This guarantees to succeed even if the PHY is in - * a "zombie" state. - * - * Locks required: None - * Return code: 0 +/* MC_CMD_SHMUART_IN msgrequest */ +#define MC_CMD_SHMUART_IN_LEN 4 +#define MC_CMD_SHMUART_IN_FLAG_OFST 0 + +/* MC_CMD_SHMUART_OUT msgresponse */ +#define MC_CMD_SHMUART_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_ENTITY_RESET + * Generic per-port reset. + */ +#define MC_CMD_ENTITY_RESET 0x20 + +/* MC_CMD_ENTITY_RESET_IN msgrequest */ +#define MC_CMD_ENTITY_RESET_IN_LEN 4 +#define MC_CMD_ENTITY_RESET_IN_FLAG_OFST 0 +#define MC_CMD_ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET_LBN 0 +#define MC_CMD_ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET_WIDTH 1 + +/* MC_CMD_ENTITY_RESET_OUT msgresponse */ +#define MC_CMD_ENTITY_RESET_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_PCIE_CREDITS + * Read instantaneous and minimum flow control thresholds. + */ +#define MC_CMD_PCIE_CREDITS 0x21 + +/* MC_CMD_PCIE_CREDITS_IN msgrequest */ +#define MC_CMD_PCIE_CREDITS_IN_LEN 8 +#define MC_CMD_PCIE_CREDITS_IN_POLL_PERIOD_OFST 0 +#define MC_CMD_PCIE_CREDITS_IN_WIPE_OFST 4 + +/* MC_CMD_PCIE_CREDITS_OUT msgresponse */ +#define MC_CMD_PCIE_CREDITS_OUT_LEN 16 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_HDR_OFST 0 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_HDR_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_DATA_OFST 2 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_DATA_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_HDR_OFST 4 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_HDR_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_DATA_OFST 6 +#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_DATA_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_HDR_OFST 8 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_HDR_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_DATA_OFST 10 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_DATA_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_HDR_OFST 12 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_HDR_LEN 2 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_DATA_OFST 14 +#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_DATA_LEN 2 + + +/***********************************/ +/* MC_CMD_RXD_MONITOR + * Get histogram of RX queue fill level. + */ +#define MC_CMD_RXD_MONITOR 0x22 + +/* MC_CMD_RXD_MONITOR_IN msgrequest */ +#define MC_CMD_RXD_MONITOR_IN_LEN 12 +#define MC_CMD_RXD_MONITOR_IN_QID_OFST 0 +#define MC_CMD_RXD_MONITOR_IN_POLL_PERIOD_OFST 4 +#define MC_CMD_RXD_MONITOR_IN_WIPE_OFST 8 + +/* MC_CMD_RXD_MONITOR_OUT msgresponse */ +#define MC_CMD_RXD_MONITOR_OUT_LEN 80 +#define MC_CMD_RXD_MONITOR_OUT_QID_OFST 0 +#define MC_CMD_RXD_MONITOR_OUT_RING_FILL_OFST 4 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_FILL_OFST 8 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_1_OFST 12 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_2_OFST 16 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_4_OFST 20 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_8_OFST 24 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_16_OFST 28 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_32_OFST 32 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_64_OFST 36 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_128_OFST 40 +#define MC_CMD_RXD_MONITOR_OUT_RING_LT_256_OFST 44 +#define MC_CMD_RXD_MONITOR_OUT_RING_GE_256_OFST 48 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_1_OFST 52 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_2_OFST 56 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_4_OFST 60 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_8_OFST 64 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_16_OFST 68 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_32_OFST 72 +#define MC_CMD_RXD_MONITOR_OUT_CACHE_GE_32_OFST 76 + + +/***********************************/ +/* MC_CMD_PUTS + * puts(3) implementation over MCDI + */ +#define MC_CMD_PUTS 0x23 + +/* MC_CMD_PUTS_IN msgrequest */ +#define MC_CMD_PUTS_IN_LENMIN 13 +#define MC_CMD_PUTS_IN_LENMAX 255 +#define MC_CMD_PUTS_IN_LEN(num) (12+1*(num)) +#define MC_CMD_PUTS_IN_DEST_OFST 0 +#define MC_CMD_PUTS_IN_UART_LBN 0 +#define MC_CMD_PUTS_IN_UART_WIDTH 1 +#define MC_CMD_PUTS_IN_PORT_LBN 1 +#define MC_CMD_PUTS_IN_PORT_WIDTH 1 +#define MC_CMD_PUTS_IN_DHOST_OFST 4 +#define MC_CMD_PUTS_IN_DHOST_LEN 6 +#define MC_CMD_PUTS_IN_STRING_OFST 12 +#define MC_CMD_PUTS_IN_STRING_LEN 1 +#define MC_CMD_PUTS_IN_STRING_MINNUM 1 +#define MC_CMD_PUTS_IN_STRING_MAXNUM 243 + +/* MC_CMD_PUTS_OUT msgresponse */ +#define MC_CMD_PUTS_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_GET_PHY_CFG + * Report PHY configuration. */ #define MC_CMD_GET_PHY_CFG 0x24 -#define MC_CMD_GET_PHY_CFG_IN_LEN 0 -#define MC_CMD_GET_PHY_CFG_OUT_LEN 72 - -#define MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0 -#define MC_CMD_GET_PHY_CFG_PRESENT_LBN 0 -#define MC_CMD_GET_PHY_CFG_PRESENT_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN 1 -#define MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN 2 -#define MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_LOWPOWER_LBN 3 -#define MC_CMD_GET_PHY_CFG_LOWPOWER_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_POWEROFF_LBN 4 -#define MC_CMD_GET_PHY_CFG_POWEROFF_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_TXDIS_LBN 5 -#define MC_CMD_GET_PHY_CFG_TXDIS_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_BIST_LBN 6 -#define MC_CMD_GET_PHY_CFG_BIST_WIDTH 1 -#define MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4 -/* Bitmask of supported capabilities */ -#define MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8 -#define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12 -#define MC_CMD_GET_PHY_CFG_OUT_PRT_OFST 16 -/* PHY statistics bitmap */ -#define MC_CMD_GET_PHY_CFG_OUT_STATS_MASK_OFST 20 -/* PHY type/name string */ -#define MC_CMD_GET_PHY_CFG_OUT_NAME_OFST 24 -#define MC_CMD_GET_PHY_CFG_OUT_NAME_LEN 20 -#define MC_CMD_GET_PHY_CFG_OUT_MEDIA_TYPE_OFST 44 -#define MC_CMD_MEDIA_XAUI 1 -#define MC_CMD_MEDIA_CX4 2 -#define MC_CMD_MEDIA_KX4 3 -#define MC_CMD_MEDIA_XFP 4 -#define MC_CMD_MEDIA_SFP_PLUS 5 -#define MC_CMD_MEDIA_BASE_T 6 -/* MDIO "MMDS" supported */ -#define MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_OFST 48 -/* Native clause 22 */ -#define MC_CMD_MMD_CLAUSE22 0 -#define MC_CMD_MMD_CLAUSE45_PMAPMD 1 -#define MC_CMD_MMD_CLAUSE45_WIS 2 -#define MC_CMD_MMD_CLAUSE45_PCS 3 -#define MC_CMD_MMD_CLAUSE45_PHYXS 4 -#define MC_CMD_MMD_CLAUSE45_DTEXS 5 -#define MC_CMD_MMD_CLAUSE45_TC 6 -#define MC_CMD_MMD_CLAUSE45_AN 7 -/* Clause22 proxied over clause45 by PHY */ -#define MC_CMD_MMD_CLAUSE45_C22EXT 29 -#define MC_CMD_MMD_CLAUSE45_VEND1 30 -#define MC_CMD_MMD_CLAUSE45_VEND2 31 -/* PHY stepping version */ -#define MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52 -#define MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN 20 - -/* MC_CMD_START_BIST: +/* MC_CMD_GET_PHY_CFG_IN msgrequest */ +#define MC_CMD_GET_PHY_CFG_IN_LEN 0 + +/* MC_CMD_GET_PHY_CFG_OUT msgresponse */ +#define MC_CMD_GET_PHY_CFG_OUT_LEN 72 +#define MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0 +#define MC_CMD_GET_PHY_CFG_OUT_PRESENT_LBN 0 +#define MC_CMD_GET_PHY_CFG_OUT_PRESENT_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN 1 +#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN 2 +#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN 3 +#define MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN 4 +#define MC_CMD_GET_PHY_CFG_OUT_POWEROFF_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN 5 +#define MC_CMD_GET_PHY_CFG_OUT_TXDIS_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_BIST_LBN 6 +#define MC_CMD_GET_PHY_CFG_OUT_BIST_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4 +#define MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8 +#define MC_CMD_PHY_CAP_10HDX_LBN 1 +#define MC_CMD_PHY_CAP_10HDX_WIDTH 1 +#define MC_CMD_PHY_CAP_10FDX_LBN 2 +#define MC_CMD_PHY_CAP_10FDX_WIDTH 1 +#define MC_CMD_PHY_CAP_100HDX_LBN 3 +#define MC_CMD_PHY_CAP_100HDX_WIDTH 1 +#define MC_CMD_PHY_CAP_100FDX_LBN 4 +#define MC_CMD_PHY_CAP_100FDX_WIDTH 1 +#define MC_CMD_PHY_CAP_1000HDX_LBN 5 +#define MC_CMD_PHY_CAP_1000HDX_WIDTH 1 +#define MC_CMD_PHY_CAP_1000FDX_LBN 6 +#define MC_CMD_PHY_CAP_1000FDX_WIDTH 1 +#define MC_CMD_PHY_CAP_10000FDX_LBN 7 +#define MC_CMD_PHY_CAP_10000FDX_WIDTH 1 +#define MC_CMD_PHY_CAP_PAUSE_LBN 8 +#define MC_CMD_PHY_CAP_PAUSE_WIDTH 1 +#define MC_CMD_PHY_CAP_ASYM_LBN 9 +#define MC_CMD_PHY_CAP_ASYM_WIDTH 1 +#define MC_CMD_PHY_CAP_AN_LBN 10 +#define MC_CMD_PHY_CAP_AN_WIDTH 1 +#define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12 +#define MC_CMD_GET_PHY_CFG_OUT_PRT_OFST 16 +#define MC_CMD_GET_PHY_CFG_OUT_STATS_MASK_OFST 20 +#define MC_CMD_GET_PHY_CFG_OUT_NAME_OFST 24 +#define MC_CMD_GET_PHY_CFG_OUT_NAME_LEN 20 +#define MC_CMD_GET_PHY_CFG_OUT_MEDIA_TYPE_OFST 44 +#define MC_CMD_MEDIA_XAUI 0x1 /* enum */ +#define MC_CMD_MEDIA_CX4 0x2 /* enum */ +#define MC_CMD_MEDIA_KX4 0x3 /* enum */ +#define MC_CMD_MEDIA_XFP 0x4 /* enum */ +#define MC_CMD_MEDIA_SFP_PLUS 0x5 /* enum */ +#define MC_CMD_MEDIA_BASE_T 0x6 /* enum */ +#define MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_OFST 48 +#define MC_CMD_MMD_CLAUSE22 0x0 /* enum */ +#define MC_CMD_MMD_CLAUSE45_PMAPMD 0x1 /* enum */ +#define MC_CMD_MMD_CLAUSE45_WIS 0x2 /* enum */ +#define MC_CMD_MMD_CLAUSE45_PCS 0x3 /* enum */ +#define MC_CMD_MMD_CLAUSE45_PHYXS 0x4 /* enum */ +#define MC_CMD_MMD_CLAUSE45_DTEXS 0x5 /* enum */ +#define MC_CMD_MMD_CLAUSE45_TC 0x6 /* enum */ +#define MC_CMD_MMD_CLAUSE45_AN 0x7 /* enum */ +#define MC_CMD_MMD_CLAUSE45_C22EXT 0x1d /* enum */ +#define MC_CMD_MMD_CLAUSE45_VEND1 0x1e /* enum */ +#define MC_CMD_MMD_CLAUSE45_VEND2 0x1f /* enum */ +#define MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52 +#define MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN 20 + + +/***********************************/ +/* MC_CMD_START_BIST * Start a BIST test on the PHY. - * - * Locks required: PHY_LOCK if doing a PHY BIST - * Return code: 0, EINVAL, EACCES (if PHY_LOCK is not held) */ #define MC_CMD_START_BIST 0x25 -#define MC_CMD_START_BIST_IN_LEN 4 -#define MC_CMD_START_BIST_IN_TYPE_OFST 0 -#define MC_CMD_START_BIST_OUT_LEN 0 - -/* Run the PHY's short cable BIST */ -#define MC_CMD_PHY_BIST_CABLE_SHORT 1 -/* Run the PHY's long cable BIST */ -#define MC_CMD_PHY_BIST_CABLE_LONG 2 -/* Run BIST on the currently selected BPX Serdes (XAUI or XFI) */ -#define MC_CMD_BPX_SERDES_BIST 3 -/* Run the MC loopback tests */ -#define MC_CMD_MC_LOOPBACK_BIST 4 -/* Run the PHY's standard BIST */ -#define MC_CMD_PHY_BIST 5 - -/* MC_CMD_POLL_PHY_BIST: (variadic output) - * Poll for BIST completion - * - * Returns a single status code, and optionally some PHY specific - * bist output. The driver should only consume the BIST output - * after validating OUTLEN and PHY_CFG.PHY_TYPE. - * - * If a driver can't successfully parse the BIST output, it should - * still respect the pass/Fail in OUT.RESULT - * - * Locks required: PHY_LOCK if doing a PHY BIST - * Return code: 0, EACCES (if PHY_LOCK is not held) + +/* MC_CMD_START_BIST_IN msgrequest */ +#define MC_CMD_START_BIST_IN_LEN 4 +#define MC_CMD_START_BIST_IN_TYPE_OFST 0 +#define MC_CMD_PHY_BIST_CABLE_SHORT 0x1 /* enum */ +#define MC_CMD_PHY_BIST_CABLE_LONG 0x2 /* enum */ +#define MC_CMD_BPX_SERDES_BIST 0x3 /* enum */ +#define MC_CMD_MC_LOOPBACK_BIST 0x4 /* enum */ +#define MC_CMD_PHY_BIST 0x5 /* enum */ + +/* MC_CMD_START_BIST_OUT msgresponse */ +#define MC_CMD_START_BIST_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_POLL_BIST + * Poll for BIST completion. */ #define MC_CMD_POLL_BIST 0x26 -#define MC_CMD_POLL_BIST_IN_LEN 0 -#define MC_CMD_POLL_BIST_OUT_LEN UNKNOWN -#define MC_CMD_POLL_BIST_OUT_SFT9001_LEN 36 -#define MC_CMD_POLL_BIST_OUT_MRSFP_LEN 8 -#define MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 -#define MC_CMD_POLL_BIST_RUNNING 1 -#define MC_CMD_POLL_BIST_PASSED 2 -#define MC_CMD_POLL_BIST_FAILED 3 -#define MC_CMD_POLL_BIST_TIMEOUT 4 -/* Generic: */ -#define MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4 -/* SFT9001-specific: */ -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A_OFST 4 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_B_OFST 8 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_C_OFST 12 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_D_OFST 16 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_A_OFST 20 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_B_OFST 24 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_C_OFST 28 -#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_D_OFST 32 -#define MC_CMD_POLL_BIST_SFT9001_PAIR_OK 1 -#define MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 2 -#define MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 3 -#define MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 4 -#define MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 9 -/* mrsfp "PHY" driver: */ -#define MC_CMD_POLL_BIST_OUT_MRSFP_TEST_OFST 4 -#define MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0 -#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 1 -#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 2 -#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 3 -#define MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 4 -#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 5 -#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 6 -#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 7 -#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 8 - -/* MC_CMD_PHY_SPI: (variadic in, variadic out) - * Read/Write/Erase the PHY SPI device - * - * Locks required: PHY_LOCK - * Return code: 0, ETIME, EINVAL, EACCES (if PHY_LOCK is not held) - */ -#define MC_CMD_PHY_SPI 0x27 -#define MC_CMD_PHY_SPI_IN_LEN(_write_bytes) (12 + (_write_bytes)) -#define MC_CMD_PHY_SPI_IN_ARGS_OFST 0 -#define MC_CMD_PHY_SPI_IN_ARGS_ADDR_OFST 0 -#define MC_CMD_PHY_SPI_IN_ARGS_READ_BYTES_OFST 4 -#define MC_CMD_PHY_SPI_IN_ARGS_ERASE_ALL_OFST 8 -/* Data to write here */ -#define MC_CMD_PHY_SPI_IN_WRITE_BUFFER_OFSET 12 -#define MC_CMD_PHY_SPI_OUT_LEN(_read_bytes) (_read_bytes) -/* Data read here */ -#define MC_CMD_PHY_SPI_OUT_READ_BUFFER_OFST 0 - - -/* MC_CMD_GET_LOOPBACK_MODES: - * Returns a bitmask of loopback modes evailable at each speed. - * - * Locks required: None - * Return code: 0 + +/* MC_CMD_POLL_BIST_IN msgrequest */ +#define MC_CMD_POLL_BIST_IN_LEN 0 + +/* MC_CMD_POLL_BIST_OUT msgresponse */ +#define MC_CMD_POLL_BIST_OUT_LEN 8 +#define MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 +#define MC_CMD_POLL_BIST_RUNNING 0x1 /* enum */ +#define MC_CMD_POLL_BIST_PASSED 0x2 /* enum */ +#define MC_CMD_POLL_BIST_FAILED 0x3 /* enum */ +#define MC_CMD_POLL_BIST_TIMEOUT 0x4 /* enum */ +#define MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4 + +/* MC_CMD_POLL_BIST_OUT_SFT9001 msgresponse */ +#define MC_CMD_POLL_BIST_OUT_SFT9001_LEN 36 +/* MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */ +/* Enum values, see field(s): */ +/* MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */ +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A_OFST 4 +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_B_OFST 8 +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_C_OFST 12 +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_D_OFST 16 +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_A_OFST 20 +#define MC_CMD_POLL_BIST_SFT9001_PAIR_OK 0x1 /* enum */ +#define MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 0x2 /* enum */ +#define MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 0x3 /* enum */ +#define MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 0x4 /* enum */ +#define MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 0x9 /* enum */ +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_B_OFST 24 +/* Enum values, see field(s): */ +/* CABLE_STATUS_A */ +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_C_OFST 28 +/* Enum values, see field(s): */ +/* CABLE_STATUS_A */ +#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_D_OFST 32 +/* Enum values, see field(s): */ +/* CABLE_STATUS_A */ + +/* MC_CMD_POLL_BIST_OUT_MRSFP msgresponse */ +#define MC_CMD_POLL_BIST_OUT_MRSFP_LEN 8 +/* MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */ +/* Enum values, see field(s): */ +/* MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */ +#define MC_CMD_POLL_BIST_OUT_MRSFP_TEST_OFST 4 +#define MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0x0 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 0x1 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 0x2 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 0x3 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 0x4 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 0x5 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 0x6 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 0x7 /* enum */ +#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 0x8 /* enum */ + + +/***********************************/ +/* MC_CMD_FLUSH_RX_QUEUES + * Flush receive queue(s). + */ +#define MC_CMD_FLUSH_RX_QUEUES 0x27 + +/* MC_CMD_FLUSH_RX_QUEUES_IN msgrequest */ +#define MC_CMD_FLUSH_RX_QUEUES_IN_LENMIN 4 +#define MC_CMD_FLUSH_RX_QUEUES_IN_LENMAX 252 +#define MC_CMD_FLUSH_RX_QUEUES_IN_LEN(num) (0+4*(num)) +#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_OFST 0 +#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_LEN 4 +#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MINNUM 1 +#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MAXNUM 63 + +/* MC_CMD_FLUSH_RX_QUEUES_OUT msgresponse */ +#define MC_CMD_FLUSH_RX_QUEUES_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_GET_LOOPBACK_MODES + * Get port's loopback modes. */ #define MC_CMD_GET_LOOPBACK_MODES 0x28 -#define MC_CMD_GET_LOOPBACK_MODES_IN_LEN 0 -#define MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 32 -#define MC_CMD_GET_LOOPBACK_MODES_100M_OFST 0 -#define MC_CMD_GET_LOOPBACK_MODES_1G_OFST 8 -#define MC_CMD_GET_LOOPBACK_MODES_10G_OFST 16 -#define MC_CMD_GET_LOOPBACK_MODES_SUGGESTED_OFST 24 - -/* Flow control enumeration */ -#define MC_CMD_FCNTL_OFF 0 -#define MC_CMD_FCNTL_RESPOND 1 -#define MC_CMD_FCNTL_BIDIR 2 -/* Auto - Use what the link has autonegotiated - * - The driver should modify the advertised capabilities via SET_LINK.CAP - * to control the negotiated flow control mode. - * - Can only be set if the PHY supports PAUSE+ASYM capabilities - * - Never returned by GET_LINK as the value programmed into the MAC - */ -#define MC_CMD_FCNTL_AUTO 3 - -/* Generic mac fault bitmask */ -#define MC_CMD_MAC_FAULT_XGMII_LOCAL_LBN 0 -#define MC_CMD_MAC_FAULT_XGMII_LOCAL_WIDTH 1 -#define MC_CMD_MAC_FAULT_XGMII_REMOTE_LBN 1 -#define MC_CMD_MAC_FAULT_XGMII_REMOTE_WIDTH 1 -#define MC_CMD_MAC_FAULT_SGMII_REMOTE_LBN 2 -#define MC_CMD_MAC_FAULT_SGMII_REMOTE_WIDTH 1 - -/* MC_CMD_GET_LINK: - * Read the unified MAC/PHY link state - * - * Locks required: None - * Return code: 0, ETIME + +/* MC_CMD_GET_LOOPBACK_MODES_IN msgrequest */ +#define MC_CMD_GET_LOOPBACK_MODES_IN_LEN 0 + +/* MC_CMD_GET_LOOPBACK_MODES_OUT msgresponse */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_LO_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_HI_OFST 4 +#define MC_CMD_LOOPBACK_NONE 0x0 /* enum */ +#define MC_CMD_LOOPBACK_DATA 0x1 /* enum */ +#define MC_CMD_LOOPBACK_GMAC 0x2 /* enum */ +#define MC_CMD_LOOPBACK_XGMII 0x3 /* enum */ +#define MC_CMD_LOOPBACK_XGXS 0x4 /* enum */ +#define MC_CMD_LOOPBACK_XAUI 0x5 /* enum */ +#define MC_CMD_LOOPBACK_GMII 0x6 /* enum */ +#define MC_CMD_LOOPBACK_SGMII 0x7 /* enum */ +#define MC_CMD_LOOPBACK_XGBR 0x8 /* enum */ +#define MC_CMD_LOOPBACK_XFI 0x9 /* enum */ +#define MC_CMD_LOOPBACK_XAUI_FAR 0xa /* enum */ +#define MC_CMD_LOOPBACK_GMII_FAR 0xb /* enum */ +#define MC_CMD_LOOPBACK_SGMII_FAR 0xc /* enum */ +#define MC_CMD_LOOPBACK_XFI_FAR 0xd /* enum */ +#define MC_CMD_LOOPBACK_GPHY 0xe /* enum */ +#define MC_CMD_LOOPBACK_PHYXS 0xf /* enum */ +#define MC_CMD_LOOPBACK_PCS 0x10 /* enum */ +#define MC_CMD_LOOPBACK_PMAPMD 0x11 /* enum */ +#define MC_CMD_LOOPBACK_XPORT 0x12 /* enum */ +#define MC_CMD_LOOPBACK_XGMII_WS 0x13 /* enum */ +#define MC_CMD_LOOPBACK_XAUI_WS 0x14 /* enum */ +#define MC_CMD_LOOPBACK_XAUI_WS_FAR 0x15 /* enum */ +#define MC_CMD_LOOPBACK_XAUI_WS_NEAR 0x16 /* enum */ +#define MC_CMD_LOOPBACK_GMII_WS 0x17 /* enum */ +#define MC_CMD_LOOPBACK_XFI_WS 0x18 /* enum */ +#define MC_CMD_LOOPBACK_XFI_WS_FAR 0x19 /* enum */ +#define MC_CMD_LOOPBACK_PHYXS_WS 0x1a /* enum */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_OFST 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LO_OFST 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_HI_OFST 12 +/* Enum values, see field(s): */ +/* 100M */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_OFST 16 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_LO_OFST 16 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_HI_OFST 20 +/* Enum values, see field(s): */ +/* 100M */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_OFST 24 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LO_OFST 24 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_HI_OFST 28 +/* Enum values, see field(s): */ +/* 100M */ + + +/***********************************/ +/* MC_CMD_GET_LINK + * Read the unified MAC/PHY link state. */ #define MC_CMD_GET_LINK 0x29 -#define MC_CMD_GET_LINK_IN_LEN 0 -#define MC_CMD_GET_LINK_OUT_LEN 28 -/* near-side and link-partner advertised capabilities */ -#define MC_CMD_GET_LINK_OUT_CAP_OFST 0 -#define MC_CMD_GET_LINK_OUT_LP_CAP_OFST 4 -/* Autonegotiated speed in mbit/s. The link may still be down - * even if this reads non-zero */ -#define MC_CMD_GET_LINK_OUT_LINK_SPEED_OFST 8 -#define MC_CMD_GET_LINK_OUT_LOOPBACK_MODE_OFST 12 -#define MC_CMD_GET_LINK_OUT_FLAGS_OFST 16 -/* Whether we have overall link up */ -#define MC_CMD_GET_LINK_LINK_UP_LBN 0 -#define MC_CMD_GET_LINK_LINK_UP_WIDTH 1 -#define MC_CMD_GET_LINK_FULL_DUPLEX_LBN 1 -#define MC_CMD_GET_LINK_FULL_DUPLEX_WIDTH 1 -/* Whether we have link at the layers provided by the BPX */ -#define MC_CMD_GET_LINK_BPX_LINK_LBN 2 -#define MC_CMD_GET_LINK_BPX_LINK_WIDTH 1 -/* Whether the PHY has external link */ -#define MC_CMD_GET_LINK_PHY_LINK_LBN 3 -#define MC_CMD_GET_LINK_PHY_LINK_WIDTH 1 -#define MC_CMD_GET_LINK_OUT_FCNTL_OFST 20 -#define MC_CMD_GET_LINK_OUT_MAC_FAULT_OFST 24 - -/* MC_CMD_SET_LINK: - * Write the unified MAC/PHY link configuration - * - * A loopback speed of "0" is supported, and means - * (choose any available speed) - * - * Locks required: None - * Return code: 0, EINVAL, ETIME + +/* MC_CMD_GET_LINK_IN msgrequest */ +#define MC_CMD_GET_LINK_IN_LEN 0 + +/* MC_CMD_GET_LINK_OUT msgresponse */ +#define MC_CMD_GET_LINK_OUT_LEN 28 +#define MC_CMD_GET_LINK_OUT_CAP_OFST 0 +#define MC_CMD_GET_LINK_OUT_LP_CAP_OFST 4 +#define MC_CMD_GET_LINK_OUT_LINK_SPEED_OFST 8 +#define MC_CMD_GET_LINK_OUT_LOOPBACK_MODE_OFST 12 +/* Enum values, see field(s): */ +/* MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */ +#define MC_CMD_GET_LINK_OUT_FLAGS_OFST 16 +#define MC_CMD_GET_LINK_OUT_LINK_UP_LBN 0 +#define MC_CMD_GET_LINK_OUT_LINK_UP_WIDTH 1 +#define MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN 1 +#define MC_CMD_GET_LINK_OUT_FULL_DUPLEX_WIDTH 1 +#define MC_CMD_GET_LINK_OUT_BPX_LINK_LBN 2 +#define MC_CMD_GET_LINK_OUT_BPX_LINK_WIDTH 1 +#define MC_CMD_GET_LINK_OUT_PHY_LINK_LBN 3 +#define MC_CMD_GET_LINK_OUT_PHY_LINK_WIDTH 1 +#define MC_CMD_GET_LINK_OUT_FCNTL_OFST 20 +#define MC_CMD_FCNTL_OFF 0x0 /* enum */ +#define MC_CMD_FCNTL_RESPOND 0x1 /* enum */ +#define MC_CMD_FCNTL_BIDIR 0x2 /* enum */ +#define MC_CMD_GET_LINK_OUT_MAC_FAULT_OFST 24 +#define MC_CMD_MAC_FAULT_XGMII_LOCAL_LBN 0 +#define MC_CMD_MAC_FAULT_XGMII_LOCAL_WIDTH 1 +#define MC_CMD_MAC_FAULT_XGMII_REMOTE_LBN 1 +#define MC_CMD_MAC_FAULT_XGMII_REMOTE_WIDTH 1 +#define MC_CMD_MAC_FAULT_SGMII_REMOTE_LBN 2 +#define MC_CMD_MAC_FAULT_SGMII_REMOTE_WIDTH 1 +#define MC_CMD_MAC_FAULT_PENDING_RECONFIG_LBN 3 +#define MC_CMD_MAC_FAULT_PENDING_RECONFIG_WIDTH 1 + + +/***********************************/ +/* MC_CMD_SET_LINK + * Write the unified MAC/PHY link configuration. */ #define MC_CMD_SET_LINK 0x2a -#define MC_CMD_SET_LINK_IN_LEN 16 -#define MC_CMD_SET_LINK_IN_CAP_OFST 0 -#define MC_CMD_SET_LINK_IN_FLAGS_OFST 4 -#define MC_CMD_SET_LINK_LOWPOWER_LBN 0 -#define MC_CMD_SET_LINK_LOWPOWER_WIDTH 1 -#define MC_CMD_SET_LINK_POWEROFF_LBN 1 -#define MC_CMD_SET_LINK_POWEROFF_WIDTH 1 -#define MC_CMD_SET_LINK_TXDIS_LBN 2 -#define MC_CMD_SET_LINK_TXDIS_WIDTH 1 -#define MC_CMD_SET_LINK_IN_LOOPBACK_MODE_OFST 8 -#define MC_CMD_SET_LINK_IN_LOOPBACK_SPEED_OFST 12 -#define MC_CMD_SET_LINK_OUT_LEN 0 - -/* MC_CMD_SET_ID_LED: - * Set indentification LED state - * - * Locks required: None - * Return code: 0, EINVAL + +/* MC_CMD_SET_LINK_IN msgrequest */ +#define MC_CMD_SET_LINK_IN_LEN 16 +#define MC_CMD_SET_LINK_IN_CAP_OFST 0 +#define MC_CMD_SET_LINK_IN_FLAGS_OFST 4 +#define MC_CMD_SET_LINK_IN_LOWPOWER_LBN 0 +#define MC_CMD_SET_LINK_IN_LOWPOWER_WIDTH 1 +#define MC_CMD_SET_LINK_IN_POWEROFF_LBN 1 +#define MC_CMD_SET_LINK_IN_POWEROFF_WIDTH 1 +#define MC_CMD_SET_LINK_IN_TXDIS_LBN 2 +#define MC_CMD_SET_LINK_IN_TXDIS_WIDTH 1 +#define MC_CMD_SET_LINK_IN_LOOPBACK_MODE_OFST 8 +/* Enum values, see field(s): */ +/* MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */ +#define MC_CMD_SET_LINK_IN_LOOPBACK_SPEED_OFST 12 + +/* MC_CMD_SET_LINK_OUT msgresponse */ +#define MC_CMD_SET_LINK_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_SET_ID_LED + * Set indentification LED state. */ #define MC_CMD_SET_ID_LED 0x2b -#define MC_CMD_SET_ID_LED_IN_LEN 4 -#define MC_CMD_SET_ID_LED_IN_STATE_OFST 0 -#define MC_CMD_LED_OFF 0 -#define MC_CMD_LED_ON 1 -#define MC_CMD_LED_DEFAULT 2 -#define MC_CMD_SET_ID_LED_OUT_LEN 0 - -/* MC_CMD_SET_MAC: - * Set MAC configuration - * - * The MTU is the MTU programmed directly into the XMAC/GMAC - * (inclusive of EtherII, VLAN, bug16011 padding) - * - * Locks required: None - * Return code: 0, EINVAL + +/* MC_CMD_SET_ID_LED_IN msgrequest */ +#define MC_CMD_SET_ID_LED_IN_LEN 4 +#define MC_CMD_SET_ID_LED_IN_STATE_OFST 0 +#define MC_CMD_LED_OFF 0x0 /* enum */ +#define MC_CMD_LED_ON 0x1 /* enum */ +#define MC_CMD_LED_DEFAULT 0x2 /* enum */ + +/* MC_CMD_SET_ID_LED_OUT msgresponse */ +#define MC_CMD_SET_ID_LED_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_SET_MAC + * Set MAC configuration. */ #define MC_CMD_SET_MAC 0x2c -#define MC_CMD_SET_MAC_IN_LEN 24 -#define MC_CMD_SET_MAC_IN_MTU_OFST 0 -#define MC_CMD_SET_MAC_IN_DRAIN_OFST 4 -#define MC_CMD_SET_MAC_IN_ADDR_OFST 8 -#define MC_CMD_SET_MAC_IN_REJECT_OFST 16 -#define MC_CMD_SET_MAC_IN_REJECT_UNCST_LBN 0 -#define MC_CMD_SET_MAC_IN_REJECT_UNCST_WIDTH 1 -#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_LBN 1 -#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_WIDTH 1 -#define MC_CMD_SET_MAC_IN_FCNTL_OFST 20 -#define MC_CMD_SET_MAC_OUT_LEN 0 - -/* MC_CMD_PHY_STATS: - * Get generic PHY statistics - * - * This call returns the statistics for a generic PHY in a sparse - * array (indexed by the enumerate). Each value is represented by - * a 32bit number. - * - * If the DMA_ADDR is 0, then no DMA is performed, and the statistics - * may be read directly out of shared memory. If DMA_ADDR != 0, then - * the statistics are dmad to that (page-aligned location) - * - * Locks required: None - * Returns: 0, ETIME - * Response methods: shared memory, event + +/* MC_CMD_SET_MAC_IN msgrequest */ +#define MC_CMD_SET_MAC_IN_LEN 24 +#define MC_CMD_SET_MAC_IN_MTU_OFST 0 +#define MC_CMD_SET_MAC_IN_DRAIN_OFST 4 +#define MC_CMD_SET_MAC_IN_ADDR_OFST 8 +#define MC_CMD_SET_MAC_IN_ADDR_LEN 8 +#define MC_CMD_SET_MAC_IN_ADDR_LO_OFST 8 +#define MC_CMD_SET_MAC_IN_ADDR_HI_OFST 12 +#define MC_CMD_SET_MAC_IN_REJECT_OFST 16 +#define MC_CMD_SET_MAC_IN_REJECT_UNCST_LBN 0 +#define MC_CMD_SET_MAC_IN_REJECT_UNCST_WIDTH 1 +#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_LBN 1 +#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_WIDTH 1 +#define MC_CMD_SET_MAC_IN_FCNTL_OFST 20 +/* MC_CMD_FCNTL_OFF 0x0 */ +/* MC_CMD_FCNTL_RESPOND 0x1 */ +/* MC_CMD_FCNTL_BIDIR 0x2 */ +#define MC_CMD_FCNTL_AUTO 0x3 /* enum */ + +/* MC_CMD_SET_MAC_OUT msgresponse */ +#define MC_CMD_SET_MAC_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_PHY_STATS + * Get generic PHY statistics. */ #define MC_CMD_PHY_STATS 0x2d -#define MC_CMD_PHY_STATS_IN_LEN 8 -#define MC_CMD_PHY_STATS_IN_DMA_ADDR_LO_OFST 0 -#define MC_CMD_PHY_STATS_IN_DMA_ADDR_HI_OFST 4 -#define MC_CMD_PHY_STATS_OUT_DMA_LEN 0 -#define MC_CMD_PHY_STATS_OUT_NO_DMA_LEN (MC_CMD_PHY_NSTATS * 4) - -/* Unified MAC statistics enumeration */ -#define MC_CMD_MAC_GENERATION_START 0 -#define MC_CMD_MAC_TX_PKTS 1 -#define MC_CMD_MAC_TX_PAUSE_PKTS 2 -#define MC_CMD_MAC_TX_CONTROL_PKTS 3 -#define MC_CMD_MAC_TX_UNICAST_PKTS 4 -#define MC_CMD_MAC_TX_MULTICAST_PKTS 5 -#define MC_CMD_MAC_TX_BROADCAST_PKTS 6 -#define MC_CMD_MAC_TX_BYTES 7 -#define MC_CMD_MAC_TX_BAD_BYTES 8 -#define MC_CMD_MAC_TX_LT64_PKTS 9 -#define MC_CMD_MAC_TX_64_PKTS 10 -#define MC_CMD_MAC_TX_65_TO_127_PKTS 11 -#define MC_CMD_MAC_TX_128_TO_255_PKTS 12 -#define MC_CMD_MAC_TX_256_TO_511_PKTS 13 -#define MC_CMD_MAC_TX_512_TO_1023_PKTS 14 -#define MC_CMD_MAC_TX_1024_TO_15XX_PKTS 15 -#define MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS 16 -#define MC_CMD_MAC_TX_GTJUMBO_PKTS 17 -#define MC_CMD_MAC_TX_BAD_FCS_PKTS 18 -#define MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS 19 -#define MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS 20 -#define MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS 21 -#define MC_CMD_MAC_TX_LATE_COLLISION_PKTS 22 -#define MC_CMD_MAC_TX_DEFERRED_PKTS 23 -#define MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS 24 -#define MC_CMD_MAC_TX_NON_TCPUDP_PKTS 25 -#define MC_CMD_MAC_TX_MAC_SRC_ERR_PKTS 26 -#define MC_CMD_MAC_TX_IP_SRC_ERR_PKTS 27 -#define MC_CMD_MAC_RX_PKTS 28 -#define MC_CMD_MAC_RX_PAUSE_PKTS 29 -#define MC_CMD_MAC_RX_GOOD_PKTS 30 -#define MC_CMD_MAC_RX_CONTROL_PKTS 31 -#define MC_CMD_MAC_RX_UNICAST_PKTS 32 -#define MC_CMD_MAC_RX_MULTICAST_PKTS 33 -#define MC_CMD_MAC_RX_BROADCAST_PKTS 34 -#define MC_CMD_MAC_RX_BYTES 35 -#define MC_CMD_MAC_RX_BAD_BYTES 36 -#define MC_CMD_MAC_RX_64_PKTS 37 -#define MC_CMD_MAC_RX_65_TO_127_PKTS 38 -#define MC_CMD_MAC_RX_128_TO_255_PKTS 39 -#define MC_CMD_MAC_RX_256_TO_511_PKTS 40 -#define MC_CMD_MAC_RX_512_TO_1023_PKTS 41 -#define MC_CMD_MAC_RX_1024_TO_15XX_PKTS 42 -#define MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS 43 -#define MC_CMD_MAC_RX_GTJUMBO_PKTS 44 -#define MC_CMD_MAC_RX_UNDERSIZE_PKTS 45 -#define MC_CMD_MAC_RX_BAD_FCS_PKTS 46 -#define MC_CMD_MAC_RX_OVERFLOW_PKTS 47 -#define MC_CMD_MAC_RX_FALSE_CARRIER_PKTS 48 -#define MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS 49 -#define MC_CMD_MAC_RX_ALIGN_ERROR_PKTS 50 -#define MC_CMD_MAC_RX_LENGTH_ERROR_PKTS 51 -#define MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS 52 -#define MC_CMD_MAC_RX_JABBER_PKTS 53 -#define MC_CMD_MAC_RX_NODESC_DROPS 54 -#define MC_CMD_MAC_RX_LANES01_CHAR_ERR 55 -#define MC_CMD_MAC_RX_LANES23_CHAR_ERR 56 -#define MC_CMD_MAC_RX_LANES01_DISP_ERR 57 -#define MC_CMD_MAC_RX_LANES23_DISP_ERR 58 -#define MC_CMD_MAC_RX_MATCH_FAULT 59 -#define MC_CMD_GMAC_DMABUF_START 64 -#define MC_CMD_GMAC_DMABUF_END 95 -/* Insert new members here. */ -#define MC_CMD_MAC_GENERATION_END 96 -#define MC_CMD_MAC_NSTATS (MC_CMD_MAC_GENERATION_END+1) - -/* MC_CMD_MAC_STATS: - * Get unified GMAC/XMAC statistics - * - * This call returns unified statistics maintained by the MC as it - * switches between the GMAC and XMAC. The MC will write out all - * supported stats. The driver should zero initialise the buffer to - * guarantee consistent results. - * - * Locks required: None - * Returns: 0 - * Response methods: shared memory, event - */ -#define MC_CMD_MAC_STATS 0x2e -#define MC_CMD_MAC_STATS_IN_LEN 16 -#define MC_CMD_MAC_STATS_IN_DMA_ADDR_LO_OFST 0 -#define MC_CMD_MAC_STATS_IN_DMA_ADDR_HI_OFST 4 -#define MC_CMD_MAC_STATS_IN_CMD_OFST 8 -#define MC_CMD_MAC_STATS_CMD_DMA_LBN 0 -#define MC_CMD_MAC_STATS_CMD_DMA_WIDTH 1 -#define MC_CMD_MAC_STATS_CMD_CLEAR_LBN 1 -#define MC_CMD_MAC_STATS_CMD_CLEAR_WIDTH 1 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_CHANGE_LBN 2 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_CHANGE_WIDTH 1 -/* Remaining PERIOD* fields only relevant when PERIODIC_CHANGE is set */ -#define MC_CMD_MAC_STATS_CMD_PERIODIC_ENABLE_LBN 3 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_ENABLE_WIDTH 1 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_CLEAR_LBN 4 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_CLEAR_WIDTH 1 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_NOEVENT_LBN 5 -#define MC_CMD_MAC_STATS_CMD_PERIODIC_NOEVENT_WIDTH 1 -#define MC_CMD_MAC_STATS_CMD_PERIOD_MS_LBN 16 -#define MC_CMD_MAC_STATS_CMD_PERIOD_MS_WIDTH 16 -#define MC_CMD_MAC_STATS_IN_DMA_LEN_OFST 12 - -#define MC_CMD_MAC_STATS_OUT_LEN 0 - -/* Callisto flags */ -#define MC_CMD_SFT9001_ROBUST_LBN 0 -#define MC_CMD_SFT9001_ROBUST_WIDTH 1 -#define MC_CMD_SFT9001_SHORT_REACH_LBN 1 -#define MC_CMD_SFT9001_SHORT_REACH_WIDTH 1 - -/* MC_CMD_SFT9001_GET: - * Read current callisto specific setting - * - * Locks required: None - * Returns: 0, ETIME - */ -#define MC_CMD_SFT9001_GET 0x30 -#define MC_CMD_SFT9001_GET_IN_LEN 0 -#define MC_CMD_SFT9001_GET_OUT_LEN 4 -#define MC_CMD_SFT9001_GET_OUT_FLAGS_OFST 0 -/* MC_CMD_SFT9001_SET: - * Write current callisto specific setting - * - * Locks required: None - * Returns: 0, ETIME, EINVAL +/* MC_CMD_PHY_STATS_IN msgrequest */ +#define MC_CMD_PHY_STATS_IN_LEN 8 +#define MC_CMD_PHY_STATS_IN_DMA_ADDR_OFST 0 +#define MC_CMD_PHY_STATS_IN_DMA_ADDR_LEN 8 +#define MC_CMD_PHY_STATS_IN_DMA_ADDR_LO_OFST 0 +#define MC_CMD_PHY_STATS_IN_DMA_ADDR_HI_OFST 4 + +/* MC_CMD_PHY_STATS_OUT_DMA msgresponse */ +#define MC_CMD_PHY_STATS_OUT_DMA_LEN 0 + +/* MC_CMD_PHY_STATS_OUT_NO_DMA msgresponse */ +#define MC_CMD_PHY_STATS_OUT_NO_DMA_LEN (((MC_CMD_PHY_NSTATS*32))>>3) +#define MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_OFST 0 +#define MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_LEN 4 +#define MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_NUM MC_CMD_PHY_NSTATS +#define MC_CMD_OUI 0x0 /* enum */ +#define MC_CMD_PMA_PMD_LINK_UP 0x1 /* enum */ +#define MC_CMD_PMA_PMD_RX_FAULT 0x2 /* enum */ +#define MC_CMD_PMA_PMD_TX_FAULT 0x3 /* enum */ +#define MC_CMD_PMA_PMD_SIGNAL 0x4 /* enum */ +#define MC_CMD_PMA_PMD_SNR_A 0x5 /* enum */ +#define MC_CMD_PMA_PMD_SNR_B 0x6 /* enum */ +#define MC_CMD_PMA_PMD_SNR_C 0x7 /* enum */ +#define MC_CMD_PMA_PMD_SNR_D 0x8 /* enum */ +#define MC_CMD_PCS_LINK_UP 0x9 /* enum */ +#define MC_CMD_PCS_RX_FAULT 0xa /* enum */ +#define MC_CMD_PCS_TX_FAULT 0xb /* enum */ +#define MC_CMD_PCS_BER 0xc /* enum */ +#define MC_CMD_PCS_BLOCK_ERRORS 0xd /* enum */ +#define MC_CMD_PHYXS_LINK_UP 0xe /* enum */ +#define MC_CMD_PHYXS_RX_FAULT 0xf /* enum */ +#define MC_CMD_PHYXS_TX_FAULT 0x10 /* enum */ +#define MC_CMD_PHYXS_ALIGN 0x11 /* enum */ +#define MC_CMD_PHYXS_SYNC 0x12 /* enum */ +#define MC_CMD_AN_LINK_UP 0x13 /* enum */ +#define MC_CMD_AN_COMPLETE 0x14 /* enum */ +#define MC_CMD_AN_10GBT_STATUS 0x15 /* enum */ +#define MC_CMD_CL22_LINK_UP 0x16 /* enum */ +#define MC_CMD_PHY_NSTATS 0x17 /* enum */ + + +/***********************************/ +/* MC_CMD_MAC_STATS + * Get generic MAC statistics. */ -#define MC_CMD_SFT9001_SET 0x31 -#define MC_CMD_SFT9001_SET_IN_LEN 4 -#define MC_CMD_SFT9001_SET_IN_FLAGS_OFST 0 -#define MC_CMD_SFT9001_SET_OUT_LEN 0 - +#define MC_CMD_MAC_STATS 0x2e -/* MC_CMD_WOL_FILTER_SET: - * Set a WoL filter - * - * Locks required: None - * Returns: 0, EBUSY, EINVAL, ENOSYS +/* MC_CMD_MAC_STATS_IN msgrequest */ +#define MC_CMD_MAC_STATS_IN_LEN 16 +#define MC_CMD_MAC_STATS_IN_DMA_ADDR_OFST 0 +#define MC_CMD_MAC_STATS_IN_DMA_ADDR_LEN 8 +#define MC_CMD_MAC_STATS_IN_DMA_ADDR_LO_OFST 0 +#define MC_CMD_MAC_STATS_IN_DMA_ADDR_HI_OFST 4 +#define MC_CMD_MAC_STATS_IN_CMD_OFST 8 +#define MC_CMD_MAC_STATS_IN_DMA_LBN 0 +#define MC_CMD_MAC_STATS_IN_DMA_WIDTH 1 +#define MC_CMD_MAC_STATS_IN_CLEAR_LBN 1 +#define MC_CMD_MAC_STATS_IN_CLEAR_WIDTH 1 +#define MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE_LBN 2 +#define MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE_WIDTH 1 +#define MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE_LBN 3 +#define MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE_WIDTH 1 +#define MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR_LBN 4 +#define MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR_WIDTH 1 +#define MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT_LBN 5 +#define MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT_WIDTH 1 +#define MC_CMD_MAC_STATS_IN_PERIOD_MS_LBN 16 +#define MC_CMD_MAC_STATS_IN_PERIOD_MS_WIDTH 16 +#define MC_CMD_MAC_STATS_IN_DMA_LEN_OFST 12 + +/* MC_CMD_MAC_STATS_OUT_DMA msgresponse */ +#define MC_CMD_MAC_STATS_OUT_DMA_LEN 0 + +/* MC_CMD_MAC_STATS_OUT_NO_DMA msgresponse */ +#define MC_CMD_MAC_STATS_OUT_NO_DMA_LEN (((MC_CMD_MAC_NSTATS*64))>>3) +#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_OFST 0 +#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_LEN 8 +#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_LO_OFST 0 +#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_HI_OFST 4 +#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_NUM MC_CMD_MAC_NSTATS +#define MC_CMD_MAC_GENERATION_START 0x0 /* enum */ +#define MC_CMD_MAC_TX_PKTS 0x1 /* enum */ +#define MC_CMD_MAC_TX_PAUSE_PKTS 0x2 /* enum */ +#define MC_CMD_MAC_TX_CONTROL_PKTS 0x3 /* enum */ +#define MC_CMD_MAC_TX_UNICAST_PKTS 0x4 /* enum */ +#define MC_CMD_MAC_TX_MULTICAST_PKTS 0x5 /* enum */ +#define MC_CMD_MAC_TX_BROADCAST_PKTS 0x6 /* enum */ +#define MC_CMD_MAC_TX_BYTES 0x7 /* enum */ +#define MC_CMD_MAC_TX_BAD_BYTES 0x8 /* enum */ +#define MC_CMD_MAC_TX_LT64_PKTS 0x9 /* enum */ +#define MC_CMD_MAC_TX_64_PKTS 0xa /* enum */ +#define MC_CMD_MAC_TX_65_TO_127_PKTS 0xb /* enum */ +#define MC_CMD_MAC_TX_128_TO_255_PKTS 0xc /* enum */ +#define MC_CMD_MAC_TX_256_TO_511_PKTS 0xd /* enum */ +#define MC_CMD_MAC_TX_512_TO_1023_PKTS 0xe /* enum */ +#define MC_CMD_MAC_TX_1024_TO_15XX_PKTS 0xf /* enum */ +#define MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS 0x10 /* enum */ +#define MC_CMD_MAC_TX_GTJUMBO_PKTS 0x11 /* enum */ +#define MC_CMD_MAC_TX_BAD_FCS_PKTS 0x12 /* enum */ +#define MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS 0x13 /* enum */ +#define MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS 0x14 /* enum */ +#define MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS 0x15 /* enum */ +#define MC_CMD_MAC_TX_LATE_COLLISION_PKTS 0x16 /* enum */ +#define MC_CMD_MAC_TX_DEFERRED_PKTS 0x17 /* enum */ +#define MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS 0x18 /* enum */ +#define MC_CMD_MAC_TX_NON_TCPUDP_PKTS 0x19 /* enum */ +#define MC_CMD_MAC_TX_MAC_SRC_ERR_PKTS 0x1a /* enum */ +#define MC_CMD_MAC_TX_IP_SRC_ERR_PKTS 0x1b /* enum */ +#define MC_CMD_MAC_RX_PKTS 0x1c /* enum */ +#define MC_CMD_MAC_RX_PAUSE_PKTS 0x1d /* enum */ +#define MC_CMD_MAC_RX_GOOD_PKTS 0x1e /* enum */ +#define MC_CMD_MAC_RX_CONTROL_PKTS 0x1f /* enum */ +#define MC_CMD_MAC_RX_UNICAST_PKTS 0x20 /* enum */ +#define MC_CMD_MAC_RX_MULTICAST_PKTS 0x21 /* enum */ +#define MC_CMD_MAC_RX_BROADCAST_PKTS 0x22 /* enum */ +#define MC_CMD_MAC_RX_BYTES 0x23 /* enum */ +#define MC_CMD_MAC_RX_BAD_BYTES 0x24 /* enum */ +#define MC_CMD_MAC_RX_64_PKTS 0x25 /* enum */ +#define MC_CMD_MAC_RX_65_TO_127_PKTS 0x26 /* enum */ +#define MC_CMD_MAC_RX_128_TO_255_PKTS 0x27 /* enum */ +#define MC_CMD_MAC_RX_256_TO_511_PKTS 0x28 /* enum */ +#define MC_CMD_MAC_RX_512_TO_1023_PKTS 0x29 /* enum */ +#define MC_CMD_MAC_RX_1024_TO_15XX_PKTS 0x2a /* enum */ +#define MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS 0x2b /* enum */ +#define MC_CMD_MAC_RX_GTJUMBO_PKTS 0x2c /* enum */ +#define MC_CMD_MAC_RX_UNDERSIZE_PKTS 0x2d /* enum */ +#define MC_CMD_MAC_RX_BAD_FCS_PKTS 0x2e /* enum */ +#define MC_CMD_MAC_RX_OVERFLOW_PKTS 0x2f /* enum */ +#define MC_CMD_MAC_RX_FALSE_CARRIER_PKTS 0x30 /* enum */ +#define MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS 0x31 /* enum */ +#define MC_CMD_MAC_RX_ALIGN_ERROR_PKTS 0x32 /* enum */ +#define MC_CMD_MAC_RX_LENGTH_ERROR_PKTS 0x33 /* enum */ +#define MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS 0x34 /* enum */ +#define MC_CMD_MAC_RX_JABBER_PKTS 0x35 /* enum */ +#define MC_CMD_MAC_RX_NODESC_DROPS 0x36 /* enum */ +#define MC_CMD_MAC_RX_LANES01_CHAR_ERR 0x37 /* enum */ +#define MC_CMD_MAC_RX_LANES23_CHAR_ERR 0x38 /* enum */ +#define MC_CMD_MAC_RX_LANES01_DISP_ERR 0x39 /* enum */ +#define MC_CMD_MAC_RX_LANES23_DISP_ERR 0x3a /* enum */ +#define MC_CMD_MAC_RX_MATCH_FAULT 0x3b /* enum */ +#define MC_CMD_GMAC_DMABUF_START 0x40 /* enum */ +#define MC_CMD_GMAC_DMABUF_END 0x5f /* enum */ +#define MC_CMD_MAC_GENERATION_END 0x60 /* enum */ +#define MC_CMD_MAC_NSTATS 0x61 /* enum */ + + +/***********************************/ +/* MC_CMD_SRIOV + * to be documented + */ +#define MC_CMD_SRIOV 0x30 + +/* MC_CMD_SRIOV_IN msgrequest */ +#define MC_CMD_SRIOV_IN_LEN 12 +#define MC_CMD_SRIOV_IN_ENABLE_OFST 0 +#define MC_CMD_SRIOV_IN_VI_BASE_OFST 4 +#define MC_CMD_SRIOV_IN_VF_COUNT_OFST 8 + +/* MC_CMD_SRIOV_OUT msgresponse */ +#define MC_CMD_SRIOV_OUT_LEN 8 +#define MC_CMD_SRIOV_OUT_VI_SCALE_OFST 0 +#define MC_CMD_SRIOV_OUT_VF_TOTAL_OFST 4 + +/* MC_CMD_MEMCPY_RECORD_TYPEDEF structuredef */ +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LEN 32 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_OFST 0 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_LBN 0 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_WIDTH 32 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_RID_OFST 4 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_RID_LBN 32 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_RID_WIDTH 32 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_OFST 8 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_LEN 8 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_LO_OFST 8 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_HI_OFST 12 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_LBN 64 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_WIDTH 64 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_RID_OFST 16 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_RID_INLINE 0x100 /* enum */ +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_RID_LBN 128 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_RID_WIDTH 32 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_OFST 20 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LEN 8 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LO_OFST 20 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_HI_OFST 24 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LBN 160 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_WIDTH 64 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LENGTH_OFST 28 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LENGTH_LBN 224 +#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LENGTH_WIDTH 32 + + +/***********************************/ +/* MC_CMD_MEMCPY + * Perform memory copy operation. + */ +#define MC_CMD_MEMCPY 0x31 + +/* MC_CMD_MEMCPY_IN msgrequest */ +#define MC_CMD_MEMCPY_IN_LENMIN 32 +#define MC_CMD_MEMCPY_IN_LENMAX 224 +#define MC_CMD_MEMCPY_IN_LEN(num) (0+32*(num)) +#define MC_CMD_MEMCPY_IN_RECORD_OFST 0 +#define MC_CMD_MEMCPY_IN_RECORD_LEN 32 +#define MC_CMD_MEMCPY_IN_RECORD_MINNUM 1 +#define MC_CMD_MEMCPY_IN_RECORD_MAXNUM 7 + +/* MC_CMD_MEMCPY_OUT msgresponse */ +#define MC_CMD_MEMCPY_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_WOL_FILTER_SET + * Set a WoL filter. */ #define MC_CMD_WOL_FILTER_SET 0x32 -#define MC_CMD_WOL_FILTER_SET_IN_LEN 192 /* 190 rounded up to a word */ -#define MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 -#define MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 - -/* There is a union at offset 8, following defines overlap due to - * this */ -#define MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 8 - -#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_OFST \ - MC_CMD_WOL_FILTER_SET_IN_DATA_OFST - -#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_IP_OFST \ - MC_CMD_WOL_FILTER_SET_IN_DATA_OFST -#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_IP_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 4) -#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_PORT_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 8) -#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_PORT_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 10) - -#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_IP_OFST \ - MC_CMD_WOL_FILTER_SET_IN_DATA_OFST -#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_IP_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 16) -#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_PORT_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 32) -#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_PORT_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 34) - -#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_MASK_OFST \ - MC_CMD_WOL_FILTER_SET_IN_DATA_OFST -#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 48) -#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 176) -#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER3_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 177) -#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_OFST \ - (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 178) - -#define MC_CMD_WOL_FILTER_SET_IN_LINK_MASK_OFST \ - MC_CMD_WOL_FILTER_SET_IN_DATA_OFST -#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_LBN 0 -#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_WIDTH 1 -#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_LBN 1 -#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_WIDTH 1 - -#define MC_CMD_WOL_FILTER_SET_OUT_LEN 4 -#define MC_CMD_WOL_FILTER_SET_OUT_FILTER_ID_OFST 0 - -/* WOL Filter types enumeration */ -#define MC_CMD_WOL_TYPE_MAGIC 0x0 - /* unused 0x1 */ -#define MC_CMD_WOL_TYPE_WIN_MAGIC 0x2 -#define MC_CMD_WOL_TYPE_IPV4_SYN 0x3 -#define MC_CMD_WOL_TYPE_IPV6_SYN 0x4 -#define MC_CMD_WOL_TYPE_BITMAP 0x5 -#define MC_CMD_WOL_TYPE_LINK 0x6 -#define MC_CMD_WOL_TYPE_MAX 0x7 - -#define MC_CMD_FILTER_MODE_SIMPLE 0x0 -#define MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff - -/* MC_CMD_WOL_FILTER_REMOVE: - * Remove a WoL filter - * - * Locks required: None - * Returns: 0, EINVAL, ENOSYS + +/* MC_CMD_WOL_FILTER_SET_IN msgrequest */ +#define MC_CMD_WOL_FILTER_SET_IN_LEN 192 +#define MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 +#define MC_CMD_FILTER_MODE_SIMPLE 0x0 /* enum */ +#define MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff /* enum */ +#define MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 +#define MC_CMD_WOL_TYPE_MAGIC 0x0 /* enum */ +#define MC_CMD_WOL_TYPE_WIN_MAGIC 0x2 /* enum */ +#define MC_CMD_WOL_TYPE_IPV4_SYN 0x3 /* enum */ +#define MC_CMD_WOL_TYPE_IPV6_SYN 0x4 /* enum */ +#define MC_CMD_WOL_TYPE_BITMAP 0x5 /* enum */ +#define MC_CMD_WOL_TYPE_LINK 0x6 /* enum */ +#define MC_CMD_WOL_TYPE_MAX 0x7 /* enum */ +#define MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_DATA_LEN 4 +#define MC_CMD_WOL_FILTER_SET_IN_DATA_NUM 46 + +/* MC_CMD_WOL_FILTER_SET_IN_MAGIC msgrequest */ +#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_LEN 16 +/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */ +/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */ +#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_LEN 8 +#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_LO_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_HI_OFST 12 + +/* MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN msgrequest */ +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_LEN 20 +/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */ +/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */ +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_IP_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_IP_OFST 12 +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_PORT_OFST 16 +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_PORT_LEN 2 +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_PORT_OFST 18 +#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_PORT_LEN 2 + +/* MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN msgrequest */ +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_LEN 44 +/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */ +/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */ +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_IP_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_IP_LEN 16 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_IP_OFST 24 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_IP_LEN 16 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_PORT_OFST 40 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_PORT_LEN 2 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_PORT_OFST 42 +#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_PORT_LEN 2 + +/* MC_CMD_WOL_FILTER_SET_IN_BITMAP msgrequest */ +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN 187 +/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */ +/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */ +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_MASK_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_MASK_LEN 48 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_BITMAP_OFST 56 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_BITMAP_LEN 128 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN_OFST 184 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN_LEN 1 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER3_OFST 185 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER3_LEN 1 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_OFST 186 +#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_LEN 1 + +/* MC_CMD_WOL_FILTER_SET_IN_LINK msgrequest */ +#define MC_CMD_WOL_FILTER_SET_IN_LINK_LEN 12 +/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */ +/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */ +#define MC_CMD_WOL_FILTER_SET_IN_LINK_MASK_OFST 8 +#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_LBN 0 +#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_WIDTH 1 +#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_LBN 1 +#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_WIDTH 1 + +/* MC_CMD_WOL_FILTER_SET_OUT msgresponse */ +#define MC_CMD_WOL_FILTER_SET_OUT_LEN 4 +#define MC_CMD_WOL_FILTER_SET_OUT_FILTER_ID_OFST 0 + + +/***********************************/ +/* MC_CMD_WOL_FILTER_REMOVE + * Remove a WoL filter. */ #define MC_CMD_WOL_FILTER_REMOVE 0x33 -#define MC_CMD_WOL_FILTER_REMOVE_IN_LEN 4 -#define MC_CMD_WOL_FILTER_REMOVE_IN_FILTER_ID_OFST 0 -#define MC_CMD_WOL_FILTER_REMOVE_OUT_LEN 0 +/* MC_CMD_WOL_FILTER_REMOVE_IN msgrequest */ +#define MC_CMD_WOL_FILTER_REMOVE_IN_LEN 4 +#define MC_CMD_WOL_FILTER_REMOVE_IN_FILTER_ID_OFST 0 -/* MC_CMD_WOL_FILTER_RESET: - * Reset (i.e. remove all) WoL filters - * - * Locks required: None - * Returns: 0, ENOSYS +/* MC_CMD_WOL_FILTER_REMOVE_OUT msgresponse */ +#define MC_CMD_WOL_FILTER_REMOVE_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_WOL_FILTER_RESET + * Reset (i.e. remove all) WoL filters. */ #define MC_CMD_WOL_FILTER_RESET 0x34 -#define MC_CMD_WOL_FILTER_RESET_IN_LEN 0 -#define MC_CMD_WOL_FILTER_RESET_OUT_LEN 0 -/* MC_CMD_SET_MCAST_HASH: - * Set the MCASH hash value without otherwise - * reconfiguring the MAC +/* MC_CMD_WOL_FILTER_RESET_IN msgrequest */ +#define MC_CMD_WOL_FILTER_RESET_IN_LEN 4 +#define MC_CMD_WOL_FILTER_RESET_IN_MASK_OFST 0 +#define MC_CMD_WOL_FILTER_RESET_IN_WAKE_FILTERS 0x1 /* enum */ +#define MC_CMD_WOL_FILTER_RESET_IN_LIGHTSOUT_OFFLOADS 0x2 /* enum */ + +/* MC_CMD_WOL_FILTER_RESET_OUT msgresponse */ +#define MC_CMD_WOL_FILTER_RESET_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_SET_MCAST_HASH + * Set the MCASH hash value. */ #define MC_CMD_SET_MCAST_HASH 0x35 -#define MC_CMD_SET_MCAST_HASH_IN_LEN 32 -#define MC_CMD_SET_MCAST_HASH_IN_HASH0_OFST 0 -#define MC_CMD_SET_MCAST_HASH_IN_HASH1_OFST 16 -#define MC_CMD_SET_MCAST_HASH_OUT_LEN 0 -/* MC_CMD_NVRAM_TYPES: - * Return bitfield indicating available types of virtual NVRAM partitions - * - * Locks required: none - * Returns: 0 +/* MC_CMD_SET_MCAST_HASH_IN msgrequest */ +#define MC_CMD_SET_MCAST_HASH_IN_LEN 32 +#define MC_CMD_SET_MCAST_HASH_IN_HASH0_OFST 0 +#define MC_CMD_SET_MCAST_HASH_IN_HASH0_LEN 16 +#define MC_CMD_SET_MCAST_HASH_IN_HASH1_OFST 16 +#define MC_CMD_SET_MCAST_HASH_IN_HASH1_LEN 16 + +/* MC_CMD_SET_MCAST_HASH_OUT msgresponse */ +#define MC_CMD_SET_MCAST_HASH_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_NVRAM_TYPES + * Get virtual NVRAM partitions information. */ #define MC_CMD_NVRAM_TYPES 0x36 -#define MC_CMD_NVRAM_TYPES_IN_LEN 0 -#define MC_CMD_NVRAM_TYPES_OUT_LEN 4 -#define MC_CMD_NVRAM_TYPES_OUT_TYPES_OFST 0 - -/* Supported NVRAM types */ -#define MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO 0 -#define MC_CMD_NVRAM_TYPE_MC_FW 1 -#define MC_CMD_NVRAM_TYPE_MC_FW_BACKUP 2 -#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 3 -#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1 4 -#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 5 -#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1 6 -#define MC_CMD_NVRAM_TYPE_EXP_ROM 7 -#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0 8 -#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1 9 -#define MC_CMD_NVRAM_TYPE_PHY_PORT0 10 -#define MC_CMD_NVRAM_TYPE_PHY_PORT1 11 -#define MC_CMD_NVRAM_TYPE_LOG 12 - -/* MC_CMD_NVRAM_INFO: - * Read info about a virtual NVRAM partition - * - * Locks required: none - * Returns: 0, EINVAL (bad type) + +/* MC_CMD_NVRAM_TYPES_IN msgrequest */ +#define MC_CMD_NVRAM_TYPES_IN_LEN 0 + +/* MC_CMD_NVRAM_TYPES_OUT msgresponse */ +#define MC_CMD_NVRAM_TYPES_OUT_LEN 4 +#define MC_CMD_NVRAM_TYPES_OUT_TYPES_OFST 0 +#define MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO 0x0 /* enum */ +#define MC_CMD_NVRAM_TYPE_MC_FW 0x1 /* enum */ +#define MC_CMD_NVRAM_TYPE_MC_FW_BACKUP 0x2 /* enum */ +#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 0x3 /* enum */ +#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1 0x4 /* enum */ +#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 0x5 /* enum */ +#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1 0x6 /* enum */ +#define MC_CMD_NVRAM_TYPE_EXP_ROM 0x7 /* enum */ +#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0 0x8 /* enum */ +#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1 0x9 /* enum */ +#define MC_CMD_NVRAM_TYPE_PHY_PORT0 0xa /* enum */ +#define MC_CMD_NVRAM_TYPE_PHY_PORT1 0xb /* enum */ +#define MC_CMD_NVRAM_TYPE_LOG 0xc /* enum */ +#define MC_CMD_NVRAM_TYPE_FPGA 0xd /* enum */ + + +/***********************************/ +/* MC_CMD_NVRAM_INFO + * Read info about a virtual NVRAM partition. */ #define MC_CMD_NVRAM_INFO 0x37 -#define MC_CMD_NVRAM_INFO_IN_LEN 4 -#define MC_CMD_NVRAM_INFO_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_INFO_OUT_LEN 24 -#define MC_CMD_NVRAM_INFO_OUT_TYPE_OFST 0 -#define MC_CMD_NVRAM_INFO_OUT_SIZE_OFST 4 -#define MC_CMD_NVRAM_INFO_OUT_ERASESIZE_OFST 8 -#define MC_CMD_NVRAM_INFO_OUT_FLAGS_OFST 12 -#define MC_CMD_NVRAM_PROTECTED_LBN 0 -#define MC_CMD_NVRAM_PROTECTED_WIDTH 1 -#define MC_CMD_NVRAM_INFO_OUT_PHYSDEV_OFST 16 -#define MC_CMD_NVRAM_INFO_OUT_PHYSADDR_OFST 20 - -/* MC_CMD_NVRAM_UPDATE_START: - * Start a group of update operations on a virtual NVRAM partition - * - * Locks required: PHY_LOCK if type==*PHY* - * Returns: 0, EINVAL (bad type), EACCES (if PHY_LOCK required and not held) + +/* MC_CMD_NVRAM_INFO_IN msgrequest */ +#define MC_CMD_NVRAM_INFO_IN_LEN 4 +#define MC_CMD_NVRAM_INFO_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ + +/* MC_CMD_NVRAM_INFO_OUT msgresponse */ +#define MC_CMD_NVRAM_INFO_OUT_LEN 24 +#define MC_CMD_NVRAM_INFO_OUT_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ +#define MC_CMD_NVRAM_INFO_OUT_SIZE_OFST 4 +#define MC_CMD_NVRAM_INFO_OUT_ERASESIZE_OFST 8 +#define MC_CMD_NVRAM_INFO_OUT_FLAGS_OFST 12 +#define MC_CMD_NVRAM_INFO_OUT_PROTECTED_LBN 0 +#define MC_CMD_NVRAM_INFO_OUT_PROTECTED_WIDTH 1 +#define MC_CMD_NVRAM_INFO_OUT_PHYSDEV_OFST 16 +#define MC_CMD_NVRAM_INFO_OUT_PHYSADDR_OFST 20 + + +/***********************************/ +/* MC_CMD_NVRAM_UPDATE_START + * Start a group of update operations on a virtual NVRAM partition. */ #define MC_CMD_NVRAM_UPDATE_START 0x38 -#define MC_CMD_NVRAM_UPDATE_START_IN_LEN 4 -#define MC_CMD_NVRAM_UPDATE_START_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_UPDATE_START_OUT_LEN 0 -/* MC_CMD_NVRAM_READ: - * Read data from a virtual NVRAM partition - * - * Locks required: PHY_LOCK if type==*PHY* - * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) +/* MC_CMD_NVRAM_UPDATE_START_IN msgrequest */ +#define MC_CMD_NVRAM_UPDATE_START_IN_LEN 4 +#define MC_CMD_NVRAM_UPDATE_START_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ + +/* MC_CMD_NVRAM_UPDATE_START_OUT msgresponse */ +#define MC_CMD_NVRAM_UPDATE_START_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_NVRAM_READ + * Read data from a virtual NVRAM partition. */ #define MC_CMD_NVRAM_READ 0x39 -#define MC_CMD_NVRAM_READ_IN_LEN 12 -#define MC_CMD_NVRAM_READ_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_READ_IN_OFFSET_OFST 4 -#define MC_CMD_NVRAM_READ_IN_LENGTH_OFST 8 -#define MC_CMD_NVRAM_READ_OUT_LEN(_read_bytes) (_read_bytes) -#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_OFST 0 - -/* MC_CMD_NVRAM_WRITE: - * Write data to a virtual NVRAM partition - * - * Locks required: PHY_LOCK if type==*PHY* - * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) + +/* MC_CMD_NVRAM_READ_IN msgrequest */ +#define MC_CMD_NVRAM_READ_IN_LEN 12 +#define MC_CMD_NVRAM_READ_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ +#define MC_CMD_NVRAM_READ_IN_OFFSET_OFST 4 +#define MC_CMD_NVRAM_READ_IN_LENGTH_OFST 8 + +/* MC_CMD_NVRAM_READ_OUT msgresponse */ +#define MC_CMD_NVRAM_READ_OUT_LENMIN 1 +#define MC_CMD_NVRAM_READ_OUT_LENMAX 255 +#define MC_CMD_NVRAM_READ_OUT_LEN(num) (0+1*(num)) +#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_OFST 0 +#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_LEN 1 +#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MINNUM 1 +#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MAXNUM 255 + + +/***********************************/ +/* MC_CMD_NVRAM_WRITE + * Write data to a virtual NVRAM partition. */ #define MC_CMD_NVRAM_WRITE 0x3a -#define MC_CMD_NVRAM_WRITE_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_WRITE_IN_OFFSET_OFST 4 -#define MC_CMD_NVRAM_WRITE_IN_LENGTH_OFST 8 -#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_OFST 12 -#define MC_CMD_NVRAM_WRITE_IN_LEN(_write_bytes) (12 + _write_bytes) -#define MC_CMD_NVRAM_WRITE_OUT_LEN 0 - -/* MC_CMD_NVRAM_ERASE: - * Erase sector(s) from a virtual NVRAM partition - * - * Locks required: PHY_LOCK if type==*PHY* - * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) + +/* MC_CMD_NVRAM_WRITE_IN msgrequest */ +#define MC_CMD_NVRAM_WRITE_IN_LENMIN 13 +#define MC_CMD_NVRAM_WRITE_IN_LENMAX 255 +#define MC_CMD_NVRAM_WRITE_IN_LEN(num) (12+1*(num)) +#define MC_CMD_NVRAM_WRITE_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ +#define MC_CMD_NVRAM_WRITE_IN_OFFSET_OFST 4 +#define MC_CMD_NVRAM_WRITE_IN_LENGTH_OFST 8 +#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_OFST 12 +#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_LEN 1 +#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MINNUM 1 +#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MAXNUM 243 + +/* MC_CMD_NVRAM_WRITE_OUT msgresponse */ +#define MC_CMD_NVRAM_WRITE_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_NVRAM_ERASE + * Erase sector(s) from a virtual NVRAM partition. */ #define MC_CMD_NVRAM_ERASE 0x3b -#define MC_CMD_NVRAM_ERASE_IN_LEN 12 -#define MC_CMD_NVRAM_ERASE_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_ERASE_IN_OFFSET_OFST 4 -#define MC_CMD_NVRAM_ERASE_IN_LENGTH_OFST 8 -#define MC_CMD_NVRAM_ERASE_OUT_LEN 0 - -/* MC_CMD_NVRAM_UPDATE_FINISH: - * Finish a group of update operations on a virtual NVRAM partition - * - * Locks required: PHY_LOCK if type==*PHY* - * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) + +/* MC_CMD_NVRAM_ERASE_IN msgrequest */ +#define MC_CMD_NVRAM_ERASE_IN_LEN 12 +#define MC_CMD_NVRAM_ERASE_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ +#define MC_CMD_NVRAM_ERASE_IN_OFFSET_OFST 4 +#define MC_CMD_NVRAM_ERASE_IN_LENGTH_OFST 8 + +/* MC_CMD_NVRAM_ERASE_OUT msgresponse */ +#define MC_CMD_NVRAM_ERASE_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_NVRAM_UPDATE_FINISH + * Finish a group of update operations on a virtual NVRAM partition. */ #define MC_CMD_NVRAM_UPDATE_FINISH 0x3c -#define MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN 8 -#define MC_CMD_NVRAM_UPDATE_FINISH_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_UPDATE_FINISH_IN_REBOOT_OFST 4 -#define MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN 0 -/* MC_CMD_REBOOT: +/* MC_CMD_NVRAM_UPDATE_FINISH_IN msgrequest */ +#define MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN 8 +#define MC_CMD_NVRAM_UPDATE_FINISH_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ +#define MC_CMD_NVRAM_UPDATE_FINISH_IN_REBOOT_OFST 4 + +/* MC_CMD_NVRAM_UPDATE_FINISH_OUT msgresponse */ +#define MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_REBOOT * Reboot the MC. - * - * The AFTER_ASSERTION flag is intended to be used when the driver notices - * an assertion failure (at which point it is expected to perform a complete - * tear down and reinitialise), to allow both ports to reset the MC once - * in an atomic fashion. - * - * Production mc firmwares are generally compiled with REBOOT_ON_ASSERT=1, - * which means that they will automatically reboot out of the assertion - * handler, so this is in practise an optional operation. It is still - * recommended that drivers execute this to support custom firmwares - * with REBOOT_ON_ASSERT=0. - * - * Locks required: NONE - * Returns: Nothing. You get back a response with ERR=1, DATALEN=0 */ #define MC_CMD_REBOOT 0x3d -#define MC_CMD_REBOOT_IN_LEN 4 -#define MC_CMD_REBOOT_IN_FLAGS_OFST 0 -#define MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION 1 -#define MC_CMD_REBOOT_OUT_LEN 0 -/* MC_CMD_SCHEDINFO: - * Request scheduler info. from the MC. - * - * Locks required: NONE - * Returns: An array of (timeslice,maximum overrun), one for each thread, - * in ascending order of thread address.s +/* MC_CMD_REBOOT_IN msgrequest */ +#define MC_CMD_REBOOT_IN_LEN 4 +#define MC_CMD_REBOOT_IN_FLAGS_OFST 0 +#define MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION 0x1 /* enum */ + +/* MC_CMD_REBOOT_OUT msgresponse */ +#define MC_CMD_REBOOT_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_SCHEDINFO + * Request scheduler info. */ #define MC_CMD_SCHEDINFO 0x3e -#define MC_CMD_SCHEDINFO_IN_LEN 0 +/* MC_CMD_SCHEDINFO_IN msgrequest */ +#define MC_CMD_SCHEDINFO_IN_LEN 0 -/* MC_CMD_SET_REBOOT_MODE: (debug) - * Set the mode for the next MC reboot. - * - * Locks required: NONE - * - * Sets the reboot mode to the specified value. Returns the old mode. +/* MC_CMD_SCHEDINFO_OUT msgresponse */ +#define MC_CMD_SCHEDINFO_OUT_LENMIN 4 +#define MC_CMD_SCHEDINFO_OUT_LENMAX 252 +#define MC_CMD_SCHEDINFO_OUT_LEN(num) (0+4*(num)) +#define MC_CMD_SCHEDINFO_OUT_DATA_OFST 0 +#define MC_CMD_SCHEDINFO_OUT_DATA_LEN 4 +#define MC_CMD_SCHEDINFO_OUT_DATA_MINNUM 1 +#define MC_CMD_SCHEDINFO_OUT_DATA_MAXNUM 63 + + +/***********************************/ +/* MC_CMD_REBOOT_MODE */ #define MC_CMD_REBOOT_MODE 0x3f -#define MC_CMD_REBOOT_MODE_IN_LEN 4 -#define MC_CMD_REBOOT_MODE_IN_VALUE_OFST 0 -#define MC_CMD_REBOOT_MODE_OUT_LEN 4 -#define MC_CMD_REBOOT_MODE_OUT_VALUE_OFST 0 -#define MC_CMD_REBOOT_MODE_NORMAL 0 -#define MC_CMD_REBOOT_MODE_SNAPPER 3 - -/* MC_CMD_DEBUG_LOG: - * Null request/response command (debug) - * - sequence number is always zero - * - only supported on the UART interface - * (the same set of bytes is delivered as an - * event over PCI) - */ -#define MC_CMD_DEBUG_LOG 0x40 -#define MC_CMD_DEBUG_LOG_IN_LEN 0 -#define MC_CMD_DEBUG_LOG_OUT_LEN 0 - -/* Generic sensor enumeration. Note that a dual port NIC - * will EITHER expose PHY_COMMON_TEMP OR PHY0_TEMP and - * PHY1_TEMP depending on whether there is a single sensor - * in the vicinity of the two port, or one per port. - */ -#define MC_CMD_SENSOR_CONTROLLER_TEMP 0 /* degC */ -#define MC_CMD_SENSOR_PHY_COMMON_TEMP 1 /* degC */ -#define MC_CMD_SENSOR_CONTROLLER_COOLING 2 /* bool */ -#define MC_CMD_SENSOR_PHY0_TEMP 3 /* degC */ -#define MC_CMD_SENSOR_PHY0_COOLING 4 /* bool */ -#define MC_CMD_SENSOR_PHY1_TEMP 5 /* degC */ -#define MC_CMD_SENSOR_PHY1_COOLING 6 /* bool */ -#define MC_CMD_SENSOR_IN_1V0 7 /* mV */ -#define MC_CMD_SENSOR_IN_1V2 8 /* mV */ -#define MC_CMD_SENSOR_IN_1V8 9 /* mV */ -#define MC_CMD_SENSOR_IN_2V5 10 /* mV */ -#define MC_CMD_SENSOR_IN_3V3 11 /* mV */ -#define MC_CMD_SENSOR_IN_12V0 12 /* mV */ - - -/* Sensor state */ -#define MC_CMD_SENSOR_STATE_OK 0 -#define MC_CMD_SENSOR_STATE_WARNING 1 -#define MC_CMD_SENSOR_STATE_FATAL 2 -#define MC_CMD_SENSOR_STATE_BROKEN 3 - -/* MC_CMD_SENSOR_INFO: + +/* MC_CMD_REBOOT_MODE_IN msgrequest */ +#define MC_CMD_REBOOT_MODE_IN_LEN 4 +#define MC_CMD_REBOOT_MODE_IN_VALUE_OFST 0 +#define MC_CMD_REBOOT_MODE_NORMAL 0x0 /* enum */ +#define MC_CMD_REBOOT_MODE_SNAPPER 0x3 /* enum */ + +/* MC_CMD_REBOOT_MODE_OUT msgresponse */ +#define MC_CMD_REBOOT_MODE_OUT_LEN 4 +#define MC_CMD_REBOOT_MODE_OUT_VALUE_OFST 0 + + +/***********************************/ +/* MC_CMD_SENSOR_INFO * Returns information about every available sensor. - * - * Each sensor has a single (16bit) value, and a corresponding state. - * The mapping between value and sensor is nominally determined by the - * MC, but in practise is implemented as zero (BROKEN), one (TEMPERATURE), - * or two (VOLTAGE) ranges per sensor per state. - * - * This call returns a mask (32bit) of the sensors that are supported - * by this platform, then an array (indexed by MC_CMD_SENSOR) of byte - * offsets to the per-sensor arrays. Each sensor array has four 16bit - * numbers, min1, max1, min2, max2. - * - * Locks required: None - * Returns: 0 */ #define MC_CMD_SENSOR_INFO 0x41 -#define MC_CMD_SENSOR_INFO_IN_LEN 0 -#define MC_CMD_SENSOR_INFO_OUT_MASK_OFST 0 -#define MC_CMD_SENSOR_INFO_OUT_OFFSET_OFST(_x) \ - (4 + (_x)) -#define MC_CMD_SENSOR_INFO_OUT_MIN1_OFST(_ofst) \ - ((_ofst) + 0) -#define MC_CMD_SENSOR_INFO_OUT_MAX1_OFST(_ofst) \ - ((_ofst) + 2) -#define MC_CMD_SENSOR_INFO_OUT_MIN2_OFST(_ofst) \ - ((_ofst) + 4) -#define MC_CMD_SENSOR_INFO_OUT_MAX2_OFST(_ofst) \ - ((_ofst) + 6) +/* MC_CMD_SENSOR_INFO_IN msgrequest */ +#define MC_CMD_SENSOR_INFO_IN_LEN 0 + +/* MC_CMD_SENSOR_INFO_OUT msgresponse */ +#define MC_CMD_SENSOR_INFO_OUT_LENMIN 12 +#define MC_CMD_SENSOR_INFO_OUT_LENMAX 252 +#define MC_CMD_SENSOR_INFO_OUT_LEN(num) (4+8*(num)) +#define MC_CMD_SENSOR_INFO_OUT_MASK_OFST 0 +#define MC_CMD_SENSOR_CONTROLLER_TEMP 0x0 /* enum */ +#define MC_CMD_SENSOR_PHY_COMMON_TEMP 0x1 /* enum */ +#define MC_CMD_SENSOR_CONTROLLER_COOLING 0x2 /* enum */ +#define MC_CMD_SENSOR_PHY0_TEMP 0x3 /* enum */ +#define MC_CMD_SENSOR_PHY0_COOLING 0x4 /* enum */ +#define MC_CMD_SENSOR_PHY1_TEMP 0x5 /* enum */ +#define MC_CMD_SENSOR_PHY1_COOLING 0x6 /* enum */ +#define MC_CMD_SENSOR_IN_1V0 0x7 /* enum */ +#define MC_CMD_SENSOR_IN_1V2 0x8 /* enum */ +#define MC_CMD_SENSOR_IN_1V8 0x9 /* enum */ +#define MC_CMD_SENSOR_IN_2V5 0xa /* enum */ +#define MC_CMD_SENSOR_IN_3V3 0xb /* enum */ +#define MC_CMD_SENSOR_IN_12V0 0xc /* enum */ +#define MC_CMD_SENSOR_IN_1V2A 0xd /* enum */ +#define MC_CMD_SENSOR_IN_VREF 0xe /* enum */ +#define MC_CMD_SENSOR_ENTRY_OFST 4 +#define MC_CMD_SENSOR_ENTRY_LEN 8 +#define MC_CMD_SENSOR_ENTRY_LO_OFST 4 +#define MC_CMD_SENSOR_ENTRY_HI_OFST 8 +#define MC_CMD_SENSOR_ENTRY_MINNUM 1 +#define MC_CMD_SENSOR_ENTRY_MAXNUM 31 + +/* MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF structuredef */ +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_LEN 8 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_OFST 0 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_LEN 2 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_LBN 0 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_WIDTH 16 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_OFST 2 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_LEN 2 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_LBN 16 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_WIDTH 16 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_OFST 4 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_LEN 2 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_LBN 32 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_WIDTH 16 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_OFST 6 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_LEN 2 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_LBN 48 +#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_WIDTH 16 + + +/***********************************/ /* MC_CMD_READ_SENSORS - * Returns the current reading from each sensor - * - * Returns a sparse array of sensor readings (indexed by the sensor - * type) into host memory. Each array element is a dword. - * - * The MC will send a SENSOREVT event every time any sensor changes state. The - * driver is responsible for ensuring that it doesn't miss any events. The board - * will function normally if all sensors are in STATE_OK or state_WARNING. - * Otherwise the board should not be expected to function. + * Returns the current reading from each sensor. */ #define MC_CMD_READ_SENSORS 0x42 -#define MC_CMD_READ_SENSORS_IN_LEN 8 -#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_LO_OFST 0 -#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4 -#define MC_CMD_READ_SENSORS_OUT_LEN 0 -/* Sensor reading fields */ -#define MC_CMD_READ_SENSOR_VALUE_LBN 0 -#define MC_CMD_READ_SENSOR_VALUE_WIDTH 16 -#define MC_CMD_READ_SENSOR_STATE_LBN 16 -#define MC_CMD_READ_SENSOR_STATE_WIDTH 8 - - -/* MC_CMD_GET_PHY_STATE: - * Report current state of PHY. A "zombie" PHY is a PHY that has failed to - * boot (e.g. due to missing or corrupted firmware). - * - * Locks required: None - * Return code: 0 +/* MC_CMD_READ_SENSORS_IN msgrequest */ +#define MC_CMD_READ_SENSORS_IN_LEN 8 +#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_OFST 0 +#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_LEN 8 +#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_LO_OFST 0 +#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4 + +/* MC_CMD_READ_SENSORS_OUT msgresponse */ +#define MC_CMD_READ_SENSORS_OUT_LEN 0 + +/* MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF structuredef */ +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN 3 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_OFST 0 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_LEN 2 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_LBN 0 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_WIDTH 16 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_OFST 2 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_LEN 1 +#define MC_CMD_SENSOR_STATE_OK 0x0 /* enum */ +#define MC_CMD_SENSOR_STATE_WARNING 0x1 /* enum */ +#define MC_CMD_SENSOR_STATE_FATAL 0x2 /* enum */ +#define MC_CMD_SENSOR_STATE_BROKEN 0x3 /* enum */ +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_LBN 16 +#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_WIDTH 8 + + +/***********************************/ +/* MC_CMD_GET_PHY_STATE + * Report current state of PHY. */ #define MC_CMD_GET_PHY_STATE 0x43 -#define MC_CMD_GET_PHY_STATE_IN_LEN 0 -#define MC_CMD_GET_PHY_STATE_OUT_LEN 4 -#define MC_CMD_GET_PHY_STATE_STATE_OFST 0 -/* PHY state enumeration: */ -#define MC_CMD_PHY_STATE_OK 1 -#define MC_CMD_PHY_STATE_ZOMBIE 2 +/* MC_CMD_GET_PHY_STATE_IN msgrequest */ +#define MC_CMD_GET_PHY_STATE_IN_LEN 0 +/* MC_CMD_GET_PHY_STATE_OUT msgresponse */ +#define MC_CMD_GET_PHY_STATE_OUT_LEN 4 +#define MC_CMD_GET_PHY_STATE_OUT_STATE_OFST 0 +#define MC_CMD_PHY_STATE_OK 0x1 /* enum */ +#define MC_CMD_PHY_STATE_ZOMBIE 0x2 /* enum */ -/* 802.1Qbb control. 8 Tx queues that map to priorities 0 - 7. Use all 1s to - * disable 802.Qbb for a given priority. */ + +/***********************************/ +/* MC_CMD_SETUP_8021QBB + * 802.1Qbb control. + */ #define MC_CMD_SETUP_8021QBB 0x44 -#define MC_CMD_SETUP_8021QBB_IN_LEN 32 -#define MC_CMD_SETUP_8021QBB_OUT_LEN 0 -#define MC_CMD_SETUP_8021QBB_IN_TXQS_OFFST 0 +/* MC_CMD_SETUP_8021QBB_IN msgrequest */ +#define MC_CMD_SETUP_8021QBB_IN_LEN 32 +#define MC_CMD_SETUP_8021QBB_IN_TXQS_OFST 0 +#define MC_CMD_SETUP_8021QBB_IN_TXQS_LEN 32 -/* MC_CMD_WOL_FILTER_GET: - * Retrieve ID of any WoL filters - * - * Locks required: None - * Returns: 0, ENOSYS - */ -#define MC_CMD_WOL_FILTER_GET 0x45 -#define MC_CMD_WOL_FILTER_GET_IN_LEN 0 -#define MC_CMD_WOL_FILTER_GET_OUT_LEN 4 -#define MC_CMD_WOL_FILTER_GET_OUT_FILTER_ID_OFST 0 +/* MC_CMD_SETUP_8021QBB_OUT msgresponse */ +#define MC_CMD_SETUP_8021QBB_OUT_LEN 0 -/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD: - * Offload a protocol to NIC for lights-out state - * - * Locks required: None - * Returns: 0, ENOSYS +/***********************************/ +/* MC_CMD_WOL_FILTER_GET + * Retrieve ID of any WoL filters. */ -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD 0x46 +#define MC_CMD_WOL_FILTER_GET 0x45 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LEN 16 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 +/* MC_CMD_WOL_FILTER_GET_IN msgrequest */ +#define MC_CMD_WOL_FILTER_GET_IN_LEN 0 -/* There is a union at offset 4, following defines overlap due to - * this */ -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_OFST 4 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARPMAC_OFST 4 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARPIP_OFST 10 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NSMAC_OFST 4 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NSSNIPV6_OFST 10 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NSIPV6_OFST 26 +/* MC_CMD_WOL_FILTER_GET_OUT msgresponse */ +#define MC_CMD_WOL_FILTER_GET_OUT_LEN 4 +#define MC_CMD_WOL_FILTER_GET_OUT_FILTER_ID_OFST 0 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_LEN 4 -#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_FILTER_ID_OFST 0 +/***********************************/ +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD + * Add a protocol offload to NIC for lights-out state. + */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD 0x46 -/* MC_CMD_REMOVE_LIGHTSOUT_PROTOCOL_OFFLOAD: - * Offload a protocol to NIC for lights-out state - * - * Locks required: None - * Returns: 0, ENOSYS +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN msgrequest */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LENMIN 8 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LENMAX 252 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LEN(num) (4+4*(num)) +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 +#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_ARP 0x1 /* enum */ +#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_NS 0x2 /* enum */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_OFST 4 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_LEN 4 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_MINNUM 1 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_MAXNUM 62 + +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP msgrequest */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_LEN 14 +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_MAC_OFST 4 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_MAC_LEN 6 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_IP_OFST 10 + +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS msgrequest */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_LEN 42 +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_MAC_OFST 4 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_MAC_LEN 6 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_SNIPV6_OFST 10 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_SNIPV6_LEN 16 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_IPV6_OFST 26 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_IPV6_LEN 16 + +/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT msgresponse */ +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_LEN 4 +#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_FILTER_ID_OFST 0 + + +/***********************************/ +/* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD + * Remove a protocol offload from NIC for lights-out state. */ #define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD 0x47 -#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_LEN 8 -#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT_LEN 0 -#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 -#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_FILTER_ID_OFST 4 +/* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN msgrequest */ +#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_LEN 8 +#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 +#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_FILTER_ID_OFST 4 -/* Lights-out offload protocols enumeration */ -#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_ARP 0x1 -#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_NS 0x2 +/* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT msgresponse */ +#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT_LEN 0 -/* MC_CMD_MAC_RESET_RESTORE: - * Restore MAC after block reset - * - * Locks required: None - * Returns: 0 +/***********************************/ +/* MC_CMD_MAC_RESET_RESTORE + * Restore MAC after block reset. */ - #define MC_CMD_MAC_RESET_RESTORE 0x48 -#define MC_CMD_MAC_RESET_RESTORE_IN_LEN 0 -#define MC_CMD_MAC_RESET_RESTORE_OUT_LEN 0 +/* MC_CMD_MAC_RESET_RESTORE_IN msgrequest */ +#define MC_CMD_MAC_RESET_RESTORE_IN_LEN 0 + +/* MC_CMD_MAC_RESET_RESTORE_OUT msgresponse */ +#define MC_CMD_MAC_RESET_RESTORE_OUT_LEN 0 -/* MC_CMD_TEST_ASSERT: - * Deliberately trigger an assert-detonation in the firmware for testing - * purposes (i.e. to allow tests that the driver copes gracefully). - * - * Locks required: None - * Returns: 0 - */ +/***********************************/ +/* MC_CMD_TESTASSERT + */ #define MC_CMD_TESTASSERT 0x49 -#define MC_CMD_TESTASSERT_IN_LEN 0 -#define MC_CMD_TESTASSERT_OUT_LEN 0 -/* MC_CMD_WORKAROUND 0x4a - * - * Enable/Disable a given workaround. The mcfw will return EINVAL if it - * doesn't understand the given workaround number - which should not - * be treated as a hard error by client code. - * - * This op does not imply any semantics about each workaround, that's between - * the driver and the mcfw on a per-workaround basis. - * - * Locks required: None - * Returns: 0, EINVAL +/* MC_CMD_TESTASSERT_IN msgrequest */ +#define MC_CMD_TESTASSERT_IN_LEN 0 + +/* MC_CMD_TESTASSERT_OUT msgresponse */ +#define MC_CMD_TESTASSERT_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_WORKAROUND + * Enable/Disable a given workaround. */ #define MC_CMD_WORKAROUND 0x4a -#define MC_CMD_WORKAROUND_IN_LEN 8 -#define MC_CMD_WORKAROUND_IN_TYPE_OFST 0 -#define MC_CMD_WORKAROUND_BUG17230 1 -#define MC_CMD_WORKAROUND_IN_ENABLED_OFST 4 -#define MC_CMD_WORKAROUND_OUT_LEN 0 - -/* MC_CMD_GET_PHY_MEDIA_INFO: - * Read media-specific data from PHY (e.g. SFP/SFP+ module ID information for - * SFP+ PHYs). - * - * The "media type" can be found via GET_PHY_CFG (GET_PHY_CFG_OUT_MEDIA_TYPE); - * the valid "page number" input values, and the output data, are interpreted - * on a per-type basis. - * - * For SFP+: PAGE=0 or 1 returns a 128-byte block read from module I2C address - * 0xA0 offset 0 or 0x80. - * Anything else: currently undefined. - * - * Locks required: None - * Return code: 0 + +/* MC_CMD_WORKAROUND_IN msgrequest */ +#define MC_CMD_WORKAROUND_IN_LEN 8 +#define MC_CMD_WORKAROUND_IN_TYPE_OFST 0 +#define MC_CMD_WORKAROUND_BUG17230 0x1 /* enum */ +#define MC_CMD_WORKAROUND_IN_ENABLED_OFST 4 + +/* MC_CMD_WORKAROUND_OUT msgresponse */ +#define MC_CMD_WORKAROUND_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_GET_PHY_MEDIA_INFO + * Read media-specific data from PHY. */ #define MC_CMD_GET_PHY_MEDIA_INFO 0x4b -#define MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN 4 -#define MC_CMD_GET_PHY_MEDIA_INFO_IN_PAGE_OFST 0 -#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(_num_bytes) (4 + (_num_bytes)) -#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0 -#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4 - -/* MC_CMD_NVRAM_TEST: - * Test a particular NVRAM partition for valid contents (where "valid" - * depends on the type of partition). - * - * Locks required: None - * Return code: 0 + +/* MC_CMD_GET_PHY_MEDIA_INFO_IN msgrequest */ +#define MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN 4 +#define MC_CMD_GET_PHY_MEDIA_INFO_IN_PAGE_OFST 0 + +/* MC_CMD_GET_PHY_MEDIA_INFO_OUT msgresponse */ +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMIN 5 +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX 255 +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(num) (4+1*(num)) +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0 +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4 +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_LEN 1 +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MINNUM 1 +#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MAXNUM 251 + + +/***********************************/ +/* MC_CMD_NVRAM_TEST + * Test a particular NVRAM partition. */ #define MC_CMD_NVRAM_TEST 0x4c -#define MC_CMD_NVRAM_TEST_IN_LEN 4 -#define MC_CMD_NVRAM_TEST_IN_TYPE_OFST 0 -#define MC_CMD_NVRAM_TEST_OUT_LEN 4 -#define MC_CMD_NVRAM_TEST_OUT_RESULT_OFST 0 -#define MC_CMD_NVRAM_TEST_PASS 0 -#define MC_CMD_NVRAM_TEST_FAIL 1 -#define MC_CMD_NVRAM_TEST_NOTSUPP 2 - -/* MC_CMD_MRSFP_TWEAK: (debug) - * Read status and/or set parameters for the "mrsfp" driver in mr_rusty builds. - * I2C I/O expander bits are always read; if equaliser parameters are supplied, - * they are configured first. - * - * Locks required: None - * Return code: 0, EINVAL + +/* MC_CMD_NVRAM_TEST_IN msgrequest */ +#define MC_CMD_NVRAM_TEST_IN_LEN 4 +#define MC_CMD_NVRAM_TEST_IN_TYPE_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */ + +/* MC_CMD_NVRAM_TEST_OUT msgresponse */ +#define MC_CMD_NVRAM_TEST_OUT_LEN 4 +#define MC_CMD_NVRAM_TEST_OUT_RESULT_OFST 0 +#define MC_CMD_NVRAM_TEST_PASS 0x0 /* enum */ +#define MC_CMD_NVRAM_TEST_FAIL 0x1 /* enum */ +#define MC_CMD_NVRAM_TEST_NOTSUPP 0x2 /* enum */ + + +/***********************************/ +/* MC_CMD_MRSFP_TWEAK + * Read status and/or set parameters for the 'mrsfp' driver. */ #define MC_CMD_MRSFP_TWEAK 0x4d -#define MC_CMD_MRSFP_TWEAK_IN_LEN_READ_ONLY 0 -#define MC_CMD_MRSFP_TWEAK_IN_LEN_EQ_CONFIG 16 -#define MC_CMD_MRSFP_TWEAK_IN_TXEQ_LEVEL_OFST 0 /* 0-6 low->high de-emph. */ -#define MC_CMD_MRSFP_TWEAK_IN_TXEQ_DT_CFG_OFST 4 /* 0-8 low->high ref.V */ -#define MC_CMD_MRSFP_TWEAK_IN_RXEQ_BOOST_OFST 8 /* 0-8 low->high boost */ -#define MC_CMD_MRSFP_TWEAK_IN_RXEQ_DT_CFG_OFST 12 /* 0-8 low->high ref.V */ -#define MC_CMD_MRSFP_TWEAK_OUT_LEN 12 -#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_INPUTS_OFST 0 /* input bits */ -#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_OUTPUTS_OFST 4 /* output bits */ -#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OFST 8 /* dirs: 0=out, 1=in */ - -/* MC_CMD_TEST_HACK: (debug (unsurprisingly)) - * Change bits of network port state for test purposes in ways that would never be - * useful in normal operation and so need a special command to change. */ -#define MC_CMD_TEST_HACK 0x2f -#define MC_CMD_TEST_HACK_IN_LEN 8 -#define MC_CMD_TEST_HACK_IN_TXPAD_OFST 0 -#define MC_CMD_TEST_HACK_IN_TXPAD_AUTO 0 /* Let the MC manage things */ -#define MC_CMD_TEST_HACK_IN_TXPAD_ON 1 /* Force on */ -#define MC_CMD_TEST_HACK_IN_TXPAD_OFF 2 /* Force on */ -#define MC_CMD_TEST_HACK_IN_IPG_OFST 4 /* Takes a value in bits */ -#define MC_CMD_TEST_HACK_IN_IPG_AUTO 0 /* The MC picks the value */ -#define MC_CMD_TEST_HACK_OUT_LEN 0 - -/* MC_CMD_SENSOR_SET_LIMS: (debug) (mostly) adjust the sensor limits. This - * is a warranty-voiding operation. - * - * IN: sensor identifier (one of the enumeration starting with MC_CMD_SENSOR_CONTROLLER_TEMP - * followed by 4 32-bit values: min(warning) max(warning), min(fatal), max(fatal). Which - * of these limits are meaningful and what their interpretation is is sensor-specific. - * - * OUT: nothing - * - * Returns: ENOENT if the sensor specified does not exist, EINVAL if the limits are - * out of range. + +/* MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG msgrequest */ +#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_LEN 16 +#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_TXEQ_LEVEL_OFST 0 +#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_TXEQ_DT_CFG_OFST 4 +#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_RXEQ_BOOST_OFST 8 +#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_RXEQ_DT_CFG_OFST 12 + +/* MC_CMD_MRSFP_TWEAK_IN_READ_ONLY msgrequest */ +#define MC_CMD_MRSFP_TWEAK_IN_READ_ONLY_LEN 0 + +/* MC_CMD_MRSFP_TWEAK_OUT msgresponse */ +#define MC_CMD_MRSFP_TWEAK_OUT_LEN 12 +#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_INPUTS_OFST 0 +#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_OUTPUTS_OFST 4 +#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OFST 8 +#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OUT 0x0 /* enum */ +#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_IN 0x1 /* enum */ + + +/***********************************/ +/* MC_CMD_SENSOR_SET_LIMS + * Adjusts the sensor limits. */ #define MC_CMD_SENSOR_SET_LIMS 0x4e -#define MC_CMD_SENSOR_SET_LIMS_IN_LEN 20 -#define MC_CMD_SENSOR_SET_LIMS_IN_SENSOR_OFST 0 -#define MC_CMD_SENSOR_SET_LIMS_IN_LOW0_OFST 4 -#define MC_CMD_SENSOR_SET_LIMS_IN_HI0_OFST 8 -#define MC_CMD_SENSOR_SET_LIMS_IN_LOW1_OFST 12 -#define MC_CMD_SENSOR_SET_LIMS_IN_HI1_OFST 16 - -/* Do NOT add new commands beyond 0x4f as part of 3.0 : 0x50 - 0x7f will be - * used for post-3.0 extensions. If you run out of space, look for gaps or - * commands that are unused in the existing range. */ + +/* MC_CMD_SENSOR_SET_LIMS_IN msgrequest */ +#define MC_CMD_SENSOR_SET_LIMS_IN_LEN 20 +#define MC_CMD_SENSOR_SET_LIMS_IN_SENSOR_OFST 0 +/* Enum values, see field(s): */ +/* MC_CMD_SENSOR_INFO/MC_CMD_SENSOR_INFO_OUT/MASK */ +#define MC_CMD_SENSOR_SET_LIMS_IN_LOW0_OFST 4 +#define MC_CMD_SENSOR_SET_LIMS_IN_HI0_OFST 8 +#define MC_CMD_SENSOR_SET_LIMS_IN_LOW1_OFST 12 +#define MC_CMD_SENSOR_SET_LIMS_IN_HI1_OFST 16 + +/* MC_CMD_SENSOR_SET_LIMS_OUT msgresponse */ +#define MC_CMD_SENSOR_SET_LIMS_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_GET_RESOURCE_LIMITS + */ +#define MC_CMD_GET_RESOURCE_LIMITS 0x4f + +/* MC_CMD_GET_RESOURCE_LIMITS_IN msgrequest */ +#define MC_CMD_GET_RESOURCE_LIMITS_IN_LEN 0 + +/* MC_CMD_GET_RESOURCE_LIMITS_OUT msgresponse */ +#define MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN 16 +#define MC_CMD_GET_RESOURCE_LIMITS_OUT_BUFTBL_OFST 0 +#define MC_CMD_GET_RESOURCE_LIMITS_OUT_EVQ_OFST 4 +#define MC_CMD_GET_RESOURCE_LIMITS_OUT_RXQ_OFST 8 +#define MC_CMD_GET_RESOURCE_LIMITS_OUT_TXQ_OFST 12 + +/* MC_CMD_RESOURCE_SPECIFIER enum */ +#define MC_CMD_RESOURCE_INSTANCE_ANY 0xffffffff /* enum */ +#define MC_CMD_RESOURCE_INSTANCE_NONE 0xfffffffe /* enum */ + #endif /* MCDI_PCOL_H */ diff --git a/drivers/net/ethernet/sfc/mcdi_phy.c b/drivers/net/ethernet/sfc/mcdi_phy.c index 3077bf1e7dfe..7bcad899a936 100644 --- a/drivers/net/ethernet/sfc/mcdi_phy.c +++ b/drivers/net/ethernet/sfc/mcdi_phy.c @@ -116,7 +116,7 @@ static int efx_mcdi_loopback_modes(struct efx_nic *efx, u64 *loopback_modes) goto fail; } - *loopback_modes = MCDI_QWORD(outbuf, GET_LOOPBACK_MODES_SUGGESTED); + *loopback_modes = MCDI_QWORD(outbuf, GET_LOOPBACK_MODES_OUT_SUGGESTED); return 0; @@ -264,22 +264,22 @@ static u32 efx_get_mcdi_phy_flags(struct efx_nic *efx) /* TODO: Advertise the capabilities supported by this PHY */ supported = 0; - if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_TXDIS_LBN)) + if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN)) supported |= PHY_MODE_TX_DISABLED; - if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_LOWPOWER_LBN)) + if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN)) supported |= PHY_MODE_LOW_POWER; - if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_POWEROFF_LBN)) + if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN)) supported |= PHY_MODE_OFF; mode = efx->phy_mode & supported; flags = 0; if (mode & PHY_MODE_TX_DISABLED) - flags |= (1 << MC_CMD_SET_LINK_TXDIS_LBN); + flags |= (1 << MC_CMD_SET_LINK_IN_TXDIS_LBN); if (mode & PHY_MODE_LOW_POWER) - flags |= (1 << MC_CMD_SET_LINK_LOWPOWER_LBN); + flags |= (1 << MC_CMD_SET_LINK_IN_LOWPOWER_LBN); if (mode & PHY_MODE_OFF) - flags |= (1 << MC_CMD_SET_LINK_POWEROFF_LBN); + flags |= (1 << MC_CMD_SET_LINK_IN_POWEROFF_LBN); return flags; } @@ -436,8 +436,8 @@ void efx_mcdi_phy_decode_link(struct efx_nic *efx, break; } - link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_LINK_UP_LBN)); - link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_FULL_DUPLEX_LBN)); + link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN)); + link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN)); link_state->speed = speed; } @@ -592,7 +592,7 @@ static int efx_mcdi_phy_test_alive(struct efx_nic *efx) if (outlen < MC_CMD_GET_PHY_STATE_OUT_LEN) return -EIO; - if (MCDI_DWORD(outbuf, GET_PHY_STATE_STATE) != MC_CMD_PHY_STATE_OK) + if (MCDI_DWORD(outbuf, GET_PHY_STATE_OUT_STATE) != MC_CMD_PHY_STATE_OK) return -EINVAL; return 0; @@ -680,7 +680,7 @@ static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results, u32 mode; int rc; - if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_BIST_LBN)) { + if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) { rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results); if (rc < 0) return rc; @@ -691,15 +691,15 @@ static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results, /* If we support both LONG and SHORT, then run each in response to * break or not. Otherwise, run the one we support */ mode = 0; - if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN)) { + if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN)) { if ((flags & ETH_TEST_FL_OFFLINE) && (phy_cfg->flags & - (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN))) + (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))) mode = MC_CMD_PHY_BIST_CABLE_LONG; else mode = MC_CMD_PHY_BIST_CABLE_SHORT; } else if (phy_cfg->flags & - (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN)) + (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN)) mode = MC_CMD_PHY_BIST_CABLE_LONG; if (mode != 0) { @@ -717,14 +717,14 @@ static const char *efx_mcdi_phy_test_name(struct efx_nic *efx, { struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; - if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_BIST_LBN)) { + if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) { if (index == 0) return "bist"; --index; } - if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN) | - (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN))) { + if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN) | + (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))) { if (index == 0) return "cable"; --index; diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index 13f61fba731f..7f61cd3812d9 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c @@ -627,8 +627,7 @@ static int siena_mtd_get_fw_subtypes(struct efx_nic *efx, struct efx_mtd *efx_mtd) { struct efx_mtd_partition *part; - uint16_t fw_subtype_list[MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN / - sizeof(uint16_t)]; + uint16_t fw_subtype_list[MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM]; int rc; rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list); -- GitLab From fa142b9da3393fd92b398b6bdecf3f21914e309b Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 20 Dec 2011 01:15:30 +0000 Subject: [PATCH 0035/1846] sfc: Rename efx_wanted_channels() to efx_wanted_parallelism() This function returns the degree of parallelism wanted, which is not necessarily the total number of channels we want to create. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 9ca5dcdf5a86..5fcc42f7d865 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1146,9 +1146,7 @@ static void efx_fini_io(struct efx_nic *efx) pci_disable_device(efx->pci_dev); } -/* Get number of channels wanted. Each channel will have its own IRQ, - * 1 RX queue and/or 2 TX queues. */ -static int efx_wanted_channels(void) +static int efx_wanted_parallelism(void) { cpumask_var_t core_mask; int count; @@ -1211,7 +1209,7 @@ static int efx_probe_interrupts(struct efx_nic *efx) struct msix_entry xentries[EFX_MAX_CHANNELS]; int n_channels; - n_channels = efx_wanted_channels(); + n_channels = efx_wanted_parallelism(); if (separate_tx_channels) n_channels *= 2; n_channels = min(n_channels, max_channels); -- GitLab From cdb08f8fd8642a6d661c920f565e85cf87a0c9be Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 20 Dec 2011 01:08:05 +0000 Subject: [PATCH 0036/1846] sfc: Set default parallelism to per-core by default The previous default of per-package can be more CPU-efficient, but users generally seem to prefer per-core. It should also allow accelerated RFS to direct packets more precisely, if IRQ affinity is properly spread out. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 5fcc42f7d865..d7301d2e81a7 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -162,7 +162,7 @@ static unsigned int interrupt_mode; * interrupt handling. * * Cards without MSI-X will only target one CPU via legacy or MSI interrupt. - * The default (0) means to assign an interrupt to each package (level II cache) + * The default (0) means to assign an interrupt to each core. */ static unsigned int rss_cpus; module_param(rss_cpus, uint, 0444); @@ -1148,14 +1148,14 @@ static void efx_fini_io(struct efx_nic *efx) static int efx_wanted_parallelism(void) { - cpumask_var_t core_mask; + cpumask_var_t thread_mask; int count; int cpu; if (rss_cpus) return rss_cpus; - if (unlikely(!zalloc_cpumask_var(&core_mask, GFP_KERNEL))) { + if (unlikely(!zalloc_cpumask_var(&thread_mask, GFP_KERNEL))) { printk(KERN_WARNING "sfc: RSS disabled due to allocation failure\n"); return 1; @@ -1163,14 +1163,14 @@ static int efx_wanted_parallelism(void) count = 0; for_each_online_cpu(cpu) { - if (!cpumask_test_cpu(cpu, core_mask)) { + if (!cpumask_test_cpu(cpu, thread_mask)) { ++count; - cpumask_or(core_mask, core_mask, - topology_core_cpumask(cpu)); + cpumask_or(thread_mask, thread_mask, + topology_thread_cpumask(cpu)); } } - free_cpumask_var(core_mask); + free_cpumask_var(thread_mask); return count; } -- GitLab From 866dc88607aa07f297eec7b504be58ca17d91a26 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Tue, 10 Jan 2012 09:53:23 +0530 Subject: [PATCH 0037/1846] ath6kl: Fix SDIO error path sdio_release_host() would be called twice if sdio_set_block_size() fails for some reason, which would result in the following warning. WARNING: at /home/sujith/dev/wireless-testing/drivers/mmc/core/core.c:828 mmc_release_host+0x42/0x50 [mmc_core]() Call Trace: [] warn_slowpath_common+0x7f/0xc0 [] warn_slowpath_null+0x1a/0x20 [] mmc_release_host+0x42/0x50 [mmc_core] [] sdio_release_host+0x1e/0x30 [mmc_core] [] ath6kl_sdio_config+0xc7/0x110 [ath6kl_sdio] [] ath6kl_sdio_probe+0x21c/0x320 [ath6kl_sdio] [] ? mmc_release_host+0x2a/0x50 [mmc_core] [] sdio_bus_probe+0xfa/0x130 [mmc_core] [] driver_probe_device+0x7e/0x1b0 [] __driver_attach+0xab/0xb0 [] ? driver_probe_device+0x1b0/0x1b0 [] ? driver_probe_device+0x1b0/0x1b0 [] bus_for_each_dev+0x64/0xa0 [] driver_attach+0x1e/0x20 [] bus_add_driver+0x1b0/0x280 [] ? 0xffffffffa0064fff [] driver_register+0x76/0x140 [] ? 0xffffffffa0064fff [] sdio_register_driver+0x21/0x30 [mmc_core] [] ath6kl_sdio_init+0x12/0x35 [ath6kl_sdio] [] do_one_initcall+0x42/0x180 [] sys_init_module+0x8f/0x200 [] system_call_fastpath+0x16/0x1b Signed-off-by: Sujith Manoharan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 8b36904ec3ec..50b19d3aefa7 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -770,7 +770,6 @@ static int ath6kl_sdio_config(struct ath6kl *ar) if (ret) { ath6kl_err("Set sdio block size %d failed: %d)\n", HIF_MBOX_BLOCK_SIZE, ret); - sdio_release_host(func); goto out; } -- GitLab From 4a8ce2fd055f8c117fb6fa6da39af8f62cbffe4b Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Tue, 10 Jan 2012 09:53:38 +0530 Subject: [PATCH 0038/1846] ath6kl: Remove redundant pointer check 'params' is already used earlier and there is no point in checking for a NULL condition again. Signed-off-by: Sujith Manoharan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 14f180eac485..9b26bbaf124e 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -983,6 +983,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, struct ath6kl *ar = ath6kl_priv(ndev); struct ath6kl_vif *vif = netdev_priv(ndev); struct ath6kl_key *key = NULL; + int seq_len; u8 key_usage; u8 key_type; @@ -1011,23 +1012,21 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, else key_usage = GROUP_USAGE; - if (params) { - int seq_len = params->seq_len; - if (params->cipher == WLAN_CIPHER_SUITE_SMS4 && - seq_len > ATH6KL_KEY_SEQ_LEN) { - /* Only first half of the WPI PN is configured */ - seq_len = ATH6KL_KEY_SEQ_LEN; - } - if (params->key_len > WLAN_MAX_KEY_LEN || - seq_len > sizeof(key->seq)) - return -EINVAL; - - key->key_len = params->key_len; - memcpy(key->key, params->key, key->key_len); - key->seq_len = seq_len; - memcpy(key->seq, params->seq, key->seq_len); - key->cipher = params->cipher; + seq_len = params->seq_len; + if (params->cipher == WLAN_CIPHER_SUITE_SMS4 && + seq_len > ATH6KL_KEY_SEQ_LEN) { + /* Only first half of the WPI PN is configured */ + seq_len = ATH6KL_KEY_SEQ_LEN; } + if (params->key_len > WLAN_MAX_KEY_LEN || + seq_len > sizeof(key->seq)) + return -EINVAL; + + key->key_len = params->key_len; + memcpy(key->key, params->key, key->key_len); + key->seq_len = seq_len; + memcpy(key->seq, params->seq, key->seq_len); + key->cipher = params->cipher; switch (key->cipher) { case WLAN_CIPHER_SUITE_WEP40: -- GitLab From cbec267a5143f70ece4069d18889a442bcb3365b Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Tue, 10 Jan 2012 09:53:53 +0530 Subject: [PATCH 0039/1846] ath6kl: Initialize a variable properly This prevents 'comp_pktq' from being used in an incorrect manner. Signed-off-by: Sujith Manoharan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/htc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index b01702258faf..2d721903640b 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2062,6 +2062,7 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, enum htc_endpoint_id id; int n_fetched = 0; + INIT_LIST_HEAD(&comp_pktq); *num_pkts = 0; /* -- GitLab From 8232736dabd2a0310f76944fa7af0542fe3ded4f Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Tue, 10 Jan 2012 09:54:10 +0530 Subject: [PATCH 0040/1846] ath6kl: Fix listen interval handling This patch addresses a few problems with the commit: "ath6kl: Implement support for listen interval from userspace" * The debugfs file required for reading/writing the listen interval wasn't created. Fix this. * The interface index was being hardcoded to zero. Fix this. * Two separate parameters, "listen_interval_time and listen_interval_beacons" were being used. This fails to work as expected because the FW assigns higher precedence to "listen_interval_beacons" and "listen_interval_time" ends up being never used at all. To handle this, fix the host driver to exclusively use listen interval based on units of beacon intervals. To set the listen interval, a user would now do something like this: echo "10" > /sys/kernel/debug/ieee80211/*/ath6kl/listen_interval kvalo: fix two checkpatch warnings Signed-off-by: Sujith Manoharan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 3 +- drivers/net/wireless/ath/ath6kl/core.h | 3 +- drivers/net/wireless/ath/ath6kl/debug.c | 44 +++++++++------------- drivers/net/wireless/ath/ath6kl/main.c | 7 ++-- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 9b26bbaf124e..1a98c9256c60 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2725,8 +2725,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev) clear_bit(SKIP_SCAN, &ar->flag); clear_bit(DESTROY_IN_PROGRESS, &ar->flag); - ar->listen_intvl_t = A_DEFAULT_LISTEN_INTERVAL; - ar->listen_intvl_b = 0; + ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL; ar->tx_pwr = 0; ar->intra_bss = 1; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 793c6a58f0fd..f4da5e19a365 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -55,7 +55,7 @@ #define MAX_DEFAULT_SEND_QUEUE_DEPTH (MAX_DEF_COOKIE_NUM / WMM_NUM_AC) #define DISCON_TIMER_INTVAL 10000 /* in msec */ -#define A_DEFAULT_LISTEN_INTERVAL 100 +#define A_DEFAULT_LISTEN_INTERVAL 1 /* beacon intervals */ #define A_MAX_WOW_LISTEN_INTERVAL 1000 /* includes also the null byte */ @@ -534,7 +534,6 @@ struct ath6kl { spinlock_t lock; struct semaphore sem; u16 listen_intvl_b; - u16 listen_intvl_t; u8 lrssi_roam_threshold; struct ath6kl_version version; u32 target_type; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index eb808b46f94c..fa7243b41442 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1505,57 +1505,46 @@ static const struct file_operations fops_bgscan_int = { }; static ssize_t ath6kl_listen_int_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 ath6kl *ar = file->private_data; - u16 listen_int_t, listen_int_b; + struct ath6kl_vif *vif; + u16 listen_interval; char buf[32]; - char *sptr, *token; ssize_t len; + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; buf[len] = '\0'; - sptr = buf; - - token = strsep(&sptr, " "); - if (!token) - return -EINVAL; - - if (kstrtou16(token, 0, &listen_int_t)) - return -EINVAL; - - if (kstrtou16(sptr, 0, &listen_int_b)) - return -EINVAL; - - if ((listen_int_t < 15) || (listen_int_t > 5000)) + if (kstrtou16(buf, 0, &listen_interval)) return -EINVAL; - if ((listen_int_b < 1) || (listen_int_b > 50)) + if ((listen_interval < 1) || (listen_interval > 50)) return -EINVAL; - ar->listen_intvl_t = listen_int_t; - ar->listen_intvl_b = listen_int_b; - - ath6kl_wmi_listeninterval_cmd(ar->wmi, 0, ar->listen_intvl_t, + ar->listen_intvl_b = listen_interval; + ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, 0, ar->listen_intvl_b); return count; } static ssize_t ath6kl_listen_int_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) + char __user *user_buf, + size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; char buf[32]; int len; - len = scnprintf(buf, sizeof(buf), "%u %u\n", ar->listen_intvl_t, - ar->listen_intvl_b); + len = scnprintf(buf, sizeof(buf), "%u\n", ar->listen_intvl_b); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1710,6 +1699,9 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("bgscan_interval", S_IWUSR, ar->debugfs_phy, ar, &fops_bgscan_int); + debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR, + ar->debugfs_phy, ar, &fops_listen_int); + debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar, &fops_power_params); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 8742eaa78186..4c26572214c7 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -584,10 +584,11 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, memcpy(vif->bssid, bssid, sizeof(vif->bssid)); vif->bss_ch = channel; - if ((vif->nw_type == INFRA_NETWORK)) + if ((vif->nw_type == INFRA_NETWORK)) { + ar->listen_intvl_b = listen_int; ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, - ar->listen_intvl_t, - ar->listen_intvl_b); + 0, ar->listen_intvl_b); + } netif_wake_queue(vif->ndev); -- GitLab From c1762a3fe196483981f91b926f5f6ee18af757f2 Mon Sep 17 00:00:00 2001 From: Thirumalai Pachamuthu Date: Thu, 12 Jan 2012 18:21:39 +0530 Subject: [PATCH 0041/1846] ath6kl: Add support for uAPSD * A new APSD power save queue is added in the station structure. * When a station has APSD capability and goes to power save, the frame designated to the station will be buffered in APSD queue. * When the host receives a frame which the firmware marked as trigger, host delivers the buffered frame from the APSD power save queue. Number of frames to deliver is decided by MAX SP length. * When a station moves from sleep to awake state, all frames buffered in APSD power save queue are sent to the firmware. * When a station is disconnected, all frames bufferes in APSD power save queue are dropped. * When the host queues the first frame to the APSD queue or removes the last frame from the APSD queue, it is indicated to the firmware using WMI_AP_APSD_BUFFERED_TRAFFIC_CMD. kvalo: fix buggy handling of sks queues, made it more obvious the user priority when wmm is disabled, remove unneed else block and combined some variable declarations Signed-off-by: Thirumalai Pachamuthu Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 + drivers/net/wireless/ath/ath6kl/core.h | 10 +- drivers/net/wireless/ath/ath6kl/main.c | 9 +- drivers/net/wireless/ath/ath6kl/txrx.c | 249 ++++++++++++++++++--- drivers/net/wireless/ath/ath6kl/wmi.c | 62 ++++- drivers/net/wireless/ath/ath6kl/wmi.h | 41 +++- 6 files changed, 324 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 1a98c9256c60..a13ecec00702 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2253,6 +2253,11 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, p.dot11_auth_mode = vif->dot11_auth_mode; p.ch = cpu_to_le16(vif->next_chan); + /* Enable uAPSD support by default */ + res = ath6kl_wmi_ap_set_apsd(ar->wmi, vif->fw_vif_idx, true); + if (res < 0) + return res; + if (vif->wdev.iftype == NL80211_IFTYPE_P2P_GO) { p.nw_subtype = SUBTYPE_P2PGO; } else { @@ -2740,6 +2745,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev) for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { spin_lock_init(&ar->sta_list[ctr].psq_lock); skb_queue_head_init(&ar->sta_list[ctr].psq); + skb_queue_head_init(&ar->sta_list[ctr].apsdq); } skb_queue_head_init(&ar->mcastpsq); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f4da5e19a365..ba3953918e4c 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -44,6 +44,10 @@ #define ATH6KL_MAX_ENDPOINTS 4 #define MAX_NODE_NUM 15 +#define ATH6KL_APSD_ALL_FRAME 0xFFFF +#define ATH6KL_APSD_NUM_OF_AC 0x4 +#define ATH6KL_APSD_FRAME_MASK 0xF + /* Extra bytes for htc header alignment */ #define ATH6KL_HTC_ALIGN_BYTES 3 @@ -146,6 +150,8 @@ struct ath6kl_fw_ie { #define STA_PS_AWAKE BIT(0) #define STA_PS_SLEEP BIT(1) #define STA_PS_POLLED BIT(2) +#define STA_PS_APSD_TRIGGER BIT(3) +#define STA_PS_APSD_EOSP BIT(4) /* HTC TX packet tagging definitions */ #define ATH6KL_CONTROL_PKT_TAG HTC_TX_PACKET_TAG_USER_DEFINED @@ -282,6 +288,8 @@ struct ath6kl_sta { u8 wpa_ie[ATH6KL_MAX_IE]; struct sk_buff_head psq; spinlock_t psq_lock; + u8 apsd_info; + struct sk_buff_head apsdq; }; struct ath6kl_version { @@ -714,7 +722,7 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel); void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, u8 keymgmt, u8 ucipher, u8 auth, - u8 assoc_req_len, u8 *assoc_info); + u8 assoc_req_len, u8 *assoc_info, u8 apsd_info); void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, u8 assoc_resp_len, u8 *assoc_info, u16 prot_reason_status); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 4c26572214c7..53f97db4a7a7 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -53,7 +53,8 @@ struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid) } static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie, - size_t ielen, u8 keymgmt, u8 ucipher, u8 auth) + size_t ielen, u8 keymgmt, u8 ucipher, u8 auth, + u8 apsd_info) { struct ath6kl_sta *sta; u8 free_slot; @@ -68,6 +69,7 @@ static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie, sta->keymgmt = keymgmt; sta->ucipher = ucipher; sta->auth = auth; + sta->apsd_info = apsd_info; ar->sta_list_index = ar->sta_list_index | (1 << free_slot); ar->ap_stats.sta[free_slot].aid = cpu_to_le32(aid); @@ -80,6 +82,7 @@ static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i) /* empty the queued pkts in the PS queue if any */ spin_lock_bh(&sta->psq_lock); skb_queue_purge(&sta->psq); + skb_queue_purge(&sta->apsdq); spin_unlock_bh(&sta->psq_lock); memset(&ar->ap_stats.sta[sta->aid - 1], 0, @@ -425,7 +428,7 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel) void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, u8 keymgmt, u8 ucipher, u8 auth, - u8 assoc_req_len, u8 *assoc_info) + u8 assoc_req_len, u8 *assoc_info, u8 apsd_info) { struct ath6kl *ar = vif->ar; u8 *ies = NULL, *wpa_ie = NULL, *pos; @@ -483,7 +486,7 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, ath6kl_add_new_sta(ar, mac_addr, aid, wpa_ie, wpa_ie ? 2 + wpa_ie[1] : 0, - keymgmt, ucipher, auth); + keymgmt, ucipher, auth, apsd_info); /* send event to application */ memset(&sinfo, 0, sizeof(sinfo)); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index fcea82479cde..91bbc1ffa493 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -77,12 +77,120 @@ static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, return ar->node_map[ep_map].ep_id; } +static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn, + struct ath6kl_vif *vif, + struct sk_buff *skb, + u32 *flags) +{ + struct ath6kl *ar = vif->ar; + bool is_apsdq_empty = false; + struct ethhdr *datap = (struct ethhdr *) skb->data; + u8 up, traffic_class, *ip_hdr; + u16 ether_type; + struct ath6kl_llc_snap_hdr *llc_hdr; + + if (conn->sta_flags & STA_PS_APSD_TRIGGER) { + /* + * This tx is because of a uAPSD trigger, determine + * more and EOSP bit. Set EOSP if queue is empty + * or sufficient frames are delivered for this trigger. + */ + spin_lock_bh(&conn->psq_lock); + if (!skb_queue_empty(&conn->apsdq)) + *flags |= WMI_DATA_HDR_FLAGS_MORE; + else if (conn->sta_flags & STA_PS_APSD_EOSP) + *flags |= WMI_DATA_HDR_FLAGS_EOSP; + *flags |= WMI_DATA_HDR_FLAGS_UAPSD; + spin_unlock_bh(&conn->psq_lock); + return false; + } else if (!conn->apsd_info) + return false; + + if (test_bit(WMM_ENABLED, &vif->flags)) { + ether_type = be16_to_cpu(datap->h_proto); + if (is_ethertype(ether_type)) { + /* packet is in DIX format */ + ip_hdr = (u8 *)(datap + 1); + } else { + /* packet is in 802.3 format */ + llc_hdr = (struct ath6kl_llc_snap_hdr *) + (datap + 1); + ether_type = be16_to_cpu(llc_hdr->eth_type); + ip_hdr = (u8 *)(llc_hdr + 1); + } + + if (ether_type == IP_ETHERTYPE) + up = ath6kl_wmi_determine_user_priority( + ip_hdr, 0); + } else { + up = 0; + } + + traffic_class = ath6kl_wmi_get_traffic_class(up); + + if ((conn->apsd_info & (1 << traffic_class)) == 0) + return false; + + /* Queue the frames if the STA is sleeping */ + spin_lock_bh(&conn->psq_lock); + is_apsdq_empty = skb_queue_empty(&conn->apsdq); + skb_queue_tail(&conn->apsdq, skb); + spin_unlock_bh(&conn->psq_lock); + + /* + * If this is the first pkt getting queued + * for this STA, update the PVB for this STA + */ + if (is_apsdq_empty) { + ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi, + vif->fw_vif_idx, + conn->aid, 1, 0); + } + *flags |= WMI_DATA_HDR_FLAGS_UAPSD; + + return true; +} + +static bool ath6kl_process_psq(struct ath6kl_sta *conn, + struct ath6kl_vif *vif, + struct sk_buff *skb, + u32 *flags) +{ + bool is_psq_empty = false; + struct ath6kl *ar = vif->ar; + + if (conn->sta_flags & STA_PS_POLLED) { + spin_lock_bh(&conn->psq_lock); + if (!skb_queue_empty(&conn->psq)) + *flags |= WMI_DATA_HDR_FLAGS_MORE; + spin_unlock_bh(&conn->psq_lock); + return false; + } + + /* Queue the frames if the STA is sleeping */ + spin_lock_bh(&conn->psq_lock); + is_psq_empty = skb_queue_empty(&conn->psq); + skb_queue_tail(&conn->psq, skb); + spin_unlock_bh(&conn->psq_lock); + + /* + * If this is the first pkt getting queued + * for this STA, update the PVB for this + * STA. + */ + if (is_psq_empty) + ath6kl_wmi_set_pvb_cmd(ar->wmi, + vif->fw_vif_idx, + conn->aid, 1); + return true; +} + static bool ath6kl_powersave_ap(struct ath6kl_vif *vif, struct sk_buff *skb, - bool *more_data) + u32 *flags) { struct ethhdr *datap = (struct ethhdr *) skb->data; struct ath6kl_sta *conn = NULL; - bool ps_queued = false, is_psq_empty = false; + bool ps_queued = false; struct ath6kl *ar = vif->ar; if (is_multicast_ether_addr(datap->h_dest)) { @@ -128,7 +236,7 @@ static bool ath6kl_powersave_ap(struct ath6kl_vif *vif, struct sk_buff *skb, */ spin_lock_bh(&ar->mcastpsq_lock); if (!skb_queue_empty(&ar->mcastpsq)) - *more_data = true; + *flags |= WMI_DATA_HDR_FLAGS_MORE; spin_unlock_bh(&ar->mcastpsq_lock); } } @@ -142,37 +250,13 @@ static bool ath6kl_powersave_ap(struct ath6kl_vif *vif, struct sk_buff *skb, } if (conn->sta_flags & STA_PS_SLEEP) { - if (!(conn->sta_flags & STA_PS_POLLED)) { - /* Queue the frames if the STA is sleeping */ - spin_lock_bh(&conn->psq_lock); - is_psq_empty = skb_queue_empty(&conn->psq); - skb_queue_tail(&conn->psq, skb); - spin_unlock_bh(&conn->psq_lock); - - /* - * If this is the first pkt getting queued - * for this STA, update the PVB for this - * STA. - */ - if (is_psq_empty) - ath6kl_wmi_set_pvb_cmd(ar->wmi, - vif->fw_vif_idx, - conn->aid, 1); - - ps_queued = true; - } else { - /* - * This tx is because of a PsPoll. - * Determine if MoreData bit has to be set. - */ - spin_lock_bh(&conn->psq_lock); - if (!skb_queue_empty(&conn->psq)) - *more_data = true; - spin_unlock_bh(&conn->psq_lock); - } + ps_queued = ath6kl_process_uapsdq(conn, + vif, skb, flags); + if (!(*flags & WMI_DATA_HDR_FLAGS_UAPSD)) + ps_queued = ath6kl_process_psq(conn, + vif, skb, flags); } } - return ps_queued; } @@ -242,12 +326,13 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) u32 map_no = 0; u16 htc_tag = ATH6KL_DATA_PKT_TAG; u8 ac = 99 ; /* initialize to unmapped ac */ - bool chk_adhoc_ps_mapping = false, more_data = false; + bool chk_adhoc_ps_mapping = false; int ret; struct wmi_tx_meta_v2 meta_v2; void *meta; u8 csum_start = 0, csum_dest = 0, csum = skb->ip_summed; u8 meta_ver = 0; + u32 flags = 0; ath6kl_dbg(ATH6KL_DBG_WLAN_TX, "%s: skb=0x%p, data=0x%p, len=0x%x\n", __func__, @@ -264,7 +349,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) /* AP mode Power saving processing */ if (vif->nw_type == AP_NETWORK) { - if (ath6kl_powersave_ap(vif, skb, &more_data)) + if (ath6kl_powersave_ap(vif, skb, &flags)) return 0; } @@ -308,7 +393,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) } ret = ath6kl_wmi_data_hdr_add(ar->wmi, skb, - DATA_MSGTYPE, more_data, 0, + DATA_MSGTYPE, flags, 0, meta_ver, meta, vif->fw_vif_idx); @@ -1093,6 +1178,76 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, return is_queued; } +static void ath6kl_uapsd_trigger_frame_rx(struct ath6kl_vif *vif, + struct ath6kl_sta *conn) +{ + struct ath6kl *ar = vif->ar; + bool is_apsdq_empty, is_apsdq_empty_at_start; + u32 num_frames_to_deliver, flags; + struct sk_buff *skb = NULL; + + /* + * If the APSD q for this STA is not empty, dequeue and + * send a pkt from the head of the q. Also update the + * More data bit in the WMI_DATA_HDR if there are + * more pkts for this STA in the APSD q. + * If there are no more pkts for this STA, + * update the APSD bitmap for this STA. + */ + + num_frames_to_deliver = (conn->apsd_info >> ATH6KL_APSD_NUM_OF_AC) & + ATH6KL_APSD_FRAME_MASK; + /* + * Number of frames to send in a service period is + * indicated by the station + * in the QOS_INFO of the association request + * If it is zero, send all frames + */ + if (!num_frames_to_deliver) + num_frames_to_deliver = ATH6KL_APSD_ALL_FRAME; + + spin_lock_bh(&conn->psq_lock); + is_apsdq_empty = skb_queue_empty(&conn->apsdq); + spin_unlock_bh(&conn->psq_lock); + is_apsdq_empty_at_start = is_apsdq_empty; + + while ((!is_apsdq_empty) && (num_frames_to_deliver)) { + + spin_lock_bh(&conn->psq_lock); + skb = skb_dequeue(&conn->apsdq); + is_apsdq_empty = skb_queue_empty(&conn->apsdq); + spin_unlock_bh(&conn->psq_lock); + + /* + * Set the STA flag to Trigger delivery, + * so that the frame will go out + */ + conn->sta_flags |= STA_PS_APSD_TRIGGER; + num_frames_to_deliver--; + + /* Last frame in the service period, set EOSP or queue empty */ + if ((is_apsdq_empty) || (!num_frames_to_deliver)) + conn->sta_flags |= STA_PS_APSD_EOSP; + + ath6kl_data_tx(skb, vif->ndev); + conn->sta_flags &= ~(STA_PS_APSD_TRIGGER); + conn->sta_flags &= ~(STA_PS_APSD_EOSP); + } + + if (is_apsdq_empty) { + if (is_apsdq_empty_at_start) + flags = WMI_AP_APSD_NO_DELIVERY_FRAMES; + else + flags = 0; + + ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi, + vif->fw_vif_idx, + conn->aid, 0, flags); + } + + return; +} + void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) { struct ath6kl *ar = target->dev->ar; @@ -1104,6 +1259,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) int status = packet->status; enum htc_endpoint_id ept = packet->endpoint; bool is_amsdu, prev_ps, ps_state = false; + bool trig_state = false; struct ath6kl_sta *conn = NULL; struct sk_buff *skb1 = NULL; struct ethhdr *datap = NULL; @@ -1197,6 +1353,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) WMI_DATA_HDR_PS_MASK); offset = sizeof(struct wmi_data_hdr); + trig_state = !!(le16_to_cpu(dhdr->info3) & WMI_DATA_HDR_TRIG); switch (meta_type) { case 0: @@ -1235,18 +1392,36 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) else conn->sta_flags &= ~STA_PS_SLEEP; + /* Accept trigger only when the station is in sleep */ + if ((conn->sta_flags & STA_PS_SLEEP) && trig_state) + ath6kl_uapsd_trigger_frame_rx(vif, conn); + if (prev_ps ^ !!(conn->sta_flags & STA_PS_SLEEP)) { if (!(conn->sta_flags & STA_PS_SLEEP)) { struct sk_buff *skbuff = NULL; + bool is_apsdq_empty; spin_lock_bh(&conn->psq_lock); - while ((skbuff = skb_dequeue(&conn->psq)) - != NULL) { + while ((skbuff = skb_dequeue(&conn->psq))) { + spin_unlock_bh(&conn->psq_lock); + ath6kl_data_tx(skbuff, vif->ndev); + spin_lock_bh(&conn->psq_lock); + } + + is_apsdq_empty = skb_queue_empty(&conn->apsdq); + while ((skbuff = skb_dequeue(&conn->apsdq))) { spin_unlock_bh(&conn->psq_lock); ath6kl_data_tx(skbuff, vif->ndev); spin_lock_bh(&conn->psq_lock); } spin_unlock_bh(&conn->psq_lock); + + if (!is_apsdq_empty) + ath6kl_wmi_set_apsd_bfrd_traf( + ar->wmi, + vif->fw_vif_idx, + conn->aid, 0, 0); + /* Clear the PVB for this STA */ ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, conn->aid, 0); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 08fbd9a9be4b..c2420f886ed8 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -180,7 +180,7 @@ static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, } int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, - u8 msg_type, bool more_data, + u8 msg_type, u32 flags, enum wmi_data_hdr_data_type data_type, u8 meta_ver, void *tx_meta_info, u8 if_idx) { @@ -204,17 +204,19 @@ int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; - if (more_data) - data_hdr->info |= - WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; + if (flags & WMI_DATA_HDR_FLAGS_MORE) + data_hdr->info |= WMI_DATA_HDR_MORE; - data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); - data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); + if (flags & WMI_DATA_HDR_FLAGS_EOSP) + data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP); + + data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); + data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); return 0; } -static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) +u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) { struct iphdr *ip_hdr = (struct iphdr *) pkt; u8 ip_pri; @@ -236,6 +238,11 @@ static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) return ip_pri; } +u8 ath6kl_wmi_get_traffic_class(u8 user_priority) +{ + return up_to_ac[user_priority & 0x7]; +} + int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, u32 layer2_priority, bool wmm_enabled, @@ -786,12 +793,14 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, ev->u.ap_sta.keymgmt, le16_to_cpu(ev->u.ap_sta.cipher), ev->u.ap_sta.apsd_info); + ath6kl_connect_ap_mode_sta( vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, ev->u.ap_sta.keymgmt, le16_to_cpu(ev->u.ap_sta.cipher), ev->u.ap_sta.auth, ev->assoc_req_len, - ev->assoc_info + ev->beacon_ie_len); + ev->assoc_info + ev->beacon_ie_len, + ev->u.ap_sta.apsd_info); } return 0; } @@ -2993,6 +3002,43 @@ int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, NO_SYNC_WMIFLAG); } +/* This command will be used to enable/disable AP uAPSD feature */ +int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable) +{ + struct wmi_ap_set_apsd_cmd *cmd; + struct sk_buff *skb; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_ap_set_apsd_cmd *)skb->data; + cmd->enable = enable; + + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID, + NO_SYNC_WMIFLAG); +} + +int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx, + u16 aid, u16 bitmap, u32 flags) +{ + struct wmi_ap_apsd_buffered_traffic_cmd *cmd; + struct sk_buff *skb; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data; + cmd->aid = cpu_to_le16(aid); + cmd->bitmap = cpu_to_le16(bitmap); + cmd->flags = cpu_to_le32(flags); + + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, + WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID, + NO_SYNC_WMIFLAG); +} + static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len, struct ath6kl_vif *vif) { diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index eae0e4e065c4..48e9d2641d69 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -149,8 +149,7 @@ enum wmi_msg_type { #define WMI_DATA_HDR_PS_MASK 0x1 #define WMI_DATA_HDR_PS_SHIFT 5 -#define WMI_DATA_HDR_MORE_MASK 0x1 -#define WMI_DATA_HDR_MORE_SHIFT 5 +#define WMI_DATA_HDR_MORE 0x20 enum wmi_data_hdr_data_type { WMI_DATA_HDR_DATA_TYPE_802_3 = 0, @@ -160,6 +159,13 @@ enum wmi_data_hdr_data_type { WMI_DATA_HDR_DATA_TYPE_ACL, }; +/* Bitmap of data header flags */ +enum wmi_data_hdr_flags { + WMI_DATA_HDR_FLAGS_MORE = 0x1, + WMI_DATA_HDR_FLAGS_EOSP = 0x2, + WMI_DATA_HDR_FLAGS_UAPSD = 0x4, +}; + #define WMI_DATA_HDR_DATA_TYPE_MASK 0x3 #define WMI_DATA_HDR_DATA_TYPE_SHIFT 6 @@ -173,8 +179,12 @@ enum wmi_data_hdr_data_type { #define WMI_DATA_HDR_META_MASK 0x7 #define WMI_DATA_HDR_META_SHIFT 13 +/* Macros for operating on WMI_DATA_HDR (info3) field */ #define WMI_DATA_HDR_IF_IDX_MASK 0xF +#define WMI_DATA_HDR_TRIG 0x10 +#define WMI_DATA_HDR_EOSP 0x10 + struct wmi_data_hdr { s8 rssi; @@ -203,7 +213,8 @@ struct wmi_data_hdr { /* * usage of info3, 16-bit: * b3:b0 - Interface index - * b15:b4 - Reserved + * b4 - uAPSD trigger in rx & EOSP in tx + * b15:b5 - Reserved */ __le16 info3; } __packed; @@ -2116,6 +2127,19 @@ struct wmi_rx_frame_format_cmd { } __packed; /* AP mode events */ +struct wmi_ap_set_apsd_cmd { + u8 enable; +} __packed; + +enum wmi_ap_apsd_buffered_traffic_flags { + WMI_AP_APSD_NO_DELIVERY_FRAMES = 0x1, +}; + +struct wmi_ap_apsd_buffered_traffic_cmd { + __le16 aid; + __le16 bitmap; + __le32 flags; +} __packed; /* WMI_PS_POLL_EVENT */ struct wmi_pspoll_event { @@ -2332,7 +2356,7 @@ enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi); void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id); int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb); int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, - u8 msg_type, bool more_data, + u8 msg_type, u32 flags, enum wmi_data_hdr_data_type data_type, u8 meta_ver, void *tx_meta_info, u8 if_idx); @@ -2446,7 +2470,16 @@ int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode); int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on); int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, u8 *filter, bool add_filter); +/* AP mode uAPSD */ +int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable); + +int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, + u8 if_idx, u16 aid, + u16 bitmap, u32 flags); + +u8 ath6kl_wmi_get_traffic_class(u8 user_priority); +u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri); /* AP mode */ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, struct wmi_connect_cmd *p); -- GitLab From e80ec84d9352419a7c0482edfbf1b96eaa4c8b95 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Thu, 12 Jan 2012 15:01:48 +0530 Subject: [PATCH 0042/1846] ath6kl: Remove useless initialization in ath6kl_read_fwlogs() ath6kl_read_fwlogs() assigns the value zero to the variable 'ret' at the time of declaration. Later, return value of ath6kl_diag_read32() repalces the init value. Hence removing useless zero assignment. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 53f97db4a7a7..0a6d6e2be6e9 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -255,7 +255,7 @@ int ath6kl_read_fwlogs(struct ath6kl *ar) struct ath6kl_dbglog_hdr debug_hdr; struct ath6kl_dbglog_buf debug_buf; u32 address, length, dropped, firstbuf, debug_hdr_addr; - int ret = 0, loop; + int ret, loop; u8 *buf; buf = kmalloc(ATH6KL_FWLOG_PAYLOAD_SIZE, GFP_KERNEL); -- GitLab From d6f802612af55cc1b3699d119a04dfa2fc8812a0 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 15:05:19 +0200 Subject: [PATCH 0043/1846] ath6kl: use netdev_features_t Commit c8f44affb7 ("net: introduce and use netdev_features_t for device features sets") added netdev_features_t to ndo_set_features. Change ath6kl to use the new type. This fixes a warning: ath6kl/main.c:1170: warning: initialization from incompatible pointer type Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 0a6d6e2be6e9..3a3b2cc9940d 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1021,7 +1021,8 @@ static struct net_device_stats *ath6kl_get_stats(struct net_device *dev) return &vif->net_stats; } -static int ath6kl_set_features(struct net_device *dev, u32 features) +static int ath6kl_set_features(struct net_device *dev, + netdev_features_t features) { struct ath6kl_vif *vif = netdev_priv(dev); struct ath6kl *ar = vif->ar; -- GitLab From 3462735dadb90efd5bed9d2b81222ed7da1390a0 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 15:05:32 +0200 Subject: [PATCH 0044/1846] ath6kl: remove -D__CHECK_ENDIAN__ from Makefile As drivers/net/wireless/ath/Makefile contains the flag to enable endian checks there's no need to have it in ath6kl makefile anymore. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index 707069303550..e24b61799158 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -33,5 +33,3 @@ ath6kl-y += txrx.o ath6kl-y += wmi.o ath6kl-y += sdio.o ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o - -ccflags-y += -D__CHECK_ENDIAN__ -- GitLab From e572602884c4f979cbba4fed413af24797fd01d9 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 15:05:46 +0200 Subject: [PATCH 0045/1846] ath6kl: fix uninitialized warning in ath6kl_process_uapsdq() Before I commited patch c1762a3fe ("ath6kl: Add support for uAPSD") I did a minor change how up variable is initialised in ath6kl_process_uapsdq(). But I was sloppy and caused this compiler warning: txrx.c:88:5: warning: 'up' may be used uninitialized in this function Revert my change to fix the warning. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/txrx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 91bbc1ffa493..dd6337142603 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -85,7 +85,7 @@ static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn, struct ath6kl *ar = vif->ar; bool is_apsdq_empty = false; struct ethhdr *datap = (struct ethhdr *) skb->data; - u8 up, traffic_class, *ip_hdr; + u8 up = 0, traffic_class, *ip_hdr; u16 ether_type; struct ath6kl_llc_snap_hdr *llc_hdr; @@ -122,8 +122,6 @@ static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn, if (ether_type == IP_ETHERTYPE) up = ath6kl_wmi_determine_user_priority( ip_hdr, 0); - } else { - up = 0; } traffic_class = ath6kl_wmi_get_traffic_class(up); -- GitLab From cd23c1c9b8a2de64477a795ab5a9cd5278397f24 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 17 Jan 2012 15:32:29 +0200 Subject: [PATCH 0046/1846] ath6kl: add testmode 2 for 6003 ART Add testmode 2 for 6003 ART. When you insmod ath6kl_sdio.ko testmode=2, ath6kl will load ART firmware utf.bin and testscript nullTestFlow.bin. These files should be put in the firmware folder. kvalo: add "ath6kl:" to the title, word wrap the commit log and remove extra line in the code Signed-off-by: Alex Yang Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 8 ++ drivers/net/wireless/ath/ath6kl/init.c | 108 +++++++++++++++++++++++-- 2 files changed, 110 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ba3953918e4c..f53594f2e537 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -125,6 +125,8 @@ struct ath6kl_fw_ie { #define AR6003_HW_2_1_1_OTP_FILE "otp.bin" #define AR6003_HW_2_1_1_FIRMWARE_FILE "athwlan.bin" #define AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE "athtcmd_ram.bin" +#define AR6003_HW_2_1_1_UTF_FIRMWARE_FILE "utf.bin" +#define AR6003_HW_2_1_1_TESTSCRIPT_FILE "nullTestFlow.bin" #define AR6003_HW_2_1_1_PATCH_FILE "data.patch.bin" #define AR6003_HW_2_1_1_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.bin" #define AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE \ @@ -592,6 +594,7 @@ struct ath6kl { u32 board_addr; u32 refclk_hz; u32 uarttx_pin; + u32 testscript_addr; struct ath6kl_hw_fw { const char *dir; @@ -599,6 +602,8 @@ struct ath6kl { const char *fw; const char *tcmd; const char *patch; + const char *utf; + const char *testscript; } fw; const char *fw_board; @@ -624,6 +629,9 @@ struct ath6kl { u8 *fw_patch; size_t fw_patch_len; + u8 *fw_testscript; + size_t fw_testscript_len; + unsigned int fw_api; unsigned long fw_capabilities[ATH6KL_CAPABILITY_LEN]; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index e5969c146302..b88f41dc3dfa 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -69,6 +69,7 @@ static const struct ath6kl_hw hw_list[] = { .reserved_ram_size = 512, .refclk_hz = 26000000, .uarttx_pin = 8, + .testscript_addr = 0x57ef74, .fw = { .dir = AR6003_HW_2_1_1_FW_DIR, @@ -76,6 +77,8 @@ static const struct ath6kl_hw hw_list[] = { .fw = AR6003_HW_2_1_1_FIRMWARE_FILE, .tcmd = AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE, .patch = AR6003_HW_2_1_1_PATCH_FILE, + .utf = AR6003_HW_2_1_1_UTF_FIRMWARE_FILE, + .testscript = AR6003_HW_2_1_1_TESTSCRIPT_FILE, }, .fw_board = AR6003_HW_2_1_1_BOARD_DATA_FILE, @@ -620,6 +623,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar) kfree(ar->fw_otp); kfree(ar->fw); kfree(ar->fw_patch); + kfree(ar->fw_testscript); ath6kl_deinit_ieee80211_hw(ar); } @@ -771,14 +775,25 @@ static int ath6kl_fetch_fw_file(struct ath6kl *ar) return 0; if (testmode) { - if (ar->hw.fw.tcmd == NULL) { - ath6kl_warn("testmode not supported\n"); - return -EOPNOTSUPP; - } + ath6kl_dbg(ATH6KL_DBG_BOOT, "testmode %d\n", + testmode); + if (testmode == 2) { + if (ar->hw.fw.utf == NULL) { + ath6kl_warn("testmode 2 not supported\n"); + return -EOPNOTSUPP; + } - snprintf(filename, sizeof(filename), "%s/%s", - ar->hw.fw.dir, ar->hw.fw.tcmd); + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.utf); + } else { + if (ar->hw.fw.tcmd == NULL) { + ath6kl_warn("testmode 1 not supported\n"); + return -EOPNOTSUPP; + } + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.tcmd); + } set_bit(TESTMODE, &ar->flag); goto get_fw; @@ -827,6 +842,34 @@ static int ath6kl_fetch_patch_file(struct ath6kl *ar) return 0; } +static int ath6kl_fetch_testscript_file(struct ath6kl *ar) +{ + char filename[100]; + int ret; + + if (testmode != 2) + return 0; + + if (ar->fw_testscript != NULL) + return 0; + + if (ar->hw.fw.testscript == NULL) + return 0; + + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.testscript); + + ret = ath6kl_get_fw(ar, filename, &ar->fw_testscript, + &ar->fw_testscript_len); + if (ret) { + ath6kl_err("Failed to get testscript file %s: %d\n", + filename, ret); + return ret; + } + + return 0; +} + static int ath6kl_fetch_fw_api1(struct ath6kl *ar) { int ret; @@ -843,6 +886,10 @@ static int ath6kl_fetch_fw_api1(struct ath6kl *ar) if (ret) return ret; + ret = ath6kl_fetch_testscript_file(ar); + if (ret) + return ret; + return 0; } @@ -1266,6 +1313,50 @@ static int ath6kl_upload_patch(struct ath6kl *ar) return 0; } +static int ath6kl_upload_testscript(struct ath6kl *ar) +{ + u32 address, param; + int ret; + + if (testmode != 2) + return 0; + + if (ar->fw_testscript == NULL) + return 0; + + address = ar->hw.testscript_addr; + + ath6kl_dbg(ATH6KL_DBG_BOOT, "writing testscript to 0x%x (%zd B)\n", + address, ar->fw_testscript_len); + + ret = ath6kl_bmi_write(ar, address, ar->fw_testscript, + ar->fw_testscript_len); + if (ret) { + ath6kl_err("Failed to write testscript file: %d\n", ret); + return ret; + } + + param = address; + ath6kl_bmi_write(ar, + ath6kl_get_hi_item_addr(ar, + HI_ITEM(hi_ota_testscript)), + (unsigned char *) ¶m, 4); + + param = 4096; + ath6kl_bmi_write(ar, + ath6kl_get_hi_item_addr(ar, + HI_ITEM(hi_end_ram_reserve_sz)), + (unsigned char *) ¶m, 4); + + param = 1; + ath6kl_bmi_write(ar, + ath6kl_get_hi_item_addr(ar, + HI_ITEM(hi_test_apps_related)), + (unsigned char *) ¶m, 4); + + return 0; +} + static int ath6kl_init_upload(struct ath6kl *ar) { u32 param, options, sleep, address; @@ -1374,6 +1465,11 @@ static int ath6kl_init_upload(struct ath6kl *ar) if (status) return status; + /* Download the test script */ + status = ath6kl_upload_testscript(ar); + if (status) + return status; + /* Restore system sleep */ address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS; status = ath6kl_bmi_reg_write(ar, address, sleep); -- GitLab From c25889e8a6fdfc54618b192a80c94419ddb7949d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:08:27 +0200 Subject: [PATCH 0047/1846] ath6kl: rename vif init and cleanup functions ath6kl_cfg80211_vif_init/cleanup() follow more closely the style used elsewhere in ath6kl. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 9 ++++----- drivers/net/wireless/ath/ath6kl/cfg80211.h | 2 ++ drivers/net/wireless/ath/ath6kl/core.h | 1 - drivers/net/wireless/ath/ath6kl/init.c | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index a13ecec00702..7e92dc9799ac 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1401,7 +1401,7 @@ static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy, ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); - ath6kl_deinit_if_data(vif); + ath6kl_cfg80211_vif_cleanup(vif); return 0; } @@ -2806,7 +2806,7 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar) return 0; } -static int ath6kl_init_if_data(struct ath6kl_vif *vif) +static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif) { vif->aggr_cntxt = aggr_init(vif->ndev); if (!vif->aggr_cntxt) { @@ -2827,7 +2827,7 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif) return 0; } -void ath6kl_deinit_if_data(struct ath6kl_vif *vif) +void ath6kl_cfg80211_vif_cleanup(struct ath6kl_vif *vif) { struct ath6kl *ar = vif->ar; struct ath6kl_mc_filter *mc_filter, *tmp; @@ -2880,8 +2880,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, ath6kl_init_control_info(vif); - /* TODO: Pass interface specific pointer instead of ar */ - if (ath6kl_init_if_data(vif)) + if (ath6kl_cfg80211_vif_init(vif)) goto err; if (register_netdevice(ndev)) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 81f20a572315..aa961694cf99 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -53,6 +53,8 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, int ath6kl_cfg80211_resume(struct ath6kl *ar); +void ath6kl_cfg80211_vif_cleanup(struct ath6kl_vif *vif); + void ath6kl_cfg80211_stop(struct ath6kl_vif *vif); void ath6kl_cfg80211_stop_all(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f53594f2e537..bdeb254c259c 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -753,7 +753,6 @@ void ath6kl_wakeup_event(void *dev); void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, bool wait_fot_compltn, bool cold_reset); void ath6kl_init_control_info(struct ath6kl_vif *vif); -void ath6kl_deinit_if_data(struct ath6kl_vif *vif); void ath6kl_core_free(struct ath6kl *ar); struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index b88f41dc3dfa..3cc4e0842add 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1811,7 +1811,7 @@ int ath6kl_core_init(struct ath6kl *ar) ath6kl_htc_flush_rx_buf(ar->htc_target); ath6kl_cleanup_amsdu_rxbufs(ar); rtnl_lock(); - ath6kl_deinit_if_data(netdev_priv(ndev)); + ath6kl_cfg80211_vif_cleanup(netdev_priv(ndev)); rtnl_unlock(); wiphy_unregister(ar->wiphy); err_debug_init: @@ -1832,6 +1832,7 @@ int ath6kl_core_init(struct ath6kl *ar) return ret; } +/* FIXME: move this to cfg80211.c and rename to ath6kl_cfg80211_vif_stop() */ void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) { static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -1877,7 +1878,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar) spin_unlock_bh(&ar->list_lock); ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag)); rtnl_lock(); - ath6kl_deinit_if_data(vif); + ath6kl_cfg80211_vif_cleanup(vif); rtnl_unlock(); spin_lock_bh(&ar->list_lock); } -- GitLab From 46d33a21cfa531f4271c3f0b7b87a295f30f9e6a Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:08:40 +0200 Subject: [PATCH 0048/1846] ath6kl: unify cfg80211 init/cleanup functions Group them together and change the naming to follow the common style in ath6kl. No functional changes. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 109 +++++++++++---------- drivers/net/wireless/ath/ath6kl/cfg80211.h | 6 +- drivers/net/wireless/ath/ath6kl/init.c | 4 +- 3 files changed, 62 insertions(+), 57 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 7e92dc9799ac..44fdd39e1701 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2755,57 +2755,6 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev) return ar; } -int ath6kl_register_ieee80211_hw(struct ath6kl *ar) -{ - struct wiphy *wiphy = ar->wiphy; - int ret; - - wiphy->mgmt_stypes = ath6kl_mgmt_stypes; - - wiphy->max_remain_on_channel_duration = 5000; - - /* set device pointer for wiphy */ - set_wiphy_dev(wiphy, ar->dev); - - wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC) | - BIT(NL80211_IFTYPE_AP); - if (ar->p2p) { - wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_GO) | - BIT(NL80211_IFTYPE_P2P_CLIENT); - } - - /* max num of ssids that can be probed during scanning */ - wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX; - wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */ - wiphy->bands[IEEE80211_BAND_2GHZ] = &ath6kl_band_2ghz; - wiphy->bands[IEEE80211_BAND_5GHZ] = &ath6kl_band_5ghz; - wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - - wiphy->cipher_suites = cipher_suites; - wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); - - wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | - WIPHY_WOWLAN_DISCONNECT | - WIPHY_WOWLAN_GTK_REKEY_FAILURE | - WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | - WIPHY_WOWLAN_EAP_IDENTITY_REQ | - WIPHY_WOWLAN_4WAY_HANDSHAKE; - wiphy->wowlan.n_patterns = WOW_MAX_FILTERS_PER_LIST; - wiphy->wowlan.pattern_min_len = 1; - wiphy->wowlan.pattern_max_len = WOW_PATTERN_SIZE; - - wiphy->max_sched_scan_ssids = 10; - - ret = wiphy_register(wiphy); - if (ret < 0) { - ath6kl_err("couldn't register wiphy device\n"); - return ret; - } - - return 0; -} - static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif) { vif->aggr_cntxt = aggr_init(vif->ndev); @@ -2907,8 +2856,64 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, return NULL; } -void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar) +int ath6kl_cfg80211_init(struct ath6kl *ar) +{ + struct wiphy *wiphy = ar->wiphy; + int ret; + + wiphy->mgmt_stypes = ath6kl_mgmt_stypes; + + wiphy->max_remain_on_channel_duration = 5000; + + /* set device pointer for wiphy */ + set_wiphy_dev(wiphy, ar->dev); + + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC) | + BIT(NL80211_IFTYPE_AP); + if (ar->p2p) { + wiphy->interface_modes |= BIT(NL80211_IFTYPE_P2P_GO) | + BIT(NL80211_IFTYPE_P2P_CLIENT); + } + + /* max num of ssids that can be probed during scanning */ + wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX; + wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */ + wiphy->bands[IEEE80211_BAND_2GHZ] = &ath6kl_band_2ghz; + wiphy->bands[IEEE80211_BAND_5GHZ] = &ath6kl_band_5ghz; + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + + wiphy->cipher_suites = cipher_suites; + wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); + + wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | + WIPHY_WOWLAN_DISCONNECT | + WIPHY_WOWLAN_GTK_REKEY_FAILURE | + WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | + WIPHY_WOWLAN_EAP_IDENTITY_REQ | + WIPHY_WOWLAN_4WAY_HANDSHAKE; + wiphy->wowlan.n_patterns = WOW_MAX_FILTERS_PER_LIST; + wiphy->wowlan.pattern_min_len = 1; + wiphy->wowlan.pattern_max_len = WOW_PATTERN_SIZE; + + wiphy->max_sched_scan_ssids = 10; + + ret = wiphy_register(wiphy); + if (ret < 0) { + ath6kl_err("couldn't register wiphy device\n"); + return ret; + } + + return 0; +} + +void ath6kl_cfg80211_cleanup(struct ath6kl *ar) { wiphy_unregister(ar->wiphy); + + /* + * FIXME: should be removed as we remove wiphy in + * ath6kl_core_free(). Most likely this causes a use after free. + */ wiphy_free(ar->wiphy); } diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index aa961694cf99..08d97691039c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -27,10 +27,7 @@ enum ath6kl_cfg_suspend_mode { struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, enum nl80211_iftype type, u8 fw_vif_idx, u8 nw_type); -int ath6kl_register_ieee80211_hw(struct ath6kl *ar); struct ath6kl *ath6kl_core_alloc(struct device *dev); -void ath6kl_deinit_ieee80211_hw(struct ath6kl *ar); - void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted); void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, @@ -58,4 +55,7 @@ void ath6kl_cfg80211_vif_cleanup(struct ath6kl_vif *vif); void ath6kl_cfg80211_stop(struct ath6kl_vif *vif); void ath6kl_cfg80211_stop_all(struct ath6kl *ar); +int ath6kl_cfg80211_init(struct ath6kl *ar); +void ath6kl_cfg80211_cleanup(struct ath6kl *ar); + #endif /* ATH6KL_CFG80211_H */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 3cc4e0842add..7e56a6aa70b9 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -625,7 +625,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar) kfree(ar->fw_patch); kfree(ar->fw_testscript); - ath6kl_deinit_ieee80211_hw(ar); + ath6kl_cfg80211_cleanup(ar); } /* firmware upload */ @@ -1722,7 +1722,7 @@ int ath6kl_core_init(struct ath6kl *ar) ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi); - ret = ath6kl_register_ieee80211_hw(ar); + ret = ath6kl_cfg80211_init(ar); if (ret) goto err_node_cleanup; -- GitLab From f29af97853599e9537191c4f33f8ac87f3f503a9 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:08:56 +0200 Subject: [PATCH 0049/1846] ath6kl: add ATH6KL_CONF_UART_DEBUG Add ATH6KL_CONF_UART_DEBUG which is set whenever uart_debug module parameter is enabled. This way we can keep the uart_debug parameter static when core.c file is introduced. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 1 + drivers/net/wireless/ath/ath6kl/init.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index bdeb254c259c..78c0402e2d33 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -197,6 +197,7 @@ struct ath6kl_fw_ie { #define ATH6KL_CONF_ENABLE_11N BIT(2) #define ATH6KL_CONF_ENABLE_TX_BURST BIT(3) #define ATH6KL_CONF_SUSPEND_CUTPOWER BIT(4) +#define ATH6KL_CONF_UART_DEBUG BIT(5) enum wlan_low_pwr_state { WLAN_POWER_STATE_ON, diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 7e56a6aa70b9..2804921d5d8a 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -469,7 +469,7 @@ int ath6kl_configure_target(struct ath6kl *ar) u8 fw_iftype, fw_mode = 0, fw_submode = 0; int i, status; - param = uart_debug; + param = !!(ar->conf_flags & ATH6KL_CONF_UART_DEBUG); if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_serial_enable)), (u8 *)¶m, 4)) { ath6kl_err("bmi_write_memory for uart debug failed\n"); @@ -1775,6 +1775,9 @@ int ath6kl_core_init(struct ath6kl *ar) if (suspend_cutpower) ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER; + if (uart_debug) + ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | WIPHY_FLAG_HAVE_AP_SME | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | -- GitLab From 45eaa78f757b3b3992ca02c753764665e9fba0a4 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:09:05 +0200 Subject: [PATCH 0050/1846] ath6kl: create core.c Currently core functions are spread between various files, group all the functions into file and rename the functions to follow the style used elsewhere in the driver. This will make it easier to a separate core module. Also fix a bug where wiphy is freed too early. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/Makefile | 1 + drivers/net/wireless/ath/ath6kl/cfg80211.c | 94 ++----- drivers/net/wireless/ath/ath6kl/cfg80211.h | 4 +- drivers/net/wireless/ath/ath6kl/common.h | 3 - drivers/net/wireless/ath/ath6kl/core.c | 292 +++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/core.h | 9 +- drivers/net/wireless/ath/ath6kl/init.c | 213 +-------------- drivers/net/wireless/ath/ath6kl/sdio.c | 4 +- 8 files changed, 332 insertions(+), 288 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/core.c diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index e24b61799158..854694b26a4b 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -31,5 +31,6 @@ ath6kl-y += init.o ath6kl-y += main.o ath6kl-y += txrx.o ath6kl-y += wmi.o +ath6kl-y += core.o ath6kl-y += sdio.o ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 44fdd39e1701..7ff9806de50b 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -23,10 +23,6 @@ #include "hif-ops.h" #include "testmode.h" -static unsigned int ath6kl_p2p; - -module_param(ath6kl_p2p, uint, 0644); - #define RATETAB_ENT(_rate, _rateid, _flags) { \ .bitrate = (_rate), \ .flags = (_flags), \ @@ -2693,68 +2689,6 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar) ath6kl_cfg80211_stop(vif); } -struct ath6kl *ath6kl_core_alloc(struct device *dev) -{ - struct ath6kl *ar; - struct wiphy *wiphy; - u8 ctr; - - /* create a new wiphy for use with cfg80211 */ - wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl)); - - if (!wiphy) { - ath6kl_err("couldn't allocate wiphy device\n"); - return NULL; - } - - ar = wiphy_priv(wiphy); - ar->p2p = !!ath6kl_p2p; - ar->wiphy = wiphy; - ar->dev = dev; - - ar->vif_max = 1; - - ar->max_norm_iface = 1; - - spin_lock_init(&ar->lock); - spin_lock_init(&ar->mcastpsq_lock); - spin_lock_init(&ar->list_lock); - - init_waitqueue_head(&ar->event_wq); - sema_init(&ar->sem, 1); - - INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue); - INIT_LIST_HEAD(&ar->vif_list); - - clear_bit(WMI_ENABLED, &ar->flag); - clear_bit(SKIP_SCAN, &ar->flag); - clear_bit(DESTROY_IN_PROGRESS, &ar->flag); - - ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL; - ar->tx_pwr = 0; - - ar->intra_bss = 1; - ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD; - - ar->state = ATH6KL_STATE_OFF; - - memset((u8 *)ar->sta_list, 0, - AP_MAX_NUM_STA * sizeof(struct ath6kl_sta)); - - /* Init the PS queues */ - for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { - spin_lock_init(&ar->sta_list[ctr].psq_lock); - skb_queue_head_init(&ar->sta_list[ctr].psq); - skb_queue_head_init(&ar->sta_list[ctr].apsdq); - } - - skb_queue_head_init(&ar->mcastpsq); - - memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3); - - return ar; -} - static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif) { vif->aggr_cntxt = aggr_init(vif->ndev); @@ -2910,10 +2844,30 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) void ath6kl_cfg80211_cleanup(struct ath6kl *ar) { wiphy_unregister(ar->wiphy); +} - /* - * FIXME: should be removed as we remove wiphy in - * ath6kl_core_free(). Most likely this causes a use after free. - */ +struct ath6kl *ath6kl_cfg80211_create(void) +{ + struct ath6kl *ar; + struct wiphy *wiphy; + + /* create a new wiphy for use with cfg80211 */ + wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl)); + + if (!wiphy) { + ath6kl_err("couldn't allocate wiphy device\n"); + return NULL; + } + + ar = wiphy_priv(wiphy); + ar->wiphy = wiphy; + + return ar; +} + +/* Note: ar variable must not be accessed after calling this! */ +void ath6kl_cfg80211_destroy(struct ath6kl *ar) +{ wiphy_free(ar->wiphy); } + diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 08d97691039c..3c693b7c0efd 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -27,7 +27,6 @@ enum ath6kl_cfg_suspend_mode { struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, enum nl80211_iftype type, u8 fw_vif_idx, u8 nw_type); -struct ath6kl *ath6kl_core_alloc(struct device *dev); void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted); void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel, @@ -58,4 +57,7 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar); int ath6kl_cfg80211_init(struct ath6kl *ar); void ath6kl_cfg80211_cleanup(struct ath6kl *ar); +struct ath6kl *ath6kl_cfg80211_create(void); +void ath6kl_cfg80211_destroy(struct ath6kl *ar); + #endif /* ATH6KL_CFG80211_H */ diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index bfd6597763da..f89f1e180da3 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -79,8 +79,5 @@ struct ath6kl; enum htc_credit_dist_reason; struct ath6kl_htc_credit_info; -struct ath6kl *ath6kl_core_alloc(struct device *sdev); -int ath6kl_core_init(struct ath6kl *ar); -void ath6kl_core_cleanup(struct ath6kl *ar); struct sk_buff *ath6kl_buf_alloc(int size); #endif /* COMMON_H */ diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c new file mode 100644 index 000000000000..40fad5ec9366 --- /dev/null +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2004-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 "core.h" + +#include + +#include "debug.h" +#include "hif-ops.h" +#include "cfg80211.h" + +unsigned int debug_mask; +static bool suspend_cutpower; +static unsigned int uart_debug; +static unsigned int ath6kl_p2p; + +module_param(debug_mask, uint, 0644); +module_param(suspend_cutpower, bool, 0444); +module_param(uart_debug, uint, 0644); +module_param(ath6kl_p2p, uint, 0644); + +int ath6kl_core_init(struct ath6kl *ar) +{ + struct ath6kl_bmi_target_info targ_info; + struct net_device *ndev; + int ret = 0, i; + + ar->ath6kl_wq = create_singlethread_workqueue("ath6kl"); + if (!ar->ath6kl_wq) + return -ENOMEM; + + ret = ath6kl_bmi_init(ar); + if (ret) + goto err_wq; + + /* + * Turn on power to get hardware (target) version and leave power + * on delibrately as we will boot the hardware anyway within few + * seconds. + */ + ret = ath6kl_hif_power_on(ar); + if (ret) + goto err_bmi_cleanup; + + ret = ath6kl_bmi_get_target_info(ar, &targ_info); + if (ret) + goto err_power_off; + + ar->version.target_ver = le32_to_cpu(targ_info.version); + ar->target_type = le32_to_cpu(targ_info.type); + ar->wiphy->hw_version = le32_to_cpu(targ_info.version); + + ret = ath6kl_init_hw_params(ar); + if (ret) + goto err_power_off; + + ar->htc_target = ath6kl_htc_create(ar); + + if (!ar->htc_target) { + ret = -ENOMEM; + goto err_power_off; + } + + ret = ath6kl_init_fetch_firmwares(ar); + if (ret) + goto err_htc_cleanup; + + /* FIXME: we should free all firmwares in the error cases below */ + + /* Indicate that WMI is enabled (although not ready yet) */ + set_bit(WMI_ENABLED, &ar->flag); + ar->wmi = ath6kl_wmi_init(ar); + if (!ar->wmi) { + ath6kl_err("failed to initialize wmi\n"); + ret = -EIO; + goto err_htc_cleanup; + } + + ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi); + + ret = ath6kl_cfg80211_init(ar); + if (ret) + goto err_node_cleanup; + + ret = ath6kl_debug_init(ar); + if (ret) { + wiphy_unregister(ar->wiphy); + goto err_node_cleanup; + } + + for (i = 0; i < ar->vif_max; i++) + ar->avail_idx_map |= BIT(i); + + rtnl_lock(); + + /* Add an initial station interface */ + ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, + INFRA_NETWORK); + + rtnl_unlock(); + + if (!ndev) { + ath6kl_err("Failed to instantiate a network device\n"); + ret = -ENOMEM; + wiphy_unregister(ar->wiphy); + goto err_debug_init; + } + + + ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", + __func__, ndev->name, ndev, ar); + + /* setup access class priority mappings */ + ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */ + ar->ac_stream_pri_map[WMM_AC_BE] = 1; + ar->ac_stream_pri_map[WMM_AC_VI] = 2; + ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */ + + /* give our connected endpoints some buffers */ + ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep); + ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]); + + /* allocate some buffers that handle larger AMSDU frames */ + ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS); + + ath6kl_cookie_init(ar); + + ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | + ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; + + if (suspend_cutpower) + ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER; + + if (uart_debug) + ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; + + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | + WIPHY_FLAG_HAVE_AP_SME | + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; + + if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN, ar->fw_capabilities)) + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; + + ar->wiphy->probe_resp_offload = + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U; + + set_bit(FIRST_BOOT, &ar->flag); + + ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; + + ret = ath6kl_init_hw_start(ar); + if (ret) { + ath6kl_err("Failed to start hardware: %d\n", ret); + goto err_rxbuf_cleanup; + } + + /* + * Set mac address which is received in ready event + * FIXME: Move to ath6kl_interface_add() + */ + memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); + + return ret; + +err_rxbuf_cleanup: + ath6kl_htc_flush_rx_buf(ar->htc_target); + ath6kl_cleanup_amsdu_rxbufs(ar); + rtnl_lock(); + ath6kl_cfg80211_vif_cleanup(netdev_priv(ndev)); + rtnl_unlock(); + wiphy_unregister(ar->wiphy); +err_debug_init: + ath6kl_debug_cleanup(ar); +err_node_cleanup: + ath6kl_wmi_shutdown(ar->wmi); + clear_bit(WMI_ENABLED, &ar->flag); + ar->wmi = NULL; +err_htc_cleanup: + ath6kl_htc_cleanup(ar->htc_target); +err_power_off: + ath6kl_hif_power_off(ar); +err_bmi_cleanup: + ath6kl_bmi_cleanup(ar); +err_wq: + destroy_workqueue(ar->ath6kl_wq); + + return ret; +} + +struct ath6kl *ath6kl_core_create(struct device *dev) +{ + struct ath6kl *ar; + u8 ctr; + + ar = ath6kl_cfg80211_create(); + if (!ar) + return NULL; + + ar->p2p = !!ath6kl_p2p; + ar->dev = dev; + + ar->vif_max = 1; + + ar->max_norm_iface = 1; + + spin_lock_init(&ar->lock); + spin_lock_init(&ar->mcastpsq_lock); + spin_lock_init(&ar->list_lock); + + init_waitqueue_head(&ar->event_wq); + sema_init(&ar->sem, 1); + + INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue); + INIT_LIST_HEAD(&ar->vif_list); + + clear_bit(WMI_ENABLED, &ar->flag); + clear_bit(SKIP_SCAN, &ar->flag); + clear_bit(DESTROY_IN_PROGRESS, &ar->flag); + + ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL; + ar->tx_pwr = 0; + + ar->intra_bss = 1; + ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD; + + ar->state = ATH6KL_STATE_OFF; + + memset((u8 *)ar->sta_list, 0, + AP_MAX_NUM_STA * sizeof(struct ath6kl_sta)); + + /* Init the PS queues */ + for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { + spin_lock_init(&ar->sta_list[ctr].psq_lock); + skb_queue_head_init(&ar->sta_list[ctr].psq); + skb_queue_head_init(&ar->sta_list[ctr].apsdq); + } + + skb_queue_head_init(&ar->mcastpsq); + + memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3); + + return ar; +} + +void ath6kl_core_cleanup(struct ath6kl *ar) +{ + ath6kl_hif_power_off(ar); + + destroy_workqueue(ar->ath6kl_wq); + + if (ar->htc_target) + ath6kl_htc_cleanup(ar->htc_target); + + ath6kl_cookie_cleanup(ar); + + ath6kl_cleanup_amsdu_rxbufs(ar); + + ath6kl_bmi_cleanup(ar); + + ath6kl_debug_cleanup(ar); + + kfree(ar->fw_board); + kfree(ar->fw_otp); + kfree(ar->fw); + kfree(ar->fw_patch); + kfree(ar->fw_testscript); + + ath6kl_cfg80211_cleanup(ar); +} + +void ath6kl_core_destroy(struct ath6kl *ar) +{ + ath6kl_cfg80211_destroy(ar); +} + diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 78c0402e2d33..67b22e4bbcc2 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -754,11 +754,18 @@ void ath6kl_wakeup_event(void *dev); void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, bool wait_fot_compltn, bool cold_reset); void ath6kl_init_control_info(struct ath6kl_vif *vif); -void ath6kl_core_free(struct ath6kl *ar); struct ath6kl_vif *ath6kl_vif_first(struct ath6kl *ar); void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready); int ath6kl_init_hw_start(struct ath6kl *ar); int ath6kl_init_hw_stop(struct ath6kl *ar); +int ath6kl_init_fetch_firmwares(struct ath6kl *ar); +int ath6kl_init_hw_params(struct ath6kl *ar); + void ath6kl_check_wow_status(struct ath6kl *ar); +struct ath6kl *ath6kl_core_create(struct device *dev); +int ath6kl_core_init(struct ath6kl *ar); +void ath6kl_core_cleanup(struct ath6kl *ar); +void ath6kl_core_destroy(struct ath6kl *ar); + #endif /* CORE_H */ diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 2804921d5d8a..b8252ced0968 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -25,15 +25,9 @@ #include "debug.h" #include "hif-ops.h" -unsigned int debug_mask; static unsigned int testmode; -static bool suspend_cutpower; -static unsigned int uart_debug; -module_param(debug_mask, uint, 0644); module_param(testmode, uint, 0644); -module_param(suspend_cutpower, bool, 0444); -module_param(uart_debug, uint, 0644); static const struct ath6kl_hw hw_list[] = { { @@ -597,37 +591,6 @@ int ath6kl_configure_target(struct ath6kl *ar) return 0; } -void ath6kl_core_free(struct ath6kl *ar) -{ - wiphy_free(ar->wiphy); -} - -void ath6kl_core_cleanup(struct ath6kl *ar) -{ - ath6kl_hif_power_off(ar); - - destroy_workqueue(ar->ath6kl_wq); - - if (ar->htc_target) - ath6kl_htc_cleanup(ar->htc_target); - - ath6kl_cookie_cleanup(ar); - - ath6kl_cleanup_amsdu_rxbufs(ar); - - ath6kl_bmi_cleanup(ar); - - ath6kl_debug_cleanup(ar); - - kfree(ar->fw_board); - kfree(ar->fw_otp); - kfree(ar->fw); - kfree(ar->fw_patch); - kfree(ar->fw_testscript); - - ath6kl_cfg80211_cleanup(ar); -} - /* firmware upload */ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename, u8 **fw, size_t *fw_len) @@ -1065,7 +1028,7 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name) return ret; } -static int ath6kl_fetch_firmwares(struct ath6kl *ar) +int ath6kl_init_fetch_firmwares(struct ath6kl *ar) { int ret; @@ -1485,7 +1448,7 @@ static int ath6kl_init_upload(struct ath6kl *ar) return status; } -static int ath6kl_init_hw_params(struct ath6kl *ar) +int ath6kl_init_hw_params(struct ath6kl *ar) { const struct ath6kl_hw *hw; int i; @@ -1663,178 +1626,6 @@ int ath6kl_init_hw_stop(struct ath6kl *ar) return 0; } -int ath6kl_core_init(struct ath6kl *ar) -{ - struct ath6kl_bmi_target_info targ_info; - struct net_device *ndev; - int ret = 0, i; - - ar->ath6kl_wq = create_singlethread_workqueue("ath6kl"); - if (!ar->ath6kl_wq) - return -ENOMEM; - - ret = ath6kl_bmi_init(ar); - if (ret) - goto err_wq; - - /* - * Turn on power to get hardware (target) version and leave power - * on delibrately as we will boot the hardware anyway within few - * seconds. - */ - ret = ath6kl_hif_power_on(ar); - if (ret) - goto err_bmi_cleanup; - - ret = ath6kl_bmi_get_target_info(ar, &targ_info); - if (ret) - goto err_power_off; - - ar->version.target_ver = le32_to_cpu(targ_info.version); - ar->target_type = le32_to_cpu(targ_info.type); - ar->wiphy->hw_version = le32_to_cpu(targ_info.version); - - ret = ath6kl_init_hw_params(ar); - if (ret) - goto err_power_off; - - ar->htc_target = ath6kl_htc_create(ar); - - if (!ar->htc_target) { - ret = -ENOMEM; - goto err_power_off; - } - - ret = ath6kl_fetch_firmwares(ar); - if (ret) - goto err_htc_cleanup; - - /* FIXME: we should free all firmwares in the error cases below */ - - /* Indicate that WMI is enabled (although not ready yet) */ - set_bit(WMI_ENABLED, &ar->flag); - ar->wmi = ath6kl_wmi_init(ar); - if (!ar->wmi) { - ath6kl_err("failed to initialize wmi\n"); - ret = -EIO; - goto err_htc_cleanup; - } - - ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi); - - ret = ath6kl_cfg80211_init(ar); - if (ret) - goto err_node_cleanup; - - ret = ath6kl_debug_init(ar); - if (ret) { - wiphy_unregister(ar->wiphy); - goto err_node_cleanup; - } - - for (i = 0; i < ar->vif_max; i++) - ar->avail_idx_map |= BIT(i); - - rtnl_lock(); - - /* Add an initial station interface */ - ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, - INFRA_NETWORK); - - rtnl_unlock(); - - if (!ndev) { - ath6kl_err("Failed to instantiate a network device\n"); - ret = -ENOMEM; - wiphy_unregister(ar->wiphy); - goto err_debug_init; - } - - - ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", - __func__, ndev->name, ndev, ar); - - /* setup access class priority mappings */ - ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */ - ar->ac_stream_pri_map[WMM_AC_BE] = 1; - ar->ac_stream_pri_map[WMM_AC_VI] = 2; - ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */ - - /* give our connected endpoints some buffers */ - ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep); - ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]); - - /* allocate some buffers that handle larger AMSDU frames */ - ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS); - - ath6kl_cookie_init(ar); - - ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | - ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; - - if (suspend_cutpower) - ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER; - - if (uart_debug) - ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; - - ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | - WIPHY_FLAG_HAVE_AP_SME | - WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | - WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; - - if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN, ar->fw_capabilities)) - ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; - - ar->wiphy->probe_resp_offload = - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P | - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U; - - set_bit(FIRST_BOOT, &ar->flag); - - ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; - - ret = ath6kl_init_hw_start(ar); - if (ret) { - ath6kl_err("Failed to start hardware: %d\n", ret); - goto err_rxbuf_cleanup; - } - - /* - * Set mac address which is received in ready event - * FIXME: Move to ath6kl_interface_add() - */ - memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); - - return ret; - -err_rxbuf_cleanup: - ath6kl_htc_flush_rx_buf(ar->htc_target); - ath6kl_cleanup_amsdu_rxbufs(ar); - rtnl_lock(); - ath6kl_cfg80211_vif_cleanup(netdev_priv(ndev)); - rtnl_unlock(); - wiphy_unregister(ar->wiphy); -err_debug_init: - ath6kl_debug_cleanup(ar); -err_node_cleanup: - ath6kl_wmi_shutdown(ar->wmi); - clear_bit(WMI_ENABLED, &ar->flag); - ar->wmi = NULL; -err_htc_cleanup: - ath6kl_htc_cleanup(ar->htc_target); -err_power_off: - ath6kl_hif_power_off(ar); -err_bmi_cleanup: - ath6kl_bmi_cleanup(ar); -err_wq: - destroy_workqueue(ar->ath6kl_wq); - - return ret; -} - /* FIXME: move this to cfg80211.c and rename to ath6kl_cfg80211_vif_stop() */ void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) { diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 662b47dc71e5..bef32ecea792 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1261,7 +1261,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]); - ar = ath6kl_core_alloc(&ar_sdio->func->dev); + ar = ath6kl_core_create(&ar_sdio->func->dev); if (!ar) { ath6kl_err("Failed to alloc ath6kl core\n"); ret = -ENOMEM; @@ -1291,7 +1291,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, return ret; err_core_alloc: - ath6kl_core_free(ar_sdio->ar); + ath6kl_core_destroy(ar_sdio->ar); err_dma: kfree(ar_sdio->dma_buffer); err_hif: -- GitLab From 5afa5aa79680ee107fef1195c80f5f67c54b6691 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:09:19 +0200 Subject: [PATCH 0051/1846] ath6kl: get rid of AR_DBG_LVL_CHECK() We don't need it as debug calls already have a log level and compiler should be smart enough to optimise away the code when ath6kl debug code is not enabled. Also it makes it easier to abstract core code to ath6kl_core.ko. In ath6kl_dump_registers() I had to change the debug level from ANY to IRQ as I removed the AR_DBG_LVL_CHECK() check before calling the function. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 35 +++++++++++-------------- drivers/net/wireless/ath/ath6kl/debug.h | 2 -- drivers/net/wireless/ath/ath6kl/hif.c | 5 ++-- drivers/net/wireless/ath/ath6kl/wmi.c | 3 --- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index fa7243b41442..bd2f1fae72a9 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -82,31 +82,31 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, struct ath6kl_irq_enable_reg *irq_enable_reg) { - ath6kl_dbg(ATH6KL_DBG_ANY, ("<------- Register Table -------->\n")); + ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n")); if (irq_proc_reg != NULL) { - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Host Int status: 0x%x\n", irq_proc_reg->host_int_status); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "CPU Int status: 0x%x\n", irq_proc_reg->cpu_int_status); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Error Int status: 0x%x\n", irq_proc_reg->error_int_status); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status: 0x%x\n", irq_proc_reg->counter_int_status); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Mbox Frame: 0x%x\n", irq_proc_reg->mbox_frame); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Rx Lookahead Valid: 0x%x\n", irq_proc_reg->rx_lkahd_valid); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Rx Lookahead 0: 0x%x\n", irq_proc_reg->rx_lkahd[0]); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Rx Lookahead 1: 0x%x\n", irq_proc_reg->rx_lkahd[1]); @@ -115,16 +115,16 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, * If the target supports GMBOX hardware, dump some * additional state. */ - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "GMBOX Host Int status 2: 0x%x\n", irq_proc_reg->host_int_status2); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "GMBOX RX Avail: 0x%x\n", irq_proc_reg->gmbox_rx_avail); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "GMBOX lookahead alias 0: 0x%x\n", irq_proc_reg->rx_gmbox_lkahd_alias[0]); - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "GMBOX lookahead alias 1: 0x%x\n", irq_proc_reg->rx_gmbox_lkahd_alias[1]); } @@ -132,13 +132,13 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, } if (irq_enable_reg != NULL) { - ath6kl_dbg(ATH6KL_DBG_ANY, + ath6kl_dbg(ATH6KL_DBG_IRQ, "Int status Enable: 0x%x\n", irq_enable_reg->int_status_en); - ath6kl_dbg(ATH6KL_DBG_ANY, "Counter Int status Enable: 0x%x\n", + ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status Enable: 0x%x\n", irq_enable_reg->cntr_int_status_en); } - ath6kl_dbg(ATH6KL_DBG_ANY, "<------------------------------->\n"); + ath6kl_dbg(ATH6KL_DBG_IRQ, "<------------------------------->\n"); } static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist) @@ -175,9 +175,6 @@ void dump_cred_dist_stats(struct htc_target *target) { struct htc_endpoint_credit_dist *ep_list; - if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_CREDIT)) - return; - list_for_each_entry(ep_list, &target->cred_dist_list, list) dump_cred_dist(ep_list); diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 9853c9c125c1..9dc39754a35f 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -55,8 +55,6 @@ int ath6kl_printk(const char *level, const char *fmt, ...); #define ath6kl_warn(fmt, ...) \ ath6kl_printk(KERN_WARNING, fmt, ##__VA_ARGS__) -#define AR_DBG_LVL_CHECK(mask) (debug_mask & mask) - enum ath6kl_war { ATH6KL_WAR_INVALID_RATE, }; diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index e57da35e59fa..711886860b5d 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -429,9 +429,8 @@ static int proc_pending_irqs(struct ath6kl_device *dev, bool *done) if (status) goto out; - if (AR_DBG_LVL_CHECK(ATH6KL_DBG_IRQ)) - ath6kl_dump_registers(dev, &dev->irq_proc_reg, - &dev->irq_en_reg); + ath6kl_dump_registers(dev, &dev->irq_proc_reg, + &dev->irq_en_reg); /* Update only those registers that are enabled */ host_int_status = dev->irq_proc_reg.host_int_status & diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index c2420f886ed8..5d678bf372d3 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -426,9 +426,6 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", evt->num_msg, evt->msg_len, evt->msg_type); - if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) - return 0; - for (index = 0; index < evt->num_msg; index++) { size = sizeof(struct wmi_tx_complete_event) + (index * sizeof(struct tx_complete_msg_v1)); -- GitLab From 3b1b7d0985fdb26403678e49938a668ef7f772ea Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:09:27 +0200 Subject: [PATCH 0052/1846] ath6kl: convert ath6kl_dbg() and ath6kl_dbg_dump() into functions That way it's possible to not export debug_mask outside the upcoming ath6kl_core.ko and that makes it easier to ath6kl_core.ko in the following patch. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 30 +++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/debug.h | 25 ++++----------------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index bd2f1fae72a9..4ba6560f0bf3 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -57,6 +57,36 @@ int ath6kl_printk(const char *level, const char *fmt, ...) #ifdef CONFIG_ATH6KL_DEBUG +void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + if (!(debug_mask & mask)) + return; + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + ath6kl_printk(KERN_DEBUG, "%pV", &vaf); + + va_end(args); +} + +void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, + const char *msg, const char *prefix, + const void *buf, size_t len) +{ + if (debug_mask & mask) { + if (msg) + ath6kl_dbg(mask, "%s\n", msg); + + print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len); + } +} + #define REG_OUTPUT_LEN_PER_LINE 25 #define REGTYPE_STR_LEN 100 diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 9dc39754a35f..872a8ce5d8f3 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -60,28 +60,11 @@ enum ath6kl_war { }; #ifdef CONFIG_ATH6KL_DEBUG -#define ath6kl_dbg(mask, fmt, ...) \ - ({ \ - int rtn; \ - if (debug_mask & mask) \ - rtn = ath6kl_printk(KERN_DEBUG, fmt, ##__VA_ARGS__); \ - else \ - rtn = 0; \ - \ - rtn; \ - }) -static inline void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, - const char *msg, const char *prefix, - const void *buf, size_t len) -{ - if (debug_mask & mask) { - if (msg) - ath6kl_dbg(mask, "%s\n", msg); - - print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len); - } -} +void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...); +void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, + const char *msg, const char *prefix, + const void *buf, size_t len); void ath6kl_dump_registers(struct ath6kl_device *dev, struct ath6kl_irq_proc_registers *irq_proc_reg, -- GitLab From d6a434d60e064a5f2bef1c13ca5ed84bfa6b8b4f Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:09:36 +0200 Subject: [PATCH 0053/1846] ath6kl: create ath6kl_core.ko Now ath6kl is ready for splitting core code to ath6kl_core.ko module. This also makes it possible to link both sdio and usb code to kernel at the same time, which earlier failed miserably. Reported-by: Stephen Rothwell Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/Makefile | 28 ++++++++++++---------- drivers/net/wireless/ath/ath6kl/cfg80211.c | 3 +++ drivers/net/wireless/ath/ath6kl/core.c | 9 +++++++ drivers/net/wireless/ath/ath6kl/debug.c | 3 +++ drivers/net/wireless/ath/ath6kl/hif.c | 5 ++++ drivers/net/wireless/ath/ath6kl/init.c | 3 +++ 6 files changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index 854694b26a4b..cbdc31c603f6 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -21,16 +21,18 @@ # Author(s): ="Atheros" #------------------------------------------------------------------------------ -obj-$(CONFIG_ATH6KL) := ath6kl.o -ath6kl-y += debug.o -ath6kl-y += hif.o -ath6kl-y += htc.o -ath6kl-y += bmi.o -ath6kl-y += cfg80211.o -ath6kl-y += init.o -ath6kl-y += main.o -ath6kl-y += txrx.o -ath6kl-y += wmi.o -ath6kl-y += core.o -ath6kl-y += sdio.o -ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o +obj-$(CONFIG_ATH6KL) += ath6kl_core.o +ath6kl_core-y += debug.o +ath6kl_core-y += hif.o +ath6kl_core-y += htc.o +ath6kl_core-y += bmi.o +ath6kl_core-y += cfg80211.o +ath6kl_core-y += init.o +ath6kl_core-y += main.o +ath6kl_core-y += txrx.o +ath6kl_core-y += wmi.o +ath6kl_core-y += core.o +ath6kl_core-$(CONFIG_NL80211_TESTMODE) += testmode.o + +obj-$(CONFIG_ATH6KL_SDIO) += ath6kl_sdio.o +ath6kl_sdio-y += sdio.o diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 7ff9806de50b..594d246da8e1 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -16,6 +16,7 @@ #include #include +#include #include "core.h" #include "cfg80211.h" @@ -1935,6 +1936,7 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, return 0; } +EXPORT_SYMBOL(ath6kl_cfg80211_suspend); int ath6kl_cfg80211_resume(struct ath6kl *ar) { @@ -1986,6 +1988,7 @@ int ath6kl_cfg80211_resume(struct ath6kl *ar) return 0; } +EXPORT_SYMBOL(ath6kl_cfg80211_resume); #ifdef CONFIG_PM diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 40fad5ec9366..d764afec395b 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -16,7 +16,9 @@ #include "core.h" +#include #include +#include #include "debug.h" #include "hif-ops.h" @@ -203,6 +205,7 @@ int ath6kl_core_init(struct ath6kl *ar) return ret; } +EXPORT_SYMBOL(ath6kl_core_init); struct ath6kl *ath6kl_core_create(struct device *dev) { @@ -258,6 +261,7 @@ struct ath6kl *ath6kl_core_create(struct device *dev) return ar; } +EXPORT_SYMBOL(ath6kl_core_create); void ath6kl_core_cleanup(struct ath6kl *ar) { @@ -284,9 +288,14 @@ void ath6kl_core_cleanup(struct ath6kl *ar) ath6kl_cfg80211_cleanup(ar); } +EXPORT_SYMBOL(ath6kl_core_cleanup); void ath6kl_core_destroy(struct ath6kl *ar) { ath6kl_cfg80211_destroy(ar); } +EXPORT_SYMBOL(ath6kl_core_destroy); +MODULE_AUTHOR("Qualcomm Atheros"); +MODULE_DESCRIPTION("Core module for AR600x SDIO and USB devices."); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 4ba6560f0bf3..6b546dc66728 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -54,6 +54,7 @@ int ath6kl_printk(const char *level, const char *fmt, ...) return rtn; } +EXPORT_SYMBOL(ath6kl_printk); #ifdef CONFIG_ATH6KL_DEBUG @@ -74,6 +75,7 @@ void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...) va_end(args); } +EXPORT_SYMBOL(ath6kl_dbg); void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, const char *msg, const char *prefix, @@ -86,6 +88,7 @@ void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len); } } +EXPORT_SYMBOL(ath6kl_dbg_dump); #define REG_OUTPUT_LEN_PER_LINE 25 #define REGTYPE_STR_LEN 100 diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 711886860b5d..d912da6ab0d1 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -15,6 +15,8 @@ */ #include "hif.h" +#include + #include "core.h" #include "target.h" #include "hif-ops.h" @@ -59,6 +61,8 @@ int ath6kl_hif_rw_comp_handler(void *context, int status) return 0; } +EXPORT_SYMBOL(ath6kl_hif_rw_comp_handler); + #define REG_DUMP_COUNT_AR6003 60 #define REGISTER_DUMP_LEN_MAX 60 @@ -560,6 +564,7 @@ int ath6kl_hif_intr_bh_handler(struct ath6kl *ar) return status; } +EXPORT_SYMBOL(ath6kl_hif_intr_bh_handler); static int ath6kl_hif_enable_intrs(struct ath6kl_device *dev) { diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index b8252ced0968..167dc41af2de 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -17,8 +17,10 @@ #include #include +#include #include #include + #include "core.h" #include "cfg80211.h" #include "target.h" @@ -1707,3 +1709,4 @@ void ath6kl_stop_txrx(struct ath6kl *ar) clear_bit(WLAN_ENABLED, &ar->flag); } +EXPORT_SYMBOL(ath6kl_stop_txrx); -- GitLab From 241b128b6b69ad41fc6f12cba45a3c3e64bce673 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 17 Jan 2012 20:09:45 +0200 Subject: [PATCH 0054/1846] ath6kl: add back beginnings of USB support John Linville had to revert the part of USB support which was already in ath6kl due to build problems in commit cb00ec382b ("ath6kl: revert USB support"). Now that I fixed the build problems properly by adding ath6kl_core.ko kernel module it's possible to add back the (incomplete) USB support. This patch is a revert of John's patch and adds back the USB code which as already in ath6kl, only difference being minor changes in Makefile and adapting usb.c to new core function names. Note that USB support in ath6kl is not complete yet. This code only makes it possible to boot firmware but as HTC layer does not yet support USB it's not possible to send any WMI commands nor data packets to the firmware. That will be added soon. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/Kconfig | 25 +- drivers/net/wireless/ath/ath6kl/Makefile | 3 + drivers/net/wireless/ath/ath6kl/bmi.c | 10 +- drivers/net/wireless/ath/ath6kl/debug.h | 1 + drivers/net/wireless/ath/ath6kl/hif.c | 5 + drivers/net/wireless/ath/ath6kl/htc.c | 10 +- drivers/net/wireless/ath/ath6kl/sdio.c | 2 +- drivers/net/wireless/ath/ath6kl/usb.c | 431 +++++++++++++++++++++++ 8 files changed, 479 insertions(+), 8 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/usb.c diff --git a/drivers/net/wireless/ath/ath6kl/Kconfig b/drivers/net/wireless/ath/ath6kl/Kconfig index 3d5f8be20eac..d755a5e7ed20 100644 --- a/drivers/net/wireless/ath/ath6kl/Kconfig +++ b/drivers/net/wireless/ath/ath6kl/Kconfig @@ -1,12 +1,29 @@ config ATH6KL - tristate "Atheros ath6kl support" + tristate "Atheros mobile chipsets support" + +config ATH6KL_SDIO + tristate "Atheros ath6kl SDIO support" + depends on ATH6KL depends on MMC depends on CFG80211 ---help--- This module adds support for wireless adapters based on - Atheros AR6003 chipset running over SDIO. If you choose to - build it as a module, it will be called ath6kl. Pls note - that AR6002 and AR6001 are not supported by this driver. + Atheros AR6003 and AR6004 chipsets running over SDIO. If you + choose to build it as a module, it will be called ath6kl_sdio. + Please note that AR6002 and AR6001 are not supported by this + driver. + +config ATH6KL_USB + tristate "Atheros ath6kl USB support" + depends on ATH6KL + depends on USB + depends on CFG80211 + depends on EXPERIMENTAL + ---help--- + This module adds support for wireless adapters based on + Atheros AR6004 chipset running over USB. This is still under + implementation and it isn't functional. If you choose to + build it as a module, it will be called ath6kl_usb. config ATH6KL_DEBUG bool "Atheros ath6kl debugging" diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index cbdc31c603f6..9ba42fa04962 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -36,3 +36,6 @@ ath6kl_core-$(CONFIG_NL80211_TESTMODE) += testmode.o obj-$(CONFIG_ATH6KL_SDIO) += ath6kl_sdio.o ath6kl_sdio-y += sdio.o + +obj-$(CONFIG_ATH6KL_USB) += ath6kl_usb.o +ath6kl_usb-y += usb.o diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index bce3575c310a..aef00d5a1438 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -57,8 +57,14 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, return ret; } - ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->version, - sizeof(targ_info->version)); + if (ar->hif_type == ATH6KL_HIF_TYPE_USB) { + ret = ath6kl_hif_bmi_read(ar, (u8 *)targ_info, + sizeof(*targ_info)); + } else { + ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->version, + sizeof(targ_info->version)); + } + if (ret) { ath6kl_err("Unable to recv target info: %d\n", ret); return ret; diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 872a8ce5d8f3..c4be6e50996b 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -41,6 +41,7 @@ enum ATH6K_DEBUG_MASK { ATH6KL_DBG_BOOT = BIT(18), /* driver init and fw boot */ ATH6KL_DBG_WMI_DUMP = BIT(19), ATH6KL_DBG_SUSPEND = BIT(20), + ATH6KL_DBG_USB = BIT(21), ATH6KL_DBG_ANY = 0xffffffff /* enable all logs */ }; diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index d912da6ab0d1..e911737ab345 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -693,6 +693,11 @@ int ath6kl_hif_setup(struct ath6kl_device *dev) ath6kl_dbg(ATH6KL_DBG_HIF, "hif block size %d mbox addr 0x%x\n", dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr); + /* usb doesn't support enabling interrupts */ + /* FIXME: remove check once USB support is implemented */ + if (dev->ar->hif_type == ATH6KL_HIF_TYPE_USB) + return 0; + status = ath6kl_hif_disable_intrs(dev); fail_setup: diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 073ddff31344..2d721903640b 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2544,6 +2544,12 @@ int ath6kl_htc_wait_target(struct htc_target *target) struct htc_service_connect_resp resp; int status; + /* FIXME: remove once USB support is implemented */ + if (target->dev->ar->hif_type == ATH6KL_HIF_TYPE_USB) { + ath6kl_err("HTC doesn't support USB yet. Patience!\n"); + return -EOPNOTSUPP; + } + /* we should be getting 1 control message that the target is ready */ packet = htc_wait_for_ctrl_msg(target); @@ -2773,7 +2779,9 @@ void ath6kl_htc_cleanup(struct htc_target *target) { struct htc_packet *packet, *tmp_packet; - ath6kl_hif_cleanup_scatter(target->dev->ar); + /* FIXME: remove check once USB support is implemented */ + if (target->dev->ar->hif_type != ATH6KL_HIF_TYPE_USB) + ath6kl_hif_cleanup_scatter(target->dev->ar); list_for_each_entry_safe(packet, tmp_packet, &target->free_ctrl_txbuf, list) { diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index bef32ecea792..7bb61077c406 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1330,7 +1330,7 @@ static const struct sdio_device_id ath6kl_sdio_devices[] = { MODULE_DEVICE_TABLE(sdio, ath6kl_sdio_devices); static struct sdio_driver ath6kl_sdio_driver = { - .name = "ath6kl", + .name = "ath6kl_sdio", .id_table = ath6kl_sdio_devices, .probe = ath6kl_sdio_probe, .remove = ath6kl_sdio_remove, diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c new file mode 100644 index 000000000000..c72567c6d338 --- /dev/null +++ b/drivers/net/wireless/ath/ath6kl/usb.c @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2007-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 + +#include "debug.h" +#include "core.h" + +/* usb device object */ +struct ath6kl_usb { + struct usb_device *udev; + struct usb_interface *interface; + u8 *diag_cmd_buffer; + u8 *diag_resp_buffer; + struct ath6kl *ar; +}; + +/* diagnostic command defnitions */ +#define ATH6KL_USB_CONTROL_REQ_SEND_BMI_CMD 1 +#define ATH6KL_USB_CONTROL_REQ_RECV_BMI_RESP 2 +#define ATH6KL_USB_CONTROL_REQ_DIAG_CMD 3 +#define ATH6KL_USB_CONTROL_REQ_DIAG_RESP 4 + +#define ATH6KL_USB_CTRL_DIAG_CC_READ 0 +#define ATH6KL_USB_CTRL_DIAG_CC_WRITE 1 + +struct ath6kl_usb_ctrl_diag_cmd_write { + __le32 cmd; + __le32 address; + __le32 value; + __le32 _pad[1]; +} __packed; + +struct ath6kl_usb_ctrl_diag_cmd_read { + __le32 cmd; + __le32 address; +} __packed; + +struct ath6kl_usb_ctrl_diag_resp_read { + __le32 value; +} __packed; + +#define ATH6KL_USB_MAX_DIAG_CMD (sizeof(struct ath6kl_usb_ctrl_diag_cmd_write)) +#define ATH6KL_USB_MAX_DIAG_RESP (sizeof(struct ath6kl_usb_ctrl_diag_resp_read)) + +static void ath6kl_usb_destroy(struct ath6kl_usb *ar_usb) +{ + usb_set_intfdata(ar_usb->interface, NULL); + + kfree(ar_usb->diag_cmd_buffer); + kfree(ar_usb->diag_resp_buffer); + + kfree(ar_usb); +} + +static struct ath6kl_usb *ath6kl_usb_create(struct usb_interface *interface) +{ + struct ath6kl_usb *ar_usb = NULL; + struct usb_device *dev = interface_to_usbdev(interface); + int status = 0; + + ar_usb = kzalloc(sizeof(struct ath6kl_usb), GFP_KERNEL); + if (ar_usb == NULL) + goto fail_ath6kl_usb_create; + + memset(ar_usb, 0, sizeof(struct ath6kl_usb)); + usb_set_intfdata(interface, ar_usb); + ar_usb->udev = dev; + ar_usb->interface = interface; + + ar_usb->diag_cmd_buffer = kzalloc(ATH6KL_USB_MAX_DIAG_CMD, GFP_KERNEL); + if (ar_usb->diag_cmd_buffer == NULL) { + status = -ENOMEM; + goto fail_ath6kl_usb_create; + } + + ar_usb->diag_resp_buffer = kzalloc(ATH6KL_USB_MAX_DIAG_RESP, + GFP_KERNEL); + if (ar_usb->diag_resp_buffer == NULL) { + status = -ENOMEM; + goto fail_ath6kl_usb_create; + } + +fail_ath6kl_usb_create: + if (status != 0) { + ath6kl_usb_destroy(ar_usb); + ar_usb = NULL; + } + return ar_usb; +} + +static void ath6kl_usb_device_detached(struct usb_interface *interface) +{ + struct ath6kl_usb *ar_usb; + + ar_usb = usb_get_intfdata(interface); + if (ar_usb == NULL) + return; + + ath6kl_stop_txrx(ar_usb->ar); + + ath6kl_core_cleanup(ar_usb->ar); + + ath6kl_usb_destroy(ar_usb); +} + +static int ath6kl_usb_submit_ctrl_out(struct ath6kl_usb *ar_usb, + u8 req, u16 value, u16 index, void *data, + u32 size) +{ + u8 *buf = NULL; + int ret; + + if (size > 0) { + buf = kmalloc(size, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + memcpy(buf, data, size); + } + + /* note: if successful returns number of bytes transfered */ + ret = usb_control_msg(ar_usb->udev, + usb_sndctrlpipe(ar_usb->udev, 0), + req, + USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, buf, + size, 1000); + + if (ret < 0) { + ath6kl_dbg(ATH6KL_DBG_USB, "%s failed,result = %d\n", + __func__, ret); + } + + kfree(buf); + + return 0; +} + +static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb, + u8 req, u16 value, u16 index, void *data, + u32 size) +{ + u8 *buf = NULL; + int ret; + + if (size > 0) { + buf = kmalloc(size, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + } + + /* note: if successful returns number of bytes transfered */ + ret = usb_control_msg(ar_usb->udev, + usb_rcvctrlpipe(ar_usb->udev, 0), + req, + USB_DIR_IN | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, buf, + size, 2 * HZ); + + if (ret < 0) { + ath6kl_dbg(ATH6KL_DBG_USB, "%s failed,result = %d\n", + __func__, ret); + } + + memcpy((u8 *) data, buf, size); + + kfree(buf); + + return 0; +} + +static int ath6kl_usb_ctrl_msg_exchange(struct ath6kl_usb *ar_usb, + u8 req_val, u8 *req_buf, u32 req_len, + u8 resp_val, u8 *resp_buf, u32 *resp_len) +{ + int ret; + + /* send command */ + ret = ath6kl_usb_submit_ctrl_out(ar_usb, req_val, 0, 0, + req_buf, req_len); + + if (ret != 0) + return ret; + + if (resp_buf == NULL) { + /* no expected response */ + return ret; + } + + /* get response */ + ret = ath6kl_usb_submit_ctrl_in(ar_usb, resp_val, 0, 0, + resp_buf, *resp_len); + + return ret; +} + +static int ath6kl_usb_diag_read32(struct ath6kl *ar, u32 address, u32 *data) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + struct ath6kl_usb_ctrl_diag_resp_read *resp; + struct ath6kl_usb_ctrl_diag_cmd_read *cmd; + u32 resp_len; + int ret; + + cmd = (struct ath6kl_usb_ctrl_diag_cmd_read *) ar_usb->diag_cmd_buffer; + + memset(cmd, 0, sizeof(*cmd)); + cmd->cmd = ATH6KL_USB_CTRL_DIAG_CC_READ; + cmd->address = cpu_to_le32(address); + resp_len = sizeof(*resp); + + ret = ath6kl_usb_ctrl_msg_exchange(ar_usb, + ATH6KL_USB_CONTROL_REQ_DIAG_CMD, + (u8 *) cmd, + sizeof(struct ath6kl_usb_ctrl_diag_cmd_write), + ATH6KL_USB_CONTROL_REQ_DIAG_RESP, + ar_usb->diag_resp_buffer, &resp_len); + + if (ret) + return ret; + + resp = (struct ath6kl_usb_ctrl_diag_resp_read *) + ar_usb->diag_resp_buffer; + + *data = le32_to_cpu(resp->value); + + return ret; +} + +static int ath6kl_usb_diag_write32(struct ath6kl *ar, u32 address, __le32 data) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + struct ath6kl_usb_ctrl_diag_cmd_write *cmd; + + cmd = (struct ath6kl_usb_ctrl_diag_cmd_write *) ar_usb->diag_cmd_buffer; + + memset(cmd, 0, sizeof(struct ath6kl_usb_ctrl_diag_cmd_write)); + cmd->cmd = cpu_to_le32(ATH6KL_USB_CTRL_DIAG_CC_WRITE); + cmd->address = cpu_to_le32(address); + cmd->value = data; + + return ath6kl_usb_ctrl_msg_exchange(ar_usb, + ATH6KL_USB_CONTROL_REQ_DIAG_CMD, + (u8 *) cmd, + sizeof(*cmd), + 0, NULL, NULL); + +} + +static int ath6kl_usb_bmi_read(struct ath6kl *ar, u8 *buf, u32 len) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + int ret; + + /* get response */ + ret = ath6kl_usb_submit_ctrl_in(ar_usb, + ATH6KL_USB_CONTROL_REQ_RECV_BMI_RESP, + 0, 0, buf, len); + if (ret != 0) { + ath6kl_err("Unable to read the bmi data from the device: %d\n", + ret); + return ret; + } + + return 0; +} + +static int ath6kl_usb_bmi_write(struct ath6kl *ar, u8 *buf, u32 len) +{ + struct ath6kl_usb *ar_usb = ar->hif_priv; + int ret; + + /* send command */ + ret = ath6kl_usb_submit_ctrl_out(ar_usb, + ATH6KL_USB_CONTROL_REQ_SEND_BMI_CMD, + 0, 0, buf, len); + if (ret != 0) { + ath6kl_err("unable to send the bmi data to the device: %d\n", + ret); + return ret; + } + + return 0; +} + +static int ath6kl_usb_power_on(struct ath6kl *ar) +{ + return 0; +} + +static int ath6kl_usb_power_off(struct ath6kl *ar) +{ + return 0; +} + +static const struct ath6kl_hif_ops ath6kl_usb_ops = { + .diag_read32 = ath6kl_usb_diag_read32, + .diag_write32 = ath6kl_usb_diag_write32, + .bmi_read = ath6kl_usb_bmi_read, + .bmi_write = ath6kl_usb_bmi_write, + .power_on = ath6kl_usb_power_on, + .power_off = ath6kl_usb_power_off, +}; + +/* ath6kl usb driver registered functions */ +static int ath6kl_usb_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_device *dev = interface_to_usbdev(interface); + struct ath6kl *ar; + struct ath6kl_usb *ar_usb = NULL; + int vendor_id, product_id; + int ret = 0; + + usb_get_dev(dev); + + vendor_id = le16_to_cpu(dev->descriptor.idVendor); + product_id = le16_to_cpu(dev->descriptor.idProduct); + + ath6kl_dbg(ATH6KL_DBG_USB, "vendor_id = %04x\n", vendor_id); + ath6kl_dbg(ATH6KL_DBG_USB, "product_id = %04x\n", product_id); + + if (interface->cur_altsetting) + ath6kl_dbg(ATH6KL_DBG_USB, "USB Interface %d\n", + interface->cur_altsetting->desc.bInterfaceNumber); + + + if (dev->speed == USB_SPEED_HIGH) + ath6kl_dbg(ATH6KL_DBG_USB, "USB 2.0 Host\n"); + else + ath6kl_dbg(ATH6KL_DBG_USB, "USB 1.1 Host\n"); + + ar_usb = ath6kl_usb_create(interface); + + if (ar_usb == NULL) { + ret = -ENOMEM; + goto err_usb_put; + } + + ar = ath6kl_core_create(&ar_usb->udev->dev); + if (ar == NULL) { + ath6kl_err("Failed to alloc ath6kl core\n"); + ret = -ENOMEM; + goto err_usb_destroy; + } + + ar->hif_priv = ar_usb; + ar->hif_type = ATH6KL_HIF_TYPE_USB; + ar->hif_ops = &ath6kl_usb_ops; + ar->mbox_info.block_size = 16; + ar->bmi.max_data_size = 252; + + ar_usb->ar = ar; + + ret = ath6kl_core_init(ar); + if (ret) { + ath6kl_err("Failed to init ath6kl core: %d\n", ret); + goto err_core_free; + } + + return ret; + +err_core_free: + ath6kl_core_destroy(ar); +err_usb_destroy: + ath6kl_usb_destroy(ar_usb); +err_usb_put: + usb_put_dev(dev); + + return ret; +} + +static void ath6kl_usb_remove(struct usb_interface *interface) +{ + usb_put_dev(interface_to_usbdev(interface)); + ath6kl_usb_device_detached(interface); +} + +/* table of devices that work with this driver */ +static struct usb_device_id ath6kl_usb_ids[] = { + {USB_DEVICE(0x0cf3, 0x9374)}, + { /* Terminating entry */ }, +}; + +MODULE_DEVICE_TABLE(usb, ath6kl_usb_ids); + +static struct usb_driver ath6kl_usb_driver = { + .name = "ath6kl_usb", + .probe = ath6kl_usb_probe, + .disconnect = ath6kl_usb_remove, + .id_table = ath6kl_usb_ids, +}; + +static int ath6kl_usb_init(void) +{ + usb_register(&ath6kl_usb_driver); + return 0; +} + +static void ath6kl_usb_exit(void) +{ + usb_deregister(&ath6kl_usb_driver); +} + +module_init(ath6kl_usb_init); +module_exit(ath6kl_usb_exit); + +MODULE_AUTHOR("Atheros Communications, Inc."); +MODULE_DESCRIPTION("Driver support for Atheros AR600x USB devices"); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_FIRMWARE(AR6004_HW_1_0_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE); +MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE); +MODULE_FIRMWARE(AR6004_HW_1_1_FIRMWARE_FILE); +MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE); +MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE); -- GitLab From 7a950ea81de6cbf96e721599bfacdb409908cd00 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 21 Jan 2012 15:22:48 +0530 Subject: [PATCH 0055/1846] ath6kl: Make sure to delete rx aggregation timer in aggr_reset_state() The timer which is used to flush rx aggregation frames needs to be disabled when resetting the aggregation state. This is found in code review. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/txrx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index dd6337142603..cb7421a31619 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1685,6 +1685,11 @@ void aggr_reset_state(struct aggr_info *aggr_info) { u8 tid; + if (aggr_info->timer_scheduled) { + del_timer(&aggr_info->timer); + aggr_info->timer_scheduled = false; + } + for (tid = 0; tid < NUM_OF_TIDS; tid++) aggr_delete_tid_state(aggr_info, tid); } -- GitLab From 0e7de662bcf33567cc957995c38dc10959cc22bf Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 21 Jan 2012 15:22:49 +0530 Subject: [PATCH 0056/1846] ath6kl: Fix memory leak when unloading ath6kl_sdio The patch "ath6kl: create core.c" removes wiphy_free() from ath6kl_cfg80211_cleanup() and misses to free wiphy in ath6kl_sdio_remove(). This patch fixes this regression. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 7bb61077c406..d9f55914b893 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1314,6 +1314,7 @@ static void ath6kl_sdio_remove(struct sdio_func *func) cancel_work_sync(&ar_sdio->wr_async_work); ath6kl_core_cleanup(ar_sdio->ar); + ath6kl_core_destroy(ar_sdio->ar); kfree(ar_sdio->dma_buffer); kfree(ar_sdio); -- GitLab From 7baef812eb5f02ccacf6fac3888c1cfa36293e91 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 21 Jan 2012 15:22:50 +0530 Subject: [PATCH 0057/1846] ath6kl: Define a structure for connection specific aggregation information This patch just groups connection specific aggregation information from struct aggr_info into a new structure (struct aggr_info_conn) so that, in softAP mode, this can be used when each connected station is made to have it's own aggregation state. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 +- drivers/net/wireless/ath/ath6kl/core.h | 11 +- drivers/net/wireless/ath/ath6kl/txrx.c | 166 +++++++++++---------- 3 files changed, 98 insertions(+), 81 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 594d246da8e1..8bf447a6a84e 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2694,7 +2694,7 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar) static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif) { - vif->aggr_cntxt = aggr_init(vif->ndev); + vif->aggr_cntxt = aggr_init(vif); if (!vif->aggr_cntxt) { ath6kl_err("failed to initialize aggr\n"); return -ENOMEM; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 67b22e4bbcc2..1b9054f8f4e4 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -242,14 +242,19 @@ struct rxtid_stats { u32 num_bar; }; -struct aggr_info { +struct aggr_info_conn { u8 aggr_sz; u8 timer_scheduled; struct timer_list timer; struct net_device *dev; struct rxtid rx_tid[NUM_OF_TIDS]; - struct sk_buff_head free_q; struct rxtid_stats stat[NUM_OF_TIDS]; + struct aggr_info *aggr_info; +}; + +struct aggr_info { + struct aggr_info_conn *aggr_conn; + struct sk_buff_head rx_amsdu_freeq; }; struct ath6kl_wep_key { @@ -707,7 +712,7 @@ struct ath6kl_cookie *ath6kl_alloc_cookie(struct ath6kl *ar); void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie); int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev); -struct aggr_info *aggr_init(struct net_device *dev); +struct aggr_info *aggr_init(struct ath6kl_vif *vif); void ath6kl_rx_refill(struct htc_target *target, enum htc_endpoint_id endpoint); void ath6kl_refill_amsdu_rxbufs(struct ath6kl *ar, int count); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index cb7421a31619..8407d0103dcd 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -819,10 +819,12 @@ static struct sk_buff *aggr_get_free_skb(struct aggr_info *p_aggr) { struct sk_buff *skb = NULL; - if (skb_queue_len(&p_aggr->free_q) < (AGGR_NUM_OF_FREE_NETBUFS >> 2)) - ath6kl_alloc_netbufs(&p_aggr->free_q, AGGR_NUM_OF_FREE_NETBUFS); + if (skb_queue_len(&p_aggr->rx_amsdu_freeq) < + (AGGR_NUM_OF_FREE_NETBUFS >> 2)) + ath6kl_alloc_netbufs(&p_aggr->rx_amsdu_freeq, + AGGR_NUM_OF_FREE_NETBUFS); - skb = skb_dequeue(&p_aggr->free_q); + skb = skb_dequeue(&p_aggr->rx_amsdu_freeq); return skb; } @@ -998,12 +1000,14 @@ static void aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, struct skb_hold_q *node; u16 idx, idx_end, seq_end; struct rxtid_stats *stats; + struct aggr_info_conn *agg_conn; - if (!p_aggr) + if (!p_aggr || !p_aggr->aggr_conn) return; - rxtid = &p_aggr->rx_tid[tid]; - stats = &p_aggr->stat[tid]; + agg_conn = p_aggr->aggr_conn; + rxtid = &agg_conn->rx_tid[tid]; + stats = &agg_conn->stat[tid]; idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz); @@ -1048,7 +1052,7 @@ static void aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, stats->num_delivered += skb_queue_len(&rxtid->q); while ((skb = skb_dequeue(&rxtid->q))) - ath6kl_deliver_frames_to_nw_stack(p_aggr->dev, skb); + ath6kl_deliver_frames_to_nw_stack(agg_conn->dev, skb); } static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, @@ -1062,9 +1066,10 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, u16 idx, st, cur, end; bool is_queued = false; u16 extended_end; + struct aggr_info_conn *agg_conn = agg_info->aggr_conn; - rxtid = &agg_info->rx_tid[tid]; - stats = &agg_info->stat[tid]; + rxtid = &agg_conn->rx_tid[tid]; + stats = &agg_conn->stat[tid]; stats->num_into_aggr++; @@ -1074,7 +1079,7 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, is_queued = true; stats->num_amsdu++; while ((skb = skb_dequeue(&rxtid->q))) - ath6kl_deliver_frames_to_nw_stack(agg_info->dev, + ath6kl_deliver_frames_to_nw_stack(agg_conn->dev, skb); } return is_queued; @@ -1152,7 +1157,7 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, aggr_deque_frms(agg_info, tid, 0, 1); - if (agg_info->timer_scheduled) + if (agg_conn->timer_scheduled) rxtid->progress = true; else for (idx = 0 ; idx < rxtid->hold_q_sz; idx++) { @@ -1163,8 +1168,8 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, * the frame doesn't remain stuck * forever. */ - agg_info->timer_scheduled = true; - mod_timer(&agg_info->timer, + agg_conn->timer_scheduled = true; + mod_timer(&agg_conn->timer, (jiffies + HZ * (AGGR_RX_TIMEOUT) / 1000)); rxtid->progress = false; @@ -1525,13 +1530,13 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) static void aggr_timeout(unsigned long arg) { u8 i, j; - struct aggr_info *p_aggr = (struct aggr_info *) arg; + struct aggr_info_conn *aggr_conn = (struct aggr_info_conn *) arg; struct rxtid *rxtid; struct rxtid_stats *stats; for (i = 0; i < NUM_OF_TIDS; i++) { - rxtid = &p_aggr->rx_tid[i]; - stats = &p_aggr->stat[i]; + rxtid = &aggr_conn->rx_tid[i]; + stats = &aggr_conn->stat[i]; if (!rxtid->aggr || !rxtid->timer_mon || rxtid->progress) continue; @@ -1542,18 +1547,18 @@ static void aggr_timeout(unsigned long arg) rxtid->seq_next, ((rxtid->seq_next + rxtid->hold_q_sz-1) & ATH6KL_MAX_SEQ_NO)); - aggr_deque_frms(p_aggr, i, 0, 0); + aggr_deque_frms(aggr_conn->aggr_info, i, 0, 0); } - p_aggr->timer_scheduled = false; + aggr_conn->timer_scheduled = false; for (i = 0; i < NUM_OF_TIDS; i++) { - rxtid = &p_aggr->rx_tid[i]; + rxtid = &aggr_conn->rx_tid[i]; if (rxtid->aggr && rxtid->hold_q) { for (j = 0; j < rxtid->hold_q_sz; j++) { if (rxtid->hold_q[j].skb) { - p_aggr->timer_scheduled = true; + aggr_conn->timer_scheduled = true; rxtid->timer_mon = true; rxtid->progress = false; break; @@ -1565,24 +1570,24 @@ static void aggr_timeout(unsigned long arg) } } - if (p_aggr->timer_scheduled) - mod_timer(&p_aggr->timer, + if (aggr_conn->timer_scheduled) + mod_timer(&aggr_conn->timer, jiffies + msecs_to_jiffies(AGGR_RX_TIMEOUT)); } -static void aggr_delete_tid_state(struct aggr_info *p_aggr, u8 tid) +static void aggr_delete_tid_state(struct aggr_info_conn *aggr_conn, u8 tid) { struct rxtid *rxtid; struct rxtid_stats *stats; - if (!p_aggr || tid >= NUM_OF_TIDS) + if (!aggr_conn || tid >= NUM_OF_TIDS) return; - rxtid = &p_aggr->rx_tid[tid]; - stats = &p_aggr->stat[tid]; + rxtid = &aggr_conn->rx_tid[tid]; + stats = &aggr_conn->stat[tid]; if (rxtid->aggr) - aggr_deque_frms(p_aggr, tid, 0, 0); + aggr_deque_frms(aggr_conn->aggr_info, tid, 0, 0); rxtid->aggr = false; rxtid->progress = false; @@ -1601,22 +1606,25 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, u8 win_sz) { struct aggr_info *p_aggr = vif->aggr_cntxt; + struct aggr_info_conn *aggr_conn; struct rxtid *rxtid; struct rxtid_stats *stats; u16 hold_q_size; - if (!p_aggr) + if (!p_aggr || !p_aggr->aggr_conn) return; - rxtid = &p_aggr->rx_tid[tid]; - stats = &p_aggr->stat[tid]; + aggr_conn = p_aggr->aggr_conn; + + rxtid = &aggr_conn->rx_tid[tid]; + stats = &aggr_conn->stat[tid]; if (win_sz < AGGR_WIN_SZ_MIN || win_sz > AGGR_WIN_SZ_MAX) ath6kl_dbg(ATH6KL_DBG_WLAN_RX, "%s: win_sz %d, tid %d\n", __func__, win_sz, tid); if (rxtid->aggr) - aggr_delete_tid_state(p_aggr, tid); + aggr_delete_tid_state(aggr_conn, tid); rxtid->seq_next = seq_no; hold_q_size = TID_WINDOW_SZ(win_sz) * sizeof(struct skb_hold_q); @@ -1632,31 +1640,23 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, rxtid->aggr = true; } -struct aggr_info *aggr_init(struct net_device *dev) +static void aggr_conn_init(struct ath6kl_vif *vif, + struct aggr_info_conn *aggr_conn) { - struct aggr_info *p_aggr = NULL; struct rxtid *rxtid; u8 i; - p_aggr = kzalloc(sizeof(struct aggr_info), GFP_KERNEL); - if (!p_aggr) { - ath6kl_err("failed to alloc memory for aggr_node\n"); - return NULL; - } - - p_aggr->aggr_sz = AGGR_SZ_DEFAULT; - p_aggr->dev = dev; - init_timer(&p_aggr->timer); - p_aggr->timer.function = aggr_timeout; - p_aggr->timer.data = (unsigned long) p_aggr; - - p_aggr->timer_scheduled = false; - skb_queue_head_init(&p_aggr->free_q); + aggr_conn->aggr_sz = AGGR_SZ_DEFAULT; + aggr_conn->dev = vif->ndev; + init_timer(&aggr_conn->timer); + aggr_conn->timer.function = aggr_timeout; + aggr_conn->timer.data = (unsigned long) aggr_conn; + aggr_conn->aggr_info = vif->aggr_cntxt; - ath6kl_alloc_netbufs(&p_aggr->free_q, AGGR_NUM_OF_FREE_NETBUFS); + aggr_conn->timer_scheduled = false; for (i = 0; i < NUM_OF_TIDS; i++) { - rxtid = &p_aggr->rx_tid[i]; + rxtid = &aggr_conn->rx_tid[i]; rxtid->aggr = false; rxtid->progress = false; rxtid->timer_mon = false; @@ -1664,6 +1664,30 @@ struct aggr_info *aggr_init(struct net_device *dev) spin_lock_init(&rxtid->lock); } +} + +struct aggr_info *aggr_init(struct ath6kl_vif *vif) +{ + struct aggr_info *p_aggr = NULL; + + p_aggr = kzalloc(sizeof(struct aggr_info), GFP_KERNEL); + if (!p_aggr) { + ath6kl_err("failed to alloc memory for aggr_node\n"); + return NULL; + } + + p_aggr->aggr_conn = kzalloc(sizeof(struct aggr_info_conn), GFP_KERNEL); + if (!p_aggr->aggr_conn) { + ath6kl_err("failed to alloc memory for connection specific aggr info\n"); + kfree(p_aggr); + return NULL; + } + + aggr_conn_init(vif, p_aggr->aggr_conn); + + skb_queue_head_init(&p_aggr->rx_amsdu_freeq); + ath6kl_alloc_netbufs(&p_aggr->rx_amsdu_freeq, AGGR_NUM_OF_FREE_NETBUFS); + return p_aggr; } @@ -1671,27 +1695,32 @@ void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid) { struct aggr_info *p_aggr = vif->aggr_cntxt; struct rxtid *rxtid; + struct aggr_info_conn *aggr_conn; - if (!p_aggr) + if (!p_aggr || !p_aggr->aggr_conn) return; - rxtid = &p_aggr->rx_tid[tid]; + aggr_conn = p_aggr->aggr_conn; + rxtid = &aggr_conn->rx_tid[tid]; if (rxtid->aggr) - aggr_delete_tid_state(p_aggr, tid); + aggr_delete_tid_state(aggr_conn, tid); } void aggr_reset_state(struct aggr_info *aggr_info) { u8 tid; - if (aggr_info->timer_scheduled) { - del_timer(&aggr_info->timer); - aggr_info->timer_scheduled = false; + if (!aggr_info || !aggr_info->aggr_conn) + return; + + if (aggr_info->aggr_conn->timer_scheduled) { + del_timer(&aggr_info->aggr_conn->timer); + aggr_info->aggr_conn->timer_scheduled = false; } for (tid = 0; tid < NUM_OF_TIDS; tid++) - aggr_delete_tid_state(aggr_info, tid); + aggr_delete_tid_state(aggr_info->aggr_conn, tid); } /* clean up our amsdu buffer list */ @@ -1718,28 +1747,11 @@ void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar) void aggr_module_destroy(struct aggr_info *aggr_info) { - struct rxtid *rxtid; - u8 i, k; - - if (!aggr_info) + if (!aggr_info || !aggr_info->aggr_conn) return; - if (aggr_info->timer_scheduled) { - del_timer(&aggr_info->timer); - aggr_info->timer_scheduled = false; - } - - for (i = 0; i < NUM_OF_TIDS; i++) { - rxtid = &aggr_info->rx_tid[i]; - if (rxtid->hold_q) { - for (k = 0; k < rxtid->hold_q_sz; k++) - dev_kfree_skb(rxtid->hold_q[k].skb); - kfree(rxtid->hold_q); - } - - skb_queue_purge(&rxtid->q); - } - - skb_queue_purge(&aggr_info->free_q); + aggr_reset_state(aggr_info); + skb_queue_purge(&aggr_info->rx_amsdu_freeq); + kfree(aggr_info->aggr_conn); kfree(aggr_info); } -- GitLab From 17741c8db4f53200a51600d1644ee6a2b76f0984 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 21 Jan 2012 15:22:51 +0530 Subject: [PATCH 0058/1846] ath6kl: Pass vif instead of ar to ath6kl_add_new_sta() This will be used when initializing station specific aggregation information. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 3a3b2cc9940d..acb4acb71718 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -52,10 +52,11 @@ struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid) return conn; } -static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie, - size_t ielen, u8 keymgmt, u8 ucipher, u8 auth, - u8 apsd_info) +static void ath6kl_add_new_sta(struct ath6kl_vif *vif, u8 *mac, u16 aid, + u8 *wpaie, size_t ielen, u8 keymgmt, + u8 ucipher, u8 auth, u8 apsd_info) { + struct ath6kl *ar = vif->ar; struct ath6kl_sta *sta; u8 free_slot; @@ -430,7 +431,6 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, u8 keymgmt, u8 ucipher, u8 auth, u8 assoc_req_len, u8 *assoc_info, u8 apsd_info) { - struct ath6kl *ar = vif->ar; u8 *ies = NULL, *wpa_ie = NULL, *pos; size_t ies_len = 0; struct station_info sinfo; @@ -484,7 +484,7 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr, pos += 2 + pos[1]; } - ath6kl_add_new_sta(ar, mac_addr, aid, wpa_ie, + ath6kl_add_new_sta(vif, mac_addr, aid, wpa_ie, wpa_ie ? 2 + wpa_ie[1] : 0, keymgmt, ucipher, auth, apsd_info); -- GitLab From 3fdc099109e75359e5de54c56478c06255850741 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 21 Jan 2012 15:22:52 +0530 Subject: [PATCH 0059/1846] ath6kl: Fix bug in using tid given by addba/delba req events The tid which is given in addba/delba req event is not just tid but also muxed with the assoc id (MSB 4 bits) which can be used to determine the corresponding connected station in softap mode. The actual tid is LSB 4 bits. Using the tid as it is with rx_tid[] would result in OOB or invalid memory access in AP mode. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/txrx.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 8407d0103dcd..8cf7b2fa0f41 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -17,6 +17,17 @@ #include "core.h" #include "debug.h" +/* + * tid - tid_mux0..tid_mux3 + * aid - tid_mux4..tid_mux7 + */ +#define ATH6KL_TID_MASK 0xf + +static inline u8 ath6kl_get_tid(u8 tid_mux) +{ + return tid_mux & ATH6KL_TID_MASK; +} + static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, u32 *map_no) { @@ -1602,7 +1613,7 @@ static void aggr_delete_tid_state(struct aggr_info_conn *aggr_conn, u8 tid) memset(stats, 0, sizeof(struct rxtid_stats)); } -void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, +void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no, u8 win_sz) { struct aggr_info *p_aggr = vif->aggr_cntxt; @@ -1610,12 +1621,17 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid, u16 seq_no, struct rxtid *rxtid; struct rxtid_stats *stats; u16 hold_q_size; + u8 tid; if (!p_aggr || !p_aggr->aggr_conn) return; aggr_conn = p_aggr->aggr_conn; + tid = ath6kl_get_tid(tid_mux); + if (tid >= NUM_OF_TIDS) + return; + rxtid = &aggr_conn->rx_tid[tid]; stats = &aggr_conn->stat[tid]; @@ -1691,15 +1707,20 @@ struct aggr_info *aggr_init(struct ath6kl_vif *vif) return p_aggr; } -void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid) +void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid_mux) { struct aggr_info *p_aggr = vif->aggr_cntxt; struct rxtid *rxtid; struct aggr_info_conn *aggr_conn; + u8 tid; if (!p_aggr || !p_aggr->aggr_conn) return; + tid = ath6kl_get_tid(tid_mux); + if (tid >= NUM_OF_TIDS) + return; + aggr_conn = p_aggr->aggr_conn; rxtid = &aggr_conn->rx_tid[tid]; -- GitLab From 1d2a4456de20db73362c86c88fe9c02169f29d0a Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 21 Jan 2012 15:22:53 +0530 Subject: [PATCH 0060/1846] ath6kl: Fix bug in maintaining aggregation state in AP mode Currently rx aggregation related states are maintained per vif, but this will not properly work when operating in AP mode. Aggregation is completely broken when more than one 11n stations are connected to AP mode vif. Fix this issue by keeping station specific aggregation state in sta_list. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 5 + drivers/net/wireless/ath/ath6kl/core.c | 7 ++ drivers/net/wireless/ath/ath6kl/core.h | 4 +- drivers/net/wireless/ath/ath6kl/init.c | 4 + drivers/net/wireless/ath/ath6kl/main.c | 7 +- drivers/net/wireless/ath/ath6kl/txrx.c | 106 +++++++++++++-------- 6 files changed, 88 insertions(+), 45 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 8bf447a6a84e..fed7b8077f5e 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2871,6 +2871,11 @@ struct ath6kl *ath6kl_cfg80211_create(void) /* Note: ar variable must not be accessed after calling this! */ void ath6kl_cfg80211_destroy(struct ath6kl *ar) { + int i; + + for (i = 0; i < AP_MAX_NUM_STA; i++) + kfree(ar->sta_list[i].aggr_conn); + wiphy_free(ar->wiphy); } diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index d764afec395b..0d92e7179f8a 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -253,6 +253,13 @@ struct ath6kl *ath6kl_core_create(struct device *dev) spin_lock_init(&ar->sta_list[ctr].psq_lock); skb_queue_head_init(&ar->sta_list[ctr].psq); skb_queue_head_init(&ar->sta_list[ctr].apsdq); + ar->sta_list[ctr].aggr_conn = + kzalloc(sizeof(struct aggr_info_conn), GFP_KERNEL); + if (!ar->sta_list[ctr].aggr_conn) { + ath6kl_err("Failed to allocate memory for sta aggregation information\n"); + ath6kl_core_destroy(ar); + return NULL; + } } skb_queue_head_init(&ar->mcastpsq); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 1b9054f8f4e4..ed9fcc11b5fc 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -298,6 +298,7 @@ struct ath6kl_sta { spinlock_t psq_lock; u8 apsd_info; struct sk_buff_head apsdq; + struct aggr_info_conn *aggr_conn; }; struct ath6kl_version { @@ -713,6 +714,7 @@ void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie); int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev); struct aggr_info *aggr_init(struct ath6kl_vif *vif); +void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info_conn *aggr_conn); void ath6kl_rx_refill(struct htc_target *target, enum htc_endpoint_id endpoint); void ath6kl_refill_amsdu_rxbufs(struct ath6kl *ar, int count); @@ -720,7 +722,7 @@ struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target, enum htc_endpoint_id endpoint, int len); void aggr_module_destroy(struct aggr_info *aggr_info); -void aggr_reset_state(struct aggr_info *aggr_info); +void aggr_reset_state(struct aggr_info_conn *aggr_conn); struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 * node_addr); struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 167dc41af2de..4d8eb1cca6e9 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1660,6 +1660,7 @@ void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready) void ath6kl_stop_txrx(struct ath6kl *ar) { struct ath6kl_vif *vif, *tmp_vif; + int i; set_bit(DESTROY_IN_PROGRESS, &ar->flag); @@ -1668,6 +1669,9 @@ void ath6kl_stop_txrx(struct ath6kl *ar) return; } + for (i = 0; i < AP_MAX_NUM_STA; i++) + aggr_reset_state(ar->sta_list[i].aggr_conn); + spin_lock_bh(&ar->list_lock); list_for_each_entry_safe(vif, tmp_vif, &ar->vif_list, list) { list_del(&vif->list); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index acb4acb71718..39da1f98da87 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -74,6 +74,7 @@ static void ath6kl_add_new_sta(struct ath6kl_vif *vif, u8 *mac, u16 aid, ar->sta_list_index = ar->sta_list_index | (1 << free_slot); ar->ap_stats.sta[free_slot].aid = cpu_to_le32(aid); + aggr_conn_init(vif, sta->aggr_conn); } static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i) @@ -94,7 +95,7 @@ static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i) sta->sta_flags = 0; ar->sta_list_index = ar->sta_list_index & ~(1 << i); - + aggr_reset_state(sta->aggr_conn); } static u8 ath6kl_remove_sta(struct ath6kl *ar, u8 *mac, u16 reason) @@ -602,7 +603,7 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, netif_carrier_on(vif->ndev); spin_unlock_bh(&vif->if_lock); - aggr_reset_state(vif->aggr_cntxt); + aggr_reset_state(vif->aggr_cntxt->aggr_conn); vif->reconnect_flag = 0; if ((vif->nw_type == ADHOC_NETWORK) && ar->ibss_ps_enable) { @@ -924,7 +925,7 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, assoc_resp_len, assoc_info, prot_reason_status); - aggr_reset_state(vif->aggr_cntxt); + aggr_reset_state(vif->aggr_cntxt->aggr_conn); del_timer(&vif->disconnect_timer); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 8cf7b2fa0f41..62c12102e146 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -22,12 +22,18 @@ * aid - tid_mux4..tid_mux7 */ #define ATH6KL_TID_MASK 0xf +#define ATH6KL_AID_SHIFT 4 static inline u8 ath6kl_get_tid(u8 tid_mux) { return tid_mux & ATH6KL_TID_MASK; } +static inline u8 ath6kl_get_aid(u8 tid_mux) +{ + return tid_mux >> ATH6KL_AID_SHIFT; +} + static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, u32 *map_no) { @@ -1003,7 +1009,7 @@ static void aggr_slice_amsdu(struct aggr_info *p_aggr, dev_kfree_skb(skb); } -static void aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, +static void aggr_deque_frms(struct aggr_info_conn *agg_conn, u8 tid, u16 seq_no, u8 order) { struct sk_buff *skb; @@ -1011,12 +1017,7 @@ static void aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, struct skb_hold_q *node; u16 idx, idx_end, seq_end; struct rxtid_stats *stats; - struct aggr_info_conn *agg_conn; - if (!p_aggr || !p_aggr->aggr_conn) - return; - - agg_conn = p_aggr->aggr_conn; rxtid = &agg_conn->rx_tid[tid]; stats = &agg_conn->stat[tid]; @@ -1047,7 +1048,8 @@ static void aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, if (node->skb) { if (node->is_amsdu) - aggr_slice_amsdu(p_aggr, rxtid, node->skb); + aggr_slice_amsdu(agg_conn->aggr_info, rxtid, + node->skb); else skb_queue_tail(&rxtid->q, node->skb); node->skb = NULL; @@ -1066,7 +1068,7 @@ static void aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, ath6kl_deliver_frames_to_nw_stack(agg_conn->dev, skb); } -static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, +static bool aggr_process_recv_frm(struct aggr_info_conn *agg_conn, u8 tid, u16 seq_no, bool is_amsdu, struct sk_buff *frame) { @@ -1077,7 +1079,6 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, u16 idx, st, cur, end; bool is_queued = false; u16 extended_end; - struct aggr_info_conn *agg_conn = agg_info->aggr_conn; rxtid = &agg_conn->rx_tid[tid]; stats = &agg_conn->stat[tid]; @@ -1086,7 +1087,7 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, if (!rxtid->aggr) { if (is_amsdu) { - aggr_slice_amsdu(agg_info, rxtid, frame); + aggr_slice_amsdu(agg_conn->aggr_info, rxtid, frame); is_queued = true; stats->num_amsdu++; while ((skb = skb_dequeue(&rxtid->q))) @@ -1110,7 +1111,7 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, (cur < end || cur > extended_end)) || ((end > extended_end) && (cur > extended_end) && (cur < end))) { - aggr_deque_frms(agg_info, tid, 0, 0); + aggr_deque_frms(agg_conn, tid, 0, 0); if (cur >= rxtid->hold_q_sz - 1) rxtid->seq_next = cur - (rxtid->hold_q_sz - 1); else @@ -1127,7 +1128,7 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, st = ATH6KL_MAX_SEQ_NO - (rxtid->hold_q_sz - 2 - cur); - aggr_deque_frms(agg_info, tid, st, 0); + aggr_deque_frms(agg_conn, tid, st, 0); } stats->num_oow++; @@ -1166,7 +1167,7 @@ static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, spin_unlock_bh(&rxtid->lock); - aggr_deque_frms(agg_info, tid, 0, 1); + aggr_deque_frms(agg_conn, tid, 0, 1); if (agg_conn->timer_scheduled) rxtid->progress = true; @@ -1278,6 +1279,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) struct sk_buff *skb1 = NULL; struct ethhdr *datap = NULL; struct ath6kl_vif *vif; + struct aggr_info_conn *aggr_conn; u16 seq_no, offset; u8 tid, if_idx; @@ -1529,11 +1531,21 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) datap = (struct ethhdr *) skb->data; - if (is_unicast_ether_addr(datap->h_dest) && - aggr_process_recv_frm(vif->aggr_cntxt, tid, seq_no, - is_amsdu, skb)) - /* aggregation code will handle the skb */ - return; + if (is_unicast_ether_addr(datap->h_dest)) { + if (vif->nw_type == AP_NETWORK) { + conn = ath6kl_find_sta(vif, datap->h_source); + if (!conn) + return; + aggr_conn = conn->aggr_conn; + } else + aggr_conn = vif->aggr_cntxt->aggr_conn; + + if (aggr_process_recv_frm(aggr_conn, tid, seq_no, + is_amsdu, skb)) { + /* aggregation code will handle the skb */ + return; + } + } ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb); } @@ -1558,7 +1570,7 @@ static void aggr_timeout(unsigned long arg) rxtid->seq_next, ((rxtid->seq_next + rxtid->hold_q_sz-1) & ATH6KL_MAX_SEQ_NO)); - aggr_deque_frms(aggr_conn->aggr_info, i, 0, 0); + aggr_deque_frms(aggr_conn, i, 0, 0); } aggr_conn->timer_scheduled = false; @@ -1598,7 +1610,7 @@ static void aggr_delete_tid_state(struct aggr_info_conn *aggr_conn, u8 tid) stats = &aggr_conn->stat[tid]; if (rxtid->aggr) - aggr_deque_frms(aggr_conn->aggr_info, tid, 0, 0); + aggr_deque_frms(aggr_conn, tid, 0, 0); rxtid->aggr = false; rxtid->progress = false; @@ -1616,17 +1628,23 @@ static void aggr_delete_tid_state(struct aggr_info_conn *aggr_conn, u8 tid) void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no, u8 win_sz) { - struct aggr_info *p_aggr = vif->aggr_cntxt; - struct aggr_info_conn *aggr_conn; + struct ath6kl_sta *sta; + struct aggr_info_conn *aggr_conn = NULL; struct rxtid *rxtid; struct rxtid_stats *stats; u16 hold_q_size; - u8 tid; + u8 tid, aid; - if (!p_aggr || !p_aggr->aggr_conn) - return; + if (vif->nw_type == AP_NETWORK) { + aid = ath6kl_get_aid(tid_mux); + sta = ath6kl_find_sta_by_aid(vif->ar, aid); + if (sta) + aggr_conn = sta->aggr_conn; + } else + aggr_conn = vif->aggr_cntxt->aggr_conn; - aggr_conn = p_aggr->aggr_conn; + if (!aggr_conn) + return; tid = ath6kl_get_tid(tid_mux); if (tid >= NUM_OF_TIDS) @@ -1656,8 +1674,7 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no, rxtid->aggr = true; } -static void aggr_conn_init(struct ath6kl_vif *vif, - struct aggr_info_conn *aggr_conn) +void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info_conn *aggr_conn) { struct rxtid *rxtid; u8 i; @@ -1709,39 +1726,46 @@ struct aggr_info *aggr_init(struct ath6kl_vif *vif) void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid_mux) { - struct aggr_info *p_aggr = vif->aggr_cntxt; + struct ath6kl_sta *sta; struct rxtid *rxtid; - struct aggr_info_conn *aggr_conn; - u8 tid; + struct aggr_info_conn *aggr_conn = NULL; + u8 tid, aid; + + if (vif->nw_type == AP_NETWORK) { + aid = ath6kl_get_aid(tid_mux); + sta = ath6kl_find_sta_by_aid(vif->ar, aid); + if (sta) + aggr_conn = sta->aggr_conn; + } else + aggr_conn = vif->aggr_cntxt->aggr_conn; - if (!p_aggr || !p_aggr->aggr_conn) + if (!aggr_conn) return; tid = ath6kl_get_tid(tid_mux); if (tid >= NUM_OF_TIDS) return; - aggr_conn = p_aggr->aggr_conn; rxtid = &aggr_conn->rx_tid[tid]; if (rxtid->aggr) aggr_delete_tid_state(aggr_conn, tid); } -void aggr_reset_state(struct aggr_info *aggr_info) +void aggr_reset_state(struct aggr_info_conn *aggr_conn) { u8 tid; - if (!aggr_info || !aggr_info->aggr_conn) + if (!aggr_conn) return; - if (aggr_info->aggr_conn->timer_scheduled) { - del_timer(&aggr_info->aggr_conn->timer); - aggr_info->aggr_conn->timer_scheduled = false; + if (aggr_conn->timer_scheduled) { + del_timer(&aggr_conn->timer); + aggr_conn->timer_scheduled = false; } for (tid = 0; tid < NUM_OF_TIDS; tid++) - aggr_delete_tid_state(aggr_info->aggr_conn, tid); + aggr_delete_tid_state(aggr_conn, tid); } /* clean up our amsdu buffer list */ @@ -1768,10 +1792,10 @@ void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar) void aggr_module_destroy(struct aggr_info *aggr_info) { - if (!aggr_info || !aggr_info->aggr_conn) + if (!aggr_info) return; - aggr_reset_state(aggr_info); + aggr_reset_state(aggr_info->aggr_conn); skb_queue_purge(&aggr_info->rx_amsdu_freeq); kfree(aggr_info->aggr_conn); kfree(aggr_info); -- GitLab From 35b88623692f7ffbfdf16e4c2358784a060c20ed Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 29 Dec 2011 14:41:39 +0200 Subject: [PATCH 0061/1846] mac80211: check sta_apply_parameters() return value Bail out if sta_apply_parameters() returns an error. Signed-off-by: Eliad Peller Acked-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/cfg.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 296620d6ca0c..d86730fe75c8 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1001,6 +1001,7 @@ static int ieee80211_change_station(struct wiphy *wiphy, struct ieee80211_local *local = wiphy_priv(wiphy); struct sta_info *sta; struct ieee80211_sub_if_data *vlansdata; + int err; mutex_lock(&local->sta_mtx); @@ -1040,7 +1041,11 @@ static int ieee80211_change_station(struct wiphy *wiphy, ieee80211_send_layer2_update(sta); } - sta_apply_parameters(local, sta, params); + err = sta_apply_parameters(local, sta, params); + if (err) { + mutex_unlock(&local->sta_mtx); + return err; + } if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates) rate_control_rate_init(sta); -- GitLab From b0f70292053a0f68f406564a721a7a3f2d66b44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 2 Jan 2012 08:41:23 +0100 Subject: [PATCH 0062/1846] ssb: SPROM: extract each core power info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already extract some basic info but it's incomplete, reads info about the first core only. Used data structure doesn't allow easy adding of more cores. This patch adds new struct and array for storing power info. The plan is to: switch all extractors (including the ones using NVRAM) to new struct, switch drivers, then deprecate and finally drop old SSB fields. Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/ssb/pci.c | 40 +++++++++++++++++++++++++++++++++++- include/linux/ssb/ssb.h | 8 ++++++++ include/linux/ssb/ssb_regs.h | 34 ++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c index 973223f5de8e..befa89eac6f3 100644 --- a/drivers/ssb/pci.c +++ b/drivers/ssb/pci.c @@ -523,7 +523,13 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in) static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) { int i; - u16 v; + u16 v, o; + u16 pwr_info_offset[] = { + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1, + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3 + }; + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) != + ARRAY_SIZE(out->core_pwr_info)); /* extract the MAC address */ for (i = 0; i < 3; i++) { @@ -607,6 +613,38 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24, sizeof(out->antenna_gain.ghz5)); + /* Extract cores power info info */ + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) { + o = pwr_info_offset[i]; + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI, + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT); + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI, + SSB_SPROM8_2G_MAXP, 0); + + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0); + + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI, + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT); + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI, + SSB_SPROM8_5G_MAXP, 0); + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP, + SSB_SPROM8_5GH_MAXP, 0); + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP, + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT); + + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0); + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0); + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0); + } + /* Extract FEM info */ SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT); diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h index dcf35b0f303a..bbc2612cb64a 100644 --- a/include/linux/ssb/ssb.h +++ b/include/linux/ssb/ssb.h @@ -16,6 +16,12 @@ struct pcmcia_device; struct ssb_bus; struct ssb_driver; +struct ssb_sprom_core_pwr_info { + u8 itssi_2g, itssi_5g; + u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh; + u16 pa_2g[3], pa_5gl[3], pa_5g[3], pa_5gh[3]; +}; + struct ssb_sprom { u8 revision; u8 il0mac[6]; /* MAC address for 802.11b/g */ @@ -82,6 +88,8 @@ struct ssb_sprom { u16 boardflags2_hi; /* Board flags (bits 48-63) */ /* TODO store board flags in a single u64 */ + struct ssb_sprom_core_pwr_info core_pwr_info[4]; + /* Antenna gain values for up to 4 antennas * on each band. Values in dBm/4 (Q5.2). Negative gain means the * loss in the connectors is bigger than the gain. */ diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h index c814ae6eeb22..40b1ef8595ee 100644 --- a/include/linux/ssb/ssb_regs.h +++ b/include/linux/ssb/ssb_regs.h @@ -449,6 +449,39 @@ #define SSB_SPROM8_TS_SLP_OPT_CORRX 0x00B6 #define SSB_SPROM8_FOC_HWIQ_IQSWP 0x00B8 #define SSB_SPROM8_PHYCAL_TEMPDELTA 0x00BA + +/* There are 4 blocks with power info sharing the same layout */ +#define SSB_SROM8_PWR_INFO_CORE0 0x00C0 +#define SSB_SROM8_PWR_INFO_CORE1 0x00E0 +#define SSB_SROM8_PWR_INFO_CORE2 0x0100 +#define SSB_SROM8_PWR_INFO_CORE3 0x0120 + +#define SSB_SROM8_2G_MAXP_ITSSI 0x00 +#define SSB_SPROM8_2G_MAXP 0x00FF +#define SSB_SPROM8_2G_ITSSI 0xFF00 +#define SSB_SPROM8_2G_ITSSI_SHIFT 8 +#define SSB_SROM8_2G_PA_0 0x02 /* 2GHz power amp settings */ +#define SSB_SROM8_2G_PA_1 0x04 +#define SSB_SROM8_2G_PA_2 0x06 +#define SSB_SROM8_5G_MAXP_ITSSI 0x08 /* 5GHz ITSSI and 5.3GHz Max Power */ +#define SSB_SPROM8_5G_MAXP 0x00FF +#define SSB_SPROM8_5G_ITSSI 0xFF00 +#define SSB_SPROM8_5G_ITSSI_SHIFT 8 +#define SSB_SPROM8_5GHL_MAXP 0x0A /* 5.2GHz and 5.8GHz Max Power */ +#define SSB_SPROM8_5GH_MAXP 0x00FF +#define SSB_SPROM8_5GL_MAXP 0xFF00 +#define SSB_SPROM8_5GL_MAXP_SHIFT 8 +#define SSB_SROM8_5G_PA_0 0x0C /* 5.3GHz power amp settings */ +#define SSB_SROM8_5G_PA_1 0x0E +#define SSB_SROM8_5G_PA_2 0x10 +#define SSB_SROM8_5GL_PA_0 0x12 /* 5.2GHz power amp settings */ +#define SSB_SROM8_5GL_PA_1 0x14 +#define SSB_SROM8_5GL_PA_2 0x16 +#define SSB_SROM8_5GH_PA_0 0x18 /* 5.8GHz power amp settings */ +#define SSB_SROM8_5GH_PA_1 0x1A +#define SSB_SROM8_5GH_PA_2 0x1C + +/* TODO: Make it deprecated */ #define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */ #define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */ #define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */ @@ -473,6 +506,7 @@ #define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */ #define SSB_SPROM8_PA1HIB1 0x00DA #define SSB_SPROM8_PA1HIB2 0x00DC + #define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */ #define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */ #define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */ -- GitLab From b35a9aca631ee0cf67cd23098ea9076ca33c3f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 2 Jan 2012 08:41:24 +0100 Subject: [PATCH 0063/1846] bcma: SPROM: add macro for easier extraction 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/bcma/sprom.c | 139 ++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index 6f230fb087c5..27f62cc2c8af 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -14,8 +14,6 @@ #include #include -#define SPOFF(offset) ((offset) / sizeof(u16)) - /************************************************** * R/W ops. **************************************************/ @@ -124,6 +122,11 @@ static int bcma_sprom_valid(const u16 *sprom) * SPROM extraction. **************************************************/ +#define SPOFF(offset) ((offset) / sizeof(u16)) + +#define SPEX(_field, _offset, _mask, _shift) \ + bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift)) + static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) { u16 v; @@ -137,72 +140,72 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v); } - bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)]; - - bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] & - SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT; - bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] & - SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT; - bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] & - SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT; - bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] & - SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT; - - bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] & - SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT; - bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] & - SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT; - bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] & - SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT; - bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] & - SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT; - - bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] & - SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT; - bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] & - SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT; - bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] & - SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT; - bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] & - SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT; - - bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] & - SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT; - bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] & - SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT; - bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] & - SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT; - bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] & - SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT; - - bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)]; - bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)]; - bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)]; - bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)]; - - bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)]; - - bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & - SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT; - bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & - SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT; - bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & - SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT; - bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & - SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT; - bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & - SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT; - - bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & - SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT; - bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & - SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT; - bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & - SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT; - bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & - SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT; - bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & - SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT; + SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0); + + SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0, + SSB_SPROM4_TXPID2G0_SHIFT); + SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1, + SSB_SPROM4_TXPID2G1_SHIFT); + SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2, + SSB_SPROM4_TXPID2G2_SHIFT); + SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3, + SSB_SPROM4_TXPID2G3_SHIFT); + + SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0, + SSB_SPROM4_TXPID5GL0_SHIFT); + SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1, + SSB_SPROM4_TXPID5GL1_SHIFT); + SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2, + SSB_SPROM4_TXPID5GL2_SHIFT); + SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3, + SSB_SPROM4_TXPID5GL3_SHIFT); + + SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0, + SSB_SPROM4_TXPID5G0_SHIFT); + SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1, + SSB_SPROM4_TXPID5G1_SHIFT); + SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2, + SSB_SPROM4_TXPID5G2_SHIFT); + SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3, + SSB_SPROM4_TXPID5G3_SHIFT); + + SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0, + SSB_SPROM4_TXPID5GH0_SHIFT); + SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1, + SSB_SPROM4_TXPID5GH1_SHIFT); + SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2, + SSB_SPROM4_TXPID5GH2_SHIFT); + SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3, + SSB_SPROM4_TXPID5GH3_SHIFT); + + SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0); + SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0); + SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0); + SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0); + + SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0); + + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS, + SSB_SROM8_FEM_TSSIPOS_SHIFT); + SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN, + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT); + SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE, + SSB_SROM8_FEM_PDET_RANGE_SHIFT); + SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO, + SSB_SROM8_FEM_TR_ISO_SHIFT); + SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT, + SSB_SROM8_FEM_ANTSWLUT_SHIFT); + + SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS, + SSB_SROM8_FEM_TSSIPOS_SHIFT); + SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN, + SSB_SROM8_FEM_EXTPA_GAIN_SHIFT); + SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE, + SSB_SROM8_FEM_PDET_RANGE_SHIFT); + SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO, + SSB_SROM8_FEM_TR_ISO_SHIFT); + SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT, + SSB_SROM8_FEM_ANTSWLUT_SHIFT); } int bcma_sprom_get(struct bcma_bus *bus) -- GitLab From 507f9a71846a3d25d0e5322754da6b65adceda80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 2 Jan 2012 08:41:25 +0100 Subject: [PATCH 0064/1846] bcma: SPROM: extract power info for cores 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/bcma/sprom.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index 27f62cc2c8af..cb835f026d94 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -129,8 +129,14 @@ static int bcma_sprom_valid(const u16 *sprom) static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) { - u16 v; + u16 v, o; int i; + u16 pwr_info_offset[] = { + SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1, + SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3 + }; + BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) != + ARRAY_SIZE(bus->sprom.core_pwr_info)); bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV; @@ -185,6 +191,38 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0); + /* Extract cores power info info */ + for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) { + o = pwr_info_offset[i]; + SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI, + SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT); + SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI, + SSB_SPROM8_2G_MAXP, 0); + + SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0); + + SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI, + SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT); + SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI, + SSB_SPROM8_5G_MAXP, 0); + SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP, + SSB_SPROM8_5GH_MAXP, 0); + SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP, + SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT); + + SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0); + SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0); + SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0); + SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0); + SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0); + } + SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT); SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN, -- GitLab From 5056635c10151970d87ae256b7f52f056291799e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 2 Jan 2012 19:31:21 +0100 Subject: [PATCH 0065/1846] b43: add maskset helpers 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/b43.h | 12 ++++++ drivers/net/wireless/b43/main.c | 67 +++++++++----------------------- drivers/net/wireless/b43/phy_n.c | 14 +++---- 3 files changed, 36 insertions(+), 57 deletions(-) diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 16e8f8058155..835462dc1206 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h @@ -999,6 +999,12 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value) dev->dev->write16(dev->dev, offset, value); } +static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask, + u16 set) +{ + b43_write16(dev, offset, (b43_read16(dev, offset) & mask) | set); +} + static inline u32 b43_read32(struct b43_wldev *dev, u16 offset) { return dev->dev->read32(dev->dev, offset); @@ -1009,6 +1015,12 @@ static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value) dev->dev->write32(dev->dev, offset, value); } +static inline void b43_maskset32(struct b43_wldev *dev, u16 offset, u32 mask, + u32 set) +{ + b43_write32(dev, offset, (b43_read32(dev, offset) & mask) | set); +} + static inline void b43_block_read(struct b43_wldev *dev, void *buffer, size_t count, u16 offset, u8 reg_width) { diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index b91f28ef1032..268f2db5237b 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -578,22 +578,14 @@ void b43_tsf_read(struct b43_wldev *dev, u64 *tsf) static void b43_time_lock(struct b43_wldev *dev) { - u32 macctl; - - macctl = b43_read32(dev, B43_MMIO_MACCTL); - macctl |= B43_MACCTL_TBTTHOLD; - b43_write32(dev, B43_MMIO_MACCTL, macctl); + b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_TBTTHOLD); /* Commit the write */ b43_read32(dev, B43_MMIO_MACCTL); } static void b43_time_unlock(struct b43_wldev *dev) { - u32 macctl; - - macctl = b43_read32(dev, B43_MMIO_MACCTL); - macctl &= ~B43_MACCTL_TBTTHOLD; - b43_write32(dev, B43_MMIO_MACCTL, macctl); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_TBTTHOLD, 0); /* Commit the write */ b43_read32(dev, B43_MMIO_MACCTL); } @@ -2485,10 +2477,8 @@ static int b43_upload_microcode(struct b43_wldev *dev) b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_ALL); /* Start the microcode PSM */ - macctl = b43_read32(dev, B43_MMIO_MACCTL); - macctl &= ~B43_MACCTL_PSM_JMP0; - macctl |= B43_MACCTL_PSM_RUN; - b43_write32(dev, B43_MMIO_MACCTL, macctl); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_JMP0, + B43_MACCTL_PSM_RUN); /* Wait for the microcode to load and respond */ i = 0; @@ -2588,10 +2578,9 @@ static int b43_upload_microcode(struct b43_wldev *dev) return 0; error: - macctl = b43_read32(dev, B43_MMIO_MACCTL); - macctl &= ~B43_MACCTL_PSM_RUN; - macctl |= B43_MACCTL_PSM_JMP0; - b43_write32(dev, B43_MMIO_MACCTL, macctl); + /* Stop the microcode PSM. */ + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN, + B43_MACCTL_PSM_JMP0); return err; } @@ -2706,11 +2695,8 @@ static int b43_gpio_init(struct b43_wldev *dev) struct ssb_device *gpiodev; u32 mask, set; - b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) - & ~B43_MACCTL_GPOUTSMSK); - - b43_write16(dev, B43_MMIO_GPIO_MASK, b43_read16(dev, B43_MMIO_GPIO_MASK) - | 0x000F); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0); + b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF); mask = 0x0000001F; set = 0x0000000F; @@ -2798,9 +2784,7 @@ void b43_mac_enable(struct b43_wldev *dev) dev->mac_suspended--; B43_WARN_ON(dev->mac_suspended < 0); if (dev->mac_suspended == 0) { - b43_write32(dev, B43_MMIO_MACCTL, - b43_read32(dev, B43_MMIO_MACCTL) - | B43_MACCTL_ENABLED); + b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_ENABLED); b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_MAC_SUSPENDED); /* Commit writes */ @@ -2821,9 +2805,7 @@ void b43_mac_suspend(struct b43_wldev *dev) if (dev->mac_suspended == 0) { b43_power_saving_ctl_bits(dev, B43_PS_AWAKE); - b43_write32(dev, B43_MMIO_MACCTL, - b43_read32(dev, B43_MMIO_MACCTL) - & ~B43_MACCTL_ENABLED); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_ENABLED, 0); /* force pci to flush the write */ b43_read32(dev, B43_MMIO_MACCTL); for (i = 35; i; i--) { @@ -2929,15 +2911,10 @@ static void b43_adjust_opmode(struct b43_wldev *dev) * so always disable it. If we want to implement PMQ, * we need to enable it here (clear DISCPMQ) in AP mode. */ - if (0 /* ctl & B43_MACCTL_AP */) { - b43_write32(dev, B43_MMIO_MACCTL, - b43_read32(dev, B43_MMIO_MACCTL) - & ~B43_MACCTL_DISCPMQ); - } else { - b43_write32(dev, B43_MMIO_MACCTL, - b43_read32(dev, B43_MMIO_MACCTL) - | B43_MACCTL_DISCPMQ); - } + if (0 /* ctl & B43_MACCTL_AP */) + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_DISCPMQ, 0); + else + b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_DISCPMQ); } static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm) @@ -3081,10 +3058,8 @@ static int b43_chip_init(struct b43_wldev *dev) if (dev->dev->core_rev < 5) b43_write32(dev, 0x010C, 0x01000000); - b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) - & ~B43_MACCTL_INFRA); - b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) - | B43_MACCTL_INFRA); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_INFRA, 0); + b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_INFRA); /* Probe Response Timeout value */ /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */ @@ -4562,8 +4537,6 @@ static void b43_set_pretbtt(struct b43_wldev *dev) /* Locking: wl->mutex */ static void b43_wireless_core_exit(struct b43_wldev *dev) { - u32 macctl; - B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED); if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) return; @@ -4574,10 +4547,8 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) b43_set_status(dev, B43_STAT_UNINIT); /* Stop the microcode PSM. */ - macctl = b43_read32(dev, B43_MMIO_MACCTL); - macctl &= ~B43_MACCTL_PSM_RUN; - macctl |= B43_MACCTL_PSM_JMP0; - b43_write32(dev, B43_MMIO_MACCTL, macctl); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN, + B43_MACCTL_PSM_JMP0); b43_dma_free(dev); b43_pio_free(dev); diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index bf5a43855358..9530f12c0282 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -3968,13 +3968,10 @@ static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init) #endif } - b43_write32(dev, B43_MMIO_MACCTL, - b43_read32(dev, B43_MMIO_MACCTL) & - ~B43_MACCTL_GPOUTSMSK); - b43_write16(dev, B43_MMIO_GPIO_MASK, - b43_read16(dev, B43_MMIO_GPIO_MASK) | 0xFC00); - b43_write16(dev, B43_MMIO_GPIO_CONTROL, - b43_read16(dev, B43_MMIO_GPIO_CONTROL) & ~0xFC00); + b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0); + b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xFC00); + b43_maskset16(dev, B43_MMIO_GPIO_CONTROL, (~0xFC00 & 0xFFFF), + 0); if (init) { b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8); @@ -4530,8 +4527,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, { check_phyreg(dev, reg); b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); - b43_write16(dev, B43_MMIO_PHY_DATA, - (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set); + b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set); } static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg) -- GitLab From d3fd8bf77affcbf80bb8297d177e17ad0b61abc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 2 Jan 2012 19:31:22 +0100 Subject: [PATCH 0066/1846] b43: N-PHY: implement TX power control 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 | 217 ++++++++++++++++++++++++++++++- drivers/net/wireless/b43/phy_n.h | 1 + 2 files changed, 217 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 9530f12c0282..fbbdbdad1019 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -2420,6 +2420,221 @@ static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev) nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF; } +/* http://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */ +static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev) +{ + struct b43_phy_n *nphy = dev->phy.n; + + u8 idx, delta; + u8 i, stf_mode; + + for (i = 0; i < 4; i++) + nphy->adj_pwr_tbl[i] = nphy->tx_power_offset[i]; + + for (stf_mode = 0; stf_mode < 4; stf_mode++) { + delta = 0; + switch (stf_mode) { + case 0: + if (dev->phy.is_40mhz && dev->phy.rev >= 5) { + idx = 68; + } else { + delta = 1; + idx = dev->phy.is_40mhz ? 52 : 4; + } + break; + case 1: + idx = dev->phy.is_40mhz ? 76 : 28; + break; + case 2: + idx = dev->phy.is_40mhz ? 84 : 36; + break; + case 3: + idx = dev->phy.is_40mhz ? 92 : 44; + break; + } + + for (i = 0; i < 20; i++) { + nphy->adj_pwr_tbl[4 + 4 * i + stf_mode] = + nphy->tx_power_offset[idx]; + if (i == 0) + idx += delta; + if (i == 14) + idx += 1 - delta; + if (i == 3 || i == 4 || i == 7 || i == 8 || i == 11 || + i == 13) + idx += 1; + } + } +} + +/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */ +static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev) +{ + struct b43_phy_n *nphy = dev->phy.n; + struct ssb_sprom *sprom = dev->dev->bus_sprom; + + s16 a1[2], b0[2], b1[2]; + u8 idle[2]; + s8 target[2]; + s32 num, den, pwr; + u32 regval[64]; + + u16 freq = dev->phy.channel_freq; + u16 tmp; + u16 r; /* routing */ + u8 i, c; + + if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) { + b43_maskset32(dev, B43_MMIO_MACCTL, ~0, 0x200000); + b43_read32(dev, B43_MMIO_MACCTL); + udelay(1); + } + + if (nphy->hang_avoid) + b43_nphy_stay_in_carrier_search(dev, true); + + b43_phy_set(dev, B43_NPHY_TSSIMODE, B43_NPHY_TSSIMODE_EN); + if (dev->phy.rev >= 3) + b43_phy_mask(dev, B43_NPHY_TXPCTL_CMD, + ~B43_NPHY_TXPCTL_CMD_PCTLEN & 0xFFFF); + else + b43_phy_set(dev, B43_NPHY_TXPCTL_CMD, + B43_NPHY_TXPCTL_CMD_PCTLEN); + + if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) + b43_maskset32(dev, B43_MMIO_MACCTL, ~0x200000, 0); + + if (sprom->revision < 4) { + idle[0] = nphy->pwr_ctl_info[0].idle_tssi_2g; + idle[1] = nphy->pwr_ctl_info[1].idle_tssi_2g; + target[0] = target[1] = 52; + a1[0] = a1[1] = -424; + b0[0] = b0[1] = 5612; + b1[0] = b1[1] = -1393; + } else { + if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { + for (c = 0; c < 2; c++) { + idle[c] = nphy->pwr_ctl_info[c].idle_tssi_2g; + target[c] = sprom->core_pwr_info[c].maxpwr_2g; + a1[c] = sprom->core_pwr_info[c].pa_2g[0]; + b0[c] = sprom->core_pwr_info[c].pa_2g[1]; + b1[c] = sprom->core_pwr_info[c].pa_2g[2]; + } + } else if (freq >= 4900 && freq < 5100) { + for (c = 0; c < 2; c++) { + idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g; + target[c] = sprom->core_pwr_info[c].maxpwr_5gl; + a1[c] = sprom->core_pwr_info[c].pa_5gl[0]; + b0[c] = sprom->core_pwr_info[c].pa_5gl[1]; + b1[c] = sprom->core_pwr_info[c].pa_5gl[2]; + } + } else if (freq >= 5100 && freq < 5500) { + for (c = 0; c < 2; c++) { + idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g; + target[c] = sprom->core_pwr_info[c].maxpwr_5g; + a1[c] = sprom->core_pwr_info[c].pa_5g[0]; + b0[c] = sprom->core_pwr_info[c].pa_5g[1]; + b1[c] = sprom->core_pwr_info[c].pa_5g[2]; + } + } else if (freq >= 5500) { + for (c = 0; c < 2; c++) { + idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g; + target[c] = sprom->core_pwr_info[c].maxpwr_5gh; + a1[c] = sprom->core_pwr_info[c].pa_5gh[0]; + b0[c] = sprom->core_pwr_info[c].pa_5gh[1]; + b1[c] = sprom->core_pwr_info[c].pa_5gh[2]; + } + } else { + idle[0] = nphy->pwr_ctl_info[0].idle_tssi_5g; + idle[1] = nphy->pwr_ctl_info[1].idle_tssi_5g; + target[0] = target[1] = 52; + a1[0] = a1[1] = -424; + b0[0] = b0[1] = 5612; + b1[0] = b1[1] = -1393; + } + } + /* target[0] = target[1] = nphy->tx_power_max; */ + + if (dev->phy.rev >= 3) { + if (sprom->fem.ghz2.tssipos) + b43_phy_set(dev, B43_NPHY_TXPCTL_ITSSI, 0x4000); + if (dev->phy.rev >= 7) { + for (c = 0; c < 2; c++) { + r = c ? 0x190 : 0x170; + if (b43_nphy_ipa(dev)) + b43_radio_write(dev, r + 0x9, (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) ? 0xE : 0xC); + } + } else { + if (b43_nphy_ipa(dev)) { + tmp = (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) ? 0xC : 0xE; + b43_radio_write(dev, + B2056_TX0 | B2056_TX_TX_SSI_MUX, tmp); + b43_radio_write(dev, + B2056_TX1 | B2056_TX_TX_SSI_MUX, tmp); + } else { + b43_radio_write(dev, + B2056_TX0 | B2056_TX_TX_SSI_MUX, 0x11); + b43_radio_write(dev, + B2056_TX1 | B2056_TX_TX_SSI_MUX, 0x11); + } + } + } + + if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) { + b43_maskset32(dev, B43_MMIO_MACCTL, ~0, 0x200000); + b43_read32(dev, B43_MMIO_MACCTL); + udelay(1); + } + + if (dev->phy.rev >= 7) { + b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD, + ~B43_NPHY_TXPCTL_CMD_INIT, 0x19); + b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT, + ~B43_NPHY_TXPCTL_INIT_PIDXI1, 0x19); + } else { + b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD, + ~B43_NPHY_TXPCTL_CMD_INIT, 0x40); + if (dev->phy.rev > 1) + b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT, + ~B43_NPHY_TXPCTL_INIT_PIDXI1, 0x40); + } + + if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) + b43_maskset32(dev, B43_MMIO_MACCTL, ~0x200000, 0); + + b43_phy_write(dev, B43_NPHY_TXPCTL_N, + 0xF0 << B43_NPHY_TXPCTL_N_TSSID_SHIFT | + 3 << B43_NPHY_TXPCTL_N_NPTIL2_SHIFT); + b43_phy_write(dev, B43_NPHY_TXPCTL_ITSSI, + idle[0] << B43_NPHY_TXPCTL_ITSSI_0_SHIFT | + idle[1] << B43_NPHY_TXPCTL_ITSSI_1_SHIFT | + B43_NPHY_TXPCTL_ITSSI_BINF); + b43_phy_write(dev, B43_NPHY_TXPCTL_TPWR, + target[0] << B43_NPHY_TXPCTL_TPWR_0_SHIFT | + target[1] << B43_NPHY_TXPCTL_TPWR_1_SHIFT); + + for (c = 0; c < 2; c++) { + for (i = 0; i < 64; i++) { + num = 8 * (16 * b0[c] + b1[c] * i); + den = 32768 + a1[c] * i; + pwr = max((4 * num + den / 2) / den, -8); + if (dev->phy.rev < 3 && (i <= (31 - idle[c] + 1))) + pwr = max(pwr, target[c] + 1); + regval[i] = pwr; + } + b43_ntab_write_bulk(dev, B43_NTAB32(26 + c, 0), 64, regval); + } + + b43_nphy_tx_prepare_adjusted_power_table(dev); + /* + b43_ntab_write_bulk(dev, B43_NTAB16(26, 64), 84, nphy->adj_pwr_tbl); + b43_ntab_write_bulk(dev, B43_NTAB16(27, 64), 84, nphy->adj_pwr_tbl); + */ + + if (nphy->hang_avoid) + b43_nphy_stay_in_carrier_search(dev, false); +} + static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev) { struct b43_phy *phy = &dev->phy; @@ -4107,7 +4322,7 @@ int b43_phy_initn(struct b43_wldev *dev) b43_nphy_tx_power_ctrl(dev, false); b43_nphy_tx_power_fix(dev); b43_nphy_tx_power_ctl_idle_tssi(dev); - /* TODO N PHY TX Power Control Setup */ + b43_nphy_tx_power_ctl_setup(dev); b43_nphy_tx_gain_table_upload(dev); if (nphy->phyrxchain != 3) diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h index 5de8f74cc02f..fd12b386fea1 100644 --- a/drivers/net/wireless/b43/phy_n.h +++ b/drivers/net/wireless/b43/phy_n.h @@ -798,6 +798,7 @@ struct b43_phy_n { bool txpwrctrl; bool pwg_gain_5ghz; u8 tx_pwr_idx[2]; + s8 tx_power_offset[101]; u16 adj_pwr_tbl[84]; u16 txcal_bbmult; u16 txiqlocal_bestc[11]; -- GitLab From aeab57517cb7995626a60e8d1817fe95e5c07f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 3 Jan 2012 22:49:17 +0100 Subject: [PATCH 0067/1846] b43: N-PHY: add helper for getting gain table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also move the code to tables file. Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 81 ++------------------------ drivers/net/wireless/b43/tables_nphy.c | 65 ++++++++++++++++++--- drivers/net/wireless/b43/tables_nphy.h | 12 +--- 3 files changed, 64 insertions(+), 94 deletions(-) diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index fbbdbdad1019..d5d02aed9dba 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -85,24 +85,6 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev) (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)); } -/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */ -static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev) -{ - if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { - if (dev->phy.rev >= 6) { - if (dev->dev->chip_id == 47162) - return txpwrctrl_tx_gain_ipa_rev5; - return txpwrctrl_tx_gain_ipa_rev6; - } else if (dev->phy.rev >= 5) { - return txpwrctrl_tx_gain_ipa_rev5; - } else { - return txpwrctrl_tx_gain_ipa; - } - } else { - return txpwrctrl_tx_gain_ipa_5g; - } -} - /************************************************** * RF (just without b43_nphy_rf_control_intc_override) **************************************************/ @@ -2229,27 +2211,12 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev) */ for (i = 0; i < 2; i++) { - if (dev->phy.rev >= 3) { - 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]]; - } + txgain = *(b43_nphy_get_tx_gain_table(dev) + txpi[i]); + + if (dev->phy.rev >= 3) radio_gain = (txgain >> 16) & 0x1FFFF; - } else { - txgain = b43_ntab_tx_gain_rev0_1_2[txpi[i]]; + else radio_gain = (txgain >> 16) & 0x1FFF; - } if (dev->phy.rev >= 7) dac_gain = (txgain >> 8) & 0x7; @@ -2647,24 +2614,7 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev) int i; #endif - if (phy->rev >= 3) { - if (b43_nphy_ipa(dev)) { - table = b43_nphy_get_ipa_gain_table(dev); - } else { - if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) { - if (phy->rev == 3) - table = b43_ntab_tx_gain_rev3_5ghz; - if (phy->rev == 4) - table = b43_ntab_tx_gain_rev4_5ghz; - else - table = b43_ntab_tx_gain_rev5plus_5ghz; - } else { - table = b43_ntab_tx_gain_rev3plus_2ghz; - } - } - } else { - table = b43_ntab_tx_gain_rev0_1_2; - } + table = b43_nphy_get_tx_gain_table(dev); b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table); b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128, table); @@ -3354,32 +3304,13 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev) B43_NPHY_TXPCTL_STAT_BIDX_SHIFT; for (i = 0; i < 2; ++i) { + table = b43_nphy_get_tx_gain_table(dev); if (dev->phy.rev >= 3) { - enum ieee80211_band band = - b43_current_band(dev->wl); - - if (b43_nphy_ipa(dev)) { - table = b43_nphy_get_ipa_gain_table(dev); - } else { - if (band == IEEE80211_BAND_5GHZ) { - if (dev->phy.rev == 3) - table = b43_ntab_tx_gain_rev3_5ghz; - else if (dev->phy.rev == 4) - table = b43_ntab_tx_gain_rev4_5ghz; - else - table = b43_ntab_tx_gain_rev5plus_5ghz; - } else { - table = b43_ntab_tx_gain_rev3plus_2ghz; - } - } - target.ipa[i] = (table[index[i]] >> 16) & 0xF; target.pad[i] = (table[index[i]] >> 20) & 0xF; target.pga[i] = (table[index[i]] >> 24) & 0xF; target.txgm[i] = (table[index[i]] >> 28) & 0xF; } else { - table = b43_ntab_tx_gain_rev0_1_2; - target.ipa[i] = (table[index[i]] >> 16) & 0x3; target.pad[i] = (table[index[i]] >> 18) & 0x3; target.pga[i] = (table[index[i]] >> 20) & 0x7; diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index f7def13524dd..afcdca638ccf 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2214,7 +2214,7 @@ static const u16 b43_ntab_antswctl2g_r3[4][32] = { }; /* TX gain tables */ -const u32 b43_ntab_tx_gain_rev0_1_2[] = { +static const u32 b43_ntab_tx_gain_rev0_1_2[] = { 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42, 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44, 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844, @@ -2249,7 +2249,7 @@ const u32 b43_ntab_tx_gain_rev0_1_2[] = { 0x03801442, 0x03801344, 0x03801342, 0x00002b00, }; -const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = { +static const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = { 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e, 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037, 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e, @@ -2284,7 +2284,7 @@ const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = { 0x1041003c, 0x1041003b, 0x10410039, 0x10410037, }; -const u32 b43_ntab_tx_gain_rev3_5ghz[] = { +static const u32 b43_ntab_tx_gain_rev3_5ghz[] = { 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e, 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037, 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e, @@ -2319,7 +2319,7 @@ const u32 b43_ntab_tx_gain_rev3_5ghz[] = { 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037, }; -const u32 b43_ntab_tx_gain_rev4_5ghz[] = { +static const u32 b43_ntab_tx_gain_rev4_5ghz[] = { 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e, 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037, 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e, @@ -2354,7 +2354,7 @@ const u32 b43_ntab_tx_gain_rev4_5ghz[] = { 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034, }; -const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = { +static const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = { 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044, 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c, 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e, @@ -2389,7 +2389,7 @@ const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = { 0x0062003b, 0x00620039, 0x00620037, 0x00620035, }; -const u32 txpwrctrl_tx_gain_ipa[] = { +static const u32 txpwrctrl_tx_gain_ipa[] = { 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029, 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025, 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029, @@ -2424,7 +2424,7 @@ const u32 txpwrctrl_tx_gain_ipa[] = { 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025, }; -const u32 txpwrctrl_tx_gain_ipa_rev5[] = { +static const u32 txpwrctrl_tx_gain_ipa_rev5[] = { 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029, 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025, 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029, @@ -2459,7 +2459,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev5[] = { 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025, }; -const u32 txpwrctrl_tx_gain_ipa_rev6[] = { +static const u32 txpwrctrl_tx_gain_ipa_rev6[] = { 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029, 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025, 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029, @@ -2494,7 +2494,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev6[] = { 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025, }; -const u32 txpwrctrl_tx_gain_ipa_5g[] = { +static const u32 txpwrctrl_tx_gain_ipa_5g[] = { 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031, 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b, 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027, @@ -3126,6 +3126,53 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev) B43_WARN_ON(1); } +/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */ +static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev) +{ + if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { + if (dev->phy.rev >= 6) { + if (dev->dev->chip_id == 47162) + return txpwrctrl_tx_gain_ipa_rev5; + return txpwrctrl_tx_gain_ipa_rev6; + } else if (dev->phy.rev >= 5) { + return txpwrctrl_tx_gain_ipa_rev5; + } else { + return txpwrctrl_tx_gain_ipa; + } + } else { + return txpwrctrl_tx_gain_ipa_5g; + } +} + +const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev) +{ + enum ieee80211_band band = b43_current_band(dev->wl); + struct ssb_sprom *sprom = dev->dev->bus_sprom; + + if (dev->phy.rev < 3) + return b43_ntab_tx_gain_rev0_1_2; + + /* rev 3+ */ + if ((dev->phy.n->ipa2g_on && band == IEEE80211_BAND_2GHZ) || + (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)) { + return b43_nphy_get_ipa_gain_table(dev); + } else if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) { + if (dev->phy.rev == 3) + return b43_ntab_tx_gain_rev3_5ghz; + if (dev->phy.rev == 4) + return sprom->fem.ghz5.extpa_gain == 3 ? + b43_ntab_tx_gain_rev4_5ghz : + b43_ntab_tx_gain_rev4_5ghz; /* FIXME */ + else + return b43_ntab_tx_gain_rev5plus_5ghz; + } else { + if (dev->phy.rev >= 5 && sprom->fem.ghz5.extpa_gain == 3) + return b43_ntab_tx_gain_rev3plus_2ghz; /* FIXME */ + else + return b43_ntab_tx_gain_rev3plus_2ghz; + } +} + struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( struct b43_wldev *dev, bool ghz5, bool ext_lna) { diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h index 97038c481930..2a9d5f14af9c 100644 --- a/drivers/net/wireless/b43/tables_nphy.h +++ b/drivers/net/wireless/b43/tables_nphy.h @@ -177,16 +177,8 @@ void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset, void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev); void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev); -extern const u32 b43_ntab_tx_gain_rev0_1_2[]; -extern const u32 b43_ntab_tx_gain_rev3plus_2ghz[]; -extern const u32 b43_ntab_tx_gain_rev3_5ghz[]; -extern const u32 b43_ntab_tx_gain_rev4_5ghz[]; -extern const u32 b43_ntab_tx_gain_rev5plus_5ghz[]; - -extern const u32 txpwrctrl_tx_gain_ipa[]; -extern const u32 txpwrctrl_tx_gain_ipa_rev5[]; -extern const u32 txpwrctrl_tx_gain_ipa_rev6[]; -extern const u32 txpwrctrl_tx_gain_ipa_5g[]; +const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev); + extern const u16 tbl_iqcal_gainparams[2][9][8]; extern const struct nphy_txiqcal_ladder ladder_lo[]; extern const struct nphy_txiqcal_ladder ladder_iq[]; -- GitLab From 603431e9e2cb158817c8403e100bb495755a2395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 3 Jan 2012 22:49:18 +0100 Subject: [PATCH 0068/1846] b43: N-PHY: fix typos in RF 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/phy_n.c | 6 +++--- drivers/net/wireless/b43/tables_nphy.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index d5d02aed9dba..f1a856874a92 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -211,7 +211,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field, reg = (i == 0) ? B43_NPHY_RFCTL_INTC1 : B43_NPHY_RFCTL_INTC2; - b43_phy_mask(dev, reg, 0xFBFF); + b43_phy_set(dev, reg, 0x400); switch (field) { case 0: @@ -227,7 +227,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field, b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_START); for (j = 0; j < 100; j++) { - if (b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_START) { + if (!(b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_START)) { j = 0; break; } @@ -246,7 +246,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field, b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_RXTX); for (j = 0; j < 100; j++) { - if (b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_RXTX) { + if (!(b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_RXTX)) { j = 0; break; } diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index afcdca638ccf..8d96454081ac 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2739,11 +2739,11 @@ const struct nphy_rf_control_override_rev3 tbl_rf_control_override_rev3[] = { { 0x0001, 0, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0002 (fls 2) */ { 0x0002, 1, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0004 (fls 3) */ { 0x0004, 2, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0008 (fls 4) */ - { 0x0016, 4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */ + { 0x0010, 4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */ { 0x0020, 5, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0020 (fls 6) */ { 0x0040, 6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0040 (fls 7) */ - { 0x0080, 6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */ - { 0x0100, 7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */ + { 0x0080, 7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */ + { 0x0100, 8, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */ { 0x0007, 0, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0200 (fls 10) */ { 0x0070, 4, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0400 (fls 11) */ { 0xE000, 13, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0800 (fls 12) */ -- GitLab From 34c5cf205ec27e170b7061f43cf6390486be9a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 3 Jan 2012 22:49:19 +0100 Subject: [PATCH 0069/1846] b43: N-PHY: upload PAPD PGA gain delta table 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 | 11 +++++------ drivers/net/wireless/b43/tables_nphy.c | 5 +++++ drivers/net/wireless/b43/tables_nphy.h | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index f1a856874a92..f6ac18139b10 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -2607,12 +2607,9 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev) struct b43_phy *phy = &dev->phy; const u32 *table = NULL; -#if 0 - TODO: b43_ntab_papd_pga_gain_delta_ipa_2* u32 rfpwr_offset; u8 pga_gain; int i; -#endif table = b43_nphy_get_tx_gain_table(dev); b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table); @@ -2621,19 +2618,21 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev) if (phy->rev >= 3) { #if 0 nphy->gmval = (table[0] >> 16) & 0x7000; +#endif for (i = 0; i < 128; i++) { pga_gain = (table[i] >> 24) & 0xF; if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) - rfpwr_offset = b43_ntab_papd_pga_gain_delta_ipa_2g[pga_gain]; + rfpwr_offset = + b43_ntab_papd_pga_gain_delta_ipa_2g[pga_gain]; else - rfpwr_offset = b43_ntab_papd_pga_gain_delta_ipa_5g[pga_gain]; + rfpwr_offset = + 0; /* FIXME */ b43_ntab_write(dev, B43_NTAB32(26, 576 + i), rfpwr_offset); b43_ntab_write(dev, B43_NTAB32(27, 576 + i), rfpwr_offset); } -#endif } } diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index 8d96454081ac..f0d8377429c6 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2529,6 +2529,11 @@ static const u32 txpwrctrl_tx_gain_ipa_5g[] = { 0x70f70021, 0x70f70020, 0x70f70020, 0x70f7001f, }; +const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[] = { + -114, -108, -98, -91, -84, -78, -70, -62, + -54, -46, -39, -31, -23, -15, -8, 0 +}; + const u16 tbl_iqcal_gainparams[2][9][8] = { { { 0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69 }, diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h index 2a9d5f14af9c..f348953c0230 100644 --- a/drivers/net/wireless/b43/tables_nphy.h +++ b/drivers/net/wireless/b43/tables_nphy.h @@ -179,6 +179,8 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev); const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev); +extern const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[]; + extern const u16 tbl_iqcal_gainparams[2][9][8]; extern const struct nphy_txiqcal_ladder ladder_lo[]; extern const struct nphy_txiqcal_ladder ladder_iq[]; -- GitLab From 3eb1fa7e0021bc03be1bf7f68b1913d959e29512 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 4 Jan 2012 14:52:51 -0800 Subject: [PATCH 0070/1846] brcm80211: make ethtool_ops const All usage of ethtool_ops should be const; also add comma at end of initializer list. Signed-off-by: Stephen Hemminger Acked-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index eb9eb766ac27..c3980c50a997 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -590,8 +590,8 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, sprintf(info->bus_info, "%s", dev_name(drvr->dev)); } -static struct ethtool_ops brcmf_ethtool_ops = { - .get_drvinfo = brcmf_ethtool_get_drvinfo +static const struct ethtool_ops brcmf_ethtool_ops = { + .get_drvinfo = brcmf_ethtool_get_drvinfo, }; static int brcmf_ethtool(struct brcmf_pub *drvr, void __user *uaddr) -- GitLab From e0c9a0219a8f542e3946fe972a68aacf8c3f906c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 5 Jan 2012 01:05:30 +0100 Subject: [PATCH 0071/1846] b43: N-PHY: implement RSSI calibration for rev3+ 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 | 193 ++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index f6ac18139b10..945aa5267d09 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -85,6 +85,13 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev) (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)); } +/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */ +static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev) +{ + return (b43_phy_read(dev, B43_NPHY_RFSEQCA) & B43_NPHY_RFSEQCA_RXEN) >> + B43_NPHY_RFSEQCA_RXEN_SHIFT; +} + /************************************************** * RF (just without b43_nphy_rf_control_intc_override) **************************************************/ @@ -1290,6 +1297,186 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf, return out; } +/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */ +static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev) +{ + struct b43_phy_n *nphy = dev->phy.n; + + u16 saved_regs_phy_rfctl[2]; + u16 saved_regs_phy[13]; + u16 regs_to_store[] = { + B43_NPHY_AFECTL_OVER1, B43_NPHY_AFECTL_OVER, + B43_NPHY_AFECTL_C1, B43_NPHY_AFECTL_C2, + B43_NPHY_TXF_40CO_B1S1, B43_NPHY_RFCTL_OVER, + B43_NPHY_TXF_40CO_B1S0, B43_NPHY_TXF_40CO_B32S1, + B43_NPHY_RFCTL_CMD, + B43_NPHY_RFCTL_LUT_TRSW_UP1, B43_NPHY_RFCTL_LUT_TRSW_UP2, + B43_NPHY_RFCTL_RSSIO1, B43_NPHY_RFCTL_RSSIO2 + }; + + u16 class; + + u16 clip_state[2]; + u16 clip_off[2] = { 0xFFFF, 0xFFFF }; + + u8 vcm_final = 0; + s8 offset[4]; + s32 results[8][4] = { }; + s32 results_min[4] = { }; + s32 poll_results[4] = { }; + + u16 *rssical_radio_regs = NULL; + u16 *rssical_phy_regs = NULL; + + u16 r; /* routing */ + u8 rx_core_state; + u8 core, i, j; + + class = b43_nphy_classifier(dev, 0, 0); + b43_nphy_classifier(dev, 7, 4); + b43_nphy_read_clip_detection(dev, clip_state); + b43_nphy_write_clip_detection(dev, clip_off); + + saved_regs_phy_rfctl[0] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1); + saved_regs_phy_rfctl[1] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2); + for (i = 0; i < ARRAY_SIZE(regs_to_store); i++) + saved_regs_phy[i] = b43_phy_read(dev, regs_to_store[i]); + + b43_nphy_rf_control_intc_override(dev, 0, 0, 7); + b43_nphy_rf_control_intc_override(dev, 1, 1, 7); + b43_nphy_rf_control_override(dev, 0x1, 0, 0, false); + b43_nphy_rf_control_override(dev, 0x2, 1, 0, false); + b43_nphy_rf_control_override(dev, 0x80, 1, 0, false); + b43_nphy_rf_control_override(dev, 0x40, 1, 0, false); + + if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) { + b43_nphy_rf_control_override(dev, 0x20, 0, 0, false); + b43_nphy_rf_control_override(dev, 0x10, 1, 0, false); + } else { + b43_nphy_rf_control_override(dev, 0x10, 0, 0, false); + b43_nphy_rf_control_override(dev, 0x20, 1, 0, false); + } + + rx_core_state = b43_nphy_get_rx_core_state(dev); + for (core = 0; core < 2; core++) { + if (!(rx_core_state & (1 << core))) + continue; + r = core ? B2056_RX1 : B2056_RX0; + b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, 2); + b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 1, 2); + for (i = 0; i < 8; i++) { + b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3, + i << 2); + b43_nphy_poll_rssi(dev, 2, results[i], 8); + } + for (i = 0; i < 4; i++) { + s32 curr; + s32 mind = 40; + s32 minpoll = 249; + u8 minvcm = 0; + if (2 * core != i) + continue; + for (j = 0; j < 8; j++) { + curr = results[j][i] * results[j][i] + + results[j][i + 1] * results[j][i]; + if (curr < mind) { + mind = curr; + minvcm = j; + } + if (results[j][i] < minpoll) + minpoll = results[j][i]; + } + vcm_final = minvcm; + results_min[i] = minpoll; + } + b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3, + vcm_final << 2); + for (i = 0; i < 4; i++) { + if (core != i / 2) + continue; + offset[i] = -results[vcm_final][i]; + if (offset[i] < 0) + offset[i] = -((abs(offset[i]) + 4) / 8); + else + offset[i] = (offset[i] + 4) / 8; + if (results_min[i] == 248) + offset[i] = -32; + b43_nphy_scale_offset_rssi(dev, 0, offset[i], + (i / 2 == 0) ? 1 : 2, + (i % 2 == 0) ? 0 : 1, + 2); + } + } + for (core = 0; core < 2; core++) { + if (!(rx_core_state & (1 << core))) + continue; + for (i = 0; i < 2; i++) { + b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, i); + b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 1, i); + b43_nphy_poll_rssi(dev, i, poll_results, 8); + for (j = 0; j < 4; j++) { + if (j / 2 == core) + offset[j] = 232 - poll_results[j]; + if (offset[j] < 0) + offset[j] = -(abs(offset[j] + 4) / 8); + else + offset[j] = (offset[j] + 4) / 8; + b43_nphy_scale_offset_rssi(dev, 0, + offset[2 * core], core + 1, j % 2, i); + } + } + } + + b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, saved_regs_phy_rfctl[0]); + b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, saved_regs_phy_rfctl[1]); + + b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX); + + b43_phy_set(dev, B43_NPHY_TXF_40CO_B1S1, 0x1); + b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_START); + b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1); + + b43_phy_set(dev, B43_NPHY_RFCTL_OVER, 0x1); + b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_RXTX); + b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1); + + for (i = 0; i < ARRAY_SIZE(regs_to_store); i++) + b43_phy_write(dev, regs_to_store[i], saved_regs_phy[i]); + + /* Store for future configuration */ + if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { + rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G; + rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G; + } else { + rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G; + rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G; + } + rssical_radio_regs[0] = b43_radio_read(dev, 0x602B); + rssical_radio_regs[0] = b43_radio_read(dev, 0x702B); + rssical_phy_regs[0] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Z); + rssical_phy_regs[1] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Z); + rssical_phy_regs[2] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Z); + rssical_phy_regs[3] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Z); + rssical_phy_regs[4] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_X); + rssical_phy_regs[5] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_X); + rssical_phy_regs[6] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_X); + rssical_phy_regs[7] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_X); + rssical_phy_regs[8] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Y); + rssical_phy_regs[9] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Y); + rssical_phy_regs[10] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Y); + rssical_phy_regs[11] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Y); + + /* Remember for which channel we store configuration */ + if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) + nphy->rssical_chanspec_2G.center_freq = dev->phy.channel_freq; + else + nphy->rssical_chanspec_5G.center_freq = dev->phy.channel_freq; + + /* End of calibration, restore configuration */ + b43_nphy_classifier(dev, 7, class); + b43_nphy_write_clip_detection(dev, clip_state); +} + /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */ static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type) { @@ -1454,12 +1641,6 @@ static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type) b43_nphy_reset_cca(dev); } -/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */ -static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev) -{ - /* TODO */ -} - /* * RSSI Calibration * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal -- GitLab From 3084f3b65c178228bece6f7b166a19f3e38a75d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 3 Jan 2012 22:49:21 +0100 Subject: [PATCH 0072/1846] b43: N-PHY: trivial: change save&rest order in RSSI polling 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 945aa5267d09..108118820b36 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -1220,12 +1220,12 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf, u16 s[2]; if (dev->phy.rev >= 3) { - save_regs_phy[0] = b43_phy_read(dev, + save_regs_phy[0] = b43_phy_read(dev, B43_NPHY_AFECTL_C1); + save_regs_phy[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C2); + save_regs_phy[2] = b43_phy_read(dev, B43_NPHY_RFCTL_LUT_TRSW_UP1); - save_regs_phy[1] = b43_phy_read(dev, + save_regs_phy[3] = b43_phy_read(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2); - save_regs_phy[2] = b43_phy_read(dev, B43_NPHY_AFECTL_C1); - save_regs_phy[3] = b43_phy_read(dev, B43_NPHY_AFECTL_C2); save_regs_phy[4] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1); save_regs_phy[5] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER); save_regs_phy[6] = b43_phy_read(dev, B43_NPHY_TXF_40CO_B1S0); @@ -1274,12 +1274,12 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf, b43_phy_write(dev, B43_NPHY_GPIO_SEL, save_regs_phy[8]); if (dev->phy.rev >= 3) { + b43_phy_write(dev, B43_NPHY_AFECTL_C1, save_regs_phy[0]); + b43_phy_write(dev, B43_NPHY_AFECTL_C2, save_regs_phy[1]); b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP1, - save_regs_phy[0]); + save_regs_phy[2]); b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2, - save_regs_phy[1]); - b43_phy_write(dev, B43_NPHY_AFECTL_C1, save_regs_phy[2]); - b43_phy_write(dev, B43_NPHY_AFECTL_C2, save_regs_phy[3]); + save_regs_phy[3]); b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, save_regs_phy[4]); b43_phy_write(dev, B43_NPHY_AFECTL_OVER, save_regs_phy[5]); b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S0, save_regs_phy[6]); -- GitLab From 884dd24499df823f5c167223c7ae93bd764e2e4f Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:39 -0800 Subject: [PATCH 0073/1846] rtlwifi: Neaten RT_ASSERT, RT_TRACE, RTPRINT, RT_PRINT_DATA macros Make the macros a bit more readable. Use do {...} while (0) without terminating semicolons. Add missing terminating semicolon to a few uses. Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/debug.h | 88 +++++++++----------- drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 2 +- drivers/net/wireless/rtlwifi/usb.c | 6 +- 5 files changed, 47 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index 160dd0685213..802c491b3d86 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -156,53 +156,47 @@ enum dbgp_flag_e { DBGP_TYPE_MAX }; -#define RT_ASSERT(_exp, fmt) \ - do { \ - if (!(_exp)) { \ - printk(KERN_DEBUG "%s:%s(): ", KBUILD_MODNAME, \ - __func__); \ - printk fmt; \ - } \ - } while (0); - -#define RT_TRACE(rtlpriv, comp, level, fmt)\ - do { \ - if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \ - ((level) <= rtlpriv->dbg.global_debuglevel))) {\ - printk(KERN_DEBUG "%s:%s():<%lx-%x> ", KBUILD_MODNAME, \ - __func__, in_interrupt(), in_atomic()); \ - printk fmt; \ - } \ - } while (0); - -#define RTPRINT(rtlpriv, dbgtype, dbgflag, printstr) \ - do { \ - if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \ - printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ - printk printstr; \ - } \ - } while (0); - -#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \ - _hexdatalen) \ - do {\ - if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) &&\ - (_level <= rtlpriv->dbg.global_debuglevel))) { \ - int __i; \ - u8* ptr = (u8 *)_hexdata; \ - printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ - printk("In process \"%s\" (pid %i):", current->comm,\ - current->pid); \ - printk(_titlestring); \ - for (__i = 0; __i < (int)_hexdatalen; __i++) { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4)\ - == 0) ? " " : " ");\ - if (((__i + 1) % 16) == 0) \ - printk("\n"); \ - } \ - printk(KERN_DEBUG "\n"); \ - } \ - } while (0); +#define RT_ASSERT(_exp, fmt) \ +do { \ + if (!(_exp)) { \ + printk(KERN_DEBUG "%s:%s(): ", \ + KBUILD_MODNAME, __func__); \ + printk fmt; \ + } \ +} while (0) + +#define RT_TRACE(rtlpriv, comp, level, fmt) \ +do { \ + if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \ + ((level) <= rtlpriv->dbg.global_debuglevel))) { \ + printk(KERN_DEBUG "%s:%s():<%lx-%x> ", \ + KBUILD_MODNAME, __func__, \ + in_interrupt(), in_atomic()); \ + printk fmt; \ + } \ +} while (0) + +#define RTPRINT(rtlpriv, dbgtype, dbgflag, printstr) \ +do { \ + if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \ + printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ + printk printstr; \ + } \ +} while (0) + +#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \ + _hexdatalen) \ +do { \ + if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) && \ + (_level <= rtlpriv->dbg.global_debuglevel))) { \ + printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ + pr_cont("In process \"%s\" (pid %i):", \ + current->comm, current->pid); \ + printk(_titlestring); \ + print_hex_dump_bytes("", DUMP_PREFIX_NONE, \ + _hexdata, _hexdatalen); \ + } \ +} while (0) void rtl_dbgp_flag_init(struct ieee80211_hw *hw); #endif diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c index 3b585aadabfc..ce9eea94bb53 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c @@ -374,7 +374,7 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("Switch to %s bandwidth\n", rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")) + "20MHz" : "40MHz")); if (is_hal_stop(rtlhal)) { rtlphy->set_bwmode_inprogress = false; diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c index e49cf2244c75..df491d38eccc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c @@ -360,7 +360,7 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("Switch to %s bandwidth\n", rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")) + "20MHz" : "40MHz")); if (is_hal_stop(rtlhal)) { rtlphy->set_bwmode_inprogress = false; return; diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index 9d89d7ccdafb..c8c4cf9240d3 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -1617,7 +1617,7 @@ static void _rtl92de_read_txpower_info(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Is D cut,Internal PA0 %d Internal PA1 %d\n", rtlefuse->internal_pa_5g[0], - rtlefuse->internal_pa_5g[1])) + rtlefuse->internal_pa_5g[1])); } rtlefuse->eeprom_c9 = hwinfo[EEPROM_RF_OPT6]; rtlefuse->eeprom_cc = hwinfo[EEPROM_RF_OPT7]; diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index e956fa71d040..1b8e68e70f8a 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -414,7 +414,7 @@ static struct sk_buff *_rtl_prep_rx_urb(struct ieee80211_hw *hw, gfp_mask); if (!skb) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to __dev_alloc_skb!!\n")) + ("Failed to __dev_alloc_skb!!\n")); return ERR_PTR(-ENOMEM); } @@ -632,14 +632,14 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw) urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to alloc URB!!\n")) + ("Failed to alloc URB!!\n")); goto err_out; } skb = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL); if (IS_ERR(skb)) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to prep_rx_urb!!\n")) + ("Failed to prep_rx_urb!!\n")); err = PTR_ERR(skb); goto err_out; } -- GitLab From af08687b4e6d44dcdb04b519e718eb58ecb99050 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:40 -0800 Subject: [PATCH 0074/1846] rtlwifi: Standardize RT_PRINT_DATA macro and uses Use a single printk(KERN_DEBUG to emit the header line to avoid any possible output interleaving. Remove unnecessary parentheses from the calling uses. Standardize header arg without trailing \n or colon. Fix a few pairwiase/pairwise typos. Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/debug.h | 7 +++---- drivers/net/wireless/rtlwifi/efuse.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 9 ++++----- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 4 ++-- drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 3 +-- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 8 ++++---- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 4 ++-- drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 4 ++-- 12 files changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index 802c491b3d86..588986a1e213 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -189,10 +189,9 @@ do { \ do { \ if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) && \ (_level <= rtlpriv->dbg.global_debuglevel))) { \ - printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ - pr_cont("In process \"%s\" (pid %i):", \ - current->comm, current->pid); \ - printk(_titlestring); \ + printk(KERN_DEBUG "%s: In process \"%s\" (pid %i): %s\n", \ + KBUILD_MODNAME, current->comm, current->pid, \ + _titlestring); \ print_hex_dump_bytes("", DUMP_PREFIX_NONE, \ _hexdata, _hexdatalen); \ } \ diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index ed1058b71587..91fd3639d737 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c @@ -478,7 +478,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw) &rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base], 8); RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, - ("U-efuse\n"), tmpdata, 8); + "U-efuse", tmpdata, 8); if (!efuse_pg_packet_write(hw, (u8) offset, word_en, tmpdata)) { diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 931d97979b04..5401b32733d3 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -570,7 +570,7 @@ void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) ppsc->reg_max_lps_awakeintvl); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "rtl92c_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", + "rtl92c_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode", u1_h2c_set_pwrmode, 3); rtl92c_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); @@ -780,10 +780,10 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) totalpacketlen = TOTAL_RESERVED_PKT_LEN; RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, - "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", + "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL", &reserved_page_packet[0], totalpacketlen); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", + "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL", u1RsvdPageLoc, 3); @@ -800,8 +800,7 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("Set RSVD page location to Fw.\n")); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "H2C_RSVDPAGE:\n", - u1RsvdPageLoc, 3); + "H2C_RSVDPAGE", u1RsvdPageLoc, 3); rtl92c_fill_h2c_cmd(hw, H2C_RSVDPAGE, sizeof(u1RsvdPageLoc), u1RsvdPageLoc); } else diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index a3deaefa788c..2156378de1e8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -1570,7 +1570,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) ("RTL819X Not boot from eeprom, check it !!")); } - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP", hwinfo, HWSET_MAX_SIZE); eeprom_id = *((u16 *)&hwinfo[0]); @@ -2134,7 +2134,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, ("add one entry\n")); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, - "Pairwiase Key content :", + "Pairwise Key content", rtlpriv->sec.pairwise_key, rtlpriv->sec. key_len[PAIRWISE_KEYIDX]); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c index 4fb5ae24dee0..378bc5673464 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c @@ -821,8 +821,7 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, } RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, - "H2C Tx Cmd Content\n", - pdesc, TX_DESC_SIZE); + "H2C Tx Cmd Content", pdesc, TX_DESC_SIZE); } void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 124cf633861c..778c0e6e836b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -496,7 +496,7 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("RTL819X Not boot from eeprom, check it !!")); } - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, ("MAP\n"), + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, "MAP", hwinfo, HWSET_MAX_SIZE); eeprom_id = le16_to_cpu(*((__le16 *)&hwinfo[0])); if (eeprom_id != RTL8190_EEPROM_ID) { diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 9e0c8fcdf90f..487ee908d7c5 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -331,7 +331,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index, ("add one entry\n")); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, - "Pairwiase Key content :", + "Pairwise Key content", rtlpriv->sec.pairwise_key, rtlpriv->sec. key_len[PAIRWISE_KEYIDX]); diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index b3cc7b949992..128cfcd09fa9 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -677,7 +677,7 @@ void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw, SET_TX_DESC_HWSEQ_EN(pdesc, 1); SET_TX_DESC_PKT_ID(pdesc, 8); } - RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content\n", + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content", pdesc, RTL_TX_DESC_SIZE); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c index 82f060bdbc0b..db6972ffe503 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c @@ -565,7 +565,7 @@ void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode, ppsc->reg_max_lps_awakeintvl); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", + "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode", u1_h2c_set_pwrmode, 3); rtl92d_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); } @@ -757,10 +757,10 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG); totalpacketlen = TOTAL_RESERVED_PKT_LEN; RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, - "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", + "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL", &reserved_page_packet[0], totalpacketlen); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", + "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL", u1RsvdPageLoc, 3); skb = dev_alloc_skb(totalpacketlen); memcpy((u8 *) skb_put(skb, totalpacketlen), &reserved_page_packet, @@ -773,7 +773,7 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("Set RSVD page location to Fw.\n")); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "H2C_RSVDPAGE:\n", u1RsvdPageLoc, 3); + "H2C_RSVDPAGE", u1RsvdPageLoc, 3); rtl92d_fill_h2c_cmd(hw, H2C_RSVDPAGE, sizeof(u1RsvdPageLoc), u1RsvdPageLoc); } else diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index c8c4cf9240d3..5c8a639582ad 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -1777,7 +1777,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("RTL819X Not boot from eeprom, check it !!")); } - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP", hwinfo, HWSET_MAX_SIZE); eeprom_id = *((u16 *)&hwinfo[0]); @@ -2279,7 +2279,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, ("add one entry\n")); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, - "Pairwiase Key content :", + "Pairwise Key content", rtlpriv->sec.pairwise_key, rtlpriv-> sec.key_len[PAIRWISE_KEYIDX]); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c index 3637c0c33525..e84b8d5e4b1b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c @@ -776,7 +776,7 @@ void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, } RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, - "H2C Tx Cmd Content\n", pdesc, TX_DESC_SIZE); + "H2C Tx Cmd Content", pdesc, TX_DESC_SIZE); wmb(); SET_TX_DESC_OWN(pdesc, 1); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index c474486e3911..f9ba077bc18f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -1636,7 +1636,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) HWSET_MAX_SIZE_92S); } - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP", hwinfo, HWSET_MAX_SIZE_92S); eeprom_id = *((u16 *)&hwinfo[0]); @@ -2453,7 +2453,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr, ("add one entry\n")); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, - "Pairwiase Key content :", + "Pairwise Key content", rtlpriv->sec.pairwise_key, rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); -- GitLab From f30d7507a8116e2099a9135c873411db8c0a3dc6 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:41 -0800 Subject: [PATCH 0075/1846] rtlwifi: Convert RT_TRACE macro to use ##__VA_ARGS__ Consolidate printks to avoid possible message interleaving and reduce the object size. Remove unnecessary RT_TRACE parentheses. Miscellaneous typo and grammar fixes. Add missing newlines to formats. Remove duplicate KERN_DEBUG prefixes. Coalesce formats. Align arguments. $ size drivers/net/wireless/rtlwifi/built-in.o* text data bss dec hex filename 594841 55333 129680 779854 be64e drivers/net/wireless/rtlwifi/built-in.o.new 607022 55333 138720 801075 c3933 drivers/net/wireless/rtlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 56 ++- drivers/net/wireless/rtlwifi/cam.c | 81 ++-- drivers/net/wireless/rtlwifi/core.c | 120 +++-- drivers/net/wireless/rtlwifi/debug.h | 7 +- drivers/net/wireless/rtlwifi/efuse.c | 31 +- drivers/net/wireless/rtlwifi/pci.c | 196 ++++---- drivers/net/wireless/rtlwifi/ps.c | 31 +- drivers/net/wireless/rtlwifi/rc.c | 2 +- drivers/net/wireless/rtlwifi/regd.c | 12 +- .../net/wireless/rtlwifi/rtl8192c/dm_common.c | 189 ++++---- .../net/wireless/rtlwifi/rtl8192c/fw_common.c | 69 ++- .../wireless/rtlwifi/rtl8192c/phy_common.c | 201 ++++----- drivers/net/wireless/rtlwifi/rtl8192ce/dm.c | 24 +- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 182 ++++---- drivers/net/wireless/rtlwifi/rtl8192ce/led.c | 16 +- drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 108 +++-- drivers/net/wireless/rtlwifi/rtl8192ce/rf.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 4 +- drivers/net/wireless/rtlwifi/rtl8192cu/dm.c | 24 +- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 179 ++++---- drivers/net/wireless/rtlwifi/rtl8192cu/led.c | 15 +- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 101 ++--- drivers/net/wireless/rtlwifi/rtl8192cu/phy.c | 121 +++-- drivers/net/wireless/rtlwifi/rtl8192cu/rf.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 36 +- drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 239 +++++----- drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 103 ++--- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 182 ++++---- drivers/net/wireless/rtlwifi/rtl8192de/led.c | 14 +- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 419 +++++++++--------- drivers/net/wireless/rtlwifi/rtl8192de/rf.c | 26 +- drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 8 +- drivers/net/wireless/rtlwifi/rtl8192se/dm.c | 30 +- drivers/net/wireless/rtlwifi/rtl8192se/fw.c | 66 +-- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 155 ++++--- drivers/net/wireless/rtlwifi/rtl8192se/led.c | 15 +- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 200 ++++----- drivers/net/wireless/rtlwifi/rtl8192se/rf.c | 60 ++- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 2 +- drivers/net/wireless/rtlwifi/usb.c | 37 +- 44 files changed, 1613 insertions(+), 1784 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index 8d6eb0f56c03..fa16b1d708fe 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -211,7 +211,7 @@ static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw, */ if (get_rf_type(rtlphy) == RF_1T2R || get_rf_type(rtlphy) == RF_2T2R) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("1T2R or 2T2R\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T2R or 2T2R\n"); ht_cap->mcs.rx_mask[0] = 0xFF; ht_cap->mcs.rx_mask[1] = 0xFF; @@ -220,7 +220,7 @@ static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw, ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); } else if (get_rf_type(rtlphy) == RF_1T1R) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("1T1R\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T1R\n"); ht_cap->mcs.rx_mask[0] = 0xFF; ht_cap->mcs.rx_mask[1] = 0x00; @@ -302,9 +302,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) /* <4> set mac->sband to wiphy->sband */ hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Err BAND %d\n", - rtlhal->current_bandtype)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Err BAND %d\n", + rtlhal->current_bandtype); } } /* <5> set hw caps */ @@ -436,13 +435,13 @@ int rtl_init_core(struct ieee80211_hw *hw) * mac80211 hw in _rtl_init_mac80211. */ if (rtl_regd_init(hw, rtl_reg_notifier)) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("REGD init failed\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "REGD init failed\n"); return 1; } else { /* CRDA regd hint must after init CRDA */ if (regulatory_hint(hw->wiphy, rtlpriv->regd.alpha2)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("regulatory_hint fail\n")); + "regulatory_hint fail\n"); } } @@ -922,17 +921,17 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) return false; RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, - ("%s ACT_ADDBAREQ From :%pM\n", - is_tx ? "Tx" : "Rx", hdr->addr2)); + "%s ACT_ADDBAREQ From :%pM\n", + is_tx ? "Tx" : "Rx", hdr->addr2); break; case ACT_ADDBARSP: RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, - ("%s ACT_ADDBARSP From :%pM\n", - is_tx ? "Tx" : "Rx", hdr->addr2)); + "%s ACT_ADDBARSP From :%pM\n", + is_tx ? "Tx" : "Rx", hdr->addr2); break; case ACT_DELBA: RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, - ("ACT_ADDBADEL From :%pM\n", hdr->addr2)); + "ACT_ADDBADEL From :%pM\n", hdr->addr2); break; } break; @@ -975,8 +974,8 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) * 67 : UDP BOOTP server */ RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), - DBG_DMESG, ("dhcp %s !!\n", - (is_tx) ? "Tx" : "Rx")); + DBG_DMESG, "dhcp %s !!\n", + is_tx ? "Tx" : "Rx"); if (is_tx) { rtl_lps_leave(hw); @@ -996,7 +995,7 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) return true; } else if (ETH_P_PAE == ether_type) { RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, - ("802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx")); + "802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx"); if (is_tx) { rtl_lps_leave(hw); @@ -1036,9 +1035,8 @@ int rtl_tx_agg_start(struct ieee80211_hw *hw, return -ENXIO; tid_data = &sta_entry->tids[tid]; - RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, - ("on ra = %pM tid = %d seq:%d\n", sta->addr, tid, - tid_data->seq_number)); + RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "on ra = %pM tid = %d seq:%d\n", + sta->addr, tid, tid_data->seq_number); *ssn = tid_data->seq_number; tid_data->agg.agg_state = RTL_AGG_START; @@ -1059,12 +1057,12 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw, return -EINVAL; if (!sta->addr) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("ra = NULL\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "ra = NULL\n"); return -EINVAL; } - RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, - ("on ra = %pM tid = %d\n", sta->addr, tid)); + RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "on ra = %pM tid = %d\n", + sta->addr, tid); if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; @@ -1087,12 +1085,12 @@ int rtl_tx_agg_oper(struct ieee80211_hw *hw, return -EINVAL; if (!sta->addr) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("ra = NULL\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "ra = NULL\n"); return -EINVAL; } - RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, - ("on ra = %pM tid = %d\n", sta->addr, tid)); + RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "on ra = %pM tid = %d\n", + sta->addr, tid); if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; @@ -1474,29 +1472,29 @@ void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len) (memcmp(mac->bssid, ap5_6, 3) == 0) || vendor == PEER_ATH) { vendor = PEER_ATH; - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>ath find\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>ath find\n"); } else if ((memcmp(mac->bssid, ap4_4, 3) == 0) || (memcmp(mac->bssid, ap4_5, 3) == 0) || (memcmp(mac->bssid, ap4_1, 3) == 0) || (memcmp(mac->bssid, ap4_2, 3) == 0) || (memcmp(mac->bssid, ap4_3, 3) == 0) || vendor == PEER_RAL) { - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>ral findn\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>ral find\n"); vendor = PEER_RAL; } else if (memcmp(mac->bssid, ap6_1, 3) == 0 || vendor == PEER_CISCO) { vendor = PEER_CISCO; - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>cisco find\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>cisco find\n"); } else if ((memcmp(mac->bssid, ap3_1, 3) == 0) || (memcmp(mac->bssid, ap3_2, 3) == 0) || (memcmp(mac->bssid, ap3_3, 3) == 0) || vendor == PEER_BROAD) { - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>broad find\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>broad find\n"); vendor = PEER_BROAD; } else if (memcmp(mac->bssid, ap7_1, 3) == 0 || vendor == PEER_MARV) { vendor = PEER_MARV; - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>marv find\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>marv find\n"); } mac->vendor = vendor; diff --git a/drivers/net/wireless/rtlwifi/cam.c b/drivers/net/wireless/rtlwifi/cam.c index dc36d7461caa..cbf5e3cdb44e 100644 --- a/drivers/net/wireless/rtlwifi/cam.c +++ b/drivers/net/wireless/rtlwifi/cam.c @@ -55,10 +55,10 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no, u8 entry_i; RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("key_cont_128:\n %x:%x:%x:%x:%x:%x\n", - key_cont_128[0], key_cont_128[1], - key_cont_128[2], key_cont_128[3], - key_cont_128[4], key_cont_128[5])); + "key_cont_128:\n %x:%x:%x:%x:%x:%x\n", + key_cont_128[0], key_cont_128[1], + key_cont_128[2], key_cont_128[3], + key_cont_128[4], key_cont_128[5]); for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { target_command = entry_i + CAM_CONTENT_COUNT * entry_no; @@ -73,14 +73,12 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no, rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], target_command); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE %x: %x\n", + rtlpriv->cfg->maps[WCAMI], target_content); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("WRITE %x: %x\n", - rtlpriv->cfg->maps[WCAMI], target_content)); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The Key ID is %d\n", entry_no)); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("WRITE %x: %x\n", - rtlpriv->cfg->maps[RWCAM], target_command)); + "The Key ID is %d\n", entry_no); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE %x: %x\n", + rtlpriv->cfg->maps[RWCAM], target_command); } else if (entry_i == 1) { @@ -94,10 +92,10 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no, rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], target_command); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("WRITE A4: %x\n", target_content)); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("WRITE A0: %x\n", target_command)); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A4: %x\n", + target_content); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A0: %x\n", + target_command); } else { @@ -114,15 +112,15 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no, target_command); udelay(100); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("WRITE A4: %x\n", target_content)); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("WRITE A0: %x\n", target_command)); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A4: %x\n", + target_content); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A0: %x\n", + target_command); } } - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("after set key, usconfig:%x\n", us_config)); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "after set key, usconfig:%x\n", + us_config); } u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, @@ -133,14 +131,13 @@ u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, struct rtl_priv *rtlpriv = rtl_priv(hw); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, " - "ulUseDK=%x MacAddr %pM\n", - ul_entry_idx, ul_key_id, ul_enc_alg, - ul_default_key, mac_addr)); + "EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, ulUseDK=%x MacAddr %pM\n", + ul_entry_idx, ul_key_id, ul_enc_alg, + ul_default_key, mac_addr); if (ul_key_id == TOTAL_CAM_ENTRY) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("<=== ulKeyId exceed!\n")); + "<=== ulKeyId exceed!\n"); return 0; } @@ -153,7 +150,7 @@ u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, rtl_cam_program_entry(hw, ul_entry_idx, mac_addr, (u8 *) key_content, us_config); - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("<===\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "<===\n"); return 1; @@ -166,7 +163,7 @@ int rtl_cam_delete_one_entry(struct ieee80211_hw *hw, u32 ul_command; struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("key_idx:%d\n", ul_key_id)); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "key_idx:%d\n", ul_key_id); ul_command = ul_key_id * CAM_CONTENT_COUNT; ul_command = ul_command | BIT(31) | BIT(16); @@ -175,9 +172,9 @@ int rtl_cam_delete_one_entry(struct ieee80211_hw *hw, rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("rtl_cam_delete_one_entry(): WRITE A4: %x\n", 0)); + "rtl_cam_delete_one_entry(): WRITE A4: %x\n", 0); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("rtl_cam_delete_one_entry(): WRITE A0: %x\n", ul_command)); + "rtl_cam_delete_one_entry(): WRITE A0: %x\n", ul_command); return 0; @@ -229,9 +226,9 @@ void rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index) rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("rtl_cam_mark_invalid(): WRITE A4: %x\n", ul_content)); + "rtl_cam_mark_invalid(): WRITE A4: %x\n", ul_content); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("rtl_cam_mark_invalid(): WRITE A0: %x\n", ul_command)); + "rtl_cam_mark_invalid(): WRITE A0: %x\n", ul_command); } EXPORT_SYMBOL(rtl_cam_mark_invalid); @@ -279,11 +276,11 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("rtl_cam_empty_entry(): WRITE A4: %x\n", - ul_content)); + "rtl_cam_empty_entry(): WRITE A4: %x\n", + ul_content); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("rtl_cam_empty_entry(): WRITE A0: %x\n", - ul_command)); + "rtl_cam_empty_entry(): WRITE A0: %x\n", + ul_command); } } @@ -297,8 +294,7 @@ u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr) u8 i, *addr; if (NULL == sta_addr) { - RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, - ("sta_addr is NULL.\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, "sta_addr is NULL\n"); return TOTAL_CAM_ENTRY; } /* Does STA already exist? */ @@ -311,8 +307,8 @@ u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr) for (entry_idx = 4; entry_idx < TOTAL_CAM_ENTRY; entry_idx++) { if ((bitmap & BIT(0)) == 0) { RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, - ("-----hwsec_cam_bitmap: 0x%x entry_idx=%d\n", - rtlpriv->sec.hwsec_cam_bitmap, entry_idx)); + "-----hwsec_cam_bitmap: 0x%x entry_idx=%d\n", + rtlpriv->sec.hwsec_cam_bitmap, entry_idx); rtlpriv->sec.hwsec_cam_bitmap |= BIT(0) << entry_idx; memcpy(rtlpriv->sec.hwsec_cam_sta_addr[entry_idx], sta_addr, ETH_ALEN); @@ -331,14 +327,13 @@ void rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr) u8 i, *addr; if (NULL == sta_addr) { - RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, - ("sta_addr is NULL.\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, "sta_addr is NULL\n"); } if ((sta_addr[0]|sta_addr[1]|sta_addr[2]|sta_addr[3]|\ sta_addr[4]|sta_addr[5]) == 0) { RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, - ("sta_addr is 00:00:00:00:00:00.\n")); + "sta_addr is 00:00:00:00:00:00\n"); return; } /* Does STA already exist? */ diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index 3f0f056fae9c..186c944c1436 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c @@ -114,7 +114,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, if (mac->vif) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("vif has been set!! mac->vif = 0x%p\n", mac->vif)); + "vif has been set!! mac->vif = 0x%p\n", mac->vif); return -EOPNOTSUPP; } @@ -125,7 +125,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, case NL80211_IFTYPE_STATION: if (mac->beacon_enabled == 1) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("NL80211_IFTYPE_STATION\n")); + "NL80211_IFTYPE_STATION\n"); mac->beacon_enabled = 0; rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, rtlpriv->cfg->maps @@ -134,7 +134,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, break; case NL80211_IFTYPE_ADHOC: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("NL80211_IFTYPE_ADHOC\n")); + "NL80211_IFTYPE_ADHOC\n"); mac->link_state = MAC80211_LINKED; rtlpriv->cfg->ops->set_bcn_reg(hw); @@ -148,7 +148,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, break; case NL80211_IFTYPE_AP: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("NL80211_IFTYPE_AP\n")); + "NL80211_IFTYPE_AP\n"); mac->link_state = MAC80211_LINKED; rtlpriv->cfg->ops->set_bcn_reg(hw); @@ -161,7 +161,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("operation mode %d is not support!\n", vif->type)); + "operation mode %d is not supported!\n", vif->type); err = -EOPNOTSUPP; goto out; } @@ -221,7 +221,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&rtlpriv->locks.conf_mutex); if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/ RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n")); + "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n"); } /*For IPS */ @@ -264,8 +264,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n", - hw->conf.long_frame_max_tx_count)); + "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n", + hw->conf.long_frame_max_tx_count); mac->retry_long = hw->conf.long_frame_max_tx_count; mac->retry_short = hw->conf.long_frame_max_tx_count; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT, @@ -320,7 +320,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) default: mac->bw_40 = false; RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not processed\n")); + "switch case not processed\n"); break; } @@ -369,12 +369,12 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw, mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] | rtlpriv->cfg->maps[MAC_RCR_AB]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Enable receive multicast frame.\n")); + "Enable receive multicast frame\n"); } else { mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] | rtlpriv->cfg->maps[MAC_RCR_AB]); RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Disable receive multicast frame.\n")); + "Disable receive multicast frame\n"); } } @@ -382,11 +382,11 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw, if (*new_flags & FIF_FCSFAIL) { mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Enable receive FCS error frame.\n")); + "Enable receive FCS error frame\n"); } else { mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Disable receive FCS error frame.\n")); + "Disable receive FCS error frame\n"); } } @@ -409,11 +409,11 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw, mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Enable receive control frame.\n")); + "Enable receive control frame\n"); } else { mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Disable receive control frame.\n")); + "Disable receive control frame\n"); } } @@ -421,11 +421,11 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw, if (*new_flags & FIF_OTHER_BSS) { mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Enable receive other BSS's frame.\n")); + "Enable receive other BSS's frame\n"); } else { mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP]; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("Disable receive other BSS's frame.\n")); + "Disable receive other BSS's frame\n"); } } } @@ -456,7 +456,7 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw, sta_entry->wireless_mode = WIRELESS_MODE_G; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("Add sta addr is %pM\n", sta->addr)); + "Add sta addr is %pM\n", sta->addr); rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); } return 0; @@ -469,7 +469,7 @@ static int rtl_op_sta_remove(struct ieee80211_hw *hw, struct rtl_sta_info *sta_entry; if (sta) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("Remove sta addr is %pM\n", sta->addr)); + "Remove sta addr is %pM\n", sta->addr); sta_entry = (struct rtl_sta_info *) sta->drv_priv; sta_entry->wireless_mode = 0; sta_entry->ratr_index = 0; @@ -514,7 +514,7 @@ static int rtl_op_conf_tx(struct ieee80211_hw *hw, if (queue >= AC_MAX) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("queue number %d is incorrect!\n", queue)); + "queue number %d is incorrect!\n", queue); return -EINVAL; } @@ -547,7 +547,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, bss_conf->enable_beacon)) { if (mac->beacon_enabled == 0) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("BSS_CHANGED_BEACON_ENABLED\n")); + "BSS_CHANGED_BEACON_ENABLED\n"); /*start hw beacon interrupt. */ /*rtlpriv->cfg->ops->set_bcn_reg(hw); */ @@ -565,7 +565,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, !bss_conf->enable_beacon)) { if (mac->beacon_enabled == 1) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("ADHOC DISABLE BEACON\n")); + "ADHOC DISABLE BEACON\n"); mac->beacon_enabled = 0; rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, @@ -575,7 +575,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, } if (changed & BSS_CHANGED_BEACON_INT) { RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE, - ("BSS_CHANGED_BEACON_INT\n")); + "BSS_CHANGED_BEACON_INT\n"); mac->beacon_interval = bss_conf->beacon_int; rtlpriv->cfg->ops->set_bcn_intv(hw); } @@ -604,7 +604,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, if (mac->opmode == NL80211_IFTYPE_STATION && sta) rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("BSS_CHANGED_ASSOC\n")); + "BSS_CHANGED_ASSOC\n"); } else { if (mac->link_state == MAC80211_LINKED) rtl_lps_leave(hw); @@ -619,20 +619,20 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, mac->vendor = PEER_UNKNOWN; RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("BSS_CHANGED_UN_ASSOC\n")); + "BSS_CHANGED_UN_ASSOC\n"); } } if (changed & BSS_CHANGED_ERP_CTS_PROT) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("BSS_CHANGED_ERP_CTS_PROT\n")); + "BSS_CHANGED_ERP_CTS_PROT\n"); mac->use_cts_protect = bss_conf->use_cts_prot; } if (changed & BSS_CHANGED_ERP_PREAMBLE) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, - ("BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", - bss_conf->use_short_preamble)); + "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", + bss_conf->use_short_preamble); mac->short_preamble = bss_conf->use_short_preamble; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE, @@ -641,7 +641,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, if (changed & BSS_CHANGED_ERP_SLOT) { RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("BSS_CHANGED_ERP_SLOT\n")); + "BSS_CHANGED_ERP_SLOT\n"); if (bss_conf->use_short_slot) mac->slot_time = RTL_SLOT_TIME_9; @@ -653,8 +653,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, } if (changed & BSS_CHANGED_HT) { - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("BSS_CHANGED_HT\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, "BSS_CHANGED_HT\n"); rcu_read_lock(); sta = get_sta(hw, vif, bss_conf->bssid); if (sta) { @@ -683,8 +682,8 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID, (u8 *) bss_conf->bssid); - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - ("%pM\n", bss_conf->bssid)); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, "%pM\n", + bss_conf->bssid); mac->vendor = PEER_UNKNOWN; memcpy(mac->bssid, bss_conf->bssid, 6); @@ -831,30 +830,30 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw, switch (action) { case IEEE80211_AMPDU_TX_START: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("IEEE80211_AMPDU_TX_START: TID:%d\n", tid)); + "IEEE80211_AMPDU_TX_START: TID:%d\n", tid); return rtl_tx_agg_start(hw, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid)); + "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid); return rtl_tx_agg_stop(hw, sta, tid); break; case IEEE80211_AMPDU_TX_OPERATIONAL: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid)); + "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid); rtl_tx_agg_oper(hw, sta, tid); break; case IEEE80211_AMPDU_RX_START: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("IEEE80211_AMPDU_RX_START:TID:%d\n", tid)); + "IEEE80211_AMPDU_RX_START:TID:%d\n", tid); break; case IEEE80211_AMPDU_RX_STOP: RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, - ("IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid)); + "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("IEEE80211_AMPDU_ERR!!!!:\n")); + "IEEE80211_AMPDU_ERR!!!!:\n"); return -EOPNOTSUPP; } return 0; @@ -867,7 +866,7 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw) mac->act_scanning = true; - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n"); if (mac->link_state == MAC80211_LINKED) { rtl_lps_leave(hw); @@ -888,7 +887,7 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("\n")); + RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n"); mac->act_scanning = false; /* Dual mac */ rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; @@ -921,13 +920,13 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("not open hw encryption\n")); + "not open hw encryption\n"); return -ENOSPC; /*User disabled HW-crypto */ } RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("%s hardware based encryption for keyidx: %d, mac: %pM\n", - cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, - sta ? sta->addr : bcast_addr)); + "%s hardware based encryption for keyidx: %d, mac: %pM\n", + cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, + sta ? sta->addr : bcast_addr); rtlpriv->sec.being_setkey = true; rtl_ips_nic_on(hw); mutex_lock(&rtlpriv->locks.conf_mutex); @@ -936,24 +935,23 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (key->cipher) { case WLAN_CIPHER_SUITE_WEP40: key_type = WEP40_ENCRYPTION; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:WEP40\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n"); break; case WLAN_CIPHER_SUITE_WEP104: - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("alg:WEP104\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n"); key_type = WEP104_ENCRYPTION; break; case WLAN_CIPHER_SUITE_TKIP: key_type = TKIP_ENCRYPTION; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:TKIP\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n"); break; case WLAN_CIPHER_SUITE_CCMP: key_type = AESCCMP_ENCRYPTION; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:CCMP\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n"); break; default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("alg_err:%x!!!!:\n", key->cipher)); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "alg_err:%x!!!!\n", + key->cipher); goto out_unlock; } if (key_type == WEP40_ENCRYPTION || @@ -995,8 +993,8 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, wep_only = true; rtlpriv->sec.pairwise_enc_algorithm = key_type; RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1" - " TKIP:2 AES:4 WEP104:5)\n", key_type)); + "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n", + key_type); rtlpriv->cfg->ops->enable_hw_sec(hw); } } @@ -1005,7 +1003,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, case SET_KEY: if (wep_only) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set WEP(group/pairwise) key\n")); + "set WEP(group/pairwise) key\n"); /* Pairwise key with an assigned MAC address. */ rtlpriv->sec.pairwise_enc_algorithm = key_type; rtlpriv->sec.group_enc_algorithm = key_type; @@ -1016,7 +1014,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, memcpy(mac_addr, zero_addr, ETH_ALEN); } else if (group_key) { /* group key */ RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set group key\n")); + "set group key\n"); /* group key */ rtlpriv->sec.group_enc_algorithm = key_type; /*set local buf about group key. */ @@ -1026,7 +1024,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, memcpy(mac_addr, bcast_addr, ETH_ALEN); } else { /* pairwise key */ RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set pairwise key\n")); + "set pairwise key\n"); if (!sta) { RT_ASSERT(false, ("pairwise key withnot" "mac_addr\n")); @@ -1056,7 +1054,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, break; case DISABLE_KEY: RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("disable key delete one entry\n")); + "disable key delete one entry\n"); /*set local buf about wep key. */ if (mac->opmode == NL80211_IFTYPE_AP) { if (sta) @@ -1077,7 +1075,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("cmd_err:%x!!!!:\n", cmd)); + "cmd_err:%x!!!!\n", cmd); } out_unlock: mutex_unlock(&rtlpriv->locks.conf_mutex); @@ -1106,8 +1104,8 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw) rtlpriv->rfkill.rfkill_state = radio_state; RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - (KERN_INFO "wireless radio switch turned %s\n", - radio_state ? "on" : "off")); + "wireless radio switch turned %s\n", + radio_state ? "on" : "off"); blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; wiphy_rfkill_set_hw_state(hw->wiphy, blocked); diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index 588986a1e213..8c1396933540 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -165,14 +165,13 @@ do { \ } \ } while (0) -#define RT_TRACE(rtlpriv, comp, level, fmt) \ +#define RT_TRACE(rtlpriv, comp, level, fmt, ...) \ do { \ if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \ ((level) <= rtlpriv->dbg.global_debuglevel))) { \ - printk(KERN_DEBUG "%s:%s():<%lx-%x> ", \ + printk(KERN_DEBUG "%s:%s():<%lx-%x> " fmt, \ KBUILD_MODNAME, __func__, \ - in_interrupt(), in_atomic()); \ - printk fmt; \ + in_interrupt(), in_atomic(), ##__VA_ARGS__); \ } \ } while (0) diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index 91fd3639d737..2885131cf1a0 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c @@ -162,8 +162,8 @@ void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value) const u32 efuse_len = rtlpriv->cfg->maps[EFUSE_REAL_CONTENT_SIZE]; - RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("Addr=%x Data =%x\n", address, value)); + RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "Addr=%x Data =%x\n", + address, value); if (address < efuse_len) { rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL], value); @@ -252,8 +252,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) if ((_offset + _size_byte) > rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]) { RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("read_efuse(): Invalid offset(%#x) with read " - "bytes(%#x)!!\n", _offset, _size_byte)); + "read_efuse(): Invalid offset(%#x) with read bytes(%#x)!!\n", + _offset, _size_byte); return; } @@ -395,9 +395,8 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw) result = false; RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("efuse_shadow_update_chk(): totalbytes(%#x), " - "hdr_num(%#x), words_need(%#x), efuse_used(%d)\n", - totalbytes, hdr_num, words_need, efuse_used)); + "efuse_shadow_update_chk(): totalbytes(%#x), hdr_num(%#x), words_need(%#x), efuse_used(%d)\n", + totalbytes, hdr_num, words_need, efuse_used); return result; } @@ -434,7 +433,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw) u8 word_en = 0x0F; u8 first_pg = false; - RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, ("--->\n")); + RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "--->\n"); if (!efuse_shadow_update_chk(hw)) { efuse_read_all_map(hw, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0]); @@ -443,7 +442,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw) rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("<---efuse out of capacity!!\n")); + "<---efuse out of capacity!!\n"); return false; } efuse_power_switch(hw, true, true); @@ -483,7 +482,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw) if (!efuse_pg_packet_write(hw, (u8) offset, word_en, tmpdata)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("PG section(%#x) fail!!\n", offset)); + "PG section(%#x) fail!!\n", offset); break; } } @@ -497,7 +496,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw) &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); - RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, ("<---\n")); + RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "<---\n"); return true; } @@ -634,8 +633,8 @@ static int efuse_one_byte_write(struct ieee80211_hw *hw, u16 addr, u8 data) struct rtl_priv *rtlpriv = rtl_priv(hw); u8 tmpidx = 0; - RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("Addr = %x Data=%x\n", addr, data)); + RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "Addr = %x Data=%x\n", + addr, data); rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 1, (u8) (addr & 0xff)); @@ -1006,7 +1005,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw, if (efuse_addr >= (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES)) { RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("efuse_addr(%#x) Out of size!!\n", efuse_addr)); + "efuse_addr(%#x) Out of size!!\n", efuse_addr); } return true; @@ -1046,8 +1045,8 @@ static u8 efuse_word_enable_data_write(struct ieee80211_hw *hw, u8 tmpdata[8]; memset(tmpdata, 0xff, PGPKT_DATA_SIZE); - RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, - ("word_en = %x efuse_addr=%x\n", word_en, efuse_addr)); + RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "word_en = %x efuse_addr=%x\n", + word_en, efuse_addr); if (!(word_en & BIT(0))) { tmpaddr = start_addr; diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 39e0907a3c4e..b52fef235754 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -170,7 +170,7 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -232,7 +232,7 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw) if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("PCI(Bridge) UNKNOWN.\n")); + "PCI(Bridge) UNKNOWN\n"); return; } @@ -286,7 +286,7 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("PCI(Bridge) UNKNOWN.\n")); + "PCI(Bridge) UNKNOWN\n"); return; } @@ -303,11 +303,10 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) u_pcibridge_aspmsetting); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PlatformEnableASPM():PciBridge busnumber[%x], " - "DevNumbe[%x], funcnumber[%x], Write reg[%x] = %x\n", - pcibridge_busnum, pcibridge_devnum, pcibridge_funcnum, - (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10), - u_pcibridge_aspmsetting)); + "PlatformEnableASPM():PciBridge busnumber[%x], DevNumbe[%x], funcnumber[%x], Write reg[%x] = %x\n", + pcibridge_busnum, pcibridge_devnum, pcibridge_funcnum, + (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10), + u_pcibridge_aspmsetting); udelay(50); @@ -382,9 +381,8 @@ static void rtl_pci_parse_configuration(struct pci_dev *pdev, pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &linkctrl_reg); pcipriv->ndis_adapter.linkctrl_reg = linkctrl_reg; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Link Control Register =%x\n", - pcipriv->ndis_adapter.linkctrl_reg)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Link Control Register =%x\n", + pcipriv->ndis_adapter.linkctrl_reg); pci_read_config_byte(pdev, 0x98, &tmp); tmp |= BIT(4); @@ -551,11 +549,10 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) skb_pull(skb, EM_HDR_LEN); RT_TRACE(rtlpriv, (COMP_INTR | COMP_SEND), DBG_TRACE, - ("new ring->idx:%d, " - "free: skb_queue_len:%d, free: seq:%x\n", - ring->idx, - skb_queue_len(&ring->queue), - *(u16 *) (skb->data + 22))); + "new ring->idx:%d, free: skb_queue_len:%d, free: seq:%x\n", + ring->idx, + skb_queue_len(&ring->queue), + *(u16 *) (skb->data + 22)); if (prio == TXCMD_QUEUE) { dev_kfree_skb(skb); @@ -593,11 +590,9 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) == 2) { RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, - ("more desc left, wake" - "skb_queue@%d,ring->idx = %d," - "skb_queue_len = 0x%d\n", - prio, ring->idx, - skb_queue_len(&ring->queue))); + "more desc left, wake skb_queue@%d, ring->idx = %d, skb_queue_len = 0x%d\n", + prio, ring->idx, + skb_queue_len(&ring->queue)); ieee80211_wake_queue(hw, skb_get_queue_mapping @@ -709,9 +704,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) new_skb = dev_alloc_skb(rtlpci->rxbuffersize); if (unlikely(!new_skb)) { - RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), - DBG_DMESG, - ("can't alloc skb for rx\n")); + RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), DBG_DMESG, + "can't alloc skb for rx\n"); goto done; } @@ -796,38 +790,37 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) /*<1> beacon related */ if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) { RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("beacon ok interrupt!\n")); + "beacon ok interrupt!\n"); } if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER])) { RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("beacon err interrupt!\n")); + "beacon err interrupt!\n"); } if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK]) { - RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("beacon interrupt!\n")); + RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "beacon interrupt!\n"); } if (inta & rtlpriv->cfg->maps[RTL_IMR_BcnInt]) { RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("prepare beacon for interrupt!\n")); + "prepare beacon for interrupt!\n"); tasklet_schedule(&rtlpriv->works.irq_prepare_bcn_tasklet); } /*<3> Tx related */ if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TXFOVW])) - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, ("IMR_TXFOVW!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "IMR_TXFOVW!\n"); if (inta & rtlpriv->cfg->maps[RTL_IMR_MGNTDOK]) { RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("Manage ok interrupt!\n")); + "Manage ok interrupt!\n"); _rtl_pci_tx_isr(hw, MGNT_QUEUE); } if (inta & rtlpriv->cfg->maps[RTL_IMR_HIGHDOK]) { RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("HIGH_QUEUE ok interrupt!\n")); + "HIGH_QUEUE ok interrupt!\n"); _rtl_pci_tx_isr(hw, HIGH_QUEUE); } @@ -835,7 +828,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtlpriv->link_info.num_tx_inperiod++; RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("BK Tx OK interrupt!\n")); + "BK Tx OK interrupt!\n"); _rtl_pci_tx_isr(hw, BK_QUEUE); } @@ -843,7 +836,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtlpriv->link_info.num_tx_inperiod++; RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("BE TX OK interrupt!\n")); + "BE TX OK interrupt!\n"); _rtl_pci_tx_isr(hw, BE_QUEUE); } @@ -851,7 +844,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtlpriv->link_info.num_tx_inperiod++; RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("VI TX OK interrupt!\n")); + "VI TX OK interrupt!\n"); _rtl_pci_tx_isr(hw, VI_QUEUE); } @@ -859,7 +852,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtlpriv->link_info.num_tx_inperiod++; RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("Vo TX OK interrupt!\n")); + "Vo TX OK interrupt!\n"); _rtl_pci_tx_isr(hw, VO_QUEUE); } @@ -868,25 +861,25 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtlpriv->link_info.num_tx_inperiod++; RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, - ("CMD TX OK interrupt!\n")); + "CMD TX OK interrupt!\n"); _rtl_pci_tx_isr(hw, TXCMD_QUEUE); } } /*<2> Rx related */ if (inta & rtlpriv->cfg->maps[RTL_IMR_ROK]) { - RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, ("Rx ok interrupt!\n")); + RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "Rx ok interrupt!\n"); _rtl_pci_rx_interrupt(hw); } if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RDU])) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("rx descriptor unavailable!\n")); + "rx descriptor unavailable!\n"); _rtl_pci_rx_interrupt(hw); } if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RXFOVW])) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, ("rx overflow !\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "rx overflow !\n"); _rtl_pci_rx_interrupt(hw); } @@ -1028,7 +1021,7 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, if (!ring || (unsigned long)ring & 0xFF) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Cannot allocate TX ring (prio = %d)\n", prio)); + "Cannot allocate TX ring (prio = %d)\n", prio); return -ENOMEM; } @@ -1039,8 +1032,8 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, rtlpci->tx_ring[prio].entries = entries; skb_queue_head_init(&rtlpci->tx_ring[prio].queue); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("queue:%d, ring_addr:%p\n", prio, ring)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "queue:%d, ring_addr:%p\n", + prio, ring); for (i = 0; i < entries; i++) { nextdescaddress = (u32) dma + @@ -1078,7 +1071,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw) if (!rtlpci->rx_ring[rx_queue_idx].desc || (unsigned long)rtlpci->rx_ring[rx_queue_idx].desc & 0xFF) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Cannot allocate RX ring\n")); + "Cannot allocate RX ring\n"); return -ENOMEM; } @@ -1355,7 +1348,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb, u8 temp_one = 1; if (ieee80211_is_auth(fc)) { - RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n")); + RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n"); rtl_ips_nic_on(hw); } @@ -1388,10 +1381,9 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb, if ((own == 1) && (hw_queue != BEACON_QUEUE)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("No more TX desc@%d, ring->idx = %d," - "idx = %d, skb_queue_len = 0x%d\n", - hw_queue, ring->idx, idx, - skb_queue_len(&ring->queue))); + "No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%d\n", + hw_queue, ring->idx, idx, + skb_queue_len(&ring->queue)); spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); return skb->len; @@ -1426,11 +1418,9 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb, hw_queue != BEACON_QUEUE) { RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, - ("less desc left, stop skb_queue@%d, " - "ring->idx = %d," - "idx = %d, skb_queue_len = 0x%d\n", - hw_queue, ring->idx, idx, - skb_queue_len(&ring->queue))); + "less desc left, stop skb_queue@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%d\n", + hw_queue, ring->idx, idx, + skb_queue_len(&ring->queue)); ieee80211_stop_queue(hw, skb_get_queue_mapping(skb)); } @@ -1497,7 +1487,7 @@ static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) err = _rtl_pci_init_trx_ring(hw); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("tx ring initialization failed")); + "tx ring initialization failed\n"); return err; } @@ -1519,12 +1509,12 @@ static int rtl_pci_start(struct ieee80211_hw *hw) err = rtlpriv->cfg->ops->hw_init(hw); if (err) { RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Failed to config hardware!\n")); + "Failed to config hardware!\n"); return err; } rtlpriv->cfg->ops->enable_interrupt(hw); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("enable_interrupt OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "enable_interrupt OK\n"); rtl_init_rx_config(hw); @@ -1535,7 +1525,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw) rtlpci->up_first_time = false; - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "OK\n"); return 0; } @@ -1622,20 +1612,20 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, switch (revisionid) { case RTL_PCI_REVISION_ID_8192PCIE: RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("8192 PCI-E is found - " - "vid/did=%x/%x\n", venderid, deviceid)); + "8192 PCI-E is found - vid/did=%x/%x\n", + venderid, deviceid); rtlhal->hw_type = HARDWARE_TYPE_RTL8192E; break; case RTL_PCI_REVISION_ID_8192SE: RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("8192SE is found - " - "vid/did=%x/%x\n", venderid, deviceid)); + "8192SE is found - vid/did=%x/%x\n", + venderid, deviceid); rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Err: Unknown device - " - "vid/did=%x/%x\n", venderid, deviceid)); + "Err: Unknown device - vid/did=%x/%x\n", + venderid, deviceid); rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; break; @@ -1646,18 +1636,18 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, deviceid == RTL_PCI_8188CE_DID) { rtlhal->hw_type = HARDWARE_TYPE_RTL8192CE; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("8192C PCI-E is found - " - "vid/did=%x/%x\n", venderid, deviceid)); + "8192C PCI-E is found - vid/did=%x/%x\n", + venderid, deviceid); } else if (deviceid == RTL_PCI_8192DE_DID || deviceid == RTL_PCI_8192DE_DID2) { rtlhal->hw_type = HARDWARE_TYPE_RTL8192DE; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("8192D PCI-E is found - " - "vid/did=%x/%x\n", venderid, deviceid)); + "8192D PCI-E is found - vid/did=%x/%x\n", + venderid, deviceid); } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Err: Unknown device -" - " vid/did=%x/%x\n", venderid, deviceid)); + "Err: Unknown device - vid/did=%x/%x\n", + venderid, deviceid); rtlhal->hw_type = RTL_DEFAULT_HARDWARE_TYPE; } @@ -1665,19 +1655,18 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) { if (revisionid == 0 || revisionid == 1) { if (revisionid == 0) { - RT_TRACE(rtlpriv, COMP_INIT, - DBG_LOUD, ("Find 92DE MAC0.\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "Find 92DE MAC0\n"); rtlhal->interfaceindex = 0; } else if (revisionid == 1) { RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Find 92DE MAC1.\n")); + "Find 92DE MAC1\n"); rtlhal->interfaceindex = 1; } } else { RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Unknown device - " - "VendorID/DeviceID=%x/%x, Revision=%x\n", - venderid, deviceid, revisionid)); + "Unknown device - VendorID/DeviceID=%x/%x, Revision=%x\n", + venderid, deviceid, revisionid); rtlhal->interfaceindex = 0; } } @@ -1693,8 +1682,8 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, if (bridge_pdev->vendor == pcibridge_vendors[tmp]) { pcipriv->ndis_adapter.pcibridge_vendor = tmp; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Pci Bridge Vendor is found index:" - " %d\n", tmp)); + "Pci Bridge Vendor is found index: %d\n", + tmp); break; } } @@ -1723,23 +1712,21 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, } RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("pcidev busnumber:devnumber:funcnumber:" - "vendor:link_ctl %d:%d:%d:%x:%x\n", - pcipriv->ndis_adapter.busnumber, - pcipriv->ndis_adapter.devnumber, - pcipriv->ndis_adapter.funcnumber, - pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg)); + "pcidev busnumber:devnumber:funcnumber:vendor:link_ctl %d:%d:%d:%x:%x\n", + pcipriv->ndis_adapter.busnumber, + pcipriv->ndis_adapter.devnumber, + pcipriv->ndis_adapter.funcnumber, + pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg); RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("pci_bridge busnumber:devnumber:funcnumber:vendor:" - "pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n", - pcipriv->ndis_adapter.pcibridge_busnum, - pcipriv->ndis_adapter.pcibridge_devnum, - pcipriv->ndis_adapter.pcibridge_funcnum, - pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor], - pcipriv->ndis_adapter.pcibridge_pciehdr_offset, - pcipriv->ndis_adapter.pcibridge_linkctrlreg, - pcipriv->ndis_adapter.amd_l1_patch)); + "pci_bridge busnumber:devnumber:funcnumber:vendor:pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n", + pcipriv->ndis_adapter.pcibridge_busnum, + pcipriv->ndis_adapter.pcibridge_devnum, + pcipriv->ndis_adapter.pcibridge_funcnum, + pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor], + pcipriv->ndis_adapter.pcibridge_pciehdr_offset, + pcipriv->ndis_adapter.pcibridge_linkctrlreg, + pcipriv->ndis_adapter.amd_l1_patch); rtl_pci_parse_configuration(pdev, hw); @@ -1828,10 +1815,9 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, } RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("mem mapped space: start: 0x%08lx len:%08lx " - "flags:%08lx, after map:0x%08lx\n", - pmem_start, pmem_len, pmem_flags, - rtlpriv->io.pci_mem_start)); + "mem mapped space: start: 0x%08lx len:%08lx flags:%08lx, after map:0x%08lx\n", + pmem_start, pmem_len, pmem_flags, + rtlpriv->io.pci_mem_start); /* Disable Clk Request */ pci_write_config_byte(pdev, 0x81, 0); @@ -1851,8 +1837,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, rtlpriv->cfg->ops->read_eeprom_info(hw); if (rtlpriv->cfg->ops->init_sw_vars(hw)) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't init_sw_vars.\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n"); goto fail3; } @@ -1865,22 +1850,21 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, err = rtl_init_core(hw); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't allocate sw for mac80211.\n")); + "Can't allocate sw for mac80211\n"); goto fail3; } /* Init PCI sw */ err = !rtl_pci_init(hw, pdev); if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to init PCI.\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Failed to init PCI\n"); goto fail3; } err = ieee80211_register_hw(hw); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't register mac80211 hw.\n")); + "Can't register mac80211 hw\n"); goto fail3; } else { rtlpriv->mac80211.mac80211_registered = 1; @@ -1889,7 +1873,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, err = sysfs_create_group(&pdev->dev.kobj, &rtl_attribute_group); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("failed to create sysfs device attributes\n")); + "failed to create sysfs device attributes\n"); goto fail3; } @@ -1901,8 +1885,8 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, IRQF_SHARED, KBUILD_MODNAME, hw); if (err) { RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("%s: failed to register IRQ handler\n", - wiphy_name(hw->wiphy))); + "%s: failed to register IRQ handler\n", + wiphy_name(hw->wiphy)); goto fail3; } else { rtlpci->irq_alloc = 1; diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index 130fdd99d573..a36dc3d5e04f 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -44,7 +44,7 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw) if (is_hal_stop(rtlhal)) RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Driver is already down!\n")); + "Driver is already down!\n"); /*<2> Enable Adapter */ rtlpriv->cfg->ops->hw_init(hw); @@ -120,7 +120,7 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw, default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -176,7 +176,7 @@ void rtl_ips_nic_off_wq_callback(void *data) if (mac->opmode != NL80211_IFTYPE_STATION) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("not station return\n")); + "not station return\n"); return; } @@ -207,7 +207,7 @@ void rtl_ips_nic_off_wq_callback(void *data) (mac->link_state == MAC80211_NOLINK) && !mac->act_scanning) { RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("IPSEnter(): Turn off RF.\n")); + "IPSEnter(): Turn off RF\n"); ppsc->inactive_pwrstate = ERFOFF; ppsc->in_powersavemode = true; @@ -280,8 +280,7 @@ static bool rtl_get_fwlps_doze(struct ieee80211_hw *hw) if (ps_timediff < 2000) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Delay enter Fw LPS for DHCP, ARP," - " or EAPOL exchanging state.\n")); + "Delay enter Fw LPS for DHCP, ARP, or EAPOL exchanging state\n"); return false; } @@ -328,8 +327,8 @@ static void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode) bool fw_current_inps; if (ppsc->dot11_psmode == EACTIVE) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("FW LPS leave ps_mode:%x\n", - FW_PS_ACTIVE_MODE)); + "FW LPS leave ps_mode:%x\n", + FW_PS_ACTIVE_MODE); rpwm_val = 0x0C; /* RF on */ fw_pwrmode = FW_PS_ACTIVE_MODE; @@ -347,8 +346,8 @@ static void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode) } else { if (rtl_get_fwlps_doze(hw)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("FW LPS enter ps_mode:%x\n", - ppsc->fwctrl_psmode)); + "FW LPS enter ps_mode:%x\n", + ppsc->fwctrl_psmode); rpwm_val = 0x02; /* RF off */ fw_current_inps = true; @@ -402,7 +401,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw) if (mac->cnt_after_linked >= 2) { if (ppsc->dot11_psmode == EACTIVE) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Enter 802.11 power save mode...\n")); + "Enter 802.11 power save mode...\n"); rtl_lps_set_psmode(hw, EAUTOPS); } @@ -434,7 +433,7 @@ void rtl_lps_leave(struct ieee80211_hw *hw) } RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Busy Traffic,Leave 802.11 power save..\n")); + "Busy Traffic,Leave 802.11 power save..\n"); rtl_lps_set_psmode(hw, EACTIVE); } @@ -518,8 +517,8 @@ void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len) queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_work, MSECS(5)); } else { - RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, ("u_bufferd: %x, " - "m_buffered: %x\n", u_buffed, m_buffed)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, + "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed); } } @@ -607,8 +606,8 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) * sleep = dtim_period, that meaons, we should * awake before every dtim */ RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("dtim_counter:%x will sleep :%d" - " beacon_intv\n", rtlpriv->psc.dtim_counter, sleep_intv)); + "dtim_counter:%x will sleep :%d beacon_intv\n", + rtlpriv->psc.dtim_counter, sleep_intv); /* we tested that 40ms is enough for sw & hw sw delay */ queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_rfon_wq, diff --git a/drivers/net/wireless/rtlwifi/rc.c b/drivers/net/wireless/rtlwifi/rc.c index 539df66dce0a..4f560d6a386c 100644 --- a/drivers/net/wireless/rtlwifi/rc.c +++ b/drivers/net/wireless/rtlwifi/rc.c @@ -251,7 +251,7 @@ static void *rtl_rate_alloc_sta(void *ppriv, rate_priv = kzalloc(sizeof(struct rtl_rate_priv), gfp); if (!rate_priv) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Unable to allocate private rc structure\n")); + "Unable to allocate private rc structure\n"); return NULL; } diff --git a/drivers/net/wireless/rtlwifi/regd.c b/drivers/net/wireless/rtlwifi/regd.c index 9fedb1f70919..c263df217604 100644 --- a/drivers/net/wireless/rtlwifi/regd.c +++ b/drivers/net/wireless/rtlwifi/regd.c @@ -398,13 +398,11 @@ int rtl_regd_init(struct ieee80211_hw *hw, rtlpriv->regd.country_code = rtlpriv->efuse.channel_plan; RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE, - (KERN_DEBUG "rtl: EEPROM regdomain: 0x%0x\n", - rtlpriv->regd.country_code)); + "rtl: EEPROM regdomain: 0x%0x\n", rtlpriv->regd.country_code); if (rtlpriv->regd.country_code >= COUNTRY_CODE_MAX) { RT_TRACE(rtlpriv, COMP_REGD, DBG_DMESG, - (KERN_DEBUG "rtl: EEPROM indicates invalid contry code" - "world wide 13 should be used\n")); + "rtl: EEPROM indicates invalid contry code, world wide 13 should be used\n"); rtlpriv->regd.country_code = COUNTRY_CODE_WORLD_WIDE_13; } @@ -420,8 +418,8 @@ int rtl_regd_init(struct ieee80211_hw *hw, } RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE, - (KERN_DEBUG "rtl: Country alpha2 being used: %c%c\n", - rtlpriv->regd.alpha2[0], rtlpriv->regd.alpha2[1])); + "rtl: Country alpha2 being used: %c%c\n", + rtlpriv->regd.alpha2[0], rtlpriv->regd.alpha2[1]); _rtl_regd_init_wiphy(&rtlpriv->regd, wiphy, reg_notifier); @@ -433,7 +431,7 @@ int rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_REGD, DBG_LOUD, ("\n")); + RT_TRACE(rtlpriv, COMP_REGD, DBG_LOUD, "\n"); return _rtl_reg_notifier_apply(wiphy, request, &rtlpriv->regd); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index 72a98cab6f69..bf94cbfb4e3f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -246,16 +246,15 @@ static void rtl92c_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw) rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("cnt_parity_fail = %d, cnt_rate_illegal = %d, " - "cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", - falsealm_cnt->cnt_parity_fail, - falsealm_cnt->cnt_rate_illegal, - falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail)); + "cnt_parity_fail = %d, cnt_rate_illegal = %d, cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", + falsealm_cnt->cnt_parity_fail, + falsealm_cnt->cnt_rate_illegal, + falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail); RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", - falsealm_cnt->cnt_ofdm_fail, - falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all)); + "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", + falsealm_cnt->cnt_ofdm_fail, + falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all); } static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw *hw) @@ -313,8 +312,8 @@ static void rtl92c_dm_ctrl_initgain_by_rssi(struct ieee80211_hw *hw) dm_digtable.backoff_val; RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("rssi_val_min = %x backoff_val %x\n", - dm_digtable.rssi_val_min, dm_digtable.backoff_val)); + "rssi_val_min = %x backoff_val %x\n", + dm_digtable.rssi_val_min, dm_digtable.backoff_val); rtl92c_dm_write_dig(hw); } @@ -364,10 +363,9 @@ static void rtl92c_dm_initial_gain_multi_sta(struct ieee80211_hw *hw) } RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("curmultista_connectstate = " - "%x dig_ext_port_stage %x\n", - dm_digtable.curmultista_connectstate, - dm_digtable.dig_ext_port_stage)); + "curmultista_connectstate = %x dig_ext_port_stage %x\n", + dm_digtable.curmultista_connectstate, + dm_digtable.dig_ext_port_stage); } static void rtl92c_dm_initial_gain_sta(struct ieee80211_hw *hw) @@ -375,10 +373,9 @@ static void rtl92c_dm_initial_gain_sta(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("presta_connectstate = %x," - " cursta_connectctate = %x\n", - dm_digtable.presta_connectstate, - dm_digtable.cursta_connectctate)); + "presta_connectstate = %x, cursta_connectctate = %x\n", + dm_digtable.presta_connectstate, + dm_digtable.cursta_connectctate); if (dm_digtable.presta_connectstate == dm_digtable.cursta_connectctate || dm_digtable.cursta_connectctate == DIG_STA_BEFORE_CONNECT @@ -464,11 +461,11 @@ static void rtl92c_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) dm_digtable.pre_cck_pd_state = dm_digtable.cur_cck_pd_state; } - RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("CCKPDStage=%x\n", dm_digtable.cur_cck_pd_state)); + RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "CCKPDStage=%x\n", + dm_digtable.cur_cck_pd_state); - RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, - ("is92C=%x\n", IS_92C_SERIAL(rtlhal->version))); + RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "is92C=%x\n", + IS_92C_SERIAL(rtlhal->version)); } static void rtl92c_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw) @@ -519,10 +516,9 @@ void rtl92c_dm_write_dig(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("cur_igvalue = 0x%x, " - "pre_igvalue = 0x%x, backoff_val = %d\n", - dm_digtable.cur_igvalue, dm_digtable.pre_igvalue, - dm_digtable.backoff_val)); + "cur_igvalue = 0x%x, pre_igvalue = 0x%x, backoff_val = %d\n", + dm_digtable.cur_igvalue, dm_digtable.pre_igvalue, + dm_digtable.backoff_val); if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) { rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, @@ -676,15 +672,14 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw rtlpriv->dm.txpower_trackinginit = true; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("rtl92c_dm_txpower_tracking_callback_thermalmeter\n")); + "rtl92c_dm_txpower_tracking_callback_thermalmeter\n"); thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " - "eeprom_thermalmeter 0x%x\n", - thermalvalue, rtlpriv->dm.thermalvalue, - rtlefuse->eeprom_thermalmeter)); + "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x\n", + thermalvalue, rtlpriv->dm.thermalvalue, + rtlefuse->eeprom_thermalmeter); rtl92c_phy_ap_calibrate(hw, (thermalvalue - rtlefuse->eeprom_thermalmeter)); @@ -702,10 +697,9 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw ofdm_index_old[0] = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Initial pathA ele_d reg0x%x = 0x%lx, " - "ofdm_index=0x%x\n", + "Initial pathA ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n", ROFDM0_XATXIQIMBALANCE, - ele_d, ofdm_index_old[0])); + ele_d, ofdm_index_old[0]); break; } } @@ -719,11 +713,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw MASKOFDM_D)) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, - DBG_LOUD, - ("Initial pathB ele_d reg0x%x = " - "0x%lx, ofdm_index=0x%x\n", - ROFDM0_XBTXIQIMBALANCE, ele_d, - ofdm_index_old[1])); + DBG_LOUD, + "Initial pathB ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n", + ROFDM0_XBTXIQIMBALANCE, ele_d, + ofdm_index_old[1]); break; } } @@ -741,11 +734,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Initial reg0x%x = 0x%lx, " - "cck_index=0x%x, ch 14 %d\n", - RCCK0_TXFILTER2, temp_cck, - cck_index_old, - rtlpriv->dm.cck_inch14)); + "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch 14 %d\n", + RCCK0_TXFILTER2, temp_cck, + cck_index_old, + rtlpriv->dm.cck_inch14); break; } } else { @@ -757,11 +749,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Initial reg0x%x = 0x%lx, " - "cck_index=0x%x, ch14 %d\n", - RCCK0_TXFILTER2, temp_cck, - cck_index_old, - rtlpriv->dm.cck_inch14)); + "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch14 %d\n", + RCCK0_TXFILTER2, temp_cck, + cck_index_old, + rtlpriv->dm.cck_inch14); break; } } @@ -790,12 +781,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw (rtlpriv->dm.thermalvalue_iqk - thermalvalue); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " - "eeprom_thermalmeter 0x%x delta 0x%x " - "delta_lck 0x%x delta_iqk 0x%x\n", + "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x delta 0x%x delta_lck 0x%x delta_iqk 0x%x\n", thermalvalue, rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter, delta, delta_lck, - delta_iqk)); + delta_iqk); if (delta_lck > 1) { rtlpriv->dm.thermalvalue_lck = thermalvalue; @@ -815,18 +804,15 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw if (is2t) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("temp OFDM_A_index=0x%x, " - "OFDM_B_index=0x%x," - "cck_index=0x%x\n", - rtlpriv->dm.ofdm_index[0], - rtlpriv->dm.ofdm_index[1], - rtlpriv->dm.cck_index)); + "temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, cck_index=0x%x\n", + rtlpriv->dm.ofdm_index[0], + rtlpriv->dm.ofdm_index[1], + rtlpriv->dm.cck_index); } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("temp OFDM_A_index=0x%x," - "cck_index=0x%x\n", - rtlpriv->dm.ofdm_index[0], - rtlpriv->dm.cck_index)); + "temp OFDM_A_index=0x%x, cck_index=0x%x\n", + rtlpriv->dm.ofdm_index[0], + rtlpriv->dm.cck_index); } if (thermalvalue > rtlefuse->eeprom_thermalmeter) { @@ -918,16 +904,13 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw if (is2t) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("new OFDM_A_index=0x%x, " - "OFDM_B_index=0x%x," - "cck_index=0x%x\n", - ofdm_index[0], ofdm_index[1], - cck_index)); + "new OFDM_A_index=0x%x, OFDM_B_index=0x%x, cck_index=0x%x\n", + ofdm_index[0], ofdm_index[1], + cck_index); } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("new OFDM_A_index=0x%x," - "cck_index=0x%x\n", - ofdm_index[0], cck_index)); + "new OFDM_A_index=0x%x, cck_index=0x%x\n", + ofdm_index[0], cck_index); } } @@ -1085,7 +1068,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw rtlpriv->dm.thermalvalue = thermalvalue; } - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("<===\n")); + RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===\n"); } @@ -1098,8 +1081,8 @@ static void rtl92c_dm_initialize_txpower_tracking_thermalmeter( rtlpriv->dm.txpower_trackinginit = false; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("pMgntInfo->txpower_tracking = %d\n", - rtlpriv->dm.txpower_tracking)); + "pMgntInfo->txpower_tracking = %d\n", + rtlpriv->dm.txpower_tracking); } static void rtl92c_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) @@ -1125,12 +1108,12 @@ static void rtl92c_dm_check_txpower_tracking_thermal_meter( rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, RFREG_OFFSET_MASK, 0x60); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Trigger 92S Thermal Meter!!\n")); + "Trigger 92S Thermal Meter!!\n"); tm_trigger = 1; return; } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Schedule TxPowerTracking direct call!!\n")); + "Schedule TxPowerTracking direct call!!\n"); rtl92c_dm_txpower_tracking_directcall(hw); tm_trigger = 0; } @@ -1169,13 +1152,13 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw) if (is_hal_stop(rtlhal)) { RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, - ("<---- driver is going to unload\n")); + "<---- driver is going to unload\n"); return; } if (!rtlpriv->dm.useramask) { RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, - ("<---- driver does not control rate adaptive mask\n")); + "<---- driver does not control rate adaptive mask\n"); return; } @@ -1210,14 +1193,13 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw) p_ra->ratr_state = DM_RATR_STA_LOW; if (p_ra->pre_ratr_state != p_ra->ratr_state) { + RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, "RSSI = %ld\n", + rtlpriv->dm.undecorated_smoothed_pwdb); RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, - ("RSSI = %ld\n", - rtlpriv->dm.undecorated_smoothed_pwdb)); + "RSSI_LEVEL = %d\n", p_ra->ratr_state); RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, - ("RSSI_LEVEL = %d\n", p_ra->ratr_state)); - RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, - ("PreState = %d, CurState = %d\n", - p_ra->pre_ratr_state, p_ra->ratr_state)); + "PreState = %d, CurState = %d\n", + p_ra->pre_ratr_state, p_ra->ratr_state); rcu_read_lock(); sta = ieee80211_find_sta(mac->vif, mac->bssid); @@ -1316,8 +1298,7 @@ static void rtl92c_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw) if (((mac->link_state == MAC80211_NOLINK)) && (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { dm_pstable.rssi_val_min = 0; - RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, - ("Not connected to any\n")); + RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, "Not connected to any\n"); } if (mac->link_state == MAC80211_LINKED) { @@ -1325,22 +1306,22 @@ static void rtl92c_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw) dm_pstable.rssi_val_min = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - dm_pstable.rssi_val_min)); + "AP Client PWDB = 0x%lx\n", + dm_pstable.rssi_val_min); } else { dm_pstable.rssi_val_min = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - dm_pstable.rssi_val_min)); + "STA Default Port PWDB = 0x%lx\n", + dm_pstable.rssi_val_min); } } else { dm_pstable.rssi_val_min = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - dm_pstable.rssi_val_min)); + "AP Ext Port PWDB = 0x%lx\n", + dm_pstable.rssi_val_min); } if (IS_92C_SERIAL(rtlhal->version)) @@ -1381,7 +1362,7 @@ void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) if ((mac->link_state < MAC80211_LINKED) && (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Not connected to any\n")); + "Not connected to any\n"); rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; @@ -1394,28 +1375,28 @@ void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Client PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } else { undecorated_smoothed_pwdb = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "STA Default Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } } else { undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Ext Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n"); } else if ((undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && (undecorated_smoothed_pwdb >= @@ -1423,18 +1404,18 @@ void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n"); } else if (undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_NORMAL\n")); + "TXHIGHPWRLEVEL_NORMAL\n"); } if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("PHY_SetTxPowerLevel8192S() Channel = %d\n", - rtlphy->current_channel)); + "PHY_SetTxPowerLevel8192S() Channel = %d\n", + rtlphy->current_channel); rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 5401b32733d3..12c025bf53b2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -172,7 +172,7 @@ static void _rtl92c_write_fw(struct ieee80211_hw *hw, struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u8 *bufferPtr = (u8 *) buffer; - RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); + RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes\n", size); if (IS_CHIP_VER_B(version)) { u32 pageNums, remainSize; @@ -186,7 +186,7 @@ static void _rtl92c_write_fw(struct ieee80211_hw *hw, if (pageNums > 4) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Page numbers should not greater then 4\n")); + "Page numbers should not greater then 4\n"); } for (page = 0; page < pageNums; page++) { @@ -219,13 +219,12 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw) if (counter >= FW_8192C_POLLING_TIMEOUT_COUNT) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("chksum report faill ! REG_MCUFWDL:0x%08x .\n", - value32)); + "chksum report faill ! REG_MCUFWDL:0x%08x\n", value32); return -EIO; } RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32)); + "Checksum report OK ! REG_MCUFWDL:0x%08x\n", value32); value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); value32 |= MCUFWDL_RDY; @@ -238,9 +237,8 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw) value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); if (value32 & WINTINI_RDY) { RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("Polling FW ready success!!" - " REG_MCUFWDL:0x%08x .\n", - value32)); + "Polling FW ready success!! REG_MCUFWDL:0x%08x\n", + value32); return 0; } @@ -249,7 +247,7 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw) } while (counter++ < FW_8192C_POLLING_TIMEOUT_COUNT); RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n", value32)); + "Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", value32); return -EIO; } @@ -272,10 +270,10 @@ 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", + "Firmware Version(%d), Signature(%#x),Size(%d)\n", le16_to_cpu(pfwheader->version), le16_to_cpu(pfwheader->signature), - (uint)sizeof(struct rtl92c_firmware_header))); + (uint)sizeof(struct rtl92c_firmware_header)); pfwdata = pfwdata + sizeof(struct rtl92c_firmware_header); fwsize = fwsize - sizeof(struct rtl92c_firmware_header); @@ -287,10 +285,10 @@ int rtl92c_download_fw(struct ieee80211_hw *hw) if (_rtl92c_fw_free_to_go(hw)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is not ready to run!\n")); + "Firmware is not ready to run!\n"); } else { RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("Firmware is ready to run!\n")); + "Firmware is ready to run!\n"); } return 0; @@ -328,22 +326,22 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, unsigned long flag; u8 idx; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("come in\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n"); while (true) { spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); if (rtlhal->h2c_setinprogress) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("H2C set in progress! Wait to set.." - "element_id(%d).\n", element_id)); + "H2C set in progress! Wait to set..element_id(%d)\n", + element_id); while (rtlhal->h2c_setinprogress) { spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); h2c_waitcounter++; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wait 100 us (%d times)...\n", - h2c_waitcounter)); + "Wait 100 us (%d times)...\n", + h2c_waitcounter); udelay(100); if (h2c_waitcounter > 1000) @@ -363,8 +361,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, wait_writeh2c_limmit--; if (wait_writeh2c_limmit == 0) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Write H2C fail because no trigger " - "for FW INT!\n")); + "Write H2C fail because no trigger for FW INT!\n"); break; } @@ -388,7 +385,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -398,8 +395,8 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, wait_h2c_limmit--; if (wait_h2c_limmit == 0) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wating too long for FW read " - "clear HMEBox(%d)!\n", boxnum)); + "Waiting too long for FW read clear HMEBox(%d)!\n", + boxnum); break; } @@ -408,14 +405,14 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, isfw_read = _rtl92c_check_fw_read_last_h2c(hw, boxnum); u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wating for FW read clear HMEBox(%d)!!! " - "0x1BF = %2x\n", boxnum, u1b_tmp)); + "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n", + boxnum, u1b_tmp); } if (!isfw_read) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Write H2C register BOX[%d] fail!!!!! " - "Fw do not read.\n", boxnum)); + "Write H2C register BOX[%d] fail!!!!! Fw do not read\n", + boxnum); break; } @@ -423,8 +420,8 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, memset(boxextcontent, 0, sizeof(boxextcontent)); boxcontent[0] = element_id; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Write element_id box_reg(%4x) = %2x\n", - box_reg, element_id)); + "Write element_id box_reg(%4x) = %2x\n", + box_reg, element_id); switch (cmd_len) { case 1: @@ -493,7 +490,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -504,15 +501,15 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, rtlhal->last_hmeboxnum = 0; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("pHalData->last_hmeboxnum = %d\n", - rtlhal->last_hmeboxnum)); + "pHalData->last_hmeboxnum = %d\n", + rtlhal->last_hmeboxnum); } spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); rtlhal->h2c_setinprogress = false; spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n"); } void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, @@ -562,7 +559,7 @@ void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) u8 u1_h2c_set_pwrmode[3] = {0}; struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("FW LPS mode = %d\n", mode)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode); SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1); @@ -798,14 +795,14 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) if (dlok) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Set RSVD page location to Fw.\n")); + "Set RSVD page location to Fw\n"); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, "H2C_RSVDPAGE", u1RsvdPageLoc, 3); rtl92c_fill_h2c_cmd(hw, H2C_RSVDPAGE, sizeof(u1RsvdPageLoc), u1RsvdPageLoc); } else RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Set RSVD page location to Fw FAIL!!!!!!.\n")); + "Set RSVD page location to Fw FAIL!!!!!!\n"); } EXPORT_SYMBOL(rtl92c_set_fw_rsvdpagepkt); diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index 1f07558debf2..8ab93a69f334 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -42,16 +42,15 @@ u32 rtl92c_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) struct rtl_priv *rtlpriv = rtl_priv(hw); u32 returnvalue, originalvalue, bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x)\n", regaddr, - bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n", + regaddr, bitmask); originalvalue = rtl_read_dword(rtlpriv, regaddr); bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); returnvalue = (originalvalue & bitmask) >> bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("BBR MASK=0x%x " - "Addr[0x%x]=0x%x\n", bitmask, - regaddr, originalvalue)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "BBR MASK=0x%x Addr[0x%x]=0x%x\n", + bitmask, regaddr, originalvalue); return returnvalue; @@ -64,9 +63,9 @@ void rtl92c_phy_set_bb_reg(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 originalvalue, bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, - data)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data); if (bitmask != MASKDWORD) { originalvalue = rtl_read_dword(rtlpriv, regaddr); @@ -76,9 +75,9 @@ void rtl92c_phy_set_bb_reg(struct ieee80211_hw *hw, rtl_write_dword(rtlpriv, regaddr, data); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, - data)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data); } EXPORT_SYMBOL(rtl92c_phy_set_bb_reg); @@ -114,7 +113,7 @@ u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw, offset &= 0x3f; newoffset = offset; if (RT_CANNOT_IO(hw)) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("return all one\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "return all one\n"); return 0xFFFFFFFF; } tmplong = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD); @@ -144,9 +143,8 @@ u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw, else retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, BLSSIREADBACKDATA); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x]=0x%x\n", - rfpath, pphyreg->rflssi_readback, - retvalue)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFR-%d Addr[0x%x]=0x%x\n", + rfpath, pphyreg->rflssi_readback, retvalue); return retvalue; } EXPORT_SYMBOL(_rtl92c_phy_rf_serial_read); @@ -162,16 +160,15 @@ void _rtl92c_phy_rf_serial_write(struct ieee80211_hw *hw, struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; if (RT_CANNOT_IO(hw)) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("stop\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "stop\n"); return; } offset &= 0x3f; newoffset = offset; data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", - rfpath, pphyreg->rf3wire_offset, - data_and_addr)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFW-%d Addr[0x%x]=0x%x\n", + rfpath, pphyreg->rf3wire_offset, data_and_addr); } EXPORT_SYMBOL(_rtl92c_phy_rf_serial_write); @@ -216,16 +213,16 @@ bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw) struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); bool rtstatus; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("==>\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n"); rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw, BASEBAND_CONFIG_PHY_REG); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Write BB Reg Fail!!\n"); return false; } if (rtlphy->rf_type == RF_1T2R) { _rtl92c_phy_bb_config_1t(hw); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Config to 1T!!\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Config to 1T!!\n"); } if (rtlefuse->autoload_failflag == false) { rtlphy->pwrgroup_cnt = 0; @@ -233,13 +230,13 @@ bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw) BASEBAND_CONFIG_PHY_REG); } if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "BB_PG Reg Fail!!\n"); return false; } rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw, BASEBAND_CONFIG_AGC_TAB); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "AGC Table Fail\n"); return false; } rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw, @@ -260,114 +257,114 @@ void _rtl92c_store_pwrIndex_diffrate_offset(struct ieee80211_hw *hw, if (regaddr == RTXAGC_A_RATE18_06) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0])); + "MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0]); } if (regaddr == RTXAGC_A_RATE54_24) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1])); + "MCSTxPowerLevelOriginalOffset[%d][1] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1]); } if (regaddr == RTXAGC_A_CCK1_MCS32) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6])); + "MCSTxPowerLevelOriginalOffset[%d][6] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6]); } if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7])); + "MCSTxPowerLevelOriginalOffset[%d][7] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7]); } if (regaddr == RTXAGC_A_MCS03_MCS00) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2])); + "MCSTxPowerLevelOriginalOffset[%d][2] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2]); } if (regaddr == RTXAGC_A_MCS07_MCS04) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3])); + "MCSTxPowerLevelOriginalOffset[%d][3] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3]); } if (regaddr == RTXAGC_A_MCS11_MCS08) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4])); + "MCSTxPowerLevelOriginalOffset[%d][4] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4]); } if (regaddr == RTXAGC_A_MCS15_MCS12) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5])); + "MCSTxPowerLevelOriginalOffset[%d][5] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5]); } if (regaddr == RTXAGC_B_RATE18_06) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8])); + "MCSTxPowerLevelOriginalOffset[%d][8] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8]); } if (regaddr == RTXAGC_B_RATE54_24) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9])); + "MCSTxPowerLevelOriginalOffset[%d][9] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9]); } if (regaddr == RTXAGC_B_CCK1_55_MCS32) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14])); + "MCSTxPowerLevelOriginalOffset[%d][14] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14]); } if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15])); + "MCSTxPowerLevelOriginalOffset[%d][15] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15]); } if (regaddr == RTXAGC_B_MCS03_MCS00) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10])); + "MCSTxPowerLevelOriginalOffset[%d][10] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10]); } if (regaddr == RTXAGC_B_MCS07_MCS04) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11])); + "MCSTxPowerLevelOriginalOffset[%d][11] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11]); } if (regaddr == RTXAGC_B_MCS11_MCS08) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12])); + "MCSTxPowerLevelOriginalOffset[%d][12] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12]); } if (regaddr == RTXAGC_B_MCS15_MCS12) { rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13])); + "MCSTxPowerLevelOriginalOffset[%d][13] = 0x%x\n", + rtlphy->pwrgroup_cnt, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13]); rtlphy->pwrgroup_cnt++; } @@ -389,12 +386,11 @@ void rtl92c_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, MASKBYTE0); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Default initial gain (c50=0x%x, " - "c58=0x%x, c60=0x%x, c68=0x%x\n", - rtlphy->default_initialgain[0], - rtlphy->default_initialgain[1], - rtlphy->default_initialgain[2], - rtlphy->default_initialgain[3])); + "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x\n", + rtlphy->default_initialgain[0], + rtlphy->default_initialgain[1], + rtlphy->default_initialgain[2], + rtlphy->default_initialgain[3]); rtlphy->framesync = (u8) rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, MASKBYTE0); @@ -402,8 +398,8 @@ void rtl92c_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) ROFDM0_RXDETECTOR2, MASKDWORD); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Default framesync (0x%x) = 0x%x\n", - ROFDM0_RXDETECTOR3, rtlphy->framesync)); + "Default framesync (0x%x) = 0x%x\n", + ROFDM0_RXDETECTOR3, rtlphy->framesync); } void _rtl92c_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw) @@ -615,8 +611,8 @@ bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw, long power_indbm) else ofdmtxpwridx = 0; RT_TRACE(rtlpriv, COMP_TXAGC, DBG_TRACE, - ("%lx dBm, ccktxpwridx = %d, ofdmtxpwridx = %d\n", - power_indbm, ccktxpwridx, ofdmtxpwridx)); + "%lx dBm, ccktxpwridx = %d, ofdmtxpwridx = %d\n", + power_indbm, ccktxpwridx, ofdmtxpwridx); for (idx = 0; idx < 14; idx++) { for (rf_path = 0; rf_path < 2; rf_path++) { rtlefuse->txpwrlevel_cck[rf_path][idx] = ccktxpwridx; @@ -710,7 +706,7 @@ void rtl92c_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Unknown Scan Backup operation.\n")); + "Unknown Scan Backup operation\n"); break; } } @@ -732,7 +728,7 @@ void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw, rtlpriv->cfg->ops->phy_set_bw_mode_callback(hw); } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("FALSE driver sleep or unload\n")); + "FALSE driver sleep or unload\n"); rtlphy->set_bwmode_inprogress = false; rtlphy->current_chan_bw = tmp_bw; } @@ -747,7 +743,7 @@ void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw) u32 delay; RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("switch to channel%d\n", rtlphy->current_channel)); + "switch to channel%d\n", rtlphy->current_channel); if (is_hal_stop(rtlhal)) return; do { @@ -765,7 +761,7 @@ void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw) } break; } while (true); - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); } EXPORT_SYMBOL(rtl92c_phy_sw_chnl_callback); @@ -787,12 +783,11 @@ u8 rtl92c_phy_sw_chnl(struct ieee80211_hw *hw) if (!(is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) { rtl92c_phy_sw_chnl_callback(hw); RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, - ("sw_chnl_inprogress false schdule workitem\n")); + "sw_chnl_inprogress false schdule workitem\n"); rtlphy->sw_chnl_inprogress = false; } else { RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, - ("sw_chnl_inprogress false driver sleep or" - " unload\n")); + "sw_chnl_inprogress false driver sleep or unload\n"); rtlphy->sw_chnl_inprogress = false; } return 1; @@ -916,7 +911,7 @@ bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -1920,23 +1915,23 @@ bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) bool postprocessing = false; RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", - iotype, rtlphy->set_io_inprogress)); + "-->IO Cmd(%#x), set_io_inprogress(%d)\n", + iotype, rtlphy->set_io_inprogress); do { switch (iotype) { case IO_CMD_RESUME_DM_BY_SCAN: RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("[IO CMD] Resume DM after scan.\n")); + "[IO CMD] Resume DM after scan\n"); postprocessing = true; break; case IO_CMD_PAUSE_DM_BY_SCAN: RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("[IO CMD] Pause DM before scan.\n")); + "[IO CMD] Pause DM before scan\n"); postprocessing = true; break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } while (false); @@ -1947,7 +1942,7 @@ bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) return false; } rtl92c_phy_set_io(hw); - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, ("<--IO Type(%#x)\n", iotype)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<--IO Type(%#x)\n", iotype); return true; } EXPORT_SYMBOL(rtl92c_phy_set_io_cmd); @@ -1958,8 +1953,8 @@ void rtl92c_phy_set_io(struct ieee80211_hw *hw) struct rtl_phy *rtlphy = &(rtlpriv->phy); RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("--->Cmd(%#x), set_io_inprogress(%d)\n", - rtlphy->current_io_type, rtlphy->set_io_inprogress)); + "--->Cmd(%#x), set_io_inprogress(%d)\n", + rtlphy->current_io_type, rtlphy->set_io_inprogress); switch (rtlphy->current_io_type) { case IO_CMD_RESUME_DM_BY_SCAN: dm_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1; @@ -1973,12 +1968,12 @@ void rtl92c_phy_set_io(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } rtlphy->set_io_inprogress = false; - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("<---(%#x)\n", rtlphy->current_io_type)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<---(%#x)\n", + rtlphy->current_io_type); } EXPORT_SYMBOL(rtl92c_phy_set_io); @@ -2018,7 +2013,7 @@ void _rtl92c_phy_set_rf_sleep(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Switch RF timeout !!!.\n")); + "Switch RF timeout !!!\n"); return; } rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c index 2df33e53e15a..6730e683aba3 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c @@ -54,7 +54,7 @@ void rtl92ce_dm_dynamic_txpower(struct ieee80211_hw *hw) if ((mac->link_state < MAC80211_LINKED) && (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Not connected to any\n")); + "Not connected to any\n"); rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; @@ -67,28 +67,28 @@ void rtl92ce_dm_dynamic_txpower(struct ieee80211_hw *hw) undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Client PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } else { undecorated_smoothed_pwdb = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "STA Default Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } } else { undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Ext Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n"); } else if ((undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && (undecorated_smoothed_pwdb >= @@ -96,18 +96,18 @@ void rtl92ce_dm_dynamic_txpower(struct ieee80211_hw *hw) rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n"); } else if (undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_NORMAL\n")); + "TXHIGHPWRLEVEL_NORMAL\n"); } if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("PHY_SetTxPowerLevel8192S() Channel = %d\n", - rtlphy->current_channel)); + "PHY_SetTxPowerLevel8192S() Channel = %d\n", + rtlphy->current_channel); rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 2156378de1e8..4aa228fe96e9 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -141,7 +141,7 @@ void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) } default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } @@ -207,7 +207,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) u8 e_aci; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("HW_VAR_SLOT_TIME %x\n", val[0])); + "HW_VAR_SLOT_TIME %x\n", val[0]); rtl_write_byte(rtlpriv, REG_SLOT, val[0]); @@ -246,8 +246,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) *val = min_spacing_to_set; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, mac->min_space_cfg); @@ -261,8 +261,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) mac->min_space_cfg |= (density_to_set << 3); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_SHORTGI_DENSITY: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, mac->min_space_cfg); @@ -310,8 +310,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) } RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_FACTOR: %#x\n", - factor_toset)); + "Set HW_VAR_AMPDU_FACTOR: %#x\n", + factor_toset); } break; } @@ -348,8 +348,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("HW_VAR_ACM_CTRL acm set " - "failed: eACI is %d\n", acm)); + "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n", + acm); break; } } else { @@ -365,14 +365,14 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, - ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " - "Write 0x%X\n", acm_ctrl)); + "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", + acm_ctrl); rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); break; } @@ -507,8 +507,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) } default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " - "not process\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "switch case not processed\n"); break; } } @@ -530,8 +530,8 @@ static bool _rtl92ce_llt_write(struct ieee80211_hw *hw, u32 address, u32 data) if (count > POLLING_LLT_THRESHOLD) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to polling write LLT done at " - "address %d!\n", address)); + "Failed to polling write LLT done at address %d!\n", + address); status = false; break; } @@ -669,18 +669,15 @@ static bool _rtl92ce_init_mac(struct ieee80211_hw *hw) udelay(2); retry = 0; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("reg0xec:%x:%x\n", - rtl_read_dword(rtlpriv, 0xEC), - bytetmp)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "reg0xec:%x:%x\n", + rtl_read_dword(rtlpriv, 0xEC), bytetmp); while ((bytetmp & BIT(0)) && retry < 1000) { retry++; udelay(50); bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("reg0xec:%x:%x\n", - rtl_read_dword(rtlpriv, - 0xEC), - bytetmp)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "reg0xec:%x:%x\n", + rtl_read_dword(rtlpriv, 0xEC), bytetmp); udelay(50); } @@ -864,13 +861,13 @@ void rtl92ce_enable_hw_security_config(struct ieee80211_hw *hw) u8 sec_reg_value; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", - rtlpriv->sec.pairwise_enc_algorithm, - rtlpriv->sec.group_enc_algorithm)); + "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", + rtlpriv->sec.pairwise_enc_algorithm, + rtlpriv->sec.group_enc_algorithm); if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("not open " - "hw encryption\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, + "not open hw encryption\n"); return; } @@ -886,7 +883,7 @@ void rtl92ce_enable_hw_security_config(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The SECR-value %x\n", sec_reg_value)); + "The SECR-value %x\n", sec_reg_value); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); @@ -910,7 +907,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) rtlpriv->intf_ops->disable_aspm(hw); rtstatus = _rtl92ce_init_mac(hw); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Init MAC failed\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n"); err = 1; return err; } @@ -918,8 +915,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) err = rtl92c_download_fw(hw); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Failed to download FW. Init HW " - "without FW now..\n")); + "Failed to download FW. Init HW without FW now..\n"); err = 1; rtlhal->fw_ready = false; return err; @@ -968,12 +964,12 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) tmp_u1b = efuse_read_1byte(hw, 0x1FA); if (!(tmp_u1b & BIT(0))) { rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("PA BIAS path A\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "PA BIAS path A\n"); } if (!(tmp_u1b & BIT(1)) && is92c) { rtl_set_rfreg(hw, RF90_PATH_B, 0x15, 0x0F, 0x05); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("PA BIAS path B\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "PA BIAS path B\n"); } if (!(tmp_u1b & BIT(4))) { @@ -982,7 +978,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x80); udelay(10); rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x90); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("under 1.5V\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "under 1.5V\n"); } rtl92c_dm_init(hw); rtlpci->being_init_adapter = false; @@ -1008,23 +1004,23 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw) switch (version) { case VERSION_B_CHIP_92C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_B_CHIP_92C.\n")); + "Chip Version ID: VERSION_B_CHIP_92C\n"); break; case VERSION_B_CHIP_88C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_B_CHIP_88C.\n")); + "Chip Version ID: VERSION_B_CHIP_88C\n"); break; case VERSION_A_CHIP_92C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_A_CHIP_92C.\n")); + "Chip Version ID: VERSION_A_CHIP_92C\n"); break; case VERSION_A_CHIP_88C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_A_CHIP_88C.\n")); + "Chip Version ID: VERSION_A_CHIP_88C\n"); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Chip Version ID: Unknown. Bug?\n")); + "Chip Version ID: Unknown. Bug?\n"); break; } @@ -1041,13 +1037,12 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw) default: rtlphy->rf_type = RF_1T1R; RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("ERROR RF_Type is set!!")); + "ERROR RF_Type is set!!\n"); break; } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Chip RF Type: %s\n", (rtlphy->rf_type == RF_2T2R) ? - "RF_2T2R" : "RF_1T1R")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Chip RF Type: %s\n", + rtlphy->rf_type == RF_2T2R ? "RF_2T2R" : "RF_1T1R"); return version; } @@ -1069,8 +1064,8 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw, _rtl92ce_disable_bcn_sub_func(hw); } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Set HW_VAR_MEDIA_STATUS: " - "No such media status(%x).\n", type)); + "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n", + type); } switch (type) { @@ -1078,27 +1073,27 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw, bt_msr |= MSR_NOLINK; ledaction = LED_CTL_LINK; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to NO LINK!\n")); + "Set Network type to NO LINK!\n"); break; case NL80211_IFTYPE_ADHOC: bt_msr |= MSR_ADHOC; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to Ad Hoc!\n")); + "Set Network type to Ad Hoc!\n"); break; case NL80211_IFTYPE_STATION: bt_msr |= MSR_INFRA; ledaction = LED_CTL_LINK; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to STA!\n")); + "Set Network type to STA!\n"); break; case NL80211_IFTYPE_AP: bt_msr |= MSR_AP; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to AP!\n")); + "Set Network type to AP!\n"); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Network type %d not support!\n", type)); + "Network type %d not supported!\n", type); return 1; break; @@ -1300,7 +1295,7 @@ void rtl92ce_set_beacon_interval(struct ieee80211_hw *hw) u16 bcn_interval = mac->beacon_interval; RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, - ("beacon_interval:%d\n", bcn_interval)); + "beacon_interval:%d\n", bcn_interval); rtl92ce_disable_interrupt(hw); rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); rtl92ce_enable_interrupt(hw); @@ -1312,8 +1307,8 @@ void rtl92ce_update_interrupt_mask(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); + RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n", + add_msr, rm_msr); if (add_msr) rtlpci->irq_mask[0] |= add_msr; @@ -1567,7 +1562,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) HWSET_MAX_SIZE); } else if (rtlefuse->epromtype == EEPROM_93C46) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); + "RTL819X Not boot from eeprom, check it !!"); } RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP", @@ -1576,10 +1571,10 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) eeprom_id = *((u16 *)&hwinfo[0]); if (eeprom_id != RTL8190_EEPROM_ID) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); + "EEPROM ID(%#x) is invalid!!\n", eeprom_id); rtlefuse->autoload_failflag = true; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; } @@ -1591,8 +1586,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; } - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("%pM\n", rtlefuse->dev_addr)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr); _rtl92ce_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag, @@ -1608,7 +1602,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); + "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid); /* set channel paln to world wide 13 */ rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13; @@ -1662,7 +1656,7 @@ static void _rtl92ce_hal_customized_behavior(struct ieee80211_hw *hw) break; } RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("RT Customized ID: 0x%02X\n", rtlhal->oem_id)); + "RT Customized ID: 0x%02X\n", rtlhal->oem_id); } void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw) @@ -1679,22 +1673,22 @@ void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw) else rtlpriv->dm.rfpath_rxenable[0] = rtlpriv->dm.rfpath_rxenable[1] = true; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", - rtlhal->version)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n", + rtlhal->version); tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); if (tmp_u1b & BIT(4)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n"); rtlefuse->epromtype = EEPROM_93C46; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n"); rtlefuse->epromtype = EEPROM_BOOT_EFUSE; } if (tmp_u1b & BIT(5)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; _rtl92ce_read_adapter_info(hw); } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n"); } _rtl92ce_hal_customized_behavior(hw); } @@ -1790,8 +1784,8 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw, rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("%x\n", rtl_read_dword(rtlpriv, REG_ARFR0))); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n", + rtl_read_dword(rtlpriv, REG_ARFR0)); } static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, @@ -1919,16 +1913,15 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, break; } RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("ratr_bitmap :%x\n", ratr_bitmap)); + "ratr_bitmap :%x\n", ratr_bitmap); *(u32 *)&rate_mask = EF4BYTE((ratr_bitmap & 0x0fffffff) | (ratr_index << 28)); rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("Rate_index:%x, " - "ratr_val:%x, %x:%x:%x:%x:%x\n", - ratr_index, ratr_bitmap, - rate_mask[0], rate_mask[1], - rate_mask[2], rate_mask[3], - rate_mask[4])); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, + "Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x\n", + ratr_index, ratr_bitmap, + rate_mask[0], rate_mask[1], rate_mask[2], rate_mask[3], + rate_mask[4]); rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask); if (macid != 0) @@ -1994,7 +1987,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("GPIOChangeRF - HW Radio ON, RF ON\n")); + "GPIOChangeRF - HW Radio ON, RF ON\n"); e_rfpowerstate_toset = ERFON; ppsc->hwradiooff = false; @@ -2002,7 +1995,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) } else if ((ppsc->hwradiooff == false) && (e_rfpowerstate_toset == ERFOFF)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); + "GPIOChangeRF - HW Radio OFF, RF OFF\n"); e_rfpowerstate_toset = ERFOFF; ppsc->hwradiooff = true; @@ -2053,7 +2046,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, u8 cam_offset = 0; u8 clear_number = 5; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n"); for (idx = 0; idx < clear_number; idx++) { rtl_cam_mark_invalid(hw, cam_offset + idx); @@ -2081,8 +2074,8 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, enc_algo = CAM_AES; break; default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " - "not process\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "switch case not processed\n"); enc_algo = CAM_TKIP; break; } @@ -2100,9 +2093,8 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, p_macaddr); if (entry_id >= TOTAL_CAM_ENTRY) { RT_TRACE(rtlpriv, COMP_SEC, - DBG_EMERG, - ("Can not find free hw" - " security cam entry\n")); + DBG_EMERG, + "Can not find free hw security cam entry\n"); return; } } else { @@ -2116,22 +2108,22 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, if (rtlpriv->sec.key_len[key_index] == 0) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("delete one entry, entry_id is %d\n", - entry_id)); + "delete one entry, entry_id is %d\n", + entry_id); if (mac->opmode == NL80211_IFTYPE_AP) rtl_cam_del_entry(hw, p_macaddr); rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY length is %d\n", - rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); + "The insert KEY length is %d\n", + rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY is %x %x\n", - rtlpriv->sec.key_buf[0][0], - rtlpriv->sec.key_buf[0][1])); + "The insert KEY is %x %x\n", + rtlpriv->sec.key_buf[0][0], + rtlpriv->sec.key_buf[0][1]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("add one entry\n")); + "add one entry\n"); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, "Pairwise Key content", @@ -2140,7 +2132,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set Pairwiase key\n")); + "set Pairwise key\n"); rtl_cam_add_one_entry(hw, macaddr, key_index, entry_id, enc_algo, @@ -2149,7 +2141,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index, key_buf[key_index]); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set group key\n")); + "set group key\n"); if (mac->opmode == NL80211_IFTYPE_ADHOC) { rtl_cam_add_one_entry(hw, diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c index 28a1a707d09c..09758f48d3e6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c @@ -45,8 +45,8 @@ void rtl92ce_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) u8 ledcfg; struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + REG_LEDCFG2, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); @@ -62,7 +62,7 @@ void rtl92ce_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = true; @@ -74,8 +74,8 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); u8 ledcfg; - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + REG_LEDCFG2, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); @@ -97,7 +97,7 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = false; @@ -145,7 +145,7 @@ void rtl92ce_led_control(struct ieee80211_hw *hw, ledaction == LED_CTL_POWER_ON)) { return; } - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d.\n", - ledaction)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d\n", + ledaction); _rtl92ce_sw_led_control(hw, ledaction); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c index ce9eea94bb53..03ee82e05f2f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c @@ -47,9 +47,9 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw, u32 original_value, readback_value, bitshift; struct rtl_phy *rtlphy = &(rtlpriv->phy); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "rfpath(%#x), bitmask(%#x)\n", - regaddr, rfpath, bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n", + regaddr, rfpath, bitmask); spin_lock(&rtlpriv->locks.rf_lock); @@ -67,9 +67,8 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw, spin_unlock(&rtlpriv->locks.rf_lock); RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("regaddr(%#x), rfpath(%#x), " - "bitmask(%#x), original_value(%#x)\n", - regaddr, rfpath, bitmask, original_value)); + "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n", + regaddr, rfpath, bitmask, original_value); return readback_value; } @@ -121,8 +120,8 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw, u32 original_value, bitshift; RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); spin_lock(&rtlpriv->locks.rf_lock); @@ -153,10 +152,9 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw, spin_unlock(&rtlpriv->locks.rf_lock); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x), data(%#x), " - "rfpath(%#x)\n", regaddr, - bitmask, data, rfpath)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); } static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) @@ -166,11 +164,10 @@ static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) u32 arraylength; u32 *ptrarray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Read Rtl819XMACPHY_Array\n"); arraylength = MAC_2T_ARRAYLENGTH; ptrarray = RTL8192CEMAC_2T_ARRAY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Img:RTL8192CEMAC_2T_ARRAY\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Img:RTL8192CEMAC_2T_ARRAY\n"); for (i = 0; i < arraylength; i = i + 2) rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); return true; @@ -215,10 +212,9 @@ bool _rtl92ce_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, phy_regarray_table[i + 1]); udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The phy_regarray_table[0] is %x" - " Rtl819XPHY_REGArray[1] is %x\n", - phy_regarray_table[i], - phy_regarray_table[i + 1])); + "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n", + phy_regarray_table[i], + phy_regarray_table[i + 1]); } } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { for (i = 0; i < agctab_arraylen; i = i + 2) { @@ -226,10 +222,9 @@ bool _rtl92ce_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, agctab_array_table[i + 1]); udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The agctab_array_table[0] is " - "%x Rtl819XPHY_REGArray[1] is %x\n", - agctab_array_table[i], - agctab_array_table[i + 1])); + "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n", + agctab_array_table[i], + agctab_array_table[i + 1]); } } return true; @@ -269,7 +264,7 @@ bool _rtl92ce_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, } else { RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("configtype != BaseBand_Config_PHY_REG\n")); + "configtype != BaseBand_Config_PHY_REG\n"); } return true; } @@ -291,20 +286,20 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, radiob_arraylen = RADIOB_2TARRAYLENGTH; radiob_array_table = RTL8192CE_RADIOB_2TARRAY; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_A:RTL8192CERADIOA_2TARRAY\n")); + "Radio_A:RTL8192CERADIOA_2TARRAY\n"); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_B:RTL8192CE_RADIOB_2TARRAY\n")); + "Radio_B:RTL8192CE_RADIOB_2TARRAY\n"); } else { radioa_arraylen = RADIOA_1TARRAYLENGTH; radioa_array_table = RTL8192CE_RADIOA_1TARRAY; radiob_arraylen = RADIOB_1TARRAYLENGTH; radiob_array_table = RTL8192CE_RADIOB_1TARRAY; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_A:RTL8192CE_RADIOA_1TARRAY\n")); + "Radio_A:RTL8192CE_RADIOA_1TARRAY\n"); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_B:RTL8192CE_RADIOB_1TARRAY\n")); + "Radio_B:RTL8192CE_RADIOB_1TARRAY\n"); } - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio No %x\n", rfpath); switch (rfpath) { case RF90_PATH_A: for (i = 0; i < radioa_arraylen; i = i + 2) { @@ -352,11 +347,11 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, break; case RF90_PATH_C: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; case RF90_PATH_D: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } return true; @@ -371,10 +366,9 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw) u8 reg_bw_opmode; u8 reg_prsr_rsc; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("Switch to %s bandwidth\n", - rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n", + rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz"); if (is_hal_stop(rtlhal)) { rtlphy->set_bwmode_inprogress = false; @@ -398,7 +392,7 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } @@ -423,12 +417,12 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } rtl92ce_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); rtlphy->set_bwmode_inprogress = false; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); } void _rtl92ce_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) @@ -499,7 +493,7 @@ static void _rtl92ce_phy_set_rf_sleep(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Switch RF timeout !!!.\n")); + "Switch RF timeout !!!\n"); return; } rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); @@ -526,7 +520,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, do { InitializeCount++; RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic enable\n")); + "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); } while ((rtstatus != true) && (InitializeCount < 10)); @@ -534,10 +528,10 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_RF_OFF_LEVL_HALT_NIC); } else { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("Set ERFON sleeped:%d ms\n", - jiffies_to_msecs(jiffies - - ppsc-> - last_sleep_jiffies))); + "Set ERFON sleeped:%d ms\n", + jiffies_to_msecs(jiffies - + ppsc-> + last_sleep_jiffies)); ppsc->last_awake_jiffies = jiffies; rtl92ce_phy_set_rf_on(hw); } @@ -553,7 +547,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, case ERFOFF:{ if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic disable\n")); + "IPS Set eRf nic disable\n"); rtl_ps_disable_nic(hw); RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); } else { @@ -578,35 +572,33 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, continue; } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("eRf Off/Sleep: %d times " - "TcbBusyQueue[%d] =%d before " - "doze!\n", (i + 1), queue_id, - skb_queue_len(&ring->queue))); + "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n", + i + 1, queue_id, + skb_queue_len(&ring->queue)); udelay(10); i++; } if (i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("\n ERFSLEEP: %d times " - "TcbBusyQueue[%d] = %d !\n", - MAX_DOZE_WAITING_TIMES_9x, - queue_id, - skb_queue_len(&ring->queue))); + "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n", + MAX_DOZE_WAITING_TIMES_9x, + queue_id, + skb_queue_len(&ring->queue)); break; } } RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("Set ERFSLEEP awaked:%d ms\n", - jiffies_to_msecs(jiffies - - ppsc->last_awake_jiffies))); + "Set ERFSLEEP awaked:%d ms\n", + jiffies_to_msecs(jiffies - + ppsc->last_awake_jiffies)); ppsc->last_sleep_jiffies = jiffies; _rtl92ce_phy_set_rf_sleep(hw); break; } default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); bresult = false; break; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c index d3b01e6023ba..3ba1a4feeb3f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c @@ -56,7 +56,7 @@ void rtl92ce_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", bandwidth)); + "unknown bandwidth: %#X\n", bandwidth); break; } } @@ -512,12 +512,12 @@ static bool _rtl92ce_phy_rf6052_config_parafile(struct ieee80211_hw *hw) if (rtstatus != true) { RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio[%d] Fail!!", rfpath)); + "Radio[%d] Fail!!\n", rfpath); return false; } } - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "<---\n"); return rtstatus; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index 89ef6982ce50..d2a3576fdaa5 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c @@ -159,7 +159,7 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->rtlhal.pfirmware = vzalloc(0x4000); if (!rtlpriv->rtlhal.pfirmware) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't alloc buffer for fw.\n")); + "Can't alloc buffer for fw\n"); return 1; } @@ -174,12 +174,12 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) err = request_firmware(&firmware, fw_name, rtlpriv->io.dev); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to request firmware!\n")); + "Failed to request firmware!\n"); return 1; } if (firmware->size > 0x4000) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is too big!\n")); + "Firmware is too big!\n"); release_firmware(firmware); return 1; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c index 378bc5673464..9f6fac450a48 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c @@ -725,7 +725,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, if (ieee80211_is_data_qos(fc)) { if (mac->rdg_en) { RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("Enable RDG function.\n")); + "Enable RDG function\n"); SET_TX_DESC_RDG_ENABLE(pdesc, 1); SET_TX_DESC_HTC(pdesc, 1); } @@ -763,7 +763,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw, SET_TX_DESC_BMC(pdesc, 1); } - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); + RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); } void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c index f311baee668d..c0016f3194e5 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c @@ -52,7 +52,7 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw) if ((mac->link_state < MAC80211_LINKED) && (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Not connected to any\n")); + "Not connected to any\n"); rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; @@ -65,28 +65,28 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw) undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Client PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } else { undecorated_smoothed_pwdb = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "STA Default Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } } else { undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Ext Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n"); } else if ((undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && (undecorated_smoothed_pwdb >= @@ -94,18 +94,18 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw) rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n"); } else if (undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_NORMAL\n")); + "TXHIGHPWRLEVEL_NORMAL\n"); } if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("PHY_SetTxPowerLevel8192S() Channel = %d\n", - rtlphy->current_channel)); + "PHY_SetTxPowerLevel8192S() Channel = %d\n", + rtlphy->current_channel); rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 778c0e6e836b..80bd17d85935 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -494,17 +494,17 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) HWSET_MAX_SIZE); } else if (rtlefuse->epromtype == EEPROM_93C46) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); + "RTL819X Not boot from eeprom, check it !!\n"); } RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, "MAP", hwinfo, HWSET_MAX_SIZE); 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)); + "EEPROM ID(%#x) is invalid!!\n", eeprom_id); rtlefuse->autoload_failflag = true; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; } if (rtlefuse->autoload_failflag) @@ -518,16 +518,15 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->autoload_failflag, hwinfo); 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)); + 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 = 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, - ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x\n", + rtlefuse->eeprom_oemid); if (rtlhal->oem_id == RT_CID_DEFAULT) { switch (rtlefuse->eeprom_oemid) { case EEPROM_CID_DEFAULT: @@ -579,8 +578,8 @@ static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw) default: break; } - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("RT Customized ID: 0x%02X\n", rtlhal->oem_id)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "RT Customized ID: 0x%02X\n", + rtlhal->oem_id); } void rtl92cu_read_eeprom_info(struct ieee80211_hw *hw) @@ -596,11 +595,11 @@ void rtl92cu_read_eeprom_info(struct ieee80211_hw *hw) tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); rtlefuse->epromtype = (tmp_u1b & BOOT_FROM_EEPROM) ? EEPROM_93C46 : EEPROM_BOOT_EFUSE; - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from %s\n", - (tmp_u1b & BOOT_FROM_EEPROM) ? "EERROM" : "EFUSE")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from %s\n", + tmp_u1b & BOOT_FROM_EEPROM ? "EERROM" : "EFUSE"); rtlefuse->autoload_failflag = (tmp_u1b & EEPROM_EN) ? false : true; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload %s\n", - (tmp_u1b & EEPROM_EN) ? "OK!!" : "ERR!!")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload %s\n", + tmp_u1b & EEPROM_EN ? "OK!!" : "ERR!!"); _rtl92cu_read_adapter_info(hw); _rtl92cu_hal_customized_behavior(hw); return; @@ -618,13 +617,12 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw) do { if (rtl_read_byte(rtlpriv, REG_APS_FSMCO) & PFM_ALDN) { RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Autoload Done!\n")); + "Autoload Done!\n"); break; } if (pollingCount++ > 100) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Failed to polling REG_APS_FSMCO[PFM_ALDN]" - " done!\n")); + "Failed to polling REG_APS_FSMCO[PFM_ALDN] done!\n"); return -ENODEV; } } while (true); @@ -639,8 +637,8 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw) value8 |= LDV12_EN; rtl_write_byte(rtlpriv, REG_LDOV12D_CTRL, value8); RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - (" power-on :REG_LDOV12D_CTRL Reg0x21:0x%02x.\n", - value8)); + " power-on :REG_LDOV12D_CTRL Reg0x21:0x%02x\n", + value8); udelay(100); value8 = rtl_read_byte(rtlpriv, REG_SYS_ISO_CTRL); value8 &= ~ISO_MD2PP; @@ -658,8 +656,7 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw) } if (pollingCount++ > 100) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Failed to polling REG_APS_FSMCO[APFM_ONMAC]" - " done!\n")); + "Failed to polling REG_APS_FSMCO[APFM_ONMAC] done!\n"); return -ENODEV; } } while (true); @@ -877,8 +874,8 @@ static void _rtl92cu_init_chipN_three_out_ep_priority(struct ieee80211_hw *hw, hiQ = QUEUE_HIGH; } _rtl92c_init_chipN_reg_priority(hw, beQ, bkQ, viQ, voQ, mgtQ, hiQ); - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Tx queue select :0x%02x..\n", queue_sel)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Tx queue select :0x%02x..\n", + queue_sel); } static void _rtl92cu_init_chipN_queue_priority(struct ieee80211_hw *hw, @@ -937,8 +934,8 @@ static void _rtl92cu_init_chipT_queue_priority(struct ieee80211_hw *hw, break; } rtl_write_byte(rtlpriv, (REG_TRXDMA_CTRL+1), hq_sele); - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Tx queue select :0x%02x..\n", hq_sele)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Tx queue select :0x%02x..\n", + hq_sele); } static void _rtl92cu_init_queue_priority(struct ieee80211_hw *hw, @@ -998,7 +995,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw) if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to init power on!\n")); + "Failed to init power on!\n"); return err; } if (!wmm_enable) { @@ -1010,7 +1007,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw) } if (false == rtl92c_init_llt_table(hw, boundary)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to init LLT Table!\n")); + "Failed to init LLT Table!\n"); return -EINVAL; } _rtl92cu_init_queue_reserved_page(hw, wmm_enable, out_ep_nums, @@ -1043,12 +1040,12 @@ void rtl92cu_enable_hw_security_config(struct ieee80211_hw *hw) struct rtl_hal *rtlhal = rtl_hal(rtlpriv); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", - rtlpriv->sec.pairwise_enc_algorithm, - rtlpriv->sec.group_enc_algorithm)); + "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", + rtlpriv->sec.pairwise_enc_algorithm, + rtlpriv->sec.group_enc_algorithm); if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("not open sw encryption\n")); + "not open sw encryption\n"); return; } sec_reg_value = SCR_TxEncEnable | SCR_RxDecEnable; @@ -1059,8 +1056,8 @@ void rtl92cu_enable_hw_security_config(struct ieee80211_hw *hw) if (IS_NORMAL_CHIP(rtlhal->version)) sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The SECR-value %x\n", sec_reg_value)); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "The SECR-value %x\n", + sec_reg_value); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); } @@ -1163,13 +1160,13 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw) rtlhal->hw_type = HARDWARE_TYPE_RTL8192CU; err = _rtl92cu_init_mac(hw); if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("init mac failed!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "init mac failed!\n"); return err; } err = rtl92c_download_fw(hw); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Failed to download FW. Init HW without FW now..\n")); + "Failed to download FW. Init HW without FW now..\n"); err = 1; rtlhal->fw_ready = false; return err; @@ -1280,8 +1277,7 @@ static void _ResetDigitalProcedure1(struct ieee80211_hw *hw, bool bWithoutHWSM) } if (retry_cnts >= 100) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("#####=> 8051 reset failed!.." - ".......................\n");); + "#####=> 8051 reset failed!.........................\n"); /* if 8051 reset fail, reset MAC. */ rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, @@ -1495,35 +1491,36 @@ static int _rtl92cu_set_media_status(struct ieee80211_hw *hw, _rtl92cu_resume_tx_beacon(hw); _rtl92cu_disable_bcn_sub_func(hw); } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, ("Set HW_VAR_MEDIA_" - "STATUS:No such media status(%x).\n", type)); + RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, + "Set HW_VAR_MEDIA_STATUS:No such media status(%x)\n", + type); } switch (type) { case NL80211_IFTYPE_UNSPECIFIED: bt_msr |= MSR_NOLINK; ledaction = LED_CTL_LINK; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to NO LINK!\n")); + "Set Network type to NO LINK!\n"); break; case NL80211_IFTYPE_ADHOC: bt_msr |= MSR_ADHOC; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to Ad Hoc!\n")); + "Set Network type to Ad Hoc!\n"); break; case NL80211_IFTYPE_STATION: bt_msr |= MSR_INFRA; ledaction = LED_CTL_LINK; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to STA!\n")); + "Set Network type to STA!\n"); break; case NL80211_IFTYPE_AP: bt_msr |= MSR_AP; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to AP!\n")); + "Set Network type to AP!\n"); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Network type %d not support!\n", type)); + "Network type %d not supported!\n", type); goto error_out; } rtl_write_byte(rtlpriv, (MSR), bt_msr); @@ -1684,8 +1681,8 @@ void rtl92cu_set_beacon_related_registers(struct ieee80211_hw *hw) value32 |= TSFRST; rtl_write_dword(rtlpriv, REG_TCR, value32); RT_TRACE(rtlpriv, COMP_INIT|COMP_BEACON, DBG_LOUD, - ("SetBeaconRelatedRegisters8192CUsb(): Set TCR(%x)\n", - value32)); + "SetBeaconRelatedRegisters8192CUsb(): Set TCR(%x)\n", + value32); /* TODO: Modify later (Find the right parameters) * NOTE: Fix test chip's bug (about contention windows's randomness) */ if ((mac->opmode == NL80211_IFTYPE_ADHOC) || @@ -1702,8 +1699,8 @@ void rtl92cu_set_beacon_interval(struct ieee80211_hw *hw) struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); u16 bcn_interval = mac->beacon_interval; - RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, - ("beacon_interval:%d\n", bcn_interval)); + RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, "beacon_interval:%d\n", + bcn_interval); rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); } @@ -1767,7 +1764,7 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } @@ -1827,8 +1824,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]); rtl_write_byte(rtlpriv, REG_R2T_SIFS+1, val[0]); rtl_write_byte(rtlpriv, REG_T2T_SIFS+1, val[0]); - RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("HW_VAR_SIFS\n")); + RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, "HW_VAR_SIFS\n"); break; } case HW_VAR_SLOT_TIME:{ @@ -1837,7 +1833,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_byte(rtlpriv, REG_SLOT, val[0]); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("HW_VAR_SLOT_TIME %x\n", val[0])); + "HW_VAR_SLOT_TIME %x\n", val[0]); if (QOS_MODE) { for (e_aci = 0; e_aci < AC_MAX; e_aci++) rtlpriv->cfg->ops->set_hw_reg(hw, @@ -1901,8 +1897,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) min_spacing_to_set); *val = min_spacing_to_set; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, mac->min_space_cfg); } @@ -1916,8 +1912,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) mac->min_space_cfg &= 0x07; mac->min_space_cfg |= (density_to_set << 3); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_SHORTGI_DENSITY: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, mac->min_space_cfg); break; @@ -1950,8 +1946,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) p_regtoset[index]); } RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_FACTOR: %#x\n", - factor_toset)); + "Set HW_VAR_AMPDU_FACTOR: %#x\n", + factor_toset); } break; } @@ -1969,8 +1965,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) AC_PARAM_ECW_MAX_OFFSET); u4b_ac_param |= (u32) tx_op << AC_PARAM_TXOP_OFFSET; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("queue:%x, ac_param:%x\n", e_aci, - u4b_ac_param)); + "queue:%x, ac_param:%x\n", + e_aci, u4b_ac_param); switch (e_aci) { case AC1_BK: rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, @@ -2020,8 +2016,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("HW_VAR_ACM_CTRL acm set " - "failed: eACI is %d\n", acm)); + "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n", + acm); break; } } else { @@ -2037,13 +2033,13 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, - ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " - "Write 0x%X\n", acm_ctrl)); + "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", + acm_ctrl); rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); break; } @@ -2051,7 +2047,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_dword(rtlpriv, REG_RCR, ((u32 *) (val))[0]); mac->rx_conf = ((u32 *) (val))[0]; RT_TRACE(rtlpriv, COMP_RECV, DBG_DMESG, - ("### Set RCR(0x%08x) ###\n", mac->rx_conf)); + "### Set RCR(0x%08x) ###\n", mac->rx_conf); break; } case HW_VAR_RETRY_LIMIT:{ @@ -2060,8 +2056,9 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_word(rtlpriv, REG_RL, retry_limit << RETRY_LIMIT_SHORT_SHIFT | retry_limit << RETRY_LIMIT_LONG_SHIFT); - RT_TRACE(rtlpriv, COMP_MLME, DBG_DMESG, ("Set HW_VAR_R" - "ETRY_LIMIT(0x%08x)\n", retry_limit)); + RT_TRACE(rtlpriv, COMP_MLME, DBG_DMESG, + "Set HW_VAR_RETRY_LIMIT(0x%08x)\n", + retry_limit); break; } case HW_VAR_DUAL_TSF_RST: @@ -2165,8 +2162,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_word(rtlpriv, REG_RXFLTMAP2, *(u16 *)val); break; default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " - "not process\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "switch case not processed\n"); break; } } @@ -2239,8 +2236,8 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, (shortgi_rate << 4) | (shortgi_rate); } rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("%x\n", rtl_read_dword(rtlpriv, - REG_ARFR0))); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n", + rtl_read_dword(rtlpriv, REG_ARFR0)); } void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) @@ -2344,17 +2341,16 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) ratr_bitmap &= 0x0f0ff0ff; break; } - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("ratr_bitmap :%x\n", - ratr_bitmap)); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "ratr_bitmap :%x\n", + ratr_bitmap); *(u32 *)&rate_mask = ((ratr_bitmap & 0x0fffffff) | ratr_index << 28); rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("Rate_index:%x, " - "ratr_val:%x, %x:%x:%x:%x:%x\n", - ratr_index, ratr_bitmap, - rate_mask[0], rate_mask[1], - rate_mask[2], rate_mask[3], - rate_mask[4])); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, + "Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x\n", + ratr_index, ratr_bitmap, + rate_mask[0], rate_mask[1], rate_mask[2], rate_mask[3], + rate_mask[4]); rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask); } @@ -2404,7 +2400,7 @@ bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid) e_rfpowerstate_toset = (u1tmp & BIT(7)) ? ERFOFF : ERFON; RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("pwrdown, 0x5c(BIT7)=%02x\n", u1tmp)); + "pwrdown, 0x5c(BIT7)=%02x\n", u1tmp); } else { rtl_write_byte(rtlpriv, REG_MAC_PINMUX_CFG, rtl_read_byte(rtlpriv, @@ -2413,27 +2409,26 @@ bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid) e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("GPIO_IN=%02x\n", u1tmp)); + "GPIO_IN=%02x\n", u1tmp); } - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("N-SS RF =%x\n", - e_rfpowerstate_toset)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "N-SS RF =%x\n", + e_rfpowerstate_toset); } if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("GPIOChangeRF - HW " - "Radio ON, RF ON\n")); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, + "GPIOChangeRF - HW Radio ON, RF ON\n"); ppsc->hwradiooff = false; actuallyset = true; } else if ((!ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFOFF)) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("GPIOChangeRF - HW" - " Radio OFF\n")); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, + "GPIOChangeRF - HW Radio OFF\n"); ppsc->hwradiooff = true; actuallyset = true; } else { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD , - ("pHalData->bHwRadioOff and eRfPowerStateToSet do not" - " match: pHalData->bHwRadioOff %x, eRfPowerStateToSet " - "%x\n", ppsc->hwradiooff, e_rfpowerstate_toset)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, + "pHalData->bHwRadioOff and eRfPowerStateToSet do not match: pHalData->bHwRadioOff %x, eRfPowerStateToSet %x\n", + ppsc->hwradiooff, e_rfpowerstate_toset); } if (actuallyset) { ppsc->hwradiooff = true; diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/led.c b/drivers/net/wireless/rtlwifi/rtl8192cu/led.c index 2ff9d8314e7b..65fd04424623 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/led.c @@ -47,8 +47,8 @@ void rtl92cu_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) u8 ledcfg; struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + REG_LEDCFG2, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); switch (pled->ledpin) { case LED_PIN_GPIO0: @@ -62,7 +62,7 @@ void rtl92cu_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = true; @@ -74,8 +74,8 @@ void rtl92cu_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) struct rtl_usb_priv *usbpriv = rtl_usbpriv(hw); u8 ledcfg; - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + REG_LEDCFG2, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); switch (pled->ledpin) { case LED_PIN_GPIO0: @@ -95,7 +95,7 @@ void rtl92cu_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = false; @@ -136,7 +136,6 @@ void rtl92cu_led_control(struct ieee80211_hw *hw, ledaction == LED_CTL_POWER_ON)) { return; } - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", - ledaction)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d\n", ledaction); _rtl92cu_sw_led_control(hw, ledaction); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 487ee908d7c5..9f09844d7d50 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -88,67 +88,59 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw) switch (rtlhal->version) { case VERSION_NORMAL_TSMC_CHIP_92C_1T2R: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_B_CHIP_92C.\n")); + "Chip Version ID: VERSION_B_CHIP_92C\n"); break; case VERSION_NORMAL_TSMC_CHIP_92C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_TSMC_CHIP_92C.\n")); + "Chip Version ID: VERSION_NORMAL_TSMC_CHIP_92C\n"); break; case VERSION_NORMAL_TSMC_CHIP_88C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_TSMC_CHIP_88C.\n")); + "Chip Version ID: VERSION_NORMAL_TSMC_CHIP_88C\n"); break; case VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_UMC_CHIP_i" - "92C_1T2R_A_CUT.\n")); + "Chip Version ID: VERSION_NORMAL_UMC_CHIP_i92C_1T2R_A_CUT\n"); break; case VERSION_NORMAL_UMC_CHIP_92C_A_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_UMC_CHIP_" - "92C_A_CUT.\n")); + "Chip Version ID: VERSION_NORMAL_UMC_CHIP_92C_A_CUT\n"); break; case VERSION_NORMAL_UMC_CHIP_88C_A_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_UMC_CHIP" - "_88C_A_CUT.\n")); + "Chip Version ID: VERSION_NORMAL_UMC_CHIP_88C_A_CUT\n"); break; case VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_UMC_CHIP" - "_92C_1T2R_B_CUT.\n")); + "Chip Version ID: VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT\n"); break; case VERSION_NORMAL_UMC_CHIP_92C_B_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_UMC_CHIP" - "_92C_B_CUT.\n")); + "Chip Version ID: VERSION_NORMAL_UMC_CHIP_92C_B_CUT\n"); break; case VERSION_NORMAL_UMC_CHIP_88C_B_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMAL_UMC_CHIP" - "_88C_B_CUT.\n")); + "Chip Version ID: VERSION_NORMAL_UMC_CHIP_88C_B_CUT\n"); break; case VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMA_UMC_CHIP" - "_8723_1T1R_A_CUT.\n")); + "Chip Version ID: VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT\n"); break; case VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_NORMA_UMC_CHIP" - "_8723_1T1R_B_CUT.\n")); + "Chip Version ID: VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT\n"); break; case VERSION_TEST_CHIP_92C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_TEST_CHIP_92C.\n")); + "Chip Version ID: VERSION_TEST_CHIP_92C\n"); break; case VERSION_TEST_CHIP_88C: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: VERSION_TEST_CHIP_88C.\n")); + "Chip Version ID: VERSION_TEST_CHIP_88C\n"); break; default: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Chip Version ID: ???????????????.\n")); + "Chip Version ID: ???????????????\n"); break; } if (IS_92C_SERIAL(rtlhal->version)) @@ -157,15 +149,15 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw) else rtlphy->rf_type = RF_1T1R; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Chip RF Type: %s\n", (rtlphy->rf_type == RF_2T2R) ? - "RF_2T2R" : "RF_1T1R")); + "Chip RF Type: %s\n", + rtlphy->rf_type == RF_2T2R ? "RF_2T2R" : "RF_1T1R"); if (get_rf_type(rtlphy) == RF_1T1R) rtlpriv->dm.rfpath_rxenable[0] = true; else rtlpriv->dm.rfpath_rxenable[0] = rtlpriv->dm.rfpath_rxenable[1] = true; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", - rtlhal->version)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n", + rtlhal->version); } /** @@ -192,9 +184,8 @@ bool rtl92c_llt_write(struct ieee80211_hw *hw, u32 address, u32 data) break; if (count > POLLING_LLT_THRESHOLD) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to polling write LLT done at" - " address %d! _LLT_OP_VALUE(%x)\n", - address, _LLT_OP_VALUE(value))); + "Failed to polling write LLT done at address %d! _LLT_OP_VALUE(%x)\n", + address, _LLT_OP_VALUE(value)); status = false; break; } @@ -272,7 +263,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index, u8 cam_offset = 0; u8 clear_number = 5; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n"); for (idx = 0; idx < clear_number; idx++) { rtl_cam_mark_invalid(hw, cam_offset + idx); rtl_cam_empty_entry(hw, cam_offset + idx); @@ -298,7 +289,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("iillegal switch case\n")); + "illegal switch case\n"); enc_algo = CAM_TKIP; break; } @@ -317,18 +308,18 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index, } if (rtlpriv->sec.key_len[key_index] == 0) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("delete one entry\n")); + "delete one entry\n"); rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY length is %d\n", - rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); + "The insert KEY length is %d\n", + rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY is %x %x\n", - rtlpriv->sec.key_buf[0][0], - rtlpriv->sec.key_buf[0][1])); + "The insert KEY is %x %x\n", + rtlpriv->sec.key_buf[0][0], + rtlpriv->sec.key_buf[0][1]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("add one entry\n")); + "add one entry\n"); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, "Pairwise Key content", @@ -336,7 +327,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index, rtlpriv->sec. key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set Pairwiase key\n")); + "set Pairwise key\n"); rtl_cam_add_one_entry(hw, macaddr, key_index, entry_id, enc_algo, @@ -345,7 +336,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index, key_buf[key_index]); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set group key\n")); + "set group key\n"); if (mac->opmode == NL80211_IFTYPE_ADHOC) { rtl_cam_add_one_entry(hw, rtlefuse->dev_addr, @@ -421,8 +412,8 @@ void rtl92c_set_qos(struct ieee80211_hw *hw, int aci) AC_PARAM_ECW_MAX_OFFSET; u4b_ac_param |= (u32) le16_to_cpu(mac->ac[aci].tx_op) << AC_PARAM_TXOP_OFFSET; - RT_TRACE(rtlpriv, COMP_QOS, DBG_LOUD, - ("queue:%x, ac_param:%x\n", aci, u4b_ac_param)); + RT_TRACE(rtlpriv, COMP_QOS, DBG_LOUD, "queue:%x, ac_param:%x\n", + aci, u4b_ac_param); switch (aci) { case AC1_BK: rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, u4b_ac_param); @@ -453,14 +444,14 @@ void rtl92c_set_mac_addr(struct ieee80211_hw *hw, const u8 *addr) for (i = 0 ; i < ETH_ALEN ; i++) rtl_write_byte(rtlpriv, (REG_MACID + i), *(addr+i)); - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("MAC Address: %02X-%02X-%02X-" - "%02X-%02X-%02X\n", - rtl_read_byte(rtlpriv, REG_MACID), - rtl_read_byte(rtlpriv, REG_MACID+1), - rtl_read_byte(rtlpriv, REG_MACID+2), - rtl_read_byte(rtlpriv, REG_MACID+3), - rtl_read_byte(rtlpriv, REG_MACID+4), - rtl_read_byte(rtlpriv, REG_MACID+5))); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, + "MAC Address: %02X-%02X-%02X-%02X-%02X-%02X\n", + rtl_read_byte(rtlpriv, REG_MACID), + rtl_read_byte(rtlpriv, REG_MACID+1), + rtl_read_byte(rtlpriv, REG_MACID+2), + rtl_read_byte(rtlpriv, REG_MACID+3), + rtl_read_byte(rtlpriv, REG_MACID+4), + rtl_read_byte(rtlpriv, REG_MACID+5)); } void rtl92c_init_driver_info_size(struct ieee80211_hw *hw, u8 size) @@ -478,26 +469,26 @@ int rtl92c_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type) case NL80211_IFTYPE_UNSPECIFIED: value = NT_NO_LINK; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Set Network type to NO LINK!\n")); + "Set Network type to NO LINK!\n"); break; case NL80211_IFTYPE_ADHOC: value = NT_LINK_AD_HOC; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Set Network type to Ad Hoc!\n")); + "Set Network type to Ad Hoc!\n"); break; case NL80211_IFTYPE_STATION: value = NT_LINK_AP; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Set Network type to STA!\n")); + "Set Network type to STA!\n"); break; case NL80211_IFTYPE_AP: value = NT_AS_AP; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Set Network type to AP!\n")); + "Set Network type to AP!\n"); break; default: RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Network type %d not support!\n", type)); + "Network type %d not supported!\n", type); return -EOPNOTSUPP; } rtl_write_byte(rtlpriv, (REG_CR + 2), value); diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c index df491d38eccc..e7ea2bae2105 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c @@ -44,9 +44,9 @@ u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw, u32 original_value, readback_value, bitshift; struct rtl_phy *rtlphy = &(rtlpriv->phy); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "rfpath(%#x), bitmask(%#x)\n", - regaddr, rfpath, bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n", + regaddr, rfpath, bitmask); if (rtlphy->rf_mode != RF_OP_BY_FW) { original_value = _rtl92c_phy_rf_serial_read(hw, rfpath, regaddr); @@ -57,9 +57,8 @@ u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw, bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); readback_value = (original_value & bitmask) >> bitshift; RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("regaddr(%#x), rfpath(%#x), " - "bitmask(%#x), original_value(%#x)\n", - regaddr, rfpath, bitmask, original_value)); + "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n", + regaddr, rfpath, bitmask, original_value); return readback_value; } @@ -72,8 +71,8 @@ void rtl92cu_phy_set_rf_reg(struct ieee80211_hw *hw, u32 original_value, bitshift; RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); if (rtlphy->rf_mode != RF_OP_BY_FW) { if (bitmask != RFREG_OFFSET_MASK) { original_value = _rtl92c_phy_rf_serial_read(hw, @@ -97,9 +96,9 @@ void rtl92cu_phy_set_rf_reg(struct ieee80211_hw *hw, } _rtl92c_phy_fw_rf_serial_write(hw, rfpath, regaddr, data); } - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); } bool rtl92cu_phy_mac_config(struct ieee80211_hw *hw) @@ -152,11 +151,10 @@ bool _rtl92cu_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) u32 arraylength; u32 *ptrarray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Read Rtl819XMACPHY_Array\n"); arraylength = rtlphy->hwparam_tables[MAC_REG].length ; ptrarray = rtlphy->hwparam_tables[MAC_REG].pdata; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Img:RTL8192CEMAC_2T_ARRAY\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Img:RTL8192CEMAC_2T_ARRAY\n"); for (i = 0; i < arraylength; i = i + 2) rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); return true; @@ -202,10 +200,9 @@ bool _rtl92cu_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, phy_regarray_table[i + 1]); udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The phy_regarray_table[0] is %x" - " Rtl819XPHY_REGArray[1] is %x\n", - phy_regarray_table[i], - phy_regarray_table[i + 1])); + "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n", + phy_regarray_table[i], + phy_regarray_table[i + 1]); } } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { for (i = 0; i < agctab_arraylen; i = i + 2) { @@ -213,10 +210,9 @@ bool _rtl92cu_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, agctab_array_table[i + 1]); udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The agctab_array_table[0] is " - "%x Rtl819XPHY_REGArray[1] is %x\n", - agctab_array_table[i], - agctab_array_table[i + 1])); + "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n", + agctab_array_table[i], + agctab_array_table[i + 1]); } } return true; @@ -255,7 +251,7 @@ bool _rtl92cu_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, } } else { RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("configtype != BaseBand_Config_PHY_REG\n")); + "configtype != BaseBand_Config_PHY_REG\n"); } return true; } @@ -277,20 +273,20 @@ bool rtl92cu_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, radiob_arraylen = rtlphy->hwparam_tables[RADIOB_2T].length; radiob_array_table = rtlphy->hwparam_tables[RADIOB_2T].pdata; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_A:RTL8192CERADIOA_2TARRAY\n")); + "Radio_A:RTL8192CERADIOA_2TARRAY\n"); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_B:RTL8192CE_RADIOB_2TARRAY\n")); + "Radio_B:RTL8192CE_RADIOB_2TARRAY\n"); } else { radioa_arraylen = rtlphy->hwparam_tables[RADIOA_1T].length; radioa_array_table = rtlphy->hwparam_tables[RADIOA_1T].pdata; radiob_arraylen = rtlphy->hwparam_tables[RADIOB_1T].length; radiob_array_table = rtlphy->hwparam_tables[RADIOB_1T].pdata; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_A:RTL8192CE_RADIOA_1TARRAY\n")); + "Radio_A:RTL8192CE_RADIOA_1TARRAY\n"); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio_B:RTL8192CE_RADIOB_1TARRAY\n")); + "Radio_B:RTL8192CE_RADIOB_1TARRAY\n"); } - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio No %x\n", rfpath); switch (rfpath) { case RF90_PATH_A: for (i = 0; i < radioa_arraylen; i = i + 2) { @@ -338,11 +334,11 @@ bool rtl92cu_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, break; case RF90_PATH_C: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; case RF90_PATH_D: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } return true; @@ -357,10 +353,9 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw) u8 reg_bw_opmode; u8 reg_prsr_rsc; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("Switch to %s bandwidth\n", - rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n", + rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz"); if (is_hal_stop(rtlhal)) { rtlphy->set_bwmode_inprogress = false; return; @@ -381,7 +376,7 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } switch (rtlphy->current_chan_bw) { @@ -403,12 +398,12 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } rtl92cu_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); rtlphy->set_bwmode_inprogress = false; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); } void rtl92cu_bb_block_on(struct ieee80211_hw *hw) @@ -480,7 +475,7 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, do { InitializeCount++; RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic enable\n")); + "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); } while ((rtstatus != true) && (InitializeCount < 10)); @@ -488,10 +483,9 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_RF_OFF_LEVL_HALT_NIC); } else { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("Set ERFON sleeped:%d ms\n", - jiffies_to_msecs(jiffies - - ppsc-> - last_sleep_jiffies))); + "Set ERFON sleeped:%d ms\n", + jiffies_to_msecs(jiffies - + ppsc->last_sleep_jiffies)); ppsc->last_awake_jiffies = jiffies; rtl92ce_phy_set_rf_on(hw); } @@ -513,27 +507,25 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, continue; } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("eRf Off/Sleep: %d times " - "TcbBusyQueue[%d] " - "=%d before doze!\n", (i + 1), - queue_id, - skb_queue_len(&ring->queue))); + "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n", + i + 1, + queue_id, + skb_queue_len(&ring->queue)); udelay(10); i++; } if (i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("\nERFOFF: %d times " - "TcbBusyQueue[%d] = %d !\n", - MAX_DOZE_WAITING_TIMES_9x, - queue_id, - skb_queue_len(&ring->queue))); + "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n", + MAX_DOZE_WAITING_TIMES_9x, + queue_id, + skb_queue_len(&ring->queue)); break; } } if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic disable\n")); + "IPS Set eRf nic disable\n"); rtl_ps_disable_nic(hw); RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); } else { @@ -557,33 +549,30 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, continue; } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("eRf Off/Sleep: %d times " - "TcbBusyQueue[%d] =%d before " - "doze!\n", (i + 1), queue_id, - skb_queue_len(&ring->queue))); + "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n", + i + 1, queue_id, + skb_queue_len(&ring->queue)); udelay(10); i++; } if (i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("\n ERFSLEEP: %d times " - "TcbBusyQueue[%d] = %d !\n", - MAX_DOZE_WAITING_TIMES_9x, - queue_id, - skb_queue_len(&ring->queue))); + "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n", + MAX_DOZE_WAITING_TIMES_9x, + queue_id, + skb_queue_len(&ring->queue)); break; } } RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("Set ERFSLEEP awaked:%d ms\n", - jiffies_to_msecs(jiffies - - ppsc->last_awake_jiffies))); + "Set ERFSLEEP awaked:%d ms\n", + jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies)); ppsc->last_sleep_jiffies = jiffies; _rtl92c_phy_set_rf_sleep(hw); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); bresult = false; break; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c index 1e851aae58db..7b48ee9acb15 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c @@ -56,7 +56,7 @@ void rtl92cu_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", bandwidth)); + "unknown bandwidth: %#X\n", bandwidth); break; } } @@ -482,11 +482,11 @@ static bool _rtl92c_phy_rf6052_config_parafile(struct ieee80211_hw *hw) } if (rtstatus != true) { RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio[%d] Fail!!", rfpath)); + "Radio[%d] Fail!!", rfpath); goto phy_rf_cfg_fail; } } - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "<---\n"); return rtstatus; phy_rf_cfg_fail: return rtstatus; diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index 6d2ca773bbc7..dee7aab4faa6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -65,7 +65,7 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->rtlhal.pfirmware = vmalloc(0x4000); if (!rtlpriv->rtlhal.pfirmware) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't alloc buffer for fw.\n")); + "Can't alloc buffer for fw\n"); return 1; } /* request fw */ @@ -73,12 +73,12 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->io.dev); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to request firmware!\n")); + "Failed to request firmware!\n"); return 1; } if (firmware->size > 0x4000) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is too big!\n")); + "Firmware is too big!\n"); release_firmware(firmware); return 1; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index 128cfcd09fa9..b875af75b893 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -108,7 +108,7 @@ static void _TwoOutEpMapping(struct ieee80211_hw *hw, bool bIsChipB, if (bwificfg) { /* for WMM */ RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("USB Chip-B & WMM Setting.....\n")); + "USB Chip-B & WMM Setting.....\n"); ep_map->ep_mapping[RTL_TXQ_BE] = 2; ep_map->ep_mapping[RTL_TXQ_BK] = 3; ep_map->ep_mapping[RTL_TXQ_VI] = 3; @@ -118,7 +118,7 @@ static void _TwoOutEpMapping(struct ieee80211_hw *hw, bool bIsChipB, ep_map->ep_mapping[RTL_TXQ_HI] = 2; } else { /* typical setting */ RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("USB typical Setting.....\n")); + "USB typical Setting.....\n"); ep_map->ep_mapping[RTL_TXQ_BE] = 3; ep_map->ep_mapping[RTL_TXQ_BK] = 3; ep_map->ep_mapping[RTL_TXQ_VI] = 2; @@ -135,7 +135,7 @@ static void _ThreeOutEpMapping(struct ieee80211_hw *hw, bool bwificfg, struct rtl_priv *rtlpriv = rtl_priv(hw); if (bwificfg) { /* for WMM */ RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("USB 3EP Setting for WMM.....\n")); + "USB 3EP Setting for WMM.....\n"); ep_map->ep_mapping[RTL_TXQ_BE] = 5; ep_map->ep_mapping[RTL_TXQ_BK] = 3; ep_map->ep_mapping[RTL_TXQ_VI] = 3; @@ -145,7 +145,7 @@ static void _ThreeOutEpMapping(struct ieee80211_hw *hw, bool bwificfg, ep_map->ep_mapping[RTL_TXQ_HI] = 2; } else { /* typical setting */ RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("USB 3EP Setting for typical.....\n")); + "USB 3EP Setting for typical.....\n"); ep_map->ep_mapping[RTL_TXQ_BE] = 5; ep_map->ep_mapping[RTL_TXQ_BK] = 5; ep_map->ep_mapping[RTL_TXQ_VI] = 3; @@ -270,23 +270,23 @@ static enum rtl_desc_qsel _rtl8192cu_mq_to_descq(struct ieee80211_hw *hw, case 0: /* VO */ qsel = QSLT_VO; RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, - ("VO queue, set qsel = 0x%x\n", QSLT_VO)); + "VO queue, set qsel = 0x%x\n", QSLT_VO); break; case 1: /* VI */ qsel = QSLT_VI; RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, - ("VI queue, set qsel = 0x%x\n", QSLT_VI)); + "VI queue, set qsel = 0x%x\n", QSLT_VI); break; case 3: /* BK */ qsel = QSLT_BK; RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, - ("BK queue, set qsel = 0x%x\n", QSLT_BK)); + "BK queue, set qsel = 0x%x\n", QSLT_BK); break; case 2: /* BE */ default: qsel = QSLT_BE; RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, - ("BE queue, set qsel = 0x%x\n", QSLT_BE)); + "BE queue, set qsel = 0x%x\n", QSLT_BE); break; } out: @@ -422,17 +422,17 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) bv = ieee80211_is_probe_resp(fc); if (bv) RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Got probe response frame.\n")); + "Got probe response frame\n"); if (ieee80211_is_beacon(fc)) - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Got beacon frame.\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got beacon frame\n"); if (ieee80211_is_data(fc)) - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Got data frame.\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n"); RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:" - "0x%02X\n", fc, (u32)hdr->addr1[0], (u32)hdr->addr1[1], - (u32)hdr->addr1[2], (u32)hdr->addr1[3], (u32)hdr->addr1[4], - (u32)hdr->addr1[5])); + "Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n", + fc, + (u32)hdr->addr1[0], (u32)hdr->addr1[1], + (u32)hdr->addr1[2], (u32)hdr->addr1[3], + (u32)hdr->addr1[4], (u32)hdr->addr1[5]); memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status)); ieee80211_rx_irqsafe(hw, skb); } @@ -594,7 +594,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw, if (ieee80211_is_data_qos(fc)) { if (mac->rdg_en) { RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("Enable RDG function.\n")); + "Enable RDG function\n"); SET_TX_DESC_RDG_ENABLE(txdesc, 1); SET_TX_DESC_HTC(txdesc, 1); } @@ -620,7 +620,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw, SET_TX_DESC_BMC(txdesc, 1); _rtl_fill_usb_tx_desc(txdesc); _rtl_tx_desc_checksum(txdesc); - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, (" %s ==>\n", __func__)); + RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, " %s ==>\n", __func__); } void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc, diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c index 3cd0736fe8e1..32537c4faf95 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c @@ -246,23 +246,21 @@ static void rtl92d_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw) rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); rtl92d_release_cckandrw_pagea_ctl(hw, &flag); } - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Cnt_Fast_Fsync_fail = %x, " - "Cnt_SB_Search_fail = %x\n", + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, + "Cnt_Fast_Fsync_fail = %x, Cnt_SB_Search_fail = %x\n", falsealm_cnt->cnt_fast_fsync_fail, - falsealm_cnt->cnt_sb_search_fail)); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Cnt_Parity_Fail = %x, " - "Cnt_Rate_Illegal = %x, Cnt_Crc8_fail = %x, " - "Cnt_Mcs_fail = %x\n", + falsealm_cnt->cnt_sb_search_fail); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, + "Cnt_Parity_Fail = %x, Cnt_Rate_Illegal = %x, Cnt_Crc8_fail = %x, Cnt_Mcs_fail = %x\n", falsealm_cnt->cnt_parity_fail, falsealm_cnt->cnt_rate_illegal, falsealm_cnt->cnt_crc8_fail, - falsealm_cnt->cnt_mcs_fail)); + falsealm_cnt->cnt_mcs_fail); RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("Cnt_Ofdm_fail = %x, " "Cnt_Cck_fail = %x, " - "Cnt_all = %x\n", + "Cnt_Ofdm_fail = %x, Cnt_Cck_fail = %x, Cnt_all = %x\n", falsealm_cnt->cnt_ofdm_fail, falsealm_cnt->cnt_cck_fail, - falsealm_cnt->cnt_all)); + falsealm_cnt->cnt_all); } static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw) @@ -275,7 +273,7 @@ static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw) (rtlpriv->dm.UNDEC_SM_PWDB == 0)) { de_digtable.min_undecorated_pwdb_for_dm = 0; RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("Not connected to any\n")); + "Not connected to any\n"); } if (mac->link_state >= MAC80211_LINKED) { if (mac->opmode == NL80211_IFTYPE_AP || @@ -283,25 +281,25 @@ static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw) de_digtable.min_undecorated_pwdb_for_dm = rtlpriv->dm.UNDEC_SM_PWDB; RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - rtlpriv->dm.UNDEC_SM_PWDB)); + "AP Client PWDB = 0x%lx\n", + rtlpriv->dm.UNDEC_SM_PWDB); } else { de_digtable.min_undecorated_pwdb_for_dm = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("STA Default Port PWDB = 0x%x\n", - de_digtable.min_undecorated_pwdb_for_dm)); + "STA Default Port PWDB = 0x%x\n", + de_digtable.min_undecorated_pwdb_for_dm); } } else { de_digtable.min_undecorated_pwdb_for_dm = rtlpriv->dm.UNDEC_SM_PWDB; RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("AP Ext Port or disconnet PWDB = 0x%x\n", - de_digtable.min_undecorated_pwdb_for_dm)); + "AP Ext Port or disconnet PWDB = 0x%x\n", + de_digtable.min_undecorated_pwdb_for_dm); } - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", - de_digtable.min_undecorated_pwdb_for_dm)); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "MinUndecoratedPWDBForDM =%d\n", + de_digtable.min_undecorated_pwdb_for_dm); } static void rtl92d_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) @@ -340,14 +338,14 @@ static void rtl92d_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) } de_digtable.pre_cck_pd_state = de_digtable.cur_cck_pd_state; } - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("CurSTAConnectState=%s\n", - (de_digtable.cursta_connectctate == DIG_STA_CONNECT ? - "DIG_STA_CONNECT " : "DIG_STA_DISCONNECT"))); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("CCKPDStage=%s\n", - (de_digtable.cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI ? - "Low RSSI " : "High RSSI "))); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("is92d single phy =%x\n", - IS_92D_SINGLEPHY(rtlpriv->rtlhal.version))); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "CurSTAConnectState=%s\n", + de_digtable.cursta_connectctate == DIG_STA_CONNECT ? + "DIG_STA_CONNECT " : "DIG_STA_DISCONNECT"); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "CCKPDStage=%s\n", + de_digtable.cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI ? + "Low RSSI " : "High RSSI "); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "is92d single phy =%x\n", + IS_92D_SINGLEPHY(rtlpriv->rtlhal.version)); } @@ -355,12 +353,12 @@ void rtl92d_dm_write_dig(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("cur_igvalue = 0x%x, " - "pre_igvalue = 0x%x, backoff_val = %d\n", + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, + "cur_igvalue = 0x%x, pre_igvalue = 0x%x, backoff_val = %d\n", de_digtable.cur_igvalue, de_digtable.pre_igvalue, - de_digtable.backoff_val)); + de_digtable.backoff_val); if (de_digtable.dig_enable_flag == false) { - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("DIG is disabled\n")); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "DIG is disabled\n"); de_digtable.pre_igvalue = 0x17; return; } @@ -377,22 +375,21 @@ static void rtl92d_early_mode_enabled(struct rtl_priv *rtlpriv) { if ((rtlpriv->mac80211.link_state >= MAC80211_LINKED) && (rtlpriv->mac80211.vendor == PEER_CISCO)) { - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("IOT_PEER = CISCO\n")); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "IOT_PEER = CISCO\n"); if (de_digtable.last_min_undecorated_pwdb_for_dm >= 50 && de_digtable.min_undecorated_pwdb_for_dm < 50) { rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x00); RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("Early Mode Off\n")); + "Early Mode Off\n"); } else if (de_digtable.last_min_undecorated_pwdb_for_dm <= 55 && de_digtable.min_undecorated_pwdb_for_dm > 55) { rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f); RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("Early Mode On\n")); + "Early Mode On\n"); } } else if (!(rtl_read_byte(rtlpriv, REG_EARLY_MODE_CONTROL) & 0xf)) { rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Early Mode On\n")); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "Early Mode On\n"); } } @@ -402,7 +399,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw) u8 value_igi = de_digtable.cur_igvalue; struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("==>\n")); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "==>\n"); if (rtlpriv->rtlhal.earlymode_enable) { rtl92d_early_mode_enabled(rtlpriv); de_digtable.last_min_undecorated_pwdb_for_dm = @@ -421,7 +418,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw) /* Not STA mode return tmp */ if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION) return; - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("progress\n")); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "progress\n"); /* Decide the current status and if modify initial gain or not */ if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) de_digtable.cursta_connectctate = DIG_STA_CONNECT; @@ -438,16 +435,16 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw) else if (falsealm_cnt->cnt_all >= DM_DIG_FA_TH2) value_igi += 2; RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() Before: large_fa_hit=%d, forbidden_igi=%x\n", - de_digtable.large_fa_hit, de_digtable.forbidden_igi)); + "dm_DIG() Before: large_fa_hit=%d, forbidden_igi=%x\n", + de_digtable.large_fa_hit, de_digtable.forbidden_igi); RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() Before: Recover_cnt=%d, rx_gain_range_min=%x\n", - de_digtable.recover_cnt, de_digtable.rx_gain_range_min)); + "dm_DIG() Before: Recover_cnt=%d, rx_gain_range_min=%x\n", + de_digtable.recover_cnt, de_digtable.rx_gain_range_min); /* deal with abnorally large false alarm */ if (falsealm_cnt->cnt_all > 10000) { RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG(): Abnornally false alarm case.\n")); + "dm_DIG(): Abnormally false alarm case\n"); de_digtable.large_fa_hit++; if (de_digtable.forbidden_igi < de_digtable.cur_igvalue) { @@ -486,11 +483,11 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw) } } RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() After: large_fa_hit=%d, forbidden_igi=%x\n", - de_digtable.large_fa_hit, de_digtable.forbidden_igi)); + "dm_DIG() After: large_fa_hit=%d, forbidden_igi=%x\n", + de_digtable.large_fa_hit, de_digtable.forbidden_igi); RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() After: recover_cnt=%d, rx_gain_range_min=%x\n", - de_digtable.recover_cnt, de_digtable.rx_gain_range_min)); + "dm_DIG() After: recover_cnt=%d, rx_gain_range_min=%x\n", + de_digtable.recover_cnt, de_digtable.rx_gain_range_min); if (value_igi > DM_DIG_MAX) value_igi = DM_DIG_MAX; @@ -500,7 +497,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw) rtl92d_dm_write_dig(hw); if (rtlpriv->rtlhal.current_bandtype != BAND_ON_5G) rtl92d_dm_cck_packet_detection_thresh(hw); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("<<==\n")); + RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "<<==\n"); } static void rtl92d_dm_init_dynamic_txpower(struct ieee80211_hw *hw) @@ -528,7 +525,7 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw) if ((mac->link_state < MAC80211_LINKED) && (rtlpriv->dm.UNDEC_SM_PWDB == 0)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Not connected to any\n")); + "Not connected to any\n"); rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; return; @@ -538,40 +535,40 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw) undecorated_smoothed_pwdb = rtlpriv->dm.UNDEC_SM_PWDB; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("IBSS Client PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "IBSS Client PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } else { undecorated_smoothed_pwdb = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "STA Default Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } } else { undecorated_smoothed_pwdb = rtlpriv->dm.UNDEC_SM_PWDB; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Ext Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } if (rtlhal->current_bandtype == BAND_ON_5G) { if (undecorated_smoothed_pwdb >= 0x33) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL2; RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, - ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n")); + "5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n"); } else if ((undecorated_smoothed_pwdb < 0x33) && (undecorated_smoothed_pwdb >= 0x2b)) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, - ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); + "5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n"); } else if (undecorated_smoothed_pwdb < 0x2b) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, - ("5G:TxHighPwrLevel_Normal\n")); + "5G:TxHighPwrLevel_Normal\n"); } } else { if (undecorated_smoothed_pwdb >= @@ -579,7 +576,7 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw) rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL2; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n"); } else if ((undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) @@ -589,19 +586,19 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw) rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); + "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n"); } else if (undecorated_smoothed_pwdb < (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_NORMAL\n")); + "TXHIGHPWRLEVEL_NORMAL\n"); } } if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("PHY_SetTxPowerLevel8192S() Channel = %d\n", - rtlphy->current_channel)); + "PHY_SetTxPowerLevel8192S() Channel = %d\n", + rtlphy->current_channel); rtl92d_phy_set_txpower_level(hw, rtlphy->current_channel); } rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; @@ -717,7 +714,7 @@ static void rtl92d_dm_rxgain_tracking_thermalmeter(struct ieee80211_hw *hw) u4tmp = (index_mapping[(rtlpriv->efuse.eeprom_thermalmeter - rtlpriv->dm.thermalvalue_rxgain)]) << 12; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("===> Rx Gain %x\n", u4tmp)); + "===> Rx Gain %x\n", u4tmp); for (i = RF90_PATH_A; i < rtlpriv->phy.num_total_rfpath; i++) rtl_set_rfreg(hw, i, 0x3C, BRFREGOFFSETMASK, (rtlpriv->phy.reg_rf3c[i] & (~(0xF000))) | u4tmp); @@ -741,27 +738,22 @@ static void rtl92d_bandtype_2_4G(struct ieee80211_hw *hw, long *temp_cckg, if (!memcmp((void *)&temp_cck, (void *)&cckswing_table_ch14[i][2], 4)) { *cck_index_old = (u8) i; - RT_TRACE(rtlpriv, - COMP_POWER_TRACKING, - DBG_LOUD, - ("Initial reg0x%x = 0x%lx, " - "cck_index=0x%x, ch 14 %d\n", - RCCK0_TXFILTER2, - temp_cck, *cck_index_old, - rtlpriv->dm.cck_inch14)); + RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, + "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch 14 %d\n", + RCCK0_TXFILTER2, temp_cck, + *cck_index_old, + rtlpriv->dm.cck_inch14); break; } } else { if (!memcmp((void *) &temp_cck, &cckswing_table_ch1ch13[i][2], 4)) { *cck_index_old = (u8) i; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, - DBG_LOUD, - ("Initial reg0x%x = 0x%lx, " - "cck_index = 0x%x, ch14 %d\n", - RCCK0_TXFILTER2, - temp_cck, *cck_index_old, - rtlpriv->dm.cck_inch14)); + RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, + "Initial reg0x%x = 0x%lx, cck_index = 0x%x, ch14 %d\n", + RCCK0_TXFILTER2, temp_cck, + *cck_index_old, + rtlpriv->dm.cck_inch14); break; } } @@ -884,12 +876,12 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( }; rtlpriv->dm.txpower_trackinginit = true; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("\n")); + RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "\n"); thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0xf800); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " - "eeprom_thermalmeter 0x%x\n", thermalvalue, - rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter)); + "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x\n", + thermalvalue, + rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter); rtl92d_phy_ap_calibrate(hw, (thermalvalue - rtlefuse->eeprom_thermalmeter)); if (is2t) @@ -904,10 +896,9 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( ofdm_index_old[0] = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Initial pathA ele_d reg0x%x = 0x%lx," - " ofdm_index=0x%x\n", + "Initial pathA ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n", ROFDM0_XATxIQIMBALANCE, - ele_d, ofdm_index_old[0])); + ele_d, ofdm_index_old[0]); break; } } @@ -920,11 +911,9 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( ofdm_index_old[1] = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Initial pathB ele_d reg " - "0x%x = 0x%lx, ofdm_index " - "= 0x%x\n", + "Initial pathB ele_d reg 0x%x = 0x%lx, ofdm_index = 0x%x\n", ROFDM0_XBTxIQIMBALANCE, ele_d, - ofdm_index_old[1])); + ofdm_index_old[1]); break; } } @@ -952,7 +941,7 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i]; rtlpriv->dm.cck_index = cck_index_old; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("reload ofdm index for band switch\n")); + "reload ofdm index for band switch\n"); } rtlpriv->dm.thermalvalue_avg [rtlpriv->dm.thermalvalue_avg_index] = thermalvalue; @@ -995,12 +984,10 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( (thermalvalue - rtlpriv->dm.thermalvalue_rxgain) : (rtlpriv->dm.thermalvalue_rxgain - thermalvalue); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x" - " eeprom_thermalmeter 0x%x delta 0x%x " - "delta_lck 0x%x delta_iqk 0x%x\n", - thermalvalue, rtlpriv->dm.thermalvalue, - rtlefuse->eeprom_thermalmeter, delta, delta_lck, - delta_iqk)); + "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x delta 0x%x delta_lck 0x%x delta_iqk 0x%x\n", + thermalvalue, rtlpriv->dm.thermalvalue, + rtlefuse->eeprom_thermalmeter, delta, delta_lck, + delta_iqk); if ((delta_lck > rtlefuse->delta_lck) && (rtlefuse->delta_lck != 0)) { rtlpriv->dm.thermalvalue_lck = thermalvalue; @@ -1036,17 +1023,15 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( } if (is2t) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("temp OFDM_A_index=0x%x, OFDM_B_index" - " = 0x%x,cck_index=0x%x\n", - rtlpriv->dm.ofdm_index[0], - rtlpriv->dm.ofdm_index[1], - rtlpriv->dm.cck_index)); + "temp OFDM_A_index=0x%x, OFDM_B_index = 0x%x,cck_index=0x%x\n", + rtlpriv->dm.ofdm_index[0], + rtlpriv->dm.ofdm_index[1], + rtlpriv->dm.cck_index); } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("temp OFDM_A_index=0x%x,cck_index = " - "0x%x\n", - rtlpriv->dm.ofdm_index[0], - rtlpriv->dm.cck_index)); + "temp OFDM_A_index=0x%x,cck_index = 0x%x\n", + rtlpriv->dm.ofdm_index[0], + rtlpriv->dm.cck_index); } for (i = 0; i < rf; i++) { if (ofdm_index[i] > OFDM_TABLE_SIZE_92D - 1) @@ -1070,15 +1055,13 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( } if (is2t) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("new OFDM_A_index=0x%x, OFDM_B_index " - "= 0x%x, cck_index=0x%x\n", + "new OFDM_A_index=0x%x, OFDM_B_index = 0x%x, cck_index=0x%x\n", ofdm_index[0], ofdm_index[1], - cck_index)); + cck_index); } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("new OFDM_A_index=0x%x,cck_index = " - "0x%x\n", - ofdm_index[0], cck_index)); + "new OFDM_A_index=0x%x,cck_index = 0x%x\n", + ofdm_index[0], cck_index); } ele_d = (ofdmswing_table[(u8) ofdm_index[0]] & 0xFFC00000) >> 22; @@ -1124,12 +1107,10 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( } RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("TxPwrTracking for interface %d path A: X =" - " 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = " - "0x%lx ele_D = 0x%lx 0xe94 = 0x%lx 0xe9c = " - "0x%lx\n", rtlhal->interfaceindex, + "TxPwrTracking for interface %d path A: X = 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = 0x%lx ele_D = 0x%lx 0xe94 = 0x%lx 0xe9c = 0x%lx\n", + rtlhal->interfaceindex, val_x, val_y, ele_a, ele_c, ele_d, - val_x, val_y)); + val_x, val_y); if (rtlhal->current_bandtype == BAND_ON_2_4G) { /* Adjust CCK according to IQK result */ @@ -1232,20 +1213,16 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( BIT(28), 0x00); } RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("TxPwrTracking path B: X = 0x%lx, " - "Y = 0x%lx ele_A = 0x%lx ele_C = 0x" - "%lx ele_D = 0x%lx 0xeb4 = 0x%lx " - "0xebc = 0x%lx\n", - val_x, val_y, ele_a, ele_c, - ele_d, val_x, val_y)); + "TxPwrTracking path B: X = 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = 0x%lx ele_D = 0x%lx 0xeb4 = 0x%lx 0xebc = 0x%lx\n", + val_x, val_y, ele_a, ele_c, + ele_d, val_x, val_y); } RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = " - "0x%x RF 0x24 = 0x%x\n", + "TxPwrTracking 0xc80 = 0x%x, 0xc94 = 0x%x RF 0x24 = 0x%x\n", rtl_get_bbreg(hw, 0xc80, BMASKDWORD), rtl_get_bbreg(hw, 0xc94, BMASKDWORD), rtl_get_rfreg(hw, RF90_PATH_A, 0x24, - BRFREGOFFSETMASK))); + BRFREGOFFSETMASK)); } if ((delta_iqk > rtlefuse->delta_iqk) && (rtlefuse->delta_iqk != 0)) { @@ -1262,7 +1239,7 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter( rtlpriv->dm.thermalvalue = thermalvalue; } - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("<===\n")); + RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===\n"); } static void rtl92d_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) @@ -1273,8 +1250,8 @@ static void rtl92d_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) rtlpriv->dm.txpower_trackinginit = false; rtlpriv->dm.txpower_track_control = true; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("pMgntInfo->txpower_tracking = %d\n", - rtlpriv->dm.txpower_tracking)); + "pMgntInfo->txpower_tracking = %d\n", + rtlpriv->dm.txpower_tracking); } void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw) @@ -1289,12 +1266,12 @@ void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw) rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, BIT(17) | BIT(16), 0x03); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Trigger 92S Thermal Meter!!\n")); + "Trigger 92S Thermal Meter!!\n"); tm_trigger = 1; return; } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Schedule TxPowerTracking direct call!!\n")); + "Schedule TxPowerTracking direct call!!\n"); rtl92d_dm_txpower_tracking_callback_thermalmeter(hw); tm_trigger = 0; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c index db6972ffe503..b84f10d60c0d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c @@ -124,14 +124,14 @@ static void _rtl92d_write_fw(struct ieee80211_hw *hw, u32 pagenums, remainSize; u32 page, offset; - RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); + RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size); if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) _rtl92d_fill_dummy(bufferPtr, &size); pagenums = size / FW_8192D_PAGE_SIZE; remainSize = size % FW_8192D_PAGE_SIZE; if (pagenums > 8) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Page numbers should not greater then 8\n")); + "Page numbers should not greater then 8\n"); } for (page = 0; page < pagenums; page++) { offset = page * FW_8192D_PAGE_SIZE; @@ -158,12 +158,12 @@ static int _rtl92d_fw_free_to_go(struct ieee80211_hw *hw) (!(value32 & FWDL_ChkSum_rpt))); if (counter >= FW_8192D_POLLING_TIMEOUT_COUNT) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("chksum report faill ! REG_MCUFWDL:0x%08x .\n", - value32)); + "chksum report faill ! REG_MCUFWDL:0x%08x\n", + value32); return -EIO; } RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32)); + "Checksum report OK ! REG_MCUFWDL:0x%08x\n", value32); value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); value32 |= MCUFWDL_RDY; rtl_write_dword(rtlpriv, REG_MCUFWDL, value32); @@ -188,7 +188,7 @@ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw) } RT_ASSERT((delay > 0), ("8051 reset failed!\n")); RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("=====> 8051 reset success (%d) .\n", delay)); + "=====> 8051 reset success (%d)\n", delay); } static int _rtl92d_fw_init(struct ieee80211_hw *hw) @@ -197,7 +197,7 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw) struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u32 counter; - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, ("FW already have download\n")); + RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, "FW already have download\n"); /* polling for FW ready */ counter = 0; do { @@ -205,10 +205,9 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw) if (rtl_read_byte(rtlpriv, FW_MAC0_READY) & MAC0_READY) { RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready success!! " - "REG_MCUFWDL: 0x%x .\n", + "Polling FW ready success!! REG_MCUFWDL: 0x%x\n", rtl_read_byte(rtlpriv, - FW_MAC0_READY))); + FW_MAC0_READY)); return 0; } udelay(5); @@ -216,10 +215,9 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw) if (rtl_read_byte(rtlpriv, FW_MAC1_READY) & MAC1_READY) { RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready success!! " - "REG_MCUFWDL: 0x%x .\n", + "Polling FW ready success!! REG_MCUFWDL: 0x%x\n", rtl_read_byte(rtlpriv, - FW_MAC1_READY))); + FW_MAC1_READY)); return 0; } udelay(5); @@ -228,18 +226,16 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw) if (rtlhal->interfaceindex == 0) { RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready fail!! MAC0 FW init not ready: " - "0x%x .\n", - rtl_read_byte(rtlpriv, FW_MAC0_READY))); + "Polling FW ready fail!! MAC0 FW init not ready: 0x%x\n", + rtl_read_byte(rtlpriv, FW_MAC0_READY)); } else { RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready fail!! MAC1 FW init not ready: " - "0x%x .\n", - rtl_read_byte(rtlpriv, FW_MAC1_READY))); + "Polling FW ready fail!! MAC1 FW init not ready: 0x%x\n", + rtl_read_byte(rtlpriv, FW_MAC1_READY)); } RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready fail!! REG_MCUFWDL:0x%08ul .\n", - rtl_read_dword(rtlpriv, REG_MCUFWDL))); + "Polling FW ready fail!! REG_MCUFWDL:0x%08ul\n", + rtl_read_dword(rtlpriv, REG_MCUFWDL)); return -1; } @@ -264,13 +260,13 @@ int rtl92d_download_fw(struct ieee80211_hw *hw) pfwdata = (u8 *) rtlhal->pfirmware; rtlhal->fw_version = (u16) GET_FIRMWARE_HDR_VERSION(pfwheader); rtlhal->fw_subversion = (u16) GET_FIRMWARE_HDR_SUB_VER(pfwheader); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, (" FirmwareVersion(%d)," - "FirmwareSubVersion(%d), Signature(%#x)\n", - rtlhal->fw_version, rtlhal->fw_subversion, - GET_FIRMWARE_HDR_SIGNATURE(pfwheader))); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "FirmwareVersion(%d), FirmwareSubVersion(%d), Signature(%#x)\n", + rtlhal->fw_version, rtlhal->fw_subversion, + GET_FIRMWARE_HDR_SIGNATURE(pfwheader)); if (IS_FW_HEADER_EXIST(pfwheader)) { RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Shift 32 bytes for FW header!!\n")); + "Shift 32 bytes for FW header!!\n"); pfwdata = pfwdata + 32; fwsize = fwsize - 32; } @@ -302,8 +298,7 @@ int rtl92d_download_fw(struct ieee80211_hw *hw) break; else RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Wait for another mac " - "download fw\n")); + "Wait for another mac download fw\n"); } spin_lock_irqsave(&globalmutex_for_fwdownload, flags); value = rtl_read_byte(rtlpriv, 0x1f); @@ -337,11 +332,10 @@ int rtl92d_download_fw(struct ieee80211_hw *hw) spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("fw is not ready to run!\n")); + "fw is not ready to run!\n"); goto exit; } else { - RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("fw is ready to run!\n")); + RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "fw is ready to run!\n"); } exit: err = _rtl92d_fw_init(hw); @@ -381,24 +375,24 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, if (ppsc->rfpwr_state == ERFOFF || ppsc->inactive_pwrstate == ERFOFF) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Return as RF is off!!!\n")); + "Return as RF is off!!!\n"); return; } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("come in\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n"); while (true) { spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); if (rtlhal->h2c_setinprogress) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("H2C set in progress! Wait to set.." - "element_id(%d).\n", element_id)); + "H2C set in progress! Wait to set..element_id(%d)\n", + element_id); while (rtlhal->h2c_setinprogress) { spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); h2c_waitcounter++; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wait 100 us (%d times)...\n", - h2c_waitcounter)); + "Wait 100 us (%d times)...\n", + h2c_waitcounter); udelay(100); if (h2c_waitcounter > 1000) @@ -418,8 +412,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, wait_writeh2c_limmit--; if (wait_writeh2c_limmit == 0) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Write H2C fail because no trigger " - "for FW INT!\n")); + "Write H2C fail because no trigger for FW INT!\n"); break; } boxnum = rtlhal->last_hmeboxnum; @@ -442,7 +435,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); @@ -450,29 +443,29 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, wait_h2c_limmit--; if (wait_h2c_limmit == 0) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wating too long for FW read " - "clear HMEBox(%d)!\n", boxnum)); + "Waiting too long for FW read clear HMEBox(%d)!\n", + boxnum); break; } udelay(10); isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wating for FW read clear HMEBox(%d)!!! " - "0x1BF = %2x\n", boxnum, u1b_tmp)); + "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n", + boxnum, u1b_tmp); } if (!isfw_read) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Write H2C register BOX[%d] fail!!!!! " - "Fw do not read.\n", boxnum)); + "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n", + boxnum); break; } memset(boxcontent, 0, sizeof(boxcontent)); memset(boxextcontent, 0, sizeof(boxextcontent)); boxcontent[0] = element_id; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Write element_id box_reg(%4x) = %2x\n", - box_reg, element_id)); + "Write element_id box_reg(%4x) = %2x\n", + box_reg, element_id); switch (cmd_len) { case 1: boxcontent[0] &= ~(BIT(7)); @@ -519,7 +512,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } bwrite_sucess = true; @@ -527,13 +520,13 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, if (rtlhal->last_hmeboxnum == 4) rtlhal->last_hmeboxnum = 0; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("pHalData->last_hmeboxnum = %d\n", - rtlhal->last_hmeboxnum)); + "pHalData->last_hmeboxnum = %d\n", + rtlhal->last_hmeboxnum); } spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); rtlhal->h2c_setinprogress = false; spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n"); } void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, @@ -559,7 +552,7 @@ void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) u8 u1_h2c_set_pwrmode[3] = { 0 }; struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("FW LPS mode = %d\n", mode)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode); SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1); SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode, @@ -771,14 +764,14 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) dlok = true; if (dlok) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Set RSVD page location to Fw.\n")); + "Set RSVD page location to Fw\n"); RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, "H2C_RSVDPAGE", u1RsvdPageLoc, 3); rtl92d_fill_h2c_cmd(hw, H2C_RSVDPAGE, sizeof(u1RsvdPageLoc), u1RsvdPageLoc); } else RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Set RSVD page location to Fw FAIL!!!!!!.\n")); + "Set RSVD page location to Fw FAIL!!!!!!\n"); } void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus) diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index 5c8a639582ad..5eecf403a5c3 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -166,7 +166,7 @@ void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } @@ -230,7 +230,7 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) u8 e_aci; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("HW_VAR_SLOT_TIME %x\n", val[0])); + "HW_VAR_SLOT_TIME %x\n", val[0]); rtl_write_byte(rtlpriv, REG_SLOT, val[0]); for (e_aci = 0; e_aci < AC_MAX; e_aci++) rtlpriv->cfg->ops->set_hw_reg(hw, @@ -261,8 +261,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) min_spacing_to_set); *val = min_spacing_to_set; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, mac->min_space_cfg); } @@ -275,8 +275,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) mac->min_space_cfg = rtlpriv->rtlhal.minspace_cfg; mac->min_space_cfg |= (density_to_set << 3); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_SHORTGI_DENSITY: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, mac->min_space_cfg); break; @@ -310,8 +310,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) } rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, regtoSet); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_FACTOR: %#x\n", - factor_toset)); + "Set HW_VAR_AMPDU_FACTOR: %#x\n", + factor_toset); } break; } @@ -344,8 +344,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("HW_VAR_ACM_CTRL acm set " - "failed: eACI is %d\n", acm)); + "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n", + acm); break; } } else { @@ -361,13 +361,13 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, - ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " - "Write 0x%X\n", acm_ctrl)); + "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", + acm_ctrl); rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); break; } @@ -502,7 +502,7 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) } default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } @@ -522,8 +522,8 @@ static bool _rtl92de_llt_write(struct ieee80211_hw *hw, u32 address, u32 data) break; if (count > POLLING_LLT_THRESHOLD) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to polling write LLT done at " - "address %d!\n", address)); + "Failed to polling write LLT done at address %d!\n", + address); status = false; break; } @@ -879,12 +879,12 @@ void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw) u8 sec_reg_value; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", - rtlpriv->sec.pairwise_enc_algorithm, - rtlpriv->sec.group_enc_algorithm)); + "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", + rtlpriv->sec.pairwise_enc_algorithm, + rtlpriv->sec.group_enc_algorithm); if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("not open hw encryption\n")); + "not open hw encryption\n"); return; } sec_reg_value = SCR_TXENCENABLE | SCR_RXENCENABLE; @@ -895,7 +895,7 @@ void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw) sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The SECR-value %x\n", sec_reg_value)); + "The SECR-value %x\n", sec_reg_value); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); } @@ -921,7 +921,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw) /* rtlpriv->intf_ops->disable_aspm(hw); */ rtstatus = _rtl92de_init_mac(hw); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Init MAC failed\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n"); err = 1; spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); return err; @@ -930,8 +930,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw) spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Failed to download FW. Init HW " - "without FW..\n")); + "Failed to download FW. Init HW without FW..\n"); rtlhal->fw_ready = false; return 1; } else { @@ -946,7 +945,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw) if (rtlhal->earlymode_enable) { RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EarlyMode Enabled!!!\n")); + "EarlyMode Enabled!!!\n"); tmp_u1b = rtl_read_byte(rtlpriv, 0x4d0); tmp_u1b = tmp_u1b | 0x1f; @@ -1064,10 +1063,10 @@ static enum version_8192d _rtl92de_read_chip_version(struct ieee80211_hw *hw) value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); if (!(value32 & 0x000f0000)) { version = VERSION_TEST_CHIP_92D_SINGLEPHY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("TEST CHIP!!!\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "TEST CHIP!!!\n"); } else { version = VERSION_NORMAL_CHIP_92D_SINGLEPHY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Normal CHIP!!!\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Normal CHIP!!!\n"); } return version; } @@ -1092,8 +1091,8 @@ static int _rtl92de_set_media_status(struct ieee80211_hw *hw, _rtl92de_disable_bcn_sub_func(hw); } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Set HW_VAR_MEDIA_STATUS: No such media " - "status(%x).\n", type)); + "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n", + type); } bcnfunc_enable = rtl_read_byte(rtlpriv, REG_BCN_CTRL); switch (type) { @@ -1102,30 +1101,30 @@ static int _rtl92de_set_media_status(struct ieee80211_hw *hw, ledaction = LED_CTL_LINK; bcnfunc_enable &= 0xF7; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to NO LINK!\n")); + "Set Network type to NO LINK!\n"); break; case NL80211_IFTYPE_ADHOC: bt_msr |= MSR_ADHOC; bcnfunc_enable |= 0x08; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to Ad Hoc!\n")); + "Set Network type to Ad Hoc!\n"); break; case NL80211_IFTYPE_STATION: bt_msr |= MSR_INFRA; ledaction = LED_CTL_LINK; bcnfunc_enable &= 0xF7; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to STA!\n")); + "Set Network type to STA!\n"); break; case NL80211_IFTYPE_AP: bt_msr |= MSR_AP; bcnfunc_enable |= 0x08; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to AP!\n")); + "Set Network type to AP!\n"); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Network type %d not support!\n", type)); + "Network type %d not supported!\n", type); return 1; break; @@ -1189,7 +1188,7 @@ void rtl92d_linked_set_reg(struct ieee80211_hw *hw) indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel); if (!rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done) { RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_DMESG, - ("Do IQK for channel:%d.\n", channel)); + "Do IQK for channel:%d\n", channel); rtl92d_phy_iq_calibrate(hw); } } @@ -1305,8 +1304,8 @@ static void _rtl92de_poweroff_adapter(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_APS_FSMCO + 1, 0x10); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("In PowerOff,reg0x%x=%X\n", REG_SPS0_CTRL, - rtl_read_byte(rtlpriv, REG_SPS0_CTRL))); + "In PowerOff,reg0x%x=%X\n", + REG_SPS0_CTRL, rtl_read_byte(rtlpriv, REG_SPS0_CTRL)); /* r. Note: for PCIe interface, PON will not turn */ /* off m-bias and BandGap in PCIe suspend mode. */ @@ -1319,7 +1318,7 @@ static void _rtl92de_poweroff_adapter(struct ieee80211_hw *hw) spin_unlock_irqrestore(&globalmutex_power, flags); } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<=======\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "<=======\n"); } void rtl92de_card_disable(struct ieee80211_hw *hw) @@ -1377,7 +1376,7 @@ void rtl92de_card_disable(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0xff); udelay(50); rtl_write_byte(rtlpriv, REG_CR, 0x0); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==> Do power off.......\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "==> Do power off.......\n"); if (rtl92d_phy_check_poweroff(hw)) _rtl92de_poweroff_adapter(hw); return; @@ -1425,7 +1424,7 @@ void rtl92de_set_beacon_interval(struct ieee80211_hw *hw) u16 bcn_interval = mac->beacon_interval; RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, - ("beacon_interval:%d\n", bcn_interval)); + "beacon_interval:%d\n", bcn_interval); /* rtl92de_disable_interrupt(hw); */ rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); /* rtl92de_enable_interrupt(hw); */ @@ -1437,8 +1436,8 @@ void rtl92de_update_interrupt_mask(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); + RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n", + add_msr, rm_msr); if (add_msr) rtlpci->irq_mask[0] |= add_msr; if (rm_msr) @@ -1615,9 +1614,9 @@ static void _rtl92de_read_txpower_info(struct ieee80211_hw *hw, rtlefuse->internal_pa_5g[1] = !((hwinfo[EEPROM_TSSI_B_5G] & BIT(6)) >> 6); RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Is D cut,Internal PA0 %d Internal PA1 %d\n", + "Is D cut,Internal PA0 %d Internal PA1 %d\n", rtlefuse->internal_pa_5g[0], - rtlefuse->internal_pa_5g[1])); + rtlefuse->internal_pa_5g[1]); } rtlefuse->eeprom_c9 = hwinfo[EEPROM_RF_OPT6]; rtlefuse->eeprom_cc = hwinfo[EEPROM_RF_OPT7]; @@ -1667,14 +1666,14 @@ static void _rtl92de_read_txpower_info(struct ieee80211_hw *hw, if (rtlefuse->eeprom_c9 == 0xFF) rtlefuse->eeprom_c9 = 0x00; RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("EEPROMRegulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); + "EEPROMRegulatory = 0x%x\n", rtlefuse->eeprom_regulatory); RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("ThermalMeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); + "ThermalMeter = 0x%x\n", rtlefuse->eeprom_thermalmeter); RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("CrystalCap = 0x%x\n", rtlefuse->crystalcap)); + "CrystalCap = 0x%x\n", rtlefuse->crystalcap); RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("Delta_IQK = 0x%x Delta_LCK = 0x%x\n", rtlefuse->delta_iqk, - rtlefuse->delta_lck)); + "Delta_IQK = 0x%x Delta_LCK = 0x%x\n", + rtlefuse->delta_iqk, rtlefuse->delta_lck); for (rfPath = 0; rfPath < RF6052_MAX_PATH; rfPath++) { for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { @@ -1710,11 +1709,11 @@ static void _rtl92de_read_macphymode_from_prom(struct ieee80211_hw *hw, if (macphy_crvalue & BIT(3)) { rtlhal->macphymode = SINGLEMAC_SINGLEPHY; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode SINGLEMAC_SINGLEPHY\n")); + "MacPhyMode SINGLEMAC_SINGLEPHY\n"); } else { rtlhal->macphymode = DUALMAC_DUALPHY; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode DUALMAC_DUALPHY\n")); + "MacPhyMode DUALMAC_DUALPHY\n"); } } @@ -1741,15 +1740,15 @@ static void _rtl92de_efuse_update_chip_version(struct ieee80211_hw *hw) switch (chipvalue) { case 0xAA55: chipver |= CHIP_92D_C_CUT; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("C-CUT!!!\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "C-CUT!!!\n"); break; case 0x9966: chipver |= CHIP_92D_D_CUT; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("D-CUT!!!\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "D-CUT!!!\n"); break; default: chipver |= CHIP_92D_D_CUT; - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, ("Unkown CUT!\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Unkown CUT!\n"); break; } rtlpriv->rtlhal.version = chipver; @@ -1775,7 +1774,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) HWSET_MAX_SIZE); } else if (rtlefuse->epromtype == EEPROM_93C46) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); + "RTL819X Not boot from eeprom, check it !!\n"); } RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP", hwinfo, HWSET_MAX_SIZE); @@ -1783,15 +1782,15 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) eeprom_id = *((u16 *)&hwinfo[0]); if (eeprom_id != RTL8190_EEPROM_ID) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); + "EEPROM ID(%#x) is invalid!!\n", eeprom_id); rtlefuse->autoload_failflag = true; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; } if (rtlefuse->autoload_failflag) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); + "RTL819X Not boot from eeprom, check it !!\n"); return; } rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; @@ -1802,16 +1801,15 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID]; rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID]; rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID]; + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROMId = 0x%4x\n", eeprom_id); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROMId = 0x%4x\n", eeprom_id)); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid)); + "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did)); + "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid)); + "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid)); + "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid); /* Read Permanent MAC address */ if (rtlhal->interfaceindex == 0) { @@ -1827,8 +1825,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) } rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, rtlefuse->dev_addr); - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("%pM\n", rtlefuse->dev_addr)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr); _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo); /* Read Channel Plan */ @@ -1849,7 +1846,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; rtlefuse->txpwr_fromeprom = true; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); + "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid); } void rtl92de_read_eeprom_info(struct ieee80211_hw *hw) @@ -1863,19 +1860,19 @@ void rtl92de_read_eeprom_info(struct ieee80211_hw *hw) tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); rtlefuse->autoload_status = tmp_u1b; if (tmp_u1b & BIT(4)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n"); rtlefuse->epromtype = EEPROM_93C46; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n"); rtlefuse->epromtype = EEPROM_BOOT_EFUSE; } if (tmp_u1b & BIT(5)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; _rtl92de_read_adapter_info(hw); } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n"); } return; } @@ -1958,8 +1955,8 @@ static void rtl92de_update_hal_rate_table(struct ieee80211_hw *hw, (shortgi_rate << 4) | (shortgi_rate); } rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("%x\n", rtl_read_dword(rtlpriv, REG_ARFR0))); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n", + rtl_read_dword(rtlpriv, REG_ARFR0)); } static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, @@ -2092,8 +2089,8 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28); value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80; RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("ratr_bitmap :%x value0:%x value1:%x\n", - ratr_bitmap, value[0], value[1])); + "ratr_bitmap :%x value0:%x value1:%x\n", + ratr_bitmap, value[0], value[1]); rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *) value); if (macid != 0) sta_entry->ratr_index = ratr_index; @@ -2153,14 +2150,14 @@ bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; if (ppsc->hwradiooff && (e_rfpowerstate_toset == ERFON)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("GPIOChangeRF - HW Radio ON, RF ON\n")); + "GPIOChangeRF - HW Radio ON, RF ON\n"); e_rfpowerstate_toset = ERFON; ppsc->hwradiooff = false; actuallyset = true; } else if ((ppsc->hwradiooff == false) && (e_rfpowerstate_toset == ERFOFF)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); + "GPIOChangeRF - HW Radio OFF, RF OFF\n"); e_rfpowerstate_toset = ERFOFF; ppsc->hwradiooff = true; actuallyset = true; @@ -2204,7 +2201,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, u8 idx; u8 cam_offset = 0; u8 clear_number = 5; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n"); for (idx = 0; idx < clear_number; idx++) { rtl_cam_mark_invalid(hw, cam_offset + idx); rtl_cam_empty_entry(hw, cam_offset + idx); @@ -2230,8 +2227,8 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, enc_algo = CAM_AES; break; default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " - "not process\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "switch case not processed\n"); enc_algo = CAM_TKIP; break; } @@ -2248,9 +2245,8 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, p_macaddr); if (entry_id >= TOTAL_CAM_ENTRY) { RT_TRACE(rtlpriv, COMP_SEC, - DBG_EMERG, ("Can not " - "find free hw security" - " cam entry\n")); + DBG_EMERG, + "Can not find free hw security cam entry\n"); return; } } else { @@ -2262,21 +2258,21 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, } if (rtlpriv->sec.key_len[key_index] == 0) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("delete one entry, entry_id is %d\n", - entry_id)); + "delete one entry, entry_id is %d\n", + entry_id); if (mac->opmode == NL80211_IFTYPE_AP) rtl_cam_del_entry(hw, p_macaddr); rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY length is %d\n", - rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); + "The insert KEY length is %d\n", + rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY is %x %x\n", - rtlpriv->sec.key_buf[0][0], - rtlpriv->sec.key_buf[0][1])); + "The insert KEY is %x %x\n", + rtlpriv->sec.key_buf[0][0], + rtlpriv->sec.key_buf[0][1]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("add one entry\n")); + "add one entry\n"); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, "Pairwise Key content", @@ -2284,7 +2280,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, rtlpriv-> sec.key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set Pairwiase key\n")); + "set Pairwise key\n"); rtl_cam_add_one_entry(hw, macaddr, key_index, entry_id, enc_algo, CAM_CONFIG_NO_USEDK, @@ -2292,7 +2288,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, sec.key_buf[key_index]); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set group key\n")); + "set group key\n"); if (mac->opmode == NL80211_IFTYPE_ADHOC) { rtl_cam_add_one_entry(hw, rtlefuse->dev_addr, diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/led.c b/drivers/net/wireless/rtlwifi/rtl8192de/led.c index f1552f4df658..f2358f20b9cd 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/led.c @@ -45,8 +45,8 @@ void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) u8 ledcfg; struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + REG_LEDCFG2, pled->ledpin); switch (pled->ledpin) { case LED_PIN_GPIO0: @@ -71,7 +71,7 @@ void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = true; @@ -83,8 +83,8 @@ void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); u8 ledcfg; - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + REG_LEDCFG2, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); @@ -106,7 +106,7 @@ void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = false; @@ -153,7 +153,7 @@ void rtl92de_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction) ledaction == LED_CTL_POWER_ON)) { return; } - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", ledaction)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d,\n", ledaction); _rtl92ce_sw_led_control(hw, ledaction); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index 0883349e1c83..82cc052fc98f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -204,8 +204,8 @@ u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) u32 returnvalue, originalvalue, bitshift; u8 dbi_direct; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x)\n", regaddr, bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n", + regaddr, bitmask); if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob) { /* mac1 use phy0 read radio_b. */ /* mac0 use phy1 read radio_b. */ @@ -220,8 +220,9 @@ u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) } bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); returnvalue = (originalvalue & bitmask) >> bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("BBR MASK=0x%x " - "Addr[0x%x]=0x%x\n", bitmask, regaddr, originalvalue)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "BBR MASK=0x%x Addr[0x%x]=0x%x\n", + bitmask, regaddr, originalvalue); return returnvalue; } @@ -233,8 +234,9 @@ void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw, u8 dbi_direct = 0; u32 originalvalue, bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, data)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data); if (rtlhal->during_mac1init_radioa) dbi_direct = BIT(3); else if (rtlhal->during_mac0init_radiob) @@ -255,8 +257,9 @@ void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw, rtl92de_write_dword_dbi(hw, (u16) regaddr, data, dbi_direct); else rtl_write_dword(rtlpriv, regaddr, data); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, data)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data); } static u32 _rtl92d_phy_rf_serial_read(struct ieee80211_hw *hw, @@ -300,8 +303,8 @@ static u32 _rtl92d_phy_rf_serial_read(struct ieee80211_hw *hw, else retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, BLSSIREADBACKDATA); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x] = 0x%x\n", - rfpath, pphyreg->rflssi_readback, retvalue)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFR-%d Addr[0x%x] = 0x%x\n", + rfpath, pphyreg->rflssi_readback, retvalue); return retvalue; } @@ -319,8 +322,8 @@ static void _rtl92d_phy_rf_serial_write(struct ieee80211_hw *hw, /* T65 RF */ data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; rtl_set_bbreg(hw, pphyreg->rf3wire_offset, BMASKDWORD, data_and_addr); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", - rfpath, pphyreg->rf3wire_offset, data_and_addr)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFW-%d Addr[0x%x]=0x%x\n", + rfpath, pphyreg->rf3wire_offset, data_and_addr); } u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, @@ -330,17 +333,17 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, u32 original_value, readback_value, bitshift; unsigned long flags; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "rfpath(%#x), bitmask(%#x)\n", - regaddr, rfpath, bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n", + regaddr, rfpath, bitmask); spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr); bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); readback_value = (original_value & bitmask) >> bitshift; spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " - "bitmask(%#x), original_value(%#x)\n", - regaddr, rfpath, bitmask, original_value)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n", + regaddr, rfpath, bitmask, original_value); return readback_value; } @@ -353,8 +356,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, unsigned long flags; RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); if (bitmask == 0) return; spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); @@ -369,9 +372,9 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, _rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data); } spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); } bool rtl92d_phy_mac_config(struct ieee80211_hw *hw) @@ -381,10 +384,10 @@ bool rtl92d_phy_mac_config(struct ieee80211_hw *hw) u32 arraylength; u32 *ptrarray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Read Rtl819XMACPHY_Array\n"); arraylength = MAC_2T_ARRAYLENGTH; ptrarray = rtl8192de_mac_2tarray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Img:Rtl819XMAC_Array\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Img:Rtl819XMAC_Array\n"); for (i = 0; i < arraylength; i = i + 2) rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) { @@ -561,25 +564,25 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, agctab_arraylen = AGCTAB_ARRAYLENGTH; agctab_array_table = rtl8192de_agctab_array; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:MAC0, Rtl819XAGCTAB_Array\n")); + " ===> phy:MAC0, Rtl819XAGCTAB_Array\n"); } else { if (rtlhal->current_bandtype == BAND_ON_2_4G) { agctab_arraylen = AGCTAB_2G_ARRAYLENGTH; agctab_array_table = rtl8192de_agctab_2garray; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:MAC1, Rtl819XAGCTAB_2GArray\n")); + " ===> phy:MAC1, Rtl819XAGCTAB_2GArray\n"); } else { agctab_5garraylen = AGCTAB_5G_ARRAYLENGTH; agctab_5garray_table = rtl8192de_agctab_5garray; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:MAC1, Rtl819XAGCTAB_5GArray\n")); + " ===> phy:MAC1, Rtl819XAGCTAB_5GArray\n"); } } phy_reg_arraylen = PHY_REG_2T_ARRAYLENGTH; phy_regarray_table = rtl8192de_phy_reg_2tarray; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:Rtl819XPHY_REG_Array_PG\n")); + " ===> phy:Rtl819XPHY_REG_Array_PG\n"); if (configtype == BASEBAND_CONFIG_PHY_REG) { for (i = 0; i < phy_reg_arraylen; i = i + 2) { if (phy_regarray_table[i] == 0xfe) @@ -598,10 +601,9 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, phy_regarray_table[i + 1]); udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The phy_regarray_table[0] is %x" - " Rtl819XPHY_REGArray[1] is %x\n", - phy_regarray_table[i], - phy_regarray_table[i + 1])); + "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n", + phy_regarray_table[i], + phy_regarray_table[i + 1]); } } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { if (rtlhal->interfaceindex == 0) { @@ -613,15 +615,12 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, * setting. */ udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The Rtl819XAGCTAB_Array_" - "Table[0] is %ul " - "Rtl819XPHY_REGArray[1] is %ul\n", + "The Rtl819XAGCTAB_Array_Table[0] is %ul Rtl819XPHY_REGArray[1] is %ul\n", agctab_array_table[i], - agctab_array_table[i + 1])); + agctab_array_table[i + 1]); } RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Normal Chip, MAC0, load " - "Rtl819XAGCTAB_Array\n")); + "Normal Chip, MAC0, load Rtl819XAGCTAB_Array\n"); } else { if (rtlhal->current_bandtype == BAND_ON_2_4G) { for (i = 0; i < agctab_arraylen; i = i + 2) { @@ -632,14 +631,12 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, * setting. */ udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The Rtl819XAGCTAB_Array_" - "Table[0] is %ul Rtl819XPHY_" - "REGArray[1] is %ul\n", + "The Rtl819XAGCTAB_Array_Table[0] is %ul Rtl819XPHY_REGArray[1] is %ul\n", agctab_array_table[i], - agctab_array_table[i + 1])); + agctab_array_table[i + 1]); } RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Load Rtl819XAGCTAB_2GArray\n")); + "Load Rtl819XAGCTAB_2GArray\n"); } else { for (i = 0; i < agctab_5garraylen; i = i + 2) { rtl_set_bbreg(hw, @@ -650,14 +647,12 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, * setting. */ udelay(1); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The Rtl819XAGCTAB_5GArray_" - "Table[0] is %ul Rtl819XPHY_" - "REGArray[1] is %ul\n", + "The Rtl819XAGCTAB_5GArray_Table[0] is %ul Rtl819XPHY_REGArray[1] is %ul\n", agctab_5garray_table[i], - agctab_5garray_table[i + 1])); + agctab_5garray_table[i + 1]); } RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Load Rtl819XAGCTAB_5GArray\n")); + "Load Rtl819XAGCTAB_5GArray\n"); } } } @@ -675,145 +670,145 @@ static void _rtl92d_store_pwrindex_diffrate_offset(struct ieee80211_hw *hw, rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][0] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][0])); + [rtlphy->pwrgroup_cnt][0]); } if (regaddr == RTXAGC_A_RATE54_24) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][1] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][1])); + [rtlphy->pwrgroup_cnt][1]); } if (regaddr == RTXAGC_A_CCK1_MCS32) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][6] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][6])); + [rtlphy->pwrgroup_cnt][6]); } if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][7] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][7] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][7])); + [rtlphy->pwrgroup_cnt][7]); } if (regaddr == RTXAGC_A_MCS03_MCS00) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][2] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][2])); + [rtlphy->pwrgroup_cnt][2]); } if (regaddr == RTXAGC_A_MCS07_MCS04) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][3] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][3])); + [rtlphy->pwrgroup_cnt][3]); } if (regaddr == RTXAGC_A_MCS11_MCS08) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][4] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][4])); + [rtlphy->pwrgroup_cnt][4]); } if (regaddr == RTXAGC_A_MCS15_MCS12) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][5] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][5])); + [rtlphy->pwrgroup_cnt][5]); } if (regaddr == RTXAGC_B_RATE18_06) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][8] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][8] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][8])); + [rtlphy->pwrgroup_cnt][8]); } if (regaddr == RTXAGC_B_RATE54_24) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][9] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][9] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][9])); + [rtlphy->pwrgroup_cnt][9]); } if (regaddr == RTXAGC_B_CCK1_55_MCS32) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][14] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][14] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][14])); + [rtlphy->pwrgroup_cnt][14]); } if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][15] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][15] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][15])); + [rtlphy->pwrgroup_cnt][15]); } if (regaddr == RTXAGC_B_MCS03_MCS00) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][10] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][10] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][10])); + [rtlphy->pwrgroup_cnt][10]); } if (regaddr == RTXAGC_B_MCS07_MCS04) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][11] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%ulx\n", + "MCSTxPowerLevelOriginalOffset[%d][11] = 0x%ulx\n", rtlphy->pwrgroup_cnt, rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][11])); + [rtlphy->pwrgroup_cnt][11]); } if (regaddr == RTXAGC_B_MCS11_MCS08) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][12] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][12])); + "MCSTxPowerLevelOriginalOffset[%d][12] = 0x%ulx\n", + rtlphy->pwrgroup_cnt, + rtlphy->mcs_txpwrlevel_origoffset + [rtlphy->pwrgroup_cnt][12]); } if (regaddr == RTXAGC_B_MCS15_MCS12) { rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][13] = data; RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][13])); + "MCSTxPowerLevelOriginalOffset[%d][13] = 0x%ulx\n", + rtlphy->pwrgroup_cnt, + rtlphy->mcs_txpwrlevel_origoffset + [rtlphy->pwrgroup_cnt][13]); rtlphy->pwrgroup_cnt++; } } @@ -849,7 +844,7 @@ static bool _rtl92d_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, } } else { RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("configtype != BaseBand_Config_PHY_REG\n")); + "configtype != BaseBand_Config_PHY_REG\n"); } return true; } @@ -861,17 +856,17 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw) struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); bool rtstatus = true; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("==>\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n"); rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, BASEBAND_CONFIG_PHY_REG); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Write BB Reg Fail!!\n"); return false; } /* if (rtlphy->rf_type == RF_1T2R) { * _rtl92c_phy_bb_config_1t(hw); - * RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Config to 1T!!\n")); + * RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Config to 1T!!\n"); *} */ if (rtlefuse->autoload_failflag == false) { @@ -880,13 +875,13 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw) BASEBAND_CONFIG_PHY_REG); } if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "BB_PG Reg Fail!!\n"); return false; } rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, BASEBAND_CONFIG_AGC_TAB); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "AGC Table Fail\n"); return false; } rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw, @@ -951,19 +946,17 @@ bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, radiob_array_table = rtl8192de_radiob_2t_int_paarray; } RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PHY_ConfigRFWithHeaderFile() " - "Radio_A:Rtl819XRadioA_1TArray\n")); + "PHY_ConfigRFWithHeaderFile() Radio_A:Rtl819XRadioA_1TArray\n"); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PHY_ConfigRFWithHeaderFile() " - "Radio_B:Rtl819XRadioB_1TArray\n")); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath)); + "PHY_ConfigRFWithHeaderFile() Radio_B:Rtl819XRadioB_1TArray\n"); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio No %x\n", rfpath); /* this only happens when DMDP, mac0 start on 2.4G, * mac1 start on 5G, mac 0 has to set phy0&phy1 * pathA or mac1 has to set phy0&phy1 pathA */ if ((content == radiob_txt) && (rfpath == RF90_PATH_A)) { RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> althougth Path A, we load radiob.txt\n")); + " ===> althougth Path A, we load radiob.txt\n"); radioa_arraylen = radiob_arraylen; radioa_array_table = radiob_array_table; } @@ -1022,11 +1015,11 @@ bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, break; case RF90_PATH_C: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; case RF90_PATH_D: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } return true; @@ -1046,19 +1039,18 @@ void rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) rtlphy->default_initialgain[3] = (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, BMASKBYTE0); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Default initial gain (c50=0x%x, " - "c58=0x%x, c60=0x%x, c68=0x%x\n", - rtlphy->default_initialgain[0], - rtlphy->default_initialgain[1], - rtlphy->default_initialgain[2], - rtlphy->default_initialgain[3])); + "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x\n", + rtlphy->default_initialgain[0], + rtlphy->default_initialgain[1], + rtlphy->default_initialgain[2], + rtlphy->default_initialgain[3]); rtlphy->framesync = (u8)rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, BMASKBYTE0); rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2, BMASKDWORD); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Default framesync (0x%x) = 0x%x\n", - ROFDM0_RXDETECTOR3, rtlphy->framesync)); + "Default framesync (0x%x) = 0x%x\n", + ROFDM0_RXDETECTOR3, rtlphy->framesync); } static void _rtl92d_get_txpower_index(struct ieee80211_hw *hw, u8 channel, @@ -1172,7 +1164,7 @@ void rtl92d_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Unknown Scan Backup operation.\n")); + "Unknown Scan Backup operation\n"); break; } } @@ -1193,14 +1185,13 @@ void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, return; if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("FALSE driver sleep or unload\n")); + "FALSE driver sleep or unload\n"); return; } rtlphy->set_bwmode_inprogress = true; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("Switch to %s bandwidth\n", - rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n", + rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz"); reg_bw_opmode = rtl_read_byte(rtlpriv, REG_BWOPMODE); reg_prsr_rsc = rtl_read_byte(rtlpriv, REG_RRSR + 2); switch (rtlphy->current_chan_bw) { @@ -1218,7 +1209,7 @@ void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } switch (rtlphy->current_chan_bw) { @@ -1250,13 +1241,13 @@ void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } rtl92d_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); rtlphy->set_bwmode_inprogress = false; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); } static void _rtl92d_phy_stop_trx_before_changeband(struct ieee80211_hw *hw) @@ -1273,7 +1264,7 @@ static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band) struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u8 value8; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==>\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "==>\n"); rtlhal->bandset = band; rtlhal->current_bandtype = band; if (IS_92D_SINGLEPHY(rtlhal->version)) @@ -1283,13 +1274,13 @@ static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band) /* reconfig BB/RF according to wireless mode */ if (rtlhal->current_bandtype == BAND_ON_2_4G) { /* BB & RF Config */ - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("====>2.4G\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "====>2.4G\n"); if (rtlhal->interfaceindex == 1) _rtl92d_phy_config_bb_with_headerfile(hw, BASEBAND_CONFIG_AGC_TAB); } else { /* 5G band */ - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("====>5G\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "====>5G\n"); if (rtlhal->interfaceindex == 1) _rtl92d_phy_config_bb_with_headerfile(hw, BASEBAND_CONFIG_AGC_TAB); @@ -1317,7 +1308,7 @@ static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band) 0 ? REG_MAC0 : REG_MAC1), value8); } mdelay(1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<==Switch Band OK.\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "<==Switch Band OK\n"); } static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw, @@ -1329,9 +1320,9 @@ static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw, u8 group, i; unsigned long flag = 0; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>path %d\n", rfpath)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>path %d\n", rfpath); if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>5G\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>5G\n"); rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0); rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0xf); /* fc area 0xd2c */ @@ -1353,14 +1344,13 @@ static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw, } else { /* G band. */ RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, - ("Load RF IMR parameters for G band. IMR already " - "setting %d\n", - rtlpriv->rtlhal.load_imrandiqk_setting_for2g)); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>2.4G\n")); + "Load RF IMR parameters for G band. IMR already setting %d\n", + rtlpriv->rtlhal.load_imrandiqk_setting_for2g); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>2.4G\n"); if (!rtlpriv->rtlhal.load_imrandiqk_setting_for2g) { RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, - ("Load RF IMR parameters " - "for G band. %d\n", rfpath)); + "Load RF IMR parameters for G band. %d\n", + rfpath); rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0); rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, @@ -1378,7 +1368,7 @@ static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw, rtl92d_release_cckandrw_pagea_ctl(hw, &flag); } } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n"); } static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw, @@ -1388,7 +1378,7 @@ static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw, struct rtl_phy *rtlphy = &(rtlpriv->phy); struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("====>\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "====>\n"); /*----Store original RFENV control type----*/ switch (rfpath) { case RF90_PATH_A: @@ -1414,7 +1404,7 @@ static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw, /*Set 0 to 12 bits for 8255 */ rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0); udelay(1); - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<====\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<====\n"); } static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath, @@ -1424,7 +1414,7 @@ static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath, struct rtl_phy *rtlphy = &(rtlpriv->phy); struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("=====>\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "=====>\n"); /*----Restore RFENV control type----*/ ; switch (rfpath) { case RF90_PATH_A: @@ -1437,7 +1427,7 @@ static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath, *pu4_regval); break; } - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<=====\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<=====\n"); } static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) @@ -1451,10 +1441,10 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) bool need_pwr_down = false, internal_pa = false; u32 u4regvalue, mask = 0x1C000, value = 0, u4tmp, u4tmp2; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>\n"); /* config path A for 5G */ if (rtlhal->current_bandtype == BAND_ON_5G) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>5G\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>5G\n"); u4tmp = curveindex_5g[channel - 1]; RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 1 set RF-A, 5G, " "0x28 = 0x%x !!\n", u4tmp)); @@ -1503,12 +1493,13 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) rf_reg_pram_c_5g[index][i]); } RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("offset 0x%x value 0x%x " - "path %d index %d readback 0x%x\n", - rf_reg_for_c_cut_5g[i], - rf_reg_pram_c_5g[index][i], path, - index, rtl_get_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_5g[i], BRFREGOFFSETMASK))); + "offset 0x%x value 0x%x path %d index %d readback 0x%x\n", + rf_reg_for_c_cut_5g[i], + rf_reg_pram_c_5g[index][i], + path, index, + rtl_get_rfreg(hw, (enum radio_path)path, + rf_reg_for_c_cut_5g[i], + BRFREGOFFSETMASK)); } if (need_pwr_down) _rtl92d_phy_restore_rf_env(hw, path, &u4regvalue); @@ -1541,11 +1532,10 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) BRFREGOFFSETMASK, rf_pram_c_5g_int_pa[index][i]); RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, - ("offset 0x%x value 0x%x " - "path %d index %d\n", + "offset 0x%x value 0x%x path %d index %d\n", rf_for_c_cut_5g_internal_pa[i], rf_pram_c_5g_int_pa[index][i], - rfpath, index)); + rfpath, index); } } else { rtl_set_rfreg(hw, (enum radio_path)rfpath, 0x0B, @@ -1553,7 +1543,7 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) } } } else if (rtlhal->current_bandtype == BAND_ON_2_4G) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>2.4G\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>2.4G\n"); u4tmp = curveindex_2g[channel - 1]; RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 3 set RF-B, 2G, " "0x28 = 0x%x !!\n", u4tmp)); @@ -1590,14 +1580,13 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) rf_reg_param_for_c_cut_2g [index][i]); RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("offset 0x%x value 0x%x mak 0x%x path %d " - "index %d readback 0x%x\n", - rf_reg_for_c_cut_2g[i], - rf_reg_param_for_c_cut_2g[index][i], - rf_reg_mask_for_c_cut_2g[i], path, index, - rtl_get_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_2g[i], - BRFREGOFFSETMASK))); + "offset 0x%x value 0x%x mak 0x%x path %d index %d readback 0x%x\n", + rf_reg_for_c_cut_2g[i], + rf_reg_param_for_c_cut_2g[index][i], + rf_reg_mask_for_c_cut_2g[i], path, index, + rtl_get_rfreg(hw, (enum radio_path)path, + rf_reg_for_c_cut_2g[i], + BRFREGOFFSETMASK)); } RTPRINT(rtlpriv, FINIT, INIT_IQK, ("cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", @@ -1611,7 +1600,7 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) if (rtlhal->during_mac0init_radiob) rtl92d_phy_powerdown_anotherphy(hw, true); } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n"); } u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl) @@ -2618,7 +2607,7 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw) true; RT_TRACE(rtlpriv, COMP_SCAN | COMP_MLME, DBG_LOUD, - ("\nIQK OK indexforchannel %d.\n", indexforchannel)); + "IQK OK indexforchannel %d\n", indexforchannel); } } @@ -2629,17 +2618,17 @@ void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel) struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); u8 indexforchannel; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("channel %d\n", channel)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "channel %d\n", channel); /*------Do IQK for normal chip and test chip 5G band------- */ indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("indexforchannel %d done %d\n", indexforchannel, - rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "indexforchannel %d done %d\n", + indexforchannel, + rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done); if (0 && !rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done && rtlphy->need_iqk) { /* Re Do IQK. */ RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_LOUD, - ("Do IQK Matrix reg for channel:%d....\n", channel)); + "Do IQK Matrix reg for channel:%d....\n", channel); rtl92d_phy_iq_calibrate(hw); } else { /* Just load the value. */ @@ -2647,8 +2636,8 @@ void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel) if (((!rtlhal->load_imrandiqk_setting_for2g) && indexforchannel == 0) || indexforchannel > 0) { RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, - ("Just Read IQK Matrix reg for channel:%d" - "....\n", channel)); + "Just Read IQK Matrix reg for channel:%d....\n", + channel); if ((rtlphy->iqk_matrix_regsetting[indexforchannel]. value[0] != NULL) /*&&(regea4 != 0) */) @@ -2672,7 +2661,7 @@ void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel) } } rtlphy->need_iqk = false; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n"); } static u32 _rtl92d_phy_get_abs(u32 val1, u32 val2) @@ -2743,7 +2732,7 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw, u32 u4tmp = 0, u4regvalue = 0; bool bneed_powerdown_radio = false; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("path %d\n", erfpath)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "path %d\n", erfpath); RTPRINT(rtlpriv, FINIT, INIT_IQK, ("band type = %d\n", rtlpriv->rtlhal.current_bandtype)); RTPRINT(rtlpriv, FINIT, INIT_IQK, ("channel = %d\n", channel)); @@ -2788,7 +2777,7 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw, if (rtlpriv->rtlhal.during_mac0init_radiob) rtl92d_phy_powerdown_anotherphy(hw, true); } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n"); } static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t) @@ -2962,10 +2951,10 @@ void rtl92d_phy_reset_iqk_result(struct ieee80211_hw *hw) u8 i; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("settings regs %d default regs %d\n", - (int)(sizeof(rtlphy->iqk_matrix_regsetting) / - sizeof(struct iqk_matrix_regs)), - IQK_MATRIX_REG_NUM)); + "settings regs %d default regs %d\n", + (int)(sizeof(rtlphy->iqk_matrix_regsetting) / + sizeof(struct iqk_matrix_regs)), + IQK_MATRIX_REG_NUM); /* 0xe94, 0xe9c, 0xea4, 0xeac, 0xeb4, 0xebc, 0xec4, 0xecc */ for (i = 0; i < IQK_MATRIX_SETTINGS_NUM; i++) { rtlphy->iqk_matrix_regsetting[i].value[0][0] = 0x100; @@ -3084,7 +3073,7 @@ static bool _rtl92d_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } break; @@ -3111,7 +3100,7 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw) if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) { RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, - ("sw_chnl_inprogress false driver sleep or unload\n")); + "sw_chnl_inprogress false driver sleep or unload\n"); return 0; } while (rtlphy->lck_inprogress && timecount < timeout) { @@ -3154,7 +3143,7 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw) rtlphy->sw_chnl_stage = 0; rtlphy->sw_chnl_step = 0; RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("switch to channel%d\n", rtlphy->current_channel)); + "switch to channel%d\n", rtlphy->current_channel); do { if (!rtlphy->sw_chnl_inprogress) @@ -3171,7 +3160,7 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw) } break; } while (true); - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); rtlphy->sw_chnl_inprogress = false; return 1; } @@ -3182,8 +3171,8 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw) struct rtl_phy *rtlphy = &(rtlpriv->phy); RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("--->Cmd(%#x), set_io_inprogress(%d)\n", - rtlphy->current_io_type, rtlphy->set_io_inprogress)); + "--->Cmd(%#x), set_io_inprogress(%d)\n", + rtlphy->current_io_type, rtlphy->set_io_inprogress); switch (rtlphy->current_io_type) { case IO_CMD_RESUME_DM_BY_SCAN: de_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1; @@ -3197,12 +3186,12 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } rtlphy->set_io_inprogress = false; - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("<---(%#x)\n", rtlphy->current_io_type)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<---(%#x)\n", + rtlphy->current_io_type); } bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) @@ -3212,23 +3201,23 @@ bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) bool postprocessing = false; RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", - iotype, rtlphy->set_io_inprogress)); + "-->IO Cmd(%#x), set_io_inprogress(%d)\n", + iotype, rtlphy->set_io_inprogress); do { switch (iotype) { case IO_CMD_RESUME_DM_BY_SCAN: RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("[IO CMD] Resume DM after scan.\n")); + "[IO CMD] Resume DM after scan\n"); postprocessing = true; break; case IO_CMD_PAUSE_DM_BY_SCAN: RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("[IO CMD] Pause DM before scan.\n")); + "[IO CMD] Pause DM before scan\n"); postprocessing = true; break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } while (false); @@ -3239,7 +3228,7 @@ bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) return false; } rtl92d_phy_set_io(hw); - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, ("<--IO Type(%#x)\n", iotype)); + RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<--IO Type(%#x)\n", iotype); return true; } @@ -3297,7 +3286,7 @@ static void _rtl92d_phy_set_rfsleep(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Fail !!! Switch RF timeout.\n")); + "Fail !!! Switch RF timeout\n"); return; } /* e. For PCIE: SYS_FUNC_EN 0x02[7:0] = 0xE2 reset BB TRX function */ @@ -3332,7 +3321,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, do { InitializeCount++; RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic enable\n")); + "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); } while ((rtstatus != true) && (InitializeCount < 10)); @@ -3341,11 +3330,10 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_RF_OFF_LEVL_HALT_NIC); } else { RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("awake, sleeped:%d ms state_" - "inap:%x\n", + "awake, sleeped:%d ms state_inap:%x\n", jiffies_to_msecs(jiffies - - ppsc->last_sleep_jiffies), - rtlpriv->psc.state_inap)); + ppsc->last_sleep_jiffies), + rtlpriv->psc.state_inap); ppsc->last_awake_jiffies = jiffies; _rtl92d_phy_set_rfon(hw); } @@ -3360,7 +3348,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, case ERFOFF: if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic disable\n")); + "IPS Set eRf nic disable\n"); rtl_ps_disable_nic(hw); RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); } else { @@ -3385,41 +3373,40 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, continue; } else if (rtlpci->pdev->current_state != PCI_D0) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("eRf Off/Sleep: %d times TcbBusyQueu" - "e[%d] !=0 but lower power state!\n", - (i + 1), queue_id)); + "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", + i + 1, queue_id); break; } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("eRf Off/Sleep: %d times TcbBusyQueu" - "e[%d] =%d " - "before doze!\n", (i + 1), queue_id, - skb_queue_len(&ring->queue))); + "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n", + i + 1, queue_id, + skb_queue_len(&ring->queue)); udelay(10); i++; } if (i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("\nERFOFF: %d times TcbBusyQueue[%d] " - "= %d !\n", - MAX_DOZE_WAITING_TIMES_9x, queue_id, - skb_queue_len(&ring->queue))); + "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n", + MAX_DOZE_WAITING_TIMES_9x, queue_id, + skb_queue_len(&ring->queue)); break; } } RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("Set rfsleep awaked:%d ms\n", - jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies))); - RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, ("sleep awaked:%d ms " - "state_inap:%x\n", jiffies_to_msecs(jiffies - - ppsc->last_awake_jiffies), rtlpriv->psc.state_inap)); + "Set rfsleep awaked:%d ms\n", + jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, + "sleep awaked:%d ms state_inap:%x\n", + jiffies_to_msecs(jiffies - + ppsc->last_awake_jiffies), + rtlpriv->psc.state_inap); ppsc->last_sleep_jiffies = jiffies; _rtl92d_phy_set_rfsleep(hw); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); bresult = false; break; } @@ -3437,17 +3424,17 @@ void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw) switch (rtlhal->macphymode) { case DUALMAC_DUALPHY: RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode: DUALMAC_DUALPHY\n")); + "MacPhyMode: DUALMAC_DUALPHY\n"); rtl_write_byte(rtlpriv, offset, 0xF3); break; case SINGLEMAC_SINGLEPHY: RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode: SINGLEMAC_SINGLEPHY\n")); + "MacPhyMode: SINGLEMAC_SINGLEPHY\n"); rtl_write_byte(rtlpriv, offset, 0xF4); break; case DUALMAC_SINGLEPHY: RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode: DUALMAC_SINGLEPHY\n")); + "MacPhyMode: DUALMAC_SINGLEPHY\n"); rtl_write_byte(rtlpriv, offset, 0xF1); break; } @@ -3615,7 +3602,7 @@ void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw) struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); u8 rfpath, i; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==>\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "==>\n"); /* r_select_5G for path_A/B 0 for 2.4G, 1 for 5G */ if (rtlhal->current_bandtype == BAND_ON_2_4G) { /* r_select_5G for path_A/B,0x878 */ @@ -3764,7 +3751,7 @@ void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw) } else { rtl92d_phy_enable_anotherphy(hw, false); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MAC1 use DBI to update 0x888")); + "MAC1 use DBI to update 0x888\n"); /* 0x888 */ rtl92de_write_dword_dbi(hw, RFPGA0_ADDALLOCKEN, rtl92de_read_dword_dbi(hw, @@ -3789,9 +3776,9 @@ void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw) BRFREGOFFSETMASK); } for (i = 0; i < 2; i++) - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("RF 0x18 = 0x%x\n", - rtlphy->rfreg_chnlval[i])); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<==\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "RF 0x18 = 0x%x\n", + rtlphy->rfreg_chnlval[i]); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "<==\n"); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c index db27cebaac2c..3bf21c2cf085 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c @@ -50,8 +50,8 @@ void rtl92d_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) BIT(11), 0x01); RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, - ("20M RF 0x18 = 0x%x\n", - rtlphy->rfreg_chnlval[rfpath])); + "20M RF 0x18 = 0x%x\n", + rtlphy->rfreg_chnlval[rfpath]); } break; @@ -62,13 +62,13 @@ void rtl92d_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(10) | BIT(11), 0x00); RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, - ("40M RF 0x18 = 0x%x\n", - rtlphy->rfreg_chnlval[rfpath])); + "40M RF 0x18 = 0x%x\n", + rtlphy->rfreg_chnlval[rfpath]); } break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", bandwidth)); + "unknown bandwidth: %#X\n", bandwidth); break; } } @@ -423,11 +423,11 @@ bool rtl92d_phy_enable_anotherphy(struct ieee80211_hw *hw, bool bmac0) rtlhal->during_mac0init_radiob = false; rtlhal->during_mac1init_radioa = false; - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("===>\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "===>\n"); /* MAC0 Need PHY1 load radio_b.txt . Driver use DBI to write. */ u1btmp = rtl_read_byte(rtlpriv, mac_reg); if (!(u1btmp & mac_on_bit)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("enable BB & RF\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "enable BB & RF\n"); /* Enable BB and RF power */ rtl92de_write_dword_dbi(hw, REG_SYS_ISO_CTRL, rtl92de_read_dword_dbi(hw, REG_SYS_ISO_CTRL, direct) | @@ -437,7 +437,7 @@ bool rtl92d_phy_enable_anotherphy(struct ieee80211_hw *hw, bool bmac0) * and radio_b.txt has been load. */ bresult = false; } - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<===\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<===\n"); return bresult; } @@ -453,17 +453,17 @@ void rtl92d_phy_powerdown_anotherphy(struct ieee80211_hw *hw, bool bmac0) rtlhal->during_mac0init_radiob = false; rtlhal->during_mac1init_radioa = false; - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("====>\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "====>\n"); /* check MAC0 enable or not again now, if * enabled, not power down radio A. */ u1btmp = rtl_read_byte(rtlpriv, mac_reg); if (!(u1btmp & mac_on_bit)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("power down\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "power down\n"); /* power down RF radio A according to YuNan's advice. */ rtl92de_write_dword_dbi(hw, RFPGA0_XA_LSSIPARAMETER, 0x00000000, direct); } - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<====\n")); + RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<====\n"); } bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw) @@ -606,7 +606,7 @@ bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw) } if (rtstatus != true) { RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio[%d] Fail!!", rfpath)); + "Radio[%d] Fail!!", rfpath); goto phy_rf_cfg_fail; } @@ -620,7 +620,7 @@ bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw) rtl92d_phy_powerdown_anotherphy(hw, false); else if (need_pwrdown_radiob) rtl92d_phy_powerdown_anotherphy(hw, true); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "<---\n"); return rtstatus; phy_rf_cfg_fail: diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index 7911c9c87085..db7579684b11 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -174,7 +174,7 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); if (!rtlpriv->rtlhal.pfirmware) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't alloc buffer for fw.\n")); + "Can't alloc buffer for fw\n"); return 1; } @@ -188,12 +188,12 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->io.dev); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to request firmware!\n")); + "Failed to request firmware!\n"); return 1; } if (firmware->size > 0x8000) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is too big!\n")); + "Firmware is too big!\n"); release_firmware(firmware); return 1; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c index e84b8d5e4b1b..f6ec0a12884f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c @@ -602,8 +602,8 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, EM_HDR_LEN); if (ptcb_desc->empkt_num) { RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD, - ("Insert 8 byte.pTcb->EMPktNum:%d\n", - ptcb_desc->empkt_num)); + "Insert 8 byte.pTcb->EMPktNum:%d\n", + ptcb_desc->empkt_num); _rtl92de_insert_emcontent(ptcb_desc, (u8 *)(skb->data)); } @@ -700,7 +700,7 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, if (ieee80211_is_data_qos(fc)) { if (mac->rdg_en) { RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("Enable RDG function.\n")); + "Enable RDG function\n"); SET_TX_DESC_RDG_ENABLE(pdesc, 1); SET_TX_DESC_HTC(pdesc, 1); } @@ -726,7 +726,7 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, SET_TX_DESC_PKT_ID(pdesc, 8); } SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); + RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); } void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c index 4203a8531ca0..4a5e3a952a47 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c @@ -170,9 +170,9 @@ static void _rtl92s_dm_txpowertracking_callback_thermalmeter( thermalvalue = (u8)rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " - "eeprom_thermalmeter 0x%x\n", thermalvalue, - rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter)); + "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermal meter 0x%x\n", + thermalvalue, + rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter); if (thermalvalue) { rtlpriv->dm.thermalvalue = thermalvalue; @@ -282,11 +282,11 @@ static void _rtl92s_dm_refresh_rateadaptive_mask(struct ieee80211_hw *hw) } if (ra->pre_ratr_state != ra->ratr_state) { - RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, ("RSSI = %ld " - "RSSI_LEVEL = %d PreState = %d, CurState = %d\n", - rtlpriv->dm.undecorated_smoothed_pwdb, - ra->ratr_state, - ra->pre_ratr_state, ra->ratr_state)); + RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, + "RSSI = %ld RSSI_LEVEL = %d PreState = %d, CurState = %d\n", + rtlpriv->dm.undecorated_smoothed_pwdb, + ra->ratr_state, + ra->pre_ratr_state, ra->ratr_state); rtlpriv->cfg->ops->update_rate_tbl(hw, sta, ra->ratr_state); @@ -586,7 +586,7 @@ static void _rtl92s_dm_dynamic_txpower(struct ieee80211_hw *hw) if ((mac->link_state < MAC80211_LINKED) && (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Not connected to any\n")); + "Not connected to any\n"); rtlpriv->dm.dynamic_txhighpower_lvl = TX_HIGHPWR_LEVEL_NORMAL; @@ -599,22 +599,22 @@ static void _rtl92s_dm_dynamic_txpower(struct ieee80211_hw *hw) undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Client PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } else { undecorated_smoothed_pwdb = rtlpriv->dm.undecorated_smoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "STA Default Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } } else { undecorated_smoothed_pwdb = rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); + "AP Ext Port PWDB = 0x%lx\n", + undecorated_smoothed_pwdb); } txpwr_threshold_lv2 = TX_POWER_NEAR_FIELD_THRESH_LVL2; diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c index 3fda6b1dcf46..2a9699feee3b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c @@ -66,7 +66,7 @@ static bool _rtl92s_firmware_enable_cpu(struct ieee80211_hw *hw) cpustatus = rtl_read_byte(rtlpriv, TCR); if (cpustatus & IMEM_RDY) { RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("IMEM Ready after CPU has refilled.\n")); + "IMEM Ready after CPU has refilled\n"); break; } @@ -120,9 +120,8 @@ static u8 _rtl92s_firmware_header_map_rftype(struct ieee80211_hw *hw) return 0x22; break; default: - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Unknown RF type(%x)\n", - rtlphy->rf_type)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Unknown RF type(%x)\n", + rtlphy->rf_type); break; } return 0x22; @@ -177,7 +176,7 @@ static bool _rtl92s_firmware_downloadcode(struct ieee80211_hw *hw, if (buffer_len >= MAX_FIRMWARE_CODE_SIZE) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Size over FIRMWARE_CODE_SIZE!\n")); + "Size over FIRMWARE_CODE_SIZE!\n"); return false; } @@ -231,8 +230,8 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, short pollingcnt = 1000; bool rtstatus = true; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("LoadStaus(%d)\n", - loadfw_status)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "LoadStaus(%d)\n", loadfw_status); firmware->fwstatus = (enum fw_status)loadfw_status; @@ -248,8 +247,8 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, if (!(cpustatus & IMEM_CHK_RPT) || (pollingcnt <= 0)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("FW_STATUS_LOAD_IMEM" - " FAIL CPU, Status=%x\r\n", cpustatus)); + "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\n", + cpustatus); goto status_check_fail; } break; @@ -266,8 +265,8 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, if (!(cpustatus & EMEM_CHK_RPT) || (pollingcnt <= 0)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("FW_STATUS_LOAD_EMEM" - " FAIL CPU, Status=%x\r\n", cpustatus)); + "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\n", + cpustatus); goto status_check_fail; } @@ -275,7 +274,7 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, rtstatus = _rtl92s_firmware_enable_cpu(hw); if (rtstatus != true) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Enable CPU fail!\n")); + "Enable CPU fail!\n"); goto status_check_fail; } break; @@ -291,14 +290,14 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, if (!(cpustatus & DMEM_CODE_DONE) || (pollingcnt <= 0)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Polling DMEM code done" - " fail ! cpustatus(%#x)\n", cpustatus)); + "Polling DMEM code done fail ! cpustatus(%#x)\n", + cpustatus); goto status_check_fail; } RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("DMEM code download success," - " cpustatus(%#x)\n", cpustatus)); + "DMEM code download success, cpustatus(%#x)\n", + cpustatus); /* Prevent Delay too much and being scheduled out */ /* Polling Load Firmware ready */ @@ -311,14 +310,14 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, } while (pollingcnt--); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Polling Load Firmware ready," - " cpustatus(%x)\n", cpustatus)); + "Polling Load Firmware ready, cpustatus(%x)\n", + cpustatus); if (((cpustatus & LOAD_FW_READY) != LOAD_FW_READY) || (pollingcnt <= 0)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Polling Load Firmware" - " ready fail ! cpustatus(%x)\n", cpustatus)); + "Polling Load Firmware ready fail ! cpustatus(%x)\n", + cpustatus); goto status_check_fail; } @@ -332,7 +331,7 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, RCR_APP_ICV | RCR_APP_MIC)); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Current RCR settings(%#x)\n", tmpu4b)); + "Current RCR settings(%#x)\n", tmpu4b); /* Set to normal mode. */ rtl_write_byte(rtlpriv, LBKMD_SEL, LBK_NORMAL); @@ -340,14 +339,15 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, default: RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Unknown status check!\n")); + "Unknown status check!\n"); rtstatus = false; break; } status_check_fail: - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("loadfw_status(%d), " - "rtstatus(%x)\n", loadfw_status, rtstatus)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "loadfw_status(%d), rtstatus(%x)\n", + loadfw_status, rtstatus); return rtstatus; } @@ -378,17 +378,17 @@ int rtl92s_download_fw(struct ieee80211_hw *hw) firmware->firmwareversion = byte(pfwheader->version, 0); firmware->pfwheader->fwpriv.hci_sel = 1;/* pcie */ - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("signature:%x, version:" - "%x, size:%x," - "imemsize:%x, sram size:%x\n", pfwheader->signature, + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", + pfwheader->signature, pfwheader->version, pfwheader->dmem_size, - pfwheader->img_imem_size, pfwheader->img_sram_size)); + pfwheader->img_imem_size, pfwheader->img_sram_size); /* 2. Retrieve IMEM image. */ if ((pfwheader->img_imem_size == 0) || (pfwheader->img_imem_size > sizeof(firmware->fw_imem))) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("memory for data image is less than IMEM required\n")); + "memory for data image is less than IMEM required\n"); goto fail; } else { puc_mappedfile += fwhdr_size; @@ -401,7 +401,7 @@ int rtl92s_download_fw(struct ieee80211_hw *hw) /* 3. Retriecve EMEM image. */ if (pfwheader->img_sram_size > sizeof(firmware->fw_emem)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("memory for data image is less than EMEM required\n")); + "memory for data image is less than EMEM required\n"); goto fail; } else { puc_mappedfile += firmware->fw_imem_len; @@ -436,7 +436,7 @@ int rtl92s_download_fw(struct ieee80211_hw *hw) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Unexpected Download step!!\n")); + "Unexpected Download step!!\n"); goto fail; break; } @@ -446,14 +446,14 @@ int rtl92s_download_fw(struct ieee80211_hw *hw) ul_filelength); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("fail!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "fail!\n"); goto fail; } /* <3> Check whether load FW process is ready */ rtstatus = _rtl92s_firmware_checkready(hw, fwstatus); if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("fail!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "fail!\n"); goto fail; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index f9ba077bc18f..dffcafe01a39 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -80,8 +80,8 @@ void rtl92se_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; } default: { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "switch case not processed\n"); break; } } @@ -140,7 +140,7 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) u8 e_aci; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("HW_VAR_SLOT_TIME %x\n", val[0])); + "HW_VAR_SLOT_TIME %x\n", val[0]); rtl_write_byte(rtlpriv, SLOT_TIME, val[0]); @@ -185,8 +185,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) *val = min_spacing_to_set; RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, mac->min_space_cfg); @@ -201,8 +201,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) mac->min_space_cfg |= (density_to_set << 3); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", - mac->min_space_cfg)); + "Set HW_VAR_SHORTGI_DENSITY: %#x\n", + mac->min_space_cfg); rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, mac->min_space_cfg); @@ -244,8 +244,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_byte(rtlpriv, AGGLEN_LMT_H, regtoset); RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_FACTOR: %#x\n", - factor_toset)); + "Set HW_VAR_AMPDU_FACTOR: %#x\n", + factor_toset); } break; } @@ -282,8 +282,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("HW_VAR_ACM_CTRL acm set " - "failed: eACI is %d\n", acm)); + "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n", + acm); break; } } else { @@ -299,13 +299,13 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } } RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, - ("HW_VAR_ACM_CTRL Write 0x%X\n", acm_ctrl)); + "HW_VAR_ACM_CTRL Write 0x%X\n", acm_ctrl); rtl_write_byte(rtlpriv, AcmHwCtrl, acm_ctrl); break; } @@ -404,7 +404,7 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) } default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -415,14 +415,14 @@ void rtl92se_enable_hw_security_config(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); u8 sec_reg_value = 0x0; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("PairwiseEncAlgorithm = %d " - "GroupEncAlgorithm = %d\n", + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", rtlpriv->sec.pairwise_enc_algorithm, - rtlpriv->sec.group_enc_algorithm)); + rtlpriv->sec.group_enc_algorithm); if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("not open hw encryption\n")); + "not open hw encryption\n"); return; } @@ -433,8 +433,8 @@ void rtl92se_enable_hw_security_config(struct ieee80211_hw *hw) sec_reg_value |= SCR_RXUSEDK; } - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, ("The SECR-value %x\n", - sec_reg_value)); + RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "The SECR-value %x\n", + sec_reg_value); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); @@ -718,8 +718,8 @@ static void _rtl92se_macconfig_before_fwdownload(struct ieee80211_hw *hw) if (pollingcnt <= 0) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Polling TXDMA_INIT_VALUE " - "timeout!! Current TCR(%#x)\n", tmpu1b)); + "Polling TXDMA_INIT_VALUE timeout!! Current TCR(%#x)\n", + tmpu1b); tmpu1b = rtl_read_byte(rtlpriv, CMDR); rtl_write_byte(rtlpriv, CMDR, tmpu1b & (~TXDMA_EN)); udelay(2); @@ -870,10 +870,10 @@ static void _rtl92se_macconfig_after_fwdownload(struct ieee80211_hw *hw) /* Change Program timing */ rtl_write_byte(rtlpriv, REG_EFUSE_CTRL + 3, 0x72); - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("EFUSE CONFIG OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "EFUSE CONFIG OK\n"); } - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "OK\n"); } @@ -951,9 +951,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) rtstatus = rtl92s_download_fw(hw); if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Failed to download FW. " - "Init HW without FW now.., Please copy FW into" - "/lib/firmware/rtlwifi\n")); + "Failed to download FW. Init HW without FW now... Please copy FW into /lib/firmware/rtlwifi\n"); rtlhal->fw_ready = false; } else { rtlhal->fw_ready = true; @@ -968,7 +966,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) /* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */ if (rtl92s_phy_mac_config(hw) != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("MAC Config failed\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "MAC Config failed\n"); return rtstatus; } @@ -978,7 +976,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) /* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */ if (rtl92s_phy_bb_config(hw) != true) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, ("BB Config failed\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "BB Config failed\n"); return rtstatus; } @@ -1014,7 +1012,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, RF_CTRL, 0x07); if (rtl92s_phy_rf_config(hw) != true) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("RF Config failed\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "RF Config failed\n"); return rtstatus; } @@ -1129,26 +1127,26 @@ static int _rtl92se_set_media_status(struct ieee80211_hw *hw, case NL80211_IFTYPE_UNSPECIFIED: bt_msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to NO LINK!\n")); + "Set Network type to NO LINK!\n"); break; case NL80211_IFTYPE_ADHOC: bt_msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to Ad Hoc!\n")); + "Set Network type to Ad Hoc!\n"); break; case NL80211_IFTYPE_STATION: bt_msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to STA!\n")); + "Set Network type to STA!\n"); break; case NL80211_IFTYPE_AP: bt_msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT); RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to AP!\n")); + "Set Network type to AP!\n"); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Network type %d not support!\n", type)); + "Network type %d not supported!\n", type); return 1; break; @@ -1583,8 +1581,8 @@ void rtl92se_update_interrupt_mask(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); + RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n", + add_msr, rm_msr); if (add_msr) rtlpci->irq_mask[0] |= add_msr; @@ -1627,7 +1625,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) if (rtlefuse->epromtype == EEPROM_93C46) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); + "RTL819X Not boot from eeprom, check it !!\n"); } else if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) { rtl_efuse_shadow_map_update(hw); @@ -1642,10 +1640,10 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) eeprom_id = *((u16 *)&hwinfo[0]); if (eeprom_id != RTL8190_EEPROM_ID) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); + "EEPROM ID(%#x) is invalid!!\n", eeprom_id); rtlefuse->autoload_failflag = true; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; } @@ -1663,15 +1661,15 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROMId = 0x%4x\n", eeprom_id)); + "EEPROMId = 0x%4x\n", eeprom_id); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid)); + "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did)); + "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid)); + "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid)); + "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid); for (i = 0; i < 6; i += 2) { usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i]; @@ -1681,8 +1679,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) for (i = 0; i < 6; i++) rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]); - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("%pM\n", rtlefuse->dev_addr)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr); /* Get Tx Power Level by Channel */ /* Read Tx power of Channel 1 ~ 14 from EEPROM. */ @@ -1937,14 +1934,14 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) if (!(tempval & BIT(0))) { rtlefuse->b1x1_recvcombine = true; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("RF_TYPE=1T2R but only 1SS\n")); + "RF_TYPE=1T2R but only 1SS\n"); } } rtlefuse->b1ss_support = rtlefuse->b1x1_recvcombine; rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMID]; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("EEPROM Customer ID: 0x%2x", - rtlefuse->eeprom_oemid)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x", + rtlefuse->eeprom_oemid); /* set channel paln to world wide 13 */ rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13; @@ -1959,19 +1956,19 @@ void rtl92se_read_eeprom_info(struct ieee80211_hw *hw) tmp_u1b = rtl_read_byte(rtlpriv, EPROM_CMD); if (tmp_u1b & BIT(4)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n"); rtlefuse->epromtype = EEPROM_93C46; } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n"); rtlefuse->epromtype = EEPROM_BOOT_EFUSE; } if (tmp_u1b & BIT(5)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); rtlefuse->autoload_failflag = false; _rtl92se_read_adapter_info(hw); } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n"); rtlefuse->autoload_failflag = true; } } @@ -2071,8 +2068,8 @@ static void rtl92se_update_hal_rate_table(struct ieee80211_hw *hw, else rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_REFRESH_BG); - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("%x\n", rtl_read_dword(rtlpriv, ARFR0))); + RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n", + rtl_read_dword(rtlpriv, ARFR0)); } static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw, @@ -2224,8 +2221,8 @@ static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw, mask |= (bmulticast ? 1 : 0) << 9 | (macid & 0x1f) << 4 | (band & 0xf); - RT_TRACE(rtlpriv, COMP_RATR, DBG_TRACE, ("mask = %x, bitmap = %x\n", - mask, ratr_bitmap)); + RT_TRACE(rtlpriv, COMP_RATR, DBG_TRACE, "mask = %x, bitmap = %x\n", + mask, ratr_bitmap); rtl_write_dword(rtlpriv, 0x2c4, ratr_bitmap); rtl_write_dword(rtlpriv, WFM5, (FW_RA_UPDATE_MASK | (mask << 8))); @@ -2301,14 +2298,14 @@ bool rtl92se_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) if ((ppsc->hwradiooff) && (rfpwr_toset == ERFON)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("RFKILL-HW Radio ON, RF ON\n")); + "RFKILL-HW Radio ON, RF ON\n"); rfpwr_toset = ERFON; ppsc->hwradiooff = false; actuallyset = true; } else if ((ppsc->hwradiooff == false) && (rfpwr_toset == ERFOFF)) { - RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("RFKILL-HW Radio OFF, RF OFF\n")); + RT_TRACE(rtlpriv, COMP_RF, + DBG_DMESG, "RFKILL-HW Radio OFF, RF OFF\n"); rfpwr_toset = ERFOFF; ppsc->hwradiooff = true; @@ -2372,7 +2369,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr, u8 cam_offset = 0; u8 clear_number = 5; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); + RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n"); for (idx = 0; idx < clear_number; idx++) { rtl_cam_mark_invalid(hw, cam_offset + idx); @@ -2401,7 +2398,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); enc_algo = CAM_TKIP; break; } @@ -2419,9 +2416,8 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr, p_macaddr); if (entry_id >= TOTAL_CAM_ENTRY) { RT_TRACE(rtlpriv, - COMP_SEC, DBG_EMERG, - ("Can not find free hw" - " security cam entry\n")); + COMP_SEC, DBG_EMERG, + "Can not find free hw security cam entry\n"); return; } } else { @@ -2435,30 +2431,31 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr, if (rtlpriv->sec.key_len[key_index] == 0) { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("delete one entry, entry_id is %d\n", - entry_id)); + "delete one entry, entry_id is %d\n", + entry_id); if (mac->opmode == NL80211_IFTYPE_AP) rtl_cam_del_entry(hw, p_macaddr); rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY length is %d\n", - rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); + "The insert KEY length is %d\n", + rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY is %x %x\n", - rtlpriv->sec.key_buf[0][0], - rtlpriv->sec.key_buf[0][1])); + "The insert KEY is %x %x\n", + rtlpriv->sec.key_buf[0][0], + rtlpriv->sec.key_buf[0][1]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("add one entry\n")); + "add one entry\n"); if (is_pairwise) { RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, - "Pairwise Key content", - rtlpriv->sec.pairwise_key, - rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); + "Pairwise Key content", + rtlpriv->sec.pairwise_key, + rtlpriv->sec. + key_len[PAIRWISE_KEYIDX]); RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set Pairwiase key\n")); + "set Pairwise key\n"); rtl_cam_add_one_entry(hw, macaddr, key_index, entry_id, enc_algo, @@ -2466,7 +2463,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr, rtlpriv->sec.key_buf[key_index]); } else { RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set group key\n")); + "set group key\n"); if (mac->opmode == NL80211_IFTYPE_ADHOC) { rtl_cam_add_one_entry(hw, diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/led.c b/drivers/net/wireless/rtlwifi/rtl8192se/led.c index e3fe7c90ebf4..1a6b0caf0841 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/led.c @@ -52,8 +52,8 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) u8 ledcfg; struct rtl_priv *rtlpriv = rtl_priv(hw); - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", LEDCFG, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + LEDCFG, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, LEDCFG); @@ -68,7 +68,7 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = true; @@ -80,8 +80,8 @@ void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); u8 ledcfg; - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", LEDCFG, pled->ledpin)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", + LEDCFG, pled->ledpin); ledcfg = rtl_read_byte(rtlpriv, LEDCFG); @@ -101,7 +101,7 @@ void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } pled->ledon = false; @@ -141,8 +141,7 @@ void rtl92se_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction) ledaction == LED_CTL_POWER_ON)) { return; } - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", - ledaction)); + RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d\n", ledaction); _rtl92se_sw_led_control(hw, ledaction); } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index f10ac1ad9087..ec5520e68472 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -58,16 +58,15 @@ u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) struct rtl_priv *rtlpriv = rtl_priv(hw); u32 returnvalue = 0, originalvalue, bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)\n", - regaddr, bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n", + regaddr, bitmask); originalvalue = rtl_read_dword(rtlpriv, regaddr); bitshift = _rtl92s_phy_calculate_bit_shift(bitmask); returnvalue = (originalvalue & bitmask) >> bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("BBR MASK=0x%x Addr[0x%x]=0x%x\n", - bitmask, regaddr, originalvalue)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "BBR MASK=0x%x Addr[0x%x]=0x%x\n", + bitmask, regaddr, originalvalue); return returnvalue; @@ -79,8 +78,9 @@ void rtl92s_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 originalvalue, bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, data)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data); if (bitmask != MASKDWORD) { originalvalue = rtl_read_dword(rtlpriv, regaddr); @@ -90,8 +90,9 @@ void rtl92s_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask, rtl_write_dword(rtlpriv, regaddr, data); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, data)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data); } @@ -149,8 +150,8 @@ static u32 _rtl92s_phy_rf_serial_read(struct ieee80211_hw *hw, retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, BLSSI_READBACK_DATA); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x]=0x%x\n", - rfpath, pphyreg->rflssi_readback, retvalue)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFR-%d Addr[0x%x]=0x%x\n", + rfpath, pphyreg->rflssi_readback, retvalue); return retvalue; @@ -172,8 +173,8 @@ static void _rtl92s_phy_rf_serial_write(struct ieee80211_hw *hw, data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", - rfpath, pphyreg->rf3wire_offset, data_and_addr)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFW-%d Addr[0x%x]=0x%x\n", + rfpath, pphyreg->rf3wire_offset, data_and_addr); } @@ -183,8 +184,9 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 original_value, readback_value, bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " - "bitmask(%#x)\n", regaddr, rfpath, bitmask)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n", + regaddr, rfpath, bitmask); spin_lock(&rtlpriv->locks.rf_lock); @@ -195,9 +197,9 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, spin_unlock(&rtlpriv->locks.rf_lock); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " - "bitmask(%#x), original_value(%#x)\n", regaddr, rfpath, - bitmask, original_value)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n", + regaddr, rfpath, bitmask, original_value); return readback_value; } @@ -212,8 +214,9 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, if (!((rtlphy->rf_pathmap >> rfpath) & 0x1)) return; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); spin_lock(&rtlpriv->locks.rf_lock); @@ -228,8 +231,9 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, spin_unlock(&rtlpriv->locks.rf_lock); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x), " - "data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath)); + RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, + "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + regaddr, bitmask, data, rfpath); } @@ -249,7 +253,7 @@ void rtl92s_phy_scan_operation_backup(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Unknown operation.\n")); + "Unknown operation\n"); break; } } @@ -264,9 +268,9 @@ void rtl92s_phy_set_bw_mode(struct ieee80211_hw *hw, struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); u8 reg_bw_opmode; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("Switch to %s bandwidth\n", - rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n", + rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz"); if (rtlphy->set_bwmode_inprogress) return; @@ -290,8 +294,7 @@ void rtl92s_phy_set_bw_mode(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", - rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } @@ -316,13 +319,13 @@ void rtl92s_phy_set_bw_mode(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + "unknown bandwidth: %#X\n", rtlphy->current_chan_bw); break; } rtl92s_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); rtlphy->set_bwmode_inprogress = false; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); } static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, @@ -438,7 +441,7 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); break; } @@ -458,9 +461,8 @@ u8 rtl92s_phy_sw_chnl(struct ieee80211_hw *hw) u32 delay; bool ret; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("switch to channel%d\n", - rtlphy->current_channel)); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "switch to channel%d\n", + rtlphy->current_channel); if (rtlphy->sw_chnl_inprogress) return 0; @@ -496,7 +498,7 @@ u8 rtl92s_phy_sw_chnl(struct ieee80211_hw *hw) rtlphy->sw_chnl_inprogress = false; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); + RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n"); return 1; } @@ -556,7 +558,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, do { InitializeCount++; RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic enable\n")); + "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); } while ((rtstatus != true) && (InitializeCount < 10)); @@ -565,11 +567,11 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_RF_OFF_LEVL_HALT_NIC); } else { RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("awake, sleeped:%d ms " - "state_inap:%x\n", - jiffies_to_msecs(jiffies - - ppsc->last_sleep_jiffies), - rtlpriv->psc.state_inap)); + "awake, sleeped:%d ms state_inap:%x\n", + jiffies_to_msecs(jiffies - + ppsc-> + last_sleep_jiffies), + rtlpriv->psc.state_inap); ppsc->last_awake_jiffies = jiffies; rtl_write_word(rtlpriv, CMDR, 0x37FC); rtl_write_byte(rtlpriv, TXPAUSE, 0x00); @@ -587,7 +589,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, case ERFOFF:{ if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic disable\n")); + "IPS Set eRf nic disable\n"); rtl_ps_disable_nic(hw); RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); } else { @@ -613,11 +615,9 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, continue; } else { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("eRf Off/Sleep: " - "%d times TcbBusyQueue[%d] = " - "%d before doze!\n", - (i + 1), queue_id, - skb_queue_len(&ring->queue))); + "eRf Off/Sleep: %d times TcbBusyQueue[%d] = %d before doze!\n", + i + 1, queue_id, + skb_queue_len(&ring->queue)); udelay(10); i++; @@ -625,31 +625,30 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, if (i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("\nERFOFF: %d times" - "TcbBusyQueue[%d] = %d !\n", + "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n", MAX_DOZE_WAITING_TIMES_9x, queue_id, - skb_queue_len(&ring->queue))); + skb_queue_len(&ring->queue)); break; } } RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("Set ERFSLEEP awaked:%d ms\n", + "Set ERFSLEEP awaked:%d ms\n", jiffies_to_msecs(jiffies - - ppsc->last_awake_jiffies))); + ppsc->last_awake_jiffies)); RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("sleep awaked:%d ms " - "state_inap:%x\n", jiffies_to_msecs(jiffies - - ppsc->last_awake_jiffies), - rtlpriv->psc.state_inap)); + "sleep awaked:%d ms state_inap:%x\n", + jiffies_to_msecs(jiffies - + ppsc->last_awake_jiffies), + rtlpriv->psc.state_inap); ppsc->last_sleep_jiffies = jiffies; _rtl92se_phy_set_rf_sleep(hw); break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); + "switch case not processed\n"); bresult = false; break; } @@ -995,7 +994,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw) if (rtstatus != true) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Write BB Reg Fail!!")); + "Write BB Reg Fail!!\n"); goto phy_BB8190_Config_ParaFile_Fail; } @@ -1009,8 +1008,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw) } if (rtstatus != true) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("_rtl92s_phy_bb_config_parafile(): " - "BB_PG Reg Fail!!")); + "_rtl92s_phy_bb_config_parafile(): BB_PG Reg Fail!!\n"); goto phy_BB8190_Config_ParaFile_Fail; } @@ -1053,7 +1051,7 @@ u8 rtl92s_phy_config_rf(struct ieee80211_hw *hw, enum radio_path rfpath) radio_b_tblen = RADIOB_ARRAYLENGTH; } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Radio No %x\n", rfpath)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Radio No %x\n", rfpath); rtstatus = true; switch (rfpath) { @@ -1175,11 +1173,11 @@ bool rtl92s_phy_bb_config(struct ieee80211_hw *hw) (rtlphy->rf_type == RF_2T2R && rf_num != 2) || (rtlphy->rf_type == RF_2T2R_GREEN && rf_num != 2)) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("RF_Type(%x) does not match " - "RF_Num(%x)!!\n", rtlphy->rf_type, rf_num)); + "RF_Type(%x) does not match RF_Num(%x)!!\n", + rtlphy->rf_type, rf_num); RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("path1 0x%x, path2 0x%x, pathmap " - "0x%x\n", path1, path2, pathmap)); + "path1 0x%x, path2 0x%x, pathmap 0x%x\n", + path1, path2, pathmap); } return rtstatus; @@ -1214,20 +1212,20 @@ void rtl92s_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) ROFDM0_XCAGCCORE1, MASKBYTE0); rtlphy->default_initialgain[3] = rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, MASKBYTE0); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Default initial gain " - "(c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n", + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n", rtlphy->default_initialgain[0], rtlphy->default_initialgain[1], rtlphy->default_initialgain[2], - rtlphy->default_initialgain[3])); + rtlphy->default_initialgain[3]); /* read framesync */ rtlphy->framesync = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, MASKBYTE0); rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2, MASKDWORD); RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Default framesync (0x%x) = 0x%x\n", - ROFDM0_RXDETECTOR3, rtlphy->framesync)); + "Default framesync (0x%x) = 0x%x\n", + ROFDM0_RXDETECTOR3, rtlphy->framesync); } @@ -1287,10 +1285,9 @@ void rtl92s_phy_set_txpower(struct ieee80211_hw *hw, u8 channel) &ofdmpowerLevel[0]); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Channel-%d, cckPowerLevel (A / B) = " - "0x%x / 0x%x, ofdmPowerLevel (A / B) = 0x%x / 0x%x\n", - channel, cckpowerlevel[0], cckpowerlevel[1], - ofdmpowerLevel[0], ofdmpowerLevel[1])); + "Channel-%d, cckPowerLevel (A / B) = 0x%x / 0x%x, ofdmPowerLevel (A / B) = 0x%x / 0x%x\n", + channel, cckpowerlevel[0], cckpowerlevel[1], + ofdmpowerLevel[0], ofdmpowerLevel[1]); _rtl92s_phy_ccxpower_indexcheck(hw, channel, &cckpowerlevel[0], &ofdmpowerLevel[0]); @@ -1316,7 +1313,7 @@ void rtl92s_phy_chk_fwcmd_iodone(struct ieee80211_hw *hw) } while (--pollingcnt); if (pollingcnt == 0) - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Set FW Cmd fail!!\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Set FW Cmd fail!!\n"); } @@ -1345,20 +1342,17 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw) switch (rtlhal->current_fwcmd_io) { case FW_CMD_RA_RESET: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_RA_RESET\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_RESET\n"); rtl_write_dword(rtlpriv, WFM5, FW_RA_RESET); rtl92s_phy_chk_fwcmd_iodone(hw); break; case FW_CMD_RA_ACTIVE: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_RA_ACTIVE\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_ACTIVE\n"); rtl_write_dword(rtlpriv, WFM5, FW_RA_ACTIVE); rtl92s_phy_chk_fwcmd_iodone(hw); break; case FW_CMD_RA_REFRESH_N: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_RA_REFRESH_N\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_REFRESH_N\n"); input = FW_RA_REFRESH; rtl_write_dword(rtlpriv, WFM5, input); rtl92s_phy_chk_fwcmd_iodone(hw); @@ -1367,7 +1361,7 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw) break; case FW_CMD_RA_REFRESH_BG: RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_RA_REFRESH_BG\n")); + "FW_CMD_RA_REFRESH_BG\n"); rtl_write_dword(rtlpriv, WFM5, FW_RA_REFRESH); rtl92s_phy_chk_fwcmd_iodone(hw); rtl_write_dword(rtlpriv, WFM5, FW_RA_DISABLE_RSSI_MASK); @@ -1375,21 +1369,20 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw) break; case FW_CMD_RA_REFRESH_N_COMB: RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_RA_REFRESH_N_COMB\n")); + "FW_CMD_RA_REFRESH_N_COMB\n"); input = FW_RA_IOT_N_COMB; rtl_write_dword(rtlpriv, WFM5, input); rtl92s_phy_chk_fwcmd_iodone(hw); break; case FW_CMD_RA_REFRESH_BG_COMB: RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_RA_REFRESH_BG_COMB\n")); + "FW_CMD_RA_REFRESH_BG_COMB\n"); input = FW_RA_IOT_BG_COMB; rtl_write_dword(rtlpriv, WFM5, input); rtl92s_phy_chk_fwcmd_iodone(hw); break; case FW_CMD_IQK_ENABLE: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_IQK_ENABLE\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_IQK_ENABLE\n"); rtl_write_dword(rtlpriv, WFM5, FW_IQK_ENABLE); rtl92s_phy_chk_fwcmd_iodone(hw); break; @@ -1424,8 +1417,7 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw) rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd); break; case FW_CMD_LPS_ENTER: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_LPS_ENTER\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_LPS_ENTER\n"); current_aid = rtlpriv->mac80211.assoc_id; rtl_write_dword(rtlpriv, WFM5, (FW_LPS_ENTER | ((current_aid | 0xc000) << 8))); @@ -1434,20 +1426,18 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw) * turbo mode until driver leave LPS */ break; case FW_CMD_LPS_LEAVE: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_LPS_LEAVE\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_LPS_LEAVE\n"); rtl_write_dword(rtlpriv, WFM5, FW_LPS_LEAVE); rtl92s_phy_chk_fwcmd_iodone(hw); break; case FW_CMD_ADD_A2_ENTRY: - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, - ("FW_CMD_ADD_A2_ENTRY\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_ADD_A2_ENTRY\n"); rtl_write_dword(rtlpriv, WFM5, FW_ADD_A2_ENTRY); rtl92s_phy_chk_fwcmd_iodone(hw); break; case FW_CMD_CTRL_DM_BY_DRIVER: RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("FW_CMD_CTRL_DM_BY_DRIVER\n")); + "FW_CMD_CTRL_DM_BY_DRIVER\n"); rtl_write_dword(rtlpriv, WFM5, FW_CTRL_DM_BY_DRIVER); rtl92s_phy_chk_fwcmd_iodone(hw); break; @@ -1472,8 +1462,8 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) bool bPostProcessing = false; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n", - fw_cmdio, rtlhal->set_fwcmd_inprogress)); + "Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n", + fw_cmdio, rtlhal->set_fwcmd_inprogress); do { /* We re-map to combined FW CMD ones if firmware version */ @@ -1501,7 +1491,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) * DM map table in the future. */ switch (fw_cmdio) { case FW_CMD_RA_INIT: - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("RA init!!\n")); + RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "RA init!!\n"); fw_cmdmap |= FW_RA_INIT_CTL; FW_CMD_IO_SET(rtlpriv, fw_cmdmap); /* Clear control flag to sync with FW. */ @@ -1509,7 +1499,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) break; case FW_CMD_DIG_DISABLE: RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Set DIG disable!!\n")); + "Set DIG disable!!\n"); fw_cmdmap &= ~FW_DIG_ENABLE_CTL; FW_CMD_IO_SET(rtlpriv, fw_cmdmap); break; @@ -1517,14 +1507,14 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) case FW_CMD_DIG_RESUME: if (!(rtlpriv->dm.dm_flag & HAL_DM_DIG_DISABLE)) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Set DIG enable or resume!!\n")); + "Set DIG enable or resume!!\n"); fw_cmdmap |= (FW_DIG_ENABLE_CTL | FW_SS_CTL); FW_CMD_IO_SET(rtlpriv, fw_cmdmap); } break; case FW_CMD_DIG_HALT: RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Set DIG halt!!\n")); + "Set DIG halt!!\n"); fw_cmdmap &= ~(FW_DIG_ENABLE_CTL | FW_SS_CTL); FW_CMD_IO_SET(rtlpriv, fw_cmdmap); break; @@ -1540,9 +1530,8 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) (rtlefuse->thermalmeter[0] << 16)); RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Set TxPwr tracking!! " - "FwCmdMap(%#x), FwParam(%#x)\n", - fw_cmdmap, fw_param)); + "Set TxPwr tracking!! FwCmdMap(%#x), FwParam(%#x)\n", + fw_cmdmap, fw_param); FW_CMD_PARA_SET(rtlpriv, fw_param); FW_CMD_IO_SET(rtlpriv, fw_cmdmap); @@ -1563,9 +1552,8 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) fw_param &= FW_RA_PARAM_CLR; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("[FW CMD] [New Version] " - "Set RA/IOT Comb in n mode!! FwCmdMap(%#x), " - "FwParam(%#x)\n", fw_cmdmap, fw_param)); + "[FW CMD] [New Version] Set RA/IOT Comb in n mode!! FwCmdMap(%#x), FwParam(%#x)\n", + fw_cmdmap, fw_param); FW_CMD_PARA_SET(rtlpriv, fw_param); FW_CMD_IO_SET(rtlpriv, fw_cmdmap); @@ -1652,7 +1640,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) break; case FW_CMD_PAPE_CONTROL: RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("[FW CMD] Set PAPE Control\n")); + "[FW CMD] Set PAPE Control\n"); fw_cmdmap &= ~FW_PAPE_CTL_BY_SW_HW; FW_CMD_IO_SET(rtlpriv, fw_cmdmap); diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c index 0ad50fe44aa2..8966b731f7e2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c @@ -123,13 +123,13 @@ static void _rtl92s_get_powerbase(struct ieee80211_hw *hw, u8 *p_pwrlevel, } if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("40MHz finalpwr_idx " - "(A / B) = 0x%x / 0x%x\n", p_final_pwridx[0], - p_final_pwridx[1])); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, + "40MHz finalpwr_idx (A / B) = 0x%x / 0x%x\n", + p_final_pwridx[0], p_final_pwridx[1]); } else { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("20MHz finalpwr_idx " - "(A / B) = 0x%x / 0x%x\n", p_final_pwridx[0], - p_final_pwridx[1])); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, + "20MHz finalpwr_idx (A / B) = 0x%x / 0x%x\n", + p_final_pwridx[0], p_final_pwridx[1]); } } @@ -153,9 +153,8 @@ static void _rtl92s_set_antennadiff(struct ieee80211_hw *hw, ant_pwr_diff = -8; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Antenna Diff from RF-B " - "to RF-A = %d (0x%x)\n", ant_pwr_diff, - ant_pwr_diff & 0xf)); + "Antenna Diff from RF-B to RF-A = %d (0x%x)\n", + ant_pwr_diff, ant_pwr_diff & 0xf); ant_pwr_diff &= 0xf; } @@ -172,9 +171,8 @@ static void _rtl92s_set_antennadiff(struct ieee80211_hw *hw, rtl_set_bbreg(hw, RFPGA0_TXGAINSTAGE, (BXBTXAGC | BXCTXAGC | BXDTXAGC), u4reg_val); - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Write BCD-Diff(0x%x) = 0x%x\n", - RFPGA0_TXGAINSTAGE, u4reg_val)); + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "Write BCD-Diff(0x%x) = 0x%x\n", + RFPGA0_TXGAINSTAGE, u4reg_val); } static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, @@ -201,8 +199,7 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, ((index < 2) ? pwrbase0 : pwrbase1); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("RTK better performance, " - "writeval = 0x%x\n", writeval)); + "RTK better performance, writeval = 0x%x\n", writeval); break; case 1: /* Realtek regulatory increase power diff defined @@ -211,8 +208,8 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, writeval = ((index < 2) ? pwrbase0 : pwrbase1); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Realtek regulatory, " - "40MHz, writeval = 0x%x\n", writeval)); + "Realtek regulatory, 40MHz, writeval = 0x%x\n", + writeval); } else { if (rtlphy->pwrgroup_cnt == 1) chnlgroup = 0; @@ -234,16 +231,15 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, pwrbase0 : pwrbase1); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Realtek regulatory, " - "20MHz, writeval = 0x%x\n", writeval)); + "Realtek regulatory, 20MHz, writeval = 0x%x\n", + writeval); } break; case 2: /* Better regulatory don't increase any power diff */ writeval = ((index < 2) ? pwrbase0 : pwrbase1); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Better regulatory, " - "writeval = 0x%x\n", writeval)); + "Better regulatory, writeval = 0x%x\n", writeval); break; case 3: /* Customer defined power diff. increase power diff @@ -252,14 +248,14 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("customer's limit, 40MHz = 0x%x\n", - rtlefuse->pwrgroup_ht40 - [RF90_PATH_A][chnl - 1])); + "customer's limit, 40MHz = 0x%x\n", + rtlefuse->pwrgroup_ht40 + [RF90_PATH_A][chnl - 1]); } else { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("customer's limit, 20MHz = 0x%x\n", - rtlefuse->pwrgroup_ht20 - [RF90_PATH_A][chnl - 1])); + "customer's limit, 20MHz = 0x%x\n", + rtlefuse->pwrgroup_ht20 + [RF90_PATH_A][chnl - 1]); } for (i = 0; i < 4; i++) { @@ -293,22 +289,19 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, (pwrdiff_limit[1] << 8) | (pwrdiff_limit[0]); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Customer's limit = 0x%x\n", - customer_limit)); + "Customer's limit = 0x%x\n", customer_limit); writeval = customer_limit + ((index < 2) ? pwrbase0 : pwrbase1); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Customer, writeval = " - "0x%x\n", writeval)); + "Customer, writeval = 0x%x\n", writeval); break; default: chnlgroup = 0; writeval = rtlphy->mcs_txpwrlevel_origoffset[chnlgroup][index] + ((index < 2) ? pwrbase0 : pwrbase1); RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("RTK better performance, " - "writeval = 0x%x\n", writeval)); + "RTK better performance, writeval = 0x%x\n", writeval); break; } @@ -541,8 +534,7 @@ void rtl92s_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) break; default: RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", - bandwidth)); + "unknown bandwidth: %#X\n", bandwidth); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index 78723cf59491..bc4b6fa4fc85 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -188,7 +188,7 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->rtlhal.pfirmware = vzalloc(sizeof(struct rt_firmware)); if (!rtlpriv->rtlhal.pfirmware) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't alloc buffer for fw.\n")); + "Can't alloc buffer for fw\n"); return 1; } @@ -199,12 +199,12 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->io.dev); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to request firmware!\n")); + "Failed to request firmware!\n"); return 1; } if (firmware->size > sizeof(struct rt_firmware)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is too big!\n")); + "Firmware is too big!\n"); release_firmware(firmware); return 1; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c index fbebe3ea0a22..1f266d1d7951 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c @@ -756,7 +756,7 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw, /* DOWRD 8 */ SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, cpu_to_le32(mapping)); - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); + RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); } void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index 1b8e68e70f8a..d670e6886c1f 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -276,14 +276,14 @@ static int _rtl_usb_init_tx(struct ieee80211_hw *hw) ? USB_HIGH_SPEED_BULK_SIZE : USB_FULL_SPEED_BULK_SIZE; - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("USB Max Bulk-out Size=%d\n", - rtlusb->max_bulk_out_size)); + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "USB Max Bulk-out Size=%d\n", + rtlusb->max_bulk_out_size); for (i = 0; i < __RTL_TXQ_NUM; i++) { u32 ep_num = rtlusb->ep_map.ep_mapping[i]; if (!ep_num) { RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("Invalid endpoint map setting!\n")); + "Invalid endpoint map setting!\n"); return -EINVAL; } } @@ -345,9 +345,9 @@ static int _rtl_usb_init(struct ieee80211_hw *hw) rtlusb->out_ep_nums++; RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - ("USB EP(0x%02x), MaxPacketSize=%d ,Interval=%d.\n", + "USB EP(0x%02x), MaxPacketSize=%d, Interval=%d\n", pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize, - pep_desc->bInterval)); + pep_desc->bInterval); } if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num) return -EINVAL ; @@ -414,7 +414,7 @@ static struct sk_buff *_rtl_prep_rx_urb(struct ieee80211_hw *hw, gfp_mask); if (!skb) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to __dev_alloc_skb!!\n")); + "Failed to __dev_alloc_skb!!\n"); return ERR_PTR(-ENOMEM); } @@ -575,7 +575,7 @@ static void _rtl_rx_completed(struct urb *_urb) if (IS_ERR(_skb)) { err = PTR_ERR(_skb); RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Can't allocate skb for bulk IN!\n")); + "Can't allocate skb for bulk IN!\n"); return; } skb = _skb; @@ -632,14 +632,14 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw) urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to alloc URB!!\n")); + "Failed to alloc URB!!\n"); goto err_out; } skb = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL); if (IS_ERR(skb)) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to prep_rx_urb!!\n")); + "Failed to prep_rx_urb!!\n"); err = PTR_ERR(skb); goto err_out; } @@ -745,7 +745,7 @@ static void _rtl_submit_tx_urb(struct ieee80211_hw *hw, struct urb *_urb) struct sk_buff *skb; RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Failed to submit urb.\n")); + "Failed to submit urb\n"); usb_unanchor_urb(_urb); skb = (struct sk_buff *)_urb->context; kfree_skb(skb); @@ -768,7 +768,7 @@ static int _usb_tx_post(struct ieee80211_hw *hw, struct urb *urb, if (urb->status) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Urb has error status 0x%X\n", urb->status)); + "Urb has error status 0x%X\n", urb->status); goto out; } /* TODO: statistics */ @@ -805,7 +805,7 @@ static struct urb *_rtl_usb_tx_urb_setup(struct ieee80211_hw *hw, _urb = usb_alloc_urb(0, GFP_ATOMIC); if (!_urb) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("Can't allocate URB for bulk out!\n")); + "Can't allocate URB for bulk out!\n"); kfree_skb(skb); return NULL; } @@ -830,7 +830,7 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, struct sk_buff *skb, WARN_ON(NULL == rtlusb->usb_tx_aggregate_hdl); if (unlikely(IS_USB_STOP(rtlusb))) { RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, - ("USB device is stopping...\n")); + "USB device is stopping...\n"); kfree_skb(skb); return; } @@ -840,7 +840,7 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, struct sk_buff *skb, _urb = _rtl_usb_tx_urb_setup(hw, _skb, ep_num); if (unlikely(!_urb)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't allocate urb. Drop skb!\n")); + "Can't allocate urb. Drop skb!\n"); return; } urb_list = &rtlusb->tx_pending[ep_num]; @@ -865,7 +865,7 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb, memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); if (ieee80211_is_auth(fc)) { - RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n")); + RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n"); rtl_ips_nic_on(hw); } @@ -969,8 +969,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, /*like read eeprom and so on */ rtlpriv->cfg->ops->read_eeprom_info(hw); if (rtlpriv->cfg->ops->init_sw_vars(hw)) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't init_sw_vars.\n")); + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n"); goto error_out; } rtlpriv->cfg->ops->init_sw_leds(hw); @@ -980,7 +979,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, err = rtl_init_core(hw); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't allocate sw for mac80211.\n")); + "Can't allocate sw for mac80211\n"); goto error_out; } @@ -990,7 +989,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, err = ieee80211_register_hw(hw); if (err) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - ("Can't register mac80211 hw.\n")); + "Can't register mac80211 hw\n"); goto error_out; } else { rtlpriv->mac80211.mac80211_registered = 1; -- GitLab From 4c48869f5d6e4ee4a773fd67a01e1b934faa57f8 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:42 -0800 Subject: [PATCH 0076/1846] rtlwifi: Convert RTPRINT macro to use ##__VA_ARGS__ Consolidate printks to avoid possible message interleaving and reduce the object size. Remove unnecessary RTPRINT parentheses. Coalesce formats. Align arguments. $ size drivers/net/wireless/rtlwifi/built-in.o* text data bss dec hex filename 590002 55333 127560 772895 bcb1f drivers/net/wireless/rtlwifi/built-in.o.new 594841 55333 129680 779854 be64e drivers/net/wireless/rtlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/debug.h | 6 +- drivers/net/wireless/rtlwifi/efuse.c | 28 +-- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 74 +++--- drivers/net/wireless/rtlwifi/rtl8192ce/rf.c | 77 +++--- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 71 +++--- drivers/net/wireless/rtlwifi/rtl8192cu/rf.c | 65 +++-- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 250 +++++++++---------- drivers/net/wireless/rtlwifi/rtl8192de/rf.c | 69 +++-- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 85 +++---- 9 files changed, 355 insertions(+), 370 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index 8c1396933540..8b51a828effa 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -175,11 +175,11 @@ do { \ } \ } while (0) -#define RTPRINT(rtlpriv, dbgtype, dbgflag, printstr) \ +#define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \ do { \ if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \ - printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ - printk printstr; \ + printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \ + ##__VA_ARGS__); \ } \ } while (0) diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index 2885131cf1a0..a079a31b4ed7 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c @@ -280,7 +280,7 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) if (*rtemp8 != 0xFF) { efuse_utilized++; RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, - ("Addr=%d\n", efuse_addr)); + "Addr=%d\n", efuse_addr); efuse_addr++; } @@ -290,13 +290,13 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) if (offset < efuse_max_section) { wren = (*rtemp8 & 0x0f); RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, - ("offset-%d Worden=%x\n", offset, wren)); + "offset-%d Worden=%x\n", offset, wren); for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { if (!(wren & 0x01)) { RTPRINT(rtlpriv, FEEPROM, - EFUSE_READ_ALL, ("Addr=%d\n", - efuse_addr)); + EFUSE_READ_ALL, + "Addr=%d\n", efuse_addr); read_efuse_byte(hw, efuse_addr, rtemp8); efuse_addr++; @@ -308,8 +308,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) break; RTPRINT(rtlpriv, FEEPROM, - EFUSE_READ_ALL, ("Addr=%d\n", - efuse_addr)); + EFUSE_READ_ALL, + "Addr=%d\n", efuse_addr); read_efuse_byte(hw, efuse_addr, rtemp8); efuse_addr++; @@ -326,7 +326,7 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) } RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, - ("Addr=%d\n", efuse_addr)); + "Addr=%d\n", efuse_addr); read_efuse_byte(hw, efuse_addr, rtemp8); if (*rtemp8 != 0xFF && (efuse_addr < efuse_len)) { efuse_utilized++; @@ -850,7 +850,7 @@ static void efuse_write_data_case1(struct ieee80211_hw *hw, u16 *efuse_addr, } } } - RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, ("efuse PG_STATE_HEADER-1\n")); + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, "efuse PG_STATE_HEADER-1\n"); } static void efuse_write_data_case2(struct ieee80211_hw *hw, u16 *efuse_addr, @@ -915,7 +915,7 @@ static void efuse_write_data_case2(struct ieee80211_hw *hw, u16 *efuse_addr, } RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, - ("efuse PG_STATE_HEADER-2\n")); + "efuse PG_STATE_HEADER-2\n"); } } @@ -935,7 +935,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw, if (efuse_get_current_size(hw) >= (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES)) { RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, - ("efuse_pg_packet_write error\n")); + "efuse_pg_packet_write error\n"); return false; } @@ -947,7 +947,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw, efuse_word_enable_data_read(word_en, data, target_pkt.data); target_word_cnts = efuse_calculate_word_cnts(target_pkt.word_en); - RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, ("efuse Power ON\n")); + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, "efuse Power ON\n"); while (continual && (efuse_addr < (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES))) { @@ -955,7 +955,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw, if (write_state == PG_STATE_HEADER) { badworden = 0x0F; RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, - ("efuse PG_STATE_HEADER\n")); + "efuse PG_STATE_HEADER\n"); if (efuse_one_byte_read(hw, efuse_addr, &efuse_data) && (efuse_data != 0xFF)) @@ -975,7 +975,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw, } else if (write_state == PG_STATE_DATA) { RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, - ("efuse PG_STATE_DATA\n")); + "efuse PG_STATE_DATA\n"); badworden = efuse_word_enable_data_write(hw, efuse_addr + 1, target_pkt.word_en, @@ -998,7 +998,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw, result = false; } RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, - ("efuse PG_STATE_HEADER-3\n")); + "efuse PG_STATE_HEADER-3\n"); } } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 4aa228fe96e9..2d01673a2087 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -1362,25 +1362,24 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path, - i, - rtlefuse-> - eeprom_chnlarea_txpwr_cck[rf_path][i])); + "RF(%d) EEPROM CCK Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse-> + eeprom_chnlarea_txpwr_cck[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", - rf_path, i, - rtlefuse-> - eeprom_chnlarea_txpwr_ht40_1s[rf_path][i])); + "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse-> + eeprom_chnlarea_txpwr_ht40_1s[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", - rf_path, i, - rtlefuse-> - eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path] - [i])); + "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse-> + eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) { for (i = 0; i < 14; i++) { @@ -1411,11 +1410,11 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, for (i = 0; i < 14; i++) { RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = " - "[0x%x / 0x%x / 0x%x]\n", rf_path, i, - rtlefuse->txpwrlevel_cck[rf_path][i], - rtlefuse->txpwrlevel_ht40_1s[rf_path][i], - rtlefuse->txpwrlevel_ht40_2s[rf_path][i])); + "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n", + rf_path, i, + rtlefuse->txpwrlevel_cck[rf_path][i], + rtlefuse->txpwrlevel_ht40_1s[rf_path][i], + rtlefuse->txpwrlevel_ht40_2s[rf_path][i]); } } @@ -1452,13 +1451,13 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, } RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-%d pwrgroup_ht20[%d] = 0x%x\n", - rf_path, i, - rtlefuse->pwrgroup_ht20[rf_path][i])); + "RF-%d pwrgroup_ht20[%d] = 0x%x\n", + rf_path, i, + rtlefuse->pwrgroup_ht20[rf_path][i]); RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-%d pwrgroup_ht40[%d] = 0x%x\n", - rf_path, i, - rtlefuse->pwrgroup_ht40[rf_path][i])); + "RF-%d pwrgroup_ht40[%d] = 0x%x\n", + rf_path, i, + rtlefuse->pwrgroup_ht40[rf_path][i]); } } @@ -1497,27 +1496,27 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_ht20diff[RF90_PATH_A][i])); + "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i])); + "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_ht20diff[RF90_PATH_B][i])); + "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i])); + "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]); if (!autoload_fail) rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7); else rtlefuse->eeprom_regulatory = 0; RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); + "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory); if (!autoload_fail) { rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A]; @@ -1526,10 +1525,9 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, rtlefuse->eeprom_tssi[RF90_PATH_A] = EEPROM_DEFAULT_TSSI; rtlefuse->eeprom_tssi[RF90_PATH_B] = EEPROM_DEFAULT_TSSI; } - RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("TSSI_A = 0x%x, TSSI_B = 0x%x\n", - rtlefuse->eeprom_tssi[RF90_PATH_A], - rtlefuse->eeprom_tssi[RF90_PATH_B])); + RTPRINT(rtlpriv, FINIT, INIT_TxPower, "TSSI_A = 0x%x, TSSI_B = 0x%x\n", + rtlefuse->eeprom_tssi[RF90_PATH_A], + rtlefuse->eeprom_tssi[RF90_PATH_B]); if (!autoload_fail) tempval = hwinfo[EEPROM_THERMAL_METER]; @@ -1542,7 +1540,7 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); + "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter); } static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c index 3ba1a4feeb3f..5ef960499a43 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c @@ -123,8 +123,8 @@ void rtl92ce_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_A_CCK1_MCS32)); + "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_A_CCK1_MCS32); tmpval = tx_agc[RF90_PATH_A] >> 8; @@ -133,22 +133,22 @@ void rtl92ce_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); + "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK11_A_CCK2_11); tmpval = tx_agc[RF90_PATH_B] >> 24; rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); + "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK11_A_CCK2_11); tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK1_55_MCS32)); + "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK1_55_MCS32); } static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, @@ -171,8 +171,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, (powerBase0 << 8) | powerBase0; *(ofdmbase + i) = powerBase0; RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [OFDM power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); + " [OFDM power base index rf(%c) = 0x%x]\n", + i == 0 ? 'A' : 'B', *(ofdmbase + i)); } for (i = 0; i < 2; i++) { @@ -187,8 +187,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, *(mcsbase + i) = powerBase1; RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [MCS power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); + " [MCS power base index rf(%c) = 0x%x]\n", + i == 0 ? 'A' : 'B', *(mcsbase + i)); } } @@ -215,9 +215,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("RTK better performance, " - "writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "RTK better performance, writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; case 1: if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { @@ -225,9 +224,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Realtek regulatory, 40MHz, " - "writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Realtek regulatory, 40MHz, writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); } else { if (rtlphy->pwrgroup_cnt == 1) chnlgroup = 0; @@ -249,9 +247,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Realtek regulatory, 20MHz, " - "writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); } break; case 2: @@ -259,27 +256,24 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Better regulatory, " - "writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Better regulatory, writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; case 3: chnlgroup = 0; if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 40MHz " - "rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), - rtlefuse->pwrgroup_ht40[rf][channel - - 1])); + "customer's limit, 40MHz rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', + rtlefuse->pwrgroup_ht40[rf][channel - + 1]); } else { RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 20MHz " - "rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), - rtlefuse->pwrgroup_ht20[rf][channel - - 1])); + "customer's limit, 20MHz rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', + rtlefuse->pwrgroup_ht20[rf][channel - + 1]); } for (i = 0; i < 4; i++) { pwr_diff_limit[i] = @@ -311,15 +305,15 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer's limit rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), customer_limit)); + "Customer's limit rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', customer_limit); writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer, writeVal rf(%c)= 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Customer, writeVal rf(%c)= 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; default: chnlgroup = 0; @@ -329,9 +323,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("RTK better performance, writeVal " - "rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "RTK better performance, writeVal rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; } @@ -383,7 +376,7 @@ static void _rtl92c_write_ofdm_power_reg(struct ieee80211_hw *hw, rtl_set_bbreg(hw, regoffset, MASKDWORD, writeVal); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Set 0x%x = %08x\n", regoffset, writeVal)); + "Set 0x%x = %08x\n", regoffset, writeVal); if (((get_rf_type(rtlphy) == RF_2T2R) && (regoffset == RTXAGC_A_MCS15_MCS12 || diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 80bd17d85935..de1542f14856 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -162,24 +162,24 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path, - i, rtlefuse-> - eeprom_chnlarea_txpwr_cck[rf_path][i])); + "RF(%d) EEPROM CCK Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse-> + eeprom_chnlarea_txpwr_cck[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", - rf_path, i, - rtlefuse-> - eeprom_chnlarea_txpwr_ht40_1s[rf_path][i])); + "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse-> + eeprom_chnlarea_txpwr_ht40_1s[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", - rf_path, i, - rtlefuse-> - eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path] - [i])); + "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse-> + eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) { for (i = 0; i < 14; i++) { index = _rtl92c_get_chnl_group((u8) i); @@ -205,11 +205,10 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, } for (i = 0; i < 14; i++) { RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = " - "[0x%x / 0x%x / 0x%x]\n", rf_path, i, - rtlefuse->txpwrlevel_cck[rf_path][i], - rtlefuse->txpwrlevel_ht40_1s[rf_path][i], - rtlefuse->txpwrlevel_ht40_2s[rf_path][i])); + "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n", rf_path, i, + rtlefuse->txpwrlevel_cck[rf_path][i], + rtlefuse->txpwrlevel_ht40_1s[rf_path][i], + rtlefuse->txpwrlevel_ht40_2s[rf_path][i]); } } for (i = 0; i < 3; i++) { @@ -242,13 +241,13 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, & 0xf0) >> 4); } RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-%d pwrgroup_ht20[%d] = 0x%x\n", - rf_path, i, - rtlefuse->pwrgroup_ht20[rf_path][i])); + "RF-%d pwrgroup_ht20[%d] = 0x%x\n", + rf_path, i, + rtlefuse->pwrgroup_ht20[rf_path][i]); RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-%d pwrgroup_ht40[%d] = 0x%x\n", - rf_path, i, - rtlefuse->pwrgroup_ht40[rf_path][i])); + "RF-%d pwrgroup_ht40[%d] = 0x%x\n", + rf_path, i, + rtlefuse->pwrgroup_ht40[rf_path][i]); } } for (i = 0; i < 14; i++) { @@ -277,26 +276,26 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][7]; for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_ht20diff[RF90_PATH_A][i])); + "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i])); + "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_ht20diff[RF90_PATH_B][i])); + "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i])); + "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]); if (!autoload_fail) rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7); else rtlefuse->eeprom_regulatory = 0; RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); + "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory); if (!autoload_fail) { rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A]; rtlefuse->eeprom_tssi[RF90_PATH_B] = hwinfo[EEPROM_TSSI_B]; @@ -305,9 +304,9 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, rtlefuse->eeprom_tssi[RF90_PATH_B] = EEPROM_DEFAULT_TSSI; } RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("TSSI_A = 0x%x, TSSI_B = 0x%x\n", - rtlefuse->eeprom_tssi[RF90_PATH_A], - rtlefuse->eeprom_tssi[RF90_PATH_B])); + "TSSI_A = 0x%x, TSSI_B = 0x%x\n", + rtlefuse->eeprom_tssi[RF90_PATH_A], + rtlefuse->eeprom_tssi[RF90_PATH_B]); if (!autoload_fail) tempval = hwinfo[EEPROM_THERMAL_METER]; else @@ -320,7 +319,7 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, rtlefuse->apk_thermalmeterignore = true; rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); + "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter); } static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c index 7b48ee9acb15..e132cb30a309 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c @@ -140,26 +140,26 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_A_CCK1_MCS32)); + "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_A_CCK1_MCS32); tmpval = tx_agc[RF90_PATH_A] >> 8; if (mac->mode == WIRELESS_MODE_B) tmpval = tmpval & 0xff00ffff; rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); + "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK11_A_CCK2_11); tmpval = tx_agc[RF90_PATH_B] >> 24; rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); + "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK11_A_CCK2_11); tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK1_55_MCS32)); + "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK1_55_MCS32); } static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, @@ -181,8 +181,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, (powerBase0 << 8) | powerBase0; *(ofdmbase + i) = powerBase0; RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [OFDM power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); + " [OFDM power base index rf(%c) = 0x%x]\n", + i == 0 ? 'A' : 'B', *(ofdmbase + i)); } for (i = 0; i < 2; i++) { if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20) { @@ -194,8 +194,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, (powerBase1 << 16) | (powerBase1 << 8) | powerBase1; *(mcsbase + i) = powerBase1; RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [MCS power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); + " [MCS power base index rf(%c) = 0x%x]\n", + i == 0 ? 'A' : 'B', *(mcsbase + i)); } } @@ -219,8 +219,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, [chnlgroup][index + (rf ? 8 : 0)] + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("RTK better performance,writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "RTK better performance,writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; case 1: if (rtlphy->pwrgroup_cnt == 1) @@ -244,32 +244,31 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Realtek regulatory, 20MHz, " - "writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; case 2: writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Better regulatory,writeVal(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Better regulatory,writeVal(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; case 3: chnlgroup = 0; if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 40MHzrf(%c) = " - "0x%x\n", ((rf == 0) ? 'A' : 'B'), + "customer's limit, 40MHzrf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', rtlefuse->pwrgroup_ht40[rf] - [channel - 1])); + [channel - 1]); } else { RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 20MHz rf(%c) = " - "0x%x\n", ((rf == 0) ? 'A' : 'B'), + "customer's limit, 20MHz rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', rtlefuse->pwrgroup_ht20[rf] - [channel - 1])); + [channel - 1]); } for (i = 0; i < 4; i++) { pwr_diff_limit[i] = @@ -297,22 +296,22 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, (pwr_diff_limit[2] << 16) | (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer's limit rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), customer_limit)); + "Customer's limit rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', customer_limit); writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer, writeVal rf(%c)= 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + "Customer, writeVal rf(%c)= 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; default: chnlgroup = 0; writeVal = rtlphy->mcs_txpwrlevel_origoffset[chnlgroup] [index + (rf ? 8 : 0)] + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("RTK better " - "performance, writeValrf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeVal)); + RTPRINT(rtlpriv, FPHY, PHY_TXPWR, + "RTK better performance, writeValrf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeVal); break; } if (rtlpriv->dm.dynamic_txhighpower_lvl == @@ -365,7 +364,7 @@ static void _rtl92c_write_ofdm_power_reg(struct ieee80211_hw *hw, regoffset = regoffset_b[index]; rtl_set_bbreg(hw, regoffset, MASKDWORD, writeVal); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Set 0x%x = %08x\n", regoffset, writeVal)); + "Set 0x%x = %08x\n", regoffset, writeVal); if (((get_rf_type(rtlphy) == RF_2T2R) && (regoffset == RTXAGC_A_MCS15_MCS12 || regoffset == RTXAGC_B_MCS15_MCS12)) || diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index 82cc052fc98f..c736b9334888 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -1446,8 +1446,8 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) if (rtlhal->current_bandtype == BAND_ON_5G) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>5G\n"); u4tmp = curveindex_5g[channel - 1]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 1 set RF-A, 5G, " - "0x28 = 0x%x !!\n", u4tmp)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, + "ver 1 set RF-A, 5G, 0x28 = 0x%x !!\n", u4tmp); for (i = 0; i < RF_CHNL_NUM_5G; i++) { if (channel == rf_chnl_5g[i] && channel <= 140) index = 0; @@ -1545,8 +1545,8 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) } else if (rtlhal->current_bandtype == BAND_ON_2_4G) { RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>2.4G\n"); u4tmp = curveindex_2g[channel - 1]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 3 set RF-B, 2G, " - "0x28 = 0x%x !!\n", u4tmp)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, + "ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", u4tmp); if (channel == 1 || channel == 2 || channel == 4 || channel == 9 || channel == 10 || channel == 11 || channel == 12) index = 0; @@ -1589,8 +1589,8 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) BRFREGOFFSETMASK)); } RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", - rf_syn_g4_for_c_cut_2g | (u4tmp << 11))); + "cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", + rf_syn_g4_for_c_cut_2g | (u4tmp << 11)); rtl_set_rfreg(hw, (enum radio_path)path, RF_SYN_G4, BRFREGOFFSETMASK, @@ -1637,9 +1637,9 @@ static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb) u32 regeac, rege94, rege9c, regea4; u8 result = 0; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK!\n"); /* path-A IQK setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A IQK setting!\n"); if (rtlhal->interfaceindex == 0) { rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x10008c1f); rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x10008c1f); @@ -1657,26 +1657,26 @@ static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb) rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x28160206); } /* LO calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "LO calibration setting!\n"); rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); /* One shot, path A LOK & IQK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "One shot, path A LOK & IQK!\n"); rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000); rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); /* delay x ms */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path A LOK & IQK.\n", - IQK_DELAY_TIME)); + "Delay %d ms for One shot, path A LOK & IQK\n", + IQK_DELAY_TIME); mdelay(IQK_DELAY_TIME); /* Check failed */ regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac); rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe94 = 0x%x\n", rege94)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe94 = 0x%x\n", rege94); rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe9c = 0x%x\n", rege9c)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe9c = 0x%x\n", rege9c); regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regea4)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xea4 = 0x%x\n", regea4); if (!(regeac & BIT(28)) && (((rege94 & 0x03FF0000) >> 16) != 0x142) && (((rege9c & 0x03FF0000) >> 16) != 0x42)) result |= 0x01; @@ -1687,7 +1687,7 @@ static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb) (((regeac & 0x03FF0000) >> 16) != 0x36)) result |= 0x02; else - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A Rx IQK fail!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A Rx IQK fail!!\n"); return result; } @@ -1708,9 +1708,9 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw, TxOKBit = BIT(31); RxOKBit = BIT(30); } - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK!\n"); /* path-A IQK setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A IQK setting!\n"); rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f); rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f); rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82140307); @@ -1723,7 +1723,7 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw, rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68110000); } /* LO calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "LO calibration setting!\n"); rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); /* path-A PA on */ rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, 0x07000f60); @@ -1731,29 +1731,29 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw, for (i = 0; i < retrycount; i++) { /* One shot, path A LOK & IQK */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("One shot, path A LOK & IQK!\n")); + "One shot, path A LOK & IQK!\n"); rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000); rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); /* delay x ms */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path A LOK & IQK.\n", - IQK_DELAY_TIME)); + "Delay %d ms for One shot, path A LOK & IQK.\n", + IQK_DELAY_TIME); mdelay(IQK_DELAY_TIME * 10); /* Check failed */ regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac); rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe94 = 0x%x\n", rege94)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe94 = 0x%x\n", rege94); rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe9c = 0x%x\n", rege9c)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe9c = 0x%x\n", rege9c); regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regea4)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xea4 = 0x%x\n", regea4); if (!(regeac & TxOKBit) && (((rege94 & 0x03FF0000) >> 16) != 0x142)) { result |= 0x01; } else { /* if Tx not OK, ignore Rx */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A Tx IQK fail!!\n")); + "Path A Tx IQK fail!!\n"); continue; } @@ -1764,7 +1764,7 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw, break; } else { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A Rx IQK fail!!\n")); + "Path A Rx IQK fail!!\n"); } } /* path A PA off */ @@ -1782,27 +1782,26 @@ static u8 _rtl92d_phy_pathb_iqk(struct ieee80211_hw *hw) u32 regeac, regeb4, regebc, regec4, regecc; u8 result = 0; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQK!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B IQK!\n"); /* One shot, path B LOK & IQK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "One shot, path A LOK & IQK!\n"); rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000002); rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000000); /* delay x ms */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path B LOK & IQK.\n", - IQK_DELAY_TIME)); + "Delay %d ms for One shot, path B LOK & IQK\n", IQK_DELAY_TIME); mdelay(IQK_DELAY_TIME); /* Check failed */ regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac); regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regeb4)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeb4 = 0x%x\n", regeb4); regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xebc = 0x%x\n", regebc)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xebc = 0x%x\n", regebc); regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regec4)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xec4 = 0x%x\n", regec4); regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xecc = 0x%x\n", regecc)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xecc = 0x%x\n", regecc); if (!(regeac & BIT(31)) && (((regeb4 & 0x03FF0000) >> 16) != 0x142) && (((regebc & 0x03FF0000) >> 16) != 0x42)) result |= 0x01; @@ -1812,7 +1811,7 @@ static u8 _rtl92d_phy_pathb_iqk(struct ieee80211_hw *hw) (((regecc & 0x03FF0000) >> 16) != 0x36)) result |= 0x02; else - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B Rx IQK fail!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B Rx IQK fail!!\n"); return result; } @@ -1826,9 +1825,9 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw) u8 i; u8 retrycount = 2; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQK!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B IQK!\n"); /* path-A IQK setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A IQK setting!\n"); rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f); rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f); rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82110000); @@ -1841,7 +1840,7 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw) rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68160960); /* LO calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "LO calibration setting!\n"); rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); /* path-B PA on */ @@ -1851,26 +1850,26 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw) for (i = 0; i < retrycount; i++) { /* One shot, path B LOK & IQK */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("One shot, path A LOK & IQK!\n")); + "One shot, path A LOK & IQK!\n"); rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xfa000000); rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); /* delay x ms */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path B LOK & IQK.\n", 10)); + "Delay %d ms for One shot, path B LOK & IQK.\n", 10); mdelay(IQK_DELAY_TIME * 10); /* Check failed */ regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac); regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regeb4)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeb4 = 0x%x\n", regeb4); regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xebc = 0x%x\n", regebc)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xebc = 0x%x\n", regebc); regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regec4)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xec4 = 0x%x\n", regec4); regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xecc = 0x%x\n", regecc)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xecc = 0x%x\n", regecc); if (!(regeac & BIT(31)) && (((regeb4 & 0x03FF0000) >> 16) != 0x142)) result |= 0x01; @@ -1882,7 +1881,7 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw) break; } else { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B Rx IQK fail!!\n")); + "Path B Rx IQK fail!!\n"); } } @@ -1901,7 +1900,7 @@ static void _rtl92d_phy_save_adda_registers(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 i; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Save ADDA parameters.\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Save ADDA parameters.\n"); for (i = 0; i < regnum; i++) adda_backup[i] = rtl_get_bbreg(hw, adda_reg[i], BMASKDWORD); } @@ -1912,7 +1911,7 @@ static void _rtl92d_phy_save_mac_registers(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 i; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Save MAC parameters.\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Save MAC parameters.\n"); for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]); macbackup[i] = rtl_read_dword(rtlpriv, macreg[i]); @@ -1926,7 +1925,7 @@ static void _rtl92d_phy_reload_adda_registers(struct ieee80211_hw *hw, u32 i; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Reload ADDA power saving parameters !\n")); + "Reload ADDA power saving parameters !\n"); for (i = 0; i < regnum; i++) rtl_set_bbreg(hw, adda_reg[i], BMASKDWORD, adda_backup[i]); } @@ -1937,7 +1936,7 @@ static void _rtl92d_phy_reload_mac_registers(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 i; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Reload MAC parameters !\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Reload MAC parameters !\n"); for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) rtl_write_byte(rtlpriv, macreg[i], (u8) macbackup[i]); rtl_write_byte(rtlpriv, macreg[i], macbackup[i]); @@ -1950,7 +1949,7 @@ static void _rtl92d_phy_path_adda_on(struct ieee80211_hw *hw, u32 pathon; u32 i; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ADDA ON.\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "ADDA ON.\n"); pathon = patha_on ? 0x04db25a4 : 0x0b1b25a4; if (patha_on) pathon = rtlpriv->rtlhal.interfaceindex == 0 ? @@ -1965,7 +1964,7 @@ static void _rtl92d_phy_mac_setting_calibration(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); u32 i; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("MAC settings for Calibration.\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "MAC settings for Calibration.\n"); rtl_write_byte(rtlpriv, macreg[0], 0x3F); for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) @@ -1977,7 +1976,7 @@ static void _rtl92d_phy_mac_setting_calibration(struct ieee80211_hw *hw, static void _rtl92d_phy_patha_standby(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A standby mode!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A standby mode!\n"); rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x0); rtl_set_bbreg(hw, RFPGA0_XA_LSSIPARAMETER, BMASKDWORD, 0x00010000); @@ -1990,7 +1989,7 @@ static void _rtl92d_phy_pimode_switch(struct ieee80211_hw *hw, bool pi_mode) u32 mode; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("BB Switch to %s mode!\n", (pi_mode ? "PI" : "SI"))); + "BB Switch to %s mode!\n", pi_mode ? "PI" : "SI"); mode = pi_mode ? 0x01000100 : 0x01000000; rtl_set_bbreg(hw, 0x820, BMASKDWORD, mode); rtl_set_bbreg(hw, 0x828, BMASKDWORD, mode); @@ -2022,12 +2021,12 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], const u32 retrycount = 2; u32 bbvalue; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK for 2.4G :Start!!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK for 2.4G :Start!!!\n"); if (t == 0) { bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("==>0x%08x\n", bbvalue)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQ Calibration for %s\n", - (is2t ? "2T2R" : "1T1R"))); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "==>0x%08x\n", bbvalue); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQ Calibration for %s\n", + is2t ? "2T2R" : "1T1R"); /* Save ADDA parameters, turn Path A ADDA on */ _rtl92d_phy_save_adda_registers(hw, adda_reg, @@ -2065,7 +2064,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], if (is2t) rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000); /* IQ calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK setting!\n"); rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x01007c00); rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800); @@ -2073,7 +2072,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], patha_ok = _rtl92d_phy_patha_iqk(hw, is2t); if (patha_ok == 0x03) { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQK Success!!\n")); + "Path A IQK Success!!\n"); result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 0x3FF0000) >> 16; result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & @@ -2086,7 +2085,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], } else if (i == (retrycount - 1) && patha_ok == 0x01) { /* Tx IQK OK */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQK Only Tx Success!!\n")); + "Path A IQK Only Tx Success!!\n"); result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 0x3FF0000) >> 16; @@ -2095,7 +2094,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], } } if (0x00 == patha_ok) - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK failed!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK failed!!\n"); if (is2t) { _rtl92d_phy_patha_standby(hw); /* Turn Path B ADDA on */ @@ -2104,7 +2103,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], pathb_ok = _rtl92d_phy_pathb_iqk(hw); if (pathb_ok == 0x03) { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK Success!!\n")); + "Path B IQK Success!!\n"); result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & 0x3FF0000) >> 16; result[t][5] = (rtl_get_bbreg(hw, 0xebc, @@ -2117,7 +2116,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], } else if (i == (retrycount - 1) && pathb_ok == 0x01) { /* Tx IQK OK */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B Only Tx IQK Success!!\n")); + "Path B Only Tx IQK Success!!\n"); result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & 0x3FF0000) >> 16; result[t][5] = (rtl_get_bbreg(hw, 0xebc, @@ -2126,12 +2125,12 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], } if (0x00 == pathb_ok) RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK failed!!\n")); + "Path B IQK failed!!\n"); } /* Back to BB mode, load original value */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK:Back to BB mode, load original value!\n")); + "IQK:Back to BB mode, load original value!\n"); rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0); if (t != 0) { @@ -2156,7 +2155,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x01008c00); rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x01008c00); } - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("<==\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "<==\n"); } static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, @@ -2188,13 +2187,13 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, /* Note: IQ calibration must be performed after loading * PHY_REG.txt , and radio_a, radio_b.txt */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK for 5G NORMAL:Start!!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK for 5G NORMAL:Start!!!\n"); mdelay(IQK_DELAY_TIME * 20); if (t == 0) { bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("==>0x%08x\n", bbvalue)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQ Calibration for %s\n", - (is2t ? "2T2R" : "1T1R"))); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "==>0x%08x\n", bbvalue); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQ Calibration for %s\n", + is2t ? "2T2R" : "1T1R"); /* Save ADDA parameters, turn Path A ADDA on */ _rtl92d_phy_save_adda_registers(hw, adda_reg, rtlphy->adda_backup, @@ -2231,13 +2230,13 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, if (is2t) rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000); /* IQ calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK setting!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK setting!\n"); rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x10007c00); rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800); patha_ok = _rtl92d_phy_patha_iqk_5g_normal(hw, is2t); if (patha_ok == 0x03) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK Success!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK Success!!\n"); result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 0x3FF0000) >> 16; result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & @@ -2248,14 +2247,14 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, 0x3FF0000) >> 16; } else if (patha_ok == 0x01) { /* Tx IQK OK */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQK Only Tx Success!!\n")); + "Path A IQK Only Tx Success!!\n"); result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 0x3FF0000) >> 16; result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & 0x3FF0000) >> 16; } else { - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK Fail!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK Fail!!\n"); } if (is2t) { /* _rtl92d_phy_patha_standby(hw); */ @@ -2264,7 +2263,7 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, pathb_ok = _rtl92d_phy_pathb_iqk_5g_normal(hw); if (pathb_ok == 0x03) { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK Success!!\n")); + "Path B IQK Success!!\n"); result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & 0x3FF0000) >> 16; result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) & @@ -2275,20 +2274,20 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, 0x3FF0000) >> 16; } else if (pathb_ok == 0x01) { /* Tx IQK OK */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B Only Tx IQK Success!!\n")); + "Path B Only Tx IQK Success!!\n"); result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & 0x3FF0000) >> 16; result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) & 0x3FF0000) >> 16; } else { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK failed!!\n")); + "Path B IQK failed!!\n"); } } /* Back to BB mode, load original value */ RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK:Back to BB mode, load original value!\n")); + "IQK:Back to BB mode, load original value!\n"); rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0); if (t != 0) { if (is2t) @@ -2310,7 +2309,7 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, rtlphy->adda_backup, IQK_ADDA_REG_NUM); } - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("<==\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "<==\n"); } static bool _rtl92d_phy_simularity_compare(struct ieee80211_hw *hw, @@ -2384,8 +2383,7 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw, rtlhal->macphymode == DUALMAC_DUALPHY; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQ Calibration %s !\n", - (iqk_ok) ? "Success" : "Failed")); + "Path A IQ Calibration %s !\n", iqk_ok ? "Success" : "Failed"); if (final_candidate == 0xFF) { return; } else if (iqk_ok) { @@ -2395,8 +2393,9 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw, if ((val_x & 0x00000200) != 0) val_x = val_x | 0xFFFFFC00; tx0_a = (val_x * oldval_0) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("X = 0x%x, tx0_a = 0x%x," - " oldval_0 0x%x\n", val_x, tx0_a, oldval_0)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, + "X = 0x%x, tx0_a = 0x%x, oldval_0 0x%x\n", + val_x, tx0_a, oldval_0); rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x3FF, tx0_a); rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24), ((val_x * oldval_0 >> 7) & 0x1)); @@ -2408,8 +2407,9 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw, rtlhal->current_bandtype == BAND_ON_5G) val_y += 3; tx0_c = (val_y * oldval_0) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Y = 0x%lx, tx0_c = 0x%lx\n", - val_y, tx0_c)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, + "Y = 0x%lx, tx0_c = 0x%lx\n", + val_y, tx0_c); rtl_set_bbreg(hw, ROFDM0_XCTxAFE, 0xF0000000, ((tx0_c & 0x3C0) >> 6)); rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x003F0000, @@ -2417,11 +2417,11 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw, if (is2t) rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(26), ((val_y * oldval_0 >> 7) & 0x1)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xC80 = 0x%x\n", - rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE, - BMASKDWORD))); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xC80 = 0x%x\n", + rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE, + BMASKDWORD)); if (txonly) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("only Tx OK\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "only Tx OK\n"); return; } reg = result[final_candidate][2]; @@ -2441,8 +2441,8 @@ static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw, u32 oldval_1, val_x, tx1_a, reg; long val_y, tx1_c; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQ Calibration %s !\n", - (iqk_ok) ? "Success" : "Failed")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B IQ Calibration %s !\n", + iqk_ok ? "Success" : "Failed"); if (final_candidate == 0xFF) { return; } else if (iqk_ok) { @@ -2452,8 +2452,8 @@ static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw, if ((val_x & 0x00000200) != 0) val_x = val_x | 0xFFFFFC00; tx1_a = (val_x * oldval_1) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("X = 0x%x, tx1_a = 0x%x\n", - val_x, tx1_a)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "X = 0x%x, tx1_a = 0x%x\n", + val_x, tx1_a); rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x3FF, tx1_a); rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(28), ((val_x * oldval_1 >> 7) & 0x1)); @@ -2463,8 +2463,8 @@ static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw, if (rtlhal->current_bandtype == BAND_ON_5G) val_y += 3; tx1_c = (val_y * oldval_1) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Y = 0x%lx, tx1_c = 0x%lx\n", - val_y, tx1_c)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "Y = 0x%lx, tx1_c = 0x%lx\n", + val_y, tx1_c); rtl_set_bbreg(hw, ROFDM0_XDTxAFE, 0xF0000000, ((tx1_c & 0x3C0) >> 6)); rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x003F0000, @@ -2496,7 +2496,7 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw) unsigned long flag = 0; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK:Start!!!channel %d\n", rtlphy->current_channel)); + "IQK:Start!!!channel %d\n", rtlphy->current_channel); for (i = 0; i < 8; i++) { result[0][i] = 0; result[1][i] = 0; @@ -2510,7 +2510,7 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw) is23simular = false; is13simular = false; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK !!!currentband %d\n", rtlhal->current_bandtype)); + "IQK !!!currentband %d\n", rtlhal->current_bandtype); rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); for (i = 0; i < 3; i++) { if (rtlhal->current_bandtype == BAND_ON_5G) { @@ -2562,10 +2562,9 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw) regec4 = result[i][6]; regecc = result[i][7]; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx " - "regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n ", + "IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n", rege94, rege9c, regea4, regeac, regeb4, regebc, regec4, - regecc)); + regecc); } if (final_candidate != 0xff) { rtlphy->reg_e94 = rege94 = result[final_candidate][0]; @@ -2577,12 +2576,11 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw) regec4 = result[final_candidate][6]; regecc = result[final_candidate][7]; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK: final_candidate is %x\n", final_candidate)); + "IQK: final_candidate is %x\n", final_candidate); RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx " - "regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n ", + "IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n", rege94, rege9c, regea4, regeac, regeb4, regebc, regec4, - regecc)); + regecc); patha_ok = pathb_ok = true; } else { rtlphy->reg_e94 = rtlphy->reg_eb4 = 0x100; /* X default value */ @@ -2716,8 +2714,8 @@ static void _rtl92d_phy_calc_curvindex(struct ieee80211_hw *hw, } } smallest_abs_val = 0xffffffff; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("curveindex[%d] = %x\n", i, - curveindex[i])); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "curveindex[%d] = %x\n", + i, curveindex[i]); } } @@ -2733,13 +2731,13 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw, bool bneed_powerdown_radio = false; RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "path %d\n", erfpath); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("band type = %d\n", - rtlpriv->rtlhal.current_bandtype)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("channel = %d\n", channel)); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "band type = %d\n", + rtlpriv->rtlhal.current_bandtype); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "channel = %d\n", channel); if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) {/* Path-A for 5G */ u4tmp = curveindex_5g[channel-1]; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("ver 1 set RF-A, 5G, 0x28 = 0x%ulx !!\n", u4tmp)); + "ver 1 set RF-A, 5G, 0x28 = 0x%ulx !!\n", u4tmp); if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY && rtlpriv->rtlhal.interfaceindex == 1) { bneed_powerdown_radio = @@ -2758,7 +2756,7 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw, } else if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) { u4tmp = curveindex_2g[channel-1]; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", u4tmp)); + "ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", u4tmp); if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY && rtlpriv->rtlhal.interfaceindex == 0) { bneed_powerdown_radio = @@ -2770,8 +2768,8 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw, } rtl_set_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800, u4tmp); RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", - rtl_get_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800))); + "ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", + rtl_get_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800)); if (bneed_powerdown_radio) _rtl92d_phy_restore_rf_env(hw, erfpath, &u4regvalue); if (rtlpriv->rtlhal.during_mac0init_radiob) @@ -2825,20 +2823,20 @@ static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t) RF_SYN_G6, BRFREGOFFSETMASK); } RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("PHY_LCK finish delay for %d ms=2\n", timecount)); + "PHY_LCK finish delay for %d ms=2\n", timecount); u4tmp = rtl_get_rfreg(hw, index, RF_SYN_G4, BRFREGOFFSETMASK); if (index == 0 && rtlhal->interfaceindex == 0) { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("path-A / 5G LCK\n")); + "path-A / 5G LCK\n"); } else { RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("path-B / 2.4G LCK\n")); + "path-B / 2.4G LCK\n"); } memset(&curvecount_val[0], 0, CV_CURVE_CNT * 2); /* Set LC calibration off */ rtl_set_rfreg(hw, (enum radio_path)index, RF_CHNLBW, 0x08000, 0x0); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("set RF 0x18[15] = 0\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "set RF 0x18[15] = 0\n"); /* save Curve-counting number */ for (i = 0; i < CV_CURVE_CNT; i++) { u32 readval = 0, readval2 = 0; @@ -2888,7 +2886,7 @@ static void _rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) { struct rtl_priv *rtlpriv = rtl_priv(hw); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("cosa PHY_LCK ver=2\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "cosa PHY_LCK ver=2\n"); _rtl92d_phy_lc_calibrate_sw(hw, is2t); } @@ -2906,8 +2904,8 @@ void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw) rtlphy->lck_inprogress = true; RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("LCK:Start!!! currentband %x delay %d ms\n", - rtlhal->current_bandtype, timecount)); + "LCK:Start!!! currentband %x delay %d ms\n", + rtlhal->current_bandtype, timecount); if (IS_92D_SINGLEPHY(rtlhal->version)) { _rtl92d_phy_lc_calibrate(hw, true); } else { @@ -2915,7 +2913,7 @@ void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw) _rtl92d_phy_lc_calibrate(hw, false); } rtlphy->lck_inprogress = false; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LCK:Finish!!!\n")); + RTPRINT(rtlpriv, FINIT, INIT_IQK, "LCK:Finish!!!\n"); } void rtl92d_phy_ap_calibrate(struct ieee80211_hw *hw, char delta) diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c index 3bf21c2cf085..2e174f48946b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c @@ -127,23 +127,23 @@ void rtl92d_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, tmpval = tx_agc[RF90_PATH_A] & 0xff; rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, BMASKBYTE1, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_A_CCK1_MCS32)); + "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_A_CCK1_MCS32); tmpval = tx_agc[RF90_PATH_A] >> 8; rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); + "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK11_A_CCK2_11); tmpval = tx_agc[RF90_PATH_B] >> 24; rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, BMASKBYTE0, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); + "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK11_A_CCK2_11); tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK1_55_MCS32)); + "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", + tmpval, RTXAGC_B_CCK1_55_MCS32); } static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw, @@ -165,8 +165,8 @@ static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw, (powerbase0 << 8) | powerbase0; *(ofdmbase + i) = powerbase0; RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [OFDM power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); + " [OFDM power base index rf(%c) = 0x%x]\n", + i == 0 ? 'A' : 'B', *(ofdmbase + i)); } for (i = 0; i < 2; i++) { @@ -179,8 +179,8 @@ static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw, (powerbase1 << 8) | powerbase1; *(mcsbase + i) = powerbase1; RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [MCS power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); + " [MCS power base index rf(%c) = 0x%x]\n", + i == 0 ? 'A' : 'B', *(mcsbase + i)); } } @@ -232,9 +232,9 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, (rf ? 8 : 0)] + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("RTK better " - "performance, writeval(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); + RTPRINT(rtlpriv, FPHY, PHY_TXPWR, + "RTK better performance, writeval(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeval); break; case 1: if (rtlphy->pwrgroup_cnt == 1) @@ -253,33 +253,31 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, powerbase0[rf] : powerbase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Realtek regulatory, " - "20MHz, writeval(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), - writeval)); + "Realtek regulatory, 20MHz, writeval(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeval); } break; case 2: writeval = ((index < 2) ? powerbase0[rf] : powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("Better regulatory, " - "writeval(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); + RTPRINT(rtlpriv, FPHY, PHY_TXPWR, + "Better regulatory, writeval(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeval); break; case 3: chnlgroup = 0; if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 40MHz rf(%c) = " - "0x%x\n", ((rf == 0) ? 'A' : 'B'), + "customer's limit, 40MHz rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', rtlefuse->pwrgroup_ht40[rf] - [channel - 1])); + [channel - 1]); } else { RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 20MHz rf(%c) = " - "0x%x\n", ((rf == 0) ? 'A' : 'B'), + "customer's limit, 20MHz rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', rtlefuse->pwrgroup_ht20[rf] - [channel - 1])); + [channel - 1]); } for (i = 0; i < 4; i++) { pwr_diff_limit[i] = @@ -308,13 +306,13 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer's limit rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), customer_limit)); + "Customer's limit rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', customer_limit); writeval = customer_limit + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer, writeval rf(%c)= 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); + "Customer, writeval rf(%c)= 0x%x\n", + rf == 0 ? 'A' : 'B', writeval); break; default: chnlgroup = 0; @@ -323,9 +321,8 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, (rf ? 8 : 0)] + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("RTK better performance, writeval " - "rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); + "RTK better performance, writeval rf(%c) = 0x%x\n", + rf == 0 ? 'A' : 'B', writeval); break; } *(p_outwriteval + rf) = writeval; @@ -367,7 +364,7 @@ static void _rtl92d_write_ofdm_power_reg(struct ieee80211_hw *hw, regoffset = regoffset_b[index]; rtl_set_bbreg(hw, regoffset, BMASKDWORD, writeval); RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Set 0x%x = %08x\n", regoffset, writeval)); + "Set 0x%x = %08x\n", regoffset, writeval); if (((get_rf_type(rtlphy) == RF_2T2R) && (regoffset == RTXAGC_A_MCS15_MCS12 || regoffset == RTXAGC_B_MCS15_MCS12)) || diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index dffcafe01a39..acab8781cc7e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -1704,23 +1704,24 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path, - i, rtlefuse->eeprom_chnlarea_txpwr_cck - [rf_path][i])); + "RF(%d) EEPROM CCK Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse->eeprom_chnlarea_txpwr_cck + [rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", - rf_path, i, - rtlefuse->eeprom_chnlarea_txpwr_ht40_1s - [rf_path][i])); + "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse->eeprom_chnlarea_txpwr_ht40_1s + [rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++) RTPRINT(rtlpriv, FINIT, INIT_EEPROM, - ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", - rf_path, i, - rtlefuse->eeprom_chnlarea_txpwr_ht40_2sdiif - [rf_path][i])); + "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", + rf_path, i, + rtlefuse->eeprom_chnlarea_txpwr_ht40_2sdiif + [rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) { @@ -1751,11 +1752,11 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) for (i = 0; i < 14; i++) { RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = " - "[0x%x / 0x%x / 0x%x]\n", rf_path, i, - rtlefuse->txpwrlevel_cck[rf_path][i], - rtlefuse->txpwrlevel_ht40_1s[rf_path][i], - rtlefuse->txpwrlevel_ht40_2s[rf_path][i])); + "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n", + rf_path, i, + rtlefuse->txpwrlevel_cck[rf_path][i], + rtlefuse->txpwrlevel_ht40_1s[rf_path][i], + rtlefuse->txpwrlevel_ht40_2s[rf_path][i]); } } @@ -1788,13 +1789,13 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) 0xf0) >> 4); RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-%d pwrgroup_ht20[%d] = 0x%x\n", - rf_path, i, - rtlefuse->pwrgroup_ht20[rf_path][i])); + "RF-%d pwrgroup_ht20[%d] = 0x%x\n", + rf_path, i, + rtlefuse->pwrgroup_ht20[rf_path][i]); RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-%d pwrgroup_ht40[%d] = 0x%x\n", - rf_path, i, - rtlefuse->pwrgroup_ht40[rf_path][i])); + "RF-%d pwrgroup_ht40[%d] = 0x%x\n", + rf_path, i, + rtlefuse->pwrgroup_ht40[rf_path][i]); } } @@ -1849,27 +1850,27 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) (hwinfo[EEPROM_REGULATORY] & 0x1); } RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); + "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_ht20diff[RF90_PATH_A][i])); + "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i])); + "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_ht20diff[RF90_PATH_B][i])); + "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]); for (i = 0; i < 14; i++) RTPRINT(rtlpriv, FINIT, INIT_TxPower, - ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, - rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i])); + "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", + i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]); - RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("TxPwrSafetyFlag = %d\n", - rtlefuse->txpwr_safetyflag)); + RTPRINT(rtlpriv, FINIT, INIT_TxPower, + "TxPwrSafetyFlag = %d\n", rtlefuse->txpwr_safetyflag); /* Read RF-indication and Tx Power gain * index diff of legacy to HT OFDM rate. */ @@ -1878,8 +1879,8 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->legacy_httxpowerdiff = rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][0]; - RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("TxPowerDiff = %#x\n", - rtlefuse->eeprom_txpowerdiff)); + RTPRINT(rtlpriv, FINIT, INIT_TxPower, + "TxPowerDiff = %#x\n", rtlefuse->eeprom_txpowerdiff); /* Get TSSI value for each path. */ usvalue = *(u16 *)&hwinfo[EEPROM_TSSI_A]; @@ -1887,16 +1888,16 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) usvalue = *(u8 *)&hwinfo[EEPROM_TSSI_B]; rtlefuse->eeprom_tssi[RF90_PATH_B] = (u8)(usvalue & 0xff); - RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("TSSI_A = 0x%x, TSSI_B = 0x%x\n", - rtlefuse->eeprom_tssi[RF90_PATH_A], - rtlefuse->eeprom_tssi[RF90_PATH_B])); + RTPRINT(rtlpriv, FINIT, INIT_TxPower, "TSSI_A = 0x%x, TSSI_B = 0x%x\n", + rtlefuse->eeprom_tssi[RF90_PATH_A], + rtlefuse->eeprom_tssi[RF90_PATH_B]); /* Read antenna tx power offset of B/C/D to A from EEPROM */ /* and read ThermalMeter from EEPROM */ tempval = *(u8 *)&hwinfo[EEPROM_THERMALMETER]; rtlefuse->eeprom_thermalmeter = tempval; - RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("thermalmeter = 0x%x\n", - rtlefuse->eeprom_thermalmeter)); + RTPRINT(rtlpriv, FINIT, INIT_TxPower, + "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter); /* ThermalMeter, BIT(0)~3 for RFIC1, BIT(4)~7 for RFIC2 */ rtlefuse->thermalmeter[0] = (rtlefuse->eeprom_thermalmeter & 0x1f); @@ -1912,8 +1913,8 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) /* Version ID, Channel plan */ rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; rtlefuse->txpwr_fromeprom = true; - RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("EEPROM ChannelPlan = 0x%4x\n", - rtlefuse->eeprom_channelplan)); + RTPRINT(rtlpriv, FINIT, INIT_TxPower, + "EEPROM ChannelPlan = 0x%4x\n", rtlefuse->eeprom_channelplan); /* Read Customer ID or Board Type!!! */ tempval = *(u8 *)&hwinfo[EEPROM_BOARDTYPE]; -- GitLab From 9d833ed752e91c71792dd8ebfd0f865e6a568a37 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:43 -0800 Subject: [PATCH 0077/1846] rtlwifi: Convert RT_ASSERT macro to use ##__VA_ARGS__ Consolidate printks to avoid possible message interleaving and reduce the object size. Remove unnecessary RT_ASSERT parentheses. Align arguments. Coalesce formats. Remove unnecessary __func__ use as the macro uses it. $ size drivers/net/wireless/rtlwifi/built-in.o* text data bss dec hex filename 588901 55333 127216 771450 bc57a drivers/net/wireless/rtlwifi/built-in.o.new 590002 55333 127560 772895 bcb1f drivers/net/wireless/rtlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/core.c | 4 ++-- drivers/net/wireless/rtlwifi/debug.h | 7 +++---- drivers/net/wireless/rtlwifi/pci.c | 15 +++++++-------- .../net/wireless/rtlwifi/rtl8192c/fw_common.c | 6 +++--- .../net/wireless/rtlwifi/rtl8192c/phy_common.c | 10 +++++----- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 16 ++++++++-------- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 5 +++-- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 4 ++-- drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 6 +++--- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 13 ++++++------- drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 16 ++++++++-------- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 4 ++-- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 16 ++++++++-------- drivers/net/wireless/rtlwifi/usb.c | 2 +- 21 files changed, 68 insertions(+), 70 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index 186c944c1436..ab6a4068764f 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c @@ -1026,8 +1026,8 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "set pairwise key\n"); if (!sta) { - RT_ASSERT(false, ("pairwise key withnot" - "mac_addr\n")); + RT_ASSERT(false, + "pairwise key without mac_addr\n"); err = -EOPNOTSUPP; goto out_unlock; diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index 8b51a828effa..74b6780880f2 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -156,12 +156,11 @@ enum dbgp_flag_e { DBGP_TYPE_MAX }; -#define RT_ASSERT(_exp, fmt) \ +#define RT_ASSERT(_exp, fmt, ...) \ do { \ if (!(_exp)) { \ - printk(KERN_DEBUG "%s:%s(): ", \ - KBUILD_MODNAME, __func__); \ - printk fmt; \ + printk(KERN_DEBUG KBUILD_MODNAME ":%s(): " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } while (0) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index b52fef235754..3c4ae5d9de4f 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1746,16 +1746,15 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, err = pci_enable_device(pdev); if (err) { - RT_ASSERT(false, - ("%s : Cannot enable new PCI device\n", - pci_name(pdev))); + RT_ASSERT(false, "%s : Cannot enable new PCI device\n", + pci_name(pdev)); return err; } if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { - RT_ASSERT(false, ("Unable to obtain 32bit DMA " - "for consistent allocations\n")); + RT_ASSERT(false, + "Unable to obtain 32bit DMA for consistent allocations\n"); pci_disable_device(pdev); return -ENOMEM; } @@ -1767,7 +1766,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, sizeof(struct rtl_priv), &rtl_ops); if (!hw) { RT_ASSERT(false, - ("%s : ieee80211 alloc failed\n", pci_name(pdev))); + "%s : ieee80211 alloc failed\n", pci_name(pdev)); err = -ENOMEM; goto fail1; } @@ -1797,7 +1796,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, /* MEM map */ err = pci_request_regions(pdev, KBUILD_MODNAME); if (err) { - RT_ASSERT(false, ("Can't obtain PCI resources\n")); + RT_ASSERT(false, "Can't obtain PCI resources\n"); return err; } @@ -1810,7 +1809,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, (unsigned long)pci_iomap(pdev, rtlpriv->cfg->bar_id, pmem_len); if (rtlpriv->io.pci_mem_start == 0) { - RT_ASSERT(false, ("Can't map PCI mem\n")); + RT_ASSERT(false, "Can't map PCI mem\n"); goto fail2; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 12c025bf53b2..1eae3baae518 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -519,8 +519,8 @@ void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, u32 tmp_cmdbuf[2]; if (rtlhal->fw_ready == false) { - RT_ASSERT(false, ("return H2C cmd because of Fw " - "download fail!!!\n")); + RT_ASSERT(false, + "return H2C cmd because of Fw download fail!!!\n"); return; } @@ -544,7 +544,7 @@ void rtl92c_firmware_selfreset(struct ieee80211_hw *hw) while (u1b_tmp & BIT(2)) { delay--; if (delay == 0) { - RT_ASSERT(false, ("8051 reset fail.\n")); + RT_ASSERT(false, "8051 reset fail\n"); break; } udelay(50); diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index 8ab93a69f334..25bde968699d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -85,7 +85,7 @@ EXPORT_SYMBOL(rtl92c_phy_set_bb_reg); u32 _rtl92c_phy_fw_rf_serial_read(struct ieee80211_hw *hw, enum radio_path rfpath, u32 offset) { - RT_ASSERT(false, ("deprecated!\n")); + RT_ASSERT(false, "deprecated!\n"); return 0; } @@ -95,7 +95,7 @@ void _rtl92c_phy_fw_rf_serial_write(struct ieee80211_hw *hw, enum radio_path rfpath, u32 offset, u32 data) { - RT_ASSERT(false, ("deprecated!\n")); + RT_ASSERT(false, "deprecated!\n"); } EXPORT_SYMBOL(_rtl92c_phy_fw_rf_serial_write); @@ -776,7 +776,7 @@ u8 rtl92c_phy_sw_chnl(struct ieee80211_hw *hw) if (rtlphy->set_bwmode_inprogress) return 0; RT_ASSERT((rtlphy->current_channel <= 14), - ("WIRELESS_MODE_G but channel>14")); + "WIRELESS_MODE_G but channel>14\n"); rtlphy->sw_chnl_inprogress = true; rtlphy->sw_chnl_stage = 0; rtlphy->sw_chnl_step = 0; @@ -802,7 +802,7 @@ static bool _rtl92c_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, struct swchnlcmd *pcmd; if (cmdtable == NULL) { - RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); + RT_ASSERT(false, "cmdtable cannot be NULL\n"); return false; } @@ -848,7 +848,7 @@ bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, rfdependcmdcnt = 0; RT_ASSERT((channel >= 1 && channel <= 14), - ("illegal channel for Zebra: %d\n", channel)); + "invalid channel for Zebra: %d\n", channel); _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG, diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 2d01673a2087..18f615c41212 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -1166,7 +1166,7 @@ void rtl92ce_set_qos(struct ieee80211_hw *hw, int aci) rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); break; default: - RT_ASSERT(false, ("invalid aci: %d !\n", aci)); + RT_ASSERT(false, "invalid aci: %d !\n", aci); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index d2a3576fdaa5..4a224dbc693d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c @@ -404,7 +404,7 @@ static int __init rtl92ce_module_init(void) ret = pci_register_driver(&rtl92ce_driver); if (ret) - RT_ASSERT(false, (": No device found\n")); + RT_ASSERT(false, "No device found\n"); return ret; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c index 9f6fac450a48..46892cc1a08d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c @@ -836,8 +836,8 @@ void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); break; default: - RT_ASSERT(false, ("ERR txdesc :%d" - " not process\n", desc_name)); + RT_ASSERT(false, "ERR txdesc :%d not process\n", + desc_name); break; } } else { @@ -856,8 +856,8 @@ void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) SET_RX_DESC_EOR(pdesc, 1); break; default: - RT_ASSERT(false, ("ERR rxdesc :%d " - "not process\n", desc_name)); + RT_ASSERT(false, "ERR rxdesc :%d not process\n", + desc_name); break; } } @@ -876,8 +876,8 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name) ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc); break; default: - RT_ASSERT(false, ("ERR txdesc :%d " - "not process\n", desc_name)); + RT_ASSERT(false, "ERR txdesc :%d not process\n", + desc_name); break; } } else { @@ -890,8 +890,8 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name) ret = GET_RX_DESC_PKT_LEN(pdesc); break; default: - RT_ASSERT(false, ("ERR rxdesc :%d " - "not process\n", desc_name)); + RT_ASSERT(false, "ERR rxdesc :%d not process\n", + desc_name); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index de1542f14856..ae38bc52a716 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -1984,8 +1984,9 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) u4b_ac_param); break; default: - RT_ASSERT(false, ("SetHwReg8185(): invalid" - " aci: %d !\n", e_aci)); + RT_ASSERT(false, + "SetHwReg8185(): invalid aci: %d !\n", + e_aci); break; } if (rtlusb->acm_method != eAcmWay2_SW) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 9f09844d7d50..943f3d49d1f2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -428,7 +428,7 @@ void rtl92c_set_qos(struct ieee80211_hw *hw, int aci) rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, u4b_ac_param); break; default: - RT_ASSERT(false, ("invalid aci: %d !\n", aci)); + RT_ASSERT(false, "invalid aci: %d !\n", aci); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index b875af75b893..aca0fd5d1165 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -244,8 +244,8 @@ u16 rtl8192cu_mq_to_hwq(__le16 fc, u16 mac80211_queue_index) break; default: hw_queue_index = RTL_TXQ_BE; - RT_ASSERT(false, ("QSLT_BE queue, skb_queue:%d\n", - mac80211_queue_index)); + RT_ASSERT(false, "QSLT_BE queue, skb_queue:%d\n", + mac80211_queue_index); break; } out: diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c index b84f10d60c0d..94f5b7dd06ed 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c @@ -186,7 +186,7 @@ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw) udelay(50); u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); } - RT_ASSERT((delay > 0), ("8051 reset failed!\n")); + RT_ASSERT((delay > 0), "8051 reset failed!\n"); RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, "=====> 8051 reset success (%d)\n", delay); } @@ -536,8 +536,8 @@ void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u32 tmp_cmdbuf[2]; if (rtlhal->fw_ready == false) { - RT_ASSERT(false, ("return H2C cmd because of Fw " - "download fail!!!\n")); + RT_ASSERT(false, + "return H2C cmd because of Fw download fail!!!\n"); return; } memset(tmp_cmdbuf, 0, 8); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index 5eecf403a5c3..d94ce371572f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -1213,7 +1213,7 @@ void rtl92de_set_qos(struct ieee80211_hw *hw, int aci) rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); break; default: - RT_ASSERT(false, ("invalid aci: %d !\n", aci)); + RT_ASSERT(false, "invalid aci: %d !\n", aci); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index c736b9334888..f27acc754944 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -2928,7 +2928,7 @@ static bool _rtl92d_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, struct swchnlcmd *pcmd; if (cmdtable == NULL) { - RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); + RT_ASSERT(false, "cmdtable cannot be NULL\n"); return false; } if (cmdtableidx >= cmdtablesz) @@ -3120,19 +3120,18 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw) * 5G and 2.4G band. */ if (channel <= 14) return 0; - RT_ASSERT((channel > 14), ("5G but channel<=14")); + RT_ASSERT((channel > 14), "5G but channel<=14\n"); break; case BAND_ON_2_4G: /* Get first channel error when change between * 5G and 2.4G band. */ if (channel > 14) return 0; - RT_ASSERT((channel <= 14), ("2G but channel>14")); + RT_ASSERT((channel <= 14), "2G but channel>14\n"); break; default: - RT_ASSERT(false, - ("Invalid WirelessMode(%#x)!!\n", - rtlpriv->mac80211.mode)); + RT_ASSERT(false, "Invalid WirelessMode(%#x)!!\n", + rtlpriv->mac80211.mode); break; } rtlphy->sw_chnl_inprogress = true; @@ -3563,7 +3562,7 @@ void rtl92d_phy_set_poweron(struct ieee80211_hw *hw) } } if (i == 200) - RT_ASSERT(false, ("Another mac power off over time\n")); + RT_ASSERT(false, "Another mac power off over time\n"); } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index db7579684b11..022f06529703 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -424,7 +424,7 @@ static int __init rtl92de_module_init(void) ret = pci_register_driver(&rtl92de_driver); if (ret) - RT_ASSERT(false, (": No device found\n")); + RT_ASSERT(false, "No device found\n"); return ret; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c index f6ec0a12884f..e7c985b372fa 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c @@ -793,8 +793,8 @@ void rtl92de_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); break; default: - RT_ASSERT(false, ("ERR txdesc :%d" - " not process\n", desc_name)); + RT_ASSERT(false, "ERR txdesc :%d not process\n", + desc_name); break; } } else { @@ -813,8 +813,8 @@ void rtl92de_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) SET_RX_DESC_EOR(pdesc, 1); break; default: - RT_ASSERT(false, ("ERR rxdesc :%d " - "not process\n", desc_name)); + RT_ASSERT(false, "ERR rxdesc :%d not process\n", + desc_name); break; } } @@ -833,8 +833,8 @@ u32 rtl92de_get_desc(u8 *p_desc, bool istx, u8 desc_name) ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc); break; default: - RT_ASSERT(false, ("ERR txdesc :%d " - "not process\n", desc_name)); + RT_ASSERT(false, "ERR txdesc :%d not process\n", + desc_name); break; } } else { @@ -847,8 +847,8 @@ u32 rtl92de_get_desc(u8 *p_desc, bool istx, u8 desc_name) ret = GET_RX_DESC_PKT_LEN(pdesc); break; default: - RT_ASSERT(false, ("ERR rxdesc :%d " - "not process\n", desc_name)); + RT_ASSERT(false, "ERR rxdesc :%d not process\n", + desc_name); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index acab8781cc7e..b03001b23288 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -1200,7 +1200,7 @@ void rtl92se_set_qos(struct ieee80211_hw *hw, int aci) rtl_write_dword(rtlpriv, EDCAPARA_VO, 0x2f3222); break; default: - RT_ASSERT(false, ("invalid aci: %d !\n", aci)); + RT_ASSERT(false, "invalid aci: %d !\n", aci); break; } } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index ec5520e68472..e24dbb3a9ba4 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -335,7 +335,7 @@ static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, struct swchnlcmd *pcmd; if (cmdtable == NULL) { - RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); + RT_ASSERT(false, "cmdtable cannot be NULL\n"); return false; } @@ -380,7 +380,7 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, rfdependcmdcnt = 0; RT_ASSERT((channel >= 1 && channel <= 14), - ("illegal channel for Zebra: %d\n", channel)); + "invalid channel for Zebra: %d\n", channel); _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG, diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index bc4b6fa4fc85..a933aef3d1ac 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -426,7 +426,7 @@ static int __init rtl92se_module_init(void) ret = pci_register_driver(&rtl92se_driver); if (ret) - RT_ASSERT(false, (": No device found\n")); + RT_ASSERT(false, "No device found\n"); return ret; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c index 1f266d1d7951..216a3e140de8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c @@ -823,8 +823,8 @@ void rtl92se_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); break; default: - RT_ASSERT(false, ("ERR txdesc :%d not process\n", - desc_name)); + RT_ASSERT(false, "ERR txdesc :%d not process\n", + desc_name); break; } } else { @@ -843,8 +843,8 @@ void rtl92se_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) SET_RX_STATUS_DESC_EOR(pdesc, 1); break; default: - RT_ASSERT(false, ("ERR rxdesc :%d not process\n", - desc_name)); + RT_ASSERT(false, "ERR rxdesc :%d not process\n", + desc_name); break; } } @@ -863,8 +863,8 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name) ret = GET_TX_DESC_TX_BUFFER_ADDRESS(desc); break; default: - RT_ASSERT(false, ("ERR txdesc :%d not process\n", - desc_name)); + RT_ASSERT(false, "ERR txdesc :%d not process\n", + desc_name); break; } } else { @@ -876,8 +876,8 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name) ret = GET_RX_STATUS_DESC_PKT_LEN(desc); break; default: - RT_ASSERT(false, ("ERR rxdesc :%d not process\n", - desc_name)); + RT_ASSERT(false, "ERR rxdesc :%d not process\n", + desc_name); break; } } diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index d670e6886c1f..6ae1b212ad99 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -946,7 +946,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) + sizeof(struct rtl_usb_priv), &rtl_ops); if (!hw) { - RT_ASSERT(false, ("%s : ieee80211 alloc failed\n", __func__)); + RT_ASSERT(false, "ieee80211 alloc failed\n"); return -ENOMEM; } rtlpriv = hw->priv; -- GitLab From 4cd9f40c66e36c59f3a753d5167a89a312f5aa87 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:44 -0800 Subject: [PATCH 0078/1846] rtlwifi: Remove duplicate __func__ The RT_TRACE macro already prepends it. Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index aca0fd5d1165..7d5f79991f8e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -620,7 +620,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw, SET_TX_DESC_BMC(txdesc, 1); _rtl_fill_usb_tx_desc(txdesc); _rtl_tx_desc_checksum(txdesc); - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, " %s ==>\n", __func__); + RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "==>\n"); } void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc, -- GitLab From f56e7eb4dd3124d53a5200ff093bc6bcbae671e9 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 4 Jan 2012 19:40:45 -0800 Subject: [PATCH 0079/1846] rtlwifi: Optimize RT_TRACE macro use of KBUILD_MODNAME for size Moving the KBUILD_MODNAME to the format reduces the overall object size a small amount. $ size drivers/net/wireless/rtlwifi/built-in.o* text data bss dec hex filename 586904 55333 127216 769453 bbdad drivers/net/wireless/rtlwifi/built-in.o.new 588901 55333 127216 771450 bc57a drivers/net/wireless/rtlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/debug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index 74b6780880f2..b024c23b6523 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -168,9 +168,9 @@ do { \ do { \ if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \ ((level) <= rtlpriv->dbg.global_debuglevel))) { \ - printk(KERN_DEBUG "%s:%s():<%lx-%x> " fmt, \ - KBUILD_MODNAME, __func__, \ - in_interrupt(), in_atomic(), ##__VA_ARGS__); \ + printk(KERN_DEBUG KBUILD_MODNAME ":%s():<%lx-%x> " fmt, \ + __func__, in_interrupt(), in_atomic(), \ + ##__VA_ARGS__); \ } \ } while (0) -- GitLab From 481b9606ec7276401c7f746fe37873855c49d1b8 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 5 Jan 2012 08:29:07 -0800 Subject: [PATCH 0080/1846] rtlwifi: add CONFIG_RTLWIFI_DEBUG to remove all of the debug logging code It does seem odd though to have a DBG_EMERG and not always emit it. What might also be useful for any embedded use is to add CONFIG_RTLWIFI_DEBUG to conditionally remove all of the debug logging code to reduce the largish object size. This reduces the object size by about 1/3 (250KB) when CONFIG_RTLWIFI_DEBUG is not set. $ size drivers/net/wireless/rtlwifi/built-in.o* text data bss dec hex filename 368722 55333 94224 518279 7e887 drivers/net/wireless/rtlwifi/built-in.o.new 586904 55333 127216 769453 bbdad drivers/net/wireless/rtlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/Kconfig | 5 ++++ drivers/net/wireless/rtlwifi/debug.h | 34 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig index d6c42e69bdbd..44b9c0a57702 100644 --- a/drivers/net/wireless/rtlwifi/Kconfig +++ b/drivers/net/wireless/rtlwifi/Kconfig @@ -49,6 +49,11 @@ config RTLWIFI depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE default m +config RTLWIFI_DEBUG + tristate "Additional debugging output" + depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE + default y + config RTL8192C_COMMON tristate depends on RTL8192CE || RTL8192CU diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index b024c23b6523..fd5600c69428 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -156,6 +156,8 @@ enum dbgp_flag_e { DBGP_TYPE_MAX }; +#ifdef CONFIG_RTLWIFI_DEBUG + #define RT_ASSERT(_exp, fmt, ...) \ do { \ if (!(_exp)) { \ @@ -195,5 +197,37 @@ do { \ } \ } while (0) +#else + +struct rtl_priv; + +__printf(2, 3) +static inline void RT_ASSERT(int exp, const char *fmt, ...) +{ +} + +__printf(4, 5) +static inline void RT_TRACE(struct rtl_priv *rtlpriv, + int comp, int level, + const char *fmt, ...) +{ +} + +__printf(4, 5) +static inline void RTPRINT(struct rtl_priv *rtlpriv, + int dbgtype, int dbgflag, + const char *fmt, ...) +{ +} + +static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv, + int comp, int level, + const char *titlestring, + const void *hexdata, size_t hexdatalen) +{ +} + +#endif + void rtl_dbgp_flag_init(struct ieee80211_hw *hw); #endif -- GitLab From d9595ce30bd860a1c5bcafef8430f46faa26d6eb Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 6 Jan 2012 11:31:42 -0800 Subject: [PATCH 0081/1846] rtlwifi: Remove incorrect logging message prefixes pr_fmt() adds them. These are unnecessary and wrong. Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 4 ++-- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 943f3d49d1f2..71c7aca0b431 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -84,7 +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); + pr_info("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/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index 022f06529703..364aa402245b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -154,9 +154,9 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; if (!rtlpriv->psc.inactiveps) - pr_info("rtl8192ce: Power Save off (module option)\n"); + pr_info("Power Save off (module option)\n"); if (!rtlpriv->psc.fwctrl_lps) - pr_info("rtl8192ce: FW Power Save off (module option)\n"); + pr_info("FW Power Save off (module option)\n"); rtlpriv->psc.reg_fwctrl_lps = 3; rtlpriv->psc.reg_max_lps_awakeintvl = 5; /* for ASPM, you can close aspm through diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index a933aef3d1ac..5795a542bdfb 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -168,9 +168,9 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; if (!rtlpriv->psc.inactiveps) - pr_info("rtl8192ce: Power Save off (module option)\n"); + pr_info("Power Save off (module option)\n"); if (!rtlpriv->psc.fwctrl_lps) - pr_info("rtl8192ce: FW Power Save off (module option)\n"); + pr_info("FW Power Save off (module option)\n"); rtlpriv->psc.reg_fwctrl_lps = 3; rtlpriv->psc.reg_max_lps_awakeintvl = 5; /* for ASPM, you can close aspm through -- GitLab From 07839b143a360f9dcf38afb5600cf049f8cbee0e Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 6 Jan 2012 11:31:43 -0800 Subject: [PATCH 0082/1846] rtlwifi: Simplify chip version id logging Reduce object size a few KB too. $ size drivers/net/wireless/rtlwifi/built-in.o* text data bss dec hex filename 584493 55333 126800 766626 bb2a2 drivers/net/wireless/rtlwifi/built-in.o.new 586904 55333 127216 769453 bbdad drivers/net/wireless/rtlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 19 ++++---- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 46 ++++++++------------ 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 18f615c41212..971bd29ef9bc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -991,6 +991,7 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw) struct rtl_phy *rtlphy = &(rtlpriv->phy); enum version_8192c version = VERSION_UNKNOWN; u32 value32; + const char *versionid; value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); if (value32 & TRP_VAUX_EN) { @@ -1003,27 +1004,25 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw) switch (version) { case VERSION_B_CHIP_92C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_B_CHIP_92C\n"); + versionid = "B_CHIP_92C"; break; case VERSION_B_CHIP_88C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_B_CHIP_88C\n"); + versionid = "B_CHIP_88C"; break; case VERSION_A_CHIP_92C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_A_CHIP_92C\n"); + versionid = "A_CHIP_92C"; break; case VERSION_A_CHIP_88C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_A_CHIP_88C\n"); + versionid = "A_CHIP_88C"; break; default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Chip Version ID: Unknown. Bug?\n"); + versionid = "Unknown. Bug?"; break; } + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, + "Chip Version ID: %s\n", versionid); + switch (version & 0x3) { case CHIP_88C: rtlphy->rf_type = RF_1T1R; diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 71c7aca0b431..060ed5fec690 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -57,6 +57,7 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw) struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_hal *rtlhal = rtl_hal(rtlpriv); enum version_8192c chip_version = VERSION_UNKNOWN; + const char *versionid; u32 value32; value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); @@ -87,62 +88,51 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw) pr_info("Chip version 0x%x\n", chip_version); switch (rtlhal->version) { case VERSION_NORMAL_TSMC_CHIP_92C_1T2R: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_B_CHIP_92C\n"); + versionid = "NORMAL_B_CHIP_92C"; break; case VERSION_NORMAL_TSMC_CHIP_92C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_TSMC_CHIP_92C\n"); + versionid = "NORMAL_TSMC_CHIP_92C"; break; case VERSION_NORMAL_TSMC_CHIP_88C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_TSMC_CHIP_88C\n"); + versionid = "NORMAL_TSMC_CHIP_88C"; break; case VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_UMC_CHIP_i92C_1T2R_A_CUT\n"); + versionid = "NORMAL_UMC_CHIP_i92C_1T2R_A_CUT"; break; case VERSION_NORMAL_UMC_CHIP_92C_A_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_UMC_CHIP_92C_A_CUT\n"); + versionid = "NORMAL_UMC_CHIP_92C_A_CUT"; break; case VERSION_NORMAL_UMC_CHIP_88C_A_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_UMC_CHIP_88C_A_CUT\n"); + versionid = "NORMAL_UMC_CHIP_88C_A_CUT"; break; case VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT\n"); + versionid = "NORMAL_UMC_CHIP_92C_1T2R_B_CUT"; break; case VERSION_NORMAL_UMC_CHIP_92C_B_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_UMC_CHIP_92C_B_CUT\n"); + versionid = "NORMAL_UMC_CHIP_92C_B_CUT"; break; case VERSION_NORMAL_UMC_CHIP_88C_B_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMAL_UMC_CHIP_88C_B_CUT\n"); + versionid = "NORMAL_UMC_CHIP_88C_B_CUT"; break; case VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT\n"); + versionid = "NORMAL_UMC_CHIP_8723_1T1R_A_CUT"; break; case VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT\n"); + versionid = "NORMAL_UMC_CHIP_8723_1T1R_B_CUT"; break; case VERSION_TEST_CHIP_92C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_TEST_CHIP_92C\n"); + versionid = "TEST_CHIP_92C"; break; case VERSION_TEST_CHIP_88C: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: VERSION_TEST_CHIP_88C\n"); + versionid = "TEST_CHIP_88C"; break; default: - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "Chip Version ID: ???????????????\n"); + versionid = "UNKNOWN"; break; } + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, + "Chip Version ID: %s\n", versionid); + if (IS_92C_SERIAL(rtlhal->version)) rtlphy->rf_type = (IS_92C_1T2R(rtlhal->version)) ? RF_1T2R : RF_2T2R; -- GitLab From 017664fe8e11ec93dfe3faca5b7ff21071011e6a Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 6 Jan 2012 13:16:27 -0800 Subject: [PATCH 0083/1846] iwlwifi: don't process the info from uCode if does not has ownership When enable the testmode from user space and working with uCode, driver does not own the uCode and should not process the notifications or pkts from uCode Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index b22b2976f899..eda95ae88ef1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1172,20 +1172,22 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, wake_up_all(&priv->shrd->notif_waitq); } - if (priv->pre_rx_handler) + if (priv->pre_rx_handler && + priv->shrd->ucode_owner == IWL_OWNERSHIP_TM) priv->pre_rx_handler(priv, rxb); - - /* Based on type of command response or notification, - * handle those that need handling via function in - * rx_handlers table. See iwl_setup_rx_handlers() */ - if (priv->rx_handlers[pkt->hdr.cmd]) { - priv->rx_handlers_stats[pkt->hdr.cmd]++; - err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd); - } else { - /* No handling needed */ - IWL_DEBUG_RX(priv, - "No handler needed for %s, 0x%02x\n", - get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + else { + /* Based on type of command response or notification, + * handle those that need handling via function in + * rx_handlers table. See iwl_setup_rx_handlers() */ + if (priv->rx_handlers[pkt->hdr.cmd]) { + priv->rx_handlers_stats[pkt->hdr.cmd]++; + err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd); + } else { + /* No handling needed */ + IWL_DEBUG_RX(priv, + "No handler needed for %s, 0x%02x\n", + get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + } } return err; } -- GitLab From 2da424b0773cea3db47e1e81db71eeebde8269d4 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 6 Jan 2012 13:16:28 -0800 Subject: [PATCH 0084/1846] iwlwifi: Sanity check for sta_id On my testing, I saw some strange behavior [ 421.739708] iwlwifi 0000:01:00.0: ACTIVATE a non DRIVER active station id 148 addr 00:00:00:00:00:00 [ 421.739719] iwlwifi 0000:01:00.0: iwl_sta_ucode_activate Added STA id 148 addr 00:00:00:00:00:00 to uCode not sure how it happen, but adding the sanity check to prevent memory corruption Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 7353826095f1..8d4353a42568 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -35,9 +35,12 @@ #include "iwl-trans.h" /* priv->shrd->sta_lock must be held */ -static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) +static int iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) { - + if (sta_id >= IWLAGN_STATION_COUNT) { + IWL_ERR(priv, "invalid sta_id %u", sta_id); + return -EINVAL; + } if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u " "addr %pM\n", @@ -53,6 +56,7 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", sta_id, priv->stations[sta_id].sta.sta.addr); } + return 0; } static int iwl_process_add_sta_resp(struct iwl_priv *priv, @@ -77,8 +81,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); - iwl_sta_ucode_activate(priv, sta_id); - ret = 0; + ret = iwl_sta_ucode_activate(priv, sta_id); break; case ADD_STA_NO_ROOM_IN_TABLE: IWL_ERR(priv, "Adding station %d failed, no room in table.\n", -- GitLab From 102f097f1937db41f59674caca0a1e38c963baba Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Fri, 6 Jan 2012 13:16:29 -0800 Subject: [PATCH 0085/1846] iwlwifi: update testmode command of direct register access In order to make sure the testcommand function of direct register access can be performed even NIC is asleep, replace corresponding handler iwl_read32 and iwl_write32 by using iwl_direct_read32 and iwl_direct_write32. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 4a5cddd2d56b..2fc20675dc7b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -299,7 +299,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - val32 = iwl_read32(bus(priv), ofs); + val32 = iwl_read_direct32(bus(priv), ofs); IWL_INFO(priv, "32bit value to read 0x%x\n", val32); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); @@ -321,7 +321,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) } 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); + iwl_write_direct32(bus(priv), ofs, val32); } break; case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: -- GitLab From b07f08a56524cdc49001b1467743acc3c5b78962 Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Fri, 6 Jan 2012 13:16:30 -0800 Subject: [PATCH 0086/1846] iwlwifi: enhance testmode command sram_read This patch enables SRAM read function to support entire target memory. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 7 +++---- drivers/net/wireless/iwlwifi/iwl-testmode.h | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 2fc20675dc7b..58575fdc4504 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -733,7 +733,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, maxsize; + u32 ofs, size, maxsize; if (priv->testmode_sram.sram_readed) return -EBUSY; @@ -765,7 +765,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); return -ENOSYS; } - if ((ofs + size) > maxsize) { + if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) { IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); return -EINVAL; } @@ -776,8 +776,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) IWL_DEBUG_INFO(priv, "Error allocating memory\n"); return -ENOMEM; } - base = 0x800000; - _iwl_read_targ_mem_words(bus(priv), base + ofs, + _iwl_read_targ_mem_words(bus(priv), ofs, priv->testmode_sram.buff_addr, priv->testmode_sram.buff_size / 4); priv->testmode_sram.num_chunks = diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 26138f110340..9c6a67ab5c34 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -271,4 +271,7 @@ enum iwl_tm_attr_t { /* Maximum data size of each dump it packet */ #define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024) +/* Address offset of data segment in SRAM */ +#define SRAM_DATA_SEG_OFFSET 0x800000 + #endif -- GitLab From 907781b5c46a1bec51548af2135903017b546924 Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Fri, 6 Jan 2012 13:16:31 -0800 Subject: [PATCH 0087/1846] iwlwifi: update error dump in testmode command sram_read The error message will be show up by using IWL_ERR insteads of IWl_DEBUG_INFO. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 58575fdc4504..b56cd900805c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -759,21 +759,21 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) maxsize = trans(priv)->ucode_wowlan.data.len; break; case IWL_UCODE_NONE: - IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); + IWL_ERR(priv, "Error, uCode does not been loaded\n"); return -ENOSYS; default: - IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); + IWL_ERR(priv, "Error, unsupported uCode type\n"); return -ENOSYS; } if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) { - IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); + IWL_ERR(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"); + IWL_ERR(priv, "Error allocating memory\n"); return -ENOMEM; } _iwl_read_targ_mem_words(bus(priv), ofs, -- GitLab From 668bd6a81bd6a3e0c10144201c6f58097de220bf Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Fri, 6 Jan 2012 13:16:32 -0800 Subject: [PATCH 0088/1846] iwlwifi: add testmode cmd IWL_TM_CMD_APP2DEV_GET_FW_INFO Add new testmode command IWL_TM_CMD_APP2DEV_GET_FW_INFO for reporting the following information of existing loaded uCode image. + uCode type + Instruction section size + Data section size Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 41 ++++++++++++++++++++- drivers/net/wireless/iwlwifi/iwl-testmode.h | 19 +++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index b56cd900805c..7684c0e2f21a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -115,6 +115,9 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, }, + [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, }, }; /* @@ -422,7 +425,7 @@ 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; - u32 devid; + u32 devid, inst_size = 0, data_size = 0; switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: @@ -548,6 +551,41 @@ 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_FW_INFO: + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + switch (priv->shrd->ucode_type) { + case IWL_UCODE_REGULAR: + inst_size = trans(priv)->ucode_rt.code.len; + data_size = trans(priv)->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + inst_size = trans(priv)->ucode_init.code.len; + data_size = trans(priv)->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + inst_size = trans(priv)->ucode_wowlan.code.len; + data_size = trans(priv)->ucode_wowlan.data.len; + break; + case IWL_UCODE_NONE: + IWL_DEBUG_INFO(priv, "The uCode has not been loaded\n"); + break; + default: + IWL_DEBUG_INFO(priv, "Unsupported uCode type\n"); + break; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type); + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size); + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size); + 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; @@ -881,6 +919,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: + case IWL_TM_CMD_APP2DEV_GET_FW_INFO: 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 9c6a67ab5c34..cb0cf35f91b5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -120,6 +120,8 @@ * @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 + * @IWL_TM_CMD_APP2DEV_GET_FW_INFO: + * retrieve informration of existing loaded uCode image * */ enum iwl_tm_cmd_t { @@ -147,7 +149,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23, IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24, - IWL_TM_CMD_MAX = 25, + IWL_TM_CMD_APP2DEV_GET_FW_INFO = 25, + IWL_TM_CMD_MAX = 26, }; /* @@ -237,6 +240,15 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_DEVICE_ID, * IWL_TM_ATTR_DEVICE_ID for the device ID information * + * @IWL_TM_ATTR_FW_TYPE: + * @IWL_TM_ATTR_FW_INST_SIZE: + * @IWL_TM_ATTR_FW_DATA_SIZE: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_INFO, + * The mandatory fields are: + * IWL_TM_ATTR_FW_TYPE for the uCode type (INIT/RUNTIME/...) + * IWL_TM_ATTR_FW_INST_SIZE for the size of instruction section + * IWL_TM_ATTR_FW_DATA_SIZE for the size of data section + * */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -259,7 +271,10 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_SRAM_DUMP = 17, IWL_TM_ATTR_FW_VERSION = 18, IWL_TM_ATTR_DEVICE_ID = 19, - IWL_TM_ATTR_MAX = 20, + IWL_TM_ATTR_FW_TYPE = 20, + IWL_TM_ATTR_FW_INST_SIZE = 21, + IWL_TM_ATTR_FW_DATA_SIZE = 22, + IWL_TM_ATTR_MAX = 23, }; /* uCode trace buffer */ -- GitLab From fb4961dbc27d40cdbed297aa9bd74fa4a0e2ba6c Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 6 Jan 2012 13:16:33 -0800 Subject: [PATCH 0089/1846] iwlwifi: update Copyright Update Copyright to 2012 Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-2000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-5000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-6000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-calib.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-hw.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.h | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.h | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-bus.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-cfg.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-commands.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-core.c | 2 +- drivers/net/wireless/iwlwifi/iwl-core.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-csr.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-debug.h | 2 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +- drivers/net/wireless/iwlwifi/iwl-devtrace.c | 2 +- drivers/net/wireless/iwlwifi/iwl-devtrace.h | 2 +- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-eeprom.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-fh.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-io.c | 2 +- drivers/net/wireless/iwlwifi/iwl-io.h | 2 +- drivers/net/wireless/iwlwifi/iwl-led.c | 2 +- drivers/net/wireless/iwlwifi/iwl-led.h | 2 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- drivers/net/wireless/iwlwifi/iwl-pci.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-power.c | 2 +- drivers/net/wireless/iwlwifi/iwl-power.h | 2 +- drivers/net/wireless/iwlwifi/iwl-prph.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-scan.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 6 +++--- drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-testmode.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans.h | 4 ++-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-wifi.h | 4 ++-- 53 files changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 1ef7bfc2ab25..cc04cce11567 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 094693328dbb..00db092d8cd0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index b3a365fea7bb..47fd98b3652c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 54b753399e6e..ab62c018fcdb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 50ff849c9f67..6aa009827865 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h index 10275ce92bde..9ed6683314a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h index 123ef5e129d5..d0ec0abd3c89 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 64cf439035c3..a8f7689aaacf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 334b5ae8fdd4..b9ba404d15c1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h index 6675b3c816d9..203b1c13c491 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index eda95ae88ef1..f127f913e5a6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portionhelp of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 1c6659416621..8ca9570ec365 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 8d4353a42568..d6aab00272b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index b0dff7a753a5..56c6def015a4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.h b/drivers/net/wireless/iwlwifi/iwl-agn-tt.h index 7282a23e8f1c..86bbf47501c1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index c664c2726553..a8c6880af34b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index b5c7c5f0a753..7321e7d31406 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index f84fb3c53563..39cbe1a1577c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 940d5038b39c..941b9cb23442 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h index e1d78257e4a9..957bc00cdaf0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-cfg.h +++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 265de39d394c..b4779c25a4b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 7bcfa781e0b9..7d6eef96454a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 7bf76ab94dd2..63f29111da13 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h index fbc3095c7b44..5f96ce105f08 100644 --- a/drivers/net/wireless/iwlwifi/iwl-csr.h +++ b/drivers/net/wireless/iwlwifi/iwl-csr.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index f8fc2393dd4c..6f7612781e03 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project. * diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 04a3343f4610..f837f32bb71c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index e54a4d11e584..4579d61da25e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/iwlwifi/iwl-devtrace.c index 2a2c8de64a04..91f45e71e0a2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.c +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h index 9b212a8f30bb..4d892211ce4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index c1eda9724f42..e27d9f55267b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 9fa937ec35e3..13f2d3928ef8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h index 5bede9d7f955..90208094b8eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fh.h +++ b/drivers/net/wireless/iwlwifi/iwl-fh.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index d57ea6484bbe..83fdff381150 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project. * diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index aae2eeb331a8..427d065435c8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project. * diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 14dcbfcdc0fd..eca79087afb8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h index 2550b3c7dcbf..b02a853103d3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.h +++ b/drivers/net/wireless/iwlwifi/iwl-led.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index f980e574e1f9..965d0475affd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index fb30ea7ca96b..03702a2e913a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index 2b188a6025b3..c7394ef2e490 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h index 5f7b720cf1a4..07a19fce5fdc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.h +++ b/drivers/net/wireless/iwlwifi/iwl-power.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h index bebdd828f324..a4d11016c3b4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-prph.h +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index a6454726737e..2aea20bf0f10 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index dc55cc4a8108..e406d49f4189 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,7 @@ struct iwl_trans_ops; #define DRV_NAME "iwlwifi" #define IWLWIFI_VERSION "in-tree:" -#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" +#define DRV_COPYRIGHT "Copyright(c) 2003-2012 Intel Corporation" #define DRV_AUTHOR "" extern struct iwl_mod_params iwlagn_mod_params; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 7684c0e2f21a..a56a77b8f926 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index cb0cf35f91b5..185b69ef7539 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index f6debf91d7b5..0ac9b4d30271 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 752493f00406..848c598bfadb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index bd29568177e6..30814b55705e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved. * * Portions of this file are derived from the ipw3945 project, as well * as portions of the ieee80211 subsystem header files. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 67d6e324e26f..5e6af4ba9652 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c index 1b20c4fb791b..506c062343b2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans.c @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index e6bf3f554772..42a9f303f543 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 36a1b5b25858..2edf0ef65a5b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -2,7 +2,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index 18501101a530..7e6eb20823cf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -5,7 +5,7 @@ * * GPL LICENSE SUMMARY * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -30,7 +30,7 @@ * * BSD LICENSE * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- GitLab From 39d02a7d90602d4557ee05db2a157a4e0ec3a3d3 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Sat, 7 Jan 2012 21:06:21 +0530 Subject: [PATCH 0090/1846] mac80211: minor cleanup we would have bailed out if 'ifibss->fixed_channel' is valid i.e. we had used 'fixed-freq' parameter in iw ibss join command. this is with the state 'IEEE80211_IBSS_MLME_JOINED' so no need to check for it Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index b3d76b756cd5..b4c30318e22b 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -642,8 +642,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) "IBSS networks with same SSID (merge)\n", sdata->name); ieee80211_request_internal_scan(sdata, - ifibss->ssid, ifibss->ssid_len, - ifibss->fixed_channel ? ifibss->channel : NULL); + ifibss->ssid, ifibss->ssid_len, NULL); } static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) -- GitLab From 76a92be537f1c8c259e393632301446257ca3ea9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:40 -0600 Subject: [PATCH 0091/1846] rtlwifi: rtl8192c_common: rtl8192de: Check for allocation failures In https://bugzilla.redhat.com/show_bug.cgi?id=771656, a kernel bug was triggered due to a failed skb allocation that was not checked. This event lead to an audit of all memory allocations in the complete rtlwifi family of drivers. This patch fixes the rest. Signed-off-by: Larry Finger Cc: Stable Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 2 ++ drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 2 ++ drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 14 +++++++++----- drivers/net/wireless/rtlwifi/usb.c | 12 +++++++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 3c4ae5d9de4f..8758b3db0723 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -652,6 +652,8 @@ static void _rtl_receive_one(struct ieee80211_hw *hw, struct sk_buff *skb, return; uskb = dev_alloc_skb(skb->len + 128); + if (!uskb) + return; /* exit if allocation failed */ memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, sizeof(rx_status)); pdata = (u8 *)skb_put(uskb, skb->len); memcpy(pdata, skb->data, skb->len); diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 1eae3baae518..e9e9c26d4963 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -785,6 +785,8 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) skb = dev_alloc_skb(totalpacketlen); + if (!skb) + return; memcpy((u8 *) skb_put(skb, totalpacketlen), &reserved_page_packet, totalpacketlen); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c index 94f5b7dd06ed..da58ca4966cc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c @@ -756,12 +756,16 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL", u1RsvdPageLoc, 3); skb = dev_alloc_skb(totalpacketlen); - memcpy((u8 *) skb_put(skb, totalpacketlen), &reserved_page_packet, - totalpacketlen); - rtstatus = _rtl92d_cmd_send_packet(hw, skb); + if (!skb) { + dlok = false; + } else { + memcpy((u8 *) skb_put(skb, totalpacketlen), + &reserved_page_packet, totalpacketlen); + rtstatus = _rtl92d_cmd_send_packet(hw, skb); - if (rtstatus) - dlok = true; + if (rtstatus) + dlok = true; + } if (dlok) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "Set RSVD page location to Fw\n"); diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index 6ae1b212ad99..4db06f6f9084 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -520,12 +520,14 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw, u8 *pdata; uskb = dev_alloc_skb(skb->len + 128); - memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, - sizeof(rx_status)); - pdata = (u8 *)skb_put(uskb, skb->len); - memcpy(pdata, skb->data, skb->len); + if (uskb) { /* drop packet on allocation failure */ + memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, + sizeof(rx_status)); + pdata = (u8 *)skb_put(uskb, skb->len); + memcpy(pdata, skb->data, skb->len); + ieee80211_rx_irqsafe(hw, uskb); + } dev_kfree_skb_any(skb); - ieee80211_rx_irqsafe(hw, uskb); } else { dev_kfree_skb_any(skb); } -- GitLab From 9ef11f7b34c0896a1d476dd8cb9a18671aaab892 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:41 -0600 Subject: [PATCH 0092/1846] rtl8192cu: Remove dead code never selected The original driver contained some conditional code that was not selected, but was not deleted in case it would be used later. That code can now be removed. Reported-by: Joe Perches Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 170 -------------------- 1 file changed, 170 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index ae38bc52a716..b8af2cf4db22 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -339,144 +339,8 @@ static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents) if (IS_HIGHT_PA(rtlefuse->board_type)) rtlefuse->external_pa = 1; pr_info("Board Type %x\n", rtlefuse->board_type); - -#ifdef CONFIG_ANTENNA_DIVERSITY - /* Antenna Diversity setting. */ - if (registry_par->antdiv_cfg == 2) /* 2: From Efuse */ - rtl_efuse->antenna_cfg = (contents[EEPROM_RF_OPT1]&0x18)>>3; - else - rtl_efuse->antenna_cfg = registry_par->antdiv_cfg; /* 0:OFF, */ - - pr_info("Antenna Config %x\n", rtl_efuse->antenna_cfg); -#endif } -#ifdef CONFIG_BT_COEXIST -static void _update_bt_param(_adapter *padapter) -{ - struct btcoexist_priv *pbtpriv = &(padapter->halpriv.bt_coexist); - struct registry_priv *registry_par = &padapter->registrypriv; - if (2 != registry_par->bt_iso) { - /* 0:Low, 1:High, 2:From Efuse */ - pbtpriv->BT_Ant_isolation = registry_par->bt_iso; - } - if (registry_par->bt_sco == 1) { - /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter, 4.Busy, - * 5.OtherBusy */ - pbtpriv->BT_Service = BT_OtherAction; - } else if (registry_par->bt_sco == 2) { - pbtpriv->BT_Service = BT_SCO; - } else if (registry_par->bt_sco == 4) { - pbtpriv->BT_Service = BT_Busy; - } else if (registry_par->bt_sco == 5) { - pbtpriv->BT_Service = BT_OtherBusy; - } else { - pbtpriv->BT_Service = BT_Idle; - } - pbtpriv->BT_Ampdu = registry_par->bt_ampdu; - pbtpriv->bCOBT = _TRUE; - pbtpriv->BtEdcaUL = 0; - pbtpriv->BtEdcaDL = 0; - pbtpriv->BtRssiState = 0xff; - pbtpriv->bInitSet = _FALSE; - pbtpriv->bBTBusyTraffic = _FALSE; - pbtpriv->bBTTrafficModeSet = _FALSE; - pbtpriv->bBTNonTrafficModeSet = _FALSE; - pbtpriv->CurrentState = 0; - pbtpriv->PreviousState = 0; - pr_info("BT Coexistance = %s\n", - (pbtpriv->BT_Coexist == _TRUE) ? "enable" : "disable"); - if (pbtpriv->BT_Coexist) { - if (pbtpriv->BT_Ant_Num == Ant_x2) - pr_info("BlueTooth BT_Ant_Num = Antx2\n"); - else if (pbtpriv->BT_Ant_Num == Ant_x1) - pr_info("BlueTooth BT_Ant_Num = Antx1\n"); - switch (pbtpriv->BT_CoexistType) { - case BT_2Wire: - pr_info("BlueTooth BT_CoexistType = BT_2Wire\n"); - break; - case BT_ISSC_3Wire: - pr_info("BlueTooth BT_CoexistType = BT_ISSC_3Wire\n"); - break; - case BT_Accel: - pr_info("BlueTooth BT_CoexistType = BT_Accel\n"); - break; - case BT_CSR_BC4: - pr_info("BlueTooth BT_CoexistType = BT_CSR_BC4\n"); - break; - case BT_CSR_BC8: - pr_info("BlueTooth BT_CoexistType = BT_CSR_BC8\n"); - break; - case BT_RTL8756: - pr_info("BlueTooth BT_CoexistType = BT_RTL8756\n"); - break; - default: - pr_info("BlueTooth BT_CoexistType = Unknown\n"); - break; - } - pr_info("BlueTooth BT_Ant_isolation = %d\n", - pbtpriv->BT_Ant_isolation); - switch (pbtpriv->BT_Service) { - case BT_OtherAction: - pr_info("BlueTooth BT_Service = BT_OtherAction\n"); - break; - case BT_SCO: - pr_info("BlueTooth BT_Service = BT_SCO\n"); - break; - case BT_Busy: - pr_info("BlueTooth BT_Service = BT_Busy\n"); - break; - case BT_OtherBusy: - pr_info("BlueTooth BT_Service = BT_OtherBusy\n"); - break; - default: - pr_info("BlueTooth BT_Service = BT_Idle\n"); - break; - } - pr_info("BT_RadioSharedType = 0x%x\n", - pbtpriv->BT_RadioSharedType); - } -} - -#define GET_BT_COEXIST(priv) (&priv->bt_coexist) - -static void _rtl92cu_read_bluetooth_coexistInfo(struct ieee80211_hw *hw, - u8 *contents, - bool bautoloadfailed); -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - bool isNormal = IS_NORMAL_CHIP(pHalData->VersionID); - struct btcoexist_priv *pbtpriv = &pHalData->bt_coexist; - u8 rf_opt4; - - _rtw_memset(pbtpriv, 0, sizeof(struct btcoexist_priv)); - if (AutoloadFail) { - pbtpriv->BT_Coexist = _FALSE; - pbtpriv->BT_CoexistType = BT_2Wire; - pbtpriv->BT_Ant_Num = Ant_x2; - pbtpriv->BT_Ant_isolation = 0; - pbtpriv->BT_RadioSharedType = BT_Radio_Shared; - return; - } - if (isNormal) { - if (pHalData->BoardType == BOARD_USB_COMBO) - pbtpriv->BT_Coexist = _TRUE; - else - pbtpriv->BT_Coexist = ((PROMContent[EEPROM_RF_OPT3] & - 0x20) >> 5); /* bit[5] */ - rf_opt4 = PROMContent[EEPROM_RF_OPT4]; - pbtpriv->BT_CoexistType = ((rf_opt4&0xe)>>1); /* bit [3:1] */ - pbtpriv->BT_Ant_Num = (rf_opt4&0x1); /* bit [0] */ - pbtpriv->BT_Ant_isolation = ((rf_opt4&0x10)>>4); /* bit [4] */ - pbtpriv->BT_RadioSharedType = ((rf_opt4&0x20)>>5); /* bit [5] */ - } else { - pbtpriv->BT_Coexist = (PROMContent[EEPROM_RF_OPT4] >> 4) ? - _TRUE : _FALSE; - } - _update_bt_param(Adapter); -} -#endif - static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -552,10 +416,6 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) } } _rtl92cu_read_board_type(hw, hwinfo); -#ifdef CONFIG_BT_COEXIST - _rtl92cu_read_bluetooth_coexistInfo(hw, hwinfo, - rtlefuse->autoload_failflag); -#endif } static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw) @@ -1107,34 +967,6 @@ static void _InitPABias(struct ieee80211_hw *hw) } } -static void _InitAntenna_Selection(struct ieee80211_hw *hw) -{ -#ifdef CONFIG_ANTENNA_DIVERSITY - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - if (pHalData->AntDivCfg == 0) - return; - - if (rtlphy->rf_type == RF_1T1R) { - rtl_write_dword(rtlpriv, REG_LEDCFG0, - rtl_read_dword(rtlpriv, - REG_LEDCFG0)|BIT(23)); - rtl_set_bbreg(hw, rFPGA0_XAB_RFPARAMETER, BIT(13), 0x01); - if (rtl_get_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, 0x300) == - Antenna_A) - pHalData->CurAntenna = Antenna_A; - else - pHalData->CurAntenna = Antenna_B; - } -#endif -} - -static void _dump_registers(struct ieee80211_hw *hw) -{ -} - static void _update_mac_setting(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -1205,10 +1037,8 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw) } _rtl92cu_hw_configure(hw); _InitPABias(hw); - _InitAntenna_Selection(hw); _update_mac_setting(hw); rtl92c_dm_init(hw); - _dump_registers(hw); return err; } -- GitLab From a8d760668eebc98915383481cb3d9eaf74c2a615 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:42 -0600 Subject: [PATCH 0093/1846] rtlwifi: Update copyright dates Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 2 +- drivers/net/wireless/rtlwifi/base.h | 2 +- drivers/net/wireless/rtlwifi/cam.c | 2 +- drivers/net/wireless/rtlwifi/cam.h | 2 +- drivers/net/wireless/rtlwifi/core.c | 2 +- drivers/net/wireless/rtlwifi/core.h | 2 +- drivers/net/wireless/rtlwifi/debug.c | 2 +- drivers/net/wireless/rtlwifi/debug.h | 2 +- drivers/net/wireless/rtlwifi/efuse.c | 2 +- drivers/net/wireless/rtlwifi/efuse.h | 2 +- drivers/net/wireless/rtlwifi/pci.c | 2 +- drivers/net/wireless/rtlwifi/pci.h | 2 +- drivers/net/wireless/rtlwifi/ps.c | 2 +- drivers/net/wireless/rtlwifi/ps.h | 2 +- drivers/net/wireless/rtlwifi/rc.c | 2 +- drivers/net/wireless/rtlwifi/rc.h | 2 +- drivers/net/wireless/rtlwifi/regd.c | 2 +- drivers/net/wireless/rtlwifi/regd.h | 2 +- drivers/net/wireless/rtlwifi/usb.c | 2 +- drivers/net/wireless/rtlwifi/usb.h | 2 +- drivers/net/wireless/rtlwifi/wifi.h | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index fa16b1d708fe..6f80142580fd 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h index f66b5757f6b9..5a23a6d0f49d 100644 --- a/drivers/net/wireless/rtlwifi/base.h +++ b/drivers/net/wireless/rtlwifi/base.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/cam.c b/drivers/net/wireless/rtlwifi/cam.c index cbf5e3cdb44e..8fd820d85eea 100644 --- a/drivers/net/wireless/rtlwifi/cam.c +++ b/drivers/net/wireless/rtlwifi/cam.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/cam.h b/drivers/net/wireless/rtlwifi/cam.h index c62da4eefc75..35e00086a520 100644 --- a/drivers/net/wireless/rtlwifi/cam.h +++ b/drivers/net/wireless/rtlwifi/cam.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index ab6a4068764f..d6e37e6a1d53 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h index f02824a3b747..a45c3892e363 100644 --- a/drivers/net/wireless/rtlwifi/core.h +++ b/drivers/net/wireless/rtlwifi/core.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * Tmis program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/debug.c b/drivers/net/wireless/rtlwifi/debug.c index 1b5cb7153a52..67dcbcdfaa7b 100644 --- a/drivers/net/wireless/rtlwifi/debug.c +++ b/drivers/net/wireless/rtlwifi/debug.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * Tmis program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h index fd5600c69428..07493d2957f2 100644 --- a/drivers/net/wireless/rtlwifi/debug.h +++ b/drivers/net/wireless/rtlwifi/debug.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * Tmis program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index a079a31b4ed7..b24cbe6e16d8 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * Tmis program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/efuse.h b/drivers/net/wireless/rtlwifi/efuse.h index 164dabaa7615..2bdea9a8699e 100644 --- a/drivers/net/wireless/rtlwifi/efuse.h +++ b/drivers/net/wireless/rtlwifi/efuse.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 8758b3db0723..4326fd1e3190 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h index ebe0b42c0518..99d81ede17b8 100644 --- a/drivers/net/wireless/rtlwifi/pci.h +++ b/drivers/net/wireless/rtlwifi/pci.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index a36dc3d5e04f..b151266ef9f6 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/ps.h b/drivers/net/wireless/rtlwifi/ps.h index 84628e6041c7..1357856998c2 100644 --- a/drivers/net/wireless/rtlwifi/ps.h +++ b/drivers/net/wireless/rtlwifi/ps.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rc.c b/drivers/net/wireless/rtlwifi/rc.c index 4f560d6a386c..c66f08a0524a 100644 --- a/drivers/net/wireless/rtlwifi/rc.c +++ b/drivers/net/wireless/rtlwifi/rc.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rc.h b/drivers/net/wireless/rtlwifi/rc.h index 4afa2c20adcf..4d6176160610 100644 --- a/drivers/net/wireless/rtlwifi/rc.h +++ b/drivers/net/wireless/rtlwifi/rc.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/regd.c b/drivers/net/wireless/rtlwifi/regd.c index c263df217604..c1608cddc529 100644 --- a/drivers/net/wireless/rtlwifi/regd.c +++ b/drivers/net/wireless/rtlwifi/regd.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/regd.h b/drivers/net/wireless/rtlwifi/regd.h index d23118938fac..70ef2f418a44 100644 --- a/drivers/net/wireless/rtlwifi/regd.h +++ b/drivers/net/wireless/rtlwifi/regd.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index 4db06f6f9084..78194e30fcd5 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2011 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/usb.h b/drivers/net/wireless/rtlwifi/usb.h index d2a63fb3e1e6..cdad7c2507e4 100644 --- a/drivers/net/wireless/rtlwifi/usb.h +++ b/drivers/net/wireless/rtlwifi/usb.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2011 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index cdaf1429fa0b..b2d98548500b 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * 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 -- GitLab From fc6168563aeb26cbc9a9ba9dd168cfdabc6f3778 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:43 -0600 Subject: [PATCH 0094/1846] rtl8192c_common: Update copyright dates Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/main.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index bf94cbfb4e3f..cb5535cf3ae2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h index b9736d3e9a39..2178e3761883 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index e9e9c26d4963..75be221fde4c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h index cec5a3a1cc53..780ea5b1e24c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/main.c b/drivers/net/wireless/rtlwifi/rtl8192c/main.c index 605ff191aeb7..8ae65b576126 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/main.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/main.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index 25bde968699d..22e998dd2f32 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h index 9a264c0d6127..cec10d696492 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * 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 -- GitLab From 9003a4aba4b040be265ce8ed51f6fe437d369453 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:44 -0600 Subject: [PATCH 0095/1846] rtl8192ce: Update copyright dates Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192ce/def.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/dm.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/dm.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/hw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/led.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/led.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/phy.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/reg.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/rf.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/sw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/table.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/table.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/trx.h | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h index 9fc804d89d65..04c3aef8a4f6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c index 6730e683aba3..27b3af880d96 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h index 07dd9552e82f..26747fa86005 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 971bd29ef9bc..c5aced459cd0 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h index 07dbe3e340a5..52a3aea9b3de 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c index 09758f48d3e6..8283e9b27639 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/led.h b/drivers/net/wireless/rtlwifi/rtl8192ce/led.h index 7dfccea2095b..c5761066d383 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/led.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/led.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c index 03ee82e05f2f..c64daf25566a 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h index be2c92adef33..d5e3b704f930 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h index ba5ff0411f0a..43806d9d1e13 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c index 5ef960499a43..69d720dd9c38 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h index 39ff03685986..6c8d56efceae 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index 4a224dbc693d..7e59b689bfff 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h index b7dc3263e433..d2367a5d0cf5 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/table.c b/drivers/net/wireless/rtlwifi/rtl8192ce/table.c index ba938b91aa6f..752f943a84ae 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/table.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/table.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/table.h b/drivers/net/wireless/rtlwifi/rtl8192ce/table.h index 3a6e8b6aeee0..8b79161f71be 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/table.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/table.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c index 46892cc1a08d..37b13636a778 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h index c8977a50ca36..efb9ab270403 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * 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 -- GitLab From c1d6604d1e3357d734d209a04cc1f80af948364b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:45 -0600 Subject: [PATCH 0096/1846] rtl8192cu: Update copyright dates Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192cu/def.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/dm.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/dm.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/hw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/led.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/led.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/mac.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/phy.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/reg.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/rf.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/sw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/table.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/table.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/trx.h | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/def.h b/drivers/net/wireless/rtlwifi/rtl8192cu/def.h index d097efb1e717..f916555e6311 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/def.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/def.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c index c0016f3194e5..6fd39eaf361e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h index 7f966c666b5a..d947e7d350bb 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index b8af2cf4db22..edb52987f5ea 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h index 32f85cba106a..f41a3aa4a26f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/led.c b/drivers/net/wireless/rtlwifi/rtl8192cu/led.c index 65fd04424623..75a2deb23af1 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/led.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/led.h b/drivers/net/wireless/rtlwifi/rtl8192cu/led.h index decaee4d1eb1..0f372278b7af 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/led.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/led.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 060ed5fec690..d028f6f21990 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h index 626d88e88e26..bf53652e4edd 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c index e7ea2bae2105..8ac3bcca4d41 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h index ff81a61729d7..42b068660483 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h b/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h index 7f1be614c998..8b81465c629b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c index e132cb30a309..780c0d98a836 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h index 500a2094b6bb..090fd33a158d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index dee7aab4faa6..aec8cae733a1 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h index 43b1177924ab..a1310abd0d54 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/table.c b/drivers/net/wireless/rtlwifi/rtl8192cu/table.c index d57ef5e88a9e..966be519edb8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/table.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/table.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/table.h b/drivers/net/wireless/rtlwifi/rtl8192cu/table.h index c3d5cd826cfa..4b020e9e30b1 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/table.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/table.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index 7d5f79991f8e..21bc827c5fa6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h index 53de5f66e242..332b06e78b00 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2009-2012 Realtek 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 -- GitLab From 6a57b08e222f4e054a7e7160ef7426c5614c0cc0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:46 -0600 Subject: [PATCH 0097/1846] rtl8192de: Update copyright dates Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192de/def.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/dm.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/fw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/hw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/led.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/led.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/phy.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/reg.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/rf.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/sw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/table.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/table.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/trx.h | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/def.h b/drivers/net/wireless/rtlwifi/rtl8192de/def.h index 946304771748..eafdf76ed64d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/def.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/def.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c index 32537c4faf95..181ed6fc90e6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h index 69354657f0f5..91030ec8ac3e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c index da58ca4966cc..b59de75a3643 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h index 0c4d489eaa48..1ffacdda734c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index d94ce371572f..695bccb43750 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.h b/drivers/net/wireless/rtlwifi/rtl8192de/hw.h index ad44ffa520e6..7c9f7a2f1e42 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/led.c b/drivers/net/wireless/rtlwifi/rtl8192de/led.c index f2358f20b9cd..76a57ae4af3e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/led.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/led.h b/drivers/net/wireless/rtlwifi/rtl8192de/led.h index 57f4a3c583d4..a29df30c3025 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/led.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/led.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index f27acc754944..9581a19c2548 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.h b/drivers/net/wireless/rtlwifi/rtl8192de/phy.h index a52c824b41e3..f074952bf25c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/reg.h b/drivers/net/wireless/rtlwifi/rtl8192de/reg.h index 131acc306fcc..9bc462331078 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/reg.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c index 2e174f48946b..ff34d2dd39b8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.h b/drivers/net/wireless/rtlwifi/rtl8192de/rf.h index 74b9cfc39a83..0fe1a48593e8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index 364aa402245b..b8d7fe39e5a8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.h b/drivers/net/wireless/rtlwifi/rtl8192de/sw.h index c95e47de1346..0e6035b8fd86 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/table.c b/drivers/net/wireless/rtlwifi/rtl8192de/table.c index bad7f9449ecf..8ea6f528dfa6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/table.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/table.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/table.h b/drivers/net/wireless/rtlwifi/rtl8192de/table.h index 93f30ca62d8f..8b724a86117a 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/table.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/table.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c index e7c985b372fa..a7f6126e2f86 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.h b/drivers/net/wireless/rtlwifi/rtl8192de/trx.h index 4d55d0b6816d..0dc736c2723b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * 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 -- GitLab From ca742cd9766ff519b0e927a9296e29541ee13c7b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 7 Jan 2012 20:46:47 -0600 Subject: [PATCH 0098/1846] rtl8192se: Update copyright dates Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192se/def.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/dm.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/dm.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/fw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/fw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/hw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/led.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/led.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/phy.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/reg.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/rf.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/sw.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/table.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/table.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/trx.h | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h index c6c044816d39..d1b0a1e14971 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c index 4a5e3a952a47..fbabae17259e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h index 9051a556acc4..e1b19a641765 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c index 2a9699feee3b..595ecd22ffa0 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.h b/drivers/net/wireless/rtlwifi/rtl8192se/fw.h index 74cc503efe8a..babe85d4b694 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index b03001b23288..625c9eb0a118 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.h b/drivers/net/wireless/rtlwifi/rtl8192se/hw.h index 6160a9bfe98a..1886c2644a26 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/led.c b/drivers/net/wireless/rtlwifi/rtl8192se/led.c index 1a6b0caf0841..ef4211bca587 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/led.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/led.h b/drivers/net/wireless/rtlwifi/rtl8192se/led.h index 8cce3870af3c..2182dbeb5f32 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/led.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/led.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index e24dbb3a9ba4..adfac569b67c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.h b/drivers/net/wireless/rtlwifi/rtl8192se/phy.h index 37e504af6446..ac0387770630 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/reg.h b/drivers/net/wireless/rtlwifi/rtl8192se/reg.h index 11f125c030ce..84d1181795b8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/reg.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c index 8966b731f7e2..46be4cc8ba96 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.h b/drivers/net/wireless/rtlwifi/rtl8192se/rf.h index 3843baa1a874..8a29eb94ab17 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index 5795a542bdfb..3bc0128deeaa 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.h b/drivers/net/wireless/rtlwifi/rtl8192se/sw.h index fc4eb285a0ac..2eb88862ebe4 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/table.c b/drivers/net/wireless/rtlwifi/rtl8192se/table.c index 154185b3969d..f1a73f75127e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/table.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/table.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/table.h b/drivers/net/wireless/rtlwifi/rtl8192se/table.h index b4ed6d951ebb..2feb73b71a4f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/table.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/table.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. + * Copyright(c) 2008 - 2012 Realtek Corporation. All rights reserved. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c index 216a3e140de8..2fd3d13b7ced 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.h b/drivers/net/wireless/rtlwifi/rtl8192se/trx.h index 05862c51b861..011e7b0695f2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright(c) 2009-2010 Realtek Corporation. + * Copyright(c) 2009-2012 Realtek Corporation. * * 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 -- GitLab From bd7e01bc7e7a90b33470173618f6f6805143cd42 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Sun, 8 Jan 2012 11:21:53 +0200 Subject: [PATCH 0099/1846] NFC: Complete NCI deactivate in deactivate_ntf If a target was active, complete the NCI deactivate request only in deactivate_ntf. Otherwise, complete it at deactivate_rsp. Deactivate_ntf represents the actual disconnection event (sent from the NCI controller). Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/nci/ntf.c | 2 ++ net/nfc/nci/rsp.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index b16a8dc2afbe..10682bf7029d 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -280,6 +280,8 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, /* complete the data exchange transaction, if exists */ if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) nci_data_exchange_complete(ndev, NULL, -EIO); + + nci_req_complete(ndev, NCI_STATUS_OK); } void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index 2840ae2f3615..3c73e92eb625 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c @@ -151,7 +151,10 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, clear_bit(NCI_DISCOVERY, &ndev->flags); - nci_req_complete(ndev, status); + /* If target was active, complete the request only in deactivate_ntf */ + if ((status != NCI_STATUS_OK) || + (!test_bit(NCI_POLL_ACTIVE, &ndev->flags))) + nci_req_complete(ndev, status); } void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) -- GitLab From 11ee51589a61fa836b1540293ad6c7dfd7de544a Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Sun, 8 Jan 2012 13:43:02 +0200 Subject: [PATCH 0100/1846] NFC: Increase NCI deactivate timeout Increase NCI deactivate timeout from 5 sec to 30 sec. NCI deactivate procedure might take a long time, depending on the local and remote parameters. Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- include/net/nfc/nci_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index bccd89e9d4c2..f4963ea77947 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -47,7 +47,7 @@ enum { #define NCI_RESET_TIMEOUT 5000 #define NCI_INIT_TIMEOUT 5000 #define NCI_RF_DISC_TIMEOUT 5000 -#define NCI_RF_DEACTIVATE_TIMEOUT 5000 +#define NCI_RF_DEACTIVATE_TIMEOUT 30000 #define NCI_CMD_TIMEOUT 5000 struct nci_dev; -- GitLab From 75ac9a28a0c6b818ba1aba874b6b3ae17241552c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 9 Jan 2012 10:40:50 +0100 Subject: [PATCH 0101/1846] drivers/net/wireless/mwifiex/scan.c: convert GFP_KERNEL to GFP_ATOMIC The function is called with locks held and thus should not use GFP_KERNEL. The semantic patch that makes this report is available in scripts/coccinelle/locks/call_kern.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Julia Lawall Acked-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 6396d3318ead..98f1ca9cd6d8 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -2001,7 +2001,7 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv) kfree(priv->curr_bcn_buf); priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size, - GFP_KERNEL); + GFP_ATOMIC); if (!priv->curr_bcn_buf) { dev_err(priv->adapter->dev, "failed to alloc curr_bcn_buf\n"); -- GitLab From e9980e6d20a5c4d3f52359142ab3569171759a5b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 9 Jan 2012 13:57:36 +0100 Subject: [PATCH 0102/1846] mac80211: refactor __ieee80211_get_channel_mode Use a switch statement instead of a list of if statements. Also include AP_VLAN in the list and skip them since the AP interface will also be looked at. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/chan.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 889c3e93e0f4..d1f7abddb182 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -20,23 +20,29 @@ __ieee80211_get_channel_mode(struct ieee80211_local *local, if (!ieee80211_sdata_running(sdata)) continue; - if (sdata->vif.type == NL80211_IFTYPE_MONITOR) + switch (sdata->vif.type) { + case NL80211_IFTYPE_MONITOR: continue; - - if (sdata->vif.type == NL80211_IFTYPE_STATION && - !sdata->u.mgd.associated) - continue; - - if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { + case NL80211_IFTYPE_STATION: + if (!sdata->u.mgd.associated) + continue; + break; + case NL80211_IFTYPE_ADHOC: if (!sdata->u.ibss.ssid_len) continue; if (!sdata->u.ibss.fixed_channel) return CHAN_MODE_HOPPING; - } - - if (sdata->vif.type == NL80211_IFTYPE_AP && - !sdata->u.ap.beacon) + break; + case NL80211_IFTYPE_AP_VLAN: + /* will also have _AP interface */ continue; + case NL80211_IFTYPE_AP: + if (!sdata->u.ap.beacon) + continue; + break; + default: + break; + } return CHAN_MODE_FIXED; } -- GitLab From efa6a09db6d6c27557fb55299b9835b45b968eae Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Mon, 9 Jan 2012 19:43:06 +0100 Subject: [PATCH 0103/1846] mac80211: In IBSS the DA field of auth frames is different from BSSID In case of authentication frame exchange between two IBSS STAs, the DA field must contain the destinatioin address (instead of the BSSID). Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 2 +- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/util.c | 6 +++--- net/mac80211/work.c | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index b4c30318e22b..4345e9449d7c 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -57,7 +57,7 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, * has actually implemented this. */ if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) - ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, + ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0); } diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 2f0642d9e154..ca6486b941b6 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1396,7 +1396,7 @@ void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local, void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, u16 transaction, u16 auth_alg, u8 *extra, size_t extra_len, const u8 *bssid, - const u8 *key, u8 key_len, u8 key_idx); + const u8 *da, const u8 *key, u8 key_len, u8 key_idx); int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, const u8 *ie, size_t ie_len, enum ieee80211_band band, u32 rate_mask, diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 9919892575f4..30d72e2af7ce 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -862,8 +862,8 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local, void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, u16 transaction, u16 auth_alg, - u8 *extra, size_t extra_len, const u8 *bssid, - const u8 *key, u8 key_len, u8 key_idx) + u8 *extra, size_t extra_len, const u8 *da, + const u8 *bssid, const u8 *key, u8 key_len, u8 key_idx) { struct ieee80211_local *local = sdata->local; struct sk_buff *skb; @@ -881,7 +881,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, memset(mgmt, 0, 24 + 6); mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); - memcpy(mgmt->da, bssid, ETH_ALEN); + memcpy(mgmt->da, da, ETH_ALEN); memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); memcpy(mgmt->bssid, bssid, ETH_ALEN); mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); diff --git a/net/mac80211/work.c b/net/mac80211/work.c index c6dd01a05291..0a1a176fbe91 100644 --- a/net/mac80211/work.c +++ b/net/mac80211/work.c @@ -480,7 +480,8 @@ ieee80211_authenticate(struct ieee80211_work *wk) sdata->name, wk->filter_ta, wk->probe_auth.tries); ieee80211_send_auth(sdata, 1, wk->probe_auth.algorithm, wk->ie, - wk->ie_len, wk->filter_ta, NULL, 0, 0); + wk->ie_len, wk->filter_ta, wk->filter_ta, NULL, 0, + 0); wk->probe_auth.transaction = 2; wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; @@ -598,7 +599,7 @@ static void ieee80211_auth_challenge(struct ieee80211_work *wk, return; ieee80211_send_auth(sdata, 3, wk->probe_auth.algorithm, elems.challenge - 2, elems.challenge_len + 2, - wk->filter_ta, wk->probe_auth.key, + wk->filter_ta, wk->filter_ta, wk->probe_auth.key, wk->probe_auth.key_len, wk->probe_auth.key_idx); wk->probe_auth.transaction = 4; } -- GitLab From e2d75c136f8df4a4e28ece75c475a65b9292729a Mon Sep 17 00:00:00 2001 From: Nicolas Cavallari Date: Wed, 11 Jan 2012 16:44:50 +0100 Subject: [PATCH 0104/1846] carl9170: claim to support IBSS RSN. On carl9170, HW encryption is disabled on IBSS; the mac80211 software-based encryption is used instead. As mac80211 supports IBSS RSN (per-STA GTK), claim its support in the carl9170 PHY. Signed-off-by: Nicolas Cavallari Acked-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/ath/carl9170/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index db774212161b..4dfb0290b43a 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c @@ -1796,6 +1796,9 @@ void *carl9170_alloc(size_t priv_size) ar->noise[i] = -95; /* ATH_DEFAULT_NOISE_FLOOR */ hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + + /* As IBSS Encryption is software-based, IBSS RSN is supported. */ + hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; return ar; err_nomem: -- GitLab From eccc068e8e84c8fe997115629925e0422a98e4de Mon Sep 17 00:00:00 2001 From: Hong Wu Date: Wed, 11 Jan 2012 20:33:39 +0200 Subject: [PATCH 0105/1846] wireless: Save original maximum regulatory transmission power for the calucation of the local maximum transmit power The local maximum transmit power is the maximum power a wireless device allowed to transmit. If Power Constraint is presented, the local maximum power equals to the maximum allowed power defined in regulatory domain minus power constraint. The maximum transmit power is maximum power a wireless device capable of transmitting, and should be used in Power Capability element (7.3.2.16 IEEE802.11 2007). The transmit power from a wireless device should not greater than the local maximum transmit power. The maximum transmit power was not calculated correctly in the current Linux wireless/mac80211 when Power Constraint is presented. Signed-off-by: Hong Wu Signed-off-by: John W. Linville --- include/net/cfg80211.h | 2 ++ net/wireless/reg.c | 19 ++----------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 15f4be7d768e..208a7b5f8d49 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -120,6 +120,7 @@ enum ieee80211_channel_flags { * @band: band this channel belongs to. * @max_antenna_gain: maximum antenna gain in dBi * @max_power: maximum transmission power (in dBm) + * @max_reg_power: maximum regulatory transmission power (in dBm) * @beacon_found: helper to regulatory code to indicate when a beacon * has been found on this channel. Use regulatory_hint_found_beacon() * to enable this, this is useful only on 5 GHz band. @@ -133,6 +134,7 @@ struct ieee80211_channel { u32 flags; int max_antenna_gain; int max_power; + int max_reg_power; bool beacon_found; u32 orig_flags; int orig_mag, orig_mpwr; diff --git a/net/wireless/reg.c b/net/wireless/reg.c index f65feaad155f..e9a0ac83b84c 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -882,23 +882,8 @@ static void handle_channel(struct wiphy *wiphy, chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); chan->max_antenna_gain = min(chan->orig_mag, (int) MBI_TO_DBI(power_rule->max_antenna_gain)); - if (chan->orig_mpwr) { - /* - * Devices that have their own custom regulatory domain - * but also use WIPHY_FLAG_STRICT_REGULATORY will follow the - * passed country IE power settings. - */ - if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE && - wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY && - wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) { - chan->max_power = - MBM_TO_DBM(power_rule->max_eirp); - } else { - chan->max_power = min(chan->orig_mpwr, - (int) MBM_TO_DBM(power_rule->max_eirp)); - } - } else - chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); + chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp); + chan->max_power = min(chan->max_power, chan->max_reg_power); } static void handle_band(struct wiphy *wiphy, -- GitLab From a48b13ac811ee236151d9e0e0dcb5639b2ab4591 Mon Sep 17 00:00:00 2001 From: Hong Wu Date: Wed, 11 Jan 2012 20:34:30 +0200 Subject: [PATCH 0106/1846] mac80211: Fix the maximum transmit power with power constraint The local maximum transmit power for a channel is defined as the maximum regulatory transmission power minus the local power constraint specified for the channel in the Power Constraint element. (7.3.2.15 IEEE80211 2007) Signed-off-by: Hong Wu Signed-off-by: John W. Linville --- net/mac80211/main.c | 3 ++- net/mac80211/mlme.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 0a0d94ad9b08..6192caadfab9 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -155,7 +155,8 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) power = chan->max_power; else power = local->power_constr_level ? - (chan->max_power - local->power_constr_level) : + min(chan->max_power, + (chan->max_reg_power - local->power_constr_level)) : chan->max_power; if (local->user_power_level >= 0) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ecb4c84c1bb3..95d3964fc080 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -547,7 +547,7 @@ static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, if (pwr_constr_elem_len != 1) return; - if ((*pwr_constr_elem <= conf->channel->max_power) && + if ((*pwr_constr_elem <= conf->channel->max_reg_power) && (*pwr_constr_elem != sdata->local->power_constr_level)) { sdata->local->power_constr_level = *pwr_constr_elem; ieee80211_hw_config(sdata->local, 0); -- GitLab From cebcab9e18725d8249f607af787ee92107a665b7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 11 Jan 2012 14:39:32 -0600 Subject: [PATCH 0107/1846] bcma: Enable logging of SPROM offset The SPROM location has been relocated again for some devices. This patch will log the offset when CONFIG_BCMA_DEBUG has been selected. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/bcma/sprom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index cb835f026d94..e35134f724f6 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -271,6 +271,7 @@ int bcma_sprom_get(struct bcma_bus *bus) * TODO: understand this condition and use it */ offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM : BCMA_CC_SPROM_PCIE6; + pr_debug("SPROM offset 0x%x\n", offset); bcma_sprom_read(bus, offset, sprom); if (bus->chipinfo.id == 0x4331) -- GitLab From 9da9a3b29ba6a9a98e437f24576f13cbe259997b Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Wed, 11 Jan 2012 20:06:11 -0800 Subject: [PATCH 0108/1846] mwifiex: use bss_type and bss_num to retrieve priv Current implementation, for retrieving priv from adapter, uses bss_index. In multi interface environment supporting different types, bss_index may not be unique. Use bss_type along with bss_num to retrieve the priv. bss_index is removed with this change. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Kiran Divekar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/11n_aggr.c | 3 ++- drivers/net/wireless/mwifiex/cfg80211.c | 1 - drivers/net/wireless/mwifiex/cmdevt.c | 3 ++- drivers/net/wireless/mwifiex/decl.h | 6 ++++-- drivers/net/wireless/mwifiex/init.c | 5 +++-- drivers/net/wireless/mwifiex/main.c | 23 ++++++----------------- drivers/net/wireless/mwifiex/main.h | 3 --- drivers/net/wireless/mwifiex/sta_rx.c | 6 ++++-- drivers/net/wireless/mwifiex/sta_tx.c | 3 ++- drivers/net/wireless/mwifiex/txrx.c | 6 ++++-- drivers/net/wireless/mwifiex/util.c | 3 ++- drivers/net/wireless/mwifiex/wmm.c | 3 ++- 12 files changed, 31 insertions(+), 34 deletions(-) diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c index 079e5532e686..ea6832dc6677 100644 --- a/drivers/net/wireless/mwifiex/11n_aggr.c +++ b/drivers/net/wireless/mwifiex/11n_aggr.c @@ -182,7 +182,8 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, skb_reserve(skb_aggr, headroom + sizeof(struct txpd)); tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr); - tx_info_aggr->bss_index = tx_info_src->bss_index; + tx_info_aggr->bss_type = tx_info_src->bss_type; + tx_info_aggr->bss_num = tx_info_src->bss_num; skb_aggr->priority = skb_src->priority; do { diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index c3b6c4652cd6..36f67da8fa4f 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -1217,7 +1217,6 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II; priv->bss_priority = 0; priv->bss_role = MWIFIEX_BSS_ROLE_STA; - priv->bss_index = 0; priv->bss_num = 0; break; diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c index 6e0a3eaecf70..6623db69e157 100644 --- a/drivers/net/wireless/mwifiex/cmdevt.c +++ b/drivers/net/wireless/mwifiex/cmdevt.c @@ -391,7 +391,8 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter) if (skb) { rx_info = MWIFIEX_SKB_RXCB(skb); - rx_info->bss_index = priv->bss_index; + rx_info->bss_num = priv->bss_num; + rx_info->bss_type = priv->bss_type; } if (eventcause != EVENT_PS_SLEEP && eventcause != EVENT_PS_AWAKE) { diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h index ae17ce02a3d0..3735c775495c 100644 --- a/drivers/net/wireless/mwifiex/decl.h +++ b/drivers/net/wireless/mwifiex/decl.h @@ -102,7 +102,8 @@ struct mwifiex_wait_queue { }; struct mwifiex_rxinfo { - u8 bss_index; + u8 bss_num; + u8 bss_type; struct sk_buff *parent; u8 use_count; }; @@ -110,7 +111,8 @@ struct mwifiex_rxinfo { struct mwifiex_txinfo { u32 status_code; u8 flags; - u8 bss_index; + u8 bss_num; + u8 bss_type; }; enum mwifiex_wmm_ac_e { diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index e05b417a3fae..e13b6d99171a 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c @@ -526,8 +526,9 @@ static void mwifiex_delete_bss_prio_tbl(struct mwifiex_private *priv) cur = &adapter->bss_prio_tbl[i].bss_prio_cur; lock = &adapter->bss_prio_tbl[i].bss_prio_lock; dev_dbg(adapter->dev, "info: delete BSS priority table," - " index = %d, i = %d, head = %p, cur = %p\n", - priv->bss_index, i, head, *cur); + " bss_type = %d, bss_num = %d, i = %d," + " head = %p, cur = %p\n", + priv->bss_type, priv->bss_num, i, head, *cur); if (*cur) { spin_lock_irqsave(lock, flags); if (list_empty(head)) { diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index 84be196188cc..1a0775d19ade 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c @@ -424,8 +424,8 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) struct sk_buff *new_skb; struct mwifiex_txinfo *tx_info; - dev_dbg(priv->adapter->dev, "data: %lu BSS(%d): Data <= kernel\n", - jiffies, priv->bss_index); + dev_dbg(priv->adapter->dev, "data: %lu BSS(%d-%d): Data <= kernel\n", + jiffies, priv->bss_type, priv->bss_num); if (priv->adapter->surprise_removed) { kfree_skb(skb); @@ -458,7 +458,8 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } tx_info = MWIFIEX_SKB_TXCB(skb); - tx_info->bss_index = priv->bss_index; + tx_info->bss_num = priv->bss_num; + tx_info->bss_type = priv->bss_type; mwifiex_fill_buffer(skb); mwifiex_wmm_add_buf_txqueue(priv->adapter, skb); @@ -531,8 +532,8 @@ mwifiex_tx_timeout(struct net_device *dev) { struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); - dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_index=%d\n", - jiffies, priv->bss_index); + dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_type-num = %d-%d\n", + jiffies, priv->bss_type, priv->bss_num); mwifiex_set_trans_start(dev); priv->num_tx_timeout++; } @@ -604,18 +605,6 @@ int is_command_pending(struct mwifiex_adapter *adapter) return !is_cmd_pend_q_empty; } -/* - * This function returns the correct private structure pointer based - * upon the BSS number. - */ -struct mwifiex_private * -mwifiex_bss_index_to_priv(struct mwifiex_adapter *adapter, u8 bss_index) -{ - if (!adapter || (bss_index >= adapter->priv_num)) - return NULL; - return adapter->priv[bss_index]; -} - /* * This is the main work queue function. * diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 3186aa437f42..6712ea89ef78 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -352,7 +352,6 @@ struct mwifiex_private; struct mwifiex_private { struct mwifiex_adapter *adapter; - u8 bss_index; u8 bss_type; u8 bss_role; u8 bss_priority; @@ -884,8 +883,6 @@ mwifiex_netdev_get_priv(struct net_device *dev) return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev)); } -struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter - *adapter, u8 bss_index); int mwifiex_init_shutdown_fw(struct mwifiex_private *priv, u32 func_init_shutdown); int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8); diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c index 5e1ef7e5da4f..d7a5d7616f22 100644 --- a/drivers/net/wireless/mwifiex/sta_rx.c +++ b/drivers/net/wireless/mwifiex/sta_rx.c @@ -43,7 +43,8 @@ int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter, { int ret; struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb); - struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; + struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter, + rx_info->bss_num, rx_info->bss_type); struct rx_packet_hdr *rx_pkt_hdr; struct rxpd *local_rx_pd; int hdr_chop; @@ -124,7 +125,8 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, struct rx_packet_hdr *rx_pkt_hdr; u8 ta[ETH_ALEN]; u16 rx_pkt_type; - struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; + struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter, + rx_info->bss_num, rx_info->bss_type); if (!priv) return -1; diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c index d97facd70e88..94d31a94620a 100644 --- a/drivers/net/wireless/mwifiex/sta_tx.c +++ b/drivers/net/wireless/mwifiex/sta_tx.c @@ -136,7 +136,8 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags) return -1; tx_info = MWIFIEX_SKB_TXCB(skb); - tx_info->bss_index = priv->bss_index; + tx_info->bss_num = priv->bss_num; + tx_info->bss_type = priv->bss_type; skb_reserve(skb, sizeof(struct txpd) + INTF_HEADER_LEN); skb_push(skb, sizeof(struct txpd)); diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c index d9274a1b77ac..9a6eacc9d6f9 100644 --- a/drivers/net/wireless/mwifiex/txrx.c +++ b/drivers/net/wireless/mwifiex/txrx.c @@ -48,7 +48,8 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter, if (!priv) priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); - rx_info->bss_index = priv->bss_index; + rx_info->bss_num = priv->bss_num; + rx_info->bss_type = priv->bss_type; return mwifiex_process_sta_rx_packet(adapter, skb); } @@ -130,7 +131,8 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, return 0; tx_info = MWIFIEX_SKB_TXCB(skb); - priv = mwifiex_bss_index_to_priv(adapter, tx_info->bss_index); + priv = mwifiex_get_priv_by_id(adapter, tx_info->bss_num, + tx_info->bss_type); if (!priv) goto done; diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c index 06976f517f66..9c48f37069f7 100644 --- a/drivers/net/wireless/mwifiex/util.c +++ b/drivers/net/wireless/mwifiex/util.c @@ -159,7 +159,8 @@ int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb) return -1; rx_info = MWIFIEX_SKB_RXCB(skb); - priv = mwifiex_bss_index_to_priv(adapter, rx_info->bss_index); + priv = mwifiex_get_priv_by_id(adapter, rx_info->bss_num, + rx_info->bss_type); if (!priv) return -1; diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index 6c239c3c8249..e6a2cb127d2b 100644 --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c @@ -603,7 +603,8 @@ mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter, struct sk_buff *skb) { struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb); - struct mwifiex_private *priv = adapter->priv[tx_info->bss_index]; + struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter, + tx_info->bss_num, tx_info->bss_type); u32 tid; struct mwifiex_ra_list_tbl *ra_list; u8 ra[ETH_ALEN], tid_down; -- GitLab From f540f9f34b35d3c8a1d4b8d47ad5f00da951bfe7 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Wed, 11 Jan 2012 20:06:12 -0800 Subject: [PATCH 0109/1846] mwifiex: derive priv from net_device instead of wiphy Currently mwifiex_private pointers are derived from wiphy structures. This will always work as long as there is only one net_device associated with one wiphy. In scenarios where there are multiple net_devices associated with single wiphy, one should use net_device to derive the priv. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Avinash Patil Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 36f67da8fa4f..00f10059ecb4 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -79,7 +79,7 @@ static int mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool pairwise, const u8 *mac_addr) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); if (mwifiex_set_encode(priv, NULL, 0, key_index, 1)) { wiphy_err(wiphy, "deleting the crypto keys\n"); @@ -122,7 +122,7 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, bool enabled, int timeout) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); u32 ps_mode; if (timeout) @@ -143,7 +143,7 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool unicast, bool multicast) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); /* Return if WEP key not configured */ if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED) @@ -165,7 +165,7 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool pairwise, const u8 *mac_addr, struct key_params *params) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); if (mwifiex_set_encode(priv, params->key, params->key_len, key_index, 0)) { @@ -376,7 +376,7 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); if (priv->media_connected) { wiphy_err(wiphy, "This setting is valid only when station " @@ -1004,7 +1004,7 @@ static int mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ibss_params *params) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); int ret = 0; if (priv->bss_mode != NL80211_IFTYPE_ADHOC) { @@ -1042,7 +1042,7 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, static int mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); + struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n", priv->cfg_bssid); @@ -1280,10 +1280,7 @@ EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf); */ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev) { - struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); - - if (!priv || !dev) - return 0; + struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); #ifdef CONFIG_DEBUG_FS mwifiex_dev_debugfs_remove(priv); -- GitLab From f1249700f563b5dc541afa7e54a2d93fdffc1fb6 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Fri, 13 Jan 2012 13:53:18 +0100 Subject: [PATCH 0110/1846] mac80211: remove useless DA checking in ieee80211_rx_mgmt_probe_resp() Actually the DA field has already been checked along the rx path (in prepare_for_handlers()) and this check is therefore useless at this point. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 4345e9449d7c..b253d0adf0ad 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -853,9 +853,6 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, size_t baselen; struct ieee802_11_elems elems; - if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) - return; /* ignore ProbeResp to foreign address */ - baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; if (baselen > len) return; -- GitLab From 6ae4bb6612c675d4132bd4fcc7cac4eef46f9624 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Fri, 13 Jan 2012 16:35:05 +0100 Subject: [PATCH 0111/1846] carl9170: remove eeprom data injection option In the early days, this was a quite useful software feature for testing different regdomains and chain configurations without adding debugfs cruft into the driver. Nowadays, the driver's phy code seems to be stable and there's no need for it anymore. Therefore I decided to removed altogether. Signed-off-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/ath/carl9170/carl9170.h | 1 - drivers/net/wireless/ath/carl9170/fw.c | 33 -------------------- drivers/net/wireless/ath/carl9170/main.c | 4 --- 3 files changed, 38 deletions(-) diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h index 6cfbb419e2f6..f0f44c30b2f7 100644 --- a/drivers/net/wireless/ath/carl9170/carl9170.h +++ b/drivers/net/wireless/ath/carl9170/carl9170.h @@ -593,7 +593,6 @@ int carl9170_get_noisefloor(struct ar9170 *ar); /* FW */ int carl9170_parse_firmware(struct ar9170 *ar); -int carl9170_fw_fix_eeprom(struct ar9170 *ar); extern struct ieee80211_rate __carl9170_ratetable[]; extern int modparam_noht; diff --git a/drivers/net/wireless/ath/carl9170/fw.c b/drivers/net/wireless/ath/carl9170/fw.c index 3de61adacd34..cffde8d9a521 100644 --- a/drivers/net/wireless/ath/carl9170/fw.c +++ b/drivers/net/wireless/ath/carl9170/fw.c @@ -389,39 +389,6 @@ carl9170_find_fw_desc(struct ar9170 *ar, const __u8 *fw_data, const size_t len) return (void *)&fw_data[scan - found]; } -int carl9170_fw_fix_eeprom(struct ar9170 *ar) -{ - const struct carl9170fw_fix_desc *fix_desc = NULL; - unsigned int i, n, off; - u32 *data = (void *)&ar->eeprom; - - fix_desc = carl9170_fw_find_desc(ar, FIX_MAGIC, - sizeof(*fix_desc), CARL9170FW_FIX_DESC_CUR_VER); - - if (!fix_desc) - return 0; - - n = (le16_to_cpu(fix_desc->head.length) - sizeof(*fix_desc)) / - sizeof(struct carl9170fw_fix_entry); - - for (i = 0; i < n; i++) { - off = le32_to_cpu(fix_desc->data[i].address) - - AR9170_EEPROM_START; - - if (off >= sizeof(struct ar9170_eeprom) || (off & 3)) { - dev_err(&ar->udev->dev, "Skip invalid entry %d\n", i); - continue; - } - - data[off / sizeof(*data)] &= - le32_to_cpu(fix_desc->data[i].mask); - data[off / sizeof(*data)] |= - le32_to_cpu(fix_desc->data[i].value); - } - - return 0; -} - int carl9170_parse_firmware(struct ar9170 *ar) { const struct carl9170fw_desc_head *fw_desc = NULL; diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index 4dfb0290b43a..6ee7c55f75a8 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c @@ -1934,10 +1934,6 @@ int carl9170_register(struct ar9170 *ar) if (err) return err; - err = carl9170_fw_fix_eeprom(ar); - if (err) - return err; - err = carl9170_parse_eeprom(ar); if (err) return err; -- GitLab From f99725777e0f57e71f37191eee5f10071ed7b423 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Sat, 14 Jan 2012 11:42:43 +0100 Subject: [PATCH 0112/1846] ath5k: claim support for IBSS RSN Disable group keys programming when using IBSS RSN. Keys will be managed using software. In this way IBSS RSN can correctly work. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/base.c | 3 +++ drivers/net/wireless/ath/ath5k/mac80211-ops.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index d366dadcf86e..4ab835f08a43 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -2442,6 +2442,9 @@ ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops) BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_MESH_POINT); + /* SW support for IBSS_RSN is provided by mac80211 */ + hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; + /* both antennas can be configured as RX or TX */ hw->wiphy->available_antennas_tx = 0x3; hw->wiphy->available_antennas_rx = 0x3; diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c index 6ed4c0717e3e..af4c7ecb4b30 100644 --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c @@ -483,6 +483,14 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, if (ath5k_modparam_nohwcrypt) return -EOPNOTSUPP; + if (vif->type == NL80211_IFTYPE_ADHOC && + (key->cipher == WLAN_CIPHER_SUITE_TKIP || + key->cipher == WLAN_CIPHER_SUITE_CCMP) && + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { + /* don't program group keys when using IBSS_RSN */ + return -EOPNOTSUPP; + } + switch (key->cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: -- GitLab From 8ae746543c8370fd04c28aaf8f185c1687b0e694 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:38 -0800 Subject: [PATCH 0113/1846] brcm80211: Use normal DEBUG define Current CONFIG_BRCMDBG flag when enabled does not necessarily enable proper pr_debug output when DEBUG is not also enabled. Remove BCMDBG define and just use DEBUG instead. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/Makefile | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 4 +- .../wireless/brcm80211/brcmfmac/dhd_common.c | 10 +-- .../net/wireless/brcm80211/brcmfmac/dhd_dbg.h | 6 +- .../wireless/brcm80211/brcmfmac/dhd_linux.c | 4 +- .../wireless/brcm80211/brcmfmac/dhd_sdio.c | 86 +++++++++---------- .../wireless/brcm80211/brcmfmac/wl_cfg80211.h | 6 +- .../net/wireless/brcm80211/brcmsmac/aiutils.c | 4 +- .../net/wireless/brcm80211/brcmsmac/ampdu.c | 2 +- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 8 +- .../wireless/brcm80211/brcmsmac/mac80211_if.c | 18 ++-- .../wireless/brcm80211/brcmsmac/mac80211_if.h | 2 +- .../net/wireless/brcm80211/brcmsmac/main.c | 42 ++++----- .../net/wireless/brcm80211/brcmsmac/main.h | 2 +- .../net/wireless/brcm80211/brcmutil/utils.c | 4 +- .../wireless/brcm80211/include/brcmu_utils.h | 4 +- 16 files changed, 102 insertions(+), 102 deletions(-) diff --git a/drivers/net/wireless/brcm80211/Makefile b/drivers/net/wireless/brcm80211/Makefile index f41c047eca82..b987920e982e 100644 --- a/drivers/net/wireless/brcm80211/Makefile +++ b/drivers/net/wireless/brcm80211/Makefile @@ -16,7 +16,7 @@ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # common flags -subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG +subdir-ccflags-$(CONFIG_BRCMDBG) += -DDEBUG obj-$(CONFIG_BRCMUTIL) += brcmutil/ obj-$(CONFIG_BRCMFMAC) += brcmfmac/ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index e58ea40a75b0..07686a748d3c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -644,9 +644,9 @@ extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx); extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf, uint len); -#ifdef BCMDBG +#ifdef DEBUG extern int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size); -#endif /* BCMDBG */ +#endif /* DEBUG */ extern int brcmf_ifname2idx(struct brcmf_pub *drvr, char *name); extern int brcmf_c_host_event(struct brcmf_pub *drvr, int *idx, diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index a51d8f5d36fc..9385c84646eb 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c @@ -38,7 +38,7 @@ #define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \ offsetof(struct brcmf_pkt_filter_pattern_le, mask_and_pattern) -#ifdef BCMDBG +#ifdef DEBUG static const char brcmf_version[] = "Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on " __DATE__ " at " __TIME__; @@ -133,7 +133,7 @@ bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, return p != NULL; } -#ifdef BCMDBG +#ifdef DEBUG static void brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) { @@ -430,7 +430,7 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) brcmf_dbg(EVENT, "\n"); } } -#endif /* BCMDBG */ +#endif /* DEBUG */ int brcmf_c_host_event(struct brcmf_pub *drvr, int *ifidx, void *pktdata, @@ -518,9 +518,9 @@ brcmf_c_host_event(struct brcmf_pub *drvr, int *ifidx, void *pktdata, break; } -#ifdef BCMDBG +#ifdef DEBUG brcmf_c_show_host_event(event, event_data); -#endif /* BCMDBG */ +#endif /* DEBUG */ return 0; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h index bb26ee36bc68..8b2060b578d9 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h @@ -32,7 +32,7 @@ #define BRCMF_BTA_VAL 0x1000 #define BRCMF_ISCAN_VAL 0x2000 -#if defined(BCMDBG) +#if defined(DEBUG) #define brcmf_dbg(level, fmt, ...) \ do { \ @@ -56,7 +56,7 @@ do { \ #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL) #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL) -#else /* (defined BCMDBG) || (defined BCMDBG) */ +#else /* (defined DEBUG) || (defined DEBUG) */ #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__) @@ -66,7 +66,7 @@ do { \ #define BRCMF_BYTES_ON() 0 #define BRCMF_GLOM_ON() 0 -#endif /* defined(BCMDBG) */ +#endif /* defined(DEBUG) */ extern int brcmf_msg_level; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index c3980c50a997..16fd1ab35408 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1146,7 +1146,7 @@ int brcmf_netdev_wait_pend8021x(struct net_device *ndev) return pend; } -#ifdef BCMDBG +#ifdef DEBUG int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size) { int ret = 0; @@ -1180,4 +1180,4 @@ int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size) return ret; } -#endif /* BCMDBG */ +#endif /* DEBUG */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index f7eeee1dcdb6..7157a60c94b2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -40,7 +40,7 @@ #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ -#ifdef BCMDBG +#ifdef DEBUG #define BRCMF_TRAP_INFO_SIZE 80 @@ -84,7 +84,7 @@ struct rte_console { char cbuf[CBUF_LEN]; }; -#endif /* BCMDBG */ +#endif /* DEBUG */ #include #include "dhd_bus.h" @@ -416,7 +416,7 @@ struct sdpcmd_regs { u16 PAD[0x80]; }; -#ifdef BCMDBG +#ifdef DEBUG /* Device console log buffer state */ struct brcmf_console { uint count; /* Poll interval msec counter */ @@ -426,7 +426,7 @@ struct brcmf_console { u8 *buf; /* Log buffer (host copy) */ uint last; /* Last buffer read index */ }; -#endif /* BCMDBG */ +#endif /* DEBUG */ struct sdpcm_shared { u32 flags; @@ -507,11 +507,11 @@ struct brcmf_sdio { uint polltick; /* Tick counter */ uint pollcnt; /* Count of active polls */ -#ifdef BCMDBG +#ifdef DEBUG uint console_interval; struct brcmf_console console; /* Console output polling support */ uint console_addr; /* Console address from shared struct */ -#endif /* BCMDBG */ +#endif /* DEBUG */ uint regfails; /* Count of R_REG failures */ @@ -587,10 +587,10 @@ struct brcmf_sdio { #define CLK_PENDING 2 /* Not used yet */ #define CLK_AVAIL 3 -#ifdef BCMDBG +#ifdef DEBUG static int qcount[NUMPRIO]; static int tx_packets[NUMPRIO]; -#endif /* BCMDBG */ +#endif /* DEBUG */ #define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ @@ -764,12 +764,12 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) bus->clkstate = CLK_AVAIL; brcmf_dbg(INFO, "CLKCTL: turned ON\n"); -#if defined(BCMDBG) +#if defined(DEBUG) if (bus->alp_only != true) { if (SBSDIO_ALPONLY(clkctl)) brcmf_dbg(ERROR, "HT Clock should be on\n"); } -#endif /* defined (BCMDBG) */ +#endif /* defined (DEBUG) */ bus->activity = true; } else { @@ -814,9 +814,9 @@ static int brcmf_sdbrcm_sdclk(struct brcmf_sdio *bus, bool on) /* Transition SD and backplane clock readiness */ static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok) { -#ifdef BCMDBG +#ifdef DEBUG uint oldstate = bus->clkstate; -#endif /* BCMDBG */ +#endif /* DEBUG */ brcmf_dbg(TRACE, "Enter\n"); @@ -861,9 +861,9 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok) brcmf_sdbrcm_wd_timer(bus, 0); break; } -#ifdef BCMDBG +#ifdef DEBUG brcmf_dbg(INFO, "%d -> %d\n", oldstate, bus->clkstate); -#endif /* BCMDBG */ +#endif /* DEBUG */ return 0; } @@ -1279,7 +1279,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) } return 0; } -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_GLOM_ON()) { printk(KERN_DEBUG "SUPERFRAME:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -1362,7 +1362,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) check = get_unaligned_le16(dptr + sizeof(u16)); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_GLOM_ON()) { printk(KERN_DEBUG "subframe:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -1433,7 +1433,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) } rxseq++; -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { printk(KERN_DEBUG "Rx Subframe Data:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -1457,7 +1457,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) continue; } -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_GLOM_ON()) { brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", bus->glom.qlen, pfirst, pfirst->data, @@ -1467,7 +1467,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) pfirst->data, min_t(int, pfirst->len, 32)); } -#endif /* BCMDBG */ +#endif /* DEBUG */ } /* sent any remaining packets up */ if (bus->glom.qlen) { @@ -1584,7 +1584,7 @@ brcmf_sdbrcm_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff) gotpkt: -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { printk(KERN_DEBUG "RxCtrl:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len); @@ -1818,7 +1818,7 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) } bus->tx_max = txmax; -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { printk(KERN_DEBUG "Rx Data:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -1865,7 +1865,7 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) brcmf_sdbrcm_rxfail(bus, true, true); continue; } -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_BYTES_ON() || BRCMF_HDRS_ON()) { printk(KERN_DEBUG "RxHdr:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -2024,7 +2024,7 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) skb_push(pkt, BRCMF_FIRSTREAD); memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD); -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { printk(KERN_DEBUG "Rx Data:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -2038,7 +2038,7 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", len); -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_GLOM_ON()) { printk(KERN_DEBUG "Glom Data:\n"); print_hex_dump_bytes("", @@ -2078,13 +2078,13 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) down(&bus->sdsem); } rxcount = maxframes - rxleft; -#ifdef BCMDBG +#ifdef DEBUG /* Message if we hit the limit */ if (!rxleft) brcmf_dbg(DATA, "hit rx limit of %d frames\n", maxframes); else -#endif /* BCMDBG */ +#endif /* DEBUG */ brcmf_dbg(DATA, "processed %d frames\n", rxcount); /* Back off rxseq if awaiting rtx, update rx_seq */ if (bus->rxskip) @@ -2176,7 +2176,7 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); -#ifdef BCMDBG +#ifdef DEBUG tx_packets[pkt->priority]++; if (BRCMF_BYTES_ON() && (((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || @@ -2410,7 +2410,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) int err; u8 clkctl, devctl = 0; -#ifdef BCMDBG +#ifdef DEBUG /* Check for inconsistent device control */ devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); @@ -2418,7 +2418,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; } -#endif /* BCMDBG */ +#endif /* DEBUG */ /* Read CSR, if clock on switch to AVAIL, else ignore */ clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, @@ -2701,7 +2701,7 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt) brcmf_txflowcontrol(bus->sdiodev->dev, 0, ON); } -#ifdef BCMDBG +#ifdef DEBUG if (pktq_plen(&bus->txq, prec) > qcount[prec]) qcount[prec] = pktq_plen(&bus->txq, prec); #endif @@ -2774,7 +2774,7 @@ brcmf_sdbrcm_membytes(struct brcmf_sdio *bus, bool write, u32 address, u8 *data, return bcmerror; } -#ifdef BCMDBG +#ifdef DEBUG #define CONSOLE_LINE_MAX 192 static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus) @@ -2852,7 +2852,7 @@ static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus) return 0; } -#endif /* BCMDBG */ +#endif /* DEBUG */ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) { @@ -2982,7 +2982,7 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) } if (ret == -1) { -#ifdef BCMDBG +#ifdef DEBUG if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { printk(KERN_DEBUG "Tx Frame:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -3096,9 +3096,9 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus) u8 *vbuffer; u32 varsizew; __le32 varsizew_le; -#ifdef BCMDBG +#ifdef DEBUG char *nvram_ularray; -#endif /* BCMDBG */ +#endif /* DEBUG */ /* Even if there are no vars are to be written, we still need to set the ramsize. */ @@ -3115,7 +3115,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus) /* Write the vars list */ bcmerror = brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize); -#ifdef BCMDBG +#ifdef DEBUG /* Verify NVRAM bytes */ brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); nvram_ularray = kmalloc(varsize, GFP_ATOMIC); @@ -3142,7 +3142,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus) brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n"); kfree(nvram_ularray); -#endif /* BCMDBG */ +#endif /* DEBUG */ kfree(vbuffer); } @@ -3569,9 +3569,9 @@ void brcmf_sdbrcm_isr(void *arg) static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) { -#ifdef BCMDBG +#ifdef DEBUG struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev); -#endif /* BCMDBG */ +#endif /* DEBUG */ brcmf_dbg(TIMER, "Enter\n"); @@ -3616,7 +3616,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) /* Update interrupt tracking */ bus->lastintrs = bus->intrcount; } -#ifdef BCMDBG +#ifdef DEBUG /* Poll for console output periodically */ if (bus_if->state == BRCMF_BUS_DATA && bus->console_interval != 0) { @@ -3630,7 +3630,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) bus->console_interval = 0; } } -#endif /* BCMDBG */ +#endif /* DEBUG */ /* On idle timeout clear activity flag and/or turn off clock */ if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) { @@ -3721,11 +3721,11 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva) if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); -#ifdef BCMDBG +#ifdef DEBUG printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); -#endif /* BCMDBG */ +#endif /* DEBUG */ /* * Force PLL off until brcmf_sdio_chip_attach() diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h index a613b49cb13f..69a48729a728 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h @@ -42,7 +42,7 @@ do { \ } \ } while (0) -#if (defined BCMDBG) +#if (defined DEBUG) #define WL_INFO(fmt, args...) \ do { \ if (brcmf_dbg_level & WL_DBG_INFO) { \ @@ -83,12 +83,12 @@ do { \ } \ } while (0) -#else /* (defined BCMDBG) */ +#else /* (defined DEBUG) */ #define WL_INFO(fmt, args...) #define WL_TRACE(fmt, args...) #define WL_SCAN(fmt, args...) #define WL_CONN(fmt, args...) -#endif /* (defined BCMDBG) */ +#endif /* (defined DEBUG) */ #define WL_NUM_SCAN_MAX 1 #define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index ab9bb11abfbb..c93ea35bceec 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -326,11 +326,11 @@ #define PCI_FORCEHT(sih) (PCIE(sih) && (ai_get_chip_id(sih) == BCM4716_CHIP_ID)) -#ifdef BCMDBG +#ifdef DEBUG #define SI_MSG(fmt, ...) pr_debug(fmt, ##__VA_ARGS__) #else #define SI_MSG(fmt, ...) no_printk(fmt, ##__VA_ARGS__) -#endif /* BCMDBG */ +#endif /* DEBUG */ #define GOODCOREADDR(x, b) \ (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index 90911eec0cf5..d89dcb14cb6d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c @@ -915,7 +915,7 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(p); struct wiphy *wiphy = wlc->wiphy; -#ifdef BCMDBG +#ifdef DEBUG u8 hole[AMPDU_MAX_MPDU]; memset(hole, 0, sizeof(hole)); #endif diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 2e90a9a16ed6..11054ae9d4f6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -177,7 +177,7 @@ #define BCMEXTRAHDROOM 172 /* debug/trace */ -#ifdef BCMDBG +#ifdef DEBUG #define DMA_ERROR(fmt, ...) \ do { \ if (*di->msg_level & 1) \ @@ -193,7 +193,7 @@ do { \ no_printk(fmt, ##__VA_ARGS__) #define DMA_TRACE(fmt, ...) \ no_printk(fmt, ##__VA_ARGS__) -#endif /* BCMDBG */ +#endif /* DEBUG */ #define DMA_NONE(fmt, ...) \ no_printk(fmt, ##__VA_ARGS__) @@ -968,7 +968,7 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) pktcnt++; } -#ifdef BCMDBG +#ifdef DEBUG if (resid > 0) { uint cur; cur = @@ -979,7 +979,7 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) DMA_ERROR("rxin %d rxout %d, hw_curr %d\n", di->rxin, di->rxout, cur); } -#endif /* BCMDBG */ +#endif /* DEBUG */ if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { DMA_ERROR("%s: bad frame length (%d)\n", diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 448ab9c4eb47..04ba9a878f40 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -96,10 +96,10 @@ static struct bcma_device_id brcms_coreid_table[] = { }; MODULE_DEVICE_TABLE(bcma, brcms_coreid_table); -#ifdef BCMDBG +#ifdef DEBUG static int msglevel = 0xdeadbeef; module_param(msglevel, int, 0); -#endif /* BCMDBG */ +#endif /* DEBUG */ static struct ieee80211_channel brcms_2ghz_chantable[] = { CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), @@ -857,7 +857,7 @@ static void brcms_free(struct brcms_info *wl) /* free timers */ for (t = wl->timers; t; t = next) { next = t->next; -#ifdef BCMDBG +#ifdef DEBUG kfree(t->name); #endif kfree(t); @@ -1177,10 +1177,10 @@ static int __init brcms_module_init(void) { int error = -ENODEV; -#ifdef BCMDBG +#ifdef DEBUG if (msglevel != 0xdeadbeef) brcm_msg_level = msglevel; -#endif /* BCMDBG */ +#endif /* DEBUG */ error = bcma_driver_register(&brcms_bcma_driver); printk(KERN_ERR "%s: register returned %d\n", __func__, error); @@ -1367,7 +1367,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl, t->next = wl->timers; wl->timers = t; -#ifdef BCMDBG +#ifdef DEBUG t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC); if (t->name) strcpy(t->name, name); @@ -1386,7 +1386,7 @@ void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic) { struct ieee80211_hw *hw = t->wl->pub->ieee_hw; -#ifdef BCMDBG +#ifdef DEBUG if (t->set) wiphy_err(hw->wiphy, "%s: Already set. Name: %s, per %d\n", __func__, t->name, periodic); @@ -1431,7 +1431,7 @@ void brcms_free_timer(struct brcms_timer *t) if (wl->timers == t) { wl->timers = wl->timers->next; -#ifdef BCMDBG +#ifdef DEBUG kfree(t->name); #endif kfree(t); @@ -1443,7 +1443,7 @@ void brcms_free_timer(struct brcms_timer *t) while (tmp) { if (tmp->next == t) { tmp->next = t->next; -#ifdef BCMDBG +#ifdef DEBUG kfree(t->name); #endif kfree(t); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h index 8f60419c37bf..9358bd5ebd35 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h @@ -40,7 +40,7 @@ struct brcms_timer { bool periodic; bool set; /* indicates if timer is active */ struct brcms_timer *next; /* for freeing on unload */ -#ifdef BCMDBG +#ifdef DEBUG char *name; /* Description of the timer */ #endif }; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index f7ed34034f88..3ae07bb9cc61 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -293,11 +293,11 @@ const u8 prio2fifo[NUMPRIO] = { /* debug/trace */ uint brcm_msg_level = -#if defined(BCMDBG) +#if defined(DEBUG) LOG_ERROR_VAL; #else 0; -#endif /* BCMDBG */ +#endif /* DEBUG */ /* TX FIFO number to WME/802.1E Access Category */ static const u8 wme_fifo2ac[] = { @@ -342,14 +342,14 @@ static const u16 xmtfifo_sz[][NFIFO] = { {9, 58, 22, 14, 14, 5}, }; -#ifdef BCMDBG +#ifdef DEBUG static const char * const fifo_names[] = { "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; #else static const char fifo_names[6][0]; #endif -#ifdef BCMDBG +#ifdef DEBUG /* pointer to most recently allocated wl/wlc */ static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); #endif @@ -3075,30 +3075,30 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc) { int i; struct macstat macstats; -#ifdef BCMDBG +#ifdef DEBUG u16 delta; u16 rxf0ovfl; u16 txfunfl[NFIFO]; -#endif /* BCMDBG */ +#endif /* DEBUG */ /* if driver down, make no sense to update stats */ if (!wlc->pub->up) return; -#ifdef BCMDBG +#ifdef DEBUG /* save last rx fifo 0 overflow count */ rxf0ovfl = wlc->core->macstat_snapshot->rxf0ovfl; /* save last tx fifo underflow count */ for (i = 0; i < NFIFO; i++) txfunfl[i] = wlc->core->macstat_snapshot->txfunfl[i]; -#endif /* BCMDBG */ +#endif /* DEBUG */ /* Read mac stats from contiguous shared memory */ brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, &macstats, sizeof(struct macstat), OBJADDR_SHM_SEL); -#ifdef BCMDBG +#ifdef DEBUG /* check for rx fifo 0 overflow */ delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl); if (delta) @@ -3114,7 +3114,7 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc) wiphy_err(wlc->wiphy, "wl%d: %u tx fifo %d underflows!" "\n", wlc->pub->unit, delta, i); } -#endif /* BCMDBG */ +#endif /* DEBUG */ /* merge counters from dma module */ for (i = 0; i < NFIFO; i++) { @@ -5765,7 +5765,7 @@ int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, return -ENODATA; } -#ifdef BCMDBG +#ifdef DEBUG static const char * const supr_reason[] = { "None", "PMQ Entry", "Flush request", "Previous frag failure", "Channel mismatch", @@ -5790,11 +5790,11 @@ static void brcms_c_print_txs_status(u16 s) printk(KERN_DEBUG " [1] %d acked\n", ((s & TX_STATUS_ACK_RCV) ? 1 : 0)); } -#endif /* BCMDBG */ +#endif /* DEBUG */ void brcms_c_print_txstatus(struct tx_status *txs) { -#if defined(BCMDBG) +#if defined(DEBUG) u16 s = txs->status; u16 ackphyrxsh = txs->ackphyrxsh; @@ -5814,7 +5814,7 @@ void brcms_c_print_txstatus(struct tx_status *txs) printk(KERN_DEBUG "RxAckSQ: %04x", (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); printk(KERN_DEBUG "\n"); -#endif /* defined(BCMDBG) */ +#endif /* defined(DEBUG) */ } bool brcms_c_chipmatch(u16 vendor, u16 device) @@ -5837,7 +5837,7 @@ bool brcms_c_chipmatch(u16 vendor, u16 device) return false; } -#if defined(BCMDBG) +#if defined(DEBUG) void brcms_c_print_txdesc(struct d11txh *txh) { u16 mtcl = le16_to_cpu(txh->MacTxControlLow); @@ -5919,9 +5919,9 @@ void brcms_c_print_txdesc(struct d11txh *txh) (u8 *)&rts, sizeof(txh->rts_frame)); printk(KERN_DEBUG "\n"); } -#endif /* defined(BCMDBG) */ +#endif /* defined(DEBUG) */ -#if defined(BCMDBG) +#if defined(DEBUG) static int brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, int len) @@ -5975,9 +5975,9 @@ brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, return (int)(p - buf); } -#endif /* defined(BCMDBG) */ +#endif /* defined(DEBUG) */ -#if defined(BCMDBG) +#if defined(DEBUG) void brcms_c_print_rxh(struct d11rxhdr *rxh) { u16 len = rxh->RxFrameSize; @@ -6016,7 +6016,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) (macstatus2 & RXS_AGGTYPE_MASK)); printk(KERN_DEBUG "RxTSFTime: %04x\n", rxh->RxTSFTime); } -#endif /* defined(BCMDBG) */ +#endif /* defined(DEBUG) */ u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) { @@ -8346,7 +8346,7 @@ brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit, wlc->wiphy = wl->wiphy; pub = wlc->pub; -#if defined(BCMDBG) +#if defined(DEBUG) wlc_info_dbg = wlc; #endif diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index adb136ec1f04..84a2a0d9dd38 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -648,7 +648,7 @@ extern void brcms_c_print_txstatus(struct tx_status *txs); extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, uint *blocks); -#if defined(BCMDBG) +#if defined(DEBUG) extern void brcms_c_print_txdesc(struct d11txh *txh); #else #define brcms_c_print_txdesc(a) diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index b7537f70a795..e25fb2da8e66 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -240,7 +240,7 @@ struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, } EXPORT_SYMBOL(brcmu_pktq_mdeq); -#if defined(BCMDBG) +#if defined(DEBUG) /* pretty hex print a pkt buffer chain */ void brcmu_prpkt(const char *msg, struct sk_buff *p0) { @@ -253,4 +253,4 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); } EXPORT_SYMBOL(brcmu_prpkt); -#endif /* defined(BCMDBG) */ +#endif /* defined(DEBUG) */ diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index ad249a0b4730..0cde38aa63f2 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h @@ -176,10 +176,10 @@ struct ipv4_addr; /* externs */ /* format/print */ -#ifdef BCMDBG +#ifdef DEBUG extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); #else #define brcmu_prpkt(a, b) -#endif /* BCMDBG */ +#endif /* DEBUG */ #endif /* _BRCMU_UTILS_H_ */ -- GitLab From d6400c29abcd218bcc9be5d09f76e0770e25face Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:39 -0800 Subject: [PATCH 0114/1846] brcmfmac: Convert printk(KERN_DEBUG to pr_debug Allow dynamic debugging. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h index 8b2060b578d9..f5ca9fc526ed 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h @@ -39,13 +39,13 @@ do { \ if (BRCMF_ERROR_VAL == BRCMF_##level##_VAL) { \ if (brcmf_msg_level & BRCMF_##level##_VAL) { \ if (net_ratelimit()) \ - printk(KERN_DEBUG "%s: " fmt, \ - __func__, ##__VA_ARGS__); \ + pr_debug("%s: " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } else { \ if (brcmf_msg_level & BRCMF_##level##_VAL) { \ - printk(KERN_DEBUG "%s: " fmt, \ - __func__, ##__VA_ARGS__); \ + pr_debug("%s: " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } \ } while (0) -- GitLab From 1e02382979dd422e3b1bdb45545a0699497e3692 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:40 -0800 Subject: [PATCH 0115/1846] brcm80211: Add and use brcmX_dbg_dump_hex Reduce the number of #ifdef DEBUG uses by adding a dbg_hex_dump routine which has the appropriate #ifdef DEBUG test. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/dhd_dbg.h | 6 + .../wireless/brcm80211/brcmfmac/dhd_sdio.c | 141 ++++++------------ .../net/wireless/brcm80211/brcmutil/utils.c | 18 +++ .../wireless/brcm80211/include/brcmu_utils.h | 11 ++ 4 files changed, 84 insertions(+), 92 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h index f5ca9fc526ed..a2c4576cf9ff 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h @@ -68,6 +68,12 @@ do { \ #endif /* defined(DEBUG) */ +#define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \ +do { \ + if (test) \ + brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \ +} while (0) + extern int brcmf_msg_level; #endif /* _BRCMF_DBG_H_ */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 7157a60c94b2..4ab1023352a2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1279,13 +1279,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) } return 0; } -#ifdef DEBUG - if (BRCMF_GLOM_ON()) { - printk(KERN_DEBUG "SUPERFRAME:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - pfirst->data, min_t(int, pfirst->len, 48)); - } -#endif + + brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), + pfirst->data, min_t(int, pfirst->len, 48), + "SUPERFRAME:\n"); /* Validate the superframe header */ dptr = (u8 *) (pfirst->data); @@ -1362,13 +1359,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) check = get_unaligned_le16(dptr + sizeof(u16)); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); -#ifdef DEBUG - if (BRCMF_GLOM_ON()) { - printk(KERN_DEBUG "subframe:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - dptr, 32); - } -#endif + brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), + dptr, 32, "subframe:\n"); if ((u16)~(sublen ^ check)) { brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n", @@ -1433,13 +1425,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) } rxseq++; -#ifdef DEBUG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - printk(KERN_DEBUG "Rx Subframe Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - dptr, dlen); - } -#endif + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(), + dptr, dlen, "Rx Subframe Data:\n"); __skb_trim(pfirst, sublen); skb_pull(pfirst, doff); @@ -1457,17 +1444,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) continue; } -#ifdef DEBUG - if (BRCMF_GLOM_ON()) { - brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", - bus->glom.qlen, pfirst, pfirst->data, - pfirst->len, pfirst->next, - pfirst->prev); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - pfirst->data, - min_t(int, pfirst->len, 32)); - } -#endif /* DEBUG */ + brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), + pfirst->data, + min_t(int, pfirst->len, 32), + "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", + bus->glom.qlen, pfirst, pfirst->data, + pfirst->len, pfirst->next, + pfirst->prev); } /* sent any remaining packets up */ if (bus->glom.qlen) { @@ -1584,12 +1567,8 @@ brcmf_sdbrcm_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff) gotpkt: -#ifdef DEBUG - if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { - printk(KERN_DEBUG "RxCtrl:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len); - } -#endif + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_CTL_ON(), + bus->rxctl, len, "RxCtrl:\n"); /* Point to valid data and indicate its length */ bus->rxctl += doff; @@ -1818,17 +1797,13 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) } bus->tx_max = txmax; -#ifdef DEBUG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - printk(KERN_DEBUG "Rx Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - rxbuf, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "RxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - bus->rxhdr, SDPCM_HDRLEN); - } -#endif + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(), + rxbuf, len, "Rx Data:\n"); + brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() && + BRCMF_DATA_ON()) && + BRCMF_HDRS_ON(), + bus->rxhdr, SDPCM_HDRLEN, + "RxHdr:\n"); if (chan == SDPCM_CONTROL_CHANNEL) { brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n", @@ -1865,13 +1840,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) brcmf_sdbrcm_rxfail(bus, true, true); continue; } -#ifdef DEBUG - if (BRCMF_BYTES_ON() || BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "RxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - bus->rxhdr, SDPCM_HDRLEN); - } -#endif + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() || BRCMF_HDRS_ON(), + bus->rxhdr, SDPCM_HDRLEN, "RxHdr:\n"); + /* Extract hardware header fields */ len = get_unaligned_le16(bus->rxhdr); @@ -2024,13 +1995,8 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) skb_push(pkt, BRCMF_FIRSTREAD); memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD); -#ifdef DEBUG - if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { - printk(KERN_DEBUG "Rx Data:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - pkt->data, len); - } -#endif + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(), + pkt->data, len, "Rx Data:\n"); deliver: /* Save superframe descriptor and allocate packet frame */ @@ -2038,14 +2004,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", len); -#ifdef DEBUG - if (BRCMF_GLOM_ON()) { - printk(KERN_DEBUG "Glom Data:\n"); - print_hex_dump_bytes("", - DUMP_PREFIX_OFFSET, - pkt->data, len); - } -#endif + brcmf_dbg_hex_dump(BRCMF_GLOM_ON(), + pkt->data, len, + "Glom Data:\n"); __skb_trim(pkt, len); skb_pull(pkt, SDPCM_HDRLEN); bus->glomd = pkt; @@ -2178,16 +2139,18 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, #ifdef DEBUG tx_packets[pkt->priority]++; - if (BRCMF_BYTES_ON() && - (((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || - (BRCMF_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) { - printk(KERN_DEBUG "Tx Frame:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "TxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, min_t(u16, len, 16)); - } + + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && + ((BRCMF_CTL_ON() && chan == SDPCM_CONTROL_CHANNEL) || + (BRCMF_DATA_ON() && chan != SDPCM_CONTROL_CHANNEL)), + frame, len, "Tx Frame:\n"); + brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() && + ((BRCMF_CTL_ON() && + chan == SDPCM_CONTROL_CHANNEL) || + (BRCMF_DATA_ON() && + chan != SDPCM_CONTROL_CHANNEL))) && + BRCMF_HDRS_ON(), + frame, min_t(u16, len, 16), "TxHdr:\n"); #endif /* Raise len to next SDIO block to eliminate tail command */ @@ -2982,17 +2945,11 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) } if (ret == -1) { -#ifdef DEBUG - if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { - printk(KERN_DEBUG "Tx Frame:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, len); - } else if (BRCMF_HDRS_ON()) { - printk(KERN_DEBUG "TxHdr:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - frame, min_t(u16, len, 16)); - } -#endif + brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_CTL_ON(), + frame, len, "Tx Frame:\n"); + brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() && BRCMF_CTL_ON()) && + BRCMF_HDRS_ON(), + frame, min_t(u16, len, 16), "TxHdr:\n"); do { ret = brcmf_tx_frame(bus, frame, len); diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index e25fb2da8e66..2207eaa34f8e 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -253,4 +253,22 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); } EXPORT_SYMBOL(brcmu_prpkt); + +void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + pr_debug("%pV", &vaf); + + va_end(args); + + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size); +} +EXPORT_SYMBOL(brcmu_dbg_hex_dump); #endif /* defined(DEBUG) */ diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h index 0cde38aa63f2..477b92ad3d62 100644 --- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h +++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h @@ -182,4 +182,15 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); #define brcmu_prpkt(a, b) #endif /* DEBUG */ +#ifdef DEBUG +extern __printf(3, 4) +void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...); +#else +__printf(3, 4) +static inline +void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...) +{ +} +#endif + #endif /* _BRCMU_UTILS_H_ */ -- GitLab From 8fb1eb8b221f1cf81128b7f681b5a5112bfcd3a2 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:41 -0800 Subject: [PATCH 0116/1846] brcmfmac: Remove useless #ifdef DEBUG This doesn't do anything anymore. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 4ab1023352a2..79230e7edb3c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2039,13 +2039,11 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) down(&bus->sdsem); } rxcount = maxframes - rxleft; -#ifdef DEBUG /* Message if we hit the limit */ if (!rxleft) brcmf_dbg(DATA, "hit rx limit of %d frames\n", maxframes); else -#endif /* DEBUG */ brcmf_dbg(DATA, "processed %d frames\n", rxcount); /* Back off rxseq if awaiting rtx, update rx_seq */ if (bus->rxskip) -- GitLab From 18aad4f8e11530fd7e41d0faea0752c3a0ce799c Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:42 -0800 Subject: [PATCH 0117/1846] brcm80211: Convert printk(KERN_DEBUG to pr_debug Use pr_debug to allow dynamic debugging to work. Move an #endif to allow brcmf_dbg_hex_dump to be outside the #if/#endif block. Move a const char* declaration to be inside a pr_debug so the function doesn't need a #if/#endif block. Don't use temporaries in debugging functions so the code can be optimized away. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- .../wireless/brcm80211/brcmfmac/dhd_common.c | 4 +- .../wireless/brcm80211/brcmfmac/dhd_sdio.c | 11 +- .../net/wireless/brcm80211/brcmsmac/main.c | 147 ++++++++---------- .../net/wireless/brcm80211/brcmsmac/main.h | 4 +- .../wireless/brcm80211/brcmsmac/phy/phy_n.c | 3 +- .../net/wireless/brcm80211/brcmutil/utils.c | 2 +- 6 files changed, 78 insertions(+), 93 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index 9385c84646eb..1c75ea887ac3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c @@ -399,10 +399,10 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) p = (char *)&buf[sizeof(struct msgtrace_hdr)]; while ((s = strstr(p, "\n")) != NULL) { *s = '\0'; - printk(KERN_DEBUG"%s\n", p); + pr_debug("%s\n", p); p = s + 1; } - printk(KERN_DEBUG "%s\n", p); + pr_debug("%s\n", p); /* Reset datalen to avoid display below */ datalen = 0; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 79230e7edb3c..91ec0235047a 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2137,6 +2137,7 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, #ifdef DEBUG tx_packets[pkt->priority]++; +#endif brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && ((BRCMF_CTL_ON() && chan == SDPCM_CONTROL_CHANNEL) || @@ -2149,7 +2150,6 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, chan != SDPCM_CONTROL_CHANNEL))) && BRCMF_HDRS_ON(), frame, min_t(u16, len, 16), "TxHdr:\n"); -#endif /* Raise len to next SDIO block to eliminate tail command */ if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { @@ -2806,7 +2806,7 @@ static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus) if (line[n - 1] == '\r') n--; line[n] = 0; - printk(KERN_DEBUG "CONSOLE: %s\n", line); + pr_debug("CONSOLE: %s\n", line); } } break2: @@ -3676,11 +3676,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva) if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); -#ifdef DEBUG - printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", - brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); - -#endif /* DEBUG */ + pr_debug("F1 signature read @0x18000000=0x%4x\n", + brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4)); /* * Force PLL off until brcmf_sdio_chip_attach() diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 3ae07bb9cc61..14ab606de745 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -5765,56 +5765,43 @@ int brcms_c_module_unregister(struct brcms_pub *pub, const char *name, return -ENODATA; } -#ifdef DEBUG -static const char * const supr_reason[] = { - "None", "PMQ Entry", "Flush request", - "Previous frag failure", "Channel mismatch", - "Lifetime Expiry", "Underflow" -}; - -static void brcms_c_print_txs_status(u16 s) -{ - printk(KERN_DEBUG "[15:12] %d frame attempts\n", - (s & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT); - printk(KERN_DEBUG " [11:8] %d rts attempts\n", - (s & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT); - printk(KERN_DEBUG " [7] %d PM mode indicated\n", - ((s & TX_STATUS_PMINDCTD) ? 1 : 0)); - printk(KERN_DEBUG " [6] %d intermediate status\n", - ((s & TX_STATUS_INTERMEDIATE) ? 1 : 0)); - printk(KERN_DEBUG " [5] %d AMPDU\n", - (s & TX_STATUS_AMPDU) ? 1 : 0); - printk(KERN_DEBUG " [4:2] %d Frame Suppressed Reason (%s)\n", - ((s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT), - supr_reason[(s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT]); - printk(KERN_DEBUG " [1] %d acked\n", - ((s & TX_STATUS_ACK_RCV) ? 1 : 0)); -} -#endif /* DEBUG */ - void brcms_c_print_txstatus(struct tx_status *txs) { -#if defined(DEBUG) - u16 s = txs->status; - u16 ackphyrxsh = txs->ackphyrxsh; - - printk(KERN_DEBUG "\ntxpkt (MPDU) Complete\n"); - - printk(KERN_DEBUG "FrameID: %04x ", txs->frameid); - printk(KERN_DEBUG "TxStatus: %04x", s); - printk(KERN_DEBUG "\n"); - - brcms_c_print_txs_status(s); - - printk(KERN_DEBUG "LastTxTime: %04x ", txs->lasttxtime); - printk(KERN_DEBUG "Seq: %04x ", txs->sequence); - printk(KERN_DEBUG "PHYTxStatus: %04x ", txs->phyerr); - printk(KERN_DEBUG "RxAckRSSI: %04x ", - (ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT); - printk(KERN_DEBUG "RxAckSQ: %04x", - (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); - printk(KERN_DEBUG "\n"); -#endif /* defined(DEBUG) */ + pr_debug("\ntxpkt (MPDU) Complete\n"); + + pr_debug("FrameID: %04x TxStatus: %04x\n", txs->frameid, txs->status); + + pr_debug("[15:12] %d frame attempts\n", + (txs->status & TX_STATUS_FRM_RTX_MASK) >> + TX_STATUS_FRM_RTX_SHIFT); + pr_debug(" [11:8] %d rts attempts\n", + (txs->status & TX_STATUS_RTS_RTX_MASK) >> + TX_STATUS_RTS_RTX_SHIFT); + pr_debug(" [7] %d PM mode indicated\n", + txs->status & TX_STATUS_PMINDCTD ? 1 : 0); + pr_debug(" [6] %d intermediate status\n", + txs->status & TX_STATUS_INTERMEDIATE ? 1 : 0); + pr_debug(" [5] %d AMPDU\n", + txs->status & TX_STATUS_AMPDU ? 1 : 0); + pr_debug(" [4:2] %d Frame Suppressed Reason (%s)\n", + (txs->status & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT, + (const char *[]) { + "None", + "PMQ Entry", + "Flush request", + "Previous frag failure", + "Channel mismatch", + "Lifetime Expiry", + "Underflow" + } [(txs->status & TX_STATUS_SUPR_MASK) >> + TX_STATUS_SUPR_SHIFT]); + pr_debug(" [1] %d acked\n", + txs->status & TX_STATUS_ACK_RCV ? 1 : 0); + + pr_debug("LastTxTime: %04x Seq: %04x PHYTxStatus: %04x RxAckRSSI: %04x RxAckSQ: %04x\n", + txs->lasttxtime, txs->sequence, txs->phyerr, + (txs->ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT, + (txs->ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); } bool brcms_c_chipmatch(u16 vendor, u16 device) @@ -5871,53 +5858,53 @@ void brcms_c_print_txdesc(struct d11txh *txh) struct ieee80211_rts rts = txh->rts_frame; /* add plcp header along with txh descriptor */ - printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); + pr_debug("Raw TxDesc + plcp header:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, txh, sizeof(struct d11txh) + 48); - printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl); - printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch); - printk(KERN_DEBUG "FC: %04x ", mfc); - printk(KERN_DEBUG "FES Time: %04x\n", tfest); - printk(KERN_DEBUG "PhyCtl: %04x%s ", ptcw, + pr_debug("TxCtlLow: %04x ", mtcl); + pr_debug("TxCtlHigh: %04x ", mtch); + pr_debug("FC: %04x ", mfc); + pr_debug("FES Time: %04x\n", tfest); + pr_debug("PhyCtl: %04x%s ", ptcw, (ptcw & PHY_TXC_SHORT_HDR) ? " short" : ""); - printk(KERN_DEBUG "PhyCtl_1: %04x ", ptcw_1); - printk(KERN_DEBUG "PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr); - printk(KERN_DEBUG "PhyCtl_1_Rts: %04x ", ptcw_1_Rts); - printk(KERN_DEBUG "PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts); - printk(KERN_DEBUG "MainRates: %04x ", mainrates); - printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); - printk(KERN_DEBUG "\n"); + pr_debug("PhyCtl_1: %04x ", ptcw_1); + pr_debug("PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr); + pr_debug("PhyCtl_1_Rts: %04x ", ptcw_1_Rts); + pr_debug("PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts); + pr_debug("MainRates: %04x ", mainrates); + pr_debug("XtraFrameTypes: %04x ", xtraft); + pr_debug("\n"); print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV)); print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET, ra, sizeof(txh->TxFrameRA)); - printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); + pr_debug("Fb FES Time: %04x ", tfestfb); print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET, rtspfb, sizeof(txh->RTSPLCPFallback)); - printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); + pr_debug("RTS DUR: %04x ", rtsdfb); print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET, fragpfb, sizeof(txh->FragPLCPFallback)); - printk(KERN_DEBUG "DUR: %04x", fragdfb); - printk(KERN_DEBUG "\n"); + pr_debug("DUR: %04x", fragdfb); + pr_debug("\n"); - printk(KERN_DEBUG "MModeLen: %04x ", mmodelen); - printk(KERN_DEBUG "MModeFbrLen: %04x\n", mmodefbrlen); + pr_debug("MModeLen: %04x ", mmodelen); + pr_debug("MModeFbrLen: %04x\n", mmodefbrlen); - printk(KERN_DEBUG "FrameID: %04x\n", tfid); - printk(KERN_DEBUG "TxStatus: %04x\n", txs); + pr_debug("FrameID: %04x\n", tfid); + pr_debug("TxStatus: %04x\n", txs); - printk(KERN_DEBUG "MaxNumMpdu: %04x\n", mnmpdu); - printk(KERN_DEBUG "MaxAggbyte: %04x\n", mabyte); - printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); - printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); + pr_debug("MaxNumMpdu: %04x\n", mnmpdu); + pr_debug("MaxAggbyte: %04x\n", mabyte); + pr_debug("MaxAggbyte_fb: %04x\n", mabyte_f); + pr_debug("MinByte: %04x\n", mmbyte); print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET, rtsph, sizeof(txh->RTSPhyHeader)); print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET, (u8 *)&rts, sizeof(txh->rts_frame)); - printk(KERN_DEBUG "\n"); + pr_debug("\n"); } #endif /* defined(DEBUG) */ @@ -5999,7 +5986,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) {0, NULL} }; - printk(KERN_DEBUG "Raw RxDesc:\n"); + pr_debug("Raw RxDesc:\n"); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, sizeof(struct d11rxhdr)); @@ -6007,14 +5994,14 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); - printk(KERN_DEBUG "RxFrameSize: %6s (%d)%s\n", lenbuf, len, + pr_debug("RxFrameSize: %6s (%d)%s\n", lenbuf, len, (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : ""); - printk(KERN_DEBUG "RxPHYStatus: %04x %04x %04x %04x\n", + pr_debug("RxPHYStatus: %04x %04x %04x %04x\n", phystatus_0, phystatus_1, phystatus_2, phystatus_3); - printk(KERN_DEBUG "RxMACStatus: %x %s\n", macstatus1, flagstr); - printk(KERN_DEBUG "RXMACaggtype: %x\n", + pr_debug("RxMACStatus: %x %s\n", macstatus1, flagstr); + pr_debug("RXMACaggtype: %x\n", (macstatus2 & RXS_AGGTYPE_MASK)); - printk(KERN_DEBUG "RxTSFTime: %04x\n", rxh->RxTSFTime); + pr_debug("RxTSFTime: %04x\n", rxh->RxTSFTime); } #endif /* defined(DEBUG) */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index 84a2a0d9dd38..8debc74c54e1 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -651,7 +651,9 @@ extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, #if defined(DEBUG) extern void brcms_c_print_txdesc(struct d11txh *txh); #else -#define brcms_c_print_txdesc(a) +static inline void brcms_c_print_txdesc(struct d11txh *txh) +{ +} #endif extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index a16f1ab292fd..a0909be6ef37 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -26434,8 +26434,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(struct brcms_phy *pi, u8 core_mask) } if (bcmerror != 0) { - printk(KERN_DEBUG "%s: Failed, cnt = %d\n", __func__, - cal_retry); + pr_debug("%s: Failed, cnt = %d\n", __func__, cal_retry); if (cal_retry < CAL_RETRY_CNT) { cal_retry++; diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 2207eaa34f8e..49086606485b 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -247,7 +247,7 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) struct sk_buff *p; if (msg && (msg[0] != '\0')) - printk(KERN_DEBUG "%s:\n", msg); + pr_debug("%s:\n", msg); for (p = p0; p; p = p->next) print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); -- GitLab From c2e6d5abab73df316d2ae7caa6d902c143b2d52d Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:43 -0800 Subject: [PATCH 0118/1846] brcm80211: Use brcmu_dbg_hex_dump Convert a couple of pr_debug/print_hex_dump to the standard utility. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/main.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 14ab606de745..72701a4bf89d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -5858,9 +5858,8 @@ void brcms_c_print_txdesc(struct d11txh *txh) struct ieee80211_rts rts = txh->rts_frame; /* add plcp header along with txh descriptor */ - pr_debug("Raw TxDesc + plcp header:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, - txh, sizeof(struct d11txh) + 48); + brcmu_dbg_hex_dump(txh, sizeof(struct d11txh) + 48, + "Raw TxDesc + plcp header:\n"); pr_debug("TxCtlLow: %04x ", mtcl); pr_debug("TxCtlHigh: %04x ", mtch); @@ -5986,9 +5985,7 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh) {0, NULL} }; - pr_debug("Raw RxDesc:\n"); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, - sizeof(struct d11rxhdr)); + brcmu_dbg_hex_dump(rxh, sizeof(struct d11rxhdr), "Raw RxDesc:\n"); brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64); -- GitLab From 02f77195db6ce252d5488b6d48d8edc1c5e2aa30 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:44 -0800 Subject: [PATCH 0119/1846] brcm80211: Use pr_fmt and pr_ Convert printks to pr_ Prefix logging with pr_fmt. Use ##__VA_ARGS__ in some WL_ logging macros. Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/bcmsdh.c | 2 ++ .../brcm80211/brcmfmac/bcmsdh_sdmmc.c | 3 ++ .../net/wireless/brcm80211/brcmfmac/dhd_cdc.c | 2 ++ .../wireless/brcm80211/brcmfmac/dhd_common.c | 3 ++ .../wireless/brcm80211/brcmfmac/dhd_linux.c | 2 ++ .../wireless/brcm80211/brcmfmac/dhd_sdio.c | 8 ++--- .../wireless/brcm80211/brcmfmac/sdio_chip.c | 2 ++ .../wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 ++ .../wireless/brcm80211/brcmfmac/wl_cfg80211.h | 30 +++++++++---------- .../wireless/brcm80211/brcmsmac/mac80211_if.c | 6 ++-- .../net/wireless/brcm80211/brcmsmac/main.c | 6 ++-- .../wireless/brcm80211/brcmsmac/phy/phy_n.c | 2 ++ .../net/wireless/brcm80211/brcmutil/utils.c | 2 ++ 13 files changed, 46 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 4bc8d251acf8..e925290b432b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -15,6 +15,8 @@ */ /* ****************** SDIO CARD Interface Functions **************************/ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 9b8c0ed833d4..ac71adeece51 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -13,6 +13,9 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c index ac8d1f437888..b3e3b7f25d82 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c @@ -19,6 +19,8 @@ * For certain dcmd codes, the dongle interprets string data from the host. ******************************************************************************/ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index 1c75ea887ac3..4187435220f3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c @@ -13,6 +13,9 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 16fd1ab35408..db2df1f1e6b2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -14,6 +14,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 91ec0235047a..6e4b5e85a099 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -14,6 +14,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -3896,8 +3898,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, bus, "brcmf_watchdog"); if (IS_ERR(bus->watchdog_tsk)) { - printk(KERN_WARNING - "brcmf_watchdog thread failed to start\n"); + pr_warn("brcmf_watchdog thread failed to start\n"); bus->watchdog_tsk = NULL; } /* Initialize DPC thread */ @@ -3905,8 +3906,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, bus, "brcmf_dpc"); if (IS_ERR(bus->dpc_tsk)) { - printk(KERN_WARNING - "brcmf_dpc thread failed to start\n"); + pr_warn("brcmf_dpc thread failed to start\n"); bus->dpc_tsk = NULL; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index 11b2d7c97ba2..1534efc21631 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -15,6 +15,8 @@ */ /* ***** SDIO interface chip backplane handle functions ***** */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index bf11850a20f1..886b0ccbc5c3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -16,6 +16,8 @@ /* Toplevel file. Relies on dhd_linux.c to send commands to the dongle. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h index 69a48729a728..b5d9b36df3d0 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h @@ -32,53 +32,53 @@ struct brcmf_cfg80211_ibss; #define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \ (WL_DBG_SCAN) | (WL_DBG_CONN)) -#define WL_ERR(fmt, args...) \ +#define WL_ERR(fmt, ...) \ do { \ if (brcmf_dbg_level & WL_DBG_ERR) { \ if (net_ratelimit()) { \ - printk(KERN_ERR "ERROR @%s : " fmt, \ - __func__, ##args); \ + pr_err("ERROR @%s : " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } \ } while (0) #if (defined DEBUG) -#define WL_INFO(fmt, args...) \ +#define WL_INFO(fmt, ...) \ do { \ if (brcmf_dbg_level & WL_DBG_INFO) { \ if (net_ratelimit()) { \ - printk(KERN_ERR "INFO @%s : " fmt, \ - __func__, ##args); \ + pr_err("INFO @%s : " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } \ } while (0) -#define WL_TRACE(fmt, args...) \ +#define WL_TRACE(fmt, ...) \ do { \ if (brcmf_dbg_level & WL_DBG_TRACE) { \ if (net_ratelimit()) { \ - printk(KERN_ERR "TRACE @%s : " fmt, \ - __func__, ##args); \ + pr_err("TRACE @%s : " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } \ } while (0) -#define WL_SCAN(fmt, args...) \ +#define WL_SCAN(fmt, ...) \ do { \ if (brcmf_dbg_level & WL_DBG_SCAN) { \ if (net_ratelimit()) { \ - printk(KERN_ERR "SCAN @%s : " fmt, \ - __func__, ##args); \ + pr_err("SCAN @%s : " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } \ } while (0) -#define WL_CONN(fmt, args...) \ +#define WL_CONN(fmt, ...) \ do { \ if (brcmf_dbg_level & WL_DBG_CONN) { \ if (net_ratelimit()) { \ - printk(KERN_ERR "CONN @%s : " fmt, \ - __func__, ##args); \ + pr_err("CONN @%s : " fmt, \ + __func__, ##__VA_ARGS__); \ } \ } \ } while (0) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 04ba9a878f40..c8427978d09e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -15,6 +15,7 @@ */ #define __UNDEF_NO_VERSION__ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include @@ -1121,8 +1122,7 @@ static int __devinit brcms_bcma_probe(struct bcma_device *pdev) wl = brcms_attach(pdev); if (!wl) { - pr_err("%s: %s: brcms_attach failed!\n", KBUILD_MODNAME, - __func__); + pr_err("%s: brcms_attach failed!\n", __func__); return -ENODEV; } return 0; @@ -1183,7 +1183,7 @@ static int __init brcms_module_init(void) #endif /* DEBUG */ error = bcma_driver_register(&brcms_bcma_driver); - printk(KERN_ERR "%s: register returned %d\n", __func__, error); + pr_err("%s: register returned %d\n", __func__, error); if (!error) return 0; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 72701a4bf89d..976a53183f68 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -14,6 +14,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -5807,7 +5809,7 @@ void brcms_c_print_txstatus(struct tx_status *txs) bool brcms_c_chipmatch(u16 vendor, u16 device) { if (vendor != PCI_VENDOR_ID_BROADCOM) { - pr_err("chipmatch: unknown vendor id %04x\n", vendor); + pr_err("unknown vendor id %04x\n", vendor); return false; } @@ -5820,7 +5822,7 @@ bool brcms_c_chipmatch(u16 vendor, u16 device) if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID)) return true; - pr_err("chipmatch: unknown device id %04x\n", device); + pr_err("unknown device id %04x\n", device); return false; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index a0909be6ef37..ec7450d2fbd6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -14,6 +14,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 49086606485b..b45ab34cdfdc 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c @@ -14,6 +14,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include -- GitLab From bfeb4dbc5cb36ae774fabe7b0e0d559e621a2ccd Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 15 Jan 2012 00:38:45 -0800 Subject: [PATCH 0120/1846] brcmfmac: Trivial typo of "couldn" to "could" fix Signed-off-by: Joe Perches Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 886b0ccbc5c3..74c95a597950 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -2785,7 +2785,7 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, wiphy_new(&wl_cfg80211_ops, sizeof(struct brcmf_cfg80211_priv) + sizeof_iface); if (!wdev->wiphy) { - WL_ERR("Couldn not allocate wiphy device\n"); + WL_ERR("Could not allocate wiphy device\n"); err = -ENOMEM; goto wiphy_new_out; } @@ -2811,7 +2811,7 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface, */ err = wiphy_register(wdev->wiphy); if (err < 0) { - WL_ERR("Couldn not register wiphy device (%d)\n", err); + WL_ERR("Could not register wiphy device (%d)\n", err); goto wiphy_register_out; } return wdev; -- GitLab From d5a2ca60e41fec4ede7b82d3608278523cffe77b Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Tue, 17 Jan 2012 11:06:43 +0200 Subject: [PATCH 0121/1846] NFC: Export new attributes sensb_res and sensf_res Export new attributes sensb_res for tech B and sensf_res for tech F in the target info (returned as a response to NFC_CMD_GET_TARGET). The max size of the attributes nfcid1, sensb_res and sensf_res is exported to user space though include/linux/nfc. Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- include/linux/nfc.h | 7 +++ include/net/nfc/nci.h | 19 ++++++++ include/net/nfc/nfc.h | 8 ++- net/nfc/nci/ntf.c | 111 +++++++++++++++++++++++++++++++++++++----- net/nfc/netlink.c | 6 +++ 5 files changed, 136 insertions(+), 15 deletions(-) diff --git a/include/linux/nfc.h b/include/linux/nfc.h index 01d4e5d60325..b4999abcb2a2 100644 --- a/include/linux/nfc.h +++ b/include/linux/nfc.h @@ -89,6 +89,8 @@ enum nfc_commands { * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the * target is not NFC-Forum compliant) * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes + * @NFC_ATTR_TARGET_SENSB_RES: NFC-B targets extra information, max 12 bytes + * @NFC_ATTR_TARGET_SENSF_RES: NFC-F targets extra information, max 18 bytes * @NFC_ATTR_COMM_MODE: Passive or active mode * @NFC_ATTR_RF_MODE: Initiator or target */ @@ -101,6 +103,8 @@ enum nfc_attrs { NFC_ATTR_TARGET_SENS_RES, NFC_ATTR_TARGET_SEL_RES, NFC_ATTR_TARGET_NFCID1, + NFC_ATTR_TARGET_SENSB_RES, + NFC_ATTR_TARGET_SENSF_RES, NFC_ATTR_COMM_MODE, NFC_ATTR_RF_MODE, /* private: internal use only */ @@ -109,6 +113,9 @@ enum nfc_attrs { #define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1) #define NFC_DEVICE_NAME_MAXSIZE 8 +#define NFC_NFCID1_MAXSIZE 10 +#define NFC_SENSB_RES_MAXSIZE 12 +#define NFC_SENSF_RES_MAXSIZE 18 /* NFC protocols */ #define NFC_PROTO_JEWEL 1 diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index 2be95e2626c0..34f5ed29c3c1 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h @@ -275,11 +275,27 @@ struct rf_tech_specific_params_nfca_poll { __u8 sel_res; } __packed; +struct rf_tech_specific_params_nfcb_poll { + __u8 sensb_res_len; + __u8 sensb_res[12]; /* 11 or 12 Bytes */ +} __packed; + +struct rf_tech_specific_params_nfcf_poll { + __u8 bit_rate; + __u8 sensf_res_len; + __u8 sensf_res[18]; /* 16 or 18 Bytes */ +} __packed; + struct activation_params_nfca_poll_iso_dep { __u8 rats_res_len; __u8 rats_res[20]; }; +struct activation_params_nfcb_poll_iso_dep { + __u8 attrib_res_len; + __u8 attrib_res[50]; +}; + struct nci_rf_intf_activated_ntf { __u8 rf_discovery_id; __u8 rf_interface; @@ -291,6 +307,8 @@ struct nci_rf_intf_activated_ntf { union { struct rf_tech_specific_params_nfca_poll nfca_poll; + struct rf_tech_specific_params_nfcb_poll nfcb_poll; + struct rf_tech_specific_params_nfcf_poll nfcf_poll; } rf_tech_specific_params; __u8 data_exch_rf_tech_and_mode; @@ -300,6 +318,7 @@ struct nci_rf_intf_activated_ntf { union { struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep; + struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep; } activation_params; } __packed; diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 8696b773a695..819530d0e37f 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -24,6 +24,7 @@ #ifndef __NET_NFC_H #define __NET_NFC_H +#include #include #include @@ -65,7 +66,6 @@ struct nfc_ops { #define NFC_TARGET_IDX_ANY -1 #define NFC_MAX_GT_LEN 48 -#define NFC_MAX_NFCID1_LEN 10 struct nfc_target { u32 idx; @@ -73,7 +73,11 @@ struct nfc_target { u16 sens_res; u8 sel_res; u8 nfcid1_len; - u8 nfcid1[NFC_MAX_NFCID1_LEN]; + u8 nfcid1[NFC_NFCID1_MAXSIZE]; + u8 sensb_res_len; + u8 sensb_res[NFC_SENSB_RES_MAXSIZE]; + u8 sensf_res_len; + u8 sensf_res[NFC_SENSF_RES_MAXSIZE]; }; struct nfc_genl_data { diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 10682bf7029d..a88be91e973f 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -115,15 +115,53 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, return data; } +static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, + struct nci_rf_intf_activated_ntf *ntf, __u8 *data) +{ + struct rf_tech_specific_params_nfcb_poll *nfcb_poll; + + nfcb_poll = &ntf->rf_tech_specific_params.nfcb_poll; + + nfcb_poll->sensb_res_len = *data++; + + pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len); + + memcpy(nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len); + data += nfcb_poll->sensb_res_len; + + return data; +} + +static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, + struct nci_rf_intf_activated_ntf *ntf, __u8 *data) +{ + struct rf_tech_specific_params_nfcf_poll *nfcf_poll; + + nfcf_poll = &ntf->rf_tech_specific_params.nfcf_poll; + + nfcf_poll->bit_rate = *data++; + nfcf_poll->sensf_res_len = *data++; + + pr_debug("bit_rate %d, sensf_res_len %d\n", + nfcf_poll->bit_rate, nfcf_poll->sensf_res_len); + + memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len); + data += nfcf_poll->sensf_res_len; + + return data; +} + static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, struct nci_rf_intf_activated_ntf *ntf, __u8 *data) { struct activation_params_nfca_poll_iso_dep *nfca_poll; + struct activation_params_nfcb_poll_iso_dep *nfcb_poll; switch (ntf->activation_rf_tech_and_mode) { case NCI_NFC_A_PASSIVE_POLL_MODE: nfca_poll = &ntf->activation_params.nfca_poll_iso_dep; nfca_poll->rats_res_len = *data++; + pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len); if (nfca_poll->rats_res_len > 0) { memcpy(nfca_poll->rats_res, data, @@ -131,6 +169,18 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, } break; + case NCI_NFC_B_PASSIVE_POLL_MODE: + nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep; + nfcb_poll->attrib_res_len = *data++; + pr_debug("attrib_res_len %d\n", + nfcb_poll->attrib_res_len); + if (nfcb_poll->attrib_res_len > 0) { + memcpy(nfcb_poll->attrib_res, + data, + nfcb_poll->attrib_res_len); + } + break; + default: pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", ntf->activation_rf_tech_and_mode); @@ -145,21 +195,14 @@ static void nci_target_found(struct nci_dev *ndev, { struct nfc_target nfc_tgt; - if (ntf->rf_protocol == NCI_RF_PROTOCOL_T2T) /* T2T MifareUL */ + memset(&nfc_tgt, 0, sizeof(nfc_tgt)); + + if (ntf->rf_protocol == NCI_RF_PROTOCOL_T2T) nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK; - else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */ + else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK; - else - nfc_tgt.supported_protocols = 0; - - nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res; - nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res; - nfc_tgt.nfcid1_len = ntf->rf_tech_specific_params.nfca_poll.nfcid1_len; - if (nfc_tgt.nfcid1_len > 0) { - memcpy(nfc_tgt.nfcid1, - ntf->rf_tech_specific_params.nfca_poll.nfcid1, - nfc_tgt.nfcid1_len); - } + else if (ntf->rf_protocol == NCI_RF_PROTOCOL_T3T) + nfc_tgt.supported_protocols = NFC_PROTO_FELICA_MASK; if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) { pr_debug("the target found does not have the desired protocol\n"); @@ -169,6 +212,38 @@ static void nci_target_found(struct nci_dev *ndev, pr_debug("new target found, supported_protocols 0x%x\n", nfc_tgt.supported_protocols); + if (ntf->activation_rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) { + nfc_tgt.sens_res = + ntf->rf_tech_specific_params.nfca_poll.sens_res; + nfc_tgt.sel_res = + ntf->rf_tech_specific_params.nfca_poll.sel_res; + nfc_tgt.nfcid1_len = + ntf->rf_tech_specific_params.nfca_poll.nfcid1_len; + if (nfc_tgt.nfcid1_len > 0) { + memcpy(nfc_tgt.nfcid1, + ntf->rf_tech_specific_params.nfca_poll.nfcid1, + nfc_tgt.nfcid1_len); + } + } else if (ntf->activation_rf_tech_and_mode == + NCI_NFC_B_PASSIVE_POLL_MODE) { + nfc_tgt.sensb_res_len = + ntf->rf_tech_specific_params.nfcb_poll.sensb_res_len; + if (nfc_tgt.sensb_res_len > 0) { + memcpy(nfc_tgt.sensb_res, + ntf->rf_tech_specific_params.nfcb_poll.sensb_res, + nfc_tgt.sensb_res_len); + } + } else if (ntf->activation_rf_tech_and_mode == + NCI_NFC_F_PASSIVE_POLL_MODE) { + nfc_tgt.sensf_res_len = + ntf->rf_tech_specific_params.nfcf_poll.sensf_res_len; + if (nfc_tgt.sensf_res_len > 0) { + memcpy(nfc_tgt.sensf_res, + ntf->rf_tech_specific_params.nfcf_poll.sensf_res, + nfc_tgt.sensf_res_len); + } + } + ndev->target_available_prots = nfc_tgt.supported_protocols; ndev->max_data_pkt_payload_size = ntf->max_data_pkt_payload_size; ndev->initial_num_credits = ntf->initial_num_credits; @@ -215,6 +290,16 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, &ntf, data); break; + case NCI_NFC_B_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcb_passive_poll(ndev, + &ntf, data); + break; + + case NCI_NFC_F_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcf_passive_poll(ndev, + &ntf, data); + break; + default: pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", ntf.activation_rf_tech_and_mode); diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 6989dfa28ee2..07f0348aabf5 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -70,6 +70,12 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target, if (target->nfcid1_len > 0) NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len, target->nfcid1); + if (target->sensb_res_len > 0) + NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len, + target->sensb_res); + if (target->sensf_res_len > 0) + NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len, + target->sensf_res); return genlmsg_end(msg, hdr); -- GitLab From 151a02f693b866dd43e147725c818fc1ddb96aa3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 17 Jan 2012 10:30:01 +0100 Subject: [PATCH 0122/1846] mac80211: clean up aggregation destruction Yogesh's patch to destroy aggregation sessions when stations are destroyed was needed, but unnecessarily complex. Clean up this code. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/sta_info.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index ff11f6bf8266..a09000432664 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -815,35 +815,20 @@ static int __must_check __sta_info_destroy(struct sta_info *sta) } #endif - /* There could be some memory leaks because of ampdu tx pending queue - * not being freed before destroying the station info. - * - * Make sure that such queues are purged before freeing the station - * info. - * TODO: We have to somehow postpone the full destruction - * until the aggregation stop completes. Refer - * http://thread.gmane.org/gmane.linux.kernel.wireless.general/81936 + /* + * Destroy aggregation state here. It would be nice to wait for the + * driver to finish aggregation stop and then clean up, but for now + * drivers have to handle aggregation stop being requested, followed + * directly by station destruction. */ - - mutex_lock(&sta->ampdu_mlme.mtx); - for (i = 0; i < STA_TID_NUM; i++) { - tid_tx = rcu_dereference_protected_tid_tx(sta, i); + tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); if (!tid_tx) continue; - if (skb_queue_len(&tid_tx->pending)) { -#ifdef CONFIG_MAC80211_HT_DEBUG - wiphy_debug(local->hw.wiphy, "TX A-MPDU purging %d " - "packets for tid=%d\n", - skb_queue_len(&tid_tx->pending), i); -#endif /* CONFIG_MAC80211_HT_DEBUG */ - __skb_queue_purge(&tid_tx->pending); - } - kfree_rcu(tid_tx, rcu_head); + __skb_queue_purge(&tid_tx->pending); + kfree(tid_tx); } - mutex_unlock(&sta->ampdu_mlme.mtx); - sta_info_free(local, sta); return 0; -- GitLab From 889cbb911a195b832745f77240f547cb2a2885bc Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 17 Jan 2012 10:33:29 +0100 Subject: [PATCH 0123/1846] mac80211: clean up rate control code It seems exceedingly unlikely that we'll ever support swapping rate control algorithms at runtime, so remove the unused refcounting code. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/rate.c | 27 ++++----------------------- net/mac80211/rate.h | 4 ---- net/mac80211/sta_info.c | 10 +++------- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index 5a5a7767d541..a21110aecd1a 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -159,7 +159,6 @@ static struct rate_control_ref *rate_control_alloc(const char *name, ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL); if (!ref) goto fail_ref; - kref_init(&ref->kref); ref->local = local; ref->ops = ieee80211_rate_control_ops_get(name); if (!ref->ops) @@ -184,11 +183,8 @@ static struct rate_control_ref *rate_control_alloc(const char *name, return NULL; } -static void rate_control_release(struct kref *kref) +static void rate_control_free(struct rate_control_ref *ctrl_ref) { - struct rate_control_ref *ctrl_ref; - - ctrl_ref = container_of(kref, struct rate_control_ref, kref); ctrl_ref->ops->free(ctrl_ref->priv); #ifdef CONFIG_MAC80211_DEBUGFS @@ -383,21 +379,10 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, BUG_ON(info->control.rates[0].idx < 0); } -struct rate_control_ref *rate_control_get(struct rate_control_ref *ref) -{ - kref_get(&ref->kref); - return ref; -} - -void rate_control_put(struct rate_control_ref *ref) -{ - kref_put(&ref->kref, rate_control_release); -} - int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, const char *name) { - struct rate_control_ref *ref, *old; + struct rate_control_ref *ref; ASSERT_RTNL(); @@ -417,12 +402,8 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, return -ENOENT; } - old = local->rate_ctrl; + WARN_ON(local->rate_ctrl); local->rate_ctrl = ref; - if (old) { - rate_control_put(old); - sta_info_flush(local, NULL); - } wiphy_debug(local->hw.wiphy, "Selected rate control algorithm '%s'\n", ref->ops->name); @@ -440,6 +421,6 @@ void rate_control_deinitialize(struct ieee80211_local *local) return; local->rate_ctrl = NULL; - rate_control_put(ref); + rate_control_free(ref); } diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h index 168427b0ffdc..8268457bd143 100644 --- a/net/mac80211/rate.h +++ b/net/mac80211/rate.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "ieee80211_i.h" #include "sta_info.h" @@ -23,14 +22,11 @@ struct rate_control_ref { struct ieee80211_local *local; struct rate_control_ops *ops; void *priv; - struct kref kref; }; void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, struct sta_info *sta, struct ieee80211_tx_rate_control *txrc); -struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); -void rate_control_put(struct rate_control_ref *ref); static inline void rate_control_tx_status(struct ieee80211_local *local, struct ieee80211_supported_band *sband, diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index a09000432664..f28fa02b6e54 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -208,10 +208,8 @@ struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata, */ void sta_info_free(struct ieee80211_local *local, struct sta_info *sta) { - if (sta->rate_ctrl) { + if (sta->rate_ctrl) rate_control_free_sta(sta); - rate_control_put(sta->rate_ctrl); - } #ifdef CONFIG_MAC80211_VERBOSE_DEBUG wiphy_debug(local->hw.wiphy, "Destroyed STA %pM\n", sta->sta.addr); @@ -264,13 +262,11 @@ static int sta_prepare_rate_control(struct ieee80211_local *local, if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) return 0; - sta->rate_ctrl = rate_control_get(local->rate_ctrl); + sta->rate_ctrl = local->rate_ctrl; sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, &sta->sta, gfp); - if (!sta->rate_ctrl_priv) { - rate_control_put(sta->rate_ctrl); + if (!sta->rate_ctrl_priv) return -ENOMEM; - } return 0; } -- GitLab From c4bf98b220cba7a8618405261d69ee53a265110e Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Tue, 17 Jan 2012 12:03:50 +0200 Subject: [PATCH 0124/1846] NFC: Add NCI data exchange timer Add NCI data exchange timer to catch timeouts, and call the data exchange callback with an error. Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- include/net/nfc/nci_core.h | 3 +++ net/nfc/nci/core.c | 24 ++++++++++++++++++++++++ net/nfc/nci/data.c | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index f4963ea77947..9154663b606b 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -41,6 +41,7 @@ enum { NCI_DISCOVERY, NCI_POLL_ACTIVE, NCI_DATA_EXCHANGE, + NCI_DATA_EXCHANGE_TO, }; /* NCI timeouts */ @@ -49,6 +50,7 @@ enum { #define NCI_RF_DISC_TIMEOUT 5000 #define NCI_RF_DEACTIVATE_TIMEOUT 30000 #define NCI_CMD_TIMEOUT 5000 +#define NCI_DATA_TIMEOUT 700 struct nci_dev; @@ -74,6 +76,7 @@ struct nci_dev { atomic_t credits_cnt; struct timer_list cmd_timer; + struct timer_list data_timer; struct workqueue_struct *cmd_wq; struct work_struct cmd_work; diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 7650139a1a05..815d28a0ed9d 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -286,6 +286,7 @@ static int nci_close_device(struct nci_dev *ndev) if (!test_and_clear_bit(NCI_UP, &ndev->flags)) { del_timer_sync(&ndev->cmd_timer); + del_timer_sync(&ndev->data_timer); mutex_unlock(&ndev->req_lock); return 0; } @@ -331,6 +332,15 @@ static void nci_cmd_timer(unsigned long arg) queue_work(ndev->cmd_wq, &ndev->cmd_work); } +/* NCI data exchange timer function */ +static void nci_data_timer(unsigned long arg) +{ + struct nci_dev *ndev = (void *) arg; + + set_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags); + queue_work(ndev->rx_wq, &ndev->rx_work); +} + static int nci_dev_up(struct nfc_dev *nfc_dev) { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); @@ -585,6 +595,8 @@ int nci_register_device(struct nci_dev *ndev) setup_timer(&ndev->cmd_timer, nci_cmd_timer, (unsigned long) ndev); + setup_timer(&ndev->data_timer, nci_data_timer, + (unsigned long) ndev); mutex_init(&ndev->req_lock); @@ -722,6 +734,9 @@ static void nci_tx_work(struct work_struct *work) nci_plen(skb->data)); nci_send_frame(skb); + + mod_timer(&ndev->data_timer, + jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT)); } } @@ -753,6 +768,15 @@ static void nci_rx_work(struct work_struct *work) break; } } + + /* check if a data exchange timout has occurred */ + if (test_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags)) { + /* complete the data exchange transaction, if exists */ + if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) + nci_data_exchange_complete(ndev, NULL, -ETIMEDOUT); + + clear_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags); + } } /* ----- NCI TX CMD worker thread ----- */ diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index e5756b30e602..7880ae924d5e 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c @@ -44,6 +44,10 @@ void nci_data_exchange_complete(struct nci_dev *ndev, pr_debug("len %d, err %d\n", skb ? skb->len : 0, err); + /* data exchange is complete, stop the data timer */ + del_timer_sync(&ndev->data_timer); + clear_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags); + if (cb) { ndev->data_exchange_cb = NULL; ndev->data_exchange_cb_context = 0; -- GitLab From 3ed1326d2e693d555e62241c2e2209f01506214e Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Tue, 17 Jan 2012 14:11:31 +0200 Subject: [PATCH 0125/1846] NFC: Add endian annotations to nfcwilink driver Add endian annotations to TI nfcwilink driver. Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/nfcwilink.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c index 06c3642e5bdb..ee60d0844332 100644 --- a/drivers/nfc/nfcwilink.c +++ b/drivers/nfc/nfcwilink.c @@ -28,6 +28,7 @@ */ #include #include +#include #include #include #include @@ -42,9 +43,9 @@ #define NFCWILINK_REGISTER_TIMEOUT 8000 /* 8 sec */ struct nfcwilink_hdr { - u8 chnl; - u8 opcode; - u16 len; + __u8 chnl; + __u8 opcode; + __le16 len; } __packed; struct nfcwilink { @@ -212,7 +213,7 @@ static int nfcwilink_send(struct sk_buff *skb) return -EBUSY; /* add the ST hdr to the start of the buffer */ - hdr.len = skb->len; + hdr.len = cpu_to_le16(skb->len); memcpy(skb_push(skb, NFCWILINK_HDR_LEN), &hdr, NFCWILINK_HDR_LEN); /* Insert skb to shared transport layer's transmit queue. @@ -239,7 +240,7 @@ static int nfcwilink_probe(struct platform_device *pdev) { static struct nfcwilink *drv; int rc; - u32 protocols; + __u32 protocols; nfc_dev_dbg(&pdev->dev, "probe entry"); -- GitLab From 1195d89b2defd92829ed54938e60312e62dc8747 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Tue, 17 Jan 2012 14:11:32 +0200 Subject: [PATCH 0126/1846] NFC: Download TI NFC init script Download TI NFC init script during nfcwilink open operation, after the NFC channel is registered with TI shared transport. TI NFC init script is written in BTS format. First, read the chip version via a special vendor specific command. Second, we request the relevant BTS file from the user space, and then send the BTS commands to the chip. Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/nfcwilink.c | 288 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 284 insertions(+), 4 deletions(-) diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c index ee60d0844332..90af28d611f6 100644 --- a/drivers/nfc/nfcwilink.c +++ b/drivers/nfc/nfcwilink.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,17 @@ #define NFCWILINK_OFFSET_LEN_IN_HDR 1 #define NFCWILINK_LEN_SIZE 2 #define NFCWILINK_REGISTER_TIMEOUT 8000 /* 8 sec */ +#define NFCWILINK_CMD_TIMEOUT 5000 /* 5 sec */ + +#define BTS_FILE_NAME_MAX_SIZE 40 +#define BTS_FILE_HDR_MAGIC 0x42535442 +#define BTS_FILE_CMD_MAX_LEN 0xff +#define BTS_FILE_ACTION_TYPE_SEND_CMD 1 + +#define NCI_VS_NFCC_INFO_CMD_GID 0x2f +#define NCI_VS_NFCC_INFO_CMD_OID 0x12 +#define NCI_VS_NFCC_INFO_RSP_GID 0x4f +#define NCI_VS_NFCC_INFO_RSP_OID 0x12 struct nfcwilink_hdr { __u8 chnl; @@ -48,6 +60,36 @@ struct nfcwilink_hdr { __le16 len; } __packed; +struct nci_vs_nfcc_info_cmd { + __u8 gid; + __u8 oid; + __u8 plen; +} __packed; + +struct nci_vs_nfcc_info_rsp { + __u8 gid; + __u8 oid; + __u8 plen; + __u8 status; + __u8 hw_id; + __u8 sw_ver_x; + __u8 sw_ver_z; + __u8 patch_id; +} __packed; + +struct bts_file_hdr { + __le32 magic; + __le32 ver; + __u8 rfu[24]; + __u8 actions[0]; +} __packed; + +struct bts_file_action { + __le16 type; + __le16 len; + __u8 data[0]; +} __packed; + struct nfcwilink { struct platform_device *pdev; struct nci_dev *ndev; @@ -55,14 +97,241 @@ struct nfcwilink { char st_register_cb_status; long (*st_write) (struct sk_buff *); - struct completion st_register_completed; + + struct completion completed; + + struct nci_vs_nfcc_info_rsp nfcc_info; }; /* NFCWILINK driver flags */ enum { NFCWILINK_RUNNING, + NFCWILINK_FW_DOWNLOAD, }; +static int nfcwilink_send(struct sk_buff *skb); + +static inline struct sk_buff *nfcwilink_skb_alloc(unsigned int len, gfp_t how) +{ + struct sk_buff *skb; + + skb = alloc_skb(len + NFCWILINK_HDR_LEN, how); + if (skb) + skb_reserve(skb, NFCWILINK_HDR_LEN); + + return skb; +} + +static void nfcwilink_fw_download_receive(struct nfcwilink *drv, + struct sk_buff *skb) +{ + struct nci_vs_nfcc_info_rsp *rsp = (void *)skb->data; + + /* Detect NCI_VS_NFCC_INFO_RSP and store the result */ + if ((skb->len > 3) && (rsp->gid == NCI_VS_NFCC_INFO_RSP_GID) && + (rsp->oid == NCI_VS_NFCC_INFO_RSP_OID)) { + memcpy(&drv->nfcc_info, rsp, + sizeof(struct nci_vs_nfcc_info_rsp)); + } + + kfree_skb(skb); + + complete(&drv->completed); +} + +static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name) +{ + struct nci_vs_nfcc_info_cmd *cmd; + struct sk_buff *skb; + unsigned long comp_ret; + int rc; + + nfc_dev_dbg(&drv->pdev->dev, "get_bts_file_name entry"); + + skb = nfcwilink_skb_alloc(sizeof(struct nci_vs_nfcc_info_cmd), + GFP_KERNEL); + if (!skb) { + nfc_dev_err(&drv->pdev->dev, + "no memory for nci_vs_nfcc_info_cmd"); + return -ENOMEM; + } + + skb->dev = (void *)drv->ndev; + + cmd = (struct nci_vs_nfcc_info_cmd *) + skb_put(skb, sizeof(struct nci_vs_nfcc_info_cmd)); + cmd->gid = NCI_VS_NFCC_INFO_CMD_GID; + cmd->oid = NCI_VS_NFCC_INFO_CMD_OID; + cmd->plen = 0; + + drv->nfcc_info.plen = 0; + + rc = nfcwilink_send(skb); + if (rc) + return rc; + + comp_ret = wait_for_completion_timeout(&drv->completed, + msecs_to_jiffies(NFCWILINK_CMD_TIMEOUT)); + nfc_dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld", + comp_ret); + if (comp_ret == 0) { + nfc_dev_err(&drv->pdev->dev, + "timeout on wait_for_completion_timeout"); + return -ETIMEDOUT; + } + + nfc_dev_dbg(&drv->pdev->dev, "nci_vs_nfcc_info_rsp: plen %d, status %d", + drv->nfcc_info.plen, + drv->nfcc_info.status); + + if ((drv->nfcc_info.plen != 5) || (drv->nfcc_info.status != 0)) { + nfc_dev_err(&drv->pdev->dev, + "invalid nci_vs_nfcc_info_rsp"); + return -EINVAL; + } + + snprintf(file_name, BTS_FILE_NAME_MAX_SIZE, + "TINfcInit_%d.%d.%d.%d.bts", + drv->nfcc_info.hw_id, + drv->nfcc_info.sw_ver_x, + drv->nfcc_info.sw_ver_z, + drv->nfcc_info.patch_id); + + nfc_dev_info(&drv->pdev->dev, "nfcwilink FW file name: %s", file_name); + + return 0; +} + +static int nfcwilink_send_bts_cmd(struct nfcwilink *drv, __u8 *data, int len) +{ + struct nfcwilink_hdr *hdr = (struct nfcwilink_hdr *)data; + struct sk_buff *skb; + unsigned long comp_ret; + int rc; + + nfc_dev_dbg(&drv->pdev->dev, "send_bts_cmd entry"); + + /* verify valid cmd for the NFC channel */ + if ((len <= sizeof(struct nfcwilink_hdr)) || + (len > BTS_FILE_CMD_MAX_LEN) || + (hdr->chnl != NFCWILINK_CHNL) || + (hdr->opcode != NFCWILINK_OPCODE)) { + nfc_dev_err(&drv->pdev->dev, + "ignoring invalid bts cmd, len %d, chnl %d, opcode %d", + len, hdr->chnl, hdr->opcode); + return 0; + } + + /* remove the ST header */ + len -= sizeof(struct nfcwilink_hdr); + data += sizeof(struct nfcwilink_hdr); + + skb = nfcwilink_skb_alloc(len, GFP_KERNEL); + if (!skb) { + nfc_dev_err(&drv->pdev->dev, "no memory for bts cmd"); + return -ENOMEM; + } + + skb->dev = (void *)drv->ndev; + + memcpy(skb_put(skb, len), data, len); + + rc = nfcwilink_send(skb); + if (rc) + return rc; + + comp_ret = wait_for_completion_timeout(&drv->completed, + msecs_to_jiffies(NFCWILINK_CMD_TIMEOUT)); + nfc_dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld", + comp_ret); + if (comp_ret == 0) { + nfc_dev_err(&drv->pdev->dev, + "timeout on wait_for_completion_timeout"); + return -ETIMEDOUT; + } + + return 0; +} + +static int nfcwilink_download_fw(struct nfcwilink *drv) +{ + unsigned char file_name[BTS_FILE_NAME_MAX_SIZE]; + const struct firmware *fw; + __u16 action_type, action_len; + __u8 *ptr; + int len, rc; + + nfc_dev_dbg(&drv->pdev->dev, "download_fw entry"); + + set_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags); + + rc = nfcwilink_get_bts_file_name(drv, file_name); + if (rc) + goto exit; + + rc = request_firmware(&fw, file_name, &drv->pdev->dev); + if (rc) { + nfc_dev_err(&drv->pdev->dev, "request_firmware failed %d", rc); + + /* if the file is not found, don't exit with failure */ + if (rc == -ENOENT) + rc = 0; + + goto exit; + } + + len = fw->size; + ptr = (__u8 *)fw->data; + + if ((len == 0) || (ptr == NULL)) { + nfc_dev_dbg(&drv->pdev->dev, + "request_firmware returned size %d", len); + goto release_fw; + } + + if (__le32_to_cpu(((struct bts_file_hdr *)ptr)->magic) != + BTS_FILE_HDR_MAGIC) { + nfc_dev_err(&drv->pdev->dev, "wrong bts magic number"); + rc = -EINVAL; + goto release_fw; + } + + /* remove the BTS header */ + len -= sizeof(struct bts_file_hdr); + ptr += sizeof(struct bts_file_hdr); + + while (len > 0) { + action_type = + __le16_to_cpu(((struct bts_file_action *)ptr)->type); + action_len = + __le16_to_cpu(((struct bts_file_action *)ptr)->len); + + nfc_dev_dbg(&drv->pdev->dev, "bts_file_action type %d, len %d", + action_type, action_len); + + switch (action_type) { + case BTS_FILE_ACTION_TYPE_SEND_CMD: + rc = nfcwilink_send_bts_cmd(drv, + ((struct bts_file_action *)ptr)->data, + action_len); + if (rc) + goto release_fw; + break; + } + + /* advance to the next action */ + len -= (sizeof(struct bts_file_action) + action_len); + ptr += (sizeof(struct bts_file_action) + action_len); + } + +release_fw: + release_firmware(fw); + +exit: + clear_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags); + return rc; +} + /* Called by ST when registration is complete */ static void nfcwilink_register_complete(void *priv_data, char data) { @@ -74,7 +343,7 @@ static void nfcwilink_register_complete(void *priv_data, char data) drv->st_register_cb_status = data; /* complete the wait in nfc_st_open() */ - complete(&drv->st_register_completed); + complete(&drv->completed); } /* Called by ST when receive data is available */ @@ -97,6 +366,11 @@ static long nfcwilink_receive(void *priv_data, struct sk_buff *skb) (apart for the chnl byte, which is not received in the hdr) */ skb_pull(skb, (NFCWILINK_HDR_LEN-1)); + if (test_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags)) { + nfcwilink_fw_download_receive(drv, skb); + return 0; + } + skb->dev = (void *) drv->ndev; /* Forward skb to NCI core layer */ @@ -137,14 +411,14 @@ static int nfcwilink_open(struct nci_dev *ndev) nfcwilink_proto.priv_data = drv; - init_completion(&drv->st_register_completed); + init_completion(&drv->completed); drv->st_register_cb_status = -EINPROGRESS; rc = st_register(&nfcwilink_proto); if (rc < 0) { if (rc == -EINPROGRESS) { comp_ret = wait_for_completion_timeout( - &drv->st_register_completed, + &drv->completed, msecs_to_jiffies(NFCWILINK_REGISTER_TIMEOUT)); nfc_dev_dbg(&drv->pdev->dev, @@ -172,6 +446,12 @@ static int nfcwilink_open(struct nci_dev *ndev) BUG_ON(nfcwilink_proto.write == NULL); drv->st_write = nfcwilink_proto.write; + if (nfcwilink_download_fw(drv)) { + nfc_dev_err(&drv->pdev->dev, "nfcwilink_download_fw failed %d", + rc); + /* open should succeed, even if the FW download failed */ + } + goto exit; clear_exit: -- GitLab From ea9917d6f9e355646258b8d08ac69108908618a2 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Tue, 17 Jan 2012 14:11:33 +0200 Subject: [PATCH 0127/1846] NFC: Free sk_buff if nfcwilink_send fails Free sk_buff if nfcwilink_send fails. Signed-off-by: Ilan Elias Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/nfcwilink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c index 90af28d611f6..1f74a77d040d 100644 --- a/drivers/nfc/nfcwilink.c +++ b/drivers/nfc/nfcwilink.c @@ -489,8 +489,10 @@ static int nfcwilink_send(struct sk_buff *skb) nfc_dev_dbg(&drv->pdev->dev, "send entry, len %d", skb->len); - if (!test_bit(NFCWILINK_RUNNING, &drv->flags)) - return -EBUSY; + if (!test_bit(NFCWILINK_RUNNING, &drv->flags)) { + kfree_skb(skb); + return -EINVAL; + } /* add the ST hdr to the start of the buffer */ hdr.len = cpu_to_le16(skb->len); -- GitLab From 24dd0dd74ec8dc4abada132e380dc179459b0f77 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Wed, 18 Jan 2012 00:10:43 +0100 Subject: [PATCH 0128/1846] mac80211: add a 2-way Authentication challenge to IBSS mode In IBSS mode, whenever a new station is added a 2-way authentication challenge is performed. Actually this event can be used to recognise a new station joining the cell even if its sta_info entry is already in the list. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index b253d0adf0ad..a497c03c03d7 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -298,6 +298,13 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta) /* If it fails, maybe we raced another insertion? */ if (sta_info_insert_rcu(sta)) return sta_info_get(sdata, addr); +#ifdef CONFIG_MAC80211_IBSS_DEBUG + printk(KERN_DEBUG "TX Auth SA=%pM DA=%pM BSSID=%pM" + "(auth_transaction=1)\n", sdata->vif.addr, + sdata->u.ibss.bssid, addr); +#endif + ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0, + addr, sdata->u.ibss.bssid, NULL, 0, 0); return sta; } -- GitLab From 6d810f10325522cfcf498dc6d64b9f96e1f5153f Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Wed, 18 Jan 2012 00:10:44 +0100 Subject: [PATCH 0129/1846] mac80211: in IBSS use the Auth frame to trigger STA reinsertion In case of a node re-joining the cell the sta_info structure belonging to it is first destroyed and then reinserted. In this way its internal state is reset. The joining operation is recognised thank the Auth frame being received. This operation is helpful in case of a node being rebooted that is joining the ad-hoc cell again, before its purge timeout on other nodes expires. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 85 ++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index a497c03c03d7..d38baa41cf6c 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -36,31 +36,6 @@ #define IEEE80211_IBSS_MAX_STA_ENTRIES 128 -static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, - struct ieee80211_mgmt *mgmt, - size_t len) -{ - u16 auth_alg, auth_transaction; - - lockdep_assert_held(&sdata->u.ibss.mtx); - - if (len < 24 + 6) - return; - - auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); - auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); - - /* - * IEEE 802.11 standard does not require authentication in IBSS - * networks and most implementations do not seem to use it. - * However, try to reply to authentication attempts if someone - * has actually implemented this. - */ - if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) - ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, mgmt->sa, - sdata->u.ibss.bssid, NULL, 0, 0); -} - static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, const u8 *bssid, const int beacon_int, struct ieee80211_channel *chan, @@ -275,7 +250,8 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, cbss->tsf); } -static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta) +static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, + bool auth) __acquires(RCU) { struct ieee80211_sub_if_data *sdata = sta->sdata; @@ -298,20 +274,22 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta) /* If it fails, maybe we raced another insertion? */ if (sta_info_insert_rcu(sta)) return sta_info_get(sdata, addr); + if (auth) { #ifdef CONFIG_MAC80211_IBSS_DEBUG - printk(KERN_DEBUG "TX Auth SA=%pM DA=%pM BSSID=%pM" - "(auth_transaction=1)\n", sdata->vif.addr, - sdata->u.ibss.bssid, addr); + printk(KERN_DEBUG "TX Auth SA=%pM DA=%pM BSSID=%pM" + "(auth_transaction=1)\n", sdata->vif.addr, + sdata->u.ibss.bssid, addr); #endif - ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0, - addr, sdata->u.ibss.bssid, NULL, 0, 0); + ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0, + addr, sdata->u.ibss.bssid, NULL, 0, 0); + } return sta; } static struct sta_info * ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid, const u8 *addr, - u32 supp_rates) + u32 supp_rates, bool auth) __acquires(RCU) { struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; @@ -353,7 +331,42 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, sta->sta.supp_rates[band] = supp_rates | ieee80211_mandatory_rates(local, band); - return ieee80211_ibss_finish_sta(sta); + return ieee80211_ibss_finish_sta(sta, auth); +} + +static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, + size_t len) +{ + u16 auth_alg, auth_transaction; + + lockdep_assert_held(&sdata->u.ibss.mtx); + + if (len < 24 + 6) + return; + + auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); + auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); + + if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1) + return; +#ifdef CONFIG_MAC80211_IBSS_DEBUG + printk(KERN_DEBUG "%s: RX Auth SA=%pM DA=%pM BSSID=%pM." + "(auth_transaction=%d)\n", + sdata->name, mgmt->sa, mgmt->da, mgmt->bssid, auth_transaction); +#endif + sta_info_destroy_addr(sdata, mgmt->sa); + ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, 0, false); + rcu_read_unlock(); + + /* + * IEEE 802.11 standard does not require authentication in IBSS + * networks and most implementations do not seem to use it. + * However, try to reply to authentication attempts if someone + * has actually implemented this. + */ + ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, + mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0); } static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, @@ -418,7 +431,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, } else { rcu_read_unlock(); sta = ieee80211_ibss_add_sta(sdata, mgmt->bssid, - mgmt->sa, supp_rates); + mgmt->sa, supp_rates, true); } } @@ -546,7 +559,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ieee80211_sta_join_ibss(sdata, bss); supp_rates = ieee80211_sta_get_rates(local, elems, band); ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, - supp_rates); + supp_rates, true); rcu_read_unlock(); } @@ -947,7 +960,7 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata) list_del(&sta->list); spin_unlock_bh(&ifibss->incomplete_lock); - ieee80211_ibss_finish_sta(sta); + ieee80211_ibss_finish_sta(sta, true); rcu_read_unlock(); spin_lock_bh(&ifibss->incomplete_lock); } -- GitLab From 8939e47fc953cce6ef53e79e9ff9b53319d1a72d Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Wed, 18 Jan 2012 13:16:12 +0200 Subject: [PATCH 0130/1846] NFC: Clearly separate NCI states from flags Make a clear separation between NCI states and flags. This is required in order to support more NCI states (e.g. for multiple targets support). Signed-off-by: Ilan Elias Signed-off-by: John W. Linville --- include/net/nfc/nci_core.h | 14 ++++++++++---- net/nfc/nci/core.c | 11 ++++++----- net/nfc/nci/ntf.c | 5 ++--- net/nfc/nci/rsp.c | 8 ++++---- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 9154663b606b..b9c3f8de13dd 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -34,16 +34,21 @@ #include #include -/* NCI device state */ -enum { +/* NCI device flags */ +enum nci_flag { NCI_INIT, NCI_UP, - NCI_DISCOVERY, - NCI_POLL_ACTIVE, NCI_DATA_EXCHANGE, NCI_DATA_EXCHANGE_TO, }; +/* NCI device states */ +enum nci_state { + NCI_IDLE, + NCI_DISCOVERY, + NCI_POLL_ACTIVE, +}; + /* NCI timeouts */ #define NCI_RESET_TIMEOUT 5000 #define NCI_INIT_TIMEOUT 5000 @@ -70,6 +75,7 @@ struct nci_dev { int tx_headroom; int tx_tailroom; + atomic_t state; unsigned long flags; atomic_t cmd_cnt; diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 815d28a0ed9d..629b76845973 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -264,6 +264,7 @@ static int nci_open_device(struct nci_dev *ndev) if (!rc) { set_bit(NCI_UP, &ndev->flags); + atomic_set(&ndev->state, NCI_IDLE); } else { /* Init failed, cleanup */ skb_queue_purge(&ndev->cmd_q); @@ -360,7 +361,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); int rc; - if (test_bit(NCI_DISCOVERY, &ndev->flags)) { + if (atomic_read(&ndev->state) == NCI_DISCOVERY) { pr_err("unable to start poll, since poll is already active\n"); return -EBUSY; } @@ -370,7 +371,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) return -EBUSY; } - if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { + if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { pr_debug("target is active, implicitly deactivate...\n"); rc = nci_request(ndev, nci_rf_deactivate_req, 0, @@ -392,7 +393,7 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev) { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); - if (!test_bit(NCI_DISCOVERY, &ndev->flags)) { + if (atomic_read(&ndev->state) != NCI_DISCOVERY) { pr_err("unable to stop poll, since poll is not active\n"); return; } @@ -408,7 +409,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); - if (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { + if (atomic_read(&ndev->state) != NCI_POLL_ACTIVE) { pr_err("there is no available target to activate\n"); return -EINVAL; } @@ -443,7 +444,7 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) ndev->target_active_prot = 0; - if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { + if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { nci_request(ndev, nci_rf_deactivate_req, 0, msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); } diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index a88be91e973f..8ec39464cea5 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -261,8 +261,7 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, __u8 *data = skb->data; int err = 0; - clear_bit(NCI_DISCOVERY, &ndev->flags); - set_bit(NCI_POLL_ACTIVE, &ndev->flags); + atomic_set(&ndev->state, NCI_POLL_ACTIVE); ntf.rf_discovery_id = *data++; ntf.rf_interface = *data++; @@ -350,7 +349,7 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason); - clear_bit(NCI_POLL_ACTIVE, &ndev->flags); + atomic_set(&ndev->state, NCI_IDLE); ndev->target_active_prot = 0; /* drop tx data queue */ diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index 3c73e92eb625..cb8bce6899cf 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c @@ -137,7 +137,7 @@ static void nci_rf_disc_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) pr_debug("status 0x%x\n", status); if (status == NCI_STATUS_OK) - set_bit(NCI_DISCOVERY, &ndev->flags); + atomic_set(&ndev->state, NCI_DISCOVERY); nci_req_complete(ndev, status); } @@ -149,12 +149,12 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, pr_debug("status 0x%x\n", status); - clear_bit(NCI_DISCOVERY, &ndev->flags); - /* If target was active, complete the request only in deactivate_ntf */ if ((status != NCI_STATUS_OK) || - (!test_bit(NCI_POLL_ACTIVE, &ndev->flags))) + (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { + atomic_set(&ndev->state, NCI_IDLE); nci_req_complete(ndev, status); + } } void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) -- GitLab From 25a1d9dc850b1bdcc4760eb625f0a67057f54d26 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Wed, 18 Jan 2012 13:16:13 +0200 Subject: [PATCH 0131/1846] NFC: NFC core layer should not set the target_idx The NFC core layer should not set the target_idx. Instead, the driver layer (e.g. NCI, PN533) should set the target_idx, so that it will be able to identify the target when its I/F (e.g. activate_target) is called. This is required in order to support multiple targets. Note that currently supported drivers (PN533 and NCI) don't use the target_idx in their implementation. Signed-off-by: Ilan Elias Signed-off-by: John W. Linville --- include/net/nfc/nfc.h | 1 - net/nfc/core.c | 5 ----- net/nfc/rawsock.c | 12 ------------ 3 files changed, 18 deletions(-) diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 819530d0e37f..d253278e5a96 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -87,7 +87,6 @@ struct nfc_genl_data { struct nfc_dev { unsigned idx; - unsigned target_idx; struct nfc_target *targets; int n_targets; int targets_generation; diff --git a/net/nfc/core.c b/net/nfc/core.c index 3ddf6e698df0..6089aca67b14 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -431,15 +431,10 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb); int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, int n_targets) { - int i; - pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets); dev->polling = false; - for (i = 0; i < n_targets; i++) - targets[i].idx = dev->target_idx++; - spin_lock_bh(&dev->targets_lock); dev->targets_generation++; diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index 2e2f8c6a61fe..5325439b0c60 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -92,18 +92,6 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr, goto error; } - if (addr->target_idx > dev->target_idx - 1 || - addr->target_idx < dev->target_idx - dev->n_targets) { - rc = -EINVAL; - goto error; - } - - if (addr->target_idx > dev->target_idx - 1 || - addr->target_idx < dev->target_idx - dev->n_targets) { - rc = -EINVAL; - goto error; - } - rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol); if (rc) goto put_dev; -- GitLab From 019c4fbaa790e2b3f11dab0c8b7d9896d77db3e5 Mon Sep 17 00:00:00 2001 From: Ilan Elias Date: Wed, 18 Jan 2012 13:16:14 +0200 Subject: [PATCH 0132/1846] NFC: Add NCI multiple targets support Add the ability to select between multiple targets in NCI. If only one target is found, it will be auto-activated. If more than one target is found, then DISCOVER_NTF will be generated for each target, and the host should select one by calling DISCOVER_SELECT_CMD. Then, the target will be activated. If the activation fails, GENERIC_ERROR_NTF is generated. Signed-off-by: Ilan Elias Signed-off-by: John W. Linville --- include/net/nfc/nci.h | 34 +++- include/net/nfc/nci_core.h | 9 +- net/nfc/nci/core.c | 91 +++++++++-- net/nfc/nci/ntf.c | 323 +++++++++++++++++++++++++++---------- net/nfc/nci/rsp.c | 17 ++ 5 files changed, 378 insertions(+), 96 deletions(-) diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h index 34f5ed29c3c1..276094b91d7c 100644 --- a/include/net/nfc/nci.h +++ b/include/net/nfc/nci.h @@ -116,6 +116,11 @@ #define NCI_DISC_MAP_MODE_POLL 0x01 #define NCI_DISC_MAP_MODE_LISTEN 0x02 +/* NCI Discover Notification Type */ +#define NCI_DISCOVER_NTF_TYPE_LAST 0x00 +#define NCI_DISCOVER_NTF_TYPE_LAST_NFCC 0x01 +#define NCI_DISCOVER_NTF_TYPE_MORE 0x02 + /* NCI Deactivation Type */ #define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 #define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 @@ -207,6 +212,13 @@ struct nci_rf_disc_cmd { struct disc_config disc_configs[NCI_MAX_NUM_RF_CONFIGS]; } __packed; +#define NCI_OP_RF_DISCOVER_SELECT_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x04) +struct nci_rf_discover_select_cmd { + __u8 rf_discovery_id; + __u8 rf_protocol; + __u8 rf_interface; +} __packed; + #define NCI_OP_RF_DEACTIVATE_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) struct nci_rf_deactivate_cmd { __u8 type; @@ -244,6 +256,8 @@ struct nci_core_init_rsp_2 { #define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) +#define NCI_OP_RF_DISCOVER_SELECT_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x04) + #define NCI_OP_RF_DEACTIVATE_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) /* --------------------------- */ @@ -260,13 +274,15 @@ struct nci_core_conn_credit_ntf { struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN]; } __packed; +#define NCI_OP_CORE_GENERIC_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x07) + #define NCI_OP_CORE_INTF_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x08) struct nci_core_intf_error_ntf { __u8 status; __u8 conn_id; } __packed; -#define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) +#define NCI_OP_RF_DISCOVER_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) struct rf_tech_specific_params_nfca_poll { __u16 sens_res; __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ @@ -286,6 +302,22 @@ struct rf_tech_specific_params_nfcf_poll { __u8 sensf_res[18]; /* 16 or 18 Bytes */ } __packed; +struct nci_rf_discover_ntf { + __u8 rf_discovery_id; + __u8 rf_protocol; + __u8 rf_tech_and_mode; + __u8 rf_tech_specific_params_len; + + union { + struct rf_tech_specific_params_nfca_poll nfca_poll; + struct rf_tech_specific_params_nfcb_poll nfcb_poll; + struct rf_tech_specific_params_nfcf_poll nfcf_poll; + } rf_tech_specific_params; + + __u8 ntf_type; +} __packed; + +#define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) struct activation_params_nfca_poll_iso_dep { __u8 rats_res_len; __u8 rats_res[20]; diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index b9c3f8de13dd..86fee8b5c65c 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -46,6 +46,8 @@ enum nci_flag { enum nci_state { NCI_IDLE, NCI_DISCOVERY, + NCI_W4_ALL_DISCOVERIES, + NCI_W4_HOST_SELECT, NCI_POLL_ACTIVE, }; @@ -53,6 +55,7 @@ enum nci_state { #define NCI_RESET_TIMEOUT 5000 #define NCI_INIT_TIMEOUT 5000 #define NCI_RF_DISC_TIMEOUT 5000 +#define NCI_RF_DISC_SELECT_TIMEOUT 5000 #define NCI_RF_DEACTIVATE_TIMEOUT 30000 #define NCI_CMD_TIMEOUT 5000 #define NCI_DATA_TIMEOUT 700 @@ -66,6 +69,7 @@ struct nci_ops { }; #define NCI_MAX_SUPPORTED_RF_INTERFACES 4 +#define NCI_MAX_DISCOVERED_TARGETS 10 /* NCI Core structures */ struct nci_dev { @@ -105,9 +109,11 @@ struct nci_dev { void *driver_data; __u32 poll_prots; - __u32 target_available_prots; __u32 target_active_prot; + struct nfc_target targets[NCI_MAX_DISCOVERED_TARGETS]; + int n_targets; + /* received during NCI_OP_CORE_RESET_RSP */ __u8 nci_ver; @@ -178,6 +184,7 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload); int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb); void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, int err); +void nci_clear_target_list(struct nci_dev *ndev); /* ----- NCI requests ----- */ #define NCI_REQ_DONE 0 diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 629b76845973..12d1d4d62672 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -216,6 +216,39 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) &cmd); } +struct nci_rf_discover_select_param { + __u8 rf_discovery_id; + __u8 rf_protocol; +}; + +static void nci_rf_discover_select_req(struct nci_dev *ndev, unsigned long opt) +{ + struct nci_rf_discover_select_param *param = + (struct nci_rf_discover_select_param *)opt; + struct nci_rf_discover_select_cmd cmd; + + cmd.rf_discovery_id = param->rf_discovery_id; + cmd.rf_protocol = param->rf_protocol; + + switch (cmd.rf_protocol) { + case NCI_RF_PROTOCOL_ISO_DEP: + cmd.rf_interface = NCI_RF_INTERFACE_ISO_DEP; + break; + + case NCI_RF_PROTOCOL_NFC_DEP: + cmd.rf_interface = NCI_RF_INTERFACE_NFC_DEP; + break; + + default: + cmd.rf_interface = NCI_RF_INTERFACE_FRAME; + break; + } + + nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_SELECT_CMD, + sizeof(struct nci_rf_discover_select_cmd), + &cmd); +} + static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt) { struct nci_rf_deactivate_cmd cmd; @@ -264,6 +297,7 @@ static int nci_open_device(struct nci_dev *ndev) if (!rc) { set_bit(NCI_UP, &ndev->flags); + nci_clear_target_list(ndev); atomic_set(&ndev->state, NCI_IDLE); } else { /* Init failed, cleanup */ @@ -361,7 +395,8 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); int rc; - if (atomic_read(&ndev->state) == NCI_DISCOVERY) { + if ((atomic_read(&ndev->state) == NCI_DISCOVERY) || + (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) { pr_err("unable to start poll, since poll is already active\n"); return -EBUSY; } @@ -371,8 +406,9 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) return -EBUSY; } - if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { - pr_debug("target is active, implicitly deactivate...\n"); + if ((atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) || + (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) { + pr_debug("target active or w4 select, implicitly deactivate\n"); rc = nci_request(ndev, nci_rf_deactivate_req, 0, msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); @@ -393,7 +429,8 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev) { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); - if (atomic_read(&ndev->state) != NCI_DISCOVERY) { + if ((atomic_read(&ndev->state) != NCI_DISCOVERY) && + (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) { pr_err("unable to stop poll, since poll is not active\n"); return; } @@ -406,10 +443,15 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, __u32 protocol) { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); + struct nci_rf_discover_select_param param; + struct nfc_target *target = 0; + int i; + int rc = 0; pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); - if (atomic_read(&ndev->state) != NCI_POLL_ACTIVE) { + if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) && + (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { pr_err("there is no available target to activate\n"); return -EINVAL; } @@ -419,16 +461,47 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, return -EBUSY; } - if (!(ndev->target_available_prots & (1 << protocol))) { + for (i = 0; i < ndev->n_targets; i++) { + if (ndev->targets[i].idx == target_idx) { + target = &ndev->targets[i]; + break; + } + } + + if (!target) { + pr_err("unable to find the selected target\n"); + return -EINVAL; + } + + if (!(target->supported_protocols & (1 << protocol))) { pr_err("target does not support the requested protocol 0x%x\n", protocol); return -EINVAL; } - ndev->target_active_prot = protocol; - ndev->target_available_prots = 0; + if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { + param.rf_discovery_id = target->idx; - return 0; + if (protocol == NFC_PROTO_JEWEL) + param.rf_protocol = NCI_RF_PROTOCOL_T1T; + else if (protocol == NFC_PROTO_MIFARE) + param.rf_protocol = NCI_RF_PROTOCOL_T2T; + else if (protocol == NFC_PROTO_FELICA) + param.rf_protocol = NCI_RF_PROTOCOL_T3T; + else if (protocol == NFC_PROTO_ISO14443) + param.rf_protocol = NCI_RF_PROTOCOL_ISO_DEP; + else + param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP; + + rc = nci_request(ndev, nci_rf_discover_select_req, + (unsigned long)¶m, + msecs_to_jiffies(NCI_RF_DISC_SELECT_TIMEOUT)); + } + + if (!rc) + ndev->target_active_prot = protocol; + + return rc; } static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 8ec39464cea5..03e7b4626a3e 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -71,6 +71,20 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, queue_work(ndev->tx_wq, &ndev->tx_work); } +static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev, + struct sk_buff *skb) +{ + __u8 status = skb->data[0]; + + pr_debug("status 0x%x\n", status); + + if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { + /* Activation failed, so complete the request + (the state remains the same) */ + nci_req_complete(ndev, status); + } +} + static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) { @@ -86,12 +100,9 @@ static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev, } static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, - struct nci_rf_intf_activated_ntf *ntf, __u8 *data) + struct rf_tech_specific_params_nfca_poll *nfca_poll, + __u8 *data) { - struct rf_tech_specific_params_nfca_poll *nfca_poll; - - nfca_poll = &ntf->rf_tech_specific_params.nfca_poll; - nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); data += 2; @@ -116,12 +127,9 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, } static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, - struct nci_rf_intf_activated_ntf *ntf, __u8 *data) + struct rf_tech_specific_params_nfcb_poll *nfcb_poll, + __u8 *data) { - struct rf_tech_specific_params_nfcb_poll *nfcb_poll; - - nfcb_poll = &ntf->rf_tech_specific_params.nfcb_poll; - nfcb_poll->sensb_res_len = *data++; pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len); @@ -133,12 +141,9 @@ static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, } static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, - struct nci_rf_intf_activated_ntf *ntf, __u8 *data) + struct rf_tech_specific_params_nfcf_poll *nfcf_poll, + __u8 *data) { - struct rf_tech_specific_params_nfcf_poll *nfcf_poll; - - nfcf_poll = &ntf->rf_tech_specific_params.nfcf_poll; - nfcf_poll->bit_rate = *data++; nfcf_poll->sensf_res_len = *data++; @@ -151,6 +156,172 @@ static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, return data; } +static int nci_add_new_protocol(struct nci_dev *ndev, + struct nfc_target *target, + __u8 rf_protocol, + __u8 rf_tech_and_mode, + void *params) +{ + struct rf_tech_specific_params_nfca_poll *nfca_poll; + struct rf_tech_specific_params_nfcb_poll *nfcb_poll; + struct rf_tech_specific_params_nfcf_poll *nfcf_poll; + __u32 protocol; + + if (rf_protocol == NCI_RF_PROTOCOL_T2T) + protocol = NFC_PROTO_MIFARE_MASK; + else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) + protocol = NFC_PROTO_ISO14443_MASK; + else if (rf_protocol == NCI_RF_PROTOCOL_T3T) + protocol = NFC_PROTO_FELICA_MASK; + else + protocol = 0; + + if (!(protocol & ndev->poll_prots)) { + pr_err("the target found does not have the desired protocol\n"); + return -EPROTO; + } + + if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) { + nfca_poll = (struct rf_tech_specific_params_nfca_poll *)params; + + target->sens_res = nfca_poll->sens_res; + target->sel_res = nfca_poll->sel_res; + target->nfcid1_len = nfca_poll->nfcid1_len; + if (target->nfcid1_len > 0) { + memcpy(target->nfcid1, nfca_poll->nfcid1, + target->nfcid1_len); + } + } else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) { + nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params; + + target->sensb_res_len = nfcb_poll->sensb_res_len; + if (target->sensb_res_len > 0) { + memcpy(target->sensb_res, nfcb_poll->sensb_res, + target->sensb_res_len); + } + } else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) { + nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params; + + target->sensf_res_len = nfcf_poll->sensf_res_len; + if (target->sensf_res_len > 0) { + memcpy(target->sensf_res, nfcf_poll->sensf_res, + target->sensf_res_len); + } + } else { + pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); + return -EPROTO; + } + + target->supported_protocols |= protocol; + + pr_debug("protocol 0x%x\n", protocol); + + return 0; +} + +static void nci_add_new_target(struct nci_dev *ndev, + struct nci_rf_discover_ntf *ntf) +{ + struct nfc_target *target; + int i, rc; + + for (i = 0; i < ndev->n_targets; i++) { + target = &ndev->targets[i]; + if (target->idx == ntf->rf_discovery_id) { + /* This target already exists, add the new protocol */ + nci_add_new_protocol(ndev, target, ntf->rf_protocol, + ntf->rf_tech_and_mode, + &ntf->rf_tech_specific_params); + return; + } + } + + /* This is a new target, check if we've enough room */ + if (ndev->n_targets == NCI_MAX_DISCOVERED_TARGETS) { + pr_debug("not enough room, ignoring new target...\n"); + return; + } + + target = &ndev->targets[ndev->n_targets]; + + rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, + ntf->rf_tech_and_mode, + &ntf->rf_tech_specific_params); + if (!rc) { + target->idx = ntf->rf_discovery_id; + ndev->n_targets++; + + pr_debug("target_idx %d, n_targets %d\n", target->idx, + ndev->n_targets); + } +} + +void nci_clear_target_list(struct nci_dev *ndev) +{ + memset(ndev->targets, 0, + (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS)); + + ndev->n_targets = 0; +} + +static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, + struct sk_buff *skb) +{ + struct nci_rf_discover_ntf ntf; + __u8 *data = skb->data; + bool add_target = true; + + ntf.rf_discovery_id = *data++; + ntf.rf_protocol = *data++; + ntf.rf_tech_and_mode = *data++; + ntf.rf_tech_specific_params_len = *data++; + + pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id); + pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol); + pr_debug("rf_tech_and_mode 0x%x\n", ntf.rf_tech_and_mode); + pr_debug("rf_tech_specific_params_len %d\n", + ntf.rf_tech_specific_params_len); + + if (ntf.rf_tech_specific_params_len > 0) { + switch (ntf.rf_tech_and_mode) { + case NCI_NFC_A_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfca_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfca_poll), data); + break; + + case NCI_NFC_B_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcb_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfcb_poll), data); + break; + + case NCI_NFC_F_PASSIVE_POLL_MODE: + data = nci_extract_rf_params_nfcf_passive_poll(ndev, + &(ntf.rf_tech_specific_params.nfcf_poll), data); + break; + + default: + pr_err("unsupported rf_tech_and_mode 0x%x\n", + ntf.rf_tech_and_mode); + data += ntf.rf_tech_specific_params_len; + add_target = false; + } + } + + ntf.ntf_type = *data++; + pr_debug("ntf_type %d\n", ntf.ntf_type); + + if (add_target == true) + nci_add_new_target(ndev, &ntf); + + if (ntf.ntf_type == NCI_DISCOVER_NTF_TYPE_MORE) { + atomic_set(&ndev->state, NCI_W4_ALL_DISCOVERIES); + } else { + atomic_set(&ndev->state, NCI_W4_HOST_SELECT); + nfc_targets_found(ndev->nfc_dev, ndev->targets, + ndev->n_targets); + } +} + static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, struct nci_rf_intf_activated_ntf *ntf, __u8 *data) { @@ -184,74 +355,32 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, default: pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", ntf->activation_rf_tech_and_mode); - return -EPROTO; + return NCI_STATUS_RF_PROTOCOL_ERROR; } - return 0; + return NCI_STATUS_OK; } -static void nci_target_found(struct nci_dev *ndev, - struct nci_rf_intf_activated_ntf *ntf) +static void nci_target_auto_activated(struct nci_dev *ndev, + struct nci_rf_intf_activated_ntf *ntf) { - struct nfc_target nfc_tgt; + struct nfc_target *target; + int rc; - memset(&nfc_tgt, 0, sizeof(nfc_tgt)); + target = &ndev->targets[ndev->n_targets]; - if (ntf->rf_protocol == NCI_RF_PROTOCOL_T2T) - nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK; - else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) - nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK; - else if (ntf->rf_protocol == NCI_RF_PROTOCOL_T3T) - nfc_tgt.supported_protocols = NFC_PROTO_FELICA_MASK; - - if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) { - pr_debug("the target found does not have the desired protocol\n"); + rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, + ntf->activation_rf_tech_and_mode, + &ntf->rf_tech_specific_params); + if (rc) return; - } - pr_debug("new target found, supported_protocols 0x%x\n", - nfc_tgt.supported_protocols); - - if (ntf->activation_rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) { - nfc_tgt.sens_res = - ntf->rf_tech_specific_params.nfca_poll.sens_res; - nfc_tgt.sel_res = - ntf->rf_tech_specific_params.nfca_poll.sel_res; - nfc_tgt.nfcid1_len = - ntf->rf_tech_specific_params.nfca_poll.nfcid1_len; - if (nfc_tgt.nfcid1_len > 0) { - memcpy(nfc_tgt.nfcid1, - ntf->rf_tech_specific_params.nfca_poll.nfcid1, - nfc_tgt.nfcid1_len); - } - } else if (ntf->activation_rf_tech_and_mode == - NCI_NFC_B_PASSIVE_POLL_MODE) { - nfc_tgt.sensb_res_len = - ntf->rf_tech_specific_params.nfcb_poll.sensb_res_len; - if (nfc_tgt.sensb_res_len > 0) { - memcpy(nfc_tgt.sensb_res, - ntf->rf_tech_specific_params.nfcb_poll.sensb_res, - nfc_tgt.sensb_res_len); - } - } else if (ntf->activation_rf_tech_and_mode == - NCI_NFC_F_PASSIVE_POLL_MODE) { - nfc_tgt.sensf_res_len = - ntf->rf_tech_specific_params.nfcf_poll.sensf_res_len; - if (nfc_tgt.sensf_res_len > 0) { - memcpy(nfc_tgt.sensf_res, - ntf->rf_tech_specific_params.nfcf_poll.sensf_res, - nfc_tgt.sensf_res_len); - } - } + target->idx = ntf->rf_discovery_id; + ndev->n_targets++; - ndev->target_available_prots = nfc_tgt.supported_protocols; - ndev->max_data_pkt_payload_size = ntf->max_data_pkt_payload_size; - ndev->initial_num_credits = ntf->initial_num_credits; + pr_debug("target_idx %d, n_targets %d\n", target->idx, ndev->n_targets); - /* set the available credits to initial value */ - atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); - - nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1); + nfc_targets_found(ndev->nfc_dev, ndev->targets, ndev->n_targets); } static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, @@ -259,9 +388,7 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, { struct nci_rf_intf_activated_ntf ntf; __u8 *data = skb->data; - int err = 0; - - atomic_set(&ndev->state, NCI_POLL_ACTIVE); + int err = NCI_STATUS_OK; ntf.rf_discovery_id = *data++; ntf.rf_interface = *data++; @@ -286,23 +413,24 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, switch (ntf.activation_rf_tech_and_mode) { case NCI_NFC_A_PASSIVE_POLL_MODE: data = nci_extract_rf_params_nfca_passive_poll(ndev, - &ntf, data); + &(ntf.rf_tech_specific_params.nfca_poll), data); break; case NCI_NFC_B_PASSIVE_POLL_MODE: data = nci_extract_rf_params_nfcb_passive_poll(ndev, - &ntf, data); + &(ntf.rf_tech_specific_params.nfcb_poll), data); break; case NCI_NFC_F_PASSIVE_POLL_MODE: data = nci_extract_rf_params_nfcf_passive_poll(ndev, - &ntf, data); + &(ntf.rf_tech_specific_params.nfcf_poll), data); break; default: pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", ntf.activation_rf_tech_and_mode); - return; + err = NCI_STATUS_RF_PROTOCOL_ERROR; + goto exit; } } @@ -334,12 +462,30 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, default: pr_err("unsupported rf_interface 0x%x\n", ntf.rf_interface); - return; + err = NCI_STATUS_RF_PROTOCOL_ERROR; + break; } } - if (!err) - nci_target_found(ndev, &ntf); +exit: + if (err == NCI_STATUS_OK) { + ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size; + ndev->initial_num_credits = ntf.initial_num_credits; + + /* set the available credits to initial value */ + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); + } + + if (atomic_read(&ndev->state) == NCI_DISCOVERY) { + /* A single target was found and activated automatically */ + atomic_set(&ndev->state, NCI_POLL_ACTIVE); + if (err == NCI_STATUS_OK) + nci_target_auto_activated(ndev, &ntf); + } else { /* ndev->state == NCI_W4_HOST_SELECT */ + /* A selected target was activated, so complete the request */ + atomic_set(&ndev->state, NCI_POLL_ACTIVE); + nci_req_complete(ndev, err); + } } static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, @@ -349,9 +495,6 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason); - atomic_set(&ndev->state, NCI_IDLE); - ndev->target_active_prot = 0; - /* drop tx data queue */ skb_queue_purge(&ndev->tx_q); @@ -365,6 +508,8 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) nci_data_exchange_complete(ndev, NULL, -EIO); + nci_clear_target_list(ndev); + atomic_set(&ndev->state, NCI_IDLE); nci_req_complete(ndev, NCI_STATUS_OK); } @@ -386,10 +531,18 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) nci_core_conn_credits_ntf_packet(ndev, skb); break; + case NCI_OP_CORE_GENERIC_ERROR_NTF: + nci_core_generic_error_ntf_packet(ndev, skb); + break; + case NCI_OP_CORE_INTF_ERROR_NTF: nci_core_conn_intf_error_ntf_packet(ndev, skb); break; + case NCI_OP_RF_DISCOVER_NTF: + nci_rf_discover_ntf_packet(ndev, skb); + break; + case NCI_OP_RF_INTF_ACTIVATED_NTF: nci_rf_intf_activated_ntf_packet(ndev, skb); break; diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index cb8bce6899cf..aa63b1e99188 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c @@ -142,6 +142,18 @@ static void nci_rf_disc_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) nci_req_complete(ndev, status); } +static void nci_rf_disc_select_rsp_packet(struct nci_dev *ndev, + struct sk_buff *skb) +{ + __u8 status = skb->data[0]; + + pr_debug("status 0x%x\n", status); + + /* Complete the request on intf_activated_ntf or generic_error_ntf */ + if (status != NCI_STATUS_OK) + nci_req_complete(ndev, status); +} + static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) { @@ -152,6 +164,7 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, /* If target was active, complete the request only in deactivate_ntf */ if ((status != NCI_STATUS_OK) || (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { + nci_clear_target_list(ndev); atomic_set(&ndev->state, NCI_IDLE); nci_req_complete(ndev, status); } @@ -190,6 +203,10 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) nci_rf_disc_rsp_packet(ndev, skb); break; + case NCI_OP_RF_DISCOVER_SELECT_RSP: + nci_rf_disc_select_rsp_packet(ndev, skb); + break; + case NCI_OP_RF_DEACTIVATE_RSP: nci_rf_deactivate_rsp_packet(ndev, skb); break; -- GitLab From d7d312cab41b2c973951fcc7f752411cbaaf8338 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Tue, 17 Jan 2012 23:13:30 +0100 Subject: [PATCH 0133/1846] ath9k_htc: claim support for IBSS RSN Skip group keys configuration in hardware in order to make IBSS RSN work. Keys will be managed using software. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 ++ drivers/net/wireless/ath/ath9k/htc_drv_main.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index 9be10a2da1c2..fc7519c93390 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -741,6 +741,8 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv, hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; + hw->queues = 4; hw->channel_change_time = 5000; hw->max_listen_interval = 10; diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c index ef4c60661290..06101b6bdeac 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c @@ -1409,6 +1409,21 @@ static int ath9k_htc_set_key(struct ieee80211_hw *hw, if (htc_modparam_nohwcrypt) return -ENOSPC; + 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)) { + /* + * For now, disable hw crypto for the RSN IBSS group keys. This + * could be optimized in the future to use a modified key cache + * design to support per-STA RX GTK, but until that gets + * implemented, use of software crypto for group addressed + * frames is a acceptable to allow RSN IBSS to be used. + */ + return -EOPNOTSUPP; + } + mutex_lock(&priv->mutex); ath_dbg(common, CONFIG, "Set HW Key\n"); ath9k_htc_ps_wakeup(priv); -- GitLab From 11deb53328a06ad4edbf774f5c3b61c6dbb9104c Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 24 Jan 2012 14:58:47 -0500 Subject: [PATCH 0134/1846] ath5k: use bool type for no_hw_rfkill_switch module parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids this: CC [M] drivers/net/wireless/ath/ath5k/base.o drivers/net/wireless/ath/ath5k/base.c: In function ‘__check_no_hw_rfkill_switch’: drivers/net/wireless/ath/ath5k/base.c:85:1: warning: return from incompatible pointer type Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 4ab835f08a43..a339693fbe26 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -80,7 +80,7 @@ static bool 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; +static bool 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"); -- GitLab From 47d505ccc7535c825f6b28aaaf105d4b75f25196 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 24 Jan 2012 15:03:04 -0500 Subject: [PATCH 0135/1846] orinoco_usb: remove version definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids this: CC [M] drivers/net/wireless/orinoco/orinoco_usb.o drivers/net/wireless/orinoco/orinoco_usb.c:1759:13: warning: ‘version’ defined but not used Signed-off-by: John W. Linville --- drivers/net/wireless/orinoco/orinoco_usb.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c index ae8ce56670b6..f634d4582bfe 100644 --- a/drivers/net/wireless/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/orinoco/orinoco_usb.c @@ -1754,11 +1754,6 @@ static struct usb_driver orinoco_driver = { .id_table = ezusb_table, }; -/* Can't be declared "const" or the whole __initdata section will - * become const */ -static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION - " (Manuel Estrada Sainz)"; - module_usb_driver(orinoco_driver); MODULE_AUTHOR("Manuel Estrada Sainz"); -- GitLab From 496053f488fc2d859e41574f3421993826d2d0eb Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 11 Jan 2012 16:46:32 -0800 Subject: [PATCH 0136/1846] ipv4: Remove bogus checks of rt_gateway being zero. It can never actually happen. rt_gateway is either the fully resolved flow lookup key's destination address, or the non-zero FIB entry gateway address. Signed-off-by: David S. Miller --- net/ipv4/ip_gre.c | 8 +++----- net/ipv4/ipip.c | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 2b53a1f7abf6..fc213350a6ed 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -724,11 +724,8 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev goto tx_error; } - if (skb->protocol == htons(ETH_P_IP)) { + if (skb->protocol == htons(ETH_P_IP)) rt = skb_rtable(skb); - if ((dst = rt->rt_gateway) == 0) - goto tx_error_icmp; - } #if IS_ENABLED(CONFIG_IPV6) else if (skb->protocol == htons(ETH_P_IPV6)) { struct neighbour *neigh = dst_get_neighbour_noref(skb_dst(skb)); @@ -910,9 +907,10 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev __IPTUNNEL_XMIT(tstats, &dev->stats); return NETDEV_TX_OK; +#if IS_ENABLED(CONFIG_IPV6) tx_error_icmp: dst_link_failure(skb); - +#endif tx_error: dev->stats.tx_errors++; dev_kfree_skb(skb); diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 22a199315309..87c63b67f8ce 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -454,8 +454,6 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) dev->stats.tx_fifo_errors++; goto tx_error; } - if ((dst = rt->rt_gateway) == 0) - goto tx_error_icmp; } rt = ip_route_output_ports(dev_net(dev), &fl4, NULL, -- GitLab From 658c8d964eb3cdb7e4230a59ba09c75a3359ee4a Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 24 Jan 2012 18:18:05 -0500 Subject: [PATCH 0137/1846] ipip: Fix bug added to ipip_tunnel_xmit(). We can remove the rt_gateway == 0 check but we shouldn't remove the 'dst' initialization too. Noticed by Eric Dumazet. Signed-off-by: David S. Miller --- net/ipv4/ipip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 87c63b67f8ce..f84ebff5cdb0 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -454,6 +454,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) dev->stats.tx_fifo_errors++; goto tx_error; } + dst = rt->rt_gateway; } rt = ip_route_output_ports(dev_net(dev), &fl4, NULL, -- GitLab From 61d57f87f3fb04a305f22befabd042ffbec8b852 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 24 Jan 2012 18:23:30 -0500 Subject: [PATCH 0138/1846] ip_gre: Fix bug added to ipgre_tunnel_xmit(). We can remove the rt_gateway == 0 check but we shouldn't remove the 'dst' initialization too. Noticed by Eric Dumazet. Signed-off-by: David S. Miller --- net/ipv4/ip_gre.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index fc213350a6ed..05f7419ed7c5 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -724,8 +724,10 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev goto tx_error; } - if (skb->protocol == htons(ETH_P_IP)) + if (skb->protocol == htons(ETH_P_IP)) { rt = skb_rtable(skb); + dst = rt->rt_gateway; + } #if IS_ENABLED(CONFIG_IPV6) else if (skb->protocol == htons(ETH_P_IPV6)) { struct neighbour *neigh = dst_get_neighbour_noref(skb_dst(skb)); -- GitLab From cf66f9d48a9c95baf8f13b199a633ce1c4cf952a Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Mon, 23 Jan 2012 08:24:43 +0000 Subject: [PATCH 0139/1846] xen/netfront: add netconsole support. add polling interface to xen-netfront device to support netconsole This patch also alters the spin_lock usage to use irqsave variant. Documentation/networking/netdevices.txt states that start_xmit can be called with interrupts disabled by netconsole and therefore using the irqsave/restore locking in this function is looks correct. Signed-off-by: Tina.Yang Cc: Jeremy Fitzhardinge Signed-off-by: Zhenzhong.Duan Tested-by: gurudas.pai [v1: Copy-n-pasted Ian Campbell comments] Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Ian Campbell Signed-off-by: David S. Miller --- drivers/net/xen-netfront.c | 57 +++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index fa679057630f..db638b4454e3 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -489,6 +489,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) int frags = skb_shinfo(skb)->nr_frags; unsigned int offset = offset_in_page(data); unsigned int len = skb_headlen(skb); + unsigned long flags; frags += DIV_ROUND_UP(offset + len, PAGE_SIZE); if (unlikely(frags > MAX_SKB_FRAGS + 1)) { @@ -498,12 +499,12 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) goto drop; } - spin_lock_irq(&np->tx_lock); + spin_lock_irqsave(&np->tx_lock, flags); if (unlikely(!netif_carrier_ok(dev) || (frags > 1 && !xennet_can_sg(dev)) || netif_needs_gso(skb, netif_skb_features(skb)))) { - spin_unlock_irq(&np->tx_lock); + spin_unlock_irqrestore(&np->tx_lock, flags); goto drop; } @@ -574,7 +575,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) if (!netfront_tx_slot_available(np)) netif_stop_queue(dev); - spin_unlock_irq(&np->tx_lock); + spin_unlock_irqrestore(&np->tx_lock, flags); return NETDEV_TX_OK; @@ -1228,6 +1229,33 @@ static int xennet_set_features(struct net_device *dev, return 0; } +static irqreturn_t xennet_interrupt(int irq, void *dev_id) +{ + struct net_device *dev = dev_id; + struct netfront_info *np = netdev_priv(dev); + unsigned long flags; + + spin_lock_irqsave(&np->tx_lock, flags); + + if (likely(netif_carrier_ok(dev))) { + xennet_tx_buf_gc(dev); + /* Under tx_lock: protects access to rx shared-ring indexes. */ + if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx)) + napi_schedule(&np->napi); + } + + spin_unlock_irqrestore(&np->tx_lock, flags); + + return IRQ_HANDLED; +} + +#ifdef CONFIG_NET_POLL_CONTROLLER +static void xennet_poll_controller(struct net_device *dev) +{ + xennet_interrupt(0, dev); +} +#endif + static const struct net_device_ops xennet_netdev_ops = { .ndo_open = xennet_open, .ndo_uninit = xennet_uninit, @@ -1239,6 +1267,9 @@ static const struct net_device_ops xennet_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_fix_features = xennet_fix_features, .ndo_set_features = xennet_set_features, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = xennet_poll_controller, +#endif }; static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev) @@ -1448,26 +1479,6 @@ static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[]) return 0; } -static irqreturn_t xennet_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct netfront_info *np = netdev_priv(dev); - unsigned long flags; - - spin_lock_irqsave(&np->tx_lock, flags); - - if (likely(netif_carrier_ok(dev))) { - xennet_tx_buf_gc(dev); - /* Under tx_lock: protects access to rx shared-ring indexes. */ - if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx)) - napi_schedule(&np->napi); - } - - spin_unlock_irqrestore(&np->tx_lock, flags); - - return IRQ_HANDLED; -} - static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info) { struct xen_netif_tx_sring *txs; -- GitLab From aaca2377e9c08d1964a5cacb95330708a6f6d106 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 23 Jan 2012 16:44:50 +0000 Subject: [PATCH 0140/1846] net: fec: use module_platform_driver Using module_platform_driver can make the code smaller. Signed-off-by: Fabio Estevam Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/fec.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index 7b25e9cf13f6..e5885ccfc8ff 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -1739,21 +1739,6 @@ static struct platform_driver fec_driver = { .remove = __devexit_p(fec_drv_remove), }; -static int __init -fec_enet_module_init(void) -{ - printk(KERN_INFO "FEC Ethernet Driver\n"); - - return platform_driver_register(&fec_driver); -} - -static void __exit -fec_enet_cleanup(void) -{ - platform_driver_unregister(&fec_driver); -} - -module_exit(fec_enet_cleanup); -module_init(fec_enet_module_init); +module_platform_driver(fec_driver); MODULE_LICENSE("GPL"); -- GitLab From 8bca5d1ebb8bf18187256845ba3aaff5fbc01934 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 24 Jan 2012 19:47:21 +0000 Subject: [PATCH 0141/1846] vmxnet3: cleanup tso headers manipulation Use existing helpers to clarify skb headers manipulation. Signed-off-by: Eric Dumazet Cc: Shreyas Bhatewara Signed-off-by: David S. Miller --- drivers/net/vmxnet3/vmxnet3_drv.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index de7fc345148a..be6aa353f6a1 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -816,27 +816,24 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, if (ctx->mss) { /* TSO */ ctx->eth_ip_hdr_size = skb_transport_offset(skb); - ctx->l4_hdr_size = ((struct tcphdr *) - skb_transport_header(skb))->doff * 4; + ctx->l4_hdr_size = tcp_hdrlen(skb); ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; } else { if (skb->ip_summed == CHECKSUM_PARTIAL) { ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); if (ctx->ipv4) { - struct iphdr *iph = (struct iphdr *) - skb_network_header(skb); + const struct iphdr *iph = ip_hdr(skb); + if (iph->protocol == IPPROTO_TCP) - ctx->l4_hdr_size = ((struct tcphdr *) - skb_transport_header(skb))->doff * 4; + ctx->l4_hdr_size = tcp_hdrlen(skb); else if (iph->protocol == IPPROTO_UDP) /* * Use tcp header size so that bytes to * be copied are more than required by * the device. */ - ctx->l4_hdr_size = - sizeof(struct tcphdr); + ctx->l4_hdr_size = sizeof(struct tcphdr); else ctx->l4_hdr_size = 0; } else { @@ -881,14 +878,17 @@ static void vmxnet3_prepare_tso(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx) { - struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb); + struct tcphdr *tcph = tcp_hdr(skb); + if (ctx->ipv4) { - struct iphdr *iph = (struct iphdr *)skb_network_header(skb); + struct iphdr *iph = ip_hdr(skb); + iph->check = 0; tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, IPPROTO_TCP, 0); } else { - struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb); + struct ipv6hdr *iph = ipv6_hdr(skb); + tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, IPPROTO_TCP, 0); } -- GitLab From a44acd551467d78a26bfa76ea348225575830efc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 24 Jan 2012 21:59:31 +0000 Subject: [PATCH 0142/1846] bnx2x: unlock before returning an error We introduced a new return here but forgot to drop the lock. Signed-off-by: Dan Carpenter Acked-by: Dmitry Kravkov Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index cb6339c35571..69465c32e5f6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -1836,6 +1836,7 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp, rc = exeq->remove(bp, exeq->owner, exeq_pos); if (rc) { BNX2X_ERR("Failed to remove command\n"); + spin_unlock_bh(&exeq->lock); return rc; } list_del(&exeq_pos->link); -- GitLab From 8a3b7a252dca9fb28c23b5bf76c49180a2b60d3b Mon Sep 17 00:00:00 2001 From: "danborkmann@iogearbox.net" Date: Thu, 19 Jan 2012 00:39:31 +0000 Subject: [PATCH 0143/1846] drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver This driver adds support for Xilinx 10/100/1000 AXI Ethernet. It can be used, for instance, on Xilinx boards with a Microblaze architecture like the ML605. The patch is against the latest net-next tree and checkpatch clean. Signed-off-by: Ariane Keller Signed-off-by: Daniel Borkmann Signed-off-by: David S. Miller --- MAINTAINERS | 6 + drivers/net/ethernet/xilinx/Kconfig | 8 + drivers/net/ethernet/xilinx/Makefile | 2 + drivers/net/ethernet/xilinx/xilinx_axienet.h | 508 +++++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 1682 +++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_mdio.c | 238 +++ 6 files changed, 2444 insertions(+) create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet.h create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_main.c create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c diff --git a/MAINTAINERS b/MAINTAINERS index 93c68d5f1cf4..087b65d12580 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7469,6 +7469,12 @@ S: Supported F: Documentation/filesystems/xfs.txt F: fs/xfs/ +XILINX AXI ETHERNET DRIVER +M: Ariane Keller +M: Daniel Borkmann +S: Maintained +F: drivers/net/ethernet/xilinx/xilinx_axienet* + XILINX SYSTEMACE DRIVER M: Grant Likely W: http://www.secretlab.ca/ diff --git a/drivers/net/ethernet/xilinx/Kconfig b/drivers/net/ethernet/xilinx/Kconfig index d5a826063a82..5778a4ae1164 100644 --- a/drivers/net/ethernet/xilinx/Kconfig +++ b/drivers/net/ethernet/xilinx/Kconfig @@ -25,6 +25,14 @@ config XILINX_EMACLITE ---help--- This driver supports the 10/100 Ethernet Lite from Xilinx. +config XILINX_AXI_EMAC + tristate "Xilinx 10/100/1000 AXI Ethernet support" + depends on (PPC32 || MICROBLAZE) + select PHYLIB + ---help--- + This driver supports the 10/100/1000 Ethernet from Xilinx for the + AXI bus interface used in Xilinx Virtex FPGAs. + config XILINX_LL_TEMAC tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver" depends on (PPC || MICROBLAZE) diff --git a/drivers/net/ethernet/xilinx/Makefile b/drivers/net/ethernet/xilinx/Makefile index 5feac734ea45..214205e975e3 100644 --- a/drivers/net/ethernet/xilinx/Makefile +++ b/drivers/net/ethernet/xilinx/Makefile @@ -5,3 +5,5 @@ ll_temac-objs := ll_temac_main.o ll_temac_mdio.o obj-$(CONFIG_XILINX_LL_TEMAC) += ll_temac.o obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o +xilinx_emac-objs := xilinx_axienet_main.o xilinx_axienet_mdio.o +obj-$(CONFIG_XILINX_AXI_EMAC) += xilinx_emac.o diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h new file mode 100644 index 000000000000..cc83af083fd7 --- /dev/null +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -0,0 +1,508 @@ +/* + * Definitions for Xilinx Axi Ethernet device driver. + * + * Copyright (c) 2009 Secret Lab Technologies, Ltd. + * Copyright (c) 2010 Xilinx, Inc. All rights reserved. + * Copyright (c) 2012 Daniel Borkmann, + * Copyright (c) 2012 Ariane Keller, + */ + +#ifndef XILINX_AXIENET_H +#define XILINX_AXIENET_H + +#include +#include +#include + +/* Packet size info */ +#define XAE_HDR_SIZE 14 /* Size of Ethernet header */ +#define XAE_HDR_VLAN_SIZE 18 /* Size of an Ethernet hdr + VLAN */ +#define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */ +#define XAE_MTU 1500 /* Max MTU of an Ethernet frame */ +#define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */ + +#define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE) +#define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + XAE_HDR_VLAN_SIZE + XAE_TRL_SIZE) +#define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE) + +/* Configuration options */ + +/* Accept all incoming packets. Default: disabled (cleared) */ +#define XAE_OPTION_PROMISC (1 << 0) + +/* Jumbo frame support for Tx & Rx. Default: disabled (cleared) */ +#define XAE_OPTION_JUMBO (1 << 1) + +/* VLAN Rx & Tx frame support. Default: disabled (cleared) */ +#define XAE_OPTION_VLAN (1 << 2) + +/* Enable recognition of flow control frames on Rx. Default: enabled (set) */ +#define XAE_OPTION_FLOW_CONTROL (1 << 4) + +/* Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not + * stripped. Default: disabled (set) */ +#define XAE_OPTION_FCS_STRIP (1 << 5) + +/* Generate FCS field and add PAD automatically for outgoing frames. + * Default: enabled (set) */ +#define XAE_OPTION_FCS_INSERT (1 << 6) + +/* Enable Length/Type error checking for incoming frames. When this option is + * set, the MAC will filter frames that have a mismatched type/length field + * and if XAE_OPTION_REPORT_RXERR is set, the user is notified when these + * types of frames are encountered. When this option is cleared, the MAC will + * allow these types of frames to be received. Default: enabled (set) */ +#define XAE_OPTION_LENTYPE_ERR (1 << 7) + +/* Enable the transmitter. Default: enabled (set) */ +#define XAE_OPTION_TXEN (1 << 11) + +/* Enable the receiver. Default: enabled (set) */ +#define XAE_OPTION_RXEN (1 << 12) + +/* Default options set when device is initialized or reset */ +#define XAE_OPTION_DEFAULTS \ + (XAE_OPTION_TXEN | \ + XAE_OPTION_FLOW_CONTROL | \ + XAE_OPTION_RXEN) + +/* Axi DMA Register definitions */ + +#define XAXIDMA_TX_CR_OFFSET 0x00000000 /* Channel control */ +#define XAXIDMA_TX_SR_OFFSET 0x00000004 /* Status */ +#define XAXIDMA_TX_CDESC_OFFSET 0x00000008 /* Current descriptor pointer */ +#define XAXIDMA_TX_TDESC_OFFSET 0x00000010 /* Tail descriptor pointer */ + +#define XAXIDMA_RX_CR_OFFSET 0x00000030 /* Channel control */ +#define XAXIDMA_RX_SR_OFFSET 0x00000034 /* Status */ +#define XAXIDMA_RX_CDESC_OFFSET 0x00000038 /* Current descriptor pointer */ +#define XAXIDMA_RX_TDESC_OFFSET 0x00000040 /* Tail descriptor pointer */ + +#define XAXIDMA_CR_RUNSTOP_MASK 0x00000001 /* Start/stop DMA channel */ +#define XAXIDMA_CR_RESET_MASK 0x00000004 /* Reset DMA engine */ + +#define XAXIDMA_BD_NDESC_OFFSET 0x00 /* Next descriptor pointer */ +#define XAXIDMA_BD_BUFA_OFFSET 0x08 /* Buffer address */ +#define XAXIDMA_BD_CTRL_LEN_OFFSET 0x18 /* Control/buffer length */ +#define XAXIDMA_BD_STS_OFFSET 0x1C /* Status */ +#define XAXIDMA_BD_USR0_OFFSET 0x20 /* User IP specific word0 */ +#define XAXIDMA_BD_USR1_OFFSET 0x24 /* User IP specific word1 */ +#define XAXIDMA_BD_USR2_OFFSET 0x28 /* User IP specific word2 */ +#define XAXIDMA_BD_USR3_OFFSET 0x2C /* User IP specific word3 */ +#define XAXIDMA_BD_USR4_OFFSET 0x30 /* User IP specific word4 */ +#define XAXIDMA_BD_ID_OFFSET 0x34 /* Sw ID */ +#define XAXIDMA_BD_HAS_STSCNTRL_OFFSET 0x38 /* Whether has stscntrl strm */ +#define XAXIDMA_BD_HAS_DRE_OFFSET 0x3C /* Whether has DRE */ + +#define XAXIDMA_BD_HAS_DRE_SHIFT 8 /* Whether has DRE shift */ +#define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */ +#define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */ + +#define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */ +#define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */ +#define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */ +#define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */ + +#define XAXIDMA_DELAY_MASK 0xFF000000 /* Delay timeout counter */ +#define XAXIDMA_COALESCE_MASK 0x00FF0000 /* Coalesce counter */ + +#define XAXIDMA_DELAY_SHIFT 24 +#define XAXIDMA_COALESCE_SHIFT 16 + +#define XAXIDMA_IRQ_IOC_MASK 0x00001000 /* Completion intr */ +#define XAXIDMA_IRQ_DELAY_MASK 0x00002000 /* Delay interrupt */ +#define XAXIDMA_IRQ_ERROR_MASK 0x00004000 /* Error interrupt */ +#define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */ + +/* Default TX/RX Threshold and waitbound values for SGDMA mode */ +#define XAXIDMA_DFT_TX_THRESHOLD 24 +#define XAXIDMA_DFT_TX_WAITBOUND 254 +#define XAXIDMA_DFT_RX_THRESHOLD 24 +#define XAXIDMA_DFT_RX_WAITBOUND 254 + +#define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */ +#define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */ +#define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */ + +#define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */ +#define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000 /* Completed */ +#define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000 /* Decode error */ +#define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000 /* Slave error */ +#define XAXIDMA_BD_STS_INT_ERR_MASK 0x10000000 /* Internal err */ +#define XAXIDMA_BD_STS_ALL_ERR_MASK 0x70000000 /* All errors */ +#define XAXIDMA_BD_STS_RXSOF_MASK 0x08000000 /* First rx pkt */ +#define XAXIDMA_BD_STS_RXEOF_MASK 0x04000000 /* Last rx pkt */ +#define XAXIDMA_BD_STS_ALL_MASK 0xFC000000 /* All status bits */ + +#define XAXIDMA_BD_MINIMUM_ALIGNMENT 0x40 + +/* Axi Ethernet registers definition */ +#define XAE_RAF_OFFSET 0x00000000 /* Reset and Address filter */ +#define XAE_TPF_OFFSET 0x00000004 /* Tx Pause Frame */ +#define XAE_IFGP_OFFSET 0x00000008 /* Tx Inter-frame gap adjustment*/ +#define XAE_IS_OFFSET 0x0000000C /* Interrupt status */ +#define XAE_IP_OFFSET 0x00000010 /* Interrupt pending */ +#define XAE_IE_OFFSET 0x00000014 /* Interrupt enable */ +#define XAE_TTAG_OFFSET 0x00000018 /* Tx VLAN TAG */ +#define XAE_RTAG_OFFSET 0x0000001C /* Rx VLAN TAG */ +#define XAE_UAWL_OFFSET 0x00000020 /* Unicast address word lower */ +#define XAE_UAWU_OFFSET 0x00000024 /* Unicast address word upper */ +#define XAE_TPID0_OFFSET 0x00000028 /* VLAN TPID0 register */ +#define XAE_TPID1_OFFSET 0x0000002C /* VLAN TPID1 register */ +#define XAE_PPST_OFFSET 0x00000030 /* PCS PMA Soft Temac Status Reg */ +#define XAE_RCW0_OFFSET 0x00000400 /* Rx Configuration Word 0 */ +#define XAE_RCW1_OFFSET 0x00000404 /* Rx Configuration Word 1 */ +#define XAE_TC_OFFSET 0x00000408 /* Tx Configuration */ +#define XAE_FCC_OFFSET 0x0000040C /* Flow Control Configuration */ +#define XAE_EMMC_OFFSET 0x00000410 /* EMAC mode configuration */ +#define XAE_PHYC_OFFSET 0x00000414 /* RGMII/SGMII configuration */ +#define XAE_MDIO_MC_OFFSET 0x00000500 /* MII Management Config */ +#define XAE_MDIO_MCR_OFFSET 0x00000504 /* MII Management Control */ +#define XAE_MDIO_MWD_OFFSET 0x00000508 /* MII Management Write Data */ +#define XAE_MDIO_MRD_OFFSET 0x0000050C /* MII Management Read Data */ +#define XAE_MDIO_MIS_OFFSET 0x00000600 /* MII Management Interrupt Status */ +#define XAE_MDIO_MIP_OFFSET 0x00000620 /* MII Mgmt Interrupt Pending + * register offset */ +#define XAE_MDIO_MIE_OFFSET 0x00000640 /* MII Management Interrupt Enable + * register offset */ +#define XAE_MDIO_MIC_OFFSET 0x00000660 /* MII Management Interrupt Clear + * register offset. */ +#define XAE_UAW0_OFFSET 0x00000700 /* Unicast address word 0 */ +#define XAE_UAW1_OFFSET 0x00000704 /* Unicast address word 1 */ +#define XAE_FMI_OFFSET 0x00000708 /* Filter Mask Index */ +#define XAE_AF0_OFFSET 0x00000710 /* Address Filter 0 */ +#define XAE_AF1_OFFSET 0x00000714 /* Address Filter 1 */ + +#define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */ +#define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */ +#define XAE_MCAST_TABLE_OFFSET 0x00020000 /* Multicast table address */ + +/* Bit Masks for Axi Ethernet RAF register */ +#define XAE_RAF_MCSTREJ_MASK 0x00000002 /* Reject receive multicast + * destination address */ +#define XAE_RAF_BCSTREJ_MASK 0x00000004 /* Reject receive broadcast + * destination address */ +#define XAE_RAF_TXVTAGMODE_MASK 0x00000018 /* Tx VLAN TAG mode */ +#define XAE_RAF_RXVTAGMODE_MASK 0x00000060 /* Rx VLAN TAG mode */ +#define XAE_RAF_TXVSTRPMODE_MASK 0x00000180 /* Tx VLAN STRIP mode */ +#define XAE_RAF_RXVSTRPMODE_MASK 0x00000600 /* Rx VLAN STRIP mode */ +#define XAE_RAF_NEWFNCENBL_MASK 0x00000800 /* New function mode */ +#define XAE_RAF_EMULTIFLTRENBL_MASK 0x00001000 /* Exteneded Multicast + * Filtering mode + */ +#define XAE_RAF_STATSRST_MASK 0x00002000 /* Stats. Counter Reset */ +#define XAE_RAF_RXBADFRMEN_MASK 0x00004000 /* Recv Bad Frame Enable */ +#define XAE_RAF_TXVTAGMODE_SHIFT 3 /* Tx Tag mode shift bits */ +#define XAE_RAF_RXVTAGMODE_SHIFT 5 /* Rx Tag mode shift bits */ +#define XAE_RAF_TXVSTRPMODE_SHIFT 7 /* Tx strip mode shift bits*/ +#define XAE_RAF_RXVSTRPMODE_SHIFT 9 /* Rx Strip mode shift bits*/ + +/* Bit Masks for Axi Ethernet TPF and IFGP registers */ +#define XAE_TPF_TPFV_MASK 0x0000FFFF /* Tx pause frame value */ +#define XAE_IFGP0_IFGP_MASK 0x0000007F /* Transmit inter-frame + * gap adjustment value */ + +/* Bit Masks for Axi Ethernet IS, IE and IP registers, Same masks apply + * for all 3 registers. */ +#define XAE_INT_HARDACSCMPLT_MASK 0x00000001 /* Hard register access + * complete */ +#define XAE_INT_AUTONEG_MASK 0x00000002 /* Auto negotiation + * complete */ +#define XAE_INT_RXCMPIT_MASK 0x00000004 /* Rx complete */ +#define XAE_INT_RXRJECT_MASK 0x00000008 /* Rx frame rejected */ +#define XAE_INT_RXFIFOOVR_MASK 0x00000010 /* Rx fifo overrun */ +#define XAE_INT_TXCMPIT_MASK 0x00000020 /* Tx complete */ +#define XAE_INT_RXDCMLOCK_MASK 0x00000040 /* Rx Dcm Lock */ +#define XAE_INT_MGTRDY_MASK 0x00000080 /* MGT clock Lock */ +#define XAE_INT_PHYRSTCMPLT_MASK 0x00000100 /* Phy Reset complete */ +#define XAE_INT_ALL_MASK 0x0000003F /* All the ints */ + +#define XAE_INT_RECV_ERROR_MASK \ + (XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK) /* INT bits that + * indicate receive + * errors */ + +/* Bit masks for Axi Ethernet VLAN TPID Word 0 register */ +#define XAE_TPID_0_MASK 0x0000FFFF /* TPID 0 */ +#define XAE_TPID_1_MASK 0xFFFF0000 /* TPID 1 */ + +/* Bit masks for Axi Ethernet VLAN TPID Word 1 register */ +#define XAE_TPID_2_MASK 0x0000FFFF /* TPID 0 */ +#define XAE_TPID_3_MASK 0xFFFF0000 /* TPID 1 */ + +/* Bit masks for Axi Ethernet RCW1 register */ +#define XAE_RCW1_RST_MASK 0x80000000 /* Reset */ +#define XAE_RCW1_JUM_MASK 0x40000000 /* Jumbo frame enable */ +#define XAE_RCW1_FCS_MASK 0x20000000 /* In-Band FCS enable + * (FCS not stripped) */ +#define XAE_RCW1_RX_MASK 0x10000000 /* Receiver enable */ +#define XAE_RCW1_VLAN_MASK 0x08000000 /* VLAN frame enable */ +#define XAE_RCW1_LT_DIS_MASK 0x02000000 /* Length/type field valid check + * disable */ +#define XAE_RCW1_CL_DIS_MASK 0x01000000 /* Control frame Length check + * disable */ +#define XAE_RCW1_PAUSEADDR_MASK 0x0000FFFF /* Pause frame source address + * bits [47:32]. Bits [31:0] are + * stored in register RCW0 */ + +/* Bit masks for Axi Ethernet TC register */ +#define XAE_TC_RST_MASK 0x80000000 /* Reset */ +#define XAE_TC_JUM_MASK 0x40000000 /* Jumbo frame enable */ +#define XAE_TC_FCS_MASK 0x20000000 /* In-Band FCS enable + * (FCS not generated) */ +#define XAE_TC_TX_MASK 0x10000000 /* Transmitter enable */ +#define XAE_TC_VLAN_MASK 0x08000000 /* VLAN frame enable */ +#define XAE_TC_IFG_MASK 0x02000000 /* Inter-frame gap adjustment + * enable */ + +/* Bit masks for Axi Ethernet FCC register */ +#define XAE_FCC_FCRX_MASK 0x20000000 /* Rx flow control enable */ +#define XAE_FCC_FCTX_MASK 0x40000000 /* Tx flow control enable */ + +/* Bit masks for Axi Ethernet EMMC register */ +#define XAE_EMMC_LINKSPEED_MASK 0xC0000000 /* Link speed */ +#define XAE_EMMC_RGMII_MASK 0x20000000 /* RGMII mode enable */ +#define XAE_EMMC_SGMII_MASK 0x10000000 /* SGMII mode enable */ +#define XAE_EMMC_GPCS_MASK 0x08000000 /* 1000BaseX mode enable */ +#define XAE_EMMC_HOST_MASK 0x04000000 /* Host interface enable */ +#define XAE_EMMC_TX16BIT 0x02000000 /* 16 bit Tx client enable */ +#define XAE_EMMC_RX16BIT 0x01000000 /* 16 bit Rx client enable */ +#define XAE_EMMC_LINKSPD_10 0x00000000 /* Link Speed mask for 10 Mbit */ +#define XAE_EMMC_LINKSPD_100 0x40000000 /* Link Speed mask for 100 Mbit */ +#define XAE_EMMC_LINKSPD_1000 0x80000000 /* Link Speed mask for 1000 Mbit */ + +/* Bit masks for Axi Ethernet PHYC register */ +#define XAE_PHYC_SGMIILINKSPEED_MASK 0xC0000000 /* SGMII link speed mask*/ +#define XAE_PHYC_RGMIILINKSPEED_MASK 0x0000000C /* RGMII link speed */ +#define XAE_PHYC_RGMIIHD_MASK 0x00000002 /* RGMII Half-duplex */ +#define XAE_PHYC_RGMIILINK_MASK 0x00000001 /* RGMII link status */ +#define XAE_PHYC_RGLINKSPD_10 0x00000000 /* RGMII link 10 Mbit */ +#define XAE_PHYC_RGLINKSPD_100 0x00000004 /* RGMII link 100 Mbit */ +#define XAE_PHYC_RGLINKSPD_1000 0x00000008 /* RGMII link 1000 Mbit */ +#define XAE_PHYC_SGLINKSPD_10 0x00000000 /* SGMII link 10 Mbit */ +#define XAE_PHYC_SGLINKSPD_100 0x40000000 /* SGMII link 100 Mbit */ +#define XAE_PHYC_SGLINKSPD_1000 0x80000000 /* SGMII link 1000 Mbit */ + +/* Bit masks for Axi Ethernet MDIO interface MC register */ +#define XAE_MDIO_MC_MDIOEN_MASK 0x00000040 /* MII management enable */ +#define XAE_MDIO_MC_CLOCK_DIVIDE_MAX 0x3F /* Maximum MDIO divisor */ + +/* Bit masks for Axi Ethernet MDIO interface MCR register */ +#define XAE_MDIO_MCR_PHYAD_MASK 0x1F000000 /* Phy Address Mask */ +#define XAE_MDIO_MCR_PHYAD_SHIFT 24 /* Phy Address Shift */ +#define XAE_MDIO_MCR_REGAD_MASK 0x001F0000 /* Reg Address Mask */ +#define XAE_MDIO_MCR_REGAD_SHIFT 16 /* Reg Address Shift */ +#define XAE_MDIO_MCR_OP_MASK 0x0000C000 /* Operation Code Mask */ +#define XAE_MDIO_MCR_OP_SHIFT 13 /* Operation Code Shift */ +#define XAE_MDIO_MCR_OP_READ_MASK 0x00008000 /* Op Code Read Mask */ +#define XAE_MDIO_MCR_OP_WRITE_MASK 0x00004000 /* Op Code Write Mask */ +#define XAE_MDIO_MCR_INITIATE_MASK 0x00000800 /* Ready Mask */ +#define XAE_MDIO_MCR_READY_MASK 0x00000080 /* Ready Mask */ + +/* Bit masks for Axi Ethernet MDIO interface MIS, MIP, MIE, MIC registers */ +#define XAE_MDIO_INT_MIIM_RDY_MASK 0x00000001 /* MIIM Interrupt */ + +/* Bit masks for Axi Ethernet UAW1 register */ +#define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF /* Station address bits + * [47:32]; Station address + * bits [31:0] are stored in + * register UAW0 */ + +/* Bit masks for Axi Ethernet FMI register */ +#define XAE_FMI_PM_MASK 0x80000000 /* Promis. mode enable */ +#define XAE_FMI_IND_MASK 0x00000003 /* Index Mask */ + +#define XAE_MDIO_DIV_DFT 29 /* Default MDIO clock divisor */ + +/* Defines for different options for C_PHY_TYPE parameter in Axi Ethernet IP */ +#define XAE_PHY_TYPE_MII 0 +#define XAE_PHY_TYPE_GMII 1 +#define XAE_PHY_TYPE_RGMII_1_3 2 +#define XAE_PHY_TYPE_RGMII_2_0 3 +#define XAE_PHY_TYPE_SGMII 4 +#define XAE_PHY_TYPE_1000BASE_X 5 + +#define XAE_MULTICAST_CAM_TABLE_NUM 4 /* Total number of entries in the + * hardware multicast table. */ + +/* Axi Ethernet Synthesis features */ +#define XAE_FEATURE_PARTIAL_RX_CSUM (1 << 0) +#define XAE_FEATURE_PARTIAL_TX_CSUM (1 << 1) +#define XAE_FEATURE_FULL_RX_CSUM (1 << 2) +#define XAE_FEATURE_FULL_TX_CSUM (1 << 3) + +#define XAE_NO_CSUM_OFFLOAD 0 + +#define XAE_FULL_CSUM_STATUS_MASK 0x00000038 +#define XAE_IP_UDP_CSUM_VALIDATED 0x00000003 +#define XAE_IP_TCP_CSUM_VALIDATED 0x00000002 + +#define DELAY_OF_ONE_MILLISEC 1000 + +/** + * struct axidma_bd - Axi Dma buffer descriptor layout + * @next: MM2S/S2MM Next Descriptor Pointer + * @reserved1: Reserved and not used + * @phys: MM2S/S2MM Buffer Address + * @reserved2: Reserved and not used + * @reserved3: Reserved and not used + * @reserved4: Reserved and not used + * @cntrl: MM2S/S2MM Control value + * @status: MM2S/S2MM Status value + * @app0: MM2S/S2MM User Application Field 0. + * @app1: MM2S/S2MM User Application Field 1. + * @app2: MM2S/S2MM User Application Field 2. + * @app3: MM2S/S2MM User Application Field 3. + * @app4: MM2S/S2MM User Application Field 4. + * @sw_id_offset: MM2S/S2MM Sw ID + * @reserved5: Reserved and not used + * @reserved6: Reserved and not used + */ +struct axidma_bd { + u32 next; /* Physical address of next buffer descriptor */ + u32 reserved1; + u32 phys; + u32 reserved2; + u32 reserved3; + u32 reserved4; + u32 cntrl; + u32 status; + u32 app0; + u32 app1; /* TX start << 16 | insert */ + u32 app2; /* TX csum seed */ + u32 app3; + u32 app4; + u32 sw_id_offset; + u32 reserved5; + u32 reserved6; +}; + +/** + * struct axienet_local - axienet private per device data + * @ndev: Pointer for net_device to which it will be attached. + * @dev: Pointer to device structure + * @phy_dev: Pointer to PHY device structure attached to the axienet_local + * @phy_node: Pointer to device node structure + * @mii_bus: Pointer to MII bus structure + * @mdio_irqs: IRQs table for MDIO bus required in mii_bus structure + * @regs: Base address for the axienet_local device address space + * @dma_regs: Base address for the axidma device address space + * @dma_err_tasklet: Tasklet structure to process Axi DMA errors + * @tx_irq: Axidma TX IRQ number + * @rx_irq: Axidma RX IRQ number + * @temac_type: axienet type to identify between soft and hard temac + * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X + * @options: AxiEthernet option word + * @last_link: Phy link state in which the PHY was negotiated earlier + * @features: Stores the extended features supported by the axienet hw + * @tx_bd_v: Virtual address of the TX buffer descriptor ring + * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring + * @rx_bd_v: Virtual address of the RX buffer descriptor ring + * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring + * @tx_bd_ci: Stores the index of the Tx buffer descriptor in the ring being + * accessed currently. Used while alloc. BDs before a TX starts + * @tx_bd_tail: Stores the index of the Tx buffer descriptor in the ring being + * accessed currently. Used while processing BDs after the TX + * completed. + * @rx_bd_ci: Stores the index of the Rx buffer descriptor in the ring being + * accessed currently. + * @max_frm_size: Stores the maximum size of the frame that can be that + * Txed/Rxed in the existing hardware. If jumbo option is + * supported, the maximum frame size would be 9k. Else it is + * 1522 bytes (assuming support for basic VLAN) + * @jumbo_support: Stores hardware configuration for jumbo support. If hardware + * can handle jumbo packets, this entry will be 1, else 0. + */ +struct axienet_local { + struct net_device *ndev; + struct device *dev; + + /* Connection to PHY device */ + struct phy_device *phy_dev; /* Pointer to PHY device */ + struct device_node *phy_node; + + /* MDIO bus data */ + struct mii_bus *mii_bus; /* MII bus reference */ + int mdio_irqs[PHY_MAX_ADDR]; /* IRQs table for MDIO bus */ + + /* IO registers, dma functions and IRQs */ + void __iomem *regs; + void __iomem *dma_regs; + + struct tasklet_struct dma_err_tasklet; + + int tx_irq; + int rx_irq; + u32 temac_type; + u32 phy_type; + + u32 options; /* Current options word */ + u32 last_link; + u32 features; + + /* Buffer descriptors */ + struct axidma_bd *tx_bd_v; + dma_addr_t tx_bd_p; + struct axidma_bd *rx_bd_v; + dma_addr_t rx_bd_p; + u32 tx_bd_ci; + u32 tx_bd_tail; + u32 rx_bd_ci; + + u32 max_frm_size; + u32 jumbo_support; + + int csum_offload_on_tx_path; + int csum_offload_on_rx_path; + + u32 coalesce_count_rx; + u32 coalesce_count_tx; +}; + +/** + * struct axiethernet_option - Used to set axi ethernet hardware options + * @opt: Option to be set. + * @reg: Register offset to be written for setting the option + * @m_or: Mask to be ORed for setting the option in the register + */ +struct axienet_option { + u32 opt; + u32 reg; + u32 m_or; +}; + +/** + * axienet_ior - Memory mapped Axi Ethernet register read + * @lp: Pointer to axienet local structure + * @offset: Address offset from the base address of Axi Ethernet core + * + * returns: The contents of the Axi Ethernet register + * + * This function returns the contents of the corresponding register. + */ +static inline u32 axienet_ior(struct axienet_local *lp, off_t offset) +{ + return in_be32(lp->regs + offset); +} + +/** + * axienet_iow - Memory mapped Axi Ethernet register write + * @lp: Pointer to axienet local structure + * @offset: Address offset from the base address of Axi Ethernet core + * @value: Value to be written into the Axi Ethernet register + * + * This function writes the desired value into the corresponding Axi Ethernet + * register. + */ +static inline void axienet_iow(struct axienet_local *lp, off_t offset, + u32 value) +{ + out_be32((lp->regs + offset), value); +} + +/* Function prototypes visible in xilinx_axienet_mdio.c for other files */ +int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np); +int axienet_mdio_wait_until_ready(struct axienet_local *lp); +void axienet_mdio_teardown(struct axienet_local *lp); + +#endif /* XILINX_AXI_ENET_H */ diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c new file mode 100644 index 000000000000..ea50caf8925b --- /dev/null +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -0,0 +1,1682 @@ +/* + * Xilinx Axi Ethernet device driver + * + * Copyright (c) 2008 Nissin Systems Co., Ltd., Yoshio Kashiwagi + * Copyright (c) 2005-2008 DLA Systems, David H. Lynch Jr. + * Copyright (c) 2008-2009 Secret Lab Technologies Ltd. + * Copyright (c) 2010 Xilinx, Inc. All rights reserved. + * Copyright (c) 2012 Daniel Borkmann, + * Copyright (c) 2012 Ariane Keller, + * + * This is a driver for the Xilinx Axi Ethernet which is used in the Virtex6 + * and Spartan6. + * + * TODO: + * - Add Axi Fifo support. + * - Factor out Axi DMA code into separate driver. + * - Test and fix basic multicast filtering. + * - Add support for extended multicast filtering. + * - Test basic VLAN support. + * - Add support for extended VLAN support. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xilinx_axienet.h" + +/* Descriptors defines for Tx and Rx DMA - 2^n for the best performance */ +#define TX_BD_NUM 64 +#define RX_BD_NUM 128 + +/* Must be shorter than length of ethtool_drvinfo.driver field to fit */ +#define DRIVER_NAME "xaxienet" +#define DRIVER_DESCRIPTION "Xilinx Axi Ethernet driver" +#define DRIVER_VERSION "1.00a" + +#define AXIENET_REGS_N 32 + +/* Match table for of_platform binding */ +static struct of_device_id axienet_of_match[] __devinitdata = { + { .compatible = "xlnx,axi-ethernet-1.00.a", }, + { .compatible = "xlnx,axi-ethernet-1.01.a", }, + { .compatible = "xlnx,axi-ethernet-2.01.a", }, + {}, +}; + +MODULE_DEVICE_TABLE(of, axienet_of_match); + +/* Option table for setting up Axi Ethernet hardware options */ +static struct axienet_option axienet_options[] = { + /* Turn on jumbo packet support for both Rx and Tx */ + { + .opt = XAE_OPTION_JUMBO, + .reg = XAE_TC_OFFSET, + .m_or = XAE_TC_JUM_MASK, + }, { + .opt = XAE_OPTION_JUMBO, + .reg = XAE_RCW1_OFFSET, + .m_or = XAE_RCW1_JUM_MASK, + }, { /* Turn on VLAN packet support for both Rx and Tx */ + .opt = XAE_OPTION_VLAN, + .reg = XAE_TC_OFFSET, + .m_or = XAE_TC_VLAN_MASK, + }, { + .opt = XAE_OPTION_VLAN, + .reg = XAE_RCW1_OFFSET, + .m_or = XAE_RCW1_VLAN_MASK, + }, { /* Turn on FCS stripping on receive packets */ + .opt = XAE_OPTION_FCS_STRIP, + .reg = XAE_RCW1_OFFSET, + .m_or = XAE_RCW1_FCS_MASK, + }, { /* Turn on FCS insertion on transmit packets */ + .opt = XAE_OPTION_FCS_INSERT, + .reg = XAE_TC_OFFSET, + .m_or = XAE_TC_FCS_MASK, + }, { /* Turn off length/type field checking on receive packets */ + .opt = XAE_OPTION_LENTYPE_ERR, + .reg = XAE_RCW1_OFFSET, + .m_or = XAE_RCW1_LT_DIS_MASK, + }, { /* Turn on Rx flow control */ + .opt = XAE_OPTION_FLOW_CONTROL, + .reg = XAE_FCC_OFFSET, + .m_or = XAE_FCC_FCRX_MASK, + }, { /* Turn on Tx flow control */ + .opt = XAE_OPTION_FLOW_CONTROL, + .reg = XAE_FCC_OFFSET, + .m_or = XAE_FCC_FCTX_MASK, + }, { /* Turn on promiscuous frame filtering */ + .opt = XAE_OPTION_PROMISC, + .reg = XAE_FMI_OFFSET, + .m_or = XAE_FMI_PM_MASK, + }, { /* Enable transmitter */ + .opt = XAE_OPTION_TXEN, + .reg = XAE_TC_OFFSET, + .m_or = XAE_TC_TX_MASK, + }, { /* Enable receiver */ + .opt = XAE_OPTION_RXEN, + .reg = XAE_RCW1_OFFSET, + .m_or = XAE_RCW1_RX_MASK, + }, + {} +}; + +/** + * axienet_dma_in32 - Memory mapped Axi DMA register read + * @lp: Pointer to axienet local structure + * @reg: Address offset from the base address of the Axi DMA core + * + * returns: The contents of the Axi DMA register + * + * This function returns the contents of the corresponding Axi DMA register. + */ +static inline u32 axienet_dma_in32(struct axienet_local *lp, off_t reg) +{ + return in_be32(lp->dma_regs + reg); +} + +/** + * axienet_dma_out32 - Memory mapped Axi DMA register write. + * @lp: Pointer to axienet local structure + * @reg: Address offset from the base address of the Axi DMA core + * @value: Value to be written into the Axi DMA register + * + * This function writes the desired value into the corresponding Axi DMA + * register. + */ +static inline void axienet_dma_out32(struct axienet_local *lp, + off_t reg, u32 value) +{ + out_be32((lp->dma_regs + reg), value); +} + +/** + * axienet_dma_bd_release - Release buffer descriptor rings + * @ndev: Pointer to the net_device structure + * + * This function is used to release the descriptors allocated in + * axienet_dma_bd_init. axienet_dma_bd_release is called when Axi Ethernet + * driver stop api is called. + */ +static void axienet_dma_bd_release(struct net_device *ndev) +{ + int i; + struct axienet_local *lp = netdev_priv(ndev); + + for (i = 0; i < RX_BD_NUM; i++) { + dma_unmap_single(ndev->dev.parent, lp->rx_bd_v[i].phys, + lp->max_frm_size, DMA_FROM_DEVICE); + dev_kfree_skb((struct sk_buff *) + (lp->rx_bd_v[i].sw_id_offset)); + } + + if (lp->rx_bd_v) { + dma_free_coherent(ndev->dev.parent, + sizeof(*lp->rx_bd_v) * RX_BD_NUM, + lp->rx_bd_v, + lp->rx_bd_p); + } + if (lp->tx_bd_v) { + dma_free_coherent(ndev->dev.parent, + sizeof(*lp->tx_bd_v) * TX_BD_NUM, + lp->tx_bd_v, + lp->tx_bd_p); + } +} + +/** + * axienet_dma_bd_init - Setup buffer descriptor rings for Axi DMA + * @ndev: Pointer to the net_device structure + * + * returns: 0, on success + * -ENOMEM, on failure + * + * This function is called to initialize the Rx and Tx DMA descriptor + * rings. This initializes the descriptors with required default values + * and is called when Axi Ethernet driver reset is called. + */ +static int axienet_dma_bd_init(struct net_device *ndev) +{ + u32 cr; + int i; + struct sk_buff *skb; + struct axienet_local *lp = netdev_priv(ndev); + + /* Reset the indexes which are used for accessing the BDs */ + lp->tx_bd_ci = 0; + lp->tx_bd_tail = 0; + lp->rx_bd_ci = 0; + + /* + * Allocate the Tx and Rx buffer descriptors. + */ + lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent, + sizeof(*lp->tx_bd_v) * TX_BD_NUM, + &lp->tx_bd_p, + GFP_KERNEL); + if (!lp->tx_bd_v) { + dev_err(&ndev->dev, "unable to allocate DMA Tx buffer " + "descriptors"); + goto out; + } + + lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent, + sizeof(*lp->rx_bd_v) * RX_BD_NUM, + &lp->rx_bd_p, + GFP_KERNEL); + if (!lp->rx_bd_v) { + dev_err(&ndev->dev, "unable to allocate DMA Rx buffer " + "descriptors"); + goto out; + } + + memset(lp->tx_bd_v, 0, sizeof(*lp->tx_bd_v) * TX_BD_NUM); + for (i = 0; i < TX_BD_NUM; i++) { + lp->tx_bd_v[i].next = lp->tx_bd_p + + sizeof(*lp->tx_bd_v) * + ((i + 1) % TX_BD_NUM); + } + + memset(lp->rx_bd_v, 0, sizeof(*lp->rx_bd_v) * RX_BD_NUM); + for (i = 0; i < RX_BD_NUM; i++) { + lp->rx_bd_v[i].next = lp->rx_bd_p + + sizeof(*lp->rx_bd_v) * + ((i + 1) % RX_BD_NUM); + + skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size); + if (!skb) { + dev_err(&ndev->dev, "alloc_skb error %d\n", i); + goto out; + } + + lp->rx_bd_v[i].sw_id_offset = (u32) skb; + lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent, + skb->data, + lp->max_frm_size, + DMA_FROM_DEVICE); + lp->rx_bd_v[i].cntrl = lp->max_frm_size; + } + + /* Start updating the Rx channel control register */ + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + /* Update the interrupt coalesce count */ + cr = ((cr & ~XAXIDMA_COALESCE_MASK) | + ((lp->coalesce_count_rx) << XAXIDMA_COALESCE_SHIFT)); + /* Update the delay timer count */ + cr = ((cr & ~XAXIDMA_DELAY_MASK) | + (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); + /* Enable coalesce, delay timer and error interrupts */ + cr |= XAXIDMA_IRQ_ALL_MASK; + /* Write to the Rx channel control register */ + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + + /* Start updating the Tx channel control register */ + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + /* Update the interrupt coalesce count */ + cr = (((cr & ~XAXIDMA_COALESCE_MASK)) | + ((lp->coalesce_count_tx) << XAXIDMA_COALESCE_SHIFT)); + /* Update the delay timer count */ + cr = (((cr & ~XAXIDMA_DELAY_MASK)) | + (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); + /* Enable coalesce, delay timer and error interrupts */ + cr |= XAXIDMA_IRQ_ALL_MASK; + /* Write to the Tx channel control register */ + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + + /* Populate the tail pointer and bring the Rx Axi DMA engine out of + * halted state. This will make the Rx side ready for reception.*/ + axienet_dma_out32(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, + cr | XAXIDMA_CR_RUNSTOP_MASK); + axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1))); + + /* Write to the RS (Run-stop) bit in the Tx channel control register. + * Tx channel is now ready to run. But only after we write to the + * tail pointer register that the Tx channel will start transmitting */ + axienet_dma_out32(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, + cr | XAXIDMA_CR_RUNSTOP_MASK); + + return 0; +out: + axienet_dma_bd_release(ndev); + return -ENOMEM; +} + +/** + * axienet_set_mac_address - Write the MAC address + * @ndev: Pointer to the net_device structure + * @address: 6 byte Address to be written as MAC address + * + * This function is called to initialize the MAC address of the Axi Ethernet + * core. It writes to the UAW0 and UAW1 registers of the core. + */ +static void axienet_set_mac_address(struct net_device *ndev, void *address) +{ + struct axienet_local *lp = netdev_priv(ndev); + + if (address) + memcpy(ndev->dev_addr, address, ETH_ALEN); + if (!is_valid_ether_addr(ndev->dev_addr)) + random_ether_addr(ndev->dev_addr); + + /* Set up unicast MAC address filter set its mac address */ + axienet_iow(lp, XAE_UAW0_OFFSET, + (ndev->dev_addr[0]) | + (ndev->dev_addr[1] << 8) | + (ndev->dev_addr[2] << 16) | + (ndev->dev_addr[3] << 24)); + axienet_iow(lp, XAE_UAW1_OFFSET, + (((axienet_ior(lp, XAE_UAW1_OFFSET)) & + ~XAE_UAW1_UNICASTADDR_MASK) | + (ndev->dev_addr[4] | + (ndev->dev_addr[5] << 8)))); +} + +/** + * netdev_set_mac_address - Write the MAC address (from outside the driver) + * @ndev: Pointer to the net_device structure + * @p: 6 byte Address to be written as MAC address + * + * returns: 0 for all conditions. Presently, there is no failure case. + * + * This function is called to initialize the MAC address of the Axi Ethernet + * core. It calls the core specific axienet_set_mac_address. This is the + * function that goes into net_device_ops structure entry ndo_set_mac_address. + */ +static int netdev_set_mac_address(struct net_device *ndev, void *p) +{ + struct sockaddr *addr = p; + axienet_set_mac_address(ndev, addr->sa_data); + return 0; +} + +/** + * axienet_set_multicast_list - Prepare the multicast table + * @ndev: Pointer to the net_device structure + * + * This function is called to initialize the multicast table during + * initialization. The Axi Ethernet basic multicast support has a four-entry + * multicast table which is initialized here. Additionally this function + * goes into the net_device_ops structure entry ndo_set_multicast_list. This + * means whenever the multicast table entries need to be updated this + * function gets called. + */ +static void axienet_set_multicast_list(struct net_device *ndev) +{ + int i; + u32 reg, af0reg, af1reg; + struct axienet_local *lp = netdev_priv(ndev); + + if (ndev->flags & (IFF_ALLMULTI | IFF_PROMISC) || + netdev_mc_count(ndev) > XAE_MULTICAST_CAM_TABLE_NUM) { + /* We must make the kernel realize we had to move into + * promiscuous mode. If it was a promiscuous mode request + * the flag is already set. If not we set it. */ + ndev->flags |= IFF_PROMISC; + reg = axienet_ior(lp, XAE_FMI_OFFSET); + reg |= XAE_FMI_PM_MASK; + axienet_iow(lp, XAE_FMI_OFFSET, reg); + dev_info(&ndev->dev, "Promiscuous mode enabled.\n"); + } else if (!netdev_mc_empty(ndev)) { + struct netdev_hw_addr *ha; + + i = 0; + netdev_for_each_mc_addr(ha, ndev) { + if (i >= XAE_MULTICAST_CAM_TABLE_NUM) + break; + + af0reg = (ha->addr[0]); + af0reg |= (ha->addr[1] << 8); + af0reg |= (ha->addr[2] << 16); + af0reg |= (ha->addr[3] << 24); + + af1reg = (ha->addr[4]); + af1reg |= (ha->addr[5] << 8); + + reg = axienet_ior(lp, XAE_FMI_OFFSET) & 0xFFFFFF00; + reg |= i; + + axienet_iow(lp, XAE_FMI_OFFSET, reg); + axienet_iow(lp, XAE_AF0_OFFSET, af0reg); + axienet_iow(lp, XAE_AF1_OFFSET, af1reg); + i++; + } + } else { + reg = axienet_ior(lp, XAE_FMI_OFFSET); + reg &= ~XAE_FMI_PM_MASK; + + axienet_iow(lp, XAE_FMI_OFFSET, reg); + + for (i = 0; i < XAE_MULTICAST_CAM_TABLE_NUM; i++) { + reg = axienet_ior(lp, XAE_FMI_OFFSET) & 0xFFFFFF00; + reg |= i; + + axienet_iow(lp, XAE_FMI_OFFSET, reg); + axienet_iow(lp, XAE_AF0_OFFSET, 0); + axienet_iow(lp, XAE_AF1_OFFSET, 0); + } + + dev_info(&ndev->dev, "Promiscuous mode disabled.\n"); + } +} + +/** + * axienet_setoptions - Set an Axi Ethernet option + * @ndev: Pointer to the net_device structure + * @options: Option to be enabled/disabled + * + * The Axi Ethernet core has multiple features which can be selectively turned + * on or off. The typical options could be jumbo frame option, basic VLAN + * option, promiscuous mode option etc. This function is used to set or clear + * these options in the Axi Ethernet hardware. This is done through + * axienet_option structure . + */ +static void axienet_setoptions(struct net_device *ndev, u32 options) +{ + int reg; + struct axienet_local *lp = netdev_priv(ndev); + struct axienet_option *tp = &axienet_options[0]; + + while (tp->opt) { + reg = ((axienet_ior(lp, tp->reg)) & ~(tp->m_or)); + if (options & tp->opt) + reg |= tp->m_or; + axienet_iow(lp, tp->reg, reg); + tp++; + } + + lp->options |= options; +} + +static void __axienet_device_reset(struct axienet_local *lp, + struct device *dev, off_t offset) +{ + u32 timeout; + /* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset + * process of Axi DMA takes a while to complete as all pending + * commands/transfers will be flushed or completed during this + * reset process. */ + axienet_dma_out32(lp, offset, XAXIDMA_CR_RESET_MASK); + timeout = DELAY_OF_ONE_MILLISEC; + while (axienet_dma_in32(lp, offset) & XAXIDMA_CR_RESET_MASK) { + udelay(1); + if (--timeout == 0) { + dev_err(dev, "axienet_device_reset DMA " + "reset timeout!\n"); + break; + } + } +} + +/** + * axienet_device_reset - Reset and initialize the Axi Ethernet hardware. + * @ndev: Pointer to the net_device structure + * + * This function is called to reset and initialize the Axi Ethernet core. This + * is typically called during initialization. It does a reset of the Axi DMA + * Rx/Tx channels and initializes the Axi DMA BDs. Since Axi DMA reset lines + * areconnected to Axi Ethernet reset lines, this in turn resets the Axi + * Ethernet core. No separate hardware reset is done for the Axi Ethernet + * core. + */ +static void axienet_device_reset(struct net_device *ndev) +{ + u32 axienet_status; + struct axienet_local *lp = netdev_priv(ndev); + + __axienet_device_reset(lp, &ndev->dev, XAXIDMA_TX_CR_OFFSET); + __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET); + + lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE; + lp->options &= (~XAE_OPTION_JUMBO); + + if ((ndev->mtu > XAE_MTU) && + (ndev->mtu <= XAE_JUMBO_MTU) && + (lp->jumbo_support)) { + lp->max_frm_size = ndev->mtu + XAE_HDR_VLAN_SIZE + + XAE_TRL_SIZE; + lp->options |= XAE_OPTION_JUMBO; + } + + if (axienet_dma_bd_init(ndev)) { + dev_err(&ndev->dev, "axienet_device_reset descriptor " + "allocation failed\n"); + } + + axienet_status = axienet_ior(lp, XAE_RCW1_OFFSET); + axienet_status &= ~XAE_RCW1_RX_MASK; + axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status); + + axienet_status = axienet_ior(lp, XAE_IP_OFFSET); + if (axienet_status & XAE_INT_RXRJECT_MASK) + axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK); + + axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK); + + /* Sync default options with HW but leave receiver and + * transmitter disabled.*/ + axienet_setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + axienet_set_mac_address(ndev, NULL); + axienet_set_multicast_list(ndev); + axienet_setoptions(ndev, lp->options); + + ndev->trans_start = jiffies; +} + +/** + * axienet_adjust_link - Adjust the PHY link speed/duplex. + * @ndev: Pointer to the net_device structure + * + * This function is called to change the speed and duplex setting after + * auto negotiation is done by the PHY. This is the function that gets + * registered with the PHY interface through the "of_phy_connect" call. + */ +static void axienet_adjust_link(struct net_device *ndev) +{ + u32 emmc_reg; + u32 link_state; + u32 setspeed = 1; + struct axienet_local *lp = netdev_priv(ndev); + struct phy_device *phy = lp->phy_dev; + + link_state = phy->speed | (phy->duplex << 1) | phy->link; + if (lp->last_link != link_state) { + if ((phy->speed == SPEED_10) || (phy->speed == SPEED_100)) { + if (lp->phy_type == XAE_PHY_TYPE_1000BASE_X) + setspeed = 0; + } else { + if ((phy->speed == SPEED_1000) && + (lp->phy_type == XAE_PHY_TYPE_MII)) + setspeed = 0; + } + + if (setspeed == 1) { + emmc_reg = axienet_ior(lp, XAE_EMMC_OFFSET); + emmc_reg &= ~XAE_EMMC_LINKSPEED_MASK; + + switch (phy->speed) { + case SPEED_1000: + emmc_reg |= XAE_EMMC_LINKSPD_1000; + break; + case SPEED_100: + emmc_reg |= XAE_EMMC_LINKSPD_100; + break; + case SPEED_10: + emmc_reg |= XAE_EMMC_LINKSPD_10; + break; + default: + dev_err(&ndev->dev, "Speed other than 10, 100 " + "or 1Gbps is not supported\n"); + break; + } + + axienet_iow(lp, XAE_EMMC_OFFSET, emmc_reg); + lp->last_link = link_state; + phy_print_status(phy); + } else { + dev_err(&ndev->dev, "Error setting Axi Ethernet " + "mac speed\n"); + } + } +} + +/** + * axienet_start_xmit_done - Invoked once a transmit is completed by the + * Axi DMA Tx channel. + * @ndev: Pointer to the net_device structure + * + * This function is invoked from the Axi DMA Tx isr to notify the completion + * of transmit operation. It clears fields in the corresponding Tx BDs and + * unmaps the corresponding buffer so that CPU can regain ownership of the + * buffer. It finally invokes "netif_wake_queue" to restart transmission if + * required. + */ +static void axienet_start_xmit_done(struct net_device *ndev) +{ + u32 size = 0; + u32 packets = 0; + struct axienet_local *lp = netdev_priv(ndev); + struct axidma_bd *cur_p; + unsigned int status = 0; + + cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; + status = cur_p->status; + while (status & XAXIDMA_BD_STS_COMPLETE_MASK) { + dma_unmap_single(ndev->dev.parent, cur_p->phys, + (cur_p->cntrl & XAXIDMA_BD_CTRL_LENGTH_MASK), + DMA_TO_DEVICE); + if (cur_p->app4) + dev_kfree_skb_irq((struct sk_buff *)cur_p->app4); + /*cur_p->phys = 0;*/ + cur_p->app0 = 0; + cur_p->app1 = 0; + cur_p->app2 = 0; + cur_p->app4 = 0; + cur_p->status = 0; + + size += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK; + packets++; + + lp->tx_bd_ci = ++lp->tx_bd_ci % TX_BD_NUM; + cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; + status = cur_p->status; + } + + ndev->stats.tx_packets += packets; + ndev->stats.tx_bytes += size; + netif_wake_queue(ndev); +} + +/** + * axienet_check_tx_bd_space - Checks if a BD/group of BDs are currently busy + * @lp: Pointer to the axienet_local structure + * @num_frag: The number of BDs to check for + * + * returns: 0, on success + * NETDEV_TX_BUSY, if any of the descriptors are not free + * + * This function is invoked before BDs are allocated and transmission starts. + * This function returns 0 if a BD or group of BDs can be allocated for + * transmission. If the BD or any of the BDs are not free the function + * returns a busy status. This is invoked from axienet_start_xmit. + */ +static inline int axienet_check_tx_bd_space(struct axienet_local *lp, + int num_frag) +{ + struct axidma_bd *cur_p; + cur_p = &lp->tx_bd_v[(lp->tx_bd_tail + num_frag) % TX_BD_NUM]; + if (cur_p->status & XAXIDMA_BD_STS_ALL_MASK) + return NETDEV_TX_BUSY; + return 0; +} + +/** + * axienet_start_xmit - Starts the transmission. + * @skb: sk_buff pointer that contains data to be Txed. + * @ndev: Pointer to net_device structure. + * + * returns: NETDEV_TX_OK, on success + * NETDEV_TX_BUSY, if any of the descriptors are not free + * + * This function is invoked from upper layers to initiate transmission. The + * function uses the next available free BDs and populates their fields to + * start the transmission. Additionally if checksum offloading is supported, + * it populates AXI Stream Control fields with appropriate values. + */ +static int axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + u32 ii; + u32 num_frag; + u32 csum_start_off; + u32 csum_index_off; + skb_frag_t *frag; + dma_addr_t tail_p; + struct axienet_local *lp = netdev_priv(ndev); + struct axidma_bd *cur_p; + + num_frag = skb_shinfo(skb)->nr_frags; + cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; + + if (axienet_check_tx_bd_space(lp, num_frag)) { + if (!netif_queue_stopped(ndev)) + netif_stop_queue(ndev); + return NETDEV_TX_BUSY; + } + + if (skb->ip_summed == CHECKSUM_PARTIAL) { + if (lp->features & XAE_FEATURE_FULL_TX_CSUM) { + /* Tx Full Checksum Offload Enabled */ + cur_p->app0 |= 2; + } else if (lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) { + csum_start_off = skb_transport_offset(skb); + csum_index_off = csum_start_off + skb->csum_offset; + /* Tx Partial Checksum Offload Enabled */ + cur_p->app0 |= 1; + cur_p->app1 = (csum_start_off << 16) | csum_index_off; + } + } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { + cur_p->app0 |= 2; /* Tx Full Checksum Offload Enabled */ + } + + cur_p->cntrl = skb_headlen(skb) | XAXIDMA_BD_CTRL_TXSOF_MASK; + cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, + skb_headlen(skb), DMA_TO_DEVICE); + + for (ii = 0; ii < num_frag; ii++) { + lp->tx_bd_tail = ++lp->tx_bd_tail % TX_BD_NUM; + cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; + frag = &skb_shinfo(skb)->frags[ii]; + cur_p->phys = dma_map_single(ndev->dev.parent, + skb_frag_address(frag), + skb_frag_size(frag), + DMA_TO_DEVICE); + cur_p->cntrl = skb_frag_size(frag); + } + + cur_p->cntrl |= XAXIDMA_BD_CTRL_TXEOF_MASK; + cur_p->app4 = (unsigned long)skb; + + tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; + /* Start the transfer */ + axienet_dma_out32(lp, XAXIDMA_TX_TDESC_OFFSET, tail_p); + lp->tx_bd_tail = ++lp->tx_bd_tail % TX_BD_NUM; + + return NETDEV_TX_OK; +} + +/** + * axienet_recv - Is called from Axi DMA Rx Isr to complete the received + * BD processing. + * @ndev: Pointer to net_device structure. + * + * This function is invoked from the Axi DMA Rx isr to process the Rx BDs. It + * does minimal processing and invokes "netif_rx" to complete further + * processing. + */ +static void axienet_recv(struct net_device *ndev) +{ + u32 length; + u32 csumstatus; + u32 size = 0; + u32 packets = 0; + dma_addr_t tail_p; + struct axienet_local *lp = netdev_priv(ndev); + struct sk_buff *skb, *new_skb; + struct axidma_bd *cur_p; + + tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci; + cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; + + while ((cur_p->status & XAXIDMA_BD_STS_COMPLETE_MASK)) { + skb = (struct sk_buff *) (cur_p->sw_id_offset); + length = cur_p->app4 & 0x0000FFFF; + + dma_unmap_single(ndev->dev.parent, cur_p->phys, + lp->max_frm_size, + DMA_FROM_DEVICE); + + skb_put(skb, length); + skb->protocol = eth_type_trans(skb, ndev); + /*skb_checksum_none_assert(skb);*/ + skb->ip_summed = CHECKSUM_NONE; + + /* if we're doing Rx csum offload, set it up */ + if (lp->features & XAE_FEATURE_FULL_RX_CSUM) { + csumstatus = (cur_p->app2 & + XAE_FULL_CSUM_STATUS_MASK) >> 3; + if ((csumstatus == XAE_IP_TCP_CSUM_VALIDATED) || + (csumstatus == XAE_IP_UDP_CSUM_VALIDATED)) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + } + } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0 && + skb->protocol == __constant_htons(ETH_P_IP) && + skb->len > 64) { + skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF); + skb->ip_summed = CHECKSUM_COMPLETE; + } + + netif_rx(skb); + + size += length; + packets++; + + new_skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size); + if (!new_skb) { + dev_err(&ndev->dev, "no memory for new sk_buff\n"); + return; + } + cur_p->phys = dma_map_single(ndev->dev.parent, new_skb->data, + lp->max_frm_size, + DMA_FROM_DEVICE); + cur_p->cntrl = lp->max_frm_size; + cur_p->status = 0; + cur_p->sw_id_offset = (u32) new_skb; + + lp->rx_bd_ci = ++lp->rx_bd_ci % RX_BD_NUM; + cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; + } + + ndev->stats.rx_packets += packets; + ndev->stats.rx_bytes += size; + + axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, tail_p); +} + +/** + * axienet_tx_irq - Tx Done Isr. + * @irq: irq number + * @_ndev: net_device pointer + * + * returns: IRQ_HANDLED for all cases. + * + * This is the Axi DMA Tx done Isr. It invokes "axienet_start_xmit_done" + * to complete the BD processing. + */ +static irqreturn_t axienet_tx_irq(int irq, void *_ndev) +{ + u32 cr; + unsigned int status; + struct net_device *ndev = _ndev; + struct axienet_local *lp = netdev_priv(ndev); + + status = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET); + if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) { + axienet_start_xmit_done(lp->ndev); + goto out; + } + if (!(status & XAXIDMA_IRQ_ALL_MASK)) + dev_err(&ndev->dev, "No interrupts asserted in Tx path"); + if (status & XAXIDMA_IRQ_ERROR_MASK) { + dev_err(&ndev->dev, "DMA Tx error 0x%x\n", status); + dev_err(&ndev->dev, "Current BD is at: 0x%x\n", + (lp->tx_bd_v[lp->tx_bd_ci]).phys); + + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + /* Disable coalesce, delay timer and error interrupts */ + cr &= (~XAXIDMA_IRQ_ALL_MASK); + /* Write to the Tx channel control register */ + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + /* Disable coalesce, delay timer and error interrupts */ + cr &= (~XAXIDMA_IRQ_ALL_MASK); + /* Write to the Rx channel control register */ + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + + tasklet_schedule(&lp->dma_err_tasklet); + } +out: + axienet_dma_out32(lp, XAXIDMA_TX_SR_OFFSET, status); + return IRQ_HANDLED; +} + +/** + * axienet_rx_irq - Rx Isr. + * @irq: irq number + * @_ndev: net_device pointer + * + * returns: IRQ_HANDLED for all cases. + * + * This is the Axi DMA Rx Isr. It invokes "axienet_recv" to complete the BD + * processing. + */ +static irqreturn_t axienet_rx_irq(int irq, void *_ndev) +{ + u32 cr; + unsigned int status; + struct net_device *ndev = _ndev; + struct axienet_local *lp = netdev_priv(ndev); + + status = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET); + if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) { + axienet_recv(lp->ndev); + goto out; + } + if (!(status & XAXIDMA_IRQ_ALL_MASK)) + dev_err(&ndev->dev, "No interrupts asserted in Rx path"); + if (status & XAXIDMA_IRQ_ERROR_MASK) { + dev_err(&ndev->dev, "DMA Rx error 0x%x\n", status); + dev_err(&ndev->dev, "Current BD is at: 0x%x\n", + (lp->rx_bd_v[lp->rx_bd_ci]).phys); + + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + /* Disable coalesce, delay timer and error interrupts */ + cr &= (~XAXIDMA_IRQ_ALL_MASK); + /* Finally write to the Tx channel control register */ + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + /* Disable coalesce, delay timer and error interrupts */ + cr &= (~XAXIDMA_IRQ_ALL_MASK); + /* write to the Rx channel control register */ + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + + tasklet_schedule(&lp->dma_err_tasklet); + } +out: + axienet_dma_out32(lp, XAXIDMA_RX_SR_OFFSET, status); + return IRQ_HANDLED; +} + +/** + * axienet_open - Driver open routine. + * @ndev: Pointer to net_device structure + * + * returns: 0, on success. + * -ENODEV, if PHY cannot be connected to + * non-zero error value on failure + * + * This is the driver open routine. It calls phy_start to start the PHY device. + * It also allocates interrupt service routines, enables the interrupt lines + * and ISR handling. Axi Ethernet core is reset through Axi DMA core. Buffer + * descriptors are initialized. + */ +static int axienet_open(struct net_device *ndev) +{ + int ret, mdio_mcreg; + struct axienet_local *lp = netdev_priv(ndev); + + dev_dbg(&ndev->dev, "axienet_open()\n"); + + mdio_mcreg = axienet_ior(lp, XAE_MDIO_MC_OFFSET); + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + /* Disable the MDIO interface till Axi Ethernet Reset is completed. + * When we do an Axi Ethernet reset, it resets the complete core + * including the MDIO. If MDIO is not disabled when the reset + * process is started, MDIO will be broken afterwards. */ + axienet_iow(lp, XAE_MDIO_MC_OFFSET, + (mdio_mcreg & (~XAE_MDIO_MC_MDIOEN_MASK))); + axienet_device_reset(ndev); + /* Enable the MDIO */ + axienet_iow(lp, XAE_MDIO_MC_OFFSET, mdio_mcreg); + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + + if (lp->phy_node) { + lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, + axienet_adjust_link, 0, + PHY_INTERFACE_MODE_GMII); + if (!lp->phy_dev) { + dev_err(lp->dev, "of_phy_connect() failed\n"); + return -ENODEV; + } + phy_start(lp->phy_dev); + } + + /* Enable interrupts for Axi DMA Tx */ + ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev); + if (ret) + goto err_tx_irq; + /* Enable interrupts for Axi DMA Rx */ + ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev); + if (ret) + goto err_rx_irq; + /* Enable tasklets for Axi DMA error handling */ + tasklet_enable(&lp->dma_err_tasklet); + return 0; + +err_rx_irq: + free_irq(lp->tx_irq, ndev); +err_tx_irq: + if (lp->phy_dev) + phy_disconnect(lp->phy_dev); + lp->phy_dev = NULL; + dev_err(lp->dev, "request_irq() failed\n"); + return ret; +} + +/** + * axienet_stop - Driver stop routine. + * @ndev: Pointer to net_device structure + * + * returns: 0, on success. + * + * This is the driver stop routine. It calls phy_disconnect to stop the PHY + * device. It also removes the interrupt handlers and disables the interrupts. + * The Axi DMA Tx/Rx BDs are released. + */ +static int axienet_stop(struct net_device *ndev) +{ + u32 cr; + struct axienet_local *lp = netdev_priv(ndev); + + dev_dbg(&ndev->dev, "axienet_close()\n"); + + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, + cr & (~XAXIDMA_CR_RUNSTOP_MASK)); + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, + cr & (~XAXIDMA_CR_RUNSTOP_MASK)); + axienet_setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + + tasklet_disable(&lp->dma_err_tasklet); + + free_irq(lp->tx_irq, ndev); + free_irq(lp->rx_irq, ndev); + + if (lp->phy_dev) + phy_disconnect(lp->phy_dev); + lp->phy_dev = NULL; + + axienet_dma_bd_release(ndev); + return 0; +} + +/** + * axienet_change_mtu - Driver change mtu routine. + * @ndev: Pointer to net_device structure + * @new_mtu: New mtu value to be applied + * + * returns: Always returns 0 (success). + * + * This is the change mtu driver routine. It checks if the Axi Ethernet + * hardware supports jumbo frames before changing the mtu. This can be + * called only when the device is not up. + */ +static int axienet_change_mtu(struct net_device *ndev, int new_mtu) +{ + struct axienet_local *lp = netdev_priv(ndev); + + if (netif_running(ndev)) + return -EBUSY; + if (lp->jumbo_support) { + if ((new_mtu > XAE_JUMBO_MTU) || (new_mtu < 64)) + return -EINVAL; + ndev->mtu = new_mtu; + } else { + if ((new_mtu > XAE_MTU) || (new_mtu < 64)) + return -EINVAL; + ndev->mtu = new_mtu; + } + + return 0; +} + +#ifdef CONFIG_NET_POLL_CONTROLLER +/** + * axienet_poll_controller - Axi Ethernet poll mechanism. + * @ndev: Pointer to net_device structure + * + * This implements Rx/Tx ISR poll mechanisms. The interrupts are disabled prior + * to polling the ISRs and are enabled back after the polling is done. + */ +static void axienet_poll_controller(struct net_device *ndev) +{ + struct axienet_local *lp = netdev_priv(ndev); + disable_irq(lp->tx_irq); + disable_irq(lp->rx_irq); + axienet_rx_irq(lp->tx_irq, ndev); + axienet_tx_irq(lp->rx_irq, ndev); + enable_irq(lp->tx_irq); + enable_irq(lp->rx_irq); +} +#endif + +static const struct net_device_ops axienet_netdev_ops = { + .ndo_open = axienet_open, + .ndo_stop = axienet_stop, + .ndo_start_xmit = axienet_start_xmit, + .ndo_change_mtu = axienet_change_mtu, + .ndo_set_mac_address = netdev_set_mac_address, + .ndo_validate_addr = eth_validate_addr, + .ndo_set_rx_mode = axienet_set_multicast_list, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = axienet_poll_controller, +#endif +}; + +/** + * axienet_ethtools_get_settings - Get Axi Ethernet settings related to PHY. + * @ndev: Pointer to net_device structure + * @ecmd: Pointer to ethtool_cmd structure + * + * This implements ethtool command for getting PHY settings. If PHY could + * not be found, the function returns -ENODEV. This function calls the + * relevant PHY ethtool API to get the PHY settings. + * Issue "ethtool ethX" under linux prompt to execute this function. + */ +static int axienet_ethtools_get_settings(struct net_device *ndev, + struct ethtool_cmd *ecmd) +{ + struct axienet_local *lp = netdev_priv(ndev); + struct phy_device *phydev = lp->phy_dev; + if (!phydev) + return -ENODEV; + return phy_ethtool_gset(phydev, ecmd); +} + +/** + * axienet_ethtools_set_settings - Set PHY settings as passed in the argument. + * @ndev: Pointer to net_device structure + * @ecmd: Pointer to ethtool_cmd structure + * + * This implements ethtool command for setting various PHY settings. If PHY + * could not be found, the function returns -ENODEV. This function calls the + * relevant PHY ethtool API to set the PHY. + * Issue e.g. "ethtool -s ethX speed 1000" under linux prompt to execute this + * function. + */ +static int axienet_ethtools_set_settings(struct net_device *ndev, + struct ethtool_cmd *ecmd) +{ + struct axienet_local *lp = netdev_priv(ndev); + struct phy_device *phydev = lp->phy_dev; + if (!phydev) + return -ENODEV; + return phy_ethtool_sset(phydev, ecmd); +} + +/** + * axienet_ethtools_get_drvinfo - Get various Axi Ethernet driver information. + * @ndev: Pointer to net_device structure + * @ed: Pointer to ethtool_drvinfo structure + * + * This implements ethtool command for getting the driver information. + * Issue "ethtool -i ethX" under linux prompt to execute this function. + */ +static void axienet_ethtools_get_drvinfo(struct net_device *ndev, + struct ethtool_drvinfo *ed) +{ + memset(ed, 0, sizeof(struct ethtool_drvinfo)); + strcpy(ed->driver, DRIVER_NAME); + strcpy(ed->version, DRIVER_VERSION); + ed->regdump_len = sizeof(u32) * AXIENET_REGS_N; +} + +/** + * axienet_ethtools_get_regs_len - Get the total regs length present in the + * AxiEthernet core. + * @ndev: Pointer to net_device structure + * + * This implements ethtool command for getting the total register length + * information. + */ +static int axienet_ethtools_get_regs_len(struct net_device *ndev) +{ + return sizeof(u32) * AXIENET_REGS_N; +} + +/** + * axienet_ethtools_get_regs - Dump the contents of all registers present + * in AxiEthernet core. + * @ndev: Pointer to net_device structure + * @regs: Pointer to ethtool_regs structure + * @ret: Void pointer used to return the contents of the registers. + * + * This implements ethtool command for getting the Axi Ethernet register dump. + * Issue "ethtool -d ethX" to execute this function. + */ +static void axienet_ethtools_get_regs(struct net_device *ndev, + struct ethtool_regs *regs, void *ret) +{ + u32 *data = (u32 *) ret; + size_t len = sizeof(u32) * AXIENET_REGS_N; + struct axienet_local *lp = netdev_priv(ndev); + + regs->version = 0; + regs->len = len; + + memset(data, 0, len); + data[0] = axienet_ior(lp, XAE_RAF_OFFSET); + data[1] = axienet_ior(lp, XAE_TPF_OFFSET); + data[2] = axienet_ior(lp, XAE_IFGP_OFFSET); + data[3] = axienet_ior(lp, XAE_IS_OFFSET); + data[4] = axienet_ior(lp, XAE_IP_OFFSET); + data[5] = axienet_ior(lp, XAE_IE_OFFSET); + data[6] = axienet_ior(lp, XAE_TTAG_OFFSET); + data[7] = axienet_ior(lp, XAE_RTAG_OFFSET); + data[8] = axienet_ior(lp, XAE_UAWL_OFFSET); + data[9] = axienet_ior(lp, XAE_UAWU_OFFSET); + data[10] = axienet_ior(lp, XAE_TPID0_OFFSET); + data[11] = axienet_ior(lp, XAE_TPID1_OFFSET); + data[12] = axienet_ior(lp, XAE_PPST_OFFSET); + data[13] = axienet_ior(lp, XAE_RCW0_OFFSET); + data[14] = axienet_ior(lp, XAE_RCW1_OFFSET); + data[15] = axienet_ior(lp, XAE_TC_OFFSET); + data[16] = axienet_ior(lp, XAE_FCC_OFFSET); + data[17] = axienet_ior(lp, XAE_EMMC_OFFSET); + data[18] = axienet_ior(lp, XAE_PHYC_OFFSET); + data[19] = axienet_ior(lp, XAE_MDIO_MC_OFFSET); + data[20] = axienet_ior(lp, XAE_MDIO_MCR_OFFSET); + data[21] = axienet_ior(lp, XAE_MDIO_MWD_OFFSET); + data[22] = axienet_ior(lp, XAE_MDIO_MRD_OFFSET); + data[23] = axienet_ior(lp, XAE_MDIO_MIS_OFFSET); + data[24] = axienet_ior(lp, XAE_MDIO_MIP_OFFSET); + data[25] = axienet_ior(lp, XAE_MDIO_MIE_OFFSET); + data[26] = axienet_ior(lp, XAE_MDIO_MIC_OFFSET); + data[27] = axienet_ior(lp, XAE_UAW0_OFFSET); + data[28] = axienet_ior(lp, XAE_UAW1_OFFSET); + data[29] = axienet_ior(lp, XAE_FMI_OFFSET); + data[30] = axienet_ior(lp, XAE_AF0_OFFSET); + data[31] = axienet_ior(lp, XAE_AF1_OFFSET); +} + +/** + * axienet_ethtools_get_pauseparam - Get the pause parameter setting for + * Tx and Rx paths. + * @ndev: Pointer to net_device structure + * @epauseparm: Pointer to ethtool_pauseparam structure. + * + * This implements ethtool command for getting axi ethernet pause frame + * setting. Issue "ethtool -a ethX" to execute this function. + */ +static void +axienet_ethtools_get_pauseparam(struct net_device *ndev, + struct ethtool_pauseparam *epauseparm) +{ + u32 regval; + struct axienet_local *lp = netdev_priv(ndev); + epauseparm->autoneg = 0; + regval = axienet_ior(lp, XAE_FCC_OFFSET); + epauseparm->tx_pause = regval & XAE_FCC_FCTX_MASK; + epauseparm->rx_pause = regval & XAE_FCC_FCRX_MASK; +} + +/** + * axienet_ethtools_set_pauseparam - Set device pause parameter(flow control) + * settings. + * @ndev: Pointer to net_device structure + * @epauseparam:Pointer to ethtool_pauseparam structure + * + * This implements ethtool command for enabling flow control on Rx and Tx + * paths. Issue "ethtool -A ethX tx on|off" under linux prompt to execute this + * function. + */ +static int +axienet_ethtools_set_pauseparam(struct net_device *ndev, + struct ethtool_pauseparam *epauseparm) +{ + u32 regval = 0; + struct axienet_local *lp = netdev_priv(ndev); + + if (netif_running(ndev)) { + printk(KERN_ERR "%s: Please stop netif before applying " + "configruation\n", ndev->name); + return -EFAULT; + } + + regval = axienet_ior(lp, XAE_FCC_OFFSET); + if (epauseparm->tx_pause) + regval |= XAE_FCC_FCTX_MASK; + else + regval &= ~XAE_FCC_FCTX_MASK; + if (epauseparm->rx_pause) + regval |= XAE_FCC_FCRX_MASK; + else + regval &= ~XAE_FCC_FCRX_MASK; + axienet_iow(lp, XAE_FCC_OFFSET, regval); + + return 0; +} + +/** + * axienet_ethtools_get_coalesce - Get DMA interrupt coalescing count. + * @ndev: Pointer to net_device structure + * @ecoalesce: Pointer to ethtool_coalesce structure + * + * This implements ethtool command for getting the DMA interrupt coalescing + * count on Tx and Rx paths. Issue "ethtool -c ethX" under linux prompt to + * execute this function. + */ +static int axienet_ethtools_get_coalesce(struct net_device *ndev, + struct ethtool_coalesce *ecoalesce) +{ + u32 regval = 0; + struct axienet_local *lp = netdev_priv(ndev); + regval = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + ecoalesce->rx_max_coalesced_frames = (regval & XAXIDMA_COALESCE_MASK) + >> XAXIDMA_COALESCE_SHIFT; + regval = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + ecoalesce->tx_max_coalesced_frames = (regval & XAXIDMA_COALESCE_MASK) + >> XAXIDMA_COALESCE_SHIFT; + return 0; +} + +/** + * axienet_ethtools_set_coalesce - Set DMA interrupt coalescing count. + * @ndev: Pointer to net_device structure + * @ecoalesce: Pointer to ethtool_coalesce structure + * + * This implements ethtool command for setting the DMA interrupt coalescing + * count on Tx and Rx paths. Issue "ethtool -C ethX rx-frames 5" under linux + * prompt to execute this function. + */ +static int axienet_ethtools_set_coalesce(struct net_device *ndev, + struct ethtool_coalesce *ecoalesce) +{ + struct axienet_local *lp = netdev_priv(ndev); + + if (netif_running(ndev)) { + printk(KERN_ERR "%s: Please stop netif before applying " + "configruation\n", ndev->name); + return -EFAULT; + } + + if ((ecoalesce->rx_coalesce_usecs) || + (ecoalesce->rx_coalesce_usecs_irq) || + (ecoalesce->rx_max_coalesced_frames_irq) || + (ecoalesce->tx_coalesce_usecs) || + (ecoalesce->tx_coalesce_usecs_irq) || + (ecoalesce->tx_max_coalesced_frames_irq) || + (ecoalesce->stats_block_coalesce_usecs) || + (ecoalesce->use_adaptive_rx_coalesce) || + (ecoalesce->use_adaptive_tx_coalesce) || + (ecoalesce->pkt_rate_low) || + (ecoalesce->rx_coalesce_usecs_low) || + (ecoalesce->rx_max_coalesced_frames_low) || + (ecoalesce->tx_coalesce_usecs_low) || + (ecoalesce->tx_max_coalesced_frames_low) || + (ecoalesce->pkt_rate_high) || + (ecoalesce->rx_coalesce_usecs_high) || + (ecoalesce->rx_max_coalesced_frames_high) || + (ecoalesce->tx_coalesce_usecs_high) || + (ecoalesce->tx_max_coalesced_frames_high) || + (ecoalesce->rate_sample_interval)) + return -EOPNOTSUPP; + if (ecoalesce->rx_max_coalesced_frames) + lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames; + if (ecoalesce->tx_max_coalesced_frames) + lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames; + + return 0; +} + +static struct ethtool_ops axienet_ethtool_ops = { + .get_settings = axienet_ethtools_get_settings, + .set_settings = axienet_ethtools_set_settings, + .get_drvinfo = axienet_ethtools_get_drvinfo, + .get_regs_len = axienet_ethtools_get_regs_len, + .get_regs = axienet_ethtools_get_regs, + .get_link = ethtool_op_get_link, + .get_pauseparam = axienet_ethtools_get_pauseparam, + .set_pauseparam = axienet_ethtools_set_pauseparam, + .get_coalesce = axienet_ethtools_get_coalesce, + .set_coalesce = axienet_ethtools_set_coalesce, +}; + +/** + * axienet_dma_err_handler - Tasklet handler for Axi DMA Error + * @data: Data passed + * + * Resets the Axi DMA and Axi Ethernet devices, and reconfigures the + * Tx/Rx BDs. + */ +static void axienet_dma_err_handler(unsigned long data) +{ + u32 axienet_status; + u32 cr, i; + int mdio_mcreg; + struct axienet_local *lp = (struct axienet_local *) data; + struct net_device *ndev = lp->ndev; + struct axidma_bd *cur_p; + + axienet_setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + mdio_mcreg = axienet_ior(lp, XAE_MDIO_MC_OFFSET); + axienet_mdio_wait_until_ready(lp); + /* Disable the MDIO interface till Axi Ethernet Reset is completed. + * When we do an Axi Ethernet reset, it resets the complete core + * including the MDIO. So if MDIO is not disabled when the reset + * process is started, MDIO will be broken afterwards. */ + axienet_iow(lp, XAE_MDIO_MC_OFFSET, (mdio_mcreg & + ~XAE_MDIO_MC_MDIOEN_MASK)); + + __axienet_device_reset(lp, &ndev->dev, XAXIDMA_TX_CR_OFFSET); + __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET); + + axienet_iow(lp, XAE_MDIO_MC_OFFSET, mdio_mcreg); + axienet_mdio_wait_until_ready(lp); + + for (i = 0; i < TX_BD_NUM; i++) { + cur_p = &lp->tx_bd_v[i]; + if (cur_p->phys) + dma_unmap_single(ndev->dev.parent, cur_p->phys, + (cur_p->cntrl & + XAXIDMA_BD_CTRL_LENGTH_MASK), + DMA_TO_DEVICE); + if (cur_p->app4) + dev_kfree_skb_irq((struct sk_buff *) cur_p->app4); + cur_p->phys = 0; + cur_p->cntrl = 0; + cur_p->status = 0; + cur_p->app0 = 0; + cur_p->app1 = 0; + cur_p->app2 = 0; + cur_p->app3 = 0; + cur_p->app4 = 0; + cur_p->sw_id_offset = 0; + } + + for (i = 0; i < RX_BD_NUM; i++) { + cur_p = &lp->rx_bd_v[i]; + cur_p->status = 0; + cur_p->app0 = 0; + cur_p->app1 = 0; + cur_p->app2 = 0; + cur_p->app3 = 0; + cur_p->app4 = 0; + } + + lp->tx_bd_ci = 0; + lp->tx_bd_tail = 0; + lp->rx_bd_ci = 0; + + /* Start updating the Rx channel control register */ + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + /* Update the interrupt coalesce count */ + cr = ((cr & ~XAXIDMA_COALESCE_MASK) | + (XAXIDMA_DFT_RX_THRESHOLD << XAXIDMA_COALESCE_SHIFT)); + /* Update the delay timer count */ + cr = ((cr & ~XAXIDMA_DELAY_MASK) | + (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); + /* Enable coalesce, delay timer and error interrupts */ + cr |= XAXIDMA_IRQ_ALL_MASK; + /* Finally write to the Rx channel control register */ + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr); + + /* Start updating the Tx channel control register */ + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + /* Update the interrupt coalesce count */ + cr = (((cr & ~XAXIDMA_COALESCE_MASK)) | + (XAXIDMA_DFT_TX_THRESHOLD << XAXIDMA_COALESCE_SHIFT)); + /* Update the delay timer count */ + cr = (((cr & ~XAXIDMA_DELAY_MASK)) | + (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT)); + /* Enable coalesce, delay timer and error interrupts */ + cr |= XAXIDMA_IRQ_ALL_MASK; + /* Finally write to the Tx channel control register */ + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr); + + /* Populate the tail pointer and bring the Rx Axi DMA engine out of + * halted state. This will make the Rx side ready for reception.*/ + axienet_dma_out32(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); + cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, + cr | XAXIDMA_CR_RUNSTOP_MASK); + axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1))); + + /* Write to the RS (Run-stop) bit in the Tx channel control register. + * Tx channel is now ready to run. But only after we write to the + * tail pointer register that the Tx channel will start transmitting */ + axienet_dma_out32(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); + cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, + cr | XAXIDMA_CR_RUNSTOP_MASK); + + axienet_status = axienet_ior(lp, XAE_RCW1_OFFSET); + axienet_status &= ~XAE_RCW1_RX_MASK; + axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status); + + axienet_status = axienet_ior(lp, XAE_IP_OFFSET); + if (axienet_status & XAE_INT_RXRJECT_MASK) + axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK); + axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK); + + /* Sync default options with HW but leave receiver and + * transmitter disabled.*/ + axienet_setoptions(ndev, lp->options & + ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); + axienet_set_mac_address(ndev, NULL); + axienet_set_multicast_list(ndev); + axienet_setoptions(ndev, lp->options); +} + +/** + * axienet_of_probe - Axi Ethernet probe function. + * @op: Pointer to platform device structure. + * @match: Pointer to device id structure + * + * returns: 0, on success + * Non-zero error value on failure. + * + * This is the probe routine for Axi Ethernet driver. This is called before + * any other driver routines are invoked. It allocates and sets up the Ethernet + * device. Parses through device tree and populates fields of + * axienet_local. It registers the Ethernet device. + */ +static int __devinit axienet_of_probe(struct platform_device *op) +{ + __be32 *p; + int size, ret = 0; + struct device_node *np; + struct axienet_local *lp; + struct net_device *ndev; + const void *addr; + + ndev = alloc_etherdev(sizeof(*lp)); + if (!ndev) { + dev_err(&op->dev, "could not allocate device.\n"); + return -ENOMEM; + } + + ether_setup(ndev); + dev_set_drvdata(&op->dev, ndev); + + SET_NETDEV_DEV(ndev, &op->dev); + ndev->flags &= ~IFF_MULTICAST; /* clear multicast */ + ndev->features = NETIF_F_SG | NETIF_F_FRAGLIST; + ndev->netdev_ops = &axienet_netdev_ops; + ndev->ethtool_ops = &axienet_ethtool_ops; + + lp = netdev_priv(ndev); + lp->ndev = ndev; + lp->dev = &op->dev; + lp->options = XAE_OPTION_DEFAULTS; + /* Map device registers */ + lp->regs = of_iomap(op->dev.of_node, 0); + if (!lp->regs) { + dev_err(&op->dev, "could not map Axi Ethernet regs.\n"); + goto nodev; + } + /* Setup checksum offload, but default to off if not specified */ + lp->features = 0; + + p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,txcsum", NULL); + if (p) { + switch (be32_to_cpup(p)) { + case 1: + lp->csum_offload_on_tx_path = + XAE_FEATURE_PARTIAL_TX_CSUM; + lp->features |= XAE_FEATURE_PARTIAL_TX_CSUM; + /* Can checksum TCP/UDP over IPv4. */ + ndev->features |= NETIF_F_IP_CSUM; + break; + case 2: + lp->csum_offload_on_tx_path = + XAE_FEATURE_FULL_TX_CSUM; + lp->features |= XAE_FEATURE_FULL_TX_CSUM; + /* Can checksum TCP/UDP over IPv4. */ + ndev->features |= NETIF_F_IP_CSUM; + break; + default: + lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD; + } + } + p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxcsum", NULL); + if (p) { + switch (be32_to_cpup(p)) { + case 1: + lp->csum_offload_on_rx_path = + XAE_FEATURE_PARTIAL_RX_CSUM; + lp->features |= XAE_FEATURE_PARTIAL_RX_CSUM; + break; + case 2: + lp->csum_offload_on_rx_path = + XAE_FEATURE_FULL_RX_CSUM; + lp->features |= XAE_FEATURE_FULL_RX_CSUM; + break; + default: + lp->csum_offload_on_rx_path = XAE_NO_CSUM_OFFLOAD; + } + } + /* For supporting jumbo frames, the Axi Ethernet hardware must have + * a larger Rx/Tx Memory. Typically, the size must be more than or + * equal to 16384 bytes, so that we can enable jumbo option and start + * supporting jumbo frames. Here we check for memory allocated for + * Rx/Tx in the hardware from the device-tree and accordingly set + * flags. */ + p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxmem", NULL); + if (p) { + if ((be32_to_cpup(p)) >= 0x4000) + lp->jumbo_support = 1; + } + p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,temac-type", + NULL); + if (p) + lp->temac_type = be32_to_cpup(p); + p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL); + if (p) + lp->phy_type = be32_to_cpup(p); + + /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ + np = of_parse_phandle(op->dev.of_node, "axistream-connected", 0); + if (!np) { + dev_err(&op->dev, "could not find DMA node\n"); + goto err_iounmap; + } + lp->dma_regs = of_iomap(np, 0); + if (lp->dma_regs) { + dev_dbg(&op->dev, "MEM base: %p\n", lp->dma_regs); + } else { + dev_err(&op->dev, "unable to map DMA registers\n"); + of_node_put(np); + } + lp->rx_irq = irq_of_parse_and_map(np, 1); + lp->tx_irq = irq_of_parse_and_map(np, 0); + of_node_put(np); + if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) { + dev_err(&op->dev, "could not determine irqs\n"); + ret = -ENOMEM; + goto err_iounmap_2; + } + + /* Retrieve the MAC address */ + addr = of_get_property(op->dev.of_node, "local-mac-address", &size); + if ((!addr) || (size != 6)) { + dev_err(&op->dev, "could not find MAC address\n"); + ret = -ENODEV; + goto err_iounmap_2; + } + axienet_set_mac_address(ndev, (void *) addr); + + lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; + lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; + + lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0); + ret = axienet_mdio_setup(lp, op->dev.of_node); + if (ret) + dev_warn(&op->dev, "error registering MDIO bus\n"); + + ret = register_netdev(lp->ndev); + if (ret) { + dev_err(lp->dev, "register_netdev() error (%i)\n", ret); + goto err_iounmap_2; + } + + tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler, + (unsigned long) lp); + tasklet_disable(&lp->dma_err_tasklet); + + return 0; + +err_iounmap_2: + if (lp->dma_regs) + iounmap(lp->dma_regs); +err_iounmap: + iounmap(lp->regs); +nodev: + free_netdev(ndev); + ndev = NULL; + return ret; +} + +static int __devexit axienet_of_remove(struct platform_device *op) +{ + struct net_device *ndev = dev_get_drvdata(&op->dev); + struct axienet_local *lp = netdev_priv(ndev); + + axienet_mdio_teardown(lp); + unregister_netdev(ndev); + + if (lp->phy_node) + of_node_put(lp->phy_node); + lp->phy_node = NULL; + + dev_set_drvdata(&op->dev, NULL); + + iounmap(lp->regs); + if (lp->dma_regs) + iounmap(lp->dma_regs); + free_netdev(ndev); + + return 0; +} + +static struct platform_driver axienet_of_driver = { + .probe = axienet_of_probe, + .remove = __devexit_p(axienet_of_remove), + .driver = { + .owner = THIS_MODULE, + .name = "xilinx_axienet", + .of_match_table = axienet_of_match, + }, +}; + +static int __init axienet_init(void) +{ + return platform_driver_register(&axienet_of_driver); +} + +static void __exit axienet_exit(void) +{ + platform_driver_unregister(&axienet_of_driver); +} + +module_init(axienet_init); +module_exit(axienet_exit); + +MODULE_DESCRIPTION("Xilinx Axi Ethernet driver"); +MODULE_AUTHOR("Xilinx"); +MODULE_LICENSE("GPL"); diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c new file mode 100644 index 000000000000..d70b6e79f6c0 --- /dev/null +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c @@ -0,0 +1,238 @@ +/* + * MDIO bus driver for the Xilinx Axi Ethernet device + * + * Copyright (c) 2009 Secret Lab Technologies, Ltd. + * Copyright (c) 2010 Xilinx, Inc. All rights reserved. + * Copyright (c) 2012 Daniel Borkmann, + * Copyright (c) 2012 Ariane Keller, + */ + +#include +#include +#include + +#include "xilinx_axienet.h" + +#define MAX_MDIO_FREQ 2500000 /* 2.5 MHz */ +#define DEFAULT_CLOCK_DIVISOR XAE_MDIO_DIV_DFT + +/* Wait till MDIO interface is ready to accept a new transaction.*/ +int axienet_mdio_wait_until_ready(struct axienet_local *lp) +{ + long end = jiffies + 2; + while (!(axienet_ior(lp, XAE_MDIO_MCR_OFFSET) & + XAE_MDIO_MCR_READY_MASK)) { + if (end - jiffies <= 0) { + WARN_ON(1); + return -ETIMEDOUT; + } + udelay(1); + } + return 0; +} + +/** + * axienet_mdio_read - MDIO interface read function + * @bus: Pointer to mii bus structure + * @phy_id: Address of the PHY device + * @reg: PHY register to read + * + * returns: The register contents on success, -ETIMEDOUT on a timeout + * + * Reads the contents of the requested register from the requested PHY + * address by first writing the details into MCR register. After a while + * the register MRD is read to obtain the PHY register content. + */ +static int axienet_mdio_read(struct mii_bus *bus, int phy_id, int reg) +{ + u32 rc; + int ret; + struct axienet_local *lp = bus->priv; + + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + + axienet_iow(lp, XAE_MDIO_MCR_OFFSET, + (((phy_id << XAE_MDIO_MCR_PHYAD_SHIFT) & + XAE_MDIO_MCR_PHYAD_MASK) | + ((reg << XAE_MDIO_MCR_REGAD_SHIFT) & + XAE_MDIO_MCR_REGAD_MASK) | + XAE_MDIO_MCR_INITIATE_MASK | + XAE_MDIO_MCR_OP_READ_MASK)); + + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + + rc = axienet_ior(lp, XAE_MDIO_MRD_OFFSET) & 0x0000FFFF; + + dev_dbg(lp->dev, "axienet_mdio_read(phy_id=%i, reg=%x) == %x\n", + phy_id, reg, rc); + + return rc; +} + +/** + * axienet_mdio_write - MDIO interface write function + * @bus: Pointer to mii bus structure + * @phy_id: Address of the PHY device + * @reg: PHY register to write to + * @val: Value to be written into the register + * + * returns: 0 on success, -ETIMEDOUT on a timeout + * + * Writes the value to the requested register by first writing the value + * into MWD register. The the MCR register is then appropriately setup + * to finish the write operation. + */ +static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg, + u16 val) +{ + int ret; + struct axienet_local *lp = bus->priv; + + dev_dbg(lp->dev, "axienet_mdio_write(phy_id=%i, reg=%x, val=%x)\n", + phy_id, reg, val); + + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + + axienet_iow(lp, XAE_MDIO_MWD_OFFSET, (u32) val); + axienet_iow(lp, XAE_MDIO_MCR_OFFSET, + (((phy_id << XAE_MDIO_MCR_PHYAD_SHIFT) & + XAE_MDIO_MCR_PHYAD_MASK) | + ((reg << XAE_MDIO_MCR_REGAD_SHIFT) & + XAE_MDIO_MCR_REGAD_MASK) | + XAE_MDIO_MCR_INITIATE_MASK | + XAE_MDIO_MCR_OP_WRITE_MASK)); + + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + return 0; +} + +/** + * axienet_mdio_setup - MDIO setup function + * @lp: Pointer to axienet local data structure. + * @np: Pointer to device node + * + * returns: 0 on success, -ETIMEDOUT on a timeout, -ENOMEM when + * mdiobus_alloc (to allocate memory for mii bus structure) fails. + * + * Sets up the MDIO interface by initializing the MDIO clock and enabling the + * MDIO interface in hardware. Register the MDIO interface. + **/ +int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np) +{ + int ret; + u32 clk_div, host_clock; + u32 *property_p; + struct mii_bus *bus; + struct resource res; + struct device_node *np1; + + /* clk_div can be calculated by deriving it from the equation: + * fMDIO = fHOST / ((1 + clk_div) * 2) + * + * Where fMDIO <= 2500000, so we get: + * fHOST / ((1 + clk_div) * 2) <= 2500000 + * + * Then we get: + * 1 / ((1 + clk_div) * 2) <= (2500000 / fHOST) + * + * Then we get: + * 1 / (1 + clk_div) <= ((2500000 * 2) / fHOST) + * + * Then we get: + * 1 / (1 + clk_div) <= (5000000 / fHOST) + * + * So: + * (1 + clk_div) >= (fHOST / 5000000) + * + * And finally: + * clk_div >= (fHOST / 5000000) - 1 + * + * fHOST can be read from the flattened device tree as property + * "clock-frequency" from the CPU + */ + + np1 = of_find_node_by_name(NULL, "cpu"); + if (!np1) { + printk(KERN_WARNING "%s(): Could not find CPU device node.", + __func__); + printk(KERN_WARNING "Setting MDIO clock divisor to " + "default %d\n", DEFAULT_CLOCK_DIVISOR); + clk_div = DEFAULT_CLOCK_DIVISOR; + goto issue; + } + property_p = (u32 *) of_get_property(np1, "clock-frequency", NULL); + if (!property_p) { + printk(KERN_WARNING "%s(): Could not find CPU property: " + "clock-frequency.", __func__); + printk(KERN_WARNING "Setting MDIO clock divisor to " + "default %d\n", DEFAULT_CLOCK_DIVISOR); + clk_div = DEFAULT_CLOCK_DIVISOR; + goto issue; + } + + host_clock = be32_to_cpup(property_p); + clk_div = (host_clock / (MAX_MDIO_FREQ * 2)) - 1; + /* If there is any remainder from the division of + * fHOST / (MAX_MDIO_FREQ * 2), then we need to add + * 1 to the clock divisor or we will surely be above 2.5 MHz */ + if (host_clock % (MAX_MDIO_FREQ * 2)) + clk_div++; + + printk(KERN_DEBUG "%s(): Setting MDIO clock divisor to %u based " + "on %u Hz host clock.\n", __func__, clk_div, host_clock); + + of_node_put(np1); +issue: + axienet_iow(lp, XAE_MDIO_MC_OFFSET, + (((u32) clk_div) | XAE_MDIO_MC_MDIOEN_MASK)); + + ret = axienet_mdio_wait_until_ready(lp); + if (ret < 0) + return ret; + + bus = mdiobus_alloc(); + if (!bus) + return -ENOMEM; + + np1 = of_get_parent(lp->phy_node); + of_address_to_resource(np1, 0, &res); + snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", + (unsigned long long) res.start); + + bus->priv = lp; + bus->name = "Xilinx Axi Ethernet MDIO"; + bus->read = axienet_mdio_read; + bus->write = axienet_mdio_write; + bus->parent = lp->dev; + bus->irq = lp->mdio_irqs; /* preallocated IRQ table */ + lp->mii_bus = bus; + + ret = of_mdiobus_register(bus, np1); + if (ret) { + mdiobus_free(bus); + return ret; + } + return 0; +} + +/** + * axienet_mdio_teardown - MDIO remove function + * @lp: Pointer to axienet local data structure. + * + * Unregisters the MDIO and frees any associate memory for mii bus. + */ +void axienet_mdio_teardown(struct axienet_local *lp) +{ + mdiobus_unregister(lp->mii_bus); + kfree(lp->mii_bus->irq); + mdiobus_free(lp->mii_bus); + lp->mii_bus = NULL; +} -- GitLab From 9b28ecd66b391349d3492574500f978566195454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Thu, 19 Jan 2012 15:37:22 +0000 Subject: [PATCH 0144/1846] net: usb: qmi_wwan: New driver for Huawei QMI based WWAN devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some WWAN LTE/3G devices based on chipsets from Qualcomm provide near standard CDC ECM interfaces in addition to the usual serial interfaces. The Huawei E392/E398 are examples of such devices. These typically cannot be fully configured using AT commands over a serial interface. It is necessary to speak the proprietary Qualcomm MSM Interface (QMI) protocol to the device to enable the ethernet proxy functionality. The devices embed the QMI protocol in CDC on the control interface, using standard CDC commands and notifications. The do not otherwise use CDC commands for the ethernet function. This driver does therefore not need access to any other aspects of the control interface than the descriptors attached to it. Another driver, cdc-wdm, will provide userspace access to the QMI protocol independently of this driver. To facilitate this, this driver avoids binding to the control interface, and uses only the associated data interface after parsing the common CDC functional descriptors on the control interface. You will want both the cdc-wdm and option drivers as companions to this driver, to have full access to all interfaces and protocols exported by the device. Signed-off-by: Bjørn Mork Signed-off-by: David S. Miller --- drivers/net/usb/Kconfig | 22 ++++ drivers/net/usb/Makefile | 1 + drivers/net/usb/qmi_wwan.c | 228 +++++++++++++++++++++++++++++++++++++ 3 files changed, 251 insertions(+) create mode 100644 drivers/net/usb/qmi_wwan.c diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 233576127934..4bad899fb38f 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig @@ -398,6 +398,27 @@ config USB_NET_KALMIA To compile this driver as a module, choose M here: the module will be called kalmia. +config USB_NET_QMI_WWAN + tristate "QMI WWAN driver for Qualcomm MSM based 3G and LTE modems" + depends on USB_USBNET + help + Support WWAN LTE/3G devices based on Qualcomm Mobile Data Modem + (MDM) chipsets. Examples of such devices are + * Huawei E392/E398 + + This driver will only drive the ethernet part of the chips. + The devices require additional configuration to be usable. + Multiple management interfaces with linux drivers are + available: + + * option: AT commands on /dev/ttyUSBx + * cdc-wdm: Qualcomm MSM Interface (QMI) protocol on /dev/cdc-wdmx + + A modem manager with support for QMI is recommended. + + To compile this driver as a module, choose M here: the + module will be called qmi_wwan. + config USB_HSO tristate "Option USB High Speed Mobile Devices" depends on USB && RFKILL @@ -461,4 +482,5 @@ config USB_VL600 http://ubuntuforums.org/showpost.php?p=10589647&postcount=17 + endmenu diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index c203fa21f6b1..a2e2d72c52a0 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile @@ -29,4 +29,5 @@ obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o obj-$(CONFIG_USB_NET_CX82310_ETH) += cx82310_eth.o obj-$(CONFIG_USB_NET_CDC_NCM) += cdc_ncm.o obj-$(CONFIG_USB_VL600) += lg-vl600.o +obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c new file mode 100644 index 000000000000..739e6de7abcb --- /dev/null +++ b/drivers/net/usb/qmi_wwan.c @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2012 Bjørn Mork + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* The name of the CDC Device Management driver */ +#define DM_DRIVER "cdc_wdm" + +/* + * This driver supports wwan (3G/LTE/?) devices using a vendor + * specific management protocol called Qualcomm MSM Interface (QMI) - + * in addition to the more common AT commands over serial interface + * management + * + * QMI is wrapped in CDC, using CDC encapsulated commands on the + * control ("master") interface of a two-interface CDC Union + * resembling standard CDC ECM. The devices do not use the control + * interface for any other CDC messages. Most likely because the + * management protocol is used in place of the standard CDC + * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE + * + * Handling a protocol like QMI is out of the scope for any driver. + * It can be exported as a character device using the cdc-wdm driver, + * which will enable userspace applications ("modem managers") to + * handle it. This may be required to use the network interface + * provided by the driver. + * + * These devices may alternatively/additionally be configured using AT + * commands on any of the serial interfaces driven by the option driver + * + * This driver binds only to the data ("slave") interface to enable + * the cdc-wdm driver to bind to the control interface. It still + * parses the CDC functional descriptors on the control interface to + * a) verify that this is indeed a handled interface (CDC Union + * header lists it as slave) + * b) get MAC address and other ethernet config from the CDC Ethernet + * header + * c) enable user bind requests against the control interface, which + * is the common way to bind to CDC Ethernet Control Model type + * interfaces + * d) provide a hint to the user about which interface is the + * corresponding management interface + */ + +static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int status = -1; + struct usb_interface *control = NULL; + u8 *buf = intf->cur_altsetting->extra; + int len = intf->cur_altsetting->extralen; + struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc; + struct usb_cdc_union_desc *cdc_union = NULL; + struct usb_cdc_ether_desc *cdc_ether = NULL; + u32 required = 1 << USB_CDC_HEADER_TYPE | 1 << USB_CDC_UNION_TYPE; + u32 found = 0; + + /* + * assume a data interface has no additional descriptors and + * that the control and data interface are numbered + * consecutively - this holds for the Huawei device at least + */ + if (len == 0 && desc->bInterfaceNumber > 0) { + control = usb_ifnum_to_if(dev->udev, desc->bInterfaceNumber - 1); + if (!control) + goto err; + + buf = control->cur_altsetting->extra; + len = control->cur_altsetting->extralen; + dev_dbg(&intf->dev, "guessing \"control\" => %s, \"data\" => this\n", + dev_name(&control->dev)); + } + + while (len > 3) { + struct usb_descriptor_header *h = (void *)buf; + + /* ignore any misplaced descriptors */ + if (h->bDescriptorType != USB_DT_CS_INTERFACE) + goto next_desc; + + /* buf[2] is CDC descriptor subtype */ + switch (buf[2]) { + case USB_CDC_HEADER_TYPE: + if (found & 1 << USB_CDC_HEADER_TYPE) { + dev_dbg(&intf->dev, "extra CDC header\n"); + goto err; + } + if (h->bLength != sizeof(struct usb_cdc_header_desc)) { + dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength); + goto err; + } + break; + case USB_CDC_UNION_TYPE: + if (found & 1 << USB_CDC_UNION_TYPE) { + dev_dbg(&intf->dev, "extra CDC union\n"); + goto err; + } + if (h->bLength != sizeof(struct usb_cdc_union_desc)) { + dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength); + goto err; + } + cdc_union = (struct usb_cdc_union_desc *)buf; + break; + case USB_CDC_ETHERNET_TYPE: + if (found & 1 << USB_CDC_ETHERNET_TYPE) { + dev_dbg(&intf->dev, "extra CDC ether\n"); + goto err; + } + if (h->bLength != sizeof(struct usb_cdc_ether_desc)) { + dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength); + goto err; + } + cdc_ether = (struct usb_cdc_ether_desc *)buf; + break; + } + + /* + * Remember which CDC functional descriptors we've seen. Works + * for all types we care about, of which USB_CDC_ETHERNET_TYPE + * (0x0f) is the highest numbered + */ + if (buf[2] < 32) + found |= 1 << buf[2]; + +next_desc: + len -= h->bLength; + buf += h->bLength; + } + + /* did we find all the required ones? */ + if ((found & required) != required) { + dev_err(&intf->dev, "CDC functional descriptors missing\n"); + goto err; + } + + /* give the user a helpful hint if trying to bind to the wrong interface */ + if (cdc_union && desc->bInterfaceNumber == cdc_union->bMasterInterface0) { + dev_err(&intf->dev, "leaving \"control\" interface for " DM_DRIVER " - try binding to %s instead!\n", + dev_name(&usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0)->dev)); + goto err; + } + + /* errors aren't fatal - we can live with the dynamic address */ + if (cdc_ether) { + dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize); + usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress); + } + + /* success! point the user to the management interface */ + if (control) + dev_info(&intf->dev, "Use \"" DM_DRIVER "\" for QMI interface %s\n", + dev_name(&control->dev)); + + /* XXX: add a sysfs symlink somewhere to help management applications find it? */ + + /* collect bulk endpoints now that we know intf == "data" interface */ + status = usbnet_get_endpoints(dev, intf); + +err: + return status; +} + +/* stolen from cdc_ether.c */ +static int qmi_wwan_manage_power(struct usbnet *dev, int on) +{ + dev->intf->needs_remote_wakeup = on; + return 0; +} + +static const struct driver_info qmi_wwan_info = { + .description = "QMI speaking wwan device", + .flags = FLAG_WWAN, + .bind = qmi_wwan_bind, + .manage_power = qmi_wwan_manage_power, +}; + +#define HUAWEI_VENDOR_ID 0x12D1 + +static const struct usb_device_id products[] = { +{ + /* Huawei E392, E398 and possibly others sharing both device id and more... */ + .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = HUAWEI_VENDOR_ID, + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */ + .driver_info = (unsigned long)&qmi_wwan_info, +}, { +}, /* END */ +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver qmi_wwan_driver = { + .name = "qmi_wwan", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, + .suspend = usbnet_suspend, + .resume = usbnet_resume, + .reset_resume = usbnet_resume, + .supports_autosuspend = 1, +}; + +static int __init qmi_wwan_init(void) +{ + return usb_register(&qmi_wwan_driver); +} +module_init(qmi_wwan_init); + +static void __exit qmi_wwan_exit(void) +{ + usb_deregister(&qmi_wwan_driver); +} +module_exit(qmi_wwan_exit); + +MODULE_AUTHOR("Bjørn Mork "); +MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver"); +MODULE_LICENSE("GPL"); -- GitLab From 02b619555ad68884bacfbe41893245394cb44885 Mon Sep 17 00:00:00 2001 From: David Miller Date: Tue, 24 Jan 2012 13:15:52 +0000 Subject: [PATCH 0145/1846] infiniband: Convert dst_fetch_ha() over to dst_neigh_lookup(). Now we must provide the IP destination address, and a reference has to be dropped when we're done with the entry. Signed-off-by: David S. Miller --- drivers/infiniband/core/addr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 1612cfd50f39..6ef660c1332f 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -178,22 +178,26 @@ static void queue_req(struct addr_req *req) mutex_unlock(&lock); } -static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *addr) +static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr, void *daddr) { struct neighbour *n; int ret; + n = dst_neigh_lookup(dst, daddr); + rcu_read_lock(); - n = dst_get_neighbour_noref(dst); if (!n || !(n->nud_state & NUD_VALID)) { if (n) neigh_event_send(n, NULL); ret = -ENODATA; } else { - ret = rdma_copy_addr(addr, dst->dev, n->ha); + ret = rdma_copy_addr(dev_addr, dst->dev, n->ha); } rcu_read_unlock(); + if (n) + neigh_release(n); + return ret; } @@ -232,7 +236,7 @@ static int addr4_resolve(struct sockaddr_in *src_in, goto put; } - ret = dst_fetch_ha(&rt->dst, addr); + ret = dst_fetch_ha(&rt->dst, addr, &fl4.daddr); put: ip_rt_put(rt); out: @@ -280,7 +284,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, goto put; } - ret = dst_fetch_ha(dst, addr); + ret = dst_fetch_ha(dst, addr, &fl6.daddr); put: dst_release(dst); return ret; -- GitLab From 64b7007eb99b78cbdd6cca7a98e12794201b9725 Mon Sep 17 00:00:00 2001 From: David Miller Date: Tue, 24 Jan 2012 13:15:57 +0000 Subject: [PATCH 0146/1846] infiniband: cxgb4: Convert import_ep() over to dst_neigh_lookup(). Now we must provide the IP destination address, and a reference has to be dropped when we're done with the entry. Signed-off-by: David S. Miller Signed-off-by: Steve Wise Signed-off-by: David S. Miller --- drivers/infiniband/hw/cxgb4/cm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index 0668bb3472d0..0cf61554f176 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -1562,11 +1562,11 @@ static int import_ep(struct c4iw_ep *ep, __be32 peer_ip, struct dst_entry *dst, struct neighbour *n; int err, step; - rcu_read_lock(); - n = dst_get_neighbour_noref(dst); - err = -ENODEV; + n = dst_neigh_lookup(dst, &peer_ip); if (!n) - goto out; + return -ENODEV; + + rcu_read_lock(); err = -ENOMEM; if (n->dev->flags & IFF_LOOPBACK) { struct net_device *pdev; @@ -1614,6 +1614,8 @@ static int import_ep(struct c4iw_ep *ep, __be32 peer_ip, struct dst_entry *dst, out: rcu_read_unlock(); + neigh_release(n); + return err; } -- GitLab From e55684fadbc5c9c69cad1b3bae228c8374b99b85 Mon Sep 17 00:00:00 2001 From: David Miller Date: Tue, 24 Jan 2012 13:16:03 +0000 Subject: [PATCH 0147/1846] infiniband: nes: Convert nes_addr_resolve_neigh() over to dst_neigh_lookup(). Now we must provide the IP destination address, and a reference has to be dropped when we're done with the entry. Signed-off-by: David S. Miller --- drivers/infiniband/hw/nes/nes_cm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c index 425065b36b8c..fc5192ee928b 100644 --- a/drivers/infiniband/hw/nes/nes_cm.c +++ b/drivers/infiniband/hw/nes/nes_cm.c @@ -1348,8 +1348,9 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi else netdev = nesvnic->netdev; + neigh = dst_neigh_lookup(&rt->dst, &dst_ip); + rcu_read_lock(); - neigh = dst_get_neighbour_noref(&rt->dst); if (neigh) { if (neigh->nud_state & NUD_VALID) { nes_debug(NES_DBG_CM, "Neighbor MAC address for 0x%08X" @@ -1360,8 +1361,7 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi if (!memcmp(nesadapter->arp_table[arpindex].mac_addr, neigh->ha, ETH_ALEN)) { /* Mac address same as in nes_arp_table */ - ip_rt_put(rt); - return rc; + goto out; } nes_manage_arp_cache(nesvnic->netdev, @@ -1377,7 +1377,12 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi neigh_event_send(neigh, NULL); } } +out: rcu_read_unlock(); + + if (neigh) + neigh_release(neigh); + ip_rt_put(rt); return rc; } -- GitLab From afd12939a09ca8f96cf8349c913dc143471c9b3c Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Thu, 5 Jan 2012 00:34:05 +0000 Subject: [PATCH 0148/1846] e1000e: cleanup Rx checksum offload code 1) cleanup whitespace in e1000_rx_checksum() function header comment 2) do not check hardware checksum when Rx checksum is disabled 3) reduce duplicated calls to le16_to_cpu() by just using it within e1000_rx_checksum() instead of in each call to the function v2: use swab16 instead of le16_to_cpu & htons and corrected type for the passed-in csum Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 3911401ed65d..263bf5f02eb1 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -487,22 +487,27 @@ static void e1000_receive_skb(struct e1000_adapter *adapter, /** * e1000_rx_checksum - Receive Checksum Offload - * @adapter: board private structure - * @status_err: receive descriptor status and error fields - * @csum: receive descriptor csum field - * @sk_buff: socket buffer with received data + * @adapter: board private structure + * @status_err: receive descriptor status and error fields + * @csum: receive descriptor csum field + * @sk_buff: socket buffer with received data **/ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, - u32 csum, struct sk_buff *skb) + __le16 csum, struct sk_buff *skb) { u16 status = (u16)status_err; u8 errors = (u8)(status_err >> 24); skb_checksum_none_assert(skb); + /* Rx checksum disabled */ + if (!(adapter->netdev->features & NETIF_F_RXCSUM)) + return; + /* Ignore Checksum bit is set */ if (status & E1000_RXD_STAT_IXSM) return; + /* TCP/UDP checksum error bit is set */ if (errors & E1000_RXD_ERR_TCPE) { /* let the stack verify checksum errors */ @@ -524,7 +529,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, * Hardware complements the payload checksum, so we undo it * and then put the value in host order for further stack use. */ - __sum16 sum = (__force __sum16)htons(csum); + __sum16 sum = (__force __sum16)swab16((__force u16)csum); skb->csum = csum_unfold(~sum); skb->ip_summed = CHECKSUM_COMPLETE; } @@ -957,8 +962,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, /* Receive Checksum Offload */ e1000_rx_checksum(adapter, staterr, - le16_to_cpu(rx_desc->wb.lower.hi_dword. - csum_ip.csum), skb); + rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); e1000_receive_skb(adapter, netdev, skb, staterr, rx_desc->wb.upper.vlan); @@ -1318,8 +1322,8 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, total_rx_bytes += skb->len; total_rx_packets++; - e1000_rx_checksum(adapter, staterr, le16_to_cpu( - rx_desc->wb.lower.hi_dword.csum_ip.csum), skb); + e1000_rx_checksum(adapter, staterr, + rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); if (rx_desc->wb.upper.header_status & cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)) @@ -1491,8 +1495,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, /* Receive Checksum Offload XXX recompute due to CRC strip? */ e1000_rx_checksum(adapter, staterr, - le16_to_cpu(rx_desc->wb.lower.hi_dword. - csum_ip.csum), skb); + rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); /* probably a little skewed due to removing CRC */ total_rx_bytes += skb->len; -- GitLab From 70495a500d787c0c90a136acf454cb7d0eecd82e Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 11 Jan 2012 01:26:50 +0000 Subject: [PATCH 0149/1846] e1000e: add Receive Packet Steering (RPS) support Enable RPS by default. Disallow jumbo frames when both receive checksum and receive hashing are enabled because the hardware cannot do both IP payload checksum (enabled when receive checksum is enabled when using packet split which is used for jumbo frames) and provide RSS hash at the same time. v2: added ethtool command to query flow hashing behavior per Ben Hutchings and changed the type of rsskey to cleanup the setting of the register array and avoid unnecessary casts (as pointed out by Joe Perches). The long error messages are not changed since there is nothing in the kernel ./Documentation that suggests the preferred method for dealing with long messages other than to never break strings; leaving them as-is for now. Signed-off-by: Bruce Allan Tested-by: Jeff Pieper Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/defines.h | 8 ++ drivers/net/ethernet/intel/e1000e/ethtool.c | 48 +++++++++++ drivers/net/ethernet/intel/e1000e/hw.h | 5 ++ drivers/net/ethernet/intel/e1000e/netdev.c | 90 +++++++++++++++++++-- 4 files changed, 145 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h index c516a7440bec..c73795f46531 100644 --- a/drivers/net/ethernet/intel/e1000e/defines.h +++ b/drivers/net/ethernet/intel/e1000e/defines.h @@ -126,6 +126,13 @@ E1000_RXDEXT_STATERR_CXE | \ E1000_RXDEXT_STATERR_RXE) +#define E1000_MRQC_RSS_FIELD_MASK 0xFFFF0000 +#define E1000_MRQC_RSS_FIELD_IPV4_TCP 0x00010000 +#define E1000_MRQC_RSS_FIELD_IPV4 0x00020000 +#define E1000_MRQC_RSS_FIELD_IPV6_TCP_EX 0x00040000 +#define E1000_MRQC_RSS_FIELD_IPV6 0x00100000 +#define E1000_MRQC_RSS_FIELD_IPV6_TCP 0x00200000 + #define E1000_RXDPS_HDRSTAT_HDRSP 0x00008000 /* Management Control */ @@ -326,6 +333,7 @@ /* Receive Checksum Control */ #define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ #define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ +#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */ /* Header split receive */ #define E1000_RFCTL_NFSW_DIS 0x00000040 diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index fb2c28e799a2..0a3137a791e9 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -1955,6 +1955,53 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset, } } +static int e1000_get_rxnfc(struct net_device *netdev, + struct ethtool_rxnfc *info, u32 *rule_locs) +{ + info->data = 0; + + switch (info->cmd) { + case ETHTOOL_GRXFH: { + struct e1000_adapter *adapter = netdev_priv(netdev); + struct e1000_hw *hw = &adapter->hw; + u32 mrqc = er32(MRQC); + + if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK)) + return 0; + + switch (info->flow_type) { + case TCP_V4_FLOW: + if (mrqc & E1000_MRQC_RSS_FIELD_IPV4_TCP) + info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + /* fall through */ + case UDP_V4_FLOW: + case SCTP_V4_FLOW: + case AH_ESP_V4_FLOW: + case IPV4_FLOW: + if (mrqc & E1000_MRQC_RSS_FIELD_IPV4) + info->data |= RXH_IP_SRC | RXH_IP_DST; + break; + case TCP_V6_FLOW: + if (mrqc & E1000_MRQC_RSS_FIELD_IPV6_TCP) + info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + /* fall through */ + case UDP_V6_FLOW: + case SCTP_V6_FLOW: + case AH_ESP_V6_FLOW: + case IPV6_FLOW: + if (mrqc & E1000_MRQC_RSS_FIELD_IPV6) + info->data |= RXH_IP_SRC | RXH_IP_DST; + break; + default: + break; + } + return 0; + } + default: + return -EOPNOTSUPP; + } +} + static const struct ethtool_ops e1000_ethtool_ops = { .get_settings = e1000_get_settings, .set_settings = e1000_set_settings, @@ -1981,6 +2028,7 @@ static const struct ethtool_ops e1000_ethtool_ops = { .get_sset_count = e1000e_get_sset_count, .get_coalesce = e1000_get_coalesce, .set_coalesce = e1000_set_coalesce, + .get_rxnfc = e1000_get_rxnfc, }; void e1000e_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h index 29670397079b..93c349ee5650 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -204,6 +204,7 @@ enum e1e_registers { E1000_WUC = 0x05800, /* Wakeup Control - RW */ E1000_WUFC = 0x05808, /* Wakeup Filter Control - RW */ E1000_WUS = 0x05810, /* Wakeup Status - RO */ + E1000_MRQC = 0x05818, /* Multiple Receive Control - RW */ E1000_MANC = 0x05820, /* Management Control - RW */ E1000_FFLT = 0x05F00, /* Flexible Filter Length Table - RW Array */ E1000_HOST_IF = 0x08800, /* Host Interface */ @@ -219,6 +220,10 @@ enum e1e_registers { E1000_SWSM = 0x05B50, /* SW Semaphore */ E1000_FWSM = 0x05B54, /* FW Semaphore */ E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */ + E1000_RETA_BASE = 0x05C00, /* Redirection Table - RW */ +#define E1000_RETA(_n) (E1000_RETA_BASE + ((_n) * 4)) + E1000_RSSRK_BASE = 0x05C80, /* RSS Random Key - RW */ +#define E1000_RSSRK(_n) (E1000_RSSRK_BASE + ((_n) * 4)) E1000_FFLT_DBG = 0x05F04, /* Debug Register */ E1000_PCH_RAICC_BASE = 0x05F50, /* Receive Address Initial CRC */ #define E1000_PCH_RAICC(_n) (E1000_PCH_RAICC_BASE + ((_n) * 4)) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 263bf5f02eb1..b196d79e108d 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -845,6 +845,13 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, } } +static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss, + struct sk_buff *skb) +{ + if (netdev->features & NETIF_F_RXHASH) + skb->rxhash = le32_to_cpu(rss); +} + /** * e1000_clean_rx_irq - Send received data up the network stack; legacy * @adapter: board private structure @@ -964,6 +971,8 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, e1000_rx_checksum(adapter, staterr, rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); + e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb); + e1000_receive_skb(adapter, netdev, skb, staterr, rx_desc->wb.upper.vlan); @@ -1325,6 +1334,8 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, e1000_rx_checksum(adapter, staterr, rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); + e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb); + if (rx_desc->wb.upper.header_status & cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)) adapter->rx_hdr_split++; @@ -1497,6 +1508,8 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, e1000_rx_checksum(adapter, staterr, rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); + e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb); + /* probably a little skewed due to removing CRC */ total_rx_bytes += skb->len; total_rx_packets++; @@ -3271,6 +3284,42 @@ static void e1000e_set_rx_mode(struct net_device *netdev) e1000e_vlan_strip_disable(adapter); } +static void e1000e_setup_rss_hash(struct e1000_adapter *adapter) +{ + struct e1000_hw *hw = &adapter->hw; + u32 mrqc, rxcsum; + int i; + static const u32 rsskey[10] = { + 0xda565a6d, 0xc20e5b25, 0x3d256741, 0xb08fa343, 0xcb2bcad0, + 0xb4307bae, 0xa32dcb77, 0x0cf23080, 0x3bb7426a, 0xfa01acbe + }; + + /* Fill out hash function seed */ + for (i = 0; i < 10; i++) + ew32(RSSRK(i), rsskey[i]); + + /* Direct all traffic to queue 0 */ + for (i = 0; i < 32; i++) + ew32(RETA(i), 0); + + /* + * Disable raw packet checksumming so that RSS hash is placed in + * descriptor on writeback. + */ + rxcsum = er32(RXCSUM); + rxcsum |= E1000_RXCSUM_PCSD; + + ew32(RXCSUM, rxcsum); + + mrqc = (E1000_MRQC_RSS_FIELD_IPV4 | + E1000_MRQC_RSS_FIELD_IPV4_TCP | + E1000_MRQC_RSS_FIELD_IPV6 | + E1000_MRQC_RSS_FIELD_IPV6_TCP | + E1000_MRQC_RSS_FIELD_IPV6_TCP_EX); + + ew32(MRQC, mrqc); +} + /** * e1000_configure - configure the hardware for Rx and Tx * @adapter: private board structure @@ -3283,6 +3332,9 @@ static void e1000_configure(struct e1000_adapter *adapter) e1000_init_manageability_pt(adapter); e1000_configure_tx(adapter); + + if (adapter->netdev->features & NETIF_F_RXHASH) + e1000e_setup_rss_hash(adapter); e1000_setup_rctl(adapter); e1000_configure_rx(adapter); adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring), @@ -5168,10 +5220,22 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; /* Jumbo frame support */ - if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) && - !(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) { - e_err("Jumbo Frames not supported.\n"); - return -EINVAL; + if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) { + if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) { + e_err("Jumbo Frames not supported.\n"); + return -EINVAL; + } + + /* + * IP payload checksum (enabled with jumbos/packet-split when + * Rx checksum is enabled) and generation of RSS hash is + * mutually exclusive in the hardware. + */ + if ((netdev->features & NETIF_F_RXCSUM) && + (netdev->features & NETIF_F_RXHASH)) { + e_err("Jumbo frames cannot be enabled when both receive checksum offload and receive hashing are enabled. Disable one of the receive offload features before enabling jumbos.\n"); + return -EINVAL; + } } /* Supported frame sizes */ @@ -5934,7 +5998,7 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) } static int e1000_set_features(struct net_device *netdev, - netdev_features_t features) + netdev_features_t features) { struct e1000_adapter *adapter = netdev_priv(netdev); netdev_features_t changed = features ^ netdev->features; @@ -5943,9 +6007,22 @@ static int e1000_set_features(struct net_device *netdev, adapter->flags |= FLAG_TSO_FORCE; if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | - NETIF_F_RXCSUM))) + NETIF_F_RXCSUM | NETIF_F_RXHASH))) return 0; + /* + * IP payload checksum (enabled with jumbos/packet-split when Rx + * checksum is enabled) and generation of RSS hash is mutually + * exclusive in the hardware. + */ + if (adapter->rx_ps_pages && + (features & NETIF_F_RXCSUM) && (features & NETIF_F_RXHASH)) { + e_err("Enabling both receive checksum offload and receive hashing is not possible with jumbo frames. Disable jumbos or enable only one of the receive offload features.\n"); + return -EINVAL; + } + + netdev->features = features; + if (netif_running(netdev)) e1000e_reinit_locked(adapter); else @@ -6136,6 +6213,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, NETIF_F_HW_VLAN_TX | NETIF_F_TSO | NETIF_F_TSO6 | + NETIF_F_RXHASH | NETIF_F_RXCSUM | NETIF_F_HW_CSUM); -- GitLab From 7ee913562fb7937595ba97f9b9adbf294b657d5b Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:45:35 +0000 Subject: [PATCH 0150/1846] e1000e: re-enable alternate MAC address for all devices which support it Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/lib.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/lib.c b/drivers/net/ethernet/intel/e1000e/lib.c index 0893ab107adf..78e3f4c0c367 100644 --- a/drivers/net/ethernet/intel/e1000e/lib.c +++ b/drivers/net/ethernet/intel/e1000e/lib.c @@ -187,11 +187,8 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) if (ret_val) goto out; - /* Check for LOM (vs. NIC) or one of two valid mezzanine cards */ - if (!((nvm_data & NVM_COMPAT_LOM) || - (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_DUAL) || - (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) || - (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES))) + /* not supported on older hardware or 82573 */ + if ((hw->mac.type < e1000_82571) || (hw->mac.type == e1000_82573)) goto out; ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, -- GitLab From c5083cf6d286e4d3485eaf7904e5d60a2d9df6f5 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:45:40 +0000 Subject: [PATCH 0151/1846] e1000e: convert head, tail and itr_register offsets to __iomem pointers The Tx/Rx head and tail registers and itr_register are always at known addresses based on the __iomem address at which the PCI region (from BAR 0) is mapped and known offsets within the region for each of these registers. Store and use the full address rather than just the region offset to reduce unnecessary address calculations. Also, change current u8 __iomem pointers to void __iomem pointers. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/e1000.h | 6 +-- drivers/net/ethernet/intel/e1000e/hw.h | 4 +- drivers/net/ethernet/intel/e1000e/netdev.c | 53 +++++++++++----------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index f478a22ed577..f6ac19751668 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -242,8 +242,8 @@ struct e1000_ring { u16 next_to_use; u16 next_to_clean; - u16 head; - u16 tail; + void __iomem *head; + void __iomem *tail; /* array of buffer information structs */ struct e1000_buffer *buffer_info; @@ -251,7 +251,7 @@ struct e1000_ring { char name[IFNAMSIZ + 5]; u32 ims_val; u32 itr_val; - u16 itr_register; + void __iomem *itr_register; int set_itr; struct sk_buff *rx_skb_top; diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h index 93c349ee5650..a15da4712f84 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -969,8 +969,8 @@ struct e1000_dev_spec_ich8lan { struct e1000_hw { struct e1000_adapter *adapter; - u8 __iomem *hw_addr; - u8 __iomem *flash_address; + void __iomem *hw_addr; + void __iomem *flash_address; struct e1000_mac_info mac; struct e1000_fc_info fc; diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index b196d79e108d..462bdeec90e4 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -550,7 +550,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, * which has bit 24 set while ME is accessing Host CSR registers, wait * if it is set and try again a number of times. **/ -static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, u8 __iomem * tail, +static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, void __iomem *tail, unsigned int i) { unsigned int j = 0; @@ -569,10 +569,9 @@ static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, u8 __iomem * tail, static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i) { - u8 __iomem *tail = (adapter->hw.hw_addr + adapter->rx_ring->tail); struct e1000_hw *hw = &adapter->hw; - if (e1000e_update_tail_wa(hw, tail, i)) { + if (e1000e_update_tail_wa(hw, adapter->rx_ring->tail, i)) { u32 rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); e_err("ME firmware caused invalid RDT - resetting\n"); @@ -582,10 +581,9 @@ static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i) static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i) { - u8 __iomem *tail = (adapter->hw.hw_addr + adapter->tx_ring->tail); struct e1000_hw *hw = &adapter->hw; - if (e1000e_update_tail_wa(hw, tail, i)) { + if (e1000e_update_tail_wa(hw, adapter->tx_ring->tail, i)) { u32 tctl = er32(TCTL); ew32(TCTL, tctl & ~E1000_TCTL_EN); e_err("ME firmware caused invalid TDT - resetting\n"); @@ -651,7 +649,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) e1000e_update_rdt_wa(adapter, i); else - writel(i, adapter->hw.hw_addr + rx_ring->tail); + writel(i, rx_ring->tail); } i++; if (i == rx_ring->count) @@ -754,8 +752,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) e1000e_update_rdt_wa(adapter, i << 1); else - writel(i << 1, - adapter->hw.hw_addr + rx_ring->tail); + writel(i << 1, rx_ring->tail); } i++; @@ -841,7 +838,7 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) e1000e_update_rdt_wa(adapter, i); else - writel(i, adapter->hw.hw_addr + rx_ring->tail); + writel(i, rx_ring->tail); } } @@ -1076,8 +1073,8 @@ static void e1000_print_hw_hang(struct work_struct *work) "PHY 1000BASE-T Status <%x>\n" "PHY Extended Status <%x>\n" "PCI Status <%x>\n", - readl(adapter->hw.hw_addr + tx_ring->head), - readl(adapter->hw.hw_addr + tx_ring->tail), + readl(tx_ring->head), + readl(tx_ring->tail), tx_ring->next_to_use, tx_ring->next_to_clean, tx_ring->buffer_info[eop].time_stamp, @@ -1617,8 +1614,8 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) rx_ring->next_to_use = 0; adapter->flags2 &= ~FLAG2_IS_DISCARDING; - writel(0, adapter->hw.hw_addr + rx_ring->head); - writel(0, adapter->hw.hw_addr + rx_ring->tail); + writel(0, rx_ring->head); + writel(0, rx_ring->tail); } static void e1000e_downshift_workaround(struct work_struct *work) @@ -1814,7 +1811,7 @@ static irqreturn_t e1000_intr_msix_rx(int irq, void *data) */ if (adapter->rx_ring->set_itr) { writel(1000000000 / (adapter->rx_ring->itr_val * 256), - adapter->hw.hw_addr + adapter->rx_ring->itr_register); + adapter->rx_ring->itr_register); adapter->rx_ring->set_itr = 0; } @@ -1855,9 +1852,9 @@ static void e1000_configure_msix(struct e1000_adapter *adapter) adapter->eiac_mask |= rx_ring->ims_val; if (rx_ring->itr_val) writel(1000000000 / (rx_ring->itr_val * 256), - hw->hw_addr + rx_ring->itr_register); + rx_ring->itr_register); else - writel(1, hw->hw_addr + rx_ring->itr_register); + writel(1, rx_ring->itr_register); ivar = E1000_IVAR_INT_ALLOC_VALID | vector; /* Configure Tx vector */ @@ -1865,9 +1862,9 @@ static void e1000_configure_msix(struct e1000_adapter *adapter) vector++; if (tx_ring->itr_val) writel(1000000000 / (tx_ring->itr_val * 256), - hw->hw_addr + tx_ring->itr_register); + tx_ring->itr_register); else - writel(1, hw->hw_addr + tx_ring->itr_register); + writel(1, tx_ring->itr_register); adapter->eiac_mask |= tx_ring->ims_val; ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8); @@ -1982,7 +1979,8 @@ static int e1000_request_msix(struct e1000_adapter *adapter) netdev); if (err) goto out; - adapter->rx_ring->itr_register = E1000_EITR_82574(vector); + adapter->rx_ring->itr_register = adapter->hw.hw_addr + + E1000_EITR_82574(vector); adapter->rx_ring->itr_val = adapter->itr; vector++; @@ -1997,7 +1995,8 @@ static int e1000_request_msix(struct e1000_adapter *adapter) netdev); if (err) goto out; - adapter->tx_ring->itr_register = E1000_EITR_82574(vector); + adapter->tx_ring->itr_register = adapter->hw.hw_addr + + E1000_EITR_82574(vector); adapter->tx_ring->itr_val = adapter->itr; vector++; @@ -2288,8 +2287,8 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter) tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; - writel(0, adapter->hw.hw_addr + tx_ring->head); - writel(0, adapter->hw.hw_addr + tx_ring->tail); + writel(0, tx_ring->head); + writel(0, tx_ring->tail); } /** @@ -2773,8 +2772,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) ew32(TDLEN, tdlen); ew32(TDH, 0); ew32(TDT, 0); - tx_ring->head = E1000_TDH; - tx_ring->tail = E1000_TDT; + tx_ring->head = adapter->hw.hw_addr + E1000_TDH; + tx_ring->tail = adapter->hw.hw_addr + E1000_TDT; /* Set the default values for the Tx Inter Packet Gap timer */ tipg = DEFAULT_82543_TIPG_IPGT_COPPER; /* 8 */ @@ -3088,8 +3087,8 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) ew32(RDLEN, rdlen); ew32(RDH, 0); ew32(RDT, 0); - rx_ring->head = E1000_RDH; - rx_ring->tail = E1000_RDT; + rx_ring->head = adapter->hw.hw_addr + E1000_RDH; + rx_ring->tail = adapter->hw.hw_addr + E1000_RDT; /* Enable Receive Checksum Offload for TCP and UDP */ rxcsum = er32(RXCSUM); @@ -4914,7 +4913,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter, if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) e1000e_update_tdt_wa(adapter, i); else - writel(i, adapter->hw.hw_addr + tx_ring->tail); + writel(i, tx_ring->tail); /* * we need this if more than one processor can write to our tail -- GitLab From 55aa69854a93d7aaf123a882b0b1f93c86cf3c7e Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:45:45 +0000 Subject: [PATCH 0152/1846] e1000e: pass pointer to ring struct instead of adapter struct For ring-specific functions, pass a pointer to the ring struct instead of a pointer to the adapter struct. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/e1000.h | 21 +- drivers/net/ethernet/intel/e1000e/ethtool.c | 10 +- drivers/net/ethernet/intel/e1000e/netdev.c | 232 ++++++++++---------- 3 files changed, 136 insertions(+), 127 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index f6ac19751668..db604cdd998c 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -234,6 +234,7 @@ struct e1000_buffer { }; struct e1000_ring { + struct e1000_adapter *adapter; /* back pointer to adapter */ void *desc; /* pointer to ring memory */ dma_addr_t dma; /* phys address of ring */ unsigned int size; /* length of ring in bytes */ @@ -334,11 +335,10 @@ struct e1000_adapter { /* * Rx */ - bool (*clean_rx) (struct e1000_adapter *adapter, - int *work_done, int work_to_do) - ____cacheline_aligned_in_smp; - void (*alloc_rx_buf) (struct e1000_adapter *adapter, - int cleaned_count, gfp_t gfp); + bool (*clean_rx) (struct e1000_ring *ring, int *work_done, + int work_to_do) ____cacheline_aligned_in_smp; + void (*alloc_rx_buf) (struct e1000_ring *ring, int cleaned_count, + gfp_t gfp); struct e1000_ring *rx_ring; u32 rx_int_delay; @@ -398,6 +398,9 @@ struct e1000_adapter { bool idle_check; int phy_hang_count; + + u16 tx_ring_count; + u16 rx_ring_count; }; struct e1000_info { @@ -492,10 +495,10 @@ extern void e1000e_down(struct e1000_adapter *adapter); extern void e1000e_reinit_locked(struct e1000_adapter *adapter); extern void e1000e_reset(struct e1000_adapter *adapter); extern void e1000e_power_up_phy(struct e1000_adapter *adapter); -extern int e1000e_setup_rx_resources(struct e1000_adapter *adapter); -extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter); -extern void e1000e_free_rx_resources(struct e1000_adapter *adapter); -extern void e1000e_free_tx_resources(struct e1000_adapter *adapter); +extern int e1000e_setup_rx_resources(struct e1000_ring *ring); +extern int e1000e_setup_tx_resources(struct e1000_ring *ring); +extern void e1000e_free_rx_resources(struct e1000_ring *ring); +extern void e1000e_free_tx_resources(struct e1000_ring *ring); extern struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats); diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index 0a3137a791e9..01c73aee7fdb 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -656,10 +656,10 @@ static int e1000_set_ringparam(struct net_device *netdev, if (netif_running(adapter->netdev)) { /* Try to get new resources before deleting old */ - err = e1000e_setup_rx_resources(adapter); + err = e1000e_setup_rx_resources(rx_ring); if (err) goto err_setup_rx; - err = e1000e_setup_tx_resources(adapter); + err = e1000e_setup_tx_resources(tx_ring); if (err) goto err_setup_tx; @@ -669,8 +669,8 @@ static int e1000_set_ringparam(struct net_device *netdev, */ adapter->rx_ring = rx_old; adapter->tx_ring = tx_old; - e1000e_free_rx_resources(adapter); - e1000e_free_tx_resources(adapter); + e1000e_free_rx_resources(adapter->rx_ring); + e1000e_free_tx_resources(adapter->tx_ring); kfree(tx_old); kfree(rx_old); adapter->rx_ring = rx_ring; @@ -683,7 +683,7 @@ static int e1000_set_ringparam(struct net_device *netdev, clear_bit(__E1000_RESETTING, &adapter->state); return 0; err_setup_tx: - e1000e_free_rx_resources(adapter); + e1000e_free_rx_resources(rx_ring); err_setup_rx: adapter->rx_ring = rx_old; adapter->tx_ring = tx_old; diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 462bdeec90e4..ffe4583994d8 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -567,11 +567,12 @@ static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, void __iomem *tail, return 0; } -static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i) +static void e1000e_update_rdt_wa(struct e1000_ring *rx_ring, unsigned int i) { + struct e1000_adapter *adapter = rx_ring->adapter; struct e1000_hw *hw = &adapter->hw; - if (e1000e_update_tail_wa(hw, adapter->rx_ring->tail, i)) { + if (e1000e_update_tail_wa(hw, rx_ring->tail, i)) { u32 rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); e_err("ME firmware caused invalid RDT - resetting\n"); @@ -579,11 +580,12 @@ static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i) } } -static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i) +static void e1000e_update_tdt_wa(struct e1000_ring *tx_ring, unsigned int i) { + struct e1000_adapter *adapter = tx_ring->adapter; struct e1000_hw *hw = &adapter->hw; - if (e1000e_update_tail_wa(hw, adapter->tx_ring->tail, i)) { + if (e1000e_update_tail_wa(hw, tx_ring->tail, i)) { u32 tctl = er32(TCTL); ew32(TCTL, tctl & ~E1000_TCTL_EN); e_err("ME firmware caused invalid TDT - resetting\n"); @@ -593,14 +595,14 @@ static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i) /** * e1000_alloc_rx_buffers - Replace used receive buffers - * @adapter: address of board private structure + * @rx_ring: Rx descriptor ring **/ -static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, +static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring, int cleaned_count, gfp_t gfp) { + struct e1000_adapter *adapter = rx_ring->adapter; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *rx_ring = adapter->rx_ring; union e1000_rx_desc_extended *rx_desc; struct e1000_buffer *buffer_info; struct sk_buff *skb; @@ -647,7 +649,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, */ wmb(); if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) - e1000e_update_rdt_wa(adapter, i); + e1000e_update_rdt_wa(rx_ring, i); else writel(i, rx_ring->tail); } @@ -662,15 +664,15 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, /** * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split - * @adapter: address of board private structure + * @rx_ring: Rx descriptor ring **/ -static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, +static void e1000_alloc_rx_buffers_ps(struct e1000_ring *rx_ring, int cleaned_count, gfp_t gfp) { + struct e1000_adapter *adapter = rx_ring->adapter; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; union e1000_rx_desc_packet_split *rx_desc; - struct e1000_ring *rx_ring = adapter->rx_ring; struct e1000_buffer *buffer_info; struct e1000_ps_page *ps_page; struct sk_buff *skb; @@ -750,7 +752,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, */ wmb(); if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) - e1000e_update_rdt_wa(adapter, i << 1); + e1000e_update_rdt_wa(rx_ring, i << 1); else writel(i << 1, rx_ring->tail); } @@ -767,17 +769,17 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, /** * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers - * @adapter: address of board private structure + * @rx_ring: Rx descriptor ring * @cleaned_count: number of buffers to allocate this pass **/ -static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, +static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring, int cleaned_count, gfp_t gfp) { + struct e1000_adapter *adapter = rx_ring->adapter; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; union e1000_rx_desc_extended *rx_desc; - struct e1000_ring *rx_ring = adapter->rx_ring; struct e1000_buffer *buffer_info; struct sk_buff *skb; unsigned int i; @@ -836,7 +838,7 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, * such as IA-64). */ wmb(); if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) - e1000e_update_rdt_wa(adapter, i); + e1000e_update_rdt_wa(rx_ring, i); else writel(i, rx_ring->tail); } @@ -850,19 +852,19 @@ static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss, } /** - * e1000_clean_rx_irq - Send received data up the network stack; legacy - * @adapter: board private structure + * e1000_clean_rx_irq - Send received data up the network stack + * @rx_ring: Rx descriptor ring * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ -static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, - int *work_done, int work_to_do) +static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done, + int work_to_do) { + struct e1000_adapter *adapter = rx_ring->adapter; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; struct e1000_hw *hw = &adapter->hw; - struct e1000_ring *rx_ring = adapter->rx_ring; union e1000_rx_desc_extended *rx_desc, *next_rxd; struct e1000_buffer *buffer_info, *next_buffer; u32 length, staterr; @@ -978,7 +980,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, /* return some buffers to hardware, one at a time is too slow */ if (cleaned_count >= E1000_RX_BUFFER_WRITE) { - adapter->alloc_rx_buf(adapter, cleaned_count, + adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC); cleaned_count = 0; } @@ -993,16 +995,18 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, cleaned_count = e1000_desc_unused(rx_ring); if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); + adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC); adapter->total_rx_bytes += total_rx_bytes; adapter->total_rx_packets += total_rx_packets; return cleaned; } -static void e1000_put_txbuf(struct e1000_adapter *adapter, - struct e1000_buffer *buffer_info) +static void e1000_put_txbuf(struct e1000_ring *tx_ring, + struct e1000_buffer *buffer_info) { + struct e1000_adapter *adapter = tx_ring->adapter; + if (buffer_info->dma) { if (buffer_info->mapped_as_page) dma_unmap_page(&adapter->pdev->dev, buffer_info->dma, @@ -1090,16 +1094,16 @@ static void e1000_print_hw_hang(struct work_struct *work) /** * e1000_clean_tx_irq - Reclaim resources after transmit completes - * @adapter: board private structure + * @tx_ring: Tx descriptor ring * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ -static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) +static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring) { + struct e1000_adapter *adapter = tx_ring->adapter; struct net_device *netdev = adapter->netdev; struct e1000_hw *hw = &adapter->hw; - struct e1000_ring *tx_ring = adapter->tx_ring; struct e1000_tx_desc *tx_desc, *eop_desc; struct e1000_buffer *buffer_info; unsigned int i, eop; @@ -1129,7 +1133,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) } } - e1000_put_txbuf(adapter, buffer_info); + e1000_put_txbuf(tx_ring, buffer_info); tx_desc->upper.data = 0; i++; @@ -1183,19 +1187,19 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) /** * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split - * @adapter: board private structure + * @rx_ring: Rx descriptor ring * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ -static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, - int *work_done, int work_to_do) +static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done, + int work_to_do) { + struct e1000_adapter *adapter = rx_ring->adapter; struct e1000_hw *hw = &adapter->hw; union e1000_rx_desc_packet_split *rx_desc, *next_rxd; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *rx_ring = adapter->rx_ring; struct e1000_buffer *buffer_info, *next_buffer; struct e1000_ps_page *ps_page; struct sk_buff *skb; @@ -1346,7 +1350,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, /* return some buffers to hardware, one at a time is too slow */ if (cleaned_count >= E1000_RX_BUFFER_WRITE) { - adapter->alloc_rx_buf(adapter, cleaned_count, + adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC); cleaned_count = 0; } @@ -1361,7 +1365,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, cleaned_count = e1000_desc_unused(rx_ring); if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); + adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC); adapter->total_rx_bytes += total_rx_bytes; adapter->total_rx_packets += total_rx_packets; @@ -1387,13 +1391,12 @@ static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ - -static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, - int *work_done, int work_to_do) +static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done, + int work_to_do) { + struct e1000_adapter *adapter = rx_ring->adapter; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *rx_ring = adapter->rx_ring; union e1000_rx_desc_extended *rx_desc, *next_rxd; struct e1000_buffer *buffer_info, *next_buffer; u32 length, staterr; @@ -1526,7 +1529,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, /* return some buffers to hardware, one at a time is too slow */ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) { - adapter->alloc_rx_buf(adapter, cleaned_count, + adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC); cleaned_count = 0; } @@ -1541,7 +1544,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, cleaned_count = e1000_desc_unused(rx_ring); if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); + adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC); adapter->total_rx_bytes += total_rx_bytes; adapter->total_rx_packets += total_rx_packets; @@ -1550,11 +1553,11 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, /** * e1000_clean_rx_ring - Free Rx Buffers per Queue - * @adapter: board private structure + * @rx_ring: Rx descriptor ring **/ -static void e1000_clean_rx_ring(struct e1000_adapter *adapter) +static void e1000_clean_rx_ring(struct e1000_ring *rx_ring) { - struct e1000_ring *rx_ring = adapter->rx_ring; + struct e1000_adapter *adapter = rx_ring->adapter; struct e1000_buffer *buffer_info; struct e1000_ps_page *ps_page; struct pci_dev *pdev = adapter->pdev; @@ -1794,7 +1797,7 @@ static irqreturn_t e1000_intr_msix_tx(int irq, void *data) adapter->total_tx_bytes = 0; adapter->total_tx_packets = 0; - if (!e1000_clean_tx_irq(adapter)) + if (!e1000_clean_tx_irq(tx_ring)) /* Ring was not completely cleaned, so fire another interrupt */ ew32(ICS, tx_ring->ims_val); @@ -1805,14 +1808,15 @@ static irqreturn_t e1000_intr_msix_rx(int irq, void *data) { struct net_device *netdev = data; struct e1000_adapter *adapter = netdev_priv(netdev); + struct e1000_ring *rx_ring = adapter->rx_ring; /* Write the ITR value calculated at the end of the * previous interrupt. */ - if (adapter->rx_ring->set_itr) { - writel(1000000000 / (adapter->rx_ring->itr_val * 256), - adapter->rx_ring->itr_register); - adapter->rx_ring->set_itr = 0; + if (rx_ring->set_itr) { + writel(1000000000 / (rx_ring->itr_val * 256), + rx_ring->itr_register); + rx_ring->set_itr = 0; } if (napi_schedule_prep(&adapter->napi)) { @@ -2177,13 +2181,13 @@ static int e1000_alloc_ring_dma(struct e1000_adapter *adapter, /** * e1000e_setup_tx_resources - allocate Tx resources (Descriptors) - * @adapter: board private structure + * @tx_ring: Tx descriptor ring * * Return 0 on success, negative on failure **/ -int e1000e_setup_tx_resources(struct e1000_adapter *adapter) +int e1000e_setup_tx_resources(struct e1000_ring *tx_ring) { - struct e1000_ring *tx_ring = adapter->tx_ring; + struct e1000_adapter *adapter = tx_ring->adapter; int err = -ENOMEM, size; size = sizeof(struct e1000_buffer) * tx_ring->count; @@ -2211,13 +2215,13 @@ int e1000e_setup_tx_resources(struct e1000_adapter *adapter) /** * e1000e_setup_rx_resources - allocate Rx resources (Descriptors) - * @adapter: board private structure + * @rx_ring: Rx descriptor ring * * Returns 0 on success, negative on failure **/ -int e1000e_setup_rx_resources(struct e1000_adapter *adapter) +int e1000e_setup_rx_resources(struct e1000_ring *rx_ring) { - struct e1000_ring *rx_ring = adapter->rx_ring; + struct e1000_adapter *adapter = rx_ring->adapter; struct e1000_buffer *buffer_info; int i, size, desc_len, err = -ENOMEM; @@ -2264,18 +2268,18 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) /** * e1000_clean_tx_ring - Free Tx Buffers - * @adapter: board private structure + * @tx_ring: Tx descriptor ring **/ -static void e1000_clean_tx_ring(struct e1000_adapter *adapter) +static void e1000_clean_tx_ring(struct e1000_ring *tx_ring) { - struct e1000_ring *tx_ring = adapter->tx_ring; + struct e1000_adapter *adapter = tx_ring->adapter; struct e1000_buffer *buffer_info; unsigned long size; unsigned int i; for (i = 0; i < tx_ring->count; i++) { buffer_info = &tx_ring->buffer_info[i]; - e1000_put_txbuf(adapter, buffer_info); + e1000_put_txbuf(tx_ring, buffer_info); } netdev_reset_queue(adapter->netdev); @@ -2293,16 +2297,16 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter) /** * e1000e_free_tx_resources - Free Tx Resources per Queue - * @adapter: board private structure + * @tx_ring: Tx descriptor ring * * Free all transmit software resources **/ -void e1000e_free_tx_resources(struct e1000_adapter *adapter) +void e1000e_free_tx_resources(struct e1000_ring *tx_ring) { + struct e1000_adapter *adapter = tx_ring->adapter; struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *tx_ring = adapter->tx_ring; - e1000_clean_tx_ring(adapter); + e1000_clean_tx_ring(tx_ring); vfree(tx_ring->buffer_info); tx_ring->buffer_info = NULL; @@ -2314,18 +2318,17 @@ void e1000e_free_tx_resources(struct e1000_adapter *adapter) /** * e1000e_free_rx_resources - Free Rx Resources - * @adapter: board private structure + * @rx_ring: Rx descriptor ring * * Free all receive software resources **/ - -void e1000e_free_rx_resources(struct e1000_adapter *adapter) +void e1000e_free_rx_resources(struct e1000_ring *rx_ring) { + struct e1000_adapter *adapter = rx_ring->adapter; struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *rx_ring = adapter->rx_ring; int i; - e1000_clean_rx_ring(adapter); + e1000_clean_rx_ring(rx_ring); for (i = 0; i < rx_ring->count; i++) kfree(rx_ring->buffer_info[i].ps_pages); @@ -2479,13 +2482,19 @@ static void e1000_set_itr(struct e1000_adapter *adapter) **/ static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter) { - adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); + int size = sizeof(struct e1000_ring); + + adapter->tx_ring = kzalloc(size, GFP_KERNEL); if (!adapter->tx_ring) goto err; + adapter->tx_ring->count = adapter->tx_ring_count; + adapter->tx_ring->adapter = adapter; - adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); + adapter->rx_ring = kzalloc(size, GFP_KERNEL); if (!adapter->rx_ring) goto err; + adapter->rx_ring->count = adapter->rx_ring_count; + adapter->rx_ring->adapter = adapter; return 0; err: @@ -2513,10 +2522,10 @@ static int e1000_clean(struct napi_struct *napi, int budget) !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val)) goto clean_rx; - tx_cleaned = e1000_clean_tx_irq(adapter); + tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring); clean_rx: - adapter->clean_rx(adapter, &work_done, budget); + adapter->clean_rx(adapter->rx_ring, &work_done, budget); if (!tx_cleaned) work_done = budget; @@ -3325,6 +3334,8 @@ static void e1000e_setup_rss_hash(struct e1000_adapter *adapter) **/ static void e1000_configure(struct e1000_adapter *adapter) { + struct e1000_ring *rx_ring = adapter->rx_ring; + e1000e_set_rx_mode(adapter->netdev); e1000_restore_vlan(adapter); @@ -3336,8 +3347,7 @@ static void e1000_configure(struct e1000_adapter *adapter) e1000e_setup_rss_hash(adapter); e1000_setup_rctl(adapter); e1000_configure_rx(adapter); - adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring), - GFP_KERNEL); + adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL); } /** @@ -3647,8 +3657,8 @@ void e1000e_down(struct e1000_adapter *adapter) spin_unlock(&adapter->stats64_lock); e1000e_flush_descriptors(adapter); - e1000_clean_tx_ring(adapter); - e1000_clean_rx_ring(adapter); + e1000_clean_tx_ring(adapter->tx_ring); + e1000_clean_rx_ring(adapter->rx_ring); adapter->link_speed = 0; adapter->link_duplex = 0; @@ -3688,6 +3698,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter) adapter->rx_ps_bsize0 = 128; adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; + adapter->tx_ring_count = E1000_DEFAULT_TXD; + adapter->rx_ring_count = E1000_DEFAULT_RXD; spin_lock_init(&adapter->stats64_lock); @@ -3846,12 +3858,12 @@ static int e1000_open(struct net_device *netdev) netif_carrier_off(netdev); /* allocate transmit descriptors */ - err = e1000e_setup_tx_resources(adapter); + err = e1000e_setup_tx_resources(adapter->tx_ring); if (err) goto err_setup_tx; /* allocate receive descriptors */ - err = e1000e_setup_rx_resources(adapter); + err = e1000e_setup_rx_resources(adapter->rx_ring); if (err) goto err_setup_rx; @@ -3927,9 +3939,9 @@ static int e1000_open(struct net_device *netdev) err_req_irq: e1000e_release_hw_control(adapter); e1000_power_down_phy(adapter); - e1000e_free_rx_resources(adapter); + e1000e_free_rx_resources(adapter->rx_ring); err_setup_rx: - e1000e_free_tx_resources(adapter); + e1000e_free_tx_resources(adapter->tx_ring); err_setup_tx: e1000e_reset(adapter); pm_runtime_put_sync(&pdev->dev); @@ -3965,8 +3977,8 @@ static int e1000_close(struct net_device *netdev) } e1000_power_down_phy(adapter); - e1000e_free_tx_resources(adapter); - e1000e_free_rx_resources(adapter); + e1000e_free_tx_resources(adapter->tx_ring); + e1000e_free_rx_resources(adapter->rx_ring); /* * kill manageability vlan ID if supported, but not if a vlan with @@ -4623,10 +4635,8 @@ static void e1000_watchdog_task(struct work_struct *work) #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 #define E1000_TX_FLAGS_VLAN_SHIFT 16 -static int e1000_tso(struct e1000_adapter *adapter, - struct sk_buff *skb) +static int e1000_tso(struct e1000_ring *tx_ring, struct sk_buff *skb) { - struct e1000_ring *tx_ring = adapter->tx_ring; struct e1000_context_desc *context_desc; struct e1000_buffer *buffer_info; unsigned int i; @@ -4695,9 +4705,9 @@ static int e1000_tso(struct e1000_adapter *adapter, return 1; } -static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb) +static bool e1000_tx_csum(struct e1000_ring *tx_ring, struct sk_buff *skb) { - struct e1000_ring *tx_ring = adapter->tx_ring; + struct e1000_adapter *adapter = tx_ring->adapter; struct e1000_context_desc *context_desc; struct e1000_buffer *buffer_info; unsigned int i; @@ -4758,12 +4768,11 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb) #define E1000_MAX_PER_TXD 8192 #define E1000_MAX_TXD_PWR 12 -static int e1000_tx_map(struct e1000_adapter *adapter, - struct sk_buff *skb, unsigned int first, - unsigned int max_per_txd, unsigned int nr_frags, - unsigned int mss) +static int e1000_tx_map(struct e1000_ring *tx_ring, struct sk_buff *skb, + unsigned int first, unsigned int max_per_txd, + unsigned int nr_frags, unsigned int mss) { - struct e1000_ring *tx_ring = adapter->tx_ring; + struct e1000_adapter *adapter = tx_ring->adapter; struct pci_dev *pdev = adapter->pdev; struct e1000_buffer *buffer_info; unsigned int len = skb_headlen(skb); @@ -4849,16 +4858,15 @@ static int e1000_tx_map(struct e1000_adapter *adapter, i += tx_ring->count; i--; buffer_info = &tx_ring->buffer_info[i]; - e1000_put_txbuf(adapter, buffer_info); + e1000_put_txbuf(tx_ring, buffer_info); } return 0; } -static void e1000_tx_queue(struct e1000_adapter *adapter, - int tx_flags, int count) +static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count) { - struct e1000_ring *tx_ring = adapter->tx_ring; + struct e1000_adapter *adapter = tx_ring->adapter; struct e1000_tx_desc *tx_desc = NULL; struct e1000_buffer *buffer_info; u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS; @@ -4911,7 +4919,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter, tx_ring->next_to_use = i; if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) - e1000e_update_tdt_wa(adapter, i); + e1000e_update_tdt_wa(tx_ring, i); else writel(i, tx_ring->tail); @@ -4961,11 +4969,11 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter, return 0; } -static int __e1000_maybe_stop_tx(struct net_device *netdev, int size) +static int __e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size) { - struct e1000_adapter *adapter = netdev_priv(netdev); + struct e1000_adapter *adapter = tx_ring->adapter; - netif_stop_queue(netdev); + netif_stop_queue(adapter->netdev); /* * Herbert's original patch had: * smp_mb__after_netif_stop_queue(); @@ -4977,22 +4985,20 @@ static int __e1000_maybe_stop_tx(struct net_device *netdev, int size) * We need to check again in a case another CPU has just * made room available. */ - if (e1000_desc_unused(adapter->tx_ring) < size) + if (e1000_desc_unused(tx_ring) < size) return -EBUSY; /* A reprieve! */ - netif_start_queue(netdev); + netif_start_queue(adapter->netdev); ++adapter->restart_queue; return 0; } -static int e1000_maybe_stop_tx(struct net_device *netdev, int size) +static int e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size) { - struct e1000_adapter *adapter = netdev_priv(netdev); - - if (e1000_desc_unused(adapter->tx_ring) >= size) + if (e1000_desc_unused(tx_ring) >= size) return 0; - return __e1000_maybe_stop_tx(netdev, size); + return __e1000_maybe_stop_tx(tx_ring, size); } #define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) @@ -5078,7 +5084,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, * need: count + 2 desc gap to keep tail from touching * head, otherwise try next time */ - if (e1000_maybe_stop_tx(netdev, count + 2)) + if (e1000_maybe_stop_tx(tx_ring, count + 2)) return NETDEV_TX_BUSY; if (vlan_tx_tag_present(skb)) { @@ -5088,7 +5094,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, first = tx_ring->next_to_use; - tso = e1000_tso(adapter, skb); + tso = e1000_tso(tx_ring, skb); if (tso < 0) { dev_kfree_skb_any(skb); return NETDEV_TX_OK; @@ -5096,7 +5102,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, if (tso) tx_flags |= E1000_TX_FLAGS_TSO; - else if (e1000_tx_csum(adapter, skb)) + else if (e1000_tx_csum(tx_ring, skb)) tx_flags |= E1000_TX_FLAGS_CSUM; /* @@ -5108,12 +5114,12 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, tx_flags |= E1000_TX_FLAGS_IPV4; /* if count is 0 then mapping error has occurred */ - count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss); + count = e1000_tx_map(tx_ring, skb, first, max_per_txd, nr_frags, mss); if (count) { netdev_sent_queue(netdev, skb->len); - e1000_tx_queue(adapter, tx_flags, count); + e1000_tx_queue(tx_ring, tx_flags, count); /* Make sure there is space in the ring for the next send. */ - e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2); + e1000_maybe_stop_tx(tx_ring, MAX_SKB_FRAGS + 2); } else { dev_kfree_skb_any(skb); -- GitLab From 508da4264add2eb13bd4d32bb896e79e6f8821fc Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:45:51 +0000 Subject: [PATCH 0153/1846] e1000e: re-factor ethtool get/set ring parameter Make it more like how igb does it, with some additional error checking. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ethtool.c | 136 +++++++++++--------- 1 file changed, 77 insertions(+), 59 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index 01c73aee7fdb..ffb6c14cbbb8 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -605,94 +605,112 @@ static void e1000_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) { struct e1000_adapter *adapter = netdev_priv(netdev); - struct e1000_ring *tx_ring = adapter->tx_ring; - struct e1000_ring *rx_ring = adapter->rx_ring; ring->rx_max_pending = E1000_MAX_RXD; ring->tx_max_pending = E1000_MAX_TXD; - ring->rx_pending = rx_ring->count; - ring->tx_pending = tx_ring->count; + ring->rx_pending = adapter->rx_ring_count; + ring->tx_pending = adapter->tx_ring_count; } static int e1000_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) { struct e1000_adapter *adapter = netdev_priv(netdev); - struct e1000_ring *tx_ring, *tx_old; - struct e1000_ring *rx_ring, *rx_old; - int err; + struct e1000_ring *temp_tx = NULL, *temp_rx = NULL; + int err = 0, size = sizeof(struct e1000_ring); + bool set_tx = false, set_rx = false; + u16 new_rx_count, new_tx_count; if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) return -EINVAL; - while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) - usleep_range(1000, 2000); + new_rx_count = clamp_t(u32, ring->rx_pending, E1000_MIN_RXD, + E1000_MAX_RXD); + new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE); - if (netif_running(adapter->netdev)) - e1000e_down(adapter); + new_tx_count = clamp_t(u32, ring->tx_pending, E1000_MIN_TXD, + E1000_MAX_TXD); + new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE); - tx_old = adapter->tx_ring; - rx_old = adapter->rx_ring; + if ((new_tx_count == adapter->tx_ring_count) && + (new_rx_count == adapter->rx_ring_count)) + /* nothing to do */ + return 0; - err = -ENOMEM; - tx_ring = kmemdup(tx_old, sizeof(struct e1000_ring), GFP_KERNEL); - if (!tx_ring) - goto err_alloc_tx; + while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) + usleep_range(1000, 2000); - rx_ring = kmemdup(rx_old, sizeof(struct e1000_ring), GFP_KERNEL); - if (!rx_ring) - goto err_alloc_rx; + if (!netif_running(adapter->netdev)) { + /* Set counts now and allocate resources during open() */ + adapter->tx_ring->count = new_tx_count; + adapter->rx_ring->count = new_rx_count; + adapter->tx_ring_count = new_tx_count; + adapter->rx_ring_count = new_rx_count; + goto clear_reset; + } - adapter->tx_ring = tx_ring; - adapter->rx_ring = rx_ring; + set_tx = (new_tx_count != adapter->tx_ring_count); + set_rx = (new_rx_count != adapter->rx_ring_count); - rx_ring->count = max(ring->rx_pending, (u32)E1000_MIN_RXD); - rx_ring->count = min(rx_ring->count, (u32)(E1000_MAX_RXD)); - rx_ring->count = ALIGN(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE); + /* Allocate temporary storage for ring updates */ + if (set_tx) { + temp_tx = vmalloc(size); + if (!temp_tx) { + err = -ENOMEM; + goto free_temp; + } + } + if (set_rx) { + temp_rx = vmalloc(size); + if (!temp_rx) { + err = -ENOMEM; + goto free_temp; + } + } - tx_ring->count = max(ring->tx_pending, (u32)E1000_MIN_TXD); - tx_ring->count = min(tx_ring->count, (u32)(E1000_MAX_TXD)); - tx_ring->count = ALIGN(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE); + e1000e_down(adapter); - if (netif_running(adapter->netdev)) { - /* Try to get new resources before deleting old */ - err = e1000e_setup_rx_resources(rx_ring); + /* + * We can't just free everything and then setup again, because the + * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring + * structs. First, attempt to allocate new resources... + */ + if (set_tx) { + memcpy(temp_tx, adapter->tx_ring, size); + temp_tx->count = new_tx_count; + err = e1000e_setup_tx_resources(temp_tx); if (err) - goto err_setup_rx; - err = e1000e_setup_tx_resources(tx_ring); + goto err_setup; + } + if (set_rx) { + memcpy(temp_rx, adapter->rx_ring, size); + temp_rx->count = new_rx_count; + err = e1000e_setup_rx_resources(temp_rx); if (err) - goto err_setup_tx; + goto err_setup_rx; + } - /* - * restore the old in order to free it, - * then add in the new - */ - adapter->rx_ring = rx_old; - adapter->tx_ring = tx_old; - e1000e_free_rx_resources(adapter->rx_ring); + /* ...then free the old resources and copy back any new ring data */ + if (set_tx) { e1000e_free_tx_resources(adapter->tx_ring); - kfree(tx_old); - kfree(rx_old); - adapter->rx_ring = rx_ring; - adapter->tx_ring = tx_ring; - err = e1000e_up(adapter); - if (err) - goto err_setup; + memcpy(adapter->tx_ring, temp_tx, size); + adapter->tx_ring_count = new_tx_count; + } + if (set_rx) { + e1000e_free_rx_resources(adapter->rx_ring); + memcpy(adapter->rx_ring, temp_rx, size); + adapter->rx_ring_count = new_rx_count; } - clear_bit(__E1000_RESETTING, &adapter->state); - return 0; -err_setup_tx: - e1000e_free_rx_resources(rx_ring); err_setup_rx: - adapter->rx_ring = rx_old; - adapter->tx_ring = tx_old; - kfree(rx_ring); -err_alloc_rx: - kfree(tx_ring); -err_alloc_tx: - e1000e_up(adapter); + if (err && set_tx) + e1000e_free_tx_resources(temp_tx); err_setup: + e1000e_up(adapter); +free_temp: + vfree(temp_tx); + vfree(temp_rx); +clear_reset: clear_bit(__E1000_RESETTING, &adapter->state); return err; } -- GitLab From b6fbca2af36530ef307069cff0fe3b1f387c00a9 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:45:56 +0000 Subject: [PATCH 0154/1846] e1000e: default IntMode based on kernel config & available hardware support Based on a patch from Prabhakar Kushwaha , set appropriate default interrupt mode dependent on whether CONFIG_PCI_MSI is enabled in the kernel configuration and if the hardware supports MSI-X. Set the module parameter log message accordingly. Signed-off-by: Bruce Allan Cc: Jin Qing Cc: Prabhakar Kushwaha Cc: Jin Qing Cc: Kumar Gala Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/param.c | 48 +++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c index 20e93b08e7f3..40664f5bfbda 100644 --- a/drivers/net/ethernet/intel/e1000e/param.c +++ b/drivers/net/ethernet/intel/e1000e/param.c @@ -113,11 +113,20 @@ E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); #define MAX_ITR 100000 #define MIN_ITR 100 -/* IntMode (Interrupt Mode) +/* + * IntMode (Interrupt Mode) + * + * Valid Range: varies depending on kernel configuration & hardware support + * + * legacy=0, MSI=1, MSI-X=2 * - * Valid Range: 0 - 2 + * When MSI/MSI-X support is enabled in kernel- + * Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise + * When MSI/MSI-X support is not enabled in kernel- + * Default Value: 0 (legacy) * - * Default Value: 2 (MSI-X) + * When a mode is specified that is not allowed/supported, it will be + * demoted to the most advanced interrupt mode available. */ E1000_PARAM(IntMode, "Interrupt Mode"); #define MAX_INTMODE 2 @@ -388,12 +397,33 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) static struct e1000_option opt = { .type = range_option, .name = "Interrupt Mode", - .err = "defaulting to 2 (MSI-X)", - .def = E1000E_INT_MODE_MSIX, - .arg = { .r = { .min = MIN_INTMODE, - .max = MAX_INTMODE } } +#ifndef CONFIG_PCI_MSI + .err = "defaulting to 0 (legacy)", + .def = E1000E_INT_MODE_LEGACY, + .arg = { .r = { .min = 0, + .max = 0 } } +#endif }; +#ifdef CONFIG_PCI_MSI + if (adapter->flags & FLAG_HAS_MSIX) { + opt.err = kstrdup("defaulting to 2 (MSI-X)", + GFP_KERNEL); + opt.def = E1000E_INT_MODE_MSIX; + opt.arg.r.max = E1000E_INT_MODE_MSIX; + } else { + opt.err = kstrdup("defaulting to 1 (MSI)", GFP_KERNEL); + opt.def = E1000E_INT_MODE_MSI; + opt.arg.r.max = E1000E_INT_MODE_MSI; + } + + if (!opt.err) { + dev_err(&adapter->pdev->dev, + "Failed to allocate memory\n"); + return; + } +#endif + if (num_IntMode > bd) { unsigned int int_mode = IntMode[bd]; e1000_validate_option(&int_mode, &opt, adapter); @@ -401,6 +431,10 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } else { adapter->int_mode = opt.def; } + +#ifdef CONFIG_PCI_MSI + kfree(opt.err); +#endif } { /* Smart Power Down */ static const struct e1000_option opt = { -- GitLab From 56032be77c7eab50e2020247ffa35ca61850503f Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:01 +0000 Subject: [PATCH 0155/1846] e1000e: always set transmit descriptor control registers the same The hardware erratum workaround where the TXDCTL register must be the same setting for both queues should always be done. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index ffe4583994d8..6081dee5ce46 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -2817,9 +2817,9 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) */ txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE; ew32(TXDCTL(0), txdctl); - /* erratum work around: set txdctl the same for both queues */ - ew32(TXDCTL(1), txdctl); } + /* erratum work around: set txdctl the same for both queues */ + ew32(TXDCTL(1), er32(TXDCTL(0))); /* Program the Transmit Control Register */ tctl = er32(TCTL); -- GitLab From 4d24136c8ea03ecfdb6b8256571da8b520b92d8b Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:06 +0000 Subject: [PATCH 0156/1846] e1000e: 82579: workaround for link drop issue When connected to certain switches, the 82579 PHY might drop link unexpectedly. Work around the issue by setting the Mean Square Error higher than the hardware default. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index e2a80a283fd3..1b69c2d6b417 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -145,6 +145,8 @@ #define I82579_EMI_ADDR 0x10 #define I82579_EMI_DATA 0x11 #define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */ +#define I82579_MSE_THRESHOLD 0x084F /* Mean Square Error Threshold */ +#define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */ /* Strapping Option Register - RO */ #define E1000_STRAP 0x0000C @@ -1669,6 +1671,26 @@ static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw) /* Set MDIO slow mode before any other MDIO access */ ret_val = e1000_set_mdio_slow_mode_hv(hw); + ret_val = hw->phy.ops.acquire(hw); + if (ret_val) + goto out; + ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, + I82579_MSE_THRESHOLD); + if (ret_val) + goto release; + /* set MSE higher to enable link to stay up when noise is high */ + ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0034); + if (ret_val) + goto release; + ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, + I82579_MSE_LINK_DOWN); + if (ret_val) + goto release; + /* drop link after 5 times MSE threshold was reached */ + ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0005); +release: + hw->phy.ops.release(hw); + out: return ret_val; } -- GitLab From 6a92f732f557401ca8cc0b16f8e8914c133cf6c6 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:12 +0000 Subject: [PATCH 0157/1846] e1000e: use default settings for Tx Inter Packet Gap timer Use the default hardware values for TIPG except for 80003es2lan(*). The code that is removed in this patch is either unnecessarily writing the TIPG register with the hardware default values for some devices (82571/2/3/4) or writing the wrong value for others (ICH/PCH LOMs). The only change in functionality is setting the correct default TIPG for the latter devices. (*) The correct value for 80003es2lan is already set properly in e1000_init_hw_80003es2lan() and e1000_cfg_kmrn_{10_100|1000}_80003es2lan(), and the unused flag FLAG_TIPG_MEDIUM_FOR_80003ESLAN is removed. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 3 +-- drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/netdev.c | 15 +-------------- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index e1159e54334a..b3a235c8ed85 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1502,8 +1502,7 @@ const struct e1000_info e1000_es2_info = { | FLAG_RX_NEEDS_RESTART /* errata */ | FLAG_TARC_SET_BIT_ZERO /* errata */ | FLAG_APME_CHECK_PORT_B - | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ - | FLAG_TIPG_MEDIUM_FOR_80003ESLAN, + | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */ .flags2 = FLAG2_DMA_BURST, .pba = 38, .max_hw_frame_size = DEFAULT_JUMBO, diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index db604cdd998c..4b3a27670a6b 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -430,7 +430,7 @@ struct e1000_info { #define FLAG_HAS_SMART_POWER_DOWN (1 << 11) #define FLAG_IS_QUAD_PORT_A (1 << 12) #define FLAG_IS_QUAD_PORT (1 << 13) -#define FLAG_TIPG_MEDIUM_FOR_80003ESLAN (1 << 14) +/* reserved bit14 */ #define FLAG_APME_IN_WUC (1 << 15) #define FLAG_APME_IN_CTRL3 (1 << 16) #define FLAG_APME_CHECK_PORT_B (1 << 17) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 6081dee5ce46..fb299905b1f1 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -2770,8 +2770,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) struct e1000_hw *hw = &adapter->hw; struct e1000_ring *tx_ring = adapter->tx_ring; u64 tdba; - u32 tdlen, tctl, tipg, tarc; - u32 ipgr1, ipgr2; + u32 tdlen, tctl, tarc; /* Setup the HW Tx Head and Tail descriptor pointers */ tdba = tx_ring->dma; @@ -2784,18 +2783,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) tx_ring->head = adapter->hw.hw_addr + E1000_TDH; tx_ring->tail = adapter->hw.hw_addr + E1000_TDT; - /* Set the default values for the Tx Inter Packet Gap timer */ - tipg = DEFAULT_82543_TIPG_IPGT_COPPER; /* 8 */ - ipgr1 = DEFAULT_82543_TIPG_IPGR1; /* 8 */ - ipgr2 = DEFAULT_82543_TIPG_IPGR2; /* 6 */ - - if (adapter->flags & FLAG_TIPG_MEDIUM_FOR_80003ESLAN) - ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2; /* 7 */ - - tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT; - tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT; - ew32(TIPG, tipg); - /* Set the Tx Interrupt Delay register */ ew32(TIDV, adapter->tx_int_delay); /* Tx irq moderation */ -- GitLab From c550b121854eb1300148da1c2c8df6ed0dabdc66 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:17 +0000 Subject: [PATCH 0158/1846] e1000e: use hardware default values for Transmit Control register This code snippet is simply writing default values to the register which is unnecessary since the values are programmed into the register by default. There is a special case for 80003es2lan needing the Retransmit on Late Collision bit set but that is also done in e1000_init_hw_80003es2lan(). Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index fb299905b1f1..89af6c026230 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -2770,7 +2770,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) struct e1000_hw *hw = &adapter->hw; struct e1000_ring *tx_ring = adapter->tx_ring; u64 tdba; - u32 tdlen, tctl, tarc; + u32 tdlen, tarc; /* Setup the HW Tx Head and Tail descriptor pointers */ tdba = tx_ring->dma; @@ -2808,12 +2808,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) /* erratum work around: set txdctl the same for both queues */ ew32(TXDCTL(1), er32(TXDCTL(0))); - /* Program the Transmit Control Register */ - tctl = er32(TCTL); - tctl &= ~E1000_TCTL_CT; - tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC | - (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); - if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) { tarc = er32(TARC(0)); /* @@ -2845,8 +2839,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) /* enable Report Status bit */ adapter->txd_cmd |= E1000_TXD_CMD_RS; - ew32(TCTL, tctl); - e1000e_config_collision_dist(hw); } -- GitLab From d6cb17d5f8015717f6963d24d52b06292a4cb40a Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:22 +0000 Subject: [PATCH 0159/1846] e1000e: 82574/82583 Tx hang workaround On 82574/82583, there is a hardware bug which might cause a Tx hang when the internal buffer is full. Setting this bit enables a hardware fix to work around the issue. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/82571.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index a3e65fd26e09..0609ac69bb38 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1227,6 +1227,10 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) case e1000_82572: reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26); break; + case e1000_82574: + case e1000_82583: + reg |= (1 << 26); + break; default: break; } -- GitLab From 8d7b02783bc2b05974f6e47c2be8157f3a9cd89e Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:45 +0000 Subject: [PATCH 0160/1846] bnx2x: Support Queue Per Cos in 5771xx devices Enable the use of up to three hardware queues for transmission. The queues are always dequed round robin (i.e. strict priority, PFC and ETS are not supported). This does allow the allocation of a seperate HW queue for low volume, high priority traffic which will be serviced more promptly. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 7 ++++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index bf27c54ff2e0..0dd22bb44f0d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -984,10 +984,11 @@ static inline int bnx2x_func_start(struct bnx2x *bp) /* Function parameters */ start_params->mf_mode = bp->mf_mode; start_params->sd_vlan_tag = bp->mf_ov; - if (CHIP_IS_E1x(bp)) - start_params->network_cos_mode = OVERRIDE_COS; - else + + if (CHIP_IS_E2(bp) || CHIP_IS_E3(bp)) start_params->network_cos_mode = STATIC_COS; + else /* CHIP_IS_E1X */ + start_params->network_cos_mode = FW_WRR; return bnx2x_func_state_change(bp, &func_params); } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h index 66da39f0c84a..f33bc5722e58 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h @@ -803,10 +803,10 @@ enum bnx2x_q_type { }; #define BNX2X_PRIMARY_CID_INDEX 0 -#define BNX2X_MULTI_TX_COS_E1X 1 +#define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */ #define BNX2X_MULTI_TX_COS_E2_E3A0 2 #define BNX2X_MULTI_TX_COS_E3B0 3 -#define BNX2X_MULTI_TX_COS BNX2X_MULTI_TX_COS_E3B0 +#define BNX2X_MULTI_TX_COS 3 /* Maximum possible */ struct bnx2x_queue_init_params { -- GitLab From 127a425e8f05b9813879e8ca909ef4338ec8ec04 Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:46 +0000 Subject: [PATCH 0161/1846] bnx2x: Removing indirect register access In virtualized environments indirect access to the device may not be supported (depending on the Hypervisor type). Indirect device access was used since in some harware contexts (i.e. certain chipset and BIOS) every access the driver makes across the pci is followed by a BIOS initiated Zero Length Read to the same address. When accessing widebus registers this zero length read corrupts the serialization of the read/write sequence resulting with errors. To avoid this problem widebus registers are always accessed via the DMAE or the indirect interface. However, the 57712x and 578xx devices intercept the zero length read and so using the indirect interface with these devices is not necessary. Since PDA is only supported for 57712x and 578xx the indirect access to device was restricted to 57710 and 57711x. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../ethernet/broadcom/bnx2x/bnx2x_init_ops.h | 53 +++++++++++-------- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 24 ++++++--- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h index 7ec1724753ad..f05ee2f137fd 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h @@ -69,12 +69,12 @@ static void bnx2x_write_big_buf(struct bnx2x *bp, u32 addr, u32 len, { if (bp->dmae_ready) bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len); - else if (wb) - /* - * Wide bus registers with no dmae need to be written - * using indirect write. - */ + + /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */ + else if (wb && CHIP_IS_E1(bp)) bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len); + + /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */ else bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len); } @@ -99,8 +99,14 @@ static void bnx2x_write_big_buf_wb(struct bnx2x *bp, u32 addr, u32 len) { if (bp->dmae_ready) bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len); - else + + /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */ + else if (CHIP_IS_E1(bp)) bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len); + + /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */ + else + bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len); } static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr, @@ -177,8 +183,14 @@ static void bnx2x_init_wr_wb(struct bnx2x *bp, u32 addr, { if (bp->dmae_ready) VIRT_WR_DMAE_LEN(bp, data, addr, len, 0); - else + + /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */ + else if (CHIP_IS_E1(bp)) bnx2x_init_ind_wr(bp, addr, data, len); + + /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */ + else + bnx2x_init_str_wr(bp, addr, data, len); } static void bnx2x_wr_64(struct bnx2x *bp, u32 reg, u32 val_lo, @@ -840,25 +852,15 @@ static void bnx2x_qm_init_cid_count(struct bnx2x *bp, int qm_cid_count, } } -static void bnx2x_qm_set_ptr_table(struct bnx2x *bp, int qm_cid_count) +static void bnx2x_qm_set_ptr_table(struct bnx2x *bp, int qm_cid_count, + u32 base_reg, u32 reg) { int i; - u32 wb_data[2]; - - wb_data[0] = wb_data[1] = 0; - + u32 wb_data[2] = {0, 0}; for (i = 0; i < 4 * QM_QUEUES_PER_FUNC; i++) { - REG_WR(bp, QM_REG_BASEADDR + i*4, + REG_WR(bp, base_reg + i*4, qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC)); - bnx2x_init_ind_wr(bp, QM_REG_PTRTBL + i*8, - wb_data, 2); - - if (CHIP_IS_E1H(bp)) { - REG_WR(bp, QM_REG_BASEADDR_EXT_A + i*4, - qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC)); - bnx2x_init_ind_wr(bp, QM_REG_PTRTBL_EXT_A + i*8, - wb_data, 2); - } + bnx2x_init_wr_wb(bp, reg + i*8, wb_data, 2); } } @@ -873,7 +875,12 @@ static void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count, case INITOP_INIT: /* set in the init-value array */ case INITOP_SET: - bnx2x_qm_set_ptr_table(bp, qm_cid_count); + bnx2x_qm_set_ptr_table(bp, qm_cid_count, + QM_REG_BASEADDR, QM_REG_PTRTBL); + if (CHIP_IS_E1H(bp)) + bnx2x_qm_set_ptr_table(bp, qm_cid_count, + QM_REG_BASEADDR_EXT_A, + QM_REG_PTRTBL_EXT_A); break; case INITOP_CLEAR: break; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 1e3f978ee6da..e56b8326652e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -498,9 +498,13 @@ void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, if (!bp->dmae_ready) { u32 *data = bnx2x_sp(bp, wb_data[0]); - DP(BNX2X_MSG_OFF, "DMAE is not ready (dst_addr %08x len32 %d)" - " using indirect\n", dst_addr, len32); - bnx2x_init_ind_wr(bp, dst_addr, data, len32); + DP(BNX2X_MSG_OFF, + "DMAE is not ready (dst_addr %08x len32 %d) using indirect\n", + dst_addr, len32); + if (CHIP_IS_E1(bp)) + bnx2x_init_ind_wr(bp, dst_addr, data, len32); + else + bnx2x_init_str_wr(bp, dst_addr, data, len32); return; } @@ -528,10 +532,16 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32) u32 *data = bnx2x_sp(bp, wb_data[0]); int i; - DP(BNX2X_MSG_OFF, "DMAE is not ready (src_addr %08x len32 %d)" - " using indirect\n", src_addr, len32); - for (i = 0; i < len32; i++) - data[i] = bnx2x_reg_rd_ind(bp, src_addr + i*4); + if (CHIP_IS_E1(bp)) { + DP(BNX2X_MSG_OFF, + "DMAE is not ready (src_addr %08x len32 %d) using indirect\n", + src_addr, len32); + for (i = 0; i < len32; i++) + data[i] = bnx2x_reg_rd_ind(bp, src_addr + i*4); + } else + for (i = 0; i < len32; i++) + data[i] = REG_RD(bp, src_addr + i*4); + return; } -- GitLab From c22610d0001ebf3420d39f419056a56c5aa43096 Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:47 +0000 Subject: [PATCH 0162/1846] bnx2x: Obtain Bus Device Function from register BDF was obtained from kernel but since in virtualized environment (e.g. physical device assigment in KVM) the function number may not be the real one, the info must be obtained from the device. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 17 ++++++++++++++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index e56b8326652e..115d77a8bebb 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -10546,6 +10546,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, { struct bnx2x *bp; int rc; + u32 pci_cfg_dword; bool chip_is_e1x = (board_type == BCM57710 || board_type == BCM57711 || board_type == BCM57711E); @@ -10556,7 +10557,6 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, bp->dev = dev; bp->pdev = pdev; bp->flags = 0; - bp->pf_num = PCI_FUNC(pdev->devfn); rc = pci_enable_device(pdev); if (rc) { @@ -10623,6 +10623,21 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, goto err_out_release; } + /* In E1/E1H use pci device function given by kernel. + * In E2/E3 read physical function from ME register since these chips + * support Physical Device Assignment where kernel BDF maybe arbitrary + * (depending on hypervisor). + */ + if (chip_is_e1x) + bp->pf_num = PCI_FUNC(pdev->devfn); + else {/* chip is E2/3*/ + pci_read_config_dword(bp->pdev, + PCICFG_ME_REGISTER, &pci_cfg_dword); + bp->pf_num = (u8)((pci_cfg_dword & ME_REG_ABS_PF_NUM) >> + ME_REG_ABS_PF_NUM_SHIFT); + } + DP(BNX2X_MSG_SP, "me reg PF num: %d\n", bp->pf_num); + bnx2x_set_power_state(bp, PCI_D0); /* clean indirect addresses */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h index dddbcf6e154e..8c79e00b37e8 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h @@ -6023,7 +6023,8 @@ #define PCICFG_MSI_CONTROL_64_BIT_ADDR_CAP (0x1<<23) #define PCICFG_MSI_CONTROL_MSI_PVMASK_CAPABLE (0x1<<24) #define PCICFG_GRC_ADDRESS 0x78 -#define PCICFG_GRC_DATA 0x80 +#define PCICFG_GRC_DATA 0x80 +#define PCICFG_ME_REGISTER 0x98 #define PCICFG_MSIX_CAP_ID_OFFSET 0xa0 #define PCICFG_MSIX_CONTROL_TABLE_SIZE (0x7ff<<16) #define PCICFG_MSIX_CONTROL_RESERVED (0x7<<27) -- GitLab From 89db4ad830fbdde9c2d990b88bbac8245718177d Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:48 +0000 Subject: [PATCH 0163/1846] bnx2x: Function Level Reset Final Cleanup 1. Fix bug where return value is ignored 2. Improve printouts 3. Fix typos Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 115d77a8bebb..9a1c4501f0ec 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -1017,8 +1017,8 @@ void bnx2x_panic_dump(struct bnx2x *bp) * initialization. */ #define FLR_WAIT_USEC 10000 /* 10 miliseconds */ -#define FLR_WAIT_INTERAVAL 50 /* usec */ -#define FLR_POLL_CNT (FLR_WAIT_USEC/FLR_WAIT_INTERAVAL) /* 200 */ +#define FLR_WAIT_INTERVAL 50 /* usec */ +#define FLR_POLL_CNT (FLR_WAIT_USEC/FLR_WAIT_INTERVAL) /* 200 */ struct pbf_pN_buf_regs { int pN; @@ -1051,7 +1051,7 @@ static void bnx2x_pbf_pN_buf_flushed(struct bnx2x *bp, while ((crd != init_crd) && ((u32)SUB_S32(crd_freed, crd_freed_start) < (init_crd - crd_start))) { if (cur_cnt--) { - udelay(FLR_WAIT_INTERAVAL); + udelay(FLR_WAIT_INTERVAL); crd = REG_RD(bp, regs->crd); crd_freed = REG_RD(bp, regs->crd_freed); } else { @@ -1065,7 +1065,7 @@ static void bnx2x_pbf_pN_buf_flushed(struct bnx2x *bp, } } DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF tx buffer[%d]\n", - poll_count-cur_cnt, FLR_WAIT_INTERAVAL, regs->pN); + poll_count-cur_cnt, FLR_WAIT_INTERVAL, regs->pN); } static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp, @@ -1083,7 +1083,7 @@ static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp, while (occup && ((u32)SUB_S32(freed, freed_start) < to_free)) { if (cur_cnt--) { - udelay(FLR_WAIT_INTERAVAL); + udelay(FLR_WAIT_INTERVAL); occup = REG_RD(bp, regs->lines_occup); freed = REG_RD(bp, regs->lines_freed); } else { @@ -1097,7 +1097,7 @@ static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp, } } DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF cmd queue[%d]\n", - poll_count-cur_cnt, FLR_WAIT_INTERAVAL, regs->pN); + poll_count-cur_cnt, FLR_WAIT_INTERVAL, regs->pN); } static inline u32 bnx2x_flr_clnup_reg_poll(struct bnx2x *bp, u32 reg, @@ -1107,7 +1107,7 @@ static inline u32 bnx2x_flr_clnup_reg_poll(struct bnx2x *bp, u32 reg, u32 val; while ((val = REG_RD(bp, reg)) != expected && cur_cnt--) - udelay(FLR_WAIT_INTERAVAL); + udelay(FLR_WAIT_INTERVAL); return val; } @@ -1220,7 +1220,7 @@ static inline int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, int ret = 0; if (REG_RD(bp, comp_addr)) { - BNX2X_ERR("Cleanup complete is not 0\n"); + BNX2X_ERR("Cleanup complete was not 0 before sending\n"); return 1; } @@ -1229,7 +1229,7 @@ static inline int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, op_gen.command |= OP_GEN_AGG_VECT(clnup_func); op_gen.command |= 1 << SDM_OP_GEN_AGG_VECT_IDX_VALID_SHIFT; - DP(BNX2X_MSG_SP, "FW Final cleanup\n"); + DP(BNX2X_MSG_SP, "sending FW Final cleanup\n"); REG_WR(bp, XSDM_REG_OPERATION_GEN, op_gen.command); if (bnx2x_flr_clnup_reg_poll(bp, comp_addr, 1, poll_cnt) != 1) { @@ -1344,6 +1344,7 @@ static int bnx2x_pf_flr_clnup(struct bnx2x *bp) REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); /* Poll HW usage counters */ + DP(BNX2X_MSG_SP, "Polling usage counters\n"); if (bnx2x_poll_hw_usage_counters(bp, poll_cnt)) return -EBUSY; @@ -6697,13 +6698,16 @@ static int bnx2x_init_hw_func(struct bnx2x *bp) u16 cdu_ilt_start; u32 addr, val; u32 main_mem_base, main_mem_size, main_mem_prty_clr; - int i, main_mem_width; + int i, main_mem_width, rc; DP(BNX2X_MSG_MCP, "starting func init func %d\n", func); /* FLR cleanup - hmmm */ - if (!CHIP_IS_E1x(bp)) - bnx2x_pf_flr_clnup(bp); + if (!CHIP_IS_E1x(bp)) { + rc = bnx2x_pf_flr_clnup(bp); + if (rc) + return rc; + } /* set MSI reconfigure capability */ if (bp->common.int_block == INT_BLOCK_HC) { -- GitLab From d1e2d9660e6bca2f06606b4bc65ea669bf669b0a Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:49 +0000 Subject: [PATCH 0164/1846] bnx2x: Loaded Firmware Version Validation In a virtualized environment it is possible for a loading driver to discover that Firmware is already loaded to the device, and that this FW does not match its own. This can happen for example if different Physical Functions are Assigned to different VMs in which different driver versions are loaded. The code in this patch ensures that only drivers with matching FW are loaded over the device, and that in the case described above where the Firmware version doesn't match the driver load is aborted. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 03f3935fd8c2..b75c8eab095c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1783,6 +1783,29 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) rc = -EBUSY; /* other port in diagnostic mode */ LOAD_ERROR_EXIT(bp, load_error1); } + if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP && + load_code != FW_MSG_CODE_DRV_LOAD_COMMON) { + /* build FW version dword */ + u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) + + (BCM_5710_FW_MINOR_VERSION << 8) + + (BCM_5710_FW_REVISION_VERSION << 16) + + (BCM_5710_FW_ENGINEERING_VERSION << 24); + + /* read loaded FW from chip */ + u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM); + + DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x", + loaded_fw, my_fw); + + /* abort nic load if version mismatch */ + if (my_fw != loaded_fw) { + BNX2X_ERR("bnx2x with FW %x already loaded, " + "which mismatches my %x FW. aborting", + loaded_fw, my_fw); + rc = -EBUSY; + LOAD_ERROR_EXIT(bp, load_error2); + } + } } else { int path = BP_PATH(bp); -- GitLab From f16da43b5df947cef427f19b8f5c4b2f5d566231 Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:50 +0000 Subject: [PATCH 0165/1846] bnx2x: Lock PF-common resources Use hardware locks to protect resources common to several Physical Functions. In a virtualized environment the RTNL lock only protects a PF's driver against the PFs sharing it's VMs with regard to device resources. Other PFs may reside in other VMs under other OSs, and are not subject to the lock. Such resources which were previously protected implicitly by the RTNL lock must now be protected explicitly with dedicated HW locks. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 4 +- .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 22 +++++- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 73 +++++++++++-------- .../net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 7 +- 4 files changed, 68 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 0dd22bb44f0d..bd990c2e5d1b 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1540,7 +1540,7 @@ static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) { if (SHMEM2_HAS(bp, drv_flags)) { u32 drv_flags; - bnx2x_acquire_hw_lock(bp, HW_LOCK_DRV_FLAGS); + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS); drv_flags = SHMEM2_RD(bp, drv_flags); if (set) @@ -1550,7 +1550,7 @@ static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) SHMEM2_WR(bp, drv_flags, drv_flags); DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); - bnx2x_release_hw_lock(bp, HW_LOCK_DRV_FLAGS); + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS); } } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 31a8b38ab15e..37a5c52197eb 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -882,11 +882,27 @@ static int bnx2x_get_eeprom_len(struct net_device *dev) return bp->common.flash_size; } +/* Per pf misc lock must be aquired before the per port mcp lock. Otherwise, had + * we done things the other way around, if two pfs from the same port would + * attempt to access nvram at the same time, we could run into a scenario such + * as: + * pf A takes the port lock. + * pf B succeeds in taking the same lock since they are from the same port. + * pf A takes the per pf misc lock. Performs eeprom access. + * pf A finishes. Unlocks the per pf misc lock. + * Pf B takes the lock and proceeds to perform it's own access. + * pf A unlocks the per port lock, while pf B is still working (!). + * mcp takes the per port lock and corrupts pf B's access (and/or has it's own + * acess corrupted by pf B).* + */ static int bnx2x_acquire_nvram_lock(struct bnx2x *bp) { int port = BP_PORT(bp); int count, i; - u32 val = 0; + u32 val; + + /* acquire HW lock: protect against other PFs in PF Direct Assignment */ + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_NVRAM); /* adjust timeout for emulation/FPGA */ count = BNX2X_NVRAM_TIMEOUT_COUNT; @@ -917,7 +933,7 @@ static int bnx2x_release_nvram_lock(struct bnx2x *bp) { int port = BP_PORT(bp); int count, i; - u32 val = 0; + u32 val; /* adjust timeout for emulation/FPGA */ count = BNX2X_NVRAM_TIMEOUT_COUNT; @@ -941,6 +957,8 @@ static int bnx2x_release_nvram_lock(struct bnx2x *bp) return -EBUSY; } + /* release HW lock: protect against other PFs in PF Direct Assignment */ + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_NVRAM); return 0; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 9a1c4501f0ec..4824b0f8bd23 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -3724,11 +3724,11 @@ static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn) */ void bnx2x_set_reset_global(struct bnx2x *bp) { - u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); - + u32 val; + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val | BNX2X_GLOBAL_RESET_BIT); - barrier(); - mmiowb(); + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); } /* @@ -3738,11 +3738,11 @@ void bnx2x_set_reset_global(struct bnx2x *bp) */ static inline void bnx2x_clear_reset_global(struct bnx2x *bp) { - u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); - + u32 val; + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~BNX2X_GLOBAL_RESET_BIT)); - barrier(); - mmiowb(); + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); } /* @@ -3765,15 +3765,17 @@ static inline bool bnx2x_reset_is_global(struct bnx2x *bp) */ static inline void bnx2x_set_reset_done(struct bnx2x *bp) { - u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); + u32 val; u32 bit = BP_PATH(bp) ? BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); /* Clear the bit */ val &= ~bit; REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); - barrier(); - mmiowb(); + + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); } /* @@ -3783,15 +3785,16 @@ static inline void bnx2x_set_reset_done(struct bnx2x *bp) */ void bnx2x_set_reset_in_progress(struct bnx2x *bp) { - u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); + u32 val; u32 bit = BP_PATH(bp) ? BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); /* Set the bit */ val |= bit; REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); - barrier(); - mmiowb(); + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); } /* @@ -3815,12 +3818,15 @@ bool bnx2x_reset_is_done(struct bnx2x *bp, int engine) */ void bnx2x_inc_load_cnt(struct bnx2x *bp) { - u32 val1, val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); + u32 val1, val; u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK; u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT : BNX2X_PATH0_LOAD_CNT_SHIFT; + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); + DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); /* get the current counter value */ @@ -3836,8 +3842,7 @@ void bnx2x_inc_load_cnt(struct bnx2x *bp) val |= ((val1 << shift) & mask); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); - barrier(); - mmiowb(); + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); } /** @@ -3851,12 +3856,14 @@ void bnx2x_inc_load_cnt(struct bnx2x *bp) */ u32 bnx2x_dec_load_cnt(struct bnx2x *bp) { - u32 val1, val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); + u32 val1, val; u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK; u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT : BNX2X_PATH0_LOAD_CNT_SHIFT; + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); /* get the current counter value */ @@ -3872,10 +3879,8 @@ u32 bnx2x_dec_load_cnt(struct bnx2x *bp) val |= ((val1 << shift) & mask); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); - barrier(); - mmiowb(); - - return val1; + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + return val1 != 0; } /* @@ -3907,11 +3912,13 @@ static inline u32 bnx2x_get_load_cnt(struct bnx2x *bp, int engine) */ static inline void bnx2x_clear_load_cnt(struct bnx2x *bp) { - u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); + u32 val; u32 mask = (BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : - BNX2X_PATH0_LOAD_CNT_MASK); - + BNX2X_PATH0_LOAD_CNT_MASK); + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); + val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~mask)); + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); } static inline void _print_next_block(int idx, const char *blk) @@ -8809,11 +8816,13 @@ static void __devinit bnx2x_undi_unload(struct bnx2x *bp) { u32 val; - /* Check if there is any driver already loaded */ - val = REG_RD(bp, MISC_REG_UNPREPARED); - if (val == 0x1) { + /* possibly another driver is trying to reset the chip */ + bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET); + + /* check if doorbell queue is reset */ + if (REG_RD(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET) + & MISC_REGISTERS_RESET_REG_1_RST_DORQ) { - bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET); /* * Check if it is the UNDI driver * UNDI driver initializes CID offset for normal bell to 0x7 @@ -8905,10 +8914,10 @@ static void __devinit bnx2x_undi_unload(struct bnx2x *bp) (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK); } - - /* now it's safe to release the lock */ - bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET); } + + /* now it's safe to release the lock */ + bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET); } static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h index 8c79e00b37e8..8ade7bd9a717 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h @@ -5731,6 +5731,7 @@ #define MISC_REGISTERS_GPIO_PORT_SHIFT 4 #define MISC_REGISTERS_GPIO_SET_POS 8 #define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588 +#define MISC_REGISTERS_RESET_REG_1_RST_DORQ (0x1<<19) #define MISC_REGISTERS_RESET_REG_1_RST_HC (0x1<<29) #define MISC_REGISTERS_RESET_REG_1_RST_NIG (0x1<<7) #define MISC_REGISTERS_RESET_REG_1_RST_PXP (0x1<<26) @@ -5783,15 +5784,17 @@ #define MISC_REGISTERS_SPIO_OUTPUT_HIGH 1 #define MISC_REGISTERS_SPIO_OUTPUT_LOW 0 #define MISC_REGISTERS_SPIO_SET_POS 8 -#define HW_LOCK_DRV_FLAGS 10 #define HW_LOCK_MAX_RESOURCE_VALUE 31 +#define HW_LOCK_RESOURCE_DRV_FLAGS 10 #define HW_LOCK_RESOURCE_GPIO 1 #define HW_LOCK_RESOURCE_MDIO 0 +#define HW_LOCK_RESOURCE_NVRAM 12 #define HW_LOCK_RESOURCE_PORT0_ATT_MASK 3 #define HW_LOCK_RESOURCE_RECOVERY_LEADER_0 8 #define HW_LOCK_RESOURCE_RECOVERY_LEADER_1 9 -#define HW_LOCK_RESOURCE_SPIO 2 +#define HW_LOCK_RESOURCE_RECOVERY_REG 11 #define HW_LOCK_RESOURCE_RESET 5 +#define HW_LOCK_RESOURCE_SPIO 2 #define AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT (0x1<<4) #define AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR (0x1<<5) #define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR (0x1<<18) -- GitLab From 889b9af34f986138eebebfe781567cb950b3a22b Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:51 +0000 Subject: [PATCH 0166/1846] bnx2x: Track active PFs with bitmap The recovery register (to which a hardware lock has been added in previous patch) is used amongst other things to track the active PFs. The old implementation which used a per path counter is not viable in a virtualized environment where a pf may increment the counter and then have the kernel crash around it preventing the counter from ever reaching zero. In the new implementation the scenario described will result in the PF timing out against the mcp, which will clear the PF's bit in the bitmask allowing recovery process to proceed. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 8 ++- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 4 +- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 56 +++++++++---------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index b75c8eab095c..15db2d679a14 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1767,6 +1767,9 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) bnx2x_napi_enable(bp); + /* set pf load just before approaching the MCP */ + bnx2x_set_pf_load(bp); + /* Send LOAD_REQUEST command to MCP * Returns the type of LOAD command: * if it is the first port to be initialized @@ -1972,7 +1975,6 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) if (bp->state == BNX2X_STATE_OPEN) bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); #endif - bnx2x_inc_load_cnt(bp); /* Wait for all pending SP commands to complete */ if (!bnx2x_wait_sp_comp(bp, ~0x0UL)) { @@ -2012,6 +2014,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) bp->port.pmf = 0; load_error1: bnx2x_napi_disable(bp); + /* clear pf_load status, as it was already set */ + bnx2x_clear_pf_load(bp); load_error0: bnx2x_free_mem(bp); @@ -2132,7 +2136,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) /* The last driver must disable a "close the gate" if there is no * parity attention or "process kill" pending. */ - if (!bnx2x_dec_load_cnt(bp) && bnx2x_reset_is_done(bp, BP_PATH(bp))) + if (!bnx2x_clear_pf_load(bp) && bnx2x_reset_is_done(bp, BP_PATH(bp))) bnx2x_disable_close_the_gate(bp); return 0; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index bd990c2e5d1b..a6ef3ef85e51 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -379,8 +379,8 @@ void bnx2x_set_q_rx_mode(struct bnx2x *bp, u8 cl_id, unsigned long ramrod_flags); /* Parity errors related */ -void bnx2x_inc_load_cnt(struct bnx2x *bp); -u32 bnx2x_dec_load_cnt(struct bnx2x *bp); +void bnx2x_set_pf_load(struct bnx2x *bp); +bool bnx2x_clear_pf_load(struct bnx2x *bp); bool bnx2x_chk_parity_attn(struct bnx2x *bp, bool *global, bool print); bool bnx2x_reset_is_done(struct bnx2x *bp, int engine); void bnx2x_set_reset_in_progress(struct bnx2x *bp); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 4824b0f8bd23..f7f167a0f85a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -3812,11 +3812,11 @@ bool bnx2x_reset_is_done(struct bnx2x *bp, int engine) } /* - * Increment the load counter for the current engine. + * set pf load for the current pf. * * should be run under rtnl lock */ -void bnx2x_inc_load_cnt(struct bnx2x *bp) +void bnx2x_set_pf_load(struct bnx2x *bp) { u32 val1, val; u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : @@ -3832,8 +3832,8 @@ void bnx2x_inc_load_cnt(struct bnx2x *bp) /* get the current counter value */ val1 = (val & mask) >> shift; - /* increment... */ - val1++; + /* set bit of that PF */ + val1 |= (1 << bp->pf_num); /* clear the old value */ val &= ~mask; @@ -3846,15 +3846,15 @@ void bnx2x_inc_load_cnt(struct bnx2x *bp) } /** - * bnx2x_dec_load_cnt - decrement the load counter + * bnx2x_clear_pf_load - clear pf load mark * * @bp: driver handle * * Should be run under rtnl lock. * Decrements the load counter for the current engine. Returns - * the new counter value. + * whether other functions are still loaded */ -u32 bnx2x_dec_load_cnt(struct bnx2x *bp) +bool bnx2x_clear_pf_load(struct bnx2x *bp) { u32 val1, val; u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : @@ -3869,8 +3869,8 @@ u32 bnx2x_dec_load_cnt(struct bnx2x *bp) /* get the current counter value */ val1 = (val & mask) >> shift; - /* decrement... */ - val1--; + /* clear bit of that PF */ + val1 &= ~(1 << bp->pf_num); /* clear the old value */ val &= ~mask; @@ -3884,11 +3884,11 @@ u32 bnx2x_dec_load_cnt(struct bnx2x *bp) } /* - * Read the load counter for the current engine. + * Read the load status for the current engine. * * should be run under rtnl lock */ -static inline u32 bnx2x_get_load_cnt(struct bnx2x *bp, int engine) +static inline bool bnx2x_get_load_status(struct bnx2x *bp, int engine) { u32 mask = (engine ? BNX2X_PATH1_LOAD_CNT_MASK : BNX2X_PATH0_LOAD_CNT_MASK); @@ -3900,17 +3900,15 @@ static inline u32 bnx2x_get_load_cnt(struct bnx2x *bp, int engine) val = (val & mask) >> shift; - DP(NETIF_MSG_HW, "load_cnt for engine %d = %d\n", engine, val); + DP(NETIF_MSG_HW, "load mask for engine %d = 0x%x\n", engine, val); - return val; + return val != 0; } /* - * Reset the load counter for the current engine. - * - * should be run under rtnl lock + * Reset the load status for the current engine. */ -static inline void bnx2x_clear_load_cnt(struct bnx2x *bp) +static inline void bnx2x_clear_load_status(struct bnx2x *bp) { u32 val; u32 mask = (BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : @@ -8582,10 +8580,10 @@ static void bnx2x_parity_recover(struct bnx2x *bp) DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_WAIT\n"); if (bp->is_leader) { int other_engine = BP_PATH(bp) ? 0 : 1; - u32 other_load_counter = - bnx2x_get_load_cnt(bp, other_engine); - u32 load_counter = - bnx2x_get_load_cnt(bp, BP_PATH(bp)); + bool other_load_status = + bnx2x_get_load_status(bp, other_engine); + bool load_status = + bnx2x_get_load_status(bp, BP_PATH(bp)); global = bnx2x_reset_is_global(bp); /* @@ -8596,8 +8594,8 @@ static void bnx2x_parity_recover(struct bnx2x *bp) * the the gates will remain closed for that * engine. */ - if (load_counter || - (global && other_load_counter)) { + if (load_status || + (global && other_load_status)) { /* Wait until all other functions get * down. */ @@ -10206,14 +10204,14 @@ static int bnx2x_open(struct net_device *dev) struct bnx2x *bp = netdev_priv(dev); bool global = false; int other_engine = BP_PATH(bp) ? 0 : 1; - u32 other_load_counter, load_counter; + bool other_load_status, load_status; netif_carrier_off(dev); bnx2x_set_power_state(bp, PCI_D0); - other_load_counter = bnx2x_get_load_cnt(bp, other_engine); - load_counter = bnx2x_get_load_cnt(bp, BP_PATH(bp)); + other_load_status = bnx2x_get_load_status(bp, other_engine); + load_status = bnx2x_get_load_status(bp, BP_PATH(bp)); /* * If parity had happen during the unload, then attentions @@ -10239,8 +10237,8 @@ static int bnx2x_open(struct net_device *dev) * global blocks only the first in the chip should try * to recover. */ - if ((!load_counter && - (!global || !other_load_counter)) && + if ((!load_status && + (!global || !other_load_status)) && bnx2x_trylock_leader_lock(bp) && !bnx2x_leader_reset(bp)) { netdev_info(bp->dev, "Recovered in open\n"); @@ -10680,7 +10678,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); /* Reset the load counter */ - bnx2x_clear_load_cnt(bp); + bnx2x_clear_load_status(bp); dev->watchdog_timeo = TX_TIMEOUT; -- GitLab From 95c6c6165eaf5a031bcf31606e081c72e4acdeb8 Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:52 +0000 Subject: [PATCH 0167/1846] bnx2x: Recovery flow bug fixes 1. Sample mcp pulse and mcp sequence in nic load instead of in init_one as they may change by the time we want to use them. 2. Allow cnic to access device during nic load (by adding a new "LOADING" state to recovery flow). This prevents the unnecessary cnic timeout which resulted by cnic attempting to access because nic is loading, but being blocked because of the Recovery state. 3. Issue 'fake' driver load command to mcp when last driver unloads to prevent mcp from taking ownership. When recovery is complete unload fake driver to allow mcp to initialize the hardware before first driver loads. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 3 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 18 +++- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 102 ++++++++++-------- 3 files changed, 75 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 8c73d34b2ff1..06bbef742fa3 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -1088,7 +1088,8 @@ enum bnx2x_recovery_state { BNX2X_RECOVERY_DONE, BNX2X_RECOVERY_INIT, BNX2X_RECOVERY_WAIT, - BNX2X_RECOVERY_FAILED + BNX2X_RECOVERY_FAILED, + BNX2X_RECOVERY_NIC_LOADING }; /* diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 15db2d679a14..8fdd71b7bef0 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1776,6 +1776,18 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) * common blocks should be initialized, otherwise - not */ if (!BP_NOMCP(bp)) { + /* init fw_seq */ + bp->fw_seq = + (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & + DRV_MSG_SEQ_NUMBER_MASK); + BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); + + /* Get current FW pulse sequence */ + bp->fw_drv_pulse_wr_seq = + (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_pulse_mb) & + DRV_PULSE_SEQ_MASK); + BNX2X_DEV_INFO("drv_pulse 0x%x\n", bp->fw_drv_pulse_wr_seq); + load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ, 0); if (!load_code) { BNX2X_ERR("MCP response failure, aborting\n"); @@ -3442,7 +3454,7 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) struct bnx2x *bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - pr_err("Handling parity error recovery. Try again later\n"); + netdev_err(dev, "Handling parity error recovery. Try again later\n"); return -EAGAIN; } @@ -3569,7 +3581,7 @@ int bnx2x_resume(struct pci_dev *pdev) bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - pr_err("Handling parity error recovery. Try again later\n"); + netdev_err(dev, "Handling parity error recovery. Try again later\n"); return -EAGAIN; } @@ -3585,8 +3597,6 @@ int bnx2x_resume(struct pci_dev *pdev) bnx2x_set_power_state(bp, PCI_D0); netif_device_attach(dev); - /* Since the chip was reset, clear the FW sequence number */ - bp->fw_seq = 0; rc = bnx2x_nic_load(bp, LOAD_OPEN); rtnl_unlock(); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index f7f167a0f85a..c945df061618 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -468,7 +468,9 @@ static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, while ((*wb_comp & ~DMAE_PCI_ERR_FLAG) != DMAE_COMP_VAL) { DP(BNX2X_MSG_OFF, "wb_comp 0x%08x\n", *wb_comp); - if (!cnt) { + if (!cnt || + (bp->recovery_state != BNX2X_RECOVERY_DONE && + bp->recovery_state != BNX2X_RECOVERY_NIC_LOADING)) { BNX2X_ERR("DMAE timeout!\n"); rc = DMAE_TIMEOUT; goto unlock; @@ -8477,13 +8479,38 @@ int bnx2x_leader_reset(struct bnx2x *bp) { int rc = 0; bool global = bnx2x_reset_is_global(bp); + u32 load_code; + + /* if not going to reset MCP - load "fake" driver to reset HW while + * driver is owner of the HW + */ + if (!global && !BP_NOMCP(bp)) { + load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ, 0); + if (!load_code) { + BNX2X_ERR("MCP response failure, aborting\n"); + rc = -EAGAIN; + goto exit_leader_reset; + } + if ((load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP) && + (load_code != FW_MSG_CODE_DRV_LOAD_COMMON)) { + BNX2X_ERR("MCP unexpected resp, aborting\n"); + rc = -EAGAIN; + goto exit_leader_reset2; + } + load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE, 0); + if (!load_code) { + BNX2X_ERR("MCP response failure, aborting\n"); + rc = -EAGAIN; + goto exit_leader_reset2; + } + } /* Try to recover after the failure */ if (bnx2x_process_kill(bp, global)) { netdev_err(bp->dev, "Something bad had happen on engine %d! " "Aii!\n", BP_PATH(bp)); rc = -EAGAIN; - goto exit_leader_reset; + goto exit_leader_reset2; } /* @@ -8494,6 +8521,12 @@ int bnx2x_leader_reset(struct bnx2x *bp) if (global) bnx2x_clear_reset_global(bp); +exit_leader_reset2: + /* unload "fake driver" if it was loaded */ + if (!global && !BP_NOMCP(bp)) { + bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP, 0); + bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0); + } exit_leader_reset: bp->is_leader = 0; bnx2x_release_leader_lock(bp); @@ -8530,13 +8563,15 @@ static inline void bnx2x_recovery_failed(struct bnx2x *bp) static void bnx2x_parity_recover(struct bnx2x *bp) { bool global = false; + bool is_parity; DP(NETIF_MSG_HW, "Handling parity\n"); while (1) { switch (bp->recovery_state) { case BNX2X_RECOVERY_INIT: DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_INIT\n"); - bnx2x_chk_parity_attn(bp, &global, false); + is_parity = bnx2x_chk_parity_attn(bp, &global, false); + WARN_ON(!is_parity); /* Try to get a LEADER_LOCK HW lock */ if (bnx2x_trylock_leader_lock(bp)) { @@ -8560,15 +8595,6 @@ static void bnx2x_parity_recover(struct bnx2x *bp) bp->recovery_state = BNX2X_RECOVERY_WAIT; - /* - * Reset MCP command sequence number and MCP mail box - * sequence as we are going to reset the MCP. - */ - if (global) { - bp->fw_seq = 0; - bp->fw_drv_pulse_wr_seq = 0; - } - /* Ensure "is_leader", MCP command sequence and * "recovery_state" update values are seen on other * CPUs. @@ -8652,9 +8678,20 @@ static void bnx2x_parity_recover(struct bnx2x *bp) return; } - if (bnx2x_nic_load(bp, LOAD_NORMAL)) - bnx2x_recovery_failed(bp); - else { + bp->recovery_state = + BNX2X_RECOVERY_NIC_LOADING; + if (bnx2x_nic_load(bp, LOAD_NORMAL)) { + netdev_err(bp->dev, + "Recovery failed. " + "Power cycle " + "needed\n"); + /* Disconnect this device */ + netif_device_detach(bp->dev); + /* Shut down the power */ + bnx2x_set_power_state( + bp, PCI_D3hot); + smp_mb(); + } else { bp->recovery_state = BNX2X_RECOVERY_DONE; smp_mb(); @@ -8908,9 +8945,6 @@ static void __devinit bnx2x_undi_unload(struct bnx2x *bp) /* restore our func and fw_seq */ bp->pf_num = orig_pf_num; - bp->fw_seq = - (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) & - DRV_MSG_SEQ_NUMBER_MASK); } } @@ -9936,16 +9970,6 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) bnx2x_get_cnic_info(bp); - /* Get current FW pulse sequence */ - if (!BP_NOMCP(bp)) { - int mb_idx = BP_FW_MB_IDX(bp); - - bp->fw_drv_pulse_wr_seq = - (SHMEM_RD(bp, func_mb[mb_idx].drv_pulse_mb) & - DRV_PULSE_SEQ_MASK); - BNX2X_DEV_INFO("drv_pulse 0x%x\n", bp->fw_drv_pulse_wr_seq); - } - return rc; } @@ -10115,14 +10139,6 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp) if (!BP_NOMCP(bp)) bnx2x_undi_unload(bp); - /* init fw_seq after undi_unload! */ - if (!BP_NOMCP(bp)) { - bp->fw_seq = - (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & - DRV_MSG_SEQ_NUMBER_MASK); - BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); - } - if (CHIP_REV_IS_FPGA(bp)) dev_err(&bp->pdev->dev, "FPGA detected\n"); @@ -11331,13 +11347,6 @@ static void bnx2x_eeh_recover(struct bnx2x *bp) if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) BNX2X_ERR("BAD MCP validity signature\n"); - - if (!BP_NOMCP(bp)) { - bp->fw_seq = - (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & - DRV_MSG_SEQ_NUMBER_MASK); - BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); - } } /** @@ -11593,6 +11602,13 @@ static int bnx2x_cnic_sp_queue(struct net_device *dev, return -EIO; #endif + if ((bp->recovery_state != BNX2X_RECOVERY_DONE) && + (bp->recovery_state != BNX2X_RECOVERY_NIC_LOADING)) { + netdev_err(dev, "Handling parity error recovery. Try again " + "later\n"); + return -EAGAIN; + } + spin_lock_bh(&bp->spq_lock); for (i = 0; i < count; i++) { -- GitLab From 7a752993fe90adf8e150cc1a85beef5f782429e7 Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:53 +0000 Subject: [PATCH 0168/1846] bnx2x: Recoverable and unrecoverable error statistics Add statistics for tracking parity errors from which we successfully recovered and those which were deemed unrecoverable. Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 12 +++++++++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 13 +++++++++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h | 4 ++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 37a5c52197eb..06cb2442c8ff 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -175,7 +175,11 @@ static const struct { { STATS_OFFSET32(total_tpa_aggregated_frames_hi), 8, STATS_FLAGS_FUNC, "tpa_aggregated_frames"}, { STATS_OFFSET32(total_tpa_bytes_hi), - 8, STATS_FLAGS_FUNC, "tpa_bytes"} + 8, STATS_FLAGS_FUNC, "tpa_bytes"}, + { STATS_OFFSET32(recoverable_error), + 4, STATS_FLAGS_FUNC, "recoverable_errors" }, + { STATS_OFFSET32(unrecoverable_error), + 4, STATS_FLAGS_FUNC, "unrecoverable_errors" }, }; #define BNX2X_NUM_STATS ARRAY_SIZE(bnx2x_stats_arr) @@ -1388,7 +1392,8 @@ static int bnx2x_set_ringparam(struct net_device *dev, struct bnx2x *bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - pr_err("Handling parity error recovery. Try again later\n"); + netdev_err(dev, "Handling parity error recovery. " + "Try again later\n"); return -EAGAIN; } @@ -2042,7 +2047,8 @@ static void bnx2x_self_test(struct net_device *dev, struct bnx2x *bp = netdev_priv(dev); u8 is_serdes; if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - pr_err("Handling parity error recovery. Try again later\n"); + netdev_err(bp->dev, "Handling parity error recovery. " + "Try again later\n"); etest->flags |= ETH_TEST_FL_FAILED; return; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index c945df061618..cdce7663efd5 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -784,6 +784,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) #endif bp->stats_state = STATS_STATE_DISABLED; + bp->eth_stats.unrecoverable_error++; DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n"); BNX2X_ERR("begin crash dump -----------------\n"); @@ -5441,6 +5442,7 @@ static void bnx2x_init_eth_fp(struct bnx2x *bp, int fp_idx) /* init shortcut */ fp->ustorm_rx_prods_offset = bnx2x_rx_ustorm_prods_offset(fp); + /* Setup SB indicies */ fp->rx_cons_sb = BNX2X_RX_SB_INDEX; @@ -8563,6 +8565,7 @@ static inline void bnx2x_recovery_failed(struct bnx2x *bp) static void bnx2x_parity_recover(struct bnx2x *bp) { bool global = false; + u32 error_recovered, error_unrecovered; bool is_parity; DP(NETIF_MSG_HW, "Handling parity\n"); @@ -8678,9 +8681,14 @@ static void bnx2x_parity_recover(struct bnx2x *bp) return; } + error_recovered = + bp->eth_stats.recoverable_error; + error_unrecovered = + bp->eth_stats.unrecoverable_error; bp->recovery_state = BNX2X_RECOVERY_NIC_LOADING; if (bnx2x_nic_load(bp, LOAD_NORMAL)) { + error_unrecovered++; netdev_err(bp->dev, "Recovery failed. " "Power cycle " @@ -8694,8 +8702,13 @@ static void bnx2x_parity_recover(struct bnx2x *bp) } else { bp->recovery_state = BNX2X_RECOVERY_DONE; + error_recovered++; smp_mb(); } + bp->eth_stats.recoverable_error = + error_recovered; + bp->eth_stats.unrecoverable_error = + error_unrecovered; return; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h index 683deb053109..9c28db167fa7 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h @@ -199,6 +199,10 @@ struct bnx2x_eth_stats { u32 pfc_frames_received_lo; u32 pfc_frames_sent_hi; u32 pfc_frames_sent_lo; + + /* Recovery */ + u32 recoverable_error; + u32 unrecoverable_error; }; -- GitLab From 85b26ea18ee63be83d65ec6db72ad7857980a04b Mon Sep 17 00:00:00 2001 From: Ariel Elior Date: Thu, 26 Jan 2012 06:01:54 +0000 Subject: [PATCH 0169/1846] bnx2x: Update version to 1.72.0 and copyrights Signed-off-by: Ariel Elior Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 6 +++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h | 2 +- 20 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 06bbef742fa3..7d184fbffaf6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -1,6 +1,6 @@ /* bnx2x.h: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,8 +23,8 @@ * (you will need to reboot afterwards) */ /* #define BNX2X_STOP_ON_ERROR */ -#define DRV_MODULE_VERSION "1.70.35-0" -#define DRV_MODULE_RELDATE "2011/11/10" +#define DRV_MODULE_VERSION "1.72.00-0" +#define DRV_MODULE_RELDATE "2012/01/26" #define BNX2X_BC_VER 0x040200 #if defined(CONFIG_DCB) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 8fdd71b7bef0..6e6a684359b5 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1,6 +1,6 @@ /* bnx2x_cmn.c: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index a6ef3ef85e51..c7c7bf1e573a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1,6 +1,6 @@ /* bnx2x_cmn.h: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 5051cf3deb20..9a9bd3ab4793 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -1,6 +1,6 @@ /* bnx2x_dcb.c: Broadcom Everest network driver. * - * Copyright 2009-2011 Broadcom Corporation + * Copyright 2009-2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h index 2ab9254e2d5e..06c7a0435948 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h @@ -1,6 +1,6 @@ /* bnx2x_dcb.h: Broadcom Everest network driver. * - * Copyright 2009-2011 Broadcom Corporation + * Copyright 2009-2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h index b983825d0ee9..3e4cff9b1ebe 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h @@ -1,6 +1,6 @@ /* bnx2x_dump.h: Broadcom Everest network driver. * - * Copyright (c) 2011 Broadcom Corporation + * Copyright (c) 2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 06cb2442c8ff..137968d33d1e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -1,6 +1,6 @@ /* bnx2x_ethtool.c: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h index 998652a1b858..e5c5982ae06d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h @@ -1,6 +1,6 @@ /* bnx2x_fw_defs.h: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h index f4a07fbaed05..4bed52ba300d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h @@ -1,6 +1,6 @@ /* bnx2x_fw_file_hdr.h: FW binary file header structure. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h index 3e30c8642c26..78b77de728b0 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h @@ -1,6 +1,6 @@ /* bnx2x_hsi.h: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h index 4d748e77d1ac..29f5c3cca31a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h @@ -1,7 +1,7 @@ /* bnx2x_init.h: Broadcom Everest network driver. * Structures and macroes needed during the initialization. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h index f05ee2f137fd..fe66d902dc62 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h @@ -2,7 +2,7 @@ * Static functions needed during the initialization. * This file is "included" in bnx2x_main.c. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index 2091e5dbbcdd..2102ad593c14 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -1,4 +1,4 @@ -/* Copyright 2008-2011 Broadcom Corporation +/* Copyright 2008-2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h index e02a68a7fb85..9cc7bafb3dfe 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h @@ -1,4 +1,4 @@ -/* Copyright 2008-2011 Broadcom Corporation +/* Copyright 2008-2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index cdce7663efd5..fea961505391 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -1,6 +1,6 @@ /* bnx2x_main.c: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h index 8ade7bd9a717..c95d9dcac6df 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h @@ -1,6 +1,6 @@ /* bnx2x_reg.h: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 69465c32e5f6..ac15f747f8da 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -1,6 +1,6 @@ /* bnx2x_sp.c: Broadcom Everest network driver. * - * Copyright 2011 Broadcom Corporation + * Copyright (c) 2011-2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h index f33bc5722e58..71e039b618a7 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h @@ -1,6 +1,6 @@ /* bnx2x_sp.h: Broadcom Everest network driver. * - * Copyright 2011 Broadcom Corporation + * Copyright (c) 2011-2012 Broadcom Corporation * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed to you diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index bc0121ac291e..7b9b304b9107 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c @@ -1,6 +1,6 @@ /* bnx2x_stats.c: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h index 9c28db167fa7..7e979686cd68 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h @@ -1,6 +1,6 @@ /* bnx2x_stats.h: Broadcom Everest network driver. * - * Copyright (c) 2007-2011 Broadcom Corporation + * Copyright (c) 2007-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- GitLab From bb349bb4b19b39830e0486aedfd7c7dca23b7baf Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 25 Jan 2012 03:56:30 +0000 Subject: [PATCH 0170/1846] be2net: allocate more headroom in incoming skbs Allocation of 64 bytes in skb headroom is not enough if we have to pull ethernet + ipv6 + tcp headers, and/or extra tunneling header. Its currently not noticed because netdev_alloc_skb_ip_align(64) give us more room, thanks to power-of-two kmalloc() roundups. Make sure we ask for 128 bytes so that side effects of upcoming patches from Ian Campbell dont decrease benet rx performance, because of extra skb head reallocations. Signed-off-by: Eric Dumazet Cc: Ian Campbell Cc: Vasundhara Volam Cc: Sathya Perla Cc: Ajit Khaparde Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 3 +++ drivers/net/ethernet/emulex/benet/be_main.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index cbdec2536da6..453d48612f83 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -74,6 +74,9 @@ static inline char *nic_name(struct pci_dev *pdev) /* Number of bytes of an RX frame that are copied to skb->data */ #define BE_HDR_LEN ((u16) 64) +/* allocate extra space to allow tunneling decapsulation without head reallocation */ +#define BE_RX_SKB_ALLOC_SIZE (BE_HDR_LEN + 64) + #define BE_MAX_JUMBO_FRAME_SIZE 9018 #define BE_MIN_MTU 256 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index e703d64434f8..0fbf365f5c62 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -1189,7 +1189,7 @@ static void be_rx_compl_process(struct be_adapter *adapter, struct net_device *netdev = adapter->netdev; struct sk_buff *skb; - skb = netdev_alloc_skb_ip_align(netdev, BE_HDR_LEN); + skb = netdev_alloc_skb_ip_align(netdev, BE_RX_SKB_ALLOC_SIZE); if (unlikely(!skb)) { rx_stats(rxo)->rx_drops_no_skbs++; be_rx_compl_discard(adapter, rxo, rxcp); -- GitLab From 09e9b813d34d9a09d64a64580a9959d8bae1f4f5 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 25 Jan 2012 04:44:20 +0000 Subject: [PATCH 0171/1846] tcp: add LINUX_MIB_TCPRETRANSFAIL counter It might be useful to get a counter of failed tcp_retransmit_skb() calls. Reported-by: Satoru Moriya Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/snmp.h | 1 + net/ipv4/proc.c | 1 + net/ipv4/tcp_output.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/snmp.h b/include/linux/snmp.h index c1241c428179..8ee8af4e6da9 100644 --- a/include/linux/snmp.h +++ b/include/linux/snmp.h @@ -232,6 +232,7 @@ enum LINUX_MIB_TCPTIMEWAITOVERFLOW, /* TCPTimeWaitOverflow */ LINUX_MIB_TCPREQQFULLDOCOOKIES, /* TCPReqQFullDoCookies */ LINUX_MIB_TCPREQQFULLDROP, /* TCPReqQFullDrop */ + LINUX_MIB_TCPRETRANSFAIL, /* TCPRetransFail */ __LINUX_MIB_MAX }; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 6afc807ee2ad..02d61079f08b 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -256,6 +256,7 @@ static const struct snmp_mib snmp4_net_list[] = { SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW), SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES), SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP), + SNMP_MIB_ITEM("TCPRetransFail", LINUX_MIB_TCPRETRANSFAIL), SNMP_MIB_SENTINEL }; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 8c8de2780c7a..561550ab3c30 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2308,8 +2308,10 @@ void tcp_xmit_retransmit_queue(struct sock *sk) if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS)) continue; - if (tcp_retransmit_skb(sk, skb)) + if (tcp_retransmit_skb(sk, skb)) { + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL); return; + } NET_INC_STATS_BH(sock_net(sk), mib_idx); if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery) -- GitLab From 39232973b779ab0c02cb6dcd8f819b7cb0fcd09a Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 26 Jan 2012 15:22:32 -0500 Subject: [PATCH 0172/1846] ipv4/ipv6: Prepare for new route gateway semantics. In the future the ipv4/ipv6 route gateway will take on two types of values: 1) INADDR_ANY/IN6ADDR_ANY, for local network routes, and in this case the neighbour must be obtained using the destination address in ipv4/ipv6 header as the lookup key. 2) Everything else, the actual nexthop route address. So if the gateway is not inaddr-any we use it, otherwise we must use the packet's destination address. Signed-off-by: David S. Miller --- net/ipv4/route.c | 5 +++++ net/ipv6/route.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index bcacf54e5418..4eeb8ce856e2 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1117,10 +1117,15 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, const vo static const __be32 inaddr_any = 0; struct net_device *dev = dst->dev; const __be32 *pkey = daddr; + const struct rtable *rt; struct neighbour *n; + rt = (const struct rtable *) dst; + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) pkey = &inaddr_any; + else if (rt->rt_gateway) + pkey = (const __be32 *) &rt->rt_gateway; n = __ipv4_neigh_lookup(&arp_tbl, dev, *(__force u32 *)pkey); if (n) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 8c2e3ab58f2a..7d7f30697ead 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -121,9 +121,23 @@ static u32 *ipv6_cow_metrics(struct dst_entry *dst, unsigned long old) return p; } +static inline const void *choose_neigh_daddr(struct rt6_info *rt, const void *daddr) +{ + struct in6_addr *p = &rt->rt6i_gateway; + + if (p->s6_addr32[0] | p->s6_addr32[1] | + p->s6_addr32[2] | p->s6_addr32[3]) + return (const void *) p; + return daddr; +} + static struct neighbour *ip6_neigh_lookup(const struct dst_entry *dst, const void *daddr) { - struct neighbour *n = __ipv6_neigh_lookup(&nd_tbl, dst->dev, daddr); + struct rt6_info *rt = (struct rt6_info *) dst; + struct neighbour *n; + + daddr = choose_neigh_daddr(rt, daddr); + n = __ipv6_neigh_lookup(&nd_tbl, dst->dev, daddr); if (n) return n; return neigh_create(&nd_tbl, daddr, dst->dev); -- GitLab From 1e2927b08160a14fff98e88e7a331d916aaa1d56 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 26 Jan 2012 15:23:21 -0500 Subject: [PATCH 0173/1846] ipv6: sit: Convert to dst_neigh_lookup() The only semantic difference is that we now hold a reference to the neighbour and thus have to release it. Signed-off-by: David S. Miller --- net/ipv6/sit.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 133768e52912..c4ffd1743528 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -680,9 +680,10 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, /* ISATAP (RFC4214) - must come before 6to4 */ if (dev->priv_flags & IFF_ISATAP) { struct neighbour *neigh = NULL; + bool do_tx_error = false; if (skb_dst(skb)) - neigh = dst_get_neighbour_noref(skb_dst(skb)); + neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr); if (neigh == NULL) { if (net_ratelimit()) @@ -697,6 +698,10 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, ipv6_addr_is_isatap(addr6)) dst = addr6->s6_addr32[3]; else + do_tx_error = true; + + neigh_release(neigh); + if (do_tx_error) goto tx_error; } @@ -705,9 +710,10 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, if (!dst) { struct neighbour *neigh = NULL; + bool do_tx_error = false; if (skb_dst(skb)) - neigh = dst_get_neighbour_noref(skb_dst(skb)); + neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr); if (neigh == NULL) { if (net_ratelimit()) @@ -723,10 +729,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, addr_type = ipv6_addr_type(addr6); } - if ((addr_type & IPV6_ADDR_COMPATv4) == 0) - goto tx_error_icmp; + if ((addr_type & IPV6_ADDR_COMPATv4) != 0) + dst = addr6->s6_addr32[3]; + else + do_tx_error = true; - dst = addr6->s6_addr32[3]; + neigh_release(neigh); + if (do_tx_error) + goto tx_error; } rt = ip_route_output_ports(dev_net(dev), &fl4, NULL, -- GitLab From c85c21ad1fe18daf26bfe8684df974d88cec50b7 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 26 Jan 2012 16:25:55 -0500 Subject: [PATCH 0174/1846] e1000e: Need to include vmalloc.h Otherwise (on sparc64): drivers/net/ethernet/intel/e1000e/ethtool.c:657:3: error: implicit declaration of function 'vmalloc' [-Werror=implicit-function-declaration] Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/e1000e/ethtool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index ffb6c14cbbb8..1ea317f1adcf 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "e1000.h" -- GitLab From a7563f342db6490e66dbf2c8a50577a72a158c9a Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 26 Jan 2012 16:29:16 -0500 Subject: [PATCH 0175/1846] ipv6: Use ipv6_addr_any() Suggested by YOSHIFUJI Hideaki. Signed-off-by: David S. Miller --- net/ipv6/route.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 7d7f30697ead..92be12bb8d23 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -125,8 +125,7 @@ static inline const void *choose_neigh_daddr(struct rt6_info *rt, const void *da { struct in6_addr *p = &rt->rt6i_gateway; - if (p->s6_addr32[0] | p->s6_addr32[1] | - p->s6_addr32[2] | p->s6_addr32[3]) + if (!ipv6_addr_any(p)) return (const void *) p; return daddr; } -- GitLab From e332bcb3d149644c344ee5fdf1f6e4ac39e9d9a3 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 20 Dec 2011 01:22:51 +0000 Subject: [PATCH 0176/1846] sfc: Remove fallback for invalid permanent MAC address By the time we look at the MAC address in efx_probe_port(), either the driver or the firmware has already validated the board configuration. The possibility of having an invalid MAC address just isn't worth considering. It certainly isn't worth having a compile-time option for this. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index d7301d2e81a7..eff5d300aa0a 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -122,15 +122,6 @@ static int napi_weight = 64; */ static unsigned int efx_monitor_interval = 1 * HZ; -/* This controls whether or not the driver will initialise devices - * with invalid MAC addresses stored in the EEPROM or flash. If true, - * such devices will be initialised with a random locally-generated - * MAC address. This allows for loading the sfc_mtd driver to - * reprogram the flash, even if the flash contents (including the MAC - * address) have previously been erased. - */ -static unsigned int allow_bad_hwaddr; - /* Initial interrupt moderation settings. They can be modified after * module load with ethtool. * @@ -916,7 +907,6 @@ static void efx_mac_work(struct work_struct *data) static int efx_probe_port(struct efx_nic *efx) { - unsigned char *perm_addr; int rc; netif_dbg(efx, probe, efx->net_dev, "create port\n"); @@ -929,28 +919,10 @@ static int efx_probe_port(struct efx_nic *efx) if (rc) return rc; - /* Sanity check MAC address */ - perm_addr = efx->net_dev->perm_addr; - if (is_valid_ether_addr(perm_addr)) { - memcpy(efx->net_dev->dev_addr, perm_addr, ETH_ALEN); - } else { - netif_err(efx, probe, efx->net_dev, "invalid MAC address %pM\n", - perm_addr); - if (!allow_bad_hwaddr) { - rc = -EINVAL; - goto err; - } - random_ether_addr(efx->net_dev->dev_addr); - netif_info(efx, probe, efx->net_dev, - "using locally-generated MAC %pM\n", - efx->net_dev->dev_addr); - } + /* Initialise MAC address to permanent address */ + memcpy(efx->net_dev->dev_addr, efx->net_dev->perm_addr, ETH_ALEN); return 0; - - err: - efx->type->remove_port(efx); - return rc; } static int efx_init_port(struct efx_nic *efx) -- GitLab From 3f713bf4dd9f7ef2a2c5e9ec124b3d992a2669db Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 20 Dec 2011 23:39:31 +0000 Subject: [PATCH 0177/1846] sfc: Make handling of MC reboot more reliable When the MC reboots, either as part of a firmware upgrade or due to a bug, it attempts to complete (with an error) any requests that were outstanding before the reboot. Since there is an inherent race condition in checking this, it will also write to a status word in shared memory. If we look at each of these separately, we may detect each reboot twice, resulting in a spurious command failure after a firmware upgrade or frustrating recovery from a firmware bug. Instead, if a request completion indicates a reboot, we must poll and clear the status word. This bug was previously masked by use of an incorrect address for the status word. Fix that, using the definition now included in mcdi_pcol.h. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mcdi.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index 7c405d16692e..f16145d92817 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -27,8 +27,6 @@ #define CMD_NOTIFY_PORT1 4 #define CMD_PDU_PORT0 0x008 #define CMD_PDU_PORT1 0x108 -#define REBOOT_FLAG_PORT0 0x3f8 -#define REBOOT_FLAG_PORT1 0x3fc #define MCDI_RPC_TIMEOUT 10 /*seconds */ @@ -36,8 +34,16 @@ (efx_port_num(efx) ? CMD_PDU_PORT1 : CMD_PDU_PORT0) #define MCDI_DOORBELL(efx) \ (efx_port_num(efx) ? CMD_NOTIFY_PORT1 : CMD_NOTIFY_PORT0) -#define MCDI_REBOOT_FLAG(efx) \ - (efx_port_num(efx) ? REBOOT_FLAG_PORT1 : REBOOT_FLAG_PORT0) +#define MCDI_STATUS(efx) \ + (efx_port_num(efx) ? MC_SMEM_P1_STATUS_OFST : MC_SMEM_P0_STATUS_OFST) + +/* A reboot/assertion causes the MCDI status word to be set after the + * command word is set or a REBOOT event is sent. If we notice a reboot + * via these mechanisms then wait 10ms for the status word to be set. */ +#define MCDI_STATUS_DELAY_US 100 +#define MCDI_STATUS_DELAY_COUNT 100 +#define MCDI_STATUS_SLEEP_MS \ + (MCDI_STATUS_DELAY_US * MCDI_STATUS_DELAY_COUNT / 1000) #define SEQ_MASK \ EFX_MASK32(EFX_WIDTH(MCDI_HEADER_SEQ)) @@ -210,7 +216,7 @@ static int efx_mcdi_poll(struct efx_nic *efx) /* Test and clear MC-rebooted flag for this port/function */ int efx_mcdi_poll_reboot(struct efx_nic *efx) { - unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG(efx); + unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_STATUS(efx); efx_dword_t reg; uint32_t value; @@ -384,6 +390,11 @@ int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, netif_dbg(efx, hw, efx->net_dev, "MC command 0x%x inlen %d failed rc=%d\n", cmd, (int)inlen, -rc); + + if (rc == -EIO || rc == -EINTR) { + msleep(MCDI_STATUS_SLEEP_MS); + efx_mcdi_poll_reboot(efx); + } } efx_mcdi_release(mcdi); @@ -465,10 +476,20 @@ static void efx_mcdi_ev_death(struct efx_nic *efx, int rc) mcdi->resplen = 0; ++mcdi->credits; } - } else + } else { + int count; + /* Nobody was waiting for an MCDI request, so trigger a reset */ efx_schedule_reset(efx, RESET_TYPE_MC_FAILURE); + /* Consume the status word since efx_mcdi_rpc_finish() won't */ + for (count = 0; count < MCDI_STATUS_DELAY_COUNT; ++count) { + if (efx_mcdi_poll_reboot(efx)) + break; + udelay(MCDI_STATUS_DELAY_US); + } + } + spin_unlock(&mcdi->iface_lock); } -- GitLab From 788ec41cc843f12e8d0eba5f2b37af18b76654a5 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 20 Dec 2011 23:52:02 +0000 Subject: [PATCH 0178/1846] sfc: Use new names for MC shared memory layout constants These are defined alongside the firmware protocol in mcdi_pcol.h. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mcdi.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index f16145d92817..e5837a6485a1 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -22,18 +22,12 @@ ************************************************************************** */ -/* Software-defined structure to the shared-memory */ -#define CMD_NOTIFY_PORT0 0 -#define CMD_NOTIFY_PORT1 4 -#define CMD_PDU_PORT0 0x008 -#define CMD_PDU_PORT1 0x108 - #define MCDI_RPC_TIMEOUT 10 /*seconds */ #define MCDI_PDU(efx) \ - (efx_port_num(efx) ? CMD_PDU_PORT1 : CMD_PDU_PORT0) + (efx_port_num(efx) ? MC_SMEM_P1_PDU_OFST : MC_SMEM_P0_PDU_OFST) #define MCDI_DOORBELL(efx) \ - (efx_port_num(efx) ? CMD_NOTIFY_PORT1 : CMD_NOTIFY_PORT0) + (efx_port_num(efx) ? MC_SMEM_P1_DOORBELL_OFST : MC_SMEM_P0_DOORBELL_OFST) #define MCDI_STATUS(efx) \ (efx_port_num(efx) ? MC_SMEM_P1_STATUS_OFST : MC_SMEM_P0_STATUS_OFST) @@ -83,7 +77,7 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd, u32 xflags, seqno; BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); - BUG_ON(inlen & 3 || inlen >= 0x100); + BUG_ON(inlen & 3 || inlen >= MC_SMEM_PDU_LEN); seqno = mcdi->seqno & SEQ_MASK; xflags = 0; @@ -117,7 +111,7 @@ static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen) int i; BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); - BUG_ON(outlen & 3 || outlen >= 0x100); + BUG_ON(outlen & 3 || outlen >= MC_SMEM_PDU_LEN); for (i = 0; i < outlen; i += 4) *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i); -- GitLab From 1cb345220f135dcca24f01cc04cbb97a8242d419 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 2 Sep 2011 23:23:00 +0100 Subject: [PATCH 0179/1846] sfc: Hold efx_nic::stats_lock while reading efx_nic::mac_stats efx_nic::stats_lock is used to serialise stats updates, but each reader was dropping it before it finished reading efx_nic::mac_stats. If there were concurrent stats reads using procfs, or one using procfs and one using ethtool, an update could race with a read. On a 32-bit system, the reader could see word-tearing of 64-bit stats (32 bits of the old value and 32 bits of the new). Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 4 +++- drivers/net/ethernet/sfc/ethtool.c | 7 +++++-- drivers/net/ethernet/sfc/net_driver.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index eff5d300aa0a..8f4cbb642bf2 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1743,8 +1743,8 @@ static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev, struc struct efx_mac_stats *mac_stats = &efx->mac_stats; spin_lock_bh(&efx->stats_lock); + efx->type->update_stats(efx); - spin_unlock_bh(&efx->stats_lock); stats->rx_packets = mac_stats->rx_packets; stats->tx_packets = mac_stats->tx_packets; @@ -1768,6 +1768,8 @@ static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev, struc stats->tx_errors = (stats->tx_window_errors + mac_stats->tx_bad); + spin_unlock_bh(&efx->stats_lock); + return stats; } diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 52c9ee4c8aa3..55a25b14d304 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -489,13 +489,14 @@ static void efx_ethtool_get_stats(struct net_device *net_dev, const struct efx_ethtool_stat *stat; struct efx_channel *channel; struct efx_tx_queue *tx_queue; - struct rtnl_link_stats64 temp; int i; EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS); + spin_lock_bh(&efx->stats_lock); + /* Update MAC and NIC statistics */ - dev_get_stats(net_dev, &temp); + efx->type->update_stats(efx); /* Fill detailed statistics buffer */ for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) { @@ -525,6 +526,8 @@ static void efx_ethtool_get_stats(struct net_device *net_dev, break; } } + + spin_unlock_bh(&efx->stats_lock); } static void efx_ethtool_self_test(struct net_device *net_dev, diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 9353ce801752..b6040141ef79 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -704,6 +704,7 @@ struct efx_filter_state; * can provide. Generic code converts these into a standard * &struct net_device_stats. * @stats_lock: Statistics update lock. Serialises statistics fetches + * and access to @mac_stats. * * This is stored in the private area of the &struct net_device. */ -- GitLab From 710b208dc2687fdb3370110d54a67fb2288835eb Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sat, 3 Sep 2011 00:15:00 +0100 Subject: [PATCH 0180/1846] sfc: Merge efx_mac_operations into efx_nic_type No NICs need to switch efx_mac_operations at run-time, and the MAC operations are fairly closely bound to NIC types. Move efx_mac_operations::reconfigure to efx_nic_type::reconfigure_mac and efx_mac_operations::check_fault fo efx_nic_type::check_mac_fault. Change callers to call through efx->type or directly if the NIC type is known. Remove efx_mac_operations::update_stats. The implementations for Falcon used to fetch MAC statistics synchronously and this was used by efx_register_netdev() to clear statistics after running self-tests. However, it now only converts statistics that have already been fetched (and that only for Falcon), and the call from efx_register_netdev() has no effect. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 17 ++++++----------- drivers/net/ethernet/sfc/ethtool.c | 4 ++-- drivers/net/ethernet/sfc/falcon.c | 15 ++++++++------- drivers/net/ethernet/sfc/falcon_xmac.c | 13 +++---------- drivers/net/ethernet/sfc/mac.h | 21 --------------------- drivers/net/ethernet/sfc/mcdi.h | 4 ++++ drivers/net/ethernet/sfc/mcdi_mac.c | 12 ++---------- drivers/net/ethernet/sfc/net_driver.h | 21 ++++----------------- drivers/net/ethernet/sfc/nic.h | 3 +++ drivers/net/ethernet/sfc/selftest.c | 2 +- drivers/net/ethernet/sfc/siena.c | 4 ++-- 11 files changed, 35 insertions(+), 81 deletions(-) delete mode 100644 drivers/net/ethernet/sfc/mac.h diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 8f4cbb642bf2..1d20e01c6aea 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -900,7 +900,7 @@ static void efx_mac_work(struct work_struct *data) mutex_lock(&efx->mac_lock); if (efx->port_enabled) { efx->type->push_multicast_hash(efx); - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); } mutex_unlock(&efx->mac_lock); } @@ -941,7 +941,7 @@ static int efx_init_port(struct efx_nic *efx) /* Reconfigure the MAC before creating dma queues (required for * Falcon/A1 where RX_INGR_EN/TX_DRAIN_EN isn't supported) */ - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); /* Ensure the PHY advertises the correct flow control settings */ rc = efx->phy_op->reconfigure(efx); @@ -969,7 +969,7 @@ static void efx_start_port(struct efx_nic *efx) /* efx_mac_work() might have been scheduled after efx_stop_port(), * and then cancelled by efx_flush_all() */ efx->type->push_multicast_hash(efx); - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); mutex_unlock(&efx->mac_lock); } @@ -1807,7 +1807,7 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu) /* Reconfigure the MAC before enabling the dma queues so that * the RX buffers don't overflow */ net_dev->mtu = new_mtu; - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); mutex_unlock(&efx->mac_lock); efx_init_channels(efx); @@ -1835,7 +1835,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) /* Reconfigure the MAC */ mutex_lock(&efx->mac_lock); - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); mutex_unlock(&efx->mac_lock); return 0; @@ -1949,10 +1949,6 @@ static int efx_register_netdev(struct efx_nic *efx) net_dev->netdev_ops = &efx_netdev_ops; SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops); - /* Clear MAC statistics */ - efx->mac_op->update_stats(efx); - memset(&efx->mac_stats, 0, sizeof(efx->mac_stats)); - rtnl_lock(); rc = dev_alloc_name(net_dev, net_dev->name); @@ -2069,7 +2065,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) "could not restore PHY settings\n"); } - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); efx_init_channels(efx); efx_restore_filters(efx); @@ -2274,7 +2270,6 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type, efx->net_dev = net_dev; spin_lock_init(&efx->stats_lock); mutex_init(&efx->mac_lock); - efx->mac_op = type->default_mac_ops; efx->phy_op = &efx_dummy_phy_operations; efx->mdio.dev = net_dev; INIT_WORK(&efx->mac_work, efx_mac_work); diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 55a25b14d304..1a7f7ba27bea 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -750,7 +750,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev, /* Recover by resetting the EM block */ falcon_stop_nic_stats(efx); falcon_drain_tx_fifo(efx); - efx->mac_op->reconfigure(efx); + falcon_reconfigure_xmac(efx); falcon_start_nic_stats(efx); } else { /* Schedule a reset to recover */ @@ -775,7 +775,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev, /* Reconfigure the MAC. The PHY *may* generate a link state change event * if the user just changed the advertised capabilities, but there's no * harm doing this twice */ - efx->mac_op->reconfigure(efx); + efx->type->reconfigure_mac(efx); out: mutex_unlock(&efx->mac_lock); diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index 5c7548959dd7..1a8a316bb538 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -19,7 +19,6 @@ #include "net_driver.h" #include "bitfield.h" #include "efx.h" -#include "mac.h" #include "spi.h" #include "nic.h" #include "regs.h" @@ -613,7 +612,7 @@ static void falcon_stats_complete(struct efx_nic *efx) nic_data->stats_pending = false; if (*nic_data->stats_dma_done == FALCON_STATS_DONE) { rmb(); /* read the done flag before the stats */ - efx->mac_op->update_stats(efx); + falcon_update_stats_xmac(efx); } else { netif_err(efx, hw, efx->net_dev, "timed out waiting for statistics\n"); @@ -670,7 +669,7 @@ static int falcon_reconfigure_port(struct efx_nic *efx) falcon_reset_macs(efx); efx->phy_op->reconfigure(efx); - rc = efx->mac_op->reconfigure(efx); + rc = falcon_reconfigure_xmac(efx); BUG_ON(rc); falcon_start_nic_stats(efx); @@ -1218,7 +1217,7 @@ static void falcon_monitor(struct efx_nic *efx) falcon_deconfigure_mac_wrapper(efx); falcon_reset_macs(efx); - rc = efx->mac_op->reconfigure(efx); + rc = falcon_reconfigure_xmac(efx); BUG_ON(rc); falcon_start_nic_stats(efx); @@ -1676,7 +1675,7 @@ static void falcon_update_nic_stats(struct efx_nic *efx) *nic_data->stats_dma_done == FALCON_STATS_DONE) { nic_data->stats_pending = false; rmb(); /* read the done flag before the stats */ - efx->mac_op->update_stats(efx); + falcon_update_stats_xmac(efx); } } @@ -1769,11 +1768,12 @@ const struct efx_nic_type falcon_a1_nic_type = { .push_irq_moderation = falcon_push_irq_moderation, .push_multicast_hash = falcon_push_multicast_hash, .reconfigure_port = falcon_reconfigure_port, + .reconfigure_mac = falcon_reconfigure_xmac, + .check_mac_fault = falcon_xmac_check_fault, .get_wol = falcon_get_wol, .set_wol = falcon_set_wol, .resume_wol = efx_port_dummy_op_void, .test_nvram = falcon_test_nvram, - .default_mac_ops = &falcon_xmac_operations, .revision = EFX_REV_FALCON_A1, .mem_map_size = 0x20000, @@ -1811,12 +1811,13 @@ const struct efx_nic_type falcon_b0_nic_type = { .push_irq_moderation = falcon_push_irq_moderation, .push_multicast_hash = falcon_push_multicast_hash, .reconfigure_port = falcon_reconfigure_port, + .reconfigure_mac = falcon_reconfigure_xmac, + .check_mac_fault = falcon_xmac_check_fault, .get_wol = falcon_get_wol, .set_wol = falcon_set_wol, .resume_wol = efx_port_dummy_op_void, .test_registers = falcon_b0_test_registers, .test_nvram = falcon_test_nvram, - .default_mac_ops = &falcon_xmac_operations, .revision = EFX_REV_FALCON_B0, /* Map everything up to and including the RSS indirection diff --git a/drivers/net/ethernet/sfc/falcon_xmac.c b/drivers/net/ethernet/sfc/falcon_xmac.c index 57434593f07b..6106ef15dee3 100644 --- a/drivers/net/ethernet/sfc/falcon_xmac.c +++ b/drivers/net/ethernet/sfc/falcon_xmac.c @@ -14,7 +14,6 @@ #include "nic.h" #include "regs.h" #include "io.h" -#include "mac.h" #include "mdio_10g.h" #include "workarounds.h" @@ -270,12 +269,12 @@ static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries) return mac_up; } -static bool falcon_xmac_check_fault(struct efx_nic *efx) +bool falcon_xmac_check_fault(struct efx_nic *efx) { return !falcon_xmac_link_ok_retry(efx, 5); } -static int falcon_reconfigure_xmac(struct efx_nic *efx) +int falcon_reconfigure_xmac(struct efx_nic *efx) { struct falcon_nic_data *nic_data = efx->nic_data; @@ -290,7 +289,7 @@ static int falcon_reconfigure_xmac(struct efx_nic *efx) return 0; } -static void falcon_update_stats_xmac(struct efx_nic *efx) +void falcon_update_stats_xmac(struct efx_nic *efx) { struct efx_mac_stats *mac_stats = &efx->mac_stats; @@ -361,9 +360,3 @@ void falcon_poll_xmac(struct efx_nic *efx) nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1); falcon_ack_status_intr(efx); } - -const struct efx_mac_operations falcon_xmac_operations = { - .reconfigure = falcon_reconfigure_xmac, - .update_stats = falcon_update_stats_xmac, - .check_fault = falcon_xmac_check_fault, -}; diff --git a/drivers/net/ethernet/sfc/mac.h b/drivers/net/ethernet/sfc/mac.h deleted file mode 100644 index d6a255d0856b..000000000000 --- a/drivers/net/ethernet/sfc/mac.h +++ /dev/null @@ -1,21 +0,0 @@ -/**************************************************************************** - * Driver for Solarflare Solarstorm network controllers and boards - * Copyright 2005-2006 Fen Systems Ltd. - * Copyright 2006-2009 Solarflare Communications Inc. - * - * 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, incorporated herein by reference. - */ - -#ifndef EFX_MAC_H -#define EFX_MAC_H - -#include "net_driver.h" - -extern const struct efx_mac_operations falcon_xmac_operations; -extern const struct efx_mac_operations efx_mcdi_mac_operations; -extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, - u32 dma_len, int enable, int clear); - -#endif diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index aced2a7856fc..c59667bf64ac 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -126,5 +126,9 @@ extern int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx, extern int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out); extern int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id); extern int efx_mcdi_wol_filter_reset(struct efx_nic *efx); +extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, + u32 dma_len, int enable, int clear); +extern int efx_mcdi_mac_reconfigure(struct efx_nic *efx); +extern bool efx_mcdi_mac_check_fault(struct efx_nic *efx); #endif /* EFX_MCDI_H */ diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index 85fe24f86396..4907062b24a2 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -9,7 +9,6 @@ #include "net_driver.h" #include "efx.h" -#include "mac.h" #include "mcdi.h" #include "mcdi_pcol.h" @@ -115,7 +114,7 @@ int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, return rc; } -static int efx_mcdi_mac_reconfigure(struct efx_nic *efx) +int efx_mcdi_mac_reconfigure(struct efx_nic *efx) { int rc; @@ -130,16 +129,9 @@ static int efx_mcdi_mac_reconfigure(struct efx_nic *efx) } -static bool efx_mcdi_mac_check_fault(struct efx_nic *efx) +bool efx_mcdi_mac_check_fault(struct efx_nic *efx) { u32 faults; int rc = efx_mcdi_get_mac_faults(efx, &faults); return (rc != 0) || (faults != 0); } - - -const struct efx_mac_operations efx_mcdi_mac_operations = { - .reconfigure = efx_mcdi_mac_reconfigure, - .update_stats = efx_port_dummy_op_void, - .check_fault = efx_mcdi_mac_check_fault, -}; diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index b6040141ef79..aa5a321a1419 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -473,18 +473,6 @@ static inline bool efx_link_state_equal(const struct efx_link_state *left, left->fc == right->fc && left->speed == right->speed; } -/** - * struct efx_mac_operations - Efx MAC operations table - * @reconfigure: Reconfigure MAC. Serialised by the mac_lock - * @update_stats: Update statistics - * @check_fault: Check fault state. True if fault present. - */ -struct efx_mac_operations { - int (*reconfigure) (struct efx_nic *efx); - void (*update_stats) (struct efx_nic *efx); - bool (*check_fault)(struct efx_nic *efx); -}; - /** * struct efx_phy_operations - Efx PHY operations table * @probe: Probe PHY and initialise efx->mdio.mode_support, efx->mdio.mmds, @@ -676,7 +664,6 @@ struct efx_filter_state; * @port_initialized: Port initialized? * @net_dev: Operating system network device. Consider holding the rtnl lock * @stats_buffer: DMA buffer for statistics - * @mac_op: MAC interface * @phy_type: PHY type * @phy_op: PHY interface * @phy_data: PHY private data (including PHY-specific stats) @@ -767,8 +754,6 @@ struct efx_nic { struct efx_buffer stats_buffer; - const struct efx_mac_operations *mac_op; - unsigned int phy_type; const struct efx_phy_operations *phy_op; void *phy_data; @@ -843,12 +828,13 @@ static inline unsigned int efx_port_num(struct efx_nic *efx) * @push_irq_moderation: Apply interrupt moderation value * @push_multicast_hash: Apply multicast hash table * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY + * @reconfigure_mac: Reconfigure MAC only. Serialised by the mac_lock + * @check_mac_fault: Check MAC fault state. True if fault present. * @get_wol: Get WoL configuration from driver state * @set_wol: Push WoL configuration to the NIC * @resume_wol: Synchronise WoL state between driver and MC (e.g. after resume) * @test_registers: Test read/write functionality of control registers * @test_nvram: Test validity of NVRAM contents - * @default_mac_ops: efx_mac_operations to set at startup * @revision: Hardware architecture revision * @mem_map_size: Memory BAR mapped size * @txd_ptr_tbl_base: TX descriptor ring base address @@ -888,12 +874,13 @@ struct efx_nic_type { void (*push_irq_moderation)(struct efx_channel *channel); void (*push_multicast_hash)(struct efx_nic *efx); int (*reconfigure_port)(struct efx_nic *efx); + int (*reconfigure_mac)(struct efx_nic *efx); + bool (*check_mac_fault)(struct efx_nic *efx); void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol); int (*set_wol)(struct efx_nic *efx, u32 type); void (*resume_wol)(struct efx_nic *efx); int (*test_registers)(struct efx_nic *efx); int (*test_nvram)(struct efx_nic *efx); - const struct efx_mac_operations *default_mac_ops; int revision; unsigned int mem_map_size; diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 5fb24d3aa3ca..cfda6ded24fe 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -189,6 +189,9 @@ extern bool efx_nic_event_present(struct efx_channel *channel); /* MAC/PHY */ extern void falcon_drain_tx_fifo(struct efx_nic *efx); extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx); +extern bool falcon_xmac_check_fault(struct efx_nic *efx); +extern int falcon_reconfigure_xmac(struct efx_nic *efx); +extern void falcon_update_stats_xmac(struct efx_nic *efx); /* Interrupts and test events */ extern int efx_nic_init_interrupt(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 5226d9857f30..9df2a7942509 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -569,7 +569,7 @@ static int efx_wait_for_link(struct efx_nic *efx) mutex_lock(&efx->mac_lock); link_up = link_state->up; if (link_up) - link_up = !efx->mac_op->check_fault(efx); + link_up = !efx->type->check_mac_fault(efx); mutex_unlock(&efx->mac_lock); if (link_up) { diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index 4d5d619feaa6..775b6784cbdb 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -18,7 +18,6 @@ #include "bitfield.h" #include "efx.h" #include "nic.h" -#include "mac.h" #include "spi.h" #include "regs.h" #include "io.h" @@ -631,13 +630,14 @@ const struct efx_nic_type siena_a0_nic_type = { .set_id_led = efx_mcdi_set_id_led, .push_irq_moderation = siena_push_irq_moderation, .push_multicast_hash = siena_push_multicast_hash, + .reconfigure_mac = efx_mcdi_mac_reconfigure, + .check_mac_fault = efx_mcdi_mac_check_fault, .reconfigure_port = efx_mcdi_phy_reconfigure, .get_wol = siena_get_wol, .set_wol = siena_set_wol, .resume_wol = siena_init_wol, .test_registers = siena_test_registers, .test_nvram = efx_mcdi_nvram_test_all, - .default_mac_ops = &efx_mcdi_mac_operations, .revision = EFX_REV_SIENA_A0, .mem_map_size = (FR_CZ_MC_TREG_SMEM + -- GitLab From 1daf417029ddc10b7854430c1e1118df791d0eaf Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 8 Sep 2011 02:09:42 +0100 Subject: [PATCH 0181/1846] sfc: Merge efx_mcdi_mac_check_fault() and efx_mcdi_get_mac_faults() The latter is only called by the former, which is a very short wrapper. Further, gcc 4.5 may currently wrongly warn that the 'faults' variable may be used uninitialised. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mcdi_mac.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index 4907062b24a2..559d79861faf 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -51,7 +51,7 @@ static int efx_mcdi_set_mac(struct efx_nic *efx) NULL, 0, NULL); } -static int efx_mcdi_get_mac_faults(struct efx_nic *efx, u32 *faults) +bool efx_mcdi_mac_check_fault(struct efx_nic *efx) { u8 outbuf[MC_CMD_GET_LINK_OUT_LEN]; size_t outlength; @@ -61,16 +61,13 @@ static int efx_mcdi_get_mac_faults(struct efx_nic *efx, u32 *faults) rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, outbuf, sizeof(outbuf), &outlength); - if (rc) - goto fail; - - *faults = MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT); - return 0; + if (rc) { + netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", + __func__, rc); + return true; + } -fail: - netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", - __func__, rc); - return rc; + return MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT) != 0; } int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, @@ -127,11 +124,3 @@ int efx_mcdi_mac_reconfigure(struct efx_nic *efx) return 0; } - - -bool efx_mcdi_mac_check_fault(struct efx_nic *efx) -{ - u32 faults; - int rc = efx_mcdi_get_mac_faults(efx, &faults); - return (rc != 0) || (faults != 0); -} -- GitLab From 30b81cda9516878906b44fed16aac9df1dbb89c7 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 13 Sep 2011 19:47:48 +0100 Subject: [PATCH 0182/1846] sfc: Remove efx_nic_type::push_multicast_hash operation Both implementations of efx_nic_type::reconfigure_mac operation push the multicast hash filter to the hardware. It is therefore redundant to call efx_nic_type::push_multicast_hash as well. efx_mcdi_mac_reconfigure() also uses this operation, but the implementation for Siena just uses MCDI anyway. Merge that into efx_mcdi_mac_reconfigure(). Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 5 +---- drivers/net/ethernet/sfc/falcon.c | 2 -- drivers/net/ethernet/sfc/mcdi_mac.c | 10 ++++++---- drivers/net/ethernet/sfc/net_driver.h | 5 ++--- drivers/net/ethernet/sfc/siena.c | 10 ---------- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 1d20e01c6aea..de162474c3c5 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -898,10 +898,8 @@ static void efx_mac_work(struct work_struct *data) struct efx_nic *efx = container_of(data, struct efx_nic, mac_work); mutex_lock(&efx->mac_lock); - if (efx->port_enabled) { - efx->type->push_multicast_hash(efx); + if (efx->port_enabled) efx->type->reconfigure_mac(efx); - } mutex_unlock(&efx->mac_lock); } @@ -968,7 +966,6 @@ static void efx_start_port(struct efx_nic *efx) /* efx_mac_work() might have been scheduled after efx_stop_port(), * and then cancelled by efx_flush_all() */ - efx->type->push_multicast_hash(efx); efx->type->reconfigure_mac(efx); mutex_unlock(&efx->mac_lock); diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index 1a8a316bb538..fe21c7e349b6 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -1766,7 +1766,6 @@ const struct efx_nic_type falcon_a1_nic_type = { .stop_stats = falcon_stop_nic_stats, .set_id_led = falcon_set_id_led, .push_irq_moderation = falcon_push_irq_moderation, - .push_multicast_hash = falcon_push_multicast_hash, .reconfigure_port = falcon_reconfigure_port, .reconfigure_mac = falcon_reconfigure_xmac, .check_mac_fault = falcon_xmac_check_fault, @@ -1809,7 +1808,6 @@ const struct efx_nic_type falcon_b0_nic_type = { .stop_stats = falcon_stop_nic_stats, .set_id_led = falcon_set_id_led, .push_irq_moderation = falcon_push_irq_moderation, - .push_multicast_hash = falcon_push_multicast_hash, .reconfigure_port = falcon_reconfigure_port, .reconfigure_mac = falcon_reconfigure_xmac, .check_mac_fault = falcon_xmac_check_fault, diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index 559d79861faf..f67cf921bd1b 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -115,12 +115,14 @@ int efx_mcdi_mac_reconfigure(struct efx_nic *efx) { int rc; + WARN_ON(!mutex_is_locked(&efx->mac_lock)); + rc = efx_mcdi_set_mac(efx); if (rc != 0) return rc; - /* Restore the multicast hash registers. */ - efx->type->push_multicast_hash(efx); - - return 0; + return efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH, + efx->multicast_hash.byte, + sizeof(efx->multicast_hash), + NULL, 0, NULL); } diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index aa5a321a1419..a88e95f58b0a 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -826,9 +826,9 @@ static inline unsigned int efx_port_num(struct efx_nic *efx) * @stop_stats: Stop the regular fetching of statistics * @set_id_led: Set state of identifying LED or revert to automatic function * @push_irq_moderation: Apply interrupt moderation value - * @push_multicast_hash: Apply multicast hash table * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY - * @reconfigure_mac: Reconfigure MAC only. Serialised by the mac_lock + * @reconfigure_mac: Push MAC address, MTU, flow control and filter settings + * to the hardware. Serialised by the mac_lock. * @check_mac_fault: Check MAC fault state. True if fault present. * @get_wol: Get WoL configuration from driver state * @set_wol: Push WoL configuration to the NIC @@ -872,7 +872,6 @@ struct efx_nic_type { void (*stop_stats)(struct efx_nic *efx); void (*set_id_led)(struct efx_nic *efx, enum efx_led_mode mode); void (*push_irq_moderation)(struct efx_channel *channel); - void (*push_multicast_hash)(struct efx_nic *efx); int (*reconfigure_port)(struct efx_nic *efx); int (*reconfigure_mac)(struct efx_nic *efx); bool (*check_mac_fault)(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index 775b6784cbdb..d681f2597e74 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -52,15 +52,6 @@ static void siena_push_irq_moderation(struct efx_channel *channel) channel->channel); } -static void siena_push_multicast_hash(struct efx_nic *efx) -{ - WARN_ON(!mutex_is_locked(&efx->mac_lock)); - - efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH, - efx->multicast_hash.byte, sizeof(efx->multicast_hash), - NULL, 0, NULL); -} - static int siena_mdio_write(struct net_device *net_dev, int prtad, int devad, u16 addr, u16 value) { @@ -629,7 +620,6 @@ const struct efx_nic_type siena_a0_nic_type = { .stop_stats = siena_stop_nic_stats, .set_id_led = efx_mcdi_set_id_led, .push_irq_moderation = siena_push_irq_moderation, - .push_multicast_hash = siena_push_multicast_hash, .reconfigure_mac = efx_mcdi_mac_reconfigure, .check_mac_fault = efx_mcdi_mac_check_fault, .reconfigure_port = efx_mcdi_phy_reconfigure, -- GitLab From 5f3f9d6c441faa323444b2f6b092d630fcd7d04c Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 4 Nov 2011 22:29:14 +0000 Subject: [PATCH 0183/1846] sfc: Consistently test DEBUG macro, not EFX_ENABLE_DEBUG The netif_dbg() macro is defined in . If the DEBUG macro is defined, it logs a message at 'debug' level, otherwise it does nothing. In net_driver.h we define DEBUG if EFX_ENABLE_DEBUG is defined, but this is too late for those source files that already got a definition of netif_dbg() by including Get rid of EFX_ENABLE_DEBUG, and only define and test DEBUG. In mtd.c, we do not use DEBUG as a condition flag but are forced to use the DEBUG macro-function from . Undefine DEBUG before including it. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mtd.c | 1 + drivers/net/ethernet/sfc/net_driver.h | 6 +----- drivers/net/ethernet/sfc/nic.c | 2 +- drivers/net/ethernet/sfc/selftest.c | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index 7f61cd3812d9..b702862a0924 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c @@ -10,6 +10,7 @@ #include #include +#undef DEBUG /* has its own use for DEBUG */ #include #include #include diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index a88e95f58b0a..4cbd997e378b 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -13,10 +13,6 @@ #ifndef EFX_NET_DRIVER_H #define EFX_NET_DRIVER_H -#if defined(EFX_ENABLE_DEBUG) && !defined(DEBUG) -#define DEBUG -#endif - #include #include #include @@ -42,7 +38,7 @@ #define EFX_DRIVER_VERSION "3.1" -#ifdef EFX_ENABLE_DEBUG +#ifdef DEBUG #define EFX_BUG_ON_PARANOID(x) BUG_ON(x) #define EFX_WARN_ON_PARANOID(x) WARN_ON(x) #else diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index b1df2f39c8f0..bf07bd0488cf 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -801,7 +801,7 @@ static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue, * error message. FRM_TRUNC indicates RXDP dropped the packet due * to a FIFO overflow. */ -#ifdef EFX_ENABLE_DEBUG +#ifdef DEBUG if (rx_ev_other_err && net_ratelimit()) { netif_dbg(efx, rx_err, efx->net_dev, " RX queue %d unexpected RX event " diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 9df2a7942509..7718287ad0bc 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -315,7 +315,7 @@ void efx_loopback_rx_packet(struct efx_nic *efx, return; err: -#ifdef EFX_ENABLE_DEBUG +#ifdef DEBUG if (atomic_read(&state->rx_bad) == 0) { netif_err(efx, drv, efx->net_dev, "received packet:\n"); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, -- GitLab From 6aa9c7f625e8ce07060467051b68fc068118ee64 Mon Sep 17 00:00:00 2001 From: Matthew Slattery Date: Wed, 14 Jul 2010 15:36:19 +0100 Subject: [PATCH 0184/1846] sfc: Support extraction of CAPABILITIES from GET_BOARD_CFG response. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mcdi.c | 10 +++++++++- drivers/net/ethernet/sfc/mcdi.h | 2 +- drivers/net/ethernet/sfc/mtd.c | 2 +- drivers/net/ethernet/sfc/siena.c | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index e5837a6485a1..f1cad22b30fa 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -678,7 +678,7 @@ int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, } int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, - u16 *fw_subtype_list) + u16 *fw_subtype_list, u32 *capabilities) { uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMIN]; size_t outlen; @@ -708,6 +708,14 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, outbuf + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST, MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM * sizeof(fw_subtype_list[0])); + if (capabilities) { + if (port_num) + *capabilities = MCDI_DWORD(outbuf, + GET_BOARD_CFG_OUT_CAPABILITIES_PORT1); + else + *capabilities = MCDI_DWORD(outbuf, + GET_BOARD_CFG_OUT_CAPABILITIES_PORT0); + } return 0; diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index c59667bf64ac..4dd39fcca678 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -97,7 +97,7 @@ extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, bool *was_attached_out); extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, - u16 *fw_subtype_list); + u16 *fw_subtype_list, u32 *capabilities); extern int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, u32 dest_evq); extern int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out); diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index b702862a0924..eff49da458ed 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c @@ -631,7 +631,7 @@ static int siena_mtd_get_fw_subtypes(struct efx_nic *efx, uint16_t fw_subtype_list[MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM]; int rc; - rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list); + rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list, NULL); if (rc) return rc; diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index d681f2597e74..65cb5e4f4264 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -216,7 +216,7 @@ static int siena_reset_hw(struct efx_nic *efx, enum reset_type method) static int siena_probe_nvconfig(struct efx_nic *efx) { - return efx_mcdi_get_board_cfg(efx, efx->net_dev->perm_addr, NULL); + return efx_mcdi_get_board_cfg(efx, efx->net_dev->perm_addr, NULL, NULL); } static int siena_probe_nic(struct efx_nic *efx) -- GitLab From cc180b69c009ec52f67a56d96b9073b9f774b323 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 8 Dec 2011 19:51:47 +0000 Subject: [PATCH 0185/1846] sfc: Correct interrupt timer quantum for Siena (normal and turbo mode) We currently assume that the timer quantum for Siena is 5 us, the same as for Falcon. This is not correct; timer ticks are generated on a rota which takes a minimum of 768 cycles (each event delivery or other timer change will delay it by 3 cycles). The timer quantum should be 6.144 or 3.072 us depending on whether turbo mode is active. Replace EFX_IRQ_MOD_RESOLUTION with a timer_quantum_ns field in struct efx_nic, initialised by the efx_nic_type::probe function. While we're at it, replace EFX_IRQ_MOD_MAX with a timer_period_max field in struct efx_nic_type. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 31 +++++++++++++++++++-------- drivers/net/ethernet/sfc/falcon.c | 6 ++++-- drivers/net/ethernet/sfc/net_driver.h | 4 ++++ drivers/net/ethernet/sfc/nic.h | 3 --- drivers/net/ethernet/sfc/siena.c | 13 ++++++++--- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index de162474c3c5..9d4ab5e5e1fa 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1513,13 +1513,13 @@ static void efx_remove_all(struct efx_nic *efx) * **************************************************************************/ -static unsigned int irq_mod_ticks(unsigned int usecs, unsigned int resolution) +static unsigned int irq_mod_ticks(unsigned int usecs, unsigned int quantum_ns) { if (usecs == 0) return 0; - if (usecs < resolution) + if (usecs * 1000 < quantum_ns) return 1; /* never round down to 0 */ - return usecs / resolution; + return usecs * 1000 / quantum_ns; } /* Set interrupt moderation parameters */ @@ -1528,14 +1528,20 @@ int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs, bool rx_may_override_tx) { struct efx_channel *channel; - unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION); - unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION); + unsigned int irq_mod_max = DIV_ROUND_UP(efx->type->timer_period_max * + efx->timer_quantum_ns, + 1000); + unsigned int tx_ticks; + unsigned int rx_ticks; EFX_ASSERT_RESET_SERIALISED(efx); - if (tx_ticks > EFX_IRQ_MOD_MAX || rx_ticks > EFX_IRQ_MOD_MAX) + if (tx_usecs > irq_mod_max || rx_usecs > irq_mod_max) return -EINVAL; + tx_ticks = irq_mod_ticks(tx_usecs, efx->timer_quantum_ns); + rx_ticks = irq_mod_ticks(rx_usecs, efx->timer_quantum_ns); + if (tx_ticks != rx_ticks && efx->tx_channel_offset == 0 && !rx_may_override_tx) { netif_err(efx, drv, efx->net_dev, "Channels are shared. " @@ -1558,8 +1564,14 @@ int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs, void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, unsigned int *rx_usecs, bool *rx_adaptive) { + /* We must round up when converting ticks to microseconds + * because we round down when converting the other way. + */ + *rx_adaptive = efx->irq_rx_adaptive; - *rx_usecs = efx->irq_rx_moderation * EFX_IRQ_MOD_RESOLUTION; + *rx_usecs = DIV_ROUND_UP(efx->irq_rx_moderation * + efx->timer_quantum_ns, + 1000); /* If channels are shared between RX and TX, so is IRQ * moderation. Otherwise, IRQ moderation is the same for all @@ -1568,9 +1580,10 @@ void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, if (efx->tx_channel_offset == 0) *tx_usecs = *rx_usecs; else - *tx_usecs = + *tx_usecs = DIV_ROUND_UP( efx->channel[efx->tx_channel_offset]->irq_moderation * - EFX_IRQ_MOD_RESOLUTION; + efx->timer_quantum_ns, + 1000); } /************************************************************************** diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index fe21c7e349b6..0b7880b0b8fc 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -103,8 +103,6 @@ static void falcon_push_irq_moderation(struct efx_channel *channel) efx_dword_t timer_cmd; struct efx_nic *efx = channel->efx; - BUILD_BUG_ON(EFX_IRQ_MOD_MAX > (1 << FRF_AB_TC_TIMER_VAL_WIDTH)); - /* Set timer register */ if (channel->irq_moderation) { EFX_POPULATE_DWORD_2(timer_cmd, @@ -1471,6 +1469,8 @@ static int falcon_probe_nic(struct efx_nic *efx) goto fail5; } + efx->timer_quantum_ns = 4968; /* 621 cycles */ + /* Initialise I2C adapter */ board = falcon_board(efx); board->i2c_adap.owner = THIS_MODULE; @@ -1785,6 +1785,7 @@ const struct efx_nic_type falcon_a1_nic_type = { .rx_buffer_padding = 0x24, .max_interrupt_mode = EFX_INT_MODE_MSI, .phys_addr_channels = 4, + .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH, .tx_dc_base = 0x130000, .rx_dc_base = 0x100000, .offload_features = NETIF_F_IP_CSUM, @@ -1836,6 +1837,7 @@ const struct efx_nic_type falcon_b0_nic_type = { .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy * interrupt handler only supports 32 * channels */ + .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH, .tx_dc_base = 0x130000, .rx_dc_base = 0x100000, .offload_features = NETIF_F_IP_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE, diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 4cbd997e378b..8ce4d068bba5 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -624,6 +624,7 @@ struct efx_filter_state; * @membase_phys: Memory BAR value as physical address * @membase: Memory BAR value * @interrupt_mode: Interrupt mode + * @timer_quantum_ns: Interrupt timer quantum, in nanoseconds * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues * @irq_rx_moderation: IRQ moderation time for RX event queues * @msg_enable: Log message enable flags @@ -706,6 +707,7 @@ struct efx_nic { void __iomem *membase; enum efx_int_mode interrupt_mode; + unsigned int timer_quantum_ns; bool irq_rx_adaptive; unsigned int irq_rx_moderation; u32 msg_enable; @@ -845,6 +847,7 @@ static inline unsigned int efx_port_num(struct efx_nic *efx) * from &enum efx_init_mode. * @phys_addr_channels: Number of channels with physically addressed * descriptors + * @timer_period_max: Maximum period of interrupt timer (in ticks) * @tx_dc_base: Base address in SRAM of TX queue descriptor caches * @rx_dc_base: Base address in SRAM of RX queue descriptor caches * @offload_features: net_device feature flags for protocol offload @@ -889,6 +892,7 @@ struct efx_nic_type { unsigned int rx_buffer_padding; unsigned int max_interrupt_mode; unsigned int phys_addr_channels; + unsigned int timer_period_max; unsigned int tx_dc_base; unsigned int rx_dc_base; netdev_features_t offload_features; diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index cfda6ded24fe..a3ccd0b9d78d 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -205,9 +205,6 @@ extern irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx); extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id); extern void falcon_irq_ack_a1(struct efx_nic *efx); -#define EFX_IRQ_MOD_RESOLUTION 5 -#define EFX_IRQ_MOD_MAX 0x1000 - /* Global Resources */ extern int efx_nic_flush_queues(struct efx_nic *efx); extern void falcon_start_nic_stats(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index 65cb5e4f4264..f05425842b31 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -35,8 +35,6 @@ static void siena_push_irq_moderation(struct efx_channel *channel) { efx_dword_t timer_cmd; - BUILD_BUG_ON(EFX_IRQ_MOD_MAX > (1 << FRF_CZ_TC_TIMER_VAL_WIDTH)); - if (channel->irq_moderation) EFX_POPULATE_DWORD_2(timer_cmd, FRF_CZ_TC_TIMER_MODE, @@ -216,7 +214,15 @@ static int siena_reset_hw(struct efx_nic *efx, enum reset_type method) static int siena_probe_nvconfig(struct efx_nic *efx) { - return efx_mcdi_get_board_cfg(efx, efx->net_dev->perm_addr, NULL, NULL); + u32 caps = 0; + int rc; + + rc = efx_mcdi_get_board_cfg(efx, efx->net_dev->perm_addr, NULL, &caps); + + efx->timer_quantum_ns = + (caps & (1 << MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN)) ? + 3072 : 6144; /* 768 cycles */ + return rc; } static int siena_probe_nic(struct efx_nic *efx) @@ -644,6 +650,7 @@ const struct efx_nic_type siena_a0_nic_type = { .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy * interrupt handler only supports 32 * channels */ + .timer_period_max = 1 << FRF_CZ_TC_TIMER_VAL_WIDTH, .tx_dc_base = 0x88000, .rx_dc_base = 0x68000, .offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | -- GitLab From 0fb53faa2e6fe67a76b8cfc6eb70a88d9d623648 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 4 Nov 2011 23:06:04 +0000 Subject: [PATCH 0186/1846] sfc: Remove dependence on NAPI polling in efx_test_eventq_irq() We cannot safely assume that the NAPI handler will complete within the 20 ms that we allow for the event self-test. The handler may be deferred for longer than this, particularly on realtime kernels. Instead, check whether either an event has been handled or (as in the old failure path) whether an interrupt has been received and an event has been delivered but not yet handled. Use napi_disable() to synchronize with the NAPI handler before checking, since it will clear events before updating eventq_read_ptr. Remove the test result chan.N.eventq.poll, since it is not an error if the NAPI handler does not run during the test. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/ethtool.c | 4 -- drivers/net/ethernet/sfc/selftest.c | 79 +++++++++++++++-------------- drivers/net/ethernet/sfc/selftest.h | 1 - 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 1a7f7ba27bea..ba9011678013 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -404,10 +404,6 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx, &tests->eventq_int[channel->channel], EFX_CHANNEL_NAME(channel), "eventq.int", NULL); - efx_fill_test(n++, strings, data, - &tests->eventq_poll[channel->channel], - EFX_CHANNEL_NAME(channel), - "eventq.poll", NULL); } efx_fill_test(n++, strings, data, &tests->registers, diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 7718287ad0bc..0f8478924475 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -161,11 +161,8 @@ static int efx_test_eventq_irq(struct efx_channel *channel, struct efx_self_tests *tests) { struct efx_nic *efx = channel->efx; - unsigned int read_ptr, count; - - tests->eventq_dma[channel->channel] = -1; - tests->eventq_int[channel->channel] = -1; - tests->eventq_poll[channel->channel] = -1; + unsigned int read_ptr; + bool napi_ran, dma_seen, int_seen; read_ptr = channel->eventq_read_ptr; channel->efx->last_irq_cpu = -1; @@ -173,44 +170,48 @@ static int efx_test_eventq_irq(struct efx_channel *channel, efx_nic_generate_test_event(channel); - /* Wait for arrival of interrupt */ - count = 0; - do { - schedule_timeout_uninterruptible(HZ / 100); - - if (ACCESS_ONCE(channel->eventq_read_ptr) != read_ptr) - goto eventq_ok; - } while (++count < 2); - - netif_err(efx, drv, efx->net_dev, - "channel %d timed out waiting for event queue\n", - channel->channel); - - /* See if interrupt arrived */ - if (channel->efx->last_irq_cpu >= 0) { - netif_err(efx, drv, efx->net_dev, - "channel %d saw interrupt on CPU%d " - "during event queue test\n", channel->channel, - raw_smp_processor_id()); - tests->eventq_int[channel->channel] = 1; + /* Wait for arrival of interrupt. NAPI processing may or may + * not complete in time, but we can cope in any case. + */ + msleep(10); + napi_disable(&channel->napi_str); + if (channel->eventq_read_ptr != read_ptr) { + napi_ran = true; + dma_seen = true; + int_seen = true; + } else { + napi_ran = false; + dma_seen = efx_nic_event_present(channel); + int_seen = efx->last_irq_cpu >= 0; } + napi_enable(&channel->napi_str); + efx_nic_eventq_read_ack(channel); + + tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1; + tests->eventq_int[channel->channel] = int_seen ? 1 : -1; - /* Check to see if event was received even if interrupt wasn't */ - if (efx_nic_event_present(channel)) { + if (dma_seen && int_seen) { + netif_dbg(efx, drv, efx->net_dev, + "channel %d event queue passed (with%s NAPI)\n", + channel->channel, napi_ran ? "" : "out"); + return 0; + } else { + /* Report failure and whether either interrupt or DMA worked */ netif_err(efx, drv, efx->net_dev, - "channel %d event was generated, but " - "failed to trigger an interrupt\n", channel->channel); - tests->eventq_dma[channel->channel] = 1; + "channel %d timed out waiting for event queue\n", + channel->channel); + if (int_seen) + netif_err(efx, drv, efx->net_dev, + "channel %d saw interrupt " + "during event queue test\n", + channel->channel); + if (dma_seen) + netif_err(efx, drv, efx->net_dev, + "channel %d event was generated, but " + "failed to trigger an interrupt\n", + channel->channel); + return -ETIMEDOUT; } - - return -ETIMEDOUT; - eventq_ok: - netif_dbg(efx, drv, efx->net_dev, "channel %d event queue passed\n", - channel->channel); - tests->eventq_dma[channel->channel] = 1; - tests->eventq_int[channel->channel] = 1; - tests->eventq_poll[channel->channel] = 1; - return 0; } static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests, diff --git a/drivers/net/ethernet/sfc/selftest.h b/drivers/net/ethernet/sfc/selftest.h index dba5456e70f3..87abe2a53846 100644 --- a/drivers/net/ethernet/sfc/selftest.h +++ b/drivers/net/ethernet/sfc/selftest.h @@ -37,7 +37,6 @@ struct efx_self_tests { int interrupt; int eventq_dma[EFX_MAX_CHANNELS]; int eventq_int[EFX_MAX_CHANNELS]; - int eventq_poll[EFX_MAX_CHANNELS]; /* offline tests */ int registers; int phy_ext[EFX_MAX_PHY_TESTS]; -- GitLab From f70d1847348e9548a9a56e4434946315bca297c8 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 6 Jan 2012 01:08:24 +0000 Subject: [PATCH 0187/1846] Partly revert "sfc: Handle serious errors in exactly one interrupt handler" This reverts commit 6369545945b90daa1a73fca174da9194c398417c in drivers/net/ethernet/sfc/falcon.c. Unlike the INT_ISR0 register on later controller revisions, the NET_IVEC_INT_Q bits written to memory are only ever set for interrupting event queues, not for any other interrupt sources. By definition there can only be one legacy interrupt handler per function, so there is no need to worry about detecting a fatal interrupt more than once. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/falcon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index 0b7880b0b8fc..b4e91edec0fa 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -174,19 +174,16 @@ irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id) "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n", irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker)); + /* Check to see if we have a serious error condition */ + syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); + if (unlikely(syserr)) + return efx_nic_fatal_interrupt(efx); + /* Determine interrupting queues, clear interrupt status * register and acknowledge the device interrupt. */ BUILD_BUG_ON(FSF_AZ_NET_IVEC_INT_Q_WIDTH > EFX_MAX_CHANNELS); queues = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_INT_Q); - - /* Check to see if we have a serious error condition */ - if (queues & (1U << efx->fatal_irq_level)) { - syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); - if (unlikely(syserr)) - return efx_nic_fatal_interrupt(efx); - } - EFX_ZERO_OWORD(*int_ker); wmb(); /* Ensure the vector is cleared before interrupt ack */ falcon_irq_ack_a1(efx); -- GitLab From 1646a6f352a6f70fcca828589ed04797aa09d494 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 5 Jan 2012 20:14:10 +0000 Subject: [PATCH 0188/1846] sfc: Clean up test interrupt handling Interrupts are normally generated by the event queues, moderated by timers. However, they may also be triggered by detection of a 'fatal' error condition (e.g. memory parity error) or by the host writing to certain CSR fields as part of a self-test. The IRQ level/index used for these on Falcon rev B0 and Siena is set by the KER_INT_LEVE_SEL field and cached by the driver in efx_nic::fatal_irq_level. Since this value is also relevant to self-tests rename the field to just 'irq_level'. Avoid unnecessary cache traffic by using a per-channel 'last_irq_cpu' field and only writing to the per-controller field when the interrupt matches efx_nic::irq_level. Remove the volatile qualifier and use ACCESS_ONCE in the places we read these fields. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.h | 6 ++++++ drivers/net/ethernet/sfc/falcon.c | 4 ++-- drivers/net/ethernet/sfc/net_driver.h | 15 ++++++++------- drivers/net/ethernet/sfc/nic.c | 27 +++++++++++++-------------- drivers/net/ethernet/sfc/selftest.c | 12 +++++++----- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h index a3541ac6ea01..e0b66d158d79 100644 --- a/drivers/net/ethernet/sfc/efx.h +++ b/drivers/net/ethernet/sfc/efx.h @@ -145,6 +145,12 @@ static inline void efx_schedule_channel(struct efx_channel *channel) napi_schedule(&channel->napi_str); } +static inline void efx_schedule_channel_irq(struct efx_channel *channel) +{ + channel->last_irq_cpu = raw_smp_processor_id(); + efx_schedule_channel(channel); +} + extern void efx_link_status_changed(struct efx_nic *efx); extern void efx_link_set_advertising(struct efx_nic *efx, u32); extern void efx_link_set_wanted_fc(struct efx_nic *efx, u8); diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index b4e91edec0fa..98285115df10 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -189,9 +189,9 @@ irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id) falcon_irq_ack_a1(efx); if (queues & 1) - efx_schedule_channel(efx_get_channel(efx, 0)); + efx_schedule_channel_irq(efx_get_channel(efx, 0)); if (queues & 2) - efx_schedule_channel(efx_get_channel(efx, 1)); + efx_schedule_channel_irq(efx_get_channel(efx, 1)); return IRQ_HANDLED; } /************************************************************************** diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 8ce4d068bba5..a4cf8cb8180c 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -325,6 +325,7 @@ enum efx_rx_alloc_method { * @eventq_mask: Event queue pointer mask * @eventq_read_ptr: Event queue read pointer * @last_eventq_read_ptr: Last event queue read pointer value. + * @last_irq_cpu: Last CPU to handle interrupt for this channel * @irq_count: Number of IRQs since last adaptive moderation decision * @irq_mod_score: IRQ moderation score * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors @@ -355,6 +356,7 @@ struct efx_channel { unsigned int eventq_read_ptr; unsigned int last_eventq_read_ptr; + int last_irq_cpu; unsigned int irq_count; unsigned int irq_mod_score; #ifdef CONFIG_RFS_ACCEL @@ -648,7 +650,7 @@ struct efx_filter_state; * @int_error_expire: Time at which error count will be expired * @irq_status: Interrupt status buffer * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0 - * @fatal_irq_level: IRQ level (bit number) used for serious errors + * @irq_level: IRQ level/index for IRQs not triggered by an event queue * @mtd_list: List of MTDs attached to the NIC * @nic_data: Hardware dependent state * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode, @@ -679,10 +681,9 @@ struct efx_filter_state; * @loopback_selftest: Offline self-test private state * @monitor_work: Hardware monitor workitem * @biu_lock: BIU (bus interface unit) lock - * @last_irq_cpu: Last CPU to handle interrupt. - * This register is written with the SMP processor ID whenever an - * interrupt is handled. It is used by efx_nic_test_interrupt() - * to verify that an interrupt has occurred. + * @last_irq_cpu: Last CPU to handle a possible test interrupt. This + * field is used by efx_test_interrupts() to verify that an + * interrupt has occurred. * @n_rx_nodesc_drop_cnt: RX no descriptor drop count * @mac_stats: MAC statistics. These include all statistics the MACs * can provide. Generic code converts these into a standard @@ -735,7 +736,7 @@ struct efx_nic { struct efx_buffer irq_status; unsigned irq_zero_count; - unsigned fatal_irq_level; + unsigned irq_level; #ifdef CONFIG_SFC_MTD struct list_head mtd_list; @@ -779,7 +780,7 @@ struct efx_nic { struct delayed_work monitor_work ____cacheline_aligned_in_smp; spinlock_t biu_lock; - volatile signed int last_irq_cpu; + int last_irq_cpu; unsigned n_rx_nodesc_drop_cnt; struct efx_mac_stats mac_stats; spinlock_t stats_lock; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index bf07bd0488cf..de7aa1c8ebda 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -1311,7 +1311,7 @@ static inline void efx_nic_interrupts(struct efx_nic *efx, efx_oword_t int_en_reg_ker; EFX_POPULATE_OWORD_3(int_en_reg_ker, - FRF_AZ_KER_INT_LEVE_SEL, efx->fatal_irq_level, + FRF_AZ_KER_INT_LEVE_SEL, efx->irq_level, FRF_AZ_KER_INT_KER, force, FRF_AZ_DRV_INT_EN_KER, enabled); efx_writeo(efx, &int_en_reg_ker, FR_AZ_INT_EN_KER); @@ -1427,11 +1427,12 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id) efx_readd(efx, ®, FR_BZ_INT_ISR0); queues = EFX_EXTRACT_DWORD(reg, 0, 31); - /* Check to see if we have a serious error condition */ - if (queues & (1U << efx->fatal_irq_level)) { + /* Handle non-event-queue sources */ + if (queues & (1U << efx->irq_level)) { syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); if (unlikely(syserr)) return efx_nic_fatal_interrupt(efx); + efx->last_irq_cpu = raw_smp_processor_id(); } if (queues != 0) { @@ -1441,7 +1442,7 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id) /* Schedule processing of any interrupting queues */ efx_for_each_channel(channel, efx) { if (queues & 1) - efx_schedule_channel(channel); + efx_schedule_channel_irq(channel); queues >>= 1; } result = IRQ_HANDLED; @@ -1458,18 +1459,16 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id) efx_for_each_channel(channel, efx) { event = efx_event(channel, channel->eventq_read_ptr); if (efx_event_present(event)) - efx_schedule_channel(channel); + efx_schedule_channel_irq(channel); else efx_nic_eventq_read_ack(channel); } } - if (result == IRQ_HANDLED) { - efx->last_irq_cpu = raw_smp_processor_id(); + if (result == IRQ_HANDLED) netif_vdbg(efx, intr, efx->net_dev, "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n", irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg)); - } return result; } @@ -1488,20 +1487,20 @@ static irqreturn_t efx_msi_interrupt(int irq, void *dev_id) efx_oword_t *int_ker = efx->irq_status.addr; int syserr; - efx->last_irq_cpu = raw_smp_processor_id(); netif_vdbg(efx, intr, efx->net_dev, "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n", irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker)); - /* Check to see if we have a serious error condition */ - if (channel->channel == efx->fatal_irq_level) { + /* Handle non-event-queue sources */ + if (channel->channel == efx->irq_level) { syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); if (unlikely(syserr)) return efx_nic_fatal_interrupt(efx); + efx->last_irq_cpu = raw_smp_processor_id(); } /* Schedule processing of the channel */ - efx_schedule_channel(channel); + efx_schedule_channel_irq(channel); return IRQ_HANDLED; } @@ -1640,10 +1639,10 @@ void efx_nic_init_common(struct efx_nic *efx) if (EFX_WORKAROUND_17213(efx) && !EFX_INT_MODE_USE_MSI(efx)) /* Use an interrupt level unused by event queues */ - efx->fatal_irq_level = 0x1f; + efx->irq_level = 0x1f; else /* Use a valid MSI-X vector */ - efx->fatal_irq_level = 0; + efx->irq_level = 0; /* Enable all the genuinely fatal interrupts. (They are still * masked by the overall interrupt mask, controlled by diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 0f8478924475..7def480570c3 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -130,6 +130,8 @@ static int efx_test_chip(struct efx_nic *efx, struct efx_self_tests *tests) static int efx_test_interrupts(struct efx_nic *efx, struct efx_self_tests *tests) { + int cpu; + netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n"); tests->interrupt = -1; @@ -142,7 +144,8 @@ static int efx_test_interrupts(struct efx_nic *efx, /* Wait for arrival of test interrupt. */ netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n"); schedule_timeout_uninterruptible(HZ / 10); - if (efx->last_irq_cpu >= 0) + cpu = ACCESS_ONCE(efx->last_irq_cpu); + if (cpu >= 0) goto success; netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n"); @@ -150,8 +153,7 @@ static int efx_test_interrupts(struct efx_nic *efx, success: netif_dbg(efx, drv, efx->net_dev, "%s test interrupt seen on CPU%d\n", - INT_MODE(efx), - efx->last_irq_cpu); + INT_MODE(efx), cpu); tests->interrupt = 1; return 0; } @@ -165,7 +167,7 @@ static int efx_test_eventq_irq(struct efx_channel *channel, bool napi_ran, dma_seen, int_seen; read_ptr = channel->eventq_read_ptr; - channel->efx->last_irq_cpu = -1; + channel->last_irq_cpu = -1; smp_wmb(); efx_nic_generate_test_event(channel); @@ -182,7 +184,7 @@ static int efx_test_eventq_irq(struct efx_channel *channel, } else { napi_ran = false; dma_seen = efx_nic_event_present(channel); - int_seen = efx->last_irq_cpu >= 0; + int_seen = ACCESS_ONCE(channel->last_irq_cpu) >= 0; } napi_enable(&channel->napi_str); efx_nic_eventq_read_ack(channel); -- GitLab From 55c5e0f85dc550f03dc8a0b0097da6af3b4865c5 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 6 Jan 2012 20:25:39 +0000 Subject: [PATCH 0189/1846] sfc: Add hwmon driver for boards using SFC9000-family controllers The SFC9000-family controllers have firmware to manage all board peripherals including temperature, heat sink continuity and voltage sensors. The firmware reports sensor alarms, which we log, and will shut down the board if necessary. Some users may want to monitor their boards more closely, so add an hwmon driver that exposes all sensors reported by the firmware. Move efx_mcdi_sensor_event() into the new file so it can share the array of sensor labels with the hwmon driver. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/Kconfig | 7 + drivers/net/ethernet/sfc/Makefile | 2 +- drivers/net/ethernet/sfc/mcdi.c | 43 --- drivers/net/ethernet/sfc/mcdi.h | 28 ++ drivers/net/ethernet/sfc/mcdi_mon.c | 415 ++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/nic.h | 14 + drivers/net/ethernet/sfc/siena.c | 6 + 7 files changed, 471 insertions(+), 44 deletions(-) create mode 100644 drivers/net/ethernet/sfc/mcdi_mon.c diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig index 5d18841f0f3d..ae40b666739b 100644 --- a/drivers/net/ethernet/sfc/Kconfig +++ b/drivers/net/ethernet/sfc/Kconfig @@ -19,3 +19,10 @@ config SFC_MTD This exposes the on-board flash memory as MTD devices (e.g. /dev/mtd1). This makes it possible to upload new firmware to the NIC. +config SFC_MCDI_MON + bool "Solarflare SFC9000-family hwmon support" + depends on SFC && HWMON && !(SFC=y && HWMON=m) + default y + ----help--- + This exposes the on-board firmware-managed sensors as a + hardware monitor device. diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index ab31c7124db1..3fa2e25ccc45 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -2,7 +2,7 @@ sfc-y += efx.o nic.o falcon.o siena.o tx.o rx.o filter.o \ falcon_xmac.o mcdi_mac.o \ selftest.o ethtool.o qt202x_phy.o mdio_10g.o \ tenxpress.o txc43128_phy.o falcon_boards.o \ - mcdi.o mcdi_phy.o + mcdi.o mcdi_phy.o mcdi_mon.o sfc-$(CONFIG_SFC_MTD) += mtd.o obj-$(CONFIG_SFC) += sfc.o diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index f1cad22b30fa..619f63a66ce7 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -517,49 +517,6 @@ static void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev) efx_link_status_changed(efx); } -static const char *const sensor_names[] = { - [MC_CMD_SENSOR_CONTROLLER_TEMP] = "Controller temp. sensor", - [MC_CMD_SENSOR_PHY_COMMON_TEMP] = "PHY shared temp. sensor", - [MC_CMD_SENSOR_CONTROLLER_COOLING] = "Controller cooling", - [MC_CMD_SENSOR_PHY0_TEMP] = "PHY 0 temp. sensor", - [MC_CMD_SENSOR_PHY0_COOLING] = "PHY 0 cooling", - [MC_CMD_SENSOR_PHY1_TEMP] = "PHY 1 temp. sensor", - [MC_CMD_SENSOR_PHY1_COOLING] = "PHY 1 cooling", - [MC_CMD_SENSOR_IN_1V0] = "1.0V supply sensor", - [MC_CMD_SENSOR_IN_1V2] = "1.2V supply sensor", - [MC_CMD_SENSOR_IN_1V8] = "1.8V supply sensor", - [MC_CMD_SENSOR_IN_2V5] = "2.5V supply sensor", - [MC_CMD_SENSOR_IN_3V3] = "3.3V supply sensor", - [MC_CMD_SENSOR_IN_12V0] = "12V supply sensor" -}; - -static const char *const sensor_status_names[] = { - [MC_CMD_SENSOR_STATE_OK] = "OK", - [MC_CMD_SENSOR_STATE_WARNING] = "Warning", - [MC_CMD_SENSOR_STATE_FATAL] = "Fatal", - [MC_CMD_SENSOR_STATE_BROKEN] = "Device failure", -}; - -static void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev) -{ - unsigned int monitor, state, value; - const char *name, *state_txt; - monitor = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR); - state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE); - value = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_VALUE); - /* Deal gracefully with the board having more drivers than we - * know about, but do not expect new sensor states. */ - name = (monitor >= ARRAY_SIZE(sensor_names)) - ? "No sensor name available" : - sensor_names[monitor]; - EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names)); - state_txt = sensor_status_names[state]; - - netif_err(efx, hw, efx->net_dev, - "Sensor %d (%s) reports condition '%s' for raw value %d\n", - monitor, name, state_txt, value); -} - /* Called from falcon_process_eventq for MCDI events */ void efx_mcdi_process_event(struct efx_channel *channel, efx_qword_t *event) diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index 4dd39fcca678..fbaa6efcd744 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -56,6 +56,15 @@ struct efx_mcdi_iface { size_t resplen; }; +struct efx_mcdi_mon { + struct efx_buffer dma_buf; + struct mutex update_lock; + unsigned long last_update; + struct device *device; + struct efx_mcdi_mon_attribute *attrs; + unsigned int n_attrs; +}; + extern void efx_mcdi_init(struct efx_nic *efx); extern int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, const u8 *inbuf, @@ -68,6 +77,7 @@ extern void efx_mcdi_mode_event(struct efx_nic *efx); extern void efx_mcdi_process_event(struct efx_channel *channel, efx_qword_t *event); +extern void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); #define MCDI_PTR2(_buf, _ofst) \ (((u8 *)_buf) + _ofst) @@ -83,6 +93,10 @@ extern void efx_mcdi_process_event(struct efx_channel *channel, #define MCDI_PTR(_buf, _ofst) \ MCDI_PTR2(_buf, MC_CMD_ ## _ofst ## _OFST) +#define MCDI_ARRAY_PTR(_buf, _field, _type, _index) \ + MCDI_PTR2(_buf, \ + MC_CMD_ ## _field ## _OFST + \ + (_index) * MC_CMD_ ## _type ## _TYPEDEF_LEN) #define MCDI_SET_DWORD(_buf, _ofst, _value) \ MCDI_SET_DWORD2(_buf, MC_CMD_ ## _ofst ## _OFST, _value) #define MCDI_DWORD(_buf, _ofst) \ @@ -92,6 +106,12 @@ extern void efx_mcdi_process_event(struct efx_channel *channel, #define MCDI_EVENT_FIELD(_ev, _field) \ EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) +#define MCDI_ARRAY_FIELD(_buf, _field1, _type, _index, _field2) \ + EFX_DWORD_FIELD( \ + *((efx_dword_t *) \ + (MCDI_ARRAY_PTR(_buf, _field1, _type, _index) + \ + (MC_CMD_ ## _type ## _TYPEDEF_ ## _field2 ## _OFST & ~3))), \ + MC_CMD_ ## _type ## _TYPEDEF_ ## _field2) extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, @@ -131,4 +151,12 @@ extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, extern int efx_mcdi_mac_reconfigure(struct efx_nic *efx); extern bool efx_mcdi_mac_check_fault(struct efx_nic *efx); +#ifdef CONFIG_SFC_MCDI_MON +extern int efx_mcdi_mon_probe(struct efx_nic *efx); +extern void efx_mcdi_mon_remove(struct efx_nic *efx); +#else +static inline int efx_mcdi_mon_probe(struct efx_nic *efx) { return 0; } +static inline void efx_mcdi_mon_remove(struct efx_nic *efx) {} +#endif + #endif /* EFX_MCDI_H */ diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c new file mode 100644 index 000000000000..8a72c10b9a6c --- /dev/null +++ b/drivers/net/ethernet/sfc/mcdi_mon.c @@ -0,0 +1,415 @@ +/**************************************************************************** + * Driver for Solarflare Solarstorm network controllers and boards + * Copyright 2011 Solarflare Communications Inc. + * + * 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, incorporated herein by reference. + */ + +#include +#include +#include +#include + +#include "net_driver.h" +#include "mcdi.h" +#include "mcdi_pcol.h" +#include "nic.h" + +enum efx_hwmon_type { + EFX_HWMON_UNKNOWN, + EFX_HWMON_TEMP, /* temperature */ + EFX_HWMON_COOL, /* cooling device, probably a heatsink */ + EFX_HWMON_IN /* input voltage */ +}; + +static const struct { + const char *label; + enum efx_hwmon_type hwmon_type; + int port; +} efx_mcdi_sensor_type[MC_CMD_SENSOR_ENTRY_MAXNUM] = { +#define SENSOR(name, label, hwmon_type, port) \ + [MC_CMD_SENSOR_##name] = { label, hwmon_type, port } + SENSOR(CONTROLLER_TEMP, "Controller temp.", EFX_HWMON_TEMP, -1), + SENSOR(PHY_COMMON_TEMP, "PHY temp.", EFX_HWMON_TEMP, -1), + SENSOR(CONTROLLER_COOLING, "Controller cooling", EFX_HWMON_COOL, -1), + SENSOR(PHY0_TEMP, "PHY temp.", EFX_HWMON_TEMP, 0), + SENSOR(PHY0_COOLING, "PHY cooling", EFX_HWMON_COOL, 0), + SENSOR(PHY1_TEMP, "PHY temp.", EFX_HWMON_TEMP, 1), + SENSOR(PHY1_COOLING, "PHY cooling", EFX_HWMON_COOL, 1), + SENSOR(IN_1V0, "1.0V supply", EFX_HWMON_IN, -1), + SENSOR(IN_1V2, "1.2V supply", EFX_HWMON_IN, -1), + SENSOR(IN_1V8, "1.8V supply", EFX_HWMON_IN, -1), + SENSOR(IN_2V5, "2.5V supply", EFX_HWMON_IN, -1), + SENSOR(IN_3V3, "3.3V supply", EFX_HWMON_IN, -1), + SENSOR(IN_12V0, "12.0V supply", EFX_HWMON_IN, -1), + SENSOR(IN_1V2A, "1.2V analogue supply", EFX_HWMON_IN, -1), + SENSOR(IN_VREF, "ref. voltage", EFX_HWMON_IN, -1), +#undef SENSOR +}; + +static const char *const sensor_status_names[] = { + [MC_CMD_SENSOR_STATE_OK] = "OK", + [MC_CMD_SENSOR_STATE_WARNING] = "Warning", + [MC_CMD_SENSOR_STATE_FATAL] = "Fatal", + [MC_CMD_SENSOR_STATE_BROKEN] = "Device failure", +}; + +void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev) +{ + unsigned int type, state, value; + const char *name = NULL, *state_txt; + + type = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR); + state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE); + value = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_VALUE); + + /* Deal gracefully with the board having more drivers than we + * know about, but do not expect new sensor states. */ + if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) + name = efx_mcdi_sensor_type[type].label; + if (!name) + name = "No sensor name available"; + EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names)); + state_txt = sensor_status_names[state]; + + netif_err(efx, hw, efx->net_dev, + "Sensor %d (%s) reports condition '%s' for raw value %d\n", + type, name, state_txt, value); +} + +#ifdef CONFIG_SFC_MCDI_MON + +struct efx_mcdi_mon_attribute { + struct device_attribute dev_attr; + unsigned int index; + unsigned int type; + unsigned int limit_value; + char name[12]; +}; + +static int efx_mcdi_mon_update(struct efx_nic *efx) +{ + struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); + u8 inbuf[MC_CMD_READ_SENSORS_IN_LEN]; + int rc; + + MCDI_SET_DWORD(inbuf, READ_SENSORS_IN_DMA_ADDR_LO, + hwmon->dma_buf.dma_addr & 0xffffffff); + MCDI_SET_DWORD(inbuf, READ_SENSORS_IN_DMA_ADDR_HI, + (u64)hwmon->dma_buf.dma_addr >> 32); + + rc = efx_mcdi_rpc(efx, MC_CMD_READ_SENSORS, + inbuf, sizeof(inbuf), NULL, 0, NULL); + if (rc == 0) + hwmon->last_update = jiffies; + return rc; +} + +static ssize_t efx_mcdi_mon_show_name(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%s\n", KBUILD_MODNAME); +} + +static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index, + efx_dword_t *entry) +{ + struct efx_nic *efx = dev_get_drvdata(dev); + struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); + int rc; + + BUILD_BUG_ON(MC_CMD_READ_SENSORS_OUT_LEN != 0); + + mutex_lock(&hwmon->update_lock); + + /* Use cached value if last update was < 1 s ago */ + if (time_before(jiffies, hwmon->last_update + HZ)) + rc = 0; + else + rc = efx_mcdi_mon_update(efx); + + /* Copy out the requested entry */ + *entry = ((efx_dword_t *)hwmon->dma_buf.addr)[index]; + + mutex_unlock(&hwmon->update_lock); + + return rc; +} + +static ssize_t efx_mcdi_mon_show_value(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct efx_mcdi_mon_attribute *mon_attr = + container_of(attr, struct efx_mcdi_mon_attribute, dev_attr); + efx_dword_t entry; + unsigned int value; + int rc; + + rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry); + if (rc) + return rc; + + value = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE); + + /* Convert temperature from degrees to milli-degrees Celsius */ + if (efx_mcdi_sensor_type[mon_attr->type].hwmon_type == EFX_HWMON_TEMP) + value *= 1000; + + return sprintf(buf, "%u\n", value); +} + +static ssize_t efx_mcdi_mon_show_limit(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct efx_mcdi_mon_attribute *mon_attr = + container_of(attr, struct efx_mcdi_mon_attribute, dev_attr); + unsigned int value; + + value = mon_attr->limit_value; + + /* Convert temperature from degrees to milli-degrees Celsius */ + if (efx_mcdi_sensor_type[mon_attr->type].hwmon_type == EFX_HWMON_TEMP) + value *= 1000; + + return sprintf(buf, "%u\n", value); +} + +static ssize_t efx_mcdi_mon_show_alarm(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct efx_mcdi_mon_attribute *mon_attr = + container_of(attr, struct efx_mcdi_mon_attribute, dev_attr); + efx_dword_t entry; + int state; + int rc; + + rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry); + if (rc) + return rc; + + state = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE); + return sprintf(buf, "%d\n", state != MC_CMD_SENSOR_STATE_OK); +} + +static ssize_t efx_mcdi_mon_show_label(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct efx_mcdi_mon_attribute *mon_attr = + container_of(attr, struct efx_mcdi_mon_attribute, dev_attr); + return sprintf(buf, "%s\n", + efx_mcdi_sensor_type[mon_attr->type].label); +} + +static int +efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name, + ssize_t (*reader)(struct device *, + struct device_attribute *, char *), + unsigned int index, unsigned int type, + unsigned int limit_value) +{ + struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); + struct efx_mcdi_mon_attribute *attr = &hwmon->attrs[hwmon->n_attrs]; + int rc; + + strlcpy(attr->name, name, sizeof(attr->name)); + attr->index = index; + attr->type = type; + attr->limit_value = limit_value; + attr->dev_attr.attr.name = attr->name; + attr->dev_attr.attr.mode = S_IRUGO; + attr->dev_attr.show = reader; + rc = device_create_file(&efx->pci_dev->dev, &attr->dev_attr); + if (rc == 0) + ++hwmon->n_attrs; + return rc; +} + +int efx_mcdi_mon_probe(struct efx_nic *efx) +{ + struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx); + unsigned int n_attrs, n_temp = 0, n_cool = 0, n_in = 0; + u8 outbuf[MC_CMD_SENSOR_INFO_OUT_LENMAX]; + size_t outlen; + char name[12]; + u32 mask; + int rc, i, type; + + BUILD_BUG_ON(MC_CMD_SENSOR_INFO_IN_LEN != 0); + + rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO, NULL, 0, + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN) + return -EIO; + + /* Find out which sensors are present. Don't create a device + * if there are none. + */ + mask = MCDI_DWORD(outbuf, SENSOR_INFO_OUT_MASK); + if (mask == 0) + return 0; + + /* Check again for short response */ + if (outlen < MC_CMD_SENSOR_INFO_OUT_LEN(hweight32(mask))) + return -EIO; + + rc = efx_nic_alloc_buffer(efx, &hwmon->dma_buf, + 4 * MC_CMD_SENSOR_ENTRY_MAXNUM); + if (rc) + return rc; + + mutex_init(&hwmon->update_lock); + efx_mcdi_mon_update(efx); + + /* Allocate space for the maximum possible number of + * attributes for this set of sensors: name of the driver plus + * value, min, max, crit, alarm and label for each sensor. + */ + n_attrs = 1 + 6 * hweight32(mask); + hwmon->attrs = kcalloc(n_attrs, sizeof(*hwmon->attrs), GFP_KERNEL); + if (!hwmon->attrs) { + rc = -ENOMEM; + goto fail; + } + + hwmon->device = hwmon_device_register(&efx->pci_dev->dev); + if (IS_ERR(hwmon->device)) { + rc = PTR_ERR(hwmon->device); + goto fail; + } + + rc = efx_mcdi_mon_add_attr(efx, "name", efx_mcdi_mon_show_name, 0, 0, 0); + if (rc) + goto fail; + + for (i = 0, type = -1; ; i++) { + const char *hwmon_prefix; + unsigned hwmon_index; + u16 min1, max1, min2, max2; + + /* Find next sensor type or exit if there is none */ + type++; + while (!(mask & (1 << type))) { + type++; + if (type == 32) + return 0; + } + + /* Skip sensors specific to a different port */ + if (efx_mcdi_sensor_type[type].hwmon_type != EFX_HWMON_UNKNOWN && + efx_mcdi_sensor_type[type].port >= 0 && + efx_mcdi_sensor_type[type].port != efx_port_num(efx)) + continue; + + switch (efx_mcdi_sensor_type[type].hwmon_type) { + case EFX_HWMON_TEMP: + hwmon_prefix = "temp"; + hwmon_index = ++n_temp; /* 1-based */ + break; + case EFX_HWMON_COOL: + /* This is likely to be a heatsink, but there + * is no convention for representing cooling + * devices other than fans. + */ + hwmon_prefix = "fan"; + hwmon_index = ++n_cool; /* 1-based */ + break; + default: + hwmon_prefix = "in"; + hwmon_index = n_in++; /* 0-based */ + break; + } + + min1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY, + SENSOR_INFO_ENTRY, i, MIN1); + max1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY, + SENSOR_INFO_ENTRY, i, MAX1); + min2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY, + SENSOR_INFO_ENTRY, i, MIN2); + max2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY, + SENSOR_INFO_ENTRY, i, MAX2); + + if (min1 != max1) { + snprintf(name, sizeof(name), "%s%u_input", + hwmon_prefix, hwmon_index); + rc = efx_mcdi_mon_add_attr( + efx, name, efx_mcdi_mon_show_value, i, type, 0); + if (rc) + goto fail; + + snprintf(name, sizeof(name), "%s%u_min", + hwmon_prefix, hwmon_index); + rc = efx_mcdi_mon_add_attr( + efx, name, efx_mcdi_mon_show_limit, + i, type, min1); + if (rc) + goto fail; + + snprintf(name, sizeof(name), "%s%u_max", + hwmon_prefix, hwmon_index); + rc = efx_mcdi_mon_add_attr( + efx, name, efx_mcdi_mon_show_limit, + i, type, max1); + if (rc) + goto fail; + + if (min2 != max2) { + /* Assume max2 is critical value. + * But we have no good way to expose min2. + */ + snprintf(name, sizeof(name), "%s%u_crit", + hwmon_prefix, hwmon_index); + rc = efx_mcdi_mon_add_attr( + efx, name, efx_mcdi_mon_show_limit, + i, type, max2); + if (rc) + goto fail; + } + } + + snprintf(name, sizeof(name), "%s%u_alarm", + hwmon_prefix, hwmon_index); + rc = efx_mcdi_mon_add_attr( + efx, name, efx_mcdi_mon_show_alarm, i, type, 0); + if (rc) + goto fail; + + if (efx_mcdi_sensor_type[type].label) { + snprintf(name, sizeof(name), "%s%u_label", + hwmon_prefix, hwmon_index); + rc = efx_mcdi_mon_add_attr( + efx, name, efx_mcdi_mon_show_label, i, type, 0); + if (rc) + goto fail; + } + } + +fail: + efx_mcdi_mon_remove(efx); + return rc; +} + +void efx_mcdi_mon_remove(struct efx_nic *efx) +{ + struct siena_nic_data *nic_data = efx->nic_data; + struct efx_mcdi_mon *hwmon = &nic_data->hwmon; + unsigned int i; + + for (i = 0; i < hwmon->n_attrs; i++) + device_remove_file(&efx->pci_dev->dev, + &hwmon->attrs[i].dev_attr); + kfree(hwmon->attrs); + if (hwmon->device) + hwmon_device_unregister(hwmon->device); + efx_nic_free_buffer(efx, &hwmon->dma_buf); +} + +#endif /* CONFIG_SFC_MCDI_MON */ diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index a3ccd0b9d78d..905a1877d603 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -144,12 +144,26 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx) * struct siena_nic_data - Siena NIC state * @mcdi: Management-Controller-to-Driver Interface * @wol_filter_id: Wake-on-LAN packet filter id + * @hwmon: Hardware monitor state */ struct siena_nic_data { struct efx_mcdi_iface mcdi; int wol_filter_id; +#ifdef CONFIG_SFC_MCDI_MON + struct efx_mcdi_mon hwmon; +#endif }; +#ifdef CONFIG_SFC_MCDI_MON +static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx) +{ + struct siena_nic_data *nic_data; + EFX_BUG_ON_PARANOID(efx_nic_rev(efx) < EFX_REV_SIENA_A0); + nic_data = efx->nic_data; + return &nic_data->hwmon; +} +#endif + extern const struct efx_nic_type falcon_a1_nic_type; extern const struct efx_nic_type falcon_b0_nic_type; extern const struct efx_nic_type siena_a0_nic_type; diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index f05425842b31..d3c4169e2a0b 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -300,6 +300,10 @@ static int siena_probe_nic(struct efx_nic *efx) goto fail5; } + rc = efx_mcdi_mon_probe(efx); + if (rc) + goto fail5; + return 0; fail5: @@ -387,6 +391,8 @@ static int siena_init_nic(struct efx_nic *efx) static void siena_remove_nic(struct efx_nic *efx) { + efx_mcdi_mon_remove(efx); + efx_nic_free_buffer(efx, &efx->irq_status); siena_reset_hw(efx, RESET_TYPE_ALL); -- GitLab From 94813b86bf1981338de0a6e2ab50be3b4366f3bd Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 6 Jan 2012 22:47:17 +0000 Subject: [PATCH 0190/1846] sfc: Update the description of SFC_MTD SFC4000 boards also have an EEPROM exposed as MTD. The boot configuration is accessed through MTD. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig index ae40b666739b..8d423544a7e6 100644 --- a/drivers/net/ethernet/sfc/Kconfig +++ b/drivers/net/ethernet/sfc/Kconfig @@ -16,9 +16,9 @@ config SFC_MTD depends on SFC && MTD && !(SFC=y && MTD=m) default y ---help--- - This exposes the on-board flash memory as MTD devices (e.g. - /dev/mtd1). This makes it possible to upload new firmware - to the NIC. + This exposes the on-board flash and/or EEPROM as MTD devices + (e.g. /dev/mtd1). This is required to update the firmware or + the boot configuration under Linux. config SFC_MCDI_MON bool "Solarflare SFC9000-family hwmon support" depends on SFC && HWMON && !(SFC=y && HWMON=m) -- GitLab From b249513e8ba3ca8bc2c87e78eb6e302d5d8abd6f Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 9 Jan 2012 19:41:48 +0000 Subject: [PATCH 0191/1846] sfc: Remove obsolete function efx_dev_name() Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/net_driver.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index a4cf8cb8180c..310c50f06458 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -791,15 +791,6 @@ static inline int efx_dev_registered(struct efx_nic *efx) return efx->net_dev->reg_state == NETREG_REGISTERED; } -/* Net device name, for inclusion in log messages if it has been registered. - * Use efx->name not efx->net_dev->name so that races with (un)registration - * are harmless. - */ -static inline const char *efx_dev_name(struct efx_nic *efx) -{ - return efx_dev_registered(efx) ? efx->name : ""; -} - static inline unsigned int efx_port_num(struct efx_nic *efx) { return efx->net_dev->dev_id; -- GitLab From 73ba7b68e952d98b0885e35402b204a7a675f4a9 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 9 Jan 2012 19:47:08 +0000 Subject: [PATCH 0192/1846] sfc: Remove remnants of on-load self-test The out-of-tree version of the sfc driver used to run a self-test on each device before registering it. Although this was never included in-tree, some functions have checks for this special case which is not really possible. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 34 +++++++++++------------------ drivers/net/ethernet/sfc/nic.c | 6 ++--- drivers/net/ethernet/sfc/selftest.c | 12 ++++------ drivers/net/ethernet/sfc/tx.c | 4 +--- 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 9d4ab5e5e1fa..4f412fe22e8c 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -855,10 +855,8 @@ int __efx_reconfigure_port(struct efx_nic *efx) WARN_ON(!mutex_is_locked(&efx->mac_lock)); /* Serialise the promiscuous flag with efx_set_multicast_list. */ - if (efx_dev_registered(efx)) { - netif_addr_lock_bh(efx->net_dev); - netif_addr_unlock_bh(efx->net_dev); - } + netif_addr_lock_bh(efx->net_dev); + netif_addr_unlock_bh(efx->net_dev); /* Disable PHY transmit in mac level loopbacks */ phy_mode = efx->phy_mode; @@ -981,10 +979,8 @@ static void efx_stop_port(struct efx_nic *efx) mutex_unlock(&efx->mac_lock); /* Serialise against efx_set_multicast_list() */ - if (efx_dev_registered(efx)) { - netif_addr_lock_bh(efx->net_dev); - netif_addr_unlock_bh(efx->net_dev); - } + netif_addr_lock_bh(efx->net_dev); + netif_addr_unlock_bh(efx->net_dev); } static void efx_fini_port(struct efx_nic *efx) @@ -1394,14 +1390,14 @@ static void efx_start_all(struct efx_nic *efx) return; if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT)) return; - if (efx_dev_registered(efx) && !netif_running(efx->net_dev)) + if (!netif_running(efx->net_dev)) return; /* Mark the port as enabled so port reconfigurations can start, then * restart the transmit interface early so the watchdog timer stops */ efx_start_port(efx); - if (efx_dev_registered(efx) && netif_device_present(efx->net_dev)) + if (netif_device_present(efx->net_dev)) netif_tx_wake_all_queues(efx->net_dev); efx_for_each_channel(channel, efx) @@ -1492,11 +1488,9 @@ static void efx_stop_all(struct efx_nic *efx) /* Stop the kernel transmit interface late, so the watchdog * timer isn't ticking over the flush */ - if (efx_dev_registered(efx)) { - netif_tx_stop_all_queues(efx->net_dev); - netif_tx_lock_bh(efx->net_dev); - netif_tx_unlock_bh(efx->net_dev); - } + netif_tx_stop_all_queues(efx->net_dev); + netif_tx_lock_bh(efx->net_dev); + netif_tx_unlock_bh(efx->net_dev); } static void efx_remove_all(struct efx_nic *efx) @@ -2018,11 +2012,9 @@ static void efx_unregister_netdev(struct efx_nic *efx) efx_release_tx_buffers(tx_queue); } - if (efx_dev_registered(efx)) { - strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); - device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); - unregister_netdev(efx->net_dev); - } + strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); + device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); + unregister_netdev(efx->net_dev); } /************************************************************************** @@ -2438,7 +2430,7 @@ static int efx_pci_probe_main(struct efx_nic *efx) /* NIC initialisation * * This is called at module load (or hotplug insertion, - * theoretically). It sets up PCI mappings, tests and resets the NIC, + * theoretically). It sets up PCI mappings, resets the NIC, * sets up and registers the network devices with the kernel and hooks * the interrupt service routine. It does not prepare the device for * transmission; this is left to the first time one of the network diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index de7aa1c8ebda..cd250f197b38 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -726,11 +726,9 @@ efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event) tx_queue = efx_channel_get_tx_queue( channel, tx_ev_q_label % EFX_TXQ_TYPES); - if (efx_dev_registered(efx)) - netif_tx_lock(efx->net_dev); + netif_tx_lock(efx->net_dev); efx_notify_tx_desc(tx_queue); - if (efx_dev_registered(efx)) - netif_tx_unlock(efx->net_dev); + netif_tx_unlock(efx->net_dev); } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_PKT_ERR) && EFX_WORKAROUND_10727(efx)) { efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH); diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index 7def480570c3..febe2a9e6211 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -397,11 +397,9 @@ static int efx_begin_loopback(struct efx_tx_queue *tx_queue) * interrupt handler. */ smp_wmb(); - if (efx_dev_registered(efx)) - netif_tx_lock_bh(efx->net_dev); + netif_tx_lock_bh(efx->net_dev); rc = efx_enqueue_skb(tx_queue, skb); - if (efx_dev_registered(efx)) - netif_tx_unlock_bh(efx->net_dev); + netif_tx_unlock_bh(efx->net_dev); if (rc != NETDEV_TX_OK) { netif_err(efx, drv, efx->net_dev, @@ -442,8 +440,7 @@ static int efx_end_loopback(struct efx_tx_queue *tx_queue, int tx_done = 0, rx_good, rx_bad; int i, rc = 0; - if (efx_dev_registered(efx)) - netif_tx_lock_bh(efx->net_dev); + netif_tx_lock_bh(efx->net_dev); /* Count the number of tx completions, and decrement the refcnt. Any * skbs not already completed will be free'd when the queue is flushed */ @@ -454,8 +451,7 @@ static int efx_end_loopback(struct efx_tx_queue *tx_queue, dev_kfree_skb_any(skb); } - if (efx_dev_registered(efx)) - netif_tx_unlock_bh(efx->net_dev); + netif_tx_unlock_bh(efx->net_dev); /* Check TX completion and received packet counts */ rx_good = atomic_read(&state->rx_good); diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c index 72f0fbc73b1a..5cb81fa3fcbd 100644 --- a/drivers/net/ethernet/sfc/tx.c +++ b/drivers/net/ethernet/sfc/tx.c @@ -446,10 +446,8 @@ void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index) likely(efx->port_enabled) && likely(netif_device_present(efx->net_dev))) { fill_level = tx_queue->insert_count - tx_queue->read_count; - if (fill_level < EFX_TXQ_THRESHOLD(efx)) { - EFX_BUG_ON_PARANOID(!efx_dev_registered(efx)); + if (fill_level < EFX_TXQ_THRESHOLD(efx)) netif_tx_wake_queue(tx_queue->core_txq); - } } /* Check whether the hardware queue is now empty */ -- GitLab From 86ee53020abe4eb9c85e612129e3848ee98302fd Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 9 Jan 2012 19:51:22 +0000 Subject: [PATCH 0193/1846] sfc: Use existing local variables instead of repeated indirect lookups Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 4f412fe22e8c..c8e1c8a93edc 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -364,7 +364,7 @@ static int efx_probe_eventq(struct efx_channel *channel) struct efx_nic *efx = channel->efx; unsigned long entries; - netif_dbg(channel->efx, probe, channel->efx->net_dev, + netif_dbg(efx, probe, efx->net_dev, "chan %d create event queue\n", channel->channel); /* Build an event queue with room for one event per tx and rx buffer, @@ -1971,7 +1971,7 @@ static int efx_register_netdev(struct efx_nic *efx) } /* Always start with carrier off; PHY events will detect the link */ - netif_carrier_off(efx->net_dev); + netif_carrier_off(net_dev); rtnl_unlock(); -- GitLab From 2aa9ef11e70c47ed26f831798f02ad3794e5ad41 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 9 Jan 2012 19:53:41 +0000 Subject: [PATCH 0194/1846] sfc: Minor formatting fixes Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index c8e1c8a93edc..8ecddd056679 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -798,16 +798,14 @@ void efx_link_status_changed(struct efx_nic *efx) } /* Status message for kernel log */ - if (link_state->up) { + if (link_state->up) netif_info(efx, link, efx->net_dev, "link up at %uMbps %s-duplex (MTU %d)%s\n", link_state->speed, link_state->fd ? "full" : "half", efx->net_dev->mtu, (efx->promiscuous ? " [PROMISC]" : "")); - } else { + else netif_info(efx, link, efx->net_dev, "link down\n"); - } - } void efx_link_set_advertising(struct efx_nic *efx, u32 advertising) @@ -1741,7 +1739,8 @@ static int efx_net_stop(struct net_device *net_dev) } /* Context: process, dev_base_lock or RTNL held, non-blocking. */ -static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats) +static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev, + struct rtnl_link_stats64 *stats) { struct efx_nic *efx = netdev_priv(net_dev); struct efx_mac_stats *mac_stats = &efx->mac_stats; -- GitLab From 6c8eef4ac8dfd888be5b46e363f8e42b9f0d5b6a Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 9 Jan 2012 19:54:16 +0000 Subject: [PATCH 0195/1846] sfc: Remove redundant 'rc' variable, always set to 0 Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 8ecddd056679..fce42f428c6c 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1793,7 +1793,6 @@ static void efx_watchdog(struct net_device *net_dev) static int efx_change_mtu(struct net_device *net_dev, int new_mtu) { struct efx_nic *efx = netdev_priv(net_dev); - int rc = 0; EFX_ASSERT_RESET_SERIALISED(efx); @@ -1816,7 +1815,7 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu) efx_init_channels(efx); efx_start_all(efx); - return rc; + return 0; } static int efx_set_mac_address(struct net_device *net_dev, void *data) -- GitLab From 0fca8c97612f90a68ff6e1873e674b4d69a435db Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 9 Jan 2012 19:54:44 +0000 Subject: [PATCH 0196/1846] sfc: Rename implementation of ndo_set_rx_mode Rename efx_set_multicast_list() to efx_set_rx_mode(), in line with the operation name net_device_ops::ndo_set_rx_mode. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index fce42f428c6c..a352c55cb54a 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -852,7 +852,7 @@ int __efx_reconfigure_port(struct efx_nic *efx) WARN_ON(!mutex_is_locked(&efx->mac_lock)); - /* Serialise the promiscuous flag with efx_set_multicast_list. */ + /* Serialise the promiscuous flag with efx_set_rx_mode. */ netif_addr_lock_bh(efx->net_dev); netif_addr_unlock_bh(efx->net_dev); @@ -1844,7 +1844,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) } /* Context: netif_addr_lock held, BHs disabled. */ -static void efx_set_multicast_list(struct net_device *net_dev) +static void efx_set_rx_mode(struct net_device *net_dev) { struct efx_nic *efx = netdev_priv(net_dev); struct netdev_hw_addr *ha; @@ -1898,7 +1898,7 @@ static const struct net_device_ops efx_netdev_ops = { .ndo_do_ioctl = efx_ioctl, .ndo_change_mtu = efx_change_mtu, .ndo_set_mac_address = efx_set_mac_address, - .ndo_set_rx_mode = efx_set_multicast_list, + .ndo_set_rx_mode = efx_set_rx_mode, .ndo_set_features = efx_set_features, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = efx_netpoll, -- GitLab From f9c762500ae77ab8940094be1325c8a2a1c8e5f5 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 12 Oct 2011 17:20:25 +0100 Subject: [PATCH 0197/1846] sfc: Make all MAC statistics consistently 64 bits wide Currently we use type u64 for byte counts, which can very quickly exceed 2^32, and unsigned long for packet counts, which do not. But it can still take only 20-something minutes to send or receive 2^32 packets, and not all tools properly handle overflow even if they sample more often than this. The MAC statistics are all updated synchronously, so it costs very little to make them all 64-bit regardless of native word size. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/ethtool.c | 117 ++++++++++++-------------- drivers/net/ethernet/sfc/net_driver.h | 110 ++++++++++++------------ 2 files changed, 109 insertions(+), 118 deletions(-) diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index ba9011678013..f887f65e4189 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -52,11 +52,6 @@ static u64 efx_get_uint_stat(void *field) return *(unsigned int *)field; } -static u64 efx_get_ulong_stat(void *field) -{ - return *(unsigned long *)field; -} - static u64 efx_get_u64_stat(void *field) { return *(u64 *) field; @@ -67,10 +62,6 @@ static u64 efx_get_atomic_stat(void *field) return atomic_read((atomic_t *) field); } -#define EFX_ETHTOOL_ULONG_MAC_STAT(field) \ - EFX_ETHTOOL_STAT(field, mac_stats, field, \ - unsigned long, efx_get_ulong_stat) - #define EFX_ETHTOOL_U64_MAC_STAT(field) \ EFX_ETHTOOL_STAT(field, mac_stats, field, \ u64, efx_get_u64_stat) @@ -95,32 +86,32 @@ static const struct efx_ethtool_stat efx_ethtool_stats[] = { EFX_ETHTOOL_U64_MAC_STAT(tx_bytes), EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes), EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_packets), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_bad), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_pause), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_control), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_unicast), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_multicast), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_broadcast), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_lt64), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_64), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_65_to_127), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_128_to_255), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_256_to_511), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_512_to_1023), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_1024_to_15xx), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_15xx_to_jumbo), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_gtjumbo), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_collision), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_single_collision), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_multiple_collision), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_collision), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_deferred), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_late_collision), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_deferred), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_non_tcpudp), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_mac_src_error), - EFX_ETHTOOL_ULONG_MAC_STAT(tx_ip_src_error), + EFX_ETHTOOL_U64_MAC_STAT(tx_packets), + EFX_ETHTOOL_U64_MAC_STAT(tx_bad), + EFX_ETHTOOL_U64_MAC_STAT(tx_pause), + EFX_ETHTOOL_U64_MAC_STAT(tx_control), + EFX_ETHTOOL_U64_MAC_STAT(tx_unicast), + EFX_ETHTOOL_U64_MAC_STAT(tx_multicast), + EFX_ETHTOOL_U64_MAC_STAT(tx_broadcast), + EFX_ETHTOOL_U64_MAC_STAT(tx_lt64), + EFX_ETHTOOL_U64_MAC_STAT(tx_64), + EFX_ETHTOOL_U64_MAC_STAT(tx_65_to_127), + EFX_ETHTOOL_U64_MAC_STAT(tx_128_to_255), + EFX_ETHTOOL_U64_MAC_STAT(tx_256_to_511), + EFX_ETHTOOL_U64_MAC_STAT(tx_512_to_1023), + EFX_ETHTOOL_U64_MAC_STAT(tx_1024_to_15xx), + EFX_ETHTOOL_U64_MAC_STAT(tx_15xx_to_jumbo), + EFX_ETHTOOL_U64_MAC_STAT(tx_gtjumbo), + EFX_ETHTOOL_U64_MAC_STAT(tx_collision), + EFX_ETHTOOL_U64_MAC_STAT(tx_single_collision), + EFX_ETHTOOL_U64_MAC_STAT(tx_multiple_collision), + EFX_ETHTOOL_U64_MAC_STAT(tx_excessive_collision), + EFX_ETHTOOL_U64_MAC_STAT(tx_deferred), + EFX_ETHTOOL_U64_MAC_STAT(tx_late_collision), + EFX_ETHTOOL_U64_MAC_STAT(tx_excessive_deferred), + EFX_ETHTOOL_U64_MAC_STAT(tx_non_tcpudp), + EFX_ETHTOOL_U64_MAC_STAT(tx_mac_src_error), + EFX_ETHTOOL_U64_MAC_STAT(tx_ip_src_error), EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts), EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers), EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets), @@ -128,34 +119,34 @@ static const struct efx_ethtool_stat efx_ethtool_stats[] = { EFX_ETHTOOL_U64_MAC_STAT(rx_bytes), EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes), EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_packets), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_good), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_pause), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_control), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_unicast), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_multicast), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_broadcast), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_lt64), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_64), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_65_to_127), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_128_to_255), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_256_to_511), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_512_to_1023), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_1024_to_15xx), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_15xx_to_jumbo), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_gtjumbo), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_lt64), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_64_to_15xx), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_15xx_to_jumbo), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_gtjumbo), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_overflow), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_missed), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_false_carrier), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_symbol_error), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_align_error), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_length_error), - EFX_ETHTOOL_ULONG_MAC_STAT(rx_internal_error), + EFX_ETHTOOL_U64_MAC_STAT(rx_packets), + EFX_ETHTOOL_U64_MAC_STAT(rx_good), + EFX_ETHTOOL_U64_MAC_STAT(rx_bad), + EFX_ETHTOOL_U64_MAC_STAT(rx_pause), + EFX_ETHTOOL_U64_MAC_STAT(rx_control), + EFX_ETHTOOL_U64_MAC_STAT(rx_unicast), + EFX_ETHTOOL_U64_MAC_STAT(rx_multicast), + EFX_ETHTOOL_U64_MAC_STAT(rx_broadcast), + EFX_ETHTOOL_U64_MAC_STAT(rx_lt64), + EFX_ETHTOOL_U64_MAC_STAT(rx_64), + EFX_ETHTOOL_U64_MAC_STAT(rx_65_to_127), + EFX_ETHTOOL_U64_MAC_STAT(rx_128_to_255), + EFX_ETHTOOL_U64_MAC_STAT(rx_256_to_511), + EFX_ETHTOOL_U64_MAC_STAT(rx_512_to_1023), + EFX_ETHTOOL_U64_MAC_STAT(rx_1024_to_15xx), + EFX_ETHTOOL_U64_MAC_STAT(rx_15xx_to_jumbo), + EFX_ETHTOOL_U64_MAC_STAT(rx_gtjumbo), + EFX_ETHTOOL_U64_MAC_STAT(rx_bad_lt64), + EFX_ETHTOOL_U64_MAC_STAT(rx_bad_64_to_15xx), + EFX_ETHTOOL_U64_MAC_STAT(rx_bad_15xx_to_jumbo), + EFX_ETHTOOL_U64_MAC_STAT(rx_bad_gtjumbo), + EFX_ETHTOOL_U64_MAC_STAT(rx_overflow), + EFX_ETHTOOL_U64_MAC_STAT(rx_missed), + EFX_ETHTOOL_U64_MAC_STAT(rx_false_carrier), + EFX_ETHTOOL_U64_MAC_STAT(rx_symbol_error), + EFX_ETHTOOL_U64_MAC_STAT(rx_align_error), + EFX_ETHTOOL_U64_MAC_STAT(rx_length_error), + EFX_ETHTOOL_U64_MAC_STAT(rx_internal_error), EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt), EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset), EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc), diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 310c50f06458..c20483efc22c 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -538,64 +538,64 @@ struct efx_mac_stats { u64 tx_bytes; u64 tx_good_bytes; u64 tx_bad_bytes; - unsigned long tx_packets; - unsigned long tx_bad; - unsigned long tx_pause; - unsigned long tx_control; - unsigned long tx_unicast; - unsigned long tx_multicast; - unsigned long tx_broadcast; - unsigned long tx_lt64; - unsigned long tx_64; - unsigned long tx_65_to_127; - unsigned long tx_128_to_255; - unsigned long tx_256_to_511; - unsigned long tx_512_to_1023; - unsigned long tx_1024_to_15xx; - unsigned long tx_15xx_to_jumbo; - unsigned long tx_gtjumbo; - unsigned long tx_collision; - unsigned long tx_single_collision; - unsigned long tx_multiple_collision; - unsigned long tx_excessive_collision; - unsigned long tx_deferred; - unsigned long tx_late_collision; - unsigned long tx_excessive_deferred; - unsigned long tx_non_tcpudp; - unsigned long tx_mac_src_error; - unsigned long tx_ip_src_error; + u64 tx_packets; + u64 tx_bad; + u64 tx_pause; + u64 tx_control; + u64 tx_unicast; + u64 tx_multicast; + u64 tx_broadcast; + u64 tx_lt64; + u64 tx_64; + u64 tx_65_to_127; + u64 tx_128_to_255; + u64 tx_256_to_511; + u64 tx_512_to_1023; + u64 tx_1024_to_15xx; + u64 tx_15xx_to_jumbo; + u64 tx_gtjumbo; + u64 tx_collision; + u64 tx_single_collision; + u64 tx_multiple_collision; + u64 tx_excessive_collision; + u64 tx_deferred; + u64 tx_late_collision; + u64 tx_excessive_deferred; + u64 tx_non_tcpudp; + u64 tx_mac_src_error; + u64 tx_ip_src_error; u64 rx_bytes; u64 rx_good_bytes; u64 rx_bad_bytes; - unsigned long rx_packets; - unsigned long rx_good; - unsigned long rx_bad; - unsigned long rx_pause; - unsigned long rx_control; - unsigned long rx_unicast; - unsigned long rx_multicast; - unsigned long rx_broadcast; - unsigned long rx_lt64; - unsigned long rx_64; - unsigned long rx_65_to_127; - unsigned long rx_128_to_255; - unsigned long rx_256_to_511; - unsigned long rx_512_to_1023; - unsigned long rx_1024_to_15xx; - unsigned long rx_15xx_to_jumbo; - unsigned long rx_gtjumbo; - unsigned long rx_bad_lt64; - unsigned long rx_bad_64_to_15xx; - unsigned long rx_bad_15xx_to_jumbo; - unsigned long rx_bad_gtjumbo; - unsigned long rx_overflow; - unsigned long rx_missed; - unsigned long rx_false_carrier; - unsigned long rx_symbol_error; - unsigned long rx_align_error; - unsigned long rx_length_error; - unsigned long rx_internal_error; - unsigned long rx_good_lt64; + u64 rx_packets; + u64 rx_good; + u64 rx_bad; + u64 rx_pause; + u64 rx_control; + u64 rx_unicast; + u64 rx_multicast; + u64 rx_broadcast; + u64 rx_lt64; + u64 rx_64; + u64 rx_65_to_127; + u64 rx_128_to_255; + u64 rx_256_to_511; + u64 rx_512_to_1023; + u64 rx_1024_to_15xx; + u64 rx_15xx_to_jumbo; + u64 rx_gtjumbo; + u64 rx_bad_lt64; + u64 rx_bad_64_to_15xx; + u64 rx_bad_15xx_to_jumbo; + u64 rx_bad_gtjumbo; + u64 rx_overflow; + u64 rx_missed; + u64 rx_false_carrier; + u64 rx_symbol_error; + u64 rx_align_error; + u64 rx_length_error; + u64 rx_internal_error; + u64 rx_good_lt64; }; /* Number of bits used in a multicast filter hash address */ -- GitLab From 1ddceb4c69463e09b6929c750046c59589d45d82 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 23 Jan 2012 22:41:30 +0000 Subject: [PATCH 0198/1846] sfc: Move the end of the non-GRO RX path into its own function Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/rx.c | 41 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index 3572c34a79fb..d97c6ebcf06d 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -568,12 +568,30 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, channel->rx_pkt_csummed = checksummed; } +static void efx_rx_deliver(struct efx_channel *channel, + struct efx_rx_buffer *rx_buf) +{ + struct sk_buff *skb; + + /* We now own the SKB */ + skb = rx_buf->u.skb; + rx_buf->u.skb = NULL; + + /* Set the SKB flags */ + skb_checksum_none_assert(skb); + + /* Pass the packet up */ + netif_receive_skb(skb); + + /* Update allocation strategy method */ + channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; +} + /* Handle a received packet. Second half: Touches packet payload. */ void __efx_rx_packet(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, bool checksummed) { struct efx_nic *efx = channel->efx; - struct sk_buff *skb; u8 *eh = efx_rx_buf_eh(efx, rx_buf); /* If we're in loopback test, then pass the packet directly to the @@ -586,7 +604,7 @@ void __efx_rx_packet(struct efx_channel *channel, } if (!rx_buf->is_page) { - skb = rx_buf->u.skb; + struct sk_buff *skb = rx_buf->u.skb; prefetch(skb_shinfo(skb)); @@ -606,23 +624,10 @@ void __efx_rx_packet(struct efx_channel *channel, if (unlikely(!(efx->net_dev->features & NETIF_F_RXCSUM))) checksummed = false; - if (likely(checksummed || rx_buf->is_page)) { + if (likely(checksummed || rx_buf->is_page)) efx_rx_packet_gro(channel, rx_buf, eh, checksummed); - return; - } - - /* We now own the SKB */ - skb = rx_buf->u.skb; - rx_buf->u.skb = NULL; - - /* Set the SKB flags */ - skb_checksum_none_assert(skb); - - /* Pass the packet up */ - netif_receive_skb(skb); - - /* Update allocation strategy method */ - channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; + else + efx_rx_deliver(channel, rx_buf); } void efx_rx_strategy(struct efx_channel *channel) -- GitLab From db3395697cad6e9dff8d21249e0b59dc9bb83b48 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 26 Aug 2011 18:05:11 +0100 Subject: [PATCH 0199/1846] sfc: Replace efx_rx_buffer::is_page and other booleans with a flags field Replace checksummed and discard booleans from efx_handle_rx_event() with a bitmask, added to the flags field. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 3 +- drivers/net/ethernet/sfc/efx.h | 4 +- drivers/net/ethernet/sfc/net_driver.h | 16 ++++--- drivers/net/ethernet/sfc/nic.c | 32 +++++++------ drivers/net/ethernet/sfc/rx.c | 65 +++++++++++++-------------- 5 files changed, 59 insertions(+), 61 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index a352c55cb54a..952d0bf7695a 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -229,8 +229,7 @@ static int efx_process_channel(struct efx_channel *channel, int budget) /* Deliver last RX packet. */ if (channel->rx_pkt) { - __efx_rx_packet(channel, channel->rx_pkt, - channel->rx_pkt_csummed); + __efx_rx_packet(channel, channel->rx_pkt); channel->rx_pkt = NULL; } diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h index e0b66d158d79..7f546e2c39e2 100644 --- a/drivers/net/ethernet/sfc/efx.h +++ b/drivers/net/ethernet/sfc/efx.h @@ -40,9 +40,9 @@ extern void efx_rx_strategy(struct efx_channel *channel); extern void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue); extern void efx_rx_slow_fill(unsigned long context); extern void __efx_rx_packet(struct efx_channel *channel, - struct efx_rx_buffer *rx_buf, bool checksummed); + struct efx_rx_buffer *rx_buf); extern void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, - unsigned int len, bool checksummed, bool discard); + unsigned int len, u16 flags); extern void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue); #define EFX_MAX_DMAQ_SIZE 4096UL diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index c20483efc22c..53864014c2b4 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -205,12 +205,12 @@ struct efx_tx_queue { /** * struct efx_rx_buffer - An Efx RX data buffer * @dma_addr: DMA base address of the buffer - * @skb: The associated socket buffer, if any. - * If both this and page are %NULL, the buffer slot is currently free. - * @page: The associated page buffer, if any. - * If both this and skb are %NULL, the buffer slot is currently free. + * @skb: The associated socket buffer. Valid iff !(@flags & %EFX_RX_BUF_PAGE). + * Will be %NULL if the buffer slot is currently free. + * @page: The associated page buffer. Valif iff @flags & %EFX_RX_BUF_PAGE. + * Will be %NULL if the buffer slot is currently free. * @len: Buffer length, in bytes. - * @is_page: Indicates if @page is valid. If false, @skb is valid. + * @flags: Flags for buffer and packet state. */ struct efx_rx_buffer { dma_addr_t dma_addr; @@ -219,8 +219,11 @@ struct efx_rx_buffer { struct page *page; } u; unsigned int len; - bool is_page; + u16 flags; }; +#define EFX_RX_BUF_PAGE 0x0001 +#define EFX_RX_PKT_CSUMMED 0x0002 +#define EFX_RX_PKT_DISCARD 0x0004 /** * struct efx_rx_page_state - Page-based rx buffer state @@ -378,7 +381,6 @@ struct efx_channel { * access with prefetches. */ struct efx_rx_buffer *rx_pkt; - bool rx_pkt_csummed; struct efx_rx_queue rx_queue; struct efx_tx_queue tx_queue[EFX_TXQ_TYPES]; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index cd250f197b38..a43d1ca270c0 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -743,10 +743,8 @@ efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event) } /* Detect errors included in the rx_evt_pkt_ok bit. */ -static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue, - const efx_qword_t *event, - bool *rx_ev_pkt_ok, - bool *discard) +static u16 efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue, + const efx_qword_t *event) { struct efx_channel *channel = efx_rx_queue_channel(rx_queue); struct efx_nic *efx = rx_queue->efx; @@ -791,10 +789,6 @@ static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue, ++channel->n_rx_tcp_udp_chksum_err; } - /* The frame must be discarded if any of these are true. */ - *discard = (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib | - rx_ev_tobe_disc | rx_ev_pause_frm); - /* TOBE_DISC is expected on unicast mismatches; don't print out an * error message. FRM_TRUNC indicates RXDP dropped the packet due * to a FIFO overflow. @@ -817,6 +811,11 @@ static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue, rx_ev_pause_frm ? " [PAUSE]" : ""); } #endif + + /* The frame must be discarded if any of these are true. */ + return (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib | + rx_ev_tobe_disc | rx_ev_pause_frm) ? + EFX_RX_PKT_DISCARD : 0; } /* Handle receive events that are not in-order. */ @@ -849,7 +848,8 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event) unsigned int rx_ev_desc_ptr, rx_ev_byte_cnt; unsigned int rx_ev_hdr_type, rx_ev_mcast_pkt; unsigned expected_ptr; - bool rx_ev_pkt_ok, discard = false, checksummed; + bool rx_ev_pkt_ok; + u16 flags; struct efx_rx_queue *rx_queue; /* Basic packet information */ @@ -872,12 +872,11 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event) /* If packet is marked as OK and packet type is TCP/IP or * UDP/IP, then we can rely on the hardware checksum. */ - checksummed = - rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP || - rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP; + flags = (rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP || + rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP) ? + EFX_RX_PKT_CSUMMED : 0; } else { - efx_handle_rx_not_ok(rx_queue, event, &rx_ev_pkt_ok, &discard); - checksummed = false; + flags = efx_handle_rx_not_ok(rx_queue, event); } /* Detect multicast packets that didn't match the filter */ @@ -888,15 +887,14 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event) if (unlikely(!rx_ev_mcast_hash_match)) { ++channel->n_rx_mcast_mismatch; - discard = true; + flags |= EFX_RX_PKT_DISCARD; } } channel->irq_mod_score += 2; /* Handle received packet */ - efx_rx_packet(rx_queue, rx_ev_desc_ptr, rx_ev_byte_cnt, - checksummed, discard); + efx_rx_packet(rx_queue, rx_ev_desc_ptr, rx_ev_byte_cnt, flags); } static void diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index d97c6ebcf06d..a33aef25ead9 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -108,7 +108,7 @@ static inline unsigned int efx_rx_buf_size(struct efx_nic *efx) static u8 *efx_rx_buf_eh(struct efx_nic *efx, struct efx_rx_buffer *buf) { - if (buf->is_page) + if (buf->flags & EFX_RX_BUF_PAGE) return page_address(buf->u.page) + efx_rx_buf_offset(efx, buf); else return (u8 *)buf->u.skb->data + efx->type->rx_buffer_hash_size; @@ -158,7 +158,7 @@ static int efx_init_rx_buffers_skb(struct efx_rx_queue *rx_queue) /* Adjust the SKB for padding and checksum */ skb_reserve(skb, NET_IP_ALIGN); rx_buf->len = skb_len - NET_IP_ALIGN; - rx_buf->is_page = false; + rx_buf->flags = 0; skb->ip_summed = CHECKSUM_UNNECESSARY; rx_buf->dma_addr = pci_map_single(efx->pci_dev, @@ -227,7 +227,7 @@ static int efx_init_rx_buffers_page(struct efx_rx_queue *rx_queue) rx_buf->dma_addr = dma_addr + EFX_PAGE_IP_ALIGN; rx_buf->u.page = page; rx_buf->len = efx->rx_buffer_len - EFX_PAGE_IP_ALIGN; - rx_buf->is_page = true; + rx_buf->flags = EFX_RX_BUF_PAGE; ++rx_queue->added_count; ++rx_queue->alloc_page_count; ++state->refcnt; @@ -248,7 +248,7 @@ static int efx_init_rx_buffers_page(struct efx_rx_queue *rx_queue) static void efx_unmap_rx_buffer(struct efx_nic *efx, struct efx_rx_buffer *rx_buf) { - if (rx_buf->is_page && rx_buf->u.page) { + if ((rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.page) { struct efx_rx_page_state *state; state = page_address(rx_buf->u.page); @@ -258,7 +258,7 @@ static void efx_unmap_rx_buffer(struct efx_nic *efx, efx_rx_buf_size(efx), PCI_DMA_FROMDEVICE); } - } else if (!rx_buf->is_page && rx_buf->u.skb) { + } else if (!(rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.skb) { pci_unmap_single(efx->pci_dev, rx_buf->dma_addr, rx_buf->len, PCI_DMA_FROMDEVICE); } @@ -267,10 +267,10 @@ static void efx_unmap_rx_buffer(struct efx_nic *efx, static void efx_free_rx_buffer(struct efx_nic *efx, struct efx_rx_buffer *rx_buf) { - if (rx_buf->is_page && rx_buf->u.page) { + if ((rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.page) { __free_pages(rx_buf->u.page, efx->rx_buffer_order); rx_buf->u.page = NULL; - } else if (!rx_buf->is_page && rx_buf->u.skb) { + } else if (!(rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.skb) { dev_kfree_skb_any(rx_buf->u.skb); rx_buf->u.skb = NULL; } @@ -310,7 +310,7 @@ static void efx_resurrect_rx_buffer(struct efx_rx_queue *rx_queue, new_buf->dma_addr = rx_buf->dma_addr ^ (PAGE_SIZE >> 1); new_buf->u.page = rx_buf->u.page; new_buf->len = rx_buf->len; - new_buf->is_page = true; + new_buf->flags = EFX_RX_BUF_PAGE; ++rx_queue->added_count; } @@ -324,7 +324,10 @@ static void efx_recycle_rx_buffer(struct efx_channel *channel, struct efx_rx_buffer *new_buf; unsigned index; - if (rx_buf->is_page && efx->rx_buffer_len <= EFX_RX_HALF_PAGE && + rx_buf->flags &= EFX_RX_BUF_PAGE; + + if ((rx_buf->flags & EFX_RX_BUF_PAGE) && + efx->rx_buffer_len <= EFX_RX_HALF_PAGE && page_count(rx_buf->u.page) == 1) efx_resurrect_rx_buffer(rx_queue, rx_buf); @@ -411,8 +414,7 @@ void efx_rx_slow_fill(unsigned long context) static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, struct efx_rx_buffer *rx_buf, - int len, bool *discard, - bool *leak_packet) + int len, bool *leak_packet) { struct efx_nic *efx = rx_queue->efx; unsigned max_len = rx_buf->len - efx->type->rx_buffer_padding; @@ -423,7 +425,7 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, /* The packet must be discarded, but this is only a fatal error * if the caller indicated it was */ - *discard = true; + rx_buf->flags |= EFX_RX_PKT_DISCARD; if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) { if (net_ratelimit()) @@ -436,7 +438,7 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, * data at the end of the skb will be trashed. So * we have no choice but to leak the fragment. */ - *leak_packet = !rx_buf->is_page; + *leak_packet = !(rx_buf->flags & EFX_RX_BUF_PAGE); efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY); } else { if (net_ratelimit()) @@ -456,13 +458,13 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, */ static void efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, - const u8 *eh, bool checksummed) + const u8 *eh) { struct napi_struct *napi = &channel->napi_str; gro_result_t gro_result; /* Pass the skb/page into the GRO engine */ - if (rx_buf->is_page) { + if (rx_buf->flags & EFX_RX_BUF_PAGE) { struct efx_nic *efx = channel->efx; struct page *page = rx_buf->u.page; struct sk_buff *skb; @@ -484,8 +486,8 @@ static void efx_rx_packet_gro(struct efx_channel *channel, skb->len = rx_buf->len; skb->data_len = rx_buf->len; skb->truesize += rx_buf->len; - skb->ip_summed = - checksummed ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE; + skb->ip_summed = ((rx_buf->flags & EFX_RX_PKT_CSUMMED) ? + CHECKSUM_UNNECESSARY : CHECKSUM_NONE); skb_record_rx_queue(skb, channel->channel); @@ -493,7 +495,7 @@ static void efx_rx_packet_gro(struct efx_channel *channel, } else { struct sk_buff *skb = rx_buf->u.skb; - EFX_BUG_ON_PARANOID(!checksummed); + EFX_BUG_ON_PARANOID(!(rx_buf->flags & EFX_RX_PKT_CSUMMED)); rx_buf->u.skb = NULL; gro_result = napi_gro_receive(napi, skb); @@ -508,7 +510,7 @@ static void efx_rx_packet_gro(struct efx_channel *channel, } void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, - unsigned int len, bool checksummed, bool discard) + unsigned int len, u16 flags) { struct efx_nic *efx = rx_queue->efx; struct efx_channel *channel = efx_rx_queue_channel(rx_queue); @@ -516,6 +518,7 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, bool leak_packet = false; rx_buf = efx_rx_buffer(rx_queue, index); + rx_buf->flags |= flags; /* This allows the refill path to post another buffer. * EFX_RXD_HEAD_ROOM ensures that the slot we are using @@ -524,18 +527,17 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, rx_queue->removed_count++; /* Validate the length encoded in the event vs the descriptor pushed */ - efx_rx_packet__check_len(rx_queue, rx_buf, len, - &discard, &leak_packet); + efx_rx_packet__check_len(rx_queue, rx_buf, len, &leak_packet); netif_vdbg(efx, rx_status, efx->net_dev, "RX queue %d received id %x at %llx+%x %s%s\n", efx_rx_queue_index(rx_queue), index, (unsigned long long)rx_buf->dma_addr, len, - (checksummed ? " [SUMMED]" : ""), - (discard ? " [DISCARD]" : "")); + (rx_buf->flags & EFX_RX_PKT_CSUMMED) ? " [SUMMED]" : "", + (rx_buf->flags & EFX_RX_PKT_DISCARD) ? " [DISCARD]" : ""); /* Discard packet, if instructed to do so */ - if (unlikely(discard)) { + if (unlikely(rx_buf->flags & EFX_RX_PKT_DISCARD)) { if (unlikely(leak_packet)) channel->n_skbuff_leaks++; else @@ -562,10 +564,8 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, rx_buf->len = len - efx->type->rx_buffer_hash_size; out: if (channel->rx_pkt) - __efx_rx_packet(channel, - channel->rx_pkt, channel->rx_pkt_csummed); + __efx_rx_packet(channel, channel->rx_pkt); channel->rx_pkt = rx_buf; - channel->rx_pkt_csummed = checksummed; } static void efx_rx_deliver(struct efx_channel *channel, @@ -588,8 +588,7 @@ static void efx_rx_deliver(struct efx_channel *channel, } /* Handle a received packet. Second half: Touches packet payload. */ -void __efx_rx_packet(struct efx_channel *channel, - struct efx_rx_buffer *rx_buf, bool checksummed) +void __efx_rx_packet(struct efx_channel *channel, struct efx_rx_buffer *rx_buf) { struct efx_nic *efx = channel->efx; u8 *eh = efx_rx_buf_eh(efx, rx_buf); @@ -603,7 +602,7 @@ void __efx_rx_packet(struct efx_channel *channel, return; } - if (!rx_buf->is_page) { + if (!(rx_buf->flags & EFX_RX_BUF_PAGE)) { struct sk_buff *skb = rx_buf->u.skb; prefetch(skb_shinfo(skb)); @@ -622,10 +621,10 @@ void __efx_rx_packet(struct efx_channel *channel, } if (unlikely(!(efx->net_dev->features & NETIF_F_RXCSUM))) - checksummed = false; + rx_buf->flags &= ~EFX_RX_PKT_CSUMMED; - if (likely(checksummed || rx_buf->is_page)) - efx_rx_packet_gro(channel, rx_buf, eh, checksummed); + if (likely(rx_buf->flags & (EFX_RX_BUF_PAGE | EFX_RX_PKT_CSUMMED))) + efx_rx_packet_gro(channel, rx_buf, eh); else efx_rx_deliver(channel, rx_buf); } -- GitLab From 79d4e9087a6ecd6bf2103bf378bf8e0d79278b5a Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:27 +0000 Subject: [PATCH 0200/1846] e1000e: disable Early Receive DMA on ICH LOMs Internal stress testing with jumbo frames shows the reliability of ICH9 and ICH10D devices is improved in certain corner cases by disabling the Early Receive feature. To reduce the performance impact caused by disabling this feature, the packet buffer sizes and relevant flow control settings are modified accordingly. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 - drivers/net/ethernet/intel/e1000e/netdev.c | 60 +++++++++------------ 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 4b3a27670a6b..70bc9e902735 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -420,7 +420,7 @@ struct e1000_info { #define FLAG_HAS_FLASH (1 << 1) #define FLAG_HAS_HW_VLAN_FILTER (1 << 2) #define FLAG_HAS_WOL (1 << 3) -#define FLAG_HAS_ERT (1 << 4) +/* reserved bit4 */ #define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5) #define FLAG_HAS_SWSM_ON_LOAD (1 << 6) #define FLAG_HAS_JUMBO_FRAMES (1 << 7) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 1b69c2d6b417..e446e0582503 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -4110,7 +4110,6 @@ const struct e1000_info e1000_ich9_info = { | FLAG_HAS_WOL | FLAG_HAS_CTRLEXT_ON_LOAD | FLAG_HAS_AMT - | FLAG_HAS_ERT | FLAG_HAS_FLASH | FLAG_APME_IN_WUC, .pba = 10, @@ -4128,7 +4127,6 @@ const struct e1000_info e1000_ich10_info = { | FLAG_HAS_WOL | FLAG_HAS_CTRLEXT_ON_LOAD | FLAG_HAS_AMT - | FLAG_HAS_ERT | FLAG_HAS_FLASH | FLAG_APME_IN_WUC, .pba = 10, diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 89af6c026230..49b5ded26329 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -2947,8 +2947,7 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) * per packet. */ pages = PAGE_USE_COUNT(adapter->netdev->mtu); - if (!(adapter->flags & FLAG_HAS_ERT) && (pages <= 3) && - (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE)) + if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE)) adapter->rx_ps_pages = pages; else adapter->rx_ps_pages = 0; @@ -3095,23 +3094,14 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) } ew32(RXCSUM, rxcsum); - /* - * Enable early receives on supported devices, only takes effect when - * packet size is equal or larger than the specified value (in 8 byte - * units), e.g. using jumbo frames when setting to E1000_ERT_2048 - */ - if ((adapter->flags & FLAG_HAS_ERT) || - (adapter->hw.mac.type == e1000_pch2lan)) { + if (adapter->hw.mac.type == e1000_pch2lan) { + /* + * With jumbo frames, excessive C-state transition + * latencies result in dropped transactions. + */ if (adapter->netdev->mtu > ETH_DATA_LEN) { u32 rxdctl = er32(RXDCTL(0)); ew32(RXDCTL(0), rxdctl | 0x3); - if (adapter->flags & FLAG_HAS_ERT) - ew32(ERT, E1000_ERT_2048 | (1 << 13)); - /* - * With jumbo frames and early-receive enabled, - * excessive C-state transition latencies result in - * dropped transactions. - */ pm_qos_update_request(&adapter->netdev->pm_qos_req, 55); } else { pm_qos_update_request(&adapter->netdev->pm_qos_req, @@ -3422,9 +3412,7 @@ void e1000e_reset(struct e1000_adapter *adapter) * if short on Rx space, Rx wins and must trump Tx * adjustment or use Early Receive if available */ - if ((pba < min_rx_space) && - (!(adapter->flags & FLAG_HAS_ERT))) - /* ERT enabled in e1000_configure_rx */ + if (pba < min_rx_space) pba = min_rx_space; } @@ -3438,8 +3426,6 @@ void e1000e_reset(struct e1000_adapter *adapter) * (or the size used for early receive) above it in the Rx FIFO. * Set it to the lower of: * - 90% of the Rx FIFO size, and - * - the full Rx FIFO size minus the early receive size (for parts - * with ERT support assuming ERT set to E1000_ERT_2048), or * - the full Rx FIFO size minus one full frame */ if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME) @@ -3450,14 +3436,19 @@ void e1000e_reset(struct e1000_adapter *adapter) fc->current_mode = fc->requested_mode; switch (hw->mac.type) { + case e1000_ich9lan: + case e1000_ich10lan: + if (adapter->netdev->mtu > ETH_DATA_LEN) { + pba = 14; + ew32(PBA, pba); + fc->high_water = 0x2800; + fc->low_water = fc->high_water - 8; + break; + } + /* fall-through */ default: - if ((adapter->flags & FLAG_HAS_ERT) && - (adapter->netdev->mtu > ETH_DATA_LEN)) - hwm = min(((pba << 10) * 9 / 10), - ((pba << 10) - (E1000_ERT_2048 << 3))); - else - hwm = min(((pba << 10) * 9 / 10), - ((pba << 10) - adapter->max_frame_size)); + hwm = min(((pba << 10) * 9 / 10), + ((pba << 10) - adapter->max_frame_size)); fc->high_water = hwm & E1000_FCRTH_RTH; /* 8-byte granularity */ fc->low_water = fc->high_water - 8; @@ -3490,11 +3481,10 @@ void e1000e_reset(struct e1000_adapter *adapter) /* * Disable Adaptive Interrupt Moderation if 2 full packets cannot - * fit in receive buffer and early-receive not supported. + * fit in receive buffer. */ if (adapter->itr_setting & 0x3) { - if (((adapter->max_frame_size * 2) > (pba << 10)) && - !(adapter->flags & FLAG_HAS_ERT)) { + if ((adapter->max_frame_size * 2) > (pba << 10)) { if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) { dev_info(&adapter->pdev->dev, "Interrupt Throttle Rate turned off\n"); @@ -3862,9 +3852,8 @@ static int e1000_open(struct net_device *netdev) E1000_MNG_DHCP_COOKIE_STATUS_VLAN)) e1000_update_mng_vlan(adapter); - /* DMA latency requirement to workaround early-receive/jumbo issue */ - if ((adapter->flags & FLAG_HAS_ERT) || - (adapter->hw.mac.type == e1000_pch2lan)) + /* DMA latency requirement to workaround jumbo issue */ + if (adapter->hw.mac.type == e1000_pch2lan) pm_qos_add_request(&adapter->netdev->pm_qos_req, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); @@ -3975,8 +3964,7 @@ static int e1000_close(struct net_device *netdev) !test_bit(__E1000_TESTING, &adapter->state)) e1000e_release_hw_control(adapter); - if ((adapter->flags & FLAG_HAS_ERT) || - (adapter->hw.mac.type == e1000_pch2lan)) + if (adapter->hw.mac.type == e1000_pch2lan) pm_qos_remove_request(&adapter->netdev->pm_qos_req); pm_runtime_put_sync(&pdev->dev); -- GitLab From 90b82984a4ce689d7b1d7132e50bc61ac6f8b74f Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:33 +0000 Subject: [PATCH 0201/1846] e1000e: update workaround for 82579 intermittently disabled during S0->Sx The workaround which toggles the LANPHYPC (LAN PHY Power Control) value bit to force the MAC-Phy interconnect into PCIe mode from SMBus mode during driver load and resume should always be done except if PHY resets are blocked by the Manageability Engine (ME). Previously, the toggle was done only if PHY resets are blocked and the ME was disabled. The rest of the patch is just indentation changes as a consequence of the updated workaround. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 103 ++++++++++---------- 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index e446e0582503..50a61fcf75cc 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -306,7 +306,6 @@ static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw) static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; - u32 fwsm; s32 ret_val = 0; phy->addr = 1; @@ -325,14 +324,14 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; - /* - * The MAC-PHY interconnect may still be in SMBus mode - * after Sx->S0. If the manageability engine (ME) is - * disabled, then toggle the LANPHYPC Value bit to force - * the interconnect to PCIe mode. - */ - fwsm = er32(FWSM); - if (!(fwsm & E1000_ICH_FWSM_FW_VALID) && !e1000_check_reset_block(hw)) { + if (!e1000_check_reset_block(hw)) { + u32 fwsm = er32(FWSM); + + /* + * The MAC-PHY interconnect may still be in SMBus mode after + * Sx->S0. If resetting the PHY is not blocked, toggle the + * LANPHYPC Value bit to force the interconnect to PCIe mode. + */ e1000_toggle_lanphypc_value_ich8lan(hw); msleep(50); @@ -340,25 +339,26 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) * Gate automatic PHY configuration by hardware on * non-managed 82579 */ - if (hw->mac.type == e1000_pch2lan) + if ((hw->mac.type == e1000_pch2lan) && + !(fwsm & E1000_ICH_FWSM_FW_VALID)) e1000_gate_hw_phy_config_ich8lan(hw, true); - } - /* - * Reset the PHY before any access to it. Doing so, ensures that - * the PHY is in a known good state before we read/write PHY registers. - * The generic reset is sufficient here, because we haven't determined - * the PHY type yet. - */ - ret_val = e1000e_phy_hw_reset_generic(hw); - if (ret_val) - goto out; + /* + * Reset the PHY before any access to it. Doing so, ensures + * that the PHY is in a known good state before we read/write + * PHY registers. The generic reset is sufficient here, + * because we haven't determined the PHY type yet. + */ + ret_val = e1000e_phy_hw_reset_generic(hw); + if (ret_val) + goto out; - /* Ungate automatic PHY configuration on non-managed 82579 */ - if ((hw->mac.type == e1000_pch2lan) && - !(fwsm & E1000_ICH_FWSM_FW_VALID)) { - usleep_range(10000, 20000); - e1000_gate_hw_phy_config_ich8lan(hw, false); + /* Ungate automatic PHY configuration on non-managed 82579 */ + if ((hw->mac.type == e1000_pch2lan) && + !(fwsm & E1000_ICH_FWSM_FW_VALID)) { + usleep_range(10000, 20000); + e1000_gate_hw_phy_config_ich8lan(hw, false); + } } phy->id = e1000_phy_unknown; @@ -3736,42 +3736,37 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) **/ void e1000_resume_workarounds_pchlan(struct e1000_hw *hw) { - u32 fwsm; + u16 phy_id1, phy_id2; + s32 ret_val; - if (hw->mac.type != e1000_pch2lan) + if ((hw->mac.type != e1000_pch2lan) || e1000_check_reset_block(hw)) return; - fwsm = er32(FWSM); - if (!(fwsm & E1000_ICH_FWSM_FW_VALID) || !e1000_check_reset_block(hw)) { - u16 phy_id1, phy_id2; - s32 ret_val; - - ret_val = hw->phy.ops.acquire(hw); - if (ret_val) { - e_dbg("Failed to acquire PHY semaphore in resume\n"); - return; - } + ret_val = hw->phy.ops.acquire(hw); + if (ret_val) { + e_dbg("Failed to acquire PHY semaphore in resume\n"); + return; + } - /* Test access to the PHY registers by reading the ID regs */ - ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_id1); - if (ret_val) - goto release; - ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_id2); - if (ret_val) - goto release; + /* Test access to the PHY registers by reading the ID regs */ + ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_id1); + if (ret_val) + goto release; + ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_id2); + if (ret_val) + goto release; - if (hw->phy.id == ((u32)(phy_id1 << 16) | - (u32)(phy_id2 & PHY_REVISION_MASK))) - goto release; + if (hw->phy.id == ((u32)(phy_id1 << 16) | + (u32)(phy_id2 & PHY_REVISION_MASK))) + goto release; - e1000_toggle_lanphypc_value_ich8lan(hw); + e1000_toggle_lanphypc_value_ich8lan(hw); - hw->phy.ops.release(hw); - msleep(50); - e1000_phy_hw_reset(hw); - msleep(50); - return; - } + hw->phy.ops.release(hw); + msleep(50); + e1000_phy_hw_reset(hw); + msleep(50); + return; release: hw->phy.ops.release(hw); -- GitLab From c077a9065b8d4612e4d55bd53c3563ca10d5c944 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:38 +0000 Subject: [PATCH 0202/1846] e1000e: ICHx/PCHx LOMs should use LPLU setting in NVM when going to Sx When going to Sx with an ICHx/PCH device, the default Low Power Link Up (LPLU, a.k.a. reverse auto-negotiation) behavior should be whatever is set in the NVM. However, the function e1000_suspend_workarounds_ich8lan() called when going to Sx always enabled LPLU in all power states. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 50a61fcf75cc..00b5e34fcfad 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -3698,9 +3698,10 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) * * During S0 to Sx transition, it is possible the link remains at gig * instead of negotiating to a lower speed. Before going to Sx, set - * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation - * to a lower speed. For PCH and newer parts, the OEM bits PHY register - * (LED, GbE disable and LPLU configurations) also needs to be written. + * 'Gig Disable' to force link speed negotiation to a lower speed based on + * the LPLU setting in the NVM or custom setting. For PCH and newer parts, + * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also + * needs to be written. **/ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) { @@ -3708,7 +3709,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) s32 ret_val; phy_ctrl = er32(PHY_CTRL); - phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | E1000_PHY_CTRL_GBE_DISABLE; + phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE; ew32(PHY_CTRL, phy_ctrl); if (hw->mac.type == e1000_ich8lan) -- GitLab From 7f1557e1422a4cc842af641c6716714751c06865 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:43 +0000 Subject: [PATCH 0203/1846] e1000e: increase Rx PBA to prevent dropping received packets on 82566/82567 During bi-directional stress on some 82566/82567 devices, some received packets were dropped. Increasing the Receive Packet Buffer Allocation resolves this. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 00b5e34fcfad..d99548ce4da7 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -4108,7 +4108,7 @@ const struct e1000_info e1000_ich9_info = { | FLAG_HAS_AMT | FLAG_HAS_FLASH | FLAG_APME_IN_WUC, - .pba = 10, + .pba = 18, .max_hw_frame_size = DEFAULT_JUMBO, .get_variants = e1000_get_variants_ich8lan, .mac_ops = &ich8_mac_ops, @@ -4125,7 +4125,7 @@ const struct e1000_info e1000_ich10_info = { | FLAG_HAS_AMT | FLAG_HAS_FLASH | FLAG_APME_IN_WUC, - .pba = 10, + .pba = 18, .max_hw_frame_size = DEFAULT_JUMBO, .get_variants = e1000_get_variants_ich8lan, .mac_ops = &ich8_mac_ops, -- GitLab From 464c85e37e6b2d2ad4f3bea23a59408c5595db15 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:49 +0000 Subject: [PATCH 0204/1846] e1000e: conditionally restart autoneg on 82577/8/9 when setting LPLU state When setting the Low Power Link Up (LPLU, a.k.a. reverse auto-negotiation) on 82577/8278/82579, do not restart auto-negotiation if reset of the Phy is blocked by the Manageability Engine. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index d99548ce4da7..6a6e6f6d9e73 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1921,7 +1921,9 @@ static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) else oem_reg &= ~HV_OEM_BITS_LPLU; - oem_reg |= HV_OEM_BITS_RESTART_AN; + if (!e1000_check_reset_block(hw)) + oem_reg |= HV_OEM_BITS_RESTART_AN; + ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg); out: -- GitLab From 434f1392ae3a3934a33d2d16987d857c97951c3d Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:54 +0000 Subject: [PATCH 0205/1846] e1000e: concatenate long debug strings which span multiple lines To ease searching for debug message strings, concatenate strings that span multiple lines even if the resulting line exceeds 80 columns; these will not cause checkpatch warnings. Also, add '\n' and remove unnecessary '\r' from a few debug strings. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/e1000e/80003es2lan.c | 3 +-- drivers/net/ethernet/intel/e1000e/ich8lan.c | 15 +++++--------- drivers/net/ethernet/intel/e1000e/lib.c | 20 ++++++++----------- drivers/net/ethernet/intel/e1000e/phy.c | 3 +-- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index b3a235c8ed85..f323ce507f58 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -667,8 +667,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) udelay(1); if (hw->phy.autoneg_wait_to_complete) { - e_dbg("Waiting for forced speed/duplex link " - "on GG82563 phy.\n"); + e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n"); ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 6a6e6f6d9e73..53e5447cbbca 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -902,8 +902,7 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) } if (!timeout) { - e_dbg("Failed to acquire the semaphore, FW or HW has it: " - "FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n", + e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n", er32(FWSM), extcnf_ctrl); extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; ew32(EXTCNF_CTRL, extcnf_ctrl); @@ -2132,8 +2131,7 @@ static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) return 0; } - e_dbg("Unable to determine valid NVM bank via EEC - " - "reading flash signature\n"); + e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n"); /* fall-thru */ default: /* set bank to 0 in case flash read fails */ @@ -2245,8 +2243,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) /* Check if the flash descriptor is valid */ if (hsfsts.hsf_status.fldesvalid == 0) { - e_dbg("Flash descriptor invalid. " - "SW Sequencing must be used.\n"); + e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n"); return -E1000_ERR_NVM; } @@ -2446,8 +2443,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, /* Repeat for some time before giving up. */ continue; } else if (hsfsts.hsf_status.flcdone == 0) { - e_dbg("Timeout error - flash cycle " - "did not complete.\n"); + e_dbg("Timeout error - flash cycle did not complete.\n"); break; } } @@ -2798,8 +2794,7 @@ static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, /* Repeat for some time before giving up. */ continue; if (hsfsts.hsf_status.flcdone == 0) { - e_dbg("Timeout error - flash cycle " - "did not complete."); + e_dbg("Timeout error - flash cycle did not complete.\n"); break; } } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); diff --git a/drivers/net/ethernet/intel/e1000e/lib.c b/drivers/net/ethernet/intel/e1000e/lib.c index 78e3f4c0c367..e2678bda8599 100644 --- a/drivers/net/ethernet/intel/e1000e/lib.c +++ b/drivers/net/ethernet/intel/e1000e/lib.c @@ -653,12 +653,10 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) if (rxcw & E1000_RXCW_SYNCH) { if (!(rxcw & E1000_RXCW_IV)) { mac->serdes_has_link = true; - e_dbg("SERDES: Link up - autoneg " - "completed successfully.\n"); + e_dbg("SERDES: Link up - autoneg completed successfully.\n"); } else { mac->serdes_has_link = false; - e_dbg("SERDES: Link down - invalid" - "codewords detected in autoneg.\n"); + e_dbg("SERDES: Link down - invalid codewords detected in autoneg.\n"); } } else { mac->serdes_has_link = false; @@ -1118,8 +1116,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) return ret_val; if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) { - e_dbg("Copper PHY and Auto Neg " - "has not completed.\n"); + e_dbg("Copper PHY and Auto Neg has not completed.\n"); return ret_val; } @@ -1183,11 +1180,10 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) */ if (hw->fc.requested_mode == e1000_fc_full) { hw->fc.current_mode = e1000_fc_full; - e_dbg("Flow Control = FULL.\r\n"); + e_dbg("Flow Control = FULL.\n"); } else { hw->fc.current_mode = e1000_fc_rx_pause; - e_dbg("Flow Control = " - "Rx PAUSE frames only.\r\n"); + e_dbg("Flow Control = Rx PAUSE frames only.\n"); } } /* @@ -1203,7 +1199,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { hw->fc.current_mode = e1000_fc_tx_pause; - e_dbg("Flow Control = Tx PAUSE frames only.\r\n"); + e_dbg("Flow Control = Tx PAUSE frames only.\n"); } /* * For transmitting PAUSE frames ONLY. @@ -1218,14 +1214,14 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { hw->fc.current_mode = e1000_fc_rx_pause; - e_dbg("Flow Control = Rx PAUSE frames only.\r\n"); + e_dbg("Flow Control = Rx PAUSE frames only.\n"); } else { /* * Per the IEEE spec, at this point flow control * should be disabled. */ hw->fc.current_mode = e1000_fc_none; - e_dbg("Flow Control = NONE.\r\n"); + e_dbg("Flow Control = NONE.\n"); } /* diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 8666476cb9be..ed70d08db5b6 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1136,8 +1136,7 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw) if (phy->autoneg_wait_to_complete) { ret_val = e1000_wait_autoneg(hw); if (ret_val) { - e_dbg("Error while waiting for " - "autoneg to complete\n"); + e_dbg("Error while waiting for autoneg to complete\n"); return ret_val; } } -- GitLab From f2315bf1d1c6e9e0e05262b7910a8f1491d2d60e Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:46:59 +0000 Subject: [PATCH 0206/1846] e1000e: convert final strncpy() to strlcpy() Convert the last instances of strncpy() to the preferred strlcpy(). Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 49b5ded26329..d6b451f9a095 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -5947,7 +5947,7 @@ static void e1000_print_device_info(struct e1000_adapter *adapter) ret_val = e1000_read_pba_string_generic(hw, pba_str, E1000_PBANUM_LENGTH); if (ret_val) - strncpy((char *)pba_str, "Unknown", sizeof(pba_str) - 1); + strlcpy((char *)pba_str, "Unknown", sizeof(pba_str)); e_info("MAC: %d, PHY: %d, PBA No: %s\n", hw->mac.type, hw->phy.type, pba_str); } @@ -6139,7 +6139,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, e1000e_set_ethtool_ops(netdev); netdev->watchdog_timeo = 5 * HZ; netif_napi_add(netdev, &adapter->napi, e1000_clean, 64); - strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1); + strlcpy(netdev->name, pci_name(pdev), sizeof(netdev->name)); netdev->mem_start = mmio_start; netdev->mem_end = mmio_start + mmio_len; @@ -6321,7 +6321,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, if (!(adapter->flags & FLAG_HAS_AMT)) e1000e_get_hw_control(adapter); - strncpy(netdev->name, "eth%d", sizeof(netdev->name) - 1); + strlcpy(netdev->name, "eth%d", sizeof(netdev->name)); err = register_netdev(netdev); if (err) goto err_register; -- GitLab From 058e8edd11fb2c694c3c6c9fd8407439eb3eb954 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 16 Dec 2011 00:47:04 +0000 Subject: [PATCH 0207/1846] e1000e: increase version number Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index d6b451f9a095..210d27ddd8cd 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -56,7 +56,7 @@ #define DRV_EXTRAVERSION "-k" -#define DRV_VERSION "1.5.1" DRV_EXTRAVERSION +#define DRV_VERSION "1.9.5" DRV_EXTRAVERSION char e1000e_driver_name[] = "e1000e"; const char e1000e_driver_version[] = DRV_VERSION; -- GitLab From c8243ee0488d9bc12995ca7ea02f651db820622e Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Sat, 17 Dec 2011 08:32:57 +0000 Subject: [PATCH 0208/1846] e1000e: call er16flash() instead of __er16flash() __er16flash() is not meant to be called directly. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 53e5447cbbca..070a90f78aa9 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2279,7 +2279,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) * cycle has a chance to end before giving up. */ for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) { - hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS); + hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); if (hsfsts.hsf_status.flcinprog == 0) { ret_val = 0; break; -- GitLab From fe2ddfb510f9d305a6654c7538c5c8faf326a16c Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 21 Dec 2011 09:47:10 +0000 Subject: [PATCH 0209/1846] e1000e: split lib.c into three more-appropriate files The generic lib.c file contains code relative to the various MACs, NVM and Manageability supported by the driver. This patch splits the file into three which are specific to those areas similar to how the PHY-specific code is in phy.c and code specific to the 80003es2lan, 8257x, and ichX MAC families are in their own files. The generic code that is applicable to all MAC/PHY parts supported by the driver remains in netdev.c, param.c and ethtool.c files. No change in functionality, just moving code around for ease of maintenance, with some whitespace and other checkpatch cleanups. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/Makefile | 3 +- .../ethernet/intel/e1000e/{lib.c => mac.c} | 1019 +---------------- drivers/net/ethernet/intel/e1000e/manage.c | 377 ++++++ drivers/net/ethernet/intel/e1000e/nvm.c | 647 +++++++++++ 4 files changed, 1051 insertions(+), 995 deletions(-) rename drivers/net/ethernet/intel/e1000e/{lib.c => mac.c} (65%) create mode 100644 drivers/net/ethernet/intel/e1000e/manage.c create mode 100644 drivers/net/ethernet/intel/e1000e/nvm.c diff --git a/drivers/net/ethernet/intel/e1000e/Makefile b/drivers/net/ethernet/intel/e1000e/Makefile index 948c05db5d68..8b888e5f6a06 100644 --- a/drivers/net/ethernet/intel/e1000e/Makefile +++ b/drivers/net/ethernet/intel/e1000e/Makefile @@ -33,5 +33,6 @@ obj-$(CONFIG_E1000E) += e1000e.o e1000e-objs := 82571.o ich8lan.o 80003es2lan.o \ - lib.o phy.o param.o ethtool.o netdev.o + mac.o manage.o nvm.o phy.o \ + param.o ethtool.o netdev.o diff --git a/drivers/net/ethernet/intel/e1000e/lib.c b/drivers/net/ethernet/intel/e1000e/mac.c similarity index 65% rename from drivers/net/ethernet/intel/e1000e/lib.c rename to drivers/net/ethernet/intel/e1000e/mac.c index e2678bda8599..64b6f439338a 100644 --- a/drivers/net/ethernet/intel/e1000e/lib.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -28,19 +28,6 @@ #include "e1000.h" -enum e1000_mng_mode { - e1000_mng_mode_none = 0, - e1000_mng_mode_asf, - e1000_mng_mode_pt, - e1000_mng_mode_ipmi, - e1000_mng_mode_host_if_only -}; - -#define E1000_FACTPS_MNGCG 0x20000000 - -/* Intel(R) Active Management Technology signature */ -#define E1000_IAMT_SIGNATURE 0x544D4149 - /** * e1000e_get_bus_info_pcie - Get PCIe bus information * @hw: pointer to the HW structure @@ -151,7 +138,7 @@ void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value) void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) { u32 i; - u8 mac_addr[ETH_ALEN] = {0}; + u8 mac_addr[ETH_ALEN] = { 0 }; /* Setup the receive address */ e_dbg("Programming MAC Address into RAR[0]\n"); @@ -159,7 +146,7 @@ void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) e1000e_rar_set(hw, hw->mac.addr, 0); /* Zero out the other (rar_entry_count - 1) receive addresses */ - e_dbg("Clearing RAR[1-%u]\n", rar_count-1); + e_dbg("Clearing RAR[1-%u]\n", rar_count - 1); for (i = 1; i < rar_count; i++) e1000e_rar_set(hw, mac_addr, i); } @@ -192,7 +179,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) goto out; ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, - &nvm_alt_mac_addr_offset); + &nvm_alt_mac_addr_offset); if (ret_val) { e_dbg("NVM Read Error\n"); goto out; @@ -251,11 +238,10 @@ void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) * HW expects these in little endian so we reverse the byte order * from network order (big endian) to little endian */ - rar_low = ((u32) addr[0] | - ((u32) addr[1] << 8) | - ((u32) addr[2] << 16) | ((u32) addr[3] << 24)); + rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) | + ((u32)addr[2] << 16) | ((u32)addr[3] << 24)); - rar_high = ((u32) addr[4] | ((u32) addr[5] << 8)); + rar_high = ((u32)addr[4] | ((u32)addr[5] << 8)); /* If MAC address zero, no need to set the AV bit */ if (rar_low || rar_high) @@ -315,7 +301,7 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) * values resulting from each mc_filter_type... * [0] [1] [2] [3] [4] [5] * 01 AA 00 12 34 56 - * LSB MSB + * LSB MSB * * case 0: hash_value = ((0x34 >> 4) | (0x56 << 4)) & 0xFFF = 0x563 * case 1: hash_value = ((0x34 >> 3) | (0x56 << 5)) & 0xFFF = 0xAC6 @@ -338,7 +324,7 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) } hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) | - (((u16) mc_addr[5]) << bit_shift))); + (((u16)mc_addr[5]) << bit_shift))); return hash_value; } @@ -362,7 +348,7 @@ void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow)); /* update mta_shadow from mc_addr_list */ - for (i = 0; (u32) i < mc_addr_count; i++) { + for (i = 0; (u32)i < mc_addr_count; i++) { hash_value = e1000_hash_mc_addr(hw, mc_addr_list); hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); @@ -458,7 +444,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) return ret_val; if (!link) - return ret_val; /* No link detected */ + return ret_val; /* No link detected */ mac->get_link_status = false; @@ -701,8 +687,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) hw->fc.requested_mode = e1000_fc_none; - else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == - NVM_WORD0F_ASM_DIR) + else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == NVM_WORD0F_ASM_DIR) hw->fc.requested_mode = e1000_fc_tx_pause; else hw->fc.requested_mode = e1000_fc_full; @@ -748,8 +733,7 @@ s32 e1000e_setup_link(struct e1000_hw *hw) */ hw->fc.current_mode = hw->fc.requested_mode; - e_dbg("After fix-ups FlowControl is now = %x\n", - hw->fc.current_mode); + e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode); /* Call the necessary media_type subroutine to configure the link. */ ret_val = mac->ops.setup_physical_interface(hw); @@ -1195,9 +1179,9 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) * 0 | 1 | 1 | 1 | e1000_fc_tx_pause */ else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) && - (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && - (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && - (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { + (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && + (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && + (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { hw->fc.current_mode = e1000_fc_tx_pause; e_dbg("Flow Control = Tx PAUSE frames only.\n"); } @@ -1261,7 +1245,8 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) * Read the status register for the current speed/duplex and store the current * speed and duplex for copper connections. **/ -s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex) +s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, + u16 *duplex) { u32 status; @@ -1294,7 +1279,8 @@ s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *dup * Sets the speed and duplex to gigabit full duplex (the only possible option) * for fiber/serdes links. **/ -s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex) +s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, + u16 *duplex) { *speed = SPEED_1000; *duplex = FULL_DUPLEX; @@ -1497,11 +1483,10 @@ s32 e1000e_setup_led_generic(struct e1000_hw *hw) ledctl = er32(LEDCTL); hw->mac.ledctl_default = ledctl; /* Turn off LED0 */ - ledctl &= ~(E1000_LEDCTL_LED0_IVRT | - E1000_LEDCTL_LED0_BLINK | - E1000_LEDCTL_LED0_MODE_MASK); + ledctl &= ~(E1000_LEDCTL_LED0_IVRT | E1000_LEDCTL_LED0_BLINK | + E1000_LEDCTL_LED0_MODE_MASK); ledctl |= (E1000_LEDCTL_MODE_LED_OFF << - E1000_LEDCTL_LED0_MODE_SHIFT); + E1000_LEDCTL_LED0_MODE_SHIFT); ew32(LEDCTL, ledctl); } else if (hw->phy.media_type == e1000_media_type_copper) { ew32(LEDCTL, hw->mac.ledctl_mode1); @@ -1537,7 +1522,7 @@ s32 e1000e_blink_led_generic(struct e1000_hw *hw) if (hw->phy.media_type == e1000_media_type_fiber) { /* always blink LED0 for PCI-E fiber */ ledctl_blink = E1000_LEDCTL_LED0_BLINK | - (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); + (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); } else { /* * set the blink bit for each LED that's "on" (0x0E) @@ -1650,8 +1635,7 @@ s32 e1000e_disable_pcie_master(struct e1000_hw *hw) ew32(CTRL, ctrl); while (timeout) { - if (!(er32(STATUS) & - E1000_STATUS_GIO_MASTER_ENABLE)) + if (!(er32(STATUS) & E1000_STATUS_GIO_MASTER_ENABLE)) break; udelay(100); timeout--; @@ -1716,7 +1700,7 @@ void e1000e_update_adaptive(struct e1000_hw *hw) mac->current_ifs_val = mac->ifs_min_val; else mac->current_ifs_val += - mac->ifs_step_size; + mac->ifs_step_size; ew32(AIT, mac->current_ifs_val); } } @@ -1731,956 +1715,3 @@ void e1000e_update_adaptive(struct e1000_hw *hw) out: return; } - -/** - * e1000_raise_eec_clk - Raise EEPROM clock - * @hw: pointer to the HW structure - * @eecd: pointer to the EEPROM - * - * Enable/Raise the EEPROM clock bit. - **/ -static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd) -{ - *eecd = *eecd | E1000_EECD_SK; - ew32(EECD, *eecd); - e1e_flush(); - udelay(hw->nvm.delay_usec); -} - -/** - * e1000_lower_eec_clk - Lower EEPROM clock - * @hw: pointer to the HW structure - * @eecd: pointer to the EEPROM - * - * Clear/Lower the EEPROM clock bit. - **/ -static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd) -{ - *eecd = *eecd & ~E1000_EECD_SK; - ew32(EECD, *eecd); - e1e_flush(); - udelay(hw->nvm.delay_usec); -} - -/** - * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM - * @hw: pointer to the HW structure - * @data: data to send to the EEPROM - * @count: number of bits to shift out - * - * We need to shift 'count' bits out to the EEPROM. So, the value in the - * "data" parameter will be shifted out to the EEPROM one bit at a time. - * In order to do this, "data" must be broken down into bits. - **/ -static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count) -{ - struct e1000_nvm_info *nvm = &hw->nvm; - u32 eecd = er32(EECD); - u32 mask; - - mask = 0x01 << (count - 1); - if (nvm->type == e1000_nvm_eeprom_spi) - eecd |= E1000_EECD_DO; - - do { - eecd &= ~E1000_EECD_DI; - - if (data & mask) - eecd |= E1000_EECD_DI; - - ew32(EECD, eecd); - e1e_flush(); - - udelay(nvm->delay_usec); - - e1000_raise_eec_clk(hw, &eecd); - e1000_lower_eec_clk(hw, &eecd); - - mask >>= 1; - } while (mask); - - eecd &= ~E1000_EECD_DI; - ew32(EECD, eecd); -} - -/** - * e1000_shift_in_eec_bits - Shift data bits in from the EEPROM - * @hw: pointer to the HW structure - * @count: number of bits to shift in - * - * In order to read a register from the EEPROM, we need to shift 'count' bits - * in from the EEPROM. Bits are "shifted in" by raising the clock input to - * the EEPROM (setting the SK bit), and then reading the value of the data out - * "DO" bit. During this "shifting in" process the data in "DI" bit should - * always be clear. - **/ -static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count) -{ - u32 eecd; - u32 i; - u16 data; - - eecd = er32(EECD); - - eecd &= ~(E1000_EECD_DO | E1000_EECD_DI); - data = 0; - - for (i = 0; i < count; i++) { - data <<= 1; - e1000_raise_eec_clk(hw, &eecd); - - eecd = er32(EECD); - - eecd &= ~E1000_EECD_DI; - if (eecd & E1000_EECD_DO) - data |= 1; - - e1000_lower_eec_clk(hw, &eecd); - } - - return data; -} - -/** - * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion - * @hw: pointer to the HW structure - * @ee_reg: EEPROM flag for polling - * - * Polls the EEPROM status bit for either read or write completion based - * upon the value of 'ee_reg'. - **/ -s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) -{ - u32 attempts = 100000; - u32 i, reg = 0; - - for (i = 0; i < attempts; i++) { - if (ee_reg == E1000_NVM_POLL_READ) - reg = er32(EERD); - else - reg = er32(EEWR); - - if (reg & E1000_NVM_RW_REG_DONE) - return 0; - - udelay(5); - } - - return -E1000_ERR_NVM; -} - -/** - * e1000e_acquire_nvm - Generic request for access to EEPROM - * @hw: pointer to the HW structure - * - * Set the EEPROM access request bit and wait for EEPROM access grant bit. - * Return successful if access grant bit set, else clear the request for - * EEPROM access and return -E1000_ERR_NVM (-1). - **/ -s32 e1000e_acquire_nvm(struct e1000_hw *hw) -{ - u32 eecd = er32(EECD); - s32 timeout = E1000_NVM_GRANT_ATTEMPTS; - - ew32(EECD, eecd | E1000_EECD_REQ); - eecd = er32(EECD); - - while (timeout) { - if (eecd & E1000_EECD_GNT) - break; - udelay(5); - eecd = er32(EECD); - timeout--; - } - - if (!timeout) { - eecd &= ~E1000_EECD_REQ; - ew32(EECD, eecd); - e_dbg("Could not acquire NVM grant\n"); - return -E1000_ERR_NVM; - } - - return 0; -} - -/** - * e1000_standby_nvm - Return EEPROM to standby state - * @hw: pointer to the HW structure - * - * Return the EEPROM to a standby state. - **/ -static void e1000_standby_nvm(struct e1000_hw *hw) -{ - struct e1000_nvm_info *nvm = &hw->nvm; - u32 eecd = er32(EECD); - - if (nvm->type == e1000_nvm_eeprom_spi) { - /* Toggle CS to flush commands */ - eecd |= E1000_EECD_CS; - ew32(EECD, eecd); - e1e_flush(); - udelay(nvm->delay_usec); - eecd &= ~E1000_EECD_CS; - ew32(EECD, eecd); - e1e_flush(); - udelay(nvm->delay_usec); - } -} - -/** - * e1000_stop_nvm - Terminate EEPROM command - * @hw: pointer to the HW structure - * - * Terminates the current command by inverting the EEPROM's chip select pin. - **/ -static void e1000_stop_nvm(struct e1000_hw *hw) -{ - u32 eecd; - - eecd = er32(EECD); - if (hw->nvm.type == e1000_nvm_eeprom_spi) { - /* Pull CS high */ - eecd |= E1000_EECD_CS; - e1000_lower_eec_clk(hw, &eecd); - } -} - -/** - * e1000e_release_nvm - Release exclusive access to EEPROM - * @hw: pointer to the HW structure - * - * Stop any current commands to the EEPROM and clear the EEPROM request bit. - **/ -void e1000e_release_nvm(struct e1000_hw *hw) -{ - u32 eecd; - - e1000_stop_nvm(hw); - - eecd = er32(EECD); - eecd &= ~E1000_EECD_REQ; - ew32(EECD, eecd); -} - -/** - * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write - * @hw: pointer to the HW structure - * - * Setups the EEPROM for reading and writing. - **/ -static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw) -{ - struct e1000_nvm_info *nvm = &hw->nvm; - u32 eecd = er32(EECD); - u8 spi_stat_reg; - - if (nvm->type == e1000_nvm_eeprom_spi) { - u16 timeout = NVM_MAX_RETRY_SPI; - - /* Clear SK and CS */ - eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); - ew32(EECD, eecd); - e1e_flush(); - udelay(1); - - /* - * Read "Status Register" repeatedly until the LSB is cleared. - * The EEPROM will signal that the command has been completed - * by clearing bit 0 of the internal status register. If it's - * not cleared within 'timeout', then error out. - */ - while (timeout) { - e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI, - hw->nvm.opcode_bits); - spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8); - if (!(spi_stat_reg & NVM_STATUS_RDY_SPI)) - break; - - udelay(5); - e1000_standby_nvm(hw); - timeout--; - } - - if (!timeout) { - e_dbg("SPI NVM Status error\n"); - return -E1000_ERR_NVM; - } - } - - return 0; -} - -/** - * e1000e_read_nvm_eerd - Reads EEPROM using EERD register - * @hw: pointer to the HW structure - * @offset: offset of word in the EEPROM to read - * @words: number of words to read - * @data: word read from the EEPROM - * - * Reads a 16 bit word from the EEPROM using the EERD register. - **/ -s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) -{ - struct e1000_nvm_info *nvm = &hw->nvm; - u32 i, eerd = 0; - s32 ret_val = 0; - - /* - * A check for invalid values: offset too large, too many words, - * too many words for the offset, and not enough words. - */ - if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || - (words == 0)) { - e_dbg("nvm parameter(s) out of bounds\n"); - return -E1000_ERR_NVM; - } - - for (i = 0; i < words; i++) { - eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) + - E1000_NVM_RW_REG_START; - - ew32(EERD, eerd); - ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); - if (ret_val) - break; - - data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA); - } - - return ret_val; -} - -/** - * e1000e_write_nvm_spi - Write to EEPROM using SPI - * @hw: pointer to the HW structure - * @offset: offset within the EEPROM to be written to - * @words: number of words to write - * @data: 16 bit word(s) to be written to the EEPROM - * - * Writes data to EEPROM at offset using SPI interface. - * - * If e1000e_update_nvm_checksum is not called after this function , the - * EEPROM will most likely contain an invalid checksum. - **/ -s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) -{ - struct e1000_nvm_info *nvm = &hw->nvm; - s32 ret_val; - u16 widx = 0; - - /* - * A check for invalid values: offset too large, too many words, - * and not enough words. - */ - if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || - (words == 0)) { - e_dbg("nvm parameter(s) out of bounds\n"); - return -E1000_ERR_NVM; - } - - ret_val = nvm->ops.acquire(hw); - if (ret_val) - return ret_val; - - while (widx < words) { - u8 write_opcode = NVM_WRITE_OPCODE_SPI; - - ret_val = e1000_ready_nvm_eeprom(hw); - if (ret_val) { - nvm->ops.release(hw); - return ret_val; - } - - e1000_standby_nvm(hw); - - /* Send the WRITE ENABLE command (8 bit opcode) */ - e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI, - nvm->opcode_bits); - - e1000_standby_nvm(hw); - - /* - * Some SPI eeproms use the 8th address bit embedded in the - * opcode - */ - if ((nvm->address_bits == 8) && (offset >= 128)) - write_opcode |= NVM_A8_OPCODE_SPI; - - /* Send the Write command (8-bit opcode + addr) */ - e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits); - e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2), - nvm->address_bits); - - /* Loop to allow for up to whole page write of eeprom */ - while (widx < words) { - u16 word_out = data[widx]; - word_out = (word_out >> 8) | (word_out << 8); - e1000_shift_out_eec_bits(hw, word_out, 16); - widx++; - - if ((((offset + widx) * 2) % nvm->page_size) == 0) { - e1000_standby_nvm(hw); - break; - } - } - } - - usleep_range(10000, 20000); - nvm->ops.release(hw); - return 0; -} - -/** - * e1000_read_pba_string_generic - Read device part number - * @hw: pointer to the HW structure - * @pba_num: pointer to device part number - * @pba_num_size: size of part number buffer - * - * Reads the product board assembly (PBA) number from the EEPROM and stores - * the value in pba_num. - **/ -s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, - u32 pba_num_size) -{ - s32 ret_val; - u16 nvm_data; - u16 pba_ptr; - u16 offset; - u16 length; - - if (pba_num == NULL) { - e_dbg("PBA string buffer was null\n"); - ret_val = E1000_ERR_INVALID_ARGUMENT; - goto out; - } - - ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); - if (ret_val) { - e_dbg("NVM Read Error\n"); - goto out; - } - - ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr); - if (ret_val) { - e_dbg("NVM Read Error\n"); - goto out; - } - - /* - * if nvm_data is not ptr guard the PBA must be in legacy format which - * means pba_ptr is actually our second data word for the PBA number - * and we can decode it into an ascii string - */ - if (nvm_data != NVM_PBA_PTR_GUARD) { - e_dbg("NVM PBA number is not stored as string\n"); - - /* we will need 11 characters to store the PBA */ - if (pba_num_size < 11) { - e_dbg("PBA string buffer too small\n"); - return E1000_ERR_NO_SPACE; - } - - /* extract hex string from data and pba_ptr */ - pba_num[0] = (nvm_data >> 12) & 0xF; - pba_num[1] = (nvm_data >> 8) & 0xF; - pba_num[2] = (nvm_data >> 4) & 0xF; - pba_num[3] = nvm_data & 0xF; - pba_num[4] = (pba_ptr >> 12) & 0xF; - pba_num[5] = (pba_ptr >> 8) & 0xF; - pba_num[6] = '-'; - pba_num[7] = 0; - pba_num[8] = (pba_ptr >> 4) & 0xF; - pba_num[9] = pba_ptr & 0xF; - - /* put a null character on the end of our string */ - pba_num[10] = '\0'; - - /* switch all the data but the '-' to hex char */ - for (offset = 0; offset < 10; offset++) { - if (pba_num[offset] < 0xA) - pba_num[offset] += '0'; - else if (pba_num[offset] < 0x10) - pba_num[offset] += 'A' - 0xA; - } - - goto out; - } - - ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length); - if (ret_val) { - e_dbg("NVM Read Error\n"); - goto out; - } - - if (length == 0xFFFF || length == 0) { - e_dbg("NVM PBA number section invalid length\n"); - ret_val = E1000_ERR_NVM_PBA_SECTION; - goto out; - } - /* check if pba_num buffer is big enough */ - if (pba_num_size < (((u32)length * 2) - 1)) { - e_dbg("PBA string buffer too small\n"); - ret_val = E1000_ERR_NO_SPACE; - goto out; - } - - /* trim pba length from start of string */ - pba_ptr++; - length--; - - for (offset = 0; offset < length; offset++) { - ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data); - if (ret_val) { - e_dbg("NVM Read Error\n"); - goto out; - } - pba_num[offset * 2] = (u8)(nvm_data >> 8); - pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); - } - pba_num[offset * 2] = '\0'; - -out: - return ret_val; -} - -/** - * e1000_read_mac_addr_generic - Read device MAC address - * @hw: pointer to the HW structure - * - * Reads the device MAC address from the EEPROM and stores the value. - * Since devices with two ports use the same EEPROM, we increment the - * last bit in the MAC address for the second port. - **/ -s32 e1000_read_mac_addr_generic(struct e1000_hw *hw) -{ - u32 rar_high; - u32 rar_low; - u16 i; - - rar_high = er32(RAH(0)); - rar_low = er32(RAL(0)); - - for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) - hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8)); - - for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) - hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8)); - - for (i = 0; i < ETH_ALEN; i++) - hw->mac.addr[i] = hw->mac.perm_addr[i]; - - return 0; -} - -/** - * e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum - * @hw: pointer to the HW structure - * - * Calculates the EEPROM checksum by reading/adding each word of the EEPROM - * and then verifies that the sum of the EEPROM is equal to 0xBABA. - **/ -s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw) -{ - s32 ret_val; - u16 checksum = 0; - u16 i, nvm_data; - - for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { - ret_val = e1000_read_nvm(hw, i, 1, &nvm_data); - if (ret_val) { - e_dbg("NVM Read Error\n"); - return ret_val; - } - checksum += nvm_data; - } - - if (checksum != (u16) NVM_SUM) { - e_dbg("NVM Checksum Invalid\n"); - return -E1000_ERR_NVM; - } - - return 0; -} - -/** - * e1000e_update_nvm_checksum_generic - Update EEPROM checksum - * @hw: pointer to the HW structure - * - * Updates the EEPROM checksum by reading/adding each word of the EEPROM - * up to the checksum. Then calculates the EEPROM checksum and writes the - * value to the EEPROM. - **/ -s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw) -{ - s32 ret_val; - u16 checksum = 0; - u16 i, nvm_data; - - for (i = 0; i < NVM_CHECKSUM_REG; i++) { - ret_val = e1000_read_nvm(hw, i, 1, &nvm_data); - if (ret_val) { - e_dbg("NVM Read Error while updating checksum.\n"); - return ret_val; - } - checksum += nvm_data; - } - checksum = (u16) NVM_SUM - checksum; - ret_val = e1000_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum); - if (ret_val) - e_dbg("NVM Write Error while updating checksum.\n"); - - return ret_val; -} - -/** - * e1000e_reload_nvm - Reloads EEPROM - * @hw: pointer to the HW structure - * - * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the - * extended control register. - **/ -void e1000e_reload_nvm(struct e1000_hw *hw) -{ - u32 ctrl_ext; - - udelay(10); - ctrl_ext = er32(CTRL_EXT); - ctrl_ext |= E1000_CTRL_EXT_EE_RST; - ew32(CTRL_EXT, ctrl_ext); - e1e_flush(); -} - -/** - * e1000_calculate_checksum - Calculate checksum for buffer - * @buffer: pointer to EEPROM - * @length: size of EEPROM to calculate a checksum for - * - * Calculates the checksum for some buffer on a specified length. The - * checksum calculated is returned. - **/ -static u8 e1000_calculate_checksum(u8 *buffer, u32 length) -{ - u32 i; - u8 sum = 0; - - if (!buffer) - return 0; - - for (i = 0; i < length; i++) - sum += buffer[i]; - - return (u8) (0 - sum); -} - -/** - * e1000_mng_enable_host_if - Checks host interface is enabled - * @hw: pointer to the HW structure - * - * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND - * - * This function checks whether the HOST IF is enabled for command operation - * and also checks whether the previous command is completed. It busy waits - * in case of previous command is not completed. - **/ -static s32 e1000_mng_enable_host_if(struct e1000_hw *hw) -{ - u32 hicr; - u8 i; - - if (!(hw->mac.arc_subsystem_valid)) { - e_dbg("ARC subsystem not valid.\n"); - return -E1000_ERR_HOST_INTERFACE_COMMAND; - } - - /* Check that the host interface is enabled. */ - hicr = er32(HICR); - if ((hicr & E1000_HICR_EN) == 0) { - e_dbg("E1000_HOST_EN bit disabled.\n"); - return -E1000_ERR_HOST_INTERFACE_COMMAND; - } - /* check the previous command is completed */ - for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) { - hicr = er32(HICR); - if (!(hicr & E1000_HICR_C)) - break; - mdelay(1); - } - - if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) { - e_dbg("Previous command timeout failed .\n"); - return -E1000_ERR_HOST_INTERFACE_COMMAND; - } - - return 0; -} - -/** - * e1000e_check_mng_mode_generic - check management mode - * @hw: pointer to the HW structure - * - * Reads the firmware semaphore register and returns true (>0) if - * manageability is enabled, else false (0). - **/ -bool e1000e_check_mng_mode_generic(struct e1000_hw *hw) -{ - u32 fwsm = er32(FWSM); - - return (fwsm & E1000_FWSM_MODE_MASK) == - (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT); -} - -/** - * e1000e_enable_tx_pkt_filtering - Enable packet filtering on Tx - * @hw: pointer to the HW structure - * - * Enables packet filtering on transmit packets if manageability is enabled - * and host interface is enabled. - **/ -bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) -{ - struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie; - u32 *buffer = (u32 *)&hw->mng_cookie; - u32 offset; - s32 ret_val, hdr_csum, csum; - u8 i, len; - - hw->mac.tx_pkt_filtering = true; - - /* No manageability, no filtering */ - if (!e1000e_check_mng_mode(hw)) { - hw->mac.tx_pkt_filtering = false; - goto out; - } - - /* - * If we can't read from the host interface for whatever - * reason, disable filtering. - */ - ret_val = e1000_mng_enable_host_if(hw); - if (ret_val) { - hw->mac.tx_pkt_filtering = false; - goto out; - } - - /* Read in the header. Length and offset are in dwords. */ - len = E1000_MNG_DHCP_COOKIE_LENGTH >> 2; - offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2; - for (i = 0; i < len; i++) - *(buffer + i) = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset + i); - hdr_csum = hdr->checksum; - hdr->checksum = 0; - csum = e1000_calculate_checksum((u8 *)hdr, - E1000_MNG_DHCP_COOKIE_LENGTH); - /* - * If either the checksums or signature don't match, then - * the cookie area isn't considered valid, in which case we - * take the safe route of assuming Tx filtering is enabled. - */ - if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) { - hw->mac.tx_pkt_filtering = true; - goto out; - } - - /* Cookie area is valid, make the final check for filtering. */ - if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) { - hw->mac.tx_pkt_filtering = false; - goto out; - } - -out: - return hw->mac.tx_pkt_filtering; -} - -/** - * e1000_mng_write_cmd_header - Writes manageability command header - * @hw: pointer to the HW structure - * @hdr: pointer to the host interface command header - * - * Writes the command header after does the checksum calculation. - **/ -static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw, - struct e1000_host_mng_command_header *hdr) -{ - u16 i, length = sizeof(struct e1000_host_mng_command_header); - - /* Write the whole command header structure with new checksum. */ - - hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length); - - length >>= 2; - /* Write the relevant command block into the ram area. */ - for (i = 0; i < length; i++) { - E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, i, - *((u32 *) hdr + i)); - e1e_flush(); - } - - return 0; -} - -/** - * e1000_mng_host_if_write - Write to the manageability host interface - * @hw: pointer to the HW structure - * @buffer: pointer to the host interface buffer - * @length: size of the buffer - * @offset: location in the buffer to write to - * @sum: sum of the data (not checksum) - * - * This function writes the buffer content at the offset given on the host if. - * It also does alignment considerations to do the writes in most efficient - * way. Also fills up the sum of the buffer in *buffer parameter. - **/ -static s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, - u16 length, u16 offset, u8 *sum) -{ - u8 *tmp; - u8 *bufptr = buffer; - u32 data = 0; - u16 remaining, i, j, prev_bytes; - - /* sum = only sum of the data and it is not checksum */ - - if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) - return -E1000_ERR_PARAM; - - tmp = (u8 *)&data; - prev_bytes = offset & 0x3; - offset >>= 2; - - if (prev_bytes) { - data = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset); - for (j = prev_bytes; j < sizeof(u32); j++) { - *(tmp + j) = *bufptr++; - *sum += *(tmp + j); - } - E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset, data); - length -= j - prev_bytes; - offset++; - } - - remaining = length & 0x3; - length -= remaining; - - /* Calculate length in DWORDs */ - length >>= 2; - - /* - * The device driver writes the relevant command block into the - * ram area. - */ - for (i = 0; i < length; i++) { - for (j = 0; j < sizeof(u32); j++) { - *(tmp + j) = *bufptr++; - *sum += *(tmp + j); - } - - E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data); - } - if (remaining) { - for (j = 0; j < sizeof(u32); j++) { - if (j < remaining) - *(tmp + j) = *bufptr++; - else - *(tmp + j) = 0; - - *sum += *(tmp + j); - } - E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data); - } - - return 0; -} - -/** - * e1000e_mng_write_dhcp_info - Writes DHCP info to host interface - * @hw: pointer to the HW structure - * @buffer: pointer to the host interface - * @length: size of the buffer - * - * Writes the DHCP information to the host interface. - **/ -s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length) -{ - struct e1000_host_mng_command_header hdr; - s32 ret_val; - u32 hicr; - - hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD; - hdr.command_length = length; - hdr.reserved1 = 0; - hdr.reserved2 = 0; - hdr.checksum = 0; - - /* Enable the host interface */ - ret_val = e1000_mng_enable_host_if(hw); - if (ret_val) - return ret_val; - - /* Populate the host interface with the contents of "buffer". */ - ret_val = e1000_mng_host_if_write(hw, buffer, length, - sizeof(hdr), &(hdr.checksum)); - if (ret_val) - return ret_val; - - /* Write the manageability command header */ - ret_val = e1000_mng_write_cmd_header(hw, &hdr); - if (ret_val) - return ret_val; - - /* Tell the ARC a new command is pending. */ - hicr = er32(HICR); - ew32(HICR, hicr | E1000_HICR_C); - - return 0; -} - -/** - * e1000e_enable_mng_pass_thru - Check if management passthrough is needed - * @hw: pointer to the HW structure - * - * Verifies the hardware needs to leave interface enabled so that frames can - * be directed to and from the management interface. - **/ -bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) -{ - u32 manc; - u32 fwsm, factps; - bool ret_val = false; - - manc = er32(MANC); - - if (!(manc & E1000_MANC_RCV_TCO_EN)) - goto out; - - if (hw->mac.has_fwsm) { - fwsm = er32(FWSM); - factps = er32(FACTPS); - - if (!(factps & E1000_FACTPS_MNGCG) && - ((fwsm & E1000_FWSM_MODE_MASK) == - (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) { - ret_val = true; - goto out; - } - } else if ((hw->mac.type == e1000_82574) || - (hw->mac.type == e1000_82583)) { - u16 data; - - factps = er32(FACTPS); - e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); - - if (!(factps & E1000_FACTPS_MNGCG) && - ((data & E1000_NVM_INIT_CTRL2_MNGM) == - (e1000_mng_mode_pt << 13))) { - ret_val = true; - goto out; - } - } else if ((manc & E1000_MANC_SMBUS_EN) && - !(manc & E1000_MANC_ASF_EN)) { - ret_val = true; - goto out; - } - -out: - return ret_val; -} diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c new file mode 100644 index 000000000000..3dae2655ec70 --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/manage.c @@ -0,0 +1,377 @@ +/******************************************************************************* + + Intel PRO/1000 Linux driver + Copyright(c) 1999 - 2011 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + + Contact Information: + Linux NICS + e1000-devel Mailing List + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#include "e1000.h" + +enum e1000_mng_mode { + e1000_mng_mode_none = 0, + e1000_mng_mode_asf, + e1000_mng_mode_pt, + e1000_mng_mode_ipmi, + e1000_mng_mode_host_if_only +}; + +#define E1000_FACTPS_MNGCG 0x20000000 + +/* Intel(R) Active Management Technology signature */ +#define E1000_IAMT_SIGNATURE 0x544D4149 + +/** + * e1000_calculate_checksum - Calculate checksum for buffer + * @buffer: pointer to EEPROM + * @length: size of EEPROM to calculate a checksum for + * + * Calculates the checksum for some buffer on a specified length. The + * checksum calculated is returned. + **/ +static u8 e1000_calculate_checksum(u8 *buffer, u32 length) +{ + u32 i; + u8 sum = 0; + + if (!buffer) + return 0; + + for (i = 0; i < length; i++) + sum += buffer[i]; + + return (u8)(0 - sum); +} + +/** + * e1000_mng_enable_host_if - Checks host interface is enabled + * @hw: pointer to the HW structure + * + * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND + * + * This function checks whether the HOST IF is enabled for command operation + * and also checks whether the previous command is completed. It busy waits + * in case of previous command is not completed. + **/ +static s32 e1000_mng_enable_host_if(struct e1000_hw *hw) +{ + u32 hicr; + u8 i; + + if (!(hw->mac.arc_subsystem_valid)) { + e_dbg("ARC subsystem not valid.\n"); + return -E1000_ERR_HOST_INTERFACE_COMMAND; + } + + /* Check that the host interface is enabled. */ + hicr = er32(HICR); + if ((hicr & E1000_HICR_EN) == 0) { + e_dbg("E1000_HOST_EN bit disabled.\n"); + return -E1000_ERR_HOST_INTERFACE_COMMAND; + } + /* check the previous command is completed */ + for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) { + hicr = er32(HICR); + if (!(hicr & E1000_HICR_C)) + break; + mdelay(1); + } + + if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) { + e_dbg("Previous command timeout failed .\n"); + return -E1000_ERR_HOST_INTERFACE_COMMAND; + } + + return 0; +} + +/** + * e1000e_check_mng_mode_generic - check management mode + * @hw: pointer to the HW structure + * + * Reads the firmware semaphore register and returns true (>0) if + * manageability is enabled, else false (0). + **/ +bool e1000e_check_mng_mode_generic(struct e1000_hw *hw) +{ + u32 fwsm = er32(FWSM); + + return (fwsm & E1000_FWSM_MODE_MASK) == + (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT); +} + +/** + * e1000e_enable_tx_pkt_filtering - Enable packet filtering on Tx + * @hw: pointer to the HW structure + * + * Enables packet filtering on transmit packets if manageability is enabled + * and host interface is enabled. + **/ +bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) +{ + struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie; + u32 *buffer = (u32 *)&hw->mng_cookie; + u32 offset; + s32 ret_val, hdr_csum, csum; + u8 i, len; + + hw->mac.tx_pkt_filtering = true; + + /* No manageability, no filtering */ + if (!e1000e_check_mng_mode(hw)) { + hw->mac.tx_pkt_filtering = false; + goto out; + } + + /* + * If we can't read from the host interface for whatever + * reason, disable filtering. + */ + ret_val = e1000_mng_enable_host_if(hw); + if (ret_val) { + hw->mac.tx_pkt_filtering = false; + goto out; + } + + /* Read in the header. Length and offset are in dwords. */ + len = E1000_MNG_DHCP_COOKIE_LENGTH >> 2; + offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2; + for (i = 0; i < len; i++) + *(buffer + i) = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, + offset + i); + hdr_csum = hdr->checksum; + hdr->checksum = 0; + csum = e1000_calculate_checksum((u8 *)hdr, + E1000_MNG_DHCP_COOKIE_LENGTH); + /* + * If either the checksums or signature don't match, then + * the cookie area isn't considered valid, in which case we + * take the safe route of assuming Tx filtering is enabled. + */ + if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) { + hw->mac.tx_pkt_filtering = true; + goto out; + } + + /* Cookie area is valid, make the final check for filtering. */ + if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) { + hw->mac.tx_pkt_filtering = false; + goto out; + } + +out: + return hw->mac.tx_pkt_filtering; +} + +/** + * e1000_mng_write_cmd_header - Writes manageability command header + * @hw: pointer to the HW structure + * @hdr: pointer to the host interface command header + * + * Writes the command header after does the checksum calculation. + **/ +static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw, + struct e1000_host_mng_command_header *hdr) +{ + u16 i, length = sizeof(struct e1000_host_mng_command_header); + + /* Write the whole command header structure with new checksum. */ + + hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length); + + length >>= 2; + /* Write the relevant command block into the ram area. */ + for (i = 0; i < length; i++) { + E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, i, *((u32 *)hdr + i)); + e1e_flush(); + } + + return 0; +} + +/** + * e1000_mng_host_if_write - Write to the manageability host interface + * @hw: pointer to the HW structure + * @buffer: pointer to the host interface buffer + * @length: size of the buffer + * @offset: location in the buffer to write to + * @sum: sum of the data (not checksum) + * + * This function writes the buffer content at the offset given on the host if. + * It also does alignment considerations to do the writes in most efficient + * way. Also fills up the sum of the buffer in *buffer parameter. + **/ +static s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, + u16 length, u16 offset, u8 *sum) +{ + u8 *tmp; + u8 *bufptr = buffer; + u32 data = 0; + u16 remaining, i, j, prev_bytes; + + /* sum = only sum of the data and it is not checksum */ + + if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) + return -E1000_ERR_PARAM; + + tmp = (u8 *)&data; + prev_bytes = offset & 0x3; + offset >>= 2; + + if (prev_bytes) { + data = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset); + for (j = prev_bytes; j < sizeof(u32); j++) { + *(tmp + j) = *bufptr++; + *sum += *(tmp + j); + } + E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset, data); + length -= j - prev_bytes; + offset++; + } + + remaining = length & 0x3; + length -= remaining; + + /* Calculate length in DWORDs */ + length >>= 2; + + /* + * The device driver writes the relevant command block into the + * ram area. + */ + for (i = 0; i < length; i++) { + for (j = 0; j < sizeof(u32); j++) { + *(tmp + j) = *bufptr++; + *sum += *(tmp + j); + } + + E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data); + } + if (remaining) { + for (j = 0; j < sizeof(u32); j++) { + if (j < remaining) + *(tmp + j) = *bufptr++; + else + *(tmp + j) = 0; + + *sum += *(tmp + j); + } + E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data); + } + + return 0; +} + +/** + * e1000e_mng_write_dhcp_info - Writes DHCP info to host interface + * @hw: pointer to the HW structure + * @buffer: pointer to the host interface + * @length: size of the buffer + * + * Writes the DHCP information to the host interface. + **/ +s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length) +{ + struct e1000_host_mng_command_header hdr; + s32 ret_val; + u32 hicr; + + hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD; + hdr.command_length = length; + hdr.reserved1 = 0; + hdr.reserved2 = 0; + hdr.checksum = 0; + + /* Enable the host interface */ + ret_val = e1000_mng_enable_host_if(hw); + if (ret_val) + return ret_val; + + /* Populate the host interface with the contents of "buffer". */ + ret_val = e1000_mng_host_if_write(hw, buffer, length, + sizeof(hdr), &(hdr.checksum)); + if (ret_val) + return ret_val; + + /* Write the manageability command header */ + ret_val = e1000_mng_write_cmd_header(hw, &hdr); + if (ret_val) + return ret_val; + + /* Tell the ARC a new command is pending. */ + hicr = er32(HICR); + ew32(HICR, hicr | E1000_HICR_C); + + return 0; +} + +/** + * e1000e_enable_mng_pass_thru - Check if management passthrough is needed + * @hw: pointer to the HW structure + * + * Verifies the hardware needs to leave interface enabled so that frames can + * be directed to and from the management interface. + **/ +bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) +{ + u32 manc; + u32 fwsm, factps; + bool ret_val = false; + + manc = er32(MANC); + + if (!(manc & E1000_MANC_RCV_TCO_EN)) + goto out; + + if (hw->mac.has_fwsm) { + fwsm = er32(FWSM); + factps = er32(FACTPS); + + if (!(factps & E1000_FACTPS_MNGCG) && + ((fwsm & E1000_FWSM_MODE_MASK) == + (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) { + ret_val = true; + goto out; + } + } else if ((hw->mac.type == e1000_82574) || + (hw->mac.type == e1000_82583)) { + u16 data; + + factps = er32(FACTPS); + e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); + + if (!(factps & E1000_FACTPS_MNGCG) && + ((data & E1000_NVM_INIT_CTRL2_MNGM) == + (e1000_mng_mode_pt << 13))) { + ret_val = true; + goto out; + } + } else if ((manc & E1000_MANC_SMBUS_EN) && + !(manc & E1000_MANC_ASF_EN)) { + ret_val = true; + goto out; + } + +out: + return ret_val; +} diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c new file mode 100644 index 000000000000..dbdaa0052b1a --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/nvm.c @@ -0,0 +1,647 @@ +/******************************************************************************* + + Intel PRO/1000 Linux driver + Copyright(c) 1999 - 2011 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + + Contact Information: + Linux NICS + e1000-devel Mailing List + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#include "e1000.h" + +/** + * e1000_raise_eec_clk - Raise EEPROM clock + * @hw: pointer to the HW structure + * @eecd: pointer to the EEPROM + * + * Enable/Raise the EEPROM clock bit. + **/ +static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd) +{ + *eecd = *eecd | E1000_EECD_SK; + ew32(EECD, *eecd); + e1e_flush(); + udelay(hw->nvm.delay_usec); +} + +/** + * e1000_lower_eec_clk - Lower EEPROM clock + * @hw: pointer to the HW structure + * @eecd: pointer to the EEPROM + * + * Clear/Lower the EEPROM clock bit. + **/ +static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd) +{ + *eecd = *eecd & ~E1000_EECD_SK; + ew32(EECD, *eecd); + e1e_flush(); + udelay(hw->nvm.delay_usec); +} + +/** + * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM + * @hw: pointer to the HW structure + * @data: data to send to the EEPROM + * @count: number of bits to shift out + * + * We need to shift 'count' bits out to the EEPROM. So, the value in the + * "data" parameter will be shifted out to the EEPROM one bit at a time. + * In order to do this, "data" must be broken down into bits. + **/ +static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count) +{ + struct e1000_nvm_info *nvm = &hw->nvm; + u32 eecd = er32(EECD); + u32 mask; + + mask = 0x01 << (count - 1); + if (nvm->type == e1000_nvm_eeprom_spi) + eecd |= E1000_EECD_DO; + + do { + eecd &= ~E1000_EECD_DI; + + if (data & mask) + eecd |= E1000_EECD_DI; + + ew32(EECD, eecd); + e1e_flush(); + + udelay(nvm->delay_usec); + + e1000_raise_eec_clk(hw, &eecd); + e1000_lower_eec_clk(hw, &eecd); + + mask >>= 1; + } while (mask); + + eecd &= ~E1000_EECD_DI; + ew32(EECD, eecd); +} + +/** + * e1000_shift_in_eec_bits - Shift data bits in from the EEPROM + * @hw: pointer to the HW structure + * @count: number of bits to shift in + * + * In order to read a register from the EEPROM, we need to shift 'count' bits + * in from the EEPROM. Bits are "shifted in" by raising the clock input to + * the EEPROM (setting the SK bit), and then reading the value of the data out + * "DO" bit. During this "shifting in" process the data in "DI" bit should + * always be clear. + **/ +static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count) +{ + u32 eecd; + u32 i; + u16 data; + + eecd = er32(EECD); + + eecd &= ~(E1000_EECD_DO | E1000_EECD_DI); + data = 0; + + for (i = 0; i < count; i++) { + data <<= 1; + e1000_raise_eec_clk(hw, &eecd); + + eecd = er32(EECD); + + eecd &= ~E1000_EECD_DI; + if (eecd & E1000_EECD_DO) + data |= 1; + + e1000_lower_eec_clk(hw, &eecd); + } + + return data; +} + +/** + * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion + * @hw: pointer to the HW structure + * @ee_reg: EEPROM flag for polling + * + * Polls the EEPROM status bit for either read or write completion based + * upon the value of 'ee_reg'. + **/ +s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) +{ + u32 attempts = 100000; + u32 i, reg = 0; + + for (i = 0; i < attempts; i++) { + if (ee_reg == E1000_NVM_POLL_READ) + reg = er32(EERD); + else + reg = er32(EEWR); + + if (reg & E1000_NVM_RW_REG_DONE) + return 0; + + udelay(5); + } + + return -E1000_ERR_NVM; +} + +/** + * e1000e_acquire_nvm - Generic request for access to EEPROM + * @hw: pointer to the HW structure + * + * Set the EEPROM access request bit and wait for EEPROM access grant bit. + * Return successful if access grant bit set, else clear the request for + * EEPROM access and return -E1000_ERR_NVM (-1). + **/ +s32 e1000e_acquire_nvm(struct e1000_hw *hw) +{ + u32 eecd = er32(EECD); + s32 timeout = E1000_NVM_GRANT_ATTEMPTS; + + ew32(EECD, eecd | E1000_EECD_REQ); + eecd = er32(EECD); + + while (timeout) { + if (eecd & E1000_EECD_GNT) + break; + udelay(5); + eecd = er32(EECD); + timeout--; + } + + if (!timeout) { + eecd &= ~E1000_EECD_REQ; + ew32(EECD, eecd); + e_dbg("Could not acquire NVM grant\n"); + return -E1000_ERR_NVM; + } + + return 0; +} + +/** + * e1000_standby_nvm - Return EEPROM to standby state + * @hw: pointer to the HW structure + * + * Return the EEPROM to a standby state. + **/ +static void e1000_standby_nvm(struct e1000_hw *hw) +{ + struct e1000_nvm_info *nvm = &hw->nvm; + u32 eecd = er32(EECD); + + if (nvm->type == e1000_nvm_eeprom_spi) { + /* Toggle CS to flush commands */ + eecd |= E1000_EECD_CS; + ew32(EECD, eecd); + e1e_flush(); + udelay(nvm->delay_usec); + eecd &= ~E1000_EECD_CS; + ew32(EECD, eecd); + e1e_flush(); + udelay(nvm->delay_usec); + } +} + +/** + * e1000_stop_nvm - Terminate EEPROM command + * @hw: pointer to the HW structure + * + * Terminates the current command by inverting the EEPROM's chip select pin. + **/ +static void e1000_stop_nvm(struct e1000_hw *hw) +{ + u32 eecd; + + eecd = er32(EECD); + if (hw->nvm.type == e1000_nvm_eeprom_spi) { + /* Pull CS high */ + eecd |= E1000_EECD_CS; + e1000_lower_eec_clk(hw, &eecd); + } +} + +/** + * e1000e_release_nvm - Release exclusive access to EEPROM + * @hw: pointer to the HW structure + * + * Stop any current commands to the EEPROM and clear the EEPROM request bit. + **/ +void e1000e_release_nvm(struct e1000_hw *hw) +{ + u32 eecd; + + e1000_stop_nvm(hw); + + eecd = er32(EECD); + eecd &= ~E1000_EECD_REQ; + ew32(EECD, eecd); +} + +/** + * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write + * @hw: pointer to the HW structure + * + * Setups the EEPROM for reading and writing. + **/ +static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw) +{ + struct e1000_nvm_info *nvm = &hw->nvm; + u32 eecd = er32(EECD); + u8 spi_stat_reg; + + if (nvm->type == e1000_nvm_eeprom_spi) { + u16 timeout = NVM_MAX_RETRY_SPI; + + /* Clear SK and CS */ + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); + ew32(EECD, eecd); + e1e_flush(); + udelay(1); + + /* + * Read "Status Register" repeatedly until the LSB is cleared. + * The EEPROM will signal that the command has been completed + * by clearing bit 0 of the internal status register. If it's + * not cleared within 'timeout', then error out. + */ + while (timeout) { + e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI, + hw->nvm.opcode_bits); + spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8); + if (!(spi_stat_reg & NVM_STATUS_RDY_SPI)) + break; + + udelay(5); + e1000_standby_nvm(hw); + timeout--; + } + + if (!timeout) { + e_dbg("SPI NVM Status error\n"); + return -E1000_ERR_NVM; + } + } + + return 0; +} + +/** + * e1000e_read_nvm_eerd - Reads EEPROM using EERD register + * @hw: pointer to the HW structure + * @offset: offset of word in the EEPROM to read + * @words: number of words to read + * @data: word read from the EEPROM + * + * Reads a 16 bit word from the EEPROM using the EERD register. + **/ +s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) +{ + struct e1000_nvm_info *nvm = &hw->nvm; + u32 i, eerd = 0; + s32 ret_val = 0; + + /* + * A check for invalid values: offset too large, too many words, + * too many words for the offset, and not enough words. + */ + if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || + (words == 0)) { + e_dbg("nvm parameter(s) out of bounds\n"); + return -E1000_ERR_NVM; + } + + for (i = 0; i < words; i++) { + eerd = ((offset + i) << E1000_NVM_RW_ADDR_SHIFT) + + E1000_NVM_RW_REG_START; + + ew32(EERD, eerd); + ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); + if (ret_val) + break; + + data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA); + } + + return ret_val; +} + +/** + * e1000e_write_nvm_spi - Write to EEPROM using SPI + * @hw: pointer to the HW structure + * @offset: offset within the EEPROM to be written to + * @words: number of words to write + * @data: 16 bit word(s) to be written to the EEPROM + * + * Writes data to EEPROM at offset using SPI interface. + * + * If e1000e_update_nvm_checksum is not called after this function , the + * EEPROM will most likely contain an invalid checksum. + **/ +s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) +{ + struct e1000_nvm_info *nvm = &hw->nvm; + s32 ret_val; + u16 widx = 0; + + /* + * A check for invalid values: offset too large, too many words, + * and not enough words. + */ + if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || + (words == 0)) { + e_dbg("nvm parameter(s) out of bounds\n"); + return -E1000_ERR_NVM; + } + + ret_val = nvm->ops.acquire(hw); + if (ret_val) + return ret_val; + + while (widx < words) { + u8 write_opcode = NVM_WRITE_OPCODE_SPI; + + ret_val = e1000_ready_nvm_eeprom(hw); + if (ret_val) { + nvm->ops.release(hw); + return ret_val; + } + + e1000_standby_nvm(hw); + + /* Send the WRITE ENABLE command (8 bit opcode) */ + e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI, + nvm->opcode_bits); + + e1000_standby_nvm(hw); + + /* + * Some SPI eeproms use the 8th address bit embedded in the + * opcode + */ + if ((nvm->address_bits == 8) && (offset >= 128)) + write_opcode |= NVM_A8_OPCODE_SPI; + + /* Send the Write command (8-bit opcode + addr) */ + e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits); + e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2), + nvm->address_bits); + + /* Loop to allow for up to whole page write of eeprom */ + while (widx < words) { + u16 word_out = data[widx]; + word_out = (word_out >> 8) | (word_out << 8); + e1000_shift_out_eec_bits(hw, word_out, 16); + widx++; + + if ((((offset + widx) * 2) % nvm->page_size) == 0) { + e1000_standby_nvm(hw); + break; + } + } + } + + usleep_range(10000, 20000); + nvm->ops.release(hw); + return 0; +} + +/** + * e1000_read_pba_string_generic - Read device part number + * @hw: pointer to the HW structure + * @pba_num: pointer to device part number + * @pba_num_size: size of part number buffer + * + * Reads the product board assembly (PBA) number from the EEPROM and stores + * the value in pba_num. + **/ +s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, + u32 pba_num_size) +{ + s32 ret_val; + u16 nvm_data; + u16 pba_ptr; + u16 offset; + u16 length; + + if (pba_num == NULL) { + e_dbg("PBA string buffer was null\n"); + ret_val = E1000_ERR_INVALID_ARGUMENT; + goto out; + } + + ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); + if (ret_val) { + e_dbg("NVM Read Error\n"); + goto out; + } + + ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr); + if (ret_val) { + e_dbg("NVM Read Error\n"); + goto out; + } + + /* + * if nvm_data is not ptr guard the PBA must be in legacy format which + * means pba_ptr is actually our second data word for the PBA number + * and we can decode it into an ascii string + */ + if (nvm_data != NVM_PBA_PTR_GUARD) { + e_dbg("NVM PBA number is not stored as string\n"); + + /* we will need 11 characters to store the PBA */ + if (pba_num_size < 11) { + e_dbg("PBA string buffer too small\n"); + return E1000_ERR_NO_SPACE; + } + + /* extract hex string from data and pba_ptr */ + pba_num[0] = (nvm_data >> 12) & 0xF; + pba_num[1] = (nvm_data >> 8) & 0xF; + pba_num[2] = (nvm_data >> 4) & 0xF; + pba_num[3] = nvm_data & 0xF; + pba_num[4] = (pba_ptr >> 12) & 0xF; + pba_num[5] = (pba_ptr >> 8) & 0xF; + pba_num[6] = '-'; + pba_num[7] = 0; + pba_num[8] = (pba_ptr >> 4) & 0xF; + pba_num[9] = pba_ptr & 0xF; + + /* put a null character on the end of our string */ + pba_num[10] = '\0'; + + /* switch all the data but the '-' to hex char */ + for (offset = 0; offset < 10; offset++) { + if (pba_num[offset] < 0xA) + pba_num[offset] += '0'; + else if (pba_num[offset] < 0x10) + pba_num[offset] += 'A' - 0xA; + } + + goto out; + } + + ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length); + if (ret_val) { + e_dbg("NVM Read Error\n"); + goto out; + } + + if (length == 0xFFFF || length == 0) { + e_dbg("NVM PBA number section invalid length\n"); + ret_val = E1000_ERR_NVM_PBA_SECTION; + goto out; + } + /* check if pba_num buffer is big enough */ + if (pba_num_size < (((u32)length * 2) - 1)) { + e_dbg("PBA string buffer too small\n"); + ret_val = E1000_ERR_NO_SPACE; + goto out; + } + + /* trim pba length from start of string */ + pba_ptr++; + length--; + + for (offset = 0; offset < length; offset++) { + ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data); + if (ret_val) { + e_dbg("NVM Read Error\n"); + goto out; + } + pba_num[offset * 2] = (u8)(nvm_data >> 8); + pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); + } + pba_num[offset * 2] = '\0'; + +out: + return ret_val; +} + +/** + * e1000_read_mac_addr_generic - Read device MAC address + * @hw: pointer to the HW structure + * + * Reads the device MAC address from the EEPROM and stores the value. + * Since devices with two ports use the same EEPROM, we increment the + * last bit in the MAC address for the second port. + **/ +s32 e1000_read_mac_addr_generic(struct e1000_hw *hw) +{ + u32 rar_high; + u32 rar_low; + u16 i; + + rar_high = er32(RAH(0)); + rar_low = er32(RAL(0)); + + for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) + hw->mac.perm_addr[i] = (u8)(rar_low >> (i * 8)); + + for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) + hw->mac.perm_addr[i + 4] = (u8)(rar_high >> (i * 8)); + + for (i = 0; i < ETH_ALEN; i++) + hw->mac.addr[i] = hw->mac.perm_addr[i]; + + return 0; +} + +/** + * e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum + * @hw: pointer to the HW structure + * + * Calculates the EEPROM checksum by reading/adding each word of the EEPROM + * and then verifies that the sum of the EEPROM is equal to 0xBABA. + **/ +s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw) +{ + s32 ret_val; + u16 checksum = 0; + u16 i, nvm_data; + + for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { + ret_val = e1000_read_nvm(hw, i, 1, &nvm_data); + if (ret_val) { + e_dbg("NVM Read Error\n"); + return ret_val; + } + checksum += nvm_data; + } + + if (checksum != (u16)NVM_SUM) { + e_dbg("NVM Checksum Invalid\n"); + return -E1000_ERR_NVM; + } + + return 0; +} + +/** + * e1000e_update_nvm_checksum_generic - Update EEPROM checksum + * @hw: pointer to the HW structure + * + * Updates the EEPROM checksum by reading/adding each word of the EEPROM + * up to the checksum. Then calculates the EEPROM checksum and writes the + * value to the EEPROM. + **/ +s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw) +{ + s32 ret_val; + u16 checksum = 0; + u16 i, nvm_data; + + for (i = 0; i < NVM_CHECKSUM_REG; i++) { + ret_val = e1000_read_nvm(hw, i, 1, &nvm_data); + if (ret_val) { + e_dbg("NVM Read Error while updating checksum.\n"); + return ret_val; + } + checksum += nvm_data; + } + checksum = (u16)NVM_SUM - checksum; + ret_val = e1000_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum); + if (ret_val) + e_dbg("NVM Write Error while updating checksum.\n"); + + return ret_val; +} + +/** + * e1000e_reload_nvm - Reloads EEPROM + * @hw: pointer to the HW structure + * + * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the + * extended control register. + **/ +void e1000e_reload_nvm(struct e1000_hw *hw) +{ + u32 ctrl_ext; + + udelay(10); + ctrl_ext = er32(CTRL_EXT); + ctrl_ext |= E1000_CTRL_EXT_EE_RST; + ew32(CTRL_EXT, ctrl_ext); + e1e_flush(); +} -- GitLab From f5e261e626eb3fe07adf484aaad2ecfc757feba3 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Sun, 1 Jan 2012 16:00:03 +0000 Subject: [PATCH 0210/1846] e1000e: update copyright year Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 2 +- drivers/net/ethernet/intel/e1000e/82571.c | 2 +- drivers/net/ethernet/intel/e1000e/Makefile | 2 +- drivers/net/ethernet/intel/e1000e/defines.h | 2 +- drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/ethtool.c | 2 +- drivers/net/ethernet/intel/e1000e/hw.h | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- drivers/net/ethernet/intel/e1000e/manage.c | 2 +- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- drivers/net/ethernet/intel/e1000e/nvm.c | 2 +- drivers/net/ethernet/intel/e1000e/param.c | 2 +- drivers/net/ethernet/intel/e1000e/phy.c | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index f323ce507f58..82a5d87c90c0 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 0609ac69bb38..844907da8aaf 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/Makefile b/drivers/net/ethernet/intel/e1000e/Makefile index 8b888e5f6a06..591b71324505 100644 --- a/drivers/net/ethernet/intel/e1000e/Makefile +++ b/drivers/net/ethernet/intel/e1000e/Makefile @@ -1,7 +1,7 @@ ################################################################################ # # Intel PRO/1000 Linux driver -# Copyright(c) 1999 - 2011 Intel Corporation. +# Copyright(c) 1999 - 2012 Intel Corporation. # # This program is free software; you can redistribute it and/or modify it # under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h index c73795f46531..1af30b967a4f 100644 --- a/drivers/net/ethernet/intel/e1000e/defines.h +++ b/drivers/net/ethernet/intel/e1000e/defines.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 70bc9e902735..45e5ae8a9fb7 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index 1ea317f1adcf..92d5b6278955 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h index a15da4712f84..197059bb9abf 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 070a90f78aa9..907b17b2e66a 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 64b6f439338a..e1cf1072f318 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c index 3dae2655ec70..6594dbf248b4 100644 --- a/drivers/net/ethernet/intel/e1000e/manage.c +++ b/drivers/net/ethernet/intel/e1000e/manage.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 210d27ddd8cd..1a8dd2f0e609 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -6538,7 +6538,7 @@ static int __init e1000_init_module(void) int ret; pr_info("Intel(R) PRO/1000 Network Driver - %s\n", e1000e_driver_version); - pr_info("Copyright(c) 1999 - 2011 Intel Corporation.\n"); + pr_info("Copyright(c) 1999 - 2012 Intel Corporation.\n"); ret = pci_register_driver(&e1000_driver); return ret; diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c index dbdaa0052b1a..f6fb7a768ba5 100644 --- a/drivers/net/ethernet/intel/e1000e/nvm.c +++ b/drivers/net/ethernet/intel/e1000e/nvm.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c index 40664f5bfbda..9c6a56d804a4 100644 --- a/drivers/net/ethernet/intel/e1000e/param.c +++ b/drivers/net/ethernet/intel/e1000e/param.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index ed70d08db5b6..8dd2ff03f1f7 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel PRO/1000 Linux driver - Copyright(c) 1999 - 2011 Intel Corporation. + Copyright(c) 1999 - 2012 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, -- GitLab From 4512ff9f361a2786a18cb805d1f64b8d8719f121 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 22 Dec 2011 18:59:37 +0100 Subject: [PATCH 0211/1846] r8169: remove hardcoded PCIe registers accesses. Signed-off-by: Francois Romieu --- drivers/net/ethernet/realtek/r8169.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 7a0c800b50ad..ca86e67a33a8 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -3824,23 +3824,21 @@ static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp) static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; - struct pci_dev *pdev = tp->pci_dev; RTL_W8(MaxTxPacketSize, 0x3f); RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0); RTL_W8(Config4, RTL_R8(Config4) | 0x01); - pci_write_config_byte(pdev, 0x79, 0x20); + rtl_tx_performance_tweak(tp->pci_dev, 0x2 << MAX_READ_REQUEST_SHIFT); } static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; - struct pci_dev *pdev = tp->pci_dev; RTL_W8(MaxTxPacketSize, 0x0c); RTL_W8(Config3, RTL_R8(Config3) & ~Jumbo_En0); RTL_W8(Config4, RTL_R8(Config4) & ~0x01); - pci_write_config_byte(pdev, 0x79, 0x50); + rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT); } static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp) -- GitLab From 209e5ac83b4d038ffb52cabc793f75031602a031 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 26 Jan 2012 09:59:50 +0100 Subject: [PATCH 0212/1846] r8169: remove rtl8169_reinit_task. I see no good reason to keep both rtl8169_reinit_task and rtl8169_reset_task: - rtl8169_reinit_task adds a software failure point which does relate to any hardware state - they handle hardware the same. Remember that rtl8169_reinit_task was introduced in the 8169 only era to handle PCI errors way before the 8168 asked for pll and firmware ops and compare : rtl8169_reinit_task | rtl8169_reset_task ----------------------------+-------------------------- rtl8169_wait_for_quiescence | rtl8169_hw_reset rtl8169_update_counters | rtl8169_wait_for_quiescence rtl8169_hw_reset | rtl_hw_start rtl8169_rx_missed | rtl8169_check_link_status rtl_pll_power_down | rtl_request_firmware | rtl8169_init_phy | rtl_pll_power_up | rtl_hw_start | rtl8169_check_link_status | Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 34 +++------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index ca86e67a33a8..4f0856b8fab3 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5353,34 +5353,6 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev) napi_enable(&tp->napi); } -static void rtl8169_reinit_task(struct work_struct *work) -{ - struct rtl8169_private *tp = - container_of(work, struct rtl8169_private, task.work); - struct net_device *dev = tp->dev; - int ret; - - rtnl_lock(); - - if (!netif_running(dev)) - goto out_unlock; - - rtl8169_wait_for_quiescence(dev); - rtl8169_close(dev); - - ret = rtl8169_open(dev); - if (unlikely(ret < 0)) { - if (net_ratelimit()) - netif_err(tp, drv, dev, - "reinit failure (status = %d). Rescheduling\n", - ret); - rtl8169_schedule_work(dev, rtl8169_reinit_task); - } - -out_unlock: - rtnl_unlock(); -} - static void rtl8169_reset_task(struct work_struct *work) { struct rtl8169_private *tp = @@ -5616,7 +5588,7 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) rtl8169_hw_reset(tp); - rtl8169_schedule_work(dev, rtl8169_reinit_task); + rtl8169_schedule_work(dev, rtl8169_reset_task); } static void rtl8169_tx_interrupt(struct net_device *dev, @@ -5923,8 +5895,8 @@ static void rtl8169_down(struct net_device *dev) rtl8169_hw_reset(tp); /* * At this point device interrupts can not be enabled in any function, - * as netif_running is not true (rtl8169_interrupt, rtl8169_reset_task, - * rtl8169_reinit_task) and napi is disabled (rtl8169_poll). + * as netif_running is not true (rtl8169_interrupt, rtl8169_reset_task) + * and napi is disabled (rtl8169_poll). */ rtl8169_rx_missed(dev, ioaddr); -- GitLab From 4422bcd4907d1bbb9f63e049e3c3819132c047a1 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 26 Jan 2012 11:23:32 +0100 Subject: [PATCH 0213/1846] r8169: stop delaying workqueue. Though motivated by the move of the driver to a single work queue of sequential events and removal of hard irq processing, it looks safe as a standalone change. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 37 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 4f0856b8fab3..6d74931049fb 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -714,7 +714,11 @@ struct rtl8169_private { unsigned int (*phy_reset_pending)(struct rtl8169_private *tp); unsigned int (*link_ok)(void __iomem *); int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd); - struct delayed_work task; + + struct { + struct work_struct work; + } wk; + unsigned features; struct mii_if_info mii; @@ -4194,7 +4198,7 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) rtl8168_driver_stop(tp); } - cancel_delayed_work_sync(&tp->task); + cancel_work_sync(&tp->wk.work); unregister_netdev(dev); @@ -4255,6 +4259,8 @@ static void rtl_request_firmware(struct rtl8169_private *tp) rtl_request_uncached_firmware(tp); } +static void rtl_task(struct work_struct *); + static int rtl8169_open(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); @@ -4282,7 +4288,7 @@ static int rtl8169_open(struct net_device *dev) if (retval < 0) goto err_free_rx_1; - INIT_DELAYED_WORK(&tp->task, NULL); + INIT_WORK(&tp->wk.work, rtl_task); smp_mb(); @@ -5328,12 +5334,11 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp) tp->cur_tx = tp->dirty_tx = 0; } -static void rtl8169_schedule_work(struct net_device *dev, work_func_t task) +static void rtl8169_schedule_work(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); - PREPARE_DELAYED_WORK(&tp->task, task); - schedule_delayed_work(&tp->task, 4); + schedule_work(&tp->wk.work); } static void rtl8169_wait_for_quiescence(struct net_device *dev) @@ -5353,10 +5358,8 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev) napi_enable(&tp->napi); } -static void rtl8169_reset_task(struct work_struct *work) +static void rtl_reset_work(struct rtl8169_private *tp) { - struct rtl8169_private *tp = - container_of(work, struct rtl8169_private, task.work); struct net_device *dev = tp->dev; int i; @@ -5385,7 +5388,7 @@ static void rtl8169_reset_task(struct work_struct *work) static void rtl8169_tx_timeout(struct net_device *dev) { - rtl8169_schedule_work(dev, rtl8169_reset_task); + rtl8169_schedule_work(dev); } static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, @@ -5588,7 +5591,7 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) rtl8169_hw_reset(tp); - rtl8169_schedule_work(dev, rtl8169_reset_task); + rtl8169_schedule_work(dev); } static void rtl8169_tx_interrupt(struct net_device *dev, @@ -5707,7 +5710,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, if (status & RxCRC) dev->stats.rx_crc_errors++; if (status & RxFOVF) { - rtl8169_schedule_work(dev, rtl8169_reset_task); + rtl8169_schedule_work(dev); dev->stats.rx_fifo_errors++; } rtl8169_mark_to_asic(desc, rx_buf_sz); @@ -5840,6 +5843,14 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) return IRQ_RETVAL(handled); } +static void rtl_task(struct work_struct *work) +{ + struct rtl8169_private *tp = + container_of(work, struct rtl8169_private, wk.work); + + rtl_reset_work(tp); +} + static int rtl8169_poll(struct napi_struct *napi, int budget) { struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); @@ -6046,7 +6057,7 @@ static void __rtl8169_resume(struct net_device *dev) rtl_pll_power_up(tp); - rtl8169_schedule_work(dev, rtl8169_reset_task); + rtl8169_schedule_work(dev); } static int rtl8169_resume(struct device *device) -- GitLab From 3e990ff5f119c2f9b142f3e2548dc90ca9b7dfa1 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 26 Jan 2012 12:50:01 +0100 Subject: [PATCH 0214/1846] r8169: factor out IntrMask writes. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 6d74931049fb..9f9abb5d01a5 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -1184,6 +1184,13 @@ static u8 rtl8168d_efuse_read(void __iomem *ioaddr, int reg_addr) return value; } +static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits) +{ + void __iomem *ioaddr = tp->mmio_addr; + + RTL_W16(IntrMask, bits); +} + static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; @@ -4383,6 +4390,8 @@ static void rtl_hw_start(struct net_device *dev) tp->hw_start(dev); + rtl_irq_enable(tp, tp->intr_event); + netif_start_queue(dev); } @@ -4510,9 +4519,6 @@ static void rtl_hw_start_8169(struct net_device *dev) /* no early-rx interrupts */ RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); - - /* Enable all known interrupts by setting the interrupt mask. */ - RTL_W16(IntrMask, tp->intr_event); } static void rtl_csi_access_enable(void __iomem *ioaddr, u32 bits) @@ -4981,8 +4987,6 @@ static void rtl_hw_start_8168(struct net_device *dev) RTL_W8(Cfg9346, Cfg9346_Lock); RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); - - RTL_W16(IntrMask, tp->intr_event); } #define R810X_CPCMD_QUIRK_MASK (\ @@ -5140,8 +5144,6 @@ static void rtl_hw_start_8101(struct net_device *dev) rtl_set_rx_mode(dev); RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000); - - RTL_W16(IntrMask, tp->intr_event); } static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) -- GitLab From 9085cdfa2f9f04d8678465748e2cced6e3f02e26 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 26 Jan 2012 12:59:08 +0100 Subject: [PATCH 0215/1846] r8169: irq mask helpers. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 37 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 9f9abb5d01a5..610f4b3655c7 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -1184,6 +1184,29 @@ static u8 rtl8168d_efuse_read(void __iomem *ioaddr, int reg_addr) return value; } +static u16 rtl_get_events(struct rtl8169_private *tp) +{ + void __iomem *ioaddr = tp->mmio_addr; + + return RTL_R16(IntrStatus); +} + +static void rtl_ack_events(struct rtl8169_private *tp, u16 bits) +{ + void __iomem *ioaddr = tp->mmio_addr; + + RTL_W16(IntrStatus, bits); + mmiowb(); +} + +static void rtl_irq_disable(struct rtl8169_private *tp) +{ + void __iomem *ioaddr = tp->mmio_addr; + + RTL_W16(IntrMask, 0); + mmiowb(); +} + static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits) { void __iomem *ioaddr = tp->mmio_addr; @@ -1195,8 +1218,8 @@ static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; - RTL_W16(IntrMask, 0x0000); - RTL_W16(IntrStatus, tp->intr_event); + rtl_irq_disable(tp); + rtl_ack_events(tp, tp->intr_event); RTL_R8(ChipCmd); } @@ -4057,11 +4080,11 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) rtl_init_rxcfg(tp); - RTL_W16(IntrMask, 0x0000); + rtl_irq_disable(tp); rtl_hw_reset(tp); - RTL_W16(IntrStatus, 0xffff); + rtl_ack_events(tp, 0xffff); pci_set_master(pdev); @@ -5775,12 +5798,12 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) struct rtl8169_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; int handled = 0; - int status; + u16 status; /* loop handling interrupts until we have no new ones or * we hit a invalid/hotplug case. */ - status = RTL_R16(IntrStatus); + status = rtl_get_events(tp); while (status && status != 0xffff) { status &= tp->intr_event; if (!status) @@ -5839,7 +5862,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) */ RTL_W16(IntrStatus, (status & RxFIFOOver) ? (status | RxOverflow) : status); - status = RTL_R16(IntrStatus); + status = rtl_get_events(tp); } done: return IRQ_RETVAL(handled); -- GitLab From 1e874e041fc7c222cbd85b20c4406070be1f687a Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Fri, 27 Jan 2012 15:05:38 +0100 Subject: [PATCH 0216/1846] r8169: missing barriers. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 610f4b3655c7..8dd13f5a9203 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5552,7 +5552,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { netif_stop_queue(dev); - smp_rmb(); + smp_mb(); if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS) netif_wake_queue(dev); } @@ -5653,7 +5653,7 @@ static void rtl8169_tx_interrupt(struct net_device *dev, if (tp->dirty_tx != dirty_tx) { tp->dirty_tx = dirty_tx; - smp_wmb(); + smp_mb(); if (netif_queue_stopped(dev) && (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) { netif_wake_queue(dev); @@ -5664,7 +5664,6 @@ static void rtl8169_tx_interrupt(struct net_device *dev, * of start_xmit activity is detected (if it is not detected, * it is slow enough). -- FR */ - smp_rmb(); if (tp->cur_tx != dirty_tx) RTL_W8(TxPoll, NPQ); } -- GitLab From c1288b1278d00169e12495eb53ad128e09560b69 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 19 Jan 2012 09:29:57 +0100 Subject: [PATCH 0217/1846] mac80211: make beacon filtering per virtual interface Due to firmware limitations, we may not be able to support beacon filtering on all virtual interfaces. To allow this in mac80211, introduce per-interface driver capability flags that the driver sets when an interface is added. Signed-off-by: Johannes Berg Acked-by: Luciano Coelho Signed-off-by: John W. Linville --- drivers/net/wireless/p54/main.c | 3 ++- drivers/net/wireless/rtlwifi/base.c | 1 - drivers/net/wireless/rtlwifi/core.c | 2 ++ drivers/net/wireless/wl1251/main.c | 3 ++- drivers/net/wireless/wl12xx/main.c | 3 ++- include/net/mac80211.h | 29 ++++++++++++++++++++--------- net/mac80211/debugfs.c | 2 -- net/mac80211/mlme.c | 2 +- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c index af2ca1a9c7d3..40f4eb7da7b2 100644 --- a/drivers/net/wireless/p54/main.c +++ b/drivers/net/wireless/p54/main.c @@ -228,6 +228,8 @@ static int p54_add_interface(struct ieee80211_hw *dev, { struct p54_common *priv = dev->priv; + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + mutex_lock(&priv->conf_mutex); if (priv->mode != NL80211_IFTYPE_MONITOR) { mutex_unlock(&priv->conf_mutex); @@ -734,7 +736,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_PS_NULLFUNC_STACK | - IEEE80211_HW_BEACON_FILTER | IEEE80211_HW_REPORTS_TX_ACK_STATUS; dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index 6f80142580fd..ff3e393bc104 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -309,7 +309,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) /* <5> set hw caps */ hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_RX_INCLUDES_FCS | - IEEE80211_HW_BEACON_FILTER | IEEE80211_HW_AMPDU_AGGREGATION | IEEE80211_HW_CONNECTION_MONITOR | /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */ diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index d6e37e6a1d53..0ee01ab2e4f6 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c @@ -112,6 +112,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); int err = 0; + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + if (mac->vif) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "vif has been set!! mac->vif = 0x%p\n", mac->vif); diff --git a/drivers/net/wireless/wl1251/main.c b/drivers/net/wireless/wl1251/main.c index ba3268ea81fe..86540db6f1a8 100644 --- a/drivers/net/wireless/wl1251/main.c +++ b/drivers/net/wireless/wl1251/main.c @@ -514,6 +514,8 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw, struct wl1251 *wl = hw->priv; int ret = 0; + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", vif->type, vif->addr); @@ -1338,7 +1340,6 @@ int wl1251_init_ieee80211(struct wl1251 *wl) wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SUPPORTS_PS | - IEEE80211_HW_BEACON_FILTER | IEEE80211_HW_SUPPORTS_UAPSD | IEEE80211_HW_SUPPORTS_CQM_RSSI; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d5f55a149de5..afc5381f2870 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2060,6 +2060,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, u8 role_type; bool booted = false; + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", ieee80211_vif_type_p2p(vif), vif->addr); @@ -4898,7 +4900,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval; wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_BEACON_FILTER | IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_SUPPORTS_UAPSD | IEEE80211_HW_HAS_RATE_CONTROL | diff --git a/include/net/mac80211.h b/include/net/mac80211.h index d49928ba5d09..ae8db247bdeb 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -851,6 +851,16 @@ struct ieee80211_channel_switch { u8 count; }; +/** + * enum ieee80211_vif_flags - virtual interface flags + * + * @IEEE80211_VIF_BEACON_FILTER: the device performs beacon filtering + * on this virtual interface to avoid unnecessary CPU wakeups + */ +enum ieee80211_vif_flags { + IEEE80211_VIF_BEACON_FILTER = BIT(0), +}; + /** * struct ieee80211_vif - per-interface data * @@ -863,6 +873,10 @@ struct ieee80211_channel_switch { * @addr: address of this interface * @p2p: indicates whether this AP or STA interface is a p2p * interface, i.e. a GO or p2p-sta respectively + * @driver_flags: flags/capabilities the driver has for this interface, + * these need to be set (or cleared) when the interface is added + * or, if supported by the driver, the interface type is changed + * at runtime, mac80211 will never touch this field * @drv_priv: data area for driver use, will always be aligned to * sizeof(void *). */ @@ -871,6 +885,7 @@ struct ieee80211_vif { struct ieee80211_bss_conf bss_conf; u8 addr[ETH_ALEN]; bool p2p; + u32 driver_flags; /* must be last */ u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); }; @@ -1079,10 +1094,6 @@ enum sta_notify_cmd { * @IEEE80211_HW_MFP_CAPABLE: * Hardware supports management frame protection (MFP, IEEE 802.11w). * - * @IEEE80211_HW_BEACON_FILTER: - * Hardware supports dropping of irrelevant beacon frames to - * avoid waking up cpu. - * * @IEEE80211_HW_SUPPORTS_STATIC_SMPS: * Hardware supports static spatial multiplexing powersave, * ie. can turn off all but one chain even on HT connections @@ -1150,7 +1161,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11, IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12, IEEE80211_HW_MFP_CAPABLE = 1<<13, - IEEE80211_HW_BEACON_FILTER = 1<<14, + /* reuse bit 14 */ IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15, IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16, IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, @@ -1446,8 +1457,8 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); * way the host will only receive beacons where some relevant information * (for example ERP protection or WMM settings) have changed. * - * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER - * hardware capability. The driver needs to enable beacon filter support + * Beacon filter support is advertised with the %IEEE80211_VIF_BEACON_FILTER + * interface capability. The driver needs to enable beacon filter support * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When * power save is enabled, the stack will not check for beacon loss and the * driver needs to notify about loss of beacons with ieee80211_beacon_loss(). @@ -3316,7 +3327,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, * * @vif: &struct ieee80211_vif pointer from the add_interface callback. * - * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and + * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER and * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the * hardware is not receiving beacons with this function. */ @@ -3327,7 +3338,7 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif); * * @vif: &struct ieee80211_vif pointer from the add_interface callback. * - * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and + * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER, and * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver * needs to inform if the connection to the AP has been lost. * diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 90baea53e7c5..e8868dae1c01 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -247,8 +247,6 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf, sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n"); if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE) sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n"); - if (local->hw.flags & IEEE80211_HW_BEACON_FILTER) - sf += snprintf(buf + sf, mxln - sf, "BEACON_FILTER\n"); if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n"); if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 95d3964fc080..b51eb49d8525 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -127,7 +127,7 @@ static void run_again(struct ieee80211_if_managed *ifmgd, void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata) { - if (sdata->local->hw.flags & IEEE80211_HW_BEACON_FILTER) + if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER) return; mod_timer(&sdata->u.mgd.bcn_mon_timer, -- GitLab From ea086359a63bd0dd85c1d784d0425340649613fa Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 19 Jan 2012 09:29:58 +0100 Subject: [PATCH 0218/1846] mac80211: make CQM RSSI support per virtual interface Similar to the previous beacon filtering patch, make CQM RSSI support depend on the flags that the driver set for virtual interfaces. Signed-off-by: Johannes Berg Acked-by: Luciano Coelho Signed-off-by: John W. Linville --- drivers/net/wireless/wl1251/main.c | 6 +++--- drivers/net/wireless/wl12xx/main.c | 4 ++-- include/net/mac80211.h | 14 +++++++------- net/mac80211/cfg.c | 10 ++-------- net/mac80211/debugfs.c | 2 -- net/mac80211/mlme.c | 4 ++-- 6 files changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/wl1251/main.c b/drivers/net/wireless/wl1251/main.c index 86540db6f1a8..41302c7b1ad0 100644 --- a/drivers/net/wireless/wl1251/main.c +++ b/drivers/net/wireless/wl1251/main.c @@ -514,7 +514,8 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw, struct wl1251 *wl = hw->priv; int ret = 0; - vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | + IEEE80211_VIF_SUPPORTS_CQM_RSSI; wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", vif->type, vif->addr); @@ -1340,8 +1341,7 @@ int wl1251_init_ieee80211(struct wl1251 *wl) wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SUPPORTS_PS | - IEEE80211_HW_SUPPORTS_UAPSD | - IEEE80211_HW_SUPPORTS_CQM_RSSI; + IEEE80211_HW_SUPPORTS_UAPSD; wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index afc5381f2870..f8748cedbae1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2060,7 +2060,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, u8 role_type; bool booted = false; - vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | + IEEE80211_VIF_SUPPORTS_CQM_RSSI; wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", ieee80211_vif_type_p2p(vif), vif->addr); @@ -4904,7 +4905,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) IEEE80211_HW_SUPPORTS_UAPSD | IEEE80211_HW_HAS_RATE_CONTROL | IEEE80211_HW_CONNECTION_MONITOR | - IEEE80211_HW_SUPPORTS_CQM_RSSI | IEEE80211_HW_REPORTS_TX_ACK_STATUS | IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_AP_LINK_PS | diff --git a/include/net/mac80211.h b/include/net/mac80211.h index ae8db247bdeb..650185876846 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -856,9 +856,14 @@ struct ieee80211_channel_switch { * * @IEEE80211_VIF_BEACON_FILTER: the device performs beacon filtering * on this virtual interface to avoid unnecessary CPU wakeups + * @IEEE80211_VIF_SUPPORTS_CQM_RSSI: the device can do connection quality + * monitoring on this virtual interface -- i.e. it can monitor + * connection quality related parameters, such as the RSSI level and + * provide notifications if configured trigger levels are reached. */ enum ieee80211_vif_flags { IEEE80211_VIF_BEACON_FILTER = BIT(0), + IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1), }; /** @@ -1119,11 +1124,6 @@ enum sta_notify_cmd { * When this flag is set, signaling beacon-loss will cause an immediate * change to disassociated state. * - * @IEEE80211_HW_SUPPORTS_CQM_RSSI: - * Hardware can do connection quality monitoring - i.e. it can monitor - * connection quality related parameters, such as the RSSI level and - * provide notifications if configured trigger levels are reached. - * * @IEEE80211_HW_NEED_DTIM_PERIOD: * This device needs to know the DTIM period for the BSS before * associating. @@ -1167,7 +1167,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, IEEE80211_HW_CONNECTION_MONITOR = 1<<19, - IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, + /* reuse bit 20 */ IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, IEEE80211_HW_AP_LINK_PS = 1<<22, IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, @@ -3408,7 +3408,7 @@ void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif); * @rssi_event: the RSSI trigger event type * @gfp: context flags * - * When the %IEEE80211_HW_SUPPORTS_CQM_RSSI is set, and a connection quality + * When the %IEEE80211_VIF_SUPPORTS_CQM_RSSI is set, and a connection quality * monitoring is configured with an rssi threshold, the driver will inform * whenever the rssi level reaches the threshold. */ diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index d86730fe75c8..74c9301681e5 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1873,7 +1873,6 @@ static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, s32 rssi_thold, u32 rssi_hyst) { struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); struct ieee80211_vif *vif = &sdata->vif; struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; @@ -1884,14 +1883,9 @@ static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, bss_conf->cqm_rssi_thold = rssi_thold; bss_conf->cqm_rssi_hyst = rssi_hyst; - if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) { - if (sdata->vif.type != NL80211_IFTYPE_STATION) - return -EOPNOTSUPP; - return 0; - } - /* tell the driver upon association, unless already associated */ - if (sdata->u.mgd.associated) + if (sdata->u.mgd.associated && + sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI) ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); return 0; diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index e8868dae1c01..affe64be9092 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -257,8 +257,6 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf, sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n"); if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n"); - if (local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI) - sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_CQM_RSSI\n"); if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK) sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n"); if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index b51eb49d8525..de3268c7be1e 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1043,7 +1043,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, bss_info_changed |= BSS_CHANGED_BSSID; /* Tell the driver to monitor connection quality (if supported) */ - if ((local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI) && + if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI && bss_conf->cqm_rssi_thold) bss_info_changed |= BSS_CHANGED_CQM; @@ -1882,7 +1882,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, if (bss_conf->cqm_rssi_thold && ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT && - !(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) { + !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) { int sig = ifmgd->ave_beacon_signal / 16; int last_event = ifmgd->last_cqm_event_signal; int thold = bss_conf->cqm_rssi_thold; -- GitLab From 8e7c4e4dc6e98a0d3ee4535c6b94a3ad63adad2a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:52:36 +0100 Subject: [PATCH 0219/1846] mac80211: fix a few -Wshadow warnings It seems that -Wshadow is no longer default in sparse runs, but let's fix the warnings anyway. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/rx.c | 3 --- net/mac80211/status.c | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 751409120769..73d213810a37 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2180,9 +2180,6 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx) if (rx->sdata->vif.type == NL80211_IFTYPE_AP && ieee80211_is_beacon(mgmt->frame_control) && !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { - struct ieee80211_rx_status *status; - - status = IEEE80211_SKB_RXCB(rx->skb); cfg80211_report_obss_beacon(rx->local->hw.wiphy, rx->skb->data, rx->skb->len, status->freq, GFP_ATOMIC); diff --git a/net/mac80211/status.c b/net/mac80211/status.c index 30c265c98f73..d67f0b967f8a 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -350,7 +350,6 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) bool send_to_cooked; bool acked; struct ieee80211_bar *bar; - u16 tid; int rtap_len; for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { @@ -412,7 +411,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) } if (!acked && ieee80211_is_back_req(fc)) { - u16 control; + u16 tid, control; /* * BAR failed, store the last SSN and retry sending @@ -516,7 +515,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) if (ieee80211_is_nullfunc(hdr->frame_control) || ieee80211_is_qos_nullfunc(hdr->frame_control)) { - bool acked = info->flags & IEEE80211_TX_STAT_ACK; + acked = info->flags & IEEE80211_TX_STAT_ACK; + cfg80211_probe_status(skb->dev, hdr->addr1, cookie, acked, GFP_ATOMIC); } else { -- GitLab From 2da8f419e78a0ebccc91c095328278fe668a7932 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:52:37 +0100 Subject: [PATCH 0220/1846] cfg80211: fix a few -Wshadow warnings It seems that -Wshadow is no longer default in sparse runs, but let's fix the warnings anyway. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/wireless/nl80211.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index afeea32e04ad..5cefd74ab47d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -427,10 +427,9 @@ static int nl80211_parse_key_new(struct nlattr *key, struct key_parse *k) if (tb[NL80211_KEY_DEFAULT_TYPES]) { struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES]; - int err = nla_parse_nested(kdt, - NUM_NL80211_KEY_DEFAULT_TYPES - 1, - tb[NL80211_KEY_DEFAULT_TYPES], - nl80211_key_default_policy); + err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1, + tb[NL80211_KEY_DEFAULT_TYPES], + nl80211_key_default_policy); if (err) return err; @@ -4781,7 +4780,6 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); struct ieee80211_supported_band *sband = wiphy->bands[ibss.channel->band]; - int err; err = ieee80211_get_ratemask(sband, rates, n_rates, &ibss.basic_rates); -- GitLab From 94f9065648a2645b28187b44ec7778c30cf58758 Mon Sep 17 00:00:00 2001 From: Chun-Yeow Yeoh Date: Sat, 21 Jan 2012 01:02:16 +0800 Subject: [PATCH 0221/1846] {nl,cfg,mac}80211: Add support of setting non-forwarding entity in Mesh A mesh node that joins the mesh network is by default a forwarding entity. This patch allows the mesh node to set as non-forwarding entity. Whenever dot11MeshForwarding is set to 0, the mesh node can prevent itself from forwarding the traffic which is not destined to him. Signed-off-by: Chun-Yeow Yeoh Signed-off-by: John W. Linville --- include/linux/nl80211.h | 4 ++++ include/net/cfg80211.h | 1 + net/mac80211/cfg.c | 2 ++ net/mac80211/debugfs_netdev.c | 1 + net/mac80211/mesh_hwmp.c | 2 +- net/wireless/mesh.c | 1 + net/wireless/nl80211.c | 5 +++++ 7 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 0f5ff3739820..4f98fae13307 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -2104,6 +2104,9 @@ enum nl80211_mntr_flags { * TUs) during which a mesh STA can send only one Action frame containing a * PERR element. * + * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding + * or forwarding entity (default is TRUE - forwarding entity) + * * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute * * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use @@ -2128,6 +2131,7 @@ enum nl80211_meshconf_params { NL80211_MESHCONF_HWMP_RANN_INTERVAL, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, + NL80211_MESHCONF_FORWARDING, /* keep last */ __NL80211_MESHCONF_ATTR_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 208a7b5f8d49..281899167d2d 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -798,6 +798,7 @@ struct mesh_config { * mesh gate, but not necessarily using the gate announcement protocol. * Still keeping the same nomenclature to be in sync with the spec. */ bool dot11MeshGateAnnouncementProtocol; + bool dot11MeshForwarding; }; /** diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 74c9301681e5..98460783c2d3 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1346,6 +1346,8 @@ static int ieee80211_update_mesh_config(struct wiphy *wiphy, conf->dot11MeshHWMPRannInterval = nconf->dot11MeshHWMPRannInterval; } + if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) + conf->dot11MeshForwarding = nconf->dot11MeshForwarding; return 0; } diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 176c08ffb13c..81d12e65a23c 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -422,6 +422,7 @@ IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol, u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol, DEC); IEEE80211_IF_FILE(dot11MeshHWMPRannInterval, u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC); +IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC); #endif diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 73abb7524b2c..cae407136ae0 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -575,7 +575,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, ifmsh->mshstats.dropped_frames_ttl++; } - if (forward) { + if (forward && ifmsh->mshcfg.dot11MeshForwarding) { u32 preq_id; u8 hopcount, flags; diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index 8c550df13037..9d3e3b6bfcf4 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c @@ -55,6 +55,7 @@ const struct mesh_config default_mesh_config = { .min_discovery_timeout = MESH_MIN_DISCOVERY_TIMEOUT, .dot11MeshHWMPRannInterval = MESH_RANN_INTERVAL, .dot11MeshGateAnnouncementProtocol = false, + .dot11MeshForwarding = true, }; const struct mesh_setup default_mesh_setup = { diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 5cefd74ab47d..c42173f947ef 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3258,6 +3258,8 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, cur_params.dot11MeshHWMPRannInterval); NLA_PUT_U8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, cur_params.dot11MeshGateAnnouncementProtocol); + NLA_PUT_U8(msg, NL80211_MESHCONF_FORWARDING, + cur_params.dot11MeshForwarding); nla_nest_end(msg, pinfoattr); genlmsg_end(msg, hdr); return genlmsg_reply(msg, info); @@ -3289,6 +3291,7 @@ static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_A [NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8 }, [NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 }, [NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 }, + [NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 }, }; static const struct nla_policy @@ -3378,6 +3381,8 @@ do {\ dot11MeshGateAnnouncementProtocol, mask, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, nla_get_u8); + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, + mask, NL80211_MESHCONF_FORWARDING, nla_get_u8); if (mask_out) *mask_out = mask; -- GitLab From 67e43de6dbc9caf52fa7bcf4c813fd088ba6fbfc Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 21 Jan 2012 16:59:10 +0100 Subject: [PATCH 0222/1846] carl9170: allow users to lower output power level This patch implements a simple way of reducing the output power of the device by a configurable upper limit. Requested-by: Harshal Chhaya Signed-off-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/ath/carl9170/carl9170.h | 1 + drivers/net/wireless/ath/carl9170/mac.c | 35 +++++++++++++++++++ drivers/net/wireless/ath/carl9170/main.c | 11 +++--- drivers/net/wireless/ath/carl9170/phy.c | 36 ++++---------------- drivers/net/wireless/ath/carl9170/tx.c | 2 ++ 5 files changed, 50 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h index f0f44c30b2f7..0cea20e3e250 100644 --- a/drivers/net/wireless/ath/carl9170/carl9170.h +++ b/drivers/net/wireless/ath/carl9170/carl9170.h @@ -559,6 +559,7 @@ int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry); int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac, const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen); int carl9170_disable_key(struct ar9170 *ar, const u8 id); +int carl9170_set_mac_tpc(struct ar9170 *ar, struct ieee80211_channel *channel); /* RX */ void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len); diff --git a/drivers/net/wireless/ath/carl9170/mac.c b/drivers/net/wireless/ath/carl9170/mac.c index dfda91970995..53415bfd8bef 100644 --- a/drivers/net/wireless/ath/carl9170/mac.c +++ b/drivers/net/wireless/ath/carl9170/mac.c @@ -485,3 +485,38 @@ int carl9170_disable_key(struct ar9170 *ar, const u8 id) return carl9170_exec_cmd(ar, CARL9170_CMD_DKEY, sizeof(key), (u8 *)&key, 0, NULL); } + +int carl9170_set_mac_tpc(struct ar9170 *ar, struct ieee80211_channel *channel) +{ + unsigned int power, chains; + + if (ar->eeprom.tx_mask != 1) + chains = AR9170_TX_PHY_TXCHAIN_2; + else + chains = AR9170_TX_PHY_TXCHAIN_1; + + switch (channel->band) { + case IEEE80211_BAND_2GHZ: + power = ar->power_2G_ofdm[0] & 0x3f; + break; + case IEEE80211_BAND_5GHZ: + power = ar->power_5G_leg[0] & 0x3f; + break; + default: + BUG_ON(1); + } + + power = min_t(unsigned int, power, ar->hw->conf.power_level * 2); + + carl9170_regwrite_begin(ar); + carl9170_regwrite(AR9170_MAC_REG_ACK_TPC, + 0x3c1e | power << 20 | chains << 26); + carl9170_regwrite(AR9170_MAC_REG_RTS_CTS_TPC, + power << 5 | chains << 11 | + power << 21 | chains << 27); + carl9170_regwrite(AR9170_MAC_REG_CFEND_QOSNULL_TPC, + power << 5 | chains << 11 | + power << 21 | chains << 27); + carl9170_regwrite_finish(); + return carl9170_regwrite_result(); +} diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index 6ee7c55f75a8..8d2523b3f722 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c @@ -853,11 +853,6 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed) goto out; } - if (changed & IEEE80211_CONF_CHANGE_POWER) { - /* TODO */ - err = 0; - } - if (changed & IEEE80211_CONF_CHANGE_SMPS) { /* TODO */ err = 0; @@ -891,6 +886,12 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed) goto out; } + if (changed & IEEE80211_CONF_CHANGE_POWER) { + err = carl9170_set_mac_tpc(ar, ar->hw->conf.channel); + if (err) + goto out; + } + out: mutex_unlock(&ar->mutex); return err; diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c index 472efc7e3402..b72c09cf43a4 100644 --- a/drivers/net/wireless/ath/carl9170/phy.c +++ b/drivers/net/wireless/ath/carl9170/phy.c @@ -1426,15 +1426,15 @@ static void carl9170_calc_ctl(struct ar9170 *ar, u32 freq, enum carl9170_bw bw) #undef EDGES } -static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq, - enum carl9170_bw bw) +static void carl9170_set_power_cal(struct ar9170 *ar, u32 freq, + enum carl9170_bw bw) { struct ar9170_calibration_target_power_legacy *ctpl; struct ar9170_calibration_target_power_ht *ctph; u8 *ctpres; int ntargets; int idx, i, n; - u8 ackpower, ackchains, f; + u8 f; u8 pwr_freqs[AR5416_MAX_NUM_TGT_PWRS]; if (freq < 3000) @@ -1523,32 +1523,6 @@ static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq, /* calc. conformance test limits and apply to ar->power*[] */ carl9170_calc_ctl(ar, freq, bw); - - /* set ACK/CTS TX power */ - carl9170_regwrite_begin(ar); - - if (ar->eeprom.tx_mask != 1) - ackchains = AR9170_TX_PHY_TXCHAIN_2; - else - ackchains = AR9170_TX_PHY_TXCHAIN_1; - - if (freq < 3000) - ackpower = ar->power_2G_ofdm[0] & 0x3f; - else - ackpower = ar->power_5G_leg[0] & 0x3f; - - carl9170_regwrite(AR9170_MAC_REG_ACK_TPC, - 0x3c1e | ackpower << 20 | ackchains << 26); - carl9170_regwrite(AR9170_MAC_REG_RTS_CTS_TPC, - ackpower << 5 | ackchains << 11 | - ackpower << 21 | ackchains << 27); - - carl9170_regwrite(AR9170_MAC_REG_CFEND_QOSNULL_TPC, - ackpower << 5 | ackchains << 11 | - ackpower << 21 | ackchains << 27); - - carl9170_regwrite_finish(); - return carl9170_regwrite_result(); } int carl9170_get_noisefloor(struct ar9170 *ar) @@ -1712,7 +1686,9 @@ int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel, if (err) return err; - err = carl9170_set_power_cal(ar, channel->center_freq, bw); + carl9170_set_power_cal(ar, channel->center_freq, bw); + + err = carl9170_set_mac_tpc(ar, channel); if (err) return err; diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c index d19a9ee9d057..771e1a9294c5 100644 --- a/drivers/net/wireless/ath/carl9170/tx.c +++ b/drivers/net/wireless/ath/carl9170/tx.c @@ -719,6 +719,8 @@ static void carl9170_tx_rate_tpc_chains(struct ar9170 *ar, else *chains = AR9170_TX_PHY_TXCHAIN_2; } + + *tpc = min_t(unsigned int, *tpc, ar->hw->conf.power_level * 2); } static __le32 carl9170_tx_physet(struct ar9170 *ar, -- GitLab From 15f0ebc23b7c68176ee3f9729d4a7f566cc6c311 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sat, 21 Jan 2012 11:03:00 -0800 Subject: [PATCH 0223/1846] kernel-doc: fix new warnings in cfg80211.h Fix new kernel-doc warnings: Warning(include/net/cfg80211.h:1165): No description found for parameter 'channel_type' Warning(include/net/cfg80211.h:2090): No description found for parameter 'probe_resp_offload' Signed-off-by: Randy Dunlap Cc: Johannes Berg Cc: linux-wireless@vger.kernel.org Signed-off-by: John W. Linville --- include/net/cfg80211.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 281899167d2d..5bb3ed4f99f5 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1143,6 +1143,7 @@ struct cfg80211_disassoc_request { * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not * search for IBSSs with a different BSSID. * @channel: The channel to use if no IBSS can be found to join. + * @channel_type: channel type (HT mode) * @channel_fixed: The channel should be fixed -- do not search for * IBSSs to join on other channels. * @ie: information element(s) to include in the beacon @@ -1981,6 +1982,11 @@ struct wiphy_wowlan_support { * configured as RX antennas. Antenna configuration commands will be * rejected unless this or @available_antennas_tx is set. * + * @probe_resp_offload: + * Bitmap of supported protocols for probe response offloading. + * See &enum nl80211_probe_resp_offload_support_attr. Only valid + * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set. + * * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation * may request, if implemented. * -- GitLab From 0c17cf962d716ea7557d18679cc98b3a43efb46d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 24 Jan 2012 14:09:06 +0100 Subject: [PATCH 0224/1846] rt2800usb: initialize H2M_INT_SRC register Ralink USB driver initialize H2M_INT_SRC to 0 after firmware load, and never touch this register later. It is not touched at all by Ralink PCI driver. Acked-by: Helmut Schaa Acked-by: Ivo van Doorn Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 22a1a8fc6e02..3e194b7e9bbe 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -448,6 +448,8 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev, */ rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); + if (rt2x00_is_usb(rt2x00dev)) + rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0); msleep(1); return 0; -- GitLab From 4ed1dd2a7ec880b301beb61cbc1e08811ec340e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 24 Jan 2012 14:09:07 +0100 Subject: [PATCH 0225/1846] rt2800: disable DMA after firmware load We can receive frames just after firmware load with current code, so disable DMA just after firmware is loaded, not before. Acked-by: Ivo van Doorn Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 3e194b7e9bbe..165535cc5072 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -411,18 +411,6 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev, rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000002); } - /* - * Disable DMA, will be reenabled later when enabling - * the radio. - */ - rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); - rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); - rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_DMA_BUSY, 0); - rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0); - rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_DMA_BUSY, 0); - rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1); - rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); - /* * Write firmware to the device. */ @@ -443,6 +431,15 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev, return -EBUSY; } + /* + * Disable DMA, will be reenabled later when enabling + * the radio. + */ + rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0); + rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); + /* * Initialize firmware. */ -- GitLab From 2a48e8ae113be506a7169d50c0b8fcb3ab0c462a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 24 Jan 2012 14:09:08 +0100 Subject: [PATCH 0226/1846] rt2800: zero MAC_SYS_CTRL bits during BBP and MAC reset Zero all other bits than RESET_CSR and RESET_BBP when want to do the reset, that the vendor driver behaviour. Acked-by: Helmut Schaa Acked-by: Ivo van Doorn Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800pci.c | 2 +- drivers/net/wireless/rt2x00/rt2800usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index dc88baefa72e..4e985026985c 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -489,7 +489,7 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev) rt2x00pci_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); - rt2x00pci_register_read(rt2x00dev, MAC_SYS_CTRL, ®); + reg = 0; rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); rt2x00pci_register_write(rt2x00dev, MAC_SYS_CTRL, reg); diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 262ee9eefb6f..425267af6106 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -228,7 +228,7 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); - rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®); + reg = 0; rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg); -- GitLab From 10ef6a8f1567739192c29f11375556ce0d53ec74 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 24 Jan 2012 14:09:09 +0100 Subject: [PATCH 0227/1846] rt2800usb: remove PWR_PIN_CFG=0x3 during init This seems to be only needed as workaround for hardware problem on PCI devices. Acked-by: Helmut Schaa Acked-by: Ivo van Doorn Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 425267af6106..f0074bcee7c9 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -226,8 +226,6 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, ®); rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000); - rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); - reg = 0; rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); -- GitLab From 2690e1bb35e97a3b15f0064e9176cd2ec61c2511 Mon Sep 17 00:00:00 2001 From: Avinash Patil Date: Tue, 24 Jan 2012 20:50:24 -0800 Subject: [PATCH 0228/1846] mwifiex: pass priv pointer instead of adapter Pass mwifiex_private pointer directly to wmm_add_buf_txqueue() instead of passing adapter and then deriving priv again in mwifiex_get_priv_by_id(). This reduces a 'for' loop in TX path. Signed-off-by: Avinash Patil Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/main.c | 2 +- drivers/net/wireless/mwifiex/wmm.c | 6 ++---- drivers/net/wireless/mwifiex/wmm.h | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index 1a0775d19ade..80e44566bf6e 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c @@ -462,7 +462,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) tx_info->bss_type = priv->bss_type; mwifiex_fill_buffer(skb); - mwifiex_wmm_add_buf_txqueue(priv->adapter, skb); + mwifiex_wmm_add_buf_txqueue(priv, skb); atomic_inc(&priv->adapter->tx_pending); if (atomic_read(&priv->adapter->tx_pending) >= MAX_TX_PENDING) { diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index e6a2cb127d2b..75f79ef9f6cf 100644 --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c @@ -599,12 +599,10 @@ mwifiex_is_ralist_valid(struct mwifiex_private *priv, * is queued at the list tail. */ void -mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter, +mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv, struct sk_buff *skb) { - struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb); - struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter, - tx_info->bss_num, tx_info->bss_type); + struct mwifiex_adapter *adapter = priv->adapter; u32 tid; struct mwifiex_ra_list_tbl *ra_list; u8 ra[ETH_ALEN], tid_down; diff --git a/drivers/net/wireless/mwifiex/wmm.h b/drivers/net/wireless/mwifiex/wmm.h index fcea1f68792f..ec839952d2e7 100644 --- a/drivers/net/wireless/mwifiex/wmm.h +++ b/drivers/net/wireless/mwifiex/wmm.h @@ -80,8 +80,8 @@ mwifiex_wmm_is_ra_list_empty(struct list_head *ra_list_hhead) return true; } -void mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter, - struct sk_buff *skb); +void mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv, + struct sk_buff *skb); void mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra); int mwifiex_wmm_lists_empty(struct mwifiex_adapter *adapter); -- GitLab From c4f3b9725ed476adbcaf1c49d882ab541bc4214c Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Tue, 24 Jan 2012 20:50:25 -0800 Subject: [PATCH 0229/1846] mwifiex: update BSS parameters in dump_station_info() This enables user to check beacon interval, DTIM period, short slot time and short preamble information using "iw dev mlan0 link" command when station is in connected state. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 17 +++++++++++++++++ drivers/net/wireless/mwifiex/main.h | 1 + drivers/net/wireless/mwifiex/scan.c | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 00f10059ecb4..6fef4925d13a 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -557,6 +557,23 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ sinfo->txrate.legacy = rate.rate * 5; + if (priv->bss_mode == NL80211_IFTYPE_STATION) { + sinfo->filled |= STATION_INFO_BSS_PARAM; + sinfo->bss_param.flags = 0; + if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap & + WLAN_CAPABILITY_SHORT_PREAMBLE) + sinfo->bss_param.flags |= + BSS_PARAM_FLAGS_SHORT_PREAMBLE; + if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap & + WLAN_CAPABILITY_SHORT_SLOT_TIME) + sinfo->bss_param.flags |= + BSS_PARAM_FLAGS_SHORT_SLOT_TIME; + sinfo->bss_param.dtim_period = + priv->curr_bss_params.bss_descriptor.dtim_period; + sinfo->bss_param.beacon_interval = + priv->curr_bss_params.bss_descriptor.beacon_period; + } + return ret; } diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 6712ea89ef78..3dc0f721c1db 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -249,6 +249,7 @@ struct mwifiex_bssdescriptor { u32 channel; u32 freq; u16 beacon_period; + u8 dtim_period; u8 erp_flags; u32 bss_mode; u8 supported_rates[MWIFIEX_SUPPORTED_RATES]; diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 98f1ca9cd6d8..135208596aff 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -1086,6 +1086,7 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, struct ieee_types_vendor_specific *vendor_ie; const u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 }; const u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 }; + struct ieee80211_tim_ie *tim_ie; found_data_rate_ie = false; rate_size = 0; @@ -1258,6 +1259,11 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, sizeof(struct ieee_types_header) - bss_entry->beacon_buf); break; + case WLAN_EID_TIM: + tim_ie = (void *) (current_ptr + + sizeof(struct ieee_types_header)); + bss_entry->dtim_period = tim_ie->dtim_period; + break; default: break; } -- GitLab From 6269cc83e7c444f3050e0d7e640d079bae17aa68 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 26 Jan 2012 09:13:31 +0300 Subject: [PATCH 0230/1846] nfc: NULL vs zero in nci_activate_target() This is a pointer so it should be NULL instead of zero. Sparse complains about this stuff: net/nfc/nci/core.c:447:37: warning: Using plain integer as NULL pointer Signed-off-by: Dan Carpenter Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/nci/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 12d1d4d62672..a47e90c7d9d1 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -444,7 +444,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); struct nci_rf_discover_select_param param; - struct nfc_target *target = 0; + struct nfc_target *target = NULL; int i; int rc = 0; -- GitLab From 6e1b1b246096fe04467f928973487fa47afaf2cc Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 26 Jan 2012 13:36:05 +0200 Subject: [PATCH 0231/1846] mac80211: send null packet on active (psm) reconfiguration The sta might be in psm against the ap (e.g. because this was the before a hw restart), so we explicitly send a null packet in order to make sure it'll sync against the ap (and get out of psm). Signed-off-by: Eliad Peller Signed-off-by: John W. Linville --- net/mac80211/util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 30d72e2af7ce..d82d886d0867 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1271,6 +1271,21 @@ int ieee80211_reconfig(struct ieee80211_local *local) ieee80211_recalc_ps(local, -1); + /* + * The sta might be in psm against the ap (e.g. because + * this was the state before a hw restart), so we + * explicitly send a null packet in order to make sure + * it'll sync against the ap (and get out of psm). + */ + if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) { + list_for_each_entry(sdata, &local->interfaces, list) { + if (sdata->vif.type != NL80211_IFTYPE_STATION) + continue; + + ieee80211_send_nullfunc(local, sdata, 0); + } + } + /* * Clear the WLAN_STA_BLOCK_BA flag so new aggregation * sessions can be established after a resume. -- GitLab From f1e3be1561c43b6bbe2426e34849fb1486dc313b Mon Sep 17 00:00:00 2001 From: Nicolas Cavallari Date: Thu, 26 Jan 2012 13:36:34 +0100 Subject: [PATCH 0232/1846] mac80211: Do not scan for IBSS merge with a fixed BSSID. Currently, when we are on an IBSS network with no active station, we would scan for other BSSID, even if fixed_bssid is on, due to a bug in ibss.c, where fixed_channel would be checked instead of fixed_bssid. This would trigger useless scans where scan results would not be used anyway. This patch also reverts commit 39d02a7d90602d4557ee05db2a157a4e0, which assumed that the ifibss->fixed_channel check was legitimate to disable single-channel scans. IBSS single-channel scan should now be fixed. Signed-off-by: Nicolas Cavallari Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index d38baa41cf6c..93b3c7298be3 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -655,14 +655,15 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) if (ieee80211_sta_active_ibss(sdata)) return; - if (ifibss->fixed_channel) + if (ifibss->fixed_bssid) return; printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n", sdata->name); ieee80211_request_internal_scan(sdata, - ifibss->ssid, ifibss->ssid_len, NULL); + ifibss->ssid, ifibss->ssid_len, + ifibss->fixed_channel ? ifibss->channel : NULL); } static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) -- GitLab From ff7e9f99f7effb385a9be2f7198743c1ad2bb126 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Fri, 27 Jan 2012 16:08:27 +0530 Subject: [PATCH 0233/1846] mwl8k: Configuring correct MAC address in broadcast key While configuring the broadcast key in the hardware, in multi-BSS environment, BSSes other than first were incorrectly configured with the MAC address of first BSS. Fixing it with correct MAC addresses. Signed-off-by: Yogesh Ashok Powar Signed-off-by: John W. Linville --- drivers/net/wireless/mwl8k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index dd5aeaff44ba..fd125473be7a 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c @@ -4093,7 +4093,7 @@ static int mwl8k_set_key(struct ieee80211_hw *hw, return -EOPNOTSUPP; if (sta == NULL) - addr = hw->wiphy->perm_addr; + addr = vif->addr; else addr = sta->addr; -- GitLab From da78dbff2e05630921c551dbbc70a4b7981a8fff Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 26 Jan 2012 14:18:23 +0100 Subject: [PATCH 0234/1846] r8169: remove work from irq handler. The irq handler was a mess. See 7ab87ff4c770eed71e3777936299292739fcd0fe ("via-rhine: move work from irq handler to softirq and beyond") for similar changes. One can notice: - all non-napi tasks are explicitely scheduled trough a single work queue. - hiding software tx queue start behind the rtl_hw_start method is mildly natural. Move it in the caller where needed. - as can be seen from the heavy use of bh disabling locks, the driver is not safe for irq context messages with netconsole. It is still quite usable for general messaging though. Tested ok with concurrent registers dump (ethtool -d) + background traffic + "echo t > /proc/sysrq-trigger". Tested with old PCI chipset, PCIe 8168 and 810x: - XID 0c900800 RTL8168evl/8111evl - XID 18000000 RTL8168b/8111b - XID 98000000 RTL8169sc/8110sc - XID 083000c0 RTL8168d/8111d - XID 081000c0 RTL8168d/8111d - XID 00b00000 RTL8105e - XID 04a00000 RTL8102e As a side note, the comments in f11a377b3f4e897d11f0e8d1fc688667e2f19708 ("r8169: avoid losing MSI interrupts") does not seem completely clear: if I hack the driver further to stop acking the irq link event bit, MSI interrupts keep being delivered (RTL8168b/8111b, XID 18000000). Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 449 ++++++++++++++------------- 1 file changed, 231 insertions(+), 218 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 8dd13f5a9203..d039d39963ad 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -667,6 +667,13 @@ struct rtl8169_counters { __le16 tx_underun; }; +enum rtl_flag { + RTL_FLAG_TASK_SLOW_PENDING, + RTL_FLAG_TASK_RESET_PENDING, + RTL_FLAG_TASK_PHY_PENDING, + RTL_FLAG_MAX +}; + struct rtl8169_private { void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; @@ -688,9 +695,8 @@ struct rtl8169_private { struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ struct timer_list timer; u16 cp_cmd; - u16 intr_event; - u16 napi_event; - u16 intr_mask; + + u16 event_slow; struct mdio_ops { void (*write)(void __iomem *, int, int); @@ -716,7 +722,10 @@ struct rtl8169_private { int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd); struct { + DECLARE_BITMAP(flags, RTL_FLAG_MAX); + struct mutex mutex; struct work_struct work; + bool enabled; } wk; unsigned features; @@ -768,13 +777,20 @@ static int rtl8169_close(struct net_device *dev); static void rtl_set_rx_mode(struct net_device *dev); static void rtl8169_tx_timeout(struct net_device *dev); static struct net_device_stats *rtl8169_get_stats(struct net_device *dev); -static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *, - void __iomem *, u32 budget); static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); -static void rtl8169_down(struct net_device *dev); static void rtl8169_rx_clear(struct rtl8169_private *tp); static int rtl8169_poll(struct napi_struct *napi, int budget); +static void rtl_lock_work(struct rtl8169_private *tp) +{ + mutex_lock(&tp->wk.mutex); +} + +static void rtl_unlock_work(struct rtl8169_private *tp) +{ + mutex_unlock(&tp->wk.mutex); +} + static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force) { int cap = pci_pcie_cap(pdev); @@ -1214,12 +1230,21 @@ static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits) RTL_W16(IntrMask, bits); } +#define RTL_EVENT_NAPI_RX (RxOK | RxErr) +#define RTL_EVENT_NAPI_TX (TxOK | TxErr) +#define RTL_EVENT_NAPI (RTL_EVENT_NAPI_RX | RTL_EVENT_NAPI_TX) + +static void rtl_irq_enable_all(struct rtl8169_private *tp) +{ + rtl_irq_enable(tp, RTL_EVENT_NAPI | tp->event_slow); +} + static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; rtl_irq_disable(tp); - rtl_ack_events(tp, tp->intr_event); + rtl_ack_events(tp, RTL_EVENT_NAPI | tp->event_slow); RTL_R8(ChipCmd); } @@ -1310,9 +1335,6 @@ static void __rtl8169_check_link_status(struct net_device *dev, struct rtl8169_private *tp, void __iomem *ioaddr, bool pm) { - unsigned long flags; - - spin_lock_irqsave(&tp->lock, flags); if (tp->link_ok(ioaddr)) { rtl_link_chg_patch(tp); /* This is to cancel a scheduled suspend if there's one. */ @@ -1327,7 +1349,6 @@ static void __rtl8169_check_link_status(struct net_device *dev, if (pm) pm_schedule_suspend(&tp->pci_dev->dev, 5000); } - spin_unlock_irqrestore(&tp->lock, flags); } static void rtl8169_check_link_status(struct net_device *dev, @@ -1370,12 +1391,12 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct rtl8169_private *tp = netdev_priv(dev); - spin_lock_irq(&tp->lock); + rtl_lock_work(tp); wol->supported = WAKE_ANY; wol->wolopts = __rtl8169_get_wol(tp); - spin_unlock_irq(&tp->lock); + rtl_unlock_work(tp); } static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) @@ -1412,14 +1433,15 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct rtl8169_private *tp = netdev_priv(dev); - spin_lock_irq(&tp->lock); + rtl_lock_work(tp); if (wol->wolopts) tp->features |= RTL_FEATURE_WOL; else tp->features &= ~RTL_FEATURE_WOL; __rtl8169_set_wol(tp, wol->wolopts); - spin_unlock_irq(&tp->lock); + + rtl_unlock_work(tp); device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts); @@ -1574,15 +1596,14 @@ static int rtl8169_set_speed(struct net_device *dev, static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) { struct rtl8169_private *tp = netdev_priv(dev); - unsigned long flags; int ret; del_timer_sync(&tp->timer); - spin_lock_irqsave(&tp->lock, flags); + rtl_lock_work(tp); ret = rtl8169_set_speed(dev, cmd->autoneg, ethtool_cmd_speed(cmd), cmd->duplex, cmd->advertising); - spin_unlock_irqrestore(&tp->lock, flags); + rtl_unlock_work(tp); return ret; } @@ -1602,14 +1623,12 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev, return features; } -static int rtl8169_set_features(struct net_device *dev, - netdev_features_t features) +static void __rtl8169_set_features(struct net_device *dev, + netdev_features_t features) { struct rtl8169_private *tp = netdev_priv(dev); - void __iomem *ioaddr = tp->mmio_addr; - unsigned long flags; - spin_lock_irqsave(&tp->lock, flags); + void __iomem *ioaddr = tp->mmio_addr; if (features & NETIF_F_RXCSUM) tp->cp_cmd |= RxChkSum; @@ -1623,12 +1642,21 @@ static int rtl8169_set_features(struct net_device *dev, RTL_W16(CPlusCmd, tp->cp_cmd); RTL_R16(CPlusCmd); +} - spin_unlock_irqrestore(&tp->lock, flags); +static int rtl8169_set_features(struct net_device *dev, + netdev_features_t features) +{ + struct rtl8169_private *tp = netdev_priv(dev); + + rtl_lock_work(tp); + __rtl8169_set_features(dev, features); + rtl_unlock_work(tp); return 0; } + static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, struct sk_buff *skb) { @@ -1677,14 +1705,12 @@ static int rtl8169_gset_xmii(struct net_device *dev, struct ethtool_cmd *cmd) static int rtl8169_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { struct rtl8169_private *tp = netdev_priv(dev); - unsigned long flags; int rc; - spin_lock_irqsave(&tp->lock, flags); - + rtl_lock_work(tp); rc = tp->get_settings(dev, cmd); + rtl_unlock_work(tp); - spin_unlock_irqrestore(&tp->lock, flags); return rc; } @@ -1692,14 +1718,15 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) { struct rtl8169_private *tp = netdev_priv(dev); - unsigned long flags; if (regs->len > R8169_REGS_SIZE) regs->len = R8169_REGS_SIZE; - spin_lock_irqsave(&tp->lock, flags); + rtl_lock_work(tp); + spin_lock_bh(&tp->lock); memcpy_fromio(p, tp->mmio_addr, regs->len); - spin_unlock_irqrestore(&tp->lock, flags); + spin_unlock_bh(&tp->lock); + rtl_unlock_work(tp); } static u32 rtl8169_get_msglevel(struct net_device *dev) @@ -3216,18 +3243,14 @@ static void rtl_hw_phy_config(struct net_device *dev) } } -static void rtl8169_phy_timer(unsigned long __opaque) +static void rtl_phy_work(struct rtl8169_private *tp) { - struct net_device *dev = (struct net_device *)__opaque; - struct rtl8169_private *tp = netdev_priv(dev); struct timer_list *timer = &tp->timer; void __iomem *ioaddr = tp->mmio_addr; unsigned long timeout = RTL8169_PHY_TIMEOUT; assert(tp->mac_version > RTL_GIGA_MAC_VER_01); - spin_lock_irq(&tp->lock); - if (tp->phy_reset_pending(tp)) { /* * A busy loop could burn quite a few cycles on nowadays CPU. @@ -3238,32 +3261,45 @@ static void rtl8169_phy_timer(unsigned long __opaque) } if (tp->link_ok(ioaddr)) - goto out_unlock; + return; - netif_warn(tp, link, dev, "PHY reset until link up\n"); + netif_warn(tp, link, tp->dev, "PHY reset until link up\n"); tp->phy_reset_enable(tp); out_mod_timer: mod_timer(timer, jiffies + timeout); -out_unlock: - spin_unlock_irq(&tp->lock); +} + +static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag) +{ + spin_lock(&tp->lock); + if (!test_and_set_bit(flag, tp->wk.flags)) + schedule_work(&tp->wk.work); + spin_unlock(&tp->lock); +} + +static void rtl_schedule_task_bh(struct rtl8169_private *tp, enum rtl_flag flag) +{ + local_bh_disable(); + rtl_schedule_task(tp, flag); + local_bh_enable(); +} + +static void rtl8169_phy_timer(unsigned long __opaque) +{ + struct net_device *dev = (struct net_device *)__opaque; + struct rtl8169_private *tp = netdev_priv(dev); + + rtl_schedule_task_bh(tp, RTL_FLAG_TASK_PHY_PENDING); } #ifdef CONFIG_NET_POLL_CONTROLLER -/* - * Polling 'interrupt' - used by things like netconsole to send skbs - * without having to re-enable interrupts. It's not called while - * the interrupt routine is executing. - */ static void rtl8169_netpoll(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); - struct pci_dev *pdev = tp->pci_dev; - disable_irq(pdev->irq); - rtl8169_interrupt(pdev->irq, dev); - enable_irq(pdev->irq); + rtl8169_interrupt(tp->pci_dev->irq, dev); } #endif @@ -3344,7 +3380,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) low = addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24); high = addr[4] | (addr[5] << 8); - spin_lock_irq(&tp->lock); + rtl_lock_work(tp); RTL_W8(Cfg9346, Cfg9346_Unlock); @@ -3368,7 +3404,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr) RTL_W8(Cfg9346, Cfg9346_Lock); - spin_unlock_irq(&tp->lock); + rtl_unlock_work(tp); } static int rtl_set_mac_address(struct net_device *dev, void *p) @@ -3422,8 +3458,7 @@ static const struct rtl_cfg_info { void (*hw_start)(struct net_device *); unsigned int region; unsigned int align; - u16 intr_event; - u16 napi_event; + u16 event_slow; unsigned features; u8 default_ver; } rtl_cfg_infos [] = { @@ -3431,9 +3466,7 @@ static const struct rtl_cfg_info { .hw_start = rtl_hw_start_8169, .region = 1, .align = 0, - .intr_event = SYSErr | LinkChg | RxOverflow | - RxFIFOOver | TxErr | TxOK | RxOK | RxErr, - .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, + .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver, .features = RTL_FEATURE_GMII, .default_ver = RTL_GIGA_MAC_VER_01, }, @@ -3441,9 +3474,7 @@ static const struct rtl_cfg_info { .hw_start = rtl_hw_start_8168, .region = 2, .align = 8, - .intr_event = SYSErr | LinkChg | RxOverflow | - TxErr | TxOK | RxOK | RxErr, - .napi_event = TxErr | TxOK | RxOK | RxOverflow, + .event_slow = SYSErr | LinkChg | RxOverflow, .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI, .default_ver = RTL_GIGA_MAC_VER_11, }, @@ -3451,9 +3482,8 @@ static const struct rtl_cfg_info { .hw_start = rtl_hw_start_8101, .region = 2, .align = 8, - .intr_event = SYSErr | LinkChg | RxOverflow | PCSTimeout | - RxFIFOOver | TxErr | TxOK | RxOK | RxErr, - .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, + .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver | + PCSTimeout, .features = RTL_FEATURE_MSI, .default_ver = RTL_GIGA_MAC_VER_13, } @@ -4131,6 +4161,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) } spin_lock_init(&tp->lock); + mutex_init(&tp->wk.mutex); /* Get MAC address */ for (i = 0; i < ETH_ALEN; i++) @@ -4158,10 +4189,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) /* 8110SCd requires hardware Rx VLAN - disallow toggling */ dev->hw_features &= ~NETIF_F_HW_VLAN_RX; - tp->intr_mask = 0xffff; tp->hw_start = cfg->hw_start; - tp->intr_event = cfg->intr_event; - tp->napi_event = cfg->napi_event; + tp->event_slow = cfg->event_slow; tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ? ~(RxBOVF | RxFOVF) : ~0; @@ -4330,16 +4359,24 @@ static int rtl8169_open(struct net_device *dev) if (retval < 0) goto err_release_fw_2; + rtl_lock_work(tp); + + tp->wk.enabled = true; + napi_enable(&tp->napi); rtl8169_init_phy(dev, tp); - rtl8169_set_features(dev, dev->features); + __rtl8169_set_features(dev, dev->features); rtl_pll_power_up(tp); rtl_hw_start(dev); + netif_start_queue(dev); + + rtl_unlock_work(tp); + tp->saved_wolopts = 0; pm_runtime_put_noidle(&pdev->dev); @@ -4413,9 +4450,7 @@ static void rtl_hw_start(struct net_device *dev) tp->hw_start(dev); - rtl_irq_enable(tp, tp->intr_event); - - netif_start_queue(dev); + rtl_irq_enable_all(tp); } static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, @@ -4921,8 +4956,8 @@ static void rtl_hw_start_8168(struct net_device *dev) /* Work around for RxFIFO overflow. */ if (tp->mac_version == RTL_GIGA_MAC_VER_11) { - tp->intr_event |= RxFIFOOver | PCSTimeout; - tp->intr_event &= ~RxOverflow; + tp->event_slow |= RxFIFOOver | PCSTimeout; + tp->event_slow &= ~RxOverflow; } rtl_set_rx_tx_desc_registers(tp, ioaddr); @@ -5108,10 +5143,8 @@ static void rtl_hw_start_8101(struct net_device *dev) void __iomem *ioaddr = tp->mmio_addr; struct pci_dev *pdev = tp->pci_dev; - if (tp->mac_version >= RTL_GIGA_MAC_VER_30) { - tp->intr_event &= ~RxFIFOOver; - tp->napi_event &= ~RxFIFOOver; - } + if (tp->mac_version >= RTL_GIGA_MAC_VER_30) + tp->event_slow &= ~RxFIFOOver; if (tp->mac_version == RTL_GIGA_MAC_VER_13 || tp->mac_version == RTL_GIGA_MAC_VER_16) { @@ -5359,61 +5392,34 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp) tp->cur_tx = tp->dirty_tx = 0; } -static void rtl8169_schedule_work(struct net_device *dev) -{ - struct rtl8169_private *tp = netdev_priv(dev); - - schedule_work(&tp->wk.work); -} - -static void rtl8169_wait_for_quiescence(struct net_device *dev) -{ - struct rtl8169_private *tp = netdev_priv(dev); - void __iomem *ioaddr = tp->mmio_addr; - - synchronize_irq(dev->irq); - - /* Wait for any pending NAPI task to complete */ - napi_disable(&tp->napi); - - rtl8169_irq_mask_and_ack(tp); - - tp->intr_mask = 0xffff; - RTL_W16(IntrMask, tp->intr_event); - napi_enable(&tp->napi); -} - static void rtl_reset_work(struct rtl8169_private *tp) { struct net_device *dev = tp->dev; int i; - rtnl_lock(); - - if (!netif_running(dev)) - goto out_unlock; + napi_disable(&tp->napi); + netif_stop_queue(dev); + synchronize_sched(); rtl8169_hw_reset(tp); - rtl8169_wait_for_quiescence(dev); - for (i = 0; i < NUM_RX_DESC; i++) rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz); rtl8169_tx_clear(tp); rtl8169_init_ring_indexes(tp); + napi_enable(&tp->napi); rtl_hw_start(dev); netif_wake_queue(dev); rtl8169_check_link_status(dev, tp, tp->mmio_addr); - -out_unlock: - rtnl_unlock(); } static void rtl8169_tx_timeout(struct net_device *dev) { - rtl8169_schedule_work(dev); + struct rtl8169_private *tp = netdev_priv(dev); + + rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); } static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, @@ -5550,6 +5556,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, RTL_W8(TxPoll, NPQ); + mmiowb(); + if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { netif_stop_queue(dev); smp_mb(); @@ -5616,12 +5624,10 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) rtl8169_hw_reset(tp); - rtl8169_schedule_work(dev); + rtl_schedule_task_bh(tp, RTL_FLAG_TASK_RESET_PENDING); } -static void rtl8169_tx_interrupt(struct net_device *dev, - struct rtl8169_private *tp, - void __iomem *ioaddr) +static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) { unsigned int dirty_tx, tx_left; @@ -5664,8 +5670,11 @@ static void rtl8169_tx_interrupt(struct net_device *dev, * of start_xmit activity is detected (if it is not detected, * it is slow enough). -- FR */ - if (tp->cur_tx != dirty_tx) + if (tp->cur_tx != dirty_tx) { + void __iomem *ioaddr = tp->mmio_addr; + RTL_W8(TxPoll, NPQ); + } } } @@ -5704,9 +5713,7 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data, return skb; } -static int rtl8169_rx_interrupt(struct net_device *dev, - struct rtl8169_private *tp, - void __iomem *ioaddr, u32 budget) +static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget) { unsigned int cur_rx, rx_left; unsigned int count; @@ -5734,7 +5741,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, if (status & RxCRC) dev->stats.rx_crc_errors++; if (status & RxFOVF) { - rtl8169_schedule_work(dev); + rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); dev->stats.rx_fifo_errors++; } rtl8169_mark_to_asic(desc, rx_buf_sz); @@ -5795,109 +5802,120 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) { struct net_device *dev = dev_instance; struct rtl8169_private *tp = netdev_priv(dev); - void __iomem *ioaddr = tp->mmio_addr; int handled = 0; u16 status; - /* loop handling interrupts until we have no new ones or - * we hit a invalid/hotplug case. - */ status = rtl_get_events(tp); - while (status && status != 0xffff) { - status &= tp->intr_event; - if (!status) - break; - - handled = 1; + if (status && status != 0xffff) { + status &= RTL_EVENT_NAPI | tp->event_slow; + if (status) { + handled = 1; - /* Handle all of the error cases first. These will reset - * the chip, so just exit the loop. - */ - if (unlikely(!netif_running(dev))) { - rtl8169_hw_reset(tp); - break; + rtl_irq_disable(tp); + napi_schedule(&tp->napi); } + } + return IRQ_RETVAL(handled); +} - if (unlikely(status & RxFIFOOver)) { - switch (tp->mac_version) { - /* Work around for rx fifo overflow */ - case RTL_GIGA_MAC_VER_11: - netif_stop_queue(dev); - rtl8169_tx_timeout(dev); - goto done; - default: - break; - } - } +/* + * Workqueue context. + */ +static void rtl_slow_event_work(struct rtl8169_private *tp) +{ + struct net_device *dev = tp->dev; + u16 status; + + status = rtl_get_events(tp) & tp->event_slow; + rtl_ack_events(tp, status); - if (unlikely(status & SYSErr)) { - rtl8169_pcierr_interrupt(dev); + if (unlikely(status & RxFIFOOver)) { + switch (tp->mac_version) { + /* Work around for rx fifo overflow */ + case RTL_GIGA_MAC_VER_11: + netif_stop_queue(dev); + rtl_schedule_task_bh(tp, RTL_FLAG_TASK_RESET_PENDING); + default: break; } + } - if (status & LinkChg) - __rtl8169_check_link_status(dev, tp, ioaddr, true); + if (unlikely(status & SYSErr)) + rtl8169_pcierr_interrupt(dev); - /* We need to see the lastest version of tp->intr_mask to - * avoid ignoring an MSI interrupt and having to wait for - * another event which may never come. - */ - smp_rmb(); - if (status & tp->intr_mask & tp->napi_event) { - RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event); - tp->intr_mask = ~tp->napi_event; - - if (likely(napi_schedule_prep(&tp->napi))) - __napi_schedule(&tp->napi); - else - netif_info(tp, intr, dev, - "interrupt %04x in poll\n", status); - } + if (status & LinkChg) + __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true); - /* We only get a new MSI interrupt when all active irq - * sources on the chip have been acknowledged. So, ack - * everything we've seen and check if new sources have become - * active to avoid blocking all interrupts from the chip. - */ - RTL_W16(IntrStatus, - (status & RxFIFOOver) ? (status | RxOverflow) : status); - status = rtl_get_events(tp); - } -done: - return IRQ_RETVAL(handled); + napi_disable(&tp->napi); + rtl_irq_disable(tp); + + napi_enable(&tp->napi); + napi_schedule(&tp->napi); } static void rtl_task(struct work_struct *work) { + static const struct { + int bitnr; + void (*action)(struct rtl8169_private *); + } rtl_work[] = { + { RTL_FLAG_TASK_SLOW_PENDING, rtl_slow_event_work }, + { RTL_FLAG_TASK_RESET_PENDING, rtl_reset_work }, + { RTL_FLAG_TASK_PHY_PENDING, rtl_phy_work } + }; struct rtl8169_private *tp = container_of(work, struct rtl8169_private, wk.work); + struct net_device *dev = tp->dev; + int i; + + rtl_lock_work(tp); + + if (!netif_running(dev) || !tp->wk.enabled) + goto out_unlock; + + for (i = 0; i < ARRAY_SIZE(rtl_work); i++) { + bool pending; + + spin_lock_bh(&tp->lock); + pending = test_and_clear_bit(rtl_work[i].bitnr, tp->wk.flags); + spin_unlock_bh(&tp->lock); + + if (pending) + rtl_work[i].action(tp); + } - rtl_reset_work(tp); +out_unlock: + rtl_unlock_work(tp); } static int rtl8169_poll(struct napi_struct *napi, int budget) { struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); struct net_device *dev = tp->dev; - void __iomem *ioaddr = tp->mmio_addr; - int work_done; + u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow; + int work_done= 0; + u16 status; + + status = rtl_get_events(tp); + rtl_ack_events(tp, status & ~tp->event_slow); + + if (status & RTL_EVENT_NAPI_RX) + work_done = rtl_rx(dev, tp, (u32) budget); + + if (status & RTL_EVENT_NAPI_TX) + rtl_tx(dev, tp); - work_done = rtl8169_rx_interrupt(dev, tp, ioaddr, (u32) budget); - rtl8169_tx_interrupt(dev, tp, ioaddr); + if (status & tp->event_slow) { + enable_mask &= ~tp->event_slow; + + rtl_schedule_task(tp, RTL_FLAG_TASK_SLOW_PENDING); + } if (work_done < budget) { napi_complete(napi); - /* We need for force the visibility of tp->intr_mask - * for other CPUs, as we can loose an MSI interrupt - * and potentially wait for a retransmit timeout if we don't. - * The posted write to IntrMask is safe, as it will - * eventually make it to the chip and we won't loose anything - * until it does. - */ - tp->intr_mask = 0xffff; - wmb(); - RTL_W16(IntrMask, tp->intr_event); + rtl_irq_enable(tp, enable_mask); + mmiowb(); } return work_done; @@ -5921,11 +5939,8 @@ static void rtl8169_down(struct net_device *dev) del_timer_sync(&tp->timer); - netif_stop_queue(dev); - napi_disable(&tp->napi); - - spin_lock_irq(&tp->lock); + netif_stop_queue(dev); rtl8169_hw_reset(tp); /* @@ -5935,12 +5950,8 @@ static void rtl8169_down(struct net_device *dev) */ rtl8169_rx_missed(dev, ioaddr); - spin_unlock_irq(&tp->lock); - - synchronize_irq(dev->irq); - /* Give a racing hard_start_xmit a few cycles to complete. */ - synchronize_sched(); /* FIXME: should this be synchronize_irq()? */ + synchronize_sched(); rtl8169_tx_clear(tp); @@ -5959,7 +5970,11 @@ static int rtl8169_close(struct net_device *dev) /* Update counters before going down */ rtl8169_update_counters(dev); + rtl_lock_work(tp); + tp->wk.enabled = false; + rtl8169_down(dev); + rtl_unlock_work(tp); free_irq(dev->irq, dev); @@ -5979,7 +5994,6 @@ static void rtl_set_rx_mode(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; - unsigned long flags; u32 mc_filter[2]; /* Multicast hash filter */ int rx_mode; u32 tmp = 0; @@ -6008,7 +6022,7 @@ static void rtl_set_rx_mode(struct net_device *dev) } } - spin_lock_irqsave(&tp->lock, flags); + spin_lock_bh(&tp->lock); tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode; @@ -6024,7 +6038,7 @@ static void rtl_set_rx_mode(struct net_device *dev) RTL_W32(RxConfig, tmp); - spin_unlock_irqrestore(&tp->lock, flags); + spin_unlock_bh(&tp->lock); } /** @@ -6037,13 +6051,9 @@ static struct net_device_stats *rtl8169_get_stats(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; - unsigned long flags; - if (netif_running(dev)) { - spin_lock_irqsave(&tp->lock, flags); + if (netif_running(dev)) rtl8169_rx_missed(dev, ioaddr); - spin_unlock_irqrestore(&tp->lock, flags); - } return &dev->stats; } @@ -6055,10 +6065,15 @@ static void rtl8169_net_suspend(struct net_device *dev) if (!netif_running(dev)) return; - rtl_pll_power_down(tp); - netif_device_detach(dev); netif_stop_queue(dev); + + rtl_lock_work(tp); + napi_disable(&tp->napi); + tp->wk.enabled = false; + rtl_unlock_work(tp); + + rtl_pll_power_down(tp); } #ifdef CONFIG_PM @@ -6081,7 +6096,9 @@ static void __rtl8169_resume(struct net_device *dev) rtl_pll_power_up(tp); - rtl8169_schedule_work(dev); + tp->wk.enabled = true; + + rtl_schedule_task_bh(tp, RTL_FLAG_TASK_RESET_PENDING); } static int rtl8169_resume(struct device *device) @@ -6107,10 +6124,10 @@ static int rtl8169_runtime_suspend(struct device *device) if (!tp->TxDescArray) return 0; - spin_lock_irq(&tp->lock); + rtl_lock_work(tp); tp->saved_wolopts = __rtl8169_get_wol(tp); __rtl8169_set_wol(tp, WAKE_ANY); - spin_unlock_irq(&tp->lock); + rtl_unlock_work(tp); rtl8169_net_suspend(dev); @@ -6126,10 +6143,10 @@ static int rtl8169_runtime_resume(struct device *device) if (!tp->TxDescArray) return 0; - spin_lock_irq(&tp->lock); + rtl_lock_work(tp); __rtl8169_set_wol(tp, tp->saved_wolopts); tp->saved_wolopts = 0; - spin_unlock_irq(&tp->lock); + rtl_unlock_work(tp); rtl8169_init_phy(dev, tp); @@ -6197,12 +6214,8 @@ static void rtl_shutdown(struct pci_dev *pdev) /* Restore original MAC address */ rtl_rar_set(tp, dev->perm_addr); - spin_lock_irq(&tp->lock); - rtl8169_hw_reset(tp); - spin_unlock_irq(&tp->lock); - if (system_state == SYSTEM_POWER_OFF) { if (__rtl8169_get_wol(tp) & WAKE_ANY) { rtl_wol_suspend_quirk(tp); -- GitLab From 0ec88662041e172acf33d7a15a2020841ee82afb Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 27 Jan 2012 15:01:08 -0800 Subject: [PATCH 0235/1846] ipv4: ip_gre: Convert to dst_neigh_lookup() The conversion is very similar to that made to ipv6's SIT code. Signed-off-by: David S. Miller --- net/ipv4/ip_gre.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 05f7419ed7c5..bf9541648b96 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -730,10 +730,12 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev } #if IS_ENABLED(CONFIG_IPV6) else if (skb->protocol == htons(ETH_P_IPV6)) { - struct neighbour *neigh = dst_get_neighbour_noref(skb_dst(skb)); const struct in6_addr *addr6; + struct neighbour *neigh; + bool do_tx_error_icmp; int addr_type; + neigh = dst_neigh_lookup(skb_dst(skb), &ipv6_hdr(skb)->daddr); if (neigh == NULL) goto tx_error; @@ -746,9 +748,14 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev } if ((addr_type & IPV6_ADDR_COMPATv4) == 0) + do_tx_error_icmp = true; + else { + do_tx_error_icmp = false; + dst = addr6->s6_addr32[3]; + } + neigh_release(neigh); + if (do_tx_error_icmp) goto tx_error_icmp; - - dst = addr6->s6_addr32[3]; } #endif else -- GitLab From eb857186eb771998fc9ab4bfd398a6fedb5a295c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 27 Jan 2012 15:07:56 -0800 Subject: [PATCH 0236/1846] ipv6: ndisc: Convert to dst_neigh_lookup() Now all code paths grab a local reference to the neigh, so if neigh is not NULL we unconditionally release it at the end. The old logic would only release if we didn't have a non-NULL 'rt'. Signed-off-by: David S. Miller --- net/ipv6/ndisc.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index d8f02ef88e59..c574ebce3fb5 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1223,11 +1223,17 @@ static void ndisc_router_discovery(struct sk_buff *skb) rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev); - if (rt) - neigh = dst_get_neighbour_noref(&rt->dst); - + if (rt) { + neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr); + if (!neigh) { + ND_PRINTK0(KERN_ERR + "ICMPv6 RA: %s() got default router without neighbour.\n", + __func__); + dst_release(&rt->dst); + return; + } + } if (rt && lifetime == 0) { - neigh_clone(neigh); ip6_del_rt(rt); rt = NULL; } @@ -1244,7 +1250,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) return; } - neigh = dst_get_neighbour_noref(&rt->dst); + neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr); if (neigh == NULL) { ND_PRINTK0(KERN_ERR "ICMPv6 RA: %s() got default router without neighbour.\n", @@ -1411,7 +1417,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) out: if (rt) dst_release(&rt->dst); - else if (neigh) + if (neigh) neigh_release(neigh); } -- GitLab From 5339ab8b1dd82f14df168fb9bf59449f3e24b03d Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 27 Jan 2012 15:14:01 -0800 Subject: [PATCH 0237/1846] ipv6: fib: Convert fib6_age() to dst_neigh_lookup(). In this specific situation we know we are dealing with a gatewayed route and therefore rt6i_gateway is not going to be in6addr_any even in future interpretations. Signed-off-by: David S. Miller --- net/ipv6/ip6_fib.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index b82bcde53f7a..5b27fbcae346 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -1552,11 +1552,20 @@ static int fib6_age(struct rt6_info *rt, void *arg) time_after_eq(now, rt->dst.lastuse + gc_args.timeout)) { RT6_TRACE("aging clone %p\n", rt); return -1; - } else if ((rt->rt6i_flags & RTF_GATEWAY) && - (!(dst_get_neighbour_noref_raw(&rt->dst)->flags & NTF_ROUTER))) { - RT6_TRACE("purging route %p via non-router but gateway\n", - rt); - return -1; + } else if (rt->rt6i_flags & RTF_GATEWAY) { + struct neighbour *neigh; + __u8 neigh_flags = 0; + + neigh = dst_neigh_lookup(&rt->dst, &rt->rt6i_gateway); + if (neigh) { + neigh_flags = neigh->flags; + neigh_release(neigh); + } + if (neigh_flags & NTF_ROUTER) { + RT6_TRACE("purging route %p via non-router but gateway\n", + rt); + return -1; + } } gc_args.more++; } -- GitLab From 4991969a1027826c3db19dd3e600e145603e6928 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 27 Jan 2012 15:30:48 -0800 Subject: [PATCH 0238/1846] ipv6: Remove neigh argument from ndisc_send_redirect() Instead, compute it as-needed inside of that function using dst_neigh_lookup(). Signed-off-by: David S. Miller --- include/net/ndisc.h | 1 - net/ipv6/ip6_output.c | 2 +- net/ipv6/ndisc.c | 12 ++++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/net/ndisc.h b/include/net/ndisc.h index e3133c23980e..6f9c25a76cd1 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h @@ -133,7 +133,6 @@ extern void ndisc_send_rs(struct net_device *dev, const struct in6_addr *daddr); extern void ndisc_send_redirect(struct sk_buff *skb, - struct neighbour *neigh, const struct in6_addr *target); extern int ndisc_mc_map(const struct in6_addr *addr, char *buf, diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index d97e07183ce9..604809b89b67 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -486,7 +486,7 @@ int ip6_forward(struct sk_buff *skb) and by source (inside ndisc_send_redirect) */ if (inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ)) - ndisc_send_redirect(skb, n, target); + ndisc_send_redirect(skb, target); } else { int addrtype = ipv6_addr_type(&hdr->saddr); diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index c574ebce3fb5..8d817018c188 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1512,8 +1512,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) } } -void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, - const struct in6_addr *target) +void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) { struct net_device *dev = skb->dev; struct net *net = dev_net(dev); @@ -1571,6 +1570,13 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, goto release; if (dev->addr_len) { + struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target); + if (!neigh) { + ND_PRINTK2(KERN_WARNING + "ICMPv6 Redirect: no neigh for target address\n"); + goto release; + } + read_lock_bh(&neigh->lock); if (neigh->nud_state & NUD_VALID) { memcpy(ha_buf, neigh->ha, dev->addr_len); @@ -1579,6 +1585,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, len += ndisc_opt_addr_space(dev); } else read_unlock_bh(&neigh->lock); + + neigh_release(neigh); } rd_len = min_t(unsigned int, -- GitLab From c45a3dfb59c0f17bdbd294dd01efb2d7f99a32c7 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 27 Jan 2012 15:32:19 -0800 Subject: [PATCH 0239/1846] ipv6: Eliminate dst_get_neighbour_noref() usage in ip6_forward(). It's only used to get at neigh->primary_key, which in this context is always going to be the same as rt->rt6i_gateway. Signed-off-by: David S. Miller --- net/ipv6/ip6_output.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 604809b89b67..7a98fc2a5d97 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -388,7 +388,6 @@ int ip6_forward(struct sk_buff *skb) struct ipv6hdr *hdr = ipv6_hdr(skb); struct inet6_skb_parm *opt = IP6CB(skb); struct net *net = dev_net(dst->dev); - struct neighbour *n; u32 mtu; if (net->ipv6.devconf_all->forwarding == 0) @@ -463,8 +462,7 @@ int ip6_forward(struct sk_buff *skb) send redirects to source routed frames. We don't send redirects to frames decapsulated from IPsec. */ - n = dst_get_neighbour_noref(dst); - if (skb->dev == dst->dev && n && opt->srcrt == 0 && !skb_sec_path(skb)) { + if (skb->dev == dst->dev && opt->srcrt == 0 && !skb_sec_path(skb)) { struct in6_addr *target = NULL; struct rt6_info *rt; @@ -474,8 +472,8 @@ int ip6_forward(struct sk_buff *skb) */ rt = (struct rt6_info *) dst; - if ((rt->rt6i_flags & RTF_GATEWAY)) - target = (struct in6_addr*)&n->primary_key; + if (rt->rt6i_flags & RTF_GATEWAY) + target = &rt->rt6i_gateway; else target = &hdr->daddr; -- GitLab From de46fb079ff16fabb3bdf7892c9a2900a9880329 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 6 Jan 2012 15:47:59 -0800 Subject: [PATCH 0240/1846] iwlwifi: fix typo Fix few places of typo Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 185b69ef7539..f97d06169b45 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -111,17 +111,17 @@ * * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - * commands from user applicaiton to indirectly access peripheral register + * commands from user application 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 + * commands from user application to read data in sram * - * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image + * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Wake 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 * @IWL_TM_CMD_APP2DEV_GET_FW_INFO: - * retrieve informration of existing loaded uCode image + * retrieve information of existing loaded uCode image * */ enum iwl_tm_cmd_t { -- GitLab From 98d4bf0c49de0d7c68fa7e1f7bd0a37420f712ca Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 13 Jan 2012 11:56:11 +0100 Subject: [PATCH 0241/1846] iwlwifi: fix uCode event tracing Fix multiple bugs in event tracing: 1) If you enable uCode tracing with the device down, it will still attempt to access the device and continuously log "MAC is in deep sleep!" errors. Fix this by only starting logging when the device is actually alive. 2) Now you can set the flag when the device is down, but logging doesn't happen when you bring it up. To fix that, start logging when the device comes alive. This means we don't log before -- we could do that but I don't need it right now. 3) For some reason we read the error instead of the event log -- use the right pointer. 4) Optimise SRAM reading of event log header. 5) Fix reading write pointer == capacity, which can happen due to racy SRAM access 6) Most importantly: fix an error where we would try to read WAY too many events (like 2^32-300) when we read the wrap counter before it is updated by the uCode -- this does happen in practice and will cause the driver to hang the machine. 7) Finally, change the timer to 10ms instead of 100ms as 100ms is too slow to capture all data with a normal event log and with 100ms the log will wrap multiple times before we have a chance to read it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 99 ++++++++++++++++------ drivers/net/wireless/iwlwifi/iwl-debugfs.c | 7 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +- 3 files changed, 76 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 7321e7d31406..3e429a3e518d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -315,7 +315,7 @@ static void iwl_bg_statistics_periodic(unsigned long data) static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, u32 start_idx, u32 num_events, - u32 mode) + u32 capacity, u32 mode) { u32 i; u32 ptr; /* SRAM byte address of log data */ @@ -338,6 +338,15 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, ptr); rmb(); + /* + * Refuse to read more than would have fit into the log from + * the current start_idx. This used to happen due to the race + * described below, but now WARN because the code below should + * prevent it from happening here. + */ + if (WARN_ON(num_events > capacity - start_idx)) + num_events = capacity - start_idx; + /* * "time" is actually "data" for mode 0 (no timestamp). * place event id # at far right for easier visual parsing. @@ -346,12 +355,11 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, ev = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); time = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); if (mode == 0) { - trace_iwlwifi_dev_ucode_cont_event(priv, - 0, time, ev); + trace_iwlwifi_dev_ucode_cont_event(priv, 0, time, ev); } else { data = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); - trace_iwlwifi_dev_ucode_cont_event(priv, - time, data, ev); + trace_iwlwifi_dev_ucode_cont_event(priv, time, + data, ev); } } /* Allow device to power down */ @@ -362,53 +370,83 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, static void iwl_continuous_event_trace(struct iwl_priv *priv) { u32 capacity; /* event log capacity in # entries */ + struct { + u32 capacity; + u32 mode; + u32 wrap_counter; + u32 write_counter; + } __packed read; u32 base; /* SRAM byte address of event log header */ u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ u32 num_wraps; /* # times uCode wrapped to top of log */ u32 next_entry; /* index of next entry to be written by uCode */ - base = priv->shrd->device_pointers.error_event_table; + base = priv->shrd->device_pointers.log_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), - base + (2 * sizeof(u32))); - mode = iwl_read_targ_mem(bus(priv), base + (1 * sizeof(u32))); - next_entry = iwl_read_targ_mem(bus(priv), - base + (3 * sizeof(u32))); + iwl_read_targ_mem_words(bus(priv), base, &read, sizeof(read)); + + capacity = read.capacity; + mode = read.mode; + num_wraps = read.wrap_counter; + next_entry = read.write_counter; } else return; + /* + * Unfortunately, the uCode doesn't use temporary variables. + * Therefore, it can happen that we read next_entry == capacity, + * which really means next_entry == 0. + */ + if (unlikely(next_entry == capacity)) + next_entry = 0; + /* + * Additionally, the uCode increases the write pointer before + * the wraps counter, so if the write pointer is smaller than + * the old write pointer (wrap occurred) but we read that no + * wrap occurred, we actually read between the next_entry and + * num_wraps update (this does happen in practice!!) -- take + * that into account by increasing num_wraps. + */ + if (unlikely(next_entry < priv->event_log.next_entry && + num_wraps == priv->event_log.num_wraps)) + num_wraps++; + if (num_wraps == priv->event_log.num_wraps) { - iwl_print_cont_event_trace(priv, - base, priv->event_log.next_entry, - next_entry - priv->event_log.next_entry, - mode); + iwl_print_cont_event_trace( + priv, base, priv->event_log.next_entry, + next_entry - priv->event_log.next_entry, + capacity, mode); + priv->event_log.non_wraps_count++; } else { - if ((num_wraps - priv->event_log.num_wraps) > 1) + if (num_wraps - priv->event_log.num_wraps > 1) priv->event_log.wraps_more_count++; else priv->event_log.wraps_once_count++; + trace_iwlwifi_dev_ucode_wrap_event(priv, num_wraps - priv->event_log.num_wraps, next_entry, priv->event_log.next_entry); + if (next_entry < priv->event_log.next_entry) { - iwl_print_cont_event_trace(priv, base, - priv->event_log.next_entry, - capacity - priv->event_log.next_entry, - mode); + iwl_print_cont_event_trace( + priv, base, priv->event_log.next_entry, + capacity - priv->event_log.next_entry, + capacity, mode); - iwl_print_cont_event_trace(priv, base, 0, - next_entry, mode); + iwl_print_cont_event_trace( + priv, base, 0, next_entry, capacity, mode); } else { - iwl_print_cont_event_trace(priv, base, - next_entry, capacity - next_entry, - mode); + iwl_print_cont_event_trace( + priv, base, next_entry, + capacity - next_entry, + capacity, mode); - iwl_print_cont_event_trace(priv, base, 0, - next_entry, mode); + iwl_print_cont_event_trace( + priv, base, 0, next_entry, capacity, mode); } } + priv->event_log.num_wraps = num_wraps; priv->event_log.next_entry = next_entry; } @@ -1219,6 +1257,11 @@ int iwl_alive_start(struct iwl_priv *priv) if (iwl_is_rfkill(priv->shrd)) return -ERFKILL; + if (priv->event_log.ucode_trace) { + /* start collecting data now */ + mod_timer(&priv->ucode_trace, jiffies); + } + /* download priority table before any calibration request */ if (cfg(priv)->bt_params && cfg(priv)->bt_params->advanced_bt_coexist) { diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index f837f32bb71c..978a1d4c6a0a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2131,9 +2131,10 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, if (trace) { priv->event_log.ucode_trace = true; - /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ - mod_timer(&priv->ucode_trace, - jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); + if (iwl_is_alive(priv->shrd)) { + /* start collecting data now */ + mod_timer(&priv->ucode_trace, jiffies); + } } else { priv->event_log.ucode_trace = false; del_timer_sync(&priv->ucode_trace); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 4579d61da25e..af846002150a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -661,7 +661,7 @@ struct traffic_stats { * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds * to perform continuous uCode event logging operation if enabled */ -#define UCODE_TRACE_PERIOD (100) +#define UCODE_TRACE_PERIOD (10) /* * iwl_event_log: current uCode event log position -- GitLab From 42602dd419177b0de1b1093a420399132ed75ca6 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 19 Jan 2012 12:16:46 -0800 Subject: [PATCH 0242/1846] iwlwifi: add option to disalbe LED Led has no use for some platform. Add additional module parameter option to disable LED Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-led.c | 4 ++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 3e429a3e518d..90315c69cdf6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -2097,7 +2097,7 @@ MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)"); module_param_named(led_mode, iwlagn_mod_params.led_mode, int, S_IRUGO); MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking (default: 0)"); + "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)"); module_param_named(power_save, iwlagn_mod_params.power_save, bool, S_IRUGO); diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index eca79087afb8..8761438f1532 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -177,6 +177,10 @@ void iwl_leds_init(struct iwl_priv *priv) int mode = iwlagn_mod_params.led_mode; int ret; + if (mode == IWL_LED_DISABLE) { + IWL_INFO(priv, "Led disabled\n"); + return; + } if (mode == IWL_LED_DEFAULT) mode = cfg(priv)->led_mode; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index e406d49f4189..04975b7b65b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -264,11 +264,13 @@ enum iwl_pa_type { * LED ON = RF ON * LED OFF = RF OFF * IWL_LED_BLINK: adjust led blink rate based on blink table + * IWL_LED_DISABLE: led disabled */ enum iwl_led_mode { IWL_LED_DEFAULT, IWL_LED_RF_STATE, IWL_LED_BLINK, + IWL_LED_DISABLE, }; /** -- GitLab From 4c7d2fe9b116f749bc8362da33a628d6654e42b4 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 14:39:19 +0100 Subject: [PATCH 0243/1846] iwlwifi: always restrict scan dwell in P2P Whenever the PAN (P2P) context is active, it has timers in the uCode that prevent sleep, so scanning can't be out of channel for more than the beacon interval programmed into the device. Before this patch, a full scan including any passive channels when P2P was active would stall forever because it wouldn't find time to execute the passive requests (for default beacon intervals of 100 TU.) Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-scan.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 2aea20bf0f10..7f2e3a1c80ef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -414,10 +414,25 @@ static u16 iwl_limit_dwell(struct iwl_priv *priv, u16 dwell_time) for_each_context(priv, ctx) { u16 value; - if (!iwl_is_associated_ctx(ctx)) - continue; - if (ctx->staging.dev_type == RXON_DEV_TYPE_P2P) + switch (ctx->staging.dev_type) { + case RXON_DEV_TYPE_P2P: + /* no timing constraints */ continue; + case RXON_DEV_TYPE_ESS: + default: + /* timing constraints if associated */ + if (!iwl_is_associated_ctx(ctx)) + continue; + break; + case RXON_DEV_TYPE_CP: + case RXON_DEV_TYPE_2STA: + /* + * These seem to always have timers for TBTT + * active in uCode even when not associated yet. + */ + break; + } + value = ctx->beacon_int; if (!value) value = IWL_PASSIVE_DWELL_BASE; -- GitLab From 41b2d62702730b0c6bc5a40722e423bb0338311a Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Mon, 30 Jan 2012 10:53:55 -0500 Subject: [PATCH 0244/1846] ath9k: use WARN_ON_ONCE in ath_rc_get_highest_rix The device seems to survive the issue, so no need to flood the logs about it... Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/rc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index b3c3798fe513..635b592ad961 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -694,7 +694,7 @@ static u8 ath_rc_get_highest_rix(struct ath_softc *sc, return rate; /* This should not happen */ - WARN_ON(1); + WARN_ON_ONCE(1); rate = ath_rc_priv->valid_rate_index[0]; -- GitLab From 8b1c36b357153f491ddea5363fdd397109c3326f Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 30 Jan 2012 16:53:37 +0000 Subject: [PATCH 0245/1846] sfc: MTD: Leave the DEBUG macro alone no longer defines DEBUG so we do not need to un-define it here. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mtd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index eff49da458ed..79c192272047 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c @@ -10,7 +10,6 @@ #include #include -#undef DEBUG /* has its own use for DEBUG */ #include #include #include -- GitLab From 06e63c57acbb1df7c35ebe846ae416a8b88dfafa Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 30 Jan 2012 16:55:05 +0000 Subject: [PATCH 0246/1846] sfc: Use a more sensible cast in efx_rx_buf_offset() This function returns the page offset of the buffer, which can be calculated based on either its DMA address or its virtual address. It used to use the virtual address and we would cast that to unsigned long, as anything smaller would result in a compiler warning. Now that it's using the DMA address we should use unsigned int, matching the return type. It is also unnecessary to use __force. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index a33aef25ead9..1dfda5e27919 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -98,7 +98,7 @@ static inline unsigned int efx_rx_buf_offset(struct efx_nic *efx, /* Offset is always within one page, so we don't need to consider * the page order. */ - return ((__force unsigned long) buf->dma_addr & (PAGE_SIZE - 1)) + + return ((unsigned int) buf->dma_addr & (PAGE_SIZE - 1)) + efx->type->rx_buffer_hash_size; } static inline unsigned int efx_rx_buf_size(struct efx_nic *efx) -- GitLab From 3396c7823efb3a5b8630388c464e1034ea031ced Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Fri, 27 Jan 2012 13:36:01 +0000 Subject: [PATCH 0247/1846] drivers/net: fix up stale paths from driver reorg The reorganization of the driver layout in drivers/net left behind some stale paths in comments and in Kconfig help text. Bring them up to date. No actual change to any code takes place here. Signed-off-by: Paul Gortmaker CC: Jeff Kirsher Signed-off-by: David S. Miller --- Documentation/magic-number.txt | 2 +- Documentation/networking/phy.txt | 3 ++- Documentation/zh_CN/magic-number.txt | 2 +- drivers/net/can/slcan.c | 2 +- drivers/net/ethernet/3com/Kconfig | 2 +- drivers/net/ethernet/8390/ax88796.c | 2 +- drivers/net/ethernet/8390/axnet_cs.c | 2 +- drivers/net/ethernet/8390/pcnet_cs.c | 2 +- drivers/net/ethernet/amd/Kconfig | 2 +- drivers/net/ethernet/amd/am79c961a.c | 2 +- drivers/net/ethernet/amd/am79c961a.h | 2 +- drivers/net/ethernet/dec/tulip/21142.c | 2 +- drivers/net/ethernet/dec/tulip/eeprom.c | 2 +- drivers/net/ethernet/dec/tulip/interrupt.c | 2 +- drivers/net/ethernet/dec/tulip/media.c | 2 +- drivers/net/ethernet/dec/tulip/pnic.c | 2 +- drivers/net/ethernet/dec/tulip/pnic2.c | 2 +- drivers/net/ethernet/dec/tulip/timer.c | 2 +- drivers/net/ethernet/dec/tulip/tulip.h | 2 +- drivers/net/ethernet/ethoc.c | 2 +- drivers/net/ethernet/freescale/fec_mpc52xx.h | 2 +- drivers/net/ethernet/freescale/gianfar.c | 2 +- drivers/net/ethernet/freescale/gianfar.h | 2 +- drivers/net/ethernet/freescale/gianfar_ethtool.c | 2 +- drivers/net/ethernet/freescale/gianfar_sysfs.c | 2 +- drivers/net/ethernet/ibm/ehea/ehea.h | 2 +- drivers/net/ethernet/ibm/ehea/ehea_ethtool.c | 2 +- drivers/net/ethernet/ibm/ehea/ehea_hw.h | 2 +- drivers/net/ethernet/ibm/ehea/ehea_main.c | 2 +- drivers/net/ethernet/ibm/ehea/ehea_phyp.c | 2 +- drivers/net/ethernet/ibm/ehea/ehea_phyp.h | 2 +- drivers/net/ethernet/ibm/ehea/ehea_qmr.c | 2 +- drivers/net/ethernet/ibm/ehea/ehea_qmr.h | 2 +- drivers/net/ethernet/ibm/emac/core.c | 2 +- drivers/net/ethernet/ibm/emac/core.h | 2 +- drivers/net/ethernet/ibm/emac/debug.c | 2 +- drivers/net/ethernet/ibm/emac/debug.h | 2 +- drivers/net/ethernet/ibm/emac/emac.h | 2 +- drivers/net/ethernet/ibm/emac/mal.c | 2 +- drivers/net/ethernet/ibm/emac/mal.h | 2 +- drivers/net/ethernet/ibm/emac/phy.c | 2 +- drivers/net/ethernet/ibm/emac/phy.h | 2 +- drivers/net/ethernet/ibm/emac/rgmii.c | 2 +- drivers/net/ethernet/ibm/emac/rgmii.h | 2 +- drivers/net/ethernet/ibm/emac/tah.c | 2 +- drivers/net/ethernet/ibm/emac/tah.h | 2 +- drivers/net/ethernet/ibm/emac/zmii.c | 2 +- drivers/net/ethernet/ibm/emac/zmii.h | 2 +- drivers/net/ethernet/micrel/ks8851.c | 2 +- drivers/net/ethernet/micrel/ks8851.h | 2 +- drivers/net/ethernet/micrel/ks8851_mll.c | 2 +- drivers/net/ethernet/micrel/ksz884x.c | 2 +- drivers/net/ethernet/netx-eth.c | 2 +- drivers/net/ethernet/realtek/Kconfig | 10 +++++----- 54 files changed, 59 insertions(+), 58 deletions(-) diff --git a/Documentation/magic-number.txt b/Documentation/magic-number.txt index abf481f780ec..82761a31d64d 100644 --- a/Documentation/magic-number.txt +++ b/Documentation/magic-number.txt @@ -89,7 +89,7 @@ TTY_DRIVER_MAGIC 0x5402 tty_driver include/linux/tty_driver.h MGSLPC_MAGIC 0x5402 mgslpc_info drivers/char/pcmcia/synclink_cs.c TTY_LDISC_MAGIC 0x5403 tty_ldisc include/linux/tty_ldisc.h USB_SERIAL_MAGIC 0x6702 usb_serial drivers/usb/serial/usb-serial.h -FULL_DUPLEX_MAGIC 0x6969 drivers/net/tulip/de2104x.c +FULL_DUPLEX_MAGIC 0x6969 drivers/net/ethernet/dec/tulip/de2104x.c USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth drivers/usb/class/bluetty.c RFCOMM_TTY_MAGIC 0x6d02 net/bluetooth/rfcomm/tty.c USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port drivers/usb/serial/usb-serial.h diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt index 9eb1ba52013d..95e5f5985a2a 100644 --- a/Documentation/networking/phy.txt +++ b/Documentation/networking/phy.txt @@ -62,7 +62,8 @@ The MDIO bus 5) The bus must also be declared somewhere as a device, and registered. As an example for how one driver implemented an mdio bus driver, see - drivers/net/gianfar_mii.c and arch/ppc/syslib/mpc85xx_devices.c + drivers/net/ethernet/freescale/fsl_pq_mdio.c and an associated DTS file + for one of the users. (e.g. "git grep fsl,.*-mdio arch/powerpc/boot/dts/") Connecting to a PHY diff --git a/Documentation/zh_CN/magic-number.txt b/Documentation/zh_CN/magic-number.txt index c278f412dc65..f606ba8598cf 100644 --- a/Documentation/zh_CN/magic-number.txt +++ b/Documentation/zh_CN/magic-number.txt @@ -89,7 +89,7 @@ TTY_DRIVER_MAGIC 0x5402 tty_driver include/linux/tty_driver.h MGSLPC_MAGIC 0x5402 mgslpc_info drivers/char/pcmcia/synclink_cs.c TTY_LDISC_MAGIC 0x5403 tty_ldisc include/linux/tty_ldisc.h USB_SERIAL_MAGIC 0x6702 usb_serial drivers/usb/serial/usb-serial.h -FULL_DUPLEX_MAGIC 0x6969 drivers/net/tulip/de2104x.c +FULL_DUPLEX_MAGIC 0x6969 drivers/net/ethernet/dec/tulip/de2104x.c USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth drivers/usb/class/bluetty.c RFCOMM_TTY_MAGIC 0x6d02 net/bluetooth/rfcomm/tty.c USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port drivers/usb/serial/usb-serial.h diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 3f1ebcc2cb83..579e7fca6447 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -1,7 +1,7 @@ /* * slcan.c - serial line CAN interface driver (using tty line discipline) * - * This file is derived from linux/drivers/net/slip.c + * This file is derived from linux/drivers/net/slip/slip.c * * slip.c Authors : Laurence Culhane * Fred N. van Kempen diff --git a/drivers/net/ethernet/3com/Kconfig b/drivers/net/ethernet/3com/Kconfig index a8bb30cf512d..bad4fa6815c5 100644 --- a/drivers/net/ethernet/3com/Kconfig +++ b/drivers/net/ethernet/3com/Kconfig @@ -97,7 +97,7 @@ config VORTEX available from . More specific information is in and in the comments at - the beginning of . + the beginning of . To compile this support as a module, choose M here. diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c index 0f92e3567f68..c30adcc9828a 100644 --- a/drivers/net/ethernet/8390/ax88796.c +++ b/drivers/net/ethernet/8390/ax88796.c @@ -1,4 +1,4 @@ -/* drivers/net/ax88796.c +/* drivers/net/ethernet/8390/ax88796.c * * Copyright 2005,2007 Simtec Electronics * Ben Dooks diff --git a/drivers/net/ethernet/8390/axnet_cs.c b/drivers/net/ethernet/8390/axnet_cs.c index bba51cdc74a1..5de394368ff3 100644 --- a/drivers/net/ethernet/8390/axnet_cs.c +++ b/drivers/net/ethernet/8390/axnet_cs.c @@ -192,7 +192,7 @@ static int get_prom(struct pcmcia_device *link) unsigned int ioaddr = dev->base_addr; int i, j; - /* This is based on drivers/net/ne.c */ + /* This is based on drivers/net/ethernet/8390/ne.c */ struct { u_char value, offset; } program_seq[] = { diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c index 053b2551a72d..f2a4e5de18c4 100644 --- a/drivers/net/ethernet/8390/pcnet_cs.c +++ b/drivers/net/ethernet/8390/pcnet_cs.c @@ -326,7 +326,7 @@ static hw_info_t *get_prom(struct pcmcia_device *link) u_char prom[32]; int i, j; - /* This is lifted straight from drivers/net/ne.c */ + /* This is lifted straight from drivers/net/ethernet/8390/ne.c */ struct { u_char value, offset; } program_seq[] = { diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig index 238b537b68fe..8350f4b37a8a 100644 --- a/drivers/net/ethernet/amd/Kconfig +++ b/drivers/net/ethernet/amd/Kconfig @@ -113,7 +113,7 @@ config DEPCA If you have a network (Ethernet) card of this type, say Y and read the Ethernet-HOWTO, available from as well as - . + . To compile this driver as a module, choose M here. The module will be called depca. diff --git a/drivers/net/ethernet/amd/am79c961a.c b/drivers/net/ethernet/amd/am79c961a.c index 7d5ded80d2d7..216ae87b9459 100644 --- a/drivers/net/ethernet/amd/am79c961a.c +++ b/drivers/net/ethernet/amd/am79c961a.c @@ -1,5 +1,5 @@ /* - * linux/drivers/net/am79c961.c + * linux/drivers/net/ethernet/amd/am79c961a.c * * by Russell King 1995-2001. * diff --git a/drivers/net/ethernet/amd/am79c961a.h b/drivers/net/ethernet/amd/am79c961a.h index fd634d32756b..9f384b79507b 100644 --- a/drivers/net/ethernet/amd/am79c961a.h +++ b/drivers/net/ethernet/amd/am79c961a.h @@ -1,5 +1,5 @@ /* - * linux/drivers/net/arm/am79c961a.h + * linux/drivers/net/ethernet/amd/am79c961a.h * * 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 diff --git a/drivers/net/ethernet/dec/tulip/21142.c b/drivers/net/ethernet/dec/tulip/21142.c index 25b8deedbef8..369858272650 100644 --- a/drivers/net/ethernet/dec/tulip/21142.c +++ b/drivers/net/ethernet/dec/tulip/21142.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/21142.c + drivers/net/ethernet/dec/tulip/21142.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/eeprom.c b/drivers/net/ethernet/dec/tulip/eeprom.c index 14d5b611783d..ed7d1dcd9566 100644 --- a/drivers/net/ethernet/dec/tulip/eeprom.c +++ b/drivers/net/ethernet/dec/tulip/eeprom.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/eeprom.c + drivers/net/ethernet/dec/tulip/eeprom.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/interrupt.c b/drivers/net/ethernet/dec/tulip/interrupt.c index 4fb8c8c0a420..feaee7424bd9 100644 --- a/drivers/net/ethernet/dec/tulip/interrupt.c +++ b/drivers/net/ethernet/dec/tulip/interrupt.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/interrupt.c + drivers/net/ethernet/dec/tulip/interrupt.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/media.c b/drivers/net/ethernet/dec/tulip/media.c index beeb17b52ad4..ae937c6749e7 100644 --- a/drivers/net/ethernet/dec/tulip/media.c +++ b/drivers/net/ethernet/dec/tulip/media.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/media.c + drivers/net/ethernet/dec/tulip/media.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/pnic.c b/drivers/net/ethernet/dec/tulip/pnic.c index 9c16e4ad02a6..5364563c4378 100644 --- a/drivers/net/ethernet/dec/tulip/pnic.c +++ b/drivers/net/ethernet/dec/tulip/pnic.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/pnic.c + drivers/net/ethernet/dec/tulip/pnic.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/pnic2.c b/drivers/net/ethernet/dec/tulip/pnic2.c index 04a7e477eaff..5895fc43f6e0 100644 --- a/drivers/net/ethernet/dec/tulip/pnic2.c +++ b/drivers/net/ethernet/dec/tulip/pnic2.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/pnic2.c + drivers/net/ethernet/dec/tulip/pnic2.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/timer.c b/drivers/net/ethernet/dec/tulip/timer.c index 19078d28ffb9..768379b8aee9 100644 --- a/drivers/net/ethernet/dec/tulip/timer.c +++ b/drivers/net/ethernet/dec/tulip/timer.c @@ -1,5 +1,5 @@ /* - drivers/net/tulip/timer.c + drivers/net/ethernet/dec/tulip/timer.c Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/dec/tulip/tulip.h b/drivers/net/ethernet/dec/tulip/tulip.h index fb3887c18dc6..38431a155f09 100644 --- a/drivers/net/ethernet/dec/tulip/tulip.h +++ b/drivers/net/ethernet/dec/tulip/tulip.h @@ -1,5 +1,5 @@ /* - drivers/net/tulip/tulip.h + drivers/net/ethernet/dec/tulip/tulip.h Copyright 2000,2001 The Linux Kernel Team Written/copyright 1994-2001 by Donald Becker. diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 60f0e788cc25..388c592b5ef5 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ethoc.c + * linux/drivers/net/ethernet/ethoc.c * * Copyright (C) 2007-2008 Avionic Design Development GmbH * Copyright (C) 2008-2009 Avionic Design GmbH diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.h b/drivers/net/ethernet/freescale/fec_mpc52xx.h index 41d2dffde55b..10afa54dd062 100644 --- a/drivers/net/ethernet/freescale/fec_mpc52xx.h +++ b/drivers/net/ethernet/freescale/fec_mpc52xx.h @@ -1,5 +1,5 @@ /* - * drivers/drivers/net/fec_mpc52xx/fec.h + * drivers/net/ethernet/freescale/fec_mpc52xx.h * * Driver for the MPC5200 Fast Ethernet Controller * diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 39d160d353a4..adb0ae4e4195 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -1,5 +1,5 @@ /* - * drivers/net/gianfar.c + * drivers/net/ethernet/freescale/gianfar.c * * Gianfar Ethernet Driver * This driver is designed for the non-CPM ethernet controllers diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 40c33a7554c0..4fe0f342acec 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h @@ -1,5 +1,5 @@ /* - * drivers/net/gianfar.h + * drivers/net/ethernet/freescale/gianfar.h * * Gianfar Ethernet Driver * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560 diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c index 5a3b2e5b2880..5a78d55f46e7 100644 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c @@ -1,5 +1,5 @@ /* - * drivers/net/gianfar_ethtool.c + * drivers/net/ethernet/freescale/gianfar_ethtool.c * * Gianfar Ethernet Driver * Ethtool support for Gianfar Enet diff --git a/drivers/net/ethernet/freescale/gianfar_sysfs.c b/drivers/net/ethernet/freescale/gianfar_sysfs.c index 64f4094ac7f1..cd14a4d449c2 100644 --- a/drivers/net/ethernet/freescale/gianfar_sysfs.c +++ b/drivers/net/ethernet/freescale/gianfar_sysfs.c @@ -1,5 +1,5 @@ /* - * drivers/net/gianfar_sysfs.c + * drivers/net/ethernet/freescale/gianfar_sysfs.c * * Gianfar Ethernet Driver * This driver is designed for the non-CPM ethernet controllers diff --git a/drivers/net/ethernet/ibm/ehea/ehea.h b/drivers/net/ethernet/ibm/ehea/ehea.h index 6650068c996c..b8e46cc31e53 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea.h +++ b/drivers/net/ethernet/ibm/ehea/ehea.h @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea.h + * linux/drivers/net/ethernet/ibm/ehea/ehea.h * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c b/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c index 6bdd8e36e564..95837b99a464 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_ethtool.c + * linux/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_hw.h b/drivers/net/ethernet/ibm/ehea/ehea_hw.h index 1a2fe4dc3eb3..180d4128a711 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_hw.h +++ b/drivers/net/ethernet/ibm/ehea/ehea_hw.h @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_hw.h + * linux/drivers/net/ethernet/ibm/ehea/ehea_hw.h * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c index 5d5fb2627184..14507d1e78c5 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_main.c + * linux/drivers/net/ethernet/ibm/ehea/ehea_main.c * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_phyp.c b/drivers/net/ethernet/ibm/ehea/ehea_phyp.c index 0506967b9044..30f903332e92 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_phyp.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_phyp.c @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_phyp.c + * linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.c * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_phyp.h b/drivers/net/ethernet/ibm/ehea/ehea_phyp.h index 2f8174c248bc..52c456ec4d6c 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_phyp.h +++ b/drivers/net/ethernet/ibm/ehea/ehea_phyp.h @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_phyp.h + * linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.h * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c index c25b05b94daa..4fb47f14dbfe 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_qmr.c + * linux/drivers/net/ethernet/ibm/ehea/ehea_qmr.c * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/ehea/ehea_qmr.h b/drivers/net/ethernet/ibm/ehea/ehea_qmr.h index 337a47ecf4aa..8e4a70c20ab7 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_qmr.h +++ b/drivers/net/ethernet/ibm/ehea/ehea_qmr.h @@ -1,5 +1,5 @@ /* - * linux/drivers/net/ehea/ehea_qmr.h + * linux/drivers/net/ethernet/ibm/ehea/ehea_qmr.h * * eHEA ethernet device driver for IBM eServer System p * diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 2abce965c7bd..d47c16e02d00 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/core.c + * drivers/net/ethernet/ibm/emac/core.c * * Driver for PowerPC 4xx on-chip ethernet controller. * diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h index fa3ec57935fa..bade29690c71 100644 --- a/drivers/net/ethernet/ibm/emac/core.h +++ b/drivers/net/ethernet/ibm/emac/core.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/core.h + * drivers/net/ethernet/ibm/emac/core.h * * Driver for PowerPC 4xx on-chip ethernet controller. * diff --git a/drivers/net/ethernet/ibm/emac/debug.c b/drivers/net/ethernet/ibm/emac/debug.c index 8c6c1e2a8750..b16b4828b64d 100644 --- a/drivers/net/ethernet/ibm/emac/debug.c +++ b/drivers/net/ethernet/ibm/emac/debug.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/debug.c + * drivers/net/ethernet/ibm/emac/debug.c * * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. * diff --git a/drivers/net/ethernet/ibm/emac/debug.h b/drivers/net/ethernet/ibm/emac/debug.h index 90477fe69d0c..59a92d5870b5 100644 --- a/drivers/net/ethernet/ibm/emac/debug.h +++ b/drivers/net/ethernet/ibm/emac/debug.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/debug.h + * drivers/net/ethernet/ibm/emac/debug.h * * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. * diff --git a/drivers/net/ethernet/ibm/emac/emac.h b/drivers/net/ethernet/ibm/emac/emac.h index 1568278d759a..b44bd243fb58 100644 --- a/drivers/net/ethernet/ibm/emac/emac.h +++ b/drivers/net/ethernet/ibm/emac/emac.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/emac.h + * drivers/net/ethernet/ibm/emac/emac.h * * Register definitions for PowerPC 4xx on-chip ethernet contoller * diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c index f3c50b97ec61..479e43e2f1ef 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/mal.c + * drivers/net/ethernet/ibm/emac/mal.c * * Memory Access Layer (MAL) support * diff --git a/drivers/net/ethernet/ibm/emac/mal.h b/drivers/net/ethernet/ibm/emac/mal.h index d06f985bda32..e431a32e3d69 100644 --- a/drivers/net/ethernet/ibm/emac/mal.h +++ b/drivers/net/ethernet/ibm/emac/mal.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/mal.h + * drivers/net/ethernet/ibm/emac/mal.h * * Memory Access Layer (MAL) support * diff --git a/drivers/net/ethernet/ibm/emac/phy.c b/drivers/net/ethernet/ibm/emac/phy.c index ab4e5969fe65..d3b9d103353e 100644 --- a/drivers/net/ethernet/ibm/emac/phy.c +++ b/drivers/net/ethernet/ibm/emac/phy.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/phy.c + * drivers/net/ethernet/ibm/emac/phy.c * * Driver for PowerPC 4xx on-chip ethernet controller, PHY support. * Borrowed from sungem_phy.c, though I only kept the generic MII diff --git a/drivers/net/ethernet/ibm/emac/phy.h b/drivers/net/ethernet/ibm/emac/phy.h index 5d2bf4cbe50b..d7e41ec37467 100644 --- a/drivers/net/ethernet/ibm/emac/phy.h +++ b/drivers/net/ethernet/ibm/emac/phy.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/phy.h + * drivers/net/ethernet/ibm/emac/phy.h * * Driver for PowerPC 4xx on-chip ethernet controller, PHY support * diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/ibm/emac/rgmii.c index 4fa53f3def64..05484f918ee3 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/rgmii.c + * drivers/net/ethernet/ibm/emac/rgmii.c * * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. * diff --git a/drivers/net/ethernet/ibm/emac/rgmii.h b/drivers/net/ethernet/ibm/emac/rgmii.h index 9296b6c5f920..668bceeff4a2 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.h +++ b/drivers/net/ethernet/ibm/emac/rgmii.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/rgmii.h + * drivers/net/ethernet/ibm/emac/rgmii.h * * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. * diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm/emac/tah.c index 5f51bf7c9dc5..0d9881efe2ff 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/tah.c + * drivers/net/ethernet/ibm/emac/tah.c * * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. * diff --git a/drivers/net/ethernet/ibm/emac/tah.h b/drivers/net/ethernet/ibm/emac/tah.h index 3437ab4964c7..350b7096a041 100644 --- a/drivers/net/ethernet/ibm/emac/tah.h +++ b/drivers/net/ethernet/ibm/emac/tah.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/tah.h + * drivers/net/ethernet/ibm/emac/tah.h * * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. * diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ibm/emac/zmii.c index 97449e786d61..e799a6116ba5 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/zmii.c + * drivers/net/ethernet/ibm/emac/zmii.c * * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. * diff --git a/drivers/net/ethernet/ibm/emac/zmii.h b/drivers/net/ethernet/ibm/emac/zmii.h index ceaed823a83c..455bfb085493 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.h +++ b/drivers/net/ethernet/ibm/emac/zmii.h @@ -1,5 +1,5 @@ /* - * drivers/net/ibm_newemac/zmii.h + * drivers/net/ethernet/ibm/emac/zmii.h * * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. * diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 6b35e7da9a9c..134c4d07936b 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -1,4 +1,4 @@ -/* drivers/net/ks8851.c +/* drivers/net/ethernet/micrel/ks8851.c * * Copyright 2009 Simtec Electronics * http://www.simtec.co.uk/ diff --git a/drivers/net/ethernet/micrel/ks8851.h b/drivers/net/ethernet/micrel/ks8851.h index b0fae86aacad..852256ef1f22 100644 --- a/drivers/net/ethernet/micrel/ks8851.h +++ b/drivers/net/ethernet/micrel/ks8851.h @@ -1,4 +1,4 @@ -/* drivers/net/ks8851.h +/* drivers/net/ethernet/micrel/ks8851.h * * Copyright 2009 Simtec Electronics * Ben Dooks diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index e58e78e5c930..a37264e61a20 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c @@ -1,5 +1,5 @@ /** - * drivers/net/ks8851_mll.c + * drivers/net/ethernet/micrel/ks8851_mll.c * Copyright (c) 2009 Micrel Inc. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index e52cd310ae76..2725d693c3c4 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c @@ -1,5 +1,5 @@ /** - * drivers/net/ksx884x.c - Micrel KSZ8841/2 PCI Ethernet driver + * drivers/net/ethernet/micrel/ksx884x.c - Micrel KSZ8841/2 PCI Ethernet driver * * Copyright (c) 2009-2010 Micrel, Inc. * Tristram Ha diff --git a/drivers/net/ethernet/netx-eth.c b/drivers/net/ethernet/netx-eth.c index 8d288af16fc9..a18bb10b4f0c 100644 --- a/drivers/net/ethernet/netx-eth.c +++ b/drivers/net/ethernet/netx-eth.c @@ -1,5 +1,5 @@ /* - * drivers/net/netx-eth.c + * drivers/net/ethernet/netx-eth.c * * Copyright (c) 2005 Sascha Hauer , Pengutronix * diff --git a/drivers/net/ethernet/realtek/Kconfig b/drivers/net/ethernet/realtek/Kconfig index 0578859a3c73..5821966f9f28 100644 --- a/drivers/net/ethernet/realtek/Kconfig +++ b/drivers/net/ethernet/realtek/Kconfig @@ -24,11 +24,11 @@ config ATP select CRC32 ---help--- This is a network (Ethernet) device which attaches to your parallel - port. Read as well as the Ethernet-HOWTO, - available from , if you - want to use this. If you intend to use this driver, you should have - said N to the "Parallel printer support", because the two drivers - don't like each other. + port. Read as well as the + Ethernet-HOWTO, available from , + if you want to use this. If you intend to use this driver, you + should have said N to the "Parallel printer support", because the two + drivers don't like each other. To compile this driver as a module, choose M here: the module will be called atp. -- GitLab From 5e6bbedd8238edbfee03d2950369edb08773cd3c Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Fri, 27 Jan 2012 13:55:46 +0000 Subject: [PATCH 0248/1846] drivers/net: strip unused module code from sun3_82586.c This code is clearly unused, since it has a #error right in it. Given the vintage of sun3 hardware, it is probably safe to assume that there is little interest in adding new functionality to the driver now, so just delete the unused block of code. Signed-off-by: Paul Gortmaker Signed-off-by: Sam Creasey Signed-off-by: David S. Miller --- drivers/net/ethernet/i825xx/sun3_82586.c | 25 ------------------------ 1 file changed, 25 deletions(-) diff --git a/drivers/net/ethernet/i825xx/sun3_82586.c b/drivers/net/ethernet/i825xx/sun3_82586.c index 6ef5e11d1c84..296cf8a0ee51 100644 --- a/drivers/net/ethernet/i825xx/sun3_82586.c +++ b/drivers/net/ethernet/i825xx/sun3_82586.c @@ -28,7 +28,6 @@ static int automatic_resume = 0; /* experimental .. better should be zero */ static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */ static int fifo=0x8; /* don't change */ -#include #include #include #include @@ -1151,28 +1150,6 @@ static void set_multicast_list(struct net_device *dev) netif_wake_queue(dev); } -#ifdef MODULE -#error This code is not currently supported as a module -static struct net_device *dev_sun3_82586; - -int init_module(void) -{ - dev_sun3_82586 = sun3_82586_probe(-1); - if (IS_ERR(dev_sun3_82586)) - return PTR_ERR(dev_sun3_82586); - return 0; -} - -void cleanup_module(void) -{ - unsigned long ioaddr = dev_sun3_82586->base_addr; - unregister_netdev(dev_sun3_82586); - release_region(ioaddr, SUN3_82586_TOTAL_SIZE); - iounmap((void *)ioaddr); - free_netdev(dev_sun3_82586); -} -#endif /* MODULE */ - #if 0 /* * DUMP .. we expect a not running CMD unit and enough space @@ -1209,5 +1186,3 @@ void sun3_82586_dump(struct net_device *dev,void *ptr) printk("\n"); } #endif - -MODULE_LICENSE("GPL"); -- GitLab From 84920c1420e2b4a4150e5bb45ee5a23ea4641523 Mon Sep 17 00:00:00 2001 From: Tony Zelenoff Date: Thu, 26 Jan 2012 22:28:58 +0000 Subject: [PATCH 0249/1846] net: Allow ipv6 proxies and arp proxies be shown with iproute2 Add ability to return neighbour proxies list to caller if it sent full ndmsg structure and has NTF_PROXY flag set. Before this patch (and before iproute2 patches): $ ip neigh add proxy 2001::1 dev eth0 $ ip -6 neigh show $ After it and with applied iproute2 patches: $ ip neigh add proxy 2001::1 dev eth0 $ ip -6 neigh show 2001::1 dev eth0 proxy $ Compatibility with old versions of iproute2 is not broken, kernel checks for incoming structure size and properly works if old structure is came. [v2] * changed comments style. * removed useless line with continue and curly bracket. * changed incoming message size check from equal to more or equal. CC: davem@davemloft.net CC: kuznet@ms2.inr.ac.ru CC: netdev@vger.kernel.org CC: xemul@parallels.com Signed-off-by: Tony Zelenoff Acked-by: Thomas Graf Signed-off-by: David S. Miller --- net/core/neighbour.c | 90 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index e287346e0934..f98ec444133a 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -2165,6 +2165,35 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, return -EMSGSIZE; } +static int pneigh_fill_info(struct sk_buff *skb, struct pneigh_entry *pn, + u32 pid, u32 seq, int type, unsigned int flags, + struct neigh_table *tbl) +{ + struct nlmsghdr *nlh; + struct ndmsg *ndm; + + nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), flags); + if (nlh == NULL) + return -EMSGSIZE; + + ndm = nlmsg_data(nlh); + ndm->ndm_family = tbl->family; + ndm->ndm_pad1 = 0; + ndm->ndm_pad2 = 0; + ndm->ndm_flags = pn->flags | NTF_PROXY; + ndm->ndm_type = NDA_DST; + ndm->ndm_ifindex = pn->dev->ifindex; + ndm->ndm_state = NUD_NONE; + + NLA_PUT(skb, NDA_DST, tbl->key_len, pn->key); + + return nlmsg_end(skb, nlh); + +nla_put_failure: + nlmsg_cancel(skb, nlh); + return -EMSGSIZE; +} + static void neigh_update_notify(struct neighbour *neigh) { call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh); @@ -2214,23 +2243,78 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, return rc; } +static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct pneigh_entry *n; + struct net *net = sock_net(skb->sk); + int rc, h, s_h = cb->args[3]; + int idx, s_idx = idx = cb->args[4]; + + read_lock_bh(&tbl->lock); + + for (h = 0; h <= PNEIGH_HASHMASK; h++) { + if (h < s_h) + continue; + if (h > s_h) + s_idx = 0; + for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) { + if (dev_net(n->dev) != net) + continue; + if (idx < s_idx) + goto next; + if (pneigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq, + RTM_NEWNEIGH, + NLM_F_MULTI, tbl) <= 0) { + read_unlock_bh(&tbl->lock); + rc = -1; + goto out; + } + next: + idx++; + } + } + + read_unlock_bh(&tbl->lock); + rc = skb->len; +out: + cb->args[3] = h; + cb->args[4] = idx; + return rc; + +} + static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) { struct neigh_table *tbl; int t, family, s_t; + int proxy = 0; + int err = 0; read_lock(&neigh_tbl_lock); family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; + + /* check for full ndmsg structure presence, family member is + * the same for both structures + */ + if (nlmsg_len(cb->nlh) >= sizeof(struct ndmsg) && + ((struct ndmsg *) nlmsg_data(cb->nlh))->ndm_flags == NTF_PROXY) + proxy = 1; + s_t = cb->args[0]; - for (tbl = neigh_tables, t = 0; tbl; tbl = tbl->next, t++) { + for (tbl = neigh_tables, t = 0; tbl && (err >= 0); + tbl = tbl->next, t++) { if (t < s_t || (family && tbl->family != family)) continue; if (t > s_t) memset(&cb->args[1], 0, sizeof(cb->args) - sizeof(cb->args[0])); - if (neigh_dump_table(tbl, skb, cb) < 0) - break; + if (proxy) + err = pneigh_dump_table(tbl, skb, cb); + else + err = neigh_dump_table(tbl, skb, cb); } read_unlock(&neigh_tbl_lock); -- GitLab From 5de658f878d49e952d7b3f3f26a396132829f513 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 30 Jan 2012 04:29:24 +0000 Subject: [PATCH 0250/1846] ipv6: fix RFC5722 comment RFC5722 Section 4 was amended by Errata 3089 Our implementation did the right thing anyway... Signed-off-by: Eric Dumazet Cc: Nicolas Dichtel Acked-by: Nicolas Dichtel Signed-off-by: David S. Miller --- net/ipv6/reassembly.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index b69fae76a6f1..9447bd69873a 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -336,12 +336,11 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, } found: - /* RFC5722, Section 4: - * When reassembling an IPv6 datagram, if + /* RFC5722, Section 4, amended by Errata ID : 3089 + * When reassembling an IPv6 datagram, if * one or more its constituent fragments is determined to be an * overlapping fragment, the entire datagram (and any constituent - * fragments, including those not yet received) MUST be silently - * discarded. + * fragments) MUST be silently discarded. */ /* Check for overlap with preceding fragment. */ -- GitLab From 5f1127ffbae3029fde5dc1464ec3c26cdf34cb80 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 24 Jan 2012 13:50:16 +0200 Subject: [PATCH 0251/1846] ath6kl: fix testmode when fw-2.bin or fw-3.bin is used Testmode (TCMD and ART) was not enabled when fw-2.bin or fw-3.bin files were available, fix that by fetching testmode file just after the board file but before rest of the firmware files are fetched. I also added testmode field to struct ath6kl and moved the module parameter to core.c. Now all module parameters are grouped in one place. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.c | 4 ++ drivers/net/wireless/ath/ath6kl/core.h | 1 + drivers/net/wireless/ath/ath6kl/init.c | 74 ++++++++++++++++---------- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 0d92e7179f8a..2a5198185d57 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -28,11 +28,13 @@ unsigned int debug_mask; static bool suspend_cutpower; static unsigned int uart_debug; static unsigned int ath6kl_p2p; +static unsigned int testmode; module_param(debug_mask, uint, 0644); module_param(suspend_cutpower, bool, 0444); module_param(uart_debug, uint, 0644); module_param(ath6kl_p2p, uint, 0644); +module_param(testmode, uint, 0644); int ath6kl_core_init(struct ath6kl *ar) { @@ -76,6 +78,8 @@ int ath6kl_core_init(struct ath6kl *ar) goto err_power_off; } + ar->testmode = testmode; + ret = ath6kl_init_fetch_firmwares(ar); if (ret) goto err_htc_cleanup; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ed9fcc11b5fc..7f1869d00d70 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -532,6 +532,7 @@ struct ath6kl { struct wiphy *wiphy; enum ath6kl_state state; + unsigned int testmode; struct ath6kl_bmi bmi; const struct ath6kl_hif_ops *hif_ops; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 4d8eb1cca6e9..bf56e5f17618 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -27,10 +27,6 @@ #include "debug.h" #include "hif-ops.h" -static unsigned int testmode; - -module_param(testmode, uint, 0644); - static const struct ath6kl_hw hw_list[] = { { .id = AR6003_HW_2_0_VERSION, @@ -731,39 +727,54 @@ static int ath6kl_fetch_otp_file(struct ath6kl *ar) return 0; } -static int ath6kl_fetch_fw_file(struct ath6kl *ar) +static int ath6kl_fetch_testmode_file(struct ath6kl *ar) { char filename[100]; int ret; - if (ar->fw != NULL) + if (ar->testmode == 0) return 0; - if (testmode) { - ath6kl_dbg(ATH6KL_DBG_BOOT, "testmode %d\n", - testmode); - if (testmode == 2) { - if (ar->hw.fw.utf == NULL) { - ath6kl_warn("testmode 2 not supported\n"); - return -EOPNOTSUPP; - } + ath6kl_dbg(ATH6KL_DBG_BOOT, "testmode %d\n", ar->testmode); - snprintf(filename, sizeof(filename), "%s/%s", - ar->hw.fw.dir, ar->hw.fw.utf); - } else { - if (ar->hw.fw.tcmd == NULL) { - ath6kl_warn("testmode 1 not supported\n"); - return -EOPNOTSUPP; - } + if (ar->testmode == 2) { + if (ar->hw.fw.utf == NULL) { + ath6kl_warn("testmode 2 not supported\n"); + return -EOPNOTSUPP; + } - snprintf(filename, sizeof(filename), "%s/%s", - ar->hw.fw.dir, ar->hw.fw.tcmd); + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.utf); + } else { + if (ar->hw.fw.tcmd == NULL) { + ath6kl_warn("testmode 1 not supported\n"); + return -EOPNOTSUPP; } - set_bit(TESTMODE, &ar->flag); - goto get_fw; + snprintf(filename, sizeof(filename), "%s/%s", + ar->hw.fw.dir, ar->hw.fw.tcmd); } + set_bit(TESTMODE, &ar->flag); + + ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len); + if (ret) { + ath6kl_err("Failed to get testmode %d firmware file %s: %d\n", + ar->testmode, filename, ret); + return ret; + } + + return 0; +} + +static int ath6kl_fetch_fw_file(struct ath6kl *ar) +{ + char filename[100]; + int ret; + + if (ar->fw != NULL) + return 0; + /* FIXME: remove WARN_ON() as we won't support FW API 1 for long */ if (WARN_ON(ar->hw.fw.fw == NULL)) return -EINVAL; @@ -771,7 +782,6 @@ static int ath6kl_fetch_fw_file(struct ath6kl *ar) snprintf(filename, sizeof(filename), "%s/%s", ar->hw.fw.dir, ar->hw.fw.fw); -get_fw: ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len); if (ret) { ath6kl_err("Failed to get firmware file %s: %d\n", @@ -812,7 +822,7 @@ static int ath6kl_fetch_testscript_file(struct ath6kl *ar) char filename[100]; int ret; - if (testmode != 2) + if (ar->testmode != 2) return 0; if (ar->fw_testscript != NULL) @@ -927,6 +937,10 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name) ath6kl_dbg(ATH6KL_DBG_BOOT, "found fw image ie (%zd B)\n", ie_len); + /* in testmode we already might have a fw file */ + if (ar->fw != NULL) + break; + ar->fw = kmemdup(data, ie_len, GFP_KERNEL); if (ar->fw == NULL) { @@ -1038,6 +1052,10 @@ int ath6kl_init_fetch_firmwares(struct ath6kl *ar) if (ret) return ret; + ret = ath6kl_fetch_testmode_file(ar); + if (ret) + return ret; + ret = ath6kl_fetch_fw_apin(ar, ATH6KL_FW_API3_FILE); if (ret == 0) { ar->fw_api = 3; @@ -1283,7 +1301,7 @@ static int ath6kl_upload_testscript(struct ath6kl *ar) u32 address, param; int ret; - if (testmode != 2) + if (ar->testmode != 2) return 0; if (ar->fw_testscript == NULL) -- GitLab From c86515412f0c364f2d45029b45d5909614087af3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Thu, 26 Jan 2012 13:17:18 +0530 Subject: [PATCH 0252/1846] ath6kl: Fix kernel panic during rx aggregation "ath6kl: Define a structure for connection specific aggregation information" introduces this. In aggr_conn_init(), vif->aggr_cntxt is assigned to aggr_conn->aggr_info, but vif->aggr_cntxt is not initialized at this point, this would end up accessing an invalid pointer in aggregation receive path. Fix this by passing the correct aggr_info to aggr_conn_init(). The panic trace would look like. [] panic+0xa1/0x1c6 [] ? kmsg_dump+0xfd/0x160 [] oops_end+0xea/0xf0 [] no_context+0x11d/0x2d0 [] __bad_area_nosemaphore+0x14d/0x230 [] ? do_page_fault+0x30d/0x520 [] bad_area_nosemaphore+0x13/0x20 [] do_page_fault+0x3bd/0x520 [] ? __lock_acquire+0x320/0x1680 [] ? trace_hardirqs_off_thunk+0x3a/0x3c [] page_fault+0x25/0x30 [] ? aggr_slice_amsdu+0xdf/0x170 [ath6kl_core] [] aggr_deque_frms+0xbc/0x190 [ath6kl_core] [] ath6kl_rx+0x3e4/0xae0 [ath6kl_core] [] ath6kl_htc_rxmsg_pending_handler+0x8b7/0xf10 [ath6kl_core] [] ? mmc_do_release_host+0x70/0x90 [mmc_core] [] ? mmc_release_host+0x2a/0x50 [mmc_core] [] ? ath6kl_alloc_amsdu_rxbuf+0x140/0x140 [ath6kl_core] [] ath6kl_hif_intr_bh_handler+0x362/0x510 [ath6kl_core] [] ath6kl_sdio_irq_handler+0x60/0xb0 [ath6kl_sdio] [] sdio_irq_thread+0xec/0x320 [mmc_core] [] ? sdio_claim_irq+0x220/0x220 [mmc_core] [] ? sdio_claim_irq+0x220/0x220 [mmc_core] [] kthread+0xbe/0xd0 [] kernel_thread_helper+0x4/0x10 [] ? retint_restore_args+0x13/0x13 [] ? __init_kthread_worker+0x70/0x70 [] ? gs_change+0x13/0x13 Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 3 ++- drivers/net/wireless/ath/ath6kl/main.c | 2 +- drivers/net/wireless/ath/ath6kl/txrx.c | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 7f1869d00d70..426f269e8ab0 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -715,7 +715,8 @@ void ath6kl_free_cookie(struct ath6kl *ar, struct ath6kl_cookie *cookie); int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev); struct aggr_info *aggr_init(struct ath6kl_vif *vif); -void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info_conn *aggr_conn); +void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info *aggr_info, + struct aggr_info_conn *aggr_conn); void ath6kl_rx_refill(struct htc_target *target, enum htc_endpoint_id endpoint); void ath6kl_refill_amsdu_rxbufs(struct ath6kl *ar, int count); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 39da1f98da87..b96d01a7919b 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -74,7 +74,7 @@ static void ath6kl_add_new_sta(struct ath6kl_vif *vif, u8 *mac, u16 aid, ar->sta_list_index = ar->sta_list_index | (1 << free_slot); ar->ap_stats.sta[free_slot].aid = cpu_to_le32(aid); - aggr_conn_init(vif, sta->aggr_conn); + aggr_conn_init(vif, vif->aggr_cntxt, sta->aggr_conn); } static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 62c12102e146..a3dc6943c7f7 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1674,7 +1674,8 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no, rxtid->aggr = true; } -void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info_conn *aggr_conn) +void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info *aggr_info, + struct aggr_info_conn *aggr_conn) { struct rxtid *rxtid; u8 i; @@ -1684,7 +1685,7 @@ void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info_conn *aggr_conn) init_timer(&aggr_conn->timer); aggr_conn->timer.function = aggr_timeout; aggr_conn->timer.data = (unsigned long) aggr_conn; - aggr_conn->aggr_info = vif->aggr_cntxt; + aggr_conn->aggr_info = aggr_info; aggr_conn->timer_scheduled = false; @@ -1716,7 +1717,7 @@ struct aggr_info *aggr_init(struct ath6kl_vif *vif) return NULL; } - aggr_conn_init(vif, p_aggr->aggr_conn); + aggr_conn_init(vif, p_aggr, p_aggr->aggr_conn); skb_queue_head_init(&p_aggr->rx_amsdu_freeq); ath6kl_alloc_netbufs(&p_aggr->rx_amsdu_freeq, AGGR_NUM_OF_FREE_NETBUFS); -- GitLab From e390af779dc671551800514d391928f5a798089a Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 30 Jan 2012 17:13:09 +0530 Subject: [PATCH 0253/1846] ath6kl: Re-architect suspend mode handling in ath6kl_sdio_suspend Using this patch, the user can bypass existing auto suspend mode selection logic and force ath6kl to enter into the suspend mode what he/she wants. If the user doesn't choose any suspend mode while doing insmod of the driver, auto suspend mode selection logic will kick in and choose suspend mode based on the host SDIO controller capability. Generic module parameter is required to specify suspend mode including Deep Sleep and WOW while doing insmod. Renaming existing mod param variable suspend_cutpower would be sufficient to meet this requirement. New module parameter suspend_mode can take any one of the below suspend state, 1. cut power 2. deep sleep 3. wow Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.c | 12 ++-- drivers/net/wireless/ath/ath6kl/core.h | 4 +- drivers/net/wireless/ath/ath6kl/sdio.c | 86 ++++++++++++++++---------- 3 files changed, 64 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 2a5198185d57..722ca59b88ce 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -25,13 +25,13 @@ #include "cfg80211.h" unsigned int debug_mask; -static bool suspend_cutpower; +static unsigned int suspend_mode; static unsigned int uart_debug; static unsigned int ath6kl_p2p; static unsigned int testmode; module_param(debug_mask, uint, 0644); -module_param(suspend_cutpower, bool, 0444); +module_param(suspend_mode, uint, 0644); module_param(uart_debug, uint, 0644); module_param(ath6kl_p2p, uint, 0644); module_param(testmode, uint, 0644); @@ -147,8 +147,12 @@ int ath6kl_core_init(struct ath6kl *ar) ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; - if (suspend_cutpower) - ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER; + if (suspend_mode && + suspend_mode >= WLAN_POWER_STATE_CUT_PWR && + suspend_mode <= WLAN_POWER_STATE_WOW) + ar->suspend_mode = suspend_mode; + else + ar->suspend_mode = 0; if (uart_debug) ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 426f269e8ab0..ce572c04b924 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -196,8 +196,7 @@ struct ath6kl_fw_ie { #define ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN BIT(1) #define ATH6KL_CONF_ENABLE_11N BIT(2) #define ATH6KL_CONF_ENABLE_TX_BURST BIT(3) -#define ATH6KL_CONF_SUSPEND_CUTPOWER BIT(4) -#define ATH6KL_CONF_UART_DEBUG BIT(5) +#define ATH6KL_CONF_UART_DEBUG BIT(4) enum wlan_low_pwr_state { WLAN_POWER_STATE_ON, @@ -619,6 +618,7 @@ struct ath6kl { } hw; u16 conf_flags; + u16 suspend_mode; wait_queue_head_t event_wq; struct ath6kl_mbox_info mbox_info; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index d9f55914b893..07dcf00ca1a7 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -779,7 +779,7 @@ static int ath6kl_sdio_config(struct ath6kl *ar) return ret; } -static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) +static int ath6kl_set_sdio_pm_caps(struct ath6kl *ar) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct sdio_func *func = ar_sdio->func; @@ -790,60 +790,82 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio suspend pm_caps 0x%x\n", flags); - if (!(flags & MMC_PM_KEEP_POWER) || - (ar->conf_flags & ATH6KL_CONF_SUSPEND_CUTPOWER)) { - /* as host doesn't support keep power we need to cut power */ - return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, - NULL); - } + if (!(flags & MMC_PM_WAKE_SDIO_IRQ) || + !(flags & MMC_PM_KEEP_POWER)) + return -EINVAL; ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); if (ret) { - printk(KERN_ERR "ath6kl: set sdio pm flags failed: %d\n", - ret); + ath6kl_err("set sdio keep pwr flag failed: %d\n", ret); return ret; } - if (!(flags & MMC_PM_WAKE_SDIO_IRQ)) - goto deepsleep; - /* sdio irq wakes up host */ + ret = sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ); + if (ret) + ath6kl_err("set sdio wake irq flag failed: %d\n", ret); + + return ret; +} + +static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) +{ + struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); + struct sdio_func *func = ar_sdio->func; + mmc_pm_flag_t flags; + int ret; if (ar->state == ATH6KL_STATE_SCHED_SCAN) { + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sched scan is in progress\n"); + + ret = ath6kl_set_sdio_pm_caps(ar); + if (ret) + goto cut_pwr; + ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_SCHED_SCAN, NULL); - if (ret) { - ath6kl_warn("Schedule scan suspend failed: %d", ret); - return ret; - } - - ret = sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ); if (ret) - ath6kl_warn("set sdio wake irq flag failed: %d\n", ret); + goto cut_pwr; - return ret; + return 0; } - if (wow) { - /* - * The host sdio controller is capable of keep power and - * sdio irq wake up at this point. It's fine to continue - * wow suspend operation. - */ + if (ar->suspend_mode == WLAN_POWER_STATE_WOW || + (!ar->suspend_mode && wow)) { + + ret = ath6kl_set_sdio_pm_caps(ar); + if (ret) + goto cut_pwr; + ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_WOW, wow); if (ret) - return ret; + goto cut_pwr; + + return 0; + } + + if (ar->suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP || + !ar->suspend_mode) { - ret = sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ); + flags = sdio_get_host_pm_caps(func); + if (!(flags & MMC_PM_KEEP_POWER)) + goto cut_pwr; + + ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); if (ret) - ath6kl_err("set sdio wake irq flag failed: %d\n", ret); + goto cut_pwr; - return ret; + ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP, + NULL); + if (ret) + goto cut_pwr; + + return 0; } -deepsleep: - return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP, NULL); +cut_pwr: + return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, NULL); } static int ath6kl_sdio_resume(struct ath6kl *ar) -- GitLab From d91e8eee046e0d4ae7a8a585616b5ce800f54568 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 30 Jan 2012 17:13:10 +0530 Subject: [PATCH 0254/1846] ath6kl: Configure WOW patterns while going to wow_suspend First preference is given to the user configured WOW patterns. If the user doesn't configure any patterns (for ex, via iw command), the default patterns will be configured based on the current mode (vif->nw_type) while going to WOW suspend. Summary of changes: * ath6kl_wow_ap() is added to configure the below default patterns when the system enters into WOW suspend in AP mode. + Unicast IP, EAPOL-like and ARP packet pattern + ARP packet pattern + mDNS/SSDP/LLMNR pattern + DHCP broadcast pattern * ath6kl_wow_sta() is added to configure the below default patterns when the system enters into WOW suspend in STA mode. + Unicast packet pattern + mDNS/SSDP/LLMNR pattern * Move the user provided WOW patterns configuration code from ath6kl_wow_suspend() to a separate function called ath6kl_wow_usr(). * Two argument variable's ('filter' and 'mask) data type in ath6kl_wmi_add_wow_pattern_cmd() are changed from 'u8 *' to 'const u8 *'. This is needed to make all pattern and mask arrays to be 'static const u8' in the caller function. * New conditional check is added to make sure user configured pattern count is within the limit (WOW_MAX_FILTERS_PER_LIST). Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 231 +++++++++++++++++---- drivers/net/wireless/ath/ath6kl/wmi.c | 3 +- drivers/net/wireless/ath/ath6kl/wmi.h | 3 +- 3 files changed, 193 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index fed7b8077f5e..e676cfccedfe 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1723,32 +1723,14 @@ static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) return 0; } -static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) +static int ath6kl_wow_usr(struct ath6kl *ar, struct ath6kl_vif *vif, + struct cfg80211_wowlan *wow, u32 *filter) { - struct in_device *in_dev; - struct in_ifaddr *ifa; - struct ath6kl_vif *vif; - int ret, pos, left; - u32 filter = 0; + int ret, pos; + u8 mask[WOW_MASK_SIZE]; u16 i; - u8 mask[WOW_MASK_SIZE], index = 0; - __be32 ips[MAX_IP_ADDRS]; - - vif = ath6kl_vif_first(ar); - if (!vif) - return -EIO; - - if (!ath6kl_cfg80211_ready(vif)) - return -EIO; - - if (!test_bit(CONNECTED, &vif->flags)) - return -EINVAL; - /* Clear existing WOW patterns */ - for (i = 0; i < WOW_MAX_FILTERS_PER_LIST; i++) - ath6kl_wmi_del_wow_pattern_cmd(ar->wmi, vif->fw_vif_idx, - WOW_LIST_ID, i); - /* Configure new WOW patterns */ + /* Configure the patterns that we received from the user. */ for (i = 0; i < wow->n_patterns; i++) { /* @@ -1771,14 +1753,194 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) * matched from the first byte of received pkt in the firmware. */ ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, - vif->fw_vif_idx, WOW_LIST_ID, - wow->patterns[i].pattern_len, - 0 /* pattern offset */, - wow->patterns[i].pattern, mask); + vif->fw_vif_idx, WOW_LIST_ID, + wow->patterns[i].pattern_len, + 0 /* pattern offset */, + wow->patterns[i].pattern, mask); if (ret) return ret; } + if (wow->disconnect) + *filter |= WOW_FILTER_OPTION_NWK_DISASSOC; + + if (wow->magic_pkt) + *filter |= WOW_FILTER_OPTION_MAGIC_PACKET; + + if (wow->gtk_rekey_failure) + *filter |= WOW_FILTER_OPTION_GTK_ERROR; + + if (wow->eap_identity_req) + *filter |= WOW_FILTER_OPTION_EAP_REQ; + + if (wow->four_way_handshake) + *filter |= WOW_FILTER_OPTION_8021X_4WAYHS; + + return 0; +} + +static int ath6kl_wow_ap(struct ath6kl *ar, struct ath6kl_vif *vif) +{ + static const u8 unicst_pattern[] = { 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08 }; + static const u8 unicst_mask[] = { 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f }; + u8 unicst_offset = 0; + static const u8 arp_pattern[] = { 0x08, 0x06 }; + static const u8 arp_mask[] = { 0xff, 0xff }; + u8 arp_offset = 20; + static const u8 discvr_pattern[] = { 0xe0, 0x00, 0x00, 0xf8 }; + static const u8 discvr_mask[] = { 0xf0, 0x00, 0x00, 0xf8 }; + u8 discvr_offset = 38; + static const u8 dhcp_pattern[] = { 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x43 /* port 67 */ }; + static const u8 dhcp_mask[] = { 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff /* port 67 */ }; + u8 dhcp_offset = 0; + int ret; + + /* Setup unicast IP, EAPOL-like and ARP pkt pattern */ + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + sizeof(unicst_pattern), unicst_offset, + unicst_pattern, unicst_mask); + if (ret) { + ath6kl_err("failed to add WOW unicast IP pattern\n"); + return ret; + } + + /* Setup all ARP pkt pattern */ + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + sizeof(arp_pattern), arp_offset, + arp_pattern, arp_mask); + if (ret) { + ath6kl_err("failed to add WOW ARP pattern\n"); + return ret; + } + + /* + * Setup multicast pattern for mDNS 224.0.0.251, + * SSDP 239.255.255.250 and LLMNR 224.0.0.252 + */ + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + sizeof(discvr_pattern), discvr_offset, + discvr_pattern, discvr_mask); + if (ret) { + ath6kl_err("failed to add WOW mDNS/SSDP/LLMNR pattern\n"); + return ret; + } + + /* Setup all DHCP broadcast pkt pattern */ + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + sizeof(dhcp_pattern), dhcp_offset, + dhcp_pattern, dhcp_mask); + if (ret) { + ath6kl_err("failed to add WOW DHCP broadcast pattern\n"); + return ret; + } + + return 0; +} + +static int ath6kl_wow_sta(struct ath6kl *ar, struct ath6kl_vif *vif) +{ + struct net_device *ndev = vif->ndev; + static const u8 discvr_pattern[] = { 0xe0, 0x00, 0x00, 0xf8 }; + static const u8 discvr_mask[] = { 0xf0, 0x00, 0x00, 0xf8 }; + u8 discvr_offset = 38; + u8 mac_mask[ETH_ALEN]; + int ret; + + /* Setup unicast pkt pattern */ + memset(mac_mask, 0xff, ETH_ALEN); + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + ETH_ALEN, 0, ndev->dev_addr, + mac_mask); + if (ret) { + ath6kl_err("failed to add WOW unicast pattern\n"); + return ret; + } + + /* + * Setup multicast pattern for mDNS 224.0.0.251, + * SSDP 239.255.255.250 and LLMNR 224.0.0.252 + */ + if ((ndev->flags & IFF_ALLMULTI) || + (ndev->flags & IFF_MULTICAST && netdev_mc_count(ndev) > 0)) { + ret = ath6kl_wmi_add_wow_pattern_cmd(ar->wmi, + vif->fw_vif_idx, WOW_LIST_ID, + sizeof(discvr_pattern), discvr_offset, + discvr_pattern, discvr_mask); + if (ret) { + ath6kl_err("failed to add WOW mDNS/SSDP/LLMNR " + "pattern\n"); + return ret; + } + } + + return 0; +} + +static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) +{ + struct in_device *in_dev; + struct in_ifaddr *ifa; + struct ath6kl_vif *vif; + int ret, left; + u32 filter = 0; + u16 i; + u8 index = 0; + __be32 ips[MAX_IP_ADDRS]; + + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + if (!ath6kl_cfg80211_ready(vif)) + return -EIO; + + if (!test_bit(CONNECTED, &vif->flags)) + return -EINVAL; + + if (wow && (wow->n_patterns > WOW_MAX_FILTERS_PER_LIST)) + return -EINVAL; + + /* Clear existing WOW patterns */ + for (i = 0; i < WOW_MAX_FILTERS_PER_LIST; i++) + ath6kl_wmi_del_wow_pattern_cmd(ar->wmi, vif->fw_vif_idx, + WOW_LIST_ID, i); + + /* + * Skip the default WOW pattern configuration + * if the driver receives any WOW patterns from + * the user. + */ + if (wow) + ret = ath6kl_wow_usr(ar, vif, wow, &filter); + else if (vif->nw_type == AP_NETWORK) + ret = ath6kl_wow_ap(ar, vif); + else + ret = ath6kl_wow_sta(ar, vif); + + if (ret) + return ret; + /* Setup own IP addr for ARP agent. */ in_dev = __in_dev_get_rtnl(vif->ndev); if (!in_dev) @@ -1806,21 +1968,6 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) } skip_arp: - if (wow->disconnect) - filter |= WOW_FILTER_OPTION_NWK_DISASSOC; - - if (wow->magic_pkt) - filter |= WOW_FILTER_OPTION_MAGIC_PACKET; - - if (wow->gtk_rekey_failure) - filter |= WOW_FILTER_OPTION_GTK_ERROR; - - if (wow->eap_identity_req) - filter |= WOW_FILTER_OPTION_EAP_REQ; - - if (wow->four_way_handshake) - filter |= WOW_FILTER_OPTION_8021X_4WAYHS; - ret = ath6kl_wmi_set_wow_mode_cmd(ar->wmi, vif->fw_vif_idx, ATH6KL_WOW_MODE_ENABLE, filter, diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 5d678bf372d3..9c8e4dfbfa0c 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2620,7 +2620,8 @@ int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, u8 list_id, u8 filter_size, - u8 filter_offset, u8 *filter, u8 *mask) + u8 filter_offset, const u8 *filter, + const u8 *mask) { struct sk_buff *skb; struct wmi_add_wow_pattern_cmd *cmd; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 48e9d2641d69..85698ef2dd88 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2461,7 +2461,8 @@ int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, u32 filter, u16 host_req_delay); int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, u8 list_id, u8 filter_size, - u8 filter_offset, u8 *filter, u8 *mask); + u8 filter_offset, const u8 *filter, + const u8 *mask); int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, u16 list_id, u16 filter_id); int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi); -- GitLab From 081c7a84e969453716e2a7bd315417067c3643ad Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 30 Jan 2012 17:13:11 +0530 Subject: [PATCH 0255/1846] ath6kl: Wait for host sleep mode cmd processed event during WOW suspend For every WMI_SET_HOST_SLEEP_MODE_CMDID command (send from the host), the firmware sends WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID as an acknowledgement to the host. In order to being sync with the firmware, the host has to wait for WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENT event before going to the suspend state. This patch ensures ath6kl_wow_suspend() waits until it gets this event after sending set host sleep mode command. This patch adds, * New command WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID in WMI event table. * New WMI function ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx() to process the event. * New flag HOST_SLEEP_MODE_CMD_PROCESSED in VIF flags to record the arrival of the event. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 15 +++++++++++++++ drivers/net/wireless/ath/ath6kl/core.h | 1 + drivers/net/wireless/ath/ath6kl/wmi.c | 17 +++++++++++++++++ drivers/net/wireless/ath/ath6kl/wmi.h | 2 ++ 4 files changed, 35 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index e676cfccedfe..1902e2fa1a68 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1975,11 +1975,26 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) if (ret) return ret; + clear_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags); + ret = ath6kl_wmi_set_host_sleep_mode_cmd(ar->wmi, vif->fw_vif_idx, ATH6KL_HOST_MODE_ASLEEP); if (ret) return ret; + left = wait_event_interruptible_timeout(ar->event_wq, + test_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags), + WMI_TIMEOUT); + if (left == 0) { + ath6kl_warn("timeout, didn't get host sleep cmd " + "processed event\n"); + ret = -ETIMEDOUT; + } else if (left < 0) { + ath6kl_warn("error while waiting for host sleep cmd " + "processed event %d\n", left); + ret = left; + } + if (ar->tx_pending[ar->ctrl_ep]) { left = wait_event_interruptible_timeout(ar->event_wq, ar->tx_pending[ar->ctrl_ep] == 0, WMI_TIMEOUT); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ce572c04b924..c4d66e066dc9 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -451,6 +451,7 @@ enum ath6kl_vif_state { DTIM_PERIOD_AVAIL, WLAN_ENABLED, STATS_UPDATE_PEND, + HOST_SLEEP_MODE_CMD_PROCESSED, }; struct ath6kl_vif { diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 9c8e4dfbfa0c..18fa9aa8af92 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2590,6 +2590,18 @@ int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, return ret; } +/* This command has zero length payload */ +static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi, + struct ath6kl_vif *vif) +{ + struct ath6kl *ar = wmi->parent_dev; + + set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags); + wake_up(&ar->event_wq); + + return 0; +} + int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, enum ath6kl_wow_mode wow_mode, u32 filter, u16 host_req_delay) @@ -3556,6 +3568,11 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); ret = ath6kl_wmi_tx_complete_event_rx(datap, len); break; + case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, + "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID"); + ret = ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif); + break; case WMI_REMAIN_ON_CHNL_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 85698ef2dd88..e7919869725e 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1357,6 +1357,8 @@ enum wmi_event_id { WMI_P2P_START_SDPD_EVENTID, WMI_P2P_SDPD_RX_EVENTID, + WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID = 0x1047, + WMI_THIN_RESERVED_START_EVENTID = 0x8000, /* Events in this range are reserved for thinmode */ WMI_THIN_RESERVED_END_EVENTID = 0x8fff, -- GitLab From 3c411a434414f4320ce926bee3733e34ba0ea407 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 30 Jan 2012 17:13:12 +0530 Subject: [PATCH 0256/1846] ath6kl: Return a proper error code when not in connected state Error code ENOTCONN is more suitable than EINVAL to report when the driver is not in connected state in ath6kl_wow_suspend(). I found this during code review. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 1902e2fa1a68..5934e40ee55d 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1916,7 +1916,7 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) return -EIO; if (!test_bit(CONNECTED, &vif->flags)) - return -EINVAL; + return -ENOTCONN; if (wow && (wow->n_patterns > WOW_MAX_FILTERS_PER_LIST)) return -EINVAL; -- GitLab From a46621a3a8f24557201a7ef62de151c812f8985c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 30 Jan 2012 15:22:06 -0500 Subject: [PATCH 0257/1846] net: Deinline __nlmsg_put and genlmsg_put. -7k code on i386 defconfig. text data bss dec hex filename 8455963 532732 1810804 10799499 a4c98b vmlinux.o.before 8448899 532732 1810804 10792435 a4adf3 vmlinux.o This change also removes commented-out copy of __nlmsg_put which was last touched in 2005 with "Enable once all users have been converted" comment on top. Changes in v2: rediffed against net-next. Signed-off-by: Denys Vlasenko Signed-off-by: David S. Miller --- include/linux/netlink.h | 18 ++---------------- include/net/genetlink.h | 31 ++----------------------------- include/net/netlink.h | 35 ----------------------------------- net/netlink/af_netlink.c | 18 ++++++++++++++++++ net/netlink/genetlink.c | 31 +++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 80 deletions(-) diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 52e48959cfa1..a390e9d54827 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -237,22 +237,8 @@ struct netlink_notify { int protocol; }; -static __inline__ struct nlmsghdr * -__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) -{ - struct nlmsghdr *nlh; - int size = NLMSG_LENGTH(len); - - nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size)); - nlh->nlmsg_type = type; - nlh->nlmsg_len = size; - nlh->nlmsg_flags = flags; - nlh->nlmsg_pid = pid; - nlh->nlmsg_seq = seq; - if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) - memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); - return nlh; -} +struct nlmsghdr * +__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags); #define NLMSG_NEW(skb, pid, seq, type, len, flags) \ ({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \ diff --git a/include/net/genetlink.h b/include/net/genetlink.h index 7db32995ccd3..ccb68880abf5 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h @@ -131,35 +131,8 @@ extern void genl_unregister_mc_group(struct genl_family *family, extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, struct nlmsghdr *nlh, gfp_t flags); -/** - * genlmsg_put - Add generic netlink header to netlink message - * @skb: socket buffer holding the message - * @pid: netlink pid the message is addressed to - * @seq: sequence number (usually the one of the sender) - * @family: generic netlink family - * @flags netlink message flags - * @cmd: generic netlink command - * - * Returns pointer to user specific header - */ -static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, - struct genl_family *family, int flags, u8 cmd) -{ - struct nlmsghdr *nlh; - struct genlmsghdr *hdr; - - nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + - family->hdrsize, flags); - if (nlh == NULL) - return NULL; - - hdr = nlmsg_data(nlh); - hdr->cmd = cmd; - hdr->version = family->version; - hdr->reserved = 0; - - return (char *) hdr + GENL_HDRLEN; -} +void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, + struct genl_family *family, int flags, u8 cmd); /** * genlmsg_nlhdr - Obtain netlink header from user specified header diff --git a/include/net/netlink.h b/include/net/netlink.h index cb1f3504687f..f394fe5d7641 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -441,41 +441,6 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh) nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ nlmsg_attrlen(nlh, hdrlen), rem) -#if 0 -/* FIXME: Enable once all users have been converted */ - -/** - * __nlmsg_put - Add a new netlink message to an skb - * @skb: socket buffer to store message in - * @pid: netlink process id - * @seq: sequence number of message - * @type: message type - * @payload: length of message payload - * @flags: message flags - * - * The caller is responsible to ensure that the skb provides enough - * tailroom for both the netlink header and payload. - */ -static inline struct nlmsghdr *__nlmsg_put(struct sk_buff *skb, u32 pid, - u32 seq, int type, int payload, - int flags) -{ - struct nlmsghdr *nlh; - - nlh = (struct nlmsghdr *) skb_put(skb, nlmsg_total_size(payload)); - nlh->nlmsg_type = type; - nlh->nlmsg_len = nlmsg_msg_size(payload); - nlh->nlmsg_flags = flags; - nlh->nlmsg_pid = pid; - nlh->nlmsg_seq = seq; - - memset((unsigned char *) nlmsg_data(nlh) + payload, 0, - nlmsg_padlen(payload)); - - return nlh; -} -#endif - /** * nlmsg_put - Add a new netlink message to an skb * @skb: socket buffer to store message in diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 629b06182f3f..4d751e3d4b4b 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1645,6 +1645,24 @@ static void netlink_destroy_callback(struct netlink_callback *cb) kfree(cb); } +struct nlmsghdr * +__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) +{ + struct nlmsghdr *nlh; + int size = NLMSG_LENGTH(len); + + nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size)); + nlh->nlmsg_type = type; + nlh->nlmsg_len = size; + nlh->nlmsg_flags = flags; + nlh->nlmsg_pid = pid; + nlh->nlmsg_seq = seq; + if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) + memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); + return nlh; +} +EXPORT_SYMBOL(__nlmsg_put); + /* * It looks a bit ugly. * It would be better to create kernel thread. diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index c29d2568c9e0..a1154717219e 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -498,6 +498,37 @@ int genl_unregister_family(struct genl_family *family) } EXPORT_SYMBOL(genl_unregister_family); +/** + * genlmsg_put - Add generic netlink header to netlink message + * @skb: socket buffer holding the message + * @pid: netlink pid the message is addressed to + * @seq: sequence number (usually the one of the sender) + * @family: generic netlink family + * @flags netlink message flags + * @cmd: generic netlink command + * + * Returns pointer to user specific header + */ +void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, + struct genl_family *family, int flags, u8 cmd) +{ + struct nlmsghdr *nlh; + struct genlmsghdr *hdr; + + nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + + family->hdrsize, flags); + if (nlh == NULL) + return NULL; + + hdr = nlmsg_data(nlh); + hdr->cmd = cmd; + hdr->version = family->version; + hdr->reserved = 0; + + return (char *) hdr + GENL_HDRLEN; +} +EXPORT_SYMBOL(genlmsg_put); + static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) { struct genl_ops *ops; -- GitLab From c037b8367c7e2b775a99d74037f5df014d2fbf06 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Mon, 30 Jan 2012 15:28:11 -0500 Subject: [PATCH 0258/1846] Revert "mac80211: Do not scan for IBSS merge with a fixed BSSID." This reverts commit f1e3be1561c43b6bbe2426e34849fb1486dc313b. Johannes Berg thinks that this patch is incorrect. I'll defer to his judgment. Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 93b3c7298be3..d38baa41cf6c 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -655,15 +655,14 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) if (ieee80211_sta_active_ibss(sdata)) return; - if (ifibss->fixed_bssid) + if (ifibss->fixed_channel) return; printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n", sdata->name); ieee80211_request_internal_scan(sdata, - ifibss->ssid, ifibss->ssid_len, - ifibss->fixed_channel ? ifibss->channel : NULL); + ifibss->ssid, ifibss->ssid_len, NULL); } static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) -- GitLab From 83d5cc012441531ab0bf6f99881958e964e9cf11 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 12 Jan 2012 09:31:10 +0100 Subject: [PATCH 0259/1846] mac80211: station state transition error handling In the future, when we start notifying drivers, state transitions could potentially fail. To make it easier to distinguish between programming bugs and driver failures: * rename sta_info_move_state() to sta_info_pre_move_state() which can only be called before the station is inserted (and check this with a new station flag). * rename sta_info_move_state_checked() to just plain sta_info_move_state(), as it will be the regular function that can fail for more than just one reason (bad transition or an error from the driver) This makes the programming model easier -- one of the functions can only be called before insertion and can't fail, the other can fail. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/cfg.c | 22 ++++++++-------------- net/mac80211/debugfs_sta.c | 5 +++-- net/mac80211/ibss.c | 6 +++--- net/mac80211/iface.c | 6 +++--- net/mac80211/mesh_plink.c | 6 +++--- net/mac80211/mlme.c | 17 +++++++++++++---- net/mac80211/sta_info.c | 19 ++++++++++++++----- net/mac80211/sta_info.h | 17 ++++++++++++----- 8 files changed, 59 insertions(+), 39 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 98460783c2d3..dc7420441574 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -776,12 +776,10 @@ static int sta_apply_parameters(struct ieee80211_local *local, if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && !test_sta_flag(sta, WLAN_STA_AUTH)) { - ret = sta_info_move_state_checked(sta, - IEEE80211_STA_AUTH); + ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); if (ret) return ret; - ret = sta_info_move_state_checked(sta, - IEEE80211_STA_ASSOC); + ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); if (ret) return ret; } @@ -789,11 +787,9 @@ static int sta_apply_parameters(struct ieee80211_local *local, if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) - ret = sta_info_move_state_checked(sta, - IEEE80211_STA_AUTHORIZED); + ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) - ret = sta_info_move_state_checked(sta, - IEEE80211_STA_ASSOC); + ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); if (ret) return ret; } @@ -805,12 +801,10 @@ static int sta_apply_parameters(struct ieee80211_local *local, if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && test_sta_flag(sta, WLAN_STA_AUTH)) { - ret = sta_info_move_state_checked(sta, - IEEE80211_STA_AUTH); + ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); if (ret) return ret; - ret = sta_info_move_state_checked(sta, - IEEE80211_STA_NONE); + ret = sta_info_move_state(sta, IEEE80211_STA_NONE); if (ret) return ret; } @@ -944,8 +938,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, if (!sta) return -ENOMEM; - sta_info_move_state(sta, IEEE80211_STA_AUTH); - sta_info_move_state(sta, IEEE80211_STA_ASSOC); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); err = sta_apply_parameters(local, sta, params); if (err) { diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c index 2406b3e7393f..c8383712fdec 100644 --- a/net/mac80211/debugfs_sta.c +++ b/net/mac80211/debugfs_sta.c @@ -63,14 +63,15 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf, test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : "" int res = scnprintf(buf, sizeof(buf), - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", TEST(AUTH), TEST(ASSOC), TEST(PS_STA), TEST(PS_DRIVER), TEST(AUTHORIZED), TEST(SHORT_PREAMBLE), TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT), TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL), TEST(UAPSD), TEST(SP), TEST(TDLS_PEER), - TEST(TDLS_PEER_AUTH)); + TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT), + TEST(INSERTED)); #undef TEST return simple_read_from_buffer(userbuf, count, ppos, buf, res); } diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index d38baa41cf6c..a98d370b56f6 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -265,9 +265,9 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, addr, sdata->name); #endif - sta_info_move_state(sta, IEEE80211_STA_AUTH); - sta_info_move_state(sta, IEEE80211_STA_ASSOC); - sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); rate_control_rate_init(sta); diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index e47768cb8cb3..6b0d70e960d4 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -318,9 +318,9 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) goto err_del_interface; } - sta_info_move_state(sta, IEEE80211_STA_AUTH); - sta_info_move_state(sta, IEEE80211_STA_ASSOC); - sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); res = sta_info_insert(sta); if (res) { diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 41ef1b476442..bf92e2878fe6 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -96,9 +96,9 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, if (!sta) return NULL; - sta_info_move_state(sta, IEEE80211_STA_AUTH); - sta_info_move_state(sta, IEEE80211_STA_ASSOC); - sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); set_sta_flag(sta, WLAN_STA_WME); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index de3268c7be1e..acc11b5c16fa 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1587,10 +1587,19 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, return false; } - sta_info_move_state(sta, IEEE80211_STA_AUTH); - sta_info_move_state(sta, IEEE80211_STA_ASSOC); - if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) - sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); + err = sta_info_move_state(sta, IEEE80211_STA_AUTH); + if (!err) + err = sta_info_move_state(sta, IEEE80211_STA_ASSOC); + if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) + err = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); + if (err) { + printk(KERN_DEBUG + "%s: failed to move station %pM to desired state\n", + sdata->name, sta->sta.addr); + WARN_ON(__sta_info_destroy(sta)); + mutex_unlock(&sdata->local->sta_mtx); + return false; + } rates = 0; basic_rates = 0; diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index f28fa02b6e54..df8f0a2f0dee 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -403,6 +403,8 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) sta_info_hash_add(local, sta); list_add(&sta->list, &local->sta_list); + + set_sta_flag(sta, WLAN_STA_INSERTED); } else { sta->dummy = false; } @@ -707,7 +709,7 @@ static bool sta_info_cleanup_expire_buffered(struct ieee80211_local *local, return have_buffered; } -static int __must_check __sta_info_destroy(struct sta_info *sta) +int __must_check __sta_info_destroy(struct sta_info *sta) { struct ieee80211_local *local; struct ieee80211_sub_if_data *sdata; @@ -722,6 +724,8 @@ static int __must_check __sta_info_destroy(struct sta_info *sta) local = sta->local; sdata = sta->sdata; + lockdep_assert_held(&local->sta_mtx); + /* * Before removing the station from the driver and * rate control, it might still start new aggregation @@ -763,8 +767,13 @@ static int __must_check __sta_info_destroy(struct sta_info *sta) if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); - while (sta->sta_state > IEEE80211_STA_NONE) - sta_info_move_state(sta, sta->sta_state - 1); + while (sta->sta_state > IEEE80211_STA_NONE) { + int err = sta_info_move_state(sta, sta->sta_state - 1); + if (err) { + WARN_ON_ONCE(1); + break; + } + } if (sta->uploaded) { if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) @@ -1391,8 +1400,8 @@ void ieee80211_sta_set_buffered(struct ieee80211_sta *pubsta, } EXPORT_SYMBOL(ieee80211_sta_set_buffered); -int sta_info_move_state_checked(struct sta_info *sta, - enum ieee80211_sta_state new_state) +int sta_info_move_state(struct sta_info *sta, + enum ieee80211_sta_state new_state) { might_sleep(); diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 6f77f12dc3fc..381de37d2478 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -52,6 +52,7 @@ * @WLAN_STA_SP: Station is in a service period, so don't try to * reply to other uAPSD trigger frames or PS-Poll. * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. + * @WLAN_STA_INSERTED: This station is inserted into the hash table. */ enum ieee80211_sta_info_flags { WLAN_STA_AUTH, @@ -71,6 +72,7 @@ enum ieee80211_sta_info_flags { WLAN_STA_UAPSD, WLAN_STA_SP, WLAN_STA_4ADDR_EVENT, + WLAN_STA_INSERTED, }; enum ieee80211_sta_state { @@ -427,13 +429,17 @@ static inline int test_and_set_sta_flag(struct sta_info *sta, return test_and_set_bit(flag, &sta->_flags); } -int sta_info_move_state_checked(struct sta_info *sta, - enum ieee80211_sta_state new_state); +int sta_info_move_state(struct sta_info *sta, + enum ieee80211_sta_state new_state); -static inline void sta_info_move_state(struct sta_info *sta, - enum ieee80211_sta_state new_state) +static inline void sta_info_pre_move_state(struct sta_info *sta, + enum ieee80211_sta_state new_state) { - int ret = sta_info_move_state_checked(sta, new_state); + int ret; + + WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED)); + + ret = sta_info_move_state(sta, new_state); WARN_ON_ONCE(ret); } @@ -544,6 +550,7 @@ int sta_info_insert(struct sta_info *sta); int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU); int sta_info_reinsert(struct sta_info *sta); +int __must_check __sta_info_destroy(struct sta_info *sta); int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, const u8 *addr); int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata, -- GitLab From 2ab694d302b489c5aa49c360dc97149b77c96586 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Fri, 27 Jan 2012 11:02:51 +0100 Subject: [PATCH 0260/1846] mac80211: Fix incorrect num_sta_ps decrement in __sta_info_destroy When WLAN_STA_PS_DRIVER is set by ieee80211_sta_block_awake the num_sta_ps counter is not incremented. Hence, we shouldn't decrement it in __sta_info_destroy if only WLAN_STA_PS_DRIVER is set. This could result in an incorrect num_sta_ps counter leading to strange side effects with associated powersaving clients. Fix this by only decrementing num_sta_ps when WLAN_STA_PS_STA was set before. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- net/mac80211/sta_info.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index df8f0a2f0dee..0c79593b1bbf 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -750,12 +750,10 @@ int __must_check __sta_info_destroy(struct sta_info *sta) sta->dead = true; - if (test_sta_flag(sta, WLAN_STA_PS_STA) || - test_sta_flag(sta, WLAN_STA_PS_DRIVER)) { + if (test_sta_flag(sta, WLAN_STA_PS_STA)) { BUG_ON(!sdata->bss); clear_sta_flag(sta, WLAN_STA_PS_STA); - clear_sta_flag(sta, WLAN_STA_PS_DRIVER); atomic_dec(&sdata->bss->num_sta_ps); sta_info_recalc_tim(sta); -- GitLab From 608383bfc04aa222c3e9e896c32f56a5e5deaff0 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Mon, 30 Jan 2012 15:18:00 +0100 Subject: [PATCH 0261/1846] mac80211: Fix incorrect num_sta_ps decrement in ap_sta_ps_end If the driver blocked this specific STA with the help of ieee80211_sta_block_awake we won't clear WLAN_STA_PS_STA later but still decrement num_sta_ps. Hence, the next data frame from this STA will trigger ap_sta_ps_end again and also decrement num_sta_ps again leading to an incorrect num_sta_ps counter. This can result in problems with powersaving clients not waking up from PS because the TIM calculation might be skipped due to the incorrect num_sta_ps counter. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- net/mac80211/rx.c | 8 ++------ net/mac80211/sta_info.c | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 73d213810a37..ab29253fb4f2 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1145,19 +1145,15 @@ static void ap_sta_ps_start(struct sta_info *sta) static void ap_sta_ps_end(struct sta_info *sta) { - struct ieee80211_sub_if_data *sdata = sta->sdata; - - atomic_dec(&sdata->bss->num_sta_ps); - #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", - sdata->name, sta->sta.addr, sta->sta.aid); + sta->sdata->name, sta->sta.addr, sta->sta.aid); #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) { #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", - sdata->name, sta->sta.addr, sta->sta.aid); + sta->sdata->name, sta->sta.addr, sta->sta.aid); #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ return; } diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 0c79593b1bbf..1fb4770a7d13 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -997,9 +997,11 @@ EXPORT_SYMBOL(ieee80211_find_sta); static void clear_sta_ps_flags(void *_sta) { struct sta_info *sta = _sta; + struct ieee80211_sub_if_data *sdata = sta->sdata; clear_sta_flag(sta, WLAN_STA_PS_DRIVER); - clear_sta_flag(sta, WLAN_STA_PS_STA); + if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA)) + atomic_dec(&sdata->bss->num_sta_ps); } /* powersave support code */ -- GitLab From d273bb20c00340748e3ca9730f87524ec5abbd64 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 27 Jan 2012 13:59:25 -0600 Subject: [PATCH 0262/1846] rtlwifi: Move pr_fmt macros to a single location Although the rtlwifi family of devices contains 11 copies of the pr_fmt macro, the macro is not defined for all routines that need it. By moving the macro to wifi.h, a single copy is available for all routines. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 7 +++---- drivers/net/wireless/rtlwifi/cam.c | 2 -- drivers/net/wireless/rtlwifi/core.h | 2 -- drivers/net/wireless/rtlwifi/debug.c | 2 ++ drivers/net/wireless/rtlwifi/pci.c | 4 ++-- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 5 +---- drivers/net/wireless/rtlwifi/rtl8192c/main.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 5 ++--- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 2 -- drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 6 ++---- drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 1 - drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 7 ++----- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 2 -- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 2 -- drivers/net/wireless/rtlwifi/rtl8192se/rf.c | 2 -- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 7 ++----- drivers/net/wireless/rtlwifi/usb.c | 7 ++----- drivers/net/wireless/rtlwifi/usb.h | 1 - drivers/net/wireless/rtlwifi/wifi.h | 2 ++ 19 files changed, 21 insertions(+), 47 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index ff3e393bc104..7a95a544a9b1 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -27,10 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include #include "wifi.h" #include "rc.h" #include "base.h" @@ -39,6 +35,9 @@ #include "ps.h" #include "regd.h" +#include +#include + /* *NOTICE!!!: This file will be very big, we hsould *keep it clear under follwing roles: diff --git a/drivers/net/wireless/rtlwifi/cam.c b/drivers/net/wireless/rtlwifi/cam.c index 8fd820d85eea..5c7d57947d23 100644 --- a/drivers/net/wireless/rtlwifi/cam.c +++ b/drivers/net/wireless/rtlwifi/cam.c @@ -27,8 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include "wifi.h" #include "cam.h" diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h index a45c3892e363..57569e0e3d47 100644 --- a/drivers/net/wireless/rtlwifi/core.h +++ b/drivers/net/wireless/rtlwifi/core.h @@ -30,8 +30,6 @@ #ifndef __RTL_CORE_H__ #define __RTL_CORE_H__ -#include - #define RTL_SUPPORTED_FILTERS \ (FIF_PROMISC_IN_BSS | \ FIF_ALLMULTI | FIF_CONTROL | \ diff --git a/drivers/net/wireless/rtlwifi/debug.c b/drivers/net/wireless/rtlwifi/debug.c index 67dcbcdfaa7b..bdda9b2fffe1 100644 --- a/drivers/net/wireless/rtlwifi/debug.c +++ b/drivers/net/wireless/rtlwifi/debug.c @@ -28,6 +28,8 @@ #include "wifi.h" +#include + void rtl_dbgp_flag_init(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 4326fd1e3190..e4d1dcfe8299 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -27,13 +27,13 @@ * *****************************************************************************/ -#include -#include "core.h" #include "wifi.h" +#include "core.h" #include "pci.h" #include "base.h" #include "ps.h" #include "efuse.h" +#include static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { PCI_VENDOR_ID_INTEL, diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 75be221fde4c..82bbc8384aca 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -27,16 +27,13 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include #include "../wifi.h" #include "../pci.h" #include "../base.h" #include "../rtl8192ce/reg.h" #include "../rtl8192ce/def.h" #include "fw_common.h" +#include static void _rtl92c_enable_fw_download(struct ieee80211_hw *hw, bool enable) { diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/main.c b/drivers/net/wireless/rtlwifi/rtl8192c/main.c index 8ae65b576126..918b1d129e77 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/main.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/main.c @@ -27,8 +27,8 @@ * *****************************************************************************/ -#include #include "../wifi.h" +#include MODULE_AUTHOR("lizhaoming "); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index 7e59b689bfff..460dc925b4e4 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c @@ -27,9 +27,6 @@ * *****************************************************************************/ -#include -#include - #include "../wifi.h" #include "../core.h" #include "../pci.h" @@ -43,6 +40,8 @@ #include "trx.h" #include "led.h" +#include + static void rtl92c_init_aspm_vars(struct ieee80211_hw *hw) { struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index edb52987f5ea..7f171682d3d6 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -27,8 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include "../wifi.h" #include "../efuse.h" #include "../base.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index d028f6f21990..025bdc2eba44 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -27,10 +27,6 @@ * ****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include - #include "../wifi.h" #include "../pci.h" #include "../usb.h" @@ -44,6 +40,8 @@ #include "mac.h" #include "trx.h" +#include + /* macro to shorten lines */ #define LINK_Q ui_link_quality diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index aec8cae733a1..c04c3be5bd4e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -41,7 +41,6 @@ #include "trx.h" #include "led.h" #include "hw.h" -#include #include MODULE_AUTHOR("Georgia "); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index b8d7fe39e5a8..bf625f9e632e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -27,11 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include - #include "../wifi.h" #include "../core.h" #include "../pci.h" @@ -44,6 +39,8 @@ #include "trx.h" #include "led.h" +#include + static void rtl92d_init_aspm_vars(struct ieee80211_hw *hw) { struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index 625c9eb0a118..cbaf1f345c6e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -27,8 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include "../wifi.h" #include "../efuse.h" #include "../base.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index adfac569b67c..05b4e2790e99 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -27,8 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include "../wifi.h" #include "../pci.h" #include "../ps.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c index 46be4cc8ba96..ad51906124db 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c @@ -27,8 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include "../wifi.h" #include "reg.h" #include "def.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index 3bc0128deeaa..0c47310b39b9 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -27,11 +27,6 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include - #include "../wifi.h" #include "../core.h" #include "../pci.h" @@ -45,6 +40,8 @@ #include "trx.h" #include "led.h" +#include + static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw) { struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index 78194e30fcd5..e7a7ea96f42b 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -25,16 +25,13 @@ * *****************************************************************************/ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include "core.h" #include "wifi.h" +#include "core.h" #include "usb.h" #include "base.h" #include "ps.h" #include "rtl8192c/fw_common.h" +#include #define REALTEK_USB_VENQT_READ 0xC0 #define REALTEK_USB_VENQT_WRITE 0x40 diff --git a/drivers/net/wireless/rtlwifi/usb.h b/drivers/net/wireless/rtlwifi/usb.h index cdad7c2507e4..43846b329153 100644 --- a/drivers/net/wireless/rtlwifi/usb.h +++ b/drivers/net/wireless/rtlwifi/usb.h @@ -28,7 +28,6 @@ #ifndef __RTL_USB_H__ #define __RTL_USB_H__ -#include #include #define RTL_RX_DESC_SIZE 24 diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index b2d98548500b..1e5fffb2db0b 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h @@ -30,6 +30,8 @@ #ifndef __RTL_WIFI_H__ #define __RTL_WIFI_H__ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include -- GitLab From 24db78c05b1e3ccb5a78aedd17aa1008c91dab5a Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Sat, 28 Jan 2012 17:25:32 +0100 Subject: [PATCH 0263/1846] nl80211: add support for mcs masks Allow to set mcs masks through nl80211. We also allow to set MCS rates but no legacy rates (and vice versa). Signed-off-by: Simon Wunderlich Signed-off-by: Mathias Kretschmer Signed-off-by: John W. Linville --- include/linux/nl80211.h | 4 +++ include/net/cfg80211.h | 3 +- net/wireless/nl80211.c | 61 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 4f98fae13307..ad56e21a9f10 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -1475,6 +1475,7 @@ enum nl80211_attrs { #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS #define NL80211_MAX_SUPP_RATES 32 +#define NL80211_MAX_SUPP_HT_RATES 77 #define NL80211_MAX_SUPP_REG_RULES 32 #define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0 #define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16 @@ -2405,12 +2406,15 @@ enum nl80211_key_attributes { * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with * 1 = 500 kbps) but without the IE length restriction (at most * %NL80211_MAX_SUPP_RATES in a single array). + * @NL80211_TXRATE_MCS: HT (MCS) rates allowed for TX rate selection + * in an array of MCS numbers. * @__NL80211_TXRATE_AFTER_LAST: internal * @NL80211_TXRATE_MAX: highest TX rate attribute */ enum nl80211_tx_rate_attributes { __NL80211_TXRATE_INVALID, NL80211_TXRATE_LEGACY, + NL80211_TXRATE_MCS, /* keep last */ __NL80211_TXRATE_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 5bb3ed4f99f5..2964205332f4 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1232,8 +1232,7 @@ enum wiphy_params_flags { struct cfg80211_bitrate_mask { struct { u32 legacy; - /* TODO: add support for masking MCS rates; e.g.: */ - /* u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; */ + u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; } control[IEEE80211_NUM_BANDS]; }; /** diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index c42173f947ef..c910b0750dc2 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5393,9 +5393,39 @@ static u32 rateset_to_mask(struct ieee80211_supported_band *sband, return mask; } +static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband, + u8 *rates, u8 rates_len, + u8 mcs[IEEE80211_HT_MCS_MASK_LEN]) +{ + u8 i; + + memset(mcs, 0, IEEE80211_HT_MCS_MASK_LEN); + + for (i = 0; i < rates_len; i++) { + int ridx, rbit; + + ridx = rates[i] / 8; + rbit = BIT(rates[i] % 8); + + /* check validity */ + if ((ridx < 0) || (ridx > IEEE80211_HT_MCS_MASK_LEN)) + return false; + + /* check availability */ + if (sband->ht_cap.mcs.rx_mask[ridx] & rbit) + mcs[ridx] |= rbit; + else + return false; + } + + return true; +} + static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY, .len = NL80211_MAX_SUPP_RATES }, + [NL80211_TXRATE_MCS] = { .type = NLA_BINARY, + .len = NL80211_MAX_SUPP_HT_RATES }, }; static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, @@ -5421,12 +5451,20 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, sband = rdev->wiphy.bands[i]; mask.control[i].legacy = sband ? (1 << sband->n_bitrates) - 1 : 0; + if (sband) + memcpy(mask.control[i].mcs, + sband->ht_cap.mcs.rx_mask, + sizeof(mask.control[i].mcs)); + else + memset(mask.control[i].mcs, 0, + sizeof(mask.control[i].mcs)); } /* * The nested attribute uses enum nl80211_band as the index. This maps * directly to the enum ieee80211_band values used in cfg80211. */ + BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8); nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) { enum ieee80211_band band = nla_type(tx_rates); @@ -5442,7 +5480,28 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, sband, nla_data(tb[NL80211_TXRATE_LEGACY]), nla_len(tb[NL80211_TXRATE_LEGACY])); - if (mask.control[band].legacy == 0) + } + if (tb[NL80211_TXRATE_MCS]) { + if (!ht_rateset_to_mask( + sband, + nla_data(tb[NL80211_TXRATE_MCS]), + nla_len(tb[NL80211_TXRATE_MCS]), + mask.control[band].mcs)) + return -EINVAL; + } + + if (mask.control[band].legacy == 0) { + /* don't allow empty legacy rates if HT + * is not even supported. */ + if (!rdev->wiphy.bands[band]->ht_cap.ht_supported) + return -EINVAL; + + for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) + if (mask.control[band].mcs[i]) + break; + + /* legacy and mcs rates may not be both empty */ + if (i == IEEE80211_HT_MCS_MASK_LEN) return -EINVAL; } } -- GitLab From 19468413e8d98d44be8daf0acaf8d576dfc53fa2 Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Sat, 28 Jan 2012 17:25:33 +0100 Subject: [PATCH 0264/1846] mac80211: add support for mcs masks * Handle MCS masks set by the user. * Match rates provided by the rate control algorithm to the mask set, also in HT mode, and switch back to legacy mode if necessary. * add debugfs files to observate the rate selection Signed-off-by: Simon Wunderlich Signed-off-by: Mathias Kretschmer Signed-off-by: John W. Linville --- include/net/mac80211.h | 1 + net/mac80211/cfg.c | 5 +- net/mac80211/debugfs_netdev.c | 34 ++++++++++ net/mac80211/ieee80211_i.h | 1 + net/mac80211/iface.c | 7 ++ net/mac80211/rate.c | 124 +++++++++++++++++++++++++++++++--- net/mac80211/tx.c | 5 ++ 7 files changed, 168 insertions(+), 9 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 650185876846..520eb4c5e5a2 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -3551,6 +3551,7 @@ struct ieee80211_tx_rate_control { bool rts, short_preamble; u8 max_rate_idx; u32 rate_idx_mask; + u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; bool bss; }; diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index dc7420441574..d15ba0d0de94 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1902,8 +1902,11 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, return ret; } - for (i = 0; i < IEEE80211_NUM_BANDS; i++) + for (i = 0; i < IEEE80211_NUM_BANDS; i++) { sdata->rc_rateidx_mask[i] = mask->control[i].legacy; + memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs, + sizeof(mask->control[i].mcs)); + } return 0; } diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 81d12e65a23c..510ed1dab3c7 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -87,6 +87,21 @@ static ssize_t ieee80211_if_fmt_##name( \ #define IEEE80211_IF_FMT_SIZE(name, field) \ IEEE80211_IF_FMT(name, field, "%zd\n") +#define IEEE80211_IF_FMT_HEXARRAY(name, field) \ +static ssize_t ieee80211_if_fmt_##name( \ + const struct ieee80211_sub_if_data *sdata, \ + char *buf, int buflen) \ +{ \ + char *p = buf; \ + int i; \ + for (i = 0; i < sizeof(sdata->field); i++) { \ + p += scnprintf(p, buflen + buf - p, "%.2x ", \ + sdata->field[i]); \ + } \ + p += scnprintf(p, buflen + buf - p, "\n"); \ + return p - buf; \ +} + #define IEEE80211_IF_FMT_ATOMIC(name, field) \ static ssize_t ieee80211_if_fmt_##name( \ const struct ieee80211_sub_if_data *sdata, \ @@ -148,6 +163,11 @@ IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[IEEE80211_BAND_2GHZ], HEX); IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ], HEX); +IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz, + rc_rateidx_mcs_mask[IEEE80211_BAND_2GHZ], HEXARRAY); +IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz, + rc_rateidx_mcs_mask[IEEE80211_BAND_5GHZ], HEXARRAY); + IEEE80211_IF_FILE(flags, flags, HEX); IEEE80211_IF_FILE(state, state, LHEX); IEEE80211_IF_FILE(channel_type, vif.bss_conf.channel_type, DEC); @@ -442,6 +462,8 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata) DEBUGFS_ADD(channel_type); DEBUGFS_ADD(rc_rateidx_mask_2ghz); DEBUGFS_ADD(rc_rateidx_mask_5ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); DEBUGFS_ADD(bssid); DEBUGFS_ADD(aid); @@ -459,6 +481,8 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata) DEBUGFS_ADD(channel_type); DEBUGFS_ADD(rc_rateidx_mask_2ghz); DEBUGFS_ADD(rc_rateidx_mask_5ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); DEBUGFS_ADD(num_sta_authorized); DEBUGFS_ADD(num_sta_ps); @@ -469,6 +493,12 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata) static void add_ibss_files(struct ieee80211_sub_if_data *sdata) { + DEBUGFS_ADD(channel_type); + DEBUGFS_ADD(rc_rateidx_mask_2ghz); + DEBUGFS_ADD(rc_rateidx_mask_5ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); + DEBUGFS_ADD_MODE(tsf, 0600); } @@ -480,6 +510,8 @@ static void add_wds_files(struct ieee80211_sub_if_data *sdata) DEBUGFS_ADD(channel_type); DEBUGFS_ADD(rc_rateidx_mask_2ghz); DEBUGFS_ADD(rc_rateidx_mask_5ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); DEBUGFS_ADD(peer); } @@ -492,6 +524,8 @@ static void add_vlan_files(struct ieee80211_sub_if_data *sdata) DEBUGFS_ADD(channel_type); DEBUGFS_ADD(rc_rateidx_mask_2ghz); DEBUGFS_ADD(rc_rateidx_mask_5ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); + DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); } static void add_monitor_files(struct ieee80211_sub_if_data *sdata) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index ca6486b941b6..d47e8c110b16 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -646,6 +646,7 @@ struct ieee80211_sub_if_data { /* bitmap of allowed (non-MCS) rate indexes for rate control */ u32 rc_rateidx_mask[IEEE80211_NUM_BANDS]; + u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN]; union { struct ieee80211_if_ap ap; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 6b0d70e960d4..c33feede5dca 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1181,6 +1181,13 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, sband = local->hw.wiphy->bands[i]; sdata->rc_rateidx_mask[i] = sband ? (1 << sband->n_bitrates) - 1 : 0; + if (sband) + memcpy(sdata->rc_rateidx_mcs_mask[i], + sband->ht_cap.mcs.rx_mask, + sizeof(sdata->rc_rateidx_mcs_mask[i])); + else + memset(sdata->rc_rateidx_mcs_mask[i], 0, + sizeof(sdata->rc_rateidx_mcs_mask[i])); } /* setup type-dependent data */ diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index a21110aecd1a..3fef26d8898a 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -289,8 +289,8 @@ bool rate_control_send_low(struct ieee80211_sta *sta, } EXPORT_SYMBOL(rate_control_send_low); -static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, - int n_bitrates, u32 mask) +static bool rate_idx_match_legacy_mask(struct ieee80211_tx_rate *rate, + int n_bitrates, u32 mask) { int j; @@ -299,7 +299,7 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, if (mask & (1 << j)) { /* Okay, found a suitable rate. Use it. */ rate->idx = j; - return; + return true; } } @@ -308,6 +308,112 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, if (mask & (1 << j)) { /* Okay, found a suitable rate. Use it. */ rate->idx = j; + return true; + } + } + return false; +} + +static bool rate_idx_match_mcs_mask(struct ieee80211_tx_rate *rate, + u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) +{ + int i, j; + int ridx, rbit; + + ridx = rate->idx / 8; + rbit = rate->idx % 8; + + /* sanity check */ + if (ridx < 0 || ridx > IEEE80211_HT_MCS_MASK_LEN) + return false; + + /* See whether the selected rate or anything below it is allowed. */ + for (i = ridx; i >= 0; i--) { + for (j = rbit; j >= 0; j--) + if (mcs_mask[i] & BIT(j)) { + rate->idx = i * 8 + j; + return true; + } + rbit = 7; + } + + /* Try to find a higher rate that would be allowed */ + ridx = (rate->idx + 1) / 8; + rbit = (rate->idx + 1) % 8; + + for (i = ridx; i < IEEE80211_HT_MCS_MASK_LEN; i++) { + for (j = rbit; j < 8; j++) + if (mcs_mask[i] & BIT(j)) { + rate->idx = i * 8 + j; + return true; + } + rbit = 0; + } + return false; +} + + + +static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, + struct ieee80211_tx_rate_control *txrc, + u32 mask, + u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) +{ + struct ieee80211_tx_rate alt_rate; + + /* handle HT rates */ + if (rate->flags & IEEE80211_TX_RC_MCS) { + if (rate_idx_match_mcs_mask(rate, mcs_mask)) + return; + + /* also try the legacy rates. */ + alt_rate.idx = 0; + /* keep protection flags */ + alt_rate.flags = rate->flags & + (IEEE80211_TX_RC_USE_RTS_CTS | + IEEE80211_TX_RC_USE_CTS_PROTECT | + IEEE80211_TX_RC_USE_SHORT_PREAMBLE); + alt_rate.count = rate->count; + if (rate_idx_match_legacy_mask(&alt_rate, + txrc->sband->n_bitrates, + mask)) { + *rate = alt_rate; + return; + } + } else { + struct sk_buff *skb = txrc->skb; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + __le16 fc; + + /* handle legacy rates */ + if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates, + mask)) + return; + + /* if HT BSS, and we handle a data frame, also try HT rates */ + if (txrc->bss_conf->channel_type == NL80211_CHAN_NO_HT) + return; + + fc = hdr->frame_control; + if (!ieee80211_is_data(fc)) + return; + + alt_rate.idx = 0; + /* keep protection flags */ + alt_rate.flags = rate->flags & + (IEEE80211_TX_RC_USE_RTS_CTS | + IEEE80211_TX_RC_USE_CTS_PROTECT | + IEEE80211_TX_RC_USE_SHORT_PREAMBLE); + alt_rate.count = rate->count; + + alt_rate.flags |= IEEE80211_TX_RC_MCS; + + if ((txrc->bss_conf->channel_type == NL80211_CHAN_HT40MINUS) || + (txrc->bss_conf->channel_type == NL80211_CHAN_HT40PLUS)) + alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; + + if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) { + *rate = alt_rate; return; } } @@ -331,6 +437,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); int i; u32 mask; + u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; if (sta) { ista = &sta->sta; @@ -354,10 +461,14 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, * the common case. */ mask = sdata->rc_rateidx_mask[info->band]; + memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band], + sizeof(mcs_mask)); if (mask != (1 << txrc->sband->n_bitrates) - 1) { if (sta) { /* Filter out rates that the STA does not support */ mask &= sta->sta.supp_rates[info->band]; + for (i = 0; i < sizeof(mcs_mask); i++) + mcs_mask[i] &= sta->sta.ht_cap.mcs.rx_mask[i]; } /* * Make sure the rate index selected for each TX rate is @@ -368,11 +479,8 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, /* Skip invalid rates */ if (info->control.rates[i].idx < 0) break; - /* Rate masking supports only legacy rates for now */ - if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) - continue; - rate_idx_match_mask(&info->control.rates[i], - txrc->sband->n_bitrates, mask); + rate_idx_match_mask(&info->control.rates[i], txrc, + mask, mcs_mask); } } diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index e05667cd5e76..1be0ca2b5936 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -635,6 +635,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) txrc.max_rate_idx = -1; else txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; + memcpy(txrc.rate_idx_mcs_mask, + tx->sdata->rc_rateidx_mcs_mask[tx->channel->band], + sizeof(txrc.rate_idx_mcs_mask)); txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || tx->sdata->vif.type == NL80211_IFTYPE_ADHOC); @@ -2431,6 +2434,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, txrc.max_rate_idx = -1; else txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; + memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band], + sizeof(txrc.rate_idx_mcs_mask)); txrc.bss = true; rate_control_get_rate(sdata, NULL, &txrc); -- GitLab From 4f3eb0ba4817e55e1b5b2f63fcf3f266c328fc1a Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Fri, 27 Jan 2012 11:02:53 +0100 Subject: [PATCH 0265/1846] mac80211: Move num_sta_ps counter decrement after synchronize_rcu Unted the assumption that the sta struct is still accessible before the synchronize_rcu call we should move the num_sta_ps counter decrement after synchronize_rcu to avoid incorrect decrements if num_sta_ps. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- net/mac80211/sta_info.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 1fb4770a7d13..fa0823892b2d 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -750,15 +750,6 @@ int __must_check __sta_info_destroy(struct sta_info *sta) sta->dead = true; - if (test_sta_flag(sta, WLAN_STA_PS_STA)) { - BUG_ON(!sdata->bss); - - clear_sta_flag(sta, WLAN_STA_PS_STA); - - atomic_dec(&sdata->bss->num_sta_ps); - sta_info_recalc_tim(sta); - } - local->num_sta--; local->sta_generation++; @@ -790,6 +781,15 @@ int __must_check __sta_info_destroy(struct sta_info *sta) */ synchronize_rcu(); + if (test_sta_flag(sta, WLAN_STA_PS_STA)) { + BUG_ON(!sdata->bss); + + clear_sta_flag(sta, WLAN_STA_PS_STA); + + atomic_dec(&sdata->bss->num_sta_ps); + sta_info_recalc_tim(sta); + } + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); __skb_queue_purge(&sta->ps_tx_buf[ac]); -- GitLab From 0a79bb57d46c7ee93de0e262cebb46f6f6f6a1a7 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Sat, 28 Jan 2012 08:30:49 -0800 Subject: [PATCH 0266/1846] iwlwifi: fix typo Fix few places of typo Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 185b69ef7539..f97d06169b45 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -111,17 +111,17 @@ * * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - * commands from user applicaiton to indirectly access peripheral register + * commands from user application 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 + * commands from user application to read data in sram * - * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image + * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Wake 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 * @IWL_TM_CMD_APP2DEV_GET_FW_INFO: - * retrieve informration of existing loaded uCode image + * retrieve information of existing loaded uCode image * */ enum iwl_tm_cmd_t { -- GitLab From 2b2db58d65edcab4bcc9d6fdd2770bb0275cdac4 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 28 Jan 2012 08:30:50 -0800 Subject: [PATCH 0267/1846] iwlwifi: fix uCode event tracing Fix multiple bugs in event tracing: 1) If you enable uCode tracing with the device down, it will still attempt to access the device and continuously log "MAC is in deep sleep!" errors. Fix this by only starting logging when the device is actually alive. 2) Now you can set the flag when the device is down, but logging doesn't happen when you bring it up. To fix that, start logging when the device comes alive. This means we don't log before -- we could do that but I don't need it right now. 3) For some reason we read the error instead of the event log -- use the right pointer. 4) Optimise SRAM reading of event log header. 5) Fix reading write pointer == capacity, which can happen due to racy SRAM access 6) Most importantly: fix an error where we would try to read WAY too many events (like 2^32-300) when we read the wrap counter before it is updated by the uCode -- this does happen in practice and will cause the driver to hang the machine. 7) Finally, change the timer to 10ms instead of 100ms as 100ms is too slow to capture all data with a normal event log and with 100ms the log will wrap multiple times before we have a chance to read it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 99 ++++++++++++++++------ drivers/net/wireless/iwlwifi/iwl-debugfs.c | 7 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +- 3 files changed, 76 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 7321e7d31406..3e429a3e518d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -315,7 +315,7 @@ static void iwl_bg_statistics_periodic(unsigned long data) static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, u32 start_idx, u32 num_events, - u32 mode) + u32 capacity, u32 mode) { u32 i; u32 ptr; /* SRAM byte address of log data */ @@ -338,6 +338,15 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, ptr); rmb(); + /* + * Refuse to read more than would have fit into the log from + * the current start_idx. This used to happen due to the race + * described below, but now WARN because the code below should + * prevent it from happening here. + */ + if (WARN_ON(num_events > capacity - start_idx)) + num_events = capacity - start_idx; + /* * "time" is actually "data" for mode 0 (no timestamp). * place event id # at far right for easier visual parsing. @@ -346,12 +355,11 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, ev = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); time = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); if (mode == 0) { - trace_iwlwifi_dev_ucode_cont_event(priv, - 0, time, ev); + trace_iwlwifi_dev_ucode_cont_event(priv, 0, time, ev); } else { data = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); - trace_iwlwifi_dev_ucode_cont_event(priv, - time, data, ev); + trace_iwlwifi_dev_ucode_cont_event(priv, time, + data, ev); } } /* Allow device to power down */ @@ -362,53 +370,83 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, static void iwl_continuous_event_trace(struct iwl_priv *priv) { u32 capacity; /* event log capacity in # entries */ + struct { + u32 capacity; + u32 mode; + u32 wrap_counter; + u32 write_counter; + } __packed read; u32 base; /* SRAM byte address of event log header */ u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ u32 num_wraps; /* # times uCode wrapped to top of log */ u32 next_entry; /* index of next entry to be written by uCode */ - base = priv->shrd->device_pointers.error_event_table; + base = priv->shrd->device_pointers.log_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), - base + (2 * sizeof(u32))); - mode = iwl_read_targ_mem(bus(priv), base + (1 * sizeof(u32))); - next_entry = iwl_read_targ_mem(bus(priv), - base + (3 * sizeof(u32))); + iwl_read_targ_mem_words(bus(priv), base, &read, sizeof(read)); + + capacity = read.capacity; + mode = read.mode; + num_wraps = read.wrap_counter; + next_entry = read.write_counter; } else return; + /* + * Unfortunately, the uCode doesn't use temporary variables. + * Therefore, it can happen that we read next_entry == capacity, + * which really means next_entry == 0. + */ + if (unlikely(next_entry == capacity)) + next_entry = 0; + /* + * Additionally, the uCode increases the write pointer before + * the wraps counter, so if the write pointer is smaller than + * the old write pointer (wrap occurred) but we read that no + * wrap occurred, we actually read between the next_entry and + * num_wraps update (this does happen in practice!!) -- take + * that into account by increasing num_wraps. + */ + if (unlikely(next_entry < priv->event_log.next_entry && + num_wraps == priv->event_log.num_wraps)) + num_wraps++; + if (num_wraps == priv->event_log.num_wraps) { - iwl_print_cont_event_trace(priv, - base, priv->event_log.next_entry, - next_entry - priv->event_log.next_entry, - mode); + iwl_print_cont_event_trace( + priv, base, priv->event_log.next_entry, + next_entry - priv->event_log.next_entry, + capacity, mode); + priv->event_log.non_wraps_count++; } else { - if ((num_wraps - priv->event_log.num_wraps) > 1) + if (num_wraps - priv->event_log.num_wraps > 1) priv->event_log.wraps_more_count++; else priv->event_log.wraps_once_count++; + trace_iwlwifi_dev_ucode_wrap_event(priv, num_wraps - priv->event_log.num_wraps, next_entry, priv->event_log.next_entry); + if (next_entry < priv->event_log.next_entry) { - iwl_print_cont_event_trace(priv, base, - priv->event_log.next_entry, - capacity - priv->event_log.next_entry, - mode); + iwl_print_cont_event_trace( + priv, base, priv->event_log.next_entry, + capacity - priv->event_log.next_entry, + capacity, mode); - iwl_print_cont_event_trace(priv, base, 0, - next_entry, mode); + iwl_print_cont_event_trace( + priv, base, 0, next_entry, capacity, mode); } else { - iwl_print_cont_event_trace(priv, base, - next_entry, capacity - next_entry, - mode); + iwl_print_cont_event_trace( + priv, base, next_entry, + capacity - next_entry, + capacity, mode); - iwl_print_cont_event_trace(priv, base, 0, - next_entry, mode); + iwl_print_cont_event_trace( + priv, base, 0, next_entry, capacity, mode); } } + priv->event_log.num_wraps = num_wraps; priv->event_log.next_entry = next_entry; } @@ -1219,6 +1257,11 @@ int iwl_alive_start(struct iwl_priv *priv) if (iwl_is_rfkill(priv->shrd)) return -ERFKILL; + if (priv->event_log.ucode_trace) { + /* start collecting data now */ + mod_timer(&priv->ucode_trace, jiffies); + } + /* download priority table before any calibration request */ if (cfg(priv)->bt_params && cfg(priv)->bt_params->advanced_bt_coexist) { diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index f837f32bb71c..978a1d4c6a0a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2131,9 +2131,10 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, if (trace) { priv->event_log.ucode_trace = true; - /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ - mod_timer(&priv->ucode_trace, - jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); + if (iwl_is_alive(priv->shrd)) { + /* start collecting data now */ + mod_timer(&priv->ucode_trace, jiffies); + } } else { priv->event_log.ucode_trace = false; del_timer_sync(&priv->ucode_trace); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 4579d61da25e..af846002150a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -661,7 +661,7 @@ struct traffic_stats { * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds * to perform continuous uCode event logging operation if enabled */ -#define UCODE_TRACE_PERIOD (100) +#define UCODE_TRACE_PERIOD (10) /* * iwl_event_log: current uCode event log position -- GitLab From dcc3ec04c14d6d840fdcc5be0ddd752a7daf7ec4 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Sat, 28 Jan 2012 08:30:51 -0800 Subject: [PATCH 0268/1846] iwlwifi: add option to disalbe LED Led has no use for some platform. Add additional module parameter option to disable LED Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-led.c | 4 ++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 3e429a3e518d..90315c69cdf6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -2097,7 +2097,7 @@ MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)"); module_param_named(led_mode, iwlagn_mod_params.led_mode, int, S_IRUGO); MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking (default: 0)"); + "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)"); module_param_named(power_save, iwlagn_mod_params.power_save, bool, S_IRUGO); diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index eca79087afb8..8761438f1532 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -177,6 +177,10 @@ void iwl_leds_init(struct iwl_priv *priv) int mode = iwlagn_mod_params.led_mode; int ret; + if (mode == IWL_LED_DISABLE) { + IWL_INFO(priv, "Led disabled\n"); + return; + } if (mode == IWL_LED_DEFAULT) mode = cfg(priv)->led_mode; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index e406d49f4189..04975b7b65b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -264,11 +264,13 @@ enum iwl_pa_type { * LED ON = RF ON * LED OFF = RF OFF * IWL_LED_BLINK: adjust led blink rate based on blink table + * IWL_LED_DISABLE: led disabled */ enum iwl_led_mode { IWL_LED_DEFAULT, IWL_LED_RF_STATE, IWL_LED_BLINK, + IWL_LED_DISABLE, }; /** -- GitLab From 2ed81710ccc0ccebe177481b8d4ac584f9c2b569 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 28 Jan 2012 08:30:52 -0800 Subject: [PATCH 0269/1846] iwlwifi: always restrict scan dwell in P2P Whenever the PAN (P2P) context is active, it has timers in the uCode that prevent sleep, so scanning can't be out of channel for more than the beacon interval programmed into the device. Before this patch, a full scan including any passive channels when P2P was active would stall forever because it wouldn't find time to execute the passive requests (for default beacon intervals of 100 TU.) Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-scan.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 2aea20bf0f10..7f2e3a1c80ef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -414,10 +414,25 @@ static u16 iwl_limit_dwell(struct iwl_priv *priv, u16 dwell_time) for_each_context(priv, ctx) { u16 value; - if (!iwl_is_associated_ctx(ctx)) - continue; - if (ctx->staging.dev_type == RXON_DEV_TYPE_P2P) + switch (ctx->staging.dev_type) { + case RXON_DEV_TYPE_P2P: + /* no timing constraints */ continue; + case RXON_DEV_TYPE_ESS: + default: + /* timing constraints if associated */ + if (!iwl_is_associated_ctx(ctx)) + continue; + break; + case RXON_DEV_TYPE_CP: + case RXON_DEV_TYPE_2STA: + /* + * These seem to always have timers for TBTT + * active in uCode even when not associated yet. + */ + break; + } + value = ctx->beacon_int; if (!value) value = IWL_PASSIVE_DWELL_BASE; -- GitLab From ed072f9e80f02e5ae4150ad5a605fc3906e9fbc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Sun, 29 Jan 2012 11:59:42 +0100 Subject: [PATCH 0270/1846] MAINTAINERS: update b43(legacy) mailing list 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 --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 6e68daa1e64b..1adb206dfcac 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1411,7 +1411,7 @@ F: net/ax25/ B43 WIRELESS DRIVER M: Stefano Brivio L: linux-wireless@vger.kernel.org -L: b43-dev@lists.infradead.org (moderated for non-subscribers) +L: b43-dev@lists.infradead.org W: http://linuxwireless.org/en/users/Drivers/b43 S: Maintained F: drivers/net/wireless/b43/ @@ -1420,6 +1420,7 @@ B43LEGACY WIRELESS DRIVER M: Larry Finger M: Stefano Brivio L: linux-wireless@vger.kernel.org +L: b43-dev@lists.infradead.org W: http://linuxwireless.org/en/users/Drivers/b43 S: Maintained F: drivers/net/wireless/b43legacy/ -- GitLab From 0ed7b93e307fd02188a33b80897069d3acc76485 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Mon, 30 Jan 2012 14:17:18 +0530 Subject: [PATCH 0271/1846] ath9k_htc: Load firmware asynchronously This patch modifies ath9k_htc to load the needed firmware in an asynchronous manner, fixing timeouts that were introduced with the new udev changes. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hif_usb.c | 154 +++++++++++++++-------- drivers/net/wireless/ath/ath9k/hif_usb.h | 3 +- 2 files changed, 101 insertions(+), 56 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c index 77c8ded8de57..f317515d8bf3 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c @@ -968,8 +968,7 @@ static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev) ath9k_hif_usb_dealloc_rx_urbs(hif_dev); } -static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev, - u32 drv_info) +static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) { int transfer, err; const void *data = hif_dev->firmware->data; @@ -1000,7 +999,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev, } kfree(buf); - if (IS_AR7010_DEVICE(drv_info)) + if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info)) firm_offset = AR7010_FIRMWARE_TEXT; else firm_offset = AR9271_FIRMWARE_TEXT; @@ -1021,28 +1020,18 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev, return 0; } -static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev, u32 drv_info) +static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev) { - int ret, idx; struct usb_host_interface *alt = &hif_dev->interface->altsetting[0]; struct usb_endpoint_descriptor *endp; + int ret, idx; - /* Request firmware */ - ret = request_firmware(&hif_dev->firmware, hif_dev->fw_name, - &hif_dev->udev->dev); - if (ret) { - dev_err(&hif_dev->udev->dev, - "ath9k_htc: Firmware - %s not found\n", hif_dev->fw_name); - goto err_fw_req; - } - - /* Download firmware */ - ret = ath9k_hif_usb_download_fw(hif_dev, drv_info); + ret = ath9k_hif_usb_download_fw(hif_dev); if (ret) { dev_err(&hif_dev->udev->dev, "ath9k_htc: Firmware - %s download failed\n", hif_dev->fw_name); - goto err_fw_download; + return ret; } /* On downloading the firmware to the target, the USB descriptor of EP4 @@ -1064,23 +1053,84 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev, u32 drv_info) if (ret) { dev_err(&hif_dev->udev->dev, "ath9k_htc: Unable to allocate URBs\n"); - goto err_fw_download; + return ret; } return 0; - -err_fw_download: - release_firmware(hif_dev->firmware); -err_fw_req: - hif_dev->firmware = NULL; - return ret; } static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev) { ath9k_hif_usb_dealloc_urbs(hif_dev); - if (hif_dev->firmware) - release_firmware(hif_dev->firmware); +} + +/* + * If initialization fails or the FW cannot be retrieved, + * detach the device. + */ +static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev) +{ + struct device *parent = hif_dev->udev->dev.parent; + + complete(&hif_dev->fw_done); + + if (parent) + device_lock(parent); + + device_release_driver(&hif_dev->udev->dev); + + if (parent) + device_unlock(parent); +} + +static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context) +{ + struct hif_device_usb *hif_dev = context; + int ret; + + if (!fw) { + dev_err(&hif_dev->udev->dev, + "ath9k_htc: Failed to get firmware %s\n", + hif_dev->fw_name); + goto err_fw; + } + + hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb, + &hif_dev->udev->dev); + if (hif_dev->htc_handle == NULL) { + goto err_fw; + } + + hif_dev->firmware = fw; + + /* Proceed with initialization */ + + ret = ath9k_hif_usb_dev_init(hif_dev); + if (ret) + goto err_dev_init; + + ret = ath9k_htc_hw_init(hif_dev->htc_handle, + &hif_dev->interface->dev, + hif_dev->usb_device_id->idProduct, + hif_dev->udev->product, + hif_dev->usb_device_id->driver_info); + if (ret) { + ret = -EINVAL; + goto err_htc_hw_init; + } + + complete(&hif_dev->fw_done); + + return; + +err_htc_hw_init: + ath9k_hif_usb_dev_deinit(hif_dev); +err_dev_init: + ath9k_htc_hw_free(hif_dev->htc_handle); + release_firmware(fw); + hif_dev->firmware = NULL; +err_fw: + ath9k_hif_usb_firmware_fail(hif_dev); } /* @@ -1155,20 +1205,16 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface, } usb_get_dev(udev); + hif_dev->udev = udev; hif_dev->interface = interface; - hif_dev->device_id = id->idProduct; + hif_dev->usb_device_id = id; #ifdef CONFIG_PM udev->reset_resume = 1; #endif usb_set_intfdata(interface, hif_dev); - hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb, - &hif_dev->udev->dev); - if (hif_dev->htc_handle == NULL) { - ret = -ENOMEM; - goto err_htc_hw_alloc; - } + init_completion(&hif_dev->fw_done); /* Find out which firmware to load */ @@ -1177,29 +1223,22 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface, else hif_dev->fw_name = FIRMWARE_AR9271; - ret = ath9k_hif_usb_dev_init(hif_dev, id->driver_info); - if (ret) { - ret = -EINVAL; - goto err_hif_init_usb; - } - - ret = ath9k_htc_hw_init(hif_dev->htc_handle, - &interface->dev, hif_dev->device_id, - hif_dev->udev->product, id->driver_info); + ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name, + &hif_dev->udev->dev, GFP_KERNEL, + hif_dev, ath9k_hif_usb_firmware_cb); if (ret) { - ret = -EINVAL; - goto err_htc_hw_init; + dev_err(&hif_dev->udev->dev, + "ath9k_htc: Async request for firmware %s failed\n", + hif_dev->fw_name); + goto err_fw_req; } - dev_info(&hif_dev->udev->dev, "ath9k_htc: USB layer initialized\n"); + dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n", + hif_dev->fw_name); return 0; -err_htc_hw_init: - ath9k_hif_usb_dev_deinit(hif_dev); -err_hif_init_usb: - ath9k_htc_hw_free(hif_dev->htc_handle); -err_htc_hw_alloc: +err_fw_req: usb_set_intfdata(interface, NULL); kfree(hif_dev); usb_put_dev(udev); @@ -1234,9 +1273,15 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface) if (!hif_dev) return; - ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged); - ath9k_htc_hw_free(hif_dev->htc_handle); - ath9k_hif_usb_dev_deinit(hif_dev); + wait_for_completion(&hif_dev->fw_done); + + if (hif_dev->firmware) { + ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged); + ath9k_htc_hw_free(hif_dev->htc_handle); + ath9k_hif_usb_dev_deinit(hif_dev); + release_firmware(hif_dev->firmware); + } + usb_set_intfdata(interface, NULL); if (!unplugged && (hif_dev->flags & HIF_USB_START)) @@ -1276,8 +1321,7 @@ static int ath9k_hif_usb_resume(struct usb_interface *interface) return ret; if (hif_dev->firmware) { - ret = ath9k_hif_usb_download_fw(hif_dev, - htc_handle->drv_priv->ah->hw_version.usbdev); + ret = ath9k_hif_usb_download_fw(hif_dev); if (ret) goto fail_resume; } else { diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h index 794f63094e5d..487ff658b4c1 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.h +++ b/drivers/net/wireless/ath/ath9k/hif_usb.h @@ -87,10 +87,11 @@ struct cmd_buf { #define HIF_USB_START BIT(0) struct hif_device_usb { - u16 device_id; struct usb_device *udev; struct usb_interface *interface; + const struct usb_device_id *usb_device_id; const struct firmware *firmware; + struct completion fw_done; struct htc_target *htc_handle; struct hif_usb_tx tx; struct usb_anchor regout_submitted; -- GitLab From feced2012e665468258a5c89b7f2a90b4e5695a4 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Mon, 30 Jan 2012 14:21:42 +0530 Subject: [PATCH 0272/1846] ath9k: Print the correct channel mode channelFlags doesn't contain the operating HT mode. Use IS_CHAN_HT40 to determine if the current channel is in HT40 mode. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 4a00806e2852..ec82e926badc 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -340,9 +340,7 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan, fastcc = false; ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n", - hchan->channel, !!(hchan->channelFlags & (CHANNEL_HT40MINUS | - CHANNEL_HT40PLUS)), - fastcc); + hchan->channel, IS_CHAN_HT40(hchan), fastcc); r = ath9k_hw_reset(ah, hchan, caldata, fastcc); if (r) { -- GitLab From b0302aba812bcc39291cdab9ad7e37008f352a91 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 30 Jan 2012 09:54:49 -0600 Subject: [PATCH 0273/1846] rtlwifi: Convert to asynchronous firmware load This patch addresses a kernel bugzilla report and two recent mail threads. The kernel bugzilla report is https://bugzilla.kernel.org/show_bug.cgi?id=42632, which reports a udev timeout on boot. The first mail thread, which was on LKML (http://lkml.indiana.edu/hypermail/ linux/kernel/1112.3/00965.html) was for a WARNING that occurs after a suspend/resume cycle for rtl8192cu. The scond mail thread (http://marc.info/?l=linux-wireless&m=132655490826766&w=2) concerned changes in udev that break drivers that delay while firmware is loaded on modprobe. This patch converts all rtlwifi-based drivers to use the asynchronous firmware loading mechanism. Drivers rtl8192ce, rtl8192cu and rtl8192de share a common callback routine. Driver rtl8192se needs different handling of the firmware, thus it has its own code. Signed-off-by: Larry Finger Cc: Stable Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 1 + drivers/net/wireless/rtlwifi/core.c | 46 ++++++++++++- drivers/net/wireless/rtlwifi/core.h | 2 + drivers/net/wireless/rtlwifi/pci.c | 26 +++----- drivers/net/wireless/rtlwifi/pci.h | 1 - drivers/net/wireless/rtlwifi/ps.c | 3 +- .../net/wireless/rtlwifi/rtl8192c/fw_common.c | 10 +-- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 6 +- drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 24 +++---- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 35 +++++----- drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 29 +++------ drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 8 +-- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 3 - drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 38 +++++------ drivers/net/wireless/rtlwifi/rtl8192se/fw.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 16 +++-- drivers/net/wireless/rtlwifi/rtl8192se/led.c | 5 +- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 65 ++++++++++++++----- drivers/net/wireless/rtlwifi/usb.c | 34 ++++------ drivers/net/wireless/rtlwifi/wifi.h | 4 +- 20 files changed, 194 insertions(+), 164 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index 7a95a544a9b1..df5655cc55c0 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -410,6 +410,7 @@ void rtl_init_rfkill(struct ieee80211_hw *hw) wiphy_rfkill_start_polling(hw->wiphy); } +EXPORT_SYMBOL(rtl_init_rfkill); void rtl_deinit_rfkill(struct ieee80211_hw *hw) { diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index 0ee01ab2e4f6..f231b9180436 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c @@ -31,8 +31,50 @@ #include "core.h" #include "cam.h" #include "base.h" +#include "pci.h" #include "ps.h" +#include + +void rtl_fw_cb(const struct firmware *firmware, void *context) +{ + struct ieee80211_hw *hw = context; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int err; + + RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, + "Firmware callback routine entered!\n"); + complete(&rtlpriv->firmware_loading_complete); + if (!firmware) { + pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name); + rtlpriv->max_fw_size = 0; + return; + } + if (firmware->size > rtlpriv->max_fw_size) { + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "Firmware is too big!\n"); + release_firmware(firmware); + return; + } + memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); + rtlpriv->rtlhal.fwsize = firmware->size; + release_firmware(firmware); + + err = ieee80211_register_hw(hw); + if (err) { + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "Can't register mac80211 hw\n"); + return; + } else { + rtlpriv->mac80211.mac80211_registered = 1; + } + set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); + + /*init rfkill */ + rtl_init_rfkill(hw); +} +EXPORT_SYMBOL(rtl_fw_cb); + /*mutex for start & stop is must here. */ static int rtl_op_start(struct ieee80211_hw *hw) { @@ -254,10 +296,12 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) * because that will cause nullfunc send by mac80211 * fail, and cause pkt loss, we have tested that 5mA * is worked very well */ - if (!rtlpriv->psc.multi_buffered) + if (!rtlpriv->psc.multi_buffered) { queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_work, MSECS(5)); + pr_info("In section\n"); + } } else { rtl_swlps_rf_awake(hw); rtlpriv->psc.sw_ps_enabled = false; diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h index 57569e0e3d47..2fe46a1b4f1f 100644 --- a/drivers/net/wireless/rtlwifi/core.h +++ b/drivers/net/wireless/rtlwifi/core.h @@ -40,4 +40,6 @@ #define RTL_SUPPORTED_CTRL_FILTER 0xFF extern const struct ieee80211_ops rtl_ops; +void rtl_fw_cb(const struct firmware *firmware, void *context); + #endif diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index e4d1dcfe8299..5cb2199435d2 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1565,6 +1565,9 @@ static void rtl_pci_stop(struct ieee80211_hw *hw) rtlpci->driver_is_goingto_unload = true; rtlpriv->cfg->ops->hw_disable(hw); + /* some things are not needed if firmware not available */ + if (!rtlpriv->max_fw_size) + return; rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF); spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); @@ -1779,6 +1782,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, rtlpriv = hw->priv; pcipriv = (void *)rtlpriv->priv; pcipriv->dev.pdev = pdev; + init_completion(&rtlpriv->firmware_loading_complete); /* init cfg & intf_ops */ rtlpriv->rtlhal.interface = INTF_PCI; @@ -1799,7 +1803,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, err = pci_request_regions(pdev, KBUILD_MODNAME); if (err) { RT_ASSERT(false, "Can't obtain PCI resources\n"); - return err; + goto fail2; } pmem_start = pci_resource_start(pdev, rtlpriv->cfg->bar_id); @@ -1862,15 +1866,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, goto fail3; } - err = ieee80211_register_hw(hw); - if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Can't register mac80211 hw\n"); - goto fail3; - } else { - rtlpriv->mac80211.mac80211_registered = 1; - } - err = sysfs_create_group(&pdev->dev.kobj, &rtl_attribute_group); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, @@ -1878,9 +1873,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, goto fail3; } - /*init rfkill */ - rtl_init_rfkill(hw); - rtlpci = rtl_pcidev(pcipriv); err = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt, IRQF_SHARED, KBUILD_MODNAME, hw); @@ -1889,24 +1881,22 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, "%s: failed to register IRQ handler\n", wiphy_name(hw->wiphy)); goto fail3; - } else { - rtlpci->irq_alloc = 1; } + rtlpci->irq_alloc = 1; - set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); return 0; fail3: pci_set_drvdata(pdev, NULL); rtl_deinit_core(hw); _rtl_pci_io_handler_release(hw); - ieee80211_free_hw(hw); if (rtlpriv->io.pci_mem_start != 0) pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start); fail2: pci_release_regions(pdev); + complete(&rtlpriv->firmware_loading_complete); fail1: @@ -1925,6 +1915,8 @@ void rtl_pci_disconnect(struct pci_dev *pdev) struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); struct rtl_mac *rtlmac = rtl_mac(rtlpriv); + /* just in case driver is removed before firmware callback */ + wait_for_completion(&rtlpriv->firmware_loading_complete); clear_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); sysfs_remove_group(&pdev->dev.kobj, &rtl_attribute_group); diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h index 99d81ede17b8..241448fc9ed5 100644 --- a/drivers/net/wireless/rtlwifi/pci.h +++ b/drivers/net/wireless/rtlwifi/pci.h @@ -239,7 +239,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, void rtl_pci_disconnect(struct pci_dev *pdev); int rtl_pci_suspend(struct device *dev); int rtl_pci_resume(struct device *dev); - static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr) { return readb((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index b151266ef9f6..15f86eaa1cd6 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -47,7 +47,8 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw) "Driver is already down!\n"); /*<2> Enable Adapter */ - rtlpriv->cfg->ops->hw_init(hw); + if (rtlpriv->cfg->ops->hw_init(hw)) + return 1; RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); /*<3> Enable Interrupt */ diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 82bbc8384aca..c20b3c30f62e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -257,10 +257,9 @@ int rtl92c_download_fw(struct ieee80211_hw *hw) u32 fwsize; enum version_8192c version = rtlhal->version; - if (!rtlhal->pfirmware) + if (rtlpriv->max_fw_size == 0 || !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; @@ -512,15 +511,8 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw, void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, u32 cmd_len, u8 *p_cmdbuffer) { - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u32 tmp_cmdbuf[2]; - if (rtlhal->fw_ready == false) { - RT_ASSERT(false, - "return H2C cmd because of Fw download fail!!!\n"); - return; - } - memset(tmp_cmdbuf, 0, 8); memcpy(tmp_cmdbuf, p_cmdbuffer, cmd_len); _rtl92c_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index c5aced459cd0..48c7b5d3fc5b 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -917,10 +917,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "Failed to download FW. Init HW without FW now..\n"); err = 1; - rtlhal->fw_ready = false; return err; - } else { - rtlhal->fw_ready = true; } rtlhal->last_hmeboxnum = 0; @@ -1193,7 +1190,6 @@ static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u8 u1b_tmp; u32 u4b_tmp; @@ -1204,7 +1200,7 @@ static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw) rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE0); - if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->fw_ready) + if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) rtl92c_firmware_selfreset(hw); rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, 0x51); rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index 460dc925b4e4..2c3b73366cd2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c @@ -91,9 +91,7 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) int err; struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - const struct firmware *firmware; struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - char *fw_name = NULL; rtl8192ce_bt_reg_init(hw); @@ -165,26 +163,20 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) /* request fw */ if (IS_VENDOR_UMC_A_CUT(rtlhal->version) && !IS_92C_SERIAL(rtlhal->version)) - fw_name = "rtlwifi/rtl8192cfwU.bin"; + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin"; else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) - fw_name = "rtlwifi/rtl8192cfwU_B.bin"; - else - fw_name = rtlpriv->cfg->fw_name; - err = request_firmware(&firmware, fw_name, rtlpriv->io.dev); + rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin"; + + rtlpriv->max_fw_size = 0x4000; + pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); + err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, + rtlpriv->io.dev, GFP_KERNEL, hw, + rtl_fw_cb); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Failed to request firmware!\n"); return 1; } - if (firmware->size > 0x4000) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Firmware is too big!\n"); - release_firmware(firmware); - return 1; - } - memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); - rtlpriv->rtlhal.fwsize = firmware->size; - release_firmware(firmware); return 0; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 7f171682d3d6..0c74d4f2eeb4 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -997,10 +997,7 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "Failed to download FW. Init HW without FW now..\n"); err = 1; - rtlhal->fw_ready = false; return err; - } else { - rtlhal->fw_ready = true; } rtlhal->last_hmeboxnum = 0; /* h2c */ _rtl92cu_phy_param_tab_init(hw); @@ -1094,23 +1091,21 @@ static void _ResetDigitalProcedure1(struct ieee80211_hw *hw, bool bWithoutHWSM) if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(1)) { /* reset MCU ready status */ rtl_write_byte(rtlpriv, REG_MCUFWDL, 0); - if (rtlhal->fw_ready) { - /* 8051 reset by self */ - rtl_write_byte(rtlpriv, REG_HMETFR+3, 0x20); - while ((retry_cnts++ < 100) && - (FEN_CPUEN & rtl_read_word(rtlpriv, - REG_SYS_FUNC_EN))) { - udelay(50); - } - if (retry_cnts >= 100) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "#####=> 8051 reset failed!.........................\n"); - /* if 8051 reset fail, reset MAC. */ - rtl_write_byte(rtlpriv, - REG_SYS_FUNC_EN + 1, - 0x50); - udelay(100); - } + /* 8051 reset by self */ + rtl_write_byte(rtlpriv, REG_HMETFR+3, 0x20); + while ((retry_cnts++ < 100) && + (FEN_CPUEN & rtl_read_word(rtlpriv, + REG_SYS_FUNC_EN))) { + udelay(50); + } + if (retry_cnts >= 100) { + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "#####=> 8051 reset failed!.........................\n"); + /* if 8051 reset fail, reset MAC. */ + rtl_write_byte(rtlpriv, + REG_SYS_FUNC_EN + 1, + 0x50); + udelay(100); } } /* Reset MAC and Enable 8051 */ diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index c04c3be5bd4e..82c85286ab2e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -53,7 +53,6 @@ MODULE_FIRMWARE("rtlwifi/rtl8192cufw.bin"); static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); - const struct firmware *firmware; int err; rtlpriv->dm.dm_initialgain_enable = true; @@ -61,29 +60,21 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->dm.disable_framebursting = false; rtlpriv->dm.thermalvalue = 0; rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug; - rtlpriv->rtlhal.pfirmware = vmalloc(0x4000); + + /* for firmware buf */ + rtlpriv->rtlhal.pfirmware = vzalloc(0x4000); if (!rtlpriv->rtlhal.pfirmware) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't alloc buffer for fw\n"); return 1; } - /* request fw */ - err = request_firmware(&firmware, rtlpriv->cfg->fw_name, - rtlpriv->io.dev); - if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Failed to request firmware!\n"); - return 1; - } - if (firmware->size > 0x4000) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Firmware is too big!\n"); - release_firmware(firmware); - return 1; - } - memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); - rtlpriv->rtlhal.fwsize = firmware->size; - release_firmware(firmware); + + pr_info("Loading firmware %s\n", rtlpriv->cfg->fw_name); + rtlpriv->max_fw_size = 0x4000; + err = request_firmware_nowait(THIS_MODULE, 1, + rtlpriv->cfg->fw_name, rtlpriv->io.dev, + GFP_KERNEL, hw, rtl_fw_cb); + return 0; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c index b59de75a3643..f548a8d0068d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c @@ -253,7 +253,7 @@ int rtl92d_download_fw(struct ieee80211_hw *hw) bool fw_downloaded = false, fwdl_in_process = false; unsigned long flags; - if (!rtlhal->pfirmware) + if (rtlpriv->max_fw_size == 0 || !rtlhal->pfirmware) return 1; fwsize = rtlhal->fwsize; pfwheader = (u8 *) rtlhal->pfirmware; @@ -532,14 +532,8 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, u32 cmd_len, u8 *cmdbuffer) { - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u32 tmp_cmdbuf[2]; - if (rtlhal->fw_ready == false) { - RT_ASSERT(false, - "return H2C cmd because of Fw download fail!!!\n"); - return; - } memset(tmp_cmdbuf, 0, 8); memcpy(tmp_cmdbuf, cmdbuffer, cmd_len); _rtl92d_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index 695bccb43750..7d877125db29 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -931,10 +931,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw) if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "Failed to download FW. Init HW without FW..\n"); - rtlhal->fw_ready = false; return 1; - } else { - rtlhal->fw_ready = true; } rtlhal->last_hmeboxnum = 0; rtlpriv->psc.fw_current_inpsmode = false; diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index bf625f9e632e..4898c502974d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -91,7 +91,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) u8 tid; struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - const struct firmware *firmware; static int header_print; rtlpriv->dm.dm_initialgain_enable = true; @@ -167,6 +166,15 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) else if (rtlpriv->psc.reg_fwctrl_lps == 3) rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE; + /* for early mode */ + rtlpriv->rtlhal.earlymode_enable = true; + for (tid = 0; tid < 8; tid++) + skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]); + + /* Only load firmware for first MAC */ + if (header_print) + return 0; + /* for firmware buf */ rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); if (!rtlpriv->rtlhal.pfirmware) { @@ -175,33 +183,21 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) return 1; } - if (!header_print) { - pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); - pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); - header_print++; - } + rtlpriv->max_fw_size = 0x8000; + pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); + pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); + header_print++; + /* request fw */ - err = request_firmware(&firmware, rtlpriv->cfg->fw_name, - rtlpriv->io.dev); + err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, + rtlpriv->io.dev, GFP_KERNEL, hw, + rtl_fw_cb); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Failed to request firmware!\n"); return 1; } - if (firmware->size > 0x8000) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Firmware is too big!\n"); - release_firmware(firmware); - return 1; - } - memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); - rtlpriv->rtlhal.fwsize = firmware->size; - release_firmware(firmware); - /* for early mode */ - rtlpriv->rtlhal.earlymode_enable = true; - for (tid = 0; tid < 8; tid++) - skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]); return 0; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c index 595ecd22ffa0..0d8bf5657008 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c @@ -364,7 +364,7 @@ int rtl92s_download_fw(struct ieee80211_hw *hw) u8 fwstatus = FW_STATUS_INIT; bool rtstatus = true; - if (!rtlhal->pfirmware) + if (rtlpriv->max_fw_size == 0 || !rtlhal->pfirmware) return 1; firmware = (struct rt_firmware *)rtlhal->pfirmware; diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index cbaf1f345c6e..22098c2f38f1 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -949,10 +949,9 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) rtstatus = rtl92s_download_fw(hw); if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - "Failed to download FW. Init HW without FW now... Please copy FW into /lib/firmware/rtlwifi\n"); - rtlhal->fw_ready = false; - } else { - rtlhal->fw_ready = true; + "Failed to download FW. Init HW without FW now... " + "Please copy FW into /lib/firmware/rtlwifi\n"); + return 1; } /* After FW download, we have to reset MAC register */ @@ -1215,9 +1214,14 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw) void rtl92se_disable_interrupt(struct ieee80211_hw *hw) { - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv; + struct rtl_pci *rtlpci; + rtlpriv = rtl_priv(hw); + /* if firmware not available, no interrupts */ + if (!rtlpriv || !rtlpriv->max_fw_size) + return; + rtlpci = rtl_pcidev(rtl_pcipriv(hw)); rtl_write_dword(rtlpriv, INTA_MASK, 0); rtl_write_dword(rtlpriv, INTA_MASK + 4, 0); diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/led.c b/drivers/net/wireless/rtlwifi/rtl8192se/led.c index ef4211bca587..44949b5cbb87 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/led.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/led.c @@ -76,10 +76,13 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) { - struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_priv *rtlpriv; struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); u8 ledcfg; + rtlpriv = rtl_priv(hw); + if (!rtlpriv || rtlpriv->max_fw_size) + return; RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n", LEDCFG, pled->ledpin); diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index 0c47310b39b9..ca38dd9f3564 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -30,6 +30,8 @@ #include "../wifi.h" #include "../core.h" #include "../pci.h" +#include "../base.h" +#include "../pci.h" #include "reg.h" #include "def.h" #include "phy.h" @@ -86,12 +88,53 @@ static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw) rtlpci->const_support_pciaspm = 2; } +static void rtl92se_fw_cb(const struct firmware *firmware, void *context) +{ + struct ieee80211_hw *hw = context; + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); + struct rt_firmware *pfirmware = NULL; + int err; + + RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, + "Firmware callback routine entered!\n"); + complete(&rtlpriv->firmware_loading_complete); + if (!firmware) { + pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name); + rtlpriv->max_fw_size = 0; + return; + } + if (firmware->size > rtlpriv->max_fw_size) { + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "Firmware is too big!\n"); + release_firmware(firmware); + return; + } + pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware; + memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size); + pfirmware->sz_fw_tmpbufferlen = firmware->size; + release_firmware(firmware); + + err = ieee80211_register_hw(hw); + if (err) { + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "Can't register mac80211 hw\n"); + return; + } else { + rtlpriv->mac80211.mac80211_registered = 1; + } + rtlpci->irq_alloc = 1; + set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); + + /*init rfkill */ + rtl_init_rfkill(hw); +} + static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - const struct firmware *firmware; - struct rt_firmware *pfirmware = NULL; int err = 0; u16 earlyrxthreshold = 7; @@ -189,27 +232,19 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) return 1; } + rtlpriv->max_fw_size = sizeof(struct rt_firmware); + pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" "Loading firmware %s\n", rtlpriv->cfg->fw_name); /* request fw */ - err = request_firmware(&firmware, rtlpriv->cfg->fw_name, - rtlpriv->io.dev); + err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, + rtlpriv->io.dev, GFP_KERNEL, hw, + rtl92se_fw_cb); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Failed to request firmware!\n"); return 1; } - if (firmware->size > sizeof(struct rt_firmware)) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "Firmware is too big!\n"); - release_firmware(firmware); - return 1; - } - - pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware; - memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size); - pfirmware->sz_fw_tmpbufferlen = firmware->size; - release_firmware(firmware); return err; } diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index e7a7ea96f42b..ffcf89fe45e4 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -664,15 +664,17 @@ static int rtl_usb_start(struct ieee80211_hw *hw) struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw)); err = rtlpriv->cfg->ops->hw_init(hw); - rtl_init_rx_config(hw); + if (!err) { + rtl_init_rx_config(hw); - /* Enable software */ - SET_USB_START(rtlusb); - /* should after adapter start and interrupt enable. */ - set_hal_start(rtlhal); + /* Enable software */ + SET_USB_START(rtlusb); + /* should after adapter start and interrupt enable. */ + set_hal_start(rtlhal); - /* Start bulk IN */ - _rtl_usb_receive(hw); + /* Start bulk IN */ + _rtl_usb_receive(hw); + } return err; } @@ -949,6 +951,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, return -ENOMEM; } rtlpriv = hw->priv; + init_completion(&rtlpriv->firmware_loading_complete); SET_IEEE80211_DEV(hw, &intf->dev); udev = interface_to_usbdev(intf); usb_get_dev(udev); @@ -982,24 +985,12 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, goto error_out; } - /*init rfkill */ - /* rtl_init_rfkill(hw); */ - - err = ieee80211_register_hw(hw); - if (err) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, - "Can't register mac80211 hw\n"); - goto error_out; - } else { - rtlpriv->mac80211.mac80211_registered = 1; - } - set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); return 0; error_out: rtl_deinit_core(hw); _rtl_usb_io_handler_release(hw); - ieee80211_free_hw(hw); usb_put_dev(udev); + complete(&rtlpriv->firmware_loading_complete); return -ENODEV; } EXPORT_SYMBOL(rtl_usb_probe); @@ -1013,6 +1004,9 @@ void rtl_usb_disconnect(struct usb_interface *intf) if (unlikely(!rtlpriv)) return; + + /* just in case driver is removed before firmware callback */ + wait_for_completion(&rtlpriv->firmware_loading_complete); /*ieee80211_unregister_hw will call ops_stop */ if (rtlmac->mac80211_registered == 1) { ieee80211_unregister_hw(hw); diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index 1e5fffb2db0b..b591614c3b9b 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h @@ -38,6 +38,7 @@ #include #include #include +#include #include "debug.h" #define RF_CHANGE_BY_INIT 0 @@ -1047,7 +1048,6 @@ struct rtl_hal { u16 fw_subversion; bool h2c_setinprogress; u8 last_hmeboxnum; - bool fw_ready; /*Reserve page start offset except beacon in TxQ. */ u8 fw_rsvdpage_startoffset; u8 h2c_txcmd_seq; @@ -1593,6 +1593,7 @@ struct rtl_debug { }; struct rtl_priv { + struct completion firmware_loading_complete; struct rtl_locks locks; struct rtl_works works; struct rtl_mac mac80211; @@ -1614,6 +1615,7 @@ struct rtl_priv { struct rtl_rate_priv *rate_priv; struct rtl_debug dbg; + int max_fw_size; /* *hal_cfg : for diff cards -- GitLab From ae1f23fb433ac0aaff8aeaa5a7b14348e9aa8277 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Tue, 31 Jan 2012 00:00:19 +0100 Subject: [PATCH 0274/1846] r8169: fix early queue wake-up. With infinite gratitude to Eric Dumazet for allowing me to identify the error. Signed-off-by: Francois Romieu Acked-by: Eric Dumazet Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index d039d39963ad..859554a03a09 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5559,7 +5559,18 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, mmiowb(); if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { + /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must + * not miss a ring update when it notices a stopped queue. + */ + smp_wmb(); netif_stop_queue(dev); + /* Sync with rtl_tx: + * - publish queue status and cur_tx ring index (write barrier) + * - refresh dirty_tx ring index (read barrier). + * May the current thread have a pessimistic view of the ring + * status and forget to wake up queue, a racing rtl_tx thread + * can't. + */ smp_mb(); if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS) netif_wake_queue(dev); @@ -5659,6 +5670,13 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) if (tp->dirty_tx != dirty_tx) { tp->dirty_tx = dirty_tx; + /* Sync with rtl8169_start_xmit: + * - publish dirty_tx ring index (write barrier) + * - refresh cur_tx ring index and queue status (read barrier) + * May the current thread miss the stopped queue condition, + * a racing xmit thread can only have a right view of the + * ring status. + */ smp_mb(); if (netif_queue_stopped(dev) && (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) { -- GitLab From 98ddf986fca17840e46e070354b7e2cd2169da15 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Tue, 31 Jan 2012 10:47:34 +0100 Subject: [PATCH 0275/1846] r8169: bh locking redux and task scheduling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - atomic bit operations are globally visible - pending status is always cleared before execution - scheduled works are either idempotent or only required to happen once after a series of originating events, say link events for instance Signed-off-by: Francois Romieu Suggested-by: Michał Mirosław Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 859554a03a09..118f6f6fcef3 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -3273,17 +3273,8 @@ static void rtl_phy_work(struct rtl8169_private *tp) static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag) { - spin_lock(&tp->lock); if (!test_and_set_bit(flag, tp->wk.flags)) schedule_work(&tp->wk.work); - spin_unlock(&tp->lock); -} - -static void rtl_schedule_task_bh(struct rtl8169_private *tp, enum rtl_flag flag) -{ - local_bh_disable(); - rtl_schedule_task(tp, flag); - local_bh_enable(); } static void rtl8169_phy_timer(unsigned long __opaque) @@ -3291,7 +3282,7 @@ static void rtl8169_phy_timer(unsigned long __opaque) struct net_device *dev = (struct net_device *)__opaque; struct rtl8169_private *tp = netdev_priv(dev); - rtl_schedule_task_bh(tp, RTL_FLAG_TASK_PHY_PENDING); + rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING); } #ifdef CONFIG_NET_POLL_CONTROLLER @@ -5635,7 +5626,7 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) rtl8169_hw_reset(tp); - rtl_schedule_task_bh(tp, RTL_FLAG_TASK_RESET_PENDING); + rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); } static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) @@ -5852,7 +5843,7 @@ static void rtl_slow_event_work(struct rtl8169_private *tp) /* Work around for rx fifo overflow */ case RTL_GIGA_MAC_VER_11: netif_stop_queue(dev); - rtl_schedule_task_bh(tp, RTL_FLAG_TASK_RESET_PENDING); + rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); default: break; } @@ -5894,10 +5885,7 @@ static void rtl_task(struct work_struct *work) for (i = 0; i < ARRAY_SIZE(rtl_work); i++) { bool pending; - spin_lock_bh(&tp->lock); pending = test_and_clear_bit(rtl_work[i].bitnr, tp->wk.flags); - spin_unlock_bh(&tp->lock); - if (pending) rtl_work[i].action(tp); } @@ -6116,7 +6104,7 @@ static void __rtl8169_resume(struct net_device *dev) tp->wk.enabled = true; - rtl_schedule_task_bh(tp, RTL_FLAG_TASK_RESET_PENDING); + rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); } static int rtl8169_resume(struct device *device) -- GitLab From 6c4a70c5f286077e78b294b3f3a93dc45c40db89 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Tue, 31 Jan 2012 10:56:44 +0100 Subject: [PATCH 0276/1846] r8169: move task enable boolean to bitfield. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simpler, more consistent, with negligible cost in non-critical paths. Signed-off-by: Francois Romieu Suggested-by: Michał Mirosław Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 118f6f6fcef3..679711e4c3c4 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -668,6 +668,7 @@ struct rtl8169_counters { }; enum rtl_flag { + RTL_FLAG_TASK_ENABLED, RTL_FLAG_TASK_SLOW_PENDING, RTL_FLAG_TASK_RESET_PENDING, RTL_FLAG_TASK_PHY_PENDING, @@ -725,7 +726,6 @@ struct rtl8169_private { DECLARE_BITMAP(flags, RTL_FLAG_MAX); struct mutex mutex; struct work_struct work; - bool enabled; } wk; unsigned features; @@ -4352,7 +4352,7 @@ static int rtl8169_open(struct net_device *dev) rtl_lock_work(tp); - tp->wk.enabled = true; + set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); napi_enable(&tp->napi); @@ -5879,7 +5879,8 @@ static void rtl_task(struct work_struct *work) rtl_lock_work(tp); - if (!netif_running(dev) || !tp->wk.enabled) + if (!netif_running(dev) || + !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) goto out_unlock; for (i = 0; i < ARRAY_SIZE(rtl_work); i++) { @@ -5977,7 +5978,7 @@ static int rtl8169_close(struct net_device *dev) rtl8169_update_counters(dev); rtl_lock_work(tp); - tp->wk.enabled = false; + clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); rtl8169_down(dev); rtl_unlock_work(tp); @@ -6076,7 +6077,7 @@ static void rtl8169_net_suspend(struct net_device *dev) rtl_lock_work(tp); napi_disable(&tp->napi); - tp->wk.enabled = false; + clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); rtl_unlock_work(tp); rtl_pll_power_down(tp); @@ -6102,7 +6103,7 @@ static void __rtl8169_resume(struct net_device *dev) rtl_pll_power_up(tp); - tp->wk.enabled = true; + set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); } -- GitLab From 934714d088f35b81edafdce89397969baf77fb8a Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Tue, 31 Jan 2012 11:09:21 +0100 Subject: [PATCH 0277/1846] r8169: avoid a useless work scheduling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Francois Romieu Suggested-by: Michał Mirosław Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 679711e4c3c4..0377ffaa8bee 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5843,7 +5843,8 @@ static void rtl_slow_event_work(struct rtl8169_private *tp) /* Work around for rx fifo overflow */ case RTL_GIGA_MAC_VER_11: netif_stop_queue(dev); - rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); + /* XXX - Hack alert. See rtl_task(). */ + set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags); default: break; } @@ -5868,6 +5869,7 @@ static void rtl_task(struct work_struct *work) int bitnr; void (*action)(struct rtl8169_private *); } rtl_work[] = { + /* XXX - keep rtl_slow_event_work() as first element. */ { RTL_FLAG_TASK_SLOW_PENDING, rtl_slow_event_work }, { RTL_FLAG_TASK_RESET_PENDING, rtl_reset_work }, { RTL_FLAG_TASK_PHY_PENDING, rtl_phy_work } -- GitLab From 6c05d25267ebb371c4311de6904f740342e82f7c Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Tue, 31 Jan 2012 11:20:34 +0100 Subject: [PATCH 0278/1846] r8169: spinlock redux. rtl8169_get_regs operates under RTNL and rtl task mutex whereas rtl_set_rx_mode is either called under RTNL or rtl task mutex protection. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 0377ffaa8bee..707742207c75 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -680,7 +680,6 @@ struct rtl8169_private { struct pci_dev *pci_dev; struct net_device *dev; struct napi_struct napi; - spinlock_t lock; u32 msg_enable; u16 txd_version; u16 mac_version; @@ -1723,9 +1722,7 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, regs->len = R8169_REGS_SIZE; rtl_lock_work(tp); - spin_lock_bh(&tp->lock); memcpy_fromio(p, tp->mmio_addr, regs->len); - spin_unlock_bh(&tp->lock); rtl_unlock_work(tp); } @@ -4151,7 +4148,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->do_ioctl = rtl_xmii_ioctl; } - spin_lock_init(&tp->lock); mutex_init(&tp->wk.mutex); /* Get MAC address */ @@ -6031,8 +6027,6 @@ static void rtl_set_rx_mode(struct net_device *dev) } } - spin_lock_bh(&tp->lock); - tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode; if (tp->mac_version > RTL_GIGA_MAC_VER_06) { @@ -6046,8 +6040,6 @@ static void rtl_set_rx_mode(struct net_device *dev) RTL_W32(MAR0 + 0, mc_filter[0]); RTL_W32(RxConfig, tmp); - - spin_unlock_bh(&tp->lock); } /** -- GitLab From a2d91241a80ec9bbc5ab24b9a2c4d730b3fa5730 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 31 Jan 2012 01:04:42 +0000 Subject: [PATCH 0279/1846] tcp: md5: remove obsolete md5_add() method We no longer use md5_add() method from struct tcp_sock_af_ops Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/net/tcp.h | 4 ---- net/ipv4/tcp_ipv4.c | 8 -------- net/ipv6/tcp_ipv6.c | 9 --------- 3 files changed, 21 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 0118ea999f67..3c903462adf5 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1462,10 +1462,6 @@ struct tcp_sock_af_ops { const struct sock *sk, const struct request_sock *req, const struct sk_buff *skb); - int (*md5_add) (struct sock *sk, - struct sock *addr_sk, - u8 *newkey, - u8 len); int (*md5_parse) (struct sock *sk, char __user *optval, int optlen); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 337ba4cca052..345e24928fa6 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -967,13 +967,6 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, } EXPORT_SYMBOL(tcp_v4_md5_do_add); -static int tcp_v4_md5_add_func(struct sock *sk, struct sock *addr_sk, - u8 *newkey, u8 newkeylen) -{ - return tcp_v4_md5_do_add(sk, inet_sk(addr_sk)->inet_daddr, - newkey, newkeylen); -} - int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) { struct tcp_sock *tp = tcp_sk(sk); @@ -1853,7 +1846,6 @@ EXPORT_SYMBOL(ipv4_specific); static const struct tcp_sock_af_ops tcp_sock_ipv4_specific = { .md5_lookup = tcp_v4_md5_lookup, .calc_md5_hash = tcp_v4_md5_hash_skb, - .md5_add = tcp_v4_md5_add_func, .md5_parse = tcp_v4_parse_md5_keys, }; #endif diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 3edd05ae4388..f37769ea6375 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -626,13 +626,6 @@ static int tcp_v6_md5_do_add(struct sock *sk, const struct in6_addr *peer, return 0; } -static int tcp_v6_md5_add_func(struct sock *sk, struct sock *addr_sk, - u8 *newkey, __u8 newkeylen) -{ - return tcp_v6_md5_do_add(sk, &inet6_sk(addr_sk)->daddr, - newkey, newkeylen); -} - static int tcp_v6_md5_do_del(struct sock *sk, const struct in6_addr *peer) { struct tcp_sock *tp = tcp_sk(sk); @@ -1898,7 +1891,6 @@ static const struct inet_connection_sock_af_ops ipv6_specific = { static const struct tcp_sock_af_ops tcp_sock_ipv6_specific = { .md5_lookup = tcp_v6_md5_lookup, .calc_md5_hash = tcp_v6_md5_hash_skb, - .md5_add = tcp_v6_md5_add_func, .md5_parse = tcp_v6_parse_md5_keys, }; #endif @@ -1930,7 +1922,6 @@ static const struct inet_connection_sock_af_ops ipv6_mapped = { static const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific = { .md5_lookup = tcp_v4_md5_lookup, .calc_md5_hash = tcp_v4_md5_hash_skb, - .md5_add = tcp_v6_md5_add_func, .md5_parse = tcp_v6_parse_md5_keys, }; #endif -- GitLab From a915da9b69273815527ccb3789421cb7027b545b Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 31 Jan 2012 05:18:33 +0000 Subject: [PATCH 0280/1846] tcp: md5: rcu conversion In order to be able to support proper RST messages for TCP MD5 flows, we need to allow access to MD5 keys without locking listener socket. This conversion is a nice cleanup, and shrinks size of timewait sockets by 80 bytes. IPv6 code reuses generic code found in IPv4 instead of duplicating it. Control path uses GFP_KERNEL allocations instead of GFP_ATOMIC. Signed-off-by: Eric Dumazet Cc: Shawn Lu Signed-off-by: David S. Miller --- include/linux/tcp.h | 3 +- include/net/tcp.h | 61 +++++------ net/ipv4/tcp_ipv4.c | 227 ++++++++++++++++----------------------- net/ipv4/tcp_minisocks.c | 12 +-- net/ipv6/tcp_ipv6.c | 173 +++-------------------------- 5 files changed, 141 insertions(+), 335 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 46a85c9e1f25..c2025f159641 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -486,8 +486,7 @@ struct tcp_timewait_sock { u32 tw_ts_recent; long tw_ts_recent_stamp; #ifdef CONFIG_TCP_MD5SIG - u16 tw_md5_keylen; - u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN]; + struct tcp_md5sig_key *tw_md5_key; #endif /* Few sockets in timewait have cookies; in that case, then this * object holds a reference to them (tw_cookie_values->kref). diff --git a/include/net/tcp.h b/include/net/tcp.h index 3c903462adf5..10ae4c7b6b4f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1130,35 +1130,26 @@ static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) /* MD5 Signature */ struct crypto_hash; +union tcp_md5_addr { + struct in_addr a4; +#if IS_ENABLED(CONFIG_IPV6) + struct in6_addr a6; +#endif +}; + /* - key database */ struct tcp_md5sig_key { - u8 *key; + struct hlist_node node; u8 keylen; -}; - -struct tcp4_md5sig_key { - struct tcp_md5sig_key base; - __be32 addr; -}; - -struct tcp6_md5sig_key { - struct tcp_md5sig_key base; -#if 0 - u32 scope_id; /* XXX */ -#endif - struct in6_addr addr; + u8 family; /* AF_INET or AF_INET6 */ + union tcp_md5_addr addr; + u8 key[TCP_MD5SIG_MAXKEYLEN]; + struct rcu_head rcu; }; /* - sock block */ struct tcp_md5sig_info { - struct tcp4_md5sig_key *keys4; -#if IS_ENABLED(CONFIG_IPV6) - struct tcp6_md5sig_key *keys6; - u32 entries6; - u32 alloced6; -#endif - u32 entries4; - u32 alloced4; + struct hlist_head head; }; /* - pseudo header */ @@ -1195,19 +1186,25 @@ extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, const struct sock *sk, const struct request_sock *req, const struct sk_buff *skb); -extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk, - struct sock *addr_sk); -extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, - u8 newkeylen); -extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr); +extern int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, + int family, const u8 *newkey, + u8 newkeylen, gfp_t gfp); +extern int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, + int family); +extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, + struct sock *addr_sk); #ifdef CONFIG_TCP_MD5SIG -#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ - &(struct tcp_md5sig_key) { \ - .key = (twsk)->tw_md5_key, \ - .keylen = (twsk)->tw_md5_keylen, \ - } : NULL) +extern struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, + const union tcp_md5_addr *addr, int family); +#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key) #else +static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, + const union tcp_md5_addr *addr, + int family) +{ + return NULL; +} #define tcp_twsk_md5_key(twsk) NULL #endif diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 345e24928fa6..1d5fd82c5c08 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -90,16 +90,8 @@ EXPORT_SYMBOL(sysctl_tcp_low_latency); #ifdef CONFIG_TCP_MD5SIG -static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, - __be32 addr); -static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, +static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key, __be32 daddr, __be32 saddr, const struct tcphdr *th); -#else -static inline -struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) -{ - return NULL; -} #endif struct inet_hashinfo tcp_hashinfo; @@ -631,7 +623,9 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) arg.iov[0].iov_len = sizeof(rep.th); #ifdef CONFIG_TCP_MD5SIG - key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->saddr) : NULL; + key = sk ? tcp_md5_do_lookup(sk, + (union tcp_md5_addr *)&ip_hdr(skb)->saddr, + AF_INET) : NULL; if (key) { rep.opt[0] = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | @@ -759,7 +753,8 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent, 0, - tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr), + tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&ip_hdr(skb)->daddr, + AF_INET), inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, ip_hdr(skb)->tos); } @@ -876,146 +871,124 @@ static struct ip_options_rcu *tcp_v4_save_options(struct sock *sk, */ /* Find the Key structure for an address. */ -static struct tcp_md5sig_key * - tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) +struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, + const union tcp_md5_addr *addr, + int family) { struct tcp_sock *tp = tcp_sk(sk); - int i; + struct tcp_md5sig_key *key; + struct hlist_node *pos; + unsigned int size = sizeof(struct in_addr); - if (!tp->md5sig_info || !tp->md5sig_info->entries4) + if (!tp->md5sig_info) return NULL; - for (i = 0; i < tp->md5sig_info->entries4; i++) { - if (tp->md5sig_info->keys4[i].addr == addr) - return &tp->md5sig_info->keys4[i].base; +#if IS_ENABLED(CONFIG_IPV6) + if (family == AF_INET6) + size = sizeof(struct in6_addr); +#endif + hlist_for_each_entry_rcu(key, pos, &tp->md5sig_info->head, node) { + if (key->family != family) + continue; + if (!memcmp(&key->addr, addr, size)) + return key; } return NULL; } +EXPORT_SYMBOL(tcp_md5_do_lookup); struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, struct sock *addr_sk) { - return tcp_v4_md5_do_lookup(sk, inet_sk(addr_sk)->inet_daddr); + union tcp_md5_addr *addr; + + addr = (union tcp_md5_addr *)&inet_sk(addr_sk)->inet_daddr; + return tcp_md5_do_lookup(sk, addr, AF_INET); } EXPORT_SYMBOL(tcp_v4_md5_lookup); static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk, struct request_sock *req) { - return tcp_v4_md5_do_lookup(sk, inet_rsk(req)->rmt_addr); + union tcp_md5_addr *addr; + + addr = (union tcp_md5_addr *)&inet_rsk(req)->rmt_addr; + return tcp_md5_do_lookup(sk, addr, AF_INET); } /* This can be called on a newly created socket, from other files */ -int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, - u8 *newkey, u8 newkeylen) +int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, + int family, const u8 *newkey, u8 newkeylen, gfp_t gfp) { /* Add Key to the list */ struct tcp_md5sig_key *key; struct tcp_sock *tp = tcp_sk(sk); - struct tcp4_md5sig_key *keys; + struct tcp_md5sig_info *md5sig; - key = tcp_v4_md5_do_lookup(sk, addr); + key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET); if (key) { /* Pre-existing entry - just update that one. */ - kfree(key->key); - key->key = newkey; + memcpy(key->key, newkey, newkeylen); key->keylen = newkeylen; - } else { - struct tcp_md5sig_info *md5sig; - - if (!tp->md5sig_info) { - tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info), - GFP_ATOMIC); - if (!tp->md5sig_info) { - kfree(newkey); - return -ENOMEM; - } - sk_nocaps_add(sk, NETIF_F_GSO_MASK); - } + return 0; + } - md5sig = tp->md5sig_info; - if (md5sig->entries4 == 0 && - tcp_alloc_md5sig_pool(sk) == NULL) { - kfree(newkey); + md5sig = tp->md5sig_info; + if (!md5sig) { + md5sig = kmalloc(sizeof(*md5sig), gfp); + if (!md5sig) return -ENOMEM; - } - - if (md5sig->alloced4 == md5sig->entries4) { - keys = kmalloc((sizeof(*keys) * - (md5sig->entries4 + 1)), GFP_ATOMIC); - if (!keys) { - kfree(newkey); - if (md5sig->entries4 == 0) - tcp_free_md5sig_pool(); - return -ENOMEM; - } - if (md5sig->entries4) - memcpy(keys, md5sig->keys4, - sizeof(*keys) * md5sig->entries4); + sk_nocaps_add(sk, NETIF_F_GSO_MASK); + INIT_HLIST_HEAD(&md5sig->head); + tp->md5sig_info = md5sig; + } - /* Free old key list, and reference new one */ - kfree(md5sig->keys4); - md5sig->keys4 = keys; - md5sig->alloced4++; - } - md5sig->entries4++; - md5sig->keys4[md5sig->entries4 - 1].addr = addr; - md5sig->keys4[md5sig->entries4 - 1].base.key = newkey; - md5sig->keys4[md5sig->entries4 - 1].base.keylen = newkeylen; + key = kmalloc(sizeof(*key), gfp); + if (!key) + return -ENOMEM; + if (hlist_empty(&md5sig->head) && !tcp_alloc_md5sig_pool(sk)) { + kfree(key); + return -ENOMEM; } + + memcpy(key->key, newkey, newkeylen); + key->keylen = newkeylen; + key->family = family; + memcpy(&key->addr, addr, + (family == AF_INET6) ? sizeof(struct in6_addr) : + sizeof(struct in_addr)); + hlist_add_head_rcu(&key->node, &md5sig->head); return 0; } -EXPORT_SYMBOL(tcp_v4_md5_do_add); +EXPORT_SYMBOL(tcp_md5_do_add); -int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) +int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family) { struct tcp_sock *tp = tcp_sk(sk); - int i; - - for (i = 0; i < tp->md5sig_info->entries4; i++) { - if (tp->md5sig_info->keys4[i].addr == addr) { - /* Free the key */ - kfree(tp->md5sig_info->keys4[i].base.key); - tp->md5sig_info->entries4--; - - if (tp->md5sig_info->entries4 == 0) { - kfree(tp->md5sig_info->keys4); - tp->md5sig_info->keys4 = NULL; - tp->md5sig_info->alloced4 = 0; - tcp_free_md5sig_pool(); - } else if (tp->md5sig_info->entries4 != i) { - /* Need to do some manipulation */ - memmove(&tp->md5sig_info->keys4[i], - &tp->md5sig_info->keys4[i+1], - (tp->md5sig_info->entries4 - i) * - sizeof(struct tcp4_md5sig_key)); - } - return 0; - } - } - return -ENOENT; + struct tcp_md5sig_key *key; + + key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET); + if (!key) + return -ENOENT; + hlist_del_rcu(&key->node); + kfree_rcu(key, rcu); + if (hlist_empty(&tp->md5sig_info->head)) + tcp_free_md5sig_pool(); + return 0; } -EXPORT_SYMBOL(tcp_v4_md5_do_del); +EXPORT_SYMBOL(tcp_md5_do_del); -static void tcp_v4_clear_md5_list(struct sock *sk) +void tcp_clear_md5_list(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); + struct tcp_md5sig_key *key; + struct hlist_node *pos, *n; - /* Free each key, then the set of key keys, - * the crypto element, and then decrement our - * hold on the last resort crypto. - */ - if (tp->md5sig_info->entries4) { - int i; - for (i = 0; i < tp->md5sig_info->entries4; i++) - kfree(tp->md5sig_info->keys4[i].base.key); - tp->md5sig_info->entries4 = 0; + if (!hlist_empty(&tp->md5sig_info->head)) tcp_free_md5sig_pool(); - } - if (tp->md5sig_info->keys4) { - kfree(tp->md5sig_info->keys4); - tp->md5sig_info->keys4 = NULL; - tp->md5sig_info->alloced4 = 0; + hlist_for_each_entry_safe(key, pos, n, &tp->md5sig_info->head, node) { + hlist_del_rcu(&key->node); + kfree_rcu(key, rcu); } } @@ -1024,7 +997,6 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval, { struct tcp_md5sig cmd; struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; - u8 *newkey; if (optlen < sizeof(cmd)) return -EINVAL; @@ -1038,29 +1010,16 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval, if (!cmd.tcpm_key || !cmd.tcpm_keylen) { if (!tcp_sk(sk)->md5sig_info) return -ENOENT; - return tcp_v4_md5_do_del(sk, sin->sin_addr.s_addr); + return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr, + AF_INET); } if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) return -EINVAL; - if (!tcp_sk(sk)->md5sig_info) { - struct tcp_sock *tp = tcp_sk(sk); - struct tcp_md5sig_info *p; - - p = kzalloc(sizeof(*p), sk->sk_allocation); - if (!p) - return -EINVAL; - - tp->md5sig_info = p; - sk_nocaps_add(sk, NETIF_F_GSO_MASK); - } - - newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, sk->sk_allocation); - if (!newkey) - return -ENOMEM; - return tcp_v4_md5_do_add(sk, sin->sin_addr.s_addr, - newkey, cmd.tcpm_keylen); + return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr, + AF_INET, cmd.tcpm_key, cmd.tcpm_keylen, + GFP_KERNEL); } static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, @@ -1086,7 +1045,7 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp)); } -static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, +static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key, __be32 daddr, __be32 saddr, const struct tcphdr *th) { struct tcp_md5sig_pool *hp; @@ -1186,7 +1145,8 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) int genhash; unsigned char newhash[16]; - hash_expected = tcp_v4_md5_do_lookup(sk, iph->saddr); + hash_expected = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&iph->saddr, + AF_INET); hash_location = tcp_parse_md5sig_option(th); /* We've parsed the options - do we have a hash? */ @@ -1474,7 +1434,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, #ifdef CONFIG_TCP_MD5SIG /* Copy over the MD5 key from the original socket */ - key = tcp_v4_md5_do_lookup(sk, newinet->inet_daddr); + key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&newinet->inet_daddr, + AF_INET); if (key != NULL) { /* * We're using one, so create a matching key @@ -1482,10 +1443,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, * memory, then we end up not copying the key * across. Shucks. */ - char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); - if (newkey != NULL) - tcp_v4_md5_do_add(newsk, newinet->inet_daddr, - newkey, key->keylen); + tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newinet->inet_daddr, + AF_INET, key->key, key->keylen, GFP_ATOMIC); sk_nocaps_add(newsk, NETIF_F_GSO_MASK); } #endif @@ -1934,7 +1893,7 @@ void tcp_v4_destroy_sock(struct sock *sk) #ifdef CONFIG_TCP_MD5SIG /* Clean up the MD5 key list, if any */ if (tp->md5sig_info) { - tcp_v4_clear_md5_list(sk); + tcp_clear_md5_list(sk); kfree(tp->md5sig_info); tp->md5sig_info = NULL; } diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 550e755747e0..3cabafb5cdd1 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -359,13 +359,11 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) */ do { struct tcp_md5sig_key *key; - memset(tcptw->tw_md5_key, 0, sizeof(tcptw->tw_md5_key)); - tcptw->tw_md5_keylen = 0; + tcptw->tw_md5_key = NULL; key = tp->af_specific->md5_lookup(sk, sk); if (key != NULL) { - memcpy(&tcptw->tw_md5_key, key->key, key->keylen); - tcptw->tw_md5_keylen = key->keylen; - if (tcp_alloc_md5sig_pool(sk) == NULL) + tcptw->tw_md5_key = kmemdup(key, sizeof(*key), GFP_ATOMIC); + if (tcptw->tw_md5_key && tcp_alloc_md5sig_pool(sk) == NULL) BUG(); } } while (0); @@ -405,8 +403,10 @@ void tcp_twsk_destructor(struct sock *sk) { #ifdef CONFIG_TCP_MD5SIG struct tcp_timewait_sock *twsk = tcp_twsk(sk); - if (twsk->tw_md5_keylen) + if (twsk->tw_md5_key) { tcp_free_md5sig_pool(); + kfree_rcu(twsk->tw_md5_key, rcu); + } #endif } EXPORT_SYMBOL_GPL(tcp_twsk_destructor); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index f37769ea6375..bec41f9a6413 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -540,19 +540,7 @@ static void tcp_v6_reqsk_destructor(struct request_sock *req) static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk, const struct in6_addr *addr) { - struct tcp_sock *tp = tcp_sk(sk); - int i; - - BUG_ON(tp == NULL); - - if (!tp->md5sig_info || !tp->md5sig_info->entries6) - return NULL; - - for (i = 0; i < tp->md5sig_info->entries6; i++) { - if (ipv6_addr_equal(&tp->md5sig_info->keys6[i].addr, addr)) - return &tp->md5sig_info->keys6[i].base; - } - return NULL; + return tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6); } static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk, @@ -567,129 +555,11 @@ static struct tcp_md5sig_key *tcp_v6_reqsk_md5_lookup(struct sock *sk, return tcp_v6_md5_do_lookup(sk, &inet6_rsk(req)->rmt_addr); } -static int tcp_v6_md5_do_add(struct sock *sk, const struct in6_addr *peer, - char *newkey, u8 newkeylen) -{ - /* Add key to the list */ - struct tcp_md5sig_key *key; - struct tcp_sock *tp = tcp_sk(sk); - struct tcp6_md5sig_key *keys; - - key = tcp_v6_md5_do_lookup(sk, peer); - if (key) { - /* modify existing entry - just update that one */ - kfree(key->key); - key->key = newkey; - key->keylen = newkeylen; - } else { - /* reallocate new list if current one is full. */ - if (!tp->md5sig_info) { - tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info), GFP_ATOMIC); - if (!tp->md5sig_info) { - kfree(newkey); - return -ENOMEM; - } - sk_nocaps_add(sk, NETIF_F_GSO_MASK); - } - if (tp->md5sig_info->entries6 == 0 && - tcp_alloc_md5sig_pool(sk) == NULL) { - kfree(newkey); - return -ENOMEM; - } - if (tp->md5sig_info->alloced6 == tp->md5sig_info->entries6) { - keys = kmalloc((sizeof (tp->md5sig_info->keys6[0]) * - (tp->md5sig_info->entries6 + 1)), GFP_ATOMIC); - - if (!keys) { - kfree(newkey); - if (tp->md5sig_info->entries6 == 0) - tcp_free_md5sig_pool(); - return -ENOMEM; - } - - if (tp->md5sig_info->entries6) - memmove(keys, tp->md5sig_info->keys6, - (sizeof (tp->md5sig_info->keys6[0]) * - tp->md5sig_info->entries6)); - - kfree(tp->md5sig_info->keys6); - tp->md5sig_info->keys6 = keys; - tp->md5sig_info->alloced6++; - } - - tp->md5sig_info->keys6[tp->md5sig_info->entries6].addr = *peer; - tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.key = newkey; - tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.keylen = newkeylen; - - tp->md5sig_info->entries6++; - } - return 0; -} - -static int tcp_v6_md5_do_del(struct sock *sk, const struct in6_addr *peer) -{ - struct tcp_sock *tp = tcp_sk(sk); - int i; - - for (i = 0; i < tp->md5sig_info->entries6; i++) { - if (ipv6_addr_equal(&tp->md5sig_info->keys6[i].addr, peer)) { - /* Free the key */ - kfree(tp->md5sig_info->keys6[i].base.key); - tp->md5sig_info->entries6--; - - if (tp->md5sig_info->entries6 == 0) { - kfree(tp->md5sig_info->keys6); - tp->md5sig_info->keys6 = NULL; - tp->md5sig_info->alloced6 = 0; - tcp_free_md5sig_pool(); - } else { - /* shrink the database */ - if (tp->md5sig_info->entries6 != i) - memmove(&tp->md5sig_info->keys6[i], - &tp->md5sig_info->keys6[i+1], - (tp->md5sig_info->entries6 - i) - * sizeof (tp->md5sig_info->keys6[0])); - } - return 0; - } - } - return -ENOENT; -} - -static void tcp_v6_clear_md5_list (struct sock *sk) -{ - struct tcp_sock *tp = tcp_sk(sk); - int i; - - if (tp->md5sig_info->entries6) { - for (i = 0; i < tp->md5sig_info->entries6; i++) - kfree(tp->md5sig_info->keys6[i].base.key); - tp->md5sig_info->entries6 = 0; - tcp_free_md5sig_pool(); - } - - kfree(tp->md5sig_info->keys6); - tp->md5sig_info->keys6 = NULL; - tp->md5sig_info->alloced6 = 0; - - if (tp->md5sig_info->entries4) { - for (i = 0; i < tp->md5sig_info->entries4; i++) - kfree(tp->md5sig_info->keys4[i].base.key); - tp->md5sig_info->entries4 = 0; - tcp_free_md5sig_pool(); - } - - kfree(tp->md5sig_info->keys4); - tp->md5sig_info->keys4 = NULL; - tp->md5sig_info->alloced4 = 0; -} - static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval, int optlen) { struct tcp_md5sig cmd; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr; - u8 *newkey; if (optlen < sizeof(cmd)) return -EINVAL; @@ -704,33 +574,21 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval, if (!tcp_sk(sk)->md5sig_info) return -ENOENT; if (ipv6_addr_v4mapped(&sin6->sin6_addr)) - return tcp_v4_md5_do_del(sk, sin6->sin6_addr.s6_addr32[3]); - return tcp_v6_md5_do_del(sk, &sin6->sin6_addr); + return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3], + AF_INET); + return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr, + AF_INET6); } if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) return -EINVAL; - if (!tcp_sk(sk)->md5sig_info) { - struct tcp_sock *tp = tcp_sk(sk); - struct tcp_md5sig_info *p; - - p = kzalloc(sizeof(struct tcp_md5sig_info), GFP_KERNEL); - if (!p) - return -ENOMEM; - - tp->md5sig_info = p; - sk_nocaps_add(sk, NETIF_F_GSO_MASK); - } + if (ipv6_addr_v4mapped(&sin6->sin6_addr)) + return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3], + AF_INET, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL); - newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL); - if (!newkey) - return -ENOMEM; - if (ipv6_addr_v4mapped(&sin6->sin6_addr)) { - return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3], - newkey, cmd.tcpm_keylen); - } - return tcp_v6_md5_do_add(sk, &sin6->sin6_addr, newkey, cmd.tcpm_keylen); + return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr, + AF_INET6, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL); } static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, @@ -1503,10 +1361,8 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, * memory, then we end up not copying the key * across. Shucks. */ - char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); - if (newkey != NULL) - tcp_v6_md5_do_add(newsk, &newnp->daddr, - newkey, key->keylen); + tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newnp->daddr, + AF_INET6, key->key, key->keylen, GFP_ATOMIC); } #endif @@ -1995,11 +1851,6 @@ static int tcp_v6_init_sock(struct sock *sk) static void tcp_v6_destroy_sock(struct sock *sk) { -#ifdef CONFIG_TCP_MD5SIG - /* Clean up the MD5 key list */ - if (tcp_sk(sk)->md5sig_info) - tcp_v6_clear_md5_list(sk); -#endif tcp_v4_destroy_sock(sk); inet6_destroy_sock(sk); } -- GitLab From cca4d5adcff515b4bf5402dc23792f5123872906 Mon Sep 17 00:00:00 2001 From: Santosh Sajjan Date: Mon, 30 Jan 2012 22:02:26 +0200 Subject: [PATCH 0281/1846] ath6kl: Workaround to support Deep Sleep with MSM. Set the host pm flag MMC_PM_WAKE_SDIO_IRQ to allow host to disable the sdc2_clk and sdc2_h_clk,so that the MSM device enter into TCXO shutdown. Signed-off-by: Santosh Sajjan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 07dcf00ca1a7..4febee723495 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -856,6 +856,19 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) if (ret) goto cut_pwr; + /* + * Workaround to support Deep Sleep with MSM, set the host pm + * flag as MMC_PM_WAKE_SDIO_IRQ to allow SDCC deiver to disable + * the sdc2_clock and internally allows MSM to enter + * TCXO shutdown properly. + */ + if ((flags & MMC_PM_WAKE_SDIO_IRQ)) { + ret = sdio_set_host_pm_flags(func, + MMC_PM_WAKE_SDIO_IRQ); + if (ret) + goto cut_pwr; + } + ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP, NULL); if (ret) -- GitLab From 5f3d9cb2962967d9d7e03abb4a7ca275a9a3fea5 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 31 Jan 2012 10:56:48 +0000 Subject: [PATCH 0282/1846] tcp: md5: use sock_kmalloc() to limit md5 keys There is no limit on number of MD5 keys an application can attach to a tcp socket. This patch adds a per tcp socket limit based on /proc/sys/net/core/optmem_max With current default optmem_max values, this allows about 150 keys on 64bit arches, and 88 keys on 32bit arches. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- net/ipv4/tcp_ipv4.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 1d5fd82c5c08..da5d3226771b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -943,11 +943,11 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, tp->md5sig_info = md5sig; } - key = kmalloc(sizeof(*key), gfp); + key = sock_kmalloc(sk, sizeof(*key), gfp); if (!key) return -ENOMEM; if (hlist_empty(&md5sig->head) && !tcp_alloc_md5sig_pool(sk)) { - kfree(key); + sock_kfree_s(sk, key, sizeof(*key)); return -ENOMEM; } @@ -971,6 +971,7 @@ int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family) if (!key) return -ENOENT; hlist_del_rcu(&key->node); + atomic_sub(sizeof(*key), &sk->sk_omem_alloc); kfree_rcu(key, rcu); if (hlist_empty(&tp->md5sig_info->head)) tcp_free_md5sig_pool(); @@ -988,6 +989,7 @@ void tcp_clear_md5_list(struct sock *sk) tcp_free_md5sig_pool(); hlist_for_each_entry_safe(key, pos, n, &tp->md5sig_info->head, node) { hlist_del_rcu(&key->node); + atomic_sub(sizeof(*key), &sk->sk_omem_alloc); kfree_rcu(key, rcu); } } -- GitLab From e404decb0fb017be80552adee894b35307b6c7b4 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 29 Jan 2012 12:56:23 +0000 Subject: [PATCH 0283/1846] drivers/net: Remove unnecessary k.alloc/v.alloc OOM messages alloc failures use dump_stack so emitting an additional out-of-memory message is an unnecessary duplication. Remove the allocation failure messages. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/bonding/bond_alb.c | 12 ++++------- drivers/net/can/slcan.c | 4 +--- drivers/net/ethernet/amd/ni65.c | 4 +--- drivers/net/ethernet/apple/bmac.c | 4 +--- drivers/net/ethernet/apple/mace.c | 4 +--- drivers/net/ethernet/broadcom/bnx2.c | 4 +--- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 4 +--- .../net/ethernet/brocade/bna/bnad_debugfs.c | 21 +++---------------- drivers/net/ethernet/cisco/enic/enic_main.c | 1 - drivers/net/ethernet/cisco/enic/vnic_rq.c | 4 +--- drivers/net/ethernet/cisco/enic/vnic_wq.c | 4 +--- drivers/net/ethernet/i825xx/lp486e.c | 2 -- drivers/net/ethernet/ibm/emac/rgmii.c | 5 +---- drivers/net/ethernet/ibm/emac/tah.c | 5 +---- drivers/net/ethernet/ibm/emac/zmii.c | 5 +---- drivers/net/ethernet/intel/e1000/e1000_main.c | 4 +--- drivers/net/ethernet/intel/ixgb/ixgb_main.c | 4 +--- .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 6 +----- drivers/net/ethernet/korina.c | 1 - drivers/net/ethernet/marvell/pxa168_eth.c | 10 ++++----- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 5 ++--- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 6 ++---- drivers/net/ethernet/micrel/ks8851_mll.c | 4 +--- .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 9 +++----- .../ethernet/qlogic/netxen/netxen_nic_init.c | 12 +++-------- drivers/net/ethernet/qlogic/qlge/qlge_dbg.c | 4 +--- drivers/net/ethernet/sis/sis900.c | 1 - .../net/ethernet/stmicro/stmmac/stmmac_main.c | 5 ++--- drivers/net/ethernet/sun/cassini.c | 1 - drivers/net/ethernet/sun/sunvnet.c | 9 +++----- .../net/ethernet/toshiba/ps3_gelic_wireless.c | 5 ++--- drivers/net/hamradio/yam.c | 1 - drivers/net/hippi/rrunner.c | 8 +------ drivers/net/irda/donauboe.c | 2 -- drivers/net/netconsole.c | 8 ++----- drivers/net/ppp/pptp.c | 4 +--- drivers/net/slip/slip.c | 4 +--- drivers/net/tokenring/3c359.c | 4 ---- drivers/net/tokenring/madgemc.c | 1 - drivers/net/vmxnet3/vmxnet3_drv.c | 15 +++---------- drivers/net/wan/c101.c | 4 +--- drivers/net/wan/dscc4.c | 8 ++----- drivers/net/wan/lmc/lmc_main.c | 1 - drivers/net/wan/n2.c | 4 +--- drivers/net/wan/pc300too.c | 1 - drivers/net/wan/pci200syn.c | 1 - drivers/net/wan/wanxl.c | 1 - drivers/net/wan/x25_asy.c | 4 +--- drivers/net/wireless/ath/ath9k/htc_hst.c | 5 +---- drivers/net/wireless/hostap/hostap_hw.c | 18 ++++++---------- drivers/net/wireless/ipw2x00/ipw2100.c | 5 +---- drivers/net/wireless/libertas/if_cs.c | 5 ++--- drivers/net/wireless/libertas/if_usb.c | 4 +--- drivers/net/wireless/libertas_tf/if_usb.c | 4 +--- drivers/net/wireless/mwifiex/pcie.c | 4 +--- drivers/net/wireless/mwifiex/sdio.c | 4 +--- drivers/net/wireless/orinoco/main.c | 6 ++---- drivers/net/wireless/prism54/islpci_mgt.c | 6 ++---- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 5 +---- drivers/net/xen-netback/netback.c | 4 +--- 60 files changed, 77 insertions(+), 233 deletions(-) diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index f820b26b9db3..9abfde479316 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -180,11 +180,9 @@ static int tlb_initialize(struct bonding *bond) int i; new_hashtbl = kzalloc(size, GFP_KERNEL); - if (!new_hashtbl) { - pr_err("%s: Error: Failed to allocate TLB hash table\n", - bond->dev->name); + if (!new_hashtbl) return -1; - } + _lock_tx_hashtbl_bh(bond); bond_info->tx_hashtbl = new_hashtbl; @@ -784,11 +782,9 @@ static int rlb_initialize(struct bonding *bond) int i; new_hashtbl = kmalloc(size, GFP_KERNEL); - if (!new_hashtbl) { - pr_err("%s: Error: Failed to allocate RLB hash table\n", - bond->dev->name); + if (!new_hashtbl) return -1; - } + _lock_rx_hashtbl_bh(bond); bond_info->rx_hashtbl = new_hashtbl; diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 579e7fca6447..98a5a7d867f5 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -639,10 +639,8 @@ static int __init slcan_init(void) printk(KERN_INFO "slcan: %d dynamic interface channels.\n", maxdev); slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL); - if (!slcan_devs) { - printk(KERN_ERR "slcan: can't allocate slcan device array!\n"); + if (!slcan_devs) return -ENOMEM; - } /* Fill in our line protocol discipline, and register it */ status = tty_register_ldisc(N_SLCAN, &slc_ldisc); diff --git a/drivers/net/ethernet/amd/ni65.c b/drivers/net/ethernet/amd/ni65.c index 6e6aa7213aab..735c213798b1 100644 --- a/drivers/net/ethernet/amd/ni65.c +++ b/drivers/net/ethernet/amd/ni65.c @@ -621,10 +621,8 @@ static void *ni65_alloc_mem(struct net_device *dev,char *what,int size,int type) } else { ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA); - if(!ret) { - printk(KERN_WARNING "%s: unable to allocate %s memory.\n",dev->name,what); + if(!ret) return NULL; - } } if( (u32) virt_to_phys(ptr+size) > 0x1000000) { printk(KERN_WARNING "%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what); diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c index d070b229dbf7..4108ac800cf0 100644 --- a/drivers/net/ethernet/apple/bmac.c +++ b/drivers/net/ethernet/apple/bmac.c @@ -1660,10 +1660,8 @@ static int __init bmac_init(void) { if (bmac_emergency_rxbuf == NULL) { bmac_emergency_rxbuf = kmalloc(RX_BUFLEN, GFP_KERNEL); - if (bmac_emergency_rxbuf == NULL) { - printk(KERN_ERR "BMAC: can't allocate emergency RX buffer\n"); + if (bmac_emergency_rxbuf == NULL) return -ENOMEM; - } } return macio_register_driver(&bmac_driver); diff --git a/drivers/net/ethernet/apple/mace.c b/drivers/net/ethernet/apple/mace.c index bec87bd9195c..45ba18ee3d6a 100644 --- a/drivers/net/ethernet/apple/mace.c +++ b/drivers/net/ethernet/apple/mace.c @@ -136,10 +136,8 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i */ if (dummy_buf == NULL) { dummy_buf = kmalloc(RX_BUFLEN+2, GFP_KERNEL); - if (dummy_buf == NULL) { - printk(KERN_ERR "MACE: couldn't allocate dummy buffer\n"); + if (dummy_buf == NULL) return -ENOMEM; - } } if (macio_request_resources(mdev, "mace")) { diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 021fb818007a..0a4c5405dcf4 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -2625,10 +2625,8 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp) u32 val; good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL); - if (good_mbuf == NULL) { - pr_err("Failed to allocate memory in %s\n", __func__); + if (good_mbuf == NULL) return -ENOMEM; - } REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS, BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index fea961505391..582cbcf5f9fb 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -10894,10 +10894,8 @@ static inline void be16_to_cpu_n(const u8 *_source, u8 *_target, u32 n) do { \ u32 len = be32_to_cpu(fw_hdr->arr.len); \ bp->arr = kmalloc(len, GFP_KERNEL); \ - if (!bp->arr) { \ - pr_err("Failed to allocate %d bytes for "#arr"\n", len); \ + if (!bp->arr) \ goto lbl; \ - } \ func(bp->firmware->data + be32_to_cpu(fw_hdr->arr.offset), \ (u8 *)bp->arr, len); \ } while (0) diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c index 592ad3929f53..c9fdceb135f3 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c @@ -62,8 +62,6 @@ bnad_debugfs_open_fwtrc(struct inode *inode, struct file *file) if (!fw_debug->debug_buffer) { kfree(fw_debug); fw_debug = NULL; - pr_warn("bna %s: Failed to allocate fwtrc buffer\n", - pci_name(bnad->pcidev)); return -ENOMEM; } @@ -105,8 +103,6 @@ bnad_debugfs_open_fwsave(struct inode *inode, struct file *file) if (!fw_debug->debug_buffer) { kfree(fw_debug); fw_debug = NULL; - pr_warn("bna %s: Failed to allocate fwsave buffer\n", - pci_name(bnad->pcidev)); return -ENOMEM; } @@ -208,8 +204,6 @@ bnad_debugfs_open_drvinfo(struct inode *inode, struct file *file) if (!drv_info->debug_buffer) { kfree(drv_info); drv_info = NULL; - pr_warn("bna %s: Failed to allocate drv info buffer\n", - pci_name(bnad->pcidev)); return -ENOMEM; } @@ -348,11 +342,8 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf, /* Allocate memory to store the user space buf */ kern_buf = kzalloc(nbytes, GFP_KERNEL); - if (!kern_buf) { - pr_warn("bna %s: Failed to allocate user buffer\n", - pci_name(bnad->pcidev)); + if (!kern_buf) return -ENOMEM; - } if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) { kfree(kern_buf); @@ -373,11 +364,8 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf, bnad->reglen = 0; bnad->regdata = kzalloc(len << 2, GFP_KERNEL); - if (!bnad->regdata) { - pr_warn("bna %s: Failed to allocate regrd buffer\n", - pci_name(bnad->pcidev)); + if (!bnad->regdata) return -ENOMEM; - } bnad->reglen = len << 2; rb = bfa_ioc_bar0(ioc); @@ -421,11 +409,8 @@ bnad_debugfs_write_regwr(struct file *file, const char __user *buf, /* Allocate memory to store the user space buf */ kern_buf = kzalloc(nbytes, GFP_KERNEL); - if (!kern_buf) { - pr_warn("bna %s: Failed to allocate user buffer\n", - pci_name(bnad->pcidev)); + if (!kern_buf) return -ENOMEM; - } if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) { kfree(kern_buf); diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index ab3f67f980d8..07df13745c43 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -2388,7 +2388,6 @@ static int __devinit enic_probe(struct pci_dev *pdev, /* Allocate structure for port profiles */ enic->pp = kcalloc(num_pps, sizeof(*enic->pp), GFP_KERNEL); if (!enic->pp) { - pr_err("port profile alloc failed, aborting\n"); err = -ENOMEM; goto err_out_disable_sriov_pp; } diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.c b/drivers/net/ethernet/cisco/enic/vnic_rq.c index 34105e0951a5..7e1488fc8ab2 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_rq.c +++ b/drivers/net/ethernet/cisco/enic/vnic_rq.c @@ -38,10 +38,8 @@ static int vnic_rq_alloc_bufs(struct vnic_rq *rq) for (i = 0; i < blks; i++) { rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ(count), GFP_ATOMIC); - if (!rq->bufs[i]) { - pr_err("Failed to alloc rq_bufs\n"); + if (!rq->bufs[i]) return -ENOMEM; - } } for (i = 0; i < blks; i++) { diff --git a/drivers/net/ethernet/cisco/enic/vnic_wq.c b/drivers/net/ethernet/cisco/enic/vnic_wq.c index df61bd932ea6..5e0d7a2be9bc 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_wq.c +++ b/drivers/net/ethernet/cisco/enic/vnic_wq.c @@ -38,10 +38,8 @@ static int vnic_wq_alloc_bufs(struct vnic_wq *wq) for (i = 0; i < blks; i++) { wq->bufs[i] = kzalloc(VNIC_WQ_BUF_BLK_SZ(count), GFP_ATOMIC); - if (!wq->bufs[i]) { - pr_err("Failed to alloc wq_bufs\n"); + if (!wq->bufs[i]) return -ENOMEM; - } } for (i = 0; i < blks; i++) { diff --git a/drivers/net/ethernet/i825xx/lp486e.c b/drivers/net/ethernet/i825xx/lp486e.c index 414044b3cb11..02df5f5accb1 100644 --- a/drivers/net/ethernet/i825xx/lp486e.c +++ b/drivers/net/ethernet/i825xx/lp486e.c @@ -454,8 +454,6 @@ init_rx_bufs(struct net_device *dev, int num) { } rfd->rbd = rbd; - } else { - printk("Could not kmalloc rbd\n"); } } lp->rbd_tail->next = rfd->rbd; diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/ibm/emac/rgmii.c index 05484f918ee3..d3123282e18e 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c @@ -237,11 +237,8 @@ static int __devinit rgmii_probe(struct platform_device *ofdev) rc = -ENOMEM; dev = kzalloc(sizeof(struct rgmii_instance), GFP_KERNEL); - if (dev == NULL) { - printk(KERN_ERR "%s: could not allocate RGMII device!\n", - np->full_name); + if (dev == NULL) goto err_gone; - } mutex_init(&dev->lock); dev->ofdev = ofdev; diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm/emac/tah.c index 0d9881efe2ff..872912ef518d 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c @@ -96,11 +96,8 @@ static int __devinit tah_probe(struct platform_device *ofdev) rc = -ENOMEM; dev = kzalloc(sizeof(struct tah_instance), GFP_KERNEL); - if (dev == NULL) { - printk(KERN_ERR "%s: could not allocate TAH device!\n", - np->full_name); + if (dev == NULL) goto err_gone; - } mutex_init(&dev->lock); dev->ofdev = ofdev; diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ibm/emac/zmii.c index e799a6116ba5..415e9b4d5408 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c @@ -240,11 +240,8 @@ static int __devinit zmii_probe(struct platform_device *ofdev) rc = -ENOMEM; dev = kzalloc(sizeof(struct zmii_instance), GFP_KERNEL); - if (dev == NULL) { - printk(KERN_ERR "%s: could not allocate ZMII device!\n", - np->full_name); + if (dev == NULL) goto err_gone; - } mutex_init(&dev->lock); dev->ofdev = ofdev; diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 669ca3800c01..363fd395c75b 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -730,10 +730,8 @@ static void e1000_dump_eeprom(struct e1000_adapter *adapter) eeprom.offset = 0; data = kmalloc(eeprom.len, GFP_KERNEL); - if (!data) { - pr_err("Unable to allocate memory to dump EEPROM data\n"); + if (!data) return; - } ops->get_eeprom(netdev, &eeprom, data); diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index 9bd5faf64a85..002478801a1b 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c @@ -1136,10 +1136,8 @@ ixgb_set_multi(struct net_device *netdev) u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES * ETH_ALEN, GFP_ATOMIC); u8 *addr; - if (!mta) { - pr_err("allocation of multicast memory failed\n"); + if (!mta) goto alloc_failed; - } IXGB_WRITE_REG(hw, RCTL, rctl); diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index bed411bada21..f3bc9333a082 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -2517,12 +2517,8 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter, size = sizeof(struct ixgbevf_rx_buffer) * rx_ring->count; rx_ring->rx_buffer_info = vzalloc(size); - if (!rx_ring->rx_buffer_info) { - hw_dbg(&adapter->hw, - "Unable to vmalloc buffer memory for " - "the receive descriptor ring\n"); + if (!rx_ring->rx_buffer_info) goto alloc_failed; - } /* Round up to nearest 4K */ rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c index 6ad094f176f8..341d10130dca 100644 --- a/drivers/net/ethernet/korina.c +++ b/drivers/net/ethernet/korina.c @@ -1150,7 +1150,6 @@ static int korina_probe(struct platform_device *pdev) lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL); if (!lp->td_ring) { - printk(KERN_ERR DRV_NAME ": cannot allocate descriptors\n"); rc = -ENXIO; goto probe_err_td_ring; } diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 953ba5851f7b..92b4b4e68e3b 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -1017,10 +1017,9 @@ static int rxq_init(struct net_device *dev) /* Allocate RX skb rings */ pep->rx_skb = kmalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size, GFP_KERNEL); - if (!pep->rx_skb) { - printk(KERN_ERR "%s: Cannot alloc RX skb ring\n", dev->name); + if (!pep->rx_skb) return -ENOMEM; - } + /* Allocate RX ring */ pep->rx_desc_count = 0; size = pep->rx_ring_size * sizeof(struct rx_desc); @@ -1081,10 +1080,9 @@ static int txq_init(struct net_device *dev) pep->tx_skb = kmalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size, GFP_KERNEL); - if (!pep->tx_skb) { - printk(KERN_ERR "%s: Cannot alloc TX skb ring\n", dev->name); + if (!pep->tx_skb) return -ENOMEM; - } + /* Allocate TX ring */ pep->tx_desc_count = 0; size = pep->tx_ring_size * sizeof(struct tx_desc); diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 971d4b6b8dfe..f61d0e08f52b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -281,10 +281,9 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv, tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS * sizeof(struct skb_frag_struct)); ring->rx_info = vmalloc(tmp); - if (!ring->rx_info) { - en_err(priv, "Failed allocating rx_info ring\n"); + if (!ring->rx_info) return -ENOMEM; - } + en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d\n", ring->rx_info, tmp); diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 9ef9038d0629..ff3250586584 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -71,16 +71,14 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, tmp = size * sizeof(struct mlx4_en_tx_info); ring->tx_info = vmalloc(tmp); - if (!ring->tx_info) { - en_err(priv, "Failed allocating tx_info ring\n"); + if (!ring->tx_info) return -ENOMEM; - } + en_dbg(DRV, priv, "Allocated tx_info ring at addr:%p size:%d\n", ring->tx_info, tmp); ring->bounce_buf = kmalloc(MAX_DESC_SIZE, GFP_KERNEL); if (!ring->bounce_buf) { - en_err(priv, "Failed allocating bounce buffer\n"); err = -ENOMEM; goto err_tx; } diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index a37264e61a20..4a9d57fb9fb4 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c @@ -1501,10 +1501,8 @@ static int ks_hw_init(struct ks_net *ks) ks->mcast_lst_size = 0; ks->frame_head_info = kmalloc(MHEADER_SIZE, GFP_KERNEL); - if (!ks->frame_head_info) { - pr_err("Error: Fail to allocate frame memory\n"); + if (!ks->frame_head_info) return false; - } ks_set_mac(ks, KS_DEFAULT_MAC_ADDRESS); return true; 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 3ead111111e1..0217991fede7 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 @@ -1587,10 +1587,8 @@ int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter, size = (int)sizeof(struct pch_gbe_buffer) * tx_ring->count; tx_ring->buffer_info = vzalloc(size); - if (!tx_ring->buffer_info) { - pr_err("Unable to allocate memory for the buffer information\n"); + if (!tx_ring->buffer_info) return -ENOMEM; - } tx_ring->size = tx_ring->count * (int)sizeof(struct pch_gbe_tx_desc); @@ -1636,10 +1634,9 @@ int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter, size = (int)sizeof(struct pch_gbe_buffer) * rx_ring->count; rx_ring->buffer_info = vzalloc(size); - if (!rx_ring->buffer_info) { - pr_err("Unable to allocate memory for the receive descriptor ring\n"); + if (!rx_ring->buffer_info) return -ENOMEM; - } + rx_ring->size = rx_ring->count * (int)sizeof(struct pch_gbe_rx_desc); rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, &rx_ring->dma, GFP_KERNEL); diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c index a8259cc19a63..094d26c51816 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c @@ -280,13 +280,10 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) } rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); - if (rds_ring->rx_buf_arr == NULL) { - printk(KERN_ERR "%s: Failed to allocate " - "rx buffer ring %d\n", - netdev->name, ring); + if (rds_ring->rx_buf_arr == NULL) /* free whatever was already allocated */ goto err_out; - } + INIT_LIST_HEAD(&rds_ring->free_list); /* * Now go through all of them, set reference handles @@ -480,11 +477,8 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter) } buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); - if (buf == NULL) { - printk("%s: netxen_pinit_from_rom: Unable to calloc memory.\n", - netxen_nic_driver_name); + if (buf == NULL) return -ENOMEM; - } for (i = 0; i < n; i++) { if (netxen_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 || diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c index fca804f36d61..58185b604b72 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c @@ -1824,10 +1824,8 @@ void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id) pr_err("%s: Enter\n", __func__); ptr = kmalloc(size, GFP_ATOMIC); - if (ptr == NULL) { - pr_err("%s: Couldn't allocate a buffer\n", __func__); + if (ptr == NULL) return; - } if (ql_write_cfg(qdev, ptr, size, bit, q_id)) { pr_err("%s: Failed to upload control block!\n", __func__); diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index c8efc708c792..91c44688bc3e 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c @@ -619,7 +619,6 @@ static int __devinit sis900_mii_probe(struct net_device * net_dev) } if ((mii_phy = kmalloc(sizeof(struct mii_phy), GFP_KERNEL)) == NULL) { - printk(KERN_WARNING "Cannot allocate mem for struct mii_phy\n"); mii_phy = sis_priv->first_mii; while (mii_phy) { struct mii_phy *phy; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 96fa2da30763..ffc7581879b1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -954,10 +954,9 @@ static int stmmac_open(struct net_device *dev) #ifdef CONFIG_STMMAC_TIMER priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); - if (unlikely(priv->tm == NULL)) { - pr_err("%s: ERROR: timer memory alloc failed\n", __func__); + if (unlikely(priv->tm == NULL)) return -ENOMEM; - } + priv->tm->freq = tmrate; /* Test if the external timer can be actually used. diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index f10665f594c4..46d84abe553d 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c @@ -835,7 +835,6 @@ static int cas_saturn_firmware_init(struct cas *cp) cp->fw_data = vmalloc(cp->fw_size); if (!cp->fw_data) { err = -ENOMEM; - pr_err("\"%s\" Failed %d\n", fw_name, err); goto out; } memcpy(cp->fw_data, &fw->data[2], cp->fw_size); diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c index 8c6c059f3489..2896f6e9672b 100644 --- a/drivers/net/ethernet/sun/sunvnet.c +++ b/drivers/net/ethernet/sun/sunvnet.c @@ -949,10 +949,9 @@ static int __devinit vnet_port_alloc_tx_bufs(struct vnet_port *port) int map_len = (ETH_FRAME_LEN + 7) & ~7; err = -ENOMEM; - if (!buf) { - pr_err("TX buffer allocation failure\n"); + if (!buf) goto err_out; - } + err = -EFAULT; if ((unsigned long)buf & (8UL - 1)) { pr_err("TX buffer misaligned\n"); @@ -1165,10 +1164,8 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, port = kzalloc(sizeof(*port), GFP_KERNEL); err = -ENOMEM; - if (!port) { - pr_err("Cannot allocate vnet_port\n"); + if (!port) goto err_out_put_mdesc; - } for (i = 0; i < ETH_ALEN; i++) port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff; diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c index fd4ed7f8cfa1..5c14f82c4954 100644 --- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c @@ -1621,10 +1621,9 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) kfree(target->hwinfo); target->hwinfo = kzalloc(be16_to_cpu(scan_info->size), GFP_KERNEL); - if (!target->hwinfo) { - pr_info("%s: kzalloc failed\n", __func__); + if (!target->hwinfo) continue; - } + /* copy hw scan info */ memcpy(target->hwinfo, scan_info, scan_info->size); target->essid_len = strnlen(scan_info->essid, diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c index 96a98d2ff151..696327773fbe 100644 --- a/drivers/net/hamradio/yam.c +++ b/drivers/net/hamradio/yam.c @@ -403,7 +403,6 @@ static unsigned char *add_mcs(unsigned char *bits, int bitrate, /* Allocate a new mcs */ if ((p = kmalloc(sizeof(struct yam_mcs), GFP_KERNEL)) == NULL) { - printk(KERN_WARNING "YAM: no memory to allocate mcs\n"); release_firmware(fw); return NULL; } diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c index e68c941926f1..2a51363d9fed 100644 --- a/drivers/net/hippi/rrunner.c +++ b/drivers/net/hippi/rrunner.c @@ -1600,12 +1600,8 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); - if (!image){ - printk(KERN_ERR "%s: Unable to allocate memory " - "for EEPROM image\n", dev->name); + if (!image) return -ENOMEM; - } - if (rrpriv->fw_running){ printk("%s: Firmware already running\n", dev->name); @@ -1637,8 +1633,6 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); if (!image || !oldimage) { - printk(KERN_ERR "%s: Unable to allocate memory " - "for EEPROM image\n", dev->name); error = -ENOMEM; goto wf_out; } diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c index 64f403da101c..617a446d126c 100644 --- a/drivers/net/irda/donauboe.c +++ b/drivers/net/irda/donauboe.c @@ -1608,7 +1608,6 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid) self->ringbuf = kmalloc(OBOE_RING_LEN << 1, GFP_KERNEL); if (!self->ringbuf) { - printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n"); err = -ENOMEM; goto freeregion; } @@ -1647,7 +1646,6 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid) if (!ok) { - printk (KERN_ERR DRIVER_NAME ": can't allocate rx/tx buffers\n"); err = -ENOMEM; goto freebufs; } diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index e8882023576b..f9347ea3d381 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -169,10 +169,8 @@ static struct netconsole_target *alloc_param_target(char *target_config) * Note that these targets get their config_item fields zeroed-out. */ nt = kzalloc(sizeof(*nt), GFP_KERNEL); - if (!nt) { - printk(KERN_ERR "netconsole: failed to allocate memory\n"); + if (!nt) goto fail; - } nt->np.name = "netconsole"; strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); @@ -551,10 +549,8 @@ static struct config_item *make_netconsole_target(struct config_group *group, * Target is disabled at creation (enabled == 0). */ nt = kzalloc(sizeof(*nt), GFP_KERNEL); - if (!nt) { - printk(KERN_ERR "netconsole: failed to allocate memory\n"); + if (!nt) return ERR_PTR(-ENOMEM); - } nt->np.name = "netconsole"; strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index df884dde2a51..234cd9d87ed9 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c @@ -670,10 +670,8 @@ static int __init pptp_init_module(void) pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *)); - if (!callid_sock) { - pr_err("PPTP: cann't allocate memory\n"); + if (!callid_sock) return -ENOMEM; - } err = gre_add_protocol(&gre_pptp_protocol, GREPROTO_PPTP); if (err) { diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c index ba08341fb92c..69345dfae0fd 100644 --- a/drivers/net/slip/slip.c +++ b/drivers/net/slip/slip.c @@ -1296,10 +1296,8 @@ static int __init slip_init(void) slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev, GFP_KERNEL); - if (!slip_devs) { - printk(KERN_ERR "SLIP: Can't allocate slip devices array.\n"); + if (!slip_devs) return -ENOMEM; - } /* Fill in our line protocol discipline, and register it */ status = tty_register_ldisc(N_SLIP, &sl_ldisc); diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c index ef9fdf3652f6..d7c292aa76b1 100644 --- a/drivers/net/tokenring/3c359.c +++ b/drivers/net/tokenring/3c359.c @@ -674,15 +674,11 @@ static int xl_open(struct net_device *dev) /* These MUST be on 8 byte boundaries */ xl_priv->xl_tx_ring = kzalloc((sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE) + 7, GFP_DMA | GFP_KERNEL); if (xl_priv->xl_tx_ring == NULL) { - printk(KERN_WARNING "%s: Not enough memory to allocate tx buffers.\n", - dev->name); free_irq(dev->irq,dev); return -ENOMEM; } xl_priv->xl_rx_ring = kzalloc((sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE) +7, GFP_DMA | GFP_KERNEL); if (xl_priv->xl_rx_ring == NULL) { - printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers.\n", - dev->name); free_irq(dev->irq,dev); kfree(xl_priv->xl_tx_ring); return -ENOMEM; diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c index 6153cfd696b6..1cdc034f6aec 100644 --- a/drivers/net/tokenring/madgemc.c +++ b/drivers/net/tokenring/madgemc.c @@ -171,7 +171,6 @@ static int __devinit madgemc_probe(struct device *device) card = kmalloc(sizeof(struct card_info), GFP_KERNEL); if (card==NULL) { - printk("madgemc: unable to allocate card struct\n"); ret = -ENOMEM; goto getout1; } diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index be6aa353f6a1..87c0b586f11f 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -537,11 +537,8 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq, tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]), GFP_KERNEL); - if (!tq->buf_info) { - printk(KERN_ERR "%s: failed to allocate tx bufinfo\n", - adapter->netdev->name); + if (!tq->buf_info) goto err; - } return 0; @@ -1519,11 +1516,9 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter) sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size + rq->rx_ring[1].size); bi = kzalloc(sz, GFP_KERNEL); - if (!bi) { - printk(KERN_ERR "%s: failed to allocate rx bufinfo\n", - adapter->netdev->name); + if (!bi) goto err; - } + rq->buf_info[0] = bi; rq->buf_info[1] = bi + rq->rx_ring[0].size; @@ -2964,8 +2959,6 @@ vmxnet3_probe_device(struct pci_dev *pdev, adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL); if (adapter->pm_conf == NULL) { - printk(KERN_ERR "Failed to allocate memory for %s\n", - pci_name(pdev)); err = -ENOMEM; goto err_alloc_pm; } @@ -2974,8 +2967,6 @@ vmxnet3_probe_device(struct pci_dev *pdev, adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL); if (adapter->rss_conf == NULL) { - printk(KERN_ERR "Failed to allocate memory for %s\n", - pci_name(pdev)); err = -ENOMEM; goto err_alloc_rss; } diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 54f995f4a5a3..09a50751763b 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -325,10 +325,8 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) } card = kzalloc(sizeof(card_t), GFP_KERNEL); - if (card == NULL) { - pr_err("unable to allocate memory\n"); + if (card == NULL) return -ENOBUFS; - } card->dev = alloc_hdlcdev(card); if (!card->dev) { diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 058e1697c174..fe8d060d8fff 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -903,10 +903,8 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) int i, ret = -ENOMEM; root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL); - if (!root) { - pr_err("can't allocate data\n"); + if (!root) goto err_out; - } for (i = 0; i < dev_per_card; i++) { root[i].dev = alloc_hdlcdev(root + i); @@ -915,10 +913,8 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) } ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL); - if (!ppriv) { - pr_err("can't allocate private data\n"); + if (!ppriv) goto err_free_dev; - } ppriv->root = root; spin_lock_init(&ppriv->lock); diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index b7f2358d23be..76a8a4a522e9 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -497,7 +497,6 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ data = kmalloc(xc.len, GFP_KERNEL); if (!data) { - printk(KERN_WARNING "%s: Failed to allocate memory for copy\n", dev->name); ret = -ENOMEM; break; } diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index 5129ad514d26..315bf09d6a20 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c @@ -358,10 +358,8 @@ static int __init n2_run(unsigned long io, unsigned long irq, } card = kzalloc(sizeof(card_t), GFP_KERNEL); - if (card == NULL) { - pr_err("unable to allocate memory\n"); + if (card == NULL) return -ENOBUFS; - } card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index c49c1b3c7aad..5fe246e060d7 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c @@ -320,7 +320,6 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { - pr_err("unable to allocate memory\n"); pci_release_regions(pdev); pci_disable_device(pdev); return -ENOBUFS; diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c index 1ce21163c776..9659fcaa34ed 100644 --- a/drivers/net/wan/pci200syn.c +++ b/drivers/net/wan/pci200syn.c @@ -299,7 +299,6 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { - pr_err("unable to allocate memory\n"); pci_release_regions(pdev); pci_disable_device(pdev); return -ENOBUFS; diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 44b707197258..feb7541b33fb 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -604,7 +604,6 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, alloc_size = sizeof(card_t) + ports * sizeof(port_t); card = kzalloc(alloc_size, GFP_KERNEL); if (card == NULL) { - pr_err("%s: unable to allocate memory\n", pci_name(pdev)); pci_release_regions(pdev); pci_disable_device(pdev); return -ENOBUFS; diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 8a10bb730d5a..e862369b4a6d 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -786,10 +786,8 @@ static int __init init_x25_asy(void) x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *), GFP_KERNEL); - if (!x25_asy_devs) { - pr_warn("Can't allocate x25_asy_ctrls[] array! Uaargh! (-> No X.25 available)\n"); + if (!x25_asy_devs) return -ENOMEM; - } return tty_register_ldisc(N_X25, &x25_ldisc); } diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c index 1b90ed8795c3..c25226a32ddc 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c @@ -431,11 +431,8 @@ struct htc_target *ath9k_htc_hw_alloc(void *hif_handle, struct htc_target *target; target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); - if (!target) { - printk(KERN_ERR "Unable to allocate memory for" - "target device\n"); + if (!target) return NULL; - } init_completion(&target->target_wait); init_completion(&target->cmd_wait); diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index a8bddd81b4d1..aa15cc4269a1 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c @@ -347,11 +347,9 @@ static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0, return -EINTR; entry = kzalloc(sizeof(*entry), GFP_ATOMIC); - if (entry == NULL) { - printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n", - dev->name); + if (entry == NULL) return -ENOMEM; - } + atomic_set(&entry->usecnt, 1); entry->type = CMD_SLEEP; entry->cmd = cmd; @@ -515,11 +513,9 @@ static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0, } entry = kzalloc(sizeof(*entry), GFP_ATOMIC); - if (entry == NULL) { - printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc " - "failed\n", dev->name); + if (entry == NULL) return -ENOMEM; - } + atomic_set(&entry->usecnt, 1); entry->type = CMD_CALLBACK; entry->cmd = cmd; @@ -2978,11 +2974,9 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set) local = iface->local; new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC); - if (new_entry == NULL) { - printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n", - local->dev->name); + if (new_entry == NULL) return -ENOMEM; - } + new_entry->aid = aid; new_entry->set = set; diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index a0e5c21d3657..e847737ccc9d 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c @@ -3464,11 +3464,8 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) priv->msg_buffers = kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet), GFP_KERNEL); - if (!priv->msg_buffers) { - printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg " - "buffers.\n", priv->net_dev->name); + if (!priv->msg_buffers) return -ENOMEM; - } for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) { v = pci_alloc_consistent(priv->pci_dev, diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index 3f7bf4d912b6..234ee88dec95 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c @@ -815,10 +815,9 @@ static int if_cs_probe(struct pcmcia_device *p_dev) lbs_deb_enter(LBS_DEB_CS); card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL); - if (!card) { - pr_err("error in kzalloc\n"); + if (!card) goto out; - } + card->p_dev = p_dev; p_dev->priv = card; diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index b5fbbc7947df..74da5f1ea243 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c @@ -261,10 +261,8 @@ static int if_usb_probe(struct usb_interface *intf, udev = interface_to_usbdev(intf); cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); - if (!cardp) { - pr_err("Out of memory allocating private data\n"); + if (!cardp) goto error; - } setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); init_waitqueue_head(&cardp->fw_wq); diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c index aff8b5743af0..7ced130f4f9e 100644 --- a/drivers/net/wireless/libertas_tf/if_usb.c +++ b/drivers/net/wireless/libertas_tf/if_usb.c @@ -153,10 +153,8 @@ static int if_usb_probe(struct usb_interface *intf, udev = interface_to_usbdev(intf); cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); - if (!cardp) { - pr_err("Out of memory allocating private data.\n"); + if (!cardp) goto error; - } setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); init_waitqueue_head(&cardp->fw_wq); diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 405350940a45..f4fbad95d3e3 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -86,10 +86,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev, pdev->vendor, pdev->device, pdev->revision); card = kzalloc(sizeof(struct pcie_service_card), GFP_KERNEL); - if (!card) { - pr_err("%s: failed to alloc memory\n", __func__); + if (!card) return -ENOMEM; - } card->dev = pdev; diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index d39d8457f252..835902750231 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -70,10 +70,8 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) func->vendor, func->device, func->class, func->num); card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL); - if (!card) { - pr_err("%s: failed to alloc memory\n", __func__); + if (!card) return -ENOMEM; - } card->func = func; diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c index 9fb77d0319f5..dd6c64ac406e 100644 --- a/drivers/net/wireless/orinoco/main.c +++ b/drivers/net/wireless/orinoco/main.c @@ -941,11 +941,9 @@ void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw) /* Add desc and skb to rx queue */ rx_data = kzalloc(sizeof(*rx_data), GFP_ATOMIC); - if (!rx_data) { - printk(KERN_WARNING "%s: Can't allocate RX packet\n", - dev->name); + if (!rx_data) goto drop; - } + rx_data->desc = desc; rx_data->skb = skb; list_add_tail(&rx_data->list, &priv->rx_list); diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c index a5224f6160e4..851fa10241e1 100644 --- a/drivers/net/wireless/prism54/islpci_mgt.c +++ b/drivers/net/wireless/prism54/islpci_mgt.c @@ -192,11 +192,9 @@ islpci_mgt_transmit(struct net_device *ndev, int operation, unsigned long oid, err = -ENOMEM; p = buf.mem = kmalloc(frag_len, GFP_KERNEL); - if (!buf.mem) { - printk(KERN_DEBUG "%s: cannot allocate mgmt frame\n", - ndev->name); + if (!buf.mem) goto error; - } + buf.size = frag_len; /* create the header directly in the fragment data area */ diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index 78723cf59491..36140ccf2abd 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -186,11 +186,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) /* for firmware buf */ rtlpriv->rtlhal.pfirmware = vzalloc(sizeof(struct rt_firmware)); - if (!rtlpriv->rtlhal.pfirmware) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't alloc buffer for fw.\n")); + if (!rtlpriv->rtlhal.pfirmware) return 1; - } pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" "Loading firmware %s\n", rtlpriv->cfg->fw_name); diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 59effac15f36..2596401308a8 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -1639,10 +1639,8 @@ static int __init netback_init(void) xen_netbk_group_nr = num_online_cpus(); xen_netbk = vzalloc(sizeof(struct xen_netbk) * xen_netbk_group_nr); - if (!xen_netbk) { - printk(KERN_ALERT "%s: out of memory\n", __func__); + if (!xen_netbk) return -ENOMEM; - } for (group = 0; group < xen_netbk_group_nr; group++) { struct xen_netbk *netbk = &xen_netbk[group]; -- GitLab From 41de8d4cff21a2e81e3d9ff66f5f7c903f9c3ab1 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 29 Jan 2012 13:47:52 +0000 Subject: [PATCH 0284/1846] drivers/net: Remove alloc_etherdev error messages alloc_etherdev has a generic OOM/unable to alloc message. Remove the duplicative messages after alloc_etherdev calls. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/ethernet/3com/3c59x.c | 5 ++--- drivers/net/ethernet/adaptec/starfire.c | 5 ++--- drivers/net/ethernet/adi/bfin_mac.c | 4 +--- drivers/net/ethernet/alteon/acenic.c | 5 +---- drivers/net/ethernet/amd/amd8111e.c | 1 - drivers/net/ethernet/amd/au1000_eth.c | 1 - drivers/net/ethernet/amd/declance.c | 2 -- drivers/net/ethernet/amd/pcnet32.c | 2 -- drivers/net/ethernet/apple/bmac.c | 4 +--- drivers/net/ethernet/apple/mace.c | 1 - drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 1 - drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 1 - drivers/net/ethernet/broadcom/b44.c | 1 - drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 4 +--- drivers/net/ethernet/broadcom/sb1250-mac.c | 2 -- drivers/net/ethernet/broadcom/tg3.c | 1 - drivers/net/ethernet/brocade/bna/bnad.c | 1 - drivers/net/ethernet/cadence/macb.c | 4 +--- drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 2 -- drivers/net/ethernet/cisco/enic/enic_main.c | 4 +--- drivers/net/ethernet/davicom/dm9000.c | 4 +--- drivers/net/ethernet/dec/tulip/tulip_core.c | 4 +--- drivers/net/ethernet/dec/tulip/xircom_cb.c | 5 ++--- drivers/net/ethernet/dnet.c | 4 +--- drivers/net/ethernet/ethoc.c | 1 - drivers/net/ethernet/hp/hp100.c | 1 - drivers/net/ethernet/ibm/ehea/ehea_main.c | 1 - drivers/net/ethernet/ibm/emac/core.c | 6 ++---- drivers/net/ethernet/ibm/iseries_veth.c | 4 +--- drivers/net/ethernet/icplus/ipg.c | 1 - drivers/net/ethernet/intel/e100.c | 5 +---- drivers/net/ethernet/jme.c | 1 - drivers/net/ethernet/korina.c | 5 ++--- drivers/net/ethernet/lantiq_etop.c | 4 ++++ drivers/net/ethernet/marvell/skge.c | 4 +--- drivers/net/ethernet/marvell/sky2.c | 4 +--- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 4 +--- drivers/net/ethernet/micrel/ks8695net.c | 4 +--- drivers/net/ethernet/micrel/ks8851.c | 4 +--- drivers/net/ethernet/microchip/enc28j60.c | 3 --- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 4 +--- drivers/net/ethernet/neterion/s2io.c | 1 - drivers/net/ethernet/netx-eth.c | 1 - drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 2 -- drivers/net/ethernet/packetengines/yellowfin.c | 5 ++--- drivers/net/ethernet/pasemi/pasemi_mac.c | 2 -- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 1 - drivers/net/ethernet/qlogic/qla3xxx.c | 1 - drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 1 - drivers/net/ethernet/rdc/r6040.c | 1 - drivers/net/ethernet/realtek/8139too.c | 5 ++--- drivers/net/ethernet/realtek/r8169.c | 2 -- drivers/net/ethernet/renesas/sh_eth.c | 1 - drivers/net/ethernet/s6gmac.c | 6 +++--- drivers/net/ethernet/seeq/sgiseeq.c | 1 - drivers/net/ethernet/sis/sis190.c | 2 -- drivers/net/ethernet/smsc/epic100.c | 5 ++--- drivers/net/ethernet/smsc/smc911x.c | 1 - drivers/net/ethernet/smsc/smc91x.c | 1 - drivers/net/ethernet/smsc/smsc911x.c | 1 - drivers/net/ethernet/smsc/smsc9420.c | 4 +--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +--- drivers/net/ethernet/sun/cassini.c | 1 - drivers/net/ethernet/sun/niu.c | 4 +--- drivers/net/ethernet/sun/sungem.c | 1 - drivers/net/ethernet/sun/sunvnet.c | 4 +--- drivers/net/ethernet/tehuti/tehuti.c | 1 - drivers/net/ethernet/ti/cpmac.c | 5 +---- drivers/net/ethernet/ti/davinci_emac.c | 1 - drivers/net/ethernet/ti/tlan.c | 1 - drivers/net/ethernet/toshiba/tc35815.c | 5 ++--- drivers/net/ethernet/tundra/tsi108_eth.c | 4 +--- drivers/net/ethernet/via/via-rhine.c | 1 - drivers/net/ethernet/via/via-velocity.c | 4 +--- drivers/net/ethernet/xilinx/ll_temac_main.c | 5 ++--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 4 +--- drivers/net/ethernet/xilinx/xilinx_emaclite.c | 4 +--- drivers/net/plip/plip.c | 4 +--- drivers/net/rionet.c | 2 -- drivers/net/usb/pegasus.c | 4 +--- drivers/net/usb/rtl8150.c | 4 +--- drivers/net/usb/usbnet.c | 4 +--- drivers/net/vmxnet3/vmxnet3_drv.c | 5 +---- drivers/net/wireless/atmel.c | 5 ++--- drivers/net/wireless/ipw2x00/libipw_module.c | 5 ++--- drivers/net/xen-netfront.c | 5 +---- 86 files changed, 63 insertions(+), 192 deletions(-) diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c index 8153a3e0a1a4..dc51d9218e6d 100644 --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c @@ -1121,10 +1121,9 @@ static int __devinit vortex_probe1(struct device *gendev, dev = alloc_etherdev(sizeof(*vp)); retval = -ENOMEM; - if (!dev) { - pr_err(PFX "unable to allocate etherdev, aborting\n"); + if (!dev) goto out; - } + SET_NETDEV_DEV(dev, gendev); vp = netdev_priv(dev); diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c index cb4f38a17f20..11fc2eccb0fd 100644 --- a/drivers/net/ethernet/adaptec/starfire.c +++ b/drivers/net/ethernet/adaptec/starfire.c @@ -686,10 +686,9 @@ static int __devinit starfire_init_one(struct pci_dev *pdev, } dev = alloc_etherdev(sizeof(*np)); - if (!dev) { - printk(KERN_ERR DRV_NAME " %d: cannot alloc etherdev, aborting\n", card_idx); + if (!dev) return -ENOMEM; - } + SET_NETDEV_DEV(dev, &pdev->dev); irq = pdev->irq; diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c index d812a103e032..525a9768bb54 100644 --- a/drivers/net/ethernet/adi/bfin_mac.c +++ b/drivers/net/ethernet/adi/bfin_mac.c @@ -1467,10 +1467,8 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev) int rc; ndev = alloc_etherdev(sizeof(struct bfin_mac_local)); - if (!ndev) { - dev_err(&pdev->dev, "Cannot allocate net device!\n"); + if (!ndev) return -ENOMEM; - } SET_NETDEV_DEV(ndev, &pdev->dev); platform_set_drvdata(pdev, ndev); diff --git a/drivers/net/ethernet/alteon/acenic.c b/drivers/net/ethernet/alteon/acenic.c index f872748ab4e6..6c3b1c0adaa0 100644 --- a/drivers/net/ethernet/alteon/acenic.c +++ b/drivers/net/ethernet/alteon/acenic.c @@ -463,11 +463,8 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev, static int boards_found; dev = alloc_etherdev(sizeof(struct ace_private)); - if (dev == NULL) { - printk(KERN_ERR "acenic: Unable to allocate " - "net_device structure!\n"); + if (dev == NULL) return -ENOMEM; - } SET_NETDEV_DEV(dev, &pdev->dev); diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c index 33e0a8c20f6b..b8306a589558 100644 --- a/drivers/net/ethernet/amd/amd8111e.c +++ b/drivers/net/ethernet/amd/amd8111e.c @@ -1859,7 +1859,6 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev, dev = alloc_etherdev(sizeof(struct amd8111e_priv)); if (!dev) { - printk(KERN_ERR "amd8111e: Etherdev alloc failed, exiting.\n"); err = -ENOMEM; goto err_free_reg; } diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index 8b95dd314253..a81c871aeacf 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -1077,7 +1077,6 @@ static int __devinit au1000_probe(struct platform_device *pdev) dev = alloc_etherdev(sizeof(struct au1000_private)); if (!dev) { - dev_err(&pdev->dev, "alloc_etherdev failed\n"); err = -ENOMEM; goto err_alloc; } diff --git a/drivers/net/ethernet/amd/declance.c b/drivers/net/ethernet/amd/declance.c index 73f8d4fa682d..dd82ee2f8d21 100644 --- a/drivers/net/ethernet/amd/declance.c +++ b/drivers/net/ethernet/amd/declance.c @@ -1052,8 +1052,6 @@ static int __devinit dec_lance_probe(struct device *bdev, const int type) dev = alloc_etherdev(sizeof(struct lance_private)); if (!dev) { - printk(KERN_ERR "%s: Unable to allocate etherdev, aborting.\n", - name); ret = -ENOMEM; goto err_out; } diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index 20e6dab0186c..1bb388f62e5b 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c @@ -1649,8 +1649,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) dev = alloc_etherdev(sizeof(*lp)); if (!dev) { - if (pcnet32_debug & NETIF_MSG_PROBE) - pr_err("Memory allocation failed\n"); ret = -ENOMEM; goto err_release_region; } diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c index 4108ac800cf0..ebc0dba5ba33 100644 --- a/drivers/net/ethernet/apple/bmac.c +++ b/drivers/net/ethernet/apple/bmac.c @@ -1269,10 +1269,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i memcpy(addr, prop_addr, sizeof(addr)); dev = alloc_etherdev(PRIV_BYTES); - if (!dev) { - printk(KERN_ERR "BMAC: alloc_etherdev failed, out of memory\n"); + if (!dev) return -ENOMEM; - } bp = netdev_priv(dev); SET_NETDEV_DEV(dev, &mdev->ofdev.dev); diff --git a/drivers/net/ethernet/apple/mace.c b/drivers/net/ethernet/apple/mace.c index 45ba18ee3d6a..bd5555dbe027 100644 --- a/drivers/net/ethernet/apple/mace.c +++ b/drivers/net/ethernet/apple/mace.c @@ -147,7 +147,6 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i dev = alloc_etherdev(PRIV_BYTES); if (!dev) { - printk(KERN_ERR "MACE: can't allocate ethernet device !\n"); rc = -ENOMEM; goto err_release; } diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index b8591246eb4c..7ee4aacb01a4 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c @@ -2689,7 +2689,6 @@ static int __devinit atl1c_probe(struct pci_dev *pdev, netdev = alloc_etherdev(sizeof(struct atl1c_adapter)); if (netdev == NULL) { err = -ENOMEM; - dev_err(&pdev->dev, "etherdev alloc failed\n"); goto err_alloc_etherdev; } diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index c915c0873810..93ff2b231284 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -2300,7 +2300,6 @@ static int __devinit atl1e_probe(struct pci_dev *pdev, netdev = alloc_etherdev(sizeof(struct atl1e_adapter)); if (netdev == NULL) { err = -ENOMEM; - dev_err(&pdev->dev, "etherdev alloc failed\n"); goto err_alloc_etherdev; } diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c index 3fb66d09ece5..66f53c797e3a 100644 --- a/drivers/net/ethernet/broadcom/b44.c +++ b/drivers/net/ethernet/broadcom/b44.c @@ -2138,7 +2138,6 @@ static int __devinit b44_init_one(struct ssb_device *sdev, dev = alloc_etherdev(sizeof(*bp)); if (!dev) { - dev_err(sdev->dev, "Etherdev alloc failed, aborting\n"); err = -ENOMEM; goto out; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 582cbcf5f9fb..ff19c3cf4409 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -11133,10 +11133,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, /* dev zeroed in init_etherdev */ dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count); - if (!dev) { - dev_err(&pdev->dev, "Cannot allocate net device\n"); + if (!dev) return -ENOMEM; - } bp = netdev_priv(dev); diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c index 084904ceaa30..49e7a258da8a 100644 --- a/drivers/net/ethernet/broadcom/sb1250-mac.c +++ b/drivers/net/ethernet/broadcom/sb1250-mac.c @@ -2623,8 +2623,6 @@ static int __devinit sbmac_probe(struct platform_device *pldev) */ dev = alloc_etherdev(sizeof(struct sbmac_softc)); if (!dev) { - printk(KERN_ERR "%s: unable to allocate etherdev\n", - dev_name(&pldev->dev)); err = -ENOMEM; goto out_unmap; } diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index a1f2e0fed78b..3bf3adca3695 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -15471,7 +15471,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS); if (!dev) { - dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n"); err = -ENOMEM; goto err_out_power_down; } diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index be7d91e4b785..ff78f770dec9 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -3284,7 +3284,6 @@ bnad_pci_probe(struct pci_dev *pdev, */ netdev = alloc_etherdev(sizeof(struct bnad)); if (!netdev) { - dev_err(&pdev->dev, "netdev allocation failed\n"); err = -ENOMEM; return err; } diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 23200680d4c1..3c315f46859b 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -1308,10 +1308,8 @@ static int __init macb_probe(struct platform_device *pdev) err = -ENOMEM; dev = alloc_etherdev(sizeof(*bp)); - if (!dev) { - dev_err(&pdev->dev, "etherdev alloc failed, aborting.\n"); + if (!dev) goto err_out; - } SET_NETDEV_DEV(dev, &pdev->dev); diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index e53365a71484..9045a451d4a9 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -2596,8 +2596,6 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, netdev = alloc_etherdev_mq(sizeof(struct port_info), MAX_PORT_QSETS); if (netdev == NULL) { - dev_err(&pdev->dev, "cannot allocate netdev for" - " port %d\n", port_id); t4vf_free_vi(adapter, viid); err = -ENOMEM; goto err_free_dev; diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 07df13745c43..2838891a94ee 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -2280,10 +2280,8 @@ static int __devinit enic_probe(struct pci_dev *pdev, */ netdev = alloc_etherdev(sizeof(struct enic)); - if (!netdev) { - pr_err("Etherdev alloc failed, aborting\n"); + if (!netdev) return -ENOMEM; - } pci_set_drvdata(pdev, netdev); diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c index f801754c71a7..493cc6202081 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c @@ -1373,10 +1373,8 @@ dm9000_probe(struct platform_device *pdev) /* Init network device */ ndev = alloc_etherdev(sizeof(struct board_info)); - if (!ndev) { - dev_err(&pdev->dev, "could not allocate device.\n"); + if (!ndev) return -ENOMEM; - } SET_NETDEV_DEV(ndev, &pdev->dev); diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c index 4eb0d76145c2..17ecb18341c9 100644 --- a/drivers/net/ethernet/dec/tulip/tulip_core.c +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c @@ -1424,10 +1424,8 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, /* alloc_etherdev ensures aligned and zeroed private structures */ dev = alloc_etherdev (sizeof (*tp)); - if (!dev) { - pr_err("ether device alloc failed, aborting\n"); + if (!dev) return -ENOMEM; - } SET_NETDEV_DEV(dev, &pdev->dev); if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) { diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c index 988b8eb24d37..b7c73eefb54b 100644 --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c +++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c @@ -222,10 +222,9 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_ is available. */ dev = alloc_etherdev(sizeof(struct xircom_private)); - if (!dev) { - pr_err("%s: failed to allocate etherdev\n", __func__); + if (!dev) goto device_fail; - } + private = netdev_priv(dev); /* Allocate the send/receive buffers */ diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c index 925c9bafc9b9..fe48cb7dde21 100644 --- a/drivers/net/ethernet/dnet.c +++ b/drivers/net/ethernet/dnet.c @@ -854,10 +854,8 @@ static int __devinit dnet_probe(struct platform_device *pdev) err = -ENOMEM; dev = alloc_etherdev(sizeof(*bp)); - if (!dev) { - dev_err(&pdev->dev, "etherdev alloc failed, aborting.\n"); + if (!dev) goto err_out_release_mem; - } /* TODO: Actually, we have some interesting features... */ dev->features |= 0; diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 388c592b5ef5..0b723ff2294b 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -913,7 +913,6 @@ static int __devinit ethoc_probe(struct platform_device *pdev) /* allocate networking device */ netdev = alloc_etherdev(sizeof(struct ethoc)); if (!netdev) { - dev_err(&pdev->dev, "cannot allocate network device\n"); ret = -ENOMEM; goto out; } diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c index 6a5ee0776b28..3598c5408e79 100644 --- a/drivers/net/ethernet/hp/hp100.c +++ b/drivers/net/ethernet/hp/hp100.c @@ -2992,7 +2992,6 @@ static int __init hp100_isa_init(void) for (i = 0; i < HP100_DEVICES && hp100_port[i] != -1; ++i) { dev = alloc_etherdev(sizeof(struct hp100_private)); if (!dev) { - printk(KERN_WARNING "hp100: no memory for network device\n"); while (cards > 0) cleanup_dev(hp100_devlist[--cards]); diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c index 14507d1e78c5..8b73dd472475 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c @@ -2980,7 +2980,6 @@ static struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter, dev = alloc_etherdev_mq(sizeof(struct ehea_port), EHEA_MAX_PORT_RES); if (!dev) { - pr_err("no mem for net_device\n"); ret = -ENOMEM; goto out_err; } diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index d47c16e02d00..dac7ffb4eaf1 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2706,11 +2706,9 @@ static int __devinit emac_probe(struct platform_device *ofdev) /* Allocate our net_device structure */ err = -ENOMEM; ndev = alloc_etherdev(sizeof(struct emac_instance)); - if (!ndev) { - printk(KERN_ERR "%s: could not allocate ethernet device!\n", - np->full_name); + if (!ndev) goto err_gone; - } + dev = netdev_priv(ndev); dev->ndev = ndev; dev->ofdev = ofdev; diff --git a/drivers/net/ethernet/ibm/iseries_veth.c b/drivers/net/ethernet/ibm/iseries_veth.c index acc31af6594a..1cafa6562a06 100644 --- a/drivers/net/ethernet/ibm/iseries_veth.c +++ b/drivers/net/ethernet/ibm/iseries_veth.c @@ -1032,10 +1032,8 @@ static struct net_device *veth_probe_one(int vlan, } dev = alloc_etherdev(sizeof (struct veth_port)); - if (! dev) { - veth_error("Unable to allocate net_device structure!\n"); + if (!dev) return NULL; - } port = netdev_priv(dev); diff --git a/drivers/net/ethernet/icplus/ipg.c b/drivers/net/ethernet/icplus/ipg.c index 075451d0207d..3c636f16a3cb 100644 --- a/drivers/net/ethernet/icplus/ipg.c +++ b/drivers/net/ethernet/icplus/ipg.c @@ -2233,7 +2233,6 @@ static int __devinit ipg_probe(struct pci_dev *pdev, */ dev = alloc_etherdev(sizeof(struct ipg_nic_private)); if (!dev) { - pr_err("%s: alloc_etherdev failed\n", pci_name(pdev)); rc = -ENOMEM; goto err_disable_0; } diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 9436397e5725..485ab8cdac48 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -2751,11 +2751,8 @@ static int __devinit e100_probe(struct pci_dev *pdev, struct nic *nic; int err; - if (!(netdev = alloc_etherdev(sizeof(struct nic)))) { - if (((1 << debug) - 1) & NETIF_MSG_PROBE) - pr_err("Etherdev alloc failed, aborting\n"); + if (!(netdev = alloc_etherdev(sizeof(struct nic)))) return -ENOMEM; - } netdev->netdev_ops = &e100_netdev_ops; SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops); diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 27d651a80f3f..1b86d0b45f3c 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c @@ -2999,7 +2999,6 @@ jme_init_one(struct pci_dev *pdev, */ netdev = alloc_etherdev(sizeof(*jme)); if (!netdev) { - pr_err("Cannot allocate netdev structure\n"); rc = -ENOMEM; goto err_out_release_regions; } diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c index 341d10130dca..f30db1c46600 100644 --- a/drivers/net/ethernet/korina.c +++ b/drivers/net/ethernet/korina.c @@ -1108,10 +1108,9 @@ static int korina_probe(struct platform_device *pdev) int rc; dev = alloc_etherdev(sizeof(struct korina_private)); - if (!dev) { - printk(KERN_ERR DRV_NAME ": alloc_etherdev failed\n"); + if (!dev) return -ENOMEM; - } + SET_NETDEV_DEV(dev, &pdev->dev); lp = netdev_priv(dev); diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c index 85e2c6cd9708..86d2fe6e053d 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -731,6 +731,10 @@ ltq_etop_probe(struct platform_device *pdev) } dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4); + if (!dev) { + err = -ENOMEM; + goto err_out; + } strcpy(dev->name, "eth%d"); dev->netdev_ops = <q_eth_netdev_ops; dev->ethtool_ops = <q_etop_ethtool_ops; diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c index edb9bda55d55..1d61eaac8587 100644 --- a/drivers/net/ethernet/marvell/skge.c +++ b/drivers/net/ethernet/marvell/skge.c @@ -3852,10 +3852,8 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port, struct skge_port *skge; struct net_device *dev = alloc_etherdev(sizeof(*skge)); - if (!dev) { - dev_err(&hw->pdev->dev, "etherdev alloc failed\n"); + if (!dev) return NULL; - } SET_NETDEV_DEV(dev, &hw->pdev->dev); dev->netdev_ops = &skge_netdev_ops; diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 760c2b17dfd3..82c2c86a1951 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -4700,10 +4700,8 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, struct sky2_port *sky2; struct net_device *dev = alloc_etherdev(sizeof(*sky2)); - if (!dev) { - dev_err(&hw->pdev->dev, "etherdev alloc failed\n"); + if (!dev) return NULL; - } SET_NETDEV_DEV(dev, &hw->pdev->dev); dev->irq = hw->pdev->irq; diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 467ae5824875..25e6480479df 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -1047,10 +1047,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv), prof->tx_ring_num, prof->rx_ring_num); - if (dev == NULL) { - mlx4_err(mdev, "Net device allocation failed\n"); + if (dev == NULL) return -ENOMEM; - } SET_NETDEV_DEV(dev, &mdev->dev->pdev->dev); dev->dev_id = port - 1; diff --git a/drivers/net/ethernet/micrel/ks8695net.c b/drivers/net/ethernet/micrel/ks8695net.c index ab81c0dc96e2..7c717276502f 100644 --- a/drivers/net/ethernet/micrel/ks8695net.c +++ b/drivers/net/ethernet/micrel/ks8695net.c @@ -1362,10 +1362,8 @@ ks8695_probe(struct platform_device *pdev) /* Initialise a net_device */ ndev = alloc_etherdev(sizeof(struct ks8695_priv)); - if (!ndev) { - dev_err(&pdev->dev, "could not allocate device.\n"); + if (!ndev) return -ENOMEM; - } SET_NETDEV_DEV(ndev, &pdev->dev); diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 134c4d07936b..4b551feae4c5 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -1419,10 +1419,8 @@ static int __devinit ks8851_probe(struct spi_device *spi) int ret; ndev = alloc_etherdev(sizeof(struct ks8851_net)); - if (!ndev) { - dev_err(&spi->dev, "failed to alloc ethernet device\n"); + if (!ndev) return -ENOMEM; - } spi->bits_per_word = 8; diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c index 50055e0282ed..c813e5d8db9d 100644 --- a/drivers/net/ethernet/microchip/enc28j60.c +++ b/drivers/net/ethernet/microchip/enc28j60.c @@ -1553,9 +1553,6 @@ static int __devinit enc28j60_probe(struct spi_device *spi) dev = alloc_etherdev(sizeof(struct enc28j60_net)); if (!dev) { - if (netif_msg_drv(&debug)) - dev_err(&spi->dev, DRV_NAME - ": unable to alloc new ethernet\n"); ret = -ENOMEM; goto error_alloc; } diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c index 20b72ecb020a..27273ae1a6e6 100644 --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c @@ -3910,10 +3910,8 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int board_number; netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES); - if (netdev == NULL) { - dev_err(dev, "Could not allocate ethernet device\n"); + if (netdev == NULL) return -ENOMEM; - } SET_NETDEV_DEV(netdev, &pdev->dev); diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c index 97f63e12d86e..138584608809 100644 --- a/drivers/net/ethernet/neterion/s2io.c +++ b/drivers/net/ethernet/neterion/s2io.c @@ -7760,7 +7760,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) else dev = alloc_etherdev(sizeof(struct s2io_nic)); if (dev == NULL) { - DBG_PRINT(ERR_DBG, "Device allocation failed\n"); pci_disable_device(pdev); pci_release_regions(pdev); return -ENODEV; diff --git a/drivers/net/ethernet/netx-eth.c b/drivers/net/ethernet/netx-eth.c index a18bb10b4f0c..5a12276f810d 100644 --- a/drivers/net/ethernet/netx-eth.c +++ b/drivers/net/ethernet/netx-eth.c @@ -383,7 +383,6 @@ static int netx_eth_drv_probe(struct platform_device *pdev) ndev = alloc_etherdev(sizeof (struct netx_eth_priv)); if (!ndev) { - printk("%s: could not allocate device.\n", CARDNAME); ret = -ENOMEM; goto exit; } 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 0217991fede7..bdbec7e04a4c 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 @@ -2419,8 +2419,6 @@ static int pch_gbe_probe(struct pci_dev *pdev, netdev = alloc_etherdev((int)sizeof(struct pch_gbe_adapter)); if (!netdev) { ret = -ENOMEM; - dev_err(&pdev->dev, - "ERR: Can't allocate and set up an Ethernet device\n"); goto err_release_pci; } SET_NETDEV_DEV(netdev, &pdev->dev); diff --git a/drivers/net/ethernet/packetengines/yellowfin.c b/drivers/net/ethernet/packetengines/yellowfin.c index db44e9af03c3..4a5774271bd4 100644 --- a/drivers/net/ethernet/packetengines/yellowfin.c +++ b/drivers/net/ethernet/packetengines/yellowfin.c @@ -397,10 +397,9 @@ static int __devinit yellowfin_init_one(struct pci_dev *pdev, if (i) return i; dev = alloc_etherdev(sizeof(*np)); - if (!dev) { - pr_err("cannot allocate ethernet device\n"); + if (!dev) return -ENOMEM; - } + SET_NETDEV_DEV(dev, &pdev->dev); np = netdev_priv(dev); diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 49b549ff2c78..3bb725ed2703 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c @@ -1740,8 +1740,6 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent) dev = alloc_etherdev(sizeof(struct pasemi_mac)); if (dev == NULL) { - dev_err(&pdev->dev, - "pasemi_mac: Could not allocate ethernet device.\n"); err = -ENOMEM; goto out_disable_device; } diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 7dd9a4b107e6..64aa44d5dabb 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -1403,7 +1403,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev = alloc_etherdev(sizeof(struct netxen_adapter)); if(!netdev) { - dev_err(&pdev->dev, "failed to allocate net_device\n"); err = -ENOMEM; goto err_out_free_res; } diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index 7931531c3a40..d49f6dac51fd 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c @@ -3805,7 +3805,6 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev, ndev = alloc_etherdev(sizeof(struct ql3_adapter)); if (!ndev) { - pr_err("%s could not alloc etherdev\n", pci_name(pdev)); err = -ENOMEM; goto err_out_free_regions; } diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 69b8e4ef14d9..7bfdf57f4b76 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -1576,7 +1576,6 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev = alloc_etherdev(sizeof(struct qlcnic_adapter)); if (!netdev) { - dev_err(&pdev->dev, "failed to allocate net_device\n"); err = -ENOMEM; goto err_out_free_res; } diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index cb0eca807852..76cab284876b 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -1107,7 +1107,6 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, dev = alloc_etherdev(sizeof(struct r6040_private)); if (!dev) { - dev_err(&pdev->dev, "Failed to allocate etherdev\n"); err = -ENOMEM; goto err_out; } diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index a8779bedb3d9..1c3feb0116b5 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c @@ -754,10 +754,9 @@ static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev) /* dev and priv zeroed in alloc_etherdev */ dev = alloc_etherdev (sizeof (*tp)); - if (dev == NULL) { - dev_err(&pdev->dev, "Unable to alloc new net device\n"); + if (dev == NULL) return ERR_PTR(-ENOMEM); - } + SET_NETDEV_DEV(dev, &pdev->dev); tp = netdev_priv(dev); diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 707742207c75..5eb6858ed0a7 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -4008,8 +4008,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev = alloc_etherdev(sizeof (*tp)); if (!dev) { - if (netif_msg_drv(&debug)) - dev_err(&pdev->dev, "unable to alloc new ethernet\n"); rc = -ENOMEM; goto out; } diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 813d41c4a845..1cb5a34d5779 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1792,7 +1792,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ndev = alloc_etherdev(sizeof(struct sh_eth_private)); if (!ndev) { - dev_err(&pdev->dev, "Could not allocate device.\n"); ret = -ENOMEM; goto out; } diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c index 22e9c0181ce8..bee97033167d 100644 --- a/drivers/net/ethernet/s6gmac.c +++ b/drivers/net/ethernet/s6gmac.c @@ -960,11 +960,11 @@ static int __devinit s6gmac_probe(struct platform_device *pdev) int res; unsigned long i; struct mii_bus *mb; + dev = alloc_etherdev(sizeof(*pd)); - if (!dev) { - printk(KERN_ERR DRV_PRMT "etherdev alloc failed, aborting.\n"); + if (!dev) return -ENOMEM; - } + dev->open = s6gmac_open; dev->stop = s6gmac_stop; dev->hard_start_xmit = s6gmac_tx; diff --git a/drivers/net/ethernet/seeq/sgiseeq.c b/drivers/net/ethernet/seeq/sgiseeq.c index f955a19eb22f..bb8c8222122b 100644 --- a/drivers/net/ethernet/seeq/sgiseeq.c +++ b/drivers/net/ethernet/seeq/sgiseeq.c @@ -733,7 +733,6 @@ static int __devinit sgiseeq_probe(struct platform_device *pdev) dev = alloc_etherdev(sizeof (struct sgiseeq_private)); if (!dev) { - printk(KERN_ERR "Sgiseeq: Etherdev alloc failed, aborting.\n"); err = -ENOMEM; goto err_out; } diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c index 5b118cd5bf94..a9deda8eaf63 100644 --- a/drivers/net/ethernet/sis/sis190.c +++ b/drivers/net/ethernet/sis/sis190.c @@ -1462,8 +1462,6 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev) dev = alloc_etherdev(sizeof(*tp)); if (!dev) { - if (netif_msg_drv(&debug)) - pr_err("unable to alloc new ethernet\n"); rc = -ENOMEM; goto err_out_0; } diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c index 2c077ce0b6d6..11dcb38b99f7 100644 --- a/drivers/net/ethernet/smsc/epic100.c +++ b/drivers/net/ethernet/smsc/epic100.c @@ -363,10 +363,9 @@ static int __devinit epic_init_one (struct pci_dev *pdev, ret = -ENOMEM; dev = alloc_etherdev(sizeof (*ep)); - if (!dev) { - dev_err(&pdev->dev, "no memory for eth device\n"); + if (!dev) goto err_out_free_res; - } + SET_NETDEV_DEV(dev, &pdev->dev); #ifdef USE_IO_OPS diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c index 313ba3b32ab4..c28230148efd 100644 --- a/drivers/net/ethernet/smsc/smc911x.c +++ b/drivers/net/ethernet/smsc/smc911x.c @@ -2065,7 +2065,6 @@ static int __devinit smc911x_drv_probe(struct platform_device *pdev) ndev = alloc_etherdev(sizeof(struct smc911x_local)); if (!ndev) { - printk("%s: could not allocate device.\n", CARDNAME); ret = -ENOMEM; goto release_1; } diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 64ad3ed74495..24104a1ee6a5 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c @@ -2223,7 +2223,6 @@ static int __devinit smc_drv_probe(struct platform_device *pdev) ndev = alloc_etherdev(sizeof(struct smc_local)); if (!ndev) { - printk("%s: could not allocate device.\n", CARDNAME); ret = -ENOMEM; goto out; } diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 24d2df068d71..6a1cd2360818 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2374,7 +2374,6 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev) dev = alloc_etherdev(sizeof(struct smsc911x_data)); if (!dev) { - pr_warn("Could not allocate device\n"); retval = -ENOMEM; goto out_release_io_1; } diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index a9efbdfe5302..595f9881e096 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c @@ -1598,10 +1598,8 @@ smsc9420_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_master(pdev); dev = alloc_etherdev(sizeof(*pd)); - if (!dev) { - printk(KERN_ERR "ether device alloc failed\n"); + if (!dev) goto out_disable_pci_device_1; - } SET_NETDEV_DEV(dev, &pdev->dev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ffc7581879b1..166fc95e5baf 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1801,10 +1801,8 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, struct stmmac_priv *priv; ndev = alloc_etherdev(sizeof(struct stmmac_priv)); - if (!ndev) { - pr_err("%s: ERROR: allocating the device\n", __func__); + if (!ndev) return NULL; - } SET_NETDEV_DEV(ndev, device); diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index 46d84abe553d..45292760fce4 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c @@ -4946,7 +4946,6 @@ static int __devinit cas_init_one(struct pci_dev *pdev, dev = alloc_etherdev(sizeof(*cp)); if (!dev) { - dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n"); err = -ENOMEM; goto err_out_disable_pdev; } diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index cf433931304f..d83c50816714 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -9685,10 +9685,8 @@ static struct net_device * __devinit niu_alloc_and_init( struct niu *np; dev = alloc_etherdev_mq(sizeof(struct niu), NIU_NUM_TXCHAN); - if (!dev) { - dev_err(gen_dev, "Etherdev alloc failed, aborting\n"); + if (!dev) return NULL; - } SET_NETDEV_DEV(dev, gen_dev); diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c index 31441a870b0b..ba041596e046 100644 --- a/drivers/net/ethernet/sun/sungem.c +++ b/drivers/net/ethernet/sun/sungem.c @@ -2885,7 +2885,6 @@ static int __devinit gem_init_one(struct pci_dev *pdev, dev = alloc_etherdev(sizeof(*gp)); if (!dev) { - pr_err("Etherdev alloc failed, aborting\n"); err = -ENOMEM; goto err_disable_device; } diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c index 2896f6e9672b..92a037a8228a 100644 --- a/drivers/net/ethernet/sun/sunvnet.c +++ b/drivers/net/ethernet/sun/sunvnet.c @@ -1026,10 +1026,8 @@ static struct vnet * __devinit vnet_new(const u64 *local_mac) int err, i; dev = alloc_etherdev(sizeof(*vp)); - if (!dev) { - pr_err("Etherdev alloc failed, aborting\n"); + if (!dev) return ERR_PTR(-ENOMEM); - } for (i = 0; i < ETH_ALEN; i++) dev->dev_addr[i] = (*local_mac >> (5 - i) * 8) & 0xff; diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c index 4b19e9b0606b..df7febba9ea6 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c @@ -1978,7 +1978,6 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ndev = alloc_etherdev(sizeof(struct bdx_priv)); if (!ndev) { err = -ENOMEM; - pr_err("alloc_etherdev failed\n"); goto err_out_iomap; } diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c index 4d9a28ffd3c3..97e1df330a17 100644 --- a/drivers/net/ethernet/ti/cpmac.c +++ b/drivers/net/ethernet/ti/cpmac.c @@ -1143,11 +1143,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev) } dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); - - if (!dev) { - printk(KERN_ERR "cpmac: Unable to allocate net_device\n"); + if (!dev) return -ENOMEM; - } platform_set_drvdata(pdev, dev); priv = netdev_priv(dev); diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 794ac30a577b..efd4f3ee1a2c 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1789,7 +1789,6 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev) ndev = alloc_etherdev(sizeof(struct emac_priv)); if (!ndev) { - dev_err(&pdev->dev, "error allocating net_device\n"); rc = -ENOMEM; goto free_clk; } diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c index 9c0dd6b8d6c9..817ad3bc4957 100644 --- a/drivers/net/ethernet/ti/tlan.c +++ b/drivers/net/ethernet/ti/tlan.c @@ -486,7 +486,6 @@ static int __devinit tlan_probe1(struct pci_dev *pdev, dev = alloc_etherdev(sizeof(struct tlan_priv)); if (dev == NULL) { - pr_err("Could not allocate memory for device\n"); rc = -ENOMEM; goto err_out_regions; } diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c index 71b785cd7563..f5ac603d5608 100644 --- a/drivers/net/ethernet/toshiba/tc35815.c +++ b/drivers/net/ethernet/toshiba/tc35815.c @@ -808,10 +808,9 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev, /* dev zeroed in alloc_etherdev */ dev = alloc_etherdev(sizeof(*lp)); - if (dev == NULL) { - dev_err(&pdev->dev, "unable to alloc new ethernet\n"); + if (dev == NULL) return -ENOMEM; - } + SET_NETDEV_DEV(dev, &pdev->dev); lp = netdev_priv(dev); lp->dev = dev; diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c index 164fb775d7b3..fc5521c9c089 100644 --- a/drivers/net/ethernet/tundra/tsi108_eth.c +++ b/drivers/net/ethernet/tundra/tsi108_eth.c @@ -1582,10 +1582,8 @@ tsi108_init_one(struct platform_device *pdev) /* Create an ethernet device instance */ dev = alloc_etherdev(sizeof(struct tsi108_prv_data)); - if (!dev) { - printk("tsi108_eth: Could not allocate a device structure\n"); + if (!dev) return -ENOMEM; - } printk("tsi108_eth%d: probe...\n", pdev->id); data = netdev_priv(dev); diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index 10b18eb63d25..1b95daa372c4 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c @@ -927,7 +927,6 @@ static int __devinit rhine_init_one(struct pci_dev *pdev, dev = alloc_etherdev(sizeof(struct rhine_private)); if (!dev) { rc = -ENOMEM; - dev_err(&pdev->dev, "alloc_etherdev failed\n"); goto err_out; } SET_NETDEV_DEV(dev, &pdev->dev); diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c index 4128d6b8cc28..2776bbc67936 100644 --- a/drivers/net/ethernet/via/via-velocity.c +++ b/drivers/net/ethernet/via/via-velocity.c @@ -2733,10 +2733,8 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi } dev = alloc_etherdev(sizeof(struct velocity_info)); - if (!dev) { - dev_err(&pdev->dev, "allocate net device failed.\n"); + if (!dev) goto out; - } /* Chain it all together */ diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index f21addb1db95..d8eb9c9e3ee2 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -1011,10 +1011,9 @@ static int __devinit temac_of_probe(struct platform_device *op) /* Init network device structure */ ndev = alloc_etherdev(sizeof(*lp)); - if (!ndev) { - dev_err(&op->dev, "could not allocate device.\n"); + if (!ndev) return -ENOMEM; - } + ether_setup(ndev); dev_set_drvdata(&op->dev, ndev); SET_NETDEV_DEV(ndev, &op->dev); diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index ea50caf8925b..a7cf00438a36 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1486,10 +1486,8 @@ static int __devinit axienet_of_probe(struct platform_device *op) const void *addr; ndev = alloc_etherdev(sizeof(*lp)); - if (!ndev) { - dev_err(&op->dev, "could not allocate device.\n"); + if (!ndev) return -ENOMEM; - } ether_setup(ndev); dev_set_drvdata(&op->dev, ndev); diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c index 79013e5731a5..90e611a6f6c6 100644 --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c @@ -1136,10 +1136,8 @@ static int __devinit xemaclite_of_probe(struct platform_device *ofdev) /* Create an ethernet device instance */ ndev = alloc_etherdev(sizeof(struct net_local)); - if (!ndev) { - dev_err(dev, "Could not allocate network device\n"); + if (!ndev) return -ENOMEM; - } dev_set_drvdata(dev, ndev); SET_NETDEV_DEV(ndev, &ofdev->dev); diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c index a9e9ca8a86ed..1a5a316cc968 100644 --- a/drivers/net/plip/plip.c +++ b/drivers/net/plip/plip.c @@ -1260,10 +1260,8 @@ static void plip_attach (struct parport *port) sprintf(name, "plip%d", unit); dev = alloc_etherdev(sizeof(struct net_local)); - if (!dev) { - printk(KERN_ERR "plip: memory squeeze\n"); + if (!dev) return; - } strcpy(dev->name, name); diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index 7145714a5ec9..a57f05726b57 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c @@ -497,8 +497,6 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) /* Allocate our net_device structure */ ndev = alloc_etherdev(sizeof(struct rionet_private)); if (ndev == NULL) { - printk(KERN_INFO "%s: could not allocate ethernet device.\n", - DRV_NAME); rc = -ENOMEM; goto out; } diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index 5d99b8cacd7d..752393092325 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c @@ -1332,10 +1332,8 @@ static int pegasus_probe(struct usb_interface *intf, usb_get_dev(dev); net = alloc_etherdev(sizeof(struct pegasus)); - if (!net) { - dev_err(&intf->dev, "can't allocate %s\n", "device"); + if (!net) goto out; - } pegasus = netdev_priv(net); pegasus->dev_index = dev_index; diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c index 0710b4ca9252..6dda2fe5b15b 100644 --- a/drivers/net/usb/rtl8150.c +++ b/drivers/net/usb/rtl8150.c @@ -894,10 +894,8 @@ static int rtl8150_probe(struct usb_interface *intf, struct net_device *netdev; netdev = alloc_etherdev(sizeof(rtl8150_t)); - if (!netdev) { - err("Out of memory"); + if (!netdev) return -ENOMEM; - } dev = netdev_priv(netdev); diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index fae0fbd8bc88..b924f46c963c 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1334,10 +1334,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) // set up our own records net = alloc_etherdev(sizeof(*dev)); - if (!net) { - dbg ("can't kmalloc dev"); + if (!net) goto out; - } /* netdev_printk() needs this so do it as early as possible */ SET_NETDEV_DEV(net, &udev->dev); diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index 87c0b586f11f..482cfa891f89 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -2918,11 +2918,8 @@ vmxnet3_probe_device(struct pci_dev *pdev, printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n", num_tx_queues, num_rx_queues); - if (!netdev) { - printk(KERN_ERR "Failed to alloc ethernet device for adapter " - "%s\n", pci_name(pdev)); + if (!netdev) return -ENOMEM; - } pci_set_drvdata(pdev, netdev); adapter = netdev_priv(netdev); diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 7e45ca2e78ef..3010cee7b95a 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c @@ -1533,10 +1533,9 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, /* Create the network device object. */ dev = alloc_etherdev(sizeof(*priv)); - if (!dev) { - printk(KERN_ERR "atmel: Couldn't alloc_etherdev\n"); + if (!dev) return NULL; - } + if (dev_alloc_name(dev, dev->name) < 0) { printk(KERN_ERR "atmel: Couldn't get name!\n"); goto err_out_free; diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c index d5ef696298ee..3adb24021a28 100644 --- a/drivers/net/wireless/ipw2x00/libipw_module.c +++ b/drivers/net/wireless/ipw2x00/libipw_module.c @@ -150,10 +150,9 @@ struct net_device *alloc_libipw(int sizeof_priv, int monitor) LIBIPW_DEBUG_INFO("Initializing...\n"); dev = alloc_etherdev(sizeof(struct libipw_device) + sizeof_priv); - if (!dev) { - LIBIPW_ERROR("Unable to allocate network device.\n"); + if (!dev) goto failed; - } + ieee = netdev_priv(dev); ieee->dev = dev; diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index db638b4454e3..168102e6ff6e 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1279,11 +1279,8 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev struct netfront_info *np; netdev = alloc_etherdev(sizeof(struct netfront_info)); - if (!netdev) { - printk(KERN_WARNING "%s> alloc_etherdev failed.\n", - __func__); + if (!netdev) return ERR_PTR(-ENOMEM); - } np = netdev_priv(netdev); np->xbdev = dev; -- GitLab From a8afca032998850ec63e83d555cdcf0eb5680cd6 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 31 Jan 2012 18:45:40 +0000 Subject: [PATCH 0285/1846] tcp: md5: protects md5sig_info with RCU This patch makes sure we use appropriate memory barriers before publishing tp->md5sig_info, allowing tcp_md5_do_lookup() being used from tcp_v4_send_reset() without holding socket lock (upcoming patch from Shawn Lu) Note we also need to respect rcu grace period before its freeing, since we can free socket without this grace period thanks to SLAB_DESTROY_BY_RCU Signed-off-by: Eric Dumazet Cc: Shawn Lu Signed-off-by: David S. Miller --- include/linux/tcp.h | 2 +- include/net/tcp.h | 1 + net/ipv4/tcp_ipv4.c | 32 ++++++++++++++++++++------------ net/ipv6/tcp_ipv6.c | 2 -- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index c2025f159641..115389e9b945 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -463,7 +463,7 @@ struct tcp_sock { const struct tcp_sock_af_ops *af_specific; /* TCP MD5 Signature Option information */ - struct tcp_md5sig_info *md5sig_info; + struct tcp_md5sig_info __rcu *md5sig_info; #endif /* When the cookie options are generated and exchanged, then this diff --git a/include/net/tcp.h b/include/net/tcp.h index 10ae4c7b6b4f..78880ba0f560 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1150,6 +1150,7 @@ struct tcp_md5sig_key { /* - sock block */ struct tcp_md5sig_info { struct hlist_head head; + struct rcu_head rcu; }; /* - pseudo header */ diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index da5d3226771b..567cca9b30df 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -879,14 +879,18 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, struct tcp_md5sig_key *key; struct hlist_node *pos; unsigned int size = sizeof(struct in_addr); + struct tcp_md5sig_info *md5sig; - if (!tp->md5sig_info) + /* caller either holds rcu_read_lock() or socket lock */ + md5sig = rcu_dereference_check(tp->md5sig_info, + sock_owned_by_user(sk)); + if (!md5sig) return NULL; #if IS_ENABLED(CONFIG_IPV6) if (family == AF_INET6) size = sizeof(struct in6_addr); #endif - hlist_for_each_entry_rcu(key, pos, &tp->md5sig_info->head, node) { + hlist_for_each_entry_rcu(key, pos, &md5sig->head, node) { if (key->family != family) continue; if (!memcmp(&key->addr, addr, size)) @@ -932,7 +936,8 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, return 0; } - md5sig = tp->md5sig_info; + md5sig = rcu_dereference_protected(tp->md5sig_info, + sock_owned_by_user(sk)); if (!md5sig) { md5sig = kmalloc(sizeof(*md5sig), gfp); if (!md5sig) @@ -940,7 +945,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, sk_nocaps_add(sk, NETIF_F_GSO_MASK); INIT_HLIST_HEAD(&md5sig->head); - tp->md5sig_info = md5sig; + rcu_assign_pointer(tp->md5sig_info, md5sig); } key = sock_kmalloc(sk, sizeof(*key), gfp); @@ -966,6 +971,7 @@ int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family) { struct tcp_sock *tp = tcp_sk(sk); struct tcp_md5sig_key *key; + struct tcp_md5sig_info *md5sig; key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET); if (!key) @@ -973,7 +979,9 @@ int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family) hlist_del_rcu(&key->node); atomic_sub(sizeof(*key), &sk->sk_omem_alloc); kfree_rcu(key, rcu); - if (hlist_empty(&tp->md5sig_info->head)) + md5sig = rcu_dereference_protected(tp->md5sig_info, + sock_owned_by_user(sk)); + if (hlist_empty(&md5sig->head)) tcp_free_md5sig_pool(); return 0; } @@ -984,10 +992,13 @@ void tcp_clear_md5_list(struct sock *sk) struct tcp_sock *tp = tcp_sk(sk); struct tcp_md5sig_key *key; struct hlist_node *pos, *n; + struct tcp_md5sig_info *md5sig; - if (!hlist_empty(&tp->md5sig_info->head)) + md5sig = rcu_dereference_protected(tp->md5sig_info, 1); + + if (!hlist_empty(&md5sig->head)) tcp_free_md5sig_pool(); - hlist_for_each_entry_safe(key, pos, n, &tp->md5sig_info->head, node) { + hlist_for_each_entry_safe(key, pos, n, &md5sig->head, node) { hlist_del_rcu(&key->node); atomic_sub(sizeof(*key), &sk->sk_omem_alloc); kfree_rcu(key, rcu); @@ -1009,12 +1020,9 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval, if (sin->sin_family != AF_INET) return -EINVAL; - if (!cmd.tcpm_key || !cmd.tcpm_keylen) { - if (!tcp_sk(sk)->md5sig_info) - return -ENOENT; + if (!cmd.tcpm_key || !cmd.tcpm_keylen) return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr, AF_INET); - } if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) return -EINVAL; @@ -1896,7 +1904,7 @@ void tcp_v4_destroy_sock(struct sock *sk) /* Clean up the MD5 key list, if any */ if (tp->md5sig_info) { tcp_clear_md5_list(sk); - kfree(tp->md5sig_info); + kfree_rcu(tp->md5sig_info, rcu); tp->md5sig_info = NULL; } #endif diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index bec41f9a6413..c25018106ef2 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -571,8 +571,6 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval, return -EINVAL; if (!cmd.tcpm_keylen) { - if (!tcp_sk(sk)->md5sig_info) - return -ENOENT; if (ipv6_addr_v4mapped(&sin6->sin6_addr)) return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3], AF_INET); -- GitLab From 5b11b2e4bdef20e839d90dce96c5bbeafaf9616c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 31 Jan 2012 21:45:26 +0000 Subject: [PATCH 0286/1846] xfrm6: remove unneeded NULL check in __xfrm6_output() We don't check for NULL consistently in __xfrm6_output(). If "x" were NULL here it would lead to an OOPs later. I asked Steffen Klassert about this and he suggested that we remove the NULL check. On 10/29/11, Steffen Klassert wrote: >> net/ipv6/xfrm6_output.c >> 148 >> 149 if ((x && x->props.mode == XFRM_MODE_TUNNEL) && >> ^ > > x can't be null here. It would be a bug if __xfrm6_output() is called > without a xfrm_state attached to the skb. I think we can just remove > this null check. Cc: Steffen Klassert Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller --- net/ipv6/xfrm6_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 4eeff89c1aaa..8755a3079d0f 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c @@ -146,7 +146,7 @@ static int __xfrm6_output(struct sk_buff *skb) return -EMSGSIZE; } - if ((x && x->props.mode == XFRM_MODE_TUNNEL) && + if (x->props.mode == XFRM_MODE_TUNNEL && ((skb->len > mtu && !skb_is_gso(skb)) || dst_allfrag(skb_dst(skb)))) { return ip6_fragment(skb, x->outer_mode->afinfo->output_finish); -- GitLab From 658ddaaf6694adf63f67451dec9ddeb87a7cb2d7 Mon Sep 17 00:00:00 2001 From: Shawn Lu Date: Tue, 31 Jan 2012 22:35:48 +0000 Subject: [PATCH 0287/1846] tcp: md5: RST: getting md5 key from listener TCP RST mechanism is broken in TCP md5(RFC2385). When connection is gone, md5 key is lost, sending RST without md5 hash is deem to ignored by peer. This can be a problem since RST help protocal like bgp to fast recove from peer crash. In most case, users of tcp md5, such as bgp and ldp, have listener on both sides to accept connection from peer. md5 keys for peers are saved in listening socket. There are two cases in finding md5 key when connection is lost: 1.Passive receive RST: The message is send to well known port, tcp will associate it with listner. md5 key is gotten from listener. 2.Active receive RST (no sock): The message is send to ative side, there is no socket associated with the message. In this case, finding listener from source port, then find md5 key from listener. we are not loosing sercuriy here: packet is checked with md5 hash. No RST is generated if md5 hash doesn't match or no md5 key can be found. Signed-off-by: Shawn Lu Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- net/ipv4/tcp_ipv4.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- net/ipv6/tcp_ipv6.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 567cca9b30df..90e47931e217 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -593,6 +593,10 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) struct ip_reply_arg arg; #ifdef CONFIG_TCP_MD5SIG struct tcp_md5sig_key *key; + const __u8 *hash_location = NULL; + unsigned char newhash[16]; + int genhash; + struct sock *sk1 = NULL; #endif struct net *net; @@ -623,9 +627,36 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) arg.iov[0].iov_len = sizeof(rep.th); #ifdef CONFIG_TCP_MD5SIG - key = sk ? tcp_md5_do_lookup(sk, - (union tcp_md5_addr *)&ip_hdr(skb)->saddr, - AF_INET) : NULL; + hash_location = tcp_parse_md5sig_option(th); + if (!sk && hash_location) { + /* + * active side is lost. Try to find listening socket through + * source port, and then find md5 key through listening socket. + * we are not loose security here: + * Incoming packet is checked with md5 hash with finding key, + * no RST generated if md5 hash doesn't match. + */ + sk1 = __inet_lookup_listener(dev_net(skb_dst(skb)->dev), + &tcp_hashinfo, ip_hdr(skb)->daddr, + ntohs(th->source), inet_iif(skb)); + /* don't send rst if it can't find key */ + if (!sk1) + return; + rcu_read_lock(); + key = tcp_md5_do_lookup(sk1, (union tcp_md5_addr *) + &ip_hdr(skb)->saddr, AF_INET); + if (!key) + goto release_sk1; + + genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, NULL, skb); + if (genhash || memcmp(hash_location, newhash, 16) != 0) + goto release_sk1; + } else { + key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *) + &ip_hdr(skb)->saddr, + AF_INET) : NULL; + } + if (key) { rep.opt[0] = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | @@ -653,6 +684,14 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); + +#ifdef CONFIG_TCP_MD5SIG +release_sk1: + if (sk1) { + rcu_read_unlock(); + sock_put(sk1); + } +#endif } /* The code following below sending ACKs in SYN-RECV and TIME-WAIT states diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index c25018106ef2..d16414cb3421 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -923,6 +923,13 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) const struct tcphdr *th = tcp_hdr(skb); u32 seq = 0, ack_seq = 0; struct tcp_md5sig_key *key = NULL; +#ifdef CONFIG_TCP_MD5SIG + const __u8 *hash_location = NULL; + struct ipv6hdr *ipv6h = ipv6_hdr(skb); + unsigned char newhash[16]; + int genhash; + struct sock *sk1 = NULL; +#endif if (th->rst) return; @@ -931,8 +938,32 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) return; #ifdef CONFIG_TCP_MD5SIG - if (sk) - key = tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr); + hash_location = tcp_parse_md5sig_option(th); + if (!sk && hash_location) { + /* + * active side is lost. Try to find listening socket through + * source port, and then find md5 key through listening socket. + * we are not loose security here: + * Incoming packet is checked with md5 hash with finding key, + * no RST generated if md5 hash doesn't match. + */ + sk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev), + &tcp_hashinfo, &ipv6h->daddr, + ntohs(th->source), inet6_iif(skb)); + if (!sk1) + return; + + rcu_read_lock(); + key = tcp_v6_md5_do_lookup(sk1, &ipv6h->saddr); + if (!key) + goto release_sk1; + + genhash = tcp_v6_md5_hash_skb(newhash, key, NULL, NULL, skb); + if (genhash || memcmp(hash_location, newhash, 16) != 0) + goto release_sk1; + } else { + key = sk ? tcp_v6_md5_do_lookup(sk, &ipv6h->saddr) : NULL; + } #endif if (th->ack) @@ -942,6 +973,14 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) (th->doff << 2); tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1, 0); + +#ifdef CONFIG_TCP_MD5SIG +release_sk1: + if (sk1) { + rcu_read_unlock(); + sock_put(sk1); + } +#endif } static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts, -- GitLab From b5d5843a1dd0031d63d9d9484346d86eae9cab3b Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Fri, 27 Jan 2012 04:24:55 +0000 Subject: [PATCH 0288/1846] mISDN: use memchr_inv Use memchr_inv to check if the data contains all same bytes. It is faster than looping for each byte. Signed-off-by: Akinobu Mita Cc: Karsten Keil Cc: netdev@vger.kernel.org Signed-off-by: David S. Miller --- drivers/isdn/mISDN/l1oip_core.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c index 22f8ec8b9247..04f115a9c43e 100644 --- a/drivers/isdn/mISDN/l1oip_core.c +++ b/drivers/isdn/mISDN/l1oip_core.c @@ -1112,7 +1112,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) struct l1oip *hc = bch->hw; int ret = -EINVAL; struct mISDNhead *hh = mISDN_HEAD_P(skb); - int l, ll, i; + int l, ll; unsigned char *p; switch (hh->prim) { @@ -1128,13 +1128,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) break; } /* check for AIS / ulaw-silence */ - p = skb->data; l = skb->len; - for (i = 0; i < l; i++) { - if (*p++ != 0xff) - break; - } - if (i == l) { + if (!memchr_inv(skb->data, 0xff, l)) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: got AIS, not sending, " "but counting\n", __func__); @@ -1144,13 +1139,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) return 0; } /* check for silence */ - p = skb->data; l = skb->len; - for (i = 0; i < l; i++) { - if (*p++ != 0x2a) - break; - } - if (i == l) { + if (!memchr_inv(skb->data, 0x2a, l)) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: got silence, not sending" ", but counting\n", __func__); -- GitLab From e6ec26935aec629f03e76c67f3bbda68dd0155e2 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 29 Jan 2012 15:50:43 +0000 Subject: [PATCH 0289/1846] netpoll: Convert printks to np_ and add pr_fmt Use a more current message logging style. Add pr_fmt to prefix dmesg output with "netpoll: " Add macros to print np->name. Signed-off-by: Joe Perches Reviewed-by: WANG Cong Signed-off-by: David S. Miller --- net/core/netpoll.c | 63 +++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 556b08298669..b5232743d5dc 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -9,6 +9,8 @@ * Copyright (C) 2002 Red Hat, Inc. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -55,6 +57,13 @@ static void arp_reply(struct sk_buff *skb); static unsigned int carrier_timeout = 4; module_param(carrier_timeout, uint, 0644); +#define np_info(np, fmt, ...) \ + pr_info("%s: " fmt, np->name, ##__VA_ARGS__) +#define np_err(np, fmt, ...) \ + pr_err("%s: " fmt, np->name, ##__VA_ARGS__) +#define np_notice(np, fmt, ...) \ + pr_notice("%s: " fmt, np->name, ##__VA_ARGS__) + static void queue_process(struct work_struct *work) { struct netpoll_info *npinfo = @@ -627,18 +636,12 @@ int __netpoll_rx(struct sk_buff *skb) void netpoll_print_options(struct netpoll *np) { - printk(KERN_INFO "%s: local port %d\n", - np->name, np->local_port); - printk(KERN_INFO "%s: local IP %pI4\n", - np->name, &np->local_ip); - printk(KERN_INFO "%s: interface '%s'\n", - np->name, np->dev_name); - printk(KERN_INFO "%s: remote port %d\n", - np->name, np->remote_port); - printk(KERN_INFO "%s: remote IP %pI4\n", - np->name, &np->remote_ip); - printk(KERN_INFO "%s: remote ethernet address %pM\n", - np->name, np->remote_mac); + np_info(np, "local port %d\n", np->local_port); + np_info(np, "local IP %pI4\n", &np->local_ip); + np_info(np, "interface '%s'\n", np->dev_name); + np_info(np, "remote port %d\n", np->remote_port); + np_info(np, "remote IP %pI4\n", &np->remote_ip); + np_info(np, "remote ethernet address %pM\n", np->remote_mac); } EXPORT_SYMBOL(netpoll_print_options); @@ -680,8 +683,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt) goto parse_failed; *delim = 0; if (*cur == ' ' || *cur == '\t') - printk(KERN_INFO "%s: warning: whitespace" - "is not allowed\n", np->name); + np_info(np, "warning: whitespace is not allowed\n"); np->remote_port = simple_strtol(cur, NULL, 10); cur = delim; } @@ -705,8 +707,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt) return 0; parse_failed: - printk(KERN_INFO "%s: couldn't parse config at '%s'!\n", - np->name, cur); + np_info(np, "couldn't parse config at '%s'!\n", cur); return -1; } EXPORT_SYMBOL(netpoll_parse_options); @@ -721,8 +722,8 @@ int __netpoll_setup(struct netpoll *np) if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) || !ndev->netdev_ops->ndo_poll_controller) { - printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", - np->name, np->dev_name); + np_err(np, "%s doesn't support polling, aborting\n", + np->dev_name); err = -ENOTSUPP; goto out; } @@ -785,14 +786,12 @@ int netpoll_setup(struct netpoll *np) if (np->dev_name) ndev = dev_get_by_name(&init_net, np->dev_name); if (!ndev) { - printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", - np->name, np->dev_name); + np_err(np, "%s doesn't exist, aborting\n", np->dev_name); return -ENODEV; } if (ndev->master) { - printk(KERN_ERR "%s: %s is a slave device, aborting.\n", - np->name, np->dev_name); + np_err(np, "%s is a slave device, aborting\n", np->dev_name); err = -EBUSY; goto put; } @@ -800,16 +799,14 @@ int netpoll_setup(struct netpoll *np) if (!netif_running(ndev)) { unsigned long atmost, atleast; - printk(KERN_INFO "%s: device %s not up yet, forcing it\n", - np->name, np->dev_name); + np_info(np, "device %s not up yet, forcing it\n", np->dev_name); rtnl_lock(); err = dev_open(ndev); rtnl_unlock(); if (err) { - printk(KERN_ERR "%s: failed to open %s\n", - np->name, ndev->name); + np_err(np, "failed to open %s\n", ndev->name); goto put; } @@ -817,9 +814,7 @@ int netpoll_setup(struct netpoll *np) atmost = jiffies + carrier_timeout * HZ; while (!netif_carrier_ok(ndev)) { if (time_after(jiffies, atmost)) { - printk(KERN_NOTICE - "%s: timeout waiting for carrier\n", - np->name); + np_notice(np, "timeout waiting for carrier\n"); break; } msleep(1); @@ -831,9 +826,7 @@ int netpoll_setup(struct netpoll *np) */ if (time_before(jiffies, atleast)) { - printk(KERN_NOTICE "%s: carrier detect appears" - " untrustworthy, waiting 4 seconds\n", - np->name); + np_notice(np, "carrier detect appears untrustworthy, waiting 4 seconds\n"); msleep(4000); } } @@ -844,15 +837,15 @@ int netpoll_setup(struct netpoll *np) if (!in_dev || !in_dev->ifa_list) { rcu_read_unlock(); - printk(KERN_ERR "%s: no IP address for %s, aborting\n", - np->name, np->dev_name); + np_err(np, "no IP address for %s, aborting\n", + np->dev_name); err = -EDESTADDRREQ; goto put; } np->local_ip = in_dev->ifa_list->ifa_local; rcu_read_unlock(); - printk(KERN_INFO "%s: local IP %pI4\n", np->name, &np->local_ip); + np_info(np, "local IP %pI4\n", &np->local_ip); } np->dev = ndev; -- GitLab From 6f7062457fc98e1fa22f74d8f386ed241213dec6 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 29 Jan 2012 15:50:44 +0000 Subject: [PATCH 0290/1846] netpoll: Neaten MAX_SKB_SIZE macro Add the types in the packet layout order. Signed-off-by: Joe Perches Reviewed-by: WANG Cong Signed-off-by: David S. Miller --- net/core/netpoll.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index b5232743d5dc..4ce473ea5dc0 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -47,9 +47,11 @@ static atomic_t trapped; #define NETPOLL_RX_ENABLED 1 #define NETPOLL_RX_DROP 2 -#define MAX_SKB_SIZE \ - (MAX_UDP_CHUNK + sizeof(struct udphdr) + \ - sizeof(struct iphdr) + sizeof(struct ethhdr)) +#define MAX_SKB_SIZE \ + (sizeof(struct ethhdr) + \ + sizeof(struct iphdr) + \ + sizeof(struct udphdr) + \ + MAX_UDP_CHUNK) static void zap_completion_queue(void); static void arp_reply(struct sk_buff *skb); -- GitLab From 8ef78adcb03b1fcb53c3bd62df4e96c1d2706c58 Mon Sep 17 00:00:00 2001 From: Peter P Waskiewicz Jr Date: Wed, 1 Feb 2012 09:19:21 +0000 Subject: [PATCH 0291/1846] ixgbe: Add module parameter to allow untested and unsafe SFP+ modules The X520 family of network devices, with the 82599 chip, support a small number of Intel-verified SFP+ modules on their NICs. To maintain stability and quality, the current devices restrict untested 3rd party SFP+ modules. This patch introduces a module parameter for ixgbe to allow these untested modules at the user's peril. It also includes a warning to the syslog alerting users that the modules aren't supported, and results may vary. CC: Jesper Dangaard Brouer Signed-off-by: Peter P Waskiewicz Jr Tested-by: Phil Schmitt Signed-off-by: Jeff Kirsher Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 14 +++++++++++--- drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 1ee5d0fbb905..2e8e7640b606 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -131,6 +131,11 @@ MODULE_PARM_DESC(max_vfs, "Maximum number of virtual functions to allocate per physical function"); #endif /* CONFIG_PCI_IOV */ +static unsigned int allow_unsupported_sfp; +module_param(allow_unsupported_sfp, uint, 0); +MODULE_PARM_DESC(allow_unsupported_sfp, + "Allow unsupported and untested SFP+ modules on 82599-based adapters"); + MODULE_AUTHOR("Intel Corporation, "); MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver"); MODULE_LICENSE("GPL"); @@ -7489,6 +7494,9 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, e_crit(probe, "Fan has stopped, replace the adapter\n"); } + if (allow_unsupported_sfp) + hw->allow_unsupported_sfp = allow_unsupported_sfp; + /* reset_hw fills in the perm_addr as well */ hw->phy.reset_if_overtemp = true; err = hw->mac.ops.reset_hw(hw); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c index 7cf1e1f56c69..29fda9777ffc 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c @@ -834,6 +834,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw) **/ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) { + struct ixgbe_adapter *adapter = hw->back; s32 status = IXGBE_ERR_PHY_ADDR_INVALID; u32 vendor_oui = 0; enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type; @@ -1068,9 +1069,16 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) if (hw->phy.type == ixgbe_phy_sfp_intel) { status = 0; } else { - hw_dbg(hw, "SFP+ module not supported\n"); - hw->phy.type = ixgbe_phy_sfp_unsupported; - status = IXGBE_ERR_SFP_NOT_SUPPORTED; + if (hw->allow_unsupported_sfp) { + e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules."); + status = 0; + } else { + hw_dbg(hw, + "SFP+ module not supported\n"); + hw->phy.type = + ixgbe_phy_sfp_unsupported; + status = IXGBE_ERR_SFP_NOT_SUPPORTED; + } } } else { status = 0; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 775602ef90e5..2dc5e71cb3fa 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h @@ -2892,6 +2892,7 @@ struct ixgbe_hw { u8 revision_id; bool adapter_stopped; bool force_full_reset; + bool allow_unsupported_sfp; }; struct ixgbe_info { -- GitLab From d45b9d39a1aed7851948460d29b843ce70eb0a68 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Sun, 29 Jan 2012 20:17:39 +0000 Subject: [PATCH 0292/1846] be2net: add descriptions for stat counters reported via ethtool Also rename a few counters appropritely and delete 2 counters that are not implemented in HW. vlan_mismatch_drops does not exist in BE3 and is accounted for in address_mismatch_drops. Do the same thing for BE2 and Lancer. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 3 +- drivers/net/ethernet/emulex/benet/be_cmds.h | 10 +-- .../net/ethernet/emulex/benet/be_ethtool.c | 64 ++++++++++++++++++- drivers/net/ethernet/emulex/benet/be_main.c | 15 ++--- 4 files changed, 74 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 453d48612f83..74aa14811977 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -265,7 +265,6 @@ struct be_drv_stats { u32 rx_drops_no_erx_descr; u32 rx_drops_no_tpre_descr; u32 rx_drops_too_many_frags; - u32 rx_drops_invalid_ring; u32 forwarded_packets; u32 rx_drops_mtu; u32 rx_crc_errors; @@ -276,7 +275,7 @@ struct be_drv_stats { u32 rx_in_range_errors; u32 rx_out_range_errors; u32 rx_frame_too_long; - u32 rx_address_match_errors; + u32 rx_address_mismatch_drops; u32 rx_dropped_too_small; u32 rx_dropped_too_short; u32 rx_dropped_header_too_small; diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index dca89249088f..bbd012b41fb4 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -592,8 +592,8 @@ struct be_port_rxf_stats_v0 { u32 rx_in_range_errors; /* dword 10*/ u32 rx_out_range_errors; /* dword 11*/ u32 rx_frame_too_long; /* dword 12*/ - u32 rx_address_match_errors; /* dword 13*/ - u32 rx_vlan_mismatch; /* dword 14*/ + u32 rx_address_mismatch_drops; /* dword 13*/ + u32 rx_vlan_mismatch_drops; /* dword 14*/ u32 rx_dropped_too_small; /* dword 15*/ u32 rx_dropped_too_short; /* dword 16*/ u32 rx_dropped_header_too_small; /* dword 17*/ @@ -799,8 +799,8 @@ struct lancer_pport_stats { u32 rx_control_frames_unknown_opcode_hi; u32 rx_in_range_errors; u32 rx_out_of_range_errors; - u32 rx_address_match_errors; - u32 rx_vlan_mismatch_errors; + u32 rx_address_mismatch_drops; + u32 rx_vlan_mismatch_drops; u32 rx_dropped_too_small; u32 rx_dropped_too_short; u32 rx_dropped_header_too_small; @@ -1384,7 +1384,7 @@ struct be_port_rxf_stats_v1 { u32 rx_in_range_errors; u32 rx_out_range_errors; u32 rx_frame_too_long; - u32 rx_address_match_errors; + u32 rx_address_mismatch_drops; u32 rx_dropped_too_small; u32 rx_dropped_too_short; u32 rx_dropped_header_too_small; diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index 6db6b6ae5e9b..0a5ee224cfe2 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -42,15 +42,42 @@ static const struct be_ethtool_stat et_stats[] = { {DRVSTAT_INFO(rx_alignment_symbol_errors)}, {DRVSTAT_INFO(rx_pause_frames)}, {DRVSTAT_INFO(rx_control_frames)}, + /* Received packets dropped when the Ethernet length field + * is not equal to the actual Ethernet data length. + */ {DRVSTAT_INFO(rx_in_range_errors)}, + /* Received packets dropped when their length field is >= 1501 bytes + * and <= 1535 bytes. + */ {DRVSTAT_INFO(rx_out_range_errors)}, + /* Received packets dropped when they are longer than 9216 bytes */ {DRVSTAT_INFO(rx_frame_too_long)}, - {DRVSTAT_INFO(rx_address_match_errors)}, + /* Received packets dropped when they don't pass the unicast or + * multicast address filtering. + */ + {DRVSTAT_INFO(rx_address_mismatch_drops)}, + /* Received packets dropped when IP packet length field is less than + * the IP header length field. + */ {DRVSTAT_INFO(rx_dropped_too_small)}, + /* Received packets dropped when IP length field is greater than + * the actual packet length. + */ {DRVSTAT_INFO(rx_dropped_too_short)}, + /* Received packets dropped when the IP header length field is less + * than 5. + */ {DRVSTAT_INFO(rx_dropped_header_too_small)}, + /* Received packets dropped when the TCP header length field is less + * than 5 or the TCP header length + IP header length is more + * than IP packet length. + */ {DRVSTAT_INFO(rx_dropped_tcp_length)}, {DRVSTAT_INFO(rx_dropped_runt)}, + /* Number of received packets dropped when a fifo for descriptors going + * into the packet demux block overflows. In normal operation, this + * fifo must never overflow. + */ {DRVSTAT_INFO(rxpp_fifo_overflow_drop)}, {DRVSTAT_INFO(rx_input_fifo_overflow_drop)}, {DRVSTAT_INFO(rx_ip_checksum_errs)}, @@ -59,16 +86,35 @@ static const struct be_ethtool_stat et_stats[] = { {DRVSTAT_INFO(tx_pauseframes)}, {DRVSTAT_INFO(tx_controlframes)}, {DRVSTAT_INFO(rx_priority_pause_frames)}, + /* Received packets dropped when an internal fifo going into + * main packet buffer tank (PMEM) overflows. + */ {DRVSTAT_INFO(pmem_fifo_overflow_drop)}, {DRVSTAT_INFO(jabber_events)}, + /* Received packets dropped due to lack of available HW packet buffers + * used to temporarily hold the received packets. + */ {DRVSTAT_INFO(rx_drops_no_pbuf)}, - {DRVSTAT_INFO(rx_drops_no_txpb)}, + /* Received packets dropped due to input receive buffer + * descriptor fifo overflowing. + */ {DRVSTAT_INFO(rx_drops_no_erx_descr)}, + /* Packets dropped because the internal FIFO to the offloaded TCP + * receive processing block is full. This could happen only for + * offloaded iSCSI or FCoE trarffic. + */ {DRVSTAT_INFO(rx_drops_no_tpre_descr)}, + /* Received packets dropped when they need more than 8 + * receive buffers. This cannot happen as the driver configures + * 2048 byte receive buffers. + */ {DRVSTAT_INFO(rx_drops_too_many_frags)}, - {DRVSTAT_INFO(rx_drops_invalid_ring)}, {DRVSTAT_INFO(forwarded_packets)}, + /* Received packets dropped when the frame length + * is more than 9018 bytes + */ {DRVSTAT_INFO(rx_drops_mtu)}, + /* Number of packets dropped due to random early drop function */ {DRVSTAT_INFO(eth_red_drops)}, {DRVSTAT_INFO(be_on_die_temperature)} }; @@ -84,8 +130,15 @@ static const struct be_ethtool_stat et_rx_stats[] = { {DRVSTAT_RX_INFO(rx_events)}, {DRVSTAT_RX_INFO(rx_compl)}, {DRVSTAT_RX_INFO(rx_mcast_pkts)}, + /* Number of page allocation failures while posting receive buffers + * to HW. + */ {DRVSTAT_RX_INFO(rx_post_fail)}, + /* Recevied packets dropped due to skb allocation failure */ {DRVSTAT_RX_INFO(rx_drops_no_skbs)}, + /* Received packets dropped due to lack of available fetched buffers + * posted by the driver. + */ {DRVSTAT_RX_INFO(rx_drops_no_frags)} }; #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) @@ -97,9 +150,14 @@ static const struct be_ethtool_stat et_tx_stats[] = { {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */ {DRVSTAT_TX_INFO(tx_bytes)}, {DRVSTAT_TX_INFO(tx_pkts)}, + /* Number of skbs queued for trasmission by the driver */ {DRVSTAT_TX_INFO(tx_reqs)}, + /* Number of TX work request blocks DMAed to HW */ {DRVSTAT_TX_INFO(tx_wrbs)}, {DRVSTAT_TX_INFO(tx_compl)}, + /* Number of times the TX queue was stopped due to lack + * of spaces in the TXQ. + */ {DRVSTAT_TX_INFO(tx_stops)} }; #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats)) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 0fbf365f5c62..1395f803cf7f 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -286,7 +286,9 @@ static void populate_be2_stats(struct be_adapter *adapter) drvs->rx_input_fifo_overflow_drop = port_stats->rx_input_fifo_overflow; drvs->rx_dropped_header_too_small = port_stats->rx_dropped_header_too_small; - drvs->rx_address_match_errors = port_stats->rx_address_match_errors; + drvs->rx_address_mismatch_drops = + port_stats->rx_address_mismatch_drops + + port_stats->rx_vlan_mismatch_drops; drvs->rx_alignment_symbol_errors = port_stats->rx_alignment_symbol_errors; @@ -298,9 +300,7 @@ static void populate_be2_stats(struct be_adapter *adapter) else drvs->jabber_events = rxf_stats->port0_jabber_events; drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; - drvs->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; - drvs->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; drvs->forwarded_packets = rxf_stats->forwarded_packets; drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; @@ -337,7 +337,7 @@ static void populate_be3_stats(struct be_adapter *adapter) port_stats->rx_dropped_header_too_small; drvs->rx_input_fifo_overflow_drop = port_stats->rx_input_fifo_overflow_drop; - drvs->rx_address_match_errors = port_stats->rx_address_match_errors; + drvs->rx_address_mismatch_drops = port_stats->rx_address_mismatch_drops; drvs->rx_alignment_symbol_errors = port_stats->rx_alignment_symbol_errors; drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop; @@ -345,9 +345,7 @@ static void populate_be3_stats(struct be_adapter *adapter) drvs->tx_controlframes = port_stats->tx_controlframes; drvs->jabber_events = port_stats->jabber_events; drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; - drvs->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; - drvs->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; drvs->forwarded_packets = rxf_stats->forwarded_packets; drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; @@ -380,13 +378,14 @@ static void populate_lancer_stats(struct be_adapter *adapter) drvs->rx_dropped_header_too_small = pport_stats->rx_dropped_header_too_small; drvs->rx_input_fifo_overflow_drop = pport_stats->rx_fifo_overflow; - drvs->rx_address_match_errors = pport_stats->rx_address_match_errors; + drvs->rx_address_mismatch_drops = + pport_stats->rx_address_mismatch_drops + + pport_stats->rx_vlan_mismatch_drops; drvs->rx_alignment_symbol_errors = pport_stats->rx_symbol_errors_lo; drvs->rxpp_fifo_overflow_drop = pport_stats->rx_fifo_overflow; drvs->tx_pauseframes = pport_stats->tx_pause_frames_lo; drvs->tx_controlframes = pport_stats->tx_control_frames_lo; drvs->jabber_events = pport_stats->rx_jabbers; - drvs->rx_drops_invalid_ring = pport_stats->rx_drops_invalid_queue; drvs->forwarded_packets = pport_stats->num_forwards_lo; drvs->rx_drops_mtu = pport_stats->rx_drops_mtu_lo; drvs->rx_drops_too_many_frags = -- GitLab From dc7cdf6c6bfc837501ea403a73eec78a350b1f7f Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Mon, 30 Jan 2012 12:00:18 +0000 Subject: [PATCH 0293/1846] hamradio: fix incompatible pointer in module parameter Fixed 'warning: return from incompatible pointer type' related to module parameters. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/hamradio/baycom_epp.c | 2 +- drivers/net/hamradio/baycom_par.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 9537aaa50c2f..49b8b58fc5c6 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c @@ -1162,7 +1162,7 @@ static void baycom_probe(struct net_device *dev) /* * command line settable parameters */ -static const char *mode[NR_PORTS] = { "", }; +static char *mode[NR_PORTS] = { "", }; static int iobase[NR_PORTS] = { 0x378, }; module_param_array(mode, charp, NULL, 0); diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c index 279d2296290a..f1aea0c98333 100644 --- a/drivers/net/hamradio/baycom_par.c +++ b/drivers/net/hamradio/baycom_par.c @@ -477,7 +477,7 @@ static int baycom_ioctl(struct net_device *dev, struct ifreq *ifr, /* * command line settable parameters */ -static const char *mode[NR_PORTS] = { "picpar", }; +static char *mode[NR_PORTS] = { "picpar", }; static int iobase[NR_PORTS] = { 0x378, }; module_param_array(mode, charp, NULL, 0); -- GitLab From 12806a241b1756518bf63c4a464fff73c1a363f2 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 1 Feb 2012 03:05:13 +0000 Subject: [PATCH 0294/1846] atm: Fix typo in lanai.c Correct spelling "reseting" to resetting" in drivers/atm/lanai.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/atm/lanai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c index f5569699f31c..68c758871812 100644 --- a/drivers/atm/lanai.c +++ b/drivers/atm/lanai.c @@ -1572,7 +1572,7 @@ static inline void host_vcc_unbind(struct lanai_dev *lanai, static void lanai_reset(struct lanai_dev *lanai) { - printk(KERN_CRIT DEV_LABEL "(itf %d): *NOT* reseting - not " + printk(KERN_CRIT DEV_LABEL "(itf %d): *NOT* resetting - not " "implemented\n", lanai->number); /* TODO */ /* The following is just a hack until we write the real -- GitLab From c3ca881f0a6e6421f167d3938f4b1e1d008cb505 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 1 Feb 2012 03:13:59 +0000 Subject: [PATCH 0295/1846] vmxnet3: Fix typo in vmxnet3_drv.c Correct spelling in "uncommited" to "uncommitted" in drivers/net/vmxnet3/vmxnet3_drv.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/net/vmxnet3/vmxnet3_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index 482cfa891f89..e1562e8acba5 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -633,7 +633,7 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx, dev_dbg(&adapter->netdev->dev, "alloc_rx_buf: %d allocated, next2fill %u, next2comp " - "%u, uncommited %u\n", num_allocated, ring->next2fill, + "%u, uncommitted %u\n", num_allocated, ring->next2fill, ring->next2comp, rq->uncommitted[ring_idx]); /* so that the device can distinguish a full ring and an empty ring */ -- GitLab From 7b6cd1ce72176e21be15a0ac153bdaa5be1b208a Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 1 Feb 2012 10:54:43 +0000 Subject: [PATCH 0296/1846] PATCH V2 net-next] net: dev: Convert printks to pr_ Use the current logging style. Coalesce formats where appropriate. Update grammar where appropriate. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- net/core/dev.c | 94 +++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 55 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 115dee1d985d..f1249472e90e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -446,7 +446,7 @@ void __dev_remove_pack(struct packet_type *pt) } } - printk(KERN_WARNING "dev_remove_pack: %p not found.\n", pt); + pr_warn("dev_remove_pack: %p not found\n", pt); out: spin_unlock(&ptype_lock); } @@ -1039,8 +1039,7 @@ int dev_change_name(struct net_device *dev, const char *newname) memcpy(dev->name, oldname, IFNAMSIZ); goto rollback; } else { - printk(KERN_ERR - "%s: name change rollback failed: %d.\n", + pr_err("%s: name change rollback failed: %d\n", dev->name, ret); } } @@ -1139,9 +1138,8 @@ void dev_load(struct net *net, const char *name) no_module = request_module("netdev-%s", name); if (no_module && capable(CAP_SYS_MODULE)) { if (!request_module("%s", name)) - pr_err("Loading kernel module for a network device " -"with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s " -"instead\n", name); + pr_err("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n", + name); } } EXPORT_SYMBOL(dev_load); @@ -1655,10 +1653,9 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) if (skb_network_header(skb2) < skb2->data || skb2->network_header > skb2->tail) { if (net_ratelimit()) - printk(KERN_CRIT "protocol %04x is " - "buggy, dev %s\n", - ntohs(skb2->protocol), - dev->name); + pr_crit("protocol %04x is buggy, dev %s\n", + ntohs(skb2->protocol), + dev->name); skb_reset_network_header(skb2); } @@ -1691,9 +1688,7 @@ static void netif_setup_tc(struct net_device *dev, unsigned int txq) /* If TC0 is invalidated disable TC mapping */ if (tc->offset + tc->count > txq) { - pr_warning("Number of in use tx queues changed " - "invalidating tc mappings. Priority " - "traffic classification disabled!\n"); + pr_warn("Number of in use tx queues changed invalidating tc mappings. Priority traffic classification disabled!\n"); dev->num_tc = 0; return; } @@ -1704,11 +1699,8 @@ static void netif_setup_tc(struct net_device *dev, unsigned int txq) tc = &dev->tc_to_txq[q]; if (tc->offset + tc->count > txq) { - pr_warning("Number of in use tx queues " - "changed. Priority %i to tc " - "mapping %i is no longer valid " - "setting map to 0\n", - i, q); + pr_warn("Number of in use tx queues changed. Priority %i to tc mapping %i is no longer valid. Setting map to 0\n", + i, q); netdev_set_prio_tc_map(dev, i, 0); } } @@ -2014,8 +2006,7 @@ EXPORT_SYMBOL(skb_gso_segment); void netdev_rx_csum_fault(struct net_device *dev) { if (net_ratelimit()) { - printk(KERN_ERR "%s: hw csum failure.\n", - dev ? dev->name : ""); + pr_err("%s: hw csum failure\n", dev ? dev->name : ""); dump_stack(); } } @@ -2332,9 +2323,9 @@ static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index) { if (unlikely(queue_index >= dev->real_num_tx_queues)) { if (net_ratelimit()) { - pr_warning("%s selects TX queue %d, but " - "real number of TX queues is %d\n", - dev->name, queue_index, dev->real_num_tx_queues); + pr_warn("%s selects TX queue %d, but real number of TX queues is %d\n", + dev->name, queue_index, + dev->real_num_tx_queues); } return 0; } @@ -2578,16 +2569,16 @@ int dev_queue_xmit(struct sk_buff *skb) } HARD_TX_UNLOCK(dev, txq); if (net_ratelimit()) - printk(KERN_CRIT "Virtual device %s asks to " - "queue packet!\n", dev->name); + pr_crit("Virtual device %s asks to queue packet!\n", + dev->name); } else { /* Recursion is detected! It is possible, * unfortunately */ recursion_alert: if (net_ratelimit()) - printk(KERN_CRIT "Dead loop on virtual device " - "%s, fix it urgently!\n", dev->name); + pr_crit("Dead loop on virtual device %s, fix it urgently!\n", + dev->name); } } @@ -3069,8 +3060,8 @@ static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) if (unlikely(MAX_RED_LOOP < ttl++)) { if (net_ratelimit()) - pr_warning( "Redir loop detected Dropping packet (%d->%d)\n", - skb->skb_iif, dev->ifindex); + pr_warn("Redir loop detected Dropping packet (%d->%d)\n", + skb->skb_iif, dev->ifindex); return TC_ACT_SHOT; } @@ -4491,16 +4482,15 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc) dev->flags &= ~IFF_PROMISC; else { dev->promiscuity -= inc; - printk(KERN_WARNING "%s: promiscuity touches roof, " - "set promiscuity failed, promiscuity feature " - "of device might be broken.\n", dev->name); + pr_warn("%s: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.\n", + dev->name); return -EOVERFLOW; } } if (dev->flags != old_flags) { - printk(KERN_INFO "device %s %s promiscuous mode\n", - dev->name, (dev->flags & IFF_PROMISC) ? "entered" : - "left"); + pr_info("device %s %s promiscuous mode\n", + dev->name, + dev->flags & IFF_PROMISC ? "entered" : "left"); if (audit_enabled) { current_uid_gid(&uid, &gid); audit_log(current->audit_context, GFP_ATOMIC, @@ -4573,9 +4563,8 @@ int dev_set_allmulti(struct net_device *dev, int inc) dev->flags &= ~IFF_ALLMULTI; else { dev->allmulti -= inc; - printk(KERN_WARNING "%s: allmulti touches roof, " - "set allmulti failed, allmulti feature of " - "device might be broken.\n", dev->name); + pr_warn("%s: allmulti touches roof, set allmulti failed. allmulti feature of device might be broken.\n", + dev->name); return -EOVERFLOW; } } @@ -5232,8 +5221,8 @@ static void rollback_registered_many(struct list_head *head) * devices and proceed with the remaining. */ if (dev->reg_state == NETREG_UNINITIALIZED) { - pr_debug("unregister_netdevice: device %s/%p never " - "was registered\n", dev->name, dev); + pr_debug("unregister_netdevice: device %s/%p never was registered\n", + dev->name, dev); WARN_ON(1); list_del(&dev->unreg_list); @@ -5465,7 +5454,7 @@ static int netif_alloc_rx_queues(struct net_device *dev) rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL); if (!rx) { - pr_err("netdev: Unable to allocate %u rx queues.\n", count); + pr_err("netdev: Unable to allocate %u rx queues\n", count); return -ENOMEM; } dev->_rx = rx; @@ -5499,8 +5488,7 @@ static int netif_alloc_netdev_queues(struct net_device *dev) tx = kcalloc(count, sizeof(struct netdev_queue), GFP_KERNEL); if (!tx) { - pr_err("netdev: Unable to allocate %u tx queues.\n", - count); + pr_err("netdev: Unable to allocate %u tx queues\n", count); return -ENOMEM; } dev->_tx = tx; @@ -5759,10 +5747,8 @@ static void netdev_wait_allrefs(struct net_device *dev) refcnt = netdev_refcnt_read(dev); if (time_after(jiffies, warning_time + 10 * HZ)) { - printk(KERN_EMERG "unregister_netdevice: " - "waiting for %s to become free. Usage " - "count = %d\n", - dev->name, refcnt); + pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n", + dev->name, refcnt); warning_time = jiffies; } } @@ -5813,7 +5799,7 @@ void netdev_run_todo(void) list_del(&dev->todo_list); if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) { - printk(KERN_ERR "network todo '%s' but state %d\n", + pr_err("network todo '%s' but state %d\n", dev->name, dev->reg_state); dump_stack(); continue; @@ -5929,15 +5915,13 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, BUG_ON(strlen(name) >= sizeof(dev->name)); if (txqs < 1) { - pr_err("alloc_netdev: Unable to allocate device " - "with zero queues.\n"); + pr_err("alloc_netdev: Unable to allocate device with zero queues\n"); return NULL; } #ifdef CONFIG_RPS if (rxqs < 1) { - pr_err("alloc_netdev: Unable to allocate device " - "with zero RX queues.\n"); + pr_err("alloc_netdev: Unable to allocate device with zero RX queues\n"); return NULL; } #endif @@ -5953,7 +5937,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, p = kzalloc(alloc_size, GFP_KERNEL); if (!p) { - printk(KERN_ERR "alloc_netdev: Unable to allocate device.\n"); + pr_err("alloc_netdev: Unable to allocate device\n"); return NULL; } @@ -6486,8 +6470,8 @@ static void __net_exit default_device_exit(struct net *net) snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); err = dev_change_net_namespace(dev, &init_net, fb_name); if (err) { - printk(KERN_EMERG "%s: failed to move %s to init_net: %d\n", - __func__, dev->name, err); + pr_emerg("%s: failed to move %s to init_net: %d\n", + __func__, dev->name, err); BUG(); } } -- GitLab From f79d52c254e4e2cef3da64dc02ade3bc8f10c539 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 1 Feb 2012 16:14:17 -0500 Subject: [PATCH 0297/1846] ipv6: Remove never used function inet6_ac_check(). It went from unused, to commented out, and never changing after that. Just get rid of it, if someone wants it they can unearth it from the history. Signed-off-by: David S. Miller --- include/net/addrconf.h | 1 - net/ipv6/anycast.c | 29 ----------------------------- 2 files changed, 30 deletions(-) diff --git a/include/net/addrconf.h b/include/net/addrconf.h index f68dce2d8d88..757a17638b1b 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -160,7 +160,6 @@ extern void addrconf_prefix_rcv(struct net_device *dev, extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr); extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr); extern void ipv6_sock_ac_close(struct sock *sk); -extern int inet6_ac_check(struct sock *sk, const struct in6_addr *addr, int ifindex); extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c index 59402b4637f9..db00d27ffb16 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c @@ -211,35 +211,6 @@ void ipv6_sock_ac_close(struct sock *sk) rcu_read_unlock(); } -#if 0 -/* The function is not used, which is funny. Apparently, author - * supposed to use it to filter out datagrams inside udp/raw but forgot. - * - * It is OK, anycasts are not special comparing to delivery to unicasts. - */ - -int inet6_ac_check(struct sock *sk, struct in6_addr *addr, int ifindex) -{ - struct ipv6_ac_socklist *pac; - struct ipv6_pinfo *np = inet6_sk(sk); - int found; - - found = 0; - read_lock(&ipv6_sk_ac_lock); - for (pac=np->ipv6_ac_list; pac; pac=pac->acl_next) { - if (ifindex && pac->acl_ifindex != ifindex) - continue; - found = ipv6_addr_equal(&pac->acl_addr, addr); - if (found) - break; - } - read_unlock(&ipv6_sk_ac_lock); - - return found; -} - -#endif - static void aca_put(struct ifacaddr6 *ac) { if (atomic_dec_and_test(&ac->aca_refcnt)) { -- GitLab From 3329bdfc4071840816d6666c6463fdb0bd4c8264 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 1 Feb 2012 16:34:25 -0500 Subject: [PATCH 0298/1846] decnet: Add missing neigh->ha locking to dn_neigh_output_packet() Basically, mirror the logic in neigh_connected_output(). Signed-off-by: David S. Miller --- net/decnet/dn_neigh.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index befe426491ba..ee7013f24fca 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c @@ -205,17 +205,23 @@ static int dn_neigh_output_packet(struct sk_buff *skb) struct neighbour *neigh = dst_get_neighbour_noref(dst); struct net_device *dev = neigh->dev; char mac_addr[ETH_ALEN]; + unsigned int seq; + int err; dn_dn2eth(mac_addr, rt->rt_local_src); - if (dev_hard_header(skb, dev, ntohs(skb->protocol), neigh->ha, - mac_addr, skb->len) >= 0) - return dev_queue_xmit(skb); - - if (net_ratelimit()) - printk(KERN_DEBUG "dn_neigh_output_packet: oops, can't send packet\n"); - - kfree_skb(skb); - return -EINVAL; + do { + seq = read_seqbegin(&neigh->ha_lock); + err = dev_hard_header(skb, dev, ntohs(skb->protocol), + neigh->ha, mac_addr, skb->len); + } while (read_seqretry(&neigh->ha_lock, seq)); + + if (err >= 0) + err = dev_queue_xmit(skb); + else { + kfree_skb(skb); + err = -EINVAL; + } + return err; } static int dn_long_output(struct neighbour *neigh, struct sk_buff *skb) -- GitLab From 7161c76f0def54f5dc7fd9a5534bb3e3e2b2aa60 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 1 Feb 2012 17:23:11 -0500 Subject: [PATCH 0299/1846] atm: clip: Convert over to dst_neigh_lookup(). CLIP only support ipv4, and this is evidenced by the fact that it is a device specific extension of arp_tbl, so this conversion is pretty straightforward. Signed-off-by: David S. Miller --- net/atm/clip.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/net/atm/clip.c b/net/atm/clip.c index c12c2582457c..ef95a30306fa 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c @@ -328,6 +328,8 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, struct atmarp_entry *entry; struct neighbour *n; struct atm_vcc *vcc; + struct rtable *rt; + __be32 *daddr; int old; unsigned long flags; @@ -338,7 +340,12 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, dev->stats.tx_dropped++; return NETDEV_TX_OK; } - n = dst_get_neighbour_noref(dst); + rt = (struct rtable *) dst; + if (rt->rt_gateway) + daddr = &rt->rt_gateway; + else + daddr = &ip_hdr(skb)->daddr; + n = dst_neigh_lookup(dst, daddr); if (!n) { pr_err("NO NEIGHBOUR !\n"); dev_kfree_skb(skb); @@ -358,7 +365,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, dev_kfree_skb(skb); dev->stats.tx_dropped++; } - return NETDEV_TX_OK; + goto out_release_neigh; } pr_debug("neigh %p, vccs %p\n", entry, entry->vccs); ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc; @@ -377,14 +384,14 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ if (old) { pr_warning("XOFF->XOFF transition\n"); - return NETDEV_TX_OK; + goto out_release_neigh; } dev->stats.tx_packets++; dev->stats.tx_bytes += skb->len; vcc->send(vcc, skb); if (atm_may_send(vcc, 0)) { entry->vccs->xoff = 0; - return NETDEV_TX_OK; + goto out_release_neigh; } spin_lock_irqsave(&clip_priv->xoff_lock, flags); netif_stop_queue(dev); /* XOFF -> throttle immediately */ @@ -396,6 +403,8 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, of the brief netif_stop_queue. If this isn't true or if it changes, use netif_wake_queue instead. */ spin_unlock_irqrestore(&clip_priv->xoff_lock, flags); +out_release_neigh: + neigh_release(n); return NETDEV_TX_OK; } -- GitLab From 57b9bef0d6990d088a5e840c88ae137d8e76202c Mon Sep 17 00:00:00 2001 From: Krishna Gudipati Date: Wed, 1 Feb 2012 15:02:41 +0000 Subject: [PATCH 0300/1846] bna: Implement ethtool flash_device entry point. Incorporated review comments from Ben Hutchings. Change details: - Implement ethtool flash_device() entry point to write the firmware image to the flash firmware partition. Signed-off-by: Krishna Gudipati Reviewed-by: Ben Hutchings Signed-off-by: David S. Miller --- drivers/net/ethernet/brocade/bna/bfa_defs.h | 1 + .../net/ethernet/brocade/bna/bnad_ethtool.c | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h b/drivers/net/ethernet/brocade/bna/bfa_defs.h index 871c6309334c..48f877337390 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_defs.h +++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h @@ -297,6 +297,7 @@ enum bfa_mode { #define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */ #define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */ #define BFA_TOTAL_FLASH_SIZE 0x400000 +#define BFA_FLASH_PART_FWIMG 2 #define BFA_FLASH_PART_MFG 7 /* diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c index 9b44ec8096ba..a27c601af3d1 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c +++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c @@ -1072,6 +1072,47 @@ bnad_set_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, return ret; } +static int +bnad_flash_device(struct net_device *netdev, struct ethtool_flash *eflash) +{ + struct bnad *bnad = netdev_priv(netdev); + struct bnad_iocmd_comp fcomp; + const struct firmware *fw; + int ret = 0; + + ret = request_firmware(&fw, eflash->data, &bnad->pcidev->dev); + if (ret) { + pr_err("BNA: Can't locate firmware %s\n", eflash->data); + goto out; + } + + fcomp.bnad = bnad; + fcomp.comp_status = 0; + + init_completion(&fcomp.comp); + spin_lock_irq(&bnad->bna_lock); + ret = bfa_nw_flash_update_part(&bnad->bna.flash, BFA_FLASH_PART_FWIMG, + bnad->id, (u8 *)fw->data, fw->size, 0, + bnad_cb_completion, &fcomp); + if (ret != BFA_STATUS_OK) { + pr_warn("BNA: Flash update failed with err: %d\n", ret); + ret = -EIO; + spin_unlock_irq(&bnad->bna_lock); + goto out; + } + + spin_unlock_irq(&bnad->bna_lock); + wait_for_completion(&fcomp.comp); + if (fcomp.comp_status != BFA_STATUS_OK) { + ret = -EIO; + pr_warn("BNA: Firmware image update to flash failed with: %d\n", + fcomp.comp_status); + } +out: + release_firmware(fw); + return ret; +} + static const struct ethtool_ops bnad_ethtool_ops = { .get_settings = bnad_get_settings, .set_settings = bnad_set_settings, @@ -1090,6 +1131,7 @@ static const struct ethtool_ops bnad_ethtool_ops = { .get_eeprom_len = bnad_get_eeprom_len, .get_eeprom = bnad_get_eeprom, .set_eeprom = bnad_set_eeprom, + .flash_device = bnad_flash_device, }; void -- GitLab From 3c325fbd0cdb4f83b7761cd8ba7519d7a236de38 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 31 Jan 2012 23:32:55 +0900 Subject: [PATCH 0301/1846] ath6kl: Fix typo in cfg80211.c Correct spelling "spported" to "supported" in drivers/net/wireless/ath/ath6kl/cfg80211.c Signed-off-by: Masanari Iida Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 5934e40ee55d..d1922d8eb3bb 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -194,7 +194,7 @@ static int ath6kl_set_auth_type(struct ath6kl_vif *vif, break; default: - ath6kl_err("%s: 0x%x not spported\n", __func__, auth_type); + ath6kl_err("%s: 0x%x not supported\n", __func__, auth_type); return -ENOTSUPP; } -- GitLab From 1b46dc04866a4962644ef32d7398e34b40f7ac21 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 31 Jan 2012 21:26:22 +0200 Subject: [PATCH 0302/1846] ath6kl: fix compiler warning in ath6kl_init_hw_params() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both Luis and John reported that they see a compiler warning: drivers/net/wireless/ath/ath6kl/init.c: In function 'ath6kl_init_hw_params': drivers/net/wireless/ath/ath6kl/init.c:1377:26: warning: ‘hw’ may be used uninitialized in this function Oddly enough I have never seen it. But AFAICT the code is correct and hw is not used uninitalized so add uninitialized_var() to inform that to the compiler. Reported-by: Luis R. Rodriguez Reported-by: John W. Linville Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index bf56e5f17618..0d76c3778106 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1470,7 +1470,7 @@ static int ath6kl_init_upload(struct ath6kl *ar) int ath6kl_init_hw_params(struct ath6kl *ar) { - const struct ath6kl_hw *hw; + const struct ath6kl_hw *uninitialized_var(hw); int i; for (i = 0; i < ARRAY_SIZE(hw_list); i++) { -- GitLab From 5fbea5dcc05415474bae7108803e324f112d5b58 Mon Sep 17 00:00:00 2001 From: Chilam Ng Date: Wed, 1 Feb 2012 01:03:37 -0800 Subject: [PATCH 0303/1846] ath6kl: initialize the 'nominal_phy' field in the 'wmi_create_pstream_cmd' struct for create_qos command The nominal_phy field is uninitialized. Initialize it to min_phy_rate for create_qos. kvalo: simplified the equation as checkpatch complained for a too long line Signed-off-by: Chilam Ng Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 6b546dc66728..d832058816fe 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1441,6 +1441,8 @@ static ssize_t ath6kl_create_qos_write(struct file *file, return -EINVAL; pstream.medium_time = cpu_to_le32(val32); + pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000; + ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream); return count; -- GitLab From ed6a3803408f18da387463d569b4edc5078fd9aa Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 2 Jan 2012 16:10:08 +0200 Subject: [PATCH 0304/1846] iwlwifi: add fw_alive to transport layer API, kill tx_start Define a new handler in the transport layer API: fw_alive. Move iwl_reset_ict to this new handler, and move the content of tx_start to this handler. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 3 --- drivers/net/wireless/iwlwifi/iwl-agn.h | 2 -- drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 6 ++---- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 10 ++++++++-- drivers/net/wireless/iwlwifi/iwl-trans.h | 15 +++++++-------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 2 +- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 90315c69cdf6..9d9185ffc39c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1243,9 +1243,6 @@ int iwl_alive_start(struct iwl_priv *priv) int ret = 0; struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - /*TODO: this should go to the transport layer */ - iwl_reset_ict(trans(priv)); - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); /* After the ALIVE response, we can send host commands to the uCode */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 39cbe1a1577c..0f5133ac3575 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -73,8 +73,6 @@ struct iwlagn_ucode_capabilities { extern struct ieee80211_ops iwlagn_hw_ops; -int iwl_reset_ict(struct iwl_trans *trans); - static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) { hdr->op_code = cmd; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 0ac9b4d30271..0f73778b73f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -258,7 +258,7 @@ void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans, /***************************************************** * ICT ******************************************************/ -int iwl_reset_ict(struct iwl_trans *trans); +void iwl_reset_ict(struct iwl_trans *trans); void iwl_disable_ict(struct iwl_trans *trans); int iwl_alloc_isr_ict(struct iwl_trans *trans); void iwl_free_isr_ict(struct iwl_trans *trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 848c598bfadb..2822b7e8bcae 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1213,7 +1213,7 @@ int iwl_alloc_isr_ict(struct iwl_trans *trans) /* Device is going up inform it about using ICT interrupt table, * also we need to tell the driver to start using ICT interrupt. */ -int iwl_reset_ict(struct iwl_trans *trans) +void iwl_reset_ict(struct iwl_trans *trans) { u32 val; unsigned long flags; @@ -1221,7 +1221,7 @@ int iwl_reset_ict(struct iwl_trans *trans) IWL_TRANS_GET_PCIE_TRANS(trans); if (!trans_pcie->ict_tbl) - return 0; + return; spin_lock_irqsave(&trans->shrd->lock, flags); iwl_disable_interrupts(trans); @@ -1241,8 +1241,6 @@ int iwl_reset_ict(struct iwl_trans *trans) iwl_write32(bus(trans), CSR_INT, trans_pcie->inta_mask); iwl_enable_interrupts(trans); spin_unlock_irqrestore(&trans->shrd->lock, flags); - - return 0; } /* Device is going down disable ict interrupt usage */ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 5e6af4ba9652..affa56fafdb8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -835,7 +835,7 @@ static void iwl_trans_txq_set_sched(struct iwl_trans *trans, u32 mask) iwl_write_prph(bus(trans), SCD_TXFACT, mask); } -static void iwl_trans_pcie_tx_start(struct iwl_trans *trans) +static void iwl_tx_start(struct iwl_trans *trans) { const struct queue_to_fifo_ac *queue_to_fifo; struct iwl_trans_pcie *trans_pcie = @@ -948,6 +948,12 @@ static void iwl_trans_pcie_tx_start(struct iwl_trans *trans) APMG_PCIDEV_STT_VAL_L1_ACT_DIS); } +static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans) +{ + iwl_reset_ict(trans); + iwl_tx_start(trans); +} + /** * iwlagn_txq_ctx_stop - Stop all Tx DMA channels */ @@ -1903,11 +1909,11 @@ static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans, const struct iwl_trans_ops trans_ops_pcie = { .alloc = iwl_trans_pcie_alloc, .request_irq = iwl_trans_pcie_request_irq, + .fw_alive = iwl_trans_pcie_fw_alive, .start_device = iwl_trans_pcie_start_device, .prepare_card_hw = iwl_trans_pcie_prepare_card_hw, .stop_device = iwl_trans_pcie_stop_device, - .tx_start = iwl_trans_pcie_tx_start, .wake_any_queue = iwl_trans_pcie_wake_any_queue, .send_cmd = iwl_trans_pcie_send_cmd, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 42a9f303f543..9795a23ee949 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -139,8 +139,7 @@ struct iwl_host_cmd { * layer. * @prepare_card_hw: claim the ownership on the HW. Will be called during * probe. - * @tx_start: starts and configures all the Tx fifo - usually done once the fw - * is alive. + * @fw_alive: called when the fw sends alive notification * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_* * @stop_device:stops the whole device (embedded CPU put to reset) * @send_cmd:send a host command @@ -166,9 +165,9 @@ struct iwl_trans_ops { struct iwl_trans *(*alloc)(struct iwl_shared *shrd); int (*request_irq)(struct iwl_trans *iwl_trans); int (*start_device)(struct iwl_trans *trans); + void (*fw_alive)(struct iwl_trans *trans); int (*prepare_card_hw)(struct iwl_trans *trans); void (*stop_device)(struct iwl_trans *trans); - void (*tx_start)(struct iwl_trans *trans); void (*wake_any_queue)(struct iwl_trans *trans, enum iwl_rxon_context_id ctx, @@ -264,6 +263,11 @@ static inline int iwl_trans_request_irq(struct iwl_trans *trans) return trans->ops->request_irq(trans); } +static inline void iwl_trans_fw_alive(struct iwl_trans *trans) +{ + trans->ops->fw_alive(trans); +} + static inline int iwl_trans_start_device(struct iwl_trans *trans) { return trans->ops->start_device(trans); @@ -279,11 +283,6 @@ static inline void iwl_trans_stop_device(struct iwl_trans *trans) trans->ops->stop_device(trans); } -static inline void iwl_trans_tx_start(struct iwl_trans *trans) -{ - trans->ops->tx_start(trans); -} - static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, enum iwl_rxon_context_id ctx, const char *msg) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 2edf0ef65a5b..0d7f207ac611 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -447,7 +447,7 @@ static int iwl_alive_notify(struct iwl_trans *trans) if (!priv->tx_cmd_pool) return -ENOMEM; - iwl_trans_tx_start(trans); + iwl_trans_fw_alive(trans); for_each_context(priv, ctx) ctx->last_tx_rejected = false; -- GitLab From a591697730a3c416cd384bc199eb5dde622c4c78 Mon Sep 17 00:00:00 2001 From: Gregory Greenman Date: Tue, 10 Jan 2012 19:22:56 +0200 Subject: [PATCH 0305/1846] iwlwifi: Connect IDI transport to driver. This patch connects IDI transport to driver. It does so by using a number of ifdefs at this stage. IDI is a new transport that is under development. Signed-off-by: Gregory Greenman Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-pci.c | 4 ++++ drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 13 ++++++++++++- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 7 ++++++- drivers/net/wireless/iwlwifi/iwl-trans.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 03702a2e913a..2c46063522c9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -454,7 +454,11 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) bus->irq = pdev->irq; bus->ops = &bus_ops_pci; +#ifdef CONFIG_IWLWIFI_IDI + err = iwl_probe(bus, &trans_ops_idi, cfg); +#else err = iwl_probe(bus, &trans_ops_pcie, cfg); +#endif if (err) goto out_disable_msi; return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 2822b7e8bcae..b94c95370b7b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -35,6 +35,10 @@ #include "iwl-io.h" #include "iwl-trans-pcie-int.h" +#ifdef CONFIG_IWLWIFI_IDI +#include "iwl-amfh.h" +#endif + /****************************************************************************** * * RX path functions @@ -1100,8 +1104,11 @@ void iwl_irq_tasklet(struct iwl_trans *trans) /* Disable periodic interrupt; we use it as just a one-shot. */ iwl_write8(bus(trans), CSR_INT_PERIODIC_REG, CSR_INT_PERIODIC_DIS); +#ifdef CONFIG_IWLWIFI_IDI + iwl_amfh_rx_handler(); +#else iwl_rx_handle(trans); - +#endif /* * Enable periodic interrupt in 8 msec only if we received * real RX interrupt (instead of just periodic int), to catch @@ -1123,7 +1130,11 @@ void iwl_irq_tasklet(struct iwl_trans *trans) isr_stats->tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ +#ifdef CONFIG_IWLWIFI_IDI + trans->shrd->trans->ucode_write_complete = 1; +#else trans->ucode_write_complete = 1; +#endif wake_up(&trans->shrd->wait_command_queue); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index affa56fafdb8..0b4280c92584 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -647,8 +647,10 @@ static int iwl_nic_init(struct iwl_trans *trans) iwl_nic_config(priv(trans)); +#ifndef CONFIG_IWLWIFI_IDI /* Allocate the RX queue, or reset if it is already allocated */ iwl_rx_init(trans); +#endif /* Allocate or reset and init all Tx and Command queues */ if (iwl_tx_init(trans)) @@ -1016,8 +1018,9 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) */ if (test_bit(STATUS_DEVICE_ENABLED, &trans->shrd->status)) { iwl_trans_tx_stop(trans); +#ifndef CONFIG_IWLWIFI_IDI iwl_trans_rx_stop(trans); - +#endif /* Power-down device's busmaster DMA clocks */ iwl_write_prph(bus(trans), APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); @@ -1298,7 +1301,9 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans) { iwl_calib_free_results(trans); iwl_trans_pcie_tx_free(trans); +#ifndef CONFIG_IWLWIFI_IDI iwl_trans_pcie_rx_free(trans); +#endif free_irq(bus(trans)->irq, trans); iwl_free_isr_ict(trans); trans->shrd->trans = NULL; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 9795a23ee949..2a6649c9ca42 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -383,6 +383,7 @@ static inline int iwl_trans_resume(struct iwl_trans *trans) * Transport layers implementations ******************************************************/ extern const struct iwl_trans_ops trans_ops_pcie; +extern const struct iwl_trans_ops trans_ops_idi; int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, const void *data, size_t len); -- GitLab From 8747bb4936c137bb93b91afd70eedd65069d26cd Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 4 Jan 2012 16:57:09 +0200 Subject: [PATCH 0306/1846] iwlwifi: separate the APM from the EEPROM There is no link between the two. Ensure that the NIC is on outside the code of the EEPROM handling. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++++ drivers/net/wireless/iwlwifi/iwl-eeprom.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 9d9185ffc39c..f3bd6a3eec38 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1848,8 +1848,12 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /***************** * 4. Read EEPROM *****************/ + /* switch the NIC on before accessing the EEPROM */ + iwl_apm_init(priv); /* Read the EEPROM */ err = iwl_eeprom_init(priv, hw_rev); + /* Reset chip to save power until we load uCode during "up". */ + iwl_apm_stop(priv); if (err) { IWL_ERR(priv, "Unable to init EEPROM\n"); goto out_free_trans; diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index e27d9f55267b..ce214e0ab496 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -676,8 +676,6 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) } e = (__le16 *)shrd->eeprom; - iwl_apm_init(priv); - ret = iwl_eeprom_verify_signature(trans(priv)); if (ret < 0) { IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); @@ -758,8 +756,6 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) err: if (ret) iwl_eeprom_free(priv->shrd); - /* Reset chip to save power until we load uCode during "up". */ - iwl_apm_stop(priv); alloc_err: return ret; } -- GitLab From 87e7597b5a3f99238d95d63c44c9f872a41b37ae Mon Sep 17 00:00:00 2001 From: David Miller Date: Wed, 1 Feb 2012 10:49:17 +0000 Subject: [PATCH 0307/1846] qeth: Move away from using neighbour entries in qeth_l3_fill_header() We've moving to a model where dst_entry objects to not have a reference to the associated neighbour entry, instead such neighbours must be looked up on-demand. Here in qeth_l3_fill_header() it's actually much simpler to use the information in the route itself. The code is already conditionalized upon protocol type. Signed-off-by: David S. Miller Tested-by: Ursula Braun --- drivers/s390/net/qeth_l3_main.c | 35 +++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 9648e4e68337..25cd3799a76c 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include @@ -2832,7 +2834,6 @@ static void qeth_l3_fill_af_iucv_hdr(struct qeth_card *card, static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, struct sk_buff *skb, int ipv, int cast_type) { - struct neighbour *n = NULL; struct dst_entry *dst; memset(hdr, 0, sizeof(struct qeth_hdr)); @@ -2855,33 +2856,29 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, rcu_read_lock(); dst = skb_dst(skb); - if (dst) - n = dst_get_neighbour_noref(dst); if (ipv == 4) { + struct rtable *rt = (struct rtable *) dst; + __be32 *pkey = &ip_hdr(skb)->daddr; + + if (rt->rt_gateway) + pkey = &rt->rt_gateway; + /* IPv4 */ hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type); memset(hdr->hdr.l3.dest_addr, 0, 12); - if (n) { - *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = - *((u32 *) n->primary_key); - } else { - /* fill in destination address used in ip header */ - *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = - ip_hdr(skb)->daddr; - } + *((__be32 *) (&hdr->hdr.l3.dest_addr[12])) = *pkey; } else if (ipv == 6) { + struct rt6_info *rt = (struct rt6_info *) dst; + struct in6_addr *pkey = &ipv6_hdr(skb)->daddr; + + if (!ipv6_addr_any(&rt->rt6i_gateway)) + pkey = &rt->rt6i_gateway; + /* IPv6 */ hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type); if (card->info.type == QETH_CARD_TYPE_IQD) hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU; - if (n) { - memcpy(hdr->hdr.l3.dest_addr, - n->primary_key, 16); - } else { - /* fill in destination address used in ip header */ - memcpy(hdr->hdr.l3.dest_addr, - &ipv6_hdr(skb)->daddr, 16); - } + memcpy(hdr->hdr.l3.dest_addr, pkey, 16); } else { /* passthrough */ if ((skb->dev->type == ARPHRD_IEEE802_TR) && -- GitLab From e1f4c485cdb2b1d7aae172b731f6c2b403381ebb Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 2 Feb 2012 03:20:28 +0000 Subject: [PATCH 0308/1846] eicon: fix -Warray-bounds warning Fix for a -Warray-bounds warning. mixer_notify_update() tries to write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while structs is defined as byte structs[1]. Set all 'structs' which are part of the typdefs in the info union to 'byte structs[0]'. v2: set all info.*.structs to byte structs[0] Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/isdn/hardware/eicon/capi20.h | 60 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/isdn/hardware/eicon/capi20.h b/drivers/isdn/hardware/eicon/capi20.h index 7ebcccda74d8..27ecd61888de 100644 --- a/drivers/isdn/hardware/eicon/capi20.h +++ b/drivers/isdn/hardware/eicon/capi20.h @@ -117,7 +117,7 @@ typedef struct api_profile_s { /*------------------------------------------------------------------*/ /* ALERT-REQUEST */ typedef struct { - byte structs[1]; /* Additional Info */ + byte structs[0]; /* Additional Info */ } _ALT_REQP; /* ALERT-CONFIRM */ typedef struct { @@ -126,7 +126,7 @@ typedef struct { /* CONNECT-REQUEST */ typedef struct { word CIP_Value; - byte structs[1]; /* Called party number, + byte structs[0]; /* Called party number, Called party subaddress, Calling party number, Calling party subaddress, @@ -143,7 +143,7 @@ typedef struct { /* CONNECT-INDICATION */ typedef struct { word CIP_Value; - byte structs[1]; /* Called party number, + byte structs[0]; /* Called party number, Called party subaddress, Calling party number, Calling party subaddress, @@ -155,24 +155,24 @@ typedef struct { /* CONNECT-RESPONSE */ typedef struct { word Accept; - byte structs[1]; /* B_protocol, + byte structs[0]; /* B_protocol, Connected party number, Connected party subaddress, LLC */ } _CON_RESP; /* CONNECT-ACTIVE-INDICATION */ typedef struct { - byte structs[1]; /* Connected party number, + byte structs[0]; /* Connected party number, Connected party subaddress, LLC */ } _CON_A_INDP; /* CONNECT-ACTIVE-RESPONSE */ typedef struct { - byte structs[1]; /* empty */ + byte structs[0]; /* empty */ } _CON_A_RESP; /* DISCONNECT-REQUEST */ typedef struct { - byte structs[1]; /* Additional Info */ + byte structs[0]; /* Additional Info */ } _DIS_REQP; /* DISCONNECT-CONFIRM */ typedef struct { @@ -184,13 +184,13 @@ typedef struct { } _DIS_INDP; /* DISCONNECT-RESPONSE */ typedef struct { - byte structs[1]; /* empty */ + byte structs[0]; /* empty */ } _DIS_RESP; /* LISTEN-REQUEST */ typedef struct { dword Info_Mask; dword CIP_Mask; - byte structs[1]; /* Calling party number, + byte structs[0]; /* Calling party number, Calling party subaddress */ } _LIS_REQP; /* LISTEN-CONFIRM */ @@ -199,7 +199,7 @@ typedef struct { } _LIS_CONP; /* INFO-REQUEST */ typedef struct { - byte structs[1]; /* Called party number, + byte structs[0]; /* Called party number, Additional Info */ } _INF_REQP; /* INFO-CONFIRM */ @@ -209,15 +209,15 @@ typedef struct { /* INFO-INDICATION */ typedef struct { word Number; - byte structs[1]; /* Info element */ + byte structs[0]; /* Info element */ } _INF_INDP; /* INFO-RESPONSE */ typedef struct { - byte structs[1]; /* empty */ + byte structs[0]; /* empty */ } _INF_RESP; /* SELECT-B-REQUEST */ typedef struct { - byte structs[1]; /* B-protocol */ + byte structs[0]; /* B-protocol */ } _SEL_B_REQP; /* SELECT-B-CONFIRM */ typedef struct { @@ -226,7 +226,7 @@ typedef struct { /* FACILITY-REQUEST */ typedef struct { word Selector; - byte structs[1]; /* Facility parameters */ + byte structs[0]; /* Facility parameters */ } _FAC_REQP; /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */ typedef struct { @@ -240,21 +240,21 @@ typedef struct { typedef struct { word Info; word Selector; - byte structs[1]; /* Facility parameters */ + byte structs[0]; /* Facility parameters */ } _FAC_CONP; /* FACILITY-INDICATION */ typedef struct { word Selector; - byte structs[1]; /* Facility parameters */ + byte structs[0]; /* Facility parameters */ } _FAC_INDP; /* FACILITY-RESPONSE */ typedef struct { word Selector; - byte structs[1]; /* Facility parameters */ + byte structs[0]; /* Facility parameters */ } _FAC_RESP; /* CONNECT-B3-REQUEST */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_REQP; /* CONNECT-B3-CONFIRM */ typedef struct { @@ -262,24 +262,24 @@ typedef struct { } _CON_B3_CONP; /* CONNECT-B3-INDICATION */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_INDP; /* CONNECT-B3-RESPONSE */ typedef struct { word Accept; - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_RESP; /* CONNECT-B3-ACTIVE-INDICATION */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_A_INDP; /* CONNECT-B3-ACTIVE-RESPONSE */ typedef struct { - byte structs[1]; /* empty */ + byte structs[0]; /* empty */ } _CON_B3_A_RESP; /* DISCONNECT-B3-REQUEST */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _DIS_B3_REQP; /* DISCONNECT-B3-CONFIRM */ typedef struct { @@ -288,11 +288,11 @@ typedef struct { /* DISCONNECT-B3-INDICATION */ typedef struct { word Info; - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _DIS_B3_INDP; /* DISCONNECT-B3-RESPONSE */ typedef struct { - byte structs[1]; /* empty */ + byte structs[0]; /* empty */ } _DIS_B3_RESP; /* DATA-B3-REQUEST */ typedef struct { @@ -335,7 +335,7 @@ typedef struct { } _DAT_B3_RESP; /* RESET-B3-REQUEST */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _RES_B3_REQP; /* RESET-B3-CONFIRM */ typedef struct { @@ -343,20 +343,20 @@ typedef struct { } _RES_B3_CONP; /* RESET-B3-INDICATION */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _RES_B3_INDP; /* RESET-B3-RESPONSE */ typedef struct { - byte structs[1]; /* empty */ + byte structs[0]; /* empty */ } _RES_B3_RESP; /* CONNECT-B3-T90-ACTIVE-INDICATION */ typedef struct { - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_T90_A_INDP; /* CONNECT-B3-T90-ACTIVE-RESPONSE */ typedef struct { word Reject; - byte structs[1]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_T90_A_RESP; /*------------------------------------------------------------------*/ /* message structure */ -- GitLab From e81fb554cfe082dc59a707767c426cbd2e361033 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 2 Feb 2012 14:08:57 -0800 Subject: [PATCH 0309/1846] iwlwifi: move the shrd memory from priv Allocating the shrd area dynamically will allow more agility while revamping the flows. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 +--- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - drivers/net/wireless/iwlwifi/iwl-pci.c | 10 ++++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index f3bd6a3eec38..b42be3084507 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1780,9 +1780,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, } priv = hw->priv; - priv->shrd = &priv->_shrd; - bus->shrd = priv->shrd; - priv->shrd->bus = bus; + priv->shrd = bus->shrd; priv->shrd->priv = priv; priv->shrd->trans = trans_ops->alloc(priv->shrd); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index af846002150a..fff5b620927b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -821,7 +821,6 @@ struct iwl_wipan_noa_data { struct iwl_priv { /*data shared among all the driver's layers */ - struct iwl_shared _shrd; struct iwl_shared *shrd; /* ieee device used by generic ieee processing code */ diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 2c46063522c9..a3ca0a78336f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -374,10 +374,18 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (!bus) { dev_printk(KERN_ERR, &pdev->dev, "Couldn't allocate iwl_pci_bus"); + return -ENOMEM; + } + + bus->shrd = kzalloc(sizeof(*bus->shrd), GFP_KERNEL); + if (!bus->shrd) { + dev_printk(KERN_ERR, &pdev->dev, + "Couldn't allocate iwl_shared"); err = -ENOMEM; goto out_no_pci; } + bus->shrd->bus = bus; pci_bus = IWL_BUS_GET_PCI_BUS(bus); pci_bus->pci_dev = pdev; @@ -472,6 +480,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_pci_disable_device: pci_disable_device(pdev); out_no_pci: + kfree(bus->shrd); kfree(bus); return err; } @@ -491,6 +500,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) pci_disable_device(pci_dev); pci_set_drvdata(pci_dev, NULL); + kfree(bus->shrd); kfree(bus); } -- GitLab From b52e7ea109cfe4ea7fea99b1cd20f57ccd95476a Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 2 Feb 2012 14:16:59 -0800 Subject: [PATCH 0310/1846] iwlwifi: allocate the transport from the bus layer Change the way we alloc the transport on the way. Since the transport is allocated from a bus specific area, we can give the bus specific parameters (i.e. pci_dev for PCI) to the transport. This will be useful when the bus layer will be killed. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 16 +++---------- drivers/net/wireless/iwlwifi/iwl-pci.c | 17 ++++++++++++- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 24 +++++++++++-------- drivers/net/wireless/iwlwifi/iwl-trans.h | 21 +++++++++++----- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index b42be3084507..1a4ba9de99b0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1783,12 +1783,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, priv->shrd = bus->shrd; priv->shrd->priv = priv; - priv->shrd->trans = trans_ops->alloc(priv->shrd); - if (priv->shrd->trans == NULL) { - err = -ENOMEM; - goto out_free_traffic_mem; - } - /* At this point both hw and priv are allocated. */ SET_IEEE80211_DEV(hw, bus(priv)->dev); @@ -1835,12 +1829,12 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, err = iwl_trans_request_irq(trans(priv)); if (err) - goto out_free_trans; + goto out_free_traffic_mem; if (iwl_trans_prepare_card_hw(trans(priv))) { err = -EIO; IWL_WARN(priv, "Failed, HW not ready\n"); - goto out_free_trans; + goto out_free_traffic_mem; } /***************** @@ -1854,7 +1848,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_apm_stop(priv); if (err) { IWL_ERR(priv, "Unable to init EEPROM\n"); - goto out_free_trans; + goto out_free_traffic_mem; } err = iwl_eeprom_check_version(priv); if (err) @@ -1935,8 +1929,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_uninit_drv(priv); out_free_eeprom: iwl_eeprom_free(priv->shrd); -out_free_trans: - iwl_trans_free(trans(priv)); out_free_traffic_mem: iwl_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); @@ -1980,8 +1972,6 @@ void __devexit iwl_remove(struct iwl_priv * priv) priv->shrd->workqueue = NULL; iwl_free_traffic_mem(priv); - iwl_trans_free(trans(priv)); - iwl_uninit_drv(priv); dev_kfree_skb(priv->beacon_skb); diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index a3ca0a78336f..c0d62e724956 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -463,14 +463,28 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) bus->ops = &bus_ops_pci; #ifdef CONFIG_IWLWIFI_IDI + trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent); + if (trans(bus) == NULL) { + err = -ENOMEM; + goto out_disable_msi; + } + err = iwl_probe(bus, &trans_ops_idi, cfg); #else + trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent); + if (trans(bus) == NULL) { + err = -ENOMEM; + goto out_disable_msi; + } + err = iwl_probe(bus, &trans_ops_pcie, cfg); #endif if (err) - goto out_disable_msi; + goto out_free_trans; return 0; +out_free_trans: + iwl_trans_free(trans(bus)); out_disable_msi: pci_disable_msi(pdev); pci_iounmap(pdev, pci_bus->hw_base); @@ -493,6 +507,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) struct iwl_shared *shrd = bus->shrd; iwl_remove(shrd->priv); + iwl_trans_free(shrd->trans); pci_disable_msi(pci_dev); pci_iounmap(pci_dev, pci_bus->hw_base); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 0b4280c92584..f0d8cccbcb11 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1376,19 +1376,24 @@ static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, const struct iwl_trans_ops trans_ops_pcie; -static struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd) +struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, + struct pci_dev *pdev, + const struct pci_device_id *ent) { + struct iwl_trans_pcie *trans_pcie; struct iwl_trans *iwl_trans = kzalloc(sizeof(struct iwl_trans) + sizeof(struct iwl_trans_pcie), GFP_KERNEL); - if (iwl_trans) { - struct iwl_trans_pcie *trans_pcie = - IWL_TRANS_GET_PCIE_TRANS(iwl_trans); - iwl_trans->ops = &trans_ops_pcie; - iwl_trans->shrd = shrd; - trans_pcie->trans = iwl_trans; - spin_lock_init(&iwl_trans->hcmd_lock); - } + + if (WARN_ON(!iwl_trans)) + return NULL; + + trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans); + + iwl_trans->ops = &trans_ops_pcie; + iwl_trans->shrd = shrd; + trans_pcie->trans = iwl_trans; + spin_lock_init(&iwl_trans->hcmd_lock); return iwl_trans; } @@ -1912,7 +1917,6 @@ static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans, #endif /*CONFIG_IWLWIFI_DEBUGFS */ const struct iwl_trans_ops trans_ops_pcie = { - .alloc = iwl_trans_pcie_alloc, .request_irq = iwl_trans_pcie_request_irq, .fw_alive = iwl_trans_pcie_fw_alive, .start_device = iwl_trans_pcie_start_device, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 2a6649c9ca42..b1a7af26c570 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -133,7 +133,6 @@ struct iwl_host_cmd { /** * struct iwl_trans_ops - transport specific operations - * @alloc: allocates the meta data (not the queues themselves) * @request_irq: requests IRQ - will be called before the FW load in probe flow * @start_device: allocates and inits all the resources for the transport * layer. @@ -162,7 +161,6 @@ struct iwl_host_cmd { */ struct iwl_trans_ops { - struct iwl_trans *(*alloc)(struct iwl_shared *shrd); int (*request_irq)(struct iwl_trans *iwl_trans); int (*start_device)(struct iwl_trans *trans); void (*fw_alive)(struct iwl_trans *trans); @@ -380,11 +378,8 @@ static inline int iwl_trans_resume(struct iwl_trans *trans) #endif /***************************************************** -* Transport layers implementations +* Utils functions ******************************************************/ -extern const struct iwl_trans_ops trans_ops_pcie; -extern const struct iwl_trans_ops trans_ops_idi; - 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); @@ -394,4 +389,18 @@ 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); +/***************************************************** +* Transport layers implementations + their allocation function +******************************************************/ +struct pci_dev; +struct pci_device_id; +extern const struct iwl_trans_ops trans_ops_pcie; +struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, + struct pci_dev *pdev, + const struct pci_device_id *ent); + +extern const struct iwl_trans_ops trans_ops_idi; +struct iwl_trans *iwl_trans_idi_alloc(struct iwl_shared *shrd, + void *pdev_void, + const void *ent_void); #endif /* __iwl_trans_h__ */ -- GitLab From a42a184458ae95937893cb873c988385637c5e14 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 2 Feb 2012 14:33:08 -0800 Subject: [PATCH 0311/1846] iwlwifi: move the bus configuration to transport All the bus configuration is now done in the transport allocation fucntion. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 2 - drivers/net/wireless/iwlwifi/iwl-pci.c | 93 +--------- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 6 + drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 169 +++++++++++++++--- drivers/net/wireless/iwlwifi/iwl-trans.h | 5 + 5 files changed, 158 insertions(+), 117 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 941b9cb23442..37ed7b60aaf6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -148,7 +148,6 @@ struct iwl_bus_ops { * @shrd - pointer to iwl_shared which holds shared data from the upper layer * NB: for the time being this needs to be set by the upper layer since * it allocates the shared data - * @irq - the irq number for the device * @reg_lock - protect hw register access */ struct iwl_bus { @@ -156,7 +155,6 @@ struct iwl_bus { const struct iwl_bus_ops *ops; struct iwl_shared *shrd; - unsigned int irq; spinlock_t reg_lock; /* pointer to bus specific struct */ diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index c0d62e724956..631b67ca2b6b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -367,7 +367,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); struct iwl_bus *bus; struct iwl_pci_bus *pci_bus; - u16 pci_cmd; int err; bus = kzalloc(sizeof(*bus) + sizeof(*pci_bus), GFP_KERNEL); @@ -382,7 +381,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) dev_printk(KERN_ERR, &pdev->dev, "Couldn't allocate iwl_shared"); err = -ENOMEM; - goto out_no_pci; + goto out_free_bus; } bus->shrd->bus = bus; @@ -391,82 +390,14 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, bus); - /* W/A - seems to solve weird behavior. We need to remove this if we - * don't want to stay in L1 all the time. This wastes a lot of power */ - 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_no_pci; - } - - 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) { - dev_printk(KERN_ERR, bus->dev, - "No suitable DMA available.\n"); - goto out_pci_disable_device; - } - } - - err = pci_request_regions(pdev, DRV_NAME); - if (err) { - dev_printk(KERN_ERR, bus->dev, "pci_request_regions failed"); - goto out_pci_disable_device; - } - - pci_bus->hw_base = pci_iomap(pdev, 0, 0); - if (!pci_bus->hw_base) { - dev_printk(KERN_ERR, bus->dev, "pci_iomap failed"); - err = -ENODEV; - goto out_pci_release_regions; - } - - dev_printk(KERN_INFO, &pdev->dev, - "pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); - dev_printk(KERN_INFO, &pdev->dev, - "pci_resource_base = %p\n", pci_bus->hw_base); - - dev_printk(KERN_INFO, &pdev->dev, - "HW Revision ID = 0x%X\n", pdev->revision); - - /* 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); - - err = pci_enable_msi(pdev); - if (err) - dev_printk(KERN_ERR, &pdev->dev, - "pci_enable_msi failed(0X%x)", err); - - /* TODO: Move this away, not needed if not MSI */ - /* enable rfkill interrupt: hw bug w/a */ - pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); - if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { - pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); - } - bus->dev = &pdev->dev; - bus->irq = pdev->irq; bus->ops = &bus_ops_pci; #ifdef CONFIG_IWLWIFI_IDI trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { err = -ENOMEM; - goto out_disable_msi; + goto out_free_bus; } err = iwl_probe(bus, &trans_ops_idi, cfg); @@ -474,26 +405,20 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { err = -ENOMEM; - goto out_disable_msi; + goto out_free_bus; } err = iwl_probe(bus, &trans_ops_pcie, cfg); #endif if (err) goto out_free_trans; + return 0; out_free_trans: iwl_trans_free(trans(bus)); -out_disable_msi: - pci_disable_msi(pdev); - pci_iounmap(pdev, pci_bus->hw_base); -out_pci_release_regions: pci_set_drvdata(pdev, NULL); - pci_release_regions(pdev); -out_pci_disable_device: - pci_disable_device(pdev); -out_no_pci: +out_free_bus: kfree(bus->shrd); kfree(bus); return err; @@ -502,18 +427,12 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static void __devexit iwl_pci_remove(struct pci_dev *pdev) { struct iwl_bus *bus = pci_get_drvdata(pdev); - struct iwl_pci_bus *pci_bus = IWL_BUS_GET_PCI_BUS(bus); - struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); struct iwl_shared *shrd = bus->shrd; iwl_remove(shrd->priv); iwl_trans_free(shrd->trans); - pci_disable_msi(pci_dev); - pci_iounmap(pci_dev, pci_bus->hw_base); - pci_release_regions(pci_dev); - pci_disable_device(pci_dev); - pci_set_drvdata(pci_dev, NULL); + pci_set_drvdata(pdev, NULL); kfree(bus->shrd); kfree(bus); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 0f73778b73f7..47d27bdf2dfd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -211,6 +211,8 @@ struct iwl_tx_queue { * @txq_ctx_active_msk: what queue is active * queue_stopped: tracks what queue is stopped * queue_stop_count: tracks what SW queue is stopped + * @pci_dev: basic pci-network driver stuff + * @hw_base: pci hardware address support */ struct iwl_trans_pcie { struct iwl_rx_queue rxq; @@ -241,6 +243,10 @@ struct iwl_trans_pcie { #define IWL_MAX_HW_QUEUES 32 unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)]; atomic_t queue_stop_count[4]; + + /* PCI bus related data */ + struct pci_dev *pci_dev; + void __iomem *hw_base; }; #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index f0d8cccbcb11..5d0cfe033407 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -60,6 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ +#include +#include #include #include #include @@ -1042,7 +1044,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) spin_unlock_irqrestore(&trans->shrd->lock, flags); /* wait to make sure we flush pending tasklet*/ - synchronize_irq(bus(trans)->irq); + synchronize_irq(trans->irq); tasklet_kill(&trans_pcie->irq_tasklet); /* stop and reset the on-board processor */ @@ -1246,10 +1248,10 @@ static int iwl_trans_pcie_request_irq(struct iwl_trans *trans) iwl_alloc_isr_ict(trans); - err = request_irq(bus(trans)->irq, iwl_isr_ict, IRQF_SHARED, + err = request_irq(trans->irq, iwl_isr_ict, IRQF_SHARED, DRV_NAME, trans); if (err) { - IWL_ERR(trans, "Error allocating IRQ %d\n", bus(trans)->irq); + IWL_ERR(trans, "Error allocating IRQ %d\n", trans->irq); iwl_free_isr_ict(trans); return err; } @@ -1299,13 +1301,22 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, static void iwl_trans_pcie_free(struct iwl_trans *trans) { + struct iwl_trans_pcie *trans_pcie = + IWL_TRANS_GET_PCIE_TRANS(trans); + iwl_calib_free_results(trans); iwl_trans_pcie_tx_free(trans); #ifndef CONFIG_IWLWIFI_IDI iwl_trans_pcie_rx_free(trans); #endif - free_irq(bus(trans)->irq, trans); + free_irq(trans->irq, trans); iwl_free_isr_ict(trans); + + pci_disable_msi(trans_pcie->pci_dev); + pci_iounmap(trans_pcie->pci_dev, trans_pcie->hw_base); + pci_release_regions(trans_pcie->pci_dev); + pci_disable_device(trans_pcie->pci_dev); + trans->shrd->trans = NULL; kfree(trans); } @@ -1374,30 +1385,6 @@ static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, } } -const struct iwl_trans_ops trans_ops_pcie; - -struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, - struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - struct iwl_trans_pcie *trans_pcie; - struct iwl_trans *iwl_trans = kzalloc(sizeof(struct iwl_trans) + - sizeof(struct iwl_trans_pcie), - GFP_KERNEL); - - if (WARN_ON(!iwl_trans)) - return NULL; - - trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans); - - iwl_trans->ops = &trans_ops_pcie; - iwl_trans->shrd = shrd; - trans_pcie->trans = iwl_trans; - spin_lock_init(&iwl_trans->hcmd_lock); - - return iwl_trans; -} - static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id, const char *msg) { @@ -1949,3 +1936,129 @@ const struct iwl_trans_ops trans_ops_pcie = { .resume = iwl_trans_pcie_resume, #endif }; + +/* TODO: remove this hack - will be possible when all the io{write/read} ops + * will be done through the transport + */ +struct iwl_pci_bus { + /* basic pci-network driver stuff */ + struct pci_dev *pci_dev; + + /* pci hardware address support */ + void __iomem *hw_base; +}; + +#define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ + ((struct iwl_pci_bus *) ((_iwl_bus)->bus_specific)) + +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + +struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, + struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + struct iwl_pci_bus *iwl_pci_bus = IWL_BUS_GET_PCI_BUS(shrd->bus); + struct iwl_trans_pcie *trans_pcie; + struct iwl_trans *trans; + u16 pci_cmd; + int err; + + trans = kzalloc(sizeof(struct iwl_trans) + + sizeof(struct iwl_trans_pcie), GFP_KERNEL); + + if (WARN_ON(!trans)) + return NULL; + + trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + + trans->ops = &trans_ops_pcie; + trans->shrd = shrd; + trans_pcie->trans = trans; + spin_lock_init(&trans->hcmd_lock); + + /* W/A - seems to solve weird behavior. We need to remove this if we + * don't want to stay in L1 all the time. This wastes a lot of power */ + 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_no_pci; + } + + 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) { + dev_printk(KERN_ERR, &pdev->dev, + "No suitable DMA available.\n"); + goto out_pci_disable_device; + } + } + + err = pci_request_regions(pdev, DRV_NAME); + if (err) { + dev_printk(KERN_ERR, &pdev->dev, "pci_request_regions failed"); + goto out_pci_disable_device; + } + + trans_pcie->hw_base = pci_iomap(pdev, 0, 0); + if (!trans_pcie->hw_base) { + dev_printk(KERN_ERR, &pdev->dev, "pci_iomap failed"); + err = -ENODEV; + goto out_pci_release_regions; + } + + /* TODO: remove this hack */ + iwl_pci_bus->hw_base = trans_pcie->hw_base; + + dev_printk(KERN_INFO, &pdev->dev, + "pci_resource_len = 0x%08llx\n", + (unsigned long long) pci_resource_len(pdev, 0)); + dev_printk(KERN_INFO, &pdev->dev, + "pci_resource_base = %p\n", trans_pcie->hw_base); + + dev_printk(KERN_INFO, &pdev->dev, + "HW Revision ID = 0x%X\n", pdev->revision); + + /* 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); + + err = pci_enable_msi(pdev); + if (err) + dev_printk(KERN_ERR, &pdev->dev, + "pci_enable_msi failed(0X%x)", err); + + trans->dev = &pdev->dev; + trans->irq = pdev->irq; + trans_pcie->pci_dev = pdev; + + /* TODO: Move this away, not needed if not MSI */ + /* enable rfkill interrupt: hw bug w/a */ + pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); + if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { + pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; + pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); + } + + return trans; + +out_pci_release_regions: + pci_release_regions(pdev); +out_pci_disable_device: + pci_disable_device(pdev); +out_no_pci: + kfree(trans); + return NULL; +} + diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index b1a7af26c570..9a8076194868 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -228,6 +228,8 @@ struct iwl_calib_result { * @ops - pointer to iwl_trans_ops * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @hcmd_lock: protects HCMD + * @dev - pointer to struct device * that represents the device + * @irq - the irq number for the device * @ucode_write_complete: indicates that the ucode has been copied. * @ucode_rt: run time ucode image * @ucode_init: init ucode image @@ -240,6 +242,9 @@ struct iwl_trans { struct iwl_shared *shrd; spinlock_t hcmd_lock; + struct device *dev; + unsigned int irq; + u8 ucode_write_complete; /* the image write is complete */ struct fw_img ucode_rt; struct fw_img ucode_init; -- GitLab From 0390549571cb614ac5cd3327b63f95155a75c673 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 3 Jan 2012 13:48:07 +0200 Subject: [PATCH 0312/1846] iwlwifi: the read / write register ops move to transport Most of the accesses to the registers are done from the transport layer. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 21 ----------- drivers/net/wireless/iwlwifi/iwl-io.h | 11 ++++-- drivers/net/wireless/iwlwifi/iwl-pci.c | 22 ----------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 37 ++++++++++--------- drivers/net/wireless/iwlwifi/iwl-trans.h | 21 +++++++++++ 5 files changed, 48 insertions(+), 64 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 37ed7b60aaf6..981f7b79d395 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -124,18 +124,12 @@ struct iwl_bus; * @apm_config: will be called during the config of the APM * @get_hw_id_string: prints the hw_id in the provided buffer * @get_hw_id: get hw_id in u32 - * @write8: write a byte to register at offset ofs - * @write32: write a dword to register at offset ofs - * @wread32: read a dword at register at offset ofs */ struct iwl_bus_ops { bool (*get_pm_support)(struct iwl_bus *bus); void (*apm_config)(struct iwl_bus *bus); void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); u32 (*get_hw_id)(struct iwl_bus *bus); - void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val); - void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val); - u32 (*read32)(struct iwl_bus *bus, u32 ofs); }; /** @@ -183,21 +177,6 @@ static inline u32 bus_get_hw_id(struct iwl_bus *bus) return bus->ops->get_hw_id(bus); } -static inline void bus_write8(struct iwl_bus *bus, u32 ofs, u8 val) -{ - bus->ops->write8(bus, ofs, val); -} - -static inline void bus_write32(struct iwl_bus *bus, u32 ofs, u32 val) -{ - bus->ops->write32(bus, ofs, val); -} - -static inline u32 bus_read32(struct iwl_bus *bus, u32 ofs) -{ - return bus->ops->read32(bus, ofs); -} - /***************************************************** * Bus layer registration functions ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index 427d065435c8..b8e00cd7b1f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h @@ -31,23 +31,28 @@ #include "iwl-devtrace.h" #include "iwl-shared.h" +/* TODO: remove when not needed any more */ #include "iwl-bus.h" +#include "iwl-trans.h" static inline void iwl_write8(struct iwl_bus *bus, u32 ofs, u8 val) { + /* TODO: get trans instead of bus */ trace_iwlwifi_dev_iowrite8(priv(bus), ofs, val); - bus_write8(bus, ofs, val); + iwl_trans_write8(trans(bus), ofs, val); } static inline void iwl_write32(struct iwl_bus *bus, u32 ofs, u32 val) { + /* TODO: get trans instead of bus */ trace_iwlwifi_dev_iowrite32(priv(bus), ofs, val); - bus_write32(bus, ofs, val); + iwl_trans_write32(trans(bus), ofs, val); } static inline u32 iwl_read32(struct iwl_bus *bus, u32 ofs) { - u32 val = bus_read32(bus, ofs); + /* TODO: get trans instead of bus */ + u32 val = iwl_trans_read32(trans(bus), ofs); trace_iwlwifi_dev_ioread32(priv(bus), ofs, val); return val; } diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 631b67ca2b6b..ab462337d7a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -79,9 +79,6 @@ struct iwl_pci_bus { /* basic pci-network driver stuff */ struct pci_dev *pci_dev; - - /* pci hardware address support */ - void __iomem *hw_base; }; #define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ @@ -151,30 +148,11 @@ static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) return (pci_dev->device << 16) + pci_dev->subsystem_device; } -static void iwl_pci_write8(struct iwl_bus *bus, u32 ofs, u8 val) -{ - iowrite8(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); -} - -static void iwl_pci_write32(struct iwl_bus *bus, u32 ofs, u32 val) -{ - iowrite32(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); -} - -static u32 iwl_pci_read32(struct iwl_bus *bus, u32 ofs) -{ - u32 val = ioread32(IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); - return val; -} - static const struct iwl_bus_ops bus_ops_pci = { .get_pm_support = iwl_pci_is_pm_supported, .apm_config = iwl_pci_apm_config, .get_hw_id_string = iwl_pci_get_hw_id_string, .get_hw_id = iwl_pci_get_hw_id, - .write8 = iwl_pci_write8, - .write32 = iwl_pci_write32, - .read32 = iwl_pci_read32, }; #define IWL_PCI_DEVICE(dev, subdev, cfg) \ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 5d0cfe033407..80f531844f3e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1299,6 +1299,22 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, return 0; } +static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val) +{ + iowrite8(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); +} + +static void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val) +{ + iowrite32(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); +} + +static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) +{ + u32 val = ioread32(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); + return val; +} + static void iwl_trans_pcie_free(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = @@ -1935,22 +1951,11 @@ const struct iwl_trans_ops trans_ops_pcie = { .suspend = iwl_trans_pcie_suspend, .resume = iwl_trans_pcie_resume, #endif + .write8 = iwl_trans_pcie_write8, + .write32 = iwl_trans_pcie_write32, + .read32 = iwl_trans_pcie_read32, }; -/* TODO: remove this hack - will be possible when all the io{write/read} ops - * will be done through the transport - */ -struct iwl_pci_bus { - /* basic pci-network driver stuff */ - struct pci_dev *pci_dev; - - /* pci hardware address support */ - void __iomem *hw_base; -}; - -#define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ - ((struct iwl_pci_bus *) ((_iwl_bus)->bus_specific)) - /* PCI registers */ #define PCI_CFG_RETRY_TIMEOUT 0x041 @@ -1958,7 +1963,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, struct pci_dev *pdev, const struct pci_device_id *ent) { - struct iwl_pci_bus *iwl_pci_bus = IWL_BUS_GET_PCI_BUS(shrd->bus); struct iwl_trans_pcie *trans_pcie; struct iwl_trans *trans; u16 pci_cmd; @@ -2018,9 +2022,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, goto out_pci_release_regions; } - /* TODO: remove this hack */ - iwl_pci_bus->hw_base = trans_pcie->hw_base; - dev_printk(KERN_INFO, &pdev->dev, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 9a8076194868..0a3727dac6ac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -158,6 +158,9 @@ struct iwl_host_cmd { * automatically deleted. * @suspend: stop the device unless WoWLAN is configured * @resume: resume activity of the device + * @write8: write a u8 to a register at offset ofs from the BAR + * @write32: write a u32 to a register at offset ofs from the BAR + * @read32: read a u32 register at offset ofs from the BAR */ struct iwl_trans_ops { @@ -201,6 +204,9 @@ struct iwl_trans_ops { int (*suspend)(struct iwl_trans *trans); int (*resume)(struct iwl_trans *trans); #endif + void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); + void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); + u32 (*read32)(struct iwl_trans *trans, u32 ofs); }; /* one for each uCode image (inst/data, boot/init/runtime) */ @@ -382,6 +388,21 @@ static inline int iwl_trans_resume(struct iwl_trans *trans) } #endif +static inline void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val) +{ + trans->ops->write8(trans, ofs, val); +} + +static inline void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val) +{ + trans->ops->write32(trans, ofs, val); +} + +static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) +{ + return trans->ops->read32(trans, ofs); +} + /***************************************************** * Utils functions ******************************************************/ -- GitLab From 1042db2af183b96cdce5972014d85e8bca0634ad Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 3 Jan 2012 16:56:15 +0200 Subject: [PATCH 0313/1846] iwlwifi: give trans to all the read / write functions From now on, the transport layer in charge of providing access to the device. So change all the driver to give a pointer to the transport to all the low level functions that actually access the device. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-1000.c | 4 +- drivers/net/wireless/iwlwifi/iwl-2000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-5000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-6000.c | 8 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 8 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 14 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 42 ++-- drivers/net/wireless/iwlwifi/iwl-bus.h | 3 - drivers/net/wireless/iwlwifi/iwl-core.c | 28 +-- drivers/net/wireless/iwlwifi/iwl-core.h | 2 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 6 +- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 61 +++--- drivers/net/wireless/iwlwifi/iwl-io.c | 193 +++++++++--------- drivers/net/wireless/iwlwifi/iwl-io.h | 63 +++--- drivers/net/wireless/iwlwifi/iwl-led.c | 9 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 27 +-- drivers/net/wireless/iwlwifi/iwl-pci.c | 4 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 16 +- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 8 +- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 82 ++++---- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 46 ++--- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 144 ++++++------- drivers/net/wireless/iwlwifi/iwl-trans.h | 2 + drivers/net/wireless/iwlwifi/iwl-ucode.c | 37 ++-- 24 files changed, 405 insertions(+), 406 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index cc04cce11567..f7a555b9d24b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -84,13 +84,13 @@ static void iwl1000_set_ct_threshold(struct iwl_priv *priv) static void iwl1000_nic_config(struct iwl_priv *priv) { /* set CSR_HW_CONFIG_REG for uCode use */ - iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); /* Setting digital SVR for 1000 card to 1.32V */ /* locking is acquired in iwl_set_bits_mask_prph() function */ - iwl_set_bits_mask_prph(bus(priv), APMG_DIGITAL_SVR_REG, + iwl_set_bits_mask_prph(trans(priv), APMG_DIGITAL_SVR_REG, APMG_SVR_DIGITAL_VOLTAGE_1_32, ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK); } diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 00db092d8cd0..876003450108 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -87,7 +87,7 @@ static void iwl2000_nic_config(struct iwl_priv *priv) iwl_rf_config(priv); if (cfg(priv)->iq_invert) - iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, + iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER); } diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 47fd98b3652c..5245a1422a64 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -73,7 +73,7 @@ static void iwl5000_nic_config(struct iwl_priv *priv) * (PCIe power is lost before PERST# is asserted), * causing ME FW to lose ownership and not being able to obtain it back. */ - iwl_set_bits_mask_prph(bus(priv), APMG_PS_CTRL_REG, + iwl_set_bits_mask_prph(trans(priv), APMG_PS_CTRL_REG, APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS, ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index ab62c018fcdb..464b88784678 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -82,7 +82,7 @@ static void iwl6050_additional_nic_config(struct iwl_priv *priv) { /* Indicate calibration version to uCode. */ if (iwl_eeprom_calib_version(priv->shrd) >= 6) - iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, + iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6); } @@ -90,9 +90,9 @@ static void iwl6150_additional_nic_config(struct iwl_priv *priv) { /* Indicate calibration version to uCode. */ if (iwl_eeprom_calib_version(priv->shrd) >= 6) - iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, + iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6); - iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, + iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_6050_1x2); } @@ -104,7 +104,7 @@ static void iwl6000_nic_config(struct iwl_priv *priv) /* no locking required for register write */ if (cfg(priv)->pa_type == IWL_PA_INTERNAL) { /* 2x2 IPA phy type */ - iwl_write32(bus(priv), CSR_GP_DRIVER_REG, + iwl_write32(trans(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA); } /* do additional nic configuration if needed */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index f127f913e5a6..a14ddab783ea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -628,16 +628,16 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - iwl_write_direct32(bus(priv), HBUS_TARG_MBX_C, + iwl_write_direct32(trans(priv), HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - iwl_write_direct32(bus(priv), HBUS_TARG_MBX_C, + iwl_write_direct32(trans(priv), HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } if (flags & CT_CARD_DISABLED) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index 56c6def015a4..c728ed75584e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -178,19 +178,19 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data) if (tt->state == IWL_TI_CT_KILL) { if (priv->thermal_throttle.ct_kill_toggle) { - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); priv->thermal_throttle.ct_kill_toggle = false; } else { - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); priv->thermal_throttle.ct_kill_toggle = true; } - iwl_read32(bus(priv), CSR_UCODE_DRV_GP1); - spin_lock_irqsave(&bus(priv)->reg_lock, flags); - if (!iwl_grab_nic_access(bus(priv))) - iwl_release_nic_access(bus(priv)); - spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); + iwl_read32(trans(priv), CSR_UCODE_DRV_GP1); + spin_lock_irqsave(&trans(priv)->reg_lock, flags); + if (!iwl_grab_nic_access(trans(priv))) + iwl_release_nic_access(trans(priv)); + spin_unlock_irqrestore(&trans(priv)->reg_lock, flags); /* Reschedule the ct_kill timer to occur in * CT_KILL_EXIT_DURATION seconds to ensure we get a diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 1a4ba9de99b0..f79791500a9c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -328,14 +328,14 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32)); /* Make sure device is powered up for SRAM reads */ - spin_lock_irqsave(&bus(priv)->reg_lock, reg_flags); - if (iwl_grab_nic_access(bus(priv))) { - spin_unlock_irqrestore(&bus(priv)->reg_lock, reg_flags); + spin_lock_irqsave(&trans(priv)->reg_lock, reg_flags); + if (iwl_grab_nic_access(trans(priv))) { + spin_unlock_irqrestore(&trans(priv)->reg_lock, reg_flags); return; } /* Set starting address; reads will auto-increment */ - iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, ptr); + iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, ptr); rmb(); /* @@ -352,19 +352,19 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, * place event id # at far right for easier visual parsing. */ for (i = 0; i < num_events; i++) { - ev = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); - time = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); + ev = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); + time = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); if (mode == 0) { trace_iwlwifi_dev_ucode_cont_event(priv, 0, time, ev); } else { - data = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); + data = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); trace_iwlwifi_dev_ucode_cont_event(priv, time, data, ev); } } /* Allow device to power down */ - iwl_release_nic_access(bus(priv)); - spin_unlock_irqrestore(&bus(priv)->reg_lock, reg_flags); + iwl_release_nic_access(trans(priv)); + spin_unlock_irqrestore(&trans(priv)->reg_lock, reg_flags); } static void iwl_continuous_event_trace(struct iwl_priv *priv) @@ -383,7 +383,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv) base = priv->shrd->device_pointers.log_event_table; if (iwlagn_hw_valid_rtc_data_addr(base)) { - iwl_read_targ_mem_words(bus(priv), base, &read, sizeof(read)); + iwl_read_targ_mem_words(trans(priv), base, &read, sizeof(read)); capacity = read.capacity; mode = read.mode; @@ -583,7 +583,7 @@ static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) priv->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, - bus(priv)->dev, + trans(priv)->dev, GFP_KERNEL, priv, iwl_ucode_callback); } @@ -1158,7 +1158,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv) int ret = 0; spin_lock_irqsave(&priv->shrd->lock, flags); - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&priv->shrd->lock, flags); priv->thermal_throttle.ct_kill_toggle = false; @@ -1693,7 +1693,7 @@ static void iwl_uninit_drv(struct iwl_priv *priv) static u32 iwl_hw_detect(struct iwl_priv *priv) { - return iwl_read32(bus(priv), CSR_HW_REV); + return iwl_read32(trans(priv), CSR_HW_REV); } /* Size of one Rx buffer in host DRAM */ @@ -1727,32 +1727,32 @@ 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 " + dev_printk(KERN_INFO, trans(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 " + dev_printk(KERN_INFO, trans(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 " + dev_printk(KERN_INFO, trans(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_TESTMODE " + dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_DEVICE_TESTMODE " #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE "enabled\n"); #else "disabled\n"); #endif - dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_P2P " + dev_printk(KERN_INFO, trans(priv)->dev, "CONFIG_IWLWIFI_P2P " #ifdef CONFIG_IWLWIFI_P2P "enabled\n"); #else @@ -1810,7 +1810,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now */ - spin_lock_init(&bus(priv)->reg_lock); + spin_lock_init(&trans(priv)->reg_lock); spin_lock_init(&priv->shrd->lock); /* @@ -1818,7 +1818,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - iwl_write32(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + iwl_write32(trans(priv), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 3. Read REV register @@ -1903,7 +1903,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_enable_rfkill_int(priv); /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(bus(priv), + if (iwl_read32(trans(priv), CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status); else diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 981f7b79d395..ce1a9cc106eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -142,15 +142,12 @@ struct iwl_bus_ops { * @shrd - pointer to iwl_shared which holds shared data from the upper layer * NB: for the time being this needs to be set by the upper layer since * it allocates the shared data - * @reg_lock - protect hw register access */ struct iwl_bus { struct device *dev; const struct iwl_bus_ops *ops; struct iwl_shared *shrd; - spinlock_t reg_lock; - /* pointer to bus specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ char bus_specific[0] __attribute__((__aligned__(sizeof(void *)))); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 7d6eef96454a..c9022c5fa817 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -888,9 +888,9 @@ static int iwl_apm_stop_master(struct iwl_priv *priv) int ret = 0; /* stop device's busmaster DMA activity */ - iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + iwl_set_bit(trans(priv), CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = iwl_poll_bit(bus(priv), CSR_RESET, + ret = iwl_poll_bit(trans(priv), CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) @@ -911,7 +911,7 @@ void iwl_apm_stop(struct iwl_priv *priv) iwl_apm_stop_master(priv); /* Reset the entire device */ - iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + iwl_set_bit(trans(priv), CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); udelay(10); @@ -919,7 +919,8 @@ void iwl_apm_stop(struct iwl_priv *priv) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - iwl_clear_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + iwl_clear_bit(trans(priv), CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } @@ -939,45 +940,46 @@ int iwl_apm_init(struct iwl_priv *priv) */ /* Disable L0S exit timer (platform NMI Work/Around) */ - iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS, + iwl_set_bit(trans(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_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS, + iwl_set_bit(trans(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_set_bit(bus(priv), CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); + iwl_set_bit(trans(priv), 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 */ - iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); bus_apm_config(bus(priv)); /* Configure analog phase-lock-loop before activating to D0A */ if (cfg(priv)->base_params->pll_cfg_val) - iwl_set_bit(bus(priv), CSR_ANA_PLL_CFG, + iwl_set_bit(trans(priv), CSR_ANA_PLL_CFG, cfg(priv)->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from * D0U* --> D0A* (powered-up active) state. */ - iwl_set_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + iwl_set_bit(trans(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_write_prph() * and accesses to uCode SRAM. */ - ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL, + ret = iwl_poll_bit(trans(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { @@ -992,11 +994,11 @@ int iwl_apm_init(struct iwl_priv *priv) * do not disable clocks. This preserves any hardware bits already * set by default in "CLK_CTRL_REG" after reset. */ - iwl_write_prph(bus(priv), APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); + iwl_write_prph(trans(priv), APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ - iwl_set_bits_prph(bus(priv), APMG_PCIDEV_STT_REG, + iwl_set_bits_prph(trans(priv), APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); set_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 63f29111da13..e74bfb7bbb27 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -300,7 +300,7 @@ static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv) static inline void iwl_enable_rfkill_int(struct iwl_priv *priv) { IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); - iwl_write32(bus(priv), CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + iwl_write32(trans(priv), CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } extern bool bt_siso_mode; diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 978a1d4c6a0a..136de6fb3fa4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -263,7 +263,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, sram = priv->dbgfs_sram_offset & ~0x3; /* read the first u32 from sram */ - val = iwl_read_targ_mem(bus(priv), sram); + val = iwl_read_targ_mem(trans(priv), sram); for (; len; len--) { /* put the address at the start of every line */ @@ -282,7 +282,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, if (++offset == 4) { sram += 4; offset = 0; - val = iwl_read_targ_mem(bus(priv), sram); + val = iwl_read_targ_mem(trans(priv), sram); } /* put in extra spaces and split lines for human readability */ @@ -2055,7 +2055,7 @@ static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = iwl_read32(bus(priv), CSR_GP_CNTRL) & + pwrsave_status = iwl_read32(trans(priv), 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/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index ce214e0ab496..d1fd1cdb29c2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -156,16 +156,16 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - iwl_set_bit(bus, CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans(bus), CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = iwl_poll_bit(bus, CSR_HW_IF_CONFIG_REG, + ret = iwl_poll_bit(trans(bus), 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_EEPROM(bus, + IWL_DEBUG_EEPROM(trans(bus), "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -177,14 +177,15 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) static void iwl_eeprom_release_semaphore(struct iwl_bus *bus) { - iwl_clear_bit(bus, CSR_HW_IF_CONFIG_REG, + iwl_clear_bit(trans(bus), CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } static int iwl_eeprom_verify_signature(struct iwl_trans *trans) { - u32 gp = iwl_read32(bus(trans), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = iwl_read32(trans, CSR_EEPROM_GP) & + CSR_EEPROM_GP_VALID_MSK; int ret = 0; IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp); @@ -305,13 +306,13 @@ void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac) static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode) { - iwl_read32(bus, CSR_OTP_GP_REG); + iwl_read32(trans(bus), CSR_OTP_GP_REG); if (mode == IWL_OTP_ACCESS_ABSOLUTE) - iwl_clear_bit(bus, CSR_OTP_GP_REG, + iwl_clear_bit(trans(bus), CSR_OTP_GP_REG, CSR_OTP_GP_REG_OTP_ACCESS_MODE); else - iwl_set_bit(bus, CSR_OTP_GP_REG, + iwl_set_bit(trans(bus), CSR_OTP_GP_REG, CSR_OTP_GP_REG_OTP_ACCESS_MODE); } @@ -332,7 +333,7 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) nvm_type = NVM_DEVICE_TYPE_EEPROM; break; default: - otpgp = iwl_read32(bus, CSR_OTP_GP_REG); + otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG); if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) nvm_type = NVM_DEVICE_TYPE_OTP; else @@ -347,22 +348,22 @@ static int iwl_init_otp_access(struct iwl_bus *bus) int ret; /* Enable 40MHz radio clock */ - iwl_write32(bus, CSR_GP_CNTRL, - iwl_read32(bus, CSR_GP_CNTRL) | + iwl_write32(trans(bus), CSR_GP_CNTRL, + iwl_read32(trans(bus), CSR_GP_CNTRL) | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* wait for clock to be ready */ - ret = iwl_poll_bit(bus, CSR_GP_CNTRL, + ret = iwl_poll_bit(trans(bus), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) IWL_ERR(bus, "Time out access OTP\n"); else { - iwl_set_bits_prph(bus, APMG_PS_CTRL_REG, + iwl_set_bits_prph(trans(bus), APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - iwl_clear_bits_prph(bus, APMG_PS_CTRL_REG, + iwl_clear_bits_prph(trans(bus), APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); /* @@ -370,7 +371,7 @@ static int iwl_init_otp_access(struct iwl_bus *bus) * this is only applicable for HW with OTP shadow RAM */ if (cfg(bus)->base_params->shadow_ram_support) - iwl_set_bit(bus, CSR_DBG_LINK_PWR_MGMT_REG, + iwl_set_bit(trans(bus), CSR_DBG_LINK_PWR_MGMT_REG, CSR_RESET_LINK_PWR_MGMT_DISABLED); } return ret; @@ -382,9 +383,9 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) u32 r; u32 otpgp; - iwl_write32(bus, CSR_EEPROM_REG, + iwl_write32(trans(bus), CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(bus, CSR_EEPROM_REG, + ret = iwl_poll_bit(trans(bus), CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IWL_EEPROM_ACCESS_TIMEOUT); @@ -392,13 +393,13 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) IWL_ERR(bus, "Time out reading OTP[%d]\n", addr); return ret; } - r = iwl_read32(bus, CSR_EEPROM_REG); + r = iwl_read32(trans(bus), CSR_EEPROM_REG); /* check for ECC errors: */ - otpgp = iwl_read32(bus, CSR_OTP_GP_REG); + otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG); if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { /* stop in this case */ /* set the uncorrectable OTP ECC bit for acknowledgement */ - iwl_set_bit(bus, CSR_OTP_GP_REG, + iwl_set_bit(trans(bus), CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n"); return -EINVAL; @@ -406,7 +407,7 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { /* continue in this case */ /* set the correctable OTP ECC bit for acknowledgement */ - iwl_set_bit(bus, CSR_OTP_GP_REG, + iwl_set_bit(trans(bus), CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); IWL_ERR(bus, "Correctable OTP ECC error, continue read\n"); } @@ -656,7 +657,7 @@ 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); + u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP); int sz; int ret; u16 addr; @@ -699,11 +700,11 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) ret = -ENOENT; goto done; } - iwl_write32(bus(priv), CSR_EEPROM_GP, - iwl_read32(bus(priv), CSR_EEPROM_GP) & + iwl_write32(trans(priv), CSR_EEPROM_GP, + iwl_read32(trans(priv), CSR_EEPROM_GP) & ~CSR_EEPROM_GP_IF_OWNER_MSK); - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, + iwl_set_bit(trans(priv), CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); /* traversing the linked list if no shadow ram supported */ @@ -728,10 +729,10 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - iwl_write32(bus(priv), CSR_EEPROM_REG, + iwl_write32(trans(priv), CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(bus(priv), CSR_EEPROM_REG, + ret = iwl_poll_bit(trans(priv), CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IWL_EEPROM_ACCESS_TIMEOUT); @@ -739,7 +740,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr); goto done; } - r = iwl_read32(bus(priv), CSR_EEPROM_REG); + r = iwl_read32(trans(priv), CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } } @@ -1068,7 +1069,7 @@ void iwl_rf_config(struct iwl_priv *priv) /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) { - iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans(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)); @@ -1080,7 +1081,7 @@ void iwl_rf_config(struct iwl_priv *priv) WARN_ON(1); /* set CSR_HW_CONFIG_REG for uCode use */ - iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); } diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index 83fdff381150..e2e3b5c9cf7f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -34,41 +34,41 @@ #define IWL_POLL_INTERVAL 10 /* microseconds */ -static inline void __iwl_set_bit(struct iwl_bus *bus, u32 reg, u32 mask) +static inline void __iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask) { - iwl_write32(bus, reg, iwl_read32(bus, reg) | mask); + iwl_write32(trans, reg, iwl_read32(trans, reg) | mask); } -static inline void __iwl_clear_bit(struct iwl_bus *bus, u32 reg, u32 mask) +static inline void __iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) { - iwl_write32(bus, reg, iwl_read32(bus, reg) & ~mask); + iwl_write32(trans, reg, iwl_read32(trans, reg) & ~mask); } -void iwl_set_bit(struct iwl_bus *bus, u32 reg, u32 mask) +void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask) { unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - __iwl_set_bit(bus, reg, mask); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + __iwl_set_bit(trans, reg, mask); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -void iwl_clear_bit(struct iwl_bus *bus, u32 reg, u32 mask) +void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) { unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - __iwl_clear_bit(bus, reg, mask); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + __iwl_clear_bit(trans, reg, mask); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -int iwl_poll_bit(struct iwl_bus *bus, u32 addr, +int iwl_poll_bit(struct iwl_trans *trans, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; do { - if ((iwl_read32(bus, addr) & mask) == (bits & mask)) + if ((iwl_read32(trans, addr) & mask) == (bits & mask)) return t; udelay(IWL_POLL_INTERVAL); t += IWL_POLL_INTERVAL; @@ -77,14 +77,15 @@ int iwl_poll_bit(struct iwl_bus *bus, u32 addr, return -ETIMEDOUT; } -int iwl_grab_nic_access_silent(struct iwl_bus *bus) +int iwl_grab_nic_access_silent(struct iwl_trans *trans) { int ret; - lockdep_assert_held(&bus->reg_lock); + lockdep_assert_held(&trans->reg_lock); /* this bit wakes up the NIC */ - __iwl_set_bit(bus, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + __iwl_set_bit(trans, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* * These bits say the device is running, and should keep running for @@ -105,70 +106,70 @@ int iwl_grab_nic_access_silent(struct iwl_bus *bus) * 5000 series and later (including 1000 series) have non-volatile SRAM, * and do not save/restore SRAM when power cycling. */ - ret = iwl_poll_bit(bus, CSR_GP_CNTRL, + ret = iwl_poll_bit(trans, 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) { - iwl_write32(bus, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); + iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } return 0; } -int iwl_grab_nic_access(struct iwl_bus *bus) +int iwl_grab_nic_access(struct iwl_trans *trans) { - int ret = iwl_grab_nic_access_silent(bus); + int ret = iwl_grab_nic_access_silent(trans); if (ret) { - u32 val = iwl_read32(bus, CSR_GP_CNTRL); - IWL_ERR(bus, + u32 val = iwl_read32(trans, CSR_GP_CNTRL); + IWL_ERR(trans, "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); } return ret; } -void iwl_release_nic_access(struct iwl_bus *bus) +void iwl_release_nic_access(struct iwl_trans *trans) { - lockdep_assert_held(&bus->reg_lock); - __iwl_clear_bit(bus, CSR_GP_CNTRL, + lockdep_assert_held(&trans->reg_lock); + __iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -u32 iwl_read_direct32(struct iwl_bus *bus, u32 reg) +u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg) { u32 value; unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - iwl_grab_nic_access(bus); - value = iwl_read32(bus, reg); - iwl_release_nic_access(bus); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + value = iwl_read32(trans, reg); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); return value; } -void iwl_write_direct32(struct iwl_bus *bus, u32 reg, u32 value) +void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value) { unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - if (!iwl_grab_nic_access(bus)) { - iwl_write32(bus, reg, value); - iwl_release_nic_access(bus); + spin_lock_irqsave(&trans->reg_lock, flags); + if (!iwl_grab_nic_access(trans)) { + iwl_write32(trans, reg, value); + iwl_release_nic_access(trans); } - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -int iwl_poll_direct_bit(struct iwl_bus *bus, u32 addr, u32 mask, +int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((iwl_read_direct32(bus, addr) & mask) == mask) + if ((iwl_read_direct32(trans, addr) & mask) == mask) return t; udelay(IWL_POLL_INTERVAL); t += IWL_POLL_INTERVAL; @@ -177,135 +178,135 @@ int iwl_poll_direct_bit(struct iwl_bus *bus, u32 addr, u32 mask, return -ETIMEDOUT; } -static inline u32 __iwl_read_prph(struct iwl_bus *bus, u32 reg) +static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 reg) { - iwl_write32(bus, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + iwl_write32(trans, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return iwl_read32(bus, HBUS_TARG_PRPH_RDAT); + return iwl_read32(trans, HBUS_TARG_PRPH_RDAT); } -static inline void __iwl_write_prph(struct iwl_bus *bus, u32 addr, u32 val) +static inline void __iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) { - iwl_write32(bus, HBUS_TARG_PRPH_WADDR, + iwl_write32(trans, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - iwl_write32(bus, HBUS_TARG_PRPH_WDAT, val); + iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val); } -u32 iwl_read_prph(struct iwl_bus *bus, u32 reg) +u32 iwl_read_prph(struct iwl_trans *trans, u32 reg) { unsigned long flags; u32 val; - spin_lock_irqsave(&bus->reg_lock, flags); - iwl_grab_nic_access(bus); - val = __iwl_read_prph(bus, reg); - iwl_release_nic_access(bus); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + val = __iwl_read_prph(trans, reg); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); return val; } -void iwl_write_prph(struct iwl_bus *bus, u32 addr, u32 val) +void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) { unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - if (!iwl_grab_nic_access(bus)) { - __iwl_write_prph(bus, addr, val); - iwl_release_nic_access(bus); + spin_lock_irqsave(&trans->reg_lock, flags); + if (!iwl_grab_nic_access(trans)) { + __iwl_write_prph(trans, addr, val); + iwl_release_nic_access(trans); } - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -void iwl_set_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask) +void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) { unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - iwl_grab_nic_access(bus); - __iwl_write_prph(bus, reg, __iwl_read_prph(bus, reg) | mask); - iwl_release_nic_access(bus); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + __iwl_write_prph(trans, reg, __iwl_read_prph(trans, reg) | mask); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -void iwl_set_bits_mask_prph(struct iwl_bus *bus, u32 reg, +void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg, u32 bits, u32 mask) { unsigned long flags; - spin_lock_irqsave(&bus->reg_lock, flags); - iwl_grab_nic_access(bus); - __iwl_write_prph(bus, reg, - (__iwl_read_prph(bus, reg) & mask) | bits); - iwl_release_nic_access(bus); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + __iwl_write_prph(trans, reg, + (__iwl_read_prph(trans, reg) & mask) | bits); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -void iwl_clear_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask) +void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) { unsigned long flags; u32 val; - spin_lock_irqsave(&bus->reg_lock, flags); - iwl_grab_nic_access(bus); - val = __iwl_read_prph(bus, reg); - __iwl_write_prph(bus, reg, (val & ~mask)); - iwl_release_nic_access(bus); - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + val = __iwl_read_prph(trans, reg); + __iwl_write_prph(trans, reg, (val & ~mask)); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -void _iwl_read_targ_mem_words(struct iwl_bus *bus, u32 addr, +void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr, void *buf, int words) { unsigned long flags; int offs; u32 *vals = buf; - spin_lock_irqsave(&bus->reg_lock, flags); - iwl_grab_nic_access(bus); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); - iwl_write32(bus, HBUS_TARG_MEM_RADDR, addr); + iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr); rmb(); for (offs = 0; offs < words; offs++) - vals[offs] = iwl_read32(bus, HBUS_TARG_MEM_RDAT); + vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT); - iwl_release_nic_access(bus); - spin_unlock_irqrestore(&bus->reg_lock, flags); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); } -u32 iwl_read_targ_mem(struct iwl_bus *bus, u32 addr) +u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr) { u32 value; - _iwl_read_targ_mem_words(bus, addr, &value, 1); + _iwl_read_targ_mem_words(trans, addr, &value, 1); return value; } -int _iwl_write_targ_mem_words(struct iwl_bus *bus, u32 addr, +int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr, void *buf, int words) { unsigned long flags; int offs, result = 0; u32 *vals = buf; - spin_lock_irqsave(&bus->reg_lock, flags); - if (!iwl_grab_nic_access(bus)) { - iwl_write32(bus, HBUS_TARG_MEM_WADDR, addr); + spin_lock_irqsave(&trans->reg_lock, flags); + if (!iwl_grab_nic_access(trans)) { + iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr); wmb(); for (offs = 0; offs < words; offs++) - iwl_write32(bus, HBUS_TARG_MEM_WDAT, vals[offs]); - iwl_release_nic_access(bus); + iwl_write32(trans, HBUS_TARG_MEM_WDAT, vals[offs]); + iwl_release_nic_access(trans); } else result = -EBUSY; - spin_unlock_irqrestore(&bus->reg_lock, flags); + spin_unlock_irqrestore(&trans->reg_lock, flags); return result; } -int iwl_write_targ_mem(struct iwl_bus *bus, u32 addr, u32 val) +int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val) { - return _iwl_write_targ_mem_words(bus, addr, &val, 1); + return _iwl_write_targ_mem_words(trans, addr, &val, 1); } diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index b8e00cd7b1f7..782486fc2f8f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h @@ -31,68 +31,63 @@ #include "iwl-devtrace.h" #include "iwl-shared.h" -/* TODO: remove when not needed any more */ -#include "iwl-bus.h" #include "iwl-trans.h" -static inline void iwl_write8(struct iwl_bus *bus, u32 ofs, u8 val) +static inline void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val) { - /* TODO: get trans instead of bus */ - trace_iwlwifi_dev_iowrite8(priv(bus), ofs, val); - iwl_trans_write8(trans(bus), ofs, val); + trace_iwlwifi_dev_iowrite8(priv(trans), ofs, val); + iwl_trans_write8(trans, ofs, val); } -static inline void iwl_write32(struct iwl_bus *bus, u32 ofs, u32 val) +static inline void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val) { - /* TODO: get trans instead of bus */ - trace_iwlwifi_dev_iowrite32(priv(bus), ofs, val); - iwl_trans_write32(trans(bus), ofs, val); + trace_iwlwifi_dev_iowrite32(priv(trans), ofs, val); + iwl_trans_write32(trans, ofs, val); } -static inline u32 iwl_read32(struct iwl_bus *bus, u32 ofs) +static inline u32 iwl_read32(struct iwl_trans *trans, u32 ofs) { - /* TODO: get trans instead of bus */ - u32 val = iwl_trans_read32(trans(bus), ofs); - trace_iwlwifi_dev_ioread32(priv(bus), ofs, val); + u32 val = iwl_trans_read32(trans, ofs); + trace_iwlwifi_dev_ioread32(priv(trans), ofs, val); return val; } -void iwl_set_bit(struct iwl_bus *bus, u32 reg, u32 mask); -void iwl_clear_bit(struct iwl_bus *bus, u32 reg, u32 mask); +void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask); +void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask); -int iwl_poll_bit(struct iwl_bus *bus, u32 addr, +int iwl_poll_bit(struct iwl_trans *trans, u32 addr, u32 bits, u32 mask, int timeout); -int iwl_poll_direct_bit(struct iwl_bus *bus, u32 addr, u32 mask, +int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, int timeout); -int iwl_grab_nic_access_silent(struct iwl_bus *bus); -int iwl_grab_nic_access(struct iwl_bus *bus); -void iwl_release_nic_access(struct iwl_bus *bus); +int iwl_grab_nic_access_silent(struct iwl_trans *trans); +int iwl_grab_nic_access(struct iwl_trans *trans); +void iwl_release_nic_access(struct iwl_trans *trans); -u32 iwl_read_direct32(struct iwl_bus *bus, u32 reg); -void iwl_write_direct32(struct iwl_bus *bus, u32 reg, u32 value); +u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg); +void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value); -u32 iwl_read_prph(struct iwl_bus *bus, u32 reg); -void iwl_write_prph(struct iwl_bus *bus, u32 addr, u32 val); -void iwl_set_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask); -void iwl_set_bits_mask_prph(struct iwl_bus *bus, u32 reg, +u32 iwl_read_prph(struct iwl_trans *trans, u32 reg); +void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val); +void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask); +void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg, u32 bits, u32 mask); -void iwl_clear_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask); +void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask); -void _iwl_read_targ_mem_words(struct iwl_bus *bus, u32 addr, +void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr, void *buf, int words); -#define iwl_read_targ_mem_words(bus, addr, buf, bufsize) \ +#define iwl_read_targ_mem_words(trans, addr, buf, bufsize) \ do { \ BUILD_BUG_ON((bufsize) % sizeof(u32)); \ - _iwl_read_targ_mem_words(bus, addr, buf, \ + _iwl_read_targ_mem_words(trans, addr, buf, \ (bufsize) / sizeof(u32));\ } while (0) -int _iwl_write_targ_mem_words(struct iwl_bus *bus, u32 addr, +int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr, void *buf, int words); -u32 iwl_read_targ_mem(struct iwl_bus *bus, u32 addr); -int iwl_write_targ_mem(struct iwl_bus *bus, u32 addr, u32 val); +u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr); +int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val); #endif diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 8761438f1532..5c7741f07aa0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -71,7 +71,7 @@ static const struct ieee80211_tpt_blink iwl_blink[] = { /* Set led register off */ void iwlagn_led_enable(struct iwl_priv *priv) { - iwl_write32(bus(priv), CSR_LED_REG, CSR_LED_REG_TRUN_ON); + iwl_write32(trans(priv), CSR_LED_REG, CSR_LED_REG_TRUN_ON); } /* @@ -107,9 +107,10 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd) }; u32 reg; - reg = iwl_read32(bus(priv), CSR_LED_REG); + reg = iwl_read32(trans(priv), CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - iwl_write32(bus(priv), CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + iwl_write32(trans(priv), CSR_LED_REG, + reg & CSR_LED_BSM_CTRL_MSK); return iwl_trans_send_cmd(trans(priv), &cmd); } @@ -206,7 +207,7 @@ void iwl_leds_init(struct iwl_priv *priv) break; } - ret = led_classdev_register(bus(priv)->dev, &priv->led); + ret = led_classdev_register(trans(priv)->dev, &priv->led); if (ret) { kfree(priv->led.name); return; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 965d0475affd..b911837b04fa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -196,7 +196,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_IBSS_RSN; if (trans(priv)->ucode_wowlan.code.len && - device_can_wakeup(bus(priv)->dev)) { + device_can_wakeup(trans(priv)->dev)) { hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT | WIPHY_WOWLAN_EAP_IDENTITY_REQ | @@ -347,7 +347,7 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw) /* User space software may expect getting rfkill changes * even if interface is down */ - iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); + iwl_write32(trans(priv), CSR_INT, 0xFFFFFFFF); iwl_enable_rfkill_int(priv); IWL_DEBUG_MAC80211(priv, "leave\n"); @@ -405,10 +405,10 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, if (ret) goto error; - device_set_wakeup_enable(bus(priv)->dev, true); + device_set_wakeup_enable(trans(priv)->dev, true); /* Now let the ucode operate on its own */ - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); goto out; @@ -436,19 +436,19 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) IWL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->shrd->mutex); - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, + iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); 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)); + spin_lock_irqsave(&trans(priv)->reg_lock, flags); + ret = iwl_grab_nic_access_silent(trans(priv)); if (ret == 0) { - iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); - status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); - iwl_release_nic_access(bus(priv)); + iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, base); + status = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); + iwl_release_nic_access(trans(priv)); } - spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); + spin_unlock_irqrestore(&trans(priv)->reg_lock, flags); #ifdef CONFIG_IWLWIFI_DEBUGFS if (ret == 0) { @@ -460,7 +460,8 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) if (priv->wowlan_sram) _iwl_read_targ_mem_words( - bus(priv), 0x800000, priv->wowlan_sram, + trans(priv), 0x800000, + priv->wowlan_sram, trans->ucode_wowlan.data.len / 4); } #endif @@ -471,7 +472,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) priv->shrd->wowlan = false; - device_set_wakeup_enable(bus(priv)->dev, false); + device_set_wakeup_enable(trans(priv)->dev, false); iwlagn_prepare_restart(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index ab462337d7a7..7bab81928482 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -121,12 +121,12 @@ static void iwl_pci_apm_config(struct iwl_bus *bus) if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ - iwl_set_bit(bus, CSR_GIO_REG, + iwl_set_bit(trans(bus), CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); dev_printk(KERN_INFO, bus->dev, "L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ - iwl_clear_bit(bus, CSR_GIO_REG, + iwl_clear_bit(trans(bus), CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); dev_printk(KERN_INFO, bus->dev, "L1 Disabled; Enabling L0S\n"); } diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index a56a77b8f926..922d841faba2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -208,7 +208,7 @@ 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, + dma_free_coherent(trans(priv)->dev, priv->testmode_trace.total_size, priv->testmode_trace.cpu_addr, priv->testmode_trace.dma_addr); @@ -302,7 +302,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - val32 = iwl_read_direct32(bus(priv), ofs); + val32 = iwl_read_direct32(trans(priv), ofs); IWL_INFO(priv, "32bit value to read 0x%x\n", val32); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); @@ -324,7 +324,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) } else { val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); IWL_INFO(priv, "32bit value to write 0x%x\n", val32); - iwl_write_direct32(bus(priv), ofs, val32); + iwl_write_direct32(trans(priv), ofs, val32); } break; case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: @@ -334,11 +334,11 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) } 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); + iwl_write8(trans(priv), ofs, val8); } break; case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: - val32 = iwl_read_prph(bus(priv), ofs); + val32 = iwl_read_prph(trans(priv), ofs); IWL_INFO(priv, "32bit value to read 0x%x\n", val32); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); @@ -360,7 +360,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) } 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); + iwl_write_prph(trans(priv), ofs, val32); } break; default: @@ -615,7 +615,7 @@ 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; + struct device *dev = trans(priv)->dev; switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: @@ -814,7 +814,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) IWL_ERR(priv, "Error allocating memory\n"); return -ENOMEM; } - _iwl_read_targ_mem_words(bus(priv), ofs, + _iwl_read_targ_mem_words(trans(priv), ofs, priv->testmode_sram.buff_addr, priv->testmode_sram.buff_size / 4); priv->testmode_sram.num_chunks = diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 47d27bdf2dfd..555175ff4f9f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -317,12 +317,12 @@ static inline void iwl_disable_interrupts(struct iwl_trans *trans) clear_bit(STATUS_INT_ENABLED, &trans->shrd->status); /* disable interrupts from uCode/NIC to host */ - iwl_write32(bus(trans), CSR_INT_MASK, 0x00000000); + iwl_write32(trans, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - iwl_write32(bus(trans), CSR_INT, 0xffffffff); - iwl_write32(bus(trans), CSR_FH_INT_STATUS, 0xffffffff); + iwl_write32(trans, CSR_INT, 0xffffffff); + iwl_write32(trans, CSR_FH_INT_STATUS, 0xffffffff); IWL_DEBUG_ISR(trans, "Disabled interrupts\n"); } @@ -333,7 +333,7 @@ static inline void iwl_enable_interrupts(struct iwl_trans *trans) IWL_DEBUG_ISR(trans, "Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &trans->shrd->status); - iwl_write32(bus(trans), CSR_INT_MASK, trans_pcie->inta_mask); + iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask); } /* diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index b94c95370b7b..ebea2435dacd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -144,30 +144,30 @@ void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans, /* shadow register enabled */ /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - iwl_write32(bus(trans), FH_RSCSR_CHNL0_WPTR, q->write_actual); + iwl_write32(trans, FH_RSCSR_CHNL0_WPTR, q->write_actual); } else { /* If power-saving is in use, make sure device is awake */ if (test_bit(STATUS_POWER_PMI, &trans->shrd->status)) { - reg = iwl_read32(bus(trans), CSR_UCODE_DRV_GP1); + reg = iwl_read32(trans, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { IWL_DEBUG_INFO(trans, "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); - iwl_set_bit(bus(trans), CSR_GP_CNTRL, + iwl_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - iwl_write_direct32(bus(trans), FH_RSCSR_CHNL0_WPTR, + iwl_write_direct32(trans, FH_RSCSR_CHNL0_WPTR, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - iwl_write_direct32(bus(trans), FH_RSCSR_CHNL0_WPTR, + iwl_write_direct32(trans, FH_RSCSR_CHNL0_WPTR, q->write_actual); } } @@ -312,7 +312,7 @@ static void iwlagn_rx_allocate(struct iwl_trans *trans, gfp_t priority) BUG_ON(rxb->page); rxb->page = page; /* Get physical address of the RB */ - rxb->page_dma = dma_map_page(bus(trans)->dev, page, 0, + rxb->page_dma = dma_map_page(trans->dev, page, 0, PAGE_SIZE << hw_params(trans).rx_page_order, DMA_FROM_DEVICE); /* dma address must be no more than 36 bits */ @@ -418,7 +418,7 @@ static void iwl_rx_handle(struct iwl_trans *trans) rxq->queue[i] = NULL; - dma_unmap_page(bus(trans)->dev, rxb->page_dma, + dma_unmap_page(trans->dev, rxb->page_dma, PAGE_SIZE << hw_params(trans).rx_page_order, DMA_FROM_DEVICE); pkt = rxb_addr(rxb); @@ -489,7 +489,7 @@ static void iwl_rx_handle(struct iwl_trans *trans) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = dma_map_page(bus(trans)->dev, rxb->page, + rxb->page_dma = dma_map_page(trans->dev, rxb->page, 0, PAGE_SIZE << hw_params(trans).rx_page_order, DMA_FROM_DEVICE); @@ -616,7 +616,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) return; } - iwl_read_targ_mem_words(bus(priv), base, &table, sizeof(table)); + iwl_read_targ_mem_words(trans(priv), base, &table, sizeof(table)); if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) { IWL_ERR(trans, "Start IWL Error Log Dump:\n"); @@ -677,9 +677,9 @@ static void iwl_irq_handle_error(struct iwl_trans *trans) struct iwl_priv *priv = priv(trans); /* W/A for WiFi/WiMAX coex and WiMAX own the RF */ if (cfg(priv)->internal_wimax_coex && - (!(iwl_read_prph(bus(trans), APMG_CLK_CTRL_REG) & + (!(iwl_read_prph(trans, APMG_CLK_CTRL_REG) & APMS_CLK_VAL_MRB_FUNC_MODE) || - (iwl_read_prph(bus(trans), APMG_PS_CTRL_REG) & + (iwl_read_prph(trans, APMG_PS_CTRL_REG) & APMG_PS_CTRL_VAL_RESET_REQ))) { /* * Keep the restart process from trying to send host @@ -745,18 +745,18 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, ptr = base + EVENT_START_OFFSET + (start_idx * event_size); /* Make sure device is powered up for SRAM reads */ - spin_lock_irqsave(&bus(trans)->reg_lock, reg_flags); - iwl_grab_nic_access(bus(trans)); + spin_lock_irqsave(&trans->reg_lock, reg_flags); + iwl_grab_nic_access(trans); /* Set starting address; reads will auto-increment */ - iwl_write32(bus(trans), HBUS_TARG_MEM_RADDR, ptr); + iwl_write32(trans, HBUS_TARG_MEM_RADDR, ptr); rmb(); /* "time" is actually "data" for mode 0 (no timestamp). * place event id # at far right for easier visual parsing. */ for (i = 0; i < num_events; i++) { - ev = iwl_read32(bus(trans), HBUS_TARG_MEM_RDAT); - time = iwl_read32(bus(trans), HBUS_TARG_MEM_RDAT); + ev = iwl_read32(trans, HBUS_TARG_MEM_RDAT); + time = iwl_read32(trans, HBUS_TARG_MEM_RDAT); if (mode == 0) { /* data, ev */ if (bufsz) { @@ -770,7 +770,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, time, ev); } } else { - data = iwl_read32(bus(trans), HBUS_TARG_MEM_RDAT); + data = iwl_read32(trans, HBUS_TARG_MEM_RDAT); if (bufsz) { pos += scnprintf(*buf + pos, bufsz - pos, "EVT_LOGT:%010u:0x%08x:%04u\n", @@ -785,8 +785,8 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, } /* Allow device to power down */ - iwl_release_nic_access(bus(trans)); - spin_unlock_irqrestore(&bus(trans)->reg_lock, reg_flags); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, reg_flags); return pos; } @@ -863,10 +863,10 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, } /* event log header */ - capacity = iwl_read_targ_mem(bus(trans), base); - mode = iwl_read_targ_mem(bus(trans), base + (1 * sizeof(u32))); - num_wraps = iwl_read_targ_mem(bus(trans), base + (2 * sizeof(u32))); - next_entry = iwl_read_targ_mem(bus(trans), base + (3 * sizeof(u32))); + capacity = iwl_read_targ_mem(trans, base); + mode = iwl_read_targ_mem(trans, base + (1 * sizeof(u32))); + num_wraps = iwl_read_targ_mem(trans, base + (2 * sizeof(u32))); + next_entry = iwl_read_targ_mem(trans, base + (3 * sizeof(u32))); if (capacity > logsize) { IWL_ERR(trans, "Log capacity %d is bogus, limit to %d " @@ -962,7 +962,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) * hardware bugs here by ACKing all the possible interrupts so that * interrupt coalescing can still be achieved. */ - iwl_write32(bus(trans), CSR_INT, + iwl_write32(trans, CSR_INT, trans_pcie->inta | ~trans_pcie->inta_mask); inta = trans_pcie->inta; @@ -970,7 +970,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) #ifdef CONFIG_IWLWIFI_DEBUG if (iwl_get_debug_level(trans->shrd) & IWL_DL_ISR) { /* just for debug */ - inta_mask = iwl_read32(bus(trans), CSR_INT_MASK); + inta_mask = iwl_read32(trans, CSR_INT_MASK); IWL_DEBUG_ISR(trans, "inta 0x%08x, enabled 0x%08x\n ", inta, inta_mask); } @@ -1018,7 +1018,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(iwl_read32(bus(trans), CSR_GP_CNTRL) & + if (!(iwl_read32(trans, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; @@ -1082,12 +1082,12 @@ void iwl_irq_tasklet(struct iwl_trans *trans) IWL_DEBUG_ISR(trans, "Rx interrupt\n"); if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); - iwl_write32(bus(trans), CSR_FH_INT_STATUS, + iwl_write32(trans, CSR_FH_INT_STATUS, CSR_FH_INT_RX_MASK); } if (inta & CSR_INT_BIT_RX_PERIODIC) { handled |= CSR_INT_BIT_RX_PERIODIC; - iwl_write32(bus(trans), + iwl_write32(trans, CSR_INT, CSR_INT_BIT_RX_PERIODIC); } /* Sending RX interrupt require many steps to be done in the @@ -1102,7 +1102,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) */ /* Disable periodic interrupt; we use it as just a one-shot. */ - iwl_write8(bus(trans), CSR_INT_PERIODIC_REG, + iwl_write8(trans, CSR_INT_PERIODIC_REG, CSR_INT_PERIODIC_DIS); #ifdef CONFIG_IWLWIFI_IDI iwl_amfh_rx_handler(); @@ -1117,7 +1117,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) * to extend the periodic interrupt; one-shot is enough. */ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) - iwl_write8(bus(trans), CSR_INT_PERIODIC_REG, + iwl_write8(trans, CSR_INT_PERIODIC_REG, CSR_INT_PERIODIC_ENA); isr_stats->rx++; @@ -1125,7 +1125,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - iwl_write32(bus(trans), CSR_FH_INT_STATUS, CSR_FH_INT_TX_MASK); + iwl_write32(trans, CSR_FH_INT_STATUS, CSR_FH_INT_TX_MASK); IWL_DEBUG_ISR(trans, "uCode load interrupt\n"); isr_stats->tx++; handled |= CSR_INT_BIT_FH_TX; @@ -1175,7 +1175,7 @@ void iwl_free_isr_ict(struct iwl_trans *trans) IWL_TRANS_GET_PCIE_TRANS(trans); if (trans_pcie->ict_tbl) { - dma_free_coherent(bus(trans)->dev, ICT_SIZE, + dma_free_coherent(trans->dev, ICT_SIZE, trans_pcie->ict_tbl, trans_pcie->ict_tbl_dma); trans_pcie->ict_tbl = NULL; @@ -1195,7 +1195,7 @@ int iwl_alloc_isr_ict(struct iwl_trans *trans) IWL_TRANS_GET_PCIE_TRANS(trans); trans_pcie->ict_tbl = - dma_alloc_coherent(bus(trans)->dev, ICT_SIZE, + dma_alloc_coherent(trans->dev, ICT_SIZE, &trans_pcie->ict_tbl_dma, GFP_KERNEL); if (!trans_pcie->ict_tbl) @@ -1246,10 +1246,10 @@ void iwl_reset_ict(struct iwl_trans *trans) IWL_DEBUG_ISR(trans, "CSR_DRAM_INT_TBL_REG =0x%x\n", val); - iwl_write32(bus(trans), CSR_DRAM_INT_TBL_REG, val); + iwl_write32(trans, CSR_DRAM_INT_TBL_REG, val); trans_pcie->use_ict = true; trans_pcie->ict_index = 0; - iwl_write32(bus(trans), CSR_INT, trans_pcie->inta_mask); + iwl_write32(trans, CSR_INT, trans_pcie->inta_mask); iwl_enable_interrupts(trans); spin_unlock_irqrestore(&trans->shrd->lock, flags); } @@ -1289,11 +1289,11 @@ static irqreturn_t iwl_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(bus(trans), CSR_INT_MASK); /* just for debug */ - iwl_write32(bus(trans), CSR_INT_MASK, 0x00000000); + inta_mask = iwl_read32(trans, CSR_INT_MASK); /* just for debug */ + iwl_write32(trans, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = iwl_read32(bus(trans), CSR_INT); + inta = iwl_read32(trans, CSR_INT); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, @@ -1312,7 +1312,7 @@ static irqreturn_t iwl_isr(int irq, void *data) #ifdef CONFIG_IWLWIFI_DEBUG if (iwl_get_debug_level(trans->shrd) & (IWL_DL_ISR)) { - inta_fh = iwl_read32(bus(trans), CSR_FH_INT_STATUS); + inta_fh = iwl_read32(trans, CSR_FH_INT_STATUS); IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled 0x%08x, " "fh 0x%08x\n", inta, inta_mask, inta_fh); } @@ -1378,8 +1378,8 @@ irqreturn_t iwl_isr_ict(int irq, void *data) * 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(bus(trans), CSR_INT_MASK); /* just for debug */ - iwl_write32(bus(trans), CSR_INT_MASK, 0x00000000); + inta_mask = iwl_read32(trans, CSR_INT_MASK); /* just for debug */ + iwl_write32(trans, CSR_INT_MASK, 0x00000000); /* Ignore interrupt if there's nothing in NIC to service. diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 30814b55705e..5e095ac50769 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -100,7 +100,7 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, struct iwl_tx_queue *txq) if (hw_params(trans).shadow_reg_enable) { /* shadow register enabled */ - iwl_write32(bus(trans), HBUS_TARG_WRPTR, + iwl_write32(trans, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); } else { /* if we're trying to save power */ @@ -108,18 +108,18 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, 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(bus(trans), CSR_UCODE_DRV_GP1); + reg = iwl_read32(trans, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { IWL_DEBUG_INFO(trans, "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); - iwl_set_bit(bus(trans), CSR_GP_CNTRL, + iwl_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - iwl_write_direct32(bus(trans), HBUS_TARG_WRPTR, + iwl_write_direct32(trans, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* @@ -128,7 +128,7 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, struct iwl_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - iwl_write32(bus(trans), HBUS_TARG_WRPTR, + iwl_write32(trans, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); } txq->need_update = 0; @@ -190,14 +190,14 @@ static void iwlagn_unmap_tfd(struct iwl_trans *trans, struct iwl_cmd_meta *meta, /* Unmap tx_cmd */ if (num_tbs) - dma_unmap_single(bus(trans)->dev, + dma_unmap_single(trans->dev, dma_unmap_addr(meta, mapping), dma_unmap_len(meta, len), DMA_BIDIRECTIONAL); /* Unmap chunks, if any. */ for (i = 1; i < num_tbs; i++) - dma_unmap_single(bus(trans)->dev, iwl_tfd_tb_get_addr(tfd, i), + dma_unmap_single(trans->dev, iwl_tfd_tb_get_addr(tfd, i), iwl_tfd_tb_get_len(tfd, i), dma_dir); } @@ -383,14 +383,14 @@ static int iwlagn_tx_queue_set_q2ratid(struct iwl_trans *trans, u16 ra_tid, tbl_dw_addr = trans_pcie->scd_base_addr + SCD_TRANS_TBL_OFFSET_QUEUE(txq_id); - tbl_dw = iwl_read_targ_mem(bus(trans), tbl_dw_addr); + tbl_dw = iwl_read_targ_mem(trans, tbl_dw_addr); if (txq_id & 0x1) tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); else tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - iwl_write_targ_mem(bus(trans), tbl_dw_addr, tbl_dw); + iwl_write_targ_mem(trans, tbl_dw_addr, tbl_dw); return 0; } @@ -399,7 +399,7 @@ static void iwlagn_tx_queue_stop_scheduler(struct iwl_trans *trans, 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_write_prph(bus(trans), + iwl_write_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id), (0 << SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); @@ -409,9 +409,9 @@ void iwl_trans_set_wr_ptrs(struct iwl_trans *trans, int txq_id, u32 index) { IWL_DEBUG_TX_QUEUES(trans, "Q %d WrPtr: %d", txq_id, index & 0xff); - iwl_write_direct32(bus(trans), HBUS_TARG_WRPTR, + iwl_write_direct32(trans, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - iwl_write_prph(bus(trans), SCD_QUEUE_RDPTR(txq_id), index); + iwl_write_prph(trans, SCD_QUEUE_RDPTR(txq_id), index); } void iwl_trans_tx_queue_set_status(struct iwl_trans *trans, @@ -423,7 +423,7 @@ void iwl_trans_tx_queue_set_status(struct iwl_trans *trans, int active = test_bit(txq_id, &trans_pcie->txq_ctx_active_msk) ? 1 : 0; - iwl_write_prph(bus(trans), SCD_QUEUE_STATUS_BITS(txq_id), + iwl_write_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id), (active << SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << SCD_QUEUE_STTS_REG_POS_TXF) | (1 << SCD_QUEUE_STTS_REG_POS_WSL) | @@ -498,10 +498,10 @@ void iwl_trans_pcie_tx_agg_setup(struct iwl_trans *trans, iwlagn_tx_queue_set_q2ratid(trans, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - iwl_set_bits_prph(bus(trans), SCD_QUEUECHAIN_SEL, (1<scd_base_addr + + iwl_write_targ_mem(trans, trans_pcie->scd_base_addr + SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), ((frame_limit << @@ -520,7 +520,7 @@ void iwl_trans_pcie_tx_agg_setup(struct iwl_trans *trans, SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK)); - iwl_set_bits_prph(bus(trans), SCD_INTERRUPT_MASK, (1 << txq_id)); + iwl_set_bits_prph(trans, SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ iwl_trans_tx_queue_set_status(trans, &trans_pcie->txq[txq_id], @@ -584,7 +584,7 @@ int iwl_trans_pcie_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) iwlagn_tx_queue_stop_scheduler(trans, txq_id); - iwl_clear_bits_prph(bus(trans), SCD_AGGR_SEL, (1 << txq_id)); + iwl_clear_bits_prph(trans, SCD_AGGR_SEL, (1 << txq_id)); trans_pcie->agg_txq[sta_id][tid] = 0; trans_pcie->txq[txq_id].q.read_ptr = 0; @@ -592,7 +592,7 @@ int iwl_trans_pcie_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) /* supposes that ssn_idx is valid (!= 0xFFF) */ iwl_trans_set_wr_ptrs(trans, txq_id, 0); - iwl_clear_bits_prph(bus(trans), SCD_INTERRUPT_MASK, (1 << txq_id)); + iwl_clear_bits_prph(trans, SCD_INTERRUPT_MASK, (1 << txq_id)); iwl_txq_ctx_deactivate(trans_pcie, txq_id); iwl_trans_tx_queue_set_status(trans, &trans_pcie->txq[txq_id], 0, 0); return 0; @@ -725,9 +725,9 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) le16_to_cpu(out_cmd->hdr.sequence), cmd_size, q->write_ptr, idx, trans->shrd->cmd_queue); - phys_addr = dma_map_single(bus(trans)->dev, &out_cmd->hdr, copy_size, + phys_addr = dma_map_single(trans->dev, &out_cmd->hdr, copy_size, DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(bus(trans)->dev, phys_addr))) { + if (unlikely(dma_mapping_error(trans->dev, phys_addr))) { idx = -ENOMEM; goto out; } @@ -748,10 +748,10 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) continue; if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) continue; - phys_addr = dma_map_single(bus(trans)->dev, + phys_addr = dma_map_single(trans->dev, (void *)cmd->data[i], cmd->len[i], DMA_BIDIRECTIONAL); - if (dma_mapping_error(bus(trans)->dev, phys_addr)) { + if (dma_mapping_error(trans->dev, phys_addr)) { iwlagn_unmap_tfd(trans, out_meta, &txq->tfds[q->write_ptr], DMA_BIDIRECTIONAL); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 80f531844f3e..a1ee2e4b0ced 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -80,7 +80,7 @@ static int iwl_trans_rx_alloc(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_rx_queue *rxq = &trans_pcie->rxq; - struct device *dev = bus(trans)->dev; + struct device *dev = trans->dev; memset(&trans_pcie->rxq, 0, sizeof(trans_pcie->rxq)); @@ -124,7 +124,7 @@ static void iwl_trans_rxq_free_rx_bufs(struct iwl_trans *trans) /* 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) { - dma_unmap_page(bus(trans)->dev, rxq->pool[i].page_dma, + dma_unmap_page(trans->dev, rxq->pool[i].page_dma, PAGE_SIZE << hw_params(trans).rx_page_order, DMA_FROM_DEVICE); __free_pages(rxq->pool[i].page, @@ -148,17 +148,17 @@ static void iwl_trans_rx_hw_init(struct iwl_trans *trans, rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - iwl_write_direct32(bus(trans), FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - iwl_write_direct32(bus(trans), FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + iwl_write_direct32(trans, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - iwl_write_direct32(bus(trans), FH_RSCSR_CHNL0_RBDCB_BASE_REG, + iwl_write_direct32(trans, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - iwl_write_direct32(bus(trans), FH_RSCSR_CHNL0_STTS_WPTR_REG, + iwl_write_direct32(trans, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -169,7 +169,7 @@ static void iwl_trans_rx_hw_init(struct iwl_trans *trans, * RB timeout 0x10 * 256 RBDs */ - iwl_write_direct32(bus(trans), FH_MEM_RCSR_CHNL0_CONFIG_REG, + iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | @@ -179,7 +179,7 @@ static void iwl_trans_rx_hw_init(struct iwl_trans *trans, (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ - iwl_write8(bus(trans), CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); + iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); } static int iwl_rx_init(struct iwl_trans *trans) @@ -244,13 +244,13 @@ static void iwl_trans_pcie_rx_free(struct iwl_trans *trans) iwl_trans_rxq_free_rx_bufs(trans); spin_unlock_irqrestore(&rxq->lock, flags); - dma_free_coherent(bus(trans)->dev, sizeof(__le32) * RX_QUEUE_SIZE, + dma_free_coherent(trans->dev, sizeof(__le32) * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma)); rxq->bd = NULL; if (rxq->rb_stts) - dma_free_coherent(bus(trans)->dev, + dma_free_coherent(trans->dev, sizeof(struct iwl_rb_status), rxq->rb_stts, rxq->rb_stts_dma); else @@ -263,8 +263,8 @@ static int iwl_trans_rx_stop(struct iwl_trans *trans) { /* stop Rx DMA */ - iwl_write_direct32(bus(trans), FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - return iwl_poll_direct_bit(bus(trans), FH_MEM_RSSR_RX_STATUS_REG, + iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + return iwl_poll_direct_bit(trans, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); } @@ -274,7 +274,7 @@ static inline int iwlagn_alloc_dma_ptr(struct iwl_trans *trans, if (WARN_ON(ptr->addr)) return -EINVAL; - ptr->addr = dma_alloc_coherent(bus(trans)->dev, size, + ptr->addr = dma_alloc_coherent(trans->dev, size, &ptr->dma, GFP_KERNEL); if (!ptr->addr) return -ENOMEM; @@ -288,7 +288,7 @@ static inline void iwlagn_free_dma_ptr(struct iwl_trans *trans, if (unlikely(!ptr->addr)) return; - dma_free_coherent(bus(trans)->dev, ptr->size, ptr->addr, ptr->dma); + dma_free_coherent(trans->dev, ptr->size, ptr->addr, ptr->dma); memset(ptr, 0, sizeof(*ptr)); } @@ -335,7 +335,7 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans, /* Circular buffer of transmit frame descriptors (TFDs), * shared with device */ - txq->tfds = dma_alloc_coherent(bus(trans)->dev, tfd_sz, + txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { IWL_ERR(trans, "dma_alloc_coherent(%zd) failed\n", tfd_sz); @@ -391,7 +391,7 @@ static int iwl_trans_txq_init(struct iwl_trans *trans, struct iwl_tx_queue *txq, * Tell nic where to find circular buffer of Tx Frame Descriptors for * given Tx queue, and enable the DMA channel used for that queue. * Circular buffer (TFD queue in DRAM) physical base address */ - iwl_write_direct32(bus(trans), FH_MEM_CBBC_QUEUE(txq_id), + iwl_write_direct32(trans, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -445,7 +445,7 @@ static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id]; - struct device *dev = bus(trans)->dev; + struct device *dev = trans->dev; int i; if (WARN_ON(!txq)) return; @@ -586,10 +586,10 @@ static int iwl_tx_init(struct iwl_trans *trans) spin_lock_irqsave(&trans->shrd->lock, flags); /* Turn off all Tx DMA fifos */ - iwl_write_prph(bus(trans), SCD_TXFACT, 0); + iwl_write_prph(trans, SCD_TXFACT, 0); /* Tell NIC where to find the "keep warm" buffer */ - iwl_write_direct32(bus(trans), FH_KW_MEM_ADDR_REG, + iwl_write_direct32(trans, FH_KW_MEM_ADDR_REG, trans_pcie->kw.dma >> 4); spin_unlock_irqrestore(&trans->shrd->lock, flags); @@ -621,12 +621,12 @@ static void iwl_set_pwr_vmain(struct iwl_trans *trans) * to set power to V_AUX, do: if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) - iwl_set_bits_mask_prph(bus(trans), APMG_PS_CTRL_REG, + iwl_set_bits_mask_prph(trans, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); */ - iwl_set_bits_mask_prph(bus(trans), APMG_PS_CTRL_REG, + iwl_set_bits_mask_prph(trans, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); } @@ -640,7 +640,7 @@ static int iwl_nic_init(struct iwl_trans *trans) iwl_apm_init(priv(trans)); /* Set interrupt coalescing calibration timer to default (512 usecs) */ - iwl_write8(bus(trans), CSR_INT_COALESCING, + iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); spin_unlock_irqrestore(&trans->shrd->lock, flags); @@ -660,7 +660,7 @@ static int iwl_nic_init(struct iwl_trans *trans) if (hw_params(trans).shadow_reg_enable) { /* enable shadow regs in HW */ - iwl_set_bit(bus(trans), CSR_MAC_SHADOW_REG_CTRL, + iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL, 0x800FFFFF); } @@ -676,11 +676,11 @@ static int iwl_set_hw_ready(struct iwl_trans *trans) { int ret; - iwl_set_bit(bus(trans), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = iwl_poll_bit(bus(trans), CSR_HW_IF_CONFIG_REG, + ret = iwl_poll_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); @@ -701,10 +701,10 @@ static int iwl_trans_pcie_prepare_card_hw(struct iwl_trans *trans) return 0; /* If HW is not ready, prepare the conditions to check again */ - iwl_set_bit(bus(trans), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = iwl_poll_bit(bus(trans), CSR_HW_IF_CONFIG_REG, + ret = iwl_poll_bit(trans, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); @@ -794,7 +794,7 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(bus(trans), CSR_GP_CNTRL) & + if (iwl_read32(trans, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); else @@ -806,7 +806,7 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans) return -ERFKILL; } - iwl_write32(bus(trans), CSR_INT, 0xFFFFFFFF); + iwl_write32(trans, CSR_INT, 0xFFFFFFFF); ret = iwl_nic_init(trans); if (ret) { @@ -815,17 +815,17 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans) } /* make sure rfkill handshake bits are cleared */ - iwl_write32(bus(trans), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(bus(trans), CSR_UCODE_DRV_GP1_CLR, + iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - iwl_write32(bus(trans), CSR_INT, 0xFFFFFFFF); + iwl_write32(trans, CSR_INT, 0xFFFFFFFF); iwl_enable_interrupts(trans); /* really make sure rfkill handshake bits are cleared */ - iwl_write32(bus(trans), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(bus(trans), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); return 0; } @@ -836,7 +836,7 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans) */ static void iwl_trans_txq_set_sched(struct iwl_trans *trans, u32 mask) { - iwl_write_prph(bus(trans), SCD_TXFACT, mask); + iwl_write_prph(trans, SCD_TXFACT, mask); } static void iwl_tx_start(struct iwl_trans *trans) @@ -852,46 +852,46 @@ static void iwl_tx_start(struct iwl_trans *trans) spin_lock_irqsave(&trans->shrd->lock, flags); trans_pcie->scd_base_addr = - iwl_read_prph(bus(trans), SCD_SRAM_BASE_ADDR); + iwl_read_prph(trans, SCD_SRAM_BASE_ADDR); a = trans_pcie->scd_base_addr + SCD_CONTEXT_MEM_LOWER_BOUND; /* reset conext data memory */ for (; a < trans_pcie->scd_base_addr + SCD_CONTEXT_MEM_UPPER_BOUND; a += 4) - iwl_write_targ_mem(bus(trans), a, 0); + iwl_write_targ_mem(trans, a, 0); /* reset tx status memory */ for (; a < trans_pcie->scd_base_addr + SCD_TX_STTS_MEM_UPPER_BOUND; a += 4) - iwl_write_targ_mem(bus(trans), a, 0); + iwl_write_targ_mem(trans, a, 0); for (; a < trans_pcie->scd_base_addr + SCD_TRANS_TBL_OFFSET_QUEUE(hw_params(trans).max_txq_num); a += 4) - iwl_write_targ_mem(bus(trans), a, 0); + iwl_write_targ_mem(trans, a, 0); - iwl_write_prph(bus(trans), SCD_DRAM_BASE_ADDR, + iwl_write_prph(trans, SCD_DRAM_BASE_ADDR, trans_pcie->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++) - iwl_write_direct32(bus(trans), FH_TCSR_CHNL_TX_CONFIG_REG(chan), + iwl_write_direct32(trans, 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_read_direct32(bus(trans), FH_TX_CHICKEN_BITS_REG); - iwl_write_direct32(bus(trans), FH_TX_CHICKEN_BITS_REG, + reg_val = iwl_read_direct32(trans, FH_TX_CHICKEN_BITS_REG); + iwl_write_direct32(trans, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); - iwl_write_prph(bus(trans), SCD_QUEUECHAIN_SEL, + iwl_write_prph(trans, SCD_QUEUECHAIN_SEL, SCD_QUEUECHAIN_SEL_ALL(trans)); - iwl_write_prph(bus(trans), SCD_AGGR_SEL, 0); + iwl_write_prph(trans, SCD_AGGR_SEL, 0); /* initiate the queues */ for (i = 0; i < hw_params(trans).max_txq_num; i++) { - iwl_write_prph(bus(trans), SCD_QUEUE_RDPTR(i), 0); - iwl_write_direct32(bus(trans), HBUS_TARG_WRPTR, 0 | (i << 8)); - iwl_write_targ_mem(bus(trans), trans_pcie->scd_base_addr + + iwl_write_prph(trans, SCD_QUEUE_RDPTR(i), 0); + iwl_write_direct32(trans, HBUS_TARG_WRPTR, 0 | (i << 8)); + iwl_write_targ_mem(trans, trans_pcie->scd_base_addr + SCD_CONTEXT_QUEUE_OFFSET(i), 0); - iwl_write_targ_mem(bus(trans), trans_pcie->scd_base_addr + + iwl_write_targ_mem(trans, trans_pcie->scd_base_addr + SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), ((SCD_WIN_SIZE << @@ -902,7 +902,7 @@ static void iwl_tx_start(struct iwl_trans *trans) SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK)); } - iwl_write_prph(bus(trans), SCD_INTERRUPT_MASK, + iwl_write_prph(trans, SCD_INTERRUPT_MASK, IWL_MASK(0, hw_params(trans).max_txq_num)); /* Activate all Tx DMA/FIFO channels */ @@ -948,7 +948,7 @@ static void iwl_tx_start(struct iwl_trans *trans) spin_unlock_irqrestore(&trans->shrd->lock, flags); /* Enable L1-Active */ - iwl_clear_bits_prph(bus(trans), APMG_PCIDEV_STT_REG, + iwl_clear_bits_prph(trans, APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); } @@ -974,14 +974,14 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) { - iwl_write_direct32(bus(trans), + iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (iwl_poll_direct_bit(bus(trans), FH_TSSR_TX_STATUS_REG, + if (iwl_poll_direct_bit(trans, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IWL_ERR(trans, "Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - iwl_read_direct32(bus(trans), + iwl_read_direct32(trans, FH_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&trans->shrd->lock, flags); @@ -1024,13 +1024,13 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) iwl_trans_rx_stop(trans); #endif /* Power-down device's busmaster DMA clocks */ - iwl_write_prph(bus(trans), APMG_CLK_DIS_REG, + iwl_write_prph(trans, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); } /* Make sure (redundant) we've released our request to stay awake */ - iwl_clear_bit(bus(trans), CSR_GP_CNTRL, + iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ @@ -1048,7 +1048,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) 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); + iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); } static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, @@ -1145,10 +1145,10 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = dma_map_single(bus(trans)->dev, + txcmd_phys = dma_map_single(trans->dev, &dev_cmd->hdr, firstlen, DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(bus(trans)->dev, txcmd_phys))) + if (unlikely(dma_mapping_error(trans->dev, txcmd_phys))) return -1; dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); @@ -1164,10 +1164,10 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, * if any (802.11 null frames have no payload). */ secondlen = skb->len - hdr_len; if (secondlen > 0) { - phys_addr = dma_map_single(bus(trans)->dev, skb->data + hdr_len, + phys_addr = dma_map_single(trans->dev, skb->data + hdr_len, secondlen, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(bus(trans)->dev, phys_addr))) { - dma_unmap_single(bus(trans)->dev, + if (unlikely(dma_mapping_error(trans->dev, phys_addr))) { + dma_unmap_single(trans->dev, dma_unmap_addr(out_meta, mapping), dma_unmap_len(out_meta, len), DMA_BIDIRECTIONAL); @@ -1185,7 +1185,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, offsetof(struct iwl_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ - dma_sync_single_for_cpu(bus(trans)->dev, txcmd_phys, firstlen, + dma_sync_single_for_cpu(trans->dev, txcmd_phys, firstlen, DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys); @@ -1199,7 +1199,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, /* Set up entry for this TFD in Tx byte-count array */ iwl_trans_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len)); - dma_sync_single_for_device(bus(trans)->dev, txcmd_phys, firstlen, + dma_sync_single_for_device(trans->dev, txcmd_phys, firstlen, DMA_BIDIRECTIONAL); trace_iwlwifi_dev_tx(priv(trans), @@ -1232,7 +1232,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, static void iwl_trans_pcie_kick_nic(struct iwl_trans *trans) { /* Remove all resets to allow NIC to operate */ - iwl_write32(bus(trans), CSR_RESET, 0); + iwl_write32(trans, CSR_RESET, 0); } static int iwl_trans_pcie_request_irq(struct iwl_trans *trans) @@ -1355,7 +1355,7 @@ static int iwl_trans_pcie_suspend(struct iwl_trans *trans) iwl_apm_stop(priv(trans)); } else { iwl_disable_interrupts(trans); - iwl_clear_bit(bus(trans), CSR_GP_CNTRL, + iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } @@ -1368,7 +1368,7 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans) iwl_enable_interrupts(trans); - if (!(iwl_read32(bus(trans), CSR_GP_CNTRL) & + if (!(iwl_read32(trans, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; @@ -1464,9 +1464,9 @@ static int iwl_trans_pcie_check_stuck_queue(struct iwl_trans *trans, int cnt) 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)) + iwl_read_prph(trans, SCD_QUEUE_RDPTR(cnt)) & (TFD_QUEUE_SIZE_MAX - 1), - iwl_read_prph(bus(trans), SCD_QUEUE_WRPTR(cnt))); + iwl_read_prph(trans, SCD_QUEUE_WRPTR(cnt))); return 1; } @@ -1520,7 +1520,7 @@ int iwl_dump_fh(struct iwl_trans *trans, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", get_fh_string(fh_tbl[i]), - iwl_read_direct32(bus(trans), fh_tbl[i])); + iwl_read_direct32(trans, fh_tbl[i])); } return pos; } @@ -1529,7 +1529,7 @@ int iwl_dump_fh(struct iwl_trans *trans, char **buf, bool display) for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { IWL_ERR(trans, " %34s: 0X%08x\n", get_fh_string(fh_tbl[i]), - iwl_read_direct32(bus(trans), fh_tbl[i])); + iwl_read_direct32(trans, fh_tbl[i])); } return 0; } @@ -1599,7 +1599,7 @@ void iwl_dump_csr(struct iwl_trans *trans) for (i = 0; i < ARRAY_SIZE(csr_tbl); i++) { IWL_ERR(trans, " %25s: 0X%08x\n", get_csr_string(csr_tbl[i]), - iwl_read32(bus(trans), csr_tbl[i])); + iwl_read32(trans, csr_tbl[i])); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 0a3727dac6ac..dec935a84a7f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -234,6 +234,7 @@ struct iwl_calib_result { * @ops - pointer to iwl_trans_ops * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @hcmd_lock: protects HCMD + * @reg_lock - protect hw register access * @dev - pointer to struct device * that represents the device * @irq - the irq number for the device * @ucode_write_complete: indicates that the ucode has been copied. @@ -247,6 +248,7 @@ struct iwl_trans { const struct iwl_trans_ops *ops; struct iwl_shared *shrd; spinlock_t hcmd_lock; + spinlock_t reg_lock; struct device *dev; unsigned int irq; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0d7f207ac611..5de8b5beb091 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -126,42 +126,41 @@ int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, 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); dma_addr_t phy_addr = image->p_addr; u32 byte_cnt = image->len; int ret; trans->ucode_write_complete = 0; - iwl_write_direct32(bus, + iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); - iwl_write_direct32(bus, + iwl_write_direct32(trans, FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); - iwl_write_direct32(bus, + iwl_write_direct32(trans, FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); - iwl_write_direct32(bus, + iwl_write_direct32(trans, 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, + iwl_write_direct32(trans, 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, + iwl_write_direct32(trans, 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); + IWL_DEBUG_FW(trans, "%s uCode section being loaded...\n", name); ret = wait_event_timeout(trans->shrd->wait_command_queue, trans->ucode_write_complete, 5 * HZ); if (!ret) { @@ -470,7 +469,7 @@ static int iwl_alive_notify(struct iwl_trans *trans) * 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, +static int iwl_verify_inst_sparse(struct iwl_trans *trans, struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; @@ -478,15 +477,15 @@ static int iwl_verify_inst_sparse(struct iwl_bus *bus, u32 val; u32 i; - IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(trans, "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, + iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR, i + IWLAGN_RTC_INST_LOWER_BOUND); - val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); + val = iwl_read32(trans, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) return -EIO; } @@ -494,7 +493,7 @@ static int iwl_verify_inst_sparse(struct iwl_bus *bus, return 0; } -static void iwl_print_mismatch_inst(struct iwl_bus *bus, +static void iwl_print_mismatch_inst(struct iwl_trans *trans, struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; @@ -503,18 +502,18 @@ static void iwl_print_mismatch_inst(struct iwl_bus *bus, u32 offs; int errors = 0; - IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(trans, "ucode inst image size is %u\n", len); - iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, + iwl_write_direct32(trans, 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); + val = iwl_read32(trans, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(bus, "uCode INST section at " + IWL_ERR(trans, "uCode INST section at " "offset 0x%x, is 0x%x, s/b 0x%x\n", offs, val, le32_to_cpu(*image)); errors++; @@ -536,14 +535,14 @@ static int iwl_verify_ucode(struct iwl_trans *trans, return -EINVAL; } - if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { + if (!iwl_verify_inst_sparse(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); + iwl_print_mismatch_inst(trans, &img->code); return -EIO; } -- GitLab From ea4caade104490de0fadb64660f9e228c050fb3d Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 4 Jan 2012 14:23:20 +0200 Subject: [PATCH 0314/1846] iwlwifi: remove the pointer to dev from the bus layer Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-bus.h | 2 -- drivers/net/wireless/iwlwifi/iwl-debug.h | 16 ++++++++-------- drivers/net/wireless/iwlwifi/iwl-pci.c | 7 ++++--- drivers/net/wireless/iwlwifi/iwl-ucode.c | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index f79791500a9c..d890b6481b8c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1146,7 +1146,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) iwl_dealloc_ucode(trans(priv)); out_unbind: complete(&priv->firmware_loading_complete); - device_release_driver(bus(priv)->dev); + device_release_driver(trans(priv)->dev); release_firmware(ucode_raw); } @@ -1785,7 +1785,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /* At this point both hw and priv are allocated. */ - SET_IEEE80211_DEV(hw, bus(priv)->dev); + SET_IEEE80211_DEV(hw, trans(priv)->dev); /* what debugging capabilities we have */ iwl_debug_config(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index ce1a9cc106eb..2065c5b74162 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -137,14 +137,12 @@ struct iwl_bus_ops { * * This data is common to all bus layer implementations. * - * @dev - pointer to struct device * that represents the device * @ops - pointer to iwl_bus_ops * @shrd - pointer to iwl_shared which holds shared data from the upper layer * NB: for the time being this needs to be set by the upper layer since * it allocates the shared data */ struct iwl_bus { - struct device *dev; const struct iwl_bus_ops *ops; struct iwl_shared *shrd; diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 6f7612781e03..351b41d7f4fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -35,10 +35,10 @@ struct iwl_priv; /*No matter what is m (priv, bus, trans), this will work */ -#define IWL_ERR(m, f, a...) dev_err(bus(m)->dev, f, ## a) -#define IWL_WARN(m, f, a...) dev_warn(bus(m)->dev, f, ## a) -#define IWL_INFO(m, f, a...) dev_info(bus(m)->dev, f, ## a) -#define IWL_CRIT(m, f, a...) dev_crit(bus(m)->dev, f, ## a) +#define IWL_ERR(m, f, a...) dev_err(trans(m)->dev, f, ## a) +#define IWL_WARN(m, f, a...) dev_warn(trans(m)->dev, f, ## a) +#define IWL_INFO(m, f, a...) dev_info(trans(m)->dev, f, ## a) +#define IWL_CRIT(m, f, a...) dev_crit(trans(m)->dev, f, ## a) #define iwl_print_hex_error(m, p, len) \ do { \ @@ -50,7 +50,7 @@ do { \ #define IWL_DEBUG(m, level, fmt, ...) \ do { \ if (iwl_get_debug_level((m)->shrd) & (level)) \ - dev_err(bus(m)->dev, "%c %s " fmt, \ + dev_err(trans(m)->dev, "%c %s " fmt, \ in_interrupt() ? 'I' : 'U', __func__, \ ##__VA_ARGS__); \ } while (0) @@ -59,7 +59,7 @@ do { \ do { \ if (iwl_get_debug_level((m)->shrd) & (level) && \ net_ratelimit()) \ - dev_err(bus(m)->dev, "%c %s " fmt, \ + dev_err(trans(m)->dev, "%c %s " fmt, \ in_interrupt() ? 'I' : 'U', __func__, \ ##__VA_ARGS__); \ } while (0) @@ -74,12 +74,12 @@ do { \ #define IWL_DEBUG_QUIET_RFKILL(p, fmt, ...) \ do { \ if (!iwl_is_rfkill(p->shrd)) \ - dev_err(bus(p)->dev, "%s%c %s " fmt, \ + dev_err(trans(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, \ + dev_err(trans(p)->dev, "%s%c %s " fmt, \ "(RFKILL) ", \ in_interrupt() ? 'I' : 'U', __func__, \ ##__VA_ARGS__); \ diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 7bab81928482..6451739aed2e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -123,12 +123,14 @@ static void iwl_pci_apm_config(struct iwl_bus *bus) /* L1-ASPM enabled; disable(!) L0S */ iwl_set_bit(trans(bus), CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - dev_printk(KERN_INFO, bus->dev, "L1 Enabled; Disabling L0S\n"); + dev_printk(KERN_INFO, trans(bus)->dev, + "L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ iwl_clear_bit(trans(bus), CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - dev_printk(KERN_INFO, bus->dev, "L1 Disabled; Enabling L0S\n"); + dev_printk(KERN_INFO, trans(bus)->dev, + "L1 Disabled; Enabling L0S\n"); } } @@ -368,7 +370,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, bus); - bus->dev = &pdev->dev; bus->ops = &bus_ops_pci; #ifdef CONFIG_IWLWIFI_IDI diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 5de8b5beb091..08483d785e2c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -83,7 +83,7 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { 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, + dma_free_coherent(trans(bus)->dev, desc->len, desc->v_addr, desc->p_addr); desc->v_addr = NULL; desc->len = 0; @@ -110,7 +110,7 @@ int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, return -EINVAL; } - desc->v_addr = dma_alloc_coherent(bus->dev, len, + desc->v_addr = dma_alloc_coherent(trans(bus)->dev, len, &desc->p_addr, GFP_KERNEL); if (!desc->v_addr) return -ENOMEM; -- GitLab From 8467ab4f42396a3714b59ca187f470542970ff9d Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 3 Jan 2012 16:28:12 +0200 Subject: [PATCH 0315/1846] iwlwifi: don't use the bus for ucode fw_desc any more This is transport related Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 14 ++++++++------ drivers/net/wireless/iwlwifi/iwl-trans.h | 2 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index d890b6481b8c..8b1839aec405 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1023,31 +1023,33 @@ static void iwl_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 */ - if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.code, + if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.data, + if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.code, + if (iwl_alloc_fw_desc(trans(priv), + &trans(priv)->ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.data, + if (iwl_alloc_fw_desc(trans(priv), + &trans(priv)->ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; } /* WoWLAN instructions and data */ if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(bus(priv), + if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_wowlan.code, pieces.wowlan_inst, pieces.wowlan_inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(bus(priv), + if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_wowlan.data, pieces.wowlan_data, pieces.wowlan_data_size)) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index dec935a84a7f..d51959984174 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -408,7 +408,7 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) /***************************************************** * Utils functions ******************************************************/ -int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, +int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, const void *data, size_t len); void iwl_dealloc_ucode(struct iwl_trans *trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 08483d785e2c..793524a3ed70 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -80,29 +80,29 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { * ******************************************************************************/ -static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) +static void iwl_free_fw_desc(struct iwl_trans *trans, struct fw_desc *desc) { if (desc->v_addr) - dma_free_coherent(trans(bus)->dev, desc->len, + dma_free_coherent(trans->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) +static void iwl_free_fw_img(struct iwl_trans *trans, struct fw_img *img) { - iwl_free_fw_desc(bus, &img->code); - iwl_free_fw_desc(bus, &img->data); + iwl_free_fw_desc(trans, &img->code); + iwl_free_fw_desc(trans, &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); + iwl_free_fw_img(trans, &trans->ucode_rt); + iwl_free_fw_img(trans, &trans->ucode_init); + iwl_free_fw_img(trans, &trans->ucode_wowlan); } -int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, +int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, const void *data, size_t len) { if (!len) { @@ -110,7 +110,7 @@ int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, return -EINVAL; } - desc->v_addr = dma_alloc_coherent(trans(bus)->dev, len, + desc->v_addr = dma_alloc_coherent(trans->dev, len, &desc->p_addr, GFP_KERNEL); if (!desc->v_addr) return -ENOMEM; -- GitLab From 57a1dc89097982874f50a0e6f68ab08f62e9e5aa Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 13:22:16 +0200 Subject: [PATCH 0316/1846] iwlwifi: rename trans_ops->request_irq to trans_ops->start_hw This handler will become thicker, reflect its real role now. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 36 +++++++++++-------- drivers/net/wireless/iwlwifi/iwl-trans.h | 8 ++--- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8b1839aec405..1c00691c9f0f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1829,7 +1829,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, IWL_INFO(priv, "Detected %s, REV=0x%X\n", cfg(priv)->name, hw_rev); - err = iwl_trans_request_irq(trans(priv)); + err = iwl_trans_start_hw(trans(priv)); if (err) goto out_free_traffic_mem; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 555175ff4f9f..561865f29d56 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -201,6 +201,7 @@ struct iwl_tx_queue { * @rxq: all the RX queue data * @rx_replenish: work that will be called when buffers need to be allocated * @trans: pointer to the generic transport area + * @irq_requested: true when the irq has been requested * @scd_base_addr: scheduler sram base address in SRAM * @scd_bc_tbls: pointer to the byte count table of the scheduler * @kw: keep warm address @@ -225,6 +226,7 @@ struct iwl_trans_pcie { int ict_index; u32 inta; bool use_ict; + bool irq_requested; struct tasklet_struct irq_tasklet; struct isr_statistics isr_stats; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index a1ee2e4b0ced..ffbafb9e447b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1235,7 +1235,7 @@ static void iwl_trans_pcie_kick_nic(struct iwl_trans *trans) iwl_write32(trans, CSR_RESET, 0); } -static int iwl_trans_pcie_request_irq(struct iwl_trans *trans) +static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); @@ -1243,20 +1243,26 @@ static int iwl_trans_pcie_request_irq(struct iwl_trans *trans) trans_pcie->inta_mask = CSR_INI_SET_MASK; - tasklet_init(&trans_pcie->irq_tasklet, (void (*)(unsigned long)) - iwl_irq_tasklet, (unsigned long)trans); + if (!trans_pcie->irq_requested) { + tasklet_init(&trans_pcie->irq_tasklet, (void (*)(unsigned long)) + iwl_irq_tasklet, (unsigned long)trans); - iwl_alloc_isr_ict(trans); + iwl_alloc_isr_ict(trans); - err = request_irq(trans->irq, iwl_isr_ict, IRQF_SHARED, - DRV_NAME, trans); - if (err) { - IWL_ERR(trans, "Error allocating IRQ %d\n", trans->irq); - iwl_free_isr_ict(trans); - return err; + err = request_irq(trans->irq, iwl_isr_ict, IRQF_SHARED, + DRV_NAME, trans); + if (err) { + IWL_ERR(trans, "Error allocating IRQ %d\n", + trans->irq); + iwl_free_isr_ict(trans); + tasklet_kill(&trans_pcie->irq_tasklet); + return err; + } + + INIT_WORK(&trans_pcie->rx_replenish, iwl_bg_rx_replenish); + trans_pcie->irq_requested = true; } - INIT_WORK(&trans_pcie->rx_replenish, iwl_bg_rx_replenish); return 0; } @@ -1325,8 +1331,10 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans) #ifndef CONFIG_IWLWIFI_IDI iwl_trans_pcie_rx_free(trans); #endif - free_irq(trans->irq, trans); - iwl_free_isr_ict(trans); + if (trans_pcie->irq_requested == true) { + free_irq(trans->irq, trans); + iwl_free_isr_ict(trans); + } pci_disable_msi(trans_pcie->pci_dev); pci_iounmap(trans_pcie->pci_dev, trans_pcie->hw_base); @@ -1920,7 +1928,7 @@ static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans, #endif /*CONFIG_IWLWIFI_DEBUGFS */ const struct iwl_trans_ops trans_ops_pcie = { - .request_irq = iwl_trans_pcie_request_irq, + .start_hw = iwl_trans_pcie_start_hw, .fw_alive = iwl_trans_pcie_fw_alive, .start_device = iwl_trans_pcie_start_device, .prepare_card_hw = iwl_trans_pcie_prepare_card_hw, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index d51959984174..ddc3a0627dd3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -133,7 +133,7 @@ struct iwl_host_cmd { /** * struct iwl_trans_ops - transport specific operations - * @request_irq: requests IRQ - will be called before the FW load in probe flow + * @start_hw: starts the HW- from that point on, the HW can send interrupts * @start_device: allocates and inits all the resources for the transport * layer. * @prepare_card_hw: claim the ownership on the HW. Will be called during @@ -164,7 +164,7 @@ struct iwl_host_cmd { */ struct iwl_trans_ops { - int (*request_irq)(struct iwl_trans *iwl_trans); + int (*start_hw)(struct iwl_trans *iwl_trans); int (*start_device)(struct iwl_trans *trans); void (*fw_alive)(struct iwl_trans *trans); int (*prepare_card_hw)(struct iwl_trans *trans); @@ -269,9 +269,9 @@ struct iwl_trans { char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); }; -static inline int iwl_trans_request_irq(struct iwl_trans *trans) +static inline int iwl_trans_start_hw(struct iwl_trans *trans) { - return trans->ops->request_irq(trans); + return trans->ops->start_hw(trans); } static inline void iwl_trans_fw_alive(struct iwl_trans *trans) -- GitLab From ebb7678d00b2fa0d7db76b5303a5bf46a5aed8f3 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 13:24:57 +0200 Subject: [PATCH 0317/1846] iwlwifi: move prepare_card_hw to start_hw Kill the trans_ops->prepare_card_hw which is now useless. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 6 ----- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 22 +++++++++++++------ drivers/net/wireless/iwlwifi/iwl-trans.h | 8 ------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 1c00691c9f0f..5ab7f681991e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1833,12 +1833,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, if (err) goto out_free_traffic_mem; - if (iwl_trans_prepare_card_hw(trans(priv))) { - err = -EIO; - IWL_WARN(priv, "Failed, HW not ready\n"); - goto out_free_traffic_mem; - } - /***************** * 4. Read EEPROM *****************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ffbafb9e447b..d1ab57a7988f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -690,13 +690,14 @@ static int iwl_set_hw_ready(struct iwl_trans *trans) } /* Note: returns standard 0/-ERROR code */ -static int iwl_trans_pcie_prepare_card_hw(struct iwl_trans *trans) +static int iwl_prepare_card_hw(struct iwl_trans *trans) { int ret; IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n"); ret = iwl_set_hw_ready(trans); + /* If the card is ready, exit 0 */ if (ret >= 0) return 0; @@ -788,7 +789,7 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans) trans_pcie->mcast_queue[IWL_RXON_CTX_PAN] = IWL_IPAN_MCAST_QUEUE; if ((hw_params(trans).sku & EEPROM_SKU_CAP_AMT_ENABLE) && - iwl_trans_pcie_prepare_card_hw(trans)) { + iwl_prepare_card_hw(trans)) { IWL_WARN(trans, "Exit HW not ready\n"); return -EIO; } @@ -1254,16 +1255,24 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) if (err) { IWL_ERR(trans, "Error allocating IRQ %d\n", trans->irq); - iwl_free_isr_ict(trans); - tasklet_kill(&trans_pcie->irq_tasklet); - return err; + goto error; } INIT_WORK(&trans_pcie->rx_replenish, iwl_bg_rx_replenish); trans_pcie->irq_requested = true; } - return 0; + err = iwl_prepare_card_hw(trans); + if (err) { + IWL_ERR(trans, "Error while preparing HW: %d", err); + goto error; + } + return err; + +error: + iwl_free_isr_ict(trans); + tasklet_kill(&trans_pcie->irq_tasklet); + return err; } static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, @@ -1931,7 +1940,6 @@ const struct iwl_trans_ops trans_ops_pcie = { .start_hw = iwl_trans_pcie_start_hw, .fw_alive = iwl_trans_pcie_fw_alive, .start_device = iwl_trans_pcie_start_device, - .prepare_card_hw = iwl_trans_pcie_prepare_card_hw, .stop_device = iwl_trans_pcie_stop_device, .wake_any_queue = iwl_trans_pcie_wake_any_queue, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index ddc3a0627dd3..55b5dc3b5dd6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -136,8 +136,6 @@ struct iwl_host_cmd { * @start_hw: starts the HW- from that point on, the HW can send interrupts * @start_device: allocates and inits all the resources for the transport * layer. - * @prepare_card_hw: claim the ownership on the HW. Will be called during - * probe. * @fw_alive: called when the fw sends alive notification * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_* * @stop_device:stops the whole device (embedded CPU put to reset) @@ -167,7 +165,6 @@ struct iwl_trans_ops { int (*start_hw)(struct iwl_trans *iwl_trans); int (*start_device)(struct iwl_trans *trans); void (*fw_alive)(struct iwl_trans *trans); - int (*prepare_card_hw)(struct iwl_trans *trans); void (*stop_device)(struct iwl_trans *trans); void (*wake_any_queue)(struct iwl_trans *trans, @@ -284,11 +281,6 @@ static inline int iwl_trans_start_device(struct iwl_trans *trans) return trans->ops->start_device(trans); } -static inline int iwl_trans_prepare_card_hw(struct iwl_trans *trans) -{ - return trans->ops->prepare_card_hw(trans); -} - static inline void iwl_trans_stop_device(struct iwl_trans *trans) { trans->ops->stop_device(trans); -- GitLab From a6c684ee489a99a54f978aa92a9bf1e82f8c633b Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 13:24:57 +0200 Subject: [PATCH 0318/1846] iwlwifi: move apm_init to start_hw This is transport related Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 - drivers/net/wireless/iwlwifi/iwl-core.c | 85 ------------------ drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 88 ++++++++++++++++++- 4 files changed, 87 insertions(+), 89 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 5ab7f681991e..3aeaa890e644 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1836,8 +1836,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /***************** * 4. Read EEPROM *****************/ - /* switch the NIC on before accessing the EEPROM */ - iwl_apm_init(priv); /* Read the EEPROM */ err = iwl_eeprom_init(priv, hw_rev); /* Reset chip to save power until we load uCode during "up". */ diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index c9022c5fa817..3ba59fa31086 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -923,91 +923,6 @@ void iwl_apm_stop(struct iwl_priv *priv) CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } - -/* - * Start up NIC's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via iwl_apm_stop()) - * NOTE: This does not load uCode nor start the embedded processor - */ -int iwl_apm_init(struct iwl_priv *priv) -{ - int ret = 0; - IWL_DEBUG_INFO(priv, "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) */ - iwl_set_bit(trans(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_set_bit(trans(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_set_bit(trans(priv), 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 - */ - iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); - - bus_apm_config(bus(priv)); - - /* Configure analog phase-lock-loop before activating to D0A */ - if (cfg(priv)->base_params->pll_cfg_val) - iwl_set_bit(trans(priv), CSR_ANA_PLL_CFG, - cfg(priv)->base_params->pll_cfg_val); - - /* - * Set "initialization complete" bit to move adapter from - * D0U* --> D0A* (powered-up active) state. - */ - iwl_set_bit(trans(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_write_prph() - * and accesses to uCode SRAM. - */ - ret = iwl_poll_bit(trans(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"); - goto out; - } - - /* - * Enable DMA clock and wait for it to stabilize. - * - * 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. - */ - iwl_write_prph(trans(priv), APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); - udelay(20); - - /* Disable L1-Active */ - iwl_set_bits_prph(trans(priv), APMG_PCIDEV_STT_REG, - APMG_PCIDEV_STT_VAL_L1_ACT_DIS); - - set_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status); - -out: - return ret; -} - - int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) { int ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 04975b7b65b3..338a55f403df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -544,7 +544,6 @@ void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state); void iwl_nic_config(struct iwl_priv *priv); void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb); void iwl_apm_stop(struct iwl_priv *priv); -int iwl_apm_init(struct iwl_priv *priv); void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand); const char *get_cmd_string(u8 cmd); bool iwl_check_for_ct_kill(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index d1ab57a7988f..335d4b1508cf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -74,6 +74,7 @@ #include "iwl-shared.h" #include "iwl-eeprom.h" #include "iwl-agn-hw.h" +#include "iwl-core.h" static int iwl_trans_rx_alloc(struct iwl_trans *trans) { @@ -631,13 +632,95 @@ static void iwl_set_pwr_vmain(struct iwl_trans *trans) ~APMG_PS_CTRL_MSK_PWR_SRC); } +/* + * Start up NIC's basic functionality after it has been reset + * (e.g. after platform boot, or shutdown via iwl_apm_stop()) + * NOTE: This does not load uCode nor start the embedded processor + */ +static int iwl_apm_init(struct iwl_trans *trans) +{ + int ret = 0; + IWL_DEBUG_INFO(trans, "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) */ + iwl_set_bit(trans, 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_set_bit(trans, 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_set_bit(trans, 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 + */ + iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); + + bus_apm_config(bus(trans)); + + /* Configure analog phase-lock-loop before activating to D0A */ + if (cfg(trans)->base_params->pll_cfg_val) + iwl_set_bit(trans, CSR_ANA_PLL_CFG, + cfg(trans)->base_params->pll_cfg_val); + + /* + * Set "initialization complete" bit to move adapter from + * D0U* --> D0A* (powered-up active) state. + */ + iwl_set_bit(trans, 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_write_prph() + * and accesses to uCode SRAM. + */ + ret = iwl_poll_bit(trans, 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(trans, "Failed to init the card\n"); + goto out; + } + + /* + * Enable DMA clock and wait for it to stabilize. + * + * 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. + */ + iwl_write_prph(trans, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); + udelay(20); + + /* Disable L1-Active */ + iwl_set_bits_prph(trans, APMG_PCIDEV_STT_REG, + APMG_PCIDEV_STT_VAL_L1_ACT_DIS); + + set_bit(STATUS_DEVICE_ENABLED, &trans->shrd->status); + +out: + return ret; +} + static int iwl_nic_init(struct iwl_trans *trans) { unsigned long flags; /* nic_init */ spin_lock_irqsave(&trans->shrd->lock, flags); - iwl_apm_init(priv(trans)); + iwl_apm_init(trans); /* Set interrupt coalescing calibration timer to default (512 usecs) */ iwl_write8(trans, CSR_INT_COALESCING, @@ -1267,6 +1350,9 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) IWL_ERR(trans, "Error while preparing HW: %d", err); goto error; } + + iwl_apm_init(trans); + return err; error: -- GitLab From cc56feb2eb06a0a80a8f07e4adab7e6626009cca Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 13:37:59 +0200 Subject: [PATCH 0319/1846] iwlwifi: introduce trans_ops->stop_hw This handler stops the HW and puts it in low power state. It will allow to clean up the flows in the upper layers. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-core.c | 40 -------------- drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 54 ++++++++++++++++++- drivers/net/wireless/iwlwifi/iwl-trans.h | 8 +++ 5 files changed, 61 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 3aeaa890e644..88462467a954 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1839,7 +1839,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /* Read the EEPROM */ err = iwl_eeprom_init(priv, hw_rev); /* Reset chip to save power until we load uCode during "up". */ - iwl_apm_stop(priv); + iwl_trans_stop_hw(trans(priv)); if (err) { IWL_ERR(priv, "Unable to init EEPROM\n"); goto out_free_traffic_mem; diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 3ba59fa31086..95f2c33695b7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -883,46 +883,6 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) } } -static int iwl_apm_stop_master(struct iwl_priv *priv) -{ - int ret = 0; - - /* stop device's busmaster DMA activity */ - iwl_set_bit(trans(priv), CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - - ret = iwl_poll_bit(trans(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"); - - IWL_DEBUG_INFO(priv, "stop master\n"); - - return ret; -} - -void iwl_apm_stop(struct iwl_priv *priv) -{ - IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); - - clear_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status); - - /* Stop device's DMA activity */ - iwl_apm_stop_master(priv); - - /* Reset the entire device */ - iwl_set_bit(trans(priv), 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. - */ - iwl_clear_bit(trans(priv), CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_INIT_DONE); -} - int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) { int ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 338a55f403df..63d4a4fc5b9e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -543,7 +543,6 @@ int iwlagn_hw_valid_rtc_data_addr(u32 addr); void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state); void iwl_nic_config(struct iwl_priv *priv); void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb); -void iwl_apm_stop(struct iwl_priv *priv); void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand); const char *get_cmd_string(u8 cmd); bool iwl_check_for_ct_kill(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 335d4b1508cf..43e894f6737d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -714,6 +714,46 @@ static int iwl_apm_init(struct iwl_trans *trans) return ret; } +static int iwl_apm_stop_master(struct iwl_trans *trans) +{ + int ret = 0; + + /* stop device's busmaster DMA activity */ + iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + + ret = iwl_poll_bit(trans, CSR_RESET, + CSR_RESET_REG_FLAG_MASTER_DISABLED, + CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); + if (ret) + IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n"); + + IWL_DEBUG_INFO(trans, "stop master\n"); + + return ret; +} + +static void iwl_apm_stop(struct iwl_trans *trans) +{ + IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n"); + + clear_bit(STATUS_DEVICE_ENABLED, &trans->shrd->status); + + /* Stop device's DMA activity */ + iwl_apm_stop_master(trans); + + /* Reset the entire device */ + iwl_set_bit(trans, 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. + */ + iwl_clear_bit(trans, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_INIT_DONE); +} + static int iwl_nic_init(struct iwl_trans *trans) { unsigned long flags; @@ -1118,7 +1158,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ - iwl_apm_stop(priv(trans)); + iwl_apm_stop(trans); /* Upon stop, the APM issues an interrupt if HW RF kill is set. * Clean again the interrupt here @@ -1361,6 +1401,15 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) return err; } +static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans) +{ + iwl_apm_stop(trans); + + /* Even if we stop the HW, we still want the RF kill interrupt */ + IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n"); + iwl_write32(trans, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); +} + static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, int txq_id, int ssn, u32 status, struct sk_buff_head *skbs) @@ -1455,7 +1504,7 @@ static int iwl_trans_pcie_suspend(struct iwl_trans *trans) * things already :-) */ if (!trans->shrd->wowlan) { - iwl_apm_stop(priv(trans)); + iwl_apm_stop(trans); } else { iwl_disable_interrupts(trans); iwl_clear_bit(trans, CSR_GP_CNTRL, @@ -2024,6 +2073,7 @@ static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans, const struct iwl_trans_ops trans_ops_pcie = { .start_hw = iwl_trans_pcie_start_hw, + .stop_hw = iwl_trans_pcie_stop_hw, .fw_alive = iwl_trans_pcie_fw_alive, .start_device = iwl_trans_pcie_start_device, .stop_device = iwl_trans_pcie_stop_device, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 55b5dc3b5dd6..d0b6146b0971 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -134,6 +134,8 @@ struct iwl_host_cmd { /** * struct iwl_trans_ops - transport specific operations * @start_hw: starts the HW- from that point on, the HW can send interrupts + * @stop_hw: stops the HW- from that point on, the HW will be in low power but + * will still issue interrupt if the HW RF kill is triggered. * @start_device: allocates and inits all the resources for the transport * layer. * @fw_alive: called when the fw sends alive notification @@ -163,6 +165,7 @@ struct iwl_host_cmd { struct iwl_trans_ops { int (*start_hw)(struct iwl_trans *iwl_trans); + void (*stop_hw)(struct iwl_trans *iwl_trans); int (*start_device)(struct iwl_trans *trans); void (*fw_alive)(struct iwl_trans *trans); void (*stop_device)(struct iwl_trans *trans); @@ -271,6 +274,11 @@ static inline int iwl_trans_start_hw(struct iwl_trans *trans) return trans->ops->start_hw(trans); } +static inline void iwl_trans_stop_hw(struct iwl_trans *trans) +{ + trans->ops->stop_hw(trans); +} + static inline void iwl_trans_fw_alive(struct iwl_trans *trans) { trans->ops->fw_alive(trans); -- GitLab From d48e2074e240192e8a0396e1ae0082dd0e78aa8e Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 13:48:21 +0200 Subject: [PATCH 0320/1846] iwlwifi: move the RF kill logic from iwl_probe to transport This is another clean up of the proble flow. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 23 ------------------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 11 +++++++++ 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 88462467a954..14f8b750c7c5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1815,13 +1815,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, spin_lock_init(&trans(priv)->reg_lock); spin_lock_init(&priv->shrd->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 - */ - iwl_write32(trans(priv), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - /*********************** * 3. Read REV register ***********************/ @@ -1890,22 +1883,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_setup_rx_handlers(priv); iwl_testmode_init(priv); - /********************************************* - * 8. Enable interrupts - *********************************************/ - - iwl_enable_rfkill_int(priv); - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(trans(priv), - CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status); - else - set_bit(STATUS_RF_KILL_HW, &priv->shrd->status); - - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)); - iwl_power_initialize(priv); iwl_tt_initialize(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 43e894f6737d..362444a7ed57 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1393,6 +1393,17 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) iwl_apm_init(trans); + /* If platform's RF_KILL switch is NOT set to KILL */ + if (iwl_read32(trans, + CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); + else + set_bit(STATUS_RF_KILL_HW, &trans->shrd->status); + + iwl_set_hw_rfkill_state(priv(trans), + test_bit(STATUS_RF_KILL_HW, + &trans->shrd->status)); + return err; error: -- GitLab From cf6142975bcbb731bc131ee9d2a68b7561076545 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 16:33:58 +0200 Subject: [PATCH 0321/1846] iwlwifi: consolidate the start_device flow Now there is only one transport function that launch a specific fw: trans_ops->start_fw. This one replaces trans_ops->start_device and trans_ops->kick_nic. The code that actually loads the fw to the device has been moved to the transport specific code. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 4 - drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 88 ++++++++++++++++--- drivers/net/wireless/iwlwifi/iwl-trans.h | 44 ++++------ drivers/net/wireless/iwlwifi/iwl-ucode.c | 87 ++---------------- 4 files changed, 103 insertions(+), 120 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index ebea2435dacd..731f287c0f35 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1130,11 +1130,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) isr_stats->tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ -#ifdef CONFIG_IWLWIFI_IDI - trans->shrd->trans->ucode_write_complete = 1; -#else trans->ucode_write_complete = 1; -#endif wake_up(&trans->shrd->wait_command_queue); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 362444a7ed57..1030a2524059 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -895,7 +896,79 @@ static const u8 iwlagn_pan_ac_to_queue[] = { 7, 6, 5, 4, }; -static int iwl_trans_pcie_start_device(struct iwl_trans *trans) +/* + * ucode + */ +static int iwl_load_section(struct iwl_trans *trans, const char *name, + struct fw_desc *image, u32 dst_addr) +{ + dma_addr_t phy_addr = image->p_addr; + u32 byte_cnt = image->len; + int ret; + + trans->ucode_write_complete = 0; + + iwl_write_direct32(trans, + FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); + + iwl_write_direct32(trans, + FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); + + iwl_write_direct32(trans, + FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), + phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); + + iwl_write_direct32(trans, + 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(trans, + 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(trans, + 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(trans, "%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 int iwl_load_given_ucode(struct iwl_trans *trans, struct fw_img *image) +{ + int ret = 0; + + ret = iwl_load_section(trans, "INST", &image->code, + IWLAGN_RTC_INST_LOWER_BOUND); + if (ret) + return ret; + + ret = iwl_load_section(trans, "DATA", &image->data, + IWLAGN_RTC_DATA_LOWER_BOUND); + if (ret) + return ret; + + /* Remove all resets to allow NIC to operate */ + iwl_write32(trans, CSR_RESET, 0); + + return 0; +} + +static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw) { int ret; struct iwl_trans_pcie *trans_pcie = @@ -951,6 +1024,9 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans) iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + /* Load the given image to the HW */ + iwl_load_given_ucode(trans, fw); + return 0; } @@ -1353,12 +1429,6 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, return 0; } -static void iwl_trans_pcie_kick_nic(struct iwl_trans *trans) -{ - /* Remove all resets to allow NIC to operate */ - iwl_write32(trans, CSR_RESET, 0); -} - static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = @@ -2086,7 +2156,7 @@ const struct iwl_trans_ops trans_ops_pcie = { .start_hw = iwl_trans_pcie_start_hw, .stop_hw = iwl_trans_pcie_stop_hw, .fw_alive = iwl_trans_pcie_fw_alive, - .start_device = iwl_trans_pcie_start_device, + .start_fw = iwl_trans_pcie_start_fw, .stop_device = iwl_trans_pcie_stop_device, .wake_any_queue = iwl_trans_pcie_wake_any_queue, @@ -2100,8 +2170,6 @@ const struct iwl_trans_ops trans_ops_pcie = { .tx_agg_alloc = iwl_trans_pcie_tx_agg_alloc, .tx_agg_setup = iwl_trans_pcie_tx_agg_setup, - .kick_nic = iwl_trans_pcie_kick_nic, - .free = iwl_trans_pcie_free, .stop_queue = iwl_trans_pcie_stop_queue, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index d0b6146b0971..4d1ae65b68ed 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -131,13 +131,25 @@ struct iwl_host_cmd { u8 id; }; +/* one for each uCode image (inst/data, boot/init/runtime) */ +struct fw_desc { + dma_addr_t p_addr; /* hardware address */ + void *v_addr; /* software address */ + u32 len; /* size in bytes */ +}; + +struct fw_img { + struct fw_desc code; /* firmware code image */ + struct fw_desc data; /* firmware data image */ +}; + /** * struct iwl_trans_ops - transport specific operations * @start_hw: starts the HW- from that point on, the HW can send interrupts * @stop_hw: stops the HW- from that point on, the HW will be in low power but * will still issue interrupt if the HW RF kill is triggered. - * @start_device: allocates and inits all the resources for the transport - * layer. + * @start_fw: allocates and inits all the resources for the transport + * layer. Also kick a fw image. This handler may sleep. * @fw_alive: called when the fw sends alive notification * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_* * @stop_device:stops the whole device (embedded CPU put to reset) @@ -148,7 +160,6 @@ struct iwl_host_cmd { * @tx_agg_setup: setup a tx queue for AMPDU - will be called once the HW is * ready and a successful ADDBA response has been received. * @tx_agg_disable: de-configure a Tx queue to send AMPDUs - * @kick_nic: remove the RESET from the embedded CPU and let it run * @free: release all the ressource for the transport layer itself such as * irq, tasklet etc... * @stop_queue: stop a specific queue @@ -166,7 +177,7 @@ struct iwl_trans_ops { int (*start_hw)(struct iwl_trans *iwl_trans); void (*stop_hw)(struct iwl_trans *iwl_trans); - int (*start_device)(struct iwl_trans *trans); + int (*start_fw)(struct iwl_trans *trans, struct fw_img *fw); void (*fw_alive)(struct iwl_trans *trans); void (*stop_device)(struct iwl_trans *trans); @@ -191,8 +202,6 @@ struct iwl_trans_ops { enum iwl_rxon_context_id ctx, int sta_id, int tid, int frame_limit, u16 ssn); - void (*kick_nic)(struct iwl_trans *trans); - void (*free)(struct iwl_trans *trans); void (*stop_queue)(struct iwl_trans *trans, int q, const char *msg); @@ -209,18 +218,6 @@ struct iwl_trans_ops { u32 (*read32)(struct iwl_trans *trans, u32 ofs); }; -/* one for each uCode image (inst/data, boot/init/runtime) */ -struct fw_desc { - dma_addr_t p_addr; /* hardware address */ - void *v_addr; /* software address */ - u32 len; /* size in bytes */ -}; - -struct fw_img { - struct fw_desc code; /* firmware code image */ - struct fw_desc data; /* firmware data image */ -}; - /* Opaque calibration results */ struct iwl_calib_result { struct list_head list; @@ -284,9 +281,11 @@ static inline void iwl_trans_fw_alive(struct iwl_trans *trans) trans->ops->fw_alive(trans); } -static inline int iwl_trans_start_device(struct iwl_trans *trans) +static inline int iwl_trans_start_fw(struct iwl_trans *trans, struct fw_img *fw) { - return trans->ops->start_device(trans); + might_sleep(); + + return trans->ops->start_fw(trans, fw); } static inline void iwl_trans_stop_device(struct iwl_trans *trans) @@ -347,11 +346,6 @@ static inline void iwl_trans_tx_agg_setup(struct iwl_trans *trans, trans->ops->tx_agg_setup(trans, ctx, sta_id, tid, frame_limit, ssn); } -static inline void iwl_trans_kick_nic(struct iwl_trans *trans) -{ - trans->ops->kick_nic(trans); -} - static inline void iwl_trans_free(struct iwl_trans *trans) { trans->ops->free(trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 793524a3ed70..87ce587d7d57 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -120,58 +120,6 @@ int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, return 0; } -/* - * ucode - */ -static int iwl_load_section(struct iwl_trans *trans, const char *name, - struct fw_desc *image, u32 dst_addr) -{ - dma_addr_t phy_addr = image->p_addr; - u32 byte_cnt = image->len; - int ret; - - trans->ucode_write_complete = 0; - - iwl_write_direct32(trans, - FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); - - iwl_write_direct32(trans, - FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); - - iwl_write_direct32(trans, - FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), - phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); - - iwl_write_direct32(trans, - 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(trans, - 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(trans, - 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(trans, "%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) { @@ -188,28 +136,6 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, return NULL; } -static int iwl_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 = iwl_load_section(trans, "INST", &image->code, - IWLAGN_RTC_INST_LOWER_BOUND); - if (ret) - return ret; - - return iwl_load_section(trans, "DATA", &image->data, - IWLAGN_RTC_DATA_LOWER_BOUND); -} - /* * Calibration */ @@ -646,28 +572,27 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, { struct iwl_notification_wait alive_wait; struct iwl_alive_data alive_data; + struct fw_img *fw; int ret; enum iwl_ucode_type old_type; - ret = iwl_trans_start_device(trans); - if (ret) - return ret; - iwl_init_notification_wait(trans->shrd, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); old_type = trans->shrd->ucode_type; trans->shrd->ucode_type = ucode_type; + fw = iwl_get_ucode_image(trans, ucode_type); - ret = iwl_load_given_ucode(trans, ucode_type); + if (!fw) + return -EINVAL; + + ret = iwl_trans_start_fw(trans, fw); if (ret) { trans->shrd->ucode_type = old_type; iwl_remove_notification(trans->shrd, &alive_wait); return ret; } - iwl_trans_kick_nic(trans); - /* * Some things may run in the background now, but we * just wait for the ALIVE notification here. -- GitLab From af634bee8c4a15629da5e114c491acb8ee50e1e9 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 21:12:22 +0200 Subject: [PATCH 0322/1846] iwlwifi: kill bus_apm_config This handler was called from the transport layer only. Merge it to the transport's apm_init. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 7 --- drivers/net/wireless/iwlwifi/iwl-pci.c | 29 ----------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 50 +++++++++++++++++-- 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 2065c5b74162..d385f692ef11 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -121,13 +121,11 @@ struct iwl_bus; /** * struct iwl_bus_ops - bus specific operations * @get_pm_support: must returns true if the bus can go to sleep - * @apm_config: will be called during the config of the APM * @get_hw_id_string: prints the hw_id in the provided buffer * @get_hw_id: get hw_id in u32 */ struct iwl_bus_ops { bool (*get_pm_support)(struct iwl_bus *bus); - void (*apm_config)(struct iwl_bus *bus); void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); u32 (*get_hw_id)(struct iwl_bus *bus); }; @@ -156,11 +154,6 @@ static inline bool bus_get_pm_support(struct iwl_bus *bus) return bus->ops->get_pm_support(bus); } -static inline void bus_apm_config(struct iwl_bus *bus) -{ - bus->ops->apm_config(bus); -} - static inline void bus_get_hw_id_string(struct iwl_bus *bus, char buf[], int buf_len) { diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 6451739aed2e..353022d406ea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -106,34 +106,6 @@ static bool iwl_pci_is_pm_supported(struct iwl_bus *bus) return !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); } -static void iwl_pci_apm_config(struct iwl_bus *bus) -{ - /* - * HW bug W/A for instability in PCIe bus 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. - */ - u16 lctl = iwl_pciexp_link_ctrl(bus); - - if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == - PCI_CFG_LINK_CTRL_VAL_L1_EN) { - /* L1-ASPM enabled; disable(!) L0S */ - iwl_set_bit(trans(bus), CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - dev_printk(KERN_INFO, trans(bus)->dev, - "L1 Enabled; Disabling L0S\n"); - } else { - /* L1-ASPM disabled; enable(!) L0S */ - iwl_clear_bit(trans(bus), CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - dev_printk(KERN_INFO, trans(bus)->dev, - "L1 Disabled; Enabling L0S\n"); - } -} - static void iwl_pci_get_hw_id_string(struct iwl_bus *bus, char buf[], int buf_len) { @@ -152,7 +124,6 @@ static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) static const struct iwl_bus_ops bus_ops_pci = { .get_pm_support = iwl_pci_is_pm_supported, - .apm_config = iwl_pci_apm_config, .get_hw_id_string = iwl_pci_get_hw_id_string, .get_hw_id = iwl_pci_get_hw_id, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 1030a2524059..c9fe8889ad82 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -633,6 +633,51 @@ static void iwl_set_pwr_vmain(struct iwl_trans *trans) ~APMG_PS_CTRL_MSK_PWR_SRC); } +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 +#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 +#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 + +static u16 iwl_pciexp_link_ctrl(struct iwl_trans *trans) +{ + int pos; + u16 pci_lnk_ctl; + struct iwl_trans_pcie *trans_pcie = + IWL_TRANS_GET_PCIE_TRANS(trans); + + struct pci_dev *pci_dev = trans_pcie->pci_dev; + + pos = pci_pcie_cap(pci_dev); + pci_read_config_word(pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); + return pci_lnk_ctl; +} + +static void iwl_apm_config(struct iwl_trans *trans) +{ + /* + * HW bug W/A for instability in PCIe bus 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. + */ + u16 lctl = iwl_pciexp_link_ctrl(trans); + + if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == + PCI_CFG_LINK_CTRL_VAL_L1_EN) { + /* L1-ASPM enabled; disable(!) L0S */ + iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); + dev_printk(KERN_INFO, trans->dev, + "L1 Enabled; Disabling L0S\n"); + } else { + /* L1-ASPM disabled; enable(!) L0S */ + iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); + dev_printk(KERN_INFO, trans->dev, + "L1 Disabled; Enabling L0S\n"); + } +} + /* * Start up NIC's basic functionality after it has been reset * (e.g. after platform boot, or shutdown via iwl_apm_stop()) @@ -669,7 +714,7 @@ static int iwl_apm_init(struct iwl_trans *trans) iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); - bus_apm_config(bus(trans)); + iwl_apm_config(trans); /* Configure analog phase-lock-loop before activating to D0A */ if (cfg(trans)->base_params->pll_cfg_val) @@ -2187,9 +2232,6 @@ const struct iwl_trans_ops trans_ops_pcie = { .read32 = iwl_trans_pcie_read32, }; -/* PCI registers */ -#define PCI_CFG_RETRY_TIMEOUT 0x041 - struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, struct pci_dev *pdev, const struct pci_device_id *ent) -- GitLab From f6d0e9be6580ba607f730d7e056518c95a864601 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 21:19:45 +0200 Subject: [PATCH 0323/1846] iwlwifi: kill bus_is_pm_supported Get this information from the transport layer which is now in charge of the APM too. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 7 ------- drivers/net/wireless/iwlwifi/iwl-pci.c | 20 ------------------- drivers/net/wireless/iwlwifi/iwl-power.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 + drivers/net/wireless/iwlwifi/iwl-trans.h | 2 ++ 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index d385f692ef11..2b0b48edf283 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -120,12 +120,10 @@ struct iwl_bus; /** * struct iwl_bus_ops - bus specific operations - * @get_pm_support: must returns true if the bus can go to sleep * @get_hw_id_string: prints the hw_id in the provided buffer * @get_hw_id: get hw_id in u32 */ struct iwl_bus_ops { - bool (*get_pm_support)(struct iwl_bus *bus); void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); u32 (*get_hw_id)(struct iwl_bus *bus); }; @@ -149,11 +147,6 @@ struct iwl_bus { char bus_specific[0] __attribute__((__aligned__(sizeof(void *)))); }; -static inline bool bus_get_pm_support(struct iwl_bus *bus) -{ - return bus->ops->get_pm_support(bus); -} - static inline void bus_get_hw_id_string(struct iwl_bus *bus, char buf[], int buf_len) { diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 353022d406ea..0c16efebf93d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -87,25 +87,6 @@ struct iwl_pci_bus { #define IWL_BUS_GET_PCI_DEV(_iwl_bus) \ ((IWL_BUS_GET_PCI_BUS(_iwl_bus))->pci_dev) -static u16 iwl_pciexp_link_ctrl(struct iwl_bus *bus) -{ - int pos; - u16 pci_lnk_ctl; - - struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); - - pos = pci_pcie_cap(pci_dev); - pci_read_config_word(pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); - return pci_lnk_ctl; -} - -static bool iwl_pci_is_pm_supported(struct iwl_bus *bus) -{ - u16 lctl = iwl_pciexp_link_ctrl(bus); - - return !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); -} - static void iwl_pci_get_hw_id_string(struct iwl_bus *bus, char buf[], int buf_len) { @@ -123,7 +104,6 @@ static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) } static const struct iwl_bus_ops bus_ops_pci = { - .get_pm_support = iwl_pci_is_pm_supported, .get_hw_id_string = iwl_pci_get_hw_id_string, .get_hw_id = iwl_pci_get_hw_id, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index c7394ef2e490..fd008c4e41fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -436,7 +436,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force) /* initialize to default */ void iwl_power_initialize(struct iwl_priv *priv) { - priv->power_data.bus_pm = bus_get_pm_support(bus(priv)); + priv->power_data.bus_pm = trans(priv)->pm_support; priv->power_data.debug_sleep_level_override = -1; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index c9fe8889ad82..8ebb5a54441c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -676,6 +676,7 @@ static void iwl_apm_config(struct iwl_trans *trans) dev_printk(KERN_INFO, trans->dev, "L1 Disabled; Enabling L0S\n"); } + trans->pm_support = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); } /* diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 4d1ae65b68ed..7f6963ffa7ca 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -239,6 +239,7 @@ struct iwl_calib_result { * @ucode_init: init ucode image * @ucode_wowlan: wake on wireless ucode image (optional) * @nvm_device_type: indicates OTP or eeprom + * @pm_support: set to true in start_hw if link pm is supported * @calib_results: list head for init calibration results */ struct iwl_trans { @@ -257,6 +258,7 @@ struct iwl_trans { /* eeprom related variables */ int nvm_device_type; + bool pm_support; /* init calibration results */ struct list_head calib_results; -- GitLab From 9ca859615212deb7dd0aee26972799d1910d050f Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 21:19:45 +0200 Subject: [PATCH 0324/1846] iwlwifi: kill bus_get_hw_id_string Get this information from the transport layer. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 8 -------- drivers/net/wireless/iwlwifi/iwl-core.c | 5 ++--- drivers/net/wireless/iwlwifi/iwl-pci.c | 10 ---------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 ++ drivers/net/wireless/iwlwifi/iwl-trans.h | 2 ++ 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 2b0b48edf283..61130895428a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -120,11 +120,9 @@ struct iwl_bus; /** * struct iwl_bus_ops - bus specific operations - * @get_hw_id_string: prints the hw_id in the provided buffer * @get_hw_id: get hw_id in u32 */ struct iwl_bus_ops { - void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); u32 (*get_hw_id)(struct iwl_bus *bus); }; @@ -147,12 +145,6 @@ struct iwl_bus { char bus_specific[0] __attribute__((__aligned__(sizeof(void *)))); }; -static inline void bus_get_hw_id_string(struct iwl_bus *bus, char buf[], - int buf_len) -{ - bus->ops->get_hw_id_string(bus, buf, buf_len); -} - static inline u32 bus_get_hw_id(struct iwl_bus *bus) { return bus->ops->get_hw_id(bus); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 95f2c33695b7..0677b3dfbfb2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -203,10 +203,9 @@ int iwl_init_geos(struct iwl_priv *priv) if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && cfg(priv)->sku & EEPROM_SKU_CAP_BAND_52GHZ) { - char buf[32]; - bus_get_hw_id_string(bus(priv), buf, sizeof(buf)); IWL_INFO(priv, "Incorrectly detected BG card as ABG. " - "Please send your %s to maintainer.\n", buf); + "Please send your %s to maintainer.\n", + trans(priv)->hw_id_str); cfg(priv)->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; } diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 0c16efebf93d..15864760733a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -87,15 +87,6 @@ struct iwl_pci_bus { #define IWL_BUS_GET_PCI_DEV(_iwl_bus) \ ((IWL_BUS_GET_PCI_BUS(_iwl_bus))->pci_dev) -static void iwl_pci_get_hw_id_string(struct iwl_bus *bus, char buf[], - int buf_len) -{ - struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); - - snprintf(buf, buf_len, "PCI ID: 0x%04X:0x%04X", pci_dev->device, - pci_dev->subsystem_device); -} - static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) { struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); @@ -104,7 +95,6 @@ static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) } static const struct iwl_bus_ops bus_ops_pci = { - .get_hw_id_string = iwl_pci_get_hw_id_string, .get_hw_id = iwl_pci_get_hw_id, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 8ebb5a54441c..73ff68ac7c45 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -2317,6 +2317,8 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, trans->dev = &pdev->dev; trans->irq = pdev->irq; trans_pcie->pci_dev = pdev; + snprintf(trans->hw_id_str, sizeof(trans->hw_id_str), + "PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device); /* TODO: Move this away, not needed if not MSI */ /* enable rfkill interrupt: hw bug w/a */ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 7f6963ffa7ca..593102d89c74 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -234,6 +234,7 @@ struct iwl_calib_result { * @reg_lock - protect hw register access * @dev - pointer to struct device * that represents the device * @irq - the irq number for the device + * @hw_id_str: a string with info about HW ID. Set during transport allocation. * @ucode_write_complete: indicates that the ucode has been copied. * @ucode_rt: run time ucode image * @ucode_init: init ucode image @@ -250,6 +251,7 @@ struct iwl_trans { struct device *dev; unsigned int irq; + char hw_id_str[52]; u8 ucode_write_complete; /* the image write is complete */ struct fw_img ucode_rt; -- GitLab From 99673ee556fce2fb973eaa571adb12663330caa9 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 8 Jan 2012 21:19:45 +0200 Subject: [PATCH 0325/1846] iwlwifi: kill bus_get_hw_id Get this information from the transport layer. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 14 ------- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- drivers/net/wireless/iwlwifi/iwl-pci.c | 37 ++----------------- drivers/net/wireless/iwlwifi/iwl-testmode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 + drivers/net/wireless/iwlwifi/iwl-trans.h | 3 ++ 6 files changed, 10 insertions(+), 49 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 61130895428a..30965e0e8ab4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -118,14 +118,6 @@ struct iwl_shared; struct iwl_bus; -/** - * struct iwl_bus_ops - bus specific operations - * @get_hw_id: get hw_id in u32 - */ -struct iwl_bus_ops { - u32 (*get_hw_id)(struct iwl_bus *bus); -}; - /** * struct iwl_bus - bus common data * @@ -137,7 +129,6 @@ struct iwl_bus_ops { * it allocates the shared data */ struct iwl_bus { - const struct iwl_bus_ops *ops; struct iwl_shared *shrd; /* pointer to bus specific struct */ @@ -145,11 +136,6 @@ struct iwl_bus { char bus_specific[0] __attribute__((__aligned__(sizeof(void *)))); }; -static inline u32 bus_get_hw_id(struct iwl_bus *bus) -{ - return bus->ops->get_hw_id(bus); -} - /***************************************************** * Bus layer registration functions ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index b911837b04fa..78bc1e857b00 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -234,7 +234,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; - hw->wiphy->hw_version = bus_get_hw_id(bus(priv)); + hw->wiphy->hw_version = trans(priv)->hw_id; iwl_leds_init(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 15864760733a..3e2fce4ce00c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -71,33 +71,6 @@ #include "iwl-csr.h" #include "iwl-cfg.h" -/* PCI registers */ -#define PCI_CFG_RETRY_TIMEOUT 0x041 -#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 -#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 - -struct iwl_pci_bus { - /* basic pci-network driver stuff */ - struct pci_dev *pci_dev; -}; - -#define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ - ((struct iwl_pci_bus *) ((_iwl_bus)->bus_specific)) - -#define IWL_BUS_GET_PCI_DEV(_iwl_bus) \ - ((IWL_BUS_GET_PCI_BUS(_iwl_bus))->pci_dev) - -static u32 iwl_pci_get_hw_id(struct iwl_bus *bus) -{ - struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); - - return (pci_dev->device << 16) + pci_dev->subsystem_device; -} - -static const struct iwl_bus_ops bus_ops_pci = { - .get_hw_id = iwl_pci_get_hw_id, -}; - #define IWL_PCI_DEVICE(dev, subdev, cfg) \ .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ @@ -283,14 +256,16 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { }; MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); struct iwl_bus *bus; - struct iwl_pci_bus *pci_bus; int err; - bus = kzalloc(sizeof(*bus) + sizeof(*pci_bus), GFP_KERNEL); + bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (!bus) { dev_printk(KERN_ERR, &pdev->dev, "Couldn't allocate iwl_pci_bus"); @@ -306,13 +281,9 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } bus->shrd->bus = bus; - pci_bus = IWL_BUS_GET_PCI_BUS(bus); - pci_bus->pci_dev = pdev; pci_set_drvdata(pdev, bus); - bus->ops = &bus_ops_pci; - #ifdef CONFIG_IWLWIFI_IDI trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 922d841faba2..7c17b9d52179 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -536,7 +536,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: - devid = bus_get_hw_id(bus(priv)); + devid = trans(priv)->hw_id; IWL_INFO(priv, "hw version: 0x%x\n", devid); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 73ff68ac7c45..4b711b790a90 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -2317,6 +2317,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, trans->dev = &pdev->dev; trans->irq = pdev->irq; trans_pcie->pci_dev = pdev; + trans->hw_id = (pdev->device << 16) + pdev->subsystem_device; snprintf(trans->hw_id_str, sizeof(trans->hw_id_str), "PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 593102d89c74..0359d71e554f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -234,6 +234,8 @@ struct iwl_calib_result { * @reg_lock - protect hw register access * @dev - pointer to struct device * that represents the device * @irq - the irq number for the device + * @hw_id: a u32 with the ID of the device / subdevice. + * Set during transport alloaction. * @hw_id_str: a string with info about HW ID. Set during transport allocation. * @ucode_write_complete: indicates that the ucode has been copied. * @ucode_rt: run time ucode image @@ -251,6 +253,7 @@ struct iwl_trans { struct device *dev; unsigned int irq; + u32 hw_id; char hw_id_str[52]; u8 ucode_write_complete; /* the image write is complete */ -- GitLab From 08079a4919ca960c0f46d244cae3a6ec2c39041d Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 9 Jan 2012 16:23:00 +0200 Subject: [PATCH 0326/1846] iwlwifi: move hw_rev to transport layer The HW revision is now read by the transport layer in its allocation. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 13 ++----------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 + drivers/net/wireless/iwlwifi/iwl-trans.h | 1 + 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 14f8b750c7c5..36f7adeb1768 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1691,13 +1691,6 @@ static void iwl_uninit_drv(struct iwl_priv *priv) #endif } - - -static u32 iwl_hw_detect(struct iwl_priv *priv) -{ - return iwl_read32(trans(priv), CSR_HW_REV); -} - /* Size of one Rx buffer in host DRAM */ #define IWL_RX_BUF_SIZE_4K (4 * 1024) #define IWL_RX_BUF_SIZE_8K (8 * 1024) @@ -1769,7 +1762,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, struct iwl_priv *priv; struct ieee80211_hw *hw; u16 num_mac; - u32 hw_rev; /************************ * 1. Allocating HW data @@ -1818,9 +1810,8 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /*********************** * 3. Read REV register ***********************/ - hw_rev = iwl_hw_detect(priv); IWL_INFO(priv, "Detected %s, REV=0x%X\n", - cfg(priv)->name, hw_rev); + cfg(priv)->name, trans(priv)->hw_rev); err = iwl_trans_start_hw(trans(priv)); if (err) @@ -1830,7 +1821,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, * 4. Read EEPROM *****************/ /* Read the EEPROM */ - err = iwl_eeprom_init(priv, hw_rev); + err = iwl_eeprom_init(priv, trans(priv)->hw_rev); /* Reset chip to save power until we load uCode during "up". */ iwl_trans_stop_hw(trans(priv)); if (err) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 4b711b790a90..ed2a9216d807 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -2317,6 +2317,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, trans->dev = &pdev->dev; trans->irq = pdev->irq; trans_pcie->pci_dev = pdev; + trans->hw_rev = iwl_read32(trans, CSR_HW_REV); trans->hw_id = (pdev->device << 16) + pdev->subsystem_device; snprintf(trans->hw_id_str, sizeof(trans->hw_id_str), "PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 0359d71e554f..a305e96d82a0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -253,6 +253,7 @@ struct iwl_trans { struct device *dev; unsigned int irq; + u32 hw_rev; u32 hw_id; char hw_id_str[52]; -- GitLab From 1df06bdc6fb26d13af18c5dbb3144f13cf55de3c Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 9 Jan 2012 16:35:08 +0200 Subject: [PATCH 0327/1846] iwlwifi: stop_hw replace enable_rfkill_int This trans_ops->stop_hw leaves the RFKILL interrupt enabled, we can call that one instead of enable_rfkill_int. By that, we reduce the numbers of acceesses to the NIC from the upper layers. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-core.h | 6 ------ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 7 ++++--- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 6 ++++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 ++ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index e74bfb7bbb27..8d60dcf6f2eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -297,12 +297,6 @@ static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv) cfg(priv)->bt_params->advanced_bt_coexist; } -static inline void iwl_enable_rfkill_int(struct iwl_priv *priv) -{ - IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); - iwl_write32(trans(priv), CSR_INT_MASK, CSR_INT_BIT_RF_KILL); -} - extern bool bt_siso_mode; #endif /* __iwl_core_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 78bc1e857b00..7177fd76e28a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -346,9 +346,10 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw) flush_workqueue(priv->shrd->workqueue); /* User space software may expect getting rfkill changes - * even if interface is down */ - iwl_write32(trans(priv), CSR_INT, 0xFFFFFFFF); - iwl_enable_rfkill_int(priv); + * even if interface is down, trans->down will leave the RF + * kill interrupt enabled + */ + iwl_trans_stop_hw(trans(priv)); IWL_DEBUG_MAC80211(priv, "leave\n"); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 731f287c0f35..78abff004534 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1149,8 +1149,10 @@ void iwl_irq_tasklet(struct iwl_trans *trans) if (test_bit(STATUS_INT_ENABLED, &trans->shrd->status)) iwl_enable_interrupts(trans); /* Re-enable RF_KILL if it occurred */ - else if (handled & CSR_INT_BIT_RF_KILL) - iwl_enable_rfkill_int(priv(trans)); + else if (handled & CSR_INT_BIT_RF_KILL) { + IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n"); + iwl_write32(trans, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + } } /****************************************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ed2a9216d807..ec26950ebb55 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1532,6 +1532,8 @@ static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans) { iwl_apm_stop(trans); + iwl_write32(trans, CSR_INT, 0xFFFFFFFF); + /* Even if we stop the HW, we still want the RF kill interrupt */ IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n"); iwl_write32(trans, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); -- GitLab From 1dcedc8e07902b32027e4cf00dc8150774a492e2 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 19 Jan 2012 08:27:03 +0200 Subject: [PATCH 0328/1846] iwlwifi: debug print in tx_queue_set_status is more clear The message was misleading when a queue is deactivated. The fifo number is irrelevant then, so don't print it. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 5e095ac50769..08e0a7da48a9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -431,9 +431,12 @@ void iwl_trans_tx_queue_set_status(struct iwl_trans *trans, txq->sched_retry = scd_retry; - IWL_DEBUG_TX_QUEUES(trans, "%s %s Queue %d on FIFO %d\n", - active ? "Activate" : "Deactivate", - scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id); + if (active) + IWL_DEBUG_TX_QUEUES(trans, "Activate %s Queue %d on FIFO %d\n", + scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id); + else + IWL_DEBUG_TX_QUEUES(trans, "Deactivate %s Queue %d\n", + scd_retry ? "BA" : "AC/CMD", txq_id); } static inline int get_fifo_from_tid(struct iwl_trans_pcie *trans_pcie, -- GitLab From 1589c5629c336dbb813accec03619940695339ec Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 27 Jan 2012 13:15:54 -0800 Subject: [PATCH 0329/1846] iwlwifi: clarify comment change a comment to be a little more clear Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 36f7adeb1768..82f8836f304d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1781,7 +1781,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, SET_IEEE80211_DEV(hw, trans(priv)->dev); - /* what debugging capabilities we have */ + /* show what debugging capabilities we have */ iwl_debug_config(priv); IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); -- GitLab From 87272af74e98225672c9165a20b0604a7db758cf Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 25 Jan 2012 15:26:34 -0800 Subject: [PATCH 0330/1846] iwlwifi: move bcast_sta_id init to common routine There is nothing device specific in the initialization of the bcast_sta_id so move it to the common inititalization routine. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-1000.c | 2 -- drivers/net/wireless/iwlwifi/iwl-2000.c | 2 -- drivers/net/wireless/iwlwifi/iwl-5000.c | 4 ---- drivers/net/wireless/iwlwifi/iwl-6000.c | 2 -- drivers/net/wireless/iwlwifi/iwl-agn.c | 1 + 5 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index f7a555b9d24b..8c1466c907ff 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -128,8 +128,6 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID; - hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE; hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE; diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 876003450108..d4f5f3b87578 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -124,8 +124,6 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID; - hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE; hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE; diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 5245a1422a64..dc9317d0343e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -170,8 +170,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID; - hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE; hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE; @@ -199,8 +197,6 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID; - hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE; hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE; diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 464b88784678..c36fb858a45b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -145,8 +145,6 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID; - hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE; hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 82f8836f304d..c41c394de2c2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -513,6 +513,7 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) 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].bcast_sta_id = IWLAGN_BROADCAST_ID; priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); priv->contexts[IWL_RXON_CTX_BSS].interface_modes = -- GitLab From edf38334061cb87c68cfc7fdc192c850b7e02320 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 25 Jan 2012 16:18:52 -0800 Subject: [PATCH 0331/1846] iwlwifi: move all ucode routines to iwl-ucode.c The routines dealing with the ucode are spread through several files. Move them all to the same file and create a iwl-ucode.h file with the ucode file definitions. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 609 +------------------ drivers/net/wireless/iwlwifi/iwl-agn.h | 1 + drivers/net/wireless/iwlwifi/iwl-dev.h | 108 ---- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans.h | 2 - drivers/net/wireless/iwlwifi/iwl-ucode.c | 610 +++++++++++++++++++- drivers/net/wireless/iwlwifi/iwl-ucode.h | 178 ++++++ 7 files changed, 791 insertions(+), 719 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-ucode.h diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index c41c394de2c2..8837171ad553 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -42,6 +41,7 @@ #include +#include "iwl-ucode.h" #include "iwl-eeprom.h" #include "iwl-wifi.h" #include "iwl-dev.h" @@ -490,7 +490,7 @@ static void iwl_bg_tx_flush(struct work_struct *work) iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); } -static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) +void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) { int i; @@ -548,611 +548,6 @@ static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); } -static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); - -#define UCODE_EXPERIMENTAL_INDEX 100 -#define UCODE_EXPERIMENTAL_TAG "exp" - -static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) -{ - const char *name_pre = cfg(priv)->fw_name_pre; - char tag[8]; - - if (first) { -#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE - priv->fw_index = UCODE_EXPERIMENTAL_INDEX; - strcpy(tag, UCODE_EXPERIMENTAL_TAG); - } else if (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) { -#endif - priv->fw_index = cfg(priv)->ucode_api_max; - sprintf(tag, "%d", priv->fw_index); - } else { - priv->fw_index--; - sprintf(tag, "%d", priv->fw_index); - } - - if (priv->fw_index < cfg(priv)->ucode_api_min) { - IWL_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'%s'\n", - (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) - ? "EXPERIMENTAL " : "", - priv->firmware_name); - - return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, - trans(priv)->dev, - GFP_KERNEL, priv, iwl_ucode_callback); -} - -struct iwlagn_firmware_pieces { - const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data; - size_t inst_size, data_size, init_size, init_data_size, - wowlan_inst_size, wowlan_data_size; - - u32 build; - - u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; - u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; -}; - -static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, - const struct firmware *ucode_raw, - struct iwlagn_firmware_pieces *pieces) -{ - struct iwl_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); - - switch (api_ver) { - default: - hdr_size = 28; - if (ucode_raw->size < hdr_size) { - IWL_ERR(priv, "File size too small!\n"); - return -EINVAL; - } - pieces->build = le32_to_cpu(ucode->u.v2.build); - pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); - pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); - pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); - pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size); - src = ucode->u.v2.data; - break; - case 0: - case 1: - case 2: - hdr_size = 24; - if (ucode_raw->size < hdr_size) { - IWL_ERR(priv, "File size too small!\n"); - return -EINVAL; - } - pieces->build = 0; - pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); - pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); - pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); - pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size); - src = ucode->u.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) { - - IWL_ERR(priv, - "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; - - return 0; -} - -static int iwlagn_load_firmware(struct iwl_priv *priv, - const struct firmware *ucode_raw, - struct iwlagn_firmware_pieces *pieces, - struct iwlagn_ucode_capabilities *capa) -{ - struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; - struct iwl_ucode_tlv *tlv; - size_t len = ucode_raw->size; - const u8 *data; - int wanted_alternative = iwlagn_mod_params.wanted_ucode_alternative; - int tmp; - u64 alternatives; - u32 tlv_len; - enum iwl_ucode_tlv_type tlv_type; - const u8 *tlv_data; - - if (len < sizeof(*ucode)) { - IWL_ERR(priv, "uCode has invalid length: %zd\n", len); - return -EINVAL; - } - - if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { - IWL_ERR(priv, "invalid uCode magic: 0X%x\n", - le32_to_cpu(ucode->magic)); - return -EINVAL; - } - - /* - * Check which alternatives are present, and "downgrade" - * when the chosen alternative is not present, warning - * the user when that happens. Some files may not have - * any alternatives, so don't warn in that case. - */ - alternatives = le64_to_cpu(ucode->alternatives); - tmp = wanted_alternative; - if (wanted_alternative > 63) - wanted_alternative = 63; - while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) - wanted_alternative--; - if (wanted_alternative && wanted_alternative != tmp) - IWL_WARN(priv, - "uCode alternative %d not available, choosing %d\n", - tmp, wanted_alternative); - - priv->ucode_ver = le32_to_cpu(ucode->ver); - pieces->build = le32_to_cpu(ucode->build); - data = ucode->data; - - len -= sizeof(*ucode); - - while (len >= sizeof(*tlv)) { - u16 tlv_alt; - - len -= sizeof(*tlv); - tlv = (void *)data; - - tlv_len = le32_to_cpu(tlv->length); - tlv_type = le16_to_cpu(tlv->type); - tlv_alt = le16_to_cpu(tlv->alternative); - tlv_data = tlv->data; - - if (len < tlv_len) { - IWL_ERR(priv, "invalid TLV len: %zd/%u\n", - len, tlv_len); - return -EINVAL; - } - len -= ALIGN(tlv_len, 4); - data += sizeof(*tlv) + ALIGN(tlv_len, 4); - - /* - * Alternative 0 is always valid. - * - * Skip alternative TLVs that are not selected. - */ - if (tlv_alt != 0 && tlv_alt != wanted_alternative) - continue; - - switch (tlv_type) { - case IWL_UCODE_TLV_INST: - pieces->inst = tlv_data; - pieces->inst_size = tlv_len; - break; - case IWL_UCODE_TLV_DATA: - pieces->data = tlv_data; - pieces->data_size = tlv_len; - break; - case IWL_UCODE_TLV_INIT: - pieces->init = tlv_data; - pieces->init_size = tlv_len; - break; - case IWL_UCODE_TLV_INIT_DATA: - pieces->init_data = tlv_data; - pieces->init_data_size = tlv_len; - break; - case IWL_UCODE_TLV_BOOT: - IWL_ERR(priv, "Found unexpected BOOT ucode\n"); - break; - case IWL_UCODE_TLV_PROBE_MAX_LEN: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - capa->max_probe_length = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_PAN: - if (tlv_len) - goto invalid_tlv_len; - capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; - break; - case IWL_UCODE_TLV_FLAGS: - /* must be at least one u32 */ - if (tlv_len < sizeof(u32)) - goto invalid_tlv_len; - /* and a proper number of u32s */ - if (tlv_len % sizeof(u32)) - goto invalid_tlv_len; - /* - * This driver only reads the first u32 as - * right now no more features are defined, - * if that changes then either the driver - * will not work with the new firmware, or - * it'll not take advantage of new features. - */ - capa->flags = le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_INIT_EVTLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->init_evtlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->init_evtlog_size = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_INIT_ERRLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->init_errlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->inst_evtlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->inst_evtlog_size = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->inst_errlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_ENHANCE_SENS_TBL: - if (tlv_len) - goto invalid_tlv_len; - priv->enhance_sensitivity_table = true; - break; - case IWL_UCODE_TLV_WOWLAN_INST: - pieces->wowlan_inst = tlv_data; - pieces->wowlan_inst_size = tlv_len; - break; - case IWL_UCODE_TLV_WOWLAN_DATA: - pieces->wowlan_data = tlv_data; - pieces->wowlan_data_size = tlv_len; - break; - case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - capa->standard_phy_calibration_size = - le32_to_cpup((__le32 *)tlv_data); - break; - default: - IWL_DEBUG_INFO(priv, "unknown TLV: %d\n", tlv_type); - break; - } - } - - if (len) { - IWL_ERR(priv, "invalid TLV after parsing: %zd\n", len); - iwl_print_hex_dump(priv, IWL_DL_FW, (u8 *)data, len); - return -EINVAL; - } - - return 0; - - invalid_tlv_len: - IWL_ERR(priv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); - iwl_print_hex_dump(priv, IWL_DL_FW, tlv_data, tlv_len); - - return -EINVAL; -} - -/** - * iwl_ucode_callback - callback when firmware was loaded - * - * If loaded successfully, copies the firmware into buffers - * for the card to fetch (via DMA). - */ -static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) -{ - struct iwl_priv *priv = context; - struct iwl_ucode_header *ucode; - int err; - struct iwlagn_firmware_pieces pieces; - const unsigned int api_max = cfg(priv)->ucode_api_max; - unsigned int api_ok = cfg(priv)->ucode_api_ok; - const unsigned int api_min = cfg(priv)->ucode_api_min; - u32 api_ver; - char buildstr[25]; - u32 build; - struct iwlagn_ucode_capabilities ucode_capa = { - .max_probe_length = 200, - .standard_phy_calibration_size = - IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE, - }; - - if (!api_ok) - api_ok = api_max; - - memset(&pieces, 0, sizeof(pieces)); - - if (!ucode_raw) { - if (priv->fw_index <= api_ok) - IWL_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", - 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"); - goto try_again; - } - - /* Data from ucode file: header followed by uCode images */ - ucode = (struct iwl_ucode_header *)ucode_raw->data; - - if (ucode->ver) - err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces); - else - err = iwlagn_load_firmware(priv, ucode_raw, &pieces, - &ucode_capa); - - if (err) - goto try_again; - - api_ver = IWL_UCODE_API(priv->ucode_ver); - build = pieces.build; - - /* - * 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 - */ - /* no api version check required for experimental uCode */ - if (priv->fw_index != UCODE_EXPERIMENTAL_INDEX) { - if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(priv, - "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_ok) { - if (api_ok != api_max) - IWL_ERR(priv, "Firmware has old API version, " - "expected v%u through v%u, got v%u.\n", - api_ok, api_max, api_ver); - else - IWL_ERR(priv, "Firmware has old API version, " - "expected v%u, got v%u.\n", - api_max, api_ver); - IWL_ERR(priv, "New firmware can be obtained from " - "http://www.intellinuxwireless.org/.\n"); - } - } - - if (build) - sprintf(buildstr, " build %u%s", build, - (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) - ? " (EXP)" : ""); - else - buildstr[0] = '\0'; - - IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\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), - buildstr); - - snprintf(priv->hw->wiphy->fw_version, - sizeof(priv->hw->wiphy->fw_version), - "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver), - buildstr); - - /* - * 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. - */ - - IWL_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", - pieces.inst_size); - IWL_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", - pieces.init_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", - pieces.init_data_size); - - /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > hw_params(priv).max_inst_size) { - IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", - pieces.inst_size); - goto try_again; - } - - if (pieces.data_size > hw_params(priv).max_data_size) { - IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", - pieces.data_size); - goto try_again; - } - - if (pieces.init_size > hw_params(priv).max_inst_size) { - IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", - pieces.init_size); - goto try_again; - } - - if (pieces.init_data_size > hw_params(priv).max_data_size) { - IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", - pieces.init_data_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 */ - if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.code, - pieces.inst, pieces.inst_size)) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.data, - pieces.data, pieces.data_size)) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_init.code, - pieces.init, pieces.init_size)) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_init.data, - pieces.init_data, pieces.init_data_size)) - goto err_pci_alloc; - } - - /* WoWLAN instructions and data */ - if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_wowlan.code, - pieces.wowlan_inst, - pieces.wowlan_inst_size)) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_wowlan.data, - pieces.wowlan_data, - pieces.wowlan_data_size)) - goto err_pci_alloc; - } - - /* Now that we can no longer fail, copy information */ - - /* - * The (size - 16) / 12 formula is based on the information recorded - * for each event, which is of mode 1 (including timestamp) for all - * new microcodes that include this information. - */ - priv->init_evtlog_ptr = pieces.init_evtlog_ptr; - if (pieces.init_evtlog_size) - priv->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; - else - priv->init_evtlog_size = - cfg(priv)->base_params->max_event_log_size; - priv->init_errlog_ptr = pieces.init_errlog_ptr; - priv->inst_evtlog_ptr = pieces.inst_evtlog_ptr; - if (pieces.inst_evtlog_size) - priv->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; - else - priv->inst_evtlog_size = - cfg(priv)->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); - - if (!(cfg(priv)->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) - ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; - - /* - * if not PAN, then don't support P2P -- might be a uCode - * packaging bug or due to the eeprom check above - */ - if (!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) - ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; - - if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { - priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; - priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; - } else { - 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 - */ - if (ucode_capa.standard_phy_calibration_size > - IWL_MAX_PHY_CALIBRATE_TBL_SIZE) - ucode_capa.standard_phy_calibration_size = - IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; - - priv->phy_calib_chain_noise_reset_cmd = - ucode_capa.standard_phy_calibration_size; - priv->phy_calib_chain_noise_gain_cmd = - ucode_capa.standard_phy_calibration_size + 1; - - /* initialize all valid contexts */ - iwl_init_context(priv, ucode_capa.flags); - - /************************************************** - * This is still part of probe() in a sense... - * - * 9. Setup and register with mac80211 and debugfs - **************************************************/ - err = iwlagn_mac_setup_register(priv, &ucode_capa); - if (err) - goto out_unbind; - - err = iwl_dbgfs_register(priv, DRV_NAME); - if (err) - IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); - - /* We have our copies now, allow OS release its copies */ - release_firmware(ucode_raw); - complete(&priv->firmware_loading_complete); - return; - - try_again: - /* try next, if any */ - if (iwl_request_firmware(priv, false)) - goto out_unbind; - release_firmware(ucode_raw); - return; - - err_pci_alloc: - IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(trans(priv)); - out_unbind: - complete(&priv->firmware_loading_complete); - device_release_driver(trans(priv)->dev); - release_firmware(ucode_raw); -} - static void iwl_rf_kill_ct_config(struct iwl_priv *priv) { struct iwl_ct_kill_config cmd; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 0f5133ac3575..37c325ff6e8c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -107,6 +107,7 @@ 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); +void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags); /* lib */ int iwlagn_send_tx_power(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index fff5b620927b..aa99457c3a52 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -292,114 +292,6 @@ struct iwl_vif_priv { u8 ibss_bssid_sta_id; }; -/* v1/v2 uCode file layout */ -struct iwl_ucode_header { - __le32 ver; /* major/minor/API/serial */ - union { - 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 { - __le32 build; /* build number */ - __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 */ - } v2; - } u; -}; - -/* - * new TLV uCode file layout - * - * The new TLV file format contains TLVs, that each specify - * some piece of data. To facilitate "groups", for example - * different instruction image with different capabilities, - * bundled with the same init image, an alternative mechanism - * is provided: - * When the alternative field is 0, that means that the item - * is always valid. When it is non-zero, then it is only - * valid in conjunction with items of the same alternative, - * in which case the driver (user) selects one alternative - * to use. - */ - -enum iwl_ucode_tlv_type { - IWL_UCODE_TLV_INVALID = 0, /* unused */ - IWL_UCODE_TLV_INST = 1, - IWL_UCODE_TLV_DATA = 2, - IWL_UCODE_TLV_INIT = 3, - IWL_UCODE_TLV_INIT_DATA = 4, - IWL_UCODE_TLV_BOOT = 5, - IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */ - IWL_UCODE_TLV_PAN = 7, - IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8, - IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9, - IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10, - IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11, - IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12, - IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13, - IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14, - IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15, - IWL_UCODE_TLV_WOWLAN_INST = 16, - IWL_UCODE_TLV_WOWLAN_DATA = 17, - IWL_UCODE_TLV_FLAGS = 18, -}; - -/** - * enum iwl_ucode_tlv_flag - ucode API flags - * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously - * was a separate TLV but moved here to save space. - * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID, - * treats good CRC threshold as a boolean - * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). - * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. - */ -enum iwl_ucode_tlv_flag { - IWL_UCODE_TLV_FLAGS_PAN = BIT(0), - IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), - IWL_UCODE_TLV_FLAGS_MFP = BIT(2), - IWL_UCODE_TLV_FLAGS_P2P = BIT(3), -}; - -struct iwl_ucode_tlv { - __le16 type; /* see above */ - __le16 alternative; /* see comment */ - __le32 length; /* not including type/length fields */ - u8 data[0]; -} __packed; - -#define IWL_TLV_UCODE_MAGIC 0x0a4c5749 - -struct iwl_tlv_ucode_header { - /* - * The TLV style ucode header is distinguished from - * the v1/v2 style header by first four bytes being - * zero, as such is an invalid combination of - * major/minor/API/serial versions. - */ - __le32 zero; - __le32 magic; - u8 human_readable[64]; - __le32 ver; /* major/minor/API/serial */ - __le32 build; - __le64 alternatives; /* bitmask of valid alternatives */ - /* - * The data contained herein has a TLV layout, - * see above for the TLV header and types. - * Note that each TLV is padded to a length - * that is a multiple of 4 for alignment. - */ - u8 data[0]; -}; - struct iwl_sensitivity_ranges { u16 min_nrg_cck; u16 max_nrg_cck; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 7177fd76e28a..d8025fee7e0d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -43,6 +42,7 @@ #include +#include "iwl-ucode.h" #include "iwl-eeprom.h" #include "iwl-wifi.h" #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index a305e96d82a0..ae68c51e5327 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -410,8 +410,6 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) /***************************************************** * Utils functions ******************************************************/ -int iwl_alloc_fw_desc(struct iwl_trans *trans, 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); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 87ce587d7d57..11b659ab261d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -32,7 +32,9 @@ #include #include #include +#include +#include "iwl-ucode.h" #include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" @@ -102,7 +104,7 @@ void iwl_dealloc_ucode(struct iwl_trans *trans) iwl_free_fw_img(trans, &trans->ucode_wowlan); } -int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, +static int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, const void *data, size_t len) { if (!len) { @@ -680,3 +682,609 @@ int iwl_run_init_ucode(struct iwl_trans *trans) iwl_trans_stop_device(trans); return ret; } + +static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); + +#define UCODE_EXPERIMENTAL_INDEX 100 +#define UCODE_EXPERIMENTAL_TAG "exp" + +int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) +{ + const char *name_pre = cfg(priv)->fw_name_pre; + char tag[8]; + + if (first) { +#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE + priv->fw_index = UCODE_EXPERIMENTAL_INDEX; + strcpy(tag, UCODE_EXPERIMENTAL_TAG); + } else if (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) { +#endif + priv->fw_index = cfg(priv)->ucode_api_max; + sprintf(tag, "%d", priv->fw_index); + } else { + priv->fw_index--; + sprintf(tag, "%d", priv->fw_index); + } + + if (priv->fw_index < cfg(priv)->ucode_api_min) { + IWL_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'%s'\n", + (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? "EXPERIMENTAL " : "", + priv->firmware_name); + + return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, + trans(priv)->dev, + GFP_KERNEL, priv, iwl_ucode_callback); +} + +struct iwlagn_firmware_pieces { + const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data; + size_t inst_size, data_size, init_size, init_data_size, + wowlan_inst_size, wowlan_data_size; + + u32 build; + + u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; + u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; +}; + +static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, + const struct firmware *ucode_raw, + struct iwlagn_firmware_pieces *pieces) +{ + struct iwl_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); + + switch (api_ver) { + default: + hdr_size = 28; + if (ucode_raw->size < hdr_size) { + IWL_ERR(priv, "File size too small!\n"); + return -EINVAL; + } + pieces->build = le32_to_cpu(ucode->u.v2.build); + pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); + pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); + pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); + pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size); + src = ucode->u.v2.data; + break; + case 0: + case 1: + case 2: + hdr_size = 24; + if (ucode_raw->size < hdr_size) { + IWL_ERR(priv, "File size too small!\n"); + return -EINVAL; + } + pieces->build = 0; + pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); + pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); + pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); + pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size); + src = ucode->u.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) { + + IWL_ERR(priv, + "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; + + return 0; +} + +static int iwlagn_load_firmware(struct iwl_priv *priv, + const struct firmware *ucode_raw, + struct iwlagn_firmware_pieces *pieces, + struct iwlagn_ucode_capabilities *capa) +{ + struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; + struct iwl_ucode_tlv *tlv; + size_t len = ucode_raw->size; + const u8 *data; + int wanted_alternative = iwlagn_mod_params.wanted_ucode_alternative; + int tmp; + u64 alternatives; + u32 tlv_len; + enum iwl_ucode_tlv_type tlv_type; + const u8 *tlv_data; + + if (len < sizeof(*ucode)) { + IWL_ERR(priv, "uCode has invalid length: %zd\n", len); + return -EINVAL; + } + + if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { + IWL_ERR(priv, "invalid uCode magic: 0X%x\n", + le32_to_cpu(ucode->magic)); + return -EINVAL; + } + + /* + * Check which alternatives are present, and "downgrade" + * when the chosen alternative is not present, warning + * the user when that happens. Some files may not have + * any alternatives, so don't warn in that case. + */ + alternatives = le64_to_cpu(ucode->alternatives); + tmp = wanted_alternative; + if (wanted_alternative > 63) + wanted_alternative = 63; + while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) + wanted_alternative--; + if (wanted_alternative && wanted_alternative != tmp) + IWL_WARN(priv, + "uCode alternative %d not available, choosing %d\n", + tmp, wanted_alternative); + + priv->ucode_ver = le32_to_cpu(ucode->ver); + pieces->build = le32_to_cpu(ucode->build); + data = ucode->data; + + len -= sizeof(*ucode); + + while (len >= sizeof(*tlv)) { + u16 tlv_alt; + + len -= sizeof(*tlv); + tlv = (void *)data; + + tlv_len = le32_to_cpu(tlv->length); + tlv_type = le16_to_cpu(tlv->type); + tlv_alt = le16_to_cpu(tlv->alternative); + tlv_data = tlv->data; + + if (len < tlv_len) { + IWL_ERR(priv, "invalid TLV len: %zd/%u\n", + len, tlv_len); + return -EINVAL; + } + len -= ALIGN(tlv_len, 4); + data += sizeof(*tlv) + ALIGN(tlv_len, 4); + + /* + * Alternative 0 is always valid. + * + * Skip alternative TLVs that are not selected. + */ + if (tlv_alt != 0 && tlv_alt != wanted_alternative) + continue; + + switch (tlv_type) { + case IWL_UCODE_TLV_INST: + pieces->inst = tlv_data; + pieces->inst_size = tlv_len; + break; + case IWL_UCODE_TLV_DATA: + pieces->data = tlv_data; + pieces->data_size = tlv_len; + break; + case IWL_UCODE_TLV_INIT: + pieces->init = tlv_data; + pieces->init_size = tlv_len; + break; + case IWL_UCODE_TLV_INIT_DATA: + pieces->init_data = tlv_data; + pieces->init_data_size = tlv_len; + break; + case IWL_UCODE_TLV_BOOT: + IWL_ERR(priv, "Found unexpected BOOT ucode\n"); + break; + case IWL_UCODE_TLV_PROBE_MAX_LEN: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + capa->max_probe_length = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_PAN: + if (tlv_len) + goto invalid_tlv_len; + capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; + break; + case IWL_UCODE_TLV_FLAGS: + /* must be at least one u32 */ + if (tlv_len < sizeof(u32)) + goto invalid_tlv_len; + /* and a proper number of u32s */ + if (tlv_len % sizeof(u32)) + goto invalid_tlv_len; + /* + * This driver only reads the first u32 as + * right now no more features are defined, + * if that changes then either the driver + * will not work with the new firmware, or + * it'll not take advantage of new features. + */ + capa->flags = le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_INIT_EVTLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->init_evtlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->init_evtlog_size = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_INIT_ERRLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->init_errlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->inst_evtlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->inst_evtlog_size = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->inst_errlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_ENHANCE_SENS_TBL: + if (tlv_len) + goto invalid_tlv_len; + priv->enhance_sensitivity_table = true; + break; + case IWL_UCODE_TLV_WOWLAN_INST: + pieces->wowlan_inst = tlv_data; + pieces->wowlan_inst_size = tlv_len; + break; + case IWL_UCODE_TLV_WOWLAN_DATA: + pieces->wowlan_data = tlv_data; + pieces->wowlan_data_size = tlv_len; + break; + case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + capa->standard_phy_calibration_size = + le32_to_cpup((__le32 *)tlv_data); + break; + default: + IWL_DEBUG_INFO(priv, "unknown TLV: %d\n", tlv_type); + break; + } + } + + if (len) { + IWL_ERR(priv, "invalid TLV after parsing: %zd\n", len); + iwl_print_hex_dump(priv, IWL_DL_FW, (u8 *)data, len); + return -EINVAL; + } + + return 0; + + invalid_tlv_len: + IWL_ERR(priv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); + iwl_print_hex_dump(priv, IWL_DL_FW, tlv_data, tlv_len); + + return -EINVAL; +} + +/** + * iwl_ucode_callback - callback when firmware was loaded + * + * If loaded successfully, copies the firmware into buffers + * for the card to fetch (via DMA). + */ +static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) +{ + struct iwl_priv *priv = context; + struct iwl_ucode_header *ucode; + int err; + struct iwlagn_firmware_pieces pieces; + const unsigned int api_max = cfg(priv)->ucode_api_max; + unsigned int api_ok = cfg(priv)->ucode_api_ok; + const unsigned int api_min = cfg(priv)->ucode_api_min; + u32 api_ver; + char buildstr[25]; + u32 build; + struct iwlagn_ucode_capabilities ucode_capa = { + .max_probe_length = 200, + .standard_phy_calibration_size = + IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE, + }; + + if (!api_ok) + api_ok = api_max; + + memset(&pieces, 0, sizeof(pieces)); + + if (!ucode_raw) { + if (priv->fw_index <= api_ok) + IWL_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", + 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"); + goto try_again; + } + + /* Data from ucode file: header followed by uCode images */ + ucode = (struct iwl_ucode_header *)ucode_raw->data; + + if (ucode->ver) + err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces); + else + err = iwlagn_load_firmware(priv, ucode_raw, &pieces, + &ucode_capa); + + if (err) + goto try_again; + + api_ver = IWL_UCODE_API(priv->ucode_ver); + build = pieces.build; + + /* + * 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 + */ + /* no api version check required for experimental uCode */ + if (priv->fw_index != UCODE_EXPERIMENTAL_INDEX) { + if (api_ver < api_min || api_ver > api_max) { + IWL_ERR(priv, + "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_ok) { + if (api_ok != api_max) + IWL_ERR(priv, "Firmware has old API version, " + "expected v%u through v%u, got v%u.\n", + api_ok, api_max, api_ver); + else + IWL_ERR(priv, "Firmware has old API version, " + "expected v%u, got v%u.\n", + api_max, api_ver); + IWL_ERR(priv, "New firmware can be obtained from " + "http://www.intellinuxwireless.org/.\n"); + } + } + + if (build) + sprintf(buildstr, " build %u%s", build, + (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? " (EXP)" : ""); + else + buildstr[0] = '\0'; + + IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\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), + buildstr); + + snprintf(priv->hw->wiphy->fw_version, + sizeof(priv->hw->wiphy->fw_version), + "%u.%u.%u.%u%s", + IWL_UCODE_MAJOR(priv->ucode_ver), + IWL_UCODE_MINOR(priv->ucode_ver), + IWL_UCODE_API(priv->ucode_ver), + IWL_UCODE_SERIAL(priv->ucode_ver), + buildstr); + + /* + * 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. + */ + + IWL_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", + pieces.inst_size); + IWL_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", + pieces.init_size); + IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", + pieces.init_data_size); + + /* Verify that uCode images will fit in card's SRAM */ + if (pieces.inst_size > hw_params(priv).max_inst_size) { + IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", + pieces.inst_size); + goto try_again; + } + + if (pieces.data_size > hw_params(priv).max_data_size) { + IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", + pieces.data_size); + goto try_again; + } + + if (pieces.init_size > hw_params(priv).max_inst_size) { + IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", + pieces.init_size); + goto try_again; + } + + if (pieces.init_data_size > hw_params(priv).max_data_size) { + IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", + pieces.init_data_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 */ + if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.code, + pieces.inst, pieces.inst_size)) + goto err_pci_alloc; + if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.data, + pieces.data, pieces.data_size)) + goto err_pci_alloc; + + /* Initialization instructions and data */ + if (pieces.init_size && pieces.init_data_size) { + if (iwl_alloc_fw_desc(trans(priv), + &trans(priv)->ucode_init.code, + pieces.init, pieces.init_size)) + goto err_pci_alloc; + if (iwl_alloc_fw_desc(trans(priv), + &trans(priv)->ucode_init.data, + pieces.init_data, pieces.init_data_size)) + goto err_pci_alloc; + } + + /* WoWLAN instructions and data */ + if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { + if (iwl_alloc_fw_desc(trans(priv), + &trans(priv)->ucode_wowlan.code, + pieces.wowlan_inst, + pieces.wowlan_inst_size)) + goto err_pci_alloc; + if (iwl_alloc_fw_desc(trans(priv), + &trans(priv)->ucode_wowlan.data, + pieces.wowlan_data, + pieces.wowlan_data_size)) + goto err_pci_alloc; + } + + /* Now that we can no longer fail, copy information */ + + /* + * The (size - 16) / 12 formula is based on the information recorded + * for each event, which is of mode 1 (including timestamp) for all + * new microcodes that include this information. + */ + priv->init_evtlog_ptr = pieces.init_evtlog_ptr; + if (pieces.init_evtlog_size) + priv->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; + else + priv->init_evtlog_size = + cfg(priv)->base_params->max_event_log_size; + priv->init_errlog_ptr = pieces.init_errlog_ptr; + priv->inst_evtlog_ptr = pieces.inst_evtlog_ptr; + if (pieces.inst_evtlog_size) + priv->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; + else + priv->inst_evtlog_size = + cfg(priv)->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); + + if (!(cfg(priv)->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) + ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; + + /* + * if not PAN, then don't support P2P -- might be a uCode + * packaging bug or due to the eeprom check above + */ + if (!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) + ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; + + if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { + priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; + priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; + } else { + 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 + */ + if (ucode_capa.standard_phy_calibration_size > + IWL_MAX_PHY_CALIBRATE_TBL_SIZE) + ucode_capa.standard_phy_calibration_size = + IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; + + priv->phy_calib_chain_noise_reset_cmd = + ucode_capa.standard_phy_calibration_size; + priv->phy_calib_chain_noise_gain_cmd = + ucode_capa.standard_phy_calibration_size + 1; + + /* initialize all valid contexts */ + iwl_init_context(priv, ucode_capa.flags); + + /************************************************** + * This is still part of probe() in a sense... + * + * 9. Setup and register with mac80211 and debugfs + **************************************************/ + err = iwlagn_mac_setup_register(priv, &ucode_capa); + if (err) + goto out_unbind; + + err = iwl_dbgfs_register(priv, DRV_NAME); + if (err) + IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); + + /* We have our copies now, allow OS release its copies */ + release_firmware(ucode_raw); + complete(&priv->firmware_loading_complete); + return; + + try_again: + /* try next, if any */ + if (iwl_request_firmware(priv, false)) + goto out_unbind; + release_firmware(ucode_raw); + return; + + err_pci_alloc: + IWL_ERR(priv, "failed to allocate pci memory\n"); + iwl_dealloc_ucode(trans(priv)); + out_unbind: + complete(&priv->firmware_loading_complete); + device_release_driver(trans(priv)->dev); + release_firmware(ucode_raw); +} + diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-ucode.h new file mode 100644 index 000000000000..eccf92519a84 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.h @@ -0,0 +1,178 @@ +/****************************************************************************** + * + * 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 - 2012 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 - 2012 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 __iwl_ucode_h__ +#define __iwl_ucode_h__ + +/* v1/v2 uCode file layout */ +struct iwl_ucode_header { + __le32 ver; /* major/minor/API/serial */ + union { + 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 { + __le32 build; /* build number */ + __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 */ + } v2; + } u; +}; + +/* + * new TLV uCode file layout + * + * The new TLV file format contains TLVs, that each specify + * some piece of data. To facilitate "groups", for example + * different instruction image with different capabilities, + * bundled with the same init image, an alternative mechanism + * is provided: + * When the alternative field is 0, that means that the item + * is always valid. When it is non-zero, then it is only + * valid in conjunction with items of the same alternative, + * in which case the driver (user) selects one alternative + * to use. + */ + +enum iwl_ucode_tlv_type { + IWL_UCODE_TLV_INVALID = 0, /* unused */ + IWL_UCODE_TLV_INST = 1, + IWL_UCODE_TLV_DATA = 2, + IWL_UCODE_TLV_INIT = 3, + IWL_UCODE_TLV_INIT_DATA = 4, + IWL_UCODE_TLV_BOOT = 5, + IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */ + IWL_UCODE_TLV_PAN = 7, + IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8, + IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9, + IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10, + IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11, + IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12, + IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13, + IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14, + IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15, + IWL_UCODE_TLV_WOWLAN_INST = 16, + IWL_UCODE_TLV_WOWLAN_DATA = 17, + IWL_UCODE_TLV_FLAGS = 18, +}; + +/** + * enum iwl_ucode_tlv_flag - ucode API flags + * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously + * was a separate TLV but moved here to save space. + * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID, + * treats good CRC threshold as a boolean + * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). + * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. + */ +enum iwl_ucode_tlv_flag { + IWL_UCODE_TLV_FLAGS_PAN = BIT(0), + IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), + IWL_UCODE_TLV_FLAGS_MFP = BIT(2), + IWL_UCODE_TLV_FLAGS_P2P = BIT(3), +}; + +struct iwl_ucode_tlv { + __le16 type; /* see above */ + __le16 alternative; /* see comment */ + __le32 length; /* not including type/length fields */ + u8 data[0]; +}; + +#define IWL_TLV_UCODE_MAGIC 0x0a4c5749 + +struct iwl_tlv_ucode_header { + /* + * The TLV style ucode header is distinguished from + * the v1/v2 style header by first four bytes being + * zero, as such is an invalid combination of + * major/minor/API/serial versions. + */ + __le32 zero; + __le32 magic; + u8 human_readable[64]; + __le32 ver; /* major/minor/API/serial */ + __le32 build; + __le64 alternatives; /* bitmask of valid alternatives */ + /* + * The data contained herein has a TLV layout, + * see above for the TLV header and types. + * Note that each TLV is padded to a length + * that is a multiple of 4 for alignment. + */ + u8 data[0]; +}; + +struct iwl_priv; + +int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first); + +#endif /* __iwl_ucode_h__ */ -- GitLab From f057ac4ed77d3390b517ee2be8e88615b9994272 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 29 Jan 2012 18:36:01 -0800 Subject: [PATCH 0332/1846] iwlwifi: release IRQ in error path smatch correctly complains: iwl-trans-pcie.c +1528 iwl_trans_pcie_start_hw(50) warn: 'trans->irq' was not released on error Fix it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi W Guy --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ec26950ebb55..836caf9c68b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1504,7 +1504,7 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) err = iwl_prepare_card_hw(trans); if (err) { IWL_ERR(trans, "Error while preparing HW: %d", err); - goto error; + goto err_free_irq; } iwl_apm_init(trans); @@ -1522,6 +1522,8 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) return err; +err_free_irq: + free_irq(trans->irq, trans); error: iwl_free_isr_ict(trans); tasklet_kill(&trans_pcie->irq_tasklet); -- GitLab From 6fe7dd0db0af18a8792d8551fd19a184f39a732c Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Wed, 25 Jan 2012 09:19:24 +0200 Subject: [PATCH 0333/1846] iwlwifi: range check to testmode direct reg access Added a check on the direct register access. Checks that the address is in the lower ragnge (0x0-0x2000), which belongs to CSR, HBUS and FH registers. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi W Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 7c17b9d52179..df7ab332c833 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -79,6 +79,7 @@ #include "iwl-testmode.h" #include "iwl-trans.h" #include "iwl-bus.h" +#include "iwl-fh.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 @@ -288,7 +289,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) { struct iwl_priv *priv = hw->priv; - u32 ofs, val32; + u32 ofs, val32, cmd; u8 val8; struct sk_buff *skb; int status = 0; @@ -300,7 +301,20 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) 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])) { + /* Allow access only to FH/CSR/HBUS in direct mode. + Since we don't have the upper bounds for the CSR and HBUS segments, + we will use only the upper bound of FH for sanity check. */ + cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); + if ((cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 || + cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 || + cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8) && + (ofs >= FH_MEM_UPPER_BOUND)) { + IWL_DEBUG_INFO(priv, "offset out of segment (0x0 - 0x%x)\n", + FH_MEM_UPPER_BOUND); + return -EINVAL; + } + + switch (cmd) { case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: val32 = iwl_read_direct32(trans(priv), ofs); IWL_INFO(priv, "32bit value to read 0x%x\n", val32); -- GitLab From f84cbda06f79f05b748707b33b925b50c2fedc84 Mon Sep 17 00:00:00 2001 From: Sebastian Haas Date: Thu, 22 Dec 2011 23:57:49 +0100 Subject: [PATCH 0334/1846] can: ems_usb: Removed double netif_device_detach netif_device_attched is called twice when ems_usb_start fails with -ENODEV Signed-off-by: Sebastian Haas Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/ems_usb.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 9697c14b8dc6..7dae64d44e83 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -627,9 +627,6 @@ static int ems_usb_start(struct ems_usb *dev) err = usb_submit_urb(urb, GFP_KERNEL); if (err) { - if (err == -ENODEV) - netif_device_detach(dev->netdev); - usb_unanchor_urb(urb); usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf, urb->transfer_dma); @@ -659,9 +656,6 @@ static int ems_usb_start(struct ems_usb *dev) err = usb_submit_urb(dev->intr_urb, GFP_KERNEL); if (err) { - if (err == -ENODEV) - netif_device_detach(dev->netdev); - dev_warn(netdev->dev.parent, "intr URB submit failed: %d\n", err); @@ -692,9 +686,6 @@ static int ems_usb_start(struct ems_usb *dev) return 0; failed: - if (err == -ENODEV) - netif_device_detach(dev->netdev); - dev_warn(netdev->dev.parent, "couldn't submit control: %d\n", err); return err; -- GitLab From cf5046b309b3a05c444a8edba6b44108510b7d7d Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Mon, 10 Oct 2011 23:43:53 +0200 Subject: [PATCH 0335/1846] can: dev: let can_get_echo_skb() return dlc of CAN frame can_get_echo_skb() is usually called in the TX complete handler. The stats->tx_packets and stats->tx_bytes should be updated there, too. This patch simplifies to figure out the size of the sent CAN frame. Signed-off-by: Marc Kleine-Budde --- drivers/net/can/dev.c | 10 +++++++++- include/linux/can/dev.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 120f1ab5a2ce..9d9799cf68cd 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -327,16 +327,24 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb); * is handled in the device driver. The driver must protect * access to priv->echo_skb, if necessary. */ -void can_get_echo_skb(struct net_device *dev, unsigned int idx) +unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx) { struct can_priv *priv = netdev_priv(dev); BUG_ON(idx >= priv->echo_skb_max); if (priv->echo_skb[idx]) { + struct sk_buff *skb = priv->echo_skb[idx]; + struct can_frame *cf = (struct can_frame *)skb->data; + u8 dlc = cf->can_dlc; + netif_rx(priv->echo_skb[idx]); priv->echo_skb[idx] = NULL; + + return dlc; } + + return 0; } EXPORT_SYMBOL_GPL(can_get_echo_skb); diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index a0969fcb72b9..5d2efe7e3f1b 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -92,7 +92,7 @@ void can_bus_off(struct net_device *dev); void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, unsigned int idx); -void can_get_echo_skb(struct net_device *dev, unsigned int idx); +unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); void can_free_echo_skb(struct net_device *dev, unsigned int idx); struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf); -- GitLab From 9a12349663061d25b49e6542d005fa7193a2cb44 Mon Sep 17 00:00:00 2001 From: Reuben Dowle Date: Tue, 1 Nov 2011 11:18:03 +1300 Subject: [PATCH 0336/1846] can: flexcan: Fix CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK Currently the flexcan driver uses hardware local echo. This blindly echos all transmitted frames to all receiving sockets, regardless what CAN_RAW_RECV_OWN_MSGS and CAN_RAW_LOOPBACK are set to. This patch now submits transmitted frames to be echoed in the transmit complete interrupt, preserving the reference to the sending socket. This allows the can protocol to correctly handle the local echo. Further this patch moves tx_bytes statistic accounting into the tx_complete handler. Signed-off-by: Reuben Dowle [mkl: move tx_bytes accounting into tx_complete handler; cleanups] Signed-off-by: Marc Kleine-Budde --- drivers/net/can/flexcan.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 7fd8089946fb..ab0136f49f49 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -269,7 +269,6 @@ static int flexcan_get_berr_counter(const struct net_device *dev, static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev) { const struct flexcan_priv *priv = netdev_priv(dev); - struct net_device_stats *stats = &dev->stats; struct flexcan_regs __iomem *regs = priv->base; struct can_frame *cf = (struct can_frame *)skb->data; u32 can_id; @@ -299,14 +298,11 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev) flexcan_write(data, ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[1]); } + can_put_echo_skb(skb, dev, 0); + flexcan_write(can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_id); flexcan_write(ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl); - kfree_skb(skb); - - /* tx_packets is incremented in flexcan_irq */ - stats->tx_bytes += cf->can_dlc; - return NETDEV_TX_OK; } @@ -609,7 +605,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) /* transmission complete interrupt */ if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) { - /* tx_bytes is incremented in flexcan_start_xmit */ + stats->tx_bytes += can_get_echo_skb(dev, 0); stats->tx_packets++; flexcan_write((1 << FLEXCAN_TX_BUF_ID), ®s->iflag1); netif_wake_queue(dev); @@ -697,12 +693,13 @@ static int flexcan_chip_start(struct net_device *dev) * only supervisor access * enable warning int * choose format C + * disable local echo * */ reg_mcr = flexcan_read(®s->mcr); reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN | - FLEXCAN_MCR_IDAM_C; + FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_SRX_DIS; dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__, reg_mcr); flexcan_write(reg_mcr, ®s->mcr); @@ -970,7 +967,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev) goto failed_map; } - dev = alloc_candev(sizeof(struct flexcan_priv), 0); + dev = alloc_candev(sizeof(struct flexcan_priv), 1); if (!dev) { err = -ENOMEM; goto failed_alloc; @@ -978,7 +975,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev) dev->netdev_ops = &flexcan_netdev_ops; dev->irq = irq; - dev->flags |= IFF_ECHO; /* we support local echo in hardware */ + dev->flags |= IFF_ECHO; priv = netdev_priv(dev); priv->can.clock.freq = clock_freq; -- GitLab From 2ee6850ca0cac95101d2a36c8b186b40d4fc7311 Mon Sep 17 00:00:00 2001 From: Sebastian Haas Date: Thu, 22 Dec 2011 23:58:34 +0100 Subject: [PATCH 0337/1846] can: ems_usb: Improved memory handling on ems_usb_start Do not return from ems_usb_start if allocation fails. If not all URBs could be allocated use the one already submitted. Signed-off-by: Sebastian Haas Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/ems_usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 7dae64d44e83..9783e02fbc26 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -607,7 +607,8 @@ static int ems_usb_start(struct ems_usb *dev) if (!urb) { dev_err(netdev->dev.parent, "No memory left for URBs\n"); - return -ENOMEM; + err = -ENOMEM; + break; } buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, @@ -616,7 +617,8 @@ static int ems_usb_start(struct ems_usb *dev) dev_err(netdev->dev.parent, "No memory left for USB buffer\n"); usb_free_urb(urb); - return -ENOMEM; + err = -ENOMEM; + break; } usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2), -- GitLab From e08534b57e79fa722e3136b79868a725a8eea0f0 Mon Sep 17 00:00:00 2001 From: James Kime Date: Mon, 12 Dec 2011 13:45:58 +0100 Subject: [PATCH 0338/1846] can: plx_pci: add support for IXXAT PCI cards This patch adds support for IXXAT passive CAN controllers Signed-off-by: James Kime Acked-by: Wolfgang Grandegger Signed-off-by: Marc Kleine-Budde --- drivers/net/can/sja1000/Kconfig | 1 + drivers/net/can/sja1000/plx_pci.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/sja1000/Kconfig b/drivers/net/can/sja1000/Kconfig index 36e9d594069d..b21523ddff3c 100644 --- a/drivers/net/can/sja1000/Kconfig +++ b/drivers/net/can/sja1000/Kconfig @@ -71,6 +71,7 @@ config CAN_PLX_PCI - esd CAN-PCIe/2000 - Marathon CAN-bus-PCI card (http://www.marathon.ru/) - TEWS TECHNOLOGIES TPMC810 card (http://www.tews.com/) + - IXXAT Automation PC-I 04/PCI card (http://www.ixxat.com/) config CAN_TSCAN1 tristate "TS-CAN1 PC104 boards" diff --git a/drivers/net/can/sja1000/plx_pci.c b/drivers/net/can/sja1000/plx_pci.c index c7f3d4ea1167..a227586ddd52 100644 --- a/drivers/net/can/sja1000/plx_pci.c +++ b/drivers/net/can/sja1000/plx_pci.c @@ -43,7 +43,8 @@ MODULE_SUPPORTED_DEVICE("Adlink PCI-7841/cPCI-7841, " "TEWS TECHNOLOGIES TPMC810, " "esd CAN-PCI/CPCI/PCI104/200, " "esd CAN-PCI/PMC/266, " - "esd CAN-PCIe/2000") + "esd CAN-PCIe/2000, " + "IXXAT PC-I 04/PCI") MODULE_LICENSE("GPL v2"); #define PLX_PCI_MAX_CHAN 2 @@ -121,6 +122,10 @@ struct plx_pci_card { #define ESD_PCI_SUB_SYS_ID_PCIE2000 0x0200 #define ESD_PCI_SUB_SYS_ID_PCI104200 0x0501 +#define IXXAT_PCI_VENDOR_ID 0x10b5 +#define IXXAT_PCI_DEVICE_ID 0x9050 +#define IXXAT_PCI_SUB_SYS_ID 0x2540 + #define MARATHON_PCI_DEVICE_ID 0x2715 #define TEWS_PCI_VENDOR_ID 0x1498 @@ -193,6 +198,14 @@ static struct plx_pci_card_info plx_pci_card_info_esd2000 __devinitdata = { /* based on PEX8311 */ }; +static struct plx_pci_card_info plx_pci_card_info_ixxat __devinitdata = { + "IXXAT PC-I 04/PCI", 2, + PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR, + {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x200, 0x80} }, + &plx_pci_reset_common + /* based on PLX9050 */ +}; + static struct plx_pci_card_info plx_pci_card_info_marathon __devinitdata = { "Marathon CAN-bus-PCI", 2, PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR, @@ -266,6 +279,13 @@ static DEFINE_PCI_DEVICE_TABLE(plx_pci_tbl) = { 0, 0, (kernel_ulong_t)&plx_pci_card_info_esd2000 }, + { + /* IXXAT PC-I 04/PCI card */ + IXXAT_PCI_VENDOR_ID, IXXAT_PCI_DEVICE_ID, + PCI_ANY_ID, IXXAT_PCI_SUB_SYS_ID, + 0, 0, + (kernel_ulong_t)&plx_pci_card_info_ixxat + }, { /* Marathon CAN-bus-PCI card */ PCI_VENDOR_ID_PLX, MARATHON_PCI_DEVICE_ID, -- GitLab From 74b5127884d76ccbf4f445f650f9e969ccb4a374 Mon Sep 17 00:00:00 2001 From: Tomoya MORINAGA Date: Fri, 27 Jan 2012 20:05:21 +0900 Subject: [PATCH 0339/1846] can: pch_can: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor On October 1 in 2011, OKI SEMICONDUCTOR Co., Ltd. changed the company name in to LAPIS Semiconductor Signed-off-by: Tomoya MORINAGA Signed-off-by: Marc Kleine-Budde --- drivers/net/can/pch_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c index d11fbb2b95ff..cc3ed57b6b15 100644 --- a/drivers/net/can/pch_can.c +++ b/drivers/net/can/pch_can.c @@ -1,6 +1,6 @@ /* * Copyright (C) 1999 - 2010 Intel Corporation. - * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD. + * Copyright (C) 2010 LAPIS SEMICONDUCTOR CO., LTD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- GitLab From 03c49daa8168b58e6256f0cad88771b9440ca5f7 Mon Sep 17 00:00:00 2001 From: Tomoya MORINAGA Date: Fri, 27 Jan 2012 20:05:22 +0900 Subject: [PATCH 0340/1846] can: Kconfig: add more information about Intel EG20T PCH CAN controller Current menu description, not easy to understand what the description means. So, add information about the device. Signed-off-by: Tomoya MORINAGA [mkl: Added space before opening parentheses in Kconfig. Make commit message more descriptive.] Signed-off-by: Marc Kleine-Budde --- drivers/net/can/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index ab45758c49a4..bb709fd66993 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -103,11 +103,11 @@ config CAN_FLEXCAN Say Y here if you want to support for Freescale FlexCAN. config PCH_CAN - tristate "PCH CAN" + tristate "Intel EG20T PCH CAN controller" depends on CAN_DEV && PCI ---help--- - This driver is for PCH CAN of Topcliff which is an IOH for x86 - embedded processor. + This driver is for PCH CAN of Topcliff (Intel EG20T PCH) which + is an IOH for x86 embedded processor (Intel Atom E6xx series). This driver can access CAN bus. source "drivers/net/can/mscan/Kconfig" -- GitLab From 79d0d8a7d5edca459f544c2ad75088e99307795e Mon Sep 17 00:00:00 2001 From: Wolfgang Grandegger Date: Wed, 1 Feb 2012 11:14:13 +0100 Subject: [PATCH 0341/1846] can: bfin_can/ti_hecc/mscan: add missing do_get_berr_counter callback Cc: Anant Gole Signed-off-by: Wolfgang Grandegger Signed-off-by: Marc Kleine-Budde --- drivers/net/can/bfin_can.c | 15 +++++++++++++++ drivers/net/can/mscan/mscan.c | 16 +++++++++++++++- drivers/net/can/ti_hecc.c | 12 ++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c index 349e0fabb63a..e1e7f9da3da5 100644 --- a/drivers/net/can/bfin_can.c +++ b/drivers/net/can/bfin_can.c @@ -224,6 +224,20 @@ static int bfin_can_set_mode(struct net_device *dev, enum can_mode mode) return 0; } +static int bfin_can_get_berr_counter(const struct net_device *dev, + struct can_berr_counter *bec) +{ + struct bfin_can_priv *priv = netdev_priv(dev); + struct bfin_can_regs __iomem *reg = priv->membase; + + u16 cec = bfin_read(®->cec); + + bec->txerr = cec >> 8; + bec->rxerr = cec; + + return 0; +} + static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct bfin_can_priv *priv = netdev_priv(dev); @@ -509,6 +523,7 @@ struct net_device *alloc_bfin_candev(void) priv->can.bittiming_const = &bfin_can_bittiming_const; priv->can.do_set_bittiming = bfin_can_set_bittiming; priv->can.do_set_mode = bfin_can_set_mode; + priv->can.do_get_berr_counter = bfin_can_get_berr_counter; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; return dev; diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index 1c82dd8b896e..d11b0832ccd6 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c @@ -560,6 +560,18 @@ static int mscan_do_set_bittiming(struct net_device *dev) return 0; } +static int mscan_get_berr_counter(const struct net_device *dev, + struct can_berr_counter *bec) +{ + struct mscan_priv *priv = netdev_priv(dev); + struct mscan_regs __iomem *regs = priv->reg_base; + + bec->txerr = in_8(®s->cantxerr); + bec->rxerr = in_8(®s->canrxerr); + + return 0; +} + static int mscan_open(struct net_device *dev) { int ret; @@ -639,8 +651,10 @@ int register_mscandev(struct net_device *dev, int mscan_clksrc) else ctl1 &= ~MSCAN_CLKSRC; - if (priv->type == MSCAN_TYPE_MPC5121) + if (priv->type == MSCAN_TYPE_MPC5121) { + priv->can.do_get_berr_counter = mscan_get_berr_counter; ctl1 |= MSCAN_BORM; /* bus-off recovery upon request */ + } ctl1 |= MSCAN_CANE; out_8(®s->canctl1, ctl1); diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c index df809e3f130e..aee925ab0de8 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c @@ -458,6 +458,17 @@ static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode) return ret; } +static int ti_hecc_get_berr_counter(const struct net_device *ndev, + struct can_berr_counter *bec) +{ + struct ti_hecc_priv *priv = netdev_priv(ndev); + + bec->txerr = hecc_read(priv, HECC_CANTEC); + bec->rxerr = hecc_read(priv, HECC_CANREC); + + return 0; +} + /* * ti_hecc_xmit: HECC Transmit * @@ -922,6 +933,7 @@ static int ti_hecc_probe(struct platform_device *pdev) priv->can.bittiming_const = &ti_hecc_bittiming_const; priv->can.do_set_mode = ti_hecc_do_set_mode; priv->can.do_get_state = ti_hecc_get_state; + priv->can.do_get_berr_counter = ti_hecc_get_berr_counter; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; spin_lock_init(&priv->mbx_lock); -- GitLab From aabdfd6adb804d0aaba0188ade0f1afe42a52e31 Mon Sep 17 00:00:00 2001 From: Wolfgang Grandegger Date: Wed, 1 Feb 2012 11:02:05 +0100 Subject: [PATCH 0342/1846] can: replace the dev_dbg/info/err/... with the new netdev_xxx macros Cc: uclinux-dist-devel@blackfin.uclinux.org Cc: Anant Gole Cc: Chris Elston Cc: Sebastian Haas Cc: Matthias Fuchs Signed-off-by: Wolfgang Grandegger Acked-by: Sebastian Haas Acked-by: Mike Frysinger Signed-off-by: Marc Kleine-Budde --- drivers/net/can/bfin_can.c | 21 +++++------- drivers/net/can/dev.c | 23 ++++++------- drivers/net/can/flexcan.c | 44 ++++++++++++------------ drivers/net/can/mcp251x.c | 3 +- drivers/net/can/mscan/mscan.c | 17 +++++---- drivers/net/can/sja1000/sja1000.c | 19 +++++------ drivers/net/can/ti_hecc.c | 20 +++++------ drivers/net/can/usb/ems_usb.c | 57 +++++++++++++------------------ drivers/net/can/usb/esd_usb2.c | 27 +++++++-------- 9 files changed, 103 insertions(+), 128 deletions(-) diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c index e1e7f9da3da5..3f88473423e9 100644 --- a/drivers/net/can/bfin_can.c +++ b/drivers/net/can/bfin_can.c @@ -82,8 +82,7 @@ static int bfin_can_set_bittiming(struct net_device *dev) bfin_write(®->clock, clk); bfin_write(®->timing, timing); - dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n", - clk, timing); + netdev_info(dev, "setting CLOCK=0x%04x TIMING=0x%04x\n", clk, timing); return 0; } @@ -108,8 +107,7 @@ static void bfin_can_set_reset_mode(struct net_device *dev) while (!(bfin_read(®->control) & CCA)) { udelay(10); if (--timeout == 0) { - dev_err(dev->dev.parent, - "fail to enter configuration mode\n"); + netdev_err(dev, "fail to enter configuration mode\n"); BUG(); } } @@ -165,8 +163,7 @@ static void bfin_can_set_normal_mode(struct net_device *dev) while (bfin_read(®->status) & CCA) { udelay(10); if (--timeout == 0) { - dev_err(dev->dev.parent, - "fail to leave configuration mode\n"); + netdev_err(dev, "fail to leave configuration mode\n"); BUG(); } } @@ -345,7 +342,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status) if (isrc & RMLIS) { /* data overrun interrupt */ - dev_dbg(dev->dev.parent, "data overrun interrupt\n"); + netdev_dbg(dev, "data overrun interrupt\n"); cf->can_id |= CAN_ERR_CRTL; cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; stats->rx_over_errors++; @@ -353,7 +350,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status) } if (isrc & BOIS) { - dev_dbg(dev->dev.parent, "bus-off mode interrupt\n"); + netdev_dbg(dev, "bus-off mode interrupt\n"); state = CAN_STATE_BUS_OFF; cf->can_id |= CAN_ERR_BUSOFF; can_bus_off(dev); @@ -361,13 +358,12 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status) if (isrc & EPIS) { /* error passive interrupt */ - dev_dbg(dev->dev.parent, "error passive interrupt\n"); + netdev_dbg(dev, "error passive interrupt\n"); state = CAN_STATE_ERROR_PASSIVE; } if ((isrc & EWTIS) || (isrc & EWRIS)) { - dev_dbg(dev->dev.parent, - "Error Warning Transmit/Receive Interrupt\n"); + netdev_dbg(dev, "Error Warning Transmit/Receive Interrupt\n"); state = CAN_STATE_ERROR_WARNING; } @@ -651,8 +647,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg) while (!(bfin_read(®->intr) & SMACK)) { udelay(10); if (--timeout == 0) { - dev_err(dev->dev.parent, - "fail to enter sleep mode\n"); + netdev_err(dev, "fail to enter sleep mode\n"); BUG(); } } diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 9d9799cf68cd..c5fe3a3db8c9 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -130,13 +130,13 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt) /* Error in one-tenth of a percent */ error = (best_error * 1000) / bt->bitrate; if (error > CAN_CALC_MAX_ERROR) { - dev_err(dev->dev.parent, - "bitrate error %ld.%ld%% too high\n", - error / 10, error % 10); + netdev_err(dev, + "bitrate error %ld.%ld%% too high\n", + error / 10, error % 10); return -EDOM; } else { - dev_warn(dev->dev.parent, "bitrate error %ld.%ld%%\n", - error / 10, error % 10); + netdev_warn(dev, "bitrate error %ld.%ld%%\n", + error / 10, error % 10); } } @@ -172,7 +172,7 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt) #else /* !CONFIG_CAN_CALC_BITTIMING */ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt) { - dev_err(dev->dev.parent, "bit-timing calculation not available\n"); + netdev_err(dev, "bit-timing calculation not available\n"); return -EINVAL; } #endif /* CONFIG_CAN_CALC_BITTIMING */ @@ -313,8 +313,7 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, priv->echo_skb[idx] = skb; } else { /* locking problem with netif_stop_queue() ?? */ - dev_err(dev->dev.parent, "%s: BUG! echo_skb is occupied!\n", - __func__); + netdev_err(dev, "%s: BUG! echo_skb is occupied!\n", __func__); kfree_skb(skb); } } @@ -400,7 +399,7 @@ void can_restart(unsigned long data) stats->rx_bytes += cf->can_dlc; restart: - dev_dbg(dev->dev.parent, "restarted\n"); + netdev_dbg(dev, "restarted\n"); priv->can_stats.restarts++; /* Now restart the device */ @@ -408,7 +407,7 @@ void can_restart(unsigned long data) netif_carrier_on(dev); if (err) - dev_err(dev->dev.parent, "Error %d during restart", err); + netdev_err(dev, "Error %d during restart", err); } int can_restart_now(struct net_device *dev) @@ -441,7 +440,7 @@ void can_bus_off(struct net_device *dev) { struct can_priv *priv = netdev_priv(dev); - dev_dbg(dev->dev.parent, "bus-off\n"); + netdev_dbg(dev, "bus-off\n"); netif_carrier_off(dev); priv->can_stats.bus_off++; @@ -553,7 +552,7 @@ int open_candev(struct net_device *dev) struct can_priv *priv = netdev_priv(dev); if (!priv->bittiming.tq && !priv->bittiming.bitrate) { - dev_err(dev->dev.parent, "bit-timing not yet defined\n"); + netdev_err(dev, "bit-timing not yet defined\n"); return -EINVAL; } diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index ab0136f49f49..e636287213fa 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -315,34 +315,34 @@ static void do_bus_err(struct net_device *dev, cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; if (reg_esr & FLEXCAN_ESR_BIT1_ERR) { - dev_dbg(dev->dev.parent, "BIT1_ERR irq\n"); + netdev_dbg(dev, "BIT1_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_BIT1; tx_errors = 1; } if (reg_esr & FLEXCAN_ESR_BIT0_ERR) { - dev_dbg(dev->dev.parent, "BIT0_ERR irq\n"); + netdev_dbg(dev, "BIT0_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_BIT0; tx_errors = 1; } if (reg_esr & FLEXCAN_ESR_ACK_ERR) { - dev_dbg(dev->dev.parent, "ACK_ERR irq\n"); + netdev_dbg(dev, "ACK_ERR irq\n"); cf->can_id |= CAN_ERR_ACK; cf->data[3] |= CAN_ERR_PROT_LOC_ACK; tx_errors = 1; } if (reg_esr & FLEXCAN_ESR_CRC_ERR) { - dev_dbg(dev->dev.parent, "CRC_ERR irq\n"); + netdev_dbg(dev, "CRC_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_BIT; cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; rx_errors = 1; } if (reg_esr & FLEXCAN_ESR_FRM_ERR) { - dev_dbg(dev->dev.parent, "FRM_ERR irq\n"); + netdev_dbg(dev, "FRM_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_FORM; rx_errors = 1; } if (reg_esr & FLEXCAN_ESR_STF_ERR) { - dev_dbg(dev->dev.parent, "STF_ERR irq\n"); + netdev_dbg(dev, "STF_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_STUFF; rx_errors = 1; } @@ -389,7 +389,7 @@ static void do_state(struct net_device *dev, */ if (new_state >= CAN_STATE_ERROR_WARNING && new_state <= CAN_STATE_BUS_OFF) { - dev_dbg(dev->dev.parent, "Error Warning IRQ\n"); + netdev_dbg(dev, "Error Warning IRQ\n"); priv->can.can_stats.error_warning++; cf->can_id |= CAN_ERR_CRTL; @@ -405,7 +405,7 @@ static void do_state(struct net_device *dev, */ if (new_state >= CAN_STATE_ERROR_PASSIVE && new_state <= CAN_STATE_BUS_OFF) { - dev_dbg(dev->dev.parent, "Error Passive IRQ\n"); + netdev_dbg(dev, "Error Passive IRQ\n"); priv->can.can_stats.error_passive++; cf->can_id |= CAN_ERR_CRTL; @@ -415,8 +415,8 @@ static void do_state(struct net_device *dev, } break; case CAN_STATE_BUS_OFF: - dev_err(dev->dev.parent, - "BUG! hardware recovered automatically from BUS_OFF\n"); + netdev_err(dev, "BUG! " + "hardware recovered automatically from BUS_OFF\n"); break; default: break; @@ -425,7 +425,7 @@ static void do_state(struct net_device *dev, /* process state changes depending on the new state */ switch (new_state) { case CAN_STATE_ERROR_ACTIVE: - dev_dbg(dev->dev.parent, "Error Active\n"); + netdev_dbg(dev, "Error Active\n"); cf->can_id |= CAN_ERR_PROT; cf->data[2] = CAN_ERR_PROT_ACTIVE; break; @@ -644,12 +644,12 @@ static void flexcan_set_bittiming(struct net_device *dev) if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) reg |= FLEXCAN_CTRL_SMP; - dev_info(dev->dev.parent, "writing ctrl=0x%08x\n", reg); + netdev_info(dev, "writing ctrl=0x%08x\n", reg); flexcan_write(reg, ®s->ctrl); /* print chip status */ - dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__, - flexcan_read(®s->mcr), flexcan_read(®s->ctrl)); + netdev_dbg(dev, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__, + flexcan_read(®s->mcr), flexcan_read(®s->ctrl)); } /* @@ -675,9 +675,8 @@ static int flexcan_chip_start(struct net_device *dev) reg_mcr = flexcan_read(®s->mcr); if (reg_mcr & FLEXCAN_MCR_SOFTRST) { - dev_err(dev->dev.parent, - "Failed to softreset can module (mcr=0x%08x)\n", - reg_mcr); + netdev_err(dev, "Failed to softreset can module (mcr=0x%08x)\n", + reg_mcr); err = -ENODEV; goto out; } @@ -700,7 +699,7 @@ static int flexcan_chip_start(struct net_device *dev) reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_SRX_DIS; - dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__, reg_mcr); + netdev_dbg(dev, "%s: writing mcr=0x%08x", __func__, reg_mcr); flexcan_write(reg_mcr, ®s->mcr); /* @@ -726,7 +725,7 @@ static int flexcan_chip_start(struct net_device *dev) /* save for later use */ priv->reg_ctrl_default = reg_ctrl; - dev_dbg(dev->dev.parent, "%s: writing ctrl=0x%08x", __func__, reg_ctrl); + netdev_dbg(dev, "%s: writing ctrl=0x%08x", __func__, reg_ctrl); flexcan_write(reg_ctrl, ®s->ctrl); for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) { @@ -758,8 +757,8 @@ static int flexcan_chip_start(struct net_device *dev) flexcan_write(FLEXCAN_IFLAG_DEFAULT, ®s->imask1); /* print chip status */ - dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n", - __func__, flexcan_read(®s->mcr), flexcan_read(®s->ctrl)); + netdev_dbg(dev, "%s: reading mcr=0x%08x ctrl=0x%08x\n", __func__, + flexcan_read(®s->mcr), flexcan_read(®s->ctrl)); return 0; @@ -897,8 +896,7 @@ static int __devinit register_flexcandev(struct net_device *dev) */ reg = flexcan_read(®s->mcr); if (!(reg & FLEXCAN_MCR_FEN)) { - dev_err(dev->dev.parent, - "Could not enable RX FIFO, unsupported core\n"); + netdev_err(dev, "Could not enable RX FIFO, unsupported core\n"); err = -ENODEV; goto out; } diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index 330140ee266d..346785c56a25 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c @@ -712,8 +712,7 @@ static void mcp251x_error_skb(struct net_device *net, int can_id, int data1) frame->data[1] = data1; netif_rx_ni(skb); } else { - dev_err(&net->dev, - "cannot allocate error skb\n"); + netdev_err(net, "cannot allocate error skb\n"); } } diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index d11b0832ccd6..41a2a2dda7ea 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c @@ -95,9 +95,9 @@ static int mscan_set_mode(struct net_device *dev, u8 mode) * any, at once. */ if (i >= MSCAN_SET_MODE_RETRIES) - dev_dbg(dev->dev.parent, - "device failed to enter sleep mode. " - "We proceed anyhow.\n"); + netdev_dbg(dev, + "device failed to enter sleep mode. " + "We proceed anyhow.\n"); else priv->can.state = CAN_STATE_SLEEPING; } @@ -213,7 +213,7 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev) switch (hweight8(i)) { case 0: netif_stop_queue(dev); - dev_err(dev->dev.parent, "Tx Ring full when queue awake!\n"); + netdev_err(dev, "Tx Ring full when queue awake!\n"); return NETDEV_TX_BUSY; case 1: /* @@ -352,7 +352,7 @@ static void mscan_get_err_frame(struct net_device *dev, struct can_frame *frame, struct net_device_stats *stats = &dev->stats; enum can_state old_state; - dev_dbg(dev->dev.parent, "error interrupt (canrflg=%#x)\n", canrflg); + netdev_dbg(dev, "error interrupt (canrflg=%#x)\n", canrflg); frame->can_id = CAN_ERR_FLAG; if (canrflg & MSCAN_OVRIF) { @@ -427,7 +427,7 @@ static int mscan_rx_poll(struct napi_struct *napi, int quota) skb = alloc_can_skb(dev, &frame); if (!skb) { if (printk_ratelimit()) - dev_notice(dev->dev.parent, "packet dropped\n"); + netdev_notice(dev, "packet dropped\n"); stats->rx_dropped++; out_8(®s->canrflg, canrflg); continue; @@ -551,8 +551,7 @@ static int mscan_do_set_bittiming(struct net_device *dev) BTR1_SET_TSEG2(bt->phase_seg2) | BTR1_SET_SAM(priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)); - dev_info(dev->dev.parent, "setting BTR0=0x%02x BTR1=0x%02x\n", - btr0, btr1); + netdev_info(dev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1); out_8(®s->canbtr0, btr0); out_8(®s->canbtr1, btr1); @@ -587,7 +586,7 @@ static int mscan_open(struct net_device *dev) ret = request_irq(dev->irq, mscan_isr, 0, dev->name, dev); if (ret < 0) { - dev_err(dev->dev.parent, "failed to attach interrupt\n"); + netdev_err(dev, "failed to attach interrupt\n"); goto exit_napi_disable; } diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index 04a3f1b756a8..ebbcfcafe29b 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c @@ -128,7 +128,7 @@ static void set_reset_mode(struct net_device *dev) status = priv->read_reg(priv, REG_MOD); } - dev_err(dev->dev.parent, "setting SJA1000 into reset mode failed!\n"); + netdev_err(dev, "setting SJA1000 into reset mode failed!\n"); } static void set_normal_mode(struct net_device *dev) @@ -156,7 +156,7 @@ static void set_normal_mode(struct net_device *dev) status = priv->read_reg(priv, REG_MOD); } - dev_err(dev->dev.parent, "setting SJA1000 into normal mode failed!\n"); + netdev_err(dev, "setting SJA1000 into normal mode failed!\n"); } static void sja1000_start(struct net_device *dev) @@ -209,8 +209,7 @@ static int sja1000_set_bittiming(struct net_device *dev) if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) btr1 |= 0x80; - dev_info(dev->dev.parent, - "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1); + netdev_info(dev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1); priv->write_reg(priv, REG_BTR0, btr0); priv->write_reg(priv, REG_BTR1, btr1); @@ -378,7 +377,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) if (isrc & IRQ_DOI) { /* data overrun interrupt */ - dev_dbg(dev->dev.parent, "data overrun interrupt\n"); + netdev_dbg(dev, "data overrun interrupt\n"); cf->can_id |= CAN_ERR_CRTL; cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; stats->rx_over_errors++; @@ -388,7 +387,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) if (isrc & IRQ_EI) { /* error warning interrupt */ - dev_dbg(dev->dev.parent, "error warning interrupt\n"); + netdev_dbg(dev, "error warning interrupt\n"); if (status & SR_BS) { state = CAN_STATE_BUS_OFF; @@ -429,7 +428,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) } if (isrc & IRQ_EPI) { /* error passive interrupt */ - dev_dbg(dev->dev.parent, "error passive interrupt\n"); + netdev_dbg(dev, "error passive interrupt\n"); if (status & SR_ES) state = CAN_STATE_ERROR_PASSIVE; else @@ -437,7 +436,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) } if (isrc & IRQ_ALI) { /* arbitration lost interrupt */ - dev_dbg(dev->dev.parent, "arbitration lost interrupt\n"); + netdev_dbg(dev, "arbitration lost interrupt\n"); alc = priv->read_reg(priv, REG_ALC); priv->can.can_stats.arbitration_lost++; stats->tx_errors++; @@ -495,7 +494,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id) status = priv->read_reg(priv, REG_SR); if (isrc & IRQ_WUI) - dev_warn(dev->dev.parent, "wakeup interrupt\n"); + netdev_warn(dev, "wakeup interrupt\n"); if (isrc & IRQ_TI) { /* transmission complete interrupt */ @@ -522,7 +521,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id) priv->post_irq(priv); if (n >= SJA1000_MAX_IRQ) - dev_dbg(dev->dev.parent, "%d messages handled in ISR", n); + netdev_dbg(dev, "%d messages handled in ISR", n); return (n) ? IRQ_HANDLED : IRQ_NONE; } diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c index aee925ab0de8..0d18a9319720 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c @@ -306,7 +306,7 @@ static int ti_hecc_set_btc(struct ti_hecc_priv *priv) if (bit_timing->brp > 4) can_btc |= HECC_CANBTC_SAM; else - dev_warn(priv->ndev->dev.parent, "WARN: Triple" \ + netdev_warn(priv->ndev, "WARN: Triple" "sampling not set due to h/w limitations"); } can_btc |= ((bit_timing->sjw - 1) & 0x3) << 8; @@ -315,7 +315,7 @@ static int ti_hecc_set_btc(struct ti_hecc_priv *priv) /* ERM being set to 0 by default meaning resync at falling edge */ hecc_write(priv, HECC_CANBTC, can_btc); - dev_info(priv->ndev->dev.parent, "setting CANBTC=%#x\n", can_btc); + netdev_info(priv->ndev, "setting CANBTC=%#x\n", can_btc); return 0; } @@ -332,7 +332,7 @@ static void ti_hecc_reset(struct net_device *ndev) u32 cnt; struct ti_hecc_priv *priv = netdev_priv(ndev); - dev_dbg(ndev->dev.parent, "resetting hecc ...\n"); + netdev_dbg(ndev, "resetting hecc ...\n"); hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_SRES); /* Set change control request and wait till enabled */ @@ -507,7 +507,7 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev) if (unlikely(hecc_read(priv, HECC_CANME) & mbx_mask)) { spin_unlock_irqrestore(&priv->mbx_lock, flags); netif_stop_queue(ndev); - dev_err(priv->ndev->dev.parent, + netdev_err(priv->ndev, "BUG: TX mbx not ready tx_head=%08X, tx_tail=%08X\n", priv->tx_head, priv->tx_tail); return NETDEV_TX_BUSY; @@ -561,7 +561,7 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno) skb = alloc_can_skb(priv->ndev, &cf); if (!skb) { if (printk_ratelimit()) - dev_err(priv->ndev->dev.parent, + netdev_err(priv->ndev, "ti_hecc_rx_pkt: alloc_can_skb() failed\n"); return -ENOMEM; } @@ -679,7 +679,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, skb = alloc_can_err_skb(ndev, &cf); if (!skb) { if (printk_ratelimit()) - dev_err(priv->ndev->dev.parent, + netdev_err(priv->ndev, "ti_hecc_error: alloc_can_err_skb() failed\n"); return -ENOMEM; } @@ -695,7 +695,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, cf->data[1] |= CAN_ERR_CRTL_RX_WARNING; } hecc_set_bit(priv, HECC_CANES, HECC_CANES_EW); - dev_dbg(priv->ndev->dev.parent, "Error Warning interrupt\n"); + netdev_dbg(priv->ndev, "Error Warning interrupt\n"); hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); } @@ -710,7 +710,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE; } hecc_set_bit(priv, HECC_CANES, HECC_CANES_EP); - dev_dbg(priv->ndev->dev.parent, "Error passive interrupt\n"); + netdev_dbg(priv->ndev, "Error passive interrupt\n"); hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); } @@ -835,7 +835,7 @@ static int ti_hecc_open(struct net_device *ndev) err = request_irq(ndev->irq, ti_hecc_interrupt, IRQF_SHARED, ndev->name, ndev); if (err) { - dev_err(ndev->dev.parent, "error requesting interrupt\n"); + netdev_err(ndev, "error requesting interrupt\n"); return err; } @@ -844,7 +844,7 @@ static int ti_hecc_open(struct net_device *ndev) /* Open common can device */ err = open_candev(ndev); if (err) { - dev_err(ndev->dev.parent, "open_candev() failed %d\n", err); + netdev_err(ndev, "open_candev() failed %d\n", err); ti_hecc_transceiver_switch(priv, 0); free_irq(ndev->irq, ndev); return err; diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 9783e02fbc26..7ae65fc80032 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -288,8 +288,7 @@ static void ems_usb_read_interrupt_callback(struct urb *urb) return; default: - dev_info(netdev->dev.parent, "Rx interrupt aborted %d\n", - urb->status); + netdev_info(netdev, "Rx interrupt aborted %d\n", urb->status); break; } @@ -298,8 +297,7 @@ static void ems_usb_read_interrupt_callback(struct urb *urb) if (err == -ENODEV) netif_device_detach(netdev); else if (err) - dev_err(netdev->dev.parent, - "failed resubmitting intr urb: %d\n", err); + netdev_err(netdev, "failed resubmitting intr urb: %d\n", err); } static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg) @@ -431,8 +429,7 @@ static void ems_usb_read_bulk_callback(struct urb *urb) return; default: - dev_info(netdev->dev.parent, "Rx URB aborted (%d)\n", - urb->status); + netdev_info(netdev, "Rx URB aborted (%d)\n", urb->status); goto resubmit_urb; } @@ -477,7 +474,7 @@ static void ems_usb_read_bulk_callback(struct urb *urb) msg_count--; if (start > urb->transfer_buffer_length) { - dev_err(netdev->dev.parent, "format error\n"); + netdev_err(netdev, "format error\n"); break; } } @@ -493,8 +490,8 @@ static void ems_usb_read_bulk_callback(struct urb *urb) if (retval == -ENODEV) netif_device_detach(netdev); else if (retval) - dev_err(netdev->dev.parent, - "failed resubmitting read bulk urb: %d\n", retval); + netdev_err(netdev, + "failed resubmitting read bulk urb: %d\n", retval); } /* @@ -521,8 +518,7 @@ static void ems_usb_write_bulk_callback(struct urb *urb) return; if (urb->status) - dev_info(netdev->dev.parent, "Tx URB aborted (%d)\n", - urb->status); + netdev_info(netdev, "Tx URB aborted (%d)\n", urb->status); netdev->trans_start = jiffies; @@ -605,8 +601,7 @@ static int ems_usb_start(struct ems_usb *dev) /* create a URB, and a buffer for it */ urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { - dev_err(netdev->dev.parent, - "No memory left for URBs\n"); + netdev_err(netdev, "No memory left for URBs\n"); err = -ENOMEM; break; } @@ -614,8 +609,7 @@ static int ems_usb_start(struct ems_usb *dev) buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, &urb->transfer_dma); if (!buf) { - dev_err(netdev->dev.parent, - "No memory left for USB buffer\n"); + netdev_err(netdev, "No memory left for USB buffer\n"); usb_free_urb(urb); err = -ENOMEM; break; @@ -641,13 +635,13 @@ static int ems_usb_start(struct ems_usb *dev) /* Did we submit any URBs */ if (i == 0) { - dev_warn(netdev->dev.parent, "couldn't setup read URBs\n"); + netdev_warn(netdev, "couldn't setup read URBs\n"); return err; } /* Warn if we've couldn't transmit all the URBs */ if (i < MAX_RX_URBS) - dev_warn(netdev->dev.parent, "rx performance may be slow\n"); + netdev_warn(netdev, "rx performance may be slow\n"); /* Setup and start interrupt URB */ usb_fill_int_urb(dev->intr_urb, dev->udev, @@ -658,8 +652,7 @@ static int ems_usb_start(struct ems_usb *dev) err = usb_submit_urb(dev->intr_urb, GFP_KERNEL); if (err) { - dev_warn(netdev->dev.parent, "intr URB submit failed: %d\n", - err); + netdev_warn(netdev, "intr URB submit failed: %d\n", err); return err; } @@ -688,7 +681,7 @@ static int ems_usb_start(struct ems_usb *dev) return 0; failed: - dev_warn(netdev->dev.parent, "couldn't submit control: %d\n", err); + netdev_warn(netdev, "couldn't submit control: %d\n", err); return err; } @@ -728,8 +721,7 @@ static int ems_usb_open(struct net_device *netdev) if (err == -ENODEV) netif_device_detach(dev->netdev); - dev_warn(netdev->dev.parent, "couldn't start device: %d\n", - err); + netdev_warn(netdev, "couldn't start device: %d\n", err); close_candev(netdev); @@ -762,13 +754,13 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne /* create a URB, and a buffer for it, and copy the data to the URB */ urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) { - dev_err(netdev->dev.parent, "No memory left for URBs\n"); + netdev_err(netdev, "No memory left for URBs\n"); goto nomem; } buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma); if (!buf) { - dev_err(netdev->dev.parent, "No memory left for USB buffer\n"); + netdev_err(netdev, "No memory left for USB buffer\n"); usb_free_urb(urb); goto nomem; } @@ -811,7 +803,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne usb_unanchor_urb(urb); usb_free_coherent(dev->udev, size, buf, urb->transfer_dma); - dev_warn(netdev->dev.parent, "couldn't find free context\n"); + netdev_warn(netdev, "couldn't find free context\n"); return NETDEV_TX_BUSY; } @@ -842,7 +834,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne if (err == -ENODEV) { netif_device_detach(netdev); } else { - dev_warn(netdev->dev.parent, "failed tx_urb %d\n", err); + netdev_warn(netdev, "failed tx_urb %d\n", err); stats->tx_dropped++; } @@ -882,7 +874,7 @@ static int ems_usb_close(struct net_device *netdev) /* Set CAN controller to reset mode */ if (ems_usb_write_mode(dev, SJA1000_MOD_RM)) - dev_warn(netdev->dev.parent, "couldn't stop device"); + netdev_warn(netdev, "couldn't stop device"); close_candev(netdev); @@ -919,7 +911,7 @@ static int ems_usb_set_mode(struct net_device *netdev, enum can_mode mode) switch (mode) { case CAN_MODE_START: if (ems_usb_write_mode(dev, SJA1000_MOD_NORMAL)) - dev_warn(netdev->dev.parent, "couldn't start device"); + netdev_warn(netdev, "couldn't start device"); if (netif_queue_stopped(netdev)) netif_wake_queue(netdev); @@ -944,8 +936,7 @@ static int ems_usb_set_bittiming(struct net_device *netdev) if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) btr1 |= 0x80; - dev_info(netdev->dev.parent, "setting BTR0=0x%02x BTR1=0x%02x\n", - btr0, btr1); + netdev_info(netdev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1); dev->active_params.msg.can_params.cc_params.sja1000.btr0 = btr0; dev->active_params.msg.can_params.cc_params.sja1000.btr1 = btr1; @@ -1050,15 +1041,13 @@ static int ems_usb_probe(struct usb_interface *intf, err = ems_usb_command_msg(dev, &dev->active_params); if (err) { - dev_err(netdev->dev.parent, - "couldn't initialize controller: %d\n", err); + netdev_err(netdev, "couldn't initialize controller: %d\n", err); goto cleanup_tx_msg_buffer; } err = register_candev(netdev); if (err) { - dev_err(netdev->dev.parent, - "couldn't register CAN device: %d\n", err); + netdev_err(netdev, "couldn't register CAN device: %d\n", err); goto cleanup_tx_msg_buffer; } diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c index 92774637aad8..09b1da5bc512 100644 --- a/drivers/net/can/usb/esd_usb2.c +++ b/drivers/net/can/usb/esd_usb2.c @@ -470,8 +470,7 @@ static void esd_usb2_write_bulk_callback(struct urb *urb) return; if (urb->status) - dev_info(netdev->dev.parent, "Tx URB aborted (%d)\n", - urb->status); + netdev_info(netdev, "Tx URB aborted (%d)\n", urb->status); netdev->trans_start = jiffies; } @@ -651,7 +650,7 @@ static int esd_usb2_start(struct esd_usb2_net_priv *priv) if (err == -ENODEV) netif_device_detach(netdev); - dev_err(netdev->dev.parent, "couldn't start device: %d\n", err); + netdev_err(netdev, "couldn't start device: %d\n", err); return err; } @@ -687,8 +686,7 @@ static int esd_usb2_open(struct net_device *netdev) /* finally start device */ err = esd_usb2_start(priv); if (err) { - dev_warn(netdev->dev.parent, - "couldn't start device: %d\n", err); + netdev_warn(netdev, "couldn't start device: %d\n", err); close_candev(netdev); return err; } @@ -721,7 +719,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb, /* create a URB, and a buffer for it, and copy the data to the URB */ urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) { - dev_err(netdev->dev.parent, "No memory left for URBs\n"); + netdev_err(netdev, "No memory left for URBs\n"); stats->tx_dropped++; dev_kfree_skb(skb); goto nourbmem; @@ -730,7 +728,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb, buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma); if (!buf) { - dev_err(netdev->dev.parent, "No memory left for USB buffer\n"); + netdev_err(netdev, "No memory left for USB buffer\n"); stats->tx_dropped++; dev_kfree_skb(skb); goto nobufmem; @@ -766,7 +764,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb, * This may never happen. */ if (!context) { - dev_warn(netdev->dev.parent, "couldn't find free context\n"); + netdev_warn(netdev, "couldn't find free context\n"); ret = NETDEV_TX_BUSY; goto releasebuf; } @@ -806,7 +804,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb, if (err == -ENODEV) netif_device_detach(netdev); else - dev_warn(netdev->dev.parent, "failed tx_urb %d\n", err); + netdev_warn(netdev, "failed tx_urb %d\n", err); goto releasebuf; } @@ -845,7 +843,7 @@ static int esd_usb2_close(struct net_device *netdev) for (i = 0; i <= ESD_MAX_ID_SEGMENT; i++) msg.msg.filter.mask[i] = 0; if (esd_usb2_send_msg(priv->usb2, &msg) < 0) - dev_err(netdev->dev.parent, "sending idadd message failed\n"); + netdev_err(netdev, "sending idadd message failed\n"); /* set CAN controller to reset mode */ msg.msg.hdr.len = 2; @@ -854,7 +852,7 @@ static int esd_usb2_close(struct net_device *netdev) msg.msg.setbaud.rsvd = 0; msg.msg.setbaud.baud = cpu_to_le32(ESD_USB2_NO_BAUDRATE); if (esd_usb2_send_msg(priv->usb2, &msg) < 0) - dev_err(netdev->dev.parent, "sending setbaud message failed\n"); + netdev_err(netdev, "sending setbaud message failed\n"); priv->can.state = CAN_STATE_STOPPED; @@ -910,7 +908,7 @@ static int esd_usb2_set_bittiming(struct net_device *netdev) msg.msg.setbaud.rsvd = 0; msg.msg.setbaud.baud = cpu_to_le32(canbtr); - dev_info(netdev->dev.parent, "setting BTR=%#x\n", canbtr); + netdev_info(netdev, "setting BTR=%#x\n", canbtr); return esd_usb2_send_msg(priv->usb2, &msg); } @@ -988,15 +986,14 @@ static int esd_usb2_probe_one_net(struct usb_interface *intf, int index) err = register_candev(netdev); if (err) { - dev_err(&intf->dev, - "couldn't register CAN device: %d\n", err); + dev_err(&intf->dev, "couldn't register CAN device: %d\n", err); free_candev(netdev); err = -ENOMEM; goto done; } dev->nets[index] = priv; - dev_info(netdev->dev.parent, "device %s registered\n", netdev->name); + netdev_info(netdev, "device %s registered\n", netdev->name); done: return err; -- GitLab From 2dcd5d95ad6b281fca6f2d5e252bbf7e8e20655b Mon Sep 17 00:00:00 2001 From: Sritej Velaga Date: Fri, 3 Feb 2012 11:35:10 +0000 Subject: [PATCH 0343/1846] netxen_nic: fix cdrp race condition Reading CRB registers(if reqd) before releasing the api lock. Signed-off-by: Sritej Velaga Signed-off-by: David S. Miller --- .../net/ethernet/qlogic/netxen/netxen_nic.h | 12 ++ .../ethernet/qlogic/netxen/netxen_nic_ctx.c | 149 +++++++++--------- 2 files changed, 89 insertions(+), 72 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h index a876dffd7101..1b09ba172310 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h @@ -686,6 +686,18 @@ struct netxen_recv_context { dma_addr_t phys_addr; }; +struct _cdrp_cmd { + u32 cmd; + u32 arg1; + u32 arg2; + u32 arg3; +}; + +struct netxen_cmd_args { + struct _cdrp_cmd req; + struct _cdrp_cmd rsp; +}; + /* New HW context creation */ #define NX_OS_CRB_RETRY_COUNT 4000 diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c index a925392abd6f..d46e8cb394eb 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c @@ -48,28 +48,27 @@ netxen_poll_rsp(struct netxen_adapter *adapter) } static u32 -netxen_issue_cmd(struct netxen_adapter *adapter, - u32 pci_fn, u32 version, u32 arg1, u32 arg2, u32 arg3, u32 cmd) +netxen_issue_cmd(struct netxen_adapter *adapter, struct netxen_cmd_args *cmd) { u32 rsp; u32 signature = 0; u32 rcode = NX_RCODE_SUCCESS; - signature = NX_CDRP_SIGNATURE_MAKE(pci_fn, version); - + signature = NX_CDRP_SIGNATURE_MAKE(adapter->ahw.pci_func, + NXHAL_VERSION); /* Acquire semaphore before accessing CRB */ if (netxen_api_lock(adapter)) return NX_RCODE_TIMEOUT; NXWR32(adapter, NX_SIGN_CRB_OFFSET, signature); - NXWR32(adapter, NX_ARG1_CRB_OFFSET, arg1); + NXWR32(adapter, NX_ARG1_CRB_OFFSET, cmd->req.arg1); - NXWR32(adapter, NX_ARG2_CRB_OFFSET, arg2); + NXWR32(adapter, NX_ARG2_CRB_OFFSET, cmd->req.arg2); - NXWR32(adapter, NX_ARG3_CRB_OFFSET, arg3); + NXWR32(adapter, NX_ARG3_CRB_OFFSET, cmd->req.arg3); - NXWR32(adapter, NX_CDRP_CRB_OFFSET, NX_CDRP_FORM_CMD(cmd)); + NXWR32(adapter, NX_CDRP_CRB_OFFSET, NX_CDRP_FORM_CMD(cmd->req.cmd)); rsp = netxen_poll_rsp(adapter); @@ -83,8 +82,15 @@ netxen_issue_cmd(struct netxen_adapter *adapter, printk(KERN_ERR "%s: failed card response code:0x%x\n", netxen_nic_driver_name, rcode); + } else if (rsp == NX_CDRP_RSP_OK) { + if (cmd->rsp.arg2) + cmd->rsp.arg2 = NXRD32(adapter, NX_ARG2_CRB_OFFSET); + if (cmd->rsp.arg3) + cmd->rsp.arg3 = NXRD32(adapter, NX_ARG3_CRB_OFFSET); } + if (cmd->rsp.arg1) + cmd->rsp.arg1 = NXRD32(adapter, NX_ARG1_CRB_OFFSET); /* Release semaphore */ netxen_api_unlock(adapter); @@ -96,15 +102,16 @@ nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu) { u32 rcode = NX_RCODE_SUCCESS; struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + struct netxen_cmd_args cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.req.cmd = NX_CDRP_CMD_SET_MTU; + cmd.req.arg1 = recv_ctx->context_id; + cmd.req.arg2 = mtu; + cmd.req.arg3 = 0; if (recv_ctx->state == NX_HOST_CTX_STATE_ACTIVE) - rcode = netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - recv_ctx->context_id, - mtu, - 0, - NX_CDRP_CMD_SET_MTU); + netxen_issue_cmd(adapter, &cmd); if (rcode != NX_RCODE_SUCCESS) return -EIO; @@ -116,15 +123,14 @@ int nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter, u32 speed, u32 duplex, u32 autoneg) { - - return netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - speed, - duplex, - autoneg, - NX_CDRP_CMD_CONFIG_GBE_PORT); - + struct netxen_cmd_args cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.req.cmd = NX_CDRP_CMD_CONFIG_GBE_PORT; + cmd.req.arg1 = speed; + cmd.req.arg2 = duplex; + cmd.req.arg3 = autoneg; + return netxen_issue_cmd(adapter, &cmd); } static int @@ -139,6 +145,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) nx_cardrsp_sds_ring_t *prsp_sds; struct nx_host_rds_ring *rds_ring; struct nx_host_sds_ring *sds_ring; + struct netxen_cmd_args cmd; dma_addr_t hostrq_phys_addr, cardrsp_phys_addr; u64 phys_addr; @@ -218,13 +225,12 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) } phys_addr = hostrq_phys_addr; - err = netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - (u32)(phys_addr >> 32), - (u32)(phys_addr & 0xffffffff), - rq_size, - NX_CDRP_CMD_CREATE_RX_CTX); + memset(&cmd, 0, sizeof(cmd)); + cmd.req.arg1 = (u32)(phys_addr >> 32); + cmd.req.arg2 = (u32)(phys_addr & 0xffffffff); + cmd.req.arg3 = rq_size; + cmd.req.cmd = NX_CDRP_CMD_CREATE_RX_CTX; + err = netxen_issue_cmd(adapter, &cmd); if (err) { printk(KERN_WARNING "Failed to create rx ctx in firmware%d\n", err); @@ -273,15 +279,15 @@ static void nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + struct netxen_cmd_args cmd; - if (netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - recv_ctx->context_id, - NX_DESTROY_CTX_RESET, - 0, - NX_CDRP_CMD_DESTROY_RX_CTX)) { + memset(&cmd, 0, sizeof(cmd)); + cmd.req.arg1 = recv_ctx->context_id; + cmd.req.arg2 = NX_DESTROY_CTX_RESET; + cmd.req.arg3 = 0; + cmd.req.cmd = NX_CDRP_CMD_DESTROY_RX_CTX; + if (netxen_issue_cmd(adapter, &cmd)) { printk(KERN_WARNING "%s: Failed to destroy rx ctx in firmware\n", netxen_nic_driver_name); @@ -302,6 +308,7 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter) dma_addr_t rq_phys_addr, rsp_phys_addr; struct nx_host_tx_ring *tx_ring = adapter->tx_ring; struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + struct netxen_cmd_args cmd; rq_size = SIZEOF_HOSTRQ_TX(nx_hostrq_tx_ctx_t); rq_addr = pci_alloc_consistent(adapter->pdev, @@ -345,13 +352,12 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter) prq_cds->ring_size = cpu_to_le32(tx_ring->num_desc); phys_addr = rq_phys_addr; - err = netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - (u32)(phys_addr >> 32), - ((u32)phys_addr & 0xffffffff), - rq_size, - NX_CDRP_CMD_CREATE_TX_CTX); + memset(&cmd, 0, sizeof(cmd)); + cmd.req.arg1 = (u32)(phys_addr >> 32); + cmd.req.arg2 = ((u32)phys_addr & 0xffffffff); + cmd.req.arg3 = rq_size; + cmd.req.cmd = NX_CDRP_CMD_CREATE_TX_CTX; + err = netxen_issue_cmd(adapter, &cmd); if (err == NX_RCODE_SUCCESS) { temp = le32_to_cpu(prsp->cds_ring.host_producer_crb); @@ -380,14 +386,14 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter) static void nx_fw_cmd_destroy_tx_ctx(struct netxen_adapter *adapter) { - if (netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - adapter->tx_context_id, - NX_DESTROY_CTX_RESET, - 0, - NX_CDRP_CMD_DESTROY_TX_CTX)) { - + struct netxen_cmd_args cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.req.arg1 = adapter->tx_context_id; + cmd.req.arg2 = NX_DESTROY_CTX_RESET; + cmd.req.arg3 = 0; + cmd.req.cmd = NX_CDRP_CMD_DESTROY_TX_CTX; + if (netxen_issue_cmd(adapter, &cmd)) { printk(KERN_WARNING "%s: Failed to destroy tx ctx in firmware\n", netxen_nic_driver_name); @@ -398,34 +404,33 @@ int nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val) { u32 rcode; - - rcode = netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - reg, - 0, - 0, - NX_CDRP_CMD_READ_PHY); - + struct netxen_cmd_args cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.req.arg1 = reg; + cmd.req.arg2 = 0; + cmd.req.arg3 = 0; + cmd.req.cmd = NX_CDRP_CMD_READ_PHY; + cmd.rsp.arg1 = 1; + rcode = netxen_issue_cmd(adapter, &cmd); if (rcode != NX_RCODE_SUCCESS) return -EIO; - return NXRD32(adapter, NX_ARG1_CRB_OFFSET); + return cmd.rsp.arg1; } int nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val) { u32 rcode; - - rcode = netxen_issue_cmd(adapter, - adapter->ahw.pci_func, - NXHAL_VERSION, - reg, - val, - 0, - NX_CDRP_CMD_WRITE_PHY); - + struct netxen_cmd_args cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.req.arg1 = reg; + cmd.req.arg2 = val; + cmd.req.arg3 = 0; + cmd.req.cmd = NX_CDRP_CMD_WRITE_PHY; + rcode = netxen_issue_cmd(adapter, &cmd); if (rcode != NX_RCODE_SUCCESS) return -EIO; -- GitLab From 83f18a557c6d6cdc03c7821e0b596c8f8b7bdb9f Mon Sep 17 00:00:00 2001 From: Manish chopra Date: Fri, 3 Feb 2012 11:35:11 +0000 Subject: [PATCH 0344/1846] netxen_nic: fw dump support Signed-off-by: Manish Chopra Signed-off-by: David S. Miller --- .../net/ethernet/qlogic/netxen/netxen_nic.h | 421 +++++++++++- .../ethernet/qlogic/netxen/netxen_nic_ctx.c | 143 ++++ .../qlogic/netxen/netxen_nic_ethtool.c | 104 +++ .../ethernet/qlogic/netxen/netxen_nic_hw.c | 629 +++++++++++++++++- .../ethernet/qlogic/netxen/netxen_nic_init.c | 3 +- .../ethernet/qlogic/netxen/netxen_nic_main.c | 102 ++- 6 files changed, 1380 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h index 1b09ba172310..8a35430b2f8b 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h @@ -1154,6 +1154,7 @@ typedef struct { #define NETXEN_NIC_LRO_DISABLED 0x00 #define NETXEN_NIC_BRIDGE_ENABLED 0X10 #define NETXEN_NIC_DIAG_ENABLED 0x20 +#define NETXEN_FW_RESET_OWNER 0x40 #define NETXEN_IS_MSI_FAMILY(adapter) \ ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED)) @@ -1171,6 +1172,419 @@ typedef struct { #define __NX_DEV_UP 1 #define __NX_RESETTING 2 +/* Mini Coredump FW supported version */ +#define NX_MD_SUPPORT_MAJOR 4 +#define NX_MD_SUPPORT_MINOR 0 +#define NX_MD_SUPPORT_SUBVERSION 579 + +#define LSW(x) ((uint16_t)(x)) +#define LSD(x) ((uint32_t)((uint64_t)(x))) +#define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16)) + +/* Mini Coredump mask level */ +#define NX_DUMP_MASK_MIN 0x03 +#define NX_DUMP_MASK_DEF 0x1f +#define NX_DUMP_MASK_MAX 0xff + +/* Mini Coredump CDRP commands */ +#define NX_CDRP_CMD_TEMP_SIZE 0x0000002f +#define NX_CDRP_CMD_GET_TEMP_HDR 0x00000030 + + +#define NX_DUMP_STATE_ARRAY_LEN 16 +#define NX_DUMP_CAP_SIZE_ARRAY_LEN 8 + +/* Mini Coredump sysfs entries flags*/ +#define NX_FORCE_FW_DUMP_KEY 0xdeadfeed +#define NX_ENABLE_FW_DUMP 0xaddfeed +#define NX_DISABLE_FW_DUMP 0xbadfeed +#define NX_FORCE_FW_RESET 0xdeaddead + + +/* Flash read/write address */ +#define NX_FW_DUMP_REG1 0x00130060 +#define NX_FW_DUMP_REG2 0x001e0000 +#define NX_FLASH_SEM2_LK 0x0013C010 +#define NX_FLASH_SEM2_ULK 0x0013C014 +#define NX_FLASH_LOCK_ID 0x001B2100 +#define FLASH_ROM_WINDOW 0x42110030 +#define FLASH_ROM_DATA 0x42150000 + +/* Mini Coredump register read/write routine */ +#define NX_RD_DUMP_REG(addr, bar0, data) do { \ + writel((addr & 0xFFFF0000), (void __iomem *) (bar0 + \ + NX_FW_DUMP_REG1)); \ + readl((void __iomem *) (bar0 + NX_FW_DUMP_REG1)); \ + *data = readl((void __iomem *) (bar0 + NX_FW_DUMP_REG2 + \ + LSW(addr))); \ +} while (0) + +#define NX_WR_DUMP_REG(addr, bar0, data) do { \ + writel((addr & 0xFFFF0000), (void __iomem *) (bar0 + \ + NX_FW_DUMP_REG1)); \ + readl((void __iomem *) (bar0 + NX_FW_DUMP_REG1)); \ + writel(data, (void __iomem *) (bar0 + NX_FW_DUMP_REG2 + LSW(addr)));\ + readl((void __iomem *) (bar0 + NX_FW_DUMP_REG2 + LSW(addr))); \ +} while (0) + + +/* +Entry Type Defines +*/ + +#define RDNOP 0 +#define RDCRB 1 +#define RDMUX 2 +#define QUEUE 3 +#define BOARD 4 +#define RDSRE 5 +#define RDOCM 6 +#define PREGS 7 +#define L1DTG 8 +#define L1ITG 9 +#define CACHE 10 + +#define L1DAT 11 +#define L1INS 12 +#define RDSTK 13 +#define RDCON 14 + +#define L2DTG 21 +#define L2ITG 22 +#define L2DAT 23 +#define L2INS 24 +#define RDOC3 25 + +#define MEMBK 32 + +#define RDROM 71 +#define RDMEM 72 +#define RDMN 73 + +#define INFOR 81 +#define CNTRL 98 + +#define TLHDR 99 +#define RDEND 255 + +#define PRIMQ 103 +#define SQG2Q 104 +#define SQG3Q 105 + +/* +* Opcodes for Control Entries. +* These Flags are bit fields. +*/ +#define NX_DUMP_WCRB 0x01 +#define NX_DUMP_RWCRB 0x02 +#define NX_DUMP_ANDCRB 0x04 +#define NX_DUMP_ORCRB 0x08 +#define NX_DUMP_POLLCRB 0x10 +#define NX_DUMP_RD_SAVE 0x20 +#define NX_DUMP_WRT_SAVED 0x40 +#define NX_DUMP_MOD_SAVE_ST 0x80 + +/* Driver Flags */ +#define NX_DUMP_SKIP 0x80 /* driver skipped this entry */ +#define NX_DUMP_SIZE_ERR 0x40 /*entry size vs capture size mismatch*/ + +#define NX_PCI_READ_32(ADDR) readl((ADDR)) +#define NX_PCI_WRITE_32(DATA, ADDR) writel(DATA, (ADDR)) + + + +struct netxen_minidump { + u32 pos; /* position in the dump buffer */ + u8 fw_supports_md; /* FW supports Mini cordump */ + u8 has_valid_dump; /* indicates valid dump */ + u8 md_capture_mask; /* driver capture mask */ + u8 md_enabled; /* Turn Mini Coredump on/off */ + u32 md_dump_size; /* Total FW Mini Coredump size */ + u32 md_capture_size; /* FW dump capture size */ + u32 md_template_size; /* FW template size */ + u32 md_template_ver; /* FW template version */ + u64 md_timestamp; /* FW Mini dump timestamp */ + void *md_template; /* FW template will be stored */ + void *md_capture_buff; /* FW dump will be stored */ +}; + + + +struct netxen_minidump_template_hdr { + u32 entry_type; + u32 first_entry_offset; + u32 size_of_template; + u32 capture_mask; + u32 num_of_entries; + u32 version; + u32 driver_timestamp; + u32 checksum; + u32 driver_capture_mask; + u32 driver_info_word2; + u32 driver_info_word3; + u32 driver_info_word4; + u32 saved_state_array[NX_DUMP_STATE_ARRAY_LEN]; + u32 capture_size_array[NX_DUMP_CAP_SIZE_ARRAY_LEN]; + u32 rsvd[0]; +}; + +/* Common Entry Header: Common to All Entry Types */ +/* + * Driver Code is for driver to write some info about the entry. + * Currently not used. + */ + +struct netxen_common_entry_hdr { + u32 entry_type; + u32 entry_size; + u32 entry_capture_size; + union { + struct { + u8 entry_capture_mask; + u8 entry_code; + u8 driver_code; + u8 driver_flags; + }; + u32 entry_ctrl_word; + }; +}; + + +/* Generic Entry Including Header */ +struct netxen_minidump_entry { + struct netxen_common_entry_hdr hdr; + u32 entry_data00; + u32 entry_data01; + u32 entry_data02; + u32 entry_data03; + u32 entry_data04; + u32 entry_data05; + u32 entry_data06; + u32 entry_data07; +}; + +/* Read ROM Header */ +struct netxen_minidump_entry_rdrom { + struct netxen_common_entry_hdr h; + union { + struct { + u32 select_addr_reg; + }; + u32 rsvd_0; + }; + union { + struct { + u8 addr_stride; + u8 addr_cnt; + u16 data_size; + }; + u32 rsvd_1; + }; + union { + struct { + u32 op_count; + }; + u32 rsvd_2; + }; + union { + struct { + u32 read_addr_reg; + }; + u32 rsvd_3; + }; + union { + struct { + u32 write_mask; + }; + u32 rsvd_4; + }; + union { + struct { + u32 read_mask; + }; + u32 rsvd_5; + }; + u32 read_addr; + u32 read_data_size; +}; + + +/* Read CRB and Control Entry Header */ +struct netxen_minidump_entry_crb { + struct netxen_common_entry_hdr h; + u32 addr; + union { + struct { + u8 addr_stride; + u8 state_index_a; + u16 poll_timeout; + }; + u32 addr_cntrl; + }; + u32 data_size; + u32 op_count; + union { + struct { + u8 opcode; + u8 state_index_v; + u8 shl; + u8 shr; + }; + u32 control_value; + }; + u32 value_1; + u32 value_2; + u32 value_3; +}; + +/* Read Memory and MN Header */ +struct netxen_minidump_entry_rdmem { + struct netxen_common_entry_hdr h; + union { + struct { + u32 select_addr_reg; + }; + u32 rsvd_0; + }; + union { + struct { + u8 addr_stride; + u8 addr_cnt; + u16 data_size; + }; + u32 rsvd_1; + }; + union { + struct { + u32 op_count; + }; + u32 rsvd_2; + }; + union { + struct { + u32 read_addr_reg; + }; + u32 rsvd_3; + }; + union { + struct { + u32 cntrl_addr_reg; + }; + u32 rsvd_4; + }; + union { + struct { + u8 wr_byte0; + u8 wr_byte1; + u8 poll_mask; + u8 poll_cnt; + }; + u32 rsvd_5; + }; + u32 read_addr; + u32 read_data_size; +}; + +/* Read Cache L1 and L2 Header */ +struct netxen_minidump_entry_cache { + struct netxen_common_entry_hdr h; + u32 tag_reg_addr; + union { + struct { + u16 tag_value_stride; + u16 init_tag_value; + }; + u32 select_addr_cntrl; + }; + u32 data_size; + u32 op_count; + u32 control_addr; + union { + struct { + u16 write_value; + u8 poll_mask; + u8 poll_wait; + }; + u32 control_value; + }; + u32 read_addr; + union { + struct { + u8 read_addr_stride; + u8 read_addr_cnt; + u16 rsvd_1; + }; + u32 read_addr_cntrl; + }; +}; + +/* Read OCM Header */ +struct netxen_minidump_entry_rdocm { + struct netxen_common_entry_hdr h; + u32 rsvd_0; + union { + struct { + u32 rsvd_1; + }; + u32 select_addr_cntrl; + }; + u32 data_size; + u32 op_count; + u32 rsvd_2; + u32 rsvd_3; + u32 read_addr; + union { + struct { + u32 read_addr_stride; + }; + u32 read_addr_cntrl; + }; +}; + +/* Read MUX Header */ +struct netxen_minidump_entry_mux { + struct netxen_common_entry_hdr h; + u32 select_addr; + union { + struct { + u32 rsvd_0; + }; + u32 select_addr_cntrl; + }; + u32 data_size; + u32 op_count; + u32 select_value; + u32 select_value_stride; + u32 read_addr; + u32 rsvd_1; +}; + +/* Read Queue Header */ +struct netxen_minidump_entry_queue { + struct netxen_common_entry_hdr h; + u32 select_addr; + union { + struct { + u16 queue_id_stride; + u16 rsvd_0; + }; + u32 select_addr_cntrl; + }; + u32 data_size; + u32 op_count; + u32 rsvd_1; + u32 rsvd_2; + u32 read_addr; + union { + struct { + u8 read_addr_stride; + u8 read_addr_cnt; + u16 rsvd_3; + }; + u32 read_addr_cntrl; + }; +}; + struct netxen_dummy_dma { void *addr; dma_addr_t phys_addr; @@ -1275,6 +1689,8 @@ struct netxen_adapter { __le32 file_prd_off; /*File fw product offset*/ u32 fw_version; const struct firmware *fw; + struct netxen_minidump mdump; /* mdump ptr */ + int fw_mdump_rdy; /* for mdump ready */ }; int nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val); @@ -1377,13 +1793,16 @@ int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable); int netxen_config_bridged_mode(struct netxen_adapter *adapter, int enable); int netxen_send_lro_cleanup(struct netxen_adapter *adapter); - +int netxen_setup_minidump(struct netxen_adapter *adapter); +void netxen_dump_fw(struct netxen_adapter *adapter); void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, struct nx_host_tx_ring *tx_ring); /* Functions from netxen_nic_main.c */ int netxen_nic_reset_context(struct netxen_adapter *); +int nx_dev_request_reset(struct netxen_adapter *adapter); + /* * NetXen Board information */ diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c index d46e8cb394eb..8f89c05e0c70 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c @@ -83,6 +83,7 @@ netxen_issue_cmd(struct netxen_adapter *adapter, struct netxen_cmd_args *cmd) printk(KERN_ERR "%s: failed card response code:0x%x\n", netxen_nic_driver_name, rcode); } else if (rsp == NX_CDRP_RSP_OK) { + cmd->rsp.cmd = NX_RCODE_SUCCESS; if (cmd->rsp.arg2) cmd->rsp.arg2 = NXRD32(adapter, NX_ARG2_CRB_OFFSET); if (cmd->rsp.arg3) @@ -97,6 +98,148 @@ netxen_issue_cmd(struct netxen_adapter *adapter, struct netxen_cmd_args *cmd) return rcode; } +static int +netxen_get_minidump_template_size(struct netxen_adapter *adapter) +{ + struct netxen_cmd_args cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.req.cmd = NX_CDRP_CMD_TEMP_SIZE; + memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd)); + netxen_issue_cmd(adapter, &cmd); + if (cmd.rsp.cmd != NX_RCODE_SUCCESS) { + dev_info(&adapter->pdev->dev, + "Can't get template size %d\n", cmd.rsp.cmd); + return -EIO; + } + adapter->mdump.md_template_size = cmd.rsp.arg2; + adapter->mdump.md_template_ver = cmd.rsp.arg3; + return 0; +} + +static int +netxen_get_minidump_template(struct netxen_adapter *adapter) +{ + dma_addr_t md_template_addr; + void *addr; + u32 size; + struct netxen_cmd_args cmd; + size = adapter->mdump.md_template_size; + + if (size == 0) { + dev_err(&adapter->pdev->dev, "Can not capture Minidump " + "template. Invalid template size.\n"); + return NX_RCODE_INVALID_ARGS; + } + + addr = pci_alloc_consistent(adapter->pdev, size, &md_template_addr); + + if (!addr) { + dev_err(&adapter->pdev->dev, "Unable to allocate dmable memory for template.\n"); + return -ENOMEM; + } + + memset(addr, 0, size); + memset(&cmd, 0, sizeof(cmd)); + memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd)); + cmd.req.cmd = NX_CDRP_CMD_GET_TEMP_HDR; + cmd.req.arg1 = LSD(md_template_addr); + cmd.req.arg2 = MSD(md_template_addr); + cmd.req.arg3 |= size; + netxen_issue_cmd(adapter, &cmd); + + if ((cmd.rsp.cmd == NX_RCODE_SUCCESS) && (size == cmd.rsp.arg2)) { + memcpy(adapter->mdump.md_template, addr, size); + } else { + dev_err(&adapter->pdev->dev, "Failed to get minidump template, " + "err_code : %d, requested_size : %d, actual_size : %d\n ", + cmd.rsp.cmd, size, cmd.rsp.arg2); + } + pci_free_consistent(adapter->pdev, size, addr, md_template_addr); + return 0; +} + +static u32 +netxen_check_template_checksum(struct netxen_adapter *adapter) +{ + u64 sum = 0 ; + u32 *buff = adapter->mdump.md_template; + int count = adapter->mdump.md_template_size/sizeof(uint32_t) ; + + while (count-- > 0) + sum += *buff++ ; + while (sum >> 32) + sum = (sum & 0xFFFFFFFF) + (sum >> 32) ; + + return ~sum; +} + +int +netxen_setup_minidump(struct netxen_adapter *adapter) +{ + int err = 0, i; + u32 *template, *tmp_buf; + struct netxen_minidump_template_hdr *hdr; + err = netxen_get_minidump_template_size(adapter); + if (err) { + adapter->mdump.fw_supports_md = 0; + if ((err == NX_RCODE_CMD_INVALID) || + (err == NX_RCODE_CMD_NOT_IMPL)) { + dev_info(&adapter->pdev->dev, + "Flashed firmware version does not support minidump, " + "minimum version required is [ %u.%u.%u ].\n ", + NX_MD_SUPPORT_MAJOR, NX_MD_SUPPORT_MINOR, + NX_MD_SUPPORT_SUBVERSION); + } + return err; + } + + if (!adapter->mdump.md_template_size) { + dev_err(&adapter->pdev->dev, "Error : Invalid template size " + ",should be non-zero.\n"); + return -EIO; + } + adapter->mdump.md_template = + kmalloc(adapter->mdump.md_template_size, GFP_KERNEL); + + if (!adapter->mdump.md_template) { + dev_err(&adapter->pdev->dev, "Unable to allocate memory " + "for minidump template.\n"); + return -ENOMEM; + } + + err = netxen_get_minidump_template(adapter); + if (err) { + if (err == NX_RCODE_CMD_NOT_IMPL) + adapter->mdump.fw_supports_md = 0; + goto free_template; + } + + if (netxen_check_template_checksum(adapter)) { + dev_err(&adapter->pdev->dev, "Minidump template checksum Error\n"); + err = -EIO; + goto free_template; + } + + adapter->mdump.md_capture_mask = NX_DUMP_MASK_DEF; + tmp_buf = (u32 *) adapter->mdump.md_template; + template = (u32 *) adapter->mdump.md_template; + for (i = 0; i < adapter->mdump.md_template_size/sizeof(u32); i++) + *template++ = __le32_to_cpu(*tmp_buf++); + hdr = (struct netxen_minidump_template_hdr *) + adapter->mdump.md_template; + adapter->mdump.md_capture_buff = NULL; + adapter->mdump.fw_supports_md = 1; + adapter->mdump.md_enabled = 1; + + return err; + +free_template: + kfree(adapter->mdump.md_template); + adapter->mdump.md_template = NULL; + return err; +} + + int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu) { diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index 8a371985319f..3e73d35cceaa 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c @@ -812,6 +812,107 @@ static int netxen_get_intr_coalesce(struct net_device *netdev, return 0; } +static int +netxen_get_dump_flag(struct net_device *netdev, struct ethtool_dump *dump) +{ + struct netxen_adapter *adapter = netdev_priv(netdev); + struct netxen_minidump *mdump = &adapter->mdump; + if (adapter->fw_mdump_rdy) + dump->len = mdump->md_dump_size; + else + dump->len = 0; + dump->flag = mdump->md_capture_mask; + dump->version = adapter->fw_version; + return 0; +} + +static int +netxen_set_dump(struct net_device *netdev, struct ethtool_dump *val) +{ + int ret = 0; + struct netxen_adapter *adapter = netdev_priv(netdev); + struct netxen_minidump *mdump = &adapter->mdump; + + switch (val->flag) { + case NX_FORCE_FW_DUMP_KEY: + if (!mdump->md_enabled) + mdump->md_enabled = 1; + if (adapter->fw_mdump_rdy) { + netdev_info(netdev, "Previous dump not cleared, not forcing dump\n"); + return ret; + } + netdev_info(netdev, "Forcing a fw dump\n"); + nx_dev_request_reset(adapter); + break; + case NX_DISABLE_FW_DUMP: + if (mdump->md_enabled) { + netdev_info(netdev, "Disabling FW Dump\n"); + mdump->md_enabled = 0; + } + break; + case NX_ENABLE_FW_DUMP: + if (!mdump->md_enabled) { + netdev_info(netdev, "Enabling FW dump\n"); + mdump->md_enabled = 1; + } + break; + case NX_FORCE_FW_RESET: + netdev_info(netdev, "Forcing FW reset\n"); + nx_dev_request_reset(adapter); + adapter->flags &= ~NETXEN_FW_RESET_OWNER; + break; + default: + if (val->flag <= NX_DUMP_MASK_MAX && + val->flag >= NX_DUMP_MASK_MIN) { + mdump->md_capture_mask = val->flag & 0xff; + netdev_info(netdev, "Driver mask changed to: 0x%x\n", + mdump->md_capture_mask); + break; + } + netdev_info(netdev, + "Invalid dump level: 0x%x\n", val->flag); + return -EINVAL; + } + + return ret; +} + +static int +netxen_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump, + void *buffer) +{ + int i, copy_sz; + u32 *hdr_ptr, *data; + struct netxen_adapter *adapter = netdev_priv(netdev); + struct netxen_minidump *mdump = &adapter->mdump; + + + if (!adapter->fw_mdump_rdy) { + netdev_info(netdev, "Dump not available\n"); + return -EINVAL; + } + /* Copy template header first */ + copy_sz = mdump->md_template_size; + hdr_ptr = (u32 *) mdump->md_template; + data = buffer; + for (i = 0; i < copy_sz/sizeof(u32); i++) + *data++ = cpu_to_le32(*hdr_ptr++); + + /* Copy captured dump data */ + memcpy(buffer + copy_sz, + mdump->md_capture_buff + mdump->md_template_size, + mdump->md_capture_size); + dump->len = copy_sz + mdump->md_capture_size; + dump->flag = mdump->md_capture_mask; + + /* Free dump area once data has been captured */ + vfree(mdump->md_capture_buff); + mdump->md_capture_buff = NULL; + adapter->fw_mdump_rdy = 0; + netdev_info(netdev, "extracted the fw dump Successfully\n"); + return 0; +} + const struct ethtool_ops netxen_nic_ethtool_ops = { .get_settings = netxen_nic_get_settings, .set_settings = netxen_nic_set_settings, @@ -833,4 +934,7 @@ const struct ethtool_ops netxen_nic_ethtool_ops = { .get_sset_count = netxen_get_sset_count, .get_coalesce = netxen_get_intr_coalesce, .set_coalesce = netxen_set_intr_coalesce, + .get_dump_flag = netxen_get_dump_flag, + .get_dump_data = netxen_get_dump_data, + .set_dump = netxen_set_dump, }; diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c index 3f89e57cae50..0a8122851025 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c @@ -46,7 +46,6 @@ static void netxen_nic_io_write_128M(struct netxen_adapter *adapter, void __iomem *addr, u32 data); static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter, void __iomem *addr); - #ifndef readq static inline u64 readq(void __iomem *addr) { @@ -1974,3 +1973,631 @@ netxen_nic_wol_supported(struct netxen_adapter *adapter) return 0; } + +static u32 netxen_md_cntrl(struct netxen_adapter *adapter, + struct netxen_minidump_template_hdr *template_hdr, + struct netxen_minidump_entry_crb *crtEntry) +{ + int loop_cnt, i, rv = 0, timeout_flag; + u32 op_count, stride; + u32 opcode, read_value, addr; + unsigned long timeout, timeout_jiffies; + addr = crtEntry->addr; + op_count = crtEntry->op_count; + stride = crtEntry->addr_stride; + + for (loop_cnt = 0; loop_cnt < op_count; loop_cnt++) { + for (i = 0; i < sizeof(crtEntry->opcode) * 8; i++) { + opcode = (crtEntry->opcode & (0x1 << i)); + if (opcode) { + switch (opcode) { + case NX_DUMP_WCRB: + NX_WR_DUMP_REG(addr, + adapter->ahw.pci_base0, + crtEntry->value_1); + break; + case NX_DUMP_RWCRB: + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + NX_WR_DUMP_REG(addr, + adapter->ahw.pci_base0, + read_value); + break; + case NX_DUMP_ANDCRB: + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + read_value &= crtEntry->value_2; + NX_WR_DUMP_REG(addr, + adapter->ahw.pci_base0, + read_value); + break; + case NX_DUMP_ORCRB: + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + read_value |= crtEntry->value_3; + NX_WR_DUMP_REG(addr, + adapter->ahw.pci_base0, + read_value); + break; + case NX_DUMP_POLLCRB: + timeout = crtEntry->poll_timeout; + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + timeout_jiffies = + msecs_to_jiffies(timeout) + jiffies; + for (timeout_flag = 0; + !timeout_flag + && ((read_value & crtEntry->value_2) + != crtEntry->value_1);) { + if (time_after(jiffies, + timeout_jiffies)) + timeout_flag = 1; + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + } + + if (timeout_flag) { + dev_err(&adapter->pdev->dev, "%s : " + "Timeout in poll_crb control operation.\n" + , __func__); + return -1; + } + break; + case NX_DUMP_RD_SAVE: + /* Decide which address to use */ + if (crtEntry->state_index_a) + addr = + template_hdr->saved_state_array + [crtEntry->state_index_a]; + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + template_hdr->saved_state_array + [crtEntry->state_index_v] + = read_value; + break; + case NX_DUMP_WRT_SAVED: + /* Decide which value to use */ + if (crtEntry->state_index_v) + read_value = + template_hdr->saved_state_array + [crtEntry->state_index_v]; + else + read_value = crtEntry->value_1; + + /* Decide which address to use */ + if (crtEntry->state_index_a) + addr = + template_hdr->saved_state_array + [crtEntry->state_index_a]; + + NX_WR_DUMP_REG(addr, + adapter->ahw.pci_base0, + read_value); + break; + case NX_DUMP_MOD_SAVE_ST: + read_value = + template_hdr->saved_state_array + [crtEntry->state_index_v]; + read_value <<= crtEntry->shl; + read_value >>= crtEntry->shr; + if (crtEntry->value_2) + read_value &= + crtEntry->value_2; + read_value |= crtEntry->value_3; + read_value += crtEntry->value_1; + /* Write value back to state area.*/ + template_hdr->saved_state_array + [crtEntry->state_index_v] + = read_value; + break; + default: + rv = 1; + break; + } + } + } + addr = addr + stride; + } + return rv; +} + +/* Read memory or MN */ +static u32 +netxen_md_rdmem(struct netxen_adapter *adapter, + struct netxen_minidump_entry_rdmem + *memEntry, u64 *data_buff) +{ + u64 addr, value = 0; + int i = 0, loop_cnt; + + addr = (u64)memEntry->read_addr; + loop_cnt = memEntry->read_data_size; /* This is size in bytes */ + loop_cnt /= sizeof(value); + + for (i = 0; i < loop_cnt; i++) { + if (netxen_nic_pci_mem_read_2M(adapter, addr, &value)) + goto out; + *data_buff++ = value; + addr += sizeof(value); + } +out: + return i * sizeof(value); +} + +/* Read CRB operation */ +static u32 netxen_md_rd_crb(struct netxen_adapter *adapter, + struct netxen_minidump_entry_crb + *crbEntry, u32 *data_buff) +{ + int loop_cnt; + u32 op_count, addr, stride, value; + + addr = crbEntry->addr; + op_count = crbEntry->op_count; + stride = crbEntry->addr_stride; + + for (loop_cnt = 0; loop_cnt < op_count; loop_cnt++) { + NX_RD_DUMP_REG(addr, adapter->ahw.pci_base0, &value); + *data_buff++ = addr; + *data_buff++ = value; + addr = addr + stride; + } + return loop_cnt * (2 * sizeof(u32)); +} + +/* Read ROM */ +static u32 +netxen_md_rdrom(struct netxen_adapter *adapter, + struct netxen_minidump_entry_rdrom + *romEntry, u32 *data_buff) +{ + int i, count = 0; + u32 size, lck_val; + u32 val; + u32 fl_addr, waddr, raddr; + fl_addr = romEntry->read_addr; + size = romEntry->read_data_size/4; +lock_try: + lck_val = readl((void __iomem *)(adapter->ahw.pci_base0 + + NX_FLASH_SEM2_LK)); + if (!lck_val && count < MAX_CTL_CHECK) { + msleep(20); + count++; + goto lock_try; + } + writel(adapter->ahw.pci_func, (void __iomem *)(adapter->ahw.pci_base0 + + NX_FLASH_LOCK_ID)); + for (i = 0; i < size; i++) { + waddr = fl_addr & 0xFFFF0000; + NX_WR_DUMP_REG(FLASH_ROM_WINDOW, adapter->ahw.pci_base0, waddr); + raddr = FLASH_ROM_DATA + (fl_addr & 0x0000FFFF); + NX_RD_DUMP_REG(raddr, adapter->ahw.pci_base0, &val); + *data_buff++ = cpu_to_le32(val); + fl_addr += sizeof(val); + } + readl((void __iomem *)(adapter->ahw.pci_base0 + NX_FLASH_SEM2_ULK)); + return romEntry->read_data_size; +} + +/* Handle L2 Cache */ +static u32 +netxen_md_L2Cache(struct netxen_adapter *adapter, + struct netxen_minidump_entry_cache + *cacheEntry, u32 *data_buff) +{ + int loop_cnt, i, k, timeout_flag = 0; + u32 addr, read_addr, read_value, cntrl_addr, tag_reg_addr; + u32 tag_value, read_cnt; + u8 cntl_value_w, cntl_value_r; + unsigned long timeout, timeout_jiffies; + + loop_cnt = cacheEntry->op_count; + read_addr = cacheEntry->read_addr; + cntrl_addr = cacheEntry->control_addr; + cntl_value_w = (u32) cacheEntry->write_value; + tag_reg_addr = cacheEntry->tag_reg_addr; + tag_value = cacheEntry->init_tag_value; + read_cnt = cacheEntry->read_addr_cnt; + + for (i = 0; i < loop_cnt; i++) { + NX_WR_DUMP_REG(tag_reg_addr, adapter->ahw.pci_base0, tag_value); + if (cntl_value_w) + NX_WR_DUMP_REG(cntrl_addr, adapter->ahw.pci_base0, + (u32)cntl_value_w); + if (cacheEntry->poll_mask) { + timeout = cacheEntry->poll_wait; + NX_RD_DUMP_REG(cntrl_addr, adapter->ahw.pci_base0, + &cntl_value_r); + timeout_jiffies = msecs_to_jiffies(timeout) + jiffies; + for (timeout_flag = 0; !timeout_flag && + ((cntl_value_r & cacheEntry->poll_mask) != 0);) { + if (time_after(jiffies, timeout_jiffies)) + timeout_flag = 1; + NX_RD_DUMP_REG(cntrl_addr, + adapter->ahw.pci_base0, + &cntl_value_r); + } + if (timeout_flag) { + dev_err(&adapter->pdev->dev, + "Timeout in processing L2 Tag poll.\n"); + return -1; + } + } + addr = read_addr; + for (k = 0; k < read_cnt; k++) { + NX_RD_DUMP_REG(addr, adapter->ahw.pci_base0, + &read_value); + *data_buff++ = read_value; + addr += cacheEntry->read_addr_stride; + } + tag_value += cacheEntry->tag_value_stride; + } + return read_cnt * loop_cnt * sizeof(read_value); +} + + +/* Handle L1 Cache */ +static u32 netxen_md_L1Cache(struct netxen_adapter *adapter, + struct netxen_minidump_entry_cache + *cacheEntry, u32 *data_buff) +{ + int i, k, loop_cnt; + u32 addr, read_addr, read_value, cntrl_addr, tag_reg_addr; + u32 tag_value, read_cnt; + u8 cntl_value_w; + + loop_cnt = cacheEntry->op_count; + read_addr = cacheEntry->read_addr; + cntrl_addr = cacheEntry->control_addr; + cntl_value_w = (u32) cacheEntry->write_value; + tag_reg_addr = cacheEntry->tag_reg_addr; + tag_value = cacheEntry->init_tag_value; + read_cnt = cacheEntry->read_addr_cnt; + + for (i = 0; i < loop_cnt; i++) { + NX_WR_DUMP_REG(tag_reg_addr, adapter->ahw.pci_base0, tag_value); + NX_WR_DUMP_REG(cntrl_addr, adapter->ahw.pci_base0, + (u32) cntl_value_w); + addr = read_addr; + for (k = 0; k < read_cnt; k++) { + NX_RD_DUMP_REG(addr, + adapter->ahw.pci_base0, + &read_value); + *data_buff++ = read_value; + addr += cacheEntry->read_addr_stride; + } + tag_value += cacheEntry->tag_value_stride; + } + return read_cnt * loop_cnt * sizeof(read_value); +} + +/* Reading OCM memory */ +static u32 +netxen_md_rdocm(struct netxen_adapter *adapter, + struct netxen_minidump_entry_rdocm + *ocmEntry, u32 *data_buff) +{ + int i, loop_cnt; + u32 value; + void __iomem *addr; + addr = (ocmEntry->read_addr + adapter->ahw.pci_base0); + loop_cnt = ocmEntry->op_count; + + for (i = 0; i < loop_cnt; i++) { + value = readl(addr); + *data_buff++ = value; + addr += ocmEntry->read_addr_stride; + } + return i * sizeof(u32); +} + +/* Read MUX data */ +static u32 +netxen_md_rdmux(struct netxen_adapter *adapter, struct netxen_minidump_entry_mux + *muxEntry, u32 *data_buff) +{ + int loop_cnt = 0; + u32 read_addr, read_value, select_addr, sel_value; + + read_addr = muxEntry->read_addr; + sel_value = muxEntry->select_value; + select_addr = muxEntry->select_addr; + + for (loop_cnt = 0; loop_cnt < muxEntry->op_count; loop_cnt++) { + NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, sel_value); + NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0, &read_value); + *data_buff++ = sel_value; + *data_buff++ = read_value; + sel_value += muxEntry->select_value_stride; + } + return loop_cnt * (2 * sizeof(u32)); +} + +/* Handling Queue State Reads */ +static u32 +netxen_md_rdqueue(struct netxen_adapter *adapter, + struct netxen_minidump_entry_queue + *queueEntry, u32 *data_buff) +{ + int loop_cnt, k; + u32 queue_id, read_addr, read_value, read_stride, select_addr, read_cnt; + + read_cnt = queueEntry->read_addr_cnt; + read_stride = queueEntry->read_addr_stride; + select_addr = queueEntry->select_addr; + + for (loop_cnt = 0, queue_id = 0; loop_cnt < queueEntry->op_count; + loop_cnt++) { + NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id); + read_addr = queueEntry->read_addr; + for (k = 0; k < read_cnt; k--) { + NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0, + &read_value); + *data_buff++ = read_value; + read_addr += read_stride; + } + queue_id += queueEntry->queue_id_stride; + } + return loop_cnt * (read_cnt * sizeof(read_value)); +} + + +/* +* We catch an error where driver does not read +* as much data as we expect from the entry. +*/ + +static int netxen_md_entry_err_chk(struct netxen_adapter *adapter, + struct netxen_minidump_entry *entry, u32 esize) +{ + if (esize < 0) { + entry->hdr.driver_flags |= NX_DUMP_SKIP; + return esize; + } + if (esize != entry->hdr.entry_capture_size) { + entry->hdr.entry_capture_size = esize; + entry->hdr.driver_flags |= NX_DUMP_SIZE_ERR; + dev_info(&adapter->pdev->dev, + "Invalidate dump, Type:%d\tMask:%d\tSize:%dCap_size:%d\n", + entry->hdr.entry_type, entry->hdr.entry_capture_mask, + esize, entry->hdr.entry_capture_size); + dev_info(&adapter->pdev->dev, "Aborting further dump capture\n"); + } + return 0; +} + +static int netxen_parse_md_template(struct netxen_adapter *adapter) +{ + int num_of_entries, buff_level, e_cnt, esize; + int end_cnt = 0, rv = 0, sane_start = 0, sane_end = 0; + char *dbuff; + void *template_buff = adapter->mdump.md_template; + char *dump_buff = adapter->mdump.md_capture_buff; + int capture_mask = adapter->mdump.md_capture_mask; + struct netxen_minidump_template_hdr *template_hdr; + struct netxen_minidump_entry *entry; + + if ((capture_mask & 0x3) != 0x3) { + dev_err(&adapter->pdev->dev, "Capture mask %02x below minimum needed " + "for valid firmware dump\n", capture_mask); + return -EINVAL; + } + template_hdr = (struct netxen_minidump_template_hdr *) template_buff; + num_of_entries = template_hdr->num_of_entries; + entry = (struct netxen_minidump_entry *) ((char *) template_buff + + template_hdr->first_entry_offset); + memcpy(dump_buff, template_buff, adapter->mdump.md_template_size); + dump_buff = dump_buff + adapter->mdump.md_template_size; + + if (template_hdr->entry_type == TLHDR) + sane_start = 1; + + for (e_cnt = 0, buff_level = 0; e_cnt < num_of_entries; e_cnt++) { + if (!(entry->hdr.entry_capture_mask & capture_mask)) { + entry->hdr.driver_flags |= NX_DUMP_SKIP; + entry = (struct netxen_minidump_entry *) + ((char *) entry + entry->hdr.entry_size); + continue; + } + switch (entry->hdr.entry_type) { + case RDNOP: + entry->hdr.driver_flags |= NX_DUMP_SKIP; + break; + case RDEND: + entry->hdr.driver_flags |= NX_DUMP_SKIP; + if (!sane_end) + end_cnt = e_cnt; + sane_end += 1; + break; + case CNTRL: + rv = netxen_md_cntrl(adapter, + template_hdr, (void *)entry); + if (rv) + entry->hdr.driver_flags |= NX_DUMP_SKIP; + break; + case RDCRB: + dbuff = dump_buff + buff_level; + esize = netxen_md_rd_crb(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case RDMN: + case RDMEM: + dbuff = dump_buff + buff_level; + esize = netxen_md_rdmem(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case BOARD: + case RDROM: + dbuff = dump_buff + buff_level; + esize = netxen_md_rdrom(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case L2ITG: + case L2DTG: + case L2DAT: + case L2INS: + dbuff = dump_buff + buff_level; + esize = netxen_md_L2Cache(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case L1DAT: + case L1INS: + dbuff = dump_buff + buff_level; + esize = netxen_md_L1Cache(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case RDOCM: + dbuff = dump_buff + buff_level; + esize = netxen_md_rdocm(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case RDMUX: + dbuff = dump_buff + buff_level; + esize = netxen_md_rdmux(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + case QUEUE: + dbuff = dump_buff + buff_level; + esize = netxen_md_rdqueue(adapter, + (void *) entry, (void *) dbuff); + rv = netxen_md_entry_err_chk + (adapter, entry, esize); + if (rv < 0) + break; + buff_level += esize; + break; + default: + entry->hdr.driver_flags |= NX_DUMP_SKIP; + break; + } + /* Next entry in the template */ + entry = (struct netxen_minidump_entry *) + ((char *) entry + entry->hdr.entry_size); + } + if (!sane_start || sane_end > 1) { + dev_err(&adapter->pdev->dev, + "Firmware minidump template configuration error.\n"); + } + return 0; +} + +static int +netxen_collect_minidump(struct netxen_adapter *adapter) +{ + int ret = 0; + struct netxen_minidump_template_hdr *hdr; + struct timespec val; + hdr = (struct netxen_minidump_template_hdr *) + adapter->mdump.md_template; + hdr->driver_capture_mask = adapter->mdump.md_capture_mask; + jiffies_to_timespec(jiffies, &val); + hdr->driver_timestamp = (u32) val.tv_sec; + hdr->driver_info_word2 = adapter->fw_version; + hdr->driver_info_word3 = NXRD32(adapter, CRB_DRIVER_VERSION); + ret = netxen_parse_md_template(adapter); + if (ret) + return ret; + + return ret; +} + + +void +netxen_dump_fw(struct netxen_adapter *adapter) +{ + struct netxen_minidump_template_hdr *hdr; + int i, k, data_size = 0; + u32 capture_mask; + hdr = (struct netxen_minidump_template_hdr *) + adapter->mdump.md_template; + capture_mask = adapter->mdump.md_capture_mask; + + for (i = 0x2, k = 1; (i & NX_DUMP_MASK_MAX); i <<= 1, k++) { + if (i & capture_mask) + data_size += hdr->capture_size_array[k]; + } + if (!data_size) { + dev_err(&adapter->pdev->dev, + "Invalid cap sizes for capture_mask=0x%x\n", + adapter->mdump.md_capture_mask); + return; + } + adapter->mdump.md_capture_size = data_size; + adapter->mdump.md_dump_size = adapter->mdump.md_template_size + + adapter->mdump.md_capture_size; + if (!adapter->mdump.md_capture_buff) { + adapter->mdump.md_capture_buff = + vmalloc(adapter->mdump.md_dump_size); + if (!adapter->mdump.md_capture_buff) { + dev_info(&adapter->pdev->dev, + "Unable to allocate memory for minidump " + "capture_buffer(%d bytes).\n", + adapter->mdump.md_dump_size); + return; + } + memset(adapter->mdump.md_capture_buff, 0, + adapter->mdump.md_dump_size); + if (netxen_collect_minidump(adapter)) { + adapter->mdump.has_valid_dump = 0; + adapter->mdump.md_dump_size = 0; + vfree(adapter->mdump.md_capture_buff); + adapter->mdump.md_capture_buff = NULL; + dev_err(&adapter->pdev->dev, + "Error in collecting firmware minidump.\n"); + } else { + adapter->mdump.md_timestamp = jiffies; + adapter->mdump.has_valid_dump = 1; + adapter->fw_mdump_rdy = 1; + dev_info(&adapter->pdev->dev, "%s Successfully " + "collected fw dump.\n", adapter->netdev->name); + } + + } else { + dev_info(&adapter->pdev->dev, + "Cannot overwrite previously collected " + "firmware minidump.\n"); + adapter->fw_mdump_rdy = 1; + return; + } +} diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c index 094d26c51816..f69ac442c6a1 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c @@ -446,7 +446,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter) /* resetall */ netxen_rom_lock(adapter); - NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 0xffffffff); + NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 0xfeffffff); netxen_rom_unlock(adapter); if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { @@ -1347,7 +1347,6 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) do { val = NXRD32(adapter, CRB_CMDPEG_STATE); - switch (val) { case PHAN_INITIALIZE_COMPLETE: case PHAN_INITIALIZE_ACK: diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 64aa44d5dabb..f67655f3462c 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -82,7 +82,6 @@ static void netxen_create_sysfs_entries(struct netxen_adapter *adapter); static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter); static void netxen_create_diag_entries(struct netxen_adapter *adapter); static void netxen_remove_diag_entries(struct netxen_adapter *adapter); - static int nx_dev_request_aer(struct netxen_adapter *adapter); static int nx_decr_dev_ref_cnt(struct netxen_adapter *adapter); static int netxen_can_start_firmware(struct netxen_adapter *adapter); @@ -802,10 +801,10 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) static void netxen_check_options(struct netxen_adapter *adapter) { - u32 fw_major, fw_minor, fw_build; + u32 fw_major, fw_minor, fw_build, prev_fw_version; char brd_name[NETXEN_MAX_SHORT_NAME]; char serial_num[32]; - int i, offset, val; + int i, offset, val, err; int *ptr32; struct pci_dev *pdev = adapter->pdev; @@ -826,9 +825,22 @@ netxen_check_options(struct netxen_adapter *adapter) fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); - + prev_fw_version = adapter->fw_version; adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); + /* Get FW Mini Coredump template and store it */ + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { + if (adapter->mdump.md_template == NULL || + adapter->fw_version > prev_fw_version) { + kfree(adapter->mdump.md_template); + adapter->mdump.md_template = NULL; + err = netxen_setup_minidump(adapter); + if (err) + dev_err(&adapter->pdev->dev, + "Failed to setup minidump rcode = %d\n", err); + } + } + if (adapter->portnum == 0) { get_brd_name_by_type(adapter->ahw.board_type, brd_name); @@ -909,7 +921,12 @@ netxen_start_firmware(struct netxen_adapter *adapter) if (err) return err; - if (!netxen_can_start_firmware(adapter)) + err = netxen_can_start_firmware(adapter); + + if (err < 0) + return err; + + if (!err) goto wait_init; first_boot = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc)); @@ -1528,6 +1545,18 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return err; } +static +void netxen_cleanup_minidump(struct netxen_adapter *adapter) +{ + kfree(adapter->mdump.md_template); + adapter->mdump.md_template = NULL; + + if (adapter->mdump.md_capture_buff) { + vfree(adapter->mdump.md_capture_buff); + adapter->mdump.md_capture_buff = NULL; + } +} + static void __devexit netxen_nic_remove(struct pci_dev *pdev) { struct netxen_adapter *adapter; @@ -1563,8 +1592,10 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) netxen_release_firmware(adapter); - if (NX_IS_REVISION_P3(pdev->revision)) + if (NX_IS_REVISION_P3(pdev->revision)) { + netxen_cleanup_minidump(adapter); pci_disable_pcie_error_reporting(pdev); + } pci_release_regions(pdev); pci_disable_device(pdev); @@ -2316,7 +2347,7 @@ nx_incr_dev_ref_cnt(struct netxen_adapter *adapter) static int nx_decr_dev_ref_cnt(struct netxen_adapter *adapter) { - int count; + int count, state; if (netxen_api_lock(adapter)) return -EIO; @@ -2324,8 +2355,9 @@ nx_decr_dev_ref_cnt(struct netxen_adapter *adapter) WARN_ON(count == 0); NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count); + state = NXRD32(adapter, NX_CRB_DEV_STATE); - if (count == 0) + if (count == 0 && state != NX_DEV_FAILED) NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD); netxen_api_unlock(adapter); @@ -2354,7 +2386,7 @@ nx_dev_request_aer(struct netxen_adapter *adapter) return ret; } -static int +int nx_dev_request_reset(struct netxen_adapter *adapter) { u32 state; @@ -2365,10 +2397,11 @@ nx_dev_request_reset(struct netxen_adapter *adapter) state = NXRD32(adapter, NX_CRB_DEV_STATE); - if (state == NX_DEV_NEED_RESET) + if (state == NX_DEV_NEED_RESET || state == NX_DEV_FAILED) ret = 0; else if (state != NX_DEV_INITALIZING && state != NX_DEV_NEED_AER) { NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_RESET); + adapter->flags |= NETXEN_FW_RESET_OWNER; ret = 0; } @@ -2383,8 +2416,10 @@ netxen_can_start_firmware(struct netxen_adapter *adapter) int count; int can_start = 0; - if (netxen_api_lock(adapter)) - return 0; + if (netxen_api_lock(adapter)) { + nx_incr_dev_ref_cnt(adapter); + return -1; + } count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); @@ -2456,8 +2491,31 @@ netxen_fwinit_work(struct work_struct *work) struct netxen_adapter *adapter = container_of(work, struct netxen_adapter, fw_work.work); int dev_state; - + int count; dev_state = NXRD32(adapter, NX_CRB_DEV_STATE); + if (adapter->flags & NETXEN_FW_RESET_OWNER) { + count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); + WARN_ON(count == 0); + if (count == 1) { + if (adapter->mdump.md_enabled) { + rtnl_lock(); + netxen_dump_fw(adapter); + rtnl_unlock(); + } + adapter->flags &= ~NETXEN_FW_RESET_OWNER; + if (netxen_api_lock(adapter)) { + clear_bit(__NX_RESETTING, &adapter->state); + NXWR32(adapter, NX_CRB_DEV_STATE, + NX_DEV_FAILED); + return; + } + count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); + NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count); + NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD); + dev_state = NX_DEV_COLD; + netxen_api_unlock(adapter); + } + } switch (dev_state) { case NX_DEV_COLD: @@ -2470,11 +2528,9 @@ netxen_fwinit_work(struct work_struct *work) case NX_DEV_NEED_RESET: case NX_DEV_INITALIZING: - if (++adapter->fw_wait_cnt < FW_POLL_THRESH) { netxen_schedule_work(adapter, netxen_fwinit_work, 2 * FW_POLL_DELAY); return; - } case NX_DEV_FAILED: default: @@ -2482,6 +2538,15 @@ netxen_fwinit_work(struct work_struct *work) break; } + if (netxen_api_lock(adapter)) { + clear_bit(__NX_RESETTING, &adapter->state); + return; + } + NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_FAILED); + netxen_api_unlock(adapter); + dev_err(&adapter->pdev->dev, "%s: Device initialization Failed\n", + adapter->netdev->name); + clear_bit(__NX_RESETTING, &adapter->state); } @@ -2491,7 +2556,7 @@ netxen_detach_work(struct work_struct *work) struct netxen_adapter *adapter = container_of(work, struct netxen_adapter, fw_work.work); struct net_device *netdev = adapter->netdev; - int ref_cnt, delay; + int ref_cnt = 0, delay; u32 status; netif_device_detach(netdev); @@ -2510,7 +2575,8 @@ netxen_detach_work(struct work_struct *work) if (adapter->temp == NX_TEMP_PANIC) goto err_ret; - ref_cnt = nx_decr_dev_ref_cnt(adapter); + if (!(adapter->flags & NETXEN_FW_RESET_OWNER)) + ref_cnt = nx_decr_dev_ref_cnt(adapter); if (ref_cnt == -EIO) goto err_ret; @@ -2550,7 +2616,7 @@ netxen_check_health(struct netxen_adapter *adapter) * Send request to destroy context in case of tx timeout only * and doesn't required in case of Fw hang */ - if (state == NX_DEV_NEED_RESET) { + if (state == NX_DEV_NEED_RESET || state == NX_DEV_FAILED) { adapter->need_fw_reset = 1; if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) goto detach; -- GitLab From db608c129b5258dbdff9c221857a95bc2dc1128e Mon Sep 17 00:00:00 2001 From: Sritej Velaga Date: Fri, 3 Feb 2012 11:35:12 +0000 Subject: [PATCH 0345/1846] netxen_nic: Fix phy link status Pass the adapter phy link status to the caller. Signed-off-by: Sritej Velaga Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c index 8f89c05e0c70..f3c0057a802b 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c @@ -559,7 +559,11 @@ nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val) if (rcode != NX_RCODE_SUCCESS) return -EIO; - return cmd.rsp.arg1; + if (val == NULL) + return -EIO; + + *val = cmd.rsp.arg1; + return 0; } int -- GitLab From 5471aed0259298e4e258b8a9e403ebdf88ebcd56 Mon Sep 17 00:00:00 2001 From: Sritej Velaga Date: Fri, 3 Feb 2012 11:35:13 +0000 Subject: [PATCH 0346/1846] netxen_nic: Error logging on firmware hang Log states of essential registers on firmware hang detection. Signed-off-by: Sritej Velaga Signed-off-by: David S. Miller --- .../ethernet/qlogic/netxen/netxen_nic_hdr.h | 1 + .../ethernet/qlogic/netxen/netxen_nic_main.c | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h index dc1967c1f312..b1a897cd9a8d 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h @@ -969,6 +969,7 @@ enum { #define NX_RCODE_FATAL_ERROR 0x80000000 #define NX_FWERROR_PEGNUM(code) ((code) & 0xff) #define NX_FWERROR_CODE(code) ((code >> 8) & 0xfffff) +#define NX_FWERROR_PEGSTAT1(code) ((code >> 8) & 0x1fffff) #define FW_POLL_DELAY (2 * HZ) #define FW_FAIL_THRESH 3 diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index f67655f3462c..f517c16bfa3f 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -2596,6 +2596,7 @@ static int netxen_check_health(struct netxen_adapter *adapter) { u32 state, heartbit; + u32 peg_status; struct net_device *netdev = adapter->netdev; state = NXRD32(adapter, NX_CRB_DEV_STATE); @@ -2642,8 +2643,24 @@ netxen_check_health(struct netxen_adapter *adapter) clear_bit(__NX_FW_ATTACHED, &adapter->state); - dev_info(&netdev->dev, "firmware hang detected\n"); - + dev_err(&netdev->dev, "firmware hang detected\n"); + peg_status = NXRD32(adapter, NETXEN_PEG_HALT_STATUS1); + dev_err(&adapter->pdev->dev, "Dumping hw/fw registers\n" + "PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,\n" + "PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,\n" + "PEG_NET_2_PC: 0x%x, PEG_NET_3_PC: 0x%x,\n" + "PEG_NET_4_PC: 0x%x\n", + peg_status, + NXRD32(adapter, NETXEN_PEG_HALT_STATUS2), + NXRD32(adapter, NETXEN_CRB_PEG_NET_0 + 0x3c), + NXRD32(adapter, NETXEN_CRB_PEG_NET_1 + 0x3c), + NXRD32(adapter, NETXEN_CRB_PEG_NET_2 + 0x3c), + NXRD32(adapter, NETXEN_CRB_PEG_NET_3 + 0x3c), + NXRD32(adapter, NETXEN_CRB_PEG_NET_4 + 0x3c)); + if (NX_FWERROR_PEGSTAT1(peg_status) == 0x67) + dev_err(&adapter->pdev->dev, + "Firmware aborted with error code 0x00006700. " + "Device is being reset.\n"); detach: if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && !test_and_set_bit(__NX_RESETTING, &adapter->state)) -- GitLab From b8c30812b479a53b717ad665728df55d30f784d5 Mon Sep 17 00:00:00 2001 From: Rajesh Borundia Date: Fri, 3 Feb 2012 11:35:14 +0000 Subject: [PATCH 0347/1846] netxen: Fix a panic during driver unload in device_remove_file o Pass adapter->pdev->dev instead of netdev->dev Signed-off-by: Rajesh Borundia Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index f517c16bfa3f..8dc4a134dece 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -2930,13 +2930,12 @@ static struct bin_attribute bin_attr_mem = { static void netxen_create_sysfs_entries(struct netxen_adapter *adapter) { - struct net_device *netdev = adapter->netdev; - struct device *dev = &netdev->dev; + struct device *dev = &adapter->pdev->dev; if (adapter->capabilities & NX_FW_CAPABILITY_BDG) { /* bridged_mode control */ if (device_create_file(dev, &dev_attr_bridged_mode)) { - dev_warn(&netdev->dev, + dev_warn(dev, "failed to create bridged_mode sysfs entry\n"); } } @@ -2945,8 +2944,7 @@ netxen_create_sysfs_entries(struct netxen_adapter *adapter) static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter) { - struct net_device *netdev = adapter->netdev; - struct device *dev = &netdev->dev; + struct device *dev = &adapter->pdev->dev; if (adapter->capabilities & NX_FW_CAPABILITY_BDG) device_remove_file(dev, &dev_attr_bridged_mode); -- GitLab From 34d6fde187f169a1b155d091158f97ab34d93bab Mon Sep 17 00:00:00 2001 From: Sony Chacko Date: Fri, 3 Feb 2012 11:35:15 +0000 Subject: [PATCH 0348/1846] netxen: report valid speed and duplex status when link is down o Update version to 4.0.78 Signed-off-by: Sony Chacko Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/netxen/netxen_nic.h | 4 ++-- drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h index 8a35430b2f8b..2eeac32f7fdd 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h @@ -53,8 +53,8 @@ #define _NETXEN_NIC_LINUX_MAJOR 4 #define _NETXEN_NIC_LINUX_MINOR 0 -#define _NETXEN_NIC_LINUX_SUBVERSION 77 -#define NETXEN_NIC_LINUX_VERSIONID "4.0.77" +#define _NETXEN_NIC_LINUX_SUBVERSION 78 +#define NETXEN_NIC_LINUX_VERSIONID "4.0.78" #define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) #define _major(v) (((v) >> 24) & 0xff) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c index 3e73d35cceaa..8c39299331a2 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c @@ -248,6 +248,11 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) } } + if (!netif_running(dev) || !adapter->ahw.linkup) { + ecmd->duplex = DUPLEX_UNKNOWN; + ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); + } + return 0; } -- GitLab From 646779f1b4ade4acac6b49dbfa8be84a98ab85b4 Mon Sep 17 00:00:00 2001 From: Sritej Velaga Date: Fri, 3 Feb 2012 13:45:41 +0000 Subject: [PATCH 0349/1846] qlcnic: Stop pause ctrl frames on fw hang. When firmware hang is detected, fw should stop sending pause control frames. Signed-off-by: Sritej Velaga Signed-off-by: Sony Chacko Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 7bfdf57f4b76..a47c70b09342 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -2999,8 +2999,18 @@ qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter) void qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) { - u32 state; - + u32 state, xg_val = 0, gb_val = 0; + + qlcnic_xg_set_xg0_mask(xg_val); + qlcnic_xg_set_xg1_mask(xg_val); + QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, xg_val); + qlcnic_gb_set_gb0_mask(gb_val); + qlcnic_gb_set_gb1_mask(gb_val); + qlcnic_gb_set_gb2_mask(gb_val); + qlcnic_gb_set_gb3_mask(gb_val); + QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, gb_val); + dev_info(&adapter->pdev->dev, "Pause control frames disabled" + " on all ports\n"); adapter->need_fw_reset = 1; if (qlcnic_api_lock(adapter)) return; -- GitLab From 476a4b6d2543f0d9fa5205e0c25ebcd7973337bd Mon Sep 17 00:00:00 2001 From: Sony Chacko Date: Fri, 3 Feb 2012 13:45:42 +0000 Subject: [PATCH 0350/1846] qlcnic: report valid speed and duplex status when link is down Report valid link statistics when link is down. Signed-off-by: Sony Chacko Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 7 ++----- drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c | 8 +++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index cc228cf3d84b..6b2cf8bd16c3 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c @@ -155,7 +155,6 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct qlcnic_adapter *adapter = netdev_priv(dev); int check_sfp_module = 0; - u16 pcifn = adapter->ahw->pci_func; /* read which mode */ if (adapter->ahw->port_type == QLCNIC_GBE) { @@ -194,10 +193,8 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) goto skip; } - val = QLCRD32(adapter, P3P_LINK_SPEED_REG(pcifn)); - ethtool_cmd_speed_set(ecmd, P3P_LINK_SPEED_MHZ * - P3P_LINK_SPEED_VAL(pcifn, val)); - ecmd->duplex = DUPLEX_FULL; + ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); + ecmd->duplex = DUPLEX_UNKNOWN; ecmd->autoneg = AUTONEG_DISABLE; } else return -EIO; diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c index 38669583840c..41d85efee422 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c @@ -1369,7 +1369,13 @@ qlcnic_handle_linkevent(struct qlcnic_adapter *adapter, adapter->module_type = module; adapter->link_autoneg = autoneg; - adapter->link_speed = link_speed; + + if (link_status) { + adapter->link_speed = link_speed; + } else { + adapter->link_speed = SPEED_UNKNOWN; + adapter->link_duplex = DUPLEX_UNKNOWN; + } } static void -- GitLab From 97048a1f2b2f0ca2b2f690b551d5e97eeb94a0e9 Mon Sep 17 00:00:00 2001 From: Sritej Velaga Date: Fri, 3 Feb 2012 13:45:43 +0000 Subject: [PATCH 0351/1846] qlcnic: Fix firmware abort code check. Check bits 8-28 of peg_halt status register for firmware abort code. Signed-off-by: Sritej Velaga Signed-off-by: Sony Chacko Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index a47c70b09342..dba95311a462 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -3159,7 +3159,7 @@ qlcnic_check_health(struct qlcnic_adapter *adapter) QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c), QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c)); peg_status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1); - if (LSW(MSB(peg_status)) == 0x67) + if (QLCNIC_FWERROR_CODE(peg_status) == 0x67) dev_err(&adapter->pdev->dev, "Firmware aborted with error code 0x00006700. " "Device is being reset.\n"); -- GitLab From c47884e4551cdea35f5bed60d0ae53d9b6c73dc2 Mon Sep 17 00:00:00 2001 From: Manish chopra Date: Fri, 3 Feb 2012 13:45:44 +0000 Subject: [PATCH 0352/1846] qlcnic: Fix API unlock Log dump status. Remove unmatched qlcnic_api_unlock call. Update version to 5.0.26. Signed-off-by: Manish Chopra Signed-off-by: Sony Chacko Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index 60976fc4ccc6..2b5af22419a5 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h @@ -37,7 +37,7 @@ #define _QLCNIC_LINUX_MAJOR 5 #define _QLCNIC_LINUX_MINOR 0 #define _QLCNIC_LINUX_SUBVERSION 25 -#define QLCNIC_LINUX_VERSIONID "5.0.25" +#define QLCNIC_LINUX_VERSIONID "5.0.26" #define QLCNIC_DRV_IDC_VER 0x01 #define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 6b2cf8bd16c3..30dcbfba8f24 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c @@ -1152,7 +1152,6 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump, if (!fw_dump->clr) { netdev_info(netdev, "Dump not available\n"); - qlcnic_api_unlock(adapter); return -EINVAL; } /* Copy template header first */ @@ -1171,7 +1170,7 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump, vfree(fw_dump->data); fw_dump->data = NULL; fw_dump->clr = 0; - + netdev_info(netdev, "extracted the FW dump Successfully\n"); return 0; } @@ -1189,7 +1188,7 @@ qlcnic_set_dump(struct net_device *netdev, struct ethtool_dump *val) return ret; } if (fw_dump->clr) { - dev_info(&adapter->pdev->dev, + netdev_info(netdev, "Previous dump not cleared, not forcing dump\n"); return ret; } -- GitLab From 97bf2262e7f8177706ecdac897be165c0b455c6f Mon Sep 17 00:00:00 2001 From: Sritej Velaga Date: Fri, 3 Feb 2012 14:06:48 +0000 Subject: [PATCH 0353/1846] qlge: Updating Schultz LICENSE.qlge file. Signed-off-by: Sritej Velaga Signed-off-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- Documentation/networking/LICENSE.qlge | 328 ++++++++++++++++++++++---- 1 file changed, 285 insertions(+), 43 deletions(-) diff --git a/Documentation/networking/LICENSE.qlge b/Documentation/networking/LICENSE.qlge index 123b6edd7f18..ce64e4d15b21 100644 --- a/Documentation/networking/LICENSE.qlge +++ b/Documentation/networking/LICENSE.qlge @@ -1,46 +1,288 @@ -Copyright (c) 2003-2008 QLogic Corporation -QLogic Linux Networking HBA Driver +Copyright (c) 2003-2011 QLogic Corporation +QLogic Linux qlge NIC Driver -This program includes a device driver for Linux 2.6 that may be -distributed with QLogic hardware specific firmware binary file. You may modify and redistribute the device driver code under the -GNU General Public License as published by the Free Software -Foundation (version 2 or a later version). - -You may redistribute the hardware specific firmware binary file -under the following terms: - - 1. Redistribution of source code (only if applicable), - must retain the above copyright notice, this list of - conditions and the following disclaimer. - - 2. Redistribution 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. - - 3. The name of QLogic Corporation may not be used to - endorse or promote products derived from this software - without specific prior written permission - -REGARDLESS OF WHAT LICENSING MECHANISM IS USED OR APPLICABLE, -THIS PROGRAM IS PROVIDED BY QLOGIC CORPORATION "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 AUTHOR -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. - -USER ACKNOWLEDGES AND AGREES THAT USE OF THIS PROGRAM WILL NOT -CREATE OR GIVE GROUNDS FOR A LICENSE BY IMPLICATION, ESTOPPEL, OR -OTHERWISE IN ANY INTELLECTUAL PROPERTY RIGHTS (PATENT, COPYRIGHT, -TRADE SECRET, MASK WORK, OR OTHER PROPRIETARY RIGHT) EMBODIED IN -ANY OTHER QLOGIC HARDWARE OR SOFTWARE EITHER SOLELY OR IN -COMBINATION WITH THIS PROGRAM. +GNU General Public License (a copy of which is attached hereto as +Exhibit A) published by the Free Software Foundation (version 2). + +EXHIBIT A + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. -- GitLab From e02ef3311ae7329335d7c2b954b3988f7628a109 Mon Sep 17 00:00:00 2001 From: Jitendra Kalsaria Date: Fri, 3 Feb 2012 14:06:49 +0000 Subject: [PATCH 0354/1846] qlge: Fixed invalid reference to ip header we have copied skb into addr(page), skb->data doesn't contain ip header information. Signed-off-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlge/qlge_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index b54898737284..582b23746876 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c @@ -1576,13 +1576,14 @@ static void ql_process_mac_rx_page(struct ql_adapter *qdev, } else if ((ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) && (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_V4)) { /* Unfragmented ipv4 UDP frame. */ - struct iphdr *iph = (struct iphdr *) skb->data; + struct iphdr *iph = + (struct iphdr *) ((u8 *)addr + ETH_HLEN); if (!(iph->frag_off & cpu_to_be16(IP_MF|IP_OFFSET))) { skb->ip_summed = CHECKSUM_UNNECESSARY; netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "TCP checksum done!\n"); + "UDP checksum done!\n"); } } } @@ -1690,7 +1691,7 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, skb->ip_summed = CHECKSUM_UNNECESSARY; netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "TCP checksum done!\n"); + "UDP checksum done!\n"); } } } -- GitLab From 19257f5a1a20ceacb49a474ce39108f75ea51886 Mon Sep 17 00:00:00 2001 From: Jitendra Kalsaria Date: Fri, 3 Feb 2012 14:06:50 +0000 Subject: [PATCH 0355/1846] qlge: Removing needless print's which are not Signed-off-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlge/qlge_main.c | 71 +------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index 582b23746876..af12e80975d1 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c @@ -375,13 +375,6 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type, u32 lower = (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) | (addr[5]); - - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Adding %s address %pM at index %d in the CAM.\n", - type == MAC_ADDR_TYPE_MULTI_MAC ? - "MULTICAST" : "UNICAST", - addr, index); - status = ql_wait_reg_rdy(qdev, MAC_ADDR_IDX, MAC_ADDR_MW, 0); @@ -430,12 +423,6 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type, * addressing. It's either MAC_ADDR_E on or off. * That's bit-27 we're talking about. */ - netif_info(qdev, ifup, qdev->ndev, - "%s VLAN ID %d %s the CAM.\n", - enable_bit ? "Adding" : "Removing", - index, - enable_bit ? "to" : "from"); - status = ql_wait_reg_rdy(qdev, MAC_ADDR_IDX, MAC_ADDR_MW, 0); @@ -535,28 +522,6 @@ static int ql_set_routing_reg(struct ql_adapter *qdev, u32 index, u32 mask, int status = -EINVAL; /* Return error if no mask match. */ u32 value = 0; - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "%s %s mask %s the routing reg.\n", - enable ? "Adding" : "Removing", - index == RT_IDX_ALL_ERR_SLOT ? "MAC ERROR/ALL ERROR" : - index == RT_IDX_IP_CSUM_ERR_SLOT ? "IP CSUM ERROR" : - index == RT_IDX_TCP_UDP_CSUM_ERR_SLOT ? "TCP/UDP CSUM ERROR" : - index == RT_IDX_BCAST_SLOT ? "BROADCAST" : - index == RT_IDX_MCAST_MATCH_SLOT ? "MULTICAST MATCH" : - index == RT_IDX_ALLMULTI_SLOT ? "ALL MULTICAST MATCH" : - index == RT_IDX_UNUSED6_SLOT ? "UNUSED6" : - index == RT_IDX_UNUSED7_SLOT ? "UNUSED7" : - index == RT_IDX_RSS_MATCH_SLOT ? "RSS ALL/IPV4 MATCH" : - index == RT_IDX_RSS_IPV6_SLOT ? "RSS IPV6" : - index == RT_IDX_RSS_TCP4_SLOT ? "RSS TCP4" : - index == RT_IDX_RSS_TCP6_SLOT ? "RSS TCP6" : - index == RT_IDX_CAM_HIT_SLOT ? "CAM HIT" : - index == RT_IDX_UNUSED013 ? "UNUSED13" : - index == RT_IDX_UNUSED014 ? "UNUSED14" : - index == RT_IDX_PROMISCUOUS_SLOT ? "PROMISCUOUS" : - "(Bad index != RT_IDX)", - enable ? "to" : "from"); - switch (mask) { case RT_IDX_CAM_HIT: { @@ -2313,13 +2278,9 @@ static void qlge_vlan_mode(struct net_device *ndev, netdev_features_t features) struct ql_adapter *qdev = netdev_priv(ndev); if (features & NETIF_F_HW_VLAN_RX) { - netif_printk(qdev, ifup, KERN_DEBUG, ndev, - "Turning on VLAN in NIC_RCV_CFG.\n"); ql_write32(qdev, NIC_RCV_CFG, NIC_RCV_CFG_VLAN_MASK | NIC_RCV_CFG_VLAN_MATCH_AND_NON); } else { - netif_printk(qdev, ifup, KERN_DEBUG, ndev, - "Turning off VLAN in NIC_RCV_CFG.\n"); ql_write32(qdev, NIC_RCV_CFG, NIC_RCV_CFG_VLAN_MASK); } } @@ -3184,8 +3145,6 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, "Invalid rx_ring->type = %d.\n", rx_ring->type); } - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Initializing rx work queue.\n"); err = ql_write_cfg(qdev, cqicb, sizeof(struct cqicb), CFG_LCQ, rx_ring->cq_id); if (err) { @@ -3238,8 +3197,6 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring) netif_err(qdev, ifup, qdev->ndev, "Failed to load tx_ring.\n"); return err; } - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Successfully loaded WQICB.\n"); return err; } @@ -3489,12 +3446,8 @@ static void ql_free_irq(struct ql_adapter *qdev) if (test_bit(QL_MSIX_ENABLED, &qdev->flags)) { free_irq(qdev->msi_x_entry[i].vector, &qdev->rx_ring[i]); - netif_printk(qdev, ifdown, KERN_DEBUG, qdev->ndev, - "freeing msix interrupt %d.\n", i); } else { free_irq(qdev->pdev->irq, &qdev->rx_ring[0]); - netif_printk(qdev, ifdown, KERN_DEBUG, qdev->ndev, - "freeing msi interrupt %d.\n", i); } } } @@ -3523,17 +3476,6 @@ static int ql_request_irq(struct ql_adapter *qdev) "Failed request for MSIX interrupt %d.\n", i); goto err_irq; - } else { - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Hooked intr %d, queue type %s, with name %s.\n", - i, - qdev->rx_ring[i].type == DEFAULT_Q ? - "DEFAULT_Q" : - qdev->rx_ring[i].type == TX_Q ? - "TX_Q" : - qdev->rx_ring[i].type == RX_Q ? - "RX_Q" : "", - intr_context->name); } } else { netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, @@ -3603,15 +3545,11 @@ static int ql_start_rss(struct ql_adapter *qdev) memcpy((void *)&ricb->ipv6_hash_key[0], init_hash_seed, 40); memcpy((void *)&ricb->ipv4_hash_key[0], init_hash_seed, 16); - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, "Initializing RSS.\n"); - status = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0); if (status) { netif_err(qdev, ifup, qdev->ndev, "Failed to load RICB.\n"); return status; } - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Successfully loaded RICB.\n"); return status; } @@ -3818,11 +3756,8 @@ static int ql_adapter_initialize(struct ql_adapter *qdev) } /* Start NAPI for the RSS queues. */ - for (i = 0; i < qdev->rss_ring_count; i++) { - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Enabling NAPI for rx_ring[%d].\n", i); + for (i = 0; i < qdev->rss_ring_count; i++) napi_enable(&qdev->rx_ring[i].napi); - } return status; } @@ -4122,10 +4057,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->lbq_size = rx_ring->lbq_len * sizeof(__le64); rx_ring->lbq_buf_size = (u16)lbq_buf_len; - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "lbq_buf_size %d, order = %d\n", - rx_ring->lbq_buf_size, - qdev->lbq_buf_order); rx_ring->sbq_len = NUM_SMALL_BUFFERS; rx_ring->sbq_size = rx_ring->sbq_len * sizeof(__le64); -- GitLab From 81f25d96f1c9fa116f9c6f06ae490c2f8fa5ebaf Mon Sep 17 00:00:00 2001 From: Jitendra Kalsaria Date: Fri, 3 Feb 2012 14:06:51 +0000 Subject: [PATCH 0356/1846] qlge: Fix memory leak in the process of refill Driver was leaking memory when page allocation failures occurs. Signed-off-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlge/qlge_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index af12e80975d1..49343ec21c82 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c @@ -1143,14 +1143,16 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) int i; while (rx_ring->lbq_free_cnt > 32) { - for (i = 0; i < 16; i++) { + for (i = (rx_ring->lbq_clean_idx % 16); i < 16; i++) { netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "lbq: try cleaning clean_idx = %d.\n", clean_idx); lbq_desc = &rx_ring->lbq[clean_idx]; if (ql_get_next_chunk(qdev, rx_ring, lbq_desc)) { + rx_ring->lbq_clean_idx = clean_idx; netif_err(qdev, ifup, qdev->ndev, - "Could not get a page chunk.\n"); + "Could not get a page chunk, i=%d, clean_idx =%d .\n", + i, clean_idx); return; } @@ -1195,7 +1197,7 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) int i; while (rx_ring->sbq_free_cnt > 16) { - for (i = 0; i < 16; i++) { + for (i = (rx_ring->sbq_clean_idx % 16); i < 16; i++) { sbq_desc = &rx_ring->sbq[clean_idx]; netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "sbq: try cleaning clean_idx = %d.\n", -- GitLab From dc4790a9ba3536384123f50ff21a219bc60c9c92 Mon Sep 17 00:00:00 2001 From: Jitendra Kalsaria Date: Fri, 3 Feb 2012 14:06:52 +0000 Subject: [PATCH 0357/1846] qlge: Bumped driver version to 1.00.00.30. Signed-off-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qlge/qlge.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qlge/qlge.h b/drivers/net/ethernet/qlogic/qlge/qlge.h index b8478aab050e..5a639df33f18 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge.h +++ b/drivers/net/ethernet/qlogic/qlge/qlge.h @@ -18,7 +18,7 @@ */ #define DRV_NAME "qlge" #define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver " -#define DRV_VERSION "v1.00.00.29.00.00-01" +#define DRV_VERSION "v1.00.00.30.00.00-01" #define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */ -- GitLab From 63da93d932af04cf80507b110afe894a8a8d1f90 Mon Sep 17 00:00:00 2001 From: Neel Patel Date: Fri, 3 Feb 2012 08:25:14 +0000 Subject: [PATCH 0358/1846] enic: Enable support for multiple hardware receive queues This patch enables support for multiple receive queues. If multiple receive queues are used ingress traffic is hashed into one of the receive queues based on IP or TCP or both headers. The max number of supported receive queues per vnic is 8. Signed-off-by: Neel Patel Signed-off-by: Christian Benvenuti Signed-off-by: Roopa Prabhu Signed-off-by: Nishank Trivedi Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index ee93a2087fe6..24bb088a7bc6 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,13 +32,13 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.31" +#define DRV_VERSION "2.1.1.32" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 #define ENIC_WQ_MAX 1 -#define ENIC_RQ_MAX 1 +#define ENIC_RQ_MAX 8 #define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX) #define ENIC_INTR_MAX (ENIC_CQ_MAX + 2) -- GitLab From f8a6dd59f79f83d7188909331dcdf6e45e1b2c1f Mon Sep 17 00:00:00 2001 From: Neel Patel Date: Fri, 3 Feb 2012 08:25:19 +0000 Subject: [PATCH 0359/1846] enic: Check firmware capability before issuing firmware commands Check if firmware supports a particular command by first checking capability using devcmd CMD_CAPABILITY. Signed-off-by: Neel Patel Signed-off-by: Christian Benvenuti Signed-off-by: Roopa Prabhu Signed-off-by: Nishank Trivedi Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/vnic_dev.c | 58 ++++++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 24bb088a7bc6..54fd9c314b38 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.32" +#define DRV_VERSION "2.1.1.33" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c index 31e7f9bc2067..298ad6f865be 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_dev.c +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c @@ -439,11 +439,12 @@ int vnic_dev_fw_info(struct vnic_dev *vdev, a1 = sizeof(struct vnic_devcmd_fw_info); /* only get fw_info once and cache it */ - err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait); - if (err == ERR_ECMDUNKNOWN) { + if (vnic_dev_capable(vdev, CMD_MCPU_FW_INFO)) + err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, + &a0, &a1, wait); + else err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO_OLD, &a0, &a1, wait); - } } *fw_info = vdev->fw_info; @@ -504,13 +505,11 @@ int vnic_dev_enable_wait(struct vnic_dev *vdev) { u64 a0 = 0, a1 = 0; int wait = 1000; - int err; - err = vnic_dev_cmd(vdev, CMD_ENABLE_WAIT, &a0, &a1, wait); - if (err == ERR_ECMDUNKNOWN) + if (vnic_dev_capable(vdev, CMD_ENABLE_WAIT)) + return vnic_dev_cmd(vdev, CMD_ENABLE_WAIT, &a0, &a1, wait); + else return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait); - - return err; } int vnic_dev_disable(struct vnic_dev *vdev) @@ -574,16 +573,15 @@ int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg) int wait = 1000; int err; - err = vnic_dev_cmd(vdev, CMD_HANG_RESET, &a0, &a1, wait); - if (err == ERR_ECMDUNKNOWN) { + if (vnic_dev_capable(vdev, CMD_HANG_RESET)) { + return vnic_dev_cmd(vdev, CMD_HANG_RESET, + &a0, &a1, wait); + } else { err = vnic_dev_soft_reset(vdev, arg); if (err) return err; - return vnic_dev_init(vdev, 0); } - - return err; } int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done) @@ -594,11 +592,13 @@ int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done) *done = 0; - err = vnic_dev_cmd(vdev, CMD_HANG_RESET_STATUS, &a0, &a1, wait); - if (err) { - if (err == ERR_ECMDUNKNOWN) - return vnic_dev_soft_reset_done(vdev, done); - return err; + if (vnic_dev_capable(vdev, CMD_HANG_RESET_STATUS)) { + err = vnic_dev_cmd(vdev, CMD_HANG_RESET_STATUS, + &a0, &a1, wait); + if (err) + return err; + } else { + return vnic_dev_soft_reset_done(vdev, done); } *done = (a0 == 0); @@ -691,13 +691,12 @@ int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev, { u64 a0 = ig_vlan_rewrite_mode, a1 = 0; int wait = 1000; - int err; - err = vnic_dev_cmd(vdev, CMD_IG_VLAN_REWRITE_MODE, &a0, &a1, wait); - if (err == ERR_ECMDUNKNOWN) + if (vnic_dev_capable(vdev, CMD_IG_VLAN_REWRITE_MODE)) + return vnic_dev_cmd(vdev, CMD_IG_VLAN_REWRITE_MODE, + &a0, &a1, wait); + else return 0; - - return err; } static int vnic_dev_notify_setcmd(struct vnic_dev *vdev, @@ -835,7 +834,10 @@ int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev) memset(vdev->args, 0, sizeof(vdev->args)); - err = _vnic_dev_cmd(vdev, CMD_INTR_COAL_CONVERT, wait); + if (vnic_dev_capable(vdev, CMD_INTR_COAL_CONVERT)) + err = _vnic_dev_cmd(vdev, CMD_INTR_COAL_CONVERT, wait); + else + err = ERR_ECMDUNKNOWN; /* Use defaults when firmware doesn't support the devcmd at all or * supports it for only specific hardware @@ -848,9 +850,11 @@ int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev) return 0; } - vdev->intr_coal_timer_info.mul = (u32) vdev->args[0]; - vdev->intr_coal_timer_info.div = (u32) vdev->args[1]; - vdev->intr_coal_timer_info.max_usec = (u32) vdev->args[2]; + if (!err) { + vdev->intr_coal_timer_info.mul = (u32) vdev->args[0]; + vdev->intr_coal_timer_info.div = (u32) vdev->args[1]; + vdev->intr_coal_timer_info.max_usec = (u32) vdev->args[2]; + } return err; } -- GitLab From 5c6652f556842f838b6963023dcc25db748ececc Mon Sep 17 00:00:00 2001 From: Neel Patel Date: Fri, 3 Feb 2012 08:25:25 +0000 Subject: [PATCH 0360/1846] enic: Update enic maintainers Signed-off-by: Neel Patel Signed-off-by: Christian Benvenuti Signed-off-by: Roopa Prabhu Signed-off-by: Nishank Trivedi Signed-off-by: David S. Miller --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 087b65d12580..6929dceb2363 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1804,7 +1804,8 @@ F: Documentation/zh_CN/ CISCO VIC ETHERNET NIC DRIVER M: Christian Benvenuti M: Roopa Prabhu -M: David Wang +M: Neel Patel +M: Nishank Trivedi S: Supported F: drivers/net/ethernet/cisco/enic/ -- GitLab From 4a695823b580124c3ab750d8d528f7c6522628c3 Mon Sep 17 00:00:00 2001 From: "sjur.brandeland@stericsson.com" Date: Fri, 3 Feb 2012 04:36:19 +0000 Subject: [PATCH 0361/1846] caif: Kill debugfs vars for caif socket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kill off the debug-fs exposed varaibles from caif_socket. Signed-off-by: Sjur Brændeland Signed-off-by: David S. Miller --- net/caif/caif_socket.c | 113 +---------------------------------------- 1 file changed, 1 insertion(+), 112 deletions(-) diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index a98628086452..0d1131864630 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c @@ -43,34 +43,9 @@ enum caif_states { #define TX_FLOW_ON_BIT 1 #define RX_FLOW_ON_BIT 2 -static struct dentry *debugfsdir; - -#ifdef CONFIG_DEBUG_FS -struct debug_fs_counter { - atomic_t caif_nr_socks; - atomic_t caif_sock_create; - atomic_t num_connect_req; - atomic_t num_connect_resp; - atomic_t num_connect_fail_resp; - atomic_t num_disconnect; - atomic_t num_remote_shutdown_ind; - atomic_t num_tx_flow_off_ind; - atomic_t num_tx_flow_on_ind; - atomic_t num_rx_flow_off; - atomic_t num_rx_flow_on; -}; -static struct debug_fs_counter cnt; -#define dbfs_atomic_inc(v) atomic_inc_return(v) -#define dbfs_atomic_dec(v) atomic_dec_return(v) -#else -#define dbfs_atomic_inc(v) 0 -#define dbfs_atomic_dec(v) 0 -#endif - struct caifsock { struct sock sk; /* must be first member */ struct cflayer layer; - char name[CAIF_LAYER_NAME_SZ]; /* Used for debugging */ u32 flow_state; struct caif_connect_request conn_req; struct mutex readlock; @@ -161,7 +136,6 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) atomic_read(&cf_sk->sk.sk_rmem_alloc), sk_rcvbuf_lowwater(cf_sk)); set_rx_flow_off(cf_sk); - dbfs_atomic_inc(&cnt.num_rx_flow_off); caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ); } @@ -172,7 +146,6 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) set_rx_flow_off(cf_sk); if (net_ratelimit()) pr_debug("sending flow OFF due to rmem_schedule\n"); - dbfs_atomic_inc(&cnt.num_rx_flow_off); caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ); } skb->dev = NULL; @@ -233,14 +206,12 @@ static void caif_ctrl_cb(struct cflayer *layr, switch (flow) { case CAIF_CTRLCMD_FLOW_ON_IND: /* OK from modem to start sending again */ - dbfs_atomic_inc(&cnt.num_tx_flow_on_ind); set_tx_flow_on(cf_sk); cf_sk->sk.sk_state_change(&cf_sk->sk); break; case CAIF_CTRLCMD_FLOW_OFF_IND: /* Modem asks us to shut up */ - dbfs_atomic_inc(&cnt.num_tx_flow_off_ind); set_tx_flow_off(cf_sk); cf_sk->sk.sk_state_change(&cf_sk->sk); break; @@ -249,7 +220,6 @@ static void caif_ctrl_cb(struct cflayer *layr, /* We're now connected */ caif_client_register_refcnt(&cf_sk->layer, cfsk_hold, cfsk_put); - dbfs_atomic_inc(&cnt.num_connect_resp); cf_sk->sk.sk_state = CAIF_CONNECTED; set_tx_flow_on(cf_sk); cf_sk->sk.sk_state_change(&cf_sk->sk); @@ -263,7 +233,6 @@ static void caif_ctrl_cb(struct cflayer *layr, case CAIF_CTRLCMD_INIT_FAIL_RSP: /* Connect request failed */ - dbfs_atomic_inc(&cnt.num_connect_fail_resp); cf_sk->sk.sk_err = ECONNREFUSED; cf_sk->sk.sk_state = CAIF_DISCONNECTED; cf_sk->sk.sk_shutdown = SHUTDOWN_MASK; @@ -277,7 +246,6 @@ static void caif_ctrl_cb(struct cflayer *layr, case CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND: /* Modem has closed this connection, or device is down. */ - dbfs_atomic_inc(&cnt.num_remote_shutdown_ind); cf_sk->sk.sk_shutdown = SHUTDOWN_MASK; cf_sk->sk.sk_err = ECONNRESET; set_rx_flow_on(cf_sk); @@ -297,7 +265,6 @@ static void caif_check_flow_release(struct sock *sk) return; if (atomic_read(&sk->sk_rmem_alloc) <= sk_rcvbuf_lowwater(cf_sk)) { - dbfs_atomic_inc(&cnt.num_rx_flow_on); set_rx_flow_on(cf_sk); caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_ON_REQ); } @@ -854,7 +821,6 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr, /*ifindex = id of the interface.*/ cf_sk->conn_req.ifindex = cf_sk->sk.sk_bound_dev_if; - dbfs_atomic_inc(&cnt.num_connect_req); cf_sk->layer.receive = caif_sktrecv_cb; err = caif_connect_client(sock_net(sk), &cf_sk->conn_req, @@ -943,8 +909,6 @@ static int caif_release(struct socket *sock) spin_unlock_bh(&sk->sk_receive_queue.lock); sock->sk = NULL; - dbfs_atomic_inc(&cnt.num_disconnect); - WARN_ON(IS_ERR(cf_sk->debugfs_socket_dir)); if (cf_sk->debugfs_socket_dir != NULL) debugfs_remove_recursive(cf_sk->debugfs_socket_dir); @@ -1052,14 +1016,12 @@ static void caif_sock_destructor(struct sock *sk) return; } sk_stream_kill_queues(&cf_sk->sk); - dbfs_atomic_dec(&cnt.caif_nr_socks); caif_free_client(&cf_sk->layer); } static int caif_create(struct net *net, struct socket *sock, int protocol, int kern) { - int num; struct sock *sk = NULL; struct caifsock *cf_sk = NULL; static struct proto prot = {.name = "PF_CAIF", @@ -1120,34 +1082,6 @@ static int caif_create(struct net *net, struct socket *sock, int protocol, cf_sk->sk.sk_priority = CAIF_PRIO_NORMAL; cf_sk->conn_req.link_selector = CAIF_LINK_LOW_LATENCY; cf_sk->conn_req.protocol = protocol; - /* Increase the number of sockets created. */ - dbfs_atomic_inc(&cnt.caif_nr_socks); - num = dbfs_atomic_inc(&cnt.caif_sock_create); -#ifdef CONFIG_DEBUG_FS - if (!IS_ERR(debugfsdir)) { - - /* Fill in some information concerning the misc socket. */ - snprintf(cf_sk->name, sizeof(cf_sk->name), "cfsk%d", num); - - cf_sk->debugfs_socket_dir = - debugfs_create_dir(cf_sk->name, debugfsdir); - - debugfs_create_u32("sk_state", S_IRUSR | S_IWUSR, - cf_sk->debugfs_socket_dir, - (u32 *) &cf_sk->sk.sk_state); - debugfs_create_u32("flow_state", S_IRUSR | S_IWUSR, - cf_sk->debugfs_socket_dir, &cf_sk->flow_state); - debugfs_create_u32("sk_rmem_alloc", S_IRUSR | S_IWUSR, - cf_sk->debugfs_socket_dir, - (u32 *) &cf_sk->sk.sk_rmem_alloc); - debugfs_create_u32("sk_wmem_alloc", S_IRUSR | S_IWUSR, - cf_sk->debugfs_socket_dir, - (u32 *) &cf_sk->sk.sk_wmem_alloc); - debugfs_create_u32("identity", S_IRUSR | S_IWUSR, - cf_sk->debugfs_socket_dir, - (u32 *) &cf_sk->layer.id); - } -#endif release_sock(&cf_sk->sk); return 0; } @@ -1159,7 +1093,7 @@ static struct net_proto_family caif_family_ops = { .owner = THIS_MODULE, }; -static int af_caif_init(void) +static int __init caif_sktinit_module(void) { int err = sock_register(&caif_family_ops); if (!err) @@ -1167,54 +1101,9 @@ static int af_caif_init(void) return 0; } -static int __init caif_sktinit_module(void) -{ -#ifdef CONFIG_DEBUG_FS - debugfsdir = debugfs_create_dir("caif_sk", NULL); - if (!IS_ERR(debugfsdir)) { - debugfs_create_u32("num_sockets", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.caif_nr_socks); - debugfs_create_u32("num_create", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.caif_sock_create); - debugfs_create_u32("num_connect_req", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_connect_req); - debugfs_create_u32("num_connect_resp", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_connect_resp); - debugfs_create_u32("num_connect_fail_resp", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_connect_fail_resp); - debugfs_create_u32("num_disconnect", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_disconnect); - debugfs_create_u32("num_remote_shutdown_ind", - S_IRUSR | S_IWUSR, debugfsdir, - (u32 *) &cnt.num_remote_shutdown_ind); - debugfs_create_u32("num_tx_flow_off_ind", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_tx_flow_off_ind); - debugfs_create_u32("num_tx_flow_on_ind", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_tx_flow_on_ind); - debugfs_create_u32("num_rx_flow_off", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_rx_flow_off); - debugfs_create_u32("num_rx_flow_on", S_IRUSR | S_IWUSR, - debugfsdir, - (u32 *) &cnt.num_rx_flow_on); - } -#endif - return af_caif_init(); -} - static void __exit caif_sktexit_module(void) { sock_unregister(PF_CAIF); - if (debugfsdir != NULL) - debugfs_remove_recursive(debugfsdir); } module_init(caif_sktinit_module); module_exit(caif_sktexit_module); -- GitLab From 576f3cc7fb94a22df2ced8dcba7d48ff42f8e745 Mon Sep 17 00:00:00 2001 From: "sjur.brandeland@stericsson.com" Date: Fri, 3 Feb 2012 04:36:20 +0000 Subject: [PATCH 0362/1846] caif: Add drop count for caif_net device. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Count dropped packets in CAIF Netdevice. Signed-off-by: Sjur Brændeland Signed-off-by: David S. Miller --- net/caif/chnl_net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c index 865690948bbc..a751d9b263ed 100644 --- a/net/caif/chnl_net.c +++ b/net/caif/chnl_net.c @@ -74,7 +74,6 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt) struct sk_buff *skb; struct chnl_net *priv = container_of(layr, struct chnl_net, chnl); int pktlen; - int err = 0; const u8 *ip_version; u8 buf; @@ -95,8 +94,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt) /* check the version of IP */ ip_version = skb_header_pointer(skb, 0, 1, &buf); - if (!ip_version) - return -EINVAL; + switch (*ip_version >> 4) { case 4: skb->protocol = htons(ETH_P_IP); @@ -105,6 +103,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt) skb->protocol = htons(ETH_P_IPV6); break; default: + priv->netdev->stats.rx_errors++; return -EINVAL; } @@ -123,7 +122,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt) priv->netdev->stats.rx_packets++; priv->netdev->stats.rx_bytes += pktlen; - return err; + return 0; } static int delete_device(struct chnl_net *dev) @@ -221,11 +220,13 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev) if (skb->len > priv->netdev->mtu) { pr_warn("Size of skb exceeded MTU\n"); + dev->stats.tx_errors++; return -ENOSPC; } if (!priv->flowenabled) { pr_debug("dropping packets flow off\n"); + dev->stats.tx_dropped++; return NETDEV_TX_BUSY; } @@ -240,8 +241,7 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev) /* Send the packet down the stack. */ result = priv->chnl.dn->transmit(priv->chnl.dn, pkt); if (result) { - if (result == -EAGAIN) - result = NETDEV_TX_BUSY; + dev->stats.tx_dropped++; return result; } -- GitLab From 332ad43f19848ed653a5e44afa8e2f4a7d34ed44 Mon Sep 17 00:00:00 2001 From: "sjur.brandeland@stericsson.com" Date: Fri, 3 Feb 2012 04:36:21 +0000 Subject: [PATCH 0363/1846] caif-hsi: Add RX flip buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement RX flip buffer in the cfhsi_rx_done function, piggy-backed frames is also supported. This gives a significant performance gain for CAIF over HSI. Signed-off-by: Sjur Brændeland Signed-off-by: David S. Miller --- drivers/net/caif/caif_hsi.c | 145 +++++++++++++++++++++++++----------- include/net/caif/caif_hsi.h | 1 + 2 files changed, 104 insertions(+), 42 deletions(-) diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c index 0a4fc62a381d..c8afd62239e9 100644 --- a/drivers/net/caif/caif_hsi.c +++ b/drivers/net/caif/caif_hsi.c @@ -426,6 +426,35 @@ static int cfhsi_rx_desc(struct cfhsi_desc *desc, struct cfhsi *cfhsi) return xfer_sz; } +static int cfhsi_rx_desc_len(struct cfhsi_desc *desc) +{ + int xfer_sz = 0; + int nfrms = 0; + u16 *plen; + + if ((desc->header & ~CFHSI_PIGGY_DESC) || + (desc->offset > CFHSI_MAX_EMB_FRM_SZ)) { + + pr_err("Invalid descriptor. %x %x\n", desc->header, + desc->offset); + return -EPROTO; + } + + /* Calculate transfer length. */ + plen = desc->cffrm_len; + while (nfrms < CFHSI_MAX_PKTS && *plen) { + xfer_sz += *plen; + plen++; + nfrms++; + } + + if (xfer_sz % 4) { + pr_err("Invalid payload len: %d, ignored.\n", xfer_sz); + return -EPROTO; + } + return xfer_sz; +} + static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi) { int rx_sz = 0; @@ -517,8 +546,10 @@ static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi) static void cfhsi_rx_done(struct cfhsi *cfhsi) { int res; - int desc_pld_len = 0; + int desc_pld_len = 0, rx_len, rx_state; struct cfhsi_desc *desc = NULL; + u8 *rx_ptr, *rx_buf; + struct cfhsi_desc *piggy_desc = NULL; desc = (struct cfhsi_desc *)cfhsi->rx_buf; @@ -534,65 +565,71 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi) spin_unlock_bh(&cfhsi->lock); if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) { - desc_pld_len = cfhsi_rx_desc(desc, cfhsi); - if (desc_pld_len == -ENOMEM) - goto restart; - if (desc_pld_len == -EPROTO) + desc_pld_len = cfhsi_rx_desc_len(desc); + + if (desc_pld_len < 0) goto out_of_sync; + + rx_buf = cfhsi->rx_buf; + rx_len = desc_pld_len; + if (desc_pld_len > 0 && (desc->header & CFHSI_PIGGY_DESC)) + rx_len += CFHSI_DESC_SZ; + if (desc_pld_len == 0) + rx_buf = cfhsi->rx_flip_buf; } else { - int pld_len; + rx_buf = cfhsi->rx_flip_buf; - if (!cfhsi->rx_state.piggy_desc) { - pld_len = cfhsi_rx_pld(desc, cfhsi); - if (pld_len == -ENOMEM) - goto restart; - if (pld_len == -EPROTO) - goto out_of_sync; - cfhsi->rx_state.pld_len = pld_len; - } else { - pld_len = cfhsi->rx_state.pld_len; - } + rx_len = CFHSI_DESC_SZ; + if (cfhsi->rx_state.pld_len > 0 && + (desc->header & CFHSI_PIGGY_DESC)) { - if ((pld_len > 0) && (desc->header & CFHSI_PIGGY_DESC)) { - struct cfhsi_desc *piggy_desc; piggy_desc = (struct cfhsi_desc *) (desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ + - pld_len); + cfhsi->rx_state.pld_len); + cfhsi->rx_state.piggy_desc = true; - /* Extract piggy-backed descriptor. */ - desc_pld_len = cfhsi_rx_desc(piggy_desc, cfhsi); - if (desc_pld_len == -ENOMEM) - goto restart; + /* Extract payload len from piggy-backed descriptor. */ + desc_pld_len = cfhsi_rx_desc_len(piggy_desc); + if (desc_pld_len < 0) + goto out_of_sync; + + if (desc_pld_len > 0) + rx_len = desc_pld_len; + + if (desc_pld_len > 0 && + (piggy_desc->header & CFHSI_PIGGY_DESC)) + rx_len += CFHSI_DESC_SZ; /* * Copy needed information from the piggy-backed * descriptor to the descriptor in the start. */ - memcpy((u8 *)desc, (u8 *)piggy_desc, + memcpy(rx_buf, (u8 *)piggy_desc, CFHSI_DESC_SHORT_SZ); - + /* Mark no embedded frame here */ + piggy_desc->offset = 0; if (desc_pld_len == -EPROTO) goto out_of_sync; } } - memset(&cfhsi->rx_state, 0, sizeof(cfhsi->rx_state)); if (desc_pld_len) { - cfhsi->rx_state.state = CFHSI_RX_STATE_PAYLOAD; - cfhsi->rx_ptr = cfhsi->rx_buf + CFHSI_DESC_SZ; - cfhsi->rx_len = desc_pld_len; + rx_state = CFHSI_RX_STATE_PAYLOAD; + rx_ptr = rx_buf + CFHSI_DESC_SZ; } else { - cfhsi->rx_state.state = CFHSI_RX_STATE_DESC; - cfhsi->rx_ptr = cfhsi->rx_buf; - cfhsi->rx_len = CFHSI_DESC_SZ; + rx_state = CFHSI_RX_STATE_DESC; + rx_ptr = rx_buf; + rx_len = CFHSI_DESC_SZ; } + /* Initiate next read */ if (test_bit(CFHSI_AWAKE, &cfhsi->bits)) { /* Set up new transfer. */ dev_dbg(&cfhsi->ndev->dev, "%s: Start RX.\n", - __func__); - res = cfhsi->dev->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len, + __func__); + + res = cfhsi->dev->cfhsi_rx(rx_ptr, rx_len, cfhsi->dev); if (WARN_ON(res < 0)) { dev_err(&cfhsi->ndev->dev, "%s: RX error %d.\n", @@ -601,16 +638,32 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi) cfhsi->ndev->stats.rx_dropped++; } } - return; -restart: - if (++cfhsi->rx_state.retries > CFHSI_MAX_RX_RETRIES) { - dev_err(&cfhsi->ndev->dev, "%s: No memory available " - "in %d iterations.\n", - __func__, CFHSI_MAX_RX_RETRIES); - BUG(); + if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) { + /* Extract payload from descriptor */ + if (cfhsi_rx_desc(desc, cfhsi) < 0) + goto out_of_sync; + } else { + /* Extract payload */ + if (cfhsi_rx_pld(desc, cfhsi) < 0) + goto out_of_sync; + if (piggy_desc) { + /* Extract any payload in piggyback descriptor. */ + if (cfhsi_rx_desc(piggy_desc, cfhsi) < 0) + goto out_of_sync; + } } - mod_timer(&cfhsi->rx_slowpath_timer, jiffies + 1); + + /* Update state info */ + memset(&cfhsi->rx_state, 0, sizeof(cfhsi->rx_state)); + cfhsi->rx_state.state = rx_state; + cfhsi->rx_ptr = rx_ptr; + cfhsi->rx_len = rx_len; + cfhsi->rx_state.pld_len = desc_pld_len; + cfhsi->rx_state.piggy_desc = desc->header & CFHSI_PIGGY_DESC; + + if (rx_buf != cfhsi->rx_buf) + swap(cfhsi->rx_buf, cfhsi->rx_flip_buf); return; out_of_sync: @@ -1040,6 +1093,12 @@ int cfhsi_probe(struct platform_device *pdev) goto err_alloc_rx; } + cfhsi->rx_flip_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL); + if (!cfhsi->rx_flip_buf) { + res = -ENODEV; + goto err_alloc_rx_flip; + } + /* Pre-calculate inactivity timeout. */ if (inactivity_timeout != -1) { cfhsi->inactivity_timeout = @@ -1138,6 +1197,8 @@ int cfhsi_probe(struct platform_device *pdev) err_activate: destroy_workqueue(cfhsi->wq); err_create_wq: + kfree(cfhsi->rx_flip_buf); + err_alloc_rx_flip: kfree(cfhsi->rx_buf); err_alloc_rx: kfree(cfhsi->tx_buf); diff --git a/include/net/caif/caif_hsi.h b/include/net/caif/caif_hsi.h index 8d552519ff67..6db8ecf52aa2 100644 --- a/include/net/caif/caif_hsi.h +++ b/include/net/caif/caif_hsi.h @@ -138,6 +138,7 @@ struct cfhsi { u8 *rx_ptr; u8 *tx_buf; u8 *rx_buf; + u8 *rx_flip_buf; spinlock_t lock; int flow_off_sent; u32 q_low_mark; -- GitLab From 57cd80d4d511748f3973accc6919e7e1e1936ebb Mon Sep 17 00:00:00 2001 From: Padmanabh Ratnakar Date: Fri, 3 Feb 2012 09:49:46 +0000 Subject: [PATCH 0364/1846] be2net: Fix link status query command Version number in query link status command is getting overwritten in be_wrb_cmd_hdr_prepare() routine. Move the initialization to fix this issue. Also initialize the domain field. Signed-off-by: Padmanabh Ratnakar Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_cmds.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 0fcb45624796..dd6e8e2b3476 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -1257,11 +1257,13 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed, } req = embedded_payload(wrb); + be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, + OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req), wrb, NULL); + if (adapter->generation == BE_GEN3 || lancer_chip(adapter)) req->hdr.version = 1; - be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, - OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req), wrb, NULL); + req->hdr.domain = dom; status = be_mcc_notify_wait(adapter); if (!status) { -- GitLab From e5e1ee89461543043a0144e6dac90547fefe2f89 Mon Sep 17 00:00:00 2001 From: Padmanabh Ratnakar Date: Fri, 3 Feb 2012 09:50:17 +0000 Subject: [PATCH 0365/1846] be2net: Use new implementation of get mac list command VFs use get mac list command to get their mac address. The format of this command has changed. Update driver to use the new format. Signed-off-by: Mammatha Edhala Signed-off-by: Padmanabh Ratnakar Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_cmds.c | 67 +++++++++++++++------ drivers/net/ethernet/emulex/benet/be_cmds.h | 36 +++++++---- drivers/net/ethernet/emulex/benet/be_main.c | 29 ++++++--- 3 files changed, 92 insertions(+), 40 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index dd6e8e2b3476..29dff7de66b6 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -2300,52 +2300,81 @@ int be_cmd_req_native_mode(struct be_adapter *adapter) /* Uses synchronous MCCQ */ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, - u32 *pmac_id) + bool *pmac_id_active, u32 *pmac_id, u8 *mac) { struct be_mcc_wrb *wrb; struct be_cmd_req_get_mac_list *req; int status; int mac_count; + struct be_dma_mem get_mac_list_cmd; + int i; + + memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem)); + get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list); + get_mac_list_cmd.va = pci_alloc_consistent(adapter->pdev, + get_mac_list_cmd.size, + &get_mac_list_cmd.dma); + + if (!get_mac_list_cmd.va) { + dev_err(&adapter->pdev->dev, + "Memory allocation failure during GET_MAC_LIST\n"); + return -ENOMEM; + } spin_lock_bh(&adapter->mcc_lock); wrb = wrb_from_mccq(adapter); if (!wrb) { status = -EBUSY; - goto err; + goto out; } - req = embedded_payload(wrb); + + req = get_mac_list_cmd.va; be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, OPCODE_COMMON_GET_MAC_LIST, sizeof(*req), - wrb, NULL); + wrb, &get_mac_list_cmd); req->hdr.domain = domain; + req->mac_type = MAC_ADDRESS_TYPE_NETWORK; + req->perm_override = 1; status = be_mcc_notify_wait(adapter); if (!status) { struct be_cmd_resp_get_mac_list *resp = - embedded_payload(wrb); - int i; - u8 *ctxt = &resp->context[0][0]; - status = -EIO; - mac_count = resp->mac_count; - be_dws_le_to_cpu(&resp->context, sizeof(resp->context)); + get_mac_list_cmd.va; + mac_count = resp->true_mac_count + resp->pseudo_mac_count; + /* Mac list returned could contain one or more active mac_ids + * or one or more pseudo permanant mac addresses. If an active + * mac_id is present, return first active mac_id found + */ for (i = 0; i < mac_count; i++) { - if (!AMAP_GET_BITS(struct amap_get_mac_list_context, - act, ctxt)) { - *pmac_id = AMAP_GET_BITS - (struct amap_get_mac_list_context, - macid, ctxt); - status = 0; - break; + struct get_list_macaddr *mac_entry; + u16 mac_addr_size; + u32 mac_id; + + mac_entry = &resp->macaddr_list[i]; + mac_addr_size = le16_to_cpu(mac_entry->mac_addr_size); + /* mac_id is a 32 bit value and mac_addr size + * is 6 bytes + */ + if (mac_addr_size == sizeof(u32)) { + *pmac_id_active = true; + mac_id = mac_entry->mac_addr_id.s_mac_id.mac_id; + *pmac_id = le32_to_cpu(mac_id); + goto out; } - ctxt += sizeof(struct amap_get_mac_list_context) / 8; } + /* If no active mac_id found, return first pseudo mac addr */ + *pmac_id_active = false; + memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr, + ETH_ALEN); } -err: +out: spin_unlock_bh(&adapter->mcc_lock); + pci_free_consistent(adapter->pdev, get_mac_list_cmd.size, + get_mac_list_cmd.va, get_mac_list_cmd.dma); return status; } diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index bbd012b41fb4..5bb66c80f05e 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -1346,22 +1346,36 @@ struct be_cmd_resp_set_func_cap { /******************** GET/SET_MACLIST **************************/ #define BE_MAX_MAC 64 -struct amap_get_mac_list_context { - u8 macid[31]; - u8 act; -} __packed; - struct be_cmd_req_get_mac_list { struct be_cmd_req_hdr hdr; - u32 rsvd; + u8 mac_type; + u8 perm_override; + u16 iface_id; + u32 mac_id; + u32 rsvd[3]; +} __packed; + +struct get_list_macaddr { + u16 mac_addr_size; + union { + u8 macaddr[6]; + struct { + u8 rsvd[2]; + u32 mac_id; + } __packed s_mac_id; + } __packed mac_addr_id; } __packed; struct be_cmd_resp_get_mac_list { struct be_cmd_resp_hdr hdr; - u8 mac_count; - u8 rsvd1; - u16 rsvd2; - u8 context[sizeof(struct amap_get_mac_list_context) / 8][BE_MAX_MAC]; + struct get_list_macaddr fd_macaddr; /* Factory default mac */ + struct get_list_macaddr macid_macaddr; /* soft mac */ + u8 true_mac_count; + u8 pseudo_mac_count; + u8 mac_list_size; + u8 rsvd; + /* perm override mac */ + struct get_list_macaddr macaddr_list[BE_MAX_MAC]; } __packed; struct be_cmd_req_set_mac_list { @@ -1575,7 +1589,7 @@ extern int be_cmd_req_native_mode(struct be_adapter *adapter); extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size); extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf); extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, - u32 *pmac_id); + bool *pmac_id_active, u32 *pmac_id, u8 *mac); extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, u8 mac_count, u32 domain); diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 1395f803cf7f..780498784d8e 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -2608,19 +2608,28 @@ static void be_setup_init(struct be_adapter *adapter) adapter->eq_next_idx = 0; } -static int be_configure_mac_from_list(struct be_adapter *adapter, u8 *mac) +static int be_add_mac_from_list(struct be_adapter *adapter, u8 *mac) { u32 pmac_id; - int status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id); - if (status != 0) - goto do_none; - status = be_cmd_mac_addr_query(adapter, mac, - MAC_ADDRESS_TYPE_NETWORK, - false, adapter->if_handle, pmac_id); + int status; + bool pmac_id_active; + + status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id_active, + &pmac_id, mac); if (status != 0) goto do_none; - status = be_cmd_pmac_add(adapter, mac, adapter->if_handle, - &adapter->pmac_id, 0); + + if (pmac_id_active) { + status = be_cmd_mac_addr_query(adapter, mac, + MAC_ADDRESS_TYPE_NETWORK, + false, adapter->if_handle, pmac_id); + + if (!status) + adapter->pmac_id = pmac_id; + } else { + status = be_cmd_pmac_add(adapter, mac, + adapter->if_handle, &adapter->pmac_id, 0); + } do_none: return status; } @@ -2685,7 +2694,7 @@ static int be_setup(struct be_adapter *adapter) */ if (!be_physfn(adapter)) { if (lancer_chip(adapter)) - status = be_configure_mac_from_list(adapter, mac); + status = be_add_mac_from_list(adapter, mac); else status = be_cmd_mac_addr_query(adapter, mac, MAC_ADDRESS_TYPE_NETWORK, false, -- GitLab From 76a82abc0598f9cd881154369c3afdff9c28568b Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sat, 4 Feb 2012 10:52:56 +0000 Subject: [PATCH 0366/1846] tms380tr: Fix cascading if/else tab abuse Cascading "if/else if"'s are ugly. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/tokenring/tms380tr.c | 179 ++++++++++++------------------- 1 file changed, 67 insertions(+), 112 deletions(-) diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c index 65e9cf3a71fe..102f896bbc58 100644 --- a/drivers/net/tokenring/tms380tr.c +++ b/drivers/net/tokenring/tms380tr.c @@ -1525,10 +1525,8 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev) /* Check if adapter is opened, avoiding COMMAND_REJECT * interrupt by the adapter! */ - if(tp->AdapterOpenFlag == 0) - { - if(tp->CMDqueue & OC_OPEN) - { + if (tp->AdapterOpenFlag == 0) { + if (tp->CMDqueue & OC_OPEN) { /* Execute OPEN command */ tp->CMDqueue ^= OC_OPEN; @@ -1536,21 +1534,17 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev) tp->scb.Parm[0] = LOWORD(Addr); tp->scb.Parm[1] = HIWORD(Addr); tp->scb.CMD = OPEN; - } - else + } else /* No OPEN command queued, but adapter closed. Note: * We'll try to re-open the adapter in DriverPoll() */ return; /* No adapter command issued */ - } - else - { + } else { /* Adapter is open; evaluate command queue: try to execute * outstanding commands (depending on priority!) CLOSE * command queued */ - if(tp->CMDqueue & OC_CLOSE) - { + if (tp->CMDqueue & OC_CLOSE) { tp->CMDqueue ^= OC_CLOSE; tp->AdapterOpenFlag = 0; tp->scb.Parm[0] = 0; /* Parm[0], Parm[1] are ignored */ @@ -1560,109 +1554,70 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev) tp->CMDqueue |= OC_OPEN; /* re-open adapter */ else tp->CMDqueue = 0; /* no more commands */ - } - else - { - if(tp->CMDqueue & OC_RECEIVE) - { - tp->CMDqueue ^= OC_RECEIVE; - Addr = htonl(((char *)tp->RplHead - (char *)tp) + tp->dmabuffer); - tp->scb.Parm[0] = LOWORD(Addr); - tp->scb.Parm[1] = HIWORD(Addr); - tp->scb.CMD = RECEIVE; - } - else - { - if(tp->CMDqueue & OC_TRANSMIT_HALT) - { - /* NOTE: TRANSMIT.HALT must be checked - * before TRANSMIT. - */ - tp->CMDqueue ^= OC_TRANSMIT_HALT; - tp->scb.CMD = TRANSMIT_HALT; - - /* Parm[0] and Parm[1] are ignored - * but should be set to zero! - */ - tp->scb.Parm[0] = 0; - tp->scb.Parm[1] = 0; - } - else - { - if(tp->CMDqueue & OC_TRANSMIT) - { - /* NOTE: TRANSMIT must be - * checked after TRANSMIT.HALT - */ - if(tp->TransmitCommandActive) - { - if(!tp->TransmitHaltScheduled) - { - tp->TransmitHaltScheduled = 1; - tms380tr_exec_cmd(dev, OC_TRANSMIT_HALT) ; - } - tp->TransmitCommandActive = 0; - return; - } - - tp->CMDqueue ^= OC_TRANSMIT; - tms380tr_cancel_tx_queue(tp); - Addr = htonl(((char *)tp->TplBusy - (char *)tp) + tp->dmabuffer); - tp->scb.Parm[0] = LOWORD(Addr); - tp->scb.Parm[1] = HIWORD(Addr); - tp->scb.CMD = TRANSMIT; - tp->TransmitCommandActive = 1; - } - else - { - if(tp->CMDqueue & OC_MODIFY_OPEN_PARMS) - { - tp->CMDqueue ^= OC_MODIFY_OPEN_PARMS; - tp->scb.Parm[0] = tp->ocpl.OPENOptions; /* new OPEN options*/ - tp->scb.Parm[0] |= ENABLE_FULL_DUPLEX_SELECTION; - tp->scb.Parm[1] = 0; /* is ignored but should be zero */ - tp->scb.CMD = MODIFY_OPEN_PARMS; - } - else - { - if(tp->CMDqueue & OC_SET_FUNCT_ADDR) - { - tp->CMDqueue ^= OC_SET_FUNCT_ADDR; - tp->scb.Parm[0] = LOWORD(tp->ocpl.FunctAddr); - tp->scb.Parm[1] = HIWORD(tp->ocpl.FunctAddr); - tp->scb.CMD = SET_FUNCT_ADDR; - } - else - { - if(tp->CMDqueue & OC_SET_GROUP_ADDR) - { - tp->CMDqueue ^= OC_SET_GROUP_ADDR; - tp->scb.Parm[0] = LOWORD(tp->ocpl.GroupAddr); - tp->scb.Parm[1] = HIWORD(tp->ocpl.GroupAddr); - tp->scb.CMD = SET_GROUP_ADDR; - } - else - { - if(tp->CMDqueue & OC_READ_ERROR_LOG) - { - tp->CMDqueue ^= OC_READ_ERROR_LOG; - Addr = htonl(((char *)&tp->errorlogtable - (char *)tp) + tp->dmabuffer); - tp->scb.Parm[0] = LOWORD(Addr); - tp->scb.Parm[1] = HIWORD(Addr); - tp->scb.CMD = READ_ERROR_LOG; - } - else - { - printk(KERN_WARNING "CheckForOutstandingCommand: unknown Command\n"); - tp->CMDqueue = 0; - return; - } - } - } - } - } + } else if (tp->CMDqueue & OC_RECEIVE) { + tp->CMDqueue ^= OC_RECEIVE; + Addr = htonl(((char *)tp->RplHead - (char *)tp) + tp->dmabuffer); + tp->scb.Parm[0] = LOWORD(Addr); + tp->scb.Parm[1] = HIWORD(Addr); + tp->scb.CMD = RECEIVE; + } else if (tp->CMDqueue & OC_TRANSMIT_HALT) { + /* NOTE: TRANSMIT.HALT must be checked + * before TRANSMIT. + */ + tp->CMDqueue ^= OC_TRANSMIT_HALT; + tp->scb.CMD = TRANSMIT_HALT; + + /* Parm[0] and Parm[1] are ignored + * but should be set to zero! + */ + tp->scb.Parm[0] = 0; + tp->scb.Parm[1] = 0; + } else if (tp->CMDqueue & OC_TRANSMIT) { + /* NOTE: TRANSMIT must be + * checked after TRANSMIT.HALT + */ + if (tp->TransmitCommandActive) { + if (!tp->TransmitHaltScheduled) { + tp->TransmitHaltScheduled = 1; + tms380tr_exec_cmd(dev, OC_TRANSMIT_HALT); } + tp->TransmitCommandActive = 0; + return; } + + tp->CMDqueue ^= OC_TRANSMIT; + tms380tr_cancel_tx_queue(tp); + Addr = htonl(((char *)tp->TplBusy - (char *)tp) + tp->dmabuffer); + tp->scb.Parm[0] = LOWORD(Addr); + tp->scb.Parm[1] = HIWORD(Addr); + tp->scb.CMD = TRANSMIT; + tp->TransmitCommandActive = 1; + } else if (tp->CMDqueue & OC_MODIFY_OPEN_PARMS) { + tp->CMDqueue ^= OC_MODIFY_OPEN_PARMS; + tp->scb.Parm[0] = tp->ocpl.OPENOptions; /* new OPEN options*/ + tp->scb.Parm[0] |= ENABLE_FULL_DUPLEX_SELECTION; + tp->scb.Parm[1] = 0; /* is ignored but should be zero */ + tp->scb.CMD = MODIFY_OPEN_PARMS; + } else if (tp->CMDqueue & OC_SET_FUNCT_ADDR) { + tp->CMDqueue ^= OC_SET_FUNCT_ADDR; + tp->scb.Parm[0] = LOWORD(tp->ocpl.FunctAddr); + tp->scb.Parm[1] = HIWORD(tp->ocpl.FunctAddr); + tp->scb.CMD = SET_FUNCT_ADDR; + } else if (tp->CMDqueue & OC_SET_GROUP_ADDR) { + tp->CMDqueue ^= OC_SET_GROUP_ADDR; + tp->scb.Parm[0] = LOWORD(tp->ocpl.GroupAddr); + tp->scb.Parm[1] = HIWORD(tp->ocpl.GroupAddr); + tp->scb.CMD = SET_GROUP_ADDR; + } else if (tp->CMDqueue & OC_READ_ERROR_LOG) { + tp->CMDqueue ^= OC_READ_ERROR_LOG; + Addr = htonl(((char *)&tp->errorlogtable - (char *)tp) + tp->dmabuffer); + tp->scb.Parm[0] = LOWORD(Addr); + tp->scb.Parm[1] = HIWORD(Addr); + tp->scb.CMD = READ_ERROR_LOG; + } else { + printk(KERN_WARNING "CheckForOutstandingCommand: unknown Command\n"); + tp->CMDqueue = 0; + return; } } -- GitLab From 8d9eb069eafce49307f839783e4a4673414b1fd5 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 3 Feb 2012 03:27:38 +0000 Subject: [PATCH 0367/1846] mlx4: Fix typo in cmd.c Correct spelling "reseting" to "resetting" in drivers/net/ethernet/mellanox/mlx4/cmd.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 405e6ac3faf6..1831ddeebc42 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -1314,7 +1314,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, down(&priv->cmd.slave_sem); if (mlx4_master_process_vhcr(dev, slave, NULL)) { mlx4_err(dev, "Failed processing vhcr for slave:%d," - " reseting slave.\n", slave); + " resetting slave.\n", slave); up(&priv->cmd.slave_sem); goto reset_slave; } -- GitLab From 5fccab3b66d53883a97fc65e0c33f3ebf74e8ff9 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Sun, 5 Feb 2012 12:13:08 +0000 Subject: [PATCH 0368/1846] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Reviewed-by: Jesper Juhl Signed-off-by: David S. Miller --- drivers/net/hyperv/rndis_filter.c | 60 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 133b7fbf8595..a60e5e2e621a 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -758,66 +758,66 @@ int rndis_filter_open(struct hv_device *dev) int rndis_filter_close(struct hv_device *dev) { - struct netvsc_device *netDevice = hv_get_drvdata(dev); + struct netvsc_device *nvdev = hv_get_drvdata(dev); - if (!netDevice) + if (!nvdev) return -EINVAL; - return rndis_filter_close_device(netDevice->extension); + return rndis_filter_close_device(nvdev->extension); } int rndis_filter_send(struct hv_device *dev, struct hv_netvsc_packet *pkt) { int ret; - struct rndis_filter_packet *filterPacket; - struct rndis_message *rndisMessage; - struct rndis_packet *rndisPacket; - u32 rndisMessageSize; + struct rndis_filter_packet *filter_pkt; + struct rndis_message *rndis_msg; + struct rndis_packet *rndis_pkt; + u32 rndis_msg_size; /* Add the rndis header */ - filterPacket = (struct rndis_filter_packet *)pkt->extension; + filter_pkt = (struct rndis_filter_packet *)pkt->extension; - memset(filterPacket, 0, sizeof(struct rndis_filter_packet)); + memset(filter_pkt, 0, sizeof(struct rndis_filter_packet)); - rndisMessage = &filterPacket->msg; - rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet); + rndis_msg = &filter_pkt->msg; + rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet); - rndisMessage->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; - rndisMessage->msg_len = pkt->total_data_buflen + - rndisMessageSize; + rndis_msg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; + rndis_msg->msg_len = pkt->total_data_buflen + + rndis_msg_size; - rndisPacket = &rndisMessage->msg.pkt; - rndisPacket->data_offset = sizeof(struct rndis_packet); - rndisPacket->data_len = pkt->total_data_buflen; + rndis_pkt = &rndis_msg->msg.pkt; + rndis_pkt->data_offset = sizeof(struct rndis_packet); + rndis_pkt->data_len = pkt->total_data_buflen; pkt->is_data_pkt = true; - pkt->page_buf[0].pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT; + pkt->page_buf[0].pfn = virt_to_phys(rndis_msg) >> PAGE_SHIFT; pkt->page_buf[0].offset = - (unsigned long)rndisMessage & (PAGE_SIZE-1); - pkt->page_buf[0].len = rndisMessageSize; + (unsigned long)rndis_msg & (PAGE_SIZE-1); + pkt->page_buf[0].len = rndis_msg_size; /* Add one page_buf if the rndis msg goes beyond page boundary */ - if (pkt->page_buf[0].offset + rndisMessageSize > PAGE_SIZE) { + if (pkt->page_buf[0].offset + rndis_msg_size > PAGE_SIZE) { int i; for (i = pkt->page_buf_cnt; i > 1; i--) pkt->page_buf[i] = pkt->page_buf[i-1]; pkt->page_buf_cnt++; pkt->page_buf[0].len = PAGE_SIZE - pkt->page_buf[0].offset; pkt->page_buf[1].pfn = virt_to_phys((void *)((ulong) - rndisMessage + pkt->page_buf[0].len)) >> PAGE_SHIFT; + rndis_msg + pkt->page_buf[0].len)) >> PAGE_SHIFT; pkt->page_buf[1].offset = 0; - pkt->page_buf[1].len = rndisMessageSize - pkt->page_buf[0].len; + pkt->page_buf[1].len = rndis_msg_size - pkt->page_buf[0].len; } /* Save the packet send completion and context */ - filterPacket->completion = pkt->completion.send.send_completion; - filterPacket->completion_ctx = + filter_pkt->completion = pkt->completion.send.send_completion; + filter_pkt->completion_ctx = pkt->completion.send.send_completion_ctx; /* Use ours */ pkt->completion.send.send_completion = rndis_filter_send_completion; - pkt->completion.send.send_completion_ctx = filterPacket; + pkt->completion.send.send_completion_ctx = filter_pkt; ret = netvsc_send(dev, pkt); if (ret != 0) { @@ -826,9 +826,9 @@ int rndis_filter_send(struct hv_device *dev, * above */ pkt->completion.send.send_completion = - filterPacket->completion; + filter_pkt->completion; pkt->completion.send.send_completion_ctx = - filterPacket->completion_ctx; + filter_pkt->completion_ctx; } return ret; @@ -836,10 +836,10 @@ int rndis_filter_send(struct hv_device *dev, static void rndis_filter_send_completion(void *ctx) { - struct rndis_filter_packet *filterPacket = ctx; + struct rndis_filter_packet *filter_pkt = ctx; /* Pass it back to the original handler */ - filterPacket->completion(filterPacket->completion_ctx); + filter_pkt->completion(filter_pkt->completion_ctx); } -- GitLab From 6f4c44460750dd4eb9926a58ab1ad0ceacef8284 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Sun, 5 Feb 2012 12:13:09 +0000 Subject: [PATCH 0369/1846] net/hyperv: Correct the assignment in netvsc_recv_callback() The first assignment to variable "net" is wrong, but overridden by the latter assignments. So the bug isn't manifested. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc_drv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 466c58a7353d..0ae7a1a6aeb0 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -267,13 +267,10 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj, int netvsc_recv_callback(struct hv_device *device_obj, struct hv_netvsc_packet *packet) { - struct net_device *net = dev_get_drvdata(&device_obj->device); + struct net_device *net; struct sk_buff *skb; - struct netvsc_device *net_device; - - net_device = hv_get_drvdata(device_obj); - net = net_device->ndev; + net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev; if (!net) { netdev_err(net, "got receive callback but net device" " not initialized yet\n"); -- GitLab From bce60806de882cf15ad3a80a51e9878863a8fced Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Sun, 5 Feb 2012 12:13:10 +0000 Subject: [PATCH 0370/1846] net/hyperv: Remove the unnecessary memset in rndis_filter_send() The memory has been allocated by kzalloc, so it's unnecessary to memset again. Signed-off-by: Haiyang Zhang Signed-off-by: K. Y. Srinivasan Signed-off-by: David S. Miller --- drivers/net/hyperv/rndis_filter.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index a60e5e2e621a..136efd84373f 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -778,8 +778,6 @@ int rndis_filter_send(struct hv_device *dev, /* Add the rndis header */ filter_pkt = (struct rndis_filter_packet *)pkt->extension; - memset(filter_pkt, 0, sizeof(struct rndis_filter_packet)); - rndis_msg = &filter_pkt->msg; rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet); -- GitLab From 22b6a2eb902985961e6b41b923988a92a4523267 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 5 Feb 2012 12:28:57 +0000 Subject: [PATCH 0371/1846] decnet: remove unused variable from dn_output() The variable 'neigh' is assigned to, but otherwise completely unused. So let's remove it. Signed-off-by: Jesper Juhl Signed-off-by: David S. Miller --- net/decnet/dn_route.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index f31ce72dca65..80a3de4906d3 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -724,11 +724,10 @@ static int dn_output(struct sk_buff *skb) struct dn_route *rt = (struct dn_route *)dst; struct net_device *dev = dst->dev; struct dn_skb_cb *cb = DN_SKB_CB(skb); - struct neighbour *neigh; int err = -EINVAL; - if ((neigh = dst_get_neighbour_noref(dst)) == NULL) + if (dst_get_neighbour_noref(dst) == NULL) goto error; skb->dev = dev; -- GitLab From 1f0b6702b5d0c10b8a1637f05baf0d597c9c0cc1 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 5 Feb 2012 12:50:46 +0000 Subject: [PATCH 0372/1846] caif: caifdev is never used in net/caif/caif_dev.c::transmit() - remove it. Signed-off-by: Jesper Juhl Signed-off-by: David S. Miller --- net/caif/caif_dev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index 82c57069415f..aa6f716524fd 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c @@ -162,7 +162,6 @@ void caif_flow_cb(struct sk_buff *skb) static int transmit(struct cflayer *layer, struct cfpkt *pkt) { int err, high = 0, qlen = 0; - struct caif_dev_common *caifdev; struct caif_device_entry *caifd = container_of(layer, struct caif_device_entry, layer); struct sk_buff *skb; @@ -174,7 +173,6 @@ static int transmit(struct cflayer *layer, struct cfpkt *pkt) skb->dev = caifd->netdev; skb_reset_network_header(skb); skb->protocol = htons(ETH_P_CAIF); - caifdev = netdev_priv(caifd->netdev); /* Check if we need to handle xoff */ if (likely(caifd->netdev->tx_queue_len == 0)) -- GitLab From b9d6d2dbf45b038a94c63295203525101a9fbbb7 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 5 Feb 2012 13:18:57 +0000 Subject: [PATCH 0373/1846] bonding: Fix misspelling of "since" Signed-off-by: Jesper Juhl Signed-off-by: David S. Miller --- drivers/net/bonding/bond_3ad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 0ae0d7c54ccf..793b00138275 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -660,7 +660,7 @@ static void __attach_bond_to_agg(struct port *port) static void __detach_bond_from_agg(struct port *port) { port = NULL; /* just to satisfy the compiler */ - // This function does nothing sience the parser/multiplexer of the receive + // This function does nothing since the parser/multiplexer of the receive // and the parser/multiplexer of the aggregator are already combined } -- GitLab From b033281f618fa40ee1b24a60cd8043b4979bfee4 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Sun, 5 Feb 2012 15:24:38 +0000 Subject: [PATCH 0374/1846] bnx2: Add support for ethtool --show-channels|--set-channels Allow the user to override the default number of RSS/TSS rings. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2.c | 99 +++++++++++++++++++++++++--- drivers/net/ethernet/broadcom/bnx2.h | 3 + 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 0a4c5405dcf4..2ab31daef80f 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -6246,7 +6246,16 @@ static int bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi) { int cpus = num_online_cpus(); - int msix_vecs = min(cpus + 1, RX_MAX_RINGS); + int msix_vecs; + + if (!bp->num_req_rx_rings) + msix_vecs = max(cpus + 1, bp->num_req_tx_rings); + else if (!bp->num_req_tx_rings) + msix_vecs = max(cpus, bp->num_req_rx_rings); + else + msix_vecs = max(bp->num_req_rx_rings, bp->num_req_tx_rings); + + msix_vecs = min(msix_vecs, RX_MAX_RINGS); bp->irq_tbl[0].handler = bnx2_interrupt; strcpy(bp->irq_tbl[0].name, bp->dev->name); @@ -6270,10 +6279,18 @@ bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi) } } - bp->num_tx_rings = rounddown_pow_of_two(bp->irq_nvecs); + if (!bp->num_req_tx_rings) + bp->num_tx_rings = rounddown_pow_of_two(bp->irq_nvecs); + else + bp->num_tx_rings = min(bp->irq_nvecs, bp->num_req_tx_rings); + + if (!bp->num_req_rx_rings) + bp->num_rx_rings = bp->irq_nvecs; + else + bp->num_rx_rings = min(bp->irq_nvecs, bp->num_req_rx_rings); + netif_set_real_num_tx_queues(bp->dev, bp->num_tx_rings); - bp->num_rx_rings = bp->irq_nvecs; return netif_set_real_num_rx_queues(bp->dev, bp->num_rx_rings); } @@ -7162,7 +7179,7 @@ bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering) } static int -bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) +bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx, bool reset_irq) { if (netif_running(bp->dev)) { /* Reset will erase chipset stats; save them */ @@ -7170,7 +7187,12 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) bnx2_netif_stop(bp, true); bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); - __bnx2_free_irq(bp); + if (reset_irq) { + bnx2_free_irq(bp); + bnx2_del_napi(bp); + } else { + __bnx2_free_irq(bp); + } bnx2_free_skbs(bp); bnx2_free_mem(bp); } @@ -7179,9 +7201,16 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) bp->tx_ring_size = tx; if (netif_running(bp->dev)) { - int rc; + int rc = 0; + + if (reset_irq) { + rc = bnx2_setup_int_mode(bp, disable_msi); + bnx2_init_napi(bp); + } + + if (!rc) + rc = bnx2_alloc_mem(bp); - rc = bnx2_alloc_mem(bp); if (!rc) rc = bnx2_request_irq(bp); @@ -7217,7 +7246,8 @@ bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering) return -EINVAL; } - rc = bnx2_change_ring_size(bp, ering->rx_pending, ering->tx_pending); + rc = bnx2_change_ring_size(bp, ering->rx_pending, ering->tx_pending, + false); return rc; } @@ -7605,6 +7635,54 @@ bnx2_set_features(struct net_device *dev, netdev_features_t features) return 0; } +static void bnx2_get_channels(struct net_device *dev, + struct ethtool_channels *channels) +{ + struct bnx2 *bp = netdev_priv(dev); + u32 max_rx_rings = 1; + u32 max_tx_rings = 1; + + if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !disable_msi) { + max_rx_rings = RX_MAX_RINGS; + max_tx_rings = TX_MAX_RINGS; + } + + channels->max_rx = max_rx_rings; + channels->max_tx = max_tx_rings; + channels->max_other = 0; + channels->max_combined = 0; + channels->rx_count = bp->num_rx_rings; + channels->tx_count = bp->num_tx_rings; + channels->other_count = 0; + channels->combined_count = 0; +} + +static int bnx2_set_channels(struct net_device *dev, + struct ethtool_channels *channels) +{ + struct bnx2 *bp = netdev_priv(dev); + u32 max_rx_rings = 1; + u32 max_tx_rings = 1; + int rc = 0; + + if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !disable_msi) { + max_rx_rings = RX_MAX_RINGS; + max_tx_rings = TX_MAX_RINGS; + } + if (channels->rx_count > max_rx_rings || + channels->tx_count > max_tx_rings) + return -EINVAL; + + bp->num_req_rx_rings = channels->rx_count; + bp->num_req_tx_rings = channels->tx_count; + + if (netif_running(dev)) + rc = bnx2_change_ring_size(bp, bp->rx_ring_size, + bp->tx_ring_size, true); + + return rc; +} + static const struct ethtool_ops bnx2_ethtool_ops = { .get_settings = bnx2_get_settings, .set_settings = bnx2_set_settings, @@ -7629,6 +7707,8 @@ static const struct ethtool_ops bnx2_ethtool_ops = { .set_phys_id = bnx2_set_phys_id, .get_ethtool_stats = bnx2_get_ethtool_stats, .get_sset_count = bnx2_get_sset_count, + .get_channels = bnx2_get_channels, + .set_channels = bnx2_set_channels, }; /* Called with rtnl_lock */ @@ -7710,7 +7790,8 @@ bnx2_change_mtu(struct net_device *dev, int new_mtu) return -EINVAL; dev->mtu = new_mtu; - return bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size); + return bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size, + false); } #ifdef CONFIG_NET_POLL_CONTROLLER diff --git a/drivers/net/ethernet/broadcom/bnx2.h b/drivers/net/ethernet/broadcom/bnx2.h index 1db2d51ba3f1..dc06bda73be7 100644 --- a/drivers/net/ethernet/broadcom/bnx2.h +++ b/drivers/net/ethernet/broadcom/bnx2.h @@ -6933,6 +6933,9 @@ struct bnx2 { u8 num_tx_rings; u8 num_rx_rings; + int num_req_tx_rings; + int num_req_rx_rings; + u32 leds_save; u32 idle_chk_status_idx; -- GitLab From 94bf91baf3a16ec274de3cd913be3033c029f853 Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Sun, 5 Feb 2012 15:24:39 +0000 Subject: [PATCH 0375/1846] bnx2: Add missing memory barrier in bnx2_start_xmit() Sync DMA descriptor before hitting the TX mailbox for weak memory model CPUs. There has been discussions several years ago about this. Some believe that writel() should guarantee ordering. Others want explicit barriers if necessary. Today writel() does not have the ordering guarantee and many other drivers use explicit barriers. Signed-off-by: Vlad Zolotarov Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 2ab31daef80f..7105989ba658 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -6565,6 +6565,9 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) } txbd->tx_bd_vlan_tag_flags |= TX_BD_FLAGS_END; + /* Sync BD data before updating TX mailbox */ + wmb(); + netdev_tx_sent_queue(txq, skb->len); prod = NEXT_TX_BD(prod); -- GitLab From 3238a9be4d7ad95c741bcfe6c147406eeef62d95 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Sun, 5 Feb 2012 15:24:40 +0000 Subject: [PATCH 0376/1846] cnic: Add FCoE parity error recovery When bnx2x returns error on FCoE SPQ messages, generate an error completion to bnx2fc immediately to speed up error recovery. This will eliminate length timeouts and spped up the reset of the device. Signed-off-by: Bhanu Prakash Gollapudi Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/cnic.c | 38 ++++++++++++++++++++--- drivers/net/ethernet/broadcom/cnic_defs.h | 3 +- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index dd3a0a232ea0..7381460142e6 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c @@ -1,6 +1,6 @@ /* cnic.c: Broadcom CNIC core network driver. * - * Copyright (c) 2006-2011 Broadcom Corporation + * Copyright (c) 2006-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2521,12 +2521,35 @@ static void cnic_bnx2x_kwqe_err(struct cnic_dev *dev, struct kwqe *kwqe) u32 cid; u32 opcode = KWQE_OPCODE(kwqe->kwqe_op_flag); u32 layer_code = kwqe->kwqe_op_flag & KWQE_LAYER_MASK; + u32 kcqe_op; int ulp_type; cid = kwqe->kwqe_info0; memset(&kcqe, 0, sizeof(kcqe)); - if (layer_code == KWQE_FLAGS_LAYER_MASK_L5_ISCSI) { + if (layer_code == KWQE_FLAGS_LAYER_MASK_L5_FCOE) { + u32 l5_cid = 0; + + ulp_type = CNIC_ULP_FCOE; + if (opcode == FCOE_KWQE_OPCODE_DISABLE_CONN) { + struct fcoe_kwqe_conn_enable_disable *req; + + req = (struct fcoe_kwqe_conn_enable_disable *) kwqe; + kcqe_op = FCOE_KCQE_OPCODE_DISABLE_CONN; + cid = req->context_id; + l5_cid = req->conn_id; + } else if (opcode == FCOE_KWQE_OPCODE_DESTROY) { + kcqe_op = FCOE_KCQE_OPCODE_DESTROY_FUNC; + } else { + return; + } + kcqe.kcqe_op_flag = kcqe_op << KCQE_FLAGS_OPCODE_SHIFT; + kcqe.kcqe_op_flag |= KCQE_FLAGS_LAYER_MASK_L5_FCOE; + kcqe.kcqe_info1 = FCOE_KCQE_COMPLETION_STATUS_NIC_ERROR; + kcqe.kcqe_info2 = cid; + kcqe.kcqe_info0 = l5_cid; + + } else if (layer_code == KWQE_FLAGS_LAYER_MASK_L5_ISCSI) { ulp_type = CNIC_ULP_ISCSI; if (opcode == ISCSI_KWQE_OPCODE_UPDATE_CONN) cid = kwqe->kwqe_info1; @@ -2539,7 +2562,6 @@ static void cnic_bnx2x_kwqe_err(struct cnic_dev *dev, struct kwqe *kwqe) } else if (layer_code == KWQE_FLAGS_LAYER_MASK_L4) { struct l4_kcq *l4kcqe = (struct l4_kcq *) &kcqe; - u32 kcqe_op; ulp_type = CNIC_ULP_L4; if (opcode == L4_KWQE_OPCODE_VALUE_CONNECT1) @@ -2686,9 +2708,17 @@ static int cnic_submit_bnx2x_fcoe_kwqes(struct cnic_dev *dev, opcode); break; } - if (ret < 0) + if (ret < 0) { netdev_err(dev->netdev, "KWQE(0x%x) failed\n", opcode); + + /* Possibly bnx2x parity error, send completion + * to ulp drivers with error code to speed up + * cleanup and reset recovery. + */ + if (ret == -EIO || ret == -EAGAIN) + cnic_bnx2x_kwqe_err(dev, kwqe); + } i += work; } return 0; diff --git a/drivers/net/ethernet/broadcom/cnic_defs.h b/drivers/net/ethernet/broadcom/cnic_defs.h index 86936f6b6dbc..7271f14bda3b 100644 --- a/drivers/net/ethernet/broadcom/cnic_defs.h +++ b/drivers/net/ethernet/broadcom/cnic_defs.h @@ -1,7 +1,7 @@ /* cnic.c: Broadcom CNIC core network driver. * - * Copyright (c) 2006-2009 Broadcom Corporation + * Copyright (c) 2006-2012 Broadcom Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,6 +69,7 @@ #define FCOE_KCQE_COMPLETION_STATUS_ERROR (0x1) #define FCOE_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE (0x3) +#define FCOE_KCQE_COMPLETION_STATUS_NIC_ERROR (0x5) /* KCQ (kernel completion queue) response op codes */ #define L4_KCQE_OPCODE_VALUE_CLOSE_COMP (53) -- GitLab From 1d266430546acf01438ae42d0a7370db4817e2ad Mon Sep 17 00:00:00 2001 From: Pradeep A Dalvi Date: Sun, 5 Feb 2012 02:49:09 +0000 Subject: [PATCH 0377/1846] netdev: ethernet dev_alloc_skb to netdev_alloc_skb Replaced deprecating dev_alloc_skb with netdev_alloc_skb in drivers/net/ethernet - Removed extra skb->dev = dev after netdev_alloc_skb Signed-off-by: Pradeep A Dalvi Signed-off-by: David S. Miller --- drivers/net/ethernet/3com/3c501.c | 2 +- drivers/net/ethernet/3com/3c509.c | 2 +- drivers/net/ethernet/3com/3c574_cs.c | 2 +- drivers/net/ethernet/3com/3c589_cs.c | 2 +- drivers/net/ethernet/3com/3c59x.c | 5 +++-- drivers/net/ethernet/3com/typhoon.c | 5 ++--- drivers/net/ethernet/8390/axnet_cs.c | 2 +- drivers/net/ethernet/8390/lib8390.c | 2 +- drivers/net/ethernet/adaptec/starfire.c | 8 +++----- drivers/net/ethernet/aeroflex/greth.c | 1 - drivers/net/ethernet/amd/7990.c | 2 +- drivers/net/ethernet/amd/a2065.c | 2 +- drivers/net/ethernet/amd/am79c961a.c | 2 +- drivers/net/ethernet/amd/amd8111e.c | 6 ++++-- drivers/net/ethernet/amd/ariadne.c | 2 +- drivers/net/ethernet/amd/atarilance.c | 2 +- drivers/net/ethernet/amd/au1000_eth.c | 2 +- drivers/net/ethernet/amd/declance.c | 2 +- drivers/net/ethernet/amd/depca.c | 2 +- drivers/net/ethernet/amd/ni65.c | 2 +- drivers/net/ethernet/amd/nmclan_cs.c | 2 +- drivers/net/ethernet/amd/pcnet32.c | 14 +++++++------- drivers/net/ethernet/amd/sun3lance.c | 2 +- drivers/net/ethernet/amd/sunlance.c | 4 ++-- drivers/net/ethernet/apple/mace.c | 4 ++-- drivers/net/ethernet/apple/macmace.c | 2 +- drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 2 +- drivers/net/ethernet/cadence/at91_ether.c | 2 +- 28 files changed, 43 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/3com/3c501.c b/drivers/net/ethernet/3com/3c501.c index 68da81d476f3..bf73e1a02293 100644 --- a/drivers/net/ethernet/3com/3c501.c +++ b/drivers/net/ethernet/3com/3c501.c @@ -702,7 +702,7 @@ static void el_receive(struct net_device *dev) */ outb(AX_SYS, AX_CMD); - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); /* * Start of frame diff --git a/drivers/net/ethernet/3com/3c509.c b/drivers/net/ethernet/3com/3c509.c index 92053e6fc980..41719da2e178 100644 --- a/drivers/net/ethernet/3com/3c509.c +++ b/drivers/net/ethernet/3com/3c509.c @@ -1066,7 +1066,7 @@ el3_rx(struct net_device *dev) short pkt_len = rx_status & 0x7ff; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len+5); + skb = netdev_alloc_skb(dev, pkt_len + 5); if (el3_debug > 4) pr_debug("Receiving packet size %d status %4.4x.\n", pkt_len, rx_status); diff --git a/drivers/net/ethernet/3com/3c574_cs.c b/drivers/net/ethernet/3com/3c574_cs.c index 9c01bc9235b3..e61b2f82ba3a 100644 --- a/drivers/net/ethernet/3com/3c574_cs.c +++ b/drivers/net/ethernet/3com/3c574_cs.c @@ -1012,7 +1012,7 @@ static int el3_rx(struct net_device *dev, int worklimit) short pkt_len = rx_status & 0x7ff; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len+5); + skb = netdev_alloc_skb(dev, pkt_len + 5); pr_debug(" Receiving packet size %d status %4.4x.\n", pkt_len, rx_status); diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c index da410f036869..b23253b9f742 100644 --- a/drivers/net/ethernet/3com/3c589_cs.c +++ b/drivers/net/ethernet/3com/3c589_cs.c @@ -819,7 +819,7 @@ static int el3_rx(struct net_device *dev) short pkt_len = rx_status & 0x7ff; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len+5); + skb = netdev_alloc_skb(dev, pkt_len + 5); netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", pkt_len, rx_status); diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c index dc51d9218e6d..1282f048dfad 100644 --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c @@ -2499,7 +2499,7 @@ static int vortex_rx(struct net_device *dev) int pkt_len = rx_status & 0x1fff; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len + 5); + skb = netdev_alloc_skb(dev, pkt_len + 5); if (vortex_debug > 4) pr_debug("Receiving packet size %d status %4.4x.\n", pkt_len, rx_status); @@ -2578,7 +2578,8 @@ boomerang_rx(struct net_device *dev) /* Check if the packet is long enough to just accept without copying to a properly sized skbuff. */ - if (pkt_len < rx_copybreak && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + if (pkt_len < rx_copybreak && + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ pci_dma_sync_single_for_cpu(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); /* 'skb_put()' points to the start of sk_buff data area. */ diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c index 6d6bc754b1a8..f7d622eed203 100644 --- a/drivers/net/ethernet/3com/typhoon.c +++ b/drivers/net/ethernet/3com/typhoon.c @@ -1607,7 +1607,7 @@ typhoon_alloc_rx_skb(struct typhoon *tp, u32 idx) le32_to_cpu(indexes->rxBuffCleared)) return -ENOMEM; - skb = dev_alloc_skb(PKT_BUF_SZ); + skb = netdev_alloc_skb(tp->dev, PKT_BUF_SZ); if(!skb) return -ENOMEM; @@ -1618,7 +1618,6 @@ typhoon_alloc_rx_skb(struct typhoon *tp, u32 idx) skb_reserve(skb, 2); #endif - skb->dev = tp->dev; dma_addr = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); @@ -1673,7 +1672,7 @@ typhoon_rx(struct typhoon *tp, struct basic_ring *rxRing, volatile __le32 * read pkt_len = le16_to_cpu(rx->frameLen); if(pkt_len < rx_copybreak && - (new_skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (new_skb = netdev_alloc_skb(tp->dev, pkt_len + 2)) != NULL) { skb_reserve(new_skb, 2); pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, PKT_BUF_SZ, diff --git a/drivers/net/ethernet/8390/axnet_cs.c b/drivers/net/ethernet/8390/axnet_cs.c index 5de394368ff3..c5bd8eb7a9f5 100644 --- a/drivers/net/ethernet/8390/axnet_cs.c +++ b/drivers/net/ethernet/8390/axnet_cs.c @@ -1408,7 +1408,7 @@ static void ei_receive(struct net_device *dev) { struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { if (ei_debug > 1) diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c index 05ae21435bfd..e77f624e8194 100644 --- a/drivers/net/ethernet/8390/lib8390.c +++ b/drivers/net/ethernet/8390/lib8390.c @@ -717,7 +717,7 @@ static void ei_receive(struct net_device *dev) } else if ((pkt_stat & 0x0F) == ENRSR_RXOK) { struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { if (ei_debug > 1) netdev_dbg(dev, "Couldn't allocate a sk_buff of size %d\n", diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c index 11fc2eccb0fd..d896816512ca 100644 --- a/drivers/net/ethernet/adaptec/starfire.c +++ b/drivers/net/ethernet/adaptec/starfire.c @@ -1179,12 +1179,11 @@ static void init_ring(struct net_device *dev) /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); + struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz); np->rx_info[i].skb = skb; if (skb == NULL) break; np->rx_info[i].mapping = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE); - skb->dev = dev; /* Mark as being used by this device. */ /* Grrr, we cannot offset to correctly align the IP header. */ np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid); } @@ -1472,7 +1471,7 @@ static int __netdev_rx(struct net_device *dev, int *quota) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(np->pci_dev, np->rx_info[entry].mapping, @@ -1596,13 +1595,12 @@ static void refill_rx_ring(struct net_device *dev) for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) { entry = np->dirty_rx % RX_RING_SIZE; if (np->rx_info[entry].skb == NULL) { - skb = dev_alloc_skb(np->rx_buf_sz); + skb = netdev_alloc_skb(dev, np->rx_buf_sz); np->rx_info[entry].skb = skb; if (skb == NULL) break; /* Better luck next round. */ np->rx_info[entry].mapping = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE); - skb->dev = dev; /* Mark as being used by this device. */ np->rx_ring[entry].rxaddr = cpu_to_dma(np->rx_info[entry].mapping | RxDescValid); } diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c index c885aa905dec..b23751e683c8 100644 --- a/drivers/net/ethernet/aeroflex/greth.c +++ b/drivers/net/ethernet/aeroflex/greth.c @@ -785,7 +785,6 @@ static int greth_rx(struct net_device *dev, int limit) } else { skb_reserve(skb, NET_IP_ALIGN); - skb->dev = dev; dma_sync_single_for_cpu(greth->dev, dma_addr, diff --git a/drivers/net/ethernet/amd/7990.c b/drivers/net/ethernet/amd/7990.c index 60b35fb5f524..1b046f58d58f 100644 --- a/drivers/net/ethernet/amd/7990.c +++ b/drivers/net/ethernet/amd/7990.c @@ -316,7 +316,7 @@ static int lance_rx (struct net_device *dev) if (bits & LE_R1_EOP) dev->stats.rx_errors++; } else { int len = (rd->mblength & 0xfff) - 4; - struct sk_buff *skb = dev_alloc_skb (len+2); + struct sk_buff *skb = netdev_alloc_skb(dev, len + 2); if (!skb) { printk ("%s: Memory squeeze, deferring packet.\n", diff --git a/drivers/net/ethernet/amd/a2065.c b/drivers/net/ethernet/amd/a2065.c index 825e5d4ef4c3..689dfcafc6d4 100644 --- a/drivers/net/ethernet/amd/a2065.c +++ b/drivers/net/ethernet/amd/a2065.c @@ -290,7 +290,7 @@ static int lance_rx(struct net_device *dev) dev->stats.rx_errors++; } else { int len = (rd->mblength & 0xfff) - 4; - struct sk_buff *skb = dev_alloc_skb(len + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, len + 2); if (!skb) { netdev_warn(dev, "Memory squeeze, deferring packet\n"); diff --git a/drivers/net/ethernet/amd/am79c961a.c b/drivers/net/ethernet/amd/am79c961a.c index 216ae87b9459..cc7b9e46780c 100644 --- a/drivers/net/ethernet/amd/am79c961a.c +++ b/drivers/net/ethernet/amd/am79c961a.c @@ -516,7 +516,7 @@ am79c961_rx(struct net_device *dev, struct dev_priv *priv) } len = am_readword(dev, hdraddr + 6); - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len + 2); if (skb) { skb_reserve(skb, 2); diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c index b8306a589558..9f62504d0086 100644 --- a/drivers/net/ethernet/amd/amd8111e.c +++ b/drivers/net/ethernet/amd/amd8111e.c @@ -336,7 +336,8 @@ static int amd8111e_init_ring(struct net_device *dev) /* Allocating receive skbs */ for (i = 0; i < NUM_RX_BUFFERS; i++) { - if (!(lp->rx_skbuff[i] = dev_alloc_skb(lp->rx_buff_len))) { + lp->rx_skbuff[i] = netdev_alloc_skb(dev, lp->rx_buff_len); + if (!lp->rx_skbuff[i]) { /* Release previos allocated skbs */ for(--i; i >= 0 ;i--) dev_kfree_skb(lp->rx_skbuff[i]); @@ -768,7 +769,8 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) } if(--rx_pkt_limit < 0) goto rx_not_empty; - if(!(new_skb = dev_alloc_skb(lp->rx_buff_len))){ + new_skb = netdev_alloc_skb(dev, lp->rx_buff_len); + if (!new_skb) { /* if allocation fail, ignore that pkt and go to next one */ lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; diff --git a/drivers/net/ethernet/amd/ariadne.c b/drivers/net/ethernet/amd/ariadne.c index eb18e1fe65c8..f4c228e4d76c 100644 --- a/drivers/net/ethernet/amd/ariadne.c +++ b/drivers/net/ethernet/amd/ariadne.c @@ -191,7 +191,7 @@ static int ariadne_rx(struct net_device *dev) short pkt_len = swapw(priv->rx_ring[entry]->RMD3); struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len + 2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { netdev_warn(dev, "Memory squeeze, deferring packet\n"); for (i = 0; i < RX_RING_SIZE; i++) diff --git a/drivers/net/ethernet/amd/atarilance.c b/drivers/net/ethernet/amd/atarilance.c index 15bfa28d6c53..70ed79c46245 100644 --- a/drivers/net/ethernet/amd/atarilance.c +++ b/drivers/net/ethernet/amd/atarilance.c @@ -997,7 +997,7 @@ static int lance_rx( struct net_device *dev ) dev->stats.rx_errors++; } else { - skb = dev_alloc_skb( pkt_len+2 ); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n", dev->name )); diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index a81c871aeacf..c1dfdc8b7079 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -725,7 +725,7 @@ static int au1000_rx(struct net_device *dev) /* good frame */ frmlen = (status & RX_FRAME_LEN_MASK); frmlen -= 4; /* Remove FCS */ - skb = dev_alloc_skb(frmlen + 2); + skb = netdev_alloc_skb(dev, frmlen + 2); if (skb == NULL) { netdev_err(dev, "Memory squeeze, dropping packet.\n"); dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/amd/declance.c b/drivers/net/ethernet/amd/declance.c index dd82ee2f8d21..7dc508e5c72e 100644 --- a/drivers/net/ethernet/amd/declance.c +++ b/drivers/net/ethernet/amd/declance.c @@ -605,7 +605,7 @@ static int lance_rx(struct net_device *dev) dev->stats.rx_errors++; } else { len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4; - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len + 2); if (skb == 0) { printk("%s: Memory squeeze, deferring packet.\n", diff --git a/drivers/net/ethernet/amd/depca.c b/drivers/net/ethernet/amd/depca.c index 681970c07f22..86dd95766a64 100644 --- a/drivers/net/ethernet/amd/depca.c +++ b/drivers/net/ethernet/amd/depca.c @@ -1042,7 +1042,7 @@ static int depca_rx(struct net_device *dev) short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len + 2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb != NULL) { unsigned char *buf; skb_reserve(skb, 2); /* 16 byte align the IP header */ diff --git a/drivers/net/ethernet/amd/ni65.c b/drivers/net/ethernet/amd/ni65.c index 735c213798b1..013b65108536 100644 --- a/drivers/net/ethernet/amd/ni65.c +++ b/drivers/net/ethernet/amd/ni65.c @@ -1089,7 +1089,7 @@ static void ni65_recv_intr(struct net_device *dev,int csr0) if (skb) skb_reserve(skb,16); #else - struct sk_buff *skb = dev_alloc_skb(len+2); + struct sk_buff *skb = netdev_alloc_skb(dev, len + 2); #endif if(skb) { diff --git a/drivers/net/ethernet/amd/nmclan_cs.c b/drivers/net/ethernet/amd/nmclan_cs.c index 6be0dd67631a..ebdb9e238a8d 100644 --- a/drivers/net/ethernet/amd/nmclan_cs.c +++ b/drivers/net/ethernet/amd/nmclan_cs.c @@ -1104,7 +1104,7 @@ static int mace_rx(struct net_device *dev, unsigned char RxCnt) pr_debug(" receiving packet size 0x%X rx_status" " 0x%X.\n", pkt_len, rx_status); - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb != NULL) { skb_reserve(skb, 2); diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c index 1bb388f62e5b..86b6d8e4e6cd 100644 --- a/drivers/net/ethernet/amd/pcnet32.c +++ b/drivers/net/ethernet/amd/pcnet32.c @@ -588,11 +588,11 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev, /* now allocate any new buffers needed */ for (; new < size; new++) { struct sk_buff *rx_skbuff; - new_skb_list[new] = dev_alloc_skb(PKT_BUF_SKB); + new_skb_list[new] = netdev_alloc_skb(dev, PKT_BUF_SKB); rx_skbuff = new_skb_list[new]; if (!rx_skbuff) { /* keep the original lists and buffers */ - netif_err(lp, drv, dev, "%s dev_alloc_skb failed\n", + netif_err(lp, drv, dev, "%s netdev_alloc_skb failed\n", __func__); goto free_all_new; } @@ -909,7 +909,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) /* Initialize Transmit buffers. */ size = data_len + 15; for (x = 0; x < numbuffs; x++) { - skb = dev_alloc_skb(size); + skb = netdev_alloc_skb(dev, size); if (!skb) { netif_printk(lp, hw, KERN_DEBUG, dev, "Cannot allocate skb at line: %d!\n", @@ -1152,7 +1152,7 @@ static void pcnet32_rx_entry(struct net_device *dev, if (pkt_len > rx_copybreak) { struct sk_buff *newskb; - newskb = dev_alloc_skb(PKT_BUF_SKB); + newskb = netdev_alloc_skb(dev, PKT_BUF_SKB); if (newskb) { skb_reserve(newskb, NET_IP_ALIGN); skb = lp->rx_skbuff[entry]; @@ -1172,7 +1172,7 @@ static void pcnet32_rx_entry(struct net_device *dev, } else skb = NULL; } else - skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN); + skb = netdev_alloc_skb(dev, pkt_len + NET_IP_ALIGN); if (skb == NULL) { netif_err(lp, drv, dev, "Memory squeeze, dropping packet\n"); @@ -2271,11 +2271,11 @@ static int pcnet32_init_ring(struct net_device *dev) for (i = 0; i < lp->rx_ring_size; i++) { struct sk_buff *rx_skbuff = lp->rx_skbuff[i]; if (rx_skbuff == NULL) { - lp->rx_skbuff[i] = dev_alloc_skb(PKT_BUF_SKB); + lp->rx_skbuff[i] = netdev_alloc_skb(dev, PKT_BUF_SKB); rx_skbuff = lp->rx_skbuff[i]; if (!rx_skbuff) { /* there is not much we can do at this point */ - netif_err(lp, drv, dev, "%s dev_alloc_skb failed\n", + netif_err(lp, drv, dev, "%s netdev_alloc_skb failed\n", __func__); return -1; } diff --git a/drivers/net/ethernet/amd/sun3lance.c b/drivers/net/ethernet/amd/sun3lance.c index 080b71fcc683..74b3891b6483 100644 --- a/drivers/net/ethernet/amd/sun3lance.c +++ b/drivers/net/ethernet/amd/sun3lance.c @@ -810,7 +810,7 @@ static int lance_rx( struct net_device *dev ) dev->stats.rx_errors++; } else { - skb = dev_alloc_skb( pkt_len+2 ); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n", dev->name )); diff --git a/drivers/net/ethernet/amd/sunlance.c b/drivers/net/ethernet/amd/sunlance.c index 7ea16d32a5f5..e3fe3504e198 100644 --- a/drivers/net/ethernet/amd/sunlance.c +++ b/drivers/net/ethernet/amd/sunlance.c @@ -534,7 +534,7 @@ static void lance_rx_dvma(struct net_device *dev) if (bits & LE_R1_EOP) dev->stats.rx_errors++; } else { len = (rd->mblength & 0xfff) - 4; - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len + 2); if (skb == NULL) { printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", @@ -706,7 +706,7 @@ static void lance_rx_pio(struct net_device *dev) if (bits & LE_R1_EOP) dev->stats.rx_errors++; } else { len = (sbus_readw(&rd->mblength) & 0xfff) - 4; - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len + 2); if (skb == NULL) { printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", diff --git a/drivers/net/ethernet/apple/mace.c b/drivers/net/ethernet/apple/mace.c index bd5555dbe027..06998462e0d3 100644 --- a/drivers/net/ethernet/apple/mace.c +++ b/drivers/net/ethernet/apple/mace.c @@ -444,7 +444,7 @@ static int mace_open(struct net_device *dev) memset((char *)mp->rx_cmds, 0, N_RX_RING * sizeof(struct dbdma_cmd)); cp = mp->rx_cmds; for (i = 0; i < N_RX_RING - 1; ++i) { - skb = dev_alloc_skb(RX_BUFLEN + 2); + skb = netdev_alloc_skb(dev, RX_BUFLEN + 2); if (!skb) { data = dummy_buf; } else { @@ -956,7 +956,7 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id) cp = mp->rx_cmds + i; skb = mp->rx_bufs[i]; if (!skb) { - skb = dev_alloc_skb(RX_BUFLEN + 2); + skb = netdev_alloc_skb(RX_BUFLEN + 2); if (skb) { skb_reserve(skb, 2); mp->rx_bufs[i] = skb; diff --git a/drivers/net/ethernet/apple/macmace.c b/drivers/net/ethernet/apple/macmace.c index 7cf81bbffe0e..ab7ff8645ab1 100644 --- a/drivers/net/ethernet/apple/macmace.c +++ b/drivers/net/ethernet/apple/macmace.c @@ -661,7 +661,7 @@ static void mace_dma_rx_frame(struct net_device *dev, struct mace_frame *mf) } else { unsigned int frame_length = mf->rcvcnt + ((frame_status & 0x0F) << 8 ); - skb = dev_alloc_skb(frame_length + 2); + skb = netdev_alloc_skb(dev, frame_length + 2); if (!skb) { dev->stats.rx_dropped++; return; diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index 7ee4aacb01a4..2c8ed70704aa 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c @@ -1765,7 +1765,7 @@ static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter, const int ringid while (next_info->flags & ATL1C_BUFFER_FREE) { rfd_desc = ATL1C_RFD_DESC(rfd_ring, rfd_next_to_use); - skb = dev_alloc_skb(adapter->rx_buffer_len); + skb = netdev_alloc_skb(adapter->netdev, adapter->rx_buffer_len); if (unlikely(!skb)) { if (netif_msg_rx_err(adapter)) dev_warn(&pdev->dev, "alloc rx buffer failed\n"); diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c index 1a5b6efa0120..906117016fc4 100644 --- a/drivers/net/ethernet/cadence/at91_ether.c +++ b/drivers/net/ethernet/cadence/at91_ether.c @@ -886,7 +886,7 @@ static void at91ether_rx(struct net_device *dev) while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) { p_recv = dlist->recv_buf[lp->rxBuffIndex]; pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */ - skb = dev_alloc_skb(pktlen + 2); + skb = netdev_alloc_skb(dev, pktlen + 2); if (skb != NULL) { skb_reserve(skb, 2); memcpy(skb_put(skb, pktlen), p_recv, pktlen); -- GitLab From 21a4e46995fa1a76281ac0281ff837f706231a37 Mon Sep 17 00:00:00 2001 From: Pradeep A Dalvi Date: Sun, 5 Feb 2012 02:50:10 +0000 Subject: [PATCH 0378/1846] netdev: ethernet dev_alloc_skb to netdev_alloc_skb Replaced deprecating dev_alloc_skb with netdev_alloc_skb in drivers/net/ethernet - Removed extra skb->dev = dev after netdev_alloc_skb Signed-off-by: Pradeep A Dalvi Signed-off-by: David S. Miller --- drivers/net/ethernet/cadence/macb.c | 2 +- drivers/net/ethernet/cirrus/cs89x0.c | 4 ++-- drivers/net/ethernet/cirrus/ep93xx_eth.c | 2 +- drivers/net/ethernet/davicom/dm9000.c | 2 +- drivers/net/ethernet/dec/ewrk3.c | 4 +++- drivers/net/ethernet/dec/tulip/de2104x.c | 6 ++---- drivers/net/ethernet/dec/tulip/de4x5.c | 4 ++-- drivers/net/ethernet/dec/tulip/interrupt.c | 8 ++++---- drivers/net/ethernet/dec/tulip/tulip_core.c | 5 ++--- drivers/net/ethernet/dec/tulip/winbond-840.c | 6 +++--- drivers/net/ethernet/dec/tulip/xircom_cb.c | 2 +- drivers/net/ethernet/dlink/de600.c | 2 +- drivers/net/ethernet/dlink/de620.c | 2 +- drivers/net/ethernet/dlink/sundance.c | 9 ++++----- drivers/net/ethernet/dnet.c | 2 +- drivers/net/ethernet/fealnx.c | 8 +++----- drivers/net/ethernet/freescale/fec.c | 4 ++-- drivers/net/ethernet/freescale/fec_mpc52xx.c | 4 ++-- .../net/ethernet/freescale/fs_enet/fs_enet-main.c | 12 ++++++------ drivers/net/ethernet/freescale/ucc_geth.c | 7 +++---- drivers/net/ethernet/fujitsu/at1700.c | 2 +- 21 files changed, 46 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 3c315f46859b..85e044567f68 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -397,7 +397,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, netdev_dbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n", first_frag, last_frag, len); - skb = dev_alloc_skb(len + RX_OFFSET); + skb = netdev_alloc_skb(bp->dev, len + RX_OFFSET); if (!skb) { bp->stats.rx_dropped++; for (frag = first_frag; ; frag = NEXT_RX(frag)) { diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c index f328da24c8fa..d5ff93653e4c 100644 --- a/drivers/net/ethernet/cirrus/cs89x0.c +++ b/drivers/net/ethernet/cirrus/cs89x0.c @@ -911,7 +911,7 @@ dma_rx(struct net_device *dev) } /* Malloc up new buffer. */ - skb = dev_alloc_skb(length + 2); + skb = netdev_alloc_skb(dev, length + 2); if (skb == NULL) { if (net_debug) /* I don't think we want to do this to a stressed system */ printk("%s: Memory squeeze, dropping packet.\n", dev->name); @@ -1616,7 +1616,7 @@ net_rx(struct net_device *dev) } /* Malloc up new buffer. */ - skb = dev_alloc_skb(length + 2); + skb = netdev_alloc_skb(dev, length + 2); if (skb == NULL) { #if 0 /* Again, this seems a cruel thing to do */ printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c index 4317af8d2f0a..c21e5ab8d1ef 100644 --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c @@ -282,7 +282,7 @@ static int ep93xx_rx(struct net_device *dev, int processed, int budget) if (rstat0 & RSTAT0_CRCI) length -= 4; - skb = dev_alloc_skb(length + 2); + skb = netdev_alloc_skb(dev, length + 2); if (likely(skb != NULL)) { struct ep93xx_rdesc *rxd = &ep->descs->rdesc[entry]; skb_reserve(skb, 2); diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c index 493cc6202081..42383ab5227e 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c @@ -1028,7 +1028,7 @@ dm9000_rx(struct net_device *dev) /* Move data from DM9000 */ if (GoodPacket && - ((skb = dev_alloc_skb(RxLen + 4)) != NULL)) { + ((skb = netdev_alloc_skb(dev, RxLen + 4)) != NULL)) { skb_reserve(skb, 2); rdptr = (u8 *) skb_put(skb, RxLen - 4); diff --git a/drivers/net/ethernet/dec/ewrk3.c b/drivers/net/ethernet/dec/ewrk3.c index f9df5e4d0341..1879f84a25a3 100644 --- a/drivers/net/ethernet/dec/ewrk3.c +++ b/drivers/net/ethernet/dec/ewrk3.c @@ -986,8 +986,10 @@ static int ewrk3_rx(struct net_device *dev) dev->stats.rx_fifo_errors++; } else { struct sk_buff *skb; + skb = netdev_alloc_skb(dev, + pkt_len + 2); - if ((skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + if (skb != NULL) { unsigned char *p; skb_reserve(skb, 2); /* Align to 16 bytes */ p = skb_put(skb, pkt_len); diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c index 1eb46a0bb488..68f1c39184df 100644 --- a/drivers/net/ethernet/dec/tulip/de2104x.c +++ b/drivers/net/ethernet/dec/tulip/de2104x.c @@ -439,7 +439,7 @@ static void de_rx (struct de_private *de) rx_tail, status, len, copying_skb); buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz; - copy_skb = dev_alloc_skb (buflen); + copy_skb = netdev_alloc_skb(de->dev, buflen); if (unlikely(!copy_skb)) { de->net_stats.rx_dropped++; drop = 1; @@ -1283,12 +1283,10 @@ static int de_refill_rx (struct de_private *de) for (i = 0; i < DE_RX_RING_SIZE; i++) { struct sk_buff *skb; - skb = dev_alloc_skb(de->rx_buf_sz); + skb = netdev_alloc_skb(de->dev, de->rx_buf_sz); if (!skb) goto err_out; - skb->dev = de->dev; - de->rx_skb[i].mapping = pci_map_single(de->pdev, skb->data, de->rx_buf_sz, PCI_DMA_FROMDEVICE); de->rx_skb[i].skb = skb; diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c index 4d71f5ae20c8..93583408a325 100644 --- a/drivers/net/ethernet/dec/tulip/de4x5.c +++ b/drivers/net/ethernet/dec/tulip/de4x5.c @@ -3598,7 +3598,7 @@ de4x5_alloc_rx_buff(struct net_device *dev, int index, int len) struct sk_buff *ret; u_long i=0, tmp; - p = dev_alloc_skb(IEEE802_3_SZ + DE4X5_ALIGN + 2); + p = netdev_alloc_skb(dev, IEEE802_3_SZ + DE4X5_ALIGN + 2); if (!p) return NULL; tmp = virt_to_bus(p->data); @@ -3618,7 +3618,7 @@ de4x5_alloc_rx_buff(struct net_device *dev, int index, int len) #else if (lp->state != OPEN) return (struct sk_buff *)1; /* Fake out the open */ - p = dev_alloc_skb(len + 2); + p = netdev_alloc_skb(dev, len + 2); if (!p) return NULL; skb_reserve(p, 2); /* Align */ diff --git a/drivers/net/ethernet/dec/tulip/interrupt.c b/drivers/net/ethernet/dec/tulip/interrupt.c index feaee7424bd9..28a5e425fecf 100644 --- a/drivers/net/ethernet/dec/tulip/interrupt.c +++ b/drivers/net/ethernet/dec/tulip/interrupt.c @@ -69,7 +69,8 @@ int tulip_refill_rx(struct net_device *dev) struct sk_buff *skb; dma_addr_t mapping; - skb = tp->rx_buffers[entry].skb = dev_alloc_skb(PKT_BUF_SZ); + skb = tp->rx_buffers[entry].skb = + netdev_alloc_skb(dev, PKT_BUF_SZ); if (skb == NULL) break; @@ -77,7 +78,6 @@ int tulip_refill_rx(struct net_device *dev) PCI_DMA_FROMDEVICE); tp->rx_buffers[entry].mapping = mapping; - skb->dev = dev; /* Mark as being used by this device. */ tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping); refilled++; } @@ -202,7 +202,7 @@ int tulip_poll(struct napi_struct *napi, int budget) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < tulip_rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(tp->pdev, tp->rx_buffers[entry].mapping, @@ -428,7 +428,7 @@ static int tulip_rx(struct net_device *dev) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < tulip_rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(tp->pdev, tp->rx_buffers[entry].mapping, diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c index 17ecb18341c9..fea3641d9398 100644 --- a/drivers/net/ethernet/dec/tulip/tulip_core.c +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c @@ -636,16 +636,15 @@ static void tulip_init_ring(struct net_device *dev) dma_addr_t mapping; /* Note the receive buffer must be longword aligned. - dev_alloc_skb() provides 16 byte alignment. But do *not* + netdev_alloc_skb() provides 16 byte alignment. But do *not* use skb_reserve() to align the IP header! */ - struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ); + struct sk_buff *skb = netdev_alloc_skb(dev, PKT_BUF_SZ); tp->rx_buffers[i].skb = skb; if (skb == NULL) break; mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); tp->rx_buffers[i].mapping = mapping; - skb->dev = dev; /* Mark as being used by this device. */ tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */ tp->rx_ring[i].buffer1 = cpu_to_le32(mapping); } diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c index 52da7b2fe3b6..2ac6fff0363a 100644 --- a/drivers/net/ethernet/dec/tulip/winbond-840.c +++ b/drivers/net/ethernet/dec/tulip/winbond-840.c @@ -815,7 +815,7 @@ static void init_rxtx_rings(struct net_device *dev) /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); + struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz); np->rx_skbuff[i] = skb; if (skb == NULL) break; @@ -1231,7 +1231,7 @@ static int netdev_rx(struct net_device *dev) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry], np->rx_skbuff[entry]->len, @@ -1270,7 +1270,7 @@ static int netdev_rx(struct net_device *dev) struct sk_buff *skb; entry = np->dirty_rx % RX_RING_SIZE; if (np->rx_skbuff[entry] == NULL) { - skb = dev_alloc_skb(np->rx_buf_sz); + skb = netdev_alloc_skb(dev, np->rx_buf_sz); np->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c index b7c73eefb54b..fdb329fe6e8e 100644 --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c +++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c @@ -1084,7 +1084,7 @@ investigate_read_descriptor(struct net_device *dev, struct xircom_private *card, pkt_len = 1518; } - skb = dev_alloc_skb(pkt_len + 2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { dev->stats.rx_dropped++; goto out; diff --git a/drivers/net/ethernet/dlink/de600.c b/drivers/net/ethernet/dlink/de600.c index c24fab1e9cbe..682750c052c8 100644 --- a/drivers/net/ethernet/dlink/de600.c +++ b/drivers/net/ethernet/dlink/de600.c @@ -335,7 +335,7 @@ static void de600_rx_intr(struct net_device *dev) return; } - skb = dev_alloc_skb(size+2); + skb = netdev_alloc_skb(dev, size + 2); if (skb == NULL) { printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size); return; diff --git a/drivers/net/ethernet/dlink/de620.c b/drivers/net/ethernet/dlink/de620.c index 3b934ab784d3..afc5aaac6b60 100644 --- a/drivers/net/ethernet/dlink/de620.c +++ b/drivers/net/ethernet/dlink/de620.c @@ -650,7 +650,7 @@ static int de620_rx_intr(struct net_device *dev) printk(KERN_WARNING "%s: Illegal packet size: %d!\n", dev->name, size); } else { /* Good packet? */ - skb = dev_alloc_skb(size+2); + skb = netdev_alloc_skb(dev, size + 2); if (skb == NULL) { /* Yeah, but no place to put it... */ printk(KERN_WARNING "%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size); dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c index 28a3a9b50b8b..7227f29ee2ee 100644 --- a/drivers/net/ethernet/dlink/sundance.c +++ b/drivers/net/ethernet/dlink/sundance.c @@ -1020,11 +1020,11 @@ static void init_ring(struct net_device *dev) /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + 2); + struct sk_buff *skb = + netdev_alloc_skb(dev, np->rx_buf_sz + 2); np->rx_skbuff[i] = skb; if (skb == NULL) break; - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* 16 byte align the IP header. */ np->rx_ring[i].frag[0].addr = cpu_to_le32( dma_map_single(&np->pci_dev->dev, skb->data, @@ -1358,7 +1358,7 @@ static void rx_poll(unsigned long data) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ dma_sync_single_for_cpu(&np->pci_dev->dev, le32_to_cpu(desc->frag[0].addr), @@ -1411,11 +1411,10 @@ static void refill_rx (struct net_device *dev) struct sk_buff *skb; entry = np->dirty_rx % RX_RING_SIZE; if (np->rx_skbuff[entry] == NULL) { - skb = dev_alloc_skb(np->rx_buf_sz + 2); + skb = netdev_alloc_skb(dev, np->rx_buf_sz + 2); np->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ np->rx_ring[entry].frag[0].addr = cpu_to_le32( dma_map_single(&np->pci_dev->dev, skb->data, diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c index fe48cb7dde21..8536e376555a 100644 --- a/drivers/net/ethernet/dnet.c +++ b/drivers/net/ethernet/dnet.c @@ -421,7 +421,7 @@ static int dnet_poll(struct napi_struct *napi, int budget) printk(KERN_ERR "%s packet receive error %x\n", __func__, cmd_word); - skb = dev_alloc_skb(pkt_len + 5); + skb = netdev_alloc_skb(dev, pkt_len + 5); if (skb != NULL) { /* Align IP on 16 byte boundaries */ skb_reserve(skb, 2); diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c index c82d444b582d..1637b9862292 100644 --- a/drivers/net/ethernet/fealnx.c +++ b/drivers/net/ethernet/fealnx.c @@ -1070,14 +1070,13 @@ static void allocate_rx_buffers(struct net_device *dev) while (np->really_rx_count != RX_RING_SIZE) { struct sk_buff *skb; - skb = dev_alloc_skb(np->rx_buf_sz); + skb = netdev_alloc_skb(dev, np->rx_buf_sz); if (skb == NULL) break; /* Better luck next round. */ while (np->lack_rxbuf->skbuff) np->lack_rxbuf = np->lack_rxbuf->next_desc_logical; - skb->dev = dev; /* Mark as being used by this device. */ np->lack_rxbuf->skbuff = skb; np->lack_rxbuf->buffer = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE); @@ -1265,7 +1264,7 @@ static void init_ring(struct net_device *dev) /* allocate skb for rx buffers */ for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); + struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz); if (skb == NULL) { np->lack_rxbuf = &np->rx_ring[i]; @@ -1274,7 +1273,6 @@ static void init_ring(struct net_device *dev) ++np->really_rx_count; np->rx_ring[i].skbuff = skb; - skb->dev = dev; /* Mark as being used by this device. */ np->rx_ring[i].buffer = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE); np->rx_ring[i].status = RXOWN; @@ -1704,7 +1702,7 @@ static int netdev_rx(struct net_device *dev) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(np->pci_dev, np->cur_rx->buffer, diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index 336edd7e0b78..f976619d1b21 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -711,7 +711,7 @@ fec_enet_rx(struct net_device *ndev) * include that when passing upstream as it messes up * bridging applications. */ - skb = dev_alloc_skb(pkt_len - 4 + NET_IP_ALIGN); + skb = netdev_alloc_skb(dev, pkt_len - 4 + NET_IP_ALIGN); if (unlikely(!skb)) { printk("%s: Memory squeeze, dropping packet.\n", @@ -1210,7 +1210,7 @@ static int fec_enet_alloc_buffers(struct net_device *ndev) bdp = fep->rx_bd_base; for (i = 0; i < RX_RING_SIZE; i++) { - skb = dev_alloc_skb(FEC_ENET_RX_FRSIZE); + skb = netdev_alloc_skb(dev, FEC_ENET_RX_FRSIZE); if (!skb) { fec_enet_free_buffers(ndev); return -ENOMEM; diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c index 30745b56fe5d..7b34d8c698da 100644 --- a/drivers/net/ethernet/freescale/fec_mpc52xx.c +++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c @@ -160,7 +160,7 @@ static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task struct sk_buff *skb; while (!bcom_queue_full(rxtsk)) { - skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); + skb = netdev_alloc_skb(dev, FEC_RX_BUFFER_SIZE); if (!skb) return -EAGAIN; @@ -416,7 +416,7 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id) /* skbs are allocated on open, so now we allocate a new one, * and remove the old (with the packet) */ - skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); + skb = netdev_alloc_skb(dev, FEC_RX_BUFFER_SIZE); if (!skb) { /* Can't get a new one : reuse the same & drop pkt */ dev_notice(&dev->dev, "Low memory - dropped packet.\n"); diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c index 910a8e18a9ae..999638a7c851 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c @@ -154,7 +154,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget) if (pkt_len <= fpi->rx_copybreak) { /* +2 to make IP header L1 cache aligned */ - skbn = dev_alloc_skb(pkt_len + 2); + skbn = netdev_alloc_skb(dev, pkt_len + 2); if (skbn != NULL) { skb_reserve(skbn, 2); /* align IP header */ skb_copy_from_linear_data(skb, @@ -165,7 +165,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget) skbn = skbt; } } else { - skbn = dev_alloc_skb(ENET_RX_FRSIZE); + skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE); if (skbn) skb_align(skbn, ENET_RX_ALIGN); @@ -286,7 +286,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev) if (pkt_len <= fpi->rx_copybreak) { /* +2 to make IP header L1 cache aligned */ - skbn = dev_alloc_skb(pkt_len + 2); + skbn = netdev_alloc_skb(dev, pkt_len + 2); if (skbn != NULL) { skb_reserve(skbn, 2); /* align IP header */ skb_copy_from_linear_data(skb, @@ -297,7 +297,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev) skbn = skbt; } } else { - skbn = dev_alloc_skb(ENET_RX_FRSIZE); + skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE); if (skbn) skb_align(skbn, ENET_RX_ALIGN); @@ -504,7 +504,7 @@ void fs_init_bds(struct net_device *dev) * Initialize the receive buffer descriptors. */ for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { - skb = dev_alloc_skb(ENET_RX_FRSIZE); + skb = netdev_alloc_skb(dev, ENET_RX_FRSIZE); if (skb == NULL) { dev_warn(fep->dev, "Memory squeeze, unable to allocate skb\n"); @@ -592,7 +592,7 @@ static struct sk_buff *tx_skb_align_workaround(struct net_device *dev, struct fs_enet_private *fep = netdev_priv(dev); /* Alloc new skb */ - new_skb = dev_alloc_skb(skb->len + 4); + new_skb = netdev_alloc_skb(dev, skb->len + 4); if (!new_skb) { if (net_ratelimit()) { dev_warn(fep->dev, diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index ba2dc083bfc0..ec0905461312 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -214,8 +214,9 @@ static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, skb = __skb_dequeue(&ugeth->rx_recycle); if (!skb) - skb = dev_alloc_skb(ugeth->ug_info->uf_info.max_rx_buf_length + - UCC_GETH_RX_DATA_BUF_ALIGNMENT); + skb = netdev_alloc_skb(ugeth->ndev, + ugeth->ug_info->uf_info.max_rx_buf_length + + UCC_GETH_RX_DATA_BUF_ALIGNMENT); if (skb == NULL) return NULL; @@ -227,8 +228,6 @@ static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, (((unsigned)skb->data) & (UCC_GETH_RX_DATA_BUF_ALIGNMENT - 1))); - skb->dev = ugeth->ndev; - out_be32(&((struct qe_bd __iomem *)bd)->buf, dma_map_single(ugeth->dev, skb->data, diff --git a/drivers/net/ethernet/fujitsu/at1700.c b/drivers/net/ethernet/fujitsu/at1700.c index 7c6c908bdf02..586b46fd4eed 100644 --- a/drivers/net/ethernet/fujitsu/at1700.c +++ b/drivers/net/ethernet/fujitsu/at1700.c @@ -757,7 +757,7 @@ net_rx(struct net_device *dev) dev->stats.rx_errors++; break; } - skb = dev_alloc_skb(pkt_len+3); + skb = netdev_alloc_skb(dev, pkt_len + 3); if (skb == NULL) { printk("%s: Memory squeeze, dropping packet (len %d).\n", dev->name, pkt_len); -- GitLab From c056b734e54e12f38f34a2583a4824e6cecc16c1 Mon Sep 17 00:00:00 2001 From: Pradeep A Dalvi Date: Sun, 5 Feb 2012 02:50:38 +0000 Subject: [PATCH 0379/1846] netdev: ethernet dev_alloc_skb to netdev_alloc_skb Replaced deprecating dev_alloc_skb with netdev_alloc_skb in drivers/net/ethernet - Removed extra skb->dev = dev after netdev_alloc_skb Signed-off-by: Pradeep A Dalvi Signed-off-by: David S. Miller --- drivers/net/ethernet/fujitsu/eth16i.c | 2 +- drivers/net/ethernet/fujitsu/fmvj18x_cs.c | 2 +- drivers/net/ethernet/hp/hp100.c | 5 ++--- drivers/net/ethernet/i825xx/3c505.c | 2 +- drivers/net/ethernet/i825xx/3c507.c | 2 +- drivers/net/ethernet/i825xx/3c523.c | 2 +- drivers/net/ethernet/i825xx/3c527.c | 4 ++-- drivers/net/ethernet/i825xx/82596.c | 8 +++----- drivers/net/ethernet/i825xx/eepro.c | 2 +- drivers/net/ethernet/i825xx/eexpress.c | 2 +- drivers/net/ethernet/i825xx/ether1.c | 2 +- drivers/net/ethernet/i825xx/lp486e.c | 2 +- drivers/net/ethernet/i825xx/ni52.c | 2 +- drivers/net/ethernet/i825xx/sun3_82586.c | 2 +- drivers/net/ethernet/i825xx/znet.c | 2 +- drivers/net/ethernet/icplus/ipg.c | 3 --- drivers/net/ethernet/lantiq_etop.c | 2 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- drivers/net/ethernet/marvell/pxa168_eth.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 +-- drivers/net/ethernet/micrel/ks8695net.c | 4 ++-- drivers/net/ethernet/micrel/ks8851_mll.c | 2 +- drivers/net/ethernet/micrel/ksz884x.c | 6 +++--- drivers/net/ethernet/microchip/enc28j60.c | 3 +-- drivers/net/ethernet/mipsnet.c | 2 +- drivers/net/ethernet/natsemi/ibmlana.c | 2 +- drivers/net/ethernet/natsemi/natsemi.c | 5 ++--- drivers/net/ethernet/natsemi/sonic.c | 4 ++-- drivers/net/ethernet/neterion/s2io.c | 6 +++--- 29 files changed, 39 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/fujitsu/eth16i.c b/drivers/net/ethernet/fujitsu/eth16i.c index b0e2313af3d1..c3f0178fb5cb 100644 --- a/drivers/net/ethernet/fujitsu/eth16i.c +++ b/drivers/net/ethernet/fujitsu/eth16i.c @@ -1164,7 +1164,7 @@ static void eth16i_rx(struct net_device *dev) else { /* Ok so now we should have a good packet */ struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len + 3); + skb = netdev_alloc_skb(dev, pkt_len + 3); if( skb == NULL ) { printk(KERN_WARNING "%s: Could'n allocate memory for packet (len %d)\n", dev->name, pkt_len); diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c index ee84b472cee6..0230319ddb59 100644 --- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c +++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c @@ -1002,7 +1002,7 @@ static void fjn_rx(struct net_device *dev) dev->stats.rx_errors++; break; } - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { netdev_notice(dev, "Memory squeeze, dropping packet (len %d)\n", pkt_len); diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c index 3598c5408e79..d496673f0908 100644 --- a/drivers/net/ethernet/hp/hp100.c +++ b/drivers/net/ethernet/hp/hp100.c @@ -1274,7 +1274,7 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr, /* Note: This depends on the alloc_skb functions allocating more * space than requested, i.e. aligning to 16bytes */ - ringptr->skb = dev_alloc_skb(roundup(MAX_ETHER_SIZE + 2, 4)); + ringptr->skb = netdev_alloc_skb(dev, roundup(MAX_ETHER_SIZE + 2, 4)); if (NULL != ringptr->skb) { /* @@ -1284,7 +1284,6 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr, */ skb_reserve(ringptr->skb, 2); - ringptr->skb->dev = dev; ringptr->skb->data = (u_char *) skb_put(ringptr->skb, MAX_ETHER_SIZE); /* ringptr->pdl points to the beginning of the PDL, i.e. the PDH */ @@ -1817,7 +1816,7 @@ static void hp100_rx(struct net_device *dev) #endif /* Now we allocate the skb and transfer the data into it. */ - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { /* Not enough memory->drop packet */ #ifdef HP100_DEBUG printk("hp100: %s: rx: couldn't allocate a sk_buff of size %d\n", diff --git a/drivers/net/ethernet/i825xx/3c505.c b/drivers/net/ethernet/i825xx/3c505.c index ba82a266051d..6a5c21b82c51 100644 --- a/drivers/net/ethernet/i825xx/3c505.c +++ b/drivers/net/ethernet/i825xx/3c505.c @@ -583,7 +583,7 @@ static void receive_packet(struct net_device *dev, int len) unsigned long flags; rlen = (len + 1) & ~1; - skb = dev_alloc_skb(rlen + 2); + skb = netdev_alloc_skb(dev, rlen + 2); if (!skb) { pr_warning("%s: memory squeeze, dropping packet\n", dev->name); diff --git a/drivers/net/ethernet/i825xx/3c507.c b/drivers/net/ethernet/i825xx/3c507.c index 1e945551c144..ed6925f11479 100644 --- a/drivers/net/ethernet/i825xx/3c507.c +++ b/drivers/net/ethernet/i825xx/3c507.c @@ -851,7 +851,7 @@ static void el16_rx(struct net_device *dev) struct sk_buff *skb; pkt_len &= 0x3fff; - skb = dev_alloc_skb(pkt_len+2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { pr_err("%s: Memory squeeze, dropping packet.\n", dev->name); diff --git a/drivers/net/ethernet/i825xx/3c523.c b/drivers/net/ethernet/i825xx/3c523.c index d70d3df4c985..8451ecd4c1ec 100644 --- a/drivers/net/ethernet/i825xx/3c523.c +++ b/drivers/net/ethernet/i825xx/3c523.c @@ -983,7 +983,7 @@ static void elmc_rcv_int(struct net_device *dev) if ((totlen = rbd->status) & RBD_LAST) { /* the first and the last buffer? */ totlen &= RBD_MASK; /* length of this frame */ rbd->status = 0; - skb = (struct sk_buff *) dev_alloc_skb(totlen + 2); + skb = netdev_alloc_skb(dev, totlen + 2); if (skb != NULL) { skb_reserve(skb, 2); /* 16 byte alignment */ skb_put(skb,totlen); diff --git a/drivers/net/ethernet/i825xx/3c527.c b/drivers/net/ethernet/i825xx/3c527.c index 474b5e71a53a..ef43f3e951c5 100644 --- a/drivers/net/ethernet/i825xx/3c527.c +++ b/drivers/net/ethernet/i825xx/3c527.c @@ -1169,7 +1169,7 @@ static void mc32_rx_ring(struct net_device *dev) /* Try to save time by avoiding a copy on big frames */ if ((length > RX_COPYBREAK) && - ((newskb=dev_alloc_skb(1532)) != NULL)) + ((newskb = netdev_alloc_skb(dev, 1532)) != NULL)) { skb=lp->rx_ring[rx_ring_tail].skb; skb_put(skb, length); @@ -1180,7 +1180,7 @@ static void mc32_rx_ring(struct net_device *dev) } else { - skb=dev_alloc_skb(length+2); + skb = netdev_alloc_skb(dev, length + 2); if(skb==NULL) { dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/i825xx/82596.c b/drivers/net/ethernet/i825xx/82596.c index f2408a4d5d9c..6aa927af382c 100644 --- a/drivers/net/ethernet/i825xx/82596.c +++ b/drivers/net/ethernet/i825xx/82596.c @@ -549,14 +549,13 @@ static inline int init_rx_bufs(struct net_device *dev) /* First build the Receive Buffer Descriptor List */ for (i = 0, rbd = lp->rbds; i < rx_ring_size; i++, rbd++) { - struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ); + struct sk_buff *skb = netdev_alloc_skb(dev, PKT_BUF_SZ); if (skb == NULL) { remove_rx_bufs(dev); return -ENOMEM; } - skb->dev = dev; rbd->v_next = rbd+1; rbd->b_next = WSWAPrbd(virt_to_bus(rbd+1)); rbd->b_addr = WSWAPrbd(virt_to_bus(rbd)); @@ -810,7 +809,7 @@ static inline int i596_rx(struct net_device *dev) struct sk_buff *newskb; /* Get fresh skbuff to replace filled one. */ - newskb = dev_alloc_skb(PKT_BUF_SZ); + newskb = netdev_alloc_skb(dev, PKT_BUF_SZ); if (newskb == NULL) { skb = NULL; /* drop pkt */ goto memory_squeeze; @@ -819,7 +818,6 @@ static inline int i596_rx(struct net_device *dev) skb_put(skb, pkt_len); rx_in_place = 1; rbd->skb = newskb; - newskb->dev = dev; rbd->v_data = newskb->data; rbd->b_data = WSWAPchar(virt_to_bus(newskb->data)); #ifdef __mc68000__ @@ -827,7 +825,7 @@ static inline int i596_rx(struct net_device *dev) #endif } else - skb = dev_alloc_skb(pkt_len + 2); + skb = netdev_alloc_skb(dev, pkt_len + 2); memory_squeeze: if (skb == NULL) { /* XXX tulip.c can defer packets here!! */ diff --git a/drivers/net/ethernet/i825xx/eepro.c b/drivers/net/ethernet/i825xx/eepro.c index 114cda7721fe..7a4ad4a07917 100644 --- a/drivers/net/ethernet/i825xx/eepro.c +++ b/drivers/net/ethernet/i825xx/eepro.c @@ -1563,7 +1563,7 @@ eepro_rx(struct net_device *dev) dev->stats.rx_bytes+=rcv_size; rcv_size &= 0x3fff; - skb = dev_alloc_skb(rcv_size+5); + skb = netdev_alloc_skb(dev, rcv_size + 5); if (skb == NULL) { printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/i825xx/eexpress.c b/drivers/net/ethernet/i825xx/eexpress.c index 3a9580f3d4dd..3fc649e54a32 100644 --- a/drivers/net/ethernet/i825xx/eexpress.c +++ b/drivers/net/ethernet/i825xx/eexpress.c @@ -955,7 +955,7 @@ static void eexp_hw_rx_pio(struct net_device *dev) { struct sk_buff *skb; pkt_len &= 0x3fff; - skb = dev_alloc_skb(pkt_len+16); + skb = netdev_alloc_skb(dev, pkt_len + 16); if (skb == NULL) { printk(KERN_WARNING "%s: Memory squeeze, dropping packet\n",dev->name); diff --git a/drivers/net/ethernet/i825xx/ether1.c b/drivers/net/ethernet/i825xx/ether1.c index 42e90a97c7a5..406a12b46404 100644 --- a/drivers/net/ethernet/i825xx/ether1.c +++ b/drivers/net/ethernet/i825xx/ether1.c @@ -867,7 +867,7 @@ ether1_recv_done (struct net_device *dev) struct sk_buff *skb; length = (length + 1) & ~1; - skb = dev_alloc_skb (length + 2); + skb = netdev_alloc_skb(dev, length + 2); if (skb) { skb_reserve (skb, 2); diff --git a/drivers/net/ethernet/i825xx/lp486e.c b/drivers/net/ethernet/i825xx/lp486e.c index 02df5f5accb1..6c2952c8ea15 100644 --- a/drivers/net/ethernet/i825xx/lp486e.c +++ b/drivers/net/ethernet/i825xx/lp486e.c @@ -656,7 +656,7 @@ i596_rx_one(struct net_device *dev, struct i596_private *lp, if (rfd->stat & RFD_STAT_OK) { /* a good frame */ int pkt_len = (rfd->count & 0x3fff); - struct sk_buff *skb = dev_alloc_skb(pkt_len); + struct sk_buff *skb = netdev_alloc_skb(dev, pkt_len); (*frames)++; diff --git a/drivers/net/ethernet/i825xx/ni52.c b/drivers/net/ethernet/i825xx/ni52.c index c0893715ef47..272976e1bb0f 100644 --- a/drivers/net/ethernet/i825xx/ni52.c +++ b/drivers/net/ethernet/i825xx/ni52.c @@ -964,7 +964,7 @@ static void ni52_rcv_int(struct net_device *dev) /* the first and the last buffer? */ totlen &= RBD_MASK; /* length of this frame */ writew(0x00, &rbd->status); - skb = (struct sk_buff *)dev_alloc_skb(totlen+2); + skb = netdev_alloc_skb(dev, totlen + 2); if (skb != NULL) { skb_reserve(skb, 2); skb_put(skb, totlen); diff --git a/drivers/net/ethernet/i825xx/sun3_82586.c b/drivers/net/ethernet/i825xx/sun3_82586.c index 296cf8a0ee51..cae17f4bc93e 100644 --- a/drivers/net/ethernet/i825xx/sun3_82586.c +++ b/drivers/net/ethernet/i825xx/sun3_82586.c @@ -778,7 +778,7 @@ static void sun3_82586_rcv_int(struct net_device *dev) { totlen &= RBD_MASK; /* length of this frame */ rbd->status = 0; - skb = (struct sk_buff *) dev_alloc_skb(totlen+2); + skb = netdev_alloc_skb(dev, totlen + 2); if(skb != NULL) { skb_reserve(skb,2); diff --git a/drivers/net/ethernet/i825xx/znet.c b/drivers/net/ethernet/i825xx/znet.c index 962b4c421f3f..a43649735a04 100644 --- a/drivers/net/ethernet/i825xx/znet.c +++ b/drivers/net/ethernet/i825xx/znet.c @@ -762,7 +762,7 @@ static void znet_rx(struct net_device *dev) /* Malloc up new buffer. */ struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len); + skb = netdev_alloc_skb(dev, pkt_len); if (skb == NULL) { if (znet_debug) printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); diff --git a/drivers/net/ethernet/icplus/ipg.c b/drivers/net/ethernet/icplus/ipg.c index 3c636f16a3cb..1b563bb959c2 100644 --- a/drivers/net/ethernet/icplus/ipg.c +++ b/drivers/net/ethernet/icplus/ipg.c @@ -744,9 +744,6 @@ static int ipg_get_rxbuff(struct net_device *dev, int entry) return -ENOMEM; } - /* Associate the receive buffer with the IPG NIC. */ - skb->dev = dev; - /* Save the address of the sk_buff structure. */ sp->rx_buff[entry] = skb; diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c index 86d2fe6e053d..3369b7db777d 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -114,7 +114,7 @@ struct ltq_etop_priv { static int ltq_etop_alloc_skb(struct ltq_etop_chan *ch) { - ch->skb[ch->dma.desc] = dev_alloc_skb(MAX_DMA_DATA_LEN); + ch->skb[ch->dma.desc] = netdev_alloc_skb(ch->netdev, MAX_DMA_DATA_LEN); if (!ch->skb[ch->dma.desc]) return -ENOMEM; ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(NULL, diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 9edecfa1f0f4..f702d0dc18c7 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -667,7 +667,7 @@ static int rxq_refill(struct rx_queue *rxq, int budget) skb = __skb_dequeue(&mp->rx_recycle); if (skb == NULL) - skb = dev_alloc_skb(mp->skb_size); + skb = netdev_alloc_skb(mp->dev, mp->skb_size); if (skb == NULL) { mp->oom = 1; diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 92b4b4e68e3b..75df2091bd2e 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -350,7 +350,7 @@ static void rxq_refill(struct net_device *dev) while (pep->rx_desc_count < pep->rx_ring_size) { int size; - skb = dev_alloc_skb(pep->skb_size); + skb = netdev_alloc_skb(dev, pep->skb_size); if (!skb) break; if (SKB_DMA_REALIGN) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index f61d0e08f52b..fb6e899f38d3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -463,12 +463,11 @@ static struct sk_buff *mlx4_en_rx_skb(struct mlx4_en_priv *priv, int used_frags; dma_addr_t dma; - skb = dev_alloc_skb(SMALL_PACKET_SIZE + NET_IP_ALIGN); + skb = netdev_alloc_skb(priv->dev, SMALL_PACKET_SIZE + NET_IP_ALIGN); if (!skb) { en_dbg(RX_ERR, priv, "Failed allocating skb\n"); return NULL; } - skb->dev = priv->dev; skb_reserve(skb, NET_IP_ALIGN); skb->len = length; diff --git a/drivers/net/ethernet/micrel/ks8695net.c b/drivers/net/ethernet/micrel/ks8695net.c index 7c717276502f..dccae1d1743a 100644 --- a/drivers/net/ethernet/micrel/ks8695net.c +++ b/drivers/net/ethernet/micrel/ks8695net.c @@ -278,7 +278,8 @@ ks8695_refill_rxbuffers(struct ks8695_priv *ksp) for (buff_n = 0; buff_n < MAX_RX_DESC; ++buff_n) { if (!ksp->rx_buffers[buff_n].skb) { - struct sk_buff *skb = dev_alloc_skb(MAX_RXBUF_SIZE); + struct sk_buff *skb = + netdev_alloc_skb(ksp->ndev, MAX_RXBUF_SIZE); dma_addr_t mapping; ksp->rx_buffers[buff_n].skb = skb; @@ -299,7 +300,6 @@ ks8695_refill_rxbuffers(struct ks8695_priv *ksp) break; } ksp->rx_buffers[buff_n].dma_ptr = mapping; - skb->dev = ksp->ndev; ksp->rx_buffers[buff_n].length = MAX_RXBUF_SIZE; /* Record this into the DMA ring */ diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index 4a9d57fb9fb4..61a2f61a31f6 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c @@ -796,7 +796,7 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev) frame_hdr = ks->frame_head_info; while (ks->frame_cnt--) { - skb = dev_alloc_skb(frame_hdr->len + 16); + skb = netdev_alloc_skb(netdev, frame_hdr->len + 16); if (likely(skb && (frame_hdr->sts & RXFSHR_RXFV) && (frame_hdr->len < RX_BUF_SIZE) && frame_hdr->len)) { skb_reserve(skb, 2); diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 2725d693c3c4..ef723b185d85 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c @@ -4863,7 +4863,7 @@ static netdev_tx_t netdev_tx(struct sk_buff *skb, struct net_device *dev) memset(&skb->data[skb->len], 0, 50 - skb->len); skb->len = 50; } else { - skb = dev_alloc_skb(50); + skb = netdev_alloc_skb(dev, 50); if (!skb) return NETDEV_TX_BUSY; memcpy(skb->data, org_skb->data, org_skb->len); @@ -4885,7 +4885,7 @@ static netdev_tx_t netdev_tx(struct sk_buff *skb, struct net_device *dev) (ETH_P_IPV6 == htons(skb->protocol)))) { struct sk_buff *org_skb = skb; - skb = dev_alloc_skb(org_skb->len); + skb = netdev_alloc_skb(dev, org_skb->len); if (!skb) { rc = NETDEV_TX_BUSY; goto unlock; @@ -5019,7 +5019,7 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw, do { /* skb->data != skb->head */ - skb = dev_alloc_skb(packet_len + 2); + skb = netdev_alloc_skb(dev, packet_len + 2); if (!skb) { dev->stats.rx_dropped++; return -ENOMEM; diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c index c813e5d8db9d..1d6b7ce3e1ee 100644 --- a/drivers/net/ethernet/microchip/enc28j60.c +++ b/drivers/net/ethernet/microchip/enc28j60.c @@ -954,14 +954,13 @@ static void enc28j60_hw_rx(struct net_device *ndev) if (len > MAX_FRAMELEN) ndev->stats.rx_over_errors++; } else { - skb = dev_alloc_skb(len + NET_IP_ALIGN); + skb = netdev_alloc_skb(ndev, len + NET_IP_ALIGN); if (!skb) { if (netif_msg_rx_err(priv)) dev_err(&ndev->dev, "out of memory for Rx'd frame\n"); ndev->stats.rx_dropped++; } else { - skb->dev = ndev; skb_reserve(skb, NET_IP_ALIGN); /* copy the packet from the receive buffer */ enc28j60_mem_read(priv, diff --git a/drivers/net/ethernet/mipsnet.c b/drivers/net/ethernet/mipsnet.c index d05b0c9e1e9c..dbc666a3d523 100644 --- a/drivers/net/ethernet/mipsnet.c +++ b/drivers/net/ethernet/mipsnet.c @@ -152,7 +152,7 @@ static inline ssize_t mipsnet_get_fromdev(struct net_device *dev, size_t len) if (!len) return len; - skb = dev_alloc_skb(len + NET_IP_ALIGN); + skb = netdev_alloc_skb(dev, len + NET_IP_ALIGN); if (!skb) { dev->stats.rx_dropped++; return -ENOMEM; diff --git a/drivers/net/ethernet/natsemi/ibmlana.c b/drivers/net/ethernet/natsemi/ibmlana.c index 999407f7ebdf..3f94ddbf4dc0 100644 --- a/drivers/net/ethernet/natsemi/ibmlana.c +++ b/drivers/net/ethernet/natsemi/ibmlana.c @@ -589,7 +589,7 @@ static void irqrx_handler(struct net_device *dev) /* fetch buffer */ - skb = dev_alloc_skb(rda.length + 2); + skb = netdev_alloc_skb(dev, rda.length + 2); if (skb == NULL) dev->stats.rx_dropped++; else { diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c index ac7b16b6e7af..d38e48d4f430 100644 --- a/drivers/net/ethernet/natsemi/natsemi.c +++ b/drivers/net/ethernet/natsemi/natsemi.c @@ -1934,11 +1934,10 @@ static void refill_rx(struct net_device *dev) int entry = np->dirty_rx % RX_RING_SIZE; if (np->rx_skbuff[entry] == NULL) { unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING; - skb = dev_alloc_skb(buflen); + skb = netdev_alloc_skb(dev, buflen); np->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ - skb->dev = dev; /* Mark as being used by this device. */ np->rx_dma[entry] = pci_map_single(np->pci_dev, skb->data, buflen, PCI_DMA_FROMDEVICE); np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]); @@ -2344,7 +2343,7 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do) /* Check if the packet is long enough to accept * without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + RX_OFFSET)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + RX_OFFSET)) != NULL) { /* 16 byte align the IP header */ skb_reserve(skb, RX_OFFSET); pci_dma_sync_single_for_cpu(np->pci_dev, diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c index 26e25d7f5829..0452e2968d27 100644 --- a/drivers/net/ethernet/natsemi/sonic.c +++ b/drivers/net/ethernet/natsemi/sonic.c @@ -51,7 +51,7 @@ static int sonic_open(struct net_device *dev) printk("sonic_open: initializing sonic driver.\n"); for (i = 0; i < SONIC_NUM_RRS; i++) { - struct sk_buff *skb = dev_alloc_skb(SONIC_RBSIZE + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); if (skb == NULL) { while(i > 0) { /* free any that were allocated successfully */ i--; @@ -422,7 +422,7 @@ static void sonic_rx(struct net_device *dev) status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); if (status & SONIC_RCR_PRX) { /* Malloc up new buffer. */ - new_skb = dev_alloc_skb(SONIC_RBSIZE + 2); + new_skb = netdev_alloc_skb(SONIC_RBSIZE + 2); if (new_skb == NULL) { printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); lp->stats.rx_dropped++; diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c index 138584608809..44a6065794c3 100644 --- a/drivers/net/ethernet/neterion/s2io.c +++ b/drivers/net/ethernet/neterion/s2io.c @@ -2524,7 +2524,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, struct ring_info *ring, size = ring->mtu + ALIGN_SIZE + BUF0_LEN + 4; /* allocate skb */ - skb = dev_alloc_skb(size); + skb = netdev_alloc_skb(nic->dev, size); if (!skb) { DBG_PRINT(INFO_DBG, "%s: Could not allocate skb\n", ring->dev->name); @@ -6820,7 +6820,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, */ rxdp1->Buffer0_ptr = *temp0; } else { - *skb = dev_alloc_skb(size); + *skb = netdev_alloc_skb(dev, size); if (!(*skb)) { DBG_PRINT(INFO_DBG, "%s: Out of memory to allocate %s\n", @@ -6849,7 +6849,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, rxdp3->Buffer0_ptr = *temp0; rxdp3->Buffer1_ptr = *temp1; } else { - *skb = dev_alloc_skb(size); + *skb = netdev_alloc_skb(dev, size); if (!(*skb)) { DBG_PRINT(INFO_DBG, "%s: Out of memory to allocate %s\n", -- GitLab From c8987876e9bf9b7b83e75b325586bc77ea8ac825 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:17 +0100 Subject: [PATCH 0380/1846] mac80211: move managed mode station state modification Move the station state modification right before insert, this just makes the current code more readable (you can tell that it's before insertion looking at a single screenful of code) right now, but some upcoming changes will require this. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 49fd1acd5d15..40b929d57a97 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1587,20 +1587,6 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, return false; } - err = sta_info_move_state(sta, IEEE80211_STA_AUTH); - if (!err) - err = sta_info_move_state(sta, IEEE80211_STA_ASSOC); - if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) - err = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); - if (err) { - printk(KERN_DEBUG - "%s: failed to move station %pM to desired state\n", - sdata->name, sta->sta.addr); - WARN_ON(__sta_info_destroy(sta)); - mutex_unlock(&sdata->local->sta_mtx); - return false; - } - rates = 0; basic_rates = 0; sband = local->hw.wiphy->bands[wk->chan->band]; @@ -1648,6 +1634,20 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, if (elems.wmm_param) set_sta_flag(sta, WLAN_STA_WME); + err = sta_info_move_state(sta, IEEE80211_STA_AUTH); + if (!err) + err = sta_info_move_state(sta, IEEE80211_STA_ASSOC); + if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) + err = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); + if (err) { + printk(KERN_DEBUG + "%s: failed to move station %pM to desired state\n", + sdata->name, sta->sta.addr); + WARN_ON(__sta_info_destroy(sta)); + mutex_unlock(&sdata->local->sta_mtx); + return false; + } + /* sta_info_reinsert will also unlock the mutex lock */ err = sta_info_reinsert(sta); sta = NULL; -- GitLab From 077f49392819608084c6d8d20e3dcca230afe07d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:18 +0100 Subject: [PATCH 0381/1846] mac80211: simplify AP_VLAN handling Setting keys and updating TKIP keys must use the BSS sdata (not AP_VLAN), so we translate. Move the translation into driver-ops wrappers instead of having it inline in the code to simplify the normal code flow. The same can be done for sta_add/remove which already does the translation in the wrapper. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/driver-ops.h | 2 ++ net/mac80211/key.c | 8 -------- net/mac80211/pm.c | 11 ++--------- net/mac80211/sta_info.c | 8 +------- net/mac80211/util.c | 11 ++--------- 5 files changed, 7 insertions(+), 33 deletions(-) diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index e8960ae39861..b8673f6100df 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -253,6 +253,7 @@ static inline int drv_set_key(struct ieee80211_local *local, might_sleep(); + sdata = get_bss_sdata(sdata); check_sdata_in_driver(sdata); trace_drv_set_key(local, cmd, sdata, sta, key); @@ -272,6 +273,7 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local, if (sta) ista = &sta->sta; + sdata = get_bss_sdata(sdata); check_sdata_in_driver(sdata); trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 87a89741432d..94f02b577d44 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -123,9 +123,6 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) */ if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) goto out_unsupported; - sdata = container_of(sdata->bss, - struct ieee80211_sub_if_data, - u.ap); } ret = drv_set_key(key->local, SET_KEY, sdata, sta, &key->conf); @@ -187,11 +184,6 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))) increment_tailroom_need_count(sdata); - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) - sdata = container_of(sdata->bss, - struct ieee80211_sub_if_data, - u.ap); - ret = drv_set_key(key->local, DISABLE_KEY, sdata, sta, &key->conf); diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 596efaf50e09..c65ff471acce 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -97,15 +97,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) /* tear down aggregation sessions and remove STAs */ mutex_lock(&local->sta_mtx); list_for_each_entry(sta, &local->sta_list, list) { - if (sta->uploaded) { - sdata = sta->sdata; - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) - sdata = container_of(sdata->bss, - struct ieee80211_sub_if_data, - u.ap); - - drv_sta_remove(local, sdata, &sta->sta); - } + if (sta->uploaded) + drv_sta_remove(local, sta->sdata, &sta->sta); mesh_plink_quiesce(sta); } diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index fa0823892b2d..8e1e361c2232 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -764,14 +764,8 @@ int __must_check __sta_info_destroy(struct sta_info *sta) } } - if (sta->uploaded) { - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) - sdata = container_of(sdata->bss, - struct ieee80211_sub_if_data, - u.ap); + if (sta->uploaded) drv_sta_remove(local, sdata, &sta->sta); - sdata = sta->sdata; - } /* * At this point, after we wait for an RCU grace period, diff --git a/net/mac80211/util.c b/net/mac80211/util.c index d82d886d0867..d4966e88aa49 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1184,15 +1184,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) /* add STAs back */ mutex_lock(&local->sta_mtx); list_for_each_entry(sta, &local->sta_list, list) { - if (sta->uploaded) { - sdata = sta->sdata; - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) - sdata = container_of(sdata->bss, - struct ieee80211_sub_if_data, - u.ap); - - WARN_ON(drv_sta_add(local, sdata, &sta->sta)); - } + if (sta->uploaded) + WARN_ON(drv_sta_add(local, sta->sdata, &sta->sta)); } mutex_unlock(&local->sta_mtx); -- GitLab From 89c91caeccf45bbeb86104445125fe1eaec12079 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:19 +0100 Subject: [PATCH 0382/1846] mac80211: dont program keys for stations not uploaded If a station couldn't be uploaded to the driver but is still kept (only in IBSS mode) we still shouldn't try to program the keys for it into hardware; fix this bug by skipping the key upload in this case. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/key.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 94f02b577d44..e8616b3ff636 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -54,14 +54,6 @@ static void assert_key_lock(struct ieee80211_local *local) lockdep_assert_held(&local->key_mtx); } -static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key) -{ - if (key->sta) - return &key->sta->sta; - - return NULL; -} - static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata) { /* @@ -95,7 +87,7 @@ static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata) static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) { struct ieee80211_sub_if_data *sdata; - struct ieee80211_sta *sta; + struct sta_info *sta; int ret; might_sleep(); @@ -105,7 +97,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) assert_key_lock(key->local); - sta = get_sta_for_key(key); + sta = key->sta; /* * If this is a per-STA GTK, check if it @@ -115,6 +107,9 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) !(key->local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)) goto out_unsupported; + if (sta && !sta->uploaded) + goto out_unsupported; + sdata = key->sdata; if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { /* @@ -125,7 +120,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) goto out_unsupported; } - ret = drv_set_key(key->local, SET_KEY, sdata, sta, &key->conf); + ret = drv_set_key(key->local, SET_KEY, sdata, + sta ? &sta->sta : NULL, &key->conf); if (!ret) { key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; @@ -144,7 +140,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) if (ret != -ENOSPC && ret != -EOPNOTSUPP) wiphy_err(key->local->hw.wiphy, "failed to set key (%d, %pM) to hardware (%d)\n", - key->conf.keyidx, sta ? sta->addr : bcast_addr, ret); + key->conf.keyidx, + sta ? sta->sta.addr : bcast_addr, ret); out_unsupported: switch (key->conf.cipher) { @@ -163,7 +160,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) { struct ieee80211_sub_if_data *sdata; - struct ieee80211_sta *sta; + struct sta_info *sta; int ret; might_sleep(); @@ -176,7 +173,7 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) return; - sta = get_sta_for_key(key); + sta = key->sta; sdata = key->sdata; if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || @@ -185,12 +182,13 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) increment_tailroom_need_count(sdata); ret = drv_set_key(key->local, DISABLE_KEY, sdata, - sta, &key->conf); + sta ? &sta->sta : NULL, &key->conf); if (ret) wiphy_err(key->local->hw.wiphy, "failed to remove key (%d, %pM) from hardware (%d)\n", - key->conf.keyidx, sta ? sta->addr : bcast_addr, ret); + key->conf.keyidx, + sta ? sta->sta.addr : bcast_addr, ret); key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; } -- GitLab From 71ec375c75095002f36f083ceb32bbb8725734ae Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:20 +0100 Subject: [PATCH 0383/1846] mac80211: add NOTEXIST station state This will be used by drivers later if they need to have stations inserted all the time, in mac80211 has no purpose, is never used and sta_state starts out in NONE. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/sta_info.c | 2 ++ net/mac80211/sta_info.h | 1 + 2 files changed, 3 insertions(+) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 8e1e361c2232..464bc691644b 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -293,6 +293,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, sta->sdata = sdata; sta->last_rx = jiffies; + sta->sta_state = IEEE80211_STA_NONE; + do_posix_clock_monotonic_gettime(&uptime); sta->last_connected = uptime.tv_sec; ewma_init(&sta->avg_signal, 1024, 8); diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 381de37d2478..da4b03c1c3bc 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -77,6 +77,7 @@ enum ieee80211_sta_info_flags { enum ieee80211_sta_state { /* NOTE: These need to be ordered correctly! */ + IEEE80211_STA_NOTEXIST, IEEE80211_STA_NONE, IEEE80211_STA_AUTH, IEEE80211_STA_ASSOC, -- GitLab From f09603a259ffef69ad4516a04eb06cd65ac522fe Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:21 +0100 Subject: [PATCH 0384/1846] mac80211: add sta_state callback (based on Eliad's patch) Add a callback to notify the low-level driver whenever the state of a station changes. The driver is only notified when the station is actually in the mac80211 hash table, not for pre-insert state transitions. To allow the driver to replace sta_add/remove calls with this, call extra transitions with the NOTEXIST state. This callback can fail, so we need to be careful in handling it when a station is inserted, particularly in the IBSS case where we still keep the station entry around for mac80211 purposes. Signed-off-by: Eliad Peller Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/mac80211.h | 30 ++++++++++ net/mac80211/driver-ops.h | 22 ++++++++ net/mac80211/driver-trace.h | 32 +++++++++++ net/mac80211/main.c | 3 + net/mac80211/pm.c | 10 +++- net/mac80211/sta_info.c | 106 ++++++++++++++++++++++++++++++------ net/mac80211/sta_info.h | 9 --- net/mac80211/util.c | 10 +++- 8 files changed, 194 insertions(+), 28 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 520eb4c5e5a2..922313f0b39b 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -981,6 +981,25 @@ enum set_key_cmd { SET_KEY, DISABLE_KEY, }; +/** + * enum ieee80211_sta_state - station state + * + * @IEEE80211_STA_NOTEXIST: station doesn't exist at all, + * this is a special state for add/remove transitions + * @IEEE80211_STA_NONE: station exists without special state + * @IEEE80211_STA_AUTH: station is authenticated + * @IEEE80211_STA_ASSOC: station is associated + * @IEEE80211_STA_AUTHORIZED: station is authorized (802.1X) + */ +enum ieee80211_sta_state { + /* NOTE: These need to be ordered correctly! */ + IEEE80211_STA_NOTEXIST, + IEEE80211_STA_NONE, + IEEE80211_STA_AUTH, + IEEE80211_STA_ASSOC, + IEEE80211_STA_AUTHORIZED, +}; + /** * struct ieee80211_sta - station table entry * @@ -1974,6 +1993,13 @@ enum ieee80211_frame_release_type { * in AP mode, this callback will not be called when the flag * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic. * + * @sta_state: Notifies low level driver about state transition of a + * station (which can be the AP, a client, IBSS/WDS/mesh peer etc.) + * This callback is mutually exclusive with @sta_add/@sta_remove. + * It must not fail for down transitions but may fail for transitions + * up the list of states. + * The callback can sleep. + * * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), * bursting) for a hardware TX queue. * Returns a negative error code on failure. @@ -2193,6 +2219,10 @@ struct ieee80211_ops { struct ieee80211_sta *sta); void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum sta_notify_cmd, struct ieee80211_sta *sta); + int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + enum ieee80211_sta_state old_state, + enum ieee80211_sta_state new_state); int (*conf_tx)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params); diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index b8673f6100df..4bd266ec5333 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -478,6 +478,28 @@ static inline void drv_sta_remove(struct ieee80211_local *local, trace_drv_return_void(local); } +static inline __must_check +int drv_sta_state(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct sta_info *sta, + enum ieee80211_sta_state old_state, + enum ieee80211_sta_state new_state) +{ + int ret = 0; + + might_sleep(); + + sdata = get_bss_sdata(sdata); + check_sdata_in_driver(sdata); + + trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); + if (local->ops->sta_state) + ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, + old_state, new_state); + trace_drv_return_int(local, ret); + return ret; +} + static inline int drv_conf_tx(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, u16 queue, const struct ieee80211_tx_queue_params *params) diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h index 6e9df8fd8fb8..384e2f08c187 100644 --- a/net/mac80211/driver-trace.h +++ b/net/mac80211/driver-trace.h @@ -635,6 +635,38 @@ TRACE_EVENT(drv_sta_notify, ) ); +TRACE_EVENT(drv_sta_state, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_state old_state, + enum ieee80211_sta_state new_state), + + TP_ARGS(local, sdata, sta, old_state, new_state), + + TP_STRUCT__entry( + LOCAL_ENTRY + VIF_ENTRY + STA_ENTRY + __field(u32, old_state) + __field(u32, new_state) + ), + + TP_fast_assign( + LOCAL_ASSIGN; + VIF_ASSIGN; + STA_ASSIGN; + __entry->old_state = old_state; + __entry->new_state = new_state; + ), + + TP_printk( + LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " state: %d->%d", + LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, + __entry->old_state, __entry->new_state + ) +); + TRACE_EVENT(drv_sta_add, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 6192caadfab9..f4fc540aac17 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -535,6 +535,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, int priv_size, i; struct wiphy *wiphy; + if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) + return NULL; + /* Ensure 32-byte alignment of our private data and hw private data. * We use the wiphy priv data for both our ieee80211_local and for * the driver's private data diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index c65ff471acce..af49ac4f0826 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -97,9 +97,17 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) /* tear down aggregation sessions and remove STAs */ mutex_lock(&local->sta_mtx); list_for_each_entry(sta, &local->sta_list, list) { - if (sta->uploaded) + if (sta->uploaded) { + enum ieee80211_sta_state state; + drv_sta_remove(local, sta->sdata, &sta->sta); + state = sta->sta_state; + for (; state > IEEE80211_STA_NOTEXIST; state--) + WARN_ON(drv_sta_state(local, sdata, sta, + state, state - 1)); + } + mesh_plink_quiesce(sta); } mutex_unlock(&local->sta_mtx); diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 464bc691644b..fcd9027c6699 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -351,6 +351,38 @@ static int sta_info_insert_check(struct sta_info *sta) return 0; } +static int sta_info_insert_drv_state(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct sta_info *sta) +{ + enum ieee80211_sta_state state; + int err = 0; + + for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { + err = drv_sta_state(local, sdata, sta, state, state + 1); + if (err) + break; + } + + if (!err) { + sta->uploaded = true; + return 0; + } + + if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { + printk(KERN_DEBUG + "%s: failed to move IBSS STA %pM to state %d (%d) - keeping it anyway.\n", + sdata->name, sta->sta.addr, state + 1, err); + err = 0; + } + + /* unwind on error */ + for (; state > IEEE80211_STA_NOTEXIST; state--) + WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); + + return err; +} + /* * should be called with sta_mtx locked * this function replaces the mutex lock @@ -392,8 +424,11 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) printk(KERN_DEBUG "%s: failed to add IBSS STA %pM to " "driver (%d) - keeping it anyway.\n", sdata->name, sta->sta.addr, err); - } else - sta->uploaded = true; + } else { + err = sta_info_insert_drv_state(local, sdata, sta); + if (err) + goto out_err; + } } if (!dummy_reinsert) { @@ -759,15 +794,19 @@ int __must_check __sta_info_destroy(struct sta_info *sta) RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); while (sta->sta_state > IEEE80211_STA_NONE) { - int err = sta_info_move_state(sta, sta->sta_state - 1); - if (err) { + ret = sta_info_move_state(sta, sta->sta_state - 1); + if (ret) { WARN_ON_ONCE(1); break; } } - if (sta->uploaded) + if (sta->uploaded) { drv_sta_remove(local, sdata, &sta->sta); + ret = drv_sta_state(local, sdata, sta, IEEE80211_STA_NONE, + IEEE80211_STA_NOTEXIST); + WARN_ON_ONCE(ret != 0); + } /* * At this point, after we wait for an RCU grace period, @@ -1404,20 +1443,58 @@ int sta_info_move_state(struct sta_info *sta, if (sta->sta_state == new_state) return 0; + /* check allowed transitions first */ + + switch (new_state) { + case IEEE80211_STA_NONE: + if (sta->sta_state != IEEE80211_STA_AUTH) + return -EINVAL; + break; + case IEEE80211_STA_AUTH: + if (sta->sta_state != IEEE80211_STA_NONE && + sta->sta_state != IEEE80211_STA_ASSOC) + return -EINVAL; + break; + case IEEE80211_STA_ASSOC: + if (sta->sta_state != IEEE80211_STA_AUTH && + sta->sta_state != IEEE80211_STA_AUTHORIZED) + return -EINVAL; + break; + case IEEE80211_STA_AUTHORIZED: + if (sta->sta_state != IEEE80211_STA_ASSOC) + return -EINVAL; + break; + default: + WARN(1, "invalid state %d", new_state); + return -EINVAL; + } + + printk(KERN_DEBUG "%s: moving STA %pM to state %d\n", + sta->sdata->name, sta->sta.addr, new_state); + + /* + * notify the driver before the actual changes so it can + * fail the transition + */ + if (test_sta_flag(sta, WLAN_STA_INSERTED)) { + int err = drv_sta_state(sta->local, sta->sdata, sta, + sta->sta_state, new_state); + if (err) + return err; + } + + /* reflect the change in all state variables */ + switch (new_state) { case IEEE80211_STA_NONE: if (sta->sta_state == IEEE80211_STA_AUTH) clear_bit(WLAN_STA_AUTH, &sta->_flags); - else - return -EINVAL; break; case IEEE80211_STA_AUTH: if (sta->sta_state == IEEE80211_STA_NONE) set_bit(WLAN_STA_AUTH, &sta->_flags); else if (sta->sta_state == IEEE80211_STA_ASSOC) clear_bit(WLAN_STA_ASSOC, &sta->_flags); - else - return -EINVAL; break; case IEEE80211_STA_ASSOC: if (sta->sta_state == IEEE80211_STA_AUTH) { @@ -1426,24 +1503,19 @@ int sta_info_move_state(struct sta_info *sta, if (sta->sdata->vif.type == NL80211_IFTYPE_AP) atomic_dec(&sta->sdata->u.ap.num_sta_authorized); clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); - } else - return -EINVAL; + } break; case IEEE80211_STA_AUTHORIZED: if (sta->sta_state == IEEE80211_STA_ASSOC) { if (sta->sdata->vif.type == NL80211_IFTYPE_AP) atomic_inc(&sta->sdata->u.ap.num_sta_authorized); set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); - } else - return -EINVAL; + } break; default: - WARN(1, "invalid state %d", new_state); - return -EINVAL; + break; } - printk(KERN_DEBUG "%s: moving STA %pM to state %d\n", - sta->sdata->name, sta->sta.addr, new_state); sta->sta_state = new_state; return 0; diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index da4b03c1c3bc..2ee808860007 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -75,15 +75,6 @@ enum ieee80211_sta_info_flags { WLAN_STA_INSERTED, }; -enum ieee80211_sta_state { - /* NOTE: These need to be ordered correctly! */ - IEEE80211_STA_NOTEXIST, - IEEE80211_STA_NONE, - IEEE80211_STA_AUTH, - IEEE80211_STA_ASSOC, - IEEE80211_STA_AUTHORIZED, -}; - #define STA_TID_NUM 16 #define ADDBA_RESP_INTERVAL HZ #define HT_AGG_MAX_RETRIES 15 diff --git a/net/mac80211/util.c b/net/mac80211/util.c index d4966e88aa49..8f8b4ecc776f 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1184,8 +1184,16 @@ int ieee80211_reconfig(struct ieee80211_local *local) /* add STAs back */ mutex_lock(&local->sta_mtx); list_for_each_entry(sta, &local->sta_list, list) { - if (sta->uploaded) + if (sta->uploaded) { + enum ieee80211_sta_state state; + WARN_ON(drv_sta_add(local, sta->sdata, &sta->sta)); + + for (state = IEEE80211_STA_NOTEXIST; + state < sta->sta_state - 1; state++) + WARN_ON(drv_sta_state(local, sta->sdata, sta, + state, state + 1)); + } } mutex_unlock(&local->sta_mtx); -- GitLab From a4ec45a421b80bc36fd37578accf081f32527a7f Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:22 +0100 Subject: [PATCH 0385/1846] mac80211: implement sta_add/sta_remove in sta_state Instead of maintaining separate sta_add/sta_remove callsites, implement it in sta_state when the driver has no sta_state implementation. The only behavioural change this should cause is in secure mesh mode: with this the station entries will only be created after the stations are set to AUTH. Given which drivers support mesh, this seems to not be a problem. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/driver-ops.h | 11 ++++++++++- net/mac80211/pm.c | 2 -- net/mac80211/sta_info.c | 23 +++++++++-------------- net/mac80211/util.c | 2 -- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 4bd266ec5333..70dfb6415c20 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -493,9 +493,18 @@ int drv_sta_state(struct ieee80211_local *local, check_sdata_in_driver(sdata); trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); - if (local->ops->sta_state) + if (local->ops->sta_state) { ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, old_state, new_state); + } else if (old_state == IEEE80211_STA_AUTH && + new_state == IEEE80211_STA_ASSOC) { + ret = drv_sta_add(local, sdata, &sta->sta); + if (ret == 0) + sta->uploaded = true; + } else if (old_state == IEEE80211_STA_ASSOC && + new_state == IEEE80211_STA_AUTH) { + drv_sta_remove(local, sdata, &sta->sta); + } trace_drv_return_int(local, ret); return ret; } diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index af49ac4f0826..2b53a5348ace 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -100,8 +100,6 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) if (sta->uploaded) { enum ieee80211_sta_state state; - drv_sta_remove(local, sta->sdata, &sta->sta); - state = sta->sta_state; for (; state > IEEE80211_STA_NOTEXIST; state--) WARN_ON(drv_sta_state(local, sdata, sta, diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index fcd9027c6699..5e577bd0e6aa 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -365,7 +365,12 @@ static int sta_info_insert_drv_state(struct ieee80211_local *local, } if (!err) { - sta->uploaded = true; + /* + * Drivers using legacy sta_add/sta_remove callbacks only + * get uploaded set to true after sta_add is called. + */ + if (!local->ops->sta_add) + sta->uploaded = true; return 0; } @@ -417,18 +422,9 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) if (!sta->dummy || dummy_reinsert) { /* notify driver */ - err = drv_sta_add(local, sdata, &sta->sta); - if (err) { - if (sdata->vif.type != NL80211_IFTYPE_ADHOC) - goto out_err; - printk(KERN_DEBUG "%s: failed to add IBSS STA %pM to " - "driver (%d) - keeping it anyway.\n", - sdata->name, sta->sta.addr, err); - } else { - err = sta_info_insert_drv_state(local, sdata, sta); - if (err) - goto out_err; - } + err = sta_info_insert_drv_state(local, sdata, sta); + if (err) + goto out_err; } if (!dummy_reinsert) { @@ -802,7 +798,6 @@ int __must_check __sta_info_destroy(struct sta_info *sta) } if (sta->uploaded) { - drv_sta_remove(local, sdata, &sta->sta); ret = drv_sta_state(local, sdata, sta, IEEE80211_STA_NONE, IEEE80211_STA_NOTEXIST); WARN_ON_ONCE(ret != 0); diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 8f8b4ecc776f..264397aee811 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1187,8 +1187,6 @@ int ieee80211_reconfig(struct ieee80211_local *local) if (sta->uploaded) { enum ieee80211_sta_state state; - WARN_ON(drv_sta_add(local, sta->sdata, &sta->sta)); - for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state - 1; state++) WARN_ON(drv_sta_state(local, sta->sdata, sta, -- GitLab From 7852e36186d2a1983c215836d7e3d7b8927c930d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:24 +0100 Subject: [PATCH 0386/1846] mac80211: remove dummy STA support The dummy STA support was added because I didn't want to change the driver API at the time. Now that we have state transitions triggering station add/remove in the driver, we only call add once a station reaches ASSOCIATED, so we can remove the dummy station stuff again. While at it, tighten the RX check and accept only port control (EAP) frames from the AP station if it's not associated yet -- in other cases there's no race. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 15 +---- net/mac80211/rx.c | 13 ++-- net/mac80211/sta_info.c | 135 ++++++++-------------------------------- net/mac80211/sta_info.h | 30 +-------- 4 files changed, 38 insertions(+), 155 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 40b929d57a97..d04811a29cdf 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1581,7 +1581,7 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, * station info was already allocated and inserted before * the association and should be available to us */ - sta = sta_info_get_rx(sdata, cbss->bssid); + sta = sta_info_get(sdata, cbss->bssid); if (WARN_ON(!sta)) { mutex_unlock(&sdata->local->sta_mtx); return false; @@ -1648,14 +1648,7 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, return false; } - /* sta_info_reinsert will also unlock the mutex lock */ - err = sta_info_reinsert(sta); - sta = NULL; - if (err) { - printk(KERN_DEBUG "%s: failed to insert STA entry for" - " the AP (error %d)\n", sdata->name, err); - return false; - } + mutex_unlock(&sdata->local->sta_mtx); /* * Always handle WMM once after association regardless @@ -2536,12 +2529,10 @@ static int ieee80211_pre_assoc(struct ieee80211_sub_if_data *sdata, if (!sta) return -ENOMEM; - sta->dummy = true; - err = sta_info_insert(sta); sta = NULL; if (err) { - printk(KERN_DEBUG "%s: failed to insert Dummy STA entry for" + printk(KERN_DEBUG "%s: failed to insert STA entry for" " the AP (error %d)\n", sdata->name, err); return err; } diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index ab29253fb4f2..8d6fa674f53e 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -859,7 +859,12 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) rx->sdata->vif.type != NL80211_IFTYPE_ADHOC && rx->sdata->vif.type != NL80211_IFTYPE_WDS && (!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_ASSOC)))) { - if (rx->sta && rx->sta->dummy && + /* + * accept port control frames from the AP even when it's not + * yet marked ASSOC to prevent a race where we don't set the + * assoc bit quickly enough before it sends the first frame + */ + if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION && ieee80211_is_data_present(hdr->frame_control)) { u16 ethertype; u8 *payload; @@ -2949,7 +2954,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, if (ieee80211_is_data(fc)) { prev_sta = NULL; - for_each_sta_info_rx(local, hdr->addr2, sta, tmp) { + for_each_sta_info(local, hdr->addr2, sta, tmp) { if (!prev_sta) { prev_sta = sta; continue; @@ -2993,7 +2998,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, continue; } - rx.sta = sta_info_get_bss_rx(prev, hdr->addr2); + rx.sta = sta_info_get_bss(prev, hdr->addr2); rx.sdata = prev; ieee80211_prepare_and_rx_handle(&rx, skb, false); @@ -3001,7 +3006,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, } if (prev) { - rx.sta = sta_info_get_bss_rx(prev, hdr->addr2); + rx.sta = sta_info_get_bss(prev, hdr->addr2); rx.sdata = prev; if (ieee80211_prepare_and_rx_handle(&rx, skb, true)) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 5e577bd0e6aa..31cd6d92531c 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -97,25 +97,6 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, struct ieee80211_local *local = sdata->local; struct sta_info *sta; - sta = rcu_dereference_check(local->sta_hash[STA_HASH(addr)], - lockdep_is_held(&local->sta_mtx)); - while (sta) { - if (sta->sdata == sdata && !sta->dummy && - memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) - break; - sta = rcu_dereference_check(sta->hnext, - lockdep_is_held(&local->sta_mtx)); - } - return sta; -} - -/* get a station info entry even if it is a dummy station*/ -struct sta_info *sta_info_get_rx(struct ieee80211_sub_if_data *sdata, - const u8 *addr) -{ - struct ieee80211_local *local = sdata->local; - struct sta_info *sta; - sta = rcu_dereference_check(local->sta_hash[STA_HASH(addr)], lockdep_is_held(&local->sta_mtx)); while (sta) { @@ -138,30 +119,6 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, struct ieee80211_local *local = sdata->local; struct sta_info *sta; - sta = rcu_dereference_check(local->sta_hash[STA_HASH(addr)], - lockdep_is_held(&local->sta_mtx)); - while (sta) { - if ((sta->sdata == sdata || - (sta->sdata->bss && sta->sdata->bss == sdata->bss)) && - !sta->dummy && - memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) - break; - sta = rcu_dereference_check(sta->hnext, - lockdep_is_held(&local->sta_mtx)); - } - return sta; -} - -/* - * Get sta info either from the specified interface - * or from one of its vlans (including dummy stations) - */ -struct sta_info *sta_info_get_bss_rx(struct ieee80211_sub_if_data *sdata, - const u8 *addr) -{ - struct ieee80211_local *local = sdata->local; - struct sta_info *sta; - sta = rcu_dereference_check(local->sta_hash[STA_HASH(addr)], lockdep_is_held(&local->sta_mtx)); while (sta) { @@ -397,66 +354,43 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) { struct ieee80211_local *local = sta->local; struct ieee80211_sub_if_data *sdata = sta->sdata; - struct sta_info *exist_sta; - bool dummy_reinsert = false; + struct station_info sinfo; int err = 0; lockdep_assert_held(&local->sta_mtx); - /* - * check if STA exists already. - * only accept a scenario of a second call to sta_info_insert_finish - * with a dummy station entry that was inserted earlier - * in that case - assume that the dummy station flag should - * be removed. - */ - exist_sta = sta_info_get_bss_rx(sdata, sta->sta.addr); - if (exist_sta) { - if (exist_sta == sta && sta->dummy) { - dummy_reinsert = true; - } else { - err = -EEXIST; - goto out_err; - } - } - - if (!sta->dummy || dummy_reinsert) { - /* notify driver */ - err = sta_info_insert_drv_state(local, sdata, sta); - if (err) - goto out_err; + /* check if STA exists already */ + if (sta_info_get_bss(sdata, sta->sta.addr)) { + err = -EEXIST; + goto out_err; } - if (!dummy_reinsert) { - local->num_sta++; - local->sta_generation++; - smp_mb(); + /* notify driver */ + err = sta_info_insert_drv_state(local, sdata, sta); + if (err) + goto out_err; - /* make the station visible */ - sta_info_hash_add(local, sta); + local->num_sta++; + local->sta_generation++; + smp_mb(); - list_add(&sta->list, &local->sta_list); + /* make the station visible */ + sta_info_hash_add(local, sta); - set_sta_flag(sta, WLAN_STA_INSERTED); - } else { - sta->dummy = false; - } + list_add(&sta->list, &local->sta_list); - if (!sta->dummy) { - struct station_info sinfo; + set_sta_flag(sta, WLAN_STA_INSERTED); - ieee80211_sta_debugfs_add(sta); - rate_control_add_sta_debugfs(sta); + ieee80211_sta_debugfs_add(sta); + rate_control_add_sta_debugfs(sta); - memset(&sinfo, 0, sizeof(sinfo)); - sinfo.filled = 0; - sinfo.generation = local->sta_generation; - cfg80211_new_sta(sdata->dev, sta->sta.addr, &sinfo, GFP_KERNEL); - } + memset(&sinfo, 0, sizeof(sinfo)); + sinfo.filled = 0; + sinfo.generation = local->sta_generation; + cfg80211_new_sta(sdata->dev, sta->sta.addr, &sinfo, GFP_KERNEL); #ifdef CONFIG_MAC80211_VERBOSE_DEBUG - wiphy_debug(local->hw.wiphy, "Inserted %sSTA %pM\n", - sta->dummy ? "dummy " : "", sta->sta.addr); + wiphy_debug(local->hw.wiphy, "Inserted STA %pM\n", sta->sta.addr); #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ /* move reference to rcu-protected */ @@ -508,25 +442,6 @@ int sta_info_insert(struct sta_info *sta) return err; } -/* Caller must hold sta->local->sta_mtx */ -int sta_info_reinsert(struct sta_info *sta) -{ - struct ieee80211_local *local = sta->local; - int err = 0; - - err = sta_info_insert_check(sta); - if (err) { - mutex_unlock(&local->sta_mtx); - return err; - } - - might_sleep(); - - err = sta_info_insert_finish(sta); - rcu_read_unlock(); - return err; -} - static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid) { /* @@ -873,7 +788,7 @@ int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, const u8 *addr) int ret; mutex_lock(&sdata->local->sta_mtx); - sta = sta_info_get_rx(sdata, addr); + sta = sta_info_get(sdata, addr); ret = __sta_info_destroy(sta); mutex_unlock(&sdata->local->sta_mtx); @@ -887,7 +802,7 @@ int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata, int ret; mutex_lock(&sdata->local->sta_mtx); - sta = sta_info_get_bss_rx(sdata, addr); + sta = sta_info_get_bss(sdata, addr); ret = __sta_info_destroy(sta); mutex_unlock(&sdata->local->sta_mtx); diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 2ee808860007..03f249bc2766 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -265,8 +265,6 @@ struct sta_ampdu_mlme { * @dead: set to true when sta is unlinked * @uploaded: set to true when sta is uploaded to the driver * @lost_packets: number of consecutive lost packets - * @dummy: indicate a dummy station created for receiving - * EAP frames before association * @sta: station information we share with the driver * @sta_state: duplicates information about station state (for debug) * @beacon_loss_count: number of times beacon loss has triggered @@ -364,9 +362,6 @@ struct sta_info { unsigned int lost_packets; unsigned int beacon_loss_count; - /* should be right in front of sta to be in the same cache line */ - bool dummy; - /* keep last! */ struct ieee80211_sta sta; }; @@ -468,15 +463,9 @@ rcu_dereference_protected_tid_tx(struct sta_info *sta, int tid) struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, const u8 *addr); -struct sta_info *sta_info_get_rx(struct ieee80211_sub_if_data *sdata, - const u8 *addr); - struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, const u8 *addr); -struct sta_info *sta_info_get_bss_rx(struct ieee80211_sub_if_data *sdata, - const u8 *addr); - static inline void for_each_sta_info_type_check(struct ieee80211_local *local, const u8 *addr, @@ -485,23 +474,7 @@ void for_each_sta_info_type_check(struct ieee80211_local *local, { } -#define for_each_sta_info(local, _addr, _sta, nxt) \ - for ( /* initialise loop */ \ - _sta = rcu_dereference(local->sta_hash[STA_HASH(_addr)]),\ - nxt = _sta ? rcu_dereference(_sta->hnext) : NULL; \ - /* typecheck */ \ - for_each_sta_info_type_check(local, (_addr), _sta, nxt),\ - /* continue condition */ \ - _sta; \ - /* advance loop */ \ - _sta = nxt, \ - nxt = _sta ? rcu_dereference(_sta->hnext) : NULL \ - ) \ - /* run code only if address matches and it's not a dummy sta */ \ - if (memcmp(_sta->sta.addr, (_addr), ETH_ALEN) == 0 && \ - !_sta->dummy) - -#define for_each_sta_info_rx(local, _addr, _sta, nxt) \ +#define for_each_sta_info(local, _addr, _sta, nxt) \ for ( /* initialise loop */ \ _sta = rcu_dereference(local->sta_hash[STA_HASH(_addr)]),\ nxt = _sta ? rcu_dereference(_sta->hnext) : NULL; \ @@ -540,7 +513,6 @@ void sta_info_free(struct ieee80211_local *local, struct sta_info *sta); */ int sta_info_insert(struct sta_info *sta); int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU); -int sta_info_reinsert(struct sta_info *sta); int __must_check __sta_info_destroy(struct sta_info *sta); int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, -- GitLab From 95de817b9034d50860319f6033ec85d25024694c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:25 +0100 Subject: [PATCH 0387/1846] cfg80211: stop tracking authenticated state To track authenticated state seems to have been a design mistake in cfg80211. It is possible to have out of band authentication (FT), tracking multiple authentications caused more problems than it ever helped, and the implementation in mac80211 is too complex. Remove all this complexity, and let userspace do whatever it wants to, mac80211 can deal with that just fine. Association is still tracked of course, but authentication no longer is. Local auth state changes are thus no longer of value, so ignore them completely. This will also help implement SAE -- asking the driver to do an authentication is now almost equivalent to sending an authentication frame, with the exception of shared key authentication which is still handled completely. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- Documentation/DocBook/80211.tmpl | 1 - include/net/cfg80211.h | 39 ++-- net/mac80211/mlme.c | 23 +-- net/wireless/core.h | 9 +- net/wireless/mlme.c | 322 +++++-------------------------- net/wireless/nl80211.c | 18 +- net/wireless/sme.c | 41 +--- 7 files changed, 91 insertions(+), 362 deletions(-) diff --git a/Documentation/DocBook/80211.tmpl b/Documentation/DocBook/80211.tmpl index 2014155c899d..c5ac6929c41c 100644 --- a/Documentation/DocBook/80211.tmpl +++ b/Documentation/DocBook/80211.tmpl @@ -129,7 +129,6 @@ !Finclude/net/cfg80211.h cfg80211_pmksa !Finclude/net/cfg80211.h cfg80211_send_rx_auth !Finclude/net/cfg80211.h cfg80211_send_auth_timeout -!Finclude/net/cfg80211.h __cfg80211_auth_canceled !Finclude/net/cfg80211.h cfg80211_send_rx_assoc !Finclude/net/cfg80211.h cfg80211_send_assoc_timeout !Finclude/net/cfg80211.h cfg80211_send_deauth diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 2964205332f4..6cfecb02a34b 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1039,10 +1039,6 @@ const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie); * @key_len: length of WEP key for shared key authentication * @key_idx: index of WEP key for shared key authentication * @key: WEP key for shared key authentication - * @local_state_change: This is a request for a local state only, i.e., no - * Authentication frame is to be transmitted and authentication state is - * to be changed without having to wait for a response from the peer STA - * (AP). */ struct cfg80211_auth_request { struct cfg80211_bss *bss; @@ -1051,7 +1047,6 @@ struct cfg80211_auth_request { enum nl80211_auth_type auth_type; const u8 *key; u8 key_len, key_idx; - bool local_state_change; }; /** @@ -1068,7 +1063,11 @@ enum cfg80211_assoc_req_flags { * * This structure provides information needed to complete IEEE 802.11 * (re)association. - * @bss: The BSS to associate with. + * @bss: The BSS to associate with. If the call is successful the driver + * is given a reference that it must release, normally via a call to + * cfg80211_send_rx_assoc(), or, if association timed out, with a + * call to cfg80211_put_bss() (in addition to calling + * cfg80211_send_assoc_timeout()) * @ie: Extra IEs to add to (Re)Association Request frame or %NULL * @ie_len: Length of ie buffer in octets * @use_mfp: Use management frame protection (IEEE 802.11w) in this association @@ -1096,19 +1095,16 @@ struct cfg80211_assoc_request { * This structure provides information needed to complete IEEE 802.11 * deauthentication. * - * @bss: the BSS to deauthenticate from + * @bssid: the BSSID of the BSS to deauthenticate from * @ie: Extra IEs to add to Deauthentication frame or %NULL * @ie_len: Length of ie buffer in octets * @reason_code: The reason code for the deauthentication - * @local_state_change: This is a request for a local state only, i.e., no - * Deauthentication frame is to be transmitted. */ struct cfg80211_deauth_request { - struct cfg80211_bss *bss; + const u8 *bssid; const u8 *ie; size_t ie_len; u16 reason_code; - bool local_state_change; }; /** @@ -2206,8 +2202,6 @@ struct cfg80211_conn; struct cfg80211_internal_bss; struct cfg80211_cached_keys; -#define MAX_AUTH_BSSES 4 - /** * struct wireless_dev - wireless per-netdev state * @@ -2271,8 +2265,6 @@ struct wireless_dev { struct list_head event_list; spinlock_t event_lock; - struct cfg80211_internal_bss *authtry_bsses[MAX_AUTH_BSSES]; - struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES]; struct cfg80211_internal_bss *current_bss; /* associated / joined */ struct ieee80211_channel *channel; @@ -2763,21 +2755,11 @@ void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len); */ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr); -/** - * __cfg80211_auth_canceled - notify cfg80211 that authentication was canceled - * @dev: network device - * @addr: The MAC address of the device with which the authentication timed out - * - * When a pending authentication had no action yet, the driver may decide - * to not send a deauth frame, but in that case must calls this function - * to tell cfg80211 about this decision. It is only valid to call this - * function within the deauth() callback. - */ -void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr); - /** * cfg80211_send_rx_assoc - notification of processed association * @dev: network device + * @bss: the BSS struct association was requested for, the struct reference + * is owned by cfg80211 after this call * @buf: (re)association response frame (header + body) * @len: length of the frame data * @@ -2786,7 +2768,8 @@ void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr); * function or cfg80211_send_assoc_timeout() to indicate the result of * cfg80211_ops::assoc() call. This function may sleep. */ -void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len); +void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, + const u8 *buf, size_t len); /** * cfg80211_send_assoc_timeout - notification of timed out association diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index d04811a29cdf..082fcda57786 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2459,9 +2459,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, struct ieee80211_work *wk; u16 auth_alg; - if (req->local_state_change) - return 0; /* no need to update mac80211 state */ - switch (req->auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: auth_alg = WLAN_AUTH_OPEN; @@ -2593,7 +2590,7 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, sta_info_destroy_addr(wk->sdata, cbss->bssid); } - cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len); + cfg80211_send_rx_assoc(wk->sdata->dev, cbss, skb->data, skb->len); destroy: if (wk->assoc.synced) drv_finish_tx_sync(local, wk->sdata, wk->filter_ta, @@ -2750,13 +2747,12 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - u8 bssid[ETH_ALEN]; bool assoc_bss = false; mutex_lock(&ifmgd->mtx); - memcpy(bssid, req->bss->bssid, ETH_ALEN); - if (ifmgd->associated == req->bss) { + if (ifmgd->associated && + memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) { ieee80211_set_disassoc(sdata, false, true); mutex_unlock(&ifmgd->mtx); assoc_bss = true; @@ -2777,7 +2773,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, tmp->type != IEEE80211_WORK_ASSOC_BEACON_WAIT) continue; - if (memcmp(req->bss->bssid, tmp->filter_ta, ETH_ALEN)) + if (memcmp(req->bssid, tmp->filter_ta, ETH_ALEN)) continue; not_auth_yet = tmp->type == IEEE80211_WORK_DIRECT_PROBE; @@ -2811,18 +2807,15 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, * frame, and if it's IDLE we have completed the auth * process already. */ - if (not_auth_yet) { - __cfg80211_auth_canceled(sdata->dev, bssid); + if (not_auth_yet) return 0; - } } printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n", - sdata->name, bssid, req->reason_code); + sdata->name, req->bssid, req->reason_code); - ieee80211_send_deauth_disassoc(sdata, bssid, IEEE80211_STYPE_DEAUTH, - req->reason_code, cookie, - !req->local_state_change); + ieee80211_send_deauth_disassoc(sdata, req->bssid, IEEE80211_STYPE_DEAUTH, + req->reason_code, cookie, true); if (assoc_bss) sta_info_flush(sdata->local, sdata); diff --git a/net/wireless/core.h b/net/wireless/core.h index 43ad9c81efcf..2b454caf4395 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -325,15 +325,13 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, const u8 *bssid, const u8 *ssid, int ssid_len, const u8 *ie, int ie_len, - const u8 *key, int key_len, int key_idx, - bool local_state_change); + const u8 *key, int key_len, int key_idx); int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, struct net_device *dev, struct ieee80211_channel *chan, enum nl80211_auth_type auth_type, const u8 *bssid, const u8 *ssid, int ssid_len, const u8 *ie, int ie_len, - const u8 *key, int key_len, int key_idx, - bool local_state_change); + const u8 *key, int key_len, int key_idx); int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, struct net_device *dev, struct ieee80211_channel *chan, @@ -421,7 +419,8 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, size_t ie_len, u16 reason, bool from_ap); void cfg80211_sme_scan_done(struct net_device *dev); void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len); -void cfg80211_sme_disassoc(struct net_device *dev, int idx); +void cfg80211_sme_disassoc(struct net_device *dev, + struct cfg80211_internal_bss *bss); void __cfg80211_scan_done(struct work_struct *wk); void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak); void __cfg80211_sched_scan_results(struct work_struct *wk); diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 438dfc105b4a..d553d365e751 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -20,40 +20,18 @@ void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) struct wireless_dev *wdev = dev->ieee80211_ptr; struct wiphy *wiphy = wdev->wiphy; struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; - u8 *bssid = mgmt->bssid; - int i; - u16 status = le16_to_cpu(mgmt->u.auth.status_code); - bool done = false; wdev_lock(wdev); - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (wdev->authtry_bsses[i] && - memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, - ETH_ALEN) == 0) { - if (status == WLAN_STATUS_SUCCESS) { - wdev->auth_bsses[i] = wdev->authtry_bsses[i]; - } else { - cfg80211_unhold_bss(wdev->authtry_bsses[i]); - cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); - } - wdev->authtry_bsses[i] = NULL; - done = true; - break; - } - } - - if (done) { - nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); - cfg80211_sme_rx_auth(dev, buf, len); - } + nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); + cfg80211_sme_rx_auth(dev, buf, len); wdev_unlock(wdev); } EXPORT_SYMBOL(cfg80211_send_rx_auth); -void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len) +void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, + const u8 *buf, size_t len) { u16 status_code; struct wireless_dev *wdev = dev->ieee80211_ptr; @@ -61,8 +39,7 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len) struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; u8 *ie = mgmt->u.assoc_resp.variable; - int i, ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); - struct cfg80211_internal_bss *bss = NULL; + int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); wdev_lock(wdev); @@ -75,43 +52,20 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len) * frame instead of reassoc. */ if (status_code != WLAN_STATUS_SUCCESS && wdev->conn && - cfg80211_sme_failed_reassoc(wdev)) + cfg80211_sme_failed_reassoc(wdev)) { + cfg80211_put_bss(bss); goto out; + } nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL); - if (status_code == WLAN_STATUS_SUCCESS) { - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (!wdev->auth_bsses[i]) - continue; - if (memcmp(wdev->auth_bsses[i]->pub.bssid, mgmt->bssid, - ETH_ALEN) == 0) { - bss = wdev->auth_bsses[i]; - wdev->auth_bsses[i] = NULL; - /* additional reference to drop hold */ - cfg80211_ref_bss(bss); - break; - } - } - - /* - * We might be coming here because the driver reported - * a successful association at the same time as the - * user requested a deauth. In that case, we will have - * removed the BSS from the auth_bsses list due to the - * deauth request when the assoc response makes it. If - * the two code paths acquire the lock the other way - * around, that's just the standard situation of a - * deauth being requested while connected. - */ - if (!bss) - goto out; - } else if (wdev->conn) { + if (status_code != WLAN_STATUS_SUCCESS && wdev->conn) { cfg80211_sme_failed_assoc(wdev); /* * do not call connect_result() now because the * sme will schedule work that does it later. */ + cfg80211_put_bss(bss); goto out; } @@ -124,17 +78,10 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len) wdev->sme_state = CFG80211_SME_CONNECTING; } - /* this consumes one bss reference (unless bss is NULL) */ + /* this consumes the bss reference */ __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs, status_code, - status_code == WLAN_STATUS_SUCCESS, - bss ? &bss->pub : NULL); - /* drop hold now, and also reference acquired above */ - if (bss) { - cfg80211_unhold_bss(bss); - cfg80211_put_bss(&bss->pub); - } - + status_code == WLAN_STATUS_SUCCESS, bss); out: wdev_unlock(wdev); } @@ -148,8 +95,7 @@ void __cfg80211_send_deauth(struct net_device *dev, struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; const u8 *bssid = mgmt->bssid; - int i; - bool found = false, was_current = false; + bool was_current = false; ASSERT_WDEV_LOCK(wdev); @@ -158,32 +104,9 @@ void __cfg80211_send_deauth(struct net_device *dev, cfg80211_unhold_bss(wdev->current_bss); cfg80211_put_bss(&wdev->current_bss->pub); wdev->current_bss = NULL; - found = true; was_current = true; - } else for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (wdev->auth_bsses[i] && - memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) { - cfg80211_unhold_bss(wdev->auth_bsses[i]); - cfg80211_put_bss(&wdev->auth_bsses[i]->pub); - wdev->auth_bsses[i] = NULL; - found = true; - break; - } - if (wdev->authtry_bsses[i] && - memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, - ETH_ALEN) == 0 && - memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) == 0) { - cfg80211_unhold_bss(wdev->authtry_bsses[i]); - cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); - wdev->authtry_bsses[i] = NULL; - found = true; - break; - } } - if (!found) - return; - nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL); if (wdev->sme_state == CFG80211_SME_CONNECTED && was_current) { @@ -220,10 +143,8 @@ void __cfg80211_send_disassoc(struct net_device *dev, struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; const u8 *bssid = mgmt->bssid; - int i; u16 reason_code; bool from_ap; - bool done = false; ASSERT_WDEV_LOCK(wdev); @@ -234,16 +155,10 @@ void __cfg80211_send_disassoc(struct net_device *dev, if (wdev->current_bss && memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (wdev->authtry_bsses[i] || wdev->auth_bsses[i]) - continue; - wdev->auth_bsses[i] = wdev->current_bss; - wdev->current_bss = NULL; - done = true; - cfg80211_sme_disassoc(dev, i); - break; - } - WARN_ON(!done); + cfg80211_sme_disassoc(dev, wdev->current_bss); + cfg80211_unhold_bss(wdev->current_bss); + cfg80211_put_bss(&wdev->current_bss->pub); + wdev->current_bss = NULL; } else WARN_ON(1); @@ -287,34 +202,6 @@ void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, } EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); -static void __cfg80211_auth_remove(struct wireless_dev *wdev, const u8 *addr) -{ - int i; - bool done = false; - - ASSERT_WDEV_LOCK(wdev); - - for (i = 0; addr && i < MAX_AUTH_BSSES; i++) { - if (wdev->authtry_bsses[i] && - memcmp(wdev->authtry_bsses[i]->pub.bssid, - addr, ETH_ALEN) == 0) { - cfg80211_unhold_bss(wdev->authtry_bsses[i]); - cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); - wdev->authtry_bsses[i] = NULL; - done = true; - break; - } - } - - WARN_ON(!done); -} - -void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr) -{ - __cfg80211_auth_remove(dev->ieee80211_ptr, addr); -} -EXPORT_SYMBOL(__cfg80211_auth_canceled); - void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) { struct wireless_dev *wdev = dev->ieee80211_ptr; @@ -329,8 +216,6 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) WLAN_STATUS_UNSPECIFIED_FAILURE, false, NULL); - __cfg80211_auth_remove(wdev, addr); - wdev_unlock(wdev); } EXPORT_SYMBOL(cfg80211_send_auth_timeout); @@ -340,8 +225,6 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr) struct wireless_dev *wdev = dev->ieee80211_ptr; struct wiphy *wiphy = wdev->wiphy; struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - int i; - bool done = false; wdev_lock(wdev); @@ -351,20 +234,6 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr) WLAN_STATUS_UNSPECIFIED_FAILURE, false, NULL); - for (i = 0; addr && i < MAX_AUTH_BSSES; i++) { - if (wdev->auth_bsses[i] && - memcmp(wdev->auth_bsses[i]->pub.bssid, - addr, ETH_ALEN) == 0) { - cfg80211_unhold_bss(wdev->auth_bsses[i]); - cfg80211_put_bss(&wdev->auth_bsses[i]->pub); - wdev->auth_bsses[i] = NULL; - done = true; - break; - } - } - - WARN_ON(!done); - wdev_unlock(wdev); } EXPORT_SYMBOL(cfg80211_send_assoc_timeout); @@ -403,13 +272,11 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, const u8 *bssid, const u8 *ssid, int ssid_len, const u8 *ie, int ie_len, - const u8 *key, int key_len, int key_idx, - bool local_state_change) + const u8 *key, int key_len, int key_idx) { struct wireless_dev *wdev = dev->ieee80211_ptr; struct cfg80211_auth_request req; - struct cfg80211_internal_bss *bss; - int i, err, slot = -1, nfree = 0; + int err; ASSERT_WDEV_LOCK(wdev); @@ -421,20 +288,8 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0) return -EALREADY; - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (wdev->authtry_bsses[i] && - memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid, - ETH_ALEN) == 0) - return -EALREADY; - if (wdev->auth_bsses[i] && - memcmp(bssid, wdev->auth_bsses[i]->pub.bssid, - ETH_ALEN) == 0) - return -EALREADY; - } - memset(&req, 0, sizeof(req)); - req.local_state_change = local_state_change; req.ie = ie; req.ie_len = ie_len; req.auth_type = auth_type; @@ -446,39 +301,9 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, if (!req.bss) return -ENOENT; - bss = bss_from_pub(req.bss); - - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (!wdev->auth_bsses[i] && !wdev->authtry_bsses[i]) { - slot = i; - nfree++; - } - } - - /* we need one free slot for disassoc and one for this auth */ - if (nfree < 2) { - err = -ENOSPC; - goto out; - } - - if (local_state_change) - wdev->auth_bsses[slot] = bss; - else - wdev->authtry_bsses[slot] = bss; - cfg80211_hold_bss(bss); - err = rdev->ops->auth(&rdev->wiphy, dev, &req); - if (err) { - if (local_state_change) - wdev->auth_bsses[slot] = NULL; - else - wdev->authtry_bsses[slot] = NULL; - cfg80211_unhold_bss(bss); - } - out: - if (err) - cfg80211_put_bss(req.bss); + cfg80211_put_bss(req.bss); return err; } @@ -487,15 +312,14 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, enum nl80211_auth_type auth_type, const u8 *bssid, const u8 *ssid, int ssid_len, const u8 *ie, int ie_len, - const u8 *key, int key_len, int key_idx, - bool local_state_change) + const u8 *key, int key_len, int key_idx) { int err; wdev_lock(dev->ieee80211_ptr); err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, ssid, ssid_len, ie, ie_len, - key, key_len, key_idx, local_state_change); + key, key_len, key_idx); wdev_unlock(dev->ieee80211_ptr); return err; @@ -530,8 +354,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, { struct wireless_dev *wdev = dev->ieee80211_ptr; struct cfg80211_assoc_request req; - struct cfg80211_internal_bss *bss; - int i, err, slot = -1; + int err; bool was_connected = false; ASSERT_WDEV_LOCK(wdev); @@ -573,26 +396,14 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, return -ENOENT; } - bss = bss_from_pub(req.bss); - - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (bss == wdev->auth_bsses[i]) { - slot = i; - break; - } - } + err = rdev->ops->assoc(&rdev->wiphy, dev, &req); - if (slot < 0) { - err = -ENOTCONN; - goto out; + if (err) { + if (was_connected) + wdev->sme_state = CFG80211_SME_CONNECTED; + cfg80211_put_bss(req.bss); } - err = rdev->ops->assoc(&rdev->wiphy, dev, &req); - out: - if (err && was_connected) - wdev->sme_state = CFG80211_SME_CONNECTED; - /* still a reference in wdev->auth_bsses[slot] */ - cfg80211_put_bss(req.bss); return err; } @@ -624,34 +435,25 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, bool local_state_change) { struct wireless_dev *wdev = dev->ieee80211_ptr; - struct cfg80211_deauth_request req; - int i; + struct cfg80211_deauth_request req = { + .bssid = bssid, + .reason_code = reason, + .ie = ie, + .ie_len = ie_len, + }; ASSERT_WDEV_LOCK(wdev); - memset(&req, 0, sizeof(req)); - req.reason_code = reason; - req.local_state_change = local_state_change; - req.ie = ie; - req.ie_len = ie_len; - if (wdev->current_bss && - memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { - req.bss = &wdev->current_bss->pub; - } else for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (wdev->auth_bsses[i] && - memcmp(bssid, wdev->auth_bsses[i]->pub.bssid, ETH_ALEN) == 0) { - req.bss = &wdev->auth_bsses[i]->pub; - break; - } - if (wdev->authtry_bsses[i] && - memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid, ETH_ALEN) == 0) { - req.bss = &wdev->authtry_bsses[i]->pub; - break; + if (local_state_change) { + if (wdev->current_bss && + memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { + cfg80211_unhold_bss(wdev->current_bss); + cfg80211_put_bss(&wdev->current_bss->pub); + wdev->current_bss = NULL; } - } - if (!req.bss) - return -ENOTCONN; + return 0; + } return rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); } @@ -722,7 +524,7 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, { struct wireless_dev *wdev = dev->ieee80211_ptr; struct cfg80211_deauth_request req; - int i; + u8 bssid[ETH_ALEN]; ASSERT_WDEV_LOCK(wdev); @@ -734,35 +536,17 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, req.ie = NULL; req.ie_len = 0; - if (wdev->current_bss) { - req.bss = &wdev->current_bss->pub; - rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); - if (wdev->current_bss) { - cfg80211_unhold_bss(wdev->current_bss); - cfg80211_put_bss(&wdev->current_bss->pub); - wdev->current_bss = NULL; - } - } + if (!wdev->current_bss) + return; - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (wdev->auth_bsses[i]) { - req.bss = &wdev->auth_bsses[i]->pub; - rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); - if (wdev->auth_bsses[i]) { - cfg80211_unhold_bss(wdev->auth_bsses[i]); - cfg80211_put_bss(&wdev->auth_bsses[i]->pub); - wdev->auth_bsses[i] = NULL; - } - } - if (wdev->authtry_bsses[i]) { - req.bss = &wdev->authtry_bsses[i]->pub; - rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); - if (wdev->authtry_bsses[i]) { - cfg80211_unhold_bss(wdev->authtry_bsses[i]); - cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); - wdev->authtry_bsses[i] = NULL; - } - } + memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); + req.bssid = bssid; + rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); + + if (wdev->current_bss) { + cfg80211_unhold_bss(wdev->current_bss); + cfg80211_put_bss(&wdev->current_bss->pub); + wdev->current_bss = NULL; } } diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index c910b0750dc2..e1fd1bf90729 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -4083,7 +4083,6 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, struct cfg80211_bss *res = &intbss->pub; void *hdr; struct nlattr *bss; - int i; ASSERT_WDEV_LOCK(wdev); @@ -4136,13 +4135,6 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, if (intbss == wdev->current_bss) NLA_PUT_U32(msg, NL80211_BSS_STATUS, NL80211_BSS_STATUS_ASSOCIATED); - else for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (intbss != wdev->auth_bsses[i]) - continue; - NLA_PUT_U32(msg, NL80211_BSS_STATUS, - NL80211_BSS_STATUS_AUTHENTICATED); - break; - } break; case NL80211_IFTYPE_ADHOC: if (intbss == wdev->current_bss) @@ -4410,10 +4402,16 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; + /* + * Since we no longer track auth state, ignore + * requests to only change local state. + */ + if (local_state_change) + return 0; + return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, ssid, ssid_len, ie, ie_len, - key.p.key, key.p.key_len, key.idx, - local_state_change); + key.p.key, key.p.key_len, key.idx); } static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 7b9ecaed96be..f7e937ff8978 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -179,7 +179,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) params->ssid, params->ssid_len, NULL, 0, params->key, params->key_len, - params->key_idx, false); + params->key_idx); case CFG80211_CONN_ASSOCIATE_NEXT: BUG_ON(!rdev->ops->assoc); wdev->conn->state = CFG80211_CONN_ASSOCIATING; @@ -477,6 +477,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, kfree(wdev->connect_keys); wdev->connect_keys = NULL; wdev->ssid_len = 0; + cfg80211_put_bss(bss); return; } @@ -701,31 +702,10 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, wdev->ssid_len = 0; if (wdev->conn) { - const u8 *bssid; - int ret; - kfree(wdev->conn->ie); wdev->conn->ie = NULL; kfree(wdev->conn); wdev->conn = NULL; - - /* - * If this disconnect was due to a disassoc, we - * we might still have an auth BSS around. For - * the userspace SME that's currently expected, - * but for the kernel SME (nl80211 CONNECT or - * wireless extensions) we want to clear up all - * state. - */ - for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (!wdev->auth_bsses[i]) - continue; - bssid = wdev->auth_bsses[i]->pub.bssid; - ret = __cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0, - WLAN_REASON_DEAUTH_LEAVING, - false); - WARN(ret, "deauth failed: %d\n", ret); - } } nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); @@ -1012,7 +992,8 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, return err; } -void cfg80211_sme_disassoc(struct net_device *dev, int idx) +void cfg80211_sme_disassoc(struct net_device *dev, + struct cfg80211_internal_bss *bss) { struct wireless_dev *wdev = dev->ieee80211_ptr; struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); @@ -1031,16 +1012,8 @@ void cfg80211_sme_disassoc(struct net_device *dev, int idx) * want it any more so deauthenticate too. */ - if (!wdev->auth_bsses[idx]) - return; + memcpy(bssid, bss->pub.bssid, ETH_ALEN); - memcpy(bssid, wdev->auth_bsses[idx]->pub.bssid, ETH_ALEN); - if (__cfg80211_mlme_deauth(rdev, dev, bssid, - NULL, 0, WLAN_REASON_DEAUTH_LEAVING, - false)) { - /* whatever -- assume gone anyway */ - cfg80211_unhold_bss(wdev->auth_bsses[idx]); - cfg80211_put_bss(&wdev->auth_bsses[idx]->pub); - wdev->auth_bsses[idx] = NULL; - } + __cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0, + WLAN_REASON_DEAUTH_LEAVING, false); } -- GitLab From 4c0c0b75e0c35ddb8f61c06bcbffede63ab4f4a2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:26 +0100 Subject: [PATCH 0388/1846] cfg80211: export cfg80211_ref_bss This is needed by mac80211 to keep a reference to a BSS alive for the auth process. Remove the old version of cfg80211_ref_bss() since it's not actually used. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/cfg80211.h | 14 ++++++++++++++ net/wireless/core.h | 5 ----- net/wireless/scan.c | 12 ++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 6cfecb02a34b..229edc526cf5 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2719,6 +2719,20 @@ struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy, struct ieee80211_channel *channel, const u8 *meshid, size_t meshidlen, const u8 *meshcfg); +/** + * cfg80211_ref_bss - reference BSS struct + * @bss: the BSS struct to reference + * + * Increments the refcount of the given BSS struct. + */ +void cfg80211_ref_bss(struct cfg80211_bss *bss); + +/** + * cfg80211_put_bss - unref BSS struct + * @bss: the BSS struct + * + * Decrements the refcount of the given BSS struct. + */ void cfg80211_put_bss(struct cfg80211_bss *bss); /** diff --git a/net/wireless/core.h b/net/wireless/core.h index 2b454caf4395..3ac2dd00d714 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -144,11 +144,6 @@ static inline struct cfg80211_internal_bss *bss_from_pub(struct cfg80211_bss *pu return container_of(pub, struct cfg80211_internal_bss, pub); } -static inline void cfg80211_ref_bss(struct cfg80211_internal_bss *bss) -{ - kref_get(&bss->ref); -} - static inline void cfg80211_hold_bss(struct cfg80211_internal_bss *bss) { atomic_inc(&bss->hold); diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 31119e32e092..afde7e5f0010 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -861,6 +861,18 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, } EXPORT_SYMBOL(cfg80211_inform_bss_frame); +void cfg80211_ref_bss(struct cfg80211_bss *pub) +{ + struct cfg80211_internal_bss *bss; + + if (!pub) + return; + + bss = container_of(pub, struct cfg80211_internal_bss, pub); + kref_get(&bss->ref); +} +EXPORT_SYMBOL(cfg80211_ref_bss); + void cfg80211_put_bss(struct cfg80211_bss *pub) { struct cfg80211_internal_bss *bss; -- GitLab From 66e67e418908442389d3a9e6509985f01cbaf9b0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:27 +0100 Subject: [PATCH 0389/1846] mac80211: redesign auth/assoc This is the second part of the auth/assoc redesign, the mac80211 part. This moves the auth/assoc code out of the work abstraction and into the MLME, so that we don't flip channels all the time etc. The only downside is that when we are associated, we need to drop the association in order to create a connection to another AP, but for most drivers this is actually desirable and the ability to do was never used by any applications. If we want to implement resource reservation with FT-OTA, we'd probably best do it with explicit R-O-C in wpa_s. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/Makefile | 4 +- net/mac80211/cfg.c | 6 +- net/mac80211/ieee80211_i.h | 77 ++- net/mac80211/iface.c | 4 +- net/mac80211/main.c | 10 +- net/mac80211/mlme.c | 1340 ++++++++++++++++++++++++++---------- net/mac80211/rx.c | 9 +- net/mac80211/work.c | 815 ---------------------- 8 files changed, 1038 insertions(+), 1227 deletions(-) diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index d540c3b160f3..1be7a454aa77 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -9,7 +9,7 @@ mac80211-y := \ scan.o offchannel.o \ ht.o agg-tx.o agg-rx.o \ ibss.o \ - mlme.o work.o \ + work.o \ iface.o \ rate.o \ michael.o \ @@ -25,7 +25,7 @@ mac80211-y := \ wme.o \ event.o \ chan.o \ - driver-trace.o + driver-trace.o mlme.o mac80211-$(CONFIG_MAC80211_LEDS) += led.o mac80211-$(CONFIG_MAC80211_DEBUGFS) += \ diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index d15ba0d0de94..c3de921c8cfd 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2028,7 +2028,7 @@ ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb) if (wk->offchan_tx.wait && !wk->offchan_tx.status) cfg80211_mgmt_tx_status(wk->sdata->dev, (unsigned long) wk->offchan_tx.frame, - wk->ie, wk->ie_len, false, GFP_KERNEL); + wk->data, wk->data_len, false, GFP_KERNEL); return WORK_DONE_DESTROY; } @@ -2179,8 +2179,8 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, wk->done = ieee80211_offchan_tx_done; wk->offchan_tx.frame = skb; wk->offchan_tx.wait = wait; - wk->ie_len = len; - memcpy(wk->ie, buf, len); + wk->data_len = len; + memcpy(wk->data, buf, len); ieee80211_add_work(wk); return 0; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index d47e8c110b16..a146b1177cb0 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -280,10 +280,6 @@ struct mesh_preq_queue { enum ieee80211_work_type { IEEE80211_WORK_ABORT, - IEEE80211_WORK_DIRECT_PROBE, - IEEE80211_WORK_AUTH, - IEEE80211_WORK_ASSOC_BEACON_WAIT, - IEEE80211_WORK_ASSOC, IEEE80211_WORK_REMAIN_ON_CHANNEL, IEEE80211_WORK_OFFCHANNEL_TX, }; @@ -316,35 +312,9 @@ struct ieee80211_work { unsigned long timeout; enum ieee80211_work_type type; - u8 filter_ta[ETH_ALEN]; - bool started; union { - struct { - int tries; - u16 algorithm, transaction; - u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssid_len; - u8 key[WLAN_KEY_LEN_WEP104]; - u8 key_len, key_idx; - bool privacy; - bool synced; - } probe_auth; - struct { - struct cfg80211_bss *bss; - const u8 *supp_rates; - const u8 *ht_information_ie; - enum ieee80211_smps_mode smps; - int tries; - u16 capability; - u8 prev_bssid[ETH_ALEN]; - u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssid_len; - u8 supp_rates_len; - bool wmm_used, use_11n, uapsd_used; - bool synced; - } assoc; struct { u32 duration; } remain; @@ -355,9 +325,8 @@ struct ieee80211_work { } offchan_tx; }; - int ie_len; - /* must be last */ - u8 ie[0]; + size_t data_len; + u8 data[]; }; /* flags used in struct ieee80211_if_managed.flags */ @@ -373,6 +342,43 @@ enum ieee80211_sta_flags { IEEE80211_STA_RESET_SIGNAL_AVE = BIT(9), }; +struct ieee80211_mgd_auth_data { + struct cfg80211_bss *bss; + unsigned long timeout; + int tries; + u16 algorithm, expected_transaction; + + u8 key[WLAN_KEY_LEN_WEP104]; + u8 key_len, key_idx; + bool synced; + bool done; + + size_t ie_len; + u8 ie[]; +}; + +struct ieee80211_mgd_assoc_data { + struct cfg80211_bss *bss; + const u8 *supp_rates; + const u8 *ht_information_ie; + + unsigned long timeout; + int tries; + + u16 capability; + u8 prev_bssid[ETH_ALEN]; + u8 ssid[IEEE80211_MAX_SSID_LEN]; + u8 ssid_len; + u8 supp_rates_len; + bool wmm_used, uapsd_used; + bool have_beacon; + bool sent_assoc; + bool synced; + + size_t ie_len; + u8 ie[]; +}; + struct ieee80211_if_managed { struct timer_list timer; struct timer_list conn_mon_timer; @@ -389,6 +395,8 @@ struct ieee80211_if_managed { struct mutex mtx; struct cfg80211_bss *associated; + struct ieee80211_mgd_auth_data *auth_data; + struct ieee80211_mgd_assoc_data *assoc_data; u8 bssid[ETH_ALEN]; @@ -770,7 +778,6 @@ struct ieee80211_local { struct list_head work_list; struct timer_list work_timer; struct work_struct work_work; - struct sk_buff_head work_skb_queue; /* * private workqueue to mac80211. mac80211 makes this accessible @@ -1437,8 +1444,6 @@ void ieee80211_work_init(struct ieee80211_local *local); void ieee80211_add_work(struct ieee80211_work *wk); void free_work(struct ieee80211_work *wk); void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata); -ieee80211_rx_result ieee80211_work_rx_mgmt(struct ieee80211_sub_if_data *sdata, - struct sk_buff *skb); int ieee80211_wk_remain_on_channel(struct ieee80211_sub_if_data *sdata, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type, diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 2efd595b2f7a..19f0818eba78 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1310,7 +1310,9 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local) /* do not count disabled managed interfaces */ if (sdata->vif.type == NL80211_IFTYPE_STATION && - !sdata->u.mgd.associated) { + !sdata->u.mgd.associated && + !sdata->u.mgd.auth_data && + !sdata->u.mgd.assoc_data) { sdata->vif.bss_conf.idle = true; continue; } diff --git a/net/mac80211/main.c b/net/mac80211/main.c index f4fc540aac17..362e89d6d467 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -199,15 +199,7 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, return; if (sdata->vif.type == NL80211_IFTYPE_STATION) { - /* - * While not associated, claim a BSSID of all-zeroes - * so that drivers don't do any weird things with the - * BSSID at that time. - */ - if (sdata->vif.bss_conf.assoc) - sdata->vif.bss_conf.bssid = sdata->u.mgd.bssid; - else - sdata->vif.bss_conf.bssid = zero; + sdata->vif.bss_conf.bssid = sdata->u.mgd.bssid; } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid; else if (sdata->vif.type == NL80211_IFTYPE_AP) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 082fcda57786..52133dab9297 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -30,6 +30,12 @@ #include "rate.h" #include "led.h" +#define IEEE80211_AUTH_TIMEOUT (HZ / 5) +#define IEEE80211_AUTH_MAX_TRIES 3 +#define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5) +#define IEEE80211_ASSOC_TIMEOUT (HZ / 5) +#define IEEE80211_ASSOC_MAX_TRIES 3 + static int max_nullfunc_tries = 2; module_param(max_nullfunc_tries, int, 0644); MODULE_PARM_DESC(max_nullfunc_tries, @@ -97,6 +103,15 @@ enum rx_mgmt_action { /* caller must call cfg80211_send_disassoc() */ RX_MGMT_CFG80211_DISASSOC, + + /* caller must call cfg80211_send_rx_auth() */ + RX_MGMT_CFG80211_RX_AUTH, + + /* caller must call cfg80211_send_rx_assoc() */ + RX_MGMT_CFG80211_RX_ASSOC, + + /* caller must call cfg80211_send_assoc_timeout() */ + RX_MGMT_CFG80211_ASSOC_TIMEOUT, }; /* utils */ @@ -115,8 +130,7 @@ static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed *ifmgd) * has happened -- the work that runs from this timer will * do that. */ -static void run_again(struct ieee80211_if_managed *ifmgd, - unsigned long timeout) +static void run_again(struct ieee80211_if_managed *ifmgd, unsigned long timeout) { ASSERT_MGD_MTX(ifmgd); @@ -284,6 +298,319 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, /* frame sending functions */ +static int ieee80211_compatible_rates(const u8 *supp_rates, int supp_rates_len, + struct ieee80211_supported_band *sband, + u32 *rates) +{ + int i, j, count; + *rates = 0; + count = 0; + for (i = 0; i < supp_rates_len; i++) { + int rate = (supp_rates[i] & 0x7F) * 5; + + for (j = 0; j < sband->n_bitrates; j++) + if (sband->bitrates[j].bitrate == rate) { + *rates |= BIT(j); + count++; + break; + } + } + + return count; +} + +static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, const u8 *ht_info_ie, + struct ieee80211_supported_band *sband, + struct ieee80211_channel *channel, + enum ieee80211_smps_mode smps) +{ + struct ieee80211_ht_info *ht_info; + u8 *pos; + u32 flags = channel->flags; + u16 cap; + struct ieee80211_sta_ht_cap ht_cap; + + BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap)); + + if (!sband->ht_cap.ht_supported) + return; + + if (!ht_info_ie) + return; + + if (ht_info_ie[1] < sizeof(struct ieee80211_ht_info)) + return; + + memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap)); + ieee80211_apply_htcap_overrides(sdata, &ht_cap); + + ht_info = (struct ieee80211_ht_info *)(ht_info_ie + 2); + + /* determine capability flags */ + cap = ht_cap.cap; + + switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: + if (flags & IEEE80211_CHAN_NO_HT40PLUS) { + cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; + cap &= ~IEEE80211_HT_CAP_SGI_40; + } + break; + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: + if (flags & IEEE80211_CHAN_NO_HT40MINUS) { + cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; + cap &= ~IEEE80211_HT_CAP_SGI_40; + } + break; + } + + /* set SM PS mode properly */ + cap &= ~IEEE80211_HT_CAP_SM_PS; + switch (smps) { + case IEEE80211_SMPS_AUTOMATIC: + case IEEE80211_SMPS_NUM_MODES: + WARN_ON(1); + case IEEE80211_SMPS_OFF: + cap |= WLAN_HT_CAP_SM_PS_DISABLED << + IEEE80211_HT_CAP_SM_PS_SHIFT; + break; + case IEEE80211_SMPS_STATIC: + cap |= WLAN_HT_CAP_SM_PS_STATIC << + IEEE80211_HT_CAP_SM_PS_SHIFT; + break; + case IEEE80211_SMPS_DYNAMIC: + cap |= WLAN_HT_CAP_SM_PS_DYNAMIC << + IEEE80211_HT_CAP_SM_PS_SHIFT; + break; + } + + /* reserve and fill IE */ + pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2); + ieee80211_ie_build_ht_cap(pos, &ht_cap, cap); +} + +static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; + struct sk_buff *skb; + struct ieee80211_mgmt *mgmt; + u8 *pos, qos_info; + size_t offset = 0, noffset; + int i, count, rates_len, supp_rates_len; + u16 capab; + struct ieee80211_supported_band *sband; + u32 rates = 0; + struct ieee80211_bss *bss = (void *)assoc_data->bss->priv; + + lockdep_assert_held(&ifmgd->mtx); + + sband = local->hw.wiphy->bands[local->oper_channel->band]; + + if (assoc_data->supp_rates_len) { + /* + * Get all rates supported by the device and the AP as + * some APs don't like getting a superset of their rates + * in the association request (e.g. D-Link DAP 1353 in + * b-only mode)... + */ + rates_len = ieee80211_compatible_rates(assoc_data->supp_rates, + assoc_data->supp_rates_len, + sband, &rates); + } else { + /* + * In case AP not provide any supported rates information + * before association, we send information element(s) with + * all rates that we support. + */ + rates = ~0; + rates_len = sband->n_bitrates; + } + + skb = alloc_skb(local->hw.extra_tx_headroom + + sizeof(*mgmt) + /* bit too much but doesn't matter */ + 2 + assoc_data->ssid_len + /* SSID */ + 4 + rates_len + /* (extended) rates */ + 4 + /* power capability */ + 2 + 2 * sband->n_channels + /* supported channels */ + 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ + assoc_data->ie_len + /* extra IEs */ + 9, /* WMM */ + GFP_KERNEL); + if (!skb) + return; + + skb_reserve(skb, local->hw.extra_tx_headroom); + + capab = WLAN_CAPABILITY_ESS; + + if (sband->band == IEEE80211_BAND_2GHZ) { + if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) + capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; + if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) + capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; + } + + if (assoc_data->capability & WLAN_CAPABILITY_PRIVACY) + capab |= WLAN_CAPABILITY_PRIVACY; + + if ((assoc_data->capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && + (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) + capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; + + mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); + memset(mgmt, 0, 24); + memcpy(mgmt->da, assoc_data->bss->bssid, ETH_ALEN); + memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); + memcpy(mgmt->bssid, assoc_data->bss->bssid, ETH_ALEN); + + if (!is_zero_ether_addr(assoc_data->prev_bssid)) { + skb_put(skb, 10); + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_REASSOC_REQ); + mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); + mgmt->u.reassoc_req.listen_interval = + cpu_to_le16(local->hw.conf.listen_interval); + memcpy(mgmt->u.reassoc_req.current_ap, assoc_data->prev_bssid, + ETH_ALEN); + } else { + skb_put(skb, 4); + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ASSOC_REQ); + mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); + mgmt->u.assoc_req.listen_interval = + cpu_to_le16(local->hw.conf.listen_interval); + } + + /* SSID */ + pos = skb_put(skb, 2 + assoc_data->ssid_len); + *pos++ = WLAN_EID_SSID; + *pos++ = assoc_data->ssid_len; + memcpy(pos, assoc_data->ssid, assoc_data->ssid_len); + + /* add all rates which were marked to be used above */ + supp_rates_len = rates_len; + if (supp_rates_len > 8) + supp_rates_len = 8; + + pos = skb_put(skb, supp_rates_len + 2); + *pos++ = WLAN_EID_SUPP_RATES; + *pos++ = supp_rates_len; + + count = 0; + for (i = 0; i < sband->n_bitrates; i++) { + if (BIT(i) & rates) { + int rate = sband->bitrates[i].bitrate; + *pos++ = (u8) (rate / 5); + if (++count == 8) + break; + } + } + + if (rates_len > count) { + pos = skb_put(skb, rates_len - count + 2); + *pos++ = WLAN_EID_EXT_SUPP_RATES; + *pos++ = rates_len - count; + + for (i++; i < sband->n_bitrates; i++) { + if (BIT(i) & rates) { + int rate = sband->bitrates[i].bitrate; + *pos++ = (u8) (rate / 5); + } + } + } + + if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) { + /* 1. power capabilities */ + pos = skb_put(skb, 4); + *pos++ = WLAN_EID_PWR_CAPABILITY; + *pos++ = 2; + *pos++ = 0; /* min tx power */ + *pos++ = local->oper_channel->max_power; /* max tx power */ + + /* 2. supported channels */ + /* TODO: get this in reg domain format */ + pos = skb_put(skb, 2 * sband->n_channels + 2); + *pos++ = WLAN_EID_SUPPORTED_CHANNELS; + *pos++ = 2 * sband->n_channels; + for (i = 0; i < sband->n_channels; i++) { + *pos++ = ieee80211_frequency_to_channel( + sband->channels[i].center_freq); + *pos++ = 1; /* one channel in the subband*/ + } + } + + /* if present, add any custom IEs that go before HT */ + if (assoc_data->ie_len && assoc_data->ie) { + static const u8 before_ht[] = { + WLAN_EID_SSID, + WLAN_EID_SUPP_RATES, + WLAN_EID_EXT_SUPP_RATES, + WLAN_EID_PWR_CAPABILITY, + WLAN_EID_SUPPORTED_CHANNELS, + WLAN_EID_RSN, + WLAN_EID_QOS_CAPA, + WLAN_EID_RRM_ENABLED_CAPABILITIES, + WLAN_EID_MOBILITY_DOMAIN, + WLAN_EID_SUPPORTED_REGULATORY_CLASSES, + }; + noffset = ieee80211_ie_split(assoc_data->ie, assoc_data->ie_len, + before_ht, ARRAY_SIZE(before_ht), + offset); + pos = skb_put(skb, noffset - offset); + memcpy(pos, assoc_data->ie + offset, noffset - offset); + offset = noffset; + } + + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N) && + bss->wmm_used && local->hw.queues >= 4) + ieee80211_add_ht_ie(sdata, skb, assoc_data->ht_information_ie, + sband, local->oper_channel, ifmgd->ap_smps); + + /* if present, add any custom non-vendor IEs that go after HT */ + if (assoc_data->ie_len && assoc_data->ie) { + noffset = ieee80211_ie_split_vendor(assoc_data->ie, + assoc_data->ie_len, + offset); + pos = skb_put(skb, noffset - offset); + memcpy(pos, assoc_data->ie + offset, noffset - offset); + offset = noffset; + } + + if (assoc_data->wmm_used && local->hw.queues >= 4) { + if (assoc_data->uapsd_used) { + qos_info = local->uapsd_queues; + qos_info |= (local->uapsd_max_sp_len << + IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); + } else { + qos_info = 0; + } + + pos = skb_put(skb, 9); + *pos++ = WLAN_EID_VENDOR_SPECIFIC; + *pos++ = 7; /* len */ + *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ + *pos++ = 0x50; + *pos++ = 0xf2; + *pos++ = 2; /* WME */ + *pos++ = 0; /* WME info */ + *pos++ = 1; /* WME ver */ + *pos++ = qos_info; + } + + /* add any remaining custom (i.e. vendor specific here) IEs */ + if (assoc_data->ie_len && assoc_data->ie) { + noffset = assoc_data->ie_len; + pos = skb_put(skb, noffset - offset); + memcpy(pos, assoc_data->ie + offset, noffset - offset); + } + + IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; + ieee80211_tx_skb(sdata, skb); +} + static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, const u8 *bssid, u16 stype, u16 reason, void *cookie, bool send_frame) @@ -1423,6 +1750,135 @@ void ieee80211_connection_loss(struct ieee80211_vif *vif) EXPORT_SYMBOL(ieee80211_connection_loss); +static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, + bool assoc) +{ + struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; + + lockdep_assert_held(&sdata->u.mgd.mtx); + + if (auth_data->synced) + drv_finish_tx_sync(sdata->local, sdata, + auth_data->bss->bssid, + IEEE80211_TX_SYNC_AUTH); + + if (!assoc) { + sta_info_destroy_addr(sdata, auth_data->bss->bssid); + + memset(sdata->u.mgd.bssid, 0, ETH_ALEN); + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); + } + + cfg80211_put_bss(auth_data->bss); + kfree(auth_data); + sdata->u.mgd.auth_data = NULL; +} + +static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len) +{ + struct ieee80211_mgd_auth_data *auth_data = sdata->u.mgd.auth_data; + u8 *pos; + struct ieee802_11_elems elems; + + pos = mgmt->u.auth.variable; + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); + if (!elems.challenge) + return; + auth_data->expected_transaction = 4; + ieee80211_send_auth(sdata, 3, auth_data->algorithm, + elems.challenge - 2, elems.challenge_len + 2, + auth_data->bss->bssid, auth_data->bss->bssid, + auth_data->key, auth_data->key_len, + auth_data->key_idx); +} + +static enum rx_mgmt_action __must_check +ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len) +{ + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + u8 bssid[ETH_ALEN]; + u16 auth_alg, auth_transaction, status_code; + struct sta_info *sta; + + lockdep_assert_held(&ifmgd->mtx); + + if (len < 24 + 6) + return RX_MGMT_NONE; + + if (!ifmgd->auth_data || ifmgd->auth_data->done) + return RX_MGMT_NONE; + + memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); + + if (memcmp(bssid, mgmt->bssid, ETH_ALEN)) + return RX_MGMT_NONE; + + auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); + auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); + status_code = le16_to_cpu(mgmt->u.auth.status_code); + + if (auth_alg != ifmgd->auth_data->algorithm || + auth_transaction != ifmgd->auth_data->expected_transaction) + return RX_MGMT_NONE; + + if (status_code != WLAN_STATUS_SUCCESS) { + printk(KERN_DEBUG "%s: %pM denied authentication (status %d)\n", + sdata->name, mgmt->sa, status_code); + goto out; + } + + switch (ifmgd->auth_data->algorithm) { + case WLAN_AUTH_OPEN: + case WLAN_AUTH_LEAP: + case WLAN_AUTH_FT: + break; + case WLAN_AUTH_SHARED_KEY: + if (ifmgd->auth_data->expected_transaction != 4) { + ieee80211_auth_challenge(sdata, mgmt, len); + /* need another frame */ + return RX_MGMT_NONE; + } + break; + default: + WARN_ONCE(1, "invalid auth alg %d", + ifmgd->auth_data->algorithm); + return RX_MGMT_NONE; + } + + printk(KERN_DEBUG "%s: authenticated\n", sdata->name); + out: + if (ifmgd->auth_data->synced) + drv_finish_tx_sync(sdata->local, sdata, bssid, + IEEE80211_TX_SYNC_AUTH); + ifmgd->auth_data->synced = false; + ifmgd->auth_data->done = true; + ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; + run_again(ifmgd, ifmgd->auth_data->timeout); + + /* move station state to auth */ + mutex_lock(&sdata->local->sta_mtx); + sta = sta_info_get(sdata, bssid); + if (!sta) { + WARN_ONCE(1, "%s: STA %pM not found", sdata->name, bssid); + goto out_err; + } + if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) { + printk(KERN_DEBUG "%s: failed moving %pM to auth\n", + sdata->name, bssid); + goto out_err; + } + mutex_unlock(&sdata->local->sta_mtx); + + return RX_MGMT_CFG80211_RX_AUTH; + out_err: + mutex_unlock(&sdata->local->sta_mtx); + /* ignore frame -- wait for timeout */ + return RX_MGMT_NONE; +} + + static enum rx_mgmt_action __must_check ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, size_t len) @@ -1431,10 +1887,14 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, const u8 *bssid = NULL; u16 reason_code; + lockdep_assert_held(&ifmgd->mtx); + if (len < 24 + 2) return RX_MGMT_NONE; - ASSERT_MGD_MTX(ifmgd); + if (!ifmgd->associated || + memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) + return RX_MGMT_NONE; bssid = ifmgd->associated->bssid; @@ -1459,15 +1919,13 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; u16 reason_code; - if (len < 24 + 2) - return RX_MGMT_NONE; - - ASSERT_MGD_MTX(ifmgd); + lockdep_assert_held(&ifmgd->mtx); - if (WARN_ON(!ifmgd->associated)) + if (len < 24 + 2) return RX_MGMT_NONE; - if (WARN_ON(memcmp(ifmgd->associated->bssid, mgmt->sa, ETH_ALEN))) + if (!ifmgd->associated || + memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) return RX_MGMT_NONE; reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); @@ -1524,15 +1982,37 @@ static void ieee80211_get_rates(struct ieee80211_supported_band *sband, } } -static bool ieee80211_assoc_success(struct ieee80211_work *wk, +static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata, + bool assoc) +{ + struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; + + lockdep_assert_held(&sdata->u.mgd.mtx); + + if (assoc_data->synced) + drv_finish_tx_sync(sdata->local, sdata, + assoc_data->bss->bssid, + IEEE80211_TX_SYNC_ASSOC); + + if (!assoc) { + sta_info_destroy_addr(sdata, assoc_data->bss->bssid); + + memset(sdata->u.mgd.bssid, 0, ETH_ALEN); + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); + } + + kfree(assoc_data); + sdata->u.mgd.assoc_data = NULL; +} + +static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, + struct cfg80211_bss *cbss, struct ieee80211_mgmt *mgmt, size_t len) { - struct ieee80211_sub_if_data *sdata = wk->sdata; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_local *local = sdata->local; struct ieee80211_supported_band *sband; struct sta_info *sta; - struct cfg80211_bss *cbss = wk->assoc.bss; u8 *pos; u32 rates, basic_rates; u16 capab_info, aid; @@ -1589,7 +2069,7 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, rates = 0; basic_rates = 0; - sband = local->hw.wiphy->bands[wk->chan->band]; + sband = local->hw.wiphy->bands[local->oper_channel->band]; ieee80211_get_rates(sband, elems.supp_rates, elems.supp_rates_len, &rates, &basic_rates, &have_higher_than_11mbit, @@ -1610,11 +2090,11 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, basic_rates = BIT(min_rate_index); } - sta->sta.supp_rates[wk->chan->band] = rates; + sta->sta.supp_rates[local->oper_channel->band] = rates; sdata->vif.bss_conf.basic_rates = basic_rates; /* cf. IEEE 802.11 9.2.12 */ - if (wk->chan->band == IEEE80211_BAND_2GHZ && + if (local->oper_channel->band == IEEE80211_BAND_2GHZ && have_higher_than_11mbit) sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; else @@ -1664,8 +2144,6 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, else ieee80211_set_wmm_default(sdata); - local->oper_channel = wk->chan; - if (elems.ht_info_elem && elems.wmm_param && (sdata->local->hw.queues >= 4) && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) @@ -1696,7 +2174,82 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk, return true; } +static enum rx_mgmt_action __must_check +ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len, + struct cfg80211_bss **bss) +{ + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; + u16 capab_info, status_code, aid; + struct ieee802_11_elems elems; + u8 *pos; + bool reassoc; + + lockdep_assert_held(&ifmgd->mtx); + + if (!assoc_data) + return RX_MGMT_NONE; + if (memcmp(assoc_data->bss->bssid, mgmt->bssid, ETH_ALEN)) + return RX_MGMT_NONE; + + /* + * AssocResp and ReassocResp have identical structure, so process both + * of them in this function. + */ + + if (len < 24 + 6) + return RX_MGMT_NONE; + + reassoc = ieee80211_is_reassoc_req(mgmt->frame_control); + capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); + status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); + aid = le16_to_cpu(mgmt->u.assoc_resp.aid); + + printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x " + "status=%d aid=%d)\n", + sdata->name, reassoc ? "Rea" : "A", mgmt->sa, + capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); + + pos = mgmt->u.assoc_resp.variable; + ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); + + if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && + elems.timeout_int && elems.timeout_int_len == 5 && + elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { + u32 tu, ms; + tu = get_unaligned_le32(elems.timeout_int + 1); + ms = tu * 1024 / 1000; + printk(KERN_DEBUG "%s: %pM rejected association temporarily; " + "comeback duration %u TU (%u ms)\n", + sdata->name, mgmt->sa, tu, ms); + assoc_data->timeout = jiffies + msecs_to_jiffies(ms); + if (ms > IEEE80211_ASSOC_TIMEOUT) + run_again(ifmgd, assoc_data->timeout); + return RX_MGMT_NONE; + } + + *bss = assoc_data->bss; + + if (status_code != WLAN_STATUS_SUCCESS) { + printk(KERN_DEBUG "%s: %pM denied association (code=%d)\n", + sdata->name, mgmt->sa, status_code); + ieee80211_destroy_assoc_data(sdata, false); + } else { + printk(KERN_DEBUG "%s: associated\n", sdata->name); + + ieee80211_destroy_assoc_data(sdata, true); + if (!ieee80211_assoc_success(sdata, *bss, mgmt, len)) { + /* oops -- internal error -- send timeout for now */ + sta_info_destroy_addr(sdata, mgmt->bssid); + cfg80211_put_bss(*bss); + return RX_MGMT_CFG80211_ASSOC_TIMEOUT; + } + } + + return RX_MGMT_CFG80211_RX_ASSOC; +} static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, size_t len, @@ -1710,7 +2263,9 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, struct ieee80211_channel *channel; bool need_ps = false; - if (sdata->u.mgd.associated) { + if (sdata->u.mgd.associated && + memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, + ETH_ALEN) == 0) { bss = (void *)sdata->u.mgd.associated->priv; /* not previously set so we may need to recalc */ need_ps = !bss->dtim_period; @@ -1780,6 +2335,15 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, if (ifmgd->associated && memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0) ieee80211_reset_ap_probe(sdata); + + if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies && + memcmp(mgmt->bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN) == 0) { + /* got probe response, continue with auth */ + printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); + ifmgd->auth_data->tries = 0; + ifmgd->auth_data->timeout = jiffies; + run_again(ifmgd, ifmgd->auth_data->timeout); + } } /* @@ -1819,7 +2383,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, u32 ncrc; u8 *bssid; - ASSERT_MGD_MTX(ifmgd); + lockdep_assert_held(&ifmgd->mtx); /* Process beacon from the current BSS */ baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; @@ -1829,21 +2393,25 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, if (rx_status->freq != local->hw.conf.channel->center_freq) return; - /* - * We might have received a number of frames, among them a - * disassoc frame and a beacon... - */ - if (!ifmgd->associated) - return; + if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && + memcmp(mgmt->bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN) == 0) { + ieee802_11_parse_elems(mgmt->u.beacon.variable, + len - baselen, &elems); - bssid = ifmgd->associated->bssid; + ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, + false); + ifmgd->assoc_data->have_beacon = true; + ifmgd->assoc_data->sent_assoc = false; + /* continue assoc process */ + ifmgd->assoc_data->timeout = jiffies; + run_again(ifmgd, ifmgd->assoc_data->timeout); + return; + } - /* - * And in theory even frames from a different AP we were just - * associated to a split-second ago! - */ - if (memcmp(bssid, mgmt->bssid, ETH_ALEN) != 0) + if (!ifmgd->associated || + memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) return; + bssid = ifmgd->associated->bssid; /* Track average RSSI from the Beacon frames of the current AP */ ifmgd->last_beacon_signal = rx_status->signal; @@ -2027,6 +2595,7 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_rx_status *rx_status; struct ieee80211_mgmt *mgmt; + struct cfg80211_bss *bss = NULL; enum rx_mgmt_action rma = RX_MGMT_NONE; u16 fc; @@ -2036,92 +2605,59 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, mutex_lock(&ifmgd->mtx); - if (ifmgd->associated && - memcmp(ifmgd->associated->bssid, mgmt->bssid, ETH_ALEN) == 0) { - switch (fc & IEEE80211_FCTL_STYPE) { - case IEEE80211_STYPE_BEACON: - ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, - rx_status); - break; - case IEEE80211_STYPE_PROBE_RESP: - ieee80211_rx_mgmt_probe_resp(sdata, skb); - break; - case IEEE80211_STYPE_DEAUTH: - rma = ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); - break; - case IEEE80211_STYPE_DISASSOC: - rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); - break; - case IEEE80211_STYPE_ACTION: - switch (mgmt->u.action.category) { - case WLAN_CATEGORY_SPECTRUM_MGMT: - ieee80211_sta_process_chanswitch(sdata, - &mgmt->u.action.u.chan_switch.sw_elem, - (void *)ifmgd->associated->priv, - rx_status->mactime); - break; - } - } - mutex_unlock(&ifmgd->mtx); - - switch (rma) { - case RX_MGMT_NONE: - /* no action */ - break; - case RX_MGMT_CFG80211_DEAUTH: - cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); - break; - case RX_MGMT_CFG80211_DISASSOC: - cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); + switch (fc & IEEE80211_FCTL_STYPE) { + case IEEE80211_STYPE_BEACON: + ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, rx_status); + break; + case IEEE80211_STYPE_PROBE_RESP: + ieee80211_rx_mgmt_probe_resp(sdata, skb); + break; + case IEEE80211_STYPE_AUTH: + rma = ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); + break; + case IEEE80211_STYPE_DEAUTH: + rma = ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); + break; + case IEEE80211_STYPE_DISASSOC: + rma = ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); + break; + case IEEE80211_STYPE_ASSOC_RESP: + case IEEE80211_STYPE_REASSOC_RESP: + rma = ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, &bss); + break; + case IEEE80211_STYPE_ACTION: + switch (mgmt->u.action.category) { + case WLAN_CATEGORY_SPECTRUM_MGMT: + ieee80211_sta_process_chanswitch(sdata, + &mgmt->u.action.u.chan_switch.sw_elem, + (void *)ifmgd->associated->priv, + rx_status->mactime); break; - default: - WARN(1, "unexpected: %d", rma); } - return; } - mutex_unlock(&ifmgd->mtx); - if (skb->len >= 24 + 2 /* mgmt + deauth reason */ && - (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_DEAUTH) { - struct ieee80211_local *local = sdata->local; - struct ieee80211_work *wk; - - mutex_lock(&local->mtx); - list_for_each_entry(wk, &local->work_list, list) { - if (wk->sdata != sdata) - continue; - - if (wk->type != IEEE80211_WORK_ASSOC && - wk->type != IEEE80211_WORK_ASSOC_BEACON_WAIT) - continue; - - if (memcmp(mgmt->bssid, wk->filter_ta, ETH_ALEN)) - continue; - if (memcmp(mgmt->sa, wk->filter_ta, ETH_ALEN)) - continue; - - /* - * Printing the message only here means we can't - * spuriously print it, but it also means that it - * won't be printed when the frame comes in before - * we even tried to associate or in similar cases. - * - * Ultimately, I suspect cfg80211 should print the - * messages instead. - */ - printk(KERN_DEBUG - "%s: deauthenticated from %pM (Reason: %u)\n", - sdata->name, mgmt->bssid, - le16_to_cpu(mgmt->u.deauth.reason_code)); - - list_del_rcu(&wk->list); - free_work(wk); - break; - } - mutex_unlock(&local->mtx); - + switch (rma) { + case RX_MGMT_NONE: + /* no action */ + break; + case RX_MGMT_CFG80211_DEAUTH: cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); + break; + case RX_MGMT_CFG80211_DISASSOC: + cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); + break; + case RX_MGMT_CFG80211_RX_AUTH: + cfg80211_send_rx_auth(sdata->dev, (u8 *)mgmt, skb->len); + break; + case RX_MGMT_CFG80211_RX_ASSOC: + cfg80211_send_rx_assoc(sdata->dev, bss, (u8 *)mgmt, skb->len); + break; + case RX_MGMT_CFG80211_ASSOC_TIMEOUT: + cfg80211_send_assoc_timeout(sdata->dev, mgmt->bssid); + break; + default: + WARN(1, "unexpected: %d", rma); } } @@ -2166,14 +2702,160 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, mutex_lock(&ifmgd->mtx); } +static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_mgd_auth_data *auth_data = ifmgd->auth_data; + + lockdep_assert_held(&ifmgd->mtx); + + if (WARN_ON_ONCE(!auth_data)) + return -EINVAL; + + if (!auth_data->synced) { + int ret = drv_tx_sync(local, sdata, auth_data->bss->bssid, + IEEE80211_TX_SYNC_AUTH); + if (ret) + return ret; + } + auth_data->synced = true; + + auth_data->tries++; + + if (auth_data->tries > IEEE80211_AUTH_MAX_TRIES) { + printk(KERN_DEBUG "%s: authentication with %pM timed out\n", + sdata->name, auth_data->bss->bssid); + + /* + * Most likely AP is not in the range so remove the + * bss struct for that AP. + */ + cfg80211_unlink_bss(local->hw.wiphy, auth_data->bss); + + return -ETIMEDOUT; + } + + if (auth_data->bss->proberesp_ies) { + printk(KERN_DEBUG "%s: send auth to %pM (try %d/%d)\n", + sdata->name, auth_data->bss->bssid, auth_data->tries, + IEEE80211_AUTH_MAX_TRIES); + + auth_data->expected_transaction = 2; + ieee80211_send_auth(sdata, 1, auth_data->algorithm, + auth_data->ie, auth_data->ie_len, + auth_data->bss->bssid, + auth_data->bss->bssid, NULL, 0, 0); + } else { + const u8 *ssidie; + + printk(KERN_DEBUG "%s: direct probe to %pM (try %d/%i)\n", + sdata->name, auth_data->bss->bssid, auth_data->tries, + IEEE80211_AUTH_MAX_TRIES); + + ssidie = ieee80211_bss_get_ie(auth_data->bss, WLAN_EID_SSID); + if (!ssidie) + return -EINVAL; + /* + * Direct probe is sent to broadcast address as some APs + * will not answer to direct packet in unassociated state. + */ + ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1], + NULL, 0, (u32) -1, true, false); + } + + auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; + run_again(ifmgd, auth_data->timeout); + + return 0; +} + +static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; + struct ieee80211_local *local = sdata->local; + + lockdep_assert_held(&sdata->u.mgd.mtx); + + if (!assoc_data->synced) { + int ret = drv_tx_sync(local, sdata, assoc_data->bss->bssid, + IEEE80211_TX_SYNC_ASSOC); + if (ret) + return ret; + } + assoc_data->synced = true; + + assoc_data->tries++; + if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) { + printk(KERN_DEBUG "%s: association with %pM timed out\n", + sdata->name, assoc_data->bss->bssid); + + /* + * Most likely AP is not in the range so remove the + * bss struct for that AP. + */ + cfg80211_unlink_bss(local->hw.wiphy, assoc_data->bss); + + return -ETIMEDOUT; + } + + printk(KERN_DEBUG "%s: associate with %pM (try %d/%d)\n", + sdata->name, assoc_data->bss->bssid, assoc_data->tries, + IEEE80211_ASSOC_MAX_TRIES); + ieee80211_send_assoc(sdata); + + assoc_data->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; + run_again(&sdata->u.mgd, assoc_data->timeout); + + return 0; +} + void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - /* then process the rest of the work */ mutex_lock(&ifmgd->mtx); + if (ifmgd->auth_data && + time_after(jiffies, ifmgd->auth_data->timeout)) { + if (ifmgd->auth_data->done) { + /* + * ok ... we waited for assoc but userspace didn't, + * so let's just kill the auth data + */ + ieee80211_destroy_auth_data(sdata, false); + } else if (ieee80211_probe_auth(sdata)) { + u8 bssid[ETH_ALEN]; + + memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); + + ieee80211_destroy_auth_data(sdata, false); + + mutex_unlock(&ifmgd->mtx); + cfg80211_send_auth_timeout(sdata->dev, bssid); + mutex_lock(&ifmgd->mtx); + } + } else if (ifmgd->auth_data) + run_again(ifmgd, ifmgd->auth_data->timeout); + + if (ifmgd->assoc_data && + time_after(jiffies, ifmgd->assoc_data->timeout)) { + if (!ifmgd->assoc_data->have_beacon || + ieee80211_do_assoc(sdata)) { + u8 bssid[ETH_ALEN]; + + memcpy(bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN); + + ieee80211_destroy_assoc_data(sdata, false); + + mutex_unlock(&ifmgd->mtx); + cfg80211_send_assoc_timeout(sdata->dev, bssid); + mutex_lock(&ifmgd->mtx); + } + } else if (ifmgd->assoc_data) + run_again(ifmgd, ifmgd->assoc_data->timeout); + if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL | IEEE80211_STA_CONNECTION_POLL) && ifmgd->associated) { @@ -2249,6 +2931,10 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) } mutex_unlock(&ifmgd->mtx); + + mutex_lock(&local->mtx); + ieee80211_recalc_idle(local); + mutex_unlock(&local->mtx); } static void ieee80211_sta_bcn_mon_timer(unsigned long data) @@ -2421,50 +3107,24 @@ int ieee80211_max_network_latency(struct notifier_block *nb, } /* config hooks */ -static enum work_done_result -ieee80211_probe_auth_done(struct ieee80211_work *wk, - struct sk_buff *skb) -{ - struct ieee80211_local *local = wk->sdata->local; - - if (!skb) { - cfg80211_send_auth_timeout(wk->sdata->dev, wk->filter_ta); - goto destroy; - } - - if (wk->type == IEEE80211_WORK_AUTH) { - cfg80211_send_rx_auth(wk->sdata->dev, skb->data, skb->len); - goto destroy; - } - - mutex_lock(&wk->sdata->u.mgd.mtx); - ieee80211_rx_mgmt_probe_resp(wk->sdata, skb); - mutex_unlock(&wk->sdata->u.mgd.mtx); - - wk->type = IEEE80211_WORK_AUTH; - wk->probe_auth.tries = 0; - return WORK_DONE_REQUEUE; - destroy: - if (wk->probe_auth.synced) - drv_finish_tx_sync(local, wk->sdata, wk->filter_ta, - IEEE80211_TX_SYNC_AUTH); - - return WORK_DONE_DESTROY; -} - int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, struct cfg80211_auth_request *req) { - const u8 *ssid; - struct ieee80211_work *wk; + struct ieee80211_local *local = sdata->local; + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_mgd_auth_data *auth_data; + struct sta_info *sta; u16 auth_alg; + int err; + + /* prepare auth data structure */ switch (req->auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: auth_alg = WLAN_AUTH_OPEN; break; case NL80211_AUTHTYPE_SHARED_KEY: - if (IS_ERR(sdata->local->wep_tx_tfm)) + if (IS_ERR(local->wep_tx_tfm)) return -EOPNOTSUPP; auth_alg = WLAN_AUTH_SHARED_KEY; break; @@ -2478,169 +3138,142 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, return -EOPNOTSUPP; } - wk = kzalloc(sizeof(*wk) + req->ie_len, GFP_KERNEL); - if (!wk) + auth_data = kzalloc(sizeof(*auth_data) + req->ie_len, GFP_KERNEL); + if (!auth_data) return -ENOMEM; - memcpy(wk->filter_ta, req->bss->bssid, ETH_ALEN); + auth_data->bss = req->bss; if (req->ie && req->ie_len) { - memcpy(wk->ie, req->ie, req->ie_len); - wk->ie_len = req->ie_len; + memcpy(auth_data->ie, req->ie, req->ie_len); + auth_data->ie_len = req->ie_len; } if (req->key && req->key_len) { - wk->probe_auth.key_len = req->key_len; - wk->probe_auth.key_idx = req->key_idx; - memcpy(wk->probe_auth.key, req->key, req->key_len); + auth_data->key_len = req->key_len; + auth_data->key_idx = req->key_idx; + memcpy(auth_data->key, req->key, req->key_len); } - ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); - memcpy(wk->probe_auth.ssid, ssid + 2, ssid[1]); - wk->probe_auth.ssid_len = ssid[1]; - - wk->probe_auth.algorithm = auth_alg; - wk->probe_auth.privacy = req->bss->capability & WLAN_CAPABILITY_PRIVACY; - - /* if we already have a probe, don't probe again */ - if (req->bss->proberesp_ies) - wk->type = IEEE80211_WORK_AUTH; - else - wk->type = IEEE80211_WORK_DIRECT_PROBE; - wk->chan = req->bss->channel; - wk->chan_type = NL80211_CHAN_NO_HT; - wk->sdata = sdata; - wk->done = ieee80211_probe_auth_done; - - ieee80211_add_work(wk); - return 0; -} + auth_data->algorithm = auth_alg; -/* create and insert a dummy station entry */ -static int ieee80211_pre_assoc(struct ieee80211_sub_if_data *sdata, - u8 *bssid) { - struct sta_info *sta; - int err; + /* try to authenticate/probe */ - sta = sta_info_alloc(sdata, bssid, GFP_KERNEL); - if (!sta) - return -ENOMEM; + mutex_lock(&ifmgd->mtx); - err = sta_info_insert(sta); - sta = NULL; - if (err) { - printk(KERN_DEBUG "%s: failed to insert STA entry for" - " the AP (error %d)\n", sdata->name, err); - return err; + if ((ifmgd->auth_data && !ifmgd->auth_data->done) || + ifmgd->assoc_data) { + err = -EBUSY; + goto err_free; } - return 0; -} + if (ifmgd->auth_data) + ieee80211_destroy_auth_data(sdata, false); -static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, - struct sk_buff *skb) -{ - struct ieee80211_local *local = wk->sdata->local; - struct ieee80211_mgmt *mgmt; - struct ieee80211_rx_status *rx_status; - struct ieee802_11_elems elems; - struct cfg80211_bss *cbss = wk->assoc.bss; - u16 status; + /* prep auth_data so we don't go into idle on disassoc */ + ifmgd->auth_data = auth_data; - if (!skb) { - sta_info_destroy_addr(wk->sdata, cbss->bssid); - cfg80211_send_assoc_timeout(wk->sdata->dev, wk->filter_ta); - goto destroy; - } + if (ifmgd->associated) + ieee80211_set_disassoc(sdata, true, false); - if (wk->type == IEEE80211_WORK_ASSOC_BEACON_WAIT) { - mutex_lock(&wk->sdata->u.mgd.mtx); - rx_status = (void *) skb->cb; - ieee802_11_parse_elems(skb->data + 24 + 12, skb->len - 24 - 12, &elems); - ieee80211_rx_bss_info(wk->sdata, (void *)skb->data, skb->len, rx_status, - &elems, true); - mutex_unlock(&wk->sdata->u.mgd.mtx); + printk(KERN_DEBUG "%s: authenticate with %pM\n", + sdata->name, req->bss->bssid); - wk->type = IEEE80211_WORK_ASSOC; - /* not really done yet */ - return WORK_DONE_REQUEUE; - } + mutex_lock(&local->mtx); + ieee80211_recalc_idle(sdata->local); + mutex_unlock(&local->mtx); - mgmt = (void *)skb->data; - status = le16_to_cpu(mgmt->u.assoc_resp.status_code); + /* switch to the right channel */ + local->oper_channel = req->bss->channel; + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); - if (status == WLAN_STATUS_SUCCESS) { - if (wk->assoc.synced) - drv_finish_tx_sync(local, wk->sdata, wk->filter_ta, - IEEE80211_TX_SYNC_ASSOC); + /* set BSSID */ + memcpy(ifmgd->bssid, req->bss->bssid, ETH_ALEN); + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); - mutex_lock(&wk->sdata->u.mgd.mtx); - if (!ieee80211_assoc_success(wk, mgmt, skb->len)) { - mutex_unlock(&wk->sdata->u.mgd.mtx); - /* oops -- internal error -- send timeout for now */ - sta_info_destroy_addr(wk->sdata, cbss->bssid); - cfg80211_send_assoc_timeout(wk->sdata->dev, - wk->filter_ta); - return WORK_DONE_DESTROY; - } + /* add station entry */ + sta = sta_info_alloc(sdata, req->bss->bssid, GFP_KERNEL); + if (!sta) { + err = -ENOMEM; + goto err_clear; + } - mutex_unlock(&wk->sdata->u.mgd.mtx); - } else { - /* assoc failed - destroy the dummy station entry */ - sta_info_destroy_addr(wk->sdata, cbss->bssid); + err = sta_info_insert(sta); + if (err) { + printk(KERN_DEBUG + "%s: failed to insert STA entry for the AP %pM (error %d)\n", + sdata->name, req->bss->bssid, err); + goto err_clear; } - cfg80211_send_rx_assoc(wk->sdata->dev, cbss, skb->data, skb->len); - destroy: - if (wk->assoc.synced) - drv_finish_tx_sync(local, wk->sdata, wk->filter_ta, - IEEE80211_TX_SYNC_ASSOC); + err = ieee80211_probe_auth(sdata); + if (err) { + if (auth_data->synced) + drv_finish_tx_sync(local, sdata, req->bss->bssid, + IEEE80211_TX_SYNC_AUTH); + sta_info_destroy_addr(sdata, req->bss->bssid); + goto err_clear; + } + + /* hold our own reference */ + cfg80211_ref_bss(auth_data->bss); + err = 0; + goto out_unlock; + + err_clear: + ifmgd->auth_data = NULL; + err_free: + kfree(auth_data); + out_unlock: + mutex_unlock(&ifmgd->mtx); - return WORK_DONE_DESTROY; + return err; } int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, struct cfg80211_assoc_request *req) { + struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_bss *bss = (void *)req->bss->priv; - struct ieee80211_work *wk; - const u8 *ssid; + struct ieee80211_mgd_assoc_data *assoc_data; + struct sta_info *sta; + const u8 *ssidie; int i, err; + ssidie = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); + if (!ssidie) + return -EINVAL; + + assoc_data = kzalloc(sizeof(*assoc_data) + req->ie_len, GFP_KERNEL); + if (!assoc_data) + return -ENOMEM; + mutex_lock(&ifmgd->mtx); - if (ifmgd->associated) { - if (!req->prev_bssid || - memcmp(req->prev_bssid, ifmgd->associated->bssid, - ETH_ALEN)) { - /* - * We are already associated and the request was not a - * reassociation request from the current BSS, so - * reject it. - */ - mutex_unlock(&ifmgd->mtx); - return -EALREADY; - } - /* Trying to reassociate - clear previous association state */ + if (ifmgd->associated) ieee80211_set_disassoc(sdata, true, false); + + if (ifmgd->auth_data && !ifmgd->auth_data->done) { + err = -EBUSY; + goto err_free; } - mutex_unlock(&ifmgd->mtx); - wk = kzalloc(sizeof(*wk) + req->ie_len, GFP_KERNEL); - if (!wk) - return -ENOMEM; + if (ifmgd->assoc_data) { + err = -EBUSY; + goto err_free; + } - /* - * create a dummy station info entry in order - * to start accepting incoming EAPOL packets from the station - */ - err = ieee80211_pre_assoc(sdata, req->bss->bssid); - if (err) { - kfree(wk); - return err; + if (ifmgd->auth_data) { + bool match; + + /* keep sta info, bssid if matching */ + match = memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN) == 0; + ieee80211_destroy_auth_data(sdata, match); } + /* prepare assoc data */ + ifmgd->flags &= ~IEEE80211_STA_DISABLE_11N; ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; @@ -2652,7 +3285,6 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP104) ifmgd->flags |= IEEE80211_STA_DISABLE_11N; - if (req->flags & ASSOC_REQ_DISABLE_HT) ifmgd->flags |= IEEE80211_STA_DISABLE_11N; @@ -2661,16 +3293,12 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, sizeof(ifmgd->ht_capa_mask)); if (req->ie && req->ie_len) { - memcpy(wk->ie, req->ie, req->ie_len); - wk->ie_len = req->ie_len; - } else - wk->ie_len = 0; - - wk->assoc.bss = req->bss; + memcpy(assoc_data->ie, req->ie, req->ie_len); + assoc_data->ie_len = req->ie_len; + } - memcpy(wk->filter_ta, req->bss->bssid, ETH_ALEN); + assoc_data->bss = req->bss; - /* new association always uses requested smps mode */ if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { if (ifmgd->powersave) ifmgd->ap_smps = IEEE80211_SMPS_DYNAMIC; @@ -2679,7 +3307,6 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, } else ifmgd->ap_smps = ifmgd->req_smps; - wk->assoc.smps = ifmgd->ap_smps; /* * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode. * We still associate in non-HT mode (11a/b/g) if any one of these @@ -2687,39 +3314,27 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, * We can set this to true for non-11n hardware, that'll be checked * separately along with the peer capabilities. */ - wk->assoc.use_11n = !(ifmgd->flags & IEEE80211_STA_DISABLE_11N); - wk->assoc.capability = req->bss->capability; - wk->assoc.wmm_used = bss->wmm_used; - wk->assoc.supp_rates = bss->supp_rates; - wk->assoc.supp_rates_len = bss->supp_rates_len; - wk->assoc.ht_information_ie = + assoc_data->capability = req->bss->capability; + assoc_data->wmm_used = bss->wmm_used; + assoc_data->supp_rates = bss->supp_rates; + assoc_data->supp_rates_len = bss->supp_rates_len; + assoc_data->ht_information_ie = ieee80211_bss_get_ie(req->bss, WLAN_EID_HT_INFORMATION); if (bss->wmm_used && bss->uapsd_supported && (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)) { - wk->assoc.uapsd_used = true; + assoc_data->uapsd_used = true; ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; } else { - wk->assoc.uapsd_used = false; + assoc_data->uapsd_used = false; ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED; } - ssid = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID); - memcpy(wk->assoc.ssid, ssid + 2, ssid[1]); - wk->assoc.ssid_len = ssid[1]; + memcpy(assoc_data->ssid, ssidie + 2, ssidie[1]); + assoc_data->ssid_len = ssidie[1]; if (req->prev_bssid) - memcpy(wk->assoc.prev_bssid, req->prev_bssid, ETH_ALEN); - - wk->chan = req->bss->channel; - wk->chan_type = NL80211_CHAN_NO_HT; - wk->sdata = sdata; - wk->done = ieee80211_assoc_done; - if (!bss->dtim_period && - sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) - wk->type = IEEE80211_WORK_ASSOC_BEACON_WAIT; - else - wk->type = IEEE80211_WORK_ASSOC; + memcpy(assoc_data->prev_bssid, req->prev_bssid, ETH_ALEN); if (req->use_mfp) { ifmgd->mfp = IEEE80211_MFP_REQUIRED; @@ -2737,15 +3352,79 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, sdata->control_port_protocol = req->crypto.control_port_ethertype; sdata->control_port_no_encrypt = req->crypto.control_port_no_encrypt; - ieee80211_add_work(wk); - return 0; + /* kick off associate process */ + + ifmgd->assoc_data = assoc_data; + + mutex_lock(&local->mtx); + ieee80211_recalc_idle(sdata->local); + mutex_unlock(&local->mtx); + + /* switch to the right channel */ + local->oper_channel = req->bss->channel; + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); + + rcu_read_lock(); + sta = sta_info_get(sdata, req->bss->bssid); + rcu_read_unlock(); + + if (!sta) { + /* set BSSID */ + memcpy(ifmgd->bssid, req->bss->bssid, ETH_ALEN); + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); + + sta = sta_info_alloc(sdata, req->bss->bssid, GFP_KERNEL); + if (!sta) { + err = -ENOMEM; + goto err_clear; + } + + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); + + err = sta_info_insert(sta); + sta = NULL; + if (err) { + printk(KERN_DEBUG + "%s: failed to insert STA entry for the AP (error %d)\n", + sdata->name, err); + goto err_clear; + } + } else + WARN_ON_ONCE(memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN)); + + if (!bss->dtim_period && + sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) { + /* + * Wait up to one beacon interval ... + * should this be more if we miss one? + */ + printk(KERN_DEBUG "%s: waiting for beacon from %pM\n", + sdata->name, ifmgd->bssid); + assoc_data->timeout = jiffies + + TU_TO_EXP_TIME(req->bss->beacon_interval); + } else { + assoc_data->have_beacon = true; + assoc_data->sent_assoc = false; + assoc_data->timeout = jiffies; + } + run_again(ifmgd, assoc_data->timeout); + + err = 0; + goto out; + err_clear: + ifmgd->assoc_data = NULL; + err_free: + kfree(assoc_data); + out: + mutex_unlock(&ifmgd->mtx); + + return err; } int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, struct cfg80211_deauth_request *req, void *cookie) { - struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; bool assoc_bss = false; @@ -2754,62 +3433,13 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, if (ifmgd->associated && memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) { ieee80211_set_disassoc(sdata, false, true); - mutex_unlock(&ifmgd->mtx); assoc_bss = true; - } else { - bool not_auth_yet = false; - struct ieee80211_work *tmp, *wk = NULL; - + } else if (ifmgd->auth_data) { + ieee80211_destroy_auth_data(sdata, false); mutex_unlock(&ifmgd->mtx); - - mutex_lock(&local->mtx); - list_for_each_entry(tmp, &local->work_list, list) { - if (tmp->sdata != sdata) - continue; - - if (tmp->type != IEEE80211_WORK_DIRECT_PROBE && - tmp->type != IEEE80211_WORK_AUTH && - tmp->type != IEEE80211_WORK_ASSOC && - tmp->type != IEEE80211_WORK_ASSOC_BEACON_WAIT) - continue; - - if (memcmp(req->bssid, tmp->filter_ta, ETH_ALEN)) - continue; - - not_auth_yet = tmp->type == IEEE80211_WORK_DIRECT_PROBE; - list_del_rcu(&tmp->list); - synchronize_rcu(); - wk = tmp; - break; - } - mutex_unlock(&local->mtx); - - if (wk && wk->type == IEEE80211_WORK_ASSOC) { - /* clean up dummy sta & TX sync */ - sta_info_destroy_addr(wk->sdata, wk->filter_ta); - if (wk->assoc.synced) - drv_finish_tx_sync(local, wk->sdata, - wk->filter_ta, - IEEE80211_TX_SYNC_ASSOC); - } else if (wk && wk->type == IEEE80211_WORK_AUTH) { - if (wk->probe_auth.synced) - drv_finish_tx_sync(local, wk->sdata, - wk->filter_ta, - IEEE80211_TX_SYNC_AUTH); - } - kfree(wk); - - /* - * If somebody requests authentication and we haven't - * sent out an auth frame yet there's no need to send - * out a deauth frame either. If the state was PROBE, - * then this is the case. If it's AUTH we have sent a - * frame, and if it's IDLE we have completed the auth - * process already. - */ - if (not_auth_yet) - return 0; + return 0; } + mutex_unlock(&ifmgd->mtx); printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n", sdata->name, req->bssid, req->reason_code); diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 8d6fa674f53e..2b5b1194dfc2 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2484,14 +2484,9 @@ static ieee80211_rx_result debug_noinline ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) { struct ieee80211_sub_if_data *sdata = rx->sdata; - ieee80211_rx_result rxs; struct ieee80211_mgmt *mgmt = (void *)rx->skb->data; __le16 stype; - rxs = ieee80211_work_rx_mgmt(rx->sdata, rx->skb); - if (rxs != RX_CONTINUE) - return rxs; - stype = mgmt->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); if (!ieee80211_vif_is_mesh(&sdata->vif) && @@ -2500,10 +2495,13 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) return RX_DROP_MONITOR; switch (stype) { + case cpu_to_le16(IEEE80211_STYPE_AUTH): case cpu_to_le16(IEEE80211_STYPE_BEACON): case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): /* process for all: mesh, mlme, ibss */ break; + case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): + case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): case cpu_to_le16(IEEE80211_STYPE_DEAUTH): case cpu_to_le16(IEEE80211_STYPE_DISASSOC): if (is_multicast_ether_addr(mgmt->da) && @@ -2515,7 +2513,6 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) return RX_DROP_MONITOR; break; case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): - case cpu_to_le16(IEEE80211_STYPE_AUTH): /* process only for ibss */ if (sdata->vif.type != NL80211_IFTYPE_ADHOC) return RX_DROP_MONITOR; diff --git a/net/mac80211/work.c b/net/mac80211/work.c index 0a1a176fbe91..c6e230efa049 100644 --- a/net/mac80211/work.c +++ b/net/mac80211/work.c @@ -27,16 +27,9 @@ #include "rate.h" #include "driver-ops.h" -#define IEEE80211_AUTH_TIMEOUT (HZ / 5) -#define IEEE80211_AUTH_MAX_TRIES 3 -#define IEEE80211_ASSOC_TIMEOUT (HZ / 5) -#define IEEE80211_ASSOC_MAX_TRIES 3 - enum work_action { - WORK_ACT_MISMATCH, WORK_ACT_NONE, WORK_ACT_TIMEOUT, - WORK_ACT_DONE, }; @@ -71,465 +64,6 @@ void free_work(struct ieee80211_work *wk) kfree_rcu(wk, rcu_head); } -static int ieee80211_compatible_rates(const u8 *supp_rates, int supp_rates_len, - struct ieee80211_supported_band *sband, - u32 *rates) -{ - int i, j, count; - *rates = 0; - count = 0; - for (i = 0; i < supp_rates_len; i++) { - int rate = (supp_rates[i] & 0x7F) * 5; - - for (j = 0; j < sband->n_bitrates; j++) - if (sband->bitrates[j].bitrate == rate) { - *rates |= BIT(j); - count++; - break; - } - } - - return count; -} - -/* frame sending functions */ - -static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata, - struct sk_buff *skb, const u8 *ht_info_ie, - struct ieee80211_supported_band *sband, - struct ieee80211_channel *channel, - enum ieee80211_smps_mode smps) -{ - struct ieee80211_ht_info *ht_info; - u8 *pos; - u32 flags = channel->flags; - u16 cap; - struct ieee80211_sta_ht_cap ht_cap; - - BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap)); - - if (!sband->ht_cap.ht_supported) - return; - - if (!ht_info_ie) - return; - - if (ht_info_ie[1] < sizeof(struct ieee80211_ht_info)) - return; - - memcpy(&ht_cap, &sband->ht_cap, sizeof(ht_cap)); - ieee80211_apply_htcap_overrides(sdata, &ht_cap); - - ht_info = (struct ieee80211_ht_info *)(ht_info_ie + 2); - - /* determine capability flags */ - cap = ht_cap.cap; - - switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { - case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: - if (flags & IEEE80211_CHAN_NO_HT40PLUS) { - cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; - cap &= ~IEEE80211_HT_CAP_SGI_40; - } - break; - case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - if (flags & IEEE80211_CHAN_NO_HT40MINUS) { - cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; - cap &= ~IEEE80211_HT_CAP_SGI_40; - } - break; - } - - /* set SM PS mode properly */ - cap &= ~IEEE80211_HT_CAP_SM_PS; - switch (smps) { - case IEEE80211_SMPS_AUTOMATIC: - case IEEE80211_SMPS_NUM_MODES: - WARN_ON(1); - case IEEE80211_SMPS_OFF: - cap |= WLAN_HT_CAP_SM_PS_DISABLED << - IEEE80211_HT_CAP_SM_PS_SHIFT; - break; - case IEEE80211_SMPS_STATIC: - cap |= WLAN_HT_CAP_SM_PS_STATIC << - IEEE80211_HT_CAP_SM_PS_SHIFT; - break; - case IEEE80211_SMPS_DYNAMIC: - cap |= WLAN_HT_CAP_SM_PS_DYNAMIC << - IEEE80211_HT_CAP_SM_PS_SHIFT; - break; - } - - /* reserve and fill IE */ - pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2); - ieee80211_ie_build_ht_cap(pos, &ht_cap, cap); -} - -static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, - struct ieee80211_work *wk) -{ - struct ieee80211_local *local = sdata->local; - struct sk_buff *skb; - struct ieee80211_mgmt *mgmt; - u8 *pos, qos_info; - size_t offset = 0, noffset; - int i, count, rates_len, supp_rates_len; - u16 capab; - struct ieee80211_supported_band *sband; - u32 rates = 0; - - sband = local->hw.wiphy->bands[wk->chan->band]; - - if (wk->assoc.supp_rates_len) { - /* - * Get all rates supported by the device and the AP as - * some APs don't like getting a superset of their rates - * in the association request (e.g. D-Link DAP 1353 in - * b-only mode)... - */ - rates_len = ieee80211_compatible_rates(wk->assoc.supp_rates, - wk->assoc.supp_rates_len, - sband, &rates); - } else { - /* - * In case AP not provide any supported rates information - * before association, we send information element(s) with - * all rates that we support. - */ - rates = ~0; - rates_len = sband->n_bitrates; - } - - skb = alloc_skb(local->hw.extra_tx_headroom + - sizeof(*mgmt) + /* bit too much but doesn't matter */ - 2 + wk->assoc.ssid_len + /* SSID */ - 4 + rates_len + /* (extended) rates */ - 4 + /* power capability */ - 2 + 2 * sband->n_channels + /* supported channels */ - 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ - wk->ie_len + /* extra IEs */ - 9, /* WMM */ - GFP_KERNEL); - if (!skb) - return; - - skb_reserve(skb, local->hw.extra_tx_headroom); - - capab = WLAN_CAPABILITY_ESS; - - if (sband->band == IEEE80211_BAND_2GHZ) { - if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) - capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; - if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) - capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; - } - - if (wk->assoc.capability & WLAN_CAPABILITY_PRIVACY) - capab |= WLAN_CAPABILITY_PRIVACY; - - if ((wk->assoc.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) && - (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)) - capab |= WLAN_CAPABILITY_SPECTRUM_MGMT; - - mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); - memset(mgmt, 0, 24); - memcpy(mgmt->da, wk->filter_ta, ETH_ALEN); - memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); - memcpy(mgmt->bssid, wk->filter_ta, ETH_ALEN); - - if (!is_zero_ether_addr(wk->assoc.prev_bssid)) { - skb_put(skb, 10); - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | - IEEE80211_STYPE_REASSOC_REQ); - mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); - mgmt->u.reassoc_req.listen_interval = - cpu_to_le16(local->hw.conf.listen_interval); - memcpy(mgmt->u.reassoc_req.current_ap, wk->assoc.prev_bssid, - ETH_ALEN); - } else { - skb_put(skb, 4); - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | - IEEE80211_STYPE_ASSOC_REQ); - mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); - mgmt->u.assoc_req.listen_interval = - cpu_to_le16(local->hw.conf.listen_interval); - } - - /* SSID */ - pos = skb_put(skb, 2 + wk->assoc.ssid_len); - *pos++ = WLAN_EID_SSID; - *pos++ = wk->assoc.ssid_len; - memcpy(pos, wk->assoc.ssid, wk->assoc.ssid_len); - - /* add all rates which were marked to be used above */ - supp_rates_len = rates_len; - if (supp_rates_len > 8) - supp_rates_len = 8; - - pos = skb_put(skb, supp_rates_len + 2); - *pos++ = WLAN_EID_SUPP_RATES; - *pos++ = supp_rates_len; - - count = 0; - for (i = 0; i < sband->n_bitrates; i++) { - if (BIT(i) & rates) { - int rate = sband->bitrates[i].bitrate; - *pos++ = (u8) (rate / 5); - if (++count == 8) - break; - } - } - - if (rates_len > count) { - pos = skb_put(skb, rates_len - count + 2); - *pos++ = WLAN_EID_EXT_SUPP_RATES; - *pos++ = rates_len - count; - - for (i++; i < sband->n_bitrates; i++) { - if (BIT(i) & rates) { - int rate = sband->bitrates[i].bitrate; - *pos++ = (u8) (rate / 5); - } - } - } - - if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) { - /* 1. power capabilities */ - pos = skb_put(skb, 4); - *pos++ = WLAN_EID_PWR_CAPABILITY; - *pos++ = 2; - *pos++ = 0; /* min tx power */ - *pos++ = wk->chan->max_power; /* max tx power */ - - /* 2. supported channels */ - /* TODO: get this in reg domain format */ - pos = skb_put(skb, 2 * sband->n_channels + 2); - *pos++ = WLAN_EID_SUPPORTED_CHANNELS; - *pos++ = 2 * sband->n_channels; - for (i = 0; i < sband->n_channels; i++) { - *pos++ = ieee80211_frequency_to_channel( - sband->channels[i].center_freq); - *pos++ = 1; /* one channel in the subband*/ - } - } - - /* if present, add any custom IEs that go before HT */ - if (wk->ie_len && wk->ie) { - static const u8 before_ht[] = { - WLAN_EID_SSID, - WLAN_EID_SUPP_RATES, - WLAN_EID_EXT_SUPP_RATES, - WLAN_EID_PWR_CAPABILITY, - WLAN_EID_SUPPORTED_CHANNELS, - WLAN_EID_RSN, - WLAN_EID_QOS_CAPA, - WLAN_EID_RRM_ENABLED_CAPABILITIES, - WLAN_EID_MOBILITY_DOMAIN, - WLAN_EID_SUPPORTED_REGULATORY_CLASSES, - }; - noffset = ieee80211_ie_split(wk->ie, wk->ie_len, - before_ht, ARRAY_SIZE(before_ht), - offset); - pos = skb_put(skb, noffset - offset); - memcpy(pos, wk->ie + offset, noffset - offset); - offset = noffset; - } - - if (wk->assoc.use_11n && wk->assoc.wmm_used && - local->hw.queues >= 4) - ieee80211_add_ht_ie(sdata, skb, wk->assoc.ht_information_ie, - sband, wk->chan, wk->assoc.smps); - - /* if present, add any custom non-vendor IEs that go after HT */ - if (wk->ie_len && wk->ie) { - noffset = ieee80211_ie_split_vendor(wk->ie, wk->ie_len, - offset); - pos = skb_put(skb, noffset - offset); - memcpy(pos, wk->ie + offset, noffset - offset); - offset = noffset; - } - - if (wk->assoc.wmm_used && local->hw.queues >= 4) { - if (wk->assoc.uapsd_used) { - qos_info = local->uapsd_queues; - qos_info |= (local->uapsd_max_sp_len << - IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); - } else { - qos_info = 0; - } - - pos = skb_put(skb, 9); - *pos++ = WLAN_EID_VENDOR_SPECIFIC; - *pos++ = 7; /* len */ - *pos++ = 0x00; /* Microsoft OUI 00:50:F2 */ - *pos++ = 0x50; - *pos++ = 0xf2; - *pos++ = 2; /* WME */ - *pos++ = 0; /* WME info */ - *pos++ = 1; /* WME ver */ - *pos++ = qos_info; - } - - /* add any remaining custom (i.e. vendor specific here) IEs */ - if (wk->ie_len && wk->ie) { - noffset = wk->ie_len; - pos = skb_put(skb, noffset - offset); - memcpy(pos, wk->ie + offset, noffset - offset); - } - - IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; - ieee80211_tx_skb(sdata, skb); -} - -static void ieee80211_remove_auth_bss(struct ieee80211_local *local, - struct ieee80211_work *wk) -{ - struct cfg80211_bss *cbss; - u16 capa_val = WLAN_CAPABILITY_ESS; - - if (wk->probe_auth.privacy) - capa_val |= WLAN_CAPABILITY_PRIVACY; - - cbss = cfg80211_get_bss(local->hw.wiphy, wk->chan, wk->filter_ta, - wk->probe_auth.ssid, wk->probe_auth.ssid_len, - WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_PRIVACY, - capa_val); - if (!cbss) - return; - - cfg80211_unlink_bss(local->hw.wiphy, cbss); - cfg80211_put_bss(cbss); -} - -static enum work_action __must_check -ieee80211_direct_probe(struct ieee80211_work *wk) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - struct ieee80211_local *local = sdata->local; - - if (!wk->probe_auth.synced) { - int ret = drv_tx_sync(local, sdata, wk->filter_ta, - IEEE80211_TX_SYNC_AUTH); - if (ret) - return WORK_ACT_TIMEOUT; - } - wk->probe_auth.synced = true; - - wk->probe_auth.tries++; - if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { - printk(KERN_DEBUG "%s: direct probe to %pM timed out\n", - sdata->name, wk->filter_ta); - - /* - * Most likely AP is not in the range so remove the - * bss struct for that AP. - */ - ieee80211_remove_auth_bss(local, wk); - - return WORK_ACT_TIMEOUT; - } - - printk(KERN_DEBUG "%s: direct probe to %pM (try %d/%i)\n", - sdata->name, wk->filter_ta, wk->probe_auth.tries, - IEEE80211_AUTH_MAX_TRIES); - - /* - * Direct probe is sent to broadcast address as some APs - * will not answer to direct packet in unassociated state. - */ - ieee80211_send_probe_req(sdata, NULL, wk->probe_auth.ssid, - wk->probe_auth.ssid_len, NULL, 0, - (u32) -1, true, false); - - wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; - run_again(local, wk->timeout); - - return WORK_ACT_NONE; -} - - -static enum work_action __must_check -ieee80211_authenticate(struct ieee80211_work *wk) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - struct ieee80211_local *local = sdata->local; - - if (!wk->probe_auth.synced) { - int ret = drv_tx_sync(local, sdata, wk->filter_ta, - IEEE80211_TX_SYNC_AUTH); - if (ret) - return WORK_ACT_TIMEOUT; - } - wk->probe_auth.synced = true; - - wk->probe_auth.tries++; - if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { - printk(KERN_DEBUG "%s: authentication with %pM" - " timed out\n", sdata->name, wk->filter_ta); - - /* - * Most likely AP is not in the range so remove the - * bss struct for that AP. - */ - ieee80211_remove_auth_bss(local, wk); - - return WORK_ACT_TIMEOUT; - } - - printk(KERN_DEBUG "%s: authenticate with %pM (try %d)\n", - sdata->name, wk->filter_ta, wk->probe_auth.tries); - - ieee80211_send_auth(sdata, 1, wk->probe_auth.algorithm, wk->ie, - wk->ie_len, wk->filter_ta, wk->filter_ta, NULL, 0, - 0); - wk->probe_auth.transaction = 2; - - wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; - run_again(local, wk->timeout); - - return WORK_ACT_NONE; -} - -static enum work_action __must_check -ieee80211_associate(struct ieee80211_work *wk) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - struct ieee80211_local *local = sdata->local; - - if (!wk->assoc.synced) { - int ret = drv_tx_sync(local, sdata, wk->filter_ta, - IEEE80211_TX_SYNC_ASSOC); - if (ret) - return WORK_ACT_TIMEOUT; - } - wk->assoc.synced = true; - - wk->assoc.tries++; - if (wk->assoc.tries > IEEE80211_ASSOC_MAX_TRIES) { - printk(KERN_DEBUG "%s: association with %pM" - " timed out\n", - sdata->name, wk->filter_ta); - - /* - * Most likely AP is not in the range so remove the - * bss struct for that AP. - */ - if (wk->assoc.bss) - cfg80211_unlink_bss(local->hw.wiphy, wk->assoc.bss); - - return WORK_ACT_TIMEOUT; - } - - printk(KERN_DEBUG "%s: associate with %pM (try %d)\n", - sdata->name, wk->filter_ta, wk->assoc.tries); - ieee80211_send_assoc(sdata, wk); - - wk->timeout = jiffies + IEEE80211_ASSOC_TIMEOUT; - run_again(local, wk->timeout); - - return WORK_ACT_NONE; -} - static enum work_action __must_check ieee80211_remain_on_channel_timeout(struct ieee80211_work *wk) { @@ -569,300 +103,6 @@ ieee80211_offchannel_tx(struct ieee80211_work *wk) return WORK_ACT_TIMEOUT; } -static enum work_action __must_check -ieee80211_assoc_beacon_wait(struct ieee80211_work *wk) -{ - if (wk->started) - return WORK_ACT_TIMEOUT; - - /* - * Wait up to one beacon interval ... - * should this be more if we miss one? - */ - printk(KERN_DEBUG "%s: waiting for beacon from %pM\n", - wk->sdata->name, wk->filter_ta); - wk->timeout = TU_TO_EXP_TIME(wk->assoc.bss->beacon_interval); - return WORK_ACT_NONE; -} - -static void ieee80211_auth_challenge(struct ieee80211_work *wk, - struct ieee80211_mgmt *mgmt, - size_t len) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - u8 *pos; - struct ieee802_11_elems elems; - - pos = mgmt->u.auth.variable; - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); - if (!elems.challenge) - return; - ieee80211_send_auth(sdata, 3, wk->probe_auth.algorithm, - elems.challenge - 2, elems.challenge_len + 2, - wk->filter_ta, wk->filter_ta, wk->probe_auth.key, - wk->probe_auth.key_len, wk->probe_auth.key_idx); - wk->probe_auth.transaction = 4; -} - -static enum work_action __must_check -ieee80211_rx_mgmt_auth(struct ieee80211_work *wk, - struct ieee80211_mgmt *mgmt, size_t len) -{ - u16 auth_alg, auth_transaction, status_code; - - if (wk->type != IEEE80211_WORK_AUTH) - return WORK_ACT_MISMATCH; - - if (len < 24 + 6) - return WORK_ACT_NONE; - - auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); - auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); - status_code = le16_to_cpu(mgmt->u.auth.status_code); - - if (auth_alg != wk->probe_auth.algorithm || - auth_transaction != wk->probe_auth.transaction) - return WORK_ACT_NONE; - - if (status_code != WLAN_STATUS_SUCCESS) { - printk(KERN_DEBUG "%s: %pM denied authentication (status %d)\n", - wk->sdata->name, mgmt->sa, status_code); - return WORK_ACT_DONE; - } - - switch (wk->probe_auth.algorithm) { - case WLAN_AUTH_OPEN: - case WLAN_AUTH_LEAP: - case WLAN_AUTH_FT: - break; - case WLAN_AUTH_SHARED_KEY: - if (wk->probe_auth.transaction != 4) { - ieee80211_auth_challenge(wk, mgmt, len); - /* need another frame */ - return WORK_ACT_NONE; - } - break; - default: - WARN_ON(1); - return WORK_ACT_NONE; - } - - printk(KERN_DEBUG "%s: authenticated\n", wk->sdata->name); - return WORK_ACT_DONE; -} - -static enum work_action __must_check -ieee80211_rx_mgmt_assoc_resp(struct ieee80211_work *wk, - struct ieee80211_mgmt *mgmt, size_t len, - bool reassoc) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - struct ieee80211_local *local = sdata->local; - u16 capab_info, status_code, aid; - struct ieee802_11_elems elems; - u8 *pos; - - if (wk->type != IEEE80211_WORK_ASSOC) - return WORK_ACT_MISMATCH; - - /* - * AssocResp and ReassocResp have identical structure, so process both - * of them in this function. - */ - - if (len < 24 + 6) - return WORK_ACT_NONE; - - capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); - status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); - aid = le16_to_cpu(mgmt->u.assoc_resp.aid); - - printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x " - "status=%d aid=%d)\n", - sdata->name, reassoc ? "Rea" : "A", mgmt->sa, - capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); - - pos = mgmt->u.assoc_resp.variable; - ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); - - if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && - elems.timeout_int && elems.timeout_int_len == 5 && - elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { - u32 tu, ms; - tu = get_unaligned_le32(elems.timeout_int + 1); - ms = tu * 1024 / 1000; - printk(KERN_DEBUG "%s: %pM rejected association temporarily; " - "comeback duration %u TU (%u ms)\n", - sdata->name, mgmt->sa, tu, ms); - wk->timeout = jiffies + msecs_to_jiffies(ms); - if (ms > IEEE80211_ASSOC_TIMEOUT) - run_again(local, wk->timeout); - return WORK_ACT_NONE; - } - - if (status_code != WLAN_STATUS_SUCCESS) - printk(KERN_DEBUG "%s: %pM denied association (code=%d)\n", - sdata->name, mgmt->sa, status_code); - else - printk(KERN_DEBUG "%s: associated\n", sdata->name); - - return WORK_ACT_DONE; -} - -static enum work_action __must_check -ieee80211_rx_mgmt_probe_resp(struct ieee80211_work *wk, - struct ieee80211_mgmt *mgmt, size_t len, - struct ieee80211_rx_status *rx_status) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - struct ieee80211_local *local = sdata->local; - size_t baselen; - - ASSERT_WORK_MTX(local); - - if (wk->type != IEEE80211_WORK_DIRECT_PROBE) - return WORK_ACT_MISMATCH; - - if (len < 24 + 12) - return WORK_ACT_NONE; - - baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; - if (baselen > len) - return WORK_ACT_NONE; - - printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); - return WORK_ACT_DONE; -} - -static enum work_action __must_check -ieee80211_rx_mgmt_beacon(struct ieee80211_work *wk, - struct ieee80211_mgmt *mgmt, size_t len) -{ - struct ieee80211_sub_if_data *sdata = wk->sdata; - struct ieee80211_local *local = sdata->local; - - ASSERT_WORK_MTX(local); - - if (wk->type != IEEE80211_WORK_ASSOC_BEACON_WAIT) - return WORK_ACT_MISMATCH; - - if (len < 24 + 12) - return WORK_ACT_NONE; - - printk(KERN_DEBUG "%s: beacon received\n", sdata->name); - return WORK_ACT_DONE; -} - -static void ieee80211_work_rx_queued_mgmt(struct ieee80211_local *local, - struct sk_buff *skb) -{ - struct ieee80211_rx_status *rx_status; - struct ieee80211_mgmt *mgmt; - struct ieee80211_work *wk; - enum work_action rma = WORK_ACT_NONE; - u16 fc; - - rx_status = (struct ieee80211_rx_status *) skb->cb; - mgmt = (struct ieee80211_mgmt *) skb->data; - fc = le16_to_cpu(mgmt->frame_control); - - mutex_lock(&local->mtx); - - list_for_each_entry(wk, &local->work_list, list) { - const u8 *bssid = NULL; - - switch (wk->type) { - case IEEE80211_WORK_DIRECT_PROBE: - case IEEE80211_WORK_AUTH: - case IEEE80211_WORK_ASSOC: - case IEEE80211_WORK_ASSOC_BEACON_WAIT: - bssid = wk->filter_ta; - break; - default: - continue; - } - - /* - * Before queuing, we already verified mgmt->sa, - * so this is needed just for matching. - */ - if (compare_ether_addr(bssid, mgmt->bssid)) - continue; - - switch (fc & IEEE80211_FCTL_STYPE) { - case IEEE80211_STYPE_BEACON: - rma = ieee80211_rx_mgmt_beacon(wk, mgmt, skb->len); - break; - case IEEE80211_STYPE_PROBE_RESP: - rma = ieee80211_rx_mgmt_probe_resp(wk, mgmt, skb->len, - rx_status); - break; - case IEEE80211_STYPE_AUTH: - rma = ieee80211_rx_mgmt_auth(wk, mgmt, skb->len); - break; - case IEEE80211_STYPE_ASSOC_RESP: - rma = ieee80211_rx_mgmt_assoc_resp(wk, mgmt, - skb->len, false); - break; - case IEEE80211_STYPE_REASSOC_RESP: - rma = ieee80211_rx_mgmt_assoc_resp(wk, mgmt, - skb->len, true); - break; - default: - WARN_ON(1); - rma = WORK_ACT_NONE; - } - - /* - * We've either received an unexpected frame, or we have - * multiple work items and need to match the frame to the - * right one. - */ - if (rma == WORK_ACT_MISMATCH) - continue; - - /* - * We've processed this frame for that work, so it can't - * belong to another work struct. - * NB: this is also required for correctness for 'rma'! - */ - break; - } - - switch (rma) { - case WORK_ACT_MISMATCH: - /* ignore this unmatched frame */ - break; - case WORK_ACT_NONE: - break; - case WORK_ACT_DONE: - list_del_rcu(&wk->list); - break; - default: - WARN(1, "unexpected: %d", rma); - } - - mutex_unlock(&local->mtx); - - if (rma != WORK_ACT_DONE) - goto out; - - switch (wk->done(wk, skb)) { - case WORK_DONE_DESTROY: - free_work(wk); - break; - case WORK_DONE_REQUEUE: - synchronize_rcu(); - wk->started = false; /* restart */ - mutex_lock(&local->mtx); - list_add_tail(&wk->list, &local->work_list); - mutex_unlock(&local->mtx); - } - - out: - kfree_skb(skb); -} - static void ieee80211_work_timer(unsigned long data) { struct ieee80211_local *local = (void *) data; @@ -877,7 +117,6 @@ static void ieee80211_work_work(struct work_struct *work) { struct ieee80211_local *local = container_of(work, struct ieee80211_local, work_work); - struct sk_buff *skb; struct ieee80211_work *wk, *tmp; LIST_HEAD(free_work); enum work_action rma; @@ -893,10 +132,6 @@ static void ieee80211_work_work(struct work_struct *work) if (WARN(local->suspended, "work scheduled while going to suspend\n")) return; - /* first process frames to avoid timing out while a frame is pending */ - while ((skb = skb_dequeue(&local->work_skb_queue))) - ieee80211_work_rx_queued_mgmt(local, skb); - mutex_lock(&local->mtx); ieee80211_recalc_idle(local); @@ -947,24 +182,12 @@ static void ieee80211_work_work(struct work_struct *work) case IEEE80211_WORK_ABORT: rma = WORK_ACT_TIMEOUT; break; - case IEEE80211_WORK_DIRECT_PROBE: - rma = ieee80211_direct_probe(wk); - break; - case IEEE80211_WORK_AUTH: - rma = ieee80211_authenticate(wk); - break; - case IEEE80211_WORK_ASSOC: - rma = ieee80211_associate(wk); - break; case IEEE80211_WORK_REMAIN_ON_CHANNEL: rma = ieee80211_remain_on_channel_timeout(wk); break; case IEEE80211_WORK_OFFCHANNEL_TX: rma = ieee80211_offchannel_tx(wk); break; - case IEEE80211_WORK_ASSOC_BEACON_WAIT: - rma = ieee80211_assoc_beacon_wait(wk); - break; } wk->started = started; @@ -1052,7 +275,6 @@ void ieee80211_work_init(struct ieee80211_local *local) setup_timer(&local->work_timer, ieee80211_work_timer, (unsigned long)local); INIT_WORK(&local->work_work, ieee80211_work_work); - skb_queue_head_init(&local->work_skb_queue); } void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata) @@ -1086,43 +308,6 @@ void ieee80211_work_purge(struct ieee80211_sub_if_data *sdata) mutex_unlock(&local->mtx); } -ieee80211_rx_result ieee80211_work_rx_mgmt(struct ieee80211_sub_if_data *sdata, - struct sk_buff *skb) -{ - struct ieee80211_local *local = sdata->local; - struct ieee80211_mgmt *mgmt; - struct ieee80211_work *wk; - u16 fc; - - if (skb->len < 24) - return RX_DROP_MONITOR; - - mgmt = (struct ieee80211_mgmt *) skb->data; - fc = le16_to_cpu(mgmt->frame_control); - - list_for_each_entry_rcu(wk, &local->work_list, list) { - if (sdata != wk->sdata) - continue; - if (compare_ether_addr(wk->filter_ta, mgmt->sa)) - continue; - if (compare_ether_addr(wk->filter_ta, mgmt->bssid)) - continue; - - switch (fc & IEEE80211_FCTL_STYPE) { - case IEEE80211_STYPE_AUTH: - case IEEE80211_STYPE_PROBE_RESP: - case IEEE80211_STYPE_ASSOC_RESP: - case IEEE80211_STYPE_REASSOC_RESP: - case IEEE80211_STYPE_BEACON: - skb_queue_tail(&local->work_skb_queue, skb); - ieee80211_queue_work(&local->hw, &local->work_work); - return RX_QUEUED; - } - } - - return RX_CONTINUE; -} - static enum work_done_result ieee80211_remain_done(struct ieee80211_work *wk, struct sk_buff *skb) { -- GitLab From 5718b134b1fe09087ca225b0e475ef65536d02b4 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Mon, 30 Jan 2012 22:52:10 +0900 Subject: [PATCH 0390/1846] net: Fix typo in ipw2x00/libipw_rx.c Correct spelling in "suppported" to "supported" in drivers/net/wireless/ipw2x00/libipw_rx.c Signed-off-by: Masanari Iida Reviewed-by: Jesper Juhl Signed-off-by: John W. Linville --- drivers/net/wireless/ipw2x00/libipw_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ipw2x00/libipw_rx.c b/drivers/net/wireless/ipw2x00/libipw_rx.c index 32a9966c3bf6..c4955d25a19a 100644 --- a/drivers/net/wireless/ipw2x00/libipw_rx.c +++ b/drivers/net/wireless/ipw2x00/libipw_rx.c @@ -172,7 +172,7 @@ libipw_rx_frame_mgmt(struct libipw_device *ieee, struct sk_buff *skb, u16 stype) { if (ieee->iw_mode == IW_MODE_MASTER) { - printk(KERN_DEBUG "%s: Master mode not yet suppported.\n", + printk(KERN_DEBUG "%s: Master mode not yet supported.\n", ieee->dev->name); return 0; /* -- GitLab From 7f4666ab3fd656513bffd449410a4d7c189081ec Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 30 Jan 2012 16:17:56 +0100 Subject: [PATCH 0391/1846] rt2800: radio 3xxx: reprogram only lower bits of RF_R3 Synchronize code with Ralink driver: 2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO (functions: RT33xx_ChipSwitchChannel() and RT30xx_ChipSwitchChannel()) Acked-by: Gertjan van Wingerde Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 5 +++++ drivers/net/wireless/rt2x00/rt2800lib.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index 2571a2fa3d09..abf2ae588164 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -1795,6 +1795,11 @@ struct mac_iveiv_entry { */ #define RFCSR2_RESCAL_EN FIELD8(0x80) +/* + * RFCSR 3: + */ +#define RFCSR3_K FIELD8(0x0f) + /* * FRCSR 5: */ diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 165535cc5072..006347e4d6ef 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1648,7 +1648,10 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, u8 rfcsr; rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); - rt2800_rfcsr_write(rt2x00dev, 3, rf->rf3); + + rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR3_K, rf->rf3); + rt2800_rfcsr_write(rt2x00dev, 3, rfcsr); rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); -- GitLab From e3bab197622276faac83eac3dfb993967d8d47e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 30 Jan 2012 16:17:57 +0100 Subject: [PATCH 0392/1846] rt2800: radio 3xxx: program RF_R1 during channel switch Synchronize code with Ralink driver: 2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO Based on functions: RT33xx_ChipSwitchChannel RT30xx_ChipSwitchChannel RT33xx_Init Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 006347e4d6ef..1bdf1ec33cd0 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1665,6 +1665,40 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, info->default_power2); rt2800_rfcsr_write(rt2x00dev, 13, rfcsr); + rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); + if (rt2x00_rt(rt2x00dev, RT3390)) { + rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, + rt2x00dev->default_ant.rx_chain_num == 1); + rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, + rt2x00dev->default_ant.tx_chain_num == 1); + } else { + rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0); + + switch (rt2x00dev->default_ant.tx_chain_num) { + case 1: + rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1); + /* fall through */ + case 2: + rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 1); + break; + } + + switch (rt2x00dev->default_ant.rx_chain_num) { + case 1: + rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1); + /* fall through */ + case 2: + rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 1); + break; + } + } + rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); + rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); -- GitLab From 3e0c7643c561c7052430f5c033d5b1b1289c962e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 30 Jan 2012 16:17:58 +0100 Subject: [PATCH 0393/1846] rt2800: radio 3xxx: add channel switch calibration routines Synchronize code with Ralink driver: 2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO Based on functions: RT33xx_ChipSwitchChannel RT30xx_ChipSwitchChannel Acked-by: Gertjan van Wingerde Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 1bdf1ec33cd0..0076bc7a9b36 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1699,6 +1699,13 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, } rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); + rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1); + rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); + msleep(1); + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0); + rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); + rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); @@ -1709,6 +1716,13 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); + + rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1); + rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); + msleep(1); + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0); + rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); } static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, -- GitLab From f1f12f9894c48dc8284762bc71e4a3ed5caf546f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 30 Jan 2012 16:17:59 +0100 Subject: [PATCH 0394/1846] rt2800: radio 3xxxx: channel switch RX/TX calibration fixes Synchronize code with Ralink driver: 2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO Based on functions: RT30xx_ChipSwitchChannel RT33xx_ChipSwitchChannel NICInitRT3370RFRegisters and defines from: include/chip/rt33xx.h Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 8 ++++++++ drivers/net/wireless/rt2x00/rt2800lib.c | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index abf2ae588164..c92fb2eee920 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -1871,6 +1871,13 @@ struct mac_iveiv_entry { */ #define RFCSR23_FREQ_OFFSET FIELD8(0x7f) +/* + * RFCSR 24: + */ +#define RFCSR24_TX_AGC_FC FIELD8(0x1f) +#define RFCSR24_TX_H20M FIELD8(0x20) +#define RFCSR24_TX_CALIB FIELD8(0x7f) + /* * RFCSR 27: */ @@ -1892,6 +1899,7 @@ struct mac_iveiv_entry { */ #define RFCSR31_RX_AGC_FC FIELD8(0x1f) #define RFCSR31_RX_H20M FIELD8(0x20) +#define RFCSR31_RX_CALIB FIELD8(0x7f) /* * RFCSR 38: diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 0076bc7a9b36..c326e7b1c374 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1645,7 +1645,7 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, struct rf_channel *rf, struct channel_info *info) { - u8 rfcsr; + u8 rfcsr, calib_tx, calib_rx; rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); @@ -1710,8 +1710,21 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); - rt2800_rfcsr_write(rt2x00dev, 24, - rt2x00dev->calibration[conf_is_ht40(conf)]); + if (rt2x00_rt(rt2x00dev, RT3390)) { + calib_tx = conf_is_ht40(conf) ? 0x68 : 0x4f; + calib_rx = conf_is_ht40(conf) ? 0x6f : 0x4f; + } else { + calib_tx = rt2x00dev->calibration[conf_is_ht40(conf)]; + calib_rx = rt2x00dev->calibration[conf_is_ht40(conf)]; + } + + rt2800_rfcsr_read(rt2x00dev, 24, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR24_TX_CALIB, calib_tx); + rt2800_rfcsr_write(rt2x00dev, 24, rfcsr); + + rt2800_rfcsr_read(rt2x00dev, 31, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR31_RX_CALIB, calib_rx); + rt2800_rfcsr_write(rt2x00dev, 31, rfcsr); rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); -- GitLab From 268bd858df5052f97722b123e990119c89171fd7 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 1 Feb 2012 16:17:40 +0100 Subject: [PATCH 0395/1846] rt2800: document RF_R03 register bits [7:4] Taken from: 2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO (based on function RT33xx_ChipSwitchChannel) Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index c92fb2eee920..fac9ece22b23 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -1799,6 +1799,9 @@ struct mac_iveiv_entry { * RFCSR 3: */ #define RFCSR3_K FIELD8(0x0f) +/* Bits [7-4] for RF3320 (RT3370/RT3390), on other chipsets reserved */ +#define RFCSR3_PA1_BIAS_CCK FIELD8(0x70); +#define RFCSR3_PA2_CASCODE_BIAS_CCKK FIELD8(0x80); /* * FRCSR 5: -- GitLab From 5f2d6171e1e70584b9819771443485750453fd16 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:31 +0100 Subject: [PATCH 0396/1846] bcma: add the core unit number Some SoCs have two pcie or gmac cores and we need to know the number of the specific core on the bus. This is the case for the BCM4706. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/scan.c | 14 ++++++++++++++ include/linux/bcma/bcma.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c index cad994857683..e513aa83ec25 100644 --- a/drivers/bcma/scan.c +++ b/drivers/bcma/scan.c @@ -212,6 +212,17 @@ static struct bcma_device *bcma_find_core_by_index(struct bcma_bus *bus, return NULL; } +static struct bcma_device *bcma_find_core_reverse(struct bcma_bus *bus, u16 coreid) +{ + struct bcma_device *core; + + list_for_each_entry_reverse(core, &bus->cores, list) { + if (core->id.id == coreid) + return core; + } + return NULL; +} + static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, struct bcma_device_id *match, int core_num, struct bcma_device *core) @@ -392,6 +403,7 @@ int bcma_bus_scan(struct bcma_bus *bus) bcma_scan_switch_core(bus, erombase); while (eromptr < eromend) { + struct bcma_device *other_core; struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL); if (!core) return -ENOMEM; @@ -411,6 +423,8 @@ int bcma_bus_scan(struct bcma_bus *bus) core->core_index = core_num++; bus->nr_cores++; + other_core = bcma_find_core_reverse(bus, core->id.id); + core->core_unit = (other_core == NULL) ? 0 : other_core->core_unit + 1; pr_info("Core %d found: %s " "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n", diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h index 83c209f39493..024a6e2a9083 100644 --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h @@ -136,6 +136,7 @@ struct bcma_device { bool dev_registered; u8 core_index; + u8 core_unit; u32 addr; u32 wrap; -- GitLab From 2be25cac8402fab56bb51166f464d1b420bcf744 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:32 +0100 Subject: [PATCH 0397/1846] bcma: add constants for PCI and use them There are many magic numbers used in the PCIe code. Replace them with some constants from the Broadcom SDK and also use them in the pcie host controller. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/driver_pci.c | 124 +++++++++++++++------------ include/linux/bcma/bcma_driver_pci.h | 85 ++++++++++++++++++ 2 files changed, 155 insertions(+), 54 deletions(-) diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c index 4fde6254f04e..fc462b4a0990 100644 --- a/drivers/bcma/driver_pci.c +++ b/drivers/bcma/driver_pci.c @@ -4,6 +4,7 @@ * * Copyright 2005, Broadcom Corporation * Copyright 2006, 2007, Michael Buesch + * Copyright 2011, 2012, Hauke Mehrtens * * Licensed under the GNU/GPL. See COPYING for details. */ @@ -18,38 +19,39 @@ static u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address) { - pcicore_write32(pc, 0x130, address); - pcicore_read32(pc, 0x130); - return pcicore_read32(pc, 0x134); + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address); + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR); + return pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_DATA); } #if 0 static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data) { - pcicore_write32(pc, 0x130, address); - pcicore_read32(pc, 0x130); - pcicore_write32(pc, 0x134, data); + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address); + pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR); + pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data); } #endif static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy) { - const u16 mdio_control = 0x128; - const u16 mdio_data = 0x12C; u32 v; int i; - v = (1 << 30); /* Start of Transaction */ - v |= (1 << 28); /* Write Transaction */ - v |= (1 << 17); /* Turnaround */ - v |= (0x1F << 18); + v = BCMA_CORE_PCI_MDIODATA_START; + v |= BCMA_CORE_PCI_MDIODATA_WRITE; + v |= (BCMA_CORE_PCI_MDIODATA_DEV_ADDR << + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF); + v |= (BCMA_CORE_PCI_MDIODATA_BLK_ADDR << + BCMA_CORE_PCI_MDIODATA_REGADDR_SHF); + v |= BCMA_CORE_PCI_MDIODATA_TA; v |= (phy << 4); - pcicore_write32(pc, mdio_data, v); + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v); udelay(10); for (i = 0; i < 200; i++) { - v = pcicore_read32(pc, mdio_control); - if (v & 0x100 /* Trans complete */) + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL); + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) break; msleep(1); } @@ -57,79 +59,84 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy) static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address) { - const u16 mdio_control = 0x128; - const u16 mdio_data = 0x12C; int max_retries = 10; u16 ret = 0; u32 v; int i; - v = 0x80; /* Enable Preamble Sequence */ - v |= 0x2; /* MDIO Clock Divisor */ - pcicore_write32(pc, mdio_control, v); + /* enable mdio access to SERDES */ + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN; + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL; + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v); if (pc->core->id.rev >= 10) { max_retries = 200; bcma_pcie_mdio_set_phy(pc, device); + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR << + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF); + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF); + } else { + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD); + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD); } - v = (1 << 30); /* Start of Transaction */ - v |= (1 << 29); /* Read Transaction */ - v |= (1 << 17); /* Turnaround */ - if (pc->core->id.rev < 10) - v |= (u32)device << 22; - v |= (u32)address << 18; - pcicore_write32(pc, mdio_data, v); + v = BCMA_CORE_PCI_MDIODATA_START; + v |= BCMA_CORE_PCI_MDIODATA_READ; + v |= BCMA_CORE_PCI_MDIODATA_TA; + + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v); /* Wait for the device to complete the transaction */ udelay(10); for (i = 0; i < max_retries; i++) { - v = pcicore_read32(pc, mdio_control); - if (v & 0x100 /* Trans complete */) { + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL); + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) { udelay(10); - ret = pcicore_read32(pc, mdio_data); + ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA); break; } msleep(1); } - pcicore_write32(pc, mdio_control, 0); + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0); return ret; } static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, u8 address, u16 data) { - const u16 mdio_control = 0x128; - const u16 mdio_data = 0x12C; int max_retries = 10; u32 v; int i; - v = 0x80; /* Enable Preamble Sequence */ - v |= 0x2; /* MDIO Clock Divisor */ - pcicore_write32(pc, mdio_control, v); + /* enable mdio access to SERDES */ + v = BCMA_CORE_PCI_MDIOCTL_PREAM_EN; + v |= BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL; + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, v); if (pc->core->id.rev >= 10) { max_retries = 200; bcma_pcie_mdio_set_phy(pc, device); + v = (BCMA_CORE_PCI_MDIODATA_DEV_ADDR << + BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF); + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF); + } else { + v = (device << BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD); + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD); } - v = (1 << 30); /* Start of Transaction */ - v |= (1 << 28); /* Write Transaction */ - v |= (1 << 17); /* Turnaround */ - if (pc->core->id.rev < 10) - v |= (u32)device << 22; - v |= (u32)address << 18; + v = BCMA_CORE_PCI_MDIODATA_START; + v |= BCMA_CORE_PCI_MDIODATA_WRITE; + v |= BCMA_CORE_PCI_MDIODATA_TA; v |= data; - pcicore_write32(pc, mdio_data, v); + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_DATA, v); /* Wait for the device to complete the transaction */ udelay(10); for (i = 0; i < max_retries; i++) { - v = pcicore_read32(pc, mdio_control); - if (v & 0x100 /* Trans complete */) + v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL); + if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE) break; msleep(1); } - pcicore_write32(pc, mdio_control, 0); + pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0); } /************************************************** @@ -138,20 +145,29 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, static u8 bcma_pcicore_polarity_workaround(struct bcma_drv_pci *pc) { - return (bcma_pcie_read(pc, 0x204) & 0x10) ? 0xC0 : 0x80; + u32 tmp; + + tmp = bcma_pcie_read(pc, BCMA_CORE_PCI_PLP_STATUSREG); + if (tmp & BCMA_CORE_PCI_PLP_POLARITYINV_STAT) + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE | + BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY; + else + return BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE; } static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc) { - const u8 serdes_pll_device = 0x1D; - const u8 serdes_rx_device = 0x1F; u16 tmp; - bcma_pcie_mdio_write(pc, serdes_rx_device, 1 /* Control */, - bcma_pcicore_polarity_workaround(pc)); - tmp = bcma_pcie_mdio_read(pc, serdes_pll_device, 1 /* Control */); - if (tmp & 0x4000) - bcma_pcie_mdio_write(pc, serdes_pll_device, 1, tmp & ~0x4000); + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_RX, + BCMA_CORE_PCI_SERDES_RX_CTRL, + bcma_pcicore_polarity_workaround(pc)); + tmp = bcma_pcie_mdio_read(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL, + BCMA_CORE_PCI_SERDES_PLL_CTRL); + if (tmp & BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN) + bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL, + BCMA_CORE_PCI_SERDES_PLL_CTRL, + tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN); } /************************************************** diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h index 3871b668caf9..67ea7beff9f3 100644 --- a/include/linux/bcma/bcma_driver_pci.h +++ b/include/linux/bcma/bcma_driver_pci.h @@ -53,6 +53,35 @@ struct pci_dev; #define BCMA_CORE_PCI_SBTOPCI1_MASK 0xFC000000 #define BCMA_CORE_PCI_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */ #define BCMA_CORE_PCI_SBTOPCI2_MASK 0xC0000000 +#define BCMA_CORE_PCI_CONFIG_ADDR 0x0120 /* pcie config space access */ +#define BCMA_CORE_PCI_CONFIG_DATA 0x0124 /* pcie config space access */ +#define BCMA_CORE_PCI_MDIO_CONTROL 0x0128 /* controls the mdio access */ +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */ +#define BCMA_CORE_PCI_MDIOCTL_DIVISOR_VAL 0x2 +#define BCMA_CORE_PCI_MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */ +#define BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE 0x100 /* Tranaction complete */ +#define BCMA_CORE_PCI_MDIO_DATA 0x012c /* Data to the mdio access */ +#define BCMA_CORE_PCI_MDIODATA_MASK 0x0000ffff /* data 2 bytes */ +#define BCMA_CORE_PCI_MDIODATA_TA 0x00020000 /* Turnaround */ +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD 18 /* Regaddr shift (rev < 10) */ +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK_OLD 0x003c0000 /* Regaddr Mask (rev < 10) */ +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF_OLD 22 /* Physmedia devaddr shift (rev < 10) */ +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK_OLD 0x0fc00000 /* Physmedia devaddr Mask (rev < 10) */ +#define BCMA_CORE_PCI_MDIODATA_REGADDR_SHF 18 /* Regaddr shift */ +#define BCMA_CORE_PCI_MDIODATA_REGADDR_MASK 0x007c0000 /* Regaddr Mask */ +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_SHF 23 /* Physmedia devaddr shift */ +#define BCMA_CORE_PCI_MDIODATA_DEVADDR_MASK 0x0f800000 /* Physmedia devaddr Mask */ +#define BCMA_CORE_PCI_MDIODATA_WRITE 0x10000000 /* write Transaction */ +#define BCMA_CORE_PCI_MDIODATA_READ 0x20000000 /* Read Transaction */ +#define BCMA_CORE_PCI_MDIODATA_START 0x40000000 /* start of Transaction */ +#define BCMA_CORE_PCI_MDIODATA_DEV_ADDR 0x0 /* dev address for serdes */ +#define BCMA_CORE_PCI_MDIODATA_BLK_ADDR 0x1F /* blk address for serdes */ +#define BCMA_CORE_PCI_MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */ +#define BCMA_CORE_PCI_MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */ +#define BCMA_CORE_PCI_MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */ +#define BCMA_CORE_PCI_PCIEIND_ADDR 0x0130 /* indirect access to the internal register */ +#define BCMA_CORE_PCI_PCIEIND_DATA 0x0134 /* Data to/from the internal regsiter */ +#define BCMA_CORE_PCI_CLKREQENCTRL 0x0138 /* >= rev 6, Clkreq rdma control */ #define BCMA_CORE_PCI_PCICFG0 0x0400 /* PCI config space 0 (rev >= 8) */ #define BCMA_CORE_PCI_PCICFG1 0x0500 /* PCI config space 1 (rev >= 8) */ #define BCMA_CORE_PCI_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */ @@ -72,6 +101,62 @@ struct pci_dev; #define BCMA_CORE_PCI_SBTOPCI_RC_READL 0x00000010 /* Memory read line */ #define BCMA_CORE_PCI_SBTOPCI_RC_READM 0x00000020 /* Memory read multiple */ +/* PCIE protocol PHY diagnostic registers */ +#define BCMA_CORE_PCI_PLP_MODEREG 0x200 /* Mode */ +#define BCMA_CORE_PCI_PLP_STATUSREG 0x204 /* Status */ +#define BCMA_CORE_PCI_PLP_POLARITYINV_STAT 0x10 /* Status reg PCIE_PLP_STATUSREG */ +#define BCMA_CORE_PCI_PLP_LTSSMCTRLREG 0x208 /* LTSSM control */ +#define BCMA_CORE_PCI_PLP_LTLINKNUMREG 0x20c /* Link Training Link number */ +#define BCMA_CORE_PCI_PLP_LTLANENUMREG 0x210 /* Link Training Lane number */ +#define BCMA_CORE_PCI_PLP_LTNFTSREG 0x214 /* Link Training N_FTS */ +#define BCMA_CORE_PCI_PLP_ATTNREG 0x218 /* Attention */ +#define BCMA_CORE_PCI_PLP_ATTNMASKREG 0x21C /* Attention Mask */ +#define BCMA_CORE_PCI_PLP_RXERRCTR 0x220 /* Rx Error */ +#define BCMA_CORE_PCI_PLP_RXFRMERRCTR 0x224 /* Rx Framing Error */ +#define BCMA_CORE_PCI_PLP_RXERRTHRESHREG 0x228 /* Rx Error threshold */ +#define BCMA_CORE_PCI_PLP_TESTCTRLREG 0x22C /* Test Control reg */ +#define BCMA_CORE_PCI_PLP_SERDESCTRLOVRDREG 0x230 /* SERDES Control Override */ +#define BCMA_CORE_PCI_PLP_TIMINGOVRDREG 0x234 /* Timing param override */ +#define BCMA_CORE_PCI_PLP_RXTXSMDIAGREG 0x238 /* RXTX State Machine Diag */ +#define BCMA_CORE_PCI_PLP_LTSSMDIAGREG 0x23C /* LTSSM State Machine Diag */ + +/* PCIE protocol DLLP diagnostic registers */ +#define BCMA_CORE_PCI_DLLP_LCREG 0x100 /* Link Control */ +#define BCMA_CORE_PCI_DLLP_LSREG 0x104 /* Link Status */ +#define BCMA_CORE_PCI_DLLP_LAREG 0x108 /* Link Attention */ +#define BCMA_CORE_PCI_DLLP_LSREG_LINKUP (1 << 16) +#define BCMA_CORE_PCI_DLLP_LAMASKREG 0x10C /* Link Attention Mask */ +#define BCMA_CORE_PCI_DLLP_NEXTTXSEQNUMREG 0x110 /* Next Tx Seq Num */ +#define BCMA_CORE_PCI_DLLP_ACKEDTXSEQNUMREG 0x114 /* Acked Tx Seq Num */ +#define BCMA_CORE_PCI_DLLP_PURGEDTXSEQNUMREG 0x118 /* Purged Tx Seq Num */ +#define BCMA_CORE_PCI_DLLP_RXSEQNUMREG 0x11C /* Rx Sequence Number */ +#define BCMA_CORE_PCI_DLLP_LRREG 0x120 /* Link Replay */ +#define BCMA_CORE_PCI_DLLP_LACKTOREG 0x124 /* Link Ack Timeout */ +#define BCMA_CORE_PCI_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */ +#define BCMA_CORE_PCI_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr */ +#define BCMA_CORE_PCI_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr */ +#define BCMA_CORE_PCI_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr */ +#define BCMA_CORE_PCI_DLLP_RTRRWREG 0x138 /* Retry buffer Read/Write */ +#define BCMA_CORE_PCI_DLLP_ECTHRESHREG 0x13C /* Error Count Threshold */ +#define BCMA_CORE_PCI_DLLP_TLPERRCTRREG 0x140 /* TLP Error Counter */ +#define BCMA_CORE_PCI_DLLP_ERRCTRREG 0x144 /* Error Counter */ +#define BCMA_CORE_PCI_DLLP_NAKRXCTRREG 0x148 /* NAK Received Counter */ +#define BCMA_CORE_PCI_DLLP_TESTREG 0x14C /* Test */ +#define BCMA_CORE_PCI_DLLP_PKTBIST 0x150 /* Packet BIST */ +#define BCMA_CORE_PCI_DLLP_PCIE11 0x154 /* DLLP PCIE 1.1 reg */ + +/* SERDES RX registers */ +#define BCMA_CORE_PCI_SERDES_RX_CTRL 1 /* Rx cntrl */ +#define BCMA_CORE_PCI_SERDES_RX_CTRL_FORCE 0x80 /* rxpolarity_force */ +#define BCMA_CORE_PCI_SERDES_RX_CTRL_POLARITY 0x40 /* rxpolarity_value */ +#define BCMA_CORE_PCI_SERDES_RX_TIMER1 2 /* Rx Timer1 */ +#define BCMA_CORE_PCI_SERDES_RX_CDR 6 /* CDR */ +#define BCMA_CORE_PCI_SERDES_RX_CDRBW 7 /* CDR BW */ + +/* SERDES PLL registers */ +#define BCMA_CORE_PCI_SERDES_PLL_CTRL 1 /* PLL control reg */ +#define BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN 0x4000 /* bit 14 is FREQDET on */ + /* PCIcore specific boardflags */ #define BCMA_CORE_PCI_BFL_NOPCI 0x00000400 /* Board leaves PCI floating */ -- GitLab From 4b259a5cc5ea967fa243dfc1f95a59ae74106f5b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:33 +0100 Subject: [PATCH 0398/1846] bcma: export bcma_pcie_read() This will be needed by the host controller. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/bcma_private.h | 3 +++ drivers/bcma/driver_pci.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h index 0def898a1d15..6109da5d883c 100644 --- a/drivers/bcma/bcma_private.h +++ b/drivers/bcma/bcma_private.h @@ -48,6 +48,9 @@ extern int __init bcma_host_pci_init(void); extern void __exit bcma_host_pci_exit(void); #endif /* CONFIG_BCMA_HOST_PCI */ +/* driver_pci.c */ +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address); + #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc); #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */ diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c index fc462b4a0990..22dc9fca6dcb 100644 --- a/drivers/bcma/driver_pci.c +++ b/drivers/bcma/driver_pci.c @@ -17,7 +17,7 @@ * R/W ops. **************************************************/ -static u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address) +u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address) { pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address); pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR); -- GitLab From d1a7a8e1d367e34e5adce91f48cae07dc08d9e6c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:34 +0100 Subject: [PATCH 0399/1846] bcma: make some functions __devinit bcma_core_pci_hostmode_init() has to be in __devinit as it will call a function in that section and so all functions calling it also have to be in __devinit. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/bcma_private.h | 4 ++-- drivers/bcma/driver_pci.c | 6 +++--- drivers/bcma/driver_pci_host.c | 2 +- drivers/bcma/host_pci.c | 4 ++-- drivers/bcma/main.c | 2 +- include/linux/bcma/bcma_driver_pci.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h index 6109da5d883c..63c5242159f2 100644 --- a/drivers/bcma/bcma_private.h +++ b/drivers/bcma/bcma_private.h @@ -13,7 +13,7 @@ struct bcma_bus; /* main.c */ -int bcma_bus_register(struct bcma_bus *bus); +int __devinit bcma_bus_register(struct bcma_bus *bus); void bcma_bus_unregister(struct bcma_bus *bus); int __init bcma_bus_early_register(struct bcma_bus *bus, struct bcma_device *core_cc, @@ -52,7 +52,7 @@ extern void __exit bcma_host_pci_exit(void); u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address); #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc); +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc); #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */ #endif diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c index 22dc9fca6dcb..155d953dba74 100644 --- a/drivers/bcma/driver_pci.c +++ b/drivers/bcma/driver_pci.c @@ -174,12 +174,12 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc) * Init. **************************************************/ -static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc) +static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc) { bcma_pcicore_serdes_workaround(pc); } -static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc) +static bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc) { struct bcma_bus *bus = pc->core->bus; u16 chipid_top; @@ -204,7 +204,7 @@ static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc) return true; } -void bcma_core_pci_init(struct bcma_drv_pci *pc) +void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc) { if (pc->setup_done) return; diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c index eb332b75ce83..99e040b607a2 100644 --- a/drivers/bcma/driver_pci_host.c +++ b/drivers/bcma/driver_pci_host.c @@ -8,7 +8,7 @@ #include "bcma_private.h" #include -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc) +void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc) { pr_err("No support for PCI core in hostmode yet\n"); } diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c index f59244e33971..e3928d68802b 100644 --- a/drivers/bcma/host_pci.c +++ b/drivers/bcma/host_pci.c @@ -154,8 +154,8 @@ const struct bcma_host_ops bcma_host_pci_ops = { .awrite32 = bcma_host_pci_awrite32, }; -static int bcma_host_pci_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int __devinit bcma_host_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id) { struct bcma_bus *bus; int err = -ENOMEM; diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index febbc0a1222a..3363036f23dc 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -132,7 +132,7 @@ static void bcma_unregister_cores(struct bcma_bus *bus) } } -int bcma_bus_register(struct bcma_bus *bus) +int __devinit bcma_bus_register(struct bcma_bus *bus) { int err; struct bcma_device *core; diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h index 67ea7beff9f3..679d4cab4547 100644 --- a/include/linux/bcma/bcma_driver_pci.h +++ b/include/linux/bcma/bcma_driver_pci.h @@ -169,7 +169,7 @@ struct bcma_drv_pci { #define pcicore_read32(pc, offset) bcma_read32((pc)->core, offset) #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val) -extern void bcma_core_pci_init(struct bcma_drv_pci *pc); +extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc); extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, bool enable); -- GitLab From 49dc9577155576b10ff79f0c1486c816b01f58bf Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:35 +0100 Subject: [PATCH 0400/1846] bcma: add PCIe host controller Some SoCs have a PCIe host controller to make it possible to attach some other devices to it, like an other Wifi card. This code was tested with an Netgear WNDR3400 (bcm4716 based), but should work with all bcma based SoCs. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- arch/mips/pci/pci-bcm47xx.c | 49 ++- drivers/bcma/bcma_private.h | 1 + drivers/bcma/driver_pci.c | 38 +- drivers/bcma/driver_pci_host.c | 576 ++++++++++++++++++++++++++- include/linux/bcma/bcma_driver_pci.h | 38 ++ include/linux/bcma/bcma_regs.h | 27 ++ 6 files changed, 690 insertions(+), 39 deletions(-) diff --git a/arch/mips/pci/pci-bcm47xx.c b/arch/mips/pci/pci-bcm47xx.c index 400535a955d0..c682468010c5 100644 --- a/arch/mips/pci/pci-bcm47xx.c +++ b/arch/mips/pci/pci-bcm47xx.c @@ -25,6 +25,7 @@ #include #include #include +#include #include int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) @@ -32,15 +33,12 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) return 0; } -int pcibios_plat_dev_init(struct pci_dev *dev) -{ #ifdef CONFIG_BCM47XX_SSB +static int bcm47xx_pcibios_plat_dev_init_ssb(struct pci_dev *dev) +{ int res; u8 slot, pin; - if (bcm47xx_bus_type != BCM47XX_BUS_TYPE_SSB) - return 0; - res = ssb_pcibios_plat_dev_init(dev); if (res < 0) { printk(KERN_ALERT "PCI: Failed to init device %s\n", @@ -60,6 +58,47 @@ int pcibios_plat_dev_init(struct pci_dev *dev) } dev->irq = res; + return 0; +} #endif + +#ifdef CONFIG_BCM47XX_BCMA +static int bcm47xx_pcibios_plat_dev_init_bcma(struct pci_dev *dev) +{ + int res; + + res = bcma_core_pci_plat_dev_init(dev); + if (res < 0) { + printk(KERN_ALERT "PCI: Failed to init device %s\n", + pci_name(dev)); + return res; + } + + res = bcma_core_pci_pcibios_map_irq(dev); + + /* IRQ-0 and IRQ-1 are software interrupts. */ + if (res < 2) { + printk(KERN_ALERT "PCI: Failed to map IRQ of device %s\n", + pci_name(dev)); + return res; + } + + dev->irq = res; return 0; } +#endif + +int pcibios_plat_dev_init(struct pci_dev *dev) +{ +#ifdef CONFIG_BCM47XX_SSB + if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_SSB) + return bcm47xx_pcibios_plat_dev_init_ssb(dev); + else +#endif +#ifdef CONFIG_BCM47XX_BCMA + if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA) + return bcm47xx_pcibios_plat_dev_init_bcma(dev); + else +#endif + return 0; +} diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h index 63c5242159f2..b81755bb4798 100644 --- a/drivers/bcma/bcma_private.h +++ b/drivers/bcma/bcma_private.h @@ -52,6 +52,7 @@ extern void __exit bcma_host_pci_exit(void); u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address); #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc); void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc); #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */ diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c index 155d953dba74..4d38ae179b48 100644 --- a/drivers/bcma/driver_pci.c +++ b/drivers/bcma/driver_pci.c @@ -2,7 +2,7 @@ * Broadcom specific AMBA * PCI Core * - * Copyright 2005, Broadcom Corporation + * Copyright 2005, 2011, Broadcom Corporation * Copyright 2006, 2007, Michael Buesch * Copyright 2011, 2012, Hauke Mehrtens * @@ -179,47 +179,19 @@ static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc) bcma_pcicore_serdes_workaround(pc); } -static bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc) -{ - struct bcma_bus *bus = pc->core->bus; - u16 chipid_top; - - chipid_top = (bus->chipinfo.id & 0xFF00); - if (chipid_top != 0x4700 && - chipid_top != 0x5300) - return false; - -#ifdef CONFIG_SSB_DRIVER_PCICORE - if (bus->sprom.boardflags_lo & SSB_BFL_NOPCI) - return false; -#endif /* CONFIG_SSB_DRIVER_PCICORE */ - -#if 0 - /* TODO: on BCMA we use address from EROM instead of magic formula */ - u32 tmp; - return !mips_busprobe32(tmp, (bus->mmio + - (pc->core->core_index * BCMA_CORE_SIZE))); -#endif - - return true; -} - void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc) { if (pc->setup_done) return; - if (bcma_core_pci_is_in_hostmode(pc)) { #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE + pc->hostmode = bcma_core_pci_is_in_hostmode(pc); + if (pc->hostmode) bcma_core_pci_hostmode_init(pc); -#else - pr_err("Driver compiled without support for hostmode PCI\n"); #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */ - } else { - bcma_core_pci_clientmode_init(pc); - } - pc->setup_done = true; + if (!pc->hostmode) + bcma_core_pci_clientmode_init(pc); } int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c index 99e040b607a2..4e20bcfa7ec5 100644 --- a/drivers/bcma/driver_pci_host.c +++ b/drivers/bcma/driver_pci_host.c @@ -2,13 +2,587 @@ * Broadcom specific AMBA * PCI Core in hostmode * + * Copyright 2005 - 2011, Broadcom Corporation + * Copyright 2006, 2007, Michael Buesch + * Copyright 2011, 2012, Hauke Mehrtens + * * Licensed under the GNU/GPL. See COPYING for details. */ #include "bcma_private.h" +#include #include +#include + +/* Probe a 32bit value on the bus and catch bus exceptions. + * Returns nonzero on a bus exception. + * This is MIPS specific */ +#define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr))) + +/* Assume one-hot slot wiring */ +#define BCMA_PCI_SLOT_MAX 16 +#define PCI_CONFIG_SPACE_SIZE 256 + +bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc) +{ + struct bcma_bus *bus = pc->core->bus; + u16 chipid_top; + u32 tmp; + + chipid_top = (bus->chipinfo.id & 0xFF00); + if (chipid_top != 0x4700 && + chipid_top != 0x5300) + return false; + + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) { + pr_info("This PCI core is disabled and not working\n"); + return false; + } + + bcma_core_enable(pc->core, 0); + + return !mips_busprobe32(tmp, pc->core->io_addr); +} + +static u32 bcma_pcie_read_config(struct bcma_drv_pci *pc, u32 address) +{ + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address); + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR); + return pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_DATA); +} + +static void bcma_pcie_write_config(struct bcma_drv_pci *pc, u32 address, + u32 data) +{ + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_ADDR, address); + pcicore_read32(pc, BCMA_CORE_PCI_CONFIG_ADDR); + pcicore_write32(pc, BCMA_CORE_PCI_CONFIG_DATA, data); +} + +static u32 bcma_get_cfgspace_addr(struct bcma_drv_pci *pc, unsigned int dev, + unsigned int func, unsigned int off) +{ + u32 addr = 0; + + /* Issue config commands only when the data link is up (atleast + * one external pcie device is present). + */ + if (dev >= 2 || !(bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_LSREG) + & BCMA_CORE_PCI_DLLP_LSREG_LINKUP)) + goto out; + + /* Type 0 transaction */ + /* Slide the PCI window to the appropriate slot */ + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0); + /* Calculate the address */ + addr = pc->host_controller->host_cfg_addr; + addr |= (dev << BCMA_CORE_PCI_CFG_SLOT_SHIFT); + addr |= (func << BCMA_CORE_PCI_CFG_FUN_SHIFT); + addr |= (off & ~3); + +out: + return addr; +} + +static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev, + unsigned int func, unsigned int off, + void *buf, int len) +{ + int err = -EINVAL; + u32 addr, val; + void __iomem *mmio = 0; + + WARN_ON(!pc->hostmode); + if (unlikely(len != 1 && len != 2 && len != 4)) + goto out; + if (dev == 0) { + /* we support only two functions on device 0 */ + if (func > 1) + return -EINVAL; + + /* accesses to config registers with offsets >= 256 + * requires indirect access. + */ + if (off >= PCI_CONFIG_SPACE_SIZE) { + addr = (func << 12); + addr |= (off & 0x0FFF); + val = bcma_pcie_read_config(pc, addr); + } else { + addr = BCMA_CORE_PCI_PCICFG0; + addr |= (func << 8); + addr |= (off & 0xfc); + val = pcicore_read32(pc, addr); + } + } else { + addr = bcma_get_cfgspace_addr(pc, dev, func, off); + if (unlikely(!addr)) + goto out; + err = -ENOMEM; + mmio = ioremap_nocache(addr, len); + if (!mmio) + goto out; + + if (mips_busprobe32(val, mmio)) { + val = 0xffffffff; + goto unmap; + } + + val = readl(mmio); + } + val >>= (8 * (off & 3)); + + switch (len) { + case 1: + *((u8 *)buf) = (u8)val; + break; + case 2: + *((u16 *)buf) = (u16)val; + break; + case 4: + *((u32 *)buf) = (u32)val; + break; + } + err = 0; +unmap: + if (mmio) + iounmap(mmio); +out: + return err; +} + +static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev, + unsigned int func, unsigned int off, + const void *buf, int len) +{ + int err = -EINVAL; + u32 addr = 0, val = 0; + void __iomem *mmio = 0; + u16 chipid = pc->core->bus->chipinfo.id; + + WARN_ON(!pc->hostmode); + if (unlikely(len != 1 && len != 2 && len != 4)) + goto out; + if (dev == 0) { + /* accesses to config registers with offsets >= 256 + * requires indirect access. + */ + if (off < PCI_CONFIG_SPACE_SIZE) { + addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0; + addr |= (func << 8); + addr |= (off & 0xfc); + mmio = ioremap_nocache(addr, len); + if (!mmio) + goto out; + } + } else { + addr = bcma_get_cfgspace_addr(pc, dev, func, off); + if (unlikely(!addr)) + goto out; + err = -ENOMEM; + mmio = ioremap_nocache(addr, len); + if (!mmio) + goto out; + + if (mips_busprobe32(val, mmio)) { + val = 0xffffffff; + goto unmap; + } + } + + switch (len) { + case 1: + val = readl(mmio); + val &= ~(0xFF << (8 * (off & 3))); + val |= *((const u8 *)buf) << (8 * (off & 3)); + break; + case 2: + val = readl(mmio); + val &= ~(0xFFFF << (8 * (off & 3))); + val |= *((const u16 *)buf) << (8 * (off & 3)); + break; + case 4: + val = *((const u32 *)buf); + break; + } + if (dev == 0 && !addr) { + /* accesses to config registers with offsets >= 256 + * requires indirect access. + */ + addr = (func << 12); + addr |= (off & 0x0FFF); + bcma_pcie_write_config(pc, addr, val); + } else { + writel(val, mmio); + + if (chipid == 0x4716 || chipid == 0x4748) + readl(mmio); + } + + err = 0; +unmap: + if (mmio) + iounmap(mmio); +out: + return err; +} + +static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus, + unsigned int devfn, + int reg, int size, u32 *val) +{ + unsigned long flags; + int err; + struct bcma_drv_pci *pc; + struct bcma_drv_pci_host *pc_host; + + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops); + pc = pc_host->pdev; + + spin_lock_irqsave(&pc_host->cfgspace_lock, flags); + err = bcma_extpci_read_config(pc, PCI_SLOT(devfn), + PCI_FUNC(devfn), reg, val, size); + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags); + + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; +} + +static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus, + unsigned int devfn, + int reg, int size, u32 val) +{ + unsigned long flags; + int err; + struct bcma_drv_pci *pc; + struct bcma_drv_pci_host *pc_host; + + pc_host = container_of(bus->ops, struct bcma_drv_pci_host, pci_ops); + pc = pc_host->pdev; + + spin_lock_irqsave(&pc_host->cfgspace_lock, flags); + err = bcma_extpci_write_config(pc, PCI_SLOT(devfn), + PCI_FUNC(devfn), reg, &val, size); + spin_unlock_irqrestore(&pc_host->cfgspace_lock, flags); + + return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; +} + +/* return cap_offset if requested capability exists in the PCI config space */ +static u8 __devinit bcma_find_pci_capability(struct bcma_drv_pci *pc, + unsigned int dev, + unsigned int func, u8 req_cap_id, + unsigned char *buf, u32 *buflen) +{ + u8 cap_id; + u8 cap_ptr = 0; + u32 bufsize; + u8 byte_val; + + /* check for Header type 0 */ + bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val, + sizeof(u8)); + if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL) + return cap_ptr; + + /* check if the capability pointer field exists */ + bcma_extpci_read_config(pc, dev, func, PCI_STATUS, &byte_val, + sizeof(u8)); + if (!(byte_val & PCI_STATUS_CAP_LIST)) + return cap_ptr; + + /* check if the capability pointer is 0x00 */ + bcma_extpci_read_config(pc, dev, func, PCI_CAPABILITY_LIST, &cap_ptr, + sizeof(u8)); + if (cap_ptr == 0x00) + return cap_ptr; + + /* loop thr'u the capability list and see if the requested capabilty + * exists */ + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id, sizeof(u8)); + while (cap_id != req_cap_id) { + bcma_extpci_read_config(pc, dev, func, cap_ptr + 1, &cap_ptr, + sizeof(u8)); + if (cap_ptr == 0x00) + return cap_ptr; + bcma_extpci_read_config(pc, dev, func, cap_ptr, &cap_id, + sizeof(u8)); + } + + /* found the caller requested capability */ + if ((buf != NULL) && (buflen != NULL)) { + u8 cap_data; + + bufsize = *buflen; + if (!bufsize) + return cap_ptr; + + *buflen = 0; + + /* copy the cpability data excluding cap ID and next ptr */ + cap_data = cap_ptr + 2; + if ((bufsize + cap_data) > PCI_CONFIG_SPACE_SIZE) + bufsize = PCI_CONFIG_SPACE_SIZE - cap_data; + *buflen = bufsize; + while (bufsize--) { + bcma_extpci_read_config(pc, dev, func, cap_data, buf, + sizeof(u8)); + cap_data++; + buf++; + } + } + + return cap_ptr; +} + +/* If the root port is capable of returning Config Request + * Retry Status (CRS) Completion Status to software then + * enable the feature. + */ +static void __devinit bcma_core_pci_enable_crs(struct bcma_drv_pci *pc) +{ + u8 cap_ptr, root_ctrl, root_cap, dev; + u16 val16; + int i; + + cap_ptr = bcma_find_pci_capability(pc, 0, 0, PCI_CAP_ID_EXP, NULL, + NULL); + root_cap = cap_ptr + PCI_EXP_RTCAP; + bcma_extpci_read_config(pc, 0, 0, root_cap, &val16, sizeof(u16)); + if (val16 & BCMA_CORE_PCI_RC_CRS_VISIBILITY) { + /* Enable CRS software visibility */ + root_ctrl = cap_ptr + PCI_EXP_RTCTL; + val16 = PCI_EXP_RTCTL_CRSSVE; + bcma_extpci_read_config(pc, 0, 0, root_ctrl, &val16, + sizeof(u16)); + + /* Initiate a configuration request to read the vendor id + * field of the device function's config space header after + * 100 ms wait time from the end of Reset. If the device is + * not done with its internal initialization, it must at + * least return a completion TLP, with a completion status + * of "Configuration Request Retry Status (CRS)". The root + * complex must complete the request to the host by returning + * a read-data value of 0001h for the Vendor ID field and + * all 1s for any additional bytes included in the request. + * Poll using the config reads for max wait time of 1 sec or + * until we receive the successful completion status. Repeat + * the procedure for all the devices. + */ + for (dev = 1; dev < BCMA_PCI_SLOT_MAX; dev++) { + for (i = 0; i < 100000; i++) { + bcma_extpci_read_config(pc, dev, 0, + PCI_VENDOR_ID, &val16, + sizeof(val16)); + if (val16 != 0x1) + break; + udelay(10); + } + if (val16 == 0x1) + pr_err("PCI: Broken device in slot %d\n", dev); + } + } +} void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc) { - pr_err("No support for PCI core in hostmode yet\n"); + struct bcma_bus *bus = pc->core->bus; + struct bcma_drv_pci_host *pc_host; + u32 tmp; + u32 pci_membase_1G; + unsigned long io_map_base; + + pr_info("PCIEcore in host mode found\n"); + + pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL); + if (!pc_host) { + pr_err("can not allocate memory"); + return; + } + + pc->host_controller = pc_host; + pc_host->pci_controller.io_resource = &pc_host->io_resource; + pc_host->pci_controller.mem_resource = &pc_host->mem_resource; + pc_host->pci_controller.pci_ops = &pc_host->pci_ops; + pc_host->pdev = pc; + + pci_membase_1G = BCMA_SOC_PCI_DMA; + pc_host->host_cfg_addr = BCMA_SOC_PCI_CFG; + + pc_host->pci_ops.read = bcma_core_pci_hostmode_read_config; + pc_host->pci_ops.write = bcma_core_pci_hostmode_write_config; + + pc_host->mem_resource.name = "BCMA PCIcore external memory", + pc_host->mem_resource.start = BCMA_SOC_PCI_DMA; + pc_host->mem_resource.end = BCMA_SOC_PCI_DMA + BCMA_SOC_PCI_DMA_SZ - 1; + pc_host->mem_resource.flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED; + + pc_host->io_resource.name = "BCMA PCIcore external I/O", + pc_host->io_resource.start = 0x100; + pc_host->io_resource.end = 0x7FF; + pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED; + + /* Reset RC */ + udelay(3000); + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE); + udelay(1000); + pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST | + BCMA_CORE_PCI_CTL_RST_OE); + + /* 64 MB I/O access window. On 4716, use + * sbtopcie0 to access the device registers. We + * can't use address match 2 (1 GB window) region + * as mips can't generate 64-bit address on the + * backplane. + */ + if (bus->chipinfo.id == 0x4716 || bus->chipinfo.id == 0x4748) { + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM; + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM + + BCMA_SOC_PCI_MEM_SZ - 1; + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0, + BCMA_CORE_PCI_SBTOPCI_MEM | BCMA_SOC_PCI_MEM); + } else if (bus->chipinfo.id == 0x5300) { + tmp = BCMA_CORE_PCI_SBTOPCI_MEM; + tmp |= BCMA_CORE_PCI_SBTOPCI_PREF; + tmp |= BCMA_CORE_PCI_SBTOPCI_BURST; + if (pc->core->core_unit == 0) { + pc_host->mem_resource.start = BCMA_SOC_PCI_MEM; + pc_host->mem_resource.end = BCMA_SOC_PCI_MEM + + BCMA_SOC_PCI_MEM_SZ - 1; + pci_membase_1G = BCMA_SOC_PCIE_DMA_H32; + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0, + tmp | BCMA_SOC_PCI_MEM); + } else if (pc->core->core_unit == 1) { + pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM; + pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM + + BCMA_SOC_PCI_MEM_SZ - 1; + pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32; + pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG; + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0, + tmp | BCMA_SOC_PCI1_MEM); + } + } else + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0, + BCMA_CORE_PCI_SBTOPCI_IO); + + /* 64 MB configuration access window */ + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI1, BCMA_CORE_PCI_SBTOPCI_CFG0); + + /* 1 GB memory access window */ + pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI2, + BCMA_CORE_PCI_SBTOPCI_MEM | pci_membase_1G); + + + /* As per PCI Express Base Spec 1.1 we need to wait for + * at least 100 ms from the end of a reset (cold/warm/hot) + * before issuing configuration requests to PCI Express + * devices. + */ + udelay(100000); + + bcma_core_pci_enable_crs(pc); + + /* Enable PCI bridge BAR0 memory & master access */ + tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; + bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp)); + + /* Enable PCI interrupts */ + pcicore_write32(pc, BCMA_CORE_PCI_IMASK, BCMA_CORE_PCI_IMASK_INTA); + + /* Ok, ready to run, register it to the system. + * The following needs change, if we want to port hostmode + * to non-MIPS platform. */ + io_map_base = (unsigned long)ioremap_nocache(BCMA_SOC_PCI_MEM, + 0x04000000); + pc_host->pci_controller.io_map_base = io_map_base; + set_io_port_base(pc_host->pci_controller.io_map_base); + /* Give some time to the PCI controller to configure itself with the new + * values. Not waiting at this point causes crashes of the machine. */ + mdelay(10); + register_pci_controller(&pc_host->pci_controller); + return; +} + +/* Early PCI fixup for a device on the PCI-core bridge. */ +static void bcma_core_pci_fixup_pcibridge(struct pci_dev *dev) +{ + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { + /* This is not a device on the PCI-core bridge. */ + return; + } + if (PCI_SLOT(dev->devfn) != 0) + return; + + pr_info("PCI: Fixing up bridge %s\n", pci_name(dev)); + + /* Enable PCI bridge bus mastering and memory space */ + pci_set_master(dev); + if (pcibios_enable_device(dev, ~0) < 0) { + pr_err("PCI: BCMA bridge enable failed\n"); + return; + } + + /* Enable PCI bridge BAR1 prefetch and burst */ + pci_write_config_dword(dev, BCMA_PCI_BAR1_CONTROL, 3); +} +DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_pcibridge); + +/* Early PCI fixup for all PCI-cores to set the correct memory address. */ +static void bcma_core_pci_fixup_addresses(struct pci_dev *dev) +{ + struct resource *res; + int pos; + + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { + /* This is not a device on the PCI-core bridge. */ + return; + } + if (PCI_SLOT(dev->devfn) == 0) + return; + + pr_info("PCI: Fixing up addresses %s\n", pci_name(dev)); + + for (pos = 0; pos < 6; pos++) { + res = &dev->resource[pos]; + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) + pci_assign_resource(dev, pos); + } +} +DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses); + +/* This function is called when doing a pci_enable_device(). + * We must first check if the device is a device on the PCI-core bridge. */ +int bcma_core_pci_plat_dev_init(struct pci_dev *dev) +{ + struct bcma_drv_pci_host *pc_host; + + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { + /* This is not a device on the PCI-core bridge. */ + return -ENODEV; + } + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host, + pci_ops); + + pr_info("PCI: Fixing up device %s\n", pci_name(dev)); + + /* Fix up interrupt lines */ + dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2; + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); + + return 0; +} +EXPORT_SYMBOL(bcma_core_pci_plat_dev_init); + +/* PCI device IRQ mapping. */ +int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev) +{ + struct bcma_drv_pci_host *pc_host; + + if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) { + /* This is not a device on the PCI-core bridge. */ + return -ENODEV; + } + + pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host, + pci_ops); + return bcma_core_mips_irq(pc_host->pdev->core) + 2; } +EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq); diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h index 679d4cab4547..46c71e27d31f 100644 --- a/include/linux/bcma/bcma_driver_pci.h +++ b/include/linux/bcma/bcma_driver_pci.h @@ -160,9 +160,44 @@ struct pci_dev; /* PCIcore specific boardflags */ #define BCMA_CORE_PCI_BFL_NOPCI 0x00000400 /* Board leaves PCI floating */ +/* PCIE Config space accessing MACROS */ +#define BCMA_CORE_PCI_CFG_BUS_SHIFT 24 /* Bus shift */ +#define BCMA_CORE_PCI_CFG_SLOT_SHIFT 19 /* Slot/Device shift */ +#define BCMA_CORE_PCI_CFG_FUN_SHIFT 16 /* Function shift */ +#define BCMA_CORE_PCI_CFG_OFF_SHIFT 0 /* Register shift */ + +#define BCMA_CORE_PCI_CFG_BUS_MASK 0xff /* Bus mask */ +#define BCMA_CORE_PCI_CFG_SLOT_MASK 0x1f /* Slot/Device mask */ +#define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */ +#define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */ + +/* PCIE Root Capability Register bits (Host mode only) */ +#define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001 + +struct bcma_drv_pci; + +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE +struct bcma_drv_pci_host { + struct bcma_drv_pci *pdev; + + u32 host_cfg_addr; + spinlock_t cfgspace_lock; + + struct pci_controller pci_controller; + struct pci_ops pci_ops; + struct resource mem_resource; + struct resource io_resource; +}; +#endif + struct bcma_drv_pci { struct bcma_device *core; u8 setup_done:1; + u8 hostmode:1; + +#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE + struct bcma_drv_pci_host *host_controller; +#endif }; /* Register access */ @@ -173,4 +208,7 @@ extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc); extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, bool enable); +extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev); +extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev); + #endif /* LINUX_BCMA_DRIVER_PCI_H_ */ diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h index 9faae2ae02e8..5a71d5719640 100644 --- a/include/linux/bcma/bcma_regs.h +++ b/include/linux/bcma/bcma_regs.h @@ -56,4 +56,31 @@ #define BCMA_PCI_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */ #define BCMA_PCI_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */ +/* SiliconBackplane Address Map. + * All regions may not exist on all chips. + */ +#define BCMA_SOC_SDRAM_BASE 0x00000000U /* Physical SDRAM */ +#define BCMA_SOC_PCI_MEM 0x08000000U /* Host Mode sb2pcitranslation0 (64 MB) */ +#define BCMA_SOC_PCI_MEM_SZ (64 * 1024 * 1024) +#define BCMA_SOC_PCI_CFG 0x0c000000U /* Host Mode sb2pcitranslation1 (64 MB) */ +#define BCMA_SOC_SDRAM_SWAPPED 0x10000000U /* Byteswapped Physical SDRAM */ +#define BCMA_SOC_SDRAM_R2 0x80000000U /* Region 2 for sdram (512 MB) */ + + +#define BCMA_SOC_PCI_DMA 0x40000000U /* Client Mode sb2pcitranslation2 (1 GB) */ +#define BCMA_SOC_PCI_DMA2 0x80000000U /* Client Mode sb2pcitranslation2 (1 GB) */ +#define BCMA_SOC_PCI_DMA_SZ 0x40000000U /* Client Mode sb2pcitranslation2 size in bytes */ +#define BCMA_SOC_PCIE_DMA_L32 0x00000000U /* PCIE Client Mode sb2pcitranslation2 + * (2 ZettaBytes), low 32 bits + */ +#define BCMA_SOC_PCIE_DMA_H32 0x80000000U /* PCIE Client Mode sb2pcitranslation2 + * (2 ZettaBytes), high 32 bits + */ + +#define BCMA_SOC_PCI1_MEM 0x40000000U /* Host Mode sb2pcitranslation0 (64 MB) */ +#define BCMA_SOC_PCI1_CFG 0x44000000U /* Host Mode sb2pcitranslation1 (64 MB) */ +#define BCMA_SOC_PCIE1_DMA_H32 0xc0000000U /* PCIE Client Mode sb2pcitranslation2 + * (2 ZettaBytes), high 32 bits + */ + #endif /* LINUX_BCMA_REGS_H_ */ -- GitLab From 8f9ada4fa1926e540b1562cb9bacb3e51a698c35 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:36 +0100 Subject: [PATCH 0401/1846] bcma: add bus num counter If we have two bcma buses on one computer the second will not work without this patch. Now each bus gets an own number. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/main.c | 12 +++++++++++- include/linux/bcma/bcma.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index 3363036f23dc..bcd1c01cde9e 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -13,6 +13,12 @@ MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); MODULE_LICENSE("GPL"); +/* contains the number the next bus should get. */ +static unsigned int bcma_bus_next_num = 0; + +/* bcma_buses_mutex locks the bcma_bus_next_num */ +static DEFINE_MUTEX(bcma_buses_mutex); + static int bcma_bus_match(struct device *dev, struct device_driver *drv); static int bcma_device_probe(struct device *dev); static int bcma_device_remove(struct device *dev); @@ -93,7 +99,7 @@ static int bcma_register_cores(struct bcma_bus *bus) core->dev.release = bcma_release_core_dev; core->dev.bus = &bcma_bus_type; - dev_set_name(&core->dev, "bcma%d:%d", 0/*bus->num*/, dev_id); + dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id); switch (bus->hosttype) { case BCMA_HOSTTYPE_PCI: @@ -137,6 +143,10 @@ int __devinit bcma_bus_register(struct bcma_bus *bus) int err; struct bcma_device *core; + mutex_lock(&bcma_buses_mutex); + bus->num = bcma_bus_next_num++; + mutex_unlock(&bcma_buses_mutex); + /* Scan for devices (cores) */ err = bcma_bus_scan(bus); if (err) { diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h index 024a6e2a9083..b9f65fbee42f 100644 --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h @@ -196,6 +196,7 @@ struct bcma_bus { struct list_head cores; u8 nr_cores; u8 init_done:1; + u8 num; struct bcma_drv_cc drv_cc; struct bcma_drv_pci drv_pci; -- GitLab From d6865dcc58f252480515101fd13532f0fc420b53 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 31 Jan 2012 00:03:37 +0100 Subject: [PATCH 0402/1846] bcma: add extra sprom check This check is needed on the BCM43224 device as it says in the capabilities it has an sprom but is extra check says it has not. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/sprom.c | 7 +++++++ include/linux/bcma/bcma_driver_chipcommon.h | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index e35134f724f6..ca7752510d5b 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -250,6 +250,7 @@ int bcma_sprom_get(struct bcma_bus *bus) { u16 offset; u16 *sprom; + u32 sromctrl; int err = 0; if (!bus->drv_cc.core) @@ -258,6 +259,12 @@ int bcma_sprom_get(struct bcma_bus *bus) if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM)) return -ENOENT; + if (bus->drv_cc.core->id.rev >= 32) { + sromctrl = bcma_read32(bus->drv_cc.core, BCMA_CC_SROM_CONTROL); + if (!(sromctrl & BCMA_CC_SROM_CONTROL_PRESENT)) + return -ENOENT; + } + sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), GFP_KERNEL); if (!sprom) diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h index a33086a7530b..e72938b10714 100644 --- a/include/linux/bcma/bcma_driver_chipcommon.h +++ b/include/linux/bcma/bcma_driver_chipcommon.h @@ -181,6 +181,22 @@ #define BCMA_CC_FLASH_CFG 0x0128 #define BCMA_CC_FLASH_CFG_DS 0x0010 /* Data size, 0=8bit, 1=16bit */ #define BCMA_CC_FLASH_WAITCNT 0x012C +#define BCMA_CC_SROM_CONTROL 0x0190 +#define BCMA_CC_SROM_CONTROL_START 0x80000000 +#define BCMA_CC_SROM_CONTROL_BUSY 0x80000000 +#define BCMA_CC_SROM_CONTROL_OPCODE 0x60000000 +#define BCMA_CC_SROM_CONTROL_OP_READ 0x00000000 +#define BCMA_CC_SROM_CONTROL_OP_WRITE 0x20000000 +#define BCMA_CC_SROM_CONTROL_OP_WRDIS 0x40000000 +#define BCMA_CC_SROM_CONTROL_OP_WREN 0x60000000 +#define BCMA_CC_SROM_CONTROL_OTPSEL 0x00000010 +#define BCMA_CC_SROM_CONTROL_LOCK 0x00000008 +#define BCMA_CC_SROM_CONTROL_SIZE_MASK 0x00000006 +#define BCMA_CC_SROM_CONTROL_SIZE_1K 0x00000000 +#define BCMA_CC_SROM_CONTROL_SIZE_4K 0x00000002 +#define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004 +#define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1 +#define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001 /* 0x1E0 is defined as shared BCMA_CLKCTLST */ #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */ #define BCMA_CC_UART0_DATA 0x0300 -- GitLab From 1d73c51a8476847d96a6c5a2ae3715d7099c58c9 Mon Sep 17 00:00:00 2001 From: "Devendra.Naga" Date: Tue, 31 Jan 2012 01:28:15 -0500 Subject: [PATCH 0403/1846] rtlwifi: remove return in _rtl_pci_switch_clk_req the return value from _rtl_pci_switch_clk_req is not used by any of its callers. Signed-off-by: Devendra.Naga Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 5cb2199435d2..9a0190944de5 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -198,7 +198,7 @@ static bool _rtl_pci_platform_switch_device_pci_aspm( } /*When we set 0x01 to enable clk request. Set 0x0 to disable clk req.*/ -static bool _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value) +static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value) { struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); @@ -207,8 +207,6 @@ static bool _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value) if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) udelay(100); - - return true; } /*Disable RTL8192SE ASPM & Disable Pci Bridge ASPM*/ -- GitLab From f3e1b97f036ee477c49b8ec561027db8e3863eab Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 31 Jan 2012 23:23:45 +0900 Subject: [PATCH 0404/1846] iwmc3200wifi: Fix typo in trace.h Correct spelling "embeded" to "embedded" in drivers/net/wireless/iwmc3200wifi/trace.h Signed-off-by: Masanari Iida Acked-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/net/wireless/iwmc3200wifi/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwmc3200wifi/trace.h b/drivers/net/wireless/iwmc3200wifi/trace.h index abb4805fa8df..f5f7070b7e22 100644 --- a/drivers/net/wireless/iwmc3200wifi/trace.h +++ b/drivers/net/wireless/iwmc3200wifi/trace.h @@ -144,7 +144,7 @@ TRACE_EVENT(iwm_tx_packets, TP_printk( IWM_PR_FMT " Tx %spacket: eot %d, seq 0x%x, sta_color 0x%x, " - "ra_tid 0x%x, credit_group 0x%x, embeded_packets %d, %d bytes", + "ra_tid 0x%x, credit_group 0x%x, embedded_packets %d, %d bytes", IWM_PR_ARG, !__entry->eot ? "concatenated " : "", __entry->eot, __entry->seq, __entry->color, __entry->ra_tid, __entry->credit_group, __entry->npkt, __entry->bytes -- GitLab From 5aff4e74dc69105b95b799b036aa597ce0726e07 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 31 Jan 2012 09:42:58 -0600 Subject: [PATCH 0405/1846] rtlwifi: Fix typo in dm.c Correct a spelling "disconnet" to "disconnect" in drivers/net/wireless/rtlwifi/rtl8192de/dm.c Signed-off-by: Masanari Iida Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c index 181ed6fc90e6..9fda1af44b38 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c @@ -294,7 +294,7 @@ static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw) de_digtable.min_undecorated_pwdb_for_dm = rtlpriv->dm.UNDEC_SM_PWDB; RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - "AP Ext Port or disconnet PWDB = 0x%x\n", + "AP Ext Port or disconnect PWDB = 0x%x\n", de_digtable.min_undecorated_pwdb_for_dm); } -- GitLab From 3eda95de19e1781612091869e866a5014257f462 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 31 Jan 2012 10:29:22 -0600 Subject: [PATCH 0406/1846] rtlwifi: Remove extra debugging message accidentally left in In commit b0302aba812bcc39291cdab9ad7e37008f352a91, an extra debugging message that is spamming the logs was not deleted before submission. Signed-off-by: Larry Finger Cc: Stable Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index f231b9180436..278e9f957e0d 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c @@ -296,12 +296,10 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) * because that will cause nullfunc send by mac80211 * fail, and cause pkt loss, we have tested that 5mA * is worked very well */ - if (!rtlpriv->psc.multi_buffered) { + if (!rtlpriv->psc.multi_buffered) queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_work, MSECS(5)); - pr_info("In section\n"); - } } else { rtl_swlps_rf_awake(hw); rtlpriv->psc.sw_ps_enabled = false; -- GitLab From 267335d63b808dc861f3a4dc81a605489a8a13ac Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Tue, 31 Jan 2012 20:25:47 +0100 Subject: [PATCH 0407/1846] cfg80211/mac80211: userspace peer authorization in IBSS If the IBSS network is RSN-protected, let userspace authorize the stations instead of adding them as AUTHORIZED by default. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- include/net/cfg80211.h | 5 +++++ net/mac80211/ibss.c | 6 +++++- net/mac80211/ieee80211_i.h | 2 ++ net/wireless/nl80211.c | 20 ++++++++++++-------- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 229edc526cf5..e0c9ff3a1977 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1147,6 +1147,10 @@ struct cfg80211_disassoc_request { * @beacon_interval: beacon interval to use * @privacy: this is a protected network, keys will be configured * after joining + * @control_port: whether user space controls IEEE 802.1X port, i.e., + * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is + * required to assume that the port is unauthorized until authorized by + * user space. Otherwise, port is marked authorized by default. * @basic_rates: bitmap of basic rates to use when creating the IBSS * @mcast_rate: per-band multicast rate index + 1 (0: disabled) */ @@ -1161,6 +1165,7 @@ struct cfg80211_ibss_params { u32 basic_rates; bool channel_fixed; bool privacy; + bool control_port; int mcast_rate[IEEE80211_NUM_BANDS]; }; diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 7b3a0b0aa246..8361da4b36ab 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -268,7 +268,10 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); + /* authorize the station only if the network is not RSN protected. If + * not wait for the userspace to authorize it */ + if (!sta->sdata->u.ibss.control_port) + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); rate_control_rate_init(sta); @@ -1075,6 +1078,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, sdata->u.ibss.fixed_bssid = false; sdata->u.ibss.privacy = params->privacy; + sdata->u.ibss.control_port = params->control_port; sdata->u.ibss.basic_rates = params->basic_rates; memcpy(sdata->vif.bss_conf.mcast_rate, params->mcast_rate, sizeof(params->mcast_rate)); diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index a146b1177cb0..74594f012cd3 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -478,6 +478,8 @@ struct ieee80211_if_ibss { bool fixed_channel; bool privacy; + bool control_port; + u8 bssid[ETH_ALEN]; u8 ssid[IEEE80211_MAX_SSID_LEN]; u8 ssid_len, ie_len; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index e1fd1bf90729..f1681e2c5949 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2654,13 +2654,6 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) break; case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_STATION: - /* disallow things sta doesn't support */ - if (params.plink_action) - return -EINVAL; - if (params.ht_capa) - return -EINVAL; - if (params.listen_interval >= 0) - return -EINVAL; /* * Don't allow userspace to change the TDLS_PEER flag, * but silently ignore attempts to change it since we @@ -2668,7 +2661,15 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) * to change the flag. */ params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); - + /* fall through */ + case NL80211_IFTYPE_ADHOC: + /* disallow things sta doesn't support */ + if (params.plink_action) + return -EINVAL; + if (params.ht_capa) + return -EINVAL; + if (params.listen_interval >= 0) + return -EINVAL; /* reject any changes other than AUTHORIZED */ if (params.sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED)) return -EINVAL; @@ -4802,6 +4803,9 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) return PTR_ERR(connkeys); } + ibss.control_port = + nla_get_flag(info->attrs[NL80211_ATTR_CONTROL_PORT]); + err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys); if (err) kfree(connkeys); -- GitLab From f0d4724b2a663089d21e19933ca591d842b63230 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 1 Feb 2012 00:13:54 +0100 Subject: [PATCH 0408/1846] bcma: log the id, rev and pkg of the chip found This makes us see what type of hardware someone uses by the dmesg output. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/scan.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c index e513aa83ec25..6621b2221b40 100644 --- a/drivers/bcma/scan.c +++ b/drivers/bcma/scan.c @@ -364,6 +364,7 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, void bcma_init_bus(struct bcma_bus *bus) { s32 tmp; + struct bcma_chipinfo *chipinfo = &(bus->chipinfo); if (bus->init_done) return; @@ -374,9 +375,12 @@ void bcma_init_bus(struct bcma_bus *bus) bcma_scan_switch_core(bus, BCMA_ADDR_BASE); tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID); - bus->chipinfo.id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT; - bus->chipinfo.rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT; - bus->chipinfo.pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT; + chipinfo->id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT; + chipinfo->rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT; + chipinfo->pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT; + pr_info("Found chip with id 0x%04X, rev 0x%02X and package 0x%02X\n", + chipinfo->id, chipinfo->rev, chipinfo->pkg); + bus->init_done = true; } -- GitLab From bedb2a18af0a4e7565182c07fadd854e3ae8c9bc Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 1 Feb 2012 00:13:55 +0100 Subject: [PATCH 0409/1846] ssb: log the id, rev and pkg of the chip found This makes us see what type of hardware someone uses by the dmesg output. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/ssb/scan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ssb/scan.c b/drivers/ssb/scan.c index 3e844874631f..266c7c5c86dc 100644 --- a/drivers/ssb/scan.c +++ b/drivers/ssb/scan.c @@ -318,6 +318,9 @@ int ssb_bus_scan(struct ssb_bus *bus, bus->chip_package = 0; } } + ssb_printk(KERN_INFO PFX "Found chip with id 0x%04X, rev 0x%02X and " + "package 0x%02X\n", bus->chip_id, bus->chip_rev, + bus->chip_package); if (!bus->nr_devices) bus->nr_devices = chipid_to_nrcores(bus->chip_id); if (bus->nr_devices > ARRAY_SIZE(bus->devices)) { -- GitLab From d486a5b4996d2fffd10098725781f2c5690774bc Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 1 Feb 2012 00:13:56 +0100 Subject: [PATCH 0410/1846] ssb: add support for bcm5354 This patch adds support the the BCM5354 SoC. It has a PMU and a constant not configurable clock. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/ssb/driver_chipcommon_pmu.c | 48 ++++++++++++++++++++++++++--- drivers/ssb/driver_mipscore.c | 3 ++ drivers/ssb/main.c | 3 ++ drivers/ssb/ssb_private.h | 4 +++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/drivers/ssb/driver_chipcommon_pmu.c b/drivers/ssb/driver_chipcommon_pmu.c index e5a2e0e9bc19..b58fef780ea0 100644 --- a/drivers/ssb/driver_chipcommon_pmu.c +++ b/drivers/ssb/driver_chipcommon_pmu.c @@ -13,6 +13,9 @@ #include #include #include +#ifdef CONFIG_BCM47XX +#include +#endif #include "ssb_private.h" @@ -92,10 +95,6 @@ static void ssb_pmu0_pllinit_r0(struct ssb_chipcommon *cc, u32 pmuctl, tmp, pllctl; unsigned int i; - if ((bus->chip_id == 0x5354) && !crystalfreq) { - /* The 5354 crystal freq is 25MHz */ - crystalfreq = 25000; - } if (crystalfreq) e = pmu0_plltab_find_entry(crystalfreq); if (!e) @@ -321,7 +320,11 @@ static void ssb_pmu_pll_init(struct ssb_chipcommon *cc) u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */ if (bus->bustype == SSB_BUSTYPE_SSB) { - /* TODO: The user may override the crystal frequency. */ +#ifdef CONFIG_BCM47XX + char buf[20]; + if (nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0) + crystalfreq = simple_strtoul(buf, NULL, 0); +#endif } switch (bus->chip_id) { @@ -330,7 +333,11 @@ static void ssb_pmu_pll_init(struct ssb_chipcommon *cc) ssb_pmu1_pllinit_r0(cc, crystalfreq); break; case 0x4328: + ssb_pmu0_pllinit_r0(cc, crystalfreq); + break; case 0x5354: + if (crystalfreq == 0) + crystalfreq = 25000; ssb_pmu0_pllinit_r0(cc, crystalfreq); break; case 0x4322: @@ -607,3 +614,34 @@ void ssb_pmu_set_ldo_paref(struct ssb_chipcommon *cc, bool on) EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage); EXPORT_SYMBOL(ssb_pmu_set_ldo_paref); + +u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc) +{ + struct ssb_bus *bus = cc->dev->bus; + + switch (bus->chip_id) { + case 0x5354: + /* 5354 chip uses a non programmable PLL of frequency 240MHz */ + return 240000000; + default: + ssb_printk(KERN_ERR PFX + "ERROR: PMU cpu clock unknown for device %04X\n", + bus->chip_id); + return 0; + } +} + +u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc) +{ + struct ssb_bus *bus = cc->dev->bus; + + switch (bus->chip_id) { + case 0x5354: + return 120000000; + default: + ssb_printk(KERN_ERR PFX + "ERROR: PMU controlclock unknown for device %04X\n", + bus->chip_id); + return 0; + } +} diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c index ced501568594..7e2ddc042f5b 100644 --- a/drivers/ssb/driver_mipscore.c +++ b/drivers/ssb/driver_mipscore.c @@ -208,6 +208,9 @@ u32 ssb_cpu_clock(struct ssb_mipscore *mcore) struct ssb_bus *bus = mcore->dev->bus; u32 pll_type, n, m, rate = 0; + if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU) + return ssb_pmu_get_cpu_clock(&bus->chipco); + if (bus->extif.dev) { ssb_extif_get_clockcontrol(&bus->extif, &pll_type, &n, &m); } else if (bus->chipco.dev) { diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index bb6317fb925c..2a0a1b99e0e4 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -1094,6 +1094,9 @@ u32 ssb_clockspeed(struct ssb_bus *bus) u32 plltype; u32 clkctl_n, clkctl_m; + if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU) + return ssb_pmu_get_controlclock(&bus->chipco); + if (ssb_extif_available(&bus->extif)) ssb_extif_get_clockcontrol(&bus->extif, &plltype, &clkctl_n, &clkctl_m); diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h index 77653014db0b..a305550b4b65 100644 --- a/drivers/ssb/ssb_private.h +++ b/drivers/ssb/ssb_private.h @@ -207,4 +207,8 @@ static inline void b43_pci_ssb_bridge_exit(void) } #endif /* CONFIG_SSB_B43_PCI_BRIDGE */ +/* driver_chipcommon_pmu.c */ +extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc); +extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc); + #endif /* LINUX_SSB_PRIVATE_H_ */ -- GitLab From 910570b5f4dbf75b73389010704ca6442a767a41 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 1 Feb 2012 10:42:11 +0300 Subject: [PATCH 0411/1846] mac80211: off by one in mcs mask handling "ridx" is used as an index into the mcs_mask[] array which has IEEE80211_HT_MCS_MASK_LEN elements. Signed-off-by: Dan Carpenter Signed-off-by: John W. Linville --- net/mac80211/rate.c | 2 +- net/wireless/nl80211.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index 3fef26d8898a..22fc28e9026e 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -324,7 +324,7 @@ static bool rate_idx_match_mcs_mask(struct ieee80211_tx_rate *rate, rbit = rate->idx % 8; /* sanity check */ - if (ridx < 0 || ridx > IEEE80211_HT_MCS_MASK_LEN) + if (ridx < 0 || ridx >= IEEE80211_HT_MCS_MASK_LEN) return false; /* See whether the selected rate or anything below it is allowed. */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index f1681e2c5949..fe2747653564 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5410,7 +5410,7 @@ static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband, rbit = BIT(rates[i] % 8); /* check validity */ - if ((ridx < 0) || (ridx > IEEE80211_HT_MCS_MASK_LEN)) + if ((ridx < 0) || (ridx >= IEEE80211_HT_MCS_MASK_LEN)) return false; /* check availability */ -- GitLab From 291689fcfbf0046d17c83c36fc983400f499dec3 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 1 Feb 2012 10:43:31 +0300 Subject: [PATCH 0412/1846] ath9k: cleanup a min_t() cast If the firmware was over 2G, it would cause memory corruption and the system would die here. Obviously we all know the firmware isn't going to be that large but static checkers get upset. Signed-off-by: Dan Carpenter Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hif_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c index f317515d8bf3..424aabb2c730 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c @@ -981,7 +981,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) return -ENOMEM; while (len) { - transfer = min_t(int, len, 4096); + transfer = min_t(size_t, len, 4096); memcpy(buf, data, transfer); err = usb_control_msg(hif_dev->udev, -- GitLab From 197a4e4e1f7ef11458f09b4dd74397baf6758133 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Wed, 1 Feb 2012 16:19:54 +0530 Subject: [PATCH 0413/1846] mwl8k: Remove BSSID from the firmware when the BSS is stopped Using command DEL_MAC_ADDR, remove the mac address of the BSS when it is stopped i.e the corresponding vif is removed. Without this, the stale bss entry will still be maintained in the firmware which causes issues when the BSS's are recreated. Signed-off-by: Nishant Sarmukadam Signed-off-by: Yogesh Ashok Powar Signed-off-by: John W. Linville --- drivers/net/wireless/mwl8k.c | 38 +++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index fd125473be7a..ac7c983f1638 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c @@ -402,6 +402,7 @@ static const struct ieee80211_rate mwl8k_rates_50[] = { #define MWL8K_CMD_SET_MAC_ADDR 0x0202 /* per-vif */ #define MWL8K_CMD_SET_RATEADAPT_MODE 0x0203 #define MWL8K_CMD_GET_WATCHDOG_BITMAP 0x0205 +#define MWL8K_CMD_DEL_MAC_ADDR 0x0206 /* per-vif */ #define MWL8K_CMD_BSS_START 0x1100 /* per-vif */ #define MWL8K_CMD_SET_NEW_STN 0x1111 /* per-vif */ #define MWL8K_CMD_UPDATE_ENCRYPTION 0x1122 /* per-vif */ @@ -3430,10 +3431,7 @@ static int mwl8k_cmd_enable_sniffer(struct ieee80211_hw *hw, bool enable) return rc; } -/* - * CMD_SET_MAC_ADDR. - */ -struct mwl8k_cmd_set_mac_addr { +struct mwl8k_cmd_update_mac_addr { struct mwl8k_cmd_pkt header; union { struct { @@ -3449,12 +3447,12 @@ struct mwl8k_cmd_set_mac_addr { #define MWL8K_MAC_TYPE_PRIMARY_AP 2 #define MWL8K_MAC_TYPE_SECONDARY_AP 3 -static int mwl8k_cmd_set_mac_addr(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u8 *mac) +static int mwl8k_cmd_update_mac_addr(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u8 *mac, bool set) { struct mwl8k_priv *priv = hw->priv; struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif); - struct mwl8k_cmd_set_mac_addr *cmd; + struct mwl8k_cmd_update_mac_addr *cmd; int mac_type; int rc; @@ -3475,7 +3473,11 @@ static int mwl8k_cmd_set_mac_addr(struct ieee80211_hw *hw, if (cmd == NULL) return -ENOMEM; - cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_MAC_ADDR); + if (set) + cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_MAC_ADDR); + else + cmd->header.code = cpu_to_le16(MWL8K_CMD_DEL_MAC_ADDR); + cmd->header.length = cpu_to_le16(sizeof(*cmd)); if (priv->ap_fw) { cmd->mbss.mac_type = cpu_to_le16(mac_type); @@ -3490,6 +3492,24 @@ static int mwl8k_cmd_set_mac_addr(struct ieee80211_hw *hw, return rc; } +/* + * MWL8K_CMD_SET_MAC_ADDR. + */ +static inline int mwl8k_cmd_set_mac_addr(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u8 *mac) +{ + return mwl8k_cmd_update_mac_addr(hw, vif, mac, true); +} + +/* + * MWL8K_CMD_DEL_MAC_ADDR. + */ +static inline int mwl8k_cmd_del_mac_addr(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u8 *mac) +{ + return mwl8k_cmd_update_mac_addr(hw, vif, mac, false); +} + /* * CMD_SET_RATEADAPT_MODE. */ @@ -4542,7 +4562,7 @@ static void mwl8k_remove_interface(struct ieee80211_hw *hw, if (priv->ap_fw) mwl8k_cmd_set_new_stn_del(hw, vif, vif->addr); - mwl8k_cmd_set_mac_addr(hw, vif, "\x00\x00\x00\x00\x00\x00"); + mwl8k_cmd_del_mac_addr(hw, vif, vif->addr); mwl8k_remove_vif(priv, mwl8k_vif); } -- GitLab From 477778bb0e7c671860528946b412294684337c5e Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Wed, 1 Feb 2012 20:41:44 -0800 Subject: [PATCH 0414/1846] mwifiex: fix NULL pointer dereference in set_channel() In set_channel() callback handler, "priv" pointer is derived from net_device. Sometimes net_device pointer coming from the stack is NULL which causes kernel crash. This patch fixes the problem by deriving "priv" from wiphy when net_device pointer is NULL. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 6fef4925d13a..54e45c829c53 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -376,7 +376,12 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type) { - struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); + struct mwifiex_private *priv; + + if (dev) + priv = mwifiex_netdev_get_priv(dev); + else + priv = mwifiex_cfg80211_get_priv(wiphy); if (priv->media_connected) { wiphy_err(wiphy, "This setting is valid only when station " -- GitLab From 3dc5e1751803e812806d7aa46150af92f91ef489 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Wed, 1 Feb 2012 20:41:45 -0800 Subject: [PATCH 0415/1846] mwifiex: enable HT operating mode This patch sets default adapter channel_type as HT. Hence the device will opearate in HT mode. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index e13b6d99171a..83cc10fca4bd 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c @@ -280,6 +280,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) adapter->adhoc_awake_period = 0; memset(&adapter->arp_filter, 0, sizeof(adapter->arp_filter)); adapter->arp_filter_size = 0; + adapter->channel_type = NL80211_CHAN_HT20; } /* -- GitLab From 885bd8eca6ac172e299750d99bd5c9fddbed89b9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 2 Feb 2012 17:44:55 +0200 Subject: [PATCH 0416/1846] mac80211: support hw scan while idle Currently, mac80211 goes to idle-off before starting a scan. However, some devices that implement hw scan might not need going idle-off in order to perform a hw scan, and thus saving some energy and simplifying their state machine. (Note that this is also the case for sched scan - it currently doesn't make mac80211 go idle-off) Add a new flag to indicate support for hw scan while idle. Signed-off-by: Eliad Peller Signed-off-by: John W. Linville --- include/net/mac80211.h | 5 +++++ net/mac80211/debugfs.c | 2 ++ net/mac80211/iface.c | 3 ++- net/mac80211/main.c | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 922313f0b39b..cbff4f94a200 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1164,6 +1164,10 @@ enum sta_notify_cmd { * @IEEE80211_HW_TX_AMPDU_SETUP_IN_HW: The device handles TX A-MPDU session * setup strictly in HW. mac80211 should not attempt to do this in * software. + * + * @IEEE80211_HW_SCAN_WHILE_IDLE: The device can do hw scan while + * being idle (i.e. mac80211 doesn't have to go idle-off during the + * the scan). */ enum ieee80211_hw_flags { IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, @@ -1190,6 +1194,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, IEEE80211_HW_AP_LINK_PS = 1<<22, IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, + IEEE80211_HW_SCAN_WHILE_IDLE = 1<<24, }; /** diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index affe64be9092..483e96ed95c1 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -263,6 +263,8 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf, sf += snprintf(buf + sf, mxln - sf, "AP_LINK_PS\n"); if (local->hw.flags & IEEE80211_HW_TX_AMPDU_SETUP_IN_HW) sf += snprintf(buf + sf, mxln - sf, "TX_AMPDU_SETUP_IN_HW\n"); + if (local->hw.flags & IEEE80211_HW_SCAN_WHILE_IDLE) + sf += snprintf(buf + sf, mxln - sf, "SCAN_WHILE_IDLE\n"); rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); kfree(buf); diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 19f0818eba78..6b3cd65d1e07 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1332,7 +1332,8 @@ u32 __ieee80211_recalc_idle(struct ieee80211_local *local) wk->sdata->vif.bss_conf.idle = false; } - if (local->scan_sdata) { + if (local->scan_sdata && + !(local->hw.flags & IEEE80211_HW_SCAN_WHILE_IDLE)) { scanning = true; local->scan_sdata->vif.bss_conf.idle = false; } diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 362e89d6d467..831a5bd44fd0 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -697,6 +697,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) ) return -EINVAL; + if ((hw->flags & IEEE80211_HW_SCAN_WHILE_IDLE) && !local->ops->hw_scan) + return -EINVAL; + if (hw->max_report_rates == 0) hw->max_report_rates = hw->max_rates; -- GitLab From 3d86b93064c7f18378a2008bab9608ca7d11bdbb Mon Sep 17 00:00:00 2001 From: Tim Gardner Date: Thu, 2 Feb 2012 13:48:06 -0700 Subject: [PATCH 0417/1846] rtlwifi: Fix PCI probe error path orphaned memory Memory allocated by ieee80211_alloc_hw() will get orphaned if any subsequent initializations fail. Also don't pci_set_drvdata(pdev, NULL) until just before disabling the PCI device. Functions called by rtl_deinit_core(hw) may eventually need the context (when its actually implemented). Cc: Larry Finger Cc: Chaoming Li Cc: John W. Linville Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Tim Gardner Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 9a0190944de5..c5f6a322feb2 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1758,8 +1758,8 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { RT_ASSERT(false, "Unable to obtain 32bit DMA for consistent allocations\n"); - pci_disable_device(pdev); - return -ENOMEM; + err = -ENOMEM; + goto fail1; } } @@ -1801,7 +1801,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, err = pci_request_regions(pdev, KBUILD_MODNAME); if (err) { RT_ASSERT(false, "Can't obtain PCI resources\n"); - goto fail2; + goto fail1; } pmem_start = pci_resource_start(pdev, rtlpriv->cfg->bar_id); @@ -1814,6 +1814,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, rtlpriv->cfg->bar_id, pmem_len); if (rtlpriv->io.pci_mem_start == 0) { RT_ASSERT(false, "Can't map PCI mem\n"); + err = -ENOMEM; goto fail2; } @@ -1830,8 +1831,10 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, pci_write_config_byte(pdev, 0x04, 0x07); /* find adapter */ - if (!_rtl_pci_find_adapter(pdev, hw)) + if (!_rtl_pci_find_adapter(pdev, hw)) { + err = -ENODEV; goto fail3; + } /* Init IO handler */ _rtl_pci_io_handler_init(&pdev->dev, hw); @@ -1841,6 +1844,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, if (rtlpriv->cfg->ops->init_sw_vars(hw)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n"); + err = -ENODEV; goto fail3; } @@ -1885,7 +1889,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, return 0; fail3: - pci_set_drvdata(pdev, NULL); rtl_deinit_core(hw); _rtl_pci_io_handler_release(hw); @@ -1897,10 +1900,12 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, complete(&rtlpriv->firmware_loading_complete); fail1: - + if (hw) + ieee80211_free_hw(hw); + pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); - return -ENODEV; + return err; } EXPORT_SYMBOL(rtl_pci_probe); -- GitLab From f3c8d2591fa7278abe58ee0278a41d5b130d1718 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Thu, 2 Feb 2012 20:48:57 -0800 Subject: [PATCH 0418/1846] mwifiex: cleanup in snmp_mib command preparation code 1) Remove unnecessary switch case usage. 2) Replace "X=cpu_to_le16(le16_to_cpu(X) + Y)" by "le16_add_cpu(X, Y)" 3) Declare "ul_temp" variable as u16 instead of u32 to avoid unnecessary typecasting Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sta_cmd.c | 60 ++++---------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c index 6e443ffa0465..324c651527cb 100644 --- a/drivers/net/wireless/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/mwifiex/sta_cmd.c @@ -103,7 +103,7 @@ static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, u16 cmd_action, u32 cmd_oid, - u32 *ul_temp) + u16 *ul_temp) { struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib; @@ -112,62 +112,18 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib) - 1 + S_DS_GEN); + snmp_mib->oid = cpu_to_le16((u16)cmd_oid); if (cmd_action == HostCmd_ACT_GEN_GET) { snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET); snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE); - cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) - + MAX_SNMP_BUF_SIZE); + le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE); + } else if (cmd_action == HostCmd_ACT_GEN_SET) { + snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); + snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); + *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp); + le16_add_cpu(&cmd->size, sizeof(u16)); } - switch (cmd_oid) { - case FRAG_THRESH_I: - snmp_mib->oid = cpu_to_le16((u16) FRAG_THRESH_I); - if (cmd_action == HostCmd_ACT_GEN_SET) { - snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); - snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); - *((__le16 *) (snmp_mib->value)) = - cpu_to_le16((u16) *ul_temp); - cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) - + sizeof(u16)); - } - break; - case RTS_THRESH_I: - snmp_mib->oid = cpu_to_le16((u16) RTS_THRESH_I); - if (cmd_action == HostCmd_ACT_GEN_SET) { - snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); - snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); - *(__le16 *) (snmp_mib->value) = - cpu_to_le16((u16) *ul_temp); - cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) - + sizeof(u16)); - } - break; - - case SHORT_RETRY_LIM_I: - snmp_mib->oid = cpu_to_le16((u16) SHORT_RETRY_LIM_I); - if (cmd_action == HostCmd_ACT_GEN_SET) { - snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); - snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); - *((__le16 *) (snmp_mib->value)) = - cpu_to_le16((u16) *ul_temp); - cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) - + sizeof(u16)); - } - break; - case DOT11D_I: - snmp_mib->oid = cpu_to_le16((u16) DOT11D_I); - if (cmd_action == HostCmd_ACT_GEN_SET) { - snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); - snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); - *((__le16 *) (snmp_mib->value)) = - cpu_to_le16((u16) *ul_temp); - cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) - + sizeof(u16)); - } - break; - default: - break; - } dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x," " Value=0x%x\n", -- GitLab From caf60a6c957e7a35837a41f845e57b4433e20276 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Thu, 2 Feb 2012 20:48:58 -0800 Subject: [PATCH 0419/1846] mwifiex: update correct dtim_period in dump_station() Earlier we were using dtim period extracted from scan response buffer provided by FW in scan operation. But it is observed that sometimes the buffer doesn't contain dtim period tlv, and wrong value (0) was sent to user space. After association FW will start listening to beacon frames of connected AP and store dtim period. Therefore we can get it from FW in dump_station() instead of using wrong value obtained in scanning. Redundant code after adapting new approach for dtim period is also removed in this patch. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 8 ++++++-- drivers/net/wireless/mwifiex/main.h | 2 +- drivers/net/wireless/mwifiex/scan.c | 6 ------ drivers/net/wireless/mwifiex/sta_cmdresp.c | 3 +++ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 54e45c829c53..478d2f12c024 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -539,6 +539,11 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, ret = -EFAULT; } + /* Get DTIM period information from firmware */ + mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, + HostCmd_ACT_GEN_GET, DTIM_PERIOD_I, + &priv->dtim_period); + /* * Bit 0 in tx_htinfo indicates that current Tx rate is 11n rate. Valid * MCS index values for us are 0 to 7. @@ -573,8 +578,7 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, WLAN_CAPABILITY_SHORT_SLOT_TIME) sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; - sinfo->bss_param.dtim_period = - priv->curr_bss_params.bss_descriptor.dtim_period; + sinfo->bss_param.dtim_period = priv->dtim_period; sinfo->bss_param.beacon_interval = priv->curr_bss_params.bss_descriptor.beacon_period; } diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 3dc0f721c1db..52810b1497ea 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -249,7 +249,6 @@ struct mwifiex_bssdescriptor { u32 channel; u32 freq; u16 beacon_period; - u8 dtim_period; u8 erp_flags; u32 bss_mode; u8 supported_rates[MWIFIEX_SUPPORTED_RATES]; @@ -392,6 +391,7 @@ struct mwifiex_private { u8 prev_bssid[ETH_ALEN]; struct mwifiex_current_bss_params curr_bss_params; u16 beacon_period; + u8 dtim_period; u16 listen_interval; u16 atim_window; u8 adhoc_channel; diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 135208596aff..98f1ca9cd6d8 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -1086,7 +1086,6 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, struct ieee_types_vendor_specific *vendor_ie; const u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 }; const u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 }; - struct ieee80211_tim_ie *tim_ie; found_data_rate_ie = false; rate_size = 0; @@ -1259,11 +1258,6 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, sizeof(struct ieee_types_header) - bss_entry->beacon_buf); break; - case WLAN_EID_TIM: - tim_ie = (void *) (current_ptr + - sizeof(struct ieee_types_header)); - bss_entry->dtim_period = tim_ie->dtim_period; - break; default: break; } diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c index e812db8b695c..0d8618a8443f 100644 --- a/drivers/net/wireless/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c @@ -210,6 +210,9 @@ static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, dev_dbg(priv->adapter->dev, "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp); break; + case DTIM_PERIOD_I: + dev_dbg(priv->adapter->dev, + "info: SNMP_RESP: DTIM period=%u\n", ul_temp); default: break; } -- GitLab From c8b03958d4b23dc48932ec095a391f3d6447e0e9 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:37 +0100 Subject: [PATCH 0420/1846] iwlegacy: move rxon commands out of ctx structure Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 82 +++++------ drivers/net/wireless/iwlegacy/3945-rs.c | 2 +- drivers/net/wireless/iwlegacy/3945.c | 22 +-- drivers/net/wireless/iwlegacy/4965-calib.c | 6 +- drivers/net/wireless/iwlegacy/4965-mac.c | 31 ++-- drivers/net/wireless/iwlegacy/4965.c | 99 +++++++------ drivers/net/wireless/iwlegacy/common.c | 157 ++++++++++----------- drivers/net/wireless/iwlegacy/common.h | 30 ++-- drivers/net/wireless/iwlegacy/debug.c | 4 +- 9 files changed, 205 insertions(+), 228 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 54b2d391e91a..980566fdb81a 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -672,15 +672,13 @@ 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->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)); + le16_to_cpu(il->timing.beacon_interval)); memset(&spectrum, 0, sizeof(spectrum)); @@ -694,15 +692,14 @@ 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)); + le16_to_cpu(il->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) + if (il->active.flags & RXON_FLG_BAND_24G_MSK) spectrum.flags |= RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; @@ -2150,7 +2147,6 @@ 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"); @@ -2206,13 +2202,13 @@ 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 *)(&il->active); - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il->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); + il_connection_init_rx_config(il, &il->ctx); } /* Configure Bluetooth device coexistence support */ @@ -2221,7 +2217,7 @@ il3945_alive_start(struct il_priv *il) set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ - il3945_commit_rxon(il, ctx); + il3945_commit_rxon(il, &il->ctx); il3945_reg_txpower_periodic(il); @@ -2670,7 +2666,7 @@ il3945_post_scan(struct il_priv *il) * 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))) + if (memcmp(&il->staging, &il->active, sizeof(il->staging))) il3945_commit_rxon(il, ctx); } @@ -2728,7 +2724,7 @@ il3945_post_associate(struct il_priv *il) return; D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, - ctx->active.bssid_addr); + il->active.bssid_addr); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -2737,30 +2733,30 @@ il3945_post_associate(struct il_priv *il) conf = &il->hw->conf; - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il3945_commit_rxon(il, ctx); rc = il_send_rxon_timing(il, ctx); if (rc) IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); + il->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; + il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { if (ctx->vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } il3945_commit_rxon(il, ctx); @@ -2902,7 +2898,7 @@ il3945_config_ap(struct il_priv *il) if (!(il_is_associated(il))) { /* RXON - unassoc (to set timing command) */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il3945_commit_rxon(il, ctx); /* RXON Timing */ @@ -2911,21 +2907,21 @@ il3945_config_ap(struct il_priv *il) IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); - ctx->staging.assoc_id = 0; + il->staging.assoc_id = 0; if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } /* restore RXON assoc */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; il3945_commit_rxon(il, ctx); } il3945_send_beacon_cmd(il); @@ -3032,7 +3028,6 @@ il3945_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, { 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)) \ @@ -3052,8 +3047,8 @@ il3945_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, mutex_lock(&il->mutex); - ctx->staging.filter_flags &= ~filter_nand; - ctx->staging.filter_flags |= filter_or; + il->staging.filter_flags &= ~filter_nand; + il->staging.filter_flags |= filter_or; /* * Not committing directly because hardware can perform a scan, @@ -3170,9 +3165,8 @@ 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); + return sprintf(buf, "0x%04X\n", il->active.flags); } static ssize_t @@ -3181,17 +3175,16 @@ il3945_store_flags(struct device *d, struct device_attribute *attr, { 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) { + if (le32_to_cpu(il->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); + il->staging.flags = cpu_to_le32(flags); + il3945_commit_rxon(il, &il->ctx); } } mutex_unlock(&il->mutex); @@ -3207,9 +3200,8 @@ 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(il->active.filter_flags)); } static ssize_t @@ -3217,19 +3209,18 @@ 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) { + if (le32_to_cpu(il->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); + il->staging.filter_flags = cpu_to_le32(filter_flags); + il3945_commit_rxon(il, &il->ctx); } } mutex_unlock(&il->mutex); @@ -3278,9 +3269,8 @@ 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), + .channel = le16_to_cpu(il->active.channel), .start_time = cpu_to_le64(il->_3945.last_tsf), .duration = cpu_to_le16(1), }; diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index d7a83f229190..40d17d7fcfef 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -944,7 +944,7 @@ 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->active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; } else diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 1489b1573a6a..dc0433f6801c 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -1388,7 +1388,7 @@ 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, + .channel = il->active.channel, }; u16 chan; @@ -1397,7 +1397,7 @@ il3945_send_tx_power(struct il_priv *il) "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(il->ctx.active.channel); + chan = le16_to_cpu(il->active.channel); txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); @@ -1673,8 +1673,8 @@ il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) .flags = CMD_WANT_SKB, .data = &rxon_assoc, }; - const struct il_rxon_cmd *rxon1 = &ctx->staging; - const struct il_rxon_cmd *rxon2 = &ctx->active; + const struct il_rxon_cmd *rxon1 = &il->staging; + const struct il_rxon_cmd *rxon2 = &il->active; if (rxon1->flags == rxon2->flags && rxon1->filter_flags == rxon2->filter_flags && @@ -1684,10 +1684,10 @@ il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) 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.flags = il->staging.flags; + rxon_assoc.filter_flags = il->staging.filter_flags; + rxon_assoc.ofdm_basic_rates = il->staging.ofdm_basic_rates; + rxon_assoc.cck_basic_rates = il->staging.cck_basic_rates; rxon_assoc.reserved = 0; rc = il_send_cmd_sync(il, &cmd); @@ -1717,8 +1717,8 @@ 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; + struct il3945_rxon_cmd *active_rxon = (void *)&il->active; + struct il3945_rxon_cmd *staging_rxon = (void *)&il->staging; int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); @@ -1776,7 +1776,7 @@ 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); + &il->active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index d3248e3ef23b..f302a6ac6286 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -806,8 +806,6 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) unsigned long flags; struct stats_rx_non_phy *rx_info; - struct il_rxon_context *ctx = &il->ctx; - if (il->disable_chain_noise_cal) return; @@ -833,8 +831,8 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) return; } - rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); - rxon_chnum = le16_to_cpu(ctx->staging.channel); + rxon_band24 = !!(il->staging.flags & RXON_FLG_BAND_24G_MSK); + rxon_chnum = le16_to_cpu(il->staging.channel); stat_band24 = !!(((struct il_notif_stats *)stat_resp)-> diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 1667232af647..6a77f41dd367 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -926,8 +926,7 @@ 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->ctx.active. - flags & RXON_FLG_CHANNEL_MODE_MSK) >> + le32_to_cpu(il->active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { rate = RATE_6M_PLCP; @@ -1164,14 +1163,14 @@ il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) 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); + il->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; + il->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; else - ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; + il->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", il->staging.rx_chain, active_rx_cnt, idle_rx_cnt); WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || @@ -3378,7 +3377,7 @@ 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) + if (il->active.rx_chain != il->staging.rx_chain) il_commit_rxon(il, &il->ctx); } } @@ -5019,11 +5018,11 @@ il4965_alive_start(struct il_priv *il) il->active_rate = RATES_MASK; - if (il_is_associated_ctx(ctx)) { + if (il_is_associated(il)) { struct il_rxon_cmd *active_rxon = - (struct il_rxon_cmd *)&ctx->active; + (struct il_rxon_cmd *)&il->active; /* apply any changes in staging */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ @@ -5768,14 +5767,14 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) goto out; - if (!il_is_associated_ctx(ctx)) + if (!il_is_associated(il)) goto out; if (!il->cfg->ops->lib->set_channel_switch) goto out; ch = channel->hw_value; - if (le16_to_cpu(ctx->active.channel) == ch) + if (le16_to_cpu(il->active.channel) == ch) goto out; ch_info = il_get_channel_info(il, channel->band, ch); @@ -5807,8 +5806,8 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, } else ctx->ht.is_40mhz = false; - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; + if ((le16_to_cpu(il->staging.channel) != ch)) + il->staging.flags = 0; il_set_rxon_channel(il, channel, ctx); il_set_rxon_ht(il, ht_conf); @@ -5860,8 +5859,8 @@ il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, mutex_lock(&il->mutex); - il->ctx.staging.filter_flags &= ~filter_nand; - il->ctx.staging.filter_flags |= filter_or; + il->staging.filter_flags &= ~filter_nand; + il->staging.filter_flags |= filter_or; /* * Not committing directly because hardware can perform a scan, diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index cacbc03880b0..b34de1433123 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1342,7 +1342,6 @@ 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->ctx; if (WARN_ONCE (test_bit(S_SCAN_HW, &il->status), @@ -1351,16 +1350,16 @@ il4965_send_tx_power(struct il_priv *il) band = il->band == IEEE80211_BAND_2GHZ; - is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); + is_ht40 = iw4965_is_ht40_channel(il->active.flags); - if (is_ht40 && (ctx->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + if (is_ht40 && (il->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) ctrl_chan_high = 1; cmd.band = band; - cmd.channel = ctx->active.channel; + cmd.channel = il->active.channel; ret = - il4965_fill_txpower_tbl(il, band, le16_to_cpu(ctx->active.channel), + il4965_fill_txpower_tbl(il, band, le16_to_cpu(il->active.channel), is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; @@ -1376,8 +1375,8 @@ 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; + const struct il_rxon_cmd *rxon1 = &il->staging; + const struct il_rxon_cmd *rxon2 = &il->active; if (rxon1->flags == rxon2->flags && rxon1->filter_flags == rxon2->filter_flags && @@ -1392,16 +1391,16 @@ il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) 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.flags = il->staging.flags; + rxon_assoc.filter_flags = il->staging.filter_flags; + rxon_assoc.ofdm_basic_rates = il->staging.ofdm_basic_rates; + rxon_assoc.cck_basic_rates = il->staging.cck_basic_rates; rxon_assoc.reserved = 0; rxon_assoc.ofdm_ht_single_stream_basic_rates = - ctx->staging.ofdm_ht_single_stream_basic_rates; + il->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; + il->staging.ofdm_ht_dual_stream_basic_rates; + rxon_assoc.rx_chain_select_flags = il->staging.rx_chain; ret = il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc), @@ -1414,9 +1413,9 @@ 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; + struct il_rxon_cmd *active_rxon = (void *)&il->active; int ret; - bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); + bool new_assoc = !!(il->staging.filter_flags & RXON_FILTER_ASSOC_MSK); if (!il_is_alive(il)) return -EBUSY; @@ -1425,7 +1424,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) return 0; /* always get timestamp with Rx frame */ - ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; + il->staging.flags |= RXON_FLG_TSF2HOST_MSK; ret = il_check_rxon_cmd(il, ctx); if (ret) { @@ -1438,7 +1437,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * abort any previous channel switch if still in process */ if (test_bit(S_CHANNEL_SWITCH_PENDING, &il->status) && - il->switch_channel != ctx->staging.channel) { + il->switch_channel != il->staging.channel) { D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); il_chswitch_done(il, false); @@ -1454,7 +1453,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) return ret; } - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + memcpy(active_rxon, &il->staging, sizeof(*active_rxon)); il_print_rx_config_cmd(il, ctx); /* * We do not commit tx power settings while channel changing, @@ -1468,7 +1467,7 @@ il4965_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_ctx(ctx) && 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; @@ -1494,7 +1493,7 @@ 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); + le16_to_cpu(il->staging.channel), il->staging.bssid_addr); il_set_rxon_hwcrypto(il, ctx, !il->cfg->mod_params->sw_crypto); @@ -1505,13 +1504,13 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) if (!new_assoc) { ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); + sizeof(struct il_rxon_cmd), &il->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)); + memcpy(active_rxon, &il->staging, sizeof(*active_rxon)); il_clear_ucode_stations(il, ctx); il_restore_stations(il, ctx); ret = il4965_restore_default_wep_keys(il, ctx); @@ -1527,12 +1526,12 @@ 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); + sizeof(struct il_rxon_cmd), &il->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); return ret; } - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + memcpy(active_rxon, &il->staging, sizeof(*active_rxon)); } il_print_rx_config_cmd(il, ctx); @@ -1564,21 +1563,21 @@ il4965_hw_channel_switch(struct il_priv *il, u16 ch; u32 tsf_low; u8 switch_count; - u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); + u16 beacon_interval = le16_to_cpu(il->timing.beacon_interval); struct ieee80211_vif *vif = ctx->vif; band = il->band == IEEE80211_BAND_2GHZ; - is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); + is_ht40 = iw4965_is_ht40_channel(il->staging.flags); - if (is_ht40 && (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + if (is_ht40 && (il->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; + cmd.rxon_flags = il->staging.flags; + cmd.rxon_filter_flags = il->staging.filter_flags; switch_count = ch_switch->count; tsf_low = ch_switch->timestamp & 0x0ffffffff; /* @@ -1611,7 +1610,7 @@ il4965_hw_channel_switch(struct il_priv *il, cmd.expect_beacon = il_is_channel_radar(ch_info); else { IL_ERR("invalid channel switch from %u to %u\n", - ctx->active.channel, ch); + il->active.channel, ch); return -EFAULT; } @@ -2139,7 +2138,7 @@ il4965_post_scan(struct il_priv *il) * 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))) + if (memcmp(&il->staging, &il->active, sizeof(il->staging))) il_commit_rxon(il, ctx); } @@ -2161,41 +2160,41 @@ il4965_post_associate(struct il_priv *il) conf = &il->hw->conf; - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il->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->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); + il->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; + il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + il->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); + il->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: @@ -2233,10 +2232,10 @@ il4965_config_ap(struct il_priv *il) return; /* The following should be done only at AP bring up */ - if (!il_is_associated_ctx(ctx)) { + if (!il_is_associated(il)) { /* RXON - unassoc (to set timing command) */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il_commit_rxon(il, ctx); /* RXON Timing */ @@ -2251,23 +2250,23 @@ il4965_config_ap(struct il_priv *il) if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - ctx->staging.assoc_id = 0; + il->staging.assoc_id = 0; if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + il->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->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; il_commit_rxon(il, ctx); } il4965_send_beacon_cmd(il); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 36454d0bbeed..2b5622695cc7 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -2361,7 +2361,7 @@ il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, 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", il->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); @@ -2648,7 +2648,7 @@ il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, * 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->active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) @@ -3581,7 +3581,7 @@ il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, #endif return il_is_channel_extension(il, il->band, - le16_to_cpu(ctx->staging.channel), + le16_to_cpu(il->staging.channel), ctx->ht.extension_chan_offset); } EXPORT_SYMBOL(il_is_ht40_tx_allowed); @@ -3633,10 +3633,10 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) lockdep_assert_held(&il->mutex); - memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); + memset(&il->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); + il->timing.timestamp = cpu_to_le64(il->timestamp); + il->timing.listen_interval = cpu_to_le16(conf->listen_interval); beacon_int = vif ? vif->bss_conf.beacon_int : 0; @@ -3644,28 +3644,28 @@ 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 */ - ctx->timing.atim_win = 0; + il->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); + il->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); + il->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); - ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ? : 1) : 1; + il->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)); + le16_to_cpu(il->timing.beacon_interval), + le32_to_cpu(il->timing.beacon_init_val), + le16_to_cpu(il->timing.atim_win)); - return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), - &ctx->timing); + return il_send_cmd_pdu(il, il->ctx.rxon_timing_cmd, sizeof(il->timing), + &il->timing); } EXPORT_SYMBOL(il_send_rxon_timing); @@ -3673,7 +3673,7 @@ void il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, int hw_decrypt) { - struct il_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &il->staging; if (hw_decrypt) rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; @@ -3687,7 +3687,7 @@ EXPORT_SYMBOL(il_set_rxon_hwcrypto); int il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) { - struct il_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &il->staging; bool error = false; if (rxon->flags & RXON_FLG_BAND_24G_MSK) { @@ -3767,8 +3767,8 @@ EXPORT_SYMBOL(il_check_rxon_cmd); 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; + const struct il_rxon_cmd *staging = &il->staging; + const struct il_rxon_cmd *active = &il->active; #define CHK(cond) \ if ((cond)) { \ @@ -3785,7 +3785,7 @@ il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) } /* These items are only settable from the full RXON command */ - CHK(!il_is_associated_ctx(ctx)); + CHK(!il_is_associated(il)); CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); CHK(compare_ether_addr(staging->node_addr, active->node_addr)); CHK(compare_ether_addr @@ -3825,7 +3825,7 @@ 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) + if (il->staging.flags & RXON_FLG_BAND_24G_MSK) return RATE_1M_PLCP; else return RATE_6M_PLCP; @@ -3836,7 +3836,7 @@ 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; + struct il_rxon_cmd *rxon = &il->staging; if (!ctx->ht.enabled) { rxon->flags &= @@ -3925,7 +3925,7 @@ il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) for (i = min; i < max; i++) { channel = il->channel_info[i].channel; - if (channel == le16_to_cpu(il->ctx.staging.channel)) + if (channel == le16_to_cpu(il->staging.channel)) continue; ch_info = il_get_channel_info(il, band, channel); @@ -3951,14 +3951,14 @@ 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(il->staging.channel) == channel && il->band == band) return 0; - ctx->staging.channel = cpu_to_le16(channel); + il->staging.channel = cpu_to_le16(channel); if (band == IEEE80211_BAND_5GHZ) - ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; + il->staging.flags &= ~RXON_FLG_BAND_24G_MSK; else - ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; + il->staging.flags |= RXON_FLG_BAND_24G_MSK; il->band = band; @@ -3973,20 +3973,20 @@ 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 &= + il->staging.flags &= ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_CCK_MSK); - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + il->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; + il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + il->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; + il->staging.flags |= RXON_FLG_BAND_24G_MSK; + il->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; + il->staging.flags &= ~RXON_FLG_CCK_MSK; } } EXPORT_SYMBOL(il_set_flags_for_band); @@ -3999,22 +3999,22 @@ 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)); + memset(&il->staging, 0, sizeof(il->staging)); if (!ctx->vif) { - ctx->staging.dev_type = ctx->unused_devtype; + il->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; + il->staging.dev_type = ctx->station_devtype; + il->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 = + il->staging.dev_type = ctx->ibss_devtype; + il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK; break; @@ -4029,35 +4029,35 @@ il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) /* 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; + il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif ch_info = - il_get_channel_info(il, il->band, le16_to_cpu(ctx->active.channel)); + il_get_channel_info(il, il->band, le16_to_cpu(il->active.channel)); if (!ch_info) ch_info = &il->channel_info[0]; - ctx->staging.channel = cpu_to_le16(ch_info->channel); + il->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->staging.ofdm_basic_rates = (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - ctx->staging.cck_basic_rates = + il->staging.cck_basic_rates = (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; /* clear both MIX and PURE40 mode flag */ - ctx->staging.flags &= + il->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); + memcpy(il->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; + il->staging.ofdm_ht_single_stream_basic_rates = 0xff; + il->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } EXPORT_SYMBOL(il_connection_init_rx_config); @@ -4084,10 +4084,10 @@ il_set_rate(struct il_priv *il) D_RATE("Set active_rate = %0x\n", il->active_rate); - il->ctx.staging.cck_basic_rates = + il->staging.cck_basic_rates = (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - il->ctx.staging.ofdm_basic_rates = + il->staging.ofdm_basic_rates = (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } EXPORT_SYMBOL(il_set_rate); @@ -4110,16 +4110,14 @@ 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; + struct il_rxon_cmd *rxon = (void *)&il->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; + il->staging.channel = csa->channel; D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { @@ -4134,7 +4132,7 @@ EXPORT_SYMBOL(il_hdl_csa); void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { - struct il_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &il->staging; D_RADIO("RX CONFIG:\n"); il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); @@ -4347,7 +4345,6 @@ 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); @@ -4378,7 +4375,7 @@ 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(&il->active, &il->staging, sizeof(il->staging)); if (defer && !force) { D_INFO("Deferring tx power set\n"); return 0; @@ -5379,8 +5376,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) /* 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 ((le16_to_cpu(il->staging.channel) != ch)) + il->staging.flags = 0; il_set_rxon_channel(il, channel, ctx); il_set_rxon_ht(il, ht_conf); @@ -5420,7 +5417,7 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) if (scan_active) goto out; - if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) + if (memcmp(&il->active, &il->staging, sizeof(il->staging))) il_commit_rxon(il, ctx); else D_INFO("Not re-sending same RXON configuration.\n"); @@ -5473,7 +5470,7 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) /* we are restarting association process * clear RXON_FILTER_ASSOC_MSK bit */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il_commit_rxon(il, ctx); il_set_rate(il); @@ -5555,8 +5552,8 @@ il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) * association and that no more packets should be * sent */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ctx->staging.assoc_id = 0; + il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il->staging.assoc_id = 0; il_commit_rxon(il, ctx); } @@ -5660,13 +5657,13 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, /* 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, + memcpy(il->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; + il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; } } @@ -5682,21 +5679,21 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *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; + il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + il->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; + il->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else - ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; + il->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; if (bss_conf->use_cts_prot) - ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; + il->staging.flags |= RXON_FLG_SELF_CTS_EN; else - ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; + il->staging.flags &= ~RXON_FLG_SELF_CTS_EN; } if (changes & BSS_CHANGED_BASIC_RATES) { @@ -5706,12 +5703,12 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, * like this here: * if (A-band) - ctx->staging.ofdm_basic_rates = + il->staging.ofdm_basic_rates = bss_conf->basic_rates; else - ctx->staging.ofdm_basic_rates = + il->staging.ofdm_basic_rates = bss_conf->basic_rates >> 4; - ctx->staging.cck_basic_rates = + il->staging.cck_basic_rates = bss_conf->basic_rates & 0xF; */ } @@ -5734,19 +5731,19 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, il_set_no_assoc(il, vif); } - if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { + if (changes && il_is_associated(il) && 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, + memcpy((void *)&il->active, &il->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, + memcpy(il->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); il->cfg->ops->legacy->config_ap(il); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index abfa388588be..ba801c7d9ad4 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1171,17 +1171,6 @@ struct il_rxon_context { 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; @@ -1306,6 +1295,17 @@ struct il_priv { struct il_rxon_context ctx; + /* + * 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; + __le16 switch_channel; /* 1st responses from initialize and runtime uCode images. @@ -1530,7 +1530,7 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) static inline int il_is_associated(struct il_priv *il) { - return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; + return (il->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } static inline int @@ -1539,12 +1539,6 @@ 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) { diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index b1b8926a9c7b..6e3841beb1df 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -1153,7 +1153,7 @@ il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, 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->active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1167,7 +1167,7 @@ il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, char buf[20]; len = - sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.filter_flags)); + sprintf(buf, "0x%04X\n", le32_to_cpu(il->active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -- GitLab From 6122d18236837ed7f264632e6b27d5cb3005add2 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:38 +0100 Subject: [PATCH 0421/1846] iwlegacy: get rid of ctx->rxon_cmd Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/4965.c | 6 +++--- drivers/net/wireless/iwlegacy/common.h | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 980566fdb81a..8de8355c523c 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3619,7 +3619,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.ctxid = 0; - 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; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 6a77f41dd367..2368f3ab02b5 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6135,7 +6135,6 @@ 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 = 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; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index b34de1433123..8926108118f6 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1472,7 +1472,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; ret = - il_send_cmd_pdu(il, ctx->rxon_cmd, + il_send_cmd_pdu(il, C_RXON, sizeof(struct il_rxon_cmd), active_rxon); /* If the mask clearing failed then we set @@ -1503,7 +1503,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ if (!new_assoc) { ret = - il_send_cmd_pdu(il, ctx->rxon_cmd, + il_send_cmd_pdu(il, C_RXON, sizeof(struct il_rxon_cmd), &il->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); @@ -1525,7 +1525,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * RXON assoc doesn't clear the station table in uCode, */ ret = - il_send_cmd_pdu(il, ctx->rxon_cmd, + il_send_cmd_pdu(il, C_RXON, sizeof(struct il_rxon_cmd), &il->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index ba801c7d9ad4..80c60e57de3c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1175,7 +1175,7 @@ struct il_rxon_context { u8 bcast_sta_id, ap_sta_id; - u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; + u8 rxon_assoc_cmd, rxon_timing_cmd; u8 qos_cmd; u8 wep_key_cmd; -- GitLab From 63d0f0c5512e29f87ed2e1612bb637d857f3b345 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:39 +0100 Subject: [PATCH 0422/1846] iwlegacy: get rid of ctx->rxon_timing_cmd Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 8de8355c523c..5ca8a784436f 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3619,7 +3619,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.ctxid = 0; - 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; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2368f3ab02b5..9539acc132a3 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6135,7 +6135,6 @@ 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_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; diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 2b5622695cc7..902521469e19 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -3664,7 +3664,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) le32_to_cpu(il->timing.beacon_init_val), le16_to_cpu(il->timing.atim_win)); - return il_send_cmd_pdu(il, il->ctx.rxon_timing_cmd, sizeof(il->timing), + return il_send_cmd_pdu(il, C_RXON_TIMING, sizeof(il->timing), &il->timing); } EXPORT_SYMBOL(il_send_rxon_timing); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 80c60e57de3c..d1d505580b1d 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1175,7 +1175,7 @@ struct il_rxon_context { u8 bcast_sta_id, ap_sta_id; - u8 rxon_assoc_cmd, rxon_timing_cmd; + u8 rxon_assoc_cmd; u8 qos_cmd; u8 wep_key_cmd; -- GitLab From 5e349f02963acc2c3607119e6e64f0cbc8d23e17 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:40 +0100 Subject: [PATCH 0423/1846] iwlegacy: get rid of rxon_assoc_cmd Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/common.h | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 5ca8a784436f..e5857df2df27 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3619,7 +3619,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.ctxid = 0; - 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 = C_WEPKEY; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 9539acc132a3..bd83299be319 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6135,7 +6135,6 @@ 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_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 = C_WEPKEY; diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index d1d505580b1d..d8e309a1756a 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1175,7 +1175,6 @@ struct il_rxon_context { u8 bcast_sta_id, ap_sta_id; - u8 rxon_assoc_cmd; u8 qos_cmd; u8 wep_key_cmd; -- GitLab From b96ed60cd0c352891fd04f4aa748f4d36a6cec5b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:41 +0100 Subject: [PATCH 0424/1846] iwlegacy: get rid of qos_cmd Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index e5857df2df27..bbbac26d8f4b 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3619,7 +3619,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.ctxid = 0; - il->ctx.qos_cmd = C_QOS_PARAM; il->ctx.ap_sta_id = IL_AP_ID; il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.interface_modes = diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index bd83299be319..2ee5de38bb31 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6135,7 +6135,6 @@ 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.qos_cmd = C_QOS_PARAM; il->ctx.ap_sta_id = IL_AP_ID; il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 902521469e19..b95f832b14ea 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -5269,7 +5269,7 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) 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), + il_send_cmd_pdu_async(il, C_QOS_PARAM, sizeof(struct il_qosparam_cmd), &ctx->qos_data.def_qos_parm, NULL); } diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index d8e309a1756a..b08ddd134430 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1175,7 +1175,6 @@ struct il_rxon_context { u8 bcast_sta_id, ap_sta_id; - u8 qos_cmd; u8 wep_key_cmd; struct il_wep_key wep_keys[WEP_KEYS_MAX]; -- GitLab From d98e294231a29699848fd0e923d91fe979e13802 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:42 +0100 Subject: [PATCH 0425/1846] iwlegacy: get rid of wep_key_cmd Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 3 +-- drivers/net/wireless/iwlegacy/common.h | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index bbbac26d8f4b..4a01acbf3a27 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3620,7 +3620,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.ctxid = 0; 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); il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2ee5de38bb31..a2955a45c332 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2823,7 +2823,7 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, 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, + .id = C_WEPKEY, .data = wep_cmd, .flags = CMD_SYNC, }; @@ -6136,7 +6136,6 @@ 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.ap_sta_id = IL_AP_ID; - 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); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index b08ddd134430..46835f932bfc 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1175,8 +1175,6 @@ struct il_rxon_context { u8 bcast_sta_id, ap_sta_id; - u8 wep_key_cmd; - struct il_wep_key wep_keys[WEP_KEYS_MAX]; u8 key_mapping_keys; -- GitLab From 8f9e56455310a3d75e8239db9729acb2b31dbdad Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:43 +0100 Subject: [PATCH 0426/1846] iwlegacy: get rid of ap_sta_id Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 3 +-- drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 4a01acbf3a27..8072ae8b0ce8 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3619,7 +3619,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.ctxid = 0; - il->ctx.ap_sta_id = IL_AP_ID; il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index a2955a45c332..f2b03cd243b5 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2906,7 +2906,7 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->hw_key_idx = HW_KEY_DEFAULT; - il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[IL_AP_ID].keyinfo.cipher = keyconf->cipher; ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, @@ -6135,7 +6135,6 @@ 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.ap_sta_id = IL_AP_ID; 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); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index b95f832b14ea..d30a2062992b 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -1899,7 +1899,7 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, u16 rate; if (is_ap) - sta_id = ctx->ap_sta_id; + sta_id = IL_AP_ID; else if (is_broadcast_ether_addr(addr)) sta_id = ctx->bcast_sta_id; else diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 46835f932bfc..cf7352f45cdb 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1173,7 +1173,7 @@ struct il_rxon_context { struct il_qos_info qos_data; - u8 bcast_sta_id, ap_sta_id; + u8 bcast_sta_id; struct il_wep_key wep_keys[WEP_KEYS_MAX]; u8 key_mapping_keys; -- GitLab From b16db50a6dc486c3a6c32cd7982a75452cb785c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:44 +0100 Subject: [PATCH 0427/1846] iwlegacy: move bcast_sta_id to hw_params Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 4 ++-- drivers/net/wireless/iwlegacy/3945-rs.c | 2 +- drivers/net/wireless/iwlegacy/3945.c | 5 +++-- drivers/net/wireless/iwlegacy/4965-mac.c | 15 ++++++++------- drivers/net/wireless/iwlegacy/4965.c | 3 +-- drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 6 +++--- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 8072ae8b0ce8..b11701f58741 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -140,7 +140,7 @@ 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->ctx.bcast_sta_id) + if (sta_id == il->hw_params.bcast_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -2598,7 +2598,7 @@ 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->ctx.bcast_sta_id; + scan->tx_cmd.sta_id = il->hw_params.bcast_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 40d17d7fcfef..6a782b5c0c5f 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -342,7 +342,7 @@ il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) int i; D_INFO("enter\n"); - if (sta_id == il->ctx.bcast_sta_id) + if (sta_id == il->hw_params.bcast_id) goto out; psta = (struct il3945_sta_priv *)sta->drv_priv; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index dc0433f6801c..3024645a6be9 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2396,6 +2396,8 @@ il3945_hw_set_hw_params(struct il_priv *il) return -ENOMEM; } + il->hw_params.bcast_id = IL3945_BROADCAST_ID; + /* Assign number of Usable TX queues */ il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; @@ -2404,7 +2406,6 @@ 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->ctx.bcast_sta_id = IL3945_BROADCAST_ID; il->sta_key_max_num = STA_KEY_MAX_NUM; @@ -2425,7 +2426,7 @@ il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, 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->hw_params.bcast_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; frame_size = diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index f2b03cd243b5..af7886243fe0 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -919,7 +919,7 @@ il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) 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.sta_id = il->hw_params.bcast_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; switch (il->scan_band) { @@ -1678,7 +1678,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* For management frames use broadcast id to do not break aggregation */ if (!ieee80211_is_data(fc)) - sta_id = ctx->bcast_sta_id; + sta_id = il->hw_params.bcast_id; else { /* Find idx into station table for destination station */ sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); @@ -2938,7 +2938,7 @@ il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, if (keyconf->keylen == WEP_KEY_LEN_128) key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; - if (sta_id == ctx->bcast_sta_id) + if (sta_id == il->hw_params.bcast_id) key_flags |= STA_KEY_MULTICAST_MSK; spin_lock_irqsave(&il->sta_lock, flags); @@ -2988,7 +2988,7 @@ il4965_set_ccmp_dynamic_key_info(struct il_priv *il, 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) + if (sta_id == il->hw_params.bcast_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -3035,7 +3035,7 @@ il4965_set_tkip_dynamic_key_info(struct il_priv *il, 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) + if (sta_id == il->hw_params.bcast_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -3253,7 +3253,7 @@ 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; + u8 sta_id = il->hw_params.bcast_id; link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { @@ -3510,7 +3510,7 @@ il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) /* 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.sta_id = il->hw_params.bcast_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 | @@ -6082,6 +6082,7 @@ il4965_hw_detect(struct il_priv *il) static int il4965_set_hw_params(struct il_priv *il) { + il->hw_params.bcast_id = IL4965_BROADCAST_ID; 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) diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8926108118f6..8d0fd60bc491 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -624,7 +624,6 @@ 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->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; @@ -1968,7 +1967,7 @@ il4965_find_station(struct il_priv *il, const u8 * addr) start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return il->ctx.bcast_sta_id; + return il->hw_params.bcast_id; spin_lock_irqsave(&il->sta_lock, flags); for (i = start; i < il->hw_params.max_stations; i++) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index d30a2062992b..b7567a8063be 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -1901,7 +1901,7 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, if (is_ap) sta_id = IL_AP_ID; else if (is_broadcast_ether_addr(addr)) - sta_id = ctx->bcast_sta_id; + sta_id = il->hw_params.bcast_id; else for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { if (!compare_ether_addr diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index cf7352f45cdb..66d0c1dd5894 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -816,6 +816,7 @@ struct il_sensitivity_ranges { /** * struct il_hw_params + * @bcast_id: f/w broadcast station ID * @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 @@ -836,6 +837,7 @@ struct il_sensitivity_ranges { * @struct il_sensitivity_ranges: range of sensitivity values */ struct il_hw_params { + u8 bcast_id; u8 max_txq_num; u8 dma_chnl_num; u16 scd_bc_tbls_size; @@ -1173,8 +1175,6 @@ struct il_rxon_context { struct il_qos_info qos_data; - u8 bcast_sta_id; - struct il_wep_key wep_keys[WEP_KEYS_MAX]; u8 key_mapping_keys; @@ -2372,7 +2372,7 @@ il_sta_id_or_broadcast(struct il_priv *il, struct il_rxon_context *context, int sta_id; if (!sta) - return context->bcast_sta_id; + return il->hw_params.bcast_id; sta_id = il_sta_id(sta); -- GitLab From 0f8b90f526f097a5c897f52b3595e9af55fc9b59 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:45 +0100 Subject: [PATCH 0428/1846] iwlegacy: get rid of *_devtype Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 3 --- drivers/net/wireless/iwlegacy/4965-mac.c | 4 ---- drivers/net/wireless/iwlegacy/common.c | 6 +++--- drivers/net/wireless/iwlegacy/common.h | 1 - 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index b11701f58741..15dcafbf29da 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3621,9 +3621,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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 diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index af7886243fe0..33725e14e14e 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6140,10 +6140,6 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index b7567a8063be..19ed86771a2a 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4002,17 +4002,17 @@ il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) memset(&il->staging, 0, sizeof(il->staging)); if (!ctx->vif) { - il->staging.dev_type = ctx->unused_devtype; + il->staging.dev_type = RXON_DEV_TYPE_ESS; } else switch (ctx->vif->type) { case NL80211_IFTYPE_STATION: - il->staging.dev_type = ctx->station_devtype; + il->staging.dev_type = RXON_DEV_TYPE_ESS; il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; break; case NL80211_IFTYPE_ADHOC: - il->staging.dev_type = ctx->ibss_devtype; + il->staging.dev_type = RXON_DEV_TYPE_IBSS; il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; il->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 66d0c1dd5894..8eac5712415d 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1171,7 +1171,6 @@ struct il_rxon_context { int ctxid; u32 interface_modes, exclusive_interface_modes; - u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; struct il_qos_info qos_data; -- GitLab From 6aa0c25435e6383d4a4af88fae8d128200dcd471 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:46 +0100 Subject: [PATCH 0429/1846] iwlegacy: get rid of ctxid Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 2 -- drivers/net/wireless/iwlegacy/4965-mac.c | 2 -- drivers/net/wireless/iwlegacy/common.c | 6 ------ drivers/net/wireless/iwlegacy/common.h | 4 +--- drivers/net/wireless/iwlegacy/debug.c | 1 - 5 files changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 15dcafbf29da..52cac0cd1064 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3617,8 +3617,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->cmd_queue = IL39_CMD_QUEUE_NUM; - il->ctx.ctxid = 0; - il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 33725e14e14e..3209970cf45f 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6132,8 +6132,6 @@ 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. */ - il->ctx.ctxid = 0; - il->ctx.always_active = true; il->ctx.is_active = true; il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 19ed86771a2a..7c7ea778d219 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -1951,7 +1951,6 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, 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; @@ -2191,9 +2190,6 @@ il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) 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; @@ -2234,8 +2230,6 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) 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", diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 8eac5712415d..8df2286ea05f 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -735,7 +735,7 @@ struct il_qos_info { struct il_station_entry { struct il_addsta_cmd sta; struct il_tid_data tid[MAX_TID_COUNT]; - u8 used, ctxid; + u8 used; struct il_hw_key keyinfo; struct il_link_quality_cmd *lq; }; @@ -1168,8 +1168,6 @@ struct il_rxon_context { bool ht_need_multiple_chains; - int ctxid; - u32 interface_modes, exclusive_interface_modes; struct il_qos_info qos_data; diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 6e3841beb1df..f3cb45e53c05 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -649,7 +649,6 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, 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, -- GitLab From d1e14e942430cd42df9913337aebbcaef53e4515 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:47 +0100 Subject: [PATCH 0430/1846] iwlegacy: get rid of mcast_queue Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 17 ++++------------- drivers/net/wireless/iwlegacy/common.h | 3 --- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 3209970cf45f..ecb7b542b96c 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1708,19 +1708,10 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) 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)]; + /* FIXME: remove me ? */ + WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM); + + 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); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 8df2286ea05f..89922e0a70da 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1157,7 +1157,6 @@ struct il_rxon_context { const u8 *ac_to_fifo; const u8 *ac_to_queue; - u8 mcast_queue; /* * We could use the vif to indicate active, but we @@ -1166,8 +1165,6 @@ struct il_rxon_context { */ bool always_active, is_active; - bool ht_need_multiple_chains; - u32 interface_modes, exclusive_interface_modes; struct il_qos_info qos_data; -- GitLab From d735f9213d11e34e6ed074acea30b6743b3385e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:48 +0100 Subject: [PATCH 0431/1846] iwlegacy: move wep_keys out of context Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 58 +++++++++++++++--------- drivers/net/wireless/iwlegacy/common.h | 19 ++------ 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ecb7b542b96c..35d868c4ba92 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2808,7 +2808,7 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, bool send_if_empty) { - int i, not_empty = 0; + int i; 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; @@ -2818,6 +2818,7 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, .data = wep_cmd, .flags = CMD_SYNC, }; + bool not_empty = false; might_sleep(); @@ -2825,24 +2826,23 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, cmd_size + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); for (i = 0; i < WEP_KEYS_MAX; i++) { + u8 key_size = il->_4965.wep_keys[i].key_size; + wep_cmd->key[i].key_idx = i; - if (ctx->wep_keys[i].key_size) { + if (key_size) { wep_cmd->key[i].key_offset = i; - not_empty = 1; - } else { + not_empty = true; + } 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->key[i].key_size = key_size; + memcpy(&wep_cmd->key[i].key[3], il->_4965.wep_keys[i].key, 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) @@ -2864,19 +2864,20 @@ il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; + int idx = keyconf->keyidx; 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", idx); - memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); + memset(&il->_4965.wep_keys[idx], 0, sizeof(struct il_wep_key)); if (il_is_rfkill(il)) { 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", idx, ret); return ret; } @@ -2886,11 +2887,12 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; + int len = keyconf->keylen; + int idx = keyconf->keyidx; lockdep_assert_held(&il->mutex); - if (keyconf->keylen != WEP_KEY_LEN_128 && - keyconf->keylen != WEP_KEY_LEN_64) { + if (len != WEP_KEY_LEN_128 && len != WEP_KEY_LEN_64) { D_WEP("Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } @@ -2899,14 +2901,12 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, keyconf->hw_key_idx = HW_KEY_DEFAULT; il->stations[IL_AP_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); + il->_4965.wep_keys[idx].key_size = len; + memcpy(&il->_4965.wep_keys[idx].key, &keyconf->key, len); 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", len, idx, ret); return ret; } @@ -3106,7 +3106,7 @@ il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, lockdep_assert_held(&il->mutex); - ctx->key_mapping_keys--; + il->_4965.key_mapping_keys--; spin_lock_irqsave(&il->sta_lock, flags); key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); @@ -3164,7 +3164,7 @@ il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, lockdep_assert_held(&il->mutex); - ctx->key_mapping_keys++; + il->_4965.key_mapping_keys++; keyconf->hw_key_idx = HW_KEY_DYNAMIC; switch (keyconf->cipher) { @@ -5067,6 +5067,20 @@ __il4965_down(struct il_priv *il) del_timer_sync(&il->watchdog); il_clear_ucode_stations(il, NULL); + + /* FIXME: race conditions ? */ + spin_lock_irq(&il->sta_lock); + /* + * 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(il->_4965.wep_keys, 0, sizeof(il->_4965.wep_keys)); + il->_4965.key_mapping_keys = 0; + spin_unlock_irq(&il->sta_lock); + il_dealloc_bcast_stations(il); il_clear_driver_stations(il); @@ -5613,7 +5627,7 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 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; + is_default_wep_key = !il->_4965.key_mapping_keys; else is_default_wep_key = (key->hw_key_idx == HW_KEY_DEFAULT); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 89922e0a70da..811e768637cb 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1169,9 +1169,6 @@ struct il_rxon_context { struct il_qos_info qos_data; - struct il_wep_key wep_keys[WEP_KEYS_MAX]; - u8 key_mapping_keys; - __le32 station_flags; struct { @@ -1417,6 +1414,9 @@ struct il_priv { u8 phy_calib_chain_noise_reset_cmd; u8 phy_calib_chain_noise_gain_cmd; + u8 key_mapping_keys; + struct il_wep_key wep_keys[WEP_KEYS_MAX]; + struct il_notif_stats stats; #ifdef CONFIG_IWLEGACY_DEBUGFS struct il_notif_stats accum_stats; @@ -2318,24 +2318,11 @@ 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); } -- GitLab From fd6415bcfb303e37052c72a3f44b7f81089d7336 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:49 +0100 Subject: [PATCH 0432/1846] iwlegacy: get rid of ctx->station_flags Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 7c7ea778d219..ac269856be14 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -1950,7 +1950,7 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, 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->sta.station_flags = 0; if (sta) { struct il_station_priv_common *sta_priv; diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 811e768637cb..a872175f164c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1169,8 +1169,6 @@ struct il_rxon_context { struct il_qos_info qos_data; - __le32 station_flags; - struct { bool non_gf_sta_present; u8 protection; -- GitLab From 8c9c48d5a9ca5e1426372f8a747846bd0609dc08 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:50 +0100 Subject: [PATCH 0433/1846] iwlegacy: remove ctx interface_modes Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 6 ++--- drivers/net/wireless/iwlegacy/4965-mac.c | 6 ++--- drivers/net/wireless/iwlegacy/common.c | 29 ++++-------------------- drivers/net/wireless/iwlegacy/common.h | 2 -- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 52cac0cd1064..7c81f5aaf7a3 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3557,7 +3557,8 @@ il3945_setup_mac(struct il_priv *il) /* Tell mac80211 our characteristics */ hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SPECTRUM_MGMT; - hw->wiphy->interface_modes = il->ctx.interface_modes; + hw->wiphy->interface_modes = + BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3617,9 +3618,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->cmd_queue = IL39_CMD_QUEUE_NUM; - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - /* * Disabling hardware scan means that mac80211 will perform scans * "the hard way", rather than using device's scan. diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 35d868c4ba92..1dd001475522 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -5454,8 +5454,8 @@ il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length) 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->interface_modes = + BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS; @@ -6141,8 +6141,6 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.is_active = true; 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); SET_IEEE80211_DEV(hw, &pdev->dev); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index ac269856be14..7f4c6bf41995 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4566,7 +4566,6 @@ 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); @@ -4578,15 +4577,7 @@ 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))) { - err = -EINVAL; - goto out; - } - - modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; - if (!(modes & BIT(vif->type))) { + if (il->ctx.vif) { err = -EOPNOTSUPP; goto out; } @@ -4979,10 +4970,10 @@ il_mac_change_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); - u32 modes; int err; - newtype = ieee80211_iftype_p2p(newtype, newp2p); + if (newp2p) + return -EOPNOTSUPP; mutex_lock(&il->mutex); @@ -4995,22 +4986,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 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; + vif->p2p = false; err = il_setup_interface(il, ctx); WARN_ON(err); /* diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index a872175f164c..eddf22d4f1b2 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1165,8 +1165,6 @@ struct il_rxon_context { */ bool always_active, is_active; - u32 interface_modes, exclusive_interface_modes; - struct il_qos_info qos_data; struct { -- GitLab From 8d44f2bd7554734913f1256e4f45c35454167161 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:51 +0100 Subject: [PATCH 0434/1846] iwlegacy: move qos_data out of ctx structure Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 24 ++++++++++++------------ drivers/net/wireless/iwlegacy/common.h | 4 ++-- drivers/net/wireless/iwlegacy/debug.c | 9 ++++----- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 7f4c6bf41995..c93fa1b85da5 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4496,15 +4496,15 @@ il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, spin_lock_irqsave(&il->lock, flags); - il->ctx.qos_data.def_qos_parm.ac[q].cw_min = + il->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 = + il->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 = + il->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + il->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; + il->qos_data.def_qos_parm.ac[q].reserved1 = 0; spin_unlock_irqrestore(&il->lock, flags); @@ -5230,20 +5230,20 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) if (!ctx->is_active) return; - ctx->qos_data.def_qos_parm.qos_flags = 0; + il->qos_data.def_qos_parm.qos_flags = 0; - if (ctx->qos_data.qos_active) - ctx->qos_data.def_qos_parm.qos_flags |= + if (il->qos_data.qos_active) + il->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; + il->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->qos_data.qos_active, il->qos_data.def_qos_parm.qos_flags); il_send_cmd_pdu_async(il, C_QOS_PARAM, sizeof(struct il_qosparam_cmd), - &ctx->qos_data.def_qos_parm, NULL); + &il->qos_data.def_qos_parm, NULL); } /** @@ -5596,7 +5596,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, unsigned long flags; spin_lock_irqsave(&il->lock, flags); - ctx->qos_data.qos_active = bss_conf->qos; + il->qos_data.qos_active = bss_conf->qos; il_update_qos(il, ctx); spin_unlock_irqrestore(&il->lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index eddf22d4f1b2..18375cb7904c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1165,8 +1165,6 @@ struct il_rxon_context { */ bool always_active, is_active; - struct il_qos_info qos_data; - struct { bool non_gf_sta_present; u8 protection; @@ -1278,6 +1276,8 @@ struct il_priv { struct il_rxon_context ctx; + struct il_qos_info qos_data; + /* * We declare this const so it can only be * changed via explicit cast within the diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index f3cb45e53c05..3a9609a88748 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -644,7 +644,6 @@ 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); @@ -656,10 +655,10 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, 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); + il->qos_data.def_qos_parm.ac[i].cw_min, + il->qos_data.def_qos_parm.ac[i].cw_max, + il->qos_data.def_qos_parm.ac[i].aifsn, + il->qos_data.def_qos_parm.ac[i].edca_txop); } return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -- GitLab From 1c03c4620edc551b5bbcc87c7aca02b482d8bc51 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:52 +0100 Subject: [PATCH 0435/1846] iwlegacy: move ht out of ctx structure Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 18 ++++----- drivers/net/wireless/iwlegacy/4965-rs.c | 13 +++---- drivers/net/wireless/iwlegacy/common.c | 49 ++++++++++++------------ drivers/net/wireless/iwlegacy/common.h | 15 ++++---- 4 files changed, 46 insertions(+), 49 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 1dd001475522..94984c850e84 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -5793,23 +5793,23 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, il->current_ht_config.smps = conf->smps_mode; /* Configure HT40 channels */ - ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { + il->ht.enabled = conf_is_ht(conf); + if (il->ht.enabled) { if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; + il->ht.is_40mhz = true; } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; + il->ht.is_40mhz = true; } else { - ctx->ht.extension_chan_offset = + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; + il->ht.is_40mhz = false; } } else - ctx->ht.is_40mhz = false; + il->ht.is_40mhz = false; if ((le16_to_cpu(il->staging.channel) != ch)) il->staging.flags = 0; diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 467d0cb14ecd..ad186d9a598f 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -641,13 +641,10 @@ il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, * there are no non-GF stations present in the BSS. */ static bool -il4965_rs_use_green(struct ieee80211_sta *sta) +il4965_rs_use_green(struct il_priv *il, 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); + !il->ht.non_gf_sta_present; } /** @@ -1815,7 +1812,7 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, if (is_legacy(tbl->lq_type)) lq_sta->is_green = 0; else - lq_sta->is_green = il4965_rs_use_green(sta); + lq_sta->is_green = il4965_rs_use_green(il, sta); is_green = lq_sta->is_green; /* current tx rate */ @@ -2166,7 +2163,7 @@ il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, int rate_idx; int i; u32 rate; - u8 use_green = il4965_rs_use_green(sta); + u8 use_green = il4965_rs_use_green(il, sta); u8 active_tbl = 0; u8 valid_tx_ant; struct il_station_priv *sta_priv; @@ -2341,7 +2338,7 @@ il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) 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->is_green = il4965_rs_use_green(il, sta); lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); lq_sta->band = il->band; /* diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index c93fa1b85da5..db2e8bb11fa1 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -2352,7 +2352,7 @@ il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, { int i; - if (ctx->ht.enabled) + if (il->ht.enabled) return true; D_INFO("Channel %u is not an HT channel\n", il->active.channel); @@ -3559,7 +3559,7 @@ 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) + if (!il->ht.enabled || !il->ht.is_40mhz) return false; /* @@ -3576,7 +3576,7 @@ il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, return il_is_channel_extension(il, il->band, le16_to_cpu(il->staging.channel), - ctx->ht.extension_chan_offset); + il->ht.extension_chan_offset); } EXPORT_SYMBOL(il_is_ht40_tx_allowed); @@ -3832,7 +3832,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, { struct il_rxon_cmd *rxon = &il->staging; - if (!ctx->ht.enabled) { + if (!il->ht.enabled) { rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | RXON_FLG_HT40_PROT_MSK @@ -3841,7 +3841,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, } rxon->flags |= - cpu_to_le32(ctx->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); + cpu_to_le32(il->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); /* Set up channel bandwidth: * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ @@ -3850,10 +3850,10 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, ~(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 (il->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) { + switch (il->ht.extension_chan_offset) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: rxon->flags &= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; @@ -3864,7 +3864,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, } } else { /* Note: control channel is opposite of extension channel */ - switch (ctx->ht.extension_chan_offset) { + switch (il->ht.extension_chan_offset) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); @@ -3890,7 +3890,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, 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); + il->ht.protection, il->ht.extension_chan_offset); } void @@ -5236,7 +5236,7 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) il->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_UPDATE_EDCA_MSK; - if (ctx->ht.enabled) + if (il->ht.enabled) il->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", @@ -5319,32 +5319,32 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) spin_lock_irqsave(&il->lock, flags); /* Configure HT40 channels */ - if (ctx->ht.enabled != conf_is_ht(conf)) { - ctx->ht.enabled = conf_is_ht(conf); + if (il->ht.enabled != conf_is_ht(conf)) { + il->ht.enabled = conf_is_ht(conf); ht_changed = true; } - if (ctx->ht.enabled) { + if (il->ht.enabled) { if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; + il->ht.is_40mhz = true; } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; + il->ht.is_40mhz = true; } else { - ctx->ht.extension_chan_offset = + il->ht.extension_chan_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; + il->ht.is_40mhz = false; } } else - ctx->ht.is_40mhz = false; + il->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; + il->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 @@ -5460,16 +5460,15 @@ 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) + if (!il->ht.enabled) return; - ctx->ht.protection = + il->ht.protection = bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; - ctx->ht.non_gf_sta_present = + il->ht.non_gf_sta_present = !!(bss_conf-> ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 18375cb7904c..df4d1602289c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1164,13 +1164,6 @@ struct il_rxon_context { * we already removed the vif for type setting. */ bool always_active, is_active; - - struct { - bool non_gf_sta_present; - u8 protection; - bool enabled, is_40mhz; - u8 extension_chan_offset; - } ht; }; struct il_power_mgr { @@ -1278,6 +1271,14 @@ struct il_priv { struct il_qos_info qos_data; + struct { + bool enabled; + bool is_40mhz; + bool non_gf_sta_present; + u8 protection; + u8 extension_chan_offset; + } ht; + /* * We declare this const so it can only be * changed via explicit cast within the -- GitLab From b75b3a70a623e6c39512e3ed9a0fd76cea19c085 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:53 +0100 Subject: [PATCH 0436/1846] iwlegacy: get rid of ctx->ac_to_fifo Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 17 ++++++++--------- drivers/net/wireless/iwlegacy/common.h | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 94984c850e84..731bb8c10b45 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1458,8 +1458,15 @@ il4965_get_ac_from_tid(u16 tid) static inline int il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) { + const u8 ac_to_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, + }; + if (likely(tid < ARRAY_SIZE(tid_to_ac))) - return ctx->ac_to_fifo[tid_to_ac[tid]]; + return ac_to_fifo[tid_to_ac[tid]]; /* no support for TIDs 8-15 yet */ return -EINVAL; @@ -6104,13 +6111,6 @@ il4965_set_hw_params(struct il_priv *il) 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, }; @@ -6139,7 +6139,6 @@ 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.ac_to_fifo = il4965_bss_ac_to_fifo; il->ctx.ac_to_queue = il4965_bss_ac_to_queue; SET_IEEE80211_DEV(hw, &pdev->dev); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index df4d1602289c..e0e4d0136601 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1155,7 +1155,6 @@ struct il_force_reset { struct il_rxon_context { struct ieee80211_vif *vif; - const u8 *ac_to_fifo; const u8 *ac_to_queue; /* -- GitLab From eb123af3d1e038c486fc8fcf19518133883792d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:54 +0100 Subject: [PATCH 0437/1846] iwlegacy: get rid of ctx->ac_to_queue Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 8 ++------ drivers/net/wireless/iwlegacy/common.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 731bb8c10b45..1c3c85ec1117 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1718,7 +1718,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* FIXME: remove me ? */ WARN_ON_ONCE(info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM); - txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; + /* Access category (AC) is also the queue number */ + txq_id = skb_get_queue_mapping(skb); /* irqs already disabled/saved above when locking il->lock */ spin_lock(&il->sta_lock); @@ -6111,10 +6112,6 @@ il4965_set_hw_params(struct il_priv *il) return il->cfg->ops->lib->set_hw_params(il); } -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) { @@ -6139,7 +6136,6 @@ 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.ac_to_queue = il4965_bss_ac_to_queue; SET_IEEE80211_DEV(hw, &pdev->dev); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index e0e4d0136601..e085131a4572 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1155,8 +1155,6 @@ struct il_force_reset { struct il_rxon_context { struct ieee80211_vif *vif; - const u8 *ac_to_queue; - /* * We could use the vif to indicate active, but we * also need it to be active during disabling when -- GitLab From dee9a09eb34a272494a315fe0c19e49b6375a000 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:55 +0100 Subject: [PATCH 0438/1846] iwlegacy: get rid of ctx->is_active Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 3 --- drivers/net/wireless/iwlegacy/4965.c | 3 --- drivers/net/wireless/iwlegacy/common.c | 21 +++------------------ drivers/net/wireless/iwlegacy/common.h | 7 ------- 4 files changed, 3 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 1c3c85ec1117..1a54c1a812dd 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6134,9 +6134,6 @@ 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. */ - il->ctx.always_active = true; - il->ctx.is_active = true; - SET_IEEE80211_DEV(hw, &pdev->dev); D_INFO("*** LOAD DRIVER ***\n"); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8d0fd60bc491..7b0192aff839 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1419,9 +1419,6 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) if (!il_is_alive(il)) return -EBUSY; - if (!ctx->is_active) - return 0; - /* always get timestamp with Rx frame */ il->staging.flags |= RXON_FLG_TSF2HOST_MSK; diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index db2e8bb11fa1..13bd3a8c21b1 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4537,7 +4537,6 @@ 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); @@ -4548,16 +4547,7 @@ il_setup_interface(struct il_priv *il, struct il_rxon_context *ctx) */ 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; + return il_set_mode(il, ctx); } int @@ -4612,11 +4602,9 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, il_force_scan_end(il); } - if (!mode_change) { + if (!mode_change) il_set_mode(il, ctx); - if (!ctx->always_active) - ctx->is_active = false; - } + } void @@ -5227,9 +5215,6 @@ 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; - il->qos_data.def_qos_parm.qos_flags = 0; if (il->qos_data.qos_active) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index e085131a4572..51c1eecf7510 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1154,13 +1154,6 @@ struct il_force_reset { struct il_rxon_context { struct ieee80211_vif *vif; - - /* - * 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; }; struct il_power_mgr { -- GitLab From 20c47eba7001680e62878c5b20e487a8b0b873ad Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:56 +0100 Subject: [PATCH 0439/1846] iwlegacy: remove il_setup_interface() Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 13bd3a8c21b1..ea2fa97fa36b 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4533,23 +4533,6 @@ 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) -{ - struct ieee80211_vif *vif = ctx->vif; - - 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; - - return il_set_mode(il, ctx); -} - int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -4574,8 +4557,9 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) vif_priv->ctx = &il->ctx; il->ctx.vif = vif; + il->iw_mode = vif->type; - err = il_setup_interface(il, &il->ctx); + err = il_set_mode(il, &il->ctx); if (err) { il->ctx.vif = NULL; il->iw_mode = NL80211_IFTYPE_STATION; @@ -4978,7 +4962,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, il_teardown_interface(il, vif, true); vif->type = newtype; vif->p2p = false; - err = il_setup_interface(il, ctx); + err = il_set_mode(il, ctx); WARN_ON(err); /* * We've switched internally, but submitting to the -- GitLab From 83007196037cc2d0bffd9f7afbe56d675779a6cb Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:57 +0100 Subject: [PATCH 0440/1846] iwlegacy: get rid of ctx structure Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 67 ++++---- drivers/net/wireless/iwlegacy/3945-rs.c | 3 +- drivers/net/wireless/iwlegacy/3945.c | 23 ++- drivers/net/wireless/iwlegacy/3945.h | 2 +- drivers/net/wireless/iwlegacy/4965-mac.c | 150 +++++++---------- drivers/net/wireless/iwlegacy/4965-rs.c | 35 ++-- drivers/net/wireless/iwlegacy/4965.c | 62 ++++--- drivers/net/wireless/iwlegacy/4965.h | 19 +-- drivers/net/wireless/iwlegacy/common.c | 199 +++++++++-------------- drivers/net/wireless/iwlegacy/common.h | 79 ++++----- 10 files changed, 261 insertions(+), 378 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 7c81f5aaf7a3..b2e04c591c6e 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -341,7 +341,7 @@ il3945_send_beacon_cmd(struct il_priv *il) return -ENOMEM; } - rate = il_get_lowest_plcp(il, &il->ctx); + rate = il_get_lowest_plcp(il); frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); @@ -512,7 +512,7 @@ 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, info->control.sta); if (sta_id == IL_INVALID_STATION) { D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; @@ -541,7 +541,6 @@ 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->ctx; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; @@ -2208,7 +2207,7 @@ il3945_alive_start(struct il_priv *il) active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ - il_connection_init_rx_config(il, &il->ctx); + il_connection_init_rx_config(il); } /* Configure Bluetooth device coexistence support */ @@ -2217,7 +2216,7 @@ il3945_alive_start(struct il_priv *il) set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ - il3945_commit_rxon(il, &il->ctx); + il3945_commit_rxon(il); il3945_reg_txpower_periodic(il); @@ -2249,7 +2248,7 @@ __il3945_down(struct il_priv *il) del_timer_sync(&il->watchdog); /* Station information will now be cleared in device */ - il_clear_ucode_stations(il, NULL); + il_clear_ucode_stations(il); il_dealloc_bcast_stations(il); il_clear_driver_stations(il); @@ -2335,12 +2334,11 @@ il3945_down(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, 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); @@ -2660,14 +2658,12 @@ 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->ctx; - /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&il->staging, &il->active, sizeof(il->staging))) - il3945_commit_rxon(il, ctx); + il3945_commit_rxon(il); } static void @@ -2680,7 +2676,8 @@ il3945_bg_restart(struct work_struct *data) if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); - il->ctx.vif = NULL; + /* FIXME: vif can be dereferenced */ + il->vif = NULL; il->is_open = 0; mutex_unlock(&il->mutex); il3945_down(il); @@ -2718,12 +2715,11 @@ 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) + if (!il->vif || !il->is_open) return; - D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, + D_ASSOC("Associated as %d to: %pM\n", il->vif->bss_conf.aid, il->active.bssid_addr); if (test_bit(S_EXIT_PENDING, &il->status)) @@ -2734,34 +2730,34 @@ il3945_post_associate(struct il_priv *il) conf = &il->hw->conf; il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); + il3945_commit_rxon(il); - rc = il_send_rxon_timing(il, ctx); + rc = il_send_rxon_timing(il); if (rc) IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); + il->staging.assoc_id = cpu_to_le16(il->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", il->vif->bss_conf.aid, + il->vif->bss_conf.beacon_int); - if (ctx->vif->bss_conf.use_short_preamble) + if (il->vif->bss_conf.use_short_preamble) il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; if (il->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (ctx->vif->bss_conf.use_short_slot) + if (il->vif->bss_conf.use_short_slot) il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - il3945_commit_rxon(il, ctx); + il3945_commit_rxon(il); - switch (ctx->vif->type) { + switch (il->vif->type) { case NL80211_IFTYPE_STATION: il3945_rate_scale_init(il->hw, IL_AP_ID); break; @@ -2770,7 +2766,7 @@ il3945_post_associate(struct il_priv *il) break; default: IL_ERR("%s Should not be called in %d mode\n", __func__, - ctx->vif->type); + il->vif->type); break; } } @@ -2887,8 +2883,7 @@ 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->ctx; - struct ieee80211_vif *vif = ctx->vif; + struct ieee80211_vif *vif = il->vif; int rc = 0; if (test_bit(S_EXIT_PENDING, &il->status)) @@ -2899,10 +2894,10 @@ il3945_config_ap(struct il_priv *il) /* RXON - unassoc (to set timing command) */ il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); + il3945_commit_rxon(il); /* RXON Timing */ - rc = il_send_rxon_timing(il, ctx); + rc = il_send_rxon_timing(il); if (rc) IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); @@ -2922,7 +2917,7 @@ il3945_config_ap(struct il_priv *il) } /* restore RXON assoc */ il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); + il3945_commit_rxon(il); } il3945_send_beacon_cmd(il); } @@ -2955,7 +2950,7 @@ 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, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } @@ -3003,8 +2998,7 @@ il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 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, 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 ? */ @@ -3184,7 +3178,7 @@ il3945_store_flags(struct device *d, struct device_attribute *attr, else { D_INFO("Committing rxon.flags = 0x%04X\n", flags); il->staging.flags = cpu_to_le32(flags); - il3945_commit_rxon(il, &il->ctx); + il3945_commit_rxon(il); } } mutex_unlock(&il->mutex); @@ -3220,7 +3214,7 @@ il3945_store_filter_flags(struct device *d, struct device_attribute *attr, D_INFO("Committing rxon.filter_flags = " "0x%04X\n", filter_flags); il->staging.filter_flags = cpu_to_le32(filter_flags); - il3945_commit_rxon(il, &il->ctx); + il3945_commit_rxon(il); } } mutex_unlock(&il->mutex); @@ -3750,8 +3744,7 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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]); il3945_setup_deferred_work(il); il3945_setup_handlers(il); il_power_initialize(il); diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 6a782b5c0c5f..70bee1a4d876 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -927,8 +927,7 @@ 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->vif, il->stations[sta_id].sta.sta.addr); if (!sta) { D_RATE("Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 3024645a6be9..1e617c9fc3cc 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -1662,7 +1662,7 @@ il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) } static int -il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) +il3945_send_rxon_assoc(struct il_priv *il) { int rc = 0; struct il_rx_pkt *pkt; @@ -1714,7 +1714,7 @@ il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) * a HW tune is required based on the RXON structure changes. */ int -il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +il3945_commit_rxon(struct il_priv *il) { /* cast away the const for active_rxon in this function */ struct il3945_rxon_cmd *active_rxon = (void *)&il->active; @@ -1735,7 +1735,7 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) 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); + rc = il_check_rxon_cmd(il); if (rc) { IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL; @@ -1744,8 +1744,8 @@ 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)) { + rc = il_send_rxon_assoc(il); if (rc) { IL_ERR("Error setting RXON_ASSOC " "configuration (%d).\n", rc); @@ -1786,8 +1786,8 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) "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_restore_stations(il); } D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" @@ -1801,7 +1801,7 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) staging_rxon->reserved4 = 0; staging_rxon->reserved5 = 0; - il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); + il_set_rxon_hwcrypto(il, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), @@ -1814,8 +1814,8 @@ 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_restore_stations(il); } /* If we issue a new RXON command which required a tune then we must @@ -2258,7 +2258,6 @@ il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) 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; @@ -2266,7 +2265,7 @@ il3945_add_bssid_station(struct il_priv *il, const u8 * addr, u8 * sta_id_r) if (sta_id_r) *sta_id_r = IL_INVALID_STATION; - ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(il, addr, 0, NULL, &sta_id); if (ret) { IL_ERR("Unable to add station %pM\n", addr); return ret; diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 9f42f79f8778..8bee127d413d 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -249,7 +249,7 @@ 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); /** * il3945_hw_find_station - Find station id for a given BSSID diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 1a54c1a812dd..4be53cc91981 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -843,7 +843,6 @@ 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->ctx; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; @@ -859,8 +858,6 @@ il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); - ctx = il_rxon_ctx_from_vif(vif); - if (!il->scan_cmd) { il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, @@ -1033,8 +1030,7 @@ il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, 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, + return il4965_add_bssid_station(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); @@ -1127,7 +1123,7 @@ il4965_count_chain_bitmap(u32 chain_bitmap) * 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) +il4965_set_rxon_chain(struct il_priv *il) { bool is_single = il4965_is_single_rx_stream(il); bool is_cam = !test_bit(S_POWER_PMI, &il->status); @@ -1456,7 +1452,7 @@ il4965_get_ac_from_tid(u16 tid) } static inline int -il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) +il4965_get_fifo_from_tid(u16 tid) { const u8 ac_to_fifo[] = { IL_TX_FIFO_VO, @@ -1645,7 +1641,6 @@ 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->ctx; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -1661,9 +1656,6 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) 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"); @@ -1688,7 +1680,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) sta_id = il->hw_params.bcast_id; else { /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); + sta_id = il_sta_id_or_broadcast(il, info->control.sta); if (sta_id == IL_INVALID_STATION) { D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); @@ -1764,7 +1756,6 @@ il4965_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 = ctx; /* Set up first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[q->write_ptr]; @@ -2228,7 +2219,8 @@ il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, unsigned long flags; struct il_tid_data *tid_data; - tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); + /* FIXME: warning if tx fifo not found ? */ + tx_fifo = il4965_get_fifo_from_tid(tid); if (unlikely(tx_fifo < 0)) return tx_fifo; @@ -2321,7 +2313,8 @@ il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, int write_ptr, read_ptr; unsigned long flags; - tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); + /* FIXME: warning if tx_fifo_id not found ? */ + tx_fifo_id = il4965_get_fifo_from_tid(tid); if (unlikely(tx_fifo_id < 0)) return tx_fifo_id; @@ -2395,9 +2388,6 @@ 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); @@ -2408,11 +2398,11 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int 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); + int tx_fifo = il4965_get_fifo_from_tid(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); + ieee80211_stop_tx_ba_cb_irqsafe(il->vif, addr, tid); } break; case IL_EMPTYING_HW_QUEUE_ADDBA: @@ -2420,7 +2410,7 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) 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); + ieee80211_start_tx_ba_cb_irqsafe(il->vif, addr, tid); } break; } @@ -2429,14 +2419,13 @@ 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) +il4965_non_agg_tx_status(struct il_priv *il, const u8 *addr1) { struct ieee80211_sta *sta; struct il_station_priv *sta_priv; rcu_read_lock(); - sta = ieee80211_find_sta(ctx->vif, addr1); + sta = ieee80211_find_sta(il->vif, addr1); if (sta) { sta_priv = (void *)sta->drv_priv; /* avoid atomic ops if this isn't a client */ @@ -2453,7 +2442,7 @@ 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); + il4965_non_agg_tx_status(il, hdr->addr1); ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } @@ -2769,8 +2758,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) * Function sleeps. */ int -il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r) +il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r) { int ret; u8 sta_id; @@ -2780,7 +2768,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, if (sta_id_r) *sta_id_r = IL_INVALID_STATION; - ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(il, addr, 0, NULL, &sta_id); if (ret) { IL_ERR("Unable to add station %pM\n", addr); return ret; @@ -2801,7 +2789,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, return -ENOMEM; } - ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); + ret = il_send_lq_cmd(il, link_cmd, CMD_SYNC, true); if (ret) IL_ERR("Link quality command failed (%d)\n", ret); @@ -2813,8 +2801,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, } static int -il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, - bool send_if_empty) +il4965_static_wepkey_cmd(struct il_priv *il, bool send_if_empty) { int i; u8 buff[sizeof(struct il_wep_cmd) + @@ -2860,15 +2847,15 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, } int -il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx) +il4965_restore_default_wep_keys(struct il_priv *il) { lockdep_assert_held(&il->mutex); - return il4965_static_wepkey_cmd(il, ctx, false); + return il4965_static_wepkey_cmd(il, false); } int -il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, +il4965_remove_default_wep_key(struct il_priv *il, struct ieee80211_key_conf *keyconf) { int ret; @@ -2884,14 +2871,14 @@ il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, /* but keys in device are clear anyway so return success */ return 0; } - ret = il4965_static_wepkey_cmd(il, ctx, 1); + ret = il4965_static_wepkey_cmd(il, 1); D_WEP("Remove default WEP key: idx=%d ret=%d\n", idx, ret); return ret; } int -il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, +il4965_set_default_wep_key(struct il_priv *il, struct ieee80211_key_conf *keyconf) { int ret; @@ -2912,14 +2899,14 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, il->_4965.wep_keys[idx].key_size = len; memcpy(&il->_4965.wep_keys[idx].key, &keyconf->key, len); - ret = il4965_static_wepkey_cmd(il, ctx, false); + ret = il4965_static_wepkey_cmd(il, false); D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", len, idx, ret); return ret; } static int -il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, +il4965_set_wep_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; @@ -2974,7 +2961,6 @@ il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, 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; @@ -3023,7 +3009,6 @@ il4965_set_ccmp_dynamic_key_info(struct il_priv *il, 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; @@ -3068,9 +3053,8 @@ il4965_set_tkip_dynamic_key_info(struct il_priv *il, } 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) +il4965_update_tkip_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { u8 sta_id; unsigned long flags; @@ -3082,7 +3066,7 @@ il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, return; } - sta_id = il_sta_id_or_broadcast(il, ctx, sta); + sta_id = il_sta_id_or_broadcast(il, sta); if (sta_id == IL_INVALID_STATION) return; @@ -3100,11 +3084,10 @@ il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, 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, +il4965_remove_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; @@ -3165,8 +3148,8 @@ il4965_remove_dynamic_key(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 *keyconf, u8 sta_id) +il4965_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, + u8 sta_id) { int ret; @@ -3178,15 +3161,15 @@ 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); + il4965_set_ccmp_dynamic_key_info(il, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: ret = - il4965_set_tkip_dynamic_key_info(il, ctx, keyconf, sta_id); + il4965_set_tkip_dynamic_key_info(il, 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, keyconf, sta_id); break; default: IL_ERR("Unknown alg: %s cipher = %x\n", __func__, @@ -3208,14 +3191,14 @@ il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, * device at the next best time. */ int -il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) +il4965_alloc_bcast_station(struct il_priv *il) { 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, 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); @@ -3248,7 +3231,7 @@ il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) * code together. */ static int -il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) +il4965_update_bcast_station(struct il_priv *il) { unsigned long flags; struct il_link_quality_cmd *link_cmd; @@ -3274,7 +3257,7 @@ il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) int il4965_update_bcast_stations(struct il_priv *il) { - return il4965_update_bcast_station(il, &il->ctx); + return il4965_update_bcast_station(il); } /** @@ -3375,9 +3358,9 @@ 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); + il->cfg->ops->hcmd->set_rxon_chain(il); if (il->active.rx_chain != il->staging.rx_chain) - il_commit_rxon(il, &il->ctx); + il_commit_rxon(il); } } @@ -3489,8 +3472,8 @@ il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) lockdep_assert_held(&il->mutex); - if (!il->beacon_ctx) { - IL_ERR("trying to build beacon w/o beacon context!\n"); + if (!il->beacon_enabled) { + IL_ERR("Trying to build beacon without beaconing enabled\n"); return 0; } @@ -3520,7 +3503,7 @@ il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) frame_size); /* Set up packet rate and flags */ - rate = il_get_lowest_plcp(il, il->beacon_ctx); + rate = il_get_lowest_plcp(il); il4965_toggle_tx_ant(il, &il->mgmt_tx_ant, il->hw_params.valid_tx_ant); rate_flags = BIT(il->mgmt_tx_ant) << RATE_MCS_ANT_POS; if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) @@ -4977,7 +4960,6 @@ 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"); @@ -5025,10 +5007,10 @@ il4965_alive_start(struct il_priv *il) active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ - il_connection_init_rx_config(il, &il->ctx); + il_connection_init_rx_config(il); if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + il->cfg->ops->hcmd->set_rxon_chain(il); } /* Configure bluetooth coexistence if enabled */ @@ -5039,7 +5021,7 @@ il4965_alive_start(struct il_priv *il) set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ - il_commit_rxon(il, ctx); + il_commit_rxon(il); /* At this point, the NIC is initialized and operational */ il4965_rf_kill_ct_config(il); @@ -5074,7 +5056,7 @@ __il4965_down(struct il_priv *il) * to prevent rearm timer */ del_timer_sync(&il->watchdog); - il_clear_ucode_stations(il, NULL); + il_clear_ucode_stations(il); /* FIXME: race conditions ? */ spin_lock_irq(&il->sta_lock); @@ -5239,7 +5221,7 @@ __il4965_up(struct il_priv *il) return -EIO; } - ret = il4965_alloc_bcast_station(il, &il->ctx); + ret = il4965_alloc_bcast_station(il); if (ret) { il_dealloc_bcast_stations(il); return ret; @@ -5393,7 +5375,8 @@ il4965_bg_restart(struct work_struct *data) if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); - il->ctx.vif = NULL; + /* FIXME: do we dereference vif without mutex locked ? */ + il->vif = NULL; il->is_open = 0; __il4965_down(il); @@ -5590,12 +5573,10 @@ il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 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, keyconf, sta, iv32, phase1key); D_MAC80211("leave\n"); } @@ -5606,8 +5587,6 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 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; @@ -5619,7 +5598,7 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return -EOPNOTSUPP; } - sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); + sta_id = il_sta_id_or_broadcast(il, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; @@ -5644,20 +5623,17 @@ 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(il, vif_priv->ctx, key); + ret = il4965_set_default_wep_key(il, key); else - ret = - il4965_set_dynamic_key(il, vif_priv->ctx, key, - sta_id); + ret = il4965_set_dynamic_key(il, 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); + ret = il4965_remove_default_wep_key(il, key); else - ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); + ret = il4965_remove_dynamic_key(il, key, sta_id); D_MAC80211("disable hwcrypto key\n"); break; @@ -5723,7 +5699,6 @@ il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, { 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; @@ -5736,8 +5711,7 @@ il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, atomic_set(&sta_priv->pending_frames, 0); ret = - il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, - &sta_id); + il_add_station_common(il, 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 ? */ @@ -5764,8 +5738,6 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, 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"); @@ -5822,9 +5794,9 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, if ((le16_to_cpu(il->staging.channel) != ch)) il->staging.flags = 0; - il_set_rxon_channel(il, channel, ctx); + il_set_rxon_channel(il, channel); il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, ctx->vif); + il_set_flags_for_band(il, channel->band, il->vif); spin_unlock_irq(&il->lock); @@ -5838,7 +5810,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = 0; - ieee80211_chswitch_done(ctx->vif, false); + ieee80211_chswitch_done(il->vif, false); } out: @@ -6049,7 +6021,7 @@ 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_init_scan_params(il); diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index ad186d9a598f..d7e2856e41d3 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -820,8 +820,6 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, 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"); @@ -889,7 +887,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, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ return; @@ -1181,8 +1179,6 @@ il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, 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; @@ -1203,7 +1199,7 @@ il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_mimo2_rate; - if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; @@ -1237,8 +1233,6 @@ il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, 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; @@ -1251,7 +1245,7 @@ il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_siso_rate; - if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; @@ -1730,8 +1724,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * setup rate table in uCode */ static void -il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, - struct il_lq_sta *lq_sta, +il4965_rs_update_rate_tbl(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, int idx, u8 is_green) { u32 rate; @@ -1739,7 +1732,7 @@ il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, /* 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); + il_send_lq_cmd(il, &lq_sta->lq, CMD_ASYNC, false); } /* @@ -1775,8 +1768,6 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, 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"); @@ -1851,7 +1842,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); - il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + il4965_rs_update_rate_tbl(il, lq_sta, tbl, idx, is_green); } return; @@ -2054,8 +2045,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) - il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, - is_green); + il4965_rs_update_rate_tbl(il, lq_sta, tbl, idx, is_green); /* Should we stay with this modulation mode, * or search for a new one? */ @@ -2095,7 +2085,7 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, 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); + il_send_lq_cmd(il, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; } @@ -2167,13 +2157,11 @@ il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, 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; @@ -2205,7 +2193,7 @@ il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, 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); + il_send_lq_cmd(il, &lq_sta->lq, CMD_SYNC, true); } static void @@ -2576,9 +2564,6 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file, 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)); @@ -2600,7 +2585,7 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file, 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, &lq_sta->lq, CMD_ASYNC, false); } return count; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 7b0192aff839..9d9197f7fa38 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1370,7 +1370,7 @@ il4965_send_tx_power(struct il_priv *il) } static int -il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) +il4965_send_rxon_assoc(struct il_priv *il) { int ret = 0; struct il4965_rxon_assoc_cmd rxon_assoc; @@ -1409,7 +1409,7 @@ il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) } static int -il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +il4965_commit_rxon(struct il_priv *il) { /* cast away the const for active_rxon in this function */ struct il_rxon_cmd *active_rxon = (void *)&il->active; @@ -1422,7 +1422,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) /* always get timestamp with Rx frame */ il->staging.flags |= RXON_FLG_TSF2HOST_MSK; - ret = il_check_rxon_cmd(il, ctx); + ret = il_check_rxon_cmd(il); if (ret) { IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL; @@ -1442,15 +1442,15 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) /* 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 (!il_full_rxon_required(il)) { + ret = il_send_rxon_assoc(il); if (ret) { IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); return ret; } memcpy(active_rxon, &il->staging, sizeof(*active_rxon)); - il_print_rx_config_cmd(il, ctx); + il_print_rx_config_cmd(il); /* * We do not commit tx power settings while channel changing, * do it now if tx power changed. @@ -1478,9 +1478,9 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) 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); + il_clear_ucode_stations(il); + il_restore_stations(il); + ret = il4965_restore_default_wep_keys(il); if (ret) { IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret; @@ -1491,7 +1491,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"), le16_to_cpu(il->staging.channel), il->staging.bssid_addr); - il_set_rxon_hwcrypto(il, ctx, !il->cfg->mod_params->sw_crypto); + il_set_rxon_hwcrypto(il, !il->cfg->mod_params->sw_crypto); /* Apply the new configuration * RXON unassoc clears the station table in uCode so restoration of @@ -1507,9 +1507,9 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) } D_INFO("Return from !new_assoc RXON.\n"); memcpy(active_rxon, &il->staging, sizeof(*active_rxon)); - il_clear_ucode_stations(il, ctx); - il_restore_stations(il, ctx); - ret = il4965_restore_default_wep_keys(il, ctx); + il_clear_ucode_stations(il); + il_restore_stations(il); + ret = il4965_restore_default_wep_keys(il); if (ret) { IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret; @@ -1529,7 +1529,7 @@ il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) } memcpy(active_rxon, &il->staging, sizeof(*active_rxon)); } - il_print_rx_config_cmd(il, ctx); + il_print_rx_config_cmd(il); il4965_init_sensitivity(il); @@ -1548,7 +1548,6 @@ 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; @@ -1560,8 +1559,11 @@ il4965_hw_channel_switch(struct il_priv *il, u32 tsf_low; u8 switch_count; u16 beacon_interval = le16_to_cpu(il->timing.beacon_interval); - struct ieee80211_vif *vif = ctx->vif; - band = il->band == IEEE80211_BAND_2GHZ; + struct ieee80211_vif *vif = il->vif; + band = (il->band == IEEE80211_BAND_2GHZ); + + if (WARN_ON_ONCE(vif == NULL)) + return -EIO; is_ht40 = iw4965_is_ht40_channel(il->staging.flags); @@ -2128,21 +2130,18 @@ static struct il_hcmd_ops il4965_hcmd = { 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(&il->staging, &il->active, sizeof(il->staging))) - il_commit_rxon(il, ctx); + il_commit_rxon(il); } static void il4965_post_associate(struct il_priv *il) { - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; + struct ieee80211_vif *vif = il->vif; struct ieee80211_conf *conf = NULL; int ret = 0; @@ -2157,9 +2156,9 @@ il4965_post_associate(struct il_priv *il) conf = &il->hw->conf; il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); + il_commit_rxon(il); - ret = il_send_rxon_timing(il, ctx); + ret = il_send_rxon_timing(il); if (ret) IL_WARN("RXON timing - " "Attempting to continue.\n"); @@ -2168,7 +2167,7 @@ il4965_post_associate(struct il_priv *il) 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); + il->cfg->ops->hcmd->set_rxon_chain(il); il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); @@ -2187,7 +2186,7 @@ il4965_post_associate(struct il_priv *il) il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - il_commit_rxon(il, ctx); + il_commit_rxon(il); D_ASSOC("Associated as %d to: %pM\n", vif->bss_conf.aid, il->active.bssid_addr); @@ -2218,8 +2217,7 @@ il4965_post_associate(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; + struct ieee80211_vif *vif = il->vif; int ret = 0; lockdep_assert_held(&il->mutex); @@ -2232,10 +2230,10 @@ il4965_config_ap(struct il_priv *il) /* RXON - unassoc (to set timing command) */ il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); + il_commit_rxon(il); /* RXON Timing */ - ret = il_send_rxon_timing(il, ctx); + ret = il_send_rxon_timing(il); if (ret) IL_WARN("RXON timing failed - " "Attempting to continue.\n"); @@ -2244,7 +2242,7 @@ il4965_config_ap(struct il_priv *il) 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); + il->cfg->ops->hcmd->set_rxon_chain(il); il->staging.assoc_id = 0; @@ -2263,7 +2261,7 @@ il4965_config_ap(struct il_priv *il) il4965_send_beacon_cmd(il); /* restore RXON assoc */ il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); + il_commit_rxon(il); } il4965_send_beacon_cmd(il); } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index f280e0161b17..67899602ee52 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -48,7 +48,7 @@ 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); /* uCode */ int il4965_verify_ucode(struct il_priv *il); @@ -134,21 +134,18 @@ il4965_get_tx_fail_reason(u32 status) #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); +int il4965_add_bssid_station(struct il_priv *il, 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, +int il4965_set_default_wep_key(struct il_priv *il, 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, +int il4965_restore_default_wep_keys(struct il_priv *il); +int il4965_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, +int il4965_remove_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, +void il4965_update_tkip_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index ea2fa97fa36b..bee11a3aeac0 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -1442,7 +1442,6 @@ 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 = @@ -1457,7 +1456,7 @@ il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, * 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; + value = il->vif ? il->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; @@ -1832,8 +1831,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) 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) +il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta) { struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; __le32 sta_flags; @@ -1874,7 +1872,7 @@ il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, 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)) + if (il_is_ht40_tx_allowed(il, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; else sta_flags &= ~STA_FLG_HT40_EN_MSK; @@ -1890,8 +1888,8 @@ il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, * 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, const u8 *addr, bool is_ap, + struct ieee80211_sta *sta) { struct il_station_entry *station; int i; @@ -1952,19 +1950,12 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, station->sta.sta.sta_id = sta_id; station->sta.station_flags = 0; - 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); + il_set_ht_add_station(il, sta_id, sta); /* 3945 only */ rate = (il->band == IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : RATE_1M_PLCP; @@ -1982,9 +1973,8 @@ 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, const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r) { unsigned long flags_spin; int ret = 0; @@ -1993,7 +1983,7 @@ il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, *sta_id_r = 0; spin_lock_irqsave(&il->sta_lock, flags_spin); - sta_id = il_prep_station(il, ctx, addr, is_ap, sta); + sta_id = il_prep_station(il, 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); @@ -2180,7 +2170,7 @@ EXPORT_SYMBOL_GPL(il_remove_station); * the ucode, e.g. unassociated RXON. */ void -il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) +il_clear_ucode_stations(struct il_priv *il) { int i; unsigned long flags_spin; @@ -2212,7 +2202,7 @@ EXPORT_SYMBOL(il_clear_ucode_stations); * Function sleeps. */ void -il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) +il_restore_stations(struct il_priv *il) { struct il_addsta_cmd sta_cmd; struct il_link_quality_cmd lq; @@ -2267,7 +2257,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) * current LQ command */ if (send_lq) - il_send_lq_cmd(il, ctx, &lq, CMD_SYNC, true); + il_send_lq_cmd(il, &lq, CMD_SYNC, true); spin_lock_irqsave(&il->sta_lock, flags_spin); il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } @@ -2347,8 +2337,7 @@ il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) * 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) +il_is_lq_table_valid(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; @@ -2376,8 +2365,8 @@ il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, * 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) +il_send_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq, + u8 flags, bool init) { int ret = 0; unsigned long flags_spin; @@ -2402,7 +2391,7 @@ il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, il_dump_lq_cmd(il, lq); BUG_ON(init && (cmd.flags & CMD_ASYNC)); - if (il_is_lq_table_valid(il, ctx, lq)) + if (il_is_lq_table_valid(il, lq)) ret = il_send_cmd(il, &cmd); else ret = -EINVAL; @@ -3556,8 +3545,7 @@ 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 ieee80211_sta_ht_cap *ht_cap) { if (!il->ht.enabled || !il->ht.is_40mhz) return false; @@ -3615,13 +3603,13 @@ il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) } int -il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) +il_send_rxon_timing(struct il_priv *il) { u64 tsf; s32 interval_tm, rem; struct ieee80211_conf *conf = NULL; u16 beacon_int; - struct ieee80211_vif *vif = ctx->vif; + struct ieee80211_vif *vif = il->vif; conf = &il->hw->conf; @@ -3664,8 +3652,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) 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, int hw_decrypt) { struct il_rxon_cmd *rxon = &il->staging; @@ -3679,7 +3666,7 @@ 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) +il_check_rxon_cmd(struct il_priv *il) { struct il_rxon_cmd *rxon = &il->staging; bool error = false; @@ -3759,7 +3746,7 @@ EXPORT_SYMBOL(il_check_rxon_cmd); * 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) +il_full_rxon_required(struct il_priv *il) { const struct il_rxon_cmd *staging = &il->staging; const struct il_rxon_cmd *active = &il->active; @@ -3813,7 +3800,7 @@ il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) 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) { /* * Assign the lowest rate -- should really get this from @@ -3827,8 +3814,7 @@ il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx) 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) +_il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { struct il_rxon_cmd *rxon = &il->staging; @@ -3848,7 +3834,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, /* 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)) { + if (il_is_ht40_tx_allowed(il, NULL)) { /* pure ht40 */ if (il->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; @@ -3886,7 +3872,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, } if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + il->cfg->ops->hcmd->set_rxon_chain(il); D_ASSOC("rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), @@ -3896,7 +3882,7 @@ _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); + _il_set_rxon_ht(il, ht_conf); } EXPORT_SYMBOL(il_set_rxon_ht); @@ -3939,8 +3925,7 @@ 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 *il, struct ieee80211_channel *ch, - struct il_rxon_context *ctx) +il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; @@ -3963,8 +3948,8 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, 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) +il_set_flags_for_band(struct il_priv *il, enum ieee80211_band band, + struct ieee80211_vif *vif) { if (band == IEEE80211_BAND_5GHZ) { il->staging.flags &= @@ -3989,35 +3974,26 @@ 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) +il_connection_init_rx_config(struct il_priv *il) { const struct il_channel_info *ch_info; memset(&il->staging, 0, sizeof(il->staging)); - if (!ctx->vif) { + if (!il->vif) { il->staging.dev_type = RXON_DEV_TYPE_ESS; - } else - switch (ctx->vif->type) { - - case NL80211_IFTYPE_STATION: - il->staging.dev_type = RXON_DEV_TYPE_ESS; - il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; - break; - - case NL80211_IFTYPE_ADHOC: - il->staging.dev_type = RXON_DEV_TYPE_IBSS; - il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; - il->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; - } + } else if (il->vif->type == NL80211_IFTYPE_STATION) { + il->staging.dev_type = RXON_DEV_TYPE_ESS; + il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; + } else if (il->vif->type == NL80211_IFTYPE_ADHOC) { + il->staging.dev_type = RXON_DEV_TYPE_IBSS; + il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; + il->staging.filter_flags = + RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK; + } else { + IL_ERR("Unsupported interface type %d\n", il->vif->type); + return; + } #if 0 /* TODO: Figure out when short_preamble would be set and cache from @@ -4037,7 +4013,7 @@ il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) il->staging.channel = cpu_to_le16(ch_info->channel); il->band = ch_info->band; - il_set_flags_for_band(il, ctx, il->band, ctx->vif); + il_set_flags_for_band(il, il->band, il->vif); il->staging.ofdm_basic_rates = (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; @@ -4047,8 +4023,8 @@ il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) /* clear both MIX and PURE40 mode flag */ il->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | RXON_FLG_CHANNEL_MODE_PURE_40); - if (ctx->vif) - memcpy(il->staging.node_addr, ctx->vif->addr, ETH_ALEN); + if (il->vif) + memcpy(il->staging.node_addr, il->vif->addr, ETH_ALEN); il->staging.ofdm_ht_single_stream_basic_rates = 0xff; il->staging.ofdm_ht_dual_stream_basic_rates = 0xff; @@ -4089,13 +4065,11 @@ 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); + ieee80211_chswitch_done(il->vif, is_success); } EXPORT_SYMBOL(il_chswitch_done); @@ -4124,7 +4098,7 @@ EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG void -il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) +il_print_rx_config_cmd(struct il_priv *il) { struct il_rxon_cmd *rxon = &il->staging; @@ -4161,7 +4135,7 @@ il_irq_handle_error(struct il_priv *il) 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); #endif wake_up(&il->wait_command_queue); @@ -4523,21 +4497,20 @@ il_mac_tx_last_beacon(struct ieee80211_hw *hw) EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int -il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) +il_set_mode(struct il_priv *il) { - il_connection_init_rx_config(il, ctx); + il_connection_init_rx_config(il); if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + il->cfg->ops->hcmd->set_rxon_chain(il); - return il_commit_rxon(il, ctx); + return il_commit_rxon(il); } 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; D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); @@ -4550,18 +4523,17 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; } - if (il->ctx.vif) { + if (il->vif) { err = -EOPNOTSUPP; goto out; } - vif_priv->ctx = &il->ctx; - il->ctx.vif = vif; + il->vif = vif; il->iw_mode = vif->type; - err = il_set_mode(il, &il->ctx); + err = il_set_mode(il); if (err) { - il->ctx.vif = NULL; + il->vif = NULL; il->iw_mode = NL80211_IFTYPE_STATION; } @@ -4577,8 +4549,6 @@ 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) { @@ -4587,7 +4557,7 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, } if (!mode_change) - il_set_mode(il, ctx); + il_set_mode(il); } @@ -4595,14 +4565,13 @@ 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; + WARN_ON(il->vif != vif); + il->vif = NULL; il_teardown_interface(il, vif, false); @@ -4941,7 +4910,6 @@ 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); int err; if (newp2p) @@ -4949,7 +4917,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mutex_lock(&il->mutex); - if (!ctx->vif || !il_is_ready_rf(il)) { + if (!il->vif || !il_is_ready_rf(il)) { /* * Huh? But wait ... this can maybe happen when * we're in the middle of a firmware restart! @@ -4962,7 +4930,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, il_teardown_interface(il, vif, true); vif->type = newtype; vif->p2p = false; - err = il_set_mode(il, ctx); + err = il_set_mode(il); WARN_ON(err); /* * We've switched internally, but submitting to the @@ -5194,7 +5162,7 @@ EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ static void -il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) +il_update_qos(struct il_priv *il) { if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -5226,7 +5194,6 @@ 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 = &il->ctx; unsigned long flags = 0; int ret = 0; u16 ch; @@ -5259,7 +5226,7 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) * configured. */ 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); } /* during scanning mac80211 will delay channel setting until @@ -5321,10 +5288,10 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) if ((le16_to_cpu(il->staging.channel) != ch)) il->staging.flags = 0; - il_set_rxon_channel(il, channel, ctx); + il_set_rxon_channel(il, channel); il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, ctx->vif); + il_set_flags_for_band(il, channel->band, il->vif); spin_unlock_irqrestore(&il->lock, flags); @@ -5360,11 +5327,11 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) goto out; if (memcmp(&il->active, &il->staging, sizeof(il->staging))) - il_commit_rxon(il, ctx); + il_commit_rxon(il); else D_INFO("Not re-sending same RXON configuration.\n"); if (ht_changed) - il_update_qos(il, ctx); + il_update_qos(il); out: D_MAC80211("leave\n"); @@ -5378,7 +5345,6 @@ 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; @@ -5413,7 +5379,7 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) * clear RXON_FILTER_ASSOC_MSK bit */ il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); + il_commit_rxon(il); il_set_rate(il); @@ -5486,8 +5452,6 @@ il_ht_conf(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); - /* * inform the ucode that there is no longer an * association and that no more packets should be @@ -5495,7 +5459,7 @@ il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) */ il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il->staging.assoc_id = 0; - il_commit_rxon(il, ctx); + il_commit_rxon(il); } static void @@ -5513,8 +5477,8 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); - if (!il->beacon_ctx) { - IL_ERR("update beacon but no beacon context!\n"); + if (!il->beacon_enabled) { + IL_ERR("update beacon with no beaconing enabled\n"); dev_kfree_skb(skb); return; } @@ -5545,7 +5509,6 @@ 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)) @@ -5565,20 +5528,16 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, spin_lock_irqsave(&il->lock, flags); il->qos_data.qos_active = bss_conf->qos; - il_update_qos(il, ctx); + il_update_qos(il); 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. - */ + /* FIXME: can we remove beacon_enabled ? */ if (vif->bss_conf.enable_beacon) - il->beacon_ctx = ctx; + il->beacon_enabled = true; else - il->beacon_ctx = NULL; + il->beacon_enabled = false; } if (changes & BSS_CHANGED_BSSID) { @@ -5658,7 +5617,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, il_ht_conf(il, vif); if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + il->cfg->ops->hcmd->set_rxon_chain(il); } if (changes & BSS_CHANGED_ASSOC) { @@ -5674,7 +5633,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (changes && il_is_associated(il) && bss_conf->aid) { D_MAC80211("Changes (%#x) while associated\n", changes); - ret = il_send_rxon_assoc(il, ctx); + ret = il_send_rxon_assoc(il); if (!ret) { /* Sync active_rxon with latest change. */ memcpy((void *)&il->active, &il->staging, diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 51c1eecf7510..746eec08886d 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -146,7 +146,6 @@ struct il_queue { /* One for each TFD */ struct il_tx_info { struct sk_buff *skb; - struct il_rxon_context *ctx; }; /** @@ -741,7 +740,6 @@ struct il_station_entry { }; struct il_station_priv_common { - struct il_rxon_context *ctx; u8 sta_id; }; @@ -752,7 +750,6 @@ struct il_station_priv_common { * space for us to put data into. */ struct il_vif_priv { - struct il_rxon_context *ctx; u8 ibss_bssid_sta_id; }; @@ -1257,7 +1254,7 @@ struct il_priv { u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; - struct il_rxon_context ctx; + struct ieee80211_vif *vif; struct il_qos_info qos_data; @@ -1426,7 +1423,7 @@ struct il_priv { struct work_struct rx_replenish; struct work_struct abort_scan; - struct il_rxon_context *beacon_ctx; + bool beacon_enabled; struct sk_buff *beacon_skb; struct work_struct tx_flush; @@ -1493,17 +1490,6 @@ il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) 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) { @@ -1585,10 +1571,9 @@ 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); + int (*commit_rxon) (struct il_priv *il); + void (*set_rxon_chain) (struct il_priv *il); }; struct il_hcmd_utils_ops { @@ -1811,20 +1796,17 @@ 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); +void il_set_rxon_hwcrypto(struct il_priv *il, int hw_decrypt); +int il_check_rxon_cmd(struct il_priv *il); +int il_full_rxon_required(struct il_priv *il); +int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch); +void il_set_flags_for_band(struct il_priv *il, 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, +bool il_is_ht40_tx_allowed(struct il_priv *il, struct ieee80211_sta_ht_cap *ht_cap); -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); 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); @@ -1927,7 +1909,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); /******************************************************************************* * Scanning @@ -2014,10 +1996,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); #else static inline void -il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) +il_print_rx_config_cmd(struct il_priv *il) { } #endif @@ -2106,17 +2088,18 @@ 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); +int il_send_rxon_timing(struct il_priv *il); + static inline int -il_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) +il_send_rxon_assoc(struct il_priv *il) { - return il->cfg->ops->hcmd->rxon_assoc(il, ctx); + return il->cfg->ops->hcmd->rxon_assoc(il); } static inline int -il_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +il_commit_rxon(struct il_priv *il) { - return il->cfg->ops->hcmd->commit_rxon(il, ctx); + return il->cfg->ops->hcmd->commit_rxon(il); } static inline const struct ieee80211_supported_band * @@ -2274,23 +2257,22 @@ il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask) (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); +void il_clear_ucode_stations(struct il_priv *il); 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, +int il_add_station_common(struct il_priv *il, 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); +u8 il_prep_station(struct il_priv *il, 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_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq, + u8 flags, bool init); /** * il_clear_driver_stations - clear knowledge of all stations from driver @@ -2334,8 +2316,7 @@ il_sta_id(struct ieee80211_sta *sta) * 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) +il_sta_id_or_broadcast(struct il_priv *il, struct ieee80211_sta *sta) { int sta_id; -- GitLab From c39ae9fd505ae314a7a4a159a41e3e022cfa317f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:58 +0100 Subject: [PATCH 0441/1846] iwlegacy: move ops out of config Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 22 ++-- drivers/net/wireless/iwlegacy/3945.c | 13 +-- drivers/net/wireless/iwlegacy/3945.h | 4 +- drivers/net/wireless/iwlegacy/4965-calib.c | 4 +- drivers/net/wireless/iwlegacy/4965-mac.c | 78 ++++++++------ drivers/net/wireless/iwlegacy/4965.c | 34 +----- drivers/net/wireless/iwlegacy/4965.h | 3 +- drivers/net/wireless/iwlegacy/common.c | 115 ++++++++------------- drivers/net/wireless/iwlegacy/common.h | 8 +- drivers/net/wireless/iwlegacy/debug.c | 13 +-- 10 files changed, 127 insertions(+), 167 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index b2e04c591c6e..40ce692b2c94 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -618,8 +618,7 @@ 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->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). */ @@ -628,8 +627,8 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) 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)); + il->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 */ @@ -2416,7 +2415,7 @@ __il3945_up(struct il_priv *il) /* 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); + rc = il->ops->lib->load_ucode(il); if (rc) { IL_ERR("Unable to set up bootstrap uCode: %d\n", rc); @@ -3458,7 +3457,7 @@ static struct attribute_group il3945_attribute_group = { .attrs = il3945_sysfs_entries, }; -struct ieee80211_ops il3945_hw_ops = { +struct ieee80211_ops il3945_mac_ops = { .tx = il3945_mac_tx, .start = il3945_mac_start, .stop = il3945_mac_stop, @@ -3599,15 +3598,13 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 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"); + hw = ieee80211_alloc_hw(sizeof(struct il_priv), &il3945_mac_ops); + if (!hw) { err = -ENOMEM; goto out; } il = hw->priv; + il->hw = hw; SET_IEEE80211_DEV(hw, &pdev->dev); il->cmd_queue = IL39_CMD_QUEUE_NUM; @@ -3618,11 +3615,12 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) */ if (il3945_mod_params.disable_hw_scan) { D_INFO("Disabling hw_scan\n"); - il3945_hw_ops.hw_scan = NULL; + il3945_mac_ops.hw_scan = NULL; } D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; + il->ops = &il3945_ops; il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 1e617c9fc3cc..918cbefd657a 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -303,7 +303,7 @@ il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) 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); + il->ops->lib->txq_free_tfd(il, txq); } if (il_queue_space(q) > q->low_mark && txq_id >= 0 && @@ -960,12 +960,12 @@ il3945_hw_nic_init(struct il_priv *il) struct il_rx_queue *rxq = &il->rxq; spin_lock_irqsave(&il->lock, flags); - il->cfg->ops->lib->apm_ops.init(il); + il->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); + il->ops->lib->apm_ops.config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { @@ -1615,7 +1615,7 @@ il3945_hw_reg_comp_txpower_temp(struct il_priv *il) } /* send Txpower command for current channel to ucode */ - return il->cfg->ops->lib->send_tx_power(il); + return il->ops->lib->send_tx_power(il); } int @@ -2685,13 +2685,12 @@ static struct il_hcmd_utils_ops il3945_hcmd_utils = { .post_scan = il3945_post_scan, }; -static const struct il_ops il3945_ops = { +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 = { @@ -2711,7 +2710,6 @@ static struct il_cfg il3945_bg_cfg = { .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, @@ -2724,7 +2722,6 @@ static struct il_cfg il3945_abg_cfg = { .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, diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 8bee127d413d..c00a8d30b6fe 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -36,6 +36,8 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" +extern const struct il_ops il3945_ops; + /* Highest firmware API version supported */ #define IL3945_UCODE_API_MAX 2 @@ -261,8 +263,6 @@ extern int il3945_commit_rxon(struct il_priv *il); */ 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); diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index f302a6ac6286..bfb361dbba50 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -923,8 +923,8 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* 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); + if (il->ops->lib->update_chain_flags) + il->ops->lib->update_chain_flags(il); data->state = IL_CHAIN_NOISE_DONE; il_power_update_mode(il, false); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 4be53cc91981..2bf743fc7829 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -201,7 +201,7 @@ il4965_hw_nic_init(struct il_priv *il) /* nic_init */ spin_lock_irqsave(&il->lock, flags); - il->cfg->ops->lib->apm_ops.init(il); + il->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); @@ -210,7 +210,7 @@ il4965_hw_nic_init(struct il_priv *il) il4965_set_pwr_vmain(il); - il->cfg->ops->lib->apm_ops.config(il); + il->ops->lib->apm_ops.config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { @@ -1381,8 +1381,8 @@ il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) 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); + if (il->ops->lib->temp_ops.temperature && change) + il->ops->lib->temp_ops.temperature(il); } void @@ -1817,8 +1817,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) 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->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; @@ -1834,8 +1833,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) 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); + il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, + secondlen, 0, 0); } scratch_phys = @@ -1855,9 +1854,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* 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)); + il->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); @@ -2479,7 +2477,7 @@ il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) txq_id >= IL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; - il->cfg->ops->lib->txq_free_tfd(il, txq); + il->ops->lib->txq_free_tfd(il, txq); } return nfreed; } @@ -3357,8 +3355,8 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) 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); + if (il->ops->hcmd->set_rxon_chain) { + il->ops->hcmd->set_rxon_chain(il); if (il->active.rx_chain != il->staging.rx_chain) il_commit_rxon(il); } @@ -3878,7 +3876,7 @@ il4965_setup_handlers(struct il_priv *il) /* block ack */ il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; /* Set up hardware specific Rx handlers */ - il->cfg->ops->lib->handler_setup(il); + il->ops->lib->handler_setup(il); } /** @@ -4780,7 +4778,7 @@ il4965_dump_nic_error_log(struct il_priv *il) else base = le32_to_cpu(il->card_alive.error_event_table_ptr); - if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + if (!il->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; @@ -5009,8 +5007,8 @@ il4965_alive_start(struct il_priv *il) /* Initialize our rx_config data */ il_connection_init_rx_config(il); - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); } /* Configure bluetooth coexistence if enabled */ @@ -5282,7 +5280,7 @@ __il4965_up(struct il_priv *il) /* 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); + ret = il->ops->lib->load_ucode(il); if (ret) { IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); @@ -5323,7 +5321,7 @@ il4965_bg_init_alive_start(struct work_struct *data) if (test_bit(S_EXIT_PENDING, &il->status)) goto out; - il->cfg->ops->lib->init_alive_start(il); + il->ops->lib->init_alive_start(il); out: mutex_unlock(&il->mutex); } @@ -5755,7 +5753,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, if (!il_is_associated(il)) goto out; - if (!il->cfg->ops->lib->set_channel_switch) + if (!il->ops->lib->set_channel_switch) goto out; ch = channel->hw_value; @@ -5807,7 +5805,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, */ 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)) { + if (il->ops->lib->set_channel_switch(il, ch_switch)) { clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = 0; ieee80211_chswitch_done(il->vif, false); @@ -5890,7 +5888,7 @@ il4965_bg_txpower_work(struct work_struct *work) /* 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); + il->ops->lib->send_tx_power(il); /* Update last_temperature to keep is_calib_needed from running * when it isn't needed... */ @@ -5996,6 +5994,28 @@ il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } +const struct ieee80211_ops il4965_mac_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 int il4965_init_drv(struct il_priv *il) { @@ -6020,8 +6040,8 @@ il4965_init_drv(struct il_priv *il) 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); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); il_init_scan_params(il); @@ -6081,7 +6101,7 @@ il4965_set_hw_params(struct il_priv *il) il->cfg->sku &= ~IL_SKU_N; /* Device-specific setup */ - return il->cfg->ops->lib->set_hw_params(il); + return il->ops->lib->set_hw_params(il); } static int @@ -6098,18 +6118,18 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 1. Allocating HW data ************************/ - hw = il_alloc_all(cfg); + hw = ieee80211_alloc_hw(sizeof(struct il_priv), &il4965_mac_ops); if (!hw) { err = -ENOMEM; goto out; } il = hw->priv; - /* At this point both hw and il are allocated. */ - + il->hw = hw; SET_IEEE80211_DEV(hw, &pdev->dev); D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; + il->ops = &il4965_ops; il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 9d9197f7fa38..27feb533d025 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2166,8 +2166,8 @@ il4965_post_associate(struct il_priv *il) 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); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); @@ -2241,8 +2241,8 @@ il4965_config_ap(struct il_priv *il) /* 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); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); il->staging.assoc_id = 0; @@ -2323,35 +2323,12 @@ static const struct il_legacy_ops il4965_legacy_ops = { .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 = { +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 = { @@ -2380,7 +2357,6 @@ struct il_cfg il4965_cfg = { .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, diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 67899602ee52..83ab60496388 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -38,11 +38,10 @@ struct il_rxon_context; /* configuration for the _4965 devices */ extern struct il_cfg il4965_cfg; +extern const struct il_ops il4965_ops; 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); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index bee11a3aeac0..3bd183336563 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -520,7 +520,7 @@ il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) il_blink_compensation(il, off, il->cfg->base_params->led_compensation); - ret = il->cfg->ops->led->cmd(il, &led_cmd); + ret = il->ops->led->cmd(il, &led_cmd); if (!ret) { il->blink_on = on; il->blink_off = off; @@ -731,7 +731,7 @@ il_eeprom_init(struct il_priv *il) } e = (__le16 *) il->eeprom; - il->cfg->ops->lib->apm_ops.init(il); + il->ops->lib->apm_ops.init(il); ret = il_eeprom_verify_signature(il); if (ret < 0) { @@ -741,7 +741,7 @@ 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); + ret = il->ops->lib->eeprom_ops.acquire_semaphore(il); if (ret < 0) { IL_ERR("Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; @@ -773,7 +773,7 @@ il_eeprom_init(struct il_priv *il) ret = 0; done: - il->cfg->ops->lib->eeprom_ops.release_semaphore(il); + il->ops->lib->eeprom_ops.release_semaphore(il); err: if (ret) @@ -800,7 +800,7 @@ il_init_band_reference(const struct il_priv *il, int eep_band, const u8 **eeprom_ch_idx) { u32 offset = - il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; + il->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); @@ -1001,9 +1001,9 @@ il_init_channel_map(struct il_priv *il) } /* Check if we do have HT40 channels */ - if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == + if (il->ops->lib->eeprom_ops.regulatory_bands[5] == EEPROM_REGULATORY_BAND_NO_HT40 && - il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == + il->ops->lib->eeprom_ops.regulatory_bands[6] == EEPROM_REGULATORY_BAND_NO_HT40) return 0; @@ -1158,9 +1158,9 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force) 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) + if (il->ops->lib->update_chain_flags && update_chains) + il->ops->lib->update_chain_flags(il); + else if (il->ops->lib->update_chain_flags) D_POWER("Cannot update the power, chain noise " "calibration running: %d\n", il->chain_noise_data.state); @@ -1485,7 +1485,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); - if (WARN_ON(!il->cfg->ops->utils->request_scan)) + if (WARN_ON(!il->ops->utils->request_scan)) return -EOPNOTSUPP; cancel_delayed_work(&il->scan_check); @@ -1510,7 +1510,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) set_bit(S_SCANNING, &il->status); il->scan_start = jiffies; - ret = il->cfg->ops->utils->request_scan(il, vif); + ret = il->ops->utils->request_scan(il, vif); if (ret) { clear_bit(S_SCANNING, &il->status); return ret; @@ -1672,7 +1672,7 @@ il_bg_scan_completed(struct work_struct *work) 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); + il->ops->utils->post_scan(il); out: mutex_unlock(&il->mutex); @@ -1814,7 +1814,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) might_sleep(); } - cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); + cmd.len = il->ops->utils->build_addsta_hcmd(sta, data); ret = il_send_cmd(il, &cmd); if (ret || (flags & CMD_ASYNC)) @@ -2722,7 +2722,7 @@ il_tx_queue_unmap(struct il_priv *il, int txq_id) return; while (q->write_ptr != q->read_ptr) { - il->cfg->ops->lib->txq_free_tfd(il, txq); + il->ops->lib->txq_free_tfd(il, txq); q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } @@ -3024,7 +3024,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, 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); + il->ops->lib->txq_init(il, txq); return 0; err: @@ -3055,7 +3055,7 @@ il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, 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); + il->ops->lib->txq_init(il, txq); } EXPORT_SYMBOL(il_tx_queue_reset); @@ -3083,7 +3083,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) u32 idx; u16 fix_size; - cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); + cmd->len = il->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 @@ -3162,9 +3162,9 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) #endif txq->need_update = 1; - if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) + if (il->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); + il->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, @@ -3172,8 +3172,8 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) 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->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); @@ -3315,30 +3315,6 @@ 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 @@ -3871,8 +3847,8 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; } - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); D_ASSOC("rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), @@ -4130,9 +4106,9 @@ il_irq_handle_error(struct il_priv *il) 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); + il->ops->lib->dump_nic_error_log(il); + if (il->ops->lib->dump_fh) + il->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); @@ -4319,7 +4295,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) if (il->tx_power_user_lmt == tx_power && !force) return 0; - if (!il->cfg->ops->lib->send_tx_power) + if (!il->ops->lib->send_tx_power) return -EOPNOTSUPP; /* 0 dBm mean 1 milliwatt */ @@ -4352,7 +4328,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) prev_tx_power = il->tx_power_user_lmt; il->tx_power_user_lmt = tx_power; - ret = il->cfg->ops->lib->send_tx_power(il); + ret = il->ops->lib->send_tx_power(il); /* if fail to set tx_power, restore the orig. tx power */ if (ret) { @@ -4501,8 +4477,8 @@ il_set_mode(struct il_priv *il) { il_connection_init_rx_config(il); - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); return il_commit_rxon(il); } @@ -5200,7 +5176,7 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) int scan_active = 0; bool ht_changed = false; - if (WARN_ON(!il->cfg->ops->legacy)) + if (WARN_ON(!il->ops->legacy)) return -EOPNOTSUPP; mutex_lock(&il->mutex); @@ -5225,8 +5201,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) * 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); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); } /* during scanning mac80211 will delay channel setting until @@ -5295,8 +5271,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) spin_unlock_irqrestore(&il->lock, flags); - if (il->cfg->ops->legacy->update_bcast_stations) - ret = il->cfg->ops->legacy->update_bcast_stations(il); + if (il->ops->legacy->update_bcast_stations) + ret = il->ops->legacy->update_bcast_stations(il); set_ch_out: /* The list of supported rates and rate mask can be different @@ -5346,7 +5322,7 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct il_priv *il = hw->priv; unsigned long flags; - if (WARN_ON(!il->cfg->ops->legacy)) + if (WARN_ON(!il->ops->legacy)) return; mutex_lock(&il->mutex); @@ -5501,7 +5477,7 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) return; } - il->cfg->ops->legacy->post_associate(il); + il->ops->legacy->post_associate(il); } void @@ -5511,7 +5487,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct il_priv *il = hw->priv; int ret; - if (WARN_ON(!il->cfg->ops->legacy)) + if (WARN_ON(!il->ops->legacy)) return; D_MAC80211("changes = 0x%X\n", changes); @@ -5616,8 +5592,8 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 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); + if (il->ops->hcmd->set_rxon_chain) + il->ops->hcmd->set_rxon_chain(il); } if (changes & BSS_CHANGED_ASSOC) { @@ -5626,7 +5602,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, il->timestamp = bss_conf->timestamp; if (!il_is_rfkill(il)) - il->cfg->ops->legacy->post_associate(il); + il->ops->legacy->post_associate(il); } else il_set_no_assoc(il, vif); } @@ -5646,16 +5622,15 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, memcpy(il->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - il->cfg->ops->legacy->config_ap(il); + il->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); + il->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", diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 746eec08886d..2af861062de0 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1167,6 +1167,7 @@ struct il_priv { struct ieee80211_channel *ieee_channels; struct ieee80211_rate *ieee_rates; struct il_cfg *cfg; + const struct il_ops *ops; /* temporary frame storage list */ struct list_head free_frames; @@ -1668,7 +1669,6 @@ struct il_ops { 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 { @@ -1777,7 +1777,6 @@ struct il_cfg { 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 */ @@ -1791,7 +1790,6 @@ struct il_cfg { * 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); @@ -2093,13 +2091,13 @@ int il_send_rxon_timing(struct il_priv *il); static inline int il_send_rxon_assoc(struct il_priv *il) { - return il->cfg->ops->hcmd->rxon_assoc(il); + return il->ops->hcmd->rxon_assoc(il); } static inline int il_commit_rxon(struct il_priv *il) { - return il->cfg->ops->hcmd->commit_rxon(il); + return il->ops->hcmd->commit_rxon(il); } static inline const struct ieee80211_supported_band * diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 3a9609a88748..4fb769caef5a 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -901,8 +901,7 @@ 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->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos); } static ssize_t @@ -910,8 +909,7 @@ 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->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos); } static ssize_t @@ -919,8 +917,7 @@ 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->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos); } static ssize_t @@ -1178,8 +1175,8 @@ il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, 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 (il->ops->lib->dump_fh) { + ret = pos = il->ops->lib->dump_fh(il, &buf, true); if (buf) { ret = simple_read_from_buffer(user_buf, count, ppos, buf, -- GitLab From 89ef1ed2d241d3dfe884055d8446a5dd94919e54 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:31:59 +0100 Subject: [PATCH 0442/1846] iwlegacy: merge il_base_params into il_cfg Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945.c | 30 ++++++++++-------- drivers/net/wireless/iwlegacy/4965-calib.c | 14 ++++---- drivers/net/wireless/iwlegacy/4965-mac.c | 8 ++--- drivers/net/wireless/iwlegacy/4965.c | 37 ++++++++++------------ drivers/net/wireless/iwlegacy/common.c | 28 ++++++++-------- drivers/net/wireless/iwlegacy/common.h | 31 +++++++++--------- drivers/net/wireless/iwlegacy/debug.c | 16 +++++----- 7 files changed, 83 insertions(+), 81 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 918cbefd657a..7c21a57d1bb5 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2398,7 +2398,7 @@ il3945_hw_set_hw_params(struct il_priv *il) il->hw_params.bcast_id = IL3945_BROADCAST_ID; /* Assign number of Usable TX queues */ - il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + il->hw_params.max_txq_num = il->cfg->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); @@ -2693,16 +2693,6 @@ const struct il_ops il3945_ops = { .legacy = &il3945_legacy_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, @@ -2711,8 +2701,15 @@ static struct il_cfg il3945_bg_cfg = { .sku = IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .mod_params = &il3945_mod_params, - .base_params = &il3945_base_params, .led_mode = IL_LED_BLINK, + + .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_abg_cfg = { @@ -2723,8 +2720,15 @@ static struct il_cfg il3945_abg_cfg = { .sku = IL_SKU_A | IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .mod_params = &il3945_mod_params, - .base_params = &il3945_base_params, .led_mode = IL_LED_BLINK, + + .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 }; DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index bfb361dbba50..fe9171506a91 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -627,13 +627,13 @@ il4965_find_disconn_antenna(struct il_priv *il, u32 * average_sig, average_sig[0] = data->chain_signal_a / - il->cfg->base_params->chain_noise_num_beacons; + il->cfg->chain_noise_num_beacons; average_sig[1] = data->chain_signal_b / - il->cfg->base_params->chain_noise_num_beacons; + il->cfg->chain_noise_num_beacons; average_sig[2] = data->chain_signal_c / - il->cfg->base_params->chain_noise_num_beacons; + il->cfg->chain_noise_num_beacons; if (average_sig[0] >= average_sig[1]) { max_average_sig = average_sig[0]; @@ -886,7 +886,7 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* 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->chain_noise_num_beacons) return; /* Analyze signal for disconnected antenna */ @@ -894,11 +894,11 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* Analyze noise for rx balance */ average_noise[0] = - data->chain_noise_a / il->cfg->base_params->chain_noise_num_beacons; + data->chain_noise_a / il->cfg->chain_noise_num_beacons; average_noise[1] = - data->chain_noise_b / il->cfg->base_params->chain_noise_num_beacons; + data->chain_noise_b / il->cfg->chain_noise_num_beacons; average_noise[2] = - data->chain_noise_c / il->cfg->base_params->chain_noise_num_beacons; + data->chain_noise_c / il->cfg->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { if (!data->disconn_array[i] && diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2bf743fc7829..49dd1e0e9a55 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2150,11 +2150,11 @@ il4965_txq_agg_enable(struct il_priv *il, int txq_id, int tx_fifo, int sta_id, if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + il->cfg->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); + il->cfg->num_of_ampdu_queues - 1); return -EINVAL; } @@ -2278,11 +2278,11 @@ 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->cfg->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); + il->cfg->num_of_ampdu_queues - 1); return -EINVAL; } diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 27feb533d025..cf1d0164a9a0 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -614,13 +614,13 @@ 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->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.max_txq_num = il->cfg->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 * + il->cfg->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; @@ -2331,22 +2331,6 @@ const struct il_ops il4965_ops = { .legacy = &il4965_legacy_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, @@ -2358,13 +2342,26 @@ struct il_cfg il4965_cfg = { .eeprom_ver = EEPROM_4965_EEPROM_VERSION, .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, .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, + + .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, }; /* Module firmware */ diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 3bd183336563..1173521f21fb 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -512,13 +512,13 @@ il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) } D_LED("Led blink time compensation=%u\n", - il->cfg->base_params->led_compensation); + il->cfg->led_compensation); led_cmd.on = il_blink_compensation(il, on, - il->cfg->base_params->led_compensation); + il->cfg->led_compensation); led_cmd.off = il_blink_compensation(il, off, - il->cfg->base_params->led_compensation); + il->cfg->led_compensation); ret = il->ops->led->cmd(il, &led_cmd); if (!ret) { @@ -691,7 +691,7 @@ il_eeprom_verify_signature(struct il_priv *il) const u8 * il_eeprom_query_addr(const struct il_priv *il, size_t offset) { - BUG_ON(offset >= il->cfg->base_params->eeprom_size); + BUG_ON(offset >= il->cfg->eeprom_size); return &il->eeprom[offset]; } EXPORT_SYMBOL(il_eeprom_query_addr); @@ -722,7 +722,7 @@ il_eeprom_init(struct il_priv *il) u16 addr; /* allocate eeprom */ - sz = il->cfg->base_params->eeprom_size; + sz = il->cfg->eeprom_size; D_EEPROM("NVM size = %d\n", sz); il->eeprom = kzalloc(sz, GFP_KERNEL); if (!il->eeprom) { @@ -4218,7 +4218,7 @@ il_apm_init(struct il_priv *il) * If not (unlikely), enable L0S, so there is at least some * power savings, even without L1. */ - if (il->cfg->base_params->set_l0s) { + if (il->cfg->set_l0s) { lctl = il_pcie_link_ctl(il); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) { @@ -4235,9 +4235,9 @@ il_apm_init(struct il_priv *il) } /* Configure analog phase-lock-loop before activating to D0A */ - if (il->cfg->base_params->pll_cfg_val) + if (il->cfg->pll_cfg_val) il_set_bit(il, CSR_ANA_PLL_CFG, - il->cfg->base_params->pll_cfg_val); + il->cfg->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from @@ -4267,7 +4267,7 @@ il_apm_init(struct il_priv *il) * 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) + if (il->cfg->use_bsm) il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else @@ -4565,7 +4565,7 @@ 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->cfg->num_of_queues, GFP_KERNEL); if (!il->txq) { IL_ERR("Not enough memory for txq\n"); return -ENOMEM; @@ -4942,11 +4942,11 @@ il_check_stuck_queue(struct il_priv *il, int cnt) timeout = txq->time_stamp + - msecs_to_jiffies(il->cfg->base_params->wd_timeout); + msecs_to_jiffies(il->cfg->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->cfg->wd_timeout); ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -4974,7 +4974,7 @@ il_bg_watchdog(unsigned long data) if (test_bit(S_EXIT_PENDING, &il->status)) return; - timeout = il->cfg->base_params->wd_timeout; + timeout = il->cfg->wd_timeout; if (timeout == 0) return; @@ -5001,7 +5001,7 @@ EXPORT_SYMBOL(il_bg_watchdog); void il_setup_watchdog(struct il_priv *il) { - unsigned int timeout = il->cfg->base_params->wd_timeout; + unsigned int timeout = il->cfg->wd_timeout; if (timeout) mod_timer(&il->watchdog, diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 2af861062de0..21ed70a7f68c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1695,21 +1695,6 @@ struct il_mod_params { * 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; }; #define IL_LED_SOLID 11 @@ -1784,6 +1769,22 @@ struct il_cfg { /* params likely to change within a device family */ u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; enum il_led_mode led_mode; + + 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; }; /*************************** diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 4fb769caef5a..bb7c95607a69 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -361,7 +361,7 @@ il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count, const u8 *ptr; char *buf; u16 eeprom_ver; - size_t eeprom_len = il->cfg->base_params->eeprom_size; + size_t eeprom_len = il->cfg->eeprom_size; buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { @@ -727,7 +727,7 @@ il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, char *buf; int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (il->cfg->base_params->num_of_queues * 32 * 8) + 400; + (il->cfg->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; @@ -833,7 +833,7 @@ il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, int cnt; int ret; const size_t bufsz = - sizeof(char) * 64 * il->cfg->base_params->num_of_queues; + sizeof(char) * 64 * il->cfg->num_of_queues; if (!il->txq) { IL_ERR("txq not ready\n"); @@ -1293,7 +1293,7 @@ il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) timeout = IL_DEF_WD_TIMEOUT; - il->cfg->base_params->wd_timeout = timeout; + il->cfg->wd_timeout = timeout; il_setup_watchdog(il); return count; } @@ -1367,17 +1367,17 @@ il_dbgfs_register(struct il_priv *il, const char *name) 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) + if (il->cfg->sensitivity_calib_by_driver) DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); - if (il->cfg->base_params->chain_noise_calib_by_driver) + if (il->cfg->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) + if (il->cfg->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) + if (il->cfg->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); -- GitLab From 00ea99e1d86b05e7ba90d66673b536b731af87cd Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:32:00 +0100 Subject: [PATCH 0443/1846] iwlegacy: remove struct il_tx_info It's just wrapper to sk_buff pointers ... Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 4 +-- drivers/net/wireless/iwlegacy/3945.c | 18 ++++++------- drivers/net/wireless/iwlegacy/4965-mac.c | 33 ++++++++++-------------- drivers/net/wireless/iwlegacy/4965.c | 18 +++++++------ drivers/net/wireless/iwlegacy/common.c | 24 ++++++++--------- drivers/net/wireless/iwlegacy/common.h | 18 ++----------- 6 files changed, 46 insertions(+), 69 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 40ce692b2c94..aa8f5c0bd642 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -538,9 +538,7 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) 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->skbs[q->write_ptr] = skb; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 7c21a57d1bb5..6c1ae5fab899 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -293,16 +293,16 @@ 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; + struct sk_buff *skb; 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; + skb = txq->skbs[txq->q.read_ptr]; + ieee80211_tx_status_irqsafe(il->hw, skb); + txq->skbs[txq->q.read_ptr] = NULL; il->ops->lib->txq_free_tfd(il, txq); } @@ -336,7 +336,7 @@ il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) } txq->time_stamp = jiffies; - info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); + info = IEEE80211_SKB_CB(txq->skbs[txq->q.read_ptr]); ieee80211_tx_info_clear_status(info); /* Fill the MRR chain with some info about on-chip retransmissions */ @@ -660,15 +660,13 @@ il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) PCI_DMA_TODEVICE); /* free SKB */ - if (txq->txb) { - struct sk_buff *skb; - - skb = txq->txb[txq->q.read_ptr].skb; + if (txq->skbs) { + struct sk_buff *skb = txq->skbs[txq->q.read_ptr]; /* can be called from irqs-disabled context */ if (skb) { dev_kfree_skb_any(skb); - txq->txb[txq->q.read_ptr].skb = NULL; + txq->skbs[txq->q.read_ptr] = NULL; } } } diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 49dd1e0e9a55..2a52e7b7325a 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1753,9 +1753,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) 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->skbs[q->write_ptr] = skb; /* Set up first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[q->write_ptr]; @@ -2435,14 +2433,14 @@ il4965_non_agg_tx_status(struct il_priv *il, const u8 *addr1) } 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 sk_buff *skb, bool is_agg) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; if (!is_agg) il4965_non_agg_tx_status(il, hdr->addr1); - ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); + ieee80211_tx_status_irqsafe(il->hw, skb); } int @@ -2450,9 +2448,9 @@ 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; + struct sk_buff *skb; if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " @@ -2464,19 +2462,18 @@ il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int 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]; + skb = txq->skbs[txq->q.read_ptr]; - if (WARN_ON_ONCE(tx_info->skb == NULL)) + if (WARN_ON_ONCE(skb == NULL)) continue; - hdr = (struct ieee80211_hdr *)tx_info->skb->data; + hdr = (struct ieee80211_hdr *) 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; + il4965_tx_status(il, skb, txq_id >= IL4965_FIRST_AMPDU_QUEUE); + txq->skbs[txq->q.read_ptr] = NULL; il->ops->lib->txq_free_tfd(il, txq); } return nfreed; @@ -2540,7 +2537,7 @@ il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, D_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); - info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); + info = IEEE80211_SKB_CB(il->txq[scd_flow].skbs[agg->start_idx]); memset(&info->status, 0, sizeof(info->status)); info->flags |= IEEE80211_TX_STAT_ACK; info->flags |= IEEE80211_TX_STAT_AMPDU; @@ -3624,15 +3621,13 @@ il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) PCI_DMA_TODEVICE); /* free SKB */ - if (txq->txb) { - struct sk_buff *skb; - - skb = txq->txb[txq->q.read_ptr].skb; + if (txq->skbs) { + struct sk_buff *skb = txq->skbs[txq->q.read_ptr]; /* can be called from irqs-disabled context */ if (skb) { dev_kfree_skb_any(skb); - txq->txb[txq->q.read_ptr].skb = NULL; + txq->skbs[txq->q.read_ptr] = NULL; } } } diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index cf1d0164a9a0..17a6922e890d 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1873,7 +1873,7 @@ il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, 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 = IEEE80211_SKB_CB(il->txq[txq_id].skbs[idx]); info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags &= ~IEEE80211_TX_CTL_AMPDU; info->flags |= il4965_tx_status_to_mac80211(status); @@ -1888,6 +1888,7 @@ il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, /* Two or more frames were attempted; expect block-ack */ u64 bitmap = 0; int start = agg->start_idx; + struct sk_buff *skb; /* Construct bit-map of pending frames within Tx win */ for (i = 0; i < agg->frame_count; i++) { @@ -1905,12 +1906,10 @@ il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, 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); + skb = il->txq[txq_id].skbs[idx]; + if (WARN_ON_ONCE(skb == NULL)) return -1; - } + hdr = (struct ieee80211_hdr *) skb->data; sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { @@ -2018,6 +2017,7 @@ il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) int txq_id = SEQ_TO_QUEUE(sequence); int idx = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; + struct sk_buff *skb; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -2036,10 +2036,12 @@ il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) } txq->time_stamp = jiffies; - info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); + + skb = txq->skbs[txq->q.read_ptr]; + info = IEEE80211_SKB_CB(skb); memset(&info->status, 0, sizeof(info->status)); - hdr = il_tx_queue_get_hdr(il, txq_id, idx); + hdr = (struct ieee80211_hdr *) skb->data; if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 1173521f21fb..04ec38e5eaaf 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -2755,8 +2755,8 @@ il_tx_queue_free(struct il_priv *il, int txq_id) txq->tfds, txq->q.dma_addr); /* De-alloc array of per-TFD driver data */ - kfree(txq->txb); - txq->txb = NULL; + kfree(txq->skbs); + txq->skbs = NULL; /* deallocate arrays */ kfree(txq->cmd); @@ -2930,23 +2930,21 @@ 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 = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(txq->txb[0]), - GFP_KERNEL); - if (!txq->txb) { - IL_ERR("kmalloc for auxiliary BD " - "structures failed\n"); + txq->skbs = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(struct skb *), + GFP_KERNEL); + if (!txq->skbs) { + IL_ERR("Fail to alloc skbs\n"); goto error; } - } else { - txq->txb = NULL; - } + } else + txq->skbs = 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); + IL_ERR("Fail to alloc TFDs\n"); goto error; } txq->q.id = id; @@ -2954,8 +2952,8 @@ il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) return 0; error: - kfree(txq->txb); - txq->txb = NULL; + kfree(txq->skbs); + txq->skbs = NULL; return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 21ed70a7f68c..527a1b9f99ea 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -143,11 +143,6 @@ struct il_queue { * space less than this */ }; -/* One for each TFD */ -struct il_tx_info { - struct sk_buff *skb; -}; - /** * struct il_tx_queue - Tx Queue for DMA * @q: generic Rx/Tx queue descriptor @@ -155,7 +150,7 @@ struct il_tx_info { * @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 + * @skbs: array of per-TFD socket buffer pointers * @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 @@ -171,7 +166,7 @@ struct il_tx_queue { void *tfds; struct il_device_cmd **cmd; struct il_cmd_meta *meta; - struct il_tx_info *txb; + struct sk_buff **skbs; unsigned long time_stamp; u8 need_update; u8 sched_retry; @@ -1482,15 +1477,6 @@ 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) -{ - if (il->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)il->txq[txq_id].txb[idx].skb-> - data; - return NULL; -} - static inline int il_is_associated(struct il_priv *il) { -- GitLab From 1023f3bc7b3f56da1f79f605cbe459318c4792ae Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 3 Feb 2012 17:32:01 +0100 Subject: [PATCH 0444/1846] iwlegacy: remove set_hw_params callback We do not need that callback, settings parameters can be done locally. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 66 +++++++++++++++++--- drivers/net/wireless/iwlegacy/4965.c | 76 ------------------------ drivers/net/wireless/iwlegacy/common.h | 2 - 3 files changed, 59 insertions(+), 85 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2a52e7b7325a..235812ac6a0d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6079,7 +6079,34 @@ il4965_hw_detect(struct il_priv *il) D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } -static int +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_hw_params(struct il_priv *il) { il->hw_params.bcast_id = IL4965_BROADCAST_ID; @@ -6095,8 +6122,36 @@ il4965_set_hw_params(struct il_priv *il) if (il->cfg->mod_params->disable_11n) il->cfg->sku &= ~IL_SKU_N; - /* Device-specific setup */ - return il->ops->lib->set_hw_params(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->num_of_queues = + il->cfg->mod_params->num_of_queues; + + il->hw_params.max_txq_num = il->cfg->num_of_queues; + il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; + il->hw_params.scd_bc_tbls_size = + il->cfg->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->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 = 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); + il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; + il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; + + il->hw_params.ct_kill_threshold = + CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); + + il->hw_params.sens = &il4965_sensitivity; + il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; } static int @@ -6230,10 +6285,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("failed to set hw parameters\n"); - goto out_free_eeprom; - } + il4965_set_hw_params(il); /******************* * 6. Setup il diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 17a6922e890d..79e4e7971338 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -569,81 +569,6 @@ 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 */ - - .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->num_of_queues = - il->cfg->mod_params->num_of_queues; - - il->hw_params.max_txq_num = il->cfg->num_of_queues; - il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; - il->hw_params.scd_bc_tbls_size = - il->cfg->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->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 = 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); - 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) { @@ -2276,7 +2201,6 @@ static struct il_hcmd_utils_ops il4965_hcmd_utils = { }; 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, diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 527a1b9f99ea..708095644f17 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1592,8 +1592,6 @@ struct il_temp_ops { }; 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, -- GitLab From a0417fa3a18a14be1f4d9cffcf378a7c42d92a91 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 6 Feb 2012 15:14:37 -0500 Subject: [PATCH 0445/1846] net: Make qdisc_skb_cb upper size bound explicit. Just like skb->cb[], so that qdisc_skb_cb can be encapsulated inside of other data structures. This is intended to be used by IPoIB so that it can remember addressing information stored at hard_header_ops->create() time that it can fetch when the packet gets to the transmit routine. Signed-off-by: David S. Miller --- include/net/sch_generic.h | 9 ++++++++- net/sched/sch_choke.c | 3 +-- net/sched/sch_netem.c | 3 +-- net/sched/sch_sfb.c | 3 +-- net/sched/sch_sfq.c | 5 ++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index f6bb08b73ca4..55ce96b53b09 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -220,9 +220,16 @@ struct tcf_proto { struct qdisc_skb_cb { unsigned int pkt_len; - long data[]; + unsigned char data[24]; }; +static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) +{ + struct qdisc_skb_cb *qcb; + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(unsigned int) + sz); + BUILD_BUG_ON(sizeof(qcb->data) < sz); +} + static inline int qdisc_qlen(const struct Qdisc *q) { return q->q.qlen; diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c index e465064d39a3..7e267d7b9c75 100644 --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c @@ -148,8 +148,7 @@ struct choke_skb_cb { static inline struct choke_skb_cb *choke_skb_cb(const struct sk_buff *skb) { - BUILD_BUG_ON(sizeof(skb->cb) < - sizeof(struct qdisc_skb_cb) + sizeof(struct choke_skb_cb)); + qdisc_cb_private_validate(skb, sizeof(struct choke_skb_cb)); return (struct choke_skb_cb *)qdisc_skb_cb(skb)->data; } diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 2776012132ea..e83d61ca78ca 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -130,8 +130,7 @@ struct netem_skb_cb { static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb) { - BUILD_BUG_ON(sizeof(skb->cb) < - sizeof(struct qdisc_skb_cb) + sizeof(struct netem_skb_cb)); + qdisc_cb_private_validate(skb, sizeof(struct netem_skb_cb)); return (struct netem_skb_cb *)qdisc_skb_cb(skb)->data; } diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 96e42cae4c7a..d7eea99333e9 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c @@ -94,8 +94,7 @@ struct sfb_skb_cb { static inline struct sfb_skb_cb *sfb_skb_cb(const struct sk_buff *skb) { - BUILD_BUG_ON(sizeof(skb->cb) < - sizeof(struct qdisc_skb_cb) + sizeof(struct sfb_skb_cb)); + qdisc_cb_private_validate(skb, sizeof(struct sfb_skb_cb)); return (struct sfb_skb_cb *)qdisc_skb_cb(skb)->data; } diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 67494aef9acf..60d47180f043 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -166,9 +166,8 @@ struct sfq_skb_cb { static inline struct sfq_skb_cb *sfq_skb_cb(const struct sk_buff *skb) { - BUILD_BUG_ON(sizeof(skb->cb) < - sizeof(struct qdisc_skb_cb) + sizeof(struct sfq_skb_cb)); - return (struct sfq_skb_cb *)qdisc_skb_cb(skb)->data; + qdisc_cb_private_validate(skb, sizeof(struct sfq_skb_cb)); + return (struct sfq_skb_cb *)qdisc_skb_cb(skb)->data; } static unsigned int sfq_hash(const struct sfq_sched_data *q, -- GitLab From e1936e9407138b483e6d1332dd944afec8131f30 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 20 Jan 2012 13:55:23 +0100 Subject: [PATCH 0446/1846] mac80211: call rate control only after init There are situations where we don't have the necessary rate control information yet for station entries, e.g. when associating. This currently doesn't really happen due to the dummy station handling; explicitly disabling rate control when it's not initialised will allow us to remove dummy stations. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/debugfs_sta.c | 4 ++-- net/mac80211/rate.c | 2 +- net/mac80211/rate.h | 1 + net/mac80211/sta_info.h | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c index c8383712fdec..6d45804d09bc 100644 --- a/net/mac80211/debugfs_sta.c +++ b/net/mac80211/debugfs_sta.c @@ -63,7 +63,7 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf, test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : "" int res = scnprintf(buf, sizeof(buf), - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", TEST(AUTH), TEST(ASSOC), TEST(PS_STA), TEST(PS_DRIVER), TEST(AUTHORIZED), TEST(SHORT_PREAMBLE), @@ -71,7 +71,7 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf, TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL), TEST(UAPSD), TEST(SP), TEST(TDLS_PEER), TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT), - TEST(INSERTED)); + TEST(INSERTED), TEST(RATE_CONTROL)); #undef TEST return simple_read_from_buffer(userbuf, count, ppos, buf, res); } diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index 22fc28e9026e..111fba38be82 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -439,7 +439,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, u32 mask; u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; - if (sta) { + if (sta && test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) { ista = &sta->sta; priv_sta = sta->rate_ctrl_priv; } diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h index 8268457bd143..5fc3135a6b45 100644 --- a/net/mac80211/rate.h +++ b/net/mac80211/rate.h @@ -58,6 +58,7 @@ static inline void rate_control_rate_init(struct sta_info *sta) sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; ref->ops->rate_init(ref->priv, sband, ista, priv_sta); + set_sta_flag(sta, WLAN_STA_RATE_CONTROL); } static inline void rate_control_rate_update(struct ieee80211_local *local, diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 03f249bc2766..23a97c9dc042 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -53,6 +53,7 @@ * reply to other uAPSD trigger frames or PS-Poll. * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. * @WLAN_STA_INSERTED: This station is inserted into the hash table. + * @WLAN_STA_RATE_CONTROL: rate control was initialized for this station. */ enum ieee80211_sta_info_flags { WLAN_STA_AUTH, @@ -73,6 +74,7 @@ enum ieee80211_sta_info_flags { WLAN_STA_SP, WLAN_STA_4ADDR_EVENT, WLAN_STA_INSERTED, + WLAN_STA_RATE_CONTROL, }; #define STA_TID_NUM 16 -- GitLab From 8809b255a9fca8c3179491d3bc9268c42e23ba97 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 25 Oct 2011 10:44:35 -0400 Subject: [PATCH 0447/1846] tipc: improve the link deferred queue insertion algorithm Re-code the algorithm for inserting an out-of-sequence message into a unicast or broadcast link's deferred message queue. It remains functionally equivalent but should be easier to understand/maintain. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index ac1832a66f8a..c317abf74a78 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1853,17 +1853,16 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) } /* - * link_defer_buf(): Sort a received out-of-sequence packet - * into the deferred reception queue. - * Returns the increase of the queue length,i.e. 0 or 1 + * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue + * + * Returns increase in queue length (i.e. 0 or 1) */ -u32 tipc_link_defer_pkt(struct sk_buff **head, - struct sk_buff **tail, +u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, struct sk_buff *buf) { - struct sk_buff *prev = NULL; - struct sk_buff *crs = *head; + struct sk_buff *queue_buf; + struct sk_buff **prev; u32 seq_no = buf_seqno(buf); buf->next = NULL; @@ -1881,31 +1880,30 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, return 1; } - /* Scan through queue and sort it in */ - do { - struct tipc_msg *msg = buf_msg(crs); + /* Locate insertion point in queue, then insert; discard if duplicate */ + prev = head; + queue_buf = *head; + for (;;) { + u32 curr_seqno = buf_seqno(queue_buf); - if (less(seq_no, msg_seqno(msg))) { - buf->next = crs; - if (prev) - prev->next = buf; - else - *head = buf; - return 1; + if (seq_no == curr_seqno) { + buf_discard(buf); + return 0; } - if (seq_no == msg_seqno(msg)) + + if (less(seq_no, curr_seqno)) break; - prev = crs; - crs = crs->next; - } while (crs); - /* Message is a duplicate of an existing message */ + prev = &queue_buf->next; + queue_buf = queue_buf->next; + } - buf_discard(buf); - return 0; + buf->next = queue_buf; + *prev = buf; + return 1; } -/** +/* * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet */ -- GitLab From 92d2c905b404d8d056ce35a0ce645e23529742c2 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 25 Oct 2011 11:20:26 -0400 Subject: [PATCH 0448/1846] tipc: Prevent transmission of outdated link protocol messages Ensures that a link endpoint discards any previously deferred link protocol message whenever it attempts to send a new one. Previously, it was possible for a link protocol message that was unsent due to congestion to be transmitted after newer protocol messages had been sent. The stale link protocol message might then cause the receiving link endpoint to malfunction because of its outdated conent. Thanks to Osamu Kaminuma [okaminum@avaya.com] for diagnosing the problem and contributing a prototype patch. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 53 +++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index c317abf74a78..bee316ce387c 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1954,6 +1954,13 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, u32 msg_size = sizeof(l_ptr->proto_msg); int r_flag; + /* Discard any previous message that was deferred due to congestion */ + + if (l_ptr->proto_msg_queue) { + buf_discard(l_ptr->proto_msg_queue); + l_ptr->proto_msg_queue = NULL; + } + if (link_blocked(l_ptr)) return; @@ -1962,6 +1969,8 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, if ((l_ptr->owner->block_setup) && (msg_typ != RESET_MSG)) return; + /* Create protocol message with "out-of-sequence" sequence number */ + msg_set_type(msg, msg_typ); msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in)); @@ -2018,44 +2027,36 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, r_flag = (l_ptr->owner->working_links > tipc_link_is_up(l_ptr)); msg_set_redundant_link(msg, r_flag); msg_set_linkprio(msg, l_ptr->priority); - - /* Ensure sequence number will not fit : */ + msg_set_size(msg, msg_size); msg_set_seqno(msg, mod(l_ptr->next_out_no + (0xffff/2))); - /* Congestion? */ - - if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { - if (!l_ptr->proto_msg_queue) { - l_ptr->proto_msg_queue = - tipc_buf_acquire(sizeof(l_ptr->proto_msg)); - } - buf = l_ptr->proto_msg_queue; - if (!buf) - return; - skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); - return; - } - - /* Message can be sent */ - buf = tipc_buf_acquire(msg_size); if (!buf) return; skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); - msg_set_size(buf_msg(buf), msg_size); - if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { - l_ptr->unacked_window = 0; - buf_discard(buf); + /* Defer message if bearer is already congested */ + + if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { + l_ptr->proto_msg_queue = buf; + return; + } + + /* Defer message if attempting to send results in bearer congestion */ + + if (!tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { + tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); + l_ptr->proto_msg_queue = buf; + l_ptr->stats.bearer_congs++; return; } - /* New congestion */ - tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); - l_ptr->proto_msg_queue = buf; - l_ptr->stats.bearer_congs++; + /* Discard message if it was sent successfully */ + + l_ptr->unacked_window = 0; + buf_discard(buf); } /* -- GitLab From 4d75313ce9b832efc4efb487f080b5ed72beae2c Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 25 Oct 2011 12:19:05 -0400 Subject: [PATCH 0449/1846] tipc: Prevent broadcast link stalling in dual LAN environments Ensure that sequence number information about incoming broadcast link messages is initialized only by the activation of the first link to a given cluster node. Previously, a race condition allowed reset and/or activation messages for a second link to re-initialize this sequence number information with obsolete values. This could trigger TIPC to request the retransmission of previously acknowledged broadcast link messages from that node, resulting in broadcast link processing becoming stalled if the node had already released one or more of those messages and was unable to perform the required retransmission. Thanks to Laser for identifying this problem and assisting in the development of this fix. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index bee316ce387c..4ea6cad11746 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -2128,14 +2128,15 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) } l_ptr->owner->bclink.supported = (max_pkt_info != 0); + /* Synchronize broadcast link info, if not done previously */ + + if (!tipc_node_is_up(l_ptr->owner)) + l_ptr->owner->bclink.last_in = msg_last_bcast(msg); + link_state_event(l_ptr, msg_type(msg)); l_ptr->peer_session = msg_session(msg); l_ptr->peer_bearer_id = msg_bearer_id(msg); - - /* Synchronize broadcast sequence numbers */ - if (!tipc_node_redundant_links(l_ptr->owner)) - l_ptr->owner->bclink.last_in = mod(msg_last_bcast(msg)); break; case STATE_MSG: -- GitLab From 934993137199ffb56fef50664f87e71cdb3471b0 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 25 Oct 2011 15:14:46 -0400 Subject: [PATCH 0450/1846] tipc: Ensure broadcast link re-acquires node after link failure Fix a bug that can prevent TIPC from sending broadcast messages to a node if contact with the node is lost and then regained. The problem occurs if the broadcast link first clears the flag indicating the node is part of the link's distribution set (when it loses contact with the node), and later fails to restore the flag (when contact is regained); restoration fails if contact with the node is regained by implicit unicast link activation triggered by the arrival of a data message, rather than explicitly by the arrival of a link activation message. The broadcast link now uses separate fields to track whether a node is theoretically capable of receiving broadcast messages versus whether it is actually part of the link's distribution set. The former member is updated by the receipt of link protocol messages, which can occur at any time; the latter member is updated only when contact with the node is gained or lost. This change also permits the simplification of several conditional expressions since the broadcast link's "supported" field can now only be set if there are working links to the associated node. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 5 +++-- net/tipc/node.c | 3 ++- net/tipc/node.h | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index 4ea6cad11746..3405f560a84d 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1502,6 +1502,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, tipc_addr_string_fill(addr_string, n_ptr->addr); info("Multicast link info for %s\n", addr_string); + info("Supportable: %d, ", n_ptr->bclink.supportable); info("Supported: %d, ", n_ptr->bclink.supported); info("Acked: %u\n", n_ptr->bclink.acked); info("Last in: %u, ", n_ptr->bclink.last_in); @@ -1736,7 +1737,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) /* Release acked messages */ - if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) + if (n_ptr->bclink.supported) tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg)); crs = l_ptr->first_out; @@ -2126,7 +2127,7 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) } else { l_ptr->max_pkt = l_ptr->max_pkt_target; } - l_ptr->owner->bclink.supported = (max_pkt_info != 0); + l_ptr->owner->bclink.supportable = (max_pkt_info != 0); /* Synchronize broadcast link info, if not done previously */ diff --git a/net/tipc/node.c b/net/tipc/node.c index 6b226faad89f..9196f943b835 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -306,8 +306,9 @@ static void node_established_contact(struct tipc_node *n_ptr) /* Syncronize broadcast acks */ n_ptr->bclink.acked = tipc_bclink_get_last_sent(); - if (n_ptr->bclink.supported) { + if (n_ptr->bclink.supportable) { tipc_bclink_add_node(n_ptr->addr); + n_ptr->bclink.supported = 1; if (n_ptr->addr < tipc_own_addr) tipc_own_tag++; } diff --git a/net/tipc/node.h b/net/tipc/node.h index 0b1c5f8b6996..90689f487615 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h @@ -62,6 +62,7 @@ * @link_cnt: number of links to node * @permit_changeover: non-zero if node has redundant links to this system * @bclink: broadcast-related info + * @supportable: non-zero if node supports TIPC b'cast link capability * @supported: non-zero if node supports TIPC b'cast capability * @acked: sequence # of last outbound b'cast message acknowledged by node * @last_in: sequence # of last in-sequence b'cast message received from node @@ -86,7 +87,8 @@ struct tipc_node { int block_setup; int permit_changeover; struct { - int supported; + u8 supportable; + u8 supported; u32 acked; u32 last_in; u32 gap_after; -- GitLab From 47361c87c504d89f1ba50b4230d56ef67792c258 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 26 Oct 2011 10:55:16 -0400 Subject: [PATCH 0451/1846] tipc: Fix problem with broadcast link synchronization between nodes Corrects a problem in which a link endpoint that activates as the result of receiving a RESET/STATE sequence of link protocol messages fails to properly record the broadcast link status information about the node to which it is now communicating with. (The problem does not occur with the more common RESET/ACTIVATE sequence of messages.) The fix ensures that the broadcast link status info is updated after the RESET message resets the link endpoint, rather than before, thereby preventing new information from being overwritten by the reset operation. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index 3405f560a84d..1150ba5a648b 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -2105,6 +2105,8 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) l_ptr->owner->block_setup = WAIT_NODE_DOWN; } + link_state_event(l_ptr, RESET_MSG); + /* fall thru' */ case ACTIVATE_MSG: /* Update link settings according other endpoint's values */ @@ -2134,10 +2136,11 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) if (!tipc_node_is_up(l_ptr->owner)) l_ptr->owner->bclink.last_in = msg_last_bcast(msg); - link_state_event(l_ptr, msg_type(msg)); - l_ptr->peer_session = msg_session(msg); l_ptr->peer_bearer_id = msg_bearer_id(msg); + + if (msg_type(msg) == ACTIVATE_MSG) + link_state_event(l_ptr, ACTIVATE_MSG); break; case STATE_MSG: -- GitLab From 57732560d1aa7d454d10e557f8959d19d1454174 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 26 Oct 2011 11:41:45 -0400 Subject: [PATCH 0452/1846] tipc: Add missing broadcast link lock when sending NACK Ensures that any attempt to send a NACK message over TIPC's broadcast link has exclusive access to the link's main data structures, to prevent interference with a simultaneous attempt to send other broadcast link traffic (such as application-generated multicast messages). Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 8eb87b11d100..7342abc2cfa1 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -340,8 +340,10 @@ static void bclink_send_nack(struct tipc_node *n_ptr) msg_set_bcgap_to(msg, n_ptr->bclink.gap_to); msg_set_bcast_tag(msg, tipc_own_tag); + spin_lock_bh(&bc_lock); tipc_bearer_send(&bcbearer->bearer, buf, NULL); bcl->stats.sent_nacks++; + spin_unlock_bh(&bc_lock); buf_discard(buf); /* -- GitLab From 8a275a6a30ba871eb34ea41c1fbb507039f4c0dc Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 26 Oct 2011 15:33:44 -0400 Subject: [PATCH 0453/1846] tipc: Fix node lock reclamation issues in broadcast link reception Fixes a pair of problems in broadcast link message reception code relating to the reclamation of the node lock after consuming an in-sequence message. 1) Now retests to see if the sending node is still up after reclaiming the node lock, and bails out if it is non-operational. 2) Now manipulates the node's deferred message queue only after reclaiming the node lock, rather than using queue head pointer information that was cached previously. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 58 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 7342abc2cfa1..e7df313020ce 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -474,7 +474,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) struct tipc_node *node; u32 next_in; u32 seqno; - struct sk_buff *deferred; + int deferred; /* Screen out unwanted broadcast messages */ @@ -489,6 +489,8 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) if (unlikely(!node->bclink.supported)) goto unlock; + /* Handle broadcast protocol message */ + if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) { if (msg_type(msg) != STATE_MSG) goto unlock; @@ -513,11 +515,11 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) /* Handle in-sequence broadcast message */ -receive: - next_in = mod(node->bclink.last_in + 1); seqno = msg_seqno(msg); + next_in = mod(node->bclink.last_in + 1); if (likely(seqno == next_in)) { +receive: bcl->stats.recv_info++; node->bclink.last_in++; bclink_set_gap(node); @@ -551,23 +553,40 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) buf_discard(buf); } buf = NULL; + + /* Determine new synchronization state */ + tipc_node_lock(node); - deferred = node->bclink.deferred_head; - if (deferred && (buf_seqno(deferred) == mod(next_in + 1))) { - buf = deferred; - msg = buf_msg(buf); - node->bclink.deferred_head = deferred->next; - goto receive; - } - } else if (less(next_in, seqno)) { + if (unlikely(!tipc_node_is_up(node))) + goto unlock; + + if (!node->bclink.deferred_head) + goto unlock; + + msg = buf_msg(node->bclink.deferred_head); + seqno = msg_seqno(msg); + next_in = mod(next_in + 1); + if (seqno != next_in) + goto unlock; + + /* Take in-sequence message from deferred queue & deliver it */ + + buf = node->bclink.deferred_head; + node->bclink.deferred_head = buf->next; + goto receive; + } + + /* Handle out-of-sequence broadcast message */ + + if (less(next_in, seqno)) { u32 gap_after = node->bclink.gap_after; u32 gap_to = node->bclink.gap_to; - if (tipc_link_defer_pkt(&node->bclink.deferred_head, - &node->bclink.deferred_tail, - buf)) { + deferred = tipc_link_defer_pkt(&node->bclink.deferred_head, + &node->bclink.deferred_tail, + buf); + if (deferred) { node->bclink.nack_sync++; - bcl->stats.deferred_recv++; if (seqno == mod(gap_after + 1)) node->bclink.gap_after = seqno; else if (less(gap_after, seqno) && less(seqno, gap_to)) @@ -579,9 +598,12 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) bclink_send_nack(node); bclink_set_gap(node); } - } else { - bcl->stats.duplicates++; - } + } else + deferred = 0; + + if (deferred) + bcl->stats.deferred_recv++; + unlock: tipc_node_unlock(node); exit: -- GitLab From 0232c5a566ff52d5c9fc1dda70253c942628ca66 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 26 Oct 2011 15:57:26 -0400 Subject: [PATCH 0454/1846] tipc: Fix bug in broadcast link duplicate message statistics Modifies broadcast link so that it increments the "received duplicate message" count if an incoming message cannot be added to the deferred message queue because it is already present in the queue. (The aligns broadcast link behavior with that of TIPC's unicast links.) Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index e7df313020ce..035b350be5c6 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -603,6 +603,8 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) if (deferred) bcl->stats.deferred_recv++; + else + bcl->stats.duplicates++; unlock: tipc_node_unlock(node); -- GitLab From b98158e3b36645305363a598d91c544fa31446f1 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 26 Oct 2011 16:13:35 -0400 Subject: [PATCH 0455/1846] tipc: Add missing locks in broadcast link statistics accumulation Ensures that all attempts to update broadcast link statistics are done only while holding the lock that protects the link's main data structures, to prevent interference by simultaneous updates caused by messages arriving on other interfaces. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 035b350be5c6..facc216c6a92 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -520,6 +520,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) if (likely(seqno == next_in)) { receive: + spin_lock_bh(&bc_lock); bcl->stats.recv_info++; node->bclink.last_in++; bclink_set_gap(node); @@ -527,7 +528,9 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) bclink_send_ack(node); bcl->stats.sent_acks++; } + if (likely(msg_isdata(msg))) { + spin_unlock_bh(&bc_lock); tipc_node_unlock(node); if (likely(msg_mcast(msg))) tipc_port_recv_mcast(buf, NULL); @@ -536,6 +539,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) } else if (msg_user(msg) == MSG_BUNDLER) { bcl->stats.recv_bundles++; bcl->stats.recv_bundled += msg_msgcnt(msg); + spin_unlock_bh(&bc_lock); tipc_node_unlock(node); tipc_link_recv_bundle(buf); } else if (msg_user(msg) == MSG_FRAGMENTER) { @@ -543,12 +547,15 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) if (tipc_link_recv_fragment(&node->bclink.defragm, &buf, &msg)) bcl->stats.recv_fragmented++; + spin_unlock_bh(&bc_lock); tipc_node_unlock(node); tipc_net_route_msg(buf); } else if (msg_user(msg) == NAME_DISTRIBUTOR) { + spin_unlock_bh(&bc_lock); tipc_node_unlock(node); tipc_named_recv(buf); } else { + spin_unlock_bh(&bc_lock); tipc_node_unlock(node); buf_discard(buf); } @@ -601,11 +608,15 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) } else deferred = 0; + spin_lock_bh(&bc_lock); + if (deferred) bcl->stats.deferred_recv++; else bcl->stats.duplicates++; + spin_unlock_bh(&bc_lock); + unlock: tipc_node_unlock(node); exit: -- GitLab From 7a54d4a99dcbbfdf1d4550faa19b615091137953 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Thu, 27 Oct 2011 14:17:53 -0400 Subject: [PATCH 0456/1846] tipc: Major redesign of broadcast link ACK/NACK algorithms Completely redesigns broadcast link ACK and NACK mechanisms to prevent spurious retransmit requests in dual LAN networks, and to prevent the broadcast link from stalling due to the failure of a receiving node to acknowledge receiving a broadcast message or request its retransmission. Note: These changes only impact the timing of when ACK and NACK messages are sent, and not the basic broadcast link protocol itself, so inter- operability with nodes using the "classic" algorithms is maintained. The revised algorithms are as follows: 1) An explicit ACK message is still sent after receiving 16 in-sequence messages, and implicit ACK information continues to be carried in other unicast link message headers (including link state messages). However, the timing of explicit ACKs is now based on the receiving node's absolute network address rather than its relative network address to ensure that the failure of another node does not delay the ACK beyond its 16 message target. 2) A NACK message is now typically sent only when a message gap persists for two consecutive incoming link state messages; this ensures that a suspected gap is not confirmed until both LANs in a dual LAN network have had an opportunity to deliver the message, thereby preventing spurious NACKs. A NACK message can also be generated by the arrival of a single link state message, if the deferred queue is so big that the current message gap cannot be the result of "normal" mis-ordering due to the use of dual LANs (or one LAN using a bonded interface). Since link state messages typically arrive at different nodes at different times the problem of multiple nodes issuing identical NACKs simultaneously is inherently avoided. 3) Nodes continue to "peek" at NACK messages sent by other nodes. If another node requests retransmission of a message gap suspected (but not yet confirmed) by the peeking node, the peeking node forgets about the gap and does not generate a duplicate retransmit request. (If the peeking node subsequently fails to receive the lost message, later link state messages will cause it to rediscover and confirm the gap and send another NACK.) 4) Message gap "equality" is now determined by the start of the gap only. This is sufficient to deal with the most common cases of message loss, and eliminates the need for complex end of gap computations. 5) A peeking node no longer tries to determine whether it should send a complementary NACK, since the most common cases of message loss don't require it to be sent. Consequently, the node no longer examines the "broadcast tag" field of a NACK message when peeking. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 226 ++++++++++++++++------------------------------- net/tipc/bcast.h | 2 +- net/tipc/link.c | 21 +++-- net/tipc/node.c | 4 +- net/tipc/node.h | 12 +-- 5 files changed, 100 insertions(+), 165 deletions(-) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index facc216c6a92..1f3b1607d9d4 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -157,39 +157,14 @@ u32 tipc_bclink_get_last_sent(void) return bcl->fsm_msg_cnt; } -/** - * bclink_set_gap - set gap according to contents of current deferred pkt queue - * - * Called with 'node' locked, bc_lock unlocked - */ - -static void bclink_set_gap(struct tipc_node *n_ptr) -{ - struct sk_buff *buf = n_ptr->bclink.deferred_head; - - n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = - mod(n_ptr->bclink.last_in); - if (unlikely(buf != NULL)) - n_ptr->bclink.gap_to = mod(buf_seqno(buf) - 1); -} - -/** - * bclink_ack_allowed - test if ACK or NACK message can be sent at this moment - * - * This mechanism endeavours to prevent all nodes in network from trying - * to ACK or NACK at the same time. - * - * Note: TIPC uses a different trigger to distribute ACKs than it does to - * distribute NACKs, but tries to use the same spacing (divide by 16). - */ - -static int bclink_ack_allowed(u32 n) +static void bclink_update_last_sent(struct tipc_node *node, u32 seqno) { - return (n % TIPC_MIN_LINK_WIN) == tipc_own_tag; + node->bclink.last_sent = less_eq(node->bclink.last_sent, seqno) ? + seqno : node->bclink.last_sent; } -/** +/* * tipc_bclink_retransmit_to - get most recent node to request retransmission * * Called with bc_lock locked @@ -300,44 +275,56 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) spin_unlock_bh(&bc_lock); } -/** - * bclink_send_ack - unicast an ACK msg +/* + * tipc_bclink_update_link_state - update broadcast link state * * tipc_net_lock and node lock set */ -static void bclink_send_ack(struct tipc_node *n_ptr) +void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent) { - struct tipc_link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; + struct sk_buff *buf; - if (l_ptr != NULL) - tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); -} + /* Ignore "stale" link state info */ -/** - * bclink_send_nack- broadcast a NACK msg - * - * tipc_net_lock and node lock set - */ + if (less_eq(last_sent, n_ptr->bclink.last_in)) + return; -static void bclink_send_nack(struct tipc_node *n_ptr) -{ - struct sk_buff *buf; - struct tipc_msg *msg; + /* Update link synchronization state; quit if in sync */ + + bclink_update_last_sent(n_ptr, last_sent); + + if (n_ptr->bclink.last_sent == n_ptr->bclink.last_in) + return; + + /* Update out-of-sync state; quit if loss is still unconfirmed */ - if (!less(n_ptr->bclink.gap_after, n_ptr->bclink.gap_to)) + if ((++n_ptr->bclink.oos_state) == 1) { + if (n_ptr->bclink.deferred_size < (TIPC_MIN_LINK_WIN / 2)) + return; + n_ptr->bclink.oos_state++; + } + + /* Don't NACK if one has been recently sent (or seen) */ + + if (n_ptr->bclink.oos_state & 0x1) return; + /* Send NACK */ + buf = tipc_buf_acquire(INT_H_SIZE); if (buf) { - msg = buf_msg(buf); + struct tipc_msg *msg = buf_msg(buf); + tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, - INT_H_SIZE, n_ptr->addr); + INT_H_SIZE, n_ptr->addr); msg_set_non_seq(msg, 1); msg_set_mc_netid(msg, tipc_net_id); - msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); - msg_set_bcgap_after(msg, n_ptr->bclink.gap_after); - msg_set_bcgap_to(msg, n_ptr->bclink.gap_to); + msg_set_bcast_ack(msg, n_ptr->bclink.last_in); + msg_set_bcgap_after(msg, n_ptr->bclink.last_in); + msg_set_bcgap_to(msg, n_ptr->bclink.deferred_head + ? buf_seqno(n_ptr->bclink.deferred_head) - 1 + : n_ptr->bclink.last_sent); msg_set_bcast_tag(msg, tipc_own_tag); spin_lock_bh(&bc_lock); @@ -346,96 +333,37 @@ static void bclink_send_nack(struct tipc_node *n_ptr) spin_unlock_bh(&bc_lock); buf_discard(buf); - /* - * Ensure we doesn't send another NACK msg to the node - * until 16 more deferred messages arrive from it - * (i.e. helps prevent all nodes from NACK'ing at same time) - */ - - n_ptr->bclink.nack_sync = tipc_own_tag; + n_ptr->bclink.oos_state++; } } -/** - * tipc_bclink_check_gap - send a NACK if a sequence gap exists +/* + * bclink_peek_nack - monitor retransmission requests sent by other nodes * - * tipc_net_lock and node lock set - */ - -void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 last_sent) -{ - if (!n_ptr->bclink.supported || - less_eq(last_sent, mod(n_ptr->bclink.last_in))) - return; - - bclink_set_gap(n_ptr); - if (n_ptr->bclink.gap_after == n_ptr->bclink.gap_to) - n_ptr->bclink.gap_to = last_sent; - bclink_send_nack(n_ptr); -} - -/** - * tipc_bclink_peek_nack - process a NACK msg meant for another node + * Delay any upcoming NACK by this node if another node has already + * requested the first message this node is going to ask for. * * Only tipc_net_lock set. */ -static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to) +static void bclink_peek_nack(struct tipc_msg *msg) { - struct tipc_node *n_ptr = tipc_node_find(dest); - u32 my_after, my_to; + struct tipc_node *n_ptr = tipc_node_find(msg_destnode(msg)); - if (unlikely(!n_ptr || !tipc_node_is_up(n_ptr))) + if (unlikely(!n_ptr)) return; + tipc_node_lock(n_ptr); - /* - * Modify gap to suppress unnecessary NACKs from this node - */ - my_after = n_ptr->bclink.gap_after; - my_to = n_ptr->bclink.gap_to; - - if (less_eq(gap_after, my_after)) { - if (less(my_after, gap_to) && less(gap_to, my_to)) - n_ptr->bclink.gap_after = gap_to; - else if (less_eq(my_to, gap_to)) - n_ptr->bclink.gap_to = n_ptr->bclink.gap_after; - } else if (less_eq(gap_after, my_to)) { - if (less_eq(my_to, gap_to)) - n_ptr->bclink.gap_to = gap_after; - } else { - /* - * Expand gap if missing bufs not in deferred queue: - */ - struct sk_buff *buf = n_ptr->bclink.deferred_head; - u32 prev = n_ptr->bclink.gap_to; - for (; buf; buf = buf->next) { - u32 seqno = buf_seqno(buf); + if (n_ptr->bclink.supported && + (n_ptr->bclink.last_in != n_ptr->bclink.last_sent) && + (n_ptr->bclink.last_in == msg_bcgap_after(msg))) + n_ptr->bclink.oos_state = 2; - if (mod(seqno - prev) != 1) { - buf = NULL; - break; - } - if (seqno == gap_after) - break; - prev = seqno; - } - if (buf == NULL) - n_ptr->bclink.gap_to = gap_after; - } - /* - * Some nodes may send a complementary NACK now: - */ - if (bclink_ack_allowed(sender_tag + 1)) { - if (n_ptr->bclink.gap_to != n_ptr->bclink.gap_after) { - bclink_send_nack(n_ptr); - bclink_set_gap(n_ptr); - } - } tipc_node_unlock(n_ptr); } -/** +/* * tipc_bclink_send_msg - broadcast a packet to all nodes in cluster */ @@ -505,10 +433,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) spin_unlock_bh(&bc_lock); } else { tipc_node_unlock(node); - tipc_bclink_peek_nack(msg_destnode(msg), - msg_bcast_tag(msg), - msg_bcgap_after(msg), - msg_bcgap_to(msg)); + bclink_peek_nack(msg); } goto exit; } @@ -519,16 +444,28 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) next_in = mod(node->bclink.last_in + 1); if (likely(seqno == next_in)) { + bclink_update_last_sent(node, seqno); receive: + node->bclink.last_in = seqno; + node->bclink.oos_state = 0; + spin_lock_bh(&bc_lock); bcl->stats.recv_info++; - node->bclink.last_in++; - bclink_set_gap(node); - if (unlikely(bclink_ack_allowed(seqno))) { - bclink_send_ack(node); + + /* + * Unicast an ACK periodically, ensuring that + * all nodes in the cluster don't ACK at the same time + */ + + if (((seqno - tipc_own_addr) % TIPC_MIN_LINK_WIN) == 0) { + tipc_link_send_proto_msg( + node->active_links[node->addr & 1], + STATE_MSG, 0, 0, 0, 0, 0); bcl->stats.sent_acks++; } + /* Deliver message to destination */ + if (likely(msg_isdata(msg))) { spin_unlock_bh(&bc_lock); tipc_node_unlock(node); @@ -567,9 +504,14 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) if (unlikely(!tipc_node_is_up(node))) goto unlock; - if (!node->bclink.deferred_head) + if (node->bclink.last_in == node->bclink.last_sent) goto unlock; + if (!node->bclink.deferred_head) { + node->bclink.oos_state = 1; + goto unlock; + } + msg = buf_msg(node->bclink.deferred_head); seqno = msg_seqno(msg); next_in = mod(next_in + 1); @@ -580,31 +522,19 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) buf = node->bclink.deferred_head; node->bclink.deferred_head = buf->next; + node->bclink.deferred_size--; goto receive; } /* Handle out-of-sequence broadcast message */ if (less(next_in, seqno)) { - u32 gap_after = node->bclink.gap_after; - u32 gap_to = node->bclink.gap_to; - deferred = tipc_link_defer_pkt(&node->bclink.deferred_head, &node->bclink.deferred_tail, buf); - if (deferred) { - node->bclink.nack_sync++; - if (seqno == mod(gap_after + 1)) - node->bclink.gap_after = seqno; - else if (less(gap_after, seqno) && less(seqno, gap_to)) - node->bclink.gap_to = seqno; - } + node->bclink.deferred_size += deferred; + bclink_update_last_sent(node, seqno); buf = NULL; - if (bclink_ack_allowed(node->bclink.nack_sync)) { - if (gap_to != gap_after) - bclink_send_nack(node); - bclink_set_gap(node); - } } else deferred = 0; diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index b009666c60b0..5571394098f9 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h @@ -96,7 +96,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf); void tipc_bclink_recv_pkt(struct sk_buff *buf); u32 tipc_bclink_get_last_sent(void); u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr); -void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 seqno); +void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent); int tipc_bclink_stats(char *stats_buf, const u32 buf_size); int tipc_bclink_reset_stats(void); int tipc_bclink_set_queue_limits(u32 limit); diff --git a/net/tipc/link.c b/net/tipc/link.c index 1150ba5a648b..cce953723ddb 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1501,14 +1501,13 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, tipc_node_lock(n_ptr); tipc_addr_string_fill(addr_string, n_ptr->addr); - info("Multicast link info for %s\n", addr_string); + info("Broadcast link info for %s\n", addr_string); info("Supportable: %d, ", n_ptr->bclink.supportable); info("Supported: %d, ", n_ptr->bclink.supported); info("Acked: %u\n", n_ptr->bclink.acked); info("Last in: %u, ", n_ptr->bclink.last_in); - info("Gap after: %u, ", n_ptr->bclink.gap_after); - info("Gap to: %u\n", n_ptr->bclink.gap_to); - info("Nack sync: %u\n\n", n_ptr->bclink.nack_sync); + info("Oos state: %u, ", n_ptr->bclink.oos_state); + info("Last sent: %u\n", n_ptr->bclink.last_sent); tipc_k_signal((Handler)link_reset_all, (unsigned long)n_ptr->addr); @@ -1974,7 +1973,7 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, msg_set_type(msg, msg_typ); msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); - msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in)); + msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); msg_set_last_bcast(msg, tipc_bclink_get_last_sent()); if (msg_typ == STATE_MSG) { @@ -2133,8 +2132,12 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) /* Synchronize broadcast link info, if not done previously */ - if (!tipc_node_is_up(l_ptr->owner)) - l_ptr->owner->bclink.last_in = msg_last_bcast(msg); + if (!tipc_node_is_up(l_ptr->owner)) { + l_ptr->owner->bclink.last_sent = + l_ptr->owner->bclink.last_in = + msg_last_bcast(msg); + l_ptr->owner->bclink.oos_state = 0; + } l_ptr->peer_session = msg_session(msg); l_ptr->peer_bearer_id = msg_bearer_id(msg); @@ -2181,7 +2184,9 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) /* Protocol message before retransmits, reduce loss risk */ - tipc_bclink_check_gap(l_ptr->owner, msg_last_bcast(msg)); + if (l_ptr->owner->bclink.supported) + tipc_bclink_update_link_state(l_ptr->owner, + msg_last_bcast(msg)); if (rec_gap || (msg_probe(msg))) { tipc_link_send_proto_msg(l_ptr, STATE_MSG, diff --git a/net/tipc/node.c b/net/tipc/node.c index 9196f943b835..6d8bdfd95cd6 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -339,12 +339,12 @@ static void node_lost_contact(struct tipc_node *n_ptr) /* Flush broadcast link info associated with lost node */ if (n_ptr->bclink.supported) { - n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0; while (n_ptr->bclink.deferred_head) { struct sk_buff *buf = n_ptr->bclink.deferred_head; n_ptr->bclink.deferred_head = buf->next; buf_discard(buf); } + n_ptr->bclink.deferred_size = 0; if (n_ptr->bclink.defragm) { buf_discard(n_ptr->bclink.defragm); @@ -450,7 +450,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) read_lock_bh(&tipc_net_lock); - /* Get space for all unicast links + multicast link */ + /* Get space for all unicast links + broadcast link */ payload_size = TLV_SPACE(sizeof(link_info)) * (atomic_read(&tipc_num_links) + 1); diff --git a/net/tipc/node.h b/net/tipc/node.h index 90689f487615..c88ce64f8a31 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h @@ -66,9 +66,9 @@ * @supported: non-zero if node supports TIPC b'cast capability * @acked: sequence # of last outbound b'cast message acknowledged by node * @last_in: sequence # of last in-sequence b'cast message received from node - * @gap_after: sequence # of last message not requiring a NAK request - * @gap_to: sequence # of last message requiring a NAK request - * @nack_sync: counter that determines when NAK requests should be sent + * @last_sent: sequence # of last b'cast message sent by node + * @oos_state: state tracker for handling OOS b'cast messages + * @deferred_size: number of OOS b'cast messages in deferred queue * @deferred_head: oldest OOS b'cast message received from node * @deferred_tail: newest OOS b'cast message received from node * @defragm: list of partially reassembled b'cast message fragments from node @@ -91,9 +91,9 @@ struct tipc_node { u8 supported; u32 acked; u32 last_in; - u32 gap_after; - u32 gap_to; - u32 nack_sync; + u32 last_sent; + u32 oos_state; + u32 deferred_size; struct sk_buff *deferred_head; struct sk_buff *deferred_tail; struct sk_buff *defragm; -- GitLab From 1ec2bb08407b377e5954b3f9479c2bf67fc925a9 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Thu, 27 Oct 2011 15:03:24 -0400 Subject: [PATCH 0457/1846] tipc: Remove obsolete broadcast tag capability Eliminates support for the broadcast tag field, which is no longer used by broadcast link NACK messages. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 1 - net/tipc/node.c | 7 +------ net/tipc/node.h | 2 -- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 1f3b1607d9d4..a9b7132d34f2 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -325,7 +325,6 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent) msg_set_bcgap_to(msg, n_ptr->bclink.deferred_head ? buf_seqno(n_ptr->bclink.deferred_head) - 1 : n_ptr->bclink.last_sent); - msg_set_bcast_tag(msg, tipc_own_tag); spin_lock_bh(&bc_lock); tipc_bearer_send(&bcbearer->bearer, buf, NULL); diff --git a/net/tipc/node.c b/net/tipc/node.c index 6d8bdfd95cd6..7bc45e135fb4 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -49,9 +49,8 @@ LIST_HEAD(tipc_node_list); static u32 tipc_num_nodes; static atomic_t tipc_num_links = ATOMIC_INIT(0); -u32 tipc_own_tag; -/** +/* * tipc_node_find - locate specified node object, if it exists */ @@ -309,8 +308,6 @@ static void node_established_contact(struct tipc_node *n_ptr) if (n_ptr->bclink.supportable) { tipc_bclink_add_node(n_ptr->addr); n_ptr->bclink.supported = 1; - if (n_ptr->addr < tipc_own_addr) - tipc_own_tag++; } } @@ -353,8 +350,6 @@ static void node_lost_contact(struct tipc_node *n_ptr) tipc_bclink_remove_node(n_ptr->addr); tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ); - if (n_ptr->addr < tipc_own_addr) - tipc_own_tag--; n_ptr->bclink.supported = 0; } diff --git a/net/tipc/node.h b/net/tipc/node.h index c88ce64f8a31..e1b78a2199c2 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h @@ -114,8 +114,6 @@ static inline unsigned int tipc_hashfn(u32 addr) return addr & (NODE_HTABLE_SIZE - 1); } -extern u32 tipc_own_tag; - struct tipc_node *tipc_node_find(u32 addr); struct tipc_node *tipc_node_create(u32 addr); void tipc_node_delete(struct tipc_node *n_ptr); -- GitLab From b76b27cad5ade1d483d4b94df6b35976bccf1055 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Thu, 27 Oct 2011 16:31:26 -0400 Subject: [PATCH 0458/1846] tipc: Prevent loss of fragmented messages over unicast links Modifies unicast link endpoint logic so an incoming fragmented message is not lost if reassembly cannot begin because there is no buffer big enough to hold the entire reassembled message. The link endpoint now ignores the first fragment completely, which causes the sending node to retransmit the first fragment so that reassembly can be re-attempted. Previously, the sender would have had no reason to retransmit the 1st fragment, so we would never have a chance to re-try the allocation. Signed-off-by: Allan Stephens --- net/tipc/link.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index cce953723ddb..d8b0a22367b6 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1774,6 +1774,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) head = link_insert_deferred_queue(l_ptr, head); if (likely(msg_is_dest(msg, tipc_own_addr))) { + int ret; deliver: if (likely(msg_isdata(msg))) { tipc_node_unlock(n_ptr); @@ -1798,11 +1799,15 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) continue; case MSG_FRAGMENTER: l_ptr->stats.recv_fragments++; - if (tipc_link_recv_fragment(&l_ptr->defragm_buf, - &buf, &msg)) { + ret = tipc_link_recv_fragment( + &l_ptr->defragm_buf, + &buf, &msg); + if (ret == 1) { l_ptr->stats.recv_fragmented++; goto deliver; } + if (ret == -1) + l_ptr->next_in_no--; break; case CHANGEOVER_PROTOCOL: type = msg_type(msg); @@ -2632,7 +2637,9 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, set_fragm_size(pbuf, fragm_sz); set_expected_frags(pbuf, exp_fragm_cnt - 1); } else { - warn("Link unable to reassemble fragmented message\n"); + dbg("Link unable to reassemble fragmented message\n"); + buf_discard(fbuf); + return -1; } buf_discard(fbuf); return 0; -- GitLab From 63e7f1ac2855ba56f15d8189694ca9bd16ae4107 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Thu, 27 Oct 2011 16:43:09 -0400 Subject: [PATCH 0459/1846] tipc: Prevent loss of fragmented messages over broadcast link Modifies broadcast link so that an incoming fragmented message is not lost if reassembly cannot begin because there currently is no buffer big enough to hold the entire reassembled message. The broadcast link now ignores the first fragment completely, which causes the sending node to retransmit the first fragment so that reassembly can be re-attempted. Previously, the sender would have had no reason to retransmit the 1st fragment, so we would never have a chance to re-try the allocation. To do this cleanly without duplicaton, a new bclink_accept_pkt() function is introduced. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 64 +++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index a9b7132d34f2..41ecf313073c 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -389,7 +389,33 @@ int tipc_bclink_send_msg(struct sk_buff *buf) return res; } -/** +/* + * bclink_accept_pkt - accept an incoming, in-sequence broadcast packet + * + * Called with both sending node's lock and bc_lock taken. + */ + +static void bclink_accept_pkt(struct tipc_node *node, u32 seqno) +{ + bclink_update_last_sent(node, seqno); + node->bclink.last_in = seqno; + node->bclink.oos_state = 0; + bcl->stats.recv_info++; + + /* + * Unicast an ACK periodically, ensuring that + * all nodes in the cluster don't ACK at the same time + */ + + if (((seqno - tipc_own_addr) % TIPC_MIN_LINK_WIN) == 0) { + tipc_link_send_proto_msg( + node->active_links[node->addr & 1], + STATE_MSG, 0, 0, 0, 0, 0); + bcl->stats.sent_acks++; + } +} + +/* * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards * * tipc_net_lock is read_locked, no other locks set @@ -443,29 +469,12 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) next_in = mod(node->bclink.last_in + 1); if (likely(seqno == next_in)) { - bclink_update_last_sent(node, seqno); receive: - node->bclink.last_in = seqno; - node->bclink.oos_state = 0; - - spin_lock_bh(&bc_lock); - bcl->stats.recv_info++; - - /* - * Unicast an ACK periodically, ensuring that - * all nodes in the cluster don't ACK at the same time - */ - - if (((seqno - tipc_own_addr) % TIPC_MIN_LINK_WIN) == 0) { - tipc_link_send_proto_msg( - node->active_links[node->addr & 1], - STATE_MSG, 0, 0, 0, 0, 0); - bcl->stats.sent_acks++; - } - /* Deliver message to destination */ if (likely(msg_isdata(msg))) { + spin_lock_bh(&bc_lock); + bclink_accept_pkt(node, seqno); spin_unlock_bh(&bc_lock); tipc_node_unlock(node); if (likely(msg_mcast(msg))) @@ -473,24 +482,35 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) else buf_discard(buf); } else if (msg_user(msg) == MSG_BUNDLER) { + spin_lock_bh(&bc_lock); + bclink_accept_pkt(node, seqno); bcl->stats.recv_bundles++; bcl->stats.recv_bundled += msg_msgcnt(msg); spin_unlock_bh(&bc_lock); tipc_node_unlock(node); tipc_link_recv_bundle(buf); } else if (msg_user(msg) == MSG_FRAGMENTER) { + int ret = tipc_link_recv_fragment(&node->bclink.defragm, + &buf, &msg); + if (ret < 0) + goto unlock; + spin_lock_bh(&bc_lock); + bclink_accept_pkt(node, seqno); bcl->stats.recv_fragments++; - if (tipc_link_recv_fragment(&node->bclink.defragm, - &buf, &msg)) + if (ret > 0) bcl->stats.recv_fragmented++; spin_unlock_bh(&bc_lock); tipc_node_unlock(node); tipc_net_route_msg(buf); } else if (msg_user(msg) == NAME_DISTRIBUTOR) { + spin_lock_bh(&bc_lock); + bclink_accept_pkt(node, seqno); spin_unlock_bh(&bc_lock); tipc_node_unlock(node); tipc_named_recv(buf); } else { + spin_lock_bh(&bc_lock); + bclink_accept_pkt(node, seqno); spin_unlock_bh(&bc_lock); tipc_node_unlock(node); buf_discard(buf); -- GitLab From 3175bd9add570f3b5c06877369897b334556a2ff Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 28 Oct 2011 12:03:00 -0400 Subject: [PATCH 0460/1846] tipc: Eliminate alteration of publication key during name table purging Removes code that alters the publication key of a name table entry that is being forcibly purged from TIPC's name table after contact with the publishing node has been lost. Current TIPC ensures that all defunct names are purged before re-establishing contact with a failed node. There used to be a risk that the publication might be accidentally deleted because it might be re-added to the name table before the purge operation was completed. But now there is no longer a need to ensure that the new key is different than the old one. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/name_distr.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index 98ebb37f1808..acecfda82f37 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -239,9 +239,6 @@ void tipc_named_node_up(unsigned long nodearg) * * Invoked for each publication issued by a newly failed node. * Removes publication structure from name table & deletes it. - * In rare cases the link may have come back up again when this - * function is called, and we have two items representing the same - * publication. Nudge this item's key to distinguish it from the other. */ static void named_purge_publ(struct publication *publ) @@ -249,7 +246,6 @@ static void named_purge_publ(struct publication *publ) struct publication *p; write_lock_bh(&tipc_nametbl_lock); - publ->key += 1222345; p = tipc_nametbl_remove_publ(publ->type, publ->lower, publ->node, publ->ref, publ->key); if (p) -- GitLab From dff10e9e637663c8c5dd0bae1a8f0e899cbb4a36 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 2 Nov 2011 10:32:14 -0400 Subject: [PATCH 0461/1846] tipc: Minor optimization to rejection of connection-based messages Modifies message rejection logic so that TIPC doesn't attempt to send a FIN message to the rejecting port if it is known in advance that there is no such message because the rejecting port doesn't exist. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/port.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/tipc/port.c b/net/tipc/port.c index d91efc69e6f9..ba3268b8da42 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -400,15 +400,16 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) /* send self-abort message when rejecting on a connected port */ if (msg_connected(msg)) { - struct sk_buff *abuf = NULL; struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg)); if (p_ptr) { + struct sk_buff *abuf = NULL; + if (p_ptr->connected) abuf = port_build_self_abort_msg(p_ptr, err); tipc_port_unlock(p_ptr); + tipc_net_route_msg(abuf); } - tipc_net_route_msg(abuf); } /* send returned message & dispose of rejected message */ -- GitLab From ab50a2a430693b0961dc7b7d9fe2a4bd77d11ea6 Mon Sep 17 00:00:00 2001 From: Mitch A Williams Date: Sat, 14 Jan 2012 08:10:50 +0000 Subject: [PATCH 0462/1846] igbvf: refactor Interrupt Throttle Rate code The existing ITR code is broken and confusing, with lots of similarly-named variables that do different things. Additionally, after the driver carefully determines the optimal interrupt rate for the adapter, it then ignores it and always writes a fixed, suboptimal value. This patch refactors that code to make variable names more descriptive of what they actually do, and then actually writes the calculated result to the hardware. Preliminary testing shows that netperf TCP_STREAM tests goes from ~918Mbps to ~940Mbps, and TCP_RR goes from ~2k transactions/sec up to > 8k. Signed-off-by: Mitch Williams Tested-by: Robert E Garrett Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/igbvf/ethtool.c | 19 +-- drivers/net/ethernet/intel/igbvf/igbvf.h | 27 +++-- drivers/net/ethernet/intel/igbvf/netdev.c | 131 ++++++++++++--------- 3 files changed, 99 insertions(+), 78 deletions(-) diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c index db7dce2351c2..8ce67064b9c5 100644 --- a/drivers/net/ethernet/intel/igbvf/ethtool.c +++ b/drivers/net/ethernet/intel/igbvf/ethtool.c @@ -343,10 +343,10 @@ static int igbvf_get_coalesce(struct net_device *netdev, { struct igbvf_adapter *adapter = netdev_priv(netdev); - if (adapter->itr_setting <= 3) - ec->rx_coalesce_usecs = adapter->itr_setting; + if (adapter->requested_itr <= 3) + ec->rx_coalesce_usecs = adapter->requested_itr; else - ec->rx_coalesce_usecs = adapter->itr_setting >> 2; + ec->rx_coalesce_usecs = adapter->current_itr >> 2; return 0; } @@ -365,15 +365,16 @@ static int igbvf_set_coalesce(struct net_device *netdev, /* convert to rate of irq's per second */ if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) { - adapter->itr = IGBVF_START_ITR; - adapter->itr_setting = ec->rx_coalesce_usecs; + adapter->current_itr = IGBVF_START_ITR; + adapter->requested_itr = ec->rx_coalesce_usecs; } else { - adapter->itr = ec->rx_coalesce_usecs << 2; - adapter->itr_setting = adapter->itr; + adapter->current_itr = ec->rx_coalesce_usecs << 2; + adapter->requested_itr = 1000000000 / + (adapter->current_itr * 256); } - writel(adapter->itr, - hw->hw_addr + adapter->rx_ring[0].itr_register); + writel(adapter->current_itr, + hw->hw_addr + adapter->rx_ring->itr_register); return 0; } diff --git a/drivers/net/ethernet/intel/igbvf/igbvf.h b/drivers/net/ethernet/intel/igbvf/igbvf.h index 2c6d87e4d3d9..a895e2f7b34d 100644 --- a/drivers/net/ethernet/intel/igbvf/igbvf.h +++ b/drivers/net/ethernet/intel/igbvf/igbvf.h @@ -43,7 +43,18 @@ struct igbvf_info; struct igbvf_adapter; /* Interrupt defines */ -#define IGBVF_START_ITR 648 /* ~6000 ints/sec */ +#define IGBVF_START_ITR 488 /* ~8000 ints/sec */ +#define IGBVF_4K_ITR 980 +#define IGBVF_20K_ITR 196 +#define IGBVF_70K_ITR 56 + +enum latency_range { + lowest_latency = 0, + low_latency = 1, + bulk_latency = 2, + latency_invalid = 255 +}; + /* Interrupt modes, as used by the IntMode parameter */ #define IGBVF_INT_MODE_LEGACY 0 @@ -155,6 +166,7 @@ struct igbvf_ring { char name[IFNAMSIZ + 5]; u32 eims_value; u32 itr_val; + enum latency_range itr_range; u16 itr_register; int set_itr; @@ -187,10 +199,8 @@ struct igbvf_adapter { unsigned long state; /* Interrupt Throttle Rate */ - u32 itr; - u32 itr_setting; - u16 tx_itr; - u16 rx_itr; + u32 requested_itr; /* ints/sec or adaptive */ + u32 current_itr; /* Actual ITR register value, not ints/sec */ /* * Tx @@ -299,13 +309,6 @@ enum igbvf_state_t { __IGBVF_DOWN }; -enum latency_range { - lowest_latency = 0, - low_latency = 1, - bulk_latency = 2, - latency_invalid = 255 -}; - extern char igbvf_driver_name[]; extern const char igbvf_driver_version[]; diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index 4e9141cfe81d..446297ff0104 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c @@ -632,14 +632,13 @@ void igbvf_free_rx_resources(struct igbvf_ring *rx_ring) * traffic pattern. Constants in this function were computed * based on theoretical maximum wire speed and thresholds were set based * on testing data as well as attempting to minimize response time - * while increasing bulk throughput. This functionality is controlled - * by the InterruptThrottleRate module parameter. + * while increasing bulk throughput. **/ -static unsigned int igbvf_update_itr(struct igbvf_adapter *adapter, - u16 itr_setting, int packets, - int bytes) +static enum latency_range igbvf_update_itr(struct igbvf_adapter *adapter, + enum latency_range itr_setting, + int packets, int bytes) { - unsigned int retval = itr_setting; + enum latency_range retval = itr_setting; if (packets == 0) goto update_itr_done; @@ -675,65 +674,87 @@ static unsigned int igbvf_update_itr(struct igbvf_adapter *adapter, retval = low_latency; } break; + default: + break; } update_itr_done: return retval; } -static void igbvf_set_itr(struct igbvf_adapter *adapter) +static int igbvf_range_to_itr(enum latency_range current_range) { - struct e1000_hw *hw = &adapter->hw; - u16 current_itr; - u32 new_itr = adapter->itr; - - adapter->tx_itr = igbvf_update_itr(adapter, adapter->tx_itr, - adapter->total_tx_packets, - adapter->total_tx_bytes); - /* conservative mode (itr 3) eliminates the lowest_latency setting */ - if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency) - adapter->tx_itr = low_latency; - - adapter->rx_itr = igbvf_update_itr(adapter, adapter->rx_itr, - adapter->total_rx_packets, - adapter->total_rx_bytes); - /* conservative mode (itr 3) eliminates the lowest_latency setting */ - if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency) - adapter->rx_itr = low_latency; + int new_itr; - current_itr = max(adapter->rx_itr, adapter->tx_itr); - - switch (current_itr) { + switch (current_range) { /* counts and packets in update_itr are dependent on these numbers */ case lowest_latency: - new_itr = 70000; + new_itr = IGBVF_70K_ITR; break; case low_latency: - new_itr = 20000; /* aka hwitr = ~200 */ + new_itr = IGBVF_20K_ITR; break; case bulk_latency: - new_itr = 4000; + new_itr = IGBVF_4K_ITR; break; default: + new_itr = IGBVF_START_ITR; break; } + return new_itr; +} + +static void igbvf_set_itr(struct igbvf_adapter *adapter) +{ + u32 new_itr; + + adapter->tx_ring->itr_range = + igbvf_update_itr(adapter, + adapter->tx_ring->itr_val, + adapter->total_tx_packets, + adapter->total_tx_bytes); + + /* conservative mode (itr 3) eliminates the lowest_latency setting */ + if (adapter->requested_itr == 3 && + adapter->tx_ring->itr_range == lowest_latency) + adapter->tx_ring->itr_range = low_latency; - if (new_itr != adapter->itr) { + new_itr = igbvf_range_to_itr(adapter->tx_ring->itr_range); + + + if (new_itr != adapter->tx_ring->itr_val) { + u32 current_itr = adapter->tx_ring->itr_val; /* * this attempts to bias the interrupt rate towards Bulk * by adding intermediate steps when interrupt rate is * increasing */ - new_itr = new_itr > adapter->itr ? - min(adapter->itr + (new_itr >> 2), new_itr) : - new_itr; - adapter->itr = new_itr; - adapter->rx_ring->itr_val = 1952; - - if (adapter->msix_entries) - adapter->rx_ring->set_itr = 1; - else - ew32(ITR, 1952); + new_itr = new_itr > current_itr ? + min(current_itr + (new_itr >> 2), new_itr) : + new_itr; + adapter->tx_ring->itr_val = new_itr; + + adapter->tx_ring->set_itr = 1; + } + + adapter->rx_ring->itr_range = + igbvf_update_itr(adapter, adapter->rx_ring->itr_val, + adapter->total_rx_packets, + adapter->total_rx_bytes); + if (adapter->requested_itr == 3 && + adapter->rx_ring->itr_range == lowest_latency) + adapter->rx_ring->itr_range = low_latency; + + new_itr = igbvf_range_to_itr(adapter->rx_ring->itr_range); + + if (new_itr != adapter->rx_ring->itr_val) { + u32 current_itr = adapter->rx_ring->itr_val; + new_itr = new_itr > current_itr ? + min(current_itr + (new_itr >> 2), new_itr) : + new_itr; + adapter->rx_ring->itr_val = new_itr; + + adapter->rx_ring->set_itr = 1; } } @@ -835,6 +856,11 @@ static irqreturn_t igbvf_intr_msix_tx(int irq, void *data) struct e1000_hw *hw = &adapter->hw; struct igbvf_ring *tx_ring = adapter->tx_ring; + if (tx_ring->set_itr) { + writel(tx_ring->itr_val, + adapter->hw.hw_addr + tx_ring->itr_register); + adapter->tx_ring->set_itr = 0; + } adapter->total_tx_bytes = 0; adapter->total_tx_packets = 0; @@ -937,19 +963,10 @@ static void igbvf_configure_msix(struct igbvf_adapter *adapter) igbvf_assign_vector(adapter, IGBVF_NO_QUEUE, 0, vector++); adapter->eims_enable_mask |= tx_ring->eims_value; - if (tx_ring->itr_val) - writel(tx_ring->itr_val, - hw->hw_addr + tx_ring->itr_register); - else - writel(1952, hw->hw_addr + tx_ring->itr_register); - + writel(tx_ring->itr_val, hw->hw_addr + tx_ring->itr_register); igbvf_assign_vector(adapter, 0, IGBVF_NO_QUEUE, vector++); adapter->eims_enable_mask |= rx_ring->eims_value; - if (rx_ring->itr_val) - writel(rx_ring->itr_val, - hw->hw_addr + rx_ring->itr_register); - else - writel(1952, hw->hw_addr + rx_ring->itr_register); + writel(rx_ring->itr_val, hw->hw_addr + rx_ring->itr_register); /* set vector for other causes, i.e. link changes */ @@ -1027,7 +1044,7 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter) goto out; adapter->tx_ring->itr_register = E1000_EITR(vector); - adapter->tx_ring->itr_val = 1952; + adapter->tx_ring->itr_val = adapter->current_itr; vector++; err = request_irq(adapter->msix_entries[vector].vector, @@ -1037,7 +1054,7 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter) goto out; adapter->rx_ring->itr_register = E1000_EITR(vector); - adapter->rx_ring->itr_val = 1952; + adapter->rx_ring->itr_val = adapter->current_itr; vector++; err = request_irq(adapter->msix_entries[vector].vector, @@ -1151,7 +1168,7 @@ static int igbvf_poll(struct napi_struct *napi, int budget) if (work_done < budget) { napi_complete(napi); - if (adapter->itr_setting & 3) + if (adapter->requested_itr & 3) igbvf_set_itr(adapter); if (!test_bit(__IGBVF_DOWN, &adapter->state)) @@ -1521,8 +1538,8 @@ static int __devinit igbvf_sw_init(struct igbvf_adapter *adapter) adapter->tx_abs_int_delay = 32; adapter->rx_int_delay = 0; adapter->rx_abs_int_delay = 8; - adapter->itr_setting = 3; - adapter->itr = 20000; + adapter->requested_itr = 3; + adapter->current_itr = IGBVF_START_ITR; /* Set various function pointers */ adapter->ei->init_ops(&adapter->hw); -- GitLab From b04e36bac5075ceeacf11b639fbf0cb69aa68996 Mon Sep 17 00:00:00 2001 From: Tushar Dave Date: Fri, 27 Jan 2012 09:00:46 +0000 Subject: [PATCH 0463/1846] e1000: Adding e1000_dump function When TX hang occurs e1000_dump prints TX ring, RX ring and Device registers. Signed-off-by: Tushar Dave Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000/e1000.h | 1 + drivers/net/ethernet/intel/e1000/e1000_hw.h | 10 + drivers/net/ethernet/intel/e1000/e1000_main.c | 224 ++++++++++++++++++ 3 files changed, 235 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h index 1e1596990b5c..2b6cd02bfba0 100644 --- a/drivers/net/ethernet/intel/e1000/e1000.h +++ b/drivers/net/ethernet/intel/e1000/e1000.h @@ -254,6 +254,7 @@ struct e1000_adapter { atomic_t tx_fifo_stall; bool pcix_82544; bool detect_tx_hung; + bool dump_buffers; /* RX */ bool (*clean_rx)(struct e1000_adapter *adapter, diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.h b/drivers/net/ethernet/intel/e1000/e1000_hw.h index f6c4d7e2560c..11578c8978db 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_hw.h +++ b/drivers/net/ethernet/intel/e1000/e1000_hw.h @@ -895,6 +895,11 @@ struct e1000_ffvt_entry { #define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */ #define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */ #define E1000_PSRCTL 0x02170 /* Packet Split Receive Control - RW */ +#define E1000_RDFH 0x02410 /* RX Data FIFO Head - RW */ +#define E1000_RDFT 0x02418 /* RX Data FIFO Tail - RW */ +#define E1000_RDFHS 0x02420 /* RX Data FIFO Head Saved - RW */ +#define E1000_RDFTS 0x02428 /* RX Data FIFO Tail Saved - RW */ +#define E1000_RDFPC 0x02430 /* RX Data FIFO Packet Count - RW */ #define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */ #define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */ #define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */ @@ -1074,6 +1079,11 @@ struct e1000_ffvt_entry { #define E1000_82542_IMC E1000_IMC #define E1000_82542_RCTL E1000_RCTL #define E1000_82542_RDTR 0x00108 +#define E1000_82542_RDFH E1000_RDFH +#define E1000_82542_RDFT E1000_RDFT +#define E1000_82542_RDFHS E1000_RDFHS +#define E1000_82542_RDFTS E1000_RDFTS +#define E1000_82542_RDFPC E1000_RDFPC #define E1000_82542_RDBAL 0x00110 #define E1000_82542_RDBAH 0x00114 #define E1000_82542_RDLEN 0x00118 diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 363fd395c75b..1f86a70b88af 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -3239,6 +3239,228 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, return NETDEV_TX_OK; } +#define NUM_REGS 38 /* 1 based count */ +static void e1000_regdump(struct e1000_adapter *adapter) +{ + struct e1000_hw *hw = &adapter->hw; + u32 regs[NUM_REGS]; + u32 *regs_buff = regs; + int i = 0; + + char *reg_name[] = { + "CTRL", "STATUS", + "RCTL", "RDLEN", "RDH", "RDT", "RDTR", + "TCTL", "TDBAL", "TDBAH", "TDLEN", "TDH", "TDT", + "TIDV", "TXDCTL", "TADV", "TARC0", + "TDBAL1", "TDBAH1", "TDLEN1", "TDH1", "TDT1", + "TXDCTL1", "TARC1", + "CTRL_EXT", "ERT", "RDBAL", "RDBAH", + "TDFH", "TDFT", "TDFHS", "TDFTS", "TDFPC", + "RDFH", "RDFT", "RDFHS", "RDFTS", "RDFPC" + }; + + regs_buff[0] = er32(CTRL); + regs_buff[1] = er32(STATUS); + + regs_buff[2] = er32(RCTL); + regs_buff[3] = er32(RDLEN); + regs_buff[4] = er32(RDH); + regs_buff[5] = er32(RDT); + regs_buff[6] = er32(RDTR); + + regs_buff[7] = er32(TCTL); + regs_buff[8] = er32(TDBAL); + regs_buff[9] = er32(TDBAH); + regs_buff[10] = er32(TDLEN); + regs_buff[11] = er32(TDH); + regs_buff[12] = er32(TDT); + regs_buff[13] = er32(TIDV); + regs_buff[14] = er32(TXDCTL); + regs_buff[15] = er32(TADV); + regs_buff[16] = er32(TARC0); + + regs_buff[17] = er32(TDBAL1); + regs_buff[18] = er32(TDBAH1); + regs_buff[19] = er32(TDLEN1); + regs_buff[20] = er32(TDH1); + regs_buff[21] = er32(TDT1); + regs_buff[22] = er32(TXDCTL1); + regs_buff[23] = er32(TARC1); + regs_buff[24] = er32(CTRL_EXT); + regs_buff[25] = er32(ERT); + regs_buff[26] = er32(RDBAL0); + regs_buff[27] = er32(RDBAH0); + regs_buff[28] = er32(TDFH); + regs_buff[29] = er32(TDFT); + regs_buff[30] = er32(TDFHS); + regs_buff[31] = er32(TDFTS); + regs_buff[32] = er32(TDFPC); + regs_buff[33] = er32(RDFH); + regs_buff[34] = er32(RDFT); + regs_buff[35] = er32(RDFHS); + regs_buff[36] = er32(RDFTS); + regs_buff[37] = er32(RDFPC); + + pr_info("Register dump\n"); + for (i = 0; i < NUM_REGS; i++) { + printk(KERN_INFO "%-15s %08x\n", + reg_name[i], regs_buff[i]); + } +} + +/* + * e1000_dump: Print registers, tx ring and rx ring + */ +static void e1000_dump(struct e1000_adapter *adapter) +{ + /* this code doesn't handle multiple rings */ + struct e1000_tx_ring *tx_ring = adapter->tx_ring; + struct e1000_rx_ring *rx_ring = adapter->rx_ring; + int i; + + if (!netif_msg_hw(adapter)) + return; + + /* Print Registers */ + e1000_regdump(adapter); + + /* + * transmit dump + */ + pr_info("TX Desc ring0 dump\n"); + + /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended) + * + * Legacy Transmit Descriptor + * +--------------------------------------------------------------+ + * 0 | Buffer Address [63:0] (Reserved on Write Back) | + * +--------------------------------------------------------------+ + * 8 | Special | CSS | Status | CMD | CSO | Length | + * +--------------------------------------------------------------+ + * 63 48 47 36 35 32 31 24 23 16 15 0 + * + * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload + * 63 48 47 40 39 32 31 16 15 8 7 0 + * +----------------------------------------------------------------+ + * 0 | TUCSE | TUCS0 | TUCSS | IPCSE | IPCS0 | IPCSS | + * +----------------------------------------------------------------+ + * 8 | MSS | HDRLEN | RSV | STA | TUCMD | DTYP | PAYLEN | + * +----------------------------------------------------------------+ + * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 + * + * Extended Data Descriptor (DTYP=0x1) + * +----------------------------------------------------------------+ + * 0 | Buffer Address [63:0] | + * +----------------------------------------------------------------+ + * 8 | VLAN tag | POPTS | Rsvd | Status | Command | DTYP | DTALEN | + * +----------------------------------------------------------------+ + * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 + */ + printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma ]" + " leng ntw timestmp bi->skb\n"); + printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen] [bi->dma ]" + " leng ntw timestmp bi->skb\n"); + + if (!netif_msg_tx_done(adapter)) + goto rx_ring_summary; + + for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { + struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i); + struct e1000_buffer *buffer_info = &tx_ring->buffer_info[i]; + struct my_u { u64 a; u64 b; }; + struct my_u *u = (struct my_u *)tx_desc; + printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX %04X %3X " + "%016llX %p", + ((le64_to_cpu(u->b) & (1<<20)) ? 'd' : 'c'), i, + le64_to_cpu(u->a), le64_to_cpu(u->b), + (u64)buffer_info->dma, buffer_info->length, + buffer_info->next_to_watch, (u64)buffer_info->time_stamp, + buffer_info->skb); + if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean) + printk(KERN_CONT" NTC/U\n"); + else if (i == tx_ring->next_to_use) + printk(KERN_CONT " NTU\n"); + else if (i == tx_ring->next_to_clean) + printk(KERN_CONT " NTC\n"); + else + printk(KERN_CONT "\n"); + + + if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, + 16, 1, phys_to_virt(buffer_info->dma), + buffer_info->length, true); + } + +rx_ring_summary: + /* + * receive dump + */ + pr_info("\nRX Desc ring dump\n"); + + /* Legacy Receive Descriptor Format + * + * +-----------------------------------------------------+ + * | Buffer Address [63:0] | + * +-----------------------------------------------------+ + * | VLAN Tag | Errors | Status 0 | Packet csum | Length | + * +-----------------------------------------------------+ + * 63 48 47 40 39 32 31 16 15 0 + */ + printk(KERN_INFO "R[desc] [address 63:0 ] [vl er S cks ln] " + "[bi->dma ] [bi->skb]\n"); + + if (!netif_msg_rx_status(adapter)) + goto exit; + + for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) { + struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i); + struct e1000_buffer *buffer_info = &rx_ring->buffer_info[i]; + struct my_u { u64 a; u64 b; }; + struct my_u *u = (struct my_u *)rx_desc; + printk(KERN_INFO "R[0x%03X] %016llX %016llX %016llX %p", + i, le64_to_cpu(u->a), le64_to_cpu(u->b), + (u64)buffer_info->dma, buffer_info->skb); + if (i == rx_ring->next_to_use) + printk(KERN_CONT " NTU\n"); + else if (i == rx_ring->next_to_clean) + printk(KERN_CONT " NTC\n"); + else + printk(KERN_CONT "\n"); + + if (netif_msg_pktdata(adapter)) + print_hex_dump(KERN_INFO, "", + DUMP_PREFIX_ADDRESS, 16, 1, + phys_to_virt(buffer_info->dma), + buffer_info->length, true); + + } /* for */ + + /* dump the descriptor caches */ + /* rx */ + printk(KERN_INFO "e1000: Rx descriptor cache in 64bit format\n"); + for (i = 0x6000; i <= 0x63FF ; i += 0x10) { + printk(KERN_INFO "R%04X: %08X|%08X %08X|%08X\n", + i, + readl(adapter->hw.hw_addr + i+4), + readl(adapter->hw.hw_addr + i), + readl(adapter->hw.hw_addr + i+12), + readl(adapter->hw.hw_addr + i+8)); + } + /* tx */ + printk(KERN_INFO "e1000: Tx descriptor cache in 64bit format\n"); + for (i = 0x7000; i <= 0x73FF ; i += 0x10) { + printk(KERN_INFO "T%04X: %08X|%08X %08X|%08X\n", + i, + readl(adapter->hw.hw_addr + i+4), + readl(adapter->hw.hw_addr + i), + readl(adapter->hw.hw_addr + i+12), + readl(adapter->hw.hw_addr + i+8)); + } +exit: + return; +} + /** * e1000_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure @@ -3260,6 +3482,7 @@ static void e1000_reset_task(struct work_struct *work) if (test_bit(__E1000_DOWN, &adapter->flags)) return; + e_err(drv, "Reset adapter\n"); e1000_reinit_safe(adapter); } @@ -3677,6 +3900,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, eop, jiffies, eop_desc->upper.fields.status); + e1000_dump(adapter); netif_stop_queue(netdev); } } -- GitLab From f36bb6cacd3bcbab9605e06f585ee8f1ea450876 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:38:04 +0000 Subject: [PATCH 0464/1846] e1000e: add missing initializers reported when compiling with W=1 warning: missing initializer Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 1a8dd2f0e609..c05137f362a1 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -137,7 +137,7 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = { {E1000_TDFPC, "TDFPC"}, /* List Terminator */ - {} + {0, NULL} }; /* @@ -6502,7 +6502,7 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = { { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_LM), board_pch2lan }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_V), board_pch2lan }, - { } /* terminate list */ + { 0, 0, 0, 0, 0, 0, 0 } /* terminate list */ }; MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); @@ -6521,7 +6521,9 @@ static struct pci_driver e1000_driver = { .probe = e1000_probe, .remove = __devexit_p(e1000_remove), #ifdef CONFIG_PM - .driver.pm = &e1000_pm_ops, + .driver = { + .pm = &e1000_pm_ops, + }, #endif .shutdown = e1000_shutdown, .err_handler = &e1000_err_handler -- GitLab From 9e2d7657e2a8fb40f732563dffb05151ea2d7e01 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:27 +0000 Subject: [PATCH 0465/1846] e1000e: cleanup - check return values consistently The majority of the e1000e code checks most function return values using a test like 'if (ret_val)' or 'if (!ret_val)' but there are a few instances of 'if (ret_val == 0)'. This patch converts the latter to the former for consistency. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ethtool.c | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index 92d5b6278955..f43af463ddc6 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -537,7 +537,7 @@ static int e1000_set_eeprom(struct net_device *netdev, ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]); ptr++; } - if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) + if (((eeprom->offset + eeprom->len) & 1) && (!ret_val)) /* need read/modify/write of last changed EEPROM word */ /* only the first byte of the word is being modified */ ret_val = e1000_read_nvm(hw, last_word, 1, diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 907b17b2e66a..0e64cc438494 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2286,7 +2286,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) } udelay(1); } - if (ret_val == 0) { + if (!ret_val) { /* * Successful in waiting for previous cycle to timeout, * now set the Flash Cycle Done. @@ -2404,7 +2404,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, udelay(1); /* Steps */ ret_val = e1000_flash_cycle_init_ich8lan(hw); - if (ret_val != 0) + if (ret_val) break; hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); @@ -2424,7 +2424,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, * read in (shift in) the Flash Data0, the order is * least significant byte first msb to lsb */ - if (ret_val == 0) { + if (!ret_val) { flash_data = er32flash(ICH_FLASH_FDATA0); if (size == 1) *data = (u8)(flash_data & 0x000000FF); @@ -2936,7 +2936,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) ret_val = e1000_flash_cycle_ich8lan(hw, ICH_FLASH_ERASE_COMMAND_TIMEOUT); - if (ret_val == 0) + if (!ret_val) break; /* -- GitLab From e68782ed789a8e52af410368a185b3768fa64614 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:43 +0000 Subject: [PATCH 0466/1846] e1000e: cleanup e1000_init_mac_params_80003es2lan() Combine two switch statements into one, convert a nebulous pointer to one that is a bit more in keeping with the rest of the driver code and remove some dead code (there are no 80003es2lan devices with fiber). No change in functionality, just cosmetic changes. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/e1000e/80003es2lan.c | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 82a5d87c90c0..9b969615b72a 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -205,15 +205,20 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct e1000_mac_info *mac = &hw->mac; - struct e1000_mac_operations *func = &mac->ops; - /* Set media type */ + /* Set media type and media-dependent function pointers */ switch (adapter->pdev->device) { case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: hw->phy.media_type = e1000_media_type_internal_serdes; + mac->ops.check_for_link = e1000e_check_for_serdes_link; + mac->ops.setup_physical_interface = + e1000e_setup_fiber_serdes_link; break; default: hw->phy.media_type = e1000_media_type_copper; + mac->ops.check_for_link = e1000e_check_for_copper_link; + mac->ops.setup_physical_interface = + e1000_setup_copper_link_80003es2lan; break; } @@ -230,25 +235,6 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) /* Adaptive IFS not supported */ mac->adaptive_ifs = false; - /* check for link */ - switch (hw->phy.media_type) { - case e1000_media_type_copper: - func->setup_physical_interface = e1000_setup_copper_link_80003es2lan; - func->check_for_link = e1000e_check_for_copper_link; - break; - case e1000_media_type_fiber: - func->setup_physical_interface = e1000e_setup_fiber_serdes_link; - func->check_for_link = e1000e_check_for_fiber_link; - break; - case e1000_media_type_internal_serdes: - func->setup_physical_interface = e1000e_setup_fiber_serdes_link; - func->check_for_link = e1000e_check_for_serdes_link; - break; - default: - return -E1000_ERR_CONFIG; - break; - } - /* set lan id for port to determine which phy lock to use */ hw->mac.ops.set_lan_id(hw); -- GitLab From 66092f59252cb53e5a997e1222ad203b78c8aa97 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:48 +0000 Subject: [PATCH 0467/1846] e1000e: cleanup e1000_init_mac_params_82571() Combine two switch statements into one, convert a nebulous pointer to one that is a bit more in keeping with the rest of the driver code and cleanup some coding style. No change in functionality, just cosmetic changes. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/82571.c | 72 ++++++++++------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 844907da8aaf..4cadcc76ad58 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -239,26 +239,39 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct e1000_mac_info *mac = &hw->mac; - struct e1000_mac_operations *func = &mac->ops; u32 swsm = 0; u32 swsm2 = 0; bool force_clear_smbi = false; - /* Set media type */ + /* Set media type and media-dependent function pointers */ switch (adapter->pdev->device) { case E1000_DEV_ID_82571EB_FIBER: case E1000_DEV_ID_82572EI_FIBER: case E1000_DEV_ID_82571EB_QUAD_FIBER: hw->phy.media_type = e1000_media_type_fiber; + mac->ops.setup_physical_interface = + e1000_setup_fiber_serdes_link_82571; + mac->ops.check_for_link = e1000e_check_for_fiber_link; + mac->ops.get_link_up_info = + e1000e_get_speed_and_duplex_fiber_serdes; break; case E1000_DEV_ID_82571EB_SERDES: - case E1000_DEV_ID_82572EI_SERDES: case E1000_DEV_ID_82571EB_SERDES_DUAL: case E1000_DEV_ID_82571EB_SERDES_QUAD: + case E1000_DEV_ID_82572EI_SERDES: hw->phy.media_type = e1000_media_type_internal_serdes; + mac->ops.setup_physical_interface = + e1000_setup_fiber_serdes_link_82571; + mac->ops.check_for_link = e1000_check_for_serdes_link_82571; + mac->ops.get_link_up_info = + e1000e_get_speed_and_duplex_fiber_serdes; break; default: hw->phy.media_type = e1000_media_type_copper; + mac->ops.setup_physical_interface = + e1000_setup_copper_link_82571; + mac->ops.check_for_link = e1000e_check_for_copper_link; + mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_copper; break; } @@ -269,38 +282,13 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) /* Adaptive IFS supported */ mac->adaptive_ifs = true; - /* check for link */ - switch (hw->phy.media_type) { - case e1000_media_type_copper: - func->setup_physical_interface = e1000_setup_copper_link_82571; - func->check_for_link = e1000e_check_for_copper_link; - func->get_link_up_info = e1000e_get_speed_and_duplex_copper; - break; - case e1000_media_type_fiber: - func->setup_physical_interface = - e1000_setup_fiber_serdes_link_82571; - func->check_for_link = e1000e_check_for_fiber_link; - func->get_link_up_info = - e1000e_get_speed_and_duplex_fiber_serdes; - break; - case e1000_media_type_internal_serdes: - func->setup_physical_interface = - e1000_setup_fiber_serdes_link_82571; - func->check_for_link = e1000_check_for_serdes_link_82571; - func->get_link_up_info = - e1000e_get_speed_and_duplex_fiber_serdes; - break; - default: - return -E1000_ERR_CONFIG; - break; - } - + /* MAC-specific function pointers */ switch (hw->mac.type) { case e1000_82573: - func->set_lan_id = e1000_set_lan_id_single_port; - func->check_mng_mode = e1000e_check_mng_mode_generic; - func->led_on = e1000e_led_on_generic; - func->blink_led = e1000e_blink_led_generic; + mac->ops.set_lan_id = e1000_set_lan_id_single_port; + mac->ops.check_mng_mode = e1000e_check_mng_mode_generic; + mac->ops.led_on = e1000e_led_on_generic; + mac->ops.blink_led = e1000e_blink_led_generic; /* FWSM register */ mac->has_fwsm = true; @@ -314,14 +302,14 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) break; case e1000_82574: case e1000_82583: - func->set_lan_id = e1000_set_lan_id_single_port; - func->check_mng_mode = e1000_check_mng_mode_82574; - func->led_on = e1000_led_on_82574; + mac->ops.set_lan_id = e1000_set_lan_id_single_port; + mac->ops.check_mng_mode = e1000_check_mng_mode_82574; + mac->ops.led_on = e1000_led_on_82574; break; default: - func->check_mng_mode = e1000e_check_mng_mode_generic; - func->led_on = e1000e_led_on_generic; - func->blink_led = e1000e_blink_led_generic; + mac->ops.check_mng_mode = e1000e_check_mng_mode_generic; + mac->ops.led_on = e1000e_led_on_generic; + mac->ops.blink_led = e1000e_blink_led_generic; /* FWSM register */ mac->has_fwsm = true; @@ -342,11 +330,11 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) if (!(swsm2 & E1000_SWSM2_LOCK)) { /* Only do this for the first interface on this card */ - ew32(SWSM2, - swsm2 | E1000_SWSM2_LOCK); + ew32(SWSM2, swsm2 | E1000_SWSM2_LOCK); force_clear_smbi = true; - } else + } else { force_clear_smbi = false; + } break; default: force_clear_smbi = true; -- GitLab From f23efdff77bbc1207255ccebe04771970604bbd9 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:38 +0000 Subject: [PATCH 0468/1846] e1000e: cleanup e1000_set_phys_id Use the existing hw pointer. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index f43af463ddc6..fd2ba3818d3c 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -1856,11 +1856,11 @@ static int e1000_set_phys_id(struct net_device *netdev, break; case ETHTOOL_ID_ON: - adapter->hw.mac.ops.led_on(&adapter->hw); + hw->mac.ops.led_on(hw); break; case ETHTOOL_ID_OFF: - adapter->hw.mac.ops.led_off(&adapter->hw); + hw->mac.ops.led_off(hw); break; } return 0; -- GitLab From 24b706b2f4bb28c34d32f9d333d8a118215a38cc Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:22 +0000 Subject: [PATCH 0469/1846] e1000e: cleanup - use braces in both branches of a conditional statement Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index c05137f362a1..02efae08ce3b 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -3756,8 +3756,9 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter) if (adapter->flags & FLAG_MSI_TEST_FAILED) { adapter->int_mode = E1000E_INT_MODE_LEGACY; e_info("MSI interrupt test failed, using legacy interrupt.\n"); - } else + } else { e_dbg("MSI interrupt test succeeded!\n"); + } free_irq(adapter->pdev->irq, netdev); pci_disable_msi(adapter->pdev); -- GitLab From a2a5b3235d0dce0feaadf4e76727adea1caa6869 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:17 +0000 Subject: [PATCH 0470/1846] e1000e: fix checkpatch warning from MINMAX test WARNING: min() should probably be min_t(unsigned int, 4, skb->data_len) Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 02efae08ce3b..a9f25fcfbfe3 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -5023,7 +5023,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, if (skb->data_len && (hdr_len == len)) { unsigned int pull_size; - pull_size = min((unsigned int)4, skb->data_len); + pull_size = min_t(unsigned int, 4, skb->data_len); if (!__pskb_pull_tail(skb, pull_size)) { e_err("__pskb_pull_tail failed.\n"); dev_kfree_skb_any(skb); -- GitLab From e885d762b7f73e811432f67608a6f0affa861029 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:32 +0000 Subject: [PATCH 0471/1846] e1000e: fix sparse warnings with -D__CHECK_ENDIAN__ Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ethtool.c | 2 +- drivers/net/ethernet/intel/e1000e/netdev.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index fd2ba3818d3c..f4dc0fa9d9b5 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -553,7 +553,7 @@ static int e1000_set_eeprom(struct net_device *netdev, memcpy(ptr, bytes, eeprom->len); for (i = 0; i < last_word - first_word + 1; i++) - eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]); + cpu_to_le16s(&eeprom_buff[i]); ret_val = e1000_write_nvm(hw, first_word, last_word - first_word + 1, eeprom_buff); diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index a9f25fcfbfe3..2ac1164d04e5 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -183,18 +183,18 @@ static void e1000e_dump(struct e1000_adapter *adapter) struct e1000_ring *tx_ring = adapter->tx_ring; struct e1000_tx_desc *tx_desc; struct my_u0 { - u64 a; - u64 b; + __le64 a; + __le64 b; } *u0; struct e1000_buffer *buffer_info; struct e1000_ring *rx_ring = adapter->rx_ring; union e1000_rx_desc_packet_split *rx_desc_ps; union e1000_rx_desc_extended *rx_desc; struct my_u1 { - u64 a; - u64 b; - u64 c; - u64 d; + __le64 a; + __le64 b; + __le64 c; + __le64 d; } *u1; u32 staterr; int i = 0; @@ -5963,7 +5963,8 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) return; ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf); - if (!ret_val && (!(le16_to_cpu(buf) & (1 << 0)))) { + le16_to_cpus(&buf); + if (!ret_val && (!(buf & (1 << 0)))) { /* Deep Smart Power Down (DSPD) */ dev_warn(&adapter->pdev->dev, "Warning: detected DSPD enabled in EEPROM\n"); -- GitLab From 0e15df490eef6f5080b84533dcd3068a78122768 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:11 +0000 Subject: [PATCH 0472/1846] e1000e: minor whitespace and indentation cleanup Cleanup of some whitespace and indentation of a single code block. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 +- drivers/net/ethernet/intel/e1000e/netdev.c | 76 +++++++++++---------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 0e64cc438494..5061d4ded6e2 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -280,8 +280,8 @@ static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val) #define er16flash(reg) __er16flash(hw, (reg)) #define er32flash(reg) __er32flash(hw, (reg)) -#define ew16flash(reg,val) __ew16flash(hw, (reg), (val)) -#define ew32flash(reg,val) __ew32flash(hw, (reg), (val)) +#define ew16flash(reg, val) __ew16flash(hw, (reg), (val)) +#define ew32flash(reg, val) __ew32flash(hw, (reg), (val)) static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw) { diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 2ac1164d04e5..293a7606e0f4 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1267,43 +1267,49 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done, skb_put(skb, length); { - /* - * this looks ugly, but it seems compiler issues make it - * more efficient than reusing j - */ - int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]); - - /* - * page alloc/put takes too long and effects small packet - * throughput, so unsplit small packets and save the alloc/put - * only valid in softirq (napi) context to call kmap_* - */ - if (l1 && (l1 <= copybreak) && - ((length + l1) <= adapter->rx_ps_bsize0)) { - u8 *vaddr; - - ps_page = &buffer_info->ps_pages[0]; + /* + * this looks ugly, but it seems compiler issues make + * it more efficient than reusing j + */ + int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]); /* - * there is no documentation about how to call - * kmap_atomic, so we can't hold the mapping - * very long + * page alloc/put takes too long and effects small + * packet throughput, so unsplit small packets and + * save the alloc/put only valid in softirq (napi) + * context to call kmap_* */ - dma_sync_single_for_cpu(&pdev->dev, ps_page->dma, - PAGE_SIZE, DMA_FROM_DEVICE); - vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ); - memcpy(skb_tail_pointer(skb), vaddr, l1); - kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); - dma_sync_single_for_device(&pdev->dev, ps_page->dma, - PAGE_SIZE, DMA_FROM_DEVICE); - - /* remove the CRC */ - if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) - l1 -= 4; - - skb_put(skb, l1); - goto copydone; - } /* if */ + if (l1 && (l1 <= copybreak) && + ((length + l1) <= adapter->rx_ps_bsize0)) { + u8 *vaddr; + + ps_page = &buffer_info->ps_pages[0]; + + /* + * there is no documentation about how to call + * kmap_atomic, so we can't hold the mapping + * very long + */ + dma_sync_single_for_cpu(&pdev->dev, + ps_page->dma, + PAGE_SIZE, + DMA_FROM_DEVICE); + vaddr = kmap_atomic(ps_page->page, + KM_SKB_DATA_SOFTIRQ); + memcpy(skb_tail_pointer(skb), vaddr, l1); + kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); + dma_sync_single_for_device(&pdev->dev, + ps_page->dma, + PAGE_SIZE, + DMA_FROM_DEVICE); + + /* remove the CRC */ + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) + l1 -= 4; + + skb_put(skb, l1); + goto copydone; + } /* if */ } for (j = 0; j < PS_PAGE_BUFFERS; j++) { @@ -4969,7 +4975,7 @@ static int e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size) return __e1000_maybe_stop_tx(tx_ring, size); } -#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) +#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1) static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) { -- GitLab From c3059be16c9ef29c05f0876a9df5fea21f29724f Mon Sep 17 00:00:00 2001 From: Shriram Rajagopalan Date: Sun, 5 Feb 2012 13:51:32 +0000 Subject: [PATCH 0473/1846] net/sched: sch_plug - Queue traffic until an explicit release command The qdisc supports two operations - plug and unplug. When the qdisc receives a plug command via netlink request, packets arriving henceforth are buffered until a corresponding unplug command is received. Depending on the type of unplug command, the queue can be unplugged indefinitely or selectively. This qdisc can be used to implement output buffering, an essential functionality required for consistent recovery in checkpoint based fault-tolerance systems. Output buffering enables speculative execution by allowing generated network traffic to be rolled back. It is used to provide network protection for Xen Guests in the Remus high availability project, available as part of Xen. This module is generic enough to be used by any other system that wishes to add speculative execution and output buffering to its applications. This module was originally available in the linux 2.6.32 PV-OPS tree, used as dom0 for Xen. For more information, please refer to http://nss.cs.ubc.ca/remus/ and http://wiki.xensource.com/xenwiki/Remus Changes in V3: * Removed debug output (printk) on queue overflow * Added TCQ_PLUG_RELEASE_INDEFINITE - that allows the user to use this qdisc, for simple plug/unplug operations. * Use of packet counts instead of pointers to keep track of the buffers in the queue. Signed-off-by: Shriram Rajagopalan Signed-off-by: Brendan Cully [author of the code in the linux 2.6.32 pvops tree] Signed-off-by: David S. Miller --- include/linux/pkt_sched.h | 21 ++++ net/sched/Kconfig | 26 +++++ net/sched/Makefile | 1 + net/sched/sch_plug.c | 233 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 net/sched/sch_plug.c diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h index 0d5b79365d03..410b33d014d2 100644 --- a/include/linux/pkt_sched.h +++ b/include/linux/pkt_sched.h @@ -127,6 +127,27 @@ struct tc_multiq_qopt { __u16 max_bands; /* Maximum number of queues */ }; +/* PLUG section */ + +#define TCQ_PLUG_BUFFER 0 +#define TCQ_PLUG_RELEASE_ONE 1 +#define TCQ_PLUG_RELEASE_INDEFINITE 2 +#define TCQ_PLUG_LIMIT 3 + +struct tc_plug_qopt { + /* TCQ_PLUG_BUFFER: Inset a plug into the queue and + * buffer any incoming packets + * TCQ_PLUG_RELEASE_ONE: Dequeue packets from queue head + * to beginning of the next plug. + * TCQ_PLUG_RELEASE_INDEFINITE: Dequeue all packets from queue. + * Stop buffering packets until the next TCQ_PLUG_BUFFER + * command is received (just act as a pass-thru queue). + * TCQ_PLUG_LIMIT: Increase/decrease queue size + */ + int action; + __u32 limit; +}; + /* TBF section */ struct tc_tbf_qopt { diff --git a/net/sched/Kconfig b/net/sched/Kconfig index 2590e91b3289..75b58f81d53d 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig @@ -260,6 +260,32 @@ config NET_SCH_INGRESS To compile this code as a module, choose M here: the module will be called sch_ingress. +config NET_SCH_PLUG + tristate "Plug network traffic until release (PLUG)" + ---help--- + + This queuing discipline allows userspace to plug/unplug a network + output queue, using the netlink interface. When it receives an + enqueue command it inserts a plug into the outbound queue that + causes following packets to enqueue until a dequeue command arrives + over netlink, causing the plug to be removed and resuming the normal + packet flow. + + This module also provides a generic "network output buffering" + functionality (aka output commit), wherein upon arrival of a dequeue + command, only packets up to the first plug are released for delivery. + The Remus HA project uses this module to enable speculative execution + of virtual machines by allowing the generated network output to be rolled + back if needed. + + For more information, please refer to http://wiki.xensource.com/xenwiki/Remus + + Say Y here if you are using this kernel for Xen dom0 and + want to protect Xen guests with Remus. + + To compile this code as a module, choose M here: the + module will be called sch_plug. + comment "Classification" config NET_CLS diff --git a/net/sched/Makefile b/net/sched/Makefile index dc5889c0a15a..8cdf4e2b51d3 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_NET_SCH_MULTIQ) += sch_multiq.o obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o obj-$(CONFIG_NET_SCH_NETEM) += sch_netem.o obj-$(CONFIG_NET_SCH_DRR) += sch_drr.o +obj-$(CONFIG_NET_SCH_PLUG) += sch_plug.o obj-$(CONFIG_NET_SCH_MQPRIO) += sch_mqprio.o obj-$(CONFIG_NET_SCH_CHOKE) += sch_choke.o obj-$(CONFIG_NET_SCH_QFQ) += sch_qfq.o diff --git a/net/sched/sch_plug.c b/net/sched/sch_plug.c new file mode 100644 index 000000000000..ba7b737e4055 --- /dev/null +++ b/net/sched/sch_plug.c @@ -0,0 +1,233 @@ +/* + * sch_plug.c Queue traffic until an explicit release command + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * There are two ways to use this qdisc: + * 1. A simple "instantaneous" plug/unplug operation, by issuing an alternating + * sequence of TCQ_PLUG_BUFFER & TCQ_PLUG_RELEASE_INDEFINITE commands. + * + * 2. For network output buffering (a.k.a output commit) functionality. + * Output commit property is commonly used by applications using checkpoint + * based fault-tolerance to ensure that the checkpoint from which a system + * is being restored is consistent w.r.t outside world. + * + * Consider for e.g. Remus - a Virtual Machine checkpointing system, + * wherein a VM is checkpointed, say every 50ms. The checkpoint is replicated + * asynchronously to the backup host, while the VM continues executing the + * next epoch speculatively. + * + * The following is a typical sequence of output buffer operations: + * 1.At epoch i, start_buffer(i) + * 2. At end of epoch i (i.e. after 50ms): + * 2.1 Stop VM and take checkpoint(i). + * 2.2 start_buffer(i+1) and Resume VM + * 3. While speculatively executing epoch(i+1), asynchronously replicate + * checkpoint(i) to backup host. + * 4. When checkpoint_ack(i) is received from backup, release_buffer(i) + * Thus, this Qdisc would receive the following sequence of commands: + * TCQ_PLUG_BUFFER (epoch i) + * .. TCQ_PLUG_BUFFER (epoch i+1) + * ....TCQ_PLUG_RELEASE_ONE (epoch i) + * ......TCQ_PLUG_BUFFER (epoch i+2) + * ........ + */ + +#include +#include +#include +#include +#include +#include +#include + +/* + * State of the queue, when used for network output buffering: + * + * plug(i+1) plug(i) head + * ------------------+--------------------+----------------> + * | | + * | | + * pkts_current_epoch| pkts_last_epoch |pkts_to_release + * ----------------->|<--------+--------->|+---------------> + * v v + * + */ + +struct plug_sched_data { + /* If true, the dequeue function releases all packets + * from head to end of the queue. The queue turns into + * a pass-through queue for newly arriving packets. + */ + bool unplug_indefinite; + + /* Queue Limit in bytes */ + u32 limit; + + /* Number of packets (output) from the current speculatively + * executing epoch. + */ + u32 pkts_current_epoch; + + /* Number of packets corresponding to the recently finished + * epoch. These will be released when we receive a + * TCQ_PLUG_RELEASE_ONE command. This command is typically + * issued after committing a checkpoint at the target. + */ + u32 pkts_last_epoch; + + /* + * Number of packets from the head of the queue, that can + * be released (committed checkpoint). + */ + u32 pkts_to_release; +}; + +static int plug_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct plug_sched_data *q = qdisc_priv(sch); + + if (likely(sch->qstats.backlog + skb->len <= q->limit)) { + if (!q->unplug_indefinite) + q->pkts_current_epoch++; + return qdisc_enqueue_tail(skb, sch); + } + + return qdisc_reshape_fail(skb, sch); +} + +static struct sk_buff *plug_dequeue(struct Qdisc *sch) +{ + struct plug_sched_data *q = qdisc_priv(sch); + + if (qdisc_is_throttled(sch)) + return NULL; + + if (!q->unplug_indefinite) { + if (!q->pkts_to_release) { + /* No more packets to dequeue. Block the queue + * and wait for the next release command. + */ + qdisc_throttled(sch); + return NULL; + } + q->pkts_to_release--; + } + + return qdisc_dequeue_head(sch); +} + +static int plug_init(struct Qdisc *sch, struct nlattr *opt) +{ + struct plug_sched_data *q = qdisc_priv(sch); + + q->pkts_current_epoch = 0; + q->pkts_last_epoch = 0; + q->pkts_to_release = 0; + q->unplug_indefinite = false; + + if (opt == NULL) { + /* We will set a default limit of 100 pkts (~150kB) + * in case tx_queue_len is not available. The + * default value is completely arbitrary. + */ + u32 pkt_limit = qdisc_dev(sch)->tx_queue_len ? : 100; + q->limit = pkt_limit * psched_mtu(qdisc_dev(sch)); + } else { + struct tc_plug_qopt *ctl = nla_data(opt); + + if (nla_len(opt) < sizeof(*ctl)) + return -EINVAL; + + q->limit = ctl->limit; + } + + qdisc_throttled(sch); + return 0; +} + +/* Receives 4 types of messages: + * TCQ_PLUG_BUFFER: Inset a plug into the queue and + * buffer any incoming packets + * TCQ_PLUG_RELEASE_ONE: Dequeue packets from queue head + * to beginning of the next plug. + * TCQ_PLUG_RELEASE_INDEFINITE: Dequeue all packets from queue. + * Stop buffering packets until the next TCQ_PLUG_BUFFER + * command is received (just act as a pass-thru queue). + * TCQ_PLUG_LIMIT: Increase/decrease queue size + */ +static int plug_change(struct Qdisc *sch, struct nlattr *opt) +{ + struct plug_sched_data *q = qdisc_priv(sch); + struct tc_plug_qopt *msg; + + if (opt == NULL) + return -EINVAL; + + msg = nla_data(opt); + if (nla_len(opt) < sizeof(*msg)) + return -EINVAL; + + switch (msg->action) { + case TCQ_PLUG_BUFFER: + /* Save size of the current buffer */ + q->pkts_last_epoch = q->pkts_current_epoch; + q->pkts_current_epoch = 0; + if (q->unplug_indefinite) + qdisc_throttled(sch); + q->unplug_indefinite = false; + break; + case TCQ_PLUG_RELEASE_ONE: + /* Add packets from the last complete buffer to the + * packets to be released set. + */ + q->pkts_to_release += q->pkts_last_epoch; + q->pkts_last_epoch = 0; + qdisc_unthrottled(sch); + netif_schedule_queue(sch->dev_queue); + break; + case TCQ_PLUG_RELEASE_INDEFINITE: + q->unplug_indefinite = true; + q->pkts_to_release = 0; + q->pkts_last_epoch = 0; + q->pkts_current_epoch = 0; + qdisc_unthrottled(sch); + netif_schedule_queue(sch->dev_queue); + break; + case TCQ_PLUG_LIMIT: + /* Limit is supplied in bytes */ + q->limit = msg->limit; + break; + default: + return -EINVAL; + } + + return 0; +} + +struct Qdisc_ops plug_qdisc_ops = { + .id = "plug", + .priv_size = sizeof(struct plug_sched_data), + .enqueue = plug_enqueue, + .dequeue = plug_dequeue, + .peek = qdisc_peek_head, + .init = plug_init, + .change = plug_change, + .owner = THIS_MODULE, +}; + +static int __init plug_module_init(void) +{ + return register_qdisc(&plug_qdisc_ops); +} + +static void __exit plug_module_exit(void) +{ + unregister_qdisc(&plug_qdisc_ops); +} +module_init(plug_module_init) +module_exit(plug_module_exit) +MODULE_LICENSE("GPL"); -- GitLab From b72061a3cb0f1c5aa3f919e2dadb4a1631773e7a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 7 Feb 2012 08:27:31 +0000 Subject: [PATCH 0474/1846] net: fec: Fix build due to wrong dev annotation commit 21a4e469 (netdev: ethernet dev_alloc_skb to netdev_alloc_skb) should have used "ndev" instead of "dev". This causes the following build errors: drivers/net/ethernet/freescale/fec.c: In function 'fec_enet_rx': drivers/net/ethernet/freescale/fec.c:714: error: 'dev' undeclared (first use in this function) drivers/net/ethernet/freescale/fec.c:714: error: (Each undeclared identifier is reported only once drivers/net/ethernet/freescale/fec.c:714: error: for each function it appears in.) drivers/net/ethernet/freescale/fec.c: In function 'fec_enet_alloc_buffers': drivers/net/ethernet/freescale/fec.c:1213: error: 'dev' undeclared (first use in this function) Fix it, so that fec driver can be built again. Signed-off-by: Fabio Estevam Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index f976619d1b21..0ee2ca7baaf3 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -711,7 +711,7 @@ fec_enet_rx(struct net_device *ndev) * include that when passing upstream as it messes up * bridging applications. */ - skb = netdev_alloc_skb(dev, pkt_len - 4 + NET_IP_ALIGN); + skb = netdev_alloc_skb(ndev, pkt_len - 4 + NET_IP_ALIGN); if (unlikely(!skb)) { printk("%s: Memory squeeze, dropping packet.\n", @@ -1210,7 +1210,7 @@ static int fec_enet_alloc_buffers(struct net_device *ndev) bdp = fep->rx_bd_base; for (i = 0; i < RX_RING_SIZE; i++) { - skb = netdev_alloc_skb(dev, FEC_ENET_RX_FRSIZE); + skb = netdev_alloc_skb(ndev, FEC_ENET_RX_FRSIZE); if (!skb) { fec_enet_free_buffers(ndev); return -ENOMEM; -- GitLab From bb7d92e3e3049e22b5807ac559a72b38fad5f499 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 6 Feb 2012 22:17:21 +0000 Subject: [PATCH 0475/1846] sh-eth: use netdev stats structure and fix dma_map_single No need to maintain a parallel net_device_stats structure in sh_eth_private, since we have a generic one in netdev Fix two dma_map_single() incorrect parameters, passing skb->tail instead of skb->data. Seems that there is no corresponding dmap_unmap_single() calls for the moment in this driver. Signed-off-by: Eric Dumazet Cc: Yoshihiro Shimoda Tested-by: Yoshihiro Shimoda Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 62 +++++++++++++-------------- drivers/net/ethernet/renesas/sh_eth.h | 1 - 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 1cb5a34d5779..dacd13150b6c 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -657,7 +657,7 @@ static void sh_eth_ring_format(struct net_device *ndev) mdp->rx_skbuff[i] = skb; if (skb == NULL) break; - dma_map_single(&ndev->dev, skb->tail, mdp->rx_buf_sz, + dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); skb->dev = ndev; /* Mark as being used by this device. */ sh_eth_set_receive_align(skb); @@ -881,8 +881,8 @@ static int sh_eth_txfree(struct net_device *ndev) if (entry >= TX_RING_SIZE - 1) txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); - mdp->stats.tx_packets++; - mdp->stats.tx_bytes += txdesc->buffer_length; + ndev->stats.tx_packets++; + ndev->stats.tx_bytes += txdesc->buffer_length; } return freeNum; } @@ -908,23 +908,23 @@ static int sh_eth_rx(struct net_device *ndev) break; if (!(desc_status & RDFEND)) - mdp->stats.rx_length_errors++; + ndev->stats.rx_length_errors++; if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 | RD_RFS5 | RD_RFS6 | RD_RFS10)) { - mdp->stats.rx_errors++; + ndev->stats.rx_errors++; if (desc_status & RD_RFS1) - mdp->stats.rx_crc_errors++; + ndev->stats.rx_crc_errors++; if (desc_status & RD_RFS2) - mdp->stats.rx_frame_errors++; + ndev->stats.rx_frame_errors++; if (desc_status & RD_RFS3) - mdp->stats.rx_length_errors++; + ndev->stats.rx_length_errors++; if (desc_status & RD_RFS4) - mdp->stats.rx_length_errors++; + ndev->stats.rx_length_errors++; if (desc_status & RD_RFS6) - mdp->stats.rx_missed_errors++; + ndev->stats.rx_missed_errors++; if (desc_status & RD_RFS10) - mdp->stats.rx_over_errors++; + ndev->stats.rx_over_errors++; } else { if (!mdp->cd->hw_swap) sh_eth_soft_swap( @@ -937,8 +937,8 @@ static int sh_eth_rx(struct net_device *ndev) skb_put(skb, pkt_len); skb->protocol = eth_type_trans(skb, ndev); netif_rx(skb); - mdp->stats.rx_packets++; - mdp->stats.rx_bytes += pkt_len; + ndev->stats.rx_packets++; + ndev->stats.rx_bytes += pkt_len; } rxdesc->status |= cpu_to_edmac(mdp, RD_RACT); entry = (++mdp->cur_rx) % RX_RING_SIZE; @@ -957,7 +957,7 @@ static int sh_eth_rx(struct net_device *ndev) mdp->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ - dma_map_single(&ndev->dev, skb->tail, mdp->rx_buf_sz, + dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); skb->dev = ndev; sh_eth_set_receive_align(skb); @@ -1007,7 +1007,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status) felic_stat = sh_eth_read(ndev, ECSR); sh_eth_write(ndev, felic_stat, ECSR); /* clear int */ if (felic_stat & ECSR_ICD) - mdp->stats.tx_carrier_errors++; + ndev->stats.tx_carrier_errors++; if (felic_stat & ECSR_LCHNG) { /* Link Changed */ if (mdp->cd->no_psr || mdp->no_ether_link) { @@ -1040,7 +1040,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status) if (intr_status & EESR_TWB) { /* Write buck end. unused write back interrupt */ if (intr_status & EESR_TABT) /* Transmit Abort int */ - mdp->stats.tx_aborted_errors++; + ndev->stats.tx_aborted_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit Abort\n"); } @@ -1049,7 +1049,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status) /* Receive Abort int */ if (intr_status & EESR_RFRMER) { /* Receive Frame Overflow int */ - mdp->stats.rx_frame_errors++; + ndev->stats.rx_frame_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive Abort\n"); } @@ -1057,21 +1057,21 @@ static void sh_eth_error(struct net_device *ndev, int intr_status) if (intr_status & EESR_TDE) { /* Transmit Descriptor Empty int */ - mdp->stats.tx_fifo_errors++; + ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit Descriptor Empty\n"); } if (intr_status & EESR_TFE) { /* FIFO under flow */ - mdp->stats.tx_fifo_errors++; + ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Transmit FIFO Under flow\n"); } if (intr_status & EESR_RDE) { /* Receive Descriptor Empty int */ - mdp->stats.rx_over_errors++; + ndev->stats.rx_over_errors++; if (sh_eth_read(ndev, EDRRR) ^ EDRRR_R) sh_eth_write(ndev, EDRRR_R, EDRRR); @@ -1081,14 +1081,14 @@ static void sh_eth_error(struct net_device *ndev, int intr_status) if (intr_status & EESR_RFE) { /* Receive FIFO Overflow int */ - mdp->stats.rx_fifo_errors++; + ndev->stats.rx_fifo_errors++; if (netif_msg_rx_err(mdp)) dev_err(&ndev->dev, "Receive FIFO Overflow\n"); } if (!mdp->cd->no_ade && (intr_status & EESR_ADE)) { /* Address Error */ - mdp->stats.tx_fifo_errors++; + ndev->stats.tx_fifo_errors++; if (netif_msg_tx_err(mdp)) dev_err(&ndev->dev, "Address Error\n"); } @@ -1445,7 +1445,7 @@ static void sh_eth_tx_timeout(struct net_device *ndev) " resetting...\n", ndev->name, (int)sh_eth_read(ndev, EESR)); /* tx_errors count up */ - mdp->stats.tx_errors++; + ndev->stats.tx_errors++; /* timer off */ del_timer_sync(&mdp->timer); @@ -1567,27 +1567,27 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) pm_runtime_get_sync(&mdp->pdev->dev); - mdp->stats.tx_dropped += sh_eth_read(ndev, TROCR); + ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR); sh_eth_write(ndev, 0, TROCR); /* (write clear) */ - mdp->stats.collisions += sh_eth_read(ndev, CDCR); + ndev->stats.collisions += sh_eth_read(ndev, CDCR); sh_eth_write(ndev, 0, CDCR); /* (write clear) */ - mdp->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR); + ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR); sh_eth_write(ndev, 0, LCCR); /* (write clear) */ if (sh_eth_is_gether(mdp)) { - mdp->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR); + ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR); sh_eth_write(ndev, 0, CERCR); /* (write clear) */ - mdp->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR); + ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR); sh_eth_write(ndev, 0, CEECR); /* (write clear) */ } else { - mdp->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR); + ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR); sh_eth_write(ndev, 0, CNDCR); /* (write clear) */ } pm_runtime_put_sync(&mdp->pdev->dev); - return &mdp->stats; + return &ndev->stats; } -/* ioctl to device funciotn*/ +/* ioctl to device function */ static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) { diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index 47877b13ffad..ba72976926fd 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h @@ -762,7 +762,6 @@ struct sh_eth_private { struct sh_eth_txdesc *tx_ring; struct sk_buff **rx_skbuff; struct sk_buff **tx_skbuff; - struct net_device_stats stats; struct timer_list timer; spinlock_t lock; u32 cur_rx, dirty_rx; /* Producer/consumer ring indices */ -- GitLab From af2ce213f6e6b28497c5c932f43b94026b5a0363 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 6 Feb 2012 21:20:15 +0000 Subject: [PATCH 0476/1846] caif: remove duplicate initialization "priv" is initialized twice. I kept the second one, because it is next to the check for NULL. Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller --- net/caif/chnl_net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c index a751d9b263ed..e866234d0e5a 100644 --- a/net/caif/chnl_net.c +++ b/net/caif/chnl_net.c @@ -72,13 +72,12 @@ static void robust_list_del(struct list_head *delete_node) static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt) { struct sk_buff *skb; - struct chnl_net *priv = container_of(layr, struct chnl_net, chnl); + struct chnl_net *priv; int pktlen; const u8 *ip_version; u8 buf; priv = container_of(layr, struct chnl_net, chnl); - if (!priv) return -EINVAL; -- GitLab From 7280f5ae0d71f2259a42d1f7603480809e4867fb Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 7 Feb 2012 15:28:15 -0500 Subject: [PATCH 0477/1846] sonice: Fix build due to botched netdev_alloc_skb() conversion. Reported-by: Geert Uytterhoeven Signed-off-by: David S. Miller --- drivers/net/ethernet/natsemi/sonic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c index 0452e2968d27..46795e403467 100644 --- a/drivers/net/ethernet/natsemi/sonic.c +++ b/drivers/net/ethernet/natsemi/sonic.c @@ -422,7 +422,7 @@ static void sonic_rx(struct net_device *dev) status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); if (status & SONIC_RCR_PRX) { /* Malloc up new buffer. */ - new_skb = netdev_alloc_skb(SONIC_RBSIZE + 2); + new_skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); if (new_skb == NULL) { printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); lp->stats.rx_dropped++; -- GitLab From 9b9a4f2acac2a04416ba15242b8666d4f8273e31 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 6 Feb 2012 08:23:27 +0200 Subject: [PATCH 0478/1846] ath6kl: store firmware logs in skbuffs Currently firmware logs are stored in a circular buffer, but this was not very flexible and fragile. It's a lot easier to store logs to struct skbuffs and store them in a skb queue. Also this makes it possible to easily increase the buffer size, even dynamically if we so want (but that's not yet supported). From user space point of view nothing should change. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 5 +- drivers/net/wireless/ath/ath6kl/debug.c | 121 ++++++++---------------- 2 files changed, 41 insertions(+), 85 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index c4d66e066dc9..9a58214135b9 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -652,10 +652,9 @@ struct ath6kl { #ifdef CONFIG_ATH6KL_DEBUG struct { - struct circ_buf fwlog_buf; - spinlock_t fwlog_lock; - void *fwlog_tmp; + struct sk_buff_head fwlog_queue; u32 fwlog_mask; + unsigned int dbgfs_diag_reg; u32 diag_reg_addr_wr; u32 diag_reg_val_wr; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index d832058816fe..98b5f15f622e 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -16,7 +16,7 @@ #include "core.h" -#include +#include #include #include #include @@ -32,9 +32,8 @@ struct ath6kl_fwlog_slot { u8 payload[0]; }; -#define ATH6KL_FWLOG_SIZE 32768 -#define ATH6KL_FWLOG_SLOT_SIZE (sizeof(struct ath6kl_fwlog_slot) + \ - ATH6KL_FWLOG_PAYLOAD_SIZE) +#define ATH6KL_FWLOG_MAX_ENTRIES 20 + #define ATH6KL_FWLOG_VALID_MASK 0x1ffff int ath6kl_printk(const char *level, const char *fmt, ...) @@ -268,105 +267,77 @@ static const struct file_operations fops_war_stats = { .llseek = default_llseek, }; -static void ath6kl_debug_fwlog_add(struct ath6kl *ar, const void *buf, - size_t buf_len) -{ - struct circ_buf *fwlog = &ar->debug.fwlog_buf; - size_t space; - int i; - - /* entries must all be equal size */ - if (WARN_ON(buf_len != ATH6KL_FWLOG_SLOT_SIZE)) - return; - - space = CIRC_SPACE(fwlog->head, fwlog->tail, ATH6KL_FWLOG_SIZE); - if (space < buf_len) - /* discard oldest slot */ - fwlog->tail = (fwlog->tail + ATH6KL_FWLOG_SLOT_SIZE) & - (ATH6KL_FWLOG_SIZE - 1); - - for (i = 0; i < buf_len; i += space) { - space = CIRC_SPACE_TO_END(fwlog->head, fwlog->tail, - ATH6KL_FWLOG_SIZE); - - if ((size_t) space > buf_len - i) - space = buf_len - i; - - memcpy(&fwlog->buf[fwlog->head], buf, space); - fwlog->head = (fwlog->head + space) & (ATH6KL_FWLOG_SIZE - 1); - } - -} - void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len) { - struct ath6kl_fwlog_slot *slot = ar->debug.fwlog_tmp; + struct ath6kl_fwlog_slot *slot; + struct sk_buff *skb; size_t slot_len; if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE)) return; - spin_lock_bh(&ar->debug.fwlog_lock); + slot_len = sizeof(*slot) + len; + skb = alloc_skb(slot_len, GFP_KERNEL); + if (!skb) + return; + + slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len); slot->timestamp = cpu_to_le32(jiffies); slot->length = cpu_to_le32(len); memcpy(slot->payload, buf, len); - slot_len = sizeof(*slot) + len; + spin_lock(&ar->debug.fwlog_queue.lock); - if (slot_len < ATH6KL_FWLOG_SLOT_SIZE) - memset(slot->payload + len, 0, - ATH6KL_FWLOG_SLOT_SIZE - slot_len); + __skb_queue_tail(&ar->debug.fwlog_queue, skb); - ath6kl_debug_fwlog_add(ar, slot, ATH6KL_FWLOG_SLOT_SIZE); + /* drop oldest entries */ + while (skb_queue_len(&ar->debug.fwlog_queue) > + ATH6KL_FWLOG_MAX_ENTRIES) { + skb = __skb_dequeue(&ar->debug.fwlog_queue); + kfree_skb(skb); + } - spin_unlock_bh(&ar->debug.fwlog_lock); -} + spin_unlock(&ar->debug.fwlog_queue.lock); -static bool ath6kl_debug_fwlog_empty(struct ath6kl *ar) -{ - return CIRC_CNT(ar->debug.fwlog_buf.head, - ar->debug.fwlog_buf.tail, - ATH6KL_FWLOG_SLOT_SIZE) == 0; + return; } static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; - struct circ_buf *fwlog = &ar->debug.fwlog_buf; - size_t len = 0, buf_len = count; + struct sk_buff *skb; ssize_t ret_cnt; + size_t len = 0; char *buf; - int ccnt; - buf = vmalloc(buf_len); + buf = vmalloc(count); if (!buf) return -ENOMEM; /* read undelivered logs from firmware */ ath6kl_read_fwlogs(ar); - spin_lock_bh(&ar->debug.fwlog_lock); + spin_lock(&ar->debug.fwlog_queue.lock); - while (len < buf_len && !ath6kl_debug_fwlog_empty(ar)) { - ccnt = CIRC_CNT_TO_END(fwlog->head, fwlog->tail, - ATH6KL_FWLOG_SIZE); + while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) { + if (skb->len > count - len) { + /* not enough space, put skb back and leave */ + __skb_queue_head(&ar->debug.fwlog_queue, skb); + break; + } - if ((size_t) ccnt > buf_len - len) - ccnt = buf_len - len; - memcpy(buf + len, &fwlog->buf[fwlog->tail], ccnt); - len += ccnt; + memcpy(buf + len, skb->data, skb->len); + len += skb->len; - fwlog->tail = (fwlog->tail + ccnt) & - (ATH6KL_FWLOG_SIZE - 1); + kfree_skb(skb); } - spin_unlock_bh(&ar->debug.fwlog_lock); + spin_unlock(&ar->debug.fwlog_queue.lock); - if (WARN_ON(len > buf_len)) - len = buf_len; + /* FIXME: what to do if len == 0? */ ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); @@ -1651,17 +1622,7 @@ static const struct file_operations fops_power_params = { int ath6kl_debug_init(struct ath6kl *ar) { - ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE); - if (ar->debug.fwlog_buf.buf == NULL) - return -ENOMEM; - - ar->debug.fwlog_tmp = kmalloc(ATH6KL_FWLOG_SLOT_SIZE, GFP_KERNEL); - if (ar->debug.fwlog_tmp == NULL) { - vfree(ar->debug.fwlog_buf.buf); - return -ENOMEM; - } - - spin_lock_init(&ar->debug.fwlog_lock); + skb_queue_head_init(&ar->debug.fwlog_queue); /* * Actually we are lying here but don't know how to read the mask @@ -1671,11 +1632,8 @@ int ath6kl_debug_init(struct ath6kl *ar) ar->debugfs_phy = debugfs_create_dir("ath6kl", ar->wiphy->debugfsdir); - if (!ar->debugfs_phy) { - vfree(ar->debug.fwlog_buf.buf); - kfree(ar->debug.fwlog_tmp); + if (!ar->debugfs_phy) return -ENOMEM; - } debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar, &fops_tgt_stats); @@ -1742,8 +1700,7 @@ int ath6kl_debug_init(struct ath6kl *ar) void ath6kl_debug_cleanup(struct ath6kl *ar) { - vfree(ar->debug.fwlog_buf.buf); - kfree(ar->debug.fwlog_tmp); + skb_queue_purge(&ar->debug.fwlog_queue); kfree(ar->debug.roam_tbl); } -- GitLab From c807b30d2588dd3c74db1f690a0e9e724dd332da Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 6 Feb 2012 08:23:40 +0200 Subject: [PATCH 0479/1846] ath6kl: add blocking debugfs file for retrieving firmware logs When debugging firmware issues it's not always enough to get the latest firmware logs, sometimes we need to get logs from a longer period. To make this possible, add a debugfs file named fwlog_block. When reading from this file ath6kl will send firmware logs whenever available and otherwise it will block and wait for new logs. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 3 + drivers/net/wireless/ath/ath6kl/debug.c | 104 +++++++++++++++++++++++- 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 9a58214135b9..4ff06a326785 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -653,6 +653,9 @@ struct ath6kl { #ifdef CONFIG_ATH6KL_DEBUG struct { struct sk_buff_head fwlog_queue; + struct completion fwlog_completion; + bool fwlog_open; + u32 fwlog_mask; unsigned int dbgfs_diag_reg; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 98b5f15f622e..ec32ff692163 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -290,6 +290,7 @@ void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len) spin_lock(&ar->debug.fwlog_queue.lock); __skb_queue_tail(&ar->debug.fwlog_queue, skb); + complete(&ar->debug.fwlog_completion); /* drop oldest entries */ while (skb_queue_len(&ar->debug.fwlog_queue) > @@ -303,6 +304,28 @@ void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len) return; } +static int ath6kl_fwlog_open(struct inode *inode, struct file *file) +{ + struct ath6kl *ar = inode->i_private; + + if (ar->debug.fwlog_open) + return -EBUSY; + + ar->debug.fwlog_open = true; + + file->private_data = inode->i_private; + return 0; +} + +static int ath6kl_fwlog_release(struct inode *inode, struct file *file) +{ + struct ath6kl *ar = inode->i_private; + + ar->debug.fwlog_open = false; + + return 0; +} + static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -347,12 +370,87 @@ static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf, } static const struct file_operations fops_fwlog = { - .open = ath6kl_debugfs_open, + .open = ath6kl_fwlog_open, + .release = ath6kl_fwlog_release, .read = ath6kl_fwlog_read, .owner = THIS_MODULE, .llseek = default_llseek, }; +static ssize_t ath6kl_fwlog_block_read(struct file *file, + char __user *user_buf, + size_t count, + loff_t *ppos) +{ + struct ath6kl *ar = file->private_data; + struct sk_buff *skb; + ssize_t ret_cnt; + size_t len = 0, not_copied; + char *buf; + int ret; + + buf = vmalloc(count); + if (!buf) + return -ENOMEM; + + spin_lock(&ar->debug.fwlog_queue.lock); + + if (skb_queue_len(&ar->debug.fwlog_queue) == 0) { + /* we must init under queue lock */ + init_completion(&ar->debug.fwlog_completion); + + spin_unlock(&ar->debug.fwlog_queue.lock); + + ret = wait_for_completion_interruptible( + &ar->debug.fwlog_completion); + if (ret == -ERESTARTSYS) + return ret; + + spin_lock(&ar->debug.fwlog_queue.lock); + } + + while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) { + if (skb->len > count - len) { + /* not enough space, put skb back and leave */ + __skb_queue_head(&ar->debug.fwlog_queue, skb); + break; + } + + + memcpy(buf + len, skb->data, skb->len); + len += skb->len; + + kfree_skb(skb); + } + + spin_unlock(&ar->debug.fwlog_queue.lock); + + /* FIXME: what to do if len == 0? */ + + not_copied = copy_to_user(user_buf, buf, len); + if (not_copied != 0) { + ret_cnt = -EFAULT; + goto out; + } + + *ppos = *ppos + len; + + ret_cnt = len; + +out: + vfree(buf); + + return ret_cnt; +} + +static const struct file_operations fops_fwlog_block = { + .open = ath6kl_fwlog_open, + .release = ath6kl_fwlog_release, + .read = ath6kl_fwlog_block_read, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1623,6 +1721,7 @@ static const struct file_operations fops_power_params = { int ath6kl_debug_init(struct ath6kl *ar) { skb_queue_head_init(&ar->debug.fwlog_queue); + init_completion(&ar->debug.fwlog_completion); /* * Actually we are lying here but don't know how to read the mask @@ -1647,6 +1746,9 @@ int ath6kl_debug_init(struct ath6kl *ar) debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar, &fops_fwlog); + debugfs_create_file("fwlog_block", S_IRUSR, ar->debugfs_phy, ar, + &fops_fwlog_block); + debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar, &fops_fwlog_mask); -- GitLab From 1b2df4073447234034e2329f0df584c6346a8ec3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 6 Feb 2012 20:15:53 +0530 Subject: [PATCH 0480/1846] ath6kl: Update license header Update license header with the copyright to Qualcomm Atheros, Inc. for the year 2011-2012. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/Makefile | 3 ++- drivers/net/wireless/ath/ath6kl/bmi.c | 1 + drivers/net/wireless/ath/ath6kl/bmi.h | 1 + drivers/net/wireless/ath/ath6kl/cfg80211.c | 1 + drivers/net/wireless/ath/ath6kl/cfg80211.h | 1 + drivers/net/wireless/ath/ath6kl/common.h | 1 + drivers/net/wireless/ath/ath6kl/core.c | 1 + drivers/net/wireless/ath/ath6kl/core.h | 1 + drivers/net/wireless/ath/ath6kl/debug.c | 1 + drivers/net/wireless/ath/ath6kl/debug.h | 1 + drivers/net/wireless/ath/ath6kl/hif-ops.h | 1 + drivers/net/wireless/ath/ath6kl/hif.c | 1 + drivers/net/wireless/ath/ath6kl/hif.h | 1 + drivers/net/wireless/ath/ath6kl/htc.c | 1 + drivers/net/wireless/ath/ath6kl/htc.h | 1 + drivers/net/wireless/ath/ath6kl/init.c | 1 + drivers/net/wireless/ath/ath6kl/main.c | 1 + drivers/net/wireless/ath/ath6kl/sdio.c | 1 + drivers/net/wireless/ath/ath6kl/target.h | 1 + drivers/net/wireless/ath/ath6kl/testmode.c | 1 + drivers/net/wireless/ath/ath6kl/testmode.h | 1 + drivers/net/wireless/ath/ath6kl/txrx.c | 1 + drivers/net/wireless/ath/ath6kl/usb.c | 1 + drivers/net/wireless/ath/ath6kl/wmi.c | 1 + drivers/net/wireless/ath/ath6kl/wmi.h | 1 + 25 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/Makefile b/drivers/net/wireless/ath/ath6kl/Makefile index 9ba42fa04962..85746c3eb027 100644 --- a/drivers/net/wireless/ath/ath6kl/Makefile +++ b/drivers/net/wireless/ath/ath6kl/Makefile @@ -1,5 +1,6 @@ #------------------------------------------------------------------------------ -# Copyright (c) 2004-2010 Atheros Communications Inc. +# Copyright (c) 2004-2011 Atheros Communications Inc. +# Copyright (c) 2011-2012 Qualcomm Atheros, Inc. # All rights reserved. # # diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index aef00d5a1438..05d1d8941fd1 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/bmi.h b/drivers/net/wireless/ath/ath6kl/bmi.h index f1ca6812456d..114f7b265a3a 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.h +++ b/drivers/net/wireless/ath/ath6kl/bmi.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d1922d8eb3bb..a91f521c5227 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.h b/drivers/net/wireless/ath/ath6kl/cfg80211.h index 3c693b7c0efd..c5def436417f 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.h +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/common.h b/drivers/net/wireless/ath/ath6kl/common.h index f89f1e180da3..a60e78c0472f 100644 --- a/drivers/net/wireless/ath/ath6kl/common.h +++ b/drivers/net/wireless/ath/ath6kl/common.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 722ca59b88ce..c4926cf11213 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 4ff06a326785..ec7d6b67b7ff 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index ec32ff692163..3d0713dfe3b9 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index c4be6e50996b..c5d5e6c8259e 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h index 2fe1dadfc77a..fd84086638e3 100644 --- a/drivers/net/wireless/ath/ath6kl/hif-ops.h +++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index e911737ab345..18c7f6453313 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2007-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 699a036f3a44..fb4186f5d432 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 2d721903640b..1385f719ad07 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2007-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 57672e1ed1a6..84a2ab52aa68 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 0d76c3778106..6183d5794929 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index b96d01a7919b..d463a18332dc 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 4febee723495..2826613b1933 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/target.h b/drivers/net/wireless/ath/ath6kl/target.h index 108a723a1085..ac27962f8fc1 100644 --- a/drivers/net/wireless/ath/ath6kl/target.h +++ b/drivers/net/wireless/ath/ath6kl/target.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2010 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/testmode.c b/drivers/net/wireless/ath/ath6kl/testmode.c index f0cd61d6188a..6675c92b542b 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.c +++ b/drivers/net/wireless/ath/ath6kl/testmode.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/testmode.h b/drivers/net/wireless/ath/ath6kl/testmode.h index 7fd47a62d078..fe651d6707df 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.h +++ b/drivers/net/wireless/ath/ath6kl/testmode.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Atheros Communications Inc. + * Copyright (c) 2011 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index a3dc6943c7f7..87d46460a524 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c index c72567c6d338..325b1224c2b1 100644 --- a/drivers/net/wireless/ath/ath6kl/usb.c +++ b/drivers/net/wireless/ath/ath6kl/usb.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2007-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 18fa9aa8af92..bbbe0a74d3c3 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2004-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index e7919869725e..e7d031b8451d 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012 Qualcomm Atheros, 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 -- GitLab From b29072cc7b0e08ace48ab709c40cf6246fb2e8b0 Mon Sep 17 00:00:00 2001 From: Chilam Ng Date: Tue, 7 Feb 2012 01:33:00 -0800 Subject: [PATCH 0481/1846] ath6kl: prioritize Tx bundling based on AC priorities Tx bundling is the more efficient use of SDIO bus and allows more packet transfers with fewer bus transactions, and is a way to improve overall throughput. However, Tx bundling has only 4 scatter request resources available. When there are multiple traffic streams of different priorities, it's possible that lower priority traffic may hog all the scatter requests and lock out the higher prioirty traffic from bundling. Tx bundling is now enabled per AC. When an AC do a scatter request and the remaining scatter request resources is lower than a configurable threshold, it will disable Tx bundling for all AC's of lower priorities. When an AC has Tx bundling disabled and has no Tx bundles sent in a consecutive and configurable number of packets, Tx bundling will be re-enabled for that AC. Signed-off-by: Chilam Ng Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/hif.h | 2 + drivers/net/wireless/ath/ath6kl/htc.c | 77 +++++++++++++++++++++++--- drivers/net/wireless/ath/ath6kl/htc.h | 7 ++- drivers/net/wireless/ath/ath6kl/sdio.c | 2 + 4 files changed, 80 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index fb4186f5d432..904458ab484b 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -198,6 +198,8 @@ struct hif_scatter_req { u8 *virt_dma_buf; struct hif_scatter_item scat_list[1]; + + u32 scat_q_depth; }; struct ath6kl_irq_proc_registers { diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 1385f719ad07..c703ef9c5313 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -23,6 +23,9 @@ #define CALC_TXRX_PADDED_LEN(dev, len) (__ALIGN_MASK((len), (dev)->block_mask)) +/* threshold to re-enable Tx bundling for an AC*/ +#define TX_RESUME_BUNDLE_THRESHOLD 1500 + /* Functions for Tx credit handling */ static void ath6kl_credit_deposit(struct ath6kl_htc_credit_info *cred_info, struct htc_endpoint_credit_dist *ep_dist, @@ -745,6 +748,12 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, struct hif_scatter_req *scat_req = NULL; int n_scat, n_sent_bundle = 0, tot_pkts_bundle = 0; int status; + u32 txb_mask; + u8 ac = WMM_NUM_AC; + + if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) || + (WMI_CONTROL_SVC != endpoint->svc_id)) + ac = target->dev->ar->ep2ac_map[endpoint->eid]; while (true) { status = 0; @@ -764,6 +773,31 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, break; } + if ((ac < WMM_NUM_AC) && (ac != WMM_AC_BK)) { + if (WMM_AC_BE == ac) + /* + * BE, BK have priorities and bit + * positions reversed + */ + txb_mask = (1 << WMM_AC_BK); + else + /* + * any AC with priority lower than + * itself + */ + txb_mask = ((1 << ac) - 1); + /* + * when the scatter request resources drop below a + * certain threshold, disable Tx bundling for all + * AC's with priority lower than the current requesting + * AC. Otherwise re-enable Tx bundling for them + */ + if (scat_req->scat_q_depth < ATH6KL_SCATTER_REQS) + target->tx_bndl_mask &= ~txb_mask; + else + target->tx_bndl_mask |= txb_mask; + } + ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx pkts to scatter: %d\n", n_scat); @@ -807,6 +841,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, struct htc_packet *packet; int bundle_sent; int n_pkts_bundle; + u8 ac = WMM_NUM_AC; spin_lock_bh(&target->tx_lock); @@ -824,6 +859,10 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, */ INIT_LIST_HEAD(&txq); + if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) || + (WMI_CONTROL_SVC != endpoint->svc_id)) + ac = target->dev->ar->ep2ac_map[endpoint->eid]; + while (true) { if (list_empty(&endpoint->txq)) @@ -841,15 +880,18 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, while (true) { /* try to send a bundle on each pass */ - if ((target->tx_bndl_enable) && + if ((target->tx_bndl_mask) && (get_queue_depth(&txq) >= HTC_MIN_HTC_MSGS_TO_BUNDLE)) { int temp1 = 0, temp2 = 0; - ath6kl_htc_tx_bundle(endpoint, &txq, - &temp1, &temp2); - bundle_sent += temp1; - n_pkts_bundle += temp2; + /* check if bundling is enabled for an AC */ + if (target->tx_bndl_mask & (1 << ac)) { + ath6kl_htc_tx_bundle(endpoint, &txq, + &temp1, &temp2); + bundle_sent += temp1; + n_pkts_bundle += temp2; + } } if (list_empty(&txq)) @@ -868,6 +910,26 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, endpoint->ep_st.tx_bundles += bundle_sent; endpoint->ep_st.tx_pkt_bundled += n_pkts_bundle; + + /* + * if an AC has bundling disabled and no tx bundling + * has occured continously for a certain number of TX, + * enable tx bundling for this AC + */ + if (!bundle_sent) { + if (!(target->tx_bndl_mask & (1 << ac)) && + (ac < WMM_NUM_AC)) { + if (++target->ac_tx_count[ac] >= + TX_RESUME_BUNDLE_THRESHOLD) { + target->ac_tx_count[ac] = 0; + target->tx_bndl_mask |= (1 << ac); + } + } + } else { + /* tx bundling will reset the counter */ + if (ac < WMM_NUM_AC) + target->ac_tx_count[ac] = 0; + } } endpoint->tx_proc_cnt = 0; @@ -2518,7 +2580,8 @@ static void htc_setup_msg_bndl(struct htc_target *target) target->max_rx_bndl_sz, target->max_tx_bndl_sz); if (target->max_tx_bndl_sz) - target->tx_bndl_enable = true; + /* tx_bndl_mask is enabled per AC, each has 1 bit */ + target->tx_bndl_mask = (1 << WMM_NUM_AC) - 1; if (target->max_rx_bndl_sz) target->rx_bndl_enable = true; @@ -2533,7 +2596,7 @@ static void htc_setup_msg_bndl(struct htc_target *target) * padding will spill into the next credit buffer * which is fatal. */ - target->tx_bndl_enable = false; + target->tx_bndl_mask = 0; } } diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 84a2ab52aa68..519766571334 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -88,6 +88,8 @@ #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4) #define WMI_MAX_SERVICES 5 +#define WMM_NUM_AC 4 + /* reserved and used to flush ALL packets */ #define HTC_TX_PACKET_TAG_ALL 0 #define HTC_SERVICE_TX_PACKET_TAG 1 @@ -532,7 +534,7 @@ struct htc_target { /* max messages per bundle for HTC */ int msg_per_bndl_max; - bool tx_bndl_enable; + u32 tx_bndl_mask; int rx_bndl_enable; int max_rx_bndl_sz; int max_tx_bndl_sz; @@ -544,6 +546,9 @@ struct htc_target { int max_xfer_szper_scatreq; int chk_irq_status_cnt; + + /* counts the number of Tx without bundling continously per AC */ + u32 ac_tx_count[WMM_NUM_AC]; }; void *ath6kl_htc_create(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 2826613b1933..cae446bf2129 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -602,6 +602,8 @@ static struct hif_scatter_req *ath6kl_sdio_scatter_req_get(struct ath6kl *ar) node = list_first_entry(&ar_sdio->scat_req, struct hif_scatter_req, list); list_del(&node->list); + + node->scat_q_depth = get_queue_depth(&ar_sdio->scat_req); } spin_unlock_bh(&ar_sdio->scat_lock); -- GitLab From fb1ac2efa323de21bc83c1b3d326d06f8251ea4f Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Date: Tue, 7 Feb 2012 14:58:54 -0800 Subject: [PATCH 0482/1846] ath6kl: add support for AR6003 2048 byte board file AR6003 2.1.1 supports both 1792 and 2048 byte board files. Add support for 2048 byte board file. kvalo: add ath6kl prefix to the title Signed-off-by: Prasanna Kumar Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 2 ++ drivers/net/wireless/ath/ath6kl/target.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 6183d5794929..72f1b4f52b2e 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1124,6 +1124,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) case TARGET_TYPE_AR6003: board_data_size = AR6003_BOARD_DATA_SZ; board_ext_data_size = AR6003_BOARD_EXT_DATA_SZ; + if (ar->fw_board_len > (board_data_size + board_ext_data_size)) + board_ext_data_size = AR6003_BOARD_EXT_DATA_SZ_V2; break; case TARGET_TYPE_AR6004: board_data_size = AR6004_BOARD_DATA_SZ; diff --git a/drivers/net/wireless/ath/ath6kl/target.h b/drivers/net/wireless/ath/ath6kl/target.h index ac27962f8fc1..78e0ef4567a5 100644 --- a/drivers/net/wireless/ath/ath6kl/target.h +++ b/drivers/net/wireless/ath/ath6kl/target.h @@ -20,6 +20,7 @@ #define AR6003_BOARD_DATA_SZ 1024 #define AR6003_BOARD_EXT_DATA_SZ 768 +#define AR6003_BOARD_EXT_DATA_SZ_V2 1024 #define AR6004_BOARD_DATA_SZ 6144 #define AR6004_BOARD_EXT_DATA_SZ 0 -- GitLab From 3b96d49a79021ce4c1ca26aecd784d16aeb91a7c Mon Sep 17 00:00:00 2001 From: Naveen Gangadharan Date: Tue, 7 Feb 2012 22:53:32 -0800 Subject: [PATCH 0483/1846] ath6kl: Fix firmware crash dump The firmware crash dump printout was wrong as it was using incorrect offsets. kvalo: improve commit log, change the "%d:" to print word indexes, not bytes Signed-off-by: Naveen Gangadharan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/hif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 18c7f6453313..ef650b61740a 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -107,9 +107,9 @@ static void ath6kl_hif_dump_fw_crash(struct ath6kl *ar) BUILD_BUG_ON(REG_DUMP_COUNT_AR6003 % 4); - for (i = 0; i < REG_DUMP_COUNT_AR6003 / 4; i++) { + for (i = 0; i < REG_DUMP_COUNT_AR6003; i += 4) { ath6kl_info("%d: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x\n", - 4 * i, + i, le32_to_cpu(regdump_val[i]), le32_to_cpu(regdump_val[i + 1]), le32_to_cpu(regdump_val[i + 2]), -- GitLab From 31a4c8b82788fa369c709bb3366c8b90c77c0dee Mon Sep 17 00:00:00 2001 From: "Pradeep A. Dalvi" Date: Wed, 8 Feb 2012 00:03:15 +0000 Subject: [PATCH 0484/1846] mace: Fix build for mace due to netdev_alloc_skb Refs: 1. pmac32_defconfig http://kisskb.ellerman.id.au/kisskb/buildresult/5583746/ 2. ppc6xx_defconfig http://kisskb.ellerman.id.au/kisskb/buildresult/5584116/ Confirmed any such occurances from all failed defconfigs & in net-next sources with grep -nrs "netdev_alloc_skb" drivers/net/ethernet/ | grep -v "," Reported-by: Geert Uytterhoeven Signed-off-by: Pradeep A Dalvi Signed-off-by: David S. Miller --- drivers/net/ethernet/apple/mace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/apple/mace.c b/drivers/net/ethernet/apple/mace.c index 06998462e0d3..e1df4b76c885 100644 --- a/drivers/net/ethernet/apple/mace.c +++ b/drivers/net/ethernet/apple/mace.c @@ -956,7 +956,7 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id) cp = mp->rx_cmds + i; skb = mp->rx_bufs[i]; if (!skb) { - skb = netdev_alloc_skb(RX_BUFLEN + 2); + skb = netdev_alloc_skb(dev, RX_BUFLEN + 2); if (skb) { skb_reserve(skb, 2); mp->rx_bufs[i] = skb; -- GitLab From 234f6e5c05277c0198797553434e2ed5acac18cc Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 6 Feb 2012 14:07:24 +1100 Subject: [PATCH 0485/1846] orinoco: Remove old mailing lists from MAINTAINERS The two orinoco mailing lists on sourceforge were set up many years ago and are now more or less moribund. I'd like to shut them down, so I don't have to keep filtering the spam from them (which is most of what comes through now). In preparation, this patch removes the reference to them from the MAINTAINERS file. Any remaining discussion of this approaching obsolete driver can go to the linux-wireless list. Signed-off-by: David Gibson Acked-by: Pavel Roskin Signed-off-by: John W. Linville --- MAINTAINERS | 2 -- 1 file changed, 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 1adb206dfcac..bcb668c0af71 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4894,8 +4894,6 @@ F: fs/ocfs2/ ORINOCO DRIVER L: linux-wireless@vger.kernel.org -L: orinoco-users@lists.sourceforge.net -L: orinoco-devel@lists.sourceforge.net W: http://linuxwireless.org/en/users/Drivers/orinoco W: http://www.nongnu.org/orinoco/ S: Orphan -- GitLab From 1ebbc48520a0853cd4d812d8342f9886b2b07b92 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:06 +0100 Subject: [PATCH 0486/1846] rt2x00: Introduce concept of driver data in struct rt2x00_dev. We are getting more and more fields in struct rt2x00_dev that are specific to one or two of the low-level drivers. Instead of putting these fields inside the main structure and thus clobbering all low-level drivers with these fields, introduce the concept of driver data inside struct rt2x00_dev, whose size is indicated by the low-level driver and which can be populated by the low-level driver. Signed-off-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2x00.h | 6 ++++++ drivers/net/wireless/rt2x00/rt2x00dev.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index b03b22c47b18..b4260bfb6cb4 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -647,6 +647,7 @@ struct rt2x00lib_ops { */ struct rt2x00_ops { const char *name; + const unsigned int drv_data_size; const unsigned int max_sta_intf; const unsigned int max_ap_intf; const unsigned int eeprom_size; @@ -741,6 +742,11 @@ struct rt2x00_dev { */ const struct rt2x00_ops *ops; + /* + * Driver data. + */ + void *drv_data; + /* * IEEE80211 control structure. */ diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index c3e1aa7c1a80..bae5b01299ea 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -1121,6 +1121,18 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) { int retval = -ENOMEM; + /* + * Allocate the driver data memory, if necessary. + */ + if (rt2x00dev->ops->drv_data_size > 0) { + rt2x00dev->drv_data = kzalloc(rt2x00dev->ops->drv_data_size, + GFP_KERNEL); + if (!rt2x00dev->drv_data) { + retval = -ENOMEM; + goto exit; + } + } + spin_lock_init(&rt2x00dev->irqmask_lock); mutex_init(&rt2x00dev->csr_mutex); @@ -1261,6 +1273,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) * Free queue structures. */ rt2x00queue_free(rt2x00dev); + + /* + * Free the driver data. + */ + if (rt2x00dev->drv_data) + kfree(rt2x00dev->drv_data); } EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); -- GitLab From 3a1c01288e5596fb70ca48ec9d9d8b561121c544 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:07 +0100 Subject: [PATCH 0487/1846] rt2x00: Use struct rt2x00_dev driver data in rt2800{pci,usb}. Start using the struct rt2x00_dev driver data in rt2800 for the calibration data. Signed-off-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 8 +++++++ drivers/net/wireless/rt2x00/rt2800lib.c | 31 +++++++++++++++++-------- drivers/net/wireless/rt2x00/rt2800pci.c | 1 + drivers/net/wireless/rt2x00/rt2800usb.c | 1 + drivers/net/wireless/rt2x00/rt2x00.h | 7 ------ 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index fac9ece22b23..7c05dee57876 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -2438,4 +2438,12 @@ struct mac_iveiv_entry { */ #define EIRP_MAX_TX_POWER_LIMIT 0x50 +/* + * RT2800 driver data structure + */ +struct rt2800_drv_data { + u8 calibration_bw20; + u8 calibration_bw40; +}; + #endif /* RT2800_H */ diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index c326e7b1c374..131139ed4b17 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1645,6 +1645,7 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, struct rf_channel *rf, struct channel_info *info) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u8 rfcsr, calib_tx, calib_rx; rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); @@ -1714,8 +1715,13 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, calib_tx = conf_is_ht40(conf) ? 0x68 : 0x4f; calib_rx = conf_is_ht40(conf) ? 0x6f : 0x4f; } else { - calib_tx = rt2x00dev->calibration[conf_is_ht40(conf)]; - calib_rx = rt2x00dev->calibration[conf_is_ht40(conf)]; + if (conf_is_ht40(conf)) { + calib_tx = drv_data->calibration_bw40; + calib_rx = drv_data->calibration_bw40; + } else { + calib_tx = drv_data->calibration_bw20; + calib_rx = drv_data->calibration_bw20; + } } rt2800_rfcsr_read(rt2x00dev, 24, &rfcsr); @@ -1743,6 +1749,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, struct rf_channel *rf, struct channel_info *info) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u8 rfcsr; u32 reg; @@ -1836,10 +1843,13 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); - rt2800_rfcsr_write(rt2x00dev, 24, - rt2x00dev->calibration[conf_is_ht40(conf)]); - rt2800_rfcsr_write(rt2x00dev, 31, - rt2x00dev->calibration[conf_is_ht40(conf)]); + if (conf_is_ht40(conf)) { + rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw40); + rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw40); + } else { + rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw20); + rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw20); + } if (rf->channel <= 14) { rt2800_rfcsr_write(rt2x00dev, 7, 0xd8); @@ -3310,6 +3320,7 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev, static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u8 rfcsr; u8 bbp; u32 reg; @@ -3598,17 +3609,17 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) * Set RX Filter calibration for 20MHz and 40MHz */ if (rt2x00_rt(rt2x00dev, RT3070)) { - rt2x00dev->calibration[0] = + drv_data->calibration_bw20 = rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x16); - rt2x00dev->calibration[1] = + drv_data->calibration_bw40 = rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x19); } else if (rt2x00_rt(rt2x00dev, RT3071) || rt2x00_rt(rt2x00dev, RT3090) || rt2x00_rt(rt2x00dev, RT3390) || rt2x00_rt(rt2x00dev, RT3572)) { - rt2x00dev->calibration[0] = + drv_data->calibration_bw20 = rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x13); - rt2x00dev->calibration[1] = + drv_data->calibration_bw40 = rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x15); } diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 4e985026985c..6ad692914ee9 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -1093,6 +1093,7 @@ static const struct data_queue_desc rt2800pci_queue_bcn = { static const struct rt2x00_ops rt2800pci_ops = { .name = KBUILD_MODNAME, + .drv_data_size = sizeof(struct rt2800_drv_data), .max_sta_intf = 1, .max_ap_intf = 8, .eeprom_size = EEPROM_SIZE, diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index f0074bcee7c9..d009b6b794bb 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -827,6 +827,7 @@ static const struct data_queue_desc rt2800usb_queue_bcn = { static const struct rt2x00_ops rt2800usb_ops = { .name = KBUILD_MODNAME, + .drv_data_size = sizeof(struct rt2800_drv_data), .max_sta_intf = 1, .max_ap_intf = 8, .eeprom_size = EEPROM_SIZE, diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index b4260bfb6cb4..5bd2f225ce48 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -896,13 +896,6 @@ struct rt2x00_dev { */ u8 freq_offset; - /* - * Calibration information (for rt2800usb & rt2800pci). - * [0] -> BW20 - * [1] -> BW40 - */ - u8 calibration[2]; - /* * Association id. */ -- GitLab From bef453dc9cf1999348e568068f256b1c439d1152 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:08 +0100 Subject: [PATCH 0488/1846] rt2x00: Update comment on freq_offset field in struct rt2x00_dev. The comment states that the field is only used for rt61pci and rt73usb. However, it is now used by rt2800pci and rt2800usb as well, so the comment is not correct anymore. Update the comment to not state any low-level drivers anymore. Signed-off-by: Gertjan van Wingerde Acked-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2x00.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 5bd2f225ce48..ed2ae6efcaa3 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -892,7 +892,7 @@ struct rt2x00_dev { u8 rssi_offset; /* - * Frequency offset (for rt61pci & rt73usb). + * Frequency offset. */ u8 freq_offset; -- GitLab From 5d137dff36dce1eda0617a00eb87b57e48300045 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:09 +0100 Subject: [PATCH 0489/1846] rt2x00: Use saved BBP 25 and 26 values when configuring channel on RT3572. This brings the rt2800 channel switching code for RT3572 closer to the v2.5.0.0 Ralink RT3572 driver. Signed-off-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 2 ++ drivers/net/wireless/rt2x00/rt2800lib.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index 7c05dee57876..8aabd0dc02c3 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -2444,6 +2444,8 @@ struct mac_iveiv_entry { struct rt2800_drv_data { u8 calibration_bw20; u8 calibration_bw40; + u8 bbp25; + u8 bbp26; }; #endif /* RT2800_H */ diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 131139ed4b17..3873a1555871 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1754,8 +1754,8 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, u32 reg; if (rf->channel <= 14) { - rt2800_bbp_write(rt2x00dev, 25, 0x15); - rt2800_bbp_write(rt2x00dev, 26, 0x85); + rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); + rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); } else { rt2800_bbp_write(rt2x00dev, 25, 0x09); rt2800_bbp_write(rt2x00dev, 26, 0xff); @@ -3623,6 +3623,12 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x15); } + /* + * Save BBP 25 & 26 values for later use in channel switching + */ + rt2800_bbp_read(rt2x00dev, 25, &drv_data->bbp25); + rt2800_bbp_read(rt2x00dev, 26, &drv_data->bbp26); + if (!rt2x00_rt(rt2x00dev, RT5390)) { /* * Set back to initial state -- GitLab From 569ffa56344e7e2a1d635a9c620215196f5c7298 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:10 +0100 Subject: [PATCH 0490/1846] rt2x00: Fix RFCSR 12 & 13 programming on RT3572 channel switching. Align with v2.5.0.0 Ralink RT3572 driver for 2.4GHz band channel switch. Signed-off-by: Gertjan van Wingerde Acked-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 3873a1555871..80a2087fcf8c 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1783,8 +1783,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, if (rf->channel <= 14) { rt2x00_set_field8(&rfcsr, RFCSR12_DR0, 3); rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, - (info->default_power1 & 0x3) | - ((info->default_power1 & 0xC) << 1)); + info->default_power1); } else { rt2x00_set_field8(&rfcsr, RFCSR12_DR0, 7); rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, @@ -1797,8 +1796,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, if (rf->channel <= 14) { rt2x00_set_field8(&rfcsr, RFCSR13_DR0, 3); rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, - (info->default_power2 & 0x3) | - ((info->default_power2 & 0xC) << 1)); + info->default_power2); } else { rt2x00_set_field8(&rfcsr, RFCSR13_DR0, 7); rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, -- GitLab From 0cd461efcc1df6763b86b29ef4d6ee1cb923aa47 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:11 +0100 Subject: [PATCH 0491/1846] rt2x00: Align RT3572 channel switch RFCSR 1 programming with Ralink driver. Align with the v2.5.0.0 Ralink RT3572 driver. Signed-off-by: Gertjan van Wingerde Acked-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 80a2087fcf8c..135e8a40edd3 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1806,11 +1806,12 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 13, rfcsr); rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr); - rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0); rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0); if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags)) { if (rf->channel <= 14) { rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1); -- GitLab From 58b8ae14d58319bff63a30a9e1c0ebb9c07f2243 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:12 +0100 Subject: [PATCH 0492/1846] rt2x00: Fix RT3572 channel switch RFCSR 7 programming. Align with the v2.5.0.0 Ralink RT3572 driver. Signed-off-by: Gertjan van Wingerde Acked-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 10 ++++++---- drivers/net/wireless/rt2x00/rt2800lib.c | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index 8aabd0dc02c3..c6648b02bf81 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -1819,10 +1819,12 @@ struct mac_iveiv_entry { * RFCSR 7: */ #define RFCSR7_RF_TUNING FIELD8(0x01) -#define RFCSR7_R02 FIELD8(0x07) -#define RFCSR7_R3 FIELD8(0x08) -#define RFCSR7_R45 FIELD8(0x30) -#define RFCSR7_R67 FIELD8(0xc0) +#define RFCSR7_BIT1 FIELD8(0x02) +#define RFCSR7_BIT2 FIELD8(0x04) +#define RFCSR7_BIT3 FIELD8(0x08) +#define RFCSR7_BIT4 FIELD8(0x10) +#define RFCSR7_BIT5 FIELD8(0x20) +#define RFCSR7_BITS67 FIELD8(0xc0) /* * RFCSR 11: diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 135e8a40edd3..395453c41e23 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1865,7 +1865,12 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 27, 0x00); rt2800_rfcsr_write(rt2x00dev, 29, 0x9b); } else { - rt2800_rfcsr_write(rt2x00dev, 7, 0x14); + rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR7_BIT2, 1); + rt2x00_set_field8(&rfcsr, RFCSR7_BIT3, 0); + rt2x00_set_field8(&rfcsr, RFCSR7_BIT4, 1); + rt2x00_set_field8(&rfcsr, RFCSR7_BITS67, 0); + rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); rt2800_rfcsr_write(rt2x00dev, 9, 0xc0); rt2800_rfcsr_write(rt2x00dev, 10, 0xf1); rt2800_rfcsr_write(rt2x00dev, 11, 0x00); -- GitLab From 77c06c2cb44fe68295efdd33939153c7d56de004 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Mon, 6 Feb 2012 23:45:13 +0100 Subject: [PATCH 0493/1846] rt2x00: Correctly set txmixer_gain in RT3572 channel switching. Align with the v2.5.0.0 Ralink RT3572 driver. Save the EEPROM txmixer_gain values inside the rt2800 driver data structure and use it throughout the code. Signed-off-by: Gertjan van Wingerde Acked-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 13 ++++++++++ drivers/net/wireless/rt2x00/rt2800lib.c | 34 ++++++++++++++++++++----- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index c6648b02bf81..06acabd02984 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -1848,6 +1848,11 @@ struct mac_iveiv_entry { */ #define RFCSR15_TX_LO2_EN FIELD8(0x08) +/* + * RFCSR 16: + */ +#define RFCSR16_TXMIXER_GAIN FIELD8(0x07) + /* * RFCSR 17: */ @@ -2110,6 +2115,12 @@ struct mac_iveiv_entry { #define EEPROM_RSSI_A2_OFFSET2 FIELD16(0x00ff) #define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00) +/* + * EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2). + */ +#define EEPROM_TXMIXER_GAIN_A 0x0026 +#define EEPROM_TXMIXER_GAIN_A_VAL FIELD16(0x0007) + /* * EEPROM EIRP Maximum TX power values(unit: dbm) */ @@ -2448,6 +2459,8 @@ struct rt2800_drv_data { u8 calibration_bw40; u8 bbp25; u8 bbp26; + u8 txmixer_gain_24g; + u8 txmixer_gain_5g; }; #endif /* RT2800_H */ diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 395453c41e23..52728be65271 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1856,7 +1856,10 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 10, 0xf1); rt2800_rfcsr_write(rt2x00dev, 11, 0xb9); rt2800_rfcsr_write(rt2x00dev, 15, 0x53); - rt2800_rfcsr_write(rt2x00dev, 16, 0x4c); + rfcsr = 0x4c; + rt2x00_set_field8(&rfcsr, RFCSR16_TXMIXER_GAIN, + drv_data->txmixer_gain_24g); + rt2800_rfcsr_write(rt2x00dev, 16, rfcsr); rt2800_rfcsr_write(rt2x00dev, 17, 0x23); rt2800_rfcsr_write(rt2x00dev, 19, 0x93); rt2800_rfcsr_write(rt2x00dev, 20, 0xb3); @@ -1875,7 +1878,10 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 10, 0xf1); rt2800_rfcsr_write(rt2x00dev, 11, 0x00); rt2800_rfcsr_write(rt2x00dev, 15, 0x43); - rt2800_rfcsr_write(rt2x00dev, 16, 0x7a); + rfcsr = 0x7a; + rt2x00_set_field8(&rfcsr, RFCSR16_TXMIXER_GAIN, + drv_data->txmixer_gain_5g); + rt2800_rfcsr_write(rt2x00dev, 16, rfcsr); rt2800_rfcsr_write(rt2x00dev, 17, 0x23); if (rf->channel <= 64) { rt2800_rfcsr_write(rt2x00dev, 19, 0xb7); @@ -3672,11 +3678,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) &rt2x00dev->cap_flags)) rt2x00_set_field8(&rfcsr, RFCSR17_R, 1); } - rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom); - if (rt2x00_get_field16(eeprom, EEPROM_TXMIXER_GAIN_BG_VAL) >= 1) - rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN, - rt2x00_get_field16(eeprom, - EEPROM_TXMIXER_GAIN_BG_VAL)); + rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN, + drv_data->txmixer_gain_24g); rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); } @@ -3884,6 +3887,7 @@ EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u16 word; u8 *mac; u8 default_lna_gain; @@ -3967,6 +3971,14 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); + rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word); + if ((word & 0x00ff) != 0x00ff) { + drv_data->txmixer_gain_24g = + rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL); + } else { + drv_data->txmixer_gain_24g = 0; + } + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); @@ -3976,6 +3988,14 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) default_lna_gain); rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); + rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word); + if ((word & 0x00ff) != 0x00ff) { + drv_data->txmixer_gain_5g = + rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL); + } else { + drv_data->txmixer_gain_5g = 0; + } + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0); -- GitLab From 79027596ff710f9662ccae5f5e85de43961420ed Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 7 Feb 2012 12:45:44 +0100 Subject: [PATCH 0494/1846] mac80211: add #ifdef CONFIG_MAC80211_VERBOSE_DEBUG for a debug printk When not debugging mac80211 code, station state transitions do not need to show up in the kernel log. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- net/mac80211/sta_info.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 31cd6d92531c..4034ee616022 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -1379,8 +1379,10 @@ int sta_info_move_state(struct sta_info *sta, return -EINVAL; } +#ifdef CONFIG_MAC80211_VERBOSE_DEBUG printk(KERN_DEBUG "%s: moving STA %pM to state %d\n", sta->sdata->name, sta->sta.addr, new_state); +#endif /* * notify the driver before the actual changes so it can -- GitLab From 7f66c2f93e5779625c10d262c84537427a2673ca Mon Sep 17 00:00:00 2001 From: Simon Graham Date: Tue, 7 Feb 2012 18:07:38 -0600 Subject: [PATCH 0495/1846] rtlwifi: Handle previous allocation failures when freeing device memory Handle previous allocation failures when freeing device memory Signed-off-by: Simon Graham Signed-off-by: Larry Finger Cc: Stable Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index c5f6a322feb2..c503bd3b809e 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1148,10 +1148,12 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw, ring->idx = (ring->idx + 1) % ring->entries; } - pci_free_consistent(rtlpci->pdev, - sizeof(*ring->desc) * ring->entries, - ring->desc, ring->dma); - ring->desc = NULL; + if (ring->desc) { + pci_free_consistent(rtlpci->pdev, + sizeof(*ring->desc) * ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; + } } static void _rtl_pci_free_rx_ring(struct rtl_pci *rtlpci) @@ -1175,12 +1177,14 @@ static void _rtl_pci_free_rx_ring(struct rtl_pci *rtlpci) kfree_skb(skb); } - pci_free_consistent(rtlpci->pdev, + if (rtlpci->rx_ring[rx_queue_idx].desc) { + pci_free_consistent(rtlpci->pdev, sizeof(*rtlpci->rx_ring[rx_queue_idx]. desc) * rtlpci->rxringcount, rtlpci->rx_ring[rx_queue_idx].desc, rtlpci->rx_ring[rx_queue_idx].dma); - rtlpci->rx_ring[rx_queue_idx].desc = NULL; + rtlpci->rx_ring[rx_queue_idx].desc = NULL; + } } } -- GitLab From 5ad20dd1480dc557afcec19ac7fae5581264dd59 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Feb 2012 21:09:25 -0800 Subject: [PATCH 0496/1846] mac80211: rename mesh static path_lookup() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you want to use mesh support from mac80211 on a recent kernel on 2.6.24 you'll run into a name clash when compiling against include/linux/namei.h, so rename this routine. /home/mcgrof/tmp/compat-wireless-3.2.5-1/net/mac80211/mesh_pathtbl.c: At top level: /home/mcgrof/tmp/compat-wireless-3.2.5-1/net/mac80211/mesh_pathtbl.c:342:26: error: conflicting types for ‘path_lookup’ include/linux/namei.h:71:12: note: previous declaration of ‘path_lookup’ was here Although this could sit as a separate patch in compat-wireless it seems best to just merge upstream. Cc: Javier Cardona Signed-off-by: Luis R. Rodriguez Acked-by: Javier Cardona Signed-off-by: John W. Linville --- net/mac80211/mesh_pathtbl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index edf167e3b8f3..dc51669e67d8 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -336,7 +336,7 @@ static void mesh_path_move_to_queue(struct mesh_path *gate_mpath, } -static struct mesh_path *path_lookup(struct mesh_table *tbl, u8 *dst, +static struct mesh_path *mpath_lookup(struct mesh_table *tbl, u8 *dst, struct ieee80211_sub_if_data *sdata) { struct mesh_path *mpath; @@ -371,12 +371,12 @@ static struct mesh_path *path_lookup(struct mesh_table *tbl, u8 *dst, */ struct mesh_path *mesh_path_lookup(u8 *dst, struct ieee80211_sub_if_data *sdata) { - return path_lookup(rcu_dereference(mesh_paths), dst, sdata); + return mpath_lookup(rcu_dereference(mesh_paths), dst, sdata); } struct mesh_path *mpp_path_lookup(u8 *dst, struct ieee80211_sub_if_data *sdata) { - return path_lookup(rcu_dereference(mpp_paths), dst, sdata); + return mpath_lookup(rcu_dereference(mpp_paths), dst, sdata); } -- GitLab From 8c1a7f5283e72306d1d23524f051501ffa1baf57 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 8 Feb 2012 02:08:21 +0000 Subject: [PATCH 0497/1846] stmmac: Fix typo in stmmac_pci.c Correct spelling "regiser" to "register" in drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index c796de9eed72..6ce0706b2d1b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -85,7 +85,7 @@ static int __devinit stmmac_pci_probe(struct pci_dev *pdev, continue; addr = pci_iomap(pdev, i, 0); if (addr == NULL) { - pr_err("%s: ERROR: cannot map regiser memory, aborting", + pr_err("%s: ERROR: cannot map register memory, aborting", __func__); ret = -EIO; goto err_out_map_failed; -- GitLab From 377cb4f9e763465984b9bb5187747fd9b02a14c0 Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Tue, 7 Feb 2012 14:51:21 +0000 Subject: [PATCH 0498/1846] IPoIB: Stop lying about hard_header_len and use skb->cb to stash LL addresses Commit a0417fa3a18a ("net: Make qdisc_skb_cb upper size bound explicit.") made it possible for a netdev driver to use skb->cb between its header_ops.create method and its .ndo_start_xmit method. Use this in ipoib_hard_header() to stash away the LL address (GID + QPN), instead of the "ipoib_pseudoheader" hack. This allows IPoIB to stop lying about its hard_header_len, which will let us fix the L2 check for GRO. Signed-off-by: Roland Dreier Signed-off-by: David S. Miller --- drivers/infiniband/ulp/ipoib/ipoib.h | 6 +- drivers/infiniband/ulp/ipoib/ipoib_main.c | 55 +++++++------------ .../infiniband/ulp/ipoib/ipoib_multicast.c | 10 +--- 3 files changed, 24 insertions(+), 47 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h index b3cc1e062b17..86df632ea612 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/drivers/infiniband/ulp/ipoib/ipoib.h @@ -44,6 +44,7 @@ #include #include +#include #include @@ -117,8 +118,9 @@ struct ipoib_header { u16 reserved; }; -struct ipoib_pseudoheader { - u8 hwaddr[INFINIBAND_ALEN]; +struct ipoib_cb { + struct qdisc_skb_cb qdisc_cb; + u8 hwaddr[INFINIBAND_ALEN]; }; /* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */ diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 3514ca05deea..3974c290b667 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -653,7 +653,7 @@ static void ipoib_path_lookup(struct sk_buff *skb, struct neighbour *n, struct n } static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, - struct ipoib_pseudoheader *phdr) + struct ipoib_cb *cb) { struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_path *path; @@ -661,17 +661,15 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, spin_lock_irqsave(&priv->lock, flags); - path = __path_find(dev, phdr->hwaddr + 4); + path = __path_find(dev, cb->hwaddr + 4); if (!path || !path->valid) { int new_path = 0; if (!path) { - path = path_rec_create(dev, phdr->hwaddr + 4); + path = path_rec_create(dev, cb->hwaddr + 4); new_path = 1; } if (path) { - /* put pseudoheader back on for next time */ - skb_push(skb, sizeof *phdr); __skb_queue_tail(&path->queue, skb); if (!path->query && path_rec_start(dev, path)) { @@ -695,12 +693,10 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, be16_to_cpu(path->pathrec.dlid)); spin_unlock_irqrestore(&priv->lock, flags); - ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr)); + ipoib_send(dev, skb, path->ah, IPOIB_QPN(cb->hwaddr)); return; } else if ((path->query || !path_rec_start(dev, path)) && skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { - /* put pseudoheader back on for next time */ - skb_push(skb, sizeof *phdr); __skb_queue_tail(&path->queue, skb); } else { ++dev->stats.tx_dropped; @@ -774,16 +770,14 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) dev_kfree_skb_any(skb); } } else { - struct ipoib_pseudoheader *phdr = - (struct ipoib_pseudoheader *) skb->data; - skb_pull(skb, sizeof *phdr); + struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb; - if (phdr->hwaddr[4] == 0xff) { + if (cb->hwaddr[4] == 0xff) { /* Add in the P_Key for multicast*/ - phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff; - phdr->hwaddr[9] = priv->pkey & 0xff; + cb->hwaddr[8] = (priv->pkey >> 8) & 0xff; + cb->hwaddr[9] = priv->pkey & 0xff; - ipoib_mcast_send(dev, phdr->hwaddr + 4, skb); + ipoib_mcast_send(dev, cb->hwaddr + 4, skb); } else { /* unicast GID -- should be ARP or RARP reply */ @@ -792,14 +786,14 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev) ipoib_warn(priv, "Unicast, no %s: type %04x, QPN %06x %pI6\n", skb_dst(skb) ? "neigh" : "dst", be16_to_cpup((__be16 *) skb->data), - IPOIB_QPN(phdr->hwaddr), - phdr->hwaddr + 4); + IPOIB_QPN(cb->hwaddr), + cb->hwaddr + 4); dev_kfree_skb_any(skb); ++dev->stats.tx_dropped; goto unlock; } - unicast_arp_send(skb, dev, phdr); + unicast_arp_send(skb, dev, cb); } } unlock: @@ -825,8 +819,6 @@ static int ipoib_hard_header(struct sk_buff *skb, const void *daddr, const void *saddr, unsigned len) { struct ipoib_header *header; - struct dst_entry *dst; - struct neighbour *n; header = (struct ipoib_header *) skb_push(skb, sizeof *header); @@ -834,18 +826,13 @@ static int ipoib_hard_header(struct sk_buff *skb, header->reserved = 0; /* - * If we don't have a neighbour structure, stuff the - * destination address onto the front of the skb so we can - * figure out where to send the packet later. + * If we don't have a dst_entry structure, stuff the + * destination address into skb->cb so we can figure out where + * to send the packet later. */ - dst = skb_dst(skb); - n = NULL; - if (dst) - n = dst_get_neighbour_noref_raw(dst); - if ((!dst || !n) && daddr) { - struct ipoib_pseudoheader *phdr = - (struct ipoib_pseudoheader *) skb_push(skb, sizeof *phdr); - memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN); + if (!skb_dst(skb)) { + struct ipoib_cb *cb = (struct ipoib_cb *) skb->cb; + memcpy(cb->hwaddr, daddr, INFINIBAND_ALEN); } return 0; @@ -1021,11 +1008,7 @@ static void ipoib_setup(struct net_device *dev) dev->flags |= IFF_BROADCAST | IFF_MULTICAST; - /* - * We add in INFINIBAND_ALEN to allow for the destination - * address "pseudoheader" for skbs without neighbour struct. - */ - dev->hard_header_len = IPOIB_ENCAP_LEN + INFINIBAND_ALEN; + dev->hard_header_len = IPOIB_ENCAP_LEN; dev->addr_len = INFINIBAND_ALEN; dev->type = ARPHRD_INFINIBAND; dev->tx_queue_len = ipoib_sendq_size * 2; diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index f7ff9dd66cda..20ebc6fd1bb9 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c @@ -262,21 +262,13 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast, netif_tx_lock_bh(dev); while (!skb_queue_empty(&mcast->pkt_queue)) { struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue); - struct dst_entry *dst = skb_dst(skb); - struct neighbour *n = NULL; netif_tx_unlock_bh(dev); skb->dev = dev; - if (dst) - n = dst_get_neighbour_noref_raw(dst); - if (!dst || !n) { - /* put pseudoheader back on for next time */ - skb_push(skb, sizeof (struct ipoib_pseudoheader)); - } - if (dev_queue_xmit(skb)) ipoib_warn(priv, "dev_queue_xmit failed to requeue packet\n"); + netif_tx_lock_bh(dev); } netif_tx_unlock_bh(dev); -- GitLab From 43480aecb1f538d4f6dd8b2c5d2b71fb98659072 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 8 Feb 2012 08:51:50 +0000 Subject: [PATCH 0499/1846] gro: more generic L2 header check Shlomo Pongratz reported GRO L2 header check was suited for Ethernet only, and failed on IB/ipoib traffic. He provided a patch faking a zeroed header to let GRO aggregates frames. Roland Dreier, Herbert Xu, and others suggested we change GRO L2 header check to be more generic, ie not assuming L2 header is 14 bytes, but taking into account hard_header_len. __napi_gro_receive() has special handling for the common case (Ethernet) to avoid a memcmp() call and use an inline optimized function instead. Signed-off-by: Eric Dumazet Reported-by: Shlomo Pongratz Cc: Roland Dreier Cc: Or Gerlitz Cc: Herbert Xu Tested-by: Sean Hefty Signed-off-by: David S. Miller --- net/core/dev.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index f1249472e90e..763a0eda7158 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3491,14 +3491,20 @@ static inline gro_result_t __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) { struct sk_buff *p; + unsigned int maclen = skb->dev->hard_header_len; for (p = napi->gro_list; p; p = p->next) { unsigned long diffs; diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev; diffs |= p->vlan_tci ^ skb->vlan_tci; - diffs |= compare_ether_header(skb_mac_header(p), - skb_gro_mac_header(skb)); + if (maclen == ETH_HLEN) + diffs |= compare_ether_header(skb_mac_header(p), + skb_gro_mac_header(skb)); + else if (!diffs) + diffs = memcmp(skb_mac_header(p), + skb_gro_mac_header(skb), + maclen); NAPI_GRO_CB(p)->same_flow = !diffs; NAPI_GRO_CB(p)->flush = 0; } -- GitLab From 76e21053b5bf33a07c76f99d27a74238310e3c71 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Wed, 8 Feb 2012 09:11:07 +0000 Subject: [PATCH 0500/1846] ipv4: Implement IP_UNICAST_IF socket option. The IP_UNICAST_IF feature is needed by the Wine project. This patch implements the feature by setting the outgoing interface in a similar fashion to that of IP_MULTICAST_IF. A separate option is needed to handle this feature since the existing options do not provide all of the characteristics required by IP_UNICAST_IF, a summary is provided below. SO_BINDTODEVICE: * SO_BINDTODEVICE requires administrative privileges, IP_UNICAST_IF does not. From reading some old mailing list articles my understanding is that SO_BINDTODEVICE requires administrative privileges because it can override the administrator's routing settings. * The SO_BINDTODEVICE option restricts both outbound and inbound traffic, IP_UNICAST_IF only impacts outbound traffic. IP_PKTINFO: * Since IP_PKTINFO and IP_UNICAST_IF are independent options, implementing IP_UNICAST_IF with IP_PKTINFO will likely break some applications. * Implementing IP_UNICAST_IF on top of IP_PKTINFO significantly complicates the Wine codebase and reduces the socket performance (doing this requires a lot of extra communication between the "server" and "user" layers). bind(): * bind() does not work on broadcast packets, IP_UNICAST_IF is specifically intended to work with broadcast packets. * Like SO_BINDTODEVICE, bind() restricts both outbound and inbound traffic. Signed-off-by: Erich E. Hoover Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/in.h | 1 + include/net/inet_sock.h | 2 ++ net/ipv4/ip_sockglue.c | 33 +++++++++++++++++++++++++++++++++ net/ipv4/ping.c | 3 ++- net/ipv4/raw.c | 3 ++- net/ipv4/udp.c | 3 ++- 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/include/linux/in.h b/include/linux/in.h index 01129c0ea87c..e0337f11d92e 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -111,6 +111,7 @@ struct in_addr { #define MCAST_LEAVE_SOURCE_GROUP 47 #define MCAST_MSFILTER 48 #define IP_MULTICAST_ALL 49 +#define IP_UNICAST_IF 50 #define MCAST_EXCLUDE 0 #define MCAST_INCLUDE 1 diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index e3e405106afe..022f772c0ebe 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -132,6 +132,7 @@ struct rtable; * @tos - TOS * @mc_ttl - Multicasting TTL * @is_icsk - is this an inet_connection_sock? + * @uc_index - Unicast outgoing device index * @mc_index - Multicast device index * @mc_list - Group array * @cork - info to build ip hdr on each ip frag while socket is corked @@ -167,6 +168,7 @@ struct inet_sock { transparent:1, mc_all:1, nodefrag:1; + int uc_index; int mc_index; __be32 mc_addr; struct ip_mc_socklist __rcu *mc_list; diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 8aa87c19fa00..9125529dab95 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -469,6 +469,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, (1<mc_loop = !!val; break; + case IP_UNICAST_IF: + { + struct net_device *dev = NULL; + int ifindex; + + if (optlen != sizeof(int)) + goto e_inval; + + ifindex = (__force int)ntohl((__force __be32)val); + if (ifindex == 0) { + inet->uc_index = 0; + err = 0; + break; + } + + dev = dev_get_by_index(sock_net(sk), ifindex); + err = -EADDRNOTAVAIL; + if (!dev) + break; + dev_put(dev); + + err = -EINVAL; + if (sk->sk_bound_dev_if) + break; + + inet->uc_index = ifindex; + err = 0; + break; + } case IP_MULTICAST_IF: { struct ip_mreqn mreq; @@ -1178,6 +1208,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, case IP_MULTICAST_LOOP: val = inet->mc_loop; break; + case IP_UNICAST_IF: + val = (__force int)htonl((__u32) inet->uc_index); + break; case IP_MULTICAST_IF: { struct in_addr addr; diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index aea5a199c37a..cfc82cf339f6 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -556,7 +556,8 @@ static int ping_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ipc.oif = inet->mc_index; if (!saddr) saddr = inet->mc_addr; - } + } else if (!ipc.oif) + ipc.oif = inet->uc_index; flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, sk->sk_protocol, diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 3ccda5ae8a27..ab466305b629 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -563,7 +563,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ipc.oif = inet->mc_index; if (!saddr) saddr = inet->mc_addr; - } + } else if (!ipc.oif) + ipc.oif = inet->uc_index; flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 5d075b5f70fc..cd99f1a0f59f 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -917,7 +917,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, if (!saddr) saddr = inet->mc_addr; connected = 0; - } + } else if (!ipc.oif) + ipc.oif = inet->uc_index; if (connected) rt = (struct rtable *)sk_dst_check(sk, 0); -- GitLab From c4062dfc425e94290ac427a98d6b4721dd2bc91f Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Wed, 8 Feb 2012 09:11:08 +0000 Subject: [PATCH 0501/1846] ipv6: Implement IPV6_UNICAST_IF socket option. The IPV6_UNICAST_IF feature is the IPv6 compliment to IP_UNICAST_IF. Signed-off-by: Erich E. Hoover Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/in6.h | 1 + include/linux/ipv6.h | 1 + net/ipv6/icmp.c | 4 ++++ net/ipv6/ipv6_sockglue.c | 34 ++++++++++++++++++++++++++++++++++ net/ipv6/raw.c | 2 ++ net/ipv6/udp.c | 3 ++- 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/include/linux/in6.h b/include/linux/in6.h index 097a34b55560..5c83d9e3eb8f 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h @@ -271,6 +271,7 @@ struct in6_flowlabel_req { #define IPV6_ORIGDSTADDR 74 #define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR #define IPV6_TRANSPARENT 75 +#define IPV6_UNICAST_IF 76 /* * Multicast Routing: diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 6318268dcaf5..743a16a41040 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -324,6 +324,7 @@ struct ipv6_pinfo { __unused_2:6; __s16 mcast_hops:9; #endif + int ucast_oif; int mcast_oif; /* pktoption flags */ diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 01d46bff63c3..af88934e4d79 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -468,6 +468,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; dst = icmpv6_route_lookup(net, skb, sk, &fl6); if (IS_ERR(dst)) @@ -553,6 +555,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb) if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; err = ip6_dst_lookup(sk, &dst, &fl6); if (err) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 18a2719003c3..6d6b65fdaa1a 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -516,6 +516,36 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, retv = 0; break; + case IPV6_UNICAST_IF: + { + struct net_device *dev = NULL; + int ifindex; + + if (optlen != sizeof(int)) + goto e_inval; + + ifindex = (__force int)ntohl((__force __be32)val); + if (ifindex == 0) { + np->ucast_oif = 0; + retv = 0; + break; + } + + dev = dev_get_by_index(net, ifindex); + retv = -EADDRNOTAVAIL; + if (!dev) + break; + dev_put(dev); + + retv = -EINVAL; + if (sk->sk_bound_dev_if) + break; + + np->ucast_oif = ifindex; + retv = 0; + break; + } + case IPV6_MULTICAST_IF: if (sk->sk_type == SOCK_STREAM) break; @@ -1160,6 +1190,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, val = np->mcast_oif; break; + case IPV6_UNICAST_IF: + val = (__force int)htonl((__u32) np->ucast_oif); + break; + case IPV6_MTU_DISCOVER: val = np->pmtudisc; break; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index d02f7e4dd611..5bddea778840 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -856,6 +856,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) fl6.flowi6_oif = np->mcast_oif; + else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 4f96b5c63685..8aebf8f90436 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1130,7 +1130,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) { fl6.flowi6_oif = np->mcast_oif; connected = 0; - } + } else if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->ucast_oif; security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); -- GitLab From 42bc0c9716c456a9686fcd4ee5cf115b992b9952 Mon Sep 17 00:00:00 2001 From: Simon Graham Date: Wed, 8 Feb 2012 12:34:23 -0500 Subject: [PATCH 0502/1846] rtlwifi: Return correct failure code on error Callers of rtl_pci_init expect zero to be returned on error. Returning the error code leads to, amongst other things, divide by zero panics attempting to use the ring size that is set to zero. Signed-off-by: Simon Graham Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index c503bd3b809e..8a941b588a41 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1492,7 +1492,7 @@ static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "tx ring initialization failed\n"); - return err; + return 0; } return 1; -- GitLab From 2cfc6fc584a65db87935ca4e4d5e1ad89d5192ee Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 8 Feb 2012 19:17:11 +0100 Subject: [PATCH 0503/1846] mac80211: do not call rate control .tx_status before .rate_init Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized. minstrel_ht crashes if this assumption is violated. Signed-off-by: Felix Fietkau Tested-by: Arend van Spriel Signed-off-by: John W. Linville --- net/mac80211/rate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h index 5fc3135a6b45..fbb1efdc4d04 100644 --- a/net/mac80211/rate.h +++ b/net/mac80211/rate.h @@ -37,7 +37,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local, struct ieee80211_sta *ista = &sta->sta; void *priv_sta = sta->rate_ctrl_priv; - if (!ref) + if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) return; ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb); -- GitLab From dae2e9f430c46c29e3f771110094bd3da3625aa4 Mon Sep 17 00:00:00 2001 From: "Pradeep A. Dalvi" Date: Mon, 6 Feb 2012 11:16:13 +0000 Subject: [PATCH 0504/1846] netdev: ethernet dev_alloc_skb to netdev_alloc_skb Replaced deprecating dev_alloc_skb with netdev_alloc_skb in drivers/net/ethernet - Removed extra skb->dev = dev after netdev_alloc_skb Signed-off-by: Pradeep A Dalvi Signed-off-by: David S. Miller --- drivers/net/ethernet/netx-eth.c | 2 +- drivers/net/ethernet/nuvoton/w90p910_ether.c | 2 +- drivers/net/ethernet/nvidia/forcedeth.c | 8 ++++---- drivers/net/ethernet/packetengines/hamachi.c | 8 +++----- drivers/net/ethernet/packetengines/yellowfin.c | 8 +++----- drivers/net/ethernet/pasemi/pasemi_mac.c | 2 +- drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c | 2 +- drivers/net/ethernet/racal/ni5010.c | 2 +- drivers/net/ethernet/realtek/atp.c | 2 +- drivers/net/ethernet/renesas/sh_eth.c | 6 ++---- drivers/net/ethernet/seeq/ether3.c | 2 +- drivers/net/ethernet/seeq/seeq8005.c | 2 +- drivers/net/ethernet/sis/sis900.c | 6 +++--- drivers/net/ethernet/smsc/epic100.c | 6 +++--- drivers/net/ethernet/smsc/smc911x.c | 2 +- drivers/net/ethernet/smsc/smc9194.c | 2 +- drivers/net/ethernet/smsc/smc91c92_cs.c | 2 +- drivers/net/ethernet/smsc/smc91x.c | 2 +- drivers/net/ethernet/smsc/smsc9420.c | 2 -- drivers/net/ethernet/sun/cassini.c | 2 +- drivers/net/ethernet/sun/sunbmac.c | 2 +- drivers/net/ethernet/sun/sunhme.c | 2 +- drivers/net/ethernet/sun/sunqe.c | 2 +- drivers/net/ethernet/tehuti/tehuti.c | 7 +++---- drivers/net/ethernet/ti/davinci_emac.c | 3 +-- drivers/net/ethernet/tile/tilepro.c | 4 ++-- drivers/net/ethernet/toshiba/tc35815.c | 2 +- drivers/net/ethernet/via/via-rhine.c | 2 -- drivers/net/ethernet/via/via-velocity.c | 2 +- drivers/net/ethernet/xilinx/xilinx_emaclite.c | 2 +- drivers/net/ethernet/xircom/xirc2ps_cs.c | 3 ++- 33 files changed, 47 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/netx-eth.c b/drivers/net/ethernet/netx-eth.c index 5a12276f810d..9d11ab7521bc 100644 --- a/drivers/net/ethernet/netx-eth.c +++ b/drivers/net/ethernet/netx-eth.c @@ -150,7 +150,7 @@ static void netx_eth_receive(struct net_device *ndev) seg = (val & FIFO_PTR_SEGMENT_MASK) >> FIFO_PTR_SEGMENT_SHIFT; len = (val & FIFO_PTR_FRAMELEN_MASK) >> FIFO_PTR_FRAMELEN_SHIFT; - skb = dev_alloc_skb(len); + skb = netdev_alloc_skb(ndev, len); if (unlikely(skb == NULL)) { printk(KERN_NOTICE "%s: Low memory, packet dropped.\n", ndev->name); diff --git a/drivers/net/ethernet/nuvoton/w90p910_ether.c b/drivers/net/ethernet/nuvoton/w90p910_ether.c index b75a0497d58d..6893a65ae55f 100644 --- a/drivers/net/ethernet/nuvoton/w90p910_ether.c +++ b/drivers/net/ethernet/nuvoton/w90p910_ether.c @@ -735,7 +735,7 @@ static void netdev_rx(struct net_device *dev) if (status & RXDS_RXGD) { data = ether->rdesc->recv_buf[ether->cur_rx]; - skb = dev_alloc_skb(length+2); + skb = netdev_alloc_skb(dev, length + 2); if (!skb) { dev_err(&pdev->dev, "get skb buffer error\n"); ether->stats.rx_dropped++; diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 4c4e7f458383..5eeb92f87380 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -1815,7 +1815,7 @@ static int nv_alloc_rx(struct net_device *dev) less_rx = np->last_rx.orig; while (np->put_rx.orig != less_rx) { - struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD); + struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz + NV_RX_ALLOC_PAD); if (skb) { np->put_rx_ctx->skb = skb; np->put_rx_ctx->dma = pci_map_single(np->pci_dev, @@ -1850,7 +1850,7 @@ static int nv_alloc_rx_optimized(struct net_device *dev) less_rx = np->last_rx.ex; while (np->put_rx.ex != less_rx) { - struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD); + struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz + NV_RX_ALLOC_PAD); if (skb) { np->put_rx_ctx->skb = skb; np->put_rx_ctx->dma = pci_map_single(np->pci_dev, @@ -4993,9 +4993,9 @@ static int nv_loopback_test(struct net_device *dev) /* setup packet for tx */ pkt_len = ETH_DATA_LEN; - tx_skb = dev_alloc_skb(pkt_len); + tx_skb = netdev_alloc_skb(dev, pkt_len); if (!tx_skb) { - netdev_err(dev, "dev_alloc_skb() failed during loopback test\n"); + netdev_err(dev, "netdev_alloc_skb() failed during loopback test\n"); ret = 0; goto out; } diff --git a/drivers/net/ethernet/packetengines/hamachi.c b/drivers/net/ethernet/packetengines/hamachi.c index 3458df3780b8..0d29f5f4b8e4 100644 --- a/drivers/net/ethernet/packetengines/hamachi.c +++ b/drivers/net/ethernet/packetengines/hamachi.c @@ -1188,11 +1188,10 @@ static void hamachi_init_ring(struct net_device *dev) } /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2); hmp->rx_skbuff[i] = skb; if (skb == NULL) break; - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* 16 byte align the IP header. */ hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); @@ -1488,7 +1487,7 @@ static int hamachi_rx(struct net_device *dev) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { #ifdef RX_CHECKSUM printk(KERN_ERR "%s: rx_copybreak non-zero " "not good with RX_CHECKSUM\n", dev->name); @@ -1591,12 +1590,11 @@ static int hamachi_rx(struct net_device *dev) entry = hmp->dirty_rx % RX_RING_SIZE; desc = &(hmp->rx_ring[entry]); if (hmp->rx_skbuff[entry] == NULL) { - struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2); hmp->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); diff --git a/drivers/net/ethernet/packetengines/yellowfin.c b/drivers/net/ethernet/packetengines/yellowfin.c index 4a5774271bd4..7757b80ef924 100644 --- a/drivers/net/ethernet/packetengines/yellowfin.c +++ b/drivers/net/ethernet/packetengines/yellowfin.c @@ -743,11 +743,10 @@ static int yellowfin_init_ring(struct net_device *dev) } for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, yp->rx_buf_sz + 2); yp->rx_skbuff[i] = skb; if (skb == NULL) break; - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* 16 byte align the IP header. */ yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev, skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); @@ -1133,7 +1132,7 @@ static int yellowfin_rx(struct net_device *dev) PCI_DMA_FROMDEVICE); yp->rx_skbuff[entry] = NULL; } else { - skb = dev_alloc_skb(pkt_len + 2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) break; skb_reserve(skb, 2); /* 16 byte align the IP header */ @@ -1156,11 +1155,10 @@ static int yellowfin_rx(struct net_device *dev) for (; yp->cur_rx - yp->dirty_rx > 0; yp->dirty_rx++) { entry = yp->dirty_rx % RX_RING_SIZE; if (yp->rx_skbuff[entry] == NULL) { - struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, yp->rx_buf_sz + 2); if (skb == NULL) break; /* Better luck next round. */ yp->rx_skbuff[entry] = skb; - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ yp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev, skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 3bb725ed2703..667498ea4603 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c @@ -643,7 +643,7 @@ static void pasemi_mac_replenish_rx_ring(const struct net_device *dev, /* Entry in use? */ WARN_ON(*buff); - skb = dev_alloc_skb(mac->bufsz); + skb = netdev_alloc_skb(dev, mac->bufsz); skb_reserve(skb, LOCAL_SKB_ALIGN); if (unlikely(!skb)) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c index f69ac442c6a1..718b27440351 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c @@ -1487,7 +1487,7 @@ netxen_alloc_rx_skb(struct netxen_adapter *adapter, dma_addr_t dma; struct pci_dev *pdev = adapter->pdev; - buffer->skb = dev_alloc_skb(rds_ring->skb_size); + buffer->skb = netdev_alloc_skb(adapter->netdev, rds_ring->skb_size); if (!buffer->skb) return 1; diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 30dcbfba8f24..89ddf7f7d7df 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c @@ -719,7 +719,7 @@ static int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode) int i, loop, cnt = 0; for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { - skb = dev_alloc_skb(QLCNIC_ILB_PKT_SIZE); + skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); skb_put(skb, QLCNIC_ILB_PKT_SIZE); diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c index 41d85efee422..d32cf0ddf1b9 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c @@ -1440,7 +1440,7 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter, dma_addr_t dma; struct pci_dev *pdev = adapter->pdev; - skb = dev_alloc_skb(rds_ring->skb_size); + skb = netdev_alloc_skb(adapter->netdev, rds_ring->skb_size); if (!skb) { adapter->stats.skb_alloc_failure++; return -ENOMEM; diff --git a/drivers/net/ethernet/racal/ni5010.c b/drivers/net/ethernet/racal/ni5010.c index 072810da9a37..807982220050 100644 --- a/drivers/net/ethernet/racal/ni5010.c +++ b/drivers/net/ethernet/racal/ni5010.c @@ -552,7 +552,7 @@ static void ni5010_rx(struct net_device *dev) } /* Malloc up new buffer. */ - skb = dev_alloc_skb(i_pkt_size + 3); + skb = netdev_alloc_skb(dev, i_pkt_size + 3); if (skb == NULL) { printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/realtek/atp.c b/drivers/net/ethernet/realtek/atp.c index e3f57fdbf0ea..46c1932048cb 100644 --- a/drivers/net/ethernet/realtek/atp.c +++ b/drivers/net/ethernet/realtek/atp.c @@ -783,7 +783,7 @@ static void net_rx(struct net_device *dev) int pkt_len = (rx_head.rx_count & 0x7ff) - 4; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len + 2); + skb = netdev_alloc_skb(dev, pkt_len + 2); if (skb == NULL) { printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index dacd13150b6c..1a69504ed9c5 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -653,13 +653,12 @@ static void sh_eth_ring_format(struct net_device *ndev) for (i = 0; i < RX_RING_SIZE; i++) { /* skb */ mdp->rx_skbuff[i] = NULL; - skb = dev_alloc_skb(mdp->rx_buf_sz); + skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz); mdp->rx_skbuff[i] = skb; if (skb == NULL) break; dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); - skb->dev = ndev; /* Mark as being used by this device. */ sh_eth_set_receive_align(skb); /* RX descriptor */ @@ -953,13 +952,12 @@ static int sh_eth_rx(struct net_device *ndev) rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); if (mdp->rx_skbuff[entry] == NULL) { - skb = dev_alloc_skb(mdp->rx_buf_sz); + skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz); mdp->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, DMA_FROM_DEVICE); - skb->dev = ndev; sh_eth_set_receive_align(skb); skb_checksum_none_assert(skb); diff --git a/drivers/net/ethernet/seeq/ether3.c b/drivers/net/ethernet/seeq/ether3.c index 893c880dadf0..7b819bd8c416 100644 --- a/drivers/net/ethernet/seeq/ether3.c +++ b/drivers/net/ethernet/seeq/ether3.c @@ -643,7 +643,7 @@ if (next_ptr < RX_START || next_ptr >= RX_END) { if (next_ptr <= this_ptr) length += RX_END - RX_START; - skb = dev_alloc_skb(length + 2); + skb = netdev_alloc_skb(dev, length + 2); if (skb) { unsigned char *buf; diff --git a/drivers/net/ethernet/seeq/seeq8005.c b/drivers/net/ethernet/seeq/seeq8005.c index 60561451789b..798990774446 100644 --- a/drivers/net/ethernet/seeq/seeq8005.c +++ b/drivers/net/ethernet/seeq/seeq8005.c @@ -548,7 +548,7 @@ static void seeq8005_rx(struct net_device *dev) struct sk_buff *skb; unsigned char *buf; - skb = dev_alloc_skb(pkt_len); + skb = netdev_alloc_skb(dev, pkt_len); if (skb == NULL) { printk("%s: Memory squeeze, dropping packet.\n", dev->name); dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index 91c44688bc3e..f968898c86db 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c @@ -1166,7 +1166,7 @@ sis900_init_rx_ring(struct net_device *net_dev) for (i = 0; i < NUM_RX_DESC; i++) { struct sk_buff *skb; - if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) { + if ((skb = netdev_alloc_skb(net_dev, RX_BUF_SIZE)) == NULL) { /* not enough memory for skbuff, this makes a "hole" on the buffer ring, it is not clear how the hardware will react to this kind of degenerated @@ -1769,7 +1769,7 @@ static int sis900_rx(struct net_device *net_dev) /* refill the Rx buffer, what if there is not enough * memory for new socket buffer ?? */ - if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) { + if ((skb = netdev_alloc_skb(net_dev, RX_BUF_SIZE)) == NULL) { /* * Not enough memory to refill the buffer * so we need to recycle the old one so @@ -1827,7 +1827,7 @@ static int sis900_rx(struct net_device *net_dev) entry = sis_priv->dirty_rx % NUM_RX_DESC; if (sis_priv->rx_skbuff[entry] == NULL) { - if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) { + if ((skb = netdev_alloc_skb(net_dev, RX_BUF_SIZE)) == NULL) { /* not enough memory for skbuff, this makes a * "hole" on the buffer ring, it is not clear * how the hardware will react to this kind diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c index 11dcb38b99f7..2a662e6112e9 100644 --- a/drivers/net/ethernet/smsc/epic100.c +++ b/drivers/net/ethernet/smsc/epic100.c @@ -934,7 +934,7 @@ static void epic_init_ring(struct net_device *dev) /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { - struct sk_buff *skb = dev_alloc_skb(ep->rx_buf_sz + 2); + struct sk_buff *skb = netdev_alloc_skb(dev, ep->rx_buf_sz + 2); ep->rx_skbuff[i] = skb; if (skb == NULL) break; @@ -1199,7 +1199,7 @@ static int epic_rx(struct net_device *dev, int budget) /* Check if the packet is long enough to accept without copying to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { skb_reserve(skb, 2); /* 16 byte align the IP header */ pci_dma_sync_single_for_cpu(ep->pci_dev, ep->rx_ring[entry].bufaddr, @@ -1232,7 +1232,7 @@ static int epic_rx(struct net_device *dev, int budget) entry = ep->dirty_rx % RX_RING_SIZE; if (ep->rx_skbuff[entry] == NULL) { struct sk_buff *skb; - skb = ep->rx_skbuff[entry] = dev_alloc_skb(ep->rx_buf_sz + 2); + skb = ep->rx_skbuff[entry] = netdev_alloc_skb(dev, ep->rx_buf_sz + 2); if (skb == NULL) break; skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c index c28230148efd..8814b2f5d46f 100644 --- a/drivers/net/ethernet/smsc/smc911x.c +++ b/drivers/net/ethernet/smsc/smc911x.c @@ -401,7 +401,7 @@ static inline void smc911x_rcv(struct net_device *dev) } else { /* Receive a valid packet */ /* Alloc a buffer with extra room for DMA alignment */ - skb=dev_alloc_skb(pkt_len+32); + skb = netdev_alloc_skb(dev, pkt_len+32); if (unlikely(skb == NULL)) { PRINTK( "%s: Low memory, rcvd packet dropped.\n", dev->name); diff --git a/drivers/net/ethernet/smsc/smc9194.c b/drivers/net/ethernet/smsc/smc9194.c index 4e45094efb18..50823da9dc1e 100644 --- a/drivers/net/ethernet/smsc/smc9194.c +++ b/drivers/net/ethernet/smsc/smc9194.c @@ -1222,7 +1222,7 @@ static void smc_rcv(struct net_device *dev) if ( status & RS_MULTICAST ) dev->stats.multicast++; - skb = dev_alloc_skb( packet_length + 5); + skb = netdev_alloc_skb(dev, packet_length + 5); if ( skb == NULL ) { printk(KERN_NOTICE CARDNAME ": Low memory, packet dropped.\n"); diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c index ada927aba7a5..d12e48a7861d 100644 --- a/drivers/net/ethernet/smsc/smc91c92_cs.c +++ b/drivers/net/ethernet/smsc/smc91c92_cs.c @@ -1500,7 +1500,7 @@ static void smc_rx(struct net_device *dev) struct sk_buff *skb; /* Note: packet_length adds 5 or 6 extra bytes here! */ - skb = dev_alloc_skb(packet_length+2); + skb = netdev_alloc_skb(dev, packet_length+2); if (skb == NULL) { pr_debug("%s: Low memory, packet dropped.\n", dev->name); diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 24104a1ee6a5..1dc4fad593e7 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c @@ -463,7 +463,7 @@ static inline void smc_rcv(struct net_device *dev) * multiple of 4 bytes on 32 bit buses. * Hence packet_len - 6 + 2 + 2 + 2. */ - skb = dev_alloc_skb(packet_len); + skb = netdev_alloc_skb(dev, packet_len); if (unlikely(skb == NULL)) { printk(KERN_NOTICE "%s: Low memory, packet dropped.\n", dev->name); diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index 595f9881e096..ee1a1680b7a8 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c @@ -850,8 +850,6 @@ static int smsc9420_alloc_rx_buffer(struct smsc9420_pdata *pd, int index) return -ENOMEM; } - skb->dev = pd->dev; - mapping = pci_map_single(pd->pdev, skb_tail_pointer(skb), PKT_BUF_SZ, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(pd->pdev, mapping)) { diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index 45292760fce4..b36edbd625dd 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c @@ -1974,7 +1974,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc, else alloclen = max(hlen, RX_COPY_MIN); - skb = dev_alloc_skb(alloclen + swivel + cp->crc_size); + skb = netdev_alloc_skb(cp->dev, alloclen + swivel + cp->crc_size); if (skb == NULL) return -1; diff --git a/drivers/net/ethernet/sun/sunbmac.c b/drivers/net/ethernet/sun/sunbmac.c index 220f724c3377..f359863b5340 100644 --- a/drivers/net/ethernet/sun/sunbmac.c +++ b/drivers/net/ethernet/sun/sunbmac.c @@ -853,7 +853,7 @@ static void bigmac_rx(struct bigmac *bp) /* Trim the original skb for the netif. */ skb_trim(skb, len); } else { - struct sk_buff *copy_skb = dev_alloc_skb(len + 2); + struct sk_buff *copy_skb = netdev_alloc_skb(bp->dev, len + 2); if (copy_skb == NULL) { drops++; diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 09c518655db2..8b627e2f798d 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2043,7 +2043,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) /* Trim the original skb for the netif. */ skb_trim(skb, len); } else { - struct sk_buff *copy_skb = dev_alloc_skb(len + 2); + struct sk_buff *copy_skb = netdev_alloc_skb(dev, len + 2); if (copy_skb == NULL) { drops++; diff --git a/drivers/net/ethernet/sun/sunqe.c b/drivers/net/ethernet/sun/sunqe.c index b28f74367ebe..b42d1c5a6ca1 100644 --- a/drivers/net/ethernet/sun/sunqe.c +++ b/drivers/net/ethernet/sun/sunqe.c @@ -435,7 +435,7 @@ static void qe_rx(struct sunqe *qep) dev->stats.rx_length_errors++; dev->stats.rx_dropped++; } else { - skb = dev_alloc_skb(len + 2); + skb = netdev_alloc_skb(dev, len + 2); if (skb == NULL) { drops++; dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c index df7febba9ea6..ad973ffc9ff3 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c @@ -1089,12 +1089,11 @@ static void bdx_rx_alloc_skbs(struct bdx_priv *priv, struct rxf_fifo *f) ENTER; dno = bdx_rxdb_available(db) - 1; while (dno > 0) { - skb = dev_alloc_skb(f->m.pktsz + NET_IP_ALIGN); + skb = netdev_alloc_skb(priv->ndev, f->m.pktsz + NET_IP_ALIGN); if (!skb) { - pr_err("NO MEM: dev_alloc_skb failed\n"); + pr_err("NO MEM: netdev_alloc_skb failed\n"); break; } - skb->dev = priv->ndev; skb_reserve(skb, NET_IP_ALIGN); idx = bdx_rxdb_alloc_elem(db); @@ -1258,7 +1257,7 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget) skb = dm->skb; if (len < BDX_COPYBREAK && - (skb2 = dev_alloc_skb(len + NET_IP_ALIGN))) { + (skb2 = netdev_alloc_skb(priv->ndev, len + NET_IP_ALIGN))) { skb_reserve(skb2, NET_IP_ALIGN); /*skb_put(skb2, len); */ pci_dma_sync_single_for_cpu(priv->pdev, diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 922a937e05cf..6b0659c59ddd 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -992,10 +992,9 @@ static irqreturn_t emac_irq(int irq, void *dev_id) static struct sk_buff *emac_rx_alloc(struct emac_priv *priv) { - struct sk_buff *skb = dev_alloc_skb(priv->rx_buf_size); + struct sk_buff *skb = netdev_alloc_skb(priv->ndev, priv->rx_buf_size); if (WARN_ON(!skb)) return NULL; - skb->dev = priv->ndev; skb_reserve(skb, NET_IP_ALIGN); return skb; } diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c index d9951afb9269..a8e5daaef6fa 100644 --- a/drivers/net/ethernet/tile/tilepro.c +++ b/drivers/net/ethernet/tile/tilepro.c @@ -419,7 +419,7 @@ static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info, #endif /* Avoid "false sharing" with last cache line. */ - /* ISSUE: This is already done by "dev_alloc_skb()". */ + /* ISSUE: This is already done by "netdev_alloc_skb()". */ unsigned int len = (((small ? LIPP_SMALL_PACKET_SIZE : large_size) + CHIP_L2_LINE_SIZE() - 1) & -CHIP_L2_LINE_SIZE()); @@ -433,7 +433,7 @@ static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info, struct sk_buff **skb_ptr; /* Request 96 extra bytes for alignment purposes. */ - skb = dev_alloc_skb(len + padding); + skb = netdev_alloc_skb(info->napi->dev, len + padding); if (skb == NULL) return false; diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c index f5ac603d5608..d117ad475c3e 100644 --- a/drivers/net/ethernet/toshiba/tc35815.c +++ b/drivers/net/ethernet/toshiba/tc35815.c @@ -453,7 +453,7 @@ static struct sk_buff *alloc_rxbuf_skb(struct net_device *dev, dma_addr_t *dma_handle) { struct sk_buff *skb; - skb = dev_alloc_skb(RX_BUF_SIZE); + skb = netdev_alloc_skb(dev, RX_BUF_SIZE); if (!skb) return NULL; *dma_handle = pci_map_single(hwdev, skb->data, RX_BUF_SIZE, diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index 1b95daa372c4..cb2ff28a0602 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c @@ -1155,7 +1155,6 @@ static void alloc_rbufs(struct net_device *dev) rp->rx_skbuff[i] = skb; if (skb == NULL) break; - skb->dev = dev; /* Mark as being used by this device. */ rp->rx_skbuff_dma[i] = pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz, @@ -1940,7 +1939,6 @@ static int rhine_rx(struct net_device *dev, int limit) rp->rx_skbuff[entry] = skb; if (skb == NULL) break; /* Better luck next round. */ - skb->dev = dev; /* Mark as being used by this device. */ rp->rx_skbuff_dma[entry] = pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz, diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c index 2776bbc67936..cf69cbf6fec3 100644 --- a/drivers/net/ethernet/via/via-velocity.c +++ b/drivers/net/ethernet/via/via-velocity.c @@ -1509,7 +1509,7 @@ static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx) struct rx_desc *rd = &(vptr->rx.ring[idx]); struct velocity_rd_info *rd_info = &(vptr->rx.info[idx]); - rd_info->skb = dev_alloc_skb(vptr->rx.buf_sz + 64); + rd_info->skb = netdev_alloc_skb(vptr->dev, vptr->rx.buf_sz + 64); if (rd_info->skb == NULL) return -ENOMEM; diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c index 90e611a6f6c6..77cfe5110318 100644 --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c @@ -613,7 +613,7 @@ static void xemaclite_rx_handler(struct net_device *dev) u32 len; len = ETH_FRAME_LEN + ETH_FCS_LEN; - skb = dev_alloc_skb(len + ALIGNMENT); + skb = netdev_alloc_skb(dev, len + ALIGNMENT); if (!skb) { /* Couldn't get memory. */ dev->stats.rx_dropped++; diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c index 33979c3ac943..5c69c6f93fb8 100644 --- a/drivers/net/ethernet/xircom/xirc2ps_cs.c +++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c @@ -1039,7 +1039,8 @@ xirc2ps_interrupt(int irq, void *dev_id) pr_debug("rsr=%#02x packet_length=%u\n", rsr, pktlen); - skb = dev_alloc_skb(pktlen+3); /* 1 extra so we can use insw */ + /* 1 extra so we can use insw */ + skb = netdev_alloc_skb(dev, pktlen + 3); if (!skb) { pr_notice("low memory, packet dropped (size=%u)\n", pktlen); dev->stats.rx_dropped++; -- GitLab From 1ab0d2ec9aeb4489c05158e8a2b00bad89f67e03 Mon Sep 17 00:00:00 2001 From: "Pradeep A. Dalvi" Date: Mon, 6 Feb 2012 11:16:48 +0000 Subject: [PATCH 0505/1846] netdev: ethernet dev_alloc_skb to netdev_alloc_skb Replaced deprecating dev_alloc_skb with netdev_alloc_skb in drivers/net/ethernet - Removed extra skb->dev = dev after netdev_alloc_skb Signed-off-by: Pradeep A Dalvi Signed-off-by: David S. Miller --- drivers/net/ethernet/3com/3c515.c | 10 ++++------ drivers/net/ethernet/adi/bfin_mac.c | 8 ++++---- drivers/net/ethernet/apple/bmac.c | 11 ++++++----- drivers/net/ethernet/dec/tulip/dmfe.c | 20 +++++++++++--------- drivers/net/ethernet/dec/tulip/uli526x.c | 21 ++++++++++++--------- drivers/net/ethernet/s6gmac.c | 9 +++++---- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c index f67a5d3a200c..59e1e001bc3f 100644 --- a/drivers/net/ethernet/3com/3c515.c +++ b/drivers/net/ethernet/3com/3c515.c @@ -826,11 +826,10 @@ static int corkscrew_open(struct net_device *dev) vp->rx_ring[i].next = 0; vp->rx_ring[i].status = 0; /* Clear complete bit. */ vp->rx_ring[i].length = PKT_BUF_SZ | 0x80000000; - skb = dev_alloc_skb(PKT_BUF_SZ); + skb = netdev_alloc_skb(dev, PKT_BUF_SZ); vp->rx_skbuff[i] = skb; if (skb == NULL) break; /* Bad news! */ - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ vp->rx_ring[i].addr = isa_virt_to_bus(skb->data); } @@ -1295,7 +1294,7 @@ static int corkscrew_rx(struct net_device *dev) short pkt_len = rx_status & 0x1fff; struct sk_buff *skb; - skb = dev_alloc_skb(pkt_len + 5 + 2); + skb = netdev_alloc_skb(dev, pkt_len + 5 + 2); if (corkscrew_debug > 4) pr_debug("Receiving packet size %d status %4.4x.\n", pkt_len, rx_status); @@ -1368,7 +1367,7 @@ static int boomerang_rx(struct net_device *dev) /* Check if the packet is long enough to just accept without copying to a properly sized skbuff. */ if (pkt_len < rx_copybreak && - (skb = dev_alloc_skb(pkt_len + 4)) != NULL) { + (skb = netdev_alloc_skb(dev, pkt_len + 4)) != NULL) { skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ /* 'skb_put()' points to the start of sk_buff data area. */ memcpy(skb_put(skb, pkt_len), @@ -1403,10 +1402,9 @@ static int boomerang_rx(struct net_device *dev) struct sk_buff *skb; entry = vp->dirty_rx % RX_RING_SIZE; if (vp->rx_skbuff[entry] == NULL) { - skb = dev_alloc_skb(PKT_BUF_SZ); + skb = netdev_alloc_skb(dev, PKT_BUF_SZ); if (skb == NULL) break; /* Bad news! */ - skb->dev = dev; /* Mark as being used by this device. */ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ vp->rx_ring[entry].addr = isa_virt_to_bus(skb->data); vp->rx_skbuff[entry] = skb; diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c index 525a9768bb54..49733696703a 100644 --- a/drivers/net/ethernet/adi/bfin_mac.c +++ b/drivers/net/ethernet/adi/bfin_mac.c @@ -113,7 +113,7 @@ static void desc_list_free(void) } } -static int desc_list_init(void) +static int desc_list_init(struct net_device *dev) { int i; struct sk_buff *new_skb; @@ -187,7 +187,7 @@ static int desc_list_init(void) struct dma_descriptor *b = &(r->desc_b); /* allocate a new skb for next time receive */ - new_skb = dev_alloc_skb(PKT_BUF_SZ + NET_IP_ALIGN); + new_skb = netdev_alloc_skb(dev, PKT_BUF_SZ + NET_IP_ALIGN); if (!new_skb) { pr_notice("init: low on mem - packet dropped\n"); goto init_error; @@ -1090,7 +1090,7 @@ static void bfin_mac_rx(struct net_device *dev) /* allocate a new skb for next time receive */ skb = current_rx_ptr->skb; - new_skb = dev_alloc_skb(PKT_BUF_SZ + NET_IP_ALIGN); + new_skb = netdev_alloc_skb(dev, PKT_BUF_SZ + NET_IP_ALIGN); if (!new_skb) { netdev_notice(dev, "rx: low on mem - packet dropped\n"); dev->stats.rx_dropped++; @@ -1397,7 +1397,7 @@ static int bfin_mac_open(struct net_device *dev) } /* initial rx and tx list */ - ret = desc_list_init(); + ret = desc_list_init(dev); if (ret) return ret; diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c index ebc0dba5ba33..855bdafb1a87 100644 --- a/drivers/net/ethernet/apple/bmac.c +++ b/drivers/net/ethernet/apple/bmac.c @@ -607,8 +607,9 @@ bmac_init_tx_ring(struct bmac_data *bp) } static int -bmac_init_rx_ring(struct bmac_data *bp) +bmac_init_rx_ring(struct net_device *dev) { + struct bmac_data *bp = netdev_priv(dev); volatile struct dbdma_regs __iomem *rd = bp->rx_dma; int i; struct sk_buff *skb; @@ -618,7 +619,7 @@ bmac_init_rx_ring(struct bmac_data *bp) (N_RX_RING + 1) * sizeof(struct dbdma_cmd)); for (i = 0; i < N_RX_RING; i++) { if ((skb = bp->rx_bufs[i]) == NULL) { - bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2); + bp->rx_bufs[i] = skb = netdev_alloc_skb(dev, RX_BUFLEN + 2); if (skb != NULL) skb_reserve(skb, 2); } @@ -722,7 +723,7 @@ static irqreturn_t bmac_rxdma_intr(int irq, void *dev_id) ++dev->stats.rx_dropped; } if ((skb = bp->rx_bufs[i]) == NULL) { - bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2); + bp->rx_bufs[i] = skb = netdev_alloc_skb(dev, RX_BUFLEN + 2); if (skb != NULL) skb_reserve(bp->rx_bufs[i], 2); } @@ -1208,7 +1209,7 @@ static void bmac_reset_and_enable(struct net_device *dev) spin_lock_irqsave(&bp->lock, flags); bmac_enable_and_reset_chip(dev); bmac_init_tx_ring(bp); - bmac_init_rx_ring(bp); + bmac_init_rx_ring(dev); bmac_init_chip(dev); bmac_start_chip(dev); bmwrite(dev, INTDISABLE, EnableNormal); @@ -1218,7 +1219,7 @@ static void bmac_reset_and_enable(struct net_device *dev) * It seems that the bmac can't receive until it's transmitted * a packet. So we give it a dummy packet to transmit. */ - skb = dev_alloc_skb(ETHERMINPACKET); + skb = netdev_alloc_skb(dev, ETHERMINPACKET); if (skb != NULL) { data = skb_put(skb, ETHERMINPACKET); memset(data, 0, ETHERMINPACKET); diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c index 51f7542eb451..1eccf4945485 100644 --- a/drivers/net/ethernet/dec/tulip/dmfe.c +++ b/drivers/net/ethernet/dec/tulip/dmfe.c @@ -325,8 +325,8 @@ static irqreturn_t dmfe_interrupt(int , void *); #ifdef CONFIG_NET_POLL_CONTROLLER static void poll_dmfe (struct net_device *dev); #endif -static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long); -static void allocate_rx_buffer(struct dmfe_board_info *); +static void dmfe_descriptor_init(struct net_device *, unsigned long); +static void allocate_rx_buffer(struct net_device *); static void update_cr6(u32, unsigned long); static void send_filter_frame(struct DEVICE *); static void dm9132_id_table(struct DEVICE *); @@ -649,7 +649,7 @@ static void dmfe_init_dm910x(struct DEVICE *dev) db->op_mode = db->media_mode; /* Force Mode */ /* Initialize Transmit/Receive decriptor and CR3/4 */ - dmfe_descriptor_init(db, ioaddr); + dmfe_descriptor_init(dev, ioaddr); /* Init CR6 to program DM910x operation */ update_cr6(db->cr6_data, ioaddr); @@ -828,7 +828,7 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id) /* reallocate rx descriptor buffer */ if (db->rx_avail_cntcr5_data & 0x01) @@ -1008,7 +1008,7 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db) /* Good packet, send to upper layer */ /* Shorst packet used new SKB */ if ((rxlen < RX_COPY_SIZE) && - ((newskb = dev_alloc_skb(rxlen + 2)) + ((newskb = netdev_alloc_skb(dev, rxlen + 2)) != NULL)) { skb = newskb; @@ -1364,8 +1364,9 @@ static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb) * Using Chain structure, and allocate Tx/Rx buffer */ -static void dmfe_descriptor_init(struct dmfe_board_info *db, unsigned long ioaddr) +static void dmfe_descriptor_init(struct net_device *dev, unsigned long ioaddr) { + struct dmfe_board_info *db = netdev_priv(dev); struct tx_desc *tmp_tx; struct rx_desc *tmp_rx; unsigned char *tmp_buf; @@ -1421,7 +1422,7 @@ static void dmfe_descriptor_init(struct dmfe_board_info *db, unsigned long ioadd tmp_rx->next_rx_desc = db->first_rx_desc; /* pre-allocate Rx buffer */ - allocate_rx_buffer(db); + allocate_rx_buffer(dev); } @@ -1551,15 +1552,16 @@ static void send_filter_frame(struct DEVICE *dev) * As possible as allocate maxiumn Rx buffer */ -static void allocate_rx_buffer(struct dmfe_board_info *db) +static void allocate_rx_buffer(struct net_device *dev) { + struct dmfe_board_info *db = netdev_priv(dev); struct rx_desc *rxptr; struct sk_buff *skb; rxptr = db->rx_insert_ptr; while(db->rx_avail_cnt < RX_DESC_CNT) { - if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL ) + if ( ( skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE) ) == NULL ) break; rxptr->rx_skb_ptr = skb; /* FIXME (?) */ rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data, diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c index 48b0b6566eef..fc4001f6a5e4 100644 --- a/drivers/net/ethernet/dec/tulip/uli526x.c +++ b/drivers/net/ethernet/dec/tulip/uli526x.c @@ -232,8 +232,8 @@ static irqreturn_t uli526x_interrupt(int, void *); #ifdef CONFIG_NET_POLL_CONTROLLER static void uli526x_poll(struct net_device *dev); #endif -static void uli526x_descriptor_init(struct uli526x_board_info *, unsigned long); -static void allocate_rx_buffer(struct uli526x_board_info *); +static void uli526x_descriptor_init(struct net_device *, unsigned long); +static void allocate_rx_buffer(struct net_device *); static void update_cr6(u32, unsigned long); static void send_filter_frame(struct net_device *, int); static u16 phy_read(unsigned long, u8, u8, u32); @@ -549,7 +549,7 @@ static void uli526x_init(struct net_device *dev) db->op_mode = db->media_mode; /* Force Mode */ /* Initialize Transmit/Receive decriptor and CR3/4 */ - uli526x_descriptor_init(db, ioaddr); + uli526x_descriptor_init(dev, ioaddr); /* Init CR6 to program M526X operation */ update_cr6(db->cr6_data, ioaddr); @@ -711,7 +711,7 @@ static irqreturn_t uli526x_interrupt(int irq, void *dev_id) /* reallocate rx descriptor buffer */ if (db->rx_avail_cntcr5_data & 0x01) @@ -844,7 +844,7 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info /* Good packet, send to upper layer */ /* Shorst packet used new SKB */ if ((rxlen < RX_COPY_SIZE) && - (((new_skb = dev_alloc_skb(rxlen + 2)) != NULL))) { + (((new_skb = netdev_alloc_skb(dev, rxlen + 2)) != NULL))) { skb = new_skb; /* size less than COPY_SIZE, allocate a rxlen SKB */ skb_reserve(skb, 2); /* 16byte align */ @@ -1289,8 +1289,9 @@ static void uli526x_reuse_skb(struct uli526x_board_info *db, struct sk_buff * sk * Using Chain structure, and allocate Tx/Rx buffer */ -static void uli526x_descriptor_init(struct uli526x_board_info *db, unsigned long ioaddr) +static void uli526x_descriptor_init(struct net_device *dev, unsigned long ioaddr) { + struct uli526x_board_info *db = netdev_priv(dev); struct tx_desc *tmp_tx; struct rx_desc *tmp_rx; unsigned char *tmp_buf; @@ -1343,7 +1344,7 @@ static void uli526x_descriptor_init(struct uli526x_board_info *db, unsigned long tmp_rx->next_rx_desc = db->first_rx_desc; /* pre-allocate Rx buffer */ - allocate_rx_buffer(db); + allocate_rx_buffer(dev); } @@ -1433,15 +1434,17 @@ static void send_filter_frame(struct net_device *dev, int mc_cnt) * As possible as allocate maxiumn Rx buffer */ -static void allocate_rx_buffer(struct uli526x_board_info *db) +static void allocate_rx_buffer(struct net_device *dev) { + struct uli526x_board_info *db = netdev_priv(dev); struct rx_desc *rxptr; struct sk_buff *skb; rxptr = db->rx_insert_ptr; while(db->rx_avail_cnt < RX_DESC_CNT) { - if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL ) + skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE); + if (skb == NULL) break; rxptr->rx_skb_ptr = skb; /* FIXME (?) */ rxptr->rdes2 = cpu_to_le32(pci_map_single(db->pdev, diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c index bee97033167d..1895605abb35 100644 --- a/drivers/net/ethernet/s6gmac.c +++ b/drivers/net/ethernet/s6gmac.c @@ -370,12 +370,13 @@ struct s6gmac { } link; }; -static void s6gmac_rx_fillfifo(struct s6gmac *pd) +static void s6gmac_rx_fillfifo(struct net_device *dev) { + struct s6gmac *pd = netdev_priv(dev); struct sk_buff *skb; while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) && (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) && - (skb = dev_alloc_skb(S6_MAX_FRLEN + 2))) { + (skb = netdev_alloc_skb(dev, S6_MAX_FRLEN + 2))) { pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb; s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan, pd->io, (u32)skb->data, S6_MAX_FRLEN); @@ -514,7 +515,7 @@ static irqreturn_t s6gmac_interrupt(int irq, void *dev_id) spin_lock(&pd->lock); if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan)) s6gmac_rx_interrupt(dev); - s6gmac_rx_fillfifo(pd); + s6gmac_rx_fillfifo(dev); if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan)) s6gmac_tx_interrupt(dev); s6gmac_stats_interrupt(pd, 0); @@ -894,7 +895,7 @@ static int s6gmac_open(struct net_device *dev) s6gmac_init_device(dev); s6gmac_init_stats(dev); s6gmac_init_dmac(dev); - s6gmac_rx_fillfifo(pd); + s6gmac_rx_fillfifo(dev); s6dmac_enable_chan(pd->rx_dma, pd->rx_chan, 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1); s6dmac_enable_chan(pd->tx_dma, pd->tx_chan, -- GitLab From 7d316b9453523498246e9e19a659c423d4c5081e Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 8 Feb 2012 00:19:45 +0000 Subject: [PATCH 0506/1846] af_iucv: remove IUCV-pathes completely A SEVER is missing in the callback of a receiving SEVERED. This may inhibit z/VM to remove the corresponding IUCV-path completely. This patch adds a SEVER in iucv_callback_connrej (together with additional locking. Signed-off-by: Ursula Braun Signed-off-by: Martin Schwidefsky Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- net/iucv/af_iucv.c | 71 ++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index d5c5b8fd1d01..3ce0259499ed 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -90,6 +90,7 @@ do { \ static void iucv_sock_kill(struct sock *sk); static void iucv_sock_close(struct sock *sk); +static void iucv_sever_path(struct sock *, int); static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); @@ -181,11 +182,7 @@ static int afiucv_pm_freeze(struct device *dev) case IUCV_DISCONN: case IUCV_CLOSING: case IUCV_CONNECTED: - if (iucv->path) { - err = pr_iucv->path_sever(iucv->path, NULL); - iucv_path_free(iucv->path); - iucv->path = NULL; - } + iucv_sever_path(sk, 0); break; case IUCV_OPEN: case IUCV_BOUND: @@ -194,6 +191,8 @@ static int afiucv_pm_freeze(struct device *dev) default: break; } + skb_queue_purge(&iucv->send_skb_q); + skb_queue_purge(&iucv->backlog_skb_q); } read_unlock(&iucv_sk_list.lock); return err; @@ -447,10 +446,29 @@ static void iucv_sock_kill(struct sock *sk) sock_put(sk); } +/* Terminate an IUCV path */ +static void iucv_sever_path(struct sock *sk, int with_user_data) +{ + unsigned char user_data[16]; + struct iucv_sock *iucv = iucv_sk(sk); + struct iucv_path *path = iucv->path; + + if (iucv->path) { + iucv->path = NULL; + if (with_user_data) { + low_nmcpy(user_data, iucv->src_name); + high_nmcpy(user_data, iucv->dst_name); + ASCEBC(user_data, sizeof(user_data)); + pr_iucv->path_sever(path, user_data); + } else + pr_iucv->path_sever(path, NULL); + iucv_path_free(path); + } +} + /* Close an IUCV socket */ static void iucv_sock_close(struct sock *sk) { - unsigned char user_data[16]; struct iucv_sock *iucv = iucv_sk(sk); unsigned long timeo; int err, blen; @@ -494,25 +512,14 @@ static void iucv_sock_close(struct sock *sk) sk->sk_state = IUCV_CLOSED; sk->sk_state_change(sk); - if (iucv->path) { - low_nmcpy(user_data, iucv->src_name); - high_nmcpy(user_data, iucv->dst_name); - ASCEBC(user_data, sizeof(user_data)); - pr_iucv->path_sever(iucv->path, user_data); - iucv_path_free(iucv->path); - iucv->path = NULL; - } - sk->sk_err = ECONNRESET; sk->sk_state_change(sk); iucv_skb_queue_purge(&iucv->send_skb_q); skb_queue_purge(&iucv->backlog_skb_q); - break; - default: - /* nothing to do here */ - break; + default: /* fall through */ + iucv_sever_path(sk, 1); } /* mark socket for deletion by iucv_sock_kill() */ @@ -894,11 +901,8 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr, if (sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_CLOSED) err = -ECONNREFUSED; - if (err && iucv->transport == AF_IUCV_TRANS_IUCV) { - pr_iucv->path_sever(iucv->path, NULL); - iucv_path_free(iucv->path); - iucv->path = NULL; - } + if (err && iucv->transport == AF_IUCV_TRANS_IUCV) + iucv_sever_path(sk, 0); done: release_sock(sk); @@ -1565,13 +1569,6 @@ static int iucv_sock_release(struct socket *sock) iucv_sock_close(sk); - /* Unregister with IUCV base support */ - if (iucv_sk(sk)->path) { - pr_iucv->path_sever(iucv_sk(sk)->path, NULL); - iucv_path_free(iucv_sk(sk)->path); - iucv_sk(sk)->path = NULL; - } - sock_orphan(sk); iucv_sock_kill(sk); return err; @@ -1750,8 +1747,7 @@ static int iucv_callback_connreq(struct iucv_path *path, path->msglim = iucv->msglimit; err = pr_iucv->path_accept(path, &af_iucv_handler, nuser_data, nsk); if (err) { - err = pr_iucv->path_sever(path, user_data); - iucv_path_free(path); + iucv_sever_path(nsk, 1); iucv_sock_kill(nsk); goto fail; } @@ -1828,6 +1824,7 @@ static void iucv_callback_txdone(struct iucv_path *path, struct sk_buff *list_skb = list->next; unsigned long flags; + bh_lock_sock(sk); if (!skb_queue_empty(list)) { spin_lock_irqsave(&list->lock, flags); @@ -1849,7 +1846,6 @@ static void iucv_callback_txdone(struct iucv_path *path, iucv_sock_wake_msglim(sk); } } - BUG_ON(!this); if (sk->sk_state == IUCV_CLOSING) { if (skb_queue_empty(&iucv_sk(sk)->send_skb_q)) { @@ -1857,6 +1853,7 @@ static void iucv_callback_txdone(struct iucv_path *path, sk->sk_state_change(sk); } } + bh_unlock_sock(sk); } @@ -1864,9 +1861,15 @@ static void iucv_callback_connrej(struct iucv_path *path, u8 ipuser[16]) { struct sock *sk = path->private; + if (sk->sk_state == IUCV_CLOSED) + return; + + bh_lock_sock(sk); + iucv_sever_path(sk, 1); sk->sk_state = IUCV_DISCONN; sk->sk_state_change(sk); + bh_unlock_sock(sk); } /* called if the other communication side shuts down its RECV direction; -- GitLab From 7f1b0ea42a800713a3d56e1e8ca1a845e0461ca2 Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 8 Feb 2012 00:19:46 +0000 Subject: [PATCH 0507/1846] af_iucv: block writing if msg limit is exceeded When polling on an AF_IUCV socket, writing should be blocked if the number of pending messages exceeds a defined limit. Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- net/iucv/af_iucv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 3ce0259499ed..ef6ab71921fc 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -1490,7 +1490,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock, if (sk->sk_state == IUCV_DISCONN) mask |= POLLIN; - if (sock_writeable(sk)) + if (sock_writeable(sk) && iucv_below_msglim(sk)) mask |= POLLOUT | POLLWRNORM | POLLWRBAND; else set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); -- GitLab From 800c5eb7b5eba6cb2a32738d763fd59f0fbcdde4 Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 8 Feb 2012 00:19:47 +0000 Subject: [PATCH 0508/1846] af_iucv: change net_device handling for HS transport This patch saves the net_device in the iucv_sock structure during bind in order to fasten skb sending. In addition some other small improvements are made for HS transport: - error checking when sending skbs - locking changes in afiucv_hs_callback_txnotify - skb freeing in afiucv_hs_callback_txnotify And finally it contains code cleanup to get rid of iucv_skb_queue_purge. Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- include/net/iucv/af_iucv.h | 1 + net/iucv/af_iucv.c | 119 +++++++++++++++++++------------------ 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h index 0954ec959159..a1517887aeac 100644 --- a/include/net/iucv/af_iucv.h +++ b/include/net/iucv/af_iucv.h @@ -113,6 +113,7 @@ struct iucv_sock { spinlock_t accept_q_lock; struct sock *parent; struct iucv_path *path; + struct net_device *hs_dev; struct sk_buff_head send_skb_q; struct sk_buff_head backlog_skb_q; struct sock_msg_q message_q; diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index ef6ab71921fc..fbce4a3126de 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -131,17 +131,6 @@ static inline void low_nmcpy(unsigned char *dst, char *src) memcpy(&dst[8], src, 8); } -static void iucv_skb_queue_purge(struct sk_buff_head *list) -{ - struct sk_buff *skb; - - while ((skb = skb_dequeue(list)) != NULL) { - if (skb->dev) - dev_put(skb->dev); - kfree_skb(skb); - } -} - static int afiucv_pm_prepare(struct device *dev) { #ifdef CONFIG_PM_DEBUG @@ -176,7 +165,7 @@ static int afiucv_pm_freeze(struct device *dev) read_lock(&iucv_sk_list.lock); sk_for_each(sk, node, &iucv_sk_list.head) { iucv = iucv_sk(sk); - iucv_skb_queue_purge(&iucv->send_skb_q); + skb_queue_purge(&iucv->send_skb_q); skb_queue_purge(&iucv->backlog_skb_q); switch (sk->sk_state) { case IUCV_DISCONN: @@ -337,7 +326,6 @@ static void iucv_sock_wake_msglim(struct sock *sk) static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, struct sk_buff *skb, u8 flags) { - struct net *net = sock_net(sock); struct iucv_sock *iucv = iucv_sk(sock); struct af_iucv_trans_hdr *phs_hdr; struct sk_buff *nskb; @@ -374,10 +362,10 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, if (imsg) memcpy(&phs_hdr->iucv_hdr, imsg, sizeof(struct iucv_message)); - skb->dev = dev_get_by_index(net, sock->sk_bound_dev_if); + skb->dev = iucv->hs_dev; if (!skb->dev) return -ENODEV; - if (!(skb->dev->flags & IFF_UP)) + if (!(skb->dev->flags & IFF_UP) || !netif_carrier_ok(skb->dev)) return -ENETDOWN; if (skb->len > skb->dev->mtu) { if (sock->sk_type == SOCK_SEQPACKET) @@ -392,15 +380,14 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, return -ENOMEM; skb_queue_tail(&iucv->send_skb_q, nskb); err = dev_queue_xmit(skb); - if (err) { + if (net_xmit_eval(err)) { skb_unlink(nskb, &iucv->send_skb_q); - dev_put(nskb->dev); kfree_skb(nskb); } else { atomic_sub(confirm_recv, &iucv->msg_recv); WARN_ON(atomic_read(&iucv->msg_recv) < 0); } - return err; + return net_xmit_eval(err); } static struct sock *__iucv_get_sock_by_name(char *nm) @@ -471,7 +458,8 @@ static void iucv_sock_close(struct sock *sk) { struct iucv_sock *iucv = iucv_sk(sk); unsigned long timeo; - int err, blen; + int err = 0; + int blen; struct sk_buff *skb; lock_sock(sk); @@ -498,7 +486,7 @@ static void iucv_sock_close(struct sock *sk) sk->sk_state = IUCV_CLOSING; sk->sk_state_change(sk); - if (!skb_queue_empty(&iucv->send_skb_q)) { + if (!err && !skb_queue_empty(&iucv->send_skb_q)) { if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) timeo = sk->sk_lingertime; else @@ -515,13 +503,19 @@ static void iucv_sock_close(struct sock *sk) sk->sk_err = ECONNRESET; sk->sk_state_change(sk); - iucv_skb_queue_purge(&iucv->send_skb_q); + skb_queue_purge(&iucv->send_skb_q); skb_queue_purge(&iucv->backlog_skb_q); default: /* fall through */ iucv_sever_path(sk, 1); } + if (iucv->hs_dev) { + dev_put(iucv->hs_dev); + iucv->hs_dev = NULL; + sk->sk_bound_dev_if = 0; + } + /* mark socket for deletion by iucv_sock_kill() */ sock_set_flag(sk, SOCK_ZAPPED); @@ -713,7 +707,6 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr, goto done_unlock; /* Bind the socket */ - if (pr_iucv) if (!memcmp(sa->siucv_user_id, iucv_userid, 8)) goto vm_bind; /* VM IUCV transport */ @@ -727,6 +720,8 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr, memcpy(iucv->src_name, sa->siucv_name, 8); memcpy(iucv->src_user_id, sa->siucv_user_id, 8); sk->sk_bound_dev_if = dev->ifindex; + iucv->hs_dev = dev; + dev_hold(dev); sk->sk_state = IUCV_BOUND; iucv->transport = AF_IUCV_TRANS_HIPER; if (!iucv->msglimit) @@ -1128,8 +1123,10 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, noblock, &err); else skb = sock_alloc_send_skb(sk, len, noblock, &err); - if (!skb) + if (!skb) { + err = -ENOMEM; goto out; + } if (iucv->transport == AF_IUCV_TRANS_HIPER) skb_reserve(skb, sizeof(struct af_iucv_trans_hdr) + ETH_HLEN); if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { @@ -1152,6 +1149,7 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, /* increment and save iucv message tag for msg_completion cbk */ txmsg.tag = iucv->send_tag++; memcpy(CB_TAG(skb), &txmsg.tag, CB_TAG_LEN); + if (iucv->transport == AF_IUCV_TRANS_HIPER) { atomic_inc(&iucv->msg_sent); err = afiucv_hs_send(&txmsg, sk, skb, 0); @@ -1206,8 +1204,6 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, return len; fail: - if (skb->dev) - dev_put(skb->dev); kfree_skb(skb); out: release_sock(sk); @@ -1400,7 +1396,14 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, } kfree_skb(skb); - atomic_inc(&iucv->msg_recv); + if (iucv->transport == AF_IUCV_TRANS_HIPER) { + atomic_inc(&iucv->msg_recv); + if (atomic_read(&iucv->msg_recv) > iucv->msglimit) { + WARN_ON(1); + iucv_sock_close(sk); + return -EFAULT; + } + } /* Queue backlog skbs */ spin_lock_bh(&iucv->message_q.lock); @@ -1957,6 +1960,8 @@ static int afiucv_hs_callback_syn(struct sock *sk, struct sk_buff *skb) memcpy(niucv->src_name, iucv->src_name, 8); memcpy(niucv->src_user_id, iucv->src_user_id, 8); nsk->sk_bound_dev_if = sk->sk_bound_dev_if; + niucv->hs_dev = iucv->hs_dev; + dev_hold(niucv->hs_dev); afiucv_swap_src_dest(skb); trans_hdr->flags = AF_IUCV_FLAG_SYN | AF_IUCV_FLAG_ACK; trans_hdr->window = niucv->msglimit; @@ -2025,12 +2030,15 @@ static int afiucv_hs_callback_fin(struct sock *sk, struct sk_buff *skb) struct iucv_sock *iucv = iucv_sk(sk); /* other end of connection closed */ - if (iucv) { - bh_lock_sock(sk); + if (!iucv) + goto out; + bh_lock_sock(sk); + if (sk->sk_state == IUCV_CONNECTED) { sk->sk_state = IUCV_DISCONN; sk->sk_state_change(sk); - bh_unlock_sock(sk); } + bh_unlock_sock(sk); +out: kfree_skb(skb); return NET_RX_SUCCESS; } @@ -2175,11 +2183,11 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, break; case (AF_IUCV_FLAG_WIN): err = afiucv_hs_callback_win(sk, skb); - if (skb->len > sizeof(struct af_iucv_trans_hdr)) - err = afiucv_hs_callback_rx(sk, skb); - else - kfree(skb); - break; + if (skb->len == sizeof(struct af_iucv_trans_hdr)) { + kfree_skb(skb); + break; + } + /* fall through */ case 0: /* plain data frame */ memcpy(CB_TRGCLS(skb), &trans_hdr->iucv_hdr.class, @@ -2205,65 +2213,64 @@ static void afiucv_hs_callback_txnotify(struct sk_buff *skb, struct iucv_sock *iucv = NULL; struct sk_buff_head *list; struct sk_buff *list_skb; - struct sk_buff *this = NULL; + struct sk_buff *nskb; unsigned long flags; struct hlist_node *node; - read_lock(&iucv_sk_list.lock); + read_lock_irqsave(&iucv_sk_list.lock, flags); sk_for_each(sk, node, &iucv_sk_list.head) if (sk == isk) { iucv = iucv_sk(sk); break; } - read_unlock(&iucv_sk_list.lock); + read_unlock_irqrestore(&iucv_sk_list.lock, flags); - if (!iucv) + if (!iucv || sock_flag(sk, SOCK_ZAPPED)) return; - bh_lock_sock(sk); list = &iucv->send_skb_q; - list_skb = list->next; + spin_lock_irqsave(&list->lock, flags); if (skb_queue_empty(list)) goto out_unlock; - - spin_lock_irqsave(&list->lock, flags); + list_skb = list->next; + nskb = list_skb->next; while (list_skb != (struct sk_buff *)list) { if (skb_shinfo(list_skb) == skb_shinfo(skb)) { - this = list_skb; switch (n) { case TX_NOTIFY_OK: - __skb_unlink(this, list); + __skb_unlink(list_skb, list); + kfree_skb(list_skb); iucv_sock_wake_msglim(sk); - dev_put(this->dev); - kfree_skb(this); break; case TX_NOTIFY_PENDING: atomic_inc(&iucv->pendings); break; case TX_NOTIFY_DELAYED_OK: - __skb_unlink(this, list); + __skb_unlink(list_skb, list); atomic_dec(&iucv->pendings); if (atomic_read(&iucv->pendings) <= 0) iucv_sock_wake_msglim(sk); - dev_put(this->dev); - kfree_skb(this); + kfree_skb(list_skb); break; case TX_NOTIFY_UNREACHABLE: case TX_NOTIFY_DELAYED_UNREACHABLE: case TX_NOTIFY_TPQFULL: /* not yet used */ case TX_NOTIFY_GENERALERROR: case TX_NOTIFY_DELAYED_GENERALERROR: - __skb_unlink(this, list); - dev_put(this->dev); - kfree_skb(this); - sk->sk_state = IUCV_DISCONN; - sk->sk_state_change(sk); + __skb_unlink(list_skb, list); + kfree_skb(list_skb); + if (sk->sk_state == IUCV_CONNECTED) { + sk->sk_state = IUCV_DISCONN; + sk->sk_state_change(sk); + } break; } break; } - list_skb = list_skb->next; + list_skb = nskb; + nskb = nskb->next; } +out_unlock: spin_unlock_irqrestore(&list->lock, flags); if (sk->sk_state == IUCV_CLOSING) { @@ -2273,8 +2280,6 @@ static void afiucv_hs_callback_txnotify(struct sk_buff *skb, } } -out_unlock: - bh_unlock_sock(sk); } static const struct proto_ops iucv_sock_ops = { .family = PF_IUCV, -- GitLab From 51363b8751a673a00ad48eea895266396d53fa52 Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 8 Feb 2012 00:19:48 +0000 Subject: [PATCH 0509/1846] af_iucv: allow retrieval of maximum message size For HS transport the maximum message size depends on the MTU-size of the HS-device bound to the AF_IUCV socket. This patch adds a getsockopt option MSGSIZE returning the maximum message size that can be handled for this AF_IUCV socket. Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- include/net/iucv/af_iucv.h | 1 + net/iucv/af_iucv.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h index a1517887aeac..2e1d5ecc2d1b 100644 --- a/include/net/iucv/af_iucv.h +++ b/include/net/iucv/af_iucv.h @@ -132,6 +132,7 @@ struct iucv_sock { /* iucv socket options (SOL_IUCV) */ #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ +#define SO_MSGSIZE 0x0800 /* get maximum msgsize */ /* iucv related control messages (scm) */ #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index fbce4a3126de..98d1f0ba7fe9 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -1633,7 +1633,8 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; struct iucv_sock *iucv = iucv_sk(sk); - int val, len; + unsigned int val; + int len; if (level != SOL_IUCV) return -ENOPROTOOPT; @@ -1656,6 +1657,13 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname, : iucv->msglimit; /* default */ release_sock(sk); break; + case SO_MSGSIZE: + if (sk->sk_state == IUCV_OPEN) + return -EBADFD; + val = (iucv->hs_dev) ? iucv->hs_dev->mtu - + sizeof(struct af_iucv_trans_hdr) - ETH_HLEN : + 0x7fffffff; + break; default: return -ENOPROTOOPT; } -- GitLab From c3ab96f36aa308fa5bf432d5a4dafc80b7373805 Mon Sep 17 00:00:00 2001 From: Frank Blaschka Date: Wed, 8 Feb 2012 00:19:49 +0000 Subject: [PATCH 0510/1846] qeth: add query OSA address table support Add qeth device private ioctl to query the OSA address table. This helps debugging hw related problems. Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- arch/s390/include/asm/qeth.h | 7 +++ drivers/s390/net/qeth_core.h | 1 + drivers/s390/net/qeth_core_main.c | 99 +++++++++++++++++++++++++++++++ drivers/s390/net/qeth_core_mpc.h | 13 ++++ drivers/s390/net/qeth_l2_main.c | 3 + drivers/s390/net/qeth_l3_main.c | 3 + 6 files changed, 126 insertions(+) diff --git a/arch/s390/include/asm/qeth.h b/arch/s390/include/asm/qeth.h index 90efda0b137d..2c7c898c03e4 100644 --- a/arch/s390/include/asm/qeth.h +++ b/arch/s390/include/asm/qeth.h @@ -20,6 +20,7 @@ #define SIOC_QETH_ARP_FLUSH_CACHE (SIOCDEVPRIVATE + 4) #define SIOC_QETH_ADP_SET_SNMP_CONTROL (SIOCDEVPRIVATE + 5) #define SIOC_QETH_GET_CARD_TYPE (SIOCDEVPRIVATE + 6) +#define SIOC_QETH_QUERY_OAT (SIOCDEVPRIVATE + 7) struct qeth_arp_cache_entry { __u8 macaddr[6]; @@ -107,4 +108,10 @@ struct qeth_arp_query_user_data { char *entries; } __attribute__((packed)); +struct qeth_query_oat_data { + __u32 command; + __u32 buffer_len; + __u32 response_len; + __u64 ptr; +}; #endif /* __ASM_S390_QETH_IOCTL_H__ */ diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 4abc79d3963f..ec7921b5138e 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -906,6 +906,7 @@ void qeth_prepare_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *, char); struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *); int qeth_mdio_read(struct net_device *, int, int); int qeth_snmp_command(struct qeth_card *, char __user *); +int qeth_query_oat_command(struct qeth_card *, char __user *); struct qeth_cmd_buffer *qeth_get_adapter_cmd(struct qeth_card *, __u32, __u32); int qeth_default_setadapterparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long); diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 9c3f38da4c01..0565584b52c3 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "qeth_core.h" @@ -4402,6 +4403,104 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata) } EXPORT_SYMBOL_GPL(qeth_snmp_command); +static int qeth_setadpparms_query_oat_cb(struct qeth_card *card, + struct qeth_reply *reply, unsigned long data) +{ + struct qeth_ipa_cmd *cmd; + struct qeth_qoat_priv *priv; + char *resdata; + int resdatalen; + + QETH_CARD_TEXT(card, 3, "qoatcb"); + + cmd = (struct qeth_ipa_cmd *)data; + priv = (struct qeth_qoat_priv *)reply->param; + resdatalen = cmd->data.setadapterparms.hdr.cmdlength; + resdata = (char *)data + 28; + + if (resdatalen > (priv->buffer_len - priv->response_len)) { + cmd->hdr.return_code = IPA_RC_FFFF; + return 0; + } + + memcpy((priv->buffer + priv->response_len), resdata, + resdatalen); + priv->response_len += resdatalen; + + if (cmd->data.setadapterparms.hdr.seq_no < + cmd->data.setadapterparms.hdr.used_total) + return 1; + return 0; +} + +int qeth_query_oat_command(struct qeth_card *card, char __user *udata) +{ + int rc = 0; + struct qeth_cmd_buffer *iob; + struct qeth_ipa_cmd *cmd; + struct qeth_query_oat *oat_req; + struct qeth_query_oat_data oat_data; + struct qeth_qoat_priv priv; + void __user *tmp; + + QETH_CARD_TEXT(card, 3, "qoatcmd"); + + if (!qeth_adp_supported(card, IPA_SETADP_QUERY_OAT)) { + rc = -EOPNOTSUPP; + goto out; + } + + if (copy_from_user(&oat_data, udata, + sizeof(struct qeth_query_oat_data))) { + rc = -EFAULT; + goto out; + } + + priv.buffer_len = oat_data.buffer_len; + priv.response_len = 0; + priv.buffer = kzalloc(oat_data.buffer_len, GFP_KERNEL); + if (!priv.buffer) { + rc = -ENOMEM; + goto out; + } + + iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_OAT, + sizeof(struct qeth_ipacmd_setadpparms_hdr) + + sizeof(struct qeth_query_oat)); + cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); + oat_req = &cmd->data.setadapterparms.data.query_oat; + oat_req->subcmd_code = oat_data.command; + + rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_query_oat_cb, + &priv); + if (!rc) { + if (is_compat_task()) + tmp = compat_ptr(oat_data.ptr); + else + tmp = (void __user *)(unsigned long)oat_data.ptr; + + if (copy_to_user(tmp, priv.buffer, + priv.response_len)) { + rc = -EFAULT; + goto out_free; + } + + oat_data.response_len = priv.response_len; + + if (copy_to_user(udata, &oat_data, + sizeof(struct qeth_query_oat_data))) + rc = -EFAULT; + } else + if (rc == IPA_RC_FFFF) + rc = -EFAULT; + +out_free: + kfree(priv.buffer); +out: + return rc; +} +EXPORT_SYMBOL_GPL(qeth_query_oat_command); + static inline int qeth_get_qdio_q_format(struct qeth_card *card) { switch (card->info.type) { diff --git a/drivers/s390/net/qeth_core_mpc.h b/drivers/s390/net/qeth_core_mpc.h index e5a9d1c03839..578e19a2de6b 100644 --- a/drivers/s390/net/qeth_core_mpc.h +++ b/drivers/s390/net/qeth_core_mpc.h @@ -249,6 +249,7 @@ enum qeth_ipa_setadp_cmd { IPA_SETADP_SET_PROMISC_MODE = 0x00000800L, IPA_SETADP_SET_DIAG_ASSIST = 0x00002000L, IPA_SETADP_SET_ACCESS_CONTROL = 0x00010000L, + IPA_SETADP_QUERY_OAT = 0x00080000L, }; enum qeth_ipa_mac_ops { CHANGE_ADDR_READ_MAC = 0, @@ -398,6 +399,17 @@ struct qeth_set_access_ctrl { __u32 subcmd_code; } __attribute__((packed)); +struct qeth_query_oat { + __u32 subcmd_code; + __u8 reserved[12]; +} __packed; + +struct qeth_qoat_priv { + __u32 buffer_len; + __u32 response_len; + char *buffer; +}; + struct qeth_ipacmd_setadpparms_hdr { __u32 supp_hw_cmds; __u32 reserved1; @@ -417,6 +429,7 @@ struct qeth_ipacmd_setadpparms { struct qeth_change_addr change_addr; struct qeth_snmp_cmd snmp; struct qeth_set_access_ctrl set_access_ctrl; + struct qeth_query_oat query_oat; __u32 mode; } data; } __attribute__ ((packed)); diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index c12967133114..e5c9cf15e5c6 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -75,6 +75,9 @@ static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) mii_data->val_out = qeth_mdio_read(dev, mii_data->phy_id, mii_data->reg_num); break; + case SIOC_QETH_QUERY_OAT: + rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data); + break; default: rc = -EOPNOTSUPP; } diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 25cd3799a76c..73bf8889984b 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -2745,6 +2745,9 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) mii_data->phy_id, mii_data->reg_num); break; + case SIOC_QETH_QUERY_OAT: + rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data); + break; default: rc = -EOPNOTSUPP; } -- GitLab From 039055b965b9cfbeacb8cdcd1ef57e18b6374e58 Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 8 Feb 2012 00:19:50 +0000 Subject: [PATCH 0511/1846] qeth: add wake_up on write channel To send commands on the write channel 8 buffers exist. If all 8 buffers are used, a wait is triggered on the write channel. When such buffer are freed, a wake_up is needed. This patch adds the missing wake_up in qeth_release_buffer(). This fix is especially important when running Communications Controller for Linux on System z. Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 0565584b52c3..cbb101828dc3 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -678,6 +678,7 @@ void qeth_release_buffer(struct qeth_channel *channel, iob->callback = qeth_send_control_data_cb; iob->rc = 0; spin_unlock_irqrestore(&channel->iob_lock, flags); + wake_up(&channel->wait_q); } EXPORT_SYMBOL_GPL(qeth_release_buffer); -- GitLab From a584b7ae4ef01425f6827657abdc3e4db49b3578 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 7 Feb 2012 23:23:36 +0000 Subject: [PATCH 0512/1846] netxen_nic: signedness bug in netxen_md_entry_err_chk() "esize" should be signed because it can be negative here. For example, when we call it in netxen_parse_md_template(), it could be -1 from the return value of netxen_md_L2Cache(). Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c index 0a8122851025..6f37470750f3 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c @@ -2354,7 +2354,7 @@ netxen_md_rdqueue(struct netxen_adapter *adapter, */ static int netxen_md_entry_err_chk(struct netxen_adapter *adapter, - struct netxen_minidump_entry *entry, u32 esize) + struct netxen_minidump_entry *entry, int esize) { if (esize < 0) { entry->hdr.driver_flags |= NX_DUMP_SKIP; -- GitLab From 0cb1f4b96092b9d91d4e50d5c77b424745cd1102 Mon Sep 17 00:00:00 2001 From: Jeffrey Huang Date: Wed, 8 Feb 2012 17:33:56 +0000 Subject: [PATCH 0513/1846] cnic: set error flag when iSCSI connection fails to speed up error recovery due to SPQ failures. The error flag will expedite the recovery process by skipping the timeouts. Signed-off-by: Jeffrey Huang Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/cnic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index 7381460142e6..e2365609a0be 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c @@ -3927,6 +3927,8 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) case L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE: if (l4kcqe->status == 0) set_bit(SK_F_OFFLD_COMPLETE, &csk->flags); + else if (l4kcqe->status == L4_KCQE_COMPLETION_STATUS_NIC_ERROR) + set_bit(SK_F_HW_ERR, &csk->flags); smp_mb__before_clear_bit(); clear_bit(SK_F_OFFLD_SCHED, &csk->flags); -- GitLab From 4cbbb04dc115423682349aa7466c8aeead825140 Mon Sep 17 00:00:00 2001 From: Eddie Wai Date: Wed, 8 Feb 2012 17:33:57 +0000 Subject: [PATCH 0514/1846] cnic: Update VLAN ID during ISCSI_UEVENT_PATH_UPDATE This will support the new VLAN attribute in the iSCSI iface file. Signed-off-by: Eddie Wai Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/cnic.c | 2 ++ drivers/net/ethernet/broadcom/cnic_if.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index e2365609a0be..df429959abdd 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c @@ -380,6 +380,8 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, if (cnic_in_use(csk) && test_bit(SK_F_CONNECT_START, &csk->flags)) { + csk->vlan_id = path_resp->vlan_id; + memcpy(csk->ha, path_resp->mac_addr, 6); if (test_bit(SK_F_IPV6, &csk->flags)) memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, diff --git a/drivers/net/ethernet/broadcom/cnic_if.h b/drivers/net/ethernet/broadcom/cnic_if.h index 1517763d4e55..60deb84d36bd 100644 --- a/drivers/net/ethernet/broadcom/cnic_if.h +++ b/drivers/net/ethernet/broadcom/cnic_if.h @@ -12,8 +12,8 @@ #ifndef CNIC_IF_H #define CNIC_IF_H -#define CNIC_MODULE_VERSION "2.5.8" -#define CNIC_MODULE_RELDATE "Jan 3, 2012" +#define CNIC_MODULE_VERSION "2.5.9" +#define CNIC_MODULE_RELDATE "Feb 8, 2012" #define CNIC_ULP_RDMA 0 #define CNIC_ULP_ISCSI 1 -- GitLab From 12325280dfeba18164f9c47e226a40ab34e23ee7 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 9 Feb 2012 14:48:25 -0500 Subject: [PATCH 0515/1846] rtlwifi: Modify rtl_pci_init to return 0 on success Fixes problem where caller would think routine succeeded when it failed leading to divide by zero panic. (This also reverts an earlier attempt, commit 42bc0c97 "rtlwifi: Return correct failure code on error". -- JWL) Signed-off-by: Simon Graham Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 8a941b588a41..07dd38efe62a 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -1492,10 +1492,10 @@ static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "tx ring initialization failed\n"); - return 0; + return err; } - return 1; + return 0; } static int rtl_pci_start(struct ieee80211_hw *hw) @@ -1866,7 +1866,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, } /* Init PCI sw */ - err = !rtl_pci_init(hw, pdev); + err = rtl_pci_init(hw, pdev); if (err) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Failed to init PCI\n"); goto fail3; -- GitLab From 4bcf053baf6b255e8c82c7ecd0d15954adb0379b Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:59 +0000 Subject: [PATCH 0516/1846] e1000e: remove test that is always false warning: comparison of unsigned expression < 0 is always false Remove an unnecessary test that is reported when compiling driver with W=1. The test is unnecessary because Intel wired GbE hardware older (i.e. less) than 82571 is not supported by this driver. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index e1cf1072f318..33d1b9e3c8d8 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -174,8 +174,8 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) if (ret_val) goto out; - /* not supported on older hardware or 82573 */ - if ((hw->mac.type < e1000_82571) || (hw->mac.type == e1000_82573)) + /* not supported on 82573 */ + if (hw->mac.type == e1000_82573) goto out; ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, -- GitLab From fe1e980f24697edb7d4e17cd74bbeae4a0388525 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 06:37:54 +0000 Subject: [PATCH 0517/1846] e1000e: remove unnecessary returns from void functions ...and convert some goto's which simply return to just return. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 3 --- drivers/net/ethernet/intel/e1000e/mac.c | 8 ++------ drivers/net/ethernet/intel/e1000e/netdev.c | 7 ++----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 5061d4ded6e2..942f4da86fb8 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1762,7 +1762,6 @@ static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate) extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG; ew32(EXTCNF_CTRL, extcnf_ctrl); - return; } /** @@ -3768,8 +3767,6 @@ void e1000_resume_workarounds_pchlan(struct e1000_hw *hw) release: hw->phy.ops.release(hw); - - return; } /** diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 33d1b9e3c8d8..be8335aead5e 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -1661,7 +1661,7 @@ void e1000e_reset_adaptive(struct e1000_hw *hw) if (!mac->adaptive_ifs) { e_dbg("Not in Adaptive IFS mode!\n"); - goto out; + return; } mac->current_ifs_val = 0; @@ -1672,8 +1672,6 @@ void e1000e_reset_adaptive(struct e1000_hw *hw) mac->in_ifs_mode = false; ew32(AIT, 0); -out: - return; } /** @@ -1689,7 +1687,7 @@ void e1000e_update_adaptive(struct e1000_hw *hw) if (!mac->adaptive_ifs) { e_dbg("Not in Adaptive IFS mode!\n"); - goto out; + return; } if ((mac->collision_delta * mac->ifs_ratio) > mac->tx_packet_delta) { @@ -1712,6 +1710,4 @@ void e1000e_update_adaptive(struct e1000_hw *hw) ew32(AIT, 0); } } -out: - return; } diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 293a7606e0f4..7ccd5f3cef61 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -221,7 +221,7 @@ static void e1000e_dump(struct e1000_adapter *adapter) /* Print Tx Ring Summary */ if (!netdev || !netif_running(netdev)) - goto exit; + return; dev_info(&adapter->pdev->dev, "Tx Ring Summary\n"); pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n"); @@ -308,7 +308,7 @@ static void e1000e_dump(struct e1000_adapter *adapter) /* Print Rx Ring */ if (!netif_msg_rx_status(adapter)) - goto exit; + return; dev_info(&adapter->pdev->dev, "Rx Ring Dump\n"); switch (adapter->rx_ps_pages) { @@ -449,9 +449,6 @@ static void e1000e_dump(struct e1000_adapter *adapter) } } } - -exit: - return; } /** -- GitLab From 668018d74762741c3fe5a54f0eea1bd65dcabd7e Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 07:02:56 +0000 Subject: [PATCH 0518/1846] e1000e: remove unnecessary parentheses Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/82571.c | 2 +- drivers/net/ethernet/intel/e1000e/ethtool.c | 4 ++-- drivers/net/ethernet/intel/e1000e/mac.c | 6 +++--- drivers/net/ethernet/intel/e1000e/manage.c | 2 +- drivers/net/ethernet/intel/e1000e/phy.c | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 4cadcc76ad58..7ef4711a32b8 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1865,7 +1865,7 @@ static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw) struct e1000_phy_info *phy = &hw->phy; struct e1000_mac_info *mac = &hw->mac; - if (!(phy->ops.check_reset_block)) + if (!phy->ops.check_reset_block) return; /* If the management interface is not enabled, then power down */ diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index f4dc0fa9d9b5..b1f5d7491b57 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -1088,7 +1088,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) tx_ring->buffer_info = kcalloc(tx_ring->count, sizeof(struct e1000_buffer), GFP_KERNEL); - if (!(tx_ring->buffer_info)) { + if (!tx_ring->buffer_info) { ret_val = 1; goto err_nomem; } @@ -1150,7 +1150,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) rx_ring->buffer_info = kcalloc(rx_ring->count, sizeof(struct e1000_buffer), GFP_KERNEL); - if (!(rx_ring->buffer_info)) { + if (!rx_ring->buffer_info) { ret_val = 5; goto err_nomem; } diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index be8335aead5e..0d63c3e1971d 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -511,8 +511,8 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw) * was just plugged in. The autoneg_failed flag does this. */ /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ - if ((ctrl & E1000_CTRL_SWDPIN1) && (!(status & E1000_STATUS_LU)) && - (!(rxcw & E1000_RXCW_C))) { + if ((ctrl & E1000_CTRL_SWDPIN1) && !(status & E1000_STATUS_LU) && + !(rxcw & E1000_RXCW_C)) { if (mac->autoneg_failed == 0) { mac->autoneg_failed = 1; return 0; @@ -577,7 +577,7 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) * time to complete. */ /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ - if ((!(status & E1000_STATUS_LU)) && (!(rxcw & E1000_RXCW_C))) { + if (!(status & E1000_STATUS_LU) && !(rxcw & E1000_RXCW_C)) { if (mac->autoneg_failed == 0) { mac->autoneg_failed = 1; return 0; diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c index 6594dbf248b4..c54caf6e5801 100644 --- a/drivers/net/ethernet/intel/e1000e/manage.c +++ b/drivers/net/ethernet/intel/e1000e/manage.c @@ -78,7 +78,7 @@ static s32 e1000_mng_enable_host_if(struct e1000_hw *hw) u32 hicr; u8 i; - if (!(hw->mac.arc_subsystem_valid)) { + if (!hw->mac.arc_subsystem_valid) { e_dbg("ARC subsystem not valid.\n"); return -E1000_ERR_HOST_INTERFACE_COMMAND; } diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 8dd2ff03f1f7..e8ad0804702f 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -132,7 +132,7 @@ s32 e1000e_get_phy_id(struct e1000_hw *hw) u16 phy_id; u16 retry_count = 0; - if (!(phy->ops.read_reg)) + if (!phy->ops.read_reg) goto out; while (retry_count < 2) { @@ -382,7 +382,7 @@ static s32 __e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, s32 ret_val = 0; if (!locked) { - if (!(hw->phy.ops.acquire)) + if (!hw->phy.ops.acquire) goto out; ret_val = hw->phy.ops.acquire(hw); @@ -453,7 +453,7 @@ static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, s32 ret_val = 0; if (!locked) { - if (!(hw->phy.ops.acquire)) + if (!hw->phy.ops.acquire) goto out; ret_val = hw->phy.ops.acquire(hw); @@ -526,7 +526,7 @@ static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, s32 ret_val = 0; if (!locked) { - if (!(hw->phy.ops.acquire)) + if (!hw->phy.ops.acquire) goto out; ret_val = hw->phy.ops.acquire(hw); @@ -599,7 +599,7 @@ static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, s32 ret_val = 0; if (!locked) { - if (!(hw->phy.ops.acquire)) + if (!hw->phy.ops.acquire) goto out; ret_val = hw->phy.ops.acquire(hw); -- GitLab From 07914ee3ccbf93ce688f1aaba15d8b01f19c5d77 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Tue, 31 Jan 2012 07:03:02 +0000 Subject: [PATCH 0519/1846] e1000e: use true/false for bool autoneg_false v2 - replaced mac->autoneg_failed == false with !mac->autoneg_failed Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/mac.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 0d63c3e1971d..83f93684dc2f 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -513,8 +513,8 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw) /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ if ((ctrl & E1000_CTRL_SWDPIN1) && !(status & E1000_STATUS_LU) && !(rxcw & E1000_RXCW_C)) { - if (mac->autoneg_failed == 0) { - mac->autoneg_failed = 1; + if (!mac->autoneg_failed) { + mac->autoneg_failed = true; return 0; } e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n"); @@ -578,8 +578,8 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) */ /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ if (!(status & E1000_STATUS_LU) && !(rxcw & E1000_RXCW_C)) { - if (mac->autoneg_failed == 0) { - mac->autoneg_failed = 1; + if (!mac->autoneg_failed) { + mac->autoneg_failed = true; return 0; } e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n"); @@ -855,7 +855,7 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw) } if (i == FIBER_LINK_UP_LIMIT) { e_dbg("Never got a valid link from auto-neg!!!\n"); - mac->autoneg_failed = 1; + mac->autoneg_failed = true; /* * AutoNeg failed to achieve a link, so we'll call * mac->check_for_link. This routine will force the @@ -867,9 +867,9 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw) e_dbg("Error while checking for link\n"); return ret_val; } - mac->autoneg_failed = 0; + mac->autoneg_failed = false; } else { - mac->autoneg_failed = 0; + mac->autoneg_failed = false; e_dbg("Valid Link Found\n"); } -- GitLab From ec34c170da8798f521f0d40cad54580ff93cea3a Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 1 Feb 2012 10:53:05 +0000 Subject: [PATCH 0520/1846] e1000e: pass pointer to hw struct for e1000_init_mac_params_XXX() The e1000_init_mac_params_XXX() functions (where XXX is one of the three MAC-family types 80003es2lan, 82571 and ich8lan) was not meant to require a pointer to the adapter struct but does require a pointer to the hw struct. Pass that pointer in to the functions instead. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 7 +++---- drivers/net/ethernet/intel/e1000e/82571.c | 7 +++---- drivers/net/ethernet/intel/e1000e/ich8lan.c | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 9b969615b72a..cfb361e5f498 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -201,13 +201,12 @@ static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw) * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs. * @hw: pointer to the HW structure **/ -static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) +static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw) { - struct e1000_hw *hw = &adapter->hw; struct e1000_mac_info *mac = &hw->mac; /* Set media type and media-dependent function pointers */ - switch (adapter->pdev->device) { + switch (hw->adapter->pdev->device) { case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: hw->phy.media_type = e1000_media_type_internal_serdes; mac->ops.check_for_link = e1000e_check_for_serdes_link; @@ -246,7 +245,7 @@ static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter) struct e1000_hw *hw = &adapter->hw; s32 rc; - rc = e1000_init_mac_params_80003es2lan(adapter); + rc = e1000_init_mac_params_80003es2lan(hw); if (rc) return rc; diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 7ef4711a32b8..795c3d640615 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -235,16 +235,15 @@ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw) * e1000_init_mac_params_82571 - Init MAC func ptrs. * @hw: pointer to the HW structure **/ -static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) +static s32 e1000_init_mac_params_82571(struct e1000_hw *hw) { - struct e1000_hw *hw = &adapter->hw; struct e1000_mac_info *mac = &hw->mac; u32 swsm = 0; u32 swsm2 = 0; bool force_clear_smbi = false; /* Set media type and media-dependent function pointers */ - switch (adapter->pdev->device) { + switch (hw->adapter->pdev->device) { case E1000_DEV_ID_82571EB_FIBER: case E1000_DEV_ID_82572EI_FIBER: case E1000_DEV_ID_82571EB_QUAD_FIBER: @@ -371,7 +370,7 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; s32 rc; - rc = e1000_init_mac_params_82571(adapter); + rc = e1000_init_mac_params_82571(hw); if (rc) return rc; diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 942f4da86fb8..112d55f76b79 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -553,9 +553,8 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) * Initialize family-specific MAC parameters and function * pointers. **/ -static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter) +static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw) { - struct e1000_hw *hw = &adapter->hw; struct e1000_mac_info *mac = &hw->mac; /* Set media type function pointer */ @@ -775,7 +774,7 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) struct e1000_hw *hw = &adapter->hw; s32 rc; - rc = e1000_init_mac_params_ich8lan(adapter); + rc = e1000_init_mac_params_ich8lan(hw); if (rc) return rc; -- GitLab From f92518ddec7ce0ef2f7e91ae5f07e0a9e19055bf Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 1 Feb 2012 11:16:42 +0000 Subject: [PATCH 0521/1846] e1000e: replace '1' with 'true' for boolean get_link_status Signed-off-by: Bruce Allan Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 6 +++--- drivers/net/ethernet/intel/e1000e/phy.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 7ccd5f3cef61..f868fb822a30 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1652,7 +1652,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data) */ if (icr & E1000_ICR_LSC) { - hw->mac.get_link_status = 1; + hw->mac.get_link_status = true; /* * ICH8 workaround-- Call gig speed drop workaround on cable * disconnect (LSC) before accessing any PHY registers @@ -1718,7 +1718,7 @@ static irqreturn_t e1000_intr(int irq, void *data) */ if (icr & E1000_ICR_LSC) { - hw->mac.get_link_status = 1; + hw->mac.get_link_status = true; /* * ICH8 workaround-- Call gig speed drop workaround on cable * disconnect (LSC) before accessing any PHY registers @@ -1775,7 +1775,7 @@ static irqreturn_t e1000_msix_other(int irq, void *data) if (icr & E1000_ICR_OTHER) { if (!(icr & E1000_ICR_LSC)) goto no_link_interrupt; - hw->mac.get_link_status = 1; + hw->mac.get_link_status = true; /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) mod_timer(&adapter->watchdog_timer, jiffies + 1); diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index e8ad0804702f..6f44c3fb80b6 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1141,7 +1141,7 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw) } } - hw->mac.get_link_status = 1; + hw->mac.get_link_status = true; return ret_val; } -- GitLab From d9dd966d7fc088a6bed991c2b1e2fba4485e0a31 Mon Sep 17 00:00:00 2001 From: Emil Tantilov Date: Sat, 28 Jan 2012 08:10:35 +0000 Subject: [PATCH 0522/1846] igb: fix warning about unused function This patch fixes a warning about unused function when CONFIG_PM_SLEEP is not selected in the kernel config: igb_main.c: warning: `igb_suspend` defined but not used [W-unused-function] Signed-off-by: Emil Tantilov Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/igb/igb_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index e91d73c8aa4e..fd911cac1ac5 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -173,7 +173,9 @@ static int igb_check_vf_assignment(struct igb_adapter *adapter); #endif #ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int igb_suspend(struct device *); +#endif static int igb_resume(struct device *); #ifdef CONFIG_PM_RUNTIME static int igb_runtime_suspend(struct device *dev); @@ -6709,6 +6711,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake, } #ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int igb_suspend(struct device *dev) { int retval; @@ -6728,6 +6731,7 @@ static int igb_suspend(struct device *dev) return 0; } +#endif /* CONFIG_PM_SLEEP */ static int igb_resume(struct device *dev) { -- GitLab From 4c1975d77b73feed7161999aab4cc64c1ae7155c Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 31 Jan 2012 02:59:23 +0000 Subject: [PATCH 0523/1846] ixgbe: Minor refactor of RSC This change addresses several issue. First I had left the use of the next and prev skb pointers floating around in the code and they were overdue to be pulled since I had rewritten the RSC code in the out-of-tree driver some time ago to address issues brought up by David Miller in regards to this. I am also now defaulting to always leaving the first buffer unmapped on any packet and then unmapping it after we read the EOP descriptor. This allows a simplification of the path with less branching. Instead of counting packets received the code was changed some time ago to track the number of buffers received. This leads to inaccurate counting when you compare numbers of packets received by the hardware versus what is tracked by the software. To correct this I am revising things so that the append_cnt value for RSC accurately tracks the number of frames received. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 10 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 235 +++++++++++------- 2 files changed, 147 insertions(+), 98 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index e6aeb64105a4..fca055362847 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -535,12 +535,16 @@ enum ixbge_state_t { __IXGBE_IN_SFP_INIT, }; -struct ixgbe_rsc_cb { +struct ixgbe_cb { + union { /* Union defining head/tail partner */ + struct sk_buff *head; + struct sk_buff *tail; + }; dma_addr_t dma; - u16 skb_cnt; + u16 append_cnt; bool delay_unmap; }; -#define IXGBE_RSC_CB(skb) ((struct ixgbe_rsc_cb *)(skb)->cb) +#define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb) enum ixgbe_boards { board_82598, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index ecc46ce8b2c3..18e474c25e61 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1207,40 +1207,96 @@ static inline u16 ixgbe_get_hlen(union ixgbe_adv_rx_desc *rx_desc) } /** - * ixgbe_transform_rsc_queue - change rsc queue into a full packet - * @skb: pointer to the last skb in the rsc queue + * ixgbe_merge_active_tail - merge active tail into lro skb + * @tail: pointer to active tail in frag_list * - * This function changes a queue full of hw rsc buffers into a completed - * packet. It uses the ->prev pointers to find the first packet and then - * turns it into the frag list owner. + * This function merges the length and data of an active tail into the + * skb containing the frag_list. It resets the tail's pointer to the head, + * but it leaves the heads pointer to tail intact. **/ -static inline struct sk_buff *ixgbe_transform_rsc_queue(struct sk_buff *skb) +static inline struct sk_buff *ixgbe_merge_active_tail(struct sk_buff *tail) { - unsigned int frag_list_size = 0; - unsigned int skb_cnt = 1; + struct sk_buff *head = IXGBE_CB(tail)->head; - while (skb->prev) { - struct sk_buff *prev = skb->prev; - frag_list_size += skb->len; - skb->prev = NULL; - skb = prev; - skb_cnt++; + if (!head) + return tail; + + head->len += tail->len; + head->data_len += tail->len; + head->truesize += tail->len; + + IXGBE_CB(tail)->head = NULL; + + return head; +} + +/** + * ixgbe_add_active_tail - adds an active tail into the skb frag_list + * @head: pointer to the start of the skb + * @tail: pointer to active tail to add to frag_list + * + * This function adds an active tail to the end of the frag list. This tail + * will still be receiving data so we cannot yet ad it's stats to the main + * skb. That is done via ixgbe_merge_active_tail. + **/ +static inline void ixgbe_add_active_tail(struct sk_buff *head, + struct sk_buff *tail) +{ + struct sk_buff *old_tail = IXGBE_CB(head)->tail; + + if (old_tail) { + ixgbe_merge_active_tail(old_tail); + old_tail->next = tail; + } else { + skb_shinfo(head)->frag_list = tail; } - skb_shinfo(skb)->frag_list = skb->next; - skb->next = NULL; - skb->len += frag_list_size; - skb->data_len += frag_list_size; - skb->truesize += frag_list_size; - IXGBE_RSC_CB(skb)->skb_cnt = skb_cnt; + IXGBE_CB(tail)->head = head; + IXGBE_CB(head)->tail = tail; +} + +/** + * ixgbe_close_active_frag_list - cleanup pointers on a frag_list skb + * @head: pointer to head of an active frag list + * + * This function will clear the frag_tail_tracker pointer on an active + * frag_list and returns true if the pointer was actually set + **/ +static inline bool ixgbe_close_active_frag_list(struct sk_buff *head) +{ + struct sk_buff *tail = IXGBE_CB(head)->tail; + + if (!tail) + return false; - return skb; + ixgbe_merge_active_tail(tail); + + IXGBE_CB(head)->tail = NULL; + + return true; } -static inline bool ixgbe_get_rsc_state(union ixgbe_adv_rx_desc *rx_desc) +static void ixgbe_get_rsc_cnt(struct ixgbe_ring *rx_ring, + union ixgbe_adv_rx_desc *rx_desc, + struct sk_buff *skb) { - return !!(le32_to_cpu(rx_desc->wb.lower.lo_dword.data) & - IXGBE_RXDADV_RSCCNT_MASK); + __le32 rsc_enabled; + u32 rsc_cnt; + + if (!ring_is_rsc_enabled(rx_ring)) + return; + + rsc_enabled = rx_desc->wb.lower.lo_dword.data & + cpu_to_le32(IXGBE_RXDADV_RSCCNT_MASK); + + /* If this is an RSC frame rsc_cnt should be non-zero */ + if (!rsc_enabled) + return; + + rsc_cnt = le32_to_cpu(rsc_enabled); + rsc_cnt >>= IXGBE_RXDADV_RSCCNT_SHIFT; + + IXGBE_CB(skb)->append_cnt += rsc_cnt - 1; } static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, @@ -1249,7 +1305,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, { struct ixgbe_adapter *adapter = q_vector->adapter; union ixgbe_adv_rx_desc *rx_desc, *next_rxd; - struct ixgbe_rx_buffer *rx_buffer_info, *next_buffer; + struct ixgbe_rx_buffer *rx_buffer_info; struct sk_buff *skb; unsigned int total_rx_bytes = 0, total_rx_packets = 0; const int current_node = numa_node_id(); @@ -1259,7 +1315,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, u32 staterr; u16 i; u16 cleaned_count = 0; - bool pkt_is_rsc = false; i = rx_ring->next_to_clean; rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); @@ -1276,32 +1331,9 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, rx_buffer_info->skb = NULL; prefetch(skb->data); - if (ring_is_rsc_enabled(rx_ring)) - pkt_is_rsc = ixgbe_get_rsc_state(rx_desc); - /* linear means we are building an skb from multiple pages */ if (!skb_is_nonlinear(skb)) { u16 hlen; - if (pkt_is_rsc && - !(staterr & IXGBE_RXD_STAT_EOP) && - !skb->prev) { - /* - * When HWRSC is enabled, delay unmapping - * of the first packet. It carries the - * header information, HW may still - * access the header after the writeback. - * Only unmap it when EOP is reached - */ - IXGBE_RSC_CB(skb)->delay_unmap = true; - IXGBE_RSC_CB(skb)->dma = rx_buffer_info->dma; - } else { - dma_unmap_single(rx_ring->dev, - rx_buffer_info->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - } - rx_buffer_info->dma = 0; - if (ring_is_ps_enabled(rx_ring)) { hlen = ixgbe_get_hlen(rx_desc); upper_len = le16_to_cpu(rx_desc->wb.upper.length); @@ -1310,6 +1342,23 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, } skb_put(skb, hlen); + + /* + * Delay unmapping of the first packet. It carries the + * header information, HW may still access the header + * after writeback. Only unmap it when EOP is reached + */ + if (!IXGBE_CB(skb)->head) { + IXGBE_CB(skb)->delay_unmap = true; + IXGBE_CB(skb)->dma = rx_buffer_info->dma; + } else { + skb = ixgbe_merge_active_tail(skb); + dma_unmap_single(rx_ring->dev, + rx_buffer_info->dma, + rx_ring->rx_buf_len, + DMA_FROM_DEVICE); + } + rx_buffer_info->dma = 0; } else { /* assume packet split since header is unmapped */ upper_len = le16_to_cpu(rx_desc->wb.upper.length); @@ -1337,6 +1386,8 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, skb->truesize += PAGE_SIZE / 2; } + ixgbe_get_rsc_cnt(rx_ring, rx_desc, skb); + i++; if (i == rx_ring->count) i = 0; @@ -1345,55 +1396,50 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, prefetch(next_rxd); cleaned_count++; - if (pkt_is_rsc) { - u32 nextp = (staterr & IXGBE_RXDADV_NEXTP_MASK) >> - IXGBE_RXDADV_NEXTP_SHIFT; + if (!(staterr & IXGBE_RXD_STAT_EOP)) { + struct ixgbe_rx_buffer *next_buffer; + u32 nextp; + + if (IXGBE_CB(skb)->append_cnt) { + nextp = staterr & IXGBE_RXDADV_NEXTP_MASK; + nextp >>= IXGBE_RXDADV_NEXTP_SHIFT; + } else { + nextp = i; + } + next_buffer = &rx_ring->rx_buffer_info[nextp]; - } else { - next_buffer = &rx_ring->rx_buffer_info[i]; - } - if (!(staterr & IXGBE_RXD_STAT_EOP)) { if (ring_is_ps_enabled(rx_ring)) { rx_buffer_info->skb = next_buffer->skb; rx_buffer_info->dma = next_buffer->dma; next_buffer->skb = skb; next_buffer->dma = 0; } else { - skb->next = next_buffer->skb; - skb->next->prev = skb; + struct sk_buff *next_skb = next_buffer->skb; + ixgbe_add_active_tail(skb, next_skb); + IXGBE_CB(next_skb)->head = skb; } rx_ring->rx_stats.non_eop_descs++; goto next_desc; } - if (skb->prev) { - skb = ixgbe_transform_rsc_queue(skb); + dma_unmap_single(rx_ring->dev, + IXGBE_CB(skb)->dma, + rx_ring->rx_buf_len, + DMA_FROM_DEVICE); + IXGBE_CB(skb)->dma = 0; + IXGBE_CB(skb)->delay_unmap = false; + + if (ixgbe_close_active_frag_list(skb) && + !IXGBE_CB(skb)->append_cnt) { /* if we got here without RSC the packet is invalid */ - if (!pkt_is_rsc) { - __pskb_trim(skb, 0); - rx_buffer_info->skb = skb; - goto next_desc; - } + dev_kfree_skb_any(skb); + goto next_desc; } - if (ring_is_rsc_enabled(rx_ring)) { - if (IXGBE_RSC_CB(skb)->delay_unmap) { - dma_unmap_single(rx_ring->dev, - IXGBE_RSC_CB(skb)->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - IXGBE_RSC_CB(skb)->dma = 0; - IXGBE_RSC_CB(skb)->delay_unmap = false; - } - } - if (pkt_is_rsc) { - if (ring_is_ps_enabled(rx_ring)) - rx_ring->rx_stats.rsc_count += - skb_shinfo(skb)->nr_frags; - else - rx_ring->rx_stats.rsc_count += - IXGBE_RSC_CB(skb)->skb_cnt; + if (IXGBE_CB(skb)->append_cnt) { + rx_ring->rx_stats.rsc_count += + IXGBE_CB(skb)->append_cnt; rx_ring->rx_stats.rsc_flush++; } @@ -3881,19 +3927,18 @@ static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring) if (rx_buffer_info->skb) { struct sk_buff *skb = rx_buffer_info->skb; rx_buffer_info->skb = NULL; - do { - struct sk_buff *this = skb; - if (IXGBE_RSC_CB(this)->delay_unmap) { - dma_unmap_single(dev, - IXGBE_RSC_CB(this)->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - IXGBE_RSC_CB(this)->dma = 0; - IXGBE_RSC_CB(skb)->delay_unmap = false; - } - skb = skb->prev; - dev_kfree_skb(this); - } while (skb); + /* We need to clean up RSC frag lists */ + skb = ixgbe_merge_active_tail(skb); + ixgbe_close_active_frag_list(skb); + if (IXGBE_CB(skb)->delay_unmap) { + dma_unmap_single(dev, + IXGBE_CB(skb)->dma, + rx_ring->rx_buf_len, + DMA_FROM_DEVICE); + IXGBE_CB(skb)->dma = 0; + IXGBE_CB(skb)->delay_unmap = false; + } + dev_kfree_skb(skb); } if (!rx_buffer_info->page) continue; -- GitLab From 1d2024f61ec14bdb0c57a97a3fe73685abc2d198 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 31 Jan 2012 02:59:29 +0000 Subject: [PATCH 0524/1846] ixgbe: Address fact that RSC was not setting GSO size for incoming frames This patch is meant to address the fact that RSC has not been setting the gso_size value on the skb. As a result performance on lossy TCP connections was negatively impacted. This change resolves the issue by setting gso_size to the average size for incoming packets. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 130 +++++++++++++++++- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 18e474c25e61..762f33777a7f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1276,6 +1276,104 @@ static inline bool ixgbe_close_active_frag_list(struct sk_buff *head) return true; } +/** + * ixgbe_get_headlen - determine size of header for RSC/LRO/GRO/FCOE + * @data: pointer to the start of the headers + * @max_len: total length of section to find headers in + * + * This function is meant to determine the length of headers that will + * be recognized by hardware for LRO, GRO, and RSC offloads. The main + * motivation of doing this is to only perform one pull for IPv4 TCP + * packets so that we can do basic things like calculating the gso_size + * based on the average data per packet. + **/ +static unsigned int ixgbe_get_headlen(unsigned char *data, + unsigned int max_len) +{ + union { + unsigned char *network; + /* l2 headers */ + struct ethhdr *eth; + struct vlan_hdr *vlan; + /* l3 headers */ + struct iphdr *ipv4; + } hdr; + __be16 protocol; + u8 nexthdr = 0; /* default to not TCP */ + u8 hlen; + + /* this should never happen, but better safe than sorry */ + if (max_len < ETH_HLEN) + return max_len; + + /* initialize network frame pointer */ + hdr.network = data; + + /* set first protocol and move network header forward */ + protocol = hdr.eth->h_proto; + hdr.network += ETH_HLEN; + + /* handle any vlan tag if present */ + if (protocol == __constant_htons(ETH_P_8021Q)) { + if ((hdr.network - data) > (max_len - VLAN_HLEN)) + return max_len; + + protocol = hdr.vlan->h_vlan_encapsulated_proto; + hdr.network += VLAN_HLEN; + } + + /* handle L3 protocols */ + if (protocol == __constant_htons(ETH_P_IP)) { + if ((hdr.network - data) > (max_len - sizeof(struct iphdr))) + return max_len; + + /* access ihl as a u8 to avoid unaligned access on ia64 */ + hlen = (hdr.network[0] & 0x0F) << 2; + + /* verify hlen meets minimum size requirements */ + if (hlen < sizeof(struct iphdr)) + return hdr.network - data; + + /* record next protocol */ + nexthdr = hdr.ipv4->protocol; + hdr.network += hlen; +#ifdef CONFIG_FCOE + } else if (protocol == __constant_htons(ETH_P_FCOE)) { + if ((hdr.network - data) > (max_len - FCOE_HEADER_LEN)) + return max_len; + hdr.network += FCOE_HEADER_LEN; +#endif + } else { + return hdr.network - data; + } + + /* finally sort out TCP */ + if (nexthdr == IPPROTO_TCP) { + if ((hdr.network - data) > (max_len - sizeof(struct tcphdr))) + return max_len; + + /* access doff as a u8 to avoid unaligned access on ia64 */ + hlen = (hdr.network[12] & 0xF0) >> 2; + + /* verify hlen meets minimum size requirements */ + if (hlen < sizeof(struct tcphdr)) + return hdr.network - data; + + hdr.network += hlen; + } + + /* + * If everything has gone correctly hdr.network should be the + * data section of the packet and will be the end of the header. + * If not then it probably represents the end of the last recognized + * header. + */ + if ((hdr.network - data) < max_len) + return hdr.network - data; + else + return max_len; +} + static void ixgbe_get_rsc_cnt(struct ixgbe_ring *rx_ring, union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb) @@ -1299,6 +1397,32 @@ static void ixgbe_get_rsc_cnt(struct ixgbe_ring *rx_ring, IXGBE_CB(skb)->append_cnt += rsc_cnt - 1; } +static void ixgbe_set_rsc_gso_size(struct ixgbe_ring *ring, + struct sk_buff *skb) +{ + u16 hdr_len = ixgbe_get_headlen(skb->data, skb_headlen(skb)); + + /* set gso_size to avoid messing up TCP MSS */ + skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->len - hdr_len), + IXGBE_CB(skb)->append_cnt); +} + +static void ixgbe_update_rsc_stats(struct ixgbe_ring *rx_ring, + struct sk_buff *skb) +{ + /* if append_cnt is 0 then frame is not RSC */ + if (!IXGBE_CB(skb)->append_cnt) + return; + + rx_ring->rx_stats.rsc_count += IXGBE_CB(skb)->append_cnt; + rx_ring->rx_stats.rsc_flush++; + + ixgbe_set_rsc_gso_size(rx_ring, skb); + + /* gso_size is computed using append_cnt so always clear it last */ + IXGBE_CB(skb)->append_cnt = 0; +} + static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, struct ixgbe_ring *rx_ring, int budget) @@ -1437,11 +1561,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, goto next_desc; } - if (IXGBE_CB(skb)->append_cnt) { - rx_ring->rx_stats.rsc_count += - IXGBE_CB(skb)->append_cnt; - rx_ring->rx_stats.rsc_flush++; - } + ixgbe_update_rsc_stats(rx_ring, skb); /* ERR_MASK will only have valid bits if EOP set */ if (unlikely(staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK)) { -- GitLab From f990b79bc80ca7a23b8a6c33241c439072d0b85b Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 31 Jan 2012 02:59:34 +0000 Subject: [PATCH 0525/1846] ixgbe: Let the Rx buffer allocation clear status bits instead of cleanup This change makes it so that we always clear the status/error bits in the Rx descriptor in the allocation path instead of the cleanup path. The advantage to this is that we spend less time modifying data. As such we can modify the data once and then let it go cold in the cache instead of writing it, reading it, and then writing it again. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 155 +++++++++++------- 1 file changed, 93 insertions(+), 62 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 762f33777a7f..538577b08e25 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1101,8 +1101,75 @@ static inline void ixgbe_release_rx_desc(struct ixgbe_ring *rx_ring, u32 val) writel(val, rx_ring->tail); } +static bool ixgbe_alloc_mapped_skb(struct ixgbe_ring *rx_ring, + struct ixgbe_rx_buffer *bi) +{ + struct sk_buff *skb = bi->skb; + dma_addr_t dma = bi->dma; + + if (dma) + return true; + + if (likely(!skb)) { + skb = netdev_alloc_skb_ip_align(rx_ring->netdev, + rx_ring->rx_buf_len); + bi->skb = skb; + if (!skb) { + rx_ring->rx_stats.alloc_rx_buff_failed++; + return false; + } + + /* initialize skb for ring */ + skb_record_rx_queue(skb, rx_ring->queue_index); + } + + dma = dma_map_single(rx_ring->dev, skb->data, + rx_ring->rx_buf_len, DMA_FROM_DEVICE); + + if (dma_mapping_error(rx_ring->dev, dma)) { + rx_ring->rx_stats.alloc_rx_buff_failed++; + return false; + } + + bi->dma = dma; + return true; +} + +static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring, + struct ixgbe_rx_buffer *bi) +{ + struct page *page = bi->page; + dma_addr_t page_dma = bi->page_dma; + unsigned int page_offset = bi->page_offset ^ (PAGE_SIZE / 2); + + if (page_dma) + return true; + + if (!page) { + page = alloc_page(GFP_ATOMIC | __GFP_COLD); + bi->page = page; + if (unlikely(!page)) { + rx_ring->rx_stats.alloc_rx_page_failed++; + return false; + } + } + + page_dma = dma_map_page(rx_ring->dev, page, + page_offset, PAGE_SIZE / 2, + DMA_FROM_DEVICE); + + if (dma_mapping_error(rx_ring->dev, page_dma)) { + rx_ring->rx_stats.alloc_rx_page_failed++; + return false; + } + + bi->page_dma = page_dma; + bi->page_offset = page_offset; + return true; +} + /** - * ixgbe_alloc_rx_buffers - Replace used receive buffers; packet split + * ixgbe_alloc_rx_buffers - Replace used receive buffers * @rx_ring: ring to place buffers on * @cleaned_count: number of buffers to replace **/ @@ -1110,82 +1177,48 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) { union ixgbe_adv_rx_desc *rx_desc; struct ixgbe_rx_buffer *bi; - struct sk_buff *skb; u16 i = rx_ring->next_to_use; - /* do nothing if no valid netdev defined */ - if (!rx_ring->netdev) + /* nothing to do or no valid netdev defined */ + if (!cleaned_count || !rx_ring->netdev) return; - while (cleaned_count--) { - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); - bi = &rx_ring->rx_buffer_info[i]; - skb = bi->skb; - - if (!skb) { - skb = netdev_alloc_skb_ip_align(rx_ring->netdev, - rx_ring->rx_buf_len); - if (!skb) { - rx_ring->rx_stats.alloc_rx_buff_failed++; - goto no_buffers; - } - /* initialize queue mapping */ - skb_record_rx_queue(skb, rx_ring->queue_index); - bi->skb = skb; - } + rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); + bi = &rx_ring->rx_buffer_info[i]; + i -= rx_ring->count; - if (!bi->dma) { - bi->dma = dma_map_single(rx_ring->dev, - skb->data, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - if (dma_mapping_error(rx_ring->dev, bi->dma)) { - rx_ring->rx_stats.alloc_rx_buff_failed++; - bi->dma = 0; - goto no_buffers; - } - } + while (cleaned_count--) { + if (!ixgbe_alloc_mapped_skb(rx_ring, bi)) + break; + /* Refresh the desc even if buffer_addrs didn't change + * because each write-back erases this info. */ if (ring_is_ps_enabled(rx_ring)) { - if (!bi->page) { - bi->page = alloc_page(GFP_ATOMIC | __GFP_COLD); - if (!bi->page) { - rx_ring->rx_stats.alloc_rx_page_failed++; - goto no_buffers; - } - } + rx_desc->read.hdr_addr = cpu_to_le64(bi->dma); - if (!bi->page_dma) { - /* use a half page if we're re-using */ - bi->page_offset ^= PAGE_SIZE / 2; - bi->page_dma = dma_map_page(rx_ring->dev, - bi->page, - bi->page_offset, - PAGE_SIZE / 2, - DMA_FROM_DEVICE); - if (dma_mapping_error(rx_ring->dev, - bi->page_dma)) { - rx_ring->rx_stats.alloc_rx_page_failed++; - bi->page_dma = 0; - goto no_buffers; - } - } + if (!ixgbe_alloc_mapped_page(rx_ring, bi)) + break; - /* Refresh the desc even if buffer_addrs didn't change - * because each write-back erases this info. */ rx_desc->read.pkt_addr = cpu_to_le64(bi->page_dma); - rx_desc->read.hdr_addr = cpu_to_le64(bi->dma); } else { rx_desc->read.pkt_addr = cpu_to_le64(bi->dma); - rx_desc->read.hdr_addr = 0; } + rx_desc++; + bi++; i++; - if (i == rx_ring->count) - i = 0; + if (unlikely(!i)) { + rx_desc = IXGBE_RX_DESC_ADV(rx_ring, 0); + bi = rx_ring->rx_buffer_info; + i -= rx_ring->count; + } + + /* clear the hdr_addr for the next_to_use descriptor */ + rx_desc->read.hdr_addr = 0; } -no_buffers: + i += rx_ring->count; + if (rx_ring->next_to_use != i) { rx_ring->next_to_use = i; ixgbe_release_rx_desc(rx_ring, i); @@ -1593,8 +1626,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, budget--; next_desc: - rx_desc->wb.upper.status_error = 0; - if (!budget) break; -- GitLab From f56e0cb1fea6aa3caace1c1ddde3f847793dcf38 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 31 Jan 2012 02:59:39 +0000 Subject: [PATCH 0526/1846] ixgbe: Add function for testing status bits in Rx descriptor This change adds a small function for testing Rx status bits in the descriptor. The advantage to this is that we can avoid unnecessary byte swaps on big endian systems. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 10 +++- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 59 +++++++++++-------- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 51 +++++++--------- 3 files changed, 65 insertions(+), 55 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index fca055362847..260e17637886 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -329,6 +329,13 @@ struct ixgbe_q_vector { #define IXGBE_10K_ITR 400 #define IXGBE_8K_ITR 500 +/* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */ +static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc, + const u32 stat_err_bits) +{ + return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits); +} + static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring) { u16 ntc = ring->next_to_clean; @@ -618,8 +625,7 @@ extern int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, extern void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter); extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, union ixgbe_adv_rx_desc *rx_desc, - struct sk_buff *skb, - u32 staterr); + struct sk_buff *skb); extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid, struct scatterlist *sgl, unsigned int sgc); extern int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 4bc794249801..da7da752b6b4 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -357,22 +357,20 @@ int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid, */ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, union ixgbe_adv_rx_desc *rx_desc, - struct sk_buff *skb, - u32 staterr) + struct sk_buff *skb) { - u16 xid; - u32 fctl; - u32 fceofe, fcerr, fcstat; int rc = -EINVAL; struct ixgbe_fcoe *fcoe; struct ixgbe_fcoe_ddp *ddp; struct fc_frame_header *fh; struct fcoe_crc_eof *crc; + __le32 fcerr = ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_FCERR); + __le32 ddp_err; + u32 fctl; + u16 xid; - fcerr = (staterr & IXGBE_RXDADV_ERR_FCERR); - fceofe = (staterr & IXGBE_RXDADV_ERR_FCEOFE); - if (fcerr == IXGBE_FCERR_BADCRC) - skb_checksum_none_assert(skb); + if (fcerr == cpu_to_le32(IXGBE_FCERR_BADCRC)) + skb->ip_summed = CHECKSUM_NONE; else skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -382,6 +380,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, else fh = (struct fc_frame_header *)(skb->data + sizeof(struct fcoe_hdr)); + fctl = ntoh24(fh->fh_f_ctl); if (fctl & FC_FC_EX_CTX) xid = be16_to_cpu(fh->fh_ox_id); @@ -396,27 +395,39 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, if (!ddp->udl) goto ddp_out; - if (fcerr | fceofe) + ddp_err = ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_FCEOFE | + IXGBE_RXDADV_ERR_FCERR); + if (ddp_err) goto ddp_out; - fcstat = (staterr & IXGBE_RXDADV_STAT_FCSTAT); - if (fcstat) { + switch (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_FCSTAT)) { + /* return 0 to bypass going to ULD for DDPed data */ + case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_DDP): /* update length of DDPed data */ ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); - /* unmap the sg list when FCP_RSP is received */ - if (fcstat == IXGBE_RXDADV_STAT_FCSTAT_FCPRSP) { - pci_unmap_sg(adapter->pdev, ddp->sgl, - ddp->sgc, DMA_FROM_DEVICE); - ddp->err = (fcerr | fceofe); - ddp->sgl = NULL; - ddp->sgc = 0; - } - /* return 0 to bypass going to ULD for DDPed data */ - if (fcstat == IXGBE_RXDADV_STAT_FCSTAT_DDP) - rc = 0; - else if (ddp->len) + rc = 0; + break; + /* unmap the sg list when FCPRSP is received */ + case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_FCPRSP): + pci_unmap_sg(adapter->pdev, ddp->sgl, + ddp->sgc, DMA_FROM_DEVICE); + ddp->err = ddp_err; + ddp->sgl = NULL; + ddp->sgc = 0; + /* fall through */ + /* if DDP length is present pass it through to ULD */ + case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NODDP): + /* update length of DDPed data */ + ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); + if (ddp->len) rc = ddp->len; + break; + /* no match will return as an error */ + case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NOMTCH): + default: + break; } + /* In target mode, check the last data frame of the sequence. * For DDP in target mode, data is already DDPed but the header * indication of the last data frame ould allow is to tell if we diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 538577b08e25..b0469ddb158c 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1019,25 +1019,23 @@ static inline bool ixgbe_rx_is_fcoe(struct ixgbe_adapter *adapter, * ixgbe_receive_skb - Send a completed packet up the stack * @adapter: board private structure * @skb: packet to send up - * @status: hardware indication of status of receive * @rx_ring: rx descriptor ring (for a specific queue) to setup * @rx_desc: rx descriptor **/ static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector, - struct sk_buff *skb, u8 status, + struct sk_buff *skb, struct ixgbe_ring *ring, union ixgbe_adv_rx_desc *rx_desc) { struct ixgbe_adapter *adapter = q_vector->adapter; - struct napi_struct *napi = &q_vector->napi; - bool is_vlan = (status & IXGBE_RXD_STAT_VP); - u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan); - if (is_vlan && (tag & VLAN_VID_MASK)) - __vlan_hwaccel_put_tag(skb, tag); + if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { + u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); + __vlan_hwaccel_put_tag(skb, vid); + } if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) - napi_gro_receive(napi, skb); + napi_gro_receive(&q_vector->napi, skb); else netif_rx(skb); } @@ -1047,12 +1045,10 @@ static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector, * @adapter: address of board private structure * @status_err: hardware indication of status of receive * @skb: skb currently being received and modified - * @status_err: status error value of last descriptor in packet **/ static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter, union ixgbe_adv_rx_desc *rx_desc, - struct sk_buff *skb, - u32 status_err) + struct sk_buff *skb) { skb->ip_summed = CHECKSUM_NONE; @@ -1061,16 +1057,16 @@ static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter, return; /* if IP and error */ - if ((status_err & IXGBE_RXD_STAT_IPCS) && - (status_err & IXGBE_RXDADV_ERR_IPE)) { + if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_IPCS) && + ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_IPE)) { adapter->hw_csum_rx_error++; return; } - if (!(status_err & IXGBE_RXD_STAT_L4CS)) + if (!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_L4CS)) return; - if (status_err & IXGBE_RXDADV_ERR_TCPE) { + if (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_TCPE)) { u16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; /* @@ -1091,6 +1087,7 @@ static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter, static inline void ixgbe_release_rx_desc(struct ixgbe_ring *rx_ring, u32 val) { + rx_ring->next_to_use = val; /* * Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only @@ -1219,10 +1216,8 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) i += rx_ring->count; - if (rx_ring->next_to_use != i) { - rx_ring->next_to_use = i; + if (rx_ring->next_to_use != i) ixgbe_release_rx_desc(rx_ring, i); - } } static inline u16 ixgbe_get_hlen(union ixgbe_adv_rx_desc *rx_desc) @@ -1469,15 +1464,13 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, #ifdef IXGBE_FCOE int ddp_bytes = 0; #endif /* IXGBE_FCOE */ - u32 staterr; u16 i; u16 cleaned_count = 0; i = rx_ring->next_to_clean; rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); - staterr = le32_to_cpu(rx_desc->wb.upper.status_error); - while (staterr & IXGBE_RXD_STAT_DD) { + while (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) { u32 upper_len = 0; rmb(); /* read descriptor and rx_buffer_info after status DD */ @@ -1553,12 +1546,13 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, prefetch(next_rxd); cleaned_count++; - if (!(staterr & IXGBE_RXD_STAT_EOP)) { + if ((!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_EOP))) { struct ixgbe_rx_buffer *next_buffer; u32 nextp; if (IXGBE_CB(skb)->append_cnt) { - nextp = staterr & IXGBE_RXDADV_NEXTP_MASK; + nextp = le32_to_cpu( + rx_desc->wb.upper.status_error); nextp >>= IXGBE_RXDADV_NEXTP_SHIFT; } else { nextp = i; @@ -1597,12 +1591,13 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, ixgbe_update_rsc_stats(rx_ring, skb); /* ERR_MASK will only have valid bits if EOP set */ - if (unlikely(staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK)) { + if (unlikely(ixgbe_test_staterr(rx_desc, + IXGBE_RXDADV_ERR_FRAME_ERR_MASK))) { dev_kfree_skb_any(skb); goto next_desc; } - ixgbe_rx_checksum(adapter, rx_desc, skb, staterr); + ixgbe_rx_checksum(adapter, rx_desc, skb); if (adapter->netdev->features & NETIF_F_RXHASH) ixgbe_rx_hash(rx_desc, skb); @@ -1614,15 +1609,14 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, #ifdef IXGBE_FCOE /* if ddp, not passing to ULD unless for FCP_RSP or error */ if (ixgbe_rx_is_fcoe(adapter, rx_desc)) { - ddp_bytes = ixgbe_fcoe_ddp(adapter, rx_desc, skb, - staterr); + ddp_bytes = ixgbe_fcoe_ddp(adapter, rx_desc, skb); if (!ddp_bytes) { dev_kfree_skb_any(skb); goto next_desc; } } #endif /* IXGBE_FCOE */ - ixgbe_receive_skb(q_vector, skb, staterr, rx_ring, rx_desc); + ixgbe_receive_skb(q_vector, skb, rx_ring, rx_desc); budget--; next_desc: @@ -1637,7 +1631,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, /* use prefetched values */ rx_desc = next_rxd; - staterr = le32_to_cpu(rx_desc->wb.upper.status_error); } rx_ring->next_to_clean = i; -- GitLab From e4f740287fbfdc7b68634e93c098c8ea8de691f1 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 31 Jan 2012 02:59:44 +0000 Subject: [PATCH 0527/1846] ixgbe: Drop the _ADV of descriptor macros since all ixgbe descriptors are ADV It doesn't make much sense to differentiate between advanced and legacy descriptors when the only descriptors that ixgbe uses are advanced descriptors. As such we can drop the _ADV suffix since all ixgbe descriptors are automatically advanced. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 6 ++--- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 26 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 260e17637886..882a58051a1f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -344,11 +344,11 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring) return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1; } -#define IXGBE_RX_DESC_ADV(R, i) \ +#define IXGBE_RX_DESC(R, i) \ (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i])) -#define IXGBE_TX_DESC_ADV(R, i) \ +#define IXGBE_TX_DESC(R, i) \ (&(((union ixgbe_adv_tx_desc *)((R)->desc))[i])) -#define IXGBE_TX_CTXTDESC_ADV(R, i) \ +#define IXGBE_TX_CTXTDESC(R, i) \ (&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i])) #define IXGBE_MAX_JUMBO_FRAME_SIZE 16128 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 1f31a04d3c91..1214fc178eea 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -1725,7 +1725,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring, /* initialize next to clean and descriptor values */ rx_ntc = rx_ring->next_to_clean; tx_ntc = tx_ring->next_to_clean; - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, rx_ntc); + rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc); staterr = le32_to_cpu(rx_desc->wb.upper.status_error); while (staterr & IXGBE_RXD_STAT_DD) { @@ -1756,7 +1756,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring, tx_ntc = 0; /* fetch next descriptor */ - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, rx_ntc); + rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc); staterr = le32_to_cpu(rx_desc->wb.upper.status_error); } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index b0469ddb158c..381d4dc88dc9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -366,7 +366,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) "leng ntw timestamp bi->skb\n"); for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, i); + tx_desc = IXGBE_TX_DESC(tx_ring, i); tx_buffer_info = &tx_ring->tx_buffer_info[i]; u0 = (struct my_u0 *)tx_desc; pr_info("T [0x%03X] %016llX %016llX %016llX" @@ -447,7 +447,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) for (i = 0; i < rx_ring->count; i++) { rx_buffer_info = &rx_ring->rx_buffer_info[i]; - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); + rx_desc = IXGBE_RX_DESC(rx_ring, i); u0 = (struct my_u0 *)rx_desc; staterr = le32_to_cpu(rx_desc->wb.upper.status_error); if (staterr & IXGBE_RXD_STAT_DD) { @@ -754,7 +754,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, u16 i = tx_ring->next_to_clean; tx_buffer = &tx_ring->tx_buffer_info[i]; - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, i); + tx_desc = IXGBE_TX_DESC(tx_ring, i); for (; budget; budget--) { union ixgbe_adv_tx_desc *eop_desc = tx_buffer->next_to_watch; @@ -795,7 +795,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, i = 0; tx_buffer = tx_ring->tx_buffer_info; - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, 0); + tx_desc = IXGBE_TX_DESC(tx_ring, 0); } } while (eop_desc); @@ -812,7 +812,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, if (check_for_tx_hang(tx_ring) && ixgbe_check_tx_hang(tx_ring)) { /* schedule immediate reset if we believe we hung */ struct ixgbe_hw *hw = &adapter->hw; - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, i); + tx_desc = IXGBE_TX_DESC(tx_ring, i); e_err(drv, "Detected Tx Unit Hang\n" " Tx Queue <%d>\n" " TDH, TDT <%x>, <%x>\n" @@ -1180,7 +1180,7 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) if (!cleaned_count || !rx_ring->netdev) return; - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); + rx_desc = IXGBE_RX_DESC(rx_ring, i); bi = &rx_ring->rx_buffer_info[i]; i -= rx_ring->count; @@ -1205,7 +1205,7 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) bi++; i++; if (unlikely(!i)) { - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, 0); + rx_desc = IXGBE_RX_DESC(rx_ring, 0); bi = rx_ring->rx_buffer_info; i -= rx_ring->count; } @@ -1468,7 +1468,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, u16 cleaned_count = 0; i = rx_ring->next_to_clean; - rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); + rx_desc = IXGBE_RX_DESC(rx_ring, i); while (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) { u32 upper_len = 0; @@ -1542,7 +1542,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, if (i == rx_ring->count) i = 0; - next_rxd = IXGBE_RX_DESC_ADV(rx_ring, i); + next_rxd = IXGBE_RX_DESC(rx_ring, i); prefetch(next_rxd); cleaned_count++; @@ -6469,7 +6469,7 @@ void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens, struct ixgbe_adv_tx_context_desc *context_desc; u16 i = tx_ring->next_to_use; - context_desc = IXGBE_TX_CTXTDESC_ADV(tx_ring, i); + context_desc = IXGBE_TX_CTXTDESC(tx_ring, i); i++; tx_ring->next_to_use = (i < tx_ring->count) ? i : 0; @@ -6702,7 +6702,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, cmd_type = ixgbe_tx_cmd_type(tx_flags); olinfo_status = ixgbe_tx_olinfo_status(tx_flags, paylen); - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, i); + tx_desc = IXGBE_TX_DESC(tx_ring, i); for (;;) { while (size > IXGBE_MAX_DATA_PER_TXD) { @@ -6717,7 +6717,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, tx_desc++; i++; if (i == tx_ring->count) { - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, 0); + tx_desc = IXGBE_TX_DESC(tx_ring, 0); i = 0; } } @@ -6753,7 +6753,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, tx_desc++; i++; if (i == tx_ring->count) { - tx_desc = IXGBE_TX_DESC_ADV(tx_ring, 0); + tx_desc = IXGBE_TX_DESC(tx_ring, 0); i = 0; } } -- GitLab From 8a0da21be84019d605af2c9a92b20a084db77de1 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 31 Jan 2012 02:59:49 +0000 Subject: [PATCH 0528/1846] ixgbe: Combine post-DMA processing of sk_buff fields into single function This change combines a number of post-DMA Rx packet processing functions into a single function. The advantage of this is that it combines most of the Rx descriptor processing into one spot so it should all be warm in the cache. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 127 ++++++++++-------- 2 files changed, 71 insertions(+), 59 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 882a58051a1f..2807a25e04e6 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -190,6 +190,7 @@ struct ixgbe_rx_queue_stats { u64 non_eop_descs; u64 alloc_rx_page_failed; u64 alloc_rx_buff_failed; + u64 csum_err; }; enum ixbge_ring_state_t { @@ -198,6 +199,7 @@ enum ixbge_ring_state_t { __IXGBE_HANG_CHECK_ARMED, __IXGBE_RX_PS_ENABLED, __IXGBE_RX_RSC_ENABLED, + __IXGBE_RX_CSUM_UDP_ZERO_ERR, }; #define ring_is_ps_enabled(ring) \ @@ -379,7 +381,6 @@ struct ixgbe_adapter { * thus the additional *_CAPABLE flags. */ u32 flags; -#define IXGBE_FLAG_RX_CSUM_ENABLED (u32)(1) #define IXGBE_FLAG_MSI_CAPABLE (u32)(1 << 1) #define IXGBE_FLAG_MSI_ENABLED (u32)(1 << 2) #define IXGBE_FLAG_MSIX_CAPABLE (u32)(1 << 3) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 381d4dc88dc9..ac1d925c0007 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -991,10 +991,12 @@ static int __ixgbe_notify_dca(struct device *dev, void *data) } #endif /* CONFIG_IXGBE_DCA */ -static inline void ixgbe_rx_hash(union ixgbe_adv_rx_desc *rx_desc, +static inline void ixgbe_rx_hash(struct ixgbe_ring *ring, + union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb) { - skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); + if (ring->netdev->features & NETIF_F_RXHASH) + skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); } /** @@ -1015,51 +1017,26 @@ static inline bool ixgbe_rx_is_fcoe(struct ixgbe_adapter *adapter, IXGBE_RXDADV_PKTTYPE_ETQF_SHIFT))); } -/** - * ixgbe_receive_skb - Send a completed packet up the stack - * @adapter: board private structure - * @skb: packet to send up - * @rx_ring: rx descriptor ring (for a specific queue) to setup - * @rx_desc: rx descriptor - **/ -static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector, - struct sk_buff *skb, - struct ixgbe_ring *ring, - union ixgbe_adv_rx_desc *rx_desc) -{ - struct ixgbe_adapter *adapter = q_vector->adapter; - - if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { - u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); - __vlan_hwaccel_put_tag(skb, vid); - } - - if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) - napi_gro_receive(&q_vector->napi, skb); - else - netif_rx(skb); -} - /** * ixgbe_rx_checksum - indicate in skb if hw indicated a good cksum - * @adapter: address of board private structure - * @status_err: hardware indication of status of receive + * @ring: structure containing ring specific data + * @rx_desc: current Rx descriptor being processed * @skb: skb currently being received and modified **/ -static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter, +static inline void ixgbe_rx_checksum(struct ixgbe_ring *ring, union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb) { - skb->ip_summed = CHECKSUM_NONE; + skb_checksum_none_assert(skb); /* Rx csum disabled */ - if (!(adapter->flags & IXGBE_FLAG_RX_CSUM_ENABLED)) + if (!(ring->netdev->features & NETIF_F_RXCSUM)) return; /* if IP and error */ if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_IPCS) && ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_IPE)) { - adapter->hw_csum_rx_error++; + ring->rx_stats.csum_err++; return; } @@ -1073,11 +1050,11 @@ static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter, * 82599 errata, UDP frames with a 0 checksum can be marked as * checksum errors. */ - if ((pkt_info & IXGBE_RXDADV_PKTTYPE_UDP) && - (adapter->hw.mac.type == ixgbe_mac_82599EB)) + if ((pkt_info & cpu_to_le16(IXGBE_RXDADV_PKTTYPE_UDP)) && + test_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state)) return; - adapter->hw_csum_rx_error++; + ring->rx_stats.csum_err++; return; } @@ -1115,9 +1092,6 @@ static bool ixgbe_alloc_mapped_skb(struct ixgbe_ring *rx_ring, rx_ring->rx_stats.alloc_rx_buff_failed++; return false; } - - /* initialize skb for ring */ - skb_record_rx_queue(skb, rx_ring->queue_index); } dma = dma_map_single(rx_ring->dev, skb->data, @@ -1451,17 +1425,58 @@ static void ixgbe_update_rsc_stats(struct ixgbe_ring *rx_ring, IXGBE_CB(skb)->append_cnt = 0; } +/** + * ixgbe_process_skb_fields - Populate skb header fields from Rx descriptor + * @rx_ring: rx descriptor ring packet is being transacted on + * @rx_desc: pointer to the EOP Rx descriptor + * @skb: pointer to current skb being populated + * + * This function checks the ring, descriptor, and packet information in + * order to populate the hash, checksum, VLAN, timestamp, protocol, and + * other fields within the skb. + **/ +static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring, + union ixgbe_adv_rx_desc *rx_desc, + struct sk_buff *skb) +{ + ixgbe_update_rsc_stats(rx_ring, skb); + + ixgbe_rx_hash(rx_ring, rx_desc, skb); + + ixgbe_rx_checksum(rx_ring, rx_desc, skb); + + if (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { + u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); + __vlan_hwaccel_put_tag(skb, vid); + } + + skb_record_rx_queue(skb, rx_ring->queue_index); + + skb->protocol = eth_type_trans(skb, rx_ring->netdev); +} + +static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector, + struct sk_buff *skb) +{ + struct ixgbe_adapter *adapter = q_vector->adapter; + + if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) + napi_gro_receive(&q_vector->napi, skb); + else + netif_rx(skb); +} + static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, struct ixgbe_ring *rx_ring, int budget) { - struct ixgbe_adapter *adapter = q_vector->adapter; union ixgbe_adv_rx_desc *rx_desc, *next_rxd; struct ixgbe_rx_buffer *rx_buffer_info; struct sk_buff *skb; unsigned int total_rx_bytes = 0, total_rx_packets = 0; const int current_node = numa_node_id(); #ifdef IXGBE_FCOE + struct ixgbe_adapter *adapter = q_vector->adapter; int ddp_bytes = 0; #endif /* IXGBE_FCOE */ u16 i; @@ -1588,8 +1603,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, goto next_desc; } - ixgbe_update_rsc_stats(rx_ring, skb); - /* ERR_MASK will only have valid bits if EOP set */ if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_FRAME_ERR_MASK))) { @@ -1597,15 +1610,13 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, goto next_desc; } - ixgbe_rx_checksum(adapter, rx_desc, skb); - if (adapter->netdev->features & NETIF_F_RXHASH) - ixgbe_rx_hash(rx_desc, skb); - /* probably a little skewed due to removing CRC */ total_rx_bytes += skb->len; total_rx_packets++; - skb->protocol = eth_type_trans(skb, rx_ring->netdev); + /* populate checksum, timestamp, VLAN, and protocol */ + ixgbe_process_skb_fields(rx_ring, rx_desc, skb); + #ifdef IXGBE_FCOE /* if ddp, not passing to ULD unless for FCP_RSP or error */ if (ixgbe_rx_is_fcoe(adapter, rx_desc)) { @@ -1616,7 +1627,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, } } #endif /* IXGBE_FCOE */ - ixgbe_receive_skb(q_vector, skb, rx_ring, rx_desc); + ixgbe_rx_skb(q_vector, skb); budget--; next_desc: @@ -4851,6 +4862,13 @@ static int ixgbe_alloc_queues(struct ixgbe_adapter *adapter) ring->dev = &adapter->pdev->dev; ring->netdev = adapter->netdev; + /* + * 82599 errata, UDP frames with a 0 checksum can be marked as + * checksum errors. + */ + if (adapter->hw.mac.type == ixgbe_mac_82599EB) + set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); + adapter->rx_ring[rx] = ring; } @@ -5255,9 +5273,6 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) return -EIO; } - /* enable rx csum by default */ - adapter->flags |= IXGBE_FLAG_RX_CSUM_ENABLED; - /* get assigned NUMA node */ adapter->node = dev_to_node(&pdev->dev); @@ -5748,7 +5763,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter) u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot; u64 non_eop_descs = 0, restart_queue = 0, tx_busy = 0; u64 alloc_rx_page_failed = 0, alloc_rx_buff_failed = 0; - u64 bytes = 0, packets = 0; + u64 bytes = 0, packets = 0, hw_csum_rx_error = 0; #ifdef IXGBE_FCOE struct ixgbe_fcoe *fcoe = &adapter->fcoe; unsigned int cpu; @@ -5778,12 +5793,14 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter) non_eop_descs += rx_ring->rx_stats.non_eop_descs; alloc_rx_page_failed += rx_ring->rx_stats.alloc_rx_page_failed; alloc_rx_buff_failed += rx_ring->rx_stats.alloc_rx_buff_failed; + hw_csum_rx_error += rx_ring->rx_stats.csum_err; bytes += rx_ring->stats.bytes; packets += rx_ring->stats.packets; } adapter->non_eop_descs = non_eop_descs; adapter->alloc_rx_page_failed = alloc_rx_page_failed; adapter->alloc_rx_buff_failed = alloc_rx_buff_failed; + adapter->hw_csum_rx_error = hw_csum_rx_error; netdev->stats.rx_bytes = bytes; netdev->stats.rx_packets = packets; @@ -7412,12 +7429,6 @@ static int ixgbe_set_features(struct net_device *netdev, struct ixgbe_adapter *adapter = netdev_priv(netdev); bool need_reset = false; - /* If Rx checksum is disabled, then RSC/LRO should also be disabled */ - if (!(data & NETIF_F_RXCSUM)) - adapter->flags &= ~IXGBE_FLAG_RX_CSUM_ENABLED; - else - adapter->flags |= IXGBE_FLAG_RX_CSUM_ENABLED; - /* Make sure RSC matches LRO, reset if change */ if (!!(data & NETIF_F_LRO) != !!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { -- GitLab From 4031ae6edb92f7e0aade76357813211ae0520a5c Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Fri, 27 Jan 2012 06:22:53 +0000 Subject: [PATCH 0529/1846] skbuff: Move rxhash and vlan_tci to consolidate holes in sk_buff This change helps to reduce the overall size of the sk_buff by moving rxhash and vlan_tci so that the u16 values and u8 bitfields can be better combined to create only one hole instead of multiple. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- include/linux/skbuff.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 50db9b04a552..2b7317ff297f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -438,6 +438,11 @@ struct sk_buff { #endif int skb_iif; + + __u32 rxhash; + + __u16 vlan_tci; + #ifdef CONFIG_NET_SCHED __u16 tc_index; /* traffic control index */ #ifdef CONFIG_NET_CLS_ACT @@ -445,8 +450,6 @@ struct sk_buff { #endif #endif - __u32 rxhash; - __u16 queue_mapping; kmemcheck_bitfield_begin(flags2); #ifdef CONFIG_IPV6_NDISC_NODETYPE @@ -470,8 +473,6 @@ struct sk_buff { __u32 dropcount; }; - __u16 vlan_tci; - sk_buff_data_t transport_header; sk_buff_data_t network_header; sk_buff_data_t mac_header; -- GitLab From 72e60278d7e4a600fd6e067b42a5822e72946d6e Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Thu, 9 Feb 2012 04:23:33 +0000 Subject: [PATCH 0530/1846] aeroflex: Fix typo in greth.c Correct spelling "reseting" to "resetting" in drivers/net/ethernet/aeroflex/greth.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/net/ethernet/aeroflex/greth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c index b23751e683c8..cfa13481e5f2 100644 --- a/drivers/net/ethernet/aeroflex/greth.c +++ b/drivers/net/ethernet/aeroflex/greth.c @@ -1421,7 +1421,7 @@ static int __devinit greth_of_probe(struct platform_device *ofdev) SET_NETDEV_DEV(dev, greth->dev); if (netif_msg_probe(greth)) - dev_dbg(greth->dev, "reseting controller.\n"); + dev_dbg(greth->dev, "resetting controller.\n"); /* Reset the controller. */ GRETH_REGSAVE(regs->control, GRETH_RESET); -- GitLab From 7a3198a89722ad9521d22b05938d357eac7460fa Mon Sep 17 00:00:00 2001 From: Jiri Benc Date: Thu, 9 Feb 2012 09:34:41 +0000 Subject: [PATCH 0531/1846] ipv6: helper function to get tclass Implement helper inline function to get traffic class from IPv6 header. Signed-off-by: Jiri Benc Signed-off-by: David S. Miller --- include/linux/ipv6.h | 5 +++++ net/ipv6/datagram.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 743a16a41040..4847a64d3c0a 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -233,6 +233,11 @@ static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb) return (struct ipv6hdr *)skb_transport_header(skb); } +static inline __u8 ipv6_tclass(const struct ipv6hdr *iph) +{ + return (ntohl(*(__be32 *)iph) >> 20) & 0xff; +} + /* This structure contains results of exthdrs parsing as offsets from skb->nh. diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 251e7cd75e89..76832c8dc89d 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -485,7 +485,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) } if (np->rxopt.bits.rxtclass) { - int tclass = (ntohl(*(__be32 *)ipv6_hdr(skb)) >> 20) & 0xff; + int tclass = ipv6_tclass(ipv6_hdr(skb)); put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); } -- GitLab From 4c507d2897bd9be810b3403ade73b04cf6fdfd4a Mon Sep 17 00:00:00 2001 From: Jiri Benc Date: Thu, 9 Feb 2012 09:35:49 +0000 Subject: [PATCH 0532/1846] net: implement IP_RECVTOS for IP_PKTOPTIONS Currently, it is not easily possible to get TOS/DSCP value of packets from an incoming TCP stream. The mechanism is there, IP_PKTOPTIONS getsockopt with IP_RECVTOS set, the same way as incoming TTL can be queried. This is not actually implemented for TOS, though. This patch adds this functionality, both for IPv4 (IP_PKTOPTIONS) and IPv6 (IPV6_2292PKTOPTIONS). For IPv4, like in the IP_RECVTTL case, the value of the TOS field is stored from the other party's ACK. This is needed for proxies which require DSCP transparency. One such example is at http://zph.bratcheda.org/. Signed-off-by: Jiri Benc Signed-off-by: David S. Miller --- include/linux/ipv6.h | 2 +- include/net/inet_sock.h | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/ip_sockglue.c | 4 ++++ net/ipv4/tcp_ipv4.c | 1 + net/ipv6/af_inet6.c | 1 + net/ipv6/ipv6_sockglue.c | 4 ++++ net/ipv6/tcp_ipv6.c | 4 ++++ 8 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 4847a64d3c0a..8260ef779762 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -366,7 +366,7 @@ struct ipv6_pinfo { dontfrag:1; __u8 min_hopcount; __u8 tclass; - __u8 padding; + __u8 rcv_tclass; __u32 dst_cookie; diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index 022f772c0ebe..ae17e1352d7e 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -168,6 +168,7 @@ struct inet_sock { transparent:1, mc_all:1, nodefrag:1; + __u8 rcv_tos; int uc_index; int mc_index; __be32 mc_addr; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f7b5670744f0..e588a34e85c2 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -381,6 +381,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, inet->mc_all = 1; inet->mc_index = 0; inet->mc_list = NULL; + inet->rcv_tos = 0; sk_refcnt_debug_inc(sk); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 9125529dab95..ca50d9f9f8c1 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1289,6 +1289,10 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname, int hlim = inet->mc_ttl; put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim); } + if (inet->cmsg_flags & IP_CMSG_TOS) { + int tos = inet->rcv_tos; + put_cmsg(&msg, SOL_IP, IP_TOS, sizeof(tos), &tos); + } len -= msg.msg_controllen; return put_user(len, optlen); } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 4d6f81c818dc..94abee8cf563 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1463,6 +1463,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, ireq->opt = NULL; newinet->mc_index = inet_iif(skb); newinet->mc_ttl = ip_hdr(skb)->ttl; + newinet->rcv_tos = ip_hdr(skb)->tos; inet_csk(newsk)->icsk_ext_hdr_len = 0; if (inet_opt) inet_csk(newsk)->icsk_ext_hdr_len = inet_opt->opt.optlen; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 273f48d1df2e..5605f9dca87e 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -214,6 +214,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol, inet->mc_ttl = 1; inet->mc_index = 0; inet->mc_list = NULL; + inet->rcv_tos = 0; if (ipv4_config.no_pmtu_disc) inet->pmtudisc = IP_PMTUDISC_DONT; diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 6d6b65fdaa1a..63dd1f89ed7d 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -1017,6 +1017,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, int hlim = np->mcast_hops; put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim); } + if (np->rxopt.bits.rxtclass) { + int tclass = np->rcv_tclass; + put_cmsg(&msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); + } if (np->rxopt.bits.rxoinfo) { struct in6_pktinfo src_info; src_info.ipi6_ifindex = np->mcast_oif ? np->mcast_oif : diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index d16414cb3421..12c6ece67f39 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1282,6 +1282,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, newnp->opt = NULL; newnp->mcast_oif = inet6_iif(skb); newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; + newnp->rcv_tclass = ipv6_tclass(ipv6_hdr(skb)); /* * No need to charge this sock to the relevant IPv6 refcnt debug socks count @@ -1360,6 +1361,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, newnp->opt = NULL; newnp->mcast_oif = inet6_iif(skb); newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; + newnp->rcv_tclass = ipv6_tclass(ipv6_hdr(skb)); /* Clone native IPv6 options from listening socket (if any) @@ -1562,6 +1564,8 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) np->mcast_oif = inet6_iif(opt_skb); if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit; + if (np->rxopt.bits.rxtclass) + np->rcv_tclass = ipv6_tclass(ipv6_hdr(skb)); if (ipv6_opt_accepted(sk, opt_skb)) { skb_set_owner_r(opt_skb, sk); opt_skb = xchg(&np->pktoptions, opt_skb); -- GitLab From c8585bd89e2e3c87eab6ca711e09b3af20fd469b Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 9 Feb 2012 09:48:53 +0000 Subject: [PATCH 0533/1846] eth: reset addr_assign_type if eth_mac_addr() called If eth_mac_addr() get called, usually if SIOCSIFHWADDR was used to change the MAC of a ethernet device, reset the addr_assign_type to NET_ADDR_PERM if the state was NET_ADDR_RANDOM before. Reset the state since the MAC is no longer random at least not from the kernel side. v2: changed to bitops, removed if() Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- net/ethernet/eth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index a2468363978e..a93af86b8474 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -288,6 +288,8 @@ int eth_mac_addr(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + /* if device marked as NET_ADDR_RANDOM, reset it */ + dev->addr_assign_type &= ~NET_ADDR_RANDOM; return 0; } EXPORT_SYMBOL(eth_mac_addr); -- GitLab From 1a0d6ae5795c376bae6d012fb25e8341e4c6d5f2 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 9 Feb 2012 09:48:54 +0000 Subject: [PATCH 0534/1846] rename dev_hw_addr_random and remove redundant second Renamed dev_hw_addr_random to eth_hw_addr_random() to reflect that this function only assign a random ethernet address (MAC). Removed the second parameter (u8 *hwaddr), it's redundant since the also given net_device already contains net_device->dev_addr. Set it directly. Adapt igbvf and ixgbevf to the changed function. Small fix for ixgbevf_probe(): if ixgbevf_sw_init() fails (which means the device got no dev_addr) handle the error and jump to err_sw_init as already done by igbvf in similar case. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/igbvf/netdev.c | 11 +++++--- .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 28 +++++++++++-------- include/linux/etherdevice.h | 13 +++++---- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index 446297ff0104..92956e80fd1b 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c @@ -2712,18 +2712,19 @@ static int __devinit igbvf_probe(struct pci_dev *pdev, dev_info(&pdev->dev, "PF still in reset state, assigning new address." " Is the PF interface up?\n"); - dev_hw_addr_random(adapter->netdev, hw->mac.addr); + eth_hw_addr_random(netdev); + memcpy(adapter->hw.mac.addr, netdev->dev_addr, + netdev->addr_len); } else { err = hw->mac.ops.read_mac_addr(hw); if (err) { dev_err(&pdev->dev, "Error reading MAC address\n"); goto err_hw_init; } + memcpy(netdev->dev_addr, adapter->hw.mac.addr, + netdev->addr_len); } - memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); - memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); - if (!is_valid_ether_addr(netdev->perm_addr)) { dev_err(&pdev->dev, "Invalid MAC Address: %pM\n", netdev->dev_addr); @@ -2731,6 +2732,8 @@ static int __devinit igbvf_probe(struct pci_dev *pdev, goto err_hw_init; } + memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); + setup_timer(&adapter->watchdog_timer, &igbvf_watchdog, (unsigned long) adapter); diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index 58c04b69ce70..e10221dcebb1 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -2199,13 +2199,17 @@ static int __devinit ixgbevf_sw_init(struct ixgbevf_adapter *adapter) if (err) { dev_info(&pdev->dev, "PF still in reset state, assigning new address\n"); - dev_hw_addr_random(adapter->netdev, hw->mac.addr); + eth_hw_addr_random(adapter->netdev); + memcpy(adapter->hw.mac.addr, adapter->netdev->dev_addr, + adapter->netdev->addr_len); } else { err = hw->mac.ops.init_hw(hw); if (err) { pr_err("init_shared_code failed: %d\n", err); goto out; } + memcpy(adapter->netdev->dev_addr, adapter->hw.mac.addr, + adapter->netdev->addr_len); } /* Enable dynamic interrupt throttling rates */ @@ -2224,6 +2228,7 @@ static int __devinit ixgbevf_sw_init(struct ixgbevf_adapter *adapter) adapter->flags |= IXGBE_FLAG_RX_CSUM_ENABLED; set_bit(__IXGBEVF_DOWN, &adapter->state); + return 0; out: return err; @@ -3394,6 +3399,17 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev, /* setup the private structure */ err = ixgbevf_sw_init(adapter); + if (err) + goto err_sw_init; + + /* The HW MAC address was set and/or determined in sw_init */ + memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); + + if (!is_valid_ether_addr(netdev->dev_addr)) { + pr_err("invalid MAC address\n"); + err = -EIO; + goto err_sw_init; + } netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | @@ -3418,16 +3434,6 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev, netdev->priv_flags |= IFF_UNICAST_FLT; - /* The HW MAC address was set and/or determined in sw_init */ - memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); - memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); - - if (!is_valid_ether_addr(netdev->dev_addr)) { - pr_err("invalid MAC address\n"); - err = -EIO; - goto err_sw_init; - } - init_timer(&adapter->watchdog_timer); adapter->watchdog_timer.function = ixgbevf_watchdog; adapter->watchdog_timer.data = (unsigned long)adapter; diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 05955cf09937..8a1835855faa 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -140,17 +140,18 @@ static inline void random_ether_addr(u8 *addr) } /** - * dev_hw_addr_random - Create random MAC and set device flag + * eth_hw_addr_random - Generate software assigned random Ethernet and + * set device flag * @dev: pointer to net_device structure - * @hwaddr: Pointer to a six-byte array containing the Ethernet address * - * Generate random MAC to be used by a device and set addr_assign_type - * so the state can be read by sysfs and be used by udev. + * Generate a random Ethernet address (MAC) to be used by a net device + * and set addr_assign_type so the state can be read by sysfs and be + * used by userspace. */ -static inline void dev_hw_addr_random(struct net_device *dev, u8 *hwaddr) +static inline void eth_hw_addr_random(struct net_device *dev) { dev->addr_assign_type |= NET_ADDR_RANDOM; - random_ether_addr(hwaddr); + random_ether_addr(dev->dev_addr); } /** -- GitLab From 23677ce3172fcb93522a1df077d21019e73ee1e3 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 9 Feb 2012 11:17:23 +0000 Subject: [PATCH 0535/1846] drivers/net: Remove boolean comparisons to true/false Booleans should not be compared to true or false but be directly tested or tested with !. Done via cocci script: @@ bool t; @@ - t == true + t @@ bool t; @@ - t != true + !t @@ bool t; @@ - t == false + !t @@ bool t; @@ - t != false + t Signed-off-by: Joe Perches Reviewed-by: Jeff Kirsher Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 3 +-- drivers/net/ethernet/brocade/bna/bfa_cee.c | 8 ++++---- drivers/net/ethernet/brocade/bna/bfa_ioc.c | 2 +- drivers/net/ethernet/intel/ixgb/ixgb_ee.c | 12 +++++------- drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c | 4 ++-- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c | 2 +- .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 2 +- drivers/net/phy/broadcom.c | 6 ++---- drivers/net/wireless/ath/ath5k/ani.c | 8 ++++---- drivers/net/wireless/ath/ath9k/ani.c | 6 +++--- drivers/net/wireless/ath/ath9k/hw-ops.h | 2 +- drivers/net/wireless/ath/ath9k/hw.c | 5 ++--- .../net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 16 +++++++--------- drivers/net/wireless/brcm80211/brcmsmac/main.c | 4 ++-- .../net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 4 ++-- drivers/net/wireless/mwl8k.c | 5 ++--- drivers/net/wireless/rtlwifi/efuse.c | 2 +- drivers/net/wireless/rtlwifi/ps.c | 3 +-- .../net/wireless/rtlwifi/rtl8192c/dm_common.c | 4 ++-- .../net/wireless/rtlwifi/rtl8192c/phy_common.c | 8 ++++---- drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 9 ++++----- drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 3 +-- drivers/net/wireless/rtlwifi/rtl8192ce/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/phy.c | 3 +-- drivers/net/wireless/rtlwifi/rtl8192cu/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 9 ++++----- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 11 +++++------ drivers/net/wireless/rtlwifi/rtl8192de/rf.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/fw.c | 6 +++--- drivers/net/wireless/rtlwifi/rtl8192se/hw.c | 10 +++++----- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 13 ++++++------- drivers/net/wireless/rtlwifi/rtl8192se/rf.c | 2 +- 35 files changed, 84 insertions(+), 100 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index c7c7bf1e573a..67e97b709edd 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -614,8 +614,7 @@ static inline void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u32 igu_addr_ctl = IGU_REG_COMMAND_REG_CTRL; u32 igu_addr_ack = IGU_REG_CSTORM_TYPE_0_SB_CLEANUP + (idu_sb_id/32)*4; u32 sb_bit = 1 << (idu_sb_id%32); - u32 func_encode = func | - ((is_Pf == true ? 1 : 0) << IGU_FID_ENCODE_IS_PF_SHIFT); + u32 func_encode = func | (is_Pf ? 1 : 0) << IGU_FID_ENCODE_IS_PF_SHIFT; u32 addr_encode = IGU_CMD_E2_PROD_UPD_BASE + idu_sb_id; /* Not supported in BC mode */ diff --git a/drivers/net/ethernet/brocade/bna/bfa_cee.c b/drivers/net/ethernet/brocade/bna/bfa_cee.c index 29f284f79e02..689e5e19cc0b 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_cee.c +++ b/drivers/net/ethernet/brocade/bna/bfa_cee.c @@ -203,7 +203,7 @@ bfa_nw_cee_get_attr(struct bfa_cee *cee, struct bfa_cee_attr *attr, if (!bfa_nw_ioc_is_operational(cee->ioc)) return BFA_STATUS_IOC_FAILURE; - if (cee->get_attr_pending == true) + if (cee->get_attr_pending) return BFA_STATUS_DEVBUSY; cee->get_attr_pending = true; @@ -272,7 +272,7 @@ bfa_cee_notify(void *arg, enum bfa_ioc_event event) switch (event) { case BFA_IOC_E_DISABLED: case BFA_IOC_E_FAILED: - if (cee->get_attr_pending == true) { + if (cee->get_attr_pending) { cee->get_attr_status = BFA_STATUS_FAILED; cee->get_attr_pending = false; if (cee->cbfn.get_attr_cbfn) { @@ -281,7 +281,7 @@ bfa_cee_notify(void *arg, enum bfa_ioc_event event) BFA_STATUS_FAILED); } } - if (cee->get_stats_pending == true) { + if (cee->get_stats_pending) { cee->get_stats_status = BFA_STATUS_FAILED; cee->get_stats_pending = false; if (cee->cbfn.get_stats_cbfn) { @@ -290,7 +290,7 @@ bfa_cee_notify(void *arg, enum bfa_ioc_event event) BFA_STATUS_FAILED); } } - if (cee->reset_stats_pending == true) { + if (cee->reset_stats_pending) { cee->reset_stats_status = BFA_STATUS_FAILED; cee->reset_stats_pending = false; if (cee->cbfn.reset_stats_cbfn) { diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c index abfad275b5f3..77977d735dd7 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c +++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c @@ -692,7 +692,7 @@ static void bfa_iocpf_sm_mismatch_entry(struct bfa_iocpf *iocpf) { /* Call only the first time sm enters fwmismatch state. */ - if (iocpf->fw_mismatch_notified == false) + if (!iocpf->fw_mismatch_notified) bfa_ioc_pf_fwmismatch(iocpf->ioc); iocpf->fw_mismatch_notified = true; diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_ee.c b/drivers/net/ethernet/intel/ixgb/ixgb_ee.c index 2ed925f38811..eca216b9b859 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_ee.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_ee.c @@ -533,10 +533,8 @@ __le16 ixgb_get_eeprom_word(struct ixgb_hw *hw, u16 index) { - if ((index < IXGB_EEPROM_SIZE) && - (ixgb_check_and_get_eeprom_data(hw) == true)) { - return hw->eeprom[index]; - } + if (index < IXGB_EEPROM_SIZE && ixgb_check_and_get_eeprom_data(hw)) + return hw->eeprom[index]; return 0; } @@ -558,7 +556,7 @@ ixgb_get_ee_mac_addr(struct ixgb_hw *hw, ENTER(); - if (ixgb_check_and_get_eeprom_data(hw) == true) { + if (ixgb_check_and_get_eeprom_data(hw)) { for (i = 0; i < ETH_ALEN; i++) { mac_addr[i] = ee_map->mac_addr[i]; } @@ -578,7 +576,7 @@ ixgb_get_ee_mac_addr(struct ixgb_hw *hw, u32 ixgb_get_ee_pba_number(struct ixgb_hw *hw) { - if (ixgb_check_and_get_eeprom_data(hw) == true) + if (ixgb_check_and_get_eeprom_data(hw)) return le16_to_cpu(hw->eeprom[EEPROM_PBA_1_2_REG]) | (le16_to_cpu(hw->eeprom[EEPROM_PBA_3_4_REG])<<16); @@ -599,7 +597,7 @@ ixgb_get_ee_device_id(struct ixgb_hw *hw) { struct ixgb_ee_map_type *ee_map = (struct ixgb_ee_map_type *)hw->eeprom; - if (ixgb_check_and_get_eeprom_data(hw) == true) + if (ixgb_check_and_get_eeprom_data(hw)) return le16_to_cpu(ee_map->device_id); return 0; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c index b406c367b190..752dbe6f0f54 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c @@ -617,7 +617,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, *link_up = false; } - if (*link_up == false) + if (!*link_up) goto out; } @@ -645,7 +645,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, else *speed = IXGBE_LINK_SPEED_1GB_FULL; - if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && (*link_up == true) && + if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && *link_up && (ixgbe_validate_link_ready(hw) != 0)) *link_up = false; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c index b01ecb4d2bb1..88a58cb08569 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -258,7 +258,7 @@ static void ixgbe_restore_vf_macvlans(struct ixgbe_adapter *adapter) list_for_each(pos, &adapter->vf_mvs.l) { entry = list_entry(pos, struct vf_macvlans, l); - if (entry->free == false) + if (!entry->free) hw->mac.ops.set_rar(hw, entry->rar_entry, entry->vf_macvlan, entry->vf, IXGBE_RAH_AV); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c index f838a2be8cfb..5e9f05fa0134 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c @@ -760,7 +760,7 @@ static s32 ixgbe_blink_led_start_X540(struct ixgbe_hw *hw, u32 index) * This will be reversed when we stop the blinking. */ hw->mac.ops.check_link(hw, &speed, &link_up, false); - if (link_up == false) { + if (!link_up) { macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC); macc_reg |= IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS; IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg); 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 bdbec7e04a4c..69a66545c8ae 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 @@ -1224,7 +1224,7 @@ static irqreturn_t pch_gbe_intr(int irq, void *data) /* When request status is Receive interruption */ if ((int_st & (PCH_GBE_INT_RX_DMA_CMPLT | PCH_GBE_INT_TX_CMPLT)) || - (adapter->rx_stop_flag == true)) { + (adapter->rx_stop_flag)) { if (likely(napi_schedule_prep(&adapter->napi))) { /* Enable only Rx Descriptor empty */ atomic_inc(&adapter->irq_sem); diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index e8be47d6d7d0..60338ff63092 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -355,8 +355,7 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev) } } - if (clk125en == false || - (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) + if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS; else val |= BCM54XX_SHD_SCR3_DLLAPD_DIS; @@ -373,8 +372,7 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev) orig = val; - if (clk125en == false || - (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) + if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) val |= BCM54XX_SHD_APD_EN; else val &= ~BCM54XX_SHD_APD_EN; diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c index bf674161a217..35e93704c4ef 100644 --- a/drivers/net/wireless/ath/ath5k/ani.c +++ b/drivers/net/wireless/ath/ath5k/ani.c @@ -257,7 +257,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as, "beacon RSSI high"); /* only OFDM: beacon RSSI is high, we can disable ODFM weak * signal detection */ - if (ofdm_trigger && as->ofdm_weak_sig == true) { + if (ofdm_trigger && as->ofdm_weak_sig) { ath5k_ani_set_ofdm_weak_signal_detection(ah, false); ath5k_ani_set_spur_immunity_level(ah, 0); return; @@ -272,7 +272,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as, * but can raise firstep level */ ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "beacon RSSI mid"); - if (ofdm_trigger && as->ofdm_weak_sig == false) + if (ofdm_trigger && !as->ofdm_weak_sig) ath5k_ani_set_ofdm_weak_signal_detection(ah, true); if (as->firstep_level < ATH5K_ANI_MAX_FIRSTEP_LVL) ath5k_ani_set_firstep_level(ah, as->firstep_level + 1); @@ -282,7 +282,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as, * detect and zero firstep level to maximize CCK sensitivity */ ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "beacon RSSI low, 2GHz"); - if (ofdm_trigger && as->ofdm_weak_sig == true) + if (ofdm_trigger && as->ofdm_weak_sig) ath5k_ani_set_ofdm_weak_signal_detection(ah, false); if (as->firstep_level > 0) ath5k_ani_set_firstep_level(ah, 0); @@ -326,7 +326,7 @@ ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as) } else if (rssi > ATH5K_ANI_RSSI_THR_LOW) { /* beacon RSSI is mid-range: turn on ODFM weak signal * detection and next, lower firstep level */ - if (as->ofdm_weak_sig == false) { + if (!as->ofdm_weak_sig) { ath5k_ani_set_ofdm_weak_signal_detection(ah, true); return; diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c index bc56f57b393b..7e0ea4e98334 100644 --- a/drivers/net/wireless/ath/ath9k/ani.c +++ b/drivers/net/wireless/ath/ath9k/ani.c @@ -407,20 +407,20 @@ static void ath9k_hw_ani_lower_immunity_old(struct ath_hw *ah) if (aniState->ofdmWeakSigDetectOff) { if (ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION, - true) == true) + true)) return; } if (aniState->firstepLevel > 0) { if (ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL, - aniState->firstepLevel - 1) == true) + aniState->firstepLevel - 1)) return; } } else { if (aniState->firstepLevel > 0) { if (ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL, - aniState->firstepLevel - 1) == true) + aniState->firstepLevel - 1)) return; } } diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h b/drivers/net/wireless/ath/ath9k/hw-ops.h index c4ad0b06bdbc..265bf77598a2 100644 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h @@ -24,7 +24,7 @@ static inline void ath9k_hw_configpcipowersave(struct ath_hw *ah, bool power_off) { - if (ah->aspm_enabled != true) + if (!ah->aspm_enabled) return; ath9k_hw_ops(ah)->config_pci_powersave(ah, power_off); diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 87db1ee1c298..d0d13d7cf372 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1600,7 +1600,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, allow_fbs = true; if (bChannelChange && - (ah->chip_fullsleep != true) && + (!ah->chip_fullsleep) && (ah->curchan != NULL) && (chan->channel != ah->curchan->channel) && (allow_fbs || @@ -2038,8 +2038,7 @@ static bool ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip) if (setChip) { if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) == AR_RTC_STATUS_SHUTDOWN) { - if (ath9k_hw_set_reset_reg(ah, - ATH9K_RESET_POWER_ON) != true) { + if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { return false; } if (!AR_SREV_9300_20_OR_LATER(ah)) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 6e4b5e85a099..bd2d1dd5a495 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -767,7 +767,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) brcmf_dbg(INFO, "CLKCTL: turned ON\n"); #if defined(DEBUG) - if (bus->alp_only != true) { + if (!bus->alp_only) { if (SBSDIO_ALPONLY(clkctl)) brcmf_dbg(ERROR, "HT Clock should be on\n"); } @@ -2059,8 +2059,7 @@ static void brcmf_sdbrcm_wait_for_event(struct brcmf_sdio *bus, bool *lockvar) { up(&bus->sdsem); - wait_event_interruptible_timeout(bus->ctrl_wait, - (*lockvar == false), HZ * 2); + wait_event_interruptible_timeout(bus->ctrl_wait, !*lockvar, HZ * 2); down(&bus->sdsem); return; } @@ -2647,8 +2646,7 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt) /* Priority based enq */ spin_lock_bh(&bus->txqlock); - if (brcmf_c_prec_enq(bus->sdiodev->dev, &bus->txq, pkt, prec) == - false) { + if (!brcmf_c_prec_enq(bus->sdiodev->dev, &bus->txq, pkt, prec)) { skb_pull(pkt, SDPCM_HDRLEN); brcmf_txcomplete(bus->sdiodev->dev, pkt, false); brcmu_pkt_buf_free_skb(pkt); @@ -2935,7 +2933,7 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) brcmf_sdbrcm_wait_for_event(bus, &bus->ctrl_frame_stat); - if (bus->ctrl_frame_stat == false) { + if (!bus->ctrl_frame_stat) { brcmf_dbg(INFO, "ctrl_frame_stat == false\n"); ret = 0; } else { @@ -2997,7 +2995,7 @@ brcmf_sdbrcm_bus_rxctl(struct device *dev, unsigned char *msg, uint msglen) rxlen, msglen); } else if (timeleft == 0) { brcmf_dbg(ERROR, "resumed on timeout\n"); - } else if (pending == true) { + } else if (pending) { brcmf_dbg(CTL, "cancelled\n"); return -ERESTARTSYS; } else { @@ -3983,7 +3981,7 @@ void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick) { /* Totally stop the timer */ - if (!wdtick && bus->wd_timer_valid == true) { + if (!wdtick && bus->wd_timer_valid) { del_timer_sync(&bus->timer); bus->wd_timer_valid = false; bus->save_ms = wdtick; @@ -3996,7 +3994,7 @@ brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick) if (wdtick) { if (bus->save_ms != BRCMF_WD_POLL_MS) { - if (bus->wd_timer_valid == true) + if (bus->wd_timer_valid) /* Stop timer and restart at new value */ del_timer_sync(&bus->timer); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index fb712cac9157..90331dd22e5d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -3248,7 +3248,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) } /* For old ucode, txfifo sizes needs to be modified(increased) */ - if (fifosz_fixup == true) + if (fifosz_fixup) brcms_b_corerev_fifofixup(wlc_hw); /* check txfifo allocations match between ucode and driver */ @@ -5427,7 +5427,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) return -EINVAL; /* update configuration value */ - if (config == true) + if (config) brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); /* Clear rateset override */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index ec7450d2fbd6..62eedd82534d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -21464,7 +21464,7 @@ void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init) if (NREV_GE(pi->pubpi.phy_rev, 3)) { u16 v0 = 0x211, v1 = 0x222, v2 = 0x144, v3 = 0x188; - if (lut_init == false) + if (!lut_init) return; if (pi->srom_fem2g.antswctrllut == 0) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 30814b55705e..dfc75c172475 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -478,7 +478,7 @@ void iwl_trans_pcie_tx_agg_setup(struct iwl_trans *trans, } txq_id = trans_pcie->agg_txq[sta_id][tid]; - if (WARN_ON_ONCE(is_agg_txqid_valid(trans, txq_id) == false)) { + if (WARN_ON_ONCE(!is_agg_txqid_valid(trans, txq_id))) { IWL_ERR(trans, "queue number out of range: %d, must be %d to %d\n", txq_id, IWLAGN_FIRST_AMPDU_QUEUE, @@ -573,7 +573,7 @@ int iwl_trans_pcie_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); u8 txq_id = trans_pcie->agg_txq[sta_id][tid]; - if (WARN_ON_ONCE(is_agg_txqid_valid(trans, txq_id) == false)) { + if (WARN_ON_ONCE(!is_agg_txqid_valid(trans, txq_id))) { IWL_ERR(trans, "queue number out of range: %d, must be %d to %d\n", txq_id, IWLAGN_FIRST_AMPDU_QUEUE, diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index fd125473be7a..91c5f74350b7 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c @@ -1330,7 +1330,7 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit) wh->addr1); if (mwl8k_vif != NULL && - mwl8k_vif->is_hw_crypto_enabled == true) { + mwl8k_vif->is_hw_crypto_enabled) { /* * When MMIC ERROR is encountered * by the firmware, payload is @@ -1993,8 +1993,7 @@ mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb) */ if (txq->len >= MWL8K_TX_DESCS - 2) { - if (mgmtframe == false || - txq->len == MWL8K_TX_DESCS) { + if (!mgmtframe || txq->len == MWL8K_TX_DESCS) { if (start_ba_session) { spin_lock(&priv->stream_lock); mwl8k_remove_stream(hw, stream); diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index b24cbe6e16d8..1f143800a8d7 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c @@ -777,7 +777,7 @@ static void efuse_write_data_case1(struct ieee80211_hw *hw, u16 *efuse_addr, dataempty = false; } - if (dataempty == false) { + if (!dataempty) { *efuse_addr = *efuse_addr + (tmp_word_cnts * 2) + 1; *write_state = PG_STATE_HEADER; } else { diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index 15f86eaa1cd6..5b9c3b5e8c92 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -105,8 +105,7 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw, case ERFOFF: - if ((changesource == RF_CHANGE_BY_HW) - && (ppsc->hwradiooff == false)) { + if ((changesource == RF_CHANGE_BY_HW) && !ppsc->hwradiooff) { ppsc->hwradiooff = true; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index cb5535cf3ae2..a64473556ea8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -329,8 +329,8 @@ static void rtl92c_dm_initial_gain_multi_sta(struct ieee80211_hw *hw) if (mac->opmode == NL80211_IFTYPE_ADHOC) multi_sta = true; - if ((multi_sta == false) || (dm_digtable.cursta_connectctate != - DIG_STA_DISCONNECT)) { + if (!multi_sta || + dm_digtable.cursta_connectctate != DIG_STA_DISCONNECT) { initialized = false; dm_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; return; diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index 22e998dd2f32..bfff5fe8623c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -216,7 +216,7 @@ bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n"); rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw, BASEBAND_CONFIG_PHY_REG); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Write BB Reg Fail!!\n"); return false; } @@ -229,13 +229,13 @@ bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw) rtstatus = rtlpriv->cfg->ops->config_bb_with_pgheaderfile(hw, BASEBAND_CONFIG_PHY_REG); } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "BB_PG Reg Fail!!\n"); return false; } rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw, BASEBAND_CONFIG_AGC_TAB); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "AGC Table Fail\n"); return false; } @@ -580,7 +580,7 @@ void rtl92c_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) struct rtl_efuse *rtlefuse = rtl_efuse(rtlpriv); u8 cckpowerlevel[2], ofdmpowerlevel[2]; - if (rtlefuse->txpwr_fromeprom == false) + if (!rtlefuse->txpwr_fromeprom) return; _rtl92c_get_txpower_index(hw, channel, &cckpowerlevel[0], &ofdmpowerlevel[0]); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 48c7b5d3fc5b..5c4d9bc040f1 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -693,7 +693,7 @@ static bool _rtl92ce_init_mac(struct ieee80211_hw *hw) rtl_write_word(rtlpriv, REG_CR, 0x2ff); - if (_rtl92ce_llt_table_init(hw) == false) + if (!_rtl92ce_llt_table_init(hw)) return false; rtl_write_dword(rtlpriv, REG_HISR, 0xffffffff); @@ -906,7 +906,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw) rtlpci->being_init_adapter = true; rtlpriv->intf_ops->disable_aspm(hw); rtstatus = _rtl92ce_init_mac(hw); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n"); err = 1; return err; @@ -1117,7 +1117,7 @@ void rtl92ce_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *) (®_rcr)); _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4)); - } else if (check_bssid == false) { + } else if (!check_bssid) { reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN)); _rtl92ce_set_bcn_ctrl_reg(hw, BIT(4), 0); rtlpriv->cfg->ops->set_hw_reg(hw, @@ -1985,8 +1985,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) e_rfpowerstate_toset = ERFON; ppsc->hwradiooff = false; actuallyset = true; - } else if ((ppsc->hwradiooff == false) - && (e_rfpowerstate_toset == ERFOFF)) { + } else if (!ppsc->hwradiooff && (e_rfpowerstate_toset == ERFOFF)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "GPIOChangeRF - HW Radio OFF, RF OFF\n"); diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c index c64daf25566a..88deae67cc14 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c @@ -522,8 +522,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); - } while ((rtstatus != true) - && (InitializeCount < 10)); + } while (!rtstatus && (InitializeCount < 10)); RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); } else { diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c index 69d720dd9c38..54c7614958a8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c @@ -503,7 +503,7 @@ static bool _rtl92ce_phy_rf6052_config_parafile(struct ieee80211_hw *hw) break; } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio[%d] Fail!!\n", rfpath); return false; diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c index 8ac3bcca4d41..34e56308301e 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c @@ -477,8 +477,7 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); - } while ((rtstatus != true) - && (InitializeCount < 10)); + } while (!rtstatus && (InitializeCount < 10)); RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); } else { diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c index 780c0d98a836..506b9a078ed1 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c @@ -479,7 +479,7 @@ static bool _rtl92c_phy_rf6052_config_parafile(struct ieee80211_hw *hw) BRFSI_RFENV << 16, u4_regvalue); break; } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio[%d] Fail!!", rfpath); goto phy_rf_cfg_fail; diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c index 181ed6fc90e6..24b407ff0416 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c @@ -405,7 +405,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw) de_digtable.last_min_undecorated_pwdb_for_dm = de_digtable.min_undecorated_pwdb_for_dm; } - if (rtlpriv->dm.dm_initialgain_enable == false) + if (!rtlpriv->dm.dm_initialgain_enable) return; /* because we will send data pkt when scanning diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c index 7d877125db29..509f5af38adf 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c @@ -707,7 +707,7 @@ static bool _rtl92de_init_mac(struct ieee80211_hw *hw) /* System init */ /* 18. LLT_table_init(Adapter); */ - if (_rtl92de_llt_table_init(hw) == false) + if (!_rtl92de_llt_table_init(hw)) return false; /* Clear interrupt and enable interrupt */ @@ -920,7 +920,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw) rtl92d_phy_reset_iqk_result(hw); /* rtlpriv->intf_ops->disable_aspm(hw); */ rtstatus = _rtl92de_init_mac(hw); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n"); err = 1; spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); @@ -1147,7 +1147,7 @@ void rtl92de_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(4)); - } else if (check_bssid == false) { + } else if (!check_bssid) { reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN)); _rtl92de_set_bcn_ctrl_reg(hw, BIT(4), 0); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); @@ -2151,8 +2151,7 @@ bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) e_rfpowerstate_toset = ERFON; ppsc->hwradiooff = false; actuallyset = true; - } else if ((ppsc->hwradiooff == false) - && (e_rfpowerstate_toset == ERFOFF)) { + } else if (!ppsc->hwradiooff && (e_rfpowerstate_toset == ERFOFF)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "GPIOChangeRF - HW Radio OFF, RF OFF\n"); e_rfpowerstate_toset = ERFOFF; diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index 9581a19c2548..93eecbd89402 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -859,7 +859,7 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n"); rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, BASEBAND_CONFIG_PHY_REG); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Write BB Reg Fail!!\n"); return false; } @@ -874,13 +874,13 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw) rtstatus = _rtl92d_phy_config_bb_with_pgheaderfile(hw, BASEBAND_CONFIG_PHY_REG); } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "BB_PG Reg Fail!!\n"); return false; } rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, BASEBAND_CONFIG_AGC_TAB); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "AGC Table Fail\n"); return false; } @@ -1129,7 +1129,7 @@ void rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) struct rtl_priv *rtlpriv = rtl_priv(hw); u8 cckpowerlevel[2], ofdmpowerlevel[2]; - if (rtlefuse->txpwr_fromeprom == false) + if (!rtlefuse->txpwr_fromeprom) return; channel = _rtl92c_phy_get_rightchnlplace(channel); _rtl92d_get_txpower_index(hw, channel, &cckpowerlevel[0], @@ -3320,8 +3320,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); - } while ((rtstatus != true) && - (InitializeCount < 10)); + } while (!rtstatus && (InitializeCount < 10)); RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c index ff34d2dd39b8..3066a7fb0b57 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c @@ -601,7 +601,7 @@ bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw) u4_regvalue); break; } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio[%d] Fail!!", rfpath); goto phy_rf_cfg_fail; diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c index 0d8bf5657008..380e7d4b1ccf 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c @@ -272,7 +272,7 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw, /* Turn On CPU */ rtstatus = _rtl92s_firmware_enable_cpu(hw); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Enable CPU fail!\n"); goto status_check_fail; @@ -445,14 +445,14 @@ int rtl92s_download_fw(struct ieee80211_hw *hw) rtstatus = _rtl92s_firmware_downloadcode(hw, puc_mappedfile, ul_filelength); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "fail!\n"); goto fail; } /* <3> Check whether load FW process is ready */ rtstatus = _rtl92s_firmware_checkready(hw, fwstatus); - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "fail!\n"); goto fail; } diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index 22098c2f38f1..b141c35bf926 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -962,7 +962,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) rtlhal->fwcmd_ioparam = rtl_read_dword(rtlpriv, LBUS_ADDR_MASK); /* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */ - if (rtl92s_phy_mac_config(hw) != true) { + if (!rtl92s_phy_mac_config(hw)) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "MAC Config failed\n"); return rtstatus; } @@ -972,7 +972,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) rtl_write_dword(rtlpriv, CMDR, 0x37FC); /* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */ - if (rtl92s_phy_bb_config(hw) != true) { + if (!rtl92s_phy_bb_config(hw)) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "BB Config failed\n"); return rtstatus; } @@ -1008,7 +1008,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) else rtl_write_byte(rtlpriv, RF_CTRL, 0x07); - if (rtl92s_phy_rf_config(hw) != true) { + if (!rtl92s_phy_rf_config(hw)) { RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "RF Config failed\n"); return rtstatus; } @@ -1105,7 +1105,7 @@ void rtl92se_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) if (check_bssid) { reg_rcr |= (RCR_CBSSID); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); - } else if (check_bssid == false) { + } else if (!check_bssid) { reg_rcr &= (~RCR_CBSSID); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); } @@ -2306,7 +2306,7 @@ bool rtl92se_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) rfpwr_toset = ERFON; ppsc->hwradiooff = false; actuallyset = true; - } else if ((ppsc->hwradiooff == false) && (rfpwr_toset == ERFOFF)) { + } else if ((!ppsc->hwradiooff) && (rfpwr_toset == ERFOFF)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "RFKILL-HW Radio OFF, RF OFF\n"); diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index 05b4e2790e99..3bfc411f13b8 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -558,8 +558,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, "IPS Set eRf nic enable\n"); rtstatus = rtl_ps_enable_nic(hw); - } while ((rtstatus != true) && - (InitializeCount < 10)); + } while (!rtstatus && (InitializeCount < 10)); RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); @@ -990,7 +989,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw) rtstatus = false; } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Write BB Reg Fail!!\n"); goto phy_BB8190_Config_ParaFile_Fail; @@ -1004,7 +1003,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw) rtstatus = _rtl92s_phy_config_bb_with_pg(hw, BASEBAND_CONFIG_PHY_REG); } - if (rtstatus != true) { + if (!rtstatus) { RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "_rtl92s_phy_bb_config_parafile(): BB_PG Reg Fail!!\n"); goto phy_BB8190_Config_ParaFile_Fail; @@ -1013,7 +1012,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw) /* 3. BB AGC table Initialization */ rtstatus = _rtl92s_phy_config_bb(hw, BASEBAND_CONFIG_AGC_TAB); - if (rtstatus != true) { + if (!rtstatus) { pr_err("%s(): AGC Table Fail\n", __func__); goto phy_BB8190_Config_ParaFile_Fail; } @@ -1270,7 +1269,7 @@ void rtl92s_phy_set_txpower(struct ieee80211_hw *hw, u8 channel) /* [0]:RF-A, [1]:RF-B */ u8 cckpowerlevel[2], ofdmpowerLevel[2]; - if (rtlefuse->txpwr_fromeprom == false) + if (!rtlefuse->txpwr_fromeprom) return; /* Mainly we use RF-A Tx Power to write the Tx Power registers, @@ -1621,7 +1620,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) break; case FW_CMD_HIGH_PWR_ENABLE: if (!(rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) && - (rtlpriv->dm.dynamic_txpower_enable != true)) { + !rtlpriv->dm.dynamic_txpower_enable) { fw_cmdmap |= (FW_HIGH_PWR_ENABLE_CTL | FW_SS_CTL); FW_CMD_IO_SET(rtlpriv, fw_cmdmap); diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c index ad51906124db..08c2f5625129 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c @@ -499,7 +499,7 @@ bool rtl92s_phy_rf6052_config(struct ieee80211_hw *hw) break; } - if (rtstatus != true) { + if (!rtstatus) { pr_err("Radio[%d] Fail!!\n", rfpath); goto fail; } -- GitLab From 10ef9ab4329edd08bccc7a8d34b96b85714195ce Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 9 Feb 2012 18:05:27 +0000 Subject: [PATCH 0536/1846] be2net: event queue re-design v2: Fixed up the bad typecasting pointed out by David... In the current design 8 TXQs are serviced by 1 EQ, while each RSS queue is serviced by a separate EQ. This is being changed as follows: - Upto 8 EQs will be used (based on the availabilty of msix vectors). Each EQ will handle 1 RSS and 1 TX ring. The default non-RSS RX queue and MCC queue are handled by the last EQ. - On cards which provide support, upto 8 RSS rings will be used, instead of the current limit of 4. The new design allows spreading the TX multi-queue completion processing across multiple CPUs unlike the previous design. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 65 +- drivers/net/ethernet/emulex/benet/be_cmds.c | 31 +- drivers/net/ethernet/emulex/benet/be_cmds.h | 8 +- .../net/ethernet/emulex/benet/be_ethtool.c | 96 +-- drivers/net/ethernet/emulex/benet/be_main.c | 812 ++++++++---------- 5 files changed, 434 insertions(+), 578 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 74aa14811977..86f51dea0c39 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -81,7 +81,7 @@ static inline char *nic_name(struct pci_dev *pdev) #define BE_MIN_MTU 256 #define BE_NUM_VLANS_SUPPORTED 64 -#define BE_MAX_EQD 96 +#define BE_MAX_EQD 96u #define BE_MAX_TX_FRAG_COUNT 30 #define EVNT_Q_LEN 1024 @@ -92,12 +92,16 @@ static inline char *nic_name(struct pci_dev *pdev) #define MCC_Q_LEN 128 /* total size not to exceed 8 pages */ #define MCC_CQ_LEN 256 -#define MAX_RSS_QS 4 /* BE limit is 4 queues/port */ +#define BE3_MAX_RSS_QS 8 +#define BE2_MAX_RSS_QS 4 +#define MAX_RSS_QS BE3_MAX_RSS_QS #define MAX_RX_QS (MAX_RSS_QS + 1) /* RSS qs + 1 def Rx */ + #define MAX_TX_QS 8 -#define BE_MAX_MSIX_VECTORS (MAX_RX_QS + 1)/* RX + TX */ +#define MAX_MSIX_VECTORS MAX_RSS_QS +#define BE_TX_BUDGET 256 #define BE_NAPI_WEIGHT 64 -#define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ +#define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ #define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST) #define FW_VER_LEN 32 @@ -165,13 +169,16 @@ struct be_eq_obj { /* Adaptive interrupt coalescing (AIC) info */ bool enable_aic; - u16 min_eqd; /* in usecs */ - u16 max_eqd; /* in usecs */ - u16 cur_eqd; /* in usecs */ - u8 eq_idx; + u32 min_eqd; /* in usecs */ + u32 max_eqd; /* in usecs */ + u32 eqd; /* configured val when aic is off */ + u32 cur_eqd; /* in usecs */ + u8 idx; /* array index */ + u16 tx_budget; struct napi_struct napi; -}; + struct be_adapter *adapter; +} ____cacheline_aligned_in_smp; struct be_mcc_obj { struct be_queue_info q; @@ -197,7 +204,7 @@ struct be_tx_obj { /* Remember the skbs that were transmitted */ struct sk_buff *sent_skb_list[TX_Q_LEN]; struct be_tx_stats stats; -}; +} ____cacheline_aligned_in_smp; /* Struct to remember the pages posted for rx frags */ struct be_rx_page_info { @@ -215,8 +222,6 @@ struct be_rx_stats { u32 rx_drops_no_skbs; /* skb allocation errors */ u32 rx_drops_no_frags; /* HW has no fetched frags */ u32 rx_post_fail; /* page post alloc failures */ - u32 rx_polls; /* NAPI calls */ - u32 rx_events; u32 rx_compl; u32 rx_mcast_pkts; u32 rx_compl_err; /* completions with err set */ @@ -249,16 +254,13 @@ struct be_rx_obj { struct be_queue_info cq; struct be_rx_compl_info rxcp; struct be_rx_page_info page_info_tbl[RX_Q_LEN]; - struct be_eq_obj rx_eq; struct be_rx_stats stats; u8 rss_id; bool rx_post_starved; /* Zero rx frags have been posted to BE */ - u32 cache_line_barrier[16]; -}; +} ____cacheline_aligned_in_smp; struct be_drv_stats { u32 be_on_die_temperature; - u32 tx_events; u32 eth_red_drops; u32 rx_drops_no_pbuf; u32 rx_drops_no_txpb; @@ -320,20 +322,19 @@ struct be_adapter { spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */ spinlock_t mcc_cq_lock; - struct msix_entry msix_entries[BE_MAX_MSIX_VECTORS]; u32 num_msix_vec; + u32 num_evt_qs; + struct be_eq_obj eq_obj[MAX_MSIX_VECTORS]; + struct msix_entry msix_entries[MAX_MSIX_VECTORS]; bool isr_registered; /* TX Rings */ - struct be_eq_obj tx_eq; + u32 num_tx_qs; struct be_tx_obj tx_obj[MAX_TX_QS]; - u8 num_tx_qs; - - u32 cache_line_break[8]; /* Rx rings */ - struct be_rx_obj rx_obj[MAX_RX_QS]; u32 num_rx_qs; + struct be_rx_obj rx_obj[MAX_RX_QS]; u32 big_page_size; /* Compounded page size shared by rx wrbs */ u8 eq_next_idx; @@ -404,24 +405,34 @@ struct be_adapter { extern const struct ethtool_ops be_ethtool_ops; #define msix_enabled(adapter) (adapter->num_msix_vec > 0) -#define tx_stats(txo) (&txo->stats) -#define rx_stats(rxo) (&rxo->stats) +#define num_irqs(adapter) (msix_enabled(adapter) ? \ + adapter->num_msix_vec : 1) +#define tx_stats(txo) (&(txo)->stats) +#define rx_stats(rxo) (&(rxo)->stats) -#define BE_SET_NETDEV_OPS(netdev, ops) (netdev->netdev_ops = ops) +/* The default RXQ is the last RXQ */ +#define default_rxo(adpt) (&adpt->rx_obj[adpt->num_rx_qs - 1]) #define for_all_rx_queues(adapter, rxo, i) \ for (i = 0, rxo = &adapter->rx_obj[i]; i < adapter->num_rx_qs; \ i++, rxo++) -/* Just skip the first default non-rss queue */ +/* Skip the default non-rss queue (last one)*/ #define for_all_rss_queues(adapter, rxo, i) \ - for (i = 0, rxo = &adapter->rx_obj[i+1]; i < (adapter->num_rx_qs - 1);\ + for (i = 0, rxo = &adapter->rx_obj[i]; i < (adapter->num_rx_qs - 1);\ i++, rxo++) #define for_all_tx_queues(adapter, txo, i) \ for (i = 0, txo = &adapter->tx_obj[i]; i < adapter->num_tx_qs; \ i++, txo++) +#define for_all_evt_queues(adapter, eqo, i) \ + for (i = 0, eqo = &adapter->eq_obj[i]; i < adapter->num_evt_qs; \ + i++, eqo++) + +#define is_mcc_eqo(eqo) (eqo->idx == 0) +#define mcc_eqo(adapter) (&adapter->eq_obj[0]) + #define PAGE_SHIFT_4K 12 #define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 29dff7de66b6..6432efa7b9cb 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -235,10 +235,10 @@ void be_async_mcc_disable(struct be_adapter *adapter) adapter->mcc_obj.rearm_cq = false; } -int be_process_mcc(struct be_adapter *adapter, int *status) +int be_process_mcc(struct be_adapter *adapter) { struct be_mcc_compl *compl; - int num = 0; + int num = 0, status = 0; struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; spin_lock_bh(&adapter->mcc_cq_lock); @@ -252,32 +252,32 @@ int be_process_mcc(struct be_adapter *adapter, int *status) be_async_grp5_evt_process(adapter, compl->flags, compl); } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { - *status = be_mcc_compl_process(adapter, compl); + status = be_mcc_compl_process(adapter, compl); atomic_dec(&mcc_obj->q.used); } be_mcc_compl_use(compl); num++; } + if (num) + be_cq_notify(adapter, mcc_obj->cq.id, mcc_obj->rearm_cq, num); + spin_unlock_bh(&adapter->mcc_cq_lock); - return num; + return status; } /* Wait till no more pending mcc requests are present */ static int be_mcc_wait_compl(struct be_adapter *adapter) { #define mcc_timeout 120000 /* 12s timeout */ - int i, num, status = 0; + int i, status = 0; struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; for (i = 0; i < mcc_timeout; i++) { if (be_error(adapter)) return -EIO; - num = be_process_mcc(adapter, &status); - if (num) - be_cq_notify(adapter, mcc_obj->cq.id, - mcc_obj->rearm_cq, num); + status = be_process_mcc(adapter); if (atomic_read(&mcc_obj->q.used) == 0) break; @@ -726,9 +726,8 @@ int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom) } /* Uses Mbox */ -int be_cmd_cq_create(struct be_adapter *adapter, - struct be_queue_info *cq, struct be_queue_info *eq, - bool sol_evts, bool no_delay, int coalesce_wm) +int be_cmd_cq_create(struct be_adapter *adapter, struct be_queue_info *cq, + struct be_queue_info *eq, bool no_delay, int coalesce_wm) { struct be_mcc_wrb *wrb; struct be_cmd_req_cq_create *req; @@ -759,7 +758,6 @@ int be_cmd_cq_create(struct be_adapter *adapter, ctxt, 1); AMAP_SET_BITS(struct amap_cq_context_lancer, eqid, ctxt, eq->id); - AMAP_SET_BITS(struct amap_cq_context_lancer, armed, ctxt, 1); } else { AMAP_SET_BITS(struct amap_cq_context_be, coalescwm, ctxt, coalesce_wm); @@ -768,11 +766,8 @@ int be_cmd_cq_create(struct be_adapter *adapter, AMAP_SET_BITS(struct amap_cq_context_be, count, ctxt, __ilog2_u32(cq->len/256)); AMAP_SET_BITS(struct amap_cq_context_be, valid, ctxt, 1); - AMAP_SET_BITS(struct amap_cq_context_be, solevent, - ctxt, sol_evts); AMAP_SET_BITS(struct amap_cq_context_be, eventable, ctxt, 1); AMAP_SET_BITS(struct amap_cq_context_be, eqid, ctxt, eq->id); - AMAP_SET_BITS(struct amap_cq_context_be, armed, ctxt, 1); } be_dws_cpu_to_le(ctxt, sizeof(req->context)); @@ -973,7 +968,7 @@ int be_cmd_txq_create(struct be_adapter *adapter, /* Uses MCC */ int be_cmd_rxq_create(struct be_adapter *adapter, struct be_queue_info *rxq, u16 cq_id, u16 frag_size, - u16 max_frame_size, u32 if_id, u32 rss, u8 *rss_id) + u32 if_id, u32 rss, u8 *rss_id) { struct be_mcc_wrb *wrb; struct be_cmd_req_eth_rx_create *req; @@ -997,7 +992,7 @@ int be_cmd_rxq_create(struct be_adapter *adapter, req->num_pages = 2; be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); req->interface_id = cpu_to_le32(if_id); - req->max_frame_size = cpu_to_le16(max_frame_size); + req->max_frame_size = cpu_to_le16(BE_MAX_JUMBO_FRAME_SIZE); req->rss_queue = cpu_to_le32(rss); status = be_mcc_notify_wait(adapter); diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index 5bb66c80f05e..687c42071411 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -1506,8 +1506,7 @@ extern int be_cmd_eq_create(struct be_adapter *adapter, struct be_queue_info *eq, int eq_delay); extern int be_cmd_cq_create(struct be_adapter *adapter, struct be_queue_info *cq, struct be_queue_info *eq, - bool sol_evts, bool no_delay, - int num_cqe_dma_coalesce); + bool no_delay, int num_cqe_dma_coalesce); extern int be_cmd_mccq_create(struct be_adapter *adapter, struct be_queue_info *mccq, struct be_queue_info *cq); @@ -1516,8 +1515,7 @@ extern int be_cmd_txq_create(struct be_adapter *adapter, struct be_queue_info *cq); extern int be_cmd_rxq_create(struct be_adapter *adapter, struct be_queue_info *rxq, u16 cq_id, - u16 frag_size, u16 max_frame_size, u32 if_id, - u32 rss, u8 *rss_id); + u16 frag_size, u32 if_id, u32 rss, u8 *rss_id); extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, int type); extern int be_cmd_rxq_destroy(struct be_adapter *adapter, @@ -1546,7 +1544,7 @@ extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, extern int be_cmd_reset_function(struct be_adapter *adapter); extern int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, u16 table_size); -extern int be_process_mcc(struct be_adapter *adapter, int *status); +extern int be_process_mcc(struct be_adapter *adapter); extern int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon, u8 status, u8 state); extern int be_cmd_get_beacon_state(struct be_adapter *adapter, diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index dc1383c396c0..30ce17806916 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -37,7 +37,6 @@ enum {DRVSTAT_TX, DRVSTAT_RX, DRVSTAT}; FIELDINFO(struct be_drv_stats, field) static const struct be_ethtool_stat et_stats[] = { - {DRVSTAT_INFO(tx_events)}, {DRVSTAT_INFO(rx_crc_errors)}, {DRVSTAT_INFO(rx_alignment_symbol_errors)}, {DRVSTAT_INFO(rx_pause_frames)}, @@ -126,8 +125,6 @@ static const struct be_ethtool_stat et_stats[] = { static const struct be_ethtool_stat et_rx_stats[] = { {DRVSTAT_RX_INFO(rx_bytes)},/* If moving this member see above note */ {DRVSTAT_RX_INFO(rx_pkts)}, /* If moving this member see above note */ - {DRVSTAT_RX_INFO(rx_polls)}, - {DRVSTAT_RX_INFO(rx_events)}, {DRVSTAT_RX_INFO(rx_compl)}, {DRVSTAT_RX_INFO(rx_mcast_pkts)}, /* Number of page allocation failures while posting receive buffers @@ -154,7 +151,6 @@ static const struct be_ethtool_stat et_tx_stats[] = { {DRVSTAT_TX_INFO(tx_reqs)}, /* Number of TX work request blocks DMAed to HW */ {DRVSTAT_TX_INFO(tx_wrbs)}, - {DRVSTAT_TX_INFO(tx_compl)}, /* Number of times the TX queue was stopped due to lack * of spaces in the TXQ. */ @@ -290,86 +286,42 @@ be_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *buf) } } -static int -be_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) +static int be_get_coalesce(struct net_device *netdev, + struct ethtool_coalesce *et) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_eq_obj *rx_eq = &adapter->rx_obj[0].rx_eq; - struct be_eq_obj *tx_eq = &adapter->tx_eq; + struct be_eq_obj *eqo = &adapter->eq_obj[0]; + - coalesce->rx_coalesce_usecs = rx_eq->cur_eqd; - coalesce->rx_coalesce_usecs_high = rx_eq->max_eqd; - coalesce->rx_coalesce_usecs_low = rx_eq->min_eqd; + et->rx_coalesce_usecs = eqo->cur_eqd; + et->rx_coalesce_usecs_high = eqo->max_eqd; + et->rx_coalesce_usecs_low = eqo->min_eqd; - coalesce->tx_coalesce_usecs = tx_eq->cur_eqd; - coalesce->tx_coalesce_usecs_high = tx_eq->max_eqd; - coalesce->tx_coalesce_usecs_low = tx_eq->min_eqd; + et->tx_coalesce_usecs = eqo->cur_eqd; + et->tx_coalesce_usecs_high = eqo->max_eqd; + et->tx_coalesce_usecs_low = eqo->min_eqd; - coalesce->use_adaptive_rx_coalesce = rx_eq->enable_aic; - coalesce->use_adaptive_tx_coalesce = tx_eq->enable_aic; + et->use_adaptive_rx_coalesce = eqo->enable_aic; + et->use_adaptive_tx_coalesce = eqo->enable_aic; return 0; } -/* - * This routine is used to set interrup coalescing delay +/* TX attributes are ignored. Only RX attributes are considered + * eqd cmd is issued in the worker thread. */ -static int -be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) +static int be_set_coalesce(struct net_device *netdev, + struct ethtool_coalesce *et) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_rx_obj *rxo; - struct be_eq_obj *rx_eq; - struct be_eq_obj *tx_eq = &adapter->tx_eq; - u32 rx_max, rx_min, rx_cur; - int status = 0, i; - u32 tx_cur; - - if (coalesce->use_adaptive_tx_coalesce == 1) - return -EINVAL; - - for_all_rx_queues(adapter, rxo, i) { - rx_eq = &rxo->rx_eq; - - if (!rx_eq->enable_aic && coalesce->use_adaptive_rx_coalesce) - rx_eq->cur_eqd = 0; - rx_eq->enable_aic = coalesce->use_adaptive_rx_coalesce; - - rx_max = coalesce->rx_coalesce_usecs_high; - rx_min = coalesce->rx_coalesce_usecs_low; - rx_cur = coalesce->rx_coalesce_usecs; - - if (rx_eq->enable_aic) { - if (rx_max > BE_MAX_EQD) - rx_max = BE_MAX_EQD; - if (rx_min > rx_max) - rx_min = rx_max; - rx_eq->max_eqd = rx_max; - rx_eq->min_eqd = rx_min; - if (rx_eq->cur_eqd > rx_max) - rx_eq->cur_eqd = rx_max; - if (rx_eq->cur_eqd < rx_min) - rx_eq->cur_eqd = rx_min; - } else { - if (rx_cur > BE_MAX_EQD) - rx_cur = BE_MAX_EQD; - if (rx_eq->cur_eqd != rx_cur) { - status = be_cmd_modify_eqd(adapter, rx_eq->q.id, - rx_cur); - if (!status) - rx_eq->cur_eqd = rx_cur; - } - } - } - - tx_cur = coalesce->tx_coalesce_usecs; - - if (tx_cur > BE_MAX_EQD) - tx_cur = BE_MAX_EQD; - if (tx_eq->cur_eqd != tx_cur) { - status = be_cmd_modify_eqd(adapter, tx_eq->q.id, tx_cur); - if (!status) - tx_eq->cur_eqd = tx_cur; + struct be_eq_obj *eqo; + int i; + + for_all_evt_queues(adapter, eqo, i) { + eqo->enable_aic = et->use_adaptive_rx_coalesce; + eqo->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD); + eqo->min_eqd = min(et->rx_coalesce_usecs_low, eqo->max_eqd); + eqo->eqd = et->rx_coalesce_usecs; } return 0; diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 780498784d8e..28f2b254d227 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -144,7 +144,7 @@ static int be_queue_alloc(struct be_adapter *adapter, struct be_queue_info *q, mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, &mem->dma, GFP_KERNEL); if (!mem->va) - return -1; + return -ENOMEM; memset(mem->va, 0, mem->size); return 0; } @@ -996,18 +996,24 @@ static int be_set_vf_tx_rate(struct net_device *netdev, return status; } -static void be_rx_eqd_update(struct be_adapter *adapter, struct be_rx_obj *rxo) +static void be_eqd_update(struct be_adapter *adapter, struct be_eq_obj *eqo) { - struct be_eq_obj *rx_eq = &rxo->rx_eq; - struct be_rx_stats *stats = rx_stats(rxo); + struct be_rx_stats *stats = rx_stats(&adapter->rx_obj[eqo->idx]); ulong now = jiffies; ulong delta = now - stats->rx_jiffies; u64 pkts; unsigned int start, eqd; - if (!rx_eq->enable_aic) + if (!eqo->enable_aic) { + eqd = eqo->eqd; + goto modify_eqd; + } + + if (eqo->idx >= adapter->num_rx_qs) return; + stats = rx_stats(&adapter->rx_obj[eqo->idx]); + /* Wrapped around */ if (time_before(now, stats->rx_jiffies)) { stats->rx_jiffies = now; @@ -1026,17 +1032,16 @@ static void be_rx_eqd_update(struct be_adapter *adapter, struct be_rx_obj *rxo) stats->rx_pps = (unsigned long)(pkts - stats->rx_pkts_prev) / (delta / HZ); stats->rx_pkts_prev = pkts; stats->rx_jiffies = now; - eqd = stats->rx_pps / 110000; - eqd = eqd << 3; - if (eqd > rx_eq->max_eqd) - eqd = rx_eq->max_eqd; - if (eqd < rx_eq->min_eqd) - eqd = rx_eq->min_eqd; + eqd = (stats->rx_pps / 110000) << 3; + eqd = min(eqd, eqo->max_eqd); + eqd = max(eqd, eqo->min_eqd); if (eqd < 10) eqd = 0; - if (eqd != rx_eq->cur_eqd) { - be_cmd_modify_eqd(adapter, rx_eq->q.id, eqd); - rx_eq->cur_eqd = eqd; + +modify_eqd: + if (eqd != eqo->cur_eqd) { + be_cmd_modify_eqd(adapter, eqo->q.id, eqd); + eqo->cur_eqd = eqd; } } @@ -1064,11 +1069,10 @@ static inline bool csum_passed(struct be_rx_compl_info *rxcp) (rxcp->ip_csum || rxcp->ipv6); } -static struct be_rx_page_info * -get_rx_page_info(struct be_adapter *adapter, - struct be_rx_obj *rxo, - u16 frag_idx) +static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo, + u16 frag_idx) { + struct be_adapter *adapter = rxo->adapter; struct be_rx_page_info *rx_page_info; struct be_queue_info *rxq = &rxo->q; @@ -1087,16 +1091,15 @@ get_rx_page_info(struct be_adapter *adapter, } /* Throwaway the data in the Rx completion */ -static void be_rx_compl_discard(struct be_adapter *adapter, - struct be_rx_obj *rxo, - struct be_rx_compl_info *rxcp) +static void be_rx_compl_discard(struct be_rx_obj *rxo, + struct be_rx_compl_info *rxcp) { struct be_queue_info *rxq = &rxo->q; struct be_rx_page_info *page_info; u16 i, num_rcvd = rxcp->num_rcvd; for (i = 0; i < num_rcvd; i++) { - page_info = get_rx_page_info(adapter, rxo, rxcp->rxq_idx); + page_info = get_rx_page_info(rxo, rxcp->rxq_idx); put_page(page_info->page); memset(page_info, 0, sizeof(*page_info)); index_inc(&rxcp->rxq_idx, rxq->len); @@ -1107,8 +1110,8 @@ static void be_rx_compl_discard(struct be_adapter *adapter, * skb_fill_rx_data forms a complete skb for an ether frame * indicated by rxcp. */ -static void skb_fill_rx_data(struct be_adapter *adapter, struct be_rx_obj *rxo, - struct sk_buff *skb, struct be_rx_compl_info *rxcp) +static void skb_fill_rx_data(struct be_rx_obj *rxo, struct sk_buff *skb, + struct be_rx_compl_info *rxcp) { struct be_queue_info *rxq = &rxo->q; struct be_rx_page_info *page_info; @@ -1116,7 +1119,7 @@ static void skb_fill_rx_data(struct be_adapter *adapter, struct be_rx_obj *rxo, u16 hdr_len, curr_frag_len, remaining; u8 *start; - page_info = get_rx_page_info(adapter, rxo, rxcp->rxq_idx); + page_info = get_rx_page_info(rxo, rxcp->rxq_idx); start = page_address(page_info->page) + page_info->page_offset; prefetch(start); @@ -1153,7 +1156,7 @@ static void skb_fill_rx_data(struct be_adapter *adapter, struct be_rx_obj *rxo, index_inc(&rxcp->rxq_idx, rxq->len); remaining = rxcp->pkt_size - curr_frag_len; for (i = 1, j = 0; i < rxcp->num_rcvd; i++) { - page_info = get_rx_page_info(adapter, rxo, rxcp->rxq_idx); + page_info = get_rx_page_info(rxo, rxcp->rxq_idx); curr_frag_len = min(remaining, rx_frag_size); /* Coalesce all frags from the same physical page in one slot */ @@ -1181,21 +1184,21 @@ static void skb_fill_rx_data(struct be_adapter *adapter, struct be_rx_obj *rxo, } /* Process the RX completion indicated by rxcp when GRO is disabled */ -static void be_rx_compl_process(struct be_adapter *adapter, - struct be_rx_obj *rxo, - struct be_rx_compl_info *rxcp) +static void be_rx_compl_process(struct be_rx_obj *rxo, + struct be_rx_compl_info *rxcp) { + struct be_adapter *adapter = rxo->adapter; struct net_device *netdev = adapter->netdev; struct sk_buff *skb; skb = netdev_alloc_skb_ip_align(netdev, BE_RX_SKB_ALLOC_SIZE); if (unlikely(!skb)) { rx_stats(rxo)->rx_drops_no_skbs++; - be_rx_compl_discard(adapter, rxo, rxcp); + be_rx_compl_discard(rxo, rxcp); return; } - skb_fill_rx_data(adapter, rxo, skb, rxcp); + skb_fill_rx_data(rxo, skb, rxcp); if (likely((netdev->features & NETIF_F_RXCSUM) && csum_passed(rxcp))) skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -1203,7 +1206,7 @@ static void be_rx_compl_process(struct be_adapter *adapter, skb_checksum_none_assert(skb); skb->protocol = eth_type_trans(skb, netdev); - if (adapter->netdev->features & NETIF_F_RXHASH) + if (netdev->features & NETIF_F_RXHASH) skb->rxhash = rxcp->rss_hash; @@ -1214,26 +1217,25 @@ static void be_rx_compl_process(struct be_adapter *adapter, } /* Process the RX completion indicated by rxcp when GRO is enabled */ -static void be_rx_compl_process_gro(struct be_adapter *adapter, - struct be_rx_obj *rxo, - struct be_rx_compl_info *rxcp) +void be_rx_compl_process_gro(struct be_rx_obj *rxo, struct napi_struct *napi, + struct be_rx_compl_info *rxcp) { + struct be_adapter *adapter = rxo->adapter; struct be_rx_page_info *page_info; struct sk_buff *skb = NULL; struct be_queue_info *rxq = &rxo->q; - struct be_eq_obj *eq_obj = &rxo->rx_eq; u16 remaining, curr_frag_len; u16 i, j; - skb = napi_get_frags(&eq_obj->napi); + skb = napi_get_frags(napi); if (!skb) { - be_rx_compl_discard(adapter, rxo, rxcp); + be_rx_compl_discard(rxo, rxcp); return; } remaining = rxcp->pkt_size; for (i = 0, j = -1; i < rxcp->num_rcvd; i++) { - page_info = get_rx_page_info(adapter, rxo, rxcp->rxq_idx); + page_info = get_rx_page_info(rxo, rxcp->rxq_idx); curr_frag_len = min(remaining, rx_frag_size); @@ -1266,12 +1268,11 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter, if (rxcp->vlanf) __vlan_hwaccel_put_tag(skb, rxcp->vlan_tag); - napi_gro_frags(&eq_obj->napi); + napi_gro_frags(napi); } -static void be_parse_rx_compl_v1(struct be_adapter *adapter, - struct be_eth_rx_compl *compl, - struct be_rx_compl_info *rxcp) +static void be_parse_rx_compl_v1(struct be_eth_rx_compl *compl, + struct be_rx_compl_info *rxcp) { rxcp->pkt_size = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, pktsize, compl); @@ -1302,9 +1303,8 @@ static void be_parse_rx_compl_v1(struct be_adapter *adapter, rxcp->port = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, port, compl); } -static void be_parse_rx_compl_v0(struct be_adapter *adapter, - struct be_eth_rx_compl *compl, - struct be_rx_compl_info *rxcp) +static void be_parse_rx_compl_v0(struct be_eth_rx_compl *compl, + struct be_rx_compl_info *rxcp) { rxcp->pkt_size = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, pktsize, compl); @@ -1350,9 +1350,9 @@ static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo) be_dws_le_to_cpu(compl, sizeof(*compl)); if (adapter->be3_native) - be_parse_rx_compl_v1(adapter, compl, rxcp); + be_parse_rx_compl_v1(compl, rxcp); else - be_parse_rx_compl_v0(adapter, compl, rxcp); + be_parse_rx_compl_v0(compl, rxcp); if (rxcp->vlanf) { /* vlanf could be wrongly set in some cards. @@ -1391,7 +1391,6 @@ static inline struct page *be_alloc_pages(u32 size, gfp_t gfp) static void be_post_rx_frags(struct be_rx_obj *rxo, gfp_t gfp) { struct be_adapter *adapter = rxo->adapter; - struct be_rx_page_info *page_info_tbl = rxo->page_info_tbl; struct be_rx_page_info *page_info = NULL, *prev_page_info = NULL; struct be_queue_info *rxq = &rxo->q; struct page *pagep = NULL; @@ -1433,7 +1432,7 @@ static void be_post_rx_frags(struct be_rx_obj *rxo, gfp_t gfp) prev_page_info = page_info; queue_head_inc(rxq); - page_info = &page_info_tbl[rxq->head]; + page_info = &rxo->page_info_tbl[rxq->head]; } if (pagep) prev_page_info->last_page_user = true; @@ -1495,62 +1494,51 @@ static u16 be_tx_compl_process(struct be_adapter *adapter, return num_wrbs; } -static inline struct be_eq_entry *event_get(struct be_eq_obj *eq_obj) +/* Return the number of events in the event queue */ +static inline int events_get(struct be_eq_obj *eqo) { - struct be_eq_entry *eqe = queue_tail_node(&eq_obj->q); + struct be_eq_entry *eqe; + int num = 0; - if (!eqe->evt) - return NULL; + do { + eqe = queue_tail_node(&eqo->q); + if (eqe->evt == 0) + break; - rmb(); - eqe->evt = le32_to_cpu(eqe->evt); - queue_tail_inc(&eq_obj->q); - return eqe; + rmb(); + eqe->evt = 0; + num++; + queue_tail_inc(&eqo->q); + } while (true); + + return num; } -static int event_handle(struct be_adapter *adapter, - struct be_eq_obj *eq_obj, - bool rearm) +static int event_handle(struct be_eq_obj *eqo) { - struct be_eq_entry *eqe; - u16 num = 0; - - while ((eqe = event_get(eq_obj)) != NULL) { - eqe->evt = 0; - num++; - } + bool rearm = false; + int num = events_get(eqo); - /* Deal with any spurious interrupts that come - * without events - */ + /* Deal with any spurious interrupts that come without events */ if (!num) rearm = true; - be_eq_notify(adapter, eq_obj->q.id, rearm, true, num); + be_eq_notify(eqo->adapter, eqo->q.id, rearm, true, num); if (num) - napi_schedule(&eq_obj->napi); + napi_schedule(&eqo->napi); return num; } -/* Just read and notify events without processing them. - * Used at the time of destroying event queues */ -static void be_eq_clean(struct be_adapter *adapter, - struct be_eq_obj *eq_obj) +/* Leaves the EQ is disarmed state */ +static void be_eq_clean(struct be_eq_obj *eqo) { - struct be_eq_entry *eqe; - u16 num = 0; - - while ((eqe = event_get(eq_obj)) != NULL) { - eqe->evt = 0; - num++; - } + int num = events_get(eqo); - if (num) - be_eq_notify(adapter, eq_obj->q.id, false, true, num); + be_eq_notify(eqo->adapter, eqo->q.id, false, true, num); } -static void be_rx_q_clean(struct be_adapter *adapter, struct be_rx_obj *rxo) +static void be_rx_cq_clean(struct be_rx_obj *rxo) { struct be_rx_page_info *page_info; struct be_queue_info *rxq = &rxo->q; @@ -1560,14 +1548,14 @@ static void be_rx_q_clean(struct be_adapter *adapter, struct be_rx_obj *rxo) /* First cleanup pending rx completions */ while ((rxcp = be_rx_compl_get(rxo)) != NULL) { - be_rx_compl_discard(adapter, rxo, rxcp); - be_cq_notify(adapter, rx_cq->id, false, 1); + be_rx_compl_discard(rxo, rxcp); + be_cq_notify(rxo->adapter, rx_cq->id, false, 1); } /* Then free posted rx buffer that were not used */ tail = (rxq->head + rxq->len - atomic_read(&rxq->used)) % rxq->len; for (; atomic_read(&rxq->used) > 0; index_inc(&tail, rxq->len)) { - page_info = get_rx_page_info(adapter, rxo, tail); + page_info = get_rx_page_info(rxo, tail); put_page(page_info->page); memset(page_info, 0, sizeof(*page_info)); } @@ -1623,6 +1611,47 @@ static void be_tx_compl_clean(struct be_adapter *adapter, } } +static void be_evt_queues_destroy(struct be_adapter *adapter) +{ + struct be_eq_obj *eqo; + int i; + + for_all_evt_queues(adapter, eqo, i) { + be_eq_clean(eqo); + if (eqo->q.created) + be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); + be_queue_free(adapter, &eqo->q); + } +} + +static int be_evt_queues_create(struct be_adapter *adapter) +{ + struct be_queue_info *eq; + struct be_eq_obj *eqo; + int i, rc; + + adapter->num_evt_qs = num_irqs(adapter); + + for_all_evt_queues(adapter, eqo, i) { + eqo->adapter = adapter; + eqo->tx_budget = BE_TX_BUDGET; + eqo->idx = i; + eqo->max_eqd = BE_MAX_EQD; + eqo->enable_aic = true; + + eq = &eqo->q; + rc = be_queue_alloc(adapter, eq, EVNT_Q_LEN, + sizeof(struct be_eq_entry)); + if (rc) + return rc; + + rc = be_cmd_eq_create(adapter, eq, eqo->cur_eqd); + if (rc) + return rc; + } + return rc; +} + static void be_mcc_queues_destroy(struct be_adapter *adapter) { struct be_queue_info *q; @@ -1643,22 +1672,19 @@ static int be_mcc_queues_create(struct be_adapter *adapter) { struct be_queue_info *q, *cq; - /* Alloc MCC compl queue */ cq = &adapter->mcc_obj.cq; if (be_queue_alloc(adapter, cq, MCC_CQ_LEN, sizeof(struct be_mcc_compl))) goto err; - /* Ask BE to create MCC compl queue; share TX's eq */ - if (be_cmd_cq_create(adapter, cq, &adapter->tx_eq.q, false, true, 0)) + /* Use the default EQ for MCC completions */ + if (be_cmd_cq_create(adapter, cq, &mcc_eqo(adapter)->q, true, 0)) goto mcc_cq_free; - /* Alloc MCC queue */ q = &adapter->mcc_obj.q; if (be_queue_alloc(adapter, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) goto mcc_cq_destroy; - /* Ask BE to create MCC queue */ if (be_cmd_mccq_create(adapter, q, cq)) goto mcc_q_free; @@ -1691,14 +1717,6 @@ static void be_tx_queues_destroy(struct be_adapter *adapter) be_cmd_q_destroy(adapter, q, QTYPE_CQ); be_queue_free(adapter, q); } - - /* Clear any residual events */ - be_eq_clean(adapter, &adapter->tx_eq); - - q = &adapter->tx_eq.q; - if (q->created) - be_cmd_q_destroy(adapter, q, QTYPE_EQ); - be_queue_free(adapter, q); } static int be_num_txqs_want(struct be_adapter *adapter) @@ -1711,10 +1729,10 @@ static int be_num_txqs_want(struct be_adapter *adapter) return MAX_TX_QS; } -/* One TX event queue is shared by all TX compl qs */ -static int be_tx_queues_create(struct be_adapter *adapter) +static int be_tx_cqs_create(struct be_adapter *adapter) { - struct be_queue_info *eq, *q, *cq; + struct be_queue_info *cq, *eq; + int status; struct be_tx_obj *txo; u8 i; @@ -1726,192 +1744,109 @@ static int be_tx_queues_create(struct be_adapter *adapter) rtnl_unlock(); } - adapter->tx_eq.max_eqd = 0; - adapter->tx_eq.min_eqd = 0; - adapter->tx_eq.cur_eqd = 96; - adapter->tx_eq.enable_aic = false; + for_all_tx_queues(adapter, txo, i) { + cq = &txo->cq; + status = be_queue_alloc(adapter, cq, TX_CQ_LEN, + sizeof(struct be_eth_tx_compl)); + if (status) + return status; - eq = &adapter->tx_eq.q; - if (be_queue_alloc(adapter, eq, EVNT_Q_LEN, - sizeof(struct be_eq_entry))) - return -1; + /* If num_evt_qs is less than num_tx_qs, then more than + * one txq share an eq + */ + eq = &adapter->eq_obj[i % adapter->num_evt_qs].q; + status = be_cmd_cq_create(adapter, cq, eq, false, 3); + if (status) + return status; + } + return 0; +} - if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd)) - goto err; - adapter->tx_eq.eq_idx = adapter->eq_next_idx++; +static int be_tx_qs_create(struct be_adapter *adapter) +{ + struct be_tx_obj *txo; + int i, status; for_all_tx_queues(adapter, txo, i) { - cq = &txo->cq; - if (be_queue_alloc(adapter, cq, TX_CQ_LEN, - sizeof(struct be_eth_tx_compl))) - goto err; - - if (be_cmd_cq_create(adapter, cq, eq, false, false, 3)) - goto err; + status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN, + sizeof(struct be_eth_wrb)); + if (status) + return status; - q = &txo->q; - if (be_queue_alloc(adapter, q, TX_Q_LEN, - sizeof(struct be_eth_wrb))) - goto err; + status = be_cmd_txq_create(adapter, &txo->q, &txo->cq); + if (status) + return status; } - return 0; -err: - be_tx_queues_destroy(adapter); - return -1; + return 0; } -static void be_rx_queues_destroy(struct be_adapter *adapter) +static void be_rx_cqs_destroy(struct be_adapter *adapter) { struct be_queue_info *q; struct be_rx_obj *rxo; int i; for_all_rx_queues(adapter, rxo, i) { - be_queue_free(adapter, &rxo->q); - q = &rxo->cq; if (q->created) be_cmd_q_destroy(adapter, q, QTYPE_CQ); be_queue_free(adapter, q); - - q = &rxo->rx_eq.q; - if (q->created) - be_cmd_q_destroy(adapter, q, QTYPE_EQ); - be_queue_free(adapter, q); - } -} - -static u32 be_num_rxqs_want(struct be_adapter *adapter) -{ - if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && - !sriov_enabled(adapter) && be_physfn(adapter)) { - return 1 + MAX_RSS_QS; /* one default non-RSS queue */ - } else { - dev_warn(&adapter->pdev->dev, - "No support for multiple RX queues\n"); - return 1; } } -static int be_rx_queues_create(struct be_adapter *adapter) +static int be_rx_cqs_create(struct be_adapter *adapter) { - struct be_queue_info *eq, *q, *cq; + struct be_queue_info *eq, *cq; struct be_rx_obj *rxo; int rc, i; - adapter->num_rx_qs = min(be_num_rxqs_want(adapter), - msix_enabled(adapter) ? - adapter->num_msix_vec - 1 : 1); - if (adapter->num_rx_qs != MAX_RX_QS) - dev_warn(&adapter->pdev->dev, - "Can create only %d RX queues", adapter->num_rx_qs); + /* We'll create as many RSS rings as there are irqs. + * But when there's only one irq there's no use creating RSS rings + */ + adapter->num_rx_qs = (num_irqs(adapter) > 1) ? + num_irqs(adapter) + 1 : 1; adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE; for_all_rx_queues(adapter, rxo, i) { rxo->adapter = adapter; - rxo->rx_eq.max_eqd = BE_MAX_EQD; - rxo->rx_eq.enable_aic = true; - - /* EQ */ - eq = &rxo->rx_eq.q; - rc = be_queue_alloc(adapter, eq, EVNT_Q_LEN, - sizeof(struct be_eq_entry)); - if (rc) - goto err; - - rc = be_cmd_eq_create(adapter, eq, rxo->rx_eq.cur_eqd); - if (rc) - goto err; - - rxo->rx_eq.eq_idx = adapter->eq_next_idx++; - - /* CQ */ cq = &rxo->cq; rc = be_queue_alloc(adapter, cq, RX_CQ_LEN, sizeof(struct be_eth_rx_compl)); if (rc) - goto err; + return rc; - rc = be_cmd_cq_create(adapter, cq, eq, false, false, 3); + eq = &adapter->eq_obj[i % adapter->num_evt_qs].q; + rc = be_cmd_cq_create(adapter, cq, eq, false, 3); if (rc) - goto err; - - /* Rx Q - will be created in be_open() */ - q = &rxo->q; - rc = be_queue_alloc(adapter, q, RX_Q_LEN, - sizeof(struct be_eth_rx_d)); - if (rc) - goto err; - + return rc; } - return 0; -err: - be_rx_queues_destroy(adapter); - return -1; -} + if (adapter->num_rx_qs != MAX_RX_QS) + dev_info(&adapter->pdev->dev, + "Created only %d receive queues", adapter->num_rx_qs); -static bool event_peek(struct be_eq_obj *eq_obj) -{ - struct be_eq_entry *eqe = queue_tail_node(&eq_obj->q); - if (!eqe->evt) - return false; - else - return true; + return 0; } static irqreturn_t be_intx(int irq, void *dev) { struct be_adapter *adapter = dev; - struct be_rx_obj *rxo; - int isr, i, tx = 0 , rx = 0; - - if (lancer_chip(adapter)) { - if (event_peek(&adapter->tx_eq)) - tx = event_handle(adapter, &adapter->tx_eq, false); - for_all_rx_queues(adapter, rxo, i) { - if (event_peek(&rxo->rx_eq)) - rx |= event_handle(adapter, &rxo->rx_eq, true); - } - - if (!(tx || rx)) - return IRQ_NONE; - - } else { - isr = ioread32(adapter->csr + CEV_ISR0_OFFSET + - (adapter->tx_eq.q.id / 8) * CEV_ISR_SIZE); - if (!isr) - return IRQ_NONE; - - if ((1 << adapter->tx_eq.eq_idx & isr)) - event_handle(adapter, &adapter->tx_eq, false); - - for_all_rx_queues(adapter, rxo, i) { - if ((1 << rxo->rx_eq.eq_idx & isr)) - event_handle(adapter, &rxo->rx_eq, true); - } - } - - return IRQ_HANDLED; -} - -static irqreturn_t be_msix_rx(int irq, void *dev) -{ - struct be_rx_obj *rxo = dev; - struct be_adapter *adapter = rxo->adapter; + int num_evts; - event_handle(adapter, &rxo->rx_eq, true); - - return IRQ_HANDLED; + /* With INTx only one EQ is used */ + num_evts = event_handle(&adapter->eq_obj[0]); + if (num_evts) + return IRQ_HANDLED; + else + return IRQ_NONE; } -static irqreturn_t be_msix_tx_mcc(int irq, void *dev) +static irqreturn_t be_msix(int irq, void *dev) { - struct be_adapter *adapter = dev; - - event_handle(adapter, &adapter->tx_eq, false); + struct be_eq_obj *eqo = dev; + event_handle(eqo); return IRQ_HANDLED; } @@ -1920,16 +1855,14 @@ static inline bool do_gro(struct be_rx_compl_info *rxcp) return (rxcp->tcpf && !rxcp->err) ? true : false; } -static int be_poll_rx(struct napi_struct *napi, int budget) +static int be_process_rx(struct be_rx_obj *rxo, struct napi_struct *napi, + int budget) { - struct be_eq_obj *rx_eq = container_of(napi, struct be_eq_obj, napi); - struct be_rx_obj *rxo = container_of(rx_eq, struct be_rx_obj, rx_eq); struct be_adapter *adapter = rxo->adapter; struct be_queue_info *rx_cq = &rxo->cq; struct be_rx_compl_info *rxcp; u32 work_done; - rx_stats(rxo)->rx_polls++; for (work_done = 0; work_done < budget; work_done++) { rxcp = be_rx_compl_get(rxo); if (!rxcp) @@ -1941,7 +1874,7 @@ static int be_poll_rx(struct napi_struct *napi, int budget) /* Discard compl with partial DMA Lancer B0 */ if (unlikely(!rxcp->pkt_size)) { - be_rx_compl_discard(adapter, rxo, rxcp); + be_rx_compl_discard(rxo, rxcp); goto loop_continue; } @@ -1950,94 +1883,96 @@ static int be_poll_rx(struct napi_struct *napi, int budget) */ if (unlikely(rxcp->port != adapter->port_num && !lancer_chip(adapter))) { - be_rx_compl_discard(adapter, rxo, rxcp); + be_rx_compl_discard(rxo, rxcp); goto loop_continue; } if (do_gro(rxcp)) - be_rx_compl_process_gro(adapter, rxo, rxcp); + be_rx_compl_process_gro(rxo, napi, rxcp); else - be_rx_compl_process(adapter, rxo, rxcp); + be_rx_compl_process(rxo, rxcp); loop_continue: be_rx_stats_update(rxo, rxcp); } - be_cq_notify(adapter, rx_cq->id, false, work_done); + if (work_done) { + be_cq_notify(adapter, rx_cq->id, true, work_done); - /* Refill the queue */ - if (work_done && atomic_read(&rxo->q.used) < RX_FRAGS_REFILL_WM) - be_post_rx_frags(rxo, GFP_ATOMIC); - - /* All consumed */ - if (work_done < budget) { - napi_complete(napi); - /* Arm CQ */ - be_cq_notify(adapter, rx_cq->id, true, 0); + if (atomic_read(&rxo->q.used) < RX_FRAGS_REFILL_WM) + be_post_rx_frags(rxo, GFP_ATOMIC); } + return work_done; } -/* As TX and MCC share the same EQ check for both TX and MCC completions. - * For TX/MCC we don't honour budget; consume everything - */ -static int be_poll_tx_mcc(struct napi_struct *napi, int budget) +static bool be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo, + int budget, int idx) { - struct be_eq_obj *tx_eq = container_of(napi, struct be_eq_obj, napi); - struct be_adapter *adapter = - container_of(tx_eq, struct be_adapter, tx_eq); - struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; - struct be_tx_obj *txo; struct be_eth_tx_compl *txcp; - int tx_compl, mcc_compl, status = 0; - u8 i; - u16 num_wrbs; + int num_wrbs = 0, work_done; - for_all_tx_queues(adapter, txo, i) { - tx_compl = 0; - num_wrbs = 0; - while ((txcp = be_tx_compl_get(&txo->cq))) { - num_wrbs += be_tx_compl_process(adapter, txo, + for (work_done = 0; work_done < budget; work_done++) { + txcp = be_tx_compl_get(&txo->cq); + if (!txcp) + break; + num_wrbs += be_tx_compl_process(adapter, txo, AMAP_GET_BITS(struct amap_eth_tx_compl, wrb_index, txcp)); - tx_compl++; - } - if (tx_compl) { - be_cq_notify(adapter, txo->cq.id, true, tx_compl); - - atomic_sub(num_wrbs, &txo->q.used); + } - /* As Tx wrbs have been freed up, wake up netdev queue - * if it was stopped due to lack of tx wrbs. */ - if (__netif_subqueue_stopped(adapter->netdev, i) && - atomic_read(&txo->q.used) < txo->q.len / 2) { - netif_wake_subqueue(adapter->netdev, i); - } + if (work_done) { + be_cq_notify(adapter, txo->cq.id, true, work_done); + atomic_sub(num_wrbs, &txo->q.used); - u64_stats_update_begin(&tx_stats(txo)->sync_compl); - tx_stats(txo)->tx_compl += tx_compl; - u64_stats_update_end(&tx_stats(txo)->sync_compl); + /* As Tx wrbs have been freed up, wake up netdev queue + * if it was stopped due to lack of tx wrbs. */ + if (__netif_subqueue_stopped(adapter->netdev, idx) && + atomic_read(&txo->q.used) < txo->q.len / 2) { + netif_wake_subqueue(adapter->netdev, idx); } + + u64_stats_update_begin(&tx_stats(txo)->sync_compl); + tx_stats(txo)->tx_compl += work_done; + u64_stats_update_end(&tx_stats(txo)->sync_compl); } + return (work_done < budget); /* Done */ +} - mcc_compl = be_process_mcc(adapter, &status); +int be_poll(struct napi_struct *napi, int budget) +{ + struct be_eq_obj *eqo = container_of(napi, struct be_eq_obj, napi); + struct be_adapter *adapter = eqo->adapter; + int max_work = 0, work, i; + bool tx_done; - if (mcc_compl) { - be_cq_notify(adapter, mcc_obj->cq.id, true, mcc_compl); + /* Process all TXQs serviced by this EQ */ + for (i = eqo->idx; i < adapter->num_tx_qs; i += adapter->num_evt_qs) { + tx_done = be_process_tx(adapter, &adapter->tx_obj[i], + eqo->tx_budget, i); + if (!tx_done) + max_work = budget; } - napi_complete(napi); + /* This loop will iterate twice for EQ0 in which + * completions of the last RXQ (default one) are also processed + * For other EQs the loop iterates only once + */ + for (i = eqo->idx; i < adapter->num_rx_qs; i += adapter->num_evt_qs) { + work = be_process_rx(&adapter->rx_obj[i], napi, budget); + max_work = max(work, max_work); + } - /* Arm CQ again to regenerate EQEs for Lancer in INTx mode */ - if (lancer_chip(adapter) && !msix_enabled(adapter)) { - for_all_tx_queues(adapter, txo, i) - be_cq_notify(adapter, txo->cq.id, true, 0); + if (is_mcc_eqo(eqo)) + be_process_mcc(adapter); - be_cq_notify(adapter, mcc_obj->cq.id, true, 0); + if (max_work < budget) { + napi_complete(napi); + be_eq_notify(adapter, eqo->q.id, true, false, 0); + } else { + /* As we'll continue in polling mode, count and clear events */ + be_eq_notify(adapter, eqo->q.id, false, false, events_get(eqo)); } - - be_eq_notify(adapter, tx_eq->q.id, true, false, 0); - adapter->drv_stats.tx_events++; - return 1; + return max_work; } void be_detect_dump_ue(struct be_adapter *adapter) @@ -2112,12 +2047,24 @@ static void be_msix_disable(struct be_adapter *adapter) } } +static uint be_num_rss_want(struct be_adapter *adapter) +{ + if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && + adapter->num_vfs == 0 && be_physfn(adapter) && + !be_is_mc(adapter)) + return (adapter->be3_native) ? BE3_MAX_RSS_QS : BE2_MAX_RSS_QS; + else + return 0; +} + static void be_msix_enable(struct be_adapter *adapter) { -#define BE_MIN_MSIX_VECTORS (1 + 1) /* Rx + Tx */ +#define BE_MIN_MSIX_VECTORS 1 int i, status, num_vec; - num_vec = be_num_rxqs_want(adapter) + 1; + /* If RSS queues are not used, need a vec for default RX Q */ + num_vec = min(be_num_rss_want(adapter), num_online_cpus()); + num_vec = max(num_vec, BE_MIN_MSIX_VECTORS); for (i = 0; i < num_vec; i++) adapter->msix_entries[i].entry = i; @@ -2185,60 +2132,31 @@ static void be_sriov_disable(struct be_adapter *adapter) } static inline int be_msix_vec_get(struct be_adapter *adapter, - struct be_eq_obj *eq_obj) -{ - return adapter->msix_entries[eq_obj->eq_idx].vector; -} - -static int be_request_irq(struct be_adapter *adapter, - struct be_eq_obj *eq_obj, - void *handler, char *desc, void *context) -{ - struct net_device *netdev = adapter->netdev; - int vec; - - sprintf(eq_obj->desc, "%s-%s", netdev->name, desc); - vec = be_msix_vec_get(adapter, eq_obj); - return request_irq(vec, handler, 0, eq_obj->desc, context); -} - -static void be_free_irq(struct be_adapter *adapter, struct be_eq_obj *eq_obj, - void *context) + struct be_eq_obj *eqo) { - int vec = be_msix_vec_get(adapter, eq_obj); - free_irq(vec, context); + return adapter->msix_entries[eqo->idx].vector; } static int be_msix_register(struct be_adapter *adapter) { - struct be_rx_obj *rxo; - int status, i; - char qname[10]; - - status = be_request_irq(adapter, &adapter->tx_eq, be_msix_tx_mcc, "tx", - adapter); - if (status) - goto err; + struct net_device *netdev = adapter->netdev; + struct be_eq_obj *eqo; + int status, i, vec; - for_all_rx_queues(adapter, rxo, i) { - sprintf(qname, "rxq%d", i); - status = be_request_irq(adapter, &rxo->rx_eq, be_msix_rx, - qname, rxo); + for_all_evt_queues(adapter, eqo, i) { + sprintf(eqo->desc, "%s-q%d", netdev->name, i); + vec = be_msix_vec_get(adapter, eqo); + status = request_irq(vec, be_msix, 0, eqo->desc, eqo); if (status) goto err_msix; } return 0; - err_msix: - be_free_irq(adapter, &adapter->tx_eq, adapter); - - for (i--, rxo = &adapter->rx_obj[i]; i >= 0; i--, rxo--) - be_free_irq(adapter, &rxo->rx_eq, rxo); - -err: - dev_warn(&adapter->pdev->dev, - "MSIX Request IRQ failed - err %d\n", status); + for (i--, eqo = &adapter->eq_obj[i]; i >= 0; i--, eqo--) + free_irq(be_msix_vec_get(adapter, eqo), eqo); + dev_warn(&adapter->pdev->dev, "MSIX Request IRQ failed - err %d\n", + status); be_msix_disable(adapter); return status; } @@ -2274,7 +2192,7 @@ static int be_irq_register(struct be_adapter *adapter) static void be_irq_unregister(struct be_adapter *adapter) { struct net_device *netdev = adapter->netdev; - struct be_rx_obj *rxo; + struct be_eq_obj *eqo; int i; if (!adapter->isr_registered) @@ -2287,16 +2205,14 @@ static void be_irq_unregister(struct be_adapter *adapter) } /* MSIx */ - be_free_irq(adapter, &adapter->tx_eq, adapter); - - for_all_rx_queues(adapter, rxo, i) - be_free_irq(adapter, &rxo->rx_eq, rxo); + for_all_evt_queues(adapter, eqo, i) + free_irq(be_msix_vec_get(adapter, eqo), eqo); done: adapter->isr_registered = false; } -static void be_rx_queues_clear(struct be_adapter *adapter) +static void be_rx_qs_destroy(struct be_adapter *adapter) { struct be_queue_info *q; struct be_rx_obj *rxo; @@ -2311,53 +2227,33 @@ static void be_rx_queues_clear(struct be_adapter *adapter) * arrive */ mdelay(1); - be_rx_q_clean(adapter, rxo); + be_rx_cq_clean(rxo); } - - /* Clear any residual events */ - q = &rxo->rx_eq.q; - if (q->created) - be_eq_clean(adapter, &rxo->rx_eq); + be_queue_free(adapter, q); } } static int be_close(struct net_device *netdev) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_rx_obj *rxo; struct be_tx_obj *txo; - struct be_eq_obj *tx_eq = &adapter->tx_eq; - int vec, i; + struct be_eq_obj *eqo; + int i; be_async_mcc_disable(adapter); if (!lancer_chip(adapter)) be_intr_set(adapter, false); - for_all_rx_queues(adapter, rxo, i) - napi_disable(&rxo->rx_eq.napi); - - napi_disable(&tx_eq->napi); - - if (lancer_chip(adapter)) { - be_cq_notify(adapter, adapter->mcc_obj.cq.id, false, 0); - for_all_rx_queues(adapter, rxo, i) - be_cq_notify(adapter, rxo->cq.id, false, 0); - for_all_tx_queues(adapter, txo, i) - be_cq_notify(adapter, txo->cq.id, false, 0); + for_all_evt_queues(adapter, eqo, i) { + napi_disable(&eqo->napi); + if (msix_enabled(adapter)) + synchronize_irq(be_msix_vec_get(adapter, eqo)); + else + synchronize_irq(netdev->irq); + be_eq_clean(eqo); } - if (msix_enabled(adapter)) { - vec = be_msix_vec_get(adapter, tx_eq); - synchronize_irq(vec); - - for_all_rx_queues(adapter, rxo, i) { - vec = be_msix_vec_get(adapter, &rxo->rx_eq); - synchronize_irq(vec); - } - } else { - synchronize_irq(netdev->irq); - } be_irq_unregister(adapter); /* Wait for all pending tx completions to arrive so that @@ -2366,21 +2262,34 @@ static int be_close(struct net_device *netdev) for_all_tx_queues(adapter, txo, i) be_tx_compl_clean(adapter, txo); - be_rx_queues_clear(adapter); + be_rx_qs_destroy(adapter); return 0; } -static int be_rx_queues_setup(struct be_adapter *adapter) +static int be_rx_qs_create(struct be_adapter *adapter) { struct be_rx_obj *rxo; int rc, i, j; u8 rsstable[128]; for_all_rx_queues(adapter, rxo, i) { + rc = be_queue_alloc(adapter, &rxo->q, RX_Q_LEN, + sizeof(struct be_eth_rx_d)); + if (rc) + return rc; + } + + /* The FW would like the default RXQ to be created first */ + rxo = default_rxo(adapter); + rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, rx_frag_size, + adapter->if_handle, false, &rxo->rss_id); + if (rc) + return rc; + + for_all_rss_queues(adapter, rxo, i) { rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, - rx_frag_size, BE_MAX_JUMBO_FRAME_SIZE, - adapter->if_handle, - (i > 0) ? 1 : 0/* rss enable */, &rxo->rss_id); + rx_frag_size, adapter->if_handle, + true, &rxo->rss_id); if (rc) return rc; } @@ -2394,48 +2303,47 @@ static int be_rx_queues_setup(struct be_adapter *adapter) } } rc = be_cmd_rss_config(adapter, rsstable, 128); - if (rc) return rc; } /* First time posting */ - for_all_rx_queues(adapter, rxo, i) { + for_all_rx_queues(adapter, rxo, i) be_post_rx_frags(rxo, GFP_KERNEL); - napi_enable(&rxo->rx_eq.napi); - } return 0; } static int be_open(struct net_device *netdev) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_eq_obj *tx_eq = &adapter->tx_eq; + struct be_eq_obj *eqo; struct be_rx_obj *rxo; + struct be_tx_obj *txo; u8 link_status; int status, i; - status = be_rx_queues_setup(adapter); + status = be_rx_qs_create(adapter); if (status) goto err; - napi_enable(&tx_eq->napi); - be_irq_register(adapter); if (!lancer_chip(adapter)) be_intr_set(adapter, true); - /* The evt queues are created in unarmed state; arm them */ - for_all_rx_queues(adapter, rxo, i) { - be_eq_notify(adapter, rxo->rx_eq.q.id, true, false, 0); + for_all_rx_queues(adapter, rxo, i) be_cq_notify(adapter, rxo->cq.id, true, 0); - } - be_eq_notify(adapter, tx_eq->q.id, true, false, 0); - /* Now that interrupts are on we can process async mcc */ + for_all_tx_queues(adapter, txo, i) + be_cq_notify(adapter, txo->cq.id, true, 0); + be_async_mcc_enable(adapter); + for_all_evt_queues(adapter, eqo, i) { + napi_enable(&eqo->napi); + be_eq_notify(adapter, eqo->q.id, true, false, 0); + } + status = be_cmd_link_status_query(adapter, NULL, NULL, &link_status, 0); if (!status) @@ -2545,11 +2453,14 @@ static int be_clear(struct be_adapter *adapter) be_cmd_if_destroy(adapter, adapter->if_handle, 0); be_mcc_queues_destroy(adapter); - be_rx_queues_destroy(adapter); + be_rx_cqs_destroy(adapter); be_tx_queues_destroy(adapter); + be_evt_queues_destroy(adapter); /* tell fw we're done with firing cmds */ be_cmd_fw_clean(adapter); + + be_msix_disable(adapter); return 0; } @@ -2639,24 +2550,29 @@ static int be_setup(struct be_adapter *adapter) struct net_device *netdev = adapter->netdev; u32 cap_flags, en_flags; u32 tx_fc, rx_fc; - int status, i; + int status; u8 mac[ETH_ALEN]; - struct be_tx_obj *txo; be_setup_init(adapter); be_cmd_req_native_mode(adapter); - status = be_tx_queues_create(adapter); - if (status != 0) + be_msix_enable(adapter); + + status = be_evt_queues_create(adapter); + if (status) goto err; - status = be_rx_queues_create(adapter); - if (status != 0) + status = be_tx_cqs_create(adapter); + if (status) + goto err; + + status = be_rx_cqs_create(adapter); + if (status) goto err; status = be_mcc_queues_create(adapter); - if (status != 0) + if (status) goto err; memset(mac, 0, ETH_ALEN); @@ -2682,12 +2598,6 @@ static int be_setup(struct be_adapter *adapter) if (status != 0) goto err; - for_all_tx_queues(adapter, txo, i) { - status = be_cmd_txq_create(adapter, &txo->q, &txo->cq); - if (status) - goto err; - } - /* The VF's permanent mac queried from card is incorrect. * For BEx: Query the mac configued by the PF using if_handle * For Lancer: Get and use mac_list to obtain mac address. @@ -2705,6 +2615,10 @@ static int be_setup(struct be_adapter *adapter) } } + status = be_tx_qs_create(adapter); + if (status) + goto err; + be_cmd_get_fw_ver(adapter, adapter->fw_ver, NULL); status = be_vid_config(adapter, false, 0); @@ -2744,12 +2658,13 @@ static int be_setup(struct be_adapter *adapter) static void be_netpoll(struct net_device *netdev) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_rx_obj *rxo; + struct be_eq_obj *eqo; int i; - event_handle(adapter, &adapter->tx_eq, false); - for_all_rx_queues(adapter, rxo, i) - event_handle(adapter, &rxo->rx_eq, true); + for_all_evt_queues(adapter, eqo, i) + event_handle(eqo); + + return; } #endif @@ -3110,7 +3025,7 @@ static const struct net_device_ops be_netdev_ops = { static void be_netdev_init(struct net_device *netdev) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_rx_obj *rxo; + struct be_eq_obj *eqo; int i; netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | @@ -3129,16 +3044,12 @@ static void be_netdev_init(struct net_device *netdev) netif_set_gso_max_size(netdev, 65535); - BE_SET_NETDEV_OPS(netdev, &be_netdev_ops); + netdev->netdev_ops = &be_netdev_ops; SET_ETHTOOL_OPS(netdev, &be_ethtool_ops); - for_all_rx_queues(adapter, rxo, i) - netif_napi_add(netdev, &rxo->rx_eq.napi, be_poll_rx, - BE_NAPI_WEIGHT); - - netif_napi_add(netdev, &adapter->tx_eq.napi, be_poll_tx_mcc, - BE_NAPI_WEIGHT); + for_all_evt_queues(adapter, eqo, i) + netif_napi_add(netdev, &eqo->napi, be_poll, BE_NAPI_WEIGHT); } static void be_unmap_pci_bars(struct be_adapter *adapter) @@ -3309,8 +3220,6 @@ static void __devexit be_remove(struct pci_dev *pdev) be_sriov_disable(adapter); - be_msix_disable(adapter); - pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); pci_disable_device(pdev); @@ -3477,6 +3386,7 @@ static void be_worker(struct work_struct *work) struct be_adapter *adapter = container_of(work, struct be_adapter, work.work); struct be_rx_obj *rxo; + struct be_eq_obj *eqo; int i; if (lancer_chip(adapter)) @@ -3487,15 +3397,7 @@ static void be_worker(struct work_struct *work) /* when interrupts are not yet enabled, just reap any pending * mcc completions */ if (!netif_running(adapter->netdev)) { - int mcc_compl, status = 0; - - mcc_compl = be_process_mcc(adapter, &status); - - if (mcc_compl) { - struct be_mcc_obj *mcc_obj = &adapter->mcc_obj; - be_cq_notify(adapter, mcc_obj->cq.id, false, mcc_compl); - } - + be_process_mcc(adapter); goto reschedule; } @@ -3508,14 +3410,15 @@ static void be_worker(struct work_struct *work) } for_all_rx_queues(adapter, rxo, i) { - be_rx_eqd_update(adapter, rxo); - if (rxo->rx_post_starved) { rxo->rx_post_starved = false; be_post_rx_frags(rxo, GFP_KERNEL); } } + for_all_evt_queues(adapter, eqo, i) + be_eqd_update(adapter, eqo); + reschedule: adapter->work_counter++; schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); @@ -3601,6 +3504,12 @@ static int __devinit be_probe(struct pci_dev *pdev, if (status) goto ctrl_clean; + /* The INTR bit may be set in the card when probed by a kdump kernel + * after a crash. + */ + if (!lancer_chip(adapter)) + be_intr_set(adapter, false); + status = be_stats_init(adapter); if (status) goto ctrl_clean; @@ -3609,14 +3518,6 @@ static int __devinit be_probe(struct pci_dev *pdev, if (status) goto stats_clean; - /* The INTR bit may be set in the card when probed by a kdump kernel - * after a crash. - */ - if (!lancer_chip(adapter)) - be_intr_set(adapter, false); - - be_msix_enable(adapter); - INIT_DELAYED_WORK(&adapter->work, be_worker); adapter->rx_fc = adapter->tx_fc = true; @@ -3629,7 +3530,8 @@ static int __devinit be_probe(struct pci_dev *pdev, if (status != 0) goto unsetup; - dev_info(&pdev->dev, "%s port %d\n", nic_name(pdev), adapter->port_num); + dev_info(&pdev->dev, "%s: %s port %d\n", netdev->name, nic_name(pdev), + adapter->port_num); schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); return 0; @@ -3673,7 +3575,6 @@ static int be_suspend(struct pci_dev *pdev, pm_message_t state) } be_clear(adapter); - be_msix_disable(adapter); pci_save_state(pdev); pci_disable_device(pdev); pci_set_power_state(pdev, pci_choose_state(pdev, state)); @@ -3695,7 +3596,6 @@ static int be_resume(struct pci_dev *pdev) pci_set_power_state(pdev, 0); pci_restore_state(pdev); - be_msix_enable(adapter); /* tell fw we're ready to fire cmds */ status = be_cmd_fw_init(adapter); if (status) -- GitLab From 67da8208bbf49c054ac478903c9e7dc44450cea0 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 10 Feb 2012 04:48:00 +0000 Subject: [PATCH 0537/1846] isdn: Fix typo in callc.c and tei.c Correct spelling "ioclt" to "ioctl" in drivers/isdn/hisax/callc.c Correct spelling "asigned" to "assigned" in drivers/isdn/hisax/tei.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/isdn/hisax/callc.c | 2 +- drivers/isdn/hisax/tei.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c index c4897e1075d8..9ae92b41660f 100644 --- a/drivers/isdn/hisax/callc.c +++ b/drivers/isdn/hisax/callc.c @@ -1693,7 +1693,7 @@ HiSax_command(isdn_ctrl * ic) default: if (csta->auxcmd) return(csta->auxcmd(csta, ic)); - printk(KERN_DEBUG "HiSax: invalid ioclt %d\n", + printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", (int) ic->arg); return (-EINVAL); } diff --git a/drivers/isdn/hisax/tei.c b/drivers/isdn/hisax/tei.c index 842f9c9e875d..9b6db9c92cd8 100644 --- a/drivers/isdn/hisax/tei.c +++ b/drivers/isdn/hisax/tei.c @@ -130,7 +130,7 @@ tei_id_request(struct FsmInst *fi, int event, void *arg) if (st->l2.tei != -1) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "assign request for already asigned tei %d", + "assign request for already assigned tei %d", st->l2.tei); return; } -- GitLab From 670d6089cd4eac537af443d213cc59bd60b4268b Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 10 Feb 2012 05:01:08 +0000 Subject: [PATCH 0538/1846] mISDN/hfcsusb: remove unused variable hfcsusb_rev Removed unused variable hfcsusb_rev (-Wunused-variable) and copied Revision info to file comment block above to keep the info. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/isdn/hardware/mISDN/hfcsusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c index 0e1f4d5b9774..43b4d29e5475 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.c +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c @@ -27,6 +27,7 @@ * poll=, default 128 * n : burst size of PH_DATA_IND at transparent rx data * + * Revision: 0.3.3 (socket), 2008-11-05 */ #include @@ -36,8 +37,6 @@ #include #include "hfcsusb.h" -static const char *hfcsusb_rev = "Revision: 0.3.3 (socket), 2008-11-05"; - static unsigned int debug; static int poll = DEFAULT_TRANSP_BURST_SZ; -- GitLab From ee556fe5fcc1c4f67fc854865f3108cf17714128 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sat, 11 Feb 2012 01:49:28 +0000 Subject: [PATCH 0539/1846] isdn: Fix typo in isdn_ppp.c Correct spelling "reseting" to "resetting" in drivers/isdn/i4l/isdn_ppp.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/isdn/i4l/isdn_ppp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index 1b002b0002a4..e38f674a7bd3 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -1156,7 +1156,7 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff if (!(is->active_filter && sk_run_filter(skb, is->active_filter) == 0)) { if (is->debug & 0x2) - printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n"); + printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); lp->huptimer = 0; if (mlp) mlp->huptimer = 0; @@ -1302,7 +1302,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) if (!(ipt->active_filter && sk_run_filter(skb, ipt->active_filter) == 0)) { if (ipt->debug & 0x4) - printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n"); + printk(KERN_DEBUG "IPPP: link-active filter: resetting huptimer.\n"); lp->huptimer = 0; } skb_pull(skb, 4); -- GitLab From 9f1de88ddd5eac43c14ed20835b4c738be61e162 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Sat, 11 Feb 2012 21:37:37 +0000 Subject: [PATCH 0540/1846] enic: Fix address deregistration for sriov vf during port profile disassociate This patch fixes erroneous PF address deregistration in cases where a port profile disassociate is called on an already disassociated interface. Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: sujith sankar Signed-off-by: ChingWei Chang Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/enic_pp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 54fd9c314b38..e65d431d4378 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.33" +#define DRV_VERSION "2.1.1.34" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/enic_pp.c b/drivers/net/ethernet/cisco/enic/enic_pp.c index 22bf03a1829e..c758674643ce 100644 --- a/drivers/net/ethernet/cisco/enic/enic_pp.c +++ b/drivers/net/ethernet/cisco/enic/enic_pp.c @@ -207,7 +207,7 @@ static int enic_pp_disassociate(struct enic *enic, int vf, if (!is_zero_ether_addr(pp->mac_addr)) ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnic_dev_del_addr, pp->mac_addr); - else if (!is_zero_ether_addr(netdev->dev_addr)) + else if (vf == PORT_SELF_VF && !is_zero_ether_addr(netdev->dev_addr)) ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnic_dev_del_addr, netdev->dev_addr); @@ -294,7 +294,7 @@ static int enic_pp_associate(struct enic *enic, int vf, if (!is_zero_ether_addr(pp->mac_addr)) ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnic_dev_add_addr, pp->mac_addr); - else if (!is_zero_ether_addr(netdev->dev_addr)) + else if (vf == PORT_SELF_VF && !is_zero_ether_addr(netdev->dev_addr)) ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnic_dev_add_addr, netdev->dev_addr); -- GitLab From 73c2ae763af0eaa1794dda68c63f97c2905722a8 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Sat, 11 Feb 2012 22:12:44 +0000 Subject: [PATCH 0541/1846] enic: remove assignment of random mac on enic vf This patch removes random mac assignment on vf's. The vf's will start with a zero mac and with upcoming support in fw/driver, a vf mac can be set via the pf. vf's also support ndo_set_mac_address. This decision was made based on the fact that a random mac on a vf is not really needed. And this will reduce some of the problems with the vf's getting a new mac on every driver load/unload (one of them being udev renaming the device on ever load/unload and reboot). Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: sujith sankar Signed-off-by: ChingWei Chang Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index e65d431d4378..f7c3067d4485 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.34" +#define DRV_VERSION "2.1.1.35" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 2838891a94ee..dd7e24b9ffbb 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -2463,11 +2463,6 @@ static int __devinit enic_probe(struct pci_dev *pdev, enic->port_mtu = enic->config.mtu; (void)enic_change_mtu(netdev, enic->port_mtu); -#ifdef CONFIG_PCI_IOV - if (enic_is_sriov_vf(enic) && is_zero_ether_addr(enic->mac_addr)) - random_ether_addr(enic->mac_addr); -#endif - err = enic_set_mac_addr(netdev, enic->mac_addr); if (err) { dev_err(dev, "Invalid MAC address, aborting\n"); -- GitLab From 4807f643872fce66108346d9e406c6df119bf395 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sun, 12 Feb 2012 03:37:06 +0000 Subject: [PATCH 0542/1846] mISDN: Fix typo in dsp_core.c Correct spelling "modul" to "module" in drivers/isdn/mISDN/dsp_core.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/isdn/mISDN/dsp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c index 0c41553ce684..742f9f49668c 100644 --- a/drivers/isdn/mISDN/dsp_core.c +++ b/drivers/isdn/mISDN/dsp_core.c @@ -1119,7 +1119,7 @@ static int __init dsp_init(void) int err; int tics; - printk(KERN_INFO "DSP modul %s\n", mISDN_dsp_revision); + printk(KERN_INFO "DSP module %s\n", mISDN_dsp_revision); dsp_options = options; dsp_debug = debug; -- GitLab From 0f09a343dabeadc4dcde4714317e25de2e93fd13 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sun, 12 Feb 2012 03:45:41 +0000 Subject: [PATCH 0543/1846] stmicro: Fix typo in stmmac_pci.c and stmmac_platform.c Correct spelling "drivr" to "driver" in drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 6ce0706b2d1b..4e12884bab39 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -98,7 +98,7 @@ static int __devinit stmmac_pci_probe(struct pci_dev *pdev, priv = stmmac_dvr_probe(&(pdev->dev), &plat_dat); if (!priv) { - pr_err("%s: main drivr probe failed", __func__); + pr_err("%s: main driver probe failed", __func__); goto err_out; } priv->ioaddr = addr; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 1ac83243649a..11af27ef4930 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -61,7 +61,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) plat_dat = pdev->dev.platform_data; priv = stmmac_dvr_probe(&(pdev->dev), plat_dat); if (!priv) { - pr_err("%s: main drivr probe failed", __func__); + pr_err("%s: main driver probe failed", __func__); goto out_unmap; } -- GitLab From fafdbf84d7eb2cd7aee435cc381a0796e1a5ccb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sun, 12 Feb 2012 11:29:06 +0000 Subject: [PATCH 0544/1846] trivial: typo hnalder -> handler Signed-off-by: David S. Miller --- drivers/net/ethernet/micrel/ks8851.c | 2 +- drivers/net/ethernet/micrel/ks8851_mll.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 4b551feae4c5..0930b9c950d0 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -445,7 +445,7 @@ static void ks8851_init_mac(struct ks8851_net *ks) /** * ks8851_irq - device interrupt handler - * @irq: Interrupt number passed from the IRQ hnalder. + * @irq: Interrupt number passed from the IRQ handler. * @pw: The private word passed to register_irq(), our struct ks8851_net. * * Disable the interrupt from happening again until we've processed the diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index 61a2f61a31f6..3d9a04e7b49d 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c @@ -839,7 +839,7 @@ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks) /** * ks_irq - device interrupt handler - * @irq: Interrupt number passed from the IRQ hnalder. + * @irq: Interrupt number passed from the IRQ handler. * @pw: The private word passed to register_irq(), our struct ks_net. * * This is the handler invoked to find out what happened -- GitLab From b57c1a5646739bfc273245dc738f2f12a2d4d3ec Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 3 Jan 2012 16:03:00 +0200 Subject: [PATCH 0545/1846] Bluetooth: Convert inquiry cache to use standard list types This makes it possible to use the convenience functions provided for standard kernel list types and it also makes it easier to extend the use of the cache for the management interface where e.g. name resolving control will be needed. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 10 ++++------ net/bluetooth/hci_core.c | 31 +++++++++++++++++-------------- net/bluetooth/hci_sysfs.c | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index ea9231f4935f..91d1baf05077 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -44,14 +44,14 @@ struct inquiry_data { }; struct inquiry_entry { - struct inquiry_entry *next; + struct list_head list; __u32 timestamp; struct inquiry_data data; }; struct inquiry_cache { + struct list_head list; __u32 timestamp; - struct inquiry_entry *list; }; struct hci_conn_hash { @@ -350,14 +350,12 @@ extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); static inline void inquiry_cache_init(struct hci_dev *hdev) { - struct inquiry_cache *c = &hdev->inq_cache; - c->list = NULL; + INIT_LIST_HEAD(&hdev->inq_cache.list); } static inline int inquiry_cache_empty(struct hci_dev *hdev) { - struct inquiry_cache *c = &hdev->inq_cache; - return c->list == NULL; + return list_empty(&hdev->inq_cache.list); } static inline long inquiry_cache_age(struct hci_dev *hdev) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 845da3ee56a0..feeea4df2529 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -357,15 +357,11 @@ struct hci_dev *hci_dev_get(int index) /* ---- Inquiry support ---- */ static void inquiry_cache_flush(struct hci_dev *hdev) { - struct inquiry_cache *cache = &hdev->inq_cache; - struct inquiry_entry *next = cache->list, *e; - - BT_DBG("cache %p", cache); + struct inquiry_entry *p, *n; - cache->list = NULL; - while ((e = next)) { - next = e->next; - kfree(e); + list_for_each_entry_safe(p, n, &hdev->inq_cache.list, list) { + list_del(&p->list); + kfree(p); } } @@ -376,10 +372,12 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b BT_DBG("cache %p, %s", cache, batostr(bdaddr)); - for (e = cache->list; e; e = e->next) + list_for_each_entry(e, &cache->list, list) { if (!bacmp(&e->data.bdaddr, bdaddr)) - break; - return e; + return e; + } + + return NULL; } void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) @@ -396,8 +394,7 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) if (!ie) return; - ie->next = cache->list; - cache->list = ie; + list_add(&ie->list, &cache->list); } memcpy(&ie->data, data, sizeof(*data)); @@ -412,15 +409,21 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) struct inquiry_entry *e; int copied = 0; - for (e = cache->list; e && copied < num; e = e->next, copied++) { + list_for_each_entry(e, &cache->list, list) { struct inquiry_data *data = &e->data; + + if (copied >= num) + break; + bacpy(&info->bdaddr, &data->bdaddr); info->pscan_rep_mode = data->pscan_rep_mode; info->pscan_period_mode = data->pscan_period_mode; info->pscan_mode = data->pscan_mode; memcpy(info->dev_class, data->dev_class, 3); info->clock_offset = data->clock_offset; + info++; + copied++; } BT_DBG("cache %p, copied %d", cache, copied); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 521095614235..ed9cceeec7be 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -388,7 +388,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p) hci_dev_lock(hdev); - for (e = cache->list; e; e = e->next) { + list_for_each_entry(e, &cache->list, list) { struct inquiry_data *data = &e->data; seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", batostr(&data->bdaddr), -- GitLab From 32748db00228b67a5315a91e1a6dd2c54864d87b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 30 Dec 2011 14:57:23 +0200 Subject: [PATCH 0546/1846] Bluetooth: Move Extended Inquiry Response defines to hci.h The EIR defines are needed also outside of mgmt.c (e.g. in hci_event.c to check if EIR data has the complete name) so it's better to have them in a single public place, i.e. hci.h. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 13 +++++++++++++ net/bluetooth/mgmt.c | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 5b2fed5eebf2..ce5133b22445 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -284,6 +284,19 @@ enum { #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00 #define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01 +/* Extended Inquiry Response field types */ +#define EIR_FLAGS 0x01 /* flags */ +#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */ +#define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */ +#define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */ +#define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */ +#define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */ +#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ +#define EIR_NAME_SHORT 0x08 /* shortened local name */ +#define EIR_NAME_COMPLETE 0x09 /* complete local name */ +#define EIR_TX_POWER 0x0A /* transmit power level */ +#define EIR_DEVICE_ID 0x10 /* device ID */ + /* ----- HCI Commands ---- */ #define HCI_OP_NOP 0x0000 diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index bc8e59dda78e..851cb19c55b1 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -303,18 +303,6 @@ static u32 get_current_settings(struct hci_dev *hdev) return settings; } -#define EIR_FLAGS 0x01 /* flags */ -#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */ -#define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */ -#define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */ -#define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */ -#define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */ -#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ -#define EIR_NAME_SHORT 0x08 /* shortened local name */ -#define EIR_NAME_COMPLETE 0x09 /* complete local name */ -#define EIR_TX_POWER 0x0A /* transmit power level */ -#define EIR_DEVICE_ID 0x10 /* device ID */ - #define PNP_INFO_SVCLASS_ID 0x1200 static u8 bluetooth_base_uuid[] = { -- GitLab From 561aafbcb2e3f8fee11d3781f866c7b4c4f93a28 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 4 Jan 2012 13:31:59 +0200 Subject: [PATCH 0547/1846] Bluetooth: Add initial mgmt_confirm_name support This patch adds initial support for mgmt_confirm_name. It adds the necessary tracking of the name state by extending the inquiry cache. The actual name resolving operation (to be done once inquiry is finished) is not yet part of this patch. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 29 ++++++++++++---- net/bluetooth/hci_core.c | 58 ++++++++++++++++++++++++++------ net/bluetooth/hci_event.c | 51 +++++++++++++++++++++++----- net/bluetooth/hci_sysfs.c | 2 +- net/bluetooth/mgmt.c | 51 +++++++++++++++++++++++++++- 5 files changed, 163 insertions(+), 28 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 91d1baf05077..2999b6e2c3f0 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -44,14 +44,23 @@ struct inquiry_data { }; struct inquiry_entry { - struct list_head list; + struct list_head all; /* inq_cache.all */ + struct list_head list; /* unknown or resolve */ + enum { + NAME_NOT_KNOWN, + NAME_NEEDED, + NAME_PENDING, + NAME_KNOWN, + } name_state; __u32 timestamp; struct inquiry_data data; }; struct inquiry_cache { - struct list_head list; - __u32 timestamp; + struct list_head all; /* All devices found during inquiry */ + struct list_head unknown; /* Name state not known */ + struct list_head resolve; /* Name needs to be resolved */ + __u32 timestamp; }; struct hci_conn_hash { @@ -350,12 +359,14 @@ extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); static inline void inquiry_cache_init(struct hci_dev *hdev) { - INIT_LIST_HEAD(&hdev->inq_cache.list); + INIT_LIST_HEAD(&hdev->inq_cache.all); + INIT_LIST_HEAD(&hdev->inq_cache.unknown); + INIT_LIST_HEAD(&hdev->inq_cache.resolve); } static inline int inquiry_cache_empty(struct hci_dev *hdev) { - return list_empty(&hdev->inq_cache.list); + return list_empty(&hdev->inq_cache.all); } static inline long inquiry_cache_age(struct hci_dev *hdev) @@ -371,7 +382,10 @@ static inline long inquiry_entry_age(struct inquiry_entry *e) struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); -void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data); +struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, + bdaddr_t *bdaddr); +void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, + bool name_known); /* ----- HCI Connections ----- */ enum { @@ -913,7 +927,8 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir); + u8 addr_type, u8 *dev_class, s8 rssi, + u8 cfm_name, u8 *eir); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index feeea4df2529..fc09a3cbe20c 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -357,12 +357,16 @@ struct hci_dev *hci_dev_get(int index) /* ---- Inquiry support ---- */ static void inquiry_cache_flush(struct hci_dev *hdev) { + struct inquiry_cache *cache = &hdev->inq_cache; struct inquiry_entry *p, *n; - list_for_each_entry_safe(p, n, &hdev->inq_cache.list, list) { - list_del(&p->list); + list_for_each_entry_safe(p, n, &cache->all, all) { + list_del(&p->all); kfree(p); } + + INIT_LIST_HEAD(&cache->unknown); + INIT_LIST_HEAD(&cache->resolve); } struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) @@ -372,7 +376,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b BT_DBG("cache %p, %s", cache, batostr(bdaddr)); - list_for_each_entry(e, &cache->list, list) { + list_for_each_entry(e, &cache->all, all) { if (!bacmp(&e->data.bdaddr, bdaddr)) return e; } @@ -380,7 +384,24 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b return NULL; } -void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) +struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, + bdaddr_t *bdaddr) +{ + struct inquiry_cache *cache = &hdev->inq_cache; + struct inquiry_entry *e; + + BT_DBG("cache %p, %s", cache, batostr(bdaddr)); + + list_for_each_entry(e, &cache->unknown, list) { + if (!bacmp(&e->data.bdaddr, bdaddr)) + return e; + } + + return NULL; +} + +void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, + bool name_known) { struct inquiry_cache *cache = &hdev->inq_cache; struct inquiry_entry *ie; @@ -388,13 +409,28 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr)); ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr); - if (!ie) { - /* Entry not in the cache. Add new one. */ - ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); - if (!ie) - return; + if (ie) + goto update; + + /* Entry not in the cache. Add new one. */ + ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); + if (!ie) + return; + + list_add(&ie->all, &cache->all); + + if (name_known) { + ie->name_state = NAME_KNOWN; + } else { + ie->name_state = NAME_NOT_KNOWN; + list_add(&ie->list, &cache->unknown); + } - list_add(&ie->list, &cache->list); +update: + if (name_known && ie->name_state != NAME_KNOWN && + ie->name_state != NAME_PENDING) { + ie->name_state = NAME_KNOWN; + list_del(&ie->list); } memcpy(&ie->data, data, sizeof(*data)); @@ -409,7 +445,7 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) struct inquiry_entry *e; int copied = 0; - list_for_each_entry(e, &cache->list, list) { + list_for_each_entry(e, &cache->all, all) { struct inquiry_data *data = &e->data; if (copied >= num) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 001307f81057..9302c3c25568 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1533,9 +1533,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.clock_offset = info->clock_offset; data.rssi = 0x00; data.ssp_mode = 0x00; - hci_inquiry_cache_update(hdev, &data); + hci_inquiry_cache_update(hdev, &data, false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, 0, NULL); + info->dev_class, 0, 1, NULL); } hci_dev_unlock(hdev); @@ -2572,10 +2572,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode = 0x00; - hci_inquiry_cache_update(hdev, &data); + hci_inquiry_cache_update(hdev, &data, false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - NULL); + 1, NULL); } } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); @@ -2589,10 +2589,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode = 0x00; - hci_inquiry_cache_update(hdev, &data); + hci_inquiry_cache_update(hdev, &data, false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - NULL); + 1, NULL); } } @@ -2710,6 +2710,31 @@ static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *s BT_DBG("%s status %d", hdev->name, ev->status); } +static inline bool eir_has_complete_name(u8 *data, size_t data_len) +{ + u8 field_len; + size_t parsed; + + for (parsed = 0; parsed < data_len - 1; parsed += field_len) { + field_len = data[0]; + + if (field_len == 0) + break; + + parsed += field_len + 1; + + if (parsed > data_len) + break; + + if (data[1] == EIR_NAME_COMPLETE) + return true; + + data += field_len + 1; + } + + return false; +} + static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct inquiry_data data; @@ -2724,6 +2749,8 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct hci_dev_lock(hdev); for (; num_rsp; num_rsp--, info++) { + bool name_known; + bacpy(&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode; @@ -2732,9 +2759,17 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode = 0x01; - hci_inquiry_cache_update(hdev, &data); + + if (test_bit(HCI_MGMT, &hdev->flags)) + name_known = eir_has_complete_name(info->data, + sizeof(info->data)); + else + name_known = true; + + hci_inquiry_cache_update(hdev, &data, name_known); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, info->rssi, info->data); + info->dev_class, info->rssi, + !name_known, info->data); } hci_dev_unlock(hdev); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index ed9cceeec7be..3600d78c2f25 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -388,7 +388,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p) hci_dev_lock(hdev); - list_for_each_entry(e, &cache->list, list) { + list_for_each_entry(e, &cache->all, all) { struct inquiry_data *data = &e->data; seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", batostr(&data->bdaddr), diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 851cb19c55b1..39775119585a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1967,6 +1967,50 @@ static int stop_discovery(struct sock *sk, u16 index) return err; } +static int confirm_name(struct sock *sk, u16 index, unsigned char *data, + u16 len) +{ + struct mgmt_cp_confirm_name *cp = (void *) data; + struct inquiry_entry *e; + struct hci_dev *hdev; + int err; + + BT_DBG("hci%u", index); + + if (len != sizeof(*cp)) + return cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, + MGMT_STATUS_INVALID_PARAMS); + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, + MGMT_STATUS_INVALID_PARAMS); + + hci_dev_lock(hdev); + + e = hci_inquiry_cache_lookup_unknown(hdev, &cp->bdaddr); + if (!e) { + err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME, + MGMT_STATUS_INVALID_PARAMS); + goto failed; + } + + if (cp->name_known) { + e->name_state = NAME_KNOWN; + list_del(&e->list); + } else { + e->name_state = NAME_NEEDED; + list_move(&e->list, &hdev->inq_cache.resolve); + } + + err = 0; + +failed: + hci_dev_unlock(hdev); + + return err; +} + static int block_device(struct sock *sk, u16 index, unsigned char *data, u16 len) { @@ -2215,6 +2259,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_STOP_DISCOVERY: err = stop_discovery(sk, index); break; + case MGMT_OP_CONFIRM_NAME: + err = confirm_name(sk, index, buf + sizeof(*hdr), len); + break; case MGMT_OP_BLOCK_DEVICE: err = block_device(sk, index, buf + sizeof(*hdr), len); break; @@ -2689,7 +2736,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, } int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir) + u8 addr_type, u8 *dev_class, s8 rssi, + u8 cfm_name, u8 *eir) { struct mgmt_ev_device_found ev; @@ -2698,6 +2746,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, bacpy(&ev.addr.bdaddr, bdaddr); ev.addr.type = link_to_mgmt(link_type, addr_type); ev.rssi = rssi; + ev.confirm_name = cfm_name; if (eir) memcpy(ev.eir, eir, sizeof(ev.eir)); -- GitLab From 3175405b906a85ed2bad21e09c444266e4a05a8e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 4 Jan 2012 13:39:52 +0200 Subject: [PATCH 0548/1846] Bluetooth: Return updated name state with hci_inquiry_cache_update If user-space has already confirmed the name for a remote device we shouldn't request confirmation again. The simplest way to do this is to return the name state from hci_inquiry_cache_update (if it is anything else than unknown then we do not need confirmation from user-space). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_core.c | 9 +++++++-- net/bluetooth/hci_event.c | 21 ++++++++++++++------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 2999b6e2c3f0..236f7f0e596e 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -384,7 +384,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, bdaddr_t *bdaddr); -void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, +bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known); /* ----- HCI Connections ----- */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index fc09a3cbe20c..162176151db9 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -400,7 +400,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, return NULL; } -void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, +bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known) { struct inquiry_cache *cache = &hdev->inq_cache; @@ -415,7 +415,7 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, /* Entry not in the cache. Add new one. */ ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); if (!ie) - return; + return false; list_add(&ie->all, &cache->all); @@ -436,6 +436,11 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, memcpy(&ie->data, data, sizeof(*data)); ie->timestamp = jiffies; cache->timestamp = jiffies; + + if (ie->name_state == NAME_NOT_KNOWN) + return false; + + return true; } static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9302c3c25568..d4d20df9fbbf 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1525,6 +1525,8 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * hci_dev_lock(hdev); for (; num_rsp; num_rsp--, info++) { + bool name_known; + bacpy(&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; data.pscan_period_mode = info->pscan_period_mode; @@ -1533,9 +1535,10 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.clock_offset = info->clock_offset; data.rssi = 0x00; data.ssp_mode = 0x00; - hci_inquiry_cache_update(hdev, &data, false); + + name_known = hci_inquiry_cache_update(hdev, &data, false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, 0, 1, NULL); + info->dev_class, 0, !name_known, NULL); } hci_dev_unlock(hdev); @@ -2551,6 +2554,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct { struct inquiry_data data; int num_rsp = *((__u8 *) skb->data); + bool name_known; BT_DBG("%s num_rsp %d", hdev->name, num_rsp); @@ -2572,10 +2576,12 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode = 0x00; - hci_inquiry_cache_update(hdev, &data, false); + + name_known = hci_inquiry_cache_update(hdev, &data, + false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - 1, NULL); + !name_known, NULL); } } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); @@ -2589,10 +2595,11 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.clock_offset = info->clock_offset; data.rssi = info->rssi; data.ssp_mode = 0x00; - hci_inquiry_cache_update(hdev, &data, false); + name_known = hci_inquiry_cache_update(hdev, &data, + false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - 1, NULL); + !name_known, NULL); } } @@ -2766,7 +2773,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct else name_known = true; - hci_inquiry_cache_update(hdev, &data, name_known); + name_known = hci_inquiry_cache_update(hdev, &data, name_known); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, !name_known, info->data); -- GitLab From 4663262c294c71aa1139616ae7f24dd345a69c15 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 2 Jan 2012 16:06:08 +0200 Subject: [PATCH 0549/1846] Bluetooth: Flush inquiry cache when starting mgmt triggered inquiry For the remote name state tracking for the management interface to work the cache needs to be flushed whenever inquiry is started. The hci_do_inquiry function is only used by the management interface so by having the flushing done from it ensures that old ioctl based functionality isn't affected. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 162176151db9..5dbfb276edf2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2611,6 +2611,8 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length) if (test_bit(HCI_INQUIRY, &hdev->flags)) return -EINPROGRESS; + inquiry_cache_flush(hdev); + memset(&cp, 0, sizeof(cp)); memcpy(&cp.lap, lap, sizeof(cp.lap)); cp.length = length; -- GitLab From 30883512be0839349d29c7b0bc31016e0498cf8c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 4 Jan 2012 14:16:21 +0200 Subject: [PATCH 0550/1846] Bluetooth: Rename hdev->inq_cache to hdev->discovery This struct is used for not just inquiry caching but also for general device discovery state tracking so it's better to rename it to something more appropriate. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 16 ++++++++-------- net/bluetooth/hci_core.c | 12 ++++++------ net/bluetooth/hci_sysfs.c | 2 +- net/bluetooth/mgmt.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 236f7f0e596e..5a566fd5e2a6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -56,7 +56,7 @@ struct inquiry_entry { struct inquiry_data data; }; -struct inquiry_cache { +struct discovery_state { struct list_head all; /* All devices found during inquiry */ struct list_head unknown; /* Name state not known */ struct list_head resolve; /* Name needs to be resolved */ @@ -226,7 +226,7 @@ struct hci_dev { struct list_head mgmt_pending; - struct inquiry_cache inq_cache; + struct discovery_state discovery; struct hci_conn_hash conn_hash; struct list_head blacklist; @@ -357,21 +357,21 @@ extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ -static inline void inquiry_cache_init(struct hci_dev *hdev) +static inline void discovery_init(struct hci_dev *hdev) { - INIT_LIST_HEAD(&hdev->inq_cache.all); - INIT_LIST_HEAD(&hdev->inq_cache.unknown); - INIT_LIST_HEAD(&hdev->inq_cache.resolve); + INIT_LIST_HEAD(&hdev->discovery.all); + INIT_LIST_HEAD(&hdev->discovery.unknown); + INIT_LIST_HEAD(&hdev->discovery.resolve); } static inline int inquiry_cache_empty(struct hci_dev *hdev) { - return list_empty(&hdev->inq_cache.all); + return list_empty(&hdev->discovery.all); } static inline long inquiry_cache_age(struct hci_dev *hdev) { - struct inquiry_cache *c = &hdev->inq_cache; + struct discovery_state *c = &hdev->discovery; return jiffies - c->timestamp; } diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5dbfb276edf2..55509b0a810a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -357,7 +357,7 @@ struct hci_dev *hci_dev_get(int index) /* ---- Inquiry support ---- */ static void inquiry_cache_flush(struct hci_dev *hdev) { - struct inquiry_cache *cache = &hdev->inq_cache; + struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *p, *n; list_for_each_entry_safe(p, n, &cache->all, all) { @@ -371,7 +371,7 @@ static void inquiry_cache_flush(struct hci_dev *hdev) struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) { - struct inquiry_cache *cache = &hdev->inq_cache; + struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *e; BT_DBG("cache %p, %s", cache, batostr(bdaddr)); @@ -387,7 +387,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, bdaddr_t *bdaddr) { - struct inquiry_cache *cache = &hdev->inq_cache; + struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *e; BT_DBG("cache %p, %s", cache, batostr(bdaddr)); @@ -403,7 +403,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known) { - struct inquiry_cache *cache = &hdev->inq_cache; + struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *ie; BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr)); @@ -445,7 +445,7 @@ bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) { - struct inquiry_cache *cache = &hdev->inq_cache; + struct discovery_state *cache = &hdev->discovery; struct inquiry_info *info = (struct inquiry_info *) buf; struct inquiry_entry *e; int copied = 0; @@ -1546,7 +1546,7 @@ int hci_register_dev(struct hci_dev *hdev) init_waitqueue_head(&hdev->req_wait_q); mutex_init(&hdev->req_lock); - inquiry_cache_init(hdev); + discovery_init(hdev); hci_conn_hash_init(hdev); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 3600d78c2f25..74b49e330a1d 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -383,7 +383,7 @@ static struct device_type bt_host = { static int inquiry_cache_show(struct seq_file *f, void *p) { struct hci_dev *hdev = f->private; - struct inquiry_cache *cache = &hdev->inq_cache; + struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *e; hci_dev_lock(hdev); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 39775119585a..894f11bc571d 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2000,7 +2000,7 @@ static int confirm_name(struct sock *sk, u16 index, unsigned char *data, list_del(&e->list); } else { e->name_state = NAME_NEEDED; - list_move(&e->list, &hdev->inq_cache.resolve); + list_move(&e->list, &hdev->discovery.resolve); } err = 0; -- GitLab From ff9ef5787046c3fd20cf9f7ca1cd70260c1eedb9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 4 Jan 2012 14:23:45 +0200 Subject: [PATCH 0551/1846] Bluetooth: Add discovery state tracking This patch adds proper state tracking to the device discovery process. This makes it possible to return appropriate errors when trying to stop a non-active discovery or start discovery when it is already ongoing. Once name resolving is implemented this also makes it possible to know what the right action to do is when a remote name lookup is cancelled. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 9 +++++++++ net/bluetooth/hci_core.c | 25 +++++++++++++++++++++++++ net/bluetooth/hci_event.c | 6 +++--- net/bluetooth/mgmt.c | 16 ++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5a566fd5e2a6..2f19de4770b6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -57,6 +57,12 @@ struct inquiry_entry { }; struct discovery_state { + enum { + DISCOVERY_STOPPED, + DISCOVERY_STARTING, + DISCOVERY_ACTIVE, + DISCOVERY_STOPPING, + } state; struct list_head all; /* All devices found during inquiry */ struct list_head unknown; /* Name state not known */ struct list_head resolve; /* Name needs to be resolved */ @@ -359,11 +365,14 @@ extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); static inline void discovery_init(struct hci_dev *hdev) { + hdev->discovery.state = DISCOVERY_STOPPED; INIT_LIST_HEAD(&hdev->discovery.all); INIT_LIST_HEAD(&hdev->discovery.unknown); INIT_LIST_HEAD(&hdev->discovery.resolve); } +void hci_discovery_set_state(struct hci_dev *hdev, int state); + static inline int inquiry_cache_empty(struct hci_dev *hdev) { return list_empty(&hdev->discovery.all); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 55509b0a810a..b68719230601 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -355,6 +355,30 @@ struct hci_dev *hci_dev_get(int index) } /* ---- Inquiry support ---- */ + +void hci_discovery_set_state(struct hci_dev *hdev, int state) +{ + BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state); + + if (hdev->discovery.state == state) + return; + + switch (state) { + case DISCOVERY_STOPPED: + mgmt_discovering(hdev, 0); + break; + case DISCOVERY_STARTING: + break; + case DISCOVERY_ACTIVE: + mgmt_discovering(hdev, 1); + break; + case DISCOVERY_STOPPING: + break; + } + + hdev->discovery.state = state; +} + static void inquiry_cache_flush(struct hci_dev *hdev) { struct discovery_state *cache = &hdev->discovery; @@ -367,6 +391,7 @@ static void inquiry_cache_flush(struct hci_dev *hdev) INIT_LIST_HEAD(&cache->unknown); INIT_LIST_HEAD(&cache->resolve); + cache->state = DISCOVERY_STOPPED; } struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d4d20df9fbbf..43d69569a0d5 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -65,7 +65,7 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) clear_bit(HCI_INQUIRY, &hdev->flags); hci_dev_lock(hdev); - mgmt_discovering(hdev, 0); + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); hci_dev_unlock(hdev); hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); @@ -1119,7 +1119,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) set_bit(HCI_INQUIRY, &hdev->flags); hci_dev_lock(hdev); - mgmt_discovering(hdev, 1); + hci_discovery_set_state(hdev, DISCOVERY_ACTIVE); hci_dev_unlock(hdev); } @@ -1507,7 +1507,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff return; hci_dev_lock(hdev); - mgmt_discovering(hdev, 0); + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); hci_dev_unlock(hdev); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 894f11bc571d..590966ddfa63 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1918,6 +1918,12 @@ static int start_discovery(struct sock *sk, u16 index, goto failed; } + if (hdev->discovery.state != DISCOVERY_STOPPED) { + err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, + MGMT_STATUS_BUSY); + goto failed; + } + cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, hdev, NULL, 0); if (!cmd) { err = -ENOMEM; @@ -1927,6 +1933,8 @@ static int start_discovery(struct sock *sk, u16 index, err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); if (err < 0) mgmt_pending_remove(cmd); + else + hci_discovery_set_state(hdev, DISCOVERY_STARTING); failed: hci_dev_unlock(hdev); @@ -1950,6 +1958,12 @@ static int stop_discovery(struct sock *sk, u16 index) hci_dev_lock(hdev); + if (hdev->discovery.state != DISCOVERY_ACTIVE) { + err = cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, + MGMT_STATUS_REJECTED); + goto failed; + } + cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, hdev, NULL, 0); if (!cmd) { err = -ENOMEM; @@ -1959,6 +1973,8 @@ static int stop_discovery(struct sock *sk, u16 index) err = hci_cancel_inquiry(hdev); if (err < 0) mgmt_pending_remove(cmd); + else + hci_discovery_set_state(hdev, DISCOVERY_STOPPING); failed: hci_dev_unlock(hdev); -- GitLab From 30dc78e1a2bcbe2a0fca7aa44dfded4bb0db6148 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 4 Jan 2012 15:44:20 +0200 Subject: [PATCH 0552/1846] Bluetooth: Add name resolving support for mgmt based discovery This patch adds the necessary logic to perform name lookups after inquiry completes. This is done by checking for entries in the resolve list after each inquiry complete and remote name complete HCI event. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 8 +++- net/bluetooth/hci_core.c | 34 +++++++++++++- net/bluetooth/hci_event.c | 81 ++++++++++++++++++++++++++++++-- net/bluetooth/mgmt.c | 37 +++++++++++++-- 4 files changed, 149 insertions(+), 11 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 2f19de4770b6..a8680da7f400 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -60,7 +60,8 @@ struct discovery_state { enum { DISCOVERY_STOPPED, DISCOVERY_STARTING, - DISCOVERY_ACTIVE, + DISCOVERY_INQUIRY, + DISCOVERY_RESOLVING, DISCOVERY_STOPPING, } state; struct list_head all; /* All devices found during inquiry */ @@ -371,6 +372,8 @@ static inline void discovery_init(struct hci_dev *hdev) INIT_LIST_HEAD(&hdev->discovery.resolve); } +bool hci_discovery_active(struct hci_dev *hdev); + void hci_discovery_set_state(struct hci_dev *hdev, int state); static inline int inquiry_cache_empty(struct hci_dev *hdev) @@ -393,6 +396,9 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, bdaddr_t *bdaddr); +struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, + bdaddr_t *bdaddr, + int state); bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b68719230601..546a42941477 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -356,6 +356,17 @@ struct hci_dev *hci_dev_get(int index) /* ---- Inquiry support ---- */ +bool hci_discovery_active(struct hci_dev *hdev) +{ + struct discovery_state *discov = &hdev->discovery; + + if (discov->state == DISCOVERY_INQUIRY || + discov->state == DISCOVERY_RESOLVING) + return true; + + return false; +} + void hci_discovery_set_state(struct hci_dev *hdev, int state) { BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state); @@ -369,9 +380,11 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) break; case DISCOVERY_STARTING: break; - case DISCOVERY_ACTIVE: + case DISCOVERY_INQUIRY: mgmt_discovering(hdev, 1); break; + case DISCOVERY_RESOLVING: + break; case DISCOVERY_STOPPING: break; } @@ -425,6 +438,25 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, return NULL; } +struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, + bdaddr_t *bdaddr, + int state) +{ + struct discovery_state *cache = &hdev->discovery; + struct inquiry_entry *e; + + BT_DBG("cache %p bdaddr %s state %d", cache, batostr(bdaddr), state); + + list_for_each_entry(e, &cache->resolve, list) { + if (!bacmp(bdaddr, BDADDR_ANY) && e->name_state == state) + return e; + if (!bacmp(&e->data.bdaddr, bdaddr)) + return e; + } + + return NULL; +} + bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known) { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 43d69569a0d5..089dff80ccb0 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1119,7 +1119,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) set_bit(HCI_INQUIRY, &hdev->flags); hci_dev_lock(hdev); - hci_discovery_set_state(hdev, DISCOVERY_ACTIVE); + hci_discovery_set_state(hdev, DISCOVERY_INQUIRY); hci_dev_unlock(hdev); } @@ -1271,6 +1271,50 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev, return 1; } +static inline int hci_resolve_name(struct hci_dev *hdev, struct inquiry_entry *e) +{ + struct hci_cp_remote_name_req cp; + + memset(&cp, 0, sizeof(cp)); + + bacpy(&cp.bdaddr, &e->data.bdaddr); + cp.pscan_rep_mode = e->data.pscan_rep_mode; + cp.pscan_mode = e->data.pscan_mode; + cp.clock_offset = e->data.clock_offset; + + return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); +} + +static void hci_resolve_next_name(struct hci_dev *hdev, bdaddr_t *bdaddr) +{ + struct discovery_state *discov = &hdev->discovery; + struct inquiry_entry *e; + + if (discov->state == DISCOVERY_STOPPING) + goto discov_complete; + + if (discov->state != DISCOVERY_RESOLVING) + return; + + e = hci_inquiry_cache_lookup_resolve(hdev, bdaddr, NAME_PENDING); + if (e) { + e->name_state = NAME_KNOWN; + list_del(&e->list); + } + + if (list_empty(&discov->resolve)) + goto discov_complete; + + e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); + if (hci_resolve_name(hdev, e) == 0) { + e->name_state = NAME_PENDING; + return; + } + +discov_complete: + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); +} + static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) { struct hci_cp_remote_name_req *cp; @@ -1289,6 +1333,9 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) hci_dev_lock(hdev); + if (test_bit(HCI_MGMT, &hdev->flags)) + hci_resolve_next_name(hdev, &cp->bdaddr); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); if (!conn) goto unlock; @@ -1496,6 +1543,8 @@ static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) { __u8 status = *((__u8 *) skb->data); + struct discovery_state *discov = &hdev->discovery; + struct inquiry_entry *e; BT_DBG("%s status %d", hdev->name, status); @@ -1506,8 +1555,28 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) return; + if (!test_bit(HCI_MGMT, &hdev->flags)) + return; + hci_dev_lock(hdev); - hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + + if (discov->state != DISCOVERY_INQUIRY) + goto unlock; + + if (list_empty(&discov->resolve)) { + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + goto unlock; + } + + e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); + if (e && hci_resolve_name(hdev, e) == 0) { + e->name_state = NAME_PENDING; + hci_discovery_set_state(hdev, DISCOVERY_RESOLVING); + } else { + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + } + +unlock: hci_dev_unlock(hdev); } @@ -1807,8 +1876,12 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb hci_dev_lock(hdev); - if (ev->status == 0 && test_bit(HCI_MGMT, &hdev->flags)) - mgmt_remote_name(hdev, &ev->bdaddr, ev->name); + if (test_bit(HCI_MGMT, &hdev->flags)) { + if (ev->status == 0) + mgmt_remote_name(hdev, &ev->bdaddr, ev->name); + + hci_resolve_next_name(hdev, &ev->bdaddr); + } conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (!conn) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 590966ddfa63..295cfc8a3076 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1947,6 +1947,8 @@ static int stop_discovery(struct sock *sk, u16 index) { struct hci_dev *hdev; struct pending_cmd *cmd; + struct hci_cp_remote_name_req_cancel cp; + struct inquiry_entry *e; int err; BT_DBG("hci%u", index); @@ -1958,25 +1960,44 @@ static int stop_discovery(struct sock *sk, u16 index) hci_dev_lock(hdev); - if (hdev->discovery.state != DISCOVERY_ACTIVE) { + if (!hci_discovery_active(hdev)) { err = cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, MGMT_STATUS_REJECTED); - goto failed; + goto unlock; } cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, hdev, NULL, 0); if (!cmd) { err = -ENOMEM; - goto failed; + goto unlock; + } + + if (hdev->discovery.state == DISCOVERY_INQUIRY) { + err = hci_cancel_inquiry(hdev); + if (err < 0) + mgmt_pending_remove(cmd); + else + hci_discovery_set_state(hdev, DISCOVERY_STOPPING); + goto unlock; + } + + e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_PENDING); + if (!e) { + mgmt_pending_remove(cmd); + err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, NULL, 0); + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + goto unlock; } - err = hci_cancel_inquiry(hdev); + bacpy(&cp.bdaddr, &e->data.bdaddr); + err = hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ_CANCEL, + sizeof(cp), &cp); if (err < 0) mgmt_pending_remove(cmd); else hci_discovery_set_state(hdev, DISCOVERY_STOPPING); -failed: +unlock: hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2004,6 +2025,12 @@ static int confirm_name(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock(hdev); + if (!hci_discovery_active(hdev)) { + err = cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, + MGMT_STATUS_FAILED); + goto failed; + } + e = hci_inquiry_cache_lookup_unknown(hdev, &cp->bdaddr); if (!e) { err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME, -- GitLab From 5e41862322388224eef7ce221c8772489e3aa39a Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 3 Jan 2012 11:53:53 +0100 Subject: [PATCH 0553/1846] Bluetooth: Don't mark non xfer isoc endpoint URBs with URB_ISO_ASAP [ 2096.384084] btusb_send_frame:684: hci0 [ 2096.384087] usb 3-1: BOGUS urb flags, 2 --> 0 [ 2096.384091] Bluetooth: hci0 urb ffff8801b61d3a80 submission failed (22) According the documentation in usb_submit_urb() URB_ISO_ASAP flag is only allowed for endpoints of type USB_ENDPOINT_XFER_ISOC. This reverts commit b8aabfc92249b239c425da7e4ca85b7e4855e984. Signed-off-by: Daniel Wagner Acked-by: Luiz Augusto von Dentz Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btusb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 55ac349695c4..8bca784c0ea0 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -726,9 +726,6 @@ static int btusb_send_frame(struct sk_buff *skb) usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len, btusb_tx_complete, skb); - if (skb->priority >= HCI_PRIO_MAX - 1) - urb->transfer_flags = URB_ISO_ASAP; - hdev->stat.acl_tx++; break; -- GitLab From 25e89e99b4a54a2cb6e27b4675cd71a3d8a9b3fc Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 4 Jan 2012 12:41:58 +0200 Subject: [PATCH 0554/1846] Bluetooth: Process num completed data blocks event Adds support for Number Of Completed Data Blocks Event. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 13 +++++++++ net/bluetooth/hci_event.c | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index ce5133b22445..6a9d316fb977 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1168,6 +1168,19 @@ struct hci_ev_le_meta { __u8 subevent; } __packed; +#define HCI_EV_NUM_COMP_BLOCKS 0x48 +struct hci_comp_blocks_info { + __le16 handle; + __le16 pkts; + __le16 blocks; +} __packed; + +struct hci_ev_num_comp_blocks { + __le16 num_blocks; + __u8 num_hndl; + struct hci_comp_blocks_info handles[0]; +} __packed; + /* Low energy meta events */ #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 089dff80ccb0..0466ed9c1b47 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2408,6 +2408,56 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s queue_work(hdev->workqueue, &hdev->tx_work); } +static inline void hci_num_comp_blocks_evt(struct hci_dev *hdev, + struct sk_buff *skb) +{ + struct hci_ev_num_comp_blocks *ev = (void *) skb->data; + int i; + + if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_BLOCK_BASED) { + BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode); + return; + } + + if (skb->len < sizeof(*ev) || skb->len < sizeof(*ev) + + ev->num_hndl * sizeof(struct hci_comp_blocks_info)) { + BT_DBG("%s bad parameters", hdev->name); + return; + } + + BT_DBG("%s num_blocks %d num_hndl %d", hdev->name, ev->num_blocks, + ev->num_hndl); + + for (i = 0; i < ev->num_hndl; i++) { + struct hci_comp_blocks_info *info = &ev->handles[i]; + struct hci_conn *conn; + __u16 handle, block_count; + + handle = __le16_to_cpu(info->handle); + block_count = __le16_to_cpu(info->blocks); + + conn = hci_conn_hash_lookup_handle(hdev, handle); + if (!conn) + continue; + + conn->sent -= block_count; + + switch (conn->type) { + case ACL_LINK: + hdev->block_cnt += block_count; + if (hdev->block_cnt > hdev->num_blocks) + hdev->block_cnt = hdev->num_blocks; + break; + + default: + BT_ERR("Unknown type %d conn %p", conn->type, conn); + break; + } + } + + queue_work(hdev->workqueue, &hdev->tx_work); +} + static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_mode_change *ev = (void *) skb->data; @@ -3386,6 +3436,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) hci_remote_oob_data_request_evt(hdev, skb); break; + case HCI_EV_NUM_COMP_BLOCKS: + hci_num_comp_blocks_evt(hdev, skb); + break; + default: BT_DBG("%s event 0x%x", hdev->name, event); break; -- GitLab From 6423cf3a1862d5b162aaa13543bf69216a9f6ac0 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 4 Jan 2012 12:10:41 +0100 Subject: [PATCH 0555/1846] Bluetooth: Fix sk_sndtimeo initialization for L2CAP socket sk_sndtime value should be specified in jiffies thus initial value needs to be converted from miliseconds. Otherwise this timeout is unreliable when CONFIG_HZ is not set to 1000. Signed-off-by: Andrzej Kaczmarek Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index c61d967012b2..c57027f7606f 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1002,7 +1002,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p INIT_LIST_HEAD(&bt_sk(sk)->accept_q); sk->sk_destruct = l2cap_sock_destruct; - sk->sk_sndtimeo = L2CAP_CONN_TIMEOUT; + sk->sk_sndtimeo = msecs_to_jiffies(L2CAP_CONN_TIMEOUT); sock_reset_flag(sk, SOCK_ZAPPED); -- GitLab From b83ddfe2ac670392c27a799371bb1a7e14a7e3d3 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 4 Jan 2012 12:10:42 +0100 Subject: [PATCH 0556/1846] Bluetooth: l2cap_set_timer needs jiffies as timeout value After moving L2CAP timers to workqueues l2cap_set_timer expects timeout value to be specified in jiffies but constants defined in miliseconds are used. This makes timeouts unreliable when CONFIG_HZ is not set to 1000. __set_chan_timer macro still uses jiffies as input to avoid multiple conversions from/to jiffies for sk_sndtimeo value which is already specified in jiffies. Signed-off-by: Andrzej Kaczmarek Ackec-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 6 +++--- net/bluetooth/l2cap_core.c | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 68f589150692..ab8f7d83079a 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -626,13 +626,13 @@ static inline void l2cap_clear_timer(struct l2cap_chan *chan, #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ - L2CAP_DEFAULT_RETRANS_TO); + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) #define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ - L2CAP_DEFAULT_MONITOR_TO); + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ - L2CAP_DEFAULT_ACK_TO); + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index faf0b11ac1d3..e35ff4cd33ce 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2970,7 +2970,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr default: sk->sk_err = ECONNRESET; - __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT); + __set_chan_timer(chan, + msecs_to_jiffies(L2CAP_DISC_REJ_TIMEOUT)); l2cap_send_disconn_req(conn, chan, ECONNRESET); goto done; } @@ -4478,7 +4479,8 @@ static inline void l2cap_check_encryption(struct l2cap_chan *chan, u8 encrypt) if (encrypt == 0x00) { if (chan->sec_level == BT_SECURITY_MEDIUM) { __clear_chan_timer(chan); - __set_chan_timer(chan, L2CAP_ENC_TIMEOUT); + __set_chan_timer(chan, + msecs_to_jiffies(L2CAP_ENC_TIMEOUT)); } else if (chan->sec_level == BT_SECURITY_HIGH) l2cap_chan_close(chan, ECONNREFUSED); } else { @@ -4546,7 +4548,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) L2CAP_CONN_REQ, sizeof(req), &req); } else { __clear_chan_timer(chan); - __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); + __set_chan_timer(chan, + msecs_to_jiffies(L2CAP_DISC_TIMEOUT)); } } else if (chan->state == BT_CONNECT2) { struct l2cap_conn_rsp rsp; @@ -4566,7 +4569,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) } } else { l2cap_state_change(chan, BT_DISCONN); - __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); + __set_chan_timer(chan, + msecs_to_jiffies(L2CAP_DISC_TIMEOUT)); res = L2CAP_CR_SEC_BLOCK; stat = L2CAP_CS_NO_INFO; } -- GitLab From cc48dc0a996af6ae20e91c551d71e7f72768860f Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 4 Jan 2012 16:42:26 +0200 Subject: [PATCH 0557/1846] Bluetooth: Remove magic number from ACL TO Adds HCI_ACL_TX_TIMEOUT and clear conversion from msec to jiffies Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_core.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 6a9d316fb977..4202c9cb497e 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -130,6 +130,7 @@ enum { #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ +#define HCI_ACL_TX_TIMEOUT (45000) /* 45 seconds */ /* HCI data types */ #define HCI_COMMAND_PKT 0x01 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 546a42941477..f84935e5cbab 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2350,7 +2350,8 @@ static inline void hci_sched_acl(struct hci_dev *hdev) if (!test_bit(HCI_RAW, &hdev->flags)) { /* ACL tx timeout must be longer than maximum * link supervision timeout (40.9 seconds) */ - if (!hdev->acl_cnt && time_after(jiffies, hdev->acl_last_tx + HZ * 45)) + if (!hdev->acl_cnt && time_after(jiffies, hdev->acl_last_tx + + msecs_to_jiffies(HCI_ACL_TX_TIMEOUT))) hci_link_tx_to(hdev, ACL_LINK); } -- GitLab From 1931782b67bd1b81007022e8311669c40bb7d5b1 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Wed, 4 Jan 2012 11:57:17 -0300 Subject: [PATCH 0558/1846] Bluetooth: Fix using an absolute timeout on hci_conn_put() queue_delayed_work() expects a relative time for when that work should be scheduled. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index a8680da7f400..25a6c3fd7d1a 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -588,7 +588,7 @@ static inline void hci_conn_put(struct hci_conn *conn) } cancel_delayed_work_sync(&conn->disc_work); queue_delayed_work(conn->hdev->workqueue, - &conn->disc_work, jiffies + timeo); + &conn->disc_work, timeo); } } -- GitLab From 9eb648c39af8c14cb63fc9ccfc9a52cdb4442daa Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:19:37 +0100 Subject: [PATCH 0559/1846] Bluetooth: hci-uart-ll: Use GFP_ATOMIC in open() The uart_proto open() callback is not called in atomic context so we can safely sleep here. The caller hci_uart_set_proto() in hci_ldisc.c is an ioctl() handler and therefore can sleep. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_ll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c index 7e4b435f79f0..b874c0efde24 100644 --- a/drivers/bluetooth/hci_ll.c +++ b/drivers/bluetooth/hci_ll.c @@ -125,7 +125,7 @@ static int ll_open(struct hci_uart *hu) BT_DBG("hu %p", hu); - ll = kzalloc(sizeof(*ll), GFP_ATOMIC); + ll = kzalloc(sizeof(*ll), GFP_KERNEL); if (!ll) return -ENOMEM; -- GitLab From fdcd1661a6b22e3ac429759627d2b4d68f77d64a Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:19:38 +0100 Subject: [PATCH 0560/1846] Bluetooth: hci-uart-h4: Use GFP_ATOMIC in open() The uart_proto open() callback is not called in atomic context so we can safely sleep here. The caller hci_uart_set_proto() in hci_ldisc.c is an ioctl-handler and therefore can sleep. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_h4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index 2fcd8b387d69..748329468d26 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c @@ -69,7 +69,7 @@ static int h4_open(struct hci_uart *hu) BT_DBG("hu %p", hu); - h4 = kzalloc(sizeof(*h4), GFP_ATOMIC); + h4 = kzalloc(sizeof(*h4), GFP_KERNEL); if (!h4) return -ENOMEM; -- GitLab From c063af346d89be16e38385e55e5630070d6fd512 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:19:39 +0100 Subject: [PATCH 0561/1846] Bluetooth: hci-uart-bcsp: Use GFP_ATOMIC in open() The uart_proto open() callback is not called in atomic context so we can safely sleep here. The caller hci_uart_set_proto() in hci_ldisc.c is an ioctl-handler and therefore can sleep. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_bcsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index 9c5b2dc38e29..8bf0c3e774e8 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c @@ -692,7 +692,7 @@ static int bcsp_open(struct hci_uart *hu) BT_DBG("hu %p", hu); - bcsp = kzalloc(sizeof(*bcsp), GFP_ATOMIC); + bcsp = kzalloc(sizeof(*bcsp), GFP_KERNEL); if (!bcsp) return -ENOMEM; -- GitLab From f5fd5baee39fe941bd73973c63990d153184e3a1 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:19:40 +0100 Subject: [PATCH 0562/1846] Bluetooth: hci-uart-ath: Use GFP_ATOMIC in open() The uart_proto open() callback is not called in atomic context so we can safely sleep here. The caller hci_uart_set_proto() in hci_ldisc.c is an ioctl-handler and therefore can sleep. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_ath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c index 4093935ddf42..12172a6a95c4 100644 --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c @@ -112,7 +112,7 @@ static int ath_open(struct hci_uart *hu) BT_DBG("hu %p", hu); - ath = kzalloc(sizeof(*ath), GFP_ATOMIC); + ath = kzalloc(sizeof(*ath), GFP_KERNEL); if (!ath) return -ENOMEM; -- GitLab From 5a0b8159e1c65ce25382d3f5189b6a462422f065 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:19:41 +0100 Subject: [PATCH 0563/1846] Bluetooth: dtl1: Fix memleak in probe() We currently leak the driver info structure if dtl1_config fails. If we add a kfree() to dtl1_release to fix this, then dtl1_release and dtl1_detach are identical so this merges both functions. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/dtl1_cs.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 969bb22e493f..b2db5e9bd1fd 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -83,9 +83,6 @@ typedef struct dtl1_info_t { static int dtl1_config(struct pcmcia_device *link); -static void dtl1_release(struct pcmcia_device *link); - -static void dtl1_detach(struct pcmcia_device *p_dev); /* Transmit states */ @@ -579,8 +576,8 @@ static void dtl1_detach(struct pcmcia_device *link) { dtl1_info_t *info = link->priv; - dtl1_release(link); - + dtl1_close(info); + pcmcia_disable_device(link); kfree(info); } @@ -619,21 +616,10 @@ static int dtl1_config(struct pcmcia_device *link) return 0; failed: - dtl1_release(link); + dtl1_detach(link); return -ENODEV; } - -static void dtl1_release(struct pcmcia_device *link) -{ - dtl1_info_t *info = link->priv; - - dtl1_close(info); - - pcmcia_disable_device(link); -} - - static const struct pcmcia_device_id dtl1_ids[] = { PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-4", 0xe1bfdd64, 0x9102bc82), -- GitLab From 010666a126fce7b9ecdda7209c558db21d771c56 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:07 +0100 Subject: [PATCH 0564/1846] Bluetooth: Make hci-destruct callback optional Several drivers already provide an empty callback so we can actually make this optional and then remove all those empty callbacks in the drivers. This callback isn't needed at all by most drivers as they can remove their allocated structures on device disconnect and not on hci destruction. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 6 ++++-- net/bluetooth/hci_core.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 25a6c3fd7d1a..86c74cc563ff 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -595,8 +595,10 @@ static inline void hci_conn_put(struct hci_conn *conn) /* ----- HCI Devices ----- */ static inline void __hci_dev_put(struct hci_dev *d) { - if (atomic_dec_and_test(&d->refcnt)) - d->destruct(d); + if (atomic_dec_and_test(&d->refcnt)) { + if (d->destruct) + d->destruct(d); + } } /* diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f84935e5cbab..f23e32a645c8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1551,7 +1551,7 @@ int hci_register_dev(struct hci_dev *hdev) BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name, hdev->bus, hdev->owner); - if (!hdev->open || !hdev->close || !hdev->destruct) + if (!hdev->open || !hdev->close) return -EINVAL; /* Do not allow HCI_AMP devices to register at index 0, -- GitLab From ac9ef65776845f3719e759368319570bf206ea2a Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:08 +0100 Subject: [PATCH 0565/1846] Bluetooth: bluecard-cs: Remove empty destruct cb The destruct callback is optional and we provide an empty callback so remove it entirely to avoid unnecessary code. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/bluecard_cs.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index c6a0c6103743..5cb325a13745 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -691,11 +691,6 @@ static int bluecard_hci_send_frame(struct sk_buff *skb) } -static void bluecard_hci_destruct(struct hci_dev *hdev) -{ -} - - static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; @@ -741,7 +736,6 @@ static int bluecard_open(bluecard_info_t *info) hdev->close = bluecard_hci_close; hdev->flush = bluecard_hci_flush; hdev->send = bluecard_hci_send_frame; - hdev->destruct = bluecard_hci_destruct; hdev->ioctl = bluecard_hci_ioctl; hdev->owner = THIS_MODULE; -- GitLab From a3f356251835205e291f7b9adb2c5f7615cf39f3 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:09 +0100 Subject: [PATCH 0566/1846] Bluetooth: bt3c-cs: Remove empty destruct cb The callback is optional and we provide an empty callback so remove it. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/bt3c_cs.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 0c97e5d514b6..e74334dfc776 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -456,11 +456,6 @@ static int bt3c_hci_send_frame(struct sk_buff *skb) } -static void bt3c_hci_destruct(struct hci_dev *hdev) -{ -} - - static int bt3c_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; @@ -587,7 +582,6 @@ static int bt3c_open(bt3c_info_t *info) hdev->close = bt3c_hci_close; hdev->flush = bt3c_hci_flush; hdev->send = bt3c_hci_send_frame; - hdev->destruct = bt3c_hci_destruct; hdev->ioctl = bt3c_hci_ioctl; hdev->owner = THIS_MODULE; -- GitLab From e300440beb806616094f838a92a33c5d4677ab7a Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:10 +0100 Subject: [PATCH 0567/1846] Bluetooth: btmrvl: Remove empty destruct cb The callback is optional and we provide an empty callback so remove it entirely. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btmrvl_main.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index 6c3defa50845..995cf43f4bd2 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c @@ -387,10 +387,6 @@ static int btmrvl_ioctl(struct hci_dev *hdev, return -ENOIOCTLCMD; } -static void btmrvl_destruct(struct hci_dev *hdev) -{ -} - static int btmrvl_send_frame(struct sk_buff *skb) { struct hci_dev *hdev = (struct hci_dev *) skb->dev; @@ -553,7 +549,6 @@ int btmrvl_register_hdev(struct btmrvl_private *priv) hdev->close = btmrvl_close; hdev->flush = btmrvl_flush; hdev->send = btmrvl_send_frame; - hdev->destruct = btmrvl_destruct; hdev->ioctl = btmrvl_ioctl; hdev->owner = THIS_MODULE; -- GitLab From 3a456784d346961194bd586aabe40011dba278c1 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:11 +0100 Subject: [PATCH 0568/1846] Bluetooth: btuart-cs: Remove empty destruct cb The destruct callback is optional and we provide an empty callback so remove it. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btuart_cs.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 200b3a2877d6..84e02f1a45b9 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -459,11 +459,6 @@ static int btuart_hci_send_frame(struct sk_buff *skb) } -static void btuart_hci_destruct(struct hci_dev *hdev) -{ -} - - static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; @@ -505,7 +500,6 @@ static int btuart_open(btuart_info_t *info) hdev->close = btuart_hci_close; hdev->flush = btuart_hci_flush; hdev->send = btuart_hci_send_frame; - hdev->destruct = btuart_hci_destruct; hdev->ioctl = btuart_hci_ioctl; hdev->owner = THIS_MODULE; -- GitLab From 6147032f9481475b21123d2f4a176bff24385f79 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:12 +0100 Subject: [PATCH 0569/1846] Bluetooth: btwilink: Remove empty destruct cb The destruct cb is optional so remove our empty dummy cb. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btwilink.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c index b5f83b44a0cd..da9cf6a6e8ac 100644 --- a/drivers/bluetooth/btwilink.c +++ b/drivers/bluetooth/btwilink.c @@ -291,14 +291,6 @@ static int ti_st_send_frame(struct sk_buff *skb) return 0; } -static void ti_st_destruct(struct hci_dev *hdev) -{ - BT_DBG("%s", hdev->name); - /* do nothing here, since platform remove - * would free the hdev->driver_data - */ -} - static int bt_ti_probe(struct platform_device *pdev) { static struct ti_st *hst; @@ -325,7 +317,6 @@ static int bt_ti_probe(struct platform_device *pdev) hdev->close = ti_st_close; hdev->flush = NULL; hdev->send = ti_st_send_frame; - hdev->destruct = ti_st_destruct; hdev->owner = THIS_MODULE; err = hci_register_dev(hdev); -- GitLab From aed014a02e809bd228a8ce7e7cc432ded9b72ef6 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:13 +0100 Subject: [PATCH 0570/1846] Bluetooth: dtl1-cs: Remove empty destruct cb The destruct cb is optional so we can safely remove our dummy cb. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/dtl1_cs.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index b2db5e9bd1fd..aae40caaa188 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -439,11 +439,6 @@ static int dtl1_hci_send_frame(struct sk_buff *skb) } -static void dtl1_hci_destruct(struct hci_dev *hdev) -{ -} - - static int dtl1_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; @@ -487,7 +482,6 @@ static int dtl1_open(dtl1_info_t *info) hdev->close = dtl1_hci_close; hdev->flush = dtl1_hci_flush; hdev->send = dtl1_hci_send_frame; - hdev->destruct = dtl1_hci_destruct; hdev->ioctl = dtl1_hci_ioctl; hdev->owner = THIS_MODULE; -- GitLab From bf18c7118cf83ad4b9aa476354b4a06bcb9d0c4f Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:14 +0100 Subject: [PATCH 0571/1846] Bluetooth: vhci: Free driver_data on file release This removes the hci-destruct callback and instead frees the private driver data in the vhci_release file release function. There is no reason to keep private driver data available if the driver has already shut down. After vhci_release is called our module can be unloaded. The only reason it is kept alive is the hci-core having a module-ref on us because of our destruct callback. However, this callback only frees hdev->driver_data. That is, we wait for the hdev-device to get destroyed to free our internal driver-data. In fact, the hci-core does never touch hdev->driver_data so it doesn't care if it is NULL. Therefore, we simply free it when unloading the driver. Another important fact is that the hdev core does not call any callbacks other than the destruct-cb after hci_unregister_dev() has been called. So there is no function of our module that will be called nor does the hci-core touch hdev->driver_data. Hence, no other code can touch hdev->driver_data after our cleanup so the destruct callback is definitely unnecessary here. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_vhci.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 2ed6ab1c6e1b..44a801292d62 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -103,11 +103,6 @@ static int vhci_send_frame(struct sk_buff *skb) return 0; } -static void vhci_destruct(struct hci_dev *hdev) -{ - kfree(hdev->driver_data); -} - static inline ssize_t vhci_get_user(struct vhci_data *data, const char __user *buf, size_t count) { @@ -248,7 +243,6 @@ static int vhci_open(struct inode *inode, struct file *file) hdev->close = vhci_close_dev; hdev->flush = vhci_flush; hdev->send = vhci_send_frame; - hdev->destruct = vhci_destruct; hdev->owner = THIS_MODULE; @@ -273,6 +267,7 @@ static int vhci_release(struct inode *inode, struct file *file) hci_free_dev(hdev); file->private_data = NULL; + kfree(data); return 0; } -- GitLab From 1a609a0a9375cc1fc2097dc697d08fb278a4c764 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:15 +0100 Subject: [PATCH 0572/1846] Bluetooth: bfusb: Free driver_data on USB shutdown This frees the private driver data on USB shutdown instead of using the hci-destruct callback. We already call usb_set_intfdata(intf, NULL) but we do not do the same with the hci object. This would be totally safe, though. After calling hci_unregister_dev()/hci_free_dev() the hdev object will never call any callback of us again except the destruct callback. Therefore, we can safely set the destruct callback to NULL and free the driver data right away. This allows to unload the module without waiting for the hdev device to be released. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/bfusb.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index a323baee51b0..e99ce89e1cad 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -544,15 +544,6 @@ static int bfusb_send_frame(struct sk_buff *skb) return 0; } -static void bfusb_destruct(struct hci_dev *hdev) -{ - struct bfusb_data *data = hdev->driver_data; - - BT_DBG("hdev %p bfusb %p", hdev, data); - - kfree(data); -} - static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; @@ -712,7 +703,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i hdev->close = bfusb_close; hdev->flush = bfusb_flush; hdev->send = bfusb_send_frame; - hdev->destruct = bfusb_destruct; hdev->ioctl = bfusb_ioctl; hdev->owner = THIS_MODULE; @@ -753,6 +743,7 @@ static void bfusb_disconnect(struct usb_interface *intf) hci_unregister_dev(hdev); hci_free_dev(hdev); + kfree(data); } static struct usb_driver bfusb_driver = { -- GitLab From 8381088e39d03c55552b9dfb09b9b303e96acc78 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:16 +0100 Subject: [PATCH 0573/1846] Bluetooth: btusb: Free driver data on USB shutdown Instead of using the hci-destruct callback we free our private driver data on USB shutdown. We already called hci_unregister_dev() here so the hci core will never ever call our callbacks again except the destruct callback. However, there is no reason to keep our *private* driver data alive if we get never called again and the hci-core does never touch it the data. So we simply free it right away and set the destruct callback to NULL. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btusb.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8bca784c0ea0..44b5e736ddc3 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -783,15 +783,6 @@ static int btusb_send_frame(struct sk_buff *skb) return err; } -static void btusb_destruct(struct hci_dev *hdev) -{ - struct btusb_data *data = hdev->driver_data; - - BT_DBG("%s", hdev->name); - - kfree(data); -} - static void btusb_notify(struct hci_dev *hdev, unsigned int evt) { struct btusb_data *data = hdev->driver_data; @@ -1004,7 +995,6 @@ static int btusb_probe(struct usb_interface *intf, hdev->close = btusb_close; hdev->flush = btusb_flush; hdev->send = btusb_send_frame; - hdev->destruct = btusb_destruct; hdev->notify = btusb_notify; hdev->owner = THIS_MODULE; @@ -1108,6 +1098,7 @@ static void btusb_disconnect(struct usb_interface *intf) __hci_dev_put(hdev); hci_free_dev(hdev); + kfree(data); } #ifdef CONFIG_PM -- GitLab From d25442ba4b44bf1fad50c9c2156a4ca89f269713 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:17 +0100 Subject: [PATCH 0574/1846] Bluetooth: bpa10x: Free private driver data on usb shutdown Instead of waiting for the hci-device to be destroyed we now free the private driver data on driver shutdown right away. We call hci_unregister_dev() on driver shutdown, that means, the hci-core will never ever call our callbacks again except the destruct callback. It also does not access hdev->driver_data so there is no reason to keep that alive. We simply set the destruct cb to NULL to avoid getting called again. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/bpa10x.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 62831603de5e..29cd11d401e1 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -432,17 +432,6 @@ static int bpa10x_send_frame(struct sk_buff *skb) return 0; } -static void bpa10x_destruct(struct hci_dev *hdev) -{ - struct bpa10x_data *data = hdev->driver_data; - - BT_DBG("%s", hdev->name); - - kfree_skb(data->rx_skb[0]); - kfree_skb(data->rx_skb[1]); - kfree(data); -} - static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct bpa10x_data *data; @@ -480,7 +469,6 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * hdev->close = bpa10x_close; hdev->flush = bpa10x_flush; hdev->send = bpa10x_send_frame; - hdev->destruct = bpa10x_destruct; hdev->owner = THIS_MODULE; @@ -512,6 +500,9 @@ static void bpa10x_disconnect(struct usb_interface *intf) hci_unregister_dev(data->hdev); hci_free_dev(data->hdev); + kfree_skb(data->rx_skb[0]); + kfree_skb(data->rx_skb[1]); + kfree(data); } static struct usb_driver bpa10x_driver = { -- GitLab From dabbaab394d17ba1d1b55092d553e6e31a3d0afd Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:18 +0100 Subject: [PATCH 0575/1846] Bluetooth: btsdio: Free driver data on SDIO shutdown Instead of waiting for the hdev object to get freed we now free the private driver-internal data on SDIO shutdown. This allows us to remove the obsolete hci-destruct callback and free our data object right away after calling hci_unregister_dev(). The HCI-core does not call any callbacks after this so we are never called again and can safely exit the module. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btsdio.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index 792e32d29a1d..d38945cc9f05 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -289,15 +289,6 @@ static int btsdio_send_frame(struct sk_buff *skb) return 0; } -static void btsdio_destruct(struct hci_dev *hdev) -{ - struct btsdio_data *data = hdev->driver_data; - - BT_DBG("%s", hdev->name); - - kfree(data); -} - static int btsdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { @@ -345,7 +336,6 @@ static int btsdio_probe(struct sdio_func *func, hdev->close = btsdio_close; hdev->flush = btsdio_flush; hdev->send = btsdio_send_frame; - hdev->destruct = btsdio_destruct; hdev->owner = THIS_MODULE; @@ -378,6 +368,7 @@ static void btsdio_remove(struct sdio_func *func) hci_unregister_dev(hdev); hci_free_dev(hdev); + kfree(data); } static struct sdio_driver btsdio_driver = { -- GitLab From 797fe796c4335b35d95d5326824513befdb5d1e9 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:19 +0100 Subject: [PATCH 0576/1846] Bluetooth: uart-ldisc: Fix memory leak and remove destruct cb We currently leak the hci_uart object if HCI_UART_PROTO_SET is never set because the hci-destruct callback will then never be called. This fix removes the hci-destruct callback and frees the driver internal private hci_uart object directly on tty-close. We call hci_unregister_dev() here so the hci-core will never call our callbacks again (except destruct). Therefore, we can safely free the driver internal data right away and set the destruct callback to NULL. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_ldisc.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 48ad2a7ab080..5ea49df3462b 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -231,15 +231,6 @@ static int hci_uart_send_frame(struct sk_buff *skb) return 0; } -static void hci_uart_destruct(struct hci_dev *hdev) -{ - if (!hdev) - return; - - BT_DBG("%s", hdev->name); - kfree(hdev->driver_data); -} - /* ------ LDISC part ------ */ /* hci_uart_tty_open * @@ -316,6 +307,8 @@ static void hci_uart_tty_close(struct tty_struct *tty) hci_free_dev(hdev); } } + + kfree(hu); } } @@ -397,7 +390,6 @@ static int hci_uart_register_dev(struct hci_uart *hu) hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; - hdev->destruct = hci_uart_destruct; hdev->parent = hu->tty->dev; hdev->owner = THIS_MODULE; -- GitLab From 587ae086f6e44c3f1d313e3efdfc8c2866784bc3 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:20 +0100 Subject: [PATCH 0577/1846] Bluetooth: Remove unused hci-destruct cb The hci-destruct callback is not used by any driver so we can remove it. There is no reason to keep it alive, anymore. Drivers can free their internal data on driver-release and we do not need to provide a public destruct callback. Internally, we still use a destruct callback inside of hci_sysfs.c. This one is used to correctly free our hci_dev data structure if no more users have a reference to it. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 86c74cc563ff..935aca8783c4 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -270,7 +270,6 @@ struct hci_dev { int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); int (*send)(struct sk_buff *skb); - void (*destruct)(struct hci_dev *hdev); void (*notify)(struct hci_dev *hdev, unsigned int evt); int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); }; @@ -595,10 +594,7 @@ static inline void hci_conn_put(struct hci_conn *conn) /* ----- HCI Devices ----- */ static inline void __hci_dev_put(struct hci_dev *d) { - if (atomic_dec_and_test(&d->refcnt)) { - if (d->destruct) - d->destruct(d); - } + atomic_dec(&d->refcnt); } /* -- GitLab From 46e06531a5ae13c66f774d3cb1ad78385618a5a2 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:21 +0100 Subject: [PATCH 0578/1846] Bluetooth: Correctly acquire module ref We provide a device-object to other subsystems and we provide our own release-function. Therefore, the device-object must own a reference to our module, otherwise the release-function may get deleted before the device-object does. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 74b49e330a1d..ec03ee2b301e 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -372,6 +372,7 @@ static void bt_host_release(struct device *dev) { void *data = dev_get_drvdata(dev); kfree(data); + module_put(THIS_MODULE); } static struct device_type bt_host = { @@ -523,6 +524,7 @@ void hci_init_sysfs(struct hci_dev *hdev) dev->type = &bt_host; dev->class = bt_class; + __module_get(THIS_MODULE); dev_set_drvdata(dev, hdev); device_initialize(dev); } -- GitLab From e9b9cfa1575e37cb2dbb5534aeaaa16814228887 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:22 +0100 Subject: [PATCH 0579/1846] Bluetooth: Remove HCI-owner field After unregistering an hci_dev object a bluetooth driver does not have any callbacks in the hci_dev structure left over. Therefore, there is no need to keep a reference to the module. Previously, we needed this to protect the hci-destruct callback. However, this callback is no longer available so we do not need this owner field, anymore. Drivers now call hci_unregister_dev() and they are done with the object. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/bfusb.c | 2 -- drivers/bluetooth/bluecard_cs.c | 2 -- drivers/bluetooth/bpa10x.c | 2 -- drivers/bluetooth/bt3c_cs.c | 2 -- drivers/bluetooth/btmrvl_main.c | 1 - drivers/bluetooth/btsdio.c | 2 -- drivers/bluetooth/btuart_cs.c | 2 -- drivers/bluetooth/btusb.c | 2 -- drivers/bluetooth/btwilink.c | 1 - drivers/bluetooth/dtl1_cs.c | 2 -- drivers/bluetooth/hci_ldisc.c | 2 -- drivers/bluetooth/hci_vhci.c | 2 -- include/net/bluetooth/hci_core.h | 13 ++----------- net/bluetooth/hci_core.c | 3 +-- 14 files changed, 3 insertions(+), 35 deletions(-) diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index e99ce89e1cad..c7d6ff0ffcf1 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -705,8 +705,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i hdev->send = bfusb_send_frame; hdev->ioctl = bfusb_ioctl; - hdev->owner = THIS_MODULE; - if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 5cb325a13745..6b1261f9deb0 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -738,8 +738,6 @@ static int bluecard_open(bluecard_info_t *info) hdev->send = bluecard_hci_send_frame; hdev->ioctl = bluecard_hci_ioctl; - hdev->owner = THIS_MODULE; - id = inb(iobase + 0x30); if ((id & 0x0f) == 0x02) diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 29cd11d401e1..9d635148104c 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -470,8 +470,6 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * hdev->flush = bpa10x_flush; hdev->send = bpa10x_send_frame; - hdev->owner = THIS_MODULE; - set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); err = hci_register_dev(hdev); diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index e74334dfc776..0e304cb4bdea 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -584,8 +584,6 @@ static int bt3c_open(bt3c_info_t *info) hdev->send = bt3c_hci_send_frame; hdev->ioctl = bt3c_hci_ioctl; - hdev->owner = THIS_MODULE; - /* Load firmware */ err = request_firmware(&firmware, "BT3CPCC.bin", &info->p_dev->dev); if (err < 0) { diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index 995cf43f4bd2..66b58fd09fbe 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c @@ -550,7 +550,6 @@ int btmrvl_register_hdev(struct btmrvl_private *priv) hdev->flush = btmrvl_flush; hdev->send = btmrvl_send_frame; hdev->ioctl = btmrvl_ioctl; - hdev->owner = THIS_MODULE; btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ); diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index d38945cc9f05..2d6e4ed1637f 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -337,8 +337,6 @@ static int btsdio_probe(struct sdio_func *func, hdev->flush = btsdio_flush; hdev->send = btsdio_send_frame; - hdev->owner = THIS_MODULE; - err = hci_register_dev(hdev); if (err < 0) { hci_free_dev(hdev); diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 84e02f1a45b9..80ad2b9b352e 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -502,8 +502,6 @@ static int btuart_open(btuart_info_t *info) hdev->send = btuart_hci_send_frame; hdev->ioctl = btuart_hci_ioctl; - hdev->owner = THIS_MODULE; - spin_lock_irqsave(&(info->lock), flags); /* Reset UART */ diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 44b5e736ddc3..a36888a9c205 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -997,8 +997,6 @@ static int btusb_probe(struct usb_interface *intf, hdev->send = btusb_send_frame; hdev->notify = btusb_notify; - hdev->owner = THIS_MODULE; - /* Interface numbers are hardcoded in the specification */ data->isoc = usb_ifnum_to_if(data->udev, 1); diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c index da9cf6a6e8ac..b81b32e4fa12 100644 --- a/drivers/bluetooth/btwilink.c +++ b/drivers/bluetooth/btwilink.c @@ -317,7 +317,6 @@ static int bt_ti_probe(struct platform_device *pdev) hdev->close = ti_st_close; hdev->flush = NULL; hdev->send = ti_st_send_frame; - hdev->owner = THIS_MODULE; err = hci_register_dev(hdev); if (err < 0) { diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index aae40caaa188..295cf1b4a052 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -484,8 +484,6 @@ static int dtl1_open(dtl1_info_t *info) hdev->send = dtl1_hci_send_frame; hdev->ioctl = dtl1_hci_ioctl; - hdev->owner = THIS_MODULE; - spin_lock_irqsave(&(info->lock), flags); /* Reset UART */ diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 5ea49df3462b..459ff0ba5a42 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -392,8 +392,6 @@ static int hci_uart_register_dev(struct hci_uart *hu) hdev->send = hci_uart_send_frame; hdev->parent = hu->tty->dev; - hdev->owner = THIS_MODULE; - if (!reset) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 44a801292d62..5f305c131a0d 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -244,8 +244,6 @@ static int vhci_open(struct inode *inode, struct file *file) hdev->flush = vhci_flush; hdev->send = vhci_send_frame; - hdev->owner = THIS_MODULE; - if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); kfree(data); diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 935aca8783c4..99984688ccdd 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -262,8 +262,6 @@ struct hci_dev { struct rfkill *rfkill; - struct module *owner; - unsigned long dev_flags; int (*open)(struct hci_dev *hdev); @@ -601,11 +599,7 @@ static inline void __hci_dev_put(struct hci_dev *d) * hci_dev_put and hci_dev_hold are macros to avoid dragging all the * overhead of all the modular infrastructure into this header. */ -#define hci_dev_put(d) \ -do { \ - __hci_dev_put(d); \ - module_put(d->owner); \ -} while (0) +#define hci_dev_put(d) __hci_dev_put(d) static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) { @@ -613,10 +607,7 @@ static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) return d; } -#define hci_dev_hold(d) \ -({ \ - try_module_get(d->owner) ? __hci_dev_hold(d) : NULL; \ -}) +#define hci_dev_hold(d) __hci_dev_hold(d) #define hci_dev_lock(d) mutex_lock(&d->lock) #define hci_dev_unlock(d) mutex_unlock(&d->lock) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f23e32a645c8..58392a6b48b5 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1548,8 +1548,7 @@ int hci_register_dev(struct hci_dev *hdev) struct list_head *head = &hci_dev_list, *p; int i, id, error; - BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name, - hdev->bus, hdev->owner); + BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); if (!hdev->open || !hdev->close) return -EINVAL; -- GitLab From 4c724c7135ca2b407bd318b4267456a7b5723825 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:23 +0100 Subject: [PATCH 0580/1846] Bluetooth: Correctly take hci_dev->dev refcount The hci_dev->dev device structure has an internal refcount. This refcount is used to protect the whole hci_dev object. However, we currently do not use it. Therefore, if someone calls hci_free_dev() we currently immediately destroy the hci_dev object because we never took the device refcount. This even happens if the hci_dev->refcnt is not 0. In fact, the hci_dev->refcnt is totally useless in its current state. Therefore, we simply remove hci_dev->refcnt and instead use hci_dev->dev refcnt. This fixes all the symptoms and also correctly integrates the device structure into our bluetooth bus system. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 5 ++--- net/bluetooth/hci_core.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 99984688ccdd..4ccf3749a9a7 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -129,7 +129,6 @@ struct adv_entry { struct hci_dev { struct list_head list; struct mutex lock; - atomic_t refcnt; char name[8]; unsigned long flags; @@ -592,7 +591,7 @@ static inline void hci_conn_put(struct hci_conn *conn) /* ----- HCI Devices ----- */ static inline void __hci_dev_put(struct hci_dev *d) { - atomic_dec(&d->refcnt); + put_device(&d->dev); } /* @@ -603,7 +602,7 @@ static inline void __hci_dev_put(struct hci_dev *d) static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) { - atomic_inc(&d->refcnt); + get_device(&d->dev); return d; } diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 58392a6b48b5..f5fba65a9e59 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1571,7 +1571,6 @@ int hci_register_dev(struct hci_dev *hdev) hdev->id = id; list_add_tail(&hdev->list, head); - atomic_set(&hdev->refcnt, 1); mutex_init(&hdev->lock); hdev->flags = 0; @@ -1655,6 +1654,7 @@ int hci_register_dev(struct hci_dev *hdev) schedule_work(&hdev->power_on); hci_notify(hdev, HCI_DEV_REG); + __hci_dev_hold(hdev); return id; -- GitLab From dc946bd86f725c42c3ab1caf9966d29f5b364fea Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 7 Jan 2012 15:47:24 +0100 Subject: [PATCH 0581/1846] Bluetooth: Remove __hci_dev_put/hold Since we remove the owner field of hci_dev hci_dev_put and __hci_dev_put do the same so we can merge them into one function. Same for hci_dev_hold and __hci_dev_hold. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btusb.c | 4 ++-- include/net/bluetooth/hci_core.h | 12 ++---------- net/bluetooth/hci_core.c | 4 ++-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index a36888a9c205..d7664ffc5183 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1079,7 +1079,7 @@ static void btusb_disconnect(struct usb_interface *intf) hdev = data->hdev; - __hci_dev_hold(hdev); + hci_dev_hold(hdev); usb_set_intfdata(data->intf, NULL); @@ -1093,7 +1093,7 @@ static void btusb_disconnect(struct usb_interface *intf) else if (data->isoc) usb_driver_release_interface(&btusb_driver, data->isoc); - __hci_dev_put(hdev); + hci_dev_put(hdev); hci_free_dev(hdev); kfree(data); diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4ccf3749a9a7..f9c88251fe1a 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -589,25 +589,17 @@ static inline void hci_conn_put(struct hci_conn *conn) } /* ----- HCI Devices ----- */ -static inline void __hci_dev_put(struct hci_dev *d) +static inline void hci_dev_put(struct hci_dev *d) { put_device(&d->dev); } -/* - * hci_dev_put and hci_dev_hold are macros to avoid dragging all the - * overhead of all the modular infrastructure into this header. - */ -#define hci_dev_put(d) __hci_dev_put(d) - -static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) +static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) { get_device(&d->dev); return d; } -#define hci_dev_hold(d) __hci_dev_hold(d) - #define hci_dev_lock(d) mutex_lock(&d->lock) #define hci_dev_unlock(d) mutex_unlock(&d->lock) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f5fba65a9e59..a3113f8c1f93 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1654,7 +1654,7 @@ int hci_register_dev(struct hci_dev *hdev) schedule_work(&hdev->power_on); hci_notify(hdev, HCI_DEV_REG); - __hci_dev_hold(hdev); + hci_dev_hold(hdev); return id; @@ -1717,7 +1717,7 @@ void hci_unregister_dev(struct hci_dev *hdev) hci_adv_entries_clear(hdev); hci_dev_unlock(hdev); - __hci_dev_put(hdev); + hci_dev_put(hdev); } EXPORT_SYMBOL(hci_unregister_dev); -- GitLab From cbe8fed490601862310f035b9973509b8634998e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 8 Jan 2012 22:51:16 +0200 Subject: [PATCH 0582/1846] Bluetooth: Remove bogus inline declaration from l2cap_chan_connect As reported by Dan Carpenter this function causes a Sparse warning and shouldn't be declared inline: include/net/bluetooth/l2cap.h:837:30 error: marked inline, but without a definition" Reported-by: Dan Carpenter Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/l2cap.h | 2 +- net/bluetooth/l2cap_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index ab8f7d83079a..26486e182f55 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -834,7 +834,7 @@ int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); struct l2cap_chan *l2cap_chan_create(struct sock *sk); void l2cap_chan_close(struct l2cap_chan *chan, int reason); void l2cap_chan_destroy(struct l2cap_chan *chan); -inline int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, +int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst); int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u32 priority); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index e35ff4cd33ce..dcccae04ae08 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1120,7 +1120,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr return c1; } -inline int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst) +int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst) { struct sock *sk = chan->sk; bdaddr_t *src = &bt_sk(sk)->src; -- GitLab From a8b2d5c2cfe1c6398e3fdd4372c4ae7f74fb4493 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 8 Jan 2012 23:11:15 +0200 Subject: [PATCH 0583/1846] Bluetooth: Move mgmt related flags from hdev->flags to hdev->dev_flags There's no point in exposing these to user-space (which is what happens to everything in hdev->flags) so move them to dev_flags instead. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 16 +++++++------- net/bluetooth/hci_core.c | 30 ++++++++++++------------- net/bluetooth/hci_event.c | 44 ++++++++++++++++++------------------- net/bluetooth/mgmt.c | 30 ++++++++++++------------- net/bluetooth/smp.c | 2 +- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4202c9cb497e..3ee39ed9c29b 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -77,14 +77,6 @@ enum { HCI_RAW, - HCI_SETUP, - HCI_AUTO_OFF, - HCI_MGMT, - HCI_PAIRABLE, - HCI_SERVICE_CACHE, - HCI_LINK_KEYS, - HCI_DEBUG_KEYS, - HCI_RESET, }; @@ -93,6 +85,14 @@ enum { * states from the controller. */ enum { + HCI_SETUP, + HCI_AUTO_OFF, + HCI_MGMT, + HCI_PAIRABLE, + HCI_SERVICE_CACHE, + HCI_LINK_KEYS, + HCI_DEBUG_KEYS, + HCI_LE_SCAN, }; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a3113f8c1f93..3acb23cf6ee4 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -668,7 +668,7 @@ int hci_dev_open(__u16 dev) hci_dev_hold(hdev); set_bit(HCI_UP, &hdev->flags); hci_notify(hdev, HCI_DEV_UP); - if (!test_bit(HCI_SETUP, &hdev->flags)) { + if (!test_bit(HCI_SETUP, &hdev->dev_flags)) { hci_dev_lock(hdev); mgmt_powered(hdev, 1); hci_dev_unlock(hdev); @@ -722,10 +722,10 @@ static int hci_dev_do_close(struct hci_dev *hdev) hdev->discov_timeout = 0; } - if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) cancel_delayed_work(&hdev->power_off); - if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->flags)) + if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) cancel_delayed_work(&hdev->service_cache); hci_dev_lock(hdev); @@ -947,11 +947,11 @@ int hci_get_dev_list(void __user *arg) read_lock(&hci_dev_list_lock); list_for_each_entry(hdev, &hci_dev_list, list) { - if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) cancel_delayed_work(&hdev->power_off); - if (!test_bit(HCI_MGMT, &hdev->flags)) - set_bit(HCI_PAIRABLE, &hdev->flags); + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) + set_bit(HCI_PAIRABLE, &hdev->dev_flags); (dr + n)->dev_id = hdev->id; (dr + n)->dev_opt = hdev->flags; @@ -983,11 +983,11 @@ int hci_get_dev_info(void __user *arg) if (!hdev) return -ENODEV; - if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) cancel_delayed_work_sync(&hdev->power_off); - if (!test_bit(HCI_MGMT, &hdev->flags)) - set_bit(HCI_PAIRABLE, &hdev->flags); + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) + set_bit(HCI_PAIRABLE, &hdev->dev_flags); strcpy(di.name, hdev->name); di.bdaddr = hdev->bdaddr; @@ -1067,11 +1067,11 @@ static void hci_power_on(struct work_struct *work) if (hci_dev_open(hdev->id) < 0) return; - if (test_bit(HCI_AUTO_OFF, &hdev->flags)) + if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) schedule_delayed_work(&hdev->power_off, msecs_to_jiffies(AUTO_OFF_TIMEOUT)); - if (test_and_clear_bit(HCI_SETUP, &hdev->flags)) + if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) mgmt_index_added(hdev); } @@ -1082,7 +1082,7 @@ static void hci_power_off(struct work_struct *work) BT_DBG("%s", hdev->name); - clear_bit(HCI_AUTO_OFF, &hdev->flags); + clear_bit(HCI_AUTO_OFF, &hdev->dev_flags); hci_dev_close(hdev->id); } @@ -1649,8 +1649,8 @@ int hci_register_dev(struct hci_dev *hdev) } } - set_bit(HCI_AUTO_OFF, &hdev->flags); - set_bit(HCI_SETUP, &hdev->flags); + set_bit(HCI_AUTO_OFF, &hdev->dev_flags); + set_bit(HCI_SETUP, &hdev->dev_flags); schedule_work(&hdev->power_on); hci_notify(hdev, HCI_DEV_REG); @@ -1686,7 +1686,7 @@ void hci_unregister_dev(struct hci_dev *hdev) kfree_skb(hdev->reassembly[i]); if (!test_bit(HCI_INIT, &hdev->flags) && - !test_bit(HCI_SETUP, &hdev->flags)) { + !test_bit(HCI_SETUP, &hdev->dev_flags)) { hci_dev_lock(hdev); mgmt_index_removed(hdev); hci_dev_unlock(hdev); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0466ed9c1b47..2d39ede1f202 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -211,7 +211,7 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_set_local_name_complete(hdev, sent, status); if (status == 0) @@ -890,7 +890,7 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); if (rp->status != 0) @@ -916,7 +916,7 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, rp->status); @@ -951,7 +951,7 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, rp->status); @@ -967,7 +967,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, rp->status); @@ -982,7 +982,7 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, rp->status); @@ -998,7 +998,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, rp->status); @@ -1110,7 +1110,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) hci_req_complete(hdev, HCI_OP_INQUIRY, status); hci_conn_check_pending(hdev); hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_start_discovery_failed(hdev, status); hci_dev_unlock(hdev); return; @@ -1333,7 +1333,7 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) hci_resolve_next_name(hdev, &cp->bdaddr); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); @@ -1555,7 +1555,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) return; - if (!test_bit(HCI_MGMT, &hdev->flags)) + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) return; hci_dev_lock(hdev); @@ -1876,7 +1876,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) { + if (test_bit(HCI_MGMT, &hdev->dev_flags)) { if (ev->status == 0) mgmt_remote_name(hdev, &ev->bdaddr, ev->name); @@ -2505,10 +2505,10 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff hci_conn_put(conn); } - if (!test_bit(HCI_PAIRABLE, &hdev->flags)) + if (!test_bit(HCI_PAIRABLE, &hdev->dev_flags)) hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(ev->bdaddr), &ev->bdaddr); - else if (test_bit(HCI_MGMT, &hdev->flags)) { + else if (test_bit(HCI_MGMT, &hdev->dev_flags)) { u8 secure; if (conn->pending_sec_level == BT_SECURITY_HIGH) @@ -2532,7 +2532,7 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff BT_DBG("%s", hdev->name); - if (!test_bit(HCI_LINK_KEYS, &hdev->flags)) + if (!test_bit(HCI_LINK_KEYS, &hdev->dev_flags)) return; hci_dev_lock(hdev); @@ -2547,7 +2547,7 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff BT_DBG("%s found key type %u for %s", hdev->name, key->type, batostr(&ev->bdaddr)); - if (!test_bit(HCI_DEBUG_KEYS, &hdev->flags) && + if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) && key->type == HCI_LK_DEBUG_COMBINATION) { BT_DBG("%s ignoring debug key", hdev->name); goto not_found; @@ -2609,7 +2609,7 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff hci_conn_put(conn); } - if (test_bit(HCI_LINK_KEYS, &hdev->flags)) + if (test_bit(HCI_LINK_KEYS, &hdev->dev_flags)) hci_add_link_key(hdev, conn, 1, &ev->bdaddr, ev->link_key, ev->key_type, pin_len); @@ -2890,7 +2890,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x01; - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) name_known = eir_has_complete_name(info->data, sizeof(info->data)); else @@ -2939,10 +2939,10 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff hci_conn_hold(conn); - if (!test_bit(HCI_MGMT, &hdev->flags)) + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) goto unlock; - if (test_bit(HCI_PAIRABLE, &hdev->flags) || + if (test_bit(HCI_PAIRABLE, &hdev->dev_flags) || (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { struct hci_cp_io_capability_reply cp; @@ -3005,7 +3005,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, hci_dev_lock(hdev); - if (!test_bit(HCI_MGMT, &hdev->flags)) + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) goto unlock; conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); @@ -3071,7 +3071,7 @@ static inline void hci_user_passkey_request_evt(struct hci_dev *hdev, hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->flags)) + if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_passkey_request(hdev, &ev->bdaddr); hci_dev_unlock(hdev); @@ -3130,7 +3130,7 @@ static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev, hci_dev_lock(hdev); - if (!test_bit(HCI_MGMT, &hdev->flags)) + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) goto unlock; data = hci_find_remote_oob_data(hdev, &ev->bdaddr); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 295cfc8a3076..3de1e909471a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -226,10 +226,10 @@ static int read_index_list(struct sock *sk) i = 0; list_for_each_entry(d, &hci_dev_list, list) { - if (test_and_clear_bit(HCI_AUTO_OFF, &d->flags)) + if (test_and_clear_bit(HCI_AUTO_OFF, &d->dev_flags)) cancel_delayed_work(&d->power_off); - if (test_bit(HCI_SETUP, &d->flags)) + if (test_bit(HCI_SETUP, &d->dev_flags)) continue; put_unaligned_le16(d->id, &rp->index[i++]); @@ -285,7 +285,7 @@ static u32 get_current_settings(struct hci_dev *hdev) if (test_bit(HCI_ISCAN, &hdev->flags)) settings |= MGMT_SETTING_DISCOVERABLE; - if (test_bit(HCI_PAIRABLE, &hdev->flags)) + if (test_bit(HCI_PAIRABLE, &hdev->dev_flags)) settings |= MGMT_SETTING_PAIRABLE; if (!(hdev->features[4] & LMP_NO_BREDR)) @@ -419,7 +419,7 @@ static int update_eir(struct hci_dev *hdev) if (hdev->ssp_mode == 0) return 0; - if (test_bit(HCI_SERVICE_CACHE, &hdev->flags)) + if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) return 0; memset(&cp, 0, sizeof(cp)); @@ -451,7 +451,7 @@ static int update_class(struct hci_dev *hdev) BT_DBG("%s", hdev->name); - if (test_bit(HCI_SERVICE_CACHE, &hdev->flags)) + if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) return 0; cod[0] = hdev->minor_class; @@ -469,7 +469,7 @@ static void service_cache_off(struct work_struct *work) struct hci_dev *hdev = container_of(work, struct hci_dev, service_cache.work); - if (!test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->flags)) + if (!test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) return; hci_dev_lock(hdev); @@ -482,10 +482,10 @@ static void service_cache_off(struct work_struct *work) static void mgmt_init_hdev(struct hci_dev *hdev) { - if (!test_and_set_bit(HCI_MGMT, &hdev->flags)) + if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); - if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->flags)) + if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) schedule_delayed_work(&hdev->service_cache, msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); } @@ -502,7 +502,7 @@ static int read_controller_info(struct sock *sk, u16 index) return cmd_status(sk, index, MGMT_OP_READ_INFO, MGMT_STATUS_INVALID_PARAMS); - if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) cancel_delayed_work_sync(&hdev->power_off); hci_dev_lock(hdev); @@ -851,9 +851,9 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock(hdev); if (cp->val) - set_bit(HCI_PAIRABLE, &hdev->flags); + set_bit(HCI_PAIRABLE, &hdev->dev_flags); else - clear_bit(HCI_PAIRABLE, &hdev->flags); + clear_bit(HCI_PAIRABLE, &hdev->dev_flags); err = send_settings_rsp(sk, MGMT_OP_SET_PAIRABLE, hdev); if (err < 0) @@ -1008,7 +1008,7 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data, hdev->major_class = cp->major; hdev->minor_class = cp->minor; - if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->flags)) { + if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) { hci_dev_unlock(hdev); cancel_delayed_work_sync(&hdev->service_cache); hci_dev_lock(hdev); @@ -1063,12 +1063,12 @@ static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, hci_link_keys_clear(hdev); - set_bit(HCI_LINK_KEYS, &hdev->flags); + set_bit(HCI_LINK_KEYS, &hdev->dev_flags); if (cp->debug_keys) - set_bit(HCI_DEBUG_KEYS, &hdev->flags); + set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags); else - clear_bit(HCI_DEBUG_KEYS, &hdev->flags); + clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags); for (i = 0; i < key_count; i++) { struct mgmt_link_key_info *key = &cp->keys[i]; diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 32c47de30344..65a90242d990 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -217,7 +217,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, { u8 dist_keys = 0; - if (test_bit(HCI_PAIRABLE, &conn->hcon->hdev->flags)) { + if (test_bit(HCI_PAIRABLE, &conn->hcon->hdev->dev_flags)) { dist_keys = SMP_DIST_ENC_KEY; authreq |= SMP_AUTH_BONDING; } else { -- GitLab From 44b5f7d0cb1939497a0858d9f43d89f039f85887 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 8 Jan 2012 23:39:40 +0200 Subject: [PATCH 0584/1846] Bluetooth: Fix resetting HCI_MGMT flag The HCI_MGMT flag should not be cleared when resetting a HCI device. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2d39ede1f202..f3dafae6e1db 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -195,7 +195,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_RESET, status); - hdev->dev_flags = 0; + /* Reset all flags, except persistent ones like HCI_MGMT */ + hdev->dev_flags &= BIT(HCI_MGMT); } static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From a3d4e20a88f54571d794cca365f232bfed0669bb Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 9 Jan 2012 00:53:02 +0200 Subject: [PATCH 0585/1846] Bluetooth: Sort to-be-resolved devices by RSSI during discovery This patch makes sure that devices with stronger signal (RSSI closer to 0) are sorted first in the resolve list and will therefore get their names resolved first during device discovery. Since it's more likely that the device the user is trying to discover has a strong signal due to its proximity this ensures that the user gets the "device found" event for it more quickly. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 28 +++++++++++++++++++++++++++- net/bluetooth/mgmt.c | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f9c88251fe1a..59e3541e9fc7 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -395,6 +395,8 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, bdaddr_t *bdaddr, int state); +void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, + struct inquiry_entry *ie); bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3acb23cf6ee4..9963121028e4 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -457,6 +457,25 @@ struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, return NULL; } +void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, + struct inquiry_entry *ie) +{ + struct discovery_state *cache = &hdev->discovery; + struct list_head *pos = &cache->resolve; + struct inquiry_entry *p; + + list_del(&ie->list); + + list_for_each_entry(p, &cache->resolve, list) { + if (p->name_state != NAME_PENDING && + abs(p->data.rssi) >= abs(ie->data.rssi)) + break; + pos = &p->list; + } + + list_add(&ie->list, pos); +} + bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, bool name_known) { @@ -466,8 +485,15 @@ bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr)); ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr); - if (ie) + if (ie) { + if (ie->name_state == NAME_NEEDED && + data->rssi != ie->data.rssi) { + ie->data.rssi = data->rssi; + hci_inquiry_cache_update_resolve(hdev, ie); + } + goto update; + } /* Entry not in the cache. Add new one. */ ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3de1e909471a..2dae2e8f6234 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2043,7 +2043,7 @@ static int confirm_name(struct sock *sk, u16 index, unsigned char *data, list_del(&e->list); } else { e->name_state = NAME_NEEDED; - list_move(&e->list, &hdev->discovery.resolve); + hci_inquiry_cache_update_resolve(hdev, e); } err = 0; -- GitLab From 8b281b9c7820b054d15cf471c418fd884cbbec78 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 10 Jan 2012 18:33:50 -0200 Subject: [PATCH 0586/1846] Bluetooth: Fix 'enable_hs' type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following build warning: CC [M] net/bluetooth/hci_core.o net/bluetooth/hci_core.c: In function ‘__check_enable_hs’: net/bluetooth/hci_core.c:2587: warning: return from incompatible pointer type module_param in hci_core.c passes 'enable_hs' as bool format, so fix this variable definition type. Signed-off-by: Fabio Estevam Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 2 +- net/bluetooth/hci_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 3ee39ed9c29b..84993073c2f1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1415,6 +1415,6 @@ struct hci_inquiry_req { }; #define IREQ_CACHE_FLUSH 0x0001 -extern int enable_hs; +extern bool enable_hs; #endif /* __HCI_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9963121028e4..91166dbbe35c 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -55,7 +55,7 @@ #define AUTO_OFF_TIMEOUT 2000 -int enable_hs; +bool enable_hs; static void hci_rx_work(struct work_struct *work); static void hci_cmd_work(struct work_struct *work); -- GitLab From 75b93b59ad625d734b1c7d7e05bf6b9898c8c28f Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 11 Jan 2012 10:59:45 +0100 Subject: [PATCH 0587/1846] Bluetooth: Make l2cap_clear_timer return if timer was running or not This is usefull when need to make action after timer was cleared depending on if it was running or not. Signed-off-by: Szymon Janc Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 26486e182f55..238daf84184c 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -616,11 +616,16 @@ static inline void l2cap_set_timer(struct l2cap_chan *chan, schedule_delayed_work(work, timeout); } -static inline void l2cap_clear_timer(struct l2cap_chan *chan, +static inline bool l2cap_clear_timer(struct l2cap_chan *chan, struct delayed_work *work) { - if (__cancel_delayed_work(work)) + bool ret; + + ret = __cancel_delayed_work(work); + if (ret) l2cap_chan_put(chan); + + return ret; } #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) -- GitLab From 0ef3ef0f676e3c7aaab4a936635f503770fd38b2 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 11 Jan 2012 10:59:46 +0100 Subject: [PATCH 0588/1846] Bluetooth: Set P-bit for SREJ frame only if there are I-frames to ack SREJ frame with P-bit set acknowledges I-frames numbered up to (ReqSeq - 1). With this patch P-bit in SREJ is set only when there are some I-frames to ack. This fixes ambiguous situation when lost of I-frame with TxSeq=0 would result in sending SREJ acking all previous I-frames. Consider following scenario: TxWindow=3 HostA: sent I-frame TxSeq=0 HostA: sent I-frame TxSeq=1 HostA: sent I-frame TxSeq=2 HostB: missed I-frame TxSeq=0 HostB: received I-frame TxSeq=1 HostB: sent SREJ ReqSeq=0 Pbit=1 HostA: received SREJ ReqSeq=0 Pbit=1 <- All I-frames acked or not? ... Signed-off-by: Szymon Janc Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index dcccae04ae08..0d5bb45e7be7 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3927,15 +3927,15 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_cont __skb_queue_head_init(&chan->srej_q); l2cap_add_to_srej_queue(chan, skb, tx_seq, sar); - set_bit(CONN_SEND_PBIT, &chan->conn_state); + /* Set P-bit only if there are some I-frames to ack. */ + if (__clear_ack_timer(chan)) + set_bit(CONN_SEND_PBIT, &chan->conn_state); err = l2cap_send_srejframe(chan, tx_seq); if (err < 0) { l2cap_send_disconn_req(chan->conn, chan, -err); return err; } - - __clear_ack_timer(chan); } return 0; -- GitLab From b17e73bb4269f47e1ea2d64a834f1cfc8644fabb Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 11 Jan 2012 10:59:47 +0100 Subject: [PATCH 0589/1846] Bluetooth: Clear ack_timer when sending ack ack_timer should be cleared when sending ACK to avoid acking I-frames twice. This commit introduces helper function (only send ack, not clearing timer) which is used by l2cap_send_ack and l2cap_ack_timeout. This is to avoid clearing ack timer in timer function. Signed-off-by: Szymon Janc Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0d5bb45e7be7..3b9e2813f1fc 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1478,7 +1478,7 @@ static int l2cap_retransmit_frames(struct l2cap_chan *chan) return ret; } -static void l2cap_send_ack(struct l2cap_chan *chan) +static void __l2cap_send_ack(struct l2cap_chan *chan) { u32 control = 0; @@ -1498,6 +1498,12 @@ static void l2cap_send_ack(struct l2cap_chan *chan) l2cap_send_sframe(chan, control); } +static void l2cap_send_ack(struct l2cap_chan *chan) +{ + __clear_ack_timer(chan); + __l2cap_send_ack(chan); +} + static void l2cap_send_srejtail(struct l2cap_chan *chan) { struct srej_list *tail; @@ -1988,7 +1994,7 @@ static void l2cap_ack_timeout(struct work_struct *work) BT_DBG("chan %p", chan); lock_sock(chan->sk); - l2cap_send_ack(chan); + __l2cap_send_ack(chan); release_sock(chan->sk); } -- GitLab From 77f918bc7babb8473933ca0a6deefc64fe24b06c Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 11 Jan 2012 10:59:48 +0100 Subject: [PATCH 0590/1846] Bluetooth: Don't send RNR immediately when entering local busy There is no need to send RNR immediately when entring local busy. Also upper layer might clear local busy condition before ack timer expires saving few cycles for sending RNR. This also prevents sending two RNRs in some cases where sending one would be enough i.e received N I-frame can trigger local busy (sending RNR acking up to N-1 I-frame) and later sending ack (RNR acking up to N I-frame). This was affecting TC_ERM_BV_07_C and TC_ERM_BV_22_C with some non default channel parameters (tx window and receiving buffer sizes). Signed-off-by: Szymon Janc Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 3b9e2813f1fc..778ceb2b8402 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3719,19 +3719,11 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u3 static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) { - u32 control; - BT_DBG("chan %p, Enter local busy", chan); set_bit(CONN_LOCAL_BUSY, &chan->conn_state); - control = __set_reqseq(chan, chan->buffer_seq); - control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); - l2cap_send_sframe(chan, control); - - set_bit(CONN_RNR_SENT, &chan->conn_state); - - __clear_ack_timer(chan); + __set_ack_timer(chan); } static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan) @@ -3871,8 +3863,11 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_cont goto drop; } - if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) + if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { + if (!test_bit(CONN_RNR_SENT, &chan->conn_state)) + l2cap_send_ack(chan); goto drop; + } if (tx_seq == chan->expected_tx_seq) goto expected; -- GitLab From 09bfb2ee52a66845bbefad0b6eaeae1b5adea949 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 11 Jan 2012 10:59:49 +0100 Subject: [PATCH 0591/1846] Bluetooth: Drop L2CAP chan reference if ERTM ack_timer fired Reference counter was incremented when starting ack timer but decremented only when clearing timer, not when timer fired. Signed-off-by: Szymon Janc Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 778ceb2b8402..6773453927ef 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1996,6 +1996,8 @@ static void l2cap_ack_timeout(struct work_struct *work) lock_sock(chan->sk); __l2cap_send_ack(chan); release_sock(chan->sk); + + l2cap_chan_put(chan); } static inline void l2cap_ertm_init(struct l2cap_chan *chan) -- GitLab From 5ef8cb9e5b5012a373f48e1e336339864b4c1303 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 13 Jan 2012 17:21:42 +0200 Subject: [PATCH 0592/1846] Bluetooth: Use chan instead of sk Remove unneeded conversion from sk to chan. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 6773453927ef..22319377eb20 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -73,7 +73,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); -static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb); +static int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb); /* ---- L2CAP channels ---- */ @@ -4138,9 +4138,8 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u32 rx_cont return 0; } -static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) +int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) { - struct l2cap_chan *chan = l2cap_pi(sk)->chan; u32 control; u16 req_seq; int len, next_tx_seq_offset, req_seq_offset; @@ -4241,7 +4240,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk break; case L2CAP_MODE_ERTM: - l2cap_ertm_data_rcv(sk, skb); + l2cap_ertm_data_rcv(chan, skb); goto done; -- GitLab From 0952a57a25ee9854e1bf21e333b9fd3de211760e Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 13 Jan 2012 17:21:43 +0200 Subject: [PATCH 0593/1846] Bluetooth: Change sk to l2cap_chan Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 22319377eb20..a66e5ec9adef 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1518,9 +1518,10 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) l2cap_send_sframe(chan, control); } -static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb) +static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, struct msghdr *msg, int len, int count, struct sk_buff *skb) { - struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn; + struct sock *sk = chan->sk; + struct l2cap_conn *conn = chan->conn; struct sk_buff **frag; int err, sent = 0; @@ -1578,7 +1579,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); put_unaligned_le16(chan->psm, skb_put(skb, 2)); - err = l2cap_skbuff_fromiovec(sk, msg, len, count, skb); + err = l2cap_skbuff_fromiovec(chan, msg, len, count, skb); if (unlikely(err < 0)) { kfree_skb(skb); return ERR_PTR(err); @@ -1611,7 +1612,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, lh->cid = cpu_to_le16(chan->dcid); lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); - err = l2cap_skbuff_fromiovec(sk, msg, len, count, skb); + err = l2cap_skbuff_fromiovec(chan, msg, len, count, skb); if (unlikely(err < 0)) { kfree_skb(skb); return ERR_PTR(err); @@ -1661,7 +1662,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, if (sdulen) put_unaligned_le16(sdulen, skb_put(skb, L2CAP_SDULEN_SIZE)); - err = l2cap_skbuff_fromiovec(sk, msg, len, count, skb); + err = l2cap_skbuff_fromiovec(chan, msg, len, count, skb); if (unlikely(err < 0)) { kfree_skb(skb); return ERR_PTR(err); -- GitLab From 7d262f86f6b73efb500be9d9242ef0673221493d Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Tue, 10 Jan 2012 18:20:49 -0300 Subject: [PATCH 0594/1846] Bluetooth: Add 'eir_len' param to mgmt_device_found() This patch adds a new parameter to mgmt_device_found() to inform the length of 'eir' pointer. EIR data from LE advertising report event doesn't have a fixed length as EIR data from extended inquiry result event does. We needed to change mgmt_device_found() so it copies 'eir_len' bytes instead of HCI_MAX_EIR_LENGTH. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_event.c | 10 ++++++---- net/bluetooth/mgmt.c | 7 +++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 59e3541e9fc7..393acd071cb6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -925,7 +925,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 *eir); + u8 cfm_name, u8 *eir, u8 eir_len); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index f3dafae6e1db..3323dc6c9868 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1608,7 +1608,8 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * name_known = hci_inquiry_cache_update(hdev, &data, false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, 0, !name_known, NULL); + info->dev_class, 0, !name_known, + NULL, 0); } hci_dev_unlock(hdev); @@ -2705,7 +2706,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - !name_known, NULL); + !name_known, NULL, 0); } } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); @@ -2723,7 +2724,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct false); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - !name_known, NULL); + !name_known, NULL, 0); } } @@ -2900,7 +2901,8 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct name_known = hci_inquiry_cache_update(hdev, &data, name_known); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - !name_known, info->data); + !name_known, info->data, + sizeof(info->data)); } hci_dev_unlock(hdev); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 2dae2e8f6234..e7bbad80fa7e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2780,10 +2780,13 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 *eir) + u8 cfm_name, u8 *eir, u8 eir_len) { struct mgmt_ev_device_found ev; + if (eir_len > sizeof(ev.eir)) + return -EINVAL; + memset(&ev, 0, sizeof(ev)); bacpy(&ev.addr.bdaddr, bdaddr); @@ -2792,7 +2795,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, ev.confirm_name = cfm_name; if (eir) - memcpy(ev.eir, eir, sizeof(ev.eir)); + memcpy(ev.eir, eir, eir_len); if (dev_class) memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); -- GitLab From 3c9e919511f87f10491628c6b44bc4675822f307 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Tue, 10 Jan 2012 18:20:50 -0300 Subject: [PATCH 0595/1846] Bluetooth: Report LE devices Devices found during LE scan should be reported to userspace through mgmt_device_found events. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 3323dc6c9868..42d63522270f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3208,6 +3208,7 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev, { u8 num_reports = skb->data[0]; void *ptr = &skb->data[1]; + s8 rssi; hci_dev_lock(hdev); @@ -3216,6 +3217,10 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev, hci_add_adv_entry(hdev, ev); + rssi = ev->data[ev->length]; + mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type, + NULL, rssi, 0, ev->data, ev->length); + ptr += sizeof(*ev) + ev->length + 1; } -- GitLab From 7005ff1780ca7ad5ed2ec710ad35affc48362ebf Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 18 Jan 2012 16:14:43 +0200 Subject: [PATCH 0596/1846] Bluetooth: Fix clearing persistent flags There are several other dev_flags besided HCI_MGMT that should not be cleared upon reset. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 42d63522270f..54132a909ea5 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -195,8 +195,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_RESET, status); - /* Reset all flags, except persistent ones like HCI_MGMT */ - hdev->dev_flags &= BIT(HCI_MGMT); + /* Reset all flags, except persistent ones */ + hdev->dev_flags &= BIT(HCI_MGMT) | BIT(HCI_SETUP) | BIT(HCI_AUTO_OFF); } static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From afc747a600ff2e3a4eef8f312fc766608a1360e2 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 15 Jan 2012 18:11:07 +0200 Subject: [PATCH 0597/1846] Bluetooth: Rename mgmt connected events to match user space User space uses device_(dis)connected instead of just (dis)connected so rename the defines and functions to match this. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 6 +++--- include/net/bluetooth/mgmt.h | 4 ++-- net/bluetooth/hci_event.c | 6 +++--- net/bluetooth/mgmt.c | 12 +++++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 393acd071cb6..f3fbfd6f6c3b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -896,10 +896,10 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable); int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent); -int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type); -int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, +int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type); +int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type); int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index be65d3417883..d1d13dc0cca8 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -328,9 +328,9 @@ struct mgmt_ev_new_link_key { struct mgmt_link_key_info key; } __packed; -#define MGMT_EV_CONNECTED 0x000A +#define MGMT_EV_DEVICE_CONNECTED 0x000A -#define MGMT_EV_DISCONNECTED 0x000B +#define MGMT_EV_DEVICE_DISCONNECTED 0x000B #define MGMT_EV_CONNECT_FAILED 0x000C struct mgmt_ev_connect_failed { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 54132a909ea5..e13ce945afc4 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1643,7 +1643,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->state = BT_CONFIG; hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; - mgmt_connected(hdev, &ev->bdaddr, conn->type, + mgmt_device_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type); } else conn->state = BT_CONNECTED; @@ -1789,7 +1789,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff if (ev->status != 0) mgmt_disconnect_failed(hdev, &conn->dst, ev->status); else - mgmt_disconnected(hdev, &conn->dst, conn->type, + mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type); } @@ -3188,7 +3188,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff goto unlock; } - mgmt_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type); + mgmt_device_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e7bbad80fa7e..c8042c6e2b46 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2464,7 +2464,7 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); } -int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, +int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type) { struct mgmt_addr_info ev; @@ -2472,7 +2472,8 @@ int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, bacpy(&ev.bdaddr, bdaddr); ev.type = link_to_mgmt(link_type, addr_type); - return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, &ev, sizeof(ev), + NULL); } static void disconnect_rsp(struct pending_cmd *cmd, void *data) @@ -2509,8 +2510,8 @@ static void remove_keys_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } -int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type) +int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type) { struct mgmt_addr_info ev; struct sock *sk = NULL; @@ -2521,7 +2522,8 @@ int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, bacpy(&ev.bdaddr, bdaddr); ev.type = link_to_mgmt(link_type, addr_type); - err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk); + err = mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev), + sk); if (sk) sock_put(sk); -- GitLab From e319d2e74378660c5e09a1b8703663ba97f0f62a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 15 Jan 2012 19:51:59 +0200 Subject: [PATCH 0598/1846] Bluetooth: Add eir_len parameter to mgmt_ev_device_found This patch add a two byte eir_len parameter mgmt_ev_device_found. Since it's unlikely that the data will in the short term be much bigger than conventional EIR lengths just use a small stack based buffer for now to avoid dynamic memory allocation & freeing. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 2 +- include/net/bluetooth/mgmt.h | 3 ++- net/bluetooth/mgmt.c | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f3fbfd6f6c3b..33dff8ef2e08 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -925,7 +925,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 *eir, u8 eir_len); + u8 cfm_name, u8 *eir, u16 eir_len); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index d1d13dc0cca8..4f166c834ddb 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -368,7 +368,8 @@ struct mgmt_ev_device_found { __u8 dev_class[3]; __s8 rssi; __u8 confirm_name; - __u8 eir[HCI_MAX_EIR_LENGTH]; + __le16 eir_len; + __u8 eir[0]; } __packed; #define MGMT_EV_REMOTE_NAME 0x0012 diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c8042c6e2b46..b7e7fdfaee38 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2782,27 +2782,29 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 *eir, u8 eir_len) + u8 cfm_name, u8 *eir, u16 eir_len) { - struct mgmt_ev_device_found ev; + char buf[512]; + struct mgmt_ev_device_found *ev = (void *) buf; + size_t ev_size = sizeof(*ev) + eir_len; - if (eir_len > sizeof(ev.eir)) + if (ev_size > sizeof(buf)) return -EINVAL; - memset(&ev, 0, sizeof(ev)); + bacpy(&ev->addr.bdaddr, bdaddr); + ev->addr.type = link_to_mgmt(link_type, addr_type); + ev->rssi = rssi; + ev->confirm_name = cfm_name; - bacpy(&ev.addr.bdaddr, bdaddr); - ev.addr.type = link_to_mgmt(link_type, addr_type); - ev.rssi = rssi; - ev.confirm_name = cfm_name; - - if (eir) - memcpy(ev.eir, eir, eir_len); + if (eir_len > 0) { + put_unaligned_le16(eir_len, &ev->eir_len); + memcpy(ev->eir, eir, eir_len); + } if (dev_class) - memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); + memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class)); - return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL); } int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) -- GitLab From 4ddb1930f91b7395a760cd4a8cf1b2a87011571c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 15 Jan 2012 20:04:43 +0200 Subject: [PATCH 0599/1846] Bluetooth: Rename eir_has_complete_name to eir_has_data_type This allows for other uses such as checking for an embedded class of device value in order to decide whether to append the class or not. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e13ce945afc4..d256042a83cf 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2842,7 +2842,7 @@ static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *s BT_DBG("%s status %d", hdev->name, ev->status); } -static inline bool eir_has_complete_name(u8 *data, size_t data_len) +static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) { u8 field_len; size_t parsed; @@ -2858,7 +2858,7 @@ static inline bool eir_has_complete_name(u8 *data, size_t data_len) if (parsed > data_len) break; - if (data[1] == EIR_NAME_COMPLETE) + if (data[1] == type) return true; data += field_len + 1; @@ -2893,8 +2893,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct data.ssp_mode = 0x01; if (test_bit(HCI_MGMT, &hdev->dev_flags)) - name_known = eir_has_complete_name(info->data, - sizeof(info->data)); + name_known = eir_has_data_type(info->data, + sizeof(info->data), + EIR_NAME_COMPLETE); else name_known = true; -- GitLab From 9ec9fc8a99acc8a521337612b5e49521c49cb4c5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 15 Jan 2012 20:46:33 +0200 Subject: [PATCH 0600/1846] Bluetooth: Add missing EIR defines to hci.h This patch adds missing EIR defines (as specified in the Bluetooth Assigned Numbers document) to hci.h. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 84993073c2f1..dd2cc6cb35b3 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -296,6 +296,9 @@ enum { #define EIR_NAME_SHORT 0x08 /* shortened local name */ #define EIR_NAME_COMPLETE 0x09 /* complete local name */ #define EIR_TX_POWER 0x0A /* transmit power level */ +#define EIR_CLASS_OF_DEV 0x0D /* Class of Device */ +#define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */ +#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */ #define EIR_DEVICE_ID 0x10 /* device ID */ /* ----- HCI Commands ---- */ -- GitLab From 6759a67579a927f2a92f398cf67555e6cc92d0ff Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 15 Jan 2012 20:51:14 +0200 Subject: [PATCH 0601/1846] Bluetooth: Move eir_has_data_field to hci_core.h This makes the function accessible from all places it's needed (e.g. mgmt.c and hci_event.c). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 25 +++++++++++++++++++++++++ net/bluetooth/hci_event.c | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 33dff8ef2e08..393bb73fc999 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -868,6 +868,31 @@ static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, read_unlock(&hci_cb_list_lock); } +static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) +{ + u8 field_len; + size_t parsed; + + for (parsed = 0; parsed < data_len - 1; parsed += field_len) { + field_len = data[0]; + + if (field_len == 0) + break; + + parsed += field_len + 1; + + if (parsed > data_len) + break; + + if (data[1] == type) + return true; + + data += field_len + 1; + } + + return false; +} + int hci_register_cb(struct hci_cb *hcb); int hci_unregister_cb(struct hci_cb *hcb); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d256042a83cf..e93afebdcf84 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2842,31 +2842,6 @@ static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *s BT_DBG("%s status %d", hdev->name, ev->status); } -static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) -{ - u8 field_len; - size_t parsed; - - for (parsed = 0; parsed < data_len - 1; parsed += field_len) { - field_len = data[0]; - - if (field_len == 0) - break; - - parsed += field_len + 1; - - if (parsed > data_len) - break; - - if (data[1] == type) - return true; - - data += field_len + 1; - } - - return false; -} - static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct inquiry_data data; -- GitLab From 1dc06093a9f353ef19b7b5180602884d0ce065c5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 15 Jan 2012 21:01:23 +0200 Subject: [PATCH 0602/1846] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found There's no need to have a separate device class field since the same information can be encoded into the EIR data. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 11 +++++++++++ include/net/bluetooth/mgmt.h | 1 - net/bluetooth/mgmt.c | 20 +++++++++++++------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 393bb73fc999..a0311018a4d0 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -893,6 +893,17 @@ static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) return false; } +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data, + u8 data_len) +{ + eir[eir_len++] = sizeof(type) + data_len; + eir[eir_len++] = type; + memcpy(&eir[eir_len], data, data_len); + eir_len += data_len; + + return eir_len; +} + int hci_register_cb(struct hci_cb *hcb); int hci_unregister_cb(struct hci_cb *hcb); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 4f166c834ddb..bdace523b910 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -365,7 +365,6 @@ struct mgmt_ev_auth_failed { #define MGMT_EV_DEVICE_FOUND 0x0011 struct mgmt_ev_device_found { struct mgmt_addr_info addr; - __u8 dev_class[3]; __s8 rssi; __u8 confirm_name; __le16 eir_len; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index b7e7fdfaee38..bec64c98b6a9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2786,23 +2786,29 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, { char buf[512]; struct mgmt_ev_device_found *ev = (void *) buf; - size_t ev_size = sizeof(*ev) + eir_len; + size_t ev_size; - if (ev_size > sizeof(buf)) + /* Leave 5 bytes for a potential CoD field */ + if (sizeof(*ev) + eir_len + 5 > sizeof(buf)) return -EINVAL; + memset(buf, 0, sizeof(buf)); + bacpy(&ev->addr.bdaddr, bdaddr); ev->addr.type = link_to_mgmt(link_type, addr_type); ev->rssi = rssi; ev->confirm_name = cfm_name; - if (eir_len > 0) { - put_unaligned_le16(eir_len, &ev->eir_len); + if (eir_len > 0) memcpy(ev->eir, eir, eir_len); - } - if (dev_class) - memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class)); + if (dev_class && !eir_has_data_type(ev->eir, eir_len, EIR_CLASS_OF_DEV)) + eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV, + dev_class, 3); + + put_unaligned_le16(eir_len, &ev->eir_len); + + ev_size = sizeof(*ev) + eir_len; return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL); } -- GitLab From 51a8efd7d02c13cb1c6fdd1cd66788792a3fcc7c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 16 Jan 2012 06:10:31 +0200 Subject: [PATCH 0603/1846] Bluetooth: Rename conn->pend to conn->flags These flags can and will be used for more general purpose values than just pending state transitions so the more common name "flags" makes more sense than "pend". Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 6 +++--- net/bluetooth/hci_conn.c | 20 +++++++++--------- net/bluetooth/hci_event.c | 36 ++++++++++++++++---------------- net/bluetooth/l2cap_core.c | 2 +- net/bluetooth/smp.c | 19 ++++++++--------- 5 files changed, 41 insertions(+), 42 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index a0311018a4d0..0938168ce602 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -300,7 +300,7 @@ struct hci_conn { __u8 io_capability; __u8 power_save; __u16 disc_timeout; - unsigned long pend; + unsigned long flags; __u8 remote_cap; __u8 remote_oob; @@ -764,7 +764,7 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) if (conn->type != ACL_LINK && conn->type != LE_LINK) return; - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) + if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) return; encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; @@ -805,7 +805,7 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) hci_proto_auth_cfm(conn, status); - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) + if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) return; encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 3db432473ad5..8a4678a2c982 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -337,7 +337,7 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn) hci_send_cmd(hdev, HCI_OP_SNIFF_SUBRATE, sizeof(cp), &cp); } - if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) { struct hci_cp_sniff_mode cp; cp.handle = cpu_to_le16(conn->handle); cp.max_interval = cpu_to_le16(hdev->sniff_max_interval); @@ -589,9 +589,9 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 acl->power_save = 1; hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON); - if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) { + if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->flags)) { /* defer SCO setup until mode change completed */ - set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->pend); + set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->flags); return sco; } @@ -633,13 +633,13 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) conn->auth_type = auth_type; - if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { struct hci_cp_auth_requested cp; cp.handle = cpu_to_le16(conn->handle); hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); if (conn->key_type != 0xff) - set_bit(HCI_CONN_REAUTH_PEND, &conn->pend); + set_bit(HCI_CONN_REAUTH_PEND, &conn->flags); } return 0; @@ -650,7 +650,7 @@ static void hci_conn_encrypt(struct hci_conn *conn) { BT_DBG("conn %p", conn); - if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { struct hci_cp_set_conn_encrypt cp; cp.handle = cpu_to_le16(conn->handle); cp.encrypt = 0x01; @@ -700,7 +700,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) goto encrypt; auth: - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) + if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) return 0; if (!hci_conn_auth(conn, sec_level, auth_type)) @@ -735,7 +735,7 @@ int hci_conn_change_link_key(struct hci_conn *conn) { BT_DBG("conn %p", conn); - if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { struct hci_cp_change_conn_link_key cp; cp.handle = cpu_to_le16(conn->handle); hci_send_cmd(conn->hdev, HCI_OP_CHANGE_CONN_LINK_KEY, @@ -754,7 +754,7 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role) if (!role && conn->link_mode & HCI_LM_MASTER) return 1; - if (!test_and_set_bit(HCI_CONN_RSWITCH_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_RSWITCH_PEND, &conn->flags)) { struct hci_cp_switch_role cp; bacpy(&cp.bdaddr, &conn->dst); cp.role = role; @@ -781,7 +781,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) if (!conn->power_save && !force_active) goto timer; - if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) { struct hci_cp_exit_sniff_mode cp; cp.handle = cpu_to_le16(conn->handle); hci_send_cmd(hdev, HCI_OP_EXIT_SNIFF_MODE, sizeof(cp), &cp); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e93afebdcf84..d9a8618ae156 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1344,7 +1344,7 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) if (!hci_outgoing_auth_needed(hdev, conn)) goto unlock; - if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { struct hci_cp_auth_requested cp; cp.handle = __cpu_to_le16(conn->handle); hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); @@ -1461,9 +1461,9 @@ static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); if (conn) { - clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend); + clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); - if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend)) + if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) hci_sco_setup(conn, status); } @@ -1488,9 +1488,9 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); if (conn) { - clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend); + clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags); - if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend)) + if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) hci_sco_setup(conn, status); } @@ -1817,7 +1817,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s if (!ev->status) { if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) && - test_bit(HCI_CONN_REAUTH_PEND, &conn->pend)) { + test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { BT_INFO("re-auth of legacy device is not possible."); } else { conn->link_mode |= HCI_LM_AUTH; @@ -1827,8 +1827,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s mgmt_auth_failed(hdev, &conn->dst, ev->status); } - clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); - clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend); + clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); + clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); if (conn->state == BT_CONFIG) { if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) { @@ -1850,7 +1850,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s hci_conn_put(conn); } - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { + if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { if (!ev->status) { struct hci_cp_set_conn_encrypt cp; cp.handle = ev->handle; @@ -1858,7 +1858,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), &cp); } else { - clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); hci_encrypt_cfm(conn, ev->status, 0x00); } } @@ -1892,7 +1892,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb if (!hci_outgoing_auth_needed(hdev, conn)) goto unlock; - if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { + if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { struct hci_cp_auth_requested cp; cp.handle = __cpu_to_le16(conn->handle); hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); @@ -1923,7 +1923,7 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff * conn->link_mode &= ~HCI_LM_ENCRYPT; } - clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); if (conn->state == BT_CONFIG) { if (!ev->status) @@ -1952,7 +1952,7 @@ static inline void hci_change_link_key_complete_evt(struct hci_dev *hdev, struct if (!ev->status) conn->link_mode |= HCI_LM_SECURE; - clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); + clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); hci_key_change_cfm(conn, ev->status); } @@ -2336,7 +2336,7 @@ static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb conn->link_mode |= HCI_LM_MASTER; } - clear_bit(HCI_CONN_RSWITCH_PEND, &conn->pend); + clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags); hci_role_switch_cfm(conn, ev->status, ev->role); } @@ -2474,14 +2474,14 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb conn->mode = ev->mode; conn->interval = __le16_to_cpu(ev->interval); - if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) { + if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) { if (conn->mode == HCI_CM_ACTIVE) conn->power_save = 1; else conn->power_save = 0; } - if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend)) + if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) hci_sco_setup(conn, ev->status); } @@ -3013,7 +3013,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, /* If we're not the initiators request authorization to * proceed from user space (mgmt_user_confirm with * confirm_hint set to 1). */ - if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { + if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { BT_DBG("Confirming auto-accept as acceptor"); confirm_hint = 1; goto confirm; @@ -3074,7 +3074,7 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_ * initiated the authentication. A traditional auth_complete * event gets always produced as initiator and is also mapped to * the mgmt_auth_failed event */ - if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend) && ev->status != 0) + if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status != 0) mgmt_auth_failed(hdev, &conn->dst, ev->status); hci_conn_put(conn); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a66e5ec9adef..27b72d954436 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1020,7 +1020,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) __cancel_delayed_work(&conn->info_timer); - if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) { + if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) { __cancel_delayed_work(&conn->security_timer); smp_chan_destroy(conn); } diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 65a90242d990..e08fe6c9c9c9 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -261,7 +261,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send) smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), &reason); - clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->pend); + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason); cancel_delayed_work_sync(&conn->security_timer); smp_chan_destroy(conn); @@ -449,7 +449,7 @@ static void random_work(struct work_struct *work) memset(stk + smp->smp_key_size, 0, SMP_MAX_ENC_KEY_SIZE - smp->smp_key_size); - if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend)) { + if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) { reason = SMP_UNSPECIFIED; goto error; } @@ -506,7 +506,7 @@ void smp_chan_destroy(struct l2cap_conn *conn) { struct smp_chan *smp = conn->smp_chan; - clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend); + clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags); if (smp->tfm) crypto_free_blkcipher(smp->tfm); @@ -571,7 +571,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) if (conn->hcon->link_mode & HCI_LM_MASTER) return SMP_CMD_NOTSUPP; - if (!test_and_set_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend)) + if (!test_and_set_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) smp = smp_chan_create(conn); smp = conn->smp_chan; @@ -707,8 +707,7 @@ static u8 smp_ltk_encrypt(struct l2cap_conn *conn) if (!key) return 0; - if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, - &hcon->pend)) + if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) return 1; master = (void *) key->data; @@ -733,7 +732,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) if (smp_ltk_encrypt(conn)) return 0; - if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) + if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) return 0; smp = smp_chan_create(conn); @@ -772,7 +771,7 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level) if (smp_ltk_encrypt(conn)) goto done; - if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) + if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) return 0; smp = smp_chan_create(conn); @@ -908,7 +907,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) BT_DBG("conn %p force %d", conn, force); - if (!test_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend)) + if (!test_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) return 0; rsp = (void *) &smp->prsp[1]; @@ -982,7 +981,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) } if (conn->hcon->out || force) { - clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend); + clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags); cancel_delayed_work_sync(&conn->security_timer); smp_chan_destroy(conn); } -- GitLab From a0c808b373e89aecc3ecae4cbdcdeff68aa12e3e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 16 Jan 2012 09:49:58 +0200 Subject: [PATCH 0604/1846] Bluetooth: Convert hdev->out to a bool type The hdev->out variable is essentially a boolean so the type 'bool' makes more sense than u8. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_conn.c | 8 ++++---- net/bluetooth/hci_event.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 0938168ce602..520da44940e9 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -282,7 +282,7 @@ struct hci_conn { __u16 state; __u8 mode; __u8 type; - __u8 out; + bool out; __u8 attempt; __u8 dev_class[3]; __u8 features[8]; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8a4678a2c982..a707d19ee44e 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -51,7 +51,7 @@ static void hci_le_connect(struct hci_conn *conn) struct hci_cp_le_create_conn cp; conn->state = BT_CONNECT; - conn->out = 1; + conn->out = true; conn->link_mode |= HCI_LM_MASTER; conn->sec_level = BT_SECURITY_LOW; @@ -83,7 +83,7 @@ void hci_acl_connect(struct hci_conn *conn) BT_DBG("%p", conn); conn->state = BT_CONNECT; - conn->out = 1; + conn->out = true; conn->link_mode = HCI_LM_MASTER; @@ -151,7 +151,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle) BT_DBG("%p", conn); conn->state = BT_CONNECT; - conn->out = 1; + conn->out = true; conn->attempt++; @@ -169,7 +169,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle) BT_DBG("%p", conn); conn->state = BT_CONNECT; - conn->out = 1; + conn->out = true; conn->attempt++; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d9a8618ae156..f6c13153a5e7 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1154,7 +1154,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) if (!conn) { conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr); if (conn) { - conn->out = 1; + conn->out = true; conn->link_mode |= HCI_LM_MASTER; } else BT_ERR("No memory for new connection"); @@ -1526,7 +1526,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status) conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr); if (conn) { conn->dst_type = cp->peer_addr_type; - conn->out = 1; + conn->out = true; } else { BT_ERR("No memory for new connection"); } -- GitLab From b644ba33699711630099efc58a4efc225560aceb Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 17 Jan 2012 21:48:47 +0200 Subject: [PATCH 0605/1846] Bluetooth: Update device_connected and device_found events to latest API This patch updates mgmt_ev_device_connected and mgmt_ev_device found to include an EIR-encoded remote name and class whenever possible. With this addition the mgmt_ev_remote_name event becomes unnecessary and can be removed. Since the connected event doesn't map to hci_conn_complete anymore a HCI_CONN_MGMT_CONNECTED flag is added to track when mgmt has been notified about a connection. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 7 ++- include/net/bluetooth/mgmt.h | 17 ++++--- net/bluetooth/hci_event.c | 78 +++++++++++++++++++++++--------- net/bluetooth/mgmt.c | 56 +++++++++++++++++------ 4 files changed, 110 insertions(+), 48 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 520da44940e9..18af5427fd0c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -409,6 +409,7 @@ enum { HCI_CONN_MODE_CHANGE_PEND, HCI_CONN_SCO_SETUP_PEND, HCI_CONN_LE_SMP_PEND, + HCI_CONN_MGMT_CONNECTED, }; static inline void hci_conn_hash_init(struct hci_dev *hdev) @@ -933,7 +934,8 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent); int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type); + u8 addr_type, u8 *name, u8 name_len, + u8 *dev_class); int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type); int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); @@ -962,7 +964,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8 *eir, u16 eir_len); -int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); +int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, s8 rssi, u8 *name, u8 name_len); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_discovering(struct hci_dev *hdev, u8 discovering); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index bdace523b910..6f37983c8775 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -329,6 +329,11 @@ struct mgmt_ev_new_link_key { } __packed; #define MGMT_EV_DEVICE_CONNECTED 0x000A +struct mgmt_ev_device_connected { + struct mgmt_addr_info addr; + __le16 eir_len; + __u8 eir[0]; +} __packed; #define MGMT_EV_DEVICE_DISCONNECTED 0x000B @@ -371,20 +376,14 @@ struct mgmt_ev_device_found { __u8 eir[0]; } __packed; -#define MGMT_EV_REMOTE_NAME 0x0012 -struct mgmt_ev_remote_name { - bdaddr_t bdaddr; - __u8 name[MGMT_MAX_NAME_LENGTH]; -} __packed; - -#define MGMT_EV_DISCOVERING 0x0013 +#define MGMT_EV_DISCOVERING 0x0012 -#define MGMT_EV_DEVICE_BLOCKED 0x0014 +#define MGMT_EV_DEVICE_BLOCKED 0x0013 struct mgmt_ev_device_blocked { bdaddr_t bdaddr; } __packed; -#define MGMT_EV_DEVICE_UNBLOCKED 0x0015 +#define MGMT_EV_DEVICE_UNBLOCKED 0x0014 struct mgmt_ev_device_unblocked { bdaddr_t bdaddr; } __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index f6c13153a5e7..f0b08ab734d7 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1286,11 +1286,36 @@ static inline int hci_resolve_name(struct hci_dev *hdev, struct inquiry_entry *e return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); } -static void hci_resolve_next_name(struct hci_dev *hdev, bdaddr_t *bdaddr) +static bool hci_resolve_next_name(struct hci_dev *hdev) { struct discovery_state *discov = &hdev->discovery; struct inquiry_entry *e; + if (list_empty(&discov->resolve)) + return false; + + e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); + if (hci_resolve_name(hdev, e) == 0) { + e->name_state = NAME_PENDING; + return true; + } + + return false; +} + +static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, + bdaddr_t *bdaddr, u8 *name, u8 name_len) +{ + struct discovery_state *discov = &hdev->discovery; + struct inquiry_entry *e; + + if (conn && !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) + mgmt_device_connected(hdev, bdaddr, ACL_LINK, 0x00, + name, name_len, conn->dev_class); + + if (discov->state == DISCOVERY_STOPPED) + return; + if (discov->state == DISCOVERY_STOPPING) goto discov_complete; @@ -1301,16 +1326,13 @@ static void hci_resolve_next_name(struct hci_dev *hdev, bdaddr_t *bdaddr) if (e) { e->name_state = NAME_KNOWN; list_del(&e->list); + if (name) + mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, + e->data.rssi, name, name_len); } - if (list_empty(&discov->resolve)) - goto discov_complete; - - e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED); - if (hci_resolve_name(hdev, e) == 0) { - e->name_state = NAME_PENDING; + if (hci_resolve_next_name(hdev)) return; - } discov_complete: hci_discovery_set_state(hdev, DISCOVERY_STOPPED); @@ -1334,10 +1356,11 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) hci_dev_lock(hdev); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); + if (test_bit(HCI_MGMT, &hdev->dev_flags)) - hci_resolve_next_name(hdev, &cp->bdaddr); + hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); if (!conn) goto unlock; @@ -1643,8 +1666,6 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->state = BT_CONFIG; hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; - mgmt_device_connected(hdev, &ev->bdaddr, conn->type, - conn->dst_type); } else conn->state = BT_CONNECTED; @@ -1785,7 +1806,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff if (ev->status == 0) conn->state = BT_CLOSED; - if (conn->type == ACL_LINK || conn->type == LE_LINK) { + if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) && + (conn->type == ACL_LINK || conn->type == LE_LINK)) { if (ev->status != 0) mgmt_disconnect_failed(hdev, &conn->dst, ev->status); else @@ -1878,14 +1900,18 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->dev_flags)) { - if (ev->status == 0) - mgmt_remote_name(hdev, &ev->bdaddr, ev->name); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); - hci_resolve_next_name(hdev, &ev->bdaddr); - } + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) + goto check_auth; - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); + if (ev->status == 0) + hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, + strnlen(ev->name, HCI_MAX_NAME_LENGTH)); + else + hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); + +check_auth: if (!conn) goto unlock; @@ -1994,7 +2020,10 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff bacpy(&cp.bdaddr, &conn->dst); cp.pscan_rep_mode = 0x02; hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); - } + } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) + mgmt_device_connected(hdev, &conn->dst, conn->type, + conn->dst_type, NULL, 0, + conn->dev_class); if (!hci_outgoing_auth_needed(hdev, conn)) { conn->state = BT_CONNECTED; @@ -2763,7 +2792,10 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b bacpy(&cp.bdaddr, &conn->dst); cp.pscan_rep_mode = 0x02; hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); - } + } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) + mgmt_device_connected(hdev, &conn->dst, conn->type, + conn->dst_type, NULL, 0, + conn->dev_class); if (!hci_outgoing_auth_needed(hdev, conn)) { conn->state = BT_CONNECTED; @@ -3164,7 +3196,9 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff goto unlock; } - mgmt_device_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type); + if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) + mgmt_device_connected(hdev, &ev->bdaddr, conn->type, + conn->dst_type, NULL, 0, 0); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index bec64c98b6a9..ae9283d47e65 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1244,7 +1244,6 @@ static int get_connections(struct sock *sk, u16 index) struct mgmt_rp_get_connections *rp; struct hci_dev *hdev; struct hci_conn *c; - struct list_head *p; size_t rp_len; u16 count; int i, err; @@ -1259,8 +1258,9 @@ static int get_connections(struct sock *sk, u16 index) hci_dev_lock(hdev); count = 0; - list_for_each(p, &hdev->conn_hash.list) { - count++; + list_for_each_entry(c, &hdev->conn_hash.list, list) { + if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) + count++; } rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info)); @@ -1274,6 +1274,8 @@ static int get_connections(struct sock *sk, u16 index) i = 0; list_for_each_entry(c, &hdev->conn_hash.list, list) { + if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) + continue; bacpy(&rp->addr[i].bdaddr, &c->dst); rp->addr[i].type = link_to_mgmt(c->type, c->dst_type); if (rp->addr[i].type == MGMT_ADDR_INVALID) @@ -2465,15 +2467,28 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, } int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type) + u8 addr_type, u8 *name, u8 name_len, + u8 *dev_class) { - struct mgmt_addr_info ev; + char buf[512]; + struct mgmt_ev_device_connected *ev = (void *) buf; + u16 eir_len = 0; - bacpy(&ev.bdaddr, bdaddr); - ev.type = link_to_mgmt(link_type, addr_type); + bacpy(&ev->addr.bdaddr, bdaddr); + ev->addr.type = link_to_mgmt(link_type, addr_type); - return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, &ev, sizeof(ev), - NULL); + if (name_len > 0) + eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, + name, name_len); + + if (dev_class && memcmp(dev_class, "\0\0\0", 3) != 0) + eir_len = eir_append_data(&ev->eir[eir_len], eir_len, + EIR_CLASS_OF_DEV, dev_class, 3); + + put_unaligned_le16(eir_len, &ev->eir_len); + + return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, buf, + sizeof(*ev) + eir_len, NULL); } static void disconnect_rsp(struct pending_cmd *cmd, void *data) @@ -2813,16 +2828,27 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL); } -int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) +int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, s8 rssi, u8 *name, u8 name_len) { - struct mgmt_ev_remote_name ev; + struct mgmt_ev_device_found *ev; + char buf[sizeof(*ev) + HCI_MAX_NAME_LENGTH + 2]; + u16 eir_len; - memset(&ev, 0, sizeof(ev)); + ev = (struct mgmt_ev_device_found *) buf; - bacpy(&ev.bdaddr, bdaddr); - memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); + memset(buf, 0, sizeof(buf)); + + bacpy(&ev->addr.bdaddr, bdaddr); + ev->addr.type = link_to_mgmt(link_type, addr_type); + ev->rssi = rssi; + + eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name, + name_len); + + put_unaligned_le16(eir_len, &ev->eir_len); - return mgmt_event(MGMT_EV_REMOTE_NAME, hdev, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); } int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) -- GitLab From 58a681ef1455aef9caad1d41073868fb399373f6 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 16 Jan 2012 06:47:28 +0200 Subject: [PATCH 0606/1846] Bluetooth: Merge boolean members of struct hci_conn into flags Now that the flags member of struct hci_conn is supposed to accommodate any boolean type values we can easily merge all boolean members into it. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 6 +++--- net/bluetooth/hci_conn.c | 15 +++++++++------ net/bluetooth/hci_event.c | 21 +++++++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 18af5427fd0c..7a033111c98f 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -286,7 +286,6 @@ struct hci_conn { __u8 attempt; __u8 dev_class[3]; __u8 features[8]; - __u8 ssp_mode; __u16 interval; __u16 pkt_type; __u16 link_policy; @@ -298,12 +297,10 @@ struct hci_conn { __u8 pin_length; __u8 enc_key_size; __u8 io_capability; - __u8 power_save; __u16 disc_timeout; unsigned long flags; __u8 remote_cap; - __u8 remote_oob; __u8 remote_auth; unsigned int sent; @@ -410,6 +407,9 @@ enum { HCI_CONN_SCO_SETUP_PEND, HCI_CONN_LE_SMP_PEND, HCI_CONN_MGMT_CONNECTED, + HCI_CONN_SSP_ENABLED, + HCI_CONN_POWER_SAVE, + HCI_CONN_REMOTE_OOB, }; static inline void hci_conn_hash_init(struct hci_dev *hdev) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index a707d19ee44e..8288e303621a 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -105,7 +105,8 @@ void hci_acl_connect(struct hci_conn *conn) } memcpy(conn->dev_class, ie->data.dev_class, 3); - conn->ssp_mode = ie->data.ssp_mode; + if (ie->data.ssp_mode > 0) + set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); } cp.pkt_type = cpu_to_le16(conn->pkt_type); @@ -386,7 +387,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) conn->remote_auth = 0xff; conn->key_type = 0xff; - conn->power_save = 1; + set_bit(HCI_CONN_POWER_SAVE, &conn->flags); conn->disc_timeout = HCI_DISCONN_TIMEOUT; switch (type) { @@ -586,7 +587,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 if (acl->state == BT_CONNECTED && (sco->state == BT_OPEN || sco->state == BT_CLOSED)) { - acl->power_save = 1; + set_bit(HCI_CONN_POWER_SAVE, &acl->flags); hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON); if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->flags)) { @@ -607,7 +608,8 @@ int hci_conn_check_link_mode(struct hci_conn *conn) { BT_DBG("conn %p", conn); - if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0 && + if (test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) && + conn->hdev->ssp_mode > 0 && !(conn->link_mode & HCI_LM_ENCRYPT)) return 0; @@ -671,7 +673,8 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) /* For non 2.1 devices and low security level we don't need the link key. */ if (sec_level == BT_SECURITY_LOW && - (!conn->ssp_mode || !conn->hdev->ssp_mode)) + (!test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) || + !conn->hdev->ssp_mode)) return 1; /* For other security levels we need the link key. */ @@ -778,7 +781,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) if (conn->mode != HCI_CM_SNIFF) goto timer; - if (!conn->power_save && !force_active) + if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active) goto timer; if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index f0b08ab734d7..02ad53801732 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1264,7 +1264,8 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev, /* Only request authentication for SSP connections or non-SSP * devices with sec_level HIGH or if MITM protection is requested */ - if (!(hdev->ssp_mode > 0 && conn->ssp_mode > 0) && + if (!(hdev->ssp_mode > 0 && + test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) && conn->pending_sec_level != BT_SECURITY_HIGH && !(conn->auth_type & 0x01)) return 0; @@ -1838,7 +1839,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s goto unlock; if (!ev->status) { - if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) && + if (!(test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) && + hdev->ssp_mode > 0) && test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { BT_INFO("re-auth of legacy device is not possible."); } else { @@ -1853,7 +1855,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); if (conn->state == BT_CONFIG) { - if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) { + if (!ev->status && hdev->ssp_mode > 0 && + test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) { struct hci_cp_set_conn_encrypt cp; cp.handle = ev->handle; cp.encrypt = 0x01; @@ -2505,9 +2508,9 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) { if (conn->mode == HCI_CM_ACTIVE) - conn->power_save = 1; + set_bit(HCI_CONN_POWER_SAVE, &conn->flags); else - conn->power_save = 0; + clear_bit(HCI_CONN_POWER_SAVE, &conn->flags); } if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags)) @@ -2780,7 +2783,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b if (ie) ie->data.ssp_mode = (ev->features[0] & 0x01); - conn->ssp_mode = (ev->features[0] & 0x01); + if (ev->features[0] & 0x01) + set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); } if (conn->state != BT_CONFIG) @@ -2962,7 +2966,7 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff conn->auth_type = hci_get_auth_req(conn); cp.authentication = conn->auth_type; - if ((conn->out == 0x01 || conn->remote_oob == 0x01) && + if ((conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)) && hci_find_remote_oob_data(hdev, &conn->dst)) cp.oob_data = 0x01; else @@ -2998,8 +3002,9 @@ static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *s goto unlock; conn->remote_cap = ev->capability; - conn->remote_oob = ev->oob_data; conn->remote_auth = ev->authentication; + if (ev->oob_data) + set_bit(HCI_CONN_REMOTE_OOB, &conn->flags); unlock: hci_dev_unlock(hdev); -- GitLab From 84bde9d6c0e6830f4a8685a5d237965053118bf9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 25 Jan 2012 14:21:06 +0200 Subject: [PATCH 0607/1846] Bluetooth: Convert hdev->ssp_mode to a flag The ssp_mode is essentially just a boolean so it's more appropriate to have it simply as a flag in hdev->dev_flags. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_conn.c | 6 +++--- net/bluetooth/hci_event.c | 17 ++++++++++++----- net/bluetooth/mgmt.c | 4 ++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index dd2cc6cb35b3..cb9097acbf44 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -94,6 +94,7 @@ enum { HCI_DEBUG_KEYS, HCI_LE_SCAN, + HCI_SSP_ENABLED, }; /* HCI ioctl defines */ diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7a033111c98f..94ba8693e9d1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -144,7 +144,6 @@ struct hci_dev { __u8 features[8]; __u8 host_features[8]; __u8 commands[64]; - __u8 ssp_mode; __u8 hci_ver; __u16 hci_rev; __u8 lmp_ver; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8288e303621a..6ec259e84b95 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -609,8 +609,8 @@ int hci_conn_check_link_mode(struct hci_conn *conn) BT_DBG("conn %p", conn); if (test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) && - conn->hdev->ssp_mode > 0 && - !(conn->link_mode & HCI_LM_ENCRYPT)) + test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags) && + !(conn->link_mode & HCI_LM_ENCRYPT)) return 0; return 1; @@ -674,7 +674,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) key. */ if (sec_level == BT_SECURITY_LOW && (!test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) || - !conn->hdev->ssp_mode)) + !test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags))) return 1; /* For other security levels we need the link key. */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 02ad53801732..eb198ccbc10d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -429,7 +429,10 @@ static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) if (rp->status) return; - hdev->ssp_mode = rp->mode; + if (rp->mode) + set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); + else + clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); } static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) @@ -446,7 +449,10 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) if (!sent) return; - hdev->ssp_mode = *((__u8 *) sent); + if (*((u8 *) sent)) + set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); + else + clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); } static u8 hci_get_inquiry_mode(struct hci_dev *hdev) @@ -1264,7 +1270,7 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev, /* Only request authentication for SSP connections or non-SSP * devices with sec_level HIGH or if MITM protection is requested */ - if (!(hdev->ssp_mode > 0 && + if (!(test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) && conn->pending_sec_level != BT_SECURITY_HIGH && !(conn->auth_type & 0x01)) @@ -1840,7 +1846,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s if (!ev->status) { if (!(test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) && - hdev->ssp_mode > 0) && + test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) && test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { BT_INFO("re-auth of legacy device is not possible."); } else { @@ -1855,7 +1861,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); if (conn->state == BT_CONFIG) { - if (!ev->status && hdev->ssp_mode > 0 && + if (!ev->status && + test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) { struct hci_cp_set_conn_encrypt cp; cp.handle = ev->handle; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ae9283d47e65..89707996d352 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -297,7 +297,7 @@ static u32 get_current_settings(struct hci_dev *hdev) if (test_bit(HCI_AUTH, &hdev->flags)) settings |= MGMT_SETTING_LINK_SECURITY; - if (hdev->ssp_mode > 0) + if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) settings |= MGMT_SETTING_SSP; return settings; @@ -416,7 +416,7 @@ static int update_eir(struct hci_dev *hdev) if (!(hdev->features[6] & LMP_EXT_INQ)) return 0; - if (hdev->ssp_mode == 0) + if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) return 0; if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) -- GitLab From aa64a8b500e61c33c17f1d5e7de0cc154489c59e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 18 Jan 2012 21:33:12 +0200 Subject: [PATCH 0608/1846] Bluetooth: Add a convenience function to check for SSP enabled It's a very common test to see if both the local and the remote device have SSP enabled. By creating a simple function to test this we can shorten many if-statements in the code. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 7 +++++++ net/bluetooth/hci_conn.c | 8 ++------ net/bluetooth/hci_event.c | 12 ++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 94ba8693e9d1..25f449fcd693 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -411,6 +411,13 @@ enum { HCI_CONN_REMOTE_OOB, }; +static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) +{ + struct hci_dev *hdev = conn->hdev; + return (test_bit(HCI_SSP_ENABLED, &hdev->flags) && + test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)); +} + static inline void hci_conn_hash_init(struct hci_dev *hdev) { struct hci_conn_hash *h = &hdev->conn_hash; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6ec259e84b95..eae7a53467ef 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -608,9 +608,7 @@ int hci_conn_check_link_mode(struct hci_conn *conn) { BT_DBG("conn %p", conn); - if (test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) && - test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags) && - !(conn->link_mode & HCI_LM_ENCRYPT)) + if (hci_conn_ssp_enabled(conn) && !(conn->link_mode & HCI_LM_ENCRYPT)) return 0; return 1; @@ -672,9 +670,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) /* For non 2.1 devices and low security level we don't need the link key. */ - if (sec_level == BT_SECURITY_LOW && - (!test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) || - !test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags))) + if (sec_level == BT_SECURITY_LOW && !hci_conn_ssp_enabled(conn)) return 1; /* For other security levels we need the link key. */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index eb198ccbc10d..6fb9016652b7 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1270,8 +1270,7 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev, /* Only request authentication for SSP connections or non-SSP * devices with sec_level HIGH or if MITM protection is requested */ - if (!(test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && - test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) && + if (!hci_conn_ssp_enabled(conn) && conn->pending_sec_level != BT_SECURITY_HIGH && !(conn->auth_type & 0x01)) return 0; @@ -1845,9 +1844,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s goto unlock; if (!ev->status) { - if (!(test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) && - test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) && - test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { + if (!hci_conn_ssp_enabled(conn) && + test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) { BT_INFO("re-auth of legacy device is not possible."); } else { conn->link_mode |= HCI_LM_AUTH; @@ -1861,9 +1859,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags); if (conn->state == BT_CONFIG) { - if (!ev->status && - test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && - test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) { + if (!ev->status && hci_conn_ssp_enabled(conn)) { struct hci_cp_set_conn_encrypt cp; cp.handle = ev->handle; cp.encrypt = 0x01; -- GitLab From 61e1b4b7de5c7e3b671e069f8bf7ee94dedbfde0 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 19 Jan 2012 11:19:50 +0200 Subject: [PATCH 0609/1846] Bluetooth: trivial: space correction Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 27b72d954436..cba1f683b649 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4720,7 +4720,7 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p) c->state, __le16_to_cpu(c->psm), c->scid, c->dcid, c->imtu, c->omtu, c->sec_level, c->mode); -} + } read_unlock(&chan_list_lock); -- GitLab From d22015aad40b4316f0f74c8e410debca44c3e6e2 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Sun, 22 Jan 2012 00:28:34 +0200 Subject: [PATCH 0610/1846] Bluetooth: silence lockdep warning Since bluetooth uses multiple protocols types, to avoid lockdep warnings, we need to use different lockdep classes (one for each protocol type). This is already done in bt_sock_create but it misses a couple of cases when new connections are created. This patch corrects that to fix the following warning: <4>[ 1864.732366] ======================================================= <4>[ 1864.733030] [ INFO: possible circular locking dependency detected ] <4>[ 1864.733544] 3.0.16-mid3-00007-gc9a0f62 #3 <4>[ 1864.733883] ------------------------------------------------------- <4>[ 1864.734408] t.android.btclc/4204 is trying to acquire lock: <4>[ 1864.734869] (rfcomm_mutex){+.+.+.}, at: [] rfcomm_dlc_close+0x15/0x30 <4>[ 1864.735541] <4>[ 1864.735549] but task is already holding lock: <4>[ 1864.736045] (sk_lock-AF_BLUETOOTH){+.+.+.}, at: [] lock_sock+0xa/0xc <4>[ 1864.736732] <4>[ 1864.736740] which lock already depends on the new lock. <4>[ 1864.736750] <4>[ 1864.737428] <4>[ 1864.737437] the existing dependency chain (in reverse order) is: <4>[ 1864.738016] <4>[ 1864.738023] -> #1 (sk_lock-AF_BLUETOOTH){+.+.+.}: <4>[ 1864.738549] [] lock_acquire+0x104/0x140 <4>[ 1864.738977] [] lock_sock_nested+0x58/0x68 <4>[ 1864.739411] [] l2cap_sock_sendmsg+0x3e/0x76 <4>[ 1864.739858] [] __sock_sendmsg+0x50/0x59 <4>[ 1864.740279] [] sock_sendmsg+0x94/0xa8 <4>[ 1864.740687] [] kernel_sendmsg+0x28/0x37 <4>[ 1864.741106] [] rfcomm_send_frame+0x30/0x38 <4>[ 1864.741542] [] rfcomm_send_ua+0x58/0x5a <4>[ 1864.741959] [] rfcomm_run+0x441/0xb52 <4>[ 1864.742365] [] kthread+0x63/0x68 <4>[ 1864.742742] [] kernel_thread_helper+0x6/0xd <4>[ 1864.743187] <4>[ 1864.743193] -> #0 (rfcomm_mutex){+.+.+.}: <4>[ 1864.743667] [] __lock_acquire+0x988/0xc00 <4>[ 1864.744100] [] lock_acquire+0x104/0x140 <4>[ 1864.744519] [] __mutex_lock_common+0x3b/0x33f <4>[ 1864.744975] [] mutex_lock_nested+0x2d/0x36 <4>[ 1864.745412] [] rfcomm_dlc_close+0x15/0x30 <4>[ 1864.745842] [] __rfcomm_sock_close+0x5f/0x6b <4>[ 1864.746288] [] rfcomm_sock_shutdown+0x2f/0x62 <4>[ 1864.746737] [] sys_socketcall+0x1db/0x422 <4>[ 1864.747165] [] syscall_call+0x7/0xb Signed-off-by: Octavian Purdila Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/bluetooth.h | 2 ++ net/bluetooth/af_bluetooth.c | 12 +++++------- net/bluetooth/l2cap_sock.c | 2 ++ net/bluetooth/rfcomm/sock.c | 2 ++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index abaad6ed9b83..4a82ca0bb0b2 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -256,4 +256,6 @@ void l2cap_exit(void); int sco_init(void); void sco_exit(void); +void bt_sock_reclassify_lock(struct sock *sk, int proto); + #endif /* __BLUETOOTH_H */ diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index ef92864ac625..72eb187a5f60 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -71,19 +71,16 @@ static const char *const bt_slock_key_strings[BT_MAX_PROTO] = { "slock-AF_BLUETOOTH-BTPROTO_AVDTP", }; -static inline void bt_sock_reclassify_lock(struct socket *sock, int proto) +void bt_sock_reclassify_lock(struct sock *sk, int proto) { - struct sock *sk = sock->sk; - - if (!sk) - return; - + BUG_ON(!sk); BUG_ON(sock_owned_by_user(sk)); sock_lock_init_class_and_name(sk, bt_slock_key_strings[proto], &bt_slock_key[proto], bt_key_strings[proto], &bt_lock_key[proto]); } +EXPORT_SYMBOL(bt_sock_reclassify_lock); int bt_sock_register(int proto, const struct net_proto_family *ops) { @@ -145,7 +142,8 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto, if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { err = bt_proto[proto]->create(net, sock, proto, kern); - bt_sock_reclassify_lock(sock, proto); + if (!err) + bt_sock_reclassify_lock(sock->sk, proto); module_put(bt_proto[proto]->owner); } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index c57027f7606f..401d9428ae4c 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -849,6 +849,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) if (!sk) return NULL; + bt_sock_reclassify_lock(sk, BTPROTO_L2CAP); + l2cap_sock_init(sk, parent); return l2cap_pi(sk)->chan; diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index f066678faeee..22169c3f1482 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -956,6 +956,8 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc * if (!sk) goto done; + bt_sock_reclassify_lock(sk, BTPROTO_RFCOMM); + rfcomm_sock_init(sk, parent); bacpy(&bt_sk(sk)->src, &src); bacpy(&bt_sk(sk)->dst, &dst); -- GitLab From 2f7719ce54bf6e877987f6ef578b580a51d8c2e3 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 20 Jan 2012 14:08:03 +0200 Subject: [PATCH 0611/1846] Bluetooth: Add alloc_skb chan operator Add channel-specific skb allocation method Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 3 +++ net/bluetooth/l2cap_core.c | 23 +++++++++++++++-------- net/bluetooth/l2cap_sock.c | 9 +++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 238daf84184c..e7a8cc7d07f4 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -506,6 +506,9 @@ struct l2cap_ops { int (*recv) (void *data, struct sk_buff *skb); void (*close) (void *data); void (*state_change) (void *data, int state); + struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, + unsigned long len, int nb, int *err); + }; struct l2cap_conn { diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index cba1f683b649..b2f52f87b98e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1520,7 +1520,6 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, struct msghdr *msg, int len, int count, struct sk_buff *skb) { - struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sk_buff **frag; int err, sent = 0; @@ -1536,7 +1535,9 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, struct msghdr while (len) { count = min_t(unsigned int, conn->mtu, len); - *frag = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err); + *frag = chan->ops->alloc_skb(chan, count, + msg->msg_flags & MSG_DONTWAIT, &err); + if (!*frag) return err; if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) @@ -1566,8 +1567,10 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, BT_DBG("sk %p len %d priority %u", sk, (int)len, priority); count = min_t(unsigned int, (conn->mtu - hlen), len); - skb = bt_skb_send_alloc(sk, count + hlen, - msg->msg_flags & MSG_DONTWAIT, &err); + + skb = chan->ops->alloc_skb(chan, count + hlen, + msg->msg_flags & MSG_DONTWAIT, &err); + if (!skb) return ERR_PTR(err); @@ -1600,8 +1603,10 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, BT_DBG("sk %p len %d", sk, (int)len); count = min_t(unsigned int, (conn->mtu - hlen), len); - skb = bt_skb_send_alloc(sk, count + hlen, - msg->msg_flags & MSG_DONTWAIT, &err); + + skb = chan->ops->alloc_skb(chan, count + hlen, + msg->msg_flags & MSG_DONTWAIT, &err); + if (!skb) return ERR_PTR(err); @@ -1647,8 +1652,10 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, hlen += L2CAP_FCS_SIZE; count = min_t(unsigned int, (conn->mtu - hlen), len); - skb = bt_skb_send_alloc(sk, count + hlen, - msg->msg_flags & MSG_DONTWAIT, &err); + + skb = chan->ops->alloc_skb(chan, count + hlen, + msg->msg_flags & MSG_DONTWAIT, &err); + if (!skb) return ERR_PTR(err); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 401d9428ae4c..16360298590f 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -899,12 +899,21 @@ static void l2cap_sock_state_change_cb(void *data, int state) sk->sk_state = state; } +static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, + unsigned long len, int nb, int *err) +{ + struct sock *sk = chan->sk; + + return bt_skb_send_alloc(sk, len, nb, err); +} + static struct l2cap_ops l2cap_chan_ops = { .name = "L2CAP Socket Interface", .new_connection = l2cap_sock_new_connection_cb, .recv = l2cap_sock_recv_cb, .close = l2cap_sock_close_cb, .state_change = l2cap_sock_state_change_cb, + .alloc_skb = l2cap_sock_alloc_skb_cb, }; static void l2cap_sock_destruct(struct sock *sk) -- GitLab From cad8f1d072375a550ca81419799ba381118c14bb Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 23 Jan 2012 10:06:05 +0100 Subject: [PATCH 0612/1846] Bluetooth: Make l2cap_ertm_data_rcv static It is not used outside of l2cap_core.c. Also l2cap_ertm_data_rcv is only used after it is defined so there is no need for forward declaration. Signed-off-by: Szymon Janc Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index b2f52f87b98e..942ba1d1a38c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -73,8 +73,6 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); -static int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb); - /* ---- L2CAP channels ---- */ static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) @@ -4146,7 +4144,7 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u32 rx_cont return 0; } -int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) +static int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) { u32 control; u16 req_seq; -- GitLab From cb601d7e65f497a2a172d65b2ef1d738ac6fe4f4 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Mon, 30 Jan 2012 09:22:09 -0300 Subject: [PATCH 0613/1846] Bluetooth: Use GFP_KERNEL in hci_conn_add() This function is called in process context only, so it should use GFP_KERNEL to allocate memory. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index eae7a53467ef..9ec7b8efae50 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -373,7 +373,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) BT_DBG("%s dst %s", hdev->name, batostr(dst)); - conn = kzalloc(sizeof(struct hci_conn), GFP_ATOMIC); + conn = kzalloc(sizeof(struct hci_conn), GFP_KERNEL); if (!conn) return NULL; -- GitLab From 75d7735c7a3ddc3842473219460285748d10db11 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Mon, 30 Jan 2012 09:22:10 -0300 Subject: [PATCH 0614/1846] Bluetooth: Use GFP_KERNEL in hci_chan_create() This function is called in process context only, so it should use GFP_KERNEL to allocate memory. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 9ec7b8efae50..7b38a0ba8765 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -945,7 +945,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn) BT_DBG("%s conn %p", hdev->name, conn); - chan = kzalloc(sizeof(struct hci_chan), GFP_ATOMIC); + chan = kzalloc(sizeof(struct hci_chan), GFP_KERNEL); if (!chan) return NULL; -- GitLab From 2f304d1e8bf89f2258a6c2e08c0bc2c5debd08f7 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 27 Jan 2012 19:42:02 -0300 Subject: [PATCH 0615/1846] Bluetooth: Fix potential deadlock We don't need to use the _sync variant in hci_conn_hold and hci_conn_put to cancel conn->disc_work delayed work. This way we avoid potential deadlocks like this one reported by lockdep. ====================================================== [ INFO: possible circular locking dependency detected ] 3.2.0+ #1 Not tainted ------------------------------------------------------- kworker/u:1/17 is trying to acquire lock: (&hdev->lock){+.+.+.}, at: [] hci_conn_timeout+0x62/0x158 [bluetooth] but task is already holding lock: ((&(&conn->disc_work)->work)){+.+...}, at: [] process_one_work+0x11a/0x2bf which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 ((&(&conn->disc_work)->work)){+.+...}: [] lock_acquire+0x8a/0xa7 [] wait_on_work+0x3d/0xaa [] __cancel_work_timer+0xac/0xef [] cancel_delayed_work_sync+0xd/0xf [] smp_chan_create+0xde/0xe6 [bluetooth] [] smp_conn_security+0xa3/0x12d [bluetooth] [] l2cap_connect_cfm+0x237/0x2e8 [bluetooth] [] hci_proto_connect_cfm+0x2d/0x6f [bluetooth] [] hci_event_packet+0x29d1/0x2d60 [bluetooth] [] hci_rx_work+0xd0/0x2e1 [bluetooth] [] process_one_work+0x178/0x2bf [] worker_thread+0xce/0x152 [] kthread+0x95/0x9d [] kernel_thread_helper+0x4/0x10 -> #1 (slock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+...}: [] lock_acquire+0x8a/0xa7 [] _raw_spin_lock_bh+0x36/0x6a [] lock_sock_nested+0x24/0x7f [] lock_sock+0xb/0xd [bluetooth] [] l2cap_chan_connect+0xa9/0x26f [bluetooth] [] l2cap_sock_connect+0xb3/0xff [bluetooth] [] sys_connect+0x69/0x8a [] system_call_fastpath+0x16/0x1b -> #0 (&hdev->lock){+.+.+.}: [] __lock_acquire+0xa80/0xd74 [] lock_acquire+0x8a/0xa7 [] __mutex_lock_common+0x48/0x38e [] mutex_lock_nested+0x2a/0x31 [] hci_conn_timeout+0x62/0x158 [bluetooth] [] process_one_work+0x178/0x2bf [] worker_thread+0xce/0x152 [] kthread+0x95/0x9d [] kernel_thread_helper+0x4/0x10 other info that might help us debug this: Chain exists of: &hdev->lock --> slock-AF_BLUETOOTH-BTPROTO_L2CAP --> (&(&conn->disc_work)->work) Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((&(&conn->disc_work)->work)); lock(slock-AF_BLUETOOTH-BTPROTO_L2CAP); lock((&(&conn->disc_work)->work)); lock(&hdev->lock); *** DEADLOCK *** 2 locks held by kworker/u:1/17: #0: (hdev->name){.+.+.+}, at: [] process_one_work+0x11a/0x2bf #1: ((&(&conn->disc_work)->work)){+.+...}, at: [] process_one_work+0x11a/0x2bf stack backtrace: Pid: 17, comm: kworker/u:1 Not tainted 3.2.0+ #1 Call Trace: [] print_circular_bug+0x1f8/0x209 [] __lock_acquire+0xa80/0xd74 [] ? arch_local_irq_restore+0x6/0xd [] ? vprintk+0x3f9/0x41e [] lock_acquire+0x8a/0xa7 [] ? hci_conn_timeout+0x62/0x158 [bluetooth] [] __mutex_lock_common+0x48/0x38e [] ? hci_conn_timeout+0x62/0x158 [bluetooth] [] ? __dynamic_pr_debug+0x6d/0x6f [] ? hci_conn_timeout+0x62/0x158 [bluetooth] [] ? trace_hardirqs_off+0xd/0xf [] mutex_lock_nested+0x2a/0x31 [] hci_conn_timeout+0x62/0x158 [bluetooth] [] process_one_work+0x178/0x2bf [] ? process_one_work+0x11a/0x2bf [] ? lock_acquired+0x1d0/0x1df [] ? hci_acl_disconn+0x65/0x65 [bluetooth] [] worker_thread+0xce/0x152 [] ? finish_task_switch+0x45/0xc5 [] ? manage_workers.isra.25+0x16a/0x16a [] kthread+0x95/0x9d [] kernel_thread_helper+0x4/0x10 [] ? retint_restore_args+0x13/0x13 [] ? __init_kthread_worker+0x55/0x55 [] ? gs_change+0x13/0x13 Signed-off-by: Andre Guedes Signed-off-by: Vinicius Costa Gomes Reviewed-by: Ulisses Furquim Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 25f449fcd693..896d9e4955fc 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -572,7 +572,7 @@ void hci_conn_put_device(struct hci_conn *conn); static inline void hci_conn_hold(struct hci_conn *conn) { atomic_inc(&conn->refcnt); - cancel_delayed_work_sync(&conn->disc_work); + cancel_delayed_work(&conn->disc_work); } static inline void hci_conn_put(struct hci_conn *conn) @@ -591,7 +591,7 @@ static inline void hci_conn_put(struct hci_conn *conn) } else { timeo = msecs_to_jiffies(10); } - cancel_delayed_work_sync(&conn->disc_work); + cancel_delayed_work(&conn->disc_work); queue_delayed_work(conn->hdev->workqueue, &conn->disc_work, timeo); } -- GitLab From e72acc13c770a82b4ce4a07e9716f29320eae0f8 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 27 Jan 2012 19:42:03 -0300 Subject: [PATCH 0616/1846] Bluetooth: Remove unneeded locking We don't need locking hdev in hci_conn_timeout() since it doesn't access any hdev's shared resources, it basically queues HCI commands. Signed-off-by: Andre Guedes Signed-off-by: Vinicius Costa Gomes Reviewed-by: Ulisses Furquim Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 7b38a0ba8765..67c94c4dfc3c 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -280,7 +280,6 @@ static void hci_conn_timeout(struct work_struct *work) { struct hci_conn *conn = container_of(work, struct hci_conn, disc_work.work); - struct hci_dev *hdev = conn->hdev; __u8 reason; BT_DBG("conn %p state %d", conn, conn->state); @@ -288,8 +287,6 @@ static void hci_conn_timeout(struct work_struct *work) if (atomic_read(&conn->refcnt)) return; - hci_dev_lock(hdev); - switch (conn->state) { case BT_CONNECT: case BT_CONNECT2: @@ -309,8 +306,6 @@ static void hci_conn_timeout(struct work_struct *work) conn->state = BT_CLOSED; break; } - - hci_dev_unlock(hdev); } /* Enter sniff mode */ -- GitLab From 17cd3f374be6648bd46c86ff8f2a2511d3f416ee Mon Sep 17 00:00:00 2001 From: Ulisses Furquim Date: Mon, 30 Jan 2012 18:26:28 -0200 Subject: [PATCH 0617/1846] Bluetooth: Remove usage of __cancel_delayed_work() __cancel_delayed_work() is being used in some paths where we cannot sleep waiting for the delayed work to finish. However, that function might return while the timer is running and the work will be queued again. Replace the calls with safer cancel_delayed_work() version which spins until the timer handler finishes on other CPUs and cancels the delayed work. Signed-off-by: Ulisses Furquim Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 4 ++-- net/bluetooth/l2cap_core.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index e7a8cc7d07f4..42fdbb833254 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -614,7 +614,7 @@ static inline void l2cap_set_timer(struct l2cap_chan *chan, { BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); - if (!__cancel_delayed_work(work)) + if (!cancel_delayed_work(work)) l2cap_chan_hold(chan); schedule_delayed_work(work, timeout); } @@ -624,7 +624,7 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan, { bool ret; - ret = __cancel_delayed_work(work); + ret = cancel_delayed_work(work); if (ret) l2cap_chan_put(chan); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 942ba1d1a38c..ae7fb27525d3 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2588,7 +2588,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && cmd->ident == conn->info_ident) { - __cancel_delayed_work(&conn->info_timer); + cancel_delayed_work(&conn->info_timer); conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; conn->info_ident = 0; @@ -3135,7 +3135,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) return 0; - __cancel_delayed_work(&conn->info_timer); + cancel_delayed_work(&conn->info_timer); if (result != L2CAP_IR_SUCCESS) { conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; @@ -4509,7 +4509,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) if (hcon->type == LE_LINK) { smp_distribute_keys(conn, 0); - __cancel_delayed_work(&conn->security_timer); + cancel_delayed_work(&conn->security_timer); } rcu_read_lock(); -- GitLab From 127074bfa3c11c12e0160437e31b08c6b27412a4 Mon Sep 17 00:00:00 2001 From: Ulisses Furquim Date: Mon, 30 Jan 2012 18:26:29 -0200 Subject: [PATCH 0618/1846] Bluetooth: Fix possible use after free in delete path We need to use the _sync() version for cancelling the info and security timer in the L2CAP connection delete path. Otherwise the delayed work handler might run after the connection object is freed. Signed-off-by: Ulisses Furquim Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ae7fb27525d3..09cd8601ea81 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1016,10 +1016,10 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) hci_chan_del(conn->hchan); if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) - __cancel_delayed_work(&conn->info_timer); + cancel_delayed_work_sync(&conn->info_timer); if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) { - __cancel_delayed_work(&conn->security_timer); + cancel_delayed_work_sync(&conn->security_timer); smp_chan_destroy(conn); } -- GitLab From 27f27ed8f0f7330337297a6dbdb49472dfeef59b Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Mon, 30 Jan 2012 19:29:11 -0300 Subject: [PATCH 0619/1846] Bluetooth: Add structures for the new LTK exchange messages This defines two new messages, one event that will inform userspace that a new Long Term Key was exchanged and one that will allow userspace to load LTKs into the kernel. Besides the information necessary for the restablishement of the secure link, we added some extra information: "authenticated" that informs if the key can be used to establish an authenticated link, and "master" that informs the role in that the key should be used. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/mgmt.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 6f37983c8775..0a694480c27e 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -288,6 +288,22 @@ struct mgmt_cp_unblock_device { bdaddr_t bdaddr; } __packed; +struct mgmt_ltk_info { + struct mgmt_addr_info addr; + __u8 authenticated; + __u8 master; + __u8 enc_size; + __le16 ediv; + __u8 rand[8]; + __u8 val[16]; +} __packed; + +#define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0026 +struct mgmt_cp_load_long_term_keys { + __le16 key_count; + struct mgmt_ltk_info keys[0]; +} __packed; + #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; @@ -387,3 +403,9 @@ struct mgmt_ev_device_blocked { struct mgmt_ev_device_unblocked { bdaddr_t bdaddr; } __packed; + +#define MGMT_EV_NEW_LONG_TERM_KEY 0x0015 +struct mgmt_ev_new_long_term_key { + __u8 store_hint; + struct mgmt_ltk_info key; +} __packed; -- GitLab From f7aa611a0ecf1d22f21e26279e1a3baf1db6b973 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Mon, 30 Jan 2012 19:29:12 -0300 Subject: [PATCH 0620/1846] Bluetooth: Rename smp_key_size to enc_key_size This makes clear that this is the size of the key used to encrypt the link. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/smp.h | 2 +- net/bluetooth/smp.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h index aeaf5fa2b9f1..7b3acdd29134 100644 --- a/include/net/bluetooth/smp.h +++ b/include/net/bluetooth/smp.h @@ -127,7 +127,7 @@ struct smp_chan { u8 rrnd[16]; /* SMP Pairing Random (remote) */ u8 pcnf[16]; /* SMP Pairing Confirm */ u8 tk[16]; /* SMP Temporary Key */ - u8 smp_key_size; + u8 enc_key_size; unsigned long smp_flags; struct crypto_blkcipher *tfm; struct work_struct confirm; diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index e08fe6c9c9c9..581833436afa 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -250,7 +250,7 @@ static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) (max_key_size < SMP_MIN_ENC_KEY_SIZE)) return SMP_ENC_KEY_SIZE; - smp->smp_key_size = max_key_size; + smp->enc_key_size = max_key_size; return 0; } @@ -446,8 +446,8 @@ static void random_work(struct work_struct *work) smp_s1(tfm, smp->tk, smp->rrnd, smp->prnd, key); swap128(key, stk); - memset(stk + smp->smp_key_size, 0, - SMP_MAX_ENC_KEY_SIZE - smp->smp_key_size); + memset(stk + smp->enc_key_size, 0, + SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) { reason = SMP_UNSPECIFIED; @@ -455,7 +455,7 @@ static void random_work(struct work_struct *work) } hci_le_start_enc(hcon, ediv, rand, stk); - hcon->enc_key_size = smp->smp_key_size; + hcon->enc_key_size = smp->enc_key_size; } else { u8 stk[16], r[16], rand[8]; __le16 ediv; @@ -469,10 +469,10 @@ static void random_work(struct work_struct *work) smp_s1(tfm, smp->tk, smp->prnd, smp->rrnd, key); swap128(key, stk); - memset(stk + smp->smp_key_size, 0, - SMP_MAX_ENC_KEY_SIZE - smp->smp_key_size); + memset(stk + smp->enc_key_size, 0, + SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); - hci_add_ltk(hcon->hdev, 0, conn->dst, smp->smp_key_size, + hci_add_ltk(hcon->hdev, 0, conn->dst, smp->enc_key_size, ediv, rand, stk); } @@ -819,7 +819,7 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) skb_pull(skb, sizeof(*rp)); - hci_add_ltk(conn->hcon->hdev, 1, conn->dst, smp->smp_key_size, + hci_add_ltk(conn->hcon->hdev, 1, conn->dst, smp->enc_key_size, rp->ediv, rp->rand, smp->tk); smp_distribute_keys(conn, 1); @@ -940,7 +940,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); - hci_add_ltk(conn->hcon->hdev, 1, conn->dst, smp->smp_key_size, + hci_add_ltk(conn->hcon->hdev, 1, conn->dst, smp->enc_key_size, ediv, ident.rand, enc.ltk); ident.ediv = cpu_to_le16(ediv); -- GitLab From 4777bfdebbddc1f58d9148de5a3e00375d063768 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Mon, 30 Jan 2012 23:31:28 -0300 Subject: [PATCH 0621/1846] Bluetooth: Use GFP_KERNEL in hci_add_adv_entry() This function is not called in interrupt context anymore, so it should use GFP_KERNEL to allocate memory. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 91166dbbe35c..45e2d2a72b15 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1553,7 +1553,7 @@ int hci_add_adv_entry(struct hci_dev *hdev, if (hci_find_adv_entry(hdev, &ev->bdaddr)) return 0; - entry = kzalloc(sizeof(*entry), GFP_ATOMIC); + entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (!entry) return -ENOMEM; -- GitLab From 66f01296962dfebf032c18ffe61c53a199b4a7bd Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Fri, 27 Jan 2012 19:32:39 +0200 Subject: [PATCH 0622/1846] Bluetooth: Fix RFCOMM session reference counting issue There is an imbalance in the rfcomm_session_hold / rfcomm_session_put operations which causes the following crash: [ 685.010159] BUG: unable to handle kernel paging request at 6b6b6b6b [ 685.010169] IP: [] rfcomm_process_dlcs+0x1b/0x15e [ 685.010181] *pdpt = 000000002d665001 *pde = 0000000000000000 [ 685.010191] Oops: 0000 [#1] PREEMPT SMP [ 685.010247] [ 685.010255] Pid: 947, comm: krfcommd Tainted: G C 3.0.16-mid8-dirty #44 [ 685.010266] EIP: 0060:[] EFLAGS: 00010246 CPU: 1 [ 685.010274] EIP is at rfcomm_process_dlcs+0x1b/0x15e [ 685.010281] EAX: e79f551c EBX: 6b6b6b6b ECX: 00000007 EDX: e79f40b4 [ 685.010288] ESI: e79f4060 EDI: ed4e1f70 EBP: ed4e1f68 ESP: ed4e1f50 [ 685.010295] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 [ 685.010303] Process krfcommd (pid: 947, ti=ed4e0000 task=ed43e5e0 task.ti=ed4e0000) [ 685.010308] Stack: [ 685.010312] ed4e1f68 c149eb53 e5925150 e79f4060 ed500000 ed4e1f70 ed4e1f80 c149ec10 [ 685.010331] 00000000 ed43e5e0 00000000 ed4e1f90 ed4e1f9c c149ec87 0000bf54 00000000 [ 685.010348] 00000000 ee03bf54 c149ec37 ed4e1fe4 c104fe01 00000000 00000000 00000000 [ 685.010367] Call Trace: [ 685.010376] [] ? rfcomm_process_rx+0x6e/0x74 [ 685.010387] [] rfcomm_process_sessions+0xb7/0xde [ 685.010398] [] rfcomm_run+0x50/0x6d [ 685.010409] [] ? rfcomm_process_sessions+0xde/0xde [ 685.010419] [] kthread+0x63/0x68 [ 685.010431] [] ? __init_kthread_worker+0x42/0x42 [ 685.010442] [] kernel_thread_helper+0x6/0xd This issue has been brought up earlier here: https://lkml.org/lkml/2011/5/21/127 The issue appears to be the rfcomm_session_put in rfcomm_recv_ua. This operation doesn't seem be to required as for the non-initiator case we have the rfcomm_process_rx doing an explicit put and in the initiator case the last dlc_unlink will drive the reference counter to 0. There have been several attempts to fix these issue: 6c2718d Bluetooth: Do not call rfcomm_session_put() for RFCOMM UA on closed socket 683d949 Bluetooth: Never deallocate a session when some DLC points to it but AFAICS they do not fix the issue just make it harder to reproduce. Signed-off-by: Octavian Purdila Signed-off-by: Gopala Krishna Murala Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/rfcomm/core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 501649bf5596..8a602388f1e7 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -1164,12 +1164,18 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci) break; case BT_DISCONN: - /* When socket is closed and we are not RFCOMM - * initiator rfcomm_process_rx already calls - * rfcomm_session_put() */ - if (s->sock->sk->sk_state != BT_CLOSED) - if (list_empty(&s->dlcs)) - rfcomm_session_put(s); + /* rfcomm_session_put is called later so don't do + * anything here otherwise we will mess up the session + * reference counter: + * + * (a) when we are the initiator dlc_unlink will drive + * the reference counter to 0 (there is no initial put + * after session_add) + * + * (b) when we are not the initiator rfcomm_rx_process + * will explicitly call put to balance the initial hold + * done after session add. + */ break; } } -- GitLab From f1c09c07cd1a6c1676c4df6450d2b28875e184c1 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Wed, 1 Feb 2012 18:27:56 -0300 Subject: [PATCH 0623/1846] Bluetooth: Fix invalid memory access when there's no SMP channel We only should try to free the SMP channel that was created if there is a pending SMP session. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/smp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 581833436afa..9ff56e18d99b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -263,8 +263,11 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send) clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason); - cancel_delayed_work_sync(&conn->security_timer); - smp_chan_destroy(conn); + + if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) { + cancel_delayed_work_sync(&conn->security_timer); + smp_chan_destroy(conn); + } } #define JUST_WORKS 0x00 @@ -506,7 +509,7 @@ void smp_chan_destroy(struct l2cap_conn *conn) { struct smp_chan *smp = conn->smp_chan; - clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags); + BUG_ON(!smp); if (smp->tfm) crypto_free_blkcipher(smp->tfm); -- GitLab From 9ef866adf9602238c2e83e951a72a1037d4179de Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 1 Feb 2012 23:42:38 +0200 Subject: [PATCH 0624/1846] Bluetooth: Update mgmt.h to match latest API spec This patch updates the opcodes for mgmt commands and events to match the latest user space API specification. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 126 ++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 0a694480c27e..42eb48bb2c3b 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -46,6 +46,16 @@ struct mgmt_hdr { __le16 len; } __packed; +#define MGMT_ADDR_BREDR 0x00 +#define MGMT_ADDR_LE_PUBLIC 0x01 +#define MGMT_ADDR_LE_RANDOM 0x02 +#define MGMT_ADDR_INVALID 0xff + +struct mgmt_addr_info { + bdaddr_t bdaddr; + __u8 type; +} __packed; + #define MGMT_OP_READ_VERSION 0x0001 struct mgmt_rp_read_version { __u8 version; @@ -148,7 +158,23 @@ struct mgmt_cp_load_link_keys { struct mgmt_link_key_info keys[0]; } __packed; -#define MGMT_OP_REMOVE_KEYS 0x0013 +struct mgmt_ltk_info { + struct mgmt_addr_info addr; + __u8 authenticated; + __u8 master; + __u8 enc_size; + __le16 ediv; + __u8 rand[8]; + __u8 val[16]; +} __packed; + +#define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013 +struct mgmt_cp_load_long_term_keys { + __le16 key_count; + struct mgmt_ltk_info keys[0]; +} __packed; + +#define MGMT_OP_REMOVE_KEYS 0x0014 struct mgmt_cp_remove_keys { bdaddr_t bdaddr; __u8 disconnect; @@ -158,7 +184,7 @@ struct mgmt_rp_remove_keys { __u8 status; }; -#define MGMT_OP_DISCONNECT 0x0014 +#define MGMT_OP_DISCONNECT 0x0015 struct mgmt_cp_disconnect { bdaddr_t bdaddr; } __packed; @@ -167,23 +193,13 @@ struct mgmt_rp_disconnect { __u8 status; } __packed; -#define MGMT_ADDR_BREDR 0x00 -#define MGMT_ADDR_LE_PUBLIC 0x01 -#define MGMT_ADDR_LE_RANDOM 0x02 -#define MGMT_ADDR_INVALID 0xff - -struct mgmt_addr_info { - bdaddr_t bdaddr; - __u8 type; -} __packed; - -#define MGMT_OP_GET_CONNECTIONS 0x0015 +#define MGMT_OP_GET_CONNECTIONS 0x0016 struct mgmt_rp_get_connections { __le16 conn_count; struct mgmt_addr_info addr[0]; } __packed; -#define MGMT_OP_PIN_CODE_REPLY 0x0016 +#define MGMT_OP_PIN_CODE_REPLY 0x0017 struct mgmt_cp_pin_code_reply { bdaddr_t bdaddr; __u8 pin_len; @@ -194,17 +210,17 @@ struct mgmt_rp_pin_code_reply { uint8_t status; } __packed; -#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 +#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0018 struct mgmt_cp_pin_code_neg_reply { bdaddr_t bdaddr; } __packed; -#define MGMT_OP_SET_IO_CAPABILITY 0x0018 +#define MGMT_OP_SET_IO_CAPABILITY 0x0019 struct mgmt_cp_set_io_capability { __u8 io_capability; } __packed; -#define MGMT_OP_PAIR_DEVICE 0x0019 +#define MGMT_OP_PAIR_DEVICE 0x001A struct mgmt_cp_pair_device { struct mgmt_addr_info addr; __u8 io_cap; @@ -214,7 +230,9 @@ struct mgmt_rp_pair_device { __u8 status; } __packed; -#define MGMT_OP_USER_CONFIRM_REPLY 0x001A +#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001B + +#define MGMT_OP_USER_CONFIRM_REPLY 0x001C struct mgmt_cp_user_confirm_reply { bdaddr_t bdaddr; } __packed; @@ -223,12 +241,12 @@ struct mgmt_rp_user_confirm_reply { __u8 status; } __packed; -#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001B +#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D struct mgmt_cp_user_confirm_neg_reply { bdaddr_t bdaddr; } __packed; -#define MGMT_OP_USER_PASSKEY_REPLY 0x001C +#define MGMT_OP_USER_PASSKEY_REPLY 0x001E struct mgmt_cp_user_passkey_reply { bdaddr_t bdaddr; __le32 passkey; @@ -238,37 +256,37 @@ struct mgmt_rp_user_passkey_reply { __u8 status; } __packed; -#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001D +#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F struct mgmt_cp_user_passkey_neg_reply { bdaddr_t bdaddr; } __packed; -#define MGMT_OP_READ_LOCAL_OOB_DATA 0x001E +#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 struct mgmt_rp_read_local_oob_data { __u8 hash[16]; __u8 randomizer[16]; } __packed; -#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x001F +#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021 struct mgmt_cp_add_remote_oob_data { bdaddr_t bdaddr; __u8 hash[16]; __u8 randomizer[16]; } __packed; -#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0020 +#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 struct mgmt_cp_remove_remote_oob_data { bdaddr_t bdaddr; } __packed; -#define MGMT_OP_START_DISCOVERY 0x0021 +#define MGMT_OP_START_DISCOVERY 0x0023 struct mgmt_cp_start_discovery { __u8 type; } __packed; -#define MGMT_OP_STOP_DISCOVERY 0x0022 +#define MGMT_OP_STOP_DISCOVERY 0x0024 -#define MGMT_OP_CONFIRM_NAME 0x0023 +#define MGMT_OP_CONFIRM_NAME 0x0025 struct mgmt_cp_confirm_name { bdaddr_t bdaddr; __u8 name_known; @@ -278,32 +296,16 @@ struct mgmt_rp_confirm_name { __u8 status; } __packed; -#define MGMT_OP_BLOCK_DEVICE 0x0024 +#define MGMT_OP_BLOCK_DEVICE 0x0026 struct mgmt_cp_block_device { bdaddr_t bdaddr; } __packed; -#define MGMT_OP_UNBLOCK_DEVICE 0x0025 +#define MGMT_OP_UNBLOCK_DEVICE 0x0027 struct mgmt_cp_unblock_device { bdaddr_t bdaddr; } __packed; -struct mgmt_ltk_info { - struct mgmt_addr_info addr; - __u8 authenticated; - __u8 master; - __u8 enc_size; - __le16 ediv; - __u8 rand[8]; - __u8 val[16]; -} __packed; - -#define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0026 -struct mgmt_cp_load_long_term_keys { - __le16 key_count; - struct mgmt_ltk_info keys[0]; -} __packed; - #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; @@ -344,46 +346,52 @@ struct mgmt_ev_new_link_key { struct mgmt_link_key_info key; } __packed; -#define MGMT_EV_DEVICE_CONNECTED 0x000A +#define MGMT_EV_NEW_LONG_TERM_KEY 0x000A +struct mgmt_ev_new_long_term_key { + __u8 store_hint; + struct mgmt_ltk_info key; +} __packed; + +#define MGMT_EV_DEVICE_CONNECTED 0x000B struct mgmt_ev_device_connected { struct mgmt_addr_info addr; __le16 eir_len; __u8 eir[0]; } __packed; -#define MGMT_EV_DEVICE_DISCONNECTED 0x000B +#define MGMT_EV_DEVICE_DISCONNECTED 0x000C -#define MGMT_EV_CONNECT_FAILED 0x000C +#define MGMT_EV_CONNECT_FAILED 0x000D struct mgmt_ev_connect_failed { struct mgmt_addr_info addr; __u8 status; } __packed; -#define MGMT_EV_PIN_CODE_REQUEST 0x000D +#define MGMT_EV_PIN_CODE_REQUEST 0x000E struct mgmt_ev_pin_code_request { bdaddr_t bdaddr; __u8 secure; } __packed; -#define MGMT_EV_USER_CONFIRM_REQUEST 0x000E +#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F struct mgmt_ev_user_confirm_request { bdaddr_t bdaddr; __u8 confirm_hint; __le32 value; } __packed; -#define MGMT_EV_USER_PASSKEY_REQUEST 0x000F +#define MGMT_EV_USER_PASSKEY_REQUEST 0x0010 struct mgmt_ev_user_passkey_request { bdaddr_t bdaddr; } __packed; -#define MGMT_EV_AUTH_FAILED 0x0010 +#define MGMT_EV_AUTH_FAILED 0x0011 struct mgmt_ev_auth_failed { bdaddr_t bdaddr; __u8 status; } __packed; -#define MGMT_EV_DEVICE_FOUND 0x0011 +#define MGMT_EV_DEVICE_FOUND 0x0012 struct mgmt_ev_device_found { struct mgmt_addr_info addr; __s8 rssi; @@ -392,20 +400,14 @@ struct mgmt_ev_device_found { __u8 eir[0]; } __packed; -#define MGMT_EV_DISCOVERING 0x0012 +#define MGMT_EV_DISCOVERING 0x0013 -#define MGMT_EV_DEVICE_BLOCKED 0x0013 +#define MGMT_EV_DEVICE_BLOCKED 0x0014 struct mgmt_ev_device_blocked { bdaddr_t bdaddr; } __packed; -#define MGMT_EV_DEVICE_UNBLOCKED 0x0014 +#define MGMT_EV_DEVICE_UNBLOCKED 0x0015 struct mgmt_ev_device_unblocked { bdaddr_t bdaddr; } __packed; - -#define MGMT_EV_NEW_LONG_TERM_KEY 0x0015 -struct mgmt_ev_new_long_term_key { - __u8 store_hint; - struct mgmt_ltk_info key; -} __packed; -- GitLab From b7d05bad1c10a363b6b99f66ac1fa76b6892e618 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Fri, 13 Jan 2012 15:11:30 +0100 Subject: [PATCH 0625/1846] Bluetooth: Fix l2cap conn failures for ssp devices Commit 330605423c fixed l2cap conn establishment for non-ssp remote devices by not setting HCI_CONN_ENCRYPT_PEND every time conn security is tested (which was always returning failure on any subsequent security checks). However, this broke l2cap conn establishment for ssp remote devices when an ACL link was already established at SDP-level security. This fix ensures that encryption must be pending whenever authentication is also pending. Signed-off-by: Peter Hurley Tested-by: Daniel Wagner Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 67c94c4dfc3c..aca71c087a1d 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -630,6 +630,10 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { struct hci_cp_auth_requested cp; + + /* encrypt must be pending if auth is also pending */ + set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); + cp.handle = cpu_to_le16(conn->handle); hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); -- GitLab From 7a7f1e7c857959f5298020969741e389f21edbae Mon Sep 17 00:00:00 2001 From: Hemant Gupta Date: Mon, 16 Jan 2012 13:34:29 +0530 Subject: [PATCH 0626/1846] Bluetooth: Send correct response to IO Capability Request This patch sends correct IO Capability response to remote device in case Local Device supports KeyBoardDisplay IO Capability as this capability is not valid as per BT spec for IO capability Request Reply Command. This capability is mapped to DisplayYesNo which is in accordance with BT spec. Signed-off-by: Hemant Gupta Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6fb9016652b7..041a35eb25c6 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2965,7 +2965,10 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff struct hci_cp_io_capability_reply cp; bacpy(&cp.bdaddr, &ev->bdaddr); - cp.capability = conn->io_capability; + /* Change the IO capability from KeyboardDisplay + * to DisplayYesNo as it is not supported by BT spec. */ + cp.capability = (conn->io_capability == 0x04) ? + 0x01 : conn->io_capability; conn->auth_type = hci_get_auth_req(conn); cp.authentication = conn->auth_type; -- GitLab From 95947a391ebe685b9870cd25cac1433aedf5d49c Mon Sep 17 00:00:00 2001 From: Hemant Gupta Date: Mon, 23 Jan 2012 15:36:11 +0530 Subject: [PATCH 0627/1846] Bluetooth: Fix clearing of debug and linkkey flags This patch fixes clearing of HCI_LINK_KEYS and HCI_DEBUG_KEYS dev_flags while resetting. Without this patch pairing does not work over management interface for BR-EDR devices. Signed-off-by: Hemant Gupta Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 041a35eb25c6..a86f82b11316 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -196,7 +196,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_RESET, status); /* Reset all flags, except persistent ones */ - hdev->dev_flags &= BIT(HCI_MGMT) | BIT(HCI_SETUP) | BIT(HCI_AUTO_OFF); + hdev->dev_flags &= BIT(HCI_MGMT) | BIT(HCI_SETUP) | BIT(HCI_AUTO_OFF) | + BIT(HCI_LINK_KEYS) | BIT(HCI_DEBUG_KEYS); } static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From 28424707a2e4ad38ab546d2ed5e3d6b035a84258 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 2 Feb 2012 04:02:29 +0200 Subject: [PATCH 0628/1846] Bluetooth: mgmt: Implement Cancel Pair Device command This patch implements the Cancel Pair Device command for mgmt. It's used by user space to cancel an ongoing pairing attempt which was triggered by the Pair Device command. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/mgmt.c | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 42eb48bb2c3b..72975fd53988 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -39,6 +39,7 @@ #define MGMT_STATUS_INVALID_PARAMS 0x0d #define MGMT_STATUS_DISCONNECTED 0x0e #define MGMT_STATUS_NOT_POWERED 0x0f +#define MGMT_STATUS_CANCELLED 0x10 struct mgmt_hdr { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 89707996d352..00ab083749eb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1594,6 +1594,54 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) return err; } +static int cancel_pair_device(struct sock *sk, u16 index, + unsigned char *data, u16 len) +{ + struct mgmt_addr_info *addr = (void *) data; + struct hci_dev *hdev; + struct pending_cmd *cmd; + struct hci_conn *conn; + int err; + + BT_DBG(""); + + if (len != sizeof(*addr)) + return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + MGMT_STATUS_INVALID_PARAMS); + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + MGMT_STATUS_INVALID_PARAMS); + + hci_dev_lock(hdev); + + cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev); + if (!cmd) { + err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + MGMT_STATUS_INVALID_PARAMS); + goto unlock; + } + + conn = cmd->user_data; + + if (bacmp(&addr->bdaddr, &conn->dst) != 0) { + err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + MGMT_STATUS_INVALID_PARAMS); + goto unlock; + } + + pairing_complete(cmd, MGMT_STATUS_CANCELLED); + + err = cmd_complete(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, addr, + sizeof(*addr)); +unlock: + hci_dev_unlock(hdev); + hci_dev_put(hdev); + + return err; +} + static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, u16 mgmt_op, u16 hci_op, __le32 passkey) { @@ -2271,6 +2319,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_PAIR_DEVICE: err = pair_device(sk, index, buf + sizeof(*hdr), len); break; + case MGMT_OP_CANCEL_PAIR_DEVICE: + err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len); + break; case MGMT_OP_USER_CONFIRM_REPLY: err = user_confirm_reply(sk, index, buf + sizeof(*hdr), len); break; -- GitLab From 3c4e0df028935618d052235ba85bc7079be13394 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 2 Feb 2012 10:32:17 +0200 Subject: [PATCH 0629/1846] Bluetooth: Use list _safe deleting from conn_hash_list Use list_for_each_entry_safe which is safe version against removal of list entry. Otherwise we remove hci_conn element and reference next element which result in accessing LIST_POISON. [ 95.571834] Bluetooth: unknown link type 127 [ 95.578349] BUG: unable to handle kernel paging request at 20002000 [ 95.580236] IP: [<20002000>] 0x20001fff [ 95.580763] *pde = 00000000 [ 95.581196] Oops: 0000 [#1] SMP ... [ 95.582298] Pid: 3355, comm: hciconfig Tainted: G O 3.2.0-VirttualBox [ 95.582298] EIP: 0060:[<20002000>] EFLAGS: 00210206 CPU: 0 [ 95.582298] EIP is at 0x20002000 ... [ 95.582298] Call Trace: [ 95.582298] [] ? hci_conn_hash_flush+0x76/0xf0 [bluetooth] [ 95.582298] [] hci_dev_do_close+0xc1/0x2e0 [bluetooth] [ 95.582298] [] ? hci_dev_get+0x69/0xb0 [bluetooth] [ 95.582298] [] hci_dev_close+0x2a/0x50 [bluetooth] [ 95.582298] [] hci_sock_ioctl+0x1af/0x3f0 [bluetooth] [ 95.582298] [] ? handle_pte_fault+0x8a/0x8f0 [ 95.582298] [] sock_ioctl+0x5f/0x260 [ 95.582298] [] ? sock_fasync+0x90/0x90 [ 95.582298] [] do_vfs_ioctl+0x83/0x5b0 [ 95.582298] [] ? do_page_fault+0x297/0x500 [ 95.582298] [] ? spurious_fault+0xd0/0xd0 [ 95.582298] [] ? up_read+0x1b/0x30 [ 95.582298] [] ? do_page_fault+0x297/0x500 [ 95.582298] [] ? init_fpu+0xef/0x160 [ 95.582298] [] ? do_debug+0x180/0x180 [ 95.582298] [] ? fpu_finit+0x28/0x80 [ 95.582298] [] sys_ioctl+0x87/0x90 [ 95.582298] [] sysenter_do_call+0x12/0x38 ... Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index aca71c087a1d..b074bd698cf6 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -795,11 +795,11 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) void hci_conn_hash_flush(struct hci_dev *hdev) { struct hci_conn_hash *h = &hdev->conn_hash; - struct hci_conn *c; + struct hci_conn *c, *n; BT_DBG("hdev %s", hdev->name); - list_for_each_entry_rcu(c, &h->list, list) { + list_for_each_entry_safe(c, n, &h->list, list) { c->state = BT_CLOSED; hci_proto_disconn_cfm(c, HCI_ERROR_LOCAL_HOST_TERM); -- GitLab From 2a5a5ec620a29d4ba07743c3151cdf0a417c8f8c Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Thu, 2 Feb 2012 10:32:18 +0200 Subject: [PATCH 0630/1846] Bluetooth: Use list _safe deleting from conn chan_list Fixes possible bug when deleting element from the list in function hci_chan_list_flush. list_for_each_entry_rcu is used and after deleting element from the list we also free pointer and then list_entry_rcu is taken from freed pointer. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b074bd698cf6..b4ecddee11b5 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -975,10 +975,10 @@ int hci_chan_del(struct hci_chan *chan) void hci_chan_list_flush(struct hci_conn *conn) { - struct hci_chan *chan; + struct hci_chan *chan, *n; BT_DBG("conn %p", conn); - list_for_each_entry_rcu(chan, &conn->chan_list, list) + list_for_each_entry_safe(chan, n, &conn->chan_list, list) hci_chan_del(chan); } -- GitLab From 37305cf649689a4d2341dd6fd89b091c6007f9ba Mon Sep 17 00:00:00 2001 From: Manoj Iyer Date: Thu, 2 Feb 2012 09:32:36 -0600 Subject: [PATCH 0631/1846] Bluetooth: btusb: Add vendor specific ID (0a5c 21f3) for BCM20702A0 T: Bus=01 Lev=02 Prnt=02 Port=03 Cnt=03 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0a5c ProdID=21f3 Rev=01.12 S: Manufacturer=Broadcom Corp S: Product=BCM20702A0 S: SerialNumber=74DE2B344A7B C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none) I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none) I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none) Signed-off-by: Manoj Iyer Tested-by: Dennis Chua Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index d7664ffc5183..afcd2816a24b 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -102,6 +102,7 @@ static struct usb_device_id btusb_table[] = { /* Broadcom BCM20702A0 */ { USB_DEVICE(0x0a5c, 0x21e3) }, + { USB_DEVICE(0x0a5c, 0x21f3) }, { USB_DEVICE(0x413c, 0x8197) }, { } /* Terminating entry */ -- GitLab From 650f726d16a3f25153d785b531516f6e90d2014f Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:07:59 -0300 Subject: [PATCH 0632/1846] Bluetooth: Fix doing some useless casts when receiving MGMT commands Every command handler of mgmt does a cast to the command structure so it can properly interpreted. So we can avoid that cast if we make those functions receive a void * directly. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 205 ++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 122 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 00ab083749eb..ad8986276848 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -611,15 +611,13 @@ static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev) return cmd_complete(sk, hdev->id, opcode, &settings, sizeof(settings)); } -static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int set_powered(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_mode *cp; + struct mgmt_mode *cp = data; struct hci_dev *hdev; struct pending_cmd *cmd; int err, up; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -664,17 +662,14 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len) return err; } -static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_set_discoverable *cp; + struct mgmt_cp_set_discoverable *cp = data; struct hci_dev *hdev; struct pending_cmd *cmd; u8 scan; int err; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -734,17 +729,14 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, return err; } -static int set_connectable(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_mode *cp; + struct mgmt_mode *cp = data; struct hci_dev *hdev; struct pending_cmd *cmd; u8 scan; int err; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -827,16 +819,13 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, return 0; } -static int set_pairable(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int set_pairable(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_mode *cp; + struct mgmt_mode *cp = data; struct hci_dev *hdev; __le32 ev; int err; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -870,15 +859,13 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data, return err; } -static int add_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_add_uuid *cp; + struct mgmt_cp_add_uuid *cp = data; struct hci_dev *hdev; struct bt_uuid *uuid; int err; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -920,16 +907,14 @@ static int add_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len) return err; } -static int remove_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) { + struct mgmt_cp_remove_uuid *cp = data; struct list_head *p, *n; - struct mgmt_cp_remove_uuid *cp; struct hci_dev *hdev; u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int err, found; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -983,15 +968,12 @@ static int remove_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len) return err; } -static int set_dev_class(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_set_dev_class *cp; + struct mgmt_cp_set_dev_class *cp = data; int err; - cp = (void *) data; - BT_DBG("request for hci%u", index); if (len != sizeof(*cp)) @@ -1026,16 +1008,13 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data, return err; } -static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_load_link_keys *cp; + struct mgmt_cp_load_link_keys *cp = data; u16 key_count, expected_len; int i; - cp = (void *) data; - if (len < sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, MGMT_STATUS_INVALID_PARAMS); @@ -1085,19 +1064,16 @@ static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, return 0; } -static int remove_keys(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int remove_keys(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_remove_keys *cp; + struct mgmt_cp_remove_keys *cp = data; struct mgmt_rp_remove_keys rp; struct hci_cp_disconnect dc; struct pending_cmd *cmd; struct hci_conn *conn; int err; - cp = (void *) data; - if (len != sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, MGMT_STATUS_INVALID_PARAMS); @@ -1154,10 +1130,10 @@ static int remove_keys(struct sock *sk, u16 index, unsigned char *data, return err; } -static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int disconnect(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_disconnect *cp; + struct mgmt_cp_disconnect *cp = data; struct hci_cp_disconnect dc; struct pending_cmd *cmd; struct hci_conn *conn; @@ -1165,8 +1141,6 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len) BT_DBG(""); - cp = (void *) data; - if (len != sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_DISCONNECT, MGMT_STATUS_INVALID_PARAMS); @@ -1314,12 +1288,11 @@ static int send_pin_code_neg_reply(struct sock *sk, u16 index, return err; } -static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; struct hci_conn *conn; - struct mgmt_cp_pin_code_reply *cp; + struct mgmt_cp_pin_code_reply *cp = data; struct mgmt_cp_pin_code_neg_reply ncp; struct hci_cp_pin_code_reply reply; struct pending_cmd *cmd; @@ -1327,8 +1300,6 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, BT_DBG(""); - cp = (void *) data; - if (len != sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_INVALID_PARAMS); @@ -1366,7 +1337,8 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, + len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1387,17 +1359,14 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, return err; } -static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int pin_code_neg_reply(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_pin_code_neg_reply *cp; + struct mgmt_cp_pin_code_neg_reply *cp = data; int err; BT_DBG(""); - cp = (void *) data; - if (len != sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, MGMT_STATUS_INVALID_PARAMS); @@ -1424,16 +1393,13 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data, return err; } -static int set_io_capability(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int set_io_capability(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_set_io_capability *cp; + struct mgmt_cp_set_io_capability *cp = data; BT_DBG(""); - cp = (void *) data; - if (len != sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_SET_IO_CAPABILITY, MGMT_STATUS_INVALID_PARAMS); @@ -1508,10 +1474,10 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status) pairing_complete(cmd, status); } -static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) +static int pair_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_pair_device *cp; + struct mgmt_cp_pair_device *cp = data; struct mgmt_rp_pair_device rp; struct pending_cmd *cmd; u8 sec_level, auth_type; @@ -1520,8 +1486,6 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) BT_DBG(""); - cp = (void *) data; - if (len != sizeof(*cp)) return cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); @@ -1721,7 +1685,7 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_user_confirm_reply *cp = (void *) data; + struct mgmt_cp_user_confirm_reply *cp = data; BT_DBG(""); @@ -1752,7 +1716,7 @@ static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data, static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_user_passkey_reply *cp = (void *) data; + struct mgmt_cp_user_passkey_reply *cp = data; BT_DBG(""); @@ -1768,7 +1732,7 @@ static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_user_passkey_neg_reply *cp = (void *) data; + struct mgmt_cp_user_passkey_neg_reply *cp = data; BT_DBG(""); @@ -1781,10 +1745,10 @@ static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, HCI_OP_USER_PASSKEY_NEG_REPLY, 0); } -static int set_local_name(struct sock *sk, u16 index, unsigned char *data, +static int set_local_name(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_set_local_name *mgmt_cp = (void *) data; + struct mgmt_cp_set_local_name *mgmt_cp = data; struct hci_cp_write_local_name hci_cp; struct hci_dev *hdev; struct pending_cmd *cmd; @@ -1803,7 +1767,8 @@ static int set_local_name(struct sock *sk, u16 index, unsigned char *data, hci_dev_lock(hdev); - cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, len); + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, + len); if (!cmd) { err = -ENOMEM; goto failed; @@ -1872,11 +1837,11 @@ static int read_local_oob_data(struct sock *sk, u16 index) return err; } -static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int add_remote_oob_data(struct sock *sk, u16 index, void *data, + u16 len) { struct hci_dev *hdev; - struct mgmt_cp_add_remote_oob_data *cp = (void *) data; + struct mgmt_cp_add_remote_oob_data *cp = data; int err; BT_DBG("hci%u ", index); @@ -1908,10 +1873,10 @@ static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data, } static int remove_remote_oob_data(struct sock *sk, u16 index, - unsigned char *data, u16 len) + void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_remove_remote_oob_data *cp = (void *) data; + struct mgmt_cp_remove_remote_oob_data *cp = data; int err; BT_DBG("hci%u ", index); @@ -1942,9 +1907,9 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, } static int start_discovery(struct sock *sk, u16 index, - unsigned char *data, u16 len) + void *data, u16 len) { - struct mgmt_cp_start_discovery *cp = (void *) data; + struct mgmt_cp_start_discovery *cp = data; struct pending_cmd *cmd; struct hci_dev *hdev; int err; @@ -2054,10 +2019,9 @@ static int stop_discovery(struct sock *sk, u16 index) return err; } -static int confirm_name(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int confirm_name(struct sock *sk, u16 index, void *data, u16 len) { - struct mgmt_cp_confirm_name *cp = (void *) data; + struct mgmt_cp_confirm_name *cp = data; struct inquiry_entry *e; struct hci_dev *hdev; int err; @@ -2104,11 +2068,10 @@ static int confirm_name(struct sock *sk, u16 index, unsigned char *data, return err; } -static int block_device(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int block_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_block_device *cp = (void *) data; + struct mgmt_cp_block_device *cp = data; int err; BT_DBG("hci%u", index); @@ -2138,11 +2101,10 @@ static int block_device(struct sock *sk, u16 index, unsigned char *data, return err; } -static int unblock_device(struct sock *sk, u16 index, unsigned char *data, - u16 len) +static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_unblock_device *cp = (void *) data; + struct mgmt_cp_unblock_device *cp = data; int err; BT_DBG("hci%u", index); @@ -2174,10 +2136,10 @@ static int unblock_device(struct sock *sk, u16 index, unsigned char *data, } static int set_fast_connectable(struct sock *sk, u16 index, - unsigned char *data, u16 len) + void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_mode *cp = (void *) data; + struct mgmt_mode *cp = data; struct hci_cp_write_page_scan_activity acp; u8 type; int err; @@ -2231,7 +2193,8 @@ static int set_fast_connectable(struct sock *sk, u16 index, int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) { - unsigned char *buf; + void *buf; + u8 *cp; struct mgmt_hdr *hdr; u16 opcode, index, len; int err; @@ -2250,7 +2213,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) goto done; } - hdr = (struct mgmt_hdr *) buf; + hdr = buf; opcode = get_unaligned_le16(&hdr->opcode); index = get_unaligned_le16(&hdr->index); len = get_unaligned_le16(&hdr->len); @@ -2260,6 +2223,8 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) goto done; } + cp = buf + sizeof(*hdr); + switch (opcode) { case MGMT_OP_READ_VERSION: err = read_version(sk); @@ -2271,98 +2236,94 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) err = read_controller_info(sk, index); break; case MGMT_OP_SET_POWERED: - err = set_powered(sk, index, buf + sizeof(*hdr), len); + err = set_powered(sk, index, cp, len); break; case MGMT_OP_SET_DISCOVERABLE: - err = set_discoverable(sk, index, buf + sizeof(*hdr), len); + err = set_discoverable(sk, index, cp, len); break; case MGMT_OP_SET_CONNECTABLE: - err = set_connectable(sk, index, buf + sizeof(*hdr), len); + err = set_connectable(sk, index, cp, len); break; case MGMT_OP_SET_FAST_CONNECTABLE: - err = set_fast_connectable(sk, index, buf + sizeof(*hdr), - len); + err = set_fast_connectable(sk, index, cp, len); break; case MGMT_OP_SET_PAIRABLE: - err = set_pairable(sk, index, buf + sizeof(*hdr), len); + err = set_pairable(sk, index, cp, len); break; case MGMT_OP_ADD_UUID: - err = add_uuid(sk, index, buf + sizeof(*hdr), len); + err = add_uuid(sk, index, cp, len); break; case MGMT_OP_REMOVE_UUID: - err = remove_uuid(sk, index, buf + sizeof(*hdr), len); + err = remove_uuid(sk, index, cp, len); break; case MGMT_OP_SET_DEV_CLASS: - err = set_dev_class(sk, index, buf + sizeof(*hdr), len); + err = set_dev_class(sk, index, cp, len); break; case MGMT_OP_LOAD_LINK_KEYS: - err = load_link_keys(sk, index, buf + sizeof(*hdr), len); + err = load_link_keys(sk, index, cp, len); break; case MGMT_OP_REMOVE_KEYS: - err = remove_keys(sk, index, buf + sizeof(*hdr), len); + err = remove_keys(sk, index, cp, len); break; case MGMT_OP_DISCONNECT: - err = disconnect(sk, index, buf + sizeof(*hdr), len); + err = disconnect(sk, index, cp, len); break; case MGMT_OP_GET_CONNECTIONS: err = get_connections(sk, index); break; case MGMT_OP_PIN_CODE_REPLY: - err = pin_code_reply(sk, index, buf + sizeof(*hdr), len); + err = pin_code_reply(sk, index, cp, len); break; case MGMT_OP_PIN_CODE_NEG_REPLY: - err = pin_code_neg_reply(sk, index, buf + sizeof(*hdr), len); + err = pin_code_neg_reply(sk, index, cp, len); break; case MGMT_OP_SET_IO_CAPABILITY: - err = set_io_capability(sk, index, buf + sizeof(*hdr), len); + err = set_io_capability(sk, index, cp, len); break; case MGMT_OP_PAIR_DEVICE: - err = pair_device(sk, index, buf + sizeof(*hdr), len); + err = pair_device(sk, index, cp, len); break; case MGMT_OP_CANCEL_PAIR_DEVICE: err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len); break; case MGMT_OP_USER_CONFIRM_REPLY: - err = user_confirm_reply(sk, index, buf + sizeof(*hdr), len); + err = user_confirm_reply(sk, index, cp, len); break; case MGMT_OP_USER_CONFIRM_NEG_REPLY: - err = user_confirm_neg_reply(sk, index, buf + sizeof(*hdr), - len); + err = user_confirm_neg_reply(sk, index, cp, len); break; case MGMT_OP_USER_PASSKEY_REPLY: - err = user_passkey_reply(sk, index, buf + sizeof(*hdr), len); + err = user_passkey_reply(sk, index, cp, len); break; case MGMT_OP_USER_PASSKEY_NEG_REPLY: - err = user_passkey_neg_reply(sk, index, buf + sizeof(*hdr), - len); + err = user_passkey_neg_reply(sk, index, cp, len); break; case MGMT_OP_SET_LOCAL_NAME: - err = set_local_name(sk, index, buf + sizeof(*hdr), len); + err = set_local_name(sk, index, cp, len); break; case MGMT_OP_READ_LOCAL_OOB_DATA: err = read_local_oob_data(sk, index); break; case MGMT_OP_ADD_REMOTE_OOB_DATA: - err = add_remote_oob_data(sk, index, buf + sizeof(*hdr), len); + err = add_remote_oob_data(sk, index, cp, len); break; case MGMT_OP_REMOVE_REMOTE_OOB_DATA: - err = remove_remote_oob_data(sk, index, buf + sizeof(*hdr), - len); + err = remove_remote_oob_data(sk, index, cp, len); break; case MGMT_OP_START_DISCOVERY: - err = start_discovery(sk, index, buf + sizeof(*hdr), len); + err = start_discovery(sk, index, cp, len); break; case MGMT_OP_STOP_DISCOVERY: err = stop_discovery(sk, index); break; case MGMT_OP_CONFIRM_NAME: - err = confirm_name(sk, index, buf + sizeof(*hdr), len); + err = confirm_name(sk, index, cp, len); break; case MGMT_OP_BLOCK_DEVICE: - err = block_device(sk, index, buf + sizeof(*hdr), len); + err = block_device(sk, index, cp, len); break; case MGMT_OP_UNBLOCK_DEVICE: - err = unblock_device(sk, index, buf + sizeof(*hdr), len); + err = unblock_device(sk, index, cp, len); break; default: BT_DBG("Unknown op %u", opcode); -- GitLab From b899efaf9b26cadb084752862490b4fc44bc3169 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:08:00 -0300 Subject: [PATCH 0633/1846] Bluetooth: Add new structures for handling SMP Long Term Keys This includes a new list for storing the keys and a new structure used to represent each key. Some notes: authenticated is used to identify that the key may be used to setup a HIGH security link. As the same list is used to store both the STK's and the LTK's the type field is used so we can separate between those two types of keys and if the key should be used when in the master or slave role. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 5 +++++ include/net/bluetooth/hci_core.h | 16 ++++++++++++++++ net/bluetooth/hci_core.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index cb9097acbf44..83f045a515a0 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -274,6 +274,11 @@ enum { #define HCI_LK_SMP_LTK 0x81 #define HCI_LK_SMP_IRK 0x82 #define HCI_LK_SMP_CSRK 0x83 +/* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */ +#define HCI_SMP_STK 0x80 +#define HCI_SMP_STK_SLAVE 0x81 +#define HCI_SMP_LTK 0x82 +#define HCI_SMP_LTK_SLAVE 0x83 /* ---- HCI Error Codes ---- */ #define HCI_ERROR_AUTH_FAILURE 0x05 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 896d9e4955fc..c998176a503d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -88,6 +88,18 @@ struct bt_uuid { u8 svc_hint; }; +struct smp_ltk { + struct list_head list; + bdaddr_t bdaddr; + u8 bdaddr_type; + u8 authenticated; + u8 type; + u8 enc_size; + __le16 ediv; + u8 rand[8]; + u8 val[16]; +} __packed; + struct key_master_id { __le16 ediv; u8 rand[8]; @@ -239,6 +251,8 @@ struct hci_dev { struct list_head link_keys; + struct list_head long_term_keys; + struct list_head remote_oob_data; struct list_head adv_entries; @@ -647,8 +661,10 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); struct link_key *hci_find_link_key_type(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); +int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]); +int hci_smp_ltks_clear(struct hci_dev *hdev); int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_remote_oob_data_clear(struct hci_dev *hdev); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 45e2d2a72b15..a28e637152fe 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1163,6 +1163,18 @@ int hci_link_keys_clear(struct hci_dev *hdev) return 0; } +int hci_smp_ltks_clear(struct hci_dev *hdev) +{ + struct smp_ltk *k, *tmp; + + list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) { + list_del(&k->list); + kfree(k); + } + + return 0; +} + struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) { struct link_key *k; @@ -1355,6 +1367,23 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) return 0; } +int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr) +{ + struct smp_ltk *k, *tmp; + + list_for_each_entry_safe(k, tmp, &hdev->long_term_keys, list) { + if (bacmp(bdaddr, &k->bdaddr)) + continue; + + BT_DBG("%s removing %s", hdev->name, batostr(bdaddr)); + + list_del(&k->list); + kfree(k); + } + + return 0; +} + /* HCI command timer function */ static void hci_cmd_timer(unsigned long arg) { @@ -1638,6 +1667,7 @@ int hci_register_dev(struct hci_dev *hdev) INIT_LIST_HEAD(&hdev->uuids); INIT_LIST_HEAD(&hdev->link_keys); + INIT_LIST_HEAD(&hdev->long_term_keys); INIT_LIST_HEAD(&hdev->remote_oob_data); @@ -1739,6 +1769,7 @@ void hci_unregister_dev(struct hci_dev *hdev) hci_blacklist_clear(hdev); hci_uuids_clear(hdev); hci_link_keys_clear(hdev); + hci_smp_ltks_clear(hdev); hci_remote_oob_data_clear(hdev); hci_adv_entries_clear(hdev); hci_dev_unlock(hdev); -- GitLab From c9839a11c0e460a2457e7cac76650d07773e6c3b Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:08:01 -0300 Subject: [PATCH 0634/1846] Bluetooth: Use the updated key structures for handling LTKs This updates all the users of the older way, that was using the link_keys list to store the SMP keys, to use the new way. This includes defining new types for the keys, we have a type for each combination of STK/LTK and Master/Slave. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 11 ++--- net/bluetooth/hci_core.c | 76 ++++++++++++++------------------ net/bluetooth/hci_event.c | 11 ++++- net/bluetooth/smp.c | 38 +++++++++------- 4 files changed, 71 insertions(+), 65 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index c998176a503d..2649caf4db96 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -658,12 +658,13 @@ int hci_link_keys_clear(struct hci_dev *hdev); struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); -struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); -struct link_key *hci_find_link_key_type(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 type); +struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); +int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, + int new_key, u8 authenticated, u8 tk[16], + u8 enc_size, u16 ediv, u8 rand[8]); +struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 addr_type); int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, - u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]); int hci_smp_ltks_clear(struct hci_dev *hdev); int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a28e637152fe..84b7a9e4f2f6 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1222,41 +1222,35 @@ static int hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn, return 0; } -struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) +struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) { - struct link_key *k; - - list_for_each_entry(k, &hdev->link_keys, list) { - struct key_master_id *id; + struct smp_ltk *k; - if (k->type != HCI_LK_SMP_LTK) + list_for_each_entry(k, &hdev->long_term_keys, list) { + if (k->ediv != ediv || + memcmp(rand, k->rand, sizeof(k->rand))) continue; - if (k->dlen != sizeof(*id)) - continue; - - id = (void *) &k->data; - if (id->ediv == ediv && - (memcmp(rand, id->rand, sizeof(id->rand)) == 0)) - return k; + return k; } return NULL; } EXPORT_SYMBOL(hci_find_ltk); -struct link_key *hci_find_link_key_type(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 type) +struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 addr_type) { - struct link_key *k; + struct smp_ltk *k; - list_for_each_entry(k, &hdev->link_keys, list) - if (k->type == type && bacmp(bdaddr, &k->bdaddr) == 0) + list_for_each_entry(k, &hdev->long_term_keys, list) + if (addr_type == k->bdaddr_type && + bacmp(bdaddr, &k->bdaddr) == 0) return k; return NULL; } -EXPORT_SYMBOL(hci_find_link_key_type); +EXPORT_SYMBOL(hci_find_ltk_by_addr); int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) @@ -1313,40 +1307,36 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, return 0; } -int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, - u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]) +int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, + int new_key, u8 authenticated, u8 tk[16], + u8 enc_size, u16 ediv, u8 rand[8]) { - struct link_key *key, *old_key; - struct key_master_id *id; - u8 old_key_type; + struct smp_ltk *key, *old_key; - BT_DBG("%s addr %s", hdev->name, batostr(bdaddr)); + if (!(type & HCI_SMP_STK) && !(type & HCI_SMP_LTK)) + return 0; - old_key = hci_find_link_key_type(hdev, bdaddr, HCI_LK_SMP_LTK); - if (old_key) { + old_key = hci_find_ltk_by_addr(hdev, bdaddr, addr_type); + if (old_key) key = old_key; - old_key_type = old_key->type; - } else { - key = kzalloc(sizeof(*key) + sizeof(*id), GFP_ATOMIC); + else { + key = kzalloc(sizeof(*key), GFP_ATOMIC); if (!key) return -ENOMEM; - list_add(&key->list, &hdev->link_keys); - old_key_type = 0xff; + list_add(&key->list, &hdev->long_term_keys); } - key->dlen = sizeof(*id); - bacpy(&key->bdaddr, bdaddr); - memcpy(key->val, ltk, sizeof(key->val)); - key->type = HCI_LK_SMP_LTK; - key->pin_len = key_size; - - id = (void *) &key->data; - id->ediv = ediv; - memcpy(id->rand, rand, sizeof(id->rand)); + key->bdaddr_type = addr_type; + memcpy(key->val, tk, sizeof(key->val)); + key->authenticated = authenticated; + key->ediv = ediv; + key->enc_size = enc_size; + key->type = type; + memcpy(key->rand, rand, sizeof(key->rand)); - if (new_key) - mgmt_new_link_key(hdev, key, old_key_type); + if (!new_key) + return 0; return 0; } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a86f82b11316..23dbb31f0423 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3256,7 +3256,7 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev, struct hci_cp_le_ltk_reply cp; struct hci_cp_le_ltk_neg_reply neg; struct hci_conn *conn; - struct link_key *ltk; + struct smp_ltk *ltk; BT_DBG("%s handle %d", hdev->name, cpu_to_le16(ev->handle)); @@ -3272,10 +3272,17 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev, memcpy(cp.ltk, ltk->val, sizeof(ltk->val)); cp.handle = cpu_to_le16(conn->handle); - conn->pin_length = ltk->pin_len; + + if (ltk->authenticated) + conn->sec_level = BT_SECURITY_HIGH; hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); + if (ltk->type & HCI_SMP_STK) { + list_del(<k->list); + kfree(ltk); + } + hci_dev_unlock(hdev); return; diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 9ff56e18d99b..0563f737779a 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -475,8 +475,9 @@ static void random_work(struct work_struct *work) memset(stk + smp->enc_key_size, 0, SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); - hci_add_ltk(hcon->hdev, 0, conn->dst, smp->enc_key_size, - ediv, rand, stk); + hci_add_ltk(hcon->hdev, conn->dst, hcon->dst_type, + HCI_SMP_STK_SLAVE, 0, 0, stk, + smp->enc_key_size, ediv, rand); } return; @@ -701,22 +702,18 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) static u8 smp_ltk_encrypt(struct l2cap_conn *conn) { - struct link_key *key; - struct key_master_id *master; + struct smp_ltk *key; struct hci_conn *hcon = conn->hcon; - key = hci_find_link_key_type(hcon->hdev, conn->dst, - HCI_LK_SMP_LTK); + key = hci_find_ltk_by_addr(hcon->hdev, conn->dst, hcon->dst_type); if (!key) return 0; if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) return 1; - master = (void *) key->data; - hci_le_start_enc(hcon, master->ediv, master->rand, - key->val); - hcon->enc_key_size = key->pin_len; + hci_le_start_enc(hcon, key->ediv, key->rand, key->val); + hcon->enc_key_size = key->enc_size; return 1; @@ -819,13 +816,19 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) { struct smp_cmd_master_ident *rp = (void *) skb->data; struct smp_chan *smp = conn->smp_chan; + struct hci_dev *hdev = conn->hcon->hdev; + struct hci_conn *hcon = conn->hcon; + u8 authenticated; skb_pull(skb, sizeof(*rp)); - hci_add_ltk(conn->hcon->hdev, 1, conn->dst, smp->enc_key_size, - rp->ediv, rp->rand, smp->tk); - + hci_dev_lock(hdev); + authenticated = (conn->hcon->sec_level == BT_SECURITY_HIGH); + hci_add_ltk(conn->hcon->hdev, conn->dst, hcon->dst_type, + HCI_SMP_LTK, 1, authenticated, smp->tk, + smp->enc_key_size, rp->ediv, rp->rand); smp_distribute_keys(conn, 1); + hci_dev_unlock(hdev); return 0; } @@ -935,6 +938,8 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) if (*keydist & SMP_DIST_ENC_KEY) { struct smp_cmd_encrypt_info enc; struct smp_cmd_master_ident ident; + struct hci_conn *hcon = conn->hcon; + u8 authenticated; __le16 ediv; get_random_bytes(enc.ltk, sizeof(enc.ltk)); @@ -943,8 +948,11 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) smp_send_cmd(conn, SMP_CMD_ENCRYPT_INFO, sizeof(enc), &enc); - hci_add_ltk(conn->hcon->hdev, 1, conn->dst, smp->enc_key_size, - ediv, ident.rand, enc.ltk); + authenticated = hcon->sec_level == BT_SECURITY_HIGH; + hci_add_ltk(conn->hcon->hdev, conn->dst, hcon->dst_type, + HCI_SMP_LTK_SLAVE, 1, authenticated, + enc.ltk, smp->enc_key_size, + ediv, ident.rand); ident.ediv = cpu_to_le16(ediv); -- GitLab From 346af67b8d116f01ef696fd47959a55deb2db8b6 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:08:02 -0300 Subject: [PATCH 0635/1846] Bluetooth: Add MGMT handlers for dealing with SMP LTK's This adds a method to notify that a new LTK is available and a handler to store keys coming from userspace into the kernel LTK list. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 2 + net/bluetooth/mgmt.c | 80 ++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 2649caf4db96..7793fc644b87 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -995,6 +995,8 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering); int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr); int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr); +int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); + /* HCI info for socket */ #define hci_pi(sk) ((struct hci_pinfo *) sk) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ad8986276848..fd0b08115f2e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2191,6 +2191,60 @@ static int set_fast_connectable(struct sock *sk, u16 index, return err; } +static int load_long_term_keys(struct sock *sk, u16 index, + void *cp_data, u16 len) +{ + struct hci_dev *hdev; + struct mgmt_cp_load_long_term_keys *cp = cp_data; + u16 key_count, expected_len; + int i; + + if (len < sizeof(*cp)) + return cmd_status(sk, index, MGMT_OP_LOAD_LONG_TERM_KEYS, + EINVAL); + + key_count = get_unaligned_le16(&cp->key_count); + + expected_len = sizeof(*cp) + key_count * + sizeof(struct mgmt_ltk_info); + if (expected_len != len) { + BT_ERR("load_keys: expected %u bytes, got %u bytes", + len, expected_len); + return cmd_status(sk, index, MGMT_OP_LOAD_LONG_TERM_KEYS, + EINVAL); + } + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_LOAD_LONG_TERM_KEYS, + ENODEV); + + BT_DBG("hci%u key_count %u", index, key_count); + + hci_dev_lock(hdev); + + hci_smp_ltks_clear(hdev); + + for (i = 0; i < key_count; i++) { + struct mgmt_ltk_info *key = &cp->keys[i]; + u8 type; + + if (key->master) + type = HCI_SMP_LTK; + else + type = HCI_SMP_LTK_SLAVE; + + hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type, + type, 0, key->authenticated, key->val, + key->enc_size, key->ediv, key->rand); + } + + hci_dev_unlock(hdev); + hci_dev_put(hdev); + + return 0; +} + int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) { void *buf; @@ -2325,6 +2379,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_UNBLOCK_DEVICE: err = unblock_device(sk, index, cp, len); break; + case MGMT_OP_LOAD_LONG_TERM_KEYS: + err = load_long_term_keys(sk, index, cp, len); + break; default: BT_DBG("Unknown op %u", opcode); err = cmd_status(sk, index, opcode, @@ -2478,6 +2535,29 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); } +int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent) +{ + struct mgmt_ev_new_long_term_key ev; + + memset(&ev, 0, sizeof(ev)); + + ev.store_hint = persistent; + bacpy(&ev.key.addr.bdaddr, &key->bdaddr); + ev.key.addr.type = key->bdaddr_type; + ev.key.authenticated = key->authenticated; + ev.key.enc_size = key->enc_size; + ev.key.ediv = key->ediv; + + if (key->type == HCI_SMP_LTK) + ev.key.master = 1; + + memcpy(ev.key.rand, key->rand, sizeof(key->rand)); + memcpy(ev.key.val, key->val, sizeof(key->val)); + + return mgmt_event(MGMT_EV_NEW_LONG_TERM_KEY, hdev, + &ev, sizeof(ev), NULL); +} + int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *name, u8 name_len, u8 *dev_class) -- GitLab From b0dbfb46ba0c0d2fe4c90e2046f7b36275763a7e Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:08:03 -0300 Subject: [PATCH 0636/1846] Bluetooth: Add support for removing LTK's when pairing is removed Instead of having a separated command for removing SMP keys, we use the Remove Keys command to remove *all* keys. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index fd0b08115f2e..9e5dead1dbef 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1089,6 +1089,12 @@ static int remove_keys(struct sock *sk, u16 index, void *data, u16 len) bacpy(&rp.bdaddr, &cp->bdaddr); rp.status = MGMT_STATUS_FAILED; + err = hci_remove_ltk(hdev, &cp->bdaddr); + if (err < 0) { + err = cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, -err); + goto unlock; + } + err = hci_remove_link_key(hdev, &cp->bdaddr); if (err < 0) { rp.status = MGMT_STATUS_NOT_PAIRED; -- GitLab From f9c5f9ddcfc404b5d4c079452755337d84c97707 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:08:04 -0300 Subject: [PATCH 0637/1846] Bluetooth: Clean up structures left unused With the use of the new structures and lists for the SMP LTK's we may remove some code that is now unused. No need to have extra fields of information inside link_key now that it is only used for Link Keys. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 4 ---- include/net/bluetooth/hci_core.h | 16 ---------------- 2 files changed, 20 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 83f045a515a0..1b634e126878 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -270,10 +270,6 @@ enum { #define HCI_LK_UNAUTH_COMBINATION 0x04 #define HCI_LK_AUTH_COMBINATION 0x05 #define HCI_LK_CHANGED_COMBINATION 0x06 -/* The spec doesn't define types for SMP keys */ -#define HCI_LK_SMP_LTK 0x81 -#define HCI_LK_SMP_IRK 0x82 -#define HCI_LK_SMP_CSRK 0x83 /* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */ #define HCI_SMP_STK 0x80 #define HCI_SMP_STK_SLAVE 0x81 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7793fc644b87..9751da78341d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -100,28 +100,12 @@ struct smp_ltk { u8 val[16]; } __packed; -struct key_master_id { - __le16 ediv; - u8 rand[8]; -} __packed; - -struct link_key_data { - bdaddr_t bdaddr; - u8 type; - u8 val[16]; - u8 pin_len; - u8 dlen; - u8 data[0]; -} __packed; - struct link_key { struct list_head list; bdaddr_t bdaddr; u8 type; u8 val[16]; u8 pin_len; - u8 dlen; - u8 data[0]; }; struct oob_data { -- GitLab From 261cc5aa9e54aac633dcc3b6469739cb6e23e21a Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 2 Feb 2012 21:08:05 -0300 Subject: [PATCH 0638/1846] Bluetooth: Add support for notifying userspace of new LTK's If we want to have proper pairing support over LE we need to inform userspace that a new LTK is available, so userspace can store that key permanently. Signed-off-by: Vinicius Costa Gomes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 84b7a9e4f2f6..76dc1538e321 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1338,6 +1338,9 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, if (!new_key) return 0; + if (type & HCI_SMP_LTK) + mgmt_new_ltk(hdev, key, 1); + return 0; } -- GitLab From b71d385a18cd4516c62d0198c9ec37e658112f75 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 3 Feb 2012 16:27:54 +0200 Subject: [PATCH 0639/1846] Bluetooth: Recalculate sched HCI blk/pkt flow ctrl Split HCI scheduling for block and packet flow control. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 85 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 76dc1538e321..9a56a4084482 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2384,18 +2384,19 @@ static void hci_prio_recalculate(struct hci_dev *hdev, __u8 type) } -static inline void hci_sched_acl(struct hci_dev *hdev) +static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb) +{ + /* Calculate count of blocks used by this packet */ + return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len); +} + +static inline void hci_sched_acl_pkt(struct hci_dev *hdev) { struct hci_chan *chan; struct sk_buff *skb; int quote; unsigned int cnt; - BT_DBG("%s", hdev->name); - - if (!hci_conn_num(hdev, ACL_LINK)) - return; - if (!test_bit(HCI_RAW, &hdev->flags)) { /* ACL tx timeout must be longer than maximum * link supervision timeout (40.9 seconds) */ @@ -2435,6 +2436,78 @@ static inline void hci_sched_acl(struct hci_dev *hdev) hci_prio_recalculate(hdev, ACL_LINK); } +static inline void hci_sched_acl_blk(struct hci_dev *hdev) +{ + struct hci_chan *chan; + struct sk_buff *skb; + int quote; + unsigned int cnt; + + if (!test_bit(HCI_RAW, &hdev->flags)) { + /* ACL tx timeout must be longer than maximum + * link supervision timeout (40.9 seconds) */ + if (!hdev->block_cnt && time_after(jiffies, hdev->acl_last_tx + + msecs_to_jiffies(HCI_ACL_TX_TIMEOUT))) + hci_link_tx_to(hdev, ACL_LINK); + } + + cnt = hdev->block_cnt; + + while (hdev->block_cnt > 0 && + (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { + u32 priority = (skb_peek(&chan->data_q))->priority; + while (quote > 0 && (skb = skb_peek(&chan->data_q))) { + int blocks; + + BT_DBG("chan %p skb %p len %d priority %u", chan, skb, + skb->len, skb->priority); + + /* Stop if priority has changed */ + if (skb->priority < priority) + break; + + skb = skb_dequeue(&chan->data_q); + + blocks = __get_blocks(hdev, skb); + if (blocks > hdev->block_cnt) + return; + + hci_conn_enter_active_mode(chan->conn, + bt_cb(skb)->force_active); + + hci_send_frame(skb); + hdev->acl_last_tx = jiffies; + + hdev->block_cnt -= blocks; + quote -= blocks; + + chan->sent += blocks; + chan->conn->sent += blocks; + } + } + + if (cnt != hdev->block_cnt) + hci_prio_recalculate(hdev, ACL_LINK); +} + +static inline void hci_sched_acl(struct hci_dev *hdev) +{ + BT_DBG("%s", hdev->name); + + if (!hci_conn_num(hdev, ACL_LINK)) + return; + + switch (hdev->flow_ctl_mode) { + case HCI_FLOW_CTL_MODE_PACKET_BASED: + hci_sched_acl_pkt(hdev); + break; + + case HCI_FLOW_CTL_MODE_BLOCK_BASED: + hci_sched_acl_blk(hdev); + break; + } +} + /* Schedule SCO */ static inline void hci_sched_sco(struct hci_dev *hdev) { -- GitLab From 63d2bc1b9a4d77f90b9719c3ff2570a274a7a22f Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 3 Feb 2012 16:27:55 +0200 Subject: [PATCH 0640/1846] Bluetooth: Helper removes duplicated code Use __check_timout helper to remove duplicated code Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9a56a4084482..95eeae59812d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2390,22 +2390,25 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb) return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len); } -static inline void hci_sched_acl_pkt(struct hci_dev *hdev) +static inline void __check_timeout(struct hci_dev *hdev, unsigned int cnt) { - struct hci_chan *chan; - struct sk_buff *skb; - int quote; - unsigned int cnt; - if (!test_bit(HCI_RAW, &hdev->flags)) { /* ACL tx timeout must be longer than maximum * link supervision timeout (40.9 seconds) */ - if (!hdev->acl_cnt && time_after(jiffies, hdev->acl_last_tx + + if (!cnt && time_after(jiffies, hdev->acl_last_tx + msecs_to_jiffies(HCI_ACL_TX_TIMEOUT))) hci_link_tx_to(hdev, ACL_LINK); } +} - cnt = hdev->acl_cnt; +static inline void hci_sched_acl_pkt(struct hci_dev *hdev) +{ + unsigned int cnt = hdev->acl_cnt; + struct hci_chan *chan; + struct sk_buff *skb; + int quote; + + __check_timeout(hdev, cnt); while (hdev->acl_cnt && (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { @@ -2438,20 +2441,12 @@ static inline void hci_sched_acl_pkt(struct hci_dev *hdev) static inline void hci_sched_acl_blk(struct hci_dev *hdev) { + unsigned int cnt = hdev->block_cnt; struct hci_chan *chan; struct sk_buff *skb; int quote; - unsigned int cnt; - - if (!test_bit(HCI_RAW, &hdev->flags)) { - /* ACL tx timeout must be longer than maximum - * link supervision timeout (40.9 seconds) */ - if (!hdev->block_cnt && time_after(jiffies, hdev->acl_last_tx + - msecs_to_jiffies(HCI_ACL_TX_TIMEOUT))) - hci_link_tx_to(hdev, ACL_LINK); - } - cnt = hdev->block_cnt; + __check_timeout(hdev, cnt); while (hdev->block_cnt > 0 && (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { -- GitLab From 8af59467412b4b61850d3ccb3737c09ecc6dc100 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 3 Feb 2012 21:29:40 +0200 Subject: [PATCH 0641/1846] Bluetooth: Add missing QUIRK_NO_RESET test to hci_dev_do_close We should only perform a reset in hci_dev_do_close if the HCI_QUIRK_NO_RESET flag is set (since in such a case a reset will not be performed when initializing the device). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 95eeae59812d..8bffd3eb344d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -767,7 +767,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) /* Reset device */ skb_queue_purge(&hdev->cmd_q); atomic_set(&hdev->cmd_cnt, 1); - if (!test_bit(HCI_RAW, &hdev->flags)) { + if (!test_bit(HCI_RAW, &hdev->flags) && + test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks)) { set_bit(HCI_INIT, &hdev->flags); __hci_request(hdev, hci_reset_req, 0, msecs_to_jiffies(250)); -- GitLab From c599008f8f999dab8cb4a6404be99bdc4716ba15 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 3 Feb 2012 17:47:57 -0300 Subject: [PATCH 0642/1846] Bluetooth: LE scan should send Discovering events Send MGMT Discovering events once LE scan starts/stops so the userspace can track when local adapters are discovering LE devices. This way, we also keep the same behavior of inquiry which sends MGMT Discovering events once inquiry starts/stops even if it is triggered by an external tool (e.g. hcitool). Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 2 ++ net/bluetooth/hci_event.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9751da78341d..bf2ef5667887 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -61,6 +61,7 @@ struct discovery_state { DISCOVERY_STOPPED, DISCOVERY_STARTING, DISCOVERY_INQUIRY, + DISCOVERY_LE_SCAN, DISCOVERY_RESOLVING, DISCOVERY_STOPPING, } state; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8bffd3eb344d..1705d9372725 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -361,6 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev) struct discovery_state *discov = &hdev->discovery; if (discov->state == DISCOVERY_INQUIRY || + discov->state == DISCOVERY_LE_SCAN || discov->state == DISCOVERY_RESOLVING) return true; @@ -381,6 +382,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) case DISCOVERY_STARTING: break; case DISCOVERY_INQUIRY: + case DISCOVERY_LE_SCAN: mgmt_discovering(hdev, 1); break; case DISCOVERY_RESOLVING: diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 23dbb31f0423..8971c18205c0 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1056,12 +1056,17 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, hci_dev_lock(hdev); hci_adv_entries_clear(hdev); + hci_discovery_set_state(hdev, DISCOVERY_LE_SCAN); hci_dev_unlock(hdev); break; case LE_SCANNING_DISABLED: clear_bit(HCI_LE_SCAN, &hdev->dev_flags); + hci_dev_lock(hdev); + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + hci_dev_unlock(hdev); + schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT); break; -- GitLab From 6fbe195dc41c4fae1fa7aca1a38c888de1d24e2d Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 3 Feb 2012 17:47:58 -0300 Subject: [PATCH 0643/1846] Bluetooth: Minor code refactoring This patch does a trivial code refacting in hci_discovery_active. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 1705d9372725..1175f27bd445 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -360,12 +360,15 @@ bool hci_discovery_active(struct hci_dev *hdev) { struct discovery_state *discov = &hdev->discovery; - if (discov->state == DISCOVERY_INQUIRY || - discov->state == DISCOVERY_LE_SCAN || - discov->state == DISCOVERY_RESOLVING) + switch (discov->state) { + case DISCOVERY_INQUIRY: + case DISCOVERY_LE_SCAN: + case DISCOVERY_RESOLVING: return true; - return false; + default: + return false; + } } void hci_discovery_set_state(struct hci_dev *hdev, int state) -- GitLab From 7ba8b4be38e7c83b2b13333a82a0ecde921a7390 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 3 Feb 2012 17:47:59 -0300 Subject: [PATCH 0644/1846] Bluetooth: Add hci_do_le_scan() This patch adds to hci_core the hci_do_le_scan function which should be used to scan LE devices. In order to enable LE scan, hci_do_le_scan() sends commands (Set LE Scan Parameters and Set LE Scan Enable) to the controller and waits for its results. If commands were executed successfully a delayed work is scheduled to disable the ongoing scanning after some amount of time. This function blocks. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 8 ++++ net/bluetooth/hci_core.c | 74 ++++++++++++++++++++++++++++++++ net/bluetooth/hci_event.c | 13 ++++-- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index bf2ef5667887..3e70872bffea 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -122,6 +122,12 @@ struct adv_entry { u8 bdaddr_type; }; +struct le_scan_params { + u8 type; + u16 interval; + u16 window; +}; + #define NUM_REASSEMBLY 4 struct hci_dev { struct list_head list; @@ -261,6 +267,8 @@ struct hci_dev { unsigned long dev_flags; + struct delayed_work le_scan_disable; + int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 1175f27bd445..ae86cdd80ac0 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -759,6 +759,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) cancel_delayed_work(&hdev->service_cache); + cancel_delayed_work_sync(&hdev->le_scan_disable); + hci_dev_lock(hdev); inquiry_cache_flush(hdev); hci_conn_hash_flush(hdev); @@ -1596,6 +1598,76 @@ int hci_add_adv_entry(struct hci_dev *hdev, return 0; } +static void le_scan_param_req(struct hci_dev *hdev, unsigned long opt) +{ + struct le_scan_params *param = (struct le_scan_params *) opt; + struct hci_cp_le_set_scan_param cp; + + memset(&cp, 0, sizeof(cp)); + cp.type = param->type; + cp.interval = cpu_to_le16(param->interval); + cp.window = cpu_to_le16(param->window); + + hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_PARAM, sizeof(cp), &cp); +} + +static void le_scan_enable_req(struct hci_dev *hdev, unsigned long opt) +{ + struct hci_cp_le_set_scan_enable cp; + + memset(&cp, 0, sizeof(cp)); + cp.enable = 1; + + hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); +} + +static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, + u16 window, int timeout) +{ + long timeo = msecs_to_jiffies(3000); + struct le_scan_params param; + int err; + + BT_DBG("%s", hdev->name); + + if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) + return -EINPROGRESS; + + param.type = type; + param.interval = interval; + param.window = window; + + hci_req_lock(hdev); + + err = __hci_request(hdev, le_scan_param_req, (unsigned long) ¶m, + timeo); + if (!err) + err = __hci_request(hdev, le_scan_enable_req, 0, timeo); + + hci_req_unlock(hdev); + + if (err < 0) + return err; + + schedule_delayed_work(&hdev->le_scan_disable, + msecs_to_jiffies(timeout)); + + return 0; +} + +static void le_scan_disable_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + le_scan_disable.work); + struct hci_cp_le_set_scan_enable cp; + + BT_DBG("%s", hdev->name); + + memset(&cp, 0, sizeof(cp)); + + hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); +} + /* Register HCI device */ int hci_register_dev(struct hci_dev *hdev) { @@ -1682,6 +1754,8 @@ int hci_register_dev(struct hci_dev *hdev) atomic_set(&hdev->promisc, 0); + INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); + write_unlock(&hci_dev_list_lock); hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND | diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8971c18205c0..97152d9d7116 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1031,6 +1031,8 @@ static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%x", hdev->name, status); + + hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status); } static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, @@ -1041,15 +1043,17 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, BT_DBG("%s status 0x%x", hdev->name, status); - if (status) - return; - cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); if (!cp) return; switch (cp->enable) { case LE_SCANNING_ENABLED: + hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status); + + if (status) + return; + set_bit(HCI_LE_SCAN, &hdev->dev_flags); cancel_delayed_work_sync(&hdev->adv_work); @@ -1061,6 +1065,9 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, break; case LE_SCANNING_DISABLED: + if (status) + return; + clear_bit(HCI_LE_SCAN, &hdev->dev_flags); hci_dev_lock(hdev); -- GitLab From 28b75a89480df99a17c8facd5c33985847d06bb6 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 3 Feb 2012 17:48:00 -0300 Subject: [PATCH 0645/1846] Bluetooth: Add hci_le_scan() We are not supposed to block in start_discovery() because start_discovery code is running in write() syscall context and this would block the write operation on the mgmt socket. This way, we cannot directly call hci_do_le_scan() to scan LE devices in start_discovery(). To overcome this issue a derefered work (hdev->le_scan) was created so we can properly call hci_do_le_scan(). The helper function hci_le_scan() simply set LE scan parameters and queue hdev->le_scan work. The work is queued on system_long_wq since it can sleep for a few seconds in the worst case (timeout). Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 6 ++++++ net/bluetooth/hci_core.c | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 3e70872bffea..7107790817a5 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -126,6 +126,7 @@ struct le_scan_params { u8 type; u16 interval; u16 window; + int timeout; }; #define NUM_REASSEMBLY 4 @@ -269,6 +270,9 @@ struct hci_dev { struct delayed_work le_scan_disable; + struct work_struct le_scan; + struct le_scan_params le_scan_params; + int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev); @@ -1033,5 +1037,7 @@ void hci_le_ltk_neg_reply(struct hci_conn *conn); int hci_do_inquiry(struct hci_dev *hdev, u8 length); int hci_cancel_inquiry(struct hci_dev *hdev); +int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, + int timeout); #endif /* __HCI_CORE_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index ae86cdd80ac0..3d09f4b4ca68 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -735,6 +735,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) { BT_DBG("%s %p", hdev->name, hdev); + cancel_work_sync(&hdev->le_scan); + hci_req_cancel(hdev, ENODEV); hci_req_lock(hdev); @@ -1668,6 +1670,37 @@ static void le_scan_disable_work(struct work_struct *work) hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } +static void le_scan_work(struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, le_scan); + struct le_scan_params *param = &hdev->le_scan_params; + + BT_DBG("%s", hdev->name); + + hci_do_le_scan(hdev, param->type, param->interval, + param->window, param->timeout); +} + +int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, + int timeout) +{ + struct le_scan_params *param = &hdev->le_scan_params; + + BT_DBG("%s", hdev->name); + + if (work_busy(&hdev->le_scan)) + return -EINPROGRESS; + + param->type = type; + param->interval = interval; + param->window = window; + param->timeout = timeout; + + queue_work(system_long_wq, &hdev->le_scan); + + return 0; +} + /* Register HCI device */ int hci_register_dev(struct hci_dev *hdev) { @@ -1754,6 +1787,8 @@ int hci_register_dev(struct hci_dev *hdev) atomic_set(&hdev->promisc, 0); + INIT_WORK(&hdev->le_scan, le_scan_work); + INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work); write_unlock(&hci_dev_list_lock); -- GitLab From 3fd2415363629b779549705f341e0645e32c1ad5 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 3 Feb 2012 17:48:01 -0300 Subject: [PATCH 0646/1846] Bluetooth: MGMT start discovery LE-Only support This patch adds LE-Only discovery procedure support to MGMT Start Discovery command. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 13 ++++++++++++- net/bluetooth/mgmt.c | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 97152d9d7116..ad5f37b13f77 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1033,6 +1033,13 @@ static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, status); hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status); + + if (status) { + hci_dev_lock(hdev); + mgmt_start_discovery_failed(hdev, status); + hci_dev_unlock(hdev); + return; + } } static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, @@ -1051,8 +1058,12 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, case LE_SCANNING_ENABLED: hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status); - if (status) + if (status) { + hci_dev_lock(hdev); + mgmt_start_discovery_failed(hdev, status); + hci_dev_unlock(hdev); return; + } set_bit(HCI_LE_SCAN, &hdev->dev_flags); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9e5dead1dbef..8c9de58779c7 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -35,6 +35,15 @@ #define MGMT_VERSION 0 #define MGMT_REVISION 1 +/* + * These LE scan and inquiry parameters were chosen according to LE General + * Discovery Procedure specification. + */ +#define LE_SCAN_TYPE 0x01 +#define LE_SCAN_WIN 0x12 +#define LE_SCAN_INT 0x12 +#define LE_SCAN_TIMEOUT_LE_ONLY 10240 /* TGAP(gen_disc_scan_min) */ + #define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ #define SERVICE_CACHE_TIMEOUT (5 * 1000) @@ -1916,6 +1925,7 @@ static int start_discovery(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_start_discovery *cp = data; + unsigned long discov_type = cp->type; struct pending_cmd *cmd; struct hci_dev *hdev; int err; @@ -1951,7 +1961,15 @@ static int start_discovery(struct sock *sk, u16 index, goto failed; } - err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); + if (test_bit(MGMT_ADDR_BREDR, &discov_type)) + err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); + else if (test_bit(MGMT_ADDR_LE_PUBLIC, &discov_type) && + test_bit(MGMT_ADDR_LE_RANDOM, &discov_type)) + err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, + LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); + else + err = -EINVAL; + if (err < 0) mgmt_pending_remove(cmd); else -- GitLab From e87775250f322b8f1612cf9918fcde827948f087 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 3 Feb 2012 17:48:02 -0300 Subject: [PATCH 0647/1846] Bluetooth: Fix indentation This patch fixes a #define indentation in mgmt.c. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8c9de58779c7..de7326b111ba 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -44,7 +44,7 @@ #define LE_SCAN_INT 0x12 #define LE_SCAN_TIMEOUT_LE_ONLY 10240 /* TGAP(gen_disc_scan_min) */ -#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ +#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ #define SERVICE_CACHE_TIMEOUT (5 * 1000) -- GitLab From 053c7e0c4a40e2bb44e3c1e61e263be00688a136 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 4 Feb 2012 00:06:00 +0200 Subject: [PATCH 0648/1846] Bluetooth: Fix device_found event length for remote name resolving The correct length of the event is the size of the ev struct (not size of the pointer like the code was previously using) plus the length of the variable-sized EIR data at the end of the struct. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index de7326b111ba..11ee5db16e97 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2964,7 +2964,8 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, put_unaligned_le16(eir_len, &ev->eir_len); - return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, + sizeof(*ev) + eir_len, NULL); } int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) -- GitLab From 343fb14549a736b348b08e702057487a7ec44d5d Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Tue, 22 Nov 2011 17:14:19 -0300 Subject: [PATCH 0649/1846] Bluetooth: Add BT_DBG to mgmt_discovering() This is helpful for device discovery implementation & debuging. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 11ee5db16e97..77bc5a4b026c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3002,6 +3002,8 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) { struct pending_cmd *cmd; + BT_DBG("%s discovering %u", hdev->name, discovering); + if (discovering) cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev); else -- GitLab From cf4cd00915c659dc7b496c454bee36bb6b833fd1 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 6 Feb 2012 15:03:59 +0200 Subject: [PATCH 0650/1846] Bluetooth: Change chan_ready param from sk to chan Change is needed to remove dependency on sk when possible before introducing l2cap channel lock. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 09cd8601ea81..80fbfcf0674d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -907,9 +907,9 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) release_sock(parent); } -static void l2cap_chan_ready(struct sock *sk) +static void l2cap_chan_ready(struct l2cap_chan *chan) { - struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct sock *sk = chan->sk; struct sock *parent = bt_sk(sk)->parent; BT_DBG("sk %p, parent %p", sk, parent); @@ -945,7 +945,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) if (conn->hcon->type == LE_LINK) { if (smp_conn_security(conn, chan->sec_level)) - l2cap_chan_ready(sk); + l2cap_chan_ready(chan); } else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { __clear_chan_timer(chan); @@ -2874,7 +2874,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr if (chan->mode == L2CAP_MODE_ERTM) l2cap_ertm_init(chan); - l2cap_chan_ready(sk); + l2cap_chan_ready(chan); goto unlock; } @@ -3005,7 +3005,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr if (chan->mode == L2CAP_MODE_ERTM) l2cap_ertm_init(chan); - l2cap_chan_ready(sk); + l2cap_chan_ready(chan); } done: @@ -4524,7 +4524,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) if (chan->scid == L2CAP_CID_LE_DATA) { if (!status && encrypt) { chan->sec_level = hcon->sec_level; - l2cap_chan_ready(sk); + l2cap_chan_ready(chan); } bh_unlock_sock(sk); -- GitLab From 5491120e75afe2a7f5b6f3a207de6d99934e5475 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 6 Feb 2012 15:04:00 +0200 Subject: [PATCH 0651/1846] Bluetooth: Clean up l2cap_chan_add Change elseif to switch. This make sense even more with following patches which otherwise have to add more elseifs statements. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 80fbfcf0674d..48fc01ef16b6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -320,7 +320,8 @@ static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) chan->conn = conn; - if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) { + switch (chan->chan_type) { + case L2CAP_CHAN_CONN_ORIENTED: if (conn->hcon->type == LE_LINK) { /* LE connection */ chan->omtu = L2CAP_LE_DEFAULT_MTU; @@ -331,12 +332,16 @@ static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) chan->scid = l2cap_alloc_cid(conn); chan->omtu = L2CAP_DEFAULT_MTU; } - } else if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { + break; + + case L2CAP_CHAN_CONN_LESS: /* Connectionless socket */ chan->scid = L2CAP_CID_CONN_LESS; chan->dcid = L2CAP_CID_CONN_LESS; chan->omtu = L2CAP_DEFAULT_MTU; - } else { + break; + + default: /* Raw socket can send/recv signalling messages only */ chan->scid = L2CAP_CID_SIGNALING; chan->dcid = L2CAP_CID_SIGNALING; -- GitLab From 6d5922b01b5e8d684dae5baaea596a4a749738e3 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 6 Feb 2012 15:04:01 +0200 Subject: [PATCH 0652/1846] Bluetooth: Remove unneeded sk variable In debug use chan %p instead of sk. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 48fc01ef16b6..f1a6b3cbdba7 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1561,13 +1561,12 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u32 priority) { - struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sk_buff *skb; int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; struct l2cap_hdr *lh; - BT_DBG("sk %p len %d priority %u", sk, (int)len, priority); + BT_DBG("chan %p len %d priority %u", chan, (int)len, priority); count = min_t(unsigned int, (conn->mtu - hlen), len); @@ -1597,13 +1596,12 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u32 priority) { - struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sk_buff *skb; int err, count, hlen = L2CAP_HDR_SIZE; struct l2cap_hdr *lh; - BT_DBG("sk %p len %d", sk, (int)len); + BT_DBG("chan %p len %d", chan, (int)len); count = min_t(unsigned int, (conn->mtu - hlen), len); @@ -1632,13 +1630,12 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u32 control, u16 sdulen) { - struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sk_buff *skb; int err, count, hlen; struct l2cap_hdr *lh; - BT_DBG("sk %p len %d", sk, (int)len); + BT_DBG("chan %p len %d", chan, (int)len); if (!conn) return ERR_PTR(-ENOTCONN); -- GitLab From 8ed7a0ae7834cbefb82ed15a92e36983924efa23 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 7 Feb 2012 15:43:01 +0100 Subject: [PATCH 0653/1846] Bluetooth: Fix possible missing I-Frame acknowledgement Make l2cap_ertm_send return number of pending I-Frames transmitted instead of all (pending + retransmitted) I-Frames transmitted. As only pending I-Frames are considered as acknowledgement, this could lead to situation when no ACK was sent in __l2cap_send_ack (if only already transmitted I-Frames were retransmitted). Signed-off-by: Szymon Janc Signed-off-by: Luiz Augusto von Dentz Acked-by: Gustavo F. Padovan Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index f1a6b3cbdba7..9add85271658 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1453,8 +1453,10 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq); - if (bt_cb(skb)->retries == 1) + if (bt_cb(skb)->retries == 1) { chan->unacked_frames++; + nsent++; + } chan->frames_sent++; @@ -1462,8 +1464,6 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) chan->tx_send_head = NULL; else chan->tx_send_head = skb_queue_next(&chan->tx_q, skb); - - nsent++; } return nsent; -- GitLab From 930fa4aee934ad59ed82163cdbee4922b883ef79 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 7 Feb 2012 15:43:02 +0100 Subject: [PATCH 0654/1846] Bluetooth: Fix double acking I-Frames when sending pending I-Frames Pending I-Frame(s) are considered as acknowledgement. To void double acking (via I-Frame and later via RR) clear ack timer when sending first pending I-Frame. Signed-off-by: Szymon Janc Signed-off-by: Luiz Augusto von Dentz Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 9add85271658..8efac7884ffb 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1455,7 +1455,9 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) if (bt_cb(skb)->retries == 1) { chan->unacked_frames++; - nsent++; + + if (!nsent++) + __clear_ack_timer(chan); } chan->frames_sent++; -- GitLab From 124f6e35286c9d8dc96f147a9026081256136615 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 13:50:12 +0200 Subject: [PATCH 0655/1846] Bluetooth: Update and rename mgmt_remove_keys to mgmt_unpair_device This patch renames the mgmt_remove_keys command to mgmt_unpair_device and updates its parameters to match the latest API (specifically, it adds an address type parameter to the command and its response). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 34 ++++++++++---------- net/bluetooth/mgmt.c | 60 ++++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 72975fd53988..4c18cd5fb8c1 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -175,17 +175,7 @@ struct mgmt_cp_load_long_term_keys { struct mgmt_ltk_info keys[0]; } __packed; -#define MGMT_OP_REMOVE_KEYS 0x0014 -struct mgmt_cp_remove_keys { - bdaddr_t bdaddr; - __u8 disconnect; -} __packed; -struct mgmt_rp_remove_keys { - bdaddr_t bdaddr; - __u8 status; -}; - -#define MGMT_OP_DISCONNECT 0x0015 +#define MGMT_OP_DISCONNECT 0x0014 struct mgmt_cp_disconnect { bdaddr_t bdaddr; } __packed; @@ -194,13 +184,13 @@ struct mgmt_rp_disconnect { __u8 status; } __packed; -#define MGMT_OP_GET_CONNECTIONS 0x0016 +#define MGMT_OP_GET_CONNECTIONS 0x0015 struct mgmt_rp_get_connections { __le16 conn_count; struct mgmt_addr_info addr[0]; } __packed; -#define MGMT_OP_PIN_CODE_REPLY 0x0017 +#define MGMT_OP_PIN_CODE_REPLY 0x0016 struct mgmt_cp_pin_code_reply { bdaddr_t bdaddr; __u8 pin_len; @@ -211,17 +201,17 @@ struct mgmt_rp_pin_code_reply { uint8_t status; } __packed; -#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0018 +#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 struct mgmt_cp_pin_code_neg_reply { bdaddr_t bdaddr; } __packed; -#define MGMT_OP_SET_IO_CAPABILITY 0x0019 +#define MGMT_OP_SET_IO_CAPABILITY 0x0018 struct mgmt_cp_set_io_capability { __u8 io_capability; } __packed; -#define MGMT_OP_PAIR_DEVICE 0x001A +#define MGMT_OP_PAIR_DEVICE 0x0019 struct mgmt_cp_pair_device { struct mgmt_addr_info addr; __u8 io_cap; @@ -231,7 +221,17 @@ struct mgmt_rp_pair_device { __u8 status; } __packed; -#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001B +#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A + +#define MGMT_OP_UNPAIR_DEVICE 0x001B +struct mgmt_cp_unpair_device { + struct mgmt_addr_info addr; + __u8 disconnect; +} __packed; +struct mgmt_rp_unpair_device { + struct mgmt_addr_info addr; + __u8 status; +}; #define MGMT_OP_USER_CONFIRM_REPLY 0x001C struct mgmt_cp_user_confirm_reply { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 77bc5a4b026c..c64e5db7f596 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1073,57 +1073,63 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) return 0; } -static int remove_keys(struct sock *sk, u16 index, void *data, u16 len) +static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; - struct mgmt_cp_remove_keys *cp = data; - struct mgmt_rp_remove_keys rp; + struct mgmt_cp_unpair_device *cp = data; + struct mgmt_rp_unpair_device rp; struct hci_cp_disconnect dc; struct pending_cmd *cmd; struct hci_conn *conn; int err; if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, + return cmd_status(sk, index, MGMT_OP_UNPAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, + return cmd_status(sk, index, MGMT_OP_UNPAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); memset(&rp, 0, sizeof(rp)); - bacpy(&rp.bdaddr, &cp->bdaddr); + bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); + rp.addr.type = cp->addr.type; rp.status = MGMT_STATUS_FAILED; - err = hci_remove_ltk(hdev, &cp->bdaddr); - if (err < 0) { - err = cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, -err); - goto unlock; - } + if (cp->addr.type == MGMT_ADDR_BREDR) + err = hci_remove_link_key(hdev, &cp->addr.bdaddr); + else + err = hci_remove_ltk(hdev, &cp->addr.bdaddr); - err = hci_remove_link_key(hdev, &cp->bdaddr); if (err < 0) { rp.status = MGMT_STATUS_NOT_PAIRED; goto unlock; } if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) { - err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, sizeof(rp)); goto unlock; } - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); + if (cp->addr.type == MGMT_ADDR_BREDR) + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, + &cp->addr.bdaddr); + else + conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, + &cp->addr.bdaddr); + if (!conn) { - err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, sizeof(rp)); goto unlock; } - cmd = mgmt_pending_add(sk, MGMT_OP_REMOVE_KEYS, hdev, cp, sizeof(*cp)); + cmd = mgmt_pending_add(sk, MGMT_OP_UNPAIR_DEVICE, hdev, cp, + sizeof(*cp)); if (!cmd) { err = -ENOMEM; goto unlock; @@ -1137,7 +1143,7 @@ static int remove_keys(struct sock *sk, u16 index, void *data, u16 len) unlock: if (err < 0) - err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp, + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, sizeof(rp)); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2340,9 +2346,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_LOAD_LINK_KEYS: err = load_link_keys(sk, index, cp, len); break; - case MGMT_OP_REMOVE_KEYS: - err = remove_keys(sk, index, cp, len); - break; case MGMT_OP_DISCONNECT: err = disconnect(sk, index, cp, len); break; @@ -2364,6 +2367,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_CANCEL_PAIR_DEVICE: err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len); break; + case MGMT_OP_UNPAIR_DEVICE: + err = unpair_device(sk, index, cp, len); + break; case MGMT_OP_USER_CONFIRM_REPLY: err = user_confirm_reply(sk, index, cp, len); break; @@ -2624,18 +2630,19 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) mgmt_pending_remove(cmd); } -static void remove_keys_rsp(struct pending_cmd *cmd, void *data) +static void unpair_device_rsp(struct pending_cmd *cmd, void *data) { u8 *status = data; - struct mgmt_cp_remove_keys *cp = cmd->param; - struct mgmt_rp_remove_keys rp; + struct mgmt_cp_unpair_device *cp = cmd->param; + struct mgmt_rp_unpair_device rp; memset(&rp, 0, sizeof(rp)); - bacpy(&rp.bdaddr, &cp->bdaddr); + bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); + rp.addr.type = cp->addr.type; if (status != NULL) rp.status = *status; - cmd_complete(cmd->sk, cmd->index, MGMT_OP_REMOVE_KEYS, &rp, + cmd_complete(cmd->sk, cmd->index, MGMT_OP_UNPAIR_DEVICE, &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -2659,7 +2666,8 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, if (sk) sock_put(sk); - mgmt_pending_foreach(MGMT_OP_REMOVE_KEYS, hdev, remove_keys_rsp, NULL); + mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, + NULL); return err; } -- GitLab From 88c3df13ca06718e5a8f509ae9cbb1228c10d537 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 14:27:38 +0200 Subject: [PATCH 0656/1846] Bluetooth: Update mgmt_disconnect to match latest API This patch adds an address type parameter to the disconnect command and response in order to match the latest mgmt API specification. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 3 ++- include/net/bluetooth/mgmt.h | 4 ++-- net/bluetooth/hci_event.c | 28 +++++++++++++++++++++++++--- net/bluetooth/mgmt.c | 28 +++++++++++++--------------- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7107790817a5..634a0cdcdad6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -958,7 +958,8 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 *dev_class); int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type); -int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); +int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type, u8 status); int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 4c18cd5fb8c1..735e547e3448 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -177,10 +177,10 @@ struct mgmt_cp_load_long_term_keys { #define MGMT_OP_DISCONNECT 0x0014 struct mgmt_cp_disconnect { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; struct mgmt_rp_disconnect { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 status; } __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index ad5f37b13f77..f0c822db28d9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1550,6 +1550,28 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) hci_dev_unlock(hdev); } +static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) +{ + struct hci_cp_disconnect *cp; + struct hci_conn *conn; + + if (!status) + return; + + cp = hci_sent_cmd_data(hdev, HCI_OP_DISCONNECT); + if (!cp) + return; + + hci_dev_lock(hdev); + + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); + if (conn) + mgmt_disconnect_failed(hdev, &conn->dst, conn->type, + conn->dst_type, status); + + hci_dev_unlock(hdev); +} + static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status) { struct hci_cp_le_create_conn *cp; @@ -1839,7 +1861,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) && (conn->type == ACL_LINK || conn->type == LE_LINK)) { if (ev->status != 0) - mgmt_disconnect_failed(hdev, &conn->dst, ev->status); + mgmt_disconnect_failed(hdev, &conn->dst, conn->type, + conn->dst_type, ev->status); else mgmt_device_disconnected(hdev, &conn->dst, conn->type, conn->dst_type); @@ -2350,8 +2373,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) break; case HCI_OP_DISCONNECT: - if (ev->status != 0) - mgmt_disconnect_failed(hdev, NULL, ev->status); + hci_cs_disconnect(hdev, ev->status); break; case HCI_OP_LE_CREATE_CONN: diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c64e5db7f596..f1257ee5afbc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1185,9 +1185,10 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); - if (!conn) - conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->bdaddr); + if (cp->addr.type == MGMT_ADDR_BREDR) + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); + else + conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr); if (!conn) { err = cmd_status(sk, index, MGMT_OP_DISCONNECT, @@ -2619,7 +2620,8 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) struct sock **sk = data; struct mgmt_rp_disconnect rp; - bacpy(&rp.bdaddr, &cp->bdaddr); + bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); + rp.addr.type = cp->addr.type; rp.status = 0; cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, &rp, sizeof(rp)); @@ -2672,27 +2674,23 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, return err; } -int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) +int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type, u8 status) { + struct mgmt_rp_disconnect rp; struct pending_cmd *cmd; - u8 mgmt_err = mgmt_status(status); int err; cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev); if (!cmd) return -ENOENT; - if (bdaddr) { - struct mgmt_rp_disconnect rp; - - bacpy(&rp.bdaddr, bdaddr); - rp.status = status; + bacpy(&rp.addr.bdaddr, bdaddr); + rp.addr.type = link_to_mgmt(link_type, addr_type); + rp.status = mgmt_status(status); - err = cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, + err = cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, &rp, sizeof(rp)); - } else - err = cmd_status(cmd->sk, hdev->id, MGMT_OP_DISCONNECT, - mgmt_err); mgmt_pending_remove(cmd); -- GitLab From 272d90df2d4d065e782cafb08358bd8918bf703a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 15:26:12 +0200 Subject: [PATCH 0657/1846] Bluetooth: Add address type to user_confirm and user_passkey messages This patch upadate the user confirm and user passkey mgmt messages to match the latest API specification by adding an address type parameter to them. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 18 +++--- include/net/bluetooth/mgmt.h | 16 +++--- net/bluetooth/hci_event.c | 14 +++-- net/bluetooth/mgmt.c | 98 ++++++++++++++++---------------- net/bluetooth/smp.c | 4 +- 5 files changed, 79 insertions(+), 71 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 634a0cdcdad6..5f27694068f2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -968,16 +968,18 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, - __le32 value, u8 confirm_hint); + u8 link_type, u8 addr_type, __le32 value, + u8 confirm_hint); int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); -int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 status); -int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr); + u8 link_type, u8 addr_type, u8 status); +int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type, u8 status); +int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type); int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); -int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 status); + u8 link_type, u8 addr_type, u8 status); +int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type, u8 status); int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 735e547e3448..378d498896b3 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -235,31 +235,31 @@ struct mgmt_rp_unpair_device { #define MGMT_OP_USER_CONFIRM_REPLY 0x001C struct mgmt_cp_user_confirm_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; struct mgmt_rp_user_confirm_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 status; } __packed; #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D struct mgmt_cp_user_confirm_neg_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_OP_USER_PASSKEY_REPLY 0x001E struct mgmt_cp_user_passkey_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __le32 passkey; } __packed; struct mgmt_rp_user_passkey_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 status; } __packed; #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F struct mgmt_cp_user_passkey_neg_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 @@ -376,14 +376,14 @@ struct mgmt_ev_pin_code_request { #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F struct mgmt_ev_user_confirm_request { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 confirm_hint; __le32 value; } __packed; #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010 struct mgmt_ev_user_passkey_request { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_EV_AUTH_FAILED 0x0011 diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index f0c822db28d9..3bf3f4d59bcc 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -960,8 +960,8 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); if (test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, - rp->status); + mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, + 0, rp->status); hci_dev_unlock(hdev); } @@ -977,6 +977,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, + ACL_LINK, 0, rp->status); hci_dev_unlock(hdev); @@ -991,8 +992,8 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); if (test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, - rp->status); + mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, + 0, rp->status); hci_dev_unlock(hdev); } @@ -1008,6 +1009,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, + ACL_LINK, 0, rp->status); hci_dev_unlock(hdev); @@ -3123,7 +3125,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, } confirm: - mgmt_user_confirm_request(hdev, &ev->bdaddr, ev->passkey, + mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, ev->passkey, confirm_hint); unlock: @@ -3140,7 +3142,7 @@ static inline void hci_user_passkey_request_evt(struct hci_dev *hdev, hci_dev_lock(hdev); if (test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_user_passkey_request(hdev, &ev->bdaddr); + mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); hci_dev_unlock(hdev); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f1257ee5afbc..16fc828096f6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1629,7 +1629,8 @@ static int cancel_pair_device(struct sock *sk, u16 index, } static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, - u16 mgmt_op, u16 hci_op, __le32 passkey) + u8 type, u16 mgmt_op, u16 hci_op, + __le32 passkey) { struct pending_cmd *cmd; struct hci_dev *hdev; @@ -1648,24 +1649,18 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, goto done; } - /* - * Check for an existing ACL link, if present pair via - * HCI commands. - * - * If no ACL link is present, check for an LE link and if - * present, pair via the SMP engine. - * - * If neither ACL nor LE links are present, fail with error. - */ - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr); - if (!conn) { + if (type == MGMT_ADDR_BREDR) + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr); + else conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); - if (!conn) { - err = cmd_status(sk, index, mgmt_op, + + if (!conn) { + err = cmd_status(sk, index, mgmt_op, MGMT_STATUS_NOT_CONNECTED); - goto done; - } + goto done; + } + if (type == MGMT_ADDR_LE_PUBLIC || type == MGMT_ADDR_LE_RANDOM) { /* Continue with pairing via SMP */ err = smp_user_confirm_reply(conn, mgmt_op, passkey); @@ -1715,9 +1710,9 @@ static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len) return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_REPLY, MGMT_STATUS_INVALID_PARAMS); - return user_pairing_resp(sk, index, &cp->bdaddr, - MGMT_OP_USER_CONFIRM_REPLY, - HCI_OP_USER_CONFIRM_REPLY, 0); + return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + MGMT_OP_USER_CONFIRM_REPLY, + HCI_OP_USER_CONFIRM_REPLY, 0); } static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data, @@ -1731,9 +1726,9 @@ static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data, return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_NEG_REPLY, MGMT_STATUS_INVALID_PARAMS); - return user_pairing_resp(sk, index, &cp->bdaddr, - MGMT_OP_USER_CONFIRM_NEG_REPLY, - HCI_OP_USER_CONFIRM_NEG_REPLY, 0); + return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + MGMT_OP_USER_CONFIRM_NEG_REPLY, + HCI_OP_USER_CONFIRM_NEG_REPLY, 0); } static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) @@ -1746,9 +1741,10 @@ static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_REPLY, EINVAL); - return user_pairing_resp(sk, index, &cp->bdaddr, - MGMT_OP_USER_PASSKEY_REPLY, - HCI_OP_USER_PASSKEY_REPLY, cp->passkey); + return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + MGMT_OP_USER_PASSKEY_REPLY, + HCI_OP_USER_PASSKEY_REPLY, + cp->passkey); } static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, @@ -1762,9 +1758,9 @@ static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_NEG_REPLY, EINVAL); - return user_pairing_resp(sk, index, &cp->bdaddr, - MGMT_OP_USER_PASSKEY_NEG_REPLY, - HCI_OP_USER_PASSKEY_NEG_REPLY, 0); + return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + MGMT_OP_USER_PASSKEY_NEG_REPLY, + HCI_OP_USER_PASSKEY_NEG_REPLY, 0); } static int set_local_name(struct sock *sk, u16 index, void *data, @@ -2765,13 +2761,15 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, } int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, - __le32 value, u8 confirm_hint) + u8 link_type, u8 addr_type, __le32 value, + u8 confirm_hint) { struct mgmt_ev_user_confirm_request ev; BT_DBG("%s", hdev->name); - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = link_to_mgmt(link_type, addr_type); ev.confirm_hint = confirm_hint; put_unaligned_le32(value, &ev.value); @@ -2779,20 +2777,23 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, NULL); } -int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr) +int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type) { struct mgmt_ev_user_passkey_request ev; BT_DBG("%s", hdev->name); - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = link_to_mgmt(link_type, addr_type); return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev), NULL); } static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status, u8 opcode) + u8 link_type, u8 addr_type, u8 status, + u8 opcode) { struct pending_cmd *cmd; struct mgmt_rp_user_confirm_reply rp; @@ -2802,7 +2803,8 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, if (!cmd) return -ENOENT; - bacpy(&rp.bdaddr, bdaddr); + bacpy(&rp.addr.bdaddr, bdaddr); + rp.addr.type = link_to_mgmt(link_type, addr_type); rp.status = mgmt_status(status); err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp)); @@ -2812,31 +2814,31 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, } int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status) + u8 link_type, u8 addr_type, u8 status) { - return user_pairing_resp_complete(hdev, bdaddr, status, - MGMT_OP_USER_CONFIRM_REPLY); + return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, + status, MGMT_OP_USER_CONFIRM_REPLY); } -int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 status) +int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type, u8 status) { - return user_pairing_resp_complete(hdev, bdaddr, status, - MGMT_OP_USER_CONFIRM_NEG_REPLY); + return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, + status, MGMT_OP_USER_CONFIRM_NEG_REPLY); } int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status) + u8 link_type, u8 addr_type, u8 status) { - return user_pairing_resp_complete(hdev, bdaddr, status, - MGMT_OP_USER_PASSKEY_REPLY); + return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, + status, MGMT_OP_USER_PASSKEY_REPLY); } -int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 status) +int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 link_type, u8 addr_type, u8 status) { - return user_pairing_resp_complete(hdev, bdaddr, status, - MGMT_OP_USER_PASSKEY_NEG_REPLY); + return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, + status, MGMT_OP_USER_PASSKEY_NEG_REPLY); } int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 0563f737779a..589766d06f22 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -349,9 +349,11 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, hci_dev_lock(hcon->hdev); if (method == REQ_PASSKEY) - ret = mgmt_user_passkey_request(hcon->hdev, conn->dst); + ret = mgmt_user_passkey_request(hcon->hdev, conn->dst, + hcon->type, hcon->dst_type); else ret = mgmt_user_confirm_request(hcon->hdev, conn->dst, + hcon->type, hcon->dst_type, cpu_to_le32(passkey), 0); hci_dev_unlock(hcon->hdev); -- GitLab From 664ce4cc293cd6c76236617f78689d0e03e69287 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 15:44:09 +0200 Subject: [PATCH 0658/1846] Bluetooth: Add address type to Out Of Band mgmt messages This patch updates the implementation for these mgmt to be up to date with the latest API specification. Right now the address type isn't actually used for anything but that might change in the future. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 4 ++-- net/bluetooth/mgmt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 378d498896b3..f284499b5f7f 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -270,14 +270,14 @@ struct mgmt_rp_read_local_oob_data { #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021 struct mgmt_cp_add_remote_oob_data { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 hash[16]; __u8 randomizer[16]; } __packed; #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 struct mgmt_cp_remove_remote_oob_data { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_OP_START_DISCOVERY 0x0023 diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 16fc828096f6..763a447b2532 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1875,7 +1875,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, hci_dev_lock(hdev); - err = hci_add_remote_oob_data(hdev, &cp->bdaddr, cp->hash, + err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, cp->randomizer); if (err < 0) err = cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, @@ -1910,7 +1910,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, hci_dev_lock(hdev); - err = hci_remove_remote_oob_data(hdev, &cp->bdaddr); + err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr); if (err < 0) err = cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, MGMT_STATUS_INVALID_PARAMS); -- GitLab From 88c1fe4ba55c7245ad2f3c81689f854287875121 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 15:56:11 +0200 Subject: [PATCH 0659/1846] Bluetooth: Add address type to mgmt blacklist messages This patch updates the implmentation for mgmt_block_device and mgmt_unblock_device and their corresponding events to match the latest API specification. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 8 ++++---- include/net/bluetooth/mgmt.h | 8 ++++---- net/bluetooth/hci_core.c | 8 ++++---- net/bluetooth/hci_sock.c | 4 ++-- net/bluetooth/mgmt.c | 14 ++++++++------ 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5f27694068f2..14a655f3929c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -646,8 +646,8 @@ int hci_inquiry(void __user *arg); struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_blacklist_clear(struct hci_dev *hdev); -int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr); +int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); +int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); int hci_uuids_clear(struct hci_dev *hdev); @@ -992,8 +992,8 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_discovering(struct hci_dev *hdev, u8 discovering); -int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr); -int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr); +int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); +int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index f284499b5f7f..92f85c834677 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -299,12 +299,12 @@ struct mgmt_rp_confirm_name { #define MGMT_OP_BLOCK_DEVICE 0x0026 struct mgmt_cp_block_device { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_OP_UNBLOCK_DEVICE 0x0027 struct mgmt_cp_unblock_device { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_EV_CMD_COMPLETE 0x0001 @@ -405,10 +405,10 @@ struct mgmt_ev_device_found { #define MGMT_EV_DEVICE_BLOCKED 0x0014 struct mgmt_ev_device_blocked { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_EV_DEVICE_UNBLOCKED 0x0015 struct mgmt_ev_device_unblocked { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3d09f4b4ca68..9ada16449aed 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1489,7 +1489,7 @@ int hci_blacklist_clear(struct hci_dev *hdev) return 0; } -int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) +int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) { struct bdaddr_list *entry; @@ -1507,10 +1507,10 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) list_add(&entry->list, &hdev->blacklist); - return mgmt_device_blocked(hdev, bdaddr); + return mgmt_device_blocked(hdev, bdaddr, type); } -int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) +int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) { struct bdaddr_list *entry; @@ -1524,7 +1524,7 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) list_del(&entry->list); kfree(entry); - return mgmt_device_unblocked(hdev, bdaddr); + return mgmt_device_unblocked(hdev, bdaddr, type); } static void hci_clear_adv_cache(struct work_struct *work) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 0dcc96266779..9e854d9fb460 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -190,7 +190,7 @@ static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg) hci_dev_lock(hdev); - err = hci_blacklist_add(hdev, &bdaddr); + err = hci_blacklist_add(hdev, &bdaddr, 0); hci_dev_unlock(hdev); @@ -207,7 +207,7 @@ static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) hci_dev_lock(hdev); - err = hci_blacklist_del(hdev, &bdaddr); + err = hci_blacklist_del(hdev, &bdaddr, 0); hci_dev_unlock(hdev); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 763a447b2532..413a0b97c533 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2114,7 +2114,7 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - err = hci_blacklist_add(hdev, &cp->bdaddr); + err = hci_blacklist_add(hdev, &cp->addr.bdaddr, cp->addr.type); if (err < 0) err = cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, MGMT_STATUS_FAILED); @@ -2147,7 +2147,7 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - err = hci_blacklist_del(hdev, &cp->bdaddr); + err = hci_blacklist_del(hdev, &cp->addr.bdaddr, cp->addr.type); if (err < 0) err = cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, @@ -3026,27 +3026,29 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) sizeof(discovering), NULL); } -int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr) +int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) { struct pending_cmd *cmd; struct mgmt_ev_device_blocked ev; cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, hdev); - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = type; return mgmt_event(MGMT_EV_DEVICE_BLOCKED, hdev, &ev, sizeof(ev), cmd ? cmd->sk : NULL); } -int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr) +int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) { struct pending_cmd *cmd; struct mgmt_ev_device_unblocked ev; cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, hdev); - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = type; return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev), cmd ? cmd->sk : NULL); -- GitLab From bab73cb68435232ba78a4bd1ac1a85862e3be0bb Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 16:07:29 +0200 Subject: [PATCH 0660/1846] Bluetooth: Add address type to mgmt_ev_auth_failed This patch updates the Authentication Failed mgmt event to match the latest API specification by adding an address type to it. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 3 ++- include/net/bluetooth/mgmt.h | 2 +- net/bluetooth/hci_event.c | 6 ++++-- net/bluetooth/mgmt.c | 6 ++++-- net/bluetooth/smp.c | 5 ++++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 14a655f3929c..ccb24a4212cd 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -980,7 +980,8 @@ int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); -int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); +int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 92f85c834677..17bbf8bf04ae 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -388,7 +388,7 @@ struct mgmt_ev_user_passkey_request { #define MGMT_EV_AUTH_FAILED 0x0011 struct mgmt_ev_auth_failed { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 status; } __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 3bf3f4d59bcc..b0784ee5f8b9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1901,7 +1901,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s conn->sec_level = conn->pending_sec_level; } } else { - mgmt_auth_failed(hdev, &conn->dst, ev->status); + mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, + ev->status); } clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); @@ -3166,7 +3167,8 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_ * event gets always produced as initiator and is also mapped to * the mgmt_auth_failed event */ if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status != 0) - mgmt_auth_failed(hdev, &conn->dst, ev->status); + mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, + ev->status); hci_conn_put(conn); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 413a0b97c533..545919828562 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2841,11 +2841,13 @@ int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, status, MGMT_OP_USER_PASSKEY_NEG_REPLY); } -int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) +int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, + u8 addr_type, u8 status) { struct mgmt_ev_auth_failed ev; - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = link_to_mgmt(link_type, addr_type); ev.status = mgmt_status(status); return mgmt_event(MGMT_EV_AUTH_FAILED, hdev, &ev, sizeof(ev), NULL); diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 589766d06f22..f6a6d8be3051 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -257,12 +257,15 @@ static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send) { + struct hci_conn *hcon = conn->hcon; + if (send) smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), &reason); clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); - mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason); + mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type, + hcon->dst_type, reason); if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) { cancel_delayed_work_sync(&conn->security_timer); -- GitLab From 82eb703efc2ad2ac52cada85a5119bb9dfcea942 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 17:19:27 +0200 Subject: [PATCH 0661/1846] Bluetooth: Fix mgmt_unpair_device command status The default response status to unpair_device should be set as 0 instead of a generic failure value. When disconnection is not needed (i.e. we can reply imediately) we should return success and not failure. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 545919828562..0cf0f4dc8213 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1097,7 +1097,6 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) memset(&rp, 0, sizeof(rp)); bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); rp.addr.type = cp->addr.type; - rp.status = MGMT_STATUS_FAILED; if (cp->addr.type == MGMT_ADDR_BREDR) err = hci_remove_link_key(hdev, &cp->addr.bdaddr); -- GitLab From b1078ad0be344e7bec6e7991f33df17565d24e08 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 9 Feb 2012 17:21:16 +0200 Subject: [PATCH 0662/1846] Bluetooth: Add Device Unpaired mgmt event This patch add a new Device Unpaired mgmt event. This will be sent to all mgmt sockets except the one that requested unpairing (that socket will get a command complete instead). The event is also reserved for future SMP updates where a remote device will be able to request pairing revocation from us. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 5 +++++ net/bluetooth/mgmt.c | 27 +++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 17bbf8bf04ae..5b5edeed59e2 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -412,3 +412,8 @@ struct mgmt_ev_device_blocked { struct mgmt_ev_device_unblocked { struct mgmt_addr_info addr; } __packed; + +#define MGMT_EV_DEVICE_UNPAIRED 0x0016 +struct mgmt_ev_device_unpaired { + struct mgmt_addr_info addr; +} __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0cf0f4dc8213..a2c2e12516c6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1073,6 +1073,18 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) return 0; } +static int device_unpaired(struct hci_dev *hdev, bdaddr_t *bdaddr, + u8 addr_type, struct sock *skip_sk) +{ + struct mgmt_ev_device_unpaired ev; + + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = addr_type; + + return mgmt_event(MGMT_EV_DEVICE_UNPAIRED, hdev, &ev, sizeof(ev), + skip_sk); +} + static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; @@ -1111,6 +1123,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) { err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, sizeof(rp)); + device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; } @@ -1124,6 +1137,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) if (!conn) { err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, sizeof(rp)); + device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; } @@ -2629,18 +2643,17 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) static void unpair_device_rsp(struct pending_cmd *cmd, void *data) { - u8 *status = data; + struct hci_dev *hdev = data; struct mgmt_cp_unpair_device *cp = cmd->param; struct mgmt_rp_unpair_device rp; memset(&rp, 0, sizeof(rp)); bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); rp.addr.type = cp->addr.type; - if (status != NULL) - rp.status = *status; - cmd_complete(cmd->sk, cmd->index, MGMT_OP_UNPAIR_DEVICE, &rp, - sizeof(rp)); + device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk); + + cmd_complete(cmd->sk, cmd->index, cmd->opcode, &rp, sizeof(rp)); mgmt_pending_remove(cmd); } @@ -2664,7 +2677,7 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, sock_put(sk); mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, - NULL); + hdev); return err; } @@ -2689,6 +2702,8 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, mgmt_pending_remove(cmd); + mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, + hdev); return err; } -- GitLab From aa2b86d761a95068354511de755695ef6b53afc7 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 9 Feb 2012 21:58:30 +0100 Subject: [PATCH 0663/1846] Bluetooth: Introduce to_hci_dev() We currently use dev_set_drvdata to keep a pointer to ourself. This doesn't make sense as we are the bus and not a driver. Therefore, introduce to_hci_dev() so we can get a struct hci_dev pointer from a struct device pointer. dev_set/get_drvdata() is reserved for drivers that provide a device and not for the bus using the device. The bus can use simple pointer arithmetic to retrieve its private data. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_sysfs.c | 33 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index ccb24a4212cd..221d772ded55 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -623,6 +623,8 @@ static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) #define hci_dev_lock(d) mutex_lock(&d->lock) #define hci_dev_unlock(d) mutex_unlock(&d->lock) +#define to_hci_dev(d) container_of(d, struct hci_dev, dev) + struct hci_dev *hci_dev_get(int index); struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index ec03ee2b301e..2a0243add1e4 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -189,19 +189,19 @@ static inline char *host_typetostr(int type) static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%s\n", host_bustostr(hdev->bus)); } static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type)); } static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); char name[HCI_MAX_NAME_LENGTH + 1]; int i; @@ -214,20 +214,20 @@ static ssize_t show_name(struct device *dev, struct device_attribute *attr, char static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "0x%.2x%.2x%.2x\n", hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); } static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%s\n", batostr(&hdev->bdaddr)); } static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", hdev->features[0], hdev->features[1], @@ -238,31 +238,31 @@ static ssize_t show_features(struct device *dev, struct device_attribute *attr, static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%d\n", hdev->manufacturer); } static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%d\n", hdev->hci_ver); } static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%d\n", hdev->hci_rev); } static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%d\n", hdev->idle_timeout); } static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); unsigned int val; int rv; @@ -280,13 +280,13 @@ static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *a static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%d\n", hdev->sniff_max_interval); } static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); u16 val; int rv; @@ -304,13 +304,13 @@ static ssize_t store_sniff_max_interval(struct device *dev, struct device_attrib static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); return sprintf(buf, "%d\n", hdev->sniff_min_interval); } static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct hci_dev *hdev = dev_get_drvdata(dev); + struct hci_dev *hdev = to_hci_dev(dev); u16 val; int rv; @@ -370,7 +370,7 @@ static const struct attribute_group *bt_host_groups[] = { static void bt_host_release(struct device *dev) { - void *data = dev_get_drvdata(dev); + void *data = to_hci_dev(dev); kfree(data); module_put(THIS_MODULE); } @@ -525,7 +525,6 @@ void hci_init_sysfs(struct hci_dev *hdev) dev->class = bt_class; __module_get(THIS_MODULE); - dev_set_drvdata(dev, hdev); device_initialize(dev); } -- GitLab From 155961e8001719af6d87cbcc961111e8ce477843 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 9 Feb 2012 21:58:32 +0100 Subject: [PATCH 0664/1846] Bluetooth: Remove hci_dev->driver_data The linux device model provides dev_set/get_drvdata so we can use this to save private driver data. This also removes several unnecessary casts. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/bfusb.c | 10 +++++----- drivers/bluetooth/bluecard_cs.c | 12 ++++++------ drivers/bluetooth/bpa10x.c | 18 +++++++++--------- drivers/bluetooth/bt3c_cs.c | 6 +++--- drivers/bluetooth/btmrvl_debugfs.c | 26 ++++++++++++-------------- drivers/bluetooth/btmrvl_main.c | 11 ++++++----- drivers/bluetooth/btsdio.c | 10 +++++----- drivers/bluetooth/btuart_cs.c | 6 +++--- drivers/bluetooth/btusb.c | 28 ++++++++++++++-------------- drivers/bluetooth/btwilink.c | 8 ++++---- drivers/bluetooth/dtl1_cs.c | 6 +++--- drivers/bluetooth/hci_ldisc.c | 6 +++--- drivers/bluetooth/hci_vhci.c | 8 ++++---- include/net/bluetooth/hci_core.h | 11 ++++++++++- 14 files changed, 87 insertions(+), 79 deletions(-) diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index c7d6ff0ffcf1..b8ac1c549a1c 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -411,7 +411,7 @@ static void bfusb_rx_complete(struct urb *urb) static int bfusb_open(struct hci_dev *hdev) { - struct bfusb_data *data = hdev->driver_data; + struct bfusb_data *data = hci_get_drvdata(hdev); unsigned long flags; int i, err; @@ -437,7 +437,7 @@ static int bfusb_open(struct hci_dev *hdev) static int bfusb_flush(struct hci_dev *hdev) { - struct bfusb_data *data = hdev->driver_data; + struct bfusb_data *data = hci_get_drvdata(hdev); BT_DBG("hdev %p bfusb %p", hdev, data); @@ -448,7 +448,7 @@ static int bfusb_flush(struct hci_dev *hdev) static int bfusb_close(struct hci_dev *hdev) { - struct bfusb_data *data = hdev->driver_data; + struct bfusb_data *data = hci_get_drvdata(hdev); unsigned long flags; BT_DBG("hdev %p bfusb %p", hdev, data); @@ -483,7 +483,7 @@ static int bfusb_send_frame(struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; - data = hdev->driver_data; + data = hci_get_drvdata(hdev); switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: @@ -696,7 +696,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i data->hdev = hdev; hdev->bus = HCI_USB; - hdev->driver_data = data; + hci_set_drvdata(hdev, data); SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = bfusb_open; diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 6b1261f9deb0..1fcd92380356 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -561,7 +561,7 @@ static irqreturn_t bluecard_interrupt(int irq, void *dev_inst) static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud) { - bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); + bluecard_info_t *info = hci_get_drvdata(hdev); struct sk_buff *skb; /* Ericsson baud rate command */ @@ -609,7 +609,7 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud) static int bluecard_hci_flush(struct hci_dev *hdev) { - bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); + bluecard_info_t *info = hci_get_drvdata(hdev); /* Drop TX queue */ skb_queue_purge(&(info->txq)); @@ -620,7 +620,7 @@ static int bluecard_hci_flush(struct hci_dev *hdev) static int bluecard_hci_open(struct hci_dev *hdev) { - bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); + bluecard_info_t *info = hci_get_drvdata(hdev); unsigned int iobase = info->p_dev->resource[0]->start; if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) @@ -640,7 +640,7 @@ static int bluecard_hci_open(struct hci_dev *hdev) static int bluecard_hci_close(struct hci_dev *hdev) { - bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); + bluecard_info_t *info = hci_get_drvdata(hdev); unsigned int iobase = info->p_dev->resource[0]->start; if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) @@ -667,7 +667,7 @@ static int bluecard_hci_send_frame(struct sk_buff *skb) return -ENODEV; } - info = (bluecard_info_t *)(hdev->driver_data); + info = hci_get_drvdata(hdev); switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: @@ -729,7 +729,7 @@ static int bluecard_open(bluecard_info_t *info) info->hdev = hdev; hdev->bus = HCI_PCCARD; - hdev->driver_data = info; + hci_set_drvdata(hdev, info); SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = bluecard_hci_open; diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 9d635148104c..d894340a7601 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -66,7 +66,7 @@ struct hci_vendor_hdr { static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count) { - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); BT_DBG("%s queue %d buffer %p count %d", hdev->name, queue, buf, count); @@ -189,7 +189,7 @@ static void bpa10x_tx_complete(struct urb *urb) static void bpa10x_rx_complete(struct urb *urb) { struct hci_dev *hdev = urb->context; - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s urb %p status %d count %d", hdev->name, @@ -219,7 +219,7 @@ static void bpa10x_rx_complete(struct urb *urb) static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev) { - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); struct urb *urb; unsigned char *buf; unsigned int pipe; @@ -260,7 +260,7 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev) static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev) { - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); struct urb *urb; unsigned char *buf; unsigned int pipe; @@ -301,7 +301,7 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev) static int bpa10x_open(struct hci_dev *hdev) { - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s", hdev->name); @@ -329,7 +329,7 @@ static int bpa10x_open(struct hci_dev *hdev) static int bpa10x_close(struct hci_dev *hdev) { - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); BT_DBG("%s", hdev->name); @@ -343,7 +343,7 @@ static int bpa10x_close(struct hci_dev *hdev) static int bpa10x_flush(struct hci_dev *hdev) { - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); BT_DBG("%s", hdev->name); @@ -355,7 +355,7 @@ static int bpa10x_flush(struct hci_dev *hdev) static int bpa10x_send_frame(struct sk_buff *skb) { struct hci_dev *hdev = (struct hci_dev *) skb->dev; - struct bpa10x_data *data = hdev->driver_data; + struct bpa10x_data *data = hci_get_drvdata(hdev); struct usb_ctrlrequest *dr; struct urb *urb; unsigned int pipe; @@ -459,7 +459,7 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * } hdev->bus = HCI_USB; - hdev->driver_data = data; + hci_set_drvdata(hdev, data); data->hdev = hdev; diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 0e304cb4bdea..9c09d6f05dc9 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -389,7 +389,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst) static int bt3c_hci_flush(struct hci_dev *hdev) { - bt3c_info_t *info = (bt3c_info_t *)(hdev->driver_data); + bt3c_info_t *info = hci_get_drvdata(hdev); /* Drop TX queue */ skb_queue_purge(&(info->txq)); @@ -428,7 +428,7 @@ static int bt3c_hci_send_frame(struct sk_buff *skb) return -ENODEV; } - info = (bt3c_info_t *) (hdev->driver_data); + info = hci_get_drvdata(hdev); switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: @@ -575,7 +575,7 @@ static int bt3c_open(bt3c_info_t *info) info->hdev = hdev; hdev->bus = HCI_PCCARD; - hdev->driver_data = info; + hci_set_drvdata(hdev, info); SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = bt3c_hci_open; diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c index 8ecf4c6c2874..60fe333cfd40 100644 --- a/drivers/bluetooth/btmrvl_debugfs.c +++ b/drivers/bluetooth/btmrvl_debugfs.c @@ -384,7 +384,7 @@ static const struct file_operations btmrvl_txdnldready_fops = { void btmrvl_debugfs_init(struct hci_dev *hdev) { - struct btmrvl_private *priv = hdev->driver_data; + struct btmrvl_private *priv = hci_get_drvdata(hdev); struct btmrvl_debugfs_data *dbg; if (!hdev->debugfs) @@ -401,36 +401,34 @@ void btmrvl_debugfs_init(struct hci_dev *hdev) dbg->config_dir = debugfs_create_dir("config", hdev->debugfs); dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, - hdev->driver_data, &btmrvl_psmode_fops); + priv, &btmrvl_psmode_fops); dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, - hdev->driver_data, &btmrvl_pscmd_fops); + priv, &btmrvl_pscmd_fops); dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, - hdev->driver_data, &btmrvl_gpiogap_fops); + priv, &btmrvl_gpiogap_fops); dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, - hdev->driver_data, &btmrvl_hsmode_fops); + priv, &btmrvl_hsmode_fops); dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, - hdev->driver_data, &btmrvl_hscmd_fops); + priv, &btmrvl_hscmd_fops); dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, - hdev->driver_data, &btmrvl_hscfgcmd_fops); + priv, &btmrvl_hscfgcmd_fops); dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); dbg->curpsmode = debugfs_create_file("curpsmode", 0444, - dbg->status_dir, - hdev->driver_data, - &btmrvl_curpsmode_fops); + dbg->status_dir, priv, &btmrvl_curpsmode_fops); dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, - hdev->driver_data, &btmrvl_psstate_fops); + priv, &btmrvl_psstate_fops); dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, - hdev->driver_data, &btmrvl_hsstate_fops); + priv, &btmrvl_hsstate_fops); dbg->txdnldready = debugfs_create_file("txdnldready", 0444, dbg->status_dir, - hdev->driver_data, + priv, &btmrvl_txdnldready_fops); } void btmrvl_debugfs_remove(struct hci_dev *hdev) { - struct btmrvl_private *priv = hdev->driver_data; + struct btmrvl_private *priv = hci_get_drvdata(hdev); struct btmrvl_debugfs_data *dbg = priv->debugfs_data; if (!dbg) diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index 66b58fd09fbe..d1209adc882d 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c @@ -394,12 +394,13 @@ static int btmrvl_send_frame(struct sk_buff *skb) BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len); - if (!hdev || !hdev->driver_data) { + if (!hdev) { BT_ERR("Frame for unknown HCI device"); return -ENODEV; } - priv = (struct btmrvl_private *) hdev->driver_data; + priv = hci_get_drvdata(hdev); + if (!test_bit(HCI_RUNNING, &hdev->flags)) { BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags); print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET, @@ -430,7 +431,7 @@ static int btmrvl_send_frame(struct sk_buff *skb) static int btmrvl_flush(struct hci_dev *hdev) { - struct btmrvl_private *priv = hdev->driver_data; + struct btmrvl_private *priv = hci_get_drvdata(hdev); skb_queue_purge(&priv->adapter->tx_queue); @@ -439,7 +440,7 @@ static int btmrvl_flush(struct hci_dev *hdev) static int btmrvl_close(struct hci_dev *hdev) { - struct btmrvl_private *priv = hdev->driver_data; + struct btmrvl_private *priv = hci_get_drvdata(hdev); if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) return 0; @@ -542,7 +543,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv) } priv->btmrvl_dev.hcidev = hdev; - hdev->driver_data = priv; + hci_set_drvdata(hdev, priv); hdev->bus = HCI_SDIO; hdev->open = btmrvl_open; diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index 2d6e4ed1637f..e10ea0347051 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -189,7 +189,7 @@ static void btsdio_interrupt(struct sdio_func *func) static int btsdio_open(struct hci_dev *hdev) { - struct btsdio_data *data = hdev->driver_data; + struct btsdio_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s", hdev->name); @@ -225,7 +225,7 @@ static int btsdio_open(struct hci_dev *hdev) static int btsdio_close(struct hci_dev *hdev) { - struct btsdio_data *data = hdev->driver_data; + struct btsdio_data *data = hci_get_drvdata(hdev); BT_DBG("%s", hdev->name); @@ -246,7 +246,7 @@ static int btsdio_close(struct hci_dev *hdev) static int btsdio_flush(struct hci_dev *hdev) { - struct btsdio_data *data = hdev->driver_data; + struct btsdio_data *data = hci_get_drvdata(hdev); BT_DBG("%s", hdev->name); @@ -258,7 +258,7 @@ static int btsdio_flush(struct hci_dev *hdev) static int btsdio_send_frame(struct sk_buff *skb) { struct hci_dev *hdev = (struct hci_dev *) skb->dev; - struct btsdio_data *data = hdev->driver_data; + struct btsdio_data *data = hci_get_drvdata(hdev); BT_DBG("%s", hdev->name); @@ -321,7 +321,7 @@ static int btsdio_probe(struct sdio_func *func, } hdev->bus = HCI_SDIO; - hdev->driver_data = data; + hci_set_drvdata(hdev, data); if (id->class == SDIO_CLASS_BT_AMP) hdev->dev_type = HCI_AMP; diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 80ad2b9b352e..194224d07f7c 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -397,7 +397,7 @@ static void btuart_change_speed(btuart_info_t *info, unsigned int speed) static int btuart_hci_flush(struct hci_dev *hdev) { - btuart_info_t *info = (btuart_info_t *)(hdev->driver_data); + btuart_info_t *info = hci_get_drvdata(hdev); /* Drop TX queue */ skb_queue_purge(&(info->txq)); @@ -435,7 +435,7 @@ static int btuart_hci_send_frame(struct sk_buff *skb) return -ENODEV; } - info = (btuart_info_t *)(hdev->driver_data); + info = hci_get_drvdata(hdev); switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: @@ -493,7 +493,7 @@ static int btuart_open(btuart_info_t *info) info->hdev = hdev; hdev->bus = HCI_PCCARD; - hdev->driver_data = info; + hci_set_drvdata(hdev, info); SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = btuart_hci_open; diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index afcd2816a24b..f4fb256d6ca6 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -243,7 +243,7 @@ static int inc_tx(struct btusb_data *data) static void btusb_intr_complete(struct urb *urb) { struct hci_dev *hdev = urb->context; - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s urb %p status %d count %d", hdev->name, @@ -282,7 +282,7 @@ static void btusb_intr_complete(struct urb *urb) static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); struct urb *urb; unsigned char *buf; unsigned int pipe; @@ -331,7 +331,7 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) static void btusb_bulk_complete(struct urb *urb) { struct hci_dev *hdev = urb->context; - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s urb %p status %d count %d", hdev->name, @@ -370,7 +370,7 @@ static void btusb_bulk_complete(struct urb *urb) static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); struct urb *urb; unsigned char *buf; unsigned int pipe; @@ -417,7 +417,7 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags) static void btusb_isoc_complete(struct urb *urb) { struct hci_dev *hdev = urb->context; - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); int i, err; BT_DBG("%s urb %p status %d count %d", hdev->name, @@ -484,7 +484,7 @@ static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu) static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); struct urb *urb; unsigned char *buf; unsigned int pipe; @@ -537,7 +537,7 @@ static void btusb_tx_complete(struct urb *urb) { struct sk_buff *skb = urb->context; struct hci_dev *hdev = (struct hci_dev *) skb->dev; - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, urb->actual_length); @@ -584,7 +584,7 @@ static void btusb_isoc_tx_complete(struct urb *urb) static int btusb_open(struct hci_dev *hdev) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s", hdev->name); @@ -634,7 +634,7 @@ static void btusb_stop_traffic(struct btusb_data *data) static int btusb_close(struct hci_dev *hdev) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); int err; BT_DBG("%s", hdev->name); @@ -664,7 +664,7 @@ static int btusb_close(struct hci_dev *hdev) static int btusb_flush(struct hci_dev *hdev) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); BT_DBG("%s", hdev->name); @@ -676,7 +676,7 @@ static int btusb_flush(struct hci_dev *hdev) static int btusb_send_frame(struct sk_buff *skb) { struct hci_dev *hdev = (struct hci_dev *) skb->dev; - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); struct usb_ctrlrequest *dr; struct urb *urb; unsigned int pipe; @@ -786,7 +786,7 @@ static int btusb_send_frame(struct sk_buff *skb) static void btusb_notify(struct hci_dev *hdev, unsigned int evt) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); BT_DBG("%s evt %d", hdev->name, evt); @@ -798,7 +798,7 @@ static void btusb_notify(struct hci_dev *hdev, unsigned int evt) static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting) { - struct btusb_data *data = hdev->driver_data; + struct btusb_data *data = hci_get_drvdata(hdev); struct usb_interface *intf = data->isoc; struct usb_endpoint_descriptor *ep_desc; int i, err; @@ -986,7 +986,7 @@ static int btusb_probe(struct usb_interface *intf, } hdev->bus = HCI_USB; - hdev->driver_data = data; + hci_set_drvdata(hdev, data); data->hdev = hdev; diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c index b81b32e4fa12..88694697f34f 100644 --- a/drivers/bluetooth/btwilink.c +++ b/drivers/bluetooth/btwilink.c @@ -161,7 +161,7 @@ static int ti_st_open(struct hci_dev *hdev) return -EBUSY; /* provide contexts for callbacks from ST */ - hst = hdev->driver_data; + hst = hci_get_drvdata(hdev); for (i = 0; i < MAX_BT_CHNL_IDS; i++) { ti_st_proto[i].priv_data = hst; @@ -236,7 +236,7 @@ static int ti_st_open(struct hci_dev *hdev) static int ti_st_close(struct hci_dev *hdev) { int err, i; - struct ti_st *hst = hdev->driver_data; + struct ti_st *hst = hci_get_drvdata(hdev); if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) return 0; @@ -264,7 +264,7 @@ static int ti_st_send_frame(struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; - hst = hdev->driver_data; + hst = hci_get_drvdata(hdev); /* Prepend skb with frame type */ memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); @@ -312,7 +312,7 @@ static int bt_ti_probe(struct platform_device *pdev) hst->hdev = hdev; hdev->bus = HCI_UART; - hdev->driver_data = hst; + hci_set_drvdata(hdev, hst); hdev->open = ti_st_open; hdev->close = ti_st_close; hdev->flush = NULL; diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 295cf1b4a052..049c0594a76b 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -364,7 +364,7 @@ static int dtl1_hci_open(struct hci_dev *hdev) static int dtl1_hci_flush(struct hci_dev *hdev) { - dtl1_info_t *info = (dtl1_info_t *)(hdev->driver_data); + dtl1_info_t *info = hci_get_drvdata(hdev); /* Drop TX queue */ skb_queue_purge(&(info->txq)); @@ -396,7 +396,7 @@ static int dtl1_hci_send_frame(struct sk_buff *skb) return -ENODEV; } - info = (dtl1_info_t *)(hdev->driver_data); + info = hci_get_drvdata(hdev); switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: @@ -475,7 +475,7 @@ static int dtl1_open(dtl1_info_t *info) info->hdev = hdev; hdev->bus = HCI_PCCARD; - hdev->driver_data = info; + hci_set_drvdata(hdev, info); SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = dtl1_hci_open; diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 459ff0ba5a42..01c23dfe2a10 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -174,7 +174,7 @@ static int hci_uart_open(struct hci_dev *hdev) /* Reset device */ static int hci_uart_flush(struct hci_dev *hdev) { - struct hci_uart *hu = (struct hci_uart *) hdev->driver_data; + struct hci_uart *hu = hci_get_drvdata(hdev); struct tty_struct *tty = hu->tty; BT_DBG("hdev %p tty %p", hdev, tty); @@ -220,7 +220,7 @@ static int hci_uart_send_frame(struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; - hu = (struct hci_uart *) hdev->driver_data; + hu = hci_get_drvdata(hdev); BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len); @@ -384,7 +384,7 @@ static int hci_uart_register_dev(struct hci_uart *hu) hu->hdev = hdev; hdev->bus = HCI_UART; - hdev->driver_data = hu; + hci_set_drvdata(hdev, hu); hdev->open = hci_uart_open; hdev->close = hci_uart_close; diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 5f305c131a0d..158bfe507da7 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -61,7 +61,7 @@ static int vhci_open_dev(struct hci_dev *hdev) static int vhci_close_dev(struct hci_dev *hdev) { - struct vhci_data *data = hdev->driver_data; + struct vhci_data *data = hci_get_drvdata(hdev); if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) return 0; @@ -73,7 +73,7 @@ static int vhci_close_dev(struct hci_dev *hdev) static int vhci_flush(struct hci_dev *hdev) { - struct vhci_data *data = hdev->driver_data; + struct vhci_data *data = hci_get_drvdata(hdev); skb_queue_purge(&data->readq); @@ -93,7 +93,7 @@ static int vhci_send_frame(struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; - data = hdev->driver_data; + data = hci_get_drvdata(hdev); memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); skb_queue_tail(&data->readq, skb); @@ -234,7 +234,7 @@ static int vhci_open(struct inode *inode, struct file *file) data->hdev = hdev; hdev->bus = HCI_VIRTUAL; - hdev->driver_data = data; + hci_set_drvdata(hdev, data); if (amp) hdev->dev_type = HCI_AMP; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 221d772ded55..4559189a22a1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -254,7 +254,6 @@ struct hci_dev { struct sk_buff_head driver_init; - void *driver_data; void *core_data; atomic_t promisc; @@ -625,6 +624,16 @@ static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) #define to_hci_dev(d) container_of(d, struct hci_dev, dev) +static inline void *hci_get_drvdata(struct hci_dev *hdev) +{ + return dev_get_drvdata(&hdev->dev); +} + +static inline void hci_set_drvdata(struct hci_dev *hdev, void *data) +{ + dev_set_drvdata(&hdev->dev, data); +} + struct hci_dev *hci_dev_get(int index); struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); -- GitLab From 3dc07322b1ce3c8477690d54ebbf15a165f43066 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 9 Feb 2012 21:58:33 +0100 Subject: [PATCH 0665/1846] Bluetooth: Introduce to_hci_conn This avoids using the dev_set/get_drvdata() functions to retrieve a pointer to our own structure. We can use simple pointer arithmetic here. The drvdata field is actually not needed by any other code-path but this makes the code more consistent with hci_dev. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_sysfs.c | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4559189a22a1..b20d990436b4 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -623,6 +623,7 @@ static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) #define hci_dev_unlock(d) mutex_unlock(&d->lock) #define to_hci_dev(d) container_of(d, struct hci_dev, dev) +#define to_hci_conn(c) container_of(c, struct hci_conn, dev) static inline void *hci_get_drvdata(struct hci_dev *hdev) { diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 2a0243add1e4..17e6cd48ad4d 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -33,19 +33,19 @@ static inline char *link_typetostr(int type) static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_conn *conn = dev_get_drvdata(dev); + struct hci_conn *conn = to_hci_conn(dev); return sprintf(buf, "%s\n", link_typetostr(conn->type)); } static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_conn *conn = dev_get_drvdata(dev); + struct hci_conn *conn = to_hci_conn(dev); return sprintf(buf, "%s\n", batostr(&conn->dst)); } static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf) { - struct hci_conn *conn = dev_get_drvdata(dev); + struct hci_conn *conn = to_hci_conn(dev); return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", conn->features[0], conn->features[1], @@ -79,7 +79,7 @@ static const struct attribute_group *bt_link_groups[] = { static void bt_link_release(struct device *dev) { - void *data = dev_get_drvdata(dev); + void *data = to_hci_conn(dev); kfree(data); } @@ -120,8 +120,6 @@ void hci_conn_add_sysfs(struct hci_conn *conn) dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); - dev_set_drvdata(&conn->dev, conn); - if (device_add(&conn->dev) < 0) { BT_ERR("Failed to register connection device"); return; -- GitLab From 2dd106887d6503819f2cedc408497023547439bb Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 9 Feb 2012 21:58:34 +0100 Subject: [PATCH 0666/1846] Bluetooth: Use proper datatypes in release-callbacks This enhances code readability a lot and avoids using void* even though we know the type of the variable. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 17e6cd48ad4d..bc154298979a 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -79,8 +79,8 @@ static const struct attribute_group *bt_link_groups[] = { static void bt_link_release(struct device *dev) { - void *data = to_hci_conn(dev); - kfree(data); + struct hci_conn *conn = to_hci_conn(dev); + kfree(conn); } static struct device_type bt_link = { @@ -368,8 +368,8 @@ static const struct attribute_group *bt_host_groups[] = { static void bt_host_release(struct device *dev) { - void *data = to_hci_dev(dev); - kfree(data); + struct hci_dev *hdev = to_hci_dev(dev); + kfree(hdev); module_put(THIS_MODULE); } -- GitLab From 9ab875affbe61b2c88685c342461c9a367ab7a3e Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 9 Feb 2012 21:58:31 +0100 Subject: [PATCH 0667/1846] Bluetooth: btusb: Remove device lock on release Recently we changed the way how we release driver-data. A driver is now responsible of destroying the data so we no longer need the device lock on deinitialization in btusb driver. Signed-off-by: David Herrmann Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/btusb.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index f4fb256d6ca6..066d5ec83a9b 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1079,9 +1079,6 @@ static void btusb_disconnect(struct usb_interface *intf) return; hdev = data->hdev; - - hci_dev_hold(hdev); - usb_set_intfdata(data->intf, NULL); if (data->isoc) @@ -1094,8 +1091,6 @@ static void btusb_disconnect(struct usb_interface *intf) else if (data->isoc) usb_driver_release_interface(&btusb_driver, data->isoc); - hci_dev_put(hdev); - hci_free_dev(hdev); kfree(data); } -- GitLab From ffacd472c4c577c9d39a97a1f7ac36f59443723b Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:54:42 +0000 Subject: [PATCH 0668/1846] e1000e: cleanup: use goto for common work needed by multiple exit points There are two exit points of e1000e_write_nvm_spi() which require the nvm->ops.release() function pointer called just before exiting. Consolidate the two duplicate pieces of common work with a goto. With this change, the value ret_val will need to be returned instead of 0. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/nvm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c index f6fb7a768ba5..1b50db59fb0d 100644 --- a/drivers/net/ethernet/intel/e1000e/nvm.c +++ b/drivers/net/ethernet/intel/e1000e/nvm.c @@ -382,10 +382,8 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) u8 write_opcode = NVM_WRITE_OPCODE_SPI; ret_val = e1000_ready_nvm_eeprom(hw); - if (ret_val) { - nvm->ops.release(hw); - return ret_val; - } + if (ret_val) + goto release; e1000_standby_nvm(hw); @@ -422,8 +420,10 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) } usleep_range(10000, 20000); +release: nvm->ops.release(hw); - return 0; + + return ret_val; } /** -- GitLab From 75ce15327030128d713079d1f5e23cbe7af532f6 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:54:48 +0000 Subject: [PATCH 0669/1846] e1000e: cleanup: rename goto labels to be more meaningful In the following functions, rename the generic 'out' goto label to the more descriptive 'release' to indicate the type of common work that is done before exiting the functions. No functional change, cosmetic only. e1000_sw_lcd_config_ich8lan() e1000_oem_bits_config_ich8lan() e1000_init_phy_wakeup() e1000e_write_phy_reg_bm() e1000e_read_phy_reg_bm() e1000e_read_phy_reg_bm2() Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 26 ++++++++++----------- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- drivers/net/ethernet/intel/e1000e/phy.c | 24 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 112d55f76b79..6ab7254487ad 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1065,7 +1065,7 @@ static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) data = er32(FEXTNVM); if (!(data & sw_cfg_mask)) - goto out; + goto release; /* * Make sure HW does not configure LCD from PHY @@ -1074,14 +1074,14 @@ static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) data = er32(EXTCNF_CTRL); if (!(hw->mac.type == e1000_pch2lan)) { if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE) - goto out; + goto release; } cnf_size = er32(EXTCNF_SIZE); cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK; cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT; if (!cnf_size) - goto out; + goto release; cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK; cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT; @@ -1097,13 +1097,13 @@ static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) */ ret_val = e1000_write_smbus_addr(hw); if (ret_val) - goto out; + goto release; data = er32(LEDCTL); ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG, (u16)data); if (ret_val) - goto out; + goto release; } /* Configure LCD from extended configuration region. */ @@ -1115,12 +1115,12 @@ static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, ®_data); if (ret_val) - goto out; + goto release; ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1), 1, ®_addr); if (ret_val) - goto out; + goto release; /* Save off the PHY page for future writes. */ if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) { @@ -1134,10 +1134,10 @@ static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr, reg_data); if (ret_val) - goto out; + goto release; } -out: +release: hw->phy.ops.release(hw); return ret_val; } @@ -1302,18 +1302,18 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state) if (!(hw->mac.type == e1000_pch2lan)) { mac_reg = er32(EXTCNF_CTRL); if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) - goto out; + goto release; } mac_reg = er32(FEXTNVM); if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M)) - goto out; + goto release; mac_reg = er32(PHY_CTRL); ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg); if (ret_val) - goto out; + goto release; oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU); @@ -1339,7 +1339,7 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state) ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg); -out: +release: hw->phy.ops.release(hw); return ret_val; diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index f868fb822a30..c11b40b81acf 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -5365,7 +5365,7 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc) /* Enable access to wakeup registers on and set page to BM_WUC_PAGE */ retval = e1000_enable_phy_wakeup_reg_access_bm(hw, &wuc_enable); if (retval) - goto out; + goto release; /* copy MAC MTA to PHY MTA - only needed for pchlan */ for (i = 0; i < adapter->hw.mac.mta_reg_count; i++) { @@ -5409,7 +5409,7 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc) retval = e1000_disable_phy_wakeup_reg_access_bm(hw, &wuc_enable); if (retval) e_err("Could not set PHY Host Wakeup bit\n"); -out: +release: hw->phy.ops.release(hw); return retval; diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 6f44c3fb80b6..70e8eb6d49d8 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -2438,7 +2438,7 @@ s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) if (page == BM_WUC_PAGE) { ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, false, false); - goto out; + goto release; } hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); @@ -2463,13 +2463,13 @@ s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) ret_val = e1000e_write_phy_reg_mdic(hw, page_select, (page << page_shift)); if (ret_val) - goto out; + goto release; } ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, data); -out: +release: hw->phy.ops.release(hw); return ret_val; } @@ -2497,7 +2497,7 @@ s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) if (page == BM_WUC_PAGE) { ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, true, false); - goto out; + goto release; } hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); @@ -2522,12 +2522,12 @@ s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) ret_val = e1000e_write_phy_reg_mdic(hw, page_select, (page << page_shift)); if (ret_val) - goto out; + goto release; } ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, data); -out: +release: hw->phy.ops.release(hw); return ret_val; } @@ -2555,7 +2555,7 @@ s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) if (page == BM_WUC_PAGE) { ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, true, false); - goto out; + goto release; } hw->phy.addr = 1; @@ -2567,12 +2567,12 @@ s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) page); if (ret_val) - goto out; + goto release; } ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, data); -out: +release: hw->phy.ops.release(hw); return ret_val; } @@ -2599,7 +2599,7 @@ s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) if (page == BM_WUC_PAGE) { ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, false, false); - goto out; + goto release; } hw->phy.addr = 1; @@ -2610,13 +2610,13 @@ s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) page); if (ret_val) - goto out; + goto release; } ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, data); -out: +release: hw->phy.ops.release(hw); return ret_val; } -- GitLab From 520d6f225f83128e9ea083a9a226f807235cc76c Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:54:53 +0000 Subject: [PATCH 0670/1846] e1000e: potentially incorrect return for e1000_cfg_kmrn_10_100_80003es2lan In the unlikely event that e1e_wphy() returns an error, the returned error code value is not propogated to the caller of e1000_cfg_kmrn_10_100_80003es2lan(). Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index cfb361e5f498..37e78649c710 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1225,9 +1225,7 @@ static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex) else reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; - ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); - - return 0; + return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); } /** -- GitLab From 8649f4319656f9fcaa59726799a824254b0a1bce Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:54:58 +0000 Subject: [PATCH 0671/1846] e1000e: potential incorrect return for e1000_setup_copper_link_80003es2lan In the unlikely event that e1000e_setup_copper_link() returns an error, the returned error code value is not propogated to the caller of e1000_setup_copper_link_80003es2lan(). Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 37e78649c710..99eb09007e73 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1147,9 +1147,7 @@ static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw) if (ret_val) return ret_val; - ret_val = e1000e_setup_copper_link(hw); - - return 0; + return e1000e_setup_copper_link(hw); } /** -- GitLab From 7eb61d81946ccb61726600c6e8ceefcce9844f02 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:03 +0000 Subject: [PATCH 0672/1846] e1000e: cleanup: remove unnecessary assignments just before returning Just return the appropriate value. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 10 +++------- drivers/net/ethernet/intel/e1000e/82571.c | 4 +--- drivers/net/ethernet/intel/e1000e/mac.c | 6 ++---- drivers/net/ethernet/intel/e1000e/phy.c | 3 +-- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 99eb09007e73..05a79cbb1ca8 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -470,9 +470,8 @@ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp); if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { - ret_val = -E1000_ERR_PHY; e1000_release_phy_80003es2lan(hw); - return ret_val; + return -E1000_ERR_PHY; } udelay(200); @@ -804,9 +803,7 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) ew32(IMC, 0xffffffff); er32(ICR); - ret_val = e1000_check_alt_mac_addr_generic(hw); - - return ret_val; + return e1000_check_alt_mac_addr_generic(hw); } /** @@ -1265,9 +1262,8 @@ static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw) } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY)); reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; - ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); - return ret_val; + return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data); } /** diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 795c3d640615..024ac243e23f 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1497,9 +1497,7 @@ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) if (ret_val) return ret_val; - ret_val = e1000e_setup_copper_link(hw); - - return ret_val; + return e1000e_setup_copper_link(hw); } /** diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 83f93684dc2f..ce8a55a584be 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -458,10 +458,8 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) * If we are forcing speed/duplex, then we simply return since * we have already determined whether we have link or not. */ - if (!mac->autoneg) { - ret_val = -E1000_ERR_CONFIG; - return ret_val; - } + if (!mac->autoneg) + return -E1000_ERR_CONFIG; /* * Auto-Neg is enabled. Auto Speed Detection takes care diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 70e8eb6d49d8..323cb145f849 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1064,8 +1064,7 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw) break; default: e_dbg("Flow control param set incorrectly\n"); - ret_val = -E1000_ERR_CONFIG; - return ret_val; + return -E1000_ERR_CONFIG; } ret_val = e1e_wphy(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); -- GitLab From 826072555b0dceac44a6e69a0c5be137e829c9d4 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:09 +0000 Subject: [PATCH 0673/1846] e1000e: cleanup: always return 0 These are a few instances of returning a value that can only be 0 so just use a 'return 0' to make it more obvious. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/82571.c | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- drivers/net/ethernet/intel/e1000e/phy.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 024ac243e23f..05e9a2911168 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -796,7 +796,7 @@ static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw) * otherwise, commit the checksum to the flash NVM. */ if (hw->nvm.type != e1000_nvm_flash_hw) - return ret_val; + return 0; /* Check for pending operations. */ for (i = 0; i < E1000_FLASH_UPDATES; i++) { diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 6ab7254487ad..ce348cd99d53 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1948,7 +1948,7 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active) u16 data; if (phy->type == e1000_phy_ife) - return ret_val; + return 0; phy_ctrl = er32(PHY_CTRL); diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index ce8a55a584be..b3b2f9e567ff 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -444,7 +444,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) return ret_val; if (!link) - return ret_val; /* No link detected */ + return 0; /* No link detected */ mac->get_link_status = false; diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 323cb145f849..a8b99bae0222 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1916,7 +1916,7 @@ s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw) phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; - return ret_val; + return 0; } /** -- GitLab From 58472a76cf811c40668bab20410c71f795774361 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 13 Feb 2012 06:53:41 +0000 Subject: [PATCH 0674/1846] virtio: net: remove sparse errors commit 3fa2a1df909 (virtio-net: per cpu 64 bit stats (v2)) added extra __percpu qualifiers and sparse errors. Signed-off-by: Eric Dumazet Cc: Stephen Hemminger Cc: Rusty Russell Signed-off-by: David S. Miller --- drivers/net/virtio_net.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 4880aa8b4c28..83c503ed4ae8 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -255,7 +255,7 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb) static void receive_buf(struct net_device *dev, void *buf, unsigned int len) { struct virtnet_info *vi = netdev_priv(dev); - struct virtnet_stats __percpu *stats = this_cpu_ptr(vi->stats); + struct virtnet_stats *stats = this_cpu_ptr(vi->stats); struct sk_buff *skb; struct page *page; struct skb_vnet_hdr *hdr; @@ -549,7 +549,7 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) { struct sk_buff *skb; unsigned int len, tot_sgs = 0; - struct virtnet_stats __percpu *stats = this_cpu_ptr(vi->stats); + struct virtnet_stats *stats = this_cpu_ptr(vi->stats); while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) { pr_debug("Sent skb %p\n", skb); @@ -688,8 +688,7 @@ static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev, unsigned int start; for_each_possible_cpu(cpu) { - struct virtnet_stats __percpu *stats - = per_cpu_ptr(vi->stats, cpu); + struct virtnet_stats *stats = per_cpu_ptr(vi->stats, cpu); u64 tpackets, tbytes, rpackets, rbytes; do { -- GitLab From ebf3312e781aee1bc22bb3a42cb324eb973a7c02 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:05 +0000 Subject: [PATCH 0675/1846] tg3: Move tg3_restart_hw to a better location This patch relocates tg3_restart_hw() to a better location. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 56 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 3bf3adca3695..a352c44d31ec 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -6292,33 +6292,6 @@ static irqreturn_t tg3_test_isr(int irq, void *dev_id) return IRQ_RETVAL(0); } -static int tg3_init_hw(struct tg3 *, int); -static int tg3_halt(struct tg3 *, int, int); - -/* Restart hardware after configuration changes, self-test, etc. - * Invoked with tp->lock held. - */ -static int tg3_restart_hw(struct tg3 *tp, int reset_phy) - __releases(tp->lock) - __acquires(tp->lock) -{ - int err; - - err = tg3_init_hw(tp, reset_phy); - if (err) { - netdev_err(tp->dev, - "Failed to re-initialize device, aborting\n"); - tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); - tg3_full_unlock(tp); - del_timer_sync(&tp->timer); - tp->irq_sync = 0; - tg3_napi_enable(tp); - dev_close(tp->dev); - tg3_full_lock(tp, 0); - } - return err; -} - #ifdef CONFIG_NET_POLL_CONTROLLER static void tg3_poll_controller(struct net_device *dev) { @@ -6330,6 +6303,9 @@ static void tg3_poll_controller(struct net_device *dev) } #endif +static int tg3_init_hw(struct tg3 *, int); +static int tg3_halt(struct tg3 *, int, int); + static void tg3_reset_task(struct work_struct *work) { struct tg3 *tp = container_of(work, struct tg3, reset_task); @@ -7014,6 +6990,8 @@ static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp, } } +static int tg3_restart_hw(struct tg3 *tp, int reset_phy); + static int tg3_change_mtu(struct net_device *dev, int new_mtu) { struct tg3 *tp = netdev_priv(dev); @@ -9135,6 +9113,30 @@ static int tg3_init_hw(struct tg3 *tp, int reset_phy) return tg3_reset_hw(tp, reset_phy); } +/* Restart hardware after configuration changes, self-test, etc. + * Invoked with tp->lock held. + */ +static int tg3_restart_hw(struct tg3 *tp, int reset_phy) + __releases(tp->lock) + __acquires(tp->lock) +{ + int err; + + err = tg3_init_hw(tp, reset_phy); + if (err) { + netdev_err(tp->dev, + "Failed to re-initialize device, aborting\n"); + tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); + tg3_full_unlock(tp); + del_timer_sync(&tp->timer); + tp->irq_sync = 0; + tg3_napi_enable(tp); + dev_close(tp->dev); + tg3_full_lock(tp, 0); + } + return err; +} + #define TG3_STAT_ADD32(PSTAT, REG) \ do { u32 __val = tr32(REG); \ (PSTAT)->low += __val; \ -- GitLab From 9a21fb8fc3a74429a4eee2d53df5a3167c290f2a Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:06 +0000 Subject: [PATCH 0676/1846] tg3: Relocate tg3_reset_task This patch moves tg3_reset_task further down in the file where it makes more sense to be. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 92 ++++++++++++++--------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index a352c44d31ec..3ab1af67d7d9 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -6303,53 +6303,6 @@ static void tg3_poll_controller(struct net_device *dev) } #endif -static int tg3_init_hw(struct tg3 *, int); -static int tg3_halt(struct tg3 *, int, int); - -static void tg3_reset_task(struct work_struct *work) -{ - struct tg3 *tp = container_of(work, struct tg3, reset_task); - int err; - - tg3_full_lock(tp, 0); - - if (!netif_running(tp->dev)) { - tg3_flag_clear(tp, RESET_TASK_PENDING); - tg3_full_unlock(tp); - return; - } - - tg3_full_unlock(tp); - - tg3_phy_stop(tp); - - tg3_netif_stop(tp); - - tg3_full_lock(tp, 1); - - if (tg3_flag(tp, TX_RECOVERY_PENDING)) { - tp->write32_tx_mbox = tg3_write32_tx_mbox; - tp->write32_rx_mbox = tg3_write_flush_reg32; - tg3_flag_set(tp, MBOX_WRITE_REORDER); - tg3_flag_clear(tp, TX_RECOVERY_PENDING); - } - - tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); - err = tg3_init_hw(tp, 1); - if (err) - goto out; - - tg3_netif_start(tp); - -out: - tg3_full_unlock(tp); - - if (!err) - tg3_phy_start(tp); - - tg3_flag_clear(tp, RESET_TASK_PENDING); -} - static void tg3_tx_timeout(struct net_device *dev) { struct tg3 *tp = netdev_priv(dev); @@ -6991,6 +6944,7 @@ static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp, } static int tg3_restart_hw(struct tg3 *tp, int reset_phy); +static int tg3_halt(struct tg3 *, int, int); static int tg3_change_mtu(struct net_device *dev, int new_mtu) { @@ -9137,6 +9091,50 @@ static int tg3_restart_hw(struct tg3 *tp, int reset_phy) return err; } +static void tg3_reset_task(struct work_struct *work) +{ + struct tg3 *tp = container_of(work, struct tg3, reset_task); + int err; + + tg3_full_lock(tp, 0); + + if (!netif_running(tp->dev)) { + tg3_flag_clear(tp, RESET_TASK_PENDING); + tg3_full_unlock(tp); + return; + } + + tg3_full_unlock(tp); + + tg3_phy_stop(tp); + + tg3_netif_stop(tp); + + tg3_full_lock(tp, 1); + + if (tg3_flag(tp, TX_RECOVERY_PENDING)) { + tp->write32_tx_mbox = tg3_write32_tx_mbox; + tp->write32_rx_mbox = tg3_write_flush_reg32; + tg3_flag_set(tp, MBOX_WRITE_REORDER); + tg3_flag_clear(tp, TX_RECOVERY_PENDING); + } + + tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); + err = tg3_init_hw(tp, 1); + if (err) + goto out; + + tg3_netif_start(tp); + +out: + tg3_full_unlock(tp); + + if (!err) + tg3_phy_start(tp); + + tg3_flag_clear(tp, RESET_TASK_PENDING); +} + #define TG3_STAT_ADD32(PSTAT, REG) \ do { u32 __val = tr32(REG); \ (PSTAT)->low += __val; \ -- GitLab From faf1627ac15d25687259844575a128e9f06f3e6f Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:07 +0000 Subject: [PATCH 0677/1846] tg3: Move tg3_change_mtu to a better location This patch moves tg3_change_mtu to a better location. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 159 ++++++++++++++-------------- 1 file changed, 78 insertions(+), 81 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 3ab1af67d7d9..7cf39b2e8cc7 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -6922,69 +6922,6 @@ static int tg3_set_features(struct net_device *dev, netdev_features_t features) return 0; } -static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp, - int new_mtu) -{ - dev->mtu = new_mtu; - - if (new_mtu > ETH_DATA_LEN) { - if (tg3_flag(tp, 5780_CLASS)) { - netdev_update_features(dev); - tg3_flag_clear(tp, TSO_CAPABLE); - } else { - tg3_flag_set(tp, JUMBO_RING_ENABLE); - } - } else { - if (tg3_flag(tp, 5780_CLASS)) { - tg3_flag_set(tp, TSO_CAPABLE); - netdev_update_features(dev); - } - tg3_flag_clear(tp, JUMBO_RING_ENABLE); - } -} - -static int tg3_restart_hw(struct tg3 *tp, int reset_phy); -static int tg3_halt(struct tg3 *, int, int); - -static int tg3_change_mtu(struct net_device *dev, int new_mtu) -{ - struct tg3 *tp = netdev_priv(dev); - int err; - - if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU(tp)) - return -EINVAL; - - if (!netif_running(dev)) { - /* We'll just catch it later when the - * device is up'd. - */ - tg3_set_mtu(dev, tp, new_mtu); - return 0; - } - - tg3_phy_stop(tp); - - tg3_netif_stop(tp); - - tg3_full_lock(tp, 1); - - tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); - - tg3_set_mtu(dev, tp, new_mtu); - - err = tg3_restart_hw(tp, 0); - - if (!err) - tg3_netif_start(tp); - - tg3_full_unlock(tp); - - if (!err) - tg3_phy_start(tp); - - return err; -} - static void tg3_rx_prodring_free(struct tg3 *tp, struct tg3_rx_prodring_set *tpr) { @@ -12040,6 +11977,84 @@ static const struct ethtool_ops tg3_ethtool_ops = { .set_rxfh_indir = tg3_set_rxfh_indir, }; +static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp, + int new_mtu) +{ + dev->mtu = new_mtu; + + if (new_mtu > ETH_DATA_LEN) { + if (tg3_flag(tp, 5780_CLASS)) { + netdev_update_features(dev); + tg3_flag_clear(tp, TSO_CAPABLE); + } else { + tg3_flag_set(tp, JUMBO_RING_ENABLE); + } + } else { + if (tg3_flag(tp, 5780_CLASS)) { + tg3_flag_set(tp, TSO_CAPABLE); + netdev_update_features(dev); + } + tg3_flag_clear(tp, JUMBO_RING_ENABLE); + } +} + +static int tg3_change_mtu(struct net_device *dev, int new_mtu) +{ + struct tg3 *tp = netdev_priv(dev); + int err; + + if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU(tp)) + return -EINVAL; + + if (!netif_running(dev)) { + /* We'll just catch it later when the + * device is up'd. + */ + tg3_set_mtu(dev, tp, new_mtu); + return 0; + } + + tg3_phy_stop(tp); + + tg3_netif_stop(tp); + + tg3_full_lock(tp, 1); + + tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); + + tg3_set_mtu(dev, tp, new_mtu); + + err = tg3_restart_hw(tp, 0); + + if (!err) + tg3_netif_start(tp); + + tg3_full_unlock(tp); + + if (!err) + tg3_phy_start(tp); + + return err; +} + +static const struct net_device_ops tg3_netdev_ops = { + .ndo_open = tg3_open, + .ndo_stop = tg3_close, + .ndo_start_xmit = tg3_start_xmit, + .ndo_get_stats64 = tg3_get_stats64, + .ndo_validate_addr = eth_validate_addr, + .ndo_set_rx_mode = tg3_set_rx_mode, + .ndo_set_mac_address = tg3_set_mac_addr, + .ndo_do_ioctl = tg3_ioctl, + .ndo_tx_timeout = tg3_tx_timeout, + .ndo_change_mtu = tg3_change_mtu, + .ndo_fix_features = tg3_fix_features, + .ndo_set_features = tg3_set_features, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = tg3_poll_controller, +#endif +}; + static void __devinit tg3_get_eeprom_size(struct tg3 *tp) { u32 cursize, val, magic; @@ -15409,24 +15424,6 @@ static void __devinit tg3_init_coal(struct tg3 *tp) } } -static const struct net_device_ops tg3_netdev_ops = { - .ndo_open = tg3_open, - .ndo_stop = tg3_close, - .ndo_start_xmit = tg3_start_xmit, - .ndo_get_stats64 = tg3_get_stats64, - .ndo_validate_addr = eth_validate_addr, - .ndo_set_rx_mode = tg3_set_rx_mode, - .ndo_set_mac_address = tg3_set_mac_addr, - .ndo_do_ioctl = tg3_ioctl, - .ndo_tx_timeout = tg3_tx_timeout, - .ndo_change_mtu = tg3_change_mtu, - .ndo_fix_features = tg3_fix_features, - .ndo_set_features = tg3_set_features, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = tg3_poll_controller, -#endif -}; - static int __devinit tg3_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { -- GitLab From ccd5ba9db50d09d6d6e2d91d76d3b27fff8f6ed5 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:08 +0000 Subject: [PATCH 0678/1846] tg3: Move tg3_set_rx_mode This patch moves __tg3_set_rx_mode above its first use and moves tg3_set_rx_mode down closer to where the netdev_ops functions should be. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 199 ++++++++++++++-------------- 1 file changed, 99 insertions(+), 100 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 7cf39b2e8cc7..df04a58a55fa 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7847,7 +7847,6 @@ static void tg3_set_bdinfo(struct tg3 *tp, u32 bdinfo_addr, nic_addr); } -static void __tg3_set_rx_mode(struct net_device *); static void __tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec) { int i; @@ -8084,6 +8083,93 @@ static void tg3_setup_rxbd_thresholds(struct tg3 *tp) tw32(JMB_REPLENISH_LWM, bdcache_maxcnt); } +static inline u32 calc_crc(unsigned char *buf, int len) +{ + u32 reg; + u32 tmp; + int j, k; + + reg = 0xffffffff; + + for (j = 0; j < len; j++) { + reg ^= buf[j]; + + for (k = 0; k < 8; k++) { + tmp = reg & 0x01; + + reg >>= 1; + + if (tmp) + reg ^= 0xedb88320; + } + } + + return ~reg; +} + +static void tg3_set_multi(struct tg3 *tp, unsigned int accept_all) +{ + /* accept or reject all multicast frames */ + tw32(MAC_HASH_REG_0, accept_all ? 0xffffffff : 0); + tw32(MAC_HASH_REG_1, accept_all ? 0xffffffff : 0); + tw32(MAC_HASH_REG_2, accept_all ? 0xffffffff : 0); + tw32(MAC_HASH_REG_3, accept_all ? 0xffffffff : 0); +} + +static void __tg3_set_rx_mode(struct net_device *dev) +{ + struct tg3 *tp = netdev_priv(dev); + u32 rx_mode; + + rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC | + RX_MODE_KEEP_VLAN_TAG); + +#if !defined(CONFIG_VLAN_8021Q) && !defined(CONFIG_VLAN_8021Q_MODULE) + /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG + * flag clear. + */ + if (!tg3_flag(tp, ENABLE_ASF)) + rx_mode |= RX_MODE_KEEP_VLAN_TAG; +#endif + + if (dev->flags & IFF_PROMISC) { + /* Promiscuous mode. */ + rx_mode |= RX_MODE_PROMISC; + } else if (dev->flags & IFF_ALLMULTI) { + /* Accept all multicast. */ + tg3_set_multi(tp, 1); + } else if (netdev_mc_empty(dev)) { + /* Reject all multicast. */ + tg3_set_multi(tp, 0); + } else { + /* Accept one or more multicast(s). */ + struct netdev_hw_addr *ha; + u32 mc_filter[4] = { 0, }; + u32 regidx; + u32 bit; + u32 crc; + + netdev_for_each_mc_addr(ha, dev) { + crc = calc_crc(ha->addr, ETH_ALEN); + bit = ~crc & 0x7f; + regidx = (bit & 0x60) >> 5; + bit &= 0x1f; + mc_filter[regidx] |= (1 << bit); + } + + tw32(MAC_HASH_REG_0, mc_filter[0]); + tw32(MAC_HASH_REG_1, mc_filter[1]); + tw32(MAC_HASH_REG_2, mc_filter[2]); + tw32(MAC_HASH_REG_3, mc_filter[3]); + } + + if (rx_mode != tp->rx_mode) { + tp->rx_mode = rx_mode; + tw32_f(MAC_RX_MODE, rx_mode); + udelay(10); + } +} + static void tg3_rss_init_dflt_indir_tbl(struct tg3 *tp) { int i; @@ -9967,105 +10053,6 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev, return stats; } -static inline u32 calc_crc(unsigned char *buf, int len) -{ - u32 reg; - u32 tmp; - int j, k; - - reg = 0xffffffff; - - for (j = 0; j < len; j++) { - reg ^= buf[j]; - - for (k = 0; k < 8; k++) { - tmp = reg & 0x01; - - reg >>= 1; - - if (tmp) - reg ^= 0xedb88320; - } - } - - return ~reg; -} - -static void tg3_set_multi(struct tg3 *tp, unsigned int accept_all) -{ - /* accept or reject all multicast frames */ - tw32(MAC_HASH_REG_0, accept_all ? 0xffffffff : 0); - tw32(MAC_HASH_REG_1, accept_all ? 0xffffffff : 0); - tw32(MAC_HASH_REG_2, accept_all ? 0xffffffff : 0); - tw32(MAC_HASH_REG_3, accept_all ? 0xffffffff : 0); -} - -static void __tg3_set_rx_mode(struct net_device *dev) -{ - struct tg3 *tp = netdev_priv(dev); - u32 rx_mode; - - rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC | - RX_MODE_KEEP_VLAN_TAG); - -#if !defined(CONFIG_VLAN_8021Q) && !defined(CONFIG_VLAN_8021Q_MODULE) - /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG - * flag clear. - */ - if (!tg3_flag(tp, ENABLE_ASF)) - rx_mode |= RX_MODE_KEEP_VLAN_TAG; -#endif - - if (dev->flags & IFF_PROMISC) { - /* Promiscuous mode. */ - rx_mode |= RX_MODE_PROMISC; - } else if (dev->flags & IFF_ALLMULTI) { - /* Accept all multicast. */ - tg3_set_multi(tp, 1); - } else if (netdev_mc_empty(dev)) { - /* Reject all multicast. */ - tg3_set_multi(tp, 0); - } else { - /* Accept one or more multicast(s). */ - struct netdev_hw_addr *ha; - u32 mc_filter[4] = { 0, }; - u32 regidx; - u32 bit; - u32 crc; - - netdev_for_each_mc_addr(ha, dev) { - crc = calc_crc(ha->addr, ETH_ALEN); - bit = ~crc & 0x7f; - regidx = (bit & 0x60) >> 5; - bit &= 0x1f; - mc_filter[regidx] |= (1 << bit); - } - - tw32(MAC_HASH_REG_0, mc_filter[0]); - tw32(MAC_HASH_REG_1, mc_filter[1]); - tw32(MAC_HASH_REG_2, mc_filter[2]); - tw32(MAC_HASH_REG_3, mc_filter[3]); - } - - if (rx_mode != tp->rx_mode) { - tp->rx_mode = rx_mode; - tw32_f(MAC_RX_MODE, rx_mode); - udelay(10); - } -} - -static void tg3_set_rx_mode(struct net_device *dev) -{ - struct tg3 *tp = netdev_priv(dev); - - if (!netif_running(dev)) - return; - - tg3_full_lock(tp, 0); - __tg3_set_rx_mode(dev); - tg3_full_unlock(tp); -} - static int tg3_get_regs_len(struct net_device *dev) { return TG3_REG_BLK_SIZE; @@ -11977,6 +11964,18 @@ static const struct ethtool_ops tg3_ethtool_ops = { .set_rxfh_indir = tg3_set_rxfh_indir, }; +static void tg3_set_rx_mode(struct net_device *dev) +{ + struct tg3 *tp = netdev_priv(dev); + + if (!netif_running(dev)) + return; + + tg3_full_lock(tp, 0); + __tg3_set_rx_mode(dev); + tg3_full_unlock(tp); +} + static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp, int new_mtu) { -- GitLab From dbe9b92a602b203174a3227a05e69c019eebf91d Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:09 +0000 Subject: [PATCH 0679/1846] tg3: Move tg3_nvram_write_block functions This patch moves the tg3_nvram_write_block functions higher in the file to eliminate a prototype. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 500 ++++++++++++++-------------- 1 file changed, 250 insertions(+), 250 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index df04a58a55fa..bbe1394b11ad 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -2978,6 +2978,256 @@ static int tg3_nvram_read_be32(struct tg3 *tp, u32 offset, __be32 *val) return res; } +static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp, + u32 offset, u32 len, u8 *buf) +{ + int i, j, rc = 0; + u32 val; + + for (i = 0; i < len; i += 4) { + u32 addr; + __be32 data; + + addr = offset + i; + + memcpy(&data, buf + i, 4); + + /* + * The SEEPROM interface expects the data to always be opposite + * the native endian format. We accomplish this by reversing + * all the operations that would have been performed on the + * data from a call to tg3_nvram_read_be32(). + */ + tw32(GRC_EEPROM_DATA, swab32(be32_to_cpu(data))); + + val = tr32(GRC_EEPROM_ADDR); + tw32(GRC_EEPROM_ADDR, val | EEPROM_ADDR_COMPLETE); + + val &= ~(EEPROM_ADDR_ADDR_MASK | EEPROM_ADDR_DEVID_MASK | + EEPROM_ADDR_READ); + tw32(GRC_EEPROM_ADDR, val | + (0 << EEPROM_ADDR_DEVID_SHIFT) | + (addr & EEPROM_ADDR_ADDR_MASK) | + EEPROM_ADDR_START | + EEPROM_ADDR_WRITE); + + for (j = 0; j < 1000; j++) { + val = tr32(GRC_EEPROM_ADDR); + + if (val & EEPROM_ADDR_COMPLETE) + break; + msleep(1); + } + if (!(val & EEPROM_ADDR_COMPLETE)) { + rc = -EBUSY; + break; + } + } + + return rc; +} + +/* offset and length are dword aligned */ +static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len, + u8 *buf) +{ + int ret = 0; + u32 pagesize = tp->nvram_pagesize; + u32 pagemask = pagesize - 1; + u32 nvram_cmd; + u8 *tmp; + + tmp = kmalloc(pagesize, GFP_KERNEL); + if (tmp == NULL) + return -ENOMEM; + + while (len) { + int j; + u32 phy_addr, page_off, size; + + phy_addr = offset & ~pagemask; + + for (j = 0; j < pagesize; j += 4) { + ret = tg3_nvram_read_be32(tp, phy_addr + j, + (__be32 *) (tmp + j)); + if (ret) + break; + } + if (ret) + break; + + page_off = offset & pagemask; + size = pagesize; + if (len < size) + size = len; + + len -= size; + + memcpy(tmp + page_off, buf, size); + + offset = offset + (pagesize - page_off); + + tg3_enable_nvram_access(tp); + + /* + * Before we can erase the flash page, we need + * to issue a special "write enable" command. + */ + nvram_cmd = NVRAM_CMD_WREN | NVRAM_CMD_GO | NVRAM_CMD_DONE; + + if (tg3_nvram_exec_cmd(tp, nvram_cmd)) + break; + + /* Erase the target page */ + tw32(NVRAM_ADDR, phy_addr); + + nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR | + NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_ERASE; + + if (tg3_nvram_exec_cmd(tp, nvram_cmd)) + break; + + /* Issue another write enable to start the write. */ + nvram_cmd = NVRAM_CMD_WREN | NVRAM_CMD_GO | NVRAM_CMD_DONE; + + if (tg3_nvram_exec_cmd(tp, nvram_cmd)) + break; + + for (j = 0; j < pagesize; j += 4) { + __be32 data; + + data = *((__be32 *) (tmp + j)); + + tw32(NVRAM_WRDATA, be32_to_cpu(data)); + + tw32(NVRAM_ADDR, phy_addr + j); + + nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | + NVRAM_CMD_WR; + + if (j == 0) + nvram_cmd |= NVRAM_CMD_FIRST; + else if (j == (pagesize - 4)) + nvram_cmd |= NVRAM_CMD_LAST; + + ret = tg3_nvram_exec_cmd(tp, nvram_cmd); + if (ret) + break; + } + if (ret) + break; + } + + nvram_cmd = NVRAM_CMD_WRDI | NVRAM_CMD_GO | NVRAM_CMD_DONE; + tg3_nvram_exec_cmd(tp, nvram_cmd); + + kfree(tmp); + + return ret; +} + +/* offset and length are dword aligned */ +static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, + u8 *buf) +{ + int i, ret = 0; + + for (i = 0; i < len; i += 4, offset += 4) { + u32 page_off, phy_addr, nvram_cmd; + __be32 data; + + memcpy(&data, buf + i, 4); + tw32(NVRAM_WRDATA, be32_to_cpu(data)); + + page_off = offset % tp->nvram_pagesize; + + phy_addr = tg3_nvram_phys_addr(tp, offset); + + tw32(NVRAM_ADDR, phy_addr); + + nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR; + + if (page_off == 0 || i == 0) + nvram_cmd |= NVRAM_CMD_FIRST; + if (page_off == (tp->nvram_pagesize - 4)) + nvram_cmd |= NVRAM_CMD_LAST; + + if (i == (len - 4)) + nvram_cmd |= NVRAM_CMD_LAST; + + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && + !tg3_flag(tp, 5755_PLUS) && + (tp->nvram_jedecnum == JEDEC_ST) && + (nvram_cmd & NVRAM_CMD_FIRST)) { + u32 cmd; + + cmd = NVRAM_CMD_WREN | NVRAM_CMD_GO | NVRAM_CMD_DONE; + ret = tg3_nvram_exec_cmd(tp, cmd); + if (ret) + break; + } + if (!tg3_flag(tp, FLASH)) { + /* We always do complete word writes to eeprom. */ + nvram_cmd |= (NVRAM_CMD_FIRST | NVRAM_CMD_LAST); + } + + ret = tg3_nvram_exec_cmd(tp, nvram_cmd); + if (ret) + break; + } + return ret; +} + +/* offset and length are dword aligned */ +static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf) +{ + int ret; + + if (tg3_flag(tp, EEPROM_WRITE_PROT)) { + tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl & + ~GRC_LCLCTRL_GPIO_OUTPUT1); + udelay(40); + } + + if (!tg3_flag(tp, NVRAM)) { + ret = tg3_nvram_write_block_using_eeprom(tp, offset, len, buf); + } else { + u32 grc_mode; + + ret = tg3_nvram_lock(tp); + if (ret) + return ret; + + tg3_enable_nvram_access(tp); + if (tg3_flag(tp, 5750_PLUS) && !tg3_flag(tp, PROTECTED_NVRAM)) + tw32(NVRAM_WRITE1, 0x406); + + grc_mode = tr32(GRC_MODE); + tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE); + + if (tg3_flag(tp, NVRAM_BUFFERED) || !tg3_flag(tp, FLASH)) { + ret = tg3_nvram_write_block_buffered(tp, offset, len, + buf); + } else { + ret = tg3_nvram_write_block_unbuffered(tp, offset, len, + buf); + } + + grc_mode = tr32(GRC_MODE); + tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE); + + tg3_disable_nvram_access(tp); + tg3_nvram_unlock(tp); + } + + if (tg3_flag(tp, EEPROM_WRITE_PROT)) { + tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); + udelay(40); + } + + return ret; +} + #define RX_CPU_SCRATCH_BASE 0x30000 #define RX_CPU_SCRATCH_SIZE 0x04000 #define TX_CPU_SCRATCH_BASE 0x34000 @@ -10147,8 +10397,6 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, return 0; } -static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf); - static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data) { struct tg3 *tp = netdev_priv(dev); @@ -12745,254 +12993,6 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) } } -static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp, - u32 offset, u32 len, u8 *buf) -{ - int i, j, rc = 0; - u32 val; - - for (i = 0; i < len; i += 4) { - u32 addr; - __be32 data; - - addr = offset + i; - - memcpy(&data, buf + i, 4); - - /* - * The SEEPROM interface expects the data to always be opposite - * the native endian format. We accomplish this by reversing - * all the operations that would have been performed on the - * data from a call to tg3_nvram_read_be32(). - */ - tw32(GRC_EEPROM_DATA, swab32(be32_to_cpu(data))); - - val = tr32(GRC_EEPROM_ADDR); - tw32(GRC_EEPROM_ADDR, val | EEPROM_ADDR_COMPLETE); - - val &= ~(EEPROM_ADDR_ADDR_MASK | EEPROM_ADDR_DEVID_MASK | - EEPROM_ADDR_READ); - tw32(GRC_EEPROM_ADDR, val | - (0 << EEPROM_ADDR_DEVID_SHIFT) | - (addr & EEPROM_ADDR_ADDR_MASK) | - EEPROM_ADDR_START | - EEPROM_ADDR_WRITE); - - for (j = 0; j < 1000; j++) { - val = tr32(GRC_EEPROM_ADDR); - - if (val & EEPROM_ADDR_COMPLETE) - break; - msleep(1); - } - if (!(val & EEPROM_ADDR_COMPLETE)) { - rc = -EBUSY; - break; - } - } - - return rc; -} - -/* offset and length are dword aligned */ -static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len, - u8 *buf) -{ - int ret = 0; - u32 pagesize = tp->nvram_pagesize; - u32 pagemask = pagesize - 1; - u32 nvram_cmd; - u8 *tmp; - - tmp = kmalloc(pagesize, GFP_KERNEL); - if (tmp == NULL) - return -ENOMEM; - - while (len) { - int j; - u32 phy_addr, page_off, size; - - phy_addr = offset & ~pagemask; - - for (j = 0; j < pagesize; j += 4) { - ret = tg3_nvram_read_be32(tp, phy_addr + j, - (__be32 *) (tmp + j)); - if (ret) - break; - } - if (ret) - break; - - page_off = offset & pagemask; - size = pagesize; - if (len < size) - size = len; - - len -= size; - - memcpy(tmp + page_off, buf, size); - - offset = offset + (pagesize - page_off); - - tg3_enable_nvram_access(tp); - - /* - * Before we can erase the flash page, we need - * to issue a special "write enable" command. - */ - nvram_cmd = NVRAM_CMD_WREN | NVRAM_CMD_GO | NVRAM_CMD_DONE; - - if (tg3_nvram_exec_cmd(tp, nvram_cmd)) - break; - - /* Erase the target page */ - tw32(NVRAM_ADDR, phy_addr); - - nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR | - NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_ERASE; - - if (tg3_nvram_exec_cmd(tp, nvram_cmd)) - break; - - /* Issue another write enable to start the write. */ - nvram_cmd = NVRAM_CMD_WREN | NVRAM_CMD_GO | NVRAM_CMD_DONE; - - if (tg3_nvram_exec_cmd(tp, nvram_cmd)) - break; - - for (j = 0; j < pagesize; j += 4) { - __be32 data; - - data = *((__be32 *) (tmp + j)); - - tw32(NVRAM_WRDATA, be32_to_cpu(data)); - - tw32(NVRAM_ADDR, phy_addr + j); - - nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | - NVRAM_CMD_WR; - - if (j == 0) - nvram_cmd |= NVRAM_CMD_FIRST; - else if (j == (pagesize - 4)) - nvram_cmd |= NVRAM_CMD_LAST; - - if ((ret = tg3_nvram_exec_cmd(tp, nvram_cmd))) - break; - } - if (ret) - break; - } - - nvram_cmd = NVRAM_CMD_WRDI | NVRAM_CMD_GO | NVRAM_CMD_DONE; - tg3_nvram_exec_cmd(tp, nvram_cmd); - - kfree(tmp); - - return ret; -} - -/* offset and length are dword aligned */ -static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, - u8 *buf) -{ - int i, ret = 0; - - for (i = 0; i < len; i += 4, offset += 4) { - u32 page_off, phy_addr, nvram_cmd; - __be32 data; - - memcpy(&data, buf + i, 4); - tw32(NVRAM_WRDATA, be32_to_cpu(data)); - - page_off = offset % tp->nvram_pagesize; - - phy_addr = tg3_nvram_phys_addr(tp, offset); - - tw32(NVRAM_ADDR, phy_addr); - - nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR; - - if (page_off == 0 || i == 0) - nvram_cmd |= NVRAM_CMD_FIRST; - if (page_off == (tp->nvram_pagesize - 4)) - nvram_cmd |= NVRAM_CMD_LAST; - - if (i == (len - 4)) - nvram_cmd |= NVRAM_CMD_LAST; - - if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && - !tg3_flag(tp, 5755_PLUS) && - (tp->nvram_jedecnum == JEDEC_ST) && - (nvram_cmd & NVRAM_CMD_FIRST)) { - - if ((ret = tg3_nvram_exec_cmd(tp, - NVRAM_CMD_WREN | NVRAM_CMD_GO | - NVRAM_CMD_DONE))) - - break; - } - if (!tg3_flag(tp, FLASH)) { - /* We always do complete word writes to eeprom. */ - nvram_cmd |= (NVRAM_CMD_FIRST | NVRAM_CMD_LAST); - } - - if ((ret = tg3_nvram_exec_cmd(tp, nvram_cmd))) - break; - } - return ret; -} - -/* offset and length are dword aligned */ -static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf) -{ - int ret; - - if (tg3_flag(tp, EEPROM_WRITE_PROT)) { - tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl & - ~GRC_LCLCTRL_GPIO_OUTPUT1); - udelay(40); - } - - if (!tg3_flag(tp, NVRAM)) { - ret = tg3_nvram_write_block_using_eeprom(tp, offset, len, buf); - } else { - u32 grc_mode; - - ret = tg3_nvram_lock(tp); - if (ret) - return ret; - - tg3_enable_nvram_access(tp); - if (tg3_flag(tp, 5750_PLUS) && !tg3_flag(tp, PROTECTED_NVRAM)) - tw32(NVRAM_WRITE1, 0x406); - - grc_mode = tr32(GRC_MODE); - tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE); - - if (tg3_flag(tp, NVRAM_BUFFERED) || !tg3_flag(tp, FLASH)) { - ret = tg3_nvram_write_block_buffered(tp, offset, len, - buf); - } else { - ret = tg3_nvram_write_block_unbuffered(tp, offset, len, - buf); - } - - grc_mode = tr32(GRC_MODE); - tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE); - - tg3_disable_nvram_access(tp); - tg3_nvram_unlock(tp); - } - - if (tg3_flag(tp, EEPROM_WRITE_PROT)) { - tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); - udelay(40); - } - - return ret; -} - struct subsys_tbl_ent { u16 subsys_vendor, subsys_devid; u32 phy_id; -- GitLab From 16c7fa7dfe9a304ca6d5bdf39aa4a8d315336a07 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:10 +0000 Subject: [PATCH 0680/1846] tg3: Relocate tg3_find_peer This patch relocates tg3_find_peer to eliminate a prototype. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 58 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index bbe1394b11ad..cc092170dfa3 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -13847,8 +13847,6 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp) tp->fw_ver[TG3_VER_SIZE - 1] = 0; } -static struct pci_dev * __devinit tg3_find_peer(struct tg3 *); - static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp) { if (tg3_flag(tp, LRG_PROD_RING_CAP)) @@ -13866,6 +13864,34 @@ static DEFINE_PCI_DEVICE_TABLE(tg3_write_reorder_chipsets) = { { }, }; +static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp) +{ + struct pci_dev *peer; + unsigned int func, devnr = tp->pdev->devfn & ~7; + + for (func = 0; func < 8; func++) { + peer = pci_get_slot(tp->pdev->bus, devnr | func); + if (peer && peer != tp->pdev) + break; + pci_dev_put(peer); + } + /* 5704 can be configured in single-port mode, set peer to + * tp->pdev in that case. + */ + if (!peer) { + peer = tp->pdev; + return peer; + } + + /* + * We don't need to keep the refcount elevated; there's no way + * to remove one half of this device without removing the other + */ + pci_dev_put(peer); + + return peer; +} + static int __devinit tg3_get_invariants(struct tg3 *tp) { u32 misc_ctrl_reg; @@ -15364,34 +15390,6 @@ static char * __devinit tg3_bus_string(struct tg3 *tp, char *str) return str; } -static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp) -{ - struct pci_dev *peer; - unsigned int func, devnr = tp->pdev->devfn & ~7; - - for (func = 0; func < 8; func++) { - peer = pci_get_slot(tp->pdev->bus, devnr | func); - if (peer && peer != tp->pdev) - break; - pci_dev_put(peer); - } - /* 5704 can be configured in single-port mode, set peer to - * tp->pdev in that case. - */ - if (!peer) { - peer = tp->pdev; - return peer; - } - - /* - * We don't need to keep the refcount elevated; there's no way - * to remove one half of this device without removing the other - */ - pci_dev_put(peer); - - return peer; -} - static void __devinit tg3_init_coal(struct tg3 *tp) { struct ethtool_coalesce *ec = &tp->coal; -- GitLab From 4b40952268c2390a71b9728194eb4b4dd514c087 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:11 +0000 Subject: [PATCH 0681/1846] tg3: Eliminate unneeded prototype This patch eliminates the unneeded tg3_halt_cpu() prototype and moves the tg3_setup_phy() prototype closer to where it is needed. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index cc092170dfa3..b89c9322c0a4 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -2709,9 +2709,6 @@ static int tg3_5700_link_polarity(struct tg3 *tp, u32 speed) return 0; } -static int tg3_setup_phy(struct tg3 *, int); -static int tg3_halt_cpu(struct tg3 *, u32); - static void tg3_power_down_phy(struct tg3 *tp, bool do_low_power) { u32 val; @@ -3514,6 +3511,8 @@ static int tg3_power_up(struct tg3 *tp) return err; } +static int tg3_setup_phy(struct tg3 *, int); + static int tg3_power_down_prepare(struct tg3 *tp) { u32 misc_host_ctrl; -- GitLab From c5665a538da6b887a5096358a12527785506e5ac Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 10:20:12 +0000 Subject: [PATCH 0682/1846] tg3: Move transmit comment to a better location This patch moves a comment in the transmit path to a better location. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index b89c9322c0a4..d418f954c72d 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -6923,7 +6923,6 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) ((skb_shinfo(skb)->nr_frags == 0) ? TXD_FLAG_END : 0), mss, vlan)) { would_hit_hwbug = 1; - /* Now loop through additional data fragments, and queue them. */ } else if (skb_shinfo(skb)->nr_frags > 0) { u32 tmp_mss = mss; @@ -6932,6 +6931,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) !tg3_flag(tp, HW_TSO_3)) tmp_mss = 0; + /* Now loop through additional data + * fragments, and queue them. + */ last = skb_shinfo(skb)->nr_frags - 1; for (i = 0; i <= last; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; -- GitLab From de8261c2fa364397ed872fad1244d75364689168 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 13 Feb 2012 04:09:20 +0000 Subject: [PATCH 0683/1846] gro: fix truesize underestimation skb_gro_receive() doesnt update truesize properly when adding one skb to frag_list. Signed-off-by: Eric Dumazet Cc: Herbert Xu Signed-off-by: David S. Miller --- net/core/skbuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index da0c97f2fab4..f3a530780753 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2906,7 +2906,7 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) nskb->prev = p; nskb->data_len += p->len; - nskb->truesize += p->len; + nskb->truesize += p->truesize; nskb->len += p->len; *head = nskb; @@ -2916,6 +2916,7 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb) p = nskb; merge: + p->truesize += skb->truesize - len; if (offset > headlen) { unsigned int eat = offset - headlen; -- GitLab From 19c6c8f58b5840fd4757233b4849f42687d2ef3a Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 13 Feb 2012 04:23:24 +0000 Subject: [PATCH 0684/1846] ppp: fix truesize underestimation When building frag_list, head truesize should be sum of all frag truesize. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- drivers/net/ppp/ppp_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index edfa15d2e795..93a86397af36 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -2113,7 +2113,7 @@ ppp_mp_reconstruct(struct ppp *ppp) skb->len += p->len; skb->data_len += p->len; - skb->truesize += p->len; + skb->truesize += p->truesize; if (p == tail) break; -- GitLab From 2132cf64371a20f5c427da42f9f9e7e99bc5fb88 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 13 Feb 2012 05:40:45 +0000 Subject: [PATCH 0685/1846] net_sched: sch_plug: plug_qdisc_ops is static net/sched/sch_plug.c:211:18: warning: symbol 'plug_qdisc_ops' was not declared. Should it be static? Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- net/sched/sch_plug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_plug.c b/net/sched/sch_plug.c index ba7b737e4055..89f8fcf73f18 100644 --- a/net/sched/sch_plug.c +++ b/net/sched/sch_plug.c @@ -208,7 +208,7 @@ static int plug_change(struct Qdisc *sch, struct nlattr *opt) return 0; } -struct Qdisc_ops plug_qdisc_ops = { +static struct Qdisc_ops plug_qdisc_ops __read_mostly = { .id = "plug", .priv_size = sizeof(struct plug_sched_data), .enqueue = plug_enqueue, -- GitLab From d7eb33840bee3c8de3f64f3861350bcfac3eaf82 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:14 +0000 Subject: [PATCH 0686/1846] e1000e: potentially incorrect return for e1000_set_d3_lplu_state_ich8lan In the unlikely event that e1e_wphy() returns an error, the returned error code is not propogated to the caller of e1000_set_d3_lplu_state_ich8lan(). With this change, there is a rare possibility that ret_val might not get set so it must be initialized. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index ce348cd99d53..5a55a6134a3b 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2030,7 +2030,7 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) { struct e1000_phy_info *phy = &hw->phy; u32 phy_ctrl; - s32 ret_val; + s32 ret_val = 0; u16 data; phy_ctrl = er32(PHY_CTRL); @@ -2096,7 +2096,7 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); } - return 0; + return ret_val; } /** -- GitLab From f1a3fe17f9ef0e51c63662b82e9915a693e8e375 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:19 +0000 Subject: [PATCH 0687/1846] e1000e: cleanup: remove unreachable statement Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 5a55a6134a3b..f5d7282afdf3 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2161,8 +2161,6 @@ static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) e_dbg("ERROR: No valid NVM bank present\n"); return -E1000_ERR_NVM; } - - return 0; } /** -- GitLab From 55920b5eae24cfd2666f3f80bc5f2c0b3b18043b Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:25 +0000 Subject: [PATCH 0688/1846] e1000e: cleanup: remove unnecessary variable ret_val ret_val gets initialized to -E1000_ERR_NVM and never set differently, so get rid of it and just return -E1000_ERR_NVM. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index f5d7282afdf3..c80ef41b5fca 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2308,7 +2308,6 @@ static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout) { union ich8_hws_flash_ctrl hsflctl; union ich8_hws_flash_status hsfsts; - s32 ret_val = -E1000_ERR_NVM; u32 i = 0; /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ @@ -2327,7 +2326,7 @@ static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout) if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0) return 0; - return ret_val; + return -E1000_ERR_NVM; } /** -- GitLab From f764956fd6c93be36cc60726ffd101d59fc3f581 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:30 +0000 Subject: [PATCH 0689/1846] e1000e: cleanup: remove unnecessary test and return Fall-through to a return statement that effectively does the same. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/phy.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index a8b99bae0222..0e86c7e761ea 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1264,8 +1264,6 @@ s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw) PHY_FORCE_LIMIT, 100000, &link); - if (ret_val) - return ret_val; } return ret_val; -- GitLab From f71dde6a44c6f817a104ab8a95a2eeabac5614df Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:35 +0000 Subject: [PATCH 0690/1846] e1000e: cleanup: remove unnecessary variable initializations Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index c80ef41b5fca..e45235ea6126 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2114,7 +2114,7 @@ static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) u32 bank1_offset = nvm->flash_bank_size * sizeof(u16); u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1; u8 sig_byte = 0; - s32 ret_val = 0; + s32 ret_val; switch (hw->mac.type) { case e1000_ich8lan: @@ -2268,7 +2268,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); ret_val = 0; } else { - s32 i = 0; + s32 i; /* * Otherwise poll for sometime so the current -- GitLab From 3fa82936347bba431f147e23c788f6364c3e5b36 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:40 +0000 Subject: [PATCH 0691/1846] e1000e: cleanup: minor whitespace addition (insert blank line separator) Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index e45235ea6126..e2c546d7dae1 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -3479,6 +3479,7 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw) default: break; } + return e1000e_setup_copper_link(hw); } -- GitLab From e561a705a61e8d4c32a1259c611703a3976347aa Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:46 +0000 Subject: [PATCH 0692/1846] e1000e: potentially incorrect return for e1000_init_hw_ich8lan In the unlikely event that e1000_setup_link_ich8lan() returns an error, the returned error code value is not propagated to the caller of e1000_init_hw_ich8lan(). Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index e2c546d7dae1..c4d65b841f35 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -3276,7 +3276,7 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) */ e1000_clear_hw_cntrs_ich8lan(hw); - return 0; + return ret_val; } /** * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits -- GitLab From 2a31b37a8956154df099400ba93cd6898a629c6d Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:51 +0000 Subject: [PATCH 0693/1846] e1000e: potentially incorrect return for e1000e_setup_fiber_serdes_link In the unlikely event that e1000_poll_fiber_serdes_link_generic() is called and it returns an error, the returned error code value is not propagated to the caller of e1000e_setup_fiber_serdes_link(). Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index b3b2f9e567ff..943b9090fda0 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -922,7 +922,7 @@ s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw) e_dbg("No signal detected\n"); } - return 0; + return ret_val; } /** -- GitLab From 5015e53a4cf0c88977120faede7eb02b0459d90e Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 8 Feb 2012 02:55:56 +0000 Subject: [PATCH 0694/1846] e1000e: cleanup goto statements to exit points without common work Per ./Documentation/CodingStyle, goto statements are acceptable for the centralized exiting of functions when there are multiple exit points which share common work such as cleanup. When no common work is required for multiple exit points, the function should just return at these exit points instead of doing an unnecessary jump to a centralized return. This patch cleans up the inappropriate use of goto statements, and removes unnecessary variables (or move to a smaller scope) where possible as a result of the cleanups. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/e1000e/80003es2lan.c | 18 +- drivers/net/ethernet/intel/e1000e/82571.c | 30 +-- drivers/net/ethernet/intel/e1000e/ich8lan.c | 176 +++++++-------- drivers/net/ethernet/intel/e1000e/mac.c | 15 +- drivers/net/ethernet/intel/e1000e/manage.c | 32 +-- drivers/net/ethernet/intel/e1000e/netdev.c | 12 +- drivers/net/ethernet/intel/e1000e/nvm.c | 22 +- drivers/net/ethernet/intel/e1000e/phy.c | 210 ++++++++---------- 8 files changed, 212 insertions(+), 303 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 05a79cbb1ca8..bc960fed8bf6 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -714,22 +714,19 @@ static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw) ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data); if (ret_val) - goto out; + return ret_val; index = phy_data & GG82563_DSPD_CABLE_LENGTH; - if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) { - ret_val = -E1000_ERR_PHY; - goto out; - } + if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) + return -E1000_ERR_PHY; phy->min_cable_length = e1000_gg82563_cable_length_table[index]; phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5]; phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; -out: - return ret_val; + return 0; } /** @@ -1348,12 +1345,9 @@ static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw) */ ret_val = e1000_check_alt_mac_addr_generic(hw); if (ret_val) - goto out; - - ret_val = e1000_read_mac_addr_generic(hw); + return ret_val; -out: - return ret_val; + return e1000_read_mac_addr_generic(hw); } /** diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 05e9a2911168..b6b7bc4c33aa 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -564,7 +564,6 @@ static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw) static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) { u32 extcnf_ctrl; - s32 ret_val = 0; s32 i = 0; extcnf_ctrl = er32(EXTCNF_CTRL); @@ -586,12 +585,10 @@ static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) /* Release semaphores */ e1000_put_hw_semaphore_82573(hw); e_dbg("Driver can't access the PHY\n"); - ret_val = -E1000_ERR_PHY; - goto out; + return -E1000_ERR_PHY; } -out: - return ret_val; + return 0; } /** @@ -1409,7 +1406,6 @@ bool e1000_check_phy_82574(struct e1000_hw *hw) { u16 status_1kbt = 0; u16 receive_errors = 0; - bool phy_hung = false; s32 ret_val = 0; /* @@ -1417,19 +1413,18 @@ bool e1000_check_phy_82574(struct e1000_hw *hw) * read the Base1000T status register If both are max then PHY is hung. */ ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors); - if (ret_val) - goto out; + return false; if (receive_errors == E1000_RECEIVE_ERROR_MAX) { ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt); if (ret_val) - goto out; + return false; if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) == E1000_IDLE_ERROR_COUNT_MASK) - phy_hung = true; + return true; } -out: - return phy_hung; + + return false; } /** @@ -1831,9 +1826,9 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) **/ static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) { - s32 ret_val = 0; - if (hw->mac.type == e1000_82571) { + s32 ret_val = 0; + /* * If there's an alternate MAC address place it in RAR0 * so that it will override the Si installed default perm @@ -1841,13 +1836,10 @@ static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) */ ret_val = e1000_check_alt_mac_addr_generic(hw); if (ret_val) - goto out; + return ret_val; } - ret_val = e1000_read_mac_addr_generic(hw); - -out: - return ret_val; + return e1000_read_mac_addr_generic(hw); } /** diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index c4d65b841f35..f3282dc5588e 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -351,7 +351,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) */ ret_val = e1000e_phy_hw_reset_generic(hw); if (ret_val) - goto out; + return ret_val; /* Ungate automatic PHY configuration on non-managed 82579 */ if ((hw->mac.type == e1000_pch2lan) && @@ -366,7 +366,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) default: ret_val = e1000e_get_phy_id(hw); if (ret_val) - goto out; + return ret_val; if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK)) break; /* fall-through */ @@ -377,10 +377,10 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) */ ret_val = e1000_set_mdio_slow_mode_hv(hw); if (ret_val) - goto out; + return ret_val; ret_val = e1000e_get_phy_id(hw); if (ret_val) - goto out; + return ret_val; break; } phy->type = e1000e_get_phy_type_from_id(phy->id); @@ -406,7 +406,6 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) break; } -out: return ret_val; } @@ -635,20 +634,18 @@ static s32 e1000_set_eee_pchlan(struct e1000_hw *hw) u16 phy_reg; if (hw->phy.type != e1000_phy_82579) - goto out; + return 0; ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg); if (ret_val) - goto out; + return ret_val; if (hw->dev_spec.ich8lan.eee_disable) phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK; else phy_reg |= I82579_LPI_CTRL_ENABLE_MASK; - ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); -out: - return ret_val; + return e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); } /** @@ -672,10 +669,8 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) * get_link_status flag is set upon receiving a Link Status * Change or Rx Sequence Error interrupt. */ - if (!mac->get_link_status) { - ret_val = 0; - goto out; - } + if (!mac->get_link_status) + return 0; /* * First we want to see if the MII Status Register reports @@ -684,16 +679,16 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) */ ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) - goto out; + return ret_val; if (hw->mac.type == e1000_pchlan) { ret_val = e1000_k1_gig_workaround_hv(hw, link); if (ret_val) - goto out; + return ret_val; } if (!link) - goto out; /* No link detected */ + return 0; /* No link detected */ mac->get_link_status = false; @@ -701,13 +696,13 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) case e1000_pch2lan: ret_val = e1000_k1_workaround_lv(hw); if (ret_val) - goto out; + return ret_val; /* fall-thru */ case e1000_pchlan: if (hw->phy.type == e1000_phy_82578) { ret_val = e1000_link_stall_workaround_hv(hw); if (ret_val) - goto out; + return ret_val; } /* @@ -737,16 +732,14 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) /* Enable/Disable EEE after link up */ ret_val = e1000_set_eee_pchlan(hw); if (ret_val) - goto out; + return ret_val; /* * If we are forcing speed/duplex, then we simply return since * we have already determined whether we have link or not. */ - if (!mac->autoneg) { - ret_val = -E1000_ERR_CONFIG; - goto out; - } + if (!mac->autoneg) + return -E1000_ERR_CONFIG; /* * Auto-Neg is enabled. Auto Speed Detection takes care @@ -765,7 +758,6 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) if (ret_val) e_dbg("Error configuring flow control\n"); -out: return ret_val; } @@ -1008,15 +1000,13 @@ static s32 e1000_write_smbus_addr(struct e1000_hw *hw) ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data); if (ret_val) - goto out; + return ret_val; phy_data &= ~HV_SMB_ADDR_MASK; phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT); phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID; - ret_val = e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data); -out: - return ret_val; + return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data); } /** @@ -1159,12 +1149,12 @@ static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link) bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled; if (hw->mac.type != e1000_pchlan) - goto out; + return 0; /* Wrap the whole flow with the sw flag */ ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */ if (link) { @@ -1218,7 +1208,7 @@ static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link) release: hw->phy.ops.release(hw); -out: + return ret_val; } @@ -1244,7 +1234,7 @@ s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) E1000_KMRNCTRLSTA_K1_CONFIG, &kmrn_reg); if (ret_val) - goto out; + return ret_val; if (k1_enable) kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE; @@ -1255,7 +1245,7 @@ s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) E1000_KMRNCTRLSTA_K1_CONFIG, kmrn_reg); if (ret_val) - goto out; + return ret_val; udelay(20); ctrl_ext = er32(CTRL_EXT); @@ -1273,8 +1263,7 @@ s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) e1e_flush(); udelay(20); -out: - return ret_val; + return 0; } /** @@ -1376,13 +1365,13 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) u16 phy_data; if (hw->mac.type != e1000_pchlan) - return ret_val; + return 0; /* Set MDIO slow mode before any other MDIO access */ if (hw->phy.type == e1000_phy_82577) { ret_val = e1000_set_mdio_slow_mode_hv(hw); if (ret_val) - goto out; + return ret_val; } if (((hw->phy.type == e1000_phy_82577) && @@ -1419,7 +1408,7 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0); hw->phy.ops.release(hw); if (ret_val) - goto out; + return ret_val; /* * Configure the K1 Si workaround during phy reset assuming there is @@ -1427,12 +1416,12 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) */ ret_val = e1000_k1_gig_workaround_hv(hw, true); if (ret_val) - goto out; + return ret_val; /* Workaround for link disconnects on a busy hub in half duplex */ ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; ret_val = hw->phy.ops.read_reg_locked(hw, BM_PORT_GEN_CFG, &phy_data); if (ret_val) goto release; @@ -1440,7 +1429,7 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) phy_data & 0x00FF); release: hw->phy.ops.release(hw); -out: + return ret_val; } @@ -1497,13 +1486,13 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable) u16 i; if (hw->mac.type != e1000_pch2lan) - goto out; + return 0; /* disable Rx path while enabling/disabling workaround */ e1e_rphy(hw, PHY_REG(769, 20), &phy_reg); ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14)); if (ret_val) - goto out; + return ret_val; if (enable) { /* @@ -1545,24 +1534,24 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable) E1000_KMRNCTRLSTA_CTRL_OFFSET, &data); if (ret_val) - goto out; + return ret_val; ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_CTRL_OFFSET, data | (1 << 0)); if (ret_val) - goto out; + return ret_val; ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_HD_CTRL, &data); if (ret_val) - goto out; + return ret_val; data &= ~(0xF << 8); data |= (0xB << 8); ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_HD_CTRL, data); if (ret_val) - goto out; + return ret_val; /* Enable jumbo frame workaround in the PHY */ e1e_rphy(hw, PHY_REG(769, 23), &data); @@ -1570,25 +1559,25 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable) data |= (0x37 << 5); ret_val = e1e_wphy(hw, PHY_REG(769, 23), data); if (ret_val) - goto out; + return ret_val; e1e_rphy(hw, PHY_REG(769, 16), &data); data &= ~(1 << 13); ret_val = e1e_wphy(hw, PHY_REG(769, 16), data); if (ret_val) - goto out; + return ret_val; e1e_rphy(hw, PHY_REG(776, 20), &data); data &= ~(0x3FF << 2); data |= (0x1A << 2); ret_val = e1e_wphy(hw, PHY_REG(776, 20), data); if (ret_val) - goto out; + return ret_val; ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100); if (ret_val) - goto out; + return ret_val; e1e_rphy(hw, HV_PM_CTRL, &data); ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10)); if (ret_val) - goto out; + return ret_val; } else { /* Write MAC register values back to h/w defaults */ mac_reg = er32(FFLT_DBG); @@ -1603,56 +1592,53 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable) E1000_KMRNCTRLSTA_CTRL_OFFSET, &data); if (ret_val) - goto out; + return ret_val; ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_CTRL_OFFSET, data & ~(1 << 0)); if (ret_val) - goto out; + return ret_val; ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_HD_CTRL, &data); if (ret_val) - goto out; + return ret_val; data &= ~(0xF << 8); data |= (0xB << 8); ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_HD_CTRL, data); if (ret_val) - goto out; + return ret_val; /* Write PHY register values back to h/w defaults */ e1e_rphy(hw, PHY_REG(769, 23), &data); data &= ~(0x7F << 5); ret_val = e1e_wphy(hw, PHY_REG(769, 23), data); if (ret_val) - goto out; + return ret_val; e1e_rphy(hw, PHY_REG(769, 16), &data); data |= (1 << 13); ret_val = e1e_wphy(hw, PHY_REG(769, 16), data); if (ret_val) - goto out; + return ret_val; e1e_rphy(hw, PHY_REG(776, 20), &data); data &= ~(0x3FF << 2); data |= (0x8 << 2); ret_val = e1e_wphy(hw, PHY_REG(776, 20), data); if (ret_val) - goto out; + return ret_val; ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00); if (ret_val) - goto out; + return ret_val; e1e_rphy(hw, HV_PM_CTRL, &data); ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10)); if (ret_val) - goto out; + return ret_val; } /* re-enable Rx path after enabling/disabling workaround */ - ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14)); - -out: - return ret_val; + return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14)); } /** @@ -1664,14 +1650,14 @@ static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw) s32 ret_val = 0; if (hw->mac.type != e1000_pch2lan) - goto out; + return 0; /* Set MDIO slow mode before any other MDIO access */ ret_val = e1000_set_mdio_slow_mode_hv(hw); ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, I82579_MSE_THRESHOLD); if (ret_val) @@ -1689,7 +1675,6 @@ static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw) release: hw->phy.ops.release(hw); -out: return ret_val; } @@ -1707,12 +1692,12 @@ static s32 e1000_k1_workaround_lv(struct e1000_hw *hw) u16 phy_reg; if (hw->mac.type != e1000_pch2lan) - goto out; + return 0; /* Set K1 beacon duration based on 1Gbps speed or otherwise */ ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg); if (ret_val) - goto out; + return ret_val; if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) { @@ -1721,7 +1706,7 @@ static s32 e1000_k1_workaround_lv(struct e1000_hw *hw) ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg); if (ret_val) - goto out; + return ret_val; if (status_reg & HV_M_STATUS_SPEED_1000) { mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC; @@ -1734,7 +1719,6 @@ static s32 e1000_k1_workaround_lv(struct e1000_hw *hw) ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); } -out: return ret_val; } @@ -1805,7 +1789,7 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) u16 reg; if (e1000_check_reset_block(hw)) - goto out; + return 0; /* Allow time for h/w to get to quiescent state after reset */ usleep_range(10000, 20000); @@ -1815,12 +1799,12 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) case e1000_pchlan: ret_val = e1000_hv_phy_workarounds_ich8lan(hw); if (ret_val) - goto out; + return ret_val; break; case e1000_pch2lan: ret_val = e1000_lv_phy_workarounds_ich8lan(hw); if (ret_val) - goto out; + return ret_val; break; default: break; @@ -1836,7 +1820,7 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) /* Configure the LCD with the extended configuration region in NVM */ ret_val = e1000_sw_lcd_config_ich8lan(hw); if (ret_val) - goto out; + return ret_val; /* Configure the LCD with the OEM bits in NVM */ ret_val = e1000_oem_bits_config_ich8lan(hw, true); @@ -1851,18 +1835,16 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) /* Set EEE LPI Update Timer to 200usec */ ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR, I82579_LPI_UPDATE_TIMER); - if (ret_val) - goto release; - ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, - 0x1387); -release: + if (!ret_val) + ret_val = hw->phy.ops.write_reg_locked(hw, + I82579_EMI_DATA, + 0x1387); hw->phy.ops.release(hw); } -out: return ret_val; } @@ -1885,12 +1867,9 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) ret_val = e1000e_phy_hw_reset_generic(hw); if (ret_val) - goto out; - - ret_val = e1000_post_phy_reset_ich8lan(hw); + return ret_val; -out: - return ret_val; + return e1000_post_phy_reset_ich8lan(hw); } /** @@ -1911,7 +1890,7 @@ static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg); if (ret_val) - goto out; + return ret_val; if (active) oem_reg |= HV_OEM_BITS_LPLU; @@ -1921,10 +1900,7 @@ static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) if (!e1000_check_reset_block(hw)) oem_reg |= HV_OEM_BITS_RESTART_AN; - ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg); - -out: - return ret_val; + return e1e_wphy(hw, HV_OEM_BITS, oem_reg); } /** @@ -3001,7 +2977,7 @@ static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw) /* Get default ID LED modes */ ret_val = hw->nvm.ops.valid_led_default(hw, &data); if (ret_val) - goto out; + return ret_val; mac->ledctl_default = er32(LEDCTL); mac->ledctl_mode1 = mac->ledctl_default; @@ -3046,8 +3022,7 @@ static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw) } } -out: - return ret_val; + return 0; } /** @@ -3162,11 +3137,11 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) if (ctrl & E1000_CTRL_PHY_RST) { ret_val = hw->phy.ops.get_cfg_done(hw); if (ret_val) - goto out; + return ret_val; ret_val = e1000_post_phy_reset_ich8lan(hw); if (ret_val) - goto out; + return ret_val; } /* @@ -3184,8 +3159,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) kab |= E1000_KABGTXD_BGSQLBIAS; ew32(KABGTXD, kab); -out: - return ret_val; + return 0; } /** diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 943b9090fda0..17991e63083d 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -172,23 +172,23 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) ret_val = e1000_read_nvm(hw, NVM_COMPAT, 1, &nvm_data); if (ret_val) - goto out; + return ret_val; /* not supported on 82573 */ if (hw->mac.type == e1000_82573) - goto out; + return 0; ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, &nvm_alt_mac_addr_offset); if (ret_val) { e_dbg("NVM Read Error\n"); - goto out; + return ret_val; } if ((nvm_alt_mac_addr_offset == 0xFFFF) || (nvm_alt_mac_addr_offset == 0x0000)) /* There is no Alternate MAC Address */ - goto out; + return 0; if (hw->bus.func == E1000_FUNC_1) nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1; @@ -197,7 +197,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data); if (ret_val) { e_dbg("NVM Read Error\n"); - goto out; + return ret_val; } alt_mac_addr[i] = (u8)(nvm_data & 0xFF); @@ -207,7 +207,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) /* if multicast bit is set, the alternate address will not be used */ if (is_multicast_ether_addr(alt_mac_addr)) { e_dbg("Ignoring Alternate Mac Address with MC bit set\n"); - goto out; + return 0; } /* @@ -217,8 +217,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) */ e1000e_rar_set(hw, alt_mac_addr, 0); -out: - return ret_val; + return 0; } /** diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c index c54caf6e5801..0d24b13ce763 100644 --- a/drivers/net/ethernet/intel/e1000e/manage.c +++ b/drivers/net/ethernet/intel/e1000e/manage.c @@ -140,7 +140,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) /* No manageability, no filtering */ if (!e1000e_check_mng_mode(hw)) { hw->mac.tx_pkt_filtering = false; - goto out; + return hw->mac.tx_pkt_filtering; } /* @@ -150,7 +150,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) ret_val = e1000_mng_enable_host_if(hw); if (ret_val) { hw->mac.tx_pkt_filtering = false; - goto out; + return hw->mac.tx_pkt_filtering; } /* Read in the header. Length and offset are in dwords. */ @@ -170,16 +170,13 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) */ if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) { hw->mac.tx_pkt_filtering = true; - goto out; + return hw->mac.tx_pkt_filtering; } /* Cookie area is valid, make the final check for filtering. */ - if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) { + if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) hw->mac.tx_pkt_filtering = false; - goto out; - } -out: return hw->mac.tx_pkt_filtering; } @@ -336,12 +333,11 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) { u32 manc; u32 fwsm, factps; - bool ret_val = false; manc = er32(MANC); if (!(manc & E1000_MANC_RCV_TCO_EN)) - goto out; + return false; if (hw->mac.has_fwsm) { fwsm = er32(FWSM); @@ -349,10 +345,8 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) if (!(factps & E1000_FACTPS_MNGCG) && ((fwsm & E1000_FWSM_MODE_MASK) == - (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) { - ret_val = true; - goto out; - } + (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) + return true; } else if ((hw->mac.type == e1000_82574) || (hw->mac.type == e1000_82583)) { u16 data; @@ -362,16 +356,12 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) if (!(factps & E1000_FACTPS_MNGCG) && ((data & E1000_NVM_INIT_CTRL2_MNGM) == - (e1000_mng_mode_pt << 13))) { - ret_val = true; - goto out; - } + (e1000_mng_mode_pt << 13))) + return true; } else if ((manc & E1000_MANC_SMBUS_EN) && !(manc & E1000_MANC_ASF_EN)) { - ret_val = true; - goto out; + return true; } -out: - return ret_val; + return false; } diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index c11b40b81acf..c079b9b0810d 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1985,7 +1985,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter) e1000_intr_msix_rx, 0, adapter->rx_ring->name, netdev); if (err) - goto out; + return err; adapter->rx_ring->itr_register = adapter->hw.hw_addr + E1000_EITR_82574(vector); adapter->rx_ring->itr_val = adapter->itr; @@ -2001,7 +2001,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter) e1000_intr_msix_tx, 0, adapter->tx_ring->name, netdev); if (err) - goto out; + return err; adapter->tx_ring->itr_register = adapter->hw.hw_addr + E1000_EITR_82574(vector); adapter->tx_ring->itr_val = adapter->itr; @@ -2010,12 +2010,11 @@ static int e1000_request_msix(struct e1000_adapter *adapter) err = request_irq(adapter->msix_entries[vector].vector, e1000_msix_other, 0, netdev->name, netdev); if (err) - goto out; + return err; e1000_configure_msix(adapter); + return 0; -out: - return err; } /** @@ -2367,7 +2366,7 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter, unsigned int retval = itr_setting; if (packets == 0) - goto update_itr_done; + return itr_setting; switch (itr_setting) { case lowest_latency: @@ -2402,7 +2401,6 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter, break; } -update_itr_done: return retval; } diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c index 1b50db59fb0d..24b7930b7500 100644 --- a/drivers/net/ethernet/intel/e1000e/nvm.c +++ b/drivers/net/ethernet/intel/e1000e/nvm.c @@ -446,20 +446,19 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, if (pba_num == NULL) { e_dbg("PBA string buffer was null\n"); - ret_val = E1000_ERR_INVALID_ARGUMENT; - goto out; + return -E1000_ERR_INVALID_ARGUMENT; } ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); if (ret_val) { e_dbg("NVM Read Error\n"); - goto out; + return ret_val; } ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr); if (ret_val) { e_dbg("NVM Read Error\n"); - goto out; + return ret_val; } /* @@ -499,25 +498,23 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, pba_num[offset] += 'A' - 0xA; } - goto out; + return 0; } ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length); if (ret_val) { e_dbg("NVM Read Error\n"); - goto out; + return ret_val; } if (length == 0xFFFF || length == 0) { e_dbg("NVM PBA number section invalid length\n"); - ret_val = E1000_ERR_NVM_PBA_SECTION; - goto out; + return -E1000_ERR_NVM_PBA_SECTION; } /* check if pba_num buffer is big enough */ if (pba_num_size < (((u32)length * 2) - 1)) { e_dbg("PBA string buffer too small\n"); - ret_val = E1000_ERR_NO_SPACE; - goto out; + return -E1000_ERR_NO_SPACE; } /* trim pba length from start of string */ @@ -528,15 +525,14 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data); if (ret_val) { e_dbg("NVM Read Error\n"); - goto out; + return ret_val; } pba_num[offset * 2] = (u8)(nvm_data >> 8); pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); } pba_num[offset * 2] = '\0'; -out: - return ret_val; + return 0; } /** diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 0e86c7e761ea..d4dbbe741246 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -133,29 +133,29 @@ s32 e1000e_get_phy_id(struct e1000_hw *hw) u16 retry_count = 0; if (!phy->ops.read_reg) - goto out; + return 0; while (retry_count < 2) { ret_val = e1e_rphy(hw, PHY_ID1, &phy_id); if (ret_val) - goto out; + return ret_val; phy->id = (u32)(phy_id << 16); udelay(20); ret_val = e1e_rphy(hw, PHY_ID2, &phy_id); if (ret_val) - goto out; + return ret_val; phy->id |= (u32)(phy_id & PHY_REVISION_MASK); phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); if (phy->id != 0 && phy->id != PHY_REVISION_MASK) - goto out; + return 0; retry_count++; } -out: - return ret_val; + + return 0; } /** @@ -383,28 +383,24 @@ static s32 __e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, if (!locked) { if (!hw->phy.ops.acquire) - goto out; + return 0; ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; } - if (offset > MAX_PHY_MULTI_PAGE_REG) { + if (offset > MAX_PHY_MULTI_PAGE_REG) ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, (u16)offset); - if (ret_val) - goto release; - } - - ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, - data); - -release: + if (!ret_val) + ret_val = e1000e_read_phy_reg_mdic(hw, + MAX_PHY_REG_ADDRESS & offset, + data); if (!locked) hw->phy.ops.release(hw); -out: + return ret_val; } @@ -454,29 +450,24 @@ static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, if (!locked) { if (!hw->phy.ops.acquire) - goto out; + return 0; ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; } - if (offset > MAX_PHY_MULTI_PAGE_REG) { + if (offset > MAX_PHY_MULTI_PAGE_REG) ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, (u16)offset); - if (ret_val) - goto release; - } - - ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, - data); - -release: + if (!ret_val) + ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & + offset, + data); if (!locked) hw->phy.ops.release(hw); -out: return ret_val; } @@ -523,15 +514,16 @@ static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, bool locked) { u32 kmrnctrlsta; - s32 ret_val = 0; if (!locked) { + s32 ret_val = 0; + if (!hw->phy.ops.acquire) - goto out; + return 0; ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; } kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & @@ -547,8 +539,7 @@ static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, if (!locked) hw->phy.ops.release(hw); -out: - return ret_val; + return 0; } /** @@ -596,15 +587,16 @@ static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, bool locked) { u32 kmrnctrlsta; - s32 ret_val = 0; if (!locked) { + s32 ret_val = 0; + if (!hw->phy.ops.acquire) - goto out; + return 0; ret_val = hw->phy.ops.acquire(hw); if (ret_val) - goto out; + return ret_val; } kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & @@ -617,8 +609,7 @@ static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, if (!locked) hw->phy.ops.release(hw); -out: - return ret_val; + return 0; } /** @@ -663,17 +654,14 @@ s32 e1000_copper_link_setup_82577(struct e1000_hw *hw) /* Enable CRS on Tx. This must be set for half-duplex operation. */ ret_val = e1e_rphy(hw, I82577_CFG_REG, &phy_data); if (ret_val) - goto out; + return ret_val; phy_data |= I82577_CFG_ASSERT_CRS_ON_TX; /* Enable downshift */ phy_data |= I82577_CFG_ENABLE_DOWNSHIFT; - ret_val = e1e_wphy(hw, I82577_CFG_REG, phy_data); - -out: - return ret_val; + return e1e_wphy(hw, I82577_CFG_REG, phy_data); } /** @@ -1397,25 +1385,25 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw) ret_val = e1e_rphy(hw, PHY_CONTROL, &data); if (ret_val) - goto out; + return ret_val; e1000e_phy_force_speed_duplex_setup(hw, &data); ret_val = e1e_wphy(hw, PHY_CONTROL, data); if (ret_val) - goto out; + return ret_val; /* Disable MDI-X support for 10/100 */ ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data); if (ret_val) - goto out; + return ret_val; data &= ~IFE_PMC_AUTO_MDIX; data &= ~IFE_PMC_FORCE_MDIX; ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, data); if (ret_val) - goto out; + return ret_val; e_dbg("IFE PMC: %X\n", data); @@ -1429,7 +1417,7 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw) 100000, &link); if (ret_val) - goto out; + return ret_val; if (!link) e_dbg("Link taking longer than expected.\n"); @@ -1440,11 +1428,10 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw) 100000, &link); if (ret_val) - goto out; + return ret_val; } -out: - return ret_val; + return 0; } /** @@ -1829,22 +1816,20 @@ s32 e1000e_get_cable_length_m88(struct e1000_hw *hw) ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); if (ret_val) - goto out; + return ret_val; index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >> M88E1000_PSSR_CABLE_LENGTH_SHIFT; - if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) { - ret_val = -E1000_ERR_PHY; - goto out; - } + + if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) + return -E1000_ERR_PHY; phy->min_cable_length = e1000_m88_cable_length_table[index]; phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; -out: - return ret_val; + return 0; } /** @@ -2069,24 +2054,23 @@ s32 e1000_get_phy_info_ife(struct e1000_hw *hw) ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) - goto out; + return ret_val; if (!link) { e_dbg("Phy info is only valid if link is up\n"); - ret_val = -E1000_ERR_CONFIG; - goto out; + return -E1000_ERR_CONFIG; } ret_val = e1e_rphy(hw, IFE_PHY_SPECIAL_CONTROL, &data); if (ret_val) - goto out; + return ret_val; phy->polarity_correction = (data & IFE_PSC_AUTO_POLARITY_DISABLE) ? false : true; if (phy->polarity_correction) { ret_val = e1000_check_polarity_ife(hw); if (ret_val) - goto out; + return ret_val; } else { /* Polarity is forced */ phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY) @@ -2096,7 +2080,7 @@ s32 e1000_get_phy_info_ife(struct e1000_hw *hw) ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data); if (ret_val) - goto out; + return ret_val; phy->is_mdix = (data & IFE_PMC_MDIX_STATUS) ? true : false; @@ -2105,8 +2089,7 @@ s32 e1000_get_phy_info_ife(struct e1000_hw *hw) phy->local_rx = e1000_1000t_rx_status_undefined; phy->remote_rx = e1000_1000t_rx_status_undefined; -out: - return ret_val; + return 0; } /** @@ -2365,7 +2348,6 @@ enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id) **/ s32 e1000e_determine_phy_address(struct e1000_hw *hw) { - s32 ret_val = -E1000_ERR_PHY_TYPE; u32 phy_addr = 0; u32 i; enum e1000_phy_type phy_type = e1000_phy_unknown; @@ -2384,17 +2366,15 @@ s32 e1000e_determine_phy_address(struct e1000_hw *hw) * If phy_type is valid, break - we found our * PHY address */ - if (phy_type != e1000_phy_unknown) { - ret_val = 0; - goto out; - } + if (phy_type != e1000_phy_unknown) + return 0; + usleep_range(1000, 2000); i++; } while (i < 10); } -out: - return ret_val; + return -E1000_ERR_PHY_TYPE; } /** @@ -2638,14 +2618,14 @@ s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg) ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); if (ret_val) { e_dbg("Could not set Port Control page\n"); - goto out; + return ret_val; } ret_val = e1000e_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg); if (ret_val) { e_dbg("Could not read PHY register %d.%d\n", BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); - goto out; + return ret_val; } /* @@ -2660,15 +2640,14 @@ s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg) if (ret_val) { e_dbg("Could not write PHY register %d.%d\n", BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); - goto out; + return ret_val; } - /* Select Host Wakeup Registers page */ - ret_val = e1000_set_page_igp(hw, (BM_WUC_PAGE << IGP_PAGE_SHIFT)); - - /* caller now able to write registers on the Wakeup registers page */ -out: - return ret_val; + /* + * Select Host Wakeup Registers page - caller now able to write + * registers on the Wakeup registers page + */ + return e1000_set_page_igp(hw, (BM_WUC_PAGE << IGP_PAGE_SHIFT)); } /** @@ -2690,7 +2669,7 @@ s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg) ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); if (ret_val) { e_dbg("Could not set Port Control page\n"); - goto out; + return ret_val; } /* Restore 769.17 to its original value */ @@ -2698,7 +2677,7 @@ s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg) if (ret_val) e_dbg("Could not restore PHY register %d.%d\n", BM_PORT_CTRL_PAGE, BM_WUC_ENABLE_REG); -out: + return ret_val; } @@ -2746,7 +2725,7 @@ static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg); if (ret_val) { e_dbg("Could not enable PHY wakeup reg access\n"); - goto out; + return ret_val; } } @@ -2756,7 +2735,7 @@ static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ADDRESS_OPCODE, reg); if (ret_val) { e_dbg("Could not write address opcode to page %d\n", page); - goto out; + return ret_val; } if (read) { @@ -2771,13 +2750,12 @@ static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, if (ret_val) { e_dbg("Could not access PHY reg %d.%d\n", page, reg); - goto out; + return ret_val; } if (!page_set) ret_val = e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg); -out: return ret_val; } @@ -3133,7 +3111,7 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, ret_val = e1000e_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F); if (ret_val) { e_dbg("Could not write the Address Offset port register\n"); - goto out; + return ret_val; } /* Read or write the data value next */ @@ -3142,12 +3120,9 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, else ret_val = e1000e_write_phy_reg_mdic(hw, data_reg, *data); - if (ret_val) { + if (ret_val) e_dbg("Could not access the Data port register\n"); - goto out; - } -out: return ret_val; } @@ -3168,17 +3143,17 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) u16 data; if (hw->phy.type != e1000_phy_82578) - goto out; + return 0; /* Do not apply workaround if in PHY loopback bit 14 set */ e1e_rphy(hw, PHY_CONTROL, &data); if (data & PHY_CONTROL_LB) - goto out; + return 0; /* check if link is up and at 1Gbps */ ret_val = e1e_rphy(hw, BM_CS_STATUS, &data); if (ret_val) - goto out; + return ret_val; data &= BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | @@ -3187,7 +3162,7 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) if (data != (BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | BM_CS_STATUS_SPEED_1000)) - goto out; + return 0; mdelay(200); @@ -3195,12 +3170,9 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC | HV_MUX_DATA_CTRL_FORCE_SPEED); if (ret_val) - goto out; - - ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC); + return ret_val; -out: - return ret_val; + return e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC); } /** @@ -3242,13 +3214,13 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw) ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data); if (ret_val) - goto out; + return ret_val; e1000e_phy_force_speed_duplex_setup(hw, &phy_data); ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); if (ret_val) - goto out; + return ret_val; udelay(1); @@ -3260,7 +3232,7 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw) 100000, &link); if (ret_val) - goto out; + return ret_val; if (!link) e_dbg("Link taking longer than expected.\n"); @@ -3270,11 +3242,8 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw) PHY_FORCE_LIMIT, 100000, &link); - if (ret_val) - goto out; } -out: return ret_val; } @@ -3296,23 +3265,22 @@ s32 e1000_get_phy_info_82577(struct e1000_hw *hw) ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) - goto out; + return ret_val; if (!link) { e_dbg("Phy info is only valid if link is up\n"); - ret_val = -E1000_ERR_CONFIG; - goto out; + return -E1000_ERR_CONFIG; } phy->polarity_correction = true; ret_val = e1000_check_polarity_82577(hw); if (ret_val) - goto out; + return ret_val; ret_val = e1e_rphy(hw, I82577_PHY_STATUS_2, &data); if (ret_val) - goto out; + return ret_val; phy->is_mdix = (data & I82577_PHY_STATUS2_MDIX) ? true : false; @@ -3320,11 +3288,11 @@ s32 e1000_get_phy_info_82577(struct e1000_hw *hw) I82577_PHY_STATUS2_SPEED_1000MBPS) { ret_val = hw->phy.ops.get_cable_length(hw); if (ret_val) - goto out; + return ret_val; ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &data); if (ret_val) - goto out; + return ret_val; phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) ? e1000_1000t_rx_status_ok @@ -3339,8 +3307,7 @@ s32 e1000_get_phy_info_82577(struct e1000_hw *hw) phy->remote_rx = e1000_1000t_rx_status_undefined; } -out: - return ret_val; + return 0; } /** @@ -3358,7 +3325,7 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw) ret_val = e1e_rphy(hw, I82577_PHY_DIAG_STATUS, &phy_data); if (ret_val) - goto out; + return ret_val; length = (phy_data & I82577_DSTATUS_CABLE_LENGTH) >> I82577_DSTATUS_CABLE_LENGTH_SHIFT; @@ -3368,6 +3335,5 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw) phy->cable_length = length; -out: - return ret_val; + return 0; } -- GitLab From d9ab70079a9730f2d748714cbe4242bc707b9eef Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 13 Feb 2012 23:29:16 +0000 Subject: [PATCH 0695/1846] sfc: Skip RX end-of-batch work on channels without an RX queue The code in efx_process_channel() to update the RX queue after each batch of RX completions works out as a no-op on a TX-only channel where the RX queue structure is set to all-zeroes, but (1) efx_channel_get_rx_queue() will BUG() if DEBUG is defined, and (2) it's a waste of time. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 952d0bf7695a..b7cf9f0108ed 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -224,19 +224,20 @@ static int efx_process_channel(struct efx_channel *channel, int budget) return 0; spent = efx_nic_process_eventq(channel, budget); - if (spent == 0) - return 0; + if (spent && efx_channel_has_rx_queue(channel)) { + struct efx_rx_queue *rx_queue = + efx_channel_get_rx_queue(channel); + + /* Deliver last RX packet. */ + if (channel->rx_pkt) { + __efx_rx_packet(channel, channel->rx_pkt); + channel->rx_pkt = NULL; + } - /* Deliver last RX packet. */ - if (channel->rx_pkt) { - __efx_rx_packet(channel, channel->rx_pkt); - channel->rx_pkt = NULL; + efx_rx_strategy(channel); + efx_fast_push_rx_descriptors(rx_queue); } - efx_rx_strategy(channel); - - efx_fast_push_rx_descriptors(efx_channel_get_rx_queue(channel)); - return spent; } -- GitLab From fadac6aae1b8d9344beaa18aa9035869d773fd98 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sat, 19 Nov 2011 00:35:47 +0000 Subject: [PATCH 0696/1846] sfc: Do not retry hardware probe if it schedules a reset If efx_pci_probe_main() schedules an INVISIBLE or ALL reset (but nothing more drastic), we retry it up to 5 times. So far as I'm aware, this was a workaround for bugs in Falcon A0 which were fixed in production silicon. Remove the retry. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 50 +++++++++++----------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index b7cf9f0108ed..2e6389c55cee 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -2440,7 +2440,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, const struct efx_nic_type *type = (const struct efx_nic_type *) entry->driver_data; struct net_device *net_dev; struct efx_nic *efx; - int i, rc; + int rc; /* Allocate and initialise a struct net_device and struct efx_nic */ net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES, @@ -2473,39 +2473,22 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, if (rc) goto fail2; - /* No serialisation is required with the reset path because - * we're in STATE_INIT. */ - for (i = 0; i < 5; i++) { - rc = efx_pci_probe_main(efx); - - /* Serialise against efx_reset(). No more resets will be - * scheduled since efx_stop_all() has been called, and we - * have not and never have been registered with either - * the rtnetlink or driverlink layers. */ - cancel_work_sync(&efx->reset_work); - - if (rc == 0) { - if (efx->reset_pending) { - /* If there was a scheduled reset during - * probe, the NIC is probably hosed anyway */ - efx_pci_remove_main(efx); - rc = -EIO; - } else { - break; - } - } + rc = efx_pci_probe_main(efx); - /* Retry if a recoverably reset event has been scheduled */ - if (efx->reset_pending & - ~(1 << RESET_TYPE_INVISIBLE | 1 << RESET_TYPE_ALL) || - !efx->reset_pending) - goto fail3; + /* Serialise against efx_reset(). No more resets will be + * scheduled since efx_stop_all() has been called, and we have + * not and never have been registered. + */ + cancel_work_sync(&efx->reset_work); - efx->reset_pending = 0; - } + if (rc) + goto fail3; - if (rc) { - netif_err(efx, probe, efx->net_dev, "Could not reset NIC\n"); + /* If there was a scheduled reset during probe, the NIC is + * probably hosed anyway. + */ + if (efx->reset_pending) { + rc = -EIO; goto fail4; } @@ -2515,7 +2498,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, rc = efx_register_netdev(efx); if (rc) - goto fail5; + goto fail4; netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); @@ -2524,9 +2507,8 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, rtnl_unlock(); return 0; - fail5: - efx_pci_remove_main(efx); fail4: + efx_pci_remove_main(efx); fail3: efx_fini_io(efx); fail2: -- GitLab From 5b6262d0ccf759a16fabe11d904a2531125a4b71 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 2 Feb 2012 21:21:15 +0000 Subject: [PATCH 0697/1846] sfc: Replace some literal constants with EFX_PAGE_SIZE/EFX_BUF_SIZE The 'page size' for PCIe DMA, i.e. the alignment of boundaries at which DMA must be broken, is 4KB. Name this value as EFX_PAGE_SIZE and use it in efx_max_tx_len(). Redefine EFX_BUF_SIZE as EFX_PAGE_SIZE since its value is also a result of that requirement, and use it in efx_init_special_buffer(). Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/nic.c | 5 +---- drivers/net/ethernet/sfc/nic.h | 5 +++++ drivers/net/ethernet/sfc/tx.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index a43d1ca270c0..dd50c4f73a9d 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -54,9 +54,6 @@ #define EFX_FLUSH_INTERVAL 10 #define EFX_FLUSH_POLL_COUNT 100 -/* Size and alignment of special buffers (4KB) */ -#define EFX_BUF_SIZE 4096 - /* Depth of RX flush request fifo */ #define EFX_RX_FLUSH_COUNT 4 @@ -196,7 +193,7 @@ efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer) /* Write buffer descriptors to NIC */ for (i = 0; i < buffer->entries; i++) { index = buffer->index + i; - dma_addr = buffer->dma_addr + (i * 4096); + dma_addr = buffer->dma_addr + (i * EFX_BUF_SIZE); netif_dbg(efx, probe, efx->net_dev, "mapping special buffer %d at %llx\n", index, (unsigned long long)dma_addr); diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 905a1877d603..4f9d18ac92fe 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -65,6 +65,11 @@ enum { #define FALCON_GMAC_LOOPBACKS \ (1 << LOOPBACK_GMAC) +/* Alignment of PCIe DMA boundaries (4KB) */ +#define EFX_PAGE_SIZE 4096 +/* Size and alignment of buffer table entries (same) */ +#define EFX_BUF_SIZE EFX_PAGE_SIZE + /** * struct falcon_board_type - board operations and type information * @id: Board type id, as found in NVRAM diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c index 5cb81fa3fcbd..a096e287e95f 100644 --- a/drivers/net/ethernet/sfc/tx.c +++ b/drivers/net/ethernet/sfc/tx.c @@ -110,7 +110,7 @@ efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr) * little benefit from using descriptors that cross those * boundaries and we keep things simple by not doing so. */ - unsigned len = (~dma_addr & 0xfff) + 1; + unsigned len = (~dma_addr & (EFX_PAGE_SIZE - 1)) + 1; /* Work around hardware bug for unaligned buffers. */ if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf)) -- GitLab From 7c43161c11d7f40e38db9a1adb61347f06127796 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 27 Jan 2012 17:23:58 +0000 Subject: [PATCH 0698/1846] sfc: Warn if unable to create MTDs Log an explicit warning if we are unable to create MTDs for a net device. Also correct the comment about why mtd_device_register() may fail; there is no longer an MTD table to fill up. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 7 ++++++- drivers/net/ethernet/sfc/mtd.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 2e6389c55cee..ce07aa516cd2 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -2502,9 +2502,14 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); + /* Try to create MTDs, but allow this to fail */ rtnl_lock(); - efx_mtd_probe(efx); /* allowed to fail */ + rc = efx_mtd_probe(efx); rtnl_unlock(); + if (rc) + netif_warn(efx, probe, efx->net_dev, + "failed to create MTDs (%d)\n", rc); + return 0; fail4: diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c index 79c192272047..26b3c23b0b6f 100644 --- a/drivers/net/ethernet/sfc/mtd.c +++ b/drivers/net/ethernet/sfc/mtd.c @@ -280,7 +280,7 @@ static int efx_mtd_probe_device(struct efx_nic *efx, struct efx_mtd *efx_mtd) --part; efx_mtd_remove_partition(part); } - /* mtd_device_register() returns 1 if the MTD table is full */ + /* Failure is unlikely here, but probably means we're out of memory */ return -ENOMEM; } -- GitLab From 3906969189a409e590a51b18c86a92d0506c9372 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:08 +0000 Subject: [PATCH 0699/1846] tg3: Disable new DMA engine for 57766 A bug was found in the new DMA engine for the 57766. This patch disables it, which causes the device to fallback to the old DMA engine. Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index d418f954c72d..0a765f109cc1 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -8896,9 +8896,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) if (tg3_flag(tp, PCI_EXPRESS)) rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST; - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57766) - rdmac_mode |= RDMAC_MODE_JMB_2K_MMRR; - if (tg3_flag(tp, HW_TSO_1) || tg3_flag(tp, HW_TSO_2) || tg3_flag(tp, HW_TSO_3)) @@ -14190,8 +14187,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) tp->dma_limit = TG3_TX_BD_DMA_MAX_4K; - else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57766) - tp->dma_limit = TG3_TX_BD_DMA_MAX_2K; if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || -- GitLab From b546e46f5c9f19a921d6f62db80f2e9371bc0558 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:09 +0000 Subject: [PATCH 0700/1846] tg3: Fix stats while interface is down If the tg3 interface is down, the driver will return ethtool stats uninitialized. This patch zeroes out the destination stat buffer in such a case. Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 0a765f109cc1..4a0b9af71238 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -10154,9 +10154,6 @@ static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *tp, struct tg3_ethtool_stats *old_estats = &tp->estats_prev; struct tg3_hw_stats *hw_stats = tp->hw_stats; - if (!hw_stats) - return old_estats; - ESTAT_ADD(rx_octets); ESTAT_ADD(rx_fragments); ESTAT_ADD(rx_ucast_packets); @@ -11029,7 +11026,10 @@ static void tg3_get_ethtool_stats(struct net_device *dev, { struct tg3 *tp = netdev_priv(dev); - tg3_get_estats(tp, (struct tg3_ethtool_stats *)tmp_stats); + if (tp->hw_stats) + tg3_get_estats(tp, (struct tg3_ethtool_stats *)tmp_stats); + else + memset(tmp_stats, 0, sizeof(struct tg3_ethtool_stats)); } static __be32 *tg3_vpd_readblock(struct tg3 *tp, u32 *vpdlen) -- GitLab From 3198e07fd64aa8c3a38dda33bcc0f44265eb581e Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:10 +0000 Subject: [PATCH 0701/1846] tg3: Fix copper autoneg adv checks When checking the autoneg advertisements, the driver failed to include the master and master enable bits for the bcm5701. This patch fixes the problem. Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 4a0b9af71238..cb17885cad47 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -4027,7 +4027,16 @@ static bool tg3_phy_copper_an_config_ok(struct tg3 *tp, u32 *lcladv) if (tg3_readphy(tp, MII_CTRL1000, &tg3_ctrl)) return false; - tg3_ctrl &= (ADVERTISE_1000HALF | ADVERTISE_1000FULL); + if (tgtadv && + (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 || + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)) { + tgtadv |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER; + tg3_ctrl &= (ADVERTISE_1000HALF | ADVERTISE_1000FULL | + CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER); + } else { + tg3_ctrl &= (ADVERTISE_1000HALF | ADVERTISE_1000FULL); + } + if (tg3_ctrl != tgtadv) return false; } -- GitLab From 422782249927e887a4c032d1d7e1f59de281ecbb Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:11 +0000 Subject: [PATCH 0702/1846] tg3: Fix NVRAM page writes on newer devices On newer devices, the hardware expects the NVRAM address register to be written only once per NVRAM page. To do otherwise causes NVRAM corruption. This patch fixes the problem. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index cb17885cad47..67b6d61abfe1 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -3140,8 +3140,6 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, phy_addr = tg3_nvram_phys_addr(tp, offset); - tw32(NVRAM_ADDR, phy_addr); - nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR; if (page_off == 0 || i == 0) @@ -3152,6 +3150,11 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, if (i == (len - 4)) nvram_cmd |= NVRAM_CMD_LAST; + if ((nvram_cmd & NVRAM_CMD_FIRST) || + !tg3_flag(tp, FLASH) || + !tg3_flag(tp, 57765_PLUS)) + tw32(NVRAM_ADDR, phy_addr); + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 && !tg3_flag(tp, 5755_PLUS) && (tp->nvram_jedecnum == JEDEC_ST) && -- GitLab From b28f389d92114ecf1a7c99eb3865438543a1808b Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:12 +0000 Subject: [PATCH 0703/1846] tg3: Reduce UMP event collision window The tg3 driver needs to submit a few phy register values to the UMP firmware each time the link state changes. Up until now, the driver would wait for the previous event to complete, then proceed to gather data through a series of phy accesses. Since phy accesses are relatively slow, it is possible for another thread to attempt to submit its own event while the UMP code is still construction its message. This patch seeks to minimize the collision window as much as possible by preloading the phy data. Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 42 ++++++++++++++++++----------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 67b6d61abfe1..31a8e8a64a6c 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -1453,33 +1453,23 @@ static void tg3_wait_for_event_ack(struct tg3 *tp) } /* tp->lock is held. */ -static void tg3_ump_link_report(struct tg3 *tp) +static void tg3_phy_gather_ump_data(struct tg3 *tp, u32 *data) { - u32 reg; - u32 val; - - if (!tg3_flag(tp, 5780_CLASS) || !tg3_flag(tp, ENABLE_ASF)) - return; - - tg3_wait_for_event_ack(tp); - - tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_LINK_UPDATE); - - tg3_write_mem(tp, NIC_SRAM_FW_CMD_LEN_MBOX, 14); + u32 reg, val; val = 0; if (!tg3_readphy(tp, MII_BMCR, ®)) val = reg << 16; if (!tg3_readphy(tp, MII_BMSR, ®)) val |= (reg & 0xffff); - tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX, val); + *data++ = val; val = 0; if (!tg3_readphy(tp, MII_ADVERTISE, ®)) val = reg << 16; if (!tg3_readphy(tp, MII_LPA, ®)) val |= (reg & 0xffff); - tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 4, val); + *data++ = val; val = 0; if (!(tp->phy_flags & TG3_PHYFLG_MII_SERDES)) { @@ -1488,13 +1478,33 @@ static void tg3_ump_link_report(struct tg3 *tp) if (!tg3_readphy(tp, MII_STAT1000, ®)) val |= (reg & 0xffff); } - tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 8, val); + *data++ = val; if (!tg3_readphy(tp, MII_PHYADDR, ®)) val = reg << 16; else val = 0; - tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 12, val); + *data++ = val; +} + +/* tp->lock is held. */ +static void tg3_ump_link_report(struct tg3 *tp) +{ + u32 data[4]; + + if (!tg3_flag(tp, 5780_CLASS) || !tg3_flag(tp, ENABLE_ASF)) + return; + + tg3_phy_gather_ump_data(tp, data); + + tg3_wait_for_event_ack(tp); + + tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_LINK_UPDATE); + tg3_write_mem(tp, NIC_SRAM_FW_CMD_LEN_MBOX, 14); + tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 0x0, data[0]); + tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 0x4, data[1]); + tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 0x8, data[2]); + tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX + 0xc, data[3]); tg3_generate_fw_event(tp); } -- GitLab From 42b123b1297d10e79bd75bc665058122161f368d Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:13 +0000 Subject: [PATCH 0704/1846] tg3: Consolidate ASIC rev detection code Detecting the ASIC revision of a device is getting to be an increasingly complex process. This patch consolidates all the ASIC rev detection code to a single routine for better maintainability. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 159 ++++++++++++++-------------- 1 file changed, 79 insertions(+), 80 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 31a8e8a64a6c..27cf74c74792 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -13912,6 +13912,83 @@ static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp) return peer; } +static void __devinit tg3_detect_asic_rev(struct tg3 *tp, u32 misc_ctrl_reg) +{ + tp->pci_chip_rev_id = misc_ctrl_reg >> MISC_HOST_CTRL_CHIPREV_SHIFT; + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_USE_PROD_ID_REG) { + u32 reg; + + /* All devices that use the alternate + * ASIC REV location have a CPMU. + */ + tg3_flag_set(tp, CPMU_PRESENT); + + if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_5719 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_5720) + reg = TG3PCI_GEN2_PRODID_ASICREV; + else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57781 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57785 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57761 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57765 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57791 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57795 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57762 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57766 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57782 || + tp->pdev->device == TG3PCI_DEVICE_TIGON3_57786) + reg = TG3PCI_GEN15_PRODID_ASICREV; + else + reg = TG3PCI_PRODID_ASICREV; + + pci_read_config_dword(tp->pdev, reg, &tp->pci_chip_rev_id); + } + + /* Wrong chip ID in 5752 A0. This code can be removed later + * as A0 is not in production. + */ + if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW) + tp->pci_chip_rev_id = CHIPREV_ID_5752_A0; + + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) + tg3_flag_set(tp, 5717_PLUS); + + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57766) + tg3_flag_set(tp, 57765_CLASS); + + if (tg3_flag(tp, 57765_CLASS) || tg3_flag(tp, 5717_PLUS)) + tg3_flag_set(tp, 57765_PLUS); + + /* Intentionally exclude ASIC_REV_5906 */ + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 || + tg3_flag(tp, 57765_PLUS)) + tg3_flag_set(tp, 5755_PLUS); + + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) + tg3_flag_set(tp, 5780_CLASS); + + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906 || + tg3_flag(tp, 5755_PLUS) || + tg3_flag(tp, 5780_CLASS)) + tg3_flag_set(tp, 5750_PLUS); + + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 || + tg3_flag(tp, 5750_PLUS)) + tg3_flag_set(tp, 5705_PLUS); +} + static int __devinit tg3_get_invariants(struct tg3 *tp) { u32 misc_ctrl_reg; @@ -13943,43 +14020,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl); - tp->pci_chip_rev_id = (misc_ctrl_reg >> - MISC_HOST_CTRL_CHIPREV_SHIFT); - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_USE_PROD_ID_REG) { - u32 prod_id_asic_rev; - - if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5719 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5720) - pci_read_config_dword(tp->pdev, - TG3PCI_GEN2_PRODID_ASICREV, - &prod_id_asic_rev); - else if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_57781 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57785 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57761 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57765 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57791 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57795 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57762 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57766 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57782 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_57786) - pci_read_config_dword(tp->pdev, - TG3PCI_GEN15_PRODID_ASICREV, - &prod_id_asic_rev); - else - pci_read_config_dword(tp->pdev, TG3PCI_PRODID_ASICREV, - &prod_id_asic_rev); - - tp->pci_chip_rev_id = prod_id_asic_rev; - } - - /* Wrong chip ID in 5752 A0. This code can be removed later - * as A0 is not in production. - */ - if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW) - tp->pci_chip_rev_id = CHIPREV_ID_5752_A0; + tg3_detect_asic_rev(tp, misc_ctrl_reg); /* If we have 5702/03 A1 or A2 on certain ICH chipsets, * we need to disable memory and use config. cycles @@ -14077,9 +14118,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) * Any tg3 device found behind the bridge will also need the 40-bit * DMA workaround. */ - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) { - tg3_flag_set(tp, 5780_CLASS); + if (tg3_flag(tp, 5780_CLASS)) { tg3_flag_set(tp, 40BIT_DMA_BUG); tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI); } else { @@ -14105,39 +14144,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) tp->pdev_peer = tg3_find_peer(tp); - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) - tg3_flag_set(tp, 5717_PLUS); - - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57766) - tg3_flag_set(tp, 57765_CLASS); - - if (tg3_flag(tp, 57765_CLASS) || tg3_flag(tp, 5717_PLUS)) - tg3_flag_set(tp, 57765_PLUS); - - /* Intentionally exclude ASIC_REV_5906 */ - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 || - tg3_flag(tp, 57765_PLUS)) - tg3_flag_set(tp, 5755_PLUS); - - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906 || - tg3_flag(tp, 5755_PLUS) || - tg3_flag(tp, 5780_CLASS)) - tg3_flag_set(tp, 5750_PLUS); - - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 || - tg3_flag(tp, 5750_PLUS)) - tg3_flag_set(tp, 5705_PLUS); - /* Determine TSO capabilities */ if (tp->pci_chip_rev_id == CHIPREV_ID_5719_A0) ; /* Do nothing. HW bug. */ @@ -14467,13 +14473,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) tg3_ape_lock_init(tp); } - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57780 || - tg3_flag(tp, 57765_PLUS)) - tg3_flag_set(tp, CPMU_PRESENT); - /* Set up tp->grc_local_ctrl before calling * tg3_pwrsrc_switch_to_vmain(). GPIO1 driven high * will bring 5700's external PHY out of reset. -- GitLab From 2855b9fe416e55d01a1946b142d87abd4cceb6ea Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:14 +0000 Subject: [PATCH 0705/1846] tg3: Remove unused link config code When tg3 devices are shutdown, the driver uses the TG3_PHYFLG_IS_LOW_POWER flag to enable a static phy configuration. Any attempt to use the link configuration variables is dead code. This patch removes such code. Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 27cf74c74792..610997cec7c9 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -3607,12 +3607,8 @@ static int tg3_power_down_prepare(struct tg3 *tp) tp->link_config.orig_autoneg = tp->link_config.autoneg; } - if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) { - tp->link_config.speed = SPEED_10; - tp->link_config.duplex = DUPLEX_HALF; - tp->link_config.autoneg = AUTONEG_ENABLE; + if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) tg3_setup_phy(tp, 0); - } } if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { -- GitLab From c6700ce2248ecf3b1b6fd009f6aed9b6387d3377 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:15 +0000 Subject: [PATCH 0706/1846] tg3: Remove unneeded link_config.orig_... members This patch removes the unneeded link_config.orig_* members. When the phy is in a low power state, the TG3_PHYFLG_IS_LOW_POWER flag solely determines how the link is configured. When the phy is powered back up, it can resume using the original settings. For the phylib case, the link configuration still needs to be saved, but since the phylib maintains its own configuration, we can repurpose the (unused in this case) tg3 link configuration members. Signed-off-by: Matt Carlson Reviewed-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 39 +++++++++-------------------- drivers/net/ethernet/broadcom/tg3.h | 8 ------ 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 610997cec7c9..859bd22f814b 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -1894,10 +1894,10 @@ static void tg3_phy_start(struct tg3 *tp) if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER; - phydev->speed = tp->link_config.orig_speed; - phydev->duplex = tp->link_config.orig_duplex; - phydev->autoneg = tp->link_config.orig_autoneg; - phydev->advertising = tp->link_config.orig_advertising; + phydev->speed = tp->link_config.speed; + phydev->duplex = tp->link_config.duplex; + phydev->autoneg = tp->link_config.autoneg; + phydev->advertising = tp->link_config.advertising; } phy_start(phydev); @@ -3564,10 +3564,10 @@ static int tg3_power_down_prepare(struct tg3 *tp) tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER; - tp->link_config.orig_speed = phydev->speed; - tp->link_config.orig_duplex = phydev->duplex; - tp->link_config.orig_autoneg = phydev->autoneg; - tp->link_config.orig_advertising = phydev->advertising; + tp->link_config.speed = phydev->speed; + tp->link_config.duplex = phydev->duplex; + tp->link_config.autoneg = phydev->autoneg; + tp->link_config.advertising = phydev->advertising; advertising = ADVERTISED_TP | ADVERTISED_Pause | @@ -3600,12 +3600,8 @@ static int tg3_power_down_prepare(struct tg3 *tp) } else { do_low_power = true; - if (!(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { + if (!(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER; - tp->link_config.orig_speed = tp->link_config.speed; - tp->link_config.orig_duplex = tp->link_config.duplex; - tp->link_config.orig_autoneg = tp->link_config.autoneg; - } if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES)) tg3_setup_phy(tp, 0); @@ -9260,12 +9256,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) } if (!tg3_flag(tp, USE_PHYLIB)) { - if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { + if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER; - tp->link_config.speed = tp->link_config.orig_speed; - tp->link_config.duplex = tp->link_config.orig_duplex; - tp->link_config.autoneg = tp->link_config.orig_autoneg; - } err = tg3_setup_phy(tp, 0); if (err) @@ -10614,10 +10606,6 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) tp->link_config.duplex = cmd->duplex; } - tp->link_config.orig_speed = tp->link_config.speed; - tp->link_config.orig_duplex = tp->link_config.duplex; - tp->link_config.orig_autoneg = tp->link_config.autoneg; - if (netif_running(dev)) tg3_setup_phy(tp, 1); @@ -10864,10 +10852,10 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam if (!epause->autoneg) tg3_setup_flow_control(tp, 0, 0); } else { - tp->link_config.orig_advertising &= + tp->link_config.advertising &= ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause); - tp->link_config.orig_advertising |= newadv; + tp->link_config.advertising |= newadv; } } else { int irq_sync = 0; @@ -13364,9 +13352,6 @@ static void __devinit tg3_phy_init_link_config(struct tg3 *tp) tp->link_config.autoneg = AUTONEG_ENABLE; tp->link_config.active_speed = SPEED_INVALID; tp->link_config.active_duplex = DUPLEX_INVALID; - tp->link_config.orig_speed = SPEED_INVALID; - tp->link_config.orig_duplex = DUPLEX_INVALID; - tp->link_config.orig_autoneg = AUTONEG_INVALID; } static int __devinit tg3_phy_probe(struct tg3 *tp) diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h index aea8f72c24fa..2ddd92e5f54f 100644 --- a/drivers/net/ethernet/broadcom/tg3.h +++ b/drivers/net/ethernet/broadcom/tg3.h @@ -2707,14 +2707,6 @@ struct tg3_link_config { #define AUTONEG_INVALID 0xff u16 active_speed; u32 rmt_adv; - - /* When we go in and out of low power mode we need - * to swap with this state. - */ - u16 orig_speed; - u8 orig_duplex; - u8 orig_autoneg; - u32 orig_advertising; }; struct tg3_bufmgr_config { -- GitLab From e740522e6d3a6c3014da30f65fe254bc7f6410d7 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:16 +0000 Subject: [PATCH 0707/1846] tg3: Use *_UNKNOWN ethtool definitions This patch replaces tg3's private SPEED_INVALID and DUPLEX_INVALID definitions with SPEED_UNKNOWN and DUPLEX_UNKNOWN respectively. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 40 ++++++++++++++--------------- drivers/net/ethernet/broadcom/tg3.h | 3 --- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 859bd22f814b..302c69bc58d7 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -1819,8 +1819,8 @@ static void tg3_adjust_link(struct net_device *dev) (6 << TX_LENGTHS_IPG_SHIFT) | (32 << TX_LENGTHS_SLOT_TIME_SHIFT))); - if ((phydev->link && tp->link_config.active_speed == SPEED_INVALID) || - (!phydev->link && tp->link_config.active_speed != SPEED_INVALID) || + if ((phydev->link && tp->link_config.active_speed == SPEED_UNKNOWN) || + (!phydev->link && tp->link_config.active_speed != SPEED_UNKNOWN) || phydev->speed != tp->link_config.active_speed || phydev->duplex != tp->link_config.active_duplex || oldflowctrl != tp->link_config.active_flowctrl) @@ -3813,8 +3813,8 @@ static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u16 *speed, u8 DUPLEX_HALF; break; } - *speed = SPEED_INVALID; - *duplex = DUPLEX_INVALID; + *speed = SPEED_UNKNOWN; + *duplex = DUPLEX_UNKNOWN; break; } } @@ -3906,7 +3906,7 @@ static void tg3_phy_copper_begin(struct tg3 *tp) tg3_phy_autoneg_cfg(tp, new_adv, FLOW_CTRL_TX | FLOW_CTRL_RX); - } else if (tp->link_config.speed == SPEED_INVALID) { + } else if (tp->link_config.speed == SPEED_UNKNOWN) { if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) tp->link_config.advertising &= ~(ADVERTISED_1000baseT_Half | @@ -3938,7 +3938,7 @@ static void tg3_phy_copper_begin(struct tg3 *tp) } if (tp->link_config.autoneg == AUTONEG_DISABLE && - tp->link_config.speed != SPEED_INVALID) { + tp->link_config.speed != SPEED_UNKNOWN) { u32 bmcr, orig_bmcr; tp->link_config.active_speed = tp->link_config.speed; @@ -4172,8 +4172,8 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) } current_link_up = 0; - current_speed = SPEED_INVALID; - current_duplex = DUPLEX_INVALID; + current_speed = SPEED_UNKNOWN; + current_duplex = DUPLEX_UNKNOWN; tp->phy_flags &= ~TG3_PHYFLG_MDIX_STATE; tp->link_config.rmt_adv = 0; @@ -5069,8 +5069,8 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int force_reset) LED_CTRL_LNKLED_OVERRIDE | LED_CTRL_1000MBPS_ON)); } else { - tp->link_config.active_speed = SPEED_INVALID; - tp->link_config.active_duplex = DUPLEX_INVALID; + tp->link_config.active_speed = SPEED_UNKNOWN; + tp->link_config.active_duplex = DUPLEX_UNKNOWN; tw32(MAC_LED_CTRL, (tp->led_ctrl | LED_CTRL_LNKLED_OVERRIDE | LED_CTRL_TRAFFIC_OVERRIDE)); @@ -5118,8 +5118,8 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) tg3_phy_reset(tp); current_link_up = 0; - current_speed = SPEED_INVALID; - current_duplex = DUPLEX_INVALID; + current_speed = SPEED_UNKNOWN; + current_duplex = DUPLEX_UNKNOWN; tp->link_config.rmt_adv = 0; err |= tg3_readphy(tp, MII_BMSR, &bmsr); @@ -10515,8 +10515,8 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) cmd->eth_tp_mdix = ETH_TP_MDI; } } else { - ethtool_cmd_speed_set(cmd, SPEED_INVALID); - cmd->duplex = DUPLEX_INVALID; + ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); + cmd->duplex = DUPLEX_UNKNOWN; cmd->eth_tp_mdix = ETH_TP_MDI_INVALID; } cmd->phy_address = tp->phy_addr; @@ -10598,8 +10598,8 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (cmd->autoneg == AUTONEG_ENABLE) { tp->link_config.advertising = (cmd->advertising | ADVERTISED_Autoneg); - tp->link_config.speed = SPEED_INVALID; - tp->link_config.duplex = DUPLEX_INVALID; + tp->link_config.speed = SPEED_UNKNOWN; + tp->link_config.duplex = DUPLEX_UNKNOWN; } else { tp->link_config.advertising = 0; tp->link_config.speed = speed; @@ -13347,11 +13347,11 @@ static void __devinit tg3_phy_init_link_config(struct tg3 *tp) adv |= ADVERTISED_FIBRE; tp->link_config.advertising = adv; - tp->link_config.speed = SPEED_INVALID; - tp->link_config.duplex = DUPLEX_INVALID; + tp->link_config.speed = SPEED_UNKNOWN; + tp->link_config.duplex = DUPLEX_UNKNOWN; tp->link_config.autoneg = AUTONEG_ENABLE; - tp->link_config.active_speed = SPEED_INVALID; - tp->link_config.active_duplex = DUPLEX_INVALID; + tp->link_config.active_speed = SPEED_UNKNOWN; + tp->link_config.active_duplex = DUPLEX_UNKNOWN; } static int __devinit tg3_phy_probe(struct tg3 *tp) diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h index 2ddd92e5f54f..300c6e55a411 100644 --- a/drivers/net/ethernet/broadcom/tg3.h +++ b/drivers/net/ethernet/broadcom/tg3.h @@ -2702,9 +2702,6 @@ struct tg3_link_config { u8 active_flowctrl; u8 active_duplex; -#define SPEED_INVALID 0xffff -#define DUPLEX_INVALID 0xff -#define AUTONEG_INVALID 0xff u16 active_speed; u32 rmt_adv; }; -- GitLab From 9e056c0320fafc03dc170772d8562e3142ed1778 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 13 Feb 2012 15:20:17 +0000 Subject: [PATCH 0708/1846] tg3: Update copyright This patch updates the copyright dates in the tg3 driver. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 2 +- drivers/net/ethernet/broadcom/tg3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 302c69bc58d7..d604664fdb42 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -4,7 +4,7 @@ * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com) * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com) * Copyright (C) 2004 Sun Microsystems Inc. - * Copyright (C) 2005-2011 Broadcom Corporation. + * Copyright (C) 2005-2012 Broadcom Corporation. * * Firmware is: * Derived from proprietary unpublished source code, diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h index 300c6e55a411..22cbe74b3d11 100644 --- a/drivers/net/ethernet/broadcom/tg3.h +++ b/drivers/net/ethernet/broadcom/tg3.h @@ -4,7 +4,7 @@ * Copyright (C) 2001, 2002, 2003, 2004 David S. Miller (davem@redhat.com) * Copyright (C) 2001 Jeff Garzik (jgarzik@pobox.com) * Copyright (C) 2004 Sun Microsystems Inc. - * Copyright (C) 2007-2011 Broadcom Corporation. + * Copyright (C) 2007-2012 Broadcom Corporation. */ #ifndef _T3_H -- GitLab From 58a30d6a3c2397f18a826f401e0f0e61e8868f19 Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:37:16 +0000 Subject: [PATCH 0709/1846] mlx4_core: fix buffer overrun When passing MLX4_UC_STEER=1 it was translated to value 2 after mlx4_QP_ATTACH_wrapper. Therefore in new_steering_entry() unicast steer entries were added to index 2 of array of size 2. Fixing this bug by shift right to one position. Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index dcd819bfb2f0..1420dbc947c2 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c @@ -2538,7 +2538,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, int attach = vhcr->op_modifier; int block_loopback = vhcr->in_modifier >> 31; u8 steer_type_mask = 2; - enum mlx4_steer_type type = gid[7] & steer_type_mask; + enum mlx4_steer_type type = (gid[7] & steer_type_mask) >> 1; qpn = vhcr->in_modifier & 0xffffff; err = get_res(dev, slave, qpn, RES_QP, &rqp); -- GitLab From 0ee9f1dd7b910f712aa56133973d165d42a81707 Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:37:22 +0000 Subject: [PATCH 0710/1846] mlx4: fix QP tree trashing When adding new unicast steer entry, before moving qp to state ready, actually before calling mlx4_RST2INIT_QP_wrapper(), there were added a lot of entries with local_qpn=0 into radix tree. This fact impacted the get_res() function and proper functioning of resource tracker in addition to adding trash entries into radix tree. Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 1420dbc947c2..629cc3018746 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c @@ -374,6 +374,7 @@ static struct res_common *alloc_qp_tr(int id) ret->com.res_id = id; ret->com.state = RES_QP_RESERVED; + ret->local_qpn = id; INIT_LIST_HEAD(&ret->mcg_list); spin_lock_init(&ret->mcg_spl); -- GitLab From 45b5136551e42a1c2bca8edad8e6f3247ca5a729 Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:37:41 +0000 Subject: [PATCH 0711/1846] mlx4: remove unused field high_prios Remove unnecessary field high_prios from mlx4_steer struct and initialization Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/main.c | 4 +--- drivers/net/ethernet/mellanox/mlx4/mlx4.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 678558b502fc..0809b7c3905c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -1543,13 +1543,11 @@ static int mlx4_init_steering(struct mlx4_dev *dev) if (!priv->steer) return -ENOMEM; - for (i = 0; i < num_entries; i++) { + for (i = 0; i < num_entries; i++) for (j = 0; j < MLX4_NUM_STEERS; j++) { INIT_LIST_HEAD(&priv->steer[i].promisc_qps[j]); INIT_LIST_HEAD(&priv->steer[i].steer_entries[j]); } - INIT_LIST_HEAD(&priv->steer[i].high_prios); - } return 0; } diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index c92269f8c057..276c7f72bd83 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h @@ -703,7 +703,6 @@ struct mlx4_msix_ctl { struct mlx4_steer { struct list_head promisc_qps[MLX4_NUM_STEERS]; struct list_head steer_entries[MLX4_NUM_STEERS]; - struct list_head high_prios; }; struct mlx4_priv { -- GitLab From deb8b3e8494f63b05ce144a52e8c0b3f80789fed Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:37:46 +0000 Subject: [PATCH 0712/1846] mlx4: remove unnecessary variables and arguments mlx4_qp_attach/detach_common() don't use hash variable, move it to find_entry() static find_entry() in mcg.c doesn't use steer argument Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/mcg.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c index ca574d850b39..da63874a5005 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mcg.c +++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c @@ -562,14 +562,14 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, */ static int find_entry(struct mlx4_dev *dev, u8 port, u8 *gid, enum mlx4_protocol prot, - enum mlx4_steer_type steer, struct mlx4_cmd_mailbox *mgm_mailbox, - u16 *hash, int *prev, int *index) + int *prev, int *index) { struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm = mgm_mailbox->buf; u8 *mgid; int err; + u16 hash; u8 op_mod = (prot == MLX4_PROT_ETH) ? !!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) : 0; @@ -580,15 +580,15 @@ static int find_entry(struct mlx4_dev *dev, u8 port, memcpy(mgid, gid, 16); - err = mlx4_GID_HASH(dev, mailbox, hash, op_mod); + err = mlx4_GID_HASH(dev, mailbox, &hash, op_mod); mlx4_free_cmd_mailbox(dev, mailbox); if (err) return err; if (0) - mlx4_dbg(dev, "Hash for %pI6 is %04x\n", gid, *hash); + mlx4_dbg(dev, "Hash for %pI6 is %04x\n", gid, hash); - *index = *hash; + *index = hash; *prev = -1; do { @@ -597,7 +597,7 @@ static int find_entry(struct mlx4_dev *dev, u8 port, return err; if (!(be32_to_cpu(mgm->members_count) & 0xffffff)) { - if (*index != *hash) { + if (*index != hash) { mlx4_err(dev, "Found zero MGID in AMGM.\n"); err = -EINVAL; } @@ -624,7 +624,6 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm; u32 members_count; - u16 hash; int index, prev; int link = 0; int i; @@ -638,8 +637,8 @@ int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], mgm = mailbox->buf; mutex_lock(&priv->mcg_table.mutex); - err = find_entry(dev, port, gid, prot, steer, - mailbox, &hash, &prev, &index); + err = find_entry(dev, port, gid, prot, + mailbox, &prev, &index); if (err) goto out; @@ -733,7 +732,6 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm; u32 members_count; - u16 hash; int prev, index; int i, loc; int err; @@ -747,8 +745,8 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], mutex_lock(&priv->mcg_table.mutex); - err = find_entry(dev, port, gid, prot, steer, - mailbox, &hash, &prev, &index); + err = find_entry(dev, port, gid, prot, + mailbox, &prev, &index); if (err) goto out; -- GitLab From de9b43dbb8a81fb58ed092351aa8e35e52368199 Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:38:12 +0000 Subject: [PATCH 0713/1846] mlx4: remove redundant adding of steering type to gid mlx4_uc_steer_add/release() should not add MLX4_UC_STEER flag to gid. It is added in mlx4_unicast_attach/detach(). Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/port.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index f44ae555bf43..575839dba8a2 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -87,7 +87,6 @@ static int mlx4_uc_steer_add(struct mlx4_dev *dev, u8 port, u64 mac, int *qpn) mac = cpu_to_be64(mac << 16); memcpy(&gid[10], &mac, ETH_ALEN); gid[5] = port; - gid[7] = MLX4_UC_STEER << 1; err = mlx4_unicast_attach(dev, &qp, gid, 0, MLX4_PROT_ETH); if (err) @@ -107,7 +106,6 @@ static void mlx4_uc_steer_release(struct mlx4_dev *dev, u8 port, mac = cpu_to_be64(mac << 16); memcpy(&gid[10], &mac, ETH_ALEN); gid[5] = port; - gid[7] = MLX4_UC_STEER << 1; mlx4_unicast_detach(dev, &qp, gid, MLX4_PROT_ETH); } -- GitLab From f1f75f0e2bb94674da540be9c488fe596dd55881 Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:38:33 +0000 Subject: [PATCH 0714/1846] mlx4: attach multicast with correct flag mlx4_multicast_attach/detach() should use always MLX4_MC_STEER flag Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/mcg.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c index da63874a5005..4799e824052f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mcg.c +++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c @@ -870,44 +870,36 @@ static int mlx4_QP_ATTACH(struct mlx4_dev *dev, struct mlx4_qp *qp, int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], int block_mcast_loopback, enum mlx4_protocol prot) { - enum mlx4_steer_type steer; - - steer = (is_valid_ether_addr(&gid[10])) ? MLX4_UC_STEER : MLX4_MC_STEER; - if (prot == MLX4_PROT_ETH && !(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER)) return 0; if (prot == MLX4_PROT_ETH) - gid[7] |= (steer << 1); + gid[7] |= (MLX4_MC_STEER << 1); if (mlx4_is_mfunc(dev)) return mlx4_QP_ATTACH(dev, qp, gid, 1, block_mcast_loopback, prot); return mlx4_qp_attach_common(dev, qp, gid, block_mcast_loopback, - prot, steer); + prot, MLX4_MC_STEER); } EXPORT_SYMBOL_GPL(mlx4_multicast_attach); int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], enum mlx4_protocol prot) { - enum mlx4_steer_type steer; - - steer = (is_valid_ether_addr(&gid[10])) ? MLX4_UC_STEER : MLX4_MC_STEER; - if (prot == MLX4_PROT_ETH && !(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER)) return 0; if (prot == MLX4_PROT_ETH) - gid[7] |= (steer << 1); + gid[7] |= (MLX4_MC_STEER << 1); if (mlx4_is_mfunc(dev)) return mlx4_QP_ATTACH(dev, qp, gid, 0, 0, prot); - return mlx4_qp_detach_common(dev, qp, gid, prot, steer); + return mlx4_qp_detach_common(dev, qp, gid, prot, MLX4_MC_STEER); } EXPORT_SYMBOL_GPL(mlx4_multicast_detach); -- GitLab From eb40d89276705a35c9a2e05793ae63411ae357eb Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Tue, 14 Feb 2012 06:38:38 +0000 Subject: [PATCH 0715/1846] mlx4: add unicast steering entries to resource_tracker Add unicast steering entries to resource tracker. Do qp_detach also for these entries when VF doesn't shut down gracefully. Otherwise there is leakage of these resources, since they are not tracked. Signed-off-by: Eugenia Emantayev Reviewed-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- .../ethernet/mellanox/mlx4/resource_tracker.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 629cc3018746..bfdb7af19e49 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c @@ -73,6 +73,7 @@ struct res_gid { struct list_head list; u8 gid[16]; enum mlx4_protocol prot; + enum mlx4_steer_type steer; }; enum res_qp_states { @@ -2480,7 +2481,8 @@ static struct res_gid *find_gid(struct mlx4_dev *dev, int slave, } static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, - u8 *gid, enum mlx4_protocol prot) + u8 *gid, enum mlx4_protocol prot, + enum mlx4_steer_type steer) { struct res_gid *res; int err; @@ -2496,6 +2498,7 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, } else { memcpy(res->gid, gid, 16); res->prot = prot; + res->steer = steer; list_add_tail(&res->list, &rqp->mcg_list); err = 0; } @@ -2505,14 +2508,15 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, } static int rem_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, - u8 *gid, enum mlx4_protocol prot) + u8 *gid, enum mlx4_protocol prot, + enum mlx4_steer_type steer) { struct res_gid *res; int err; spin_lock_irq(&rqp->mcg_spl); res = find_gid(dev, slave, rqp, gid); - if (!res || res->prot != prot) + if (!res || res->prot != prot || res->steer != steer) err = -EINVAL; else { list_del(&res->list); @@ -2548,7 +2552,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, qp.qpn = qpn; if (attach) { - err = add_mcg_res(dev, slave, rqp, gid, prot); + err = add_mcg_res(dev, slave, rqp, gid, prot, type); if (err) goto ex_put; @@ -2557,7 +2561,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, if (err) goto ex_rem; } else { - err = rem_mcg_res(dev, slave, rqp, gid, prot); + err = rem_mcg_res(dev, slave, rqp, gid, prot, type); if (err) goto ex_put; err = mlx4_qp_detach_common(dev, &qp, gid, prot, type); @@ -2568,7 +2572,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ex_rem: /* ignore error return below, already in error */ - err1 = rem_mcg_res(dev, slave, rqp, gid, prot); + err1 = rem_mcg_res(dev, slave, rqp, gid, prot, type); ex_put: put_res(dev, slave, qpn, RES_QP); @@ -2607,7 +2611,7 @@ static void detach_qp(struct mlx4_dev *dev, int slave, struct res_qp *rqp) list_for_each_entry_safe(rgid, tmp, &rqp->mcg_list, list) { qp.qpn = rqp->local_qpn; err = mlx4_qp_detach_common(dev, &qp, rgid->gid, rgid->prot, - MLX4_MC_STEER); + rgid->steer); list_del(&rgid->list); kfree(rgid); } -- GitLab From 059625e757754459d8adb370e3d751abdd51723b Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 21 Dec 2011 22:36:27 +0200 Subject: [PATCH 0716/1846] wl1251: fix sparse warning The wl1251 driver was generating the following warning: drivers/net/wireless/wl1251/boot.c:467:21: warning: incorrect type in assignment (different base types) drivers/net/wireless/wl1251/boot.c:467:21: expected unsigned int [unsigned] [assigned] [usertype] val drivers/net/wireless/wl1251/boot.c:467:21: got restricted __le32 [usertype] Fix this by removing one cpu_to_le32() call in the wrong place. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl1251/boot.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/wl1251/boot.c b/drivers/net/wireless/wl1251/boot.c index d729daf8e841..a2e5241382da 100644 --- a/drivers/net/wireless/wl1251/boot.c +++ b/drivers/net/wireless/wl1251/boot.c @@ -464,8 +464,6 @@ static int wl1251_boot_upload_nvs(struct wl1251 *wl) val = (nvs_ptr[0] | (nvs_ptr[1] << 8) | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); - val = cpu_to_le32(val); - wl1251_debug(DEBUG_BOOT, "nvs write table 0x%x: 0x%x", nvs_start, val); -- GitLab From ac9e2d9afa90ecb7ee1b419cce6969f31a138f77 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 21 Dec 2011 22:36:28 +0200 Subject: [PATCH 0717/1846] wl1251: convert 32-bit values to le32 before writing to the chip The 32-bit values were not converted before writing them to the chip. Change the wl1251_read32() and wl1251_write32() so that they always read and write le32 values and convert to and from the CPU endianess. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl1251/io.h | 9 ++++----- drivers/net/wireless/wl1251/wl1251.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/wl1251/io.h b/drivers/net/wireless/wl1251/io.h index c545e9d5f512..d382877c34cc 100644 --- a/drivers/net/wireless/wl1251/io.h +++ b/drivers/net/wireless/wl1251/io.h @@ -36,16 +36,15 @@ static inline u32 wl1251_read32(struct wl1251 *wl, int addr) { - u32 response; - - wl->if_ops->read(wl, addr, &response, sizeof(u32)); + wl->if_ops->read(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32)); - return response; + return le32_to_cpu(wl->buffer_32); } static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) { - wl->if_ops->write(wl, addr, &val, sizeof(u32)); + wl->buffer_32 = cpu_to_le32(val); + wl->if_ops->write(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32)); } static inline u32 wl1251_read_elp(struct wl1251 *wl, int addr) diff --git a/drivers/net/wireless/wl1251/wl1251.h b/drivers/net/wireless/wl1251/wl1251.h index a77f1bbbed0a..9d8f5816c6f9 100644 --- a/drivers/net/wireless/wl1251/wl1251.h +++ b/drivers/net/wireless/wl1251/wl1251.h @@ -380,7 +380,7 @@ struct wl1251 { struct wl1251_stats stats; struct wl1251_debugfs debugfs; - u32 buffer_32; + __le32 buffer_32; u32 buffer_cmd; u8 buffer_busyword[WL1251_BUSY_WORD_LEN]; struct wl1251_rx_descriptor *rx_descriptor; -- GitLab From ebff1bae9445af019e7e3c5b62964ec99b5a8250 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 21 Dec 2011 22:36:29 +0200 Subject: [PATCH 0718/1846] wl1251: enable sparse endianess check by default Following the good example of the Intel (and more recently Atheros) drivers, enable endianess check by default when running sparse. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl1251/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/wl1251/Makefile b/drivers/net/wireless/wl1251/Makefile index 58b4f935a3f6..a5c6328b5f72 100644 --- a/drivers/net/wireless/wl1251/Makefile +++ b/drivers/net/wireless/wl1251/Makefile @@ -6,3 +6,5 @@ wl1251_sdio-objs += sdio.o obj-$(CONFIG_WL1251) += wl1251.o obj-$(CONFIG_WL1251_SPI) += wl1251_spi.o obj-$(CONFIG_WL1251_SDIO) += wl1251_sdio.o + +ccflags-y += -D__CHECK_ENDIAN__ -- GitLab From 15944aef29b6a3d96c52f3140c08b5a9d5fda0e9 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 21 Dec 2011 21:52:31 +0200 Subject: [PATCH 0719/1846] wl12xx: enable sparse endianess check by default Following the good example of the Intel (and more recently Atheros) drivers, enable endianess check by default when running sparse. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile index fe67262ba19f..98f289c907a9 100644 --- a/drivers/net/wireless/wl12xx/Makefile +++ b/drivers/net/wireless/wl12xx/Makefile @@ -11,3 +11,5 @@ obj-$(CONFIG_WL12XX_SDIO) += wl12xx_sdio.o # small builtin driver bit obj-$(CONFIG_WL12XX_PLATFORM_DATA) += wl12xx_platform_data.o + +ccflags-y += -D__CHECK_ENDIAN__ -- GitLab From 9e0dc890ce23e2b28ce906bb8f466ca66f420911 Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Wed, 11 Jan 2012 14:22:42 +0100 Subject: [PATCH 0720/1846] wl12xx: Make sure HW is available in sched scan ops The sched_scan_(stop|start) ops fails to check for WL1271_STATE_OFF. This can lead to a race where the driver tries to access the HW while it's off. Fix this by checking for WL1271_STATE_OFF before accessing the HW. Signed-off-by: Pontus Fuchs Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f8748cedbae1..f2a958c9537a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3108,6 +3108,11 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, mutex_lock(&wl->mutex); + if (wl->state == WL1271_STATE_OFF) { + ret = -EAGAIN; + goto out; + } + ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; @@ -3139,6 +3144,9 @@ static void wl1271_op_sched_scan_stop(struct ieee80211_hw *hw, mutex_lock(&wl->mutex); + if (wl->state == WL1271_STATE_OFF) + goto out; + ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; -- GitLab From f3df1331f25f782e838a3ecb72cec86b539ac02f Mon Sep 17 00:00:00 2001 From: Ido Yariv Date: Wed, 11 Jan 2012 09:42:39 +0200 Subject: [PATCH 0721/1846] wl12xx: Acquire lock before stopping plt __wl1271_plt_stop is called from both wl1271_plt_stop and wl1271_unregister_hw. While wl1271_plt_stop acquires a mutex, wl1271_unregister_hw does not. Fix this by calling wl1271_plt_stop instead of __wl1271_plt_stop from wl1271_unregister_hw. Signed-off-by: Ido Yariv Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f2a958c9537a..ac6866469073 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1391,13 +1391,15 @@ int wl1271_plt_start(struct wl1271 *wl) return ret; } -static int __wl1271_plt_stop(struct wl1271 *wl) +int wl1271_plt_stop(struct wl1271 *wl) { int ret = 0; wl1271_notice("power down"); + mutex_lock(&wl->mutex); if (wl->state != WL1271_STATE_PLT) { + mutex_unlock(&wl->mutex); wl1271_error("cannot power down because not in PLT " "state: %d", wl->state); ret = -EBUSY; @@ -1410,25 +1412,15 @@ static int __wl1271_plt_stop(struct wl1271 *wl) wl->rx_counter = 0; mutex_unlock(&wl->mutex); + wl1271_disable_interrupts(wl); wl1271_flush_deferred_work(wl); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->recovery_work); - mutex_lock(&wl->mutex); out: return ret; } -int wl1271_plt_stop(struct wl1271 *wl) -{ - int ret; - - mutex_lock(&wl->mutex); - ret = __wl1271_plt_stop(wl); - mutex_unlock(&wl->mutex); - return ret; -} - static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct wl1271 *wl = hw->priv; @@ -4881,7 +4873,7 @@ static int wl1271_register_hw(struct wl1271 *wl) static void wl1271_unregister_hw(struct wl1271 *wl) { if (wl->state == WL1271_STATE_PLT) - __wl1271_plt_stop(wl); + wl1271_plt_stop(wl); unregister_netdevice_notifier(&wl1271_dev_notifier); ieee80211_unregister_hw(wl->hw); -- GitLab From a454969ede024a209e6a755d5f7a928ab81ed00c Mon Sep 17 00:00:00 2001 From: Ido Yariv Date: Wed, 11 Jan 2012 09:42:40 +0200 Subject: [PATCH 0722/1846] wl12xx: Power off after flushing work When stopping plt, the chip is powered off before all current work items are flushed and interrupts are disabled. This might introduce a race in which the driver tries to communicate with a powered off chip. Fix this by powering off the device only after interrupts are disabled and all work items are flushed. Signed-off-by: Ido Yariv Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index ac6866469073..9e9fb3fb8f01 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1406,8 +1406,6 @@ int wl1271_plt_stop(struct wl1271 *wl) goto out; } - wl1271_power_off(wl); - wl->state = WL1271_STATE_OFF; wl->rx_counter = 0; @@ -1417,6 +1415,11 @@ int wl1271_plt_stop(struct wl1271 *wl) wl1271_flush_deferred_work(wl); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->recovery_work); + + mutex_lock(&wl->mutex); + wl1271_power_off(wl); + mutex_unlock(&wl->mutex); + out: return ret; } -- GitLab From 46b0cc9ffce356fbcb2135219a3ed8500714a9e4 Mon Sep 17 00:00:00 2001 From: Ido Yariv Date: Wed, 11 Jan 2012 09:42:41 +0200 Subject: [PATCH 0723/1846] wl12xx: Fix potential interrupt storm The interrupt threaded handler exits immediately if the driver's state is WL1271_STATE_OFF. As a result, the interrupt status is not read. If the interrupt is level triggered, it will be fired again. Fix this by disabling interrupts before setting the state to OFF. Signed-off-by: Ido Yariv Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 9e9fb3fb8f01..3a1636b68cd2 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1397,9 +1397,23 @@ int wl1271_plt_stop(struct wl1271 *wl) wl1271_notice("power down"); + /* + * Interrupts must be disabled before setting the state to OFF. + * Otherwise, the interrupt handler might be called and exit without + * reading the interrupt status. + */ + wl1271_disable_interrupts(wl); mutex_lock(&wl->mutex); if (wl->state != WL1271_STATE_PLT) { mutex_unlock(&wl->mutex); + + /* + * This will not necessarily enable interrupts as interrupts + * may have been disabled when op_stop was called. It will, + * however, balance the above call to disable_interrupts(). + */ + wl1271_enable_interrupts(wl); + wl1271_error("cannot power down because not in PLT " "state: %d", wl->state); ret = -EBUSY; @@ -1411,7 +1425,6 @@ int wl1271_plt_stop(struct wl1271 *wl) mutex_unlock(&wl->mutex); - wl1271_disable_interrupts(wl); wl1271_flush_deferred_work(wl); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->recovery_work); @@ -1773,11 +1786,25 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); + /* + * Interrupts must be disabled before setting the state to OFF. + * Otherwise, the interrupt handler might be called and exit without + * reading the interrupt status. + */ + wl1271_disable_interrupts(wl); mutex_lock(&wl->mutex); if (wl->state == WL1271_STATE_OFF) { mutex_unlock(&wl->mutex); + + /* + * This will not necessarily enable interrupts as interrupts + * may have been disabled when op_stop was called. It will, + * however, balance the above call to disable_interrupts(). + */ + wl1271_enable_interrupts(wl); return; } + /* * this must be before the cancel_work calls below, so that the work * functions don't perform further work. @@ -1789,7 +1816,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) list_del(&wl->list); 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); -- GitLab From f6fbeccd3e513c23de9cd8562f2b2e78d4d17912 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 11 Jan 2012 09:42:42 +0200 Subject: [PATCH 0724/1846] wl12xx: cancel delayed elp work and clear flags when stopping PLT In some cases a race condition can happen if we don't cancel any pending ELP work before stopping PLT. With this commit we cancel ELP work and clear the wl->flags bitmask. Also clean up the wl elements after powering off. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3a1636b68cd2..3587afcd6469 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1420,17 +1420,18 @@ int wl1271_plt_stop(struct wl1271 *wl) goto out; } - wl->state = WL1271_STATE_OFF; - wl->rx_counter = 0; - mutex_unlock(&wl->mutex); wl1271_flush_deferred_work(wl); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->recovery_work); + cancel_delayed_work_sync(&wl->elp_work); mutex_lock(&wl->mutex); wl1271_power_off(wl); + wl->flags = 0; + wl->state = WL1271_STATE_OFF; + wl->rx_counter = 0; mutex_unlock(&wl->mutex); out: -- GitLab From 0becb14ab42c2435402437a9dbc279599f6af8fb Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 12 Jan 2012 14:45:34 +0200 Subject: [PATCH 0725/1846] wl12xx: move partition table definition to io.c Up till now we only needed to access the partition table in boot.c. But to add support for reading the MAC address from the FUSE in testmode, we will have to change the partition in testmode.c. Thus, we move the partition table to io.c and export it via io.h. It makes more sense to have it in the io part anyway. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/boot.c | 73 +++--------------------------- drivers/net/wireless/wl12xx/io.c | 59 ++++++++++++++++++++++++ drivers/net/wireless/wl12xx/io.h | 2 + 3 files changed, 68 insertions(+), 66 deletions(-) diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index 8f9cf5a816ea..84d295126edf 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -33,65 +33,6 @@ #include "event.h" #include "rx.h" -static struct wl1271_partition_set part_table[PART_TABLE_LEN] = { - [PART_DOWN] = { - .mem = { - .start = 0x00000000, - .size = 0x000177c0 - }, - .reg = { - .start = REGISTERS_BASE, - .size = 0x00008800 - }, - .mem2 = { - .start = 0x00000000, - .size = 0x00000000 - }, - .mem3 = { - .start = 0x00000000, - .size = 0x00000000 - }, - }, - - [PART_WORK] = { - .mem = { - .start = 0x00040000, - .size = 0x00014fc0 - }, - .reg = { - .start = REGISTERS_BASE, - .size = 0x0000a000 - }, - .mem2 = { - .start = 0x003004f8, - .size = 0x00000004 - }, - .mem3 = { - .start = 0x00040404, - .size = 0x00000000 - }, - }, - - [PART_DRPW] = { - .mem = { - .start = 0x00040000, - .size = 0x00014fc0 - }, - .reg = { - .start = DRPW_BASE, - .size = 0x00006000 - }, - .mem2 = { - .start = 0x00000000, - .size = 0x00000000 - }, - .mem3 = { - .start = 0x00000000, - .size = 0x00000000 - } - } -}; - static void wl1271_boot_set_ecpu_ctrl(struct wl1271 *wl, u32 flag) { u32 cpu_ctrl; @@ -181,13 +122,13 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf, return -ENOMEM; } - memcpy(&partition, &part_table[PART_DOWN], sizeof(partition)); + memcpy(&partition, &wl12xx_part_table[PART_DOWN], sizeof(partition)); partition.mem.start = dest; wl1271_set_partition(wl, &partition); /* 10.1 set partition limit and chunk num */ chunk_num = 0; - partition_limit = part_table[PART_DOWN].mem.size; + partition_limit = wl12xx_part_table[PART_DOWN].mem.size; while (chunk_num < fw_data_len / CHUNK_SIZE) { /* 10.2 update partition, if needed */ @@ -195,7 +136,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf, if (addr > partition_limit) { addr = dest + chunk_num * CHUNK_SIZE; partition_limit = chunk_num * CHUNK_SIZE + - part_table[PART_DOWN].mem.size; + wl12xx_part_table[PART_DOWN].mem.size; partition.mem.start = addr; wl1271_set_partition(wl, &partition); } @@ -383,7 +324,7 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) nvs_len -= nvs_ptr - (u8 *)wl->nvs; /* Now we must set the partition correctly */ - wl1271_set_partition(wl, &part_table[PART_WORK]); + wl1271_set_partition(wl, &wl12xx_part_table[PART_WORK]); /* Copy the NVS tables to a new block to ensure alignment */ nvs_aligned = kmemdup(nvs_ptr, nvs_len, GFP_KERNEL); @@ -492,7 +433,7 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl) wl->event_box_addr = wl1271_read32(wl, REG_EVENT_MAILBOX_PTR); /* set the working partition to its "running" mode offset */ - wl1271_set_partition(wl, &part_table[PART_WORK]); + wl1271_set_partition(wl, &wl12xx_part_table[PART_WORK]); wl1271_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x", wl->cmd_box_addr, wl->event_box_addr); @@ -769,7 +710,7 @@ int wl1271_load_firmware(struct wl1271 *wl) wl1271_write32(wl, WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL); udelay(500); - wl1271_set_partition(wl, &part_table[PART_DRPW]); + wl1271_set_partition(wl, &wl12xx_part_table[PART_DRPW]); /* Read-modify-write DRPW_SCRATCH_START register (see next state) to be used by DRPw FW. The RTRIM value will be added by the FW @@ -788,7 +729,7 @@ int wl1271_load_firmware(struct wl1271 *wl) wl1271_write32(wl, DRPW_SCRATCH_START, clk); - wl1271_set_partition(wl, &part_table[PART_WORK]); + wl1271_set_partition(wl, &wl12xx_part_table[PART_WORK]); /* Disable interrupts */ wl1271_write32(wl, ACX_REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL); diff --git a/drivers/net/wireless/wl12xx/io.c b/drivers/net/wireless/wl12xx/io.c index 079ad380e8ff..c574a3b31e31 100644 --- a/drivers/net/wireless/wl12xx/io.c +++ b/drivers/net/wireless/wl12xx/io.c @@ -45,6 +45,65 @@ #define OCP_STATUS_REQ_FAILED 0x20000 #define OCP_STATUS_RESP_ERROR 0x30000 +struct wl1271_partition_set wl12xx_part_table[PART_TABLE_LEN] = { + [PART_DOWN] = { + .mem = { + .start = 0x00000000, + .size = 0x000177c0 + }, + .reg = { + .start = REGISTERS_BASE, + .size = 0x00008800 + }, + .mem2 = { + .start = 0x00000000, + .size = 0x00000000 + }, + .mem3 = { + .start = 0x00000000, + .size = 0x00000000 + }, + }, + + [PART_WORK] = { + .mem = { + .start = 0x00040000, + .size = 0x00014fc0 + }, + .reg = { + .start = REGISTERS_BASE, + .size = 0x0000a000 + }, + .mem2 = { + .start = 0x003004f8, + .size = 0x00000004 + }, + .mem3 = { + .start = 0x00040404, + .size = 0x00000000 + }, + }, + + [PART_DRPW] = { + .mem = { + .start = 0x00040000, + .size = 0x00014fc0 + }, + .reg = { + .start = DRPW_BASE, + .size = 0x00006000 + }, + .mem2 = { + .start = 0x00000000, + .size = 0x00000000 + }, + .mem3 = { + .start = 0x00000000, + .size = 0x00000000 + } + } +}; + bool wl1271_set_block_size(struct wl1271 *wl) { if (wl->if_ops->set_block_size) { diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h index d398cbcea986..4fb3dab8c3b2 100644 --- a/drivers/net/wireless/wl12xx/io.h +++ b/drivers/net/wireless/wl12xx/io.h @@ -43,6 +43,8 @@ #define HW_ACCESS_PRAM_MAX_RANGE 0x3c000 +extern struct wl1271_partition_set wl12xx_part_table[PART_TABLE_LEN]; + struct wl1271; void wl1271_disable_interrupts(struct wl1271 *wl); -- GitLab From 30c5dbd1ee191dca1c04c70df0ba1adf0a9769c3 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 18 Jan 2012 14:53:22 +0200 Subject: [PATCH 0726/1846] wl12xx: read chip ID and HW PG version during probe In order to read the MAC addresses from the fuse ROM, we need to know the chip ID and the HW PG version. We need to know the MAC address during probe, because that's when we register our HW with mac80211. To prepare for that, this patch reads the chip ID and HW PG version during probe instead of doing it at boot time. We power the chip on briefly in order to do that. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/boot.c | 15 -------- drivers/net/wireless/wl12xx/debug.h | 1 + drivers/net/wireless/wl12xx/main.c | 59 ++++++++++++++++++++++------- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index 84d295126edf..599919e2a60d 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -488,19 +488,6 @@ static int wl1271_boot_write_irq_polarity(struct wl1271 *wl) return 0; } -static void wl1271_boot_hw_version(struct wl1271 *wl) -{ - u32 fuse; - - if (wl->chip.id == CHIP_ID_1283_PG20) - fuse = wl1271_top_reg_read(wl, WL128X_REG_FUSE_DATA_2_1); - else - fuse = wl1271_top_reg_read(wl, WL127X_REG_FUSE_DATA_2_1); - fuse = (fuse & PG_VER_MASK) >> PG_VER_OFFSET; - - wl->hw_pg_ver = (s8)fuse; -} - static int wl128x_switch_tcxo_to_fref(struct wl1271 *wl) { u16 spare_reg; @@ -694,8 +681,6 @@ int wl1271_load_firmware(struct wl1271 *wl) u32 tmp, clk; int selected_clock = -1; - wl1271_boot_hw_version(wl); - if (wl->chip.id == CHIP_ID_1283_PG20) { ret = wl128x_boot_clk(wl, &selected_clock); if (ret < 0) diff --git a/drivers/net/wireless/wl12xx/debug.h b/drivers/net/wireless/wl12xx/debug.h index b85fd8c41e8f..ec0fdc25b280 100644 --- a/drivers/net/wireless/wl12xx/debug.h +++ b/drivers/net/wireless/wl12xx/debug.h @@ -51,6 +51,7 @@ enum { DEBUG_FILTERS = BIT(15), DEBUG_ADHOC = BIT(16), DEBUG_AP = BIT(17), + DEBUG_PROBE = BIT(18), DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP), DEBUG_ALL = ~0, }; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3587afcd6469..a41af84f649d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1232,10 +1232,9 @@ static int wl1271_setup(struct wl1271 *wl) return 0; } -static int wl1271_chip_wakeup(struct wl1271 *wl) +static int wl12xx_set_power_on(struct wl1271 *wl) { - struct wl1271_partition_set partition; - int ret = 0; + int ret; msleep(WL1271_PRE_POWER_ON_SLEEP); ret = wl1271_power_on(wl); @@ -1245,20 +1244,22 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) wl1271_io_reset(wl); wl1271_io_init(wl); - /* 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); + wl1271_set_partition(wl, &wl12xx_part_table[PART_DOWN]); /* ELP module wake up */ wl1271_fw_wakeup(wl); - /* whal_FwCtrl_BootSm() */ +out: + return ret; +} - /* 0. read chip id from CHIP_ID */ - wl->chip.id = wl1271_read32(wl, CHIP_ID_B); +static int wl1271_chip_wakeup(struct wl1271 *wl) +{ + int ret = 0; + + ret = wl12xx_set_power_on(wl); + if (ret < 0) + goto out; /* * For wl127x based devices we could use the default block @@ -4858,6 +4859,29 @@ static struct bin_attribute fwlog_attr = { .read = wl1271_sysfs_read_fwlog, }; +static int wl12xx_get_hw_info(struct wl1271 *wl) +{ + int ret; + u32 die_info; + + ret = wl12xx_set_power_on(wl); + if (ret < 0) + goto out; + + wl->chip.id = wl1271_read32(wl, CHIP_ID_B); + + if (wl->chip.id == CHIP_ID_1283_PG20) + die_info = wl1271_top_reg_read(wl, WL128X_REG_FUSE_DATA_2_1); + else + die_info = wl1271_top_reg_read(wl, WL127X_REG_FUSE_DATA_2_1); + + wl->hw_pg_ver = (s8) (die_info & PG_VER_MASK) >> PG_VER_OFFSET; + + wl1271_power_off(wl); +out: + return ret; +} + static int wl1271_register_hw(struct wl1271 *wl) { int ret; @@ -4865,6 +4889,12 @@ static int wl1271_register_hw(struct wl1271 *wl) if (wl->mac80211_registered) return 0; + ret = wl12xx_get_hw_info(wl); + if (ret < 0) { + wl1271_error("couldn't get hw info"); + goto out; + } + ret = wl1271_fetch_nvs(wl); if (ret == 0) { /* NOTE: The wl->nvs->nvs element must be first, in @@ -4886,7 +4916,7 @@ static int wl1271_register_hw(struct wl1271 *wl) ret = ieee80211_register_hw(wl->hw); if (ret < 0) { wl1271_error("unable to register mac80211 hw: %d", ret); - return ret; + goto out; } wl->mac80211_registered = true; @@ -4897,7 +4927,8 @@ static int wl1271_register_hw(struct wl1271 *wl) wl1271_notice("loaded"); - return 0; +out: + return ret; } static void wl1271_unregister_hw(struct wl1271 *wl) -- GitLab From 5e037e74802a10a71dddbb05585753b2fcbd8ad7 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 23 Dec 2011 09:32:17 +0200 Subject: [PATCH 0727/1846] wl12xx: use two MAC addresses based on the NVS or from fuse ROM Add support for two MAC addresses. If the NVS has a valid MAC address, that takes precedence and we use two sequential address starting from the one specified. If the NVS doesn't contain a valid MAC address (ie. if it is set to 00:00:00:00:00:00), we check if the HW PG version in use has the BD_ADDR written in the fuse ROM. If it does, we read it and derive the two subsequent addresses for WLAN. During production, 3 addresses are reserved per device. The first for Bluetooth (burnt in the fuse ROM) and the following two for WLAN. This patch has some code by Igal and Arik (squashed from internal patches). Signed-off-by: Arik Nemtsov Signed-off-by: Igal Chernobelsky Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/boot.c | 14 ++-- drivers/net/wireless/wl12xx/boot.h | 10 --- drivers/net/wireless/wl12xx/main.c | 99 +++++++++++++++++++++++++--- drivers/net/wireless/wl12xx/reg.h | 27 ++++++++ drivers/net/wireless/wl12xx/wl12xx.h | 7 +- 5 files changed, 131 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index 599919e2a60d..32a7f9b69d7c 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -258,12 +258,12 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) } /* update current MAC address to NVS */ - nvs_ptr[11] = wl->mac_addr[0]; - nvs_ptr[10] = wl->mac_addr[1]; - nvs_ptr[6] = wl->mac_addr[2]; - nvs_ptr[5] = wl->mac_addr[3]; - nvs_ptr[4] = wl->mac_addr[4]; - nvs_ptr[3] = wl->mac_addr[5]; + nvs_ptr[11] = wl->addresses[0].addr[0]; + nvs_ptr[10] = wl->addresses[0].addr[1]; + nvs_ptr[6] = wl->addresses[0].addr[2]; + nvs_ptr[5] = wl->addresses[0].addr[3]; + nvs_ptr[4] = wl->addresses[0].addr[4]; + nvs_ptr[3] = wl->addresses[0].addr[5]; /* * Layout before the actual NVS tables: @@ -626,7 +626,7 @@ static int wl127x_boot_clk(struct wl1271 *wl) u32 pause; u32 clk; - if (((wl->hw_pg_ver & PG_MAJOR_VER_MASK) >> PG_MAJOR_VER_OFFSET) < 3) + if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3) wl->quirks |= WL12XX_QUIRK_END_OF_TRANSACTION; if (wl->ref_clock == CONF_REF_CLK_19_2_E || diff --git a/drivers/net/wireless/wl12xx/boot.h b/drivers/net/wireless/wl12xx/boot.h index 06dad9380fa7..c3adc09f403d 100644 --- a/drivers/net/wireless/wl12xx/boot.h +++ b/drivers/net/wireless/wl12xx/boot.h @@ -55,16 +55,6 @@ struct wl1271_static_data { #define OCP_REG_CLK_POLARITY 0x0cb2 #define OCP_REG_CLK_PULL 0x0cb4 -#define WL127X_REG_FUSE_DATA_2_1 0x050a -#define WL128X_REG_FUSE_DATA_2_1 0x2152 -#define PG_VER_MASK 0x3c -#define PG_VER_OFFSET 2 - -#define PG_MAJOR_VER_MASK 0x3 -#define PG_MAJOR_VER_OFFSET 0x0 -#define PG_MINOR_VER_MASK 0xc -#define PG_MINOR_VER_OFFSET 0x2 - #define CMD_MBOX_ADDRESS 0x407B4 #define POLARITY_LOW BIT(1) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a41af84f649d..6c92f86217cd 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2132,7 +2132,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, * we still need this in order to configure the fw * while uploading the nvs */ - memcpy(wl->mac_addr, vif->addr, ETH_ALEN); + memcpy(wl->addresses[0].addr, vif->addr, ETH_ALEN); booted = wl12xx_init_fw(wl); if (!booted) { @@ -4859,6 +4859,76 @@ static struct bin_attribute fwlog_attr = { .read = wl1271_sysfs_read_fwlog, }; +static bool wl12xx_mac_in_fuse(struct wl1271 *wl) +{ + bool supported = false; + u8 major, minor; + + if (wl->chip.id == CHIP_ID_1283_PG20) { + major = WL128X_PG_GET_MAJOR(wl->hw_pg_ver); + minor = WL128X_PG_GET_MINOR(wl->hw_pg_ver); + + /* in wl128x we have the MAC address if the PG is >= (2, 1) */ + if (major > 2 || (major == 2 && minor >= 1)) + supported = true; + } else { + major = WL127X_PG_GET_MAJOR(wl->hw_pg_ver); + minor = WL127X_PG_GET_MINOR(wl->hw_pg_ver); + + /* in wl127x we have the MAC address if the PG is >= (3, 1) */ + if (major == 3 && minor >= 1) + supported = true; + } + + wl1271_debug(DEBUG_PROBE, + "PG Ver major = %d minor = %d, MAC %s present", + major, minor, supported ? "is" : "is not"); + + return supported; +} + +static void wl12xx_derive_mac_addresses(struct wl1271 *wl, + u32 oui, u32 nic, int n) +{ + int i; + + wl1271_debug(DEBUG_PROBE, "base address: oui %06x nic %06x, n %d", + oui, nic, n); + + if (nic + n - 1 > 0xffffff) + wl1271_warning("NIC part of the MAC address wraps around!"); + + for (i = 0; i < n; i++) { + wl->addresses[i].addr[0] = (u8)(oui >> 16); + wl->addresses[i].addr[1] = (u8)(oui >> 8); + wl->addresses[i].addr[2] = (u8) oui; + wl->addresses[i].addr[3] = (u8)(nic >> 16); + wl->addresses[i].addr[4] = (u8)(nic >> 8); + wl->addresses[i].addr[5] = (u8) nic; + nic++; + } + + wl->hw->wiphy->n_addresses = n; + wl->hw->wiphy->addresses = wl->addresses; +} + +static void wl12xx_get_fuse_mac(struct wl1271 *wl) +{ + u32 mac1, mac2; + + wl1271_set_partition(wl, &wl12xx_part_table[PART_DRPW]); + + mac1 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_1); + mac2 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_2); + + /* these are the two parts of the BD_ADDR */ + wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) + + ((mac1 & 0xff000000) >> 24); + wl->fuse_nic_addr = mac1 & 0xffffff; + + wl1271_set_partition(wl, &wl12xx_part_table[PART_DOWN]); +} + static int wl12xx_get_hw_info(struct wl1271 *wl) { int ret; @@ -4877,6 +4947,13 @@ static int wl12xx_get_hw_info(struct wl1271 *wl) wl->hw_pg_ver = (s8) (die_info & PG_VER_MASK) >> PG_VER_OFFSET; + if (!wl12xx_mac_in_fuse(wl)) { + wl->fuse_oui_addr = 0; + wl->fuse_nic_addr = 0; + } else { + wl12xx_get_fuse_mac(wl); + } + wl1271_power_off(wl); out: return ret; @@ -4885,6 +4962,7 @@ static int wl12xx_get_hw_info(struct wl1271 *wl) static int wl1271_register_hw(struct wl1271 *wl) { int ret; + u32 oui_addr = 0, nic_addr = 0; if (wl->mac80211_registered) return 0; @@ -4903,15 +4981,20 @@ static int wl1271_register_hw(struct wl1271 *wl) */ u8 *nvs_ptr = (u8 *)wl->nvs; - wl->mac_addr[0] = nvs_ptr[11]; - wl->mac_addr[1] = nvs_ptr[10]; - wl->mac_addr[2] = nvs_ptr[6]; - wl->mac_addr[3] = nvs_ptr[5]; - wl->mac_addr[4] = nvs_ptr[4]; - wl->mac_addr[5] = nvs_ptr[3]; + oui_addr = + (nvs_ptr[11] << 16) + (nvs_ptr[10] << 8) + nvs_ptr[6]; + nic_addr = + (nvs_ptr[5] << 16) + (nvs_ptr[4] << 8) + nvs_ptr[3]; + } + + /* if the MAC address is zeroed in the NVS derive from fuse */ + if (oui_addr == 0 && nic_addr == 0) { + oui_addr = wl->fuse_oui_addr; + /* fuse has the BD_ADDR, the WLAN addresses are the next two */ + nic_addr = wl->fuse_nic_addr + 1; } - SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); + wl12xx_derive_mac_addresses(wl, oui_addr, nic_addr, 2); ret = ieee80211_register_hw(wl->hw); if (ret < 0) { diff --git a/drivers/net/wireless/wl12xx/reg.h b/drivers/net/wireless/wl12xx/reg.h index df34d5977b98..340db324bc26 100644 --- a/drivers/net/wireless/wl12xx/reg.h +++ b/drivers/net/wireless/wl12xx/reg.h @@ -525,4 +525,31 @@ b12-b0 - Supported Rate indicator bits as defined below. */ #define INTR_TRIG_TX_PROC1 BIT(18) +#define WL127X_REG_FUSE_DATA_2_1 0x050a +#define WL128X_REG_FUSE_DATA_2_1 0x2152 +#define PG_VER_MASK 0x3c +#define PG_VER_OFFSET 2 + +#define WL127X_PG_MAJOR_VER_MASK 0x3 +#define WL127X_PG_MAJOR_VER_OFFSET 0x0 +#define WL127X_PG_MINOR_VER_MASK 0xc +#define WL127X_PG_MINOR_VER_OFFSET 0x2 + +#define WL128X_PG_MAJOR_VER_MASK 0xc +#define WL128X_PG_MAJOR_VER_OFFSET 0x2 +#define WL128X_PG_MINOR_VER_MASK 0x3 +#define WL128X_PG_MINOR_VER_OFFSET 0x0 + +#define WL127X_PG_GET_MAJOR(pg_ver) ((pg_ver & WL127X_PG_MAJOR_VER_MASK) >> \ + WL127X_PG_MAJOR_VER_OFFSET) +#define WL127X_PG_GET_MINOR(pg_ver) ((pg_ver & WL127X_PG_MINOR_VER_MASK) >> \ + WL127X_PG_MINOR_VER_OFFSET) +#define WL128X_PG_GET_MAJOR(pg_ver) ((pg_ver & WL128X_PG_MAJOR_VER_MASK) >> \ + WL128X_PG_MAJOR_VER_OFFSET) +#define WL128X_PG_GET_MINOR(pg_ver) ((pg_ver & WL128X_PG_MINOR_VER_MASK) >> \ + WL128X_PG_MINOR_VER_OFFSET) + +#define WL12XX_REG_FUSE_BD_ADDR_1 0x00310eb4 +#define WL12XX_REG_FUSE_BD_ADDR_2 0x00310eb8 + #endif diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b2b09cd02022..1f629fac02e4 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -313,7 +313,12 @@ struct wl1271 { s8 hw_pg_ver; - u8 mac_addr[ETH_ALEN]; + /* address read from the fuse ROM */ + u32 fuse_oui_addr; + u32 fuse_nic_addr; + + /* we have up to 2 MAC addresses */ + struct mac_address addresses[2]; int channel; u8 system_hlid; -- GitLab From 75f25548bea11d35b7cb0879eea595d3f86a0cc4 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 13 Jan 2012 14:04:29 +0200 Subject: [PATCH 0728/1846] wl12xx: add testmode operation to read the BD_ADDR from Fuse ROM Add a testmode command to retrieve the BD_ADDR that is stored in the Fuse ROM in newer PGs. In old PGs this operation is not supported. The caller can then derive the MAC addresses from it. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/testmode.c | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 25093c0cb0ed..b6b433e5562f 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -30,6 +30,7 @@ #include "acx.h" #include "reg.h" #include "ps.h" +#include "io.h" #define WL1271_TM_MAX_DATA_LENGTH 1024 @@ -41,6 +42,7 @@ enum wl1271_tm_commands { WL1271_TM_CMD_NVS_PUSH, /* Not in use. Keep to not break ABI */ WL1271_TM_CMD_SET_PLT_MODE, WL1271_TM_CMD_RECOVER, + WL1271_TM_CMD_GET_MAC, __WL1271_TM_CMD_AFTER_LAST }; @@ -264,6 +266,52 @@ static int wl1271_tm_cmd_recover(struct wl1271 *wl, struct nlattr *tb[]) return 0; } +static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[]) +{ + struct sk_buff *skb; + u8 mac_addr[ETH_ALEN]; + int ret = 0; + + mutex_lock(&wl->mutex); + + if (wl->state != WL1271_STATE_PLT) { + ret = -EINVAL; + goto out; + } + + if (wl->fuse_oui_addr == 0 && wl->fuse_nic_addr == 0) { + ret = -EOPNOTSUPP; + goto out; + } + + mac_addr[0] = (u8)(wl->fuse_oui_addr >> 16); + mac_addr[1] = (u8)(wl->fuse_oui_addr >> 8); + mac_addr[2] = (u8) wl->fuse_oui_addr; + mac_addr[3] = (u8)(wl->fuse_nic_addr >> 16); + mac_addr[4] = (u8)(wl->fuse_nic_addr >> 8); + mac_addr[5] = (u8) wl->fuse_nic_addr; + + skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, ETH_ALEN); + if (!skb) { + ret = -ENOMEM; + goto out; + } + + NLA_PUT(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr); + ret = cfg80211_testmode_reply(skb); + if (ret < 0) + goto out; + +out: + mutex_unlock(&wl->mutex); + return ret; + +nla_put_failure: + kfree_skb(skb); + ret = -EMSGSIZE; + goto out; +} + int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len) { struct wl1271 *wl = hw->priv; @@ -288,6 +336,8 @@ int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len) return wl1271_tm_cmd_set_plt_mode(wl, tb); case WL1271_TM_CMD_RECOVER: return wl1271_tm_cmd_recover(wl, tb); + case WL1271_TM_CMD_GET_MAC: + return wl12xx_tm_cmd_get_mac(wl, tb); default: return -EOPNOTSUPP; } -- GitLab From 775e1a4bd57a117ae181afebf59e26fa072db6a8 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Tue, 24 Jan 2012 11:46:32 +0200 Subject: [PATCH 0729/1846] wl12xx: remove unnecessary shadow declaration The vif variable was being declared inside one of the internal blocks of wl1271_event_process. This is not necessary, since this variable is already declared in the function context. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index d3280df68f5d..cfc38ea21e4a 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -344,7 +344,6 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) /* 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, @@ -352,6 +351,8 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) continue; success = mbox->channel_switch_status ? false : true; + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_chswitch_done(vif, success); } } -- GitLab From 2c882fa47502ef201e0533fc7cc21b097f4bcdca Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Tue, 7 Feb 2012 12:37:33 +0200 Subject: [PATCH 0730/1846] wl12xx: fix typo in fwlog module param description Fix a copy and paste bug in the MODULE_PARAM_DESC for fwlog. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 6c92f86217cd..ce0a233d2cd1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5444,7 +5444,7 @@ module_param_named(debug_level, wl12xx_debug_level, uint, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(debug_level, "wl12xx debugging level"); module_param_named(fwlog, fwlog_param, charp, 0); -MODULE_PARM_DESC(keymap, +MODULE_PARM_DESC(fwlog, "FW logger options: continuous, ondemand, dbgpins or disable"); module_param(bug_on_recovery, bool, S_IRUSR | S_IWUSR); -- GitLab From 7db4ee6d0a932bb95f839d9b427899b74139a8d5 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 24 Jan 2012 18:18:42 +0200 Subject: [PATCH 0731/1846] wl12xx: check bss_conf->assoc on CHANGED_BSSID with the new auth/assoc redesign, we get CHANGED_BSSID indication before CHANGED_ASSOC indication, while our CHANGED_BSSID handling block assumes we are already associated. Fix it by checking we are either in ibss mode, or already associated. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index ce0a233d2cd1..bba2a52256b6 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3665,7 +3665,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wlvif->rssi_thold = bss_conf->cqm_rssi_thold; } - if (changed & BSS_CHANGED_BSSID) + if (changed & BSS_CHANGED_BSSID && + (is_ibss || bss_conf->assoc)) if (!is_zero_ether_addr(bss_conf->bssid)) { ret = wl12xx_cmd_build_null_data(wl, wlvif); if (ret < 0) -- GitLab From 2801d69e84d04714c22f8cc22fbe8535ac5f1eb7 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 24 Jan 2012 18:18:43 +0200 Subject: [PATCH 0732/1846] wl12xx: remove wl1271_tx_update_filters wl1271_tx_update_filters() is used as some workaround to open filters while roaming on the same channel. However, it doesn't handle roaming to a different channel, and it might also sleep in the tx path, which is a bug. With the new auth/assoc redesign, roaming is much simpler, and this function is not needed anymore. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 4508ccd78328..2bf43b86a3f9 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -77,35 +77,6 @@ static void wl1271_free_tx_id(struct wl1271 *wl, int id) } } -static int wl1271_tx_update_filters(struct wl1271 *wl, - struct wl12xx_vif *wlvif, - struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr; - int ret; - - hdr = (struct ieee80211_hdr *)skb->data; - - /* - * stop bssid-based filtering before transmitting authentication - * requests. this way the hw will never drop authentication - * responses coming from BSSIDs it isn't familiar with (e.g. on - * roaming) - */ - if (!ieee80211_is_auth(hdr->frame_control)) - return 0; - - if (wlvif->dev_hlid != WL12XX_INVALID_LINK_ID) - goto out; - - wl1271_debug(DEBUG_CMD, "starting device role for roaming"); - ret = wl12xx_start_dev(wl, wlvif); - if (ret < 0) - goto out; -out: - return 0; -} - static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl, struct sk_buff *skb) { @@ -187,8 +158,6 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl12xx_tx_get_hlid_ap(wl, wlvif, skb); - wl1271_tx_update_filters(wl, wlvif, skb); - if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) && !ieee80211_is_auth(hdr->frame_control) && -- GitLab From b4748306368a61b64b97b16f11cb6a82eebb60f9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 26 Jan 2012 14:12:31 +0200 Subject: [PATCH 0733/1846] Revert "wl12xx: Change claiming of the SDIO bus" This reverts commit 393fb560d328cc06e6a5c7b7473901ad724f82e7. Commit b6ad726 ("mmc: core: Prevent too long response times for suspend") fails the suspend if the mmc host can't be claimed before suspend. As the host is claimed by us as long as the chip is powered on, suspend will always fail. Revert to claiming the sdio bus only when needed. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/sdio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 468a50553fac..099c2c9c1a2d 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -74,6 +74,8 @@ static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); + sdio_claim_host(func); + if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); dev_dbg(child->parent, "sdio read 52 addr 0x%x, byte 0x%02x\n", @@ -88,6 +90,8 @@ static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, addr, len); } + sdio_release_host(func); + if (ret) dev_err(child->parent, "sdio read failed (%d)\n", ret); } @@ -99,6 +103,8 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); + sdio_claim_host(func); + if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); dev_dbg(child->parent, "sdio write 52 addr 0x%x, byte 0x%02x\n", @@ -113,6 +119,8 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, ret = sdio_memcpy_toio(func, addr, buf, len); } + sdio_release_host(func); + if (ret) dev_err(child->parent, "sdio write failed (%d)\n", ret); } @@ -136,6 +144,7 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) sdio_claim_host(func); sdio_enable_func(func); + sdio_release_host(func); out: return ret; @@ -146,6 +155,7 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) int ret; struct sdio_func *func = dev_to_sdio_func(glue->dev); + sdio_claim_host(func); sdio_disable_func(func); sdio_release_host(func); -- GitLab From 1ebaa2d041746949c291fff17be9880820f70e55 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 26 Jan 2012 14:12:32 +0200 Subject: [PATCH 0734/1846] wl12xx: don't release/claim sdio on suspend/resume Since we reverted to claiming the host only when needed, we no longer need to release/claim the host on suspend/resume. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/sdio.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 099c2c9c1a2d..ce3b9a99463e 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -324,9 +324,6 @@ static int wl1271_suspend(struct device *dev) dev_err(dev, "error while trying to keep power\n"); goto out; } - - /* release host */ - sdio_release_host(func); } out: return ret; @@ -334,15 +331,7 @@ static int wl1271_suspend(struct device *dev) static int wl1271_resume(struct device *dev) { - struct sdio_func *func = dev_to_sdio_func(dev); - 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) { - /* claim back host */ - sdio_claim_host(func); - } return 0; } -- GitLab From cdaac6281170ee2934ad443cb60fbdd6cf318b64 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 31 Jan 2012 11:57:16 +0200 Subject: [PATCH 0735/1846] wl12xx: fw api change - add role_id to set_template The set_template commands now takes the role_id as parameter. Usually, we'll use the vif's main role_id. However, sometimes we'll want to use wlvif->dev_role_id instead of wlvif->role_id, so pass the wanted role_id as param. Update WL127X_FW_NAME/WL128X_FW_NAME. (This commit starts a series of fw update patches, and changes the start() callback to return an error in order to prevent the use of the driver during the transition. This change will be reverted in the last patch of series) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 37 +++++++++++++++-------- drivers/net/wireless/wl12xx/cmd.h | 18 +++++++---- drivers/net/wireless/wl12xx/init.c | 45 ++++++++++++++++++---------- drivers/net/wireless/wl12xx/main.c | 15 ++++++---- drivers/net/wireless/wl12xx/scan.c | 28 ++++++++++------- drivers/net/wireless/wl12xx/wl12xx.h | 4 +-- 6 files changed, 94 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 25990bd38be6..28e0a56d794f 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1022,8 +1022,9 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; } -int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, - void *buf, size_t buf_len, int index, u32 rates) +int wl1271_cmd_template_set(struct wl1271 *wl, u8 role_id, + u16 template_id, void *buf, size_t buf_len, + int index, u32 rates) { struct wl1271_cmd_template_set *cmd; int ret = 0; @@ -1039,6 +1040,8 @@ int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, goto out; } + /* during initialization wlvif is NULL */ + cmd->role_id = role_id; cmd->len = cpu_to_le16(buf_len); cmd->template_type = template_id; cmd->enabled_rates = cpu_to_le32(rates); @@ -1082,7 +1085,8 @@ int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif) ptr = skb->data; } - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, ptr, size, 0, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_NULL_DATA, ptr, size, 0, wlvif->basic_rate); out: @@ -1105,7 +1109,7 @@ int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, if (!skb) goto out; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_KLV, skb->data, skb->len, CMD_TEMPL_KLV_IDX_NULL_DATA, wlvif->basic_rate); @@ -1130,7 +1134,8 @@ int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (!skb) goto out; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_PS_POLL, skb->data, skb->len, 0, wlvif->basic_rate_set); out: @@ -1138,9 +1143,10 @@ int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; } -int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, +int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 role_id, u8 band, const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len, u8 band) + const u8 *ie, size_t ie_len) { struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb; @@ -1158,10 +1164,12 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, 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, + ret = wl1271_cmd_template_set(wl, role_id, + CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); else - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5, + ret = wl1271_cmd_template_set(wl, role_id, + CMD_TEMPL_CFG_PROBE_REQ_5, skb->data, skb->len, 0, rate); out: @@ -1186,10 +1194,12 @@ struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, 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, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); else - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_CFG_PROBE_REQ_5, skb->data, skb->len, 0, rate); if (ret < 0) @@ -1235,7 +1245,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, memcpy(tmpl.sender_hw, vif->addr, ETH_ALEN); tmpl.sender_ip = ip_addr; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_ARP_RSP, &tmpl, sizeof(tmpl), 0, wlvif->basic_rate); @@ -1260,7 +1270,8 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) /* FIXME: not sure what priority to use here */ template.qos_ctrl = cpu_to_le16(0); - return wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, &template, + return wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_QOS_NULL_DATA, &template, sizeof(template), 0, wlvif->basic_rate); } diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 3f7d0b93c24d..8e8035d33068 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -54,14 +54,16 @@ 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, - void *buf, size_t buf_len, int index, u32 rates); +int wl1271_cmd_template_set(struct wl1271 *wl, u8 role_id, + u16 template_id, void *buf, size_t buf_len, + int index, u32 rates); 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, struct wl12xx_vif *wlvif, +int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 role_id, u8 band, const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len, u8 band); + const u8 *ie, size_t ie_len); struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb); @@ -191,7 +193,7 @@ enum cmd_templ { /* unit ms */ #define WL1271_COMMAND_TIMEOUT 2000 #define WL1271_CMD_TEMPL_DFLT_SIZE 252 -#define WL1271_CMD_TEMPL_MAX_SIZE 548 +#define WL1271_CMD_TEMPL_MAX_SIZE 512 #define WL1271_EVENT_TIMEOUT 750 struct wl1271_cmd_header { @@ -364,14 +366,18 @@ struct cmd_enabledisable_path { struct wl1271_cmd_template_set { struct wl1271_cmd_header header; - __le16 len; + u8 role_id; u8 template_type; + __le16 len; u8 index; /* relevant only for KLV_TEMPLATE type */ + u8 padding[3]; + __le32 enabled_rates; u8 short_retry_limit; u8 long_retry_limit; u8 aflags; u8 reserved; + u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE]; } __packed; diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index ca7ee59e4505..fcf2b128f9a4 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -39,50 +39,58 @@ int wl1271_init_templates_config(struct wl1271 *wl) int ret, i; /* send empty templates for fw memory reservation */ - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_CFG_PROBE_REQ_5, NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + 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_PS_POLL, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_PS_POLL, NULL, sizeof(struct wl12xx_ps_poll_template), 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_QOS_NULL_DATA, NULL, sizeof (struct ieee80211_qos_hdr), 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_PROBE_RESPONSE, NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_BEACON, NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_ARP_RSP, NULL, sizeof (struct wl12xx_arp_rsp_template), 0, WL1271_RATE_AUTOMATIC); @@ -93,19 +101,22 @@ int wl1271_init_templates_config(struct wl1271 *wl) * 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, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + 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, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + 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, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_DEAUTH_AP, NULL, sizeof (struct wl12xx_disconn_template), 0, WL1271_RATE_AUTOMATIC); @@ -113,7 +124,8 @@ int wl1271_init_templates_config(struct wl1271 *wl) return ret; for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, + ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, + CMD_TEMPL_KLV, NULL, sizeof(struct ieee80211_qos_hdr), i, WL1271_RATE_AUTOMATIC); if (ret < 0) @@ -140,7 +152,8 @@ static int wl1271_ap_init_deauth_template(struct wl1271 *wl, IEEE80211_STYPE_DEAUTH); rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_DEAUTH_AP, tmpl, sizeof(*tmpl), 0, rate); out: @@ -172,7 +185,8 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl, memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_NULL_DATA, nullfunc, sizeof(*nullfunc), 0, rate); out: @@ -204,7 +218,8 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, memcpy(qosnull->addr3, vif->addr, ETH_ALEN); rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, + CMD_TEMPL_QOS_NULL_DATA, qosnull, sizeof(*qosnull), 0, rate); out: diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index bba2a52256b6..e4549dfb70d4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1778,7 +1778,9 @@ static int wl1271_op_start(struct ieee80211_hw *hw) * is added. That is where we will initialize the hardware. */ - return 0; + wl1271_error("wl12xx is in an ustable state (fw api update is " + "taking place). skip this commit when bisecting"); + return -EBUSY; } static void wl1271_op_stop(struct ieee80211_hw *hw) @@ -3297,6 +3299,7 @@ static void wl12xx_remove_vendor_ie(struct sk_buff *skb, static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, u32 rates, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct sk_buff *skb; int ret; @@ -3304,7 +3307,7 @@ static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, u32 rates, if (!skb) return -EOPNOTSUPP; - ret = wl1271_cmd_template_set(wl, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_AP_PROBE_RESPONSE, skb->data, skb->len, 0, @@ -3328,7 +3331,7 @@ static int wl1271_ap_set_probe_resp_tmpl_legacy(struct wl1271 *wl, /* no need to change probe response if the SSID is set correctly */ if (wlvif->ssid_len > 0) - return wl1271_cmd_template_set(wl, + return wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_AP_PROBE_RESPONSE, probe_rsp_data, probe_rsp_len, 0, @@ -3365,7 +3368,7 @@ static int wl1271_ap_set_probe_resp_tmpl_legacy(struct wl1271 *wl, ptr, probe_rsp_len - (ptr - probe_rsp_data)); templ_len += probe_rsp_len - (ptr - probe_rsp_data); - return wl1271_cmd_template_set(wl, + return wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_AP_PROBE_RESPONSE, probe_rsp_templ, templ_len, 0, @@ -3462,7 +3465,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, 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, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, tmpl_id, beacon->data, beacon->len, 0, min_rate); @@ -3501,7 +3504,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, beacon->len, min_rate); else - ret = wl1271_cmd_template_set(wl, + ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_PROBE_RESPONSE, beacon->data, beacon->len, 0, diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e24111ececc5..416ae9145d61 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -217,9 +217,11 @@ 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, wlvif, wl->scan.ssid, - wl->scan.ssid_len, wl->scan.req->ie, - wl->scan.req->ie_len, band); + ret = wl12xx_cmd_build_probe_req(wl, wlvif, + wlvif->role_id, band, + wl->scan.ssid, wl->scan.ssid_len, + wl->scan.req->ie, + wl->scan.req->ie_len); if (ret < 0) { wl1271_error("PROBE request template failed"); goto out; @@ -658,11 +660,13 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, } if (!force_passive && cfg->active[0]) { - ret = wl1271_cmd_build_probe_req(wl, wlvif, req->ssids[0].ssid, + u8 band = IEEE80211_BAND_2GHZ; + ret = wl12xx_cmd_build_probe_req(wl, wlvif, + wlvif->role_id, band, + req->ssids[0].ssid, req->ssids[0].ssid_len, - ies->ie[IEEE80211_BAND_2GHZ], - ies->len[IEEE80211_BAND_2GHZ], - IEEE80211_BAND_2GHZ); + ies->ie[band], + ies->len[band]); if (ret < 0) { wl1271_error("2.4GHz PROBE request template failed"); goto out; @@ -670,11 +674,13 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, } if (!force_passive && cfg->active[1]) { - ret = wl1271_cmd_build_probe_req(wl, wlvif, req->ssids[0].ssid, + u8 band = IEEE80211_BAND_5GHZ; + ret = wl12xx_cmd_build_probe_req(wl, wlvif, + wlvif->role_id, band, + req->ssids[0].ssid, req->ssids[0].ssid_len, - ies->ie[IEEE80211_BAND_5GHZ], - ies->len[IEEE80211_BAND_5GHZ], - IEEE80211_BAND_5GHZ); + ies->ie[band], + ies->len[band]); if (ret < 0) { wl1271_error("5GHz PROBE request template failed"); goto out; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 1f629fac02e4..b9bfbfffc5c0 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -35,8 +35,8 @@ #include "conf.h" #include "ini.h" -#define WL127X_FW_NAME "ti-connectivity/wl127x-fw-3.bin" -#define WL128X_FW_NAME "ti-connectivity/wl128x-fw-3.bin" +#define WL127X_FW_NAME "ti-connectivity/wl127x-fw-4-sr.bin" +#define WL128X_FW_NAME "ti-connectivity/wl128x-fw-4-sr.bin" /* * wl127x and wl128x are using the same NVS file name. However, the -- GitLab From c059beb2adbf632748ac63ea829c69437575761a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 31 Jan 2012 11:57:17 +0200 Subject: [PATCH 0736/1846] wl12xx: use dev_role_id for scans Use device role for scans when the sta is not associated. sched_scan is used only when the sta is not associated, and thus should use the dev role (instead of sta role). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 3 ++- drivers/net/wireless/wl12xx/main.c | 2 +- drivers/net/wireless/wl12xx/scan.c | 20 ++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 28e0a56d794f..10dba19f3eb3 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1029,7 +1029,8 @@ int wl1271_cmd_template_set(struct wl1271 *wl, u8 role_id, struct wl1271_cmd_template_set *cmd; int ret = 0; - wl1271_debug(DEBUG_CMD, "cmd template_set %d", template_id); + wl1271_debug(DEBUG_CMD, "cmd template_set %d (role %d)", + template_id, role_id); WARN_ON(buf_len > WL1271_CMD_TEMPL_MAX_SIZE); buf_len = min_t(size_t, buf_len, WL1271_CMD_TEMPL_MAX_SIZE); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e4549dfb70d4..d16ea7a528a2 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3070,7 +3070,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, /* cancel ROC before scanning */ if (wl12xx_dev_role_started(wlvif)) - wl12xx_stop_dev(wl, wlvif); + wl12xx_croc(wl, wlvif->dev_role_id); ret = wl1271_scan(hw->priv, vif, ssid, len, req); out_sleep: diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 416ae9145d61..6adc7333b7e6 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -77,7 +77,10 @@ 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_start_dev(wl, wlvif); + if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) + wl12xx_start_dev(wl, wlvif); + else + wl12xx_roc(wl, wlvif, wlvif->dev_role_id); } wl1271_ps_elp_sleep(wl); @@ -185,11 +188,16 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, if (passive) scan_options |= WL1271_SCAN_OPT_PASSIVE; - if (WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID)) { + if (WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID || + wlvif->dev_role_id == WL12XX_INVALID_ROLE_ID)) { ret = -EINVAL; goto out; } - cmd->params.role_id = wlvif->role_id; + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) + cmd->params.role_id = wlvif->role_id; + else + cmd->params.role_id = wlvif->dev_role_id; + cmd->params.scan_options = cpu_to_le16(scan_options); cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req, @@ -218,7 +226,7 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, memcpy(cmd->addr, vif->addr, ETH_ALEN); ret = wl12xx_cmd_build_probe_req(wl, wlvif, - wlvif->role_id, band, + cmd->params.role_id, band, wl->scan.ssid, wl->scan.ssid_len, wl->scan.req->ie, wl->scan.req->ie_len); @@ -662,7 +670,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, if (!force_passive && cfg->active[0]) { u8 band = IEEE80211_BAND_2GHZ; ret = wl12xx_cmd_build_probe_req(wl, wlvif, - wlvif->role_id, band, + wlvif->dev_role_id, band, req->ssids[0].ssid, req->ssids[0].ssid_len, ies->ie[band], @@ -676,7 +684,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, if (!force_passive && cfg->active[1]) { u8 band = IEEE80211_BAND_5GHZ; ret = wl12xx_cmd_build_probe_req(wl, wlvif, - wlvif->role_id, band, + wlvif->dev_role_id, band, req->ssids[0].ssid, req->ssids[0].ssid_len, ies->ie[band], -- GitLab From 9c531149af5b6e81d204c3f633827338ad9b327e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 31 Jan 2012 11:57:18 +0200 Subject: [PATCH 0737/1846] wl12xx: fw api change - add role_id to tsf_info The ACX_TSF_INFO command now takes role_id as param. change the struct accordingly, and pass the wlvif to the wl1271_acx_tsf_info() function. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 7 +++++-- drivers/net/wireless/wl12xx/acx.h | 9 ++++++--- drivers/net/wireless/wl12xx/main.c | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 7537c401a448..af2c3123d1d7 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -1459,9 +1459,10 @@ int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, return ret; } -int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime) +int wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u64 *mactime) { - struct wl1271_acx_fw_tsf_information *tsf_info; + struct wl12xx_acx_fw_tsf_information *tsf_info; int ret; tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL); @@ -1470,6 +1471,8 @@ int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime) goto out; } + tsf_info->role_id = wlvif->role_id; + ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO, tsf_info, sizeof(*tsf_info)); if (ret < 0) { diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 69892b40c2df..a5bf761c83d2 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -995,15 +995,17 @@ struct wl1271_acx_ba_receiver_setup { u8 padding[2]; } __packed; -struct wl1271_acx_fw_tsf_information { +struct wl12xx_acx_fw_tsf_information { struct acx_header header; + u8 role_id; + u8 padding1[3]; __le32 current_tsf_high; __le32 current_tsf_low; __le32 last_bttt_high; __le32 last_tbtt_low; u8 last_dtim_count; - u8 padding[3]; + u8 padding2[3]; } __packed; struct wl1271_acx_ps_rx_streaming { @@ -1296,7 +1298,8 @@ 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 wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u64 *mactime); 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); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d16ea7a528a2..1cdffa88eb02 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4047,6 +4047,7 @@ static u64 wl1271_op_get_tsf(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u64 mactime = ULLONG_MAX; int ret; @@ -4061,7 +4062,7 @@ static u64 wl1271_op_get_tsf(struct ieee80211_hw *hw, if (ret < 0) goto out; - ret = wl1271_acx_tsf_info(wl, &mactime); + ret = wl12xx_acx_tsf_info(wl, wlvif, &mactime); if (ret < 0) goto out_sleep; -- GitLab From 8332f0f6dc017aef9aa4a95a6a2bd6eba4c82d0a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 31 Jan 2012 11:57:19 +0200 Subject: [PATCH 0738/1846] wl12xx: fw api change - update cmd/acx/event enums Update enums/structs to the new fw api. Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.h | 137 ++++++++++++++-------------- drivers/net/wireless/wl12xx/boot.c | 2 +- drivers/net/wireless/wl12xx/cmd.c | 12 ++- drivers/net/wireless/wl12xx/cmd.h | 122 +++++++++++++------------ drivers/net/wireless/wl12xx/event.h | 15 ++- drivers/net/wireless/wl12xx/main.c | 2 +- 6 files changed, 156 insertions(+), 134 deletions(-) diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index a5bf761c83d2..0749df58c85d 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1153,74 +1153,75 @@ struct wl12xx_acx_config_hangover { } __packed; enum { - ACX_WAKE_UP_CONDITIONS = 0x0002, - ACX_MEM_CFG = 0x0003, - ACX_SLOT = 0x0004, - ACX_AC_CFG = 0x0007, - ACX_MEM_MAP = 0x0008, - ACX_AID = 0x000A, - ACX_MEDIUM_USAGE = 0x000F, - ACX_TX_QUEUE_CFG = 0x0011, /* FIXME: only used by wl1251 */ - ACX_STATISTICS = 0x0013, /* Debug API */ - ACX_PWR_CONSUMPTION_STATISTICS = 0x0014, - ACX_FEATURE_CFG = 0x0015, - ACX_TID_CFG = 0x001A, - ACX_PS_RX_STREAMING = 0x001B, - ACX_BEACON_FILTER_OPT = 0x001F, - ACX_NOISE_HIST = 0x0021, - ACX_HDK_VERSION = 0x0022, /* ??? */ - ACX_PD_THRESHOLD = 0x0023, - ACX_TX_CONFIG_OPT = 0x0024, - ACX_CCA_THRESHOLD = 0x0025, - ACX_EVENT_MBOX_MASK = 0x0026, - ACX_CONN_MONIT_PARAMS = 0x002D, - ACX_BCN_DTIM_OPTIONS = 0x0031, - ACX_SG_ENABLE = 0x0032, - ACX_SG_CFG = 0x0033, - ACX_FM_COEX_CFG = 0x0034, - ACX_BEACON_FILTER_TABLE = 0x0038, - ACX_ARP_IP_FILTER = 0x0039, - ACX_ROAMING_STATISTICS_TBL = 0x003B, - ACX_RATE_POLICY = 0x003D, - ACX_CTS_PROTECTION = 0x003E, - ACX_SLEEP_AUTH = 0x003F, - ACX_PREAMBLE_TYPE = 0x0040, - ACX_ERROR_CNT = 0x0041, - ACX_IBSS_FILTER = 0x0044, - ACX_SERVICE_PERIOD_TIMEOUT = 0x0045, - ACX_TSF_INFO = 0x0046, - ACX_CONFIG_PS_WMM = 0x0049, - ACX_ENABLE_RX_DATA_FILTER = 0x004A, - ACX_SET_RX_DATA_FILTER = 0x004B, - ACX_GET_DATA_FILTER_STATISTICS = 0x004C, - ACX_RX_CONFIG_OPT = 0x004E, - ACX_FRAG_CFG = 0x004F, - ACX_BET_ENABLE = 0x0050, - ACX_RSSI_SNR_TRIGGER = 0x0051, - ACX_RSSI_SNR_WEIGHTS = 0x0052, - ACX_KEEP_ALIVE_MODE = 0x0053, - ACX_SET_KEEP_ALIVE_CONFIG = 0x0054, - ACX_BA_SESSION_INIT_POLICY = 0x0055, - ACX_BA_SESSION_RX_SETUP = 0x0056, - ACX_PEER_HT_CAP = 0x0057, - ACX_HT_BSS_OPERATION = 0x0058, - ACX_COEX_ACTIVITY = 0x0059, - ACX_BURST_MODE = 0x005C, - ACX_SET_RATE_MGMT_PARAMS = 0x005D, - ACX_SET_RATE_ADAPT_PARAMS = 0x0060, - ACX_SET_DCO_ITRIM_PARAMS = 0x0061, - ACX_GEN_FW_CMD = 0x0070, - ACX_HOST_IF_CFG_BITMAP = 0x0071, - ACX_MAX_TX_FAILURE = 0x0072, - ACX_UPDATE_INCONNECTION_STA_LIST = 0x0073, - DOT11_RX_MSDU_LIFE_TIME = 0x1004, - DOT11_CUR_TX_PWR = 0x100D, - DOT11_RX_DOT11_MODE = 0x1012, - DOT11_RTS_THRESHOLD = 0x1013, - DOT11_GROUP_ADDRESS_TBL = 0x1014, - ACX_PM_CONFIG = 0x1016, - ACX_CONFIG_PS = 0x1017, - ACX_CONFIG_HANGOVER = 0x1018, + ACX_WAKE_UP_CONDITIONS = 0x0000, + ACX_MEM_CFG = 0x0001, + ACX_SLOT = 0x0002, + ACX_AC_CFG = 0x0003, + ACX_MEM_MAP = 0x0004, + ACX_AID = 0x0005, + ACX_MEDIUM_USAGE = 0x0006, + ACX_STATISTICS = 0x0007, + ACX_PWR_CONSUMPTION_STATISTICS = 0x0008, + ACX_TID_CFG = 0x0009, + ACX_PS_RX_STREAMING = 0x000A, + ACX_BEACON_FILTER_OPT = 0x000B, + ACX_NOISE_HIST = 0x000C, + ACX_HDK_VERSION = 0x000D, + ACX_PD_THRESHOLD = 0x000E, + ACX_TX_CONFIG_OPT = 0x000F, + ACX_CCA_THRESHOLD = 0x0010, + ACX_EVENT_MBOX_MASK = 0x0011, + ACX_CONN_MONIT_PARAMS = 0x0012, + ACX_DISABLE_BROADCASTS = 0x0013, + ACX_BCN_DTIM_OPTIONS = 0x0014, + ACX_SG_ENABLE = 0x0015, + ACX_SG_CFG = 0x0016, + ACX_FM_COEX_CFG = 0x0017, + ACX_BEACON_FILTER_TABLE = 0x0018, + ACX_ARP_IP_FILTER = 0x0019, + ACX_ROAMING_STATISTICS_TBL = 0x001A, + ACX_RATE_POLICY = 0x001B, + ACX_CTS_PROTECTION = 0x001C, + ACX_SLEEP_AUTH = 0x001D, + ACX_PREAMBLE_TYPE = 0x001E, + ACX_ERROR_CNT = 0x001F, + ACX_IBSS_FILTER = 0x0020, + ACX_SERVICE_PERIOD_TIMEOUT = 0x0021, + ACX_TSF_INFO = 0x0022, + ACX_CONFIG_PS_WMM = 0x0023, + ACX_ENABLE_RX_DATA_FILTER = 0x0024, + ACX_SET_RX_DATA_FILTER = 0x0025, + ACX_GET_DATA_FILTER_STATISTICS = 0x0026, + ACX_RX_CONFIG_OPT = 0x0027, + ACX_FRAG_CFG = 0x0028, + ACX_BET_ENABLE = 0x0029, + ACX_RSSI_SNR_TRIGGER = 0x002A, + ACX_RSSI_SNR_WEIGHTS = 0x002B, + ACX_KEEP_ALIVE_MODE = 0x002C, + ACX_SET_KEEP_ALIVE_CONFIG = 0x002D, + ACX_BA_SESSION_INIT_POLICY = 0x002E, + ACX_BA_SESSION_RX_SETUP = 0x002F, + ACX_PEER_HT_CAP = 0x0030, + ACX_HT_BSS_OPERATION = 0x0031, + ACX_COEX_ACTIVITY = 0x0032, + ACX_BURST_MODE = 0x0033, + ACX_SET_RATE_MGMT_PARAMS = 0x0034, + ACX_GET_RATE_MGMT_PARAMS = 0x0035, + ACX_SET_RATE_ADAPT_PARAMS = 0x0036, + ACX_SET_DCO_ITRIM_PARAMS = 0x0037, + ACX_GEN_FW_CMD = 0x0038, + ACX_HOST_IF_CFG_BITMAP = 0x0039, + ACX_MAX_TX_FAILURE = 0x003A, + ACX_UPDATE_INCONNECTION_STA_LIST = 0x003B, + DOT11_RX_MSDU_LIFE_TIME = 0x003C, + DOT11_CUR_TX_PWR = 0x003D, + DOT11_RTS_THRESHOLD = 0x003E, + DOT11_GROUP_ADDRESS_TBL = 0x003F, + ACX_PM_CONFIG = 0x0040, + ACX_CONFIG_PS = 0x0041, + ACX_CONFIG_HANGOVER = 0x0042, + ACX_FEATURE_CFG = 0x0043, + ACX_PROTECTION_CFG = 0x0044, }; diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index 32a7f9b69d7c..eea2dda6e6e7 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -449,7 +449,7 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl) wl->event_mask = BSS_LOSE_EVENT_ID | SCAN_COMPLETE_EVENT_ID | PS_REPORT_EVENT_ID | - DISCONNECT_EVENT_COMPLETE_ID | + ROLE_STOP_COMPLETE_EVENT_ID | RSSI_SNR_TRIGGER_0_EVENT_ID | PSPOLL_DELIVERY_FAILURE_EVENT_ID | SOFT_GEMINI_SENSE_EVENT_ID | diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 10dba19f3eb3..88e94c5938a4 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -566,7 +566,7 @@ static int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, goto out_free; } - ret = wl1271_cmd_wait_for_event(wl, DISCONNECT_EVENT_COMPLETE_ID); + ret = wl1271_cmd_wait_for_event(wl, ROLE_STOP_COMPLETE_EVENT_ID); if (ret < 0) { wl1271_error("cmd role stop dev event completion error"); goto out_free; @@ -715,6 +715,8 @@ 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; + /* FIXME: Change when adding DFS */ + cmd->ap.reset_tsf = 1; /* By default reset AP TSF */ cmd->channel = wlvif->channel; if (!bss_conf->hidden_ssid) { @@ -1756,6 +1758,7 @@ int wl12xx_croc(struct wl1271 *wl, u8 role_id) } int wl12xx_cmd_channel_switch(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct ieee80211_channel_switch *ch_switch) { struct wl12xx_cmd_channel_switch *cmd; @@ -1769,10 +1772,13 @@ int wl12xx_cmd_channel_switch(struct wl1271 *wl, goto out; } + cmd->role_id = wlvif->role_id; cmd->channel = ch_switch->channel->hw_value; cmd->switch_time = ch_switch->count; - cmd->tx_suspend = ch_switch->block_tx; - cmd->flush = 0; /* this value is ignored by the FW */ + cmd->stop_tx = ch_switch->block_tx; + + /* FIXME: control from mac80211 in the future */ + cmd->post_switch_tx_disable = 0; /* Enable TX on the target channel */ ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0); if (ret < 0) { diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 8e8035d33068..edd240db0dcc 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -91,6 +91,7 @@ int wl12xx_cmd_config_fwlog(struct wl1271 *wl); int wl12xx_cmd_start_fwlog(struct wl1271 *wl); int wl12xx_cmd_stop_fwlog(struct wl1271 *wl); int wl12xx_cmd_channel_switch(struct wl1271 *wl, + struct wl12xx_vif *wlvif, 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, @@ -98,62 +99,65 @@ int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, 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*/ - CMD_CONFIGURE = 2, /*use this to write information elements*/ - CMD_ENABLE_RX = 3, - CMD_ENABLE_TX = 4, - CMD_DISABLE_RX = 5, - CMD_DISABLE_TX = 6, - CMD_SCAN = 8, - CMD_STOP_SCAN = 9, - CMD_SET_KEYS = 12, - CMD_READ_MEMORY = 13, - CMD_WRITE_MEMORY = 14, - CMD_SET_TEMPLATE = 19, - CMD_TEST = 23, - CMD_NOISE_HIST = 28, - CMD_QUIET_ELEMENT_SET_STATE = 29, - CMD_SET_BCN_MODE = 33, - CMD_MEASUREMENT = 34, - CMD_STOP_MEASUREMENT = 35, - CMD_SET_PS_MODE = 37, - CMD_CHANNEL_SWITCH = 38, - CMD_STOP_CHANNEL_SWICTH = 39, - CMD_AP_DISCOVERY = 40, - CMD_STOP_AP_DISCOVERY = 41, - CMD_HEALTH_CHECK = 45, - CMD_DEBUG = 46, - CMD_TRIGGER_SCAN_TO = 47, - CMD_CONNECTION_SCAN_CFG = 48, - CMD_CONNECTION_SCAN_SSID_CFG = 49, - CMD_START_PERIODIC_SCAN = 50, - CMD_STOP_PERIODIC_SCAN = 51, - CMD_SET_PEER_STATE = 52, - CMD_REMAIN_ON_CHANNEL = 53, - CMD_CANCEL_REMAIN_ON_CHANNEL = 54, - - CMD_CONFIG_FWLOGGER = 55, - CMD_START_FWLOGGER = 56, - CMD_STOP_FWLOGGER = 57, - - /* AP commands */ - CMD_ADD_PEER = 62, - CMD_REMOVE_PEER = 63, + CMD_INTERROGATE = 1, /* use this to read information elements */ + CMD_CONFIGURE = 2, /* use this to write information elements */ + CMD_ENABLE_RX = 3, + CMD_ENABLE_TX = 4, + CMD_DISABLE_RX = 5, + CMD_DISABLE_TX = 6, + CMD_SCAN = 7, + CMD_STOP_SCAN = 8, + CMD_SET_KEYS = 9, + CMD_READ_MEMORY = 10, + CMD_WRITE_MEMORY = 11, + CMD_SET_TEMPLATE = 12, + CMD_TEST = 13, + CMD_NOISE_HIST = 14, + CMD_QUIET_ELEMENT_SET_STATE = 15, + CMD_SET_BCN_MODE = 16, + + CMD_MEASUREMENT = 17, + CMD_STOP_MEASUREMENT = 18, + CMD_SET_PS_MODE = 19, + CMD_CHANNEL_SWITCH = 20, + CMD_STOP_CHANNEL_SWICTH = 21, + CMD_AP_DISCOVERY = 22, + CMD_STOP_AP_DISCOVERY = 23, + CMD_HEALTH_CHECK = 24, + CMD_DEBUG = 25, + CMD_TRIGGER_SCAN_TO = 26, + CMD_CONNECTION_SCAN_CFG = 27, + CMD_CONNECTION_SCAN_SSID_CFG = 28, + CMD_START_PERIODIC_SCAN = 29, + CMD_STOP_PERIODIC_SCAN = 30, + CMD_SET_PEER_STATE = 31, + CMD_REMAIN_ON_CHANNEL = 32, + CMD_CANCEL_REMAIN_ON_CHANNEL = 33, + CMD_CONFIG_FWLOGGER = 34, + CMD_START_FWLOGGER = 35, + CMD_STOP_FWLOGGER = 36, + + /* Access point commands */ + CMD_ADD_PEER = 37, + CMD_REMOVE_PEER = 38, /* Role API */ - CMD_ROLE_ENABLE = 70, - CMD_ROLE_DISABLE = 71, - CMD_ROLE_START = 72, - CMD_ROLE_STOP = 73, + CMD_ROLE_ENABLE = 39, + CMD_ROLE_DISABLE = 40, + CMD_ROLE_START = 41, + CMD_ROLE_STOP = 42, - /* WIFI Direct */ - CMD_WFD_START_DISCOVERY = 80, - CMD_WFD_STOP_DISCOVERY = 81, - CMD_WFD_ATTRIBUTE_CONFIG = 82, + /* DFS */ + CMD_START_RADAR_DETECTION = 43, + CMD_STOP_RADAR_DETECTION = 44, - CMD_NOP = 100, + /* WIFI Direct */ + CMD_WFD_START_DISCOVERY = 45, + CMD_WFD_STOP_DISCOVERY = 46, + CMD_WFD_ATTRIBUTE_CONFIG = 47, + CMD_NOP = 48, + CMD_LAST_COMMAND, - NUM_COMMANDS, MAX_COMMAND_ID = 0xFFFF, }; @@ -341,7 +345,9 @@ struct wl12xx_cmd_role_start { u8 ssid_len; u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 padding_1[5]; + u8 reset_tsf; + + u8 padding_1[4]; } __packed ap; }; } __packed; @@ -701,14 +707,18 @@ struct wl12xx_cmd_stop_fwlog { struct wl12xx_cmd_channel_switch { struct wl1271_cmd_header header; + u8 role_id; + /* The new serving channel */ u8 channel; /* Relative time of the serving channel switch in TBTT units */ u8 switch_time; - /* 1: Suspend TX till switch time; 0: Do not suspend TX */ - u8 tx_suspend; - /* 1: Flush TX at switch time; 0: Do not flush */ - u8 flush; + /* Stop the role TX, should expect it after radar detection */ + u8 stop_tx; + /* The target channel tx status 1-stopped 0-open*/ + u8 post_switch_tx_disable; + + u8 padding[3]; } __packed; struct wl12xx_cmd_stop_channel_switch { diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/event.h index 1d878ba47bf4..b41f730f11dd 100644 --- a/drivers/net/wireless/wl12xx/event.h +++ b/drivers/net/wireless/wl12xx/event.h @@ -53,8 +53,8 @@ enum { AP_DISCOVERY_COMPLETE_EVENT_ID = BIT(12), PS_REPORT_EVENT_ID = BIT(13), PSPOLL_DELIVERY_FAILURE_EVENT_ID = BIT(14), - DISCONNECT_EVENT_COMPLETE_ID = BIT(15), - /* BIT(16) is reserved */ + ROLE_STOP_COMPLETE_EVENT_ID = BIT(15), + RADAR_DETECTED_EVENT_ID = BIT(16), CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(17), BSS_LOSE_EVENT_ID = BIT(18), REGAINED_BSS_EVENT_ID = BIT(19), @@ -94,7 +94,7 @@ struct event_mailbox { u8 soft_gemini_sense_info; u8 soft_gemini_protective_info; s8 rssi_snr_trigger_metric[NUM_OF_RSSI_SNR_TRIGGERS]; - u8 channel_switch_status; + u8 change_auto_mode_timeout; u8 scheduled_scan_status; u8 ps_status; /* tuned channel (roc) */ @@ -119,12 +119,17 @@ struct event_mailbox { u8 rx_ba_allowed; u8 reserved_6[2]; + /* Channel switch results */ + + u8 channel_switch_role_id; + u8 channel_switch_status; + u8 reserved_7[2]; + u8 ps_poll_delivery_failure_role_ids; u8 stopped_role_ids; u8 started_role_ids; - u8 change_auto_mode_timeout; - u8 reserved_7[12]; + u8 reserved_8[9]; } __packed; int wl1271_event_unmask(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 1cdffa88eb02..a339a85ecfb0 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4409,7 +4409,7 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, /* TODO: change mac80211 to pass vif as param */ wl12xx_for_each_wlvif_sta(wl, wlvif) { - ret = wl12xx_cmd_channel_switch(wl, ch_switch); + ret = wl12xx_cmd_channel_switch(wl, wlvif, ch_switch); if (!ret) set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags); -- GitLab From d6bf9ada92c113e56151b6a993b9b9d5d03f1365 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 31 Jan 2012 11:57:20 +0200 Subject: [PATCH 0739/1846] wl12xx: remove PS management code Removal of PS management code from the driver as PS is handled by the FW (dynamic PS) Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/boot.c | 1 - drivers/net/wireless/wl12xx/conf.h | 7 -- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/event.c | 143 -------------------------- drivers/net/wireless/wl12xx/event.h | 5 +- drivers/net/wireless/wl12xx/main.c | 81 +-------------- drivers/net/wireless/wl12xx/wl12xx.h | 6 -- 7 files changed, 5 insertions(+), 239 deletions(-) diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index eea2dda6e6e7..954101d03f06 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -448,7 +448,6 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl) /* unmask required mbox events */ wl->event_mask = BSS_LOSE_EVENT_ID | SCAN_COMPLETE_EVENT_ID | - PS_REPORT_EVENT_ID | ROLE_STOP_COMPLETE_EVENT_ID | RSSI_SNR_TRIGGER_0_EVENT_ID | PSPOLL_DELIVERY_FAILURE_EVENT_ID | diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 1bcfb017058d..47cf80f0b036 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -867,13 +867,6 @@ struct conf_conn_settings { */ u8 ps_poll_threshold; - /* - * PS Poll failure recovery ACTIVE period length - * - * Range: u32 (ms) - */ - u32 ps_poll_recovery_period; - /* * Configuration of signal average weights. */ diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 15eb3a9c30ca..5e96e059f2b5 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -471,7 +471,6 @@ static ssize_t vifs_state_read(struct file *file, char __user *user_buf, 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); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index cfc38ea21e4a..05cd2ce927c6 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -30,133 +30,6 @@ #include "scan.h" #include "wl12xx_80211.h" -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); - 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"); - - mutex_lock(&wl->mutex); - - if (unlikely(wl->state == WL1271_STATE_OFF)) - goto out; - - if (!test_and_clear_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags)) - goto out; - - if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) - goto out; - - /* - * if we end up here, then we were in powersave when the pspoll - * delivery failure occurred, and no-one changed state since, so - * we should go back to powersave. - */ - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - - wl1271_ps_set_mode(wl, wlvif, 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, - struct wl12xx_vif *wlvif) -{ - int delay = wl->conf.conn.ps_poll_recovery_period; - int ret; - - wlvif->ps_poll_failures++; - if (wlvif->ps_poll_failures == 1) - wl1271_info("AP with dysfunctional ps-poll, " - "trying to work around it."); - - /* force active mode receive data from the AP */ - 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) - return; - set_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags); - ieee80211_queue_delayed_work(wl->hw, &wlvif->pspoll_work, - msecs_to_jiffies(delay)); - } - - /* - * If already in active mode, lets we should be getting data from - * the AP right away. If we enter PSM too fast after this, and data - * remains on the AP, we will get another event like this, and we'll - * go into active once more. - */ -} - -static int wl1271_event_ps_report(struct wl1271 *wl, - struct wl12xx_vif *wlvif, - struct event_mailbox *mbox, - bool *beacon_loss) -{ - int ret = 0; - u32 total_retries = wl->conf.conn.psm_entry_retries; - - wl1271_debug(DEBUG_EVENT, "ps_status: 0x%x", mbox->ps_status); - - switch (mbox->ps_status) { - case EVENT_ENTER_POWER_SAVE_FAIL: - wl1271_debug(DEBUG_PSM, "PSM entry failed"); - - if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { - /* remain in active mode */ - wlvif->psm_entry_retry = 0; - break; - } - - 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."); - wlvif->psm_entry_retry = 0; - *beacon_loss = true; - } - break; - case EVENT_ENTER_POWER_SAVE_SUCCESS: - wlvif->psm_entry_retry = 0; - - /* - * BET has only a minor effect in 5GHz and masks - * channel switch IEs, so we only enable BET on 2.4GHz - */ - if (wlvif->band == IEEE80211_BAND_2GHZ) - /* enable beacon early termination */ - ret = wl1271_acx_bet_enable(wl, wlvif, true); - - if (wlvif->ps_compl) { - complete(wlvif->ps_compl); - wlvif->ps_compl = NULL; - } - break; - default: - break; - } - - return ret; -} - static void wl1271_event_rssi_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct event_mailbox *mbox) @@ -237,7 +110,6 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) { struct ieee80211_vif *vif; struct wl12xx_vif *wlvif; - int ret; u32 vector; bool beacon_loss = false; bool disconnect_sta = false; @@ -293,21 +165,6 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) beacon_loss = true; } - if (vector & PS_REPORT_EVENT_ID) { - wl1271_debug(DEBUG_EVENT, "PS_REPORT_EVENT"); - 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) - 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"); diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/event.h index b41f730f11dd..057d193d3525 100644 --- a/drivers/net/wireless/wl12xx/event.h +++ b/drivers/net/wireless/wl12xx/event.h @@ -51,7 +51,7 @@ enum { SCAN_COMPLETE_EVENT_ID = BIT(10), WFD_DISCOVERY_COMPLETE_EVENT_ID = BIT(11), AP_DISCOVERY_COMPLETE_EVENT_ID = BIT(12), - PS_REPORT_EVENT_ID = BIT(13), + RESERVED1 = BIT(13), PSPOLL_DELIVERY_FAILURE_EVENT_ID = BIT(14), ROLE_STOP_COMPLETE_EVENT_ID = BIT(15), RADAR_DETECTED_EVENT_ID = BIT(16), @@ -96,7 +96,7 @@ struct event_mailbox { s8 rssi_snr_trigger_metric[NUM_OF_RSSI_SNR_TRIGGERS]; u8 change_auto_mode_timeout; u8 scheduled_scan_status; - u8 ps_status; + u8 reserved4; /* tuned channel (roc) */ u8 roc_channel; @@ -135,6 +135,5 @@ struct event_mailbox { int wl1271_event_unmask(struct wl1271 *wl); 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); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a339a85ecfb0..74d4abb25ab1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -235,7 +235,6 @@ static struct conf_drv_settings default_conf = { .broadcast_timeout = 20000, .rx_broadcast_in_ps = 1, .ps_poll_threshold = 10, - .ps_poll_recovery_period = 700, .bet_enable = CONF_BET_MODE_ENABLE, .bet_max_consecutive = 50, .psm_entry_retries = 8, @@ -1570,57 +1569,6 @@ static struct notifier_block wl1271_dev_notifier = { }; #ifdef CONFIG_PM -static int wl1271_configure_suspend_sta(struct wl1271 *wl, - struct wl12xx_vif *wlvif) -{ - int ret = 0; - - mutex_lock(&wl->mutex); - - if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) - goto out_unlock; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out_unlock; - - /* enter psm if needed*/ - if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { - DECLARE_COMPLETION_ONSTACK(compl); - - wlvif->ps_compl = &compl; - ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, - wlvif->basic_rate, true); - if (ret < 0) - goto out_sleep; - - /* we must unlock here so we will be able to get events */ - wl1271_ps_elp_sleep(wl); - mutex_unlock(&wl->mutex); - - 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_cleanup; - } - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out_cleanup; - } -out_sleep: - wl1271_ps_elp_sleep(wl); -out_cleanup: - wlvif->ps_compl = NULL; -out_unlock: - mutex_unlock(&wl->mutex); - return ret; - -} static int wl1271_configure_suspend_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -1648,8 +1596,6 @@ static int wl1271_configure_suspend_ap(struct wl1271 *wl, static int wl1271_configure_suspend(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - 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, wlvif); return 0; @@ -1659,10 +1605,9 @@ static void wl1271_configure_resume(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - 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) + if (!is_ap) return; mutex_lock(&wl->mutex); @@ -1670,14 +1615,7 @@ static void wl1271_configure_resume(struct wl1271 *wl, if (ret < 0) goto out; - if (is_sta) { - /* exit psm if it wasn't configured */ - 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) { - wl1271_acx_beacon_filter_opt(wl, wlvif, false); - } + wl1271_acx_beacon_filter_opt(wl, wlvif, false); wl1271_ps_elp_sleep(wl); out: @@ -1719,9 +1657,6 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, wl1271_enable_interrupts(wl); flush_work(&wl->tx_work); - wl12xx_for_each_wlvif(wl, wlvif) { - flush_delayed_work(&wlvif->pspoll_work); - } flush_delayed_work(&wl->elp_work); return 0; @@ -1994,7 +1929,6 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) 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, @@ -2278,10 +2212,10 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, 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); } @@ -2528,13 +2462,6 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, } } - /* - * if mac80211 changes the PSM mode, make sure the mode is not - * incorrectly changed after the pspoll failure active window. - */ - if (changed & IEEE80211_CONF_CHANGE_PS) - clear_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags); - if (conf->flags & IEEE80211_CONF_PS && !test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { set_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); @@ -3708,8 +3635,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wlvif->aid = bss_conf->aid; set_assoc = true; - wlvif->ps_poll_failures = 0; - /* * use basic rates from AP, and determine lowest rate * to use with control frames. diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b9bfbfffc5c0..e18e6160fdab 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -565,12 +565,6 @@ struct wl12xx_vif { /* Session counter for the chipset */ int session_counter; - 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; -- GitLab From f1d63a59635feef3481ed1972a883a5d6be7f9bb Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 31 Jan 2012 11:57:21 +0200 Subject: [PATCH 0740/1846] wl12xx: add support for HW dynamic PS FW now supports dynamic PS so we don't need to use mac80211 support. FW will go to PSM after a specified timeout with no Rx/Tx traffic. - Changed FW API to include new PS mode (AUTO_MODE) and including timeout parameter - The default PS mode would be dynamic PS - Default timeout is 100ms (same as it used to be in mac80211) - Avoid using mac80211 APIs to disable/enable dynamic PS as we're not using mac80211 PS control anymore. - COEX is handled by the FW while in dynamic PS so removed handling of SOFT_GEMINI Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 3 ++- drivers/net/wireless/wl12xx/cmd.h | 5 +++-- drivers/net/wireless/wl12xx/conf.h | 6 ++++++ drivers/net/wireless/wl12xx/event.c | 8 -------- drivers/net/wireless/wl12xx/main.c | 15 +++++---------- drivers/net/wireless/wl12xx/ps.c | 15 ++++++++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 88e94c5938a4..bf3c37bd1f12 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -996,7 +996,7 @@ int wl1271_cmd_data_path(struct wl1271 *wl, bool enable) } int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, - u8 ps_mode) + u8 ps_mode, u16 auto_ps_timeout) { struct wl1271_cmd_ps_params *ps_params = NULL; int ret = 0; @@ -1011,6 +1011,7 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, ps_params->role_id = wlvif->role_id; ps_params->ps_mode = ps_mode; + ps_params->auto_ps_timeout = auto_ps_timeout; ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params, sizeof(*ps_params), 0); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index edd240db0dcc..83a2a2edb261 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -51,7 +51,7 @@ 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, struct wl12xx_vif *wlvif, - u8 ps_mode); + u8 ps_mode, u16 auto_ps_timeout); int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, size_t len); int wl1271_cmd_template_set(struct wl1271 *wl, u8 role_id, @@ -400,6 +400,7 @@ struct wl1271_tim { } __packed; enum wl1271_cmd_ps_mode { + STATION_AUTO_PS_MODE, /* Dynamic Power Save */ STATION_ACTIVE_MODE, STATION_POWER_SAVE_MODE }; @@ -409,7 +410,7 @@ struct wl1271_cmd_ps_params { u8 role_id; u8 ps_mode; /* STATION_* */ - u8 padding[2]; + u16 auto_ps_timeout; } __packed; /* HW encryption keys */ diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 47cf80f0b036..10e5e3df4b95 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -914,6 +914,12 @@ struct conf_conn_settings { */ u8 psm_entry_nullfunc_retries; + /* + * Specifies the dynamic PS timeout in ms that will be used + * by the FW when in AUTO_PS mode + */ + u16 dynamic_ps_timeout; + /* * * Specifies the interval of the connection keep-alive null-func diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 05cd2ce927c6..c953717f38eb 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -78,21 +78,13 @@ 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 */ - 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 { 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); } } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 74d4abb25ab1..6b240868ac75 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1,3 +1,4 @@ + /* * This file is part of wl1271 * @@ -240,6 +241,7 @@ static struct conf_drv_settings default_conf = { .psm_entry_retries = 8, .psm_exit_retries = 16, .psm_entry_nullfunc_retries = 3, + .dynamic_ps_timeout = 100, .keep_alive_interval = 55000, .max_listen_interval = 20, }, @@ -2142,10 +2144,6 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, wl1271_info("down"); - /* 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(vif); - if (wl->scan.state != WL1271_SCAN_STATE_IDLE && wl->scan_vif == vif) { wl->scan.state = WL1271_SCAN_STATE_IDLE; @@ -3694,9 +3692,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, dev_kfree_skb(wlvif->probereq); wlvif->probereq = NULL; - /* re-enable dynamic ps - just in case */ - ieee80211_enable_dyn_ps(vif); - /* revert back to minimum rates for the current band */ wl1271_set_band_rate(wl, wlvif); wlvif->basic_rate = @@ -3827,10 +3822,9 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, /* If we want to go in PSM but we're not there yet */ 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; - ret = wl1271_ps_set_mode(wl, wlvif, mode, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_AUTO_PS_MODE, wlvif->basic_rate, true); if (ret < 0) @@ -4976,6 +4970,7 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SUPPORTS_PS | + IEEE80211_HW_SUPPORTS_DYNAMIC_PS | IEEE80211_HW_SUPPORTS_UAPSD | IEEE80211_HW_HAS_RATE_CONTROL | IEEE80211_HW_CONNECTION_MONITOR | diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index a2bdacdd7e1d..60f03c4dfbe7 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -163,10 +163,12 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum wl1271_cmd_ps_mode mode, u32 rates, bool send) { int ret; + u16 timeout = wl->conf.conn.dynamic_ps_timeout; switch (mode) { - case STATION_POWER_SAVE_MODE: - wl1271_debug(DEBUG_PSM, "entering psm"); + case STATION_AUTO_PS_MODE: + wl1271_debug(DEBUG_PSM, "entering psm (mode=%d,timeout=%u)", + mode, timeout); ret = wl1271_acx_wake_up_conditions(wl, wlvif); if (ret < 0) { @@ -174,14 +176,13 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; } - ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_POWER_SAVE_MODE); + ret = wl1271_cmd_ps_mode(wl, wlvif, mode, timeout); if (ret < 0) return ret; set_bit(WLVIF_FLAG_PSM, &wlvif->flags); break; case STATION_ACTIVE_MODE: - default: wl1271_debug(DEBUG_PSM, "leaving psm"); /* disable beacon early termination */ @@ -191,12 +192,16 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; } - ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_ACTIVE_MODE); + ret = wl1271_cmd_ps_mode(wl, wlvif, mode, 0); if (ret < 0) return ret; clear_bit(WLVIF_FLAG_PSM, &wlvif->flags); break; + case STATION_POWER_SAVE_MODE: + default: + wl1271_warning("trying to set ps to unsupported mode %d", mode); + ret = -EINVAL; } return ret; -- GitLab From 1faff895df6a5213ee16a241951dc79c7ec5b5cb Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 31 Jan 2012 11:57:22 +0200 Subject: [PATCH 0741/1846] wl12xx: add dynamic_ps_timeout debugfs file Enable read/write of dynamic_ps_timeout which controls the timeout of the dynamic PS implemented in the FW. dynamic_ps_timeout is the timeout (in msec) until going back to PS when there's no Rx/Tx Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 5e96e059f2b5..156a7741df34 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -312,6 +312,72 @@ static const struct file_operations start_recovery_ops = { .llseek = default_llseek, }; +static ssize_t dynamic_ps_timeout_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + + return wl1271_format_buffer(user_buf, count, + ppos, "%d\n", + wl->conf.conn.dynamic_ps_timeout); +} + +static ssize_t dynamic_ps_timeout_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; + unsigned long value; + int ret; + + ret = kstrtoul_from_user(user_buf, count, 10, &value); + if (ret < 0) { + wl1271_warning("illegal value in dynamic_ps"); + return -EINVAL; + } + + if (value < 1 || value > 65535) { + wl1271_warning("dyanmic_ps_timeout is not in valid range"); + return -ERANGE; + } + + mutex_lock(&wl->mutex); + + wl->conf.conn.dynamic_ps_timeout = value; + + if (wl->state == WL1271_STATE_OFF) + goto out; + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + /* In case we're already in PSM, trigger it again to set new timeout + * immediately without waiting for re-association + */ + + wl12xx_for_each_wlvif_sta(wl, wlvif) { + if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) + wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE, + wlvif->basic_rate, true); + + } + + wl1271_ps_elp_sleep(wl); + +out: + mutex_unlock(&wl->mutex); + return count; +} + +static const struct file_operations dynamic_ps_timeout_ops = { + .read = dynamic_ps_timeout_read, + .write = dynamic_ps_timeout_write, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + static ssize_t driver_state_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -887,6 +953,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(dtim_interval, rootdir); DEBUGFS_ADD(beacon_interval, rootdir); DEBUGFS_ADD(beacon_filtering, rootdir); + DEBUGFS_ADD(dynamic_ps_timeout, rootdir); streaming = debugfs_create_dir("rx_streaming", rootdir); if (!streaming || IS_ERR(streaming)) -- GitLab From 248a0018f365c1fa51aa381e7b6f6e97eacf61ff Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 31 Jan 2012 11:57:23 +0200 Subject: [PATCH 0742/1846] wl12xx: remove 2 unused parameters in wl1271_ps_set_mode() cleanup 2 unused parameters of wl1271_ps_set_mode Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 4 +--- drivers/net/wireless/wl12xx/main.c | 10 +++------- drivers/net/wireless/wl12xx/ps.c | 2 +- drivers/net/wireless/wl12xx/ps.h | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 156a7741df34..4436851a4fa7 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -359,9 +359,7 @@ static ssize_t dynamic_ps_timeout_write(struct file *file, wl12xx_for_each_wlvif_sta(wl, wlvif) { if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) - wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE, - wlvif->basic_rate, true); - + wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 6b240868ac75..97f7591c3b39 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2472,8 +2472,7 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, 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, - wlvif->basic_rate, true); + STATION_AUTO_PS_MODE); } } else if (!(conf->flags & IEEE80211_CONF_PS) && test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { @@ -2483,8 +2482,7 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) ret = wl1271_ps_set_mode(wl, wlvif, - STATION_ACTIVE_MODE, - wlvif->basic_rate, true); + STATION_ACTIVE_MODE); } if (conf->power_level != wlvif->power_level) { @@ -3824,9 +3822,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, !test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { ret = wl1271_ps_set_mode(wl, wlvif, - STATION_AUTO_PS_MODE, - wlvif->basic_rate, - true); + STATION_AUTO_PS_MODE); if (ret < 0) goto out; } diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 60f03c4dfbe7..5074c2af17c0 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -160,7 +160,7 @@ int wl1271_ps_elp_wakeup(struct wl1271 *wl) } int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, - enum wl1271_cmd_ps_mode mode, u32 rates, bool send) + enum wl1271_cmd_ps_mode mode) { int ret; u16 timeout = wl->conf.conn.dynamic_ps_timeout; diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/ps.h index a12052f02026..5f19d4fbbf27 100644 --- a/drivers/net/wireless/wl12xx/ps.h +++ b/drivers/net/wireless/wl12xx/ps.h @@ -28,7 +28,7 @@ #include "acx.h" int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, - enum wl1271_cmd_ps_mode mode, u32 rates, bool send); + enum wl1271_cmd_ps_mode mode); void wl1271_ps_elp_sleep(struct wl1271 *wl); int wl1271_ps_elp_wakeup(struct wl1271 *wl); void wl1271_elp_work(struct work_struct *work); -- GitLab From ed471d3402b0fa77e52007c6f8d79b16c4194000 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 31 Jan 2012 11:57:24 +0200 Subject: [PATCH 0743/1846] wl12xx: enable/disable BET with AUTO_PS/ACTIVE While the FW with dynamic PS controls BET when going to PSM and back internally within the FW, there's still a need to enable it from the driver at least once (so enable on every entry to AUTO_PS) and disable it once we explicitly go back to STATION_ACTIVE_MODE. BET isn't relevant for 5GHz Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/ps.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 5074c2af17c0..d7a91d3c398d 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -181,6 +181,13 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; set_bit(WLVIF_FLAG_PSM, &wlvif->flags); + + /* enable beacon early termination. Not relevant for 5GHz */ + if (wlvif->band == IEEE80211_BAND_2GHZ) { + ret = wl1271_acx_bet_enable(wl, wlvif, true); + if (ret < 0) + return ret; + } break; case STATION_ACTIVE_MODE: wl1271_debug(DEBUG_PSM, "leaving psm"); -- GitLab From d18da7fcca449f09c91a209b4f5006959c5a7656 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 31 Jan 2012 11:57:25 +0200 Subject: [PATCH 0744/1846] wl12xx: change WLVIF_FLAG_PSM name and remove WLVIF_FLAG_PSM_REQUESTED WLVIF_FLAG_PSM turned to WLVIF_FLAG_IN_AUTO_PS which marks that this vif is in AUTO PS. WLVIF_FLAG_PSM_REQUESTED is not required as mac80211 calls op_config with CONF_PS after association. wl12xx_config_vif() handling of CONF_PS was simplified and cleaned up. Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 2 +- drivers/net/wireless/wl12xx/main.c | 46 ++++++++++----------------- drivers/net/wireless/wl12xx/ps.c | 8 ++--- drivers/net/wireless/wl12xx/wl12xx.h | 3 +- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 4436851a4fa7..4dcb3f758fe2 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -358,7 +358,7 @@ static ssize_t dynamic_ps_timeout_write(struct file *file, */ wl12xx_for_each_wlvif_sta(wl, wlvif) { - if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) + if (test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags)) wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE); } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 97f7591c3b39..4ca7278201ec 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1715,9 +1715,7 @@ static int wl1271_op_start(struct ieee80211_hw *hw) * is added. That is where we will initialize the hardware. */ - wl1271_error("wl12xx is in an ustable state (fw api update is " - "taking place). skip this commit when bisecting"); - return -EBUSY; + return 0; } static void wl1271_op_stop(struct ieee80211_hw *hw) @@ -2460,29 +2458,29 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, } } - if (conf->flags & IEEE80211_CONF_PS && - !test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { - set_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); + if ((changed & IEEE80211_CONF_CHANGE_PS) && !is_ap) { + + if ((conf->flags & IEEE80211_CONF_PS) && + test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && + !test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags)) { + + wl1271_debug(DEBUG_PSM, "auto ps enabled"); - /* - * We enter PSM only if we're already associated. - * If we're not, we'll enter it when joining an SSID, - * through the bss_info_changed() hook. - */ - if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { - wl1271_debug(DEBUG_PSM, "psm enabled"); ret = wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE); - } - } else if (!(conf->flags & IEEE80211_CONF_PS) && - test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { - wl1271_debug(DEBUG_PSM, "psm disabled"); + if (ret < 0) + wl1271_warning("enter auto ps failed %d", ret); - clear_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); + } else if (!(conf->flags & IEEE80211_CONF_PS) && + test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags)) { + + wl1271_debug(DEBUG_PSM, "auto ps disabled"); - if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE); + if (ret < 0) + wl1271_warning("exit auto ps failed %d", ret); + } } if (conf->power_level != wlvif->power_level) { @@ -3816,16 +3814,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (ret < 0) goto out; } - - /* If we want to go in PSM but we're not there yet */ - if (test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags) && - !test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { - - ret = wl1271_ps_set_mode(wl, wlvif, - STATION_AUTO_PS_MODE); - if (ret < 0) - goto out; - } } /* Handle new association with HT. Do this after join. */ diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index d7a91d3c398d..e209e29ffb45 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -56,7 +56,7 @@ void wl1271_elp_work(struct work_struct *work) if (wlvif->bss_type == BSS_TYPE_AP_BSS) goto out; - if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) && + if (!test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags) && test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) goto out; } @@ -84,7 +84,7 @@ void wl1271_ps_elp_sleep(struct wl1271 *wl) if (wlvif->bss_type == BSS_TYPE_AP_BSS) return; - if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) && + if (!test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags) && test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) return; } @@ -180,7 +180,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - set_bit(WLVIF_FLAG_PSM, &wlvif->flags); + set_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags); /* enable beacon early termination. Not relevant for 5GHz */ if (wlvif->band == IEEE80211_BAND_2GHZ) { @@ -203,7 +203,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - clear_bit(WLVIF_FLAG_PSM, &wlvif->flags); + clear_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags); break; case STATION_POWER_SAVE_MODE: default: diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index e18e6160fdab..9baed6be6a31 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -254,8 +254,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, - WLVIF_FLAG_PSM, - WLVIF_FLAG_PSM_REQUESTED, + WLVIF_FLAG_IN_AUTO_PS, WLVIF_FLAG_STA_STATE_SENT, WLVIF_FLAG_RX_STREAMING_STARTED, WLVIF_FLAG_PSPOLL_FAILURE, -- GitLab From d2e2d769e3d328ba7cbf08e8ed85e3f817915843 Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Tue, 31 Jan 2012 17:54:40 +0200 Subject: [PATCH 0745/1846] wl12xx: Set IEEE80211_TX_RC_MCS on MCS rates on TX complete. IEEE80211_TX_RC_MCS was not set correctly leading to incorrect link speed calculation. Signed-off-by: Pontus Fuchs Signed-off-by: Ido Reis Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/conf.h | 4 ++++ drivers/net/wireless/wl12xx/tx.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 10e5e3df4b95..209f05312909 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -91,6 +91,10 @@ enum { CONF_HW_RXTX_RATE_UNSUPPORTED = 0xff }; +/* Rates between and including these are MCS rates */ +#define CONF_HW_RXTX_RATE_MCS_MIN CONF_HW_RXTX_RATE_MCS7 +#define CONF_HW_RXTX_RATE_MCS_MAX CONF_HW_RXTX_RATE_MCS0 + enum { CONF_SG_DISABLE = 0, CONF_SG_PROTECTIVE, diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 2bf43b86a3f9..f95112f6769f 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -764,6 +764,14 @@ void wl1271_tx_work(struct work_struct *work) mutex_unlock(&wl->mutex); } +static u8 wl1271_tx_get_rate_flags(u8 rate_class_index) +{ + if (rate_class_index >= CONF_HW_RXTX_RATE_MCS_MIN && + rate_class_index <= CONF_HW_RXTX_RATE_MCS_MAX) + return IEEE80211_TX_RC_MCS; + return 0; +} + static void wl1271_tx_complete_packet(struct wl1271 *wl, struct wl1271_tx_hw_res_descr *result) { @@ -773,6 +781,7 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, struct sk_buff *skb; int id = result->id; int rate = -1; + u8 rate_flags = 0; u8 retries = 0; /* check for id legality */ @@ -799,6 +808,7 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, info->flags |= IEEE80211_TX_STAT_ACK; rate = wl1271_rate_to_idx(result->rate_class_index, wlvif->band); + rate_flags = wl1271_tx_get_rate_flags(result->rate_class_index); retries = result->ack_failures; } else if (result->status == TX_RETRY_EXCEEDED) { wl->stats.excessive_retries++; @@ -807,7 +817,7 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, info->status.rates[0].idx = rate; info->status.rates[0].count = retries; - info->status.rates[0].flags = 0; + info->status.rates[0].flags = rate_flags; info->status.ack_signal = -1; wl->stats.retry_count += result->ack_failures; -- GitLab From defe02c720d54fc9bda3e5e625be70adac347a61 Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Tue, 31 Jan 2012 17:54:41 +0200 Subject: [PATCH 0746/1846] wl12xx: Set IEEE80211_TX_RC_SHORT_GI if short GI was used on New FW reports usage of short GI as a rate class index. Check for this rate and set the IEEE80211_TX_RC_SHORT_GI if used. Signed-off-by: Pontus Fuchs Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/conf.h | 5 +++-- drivers/net/wireless/wl12xx/main.c | 2 ++ drivers/net/wireless/wl12xx/tx.c | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 209f05312909..1147396bf7eb 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -66,7 +66,8 @@ enum { }; enum { - CONF_HW_RXTX_RATE_MCS7 = 0, + CONF_HW_RXTX_RATE_MCS7_SGI = 0, + CONF_HW_RXTX_RATE_MCS7, CONF_HW_RXTX_RATE_MCS6, CONF_HW_RXTX_RATE_MCS5, CONF_HW_RXTX_RATE_MCS4, @@ -92,7 +93,7 @@ enum { }; /* Rates between and including these are MCS rates */ -#define CONF_HW_RXTX_RATE_MCS_MIN CONF_HW_RXTX_RATE_MCS7 +#define CONF_HW_RXTX_RATE_MCS_MIN CONF_HW_RXTX_RATE_MCS7_SGI #define CONF_HW_RXTX_RATE_MCS_MAX CONF_HW_RXTX_RATE_MCS0 enum { diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 4ca7278201ec..fa2bf307aa0d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4406,6 +4406,7 @@ static struct ieee80211_channel wl1271_channels[] = { /* mapping to indexes for wl1271_rates */ static const u8 wl1271_rate_to_idx_2ghz[] = { /* MCS rates are used only with 11n */ + 7, /* CONF_HW_RXTX_RATE_MCS7_SGI */ 7, /* CONF_HW_RXTX_RATE_MCS7 */ 6, /* CONF_HW_RXTX_RATE_MCS6 */ 5, /* CONF_HW_RXTX_RATE_MCS5 */ @@ -4527,6 +4528,7 @@ static struct ieee80211_channel wl1271_channels_5ghz[] = { /* mapping to indexes for wl1271_rates_5ghz */ static const u8 wl1271_rate_to_idx_5ghz[] = { /* MCS rates are used only with 11n */ + 7, /* CONF_HW_RXTX_RATE_MCS7_SGI */ 7, /* CONF_HW_RXTX_RATE_MCS7 */ 6, /* CONF_HW_RXTX_RATE_MCS6 */ 5, /* CONF_HW_RXTX_RATE_MCS5 */ diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index f95112f6769f..ee313e7ce8fe 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -766,10 +766,14 @@ void wl1271_tx_work(struct work_struct *work) static u8 wl1271_tx_get_rate_flags(u8 rate_class_index) { + u8 flags = 0; + if (rate_class_index >= CONF_HW_RXTX_RATE_MCS_MIN && rate_class_index <= CONF_HW_RXTX_RATE_MCS_MAX) - return IEEE80211_TX_RC_MCS; - return 0; + flags |= IEEE80211_TX_RC_MCS; + if (rate_class_index == CONF_HW_RXTX_RATE_MCS7_SGI) + flags |= IEEE80211_TX_RC_SHORT_GI; + return flags; } static void wl1271_tx_complete_packet(struct wl1271 *wl, -- GitLab From f4f57943f265d80fe5f0fedf6964f8056e753cf3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 31 Jan 2012 17:54:42 +0200 Subject: [PATCH 0747/1846] wl12xx: add TX_HW_ATTR_HOST_ENCRYPT flag In WEP shared authentication, we encrypt the auth frame in the host, and we want the fw to pass it as-is. Use the TX_HW_ATTR_HOST_ENCRYPT flag in order to indicate it to the fw. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 17 +++++++++++++---- drivers/net/wireless/wl12xx/tx.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index ee313e7ce8fe..1f5cc2af5bc6 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -255,16 +255,20 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, int aligned_len, ac, rate_idx; s64 hosttime; u16 tx_attr = 0; + __le16 frame_control; + struct ieee80211_hdr *hdr; + u8 *frame_start; bool is_dummy; desc = (struct wl1271_tx_hw_descr *) skb->data; + frame_start = (u8 *)(desc + 1); + hdr = (struct ieee80211_hdr *)(frame_start + extra); + frame_control = hdr->frame_control; /* relocate space for security header */ if (extra) { - void *framestart = skb->data + sizeof(*desc); - u16 fc = *(u16 *)(framestart + extra); - int hdrlen = ieee80211_hdrlen(cpu_to_le16(fc)); - memmove(framestart, framestart + extra, hdrlen); + int hdrlen = ieee80211_hdrlen(frame_control); + memmove(frame_start, hdr, hdrlen); } /* configure packet life time */ @@ -353,6 +357,11 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, desc->wl127x_mem.total_mem_blocks); } + /* for WEP shared auth - no fw encryption is needed */ + if (ieee80211_is_auth(frame_control) && + ieee80211_has_protected(frame_control)) + tx_attr |= TX_HW_ATTR_HOST_ENCRYPT; + desc->tx_attr = cpu_to_le16(tx_attr); } diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 2dbb24e6d541..7ceb3ceaa648 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -39,6 +39,7 @@ #define TX_HW_ATTR_LAST_WORD_PAD (BIT(10) | BIT(11)) #define TX_HW_ATTR_TX_CMPLT_REQ BIT(12) #define TX_HW_ATTR_TX_DUMMY_REQ BIT(13) +#define TX_HW_ATTR_HOST_ENCRYPT BIT(14) #define TX_HW_ATTR_OFST_SAVE_RETRIES 0 #define TX_HW_ATTR_OFST_HEADER_PAD 1 -- GitLab From 26612c435b34bd99fdf79f5c1d8826ebd0ea86f3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 31 Jan 2012 17:54:43 +0200 Subject: [PATCH 0748/1846] wl12xx: add new coex params new params were added to the coex params. Add them with default value of 0. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/conf.h | 4 ++++ drivers/net/wireless/wl12xx/main.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 1147396bf7eb..18637eec1e21 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -317,6 +317,10 @@ enum { CONF_AP_BT_ACL_VAL_BT_SERVE_TIME, CONF_AP_BT_ACL_VAL_WL_SERVE_TIME, + /* CTS Diluting params */ + CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH, + CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER, + CONF_SG_TEMP_PARAM_1, CONF_SG_TEMP_PARAM_2, CONF_SG_TEMP_PARAM_3, diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fa2bf307aa0d..aa5d512c8f82 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -116,6 +116,9 @@ static struct conf_drv_settings default_conf = { [CONF_AP_CONNECTION_PROTECTION_TIME] = 0, [CONF_AP_BT_ACL_VAL_BT_SERVE_TIME] = 25, [CONF_AP_BT_ACL_VAL_WL_SERVE_TIME] = 25, + /* CTS Diluting params */ + [CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH] = 0, + [CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER] = 0, }, .state = CONF_SG_PROTECTIVE, }, -- GitLab From dae728fe67c7c5ab10f91366bd9d1f8db203e123 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Thu, 2 Feb 2012 12:03:39 +0200 Subject: [PATCH 0749/1846] wl12xx: Set different wake up conditions in case of suspend Added ability to set different wake up conditions for suspend/resume. Set default values to wake up every 3 DTIMs while suspended and every 1 DTIM while resumed Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 10 +++--- drivers/net/wireless/wl12xx/acx.h | 3 +- drivers/net/wireless/wl12xx/conf.h | 13 ++++++++ drivers/net/wireless/wl12xx/main.c | 51 ++++++++++++++++++++++++++++-- drivers/net/wireless/wl12xx/ps.c | 4 ++- 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index af2c3123d1d7..bc96db0683a5 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -34,12 +34,14 @@ #include "reg.h" #include "ps.h" -int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif) +int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 wake_up_event, u8 listen_interval) { struct acx_wake_up_condition *wake_up; int ret; - wl1271_debug(DEBUG_ACX, "acx wake up conditions"); + wl1271_debug(DEBUG_ACX, "acx wake up conditions (wake_up_event %d listen_interval %d)", + wake_up_event, listen_interval); wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL); if (!wake_up) { @@ -48,8 +50,8 @@ int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif) } 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; + wake_up->wake_up_event = wake_up_event; + wake_up->listen_interval = listen_interval; ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS, wake_up, sizeof(*wake_up)); diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 0749df58c85d..a28fc044034c 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1226,7 +1226,8 @@ enum { int wl1271_acx_wake_up_conditions(struct wl1271 *wl, - struct wl12xx_vif *wlvif); + struct wl12xx_vif *wlvif, + u8 wake_up_event, u8 listen_interval); int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth); int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif, int power); diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 18637eec1e21..80eafadc389d 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -818,6 +818,19 @@ struct conf_conn_settings { */ u8 listen_interval; + /* + * Firmware wakeup conditions during suspend + * Range: CONF_WAKE_UP_EVENT_* + */ + u8 suspend_wake_up_event; + + /* + * Listen interval during suspend. + * Currently will be in DTIMs (1-10) + * + */ + u8 suspend_listen_interval; + /* * Enable or disable the beacon filtering. * diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index aa5d512c8f82..fa61dfd2084c 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -221,6 +221,8 @@ static struct conf_drv_settings default_conf = { .conn = { .wake_up_event = CONF_WAKE_UP_EVENT_DTIM, .listen_interval = 1, + .suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM, + .suspend_listen_interval = 3, .bcn_filt_mode = CONF_BCN_FILT_MODE_ENABLED, .bcn_filt_ie_count = 2, .bcn_filt_ie = { @@ -1574,6 +1576,35 @@ static struct notifier_block wl1271_dev_notifier = { }; #ifdef CONFIG_PM +static int wl1271_configure_suspend_sta(struct wl1271 *wl, + struct wl12xx_vif *wlvif) +{ + int ret = 0; + + mutex_lock(&wl->mutex); + + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) + goto out_unlock; + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out_unlock; + + ret = wl1271_acx_wake_up_conditions(wl, wlvif, + wl->conf.conn.suspend_wake_up_event, + wl->conf.conn.suspend_listen_interval); + + if (ret < 0) + wl1271_error("suspend: set wake up conditions failed: %d", ret); + + + wl1271_ps_elp_sleep(wl); + +out_unlock: + mutex_unlock(&wl->mutex); + return ret; + +} static int wl1271_configure_suspend_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -1601,6 +1632,8 @@ static int wl1271_configure_suspend_ap(struct wl1271 *wl, static int wl1271_configure_suspend(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + 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, wlvif); return 0; @@ -1609,10 +1642,11 @@ static int wl1271_configure_suspend(struct wl1271 *wl, static void wl1271_configure_resume(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - int ret; + int ret = 0; bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS; + bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; - if (!is_ap) + if ((!is_ap) && (!is_sta)) return; mutex_lock(&wl->mutex); @@ -1620,7 +1654,18 @@ static void wl1271_configure_resume(struct wl1271 *wl, if (ret < 0) goto out; - wl1271_acx_beacon_filter_opt(wl, wlvif, false); + if (is_sta) { + ret = wl1271_acx_wake_up_conditions(wl, wlvif, + wl->conf.conn.wake_up_event, + wl->conf.conn.listen_interval); + + if (ret < 0) + wl1271_error("resume: wake up conditions failed: %d", + ret); + + } else if (is_ap) { + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); + } wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index e209e29ffb45..d1979223ad28 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -170,7 +170,9 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_debug(DEBUG_PSM, "entering psm (mode=%d,timeout=%u)", mode, timeout); - ret = wl1271_acx_wake_up_conditions(wl, wlvif); + ret = wl1271_acx_wake_up_conditions(wl, wlvif, + wl->conf.conn.wake_up_event, + wl->conf.conn.listen_interval); if (ret < 0) { wl1271_error("couldn't set wake up conditions"); return ret; -- GitLab From 59a10c66d0a1970d3f8a7e65bb1f03dec3aae3c5 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Thu, 2 Feb 2012 12:03:40 +0200 Subject: [PATCH 0750/1846] wl12xx: add suspend_listen_interval debugfs file Add read/write to suspend_dtim_interval file which controls the number of DTIM periods between wakeups while the host is suspended. The value while the host is resumed is controlled by the file dtim_interval which existed previously. Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 4dcb3f758fe2..15353fac0707 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -625,6 +625,64 @@ static const struct file_operations dtim_interval_ops = { .llseek = default_llseek, }; + + +static ssize_t suspend_dtim_interval_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + u8 value; + + if (wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_DTIM || + wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM) + value = wl->conf.conn.suspend_listen_interval; + else + value = 0; + + return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value); +} + +static ssize_t suspend_dtim_interval_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + unsigned long value; + int ret; + + ret = kstrtoul_from_user(user_buf, count, 10, &value); + if (ret < 0) { + wl1271_warning("illegal value for suspend_dtim_interval"); + return -EINVAL; + } + + if (value < 1 || value > 10) { + wl1271_warning("suspend_dtim value is not in valid range"); + return -ERANGE; + } + + mutex_lock(&wl->mutex); + + wl->conf.conn.suspend_listen_interval = value; + /* for some reason there are different event types for 1 and >1 */ + if (value == 1) + wl->conf.conn.suspend_wake_up_event = CONF_WAKE_UP_EVENT_DTIM; + else + wl->conf.conn.suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM; + + mutex_unlock(&wl->mutex); + return count; +} + + +static const struct file_operations suspend_dtim_interval_ops = { + .read = suspend_dtim_interval_read, + .write = suspend_dtim_interval_write, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + static ssize_t beacon_interval_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -949,6 +1007,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(driver_state, rootdir); DEBUGFS_ADD(vifs_state, rootdir); DEBUGFS_ADD(dtim_interval, rootdir); + DEBUGFS_ADD(suspend_dtim_interval, rootdir); DEBUGFS_ADD(beacon_interval, rootdir); DEBUGFS_ADD(beacon_filtering, rootdir); DEBUGFS_ADD(dynamic_ps_timeout, rootdir); -- GitLab From 5c0dc2fcfec606cf9f2d28ff31bbeb0a6225b27a Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Thu, 2 Feb 2012 19:06:45 +0200 Subject: [PATCH 0751/1846] wl12xx: add forced_ps mode For certain WiFi certification tests forcing PS is necessary. Since DPS is now enabled in the FW and this can't be achieved by using netlatency this required a new config option. Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/conf.h | 6 ++++++ drivers/net/wireless/wl12xx/debugfs.c | 2 +- drivers/net/wireless/wl12xx/main.c | 25 +++++++++++++++++++------ drivers/net/wireless/wl12xx/ps.c | 10 +++++----- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 80eafadc389d..823535cdf150 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -942,6 +942,12 @@ struct conf_conn_settings { */ u16 dynamic_ps_timeout; + /* + * Specifies whether dynamic PS should be disabled and PSM forced. + * This is required for certain WiFi certification tests. + */ + u8 forced_ps; + /* * * Specifies the interval of the connection keep-alive null-func diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 15353fac0707..02da445ea98a 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -358,7 +358,7 @@ static ssize_t dynamic_ps_timeout_write(struct file *file, */ wl12xx_for_each_wlvif_sta(wl, wlvif) { - if (test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags)) + if (test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE); } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fa61dfd2084c..b828149a1655 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -247,6 +247,7 @@ static struct conf_drv_settings default_conf = { .psm_exit_retries = 16, .psm_entry_nullfunc_retries = 3, .dynamic_ps_timeout = 100, + .forced_ps = false, .keep_alive_interval = 55000, .max_listen_interval = 20, }, @@ -2510,17 +2511,29 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, if ((conf->flags & IEEE80211_CONF_PS) && test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && - !test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags)) { + !test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) { - wl1271_debug(DEBUG_PSM, "auto ps enabled"); + int ps_mode; + char *ps_mode_str; + + if (wl->conf.conn.forced_ps) { + ps_mode = STATION_POWER_SAVE_MODE; + ps_mode_str = "forced"; + } else { + ps_mode = STATION_AUTO_PS_MODE; + ps_mode_str = "auto"; + } + + wl1271_debug(DEBUG_PSM, "%s ps enabled", ps_mode_str); + + ret = wl1271_ps_set_mode(wl, wlvif, ps_mode); - ret = wl1271_ps_set_mode(wl, wlvif, - STATION_AUTO_PS_MODE); if (ret < 0) - wl1271_warning("enter auto ps failed %d", ret); + wl1271_warning("enter %s ps failed %d", + ps_mode_str, ret); } else if (!(conf->flags & IEEE80211_CONF_PS) && - test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags)) { + test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) { wl1271_debug(DEBUG_PSM, "auto ps disabled"); diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index d1979223ad28..23d67501c50a 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -56,7 +56,7 @@ void wl1271_elp_work(struct work_struct *work) if (wlvif->bss_type == BSS_TYPE_AP_BSS) goto out; - if (!test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags) && + if (!test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags) && test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) goto out; } @@ -84,7 +84,7 @@ void wl1271_ps_elp_sleep(struct wl1271 *wl) if (wlvif->bss_type == BSS_TYPE_AP_BSS) return; - if (!test_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags) && + if (!test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags) && test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) return; } @@ -167,6 +167,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, switch (mode) { case STATION_AUTO_PS_MODE: + case STATION_POWER_SAVE_MODE: wl1271_debug(DEBUG_PSM, "entering psm (mode=%d,timeout=%u)", mode, timeout); @@ -182,7 +183,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - set_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags); + set_bit(WLVIF_FLAG_IN_PS, &wlvif->flags); /* enable beacon early termination. Not relevant for 5GHz */ if (wlvif->band == IEEE80211_BAND_2GHZ) { @@ -205,9 +206,8 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - clear_bit(WLVIF_FLAG_IN_AUTO_PS, &wlvif->flags); + clear_bit(WLVIF_FLAG_IN_PS, &wlvif->flags); break; - case STATION_POWER_SAVE_MODE: default: wl1271_warning("trying to set ps to unsupported mode %d", mode); ret = -EINVAL; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9baed6be6a31..61c58c13fa90 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -254,7 +254,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, - WLVIF_FLAG_IN_AUTO_PS, + WLVIF_FLAG_IN_PS, WLVIF_FLAG_STA_STATE_SENT, WLVIF_FLAG_RX_STREAMING_STARTED, WLVIF_FLAG_PSPOLL_FAILURE, -- GitLab From 20ae7e5e4b13937da6882bf84b080eb31feb9a7b Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Thu, 2 Feb 2012 12:03:42 +0200 Subject: [PATCH 0752/1846] wl12xx: add forced_ps debugfs file Added control over forced_ps option through debugfs. This can be either 1 or 0. Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 02da445ea98a..1c2623850eae 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -376,6 +376,75 @@ static const struct file_operations dynamic_ps_timeout_ops = { .llseek = default_llseek, }; +static ssize_t forced_ps_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + + return wl1271_format_buffer(user_buf, count, + ppos, "%d\n", + wl->conf.conn.forced_ps); +} + +static ssize_t forced_ps_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; + unsigned long value; + int ret, ps_mode; + + ret = kstrtoul_from_user(user_buf, count, 10, &value); + if (ret < 0) { + wl1271_warning("illegal value in forced_ps"); + return -EINVAL; + } + + if (value != 1 && value != 0) { + wl1271_warning("forced_ps should be either 0 or 1"); + return -ERANGE; + } + + mutex_lock(&wl->mutex); + + if (wl->conf.conn.forced_ps == value) + goto out; + + wl->conf.conn.forced_ps = value; + + if (wl->state == WL1271_STATE_OFF) + goto out; + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + /* In case we're already in PSM, trigger it again to switch mode + * immediately without waiting for re-association + */ + + ps_mode = value ? STATION_POWER_SAVE_MODE : STATION_AUTO_PS_MODE; + + wl12xx_for_each_wlvif_sta(wl, wlvif) { + if (test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) + wl1271_ps_set_mode(wl, wlvif, ps_mode); + } + + wl1271_ps_elp_sleep(wl); + +out: + mutex_unlock(&wl->mutex); + return count; +} + +static const struct file_operations forced_ps_ops = { + .read = forced_ps_read, + .write = forced_ps_write, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + static ssize_t driver_state_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1011,6 +1080,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(beacon_interval, rootdir); DEBUGFS_ADD(beacon_filtering, rootdir); DEBUGFS_ADD(dynamic_ps_timeout, rootdir); + DEBUGFS_ADD(forced_ps, rootdir); streaming = debugfs_create_dir("rx_streaming", rootdir); if (!streaming || IS_ERR(streaming)) -- GitLab From 5ec8a448e0e978103bc5ca7136084b5e2b36989e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 2 Feb 2012 12:22:09 +0200 Subject: [PATCH 0753/1846] wl12xx: consider encryption and QoS in auto arp template When configuring the arp response template, and encryption is enabled, we should add some space and set the protected flag bit in the fc. In order to track the encryption type, set wlvif->encryption_type when setting an encryption key, and reconfigure the arp response. Clear this field on wl1271_join, as keys have to be re-configured anyway after a join command. Similarly, track whether QoS is configured. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 88 +++++++++++++++++----- drivers/net/wireless/wl12xx/cmd.h | 3 +- drivers/net/wireless/wl12xx/debugfs.c | 1 + drivers/net/wireless/wl12xx/init.c | 6 +- drivers/net/wireless/wl12xx/main.c | 31 +++++++- drivers/net/wireless/wl12xx/tx.c | 11 +-- drivers/net/wireless/wl12xx/tx.h | 4 +- drivers/net/wireless/wl12xx/wl12xx.h | 6 ++ drivers/net/wireless/wl12xx/wl12xx_80211.h | 2 +- 9 files changed, 117 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index bf3c37bd1f12..b776d9d5efe8 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1213,32 +1213,34 @@ struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, return skb; } -int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, - __be32 ip_addr) +int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - int ret; + int ret, extra; + u16 fc; struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); - struct wl12xx_arp_rsp_template tmpl; + struct sk_buff *skb; + struct wl12xx_arp_rsp_template *tmpl; struct ieee80211_hdr_3addr *hdr; struct arphdr *arp_hdr; - memset(&tmpl, 0, sizeof(tmpl)); + skb = dev_alloc_skb(sizeof(*hdr) + sizeof(__le16) + sizeof(*tmpl) + + WL1271_EXTRA_SPACE_MAX); + if (!skb) { + wl1271_error("failed to allocate buffer for arp rsp template"); + return -ENOMEM; + } - /* mac80211 header */ - hdr = &tmpl.hdr; - hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | - IEEE80211_STYPE_DATA | - IEEE80211_FCTL_TODS); - memcpy(hdr->addr1, vif->bss_conf.bssid, ETH_ALEN); - memcpy(hdr->addr2, vif->addr, ETH_ALEN); - memset(hdr->addr3, 0xff, ETH_ALEN); + skb_reserve(skb, sizeof(*hdr) + WL1271_EXTRA_SPACE_MAX); + + tmpl = (struct wl12xx_arp_rsp_template *)skb_put(skb, sizeof(*tmpl)); + memset(tmpl, 0, sizeof(tmpl)); /* llc layer */ - memcpy(tmpl.llc_hdr, rfc1042_header, sizeof(rfc1042_header)); - tmpl.llc_type = cpu_to_be16(ETH_P_ARP); + memcpy(tmpl->llc_hdr, rfc1042_header, sizeof(rfc1042_header)); + tmpl->llc_type = cpu_to_be16(ETH_P_ARP); /* arp header */ - arp_hdr = &tmpl.arp_hdr; + arp_hdr = &tmpl->arp_hdr; arp_hdr->ar_hrd = cpu_to_be16(ARPHRD_ETHER); arp_hdr->ar_pro = cpu_to_be16(ETH_P_IP); arp_hdr->ar_hln = ETH_ALEN; @@ -1246,13 +1248,59 @@ 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, vif->addr, ETH_ALEN); - tmpl.sender_ip = ip_addr; + memcpy(tmpl->sender_hw, vif->addr, ETH_ALEN); + tmpl->sender_ip = wlvif->ip_addr; + + /* encryption space */ + switch (wlvif->encryption_type) { + case KEY_TKIP: + extra = WL1271_EXTRA_SPACE_TKIP; + break; + case KEY_AES: + extra = WL1271_EXTRA_SPACE_AES; + break; + case KEY_NONE: + case KEY_WEP: + case KEY_GEM: + extra = 0; + break; + default: + wl1271_warning("Unknown encryption type: %d", + wlvif->encryption_type); + ret = -EINVAL; + goto out; + } + + if (extra) { + u8 *space = skb_push(skb, extra); + memset(space, 0, extra); + } + + /* QoS header - BE */ + if (wlvif->sta.qos) + memset(skb_push(skb, sizeof(__le16)), 0, sizeof(__le16)); + + /* mac80211 header */ + hdr = (struct ieee80211_hdr_3addr *)skb_push(skb, sizeof(*hdr)); + memset(hdr, 0, sizeof(hdr)); + fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_TODS; + if (wlvif->sta.qos) + fc |= IEEE80211_STYPE_QOS_DATA; + else + fc |= IEEE80211_STYPE_DATA; + if (wlvif->encryption_type != KEY_NONE) + fc |= IEEE80211_FCTL_PROTECTED; + + hdr->frame_control = cpu_to_le16(fc); + memcpy(hdr->addr1, vif->bss_conf.bssid, ETH_ALEN); + memcpy(hdr->addr2, vif->addr, ETH_ALEN); + memset(hdr->addr3, 0xff, ETH_ALEN); ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_ARP_RSP, - &tmpl, sizeof(tmpl), 0, + skb->data, skb->len, 0, wlvif->basic_rate); - +out: + dev_kfree_skb(skb); return ret; } diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 83a2a2edb261..de217d92516b 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -67,8 +67,7 @@ int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, 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); +int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif); 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); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 1c2623850eae..f063c704ebcf 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -579,6 +579,7 @@ static ssize_t vifs_state_read(struct file *file, char __user *user_buf, VIF_STATE_PRINT_INT(sta.basic_rate_idx); VIF_STATE_PRINT_INT(sta.ap_rate_idx); VIF_STATE_PRINT_INT(sta.p2p_rate_idx); + VIF_STATE_PRINT_INT(sta.qos); } else { VIF_STATE_PRINT_INT(ap.global_hlid); VIF_STATE_PRINT_INT(ap.bcast_hlid); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index fcf2b128f9a4..acc03799fc66 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -37,6 +37,7 @@ int wl1271_init_templates_config(struct wl1271 *wl) { int ret, i; + size_t max_size; /* send empty templates for fw memory reservation */ ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, @@ -89,10 +90,11 @@ int wl1271_init_templates_config(struct wl1271 *wl) if (ret < 0) return ret; + max_size = sizeof(struct wl12xx_arp_rsp_template) + + WL1271_EXTRA_SPACE_MAX; ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, CMD_TEMPL_ARP_RSP, NULL, - sizeof - (struct wl12xx_arp_rsp_template), + max_size, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b828149a1655..a84fe28873ea 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2324,6 +2324,9 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) wl1271_info("JOIN while associated."); + /* clear encryption type */ + wlvif->encryption_type = KEY_NONE; + if (set_assoc) set_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); @@ -2981,6 +2984,21 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, wl1271_error("Could not add or replace key"); goto out_sleep; } + + /* + * reconfiguring arp response if the unicast (or common) + * encryption key type was changed + */ + if (wlvif->bss_type == BSS_TYPE_STA_BSS && + (sta || key_type == KEY_WEP) && + wlvif->encryption_type != key_type) { + wlvif->encryption_type = key_type; + ret = wl1271_cmd_build_arp_rsp(wl, wlvif); + if (ret < 0) { + wl1271_warning("build arp rsp failed: %d", ret); + goto out_sleep; + } + } break; case DISABLE_KEY: @@ -3822,19 +3840,22 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (ret < 0) goto out; - if (changed & BSS_CHANGED_ARP_FILTER) { + if ((changed & BSS_CHANGED_ARP_FILTER) || + (!is_ibss && (changed & BSS_CHANGED_QOS))) { __be32 addr = bss_conf->arp_addr_list[0]; + wlvif->sta.qos = bss_conf->qos; WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS); if (bss_conf->arp_addr_cnt == 1 && bss_conf->arp_filter_enabled) { + wlvif->ip_addr = addr; /* * The template should have been configured only upon * association. however, it seems that the correct ip * isn't being set (when sending), so we have to * reconfigure the template upon every ip change. */ - ret = wl1271_cmd_build_arp_rsp(wl, wlvif, addr); + ret = wl1271_cmd_build_arp_rsp(wl, wlvif); if (ret < 0) { wl1271_warning("build arp rsp failed: %d", ret); goto out; @@ -3843,8 +3864,10 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, ret = wl1271_acx_arp_ip_filter(wl, wlvif, ACX_ARP_FILTER_ARP_FILTERING, addr); - } else + } else { + wlvif->ip_addr = 0; ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr); + } if (ret < 0) goto out; @@ -5007,7 +5030,7 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) }; /* The tx descriptor buffer and the TKIP space. */ - wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE + + wl->hw->extra_tx_headroom = WL1271_EXTRA_SPACE_TKIP + sizeof(struct wl1271_tx_hw_descr); /* unit us */ diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 1f5cc2af5bc6..6446e4d3e8f9 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -386,7 +386,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (info->control.hw_key && info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) - extra = WL1271_TKIP_IV_SPACE; + extra = WL1271_EXTRA_SPACE_TKIP; if (info->control.hw_key) { bool is_wep; @@ -861,8 +861,9 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, if (info->control.hw_key && info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) { int hdrlen = ieee80211_get_hdrlen_from_skb(skb); - memmove(skb->data + WL1271_TKIP_IV_SPACE, skb->data, hdrlen); - skb_pull(skb, WL1271_TKIP_IV_SPACE); + memmove(skb->data + WL1271_EXTRA_SPACE_TKIP, skb->data, + hdrlen); + skb_pull(skb, WL1271_EXTRA_SPACE_TKIP); } wl1271_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x" @@ -1004,9 +1005,9 @@ void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues) info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) { int hdrlen = ieee80211_get_hdrlen_from_skb(skb); - memmove(skb->data + WL1271_TKIP_IV_SPACE, + memmove(skb->data + WL1271_EXTRA_SPACE_TKIP, skb->data, hdrlen); - skb_pull(skb, WL1271_TKIP_IV_SPACE); + skb_pull(skb, WL1271_EXTRA_SPACE_TKIP); } info->status.rates[0].idx = -1; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 7ceb3ceaa648..e3977b55a710 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -52,7 +52,9 @@ #define TX_HW_RESULT_QUEUE_LEN_MASK 0xf #define WL1271_TX_ALIGN_TO 4 -#define WL1271_TKIP_IV_SPACE 4 +#define WL1271_EXTRA_SPACE_TKIP 4 +#define WL1271_EXTRA_SPACE_AES 8 +#define WL1271_EXTRA_SPACE_MAX 8 /* Used for management frames and dummy packets */ #define WL1271_TID_MGMT 7 diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 61c58c13fa90..81af416d17da 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,6 +507,8 @@ struct wl12xx_vif { u8 basic_rate_idx; u8 ap_rate_idx; u8 p2p_rate_idx; + + bool qos; } sta; struct { u8 global_hlid; @@ -573,6 +575,10 @@ struct wl12xx_vif { int rssi_thold; int last_rssi_event; + /* save the current encryption type for auto-arp config */ + u8 encryption_type; + __be32 ip_addr; + /* RX BA constraint value */ bool ba_support; bool ba_allowed; diff --git a/drivers/net/wireless/wl12xx/wl12xx_80211.h b/drivers/net/wireless/wl12xx/wl12xx_80211.h index 8f0ffaf62309..22b0bc98d7b5 100644 --- a/drivers/net/wireless/wl12xx/wl12xx_80211.h +++ b/drivers/net/wireless/wl12xx/wl12xx_80211.h @@ -117,7 +117,7 @@ struct wl12xx_ps_poll_template { } __packed; struct wl12xx_arp_rsp_template { - struct ieee80211_hdr_3addr hdr; + /* not including ieee80211 header */ u8 llc_hdr[sizeof(rfc1042_header)]; __be16 llc_type; -- GitLab From b87f20c018cead99b76c431b9289c0f17168d21c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 2 Feb 2012 12:22:10 +0200 Subject: [PATCH 0754/1846] wl12xx: Revert "wl12xx: disable auto-arp" This reverts commit e5e2f24b3eec67a7a35d43654a997f98ca21aff2. The encryption consideration on auto-arp configuration, along with a fw fix, seem to resolve the crashes that occured when auto-arp was enabled, so we can re-enable it now. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a84fe28873ea..a264cb5bee5a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3862,7 +3862,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, } ret = wl1271_acx_arp_ip_filter(wl, wlvif, - ACX_ARP_FILTER_ARP_FILTERING, + (ACX_ARP_FILTER_ARP_FILTERING | + ACX_ARP_FILTER_AUTO_ARP), addr); } else { wlvif->ip_addr = 0; -- GitLab From 76a74c8a65c6d2587e48355d3a122b4274f5abbf Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 2 Feb 2012 12:22:11 +0200 Subject: [PATCH 0755/1846] wl12xx: configure arp filtering only after association We have to configure arp filtering only after the role was started, so move the BSS_CHANGED_ARP_FILTER handling after the join. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 69 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a264cb5bee5a..b45a16c1f717 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3840,40 +3840,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (ret < 0) goto out; - if ((changed & BSS_CHANGED_ARP_FILTER) || - (!is_ibss && (changed & BSS_CHANGED_QOS))) { - __be32 addr = bss_conf->arp_addr_list[0]; - wlvif->sta.qos = bss_conf->qos; - WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS); - - if (bss_conf->arp_addr_cnt == 1 && - bss_conf->arp_filter_enabled) { - wlvif->ip_addr = addr; - /* - * The template should have been configured only upon - * association. however, it seems that the correct ip - * isn't being set (when sending), so we have to - * reconfigure the template upon every ip change. - */ - ret = wl1271_cmd_build_arp_rsp(wl, wlvif); - if (ret < 0) { - wl1271_warning("build arp rsp failed: %d", ret); - goto out; - } - - ret = wl1271_acx_arp_ip_filter(wl, wlvif, - (ACX_ARP_FILTER_ARP_FILTERING | - ACX_ARP_FILTER_AUTO_ARP), - addr); - } else { - wlvif->ip_addr = 0; - ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr); - } - - if (ret < 0) - goto out; - } - if (do_join) { ret = wl1271_join(wl, wlvif, set_assoc); if (ret < 0) { @@ -3940,6 +3906,41 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, } } + /* Handle arp filtering. Done after join. */ + if ((changed & BSS_CHANGED_ARP_FILTER) || + (!is_ibss && (changed & BSS_CHANGED_QOS))) { + __be32 addr = bss_conf->arp_addr_list[0]; + wlvif->sta.qos = bss_conf->qos; + WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS); + + if (bss_conf->arp_addr_cnt == 1 && + bss_conf->arp_filter_enabled) { + wlvif->ip_addr = addr; + /* + * The template should have been configured only upon + * association. however, it seems that the correct ip + * isn't being set (when sending), so we have to + * reconfigure the template upon every ip change. + */ + ret = wl1271_cmd_build_arp_rsp(wl, wlvif); + if (ret < 0) { + wl1271_warning("build arp rsp failed: %d", ret); + goto out; + } + + ret = wl1271_acx_arp_ip_filter(wl, wlvif, + (ACX_ARP_FILTER_ARP_FILTERING | + ACX_ARP_FILTER_AUTO_ARP), + addr); + } else { + wlvif->ip_addr = 0; + ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr); + } + + if (ret < 0) + goto out; + } + out: return; } -- GitLab From 79aba1baf251e22fbc97a42c711c4b683807ac43 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 2 Feb 2012 13:15:35 +0200 Subject: [PATCH 0756/1846] wl12xx: declare support for hw scan while idle By allowing hw scan while idle, we no longer need the redundant ROC/CROC that are done on idle off/on, which helps simplifying the state machine of the driver. This way, we can also allow scanning while there is an ongoing sched scan (otherwise, we won't be able to ROC on idle-off) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 7 ++----- drivers/net/wireless/wl12xx/scan.c | 13 ------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b45a16c1f717..17dcd63bfc48 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3068,10 +3068,6 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, goto out_sleep; } - /* cancel ROC before scanning */ - if (wl12xx_dev_role_started(wlvif)) - wl12xx_croc(wl, wlvif->dev_role_id); - ret = wl1271_scan(hw->priv, vif, ssid, len, req); out_sleep: wl1271_ps_elp_sleep(wl); @@ -5050,7 +5046,8 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_AP_LINK_PS | IEEE80211_HW_AMPDU_AGGREGATION | - IEEE80211_HW_TX_AMPDU_SETUP_IN_HW; + IEEE80211_HW_TX_AMPDU_SETUP_IN_HW | + IEEE80211_HW_SCAN_WHILE_IDLE; wl->hw->wiphy->cipher_suites = cipher_suites; wl->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 6adc7333b7e6..848a165fa55c 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -38,7 +38,6 @@ void wl1271_scan_complete_work(struct work_struct *work) struct ieee80211_vif *vif; struct wl12xx_vif *wlvif; int ret; - bool is_sta, is_ibss; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1271, scan_complete_work); @@ -70,18 +69,6 @@ void wl1271_scan_complete_work(struct work_struct *work) wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq); } - /* 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(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) || - (is_ibss && !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags))) && - !test_bit(wlvif->dev_role_id, wl->roc_map)) { - /* restore remain on channel */ - if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) - wl12xx_start_dev(wl, wlvif); - else - wl12xx_roc(wl, wlvif, wlvif->dev_role_id); - } wl1271_ps_elp_sleep(wl); if (wl->scan.failed) { -- GitLab From 35d7742ff31609d655f8f8b3f869647006a2ac26 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 2 Feb 2012 13:54:26 +0200 Subject: [PATCH 0757/1846] wl12xx: don't fail on AP scan AP role uses its own role_id for scans, so there's no reason to fail the scan if dev_role_id is invalid. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/scan.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 848a165fa55c..e3566ca90f0d 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -175,16 +175,17 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, if (passive) scan_options |= WL1271_SCAN_OPT_PASSIVE; - if (WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID || - wlvif->dev_role_id == WL12XX_INVALID_ROLE_ID)) { - ret = -EINVAL; - goto out; - } - if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) + if (wlvif->bss_type == BSS_TYPE_AP_BSS || + test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) cmd->params.role_id = wlvif->role_id; else cmd->params.role_id = wlvif->dev_role_id; + if (WARN_ON(cmd->params.role_id == WL12XX_INVALID_ROLE_ID)) { + ret = -EINVAL; + goto out; + } + cmd->params.scan_options = cpu_to_le16(scan_options); cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req, -- GitLab From c08e371a683021cfb99632db799bea9b69d176e5 Mon Sep 17 00:00:00 2001 From: Ido Reis Date: Thu, 2 Feb 2012 13:54:27 +0200 Subject: [PATCH 0758/1846] wl12xx: increase max probe-req template size to WL1271_CMD_TEMPL_MAX_SIZE Increase max scan IEs to allow big probe-req frames Report a correct max-length for the scan IEs we can support, according to the now larger size of the probe-req template. Signed-off-by: Ido Reis Signed-off-by: Arik Nemtsov Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 4 ++-- drivers/net/wireless/wl12xx/main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index acc03799fc66..203fbebf09eb 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -42,14 +42,14 @@ int wl1271_init_templates_config(struct wl1271 *wl) /* send empty templates for fw memory reservation */ ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL, - WL1271_CMD_TEMPL_DFLT_SIZE, + WL1271_CMD_TEMPL_MAX_SIZE, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; ret = wl1271_cmd_template_set(wl, WL12XX_INVALID_ROLE_ID, CMD_TEMPL_CFG_PROBE_REQ_5, - NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0, + NULL, WL1271_CMD_TEMPL_MAX_SIZE, 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 17dcd63bfc48..253847ff344b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5063,10 +5063,10 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) * should be the maximum length possible for a template, without * the IEEE80211 header of the template */ - wl->hw->wiphy->max_scan_ie_len = WL1271_CMD_TEMPL_DFLT_SIZE - + wl->hw->wiphy->max_scan_ie_len = WL1271_CMD_TEMPL_MAX_SIZE - sizeof(struct ieee80211_header); - wl->hw->wiphy->max_sched_scan_ie_len = WL1271_CMD_TEMPL_DFLT_SIZE - + wl->hw->wiphy->max_sched_scan_ie_len = WL1271_CMD_TEMPL_MAX_SIZE - sizeof(struct ieee80211_header); wl->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; -- GitLab From d647f2dd1a445f5a683372f1b47919fe92c19896 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Thu, 2 Feb 2012 13:54:28 +0200 Subject: [PATCH 0759/1846] wl12xx: use split scan for normal scan Split scan allows the FW to schedule other activities during a scan which may be a long operation. This is achieved by setting a trigger TID to ANY_TID and a scan trigger timeout other than 0. The default one is set to 50ms. Signed-off-by: Eyal Shapira Signed-off-by: Igal Chernobelsky Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/conf.h | 8 ++++++++ drivers/net/wireless/wl12xx/main.c | 1 + drivers/net/wireless/wl12xx/scan.c | 8 +++++--- drivers/net/wireless/wl12xx/scan.h | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 823535cdf150..cc50faaf03d1 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -1082,6 +1082,14 @@ struct conf_scan_settings { */ u16 num_probe_reqs; + /* + * Scan trigger (split scan) timeout. The FW will split the scan + * operation into slices of the given time and allow the FW to schedule + * other tasks in between. + * + * Range: u32 Microsecs + */ + u32 split_scan_timeout; }; struct conf_sched_scan_settings { diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 253847ff344b..723df48ed447 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -272,6 +272,7 @@ static struct conf_drv_settings default_conf = { .min_dwell_time_passive = 100000, .max_dwell_time_passive = 100000, .num_probe_reqs = 2, + .split_scan_timeout = 50000, }, .sched_scan = { /* sched_scan requires dwell times in TU instead of TU/1000 */ diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e3566ca90f0d..e43a6b2c1d91 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -172,6 +172,9 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, goto out; } + if (wl->conf.scan.split_scan_timeout) + scan_options |= WL1271_SCAN_OPT_SPLIT_SCAN; + if (passive) scan_options |= WL1271_SCAN_OPT_PASSIVE; @@ -198,7 +201,7 @@ 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.tid_trigger = 0; + cmd->params.tid_trigger = CONF_TX_AC_ANY_TID; cmd->params.scan_tag = WL1271_SCAN_DEFAULT_TAG; if (band == IEEE80211_BAND_2GHZ) @@ -223,8 +226,7 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, goto out; } - /* disable the timeout */ - trigger->timeout = 0; + trigger->timeout = cpu_to_le32(wl->conf.scan.split_scan_timeout); ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger, sizeof(*trigger), 0); if (ret < 0) { diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h index a7ed43dc08c9..96ff457a3a0b 100644 --- a/drivers/net/wireless/wl12xx/scan.h +++ b/drivers/net/wireless/wl12xx/scan.h @@ -48,7 +48,7 @@ void wl1271_scan_sched_scan_results(struct wl1271 *wl); #define WL1271_SCAN_CURRENT_TX_PWR 0 #define WL1271_SCAN_OPT_ACTIVE 0 #define WL1271_SCAN_OPT_PASSIVE 1 -#define WL1271_SCAN_OPT_TRIGGERED_SCAN 2 +#define WL1271_SCAN_OPT_SPLIT_SCAN 2 #define WL1271_SCAN_OPT_PRIORITY_HIGH 4 /* scan even if we fail to enter psm */ #define WL1271_SCAN_OPT_FORCE 8 -- GitLab From f95f9aad150238236b2338efa60a14891081026e Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Thu, 2 Feb 2012 13:54:29 +0200 Subject: [PATCH 0760/1846] wl12xx: add split_scan_timeout debugfs file Add control over split_scan_timeout through debugfs. Values are in ms while 0 will disable split scan. Signed-off-by: Eyal Shapira Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index f063c704ebcf..00dbe1595a7f 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -445,6 +445,48 @@ static const struct file_operations forced_ps_ops = { .llseek = default_llseek, }; +static ssize_t split_scan_timeout_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + + return wl1271_format_buffer(user_buf, count, + ppos, "%d\n", + wl->conf.scan.split_scan_timeout / 1000); +} + +static ssize_t split_scan_timeout_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + unsigned long value; + int ret; + + ret = kstrtoul_from_user(user_buf, count, 10, &value); + if (ret < 0) { + wl1271_warning("illegal value in split_scan_timeout"); + return -EINVAL; + } + + if (value == 0) + wl1271_info("split scan will be disabled"); + + mutex_lock(&wl->mutex); + + wl->conf.scan.split_scan_timeout = value * 1000; + + mutex_unlock(&wl->mutex); + return count; +} + +static const struct file_operations split_scan_timeout_ops = { + .read = split_scan_timeout_read, + .write = split_scan_timeout_write, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + static ssize_t driver_state_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1082,6 +1124,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(beacon_filtering, rootdir); DEBUGFS_ADD(dynamic_ps_timeout, rootdir); DEBUGFS_ADD(forced_ps, rootdir); + DEBUGFS_ADD(split_scan_timeout, rootdir); streaming = debugfs_create_dir("rx_streaming", rootdir); if (!streaming || IS_ERR(streaming)) -- GitLab From 3fcdab7066a31ae90ac2beba7d38e8e606374998 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 6 Feb 2012 12:47:54 +0200 Subject: [PATCH 0761/1846] wl12xx: Use a dedicated fw for PLT A special PLT firmware is used for calibration. Add multiple fw support by introducing a new fw_type member, representing the currently saved fw (the actual fw state can be determined by wl->state). Signed-off-by: Gery Kahn Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 2 +- drivers/net/wireless/wl12xx/main.c | 53 +++++++++++++++++--------- drivers/net/wireless/wl12xx/rx.c | 2 +- drivers/net/wireless/wl12xx/sdio.c | 2 + drivers/net/wireless/wl12xx/spi.c | 2 + drivers/net/wireless/wl12xx/testmode.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 11 +++++- 7 files changed, 52 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 00dbe1595a7f..e1cf72765965 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -113,7 +113,7 @@ static void wl1271_debugfs_update_stats(struct wl1271 *wl) if (ret < 0) goto out; - if (wl->state == WL1271_STATE_ON && + if (wl->state == WL1271_STATE_ON && !wl->plt && time_after(jiffies, wl->stats.fw_stats_update + msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) { wl1271_acx_statistics(wl, wl->stats.fw_stats); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 723df48ed447..c10940703e8c 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -993,16 +993,29 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) return IRQ_HANDLED; } -static int wl1271_fetch_firmware(struct wl1271 *wl) +static int wl12xx_fetch_firmware(struct wl1271 *wl, bool plt) { const struct firmware *fw; const char *fw_name; + enum wl12xx_fw_type fw_type; int ret; - if (wl->chip.id == CHIP_ID_1283_PG20) - fw_name = WL128X_FW_NAME; - else - fw_name = WL127X_FW_NAME; + if (plt) { + fw_type = WL12XX_FW_TYPE_PLT; + if (wl->chip.id == CHIP_ID_1283_PG20) + fw_name = WL128X_PLT_FW_NAME; + else + fw_name = WL127X_PLT_FW_NAME; + } else { + fw_type = WL12XX_FW_TYPE_NORMAL; + if (wl->chip.id == CHIP_ID_1283_PG20) + fw_name = WL128X_FW_NAME; + else + fw_name = WL127X_FW_NAME; + } + + if (wl->fw_type == fw_type) + return 0; wl1271_debug(DEBUG_BOOT, "booting firmware %s", fw_name); @@ -1021,6 +1034,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl) } vfree(wl->fw); + wl->fw_type = WL12XX_FW_TYPE_NONE; wl->fw_len = fw->size; wl->fw = vmalloc(wl->fw_len); @@ -1032,7 +1046,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl) memcpy(wl->fw, fw->data, wl->fw_len); ret = 0; - + wl->fw_type = fw_type; out: release_firmware(fw); @@ -1160,7 +1174,7 @@ static void wl1271_recovery_work(struct work_struct *work) mutex_lock(&wl->mutex); - if (wl->state != WL1271_STATE_ON) + if (wl->state != WL1271_STATE_ON || wl->plt) goto out_unlock; /* Avoid a recursive recovery */ @@ -1261,7 +1275,7 @@ static int wl12xx_set_power_on(struct wl1271 *wl) return ret; } -static int wl1271_chip_wakeup(struct wl1271 *wl) +static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt) { int ret = 0; @@ -1316,11 +1330,9 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) goto out; } - if (wl->fw == NULL) { - ret = wl1271_fetch_firmware(wl); - if (ret < 0) - goto out; - } + ret = wl12xx_fetch_firmware(wl, plt); + if (ret < 0) + goto out; /* No NVS from netlink, try to get it from the filesystem */ if (wl->nvs == NULL) { @@ -1352,7 +1364,7 @@ int wl1271_plt_start(struct wl1271 *wl) while (retries) { retries--; - ret = wl1271_chip_wakeup(wl); + ret = wl12xx_chip_wakeup(wl, true); if (ret < 0) goto power_off; @@ -1364,7 +1376,8 @@ int wl1271_plt_start(struct wl1271 *wl) if (ret < 0) goto irq_disable; - wl->state = WL1271_STATE_PLT; + wl->plt = true; + wl->state = WL1271_STATE_ON; wl1271_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver_str); @@ -1413,7 +1426,7 @@ int wl1271_plt_stop(struct wl1271 *wl) */ wl1271_disable_interrupts(wl); mutex_lock(&wl->mutex); - if (wl->state != WL1271_STATE_PLT) { + if (!wl->plt) { mutex_unlock(&wl->mutex); /* @@ -1440,6 +1453,7 @@ int wl1271_plt_stop(struct wl1271 *wl) wl1271_power_off(wl); wl->flags = 0; wl->state = WL1271_STATE_OFF; + wl->plt = false; wl->rx_counter = 0; mutex_unlock(&wl->mutex); @@ -1995,7 +2009,7 @@ static bool wl12xx_init_fw(struct wl1271 *wl) while (retries) { retries--; - ret = wl1271_chip_wakeup(wl); + ret = wl12xx_chip_wakeup(wl, false); if (ret < 0) goto power_off; @@ -2098,6 +2112,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; } + ret = wl12xx_init_vif_data(wl, vif); if (ret < 0) goto out; @@ -5009,7 +5024,7 @@ static int wl1271_register_hw(struct wl1271 *wl) static void wl1271_unregister_hw(struct wl1271 *wl) { - if (wl->state == WL1271_STATE_PLT) + if (wl->plt) wl1271_plt_stop(wl); unregister_netdevice_notifier(&wl1271_dev_notifier); @@ -5186,6 +5201,7 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) spin_lock_init(&wl->wl_lock); wl->state = WL1271_STATE_OFF; + wl->fw_type = WL12XX_FW_TYPE_NONE; mutex_init(&wl->mutex); /* Apply default driver configuration. */ @@ -5253,6 +5269,7 @@ static int wl1271_free_hw(struct wl1271 *wl) vfree(wl->fw); wl->fw = NULL; + wl->fw_type = WL12XX_FW_TYPE_NONE; kfree(wl->nvs); wl->nvs = NULL; diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index 4fbd2a722ffa..cfa6071704c5 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -113,7 +113,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, * In PLT mode we seem to get frames and mac80211 warns about them, * workaround this by not retrieving them at all. */ - if (unlikely(wl->state == WL1271_STATE_PLT)) + if (unlikely(wl->plt)) return -EINVAL; /* the data read starts with the descriptor */ diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index ce3b9a99463e..1c0264ca021f 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -372,3 +372,5 @@ MODULE_AUTHOR("Luciano Coelho "); MODULE_AUTHOR("Juuso Oikarinen "); MODULE_FIRMWARE(WL127X_FW_NAME); MODULE_FIRMWARE(WL128X_FW_NAME); +MODULE_FIRMWARE(WL127X_PLT_FW_NAME); +MODULE_FIRMWARE(WL128X_PLT_FW_NAME); diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 92caa7ce6053..5c2d4a0ef000 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -435,4 +435,6 @@ MODULE_AUTHOR("Luciano Coelho "); MODULE_AUTHOR("Juuso Oikarinen "); MODULE_FIRMWARE(WL127X_FW_NAME); MODULE_FIRMWARE(WL128X_FW_NAME); +MODULE_FIRMWARE(WL127X_PLT_FW_NAME); +MODULE_FIRMWARE(WL128X_PLT_FW_NAME); MODULE_ALIAS("spi:wl1271"); diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index b6b433e5562f..1e93bb9c0246 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -274,7 +274,7 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[]) mutex_lock(&wl->mutex); - if (wl->state != WL1271_STATE_PLT) { + if (!wl->plt) { ret = -EINVAL; goto out; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 81af416d17da..9b48aa48cdca 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -37,6 +37,8 @@ #define WL127X_FW_NAME "ti-connectivity/wl127x-fw-4-sr.bin" #define WL128X_FW_NAME "ti-connectivity/wl128x-fw-4-sr.bin" +#define WL127X_PLT_FW_NAME "ti-connectivity/wl127x-fw-4-plt.bin" +#define WL128X_PLT_FW_NAME "ti-connectivity/wl128x-fw-4-plt.bin" /* * wl127x and wl128x are using the same NVS file name. However, the @@ -90,7 +92,12 @@ enum wl1271_state { WL1271_STATE_OFF, WL1271_STATE_ON, - WL1271_STATE_PLT, +}; + +enum wl12xx_fw_type { + WL12XX_FW_TYPE_NONE, + WL12XX_FW_TYPE_NORMAL, + WL12XX_FW_TYPE_PLT, }; enum wl1271_partition_type { @@ -294,6 +301,8 @@ struct wl1271 { spinlock_t wl_lock; enum wl1271_state state; + enum wl12xx_fw_type fw_type; + bool plt; struct mutex mutex; unsigned long flags; -- GitLab From 4549d09c57cf44ae9ab6095c375bad5c100658c7 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 6 Feb 2012 13:07:52 +0200 Subject: [PATCH 0762/1846] wl12xx: dynamically change fw according to number of active roles wl12xx uses different fw for single-role and multi-role scenarios (due to lack of space, some of the fw advanced features are disabled in the multi-role fw). Add checks on add_interfae and remove_interface in order to determine whether a fw switch is needed (and initiate recovery in this case). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 114 +++++++++++++++++++++++++-- drivers/net/wireless/wl12xx/sdio.c | 6 +- drivers/net/wireless/wl12xx/spi.c | 6 +- drivers/net/wireless/wl12xx/wl12xx.h | 11 ++- 4 files changed, 124 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index c10940703e8c..b3b4c4019787 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -993,6 +993,35 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) return IRQ_HANDLED; } +struct vif_counter_data { + u8 counter; + + struct ieee80211_vif *cur_vif; + bool cur_vif_running; +}; + +static void wl12xx_vif_count_iter(void *data, u8 *mac, + struct ieee80211_vif *vif) +{ + struct vif_counter_data *counter = data; + + counter->counter++; + if (counter->cur_vif == vif) + counter->cur_vif_running = true; +} + +/* caller must not hold wl->mutex, as it might deadlock */ +static void wl12xx_get_vif_count(struct ieee80211_hw *hw, + struct ieee80211_vif *cur_vif, + struct vif_counter_data *data) +{ + memset(data, 0, sizeof(*data)); + data->cur_vif = cur_vif; + + ieee80211_iterate_active_interfaces(hw, + wl12xx_vif_count_iter, data); +} + static int wl12xx_fetch_firmware(struct wl1271 *wl, bool plt) { const struct firmware *fw; @@ -1007,11 +1036,23 @@ static int wl12xx_fetch_firmware(struct wl1271 *wl, bool plt) else fw_name = WL127X_PLT_FW_NAME; } else { - fw_type = WL12XX_FW_TYPE_NORMAL; - if (wl->chip.id == CHIP_ID_1283_PG20) - fw_name = WL128X_FW_NAME; - else - fw_name = WL127X_FW_NAME; + /* + * we can't call wl12xx_get_vif_count() here because + * wl->mutex is taken, so use the cached last_vif_count value + */ + if (wl->last_vif_count > 1) { + fw_type = WL12XX_FW_TYPE_MULTI; + if (wl->chip.id == CHIP_ID_1283_PG20) + fw_name = WL128X_FW_NAME_MULTI; + else + fw_name = WL127X_FW_NAME_MULTI; + } else { + fw_type = WL12XX_FW_TYPE_NORMAL; + if (wl->chip.id == CHIP_ID_1283_PG20) + fw_name = WL128X_FW_NAME_SINGLE; + else + fw_name = WL127X_FW_NAME_SINGLE; + } } if (wl->fw_type == fw_type) @@ -2074,11 +2115,47 @@ static bool wl12xx_dev_role_started(struct wl12xx_vif *wlvif) return wlvif->dev_hlid != WL12XX_INVALID_LINK_ID; } +/* + * Check whether a fw switch (i.e. moving from one loaded + * fw to another) is needed. This function is also responsible + * for updating wl->last_vif_count, so it must be called before + * loading a non-plt fw (so the correct fw (single-role/multi-role) + * will be used). + */ +static bool wl12xx_need_fw_change(struct wl1271 *wl, + struct vif_counter_data vif_counter_data, + bool add) +{ + enum wl12xx_fw_type current_fw = wl->fw_type; + u8 vif_count = vif_counter_data.counter; + + if (test_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags)) + return false; + + /* increase the vif count if this is a new vif */ + if (add && !vif_counter_data.cur_vif_running) + vif_count++; + + wl->last_vif_count = vif_count; + + /* no need for fw change if the device is OFF */ + if (wl->state == WL1271_STATE_OFF) + return false; + + if (vif_count > 1 && current_fw == WL12XX_FW_TYPE_NORMAL) + return true; + if (vif_count <= 1 && current_fw == WL12XX_FW_TYPE_MULTI) + return true; + + return false; +} + 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); + struct vif_counter_data vif_count; int ret = 0; u8 role_type; bool booted = false; @@ -2089,6 +2166,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", ieee80211_vif_type_p2p(vif), vif->addr); + wl12xx_get_vif_count(hw, vif, &vif_count); + mutex_lock(&wl->mutex); ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) @@ -2124,6 +2203,12 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; } + if (wl12xx_need_fw_change(wl, vif_count, true)) { + mutex_unlock(&wl->mutex); + wl1271_recovery_work(&wl->recovery_work); + return 0; + } + /* * TODO: after the nvs issue will be solved, move this block * to start(), and make sure here the driver is ON. @@ -2287,7 +2372,10 @@ 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; + struct vif_counter_data vif_count; + bool cancel_recovery = true; + wl12xx_get_vif_count(hw, vif, &vif_count); mutex_lock(&wl->mutex); if (wl->state == WL1271_STATE_OFF || @@ -2306,20 +2394,32 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, break; } WARN_ON(iter != wlvif); + if (wl12xx_need_fw_change(wl, vif_count, false)) { + wl12xx_queue_recovery_work(wl); + cancel_recovery = false; + } out: mutex_unlock(&wl->mutex); - cancel_work_sync(&wl->recovery_work); + if (cancel_recovery) + cancel_work_sync(&wl->recovery_work); } static int wl12xx_op_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype new_type, bool p2p) { + struct wl1271 *wl = hw->priv; + int ret; + + set_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags); wl1271_op_remove_interface(hw, vif); vif->type = ieee80211_iftype_p2p(new_type, p2p); vif->p2p = p2p; - return wl1271_op_add_interface(hw, vif); + ret = wl1271_op_add_interface(hw, vif); + + clear_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags); + return ret; } static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 1c0264ca021f..4b3c32774bae 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -370,7 +370,9 @@ module_exit(wl1271_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Luciano Coelho "); MODULE_AUTHOR("Juuso Oikarinen "); -MODULE_FIRMWARE(WL127X_FW_NAME); -MODULE_FIRMWARE(WL128X_FW_NAME); +MODULE_FIRMWARE(WL127X_FW_NAME_SINGLE); +MODULE_FIRMWARE(WL127X_FW_NAME_MULTI); MODULE_FIRMWARE(WL127X_PLT_FW_NAME); +MODULE_FIRMWARE(WL128X_FW_NAME_SINGLE); +MODULE_FIRMWARE(WL128X_FW_NAME_MULTI); MODULE_FIRMWARE(WL128X_PLT_FW_NAME); diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 5c2d4a0ef000..2fc18a8dcce8 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -433,8 +433,10 @@ module_exit(wl1271_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Luciano Coelho "); MODULE_AUTHOR("Juuso Oikarinen "); -MODULE_FIRMWARE(WL127X_FW_NAME); -MODULE_FIRMWARE(WL128X_FW_NAME); +MODULE_FIRMWARE(WL127X_FW_NAME_SINGLE); +MODULE_FIRMWARE(WL127X_FW_NAME_MULTI); MODULE_FIRMWARE(WL127X_PLT_FW_NAME); +MODULE_FIRMWARE(WL128X_FW_NAME_SINGLE); +MODULE_FIRMWARE(WL128X_FW_NAME_MULTI); MODULE_FIRMWARE(WL128X_PLT_FW_NAME); MODULE_ALIAS("spi:wl1271"); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9b48aa48cdca..04cddaaf9498 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -35,8 +35,12 @@ #include "conf.h" #include "ini.h" -#define WL127X_FW_NAME "ti-connectivity/wl127x-fw-4-sr.bin" -#define WL128X_FW_NAME "ti-connectivity/wl128x-fw-4-sr.bin" +#define WL127X_FW_NAME_MULTI "ti-connectivity/wl127x-fw-4-mr.bin" +#define WL127X_FW_NAME_SINGLE "ti-connectivity/wl127x-fw-4-sr.bin" + +#define WL128X_FW_NAME_MULTI "ti-connectivity/wl128x-fw-4-mr.bin" +#define WL128X_FW_NAME_SINGLE "ti-connectivity/wl128x-fw-4-sr.bin" + #define WL127X_PLT_FW_NAME "ti-connectivity/wl127x-fw-4-plt.bin" #define WL128X_PLT_FW_NAME "ti-connectivity/wl128x-fw-4-plt.bin" @@ -97,6 +101,7 @@ enum wl1271_state { enum wl12xx_fw_type { WL12XX_FW_TYPE_NONE, WL12XX_FW_TYPE_NORMAL, + WL12XX_FW_TYPE_MULTI, WL12XX_FW_TYPE_PLT, }; @@ -254,6 +259,7 @@ enum wl12xx_flags { WL1271_FLAG_PENDING_WORK, WL1271_FLAG_SOFT_GEMINI, WL1271_FLAG_RECOVERY_IN_PROGRESS, + WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, }; enum wl12xx_vif_flags { @@ -303,6 +309,7 @@ struct wl1271 { enum wl1271_state state; enum wl12xx_fw_type fw_type; bool plt; + u8 last_vif_count; struct mutex mutex; unsigned long flags; -- GitLab From 3dee43930fb48a0746621c99d46318aad8169980 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 6 Feb 2012 12:47:56 +0200 Subject: [PATCH 0763/1846] wl12xx: enter forced-psm on fw change Enter forced psm when changing fw, in order to make the sta a bit more disconnection-persistent. (DPM doesn't know about the incoming recovery, so it won't enter psm by itself) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b3b4c4019787..10c1ecdf9bab 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2150,6 +2150,19 @@ static bool wl12xx_need_fw_change(struct wl1271 *wl, return false; } +/* + * Enter "forced psm". Make sure the sta is in psm against the ap, + * to make the fw switch a bit more disconnection-persistent. + */ +static void wl12xx_force_active_psm(struct wl1271 *wl) +{ + struct wl12xx_vif *wlvif; + + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE); + } +} + static int wl1271_op_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -2204,6 +2217,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, } if (wl12xx_need_fw_change(wl, vif_count, true)) { + wl12xx_force_active_psm(wl); mutex_unlock(&wl->mutex); wl1271_recovery_work(&wl->recovery_work); return 0; @@ -2395,6 +2409,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, } WARN_ON(iter != wlvif); if (wl12xx_need_fw_change(wl, vif_count, false)) { + wl12xx_force_active_psm(wl); wl12xx_queue_recovery_work(wl); cancel_recovery = false; } -- GitLab From 9b44350b495a6ec94f59073c5a4e09e80a818304 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 6 Feb 2012 12:47:57 +0200 Subject: [PATCH 0764/1846] wl12xx: delete wl->vif (and allow multiple vifs) Delete the global wl->vif (and the checks on it), so multiple vifs could be added. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 11 ----------- drivers/net/wireless/wl12xx/wl12xx.h | 2 -- 2 files changed, 13 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 10c1ecdf9bab..fc8dfbfe1d89 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2186,13 +2186,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto out_unlock; - 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 @@ -2265,7 +2258,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto out; - wl->vif = vif; list_add(&wlvif->list, &wl->wlvif_list); set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags); @@ -2298,8 +2290,6 @@ 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; @@ -5291,7 +5281,6 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) wl->rx_counter = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->band = IEEE80211_BAND_2GHZ; - wl->vif = NULL; wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 04cddaaf9498..90352415e2aa 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -445,8 +445,6 @@ struct wl1271 { struct wl12xx_fw_status *fw_status; struct wl1271_tx_hw_res_if *tx_res_if; - struct ieee80211_vif *vif; - /* Current chipset configuration */ struct conf_drv_settings conf; -- GitLab From 51c4ed95a857ded6017537fd53fa00db64908954 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 8 Feb 2012 12:20:04 +0300 Subject: [PATCH 0765/1846] wl12xx: remove some dead code in wl1271_plt_init() "ret" has already been checked at this point, and we don't need to check it again. This was left around from a previous patch 49d750ca14 "wl12xx: 1281/1283 support - New radio structs and functions". Signed-off-by: Dan Carpenter Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fc8dfbfe1d89..adf9bbcf88fd 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -680,8 +680,6 @@ static int wl1271_plt_init(struct wl1271 *wl) if (ret < 0) return ret; } - if (ret < 0) - return ret; /* Chip-specific initializations */ ret = wl1271_chip_specific_init(wl); -- GitLab From e70bb2e89959983aebcfce28f645a1104ffa9ab2 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 13 Feb 2012 16:59:33 +0200 Subject: [PATCH 0766/1846] Bluetooth: Implement Read Supported Commands commands for mgmt This patch implements the Read Supported Commands mgmt command which was recently added to the API specification. It returns a list of supported commands and events to user space. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 7 +++ net/bluetooth/mgmt.c | 99 ++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 5b5edeed59e2..255a99600f08 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -63,6 +63,13 @@ struct mgmt_rp_read_version { __le16 revision; } __packed; +#define MGMT_OP_READ_COMMANDS 0x0002 +struct mgmt_rp_read_commands { + __le16 num_commands; + __le16 num_events; + __le16 opcodes[0]; +} __packed; + #define MGMT_OP_READ_INDEX_LIST 0x0003 struct mgmt_rp_read_index_list { __le16 num_controllers; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a2c2e12516c6..8efbd8eaa1b3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -35,6 +35,69 @@ #define MGMT_VERSION 0 #define MGMT_REVISION 1 +static const u16 mgmt_commands[] = { + MGMT_OP_READ_INDEX_LIST, + MGMT_OP_READ_INFO, + MGMT_OP_SET_POWERED, + MGMT_OP_SET_DISCOVERABLE, + MGMT_OP_SET_CONNECTABLE, + MGMT_OP_SET_FAST_CONNECTABLE, + MGMT_OP_SET_PAIRABLE, + MGMT_OP_SET_LINK_SECURITY, + MGMT_OP_SET_SSP, + MGMT_OP_SET_HS, + MGMT_OP_SET_LE, + MGMT_OP_SET_DEV_CLASS, + MGMT_OP_SET_LOCAL_NAME, + MGMT_OP_ADD_UUID, + MGMT_OP_REMOVE_UUID, + MGMT_OP_LOAD_LINK_KEYS, + MGMT_OP_LOAD_LONG_TERM_KEYS, + MGMT_OP_DISCONNECT, + MGMT_OP_GET_CONNECTIONS, + MGMT_OP_PIN_CODE_REPLY, + MGMT_OP_PIN_CODE_NEG_REPLY, + MGMT_OP_SET_IO_CAPABILITY, + MGMT_OP_PAIR_DEVICE, + MGMT_OP_CANCEL_PAIR_DEVICE, + MGMT_OP_UNPAIR_DEVICE, + MGMT_OP_USER_CONFIRM_REPLY, + MGMT_OP_USER_CONFIRM_NEG_REPLY, + MGMT_OP_USER_PASSKEY_REPLY, + MGMT_OP_USER_PASSKEY_NEG_REPLY, + MGMT_OP_READ_LOCAL_OOB_DATA, + MGMT_OP_ADD_REMOTE_OOB_DATA, + MGMT_OP_REMOVE_REMOTE_OOB_DATA, + MGMT_OP_START_DISCOVERY, + MGMT_OP_STOP_DISCOVERY, + MGMT_OP_CONFIRM_NAME, + MGMT_OP_BLOCK_DEVICE, + MGMT_OP_UNBLOCK_DEVICE, +}; + +static const u16 mgmt_events[] = { + MGMT_EV_CONTROLLER_ERROR, + MGMT_EV_INDEX_ADDED, + MGMT_EV_INDEX_REMOVED, + MGMT_EV_NEW_SETTINGS, + MGMT_EV_CLASS_OF_DEV_CHANGED, + MGMT_EV_LOCAL_NAME_CHANGED, + MGMT_EV_NEW_LINK_KEY, + MGMT_EV_NEW_LONG_TERM_KEY, + MGMT_EV_DEVICE_CONNECTED, + MGMT_EV_DEVICE_DISCONNECTED, + MGMT_EV_CONNECT_FAILED, + MGMT_EV_PIN_CODE_REQUEST, + MGMT_EV_USER_CONFIRM_REQUEST, + MGMT_EV_USER_PASSKEY_REQUEST, + MGMT_EV_AUTH_FAILED, + MGMT_EV_DEVICE_FOUND, + MGMT_EV_DISCOVERING, + MGMT_EV_DEVICE_BLOCKED, + MGMT_EV_DEVICE_UNBLOCKED, + MGMT_EV_DEVICE_UNPAIRED, +}; + /* * These LE scan and inquiry parameters were chosen according to LE General * Discovery Procedure specification. @@ -206,6 +269,39 @@ static int read_version(struct sock *sk) sizeof(rp)); } +static int read_commands(struct sock *sk) +{ + struct mgmt_rp_read_commands *rp; + u16 num_commands = ARRAY_SIZE(mgmt_commands); + u16 num_events = ARRAY_SIZE(mgmt_events); + u16 *opcode; + size_t rp_size; + int i, err; + + BT_DBG("sock %p", sk); + + rp_size = sizeof(*rp) + ((num_commands + num_events) * sizeof(u16)); + + rp = kmalloc(rp_size, GFP_KERNEL); + if (!rp) + return -ENOMEM; + + put_unaligned_le16(num_commands, &rp->num_commands); + put_unaligned_le16(num_events, &rp->num_events); + + for (i = 0, opcode = rp->opcodes; i < num_commands; i++, opcode++) + put_unaligned_le16(mgmt_commands[i], opcode); + + for (i = 0; i < num_events; i++, opcode++) + put_unaligned_le16(mgmt_events[i], opcode); + + err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_COMMANDS, rp, + rp_size); + kfree(rp); + + return err; +} + static int read_index_list(struct sock *sk) { struct mgmt_rp_read_index_list *rp; @@ -2323,6 +2419,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_READ_VERSION: err = read_version(sk); break; + case MGMT_OP_READ_COMMANDS: + err = read_commands(sk); + break; case MGMT_OP_READ_INDEX_LIST: err = read_index_list(sk); break; -- GitLab From 203159d486006a18fa1ccf787a10d15d3128cdac Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Mon, 13 Feb 2012 15:41:01 -0300 Subject: [PATCH 0767/1846] Bluetooth: Fix discovery state machine In case of Start Discovery command failure, we should set the discovery state to DISCOVERY_STOPPED. Otherwise, we stuck at DISCOVERY_STARTING state and subsequent Start Discovery commands will simply fail. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8efbd8eaa1b3..066d338be1ce 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3096,6 +3096,8 @@ int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) struct pending_cmd *cmd; int err; + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev); if (!cmd) return -ENOENT; -- GitLab From 7b99b659d90c5d421cb1867295c78a4c0c030734 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Mon, 13 Feb 2012 15:41:02 -0300 Subject: [PATCH 0768/1846] Bluetooth: Fix event sending with DISCOVERY_STOPPED state We are not supposed to send mgmt_discovering events if we are transiting from DISCOVERY_STARTING to DISCOVERY_STOPPED state. It doesn't make sense to send mgmt_discovering event once discovery procedure has not been even started. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9ada16449aed..dc31e7d6028e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -380,7 +380,8 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) switch (state) { case DISCOVERY_STOPPED: - mgmt_discovering(hdev, 0); + if (hdev->discovery.state != DISCOVERY_STARTING) + mgmt_discovering(hdev, 0); break; case DISCOVERY_STARTING: break; -- GitLab From 1355b704b9ba44182a97c90b4480d79f0de8f040 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:22 +0000 Subject: [PATCH 0769/1846] bnx2x: consistent statistics after internal driver reload Currently bnx2x statistics are reset by inner driver reload, e.g. by MTU change. This patch fixes this issue - from now on statistics should only be reset upon device closure. Thanks to Michal Schmidt for his initial patch regarding this issue. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 6 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 41 +-- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 73 ++++ .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 + .../net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 340 ++++++++---------- .../net/ethernet/broadcom/bnx2x/bnx2x_stats.h | 148 +++++++- 6 files changed, 374 insertions(+), 236 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 7d184fbffaf6..d60b5f073b6f 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -540,6 +540,7 @@ struct bnx2x_fastpath { struct ustorm_per_queue_stats old_uclient; struct xstorm_per_queue_stats old_xclient; struct bnx2x_eth_q_stats eth_q_stats; + struct bnx2x_eth_q_stats_old eth_q_stats_old; /* The size is calculated using the following: sizeof name field from netdev structure + @@ -1046,7 +1047,6 @@ struct bnx2x_slowpath { struct nig_stats nig_stats; struct host_port_stats port_stats; struct host_func_stats func_stats; - struct host_func_stats func_stats_base; u32 wb_comp; u32 wb_data[4]; @@ -1462,6 +1462,10 @@ struct bnx2x { u16 stats_counter; struct bnx2x_eth_stats eth_stats; + struct bnx2x_eth_stats_old eth_stats_old; + struct bnx2x_net_stats_old net_stats_old; + struct bnx2x_fw_port_stats_old fw_stats_old; + bool stats_init; struct z_stream_s *strm; void *gunzip_buf; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 518ec5c6872d..7f6a1b1be74d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -31,46 +31,6 @@ -/** - * bnx2x_bz_fp - zero content of the fastpath structure. - * - * @bp: driver handle - * @index: fastpath index to be zeroed - * - * Makes sure the contents of the bp->fp[index].napi is kept - * intact. - */ -static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) -{ - struct bnx2x_fastpath *fp = &bp->fp[index]; - struct napi_struct orig_napi = fp->napi; - /* bzero bnx2x_fastpath contents */ - memset(fp, 0, sizeof(*fp)); - - /* Restore the NAPI object as it has been already initialized */ - fp->napi = orig_napi; - - fp->bp = bp; - fp->index = index; - if (IS_ETH_FP(fp)) - fp->max_cos = bp->max_cos; - else - /* Special queues support only one CoS */ - fp->max_cos = 1; - - /* - * set the tpa flag for each queue. The tpa flag determines the queue - * minimal size so it must be set prior to queue memory allocation - */ - fp->disable_tpa = ((bp->flags & TPA_ENABLE_FLAG) == 0); - -#ifdef BCM_CNIC - /* We don't want TPA on an FCoE L2 ring */ - if (IS_FCOE_FP(fp)) - fp->disable_tpa = 1; -#endif -} - /** * bnx2x_move_fp - move content of the fastpath structure. * @@ -2084,6 +2044,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) bnx2x_drv_pulse(bp); bnx2x_stats_handle(bp, STATS_EVENT_STOP); + bnx2x_save_statistics(bp); /* Cleanup the chip if needed */ if (unload_mode != UNLOAD_RECOVERY) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 67e97b709edd..f978c6a1aef1 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1491,6 +1491,79 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) return max_cfg; } +/** + * bnx2x_bz_fp - zero content of the fastpath structure. + * + * @bp: driver handle + * @index: fastpath index to be zeroed + * + * Makes sure the contents of the bp->fp[index].napi is kept + * intact. + */ +static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) +{ + struct bnx2x_fastpath *fp = &bp->fp[index]; + struct napi_struct orig_napi = fp->napi; + /* bzero bnx2x_fastpath contents */ + if (bp->stats_init) + memset(fp, 0, sizeof(*fp)); + else { + /* Keep Queue statistics */ + struct bnx2x_eth_q_stats *tmp_eth_q_stats; + struct bnx2x_eth_q_stats_old *tmp_eth_q_stats_old; + + tmp_eth_q_stats = kzalloc(sizeof(struct bnx2x_eth_q_stats), + GFP_KERNEL); + if (tmp_eth_q_stats) + memcpy(tmp_eth_q_stats, &fp->eth_q_stats, + sizeof(struct bnx2x_eth_q_stats)); + + tmp_eth_q_stats_old = + kzalloc(sizeof(struct bnx2x_eth_q_stats_old), + GFP_KERNEL); + if (tmp_eth_q_stats_old) + memcpy(tmp_eth_q_stats_old, &fp->eth_q_stats_old, + sizeof(struct bnx2x_eth_q_stats_old)); + + memset(fp, 0, sizeof(*fp)); + + if (tmp_eth_q_stats) { + memcpy(&fp->eth_q_stats, tmp_eth_q_stats, + sizeof(struct bnx2x_eth_q_stats)); + kfree(tmp_eth_q_stats); + } + + if (tmp_eth_q_stats_old) { + memcpy(&fp->eth_q_stats_old, tmp_eth_q_stats_old, + sizeof(struct bnx2x_eth_q_stats_old)); + kfree(tmp_eth_q_stats_old); + } + + } + + /* Restore the NAPI object as it has been already initialized */ + fp->napi = orig_napi; + + fp->bp = bp; + fp->index = index; + if (IS_ETH_FP(fp)) + fp->max_cos = bp->max_cos; + else + /* Special queues support only one CoS */ + fp->max_cos = 1; + + /* + * set the tpa flag for each queue. The tpa flag determines the queue + * minimal size so it must be set prior to queue memory allocation + */ + fp->disable_tpa = (bp->flags & TPA_ENABLE_FLAG) == 0; +#ifdef BCM_CNIC + /* We don't want TPA on an FCoE L2 ring */ + if (IS_FCOE_FP(fp)) + fp->disable_tpa = 1; +#endif +} + /** * bnx2x_get_iscsi_info - update iSCSI params according to licensing info. * diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index ff19c3cf4409..e0d5f15784fd 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -10235,6 +10235,8 @@ static int bnx2x_open(struct net_device *dev) int other_engine = BP_PATH(bp) ? 0 : 1; bool other_load_status, load_status; + bp->stats_init = true; + netif_carrier_off(dev); bnx2x_set_power_state(bp, PCI_D0); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index 7b9b304b9107..abd310d71512 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c @@ -161,7 +161,7 @@ static void bnx2x_stats_pmf_update(struct bnx2x *bp) u32 *stats_comp = bnx2x_sp(bp, stats_comp); /* sanity */ - if (!IS_MF(bp) || !bp->port.pmf || !bp->port.port_stx) { + if (!bp->port.pmf || !bp->port.port_stx) { BNX2X_ERR("BUG!\n"); return; } @@ -638,31 +638,30 @@ static void bnx2x_mstat_stats_update(struct bnx2x *bp) tx_stat_dot3statsinternalmactransmiterrors); ADD_STAT64(stats_tx.tx_gtufl, tx_stat_mac_ufl); - ADD_64(estats->etherstatspkts1024octetsto1522octets_hi, - new->stats_tx.tx_gt1518_hi, - estats->etherstatspkts1024octetsto1522octets_lo, - new->stats_tx.tx_gt1518_lo); + estats->etherstatspkts1024octetsto1522octets_hi = + pstats->mac_stx[1].tx_stat_etherstatspkts1024octetsto1522octets_hi; + estats->etherstatspkts1024octetsto1522octets_lo = + pstats->mac_stx[1].tx_stat_etherstatspkts1024octetsto1522octets_lo; - ADD_64(estats->etherstatspktsover1522octets_hi, - new->stats_tx.tx_gt2047_hi, - estats->etherstatspktsover1522octets_lo, - new->stats_tx.tx_gt2047_lo); + estats->etherstatspktsover1522octets_hi = + pstats->mac_stx[1].tx_stat_mac_2047_hi; + estats->etherstatspktsover1522octets_lo = + pstats->mac_stx[1].tx_stat_mac_2047_lo; ADD_64(estats->etherstatspktsover1522octets_hi, - new->stats_tx.tx_gt4095_hi, + pstats->mac_stx[1].tx_stat_mac_4095_hi, estats->etherstatspktsover1522octets_lo, - new->stats_tx.tx_gt4095_lo); + pstats->mac_stx[1].tx_stat_mac_4095_lo); ADD_64(estats->etherstatspktsover1522octets_hi, - new->stats_tx.tx_gt9216_hi, + pstats->mac_stx[1].tx_stat_mac_9216_hi, estats->etherstatspktsover1522octets_lo, - new->stats_tx.tx_gt9216_lo); - + pstats->mac_stx[1].tx_stat_mac_9216_lo); ADD_64(estats->etherstatspktsover1522octets_hi, - new->stats_tx.tx_gt16383_hi, + pstats->mac_stx[1].tx_stat_mac_16383_hi, estats->etherstatspktsover1522octets_lo, - new->stats_tx.tx_gt16383_lo); + pstats->mac_stx[1].tx_stat_mac_16383_lo); estats->pause_frames_received_hi = pstats->mac_stx[1].rx_stat_mac_xpf_hi; @@ -817,6 +816,7 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) &bp->fw_stats_data->pf.tstorm_pf_statistics; struct host_func_stats *fstats = bnx2x_sp(bp, func_stats); struct bnx2x_eth_stats *estats = &bp->eth_stats; + struct bnx2x_eth_stats_old *estats_old = &bp->eth_stats_old; struct stats_counter *counters = &bp->fw_stats_data->storm_counters; int i; u16 cur_stats_counter; @@ -857,21 +857,8 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) return -EAGAIN; } - memcpy(&(fstats->total_bytes_received_hi), - &(bnx2x_sp(bp, func_stats_base)->total_bytes_received_hi), - sizeof(struct host_func_stats) - 2*sizeof(u32)); estats->error_bytes_received_hi = 0; estats->error_bytes_received_lo = 0; - estats->etherstatsoverrsizepkts_hi = 0; - estats->etherstatsoverrsizepkts_lo = 0; - estats->no_buff_discard_hi = 0; - estats->no_buff_discard_lo = 0; - estats->total_tpa_aggregations_hi = 0; - estats->total_tpa_aggregations_lo = 0; - estats->total_tpa_aggregated_frames_hi = 0; - estats->total_tpa_aggregated_frames_lo = 0; - estats->total_tpa_bytes_hi = 0; - estats->total_tpa_bytes_lo = 0; for_each_eth_queue(bp, i) { struct bnx2x_fastpath *fp = &bp->fp[i]; @@ -888,6 +875,8 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) xstorm_queue_statistics; struct xstorm_per_queue_stats *old_xclient = &fp->old_xclient; struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats; + struct bnx2x_eth_q_stats_old *qstats_old = &fp->eth_q_stats_old; + u32 diff; DP(BNX2X_MSG_STATS, "queue[%d]: ucast_sent 0x%x, " @@ -897,20 +886,12 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) DP(BNX2X_MSG_STATS, "---------------\n"); - qstats->total_broadcast_bytes_received_hi = - le32_to_cpu(tclient->rcv_bcast_bytes.hi); - qstats->total_broadcast_bytes_received_lo = - le32_to_cpu(tclient->rcv_bcast_bytes.lo); - - qstats->total_multicast_bytes_received_hi = - le32_to_cpu(tclient->rcv_mcast_bytes.hi); - qstats->total_multicast_bytes_received_lo = - le32_to_cpu(tclient->rcv_mcast_bytes.lo); - - qstats->total_unicast_bytes_received_hi = - le32_to_cpu(tclient->rcv_ucast_bytes.hi); - qstats->total_unicast_bytes_received_lo = - le32_to_cpu(tclient->rcv_ucast_bytes.lo); + UPDATE_QSTAT(tclient->rcv_bcast_bytes, + total_broadcast_bytes_received); + UPDATE_QSTAT(tclient->rcv_mcast_bytes, + total_multicast_bytes_received); + UPDATE_QSTAT(tclient->rcv_ucast_bytes, + total_unicast_bytes_received); /* * sum to total_bytes_received all @@ -943,9 +924,9 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) total_multicast_packets_received); UPDATE_EXTEND_TSTAT(rcv_bcast_pkts, total_broadcast_packets_received); - UPDATE_EXTEND_TSTAT(pkts_too_big_discard, - etherstatsoverrsizepkts); - UPDATE_EXTEND_TSTAT(no_buff_discard, no_buff_discard); + UPDATE_EXTEND_E_TSTAT(pkts_too_big_discard, + etherstatsoverrsizepkts); + UPDATE_EXTEND_E_TSTAT(no_buff_discard, no_buff_discard); SUB_EXTEND_USTAT(ucast_no_buff_pkts, total_unicast_packets_received); @@ -953,24 +934,17 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) total_multicast_packets_received); SUB_EXTEND_USTAT(bcast_no_buff_pkts, total_broadcast_packets_received); - UPDATE_EXTEND_USTAT(ucast_no_buff_pkts, no_buff_discard); - UPDATE_EXTEND_USTAT(mcast_no_buff_pkts, no_buff_discard); - UPDATE_EXTEND_USTAT(bcast_no_buff_pkts, no_buff_discard); - - qstats->total_broadcast_bytes_transmitted_hi = - le32_to_cpu(xclient->bcast_bytes_sent.hi); - qstats->total_broadcast_bytes_transmitted_lo = - le32_to_cpu(xclient->bcast_bytes_sent.lo); - - qstats->total_multicast_bytes_transmitted_hi = - le32_to_cpu(xclient->mcast_bytes_sent.hi); - qstats->total_multicast_bytes_transmitted_lo = - le32_to_cpu(xclient->mcast_bytes_sent.lo); - - qstats->total_unicast_bytes_transmitted_hi = - le32_to_cpu(xclient->ucast_bytes_sent.hi); - qstats->total_unicast_bytes_transmitted_lo = - le32_to_cpu(xclient->ucast_bytes_sent.lo); + UPDATE_EXTEND_E_USTAT(ucast_no_buff_pkts, no_buff_discard); + UPDATE_EXTEND_E_USTAT(mcast_no_buff_pkts, no_buff_discard); + UPDATE_EXTEND_E_USTAT(bcast_no_buff_pkts, no_buff_discard); + + UPDATE_QSTAT(xclient->bcast_bytes_sent, + total_broadcast_bytes_transmitted); + UPDATE_QSTAT(xclient->mcast_bytes_sent, + total_multicast_bytes_transmitted); + UPDATE_QSTAT(xclient->ucast_bytes_sent, + total_unicast_bytes_transmitted); + /* * sum to total_bytes_transmitted all * unicast/multicast/broadcast @@ -1006,110 +980,54 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) total_transmitted_dropped_packets_error); /* TPA aggregations completed */ - UPDATE_EXTEND_USTAT(coalesced_events, total_tpa_aggregations); + UPDATE_EXTEND_E_USTAT(coalesced_events, total_tpa_aggregations); /* Number of network frames aggregated by TPA */ - UPDATE_EXTEND_USTAT(coalesced_pkts, - total_tpa_aggregated_frames); + UPDATE_EXTEND_E_USTAT(coalesced_pkts, + total_tpa_aggregated_frames); /* Total number of bytes in completed TPA aggregations */ - qstats->total_tpa_bytes_lo = - le32_to_cpu(uclient->coalesced_bytes.lo); - qstats->total_tpa_bytes_hi = - le32_to_cpu(uclient->coalesced_bytes.hi); - - /* TPA stats per-function */ - ADD_64(estats->total_tpa_aggregations_hi, - qstats->total_tpa_aggregations_hi, - estats->total_tpa_aggregations_lo, - qstats->total_tpa_aggregations_lo); - ADD_64(estats->total_tpa_aggregated_frames_hi, - qstats->total_tpa_aggregated_frames_hi, - estats->total_tpa_aggregated_frames_lo, - qstats->total_tpa_aggregated_frames_lo); - ADD_64(estats->total_tpa_bytes_hi, - qstats->total_tpa_bytes_hi, - estats->total_tpa_bytes_lo, - qstats->total_tpa_bytes_lo); - - ADD_64(fstats->total_bytes_received_hi, - qstats->total_bytes_received_hi, - fstats->total_bytes_received_lo, - qstats->total_bytes_received_lo); - ADD_64(fstats->total_bytes_transmitted_hi, - qstats->total_bytes_transmitted_hi, - fstats->total_bytes_transmitted_lo, - qstats->total_bytes_transmitted_lo); - ADD_64(fstats->total_unicast_packets_received_hi, - qstats->total_unicast_packets_received_hi, - fstats->total_unicast_packets_received_lo, - qstats->total_unicast_packets_received_lo); - ADD_64(fstats->total_multicast_packets_received_hi, - qstats->total_multicast_packets_received_hi, - fstats->total_multicast_packets_received_lo, - qstats->total_multicast_packets_received_lo); - ADD_64(fstats->total_broadcast_packets_received_hi, - qstats->total_broadcast_packets_received_hi, - fstats->total_broadcast_packets_received_lo, - qstats->total_broadcast_packets_received_lo); - ADD_64(fstats->total_unicast_packets_transmitted_hi, - qstats->total_unicast_packets_transmitted_hi, - fstats->total_unicast_packets_transmitted_lo, - qstats->total_unicast_packets_transmitted_lo); - ADD_64(fstats->total_multicast_packets_transmitted_hi, - qstats->total_multicast_packets_transmitted_hi, - fstats->total_multicast_packets_transmitted_lo, - qstats->total_multicast_packets_transmitted_lo); - ADD_64(fstats->total_broadcast_packets_transmitted_hi, - qstats->total_broadcast_packets_transmitted_hi, - fstats->total_broadcast_packets_transmitted_lo, - qstats->total_broadcast_packets_transmitted_lo); - ADD_64(fstats->valid_bytes_received_hi, - qstats->valid_bytes_received_hi, - fstats->valid_bytes_received_lo, - qstats->valid_bytes_received_lo); - - ADD_64(estats->etherstatsoverrsizepkts_hi, - qstats->etherstatsoverrsizepkts_hi, - estats->etherstatsoverrsizepkts_lo, - qstats->etherstatsoverrsizepkts_lo); - ADD_64(estats->no_buff_discard_hi, qstats->no_buff_discard_hi, - estats->no_buff_discard_lo, qstats->no_buff_discard_lo); + UPDATE_QSTAT(uclient->coalesced_bytes, total_tpa_bytes); + + UPDATE_ESTAT_QSTAT_64(total_tpa_bytes); + + UPDATE_FSTAT_QSTAT(total_bytes_received); + UPDATE_FSTAT_QSTAT(total_bytes_transmitted); + UPDATE_FSTAT_QSTAT(total_unicast_packets_received); + UPDATE_FSTAT_QSTAT(total_multicast_packets_received); + UPDATE_FSTAT_QSTAT(total_broadcast_packets_received); + UPDATE_FSTAT_QSTAT(total_unicast_packets_transmitted); + UPDATE_FSTAT_QSTAT(total_multicast_packets_transmitted); + UPDATE_FSTAT_QSTAT(total_broadcast_packets_transmitted); + UPDATE_FSTAT_QSTAT(valid_bytes_received); } - ADD_64(fstats->total_bytes_received_hi, + ADD_64(estats->total_bytes_received_hi, estats->rx_stat_ifhcinbadoctets_hi, - fstats->total_bytes_received_lo, + estats->total_bytes_received_lo, estats->rx_stat_ifhcinbadoctets_lo); - ADD_64(fstats->total_bytes_received_hi, + ADD_64(estats->total_bytes_received_hi, tfunc->rcv_error_bytes.hi, - fstats->total_bytes_received_lo, + estats->total_bytes_received_lo, tfunc->rcv_error_bytes.lo); - memcpy(estats, &(fstats->total_bytes_received_hi), - sizeof(struct host_func_stats) - 2*sizeof(u32)); - ADD_64(estats->error_bytes_received_hi, tfunc->rcv_error_bytes.hi, estats->error_bytes_received_lo, tfunc->rcv_error_bytes.lo); - ADD_64(estats->etherstatsoverrsizepkts_hi, - estats->rx_stat_dot3statsframestoolong_hi, - estats->etherstatsoverrsizepkts_lo, - estats->rx_stat_dot3statsframestoolong_lo); + UPDATE_ESTAT(etherstatsoverrsizepkts, rx_stat_dot3statsframestoolong); + ADD_64(estats->error_bytes_received_hi, estats->rx_stat_ifhcinbadoctets_hi, estats->error_bytes_received_lo, estats->rx_stat_ifhcinbadoctets_lo); if (bp->port.pmf) { - estats->mac_filter_discard = - le32_to_cpu(tport->mac_filter_discard); - estats->mf_tag_discard = - le32_to_cpu(tport->mf_tag_discard); - estats->brb_truncate_discard = - le32_to_cpu(tport->brb_truncate_discard); - estats->mac_discard = le32_to_cpu(tport->mac_discard); + struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old; + UPDATE_FW_STAT(mac_filter_discard); + UPDATE_FW_STAT(mf_tag_discard); + UPDATE_FW_STAT(brb_truncate_discard); + UPDATE_FW_STAT(mac_discard); } fstats->host_func_stats_start = ++fstats->host_func_stats_end; @@ -1143,7 +1061,7 @@ static void bnx2x_net_stats_update(struct bnx2x *bp) tmp = estats->mac_discard; for_each_rx_queue(bp, i) tmp += le32_to_cpu(bp->fp[i].old_tclient.checksum_discard); - nstats->rx_dropped = tmp; + nstats->rx_dropped = tmp + bp->net_stats_old.rx_dropped; nstats->tx_dropped = 0; @@ -1191,17 +1109,15 @@ static void bnx2x_drv_stats_update(struct bnx2x *bp) struct bnx2x_eth_stats *estats = &bp->eth_stats; int i; - estats->driver_xoff = 0; - estats->rx_err_discard_pkt = 0; - estats->rx_skb_alloc_failed = 0; - estats->hw_csum_err = 0; for_each_queue(bp, i) { struct bnx2x_eth_q_stats *qstats = &bp->fp[i].eth_q_stats; + struct bnx2x_eth_q_stats_old *qstats_old = + &bp->fp[i].eth_q_stats_old; - estats->driver_xoff += qstats->driver_xoff; - estats->rx_err_discard_pkt += qstats->rx_err_discard_pkt; - estats->rx_skb_alloc_failed += qstats->rx_skb_alloc_failed; - estats->hw_csum_err += qstats->hw_csum_err; + UPDATE_ESTAT_QSTAT(driver_xoff); + UPDATE_ESTAT_QSTAT(rx_err_discard_pkt); + UPDATE_ESTAT_QSTAT(rx_skb_alloc_failed); + UPDATE_ESTAT_QSTAT(hw_csum_err); } } @@ -1446,33 +1362,6 @@ static void bnx2x_port_stats_base_init(struct bnx2x *bp) bnx2x_stats_comp(bp); } -static void bnx2x_func_stats_base_init(struct bnx2x *bp) -{ - int vn, vn_max = IS_MF(bp) ? BP_MAX_VN_NUM(bp) : E1VN_MAX; - u32 func_stx; - - /* sanity */ - if (!bp->port.pmf || !bp->func_stx) { - BNX2X_ERR("BUG!\n"); - return; - } - - /* save our func_stx */ - func_stx = bp->func_stx; - - for (vn = VN_0; vn < vn_max; vn++) { - int mb_idx = BP_FW_MB_IDX_VN(bp, vn); - - bp->func_stx = SHMEM_RD(bp, func_mb[mb_idx].fw_mb_param); - bnx2x_func_stats_init(bp); - bnx2x_hw_stats_post(bp); - bnx2x_stats_comp(bp); - } - - /* restore our func_stx */ - bp->func_stx = func_stx; -} - static void bnx2x_func_stats_base_update(struct bnx2x *bp) { struct dmae_command *dmae = &bp->stats_dmae; @@ -1491,8 +1380,8 @@ static void bnx2x_func_stats_base_update(struct bnx2x *bp) true, DMAE_COMP_PCI); dmae->src_addr_lo = bp->func_stx >> 2; dmae->src_addr_hi = 0; - dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats_base)); - dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats_base)); + dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); + dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); dmae->len = sizeof(struct host_func_stats) >> 2; dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); @@ -1653,6 +1542,10 @@ void bnx2x_stats_init(struct bnx2x *bp) DP(BNX2X_MSG_STATS, "port_stx 0x%x func_stx 0x%x\n", bp->port.port_stx, bp->func_stx); + /* pmf should retrieve port statistics from SP on a non-init*/ + if (!bp->stats_init && bp->port.pmf && bp->port.port_stx) + bnx2x_stats_handle(bp, STATS_EVENT_PMF); + port = BP_PORT(bp); /* port stats */ memset(&(bp->port.old_nig_stats), 0, sizeof(struct nig_stats)); @@ -1674,24 +1567,83 @@ void bnx2x_stats_init(struct bnx2x *bp) memset(&fp->old_tclient, 0, sizeof(fp->old_tclient)); memset(&fp->old_uclient, 0, sizeof(fp->old_uclient)); memset(&fp->old_xclient, 0, sizeof(fp->old_xclient)); - memset(&fp->eth_q_stats, 0, sizeof(fp->eth_q_stats)); + if (bp->stats_init) { + memset(&fp->eth_q_stats, 0, sizeof(fp->eth_q_stats)); + memset(&fp->eth_q_stats_old, 0, + sizeof(fp->eth_q_stats_old)); + } } /* Prepare statistics ramrod data */ bnx2x_prep_fw_stats_req(bp); memset(&bp->dev->stats, 0, sizeof(bp->dev->stats)); - memset(&bp->eth_stats, 0, sizeof(bp->eth_stats)); + if (bp->stats_init) { + memset(&bp->net_stats_old, 0, sizeof(bp->net_stats_old)); + memset(&bp->fw_stats_old, 0, sizeof(bp->fw_stats_old)); + memset(&bp->eth_stats_old, 0, sizeof(bp->eth_stats_old)); + memset(&bp->eth_stats, 0, sizeof(bp->eth_stats)); - bp->stats_state = STATS_STATE_DISABLED; + /* Clean SP from previous statistics */ + if (bp->func_stx) { + memset(bnx2x_sp(bp, func_stats), 0, + sizeof(struct host_func_stats)); + bnx2x_func_stats_init(bp); + bnx2x_hw_stats_post(bp); + bnx2x_stats_comp(bp); + } + } - if (bp->port.pmf) { - if (bp->port.port_stx) - bnx2x_port_stats_base_init(bp); + bp->stats_state = STATS_STATE_DISABLED; - if (bp->func_stx) - bnx2x_func_stats_base_init(bp); + if (bp->port.pmf && bp->port.port_stx) + bnx2x_port_stats_base_init(bp); - } else if (bp->func_stx) + /* On a non-init, retrieve previous statistics from SP */ + if (!bp->stats_init && bp->func_stx) bnx2x_func_stats_base_update(bp); + + /* mark the end of statistics initializiation */ + bp->stats_init = false; +} + +void bnx2x_save_statistics(struct bnx2x *bp) +{ + int i; + struct net_device_stats *nstats = &bp->dev->stats; + + /* save queue statistics */ + for_each_eth_queue(bp, i) { + struct bnx2x_fastpath *fp = &bp->fp[i]; + struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats; + struct bnx2x_eth_q_stats_old *qstats_old = &fp->eth_q_stats_old; + + UPDATE_QSTAT_OLD(total_unicast_bytes_received_hi); + UPDATE_QSTAT_OLD(total_unicast_bytes_received_lo); + UPDATE_QSTAT_OLD(total_broadcast_bytes_received_hi); + UPDATE_QSTAT_OLD(total_broadcast_bytes_received_lo); + UPDATE_QSTAT_OLD(total_multicast_bytes_received_hi); + UPDATE_QSTAT_OLD(total_multicast_bytes_received_lo); + UPDATE_QSTAT_OLD(total_unicast_bytes_transmitted_hi); + UPDATE_QSTAT_OLD(total_unicast_bytes_transmitted_lo); + UPDATE_QSTAT_OLD(total_broadcast_bytes_transmitted_hi); + UPDATE_QSTAT_OLD(total_broadcast_bytes_transmitted_lo); + UPDATE_QSTAT_OLD(total_multicast_bytes_transmitted_hi); + UPDATE_QSTAT_OLD(total_multicast_bytes_transmitted_lo); + UPDATE_QSTAT_OLD(total_tpa_bytes_hi); + UPDATE_QSTAT_OLD(total_tpa_bytes_lo); + } + + /* save net_device_stats statistics */ + bp->net_stats_old.rx_dropped = nstats->rx_dropped; + + /* store port firmware statistics */ + if (bp->port.pmf && IS_MF(bp)) { + struct bnx2x_eth_stats *estats = &bp->eth_stats; + struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old; + UPDATE_FW_STAT_OLD(mac_filter_discard); + UPDATE_FW_STAT_OLD(mf_tag_discard); + UPDATE_FW_STAT_OLD(brb_truncate_discard); + UPDATE_FW_STAT_OLD(mac_discard); + } } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h index 7e979686cd68..39ffd6dcdf1a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h @@ -264,6 +264,69 @@ struct bnx2x_eth_q_stats { u32 total_tpa_bytes_lo; }; +struct bnx2x_eth_stats_old { + u32 rx_stat_dot3statsframestoolong_hi; + u32 rx_stat_dot3statsframestoolong_lo; +}; + +struct bnx2x_eth_q_stats_old { + /* Fields to perserve over fw reset*/ + u32 total_unicast_bytes_received_hi; + u32 total_unicast_bytes_received_lo; + u32 total_broadcast_bytes_received_hi; + u32 total_broadcast_bytes_received_lo; + u32 total_multicast_bytes_received_hi; + u32 total_multicast_bytes_received_lo; + u32 total_unicast_bytes_transmitted_hi; + u32 total_unicast_bytes_transmitted_lo; + u32 total_broadcast_bytes_transmitted_hi; + u32 total_broadcast_bytes_transmitted_lo; + u32 total_multicast_bytes_transmitted_hi; + u32 total_multicast_bytes_transmitted_lo; + u32 total_tpa_bytes_hi; + u32 total_tpa_bytes_lo; + + /* Fields to perserve last of */ + u32 total_bytes_received_hi; + u32 total_bytes_received_lo; + u32 total_bytes_transmitted_hi; + u32 total_bytes_transmitted_lo; + u32 total_unicast_packets_received_hi; + u32 total_unicast_packets_received_lo; + u32 total_multicast_packets_received_hi; + u32 total_multicast_packets_received_lo; + u32 total_broadcast_packets_received_hi; + u32 total_broadcast_packets_received_lo; + u32 total_unicast_packets_transmitted_hi; + u32 total_unicast_packets_transmitted_lo; + u32 total_multicast_packets_transmitted_hi; + u32 total_multicast_packets_transmitted_lo; + u32 total_broadcast_packets_transmitted_hi; + u32 total_broadcast_packets_transmitted_lo; + u32 valid_bytes_received_hi; + u32 valid_bytes_received_lo; + + u32 total_tpa_bytes_hi_old; + u32 total_tpa_bytes_lo_old; + + u32 driver_xoff_old; + u32 rx_err_discard_pkt_old; + u32 rx_skb_alloc_failed_old; + u32 hw_csum_err_old; +}; + +struct bnx2x_net_stats_old { + u32 rx_dropped; +}; + +struct bnx2x_fw_port_stats_old { + u32 mac_filter_discard; + u32 mf_tag_discard; + u32 brb_truncate_discard; + u32 mac_discard; +}; + + /**************************************************************************** * Macros ****************************************************************************/ @@ -348,11 +411,28 @@ struct bnx2x_eth_q_stats { ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ } while (0) +#define UPDATE_EXTEND_E_TSTAT(s, t) \ + do { \ + UPDATE_EXTEND_TSTAT(s, t); \ + ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \ + } while (0) + #define UPDATE_EXTEND_USTAT(s, t) \ do { \ diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \ old_uclient->s = uclient->s; \ - ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ + } while (0) + +#define UPDATE_EXTEND_E_USTAT(s, t) \ + do { \ + UPDATE_EXTEND_USTAT(s, t); \ + ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \ + } while (0) + +#define UPDATE_EXTEND_E_USTAT(s, t) \ + do { \ + UPDATE_EXTEND_USTAT(s, t); \ + ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \ } while (0) #define UPDATE_EXTEND_XSTAT(s, t) \ @@ -362,6 +442,66 @@ struct bnx2x_eth_q_stats { ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ } while (0) +#define UPDATE_QSTAT(s, t) \ + do { \ + qstats->t##_hi = qstats_old->t##_hi + le32_to_cpu(s.hi); \ + qstats->t##_lo = qstats_old->t##_lo + le32_to_cpu(s.lo); \ + } while (0) + +#define UPDATE_QSTAT_OLD(f) \ + do { \ + qstats_old->f = qstats->f; \ + } while (0) + +#define UPDATE_ESTAT_QSTAT_64(s) \ + do { \ + ADD_64(estats->s##_hi, qstats->s##_hi, \ + estats->s##_lo, qstats->s##_lo); \ + SUB_64(estats->s##_hi, qstats_old->s##_hi_old, \ + estats->s##_lo, qstats_old->s##_lo_old); \ + qstats_old->s##_hi_old = qstats->s##_hi; \ + qstats_old->s##_lo_old = qstats->s##_lo; \ + } while (0) + +#define UPDATE_ESTAT_QSTAT(s) \ + do { \ + estats->s += qstats->s; \ + estats->s -= qstats_old->s##_old; \ + qstats_old->s##_old = qstats->s; \ + } while (0) + +#define UPDATE_FSTAT_QSTAT(s) \ + do { \ + ADD_64(fstats->s##_hi, qstats->s##_hi, \ + fstats->s##_lo, qstats->s##_lo); \ + SUB_64(fstats->s##_hi, qstats_old->s##_hi, \ + fstats->s##_lo, qstats_old->s##_lo); \ + estats->s##_hi = fstats->s##_hi; \ + estats->s##_lo = fstats->s##_lo; \ + qstats_old->s##_hi = qstats->s##_hi; \ + qstats_old->s##_lo = qstats->s##_lo; \ + } while (0) + +#define UPDATE_FW_STAT(s) \ + do { \ + estats->s = le32_to_cpu(tport->s) + fwstats->s; \ + } while (0) + +#define UPDATE_FW_STAT_OLD(f) \ + do { \ + fwstats->f = estats->f; \ + } while (0) + +#define UPDATE_ESTAT(s, t) \ + do { \ + SUB_64(estats->s##_hi, estats_old->t##_hi, \ + estats->s##_lo, estats_old->t##_lo); \ + ADD_64(estats->s##_hi, estats->t##_hi, \ + estats->s##_lo, estats->t##_lo); \ + estats_old->t##_hi = estats->t##_hi; \ + estats_old->t##_lo = estats->t##_lo; \ + } while (0) + /* minuend -= subtrahend */ #define SUB_64(m_hi, s_hi, m_lo, s_lo) \ do { \ @@ -388,4 +528,10 @@ void bnx2x_stats_init(struct bnx2x *bp); void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event); +/** + * bnx2x_save_statistics - save statistics when unloading. + * + * @bp: driver handle + */ +void bnx2x_save_statistics(struct bnx2x *bp); #endif /* BNX2X_STATS_H */ -- GitLab From e18c56b2e94080982d4542987a6fcf80b12d9414 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:23 +0000 Subject: [PATCH 0770/1846] bnx2x: half duplex support added for several boards From: Yaniv Rosner Several boards require an additional HW bit written in-order to enable half duplex. Signed-off-by: Yaniv Rosner Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 3 +++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index 2102ad593c14..e7b0baf873b6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -1612,6 +1612,9 @@ static void bnx2x_umac_enable(struct link_params *params, if (!(vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)) val |= UMAC_COMMAND_CONFIG_REG_PAUSE_IGNORE; + if (vars->duplex == DUPLEX_HALF) + val |= UMAC_COMMAND_CONFIG_REG_HD_ENA; + REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); udelay(50); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h index c95d9dcac6df..2feaca52d70c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h @@ -4812,6 +4812,7 @@ The fields are: [4:0] - tail pointer; 10:5] - Link List size; 15:11] - header pointer. */ #define UCM_REG_XX_TABLE 0xe0300 +#define UMAC_COMMAND_CONFIG_REG_HD_ENA (0x1<<10) #define UMAC_COMMAND_CONFIG_REG_IGNORE_TX_PAUSE (0x1<<28) #define UMAC_COMMAND_CONFIG_REG_LOOP_ENA (0x1<<15) #define UMAC_COMMAND_CONFIG_REG_NO_LGTH_CHECK (0x1<<24) -- GitLab From 9e7e8399c5d3c4dfaf84324a4a6b07a701d3e482 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:24 +0000 Subject: [PATCH 0771/1846] bnx2x: ethtool publishes link partners speed and FC Following the changes in the ethtool source code, this patch enables the bnx2x driver to publish the Link partner's capabilities s, when ethtool is used on an interface which completed autoneg. Signed-off-by: Yuval Mintz Signed-off-by: Yaniv Rosner Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 39 ++- .../net/ethernet/broadcom/bnx2x/bnx2x_link.c | 304 +++++++++++++----- .../net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 8 +- 3 files changed, 272 insertions(+), 79 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 137968d33d1e..4cbd474ccecc 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -246,6 +246,34 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) else cmd->autoneg = AUTONEG_DISABLE; + /* Publish LP advertised speeds and FC */ + if (bp->link_vars.link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { + u32 status = bp->link_vars.link_status; + + cmd->lp_advertising |= ADVERTISED_Autoneg; + if (status & LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE) + cmd->lp_advertising |= ADVERTISED_Pause; + if (status & LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE) + cmd->lp_advertising |= ADVERTISED_Asym_Pause; + + if (status & LINK_STATUS_LINK_PARTNER_10THD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_10baseT_Half; + if (status & LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_10baseT_Full; + if (status & LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_100baseT_Half; + if (status & LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_100baseT_Full; + if (status & LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_1000baseT_Half; + if (status & LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_1000baseT_Full; + if (status & LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_2500baseX_Full; + if (status & LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE) + cmd->lp_advertising |= ADVERTISED_10000baseT_Full; + } + cmd->maxtxpkt = 0; cmd->maxrxpkt = 0; @@ -1415,12 +1443,19 @@ static void bnx2x_get_pauseparam(struct net_device *dev, { struct bnx2x *bp = netdev_priv(dev); int cfg_idx = bnx2x_get_link_cfg_idx(bp); + int cfg_reg; + epause->autoneg = (bp->link_params.req_flow_ctrl[cfg_idx] == BNX2X_FLOW_CTRL_AUTO); - epause->rx_pause = ((bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_RX) == + if (!epause->autoneg) + cfg_reg = bp->link_vars.flow_ctrl; + else + cfg_reg = bp->link_params.req_fc_auto_adv; + + epause->rx_pause = ((cfg_reg & BNX2X_FLOW_CTRL_RX) == BNX2X_FLOW_CTRL_RX); - epause->tx_pause = ((bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX) == + epause->tx_pause = ((cfg_reg & BNX2X_FLOW_CTRL_TX) == BNX2X_FLOW_CTRL_TX); DP(NETIF_MSG_LINK, "ethtool_pauseparam: cmd %d\n" diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index e7b0baf873b6..fba4c4110bd7 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -3638,45 +3638,50 @@ static void bnx2x_pause_resolve(struct link_vars *vars, u32 pause_result) vars->link_status |= LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE; } -static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, - struct link_params *params, - struct link_vars *vars) +static void bnx2x_ext_phy_update_adv_fc(struct bnx2x_phy *phy, + struct link_params *params, + struct link_vars *vars) { - struct bnx2x *bp = params->bp; u16 ld_pause; /* local */ u16 lp_pause; /* link partner */ u16 pause_result; - u8 ret = 0; - /* read twice */ + struct bnx2x *bp = params->bp; + if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { + bnx2x_cl22_read(bp, phy, 0x4, &ld_pause); + bnx2x_cl22_read(bp, phy, 0x5, &lp_pause); + } else { + bnx2x_cl45_read(bp, phy, + MDIO_AN_DEVAD, + MDIO_AN_REG_ADV_PAUSE, &ld_pause); + bnx2x_cl45_read(bp, phy, + MDIO_AN_DEVAD, + MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); + } + pause_result = (ld_pause & + MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; + pause_result |= (lp_pause & + MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; + DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", pause_result); + bnx2x_pause_resolve(vars, pause_result); +} +static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, + struct link_params *params, + struct link_vars *vars) +{ + u8 ret = 0; vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; - - if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) + if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) { + /* Update the advertised flow-controled of LD/LP in AN */ + if (phy->req_line_speed == SPEED_AUTO_NEG) + bnx2x_ext_phy_update_adv_fc(phy, params, vars); + /* But set the flow-control result as the requested one */ vars->flow_ctrl = phy->req_flow_ctrl; - else if (phy->req_line_speed != SPEED_AUTO_NEG) + } else if (phy->req_line_speed != SPEED_AUTO_NEG) vars->flow_ctrl = params->req_fc_auto_adv; else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { ret = 1; - if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { - bnx2x_cl22_read(bp, phy, - 0x4, &ld_pause); - bnx2x_cl22_read(bp, phy, - 0x5, &lp_pause); - } else { - bnx2x_cl45_read(bp, phy, - MDIO_AN_DEVAD, - MDIO_AN_REG_ADV_PAUSE, &ld_pause); - bnx2x_cl45_read(bp, phy, - MDIO_AN_DEVAD, - MDIO_AN_REG_LP_AUTO_NEG, &lp_pause); - } - pause_result = (ld_pause & - MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; - pause_result |= (lp_pause & - MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; - DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n", - pause_result); - bnx2x_pause_resolve(vars, pause_result); + bnx2x_ext_phy_update_adv_fc(phy, params, vars); } return ret; } @@ -5219,22 +5224,69 @@ static int bnx2x_direct_parallel_detect_used(struct bnx2x_phy *phy, return 0; } +static void bnx2x_update_adv_fc(struct bnx2x_phy *phy, + struct link_params *params, + struct link_vars *vars, + u32 gp_status) +{ + u16 ld_pause; /* local driver */ + u16 lp_pause; /* link partner */ + u16 pause_result; + struct bnx2x *bp = params->bp; + if ((gp_status & + (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | + MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == + (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | + MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { + + CL22_RD_OVER_CL45(bp, phy, + MDIO_REG_BANK_CL73_IEEEB1, + MDIO_CL73_IEEEB1_AN_ADV1, + &ld_pause); + CL22_RD_OVER_CL45(bp, phy, + MDIO_REG_BANK_CL73_IEEEB1, + MDIO_CL73_IEEEB1_AN_LP_ADV1, + &lp_pause); + pause_result = (ld_pause & + MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) >> 8; + pause_result |= (lp_pause & + MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) >> 10; + DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", pause_result); + } else { + CL22_RD_OVER_CL45(bp, phy, + MDIO_REG_BANK_COMBO_IEEE0, + MDIO_COMBO_IEEE0_AUTO_NEG_ADV, + &ld_pause); + CL22_RD_OVER_CL45(bp, phy, + MDIO_REG_BANK_COMBO_IEEE0, + MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, + &lp_pause); + pause_result = (ld_pause & + MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; + pause_result |= (lp_pause & + MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; + DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", pause_result); + } + bnx2x_pause_resolve(vars, pause_result); + +} + static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars, u32 gp_status) { struct bnx2x *bp = params->bp; - u16 ld_pause; /* local driver */ - u16 lp_pause; /* link partner */ - u16 pause_result; - vars->flow_ctrl = BNX2X_FLOW_CTRL_NONE; /* resolve from gp_status in case of AN complete and not sgmii */ - if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) + if (phy->req_flow_ctrl != BNX2X_FLOW_CTRL_AUTO) { + /* Update the advertised flow-controled of LD/LP in AN */ + if (phy->req_line_speed == SPEED_AUTO_NEG) + bnx2x_update_adv_fc(phy, params, vars, gp_status); + /* But set the flow-control result as the requested one */ vars->flow_ctrl = phy->req_flow_ctrl; - else if (phy->req_line_speed != SPEED_AUTO_NEG) + } else if (phy->req_line_speed != SPEED_AUTO_NEG) vars->flow_ctrl = params->req_fc_auto_adv; else if ((gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && (!(vars->phy_flags & PHY_SGMII_FLAG))) { @@ -5242,45 +5294,7 @@ static void bnx2x_flow_ctrl_resolve(struct bnx2x_phy *phy, vars->flow_ctrl = params->req_fc_auto_adv; return; } - if ((gp_status & - (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | - MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) == - (MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_AUTONEG_COMPLETE | - MDIO_GP_STATUS_TOP_AN_STATUS1_CL73_MR_LP_NP_AN_ABLE)) { - - CL22_RD_OVER_CL45(bp, phy, - MDIO_REG_BANK_CL73_IEEEB1, - MDIO_CL73_IEEEB1_AN_ADV1, - &ld_pause); - CL22_RD_OVER_CL45(bp, phy, - MDIO_REG_BANK_CL73_IEEEB1, - MDIO_CL73_IEEEB1_AN_LP_ADV1, - &lp_pause); - pause_result = (ld_pause & - MDIO_CL73_IEEEB1_AN_ADV1_PAUSE_MASK) - >> 8; - pause_result |= (lp_pause & - MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK) - >> 10; - DP(NETIF_MSG_LINK, "pause_result CL73 0x%x\n", - pause_result); - } else { - CL22_RD_OVER_CL45(bp, phy, - MDIO_REG_BANK_COMBO_IEEE0, - MDIO_COMBO_IEEE0_AUTO_NEG_ADV, - &ld_pause); - CL22_RD_OVER_CL45(bp, phy, - MDIO_REG_BANK_COMBO_IEEE0, - MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1, - &lp_pause); - pause_result = (ld_pause & - MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>5; - pause_result |= (lp_pause & - MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; - DP(NETIF_MSG_LINK, "pause_result CL37 0x%x\n", - pause_result); - } - bnx2x_pause_resolve(vars, pause_result); + bnx2x_update_adv_fc(phy, params, vars, gp_status); } DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", vars->flow_ctrl); } @@ -5499,6 +5513,33 @@ static int bnx2x_link_settings_status(struct bnx2x_phy *phy, } } + /* Read LP advertised speeds*/ + if (SINGLE_MEDIA_DIRECT(params) && + (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE)) { + u16 val; + + CL22_RD_OVER_CL45(bp, phy, MDIO_REG_BANK_CL73_IEEEB1, + MDIO_CL73_IEEEB1_AN_LP_ADV2, &val); + + if (val & MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; + if (val & (MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4 | + MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + + CL22_RD_OVER_CL45(bp, phy, MDIO_REG_BANK_OVER_1G, + MDIO_OVER_1G_LP_UP1, &val); + + if (val & MDIO_OVER_1G_UP1_2_5G) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE; + if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + } + DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", vars->duplex, vars->flow_ctrl, vars->link_status); return rc; @@ -5556,6 +5597,34 @@ static int bnx2x_warpcore_read_status(struct bnx2x_phy *phy, } } + if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) && + SINGLE_MEDIA_DIRECT(params)) { + u16 val; + + bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, + MDIO_AN_REG_LP_AUTO_NEG2, &val); + + if (val & MDIO_CL73_IEEEB1_AN_ADV2_ADVR_1000M_KX) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; + if (val & (MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KX4 | + MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + + bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, + MDIO_WC_REG_DIGITAL3_LP_UP1, &val); + + if (val & MDIO_OVER_1G_UP1_2_5G) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE; + if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + + } + + if (lane < 2) { bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, MDIO_WC_REG_GP2_STATUS_GP_2_2, &gp_speed); @@ -6421,7 +6490,9 @@ static int bnx2x_update_link_down(struct link_params *params, LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | - LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK); + LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK | + LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE | + LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE); vars->line_speed = 0; bnx2x_update_mng(params, vars->link_status); @@ -7370,6 +7441,19 @@ static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy, bnx2x_8073_resolve_fc(phy, params, vars); vars->duplex = DUPLEX_FULL; } + + if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { + bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, + MDIO_AN_REG_LP_AUTO_NEG2, &val1); + + if (val1 & (1<<5)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; + if (val1 & (1<<7)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + } + return link_up; } @@ -9951,6 +10035,42 @@ static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy, DP(NETIF_MSG_LINK, "BCM84823: link speed is %d\n", vars->line_speed); bnx2x_ext_phy_resolve_fc(phy, params, vars); + + /* Read LP advertised speeds */ + bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, + MDIO_AN_REG_CL37_FC_LP, &val); + if (val & (1<<5)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10THD_CAPABLE; + if (val & (1<<6)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE; + if (val & (1<<7)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE; + if (val & (1<<8)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE; + if (val & (1<<9)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_100T4_CAPABLE; + + bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, + MDIO_AN_REG_1000T_STATUS, &val); + + if (val & (1<<10)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE; + if (val & (1<<11)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; + + bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD, + MDIO_AN_REG_MASTER_STATUS, &val); + + if (val & (1<<11)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; } return link_up; @@ -10574,6 +10694,35 @@ static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, } bnx2x_ext_phy_resolve_fc(phy, params, vars); + + if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { + /* report LP advertised speeds */ + bnx2x_cl22_read(bp, phy, 0x5, &val); + + if (val & (1<<5)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10THD_CAPABLE; + if (val & (1<<6)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE; + if (val & (1<<7)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE; + if (val & (1<<8)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE; + if (val & (1<<9)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_100T4_CAPABLE; + + bnx2x_cl22_read(bp, phy, 0xa, &val); + if (val & (1<<10)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE; + if (val & (1<<11)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE; + } } return link_up; } @@ -10702,6 +10851,11 @@ static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy, val2, (val2 & (1<<14))); bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); bnx2x_ext_phy_resolve_fc(phy, params, vars); + + /* read LP advertised speeds */ + if (val2 & (1<<11)) + vars->link_status |= + LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; } return link_up; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h index 2feaca52d70c..fd7fb4581849 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h @@ -6406,6 +6406,7 @@ #define MDIO_CL73_IEEEB1_AN_LP_ADV1_ASYMMETRIC 0x0800 #define MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_BOTH 0x0C00 #define MDIO_CL73_IEEEB1_AN_LP_ADV1_PAUSE_MASK 0x0C00 +#define MDIO_CL73_IEEEB1_AN_LP_ADV2 0x04 #define MDIO_REG_BANK_RX0 0x80b0 #define MDIO_RX0_RX_STATUS 0x10 @@ -6799,14 +6800,16 @@ Theotherbitsarereservedandshouldbezero*/ #define MDIO_AN_REG_ADV_PAUSE_MASK 0x0C00 #define MDIO_AN_REG_ADV 0x0011 #define MDIO_AN_REG_ADV2 0x0012 -#define MDIO_AN_REG_LP_AUTO_NEG 0x0013 +#define MDIO_AN_REG_LP_AUTO_NEG 0x0013 +#define MDIO_AN_REG_LP_AUTO_NEG2 0x0014 #define MDIO_AN_REG_MASTER_STATUS 0x0021 /*bcm*/ #define MDIO_AN_REG_LINK_STATUS 0x8304 #define MDIO_AN_REG_CL37_CL73 0x8370 #define MDIO_AN_REG_CL37_AN 0xffe0 #define MDIO_AN_REG_CL37_FC_LD 0xffe4 -#define MDIO_AN_REG_CL37_FC_LP 0xffe5 +#define MDIO_AN_REG_CL37_FC_LP 0xffe5 +#define MDIO_AN_REG_1000T_STATUS 0xffea #define MDIO_AN_REG_8073_2_5G 0x8329 #define MDIO_AN_REG_8073_BAM 0x8350 @@ -6971,6 +6974,7 @@ Theotherbitsarereservedandshouldbezero*/ #define MDIO_WC_REG_SERDESDIGITAL_MISC1 0x8308 #define MDIO_WC_REG_SERDESDIGITAL_MISC2 0x8309 #define MDIO_WC_REG_DIGITAL3_UP1 0x8329 +#define MDIO_WC_REG_DIGITAL3_LP_UP1 0x832c #define MDIO_WC_REG_DIGITAL4_MISC3 0x833c #define MDIO_WC_REG_DIGITAL5_MISC6 0x8345 #define MDIO_WC_REG_DIGITAL5_MISC7 0x8349 -- GitLab From 1b85ae52733b859e280035330e016731d4a62307 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:25 +0000 Subject: [PATCH 0772/1846] bnx2x: added autoneg-restart after link advertisement changes From: Yaniv Rosner Signed-off-by: Yaniv Rosner Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index fba4c4110bd7..acc9649667d0 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -3793,7 +3793,7 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, /* Enable Autoneg */ bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, - MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1000); + MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x1200); } -- GitLab From 817a8aa8cfa1ebfb7bf27afb53ebb1ec3d49b564 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:26 +0000 Subject: [PATCH 0773/1846] bnx2x: force 10G on 84833 phy should be autoneg with only 10G advertised From: Yaniv Rosner Signed-off-by: Yaniv Rosner Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index acc9649667d0..57fe056bc5e0 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -9492,13 +9492,8 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, { struct bnx2x *bp = params->bp; u16 autoneg_val, an_1000_val, an_10_100_val, an_10g_val; - u16 tmp_req_line_speed; - tmp_req_line_speed = phy->req_line_speed; - if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { - if (phy->req_line_speed == SPEED_10000) - phy->req_line_speed = SPEED_AUTO_NEG; - } else { + if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { /* Save spirom version */ bnx2x_save_848xx_spirom_version(phy, bp, params->port); } @@ -9642,8 +9637,6 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, MDIO_AN_REG_8481_10GBASE_T_AN_CTRL, 1); - phy->req_line_speed = tmp_req_line_speed; - return 0; } -- GitLab From afa13b4b94bc4b3247fa46dd8698c8dbfe1a615c Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:27 +0000 Subject: [PATCH 0774/1846] bnx2x: allocate memory dynamically in ethtool self-test. From: Merav Sicron Current ethtool self tests usesa large buffer on stack. This patch replaces that array by dynamically allocated memory Signed-off-by: Merav Sicron Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 4cbd474ccecc..c18dc1d14a1d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -2016,14 +2016,22 @@ static int bnx2x_test_nvram(struct bnx2x *bp) { 0x708, 0x70 }, /* manuf_key_info */ { 0, 0 } }; - __be32 buf[0x350 / 4]; - u8 *data = (u8 *)buf; + __be32 *buf; + u8 *data; int i, rc; u32 magic, crc; if (BP_NOMCP(bp)) return 0; + buf = kmalloc(0x350, GFP_KERNEL); + if (!buf) { + DP(NETIF_MSG_PROBE, "kmalloc failed\n"); + rc = -ENOMEM; + goto test_nvram_exit; + } + data = (u8 *)buf; + rc = bnx2x_nvram_read(bp, 0, data, 4); if (rc) { DP(NETIF_MSG_PROBE, "magic value read (rc %d)\n", rc); @@ -2057,6 +2065,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) } test_nvram_exit: + kfree(buf); return rc; } -- GitLab From d760fc37b0f74502b3f748951f22c6683b079a8e Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:28 +0000 Subject: [PATCH 0775/1846] bnx2x: allocate smaller Rx rings for 1G functions Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 7f6a1b1be74d..5d15efc2a9e2 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -3122,9 +3122,16 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index) } else #endif if (!bp->rx_ring_size) { + u32 cfg = SHMEM_RD(bp, + dev_info.port_hw_config[BP_PORT(bp)].default_cfg); rx_ring_size = MAX_RX_AVAIL/BNX2X_NUM_RX_QUEUES(bp); + /* Dercease ring size for 1G functions */ + if ((cfg & PORT_HW_CFG_NET_SERDES_IF_MASK) == + PORT_HW_CFG_NET_SERDES_IF_SGMII) + rx_ring_size /= 10; + /* allocate at least number of buffers required by FW */ rx_ring_size = max_t(int, bp->disable_tpa ? MIN_RX_SIZE_NONTPA : MIN_RX_SIZE_TPA, rx_ring_size); -- GitLab From 82fa848c117e57f0b3fd848f2aaf3f6859f42201 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:29 +0000 Subject: [PATCH 0776/1846] bnx2x: notify cnic of address of info-to-the-mcp Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index e0d5f15784fd..1527aedd9786 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -7125,6 +7125,11 @@ int bnx2x_alloc_mem(struct bnx2x *bp) BNX2X_PCI_ALLOC(bp->slowpath, &bp->slowpath_mapping, sizeof(struct bnx2x_slowpath)); +#ifdef BCM_CNIC + /* write address to which L5 should insert its values */ + bp->cnic_eth_dev.addr_drv_info_to_mcp = &bp->slowpath->drv_info_to_mcp; +#endif + /* Allocated memory for FW statistics */ if (bnx2x_alloc_fw_stats_mem(bp)) goto alloc_mem_err; -- GitLab From 10bd1f243c3a5ea1aebae88d21932e5614afa9cc Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:30 +0000 Subject: [PATCH 0777/1846] bnx2x: allow BCM84833 phy to advertise 100Base-T speeds Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 1527aedd9786..9f2911982853 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -9298,6 +9298,11 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) SPEED_AUTO_NEG; bp->port.advertising[idx] |= bp->port.supported[idx]; + if (bp->link_params.phy[EXT_PHY1].type == + PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) + bp->port.advertising[idx] |= + (SUPPORTED_100baseT_Half | + SUPPORTED_100baseT_Full); } else { /* force 10G, no AN */ bp->link_params.req_line_speed[idx] = -- GitLab From 04f2d51313938d004983652ea6162d4940d83a04 Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:31 +0000 Subject: [PATCH 0778/1846] bnx2x: removed code re-checking memory base after device open Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 9f2911982853..b9afd26cfbe6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -11352,17 +11352,6 @@ static void bnx2x_eeh_recover(struct bnx2x *bp) mutex_init(&bp->port.phy_mutex); - bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR); - bp->link_params.shmem_base = bp->common.shmem_base; - BNX2X_DEV_INFO("shmem offset is 0x%x\n", bp->common.shmem_base); - - if (!bp->common.shmem_base || - (bp->common.shmem_base < 0xA0000) || - (bp->common.shmem_base >= 0xC0000)) { - BNX2X_DEV_INFO("MCP not active\n"); - bp->flags |= NO_MCP_FLAG; - return; - } val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]); if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) -- GitLab From a1e785e02bb53573443c7e58a444cef1a049f6ce Mon Sep 17 00:00:00 2001 From: Mintz Yuval Date: Wed, 15 Feb 2012 02:10:32 +0000 Subject: [PATCH 0779/1846] bnx2x: allow all functions to display the phy FW version The phy FW version is stored in regular memory, no MDC-MDIO access or any special locks are required to read it in the current implementation. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 10 ++-------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 4 ++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index c18dc1d14a1d..7e57fa40d2e3 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -806,14 +806,8 @@ static void bnx2x_get_drvinfo(struct net_device *dev, strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); phy_fw_ver[0] = '\0'; - if (bp->port.pmf) { - bnx2x_acquire_phy_lock(bp); - bnx2x_get_ext_phy_fw_version(&bp->link_params, - (bp->state != BNX2X_STATE_CLOSED), - phy_fw_ver, PHY_FW_VER_LEN); - bnx2x_release_phy_lock(bp); - } - + bnx2x_get_ext_phy_fw_version(&bp->link_params, + phy_fw_ver, PHY_FW_VER_LEN); strlcpy(info->fw_version, bp->fw_ver, sizeof(info->fw_version)); snprintf(info->fw_version + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver), "bc %d.%d.%d%s%s", diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c index 57fe056bc5e0..beb4cdbdb6e1 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c @@ -6042,8 +6042,8 @@ static int bnx2x_null_format_ver(u32 spirom_ver, u8 *str, u16 *len) return 0; } -int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, - u8 *version, u16 len) +int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 *version, + u16 len) { struct bnx2x *bp; u32 spirom_ver = 0; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h index 9cc7bafb3dfe..7ba557a610da 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h @@ -337,8 +337,8 @@ int bnx2x_phy_write(struct link_params *params, u8 phy_addr, void bnx2x_link_status_update(struct link_params *input, struct link_vars *output); /* returns string representing the fw_version of the external phy */ -int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 driver_loaded, - u8 *version, u16 len); +int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 *version, + u16 len); /* Set/Unset the led Basically, the CLC takes care of the led for the link, but in case one needs -- GitLab From f2cedb63df14342ad40a8b5b324fc5d94a60b665 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 15 Feb 2012 06:45:39 +0000 Subject: [PATCH 0780/1846] net: replace random_ether_addr() with eth_hw_addr_random() Replace usage of random_ether_addr() with eth_hw_addr_random() to set addr_assign_type correctly to NET_ADDR_RANDOM. Change the trivial cases. v2: adapt to renamed eth_hw_addr_random() Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/cadence/macb.c | 2 +- drivers/net/ethernet/cirrus/ep93xx_eth.c | 2 +- drivers/net/ethernet/davicom/dm9000.c | 2 +- drivers/net/ethernet/dnet.c | 2 +- drivers/net/ethernet/faraday/ftgmac100.c | 2 +- drivers/net/ethernet/faraday/ftmac100.c | 2 +- drivers/net/ethernet/mipsnet.c | 2 +- drivers/net/ethernet/natsemi/macsonic.c | 2 +- drivers/net/ethernet/rdc/r6040.c | 2 +- drivers/net/ethernet/sis/sis900.c | 2 +- drivers/net/ethernet/smsc/smsc9420.c | 5 ++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/ethernet/toshiba/tc35815.c | 2 +- drivers/net/ethernet/via/via-rhine.c | 2 +- drivers/net/ifb.c | 2 +- drivers/net/tun.c | 2 +- drivers/net/usb/smsc75xx.c | 2 +- drivers/net/usb/smsc95xx.c | 2 +- drivers/net/veth.c | 4 ++-- drivers/net/virtio_net.c | 2 +- drivers/net/wan/hdlc_fr.c | 2 +- drivers/net/wan/hdlc_raw_eth.c | 2 +- net/ipv4/ip_gre.c | 2 +- net/l2tp/l2tp_eth.c | 2 +- 24 files changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 85e044567f68..c4834c23be35 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -87,7 +87,7 @@ static void __init macb_get_hwaddr(struct macb *bp) memcpy(bp->dev->dev_addr, addr, sizeof(addr)); } else { netdev_info(bp->dev, "invalid hw address, using random\n"); - random_ether_addr(bp->dev->dev_addr); + eth_hw_addr_random(bp->dev); } } diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c index c21e5ab8d1ef..78c55213eaf7 100644 --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c @@ -859,7 +859,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev) ep->mdc_divisor = 40; /* Max HCLK 100 MHz, min MDIO clk 2.5 MHz. */ if (is_zero_ether_addr(dev->dev_addr)) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); err = register_netdev(dev); if (err) { diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c index 42383ab5227e..36499d5edd95 100644 --- a/drivers/net/ethernet/davicom/dm9000.c +++ b/drivers/net/ethernet/davicom/dm9000.c @@ -1585,7 +1585,7 @@ dm9000_probe(struct platform_device *pdev) dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please " "set using ifconfig\n", ndev->name); - random_ether_addr(ndev->dev_addr); + eth_hw_addr_random(ndev); mac_src = "random"; } diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c index 8536e376555a..b276469f74e9 100644 --- a/drivers/net/ethernet/dnet.c +++ b/drivers/net/ethernet/dnet.c @@ -895,7 +895,7 @@ static int __devinit dnet_probe(struct platform_device *pdev) if (!is_valid_ether_addr(dev->dev_addr)) { /* choose a random ethernet address */ - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); __dnet_set_hwaddr(bp); } diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index 47f85c337cf7..16b07048274c 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1289,7 +1289,7 @@ static int ftgmac100_probe(struct platform_device *pdev) netdev_info(netdev, "irq %d, mapped at %p\n", priv->irq, priv->base); if (!is_valid_ether_addr(netdev->dev_addr)) { - random_ether_addr(netdev->dev_addr); + eth_hw_addr_random(netdev); netdev_info(netdev, "generated random MAC address %pM\n", netdev->dev_addr); } diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c index bb336a0959c9..829b1092fd78 100644 --- a/drivers/net/ethernet/faraday/ftmac100.c +++ b/drivers/net/ethernet/faraday/ftmac100.c @@ -1133,7 +1133,7 @@ static int ftmac100_probe(struct platform_device *pdev) netdev_info(netdev, "irq %d, mapped at %p\n", priv->irq, priv->base); if (!is_valid_ether_addr(netdev->dev_addr)) { - random_ether_addr(netdev->dev_addr); + eth_hw_addr_random(netdev); netdev_info(netdev, "generated random MAC address %pM\n", netdev->dev_addr); } diff --git a/drivers/net/ethernet/mipsnet.c b/drivers/net/ethernet/mipsnet.c index dbc666a3d523..db5285befe2a 100644 --- a/drivers/net/ethernet/mipsnet.c +++ b/drivers/net/ethernet/mipsnet.c @@ -281,7 +281,7 @@ static int __devinit mipsnet_probe(struct platform_device *dev) * Lacking any better mechanism to allocate a MAC address we use a * random one ... */ - random_ether_addr(netdev->dev_addr); + eth_hw_addr_random(netdev); err = register_netdev(netdev); if (err) { diff --git a/drivers/net/ethernet/natsemi/macsonic.c b/drivers/net/ethernet/natsemi/macsonic.c index f1b85561c650..e640e23460de 100644 --- a/drivers/net/ethernet/natsemi/macsonic.c +++ b/drivers/net/ethernet/natsemi/macsonic.c @@ -307,7 +307,7 @@ static void __devinit mac_onboard_sonic_ethernet_addr(struct net_device *dev) printk(KERN_WARNING "macsonic: MAC address in CAM entry 15 " "seems invalid, will use a random MAC\n"); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); } static int __devinit mac_onboard_sonic_probe(struct net_device *dev) diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c index 76cab284876b..b96e1920e045 100644 --- a/drivers/net/ethernet/rdc/r6040.c +++ b/drivers/net/ethernet/rdc/r6040.c @@ -1151,7 +1151,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, if (!(adrp[0] || adrp[1] || adrp[2])) { netdev_warn(dev, "MAC address not initialized, " "generating random\n"); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); } /* Link new device into r6040_root_dev */ diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index f968898c86db..5ccf02e7e3ad 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c @@ -527,7 +527,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev, ret = sis900_get_mac_addr(pci_dev, net_dev); if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) { - random_ether_addr(net_dev->dev_addr); + eth_hw_addr_random(net_dev); printk(KERN_WARNING "%s: Unreadable or invalid MAC address," "using random generated one\n", dev_name); } diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index ee1a1680b7a8..38386478532b 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c @@ -509,10 +509,9 @@ static void smsc9420_check_mac_address(struct net_device *dev) smsc_dbg(PROBE, "Mac Address is read from EEPROM"); } else { /* eeprom values are invalid, generate random MAC */ - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); smsc9420_set_mac_address(dev); - smsc_dbg(PROBE, - "MAC Address is set to random_ether_addr"); + smsc_dbg(PROBE, "MAC Address is set to random"); } } } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 166fc95e5baf..ab36dfcbd817 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -910,7 +910,7 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv) priv->dev->base_addr, priv->dev->dev_addr, 0); if (!is_valid_ether_addr(priv->dev->dev_addr)) - random_ether_addr(priv->dev->dev_addr); + eth_hw_addr_random(priv->dev); } pr_warning("%s: device MAC address %pM\n", priv->dev->name, priv->dev->dev_addr); diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c index d117ad475c3e..651a70c55e6e 100644 --- a/drivers/net/ethernet/toshiba/tc35815.c +++ b/drivers/net/ethernet/toshiba/tc35815.c @@ -849,7 +849,7 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev, /* Retrieve the ethernet address. */ if (tc35815_init_dev_addr(dev)) { dev_warn(&pdev->dev, "not valid ether addr\n"); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); } rc = register_netdev(dev); diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index cb2ff28a0602..39b8cf3dafcd 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c @@ -983,7 +983,7 @@ static int __devinit rhine_init_one(struct pci_dev *pdev, if (!is_valid_ether_addr(dev->dev_addr)) { /* Report it and use a random ethernet address instead */ netdev_err(dev, "Invalid MAC address: %pM\n", dev->dev_addr); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); netdev_info(dev, "Using random MAC address: %pM\n", dev->dev_addr); } diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index e05b645bbc32..344dceb1aaf9 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c @@ -184,7 +184,7 @@ static void ifb_setup(struct net_device *dev) dev->flags |= IFF_NOARP; dev->flags &= ~IFF_MULTICAST; dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); } static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 93c5d72711b0..2c5d34957c57 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -531,7 +531,7 @@ static void tun_net_init(struct net_device *dev) ether_setup(dev); dev->priv_flags &= ~IFF_TX_SKB_SHARING; - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); dev->tx_queue_len = TUN_READQ_SIZE; /* We prefer our own queue length */ break; diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index 3b017bbd2a22..187d01ccb973 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -615,7 +615,7 @@ static void smsc75xx_init_mac_address(struct usbnet *dev) } /* no eeprom, or eeprom values are invalid. generate random MAC */ - random_ether_addr(dev->net->dev_addr); + eth_hw_addr_random(dev->net); netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr"); } diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index d45520e6dd48..5f19f84d3494 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -614,7 +614,7 @@ static void smsc95xx_init_mac_address(struct usbnet *dev) } /* no eeprom, or eeprom values are invalid. generate random MAC */ - random_ether_addr(dev->net->dev_addr); + eth_hw_addr_random(dev->net); netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr\n"); } diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 49f4667e1fa3..b8a697f5cb69 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -346,7 +346,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, } if (tbp[IFLA_ADDRESS] == NULL) - random_ether_addr(peer->dev_addr); + eth_hw_addr_random(peer); err = register_netdevice(peer); put_net(net); @@ -368,7 +368,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, */ if (tb[IFLA_ADDRESS] == NULL) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); if (tb[IFLA_IFNAME]) nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ); diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 83c503ed4ae8..019da012669f 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1060,7 +1060,7 @@ static int virtnet_probe(struct virtio_device *vdev) if (virtio_config_val_len(vdev, VIRTIO_NET_F_MAC, offsetof(struct virtio_net_config, mac), dev->dev_addr, dev->addr_len) < 0) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); /* Set up our device-specific information */ vi = netdev_priv(dev); diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index eb2028187fbe..7c6cb4f31798 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -1087,7 +1087,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) } if (type == ARPHRD_ETHER) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); else { *(__be16*)dev->dev_addr = htons(dlci); dlci_to_q922(dev->broadcast, dlci); diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c index 05c9b0b96239..3ab72b3082de 100644 --- a/drivers/net/wan/hdlc_raw_eth.c +++ b/drivers/net/wan/hdlc_raw_eth.c @@ -101,7 +101,7 @@ static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr) old_qlen = dev->tx_queue_len; ether_setup(dev); dev->tx_queue_len = old_qlen; - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); netif_dormant_off(dev); return 0; } diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 0286d78c589c..b59414a0c1ee 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1536,7 +1536,7 @@ static int ipgre_newlink(struct net *src_net, struct net_device *dev, struct nla return -EEXIST; if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS]) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); mtu = ipgre_tunnel_bind_dev(dev); if (!tb[IFLA_MTU]) diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c index d2726a74597d..63fe5f353f04 100644 --- a/net/l2tp/l2tp_eth.c +++ b/net/l2tp/l2tp_eth.c @@ -64,7 +64,7 @@ static int l2tp_eth_dev_init(struct net_device *dev) struct l2tp_eth *priv = netdev_priv(dev); priv->dev = dev; - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); memset(&dev->broadcast[0], 0xff, 6); return 0; -- GitLab From 7ce5d222190cb3ce3ae88bafde7c4fa52a5103e0 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 15 Feb 2012 06:45:40 +0000 Subject: [PATCH 0781/1846] net: use eth_hw_addr_random() and reset addr_assign_type Use eth_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: adapt to renamed eth_hw_addr_random() Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/dummy.c | 3 ++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/calxeda/xgmac.c | 3 ++- drivers/net/ethernet/marvell/pxa168_eth.c | 3 ++- drivers/net/ethernet/micrel/ks8842.c | 3 ++- drivers/net/ethernet/micrel/ks8851.c | 3 ++- drivers/net/ethernet/micrel/ks8851_mll.c | 1 + drivers/net/ethernet/microchip/enc28j60.c | 3 ++- drivers/net/ethernet/nvidia/forcedeth.c | 3 ++- drivers/net/ethernet/smsc/smsc911x.c | 3 ++- drivers/net/ethernet/tile/tilepro.c | 3 ++- drivers/net/macvlan.c | 3 ++- drivers/net/team/team.c | 3 ++- net/bridge/br_device.c | 3 ++- net/openvswitch/vport-internal_dev.c | 3 ++- 16 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index 087648ea1edb..d5c6d92f1ee7 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c @@ -47,6 +47,7 @@ static int dummy_set_address(struct net_device *dev, void *p) if (!is_valid_ether_addr(sa->sa_data)) return -EADDRNOTAVAIL; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); return 0; } @@ -135,7 +136,7 @@ static void dummy_setup(struct net_device *dev) dev->flags &= ~IFF_MULTICAST; dev->features |= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO; dev->features |= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX; - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); } static int dummy_validate(struct nlattr *tb[], struct nlattr *data[]) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 5d15efc2a9e2..aa14502289ce 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -3007,6 +3007,7 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p) return rc; } + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); if (netif_running(dev)) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index b9afd26cfbe6..8e809c1408b4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -9683,7 +9683,7 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) if (BP_NOMCP(bp)) { BNX2X_ERROR("warning: random MAC workaround active\n"); - random_ether_addr(bp->dev->dev_addr); + eth_hw_addr_random(bp->dev); } else if (IS_MF(bp)) { val2 = MF_CFG_RD(bp, func_mf_config[func].mac_upper); val = MF_CFG_RD(bp, func_mf_config[func].mac_lower); diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index 1fce186a9031..11f667f6131a 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c @@ -1012,7 +1012,7 @@ static int xgmac_open(struct net_device *dev) * address using the following linux command: * ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx */ if (!is_valid_ether_addr(dev->dev_addr)) { - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); netdev_dbg(priv->dev, "generated random MAC address %pM\n", dev->dev_addr); } @@ -1482,6 +1482,7 @@ static int xgmac_set_mac_address(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); xgmac_set_mac_addr(ioaddr, dev->dev_addr, 0); diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 75df2091bd2e..83e37ad113e0 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -629,6 +629,7 @@ static int pxa168_eth_set_mac_address(struct net_device *dev, void *addr) if (!is_valid_ether_addr(sa->sa_data)) return -EINVAL; memcpy(oldMac, dev->dev_addr, ETH_ALEN); + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); netif_addr_lock_bh(dev); update_hash_table_mac_address(pep, oldMac, dev->dev_addr); @@ -1520,7 +1521,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task); printk(KERN_INFO "%s:Using random mac address\n", DRIVER_NAME); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); pep->pd = pdev->dev.platform_data; pep->rx_ring_size = NUM_RX_DESCS; diff --git a/drivers/net/ethernet/micrel/ks8842.c b/drivers/net/ethernet/micrel/ks8842.c index 0a85690a1321..0686b93f1857 100644 --- a/drivers/net/ethernet/micrel/ks8842.c +++ b/drivers/net/ethernet/micrel/ks8842.c @@ -1080,6 +1080,7 @@ static int ks8842_set_mac(struct net_device *netdev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; + netdev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(netdev->dev_addr, mac, netdev->addr_len); ks8842_write_mac_addr(adapter, mac); @@ -1211,7 +1212,7 @@ static int __devinit ks8842_probe(struct platform_device *pdev) ks8842_read_mac_addr(adapter, netdev->dev_addr); if (!is_valid_ether_addr(netdev->dev_addr)) - random_ether_addr(netdev->dev_addr); + eth_hw_addr_random(netdev); } id = ks8842_read16(adapter, 32, REG_SW_ID_AND_ENABLE); diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 0930b9c950d0..42a6a20efb15 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -439,7 +439,7 @@ static void ks8851_init_mac(struct ks8851_net *ks) dev->dev_addr); } - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); ks8851_write_mac_addr(dev); } @@ -1050,6 +1050,7 @@ static int ks8851_set_mac_address(struct net_device *dev, void *addr) if (!is_valid_ether_addr(sa->sa_data)) return -EADDRNOTAVAIL; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); return ks8851_write_mac_addr(dev); } diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index 3d9a04e7b49d..180460f4e41f 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c @@ -1241,6 +1241,7 @@ static int ks_set_mac_address(struct net_device *netdev, void *paddr) struct sockaddr *addr = paddr; u8 *da; + netdev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); da = (u8 *)netdev->dev_addr; diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c index 1d6b7ce3e1ee..6118bdad244f 100644 --- a/drivers/net/ethernet/microchip/enc28j60.c +++ b/drivers/net/ethernet/microchip/enc28j60.c @@ -527,6 +527,7 @@ static int enc28j60_set_mac_address(struct net_device *dev, void *addr) if (!is_valid_ether_addr(address->sa_data)) return -EADDRNOTAVAIL; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, address->sa_data, dev->addr_len); return enc28j60_set_hw_macaddr(dev); } @@ -1575,7 +1576,7 @@ static int __devinit enc28j60_probe(struct spi_device *spi) ret = -EIO; goto error_irq; } - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); enc28j60_set_hw_macaddr(dev); /* Board setup must set the relevant edge trigger type; diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 5eeb92f87380..8561dd25db66 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -3022,6 +3022,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr) /* synchronized against open : rtnl_lock() held by caller */ memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN); + dev->addr_assign_type &= ~NET_ADDR_RANDOM; if (netif_running(dev)) { netif_tx_lock_bh(dev); @@ -5741,7 +5742,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i dev_err(&pci_dev->dev, "Invalid MAC address detected: %pM - Please complain to your hardware vendor.\n", dev->dev_addr); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); dev_err(&pci_dev->dev, "Using random MAC address: %pM\n", dev->dev_addr); } diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 6a1cd2360818..4a6971027076 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -1833,6 +1833,7 @@ static int smsc911x_set_mac_address(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); spin_lock_irq(&pdata->mac_lock); @@ -2485,7 +2486,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev) "Mac Address is read from LAN911x EEPROM"); } else { /* eeprom values are invalid, generate random MAC */ - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); smsc911x_set_hw_mac_address(pdata, dev->dev_addr); SMSC_TRACE(pdata, probe, "MAC Address is set to random_ether_addr"); diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c index a8e5daaef6fa..948c4f2a2d67 100644 --- a/drivers/net/ethernet/tile/tilepro.c +++ b/drivers/net/ethernet/tile/tilepro.c @@ -2190,6 +2190,7 @@ static int tile_net_set_mac_address(struct net_device *dev, void *p) /* ISSUE: Note that "dev_addr" is now a pointer. */ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); + dev->addr_assign_type &= ~NET_ADDR_RANDOM; return 0; } @@ -2254,7 +2255,7 @@ static int tile_net_get_mac(struct net_device *dev) * can't get its MAC address, we are most likely running * the simulator, so let's generate a random MAC address. */ - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); } return 0; diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 9ea99217f116..f975afdc315c 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -372,6 +372,7 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p) if (!(dev->flags & IFF_UP)) { /* Just copy in the new address */ + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); } else { /* Rehash and update the device filters */ @@ -687,7 +688,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, return -EINVAL; if (!tb[IFLA_ADDRESS]) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); if (!macvlan_port_exists(lowerdev)) { err = macvlan_port_create(lowerdev); diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 6b678f38e5ce..8f81805c6825 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -868,6 +868,7 @@ static int team_set_mac_address(struct net_device *dev, void *p) struct team_port *port; struct sockaddr *addr = p; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); rcu_read_lock(); list_for_each_entry_rcu(port, &team->port_list, list) @@ -1087,7 +1088,7 @@ static int team_newlink(struct net *src_net, struct net_device *dev, int err; if (tb[IFLA_ADDRESS] == NULL) - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); err = register_netdevice(dev); if (err) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 71773b014e0c..a157bf827d87 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -171,6 +171,7 @@ static int br_set_mac_address(struct net_device *dev, void *p) spin_lock_bh(&br->lock); if (compare_ether_addr(dev->dev_addr, addr->sa_data)) { + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); br_fdb_change_mac_address(br, addr->sa_data); br_stp_change_bridge_id(br, addr->sa_data); @@ -334,7 +335,7 @@ void br_dev_setup(struct net_device *dev) { struct net_bridge *br = netdev_priv(dev); - random_ether_addr(dev->dev_addr); + eth_hw_addr_random(dev); ether_setup(dev); dev->netdev_ops = &br_netdev_ops; diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c index 322b8d206693..b6b1d7daa3cb 100644 --- a/net/openvswitch/vport-internal_dev.c +++ b/net/openvswitch/vport-internal_dev.c @@ -66,6 +66,7 @@ static int internal_dev_mac_addr(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; + dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); return 0; } @@ -145,7 +146,7 @@ static void do_setup(struct net_device *netdev) netdev->vlan_features = netdev->features; netdev->features |= NETIF_F_HW_VLAN_TX; netdev->hw_features = netdev->features & ~NETIF_F_LLTX; - random_ether_addr(netdev->dev_addr); + eth_hw_addr_random(netdev); } static struct vport *internal_dev_create(const struct vport_parms *parms) -- GitLab From 16387605a503a5462c79b740f9696ad4f5a960e5 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 15 Feb 2012 07:54:43 +0000 Subject: [PATCH 0782/1846] renesas/sh_eth.c: fix linux/interrupt.h included twice Remove double include of linux/interrupt.h. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index cfad09107054..98062bf4197a 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include -- GitLab From e90c9db236b7bdf6d39df28466849872d2c26d9a Mon Sep 17 00:00:00 2001 From: Divy Le Ray Date: Mon, 13 Feb 2012 10:28:46 +0000 Subject: [PATCH 0783/1846] cxgb3: update firmware version Hi Dave, This patch is sent in conjunction with the cxgb3 firmware update submission on linux-firmware. (https://lkml.org/lkml/2012/2/13/27) Cheers, Divy From: Divy Le Ray This patch updates the firmware version cxgb3 is requesting to 7.12.0. Signed-off-by: Divy Le Ray Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb3/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb3/version.h b/drivers/net/ethernet/chelsio/cxgb3/version.h index 8bda06e366c8..165bfb91487a 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/version.h +++ b/drivers/net/ethernet/chelsio/cxgb3/version.h @@ -35,10 +35,10 @@ #define DRV_DESC "Chelsio T3 Network Driver" #define DRV_NAME "cxgb3" /* Driver version */ -#define DRV_VERSION "1.1.4-ko" +#define DRV_VERSION "1.1.5-ko" /* Firmware version */ #define FW_VERSION_MAJOR 7 -#define FW_VERSION_MINOR 10 +#define FW_VERSION_MINOR 12 #define FW_VERSION_MICRO 0 #endif /* __CHELSIO_VERSION_H */ -- GitLab From 4c5e40366a8879a3fda6a22a4b65c02ef20a08c4 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 15 Feb 2012 16:37:44 -0500 Subject: [PATCH 0784/1846] decnet: net/dn.h needs net/flow.h Reported-by: Randy Dunlap Signed-off-by: David S. Miller --- include/net/dn.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/dn.h b/include/net/dn.h index 298521e0d8a2..814af0b9387d 100644 --- a/include/net/dn.h +++ b/include/net/dn.h @@ -3,6 +3,7 @@ #include #include +#include #include #include -- GitLab From 80703d265b7e8a801560d907b1bfe340e574dbca Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 15 Feb 2012 17:48:35 -0500 Subject: [PATCH 0785/1846] ipv4: Eliminate spurious argument to __ipv4_neigh_lookup 'tbl' is always arp_tbl, so specifying it is pointless. Signed-off-by: David S. Miller --- include/net/arp.h | 4 ++-- net/ipv4/route.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/arp.h b/include/net/arp.h index 0013dc87940b..4a1f3fb562eb 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -15,14 +15,14 @@ static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd return val * hash_rnd; } -static inline struct neighbour *__ipv4_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, u32 key) +static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) { struct neigh_hash_table *nht; struct neighbour *n; u32 hash_val; rcu_read_lock_bh(); - nht = rcu_dereference_bh(tbl->nht); + nht = rcu_dereference_bh(arp_tbl.nht); hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); n != NULL; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 4eeb8ce856e2..0489cedc1671 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1127,7 +1127,7 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, const vo else if (rt->rt_gateway) pkey = (const __be32 *) &rt->rt_gateway; - n = __ipv4_neigh_lookup(&arp_tbl, dev, *(__force u32 *)pkey); + n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey); if (n) return n; return neigh_create(&arp_tbl, pkey, dev); -- GitLab From c274d65c949d0909fc8f4f19561ecb7c1d3d1559 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 2 Feb 2012 22:41:49 +0000 Subject: [PATCH 0786/1846] sfc: Add support for configuring RX unicast/multicast default filters On Siena all received packets that don't match a more specific filter will match the unicast or multicast default filter. Currently we leave these set to the default values (RSS with base queue number of 0). Allow them to be reconfigured to select a single RX queue. These default filters are programmed through the FILTER_CTL register, but we represent them internally as an additional table of size 2. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/ethtool.c | 59 ++++++--- drivers/net/ethernet/sfc/filter.c | 196 ++++++++++++++++++++++++----- drivers/net/ethernet/sfc/filter.h | 6 + 3 files changed, 214 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index f887f65e4189..83191151b650 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -808,11 +808,16 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags) return efx_reset(efx, rc); } +/* MAC address mask including only MC flag */ +static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; + static int efx_ethtool_get_class_rule(struct efx_nic *efx, struct ethtool_rx_flow_spec *rule) { struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; + struct ethhdr *mac_entry = &rule->h_u.ether_spec; + struct ethhdr *mac_mask = &rule->m_u.ether_spec; struct efx_filter_spec spec; u16 vid; u8 proto; @@ -828,11 +833,18 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx, else rule->ring_cookie = spec.dmaq_id; - rc = efx_filter_get_eth_local(&spec, &vid, - rule->h_u.ether_spec.h_dest); + if (spec.type == EFX_FILTER_MC_DEF || spec.type == EFX_FILTER_UC_DEF) { + rule->flow_type = ETHER_FLOW; + memcpy(mac_mask->h_dest, mac_addr_mc_mask, ETH_ALEN); + if (spec.type == EFX_FILTER_MC_DEF) + memcpy(mac_entry->h_dest, mac_addr_mc_mask, ETH_ALEN); + return 0; + } + + rc = efx_filter_get_eth_local(&spec, &vid, mac_entry->h_dest); if (rc == 0) { rule->flow_type = ETHER_FLOW; - memset(rule->m_u.ether_spec.h_dest, ~0, ETH_ALEN); + memset(mac_mask->h_dest, ~0, ETH_ALEN); if (vid != EFX_FILTER_VID_UNSPEC) { rule->flow_type |= FLOW_EXT; rule->h_ext.vlan_tci = htons(vid); @@ -1001,27 +1013,40 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx, } case ETHER_FLOW | FLOW_EXT: - /* Must match all or none of VID */ - if (rule->m_ext.vlan_tci != htons(0xfff) && - rule->m_ext.vlan_tci != 0) - return -EINVAL; - case ETHER_FLOW: - /* Must match all of destination */ - if (!is_broadcast_ether_addr(mac_mask->h_dest)) - return -EINVAL; - /* and nothing else */ + case ETHER_FLOW: { + u16 vlan_tag_mask = (rule->flow_type & FLOW_EXT ? + ntohs(rule->m_ext.vlan_tci) : 0); + + /* Must not match on source address or Ethertype */ if (!is_zero_ether_addr(mac_mask->h_source) || mac_mask->h_proto) return -EINVAL; - rc = efx_filter_set_eth_local( - &spec, - (rule->flow_type & FLOW_EXT && rule->m_ext.vlan_tci) ? - ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC, - mac_entry->h_dest); + /* Is it a default UC or MC filter? */ + if (!compare_ether_addr(mac_mask->h_dest, mac_addr_mc_mask) && + vlan_tag_mask == 0) { + if (is_multicast_ether_addr(mac_entry->h_dest)) + rc = efx_filter_set_mc_def(&spec); + else + rc = efx_filter_set_uc_def(&spec); + } + /* Otherwise, it must match all of destination and all + * or none of VID. + */ + else if (is_broadcast_ether_addr(mac_mask->h_dest) && + (vlan_tag_mask == 0xfff || vlan_tag_mask == 0)) { + rc = efx_filter_set_eth_local( + &spec, + vlan_tag_mask ? + ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC, + mac_entry->h_dest); + } else { + rc = -EINVAL; + } if (rc) return rc; break; + } default: return -EINVAL; diff --git a/drivers/net/ethernet/sfc/filter.c b/drivers/net/ethernet/sfc/filter.c index 1fbbbee7b1ae..92517ea42715 100644 --- a/drivers/net/ethernet/sfc/filter.c +++ b/drivers/net/ethernet/sfc/filter.c @@ -35,9 +35,16 @@ enum efx_filter_table_id { EFX_FILTER_TABLE_RX_IP = 0, EFX_FILTER_TABLE_RX_MAC, + EFX_FILTER_TABLE_RX_DEF, EFX_FILTER_TABLE_COUNT, }; +enum efx_filter_index { + EFX_FILTER_INDEX_UC_DEF, + EFX_FILTER_INDEX_MC_DEF, + EFX_FILTER_SIZE_RX_DEF, +}; + struct efx_filter_table { enum efx_filter_table_id id; u32 offset; /* address of table relative to BAR */ @@ -109,7 +116,7 @@ static void efx_filter_table_reset_search_depth(struct efx_filter_table *table) memset(table->search_depth, 0, sizeof(table->search_depth)); } -static void efx_filter_push_rx_limits(struct efx_nic *efx) +static void efx_filter_push_rx_config(struct efx_nic *efx) { struct efx_filter_state *state = efx->filter_state; struct efx_filter_table *table; @@ -143,6 +150,32 @@ static void efx_filter_push_rx_limits(struct efx_nic *efx) FILTER_CTL_SRCH_FUDGE_WILD); } + table = &state->table[EFX_FILTER_TABLE_RX_DEF]; + if (table->size) { + EFX_SET_OWORD_FIELD( + filter_ctl, FRF_CZ_UNICAST_NOMATCH_Q_ID, + table->spec[EFX_FILTER_INDEX_UC_DEF].dmaq_id); + EFX_SET_OWORD_FIELD( + filter_ctl, FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED, + !!(table->spec[EFX_FILTER_INDEX_UC_DEF].flags & + EFX_FILTER_FLAG_RX_RSS)); + EFX_SET_OWORD_FIELD( + filter_ctl, FRF_CZ_UNICAST_NOMATCH_IP_OVERRIDE, + !!(table->spec[EFX_FILTER_INDEX_UC_DEF].flags & + EFX_FILTER_FLAG_RX_OVERRIDE_IP)); + EFX_SET_OWORD_FIELD( + filter_ctl, FRF_CZ_MULTICAST_NOMATCH_Q_ID, + table->spec[EFX_FILTER_INDEX_MC_DEF].dmaq_id); + EFX_SET_OWORD_FIELD( + filter_ctl, FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED, + !!(table->spec[EFX_FILTER_INDEX_MC_DEF].flags & + EFX_FILTER_FLAG_RX_RSS)); + EFX_SET_OWORD_FIELD( + filter_ctl, FRF_CZ_MULTICAST_NOMATCH_IP_OVERRIDE, + !!(table->spec[EFX_FILTER_INDEX_MC_DEF].flags & + EFX_FILTER_FLAG_RX_OVERRIDE_IP)); + } + efx_writeo(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL); } @@ -319,6 +352,52 @@ int efx_filter_set_eth_local(struct efx_filter_spec *spec, return 0; } +/** + * efx_filter_set_uc_def - specify matching otherwise-unmatched unicast + * @spec: Specification to initialise + */ +int efx_filter_set_uc_def(struct efx_filter_spec *spec) +{ + EFX_BUG_ON_PARANOID(!(spec->flags & + (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX))); + + if (spec->type != EFX_FILTER_UNSPEC) + return -EINVAL; + + spec->type = EFX_FILTER_UC_DEF; + memset(spec->data, 0, sizeof(spec->data)); /* ensure equality */ + return 0; +} + +/** + * efx_filter_set_mc_def - specify matching otherwise-unmatched multicast + * @spec: Specification to initialise + */ +int efx_filter_set_mc_def(struct efx_filter_spec *spec) +{ + EFX_BUG_ON_PARANOID(!(spec->flags & + (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX))); + + if (spec->type != EFX_FILTER_UNSPEC) + return -EINVAL; + + spec->type = EFX_FILTER_MC_DEF; + memset(spec->data, 0, sizeof(spec->data)); /* ensure equality */ + return 0; +} + +static void efx_filter_reset_rx_def(struct efx_nic *efx, unsigned filter_idx) +{ + struct efx_filter_state *state = efx->filter_state; + struct efx_filter_table *table = &state->table[EFX_FILTER_TABLE_RX_DEF]; + struct efx_filter_spec *spec = &table->spec[filter_idx]; + + efx_filter_init_rx(spec, EFX_FILTER_PRI_MANUAL, + EFX_FILTER_FLAG_RX_RSS, 0); + spec->type = EFX_FILTER_UC_DEF + filter_idx; + table->used_bitmap[0] |= 1 << filter_idx; +} + int efx_filter_get_eth_local(const struct efx_filter_spec *spec, u16 *vid, u8 *addr) { @@ -366,6 +445,13 @@ static u32 efx_filter_build(efx_oword_t *filter, struct efx_filter_spec *spec) break; } + case EFX_FILTER_TABLE_RX_DEF: + /* One filter spec per type */ + BUILD_BUG_ON(EFX_FILTER_INDEX_UC_DEF != 0); + BUILD_BUG_ON(EFX_FILTER_INDEX_MC_DEF != + EFX_FILTER_MC_DEF - EFX_FILTER_UC_DEF); + return spec->type - EFX_FILTER_UC_DEF; + case EFX_FILTER_TABLE_RX_MAC: { bool is_wild = spec->type == EFX_FILTER_MAC_WILD; EFX_POPULATE_OWORD_8( @@ -448,23 +534,40 @@ static int efx_filter_search(struct efx_filter_table *table, * MAC filters without overriding behaviour. */ +#define EFX_FILTER_MATCH_PRI_RX_MAC_OVERRIDE_IP 0 +#define EFX_FILTER_MATCH_PRI_RX_DEF_OVERRIDE_IP 1 +#define EFX_FILTER_MATCH_PRI_NORMAL_BASE 2 + #define EFX_FILTER_INDEX_WIDTH 13 #define EFX_FILTER_INDEX_MASK ((1 << EFX_FILTER_INDEX_WIDTH) - 1) static inline u32 efx_filter_make_id(enum efx_filter_table_id table_id, unsigned int index, u8 flags) { - return (table_id == EFX_FILTER_TABLE_RX_MAC && - flags & EFX_FILTER_FLAG_RX_OVERRIDE_IP) ? - index : - (table_id + 1) << EFX_FILTER_INDEX_WIDTH | index; + unsigned int match_pri = EFX_FILTER_MATCH_PRI_NORMAL_BASE + table_id; + + if (flags & EFX_FILTER_FLAG_RX_OVERRIDE_IP) { + if (table_id == EFX_FILTER_TABLE_RX_MAC) + match_pri = EFX_FILTER_MATCH_PRI_RX_MAC_OVERRIDE_IP; + else if (table_id == EFX_FILTER_TABLE_RX_DEF) + match_pri = EFX_FILTER_MATCH_PRI_RX_DEF_OVERRIDE_IP; + } + + return match_pri << EFX_FILTER_INDEX_WIDTH | index; } static inline enum efx_filter_table_id efx_filter_id_table_id(u32 id) { - return (id <= EFX_FILTER_INDEX_MASK) ? - EFX_FILTER_TABLE_RX_MAC : - (id >> EFX_FILTER_INDEX_WIDTH) - 1; + unsigned int match_pri = id >> EFX_FILTER_INDEX_WIDTH; + + switch (match_pri) { + case EFX_FILTER_MATCH_PRI_RX_MAC_OVERRIDE_IP: + return EFX_FILTER_TABLE_RX_MAC; + case EFX_FILTER_MATCH_PRI_RX_DEF_OVERRIDE_IP: + return EFX_FILTER_TABLE_RX_DEF; + default: + return match_pri - EFX_FILTER_MATCH_PRI_NORMAL_BASE; + } } static inline unsigned int efx_filter_id_index(u32 id) @@ -474,23 +577,27 @@ static inline unsigned int efx_filter_id_index(u32 id) static inline u8 efx_filter_id_flags(u32 id) { - return (id <= EFX_FILTER_INDEX_MASK) ? - EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_RX_OVERRIDE_IP : - EFX_FILTER_FLAG_RX; + unsigned int match_pri = id >> EFX_FILTER_INDEX_WIDTH; + + if (match_pri < EFX_FILTER_MATCH_PRI_NORMAL_BASE) + return EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_RX_OVERRIDE_IP; + else + return EFX_FILTER_FLAG_RX; } u32 efx_filter_get_rx_id_limit(struct efx_nic *efx) { struct efx_filter_state *state = efx->filter_state; + unsigned int table_id = EFX_FILTER_TABLE_RX_DEF; - if (state->table[EFX_FILTER_TABLE_RX_MAC].size != 0) - return ((EFX_FILTER_TABLE_RX_MAC + 1) << EFX_FILTER_INDEX_WIDTH) - + state->table[EFX_FILTER_TABLE_RX_MAC].size; - else if (state->table[EFX_FILTER_TABLE_RX_IP].size != 0) - return ((EFX_FILTER_TABLE_RX_IP + 1) << EFX_FILTER_INDEX_WIDTH) - + state->table[EFX_FILTER_TABLE_RX_IP].size; - else - return 0; + do { + if (state->table[table_id].size != 0) + return ((EFX_FILTER_MATCH_PRI_NORMAL_BASE + table_id) + << EFX_FILTER_INDEX_WIDTH) + + state->table[table_id].size; + } while (table_id--); + + return 0; } /** @@ -548,12 +655,17 @@ s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, } *saved_spec = *spec; - if (table->search_depth[spec->type] < depth) { - table->search_depth[spec->type] = depth; - efx_filter_push_rx_limits(efx); - } + if (table->id == EFX_FILTER_TABLE_RX_DEF) { + efx_filter_push_rx_config(efx); + } else { + if (table->search_depth[spec->type] < depth) { + table->search_depth[spec->type] = depth; + efx_filter_push_rx_config(efx); + } - efx_writeo(efx, &filter, table->offset + table->step * filter_idx); + efx_writeo(efx, &filter, + table->offset + table->step * filter_idx); + } netif_vdbg(efx, hw, efx->net_dev, "%s: filter type %d index %d rxq %u set", @@ -571,7 +683,11 @@ static void efx_filter_table_clear_entry(struct efx_nic *efx, { static efx_oword_t filter; - if (test_bit(filter_idx, table->used_bitmap)) { + if (table->id == EFX_FILTER_TABLE_RX_DEF) { + /* RX default filters must always exist */ + efx_filter_reset_rx_def(efx, filter_idx); + efx_filter_push_rx_config(efx); + } else if (test_bit(filter_idx, table->used_bitmap)) { __clear_bit(filter_idx, table->used_bitmap); --table->used; memset(&table->spec[filter_idx], 0, sizeof(table->spec[0])); @@ -617,7 +733,8 @@ int efx_filter_remove_id_safe(struct efx_nic *efx, spin_lock_bh(&state->lock); if (test_bit(filter_idx, table->used_bitmap) && - spec->priority == priority && spec->flags == filter_flags) { + spec->priority == priority && + !((spec->flags ^ filter_flags) & EFX_FILTER_FLAG_RX_OVERRIDE_IP)) { efx_filter_table_clear_entry(efx, table, filter_idx); if (table->used == 0) efx_filter_table_reset_search_depth(table); @@ -668,7 +785,8 @@ int efx_filter_get_filter_safe(struct efx_nic *efx, spin_lock_bh(&state->lock); if (test_bit(filter_idx, table->used_bitmap) && - spec->priority == priority && spec->flags == filter_flags) { + spec->priority == priority && + !((spec->flags ^ filter_flags) & EFX_FILTER_FLAG_RX_OVERRIDE_IP)) { *spec_buf = *spec; rc = 0; } else { @@ -722,7 +840,7 @@ u32 efx_filter_count_rx_used(struct efx_nic *efx, spin_lock_bh(&state->lock); for (table_id = EFX_FILTER_TABLE_RX_IP; - table_id <= EFX_FILTER_TABLE_RX_MAC; + table_id <= EFX_FILTER_TABLE_RX_DEF; table_id++) { table = &state->table[table_id]; for (filter_idx = 0; filter_idx < table->size; filter_idx++) { @@ -750,7 +868,7 @@ s32 efx_filter_get_rx_ids(struct efx_nic *efx, spin_lock_bh(&state->lock); for (table_id = EFX_FILTER_TABLE_RX_IP; - table_id <= EFX_FILTER_TABLE_RX_MAC; + table_id <= EFX_FILTER_TABLE_RX_DEF; table_id++) { table = &state->table[table_id]; for (filter_idx = 0; filter_idx < table->size; filter_idx++) { @@ -785,6 +903,11 @@ void efx_restore_filters(struct efx_nic *efx) for (table_id = 0; table_id < EFX_FILTER_TABLE_COUNT; table_id++) { table = &state->table[table_id]; + + /* Check whether this is a regular register table */ + if (table->step == 0) + continue; + for (filter_idx = 0; filter_idx < table->size; filter_idx++) { if (!test_bit(filter_idx, table->used_bitmap)) continue; @@ -794,7 +917,7 @@ void efx_restore_filters(struct efx_nic *efx) } } - efx_filter_push_rx_limits(efx); + efx_filter_push_rx_config(efx); spin_unlock_bh(&state->lock); } @@ -833,6 +956,10 @@ int efx_probe_filters(struct efx_nic *efx) table->offset = FR_CZ_RX_MAC_FILTER_TBL0; table->size = FR_CZ_RX_MAC_FILTER_TBL0_ROWS; table->step = FR_CZ_RX_MAC_FILTER_TBL0_STEP; + + table = &state->table[EFX_FILTER_TABLE_RX_DEF]; + table->id = EFX_FILTER_TABLE_RX_DEF; + table->size = EFX_FILTER_SIZE_RX_DEF; } for (table_id = 0; table_id < EFX_FILTER_TABLE_COUNT; table_id++) { @@ -849,6 +976,15 @@ int efx_probe_filters(struct efx_nic *efx) goto fail; } + if (state->table[EFX_FILTER_TABLE_RX_DEF].size) { + /* RX default filters must always exist */ + unsigned i; + for (i = 0; i < EFX_FILTER_SIZE_RX_DEF; i++) + efx_filter_reset_rx_def(efx, i); + } + + efx_filter_push_rx_config(efx); + return 0; fail: diff --git a/drivers/net/ethernet/sfc/filter.h b/drivers/net/ethernet/sfc/filter.h index 3d4108cd90ca..451997841dc9 100644 --- a/drivers/net/ethernet/sfc/filter.h +++ b/drivers/net/ethernet/sfc/filter.h @@ -20,6 +20,8 @@ * @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port) * @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID * @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address + * @EFX_FILTER_UC_DEF: Matching all otherwise unmatched unicast + * @EFX_FILTER_MC_DEF: Matching all otherwise unmatched multicast * @EFX_FILTER_UNSPEC: Match type is unspecified * * Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types. @@ -31,6 +33,8 @@ enum efx_filter_type { EFX_FILTER_UDP_WILD, EFX_FILTER_MAC_FULL = 4, EFX_FILTER_MAC_WILD, + EFX_FILTER_UC_DEF = 8, + EFX_FILTER_MC_DEF, EFX_FILTER_TYPE_COUNT, /* number of specific types */ EFX_FILTER_UNSPEC = 0xf, }; @@ -117,6 +121,8 @@ extern int efx_filter_set_eth_local(struct efx_filter_spec *spec, u16 vid, const u8 *addr); extern int efx_filter_get_eth_local(const struct efx_filter_spec *spec, u16 *vid, u8 *addr); +extern int efx_filter_set_uc_def(struct efx_filter_spec *spec); +extern int efx_filter_set_mc_def(struct efx_filter_spec *spec); enum { EFX_FILTER_VID_UNSPEC = 0xffff, }; -- GitLab From 3d885e39219095ec5788026a1256dff61c86fa29 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 6 Feb 2012 17:27:52 +0000 Subject: [PATCH 0787/1846] sfc: Add support for TX MAC filters On Siena each TX queue can be configured to send only packets for which there is a TX MAC filter that matches the source MAC address, queue ID, and optionally VID. This will be used to implement the 'spoofchk' feature for SR-IOV virtual functions. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/filter.c | 63 +++++++++++++++++++++++++++++-- drivers/net/ethernet/sfc/filter.h | 14 ++++++- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sfc/filter.c b/drivers/net/ethernet/sfc/filter.c index 92517ea42715..fea7f7300675 100644 --- a/drivers/net/ethernet/sfc/filter.c +++ b/drivers/net/ethernet/sfc/filter.c @@ -36,6 +36,7 @@ enum efx_filter_table_id { EFX_FILTER_TABLE_RX_IP = 0, EFX_FILTER_TABLE_RX_MAC, EFX_FILTER_TABLE_RX_DEF, + EFX_FILTER_TABLE_TX_MAC, EFX_FILTER_TABLE_COUNT, }; @@ -97,8 +98,9 @@ efx_filter_spec_table_id(const struct efx_filter_spec *spec) BUILD_BUG_ON(EFX_FILTER_TABLE_RX_IP != (EFX_FILTER_UDP_WILD >> 2)); BUILD_BUG_ON(EFX_FILTER_TABLE_RX_MAC != (EFX_FILTER_MAC_FULL >> 2)); BUILD_BUG_ON(EFX_FILTER_TABLE_RX_MAC != (EFX_FILTER_MAC_WILD >> 2)); + BUILD_BUG_ON(EFX_FILTER_TABLE_TX_MAC != EFX_FILTER_TABLE_RX_MAC + 2); EFX_BUG_ON_PARANOID(spec->type == EFX_FILTER_UNSPEC); - return spec->type >> 2; + return (spec->type >> 2) + ((spec->flags & EFX_FILTER_FLAG_TX) ? 2 : 0); } static struct efx_filter_table * @@ -179,6 +181,29 @@ static void efx_filter_push_rx_config(struct efx_nic *efx) efx_writeo(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL); } +static void efx_filter_push_tx_limits(struct efx_nic *efx) +{ + struct efx_filter_state *state = efx->filter_state; + struct efx_filter_table *table; + efx_oword_t tx_cfg; + + efx_reado(efx, &tx_cfg, FR_AZ_TX_CFG); + + table = &state->table[EFX_FILTER_TABLE_TX_MAC]; + if (table->size) { + EFX_SET_OWORD_FIELD( + tx_cfg, FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE, + table->search_depth[EFX_FILTER_MAC_FULL] + + FILTER_CTL_SRCH_FUDGE_FULL); + EFX_SET_OWORD_FIELD( + tx_cfg, FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE, + table->search_depth[EFX_FILTER_MAC_WILD] + + FILTER_CTL_SRCH_FUDGE_WILD); + } + + efx_writeo(efx, &tx_cfg, FR_AZ_TX_CFG); +} + static inline void __efx_filter_set_ipv4(struct efx_filter_spec *spec, __be32 host1, __be16 port1, __be32 host2, __be16 port2) @@ -333,7 +358,8 @@ int efx_filter_get_ipv4_full(const struct efx_filter_spec *spec, int efx_filter_set_eth_local(struct efx_filter_spec *spec, u16 vid, const u8 *addr) { - EFX_BUG_ON_PARANOID(!(spec->flags & EFX_FILTER_FLAG_RX)); + EFX_BUG_ON_PARANOID(!(spec->flags & + (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX))); /* This cannot currently be combined with other filtering */ if (spec->type != EFX_FILTER_UNSPEC) @@ -471,6 +497,18 @@ static u32 efx_filter_build(efx_oword_t *filter, struct efx_filter_spec *spec) break; } + case EFX_FILTER_TABLE_TX_MAC: { + bool is_wild = spec->type == EFX_FILTER_MAC_WILD; + EFX_POPULATE_OWORD_5(*filter, + FRF_CZ_TMFT_TXQ_ID, spec->dmaq_id, + FRF_CZ_TMFT_WILDCARD_MATCH, is_wild, + FRF_CZ_TMFT_SRC_MAC_HI, spec->data[2], + FRF_CZ_TMFT_SRC_MAC_LO, spec->data[1], + FRF_CZ_TMFT_VLAN_ID, spec->data[0]); + data3 = is_wild | spec->dmaq_id << 1; + break; + } + default: BUG(); } @@ -485,6 +523,10 @@ static bool efx_filter_equal(const struct efx_filter_spec *left, memcmp(left->data, right->data, sizeof(left->data))) return false; + if (left->flags & EFX_FILTER_FLAG_TX && + left->dmaq_id != right->dmaq_id) + return false; + return true; } @@ -581,8 +623,11 @@ static inline u8 efx_filter_id_flags(u32 id) if (match_pri < EFX_FILTER_MATCH_PRI_NORMAL_BASE) return EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_RX_OVERRIDE_IP; - else + else if (match_pri <= + EFX_FILTER_MATCH_PRI_NORMAL_BASE + EFX_FILTER_TABLE_RX_DEF) return EFX_FILTER_FLAG_RX; + else + return EFX_FILTER_FLAG_TX; } u32 efx_filter_get_rx_id_limit(struct efx_nic *efx) @@ -660,7 +705,10 @@ s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec, } else { if (table->search_depth[spec->type] < depth) { table->search_depth[spec->type] = depth; - efx_filter_push_rx_config(efx); + if (spec->flags & EFX_FILTER_FLAG_TX) + efx_filter_push_tx_limits(efx); + else + efx_filter_push_rx_config(efx); } efx_writeo(efx, &filter, @@ -918,6 +966,7 @@ void efx_restore_filters(struct efx_nic *efx) } efx_filter_push_rx_config(efx); + efx_filter_push_tx_limits(efx); spin_unlock_bh(&state->lock); } @@ -960,6 +1009,12 @@ int efx_probe_filters(struct efx_nic *efx) table = &state->table[EFX_FILTER_TABLE_RX_DEF]; table->id = EFX_FILTER_TABLE_RX_DEF; table->size = EFX_FILTER_SIZE_RX_DEF; + + table = &state->table[EFX_FILTER_TABLE_TX_MAC]; + table->id = EFX_FILTER_TABLE_TX_MAC; + table->offset = FR_CZ_TX_MAC_FILTER_TBL0; + table->size = FR_CZ_TX_MAC_FILTER_TBL0_ROWS; + table->step = FR_CZ_TX_MAC_FILTER_TBL0_STEP; } for (table_id = 0; table_id < EFX_FILTER_TABLE_COUNT; table_id++) { diff --git a/drivers/net/ethernet/sfc/filter.h b/drivers/net/ethernet/sfc/filter.h index 451997841dc9..3c77802aed6c 100644 --- a/drivers/net/ethernet/sfc/filter.h +++ b/drivers/net/ethernet/sfc/filter.h @@ -43,7 +43,8 @@ enum efx_filter_type { * enum efx_filter_priority - priority of a hardware filter specification * @EFX_FILTER_PRI_HINT: Performance hint * @EFX_FILTER_PRI_MANUAL: Manually configured filter - * @EFX_FILTER_PRI_REQUIRED: Required for correct behaviour + * @EFX_FILTER_PRI_REQUIRED: Required for correct behaviour (user-level + * networking and SR-IOV) */ enum efx_filter_priority { EFX_FILTER_PRI_HINT = 0, @@ -64,12 +65,14 @@ enum efx_filter_priority { * any IP filter that matches the same packet. By default, IP * filters take precedence. * @EFX_FILTER_FLAG_RX: Filter is for RX + * @EFX_FILTER_FLAG_TX: Filter is for TX */ enum efx_filter_flags { EFX_FILTER_FLAG_RX_RSS = 0x01, EFX_FILTER_FLAG_RX_SCATTER = 0x02, EFX_FILTER_FLAG_RX_OVERRIDE_IP = 0x04, EFX_FILTER_FLAG_RX = 0x08, + EFX_FILTER_FLAG_TX = 0x10, }; /** @@ -107,6 +110,15 @@ static inline void efx_filter_init_rx(struct efx_filter_spec *spec, spec->dmaq_id = rxq_id; } +static inline void efx_filter_init_tx(struct efx_filter_spec *spec, + unsigned txq_id) +{ + spec->type = EFX_FILTER_UNSPEC; + spec->priority = EFX_FILTER_PRI_REQUIRED; + spec->flags = EFX_FILTER_FLAG_TX; + spec->dmaq_id = txq_id; +} + extern int efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto, __be32 host, __be16 port); extern int efx_filter_get_ipv4_local(const struct efx_filter_spec *spec, -- GitLab From 055e0ad01418bc4d68106df8c8a2d0338fbf67ba Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 6 Feb 2012 18:00:57 +0000 Subject: [PATCH 0788/1846] sfc: Correct MAC filter bitfield definitions The RMFT_DEST_MAC and TMFT_SRC_MAC register fields were previously documented as 44 bits wide, whereas a MAC address has 48 bits. Thankfully the hardware uses the correct width and the driver has used separate definitions that divide each of these into 32-bit and 16-bit fields. Fix the initial definitions for these fields and rewrite the latter definitions to use them. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/regs.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/sfc/regs.h b/drivers/net/ethernet/sfc/regs.h index cc2c86b76a7b..ade4c4dc56ca 100644 --- a/drivers/net/ethernet/sfc/regs.h +++ b/drivers/net/ethernet/sfc/regs.h @@ -2446,8 +2446,8 @@ #define FRF_CZ_RMFT_RXQ_ID_WIDTH 12 #define FRF_CZ_RMFT_WILDCARD_MATCH_LBN 60 #define FRF_CZ_RMFT_WILDCARD_MATCH_WIDTH 1 -#define FRF_CZ_RMFT_DEST_MAC_LBN 16 -#define FRF_CZ_RMFT_DEST_MAC_WIDTH 44 +#define FRF_CZ_RMFT_DEST_MAC_LBN 12 +#define FRF_CZ_RMFT_DEST_MAC_WIDTH 48 #define FRF_CZ_RMFT_VLAN_ID_LBN 0 #define FRF_CZ_RMFT_VLAN_ID_WIDTH 12 @@ -2523,8 +2523,8 @@ #define FRF_CZ_TMFT_TXQ_ID_WIDTH 12 #define FRF_CZ_TMFT_WILDCARD_MATCH_LBN 60 #define FRF_CZ_TMFT_WILDCARD_MATCH_WIDTH 1 -#define FRF_CZ_TMFT_SRC_MAC_LBN 16 -#define FRF_CZ_TMFT_SRC_MAC_WIDTH 44 +#define FRF_CZ_TMFT_SRC_MAC_LBN 12 +#define FRF_CZ_TMFT_SRC_MAC_WIDTH 48 #define FRF_CZ_TMFT_VLAN_ID_LBN 0 #define FRF_CZ_TMFT_VLAN_ID_WIDTH 12 @@ -2895,17 +2895,17 @@ /* RX_MAC_FILTER_TBL0 */ /* RMFT_DEST_MAC is wider than 32 bits */ -#define FRF_CZ_RMFT_DEST_MAC_LO_LBN 12 +#define FRF_CZ_RMFT_DEST_MAC_LO_LBN FRF_CZ_RMFT_DEST_MAC_LBN #define FRF_CZ_RMFT_DEST_MAC_LO_WIDTH 32 -#define FRF_CZ_RMFT_DEST_MAC_HI_LBN 44 -#define FRF_CZ_RMFT_DEST_MAC_HI_WIDTH 16 +#define FRF_CZ_RMFT_DEST_MAC_HI_LBN (FRF_CZ_RMFT_DEST_MAC_LBN + 32) +#define FRF_CZ_RMFT_DEST_MAC_HI_WIDTH (FRF_CZ_RMFT_DEST_MAC_WIDTH - 32) /* TX_MAC_FILTER_TBL0 */ /* TMFT_SRC_MAC is wider than 32 bits */ -#define FRF_CZ_TMFT_SRC_MAC_LO_LBN 12 +#define FRF_CZ_TMFT_SRC_MAC_LO_LBN FRF_CZ_TMFT_SRC_MAC_LBN #define FRF_CZ_TMFT_SRC_MAC_LO_WIDTH 32 -#define FRF_CZ_TMFT_SRC_MAC_HI_LBN 44 -#define FRF_CZ_TMFT_SRC_MAC_HI_WIDTH 16 +#define FRF_CZ_TMFT_SRC_MAC_HI_LBN (FRF_CZ_TMFT_SRC_MAC_LBN + 32) +#define FRF_CZ_TMFT_SRC_MAC_HI_WIDTH (FRF_CZ_TMFT_SRC_MAC_WIDTH - 32) /* TX_PACE_TBL */ /* Values >20 are documented as reserved, but will result in a queue going -- GitLab From 4ef594eb892b3263fe45d72d5b8161ed4ffa6c0d Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 7 Feb 2012 23:39:18 +0000 Subject: [PATCH 0789/1846] sfc: Generalise driver event generation Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/nic.c | 51 ++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index dd50c4f73a9d..0a46b1c872a7 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -57,13 +57,17 @@ /* Depth of RX flush request fifo */ #define EFX_RX_FLUSH_COUNT 4 -/* Generated event code for efx_generate_test_event() */ -#define EFX_CHANNEL_MAGIC_TEST(_channel) \ - (0x00010100 + (_channel)->channel) +/* Driver generated events */ +#define _EFX_CHANNEL_MAGIC_TEST 0x000101 +#define _EFX_CHANNEL_MAGIC_FILL 0x000102 -/* Generated event code for efx_generate_fill_event() */ -#define EFX_CHANNEL_MAGIC_FILL(_channel) \ - (0x00010200 + (_channel)->channel) +#define _EFX_CHANNEL_MAGIC(_code, _data) ((_code) << 8 | (_data)) +#define _EFX_CHANNEL_MAGIC_CODE(_magic) ((_magic) >> 8) + +#define EFX_CHANNEL_MAGIC_TEST(_channel) \ + _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TEST, (_channel)->channel) +#define EFX_CHANNEL_MAGIC_FILL(_channel) \ + _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_FILL, (_channel)->channel) /************************************************************************** * @@ -693,6 +697,16 @@ static void efx_generate_event(struct efx_channel *channel, efx_qword_t *event) efx_writeo(channel->efx, &drv_ev_reg, FR_AZ_DRV_EV); } +static void efx_magic_event(struct efx_channel *channel, u32 magic) +{ + efx_qword_t event; + + EFX_POPULATE_QWORD_2(event, FSF_AZ_EV_CODE, + FSE_AZ_EV_CODE_DRV_GEN_EV, + FSF_AZ_DRV_GEN_EV_MAGIC, magic); + efx_generate_event(channel, &event); +} + /* Handle a transmit completion event * * The NIC batches TX completion events; the message we receive is of @@ -898,12 +912,13 @@ static void efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event) { struct efx_nic *efx = channel->efx; - unsigned code; + unsigned magic; - code = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC); - if (code == EFX_CHANNEL_MAGIC_TEST(channel)) + magic = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC); + + if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) ; /* ignore */ - else if (code == EFX_CHANNEL_MAGIC_FILL(channel)) + else if (magic == EFX_CHANNEL_MAGIC_FILL(channel)) /* The queue must be empty, so we won't receive any rx * events, so efx_process_channel() won't refill the * queue. Refill it here */ @@ -1132,24 +1147,12 @@ void efx_nic_remove_eventq(struct efx_channel *channel) void efx_nic_generate_test_event(struct efx_channel *channel) { - unsigned int magic = EFX_CHANNEL_MAGIC_TEST(channel); - efx_qword_t test_event; - - EFX_POPULATE_QWORD_2(test_event, FSF_AZ_EV_CODE, - FSE_AZ_EV_CODE_DRV_GEN_EV, - FSF_AZ_DRV_GEN_EV_MAGIC, magic); - efx_generate_event(channel, &test_event); + efx_magic_event(channel, EFX_CHANNEL_MAGIC_TEST(channel)); } void efx_nic_generate_fill_event(struct efx_channel *channel) { - unsigned int magic = EFX_CHANNEL_MAGIC_FILL(channel); - efx_qword_t test_event; - - EFX_POPULATE_QWORD_2(test_event, FSF_AZ_EV_CODE, - FSE_AZ_EV_CODE_DRV_GEN_EV, - FSF_AZ_DRV_GEN_EV_MAGIC, magic); - efx_generate_event(channel, &test_event); + efx_magic_event(channel, EFX_CHANNEL_MAGIC_FILL(channel)); } /************************************************************************** -- GitLab From 2ae75dac301b0f255f79cd84ac70c619e55d7694 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 7 Feb 2012 23:49:52 +0000 Subject: [PATCH 0790/1846] sfc: Generate RX fill events based on RX queues, not channels This makes it harder to accidentally send such events to TX-only channels. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/nic.c | 17 +++++++++++------ drivers/net/ethernet/sfc/nic.h | 2 +- drivers/net/ethernet/sfc/rx.c | 3 +-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 0a46b1c872a7..2b33afd4276d 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -66,8 +66,9 @@ #define EFX_CHANNEL_MAGIC_TEST(_channel) \ _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TEST, (_channel)->channel) -#define EFX_CHANNEL_MAGIC_FILL(_channel) \ - _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_FILL, (_channel)->channel) +#define EFX_CHANNEL_MAGIC_FILL(_rx_queue) \ + _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_FILL, \ + efx_rx_queue_index(_rx_queue)) /************************************************************************** * @@ -912,17 +913,20 @@ static void efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event) { struct efx_nic *efx = channel->efx; + struct efx_rx_queue *rx_queue = + efx_channel_has_rx_queue(channel) ? + efx_channel_get_rx_queue(channel) : NULL; unsigned magic; magic = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC); if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) ; /* ignore */ - else if (magic == EFX_CHANNEL_MAGIC_FILL(channel)) + else if (rx_queue && magic == EFX_CHANNEL_MAGIC_FILL(rx_queue)) /* The queue must be empty, so we won't receive any rx * events, so efx_process_channel() won't refill the * queue. Refill it here */ - efx_fast_push_rx_descriptors(efx_channel_get_rx_queue(channel)); + efx_fast_push_rx_descriptors(rx_queue); else netif_dbg(efx, hw, efx->net_dev, "channel %d received " "generated event "EFX_QWORD_FMT"\n", @@ -1150,9 +1154,10 @@ void efx_nic_generate_test_event(struct efx_channel *channel) efx_magic_event(channel, EFX_CHANNEL_MAGIC_TEST(channel)); } -void efx_nic_generate_fill_event(struct efx_channel *channel) +void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue) { - efx_magic_event(channel, EFX_CHANNEL_MAGIC_FILL(channel)); + efx_magic_event(efx_rx_queue_channel(rx_queue), + EFX_CHANNEL_MAGIC_FILL(rx_queue)); } /************************************************************************** diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 4f9d18ac92fe..aeca4e8bb4c2 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -195,6 +195,7 @@ extern void efx_nic_init_rx(struct efx_rx_queue *rx_queue); extern void efx_nic_fini_rx(struct efx_rx_queue *rx_queue); extern void efx_nic_remove_rx(struct efx_rx_queue *rx_queue); extern void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue); +extern void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue); /* Event data path */ extern int efx_nic_probe_eventq(struct efx_channel *channel); @@ -216,7 +217,6 @@ extern void falcon_update_stats_xmac(struct efx_nic *efx); extern int efx_nic_init_interrupt(struct efx_nic *efx); extern void efx_nic_enable_interrupts(struct efx_nic *efx); extern void efx_nic_generate_test_event(struct efx_channel *channel); -extern void efx_nic_generate_fill_event(struct efx_channel *channel); extern void efx_nic_generate_interrupt(struct efx_nic *efx); extern void efx_nic_disable_interrupts(struct efx_nic *efx); extern void efx_nic_fini_interrupt(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index 1dfda5e27919..76fb521a2fa2 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -405,10 +405,9 @@ void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue) void efx_rx_slow_fill(unsigned long context) { struct efx_rx_queue *rx_queue = (struct efx_rx_queue *)context; - struct efx_channel *channel = efx_rx_queue_channel(rx_queue); /* Post an event to cause NAPI to run and refill the queue */ - efx_nic_generate_fill_event(channel); + efx_nic_generate_fill_event(rx_queue); ++rx_queue->slow_fill_count; } -- GitLab From 9f2cb71c2b0ce33c472856c0feec2883fa0d9cd1 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 8 Feb 2012 00:11:20 +0000 Subject: [PATCH 0791/1846] sfc: Leave interrupts and event queues enabled whenever we can When SR-IOV is enabled we may receive FLR (Function-Level Reset) events, associated queue flush events and requests from VF drivers at any time. Therefore we need to keep event queues and interrupts enabled whenever possible. Currently we stop interrupt-driven event processing before flushing RX and TX queues; efx_nic_flush_queues() then polls event queues for flush events and discards any others it finds. Change it to work with the regular event handling functions. Currently efx_start_channel() fills RX queues synchronously when a device is brought up. This could now race with NAPI, so change it to send fill events. This was almost entirely written by Steve Hodgson, formerly shodgson@solarflare.com. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 237 ++++++++--------- drivers/net/ethernet/sfc/net_driver.h | 36 ++- drivers/net/ethernet/sfc/nic.c | 349 +++++++++++++------------- drivers/net/ethernet/sfc/rx.c | 4 + 4 files changed, 308 insertions(+), 318 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index ce07aa516cd2..ccfb43c9968d 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -186,6 +186,8 @@ MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value"); * *************************************************************************/ +static void efx_start_interrupts(struct efx_nic *efx); +static void efx_stop_interrupts(struct efx_nic *efx); static void efx_remove_channels(struct efx_nic *efx); static void efx_remove_port(struct efx_nic *efx); static void efx_init_napi(struct efx_nic *efx); @@ -217,10 +219,9 @@ static void efx_stop_all(struct efx_nic *efx); */ static int efx_process_channel(struct efx_channel *channel, int budget) { - struct efx_nic *efx = channel->efx; int spent; - if (unlikely(efx->reset_pending || !channel->enabled)) + if (unlikely(!channel->enabled)) return 0; spent = efx_nic_process_eventq(channel, budget); @@ -233,9 +234,10 @@ static int efx_process_channel(struct efx_channel *channel, int budget) __efx_rx_packet(channel, channel->rx_pkt); channel->rx_pkt = NULL; } - - efx_rx_strategy(channel); - efx_fast_push_rx_descriptors(rx_queue); + if (rx_queue->enabled) { + efx_rx_strategy(channel); + efx_fast_push_rx_descriptors(rx_queue); + } } return spent; @@ -387,6 +389,34 @@ static void efx_init_eventq(struct efx_channel *channel) efx_nic_init_eventq(channel); } +/* Enable event queue processing and NAPI */ +static void efx_start_eventq(struct efx_channel *channel) +{ + netif_dbg(channel->efx, ifup, channel->efx->net_dev, + "chan %d start event queue\n", channel->channel); + + /* The interrupt handler for this channel may set work_pending + * as soon as we enable it. Make sure it's cleared before + * then. Similarly, make sure it sees the enabled flag set. + */ + channel->work_pending = false; + channel->enabled = true; + smp_wmb(); + + napi_enable(&channel->napi_str); + efx_nic_eventq_read_ack(channel); +} + +/* Disable event queue processing and NAPI */ +static void efx_stop_eventq(struct efx_channel *channel) +{ + if (!channel->enabled) + return; + + napi_disable(&channel->napi_str); + channel->enabled = false; +} + static void efx_fini_eventq(struct efx_channel *channel) { netif_dbg(channel->efx, drv, channel->efx->net_dev, @@ -556,7 +586,7 @@ static int efx_probe_channels(struct efx_nic *efx) * to propagate configuration changes (mtu, checksum offload), or * to clear hardware error conditions */ -static void efx_init_channels(struct efx_nic *efx) +static void efx_start_datapath(struct efx_nic *efx) { struct efx_tx_queue *tx_queue; struct efx_rx_queue *rx_queue; @@ -575,68 +605,26 @@ static void efx_init_channels(struct efx_nic *efx) /* Initialise the channels */ efx_for_each_channel(channel, efx) { - netif_dbg(channel->efx, drv, channel->efx->net_dev, - "init chan %d\n", channel->channel); - - efx_init_eventq(channel); - efx_for_each_channel_tx_queue(tx_queue, channel) efx_init_tx_queue(tx_queue); /* The rx buffer allocation strategy is MTU dependent */ efx_rx_strategy(channel); - efx_for_each_channel_rx_queue(rx_queue, channel) + efx_for_each_channel_rx_queue(rx_queue, channel) { efx_init_rx_queue(rx_queue); + efx_nic_generate_fill_event(rx_queue); + } WARN_ON(channel->rx_pkt != NULL); efx_rx_strategy(channel); } -} - -/* This enables event queue processing and packet transmission. - * - * Note that this function is not allowed to fail, since that would - * introduce too much complexity into the suspend/resume path. - */ -static void efx_start_channel(struct efx_channel *channel) -{ - struct efx_rx_queue *rx_queue; - - netif_dbg(channel->efx, ifup, channel->efx->net_dev, - "starting chan %d\n", channel->channel); - - /* The interrupt handler for this channel may set work_pending - * as soon as we enable it. Make sure it's cleared before - * then. Similarly, make sure it sees the enabled flag set. */ - channel->work_pending = false; - channel->enabled = true; - smp_wmb(); - - /* Fill the queues before enabling NAPI */ - efx_for_each_channel_rx_queue(rx_queue, channel) - efx_fast_push_rx_descriptors(rx_queue); - - napi_enable(&channel->napi_str); -} -/* This disables event queue processing and packet transmission. - * This function does not guarantee that all queue processing - * (e.g. RX refill) is complete. - */ -static void efx_stop_channel(struct efx_channel *channel) -{ - if (!channel->enabled) - return; - - netif_dbg(channel->efx, ifdown, channel->efx->net_dev, - "stop chan %d\n", channel->channel); - - channel->enabled = false; - napi_disable(&channel->napi_str); + if (netif_device_present(efx->net_dev)) + netif_tx_wake_all_queues(efx->net_dev); } -static void efx_fini_channels(struct efx_nic *efx) +static void efx_stop_datapath(struct efx_nic *efx) { struct efx_channel *channel; struct efx_tx_queue *tx_queue; @@ -663,14 +651,21 @@ static void efx_fini_channels(struct efx_nic *efx) } efx_for_each_channel(channel, efx) { - netif_dbg(channel->efx, drv, channel->efx->net_dev, - "shut down chan %d\n", channel->channel); + /* RX packet processing is pipelined, so wait for the + * NAPI handler to complete. At least event queue 0 + * might be kept active by non-data events, so don't + * use napi_synchronize() but actually disable NAPI + * temporarily. + */ + if (efx_channel_has_rx_queue(channel)) { + efx_stop_eventq(channel); + efx_start_eventq(channel); + } efx_for_each_channel_rx_queue(rx_queue, channel) efx_fini_rx_queue(rx_queue); efx_for_each_possible_channel_tx_queue(tx_queue, channel) efx_fini_tx_queue(tx_queue); - efx_fini_eventq(channel); } } @@ -706,7 +701,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) int rc; efx_stop_all(efx); - efx_fini_channels(efx); + efx_stop_interrupts(efx); /* Clone channels */ memset(other_channel, 0, sizeof(other_channel)); @@ -746,7 +741,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) for (i = 0; i < efx->n_channels; i++) kfree(other_channel[i]); - efx_init_channels(efx); + efx_start_interrupts(efx); efx_start_all(efx); return rc; @@ -1246,6 +1241,44 @@ static int efx_probe_interrupts(struct efx_nic *efx) return 0; } +/* Enable interrupts, then probe and start the event queues */ +static void efx_start_interrupts(struct efx_nic *efx) +{ + struct efx_channel *channel; + + if (efx->legacy_irq) + efx->legacy_irq_enabled = true; + efx_nic_enable_interrupts(efx); + + efx_for_each_channel(channel, efx) { + efx_init_eventq(channel); + efx_start_eventq(channel); + } + + efx_mcdi_mode_event(efx); +} + +static void efx_stop_interrupts(struct efx_nic *efx) +{ + struct efx_channel *channel; + + efx_mcdi_mode_poll(efx); + + efx_nic_disable_interrupts(efx); + if (efx->legacy_irq) { + synchronize_irq(efx->legacy_irq); + efx->legacy_irq_enabled = false; + } + + efx_for_each_channel(channel, efx) { + if (channel->irq) + synchronize_irq(channel->irq); + + efx_stop_eventq(channel); + efx_fini_eventq(channel); + } +} + static void efx_remove_interrupts(struct efx_nic *efx) { struct efx_channel *channel; @@ -1371,15 +1404,13 @@ static int efx_probe_all(struct efx_nic *efx) return rc; } -/* Called after previous invocation(s) of efx_stop_all, restarts the - * port, kernel transmit queue, NAPI processing and hardware interrupts, - * and ensures that the port is scheduled to be reconfigured. - * This function is safe to call multiple times when the NIC is in any - * state. */ +/* Called after previous invocation(s) of efx_stop_all, restarts the port, + * kernel transmit queues and NAPI processing, and ensures that the port is + * scheduled to be reconfigured. This function is safe to call multiple + * times when the NIC is in any state. + */ static void efx_start_all(struct efx_nic *efx) { - struct efx_channel *channel; - EFX_ASSERT_RESET_SERIALISED(efx); /* Check that it is appropriate to restart the interface. All @@ -1391,28 +1422,8 @@ static void efx_start_all(struct efx_nic *efx) if (!netif_running(efx->net_dev)) return; - /* Mark the port as enabled so port reconfigurations can start, then - * restart the transmit interface early so the watchdog timer stops */ efx_start_port(efx); - - if (netif_device_present(efx->net_dev)) - netif_tx_wake_all_queues(efx->net_dev); - - efx_for_each_channel(channel, efx) - efx_start_channel(channel); - - if (efx->legacy_irq) - efx->legacy_irq_enabled = true; - efx_nic_enable_interrupts(efx); - - /* Switch to event based MCDI completions after enabling interrupts. - * If a reset has been scheduled, then we need to stay in polled mode. - * Rather than serialising efx_mcdi_mode_event() [which sleeps] and - * reset_pending [modified from an atomic context], we instead guarantee - * that efx_mcdi_mode_poll() isn't reverted erroneously */ - efx_mcdi_mode_event(efx); - if (efx->reset_pending) - efx_mcdi_mode_poll(efx); + efx_start_datapath(efx); /* Start the hardware monitor if there is one. Otherwise (we're link * event driven), we have to poll the PHY because after an event queue @@ -1448,8 +1459,6 @@ static void efx_flush_all(struct efx_nic *efx) * taking locks. */ static void efx_stop_all(struct efx_nic *efx) { - struct efx_channel *channel; - EFX_ASSERT_RESET_SERIALISED(efx); /* port_enabled can be read safely under the rtnl lock */ @@ -1457,28 +1466,6 @@ static void efx_stop_all(struct efx_nic *efx) return; efx->type->stop_stats(efx); - - /* Switch to MCDI polling on Siena before disabling interrupts */ - efx_mcdi_mode_poll(efx); - - /* Disable interrupts and wait for ISR to complete */ - efx_nic_disable_interrupts(efx); - if (efx->legacy_irq) { - synchronize_irq(efx->legacy_irq); - efx->legacy_irq_enabled = false; - } - efx_for_each_channel(channel, efx) { - if (channel->irq) - synchronize_irq(channel->irq); - } - - /* Stop all NAPI processing and synchronous rx refills */ - efx_for_each_channel(channel, efx) - efx_stop_channel(channel); - - /* Stop all asynchronous port reconfigurations. Since all - * event processing has already been stopped, there is no - * window to loose phy events */ efx_stop_port(efx); /* Flush efx_mac_work(), refill_workqueue, monitor_work */ @@ -1486,9 +1473,9 @@ static void efx_stop_all(struct efx_nic *efx) /* Stop the kernel transmit interface late, so the watchdog * timer isn't ticking over the flush */ - netif_tx_stop_all_queues(efx->net_dev); - netif_tx_lock_bh(efx->net_dev); - netif_tx_unlock_bh(efx->net_dev); + netif_tx_disable(efx->net_dev); + + efx_stop_datapath(efx); } static void efx_remove_all(struct efx_nic *efx) @@ -1731,8 +1718,6 @@ static int efx_net_stop(struct net_device *net_dev) if (efx->state != STATE_DISABLED) { /* Stop the device and flush all the channels */ efx_stop_all(efx); - efx_fini_channels(efx); - efx_init_channels(efx); } return 0; @@ -1803,8 +1788,6 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu) netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu); - efx_fini_channels(efx); - mutex_lock(&efx->mac_lock); /* Reconfigure the MAC before enabling the dma queues so that * the RX buffers don't overflow */ @@ -1812,8 +1795,6 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu) efx->type->reconfigure_mac(efx); mutex_unlock(&efx->mac_lock); - efx_init_channels(efx); - efx_start_all(efx); return 0; } @@ -2030,7 +2011,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method) efx_stop_all(efx); mutex_lock(&efx->mac_lock); - efx_fini_channels(efx); + efx_stop_interrupts(efx); if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) efx->phy_op->fini(efx); efx->type->fini(efx); @@ -2067,7 +2048,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) efx->type->reconfigure_mac(efx); - efx_init_channels(efx); + efx_start_interrupts(efx); efx_restore_filters(efx); mutex_unlock(&efx->mac_lock); @@ -2273,6 +2254,7 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type, efx->phy_op = &efx_dummy_phy_operations; efx->mdio.dev = net_dev; INIT_WORK(&efx->mac_work, efx_mac_work); + init_waitqueue_head(&efx->flush_wq); for (i = 0; i < EFX_MAX_CHANNELS; i++) { efx->channel[i] = efx_alloc_channel(efx, i, NULL); @@ -2330,8 +2312,8 @@ static void efx_pci_remove_main(struct efx_nic *efx) free_irq_cpu_rmap(efx->net_dev->rx_cpu_rmap); efx->net_dev->rx_cpu_rmap = NULL; #endif + efx_stop_interrupts(efx); efx_nic_fini_interrupt(efx); - efx_fini_channels(efx); efx_fini_port(efx); efx->type->fini(efx); efx_fini_napi(efx); @@ -2357,6 +2339,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) /* Allow any queued efx_resets() to complete */ rtnl_unlock(); + efx_stop_interrupts(efx); efx_unregister_netdev(efx); efx_mtd_remove(efx); @@ -2405,16 +2388,14 @@ static int efx_pci_probe_main(struct efx_nic *efx) goto fail4; } - efx_init_channels(efx); - rc = efx_nic_init_interrupt(efx); if (rc) goto fail5; + efx_start_interrupts(efx); return 0; fail5: - efx_fini_channels(efx); efx_fini_port(efx); fail4: efx->type->fini(efx); @@ -2534,7 +2515,7 @@ static int efx_pm_freeze(struct device *dev) netif_device_detach(efx->net_dev); efx_stop_all(efx); - efx_fini_channels(efx); + efx_stop_interrupts(efx); return 0; } @@ -2545,7 +2526,7 @@ static int efx_pm_thaw(struct device *dev) efx->state = STATE_INIT; - efx_init_channels(efx); + efx_start_interrupts(efx); mutex_lock(&efx->mac_lock); efx->phy_op->reconfigure(efx); diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 53864014c2b4..18c4b3c245e2 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -85,13 +85,6 @@ struct efx_special_buffer { int entries; }; -enum efx_flush_state { - FLUSH_NONE, - FLUSH_PENDING, - FLUSH_FAILED, - FLUSH_DONE, -}; - /** * struct efx_tx_buffer - An Efx TX buffer * @skb: The associated socket buffer. @@ -138,7 +131,6 @@ struct efx_tx_buffer { * @txd: The hardware descriptor ring * @ptr_mask: The size of the ring minus 1. * @initialised: Has hardware queue been initialised? - * @flushed: Used when handling queue flushing * @read_count: Current read pointer. * This is the number of buffers that have been removed from both rings. * @old_write_count: The value of @write_count when last checked. @@ -181,7 +173,6 @@ struct efx_tx_queue { struct efx_special_buffer txd; unsigned int ptr_mask; bool initialised; - enum efx_flush_state flushed; /* Members used mainly on the completion path */ unsigned int read_count ____cacheline_aligned_in_smp; @@ -249,6 +240,9 @@ struct efx_rx_page_state { * @buffer: The software buffer ring * @rxd: The hardware descriptor ring * @ptr_mask: The size of the ring minus 1. + * @enabled: Receive queue enabled indicator. + * @flush_pending: Set when a RX flush is pending. Has the same lifetime as + * @rxq_flush_pending. * @added_count: Number of buffers added to the receive queue. * @notified_count: Number of buffers given to NIC (<= @added_count). * @removed_count: Number of buffers removed from the receive queue. @@ -263,13 +257,14 @@ struct efx_rx_page_state { * @alloc_page_count: RX allocation strategy counter. * @alloc_skb_count: RX allocation strategy counter. * @slow_fill: Timer used to defer efx_nic_generate_fill_event(). - * @flushed: Use when handling queue flushing */ struct efx_rx_queue { struct efx_nic *efx; struct efx_rx_buffer *buffer; struct efx_special_buffer rxd; unsigned int ptr_mask; + bool enabled; + bool flush_pending; int added_count; int notified_count; @@ -283,8 +278,6 @@ struct efx_rx_queue { unsigned int alloc_skb_count; struct timer_list slow_fill; unsigned int slow_fill_count; - - enum efx_flush_state flushed; }; /** @@ -681,6 +674,13 @@ struct efx_filter_state; * @loopback_mode: Loopback status * @loopback_modes: Supported loopback mode bitmask * @loopback_selftest: Offline self-test private state + * @drain_pending: Count of RX and TX queues that haven't been flushed and drained. + * @rxq_flush_pending: Count of number of receive queues that need to be flushed. + * Decremented when the efx_flush_rx_queue() is called. + * @rxq_flush_outstanding: Count of number of RX flushes started but not yet + * completed (either success or failure). Not used when MCDI is used to + * flush receive queues. + * @flush_wq: wait queue used by efx_nic_flush_queues() to wait for flush completions. * @monitor_work: Hardware monitor workitem * @biu_lock: BIU (bus interface unit) lock * @last_irq_cpu: Last CPU to handle a possible test interrupt. This @@ -778,6 +778,11 @@ struct efx_nic { struct efx_filter_state *filter_state; + atomic_t drain_pending; + atomic_t rxq_flush_pending; + atomic_t rxq_flush_outstanding; + wait_queue_head_t flush_wq; + /* The following fields may be written more often */ struct delayed_work monitor_work ____cacheline_aligned_in_smp; @@ -956,13 +961,6 @@ static inline bool efx_tx_queue_used(struct efx_tx_queue *tx_queue) _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \ _tx_queue++) -static inline struct efx_rx_queue * -efx_get_rx_queue(struct efx_nic *efx, unsigned index) -{ - EFX_BUG_ON_PARANOID(index >= efx->n_rx_channels); - return &efx->channel[index]->rx_queue; -} - static inline bool efx_channel_has_rx_queue(struct efx_channel *channel) { return channel->channel < channel->efx->n_rx_channels; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 2b33afd4276d..03e4125d6b96 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -49,17 +49,14 @@ #define EFX_INT_ERROR_EXPIRE 3600 #define EFX_MAX_INT_ERRORS 5 -/* We poll for events every FLUSH_INTERVAL ms, and check FLUSH_POLL_COUNT times - */ -#define EFX_FLUSH_INTERVAL 10 -#define EFX_FLUSH_POLL_COUNT 100 - /* Depth of RX flush request fifo */ #define EFX_RX_FLUSH_COUNT 4 /* Driver generated events */ #define _EFX_CHANNEL_MAGIC_TEST 0x000101 #define _EFX_CHANNEL_MAGIC_FILL 0x000102 +#define _EFX_CHANNEL_MAGIC_RX_DRAIN 0x000103 +#define _EFX_CHANNEL_MAGIC_TX_DRAIN 0x000104 #define _EFX_CHANNEL_MAGIC(_code, _data) ((_code) << 8 | (_data)) #define _EFX_CHANNEL_MAGIC_CODE(_magic) ((_magic) >> 8) @@ -69,6 +66,12 @@ #define EFX_CHANNEL_MAGIC_FILL(_rx_queue) \ _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_FILL, \ efx_rx_queue_index(_rx_queue)) +#define EFX_CHANNEL_MAGIC_RX_DRAIN(_rx_queue) \ + _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_RX_DRAIN, \ + efx_rx_queue_index(_rx_queue)) +#define EFX_CHANNEL_MAGIC_TX_DRAIN(_tx_queue) \ + _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TX_DRAIN, \ + (_tx_queue)->queue) /************************************************************************** * @@ -432,8 +435,6 @@ void efx_nic_init_tx(struct efx_tx_queue *tx_queue) struct efx_nic *efx = tx_queue->efx; efx_oword_t reg; - tx_queue->flushed = FLUSH_NONE; - /* Pin TX descriptor ring */ efx_init_special_buffer(efx, &tx_queue->txd); @@ -490,9 +491,6 @@ static void efx_flush_tx_queue(struct efx_tx_queue *tx_queue) struct efx_nic *efx = tx_queue->efx; efx_oword_t tx_flush_descq; - tx_queue->flushed = FLUSH_PENDING; - - /* Post a flush command */ EFX_POPULATE_OWORD_2(tx_flush_descq, FRF_AZ_TX_FLUSH_DESCQ_CMD, 1, FRF_AZ_TX_FLUSH_DESCQ, tx_queue->queue); @@ -504,9 +502,6 @@ void efx_nic_fini_tx(struct efx_tx_queue *tx_queue) struct efx_nic *efx = tx_queue->efx; efx_oword_t tx_desc_ptr; - /* The queue should have been flushed */ - WARN_ON(tx_queue->flushed != FLUSH_DONE); - /* Remove TX descriptor ring from card */ EFX_ZERO_OWORD(tx_desc_ptr); efx_writeo_table(efx, &tx_desc_ptr, efx->type->txd_ptr_tbl_base, @@ -597,8 +592,6 @@ void efx_nic_init_rx(struct efx_rx_queue *rx_queue) efx_rx_queue_index(rx_queue), rx_queue->rxd.index, rx_queue->rxd.index + rx_queue->rxd.entries - 1); - rx_queue->flushed = FLUSH_NONE; - /* Pin RX descriptor ring */ efx_init_special_buffer(efx, &rx_queue->rxd); @@ -627,9 +620,6 @@ static void efx_flush_rx_queue(struct efx_rx_queue *rx_queue) struct efx_nic *efx = rx_queue->efx; efx_oword_t rx_flush_descq; - rx_queue->flushed = FLUSH_PENDING; - - /* Post a flush command */ EFX_POPULATE_OWORD_2(rx_flush_descq, FRF_AZ_RX_FLUSH_DESCQ_CMD, 1, FRF_AZ_RX_FLUSH_DESCQ, @@ -642,9 +632,6 @@ void efx_nic_fini_rx(struct efx_rx_queue *rx_queue) efx_oword_t rx_desc_ptr; struct efx_nic *efx = rx_queue->efx; - /* The queue should already have been flushed */ - WARN_ON(rx_queue->flushed != FLUSH_DONE); - /* Remove RX descriptor ring from card */ EFX_ZERO_OWORD(rx_desc_ptr); efx_writeo_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base, @@ -660,6 +647,89 @@ void efx_nic_remove_rx(struct efx_rx_queue *rx_queue) efx_free_special_buffer(rx_queue->efx, &rx_queue->rxd); } +/************************************************************************** + * + * Flush handling + * + **************************************************************************/ + +/* efx_nic_flush_queues() must be woken up when all flushes are completed, + * or more RX flushes can be kicked off. + */ +static bool efx_flush_wake(struct efx_nic *efx) +{ + /* Ensure that all updates are visible to efx_nic_flush_queues() */ + smp_mb(); + + return (atomic_read(&efx->drain_pending) == 0 || + (atomic_read(&efx->rxq_flush_outstanding) < EFX_RX_FLUSH_COUNT + && atomic_read(&efx->rxq_flush_pending) > 0)); +} + +/* Flush all the transmit queues, and continue flushing receive queues until + * they're all flushed. Wait for the DRAIN events to be recieved so that there + * are no more RX and TX events left on any channel. */ +int efx_nic_flush_queues(struct efx_nic *efx) +{ + unsigned timeout = msecs_to_jiffies(5000); /* 5s for all flushes and drains */ + struct efx_channel *channel; + struct efx_rx_queue *rx_queue; + struct efx_tx_queue *tx_queue; + int rc = 0; + + efx->type->prepare_flush(efx); + + efx_for_each_channel(channel, efx) { + efx_for_each_channel_tx_queue(tx_queue, channel) { + atomic_inc(&efx->drain_pending); + efx_flush_tx_queue(tx_queue); + } + efx_for_each_channel_rx_queue(rx_queue, channel) { + atomic_inc(&efx->drain_pending); + rx_queue->flush_pending = true; + atomic_inc(&efx->rxq_flush_pending); + } + } + + while (timeout && atomic_read(&efx->drain_pending) > 0) { + /* The hardware supports four concurrent rx flushes, each of + * which may need to be retried if there is an outstanding + * descriptor fetch + */ + efx_for_each_channel(channel, efx) { + efx_for_each_channel_rx_queue(rx_queue, channel) { + if (atomic_read(&efx->rxq_flush_outstanding) >= + EFX_RX_FLUSH_COUNT) + break; + + if (rx_queue->flush_pending) { + rx_queue->flush_pending = false; + atomic_dec(&efx->rxq_flush_pending); + atomic_inc(&efx->rxq_flush_outstanding); + efx_flush_rx_queue(rx_queue); + } + } + } + + timeout = wait_event_timeout(efx->flush_wq, efx_flush_wake(efx), + timeout); + } + + if (atomic_read(&efx->drain_pending)) { + netif_err(efx, hw, efx->net_dev, "failed to flush %d queues " + "(rx %d+%d)\n", atomic_read(&efx->drain_pending), + atomic_read(&efx->rxq_flush_outstanding), + atomic_read(&efx->rxq_flush_pending)); + rc = -ETIMEDOUT; + + atomic_set(&efx->drain_pending, 0); + atomic_set(&efx->rxq_flush_pending, 0); + atomic_set(&efx->rxq_flush_outstanding, 0); + } + + return rc; +} + /************************************************************************** * * Event queue processing @@ -722,6 +792,9 @@ efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event) struct efx_nic *efx = channel->efx; int tx_packets = 0; + if (unlikely(ACCESS_ONCE(efx->reset_pending))) + return 0; + if (likely(EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_COMP))) { /* Transmit completion */ tx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_DESC_PTR); @@ -863,6 +936,10 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event) bool rx_ev_pkt_ok; u16 flags; struct efx_rx_queue *rx_queue; + struct efx_nic *efx = channel->efx; + + if (unlikely(ACCESS_ONCE(efx->reset_pending))) + return; /* Basic packet information */ rx_ev_byte_cnt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_BYTE_CNT); @@ -909,6 +986,72 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event) efx_rx_packet(rx_queue, rx_ev_desc_ptr, rx_ev_byte_cnt, flags); } +/* If this flush done event corresponds to a &struct efx_tx_queue, then + * send an %EFX_CHANNEL_MAGIC_TX_DRAIN event to drain the event queue + * of all transmit completions. + */ +static void +efx_handle_tx_flush_done(struct efx_nic *efx, efx_qword_t *event) +{ + struct efx_tx_queue *tx_queue; + int qid; + + qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA); + if (qid < EFX_TXQ_TYPES * efx->n_tx_channels) { + tx_queue = efx_get_tx_queue(efx, qid / EFX_TXQ_TYPES, + qid % EFX_TXQ_TYPES); + + efx_magic_event(tx_queue->channel, + EFX_CHANNEL_MAGIC_TX_DRAIN(tx_queue)); + } +} + +/* If this flush done event corresponds to a &struct efx_rx_queue: If the flush + * was succesful then send an %EFX_CHANNEL_MAGIC_RX_DRAIN, otherwise add + * the RX queue back to the mask of RX queues in need of flushing. + */ +static void +efx_handle_rx_flush_done(struct efx_nic *efx, efx_qword_t *event) +{ + struct efx_channel *channel; + struct efx_rx_queue *rx_queue; + int qid; + bool failed; + + qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_DESCQ_ID); + failed = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL); + if (qid >= efx->n_channels) + return; + channel = efx_get_channel(efx, qid); + if (!efx_channel_has_rx_queue(channel)) + return; + rx_queue = efx_channel_get_rx_queue(channel); + + if (failed) { + netif_info(efx, hw, efx->net_dev, + "RXQ %d flush retry\n", qid); + rx_queue->flush_pending = true; + atomic_inc(&efx->rxq_flush_pending); + } else { + efx_magic_event(efx_rx_queue_channel(rx_queue), + EFX_CHANNEL_MAGIC_RX_DRAIN(rx_queue)); + } + atomic_dec(&efx->rxq_flush_outstanding); + if (efx_flush_wake(efx)) + wake_up(&efx->flush_wq); +} + +static void +efx_handle_drain_event(struct efx_channel *channel) +{ + struct efx_nic *efx = channel->efx; + + WARN_ON(atomic_read(&efx->drain_pending) == 0); + atomic_dec(&efx->drain_pending); + if (efx_flush_wake(efx)) + wake_up(&efx->flush_wq); +} + static void efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event) { @@ -916,21 +1059,28 @@ efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event) struct efx_rx_queue *rx_queue = efx_channel_has_rx_queue(channel) ? efx_channel_get_rx_queue(channel) : NULL; - unsigned magic; + unsigned magic, code; magic = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC); + code = _EFX_CHANNEL_MAGIC_CODE(magic); - if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) - ; /* ignore */ - else if (rx_queue && magic == EFX_CHANNEL_MAGIC_FILL(rx_queue)) + if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) { + /* ignore */ + } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_FILL(rx_queue)) { /* The queue must be empty, so we won't receive any rx * events, so efx_process_channel() won't refill the * queue. Refill it here */ efx_fast_push_rx_descriptors(rx_queue); - else + } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_RX_DRAIN(rx_queue)) { + rx_queue->enabled = false; + efx_handle_drain_event(channel); + } else if (code == _EFX_CHANNEL_MAGIC_TX_DRAIN) { + efx_handle_drain_event(channel); + } else { netif_dbg(efx, hw, efx->net_dev, "channel %d received " "generated event "EFX_QWORD_FMT"\n", channel->channel, EFX_QWORD_VAL(*event)); + } } static void @@ -947,10 +1097,12 @@ efx_handle_driver_event(struct efx_channel *channel, efx_qword_t *event) case FSE_AZ_TX_DESCQ_FLS_DONE_EV: netif_vdbg(efx, hw, efx->net_dev, "channel %d TXQ %d flushed\n", channel->channel, ev_sub_data); + efx_handle_tx_flush_done(efx, event); break; case FSE_AZ_RX_DESCQ_FLS_DONE_EV: netif_vdbg(efx, hw, efx->net_dev, "channel %d RXQ %d flushed\n", channel->channel, ev_sub_data); + efx_handle_rx_flush_done(efx, event); break; case FSE_AZ_EVQ_INIT_DONE_EV: netif_dbg(efx, hw, efx->net_dev, @@ -1160,143 +1312,6 @@ void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue) EFX_CHANNEL_MAGIC_FILL(rx_queue)); } -/************************************************************************** - * - * Flush handling - * - **************************************************************************/ - - -static void efx_poll_flush_events(struct efx_nic *efx) -{ - struct efx_channel *channel = efx_get_channel(efx, 0); - struct efx_tx_queue *tx_queue; - struct efx_rx_queue *rx_queue; - unsigned int read_ptr = channel->eventq_read_ptr; - unsigned int end_ptr = read_ptr + channel->eventq_mask - 1; - - do { - efx_qword_t *event = efx_event(channel, read_ptr); - int ev_code, ev_sub_code, ev_queue; - bool ev_failed; - - if (!efx_event_present(event)) - break; - - ev_code = EFX_QWORD_FIELD(*event, FSF_AZ_EV_CODE); - ev_sub_code = EFX_QWORD_FIELD(*event, - FSF_AZ_DRIVER_EV_SUBCODE); - if (ev_code == FSE_AZ_EV_CODE_DRIVER_EV && - ev_sub_code == FSE_AZ_TX_DESCQ_FLS_DONE_EV) { - ev_queue = EFX_QWORD_FIELD(*event, - FSF_AZ_DRIVER_EV_SUBDATA); - if (ev_queue < EFX_TXQ_TYPES * efx->n_tx_channels) { - tx_queue = efx_get_tx_queue( - efx, ev_queue / EFX_TXQ_TYPES, - ev_queue % EFX_TXQ_TYPES); - tx_queue->flushed = FLUSH_DONE; - } - } else if (ev_code == FSE_AZ_EV_CODE_DRIVER_EV && - ev_sub_code == FSE_AZ_RX_DESCQ_FLS_DONE_EV) { - ev_queue = EFX_QWORD_FIELD( - *event, FSF_AZ_DRIVER_EV_RX_DESCQ_ID); - ev_failed = EFX_QWORD_FIELD( - *event, FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL); - if (ev_queue < efx->n_rx_channels) { - rx_queue = efx_get_rx_queue(efx, ev_queue); - rx_queue->flushed = - ev_failed ? FLUSH_FAILED : FLUSH_DONE; - } - } - - /* We're about to destroy the queue anyway, so - * it's ok to throw away every non-flush event */ - EFX_SET_QWORD(*event); - - ++read_ptr; - } while (read_ptr != end_ptr); - - channel->eventq_read_ptr = read_ptr; -} - -/* Handle tx and rx flushes at the same time, since they run in - * parallel in the hardware and there's no reason for us to - * serialise them */ -int efx_nic_flush_queues(struct efx_nic *efx) -{ - struct efx_channel *channel; - struct efx_rx_queue *rx_queue; - struct efx_tx_queue *tx_queue; - int i, tx_pending, rx_pending; - - /* If necessary prepare the hardware for flushing */ - efx->type->prepare_flush(efx); - - /* Flush all tx queues in parallel */ - efx_for_each_channel(channel, efx) { - efx_for_each_possible_channel_tx_queue(tx_queue, channel) { - if (tx_queue->initialised) - efx_flush_tx_queue(tx_queue); - } - } - - /* The hardware supports four concurrent rx flushes, each of which may - * need to be retried if there is an outstanding descriptor fetch */ - for (i = 0; i < EFX_FLUSH_POLL_COUNT; ++i) { - rx_pending = tx_pending = 0; - efx_for_each_channel(channel, efx) { - efx_for_each_channel_rx_queue(rx_queue, channel) { - if (rx_queue->flushed == FLUSH_PENDING) - ++rx_pending; - } - } - efx_for_each_channel(channel, efx) { - efx_for_each_channel_rx_queue(rx_queue, channel) { - if (rx_pending == EFX_RX_FLUSH_COUNT) - break; - if (rx_queue->flushed == FLUSH_FAILED || - rx_queue->flushed == FLUSH_NONE) { - efx_flush_rx_queue(rx_queue); - ++rx_pending; - } - } - efx_for_each_possible_channel_tx_queue(tx_queue, channel) { - if (tx_queue->initialised && - tx_queue->flushed != FLUSH_DONE) - ++tx_pending; - } - } - - if (rx_pending == 0 && tx_pending == 0) - return 0; - - msleep(EFX_FLUSH_INTERVAL); - efx_poll_flush_events(efx); - } - - /* Mark the queues as all flushed. We're going to return failure - * leading to a reset, or fake up success anyway */ - efx_for_each_channel(channel, efx) { - efx_for_each_possible_channel_tx_queue(tx_queue, channel) { - if (tx_queue->initialised && - tx_queue->flushed != FLUSH_DONE) - netif_err(efx, hw, efx->net_dev, - "tx queue %d flush command timed out\n", - tx_queue->queue); - tx_queue->flushed = FLUSH_DONE; - } - efx_for_each_channel_rx_queue(rx_queue, channel) { - if (rx_queue->flushed != FLUSH_DONE) - netif_err(efx, hw, efx->net_dev, - "rx queue %d flush command timed out\n", - efx_rx_queue_index(rx_queue)); - rx_queue->flushed = FLUSH_DONE; - } - } - - return -ETIMEDOUT; -} - /************************************************************************** * * Hardware interrupts @@ -1320,18 +1335,10 @@ static inline void efx_nic_interrupts(struct efx_nic *efx, void efx_nic_enable_interrupts(struct efx_nic *efx) { - struct efx_channel *channel; - EFX_ZERO_OWORD(*((efx_oword_t *) efx->irq_status.addr)); wmb(); /* Ensure interrupt vector is clear before interrupts enabled */ - /* Enable interrupts */ efx_nic_interrupts(efx, true, false); - - /* Force processing of all the channels to get the EVQ RPTRs up to - date */ - efx_for_each_channel(channel, efx) - efx_schedule_channel(channel); } void efx_nic_disable_interrupts(struct efx_nic *efx) diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index 76fb521a2fa2..506d24669956 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -705,6 +705,7 @@ void efx_init_rx_queue(struct efx_rx_queue *rx_queue) rx_queue->fast_fill_limit = limit; /* Set up RX descriptor ring */ + rx_queue->enabled = true; efx_nic_init_rx(rx_queue); } @@ -716,6 +717,9 @@ void efx_fini_rx_queue(struct efx_rx_queue *rx_queue) netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev, "shutting down RX queue %d\n", efx_rx_queue_index(rx_queue)); + /* A flush failure might have left rx_queue->enabled */ + rx_queue->enabled = false; + del_timer_sync(&rx_queue->slow_fill); efx_nic_fini_rx(rx_queue); -- GitLab From 9d9a6973a890c5b2258e717e4aae716720e60fcb Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 10 Feb 2012 23:01:48 +0000 Subject: [PATCH 0792/1846] sfc: Use proper function to test for RX channel in efx_poll() Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index ccfb43c9968d..eda2272bc4c0 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -279,7 +279,7 @@ static int efx_poll(struct napi_struct *napi, int budget) spent = efx_process_channel(channel, budget); if (spent < budget) { - if (channel->channel < efx->n_rx_channels && + if (efx_channel_has_rx_queue(channel) && efx->irq_rx_adaptive && unlikely(++channel->irq_count == 1000)) { if (unlikely(channel->irq_mod_score < -- GitLab From 90893000e21e2d52a0a9d5aa0c4234c90bcd9470 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 10 Feb 2012 22:23:41 +0000 Subject: [PATCH 0793/1846] sfc: Generalise event generation to cover VF-owned event queues For SR-IOV we will need to send events to event queues that belong to VFs serviced by other drivers. Change the parameters of efx_generate_event() to allow this and declare it extern. While we're at it, remove the existing declaration under the wrong name efx_nic_generate_event(). Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/nic.c | 9 +++++---- drivers/net/ethernet/sfc/nic.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 03e4125d6b96..539b57441e80 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -754,7 +754,8 @@ void efx_nic_eventq_read_ack(struct efx_channel *channel) } /* Use HW to insert a SW defined event */ -static void efx_generate_event(struct efx_channel *channel, efx_qword_t *event) +void efx_generate_event(struct efx_nic *efx, unsigned int evq, + efx_qword_t *event) { efx_oword_t drv_ev_reg; @@ -764,8 +765,8 @@ static void efx_generate_event(struct efx_channel *channel, efx_qword_t *event) drv_ev_reg.u32[1] = event->u32[1]; drv_ev_reg.u32[2] = 0; drv_ev_reg.u32[3] = 0; - EFX_SET_OWORD_FIELD(drv_ev_reg, FRF_AZ_DRV_EV_QID, channel->channel); - efx_writeo(channel->efx, &drv_ev_reg, FR_AZ_DRV_EV); + EFX_SET_OWORD_FIELD(drv_ev_reg, FRF_AZ_DRV_EV_QID, evq); + efx_writeo(efx, &drv_ev_reg, FR_AZ_DRV_EV); } static void efx_magic_event(struct efx_channel *channel, u32 magic) @@ -775,7 +776,7 @@ static void efx_magic_event(struct efx_channel *channel, u32 magic) EFX_POPULATE_QWORD_2(event, FSF_AZ_EV_CODE, FSE_AZ_EV_CODE_DRV_GEN_EV, FSF_AZ_DRV_GEN_EV_MAGIC, magic); - efx_generate_event(channel, &event); + efx_generate_event(channel->efx, channel->channel, &event); } /* Handle a transmit completion event diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index aeca4e8bb4c2..1f53e2c7cfd7 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -283,8 +283,8 @@ extern void efx_nic_get_regs(struct efx_nic *efx, void *buf); #define MAC_DATA_LBN 0 #define MAC_DATA_WIDTH 32 -extern void efx_nic_generate_event(struct efx_channel *channel, - efx_qword_t *event); +extern void efx_generate_event(struct efx_nic *efx, unsigned int evq, + efx_qword_t *event); extern void falcon_poll_xmac(struct efx_nic *efx); -- GitLab From a606f4325dca6950996abbae452d33f2af095f39 Mon Sep 17 00:00:00 2001 From: Steve Hodgson Date: Mon, 23 May 2011 12:18:45 +0100 Subject: [PATCH 0794/1846] sfc: Disable flow control during flushes The TX DMA engine issues upstream read requests when there is room in the TX FIFO for the completion. However, the fetches for the rest of the packet might be delayed by any back pressure. Since a flush must wait for an EOP, the entire flush may be delayed by back pressure. Mitigate this by disabling flow control before the flushes are started. Since PF and VF flushes run in parallel introduce fc_disable, a reference count of the number of flushes outstanding. The same principle could be applied to Falcon, but that would bring with it its own testing. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/mcdi_mac.c | 2 ++ drivers/net/ethernet/sfc/net_driver.h | 4 ++++ drivers/net/ethernet/sfc/nic.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index f67cf921bd1b..98afe1c1165d 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -44,6 +44,8 @@ static int efx_mcdi_set_mac(struct efx_nic *efx) } if (efx->wanted_fc & EFX_FC_AUTO) fcntl = MC_CMD_FCNTL_AUTO; + if (efx->fc_disable) + fcntl = MC_CMD_FCNTL_OFF; MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl); diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 18c4b3c245e2..f52687741508 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -670,6 +670,9 @@ struct efx_filter_state; * @promiscuous: Promiscuous flag. Protected by netif_tx_lock. * @multicast_hash: Multicast hash table * @wanted_fc: Wanted flow control flags + * @fc_disable: When non-zero flow control is disabled. Typically used to + * ensure that network back pressure doesn't delay dma queue flushes. + * Serialised by the rtnl lock. * @mac_work: Work item for changing MAC promiscuity and multicast hash * @loopback_mode: Loopback status * @loopback_modes: Supported loopback mode bitmask @@ -769,6 +772,7 @@ struct efx_nic { bool promiscuous; union efx_multicast_hash multicast_hash; u8 wanted_fc; + unsigned fc_disable; atomic_t rx_reset; enum efx_loopback_mode loopback_mode; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 539b57441e80..1bb41fff3edc 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -677,6 +677,7 @@ int efx_nic_flush_queues(struct efx_nic *efx) struct efx_tx_queue *tx_queue; int rc = 0; + efx->fc_disable++; efx->type->prepare_flush(efx); efx_for_each_channel(channel, efx) { @@ -727,6 +728,8 @@ int efx_nic_flush_queues(struct efx_nic *efx) atomic_set(&efx->rxq_flush_outstanding, 0); } + efx->fc_disable--; + return rc; } -- GitLab From 5bbe2f4f64cc7f6da6390035dcfc42b14bd80484 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 13 Feb 2012 23:14:23 +0000 Subject: [PATCH 0795/1846] sfc: Make buffer table indices and counts consistently unsigned Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/net_driver.h | 4 ++-- drivers/net/ethernet/sfc/nic.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index f52687741508..59c0583182a5 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -81,8 +81,8 @@ struct efx_special_buffer { void *addr; dma_addr_t dma_addr; unsigned int len; - int index; - int entries; + unsigned int index; + unsigned int entries; }; /** diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 1bb41fff3edc..2bdfb6374ce8 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -192,7 +192,7 @@ static void efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer) { efx_qword_t buf_desc; - int index; + unsigned int index; dma_addr_t dma_addr; int i; -- GitLab From a16e5b246c5b1aff3141ca6ae443307f3241a133 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 14 Feb 2012 00:40:12 +0000 Subject: [PATCH 0796/1846] sfc: Make all CPU/IRQ/channel/queue counts unsigned Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 18 ++++++++++-------- drivers/net/ethernet/sfc/net_driver.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index eda2272bc4c0..3a103f8972e7 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1104,10 +1104,10 @@ static void efx_fini_io(struct efx_nic *efx) pci_disable_device(efx->pci_dev); } -static int efx_wanted_parallelism(void) +static unsigned int efx_wanted_parallelism(void) { cpumask_var_t thread_mask; - int count; + unsigned int count; int cpu; if (rss_cpus) @@ -1136,7 +1136,8 @@ static int efx_init_rx_cpu_rmap(struct efx_nic *efx, struct msix_entry *xentries) { #ifdef CONFIG_RFS_ACCEL - int i, rc; + unsigned int i; + int rc; efx->net_dev->rx_cpu_rmap = alloc_irq_cpu_rmap(efx->n_rx_channels); if (!efx->net_dev->rx_cpu_rmap) @@ -1159,13 +1160,14 @@ efx_init_rx_cpu_rmap(struct efx_nic *efx, struct msix_entry *xentries) */ static int efx_probe_interrupts(struct efx_nic *efx) { - int max_channels = - min_t(int, efx->type->phys_addr_channels, EFX_MAX_CHANNELS); - int rc, i; + unsigned int max_channels = + min(efx->type->phys_addr_channels, EFX_MAX_CHANNELS); + unsigned int i; + int rc; if (efx->interrupt_mode == EFX_INT_MODE_MSIX) { struct msix_entry xentries[EFX_MAX_CHANNELS]; - int n_channels; + unsigned int n_channels; n_channels = efx_wanted_parallelism(); if (separate_tx_channels) @@ -1178,7 +1180,7 @@ static int efx_probe_interrupts(struct efx_nic *efx) if (rc > 0) { netif_err(efx, drv, efx->net_dev, "WARNING: Insufficient MSI-X vectors" - " available (%d < %d).\n", rc, n_channels); + " available (%d < %u).\n", rc, n_channels); netif_err(efx, drv, efx->net_dev, "WARNING: Performance may be reduced.\n"); EFX_BUG_ON_PARANOID(rc >= n_channels); diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 59c0583182a5..3260e7137918 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -52,7 +52,7 @@ * **************************************************************************/ -#define EFX_MAX_CHANNELS 32 +#define EFX_MAX_CHANNELS 32U #define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS /* Checksum generation is a per-queue option in hardware, so each -- GitLab From 7f967c011ae9c59fc7e7a017070ef7b22a5a4fbf Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 13 Feb 2012 23:45:02 +0000 Subject: [PATCH 0797/1846] sfc: Add support for 'extra' channel types Abstract some of the channel operations to allow for 'extra' channels that do not have RX or TX queues. - Try to assign a channel to each extra channel type that is enabled for the NIC, but gracefully degrade if we can't allocate sufficient MSI-X vectors - Allow each extra channel type to generate its own channel name - Allow channel types to disable reallocation and reinitialisation of their channels Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 312 +++++++++++++++++--------- drivers/net/ethernet/sfc/efx.h | 1 + drivers/net/ethernet/sfc/net_driver.h | 34 +++ 3 files changed, 239 insertions(+), 108 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 3a103f8972e7..0a9ab49eef95 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -186,11 +186,13 @@ MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value"); * *************************************************************************/ -static void efx_start_interrupts(struct efx_nic *efx); -static void efx_stop_interrupts(struct efx_nic *efx); +static void efx_start_interrupts(struct efx_nic *efx, bool may_keep_eventq); +static void efx_stop_interrupts(struct efx_nic *efx, bool may_keep_eventq); +static void efx_remove_channel(struct efx_channel *channel); static void efx_remove_channels(struct efx_nic *efx); +static const struct efx_channel_type efx_default_channel_type; static void efx_remove_port(struct efx_nic *efx); -static void efx_init_napi(struct efx_nic *efx); +static void efx_init_napi_channel(struct efx_channel *channel); static void efx_fini_napi(struct efx_nic *efx); static void efx_fini_napi_channel(struct efx_channel *channel); static void efx_fini_struct(struct efx_nic *efx); @@ -439,8 +441,7 @@ static void efx_remove_eventq(struct efx_channel *channel) * *************************************************************************/ -/* Allocate and initialise a channel structure, optionally copying - * parameters (but not resources) from an old channel structure. */ +/* Allocate and initialise a channel structure. */ static struct efx_channel * efx_alloc_channel(struct efx_nic *efx, int i, struct efx_channel *old_channel) { @@ -449,45 +450,60 @@ efx_alloc_channel(struct efx_nic *efx, int i, struct efx_channel *old_channel) struct efx_tx_queue *tx_queue; int j; - if (old_channel) { - channel = kmalloc(sizeof(*channel), GFP_KERNEL); - if (!channel) - return NULL; + channel = kzalloc(sizeof(*channel), GFP_KERNEL); + if (!channel) + return NULL; - *channel = *old_channel; + channel->efx = efx; + channel->channel = i; + channel->type = &efx_default_channel_type; - channel->napi_dev = NULL; - memset(&channel->eventq, 0, sizeof(channel->eventq)); + for (j = 0; j < EFX_TXQ_TYPES; j++) { + tx_queue = &channel->tx_queue[j]; + tx_queue->efx = efx; + tx_queue->queue = i * EFX_TXQ_TYPES + j; + tx_queue->channel = channel; + } - rx_queue = &channel->rx_queue; - rx_queue->buffer = NULL; - memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd)); + rx_queue = &channel->rx_queue; + rx_queue->efx = efx; + setup_timer(&rx_queue->slow_fill, efx_rx_slow_fill, + (unsigned long)rx_queue); - for (j = 0; j < EFX_TXQ_TYPES; j++) { - tx_queue = &channel->tx_queue[j]; - if (tx_queue->channel) - tx_queue->channel = channel; - tx_queue->buffer = NULL; - memset(&tx_queue->txd, 0, sizeof(tx_queue->txd)); - } - } else { - channel = kzalloc(sizeof(*channel), GFP_KERNEL); - if (!channel) - return NULL; + return channel; +} + +/* Allocate and initialise a channel structure, copying parameters + * (but not resources) from an old channel structure. + */ +static struct efx_channel * +efx_copy_channel(const struct efx_channel *old_channel) +{ + struct efx_channel *channel; + struct efx_rx_queue *rx_queue; + struct efx_tx_queue *tx_queue; + int j; - channel->efx = efx; - channel->channel = i; + channel = kmalloc(sizeof(*channel), GFP_KERNEL); + if (!channel) + return NULL; + + *channel = *old_channel; + + channel->napi_dev = NULL; + memset(&channel->eventq, 0, sizeof(channel->eventq)); - for (j = 0; j < EFX_TXQ_TYPES; j++) { - tx_queue = &channel->tx_queue[j]; - tx_queue->efx = efx; - tx_queue->queue = i * EFX_TXQ_TYPES + j; + for (j = 0; j < EFX_TXQ_TYPES; j++) { + tx_queue = &channel->tx_queue[j]; + if (tx_queue->channel) tx_queue->channel = channel; - } + tx_queue->buffer = NULL; + memset(&tx_queue->txd, 0, sizeof(tx_queue->txd)); } rx_queue = &channel->rx_queue; - rx_queue->efx = efx; + rx_queue->buffer = NULL; + memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd)); setup_timer(&rx_queue->slow_fill, efx_rx_slow_fill, (unsigned long)rx_queue); @@ -503,57 +519,62 @@ static int efx_probe_channel(struct efx_channel *channel) netif_dbg(channel->efx, probe, channel->efx->net_dev, "creating channel %d\n", channel->channel); + rc = channel->type->pre_probe(channel); + if (rc) + goto fail; + rc = efx_probe_eventq(channel); if (rc) - goto fail1; + goto fail; efx_for_each_channel_tx_queue(tx_queue, channel) { rc = efx_probe_tx_queue(tx_queue); if (rc) - goto fail2; + goto fail; } efx_for_each_channel_rx_queue(rx_queue, channel) { rc = efx_probe_rx_queue(rx_queue); if (rc) - goto fail3; + goto fail; } channel->n_rx_frm_trunc = 0; return 0; - fail3: - efx_for_each_channel_rx_queue(rx_queue, channel) - efx_remove_rx_queue(rx_queue); - fail2: - efx_for_each_channel_tx_queue(tx_queue, channel) - efx_remove_tx_queue(tx_queue); - fail1: +fail: + efx_remove_channel(channel); return rc; } +static void +efx_get_channel_name(struct efx_channel *channel, char *buf, size_t len) +{ + struct efx_nic *efx = channel->efx; + const char *type; + int number; + + number = channel->channel; + if (efx->tx_channel_offset == 0) { + type = ""; + } else if (channel->channel < efx->tx_channel_offset) { + type = "-rx"; + } else { + type = "-tx"; + number -= efx->tx_channel_offset; + } + snprintf(buf, len, "%s%s-%d", efx->name, type, number); +} static void efx_set_channel_names(struct efx_nic *efx) { struct efx_channel *channel; - const char *type = ""; - int number; - efx_for_each_channel(channel, efx) { - number = channel->channel; - if (efx->n_channels > efx->n_rx_channels) { - if (channel->channel < efx->n_rx_channels) { - type = "-rx"; - } else { - type = "-tx"; - number -= efx->n_rx_channels; - } - } - snprintf(efx->channel_name[channel->channel], - sizeof(efx->channel_name[0]), - "%s%s-%d", efx->name, type, number); - } + efx_for_each_channel(channel, efx) + channel->type->get_name(channel, + efx->channel_name[channel->channel], + sizeof(efx->channel_name[0])); } static int efx_probe_channels(struct efx_nic *efx) @@ -697,16 +718,40 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) { struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; u32 old_rxq_entries, old_txq_entries; - unsigned i; - int rc; + unsigned i, next_buffer_table = 0; + int rc = 0; + + /* Not all channels should be reallocated. We must avoid + * reallocating their buffer table entries. + */ + efx_for_each_channel(channel, efx) { + struct efx_rx_queue *rx_queue; + struct efx_tx_queue *tx_queue; + + if (channel->type->copy) + continue; + next_buffer_table = max(next_buffer_table, + channel->eventq.index + + channel->eventq.entries); + efx_for_each_channel_rx_queue(rx_queue, channel) + next_buffer_table = max(next_buffer_table, + rx_queue->rxd.index + + rx_queue->rxd.entries); + efx_for_each_channel_tx_queue(tx_queue, channel) + next_buffer_table = max(next_buffer_table, + tx_queue->txd.index + + tx_queue->txd.entries); + } efx_stop_all(efx); - efx_stop_interrupts(efx); + efx_stop_interrupts(efx, true); - /* Clone channels */ + /* Clone channels (where possible) */ memset(other_channel, 0, sizeof(other_channel)); for (i = 0; i < efx->n_channels; i++) { - channel = efx_alloc_channel(efx, i, efx->channel[i]); + channel = efx->channel[i]; + if (channel->type->copy) + channel = channel->type->copy(channel); if (!channel) { rc = -ENOMEM; goto out; @@ -725,23 +770,31 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) other_channel[i] = channel; } - rc = efx_probe_channels(efx); - if (rc) - goto rollback; - - efx_init_napi(efx); + /* Restart buffer table allocation */ + efx->next_buffer_table = next_buffer_table; - /* Destroy old channels */ for (i = 0; i < efx->n_channels; i++) { - efx_fini_napi_channel(other_channel[i]); - efx_remove_channel(other_channel[i]); + channel = efx->channel[i]; + if (!channel->type->copy) + continue; + rc = efx_probe_channel(channel); + if (rc) + goto rollback; + efx_init_napi_channel(efx->channel[i]); } + out: - /* Free unused channel structures */ - for (i = 0; i < efx->n_channels; i++) - kfree(other_channel[i]); + /* Destroy unused channel structures */ + for (i = 0; i < efx->n_channels; i++) { + channel = other_channel[i]; + if (channel && channel->type->copy) { + efx_fini_napi_channel(channel); + efx_remove_channel(channel); + kfree(channel); + } + } - efx_start_interrupts(efx); + efx_start_interrupts(efx, true); efx_start_all(efx); return rc; @@ -762,6 +815,18 @@ void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue) mod_timer(&rx_queue->slow_fill, jiffies + msecs_to_jiffies(100)); } +static const struct efx_channel_type efx_default_channel_type = { + .pre_probe = efx_channel_dummy_op_int, + .get_name = efx_get_channel_name, + .copy = efx_copy_channel, + .keep_eventq = false, +}; + +int efx_channel_dummy_op_int(struct efx_channel *channel) +{ + return 0; +} + /************************************************************************** * * Port handling @@ -1162,9 +1227,14 @@ static int efx_probe_interrupts(struct efx_nic *efx) { unsigned int max_channels = min(efx->type->phys_addr_channels, EFX_MAX_CHANNELS); - unsigned int i; + unsigned int extra_channels = 0; + unsigned int i, j; int rc; + for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) + if (efx->extra_channel_type[i]) + ++extra_channels; + if (efx->interrupt_mode == EFX_INT_MODE_MSIX) { struct msix_entry xentries[EFX_MAX_CHANNELS]; unsigned int n_channels; @@ -1172,6 +1242,7 @@ static int efx_probe_interrupts(struct efx_nic *efx) n_channels = efx_wanted_parallelism(); if (separate_tx_channels) n_channels *= 2; + n_channels += extra_channels; n_channels = min(n_channels, max_channels); for (i = 0; i < n_channels; i++) @@ -1191,22 +1262,23 @@ static int efx_probe_interrupts(struct efx_nic *efx) if (rc == 0) { efx->n_channels = n_channels; + if (n_channels > extra_channels) + n_channels -= extra_channels; if (separate_tx_channels) { - efx->n_tx_channels = - max(efx->n_channels / 2, 1U); - efx->n_rx_channels = - max(efx->n_channels - - efx->n_tx_channels, 1U); + efx->n_tx_channels = max(n_channels / 2, 1U); + efx->n_rx_channels = max(n_channels - + efx->n_tx_channels, + 1U); } else { - efx->n_tx_channels = efx->n_channels; - efx->n_rx_channels = efx->n_channels; + efx->n_tx_channels = n_channels; + efx->n_rx_channels = n_channels; } rc = efx_init_rx_cpu_rmap(efx, xentries); if (rc) { pci_disable_msix(efx->pci_dev); return rc; } - for (i = 0; i < n_channels; i++) + for (i = 0; i < efx->n_channels; i++) efx_get_channel(efx, i)->irq = xentries[i].vector; } else { @@ -1240,11 +1312,26 @@ static int efx_probe_interrupts(struct efx_nic *efx) efx->legacy_irq = efx->pci_dev->irq; } + /* Assign extra channels if possible */ + j = efx->n_channels; + for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) { + if (!efx->extra_channel_type[i]) + continue; + if (efx->interrupt_mode != EFX_INT_MODE_MSIX || + efx->n_channels <= extra_channels) { + efx->extra_channel_type[i]->handle_no_channel(efx); + } else { + --j; + efx_get_channel(efx, j)->type = + efx->extra_channel_type[i]; + } + } + return 0; } /* Enable interrupts, then probe and start the event queues */ -static void efx_start_interrupts(struct efx_nic *efx) +static void efx_start_interrupts(struct efx_nic *efx, bool may_keep_eventq) { struct efx_channel *channel; @@ -1253,14 +1340,15 @@ static void efx_start_interrupts(struct efx_nic *efx) efx_nic_enable_interrupts(efx); efx_for_each_channel(channel, efx) { - efx_init_eventq(channel); + if (!channel->type->keep_eventq || !may_keep_eventq) + efx_init_eventq(channel); efx_start_eventq(channel); } efx_mcdi_mode_event(efx); } -static void efx_stop_interrupts(struct efx_nic *efx) +static void efx_stop_interrupts(struct efx_nic *efx, bool may_keep_eventq) { struct efx_channel *channel; @@ -1277,7 +1365,8 @@ static void efx_stop_interrupts(struct efx_nic *efx) synchronize_irq(channel->irq); efx_stop_eventq(channel); - efx_fini_eventq(channel); + if (!channel->type->keep_eventq || !may_keep_eventq) + efx_fini_eventq(channel); } } @@ -1383,21 +1472,22 @@ static int efx_probe_all(struct efx_nic *efx) } efx->rxq_entries = efx->txq_entries = EFX_DEFAULT_DMAQ_SIZE; - rc = efx_probe_channels(efx); - if (rc) - goto fail3; rc = efx_probe_filters(efx); if (rc) { netif_err(efx, probe, efx->net_dev, "failed to create filter tables\n"); - goto fail4; + goto fail3; } + rc = efx_probe_channels(efx); + if (rc) + goto fail4; + return 0; fail4: - efx_remove_channels(efx); + efx_remove_filters(efx); fail3: efx_remove_port(efx); fail2: @@ -1482,8 +1572,8 @@ static void efx_stop_all(struct efx_nic *efx) static void efx_remove_all(struct efx_nic *efx) { - efx_remove_filters(efx); efx_remove_channels(efx); + efx_remove_filters(efx); efx_remove_port(efx); efx_remove_nic(efx); } @@ -1627,15 +1717,21 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) * **************************************************************************/ +static void efx_init_napi_channel(struct efx_channel *channel) +{ + struct efx_nic *efx = channel->efx; + + channel->napi_dev = efx->net_dev; + netif_napi_add(channel->napi_dev, &channel->napi_str, + efx_poll, napi_weight); +} + static void efx_init_napi(struct efx_nic *efx) { struct efx_channel *channel; - efx_for_each_channel(channel, efx) { - channel->napi_dev = efx->net_dev; - netif_napi_add(channel->napi_dev, &channel->napi_str, - efx_poll, napi_weight); - } + efx_for_each_channel(channel, efx) + efx_init_napi_channel(channel); } static void efx_fini_napi_channel(struct efx_channel *channel) @@ -2013,7 +2109,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method) efx_stop_all(efx); mutex_lock(&efx->mac_lock); - efx_stop_interrupts(efx); + efx_stop_interrupts(efx, false); if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) efx->phy_op->fini(efx); efx->type->fini(efx); @@ -2050,7 +2146,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) efx->type->reconfigure_mac(efx); - efx_start_interrupts(efx); + efx_start_interrupts(efx, false); efx_restore_filters(efx); mutex_unlock(&efx->mac_lock); @@ -2314,7 +2410,7 @@ static void efx_pci_remove_main(struct efx_nic *efx) free_irq_cpu_rmap(efx->net_dev->rx_cpu_rmap); efx->net_dev->rx_cpu_rmap = NULL; #endif - efx_stop_interrupts(efx); + efx_stop_interrupts(efx, false); efx_nic_fini_interrupt(efx); efx_fini_port(efx); efx->type->fini(efx); @@ -2341,7 +2437,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) /* Allow any queued efx_resets() to complete */ rtnl_unlock(); - efx_stop_interrupts(efx); + efx_stop_interrupts(efx, false); efx_unregister_netdev(efx); efx_mtd_remove(efx); @@ -2393,7 +2489,7 @@ static int efx_pci_probe_main(struct efx_nic *efx) rc = efx_nic_init_interrupt(efx); if (rc) goto fail5; - efx_start_interrupts(efx); + efx_start_interrupts(efx, false); return 0; @@ -2517,7 +2613,7 @@ static int efx_pm_freeze(struct device *dev) netif_device_detach(efx->net_dev); efx_stop_all(efx); - efx_stop_interrupts(efx); + efx_stop_interrupts(efx, false); return 0; } @@ -2528,7 +2624,7 @@ static int efx_pm_thaw(struct device *dev) efx->state = STATE_INIT; - efx_start_interrupts(efx); + efx_start_interrupts(efx, false); mutex_lock(&efx->mac_lock); efx->phy_op->reconfigure(efx); diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h index 7f546e2c39e2..4debfe07fb88 100644 --- a/drivers/net/ethernet/sfc/efx.h +++ b/drivers/net/ethernet/sfc/efx.h @@ -95,6 +95,7 @@ static inline void efx_filter_rfs_expire(struct efx_channel *channel) {} #endif /* Channels */ +extern int efx_channel_dummy_op_int(struct efx_channel *channel); extern void efx_process_channel_now(struct efx_channel *channel); extern int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries); diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 3260e7137918..94b0dcab897f 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -54,6 +54,7 @@ #define EFX_MAX_CHANNELS 32U #define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS +#define EFX_MAX_EXTRA_CHANNELS 0U /* Checksum generation is a per-queue option in hardware, so each * queue visible to the networking core is backed by two hardware TX @@ -311,6 +312,7 @@ enum efx_rx_alloc_method { * * @efx: Associated Efx NIC * @channel: Channel instance number + * @type: Channel type definition * @enabled: Channel enabled indicator * @irq: IRQ number (MSI and MSI-X only) * @irq_moderation: IRQ moderation value (in hardware ticks) @@ -341,6 +343,7 @@ enum efx_rx_alloc_method { struct efx_channel { struct efx_nic *efx; int channel; + const struct efx_channel_type *type; bool enabled; int irq; unsigned int irq_moderation; @@ -379,6 +382,26 @@ struct efx_channel { struct efx_tx_queue tx_queue[EFX_TXQ_TYPES]; }; +/** + * struct efx_channel_type - distinguishes traffic and extra channels + * @handle_no_channel: Handle failure to allocate an extra channel + * @pre_probe: Set up extra state prior to initialisation + * @post_remove: Tear down extra state after finalisation, if allocated. + * May be called on channels that have not been probed. + * @get_name: Generate the channel's name (used for its IRQ handler) + * @copy: Copy the channel state prior to reallocation. May be %NULL if + * reallocation is not supported. + * @keep_eventq: Flag for whether event queue should be kept initialised + * while the device is stopped + */ +struct efx_channel_type { + void (*handle_no_channel)(struct efx_nic *); + int (*pre_probe)(struct efx_channel *); + void (*get_name)(struct efx_channel *, char *buf, size_t len); + struct efx_channel *(*copy)(const struct efx_channel *); + bool keep_eventq; +}; + enum efx_led_mode { EFX_LED_OFF = 0, EFX_LED_ON = 1, @@ -631,6 +654,8 @@ struct efx_filter_state; * @rx_queue: RX DMA queues * @channel: Channels * @channel_name: Names for channels and their IRQs + * @extra_channel_types: Types of extra (non-traffic) channels that + * should be allocated for this NIC * @rxq_entries: Size of receive queues requested by user. * @txq_entries: Size of transmit queues requested by user. * @next_buffer_table: First available buffer table id @@ -723,6 +748,8 @@ struct efx_nic { struct efx_channel *channel[EFX_MAX_CHANNELS]; char channel_name[EFX_MAX_CHANNELS][IFNAMSIZ + 6]; + const struct efx_channel_type * + extra_channel_type[EFX_MAX_EXTRA_CHANNELS]; unsigned rxq_entries; unsigned txq_entries; @@ -921,6 +948,13 @@ efx_get_channel(struct efx_nic *efx, unsigned index) _channel = (_channel->channel + 1 < (_efx)->n_channels) ? \ (_efx)->channel[_channel->channel + 1] : NULL) +/* Iterate over all used channels in reverse */ +#define efx_for_each_channel_rev(_channel, _efx) \ + for (_channel = (_efx)->channel[(_efx)->n_channels - 1]; \ + _channel; \ + _channel = _channel->channel ? \ + (_efx)->channel[_channel->channel - 1] : NULL) + static inline struct efx_tx_queue * efx_get_tx_queue(struct efx_nic *efx, unsigned index, unsigned type) { -- GitLab From a9a52506277275b73955504bf4df745502a28b8b Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 14 Feb 2012 20:15:57 +0000 Subject: [PATCH 0798/1846] sfc: Pass NIC structure into efx_wanted_parallelism() This lets us identify the NIC affected in case of failure, and will be necessary to adjust for SR-IOV constraints. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 0a9ab49eef95..e943ffbe5e2a 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1169,7 +1169,7 @@ static void efx_fini_io(struct efx_nic *efx) pci_disable_device(efx->pci_dev); } -static unsigned int efx_wanted_parallelism(void) +static unsigned int efx_wanted_parallelism(struct efx_nic *efx) { cpumask_var_t thread_mask; unsigned int count; @@ -1179,8 +1179,8 @@ static unsigned int efx_wanted_parallelism(void) return rss_cpus; if (unlikely(!zalloc_cpumask_var(&thread_mask, GFP_KERNEL))) { - printk(KERN_WARNING - "sfc: RSS disabled due to allocation failure\n"); + netif_warn(efx, probe, efx->net_dev, + "RSS disabled due to allocation failure\n"); return 1; } @@ -1239,7 +1239,7 @@ static int efx_probe_interrupts(struct efx_nic *efx) struct msix_entry xentries[EFX_MAX_CHANNELS]; unsigned int n_channels; - n_channels = efx_wanted_parallelism(); + n_channels = efx_wanted_parallelism(efx); if (separate_tx_channels) n_channels *= 2; n_channels += extra_channels; -- GitLab From 28e47c498a931200125e299e9d60d22e27b4ab0d Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 15 Feb 2012 01:58:49 +0000 Subject: [PATCH 0799/1846] sfc: Allocate SRAM between buffer table and descriptor caches at init time Each port has a block of 64-bit SRAM that is divided between buffer table and descriptor cache regions at initialisation time. Currently we use a fixed allocation, but it needs to be changed to support larger numbers of queues. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 2 ++ drivers/net/ethernet/sfc/falcon.c | 12 ++++++++---- drivers/net/ethernet/sfc/net_driver.h | 13 +++++++++---- drivers/net/ethernet/sfc/nic.c | 23 +++++++++++++++++++---- drivers/net/ethernet/sfc/nic.h | 2 ++ drivers/net/ethernet/sfc/siena.c | 12 ++++++++++-- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index e943ffbe5e2a..c9c306aef2d9 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1420,6 +1420,8 @@ static int efx_probe_nic(struct efx_nic *efx) if (rc) goto fail; + efx->type->dimension_resources(efx); + if (efx->n_channels > 1) get_random_bytes(&efx->rx_hash_key, sizeof(efx->rx_hash_key)); for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); i++) diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index 98285115df10..3a1ca2bd1548 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c @@ -1333,6 +1333,12 @@ static int falcon_probe_nvconfig(struct efx_nic *efx) return rc; } +static void falcon_dimension_resources(struct efx_nic *efx) +{ + efx->rx_dc_base = 0x20000; + efx->tx_dc_base = 0x26000; +} + /* Probe all SPI devices on the NIC */ static void falcon_probe_spi_devices(struct efx_nic *efx) { @@ -1749,6 +1755,7 @@ const struct efx_nic_type falcon_a1_nic_type = { .probe = falcon_probe_nic, .remove = falcon_remove_nic, .init = falcon_init_nic, + .dimension_resources = falcon_dimension_resources, .fini = efx_port_dummy_op_void, .monitor = falcon_monitor, .map_reset_reason = falcon_map_reset_reason, @@ -1783,8 +1790,6 @@ const struct efx_nic_type falcon_a1_nic_type = { .max_interrupt_mode = EFX_INT_MODE_MSI, .phys_addr_channels = 4, .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH, - .tx_dc_base = 0x130000, - .rx_dc_base = 0x100000, .offload_features = NETIF_F_IP_CSUM, }; @@ -1792,6 +1797,7 @@ const struct efx_nic_type falcon_b0_nic_type = { .probe = falcon_probe_nic, .remove = falcon_remove_nic, .init = falcon_init_nic, + .dimension_resources = falcon_dimension_resources, .fini = efx_port_dummy_op_void, .monitor = falcon_monitor, .map_reset_reason = falcon_map_reset_reason, @@ -1835,8 +1841,6 @@ const struct efx_nic_type falcon_b0_nic_type = { * interrupt handler only supports 32 * channels */ .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH, - .tx_dc_base = 0x130000, - .rx_dc_base = 0x100000, .offload_features = NETIF_F_IP_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE, }; diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 94b0dcab897f..7870cefcb203 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -658,6 +658,9 @@ struct efx_filter_state; * should be allocated for this NIC * @rxq_entries: Size of receive queues requested by user. * @txq_entries: Size of transmit queues requested by user. + * @tx_dc_base: Base qword address in SRAM of TX queue descriptor caches + * @rx_dc_base: Base qword address in SRAM of RX queue descriptor caches + * @sram_lim_qw: Qword address limit of SRAM * @next_buffer_table: First available buffer table id * @n_channels: Number of channels in use * @n_rx_channels: Number of channels used for RX (= number of RX queues) @@ -753,6 +756,9 @@ struct efx_nic { unsigned rxq_entries; unsigned txq_entries; + unsigned tx_dc_base; + unsigned rx_dc_base; + unsigned sram_lim_qw; unsigned next_buffer_table; unsigned n_channels; unsigned n_rx_channels; @@ -839,6 +845,8 @@ static inline unsigned int efx_port_num(struct efx_nic *efx) * @probe: Probe the controller * @remove: Free resources allocated by probe() * @init: Initialise the controller + * @dimension_resources: Dimension controller resources (buffer table, + * and VIs once the available interrupt resources are clear) * @fini: Shut down the controller * @monitor: Periodic function for polling link state and hardware monitor * @map_reset_reason: Map ethtool reset reason to a reset method @@ -878,8 +886,6 @@ static inline unsigned int efx_port_num(struct efx_nic *efx) * @phys_addr_channels: Number of channels with physically addressed * descriptors * @timer_period_max: Maximum period of interrupt timer (in ticks) - * @tx_dc_base: Base address in SRAM of TX queue descriptor caches - * @rx_dc_base: Base address in SRAM of RX queue descriptor caches * @offload_features: net_device feature flags for protocol offload * features implemented in hardware */ @@ -887,6 +893,7 @@ struct efx_nic_type { int (*probe)(struct efx_nic *efx); void (*remove)(struct efx_nic *efx); int (*init)(struct efx_nic *efx); + void (*dimension_resources)(struct efx_nic *efx); void (*fini)(struct efx_nic *efx); void (*monitor)(struct efx_nic *efx); enum reset_type (*map_reset_reason)(enum reset_type reason); @@ -923,8 +930,6 @@ struct efx_nic_type { unsigned int max_interrupt_mode; unsigned int phys_addr_channels; unsigned int timer_period_max; - unsigned int tx_dc_base; - unsigned int rx_dc_base; netdev_features_t offload_features; }; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 2bdfb6374ce8..747cf9439164 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -1609,6 +1609,23 @@ void efx_nic_fini_interrupt(struct efx_nic *efx) free_irq(efx->legacy_irq, efx); } +void efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw) +{ + unsigned vi_count, buftbl_min; + + /* Account for the buffer table entries backing the datapath channels + * and the descriptor caches for those channels. + */ + buftbl_min = ((efx->n_rx_channels * EFX_MAX_DMAQ_SIZE + + efx->n_tx_channels * EFX_TXQ_TYPES * EFX_MAX_DMAQ_SIZE + + efx->n_channels * EFX_MAX_EVQ_SIZE) + * sizeof(efx_qword_t) / EFX_BUF_SIZE); + vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES); + + efx->tx_dc_base = sram_lim_qw - vi_count * TX_DC_ENTRIES; + efx->rx_dc_base = efx->tx_dc_base - vi_count * RX_DC_ENTRIES; +} + u32 efx_nic_fpga_ver(struct efx_nic *efx) { efx_oword_t altera_build; @@ -1621,11 +1638,9 @@ void efx_nic_init_common(struct efx_nic *efx) efx_oword_t temp; /* Set positions of descriptor caches in SRAM. */ - EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_TX_DC_BASE_ADR, - efx->type->tx_dc_base / 8); + EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_TX_DC_BASE_ADR, efx->tx_dc_base); efx_writeo(efx, &temp, FR_AZ_SRM_TX_DC_CFG); - EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_RX_DC_BASE_ADR, - efx->type->rx_dc_base / 8); + EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_RX_DC_BASE_ADR, efx->rx_dc_base); efx_writeo(efx, &temp, FR_AZ_SRM_RX_DC_CFG); /* Set TX descriptor cache size. */ diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 1f53e2c7cfd7..5df7da8b8ebf 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -230,6 +230,8 @@ extern void falcon_start_nic_stats(struct efx_nic *efx); extern void falcon_stop_nic_stats(struct efx_nic *efx); extern void falcon_setup_xaui(struct efx_nic *efx); extern int falcon_reset_xaui(struct efx_nic *efx); +extern void +efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw); extern void efx_nic_init_common(struct efx_nic *efx); extern void efx_nic_push_rx_indir_table(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index d3c4169e2a0b..657f3fa93bcf 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -225,6 +225,15 @@ static int siena_probe_nvconfig(struct efx_nic *efx) return rc; } +static void siena_dimension_resources(struct efx_nic *efx) +{ + /* Each port has a small block of internal SRAM dedicated to + * the buffer table and descriptor caches. In theory we can + * map both blocks to one port, but we don't. + */ + efx_nic_dimension_resources(efx, FR_CZ_BUF_FULL_TBL_ROWS / 2); +} + static int siena_probe_nic(struct efx_nic *efx) { struct siena_nic_data *nic_data; @@ -619,6 +628,7 @@ const struct efx_nic_type siena_a0_nic_type = { .probe = siena_probe_nic, .remove = siena_remove_nic, .init = siena_init_nic, + .dimension_resources = siena_dimension_resources, .fini = efx_port_dummy_op_void, .monitor = NULL, .map_reset_reason = siena_map_reset_reason, @@ -657,8 +667,6 @@ const struct efx_nic_type siena_a0_nic_type = { * interrupt handler only supports 32 * channels */ .timer_period_max = 1 << FRF_CZ_TC_TIMER_VAL_WIDTH, - .tx_dc_base = 0x88000, - .rx_dc_base = 0x68000, .offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE), }; -- GitLab From cd2d5b529cdb9bd274f3e4bc68d37d4d63b7f383 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 14 Feb 2012 00:48:07 +0000 Subject: [PATCH 0800/1846] sfc: Add SR-IOV back-end support for SFC9000 family On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs), each with an RX queue, a TX queue, an event queue and a mailbox register. These may be assigned to up to 127 SR-IOV virtual functions per port, with up to 64 VIs per VF. We allocate an extra channel (IRQ and event queue only) to receive requests from VF drivers. There is a per-port limit of 4 concurrent RX queue flushes, and queue flushes may be initiated by the MC in response to a Function Level Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all flush requests via the MC. The RSS indirection table is shared with VFs, so the number of RX queues used in the PF is limited to the number of VIs per VF. This is almost entirely the work of Steve Hodgson, formerly shodgson@solarflare.com. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/Kconfig | 8 + drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/efx.c | 70 +- drivers/net/ethernet/sfc/ethtool.c | 3 +- drivers/net/ethernet/sfc/mcdi.c | 34 + drivers/net/ethernet/sfc/mcdi.h | 2 + drivers/net/ethernet/sfc/mcdi_mac.c | 2 +- drivers/net/ethernet/sfc/net_driver.h | 32 +- drivers/net/ethernet/sfc/nic.c | 79 +- drivers/net/ethernet/sfc/nic.h | 89 ++ drivers/net/ethernet/sfc/siena.c | 2 + drivers/net/ethernet/sfc/siena_sriov.c | 1642 ++++++++++++++++++++++++ drivers/net/ethernet/sfc/vfdi.h | 254 ++++ 13 files changed, 2192 insertions(+), 26 deletions(-) create mode 100644 drivers/net/ethernet/sfc/siena_sriov.c create mode 100644 drivers/net/ethernet/sfc/vfdi.h diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig index 8d423544a7e6..fb3cbc27063c 100644 --- a/drivers/net/ethernet/sfc/Kconfig +++ b/drivers/net/ethernet/sfc/Kconfig @@ -26,3 +26,11 @@ config SFC_MCDI_MON ----help--- This exposes the on-board firmware-managed sensors as a hardware monitor device. +config SFC_SRIOV + bool "Solarflare SFC9000-family SR-IOV support" + depends on SFC && PCI_IOV + default y + ---help--- + This enables support for the SFC9000 I/O Virtualization + features, allowing accelerated network performance in + virtualized environments. diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 3fa2e25ccc45..ea1f8db57318 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -4,5 +4,6 @@ sfc-y += efx.o nic.o falcon.o siena.o tx.o rx.o filter.o \ tenxpress.o txc43128_phy.o falcon_boards.o \ mcdi.o mcdi_phy.o mcdi_mon.o sfc-$(CONFIG_SFC_MTD) += mtd.o +sfc-$(CONFIG_SFC_SRIOV) += siena_sriov.o obj-$(CONFIG_SFC) += sfc.o diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index c9c306aef2d9..ac571cf14485 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1175,25 +1175,40 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx) unsigned int count; int cpu; - if (rss_cpus) - return rss_cpus; + if (rss_cpus) { + count = rss_cpus; + } else { + if (unlikely(!zalloc_cpumask_var(&thread_mask, GFP_KERNEL))) { + netif_warn(efx, probe, efx->net_dev, + "RSS disabled due to allocation failure\n"); + return 1; + } - if (unlikely(!zalloc_cpumask_var(&thread_mask, GFP_KERNEL))) { - netif_warn(efx, probe, efx->net_dev, - "RSS disabled due to allocation failure\n"); - return 1; + count = 0; + for_each_online_cpu(cpu) { + if (!cpumask_test_cpu(cpu, thread_mask)) { + ++count; + cpumask_or(thread_mask, thread_mask, + topology_thread_cpumask(cpu)); + } + } + + free_cpumask_var(thread_mask); } - count = 0; - for_each_online_cpu(cpu) { - if (!cpumask_test_cpu(cpu, thread_mask)) { - ++count; - cpumask_or(thread_mask, thread_mask, - topology_thread_cpumask(cpu)); - } + /* If RSS is requested for the PF *and* VFs then we can't write RSS + * table entries that are inaccessible to VFs + */ + if (efx_sriov_wanted(efx) && efx_vf_size(efx) > 1 && + count > efx_vf_size(efx)) { + netif_warn(efx, probe, efx->net_dev, + "Reducing number of RSS channels from %u to %u for " + "VF support. Increase vf-msix-limit to use more " + "channels on the PF.\n", + count, efx_vf_size(efx)); + count = efx_vf_size(efx); } - free_cpumask_var(thread_mask); return count; } @@ -1327,6 +1342,10 @@ static int efx_probe_interrupts(struct efx_nic *efx) } } + /* RSS might be usable on VFs even if it is disabled on the PF */ + efx->rss_spread = (efx->n_rx_channels > 1 ? + efx->n_rx_channels : efx_vf_size(efx)); + return 0; } @@ -1426,7 +1445,7 @@ static int efx_probe_nic(struct efx_nic *efx) get_random_bytes(&efx->rx_hash_key, sizeof(efx->rx_hash_key)); for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); i++) efx->rx_indir_table[i] = - ethtool_rxfh_indir_default(i, efx->n_rx_channels); + ethtool_rxfh_indir_default(i, efx->rss_spread); efx_set_channels(efx); netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels); @@ -1915,6 +1934,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) } memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len); + efx_sriov_mac_address_changed(efx); /* Reconfigure the MAC */ mutex_lock(&efx->mac_lock); @@ -1981,6 +2001,12 @@ static const struct net_device_ops efx_netdev_ops = { .ndo_set_mac_address = efx_set_mac_address, .ndo_set_rx_mode = efx_set_rx_mode, .ndo_set_features = efx_set_features, +#ifdef CONFIG_SFC_SRIOV + .ndo_set_vf_mac = efx_sriov_set_vf_mac, + .ndo_set_vf_vlan = efx_sriov_set_vf_vlan, + .ndo_set_vf_spoofchk = efx_sriov_set_vf_spoofchk, + .ndo_get_vf_config = efx_sriov_get_vf_config, +#endif #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = efx_netpoll, #endif @@ -2150,6 +2176,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) efx_start_interrupts(efx, false); efx_restore_filters(efx); + efx_sriov_reset(efx); mutex_unlock(&efx->mac_lock); @@ -2440,6 +2467,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) rtnl_unlock(); efx_stop_interrupts(efx, false); + efx_sriov_fini(efx); efx_unregister_netdev(efx); efx_mtd_remove(efx); @@ -2581,6 +2609,11 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, if (rc) goto fail4; + rc = efx_sriov_init(efx); + if (rc) + netif_err(efx, probe, efx->net_dev, + "SR-IOV can't be enabled rc %d\n", rc); + netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); /* Try to create MTDs, but allow this to fail */ @@ -2732,6 +2765,10 @@ static int __init efx_init_module(void) if (rc) goto err_notifier; + rc = efx_init_sriov(); + if (rc) + goto err_sriov; + reset_workqueue = create_singlethread_workqueue("sfc_reset"); if (!reset_workqueue) { rc = -ENOMEM; @@ -2747,6 +2784,8 @@ static int __init efx_init_module(void) err_pci: destroy_workqueue(reset_workqueue); err_reset: + efx_fini_sriov(); + err_sriov: unregister_netdevice_notifier(&efx_netdev_notifier); err_notifier: return rc; @@ -2758,6 +2797,7 @@ static void __exit efx_exit_module(void) pci_unregister_driver(&efx_pci_driver); destroy_workqueue(reset_workqueue); + efx_fini_sriov(); unregister_netdevice_notifier(&efx_netdev_notifier); } diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 83191151b650..f22f45f515a8 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -1085,7 +1085,8 @@ static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev) { struct efx_nic *efx = netdev_priv(net_dev); - return (efx_nic_rev(efx) < EFX_REV_FALCON_B0 ? + return ((efx_nic_rev(efx) < EFX_REV_FALCON_B0 || + efx->n_rx_channels == 1) ? 0 : ARRAY_SIZE(efx->rx_indir_table)); } diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index 619f63a66ce7..17b6463e459c 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c @@ -560,6 +560,9 @@ void efx_mcdi_process_event(struct efx_channel *channel, case MCDI_EVENT_CODE_MAC_STATS_DMA: /* MAC stats are gather lazily. We can ignore this. */ break; + case MCDI_EVENT_CODE_FLR: + efx_sriov_flr(efx, MCDI_EVENT_FIELD(*event, FLR_VF)); + break; default: netif_err(efx, hw, efx->net_dev, "Unknown MCDI event 0x%x\n", @@ -1154,6 +1157,37 @@ int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id) return rc; } +int efx_mcdi_flush_rxqs(struct efx_nic *efx) +{ + struct efx_channel *channel; + struct efx_rx_queue *rx_queue; + __le32 *qid; + int rc, count; + + qid = kmalloc(EFX_MAX_CHANNELS * sizeof(*qid), GFP_KERNEL); + if (qid == NULL) + return -ENOMEM; + + count = 0; + efx_for_each_channel(channel, efx) { + efx_for_each_channel_rx_queue(rx_queue, channel) { + if (rx_queue->flush_pending) { + rx_queue->flush_pending = false; + atomic_dec(&efx->rxq_flush_pending); + qid[count++] = cpu_to_le32( + efx_rx_queue_index(rx_queue)); + } + } + } + + rc = efx_mcdi_rpc(efx, MC_CMD_FLUSH_RX_QUEUES, (u8 *)qid, + count * sizeof(*qid), NULL, 0, NULL); + WARN_ON(rc > 0); + + kfree(qid); + + return rc; +} int efx_mcdi_wol_filter_reset(struct efx_nic *efx) { diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index fbaa6efcd744..0bdf3e331832 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -146,6 +146,8 @@ extern int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx, extern int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out); extern int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id); extern int efx_mcdi_wol_filter_reset(struct efx_nic *efx); +extern int efx_mcdi_flush_rxqs(struct efx_nic *efx); +extern int efx_mcdi_set_mac(struct efx_nic *efx); extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, u32 dma_len, int enable, int clear); extern int efx_mcdi_mac_reconfigure(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c index 98afe1c1165d..1003f309cba7 100644 --- a/drivers/net/ethernet/sfc/mcdi_mac.c +++ b/drivers/net/ethernet/sfc/mcdi_mac.c @@ -12,7 +12,7 @@ #include "mcdi.h" #include "mcdi_pcol.h" -static int efx_mcdi_set_mac(struct efx_nic *efx) +int efx_mcdi_set_mac(struct efx_nic *efx) { u32 reject, fcntl; u8 cmdbytes[MC_CMD_SET_MAC_IN_LEN]; diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 7870cefcb203..3fbec458c323 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,8 @@ #define EFX_MAX_CHANNELS 32U #define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS -#define EFX_MAX_EXTRA_CHANNELS 0U +#define EFX_EXTRA_CHANNEL_IOV 0 +#define EFX_MAX_EXTRA_CHANNELS 1U /* Checksum generation is a per-queue option in hardware, so each * queue visible to the networking core is backed by two hardware TX @@ -629,6 +631,8 @@ union efx_multicast_hash { }; struct efx_filter_state; +struct efx_vf; +struct vfdi_status; /** * struct efx_nic - an Efx NIC @@ -712,6 +716,17 @@ struct efx_filter_state; * completed (either success or failure). Not used when MCDI is used to * flush receive queues. * @flush_wq: wait queue used by efx_nic_flush_queues() to wait for flush completions. + * @vf: Array of &struct efx_vf objects. + * @vf_count: Number of VFs intended to be enabled. + * @vf_init_count: Number of VFs that have been fully initialised. + * @vi_scale: log2 number of vnics per VF. + * @vf_buftbl_base: The zeroth buffer table index used to back VF queues. + * @vfdi_status: Common VFDI status page to be dmad to VF address space. + * @local_addr_list: List of local addresses. Protected by %local_lock. + * @local_page_list: List of DMA addressable pages used to broadcast + * %local_addr_list. Protected by %local_lock. + * @local_lock: Mutex protecting %local_addr_list and %local_page_list. + * @peer_work: Work item to broadcast peer addresses to VMs. * @monitor_work: Hardware monitor workitem * @biu_lock: BIU (bus interface unit) lock * @last_irq_cpu: Last CPU to handle a possible test interrupt. This @@ -762,6 +777,7 @@ struct efx_nic { unsigned next_buffer_table; unsigned n_channels; unsigned n_rx_channels; + unsigned rss_spread; unsigned tx_channel_offset; unsigned n_tx_channels; unsigned int rx_buffer_len; @@ -820,6 +836,20 @@ struct efx_nic { atomic_t rxq_flush_outstanding; wait_queue_head_t flush_wq; +#ifdef CONFIG_SFC_SRIOV + struct efx_channel *vfdi_channel; + struct efx_vf *vf; + unsigned vf_count; + unsigned vf_init_count; + unsigned vi_scale; + unsigned vf_buftbl_base; + struct efx_buffer vfdi_status; + struct list_head local_addr_list; + struct list_head local_page_list; + struct mutex local_lock; + struct work_struct peer_work; +#endif + /* The following fields may be written more often */ struct delayed_work monitor_work ____cacheline_aligned_in_smp; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 747cf9439164..2bf4283f05fe 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -264,6 +264,10 @@ static int efx_alloc_special_buffer(struct efx_nic *efx, /* Select new buffer ID */ buffer->index = efx->next_buffer_table; efx->next_buffer_table += buffer->entries; +#ifdef CONFIG_SFC_SRIOV + BUG_ON(efx_sriov_enabled(efx) && + efx->vf_buftbl_base < efx->next_buffer_table); +#endif netif_dbg(efx, probe, efx->net_dev, "allocating special buffers %d-%d at %llx+%x " @@ -693,6 +697,16 @@ int efx_nic_flush_queues(struct efx_nic *efx) } while (timeout && atomic_read(&efx->drain_pending) > 0) { + /* If SRIOV is enabled, then offload receive queue flushing to + * the firmware (though we will still have to poll for + * completion). If that fails, fall back to the old scheme. + */ + if (efx_sriov_enabled(efx)) { + rc = efx_mcdi_flush_rxqs(efx); + if (!rc) + goto wait; + } + /* The hardware supports four concurrent rx flushes, each of * which may need to be retried if there is an outstanding * descriptor fetch @@ -712,6 +726,7 @@ int efx_nic_flush_queues(struct efx_nic *efx) } } + wait: timeout = wait_event_timeout(efx->flush_wq, efx_flush_wake(efx), timeout); } @@ -1102,11 +1117,13 @@ efx_handle_driver_event(struct efx_channel *channel, efx_qword_t *event) netif_vdbg(efx, hw, efx->net_dev, "channel %d TXQ %d flushed\n", channel->channel, ev_sub_data); efx_handle_tx_flush_done(efx, event); + efx_sriov_tx_flush_done(efx, event); break; case FSE_AZ_RX_DESCQ_FLS_DONE_EV: netif_vdbg(efx, hw, efx->net_dev, "channel %d RXQ %d flushed\n", channel->channel, ev_sub_data); efx_handle_rx_flush_done(efx, event); + efx_sriov_rx_flush_done(efx, event); break; case FSE_AZ_EVQ_INIT_DONE_EV: netif_dbg(efx, hw, efx->net_dev, @@ -1138,16 +1155,24 @@ efx_handle_driver_event(struct efx_channel *channel, efx_qword_t *event) RESET_TYPE_DISABLE); break; case FSE_BZ_RX_DSC_ERROR_EV: - netif_err(efx, rx_err, efx->net_dev, - "RX DMA Q %d reports descriptor fetch error." - " RX Q %d is disabled.\n", ev_sub_data, ev_sub_data); - efx_schedule_reset(efx, RESET_TYPE_RX_DESC_FETCH); + if (ev_sub_data < EFX_VI_BASE) { + netif_err(efx, rx_err, efx->net_dev, + "RX DMA Q %d reports descriptor fetch error." + " RX Q %d is disabled.\n", ev_sub_data, + ev_sub_data); + efx_schedule_reset(efx, RESET_TYPE_RX_DESC_FETCH); + } else + efx_sriov_desc_fetch_err(efx, ev_sub_data); break; case FSE_BZ_TX_DSC_ERROR_EV: - netif_err(efx, tx_err, efx->net_dev, - "TX DMA Q %d reports descriptor fetch error." - " TX Q %d is disabled.\n", ev_sub_data, ev_sub_data); - efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH); + if (ev_sub_data < EFX_VI_BASE) { + netif_err(efx, tx_err, efx->net_dev, + "TX DMA Q %d reports descriptor fetch error." + " TX Q %d is disabled.\n", ev_sub_data, + ev_sub_data); + efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH); + } else + efx_sriov_desc_fetch_err(efx, ev_sub_data); break; default: netif_vdbg(efx, hw, efx->net_dev, @@ -1207,6 +1232,9 @@ int efx_nic_process_eventq(struct efx_channel *channel, int budget) case FSE_AZ_EV_CODE_DRIVER_EV: efx_handle_driver_event(channel, &event); break; + case FSE_CZ_EV_CODE_USER_EV: + efx_sriov_event(channel, &event); + break; case FSE_CZ_EV_CODE_MCDI_EV: efx_mcdi_process_event(channel, &event); break; @@ -1609,6 +1637,15 @@ void efx_nic_fini_interrupt(struct efx_nic *efx) free_irq(efx->legacy_irq, efx); } +/* Looks at available SRAM resources and works out how many queues we + * can support, and where things like descriptor caches should live. + * + * SRAM is split up as follows: + * 0 buftbl entries for channels + * efx->vf_buftbl_base buftbl entries for SR-IOV + * efx->rx_dc_base RX descriptor caches + * efx->tx_dc_base TX descriptor caches + */ void efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw) { unsigned vi_count, buftbl_min; @@ -1622,6 +1659,32 @@ void efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw) * sizeof(efx_qword_t) / EFX_BUF_SIZE); vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES); +#ifdef CONFIG_SFC_SRIOV + if (efx_sriov_wanted(efx)) { + unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit; + + efx->vf_buftbl_base = buftbl_min; + + vi_dc_entries = RX_DC_ENTRIES + TX_DC_ENTRIES; + vi_count = max(vi_count, EFX_VI_BASE); + buftbl_free = (sram_lim_qw - buftbl_min - + vi_count * vi_dc_entries); + + entries_per_vf = ((vi_dc_entries + EFX_VF_BUFTBL_PER_VI) * + efx_vf_size(efx)); + vf_limit = min(buftbl_free / entries_per_vf, + (1024U - EFX_VI_BASE) >> efx->vi_scale); + + if (efx->vf_count > vf_limit) { + netif_err(efx, probe, efx->net_dev, + "Reducing VF count from from %d to %d\n", + efx->vf_count, vf_limit); + efx->vf_count = vf_limit; + } + vi_count += efx->vf_count * efx_vf_size(efx); + } +#endif + efx->tx_dc_base = sram_lim_qw - vi_count * TX_DC_ENTRIES; efx->rx_dc_base = efx->tx_dc_base - vi_count * RX_DC_ENTRIES; } diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 5df7da8b8ebf..246c4140453c 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -169,6 +169,95 @@ static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx) } #endif +/* + * On the SFC9000 family each port is associated with 1 PCI physical + * function (PF) handled by sfc and a configurable number of virtual + * functions (VFs) that may be handled by some other driver, often in + * a VM guest. The queue pointer registers are mapped in both PF and + * VF BARs such that an 8K region provides access to a single RX, TX + * and event queue (collectively a Virtual Interface, VI or VNIC). + * + * The PF has access to all 1024 VIs while VFs are mapped to VIs + * according to VI_BASE and VI_SCALE: VF i has access to VIs numbered + * in range [VI_BASE + i << VI_SCALE, VI_BASE + i + 1 << VI_SCALE). + * The number of VIs and the VI_SCALE value are configurable but must + * be established at boot time by firmware. + */ + +/* Maximum VI_SCALE parameter supported by Siena */ +#define EFX_VI_SCALE_MAX 6 +/* Base VI to use for SR-IOV. Must be aligned to (1 << EFX_VI_SCALE_MAX), + * so this is the smallest allowed value. */ +#define EFX_VI_BASE 128U +/* Maximum number of VFs allowed */ +#define EFX_VF_COUNT_MAX 127 +/* Limit EVQs on VFs to be only 8k to reduce buffer table reservation */ +#define EFX_MAX_VF_EVQ_SIZE 8192UL +/* The number of buffer table entries reserved for each VI on a VF */ +#define EFX_VF_BUFTBL_PER_VI \ + ((EFX_MAX_VF_EVQ_SIZE + 2 * EFX_MAX_DMAQ_SIZE) * \ + sizeof(efx_qword_t) / EFX_BUF_SIZE) + +#ifdef CONFIG_SFC_SRIOV + +static inline bool efx_sriov_wanted(struct efx_nic *efx) +{ + return efx->vf_count != 0; +} +static inline bool efx_sriov_enabled(struct efx_nic *efx) +{ + return efx->vf_init_count != 0; +} +static inline unsigned int efx_vf_size(struct efx_nic *efx) +{ + return 1 << efx->vi_scale; +} + +extern int efx_init_sriov(void); +extern void efx_sriov_probe(struct efx_nic *efx); +extern int efx_sriov_init(struct efx_nic *efx); +extern void efx_sriov_mac_address_changed(struct efx_nic *efx); +extern void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event); +extern void efx_sriov_rx_flush_done(struct efx_nic *efx, efx_qword_t *event); +extern void efx_sriov_event(struct efx_channel *channel, efx_qword_t *event); +extern void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq); +extern void efx_sriov_flr(struct efx_nic *efx, unsigned flr); +extern void efx_sriov_reset(struct efx_nic *efx); +extern void efx_sriov_fini(struct efx_nic *efx); +extern void efx_fini_sriov(void); + +#else + +static inline bool efx_sriov_wanted(struct efx_nic *efx) { return false; } +static inline bool efx_sriov_enabled(struct efx_nic *efx) { return false; } +static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; } + +static inline int efx_init_sriov(void) { return 0; } +static inline void efx_sriov_probe(struct efx_nic *efx) {} +static inline int efx_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } +static inline void efx_sriov_mac_address_changed(struct efx_nic *efx) {} +static inline void efx_sriov_tx_flush_done(struct efx_nic *efx, + efx_qword_t *event) {} +static inline void efx_sriov_rx_flush_done(struct efx_nic *efx, + efx_qword_t *event) {} +static inline void efx_sriov_event(struct efx_channel *channel, + efx_qword_t *event) {} +static inline void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq) {} +static inline void efx_sriov_flr(struct efx_nic *efx, unsigned flr) {} +static inline void efx_sriov_reset(struct efx_nic *efx) {} +static inline void efx_sriov_fini(struct efx_nic *efx) {} +static inline void efx_fini_sriov(void) {} + +#endif + +extern int efx_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac); +extern int efx_sriov_set_vf_vlan(struct net_device *dev, int vf, + u16 vlan, u8 qos); +extern int efx_sriov_get_vf_config(struct net_device *dev, int vf, + struct ifla_vf_info *ivf); +extern int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf, + bool spoofchk); + extern const struct efx_nic_type falcon_a1_nic_type; extern const struct efx_nic_type falcon_b0_nic_type; extern const struct efx_nic_type siena_a0_nic_type; diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index 657f3fa93bcf..7bea79017a05 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -313,6 +313,8 @@ static int siena_probe_nic(struct efx_nic *efx) if (rc) goto fail5; + efx_sriov_probe(efx); + return 0; fail5: diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c new file mode 100644 index 000000000000..5c6839ec3a83 --- /dev/null +++ b/drivers/net/ethernet/sfc/siena_sriov.c @@ -0,0 +1,1642 @@ +/**************************************************************************** + * Driver for Solarflare Solarstorm network controllers and boards + * Copyright 2010-2011 Solarflare Communications Inc. + * + * 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, incorporated herein by reference. + */ +#include +#include +#include "net_driver.h" +#include "efx.h" +#include "nic.h" +#include "io.h" +#include "mcdi.h" +#include "filter.h" +#include "mcdi_pcol.h" +#include "regs.h" +#include "vfdi.h" + +/* Number of longs required to track all the VIs in a VF */ +#define VI_MASK_LENGTH BITS_TO_LONGS(1 << EFX_VI_SCALE_MAX) + +/** + * enum efx_vf_tx_filter_mode - TX MAC filtering behaviour + * @VF_TX_FILTER_OFF: Disabled + * @VF_TX_FILTER_AUTO: Enabled if MAC address assigned to VF and only + * 2 TX queues allowed per VF. + * @VF_TX_FILTER_ON: Enabled + */ +enum efx_vf_tx_filter_mode { + VF_TX_FILTER_OFF, + VF_TX_FILTER_AUTO, + VF_TX_FILTER_ON, +}; + +/** + * struct efx_vf - Back-end resource and protocol state for a PCI VF + * @efx: The Efx NIC owning this VF + * @pci_rid: The PCI requester ID for this VF + * @pci_name: The PCI name (formatted address) of this VF + * @index: Index of VF within its port and PF. + * @req: VFDI incoming request work item. Incoming USR_EV events are received + * by the NAPI handler, but must be handled by executing MCDI requests + * inside a work item. + * @req_addr: VFDI incoming request DMA address (in VF's PCI address space). + * @req_type: Expected next incoming (from VF) %VFDI_EV_TYPE member. + * @req_seqno: Expected next incoming (from VF) %VFDI_EV_SEQ member. + * @msg_seqno: Next %VFDI_EV_SEQ member to reply to VF. Protected by + * @status_lock + * @busy: VFDI request queued to be processed or being processed. Receiving + * a VFDI request when @busy is set is an error condition. + * @buf: Incoming VFDI requests are DMA from the VF into this buffer. + * @buftbl_base: Buffer table entries for this VF start at this index. + * @rx_filtering: Receive filtering has been requested by the VF driver. + * @rx_filter_flags: The flags sent in the %VFDI_OP_INSERT_FILTER request. + * @rx_filter_qid: VF relative qid for RX filter requested by VF. + * @rx_filter_id: Receive MAC filter ID. Only one filter per VF is supported. + * @tx_filter_mode: Transmit MAC filtering mode. + * @tx_filter_id: Transmit MAC filter ID. + * @addr: The MAC address and outer vlan tag of the VF. + * @status_addr: VF DMA address of page for &struct vfdi_status updates. + * @status_lock: Mutex protecting @msg_seqno, @status_addr, @addr, + * @peer_page_addrs and @peer_page_count from simultaneous + * updates by the VM and consumption by + * efx_sriov_update_vf_addr() + * @peer_page_addrs: Pointer to an array of guest pages for local addresses. + * @peer_page_count: Number of entries in @peer_page_count. + * @evq0_addrs: Array of guest pages backing evq0. + * @evq0_count: Number of entries in @evq0_addrs. + * @flush_waitq: wait queue used by %VFDI_OP_FINI_ALL_QUEUES handler + * to wait for flush completions. + * @txq_lock: Mutex for TX queue allocation. + * @txq_mask: Mask of initialized transmit queues. + * @txq_count: Number of initialized transmit queues. + * @rxq_mask: Mask of initialized receive queues. + * @rxq_count: Number of initialized receive queues. + * @rxq_retry_mask: Mask or receive queues that need to be flushed again + * due to flush failure. + * @rxq_retry_count: Number of receive queues in @rxq_retry_mask. + * @reset_work: Work item to schedule a VF reset. + */ +struct efx_vf { + struct efx_nic *efx; + unsigned int pci_rid; + char pci_name[13]; /* dddd:bb:dd.f */ + unsigned int index; + struct work_struct req; + u64 req_addr; + int req_type; + unsigned req_seqno; + unsigned msg_seqno; + bool busy; + struct efx_buffer buf; + unsigned buftbl_base; + bool rx_filtering; + enum efx_filter_flags rx_filter_flags; + unsigned rx_filter_qid; + int rx_filter_id; + enum efx_vf_tx_filter_mode tx_filter_mode; + int tx_filter_id; + struct vfdi_endpoint addr; + u64 status_addr; + struct mutex status_lock; + u64 *peer_page_addrs; + unsigned peer_page_count; + u64 evq0_addrs[EFX_MAX_VF_EVQ_SIZE * sizeof(efx_qword_t) / + EFX_BUF_SIZE]; + unsigned evq0_count; + wait_queue_head_t flush_waitq; + struct mutex txq_lock; + unsigned long txq_mask[VI_MASK_LENGTH]; + unsigned txq_count; + unsigned long rxq_mask[VI_MASK_LENGTH]; + unsigned rxq_count; + unsigned long rxq_retry_mask[VI_MASK_LENGTH]; + atomic_t rxq_retry_count; + struct work_struct reset_work; +}; + +struct efx_memcpy_req { + unsigned int from_rid; + void *from_buf; + u64 from_addr; + unsigned int to_rid; + u64 to_addr; + unsigned length; +}; + +/** + * struct efx_local_addr - A MAC address on the vswitch without a VF. + * + * Siena does not have a switch, so VFs can't transmit data to each + * other. Instead the VFs must be made aware of the local addresses + * on the vswitch, so that they can arrange for an alternative + * software datapath to be used. + * + * @link: List head for insertion into efx->local_addr_list. + * @addr: Ethernet address + */ +struct efx_local_addr { + struct list_head link; + u8 addr[ETH_ALEN]; +}; + +/** + * struct efx_endpoint_page - Page of vfdi_endpoint structures + * + * @link: List head for insertion into efx->local_page_list. + * @ptr: Pointer to page. + * @addr: DMA address of page. + */ +struct efx_endpoint_page { + struct list_head link; + void *ptr; + dma_addr_t addr; +}; + +/* Buffer table entries are reserved txq0,rxq0,evq0,txq1,rxq1,evq1 */ +#define EFX_BUFTBL_TXQ_BASE(_vf, _qid) \ + ((_vf)->buftbl_base + EFX_VF_BUFTBL_PER_VI * (_qid)) +#define EFX_BUFTBL_RXQ_BASE(_vf, _qid) \ + (EFX_BUFTBL_TXQ_BASE(_vf, _qid) + \ + (EFX_MAX_DMAQ_SIZE * sizeof(efx_qword_t) / EFX_BUF_SIZE)) +#define EFX_BUFTBL_EVQ_BASE(_vf, _qid) \ + (EFX_BUFTBL_TXQ_BASE(_vf, _qid) + \ + (2 * EFX_MAX_DMAQ_SIZE * sizeof(efx_qword_t) / EFX_BUF_SIZE)) + +#define EFX_FIELD_MASK(_field) \ + ((1 << _field ## _WIDTH) - 1) + +/* VFs can only use this many transmit channels */ +static unsigned int vf_max_tx_channels = 2; +module_param(vf_max_tx_channels, uint, 0444); +MODULE_PARM_DESC(vf_max_tx_channels, + "Limit the number of TX channels VFs can use"); + +static int max_vfs = -1; +module_param(max_vfs, int, 0444); +MODULE_PARM_DESC(max_vfs, + "Reduce the number of VFs initialized by the driver"); + +/* Workqueue used by VFDI communication. We can't use the global + * workqueue because it may be running the VF driver's probe() + * routine, which will be blocked there waiting for a VFDI response. + */ +static struct workqueue_struct *vfdi_workqueue; + +static unsigned abs_index(struct efx_vf *vf, unsigned index) +{ + return EFX_VI_BASE + vf->index * efx_vf_size(vf->efx) + index; +} + +static int efx_sriov_cmd(struct efx_nic *efx, bool enable, + unsigned *vi_scale_out, unsigned *vf_total_out) +{ + u8 inbuf[MC_CMD_SRIOV_IN_LEN]; + u8 outbuf[MC_CMD_SRIOV_OUT_LEN]; + unsigned vi_scale, vf_total; + size_t outlen; + int rc; + + MCDI_SET_DWORD(inbuf, SRIOV_IN_ENABLE, enable ? 1 : 0); + MCDI_SET_DWORD(inbuf, SRIOV_IN_VI_BASE, EFX_VI_BASE); + MCDI_SET_DWORD(inbuf, SRIOV_IN_VF_COUNT, efx->vf_count); + + rc = efx_mcdi_rpc(efx, MC_CMD_SRIOV, inbuf, MC_CMD_SRIOV_IN_LEN, + outbuf, MC_CMD_SRIOV_OUT_LEN, &outlen); + if (rc) + return rc; + if (outlen < MC_CMD_SRIOV_OUT_LEN) + return -EIO; + + vf_total = MCDI_DWORD(outbuf, SRIOV_OUT_VF_TOTAL); + vi_scale = MCDI_DWORD(outbuf, SRIOV_OUT_VI_SCALE); + if (vi_scale > EFX_VI_SCALE_MAX) + return -EOPNOTSUPP; + + if (vi_scale_out) + *vi_scale_out = vi_scale; + if (vf_total_out) + *vf_total_out = vf_total; + + return 0; +} + +static void efx_sriov_usrev(struct efx_nic *efx, bool enabled) +{ + efx_oword_t reg; + + EFX_POPULATE_OWORD_2(reg, + FRF_CZ_USREV_DIS, enabled ? 0 : 1, + FRF_CZ_DFLT_EVQ, efx->vfdi_channel->channel); + efx_writeo(efx, ®, FR_CZ_USR_EV_CFG); +} + +static int efx_sriov_memcpy(struct efx_nic *efx, struct efx_memcpy_req *req, + unsigned int count) +{ + u8 *inbuf, *record; + unsigned int used; + u32 from_rid, from_hi, from_lo; + int rc; + + mb(); /* Finish writing source/reading dest before DMA starts */ + + used = MC_CMD_MEMCPY_IN_LEN(count); + if (WARN_ON(used > MCDI_CTL_SDU_LEN_MAX)) + return -ENOBUFS; + + /* Allocate room for the largest request */ + inbuf = kzalloc(MCDI_CTL_SDU_LEN_MAX, GFP_KERNEL); + if (inbuf == NULL) + return -ENOMEM; + + record = inbuf; + MCDI_SET_DWORD(record, MEMCPY_IN_RECORD, count); + while (count-- > 0) { + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_TO_RID, + req->to_rid); + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_TO_ADDR_LO, + (u32)req->to_addr); + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_TO_ADDR_HI, + (u32)(req->to_addr >> 32)); + if (req->from_buf == NULL) { + from_rid = req->from_rid; + from_lo = (u32)req->from_addr; + from_hi = (u32)(req->from_addr >> 32); + } else { + if (WARN_ON(used + req->length > MCDI_CTL_SDU_LEN_MAX)) { + rc = -ENOBUFS; + goto out; + } + + from_rid = MC_CMD_MEMCPY_RECORD_TYPEDEF_RID_INLINE; + from_lo = used; + from_hi = 0; + memcpy(inbuf + used, req->from_buf, req->length); + used += req->length; + } + + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_RID, from_rid); + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LO, + from_lo); + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_ADDR_HI, + from_hi); + MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_LENGTH, + req->length); + + ++req; + record += MC_CMD_MEMCPY_IN_RECORD_LEN; + } + + rc = efx_mcdi_rpc(efx, MC_CMD_MEMCPY, inbuf, used, NULL, 0, NULL); +out: + kfree(inbuf); + + mb(); /* Don't write source/read dest before DMA is complete */ + + return rc; +} + +/* The TX filter is entirely controlled by this driver, and is modified + * underneath the feet of the VF + */ +static void efx_sriov_reset_tx_filter(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct efx_filter_spec filter; + u16 vlan; + int rc; + + if (vf->tx_filter_id != -1) { + efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, + vf->tx_filter_id); + netif_dbg(efx, hw, efx->net_dev, "Removed vf %s tx filter %d\n", + vf->pci_name, vf->tx_filter_id); + vf->tx_filter_id = -1; + } + + if (is_zero_ether_addr(vf->addr.mac_addr)) + return; + + /* Turn on TX filtering automatically if not explicitly + * enabled or disabled. + */ + if (vf->tx_filter_mode == VF_TX_FILTER_AUTO && vf_max_tx_channels <= 2) + vf->tx_filter_mode = VF_TX_FILTER_ON; + + vlan = ntohs(vf->addr.tci) & VLAN_VID_MASK; + efx_filter_init_tx(&filter, abs_index(vf, 0)); + rc = efx_filter_set_eth_local(&filter, + vlan ? vlan : EFX_FILTER_VID_UNSPEC, + vf->addr.mac_addr); + BUG_ON(rc); + + rc = efx_filter_insert_filter(efx, &filter, true); + if (rc < 0) { + netif_warn(efx, hw, efx->net_dev, + "Unable to migrate tx filter for vf %s\n", + vf->pci_name); + } else { + netif_dbg(efx, hw, efx->net_dev, "Inserted vf %s tx filter %d\n", + vf->pci_name, rc); + vf->tx_filter_id = rc; + } +} + +/* The RX filter is managed here on behalf of the VF driver */ +static void efx_sriov_reset_rx_filter(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct efx_filter_spec filter; + u16 vlan; + int rc; + + if (vf->rx_filter_id != -1) { + efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, + vf->rx_filter_id); + netif_dbg(efx, hw, efx->net_dev, "Removed vf %s rx filter %d\n", + vf->pci_name, vf->rx_filter_id); + vf->rx_filter_id = -1; + } + + if (!vf->rx_filtering || is_zero_ether_addr(vf->addr.mac_addr)) + return; + + vlan = ntohs(vf->addr.tci) & VLAN_VID_MASK; + efx_filter_init_rx(&filter, EFX_FILTER_PRI_REQUIRED, + vf->rx_filter_flags, + abs_index(vf, vf->rx_filter_qid)); + rc = efx_filter_set_eth_local(&filter, + vlan ? vlan : EFX_FILTER_VID_UNSPEC, + vf->addr.mac_addr); + BUG_ON(rc); + + rc = efx_filter_insert_filter(efx, &filter, true); + if (rc < 0) { + netif_warn(efx, hw, efx->net_dev, + "Unable to insert rx filter for vf %s\n", + vf->pci_name); + } else { + netif_dbg(efx, hw, efx->net_dev, "Inserted vf %s rx filter %d\n", + vf->pci_name, rc); + vf->rx_filter_id = rc; + } +} + +static void __efx_sriov_update_vf_addr(struct efx_vf *vf) +{ + efx_sriov_reset_tx_filter(vf); + efx_sriov_reset_rx_filter(vf); + queue_work(vfdi_workqueue, &vf->efx->peer_work); +} + +/* Push the peer list to this VF. The caller must hold status_lock to interlock + * with VFDI requests, and they must be serialised against manipulation of + * local_page_list, either by acquiring local_lock or by running from + * efx_sriov_peer_work() + */ +static void __efx_sriov_push_vf_status(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct vfdi_status *status = efx->vfdi_status.addr; + struct efx_memcpy_req copy[4]; + struct efx_endpoint_page *epp; + unsigned int pos, count; + unsigned data_offset; + efx_qword_t event; + + WARN_ON(!mutex_is_locked(&vf->status_lock)); + WARN_ON(!vf->status_addr); + + status->local = vf->addr; + status->generation_end = ++status->generation_start; + + memset(copy, '\0', sizeof(copy)); + /* Write generation_start */ + copy[0].from_buf = &status->generation_start; + copy[0].to_rid = vf->pci_rid; + copy[0].to_addr = vf->status_addr + offsetof(struct vfdi_status, + generation_start); + copy[0].length = sizeof(status->generation_start); + /* DMA the rest of the structure (excluding the generations). This + * assumes that the non-generation portion of vfdi_status is in + * one chunk starting at the version member. + */ + data_offset = offsetof(struct vfdi_status, version); + copy[1].from_rid = efx->pci_dev->devfn; + copy[1].from_addr = efx->vfdi_status.dma_addr + data_offset; + copy[1].to_rid = vf->pci_rid; + copy[1].to_addr = vf->status_addr + data_offset; + copy[1].length = status->length - data_offset; + + /* Copy the peer pages */ + pos = 2; + count = 0; + list_for_each_entry(epp, &efx->local_page_list, link) { + if (count == vf->peer_page_count) { + /* The VF driver will know they need to provide more + * pages because peer_addr_count is too large. + */ + break; + } + copy[pos].from_buf = NULL; + copy[pos].from_rid = efx->pci_dev->devfn; + copy[pos].from_addr = epp->addr; + copy[pos].to_rid = vf->pci_rid; + copy[pos].to_addr = vf->peer_page_addrs[count]; + copy[pos].length = EFX_PAGE_SIZE; + + if (++pos == ARRAY_SIZE(copy)) { + efx_sriov_memcpy(efx, copy, ARRAY_SIZE(copy)); + pos = 0; + } + ++count; + } + + /* Write generation_end */ + copy[pos].from_buf = &status->generation_end; + copy[pos].to_rid = vf->pci_rid; + copy[pos].to_addr = vf->status_addr + offsetof(struct vfdi_status, + generation_end); + copy[pos].length = sizeof(status->generation_end); + efx_sriov_memcpy(efx, copy, pos + 1); + + /* Notify the guest */ + EFX_POPULATE_QWORD_3(event, + FSF_AZ_EV_CODE, FSE_CZ_EV_CODE_USER_EV, + VFDI_EV_SEQ, (vf->msg_seqno & 0xff), + VFDI_EV_TYPE, VFDI_EV_TYPE_STATUS); + ++vf->msg_seqno; + efx_generate_event(efx, EFX_VI_BASE + vf->index * efx_vf_size(efx), + &event); +} + +static void efx_sriov_bufs(struct efx_nic *efx, unsigned offset, + u64 *addr, unsigned count) +{ + efx_qword_t buf; + unsigned pos; + + for (pos = 0; pos < count; ++pos) { + EFX_POPULATE_QWORD_3(buf, + FRF_AZ_BUF_ADR_REGION, 0, + FRF_AZ_BUF_ADR_FBUF, + addr ? addr[pos] >> 12 : 0, + FRF_AZ_BUF_OWNER_ID_FBUF, 0); + efx_sram_writeq(efx, efx->membase + FR_BZ_BUF_FULL_TBL, + &buf, offset + pos); + } +} + +static bool bad_vf_index(struct efx_nic *efx, unsigned index) +{ + return index >= efx_vf_size(efx); +} + +static bool bad_buf_count(unsigned buf_count, unsigned max_entry_count) +{ + unsigned max_buf_count = max_entry_count * + sizeof(efx_qword_t) / EFX_BUF_SIZE; + + return ((buf_count & (buf_count - 1)) || buf_count > max_buf_count); +} + +/* Check that VI specified by per-port index belongs to a VF. + * Optionally set VF index and VI index within the VF. + */ +static bool map_vi_index(struct efx_nic *efx, unsigned abs_index, + struct efx_vf **vf_out, unsigned *rel_index_out) +{ + unsigned vf_i; + + if (abs_index < EFX_VI_BASE) + return true; + vf_i = (abs_index - EFX_VI_BASE) * efx_vf_size(efx); + if (vf_i >= efx->vf_init_count) + return true; + + if (vf_out) + *vf_out = efx->vf + vf_i; + if (rel_index_out) + *rel_index_out = abs_index % efx_vf_size(efx); + return false; +} + +static int efx_vfdi_init_evq(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct vfdi_req *req = vf->buf.addr; + unsigned vf_evq = req->u.init_evq.index; + unsigned buf_count = req->u.init_evq.buf_count; + unsigned abs_evq = abs_index(vf, vf_evq); + unsigned buftbl = EFX_BUFTBL_EVQ_BASE(vf, vf_evq); + efx_oword_t reg; + + if (bad_vf_index(efx, vf_evq) || + bad_buf_count(buf_count, EFX_MAX_VF_EVQ_SIZE)) { + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Invalid INIT_EVQ from %s: evq %d bufs %d\n", + vf->pci_name, vf_evq, buf_count); + return VFDI_RC_EINVAL; + } + + efx_sriov_bufs(efx, buftbl, req->u.init_evq.addr, buf_count); + + EFX_POPULATE_OWORD_3(reg, + FRF_CZ_TIMER_Q_EN, 1, + FRF_CZ_HOST_NOTIFY_MODE, 0, + FRF_CZ_TIMER_MODE, FFE_CZ_TIMER_MODE_DIS); + efx_writeo_table(efx, ®, FR_BZ_TIMER_TBL, abs_evq); + EFX_POPULATE_OWORD_3(reg, + FRF_AZ_EVQ_EN, 1, + FRF_AZ_EVQ_SIZE, __ffs(buf_count), + FRF_AZ_EVQ_BUF_BASE_ID, buftbl); + efx_writeo_table(efx, ®, FR_BZ_EVQ_PTR_TBL, abs_evq); + + if (vf_evq == 0) { + memcpy(vf->evq0_addrs, req->u.init_evq.addr, + buf_count * sizeof(u64)); + vf->evq0_count = buf_count; + } + + return VFDI_RC_SUCCESS; +} + +static int efx_vfdi_init_rxq(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct vfdi_req *req = vf->buf.addr; + unsigned vf_rxq = req->u.init_rxq.index; + unsigned vf_evq = req->u.init_rxq.evq; + unsigned buf_count = req->u.init_rxq.buf_count; + unsigned buftbl = EFX_BUFTBL_RXQ_BASE(vf, vf_rxq); + unsigned label; + efx_oword_t reg; + + if (bad_vf_index(efx, vf_evq) || bad_vf_index(efx, vf_rxq) || + bad_buf_count(buf_count, EFX_MAX_DMAQ_SIZE)) { + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Invalid INIT_RXQ from %s: rxq %d evq %d " + "buf_count %d\n", vf->pci_name, vf_rxq, + vf_evq, buf_count); + return VFDI_RC_EINVAL; + } + if (__test_and_set_bit(req->u.init_rxq.index, vf->rxq_mask)) + ++vf->rxq_count; + efx_sriov_bufs(efx, buftbl, req->u.init_rxq.addr, buf_count); + + label = req->u.init_rxq.label & EFX_FIELD_MASK(FRF_AZ_RX_DESCQ_LABEL); + EFX_POPULATE_OWORD_6(reg, + FRF_AZ_RX_DESCQ_BUF_BASE_ID, buftbl, + FRF_AZ_RX_DESCQ_EVQ_ID, abs_index(vf, vf_evq), + FRF_AZ_RX_DESCQ_LABEL, label, + FRF_AZ_RX_DESCQ_SIZE, __ffs(buf_count), + FRF_AZ_RX_DESCQ_JUMBO, + !!(req->u.init_rxq.flags & + VFDI_RXQ_FLAG_SCATTER_EN), + FRF_AZ_RX_DESCQ_EN, 1); + efx_writeo_table(efx, ®, FR_BZ_RX_DESC_PTR_TBL, + abs_index(vf, vf_rxq)); + + return VFDI_RC_SUCCESS; +} + +static int efx_vfdi_init_txq(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct vfdi_req *req = vf->buf.addr; + unsigned vf_txq = req->u.init_txq.index; + unsigned vf_evq = req->u.init_txq.evq; + unsigned buf_count = req->u.init_txq.buf_count; + unsigned buftbl = EFX_BUFTBL_TXQ_BASE(vf, vf_txq); + unsigned label, eth_filt_en; + efx_oword_t reg; + + if (bad_vf_index(efx, vf_evq) || bad_vf_index(efx, vf_txq) || + vf_txq >= vf_max_tx_channels || + bad_buf_count(buf_count, EFX_MAX_DMAQ_SIZE)) { + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Invalid INIT_TXQ from %s: txq %d evq %d " + "buf_count %d\n", vf->pci_name, vf_txq, + vf_evq, buf_count); + return VFDI_RC_EINVAL; + } + + mutex_lock(&vf->txq_lock); + if (__test_and_set_bit(req->u.init_txq.index, vf->txq_mask)) + ++vf->txq_count; + mutex_unlock(&vf->txq_lock); + efx_sriov_bufs(efx, buftbl, req->u.init_txq.addr, buf_count); + + eth_filt_en = vf->tx_filter_mode == VF_TX_FILTER_ON; + + label = req->u.init_txq.label & EFX_FIELD_MASK(FRF_AZ_TX_DESCQ_LABEL); + EFX_POPULATE_OWORD_8(reg, + FRF_CZ_TX_DPT_Q_MASK_WIDTH, min(efx->vi_scale, 1U), + FRF_CZ_TX_DPT_ETH_FILT_EN, eth_filt_en, + FRF_AZ_TX_DESCQ_EN, 1, + FRF_AZ_TX_DESCQ_BUF_BASE_ID, buftbl, + FRF_AZ_TX_DESCQ_EVQ_ID, abs_index(vf, vf_evq), + FRF_AZ_TX_DESCQ_LABEL, label, + FRF_AZ_TX_DESCQ_SIZE, __ffs(buf_count), + FRF_BZ_TX_NON_IP_DROP_DIS, 1); + efx_writeo_table(efx, ®, FR_BZ_TX_DESC_PTR_TBL, + abs_index(vf, vf_txq)); + + return VFDI_RC_SUCCESS; +} + +/* Returns true when efx_vfdi_fini_all_queues should wake */ +static bool efx_vfdi_flush_wake(struct efx_vf *vf) +{ + /* Ensure that all updates are visible to efx_vfdi_fini_all_queues() */ + smp_mb(); + + return (!vf->txq_count && !vf->rxq_count) || + atomic_read(&vf->rxq_retry_count); +} + +static void efx_vfdi_flush_clear(struct efx_vf *vf) +{ + memset(vf->txq_mask, 0, sizeof(vf->txq_mask)); + vf->txq_count = 0; + memset(vf->rxq_mask, 0, sizeof(vf->rxq_mask)); + vf->rxq_count = 0; + memset(vf->rxq_retry_mask, 0, sizeof(vf->rxq_retry_mask)); + atomic_set(&vf->rxq_retry_count, 0); +} + +static int efx_vfdi_fini_all_queues(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + efx_oword_t reg; + unsigned count = efx_vf_size(efx); + unsigned vf_offset = EFX_VI_BASE + vf->index * efx_vf_size(efx); + unsigned timeout = HZ; + unsigned index, rxqs_count; + __le32 *rxqs; + int rc; + + rxqs = kmalloc(count * sizeof(*rxqs), GFP_KERNEL); + if (rxqs == NULL) + return VFDI_RC_ENOMEM; + + rtnl_lock(); + if (efx->fc_disable++ == 0) + efx_mcdi_set_mac(efx); + rtnl_unlock(); + + /* Flush all the initialized queues */ + rxqs_count = 0; + for (index = 0; index < count; ++index) { + if (test_bit(index, vf->txq_mask)) { + EFX_POPULATE_OWORD_2(reg, + FRF_AZ_TX_FLUSH_DESCQ_CMD, 1, + FRF_AZ_TX_FLUSH_DESCQ, + vf_offset + index); + efx_writeo(efx, ®, FR_AZ_TX_FLUSH_DESCQ); + } + if (test_bit(index, vf->rxq_mask)) + rxqs[rxqs_count++] = cpu_to_le32(vf_offset + index); + } + + atomic_set(&vf->rxq_retry_count, 0); + while (timeout && (vf->rxq_count || vf->txq_count)) { + rc = efx_mcdi_rpc(efx, MC_CMD_FLUSH_RX_QUEUES, (u8 *)rxqs, + rxqs_count * sizeof(*rxqs), NULL, 0, NULL); + WARN_ON(rc < 0); + + timeout = wait_event_timeout(vf->flush_waitq, + efx_vfdi_flush_wake(vf), + timeout); + rxqs_count = 0; + for (index = 0; index < count; ++index) { + if (test_and_clear_bit(index, vf->rxq_retry_mask)) { + atomic_dec(&vf->rxq_retry_count); + rxqs[rxqs_count++] = + cpu_to_le32(vf_offset + index); + } + } + } + + rtnl_lock(); + if (--efx->fc_disable == 0) + efx_mcdi_set_mac(efx); + rtnl_unlock(); + + /* Irrespective of success/failure, fini the queues */ + EFX_ZERO_OWORD(reg); + for (index = 0; index < count; ++index) { + efx_writeo_table(efx, ®, FR_BZ_RX_DESC_PTR_TBL, + vf_offset + index); + efx_writeo_table(efx, ®, FR_BZ_TX_DESC_PTR_TBL, + vf_offset + index); + efx_writeo_table(efx, ®, FR_BZ_EVQ_PTR_TBL, + vf_offset + index); + efx_writeo_table(efx, ®, FR_BZ_TIMER_TBL, + vf_offset + index); + } + efx_sriov_bufs(efx, vf->buftbl_base, NULL, + EFX_VF_BUFTBL_PER_VI * efx_vf_size(efx)); + kfree(rxqs); + efx_vfdi_flush_clear(vf); + + vf->evq0_count = 0; + + return timeout ? 0 : VFDI_RC_ETIMEDOUT; +} + +static int efx_vfdi_insert_filter(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct vfdi_req *req = vf->buf.addr; + unsigned vf_rxq = req->u.mac_filter.rxq; + unsigned flags; + + if (bad_vf_index(efx, vf_rxq) || vf->rx_filtering) { + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Invalid INSERT_FILTER from %s: rxq %d " + "flags 0x%x\n", vf->pci_name, vf_rxq, + req->u.mac_filter.flags); + return VFDI_RC_EINVAL; + } + + flags = 0; + if (req->u.mac_filter.flags & VFDI_MAC_FILTER_FLAG_RSS) + flags |= EFX_FILTER_FLAG_RX_RSS; + if (req->u.mac_filter.flags & VFDI_MAC_FILTER_FLAG_SCATTER) + flags |= EFX_FILTER_FLAG_RX_SCATTER; + vf->rx_filter_flags = flags; + vf->rx_filter_qid = vf_rxq; + vf->rx_filtering = true; + + efx_sriov_reset_rx_filter(vf); + queue_work(vfdi_workqueue, &efx->peer_work); + + return VFDI_RC_SUCCESS; +} + +static int efx_vfdi_remove_all_filters(struct efx_vf *vf) +{ + vf->rx_filtering = false; + efx_sriov_reset_rx_filter(vf); + queue_work(vfdi_workqueue, &vf->efx->peer_work); + + return VFDI_RC_SUCCESS; +} + +static int efx_vfdi_set_status_page(struct efx_vf *vf) +{ + struct efx_nic *efx = vf->efx; + struct vfdi_req *req = vf->buf.addr; + unsigned int page_count; + + page_count = req->u.set_status_page.peer_page_count; + if (!req->u.set_status_page.dma_addr || EFX_PAGE_SIZE < + offsetof(struct vfdi_req, + u.set_status_page.peer_page_addr[page_count])) { + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Invalid SET_STATUS_PAGE from %s\n", + vf->pci_name); + return VFDI_RC_EINVAL; + } + + mutex_lock(&efx->local_lock); + mutex_lock(&vf->status_lock); + vf->status_addr = req->u.set_status_page.dma_addr; + + kfree(vf->peer_page_addrs); + vf->peer_page_addrs = NULL; + vf->peer_page_count = 0; + + if (page_count) { + vf->peer_page_addrs = kcalloc(page_count, sizeof(u64), + GFP_KERNEL); + if (vf->peer_page_addrs) { + memcpy(vf->peer_page_addrs, + req->u.set_status_page.peer_page_addr, + page_count * sizeof(u64)); + vf->peer_page_count = page_count; + } + } + + __efx_sriov_push_vf_status(vf); + mutex_unlock(&vf->status_lock); + mutex_unlock(&efx->local_lock); + + return VFDI_RC_SUCCESS; +} + +static int efx_vfdi_clear_status_page(struct efx_vf *vf) +{ + mutex_lock(&vf->status_lock); + vf->status_addr = 0; + mutex_unlock(&vf->status_lock); + + return VFDI_RC_SUCCESS; +} + +typedef int (*efx_vfdi_op_t)(struct efx_vf *vf); + +static const efx_vfdi_op_t vfdi_ops[VFDI_OP_LIMIT] = { + [VFDI_OP_INIT_EVQ] = efx_vfdi_init_evq, + [VFDI_OP_INIT_TXQ] = efx_vfdi_init_txq, + [VFDI_OP_INIT_RXQ] = efx_vfdi_init_rxq, + [VFDI_OP_FINI_ALL_QUEUES] = efx_vfdi_fini_all_queues, + [VFDI_OP_INSERT_FILTER] = efx_vfdi_insert_filter, + [VFDI_OP_REMOVE_ALL_FILTERS] = efx_vfdi_remove_all_filters, + [VFDI_OP_SET_STATUS_PAGE] = efx_vfdi_set_status_page, + [VFDI_OP_CLEAR_STATUS_PAGE] = efx_vfdi_clear_status_page, +}; + +static void efx_sriov_vfdi(struct work_struct *work) +{ + struct efx_vf *vf = container_of(work, struct efx_vf, req); + struct efx_nic *efx = vf->efx; + struct vfdi_req *req = vf->buf.addr; + struct efx_memcpy_req copy[2]; + int rc; + + /* Copy this page into the local address space */ + memset(copy, '\0', sizeof(copy)); + copy[0].from_rid = vf->pci_rid; + copy[0].from_addr = vf->req_addr; + copy[0].to_rid = efx->pci_dev->devfn; + copy[0].to_addr = vf->buf.dma_addr; + copy[0].length = EFX_PAGE_SIZE; + rc = efx_sriov_memcpy(efx, copy, 1); + if (rc) { + /* If we can't get the request, we can't reply to the caller */ + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Unable to fetch VFDI request from %s rc %d\n", + vf->pci_name, -rc); + vf->busy = false; + return; + } + + if (req->op < VFDI_OP_LIMIT && vfdi_ops[req->op] != NULL) { + rc = vfdi_ops[req->op](vf); + if (rc == 0) { + netif_dbg(efx, hw, efx->net_dev, + "vfdi request %d from %s ok\n", + req->op, vf->pci_name); + } + } else { + netif_dbg(efx, hw, efx->net_dev, + "ERROR: Unrecognised request %d from VF %s addr " + "%llx\n", req->op, vf->pci_name, + (unsigned long long)vf->req_addr); + rc = VFDI_RC_EOPNOTSUPP; + } + + /* Allow subsequent VF requests */ + vf->busy = false; + smp_wmb(); + + /* Respond to the request */ + req->rc = rc; + req->op = VFDI_OP_RESPONSE; + + memset(copy, '\0', sizeof(copy)); + copy[0].from_buf = &req->rc; + copy[0].to_rid = vf->pci_rid; + copy[0].to_addr = vf->req_addr + offsetof(struct vfdi_req, rc); + copy[0].length = sizeof(req->rc); + copy[1].from_buf = &req->op; + copy[1].to_rid = vf->pci_rid; + copy[1].to_addr = vf->req_addr + offsetof(struct vfdi_req, op); + copy[1].length = sizeof(req->op); + + (void) efx_sriov_memcpy(efx, copy, ARRAY_SIZE(copy)); +} + + + +/* After a reset the event queues inside the guests no longer exist. Fill the + * event ring in guest memory with VFDI reset events, then (re-initialise) the + * event queue to raise an interrupt. The guest driver will then recover. + */ +static void efx_sriov_reset_vf(struct efx_vf *vf, struct efx_buffer *buffer) +{ + struct efx_nic *efx = vf->efx; + struct efx_memcpy_req copy_req[4]; + efx_qword_t event; + unsigned int pos, count, k, buftbl, abs_evq; + efx_oword_t reg; + efx_dword_t ptr; + int rc; + + BUG_ON(buffer->len != EFX_PAGE_SIZE); + + if (!vf->evq0_count) + return; + BUG_ON(vf->evq0_count & (vf->evq0_count - 1)); + + mutex_lock(&vf->status_lock); + EFX_POPULATE_QWORD_3(event, + FSF_AZ_EV_CODE, FSE_CZ_EV_CODE_USER_EV, + VFDI_EV_SEQ, vf->msg_seqno, + VFDI_EV_TYPE, VFDI_EV_TYPE_RESET); + vf->msg_seqno++; + for (pos = 0; pos < EFX_PAGE_SIZE; pos += sizeof(event)) + memcpy(buffer->addr + pos, &event, sizeof(event)); + + for (pos = 0; pos < vf->evq0_count; pos += count) { + count = min_t(unsigned, vf->evq0_count - pos, + ARRAY_SIZE(copy_req)); + for (k = 0; k < count; k++) { + copy_req[k].from_buf = NULL; + copy_req[k].from_rid = efx->pci_dev->devfn; + copy_req[k].from_addr = buffer->dma_addr; + copy_req[k].to_rid = vf->pci_rid; + copy_req[k].to_addr = vf->evq0_addrs[pos + k]; + copy_req[k].length = EFX_PAGE_SIZE; + } + rc = efx_sriov_memcpy(efx, copy_req, count); + if (rc) { + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Unable to notify %s of reset" + ": %d\n", vf->pci_name, -rc); + break; + } + } + + /* Reinitialise, arm and trigger evq0 */ + abs_evq = abs_index(vf, 0); + buftbl = EFX_BUFTBL_EVQ_BASE(vf, 0); + efx_sriov_bufs(efx, buftbl, vf->evq0_addrs, vf->evq0_count); + + EFX_POPULATE_OWORD_3(reg, + FRF_CZ_TIMER_Q_EN, 1, + FRF_CZ_HOST_NOTIFY_MODE, 0, + FRF_CZ_TIMER_MODE, FFE_CZ_TIMER_MODE_DIS); + efx_writeo_table(efx, ®, FR_BZ_TIMER_TBL, abs_evq); + EFX_POPULATE_OWORD_3(reg, + FRF_AZ_EVQ_EN, 1, + FRF_AZ_EVQ_SIZE, __ffs(vf->evq0_count), + FRF_AZ_EVQ_BUF_BASE_ID, buftbl); + efx_writeo_table(efx, ®, FR_BZ_EVQ_PTR_TBL, abs_evq); + EFX_POPULATE_DWORD_1(ptr, FRF_AZ_EVQ_RPTR, 0); + efx_writed_table(efx, &ptr, FR_BZ_EVQ_RPTR, abs_evq); + + mutex_unlock(&vf->status_lock); +} + +static void efx_sriov_reset_vf_work(struct work_struct *work) +{ + struct efx_vf *vf = container_of(work, struct efx_vf, req); + struct efx_nic *efx = vf->efx; + struct efx_buffer buf; + + if (!efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE)) { + efx_sriov_reset_vf(vf, &buf); + efx_nic_free_buffer(efx, &buf); + } +} + +static void efx_sriov_handle_no_channel(struct efx_nic *efx) +{ + netif_err(efx, drv, efx->net_dev, + "ERROR: IOV requires MSI-X and 1 additional interrupt" + "vector. IOV disabled\n"); + efx->vf_count = 0; +} + +static int efx_sriov_probe_channel(struct efx_channel *channel) +{ + channel->efx->vfdi_channel = channel; + return 0; +} + +static void +efx_sriov_get_channel_name(struct efx_channel *channel, char *buf, size_t len) +{ + snprintf(buf, len, "%s-iov", channel->efx->name); +} + +static const struct efx_channel_type efx_sriov_channel_type = { + .handle_no_channel = efx_sriov_handle_no_channel, + .pre_probe = efx_sriov_probe_channel, + .get_name = efx_sriov_get_channel_name, + /* no copy operation; channel must not be reallocated */ + .keep_eventq = true, +}; + +void efx_sriov_probe(struct efx_nic *efx) +{ + unsigned count; + + if (!max_vfs) + return; + + if (efx_sriov_cmd(efx, false, &efx->vi_scale, &count)) + return; + if (count > 0 && count > max_vfs) + count = max_vfs; + + /* efx_nic_dimension_resources() will reduce vf_count as appopriate */ + efx->vf_count = count; + + efx->extra_channel_type[EFX_EXTRA_CHANNEL_IOV] = &efx_sriov_channel_type; +} + +/* Copy the list of individual addresses into the vfdi_status.peers + * array and auxillary pages, protected by %local_lock. Drop that lock + * and then broadcast the address list to every VF. + */ +static void efx_sriov_peer_work(struct work_struct *data) +{ + struct efx_nic *efx = container_of(data, struct efx_nic, peer_work); + struct vfdi_status *vfdi_status = efx->vfdi_status.addr; + struct efx_vf *vf; + struct efx_local_addr *local_addr; + struct vfdi_endpoint *peer; + struct efx_endpoint_page *epp; + struct list_head pages; + unsigned int peer_space; + unsigned int peer_count; + unsigned int pos; + + mutex_lock(&efx->local_lock); + + /* Move the existing peer pages off %local_page_list */ + INIT_LIST_HEAD(&pages); + list_splice_tail_init(&efx->local_page_list, &pages); + + /* Populate the VF addresses starting from entry 1 (entry 0 is + * the PF address) + */ + peer = vfdi_status->peers + 1; + peer_space = ARRAY_SIZE(vfdi_status->peers) - 1; + peer_count = 1; + for (pos = 0; pos < efx->vf_count; ++pos) { + vf = efx->vf + pos; + + mutex_lock(&vf->status_lock); + if (vf->rx_filtering && !is_zero_ether_addr(vf->addr.mac_addr)) { + *peer++ = vf->addr; + ++peer_count; + --peer_space; + BUG_ON(peer_space == 0); + } + mutex_unlock(&vf->status_lock); + } + + /* Fill the remaining addresses */ + list_for_each_entry(local_addr, &efx->local_addr_list, link) { + memcpy(peer->mac_addr, local_addr->addr, ETH_ALEN); + peer->tci = 0; + ++peer; + ++peer_count; + if (--peer_space == 0) { + if (list_empty(&pages)) { + epp = kmalloc(sizeof(*epp), GFP_KERNEL); + if (!epp) + break; + epp->ptr = dma_alloc_coherent( + &efx->pci_dev->dev, EFX_PAGE_SIZE, + &epp->addr, GFP_KERNEL); + if (!epp->ptr) { + kfree(epp); + break; + } + } else { + epp = list_first_entry( + &pages, struct efx_endpoint_page, link); + list_del(&epp->link); + } + + list_add_tail(&epp->link, &efx->local_page_list); + peer = (struct vfdi_endpoint *)epp->ptr; + peer_space = EFX_PAGE_SIZE / sizeof(struct vfdi_endpoint); + } + } + vfdi_status->peer_count = peer_count; + mutex_unlock(&efx->local_lock); + + /* Free any now unused endpoint pages */ + while (!list_empty(&pages)) { + epp = list_first_entry( + &pages, struct efx_endpoint_page, link); + list_del(&epp->link); + dma_free_coherent(&efx->pci_dev->dev, EFX_PAGE_SIZE, + epp->ptr, epp->addr); + kfree(epp); + } + + /* Finally, push the pages */ + for (pos = 0; pos < efx->vf_count; ++pos) { + vf = efx->vf + pos; + + mutex_lock(&vf->status_lock); + if (vf->status_addr) + __efx_sriov_push_vf_status(vf); + mutex_unlock(&vf->status_lock); + } +} + +static void efx_sriov_free_local(struct efx_nic *efx) +{ + struct efx_local_addr *local_addr; + struct efx_endpoint_page *epp; + + while (!list_empty(&efx->local_addr_list)) { + local_addr = list_first_entry(&efx->local_addr_list, + struct efx_local_addr, link); + list_del(&local_addr->link); + kfree(local_addr); + } + + while (!list_empty(&efx->local_page_list)) { + epp = list_first_entry(&efx->local_page_list, + struct efx_endpoint_page, link); + list_del(&epp->link); + dma_free_coherent(&efx->pci_dev->dev, EFX_PAGE_SIZE, + epp->ptr, epp->addr); + kfree(epp); + } +} + +static int efx_sriov_vf_alloc(struct efx_nic *efx) +{ + unsigned index; + struct efx_vf *vf; + + efx->vf = kzalloc(sizeof(struct efx_vf) * efx->vf_count, GFP_KERNEL); + if (!efx->vf) + return -ENOMEM; + + for (index = 0; index < efx->vf_count; ++index) { + vf = efx->vf + index; + + vf->efx = efx; + vf->index = index; + vf->rx_filter_id = -1; + vf->tx_filter_mode = VF_TX_FILTER_AUTO; + vf->tx_filter_id = -1; + INIT_WORK(&vf->req, efx_sriov_vfdi); + INIT_WORK(&vf->reset_work, efx_sriov_reset_vf_work); + init_waitqueue_head(&vf->flush_waitq); + mutex_init(&vf->status_lock); + mutex_init(&vf->txq_lock); + } + + return 0; +} + +static void efx_sriov_vfs_fini(struct efx_nic *efx) +{ + struct efx_vf *vf; + unsigned int pos; + + for (pos = 0; pos < efx->vf_count; ++pos) { + vf = efx->vf + pos; + + efx_nic_free_buffer(efx, &vf->buf); + kfree(vf->peer_page_addrs); + vf->peer_page_addrs = NULL; + vf->peer_page_count = 0; + + vf->evq0_count = 0; + } +} + +static int efx_sriov_vfs_init(struct efx_nic *efx) +{ + struct pci_dev *pci_dev = efx->pci_dev; + unsigned index, devfn, sriov, buftbl_base; + u16 offset, stride; + struct efx_vf *vf; + int rc; + + sriov = pci_find_ext_capability(pci_dev, PCI_EXT_CAP_ID_SRIOV); + if (!sriov) + return -ENOENT; + + pci_read_config_word(pci_dev, sriov + PCI_SRIOV_VF_OFFSET, &offset); + pci_read_config_word(pci_dev, sriov + PCI_SRIOV_VF_STRIDE, &stride); + + buftbl_base = efx->vf_buftbl_base; + devfn = pci_dev->devfn + offset; + for (index = 0; index < efx->vf_count; ++index) { + vf = efx->vf + index; + + /* Reserve buffer entries */ + vf->buftbl_base = buftbl_base; + buftbl_base += EFX_VF_BUFTBL_PER_VI * efx_vf_size(efx); + + vf->pci_rid = devfn; + snprintf(vf->pci_name, sizeof(vf->pci_name), + "%04x:%02x:%02x.%d", + pci_domain_nr(pci_dev->bus), pci_dev->bus->number, + PCI_SLOT(devfn), PCI_FUNC(devfn)); + + rc = efx_nic_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE); + if (rc) + goto fail; + + devfn += stride; + } + + return 0; + +fail: + efx_sriov_vfs_fini(efx); + return rc; +} + +int efx_sriov_init(struct efx_nic *efx) +{ + struct net_device *net_dev = efx->net_dev; + struct vfdi_status *vfdi_status; + int rc; + + /* Ensure there's room for vf_channel */ + BUILD_BUG_ON(EFX_MAX_CHANNELS + 1 >= EFX_VI_BASE); + /* Ensure that VI_BASE is aligned on VI_SCALE */ + BUILD_BUG_ON(EFX_VI_BASE & ((1 << EFX_VI_SCALE_MAX) - 1)); + + if (efx->vf_count == 0) + return 0; + + rc = efx_sriov_cmd(efx, true, NULL, NULL); + if (rc) + goto fail_cmd; + + rc = efx_nic_alloc_buffer(efx, &efx->vfdi_status, sizeof(*vfdi_status)); + if (rc) + goto fail_status; + vfdi_status = efx->vfdi_status.addr; + memset(vfdi_status, 0, sizeof(*vfdi_status)); + vfdi_status->version = 1; + vfdi_status->length = sizeof(*vfdi_status); + vfdi_status->max_tx_channels = vf_max_tx_channels; + vfdi_status->vi_scale = efx->vi_scale; + vfdi_status->rss_rxq_count = efx->rss_spread; + vfdi_status->peer_count = 1 + efx->vf_count; + vfdi_status->timer_quantum_ns = efx->timer_quantum_ns; + + rc = efx_sriov_vf_alloc(efx); + if (rc) + goto fail_alloc; + + mutex_init(&efx->local_lock); + INIT_WORK(&efx->peer_work, efx_sriov_peer_work); + INIT_LIST_HEAD(&efx->local_addr_list); + INIT_LIST_HEAD(&efx->local_page_list); + + rc = efx_sriov_vfs_init(efx); + if (rc) + goto fail_vfs; + + rtnl_lock(); + memcpy(vfdi_status->peers[0].mac_addr, + net_dev->dev_addr, ETH_ALEN); + efx->vf_init_count = efx->vf_count; + rtnl_unlock(); + + efx_sriov_usrev(efx, true); + + /* At this point we must be ready to accept VFDI requests */ + + rc = pci_enable_sriov(efx->pci_dev, efx->vf_count); + if (rc) + goto fail_pci; + + netif_info(efx, probe, net_dev, + "enabled SR-IOV for %d VFs, %d VI per VF\n", + efx->vf_count, efx_vf_size(efx)); + return 0; + +fail_pci: + efx_sriov_usrev(efx, false); + rtnl_lock(); + efx->vf_init_count = 0; + rtnl_unlock(); + efx_sriov_vfs_fini(efx); +fail_vfs: + cancel_work_sync(&efx->peer_work); + efx_sriov_free_local(efx); + kfree(efx->vf); +fail_alloc: + efx_nic_free_buffer(efx, &efx->vfdi_status); +fail_status: + efx_sriov_cmd(efx, false, NULL, NULL); +fail_cmd: + return rc; +} + +void efx_sriov_fini(struct efx_nic *efx) +{ + struct efx_vf *vf; + unsigned int pos; + + if (efx->vf_init_count == 0) + return; + + /* Disable all interfaces to reconfiguration */ + BUG_ON(efx->vfdi_channel->enabled); + efx_sriov_usrev(efx, false); + rtnl_lock(); + efx->vf_init_count = 0; + rtnl_unlock(); + + /* Flush all reconfiguration work */ + for (pos = 0; pos < efx->vf_count; ++pos) { + vf = efx->vf + pos; + cancel_work_sync(&vf->req); + cancel_work_sync(&vf->reset_work); + } + cancel_work_sync(&efx->peer_work); + + pci_disable_sriov(efx->pci_dev); + + /* Tear down back-end state */ + efx_sriov_vfs_fini(efx); + efx_sriov_free_local(efx); + kfree(efx->vf); + efx_nic_free_buffer(efx, &efx->vfdi_status); + efx_sriov_cmd(efx, false, NULL, NULL); +} + +void efx_sriov_event(struct efx_channel *channel, efx_qword_t *event) +{ + struct efx_nic *efx = channel->efx; + struct efx_vf *vf; + unsigned qid, seq, type, data; + + qid = EFX_QWORD_FIELD(*event, FSF_CZ_USER_QID); + + /* USR_EV_REG_VALUE is dword0, so access the VFDI_EV fields directly */ + BUILD_BUG_ON(FSF_CZ_USER_EV_REG_VALUE_LBN != 0); + seq = EFX_QWORD_FIELD(*event, VFDI_EV_SEQ); + type = EFX_QWORD_FIELD(*event, VFDI_EV_TYPE); + data = EFX_QWORD_FIELD(*event, VFDI_EV_DATA); + + netif_vdbg(efx, hw, efx->net_dev, + "USR_EV event from qid %d seq 0x%x type %d data 0x%x\n", + qid, seq, type, data); + + if (map_vi_index(efx, qid, &vf, NULL)) + return; + if (vf->busy) + goto error; + + if (type == VFDI_EV_TYPE_REQ_WORD0) { + /* Resynchronise */ + vf->req_type = VFDI_EV_TYPE_REQ_WORD0; + vf->req_seqno = seq + 1; + vf->req_addr = 0; + } else if (seq != (vf->req_seqno++ & 0xff) || type != vf->req_type) + goto error; + + switch (vf->req_type) { + case VFDI_EV_TYPE_REQ_WORD0: + case VFDI_EV_TYPE_REQ_WORD1: + case VFDI_EV_TYPE_REQ_WORD2: + vf->req_addr |= (u64)data << (vf->req_type << 4); + ++vf->req_type; + return; + + case VFDI_EV_TYPE_REQ_WORD3: + vf->req_addr |= (u64)data << 48; + vf->req_type = VFDI_EV_TYPE_REQ_WORD0; + vf->busy = true; + queue_work(vfdi_workqueue, &vf->req); + return; + } + +error: + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "ERROR: Screaming VFDI request from %s\n", + vf->pci_name); + /* Reset the request and sequence number */ + vf->req_type = VFDI_EV_TYPE_REQ_WORD0; + vf->req_seqno = seq + 1; +} + +void efx_sriov_flr(struct efx_nic *efx, unsigned vf_i) +{ + struct efx_vf *vf; + + if (vf_i > efx->vf_init_count) + return; + vf = efx->vf + vf_i; + netif_info(efx, hw, efx->net_dev, + "FLR on VF %s\n", vf->pci_name); + + vf->status_addr = 0; + efx_vfdi_remove_all_filters(vf); + efx_vfdi_flush_clear(vf); + + vf->evq0_count = 0; +} + +void efx_sriov_mac_address_changed(struct efx_nic *efx) +{ + struct vfdi_status *vfdi_status = efx->vfdi_status.addr; + + if (!efx->vf_init_count) + return; + memcpy(vfdi_status->peers[0].mac_addr, + efx->net_dev->dev_addr, ETH_ALEN); + queue_work(vfdi_workqueue, &efx->peer_work); +} + +void efx_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event) +{ + struct efx_vf *vf; + unsigned queue, qid; + + queue = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA); + if (map_vi_index(efx, queue, &vf, &qid)) + return; + /* Ignore flush completions triggered by an FLR */ + if (!test_bit(qid, vf->txq_mask)) + return; + + __clear_bit(qid, vf->txq_mask); + --vf->txq_count; + + if (efx_vfdi_flush_wake(vf)) + wake_up(&vf->flush_waitq); +} + +void efx_sriov_rx_flush_done(struct efx_nic *efx, efx_qword_t *event) +{ + struct efx_vf *vf; + unsigned ev_failed, queue, qid; + + queue = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_DESCQ_ID); + ev_failed = EFX_QWORD_FIELD(*event, + FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL); + if (map_vi_index(efx, queue, &vf, &qid)) + return; + if (!test_bit(qid, vf->rxq_mask)) + return; + + if (ev_failed) { + set_bit(qid, vf->rxq_retry_mask); + atomic_inc(&vf->rxq_retry_count); + } else { + __clear_bit(qid, vf->rxq_mask); + --vf->rxq_count; + } + if (efx_vfdi_flush_wake(vf)) + wake_up(&vf->flush_waitq); +} + +/* Called from napi. Schedule the reset work item */ +void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq) +{ + struct efx_vf *vf; + unsigned int rel; + + if (map_vi_index(efx, dmaq, &vf, &rel)) + return; + + if (net_ratelimit()) + netif_err(efx, hw, efx->net_dev, + "VF %d DMA Q %d reports descriptor fetch error.\n", + vf->index, rel); + queue_work(vfdi_workqueue, &vf->reset_work); +} + +/* Reset all VFs */ +void efx_sriov_reset(struct efx_nic *efx) +{ + unsigned int vf_i; + struct efx_buffer buf; + struct efx_vf *vf; + + ASSERT_RTNL(); + + if (efx->vf_init_count == 0) + return; + + efx_sriov_usrev(efx, true); + (void)efx_sriov_cmd(efx, true, NULL, NULL); + + if (efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE)) + return; + + for (vf_i = 0; vf_i < efx->vf_init_count; ++vf_i) { + vf = efx->vf + vf_i; + efx_sriov_reset_vf(vf, &buf); + } + + efx_nic_free_buffer(efx, &buf); +} + +int efx_init_sriov(void) +{ + /* A single threaded workqueue is sufficient. efx_sriov_vfdi() and + * efx_sriov_peer_work() spend almost all their time sleeping for + * MCDI to complete anyway + */ + vfdi_workqueue = create_singlethread_workqueue("sfc_vfdi"); + if (!vfdi_workqueue) + return -ENOMEM; + + return 0; +} + +void efx_fini_sriov(void) +{ + destroy_workqueue(vfdi_workqueue); +} + +int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac) +{ + struct efx_nic *efx = netdev_priv(net_dev); + struct efx_vf *vf; + + if (vf_i >= efx->vf_init_count) + return -EINVAL; + vf = efx->vf + vf_i; + + mutex_lock(&vf->status_lock); + memcpy(vf->addr.mac_addr, mac, ETH_ALEN); + __efx_sriov_update_vf_addr(vf); + mutex_unlock(&vf->status_lock); + + return 0; +} + +int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, + u16 vlan, u8 qos) +{ + struct efx_nic *efx = netdev_priv(net_dev); + struct efx_vf *vf; + u16 tci; + + if (vf_i >= efx->vf_init_count) + return -EINVAL; + vf = efx->vf + vf_i; + + mutex_lock(&vf->status_lock); + tci = (vlan & VLAN_VID_MASK) | ((qos & 0x7) << VLAN_PRIO_SHIFT); + vf->addr.tci = htons(tci); + __efx_sriov_update_vf_addr(vf); + mutex_unlock(&vf->status_lock); + + return 0; +} + +int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i, + bool spoofchk) +{ + struct efx_nic *efx = netdev_priv(net_dev); + struct efx_vf *vf; + int rc; + + if (vf_i >= efx->vf_init_count) + return -EINVAL; + vf = efx->vf + vf_i; + + mutex_lock(&vf->txq_lock); + if (vf->txq_count == 0) { + vf->tx_filter_mode = + spoofchk ? VF_TX_FILTER_ON : VF_TX_FILTER_OFF; + rc = 0; + } else { + /* This cannot be changed while TX queues are running */ + rc = -EBUSY; + } + mutex_unlock(&vf->txq_lock); + return rc; +} + +int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i, + struct ifla_vf_info *ivi) +{ + struct efx_nic *efx = netdev_priv(net_dev); + struct efx_vf *vf; + u16 tci; + + if (vf_i >= efx->vf_init_count) + return -EINVAL; + vf = efx->vf + vf_i; + + ivi->vf = vf_i; + memcpy(ivi->mac, vf->addr.mac_addr, ETH_ALEN); + ivi->tx_rate = 0; + tci = ntohs(vf->addr.tci); + ivi->vlan = tci & VLAN_VID_MASK; + ivi->qos = (tci >> VLAN_PRIO_SHIFT) & 0x7; + ivi->spoofchk = vf->tx_filter_mode == VF_TX_FILTER_ON; + + return 0; +} + diff --git a/drivers/net/ethernet/sfc/vfdi.h b/drivers/net/ethernet/sfc/vfdi.h new file mode 100644 index 000000000000..656fa70f9993 --- /dev/null +++ b/drivers/net/ethernet/sfc/vfdi.h @@ -0,0 +1,254 @@ +/**************************************************************************** + * Driver for Solarflare Solarstorm network controllers and boards + * Copyright 2010-2012 Solarflare Communications Inc. + * + * 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, incorporated herein by reference. + */ +#ifndef _VFDI_H +#define _VFDI_H + +/** + * DOC: Virtual Function Driver Interface + * + * This file contains software structures used to form a two way + * communication channel between the VF driver and the PF driver, + * named Virtual Function Driver Interface (VFDI). + * + * For the purposes of VFDI, a page is a memory region with size and + * alignment of 4K. All addresses are DMA addresses to be used within + * the domain of the relevant VF. + * + * The only hardware-defined channels for a VF driver to communicate + * with the PF driver are the event mailboxes (%FR_CZ_USR_EV + * registers). Writing to these registers generates an event with + * EV_CODE = EV_CODE_USR_EV, USER_QID set to the index of the mailbox + * and USER_EV_REG_VALUE set to the value written. The PF driver may + * direct or disable delivery of these events by setting + * %FR_CZ_USR_EV_CFG. + * + * The PF driver can send arbitrary events to arbitrary event queues. + * However, for consistency, VFDI events from the PF are defined to + * follow the same form and be sent to the first event queue assigned + * to the VF while that queue is enabled by the VF driver. + * + * The general form of the variable bits of VFDI events is: + * + * 0 16 24 31 + * | DATA | TYPE | SEQ | + * + * SEQ is a sequence number which should be incremented by 1 (modulo + * 256) for each event. The sequence numbers used in each direction + * are independent. + * + * The VF submits requests of type &struct vfdi_req by sending the + * address of the request (ADDR) in a series of 4 events: + * + * 0 16 24 31 + * | ADDR[0:15] | VFDI_EV_TYPE_REQ_WORD0 | SEQ | + * | ADDR[16:31] | VFDI_EV_TYPE_REQ_WORD1 | SEQ+1 | + * | ADDR[32:47] | VFDI_EV_TYPE_REQ_WORD2 | SEQ+2 | + * | ADDR[48:63] | VFDI_EV_TYPE_REQ_WORD3 | SEQ+3 | + * + * The address must be page-aligned. After receiving such a valid + * series of events, the PF driver will attempt to read the request + * and write a response to the same address. In case of an invalid + * sequence of events or a DMA error, there will be no response. + * + * The VF driver may request that the PF driver writes status + * information into its domain asynchronously. After writing the + * status, the PF driver will send an event of the form: + * + * 0 16 24 31 + * | reserved | VFDI_EV_TYPE_STATUS | SEQ | + * + * In case the VF must be reset for any reason, the PF driver will + * send an event of the form: + * + * 0 16 24 31 + * | reserved | VFDI_EV_TYPE_RESET | SEQ | + * + * It is then the responsibility of the VF driver to request + * reinitialisation of its queues. + */ +#define VFDI_EV_SEQ_LBN 24 +#define VFDI_EV_SEQ_WIDTH 8 +#define VFDI_EV_TYPE_LBN 16 +#define VFDI_EV_TYPE_WIDTH 8 +#define VFDI_EV_TYPE_REQ_WORD0 0 +#define VFDI_EV_TYPE_REQ_WORD1 1 +#define VFDI_EV_TYPE_REQ_WORD2 2 +#define VFDI_EV_TYPE_REQ_WORD3 3 +#define VFDI_EV_TYPE_STATUS 4 +#define VFDI_EV_TYPE_RESET 5 +#define VFDI_EV_DATA_LBN 0 +#define VFDI_EV_DATA_WIDTH 16 + +struct vfdi_endpoint { + u8 mac_addr[ETH_ALEN]; + __be16 tci; +}; + +/** + * enum vfdi_op - VFDI operation enumeration + * @VFDI_OP_RESPONSE: Indicates a response to the request. + * @VFDI_OP_INIT_EVQ: Initialize SRAM entries and initialize an EVQ. + * @VFDI_OP_INIT_RXQ: Initialize SRAM entries and initialize an RXQ. + * @VFDI_OP_INIT_TXQ: Initialize SRAM entries and initialize a TXQ. + * @VFDI_OP_FINI_ALL_QUEUES: Flush all queues, finalize all queues, then + * finalize the SRAM entries. + * @VFDI_OP_INSERT_FILTER: Insert a MAC filter targetting the given RXQ. + * @VFDI_OP_REMOVE_ALL_FILTERS: Remove all filters. + * @VFDI_OP_SET_STATUS_PAGE: Set the DMA page(s) used for status updates + * from PF and write the initial status. + * @VFDI_OP_CLEAR_STATUS_PAGE: Clear the DMA page(s) used for status + * updates from PF. + */ +enum vfdi_op { + VFDI_OP_RESPONSE = 0, + VFDI_OP_INIT_EVQ = 1, + VFDI_OP_INIT_RXQ = 2, + VFDI_OP_INIT_TXQ = 3, + VFDI_OP_FINI_ALL_QUEUES = 4, + VFDI_OP_INSERT_FILTER = 5, + VFDI_OP_REMOVE_ALL_FILTERS = 6, + VFDI_OP_SET_STATUS_PAGE = 7, + VFDI_OP_CLEAR_STATUS_PAGE = 8, + VFDI_OP_LIMIT, +}; + +/* Response codes for VFDI operations. Other values may be used in future. */ +#define VFDI_RC_SUCCESS 0 +#define VFDI_RC_ENOMEM (-12) +#define VFDI_RC_EINVAL (-22) +#define VFDI_RC_EOPNOTSUPP (-95) +#define VFDI_RC_ETIMEDOUT (-110) + +/** + * struct vfdi_req - Request from VF driver to PF driver + * @op: Operation code or response indicator, taken from &enum vfdi_op. + * @rc: Response code. Set to 0 on success or a negative error code on failure. + * @u.init_evq.index: Index of event queue to create. + * @u.init_evq.buf_count: Number of 4k buffers backing event queue. + * @u.init_evq.addr: Array of length %u.init_evq.buf_count containing DMA + * address of each page backing the event queue. + * @u.init_rxq.index: Index of receive queue to create. + * @u.init_rxq.buf_count: Number of 4k buffers backing receive queue. + * @u.init_rxq.evq: Instance of event queue to target receive events at. + * @u.init_rxq.label: Label used in receive events. + * @u.init_rxq.flags: Unused. + * @u.init_rxq.addr: Array of length %u.init_rxq.buf_count containing DMA + * address of each page backing the receive queue. + * @u.init_txq.index: Index of transmit queue to create. + * @u.init_txq.buf_count: Number of 4k buffers backing transmit queue. + * @u.init_txq.evq: Instance of event queue to target transmit completion + * events at. + * @u.init_txq.label: Label used in transmit completion events. + * @u.init_txq.flags: Checksum offload flags. + * @u.init_txq.addr: Array of length %u.init_txq.buf_count containing DMA + * address of each page backing the transmit queue. + * @u.mac_filter.rxq: Insert MAC filter at VF local address/VLAN targetting + * all traffic at this receive queue. + * @u.mac_filter.flags: MAC filter flags. + * @u.set_status_page.dma_addr: Base address for the &struct vfdi_status. + * This address must be such that the structure fits within a page. + * @u.set_status_page.peer_page_count: Number of additional pages the VF + * has provided into which peer addresses may be DMAd. + * @u.set_status_page.peer_page_addr: Array of DMA addresses of pages. + * If the number of peers exceeds 256, then the VF must provide + * additional pages in this array. The PF will then DMA up to + * 512 vfdi_endpoint structures into each page. These addresses + * must be page-aligned. + */ +struct vfdi_req { + u32 op; + u32 reserved1; + s32 rc; + u32 reserved2; + union { + struct { + u32 index; + u32 buf_count; + u64 addr[]; + } init_evq; + struct { + u32 index; + u32 buf_count; + u32 evq; + u32 label; + u32 flags; +#define VFDI_RXQ_FLAG_SCATTER_EN 1 + u32 reserved; + u64 addr[]; + } init_rxq; + struct { + u32 index; + u32 buf_count; + u32 evq; + u32 label; + u32 flags; +#define VFDI_TXQ_FLAG_IP_CSUM_DIS 1 +#define VFDI_TXQ_FLAG_TCPUDP_CSUM_DIS 2 + u32 reserved; + u64 addr[]; + } init_txq; + struct { + u32 rxq; + u32 flags; +#define VFDI_MAC_FILTER_FLAG_RSS 1 +#define VFDI_MAC_FILTER_FLAG_SCATTER 2 + } mac_filter; + struct { + u64 dma_addr; + u64 peer_page_count; + u64 peer_page_addr[]; + } set_status_page; + } u; +}; + +/** + * struct vfdi_status - Status provided by PF driver to VF driver + * @generation_start: A generation count DMA'd to VF *before* the + * rest of the structure. + * @generation_end: A generation count DMA'd to VF *after* the + * rest of the structure. + * @version: Version of this structure; currently set to 1. Later + * versions must either be layout-compatible or only be sent to VFs + * that specifically request them. + * @length: Total length of this structure including embedded tables + * @vi_scale: log2 the number of VIs available on this VF. This quantity + * is used by the hardware for register decoding. + * @max_tx_channels: The maximum number of transmit queues the VF can use. + * @rss_rxq_count: The number of receive queues present in the shared RSS + * indirection table. + * @peer_count: Total number of peers in the complete peer list. If larger + * than ARRAY_SIZE(%peers), then the VF must provide sufficient + * additional pages each of which is filled with vfdi_endpoint structures. + * @local: The MAC address and outer VLAN tag of *this* VF + * @peers: Table of peer addresses. The @tci fields in these structures + * are currently unused and must be ignored. Additional peers are + * written into any additional pages provided by the VF. + * @timer_quantum_ns: Timer quantum (nominal period between timer ticks) + * for interrupt moderation timers, in nanoseconds. This member is only + * present if @length is sufficiently large. + */ +struct vfdi_status { + u32 generation_start; + u32 generation_end; + u32 version; + u32 length; + u8 vi_scale; + u8 max_tx_channels; + u8 rss_rxq_count; + u8 reserved1; + u16 peer_count; + u16 reserved2; + struct vfdi_endpoint local; + struct vfdi_endpoint peers[256]; + + /* Members below here extend version 1 of this structure */ + u32 timer_quantum_ns; +}; + +#endif -- GitLab From 7ddb6e0f3f7aa265c905b947e9ac4ab9562e52f2 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 14 Feb 2012 15:12:57 +0200 Subject: [PATCH 0801/1846] Bluetooth: Do not dereference zero sk Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_sock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 16360298590f..138fe3446678 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -795,7 +795,7 @@ static void l2cap_sock_kill(struct sock *sk) static int l2cap_sock_shutdown(struct socket *sock, int how) { struct sock *sk = sock->sk; - struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct l2cap_chan *chan; int err = 0; BT_DBG("sock %p, sk %p", sock, sk); @@ -803,6 +803,8 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) if (!sk) return 0; + chan = l2cap_pi(sk)->chan; + lock_sock(sk); if (!sk->sk_shutdown) { if (chan->mode == L2CAP_MODE_ERTM) -- GitLab From 17071578888c7c18709e48e74fae228c04581b9a Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Mon, 7 Nov 2011 16:36:40 +0100 Subject: [PATCH 0802/1846] batman-adv: add tt_initialised flag to the orig_node struct (ttvn == 0) is currently used as initial condition. However this is not a good idea because ttvn gets the vale zero each time after reaching the maximum value (wrap around). For this reason a new flag is added in order to define whether a node has an initialised table or not. Moreover, after invoking tt_global_del_orig(), tt_initialised has to be set to false Reported-by: Alexey Fisher Signed-off-by: Antonio Quartulli Signed-off-by: Simon Wunderlich Tested-by: Alexey Fisher Signed-off-by: Marek Lindner --- net/batman-adv/originator.c | 1 + net/batman-adv/translation-table.c | 11 ++++++++--- net/batman-adv/types.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 0bc2045a2f2e..847ff7e98a61 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) /* extra reference for return */ atomic_set(&orig_node->refcount, 2); + orig_node->tt_initialised = false; orig_node->tt_poss_change = false; orig_node->bat_priv = bat_priv; memcpy(orig_node->orig, addr, ETH_ALEN); diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index ab8dea8b0b2e..c632475df375 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -733,6 +733,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, spin_unlock_bh(list_lock); } atomic_set(&orig_node->tt_size, 0); + orig_node->tt_initialised = false; } static void tt_global_roam_purge(struct bat_priv *bat_priv) @@ -1450,6 +1451,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv, */ return; } + orig_node->tt_initialised = true; } static void tt_fill_gtable(struct bat_priv *bat_priv, @@ -1854,8 +1856,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); bool full_table = true; - /* the ttvn increased by one -> we can apply the attached changes */ - if (ttvn - orig_ttvn == 1) { + /* orig table not initialised AND first diff is in the OGM OR the ttvn + * increased by one -> we can apply the attached changes */ + if ((!orig_node->tt_initialised && ttvn == 1) || + ttvn - orig_ttvn == 1) { /* the OGM could not contain the changes due to their size or * because they have already been sent TT_OGM_APPEND_MAX times. * In this case send a tt request */ @@ -1889,7 +1893,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, } else { /* if we missed more than one change or our tables are not * in sync anymore -> request fresh tt data */ - if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { + if (!orig_node->tt_initialised || ttvn != orig_ttvn || + orig_node->tt_crc != tt_crc) { request_table: bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " "Need to retrieve the correct information " diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index e9eb043719ac..35085f410b96 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -81,6 +81,7 @@ struct orig_node { int16_t tt_buff_len; spinlock_t tt_buff_lock; /* protects tt_buff */ atomic_t tt_size; + bool tt_initialised; /* The tt_poss_change flag is used to detect an ongoing roaming phase. * If true, then I sent a Roaming_adv to this orig_node and I have to * inspect every packet directed to it to check whether it is still -- GitLab From 76543d14aec6ce5cb3fc7be9b39c50fcebd2043b Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 20 Nov 2011 15:47:38 +0100 Subject: [PATCH 0803/1846] batman-adv: Explicitly mark the common header structure All batman-adv packets have a common 3 byte header. It can be used to share some code between different code paths, but it was never explicit stated that this header has to be always the same for all packets. Therefore, new code changes always have the problem that they may accidently introduce regressions by moving some elements around. A new structure is introduced that contains the common header and makes it easier visible that these 3 bytes have to be the same for all on-wire packets. Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/bat_iv_ogm.c | 47 +++++++++++++++--------------- net/batman-adv/hard-interface.c | 6 ++-- net/batman-adv/icmp_socket.c | 6 ++-- net/batman-adv/packet.h | 38 +++++++++--------------- net/batman-adv/routing.c | 18 ++++++------ net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c | 14 ++++----- net/batman-adv/translation-table.c | 24 +++++++-------- net/batman-adv/unicast.c | 16 +++++----- net/batman-adv/vis.c | 14 ++++----- 10 files changed, 87 insertions(+), 98 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 3512e251545b..d60e1ba0bc15 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -38,10 +38,10 @@ void bat_ogm_init(struct hard_iface *hard_iface) hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC); batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; - batman_ogm_packet->packet_type = BAT_OGM; - batman_ogm_packet->version = COMPAT_VERSION; + batman_ogm_packet->header.packet_type = BAT_OGM; + batman_ogm_packet->header.version = COMPAT_VERSION; + batman_ogm_packet->header.ttl = 2; batman_ogm_packet->flags = NO_FLAGS; - batman_ogm_packet->ttl = 2; batman_ogm_packet->tq = TQ_MAX_VALUE; batman_ogm_packet->tt_num_changes = 0; batman_ogm_packet->ttvn = 0; @@ -53,7 +53,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface) batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; - batman_ogm_packet->ttl = TTL; + batman_ogm_packet->header.ttl = TTL; } void bat_ogm_update_mac(struct hard_iface *hard_iface) @@ -137,7 +137,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet, fwd_str, (packet_num > 0 ? "aggregated " : ""), batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), - batman_ogm_packet->tq, batman_ogm_packet->ttl, + batman_ogm_packet->tq, batman_ogm_packet->header.ttl, (batman_ogm_packet->flags & DIRECTLINK ? "on" : "off"), batman_ogm_packet->ttvn, hard_iface->net_dev->name, @@ -188,7 +188,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet) /* multihomed peer assumed */ /* non-primary OGMs are only broadcasted on their interface */ - if ((directlink && (batman_ogm_packet->ttl == 1)) || + if ((directlink && (batman_ogm_packet->header.ttl == 1)) || (forw_packet->own && (forw_packet->if_incoming != primary_if))) { /* FIXME: what about aggregated packets ? */ @@ -198,7 +198,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet) (forw_packet->own ? "Sending own" : "Forwarding"), batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), - batman_ogm_packet->ttl, + batman_ogm_packet->header.ttl, forw_packet->if_incoming->net_dev->name, forw_packet->if_incoming->net_dev->dev_addr); @@ -272,7 +272,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet * are flooded through the net */ if ((!directlink) && (!(batman_ogm_packet->flags & DIRECTLINK)) && - (batman_ogm_packet->ttl != 1) && + (batman_ogm_packet->header.ttl != 1) && /* own packets originating non-primary * interfaces leave only that interface */ @@ -285,7 +285,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet /* if the incoming packet is sent via this one * interface only - we still can aggregate */ if ((directlink) && - (new_batman_ogm_packet->ttl == 1) && + (new_batman_ogm_packet->header.ttl == 1) && (forw_packet->if_incoming == if_incoming) && /* packets from direct neighbors or @@ -471,7 +471,7 @@ static void bat_ogm_forward(struct orig_node *orig_node, uint8_t in_tq, in_ttl, tq_avg = 0; uint8_t tt_num_changes; - if (batman_ogm_packet->ttl <= 1) { + if (batman_ogm_packet->header.ttl <= 1) { bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); return; } @@ -479,10 +479,10 @@ static void bat_ogm_forward(struct orig_node *orig_node, router = orig_node_get_router(orig_node); in_tq = batman_ogm_packet->tq; - in_ttl = batman_ogm_packet->ttl; + in_ttl = batman_ogm_packet->header.ttl; tt_num_changes = batman_ogm_packet->tt_num_changes; - batman_ogm_packet->ttl--; + batman_ogm_packet->header.ttl--; memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); /* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast @@ -494,7 +494,8 @@ static void bat_ogm_forward(struct orig_node *orig_node, batman_ogm_packet->tq = router->tq_avg; if (router->last_ttl) - batman_ogm_packet->ttl = router->last_ttl - 1; + batman_ogm_packet->header.ttl = + router->last_ttl - 1; } tq_avg = router->tq_avg; @@ -510,7 +511,7 @@ static void bat_ogm_forward(struct orig_node *orig_node, "Forwarding packet: tq_orig: %i, tq_avg: %i, " "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n", in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1, - batman_ogm_packet->ttl); + batman_ogm_packet->header.ttl); batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno); batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc); @@ -642,8 +643,8 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv, spin_unlock_bh(&neigh_node->tq_lock); if (!is_duplicate) { - orig_node->last_ttl = batman_ogm_packet->ttl; - neigh_node->last_ttl = batman_ogm_packet->ttl; + orig_node->last_ttl = batman_ogm_packet->header.ttl; + neigh_node->last_ttl = batman_ogm_packet->header.ttl; } bonding_candidate_add(orig_node, neigh_node); @@ -683,7 +684,7 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv, /* I have to check for transtable changes only if the OGM has been * sent through a primary interface */ if (((batman_ogm_packet->orig != ethhdr->h_source) && - (batman_ogm_packet->ttl > 2)) || + (batman_ogm_packet->header.ttl > 2)) || (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) tt_update_orig(bat_priv, orig_node, tt_buff, batman_ogm_packet->tt_num_changes, @@ -918,7 +919,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, * packet in an aggregation. Here we expect that the padding * is always zero (or not 0x01) */ - if (batman_ogm_packet->packet_type != BAT_OGM) + if (batman_ogm_packet->header.packet_type != BAT_OGM) return; /* could be changed by schedule_own_packet() */ @@ -938,8 +939,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, batman_ogm_packet->prev_sender, batman_ogm_packet->seqno, batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc, batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, - batman_ogm_packet->ttl, batman_ogm_packet->version, - has_directlink_flag); + batman_ogm_packet->header.ttl, + batman_ogm_packet->header.version, has_directlink_flag); rcu_read_lock(); list_for_each_entry_rcu(hard_iface, &hardif_list, list) { @@ -966,10 +967,10 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, } rcu_read_unlock(); - if (batman_ogm_packet->version != COMPAT_VERSION) { + if (batman_ogm_packet->header.version != COMPAT_VERSION) { bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: incompatible batman version (%i)\n", - batman_ogm_packet->version); + batman_ogm_packet->header.version); return; } @@ -1091,7 +1092,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, if (is_bidirectional && (!is_duplicate || ((orig_node->last_real_seqno == batman_ogm_packet->seqno) && - (orig_node->last_ttl - 3 <= batman_ogm_packet->ttl)))) + (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) bat_ogm_orig_update(bat_priv, orig_node, ethhdr, batman_ogm_packet, if_incoming, tt_buff, is_duplicate); diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 7704df468e0b..d3e0e32e51c6 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -590,17 +590,17 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, batman_ogm_packet = (struct batman_ogm_packet *)skb->data; - if (batman_ogm_packet->version != COMPAT_VERSION) { + if (batman_ogm_packet->header.version != COMPAT_VERSION) { bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: incompatible batman version (%i)\n", - batman_ogm_packet->version); + batman_ogm_packet->header.version); goto err_free; } /* all receive handlers return whether they received or reused * the supplied skb. if not, we have to free the skb. */ - switch (batman_ogm_packet->packet_type) { + switch (batman_ogm_packet->header.packet_type) { /* batman originator packet */ case BAT_OGM: ret = recv_bat_ogm_packet(skb, hard_iface); diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index d9c1e7bb7fbf..5d69e103faa1 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -191,7 +191,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, goto free_skb; } - if (icmp_packet->packet_type != BAT_ICMP) { + if (icmp_packet->header.packet_type != BAT_ICMP) { bat_dbg(DBG_BATMAN, bat_priv, "Error - can't send packet from char device: " "got bogus packet type (expected: BAT_ICMP)\n"); @@ -209,9 +209,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, icmp_packet->uid = socket_client->index; - if (icmp_packet->version != COMPAT_VERSION) { + if (icmp_packet->header.version != COMPAT_VERSION) { icmp_packet->msg_type = PARAMETER_PROBLEM; - icmp_packet->version = COMPAT_VERSION; + icmp_packet->header.version = COMPAT_VERSION; bat_socket_add_packet(socket_client, icmp_packet, packet_len); goto free_skb; } diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 4d9e54c57a36..88c717b9344d 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -90,10 +90,14 @@ enum tt_client_flags { TT_CLIENT_PENDING = 1 << 10 }; -struct batman_ogm_packet { +struct batman_header { uint8_t packet_type; uint8_t version; /* batman version field */ uint8_t ttl; +} __packed; + +struct batman_ogm_packet { + struct batman_header header; uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ uint32_t seqno; uint8_t orig[6]; @@ -108,9 +112,7 @@ struct batman_ogm_packet { #define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet) struct icmp_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batman_header header; uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[6]; uint8_t orig[6]; @@ -124,9 +126,7 @@ struct icmp_packet { /* icmp_packet_rr must start with all fields from imcp_packet * as this is assumed by code that handles ICMP packets */ struct icmp_packet_rr { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batman_header header; uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[6]; uint8_t orig[6]; @@ -137,17 +137,13 @@ struct icmp_packet_rr { } __packed; struct unicast_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batman_header header; uint8_t ttvn; /* destination translation table version number */ uint8_t dest[6]; } __packed; struct unicast_frag_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batman_header header; uint8_t ttvn; /* destination translation table version number */ uint8_t dest[6]; uint8_t flags; @@ -157,18 +153,14 @@ struct unicast_frag_packet { } __packed; struct bcast_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batman_header header; uint8_t reserved; uint32_t seqno; uint8_t orig[6]; } __packed; struct vis_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; /* TTL */ + struct batman_header header; uint8_t vis_type; /* which type of vis-participant sent this? */ uint32_t seqno; /* sequence number */ uint8_t entries; /* number of entries behind this struct */ @@ -179,9 +171,7 @@ struct vis_packet { } __packed; struct tt_query_packet { - uint8_t packet_type; - uint8_t version; /* batman version field */ - uint8_t ttl; + struct batman_header header; /* the flag field is a combination of: * - TT_REQUEST or TT_RESPONSE * - TT_FULL_TABLE */ @@ -202,9 +192,7 @@ struct tt_query_packet { } __packed; struct roam_adv_packet { - uint8_t packet_type; - uint8_t version; - uint8_t ttl; + struct batman_header header; uint8_t reserved; uint8_t dst[ETH_ALEN]; uint8_t src[ETH_ALEN]; diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 773e606f9702..4363d197aebc 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -320,7 +320,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); icmp_packet->msg_type = ECHO_REPLY; - icmp_packet->ttl = TTL; + icmp_packet->header.ttl = TTL; send_skb_packet(skb, router->if_incoming, router->addr); ret = NET_RX_SUCCESS; @@ -376,7 +376,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); icmp_packet->msg_type = TTL_EXCEEDED; - icmp_packet->ttl = TTL; + icmp_packet->header.ttl = TTL; send_skb_packet(skb, router->if_incoming, router->addr); ret = NET_RX_SUCCESS; @@ -441,7 +441,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) return recv_my_icmp_packet(bat_priv, skb, hdr_size); /* TTL exceeded */ - if (icmp_packet->ttl < 2) + if (icmp_packet->header.ttl < 2) return recv_icmp_ttl_exceeded(bat_priv, skb); /* get routing information */ @@ -460,7 +460,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) icmp_packet = (struct icmp_packet_rr *)skb->data; /* decrement ttl */ - icmp_packet->ttl--; + icmp_packet->header.ttl--; /* route it */ send_skb_packet(skb, router->if_incoming, router->addr); @@ -815,7 +815,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) unicast_packet = (struct unicast_packet *)skb->data; /* TTL exceeded */ - if (unicast_packet->ttl < 2) { + if (unicast_packet->header.ttl < 2) { pr_debug("Warning - can't forward unicast packet from %pM to " "%pM: ttl exceeded\n", ethhdr->h_source, unicast_packet->dest); @@ -840,7 +840,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) unicast_packet = (struct unicast_packet *)skb->data; - if (unicast_packet->packet_type == BAT_UNICAST && + if (unicast_packet->header.packet_type == BAT_UNICAST && atomic_read(&bat_priv->fragmentation) && skb->len > neigh_node->if_incoming->net_dev->mtu) { ret = frag_send_skb(skb, bat_priv, @@ -848,7 +848,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) goto out; } - if (unicast_packet->packet_type == BAT_UNICAST_FRAG && + if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) { ret = frag_reassemble_skb(skb, bat_priv, &new_skb); @@ -867,7 +867,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) } /* decrement ttl */ - unicast_packet->ttl--; + unicast_packet->header.ttl--; /* route it */ send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); @@ -1041,7 +1041,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) if (is_my_mac(bcast_packet->orig)) goto out; - if (bcast_packet->ttl < 2) + if (bcast_packet->header.ttl < 2) goto out; orig_node = orig_hash_find(bat_priv, bcast_packet->orig); diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 8a684eb738ad..b00a0f537b4e 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -234,7 +234,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv, /* as we have a copy now, it is safe to decrease the TTL */ bcast_packet = (struct bcast_packet *)newskb->data; - bcast_packet->ttl--; + bcast_packet->header.ttl--; skb_reset_mac_header(newskb); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 987c75a775f9..bd8c7cfaeacf 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -457,10 +457,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev, batman_ogm_packet = (struct batman_ogm_packet *) (skb->data + ETH_HLEN); - if (batman_ogm_packet->version != COMPAT_VERSION) + if (batman_ogm_packet->header.version != COMPAT_VERSION) goto out; - if (batman_ogm_packet->packet_type != BAT_OGM) + if (batman_ogm_packet->header.packet_type != BAT_OGM) goto out; if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) @@ -632,11 +632,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) goto dropped; bcast_packet = (struct bcast_packet *)skb->data; - bcast_packet->version = COMPAT_VERSION; - bcast_packet->ttl = TTL; + bcast_packet->header.version = COMPAT_VERSION; + bcast_packet->header.ttl = TTL; /* batman packet type: broadcast */ - bcast_packet->packet_type = BAT_BCAST; + bcast_packet->header.packet_type = BAT_BCAST; /* hw address of first interface is the orig mac because only * this mac is known throughout the mesh */ @@ -725,8 +725,8 @@ void interface_rx(struct net_device *soft_iface, skb_push(skb, hdr_size); unicast_packet = (struct unicast_packet *)skb->data; - if ((unicast_packet->packet_type != BAT_UNICAST) && - (unicast_packet->packet_type != BAT_UNICAST_FRAG)) + if ((unicast_packet->header.packet_type != BAT_UNICAST) && + (unicast_packet->header.packet_type != BAT_UNICAST_FRAG)) goto dropped; skb_reset_mac_header(skb); diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index c632475df375..bc518fca0b69 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1135,11 +1135,11 @@ static int send_tt_request(struct bat_priv *bat_priv, tt_request = (struct tt_query_packet *)skb_put(skb, sizeof(struct tt_query_packet)); - tt_request->packet_type = BAT_TT_QUERY; - tt_request->version = COMPAT_VERSION; + tt_request->header.packet_type = BAT_TT_QUERY; + tt_request->header.version = COMPAT_VERSION; memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); - tt_request->ttl = TTL; + tt_request->header.ttl = TTL; tt_request->ttvn = ttvn; tt_request->tt_data = tt_crc; tt_request->flags = TT_REQUEST; @@ -1265,9 +1265,9 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, tt_response = (struct tt_query_packet *)skb->data; } - tt_response->packet_type = BAT_TT_QUERY; - tt_response->version = COMPAT_VERSION; - tt_response->ttl = TTL; + tt_response->header.packet_type = BAT_TT_QUERY; + tt_response->header.version = COMPAT_VERSION; + tt_response->header.ttl = TTL; memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); tt_response->flags = TT_RESPONSE; @@ -1382,9 +1382,9 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, tt_response = (struct tt_query_packet *)skb->data; } - tt_response->packet_type = BAT_TT_QUERY; - tt_response->version = COMPAT_VERSION; - tt_response->ttl = TTL; + tt_response->header.packet_type = BAT_TT_QUERY; + tt_response->header.version = COMPAT_VERSION; + tt_response->header.ttl = TTL; memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(tt_response->dst, tt_request->src, ETH_ALEN); tt_response->flags = TT_RESPONSE; @@ -1671,9 +1671,9 @@ void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, sizeof(struct roam_adv_packet)); - roam_adv_packet->packet_type = BAT_ROAM_ADV; - roam_adv_packet->version = COMPAT_VERSION; - roam_adv_packet->ttl = TTL; + roam_adv_packet->header.packet_type = BAT_ROAM_ADV; + roam_adv_packet->header.version = COMPAT_VERSION; + roam_adv_packet->header.ttl = TTL; primary_if = primary_if_get_selected(bat_priv); if (!primary_if) goto out; diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 07d1c1da89dd..6f3c65952f53 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c @@ -67,7 +67,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, memmove(skb->data + uni_diff, skb->data, hdr_len); unicast_packet = (struct unicast_packet *) skb_pull(skb, uni_diff); - unicast_packet->packet_type = BAT_UNICAST; + unicast_packet->header.packet_type = BAT_UNICAST; return skb; @@ -251,9 +251,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); - frag1->ttl--; - frag1->version = COMPAT_VERSION; - frag1->packet_type = BAT_UNICAST_FRAG; + frag1->header.ttl--; + frag1->header.version = COMPAT_VERSION; + frag1->header.packet_type = BAT_UNICAST_FRAG; memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); memcpy(frag2, frag1, sizeof(*frag2)); @@ -320,11 +320,11 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) unicast_packet = (struct unicast_packet *)skb->data; - unicast_packet->version = COMPAT_VERSION; + unicast_packet->header.version = COMPAT_VERSION; /* batman packet type: unicast */ - unicast_packet->packet_type = BAT_UNICAST; + unicast_packet->header.packet_type = BAT_UNICAST; /* set unicast ttl */ - unicast_packet->ttl = TTL; + unicast_packet->header.ttl = TTL; /* copy the destination for faster routing */ memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); /* set the destination tt version number */ @@ -335,7 +335,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) data_len + sizeof(*unicast_packet) > neigh_node->if_incoming->net_dev->mtu) { /* send frag skb decreases ttl */ - unicast_packet->ttl++; + unicast_packet->header.ttl++; ret = frag_send_skb(skb, bat_priv, neigh_node->if_incoming, neigh_node->addr); goto out; diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index cc3b9f2f3b5d..ac7e66100590 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c @@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) packet->vis_type = atomic_read(&bat_priv->vis_mode); memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); - packet->ttl = TTL; + packet->header.ttl = TTL; packet->seqno = htonl(ntohl(packet->seqno) + 1); packet->entries = 0; skb_trim(info->skb_packet, sizeof(*packet)); @@ -818,19 +818,19 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) goto out; packet = (struct vis_packet *)info->skb_packet->data; - if (packet->ttl < 2) { + if (packet->header.ttl < 2) { pr_debug("Error - can't send vis packet: ttl exceeded\n"); goto out; } memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN); - packet->ttl--; + packet->header.ttl--; if (is_broadcast_ether_addr(packet->target_orig)) broadcast_vis_packet(bat_priv, info); else unicast_vis_packet(bat_priv, info); - packet->ttl++; /* restore TTL */ + packet->header.ttl++; /* restore TTL */ out: if (primary_if) @@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv) INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); kref_init(&bat_priv->my_vis_info->refcount); bat_priv->my_vis_info->bat_priv = bat_priv; - packet->version = COMPAT_VERSION; - packet->packet_type = BAT_VIS; - packet->ttl = TTL; + packet->header.version = COMPAT_VERSION; + packet->header.packet_type = BAT_VIS; + packet->header.ttl = TTL; packet->seqno = 0; packet->entries = 0; -- GitLab From 8780dad9e97f564da0eb3443009c3203122e7e7d Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Mon, 5 Dec 2011 04:01:51 +0800 Subject: [PATCH 0804/1846] batman-adv: simplify bat_ogm_receive API call Most of the values in that call are derived from the skb, so we can hand over the skb instead. Reported-by: Simon Wunderlich Signed-off-by: Marek Lindner --- net/batman-adv/bat_iv_ogm.c | 11 +++++++---- net/batman-adv/bat_ogm.h | 3 +-- net/batman-adv/routing.c | 4 +--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index d60e1ba0bc15..3402fa575b47 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -1140,13 +1140,16 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, orig_node_free_ref(orig_node); } -void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff, - int packet_len, struct hard_iface *if_incoming) +void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb) { struct batman_ogm_packet *batman_ogm_packet; - int buff_pos = 0; - unsigned char *tt_buff; + struct ethhdr *ethhdr; + int buff_pos = 0, packet_len; + unsigned char *tt_buff, *packet_buff; + packet_len = skb_headlen(skb); + ethhdr = (struct ethhdr *)skb_mac_header(skb); + packet_buff = skb->data; batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; /* unpack the aggregated packets and process them one by one */ diff --git a/net/batman-adv/bat_ogm.h b/net/batman-adv/bat_ogm.h index 69329c107e28..47edfde6f924 100644 --- a/net/batman-adv/bat_ogm.h +++ b/net/batman-adv/bat_ogm.h @@ -29,7 +29,6 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface); void bat_ogm_update_mac(struct hard_iface *hard_iface); void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes); void bat_ogm_emit(struct forw_packet *forw_packet); -void bat_ogm_receive(const struct ethhdr *ethhdr, unsigned char *packet_buff, - int packet_len, struct hard_iface *if_incoming); +void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb); #endif /* _NET_BATMAN_ADV_OGM_H_ */ diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 4363d197aebc..5bc41c896e35 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -272,9 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface) if (skb_linearize(skb) < 0) return NET_RX_DROP; - ethhdr = (struct ethhdr *)skb_mac_header(skb); - - bat_ogm_receive(ethhdr, skb->data, skb_headlen(skb), hard_iface); + bat_ogm_receive(hard_iface, skb); kfree_skb(skb); return NET_RX_SUCCESS; -- GitLab From c51f9c09fabc96f23e449b5e39b1fc4e2cabcd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= Date: Thu, 8 Dec 2011 12:48:26 +0100 Subject: [PATCH 0805/1846] batman-adv: Rm empty line from is_my_mac() in main.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Hundebøll Signed-off-by: Marek Lindner --- net/batman-adv/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index fb87bdc2ce9b..71b56cf9cdd6 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -170,7 +170,6 @@ int is_my_mac(const uint8_t *addr) } rcu_read_unlock(); return 0; - } module_init(batman_init); -- GitLab From a04ccd5970ec11f0b320971051435d86d3233c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= Date: Thu, 8 Dec 2011 13:32:41 +0100 Subject: [PATCH 0806/1846] batman-adv: Move is_out_of_time() to main.h for general use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both translation tables and network coding use timeouts to do house keeping, so we might as well share the function used to compare a timestamp+timeout with current time. For readability and simplicity, the function is renamed to has_timed_out() and uses time_is_before_jiffies() instead of time_after(). Signed-off-by: Martin Hundebøll Signed-off-by: Marek Lindner --- net/batman-adv/main.h | 11 ++++++++++ net/batman-adv/translation-table.c | 32 +++++++++++------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 86354e06eb48..f9c659b3f3a9 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -202,6 +202,17 @@ static inline int compare_eth(const void *data1, const void *data2) return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); } +/** + * has_timed_out - compares current time (jiffies) and timestamp + timeout + * @timestamp: base value to compare with (in jiffies) + * @timeout: added to base value before comparing (in milliseconds) + * + * Returns true if current time is after timestamp + timeout + */ +static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) +{ + return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout)); +} #define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index bc518fca0b69..a84e80409f9b 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -108,14 +108,6 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, } -static bool is_out_of_time(unsigned long starting_time, unsigned long timeout) -{ - unsigned long deadline; - deadline = starting_time + msecs_to_jiffies(timeout); - - return time_after(jiffies, deadline); -} - static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) { if (atomic_dec_and_test(&tt_local_entry->common.refcount)) @@ -420,8 +412,8 @@ static void tt_local_purge(struct bat_priv *bat_priv) if (tt_local_entry->common.flags & TT_CLIENT_PENDING) continue; - if (!is_out_of_time(tt_local_entry->last_seen, - TT_LOCAL_TIMEOUT * 1000)) + if (!has_timed_out(tt_local_entry->last_seen, + TT_LOCAL_TIMEOUT * 1000)) continue; tt_local_set_pending(bat_priv, tt_local_entry, @@ -758,8 +750,8 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) common); if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) continue; - if (!is_out_of_time(tt_global_entry->roam_at, - TT_CLIENT_ROAM_TIMEOUT * 1000)) + if (!has_timed_out(tt_global_entry->roam_at, + TT_CLIENT_ROAM_TIMEOUT * 1000)) continue; bat_dbg(DBG_TT, bat_priv, "Deleting global " @@ -978,8 +970,8 @@ static void tt_req_purge(struct bat_priv *bat_priv) spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { - if (is_out_of_time(node->issued_at, - TT_REQUEST_TIMEOUT * 1000)) { + if (has_timed_out(node->issued_at, + TT_REQUEST_TIMEOUT * 1000)) { list_del(&node->list); kfree(node); } @@ -997,8 +989,8 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { if (compare_eth(tt_req_node_tmp, orig_node) && - !is_out_of_time(tt_req_node_tmp->issued_at, - TT_REQUEST_TIMEOUT * 1000)) + !has_timed_out(tt_req_node_tmp->issued_at, + TT_REQUEST_TIMEOUT * 1000)) goto unlock; } @@ -1591,8 +1583,8 @@ static void tt_roam_purge(struct bat_priv *bat_priv) spin_lock_bh(&bat_priv->tt_roam_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { - if (!is_out_of_time(node->first_time, - ROAMING_MAX_TIME * 1000)) + if (!has_timed_out(node->first_time, + ROAMING_MAX_TIME * 1000)) continue; list_del(&node->list); @@ -1619,8 +1611,8 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv, if (!compare_eth(tt_roam_node->addr, client)) continue; - if (is_out_of_time(tt_roam_node->first_time, - ROAMING_MAX_TIME * 1000)) + if (has_timed_out(tt_roam_node->first_time, + ROAMING_MAX_TIME * 1000)) continue; if (!atomic_dec_not_zero(&tt_roam_node->counter)) -- GitLab From 6e242f9037f8a82ce2608c20a5460b670b2d5ff4 Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Wed, 7 Dec 2011 18:02:50 +0800 Subject: [PATCH 0807/1846] batman-adv: warn if added interface is part of a bridge Signed-off-by: Marek Lindner --- net/batman-adv/hard-interface.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index d3e0e32e51c6..68b667c1d85e 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -281,6 +281,14 @@ int hardif_enable_interface(struct hard_iface *hard_iface, if (!atomic_inc_not_zero(&hard_iface->refcount)) goto out; + /* hard-interface is part of a bridge */ + if (hard_iface->net_dev->priv_flags & IFF_BRIDGE_PORT) + pr_err("You are about to enable batman-adv on '%s' which " + "already is part of a bridge. Unless you know exactly " + "what you are doing this is probably wrong and won't " + "work the way you think it would.\n", + hard_iface->net_dev->name); + soft_iface = dev_get_by_name(&init_net, iface_name); if (!soft_iface) { -- GitLab From 1c280471b013e26c833fc86acc231c73442cfa21 Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Mon, 28 Nov 2011 17:40:17 +0800 Subject: [PATCH 0808/1846] batman-adv: add infrastructure to change routing algorithm at runtime Signed-off-by: Marek Lindner --- net/batman-adv/bat_algo.h | 27 +++++++++++++ net/batman-adv/bat_debugfs.c | 22 ++++++++++ net/batman-adv/bat_iv_ogm.c | 10 +++++ net/batman-adv/main.c | 72 +++++++++++++++++++++++++++++++++ net/batman-adv/main.h | 4 ++ net/batman-adv/soft-interface.c | 4 ++ net/batman-adv/types.h | 6 +++ 7 files changed, 145 insertions(+) create mode 100644 net/batman-adv/bat_algo.h diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h new file mode 100644 index 000000000000..755379fd367d --- /dev/null +++ b/net/batman-adv/bat_algo.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2011 B.A.T.M.A.N. contributors: + * + * Marek Lindner + * + * 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-1301, USA + * + */ + +#ifndef _NET_BATMAN_ADV_BAT_ALGO_H_ +#define _NET_BATMAN_ADV_BAT_ALGO_H_ + +int bat_iv_init(void); + +#endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */ diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c index d0af9bf69e46..a7a393eeb935 100644 --- a/net/batman-adv/bat_debugfs.c +++ b/net/batman-adv/bat_debugfs.c @@ -221,6 +221,11 @@ static void debug_log_cleanup(struct bat_priv *bat_priv) } #endif +static int bat_algorithms_open(struct inode *inode, struct file *file) +{ + return single_open(file, bat_algo_seq_print_text, NULL); +} + static int originators_open(struct inode *inode, struct file *file) { struct net_device *net_dev = (struct net_device *)inode->i_private; @@ -274,6 +279,7 @@ struct bat_debuginfo bat_debuginfo_##_name = { \ } \ }; +static BAT_DEBUGINFO(routing_algos, S_IRUGO, bat_algorithms_open); static BAT_DEBUGINFO(originators, S_IRUGO, originators_open); static BAT_DEBUGINFO(gateways, S_IRUGO, gateways_open); static BAT_DEBUGINFO(softif_neigh, S_IRUGO, softif_neigh_open); @@ -293,9 +299,25 @@ static struct bat_debuginfo *mesh_debuginfos[] = { void debugfs_init(void) { + struct bat_debuginfo *bat_debug; + struct dentry *file; + bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); if (bat_debugfs == ERR_PTR(-ENODEV)) bat_debugfs = NULL; + + if (!bat_debugfs) + goto out; + + bat_debug = &bat_debuginfo_routing_algos; + file = debugfs_create_file(bat_debug->attr.name, + S_IFREG | bat_debug->attr.mode, + bat_debugfs, NULL, &bat_debug->fops); + if (!file) + pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); + +out: + return; } void debugfs_destroy(void) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 3402fa575b47..1847efaaa6fd 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -29,6 +29,7 @@ #include "gateway_client.h" #include "hard-interface.h" #include "send.h" +#include "bat_algo.h" void bat_ogm_init(struct hard_iface *hard_iface) { @@ -1172,3 +1173,12 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb) } while (bat_ogm_aggr_packet(buff_pos, packet_len, batman_ogm_packet->tt_num_changes)); } + +static struct bat_algo_ops batman_iv __read_mostly = { + .name = "BATMAN IV", +}; + +int __init bat_iv_init(void) +{ + return bat_algo_register(&batman_iv); +} diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 71b56cf9cdd6..7c87a341f29f 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -32,11 +32,14 @@ #include "gateway_client.h" #include "vis.h" #include "hash.h" +#include "bat_algo.h" /* List manipulations on hardif_list have to be rtnl_lock()'ed, * list traversals just rcu-locked */ struct list_head hardif_list; +char bat_routing_algo[20] = "BATMAN IV"; +static struct hlist_head bat_algo_list; unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -45,6 +48,9 @@ struct workqueue_struct *bat_event_workqueue; static int __init batman_init(void) { INIT_LIST_HEAD(&hardif_list); + INIT_HLIST_HEAD(&bat_algo_list); + + bat_iv_init(); /* the name should not be longer than 10 chars - see * http://lwn.net/Articles/23634/ */ @@ -172,6 +178,72 @@ int is_my_mac(const uint8_t *addr) return 0; } +static struct bat_algo_ops *bat_algo_get(char *name) +{ + struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; + struct hlist_node *node; + + hlist_for_each_entry(bat_algo_ops_tmp, node, &bat_algo_list, list) { + if (strcmp(bat_algo_ops_tmp->name, name) != 0) + continue; + + bat_algo_ops = bat_algo_ops_tmp; + break; + } + + return bat_algo_ops; +} + +int bat_algo_register(struct bat_algo_ops *bat_algo_ops) +{ + struct bat_algo_ops *bat_algo_ops_tmp; + int ret = -1; + + bat_algo_ops_tmp = bat_algo_get(bat_algo_ops->name); + if (bat_algo_ops_tmp) { + pr_info("Trying to register already registered routing " + "algorithm: %s\n", bat_algo_ops->name); + goto out; + } + + INIT_HLIST_NODE(&bat_algo_ops->list); + hlist_add_head(&bat_algo_ops->list, &bat_algo_list); + ret = 0; + +out: + return ret; +} + +int bat_algo_select(struct bat_priv *bat_priv, char *name) +{ + struct bat_algo_ops *bat_algo_ops; + int ret = -1; + + bat_algo_ops = bat_algo_get(name); + if (!bat_algo_ops) + goto out; + + bat_priv->bat_algo_ops = bat_algo_ops; + ret = 0; + +out: + return ret; +} + +int bat_algo_seq_print_text(struct seq_file *seq, void *offset) +{ + struct bat_algo_ops *bat_algo_ops; + struct hlist_node *node; + + seq_printf(seq, "Available routing algorithms:\n"); + + hlist_for_each_entry(bat_algo_ops, node, &bat_algo_list, list) { + seq_printf(seq, "%s\n", bat_algo_ops->name); + } + + return 0; +} + module_init(batman_init); module_exit(batman_exit); diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index f9c659b3f3a9..586afafb1b67 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -147,6 +147,7 @@ enum dbg_level { #include #include "types.h" +extern char bat_routing_algo[]; extern struct list_head hardif_list; extern unsigned char broadcast_addr[]; @@ -157,6 +158,9 @@ void mesh_free(struct net_device *soft_iface); void inc_module_count(void); void dec_module_count(void); int is_my_mac(const uint8_t *addr); +int bat_algo_register(struct bat_algo_ops *bat_algo_ops); +int bat_algo_select(struct bat_priv *bat_priv, char *name); +int bat_algo_seq_print_text(struct seq_file *seq, void *offset); #ifdef CONFIG_BATMAN_ADV_DEBUG int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index bd8c7cfaeacf..b5aecd5e45cc 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -855,6 +855,10 @@ struct net_device *softif_create(const char *name) bat_priv->primary_if = NULL; bat_priv->num_ifaces = 0; + ret = bat_algo_select(bat_priv, bat_routing_algo); + if (ret < 0) + goto unreg_soft_iface; + ret = sysfs_add_meshif(soft_iface); if (ret < 0) goto unreg_soft_iface; diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 35085f410b96..d21ff2cf668e 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -206,6 +206,7 @@ struct bat_priv { atomic_t gw_reselect; struct hard_iface __rcu *primary_if; /* rcu protected pointer */ struct vis_info *my_vis_info; + struct bat_algo_ops *bat_algo_ops; }; struct socket_client { @@ -344,4 +345,9 @@ struct softif_neigh { struct rcu_head rcu; }; +struct bat_algo_ops { + struct hlist_node list; + char *name; +}; + #endif /* _NET_BATMAN_ADV_TYPES_H_ */ -- GitLab From 01c4224b51feba2ba64d070ab9f4aa32c9d0bb29 Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Mon, 28 Nov 2011 21:31:55 +0800 Subject: [PATCH 0809/1846] batman-adv: convert batman iv algorithm to use dynamic infrastructure Signed-off-by: Marek Lindner --- net/batman-adv/bat_iv_ogm.c | 179 +++++++++++++++++--------------- net/batman-adv/bat_ogm.h | 34 ------ net/batman-adv/hard-interface.c | 10 +- net/batman-adv/main.c | 12 +++ net/batman-adv/routing.c | 4 +- net/batman-adv/send.c | 5 +- net/batman-adv/types.h | 14 +++ 7 files changed, 129 insertions(+), 129 deletions(-) delete mode 100644 net/batman-adv/bat_ogm.h diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 1847efaaa6fd..1c483a5dd808 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -20,7 +20,6 @@ */ #include "main.h" -#include "bat_ogm.h" #include "translation-table.h" #include "ring_buffer.h" #include "originator.h" @@ -31,7 +30,7 @@ #include "send.h" #include "bat_algo.h" -void bat_ogm_init(struct hard_iface *hard_iface) +static void bat_iv_ogm_init(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; @@ -48,7 +47,7 @@ void bat_ogm_init(struct hard_iface *hard_iface) batman_ogm_packet->ttvn = 0; } -void bat_ogm_init_primary(struct hard_iface *hard_iface) +static void bat_iv_ogm_init_primary(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; @@ -57,7 +56,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface) batman_ogm_packet->header.ttl = TTL; } -void bat_ogm_update_mac(struct hard_iface *hard_iface) +static void bat_iv_ogm_update_mac(struct hard_iface *hard_iface) { struct batman_ogm_packet *batman_ogm_packet; @@ -69,7 +68,7 @@ void bat_ogm_update_mac(struct hard_iface *hard_iface) } /* when do we schedule our own ogm to be sent */ -static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv) +static unsigned long bat_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) { return jiffies + msecs_to_jiffies( atomic_read(&bat_priv->orig_interval) - @@ -77,7 +76,7 @@ static unsigned long bat_ogm_emit_send_time(const struct bat_priv *bat_priv) } /* when do we schedule a ogm packet to be sent */ -static unsigned long bat_ogm_fwd_send_time(void) +static unsigned long bat_iv_ogm_fwd_send_time(void) { return jiffies + msecs_to_jiffies(random32() % (JITTER/2)); } @@ -90,8 +89,8 @@ static uint8_t hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) } /* is there another aggregated packet here? */ -static int bat_ogm_aggr_packet(int buff_pos, int packet_len, - int tt_num_changes) +static int bat_iv_ogm_aggr_packet(int buff_pos, int packet_len, + int tt_num_changes) { int next_buff_pos = buff_pos + BATMAN_OGM_LEN + tt_len(tt_num_changes); @@ -100,8 +99,8 @@ static int bat_ogm_aggr_packet(int buff_pos, int packet_len, } /* send a batman ogm to a given interface */ -static void bat_ogm_send_to_if(struct forw_packet *forw_packet, - struct hard_iface *hard_iface) +static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, + struct hard_iface *hard_iface) { struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); char *fwd_str; @@ -118,8 +117,8 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet, batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; /* adjust all flags and log packets */ - while (bat_ogm_aggr_packet(buff_pos, forw_packet->packet_len, - batman_ogm_packet->tt_num_changes)) { + while (bat_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, + batman_ogm_packet->tt_num_changes)) { /* we might have aggregated direct link packets with an * ordinary base packet */ @@ -158,7 +157,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet, } /* send a batman ogm packet */ -void bat_ogm_emit(struct forw_packet *forw_packet) +static void bat_iv_ogm_emit(struct forw_packet *forw_packet) { struct hard_iface *hard_iface; struct net_device *soft_iface; @@ -217,7 +216,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet) if (hard_iface->soft_iface != soft_iface) continue; - bat_ogm_send_to_if(forw_packet, hard_iface); + bat_iv_ogm_send_to_if(forw_packet, hard_iface); } rcu_read_unlock(); @@ -227,13 +226,13 @@ void bat_ogm_emit(struct forw_packet *forw_packet) } /* return true if new_packet can be aggregated with forw_packet */ -static bool bat_ogm_can_aggregate(const struct batman_ogm_packet +static bool bat_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_batman_ogm_packet, - struct bat_priv *bat_priv, - int packet_len, unsigned long send_time, - bool directlink, - const struct hard_iface *if_incoming, - const struct forw_packet *forw_packet) + struct bat_priv *bat_priv, + int packet_len, unsigned long send_time, + bool directlink, + const struct hard_iface *if_incoming, + const struct forw_packet *forw_packet) { struct batman_ogm_packet *batman_ogm_packet; int aggregated_bytes = forw_packet->packet_len + packet_len; @@ -307,11 +306,11 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet } /* create a new aggregated packet and add this packet to it */ -static void bat_ogm_aggregate_new(const unsigned char *packet_buff, - int packet_len, unsigned long send_time, - bool direct_link, - struct hard_iface *if_incoming, - int own_packet) +static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff, + int packet_len, unsigned long send_time, + bool direct_link, + struct hard_iface *if_incoming, + int own_packet) { struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct forw_packet *forw_packet_aggr; @@ -386,9 +385,9 @@ static void bat_ogm_aggregate_new(const unsigned char *packet_buff, } /* aggregate a new packet into the existing ogm packet */ -static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr, - const unsigned char *packet_buff, - int packet_len, bool direct_link) +static void bat_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr, + const unsigned char *packet_buff, + int packet_len, bool direct_link) { unsigned char *skb_buff; @@ -403,10 +402,10 @@ static void bat_ogm_aggregate(struct forw_packet *forw_packet_aggr, (1 << forw_packet_aggr->num_packets); } -static void bat_ogm_queue_add(struct bat_priv *bat_priv, - unsigned char *packet_buff, - int packet_len, struct hard_iface *if_incoming, - int own_packet, unsigned long send_time) +static void bat_iv_ogm_queue_add(struct bat_priv *bat_priv, + unsigned char *packet_buff, + int packet_len, struct hard_iface *if_incoming, + int own_packet, unsigned long send_time) { /** * _aggr -> pointer to the packet we want to aggregate with @@ -426,11 +425,11 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv, if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { hlist_for_each_entry(forw_packet_pos, tmp_node, &bat_priv->forw_bat_list, list) { - if (bat_ogm_can_aggregate(batman_ogm_packet, - bat_priv, packet_len, - send_time, direct_link, - if_incoming, - forw_packet_pos)) { + if (bat_iv_ogm_can_aggregate(batman_ogm_packet, + bat_priv, packet_len, + send_time, direct_link, + if_incoming, + forw_packet_pos)) { forw_packet_aggr = forw_packet_pos; break; } @@ -452,20 +451,20 @@ static void bat_ogm_queue_add(struct bat_priv *bat_priv, (atomic_read(&bat_priv->aggregated_ogms))) send_time += msecs_to_jiffies(MAX_AGGREGATION_MS); - bat_ogm_aggregate_new(packet_buff, packet_len, - send_time, direct_link, - if_incoming, own_packet); + bat_iv_ogm_aggregate_new(packet_buff, packet_len, + send_time, direct_link, + if_incoming, own_packet); } else { - bat_ogm_aggregate(forw_packet_aggr, packet_buff, packet_len, - direct_link); + bat_iv_ogm_aggregate(forw_packet_aggr, packet_buff, + packet_len, direct_link); spin_unlock_bh(&bat_priv->forw_bat_list_lock); } } -static void bat_ogm_forward(struct orig_node *orig_node, - const struct ethhdr *ethhdr, - struct batman_ogm_packet *batman_ogm_packet, - int directlink, struct hard_iface *if_incoming) +static void bat_iv_ogm_forward(struct orig_node *orig_node, + const struct ethhdr *ethhdr, + struct batman_ogm_packet *batman_ogm_packet, + int directlink, struct hard_iface *if_incoming) { struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct neigh_node *router; @@ -524,12 +523,13 @@ static void bat_ogm_forward(struct orig_node *orig_node, else batman_ogm_packet->flags &= ~DIRECTLINK; - bat_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, - BATMAN_OGM_LEN + tt_len(tt_num_changes), - if_incoming, 0, bat_ogm_fwd_send_time()); + bat_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, + BATMAN_OGM_LEN + tt_len(tt_num_changes), + if_incoming, 0, bat_iv_ogm_fwd_send_time()); } -void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes) +static void bat_iv_ogm_schedule(struct hard_iface *hard_iface, + int tt_num_changes) { struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct batman_ogm_packet *batman_ogm_packet; @@ -566,21 +566,22 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes) atomic_inc(&hard_iface->seqno); slide_own_bcast_window(hard_iface); - bat_ogm_queue_add(bat_priv, hard_iface->packet_buff, - hard_iface->packet_len, hard_iface, 1, - bat_ogm_emit_send_time(bat_priv)); + bat_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, + hard_iface->packet_len, hard_iface, 1, + bat_iv_ogm_emit_send_time(bat_priv)); if (primary_if) hardif_free_ref(primary_if); } -static void bat_ogm_orig_update(struct bat_priv *bat_priv, - struct orig_node *orig_node, - const struct ethhdr *ethhdr, - const struct batman_ogm_packet +static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, + struct orig_node *orig_node, + const struct ethhdr *ethhdr, + const struct batman_ogm_packet *batman_ogm_packet, - struct hard_iface *if_incoming, - const unsigned char *tt_buff, int is_duplicate) + struct hard_iface *if_incoming, + const unsigned char *tt_buff, + int is_duplicate) { struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; struct neigh_node *router = NULL; @@ -715,10 +716,10 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv, neigh_node_free_ref(router); } -static int bat_ogm_calc_tq(struct orig_node *orig_node, - struct orig_node *orig_neigh_node, - struct batman_ogm_packet *batman_ogm_packet, - struct hard_iface *if_incoming) +static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, + struct orig_node *orig_neigh_node, + struct batman_ogm_packet *batman_ogm_packet, + struct hard_iface *if_incoming) { struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct neigh_node *neigh_node = NULL, *tmp_neigh_node; @@ -827,10 +828,10 @@ static int bat_ogm_calc_tq(struct orig_node *orig_node, * -1 the packet is old and has been received while the seqno window * was protected. Caller should drop it. */ -static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr, - const struct batman_ogm_packet +static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, + const struct batman_ogm_packet *batman_ogm_packet, - const struct hard_iface *if_incoming) + const struct hard_iface *if_incoming) { struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct orig_node *orig_node; @@ -892,10 +893,10 @@ static int bat_ogm_update_seqnos(const struct ethhdr *ethhdr, return ret; } -static void bat_ogm_process(const struct ethhdr *ethhdr, - struct batman_ogm_packet *batman_ogm_packet, - const unsigned char *tt_buff, - struct hard_iface *if_incoming) +static void bat_iv_ogm_process(const struct ethhdr *ethhdr, + struct batman_ogm_packet *batman_ogm_packet, + const unsigned char *tt_buff, + struct hard_iface *if_incoming) { struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); struct hard_iface *hard_iface; @@ -1033,8 +1034,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, if (!orig_node) return; - is_duplicate = bat_ogm_update_seqnos(ethhdr, batman_ogm_packet, - if_incoming); + is_duplicate = bat_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet, + if_incoming); if (is_duplicate == -1) { bat_dbg(DBG_BATMAN, bat_priv, @@ -1083,8 +1084,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, goto out_neigh; } - is_bidirectional = bat_ogm_calc_tq(orig_node, orig_neigh_node, - batman_ogm_packet, if_incoming); + is_bidirectional = bat_iv_ogm_calc_tq(orig_node, orig_neigh_node, + batman_ogm_packet, if_incoming); bonding_save_primary(orig_node, orig_neigh_node, batman_ogm_packet); @@ -1094,16 +1095,16 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, (!is_duplicate || ((orig_node->last_real_seqno == batman_ogm_packet->seqno) && (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) - bat_ogm_orig_update(bat_priv, orig_node, ethhdr, - batman_ogm_packet, if_incoming, - tt_buff, is_duplicate); + bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, + batman_ogm_packet, if_incoming, + tt_buff, is_duplicate); /* is single hop (direct) neighbor */ if (is_single_hop_neigh) { /* mark direct link on incoming interface */ - bat_ogm_forward(orig_node, ethhdr, batman_ogm_packet, - 1, if_incoming); + bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, + 1, if_incoming); bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: " "rebroadcast neighbor packet with direct link flag\n"); @@ -1125,7 +1126,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: rebroadcast originator packet\n"); - bat_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 0, if_incoming); + bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, + 0, if_incoming); out_neigh: if ((orig_neigh_node) && (!is_single_hop_neigh)) @@ -1141,7 +1143,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr, orig_node_free_ref(orig_node); } -void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb) +static void bat_iv_ogm_receive(struct hard_iface *if_incoming, + struct sk_buff *skb) { struct batman_ogm_packet *batman_ogm_packet; struct ethhdr *ethhdr; @@ -1162,20 +1165,26 @@ void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb) tt_buff = packet_buff + buff_pos + BATMAN_OGM_LEN; - bat_ogm_process(ethhdr, batman_ogm_packet, - tt_buff, if_incoming); + bat_iv_ogm_process(ethhdr, batman_ogm_packet, + tt_buff, if_incoming); buff_pos += BATMAN_OGM_LEN + tt_len(batman_ogm_packet->tt_num_changes); batman_ogm_packet = (struct batman_ogm_packet *) (packet_buff + buff_pos); - } while (bat_ogm_aggr_packet(buff_pos, packet_len, - batman_ogm_packet->tt_num_changes)); + } while (bat_iv_ogm_aggr_packet(buff_pos, packet_len, + batman_ogm_packet->tt_num_changes)); } static struct bat_algo_ops batman_iv __read_mostly = { .name = "BATMAN IV", + .bat_ogm_init = bat_iv_ogm_init, + .bat_ogm_init_primary = bat_iv_ogm_init_primary, + .bat_ogm_update_mac = bat_iv_ogm_update_mac, + .bat_ogm_schedule = bat_iv_ogm_schedule, + .bat_ogm_emit = bat_iv_ogm_emit, + .bat_ogm_receive = bat_iv_ogm_receive, }; int __init bat_iv_init(void) diff --git a/net/batman-adv/bat_ogm.h b/net/batman-adv/bat_ogm.h deleted file mode 100644 index 47edfde6f924..000000000000 --- a/net/batman-adv/bat_ogm.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: - * - * Marek Lindner, Simon Wunderlich - * - * 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-1301, USA - * - */ - -#ifndef _NET_BATMAN_ADV_OGM_H_ -#define _NET_BATMAN_ADV_OGM_H_ - -#include "main.h" - -void bat_ogm_init(struct hard_iface *hard_iface); -void bat_ogm_init_primary(struct hard_iface *hard_iface); -void bat_ogm_update_mac(struct hard_iface *hard_iface); -void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes); -void bat_ogm_emit(struct forw_packet *forw_packet); -void bat_ogm_receive(struct hard_iface *if_incoming, struct sk_buff *skb); - -#endif /* _NET_BATMAN_ADV_OGM_H_ */ diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 68b667c1d85e..ff5ba406b1cf 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -28,7 +28,6 @@ #include "bat_sysfs.h" #include "originator.h" #include "hash.h" -#include "bat_ogm.h" #include @@ -147,7 +146,7 @@ static void primary_if_select(struct bat_priv *bat_priv, if (!new_hard_iface) return; - bat_ogm_init_primary(new_hard_iface); + bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface); primary_if_update_addr(bat_priv); } @@ -233,7 +232,7 @@ static void hardif_activate_interface(struct hard_iface *hard_iface) bat_priv = netdev_priv(hard_iface->soft_iface); - bat_ogm_update_mac(hard_iface); + bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface); hard_iface->if_status = IF_TO_BE_ACTIVATED; /** @@ -315,7 +314,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, hard_iface->soft_iface = soft_iface; bat_priv = netdev_priv(hard_iface->soft_iface); - bat_ogm_init(hard_iface); + bat_priv->bat_algo_ops->bat_ogm_init(hard_iface); if (!hard_iface->packet_buff) { bat_err(hard_iface->soft_iface, "Can't add interface packet " @@ -535,9 +534,10 @@ static int hard_if_event(struct notifier_block *this, goto hardif_put; check_known_mac_addr(hard_iface->net_dev); - bat_ogm_update_mac(hard_iface); bat_priv = netdev_priv(hard_iface->soft_iface); + bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface); + primary_if = primary_if_get_selected(bat_priv); if (!primary_if) goto hardif_put; diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 7c87a341f29f..bcc2bddd893a 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -206,6 +206,18 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops) goto out; } + /* all algorithms must implement all ops (for now) */ + if (!bat_algo_ops->bat_ogm_init || + !bat_algo_ops->bat_ogm_init_primary || + !bat_algo_ops->bat_ogm_update_mac || + !bat_algo_ops->bat_ogm_schedule || + !bat_algo_ops->bat_ogm_emit || + !bat_algo_ops->bat_ogm_receive) { + pr_info("Routing algo '%s' does not implement required ops\n", + bat_algo_ops->name); + goto out; + } + INIT_HLIST_NODE(&bat_algo_ops->list); hlist_add_head(&bat_algo_ops->list, &bat_algo_list); ret = 0; diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 5bc41c896e35..b72d7f3b3c6a 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -29,7 +29,6 @@ #include "originator.h" #include "vis.h" #include "unicast.h" -#include "bat_ogm.h" void slide_own_bcast_window(struct hard_iface *hard_iface) { @@ -248,6 +247,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface) { + struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct ethhdr *ethhdr; /* drop packet if it has not necessary minimum size */ @@ -272,7 +272,7 @@ int recv_bat_ogm_packet(struct sk_buff *skb, struct hard_iface *hard_iface) if (skb_linearize(skb) < 0) return NET_RX_DROP; - bat_ogm_receive(hard_iface, skb); + bat_priv->bat_algo_ops->bat_ogm_receive(hard_iface, skb); kfree_skb(skb); return NET_RX_SUCCESS; diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index b00a0f537b4e..019337e3eafb 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -28,7 +28,6 @@ #include "vis.h" #include "gateway_common.h" #include "originator.h" -#include "bat_ogm.h" static void send_outstanding_bcast_packet(struct work_struct *work); @@ -168,7 +167,7 @@ void schedule_bat_ogm(struct hard_iface *hard_iface) if (primary_if) hardif_free_ref(primary_if); - bat_ogm_schedule(hard_iface, tt_num_changes); + bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface, tt_num_changes); } static void forw_packet_free(struct forw_packet *forw_packet) @@ -318,7 +317,7 @@ void send_outstanding_bat_ogm_packet(struct work_struct *work) if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) goto out; - bat_ogm_emit(forw_packet); + bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet); /** * we have to have at least one packet in the queue diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index d21ff2cf668e..650ce5fb1192 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -348,6 +348,20 @@ struct softif_neigh { struct bat_algo_ops { struct hlist_node list; char *name; + /* init OGM when hard-interface is enabled */ + void (*bat_ogm_init)(struct hard_iface *hard_iface); + /* init primary OGM when primary interface is selected */ + void (*bat_ogm_init_primary)(struct hard_iface *hard_iface); + /* init mac addresses of the OGM belonging to this hard-interface */ + void (*bat_ogm_update_mac)(struct hard_iface *hard_iface); + /* prepare a new outgoing OGM for the send queue */ + void (*bat_ogm_schedule)(struct hard_iface *hard_iface, + int tt_num_changes); + /* send scheduled OGM */ + void (*bat_ogm_emit)(struct forw_packet *forw_packet); + /* receive incoming OGM */ + void (*bat_ogm_receive)(struct hard_iface *if_incoming, + struct sk_buff *skb); }; #endif /* _NET_BATMAN_ADV_TYPES_H_ */ -- GitLab From 032b7969f8874d5ddc65691cd3d008beffd2a09e Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Tue, 20 Dec 2011 19:30:40 +0800 Subject: [PATCH 0810/1846] batman-adv: convert time_after instances to has_timed_out To increase readability the has_timed_out() functions has been introduced. This patch converts existing time_after() calls to use this wrapper function (if applicable). This patch also converts all timeouts to miliseconds to be consistent. Signed-off-by: Marek Lindner Signed-off-by: Simon Wunderlich --- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/main.h | 13 +++++++------ net/batman-adv/originator.c | 11 ++++------- net/batman-adv/routing.c | 3 +-- net/batman-adv/soft-interface.c | 4 ++-- net/batman-adv/translation-table.c | 15 ++++++--------- net/batman-adv/vis.c | 3 +-- net/batman-adv/vis.h | 3 ++- 8 files changed, 24 insertions(+), 30 deletions(-) diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 24403a7350f7..df5631e1f2a5 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -396,7 +396,7 @@ void gw_node_purge(struct bat_priv *bat_priv) { struct gw_node *gw_node, *curr_gw; struct hlist_node *node, *node_tmp; - unsigned long timeout = 2 * PURGE_TIMEOUT * HZ; + unsigned long timeout = msecs_to_jiffies(2 * PURGE_TIMEOUT); int do_deselect = 0; curr_gw = gw_get_selected_gw_node(bat_priv); diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 586afafb1b67..ecfed88d0d43 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -41,13 +41,14 @@ /* purge originators after time in seconds if no valid packet comes in * -> TODO: check influence on TQ_LOCAL_WINDOW_SIZE */ -#define PURGE_TIMEOUT 200 -#define TT_LOCAL_TIMEOUT 3600 /* in seconds */ -#define TT_CLIENT_ROAM_TIMEOUT 600 +#define PURGE_TIMEOUT 200000 /* 200 seconds */ +#define TT_LOCAL_TIMEOUT 3600000 /* in miliseconds */ +#define TT_CLIENT_ROAM_TIMEOUT 600000 /* in miliseconds */ /* sliding packet range of received originator messages in sequence numbers * (should be a multiple of our word size) */ #define TQ_LOCAL_WINDOW_SIZE 64 -#define TT_REQUEST_TIMEOUT 3 /* seconds we have to keep pending tt_req */ +#define TT_REQUEST_TIMEOUT 3000 /* miliseconds we have to keep + * pending tt_req */ #define TQ_GLOBAL_WINDOW_SIZE 5 #define TQ_LOCAL_BIDRECT_SEND_MINIMUM 1 @@ -56,8 +57,8 @@ #define TT_OGM_APPEND_MAX 3 /* number of OGMs sent with the last tt diff */ -#define ROAMING_MAX_TIME 20 /* Time in which a client can roam at most - * ROAMING_MAX_COUNT times */ +#define ROAMING_MAX_TIME 20000 /* Time in which a client can roam at most + * ROAMING_MAX_COUNT times in miliseconds*/ #define ROAMING_MAX_COUNT 5 #define NO_FLAGS 0 diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 847ff7e98a61..1161f27ad8cc 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -282,8 +282,7 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, hlist_for_each_entry_safe(neigh_node, node, node_tmp, &orig_node->neigh_list, list) { - if ((time_after(jiffies, - neigh_node->last_valid + PURGE_TIMEOUT * HZ)) || + if ((has_timed_out(neigh_node->last_valid, PURGE_TIMEOUT)) || (neigh_node->if_incoming->if_status == IF_INACTIVE) || (neigh_node->if_incoming->if_status == IF_NOT_IN_USE) || (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) { @@ -327,9 +326,7 @@ static bool purge_orig_node(struct bat_priv *bat_priv, { struct neigh_node *best_neigh_node; - if (time_after(jiffies, - orig_node->last_valid + 2 * PURGE_TIMEOUT * HZ)) { - + if (has_timed_out(orig_node->last_valid, 2 * PURGE_TIMEOUT)) { bat_dbg(DBG_BATMAN, bat_priv, "Originator timeout: originator %pM, last_valid %lu\n", orig_node->orig, (orig_node->last_valid / HZ)); @@ -372,8 +369,8 @@ static void _purge_orig(struct bat_priv *bat_priv) continue; } - if (time_after(jiffies, orig_node->last_frag_packet + - msecs_to_jiffies(FRAG_TIMEOUT))) + if (has_timed_out(orig_node->last_frag_packet, + FRAG_TIMEOUT)) frag_list_free(&orig_node->frag_list); } spin_unlock_bh(list_lock); diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index b72d7f3b3c6a..c1e45c0bb186 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -231,8 +231,7 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, { if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { - if (time_after(jiffies, *last_reset + - msecs_to_jiffies(RESET_PROTECTION_MS))) { + if (has_timed_out(*last_reset, RESET_PROTECTION_MS)) { *last_reset = jiffies; bat_dbg(DBG_BATMAN, bat_priv, diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index b5aecd5e45cc..c41dac3bbf81 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -396,8 +396,8 @@ void softif_neigh_purge(struct bat_priv *bat_priv) hlist_for_each_entry_safe(softif_neigh, node_tmp, node_tmp2, &softif_neigh_vid->softif_neigh_list, list) { - if ((!time_after(jiffies, softif_neigh->last_seen + - msecs_to_jiffies(SOFTIF_NEIGH_TIMEOUT))) && + if ((!has_timed_out(softif_neigh->last_seen, + SOFTIF_NEIGH_TIMEOUT)) && (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE)) continue; diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index a84e80409f9b..ff9a1b33c136 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -413,7 +413,7 @@ static void tt_local_purge(struct bat_priv *bat_priv) continue; if (!has_timed_out(tt_local_entry->last_seen, - TT_LOCAL_TIMEOUT * 1000)) + TT_LOCAL_TIMEOUT)) continue; tt_local_set_pending(bat_priv, tt_local_entry, @@ -751,7 +751,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) continue; if (!has_timed_out(tt_global_entry->roam_at, - TT_CLIENT_ROAM_TIMEOUT * 1000)) + TT_CLIENT_ROAM_TIMEOUT)) continue; bat_dbg(DBG_TT, bat_priv, "Deleting global " @@ -970,8 +970,7 @@ static void tt_req_purge(struct bat_priv *bat_priv) spin_lock_bh(&bat_priv->tt_req_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { - if (has_timed_out(node->issued_at, - TT_REQUEST_TIMEOUT * 1000)) { + if (has_timed_out(node->issued_at, TT_REQUEST_TIMEOUT)) { list_del(&node->list); kfree(node); } @@ -990,7 +989,7 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { if (compare_eth(tt_req_node_tmp, orig_node) && !has_timed_out(tt_req_node_tmp->issued_at, - TT_REQUEST_TIMEOUT * 1000)) + TT_REQUEST_TIMEOUT)) goto unlock; } @@ -1583,8 +1582,7 @@ static void tt_roam_purge(struct bat_priv *bat_priv) spin_lock_bh(&bat_priv->tt_roam_list_lock); list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { - if (!has_timed_out(node->first_time, - ROAMING_MAX_TIME * 1000)) + if (!has_timed_out(node->first_time, ROAMING_MAX_TIME)) continue; list_del(&node->list); @@ -1611,8 +1609,7 @@ static bool tt_check_roam_count(struct bat_priv *bat_priv, if (!compare_eth(tt_roam_node->addr, client)) continue; - if (has_timed_out(tt_roam_node->first_time, - ROAMING_MAX_TIME * 1000)) + if (has_timed_out(tt_roam_node->first_time, ROAMING_MAX_TIME)) continue; if (!atomic_dec_not_zero(&tt_roam_node->counter)) diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index ac7e66100590..4f4b2a0c2d7b 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c @@ -714,8 +714,7 @@ static void purge_vis_packets(struct bat_priv *bat_priv) if (info == bat_priv->my_vis_info) continue; - if (time_after(jiffies, - info->first_seen + VIS_TIMEOUT * HZ)) { + if (has_timed_out(info->first_seen, VIS_TIMEOUT)) { hlist_del(node); send_list_del(info); kref_put(&info->refcount, free_info); diff --git a/net/batman-adv/vis.h b/net/batman-adv/vis.h index 31b820d07f23..851bc4f1e358 100644 --- a/net/batman-adv/vis.h +++ b/net/batman-adv/vis.h @@ -22,7 +22,8 @@ #ifndef _NET_BATMAN_ADV_VIS_H_ #define _NET_BATMAN_ADV_VIS_H_ -#define VIS_TIMEOUT 200 /* timeout of vis packets in seconds */ +#define VIS_TIMEOUT 200000 /* timeout of vis packets + * in miliseconds */ int vis_seq_print_text(struct seq_file *seq, void *offset); void receive_server_sync_packet(struct bat_priv *bat_priv, -- GitLab From d419be1fd1e4417adc833365a3b69d0968c27c3f Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Sat, 10 Dec 2011 19:45:53 +0800 Subject: [PATCH 0811/1846] batman-adv: allowing changing the routing algorithm via module parameter Signed-off-by: Marek Lindner --- net/batman-adv/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index bcc2bddd893a..8ae497b26bd8 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -256,6 +256,30 @@ int bat_algo_seq_print_text(struct seq_file *seq, void *offset) return 0; } +static int param_set_ra(const char *val, const struct kernel_param *kp) +{ + struct bat_algo_ops *bat_algo_ops; + + bat_algo_ops = bat_algo_get((char *)val); + if (!bat_algo_ops) { + pr_err("Routing algorithm '%s' is not supported\n", val); + return -EINVAL; + } + + return param_set_copystring(val, kp); +} + +static const struct kernel_param_ops param_ops_ra = { + .set = param_set_ra, + .get = param_get_string, +}; + +static struct kparam_string __param_string_ra = { + .maxlen = sizeof(bat_routing_algo), + .string = bat_routing_algo, +}; + +module_param_cb(routing_algo, ¶m_ops_ra, &__param_string_ra, 0644); module_init(batman_init); module_exit(batman_exit); -- GitLab From 92f90f56caa30dfcb6c5755776d73df23ef2ae1a Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Thu, 22 Dec 2011 20:31:12 +0800 Subject: [PATCH 0812/1846] batman-adv: refactor tt_global_del() to avoid misalignment Signed-off-by: Sven Eckelmann Acked-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/translation-table.c | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index ff9a1b33c136..30c2d1b7de49 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -657,29 +657,31 @@ void tt_global_del(struct bat_priv *bat_priv, struct tt_local_entry *tt_local_entry = NULL; tt_global_entry = tt_global_hash_find(bat_priv, addr); - if (!tt_global_entry) + if (!tt_global_entry || tt_global_entry->orig_node != orig_node) goto out; - if (tt_global_entry->orig_node == orig_node) { - if (roaming) { - /* if we are deleting a global entry due to a roam - * event, there are two possibilities: - * 1) the client roamed from node A to node B => we mark - * it with TT_CLIENT_ROAM, we start a timer and we - * wait for node B to claim it. In case of timeout - * the entry is purged. - * 2) the client roamed to us => we can directly delete - * the global entry, since it is useless now. */ - tt_local_entry = tt_local_hash_find(bat_priv, - tt_global_entry->common.addr); - if (!tt_local_entry) { - tt_global_entry->common.flags |= TT_CLIENT_ROAM; - tt_global_entry->roam_at = jiffies; - goto out; - } - } - _tt_global_del(bat_priv, tt_global_entry, message); + if (!roaming) + goto out_del; + + /* if we are deleting a global entry due to a roam + * event, there are two possibilities: + * 1) the client roamed from node A to node B => we mark + * it with TT_CLIENT_ROAM, we start a timer and we + * wait for node B to claim it. In case of timeout + * the entry is purged. + * 2) the client roamed to us => we can directly delete + * the global entry, since it is useless now. */ + tt_local_entry = tt_local_hash_find(bat_priv, + tt_global_entry->common.addr); + if (!tt_local_entry) { + tt_global_entry->common.flags |= TT_CLIENT_ROAM; + tt_global_entry->roam_at = jiffies; + goto out; } + +out_del: + _tt_global_del(bat_priv, tt_global_entry, message); + out: if (tt_global_entry) tt_global_entry_free_ref(tt_global_entry); -- GitLab From ea3d2fd1b11fb3ef8706a48ece0a49a61bcd08bc Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Tue, 29 Nov 2011 00:15:37 +0800 Subject: [PATCH 0813/1846] batman-adv: export used routing algorithm via sysfs Signed-off-by: Marek Lindner --- Documentation/ABI/testing/sysfs-class-net-mesh | 7 +++++++ net/batman-adv/bat_sysfs.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-net-mesh b/Documentation/ABI/testing/sysfs-class-net-mesh index b02001488eef..b218e0f8bdb3 100644 --- a/Documentation/ABI/testing/sysfs-class-net-mesh +++ b/Documentation/ABI/testing/sysfs-class-net-mesh @@ -65,6 +65,13 @@ Description: Defines the penalty which will be applied to an originator message's tq-field on every hop. +What: /sys/class/net//mesh/routing_algo +Date: Dec 2011 +Contact: Marek Lindner +Description: + Defines the routing procotol this mesh instance + uses to find the optimal paths through the mesh. + What: /sys/class/net//mesh/vis_mode Date: May 2010 Contact: Marek Lindner diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c index c25492f7d665..480ae0a5ba43 100644 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c @@ -272,6 +272,13 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, return count; } +static ssize_t show_bat_algo(struct kobject *kobj, struct attribute *attr, + char *buff) +{ + struct bat_priv *bat_priv = kobj_to_batpriv(kobj); + return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name); +} + static void post_gw_deselect(struct net_device *net_dev) { struct bat_priv *bat_priv = netdev_priv(net_dev); @@ -382,6 +389,7 @@ BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL); BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu); BAT_ATTR_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); +static BAT_ATTR(routing_algo, S_IRUGO, show_bat_algo, NULL); static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode); BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL); BAT_ATTR_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL); @@ -399,6 +407,7 @@ static struct bat_attribute *mesh_attrs[] = { &bat_attr_fragmentation, &bat_attr_ap_isolation, &bat_attr_vis_mode, + &bat_attr_routing_algo, &bat_attr_gw_mode, &bat_attr_orig_interval, &bat_attr_hop_penalty, -- GitLab From 567db7b0b7c0a94cc62846f8ebb429bdda2884bc Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 1 Jan 2012 00:41:38 +0100 Subject: [PATCH 0814/1846] batman-adv: Update copyright years Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/Makefile | 2 +- net/batman-adv/bat_algo.h | 2 +- net/batman-adv/bat_debugfs.c | 2 +- net/batman-adv/bat_debugfs.h | 2 +- net/batman-adv/bat_iv_ogm.c | 2 +- net/batman-adv/bat_sysfs.c | 2 +- net/batman-adv/bat_sysfs.h | 2 +- net/batman-adv/bitarray.c | 2 +- net/batman-adv/bitarray.h | 2 +- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/gateway_client.h | 2 +- net/batman-adv/gateway_common.c | 2 +- net/batman-adv/gateway_common.h | 2 +- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/hard-interface.h | 2 +- net/batman-adv/hash.c | 2 +- net/batman-adv/hash.h | 2 +- net/batman-adv/icmp_socket.c | 2 +- net/batman-adv/icmp_socket.h | 2 +- net/batman-adv/main.c | 2 +- net/batman-adv/main.h | 2 +- net/batman-adv/originator.c | 2 +- net/batman-adv/originator.h | 2 +- net/batman-adv/packet.h | 2 +- net/batman-adv/ring_buffer.c | 2 +- net/batman-adv/ring_buffer.h | 2 +- net/batman-adv/routing.c | 2 +- net/batman-adv/routing.h | 2 +- net/batman-adv/send.c | 2 +- net/batman-adv/send.h | 2 +- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/soft-interface.h | 2 +- net/batman-adv/translation-table.c | 2 +- net/batman-adv/translation-table.h | 2 +- net/batman-adv/types.h | 2 +- net/batman-adv/unicast.c | 2 +- net/batman-adv/unicast.h | 2 +- net/batman-adv/vis.c | 2 +- net/batman-adv/vis.h | 2 +- 39 files changed, 39 insertions(+), 39 deletions(-) diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile index ce6861166499..4e392ebedb64 100644 --- a/net/batman-adv/Makefile +++ b/net/batman-adv/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: +# Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: # # Marek Lindner, Simon Wunderlich # diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h index 755379fd367d..9852a688ba43 100644 --- a/net/batman-adv/bat_algo.h +++ b/net/batman-adv/bat_algo.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c index a7a393eeb935..c3b0548b175d 100644 --- a/net/batman-adv/bat_debugfs.c +++ b/net/batman-adv/bat_debugfs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/bat_debugfs.h b/net/batman-adv/bat_debugfs.h index bc9cda3f01e1..d605c6746428 100644 --- a/net/batman-adv/bat_debugfs.h +++ b/net/batman-adv/bat_debugfs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 1c483a5dd808..2b66daef1ef6 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c index 480ae0a5ba43..7317729a00f7 100644 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/bat_sysfs.h b/net/batman-adv/bat_sysfs.h index a3f75a723c56..fece77ae586e 100644 --- a/net/batman-adv/bat_sysfs.h +++ b/net/batman-adv/bat_sysfs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c index 9bc63b209b3f..e63069d61dbb 100644 --- a/net/batman-adv/bitarray.c +++ b/net/batman-adv/bitarray.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h index 9c04422aeb07..c6135728a680 100644 --- a/net/batman-adv/bitarray.h +++ b/net/batman-adv/bitarray.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index df5631e1f2a5..65a77a10f17d 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h index e1edba08eb1d..bf56a5aea10b 100644 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index c4ac7b0a2a63..7f79e156e64d 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h index 55e527a489fe..b8fb11c4f927 100644 --- a/net/batman-adv/gateway_common.h +++ b/net/batman-adv/gateway_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index ff5ba406b1cf..41826b96d9f1 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h index 67f78d1a63b4..e68c5655e616 100644 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c index d1da29da333b..117687bedf25 100644 --- a/net/batman-adv/hash.c +++ b/net/batman-adv/hash.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h index 4768717f07f9..d4bd7862719b 100644 --- a/net/batman-adv/hash.h +++ b/net/batman-adv/hash.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2006-2012 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index 5d69e103faa1..9b755f9eb182 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/icmp_socket.h b/net/batman-adv/icmp_socket.h index 462b190fa101..380ed4c2443a 100644 --- a/net/batman-adv/icmp_socket.h +++ b/net/batman-adv/icmp_socket.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 8ae497b26bd8..08f3b3a8e883 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index ecfed88d0d43..6b276e179419 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 1161f27ad8cc..c2e46b551624 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2009-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h index 67765ffef731..3fe2eda85652 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 88c717b9344d..441f3db1bd91 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/ring_buffer.c b/net/batman-adv/ring_buffer.c index f1ccfa76ce8a..fd63951d118d 100644 --- a/net/batman-adv/ring_buffer.c +++ b/net/batman-adv/ring_buffer.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/ring_buffer.h b/net/batman-adv/ring_buffer.h index 7cdfe62b657c..8b58bd82767d 100644 --- a/net/batman-adv/ring_buffer.h +++ b/net/batman-adv/ring_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index c1e45c0bb186..cf9a2f62de6a 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h index 7aaee0fb0fdc..92ac100d83da 100644 --- a/net/batman-adv/routing.h +++ b/net/batman-adv/routing.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 019337e3eafb..413758065323 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/send.h b/net/batman-adv/send.h index c8ca3ef7385b..824ef06f9b01 100644 --- a/net/batman-adv/send.h +++ b/net/batman-adv/send.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index c41dac3bbf81..2ffdc74ac40e 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h index 001546fc96f1..756eab5b8dd4 100644 --- a/net/batman-adv/soft-interface.h +++ b/net/batman-adv/soft-interface.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner * diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 30c2d1b7de49..4dc5af334f6b 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h index 30efd49881a3..c753633b1da1 100644 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 650ce5fb1192..302efb523475 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 6f3c65952f53..0897dfa72c59 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: * * Andreas Langer * diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h index 8fd5535544b9..a9faf6b1db19 100644 --- a/net/batman-adv/unicast.h +++ b/net/batman-adv/unicast.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2010-2012 B.A.T.M.A.N. contributors: * * Andreas Langer * diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index 4f4b2a0c2d7b..c4a5b8cafada 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2008-2012 B.A.T.M.A.N. contributors: * * Simon Wunderlich * diff --git a/net/batman-adv/vis.h b/net/batman-adv/vis.h index 851bc4f1e358..ee2e46e5347b 100644 --- a/net/batman-adv/vis.h +++ b/net/batman-adv/vis.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2011 B.A.T.M.A.N. contributors: + * Copyright (C) 2008-2012 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * -- GitLab From c40ed2bfa6cc30174d5c547b37bcd6528c830ef4 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Fri, 6 Jan 2012 21:31:33 +0100 Subject: [PATCH 0815/1846] batman-adv: set TT_CLIENT_NEW flag before invoking hash_add() In case of a new tt_local_entry, the TT_CLIENT_NEW flag has to be set before adding such entry to the hash table. Otherwise, it opens a race condition in which the entry can be found but the flag has not been set. Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/translation-table.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 4dc5af334f6b..9be9c41c529b 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -210,6 +210,11 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, if (compare_eth(addr, soft_iface->dev_addr)) tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; + /* The local entry has to be marked as NEW to avoid to send it in + * a full table response going out before the next ttvn increment + * (consistency check) */ + tt_local_entry->common.flags |= TT_CLIENT_NEW; + hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig, &tt_local_entry->common, &tt_local_entry->common.hash_entry); @@ -222,11 +227,6 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, tt_local_event(bat_priv, addr, tt_local_entry->common.flags); - /* The local entry has to be marked as NEW to avoid to send it in - * a full table response going out before the next ttvn increment - * (consistency check) */ - tt_local_entry->common.flags |= TT_CLIENT_NEW; - /* remove address from global hash if present */ tt_global_entry = tt_global_hash_find(bat_priv, addr); -- GitLab From c566dbbef029d7ea957e9566e3073e68b9e05de9 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Fri, 6 Jan 2012 21:31:34 +0100 Subject: [PATCH 0816/1846] batman-adv: code refactoring - move debug print into tt_local_set_pending Each tt_local_set_pending is always followed by a bat_dbg invocation. This can be simplified by moving the bat_dbg() call. Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/translation-table.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 9be9c41c529b..1ff7fbebf921 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -355,7 +355,7 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) static void tt_local_set_pending(struct bat_priv *bat_priv, struct tt_local_entry *tt_local_entry, - uint16_t flags) + uint16_t flags, const char *message) { tt_local_event(bat_priv, tt_local_entry->common.addr, tt_local_entry->common.flags | flags); @@ -364,6 +364,9 @@ static void tt_local_set_pending(struct bat_priv *bat_priv, * to be kept in the table in order to send it in a full table * response issued before the net ttvn increment (consistency check) */ tt_local_entry->common.flags |= TT_CLIENT_PENDING; + + bat_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) pending to be removed: " + "%s\n", tt_local_entry->common.addr, message); } void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, @@ -376,10 +379,7 @@ void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, goto out; tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | - (roaming ? TT_CLIENT_ROAM : NO_FLAGS)); - - bat_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) pending to be removed: " - "%s\n", tt_local_entry->common.addr, message); + (roaming ? TT_CLIENT_ROAM : NO_FLAGS), message); out: if (tt_local_entry) tt_local_entry_free_ref(tt_local_entry); @@ -417,10 +417,7 @@ static void tt_local_purge(struct bat_priv *bat_priv) continue; tt_local_set_pending(bat_priv, tt_local_entry, - TT_CLIENT_DEL); - bat_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) " - "pending to be removed: timed out\n", - tt_local_entry->common.addr); + TT_CLIENT_DEL, "timed out"); } spin_unlock_bh(list_lock); } -- GitLab From 78d6942a45f86126ebdadd45418188b221d63344 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Thu, 12 Jan 2012 19:07:00 +0100 Subject: [PATCH 0817/1846] batman-adv: TT_CLIENT_PENDING is never set in struct tt_global_entry Actually the TT_CLIENT_PENDING flag is never set in the tt_global_entry structure, therefore this code is useless and can be removed. Reported-by: Simon Wunderlich Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/translation-table.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 1ff7fbebf921..9a6f315b7d44 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -603,7 +603,7 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) struct tt_global_entry, common); seq_printf(seq, " * %pM (%3u) via %pM (%3u) " - "[%c%c%c]\n", + "[%c%c]\n", tt_global_entry->common.addr, tt_global_entry->ttvn, tt_global_entry->orig_node->orig, @@ -612,8 +612,6 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) last_ttvn), (tt_global_entry->common.flags & TT_CLIENT_ROAM ? 'R' : '.'), - (tt_global_entry->common.flags & - TT_CLIENT_PENDING ? 'X' : '.'), (tt_global_entry->common.flags & TT_CLIENT_WIFI ? 'W' : '.')); } @@ -838,11 +836,6 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv, if (!atomic_inc_not_zero(&tt_global_entry->orig_node->refcount)) goto out; - /* A global client marked as PENDING has already moved from that - * originator */ - if (tt_global_entry->common.flags & TT_CLIENT_PENDING) - goto out; - orig_node = tt_global_entry->orig_node; out: -- GitLab From fdc8ff101163f10d36187a890a3c4990cebb8b12 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 5 Feb 2012 15:23:55 +0100 Subject: [PATCH 0818/1846] batman-adv: Start new development cycle Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 6b276e179419..1468788a9d64 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -28,7 +28,7 @@ #define DRIVER_DEVICE "batman-adv" #ifndef SOURCE_VERSION -#define SOURCE_VERSION "2012.0.0" +#define SOURCE_VERSION "2012.1.0" #endif /* B.A.T.M.A.N. parameters */ -- GitLab From 3acbc9715a5ac8a2534a69eb3488b63b7c9fb1e2 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 15 Feb 2012 17:54:51 +0000 Subject: [PATCH 0819/1846] net: sh_eth: add the value of tsu to the SH7757's GETHER The SH7757's GETHER has TSU registers. So, this patch adds the value of ".tsu = 1" in the sh_eth_cpu_data. Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 98062bf4197a..8f53b5ac7f05 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -268,6 +268,7 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data_giga = { .rpadir_value = 2 << 16, .no_trimd = 1, .no_ade = 1, + .tsu = 1, }; static struct sh_eth_cpu_data *sh_eth_get_cpu_data(struct sh_eth_private *mdp) -- GitLab From 150647fb2c313d7c5184fca3fa0829a4a7d6f7bc Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 15 Feb 2012 17:54:56 +0000 Subject: [PATCH 0820/1846] net: sh_eth: change the condition of initialization The SH7757 has 2 Fast Ethernet and 2 Gigabit Ethernet, and the first Gigabit channel needs the initialization. So, this patch adds the parameter of "needs_init", and if the sh_eth_plat_data is set it to 1, the driver will initialize the channel. Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 4 ++-- include/linux/sh_eth.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 8f53b5ac7f05..5a5afbc7273b 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1859,8 +1859,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev) /* read and set MAC address */ read_mac_address(ndev, pd->mac_addr); - /* First device only init */ - if (!devno) { + /* initialize first or needed device */ + if (!devno || pd->needs_init) { if (mdp->cd->tsu) { struct resource *rtsu; rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); diff --git a/include/linux/sh_eth.h b/include/linux/sh_eth.h index 2076acf8294d..b17d765ded84 100644 --- a/include/linux/sh_eth.h +++ b/include/linux/sh_eth.h @@ -20,6 +20,7 @@ struct sh_eth_plat_data { unsigned char mac_addr[6]; unsigned no_ether_link:1; unsigned ether_link_active_low:1; + unsigned needs_init:1; }; #endif -- GitLab From 6ba88021c36516c26c11eff8c6d7d9a045faecd3 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 15 Feb 2012 17:55:01 +0000 Subject: [PATCH 0821/1846] net: sh_eth: modify a condition of ioremap for TSU If the controller has TSU, the each channel needs TSU registers. This patch also fixes the iounmap condition in the sh_eth_drv_remove(). Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 5a5afbc7273b..8bd0e5897424 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1859,18 +1859,20 @@ static int sh_eth_drv_probe(struct platform_device *pdev) /* read and set MAC address */ read_mac_address(ndev, pd->mac_addr); + /* ioremap the TSU registers */ + if (mdp->cd->tsu) { + struct resource *rtsu; + rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!rtsu) { + dev_err(&pdev->dev, "Not found TSU resource\n"); + goto out_release; + } + mdp->tsu_addr = ioremap(rtsu->start, + resource_size(rtsu)); + } + /* initialize first or needed device */ if (!devno || pd->needs_init) { - if (mdp->cd->tsu) { - struct resource *rtsu; - rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!rtsu) { - dev_err(&pdev->dev, "Not found TSU resource\n"); - goto out_release; - } - mdp->tsu_addr = ioremap(rtsu->start, - resource_size(rtsu)); - } if (mdp->cd->chip_reset) mdp->cd->chip_reset(ndev); @@ -1919,7 +1921,8 @@ static int sh_eth_drv_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct sh_eth_private *mdp = netdev_priv(ndev); - iounmap(mdp->tsu_addr); + if (mdp->cd->tsu) + iounmap(mdp->tsu_addr); sh_mdio_release(ndev); unregister_netdev(ndev); pm_runtime_disable(&pdev->dev); -- GitLab From 6743fe6df43b4dc5950f605edfeee086d0a80f06 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 15 Feb 2012 17:55:03 +0000 Subject: [PATCH 0822/1846] net: sh_eth: add support for multicast filtering Some controllers have TSU. It can filter multicast by hardware. This patch supports it. Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 282 +++++++++++++++++++++++++- drivers/net/ethernet/renesas/sh_eth.h | 9 + 2 files changed, 286 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 8bd0e5897424..99d8ce8379c8 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1604,18 +1604,289 @@ static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, } #if defined(SH_ETH_HAS_TSU) +/* For TSU_POSTn. Please refer to the manual about this (strange) bitfields */ +static void *sh_eth_tsu_get_post_reg_offset(struct sh_eth_private *mdp, + int entry) +{ + return sh_eth_tsu_get_offset(mdp, TSU_POST1) + (entry / 8 * 4); +} + +static u32 sh_eth_tsu_get_post_mask(int entry) +{ + return 0x0f << (28 - ((entry % 8) * 4)); +} + +static u32 sh_eth_tsu_get_post_bit(struct sh_eth_private *mdp, int entry) +{ + return (0x08 >> (mdp->port << 1)) << (28 - ((entry % 8) * 4)); +} + +static void sh_eth_tsu_enable_cam_entry_post(struct net_device *ndev, + int entry) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + u32 tmp; + void *reg_offset; + + reg_offset = sh_eth_tsu_get_post_reg_offset(mdp, entry); + tmp = ioread32(reg_offset); + iowrite32(tmp | sh_eth_tsu_get_post_bit(mdp, entry), reg_offset); +} + +static bool sh_eth_tsu_disable_cam_entry_post(struct net_device *ndev, + int entry) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + u32 post_mask, ref_mask, tmp; + void *reg_offset; + + reg_offset = sh_eth_tsu_get_post_reg_offset(mdp, entry); + post_mask = sh_eth_tsu_get_post_mask(entry); + ref_mask = sh_eth_tsu_get_post_bit(mdp, entry) & ~post_mask; + + tmp = ioread32(reg_offset); + iowrite32(tmp & ~post_mask, reg_offset); + + /* If other port enables, the function returns "true" */ + return tmp & ref_mask; +} + +static int sh_eth_tsu_busy(struct net_device *ndev) +{ + int timeout = SH_ETH_TSU_TIMEOUT_MS * 100; + struct sh_eth_private *mdp = netdev_priv(ndev); + + while ((sh_eth_tsu_read(mdp, TSU_ADSBSY) & TSU_ADSBSY_0)) { + udelay(10); + timeout--; + if (timeout <= 0) { + dev_err(&ndev->dev, "%s: timeout\n", __func__); + return -ETIMEDOUT; + } + } + + return 0; +} + +static int sh_eth_tsu_write_entry(struct net_device *ndev, void *reg, + const u8 *addr) +{ + u32 val; + + val = addr[0] << 24 | addr[1] << 16 | addr[2] << 8 | addr[3]; + iowrite32(val, reg); + if (sh_eth_tsu_busy(ndev) < 0) + return -EBUSY; + + val = addr[4] << 8 | addr[5]; + iowrite32(val, reg + 4); + if (sh_eth_tsu_busy(ndev) < 0) + return -EBUSY; + + return 0; +} + +static void sh_eth_tsu_read_entry(void *reg, u8 *addr) +{ + u32 val; + + val = ioread32(reg); + addr[0] = (val >> 24) & 0xff; + addr[1] = (val >> 16) & 0xff; + addr[2] = (val >> 8) & 0xff; + addr[3] = val & 0xff; + val = ioread32(reg + 4); + addr[4] = (val >> 8) & 0xff; + addr[5] = val & 0xff; +} + + +static int sh_eth_tsu_find_entry(struct net_device *ndev, const u8 *addr) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); + int i; + u8 c_addr[ETH_ALEN]; + + for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) { + sh_eth_tsu_read_entry(reg_offset, c_addr); + if (memcmp(addr, c_addr, ETH_ALEN) == 0) + return i; + } + + return -ENOENT; +} + +static int sh_eth_tsu_find_empty(struct net_device *ndev) +{ + u8 blank[ETH_ALEN]; + int entry; + + memset(blank, 0, sizeof(blank)); + entry = sh_eth_tsu_find_entry(ndev, blank); + return (entry < 0) ? -ENOMEM : entry; +} + +static int sh_eth_tsu_disable_cam_entry_table(struct net_device *ndev, + int entry) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); + int ret; + u8 blank[ETH_ALEN]; + + sh_eth_tsu_write(mdp, sh_eth_tsu_read(mdp, TSU_TEN) & + ~(1 << (31 - entry)), TSU_TEN); + + memset(blank, 0, sizeof(blank)); + ret = sh_eth_tsu_write_entry(ndev, reg_offset + entry * 8, blank); + if (ret < 0) + return ret; + return 0; +} + +static int sh_eth_tsu_add_entry(struct net_device *ndev, const u8 *addr) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); + int i, ret; + + if (!mdp->cd->tsu) + return 0; + + i = sh_eth_tsu_find_entry(ndev, addr); + if (i < 0) { + /* No entry found, create one */ + i = sh_eth_tsu_find_empty(ndev); + if (i < 0) + return -ENOMEM; + ret = sh_eth_tsu_write_entry(ndev, reg_offset + i * 8, addr); + if (ret < 0) + return ret; + + /* Enable the entry */ + sh_eth_tsu_write(mdp, sh_eth_tsu_read(mdp, TSU_TEN) | + (1 << (31 - i)), TSU_TEN); + } + + /* Entry found or created, enable POST */ + sh_eth_tsu_enable_cam_entry_post(ndev, i); + + return 0; +} + +static int sh_eth_tsu_del_entry(struct net_device *ndev, const u8 *addr) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + int i, ret; + + if (!mdp->cd->tsu) + return 0; + + i = sh_eth_tsu_find_entry(ndev, addr); + if (i) { + /* Entry found */ + if (sh_eth_tsu_disable_cam_entry_post(ndev, i)) + goto done; + + /* Disable the entry if both ports was disabled */ + ret = sh_eth_tsu_disable_cam_entry_table(ndev, i); + if (ret < 0) + return ret; + } +done: + return 0; +} + +static int sh_eth_tsu_purge_all(struct net_device *ndev) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + int i, ret; + + if (unlikely(!mdp->cd->tsu)) + return 0; + + for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++) { + if (sh_eth_tsu_disable_cam_entry_post(ndev, i)) + continue; + + /* Disable the entry if both ports was disabled */ + ret = sh_eth_tsu_disable_cam_entry_table(ndev, i); + if (ret < 0) + return ret; + } + + return 0; +} + +static void sh_eth_tsu_purge_mcast(struct net_device *ndev) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + u8 addr[ETH_ALEN]; + void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); + int i; + + if (unlikely(!mdp->cd->tsu)) + return; + + for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) { + sh_eth_tsu_read_entry(reg_offset, addr); + if (is_multicast_ether_addr(addr)) + sh_eth_tsu_del_entry(ndev, addr); + } +} + /* Multicast reception directions set */ static void sh_eth_set_multicast_list(struct net_device *ndev) { + struct sh_eth_private *mdp = netdev_priv(ndev); + u32 ecmr_bits; + int mcast_all = 0; + unsigned long flags; + + spin_lock_irqsave(&mdp->lock, flags); + /* + * Initial condition is MCT = 1, PRM = 0. + * Depending on ndev->flags, set PRM or clear MCT + */ + ecmr_bits = (sh_eth_read(ndev, ECMR) & ~ECMR_PRM) | ECMR_MCT; + + if (!(ndev->flags & IFF_MULTICAST)) { + sh_eth_tsu_purge_mcast(ndev); + mcast_all = 1; + } + if (ndev->flags & IFF_ALLMULTI) { + sh_eth_tsu_purge_mcast(ndev); + ecmr_bits &= ~ECMR_MCT; + mcast_all = 1; + } + if (ndev->flags & IFF_PROMISC) { - /* Set promiscuous. */ - sh_eth_write(ndev, (sh_eth_read(ndev, ECMR) & ~ECMR_MCT) | - ECMR_PRM, ECMR); + sh_eth_tsu_purge_all(ndev); + ecmr_bits = (ecmr_bits & ~ECMR_MCT) | ECMR_PRM; + } else if (mdp->cd->tsu) { + struct netdev_hw_addr *ha; + netdev_for_each_mc_addr(ha, ndev) { + if (mcast_all && is_multicast_ether_addr(ha->addr)) + continue; + + if (sh_eth_tsu_add_entry(ndev, ha->addr) < 0) { + if (!mcast_all) { + sh_eth_tsu_purge_mcast(ndev); + ecmr_bits &= ~ECMR_MCT; + mcast_all = 1; + } + } + } } else { /* Normal, unicast/broadcast-only mode. */ - sh_eth_write(ndev, (sh_eth_read(ndev, ECMR) & ~ECMR_PRM) | - ECMR_MCT, ECMR); + ecmr_bits = (ecmr_bits & ~ECMR_PRM) | ECMR_MCT; } + + /* update the ethernet mode */ + sh_eth_write(ndev, ecmr_bits, ECMR); + + spin_unlock_irqrestore(&mdp->lock, flags); } #endif /* SH_ETH_HAS_TSU */ @@ -1869,6 +2140,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) } mdp->tsu_addr = ioremap(rtsu->start, resource_size(rtsu)); + mdp->port = devno % 2; } /* initialize first or needed device */ diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index cb07add8638f..86b392e22c01 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h @@ -29,6 +29,8 @@ #define RX_RING_SIZE 64 /* Rx ring size */ #define ETHERSMALL 60 #define PKT_BUF_SZ 1538 +#define SH_ETH_TSU_TIMEOUT_MS 500 +#define SH_ETH_TSU_CAM_ENTRIES 32 enum { /* E-DMAC registers */ @@ -778,6 +780,7 @@ struct sh_eth_private { char post_rx; /* POST receive */ char post_fw; /* POST forward */ struct net_device_stats tsu_stats; /* TSU forward status */ + int port; /* for TSU */ unsigned no_ether_link:1; unsigned ether_link_active_low:1; @@ -811,6 +814,12 @@ static inline unsigned long sh_eth_read(struct net_device *ndev, return ioread32(mdp->addr + mdp->reg_offset[enum_index]); } +static inline void *sh_eth_tsu_get_offset(struct sh_eth_private *mdp, + int enum_index) +{ + return mdp->tsu_addr + mdp->reg_offset[enum_index]; +} + static inline void sh_eth_tsu_write(struct sh_eth_private *mdp, unsigned long data, int enum_index) { -- GitLab From 71cc7c37af71b497698f7f8a68e46a458071fcef Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Wed, 15 Feb 2012 17:55:06 +0000 Subject: [PATCH 0823/1846] net: sh_eth: add support for VLAN tag filtering Some controllers have TSU. It can register one VLAN tag, and it can filter other VLAN tag by hardware. If vlan_rx_add_vid() is called twice or more, the driver will disable the filtering. Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller --- drivers/net/ethernet/renesas/sh_eth.c | 59 +++++++++++++++++++++++++++ drivers/net/ethernet/renesas/sh_eth.h | 5 +++ 2 files changed, 64 insertions(+) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 99d8ce8379c8..8615961c1287 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1888,6 +1888,62 @@ static void sh_eth_set_multicast_list(struct net_device *ndev) spin_unlock_irqrestore(&mdp->lock, flags); } + +static int sh_eth_get_vtag_index(struct sh_eth_private *mdp) +{ + if (!mdp->port) + return TSU_VTAG0; + else + return TSU_VTAG1; +} + +static int sh_eth_vlan_rx_add_vid(struct net_device *ndev, u16 vid) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + int vtag_reg_index = sh_eth_get_vtag_index(mdp); + + if (unlikely(!mdp->cd->tsu)) + return -EPERM; + + /* No filtering if vid = 0 */ + if (!vid) + return 0; + + mdp->vlan_num_ids++; + + /* + * The controller has one VLAN tag HW filter. So, if the filter is + * already enabled, the driver disables it and the filte + */ + if (mdp->vlan_num_ids > 1) { + /* disable VLAN filter */ + sh_eth_tsu_write(mdp, 0, vtag_reg_index); + return 0; + } + + sh_eth_tsu_write(mdp, TSU_VTAG_ENABLE | (vid & TSU_VTAG_VID_MASK), + vtag_reg_index); + + return 0; +} + +static int sh_eth_vlan_rx_kill_vid(struct net_device *ndev, u16 vid) +{ + struct sh_eth_private *mdp = netdev_priv(ndev); + int vtag_reg_index = sh_eth_get_vtag_index(mdp); + + if (unlikely(!mdp->cd->tsu)) + return -EPERM; + + /* No filtering if vid = 0 */ + if (!vid) + return 0; + + mdp->vlan_num_ids--; + sh_eth_tsu_write(mdp, 0, vtag_reg_index); + + return 0; +} #endif /* SH_ETH_HAS_TSU */ /* SuperH's TSU register init function */ @@ -2037,6 +2093,8 @@ static const struct net_device_ops sh_eth_netdev_ops = { .ndo_get_stats = sh_eth_get_stats, #if defined(SH_ETH_HAS_TSU) .ndo_set_rx_mode = sh_eth_set_multicast_list, + .ndo_vlan_rx_add_vid = sh_eth_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = sh_eth_vlan_rx_kill_vid, #endif .ndo_tx_timeout = sh_eth_tx_timeout, .ndo_do_ioctl = sh_eth_do_ioctl, @@ -2141,6 +2199,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) mdp->tsu_addr = ioremap(rtsu->start, resource_size(rtsu)); mdp->port = devno % 2; + ndev->features = NETIF_F_HW_VLAN_FILTER; } /* initialize first or needed device */ diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index 86b392e22c01..57dc26261116 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h @@ -679,6 +679,10 @@ enum TSU_FWSLC_BIT { TSU_FWSLC_CAMSEL11 = 0x0002, TSU_FWSLC_CAMSEL10 = 0x0001, }; +/* TSU_VTAGn */ +#define TSU_VTAG_ENABLE 0x80000000 +#define TSU_VTAG_VID_MASK 0x00000fff + /* * The sh ether Tx buffer descriptors. * This structure should be 20 bytes. @@ -781,6 +785,7 @@ struct sh_eth_private { char post_fw; /* POST forward */ struct net_device_stats tsu_stats; /* TSU forward status */ int port; /* for TSU */ + int vlan_num_ids; /* for VLAN tag filter */ unsigned no_ether_link:1; unsigned ether_link_active_low:1; -- GitLab From 76a7f3a40c2bfbdb5f2b23ac780fa4e4f22e8659 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 00:34:40 +0200 Subject: [PATCH 0824/1846] Bluetooth: Remove unused member from cmd_lookup struct The val member of cmd_lookup isn't used anywhere so it can be removed. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 066d338be1ce..5520858553cc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2561,7 +2561,6 @@ int mgmt_index_removed(struct hci_dev *hdev) } struct cmd_lookup { - u8 val; struct sock *sk; struct hci_dev *hdev; }; @@ -2584,7 +2583,7 @@ static void settings_rsp(struct pending_cmd *cmd, void *data) int mgmt_powered(struct hci_dev *hdev, u8 powered) { - struct cmd_lookup match = { powered, NULL, hdev }; + struct cmd_lookup match = { NULL, hdev }; __le32 ev; int ret; @@ -2608,7 +2607,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) { - struct cmd_lookup match = { discoverable, NULL, hdev }; + struct cmd_lookup match = { NULL, hdev }; __le32 ev; int ret; @@ -2627,7 +2626,7 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) int mgmt_connectable(struct hci_dev *hdev, u8 connectable) { __le32 ev; - struct cmd_lookup match = { connectable, NULL, hdev }; + struct cmd_lookup match = { NULL, hdev }; int ret; mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, settings_rsp, -- GitLab From 7bb895d68e0c18b730bd89f2ed7e58de0e3a591a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 01:20:00 +0200 Subject: [PATCH 0825/1846] Bluetooth: mgmt: Use more consistent error variable names For simple integer errors the variable name "err" is more consistent with the existing code base than "ret". Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5520858553cc..d5dbe402bc03 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2585,7 +2585,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) { struct cmd_lookup match = { NULL, hdev }; __le32 ev; - int ret; + int err; mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); @@ -2596,50 +2596,50 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) ev = cpu_to_le32(get_current_settings(hdev)); - ret = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); if (match.sk) sock_put(match.sk); - return ret; + return err; } int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) { struct cmd_lookup match = { NULL, hdev }; __le32 ev; - int ret; + int err; mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, settings_rsp, &match); ev = cpu_to_le32(get_current_settings(hdev)); - ret = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); if (match.sk) sock_put(match.sk); - return ret; + return err; } int mgmt_connectable(struct hci_dev *hdev, u8 connectable) { __le32 ev; struct cmd_lookup match = { NULL, hdev }; - int ret; + int err; mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, settings_rsp, &match); ev = cpu_to_le32(get_current_settings(hdev)); - ret = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); if (match.sk) sock_put(match.sk); - return ret; + return err; } int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) -- GitLab From 33ef95ed30283eb17c686a815caf1d33e966fe4a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 16 Feb 2012 23:56:27 +0200 Subject: [PATCH 0826/1846] Bluetooth: mgmt: Add support for Set Link Security command The Set Link Security mgmt command is used to enable or disable link level security, also known as Security Mode 3. This is rarely enabled in modern systems but the command needs to be available for completeness, qualification purposes and those few systems that actually want to enable it. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_event.c | 3 ++ net/bluetooth/mgmt.c | 87 ++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index b20d990436b4..66f84adbbbef 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -994,6 +994,7 @@ int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); +int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index b0784ee5f8b9..239e9fb8f7c5 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -254,6 +254,9 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) clear_bit(HCI_AUTH, &hdev->flags); } + if (test_bit(HCI_MGMT, &hdev->dev_flags)) + mgmt_auth_enable_complete(hdev, status); + hci_req_complete(hdev, HCI_OP_WRITE_AUTH_ENABLE, status); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d5dbe402bc03..0c9fbb45d2e9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -964,6 +964,65 @@ static int set_pairable(struct sock *sk, u16 index, void *data, u16 len) return err; } +static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) +{ + struct mgmt_mode *cp = data; + struct pending_cmd *cmd; + struct hci_dev *hdev; + uint8_t val; + int err; + + BT_DBG("request for hci%u", index); + + if (len != sizeof(*cp)) + return cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, + MGMT_STATUS_INVALID_PARAMS); + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, + MGMT_STATUS_INVALID_PARAMS); + + hci_dev_lock(hdev); + + if (!test_bit(HCI_UP, &hdev->flags)) { + err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, + MGMT_STATUS_NOT_POWERED); + goto failed; + } + + if (mgmt_pending_find(MGMT_OP_SET_LINK_SECURITY, hdev)) { + err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, + MGMT_STATUS_BUSY); + goto failed; + } + + val = !!cp->val; + + if (test_bit(HCI_AUTH, &hdev->flags) == val) { + err = send_settings_rsp(sk, MGMT_OP_SET_LINK_SECURITY, hdev); + goto failed; + } + + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LINK_SECURITY, hdev, data, len); + if (!cmd) { + err = -ENOMEM; + goto failed; + } + + err = hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, sizeof(val), &val); + if (err < 0) { + mgmt_pending_remove(cmd); + goto failed; + } + +failed: + hci_dev_unlock(hdev); + hci_dev_put(hdev); + + return err; +} + static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_add_uuid *cp = data; @@ -2443,6 +2502,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_SET_PAIRABLE: err = set_pairable(sk, index, cp, len); break; + case MGMT_OP_SET_LINK_SECURITY: + err = set_link_security(sk, index, cp, len); + break; case MGMT_OP_ADD_UUID: err = add_uuid(sk, index, cp, len); break; @@ -2965,6 +3027,31 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, return mgmt_event(MGMT_EV_AUTH_FAILED, hdev, &ev, sizeof(ev), NULL); } +int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) +{ + struct cmd_lookup match = { NULL, hdev }; + __le32 ev; + int err; + + if (status) { + u8 mgmt_err = mgmt_status(status); + mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, + cmd_status_rsp, &mgmt_err); + return 0; + } + + mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, settings_rsp, + &match); + + ev = cpu_to_le32(get_current_settings(hdev)); + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + + if (match.sk) + sock_put(match.sk); + + return err; +} + int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) { struct pending_cmd *cmd; -- GitLab From ed2c4ee360709ca838efa0ea4d6295590aff3d24 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 00:56:28 +0200 Subject: [PATCH 0827/1846] Bluetooth: mgmt: Add support for Set SSP command The Set SSP mgmt command can be used for enabling and disabling Secure Simple Pairing support for controllers that support it. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_event.c | 6 ++- net/bluetooth/mgmt.c | 85 ++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 66f84adbbbef..43e0b1eda020 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -995,6 +995,7 @@ int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); +int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 239e9fb8f7c5..179d127601fc 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -447,7 +447,7 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, status); if (status) - return; + goto done; sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); if (!sent) @@ -457,6 +457,10 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); else clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); + +done: + if (test_bit(HCI_MGMT, &hdev->dev_flags)) + mgmt_ssp_enable_complete(hdev, status); } static u8 hci_get_inquiry_mode(struct hci_dev *hdev) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0c9fbb45d2e9..36c4ff6fdf05 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1023,6 +1023,64 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) return err; } +static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) +{ + struct mgmt_mode *cp = data; + struct pending_cmd *cmd; + struct hci_dev *hdev; + uint8_t val; + int err; + + BT_DBG("request for hci%u", index); + + if (len != sizeof(*cp)) + return cmd_status(sk, index, MGMT_OP_SET_SSP, + MGMT_STATUS_INVALID_PARAMS); + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_SET_SSP, + MGMT_STATUS_INVALID_PARAMS); + + hci_dev_lock(hdev); + + if (!test_bit(HCI_UP, &hdev->flags)) { + err = cmd_status(sk, index, MGMT_OP_SET_SSP, + MGMT_STATUS_NOT_POWERED); + goto failed; + } + + if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { + err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_BUSY); + goto failed; + } + + val = !!cp->val; + + if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) == val) { + err = send_settings_rsp(sk, MGMT_OP_SET_SSP, hdev); + goto failed; + } + + cmd = mgmt_pending_add(sk, MGMT_OP_SET_SSP, hdev, data, len); + if (!cmd) { + err = -ENOMEM; + goto failed; + } + + err = hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, sizeof(val), &val); + if (err < 0) { + mgmt_pending_remove(cmd); + goto failed; + } + +failed: + hci_dev_unlock(hdev); + hci_dev_put(hdev); + + return err; +} + static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_add_uuid *cp = data; @@ -2505,6 +2563,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_SET_LINK_SECURITY: err = set_link_security(sk, index, cp, len); break; + case MGMT_OP_SET_SSP: + err = set_ssp(sk, index, cp, len); + break; case MGMT_OP_ADD_UUID: err = add_uuid(sk, index, cp, len); break; @@ -3052,6 +3113,30 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) return err; } +int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status) +{ + struct cmd_lookup match = { NULL, hdev }; + __le32 ev; + int err; + + if (status) { + u8 mgmt_err = mgmt_status(status); + mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, + cmd_status_rsp, &mgmt_err); + return 0; + } + + mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, settings_rsp, &match); + + ev = cpu_to_le32(get_current_settings(hdev)); + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + + if (match.sk) + sock_put(match.sk); + + return err; +} + int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) { struct pending_cmd *cmd; -- GitLab From 3ed7003e724a04482e0ef1e794eece8c1c177b37 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 16 Feb 2012 23:32:42 -0800 Subject: [PATCH 0828/1846] Bluetooth: Add logging functions bt_info and bt_err Use specific logging functions instead of a generic bt_printk function can save some text. Remove now unused bt_printk function. Add compatibility BT_INFO and BT_ERR macros. (compiled x86 and defconfig with bluetooth and all bluetooth drivers) $ size net/bluetooth/built-in.o* text data bss dec hex filename 381662 20072 100416 502150 7a986 net/bluetooth/built-in.o.allyesconfig.new 382463 20072 100400 502935 7ac97 net/bluetooth/built-in.o.allyesconfig.old 126635 1388 132 128155 1f49b net/bluetooth/built-in.o.defconfig.new 127175 1388 132 128695 1f6b7 net/bluetooth/built-in.o.defconfig.old $ size drivers/bluetooth/built-in.o* 127575 8976 29476 166027 2888b drivers/bluetooth/built-in.o.allyesconfig.new 129512 8976 29516 168004 29044 drivers/bluetooth/built-in.o.allyesconfig.old 52998 3292 156 56446 dc7e drivers/bluetooth/built-in.o.defconfig.new 54358 3292 156 57806 e1ce drivers/bluetooth/built-in.o.defconfig.old Signed-off-by: Joe Perches Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/bluetooth.h | 14 ++++++++------ net/bluetooth/lib.c | 27 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 4a82ca0bb0b2..9f5f2c1c5554 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -109,12 +109,14 @@ struct bt_power { */ #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 -__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) -#define BT_ERR(fmt, arg...) bt_printk(KERN_ERR, pr_fmt(fmt), ##arg) -#define BT_DBG(fmt, arg...) pr_debug(fmt "\n", ##arg) +__printf(1, 2) +int bt_info(const char *fmt, ...); +__printf(1, 2) +int bt_err(const char *fmt, ...); + +#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) +#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) +#define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) /* Connection and socket states */ enum { diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c index 86a6bed229df..506628876f36 100644 --- a/net/bluetooth/lib.c +++ b/net/bluetooth/lib.c @@ -24,6 +24,8 @@ /* Bluetooth kernel library. */ +#define pr_fmt(fmt) "Bluetooth: " fmt + #include #include @@ -151,7 +153,26 @@ int bt_to_errno(__u16 code) } EXPORT_SYMBOL(bt_to_errno); -int bt_printk(const char *level, const char *format, ...) +int bt_info(const char *format, ...) +{ + struct va_format vaf; + va_list args; + int r; + + va_start(args, format); + + vaf.fmt = format; + vaf.va = &args; + + r = pr_info("%pV", &vaf); + + va_end(args); + + return r; +} +EXPORT_SYMBOL(bt_info); + +int bt_err(const char *format, ...) { struct va_format vaf; va_list args; @@ -162,10 +183,10 @@ int bt_printk(const char *level, const char *format, ...) vaf.fmt = format; vaf.va = &args; - r = printk("%sBluetooth: %pV\n", level, &vaf); + r = pr_err("%pV", &vaf); va_end(args); return r; } -EXPORT_SYMBOL(bt_printk); +EXPORT_SYMBOL(bt_err); -- GitLab From 20d1803a70ddafc8410b461caaa397e49da246ac Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 17 Feb 2012 11:40:55 +0200 Subject: [PATCH 0829/1846] Bluetooth: Move scope of state_to_string Function state_to_string will be used in other files in debug statements. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/bluetooth.h | 27 +++++++++++++++++++++++++++ net/bluetooth/l2cap_core.c | 26 -------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 9f5f2c1c5554..5ca9219fe940 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -131,6 +131,33 @@ enum { BT_CLOSED }; +/* If unused will be removed by compiler */ +static inline const char *state_to_string(int state) +{ + switch (state) { + case BT_CONNECTED: + return "BT_CONNECTED"; + case BT_OPEN: + return "BT_OPEN"; + case BT_BOUND: + return "BT_BOUND"; + case BT_LISTEN: + return "BT_LISTEN"; + case BT_CONNECT: + return "BT_CONNECT"; + case BT_CONNECT2: + return "BT_CONNECT2"; + case BT_CONFIG: + return "BT_CONFIG"; + case BT_DISCONN: + return "BT_DISCONN"; + case BT_CLOSED: + return "BT_CLOSED"; + } + + return "invalid state"; +} + /* BD Address */ typedef struct { __u8 b[6]; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8efac7884ffb..252a96e474ca 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -215,32 +215,6 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) return 0; } -static char *state_to_string(int state) -{ - switch(state) { - case BT_CONNECTED: - return "BT_CONNECTED"; - case BT_OPEN: - return "BT_OPEN"; - case BT_BOUND: - return "BT_BOUND"; - case BT_LISTEN: - return "BT_LISTEN"; - case BT_CONNECT: - return "BT_CONNECT"; - case BT_CONNECT2: - return "BT_CONNECT2"; - case BT_CONFIG: - return "BT_CONFIG"; - case BT_DISCONN: - return "BT_DISCONN"; - case BT_CLOSED: - return "BT_CLOSED"; - } - - return "invalid state"; -} - static void l2cap_state_change(struct l2cap_chan *chan, int state) { BT_DBG("%p %s -> %s", chan, state_to_string(chan->state), -- GitLab From e05dcc3291dcfe9ab1b456f38ccb3041ebbda59c Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 17 Feb 2012 11:40:56 +0200 Subject: [PATCH 0830/1846] Bluetooth: Use symbolic names for state in debug Use state_to_string function in debug statements. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 3 ++- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/l2cap_core.c | 5 +++-- net/bluetooth/l2cap_sock.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 42fdbb833254..bbb0e214e51d 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -612,7 +612,8 @@ static inline void l2cap_chan_put(struct l2cap_chan *c) static inline void l2cap_set_timer(struct l2cap_chan *chan, struct delayed_work *work, long timeout) { - BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); + BT_DBG("chan %p state %s timeout %ld", chan, + state_to_string(chan->state), timeout); if (!cancel_delayed_work(work)) l2cap_chan_hold(chan); diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b4ecddee11b5..f38e1b11d835 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -282,7 +282,7 @@ static void hci_conn_timeout(struct work_struct *work) disc_work.work); __u8 reason; - BT_DBG("conn %p state %d", conn, conn->state); + BT_DBG("conn %p state %s", conn, state_to_string(conn->state)); if (atomic_read(&conn->refcnt)) return; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 252a96e474ca..88968e711d3d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -231,7 +231,7 @@ static void l2cap_chan_timeout(struct work_struct *work) struct sock *sk = chan->sk; int reason; - BT_DBG("chan %p state %d", chan, chan->state); + BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); lock_sock(sk); @@ -413,7 +413,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) struct l2cap_conn *conn = chan->conn; struct sock *sk = chan->sk; - BT_DBG("chan %p state %d socket %p", chan, chan->state, sk->sk_socket); + BT_DBG("chan %p state %s sk %p", chan, + state_to_string(chan->state), sk); switch (chan->state) { case BT_LISTEN: diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 138fe3446678..b48d6c1b9db6 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -783,7 +783,7 @@ static void l2cap_sock_kill(struct sock *sk) if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) return; - BT_DBG("sk %p state %d", sk, sk->sk_state); + BT_DBG("sk %p state %s", sk, state_to_string(sk->sk_state)); /* Kill poor orphan */ -- GitLab From 42d2d87cfe837e987802588f8d8b119a76714a74 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 17 Feb 2012 11:40:57 +0200 Subject: [PATCH 0831/1846] Bluetooth: Prefix hex numbers with object name Several hex numbers were printed without object name which complicates debugging. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/l2cap_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index f38e1b11d835..7ee6895c4b0c 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -80,7 +80,7 @@ void hci_acl_connect(struct hci_conn *conn) struct inquiry_entry *ie; struct hci_cp_create_conn cp; - BT_DBG("%p", conn); + BT_DBG("hcon %p", conn); conn->state = BT_CONNECT; conn->out = true; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 88968e711d3d..37736c6603fc 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -217,7 +217,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) static void l2cap_state_change(struct l2cap_chan *chan, int state) { - BT_DBG("%p %s -> %s", chan, state_to_string(chan->state), + BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state), state_to_string(state)); chan->state = state; -- GitLab From d753fdc40f60da2eef03b4816392081a552fea5a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 14:06:34 +0200 Subject: [PATCH 0832/1846] Bluetooth: mgmt: Add address type to link key messages The latest mgmt API includes an address type wherever there's an address present. This patch updates the link key messages to match it. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 2 +- net/bluetooth/mgmt.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 255a99600f08..5aafe929d011 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -153,7 +153,7 @@ struct mgmt_cp_remove_uuid { } __packed; struct mgmt_link_key_info { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; u8 type; u8 val[16]; u8 pin_len; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 36c4ff6fdf05..b0de7194249e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1274,8 +1274,8 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) for (i = 0; i < key_count; i++) { struct mgmt_link_key_info *key = &cp->keys[i]; - hci_add_link_key(hdev, NULL, 0, &key->bdaddr, key->val, key->type, - key->pin_len); + hci_add_link_key(hdev, NULL, 0, &key->addr.bdaddr, key->val, + key->type, key->pin_len); } cmd_complete(sk, index, MGMT_OP_LOAD_LINK_KEYS, NULL, 0); @@ -2788,7 +2788,8 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, memset(&ev, 0, sizeof(ev)); ev.store_hint = persistent; - bacpy(&ev.key.bdaddr, &key->bdaddr); + bacpy(&ev.key.addr.bdaddr, &key->bdaddr); + ev.key.addr.type = MGMT_ADDR_BREDR; ev.key.type = key->type; memcpy(ev.key.val, key->val, 16); ev.key.pin_len = key->pin_len; -- GitLab From d8457698e7f23a05055396a15ec72ba663282867 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 14:24:57 +0200 Subject: [PATCH 0833/1846] Bluetooth: mgmt: Add address type to PIN code messages The latest mgmt API includes address types for all messages containing an address. This patch updates the PIN code messages to match this. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 8 ++++---- net/bluetooth/mgmt.c | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 5aafe929d011..eb584cc287d6 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -199,18 +199,18 @@ struct mgmt_rp_get_connections { #define MGMT_OP_PIN_CODE_REPLY 0x0016 struct mgmt_cp_pin_code_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 pin_len; __u8 pin_code[16]; } __packed; struct mgmt_rp_pin_code_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; uint8_t status; } __packed; #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 struct mgmt_cp_pin_code_neg_reply { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; } __packed; #define MGMT_OP_SET_IO_CAPABILITY 0x0018 @@ -377,7 +377,7 @@ struct mgmt_ev_connect_failed { #define MGMT_EV_PIN_CODE_REQUEST 0x000E struct mgmt_ev_pin_code_request { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 secure; } __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index b0de7194249e..68623401933f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1528,8 +1528,8 @@ static int send_pin_code_neg_reply(struct sock *sk, u16 index, if (!cmd) return -ENOMEM; - err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(cp->bdaddr), - &cp->bdaddr); + err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, + sizeof(cp->addr.bdaddr), &cp->addr.bdaddr); if (err < 0) mgmt_pending_remove(cmd); @@ -1541,7 +1541,6 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) struct hci_dev *hdev; struct hci_conn *conn; struct mgmt_cp_pin_code_reply *cp = data; - struct mgmt_cp_pin_code_neg_reply ncp; struct hci_cp_pin_code_reply reply; struct pending_cmd *cmd; int err; @@ -1565,7 +1564,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); if (!conn) { err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_NOT_CONNECTED); @@ -1573,7 +1572,9 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) } if (conn->pending_sec_level == BT_SECURITY_HIGH && cp->pin_len != 16) { - bacpy(&ncp.bdaddr, &cp->bdaddr); + struct mgmt_cp_pin_code_neg_reply ncp; + + memcpy(&ncp.addr, &cp->addr, sizeof(ncp.addr)); BT_ERR("PIN code is not 16 bytes long"); @@ -1592,7 +1593,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - bacpy(&reply.bdaddr, &cp->bdaddr); + bacpy(&reply.bdaddr, &cp->addr.bdaddr); reply.pin_len = cp->pin_len; memcpy(reply.pin_code, cp->pin_code, sizeof(reply.pin_code)); @@ -2945,7 +2946,8 @@ int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure) { struct mgmt_ev_pin_code_request ev; - bacpy(&ev.bdaddr, bdaddr); + bacpy(&ev.addr.bdaddr, bdaddr); + ev.addr.type = MGMT_ADDR_BREDR; ev.secure = secure; return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev), @@ -2963,7 +2965,8 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, if (!cmd) return -ENOENT; - bacpy(&rp.bdaddr, bdaddr); + bacpy(&rp.addr.bdaddr, bdaddr); + rp.addr.type = MGMT_ADDR_BREDR; rp.status = mgmt_status(status); err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, &rp, @@ -2985,7 +2988,8 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, if (!cmd) return -ENOENT; - bacpy(&rp.bdaddr, bdaddr); + bacpy(&rp.addr.bdaddr, bdaddr); + rp.addr.type = MGMT_ADDR_BREDR; rp.status = mgmt_status(status); err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, -- GitLab From a198e7b100b26dd6ac0240487ca37bad0f53e3e6 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 14:27:06 +0200 Subject: [PATCH 0834/1846] Bluetooth: mgmt: Add address type to confirm name command The latest mgmt API includes an address type for all messages containing an address. This patch updates the confirm name command to match this. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 4 ++-- net/bluetooth/mgmt.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index eb584cc287d6..14c1816cac67 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -296,11 +296,11 @@ struct mgmt_cp_start_discovery { #define MGMT_OP_CONFIRM_NAME 0x0025 struct mgmt_cp_confirm_name { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 name_known; } __packed; struct mgmt_rp_confirm_name { - bdaddr_t bdaddr; + struct mgmt_addr_info addr; __u8 status; } __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 68623401933f..01c8d6239a4b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2299,7 +2299,7 @@ static int confirm_name(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - e = hci_inquiry_cache_lookup_unknown(hdev, &cp->bdaddr); + e = hci_inquiry_cache_lookup_unknown(hdev, &cp->addr.bdaddr); if (!e) { err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME, MGMT_STATUS_INVALID_PARAMS); -- GitLab From ea585ab51d3fe2eb2d738c91f83e7c309e76b4fe Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 14:50:39 +0200 Subject: [PATCH 0835/1846] Bluetooth: Add Intel copyright to mgmt files This patch adds the appropriate Intel copyright to mgmt files. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/mgmt.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 14c1816cac67..ee625a6ad791 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -2,6 +2,7 @@ BlueZ - Bluetooth protocol stack for Linux Copyright (C) 2010 Nokia Corporation + Copyright (C) 2011-2012 Intel Corporation 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 diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 01c8d6239a4b..f9f3e4c44150 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1,6 +1,8 @@ /* BlueZ - Bluetooth protocol stack for Linux + Copyright (C) 2010 Nokia Corporation + Copyright (C) 2011-2012 Intel Corporation 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 -- GitLab From 2f73d7c2b1f92e34aceee21740ec5fb9b8262ecb Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 3 Feb 2012 13:06:57 -0800 Subject: [PATCH 0836/1846] iwlwifi: log as error when error detected A lot of error conditions in testmode log as IWL_DEBUG_INFO which is not logged by default. Change it Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 122 ++++++++------------ 1 file changed, 51 insertions(+), 71 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index df7ab332c833..e42e0768880b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -172,7 +172,7 @@ static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, GFP_ATOMIC); if (skb == NULL) { - IWL_DEBUG_INFO(priv, + IWL_ERR(priv, "Run out of memory for messages to user space ?\n"); return; } @@ -183,7 +183,7 @@ static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, nla_put_failure: kfree_skb(skb); - IWL_DEBUG_INFO(priv, "Ouch, overran buffer, check allocation!\n"); + IWL_ERR(priv, "Ouch, overran buffer, check allocation!\n"); } void iwl_testmode_init(struct iwl_priv *priv) @@ -252,8 +252,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) 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"); + IWL_ERR(priv, "Missing ucode command mandatory fields\n"); return -ENOMSG; } @@ -295,7 +294,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) int status = 0; if (!tb[IWL_TM_ATTR_REG_OFFSET]) { - IWL_DEBUG_INFO(priv, "Error finding register offset\n"); + IWL_ERR(priv, "Missing register offset\n"); return -ENOMSG; } ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]); @@ -309,7 +308,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 || cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8) && (ofs >= FH_MEM_UPPER_BOUND)) { - IWL_DEBUG_INFO(priv, "offset out of segment (0x0 - 0x%x)\n", + IWL_ERR(priv, "offset out of segment (0x0 - 0x%x)\n", FH_MEM_UPPER_BOUND); return -EINVAL; } @@ -321,19 +320,17 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\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); + IWL_ERR(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"); + IWL_ERR(priv, "Missing value to write\n"); return -ENOMSG; } else { val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); @@ -343,7 +340,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) 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"); + IWL_ERR(priv, "Missing value to write\n"); return -ENOMSG; } else { val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); @@ -357,19 +354,17 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\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); + IWL_ERR(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"); + IWL_ERR(priv, "Missing value to write\n"); return -ENOMSG; } else { val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); @@ -378,7 +373,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) } break; default: - IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n"); + IWL_ERR(priv, "Unknown testmode register command ID\n"); return -ENOSYS; } @@ -400,14 +395,13 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) NULL, NULL); ret = iwl_init_alive_start(trans(priv)); if (ret) { - IWL_DEBUG_INFO(priv, - "Error configuring init calibration: %d\n", ret); + IWL_ERR(priv, "Fail init calibration: %d\n", ret); goto cfg_init_calib_error; } ret = iwl_wait_notification(priv->shrd, &calib_wait, 2 * HZ); if (ret) - IWL_DEBUG_INFO(priv, "Error detecting" + IWL_ERR(priv, "Error detecting" " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); return ret; @@ -448,8 +442,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, rsp_data_len + 20); if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\n"); return -ENOMEM; } NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, @@ -458,15 +451,13 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) rsp_data_len, rsp_data_ptr); status = cfg80211_testmode_reply(skb); if (status < 0) - IWL_DEBUG_INFO(priv, "Error sending msg : %d\n", - status); + IWL_ERR(priv, "Error sending msg : %d\n", status); break; case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT); if (status) - IWL_DEBUG_INFO(priv, - "Error loading init ucode: %d\n", status); + IWL_ERR(priv, "Error loading init ucode: %d\n", status); break; case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: @@ -477,13 +468,13 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_REGULAR); if (status) { - IWL_DEBUG_INFO(priv, + IWL_ERR(priv, "Error loading runtime ucode: %d\n", status); break; } status = iwl_alive_start(priv); if (status) - IWL_DEBUG_INFO(priv, + IWL_ERR(priv, "Error starting the device: %d\n", status); break; @@ -492,13 +483,13 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) iwl_trans_stop_device(trans); status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_WOWLAN); if (status) { - IWL_DEBUG_INFO(priv, + IWL_ERR(priv, "Error loading WOWLAN ucode: %d\n", status); break; } status = iwl_alive_start(priv); if (status) - IWL_DEBUG_INFO(priv, + IWL_ERR(priv, "Error starting the device: %d\n", status); break; @@ -507,8 +498,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, cfg(priv)->base_params->eeprom_size + 20); if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\n"); return -ENOMEM; } NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, @@ -518,17 +508,15 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) priv->shrd->eeprom); status = cfg80211_testmode_reply(skb); if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", - status); + IWL_ERR(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"); + IWL_ERR(priv, "Missing fixrate setting\n"); return -ENOMSG; } priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); @@ -539,14 +527,13 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\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); + IWL_ERR(priv, "Error sending msg : %d\n", status); break; case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: @@ -555,20 +542,19 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\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); + IWL_ERR(priv, "Error sending msg : %d\n", status); break; case IWL_TM_CMD_APP2DEV_GET_FW_INFO: skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8); if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\n"); return -ENOMEM; } switch (priv->shrd->ucode_type) { @@ -585,10 +571,10 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) data_size = trans(priv)->ucode_wowlan.data.len; break; case IWL_UCODE_NONE: - IWL_DEBUG_INFO(priv, "The uCode has not been loaded\n"); + IWL_ERR(priv, "No uCode has not been loaded\n"); break; default: - IWL_DEBUG_INFO(priv, "Unsupported uCode type\n"); + IWL_ERR(priv, "Unsupported uCode type\n"); break; } NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type); @@ -596,12 +582,11 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) NLA_PUT_U32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size); status = cfg80211_testmode_reply(skb); if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", status); + IWL_ERR(priv, "Error sending msg : %d\n", status); break; default: - IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); + IWL_ERR(priv, "Unknown testmode driver command ID\n"); return -ENOSYS; } return status; @@ -664,8 +649,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) 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_ERR(priv, "Memory allocation fail\n"); iwl_trace_cleanup(priv); return -ENOMEM; } @@ -674,9 +658,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) (u64 *)&priv->testmode_trace.dma_addr); status = cfg80211_testmode_reply(skb); if (status < 0) { - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", - status); + IWL_ERR(priv, "Error sending msg : %d\n", status); } priv->testmode_trace.num_chunks = DIV_ROUND_UP(priv->testmode_trace.buff_size, @@ -687,7 +669,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) iwl_trace_cleanup(priv); break; default: - IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n"); + IWL_ERR(priv, "Unknown testmode mem command ID\n"); return -ENOSYS; } return status; @@ -752,7 +734,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) u8 owner; if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { - IWL_DEBUG_INFO(priv, "Error finding ucode owner\n"); + IWL_ERR(priv, "Missing ucode owner\n"); return -ENOMSG; } @@ -760,7 +742,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) priv->shrd->ucode_owner = owner; else { - IWL_DEBUG_INFO(priv, "Invalid owner\n"); + IWL_ERR(priv, "Invalid owner\n"); return -EINVAL; } return 0; @@ -791,12 +773,12 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) return -EBUSY; if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { - IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); + IWL_ERR(priv, "Missing 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"); + IWL_ERR(priv, "Missing size for SRAM reading\n"); return -ENOMSG; } size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); @@ -811,10 +793,10 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) maxsize = trans(priv)->ucode_wowlan.data.len; break; case IWL_UCODE_NONE: - IWL_ERR(priv, "Error, uCode does not been loaded\n"); + IWL_ERR(priv, "uCode does not been loaded\n"); return -ENOSYS; default: - IWL_ERR(priv, "Error, unsupported uCode type\n"); + IWL_ERR(priv, "unsupported uCode type\n"); return -ENOSYS; } if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) { @@ -825,7 +807,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) priv->testmode_sram.buff_addr = kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); if (priv->testmode_sram.buff_addr == NULL) { - IWL_ERR(priv, "Error allocating memory\n"); + IWL_ERR(priv, "Memory allocation fail\n"); return -ENOMEM; } _iwl_read_targ_mem_words(trans(priv), ofs, @@ -898,14 +880,13 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) 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); + IWL_ERR(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"); + IWL_ERR(priv, "Missing testmode command type\n"); return -ENOMSG; } /* in case multiple accesses to the device happens */ @@ -956,7 +937,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) break; default: - IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); + IWL_ERR(priv, "Unknown testmode command\n"); result = -ENOSYS; break; } @@ -981,15 +962,14 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, 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); + IWL_ERR(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"); + IWL_ERR(priv, "Missing testmode command type\n"); return -ENOMSG; } cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); -- GitLab From 6c55f5ed3a23ba60a0e7809a39ad7361ae00a764 Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Wed, 25 Jan 2012 13:30:27 +0200 Subject: [PATCH 0837/1846] iwlwifi: testmode new indirect RW API Replaced the old SRAM and periphery indirect access functions with a unified indirect memory access functions. These include new IWL_TM_CMDs for buffer read/write/dump which replace the SRAM read/dump commands, but the API for IWL_TM_CMD_INDIRECT_REG read/write will now not be supported (returns error). This also handles writing to periphery registers in 1-3 bytes. Requires the corresponding patch in the library for the API change. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 6 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 226 ++++++++++++-------- drivers/net/wireless/iwlwifi/iwl-testmode.h | 53 ++--- 3 files changed, 163 insertions(+), 122 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index aa99457c3a52..0e8f13705dbe 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -696,11 +696,11 @@ struct iwl_testmode_trace { dma_addr_t dma_addr; bool trace_enabled; }; -struct iwl_testmode_sram { +struct iwl_testmode_mem { u32 buff_size; u32 num_chunks; u8 *buff_addr; - bool sram_readed; + bool read_in_progress; }; #endif @@ -964,7 +964,7 @@ struct iwl_priv { bool led_registered; #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE struct iwl_testmode_trace testmode_trace; - struct iwl_testmode_sram testmode_sram; + struct iwl_testmode_mem testmode_mem; u32 tm_fixed_rate; #endif diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index e42e0768880b..debc9ababbfa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -81,6 +81,13 @@ #include "iwl-bus.h" #include "iwl-fh.h" + +/* Periphery registers absolute lower bound. This is used in order to + * differentiate registery access through HBUS_TARG_PRPH_* and + * HBUS_TARG_MEM_* accesses. + */ +#define IWL_TM_ABS_PRPH_START (0xA00000) + /* 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. @@ -110,9 +117,9 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [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, }, + [IWL_TM_ATTR_MEM_ADDR] = { .type = NLA_U32, }, + [IWL_TM_ATTR_BUFFER_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_BUFFER_DUMP] = { .type = NLA_UNSPEC, }, [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, }, @@ -190,17 +197,17 @@ 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; + priv->testmode_mem.read_in_progress = false; } -static void iwl_sram_cleanup(struct iwl_priv *priv) +static void iwl_mem_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; + if (priv->testmode_mem.read_in_progress) { + kfree(priv->testmode_mem.buff_addr); + priv->testmode_mem.buff_addr = NULL; + priv->testmode_mem.buff_size = 0; + priv->testmode_mem.num_chunks = 0; + priv->testmode_mem.read_in_progress = false; } } @@ -226,7 +233,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); + iwl_mem_cleanup(priv); } /* @@ -348,30 +355,6 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) iwl_write8(trans(priv), ofs, val8); } break; - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: - val32 = iwl_read_prph(trans(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_ERR(priv, "Memory allocation fail\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_ERR(priv, "Error sending msg : %d\n", status); - break; - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - if (!tb[IWL_TM_ATTR_REG_VALUE32]) { - IWL_ERR(priv, "Missing 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(trans(priv), ofs, val32); - } - break; default: IWL_ERR(priv, "Unknown testmode register command ID\n"); return -ENOSYS; @@ -748,6 +731,81 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) return 0; } +static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size) +{ + struct iwl_trans *trans = trans(priv); + unsigned long flags; + int i; + + if (size & 0x3) + return -EINVAL; + priv->testmode_mem.buff_size = size; + priv->testmode_mem.buff_addr = + kmalloc(priv->testmode_mem.buff_size, GFP_KERNEL); + if (priv->testmode_mem.buff_addr == NULL) + return -ENOMEM; + + /* Hard-coded periphery absolute address */ + if (IWL_TM_ABS_PRPH_START <= addr && + addr < IWL_TM_ABS_PRPH_START + PRPH_END) { + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + iwl_write32(trans, HBUS_TARG_PRPH_RADDR, addr); + for (i = 0; i < size; i += 4) + priv->testmode_mem.buff_addr[i] = + iwl_read32(trans, HBUS_TARG_PRPH_RDAT); + iwl_release_nic_access(trans); + spin_unlock_irqrestore(&trans->reg_lock, flags); + } else { /* target memory (SRAM) */ + _iwl_read_targ_mem_words(trans, addr, + priv->testmode_mem.buff_addr, + priv->testmode_mem.buff_size / 4); + } + + priv->testmode_mem.num_chunks = + DIV_ROUND_UP(priv->testmode_mem.buff_size, DUMP_CHUNK_SIZE); + priv->testmode_mem.read_in_progress = true; + return 0; + +} + +static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr, + u32 size, unsigned char *buf) +{ + struct iwl_trans *trans = trans(priv); + u32 val, i; + unsigned long flags; + + if (IWL_TM_ABS_PRPH_START <= addr && + addr < IWL_TM_ABS_PRPH_START + PRPH_END) { + /* Periphery writes can be 1-3 bytes long, or DWORDs */ + if (size < 4) { + memcpy(&val, buf, size); + spin_lock_irqsave(&trans->reg_lock, flags); + iwl_grab_nic_access(trans); + iwl_write32(trans, HBUS_TARG_PRPH_WADDR, + (addr & 0x0000FFFF) | (size << 24)); + iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val); + iwl_release_nic_access(trans); + /* needed after consecutive writes w/o read */ + mmiowb(); + spin_unlock_irqrestore(&trans->reg_lock, flags); + } else { + if (size % 4) + return -EINVAL; + for (i = 0; i < size; i += 4) + iwl_write_prph(trans, addr+i, + *(u32 *)buf+i); + } + } else if (iwlagn_hw_valid_rtc_data_addr(addr) || + (IWLAGN_RTC_INST_LOWER_BOUND <= addr && + addr < IWLAGN_RTC_INST_UPPER_BOUND)) { + _iwl_write_targ_mem_words(trans, addr, buf, size/4); + } else + return -EINVAL; + return 0; +} + /* * This function handles the user application commands for SRAM data dump * @@ -764,82 +822,60 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) * @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) +static int iwl_testmode_indirect_mem(struct ieee80211_hw *hw, + struct nlattr **tb) { struct iwl_priv *priv = hw->priv; - u32 ofs, size, maxsize; + u32 addr, size, cmd; + unsigned char *buf; - if (priv->testmode_sram.sram_readed) + /* Both read and write should be blocked, for atomicity */ + if (priv->testmode_mem.read_in_progress) return -EBUSY; - if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { - IWL_ERR(priv, "Missing SRAM offset address\n"); + cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); + if (!tb[IWL_TM_ATTR_MEM_ADDR]) { + IWL_ERR(priv, "Error finding memory offset address\n"); return -ENOMSG; } - ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); - if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { - IWL_ERR(priv, "Missing size for SRAM reading\n"); + addr = nla_get_u32(tb[IWL_TM_ATTR_MEM_ADDR]); + if (!tb[IWL_TM_ATTR_BUFFER_SIZE]) { + IWL_ERR(priv, "Error finding size for memory reading\n"); return -ENOMSG; } - size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); - switch (priv->shrd->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_ERR(priv, "uCode does not been loaded\n"); - return -ENOSYS; - default: - IWL_ERR(priv, "unsupported uCode type\n"); - return -ENOSYS; - } - if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) { - IWL_ERR(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_ERR(priv, "Memory allocation fail\n"); - return -ENOMEM; + size = nla_get_u32(tb[IWL_TM_ATTR_BUFFER_SIZE]); + + if (cmd == IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ) + return iwl_testmode_indirect_read(priv, addr, size); + else { + if (!tb[IWL_TM_ATTR_BUFFER_DUMP]) + return -EINVAL; + buf = (unsigned char *) nla_data(tb[IWL_TM_ATTR_BUFFER_DUMP]); + return iwl_testmode_indirect_write(priv, addr, size, buf); } - _iwl_read_targ_mem_words(trans(priv), 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, +static int iwl_testmode_buffer_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) { + if (priv->testmode_mem.read_in_progress) { idx = cb->args[4]; - if (idx >= priv->testmode_sram.num_chunks) { - iwl_sram_cleanup(priv); + if (idx >= priv->testmode_mem.num_chunks) { + iwl_mem_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 % + if (((idx + 1) == priv->testmode_mem.num_chunks) && + (priv->testmode_mem.buff_size % DUMP_CHUNK_SIZE)) + length = priv->testmode_mem.buff_size % DUMP_CHUNK_SIZE; - NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, - priv->testmode_sram.buff_addr + + NLA_PUT(skb, IWL_TM_ATTR_BUFFER_DUMP, length, + priv->testmode_mem.buff_addr + (DUMP_CHUNK_SIZE * idx)); idx++; cb->args[4] = idx; @@ -900,8 +936,6 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) 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; @@ -931,9 +965,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); + case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ: + case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE: + IWL_DEBUG_INFO(priv, "testmode indirect memory cmd " + "to driver\n"); + result = iwl_testmode_indirect_mem(hw, tb); break; default: @@ -983,9 +1019,9 @@ 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: + case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP: IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); - result = iwl_testmode_sram_dump(hw, tb, skb, cb); + result = iwl_testmode_buffer_dump(hw, tb, skb, cb); break; default: result = -EINVAL; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index f97d06169b45..3815cf372f2b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -109,20 +109,19 @@ * 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 application to indirectly access peripheral register - * - * @IWL_TM_CMD_APP2DEV_READ_SRAM: - * @IWL_TM_CMD_APP2DEV_DUMP_SRAM: - * commands from user application to read data in sram - * * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Wake 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 * @IWL_TM_CMD_APP2DEV_GET_FW_INFO: * retrieve information of existing loaded uCode image * + * @IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ: + * @IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP: + * @IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE: + * Commands to read/write data from periphery or SRAM memory ranges. + * Fore reading, a READ command is sent from the userspace and the data + * is returned when the user calls a DUMP command. + * For writing, only a WRITE command is used. */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, @@ -142,15 +141,18 @@ 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_APP2DEV_INDIRECT_REG_READ32 = 18, - IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 = 19, - IWL_TM_CMD_APP2DEV_READ_SRAM = 20, - IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, + RESERVED_18 = 18, + RESERVED_19 = 19, + RESERVED_20 = 20, + RESERVED_21 = 21, IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23, IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24, IWL_TM_CMD_APP2DEV_GET_FW_INFO = 25, - IWL_TM_CMD_MAX = 26, + IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ = 26, + IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP = 27, + IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE = 28, + IWL_TM_CMD_MAX = 29, }; /* @@ -221,16 +223,19 @@ enum iwl_tm_cmd_t { * 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, + * @IWL_TM_ATTR_MEM_ADDR: + * @IWL_TM_ATTR_BUFFER_SIZE: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ + * or IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE. * 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_MEM_ADDR for the address in SRAM/periphery to read/write + * IWL_TM_ATTR_BUFFER_SIZE for the buffer size of data to read/write. * - * @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 + * @IWL_TM_ATTR_BUFFER_DUMP: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP, + * IWL_TM_ATTR_BUFFER_DUMP is used for the data that was read. + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE, + * this attribute contains the data to write. * * @IWL_TM_ATTR_FW_VERSION: * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_VERSION, @@ -266,9 +271,9 @@ 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_SRAM_ADDR = 15, - IWL_TM_ATTR_SRAM_SIZE = 16, - IWL_TM_ATTR_SRAM_DUMP = 17, + IWL_TM_ATTR_MEM_ADDR = 15, + IWL_TM_ATTR_BUFFER_SIZE = 16, + IWL_TM_ATTR_BUFFER_DUMP = 17, IWL_TM_ATTR_FW_VERSION = 18, IWL_TM_ATTR_DEVICE_ID = 19, IWL_TM_ATTR_FW_TYPE = 20, -- GitLab From cdfef6c224f9490215cadd91b34c579757a6e59d Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Tue, 31 Jan 2012 15:30:39 +0200 Subject: [PATCH 0838/1846] iwlwifi: added reply data to testmode HCMD send The testmode command for host command send now replies with a nl80211 message and the response it recieved from the device. This does not change the API directly, but adds a reply to the testmode call. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 59 ++++++++++++++++++--- drivers/net/wireless/iwlwifi/iwl-testmode.h | 11 ++-- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index debc9ababbfa..e54a1dd7014a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -236,6 +236,7 @@ void iwl_testmode_cleanup(struct iwl_priv *priv) iwl_mem_cleanup(priv); } + /* * This function handles the user application commands to the ucode. * @@ -244,8 +245,10 @@ void iwl_testmode_cleanup(struct iwl_priv *priv) * 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. + * application; otherwise, waits for the host command to be sent and checks + * the return code. In case or error, it is returned, otherwise a reply is + * allocated and the reply RX packet + * is returned. * * @hw: ieee80211_hw object that represents the device * @tb: gnl message fields from the user space @@ -254,6 +257,12 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) { struct iwl_priv *priv = hw->priv; struct iwl_host_cmd cmd; + struct iwl_rx_packet *pkt; + struct sk_buff *skb; + void *reply_buf; + u32 reply_len; + int ret; + bool cmd_want_skb; memset(&cmd, 0, sizeof(struct iwl_host_cmd)); @@ -263,15 +272,53 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) return -ENOMSG; } - cmd.flags = CMD_ON_DEMAND; + cmd.flags = CMD_ON_DEMAND | CMD_SYNC; + cmd_want_skb = nla_get_flag(tb[IWL_TM_ATTR_UCODE_CMD_SKB]); + if (cmd_want_skb) + cmd.flags |= CMD_WANT_SKB; + 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," + IWL_DEBUG_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); + + ret = iwl_trans_send_cmd(trans(priv), &cmd); + if (ret) { + IWL_ERR(priv, "Failed to send hcmd\n"); + return ret; + } + if (!cmd_want_skb) + return ret; + + /* Handling return of SKB to the user */ + pkt = (struct iwl_rx_packet *)cmd.reply_page; + if (!pkt) { + IWL_ERR(priv, "HCMD received a null response packet\n"); + return ret; + } + + reply_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, reply_len + 20); + reply_buf = kmalloc(reply_len, GFP_KERNEL); + if (!skb || !reply_buf) { + kfree_skb(skb); + kfree(reply_buf); + return -ENOMEM; + } + + /* The reply is in a page, that we cannot send to user space. */ + memcpy(reply_buf, &(pkt->u), reply_len); + iwl_free_pages(priv->shrd, cmd.reply_page); + + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); + NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf); + return cfg80211_testmode_reply(skb); + +nla_put_failure: + IWL_DEBUG_INFO(priv, "Failed creating NL attributes\n"); + return -ENOMSG; } diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 3815cf372f2b..69b2e80f4071 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -99,7 +99,7 @@ * to user application * @IWL_TM_CMD_DEV2APP_UCODE_RX_PKT: * commands from kernel space to multicast the spontaneous messages - * to user application + * to user application, or reply of host commands * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: * commands from kernel space to carry the eeprom response * to user application @@ -173,8 +173,6 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE, * The mandatory fields are : * IWL_TM_ATTR_UCODE_CMD_ID for recognizable command ID; - * IWL_TM_ATTR_COMMAND_FLAG for the flags of the commands; - * The optional fields are: * IWL_TM_ATTR_UCODE_CMD_DATA for the actual command payload * to the ucode * @@ -254,6 +252,10 @@ enum iwl_tm_cmd_t { * IWL_TM_ATTR_FW_INST_SIZE for the size of instruction section * IWL_TM_ATTR_FW_DATA_SIZE for the size of data section * + * @IWL_TM_ATTR_UCODE_CMD_SKB: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE this flag + * indicates that the user wants to receive the response of the command + * in a reply SKB. If it's not present, the response is not returned. */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -279,7 +281,8 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_FW_TYPE = 20, IWL_TM_ATTR_FW_INST_SIZE = 21, IWL_TM_ATTR_FW_DATA_SIZE = 22, - IWL_TM_ATTR_MAX = 23, + IWL_TM_ATTR_UCODE_CMD_SKB = 23, + IWL_TM_ATTR_MAX = 24, }; /* uCode trace buffer */ -- GitLab From 2655e314c4b204966008689eaf3e87ba1f38d55c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 31 Jan 2012 21:08:37 -0800 Subject: [PATCH 0839/1846] iwlwifi: trace debug messages Make iwlwifi record all debug messages into tracing, even if debug_level is not enabled. Due to the lack of APIs, the debug messages are now recorded up to a max length of 100, the only one above that is the RXON which is not needed if you trace the commands as well as it only dumps the command contents. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi W Guy --- drivers/net/wireless/iwlwifi/Makefile | 2 +- drivers/net/wireless/iwlwifi/iwl-debug.c | 127 ++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-debug.h | 83 ++++++------- drivers/net/wireless/iwlwifi/iwl-devtrace.h | 65 ++++++++++ 4 files changed, 235 insertions(+), 42 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-debug.c diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index 9dc84a7354db..46622a0f017b 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-ucode.o iwl-agn-tx.o +iwlwifi-objs += iwl-ucode.o iwl-agn-tx.o iwl-debug.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-debug.c b/drivers/net/wireless/iwlwifi/iwl-debug.c new file mode 100644 index 000000000000..4bc2e70051d6 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-debug.c @@ -0,0 +1,127 @@ +/****************************************************************************** + * + * 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) 2007 - 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 "iwl-debug.h" + +#define __iwl_fn(fn) \ +void __iwl_ ##fn(struct device *dev, const char *fmt, ...) \ +{ \ + struct va_format vaf = { \ + .fmt = fmt, \ + }; \ + va_list args; \ + \ + va_start(args, fmt); \ + vaf.va = &args; \ + dev_ ##fn(dev, "%pV", &vaf); \ + trace_iwlwifi_ ##fn(&vaf); \ + va_end(args); \ +} + +__iwl_fn(warn) +__iwl_fn(info) +__iwl_fn(crit) + +void __iwl_err(struct device *dev, bool rfkill_prefix, bool trace_only, + const char *fmt, ...) +{ + struct va_format vaf = { + .fmt = fmt, + }; + va_list args; + + va_start(args, fmt); + vaf.va = &args; + if (!trace_only) { + if (rfkill_prefix) + dev_err(dev, "(RFKILL) %pV", &vaf); + else + dev_err(dev, "%pV", &vaf); + } + trace_iwlwifi_err(&vaf); + va_end(args); +} + +#if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING) +void __iwl_dbg(struct iwl_shared *shared, struct device *dev, + u32 level, bool limit, const char *function, + const char *fmt, ...) +{ + struct va_format vaf = { + .fmt = fmt, + }; + va_list args; + + va_start(args, fmt); + vaf.va = &args; +#ifdef CONFIG_IWLWIFI_DEBUG + if (iwl_get_debug_level(shared) & level && + (!limit || net_ratelimit())) + dev_err(dev, "%c %s %pV", in_interrupt() ? 'I' : 'U', + function, &vaf); +#endif + trace_iwlwifi_dbg(level, in_interrupt(), function, &vaf); + va_end(args); +} +#endif diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 351b41d7f4fd..bfc08494ed22 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -31,14 +31,33 @@ #include "iwl-bus.h" #include "iwl-shared.h" +#include "iwl-devtrace.h" struct iwl_priv; -/*No matter what is m (priv, bus, trans), this will work */ -#define IWL_ERR(m, f, a...) dev_err(trans(m)->dev, f, ## a) -#define IWL_WARN(m, f, a...) dev_warn(trans(m)->dev, f, ## a) -#define IWL_INFO(m, f, a...) dev_info(trans(m)->dev, f, ## a) -#define IWL_CRIT(m, f, a...) dev_crit(trans(m)->dev, f, ## a) +void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace, + const char *fmt, ...); +void __iwl_warn(struct device *dev, const char *fmt, ...); +void __iwl_info(struct device *dev, const char *fmt, ...); +void __iwl_crit(struct device *dev, const char *fmt, ...); + +/* No matter what is m (priv, bus, trans), this will work */ +#define IWL_ERR(m, f, a...) __iwl_err(trans(m)->dev, false, false, f, ## a) +#define IWL_WARN(m, f, a...) __iwl_warn(trans(m)->dev, f, ## a) +#define IWL_INFO(m, f, a...) __iwl_info(trans(m)->dev, f, ## a) +#define IWL_CRIT(m, f, a...) __iwl_crit(trans(m)->dev, f, ## a) + +#if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING) +void __iwl_dbg(struct iwl_shared *shared, struct device *dev, + u32 level, bool limit, const char *function, + const char *fmt, ...); +#else +static inline void +__iwl_dbg(struct iwl_shared *shared, struct device *dev, + u32 level, bool limit, const char *function, + const char *fmt, ...) +{} +#endif #define iwl_print_hex_error(m, p, len) \ do { \ @@ -46,53 +65,35 @@ do { \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) -#ifdef CONFIG_IWLWIFI_DEBUG -#define IWL_DEBUG(m, level, fmt, ...) \ -do { \ - if (iwl_get_debug_level((m)->shrd) & (level)) \ - dev_err(trans(m)->dev, "%c %s " fmt, \ - in_interrupt() ? 'I' : 'U', __func__, \ - ##__VA_ARGS__); \ -} while (0) - -#define IWL_DEBUG_LIMIT(m, level, fmt, ...) \ -do { \ - if (iwl_get_debug_level((m)->shrd) & (level) && \ - net_ratelimit()) \ - dev_err(trans(m)->dev, "%c %s " fmt, \ - in_interrupt() ? 'I' : 'U', __func__, \ - ##__VA_ARGS__); \ -} while (0) +#define IWL_DEBUG(m, level, fmt, args...) \ + __iwl_dbg((m)->shrd, trans(m)->dev, level, false, __func__, fmt, ##args) +#define IWL_DEBUG_LIMIT(m, level, fmt, args...) \ + __iwl_dbg((m)->shrd, trans(m)->dev, level, true, __func__, fmt, ##args) +#ifdef CONFIG_IWLWIFI_DEBUG #define iwl_print_hex_dump(m, level, p, len) \ do { \ if (iwl_get_debug_level((m)->shrd) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) - -#define IWL_DEBUG_QUIET_RFKILL(p, fmt, ...) \ +#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ do { \ - if (!iwl_is_rfkill(p->shrd)) \ - dev_err(trans(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(trans(p)->dev, "%s%c %s " fmt, \ - "(RFKILL) ", \ - in_interrupt() ? 'I' : 'U', __func__, \ - ##__VA_ARGS__); \ + if (!iwl_is_rfkill((m)->shrd)) \ + IWL_ERR(m, fmt, ##args); \ + else \ + __iwl_err(trans(m)->dev, true, \ + !(iwl_get_debug_level((m)->shrd) & IWL_DL_RADIO),\ + fmt, ##args); \ } while (0) - #else -#define IWL_DEBUG(m, level, fmt, args...) -#define IWL_DEBUG_LIMIT(m, level, fmt, args...) #define iwl_print_hex_dump(m, level, p, len) -#define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ -do { \ - if (!iwl_is_rfkill(p->shrd)) \ - IWL_ERR(p, fmt, ##args); \ +#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ +do { \ + if (!iwl_is_rfkill((m)->shrd)) \ + IWL_ERR(m, fmt, ##args); \ + else \ + __iwl_err(trans(m)->dev, true, true, fmt, ##args); \ } while (0) #endif /* CONFIG_IWLWIFI_DEBUG */ diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h index 4d892211ce4c..96e62338cec0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h @@ -34,6 +34,11 @@ #undef TRACE_EVENT #define TRACE_EVENT(name, proto, ...) \ static inline void trace_ ## name(proto) {} +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(...) +#undef DEFINE_EVENT +#define DEFINE_EVENT(evt_class, name, proto, ...) \ +static inline void trace_ ## name(proto) {} #endif #define PRIV_ENTRY __field(void *, priv) @@ -163,6 +168,66 @@ TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, __entry->p_entry) ); +#undef TRACE_SYSTEM +#define TRACE_SYSTEM iwlwifi_msg + +#define MAX_MSG_LEN 100 + +DECLARE_EVENT_CLASS(iwlwifi_msg_event, + TP_PROTO(struct va_format *vaf), + TP_ARGS(vaf), + TP_STRUCT__entry( + __dynamic_array(char, msg, MAX_MSG_LEN) + ), + TP_fast_assign( + WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), + MAX_MSG_LEN, vaf->fmt, + *vaf->va) >= MAX_MSG_LEN); + ), + TP_printk("%s", (char *)__get_dynamic_array(msg)) +); + +DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_err, + TP_PROTO(struct va_format *vaf), + TP_ARGS(vaf) +); + +DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_warn, + TP_PROTO(struct va_format *vaf), + TP_ARGS(vaf) +); + +DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_info, + TP_PROTO(struct va_format *vaf), + TP_ARGS(vaf) +); + +DEFINE_EVENT(iwlwifi_msg_event, iwlwifi_crit, + TP_PROTO(struct va_format *vaf), + TP_ARGS(vaf) +); + +TRACE_EVENT(iwlwifi_dbg, + TP_PROTO(u32 level, bool in_interrupt, const char *function, + struct va_format *vaf), + TP_ARGS(level, in_interrupt, function, vaf), + TP_STRUCT__entry( + __field(u32, level) + __field(u8, in_interrupt) + __string(function, function) + __dynamic_array(char, msg, MAX_MSG_LEN) + ), + TP_fast_assign( + __entry->level = level; + __entry->in_interrupt = in_interrupt; + __assign_str(function, function); + WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg), + MAX_MSG_LEN, vaf->fmt, + *vaf->va) >= MAX_MSG_LEN); + ), + TP_printk("%s", (char *)__get_dynamic_array(msg)) +); + #undef TRACE_SYSTEM #define TRACE_SYSTEM iwlwifi -- GitLab From 1ee158d83853a9f5c1465be56d56ff56e6698e92 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 17 Feb 2012 10:07:44 -0800 Subject: [PATCH 0840/1846] iwlwifi: move workqueue to priv In order to separate the different parts of the driver better, we are reducing the shared data. This moves the workqueue to "priv", and removes it from the transport. To do this, simply use schedule_work() in the transport. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 6 +++--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 14 +++++++------- drivers/net/wireless/iwlwifi/iwl-core.c | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-scan.c | 10 +++++----- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 10 ++-------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 ++ 13 files changed, 29 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index a8f7689aaacf..30b99b9abf7f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -700,7 +700,7 @@ static void iwlagn_set_kill_msk(struct iwl_priv *priv, priv->kill_cts_mask = bt_kill_cts_msg[kill_msk]; /* schedule to send runtime bt_config */ - queue_work(priv->shrd->workqueue, &priv->bt_runtime_config); + queue_work(priv->workqueue, &priv->bt_runtime_config); } } @@ -745,7 +745,7 @@ int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, IWL_BT_COEX_TRAFFIC_LOAD_NONE; } priv->bt_status = coex->bt_status; - queue_work(priv->shrd->workqueue, + queue_work(priv->workqueue, &priv->bt_traffic_change_work); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index b9ba404d15c1..f88e2e33e2e8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -892,7 +892,7 @@ static void rs_bt_update_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); - queue_work(priv->shrd->workqueue, &priv->bt_full_concurrency); + queue_work(priv->workqueue, &priv->bt_full_concurrency); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index a14ddab783ea..aee7d060d317 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -581,7 +581,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, if (unlikely(!test_bit(STATUS_SCANNING, &priv->shrd->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { iwlagn_rx_calc_noise(priv); - queue_work(priv->shrd->workqueue, &priv->run_time_calib_work); + queue_work(priv->workqueue, &priv->run_time_calib_work); } if (cfg(priv)->lib->temperature && change) cfg(priv)->lib->temperature(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index c728ed75584e..56d7c0e38163 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -568,7 +568,7 @@ void iwl_tt_enter_ct_kill(struct iwl_priv *priv) return; IWL_DEBUG_TEMP(priv, "Queueing critical temperature enter.\n"); - queue_work(priv->shrd->workqueue, &priv->ct_enter); + queue_work(priv->workqueue, &priv->ct_enter); } void iwl_tt_exit_ct_kill(struct iwl_priv *priv) @@ -577,7 +577,7 @@ void iwl_tt_exit_ct_kill(struct iwl_priv *priv) return; IWL_DEBUG_TEMP(priv, "Queueing critical temperature exit.\n"); - queue_work(priv->shrd->workqueue, &priv->ct_exit); + queue_work(priv->workqueue, &priv->ct_exit); } static void iwl_bg_tt_work(struct work_struct *work) @@ -600,7 +600,7 @@ void iwl_tt_handler(struct iwl_priv *priv) return; IWL_DEBUG_TEMP(priv, "Queueing thermal throttling work.\n"); - queue_work(priv->shrd->workqueue, &priv->tt_work); + queue_work(priv->workqueue, &priv->tt_work); } /* Thermal throttling initialization diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 64f8db685dc5..da18a8fc9af7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -983,7 +983,7 @@ static void iwl_check_abort_status(struct iwl_priv *priv, if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { IWL_ERR(priv, "Tx flush command to flush out all frames\n"); if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - queue_work(priv->shrd->workqueue, &priv->tx_flush); + queue_work(priv->workqueue, &priv->tx_flush); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8837171ad553..1cf99a586ec9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -939,7 +939,7 @@ static void iwlagn_disable_roc_work(struct work_struct *work) static void iwl_setup_deferred_work(struct iwl_priv *priv) { - priv->shrd->workqueue = create_singlethread_workqueue(DRV_NAME); + priv->workqueue = create_singlethread_workqueue(DRV_NAME); init_waitqueue_head(&priv->shrd->wait_command_queue); @@ -1282,8 +1282,8 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, return 0; out_destroy_workqueue: - destroy_workqueue(priv->shrd->workqueue); - priv->shrd->workqueue = NULL; + destroy_workqueue(priv->workqueue); + priv->workqueue = NULL; iwl_uninit_drv(priv); out_free_eeprom: iwl_eeprom_free(priv->shrd); @@ -1321,13 +1321,13 @@ void __devexit iwl_remove(struct iwl_priv * priv) iwl_eeprom_free(priv->shrd); /*netif_stop_queue(dev); */ - flush_workqueue(priv->shrd->workqueue); + flush_workqueue(priv->workqueue); /* ieee80211_unregister_hw calls iwlagn_mac_stop, which flushes - * priv->shrd->workqueue... so we can't take down the workqueue + * priv->workqueue... so we can't take down the workqueue * until now... */ - destroy_workqueue(priv->shrd->workqueue); - priv->shrd->workqueue = NULL; + destroy_workqueue(priv->workqueue); + priv->workqueue = NULL; iwl_free_traffic_mem(priv); iwl_uninit_drv(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 0677b3dfbfb2..6dff9c41c555 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -875,7 +875,7 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) if (iwlagn_mod_params.restart_fw) { IWL_DEBUG_FW_ERRORS(priv, "Restarting adapter due to uCode error.\n"); - queue_work(priv->shrd->workqueue, &priv->restart); + queue_work(priv->workqueue, &priv->restart); } else IWL_DEBUG_FW_ERRORS(priv, "Detected FW error, but not restarting\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 0e8f13705dbe..db37877eed77 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -721,6 +721,8 @@ struct iwl_priv { struct ieee80211_rate *ieee_rates; struct kmem_cache *tx_cmd_pool; + struct workqueue_struct *workqueue; + enum ieee80211_band band; void (*pre_rx_handler)(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index d8025fee7e0d..17358cfb68a9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -343,7 +343,7 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw) iwl_down(priv); - flush_workqueue(priv->shrd->workqueue); + flush_workqueue(priv->workqueue); /* User space software may expect getting rfkill changes * even if interface is down, trans->down will leave the RF @@ -1117,7 +1117,7 @@ static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, { struct iwl_priv *priv = hw->priv; - queue_work(priv->shrd->workqueue, &priv->beacon_update); + queue_work(priv->workqueue, &priv->beacon_update); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 7f2e3a1c80ef..42ee1c410efd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -218,7 +218,7 @@ static void iwl_do_scan_abort(struct iwl_priv *priv) int iwl_scan_cancel(struct iwl_priv *priv) { IWL_DEBUG_SCAN(priv, "Queuing abort scan\n"); - queue_work(priv->shrd->workqueue, &priv->abort_scan); + queue_work(priv->workqueue, &priv->abort_scan); return 0; } @@ -354,7 +354,7 @@ static int iwl_rx_scan_complete_notif(struct iwl_priv *priv, */ set_bit(STATUS_SCAN_COMPLETE, &priv->shrd->status); clear_bit(STATUS_SCAN_HW, &priv->shrd->status); - queue_work(priv->shrd->workqueue, &priv->scan_completed); + queue_work(priv->workqueue, &priv->scan_completed); if (priv->iw_mode != NL80211_IFTYPE_ADHOC && iwl_advanced_bt_coexist(priv) && @@ -374,7 +374,7 @@ static int iwl_rx_scan_complete_notif(struct iwl_priv *priv, IWL_BT_COEX_TRAFFIC_LOAD_NONE; } priv->bt_status = scan_notif->bt_status; - queue_work(priv->shrd->workqueue, + queue_work(priv->workqueue, &priv->bt_traffic_change_work); } return 0; @@ -950,7 +950,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, return ret; } - queue_delayed_work(priv->shrd->workqueue, &priv->scan_check, + queue_delayed_work(priv->workqueue, &priv->scan_check, IWL_SCAN_CHECK_WATCHDOG); return 0; @@ -963,7 +963,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, */ void iwl_internal_short_hw_scan(struct iwl_priv *priv) { - queue_work(priv->shrd->workqueue, &priv->start_internal_scan); + queue_work(priv->workqueue, &priv->start_internal_scan); } static void iwl_bg_start_internal_scan(struct work_struct *work) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 63d4a4fc5b9e..42bf43b9c406 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -359,7 +359,6 @@ struct iwl_cfg { * @priv: pointer to the upper layer data * @trans: pointer to the transport layer data * @hw_params: see struct iwl_hw_params - * @workqueue: the workqueue used by all the layers of the driver * @lock: protect general shared data * @sta_lock: protects the station table. * If lock and sta_lock are needed, lock must be acquired first. @@ -391,7 +390,6 @@ struct iwl_shared { struct iwl_trans *trans; struct iwl_hw_params hw_params; - struct workqueue_struct *workqueue; spinlock_t lock; spinlock_t sta_lock; struct mutex mutex; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 3826852ec5f0..1b11cfec5da6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -227,7 +227,7 @@ static void iwlagn_rx_queue_restock(struct iwl_trans *trans) /* If the pre-allocated buffer pool is dropping low, schedule to * refill it */ if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(trans->shrd->workqueue, &trans_pcie->rx_replenish); + schedule_work(&trans_pcie->rx_replenish); /* If we've added more space for the firmware to place data, tell it. @@ -351,14 +351,8 @@ void iwl_bg_rx_replenish(struct work_struct *data) { struct iwl_trans_pcie *trans_pcie = container_of(data, struct iwl_trans_pcie, rx_replenish); - struct iwl_trans *trans = trans_pcie->trans; - if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status)) - return; - - mutex_lock(&trans->shrd->mutex); - iwlagn_rx_replenish(trans); - mutex_unlock(&trans->shrd->mutex); + iwlagn_rx_replenish(trans_pcie->trans); } /** diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index f5cb5d3cd926..e8d1dbfa1aea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1293,6 +1293,8 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) synchronize_irq(trans->irq); tasklet_kill(&trans_pcie->irq_tasklet); + cancel_work_sync(&trans_pcie->rx_replenish); + /* stop and reset the on-board processor */ iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); } -- GitLab From 7b11488fbbbe06ada39a396dec16532db8c933e6 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 5 Feb 2012 13:55:11 -0800 Subject: [PATCH 0841/1846] iwlwifi: give PCIe its own lock Instead of using a global lock, the PCIe transport can use an own lock for its IRQ. This will make it possible to not disable IRQs for the shared lock. The lock is currently used throughout the code but this can be improved even further by splitting up the locking for the queues. Signed-off-by: Johannes Berg Reviewed-by: Wey-Yi W Guy --- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 1 + .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 29 ++++++++------- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 4 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 37 +++++++++++-------- 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 561865f29d56..8c30fea8c2b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -230,6 +230,7 @@ struct iwl_trans_pcie { struct tasklet_struct irq_tasklet; struct isr_statistics isr_stats; + spinlock_t irq_lock; u32 inta_mask; u32 scd_base_addr; struct iwl_dma_ptr scd_bc_tbls; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 1b11cfec5da6..e06342656cea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -331,13 +331,14 @@ static void iwlagn_rx_allocate(struct iwl_trans *trans, gfp_t priority) void iwlagn_rx_replenish(struct iwl_trans *trans) { + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); unsigned long flags; iwlagn_rx_allocate(trans, GFP_KERNEL); - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); iwlagn_rx_queue_restock(trans); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); } static void iwlagn_rx_replenish_now(struct iwl_trans *trans) @@ -943,7 +944,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) struct isr_statistics *isr_stats = &trans_pcie->isr_stats; - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, @@ -973,7 +974,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) /* saved interrupt in inta variable now we can reset trans_pcie->inta */ trans_pcie->inta = 0; - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { @@ -1226,7 +1227,7 @@ void iwl_reset_ict(struct iwl_trans *trans) if (!trans_pcie->ict_tbl) return; - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); iwl_disable_interrupts(trans); memset(trans_pcie->ict_tbl, 0, ICT_SIZE); @@ -1243,7 +1244,7 @@ void iwl_reset_ict(struct iwl_trans *trans) trans_pcie->ict_index = 0; iwl_write32(trans, CSR_INT, trans_pcie->inta_mask); iwl_enable_interrupts(trans); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); } /* Device is going down disable ict interrupt usage */ @@ -1254,9 +1255,9 @@ void iwl_disable_ict(struct iwl_trans *trans) unsigned long flags; - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); trans_pcie->use_ict = false; - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); } static irqreturn_t iwl_isr(int irq, void *data) @@ -1275,7 +1276,7 @@ static irqreturn_t iwl_isr(int irq, void *data) trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); /* Disable (but don't clear!) interrupts here to avoid * back-to-back ISRs and sporadic interrupts from our NIC. @@ -1319,7 +1320,7 @@ static irqreturn_t iwl_isr(int irq, void *data) iwl_enable_interrupts(trans); unplugged: - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); return IRQ_HANDLED; none: @@ -1329,7 +1330,7 @@ static irqreturn_t iwl_isr(int irq, void *data) !trans_pcie->inta) iwl_enable_interrupts(trans); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); return IRQ_NONE; } @@ -1363,7 +1364,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) trace_iwlwifi_dev_irq(priv(trans)); - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); /* Disable (but don't clear!) interrupts here to avoid * back-to-back ISRs and sporadic interrupts from our NIC. @@ -1434,7 +1435,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) iwl_enable_interrupts(trans); } - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); return IRQ_HANDLED; none: @@ -1445,6 +1446,6 @@ irqreturn_t iwl_isr_ict(int irq, void *data) !trans_pcie->inta) iwl_enable_interrupts(trans); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); return IRQ_NONE; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 08e0a7da48a9..a3cebd76dc0c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -492,7 +492,7 @@ void iwl_trans_pcie_tx_agg_setup(struct iwl_trans *trans, ra_tid = BUILD_RAxTID(sta_id, tid); - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); /* Stop this Tx queue before configuring it */ iwlagn_tx_queue_stop_scheduler(trans, txq_id); @@ -532,7 +532,7 @@ void iwl_trans_pcie_tx_agg_setup(struct iwl_trans *trans, trans_pcie->txq[txq_id].sta_id = sta_id; trans_pcie->txq[txq_id].tid = tid; - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); } /* diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index e8d1dbfa1aea..176063c4f781 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -219,10 +219,10 @@ static int iwl_rx_init(struct iwl_trans *trans) iwl_trans_rx_hw_init(trans, rxq); - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); rxq->need_update = 1; iwl_rx_queue_update_write_ptr(trans, rxq); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); return 0; } @@ -585,7 +585,7 @@ static int iwl_tx_init(struct iwl_trans *trans) alloc = true; } - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); /* Turn off all Tx DMA fifos */ iwl_write_prph(trans, SCD_TXFACT, 0); @@ -594,7 +594,7 @@ static int iwl_tx_init(struct iwl_trans *trans) iwl_write_direct32(trans, FH_KW_MEM_ADDR_REG, trans_pcie->kw.dma >> 4); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { @@ -803,17 +803,18 @@ static void iwl_apm_stop(struct iwl_trans *trans) static int iwl_nic_init(struct iwl_trans *trans) { + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); unsigned long flags; /* nic_init */ - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); iwl_apm_init(trans); /* Set interrupt coalescing calibration timer to default (512 usecs) */ iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); iwl_set_pwr_vmain(trans); @@ -1078,10 +1079,15 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw) /* * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask - * must be called under priv->shrd->lock and mac access + * must be called under the irq lock and with MAC access */ static void iwl_trans_txq_set_sched(struct iwl_trans *trans, u32 mask) { + struct iwl_trans_pcie __maybe_unused *trans_pcie = + IWL_TRANS_GET_PCIE_TRANS(trans); + + lockdep_assert_held(&trans_pcie->irq_lock); + iwl_write_prph(trans, SCD_TXFACT, mask); } @@ -1095,7 +1101,7 @@ static void iwl_tx_start(struct iwl_trans *trans) int i, chan; u32 reg_val; - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); trans_pcie->scd_base_addr = iwl_read_prph(trans, SCD_SRAM_BASE_ADDR); @@ -1191,7 +1197,7 @@ static void iwl_tx_start(struct iwl_trans *trans) fifo, 0); } - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* Enable L1-Active */ iwl_clear_bits_prph(trans, APMG_PCIDEV_STT_REG, @@ -1214,7 +1220,7 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); /* Turn off all Tx DMA fifos */ - spin_lock_irqsave(&trans->shrd->lock, flags); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); iwl_trans_txq_set_sched(trans, 0); @@ -1230,7 +1236,7 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans) iwl_read_direct32(trans, FH_TSSR_TX_STATUS_REG)); } - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); if (!trans_pcie->txq) { IWL_WARN(trans, "Stopping tx queues that aren't allocated..."); @@ -1250,9 +1256,9 @@ static void iwl_trans_pcie_stop_device(struct iwl_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); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); iwl_disable_interrupts(trans); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* device going down, Stop using ICT table */ iwl_disable_ict(trans); @@ -1285,9 +1291,9 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *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); + spin_lock_irqsave(&trans_pcie->irq_lock, flags); iwl_disable_interrupts(trans); - spin_unlock_irqrestore(&trans->shrd->lock, flags); + spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* wait to make sure we flush pending tasklet*/ synchronize_irq(trans->irq); @@ -2261,6 +2267,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, trans->shrd = shrd; trans_pcie->trans = trans; spin_lock_init(&trans->hcmd_lock); + spin_lock_init(&trans_pcie->irq_lock); /* W/A - seems to solve weird behavior. We need to remove this if we * don't want to stay in L1 all the time. This wastes a lot of power */ -- GitLab From b1c23d9ec3afb85bd299e4f3859dce555fd55c8a Mon Sep 17 00:00:00 2001 From: Don Fry Date: Tue, 7 Feb 2012 14:45:58 -0800 Subject: [PATCH 0842/1846] iwlwifi: create iwl_nic structure Create iwl_nic structure and link it together. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-pci.c | 18 +++++++++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 3 ++ drivers/net/wireless/iwlwifi/iwl-ucode.h | 37 +++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-wifi.h | 30 ++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 3e2fce4ce00c..519067020534 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -70,6 +70,7 @@ #include "iwl-trans.h" #include "iwl-csr.h" #include "iwl-cfg.h" +#include "iwl-wifi.h" #define IWL_PCI_DEVICE(dev, subdev, cfg) \ .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ @@ -282,13 +283,23 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) bus->shrd->bus = bus; + /* temporarily create this here */ + bus->shrd->nic = kzalloc(sizeof(*bus->shrd->nic), GFP_KERNEL); + if (!bus->shrd->nic) { + dev_printk(KERN_ERR, &pdev->dev, + "Couldn't allocate iwl_nic"); + err = -ENOMEM; + goto out_free_bus; + } + /* and initialize it as well, temporarily */ + bus->shrd->nic->shrd = bus->shrd; pci_set_drvdata(pdev, bus); #ifdef CONFIG_IWLWIFI_IDI trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { err = -ENOMEM; - goto out_free_bus; + goto out_free_nic; } err = iwl_probe(bus, &trans_ops_idi, cfg); @@ -296,7 +307,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { err = -ENOMEM; - goto out_free_bus; + goto out_free_nic; } err = iwl_probe(bus, &trans_ops_pcie, cfg); @@ -309,6 +320,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_free_trans: iwl_trans_free(trans(bus)); pci_set_drvdata(pdev, NULL); +out_free_nic: + kfree(bus->shrd->nic); out_free_bus: kfree(bus->shrd); kfree(bus); @@ -325,6 +338,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) pci_set_drvdata(pdev, NULL); + kfree(bus->shrd->nic); kfree(bus->shrd); kfree(bus); } diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 42bf43b9c406..8c6fc6e20768 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -358,6 +358,7 @@ struct iwl_cfg { * @cfg: see struct iwl_cfg * @priv: pointer to the upper layer data * @trans: pointer to the transport layer data + * @nic: pointer to the nic data * @hw_params: see struct iwl_hw_params * @lock: protect general shared data * @sta_lock: protects the station table. @@ -388,6 +389,7 @@ struct iwl_shared { struct iwl_cfg *cfg; struct iwl_priv *priv; struct iwl_trans *trans; + struct iwl_nic *nic; struct iwl_hw_params hw_params; spinlock_t lock; @@ -418,6 +420,7 @@ struct iwl_shared { #define priv(_m) ((_m)->shrd->priv) #define cfg(_m) ((_m)->shrd->cfg) #define bus(_m) ((_m)->shrd->bus) +#define nic(_m) ((_m)->shrd->nic) #define trans(_m) ((_m)->shrd->trans) #define hw_params(_m) ((_m)->shrd->hw_params) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-ucode.h index eccf92519a84..18c77e9bb9b0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.h +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.h @@ -63,6 +63,10 @@ #ifndef __iwl_ucode_h__ #define __iwl_ucode_h__ +#include "iwl-trans.h" + +#include + /* v1/v2 uCode file layout */ struct iwl_ucode_header { __le32 ver; /* major/minor/API/serial */ @@ -171,6 +175,39 @@ struct iwl_tlv_ucode_header { u8 data[0]; }; +struct iwl_ucode_capabilities { + u32 max_probe_length; + u32 standard_phy_calibration_size; + u32 flags; +}; + +/** + * struct iwl_fw - variables associated with the firmware + * + * @ucode_ver: ucode version from the ucode file + * @fw_version: firmware version string + * @ucode_rt: run time ucode image + * @ucode_init: init ucode image + * @ucode_wowlan: wake on wireless ucode image (optional) + * @ucode_capa: capabilities parsed from the ucode file. + * @enhance_sensitivity_table: device can do enhanced sensitivity. + */ +struct iwl_fw { + + /* ucode image and variables */ + u32 ucode_ver; /* version of ucode, copy of + iwl_ucode.ver */ + char fw_version[ETHTOOL_BUSINFO_LEN]; + + /* ucode images */ + struct fw_img ucode_rt; + struct fw_img ucode_init; + struct fw_img ucode_wowlan; + + struct iwl_ucode_capabilities ucode_capa; + bool enhance_sensitivity_table; +}; + struct iwl_priv; int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first); diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index 7e6eb20823cf..a34708d19380 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -64,6 +64,36 @@ #define __iwl_wifi_h__ #include "iwl-shared.h" +#include "iwl-ucode.h" + +/** + * struct iwl_nic - nic common data + * @fw: the iwl_fw structure + * @shrd: pointer to common shared structure + * @fw_index: firmware revision to try loading + * @firmware_name: composite filename of ucode file to load + * @init_evtlog_ptr: event log offset for init ucode. + * @init_evtlog_size: event log size for init ucode. + * @init_errlog_ptr: error log offfset for init ucode. + * @inst_evtlog_ptr: event log offset for runtime ucode. + * @inst_evtlog_size: event log size for runtime ucode. + * @inst_errlog_ptr: error log offfset for runtime ucode. + * @request_firmware_complete: the firmware has been obtained from user space + */ +struct iwl_nic { + struct iwl_fw fw; + + struct iwl_shared *shrd; + + int fw_index; /* firmware we're trying to load */ + char firmware_name[25]; /* name of firmware file to load */ + + u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; + u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; + + struct completion request_firmware_complete; +}; + int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); void iwl_send_prio_tbl(struct iwl_trans *trans); -- GitLab From d359667767e845d86f60a4ea6374ccb6b8fe0ce5 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 6 Feb 2012 15:51:15 -0800 Subject: [PATCH 0843/1846] iwlwifi: move ucode_ver to iwl_nic Delete ucode_ver from iwl_priv and use iwl_nic instead. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 3 --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 6 +++-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 29 ++++++++++++--------- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 30b99b9abf7f..c368433f8bc8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -77,7 +77,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv) tx_power_cmd.flags = IWLAGN_TX_POWER_NO_CLOSED; tx_power_cmd.srv_chan_lmt = IWLAGN_TX_POWER_AUTO; - if (IWL_UCODE_API(priv->ucode_ver) == 1) + if (IWL_UCODE_API(nic(priv)->fw.ucode_ver) == 1) tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD_V1; else tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 1cf99a586ec9..9e902f7e9d35 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -618,7 +618,7 @@ static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant) .valid = cpu_to_le32(valid_tx_ant), }; - if (IWL_UCODE_API(priv->ucode_ver) > 1) { + if (IWL_UCODE_API(nic(priv)->fw.ucode_ver) > 1) { IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant); return iwl_trans_send_cmd_pdu(trans(priv), TX_ANT_CONFIGURATION_CMD, diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index db37877eed77..f3dc67c8b3eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -789,9 +789,6 @@ 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 */ - char firmware_name[25]; struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index e54a1dd7014a..963cc6c89a46 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -553,14 +553,16 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: - IWL_INFO(priv, "uCode version raw: 0x%x\n", priv->ucode_ver); + IWL_INFO(priv, "uCode version raw: 0x%x\n", + nic(priv)->fw.ucode_ver); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); if (!skb) { IWL_ERR(priv, "Memory allocation fail\n"); return -ENOMEM; } - NLA_PUT_U32(skb, IWL_TM_ATTR_FW_VERSION, priv->ucode_ver); + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_VERSION, + nic(priv)->fw.ucode_ver); status = cfg80211_testmode_reply(skb); if (status < 0) IWL_ERR(priv, "Error sending msg : %d\n", status); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 11b659ab261d..ca3cd8a9046f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -738,12 +738,13 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, const struct firmware *ucode_raw, struct iwlagn_firmware_pieces *pieces) { + struct iwl_nic *nic = nic(priv); struct iwl_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); + nic->fw.ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IWL_UCODE_API(nic->fw.ucode_ver); switch (api_ver) { default: @@ -804,6 +805,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, struct iwlagn_firmware_pieces *pieces, struct iwlagn_ucode_capabilities *capa) { + struct iwl_nic *nic = nic(priv); struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; struct iwl_ucode_tlv *tlv; size_t len = ucode_raw->size; @@ -843,7 +845,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, "uCode alternative %d not available, choosing %d\n", tmp, wanted_alternative); - priv->ucode_ver = le32_to_cpu(ucode->ver); + nic->fw.ucode_ver = le32_to_cpu(ucode->ver); pieces->build = le32_to_cpu(ucode->build); data = ucode->data; @@ -1008,6 +1010,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) { struct iwl_priv *priv = context; + struct iwl_nic *nic = nic(priv); struct iwl_ucode_header *ucode; int err; struct iwlagn_firmware_pieces pieces; @@ -1057,7 +1060,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (err) goto try_again; - api_ver = IWL_UCODE_API(priv->ucode_ver); + api_ver = IWL_UCODE_API(nic->fw.ucode_ver); build = pieces.build; /* @@ -1097,19 +1100,19 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) buildstr[0] = '\0'; IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\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), + IWL_UCODE_MAJOR(nic->fw.ucode_ver), + IWL_UCODE_MINOR(nic->fw.ucode_ver), + IWL_UCODE_API(nic->fw.ucode_ver), + IWL_UCODE_SERIAL(nic->fw.ucode_ver), buildstr); snprintf(priv->hw->wiphy->fw_version, sizeof(priv->hw->wiphy->fw_version), "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver), + IWL_UCODE_MAJOR(nic->fw.ucode_ver), + IWL_UCODE_MINOR(nic->fw.ucode_ver), + IWL_UCODE_API(nic->fw.ucode_ver), + IWL_UCODE_SERIAL(nic->fw.ucode_ver), buildstr); /* @@ -1119,7 +1122,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) */ IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", - priv->ucode_ver); + nic->fw.ucode_ver); IWL_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", -- GitLab From f6fd51d9a5abc9aa90246ddc82bbca376c06462e Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 6 Feb 2012 15:54:31 -0800 Subject: [PATCH 0844/1846] iwlwifi: move fw_index from iwl_priv to iwl_nic Delete fw_index from iwl_priv and use iwl_nic instead. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - drivers/net/wireless/iwlwifi/iwl-ucode.c | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index f3dc67c8b3eb..008287f08d75 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -788,7 +788,6 @@ struct iwl_priv { struct mac_address addresses[2]; /* uCode images, save to reload in case of failure */ - int fw_index; /* firmware we're trying to load */ char firmware_name[25]; struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index ca3cd8a9046f..c3ac2cc7a795 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -690,23 +690,24 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) { + struct iwl_nic *nic = nic(priv); const char *name_pre = cfg(priv)->fw_name_pre; char tag[8]; if (first) { #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE - priv->fw_index = UCODE_EXPERIMENTAL_INDEX; + nic->fw_index = UCODE_EXPERIMENTAL_INDEX; strcpy(tag, UCODE_EXPERIMENTAL_TAG); - } else if (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) { + } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { #endif - priv->fw_index = cfg(priv)->ucode_api_max; - sprintf(tag, "%d", priv->fw_index); + nic->fw_index = cfg(priv)->ucode_api_max; + sprintf(tag, "%d", nic->fw_index); } else { - priv->fw_index--; - sprintf(tag, "%d", priv->fw_index); + nic->fw_index--; + sprintf(tag, "%d", nic->fw_index); } - if (priv->fw_index < cfg(priv)->ucode_api_min) { + if (nic->fw_index < cfg(priv)->ucode_api_min) { IWL_ERR(priv, "no suitable firmware found!\n"); return -ENOENT; } @@ -714,7 +715,7 @@ int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); IWL_DEBUG_INFO(priv, "attempting to load firmware %s'%s'\n", - (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) ? "EXPERIMENTAL " : "", priv->firmware_name); @@ -1032,7 +1033,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { - if (priv->fw_index <= api_ok) + if (nic->fw_index <= api_ok) IWL_ERR(priv, "request for firmware file '%s' failed.\n", priv->firmware_name); @@ -1069,7 +1070,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ /* no api version check required for experimental uCode */ - if (priv->fw_index != UCODE_EXPERIMENTAL_INDEX) { + if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { if (api_ver < api_min || api_ver > api_max) { IWL_ERR(priv, "Driver unable to support your firmware API. " @@ -1094,7 +1095,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (build) sprintf(buildstr, " build %u%s", build, - (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) ? " (EXP)" : ""); else buildstr[0] = '\0'; -- GitLab From 737805ff7a15105b77d83c7c3b17fa0868cb864e Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 6 Feb 2012 15:57:40 -0800 Subject: [PATCH 0845/1846] iwlwifi: move firmware_name to iwl_nic Delete firmware_name from iwl_priv and use iwl_nic instead. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 3 --- drivers/net/wireless/iwlwifi/iwl-ucode.c | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 008287f08d75..332101006353 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -787,9 +787,6 @@ struct iwl_priv { /* EEPROM MAC addresses */ struct mac_address addresses[2]; - /* uCode images, save to reload in case of failure */ - char firmware_name[25]; - struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; __le16 switch_channel; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index c3ac2cc7a795..0ba8ea910274 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -712,14 +712,14 @@ int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) return -ENOENT; } - sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); IWL_DEBUG_INFO(priv, "attempting to load firmware %s'%s'\n", (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) ? "EXPERIMENTAL " : "", - priv->firmware_name); + nic->firmware_name); - return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, + return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, trans(priv)->dev, GFP_KERNEL, priv, iwl_ucode_callback); } @@ -1036,12 +1036,12 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (nic->fw_index <= api_ok) IWL_ERR(priv, "request for firmware file '%s' failed.\n", - priv->firmware_name); + nic->firmware_name); goto try_again; } IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", - priv->firmware_name, ucode_raw->size); + nic->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { -- GitLab From 96502ceb1c122cf5496c9176bb690a52b3fab362 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 6 Feb 2012 16:00:14 -0800 Subject: [PATCH 0846/1846] iwlwifi: move firmware_loading_complete to iwl_nic Move firmware_loading_complete from iwl_priv to iwl_nic and rename it to more accurately reflect what it does. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 -- drivers/net/wireless/iwlwifi/iwl-ucode.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 9e902f7e9d35..12803d3fb2f9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1273,7 +1273,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_power_initialize(priv); iwl_tt_initialize(priv); - init_completion(&priv->firmware_loading_complete); + init_completion(&nic(priv)->request_firmware_complete); err = iwl_request_firmware(priv, true); if (err) @@ -1296,7 +1296,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, void __devexit iwl_remove(struct iwl_priv * priv) { - wait_for_completion(&priv->firmware_loading_complete); + wait_for_completion(&nic(priv)->request_firmware_complete); IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 332101006353..0d0b4bb9dc63 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -864,8 +864,6 @@ struct iwl_priv { struct iwl_rx_phy_res last_phy_res; bool last_phy_res_valid; - struct completion firmware_loading_complete; - u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0ba8ea910274..51a8fb353a6e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -1273,7 +1273,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); - complete(&priv->firmware_loading_complete); + complete(&nic->request_firmware_complete); return; try_again: @@ -1287,7 +1287,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) IWL_ERR(priv, "failed to allocate pci memory\n"); iwl_dealloc_ucode(trans(priv)); out_unbind: - complete(&priv->firmware_loading_complete); + complete(&nic->request_firmware_complete); device_release_driver(trans(priv)->dev); release_firmware(ucode_raw); } -- GitLab From 6516174d1a42c1b1b2861360bf44fe9992fb0f7e Mon Sep 17 00:00:00 2001 From: Don Fry Date: Tue, 7 Feb 2012 15:00:12 -0800 Subject: [PATCH 0847/1846] iwlwifi: Move ucode pointers to iwl_fw The ucode image is a ucode related thing not a transport one. Move them. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 11 +++---- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 8 ++--- drivers/net/wireless/iwlwifi/iwl-testmode.c | 12 ++++---- drivers/net/wireless/iwlwifi/iwl-trans.h | 16 +--------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 33 +++++++++++---------- drivers/net/wireless/iwlwifi/iwl-ucode.h | 14 +++++++-- 6 files changed, 46 insertions(+), 48 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 136de6fb3fa4..ad74138e1c70 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -40,6 +40,7 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-agn.h" +#include "iwl-wifi.h" /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ @@ -234,12 +235,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); + struct iwl_nic *nic = nic(priv); priv->dbgfs_sram_offset = 0x800000; - if (trans->shrd->ucode_type == IWL_UCODE_INIT) - priv->dbgfs_sram_len = trans->ucode_init.data.len; + if (nic->shrd->ucode_type == IWL_UCODE_INIT) + priv->dbgfs_sram_len = nic->fw.ucode_init.data.len; else - priv->dbgfs_sram_len = trans->ucode_rt.data.len; + priv->dbgfs_sram_len = nic->fw.ucode_rt.data.len; } len = priv->dbgfs_sram_len; @@ -342,7 +343,7 @@ static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, priv->wowlan_sram, - trans(priv)->ucode_wowlan.data.len); + nic(priv)->fw.ucode_wowlan.data.len); } static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 17358cfb68a9..ca0c46506674 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -195,7 +195,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_DISABLE_BEACON_HINTS | WIPHY_FLAG_IBSS_RSN; - if (trans(priv)->ucode_wowlan.code.len && + if (nic(priv)->fw.ucode_wowlan.code.len && device_can_wakeup(trans(priv)->dev)) { hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT | @@ -453,17 +453,17 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) #ifdef CONFIG_IWLWIFI_DEBUGFS if (ret == 0) { - struct iwl_trans *trans = trans(priv); + struct iwl_nic *nic = nic(priv); if (!priv->wowlan_sram) priv->wowlan_sram = - kzalloc(trans->ucode_wowlan.data.len, + kzalloc(nic->fw.ucode_wowlan.data.len, GFP_KERNEL); if (priv->wowlan_sram) _iwl_read_targ_mem_words( trans(priv), 0x800000, priv->wowlan_sram, - trans->ucode_wowlan.data.len / 4); + nic->fw.ucode_wowlan.data.len / 4); } #endif } diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 963cc6c89a46..5f00a3712707 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -591,16 +591,16 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) } switch (priv->shrd->ucode_type) { case IWL_UCODE_REGULAR: - inst_size = trans(priv)->ucode_rt.code.len; - data_size = trans(priv)->ucode_rt.data.len; + inst_size = nic(priv)->fw.ucode_rt.code.len; + data_size = nic(priv)->fw.ucode_rt.data.len; break; case IWL_UCODE_INIT: - inst_size = trans(priv)->ucode_init.code.len; - data_size = trans(priv)->ucode_init.data.len; + inst_size = nic(priv)->fw.ucode_init.code.len; + data_size = nic(priv)->fw.ucode_init.data.len; break; case IWL_UCODE_WOWLAN: - inst_size = trans(priv)->ucode_wowlan.code.len; - data_size = trans(priv)->ucode_wowlan.data.len; + inst_size = nic(priv)->fw.ucode_wowlan.code.len; + data_size = nic(priv)->fw.ucode_wowlan.data.len; break; case IWL_UCODE_NONE: IWL_ERR(priv, "No uCode has not been loaded\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index ae68c51e5327..913df937c964 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -68,6 +68,7 @@ #include "iwl-shared.h" #include "iwl-commands.h" +#include "iwl-ucode.h" /*This file includes the declaration that are exported from the transport * layer */ @@ -131,18 +132,6 @@ struct iwl_host_cmd { u8 id; }; -/* one for each uCode image (inst/data, boot/init/runtime) */ -struct fw_desc { - dma_addr_t p_addr; /* hardware address */ - void *v_addr; /* software address */ - u32 len; /* size in bytes */ -}; - -struct fw_img { - struct fw_desc code; /* firmware code image */ - struct fw_desc data; /* firmware data image */ -}; - /** * struct iwl_trans_ops - transport specific operations * @start_hw: starts the HW- from that point on, the HW can send interrupts @@ -258,9 +247,6 @@ struct iwl_trans { char hw_id_str[52]; u8 ucode_write_complete; /* the image write is complete */ - struct fw_img ucode_rt; - struct fw_img ucode_init; - struct fw_img ucode_wowlan; /* eeprom related variables */ int nvm_device_type; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 51a8fb353a6e..36039eb54dd4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -99,9 +99,10 @@ static void iwl_free_fw_img(struct iwl_trans *trans, struct fw_img *img) void iwl_dealloc_ucode(struct iwl_trans *trans) { - iwl_free_fw_img(trans, &trans->ucode_rt); - iwl_free_fw_img(trans, &trans->ucode_init); - iwl_free_fw_img(trans, &trans->ucode_wowlan); + struct iwl_nic *nic = nic(trans); + iwl_free_fw_img(trans, &nic->fw.ucode_rt); + iwl_free_fw_img(trans, &nic->fw.ucode_init); + iwl_free_fw_img(trans, &nic->fw.ucode_wowlan); } static int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, @@ -122,16 +123,16 @@ static int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, return 0; } -static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, +static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic, enum iwl_ucode_type ucode_type) { switch (ucode_type) { case IWL_UCODE_INIT: - return &trans->ucode_init; + return &nic->fw.ucode_init; case IWL_UCODE_WOWLAN: - return &trans->ucode_wowlan; + return &nic->fw.ucode_wowlan; case IWL_UCODE_REGULAR: - return &trans->ucode_rt; + return &nic->fw.ucode_rt; case IWL_UCODE_NONE: break; } @@ -456,7 +457,7 @@ static void iwl_print_mismatch_inst(struct iwl_trans *trans, 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); + struct fw_img *img = iwl_get_ucode_image(nic(trans), ucode_type); if (!img) { IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); @@ -583,7 +584,7 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, old_type = trans->shrd->ucode_type; trans->shrd->ucode_type = ucode_type; - fw = iwl_get_ucode_image(trans, ucode_type); + fw = iwl_get_ucode_image(nic(trans), ucode_type); if (!fw) return -EINVAL; @@ -647,7 +648,7 @@ int iwl_run_init_ucode(struct iwl_trans *trans) lockdep_assert_held(&trans->shrd->mutex); /* No init ucode required? Curious, but maybe ok */ - if (!trans->ucode_init.code.len) + if (!nic(trans)->fw.ucode_init.code.len) return 0; if (trans->shrd->ucode_type != IWL_UCODE_NONE) @@ -1163,21 +1164,21 @@ static void iwl_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 */ - if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.code, + if (iwl_alloc_fw_desc(trans(priv), &nic(priv)->fw.ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), &trans(priv)->ucode_rt.data, + if (iwl_alloc_fw_desc(trans(priv), &nic(priv)->fw.ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_init.code, + &nic(priv)->fw.ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_init.data, + &nic(priv)->fw.ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; } @@ -1185,12 +1186,12 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* WoWLAN instructions and data */ if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_wowlan.code, + &nic(priv)->fw.ucode_wowlan.code, pieces.wowlan_inst, pieces.wowlan_inst_size)) goto err_pci_alloc; if (iwl_alloc_fw_desc(trans(priv), - &trans(priv)->ucode_wowlan.data, + &nic(priv)->fw.ucode_wowlan.data, pieces.wowlan_data, pieces.wowlan_data_size)) goto err_pci_alloc; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-ucode.h index 18c77e9bb9b0..5e4b88e05c62 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.h +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.h @@ -63,8 +63,6 @@ #ifndef __iwl_ucode_h__ #define __iwl_ucode_h__ -#include "iwl-trans.h" - #include /* v1/v2 uCode file layout */ @@ -181,6 +179,18 @@ struct iwl_ucode_capabilities { u32 flags; }; +/* one for each uCode image (inst/data, boot/init/runtime) */ +struct fw_desc { + dma_addr_t p_addr; /* hardware address */ + void *v_addr; /* software address */ + u32 len; /* size in bytes */ +}; + +struct fw_img { + struct fw_desc code; /* firmware code image */ + struct fw_desc data; /* firmware data image */ +}; + /** * struct iwl_fw - variables associated with the firmware * -- GitLab From 655ccceb59f8fbffc2ed151d07d03eb88f27adb6 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 6 Feb 2012 16:37:46 -0800 Subject: [PATCH 0848/1846] iwlwifi: change args to ucode routines Change the prameters to the ucode (de)allocate routines to iwl_nic as they are not transport operations. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans.h | 2 - drivers/net/wireless/iwlwifi/iwl-ucode.c | 65 ++++++++++++------------ drivers/net/wireless/iwlwifi/iwl-wifi.h | 2 + 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 12803d3fb2f9..ff22c4ae13b1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1316,7 +1316,7 @@ void __devexit iwl_remove(struct iwl_priv * priv) /*This will stop the queues, move the device to low power state */ iwl_trans_stop_device(trans(priv)); - iwl_dealloc_ucode(trans(priv)); + iwl_dealloc_ucode(nic(priv)); iwl_eeprom_free(priv->shrd); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 913df937c964..7ea5f7733d2b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -396,8 +396,6 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) /***************************************************** * Utils functions ******************************************************/ -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); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 36039eb54dd4..26ead61d1f5c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -82,30 +82,29 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { * ******************************************************************************/ -static void iwl_free_fw_desc(struct iwl_trans *trans, struct fw_desc *desc) +static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc) { if (desc->v_addr) - dma_free_coherent(trans->dev, desc->len, + dma_free_coherent(trans(nic)->dev, desc->len, desc->v_addr, desc->p_addr); desc->v_addr = NULL; desc->len = 0; } -static void iwl_free_fw_img(struct iwl_trans *trans, struct fw_img *img) +static void iwl_free_fw_img(struct iwl_nic *nic, struct fw_img *img) { - iwl_free_fw_desc(trans, &img->code); - iwl_free_fw_desc(trans, &img->data); + iwl_free_fw_desc(nic, &img->code); + iwl_free_fw_desc(nic, &img->data); } -void iwl_dealloc_ucode(struct iwl_trans *trans) +void iwl_dealloc_ucode(struct iwl_nic *nic) { - struct iwl_nic *nic = nic(trans); - iwl_free_fw_img(trans, &nic->fw.ucode_rt); - iwl_free_fw_img(trans, &nic->fw.ucode_init); - iwl_free_fw_img(trans, &nic->fw.ucode_wowlan); + iwl_free_fw_img(nic, &nic->fw.ucode_rt); + iwl_free_fw_img(nic, &nic->fw.ucode_init); + iwl_free_fw_img(nic, &nic->fw.ucode_wowlan); } -static int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, +static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc, const void *data, size_t len) { if (!len) { @@ -113,7 +112,7 @@ static int iwl_alloc_fw_desc(struct iwl_trans *trans, struct fw_desc *desc, return -EINVAL; } - desc->v_addr = dma_alloc_coherent(trans->dev, len, + desc->v_addr = dma_alloc_coherent(trans(nic)->dev, len, &desc->p_addr, GFP_KERNEL); if (!desc->v_addr) return -ENOMEM; @@ -398,15 +397,16 @@ static int iwl_alive_notify(struct iwl_trans *trans) * 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_trans *trans, +static int iwl_verify_inst_sparse(struct iwl_nic *nic, struct fw_desc *fw_desc) { + struct iwl_trans *trans = trans(nic); __le32 *image = (__le32 *)fw_desc->v_addr; u32 len = fw_desc->len; u32 val; u32 i; - IWL_DEBUG_FW(trans, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(nic, "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 */ @@ -422,16 +422,17 @@ static int iwl_verify_inst_sparse(struct iwl_trans *trans, return 0; } -static void iwl_print_mismatch_inst(struct iwl_trans *trans, +static void iwl_print_mismatch_inst(struct iwl_nic *nic, struct fw_desc *fw_desc) { + struct iwl_trans *trans = trans(nic); __le32 *image = (__le32 *)fw_desc->v_addr; u32 len = fw_desc->len; u32 val; u32 offs; int errors = 0; - IWL_DEBUG_FW(trans, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len); iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR, IWLAGN_RTC_INST_LOWER_BOUND); @@ -442,7 +443,7 @@ static void iwl_print_mismatch_inst(struct iwl_trans *trans, /* read data comes through single port, auto-incr addr */ val = iwl_read32(trans, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(trans, "uCode INST section at " + IWL_ERR(nic, "uCode INST section at " "offset 0x%x, is 0x%x, s/b 0x%x\n", offs, val, le32_to_cpu(*image)); errors++; @@ -454,24 +455,24 @@ static void iwl_print_mismatch_inst(struct iwl_trans *trans, * iwl_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int iwl_verify_ucode(struct iwl_trans *trans, +static int iwl_verify_ucode(struct iwl_nic *nic, enum iwl_ucode_type ucode_type) { - struct fw_img *img = iwl_get_ucode_image(nic(trans), ucode_type); + struct fw_img *img = iwl_get_ucode_image(nic, ucode_type); if (!img) { - IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); + IWL_ERR(nic, "Invalid ucode requested (%d)\n", ucode_type); return -EINVAL; } - if (!iwl_verify_inst_sparse(trans, &img->code)) { - IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); + if (!iwl_verify_inst_sparse(nic, &img->code)) { + IWL_DEBUG_FW(nic, "uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); + IWL_ERR(nic, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - iwl_print_mismatch_inst(trans, &img->code); + iwl_print_mismatch_inst(nic, &img->code); return -EIO; } @@ -619,7 +620,7 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, * skip it for WoWLAN. */ if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(trans, ucode_type); + ret = iwl_verify_ucode(nic(trans), ucode_type); if (ret) { trans->shrd->ucode_type = old_type; return ret; @@ -1164,20 +1165,20 @@ static void iwl_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 */ - if (iwl_alloc_fw_desc(trans(priv), &nic(priv)->fw.ucode_rt.code, + if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), &nic(priv)->fw.ucode_rt.data, + if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(trans(priv), + if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), + if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; @@ -1185,12 +1186,12 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* WoWLAN instructions and data */ if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(trans(priv), + if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_wowlan.code, pieces.wowlan_inst, pieces.wowlan_inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(trans(priv), + if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_wowlan.data, pieces.wowlan_data, pieces.wowlan_data_size)) @@ -1286,7 +1287,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) err_pci_alloc: IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(trans(priv)); + iwl_dealloc_ucode(nic(priv)); out_unbind: complete(&nic->request_firmware_complete); device_release_driver(trans(priv)->dev); diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index a34708d19380..392f1113d954 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -95,6 +95,8 @@ struct iwl_nic { }; +void iwl_dealloc_ucode(struct iwl_nic *nic); + int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); void iwl_send_prio_tbl(struct iwl_trans *trans); int iwl_init_alive_start(struct iwl_trans *trans); -- GitLab From 78e5a464320338a90b0367ab9cc58029393a9824 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Fri, 17 Feb 2012 10:34:53 -0800 Subject: [PATCH 0849/1846] iwlwifi: kill iwl_down and s/__iwl_down/iwl_down iwl_down was just a wrapper around __iwl_down which was called from one place only. Replace it to direct call to iwl_down. Add lockdep warning in iwl_down to ensure it was called with the mutex held. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 19 +++++-------------- drivers/net/wireless/iwlwifi/iwl-agn.h | 2 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 6 +++++- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ff22c4ae13b1..cf1a353c20bb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -738,14 +738,14 @@ int iwl_alive_start(struct iwl_priv *priv) return iwl_power_update_mode(priv, true); } -static void iwl_cancel_deferred_work(struct iwl_priv *priv); - -void __iwl_down(struct iwl_priv *priv) +void iwl_down(struct iwl_priv *priv) { int exit_pending; IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + lockdep_assert_held(&priv->shrd->mutex); + iwl_scan_cancel_timeout(priv, 200); /* @@ -803,15 +803,6 @@ void __iwl_down(struct iwl_priv *priv) priv->beacon_skb = NULL; } -void iwl_down(struct iwl_priv *priv) -{ - mutex_lock(&priv->shrd->mutex); - __iwl_down(priv); - mutex_unlock(&priv->shrd->mutex); - - iwl_cancel_deferred_work(priv); -} - /***************************************************************************** * * Workqueue callbacks @@ -869,7 +860,7 @@ void iwlagn_prepare_restart(struct iwl_priv *priv) bt_status = priv->bt_status; bt_is_sco = priv->bt_is_sco; - __iwl_down(priv); + iwl_down(priv); priv->bt_full_concurrent = bt_full_concurrent; priv->bt_ci_compliance = bt_ci_compliance; @@ -970,7 +961,7 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) priv->watchdog.function = iwl_bg_watchdog; } -static void iwl_cancel_deferred_work(struct iwl_priv *priv) +void iwl_cancel_deferred_work(struct iwl_priv *priv) { if (cfg(priv)->lib->cancel_deferred_work) cfg(priv)->lib->cancel_deferred_work(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 37c325ff6e8c..8a170b7f1e17 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -81,8 +81,8 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) hdr->data_valid = 1; } -void __iwl_down(struct iwl_priv *priv); void iwl_down(struct iwl_priv *priv); +void iwl_cancel_deferred_work(struct iwl_priv *priv); void iwlagn_prepare_restart(struct iwl_priv *priv); /* MAC80211 */ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index ca0c46506674..90d8081426f6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -296,7 +296,7 @@ static int __iwl_up(struct iwl_priv *priv) error: set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); - __iwl_down(priv); + iwl_down(priv); clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); IWL_ERR(priv, "Unable to initialize device.\n"); @@ -341,7 +341,11 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw) priv->is_open = 0; + mutex_lock(&priv->shrd->mutex); iwl_down(priv); + mutex_unlock(&priv->shrd->mutex); + + iwl_cancel_deferred_work(priv); flush_workqueue(priv->workqueue); -- GitLab From 6d4dec7ba4b0275c97c39b694cfe60e9aeafdf60 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Fri, 17 Feb 2012 10:52:03 -0800 Subject: [PATCH 0850/1846] iwlwifi: iwl_set_hw_params returns always 0 Remove the return value. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-1000.c | 4 +--- drivers/net/wireless/iwlwifi/iwl-2000.c | 4 +--- drivers/net/wireless/iwlwifi/iwl-5000.c | 8 ++------ drivers/net/wireless/iwlwifi/iwl-6000.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-agn.c | 10 +++------- drivers/net/wireless/iwlwifi/iwl-core.h | 2 +- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 8c1466c907ff..91c4a72da8d7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -120,7 +120,7 @@ static struct iwl_sensitivity_ranges iwl1000_sensitivity = { .nrg_th_cca = 62, }; -static int iwl1000_hw_set_hw_params(struct iwl_priv *priv) +static void iwl1000_hw_set_hw_params(struct iwl_priv *priv) { if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) @@ -146,8 +146,6 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv) /* Set initial sensitivity parameters */ hw_params(priv).sens = &iwl1000_sensitivity; - - return 0; } static struct iwl_lib_ops iwl1000_lib = { diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index d4f5f3b87578..75f0e5088662 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -116,7 +116,7 @@ static struct iwl_sensitivity_ranges iwl2000_sensitivity = { .nrg_th_cca = 62, }; -static int iwl2000_hw_set_hw_params(struct iwl_priv *priv) +static void iwl2000_hw_set_hw_params(struct iwl_priv *priv) { if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) @@ -142,8 +142,6 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv) /* Set initial sensitivity parameters */ hw_params(priv).sens = &iwl2000_sensitivity; - - return 0; } static struct iwl_lib_ops iwl2000_lib = { diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index dc9317d0343e..458e6778c72f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -162,7 +162,7 @@ static void iwl5000_set_ct_threshold(struct iwl_priv *priv) hw_params(priv).ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY; } -static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) +static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) { if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) @@ -185,11 +185,9 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) /* Set initial sensitivity parameters */ hw_params(priv).sens = &iwl5000_sensitivity; - - return 0; } -static int iwl5150_hw_set_hw_params(struct iwl_priv *priv) +static void iwl5150_hw_set_hw_params(struct iwl_priv *priv) { if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) @@ -212,8 +210,6 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv) /* Set initial sensitivity parameters */ hw_params(priv).sens = &iwl5150_sensitivity; - - return 0; } static void iwl5150_temperature(struct iwl_priv *priv) diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index c36fb858a45b..19e41037f61e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -137,7 +137,7 @@ static struct iwl_sensitivity_ranges iwl6000_sensitivity = { .nrg_th_cca = 62, }; -static int iwl6000_hw_set_hw_params(struct iwl_priv *priv) +static void iwl6000_hw_set_hw_params(struct iwl_priv *priv) { if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) @@ -165,7 +165,6 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv) /* Set initial sensitivity parameters */ hw_params(priv).sens = &iwl6000_sensitivity; - return 0; } static int iwl6000_hw_channel_switch(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index cf1a353c20bb..68b9e5e5da78 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1082,7 +1082,7 @@ static void iwl_uninit_drv(struct iwl_priv *priv) #define IWL_RX_BUF_SIZE_4K (4 * 1024) #define IWL_RX_BUF_SIZE_8K (8 * 1024) -static int iwl_set_hw_params(struct iwl_priv *priv) +static void iwl_set_hw_params(struct iwl_priv *priv) { if (iwlagn_mod_params.amsdu_size_8K) hw_params(priv).rx_page_order = @@ -1102,7 +1102,7 @@ static int iwl_set_hw_params(struct iwl_priv *priv) hw_params(priv).wd_timeout = cfg(priv)->base_params->wd_timeout; /* Device-specific setup */ - return cfg(priv)->lib->set_hw_params(priv); + cfg(priv)->lib->set_hw_params(priv); } @@ -1239,11 +1239,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, /************************ * 5. Setup HW constants ************************/ - if (iwl_set_hw_params(priv)) { - err = -ENOENT; - IWL_ERR(priv, "failed to set hw parameters\n"); - goto out_free_eeprom; - } + iwl_set_hw_params(priv); /******************* * 6. Setup priv diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 8d60dcf6f2eb..49370dd37768 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -76,7 +76,7 @@ struct iwl_cmd; struct iwl_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct iwl_priv *priv); + void (*set_hw_params)(struct iwl_priv *priv); /* setup BT Rx handler */ void (*bt_rx_handler_setup)(struct iwl_priv *priv); /* setup BT related deferred work */ -- GitLab From 637d7925910df46bb29a0260dd2fec68b50a811b Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 7 Feb 2012 10:55:46 +0200 Subject: [PATCH 0851/1846] iwlwifi: use enhance_sensitivity from iwl_fw Remove another dependency between the nic layer and the iwl_priv struct. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 6 ++++-- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - drivers/net/wireless/iwlwifi/iwl-ucode.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 6aa009827865..988ee454a944 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -68,6 +68,8 @@ #include "iwl-agn-calib.h" #include "iwl-trans.h" #include "iwl-agn.h" +#include "iwl-wifi.h" +#include "iwl-ucode.h" /***************************************************************************** * INIT calibrations framework @@ -634,7 +636,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv) data->last_bad_plcp_cnt_cck = 0; data->last_fa_cnt_cck = 0; - if (priv->enhance_sensitivity_table) + if (nic(priv)->fw.enhance_sensitivity_table) ret |= iwl_enhance_sensitivity_write(priv); else ret |= iwl_sensitivity_write(priv); @@ -745,7 +747,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv) iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); - if (priv->enhance_sensitivity_table) + if (nic(priv)->fw.enhance_sensitivity_table) iwl_enhance_sensitivity_write(priv); else iwl_sensitivity_write(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 0d0b4bb9dc63..8a72940aa805 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -796,7 +796,6 @@ struct iwl_priv { u8 start_calib; struct iwl_sensitivity_data sensitivity_data; struct iwl_chain_noise_data chain_noise_data; - bool enhance_sensitivity_table; __le16 sensitivity_tbl[HD_TABLE_SIZE]; __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES]; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 26ead61d1f5c..a2695c27f663 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -967,7 +967,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, case IWL_UCODE_TLV_ENHANCE_SENS_TBL: if (tlv_len) goto invalid_tlv_len; - priv->enhance_sensitivity_table = true; + nic->fw.enhance_sensitivity_table = true; break; case IWL_UCODE_TLV_WOWLAN_INST: pieces->wowlan_inst = tlv_data; -- GitLab From 858b7c74dda1d748a687a523e83cf7d1449c70f3 Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Mon, 6 Feb 2012 00:40:47 +0200 Subject: [PATCH 0852/1846] iwlwifi: fixes to testmode indirect access Fixed casting of buffer addressing, and added size to the read method, like in __iwl_read_prph. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 5f00a3712707..ba5c63a023a2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -799,9 +799,10 @@ static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size) addr < IWL_TM_ABS_PRPH_START + PRPH_END) { spin_lock_irqsave(&trans->reg_lock, flags); iwl_grab_nic_access(trans); - iwl_write32(trans, HBUS_TARG_PRPH_RADDR, addr); + iwl_write32(trans, HBUS_TARG_PRPH_RADDR, + addr | (3 << 24)); for (i = 0; i < size; i += 4) - priv->testmode_mem.buff_addr[i] = + *(u32 *)(priv->testmode_mem.buff_addr + i) = iwl_read32(trans, HBUS_TARG_PRPH_RDAT); iwl_release_nic_access(trans); spin_unlock_irqrestore(&trans->reg_lock, flags); @@ -833,7 +834,8 @@ static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr, spin_lock_irqsave(&trans->reg_lock, flags); iwl_grab_nic_access(trans); iwl_write32(trans, HBUS_TARG_PRPH_WADDR, - (addr & 0x0000FFFF) | (size << 24)); + (addr & 0x0000FFFF) | + ((size - 1) << 24)); iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val); iwl_release_nic_access(trans); /* needed after consecutive writes w/o read */ @@ -844,7 +846,7 @@ static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr, return -EINVAL; for (i = 0; i < size; i += 4) iwl_write_prph(trans, addr+i, - *(u32 *)buf+i); + *(u32 *)(buf+i)); } } else if (iwlagn_hw_valid_rtc_data_addr(addr) || (IWLAGN_RTC_INST_LOWER_BOUND <= addr && -- GitLab From edabfa914d52daf8c01511109144fe5af3c4389e Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Wed, 8 Feb 2012 10:01:35 +0200 Subject: [PATCH 0853/1846] iwlwifi: send testmode hcmd reply with rx header When a host command is sent through testmode, the whole reply (including rx header) is returned to the user, and not only the payload of the rx. Before this commit the length was buggy - the reply contained 4 bytes after the end of the payload. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index ba5c63a023a2..80955ed06e82 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -309,7 +309,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) } /* The reply is in a page, that we cannot send to user space. */ - memcpy(reply_buf, &(pkt->u), reply_len); + memcpy(reply_buf, &(pkt->hdr), reply_len); iwl_free_pages(priv->shrd, cmd.reply_page); NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); -- GitLab From 60396183a4e7adce7aa71f801e47b063fe1f70a8 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 6 Feb 2012 16:41:58 +0200 Subject: [PATCH 0854/1846] iwlwifi: document the transport layer Fix a few typos in the existing comments too. Enforce the comments with might_sleep. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-trans.h | 120 ++++++++++++++++++++--- 1 file changed, 107 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 7ea5f7733d2b..2a2941f9fd21 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -70,17 +70,72 @@ #include "iwl-commands.h" #include "iwl-ucode.h" - /*This file includes the declaration that are exported from the transport - * layer */ +/** + * DOC: Transport layer - what is it ? + * + * The tranport layer is the layer that deals with the HW directly. It provides + * an abstraction of the underlying HW to the upper layer. The transport layer + * doesn't provide any policy, algorithm or anything of this kind, but only + * mechanisms to make the HW do something.It is not completely stateless but + * close to it. + * We will have an implementation for each different supported bus. + */ + +/** + * DOC: Life cycle of the transport layer + * + * The transport layer has a very precise life cycle. + * + * 1) A helper function is called during the module initialization and + * registers the bus driver's ops with the transport's alloc function. + * 2) Bus's probe calls to the transport layer's allocation functions. + * Of course this function is bus specific. + * 3) This allocation functions will spawn the upper layer which will + * register mac80211. + * + * 4) At some point (i.e. mac80211's start call), the op_mode will call + * the following sequence: + * start_hw + * start_fw + * + * 5) Then when finished (or reset): + * stop_fw (a.k.a. stop device for the moment) + * stop_hw + * + * 6) Eventually, the free function will be called. + */ + +/** + * DOC: API needed by the transport layer from the op_mode + * + * TODO + */ struct iwl_priv; struct iwl_shared; +/** + * DOC: Host command section + * + * A host command is a commaned issued by the upper layer to the fw. There are + * several versions of fw that have several APIs. The transport layer is + * completely agnostic to these differences. + * The transport does provide helper functionnality (i.e. SYNC / ASYNC mode), + */ #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 { +/** + * enum CMD_MODE - how to send the host commands ? + * + * @CMD_SYNC: The caller will be stalled until the fw responds to the command + * @CMD_ASYNC: Return right away and don't want for the response + * @CMD_WANT_SKB: valid only with CMD_SYNC. The caller needs the buffer of the + * response. + * @CMD_ON_DEMAND: This command is sent by the test mode pipe. + */ +enum CMD_MODE { CMD_SYNC = 0, CMD_ASYNC = BIT(0), CMD_WANT_SKB = BIT(1), @@ -105,20 +160,29 @@ struct iwl_device_cmd { #define IWL_MAX_CMD_TFDS 2 +/** + * struct iwl_hcmd_dataflag - flag for each one of the chunks of the command + * + * IWL_HCMD_DFL_NOCOPY: By default, the command is copied to the host command's + * ring. The transport layer doesn't map the command's buffer to DMA, but + * rather copies it to an previously allocated DMA buffer. This flag tells + * the transport layer not to copy the command, but to map the existing + * buffer. This can save memcpy and is worth with very big comamnds. + */ enum iwl_hcmd_dataflag { IWL_HCMD_DFL_NOCOPY = BIT(0), }; /** * struct iwl_host_cmd - Host command to the uCode + * * @data: array of chunks that composes the data of the host command * @reply_page: pointer to the page that holds the response to the host command * @handler_status: return value of the handler of the command * (put in setup_rx_handlers) - valid for SYNC mode only - * @callback: - * @flags: can be CMD_* note CMD_WANT_SKB is incompatible withe CMD_ASYNC + * @flags: can be CMD_* * @len: array of the lenths of the chunks in data - * @dataflags: + * @dataflags: IWL_HCMD_DFL_* * @id: id of the host command */ struct iwl_host_cmd { @@ -134,26 +198,43 @@ struct iwl_host_cmd { /** * struct iwl_trans_ops - transport specific operations + * + * All the handlers MUST be implemented + * * @start_hw: starts the HW- from that point on, the HW can send interrupts + * May sleep * @stop_hw: stops the HW- from that point on, the HW will be in low power but * will still issue interrupt if the HW RF kill is triggered. + * May sleep * @start_fw: allocates and inits all the resources for the transport - * layer. Also kick a fw image. This handler may sleep. + * layer. Also kick a fw image. + * May sleep * @fw_alive: called when the fw sends alive notification + * May sleep * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_* * @stop_device:stops the whole device (embedded CPU put to reset) + * May sleep * @send_cmd:send a host command + * May sleep only if CMD_SYNC is set * @tx: send an skb + * Must be atomic * @reclaim: free packet until ssn. Returns a list of freed packets. + * Must be atomic * @tx_agg_alloc: allocate resources for a TX BA session + * May sleep * @tx_agg_setup: setup a tx queue for AMPDU - will be called once the HW is - * ready and a successful ADDBA response has been received. + * ready and a successful ADDBA response has been received. + * May sleep * @tx_agg_disable: de-configure a Tx queue to send AMPDUs + * May sleep * @free: release all the ressource for the transport layer itself such as - * irq, tasklet etc... + * irq, tasklet etc... From this point on, the device may not issue + * any interrupt (incl. RFKILL). + * May sleep * @stop_queue: stop a specific queue * @check_stuck_queue: check if a specific queue is stuck * @wait_tx_queue_empty: wait until all tx queues are empty + * May sleep * @dbgfs_register: add the dbgfs files under this directory. Files will be * automatically deleted. * @suspend: stop the device unless WoWLAN is configured @@ -217,6 +298,7 @@ struct iwl_calib_result { /** * struct iwl_trans - transport common data + * * @ops - pointer to iwl_trans_ops * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @hcmd_lock: protects HCMD @@ -224,7 +306,7 @@ struct iwl_calib_result { * @dev - pointer to struct device * that represents the device * @irq - the irq number for the device * @hw_id: a u32 with the ID of the device / subdevice. - * Set during transport alloaction. + * Set during transport allocation. * @hw_id_str: a string with info about HW ID. Set during transport allocation. * @ucode_write_complete: indicates that the ucode has been copied. * @ucode_rt: run time ucode image @@ -246,13 +328,11 @@ struct iwl_trans { u32 hw_id; char hw_id_str[52]; - u8 ucode_write_complete; /* the image write is complete */ + u8 ucode_write_complete; - /* eeprom related variables */ int nvm_device_type; bool pm_support; - /* init calibration results */ struct list_head calib_results; /* pointer to trans specific struct */ @@ -262,16 +342,22 @@ struct iwl_trans { static inline int iwl_trans_start_hw(struct iwl_trans *trans) { + might_sleep(); + return trans->ops->start_hw(trans); } static inline void iwl_trans_stop_hw(struct iwl_trans *trans) { + might_sleep(); + trans->ops->stop_hw(trans); } static inline void iwl_trans_fw_alive(struct iwl_trans *trans) { + might_sleep(); + trans->ops->fw_alive(trans); } @@ -284,6 +370,8 @@ static inline int iwl_trans_start_fw(struct iwl_trans *trans, struct fw_img *fw) static inline void iwl_trans_stop_device(struct iwl_trans *trans) { + might_sleep(); + trans->ops->stop_device(trans); } @@ -322,12 +410,16 @@ static inline int iwl_trans_reclaim(struct iwl_trans *trans, int sta_id, static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) { + might_sleep(); + return trans->ops->tx_agg_disable(trans, sta_id, tid); } static inline int iwl_trans_tx_agg_alloc(struct iwl_trans *trans, int sta_id, int tid) { + might_sleep(); + return trans->ops->tx_agg_alloc(trans, sta_id, tid); } @@ -337,6 +429,8 @@ static inline void iwl_trans_tx_agg_setup(struct iwl_trans *trans, int sta_id, int tid, int frame_limit, u16 ssn) { + might_sleep(); + trans->ops->tx_agg_setup(trans, ctx, sta_id, tid, frame_limit, ssn); } -- GitLab From 8655112d91f247f6b96c9b1285658c141238ce90 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Tue, 7 Feb 2012 14:03:55 -0800 Subject: [PATCH 0855/1846] iwlwifi: move event and err pointers to iwl_nic Move the ucode offset pointers to the iwl_nic as they are nic related. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 3 -- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 31 ++++++++++--------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 16 +++++----- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 8a72940aa805..494c696dc177 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -863,9 +863,6 @@ struct iwl_priv { struct iwl_rx_phy_res last_phy_res; bool last_phy_res_valid; - u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; - u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; - /* * chain noise reset and gain commands are the * two extra calibration commands follows the standard diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index e06342656cea..6715d04b72f4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -34,6 +34,7 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-trans-pcie-int.h" +#include "iwl-wifi.h" #ifdef CONFIG_IWLWIFI_IDI #include "iwl-amfh.h" @@ -589,17 +590,17 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) { u32 base; struct iwl_error_event_table table; - struct iwl_priv *priv = priv(trans); + struct iwl_nic *nic = nic(trans); struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); base = trans->shrd->device_pointers.error_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) - base = priv->init_errlog_ptr; + base = nic->init_errlog_ptr; } else { if (!base) - base = priv->inst_errlog_ptr; + base = nic->inst_errlog_ptr; } if (!iwlagn_hw_valid_rtc_data_addr(base)) { @@ -611,7 +612,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) return; } - iwl_read_targ_mem_words(trans(priv), base, &table, sizeof(table)); + iwl_read_targ_mem_words(trans, base, &table, sizeof(table)); if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) { IWL_ERR(trans, "Start IWL Error Log Dump:\n"); @@ -621,7 +622,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) trans_pcie->isr_stats.err_code = table.error_id; - trace_iwlwifi_dev_ucode_error(priv, table.error_id, table.tsf_low, + trace_iwlwifi_dev_ucode_error(priv(nic), table.error_id, table.tsf_low, table.data1, table.data2, table.line, table.blink1, table.blink2, table.ilink1, table.ilink2, table.bcon_time, table.gp1, @@ -718,7 +719,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, u32 ptr; /* SRAM byte address of log data */ u32 ev, time, data; /* event log data */ unsigned long reg_flags; - struct iwl_priv *priv = priv(trans); + struct iwl_nic *nic = nic(trans); if (num_events == 0) return pos; @@ -726,10 +727,10 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, base = trans->shrd->device_pointers.log_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) - base = priv->init_evtlog_ptr; + base = nic->init_evtlog_ptr; } else { if (!base) - base = priv->inst_evtlog_ptr; + base = nic->inst_evtlog_ptr; } if (mode == 0) @@ -759,7 +760,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, "EVT_LOG:0x%08x:%04u\n", time, ev); } else { - trace_iwlwifi_dev_ucode_event(priv, 0, + trace_iwlwifi_dev_ucode_event(priv(trans), 0, time, ev); IWL_ERR(trans, "EVT_LOG:0x%08x:%04u\n", time, ev); @@ -773,7 +774,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, } else { IWL_ERR(trans, "EVT_LOGT:%010u:0x%08x:%04u\n", time, data, ev); - trace_iwlwifi_dev_ucode_event(priv, time, + trace_iwlwifi_dev_ucode_event(priv(trans), time, data, ev); } } @@ -835,17 +836,17 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, u32 logsize; int pos = 0; size_t bufsz = 0; - struct iwl_priv *priv = priv(trans); + struct iwl_nic *nic = nic(trans); base = trans->shrd->device_pointers.log_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { - logsize = priv->init_evtlog_size; + logsize = nic->init_evtlog_size; if (!base) - base = priv->init_evtlog_ptr; + base = nic->init_evtlog_ptr; } else { - logsize = priv->inst_evtlog_size; + logsize = nic->inst_evtlog_size; if (!base) - base = priv->inst_evtlog_ptr; + base = nic->inst_evtlog_ptr; } if (!iwlagn_hw_valid_rtc_data_addr(base)) { diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index a2695c27f663..0d04a4d7dc84 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -1205,20 +1205,20 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * for each event, which is of mode 1 (including timestamp) for all * new microcodes that include this information. */ - priv->init_evtlog_ptr = pieces.init_evtlog_ptr; + nic->init_evtlog_ptr = pieces.init_evtlog_ptr; if (pieces.init_evtlog_size) - priv->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; + nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; else - priv->init_evtlog_size = + nic->init_evtlog_size = cfg(priv)->base_params->max_event_log_size; - priv->init_errlog_ptr = pieces.init_errlog_ptr; - priv->inst_evtlog_ptr = pieces.inst_evtlog_ptr; + nic->init_errlog_ptr = pieces.init_errlog_ptr; + nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; if (pieces.inst_evtlog_size) - priv->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; + nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; else - priv->inst_evtlog_size = + nic->inst_evtlog_size = cfg(priv)->base_params->max_event_log_size; - priv->inst_errlog_ptr = pieces.inst_errlog_ptr; + nic->inst_errlog_ptr = pieces.inst_errlog_ptr; #ifndef CONFIG_IWLWIFI_P2P ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; #endif -- GitLab From 69655ebf1a64eb922e2ed94ed62898e3c47dd492 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 6 Feb 2012 14:30:54 +0200 Subject: [PATCH 0856/1846] iwlwifi: the transport knows its state This allows to handle races such as Tx packets on their way to be sent although the transport has been stopped already. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-trans.h | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 2a2941f9fd21..20b50a0e0a86 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -69,6 +69,7 @@ #include "iwl-shared.h" #include "iwl-commands.h" #include "iwl-ucode.h" +#include "iwl-debug.h" /** * DOC: Transport layer - what is it ? @@ -296,6 +297,17 @@ struct iwl_calib_result { /* data follows */ }; +/** + * enum iwl_trans_state - state of the transport layer + * + * @IWL_TRANS_NO_FW: no fw has sent an alive response + * @IWL_TRANS_FW_ALIVE: a fw has sent an alive response + */ +enum iwl_trans_state { + IWL_TRANS_NO_FW = 0, + IWL_TRANS_FW_ALIVE = 1, +}; + /** * struct iwl_trans - transport common data * @@ -319,6 +331,7 @@ struct iwl_calib_result { struct iwl_trans { const struct iwl_trans_ops *ops; struct iwl_shared *shrd; + enum iwl_trans_state state; spinlock_t hcmd_lock; spinlock_t reg_lock; @@ -352,6 +365,8 @@ static inline void iwl_trans_stop_hw(struct iwl_trans *trans) might_sleep(); trans->ops->stop_hw(trans); + + trans->state = IWL_TRANS_NO_FW; } static inline void iwl_trans_fw_alive(struct iwl_trans *trans) @@ -359,6 +374,8 @@ static inline void iwl_trans_fw_alive(struct iwl_trans *trans) might_sleep(); trans->ops->fw_alive(trans); + + trans->state = IWL_TRANS_FW_ALIVE; } static inline int iwl_trans_start_fw(struct iwl_trans *trans, struct fw_img *fw) @@ -373,12 +390,17 @@ static inline void iwl_trans_stop_device(struct iwl_trans *trans) might_sleep(); trans->ops->stop_device(trans); + + trans->state = IWL_TRANS_NO_FW; } static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, enum iwl_rxon_context_id ctx, const char *msg) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + trans->ops->wake_any_queue(trans, ctx, msg); } @@ -386,6 +408,9 @@ static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, static inline int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->send_cmd(trans, cmd); } @@ -396,6 +421,9 @@ static inline int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb, struct iwl_device_cmd *dev_cmd, enum iwl_rxon_context_id ctx, u8 sta_id, u8 tid) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->tx(trans, skb, dev_cmd, ctx, sta_id, tid); } @@ -403,6 +431,9 @@ static inline int iwl_trans_reclaim(struct iwl_trans *trans, int sta_id, int tid, int txq_id, int ssn, u32 status, struct sk_buff_head *skbs) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->reclaim(trans, sta_id, tid, txq_id, ssn, status, skbs); } @@ -412,6 +443,9 @@ static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, { might_sleep(); + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->tx_agg_disable(trans, sta_id, tid); } @@ -420,6 +454,9 @@ static inline int iwl_trans_tx_agg_alloc(struct iwl_trans *trans, { might_sleep(); + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->tx_agg_alloc(trans, sta_id, tid); } @@ -431,6 +468,9 @@ static inline void iwl_trans_tx_agg_setup(struct iwl_trans *trans, { might_sleep(); + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + trans->ops->tx_agg_setup(trans, ctx, sta_id, tid, frame_limit, ssn); } @@ -442,16 +482,25 @@ static inline void iwl_trans_free(struct iwl_trans *trans) static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q, const char *msg) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + trans->ops->stop_queue(trans, q, msg); } static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->wait_tx_queue_empty(trans); } static inline int iwl_trans_check_stuck_queue(struct iwl_trans *trans, int q) { + if (trans->state != IWL_TRANS_FW_ALIVE) + IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + return trans->ops->check_stuck_queue(trans, q); } static inline int iwl_trans_dbgfs_register(struct iwl_trans *trans, -- GitLab From 06e03f8ce91b71c6ce4134c8bf9ed801aed0382c Mon Sep 17 00:00:00 2001 From: Don Fry Date: Tue, 7 Feb 2012 14:21:32 -0800 Subject: [PATCH 0857/1846] iwlwifi: changes args to iwl_nic for firmware operations Remove the references to iwl_priv from the firmware request and parsing routines. They are generic to the nic. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 149 ++++++++++++----------- drivers/net/wireless/iwlwifi/iwl-ucode.h | 4 - drivers/net/wireless/iwlwifi/iwl-wifi.h | 1 + 4 files changed, 77 insertions(+), 79 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 68b9e5e5da78..e8fed167f97e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1262,7 +1262,7 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, init_completion(&nic(priv)->request_firmware_complete); - err = iwl_request_firmware(priv, true); + err = iwl_request_firmware(nic(priv), true); if (err) goto out_destroy_workqueue; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0d04a4d7dc84..01768f709a76 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -690,10 +690,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); #define UCODE_EXPERIMENTAL_INDEX 100 #define UCODE_EXPERIMENTAL_TAG "exp" -int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) +int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first) { - struct iwl_nic *nic = nic(priv); - const char *name_pre = cfg(priv)->fw_name_pre; + struct iwl_cfg *cfg = cfg(nic); + const char *name_pre = cfg->fw_name_pre; char tag[8]; if (first) { @@ -702,28 +702,28 @@ int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) strcpy(tag, UCODE_EXPERIMENTAL_TAG); } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { #endif - nic->fw_index = cfg(priv)->ucode_api_max; + nic->fw_index = cfg->ucode_api_max; sprintf(tag, "%d", nic->fw_index); } else { nic->fw_index--; sprintf(tag, "%d", nic->fw_index); } - if (nic->fw_index < cfg(priv)->ucode_api_min) { - IWL_ERR(priv, "no suitable firmware found!\n"); + if (nic->fw_index < cfg->ucode_api_min) { + IWL_ERR(nic, "no suitable firmware found!\n"); return -ENOENT; } sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IWL_DEBUG_INFO(priv, "attempting to load firmware %s'%s'\n", + IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n", (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) ? "EXPERIMENTAL " : "", nic->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, - trans(priv)->dev, - GFP_KERNEL, priv, iwl_ucode_callback); + trans(nic)->dev, + GFP_KERNEL, nic, iwl_ucode_callback); } struct iwlagn_firmware_pieces { @@ -737,11 +737,10 @@ struct iwlagn_firmware_pieces { u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; }; -static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, +static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, const struct firmware *ucode_raw, struct iwlagn_firmware_pieces *pieces) { - struct iwl_nic *nic = nic(priv); struct iwl_ucode_header *ucode = (void *)ucode_raw->data; u32 api_ver, hdr_size; const u8 *src; @@ -753,7 +752,7 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, default: hdr_size = 28; if (ucode_raw->size < hdr_size) { - IWL_ERR(priv, "File size too small!\n"); + IWL_ERR(nic, "File size too small!\n"); return -EINVAL; } pieces->build = le32_to_cpu(ucode->u.v2.build); @@ -768,7 +767,7 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IWL_ERR(priv, "File size too small!\n"); + IWL_ERR(nic, "File size too small!\n"); return -EINVAL; } pieces->build = 0; @@ -785,7 +784,7 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, pieces->data_size + pieces->init_size + pieces->init_data_size) { - IWL_ERR(priv, + IWL_ERR(nic, "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -803,12 +802,11 @@ static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, return 0; } -static int iwlagn_load_firmware(struct iwl_priv *priv, +static int iwl_parse_tlv_firmware(struct iwl_nic *nic, const struct firmware *ucode_raw, struct iwlagn_firmware_pieces *pieces, struct iwlagn_ucode_capabilities *capa) { - struct iwl_nic *nic = nic(priv); struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; struct iwl_ucode_tlv *tlv; size_t len = ucode_raw->size; @@ -821,12 +819,12 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, const u8 *tlv_data; if (len < sizeof(*ucode)) { - IWL_ERR(priv, "uCode has invalid length: %zd\n", len); + IWL_ERR(nic, "uCode has invalid length: %zd\n", len); return -EINVAL; } if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { - IWL_ERR(priv, "invalid uCode magic: 0X%x\n", + IWL_ERR(nic, "invalid uCode magic: 0X%x\n", le32_to_cpu(ucode->magic)); return -EINVAL; } @@ -844,7 +842,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) wanted_alternative--; if (wanted_alternative && wanted_alternative != tmp) - IWL_WARN(priv, + IWL_WARN(nic, "uCode alternative %d not available, choosing %d\n", tmp, wanted_alternative); @@ -866,7 +864,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, tlv_data = tlv->data; if (len < tlv_len) { - IWL_ERR(priv, "invalid TLV len: %zd/%u\n", + IWL_ERR(nic, "invalid TLV len: %zd/%u\n", len, tlv_len); return -EINVAL; } @@ -899,7 +897,7 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, pieces->init_data_size = tlv_len; break; case IWL_UCODE_TLV_BOOT: - IWL_ERR(priv, "Found unexpected BOOT ucode\n"); + IWL_ERR(nic, "Found unexpected BOOT ucode\n"); break; case IWL_UCODE_TLV_PROBE_MAX_LEN: if (tlv_len != sizeof(u32)) @@ -984,22 +982,22 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, le32_to_cpup((__le32 *)tlv_data); break; default: - IWL_DEBUG_INFO(priv, "unknown TLV: %d\n", tlv_type); + IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type); break; } } if (len) { - IWL_ERR(priv, "invalid TLV after parsing: %zd\n", len); - iwl_print_hex_dump(priv, IWL_DL_FW, (u8 *)data, len); + IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len); + iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len); return -EINVAL; } return 0; invalid_tlv_len: - IWL_ERR(priv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); - iwl_print_hex_dump(priv, IWL_DL_FW, tlv_data, tlv_len); + IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); + iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len); return -EINVAL; } @@ -1012,14 +1010,15 @@ static int iwlagn_load_firmware(struct iwl_priv *priv, */ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) { - struct iwl_priv *priv = context; - struct iwl_nic *nic = nic(priv); + struct iwl_nic *nic = context; + struct iwl_cfg *cfg = cfg(nic); + struct iwl_priv *priv = priv(nic); /* temporary */ struct iwl_ucode_header *ucode; int err; struct iwlagn_firmware_pieces pieces; - const unsigned int api_max = cfg(priv)->ucode_api_max; - unsigned int api_ok = cfg(priv)->ucode_api_ok; - const unsigned int api_min = cfg(priv)->ucode_api_min; + const unsigned int api_max = cfg->ucode_api_max; + unsigned int api_ok = cfg->ucode_api_ok; + const unsigned int api_min = cfg->ucode_api_min; u32 api_ver; char buildstr[25]; u32 build; @@ -1036,18 +1035,18 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (!ucode_raw) { if (nic->fw_index <= api_ok) - IWL_ERR(priv, + IWL_ERR(nic, "request for firmware file '%s' failed.\n", nic->firmware_name); goto try_again; } - IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", + IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n", nic->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"); + IWL_ERR(nic, "File size way too small!\n"); goto try_again; } @@ -1055,9 +1054,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) ucode = (struct iwl_ucode_header *)ucode_raw->data; if (ucode->ver) - err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces); + err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); else - err = iwlagn_load_firmware(priv, ucode_raw, &pieces, + err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, &ucode_capa); if (err) @@ -1074,7 +1073,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* no api version check required for experimental uCode */ if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(priv, + IWL_ERR(nic, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1083,14 +1082,14 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (api_ver < api_ok) { if (api_ok != api_max) - IWL_ERR(priv, "Firmware has old API version, " + IWL_ERR(nic, "Firmware has old API version, " "expected v%u through v%u, got v%u.\n", api_ok, api_max, api_ver); else - IWL_ERR(priv, "Firmware has old API version, " + IWL_ERR(nic, "Firmware has old API version, " "expected v%u, got v%u.\n", api_max, api_ver); - IWL_ERR(priv, "New firmware can be obtained from " + IWL_ERR(nic, "New firmware can be obtained from " "http://www.intellinuxwireless.org/.\n"); } } @@ -1102,7 +1101,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) else buildstr[0] = '\0'; - IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\n", + IWL_INFO(nic, "loaded firmware version %u.%u.%u.%u%s\n", IWL_UCODE_MAJOR(nic->fw.ucode_ver), IWL_UCODE_MINOR(nic->fw.ucode_ver), IWL_UCODE_API(nic->fw.ucode_ver), @@ -1124,38 +1123,38 @@ static void iwl_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", + IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n", nic->fw.ucode_ver); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", + IWL_DEBUG_INFO(nic, "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", + IWL_DEBUG_INFO(nic, "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", + IWL_DEBUG_INFO(nic, "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", + IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n", pieces.init_data_size); /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > hw_params(priv).max_inst_size) { - IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", + if (pieces.inst_size > hw_params(nic).max_inst_size) { + IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } - if (pieces.data_size > hw_params(priv).max_data_size) { - IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", + if (pieces.data_size > hw_params(nic).max_data_size) { + IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } - if (pieces.init_size > hw_params(priv).max_inst_size) { - IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", + if (pieces.init_size > hw_params(nic).max_inst_size) { + IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } - if (pieces.init_data_size > hw_params(priv).max_data_size) { - IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", + if (pieces.init_data_size > hw_params(nic).max_data_size) { + IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } @@ -1165,34 +1164,34 @@ static void iwl_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 */ - if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_rt.code, + if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic(priv), &nic(priv)->fw.ucode_rt.data, + if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(nic(priv), - &nic(priv)->fw.ucode_init.code, + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic(priv), - &nic(priv)->fw.ucode_init.data, + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; } /* WoWLAN instructions and data */ if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(nic(priv), - &nic(priv)->fw.ucode_wowlan.code, + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_wowlan.code, pieces.wowlan_inst, pieces.wowlan_inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic(priv), - &nic(priv)->fw.ucode_wowlan.data, + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_wowlan.data, pieces.wowlan_data, pieces.wowlan_data_size)) goto err_pci_alloc; @@ -1210,14 +1209,14 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; else nic->init_evtlog_size = - cfg(priv)->base_params->max_event_log_size; + cfg->base_params->max_event_log_size; nic->init_errlog_ptr = pieces.init_errlog_ptr; nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; if (pieces.inst_evtlog_size) nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; else nic->inst_evtlog_size = - cfg(priv)->base_params->max_event_log_size; + cfg->base_params->max_event_log_size; nic->inst_errlog_ptr = pieces.inst_errlog_ptr; #ifndef CONFIG_IWLWIFI_P2P ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; @@ -1226,7 +1225,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) priv->new_scan_threshold_behaviour = !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); - if (!(cfg(priv)->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) + if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; /* @@ -1238,10 +1237,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; - priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; + nic->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; } else { priv->sta_key_max_num = STA_KEY_MAX_NUM; - priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; + nic->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; } /* * figure out the offset of chain noise reset and gain commands @@ -1271,7 +1270,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) err = iwl_dbgfs_register(priv, DRV_NAME); if (err) - IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); + IWL_ERR(nic, + "failed to create debugfs files. Ignoring error: %d\n", + err); /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); @@ -1280,17 +1281,17 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) try_again: /* try next, if any */ - if (iwl_request_firmware(priv, false)) + if (iwl_request_firmware(nic, false)) goto out_unbind; release_firmware(ucode_raw); return; err_pci_alloc: - IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(nic(priv)); + IWL_ERR(nic, "failed to allocate pci memory\n"); + iwl_dealloc_ucode(nic); out_unbind: complete(&nic->request_firmware_complete); - device_release_driver(trans(priv)->dev); + device_release_driver(trans(nic)->dev); release_firmware(ucode_raw); } diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-ucode.h index 5e4b88e05c62..d13e6241f126 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.h +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.h @@ -218,8 +218,4 @@ struct iwl_fw { bool enhance_sensitivity_table; }; -struct iwl_priv; - -int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first); - #endif /* __iwl_ucode_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index 392f1113d954..84172f6de4bb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -95,6 +95,7 @@ struct iwl_nic { }; +int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first); void iwl_dealloc_ucode(struct iwl_nic *nic); int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); -- GitLab From 4a986777a53d5fe8fd92ef30e0e8eedd0ff800b1 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 6 Feb 2012 17:06:07 -0800 Subject: [PATCH 0858/1846] iwlwifi: save ucode capabilities in iwl_fw The capabilities parsed from the ucode file are never saved. Save them in the iwl_fw structure. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.h | 8 ++--- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans.h | 3 -- drivers/net/wireless/iwlwifi/iwl-ucode.c | 38 ++++++++++----------- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 8a170b7f1e17..79894aca9644 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -65,11 +65,7 @@ #include "iwl-dev.h" -struct iwlagn_ucode_capabilities { - u32 max_probe_length; - u32 standard_phy_calibration_size; - u32 flags; -}; +struct iwl_ucode_capabilities; extern struct ieee80211_ops iwlagn_hw_ops; @@ -88,7 +84,7 @@ void iwlagn_prepare_restart(struct iwl_priv *priv); /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); int iwlagn_mac_setup_register(struct iwl_priv *priv, - struct iwlagn_ucode_capabilities *capa); + struct iwl_ucode_capabilities *capa); void iwlagn_mac_unregister(struct iwl_priv *priv); /* RXON */ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 90d8081426f6..9c29234221fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -136,7 +136,7 @@ iwlagn_iface_combinations_p2p[] = { * other mac80211 functions grouped here. */ int iwlagn_mac_setup_register(struct iwl_priv *priv, - struct iwlagn_ucode_capabilities *capa) + struct iwl_ucode_capabilities *capa) { int ret; struct ieee80211_hw *hw = priv->hw; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 20b50a0e0a86..cc7a3cfb5f24 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -321,9 +321,6 @@ enum iwl_trans_state { * Set during transport allocation. * @hw_id_str: a string with info about HW ID. Set during transport allocation. * @ucode_write_complete: indicates that the ucode has been copied. - * @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 * @pm_support: set to true in start_hw if link pm is supported * @calib_results: list head for init calibration results diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 01768f709a76..9e21fc15c5f8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -805,7 +805,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, static int iwl_parse_tlv_firmware(struct iwl_nic *nic, const struct firmware *ucode_raw, struct iwlagn_firmware_pieces *pieces, - struct iwlagn_ucode_capabilities *capa) + struct iwl_ucode_capabilities *capa) { struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; struct iwl_ucode_tlv *tlv; @@ -1012,6 +1012,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) { struct iwl_nic *nic = context; struct iwl_cfg *cfg = cfg(nic); + struct iwl_fw *fw = &nic->fw; struct iwl_priv *priv = priv(nic); /* temporary */ struct iwl_ucode_header *ucode; int err; @@ -1022,11 +1023,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) u32 api_ver; char buildstr[25]; u32 build; - struct iwlagn_ucode_capabilities ucode_capa = { - .max_probe_length = 200, - .standard_phy_calibration_size = - IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE, - }; + + fw->ucode_capa.max_probe_length = 200; + fw->ucode_capa.standard_phy_calibration_size = + IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; if (!api_ok) api_ok = api_max; @@ -1057,7 +1057,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); else err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, - &ucode_capa); + &fw->ucode_capa); if (err) goto try_again; @@ -1219,23 +1219,23 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) cfg->base_params->max_event_log_size; nic->inst_errlog_ptr = pieces.inst_errlog_ptr; #ifndef CONFIG_IWLWIFI_P2P - ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; + fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; #endif priv->new_scan_threshold_behaviour = - !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); + !!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) - ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; + fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; /* * if not PAN, then don't support P2P -- might be a uCode * packaging bug or due to the eeprom check above */ - if (!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) - ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; + if (!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) + fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; - if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { + if (fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; nic->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; } else { @@ -1246,25 +1246,25 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * figure out the offset of chain noise reset and gain commands * base on the size of standard phy calibration commands table size */ - if (ucode_capa.standard_phy_calibration_size > + if (fw->ucode_capa.standard_phy_calibration_size > IWL_MAX_PHY_CALIBRATE_TBL_SIZE) - ucode_capa.standard_phy_calibration_size = + fw->ucode_capa.standard_phy_calibration_size = IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; priv->phy_calib_chain_noise_reset_cmd = - ucode_capa.standard_phy_calibration_size; + fw->ucode_capa.standard_phy_calibration_size; priv->phy_calib_chain_noise_gain_cmd = - ucode_capa.standard_phy_calibration_size + 1; + fw->ucode_capa.standard_phy_calibration_size + 1; /* initialize all valid contexts */ - iwl_init_context(priv, ucode_capa.flags); + iwl_init_context(priv, fw->ucode_capa.flags); /************************************************** * This is still part of probe() in a sense... * * 9. Setup and register with mac80211 and debugfs **************************************************/ - err = iwlagn_mac_setup_register(priv, &ucode_capa); + err = iwlagn_mac_setup_register(priv, &fw->ucode_capa); if (err) goto out_unbind; -- GitLab From dae66d0d2ee1a188fcfd437c4e6b2bf32dc7a1b2 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 7 Feb 2012 12:56:26 +0200 Subject: [PATCH 0859/1846] iwlwifi: SRAM size moves from hw_params to cfg This will allow to set the hw_params after we fetch the uCode. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-1000.c | 6 ++++-- drivers/net/wireless/iwlwifi/iwl-2000.c | 10 ++++++++-- drivers/net/wireless/iwlwifi/iwl-5000.c | 10 ++++++---- drivers/net/wireless/iwlwifi/iwl-6000.c | 14 ++++++++++++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 8 ++++---- drivers/net/wireless/iwlwifi/iwl-ucode.c | 8 ++++---- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 91c4a72da8d7..605ee3df1d82 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -128,8 +128,6 @@ static void iwl1000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE; - hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); @@ -191,6 +189,8 @@ static struct iwl_ht_params iwl1000_ht_params = { .ucode_api_max = IWL1000_UCODE_API_MAX, \ .ucode_api_ok = IWL1000_UCODE_API_OK, \ .ucode_api_min = IWL1000_UCODE_API_MIN, \ + .max_inst_size = IWLAGN_RTC_INST_SIZE, \ + .max_data_size = IWLAGN_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \ .lib = &iwl1000_lib, \ @@ -213,6 +213,8 @@ struct iwl_cfg iwl1000_bg_cfg = { .ucode_api_max = IWL100_UCODE_API_MAX, \ .ucode_api_ok = IWL100_UCODE_API_OK, \ .ucode_api_min = IWL100_UCODE_API_MIN, \ + .max_inst_size = IWLAGN_RTC_INST_SIZE, \ + .max_data_size = IWLAGN_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_1000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_1000_TX_POWER_VERSION, \ .lib = &iwl1000_lib, \ diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 75f0e5088662..e6e8c79a80d8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -124,8 +124,6 @@ static void iwl2000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE; - hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); @@ -240,6 +238,8 @@ static struct iwl_bt_params iwl2030_bt_params = { .ucode_api_max = IWL2000_UCODE_API_MAX, \ .ucode_api_ok = IWL2000_UCODE_API_OK, \ .ucode_api_min = IWL2000_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .lib = &iwl2000_lib, \ @@ -266,6 +266,8 @@ struct iwl_cfg iwl2000_2bgn_d_cfg = { .ucode_api_max = IWL2030_UCODE_API_MAX, \ .ucode_api_ok = IWL2030_UCODE_API_OK, \ .ucode_api_min = IWL2030_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .lib = &iwl2030_lib, \ @@ -288,6 +290,8 @@ struct iwl_cfg iwl2030_2bgn_cfg = { .ucode_api_max = IWL105_UCODE_API_MAX, \ .ucode_api_ok = IWL105_UCODE_API_OK, \ .ucode_api_min = IWL105_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .lib = &iwl2000_lib, \ @@ -316,6 +320,8 @@ struct iwl_cfg iwl105_bgn_d_cfg = { .ucode_api_max = IWL135_UCODE_API_MAX, \ .ucode_api_ok = IWL135_UCODE_API_OK, \ .ucode_api_min = IWL135_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .lib = &iwl2030_lib, \ diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 458e6778c72f..1527dec7a267 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -170,8 +170,6 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE; - hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); @@ -195,8 +193,6 @@ static void iwl5150_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE; - hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); @@ -352,6 +348,8 @@ static struct iwl_ht_params iwl5000_ht_params = { .fw_name_pre = IWL5000_FW_PRE, \ .ucode_api_max = IWL5000_UCODE_API_MAX, \ .ucode_api_min = IWL5000_UCODE_API_MIN, \ + .max_inst_size = IWLAGN_RTC_INST_SIZE, \ + .max_data_size = IWLAGN_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_5000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, \ .lib = &iwl5000_lib, \ @@ -395,6 +393,8 @@ struct iwl_cfg iwl5350_agn_cfg = { .fw_name_pre = IWL5000_FW_PRE, .ucode_api_max = IWL5000_UCODE_API_MAX, .ucode_api_min = IWL5000_UCODE_API_MIN, + .max_inst_size = IWLAGN_RTC_INST_SIZE, + .max_data_size = IWLAGN_RTC_DATA_SIZE, .eeprom_ver = EEPROM_5050_EEPROM_VERSION, .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, .lib = &iwl5000_lib, @@ -408,6 +408,8 @@ struct iwl_cfg iwl5350_agn_cfg = { .fw_name_pre = IWL5150_FW_PRE, \ .ucode_api_max = IWL5150_UCODE_API_MAX, \ .ucode_api_min = IWL5150_UCODE_API_MIN, \ + .max_inst_size = IWLAGN_RTC_INST_SIZE, \ + .max_data_size = IWLAGN_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_5050_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, \ .lib = &iwl5150_lib, \ diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 19e41037f61e..1e6fbf4fcb46 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -145,8 +145,6 @@ static void iwl6000_hw_set_hw_params(struct iwl_priv *priv) iwlagn_mod_params.num_of_queues; hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE; - hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); @@ -348,6 +346,8 @@ static struct iwl_bt_params iwl6000_bt_params = { .ucode_api_max = IWL6000G2_UCODE_API_MAX, \ .ucode_api_ok = IWL6000G2_UCODE_API_OK, \ .ucode_api_min = IWL6000G2_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_6005_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_6005_TX_POWER_VERSION, \ .lib = &iwl6000_lib, \ @@ -388,6 +388,8 @@ struct iwl_cfg iwl6005_2agn_d_cfg = { .ucode_api_max = IWL6000G2_UCODE_API_MAX, \ .ucode_api_ok = IWL6000G2_UCODE_API_OK, \ .ucode_api_min = IWL6000G2_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .eeprom_ver = EEPROM_6030_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_6030_TX_POWER_VERSION, \ .lib = &iwl6030_lib, \ @@ -457,6 +459,8 @@ struct iwl_cfg iwl130_bg_cfg = { .ucode_api_max = IWL6000_UCODE_API_MAX, \ .ucode_api_ok = IWL6000_UCODE_API_OK, \ .ucode_api_min = IWL6000_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .valid_tx_ant = ANT_BC, /* .cfg overwrite */ \ .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \ .eeprom_ver = EEPROM_6000_EEPROM_VERSION, \ @@ -486,6 +490,8 @@ struct iwl_cfg iwl6000i_2bg_cfg = { .fw_name_pre = IWL6050_FW_PRE, \ .ucode_api_max = IWL6050_UCODE_API_MAX, \ .ucode_api_min = IWL6050_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .valid_tx_ant = ANT_AB, /* .cfg overwrite */ \ .valid_rx_ant = ANT_AB, /* .cfg overwrite */ \ .lib = &iwl6000_lib, \ @@ -511,6 +517,8 @@ struct iwl_cfg iwl6050_2abg_cfg = { .fw_name_pre = IWL6050_FW_PRE, \ .ucode_api_max = IWL6050_UCODE_API_MAX, \ .ucode_api_min = IWL6050_UCODE_API_MIN, \ + .max_inst_size = IWL60_RTC_INST_SIZE, \ + .max_data_size = IWL60_RTC_DATA_SIZE, \ .lib = &iwl6000_lib, \ .additional_nic_config = iwl6150_additional_nic_config, \ .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \ @@ -536,6 +544,8 @@ struct iwl_cfg iwl6000_3agn_cfg = { .ucode_api_max = IWL6000_UCODE_API_MAX, .ucode_api_ok = IWL6000_UCODE_API_OK, .ucode_api_min = IWL6000_UCODE_API_MIN, + .max_inst_size = IWL60_RTC_INST_SIZE, + .max_data_size = IWL60_RTC_DATA_SIZE, .eeprom_ver = EEPROM_6000_EEPROM_VERSION, .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, .lib = &iwl6000_lib, diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 8c6fc6e20768..f810b41db9df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -173,8 +173,6 @@ struct iwl_mod_params { * @ht40_channel: is 40MHz width possible: BIT(IEEE80211_BAND_XXX) * @sku: sku read from EEPROM * @rx_page_order: Rx buffer page order - * @max_inst_size: for ucode use - * @max_data_size: for ucode use * @ct_kill_threshold: temperature threshold - in hw dependent unit * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit * relevant for 1000, 6000 and up @@ -192,8 +190,6 @@ struct iwl_hw_params { bool shadow_reg_enable; u16 sku; u32 rx_page_order; - u32 max_inst_size; - u32 max_data_size; u32 ct_kill_threshold; u32 ct_kill_exit_threshold; unsigned int wd_timeout; @@ -283,6 +279,8 @@ enum iwl_led_mode { * @ucode_api_ok: oldest version of the uCode API that is OK to load * without a warning, for use in transitions * @ucode_api_min: Lowest version of uCode API supported by driver. + * @max_inst_size: The maximal length of the fw inst section + * @max_data_size: The maximal length of the fw data section * @valid_tx_ant: valid transmit antenna * @valid_rx_ant: valid receive antenna * @sku: sku information from EEPROM @@ -320,6 +318,8 @@ struct iwl_cfg { const unsigned int ucode_api_max; const unsigned int ucode_api_ok; const unsigned int ucode_api_min; + const u32 max_data_size; + const u32 max_inst_size; u8 valid_tx_ant; u8 valid_rx_ant; u16 sku; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 9e21fc15c5f8..61c6c0568c11 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -1135,25 +1135,25 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) pieces.init_data_size); /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > hw_params(nic).max_inst_size) { + if (pieces.inst_size > cfg->max_inst_size) { IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } - if (pieces.data_size > hw_params(nic).max_data_size) { + if (pieces.data_size > cfg->max_data_size) { IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } - if (pieces.init_size > hw_params(nic).max_inst_size) { + if (pieces.init_size > cfg->max_inst_size) { IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } - if (pieces.init_data_size > hw_params(nic).max_data_size) { + if (pieces.init_data_size > cfg->max_data_size) { IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; -- GitLab From dd63b84eb44ba4e34daa83cf535a8bb79bc7f2e2 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 8 Feb 2012 15:57:39 -0800 Subject: [PATCH 0860/1846] iwlwifi: remove un-necessary return Already return 0, change to void Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-core.c | 5 ++--- drivers/net/wireless/iwlwifi/iwl-core.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 6dff9c41c555..f3b72bc84d25 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -643,7 +643,7 @@ u8 iwl_get_single_channel_number(struct iwl_priv *priv, * 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_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, +void iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, struct iwl_rxon_context *ctx) { enum ieee80211_band band = ch->band; @@ -651,7 +651,7 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, if ((le16_to_cpu(ctx->staging.channel) == channel) && (priv->band == band)) - return 0; + return; ctx->staging.channel = cpu_to_le16(channel); if (band == IEEE80211_BAND_5GHZ) @@ -663,7 +663,6 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); - return 0; } void iwl_set_flags_for_band(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 49370dd37768..930e247bbae6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -169,7 +169,7 @@ void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, int hw_decrypt); int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx); int iwl_full_rxon_required(struct iwl_priv *priv, struct iwl_rxon_context *ctx); -int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, +void iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, struct iwl_rxon_context *ctx); void iwl_set_flags_for_band(struct iwl_priv *priv, struct iwl_rxon_context *ctx, -- GitLab From 758f555f5e69bb44fc85edb90b3d15e68a29bc0c Mon Sep 17 00:00:00 2001 From: Meenakshi Venkataraman Date: Wed, 8 Feb 2012 12:04:41 -0800 Subject: [PATCH 0861/1846] iwlwifi: enable receiving beacons when not associated If the firmware implements beacon filtering, beacons are filtered when not associated. This causes association failures on channels marked passive. Enabling this flag indicates to the firmware to allow the beacons to pass through when not associated only. Signed-off-by: Meenakshi Venkataraman Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 8ca9570ec365..35dd7e364b46 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -900,6 +900,22 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, } } + /* + * If the ucode decides to do beacon filtering before + * association, it will lose beacons that are needed + * before sending frames out on passive channels. This + * causes association failures on those channels. Enable + * receiving beacons in such cases. + */ + + if (vif->type == NL80211_IFTYPE_STATION) { + if (!bss_conf->assoc) + ctx->staging.filter_flags |= RXON_FILTER_BCON_AWARE_MSK; + else + ctx->staging.filter_flags &= + ~RXON_FILTER_BCON_AWARE_MSK; + } + if (force || memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) iwlagn_commit_rxon(priv, ctx); -- GitLab From 7718f2c27dbdae0b22b2268a9c1b38edf0d8fa16 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:22 +0000 Subject: [PATCH 0862/1846] au1000_eth: use eth_hw_addr_random() instead of random_ether_addr() Use eth_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. v2: adapt to eth_hw_addr_random() Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/amd/au1000_eth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index c1dfdc8b7079..397596b078d9 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -1129,9 +1129,6 @@ static int __devinit au1000_probe(struct platform_device *pdev) au1000_setup_hw_rings(aup, aup->macdma); - /* set a random MAC now in case platform_data doesn't provide one */ - random_ether_addr(dev->dev_addr); - writel(0, aup->enable); aup->mac_enabled = 0; @@ -1141,8 +1138,12 @@ static int __devinit au1000_probe(struct platform_device *pdev) " PHY search on MAC0\n"); aup->phy1_search_mac0 = 1; } else { - if (is_valid_ether_addr(pd->mac)) + if (is_valid_ether_addr(pd->mac)) { memcpy(dev->dev_addr, pd->mac, 6); + } else { + /* Set a random MAC since no valid provided by platform_data. */ + eth_hw_addr_random(dev); + } aup->phy_static_config = pd->phy_static_config; aup->phy_search_highest_addr = pd->phy_search_highest_addr; -- GitLab From 43aabec51e0ab5d71c30530eec55963673354033 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:23 +0000 Subject: [PATCH 0863/1846] lantiq_etop: set addr_assign_type if random_ether_addr() used Set addr_assign_type correctly to NET_ADDR_RANDOM in case a random MAC address was generated and assigned to the netdevice. v2: added comment, renamed bool variable to random_mac Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/lantiq_etop.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c index 3369b7db777d..e89808ff73ed 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -634,6 +634,7 @@ ltq_etop_init(struct net_device *dev) struct ltq_etop_priv *priv = netdev_priv(dev); struct sockaddr mac; int err; + bool random_mac = false; ether_setup(dev); dev->watchdog_timeo = 10 * HZ; @@ -646,11 +647,17 @@ ltq_etop_init(struct net_device *dev) if (!is_valid_ether_addr(mac.sa_data)) { pr_warn("etop: invalid MAC, using random\n"); random_ether_addr(mac.sa_data); + random_mac = true; } err = ltq_etop_set_mac_address(dev, &mac); if (err) goto err_netdev; + + /* Set addr_assign_type here, ltq_etop_set_mac_address would reset it. */ + if (random_mac) + dev->addr_assign_type |= NET_ADDR_RANDOM; + ltq_etop_set_multicast_list(dev); err = ltq_etop_mdio_init(dev); if (err) -- GitLab From baf1d3788e513cadfa26d400b1ae7a13c949f0ff Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:24 +0000 Subject: [PATCH 0864/1846] davinci_emac: use eth_hw_addr_random() instead of random_ether_addr() Use eth_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. Remove one memcpy from emac_dev_setmac_addr() since this is a duplicate: it's already done some lines above. v2: use bitops, adapt to eth_hw_addr_random, remove a memcpy Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/davinci_emac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 6b0659c59ddd..f053aebbaa06 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1259,10 +1259,10 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr) /* Store mac addr in priv and rx channel and set it in EMAC hw */ memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len); memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len); + ndev->addr_assign_type &= ~NET_ADDR_RANDOM; /* MAC address is configured only after the interface is enabled. */ if (netif_running(ndev)) { - memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len); emac_setmac(priv, EMAC_DEF_RX_CH, priv->mac_addr); } @@ -1896,7 +1896,8 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev) if (!is_valid_ether_addr(priv->mac_addr)) { /* Use random MAC if none passed */ - random_ether_addr(priv->mac_addr); + eth_hw_addr_random(ndev); + memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len); dev_warn(&pdev->dev, "using random MAC addr: %pM\n", priv->mac_addr); } -- GitLab From 5a5e7c36448664a58d13aab5a9006b01f6a58910 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:25 +0000 Subject: [PATCH 0865/1846] xilinx ll_temac: use eth_hw_addr_random() instead of random_ether_addr() Use eth_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: reworked to prevent using an extra variable Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/xilinx/ll_temac_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index d8eb9c9e3ee2..eb285418924e 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -327,7 +327,9 @@ static int temac_set_mac_address(struct net_device *ndev, void *address) memcpy(ndev->dev_addr, address, ETH_ALEN); if (!is_valid_ether_addr(ndev->dev_addr)) - random_ether_addr(ndev->dev_addr); + eth_hw_addr_random(ndev); + else + dev->addr_assign_type &= ~NET_ADDR_RANDOM; /* set up unicast MAC address filter set its mac address */ mutex_lock(&lp->indirect_mutex); -- GitLab From 067fb4c81944f8965a08cd91c0a1d66ccd09feea Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:26 +0000 Subject: [PATCH 0866/1846] igbvf: reset netdevice addr_assign_type if changed Reset the state of addr_assign_type to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: use bitops to reset addr_assign_type Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/igbvf/netdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index 92956e80fd1b..217c143686d2 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c @@ -1712,6 +1712,7 @@ static int igbvf_set_mac(struct net_device *netdev, void *p) return -EADDRNOTAVAIL; memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); + netdev->addr_assign_type &= ~NET_ADDR_RANDOM; return 0; } -- GitLab From 28009a6cab764f04d4e7c409c180c77b2ef36ba1 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:27 +0000 Subject: [PATCH 0867/1846] batman-adv: use eth_hw_addr_random() instead of random_ether_addr() Use eth_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. Remove dev_addr in interface_setup(), it's not needed anymore. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: use bitops, adapt to eth_hw_addr_random() Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- net/batman-adv/soft-interface.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index b5aecd5e45cc..2d8bd2ad6ba3 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -541,6 +541,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p) } memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + dev->addr_assign_type &= ~NET_ADDR_RANDOM; return 0; } @@ -783,7 +784,6 @@ static const struct net_device_ops bat_netdev_ops = { static void interface_setup(struct net_device *dev) { struct bat_priv *priv = netdev_priv(dev); - char dev_addr[ETH_ALEN]; ether_setup(dev); @@ -800,8 +800,7 @@ static void interface_setup(struct net_device *dev) dev->hard_header_len = BAT_HEADER_LEN; /* generate random address */ - random_ether_addr(dev_addr); - memcpy(dev->dev_addr, dev_addr, ETH_ALEN); + eth_hw_addr_random(dev); SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); -- GitLab From 939d2254fc259fd5ca0872f96b56f6966d804e24 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:29 +0000 Subject: [PATCH 0868/1846] ethoc: set addr_assign_type if random_ether_addr() used Set addr_assign_type correctly to NET_ADDR_RANDOM in case a random MAC address was generated and assigned to the netdevice. Fixed ethoc_set_mac_address() to check if the given mac address is valid and set also dev_addr of the net_device. Check also the return value of ethoc_set_mac_address() in ethoc_probe(). Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: set net_device->dev_addr in ethoc_set_mac_address(), check if given address is valid Signed-off-by: Danny Kukawka --- drivers/net/ethernet/ethoc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 0b723ff2294b..a38167810546 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -776,10 +776,16 @@ static int ethoc_set_mac_address(struct net_device *dev, void *addr) struct ethoc *priv = netdev_priv(dev); u8 *mac = (u8 *)addr; + if (!is_valid_ether_addr(mac)) + return -EADDRNOTAVAIL; + ethoc_write(priv, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | (mac[5] << 0)); ethoc_write(priv, MAC_ADDR1, (mac[0] << 8) | (mac[1] << 0)); + memcpy(dev->dev_addr, mac, ETH_ALEN); + dev->addr_assign_type &= ~NET_ADDR_RANDOM; + return 0; } @@ -909,6 +915,7 @@ static int __devinit ethoc_probe(struct platform_device *pdev) unsigned int phy; int num_bd; int ret = 0; + bool random_mac = false; /* allocate networking device */ netdev = alloc_etherdev(sizeof(struct ethoc)); @@ -1049,10 +1056,19 @@ static int __devinit ethoc_probe(struct platform_device *pdev) /* Check the MAC again for validity, if it still isn't choose and * program a random one. */ - if (!is_valid_ether_addr(netdev->dev_addr)) + if (!is_valid_ether_addr(netdev->dev_addr)) { random_ether_addr(netdev->dev_addr); + random_mac = true; + } + + ret = ethoc_set_mac_address(netdev, netdev->dev_addr); + if (ret) { + dev_err(&netdev->dev, "failed to set MAC address\n"); + goto error; + } - ethoc_set_mac_address(netdev, netdev->dev_addr); + if (random_mac) + netdev->addr_assign_type |= NET_ADDR_RANDOM; /* register MII bus */ priv->mdio = mdiobus_alloc(); -- GitLab From 6a214fd4142d585ef2226e8ef6bc29a15403506f Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 05:43:30 +0000 Subject: [PATCH 0869/1846] atheros eth: set addr_assign_type if random_ether_addr() used Set addr_assign_type correctly to NET_ADDR_RANDOM in case a random MAC address was generated and assigned to the netdevice. Fix error handling in atl1c_probe(). If atl1c_read_mac_addr() couldn't get the hw mac address, and a random mac address get set return the error code. Don't go to err_eeprom in atl1c_probe(), use the generated MAC address in this case. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: use bitops Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/atheros/atl1c/atl1c_hw.c | 2 +- drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 9 ++++----- drivers/net/ethernet/atheros/atlx/atl1.c | 12 +++++++++--- drivers/net/ethernet/atheros/atlx/atlx.c | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c index 23f2ab0f2fa8..bd1667cbffa6 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c @@ -224,7 +224,7 @@ int atl1c_read_mac_addr(struct atl1c_hw *hw) random_ether_addr(hw->perm_mac_addr); memcpy(hw->mac_addr, hw->perm_mac_addr, sizeof(hw->perm_mac_addr)); - return 0; + return err; } /* diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index 2c8ed70704aa..ccdf1f6e2f9f 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c @@ -468,6 +468,7 @@ static int atl1c_set_mac_addr(struct net_device *netdev, void *p) memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len); + netdev->addr_assign_type &= ~NET_ADDR_RANDOM; atl1c_hw_set_mac_addr(&adapter->hw); @@ -2745,10 +2746,9 @@ static int __devinit atl1c_probe(struct pci_dev *pdev, err = -EIO; goto err_reset; } - if (atl1c_read_mac_addr(&adapter->hw) != 0) { - err = -EIO; - dev_err(&pdev->dev, "get mac address failed\n"); - goto err_eeprom; + if (atl1c_read_mac_addr(&adapter->hw)) { + /* got a random MAC address, set NET_ADDR_RANDOM to netdev */ + netdev->addr_assign_type |= NET_ADDR_RANDOM; } memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len); @@ -2773,7 +2773,6 @@ static int __devinit atl1c_probe(struct pci_dev *pdev, err_reset: err_register: err_sw_init: -err_eeprom: iounmap(adapter->hw.hw_addr); err_init_netdev: err_ioremap: diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c index 9bd204976648..40ac41436549 100644 --- a/drivers/net/ethernet/atheros/atlx/atl1.c +++ b/drivers/net/ethernet/atheros/atlx/atl1.c @@ -534,14 +534,17 @@ static int atl1_get_permanent_address(struct atl1_hw *hw) */ static s32 atl1_read_mac_addr(struct atl1_hw *hw) { + s32 ret = 0; u16 i; - if (atl1_get_permanent_address(hw)) + if (atl1_get_permanent_address(hw)) { random_ether_addr(hw->perm_mac_addr); + ret = 1; + } for (i = 0; i < ETH_ALEN; i++) hw->mac_addr[i] = hw->perm_mac_addr[i]; - return 0; + return ret; } /* @@ -3007,7 +3010,10 @@ static int __devinit atl1_probe(struct pci_dev *pdev, } /* copy the MAC address out of the EEPROM */ - atl1_read_mac_addr(&adapter->hw); + if (atl1_read_mac_addr(&adapter->hw)) { + /* mark random mac */ + netdev->addr_assign_type |= NET_ADDR_RANDOM; + } memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); if (!is_valid_ether_addr(netdev->dev_addr)) { diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c index 8ff7411094d5..3cd8837236dc 100644 --- a/drivers/net/ethernet/atheros/atlx/atlx.c +++ b/drivers/net/ethernet/atheros/atlx/atlx.c @@ -84,6 +84,7 @@ static int atlx_set_mac(struct net_device *netdev, void *p) memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len); + netdev->addr_assign_type &= ~NET_ADDR_RANDOM; atlx_set_mac_addr(&adapter->hw); return 0; -- GitLab From 95f2054f167f7da72b0771984dbb2bec612740d0 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 17 Feb 2012 16:05:03 -0500 Subject: [PATCH 0870/1846] UML net: set addr_assign_type if random_ether_addr() used Set addr_assign_type correctly to NET_ADDR_RANDOM in case a random MAC address was generated and assigned to the netdevice. Return state from setup_etheraddr() about returning a random MAC address or not and check this state in eth_configure(). Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- arch/um/drivers/net_kern.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index a492e59883a3..d2996183e584 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -293,7 +293,7 @@ static void uml_net_user_timer_expire(unsigned long _conn) #endif } -static void setup_etheraddr(char *str, unsigned char *addr, char *name) +static int setup_etheraddr(char *str, unsigned char *addr, char *name) { char *end; int i; @@ -334,12 +334,13 @@ static void setup_etheraddr(char *str, unsigned char *addr, char *name) addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], addr[5]); } - return; + return 0; random: printk(KERN_INFO "Choosing a random ethernet address for device %s\n", name); random_ether_addr(addr); + return 1; } static DEFINE_SPINLOCK(devices_lock); @@ -391,6 +392,7 @@ static void eth_configure(int n, void *init, char *mac, struct net_device *dev; struct uml_net_private *lp; int err, size; + int random_mac; size = transport->private_size + sizeof(struct uml_net_private); @@ -417,7 +419,7 @@ static void eth_configure(int n, void *init, char *mac, */ snprintf(dev->name, sizeof(dev->name), "eth%d", n); - setup_etheraddr(mac, device->mac, dev->name); + random_mac = setup_etheraddr(mac, device->mac, dev->name); printk(KERN_INFO "Netdevice %d (%pM) : ", n, device->mac); @@ -474,6 +476,9 @@ static void eth_configure(int n, void *init, char *mac, /* don't use eth_mac_addr, it will not work here */ memcpy(dev->dev_addr, device->mac, ETH_ALEN); + if (random_mac) + dev->addr_assign_type |= NET_ADDR_RANDOM; + dev->mtu = transport->user->mtu; dev->netdev_ops = ¨_netdev_ops; dev->ethtool_ops = ¨_net_ethtool_ops; -- GitLab From b4a466765d3fb05c1f63ddc5d195980ead894ded Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 17 Feb 2012 05:35:37 +0000 Subject: [PATCH 0871/1846] net: ethernet: xilinx: Convert xilinx_axienet to module_platform_driver Follow commit db62f684. Convert the driver to use the module_platform_driver() macro which makes the code a bit smaller and simpler. Signed-off-by: Tobias Klauser Signed-off-by: David S. Miller --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index a7cf00438a36..2fcbeba6814b 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1662,18 +1662,7 @@ static struct platform_driver axienet_of_driver = { }, }; -static int __init axienet_init(void) -{ - return platform_driver_register(&axienet_of_driver); -} - -static void __exit axienet_exit(void) -{ - platform_driver_unregister(&axienet_of_driver); -} - -module_init(axienet_init); -module_exit(axienet_exit); +module_platform_driver(axienet_of_driver); MODULE_DESCRIPTION("Xilinx Axi Ethernet driver"); MODULE_AUTHOR("Xilinx"); -- GitLab From da1943164677ae2cdd630196b79089d476726348 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Sat, 18 Feb 2012 01:50:43 -0500 Subject: [PATCH 0872/1846] cisco/enic: use eth_hw_addr_random() instead of random_ether_addr() Use dev_hw_addr_random() instead of calling random_ether_addr() to set addr_assign_type correctly to NET_ADDR_RANDOM. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v3: adapt to net-next v2: use bitops, adapt to eth_hw_addr_random(), add a comment Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index dd7e24b9ffbb..7dfa567b7e04 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -865,6 +865,7 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr) } memcpy(netdev->dev_addr, addr, netdev->addr_len); + netdev->addr_assign_type &= ~NET_ADDR_RANDOM; return 0; } @@ -1119,7 +1120,7 @@ static int enic_set_vf_port(struct net_device *netdev, int vf, memcpy(pp->mac_addr, prev_pp.vf_mac, ETH_ALEN); if (vf == PORT_SELF_VF && is_zero_ether_addr(netdev->dev_addr)) - random_ether_addr(netdev->dev_addr); + eth_hw_addr_random(netdev); err = enic_process_set_pp_request(enic, vf, &prev_pp, &restore_pp); if (err) { -- GitLab From f39799f5047c4827b200acbf33cd0ba076afd7ed Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 17 Feb 2012 20:39:35 -0300 Subject: [PATCH 0873/1846] Bluetooth: Prepare start_discovery This patch does some code refactoring in start_discovery function in order to prepare it for interleaved discovery support. MGMT_ADDR_* macros were moved to hci_core.h since they are now used to define discovery type macros. Discovery type macros were defined according to mgmt-api.txt specification: Possible values for the Type parameter are a bit-wise or of the following bits: 1 BR/EDR 2 LE Public 3 LE Random By combining these e.g. the following values are possible: 1 BR/EDR 6 LE (public & random) 7 BR/EDR/LE (interleaved discovery) Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 12 ++++++++++++ include/net/bluetooth/mgmt.h | 5 ----- net/bluetooth/mgmt.c | 15 ++++++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 43e0b1eda020..be8da5d54abb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -956,6 +956,18 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, struct sock *skip_sk); /* Management interface */ +#define MGMT_ADDR_BREDR 0x00 +#define MGMT_ADDR_LE_PUBLIC 0x01 +#define MGMT_ADDR_LE_RANDOM 0x02 +#define MGMT_ADDR_INVALID 0xff + +#define DISCOV_TYPE_BREDR (BIT(MGMT_ADDR_BREDR)) +#define DISCOV_TYPE_LE (BIT(MGMT_ADDR_LE_PUBLIC) | \ + BIT(MGMT_ADDR_LE_RANDOM)) +#define DISCOV_TYPE_INTERLEAVED (BIT(MGMT_ADDR_BREDR) | \ + BIT(MGMT_ADDR_LE_PUBLIC) | \ + BIT(MGMT_ADDR_LE_RANDOM)) + int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); int mgmt_index_added(struct hci_dev *hdev); int mgmt_index_removed(struct hci_dev *hdev); diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index ee625a6ad791..ad54b5fd634c 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -48,11 +48,6 @@ struct mgmt_hdr { __le16 len; } __packed; -#define MGMT_ADDR_BREDR 0x00 -#define MGMT_ADDR_LE_PUBLIC 0x01 -#define MGMT_ADDR_LE_RANDOM 0x02 -#define MGMT_ADDR_INVALID 0xff - struct mgmt_addr_info { bdaddr_t bdaddr; __u8 type; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f9f3e4c44150..196215c9d424 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2157,7 +2157,6 @@ static int start_discovery(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_start_discovery *cp = data; - unsigned long discov_type = cp->type; struct pending_cmd *cmd; struct hci_dev *hdev; int err; @@ -2193,14 +2192,20 @@ static int start_discovery(struct sock *sk, u16 index, goto failed; } - if (test_bit(MGMT_ADDR_BREDR, &discov_type)) + switch (cp->type) { + case DISCOV_TYPE_BREDR: + case DISCOV_TYPE_INTERLEAVED: err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); - else if (test_bit(MGMT_ADDR_LE_PUBLIC, &discov_type) && - test_bit(MGMT_ADDR_LE_RANDOM, &discov_type)) + break; + + case DISCOV_TYPE_LE: err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); - else + break; + + default: err = -EINVAL; + } if (err < 0) mgmt_pending_remove(cmd); -- GitLab From 4aab14e5504e84c42534378f91e836e6f55d0886 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 17 Feb 2012 20:39:36 -0300 Subject: [PATCH 0874/1846] Bluetooth: Track discovery type This patch adds to struct discovery_state the field 'type' so that we can track the discovery type the device is performing. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 2 ++ net/bluetooth/mgmt.c | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index be8da5d54abb..d7c79b5335c2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -57,6 +57,7 @@ struct inquiry_entry { }; struct discovery_state { + int type; enum { DISCOVERY_STOPPED, DISCOVERY_STARTING, diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index dc31e7d6028e..29a9b01c3b9b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -380,6 +380,8 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) switch (state) { case DISCOVERY_STOPPED: + hdev->discovery.type = 0; + if (hdev->discovery.state != DISCOVERY_STARTING) mgmt_discovering(hdev, 0); break; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 196215c9d424..9d98382e48c7 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2192,7 +2192,9 @@ static int start_discovery(struct sock *sk, u16 index, goto failed; } - switch (cp->type) { + hdev->discovery.type = cp->type; + + switch (hdev->discovery.type) { case DISCOV_TYPE_BREDR: case DISCOV_TYPE_INTERLEAVED: err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); -- GitLab From 343f935bfa44189c68527102c409286b0cfc4526 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 17 Feb 2012 20:39:37 -0300 Subject: [PATCH 0875/1846] Bluetooth: Merge INQUIRY and LE_SCAN discovery states This patch merges DISCOVERY_INQUIRY and DISCOVERY_LE_SCAN states into a new state called DISCOVERY_FINDING. From the discovery perspective, we are pretty much worried about to know just if we are finding devices than what exactly phase of "finding devices" (inquiry or LE scan) we are currently running. Besides, to know if the controller is performing inquiry or LE scan we should check HCI_INQUIRY or HCI_LE_SCAN bits in hdev flags. Moreover, merging this two states will simplify the discovery state machine and will keep interleaved discovery implementation simpler. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 3 +-- net/bluetooth/hci_core.c | 6 ++---- net/bluetooth/hci_event.c | 6 +++--- net/bluetooth/mgmt.c | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d7c79b5335c2..942de7764278 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -61,8 +61,7 @@ struct discovery_state { enum { DISCOVERY_STOPPED, DISCOVERY_STARTING, - DISCOVERY_INQUIRY, - DISCOVERY_LE_SCAN, + DISCOVERY_FINDING, DISCOVERY_RESOLVING, DISCOVERY_STOPPING, } state; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 29a9b01c3b9b..fabca080ae70 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -361,8 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev) struct discovery_state *discov = &hdev->discovery; switch (discov->state) { - case DISCOVERY_INQUIRY: - case DISCOVERY_LE_SCAN: + case DISCOVERY_FINDING: case DISCOVERY_RESOLVING: return true; @@ -387,8 +386,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) break; case DISCOVERY_STARTING: break; - case DISCOVERY_INQUIRY: - case DISCOVERY_LE_SCAN: + case DISCOVERY_FINDING: mgmt_discovering(hdev, 1); break; case DISCOVERY_RESOLVING: diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 179d127601fc..9aea7b898821 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1080,7 +1080,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, hci_dev_lock(hdev); hci_adv_entries_clear(hdev); - hci_discovery_set_state(hdev, DISCOVERY_LE_SCAN); + hci_discovery_set_state(hdev, DISCOVERY_FINDING); hci_dev_unlock(hdev); break; @@ -1159,7 +1159,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) set_bit(HCI_INQUIRY, &hdev->flags); hci_dev_lock(hdev); - hci_discovery_set_state(hdev, DISCOVERY_INQUIRY); + hci_discovery_set_state(hdev, DISCOVERY_FINDING); hci_dev_unlock(hdev); } @@ -1645,7 +1645,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff hci_dev_lock(hdev); - if (discov->state != DISCOVERY_INQUIRY) + if (discov->state != DISCOVERY_FINDING) goto unlock; if (list_empty(&discov->resolve)) { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9d98382e48c7..a9cd38dc2cab 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2250,7 +2250,7 @@ static int stop_discovery(struct sock *sk, u16 index) goto unlock; } - if (hdev->discovery.state == DISCOVERY_INQUIRY) { + if (hdev->discovery.state == DISCOVERY_FINDING) { err = hci_cancel_inquiry(hdev); if (err < 0) mgmt_pending_remove(cmd); -- GitLab From 5e0452c00a2e4b04ec1482248c897dacf106f1df Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 17 Feb 2012 20:39:38 -0300 Subject: [PATCH 0876/1846] Bluetooth: Interleaved discovery support This patch adds interleaved discovery support to MGMT Start Discovery command. In case interleaved discovery is not supported (not a dual mode device), we perform BR/EDR or LE-only discovery according to the device capabilities. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_event.c | 13 ++++++--- net/bluetooth/mgmt.c | 47 +++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 942de7764278..2aafeb3a8793 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -716,6 +716,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) +#define lmp_bredr_capable(dev) (!((dev)->features[4] & LMP_NO_BREDR)) /* ----- Extended LMP capabilities ----- */ #define lmp_host_le_capable(dev) ((dev)->host_features[0] & LMP_HOST_LE) @@ -1019,6 +1020,7 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_discovering(struct hci_dev *hdev, u8 discovering); +int mgmt_interleaved_discovery(struct hci_dev *hdev); int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9aea7b898821..04fb1f02dfcc 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1090,11 +1090,16 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, clear_bit(HCI_LE_SCAN, &hdev->dev_flags); - hci_dev_lock(hdev); - hci_discovery_set_state(hdev, DISCOVERY_STOPPED); - hci_dev_unlock(hdev); - schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT); + + if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED) { + mgmt_interleaved_discovery(hdev); + } else { + hci_dev_lock(hdev); + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + hci_dev_unlock(hdev); + } + break; default: diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a9cd38dc2cab..89754bbcd02b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -108,8 +108,10 @@ static const u16 mgmt_events[] = { #define LE_SCAN_WIN 0x12 #define LE_SCAN_INT 0x12 #define LE_SCAN_TIMEOUT_LE_ONLY 10240 /* TGAP(gen_disc_scan_min) */ +#define LE_SCAN_TIMEOUT_BREDR_LE 5120 /* TGAP(100)/2 */ #define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ +#define INQUIRY_LEN_BREDR_LE 0x04 /* TGAP(100)/2 */ #define SERVICE_CACHE_TIMEOUT (5 * 1000) @@ -2153,6 +2155,46 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, return err; } +static int discovery(struct hci_dev *hdev) +{ + int err; + + if (lmp_host_le_capable(hdev)) { + if (lmp_bredr_capable(hdev)) { + err = hci_le_scan(hdev, LE_SCAN_TYPE, + LE_SCAN_INT, LE_SCAN_WIN, + LE_SCAN_TIMEOUT_BREDR_LE); + } else { + hdev->discovery.type = DISCOV_TYPE_LE; + err = hci_le_scan(hdev, LE_SCAN_TYPE, + LE_SCAN_INT, LE_SCAN_WIN, + LE_SCAN_TIMEOUT_LE_ONLY); + } + } else { + hdev->discovery.type = DISCOV_TYPE_BREDR; + err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); + } + + return err; +} + +int mgmt_interleaved_discovery(struct hci_dev *hdev) +{ + int err; + + BT_DBG("%s", hdev->name); + + hci_dev_lock(hdev); + + err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR_LE); + if (err < 0) + hci_discovery_set_state(hdev, DISCOVERY_STOPPED); + + hci_dev_unlock(hdev); + + return err; +} + static int start_discovery(struct sock *sk, u16 index, void *data, u16 len) { @@ -2196,7 +2238,6 @@ static int start_discovery(struct sock *sk, u16 index, switch (hdev->discovery.type) { case DISCOV_TYPE_BREDR: - case DISCOV_TYPE_INTERLEAVED: err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); break; @@ -2205,6 +2246,10 @@ static int start_discovery(struct sock *sk, u16 index, LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); break; + case DISCOV_TYPE_INTERLEAVED: + err = discovery(hdev); + break; + default: err = -EINVAL; } -- GitLab From 3c6b764020d19b0993fe67f938b4b08f25c9bdd9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 18 Feb 2012 14:49:58 +0200 Subject: [PATCH 0877/1846] Bluetooth: mgmt: Change ordering of cmd_status paramters In accordance to the latest mgmt API specification the opcode comes first and then the status. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index ad54b5fd634c..36e68b4551af 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -318,8 +318,8 @@ struct mgmt_ev_cmd_complete { #define MGMT_EV_CMD_STATUS 0x0002 struct mgmt_ev_cmd_status { - __u8 status; __le16 opcode; + __u8 status; } __packed; #define MGMT_EV_CONTROLLER_ERROR 0x0003 -- GitLab From aee9b218036476b8b659de5bbfada3a4633f635b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 18 Feb 2012 15:07:59 +0200 Subject: [PATCH 0878/1846] Bluetooth: mgmt: Move status parameters into the cmd_complete header Instead of having status paramters part of each individual command response it's simpler to just have the status as part of the command complete header. This patch updates the code to follow this convention and thereby also ensures compliance with the latest mgmt API specification. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 8 +-- net/bluetooth/mgmt.c | 107 ++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 59 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 36e68b4551af..7e3d38bfaec3 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -184,7 +184,6 @@ struct mgmt_cp_disconnect { } __packed; struct mgmt_rp_disconnect { struct mgmt_addr_info addr; - __u8 status; } __packed; #define MGMT_OP_GET_CONNECTIONS 0x0015 @@ -201,7 +200,6 @@ struct mgmt_cp_pin_code_reply { } __packed; struct mgmt_rp_pin_code_reply { struct mgmt_addr_info addr; - uint8_t status; } __packed; #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 @@ -221,7 +219,6 @@ struct mgmt_cp_pair_device { } __packed; struct mgmt_rp_pair_device { struct mgmt_addr_info addr; - __u8 status; } __packed; #define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A @@ -233,7 +230,6 @@ struct mgmt_cp_unpair_device { } __packed; struct mgmt_rp_unpair_device { struct mgmt_addr_info addr; - __u8 status; }; #define MGMT_OP_USER_CONFIRM_REPLY 0x001C @@ -242,7 +238,6 @@ struct mgmt_cp_user_confirm_reply { } __packed; struct mgmt_rp_user_confirm_reply { struct mgmt_addr_info addr; - __u8 status; } __packed; #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D @@ -257,7 +252,6 @@ struct mgmt_cp_user_passkey_reply { } __packed; struct mgmt_rp_user_passkey_reply { struct mgmt_addr_info addr; - __u8 status; } __packed; #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F @@ -297,7 +291,6 @@ struct mgmt_cp_confirm_name { } __packed; struct mgmt_rp_confirm_name { struct mgmt_addr_info addr; - __u8 status; } __packed; #define MGMT_OP_BLOCK_DEVICE 0x0026 @@ -313,6 +306,7 @@ struct mgmt_cp_unblock_device { #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; + __u8 status; __u8 data[0]; } __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 89754bbcd02b..61d0250bd77e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -227,8 +227,8 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) return err; } -static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, - size_t rp_len) +static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, + void *rp, size_t rp_len) { struct sk_buff *skb; struct mgmt_hdr *hdr; @@ -249,6 +249,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, ev = (void *) skb_put(skb, sizeof(*ev) + rp_len); put_unaligned_le16(cmd, &ev->opcode); + ev->status = status; if (rp) memcpy(ev->data, rp, rp_len); @@ -269,7 +270,7 @@ static int read_version(struct sock *sk) rp.version = MGMT_VERSION; put_unaligned_le16(MGMT_REVISION, &rp.revision); - return cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_VERSION, &rp, + return cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_VERSION, 0, &rp, sizeof(rp)); } @@ -299,7 +300,7 @@ static int read_commands(struct sock *sk) for (i = 0; i < num_events; i++, opcode++) put_unaligned_le16(mgmt_events[i], opcode); - err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_COMMANDS, rp, + err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_COMMANDS, 0, rp, rp_size); kfree(rp); @@ -347,7 +348,7 @@ static int read_index_list(struct sock *sk) read_unlock(&hci_dev_list_lock); - err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, rp, + err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp, rp_len); kfree(rp); @@ -637,7 +638,7 @@ static int read_controller_info(struct sock *sk, u16 index) hci_dev_unlock(hdev); hci_dev_put(hdev); - return cmd_complete(sk, index, MGMT_OP_READ_INFO, &rp, sizeof(rp)); + return cmd_complete(sk, index, MGMT_OP_READ_INFO, 0, &rp, sizeof(rp)); } static void mgmt_pending_free(struct pending_cmd *cmd) @@ -717,7 +718,8 @@ static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev) { __le32 settings = cpu_to_le32(get_current_settings(hdev)); - return cmd_complete(sk, hdev->id, opcode, &settings, sizeof(settings)); + return cmd_complete(sk, hdev->id, opcode, 0, &settings, + sizeof(settings)); } static int set_powered(struct sock *sk, u16 index, void *data, u16 len) @@ -1124,7 +1126,7 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto failed; - err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, 0, NULL, 0); failed: hci_dev_unlock(hdev); @@ -1185,7 +1187,7 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto unlock; - err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, NULL, 0); unlock: hci_dev_unlock(hdev); @@ -1226,7 +1228,8 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) err = update_class(hdev); if (err == 0) - err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, + NULL, 0); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -1282,7 +1285,7 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) key->type, key->pin_len); } - cmd_complete(sk, index, MGMT_OP_LOAD_LINK_KEYS, NULL, 0); + cmd_complete(sk, index, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -1310,6 +1313,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) struct hci_cp_disconnect dc; struct pending_cmd *cmd; struct hci_conn *conn; + u8 status = 0; int err; if (len != sizeof(*cp)) @@ -1333,13 +1337,13 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) err = hci_remove_ltk(hdev, &cp->addr.bdaddr); if (err < 0) { - rp.status = MGMT_STATUS_NOT_PAIRED; + status = MGMT_STATUS_NOT_PAIRED; goto unlock; } if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, - sizeof(rp)); + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, status, + &rp, sizeof(rp)); device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; } @@ -1352,8 +1356,8 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) &cp->addr.bdaddr); if (!conn) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, - sizeof(rp)); + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, status, + &rp, sizeof(rp)); device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; } @@ -1373,8 +1377,8 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) unlock: if (err < 0) - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, &rp, - sizeof(rp)); + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, status, + &rp, sizeof(rp)); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -1512,7 +1516,7 @@ static int get_connections(struct sock *sk, u16 index) /* Recalculate length in case of filtered SCO connections, etc */ rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); - err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); + err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, 0, rp, rp_len); unlock: kfree(rp); @@ -1672,7 +1676,7 @@ static int set_io_capability(struct sock *sk, u16 index, void *data, u16 len) hci_dev_unlock(hdev); hci_dev_put(hdev); - return cmd_complete(sk, index, MGMT_OP_SET_IO_CAPABILITY, NULL, 0); + return cmd_complete(sk, index, MGMT_OP_SET_IO_CAPABILITY, 0, NULL, 0); } static inline struct pending_cmd *find_pairing(struct hci_conn *conn) @@ -1700,9 +1704,9 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) bacpy(&rp.addr.bdaddr, &conn->dst); rp.addr.type = link_to_mgmt(conn->type, conn->dst_type); - rp.status = status; - cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, &rp, sizeof(rp)); + cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, + &rp, sizeof(rp)); /* So we don't get further callbacks for this connection */ conn->connect_cfm_cb = NULL; @@ -1735,6 +1739,7 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) struct pending_cmd *cmd; u8 sec_level, auth_type; struct hci_conn *conn; + u8 status = 0; int err; BT_DBG(""); @@ -1768,16 +1773,16 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) rp.addr.type = cp->addr.type; if (IS_ERR(conn)) { - rp.status = -PTR_ERR(conn); - err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, + status = -PTR_ERR(conn); + err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, status, &rp, sizeof(rp)); goto unlock; } if (conn->connect_cfm_cb) { hci_conn_put(conn); - rp.status = EBUSY; - err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, + status = EBUSY; + err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, status, &rp, sizeof(rp)); goto unlock; } @@ -1850,7 +1855,7 @@ static int cancel_pair_device(struct sock *sk, u16 index, pairing_complete(cmd, MGMT_STATUS_CANCELLED); - err = cmd_complete(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, addr, + err = cmd_complete(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, 0, addr, sizeof(*addr)); unlock: hci_dev_unlock(hdev); @@ -2112,8 +2117,8 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, err = cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, MGMT_STATUS_FAILED); else - err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, NULL, - 0); + err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, 0, + NULL, 0); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2147,7 +2152,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, MGMT_STATUS_INVALID_PARAMS); else err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - NULL, 0); + 0, NULL, 0); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2307,7 +2312,8 @@ static int stop_discovery(struct sock *sk, u16 index) e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_PENDING); if (!e) { mgmt_pending_remove(cmd); - err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, 0, + NULL, 0); hci_discovery_set_state(hdev, DISCOVERY_STOPPED); goto unlock; } @@ -2400,8 +2406,8 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) err = cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, MGMT_STATUS_FAILED); else - err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, - NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, 0, + NULL, 0); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2434,7 +2440,7 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) err = cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, MGMT_STATUS_INVALID_PARAMS); else - err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, + err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, 0, NULL, 0); hci_dev_unlock(hdev); @@ -2490,8 +2496,8 @@ static int set_fast_connectable(struct sock *sk, u16 index, goto done; } - err = cmd_complete(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, - NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, 0, + NULL, 0); done: hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2908,9 +2914,9 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); rp.addr.type = cp->addr.type; - rp.status = 0; - cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, &rp, sizeof(rp)); + cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, 0, &rp, + sizeof(rp)); *sk = cmd->sk; sock_hold(*sk); @@ -2930,7 +2936,7 @@ static void unpair_device_rsp(struct pending_cmd *cmd, void *data) device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk); - cmd_complete(cmd->sk, cmd->index, cmd->opcode, &rp, sizeof(rp)); + cmd_complete(cmd->sk, cmd->index, cmd->opcode, 0, &rp, sizeof(rp)); mgmt_pending_remove(cmd); } @@ -2972,10 +2978,9 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, bacpy(&rp.addr.bdaddr, bdaddr); rp.addr.type = link_to_mgmt(link_type, addr_type); - rp.status = mgmt_status(status); err = cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, - &rp, sizeof(rp)); + mgmt_status(status), &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3021,10 +3026,9 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, bacpy(&rp.addr.bdaddr, bdaddr); rp.addr.type = MGMT_ADDR_BREDR; - rp.status = mgmt_status(status); - err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, &rp, - sizeof(rp)); + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, + mgmt_status(status), &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3044,10 +3048,9 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, bacpy(&rp.addr.bdaddr, bdaddr); rp.addr.type = MGMT_ADDR_BREDR; - rp.status = mgmt_status(status); - err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, - sizeof(rp)); + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, + mgmt_status(status), &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3099,8 +3102,8 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, bacpy(&rp.addr.bdaddr, bdaddr); rp.addr.type = link_to_mgmt(link_type, addr_type); - rp.status = mgmt_status(status); - err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp)); + err = cmd_complete(cmd->sk, hdev->id, opcode, mgmt_status(status), + &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3217,7 +3220,7 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) update_eir(hdev); - err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, &ev, + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, &ev, sizeof(ev)); if (err < 0) goto failed; @@ -3256,7 +3259,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, - &rp, sizeof(rp)); + 0, &rp, sizeof(rp)); } mgmt_pending_remove(cmd); @@ -3365,7 +3368,7 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev); if (cmd != NULL) { - cmd_complete(cmd->sk, hdev->id, cmd->opcode, NULL, 0); + cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, NULL, 0); mgmt_pending_remove(cmd); } -- GitLab From e211326c0b064e8fe2a8cb51427c3f2044ad84be Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 18 Feb 2012 15:20:03 +0200 Subject: [PATCH 0879/1846] Bluetooth: mgmt: Fix Pair Device response status values This patch fixes the status in Pair Device responses to follow proper mgmt status values. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 61d0250bd77e..79255f536278 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1728,7 +1728,7 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status) if (!cmd) BT_DBG("Unable to find a pending command"); else - pairing_complete(cmd, status); + pairing_complete(cmd, mgmt_status(status)); } static int pair_device(struct sock *sk, u16 index, void *data, u16 len) @@ -1739,7 +1739,6 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) struct pending_cmd *cmd; u8 sec_level, auth_type; struct hci_conn *conn; - u8 status = 0; int err; BT_DBG(""); @@ -1773,17 +1772,16 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) rp.addr.type = cp->addr.type; if (IS_ERR(conn)) { - status = -PTR_ERR(conn); - err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, status, - &rp, sizeof(rp)); + err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, + MGMT_STATUS_CONNECT_FAILED, + &rp, sizeof(rp)); goto unlock; } if (conn->connect_cfm_cb) { hci_conn_put(conn); - status = EBUSY; - err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, status, - &rp, sizeof(rp)); + err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, + MGMT_STATUS_BUSY, &rp, sizeof(rp)); goto unlock; } -- GitLab From f808e166e7c529a7e706cda916c8c99589d2d95b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 19 Feb 2012 12:52:07 +0200 Subject: [PATCH 0880/1846] Bluetooth: mgmt: Fix Start Discovery return parameters The same address type that was passed to the Start Discovery command should also be returned in the response message. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 79255f536278..258adf444936 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3325,6 +3325,7 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) { struct pending_cmd *cmd; + u8 type; int err; hci_discovery_set_state(hdev, DISCOVERY_STOPPED); @@ -3333,7 +3334,10 @@ int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) if (!cmd) return -ENOENT; - err = cmd_status(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status)); + type = hdev->discovery.type; + + err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status), + &type, sizeof(type)); mgmt_pending_remove(cmd); return err; @@ -3366,7 +3370,14 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev); if (cmd != NULL) { - cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, NULL, 0); + u8 type = hdev->discovery.type; + + if (discovering) + cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, + &type, sizeof(type)); + else + cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, + NULL, 0); mgmt_pending_remove(cmd); } -- GitLab From f0eeea8b61d6e8316f6137b372eb3f3ac180508c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 19 Feb 2012 12:58:54 +0200 Subject: [PATCH 0881/1846] Bluetooth: mgmt: Fix (Un)Block Device return parameters The same address as was passed to the (Un)Block Device command should also be returned in the command response message. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 258adf444936..c7e9a450b443 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2384,6 +2384,7 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; struct mgmt_cp_block_device *cp = data; + u8 status; int err; BT_DBG("hci%u", index); @@ -2394,18 +2395,20 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS); + return cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, + MGMT_STATUS_INVALID_PARAMS, + &cp->addr, sizeof(cp->addr)); hci_dev_lock(hdev); err = hci_blacklist_add(hdev, &cp->addr.bdaddr, cp->addr.type); if (err < 0) - err = cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, - MGMT_STATUS_FAILED); + status = MGMT_STATUS_FAILED; else - err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, 0, - NULL, 0); + status = 0; + + err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, status, + &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2417,6 +2420,7 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; struct mgmt_cp_unblock_device *cp = data; + u8 status; int err; BT_DBG("hci%u", index); @@ -2427,19 +2431,20 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS); + return cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, + MGMT_STATUS_INVALID_PARAMS, + &cp->addr, sizeof(cp->addr)); hci_dev_lock(hdev); err = hci_blacklist_del(hdev, &cp->addr.bdaddr, cp->addr.type); - if (err < 0) - err = cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS); + status = MGMT_STATUS_INVALID_PARAMS; else - err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, 0, - NULL, 0); + status = 0; + + err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, status, + &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); hci_dev_put(hdev); -- GitLab From bf1e3541f75a395e1e21b144fe1c387cc71baff1 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 19 Feb 2012 13:16:14 +0200 Subject: [PATCH 0882/1846] Bluetooth: mgmt: Fix OOB command response parameters The response to the Add/Remove Out Of Band Data commands should include the same address as was given in the command itself. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c7e9a450b443..952c0a8ca305 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2094,6 +2094,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, { struct hci_dev *hdev; struct mgmt_cp_add_remote_oob_data *cp = data; + u8 status; int err; BT_DBG("hci%u ", index); @@ -2104,19 +2105,21 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS); + return cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, + MGMT_STATUS_INVALID_PARAMS, + &cp->addr, sizeof(cp->addr)); hci_dev_lock(hdev); err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, cp->randomizer); if (err < 0) - err = cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, - MGMT_STATUS_FAILED); + status = MGMT_STATUS_FAILED; else - err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, 0, - NULL, 0); + status = 0; + + err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, status, + &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2129,6 +2132,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, { struct hci_dev *hdev; struct mgmt_cp_remove_remote_oob_data *cp = data; + u8 status; int err; BT_DBG("hci%u ", index); @@ -2139,18 +2143,20 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, hdev = hci_dev_get(index); if (!hdev) - return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS); + return cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, + MGMT_STATUS_INVALID_PARAMS, + &cp->addr, sizeof(cp->addr)); hci_dev_lock(hdev); err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr); if (err < 0) - err = cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS); + status = MGMT_STATUS_INVALID_PARAMS; else - err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - 0, NULL, 0); + status = 0; + + err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, status, + &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); hci_dev_put(hdev); -- GitLab From 2da9c55c5a4a0b8f0348b7acd70d8b08a6ae4573 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Feb 2012 14:39:28 +0200 Subject: [PATCH 0883/1846] Bluetooth: mgmt: Bump mgmt version This patch bumps the mgmt version to 1 and resets the revision to 0. This is in order to indicate API stability to user space. The mgmt API has reached a point where no major backwards incompatible changes are expected so it makes sense to do this version bump now. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 952c0a8ca305..18d593f23934 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -34,8 +34,8 @@ #include #include -#define MGMT_VERSION 0 -#define MGMT_REVISION 1 +#define MGMT_VERSION 1 +#define MGMT_REVISION 0 static const u16 mgmt_commands[] = { MGMT_OP_READ_INDEX_LIST, -- GitLab From 48c7aba91f372251867d15efc9cf694ceee2de02 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 19 Feb 2012 14:06:48 +0200 Subject: [PATCH 0884/1846] Bluetooth: Fix hci_connect error return values The hci_connect function should either return a valid hci_conn pointer or a ERR_PTR() but never NULL. This patch fixes the two places where hci_conn_add failures would have caused a NULL return. The only reason for failure with hci_conn_add is memory allocation so ENOMEM seems to be a good choice here. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 7ee6895c4b0c..8549d04e3313 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -551,7 +551,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 if (!acl) { acl = hci_conn_add(hdev, ACL_LINK, dst); if (!acl) - return NULL; + return ERR_PTR(-ENOMEM); } hci_conn_hold(acl); @@ -571,7 +571,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sco = hci_conn_add(hdev, type, dst); if (!sco) { hci_conn_put(acl); - return NULL; + return ERR_PTR(-ENOMEM); } } -- GitLab From 56ad315250bec1cd239c18712e072d1ff1f4aaf3 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Thu, 16 Feb 2012 02:38:48 +0000 Subject: [PATCH 0885/1846] bnx2x: make bnx2x_close() static again Commit 8304859a "bnx2x: add fan failure event handling" made the function bnx2x_close() non-static unnecessarily. The function is not called from other sources. Make it static again. Signed-off-by: Michal Schmidt Acked-by: Yuval Mintz Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 2 -- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index d60b5f073b6f..604060ab8872 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -2078,8 +2078,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms, #define BNX2X_VPD_LEN 128 #define VENDOR_ID_LEN 4 -int bnx2x_close(struct net_device *dev); - /* Congestion management fairness mode */ #define CMNG_FNS_NONE 0 #define CMNG_FNS_MINMAX 1 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 644d8e9f61b1..9831d8c416a9 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -8711,6 +8711,8 @@ static void bnx2x_parity_recover(struct bnx2x *bp) } } +static int bnx2x_close(struct net_device *dev); + /* bnx2x_nic_unload() flushes the bnx2x_wq, thus reset task is * scheduled on a general queue in order to prevent a dead lock. */ @@ -10288,7 +10290,7 @@ static int bnx2x_open(struct net_device *dev) } /* called with rtnl_lock */ -int bnx2x_close(struct net_device *dev) +static int bnx2x_close(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); -- GitLab From 772301b6187a88359b9514bdd023becf31e7f013 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Thu, 16 Feb 2012 03:25:19 +0000 Subject: [PATCH 0886/1846] ethernet: Fix typo in lantiq_etop.c Correct spelling "platfom" to "platform" in drivers/net/ethernet/lantiq_etop.c Signed-off-by: Masanari Iida Signed-off-by: David S. Miller --- drivers/net/ethernet/lantiq_etop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c index e89808ff73ed..5dc9cbd51514 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -803,7 +803,7 @@ init_ltq_etop(void) int ret = platform_driver_probe(<q_mii_driver, ltq_etop_probe); if (ret) - pr_err("ltq_etop: Error registering platfom driver!"); + pr_err("ltq_etop: Error registering platform driver!"); return ret; } -- GitLab From fa63c6da22b4a6ea6e7d04e3dc9178dd72304903 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 16 Feb 2012 07:09:30 +0000 Subject: [PATCH 0887/1846] arch/blackfin: don't generate random mac in bfin_get_ether_addr() Changed bfin_get_ether_addr() to return a state and to set no random mac address if the board don't provide one. Let the caller of bfin_get_ether_addr() set a random mac address if the return value is not 0. v2: don't set random mac in bfin_get_ether_addr() Signed-off-by: Danny Kukawka Acked-by: Mike Frysinger Signed-off-by: David S. Miller --- arch/blackfin/mach-bf518/boards/ezbrd.c | 3 ++- arch/blackfin/mach-bf518/boards/tcm-bf518.c | 5 ++--- arch/blackfin/mach-bf527/boards/ad7160eval.c | 3 ++- arch/blackfin/mach-bf527/boards/cm_bf527.c | 5 ++--- arch/blackfin/mach-bf527/boards/ezbrd.c | 3 ++- arch/blackfin/mach-bf527/boards/ezkit.c | 3 ++- arch/blackfin/mach-bf527/boards/tll6527m.c | 3 ++- arch/blackfin/mach-bf537/boards/cm_bf537e.c | 5 ++--- arch/blackfin/mach-bf537/boards/cm_bf537u.c | 5 ++--- arch/blackfin/mach-bf537/boards/dnp5370.c | 3 ++- arch/blackfin/mach-bf537/boards/pnav10.c | 5 ++--- arch/blackfin/mach-bf537/boards/stamp.c | 3 ++- arch/blackfin/mach-bf537/boards/tcm_bf537.c | 5 ++--- 13 files changed, 26 insertions(+), 25 deletions(-) diff --git a/arch/blackfin/mach-bf518/boards/ezbrd.c b/arch/blackfin/mach-bf518/boards/ezbrd.c index a2d96d31bbf1..a17395727efa 100644 --- a/arch/blackfin/mach-bf518/boards/ezbrd.c +++ b/arch/blackfin/mach-bf518/boards/ezbrd.c @@ -821,7 +821,7 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { /* the MAC is stored in OTP memory page 0xDF */ u32 ret; @@ -834,5 +834,6 @@ void bfin_get_ether_addr(char *addr) for (ret = 0; ret < 6; ++ret) addr[ret] = otp_mac_p[5 - ret]; } + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf518/boards/tcm-bf518.c b/arch/blackfin/mach-bf518/boards/tcm-bf518.c index f271310f739d..6eebee4e4217 100644 --- a/arch/blackfin/mach-bf518/boards/tcm-bf518.c +++ b/arch/blackfin/mach-bf518/boards/tcm-bf518.c @@ -730,9 +730,8 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { - random_ether_addr(addr); - printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__); + return 1; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf527/boards/ad7160eval.c b/arch/blackfin/mach-bf527/boards/ad7160eval.c index c8d5d2b7c732..fad7fea1b0bf 100644 --- a/arch/blackfin/mach-bf527/boards/ad7160eval.c +++ b/arch/blackfin/mach-bf527/boards/ad7160eval.c @@ -846,7 +846,7 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { /* the MAC is stored in OTP memory page 0xDF */ u32 ret; @@ -859,5 +859,6 @@ void bfin_get_ether_addr(char *addr) for (ret = 0; ret < 6; ++ret) addr[ret] = otp_mac_p[5 - ret]; } + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf527/boards/cm_bf527.c b/arch/blackfin/mach-bf527/boards/cm_bf527.c index 7330607856e9..65b7fbd30e16 100644 --- a/arch/blackfin/mach-bf527/boards/cm_bf527.c +++ b/arch/blackfin/mach-bf527/boards/cm_bf527.c @@ -983,9 +983,8 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { - random_ether_addr(addr); - printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__); + return 1; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c index db3ecfce8306..17c6a24cc076 100644 --- a/arch/blackfin/mach-bf527/boards/ezbrd.c +++ b/arch/blackfin/mach-bf527/boards/ezbrd.c @@ -870,7 +870,7 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { /* the MAC is stored in OTP memory page 0xDF */ u32 ret; @@ -883,5 +883,6 @@ void bfin_get_ether_addr(char *addr) for (ret = 0; ret < 6; ++ret) addr[ret] = otp_mac_p[5 - ret]; } + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c index dfdd8e6bac72..2f9a2bd83ce4 100644 --- a/arch/blackfin/mach-bf527/boards/ezkit.c +++ b/arch/blackfin/mach-bf527/boards/ezkit.c @@ -1311,7 +1311,7 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { /* the MAC is stored in OTP memory page 0xDF */ u32 ret; @@ -1324,5 +1324,6 @@ void bfin_get_ether_addr(char *addr) for (ret = 0; ret < 6; ++ret) addr[ret] = otp_mac_p[5 - ret]; } + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c index 360e97fc5293..d192c0ac941c 100644 --- a/arch/blackfin/mach-bf527/boards/tll6527m.c +++ b/arch/blackfin/mach-bf527/boards/tll6527m.c @@ -931,7 +931,7 @@ void native_machine_restart(char *cmd) bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { /* the MAC is stored in OTP memory page 0xDF */ u32 ret; @@ -945,5 +945,6 @@ void bfin_get_ether_addr(char *addr) for (ret = 0; ret < 6; ++ret) addr[ret] = otp_mac_p[5 - ret]; } + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537e.c b/arch/blackfin/mach-bf537/boards/cm_bf537e.c index 0d4a2f61a973..27fd2c32ae9a 100644 --- a/arch/blackfin/mach-bf537/boards/cm_bf537e.c +++ b/arch/blackfin/mach-bf537/boards/cm_bf537e.c @@ -813,9 +813,8 @@ void __init native_machine_early_platform_add_devices(void) ARRAY_SIZE(cm_bf537e_early_devices)); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { - random_ether_addr(addr); - printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__); + return 1; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537u.c b/arch/blackfin/mach-bf537/boards/cm_bf537u.c index f5536982706c..3f3abad86ec3 100644 --- a/arch/blackfin/mach-bf537/boards/cm_bf537u.c +++ b/arch/blackfin/mach-bf537/boards/cm_bf537u.c @@ -790,9 +790,8 @@ void __init native_machine_early_platform_add_devices(void) ARRAY_SIZE(cm_bf537u_early_devices)); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { - random_ether_addr(addr); - printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__); + return 1; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf537/boards/dnp5370.c b/arch/blackfin/mach-bf537/boards/dnp5370.c index 11dadeb33d79..6f77bf708ec0 100644 --- a/arch/blackfin/mach-bf537/boards/dnp5370.c +++ b/arch/blackfin/mach-bf537/boards/dnp5370.c @@ -399,9 +399,10 @@ arch_initcall(dnp5370_init); /* * Currently the MAC address is saved in Flash by U-Boot */ -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC); *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4); + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c index 6fd84709fc68..e9507feea319 100644 --- a/arch/blackfin/mach-bf537/boards/pnav10.c +++ b/arch/blackfin/mach-bf537/boards/pnav10.c @@ -535,9 +535,8 @@ void __init native_machine_early_platform_add_devices(void) ARRAY_SIZE(stamp_early_devices)); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { - random_ether_addr(addr); - printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__); + return 1; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 2221173e489e..0b807253f4d6 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -2993,9 +2993,10 @@ void native_machine_restart(char *cmd) * Currently the MAC address is saved in Flash by U-Boot */ #define FLASH_MAC 0x203f0000 -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC); *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4); + return 0; } EXPORT_SYMBOL(bfin_get_ether_addr); diff --git a/arch/blackfin/mach-bf537/boards/tcm_bf537.c b/arch/blackfin/mach-bf537/boards/tcm_bf537.c index 988517671a5d..3fb421823857 100644 --- a/arch/blackfin/mach-bf537/boards/tcm_bf537.c +++ b/arch/blackfin/mach-bf537/boards/tcm_bf537.c @@ -780,9 +780,8 @@ void __init native_machine_early_platform_add_devices(void) ARRAY_SIZE(cm_bf537_early_devices)); } -void bfin_get_ether_addr(char *addr) +int bfin_get_ether_addr(char *addr) { - random_ether_addr(addr); - printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__); + return 1; } EXPORT_SYMBOL(bfin_get_ether_addr); -- GitLab From 5055d2f236e1495d68c468eeb684fd5789673f1d Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 16 Feb 2012 07:09:31 +0000 Subject: [PATCH 0888/1846] adi: adapt to eth_hw_addr_random() and changes in arch/blackfin Adapt adi ethernet driver to changes in bfin_get_ether_addr() from arch/blackfin. bfin_get_ether_addr() returns now a state. Set a random mac address via new eth_hw_addr_random() in case the return value is not 0. Reset the state to NET_ADDR_PERM as soon as the MAC get changed via .ndo_set_mac_address. v2: change the logic to reduce unneeded checks Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/adi/bfin_mac.c | 15 +++++++++------ drivers/net/ethernet/adi/bfin_mac.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c index 49733696703a..ab4daeccdf98 100644 --- a/drivers/net/ethernet/adi/bfin_mac.c +++ b/drivers/net/ethernet/adi/bfin_mac.c @@ -621,6 +621,7 @@ static int bfin_mac_set_mac_address(struct net_device *dev, void *p) if (netif_running(dev)) return -EBUSY; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); + dev->addr_assign_type &= ~NET_ADDR_RANDOM; setup_mac_addr(dev->dev_addr); return 0; } @@ -1494,12 +1495,14 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev) * Grab the MAC from the board somehow * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c */ - if (!is_valid_ether_addr(ndev->dev_addr)) - bfin_get_ether_addr(ndev->dev_addr); - - /* If still not valid, get a random one */ - if (!is_valid_ether_addr(ndev->dev_addr)) - random_ether_addr(ndev->dev_addr); + if (!is_valid_ether_addr(ndev->dev_addr)) { + if (bfin_get_ether_addr(ndev->dev_addr) || + !is_valid_ether_addr(ndev->dev_addr)) { + /* Still not valid, get a random one */ + netdev_warn(ndev, "Setting Ethernet MAC to a random one\n"); + eth_hw_addr_random(ndev); + } + } setup_mac_addr(ndev->dev_addr); diff --git a/drivers/net/ethernet/adi/bfin_mac.h b/drivers/net/ethernet/adi/bfin_mac.h index f8559ac9a403..960905c08223 100644 --- a/drivers/net/ethernet/adi/bfin_mac.h +++ b/drivers/net/ethernet/adi/bfin_mac.h @@ -101,6 +101,6 @@ struct bfin_mac_local { #endif }; -extern void bfin_get_ether_addr(char *addr); +extern int bfin_get_ether_addr(char *addr); #endif -- GitLab From 5277f7a6c2f322f11e8deed48530296d70bc5d5f Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 20 Feb 2012 00:46:06 -0500 Subject: [PATCH 0889/1846] ll_temac: Fix build. Reported-by: Stephen Rothwell Signed-off-by: David S. Miller --- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index eb285418924e..d21591a2c593 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -329,7 +329,7 @@ static int temac_set_mac_address(struct net_device *ndev, void *address) if (!is_valid_ether_addr(ndev->dev_addr)) eth_hw_addr_random(ndev); else - dev->addr_assign_type &= ~NET_ADDR_RANDOM; + ndev->addr_assign_type &= ~NET_ADDR_RANDOM; /* set up unicast MAC address filter set its mac address */ mutex_lock(&lp->indirect_mutex); -- GitLab From b13423ee0cba4dc23ca21e61ca45f482d6713509 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Mon, 20 Feb 2012 00:11:48 +0000 Subject: [PATCH 0890/1846] enic: rename CMD_MAC_ADDR to CMD_GET_MAC_ADDR firmware devcmd CMD_MAC_ADDR gets the mac address of a vnic from adapter. This patch renames it to CMD_GET_MAC_ADDR more appropriately. Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: Sujith Sankar Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic_res.c | 2 +- drivers/net/ethernet/cisco/enic/vnic_dev.c | 6 +++--- drivers/net/ethernet/cisco/enic/vnic_dev.h | 2 +- drivers/net/ethernet/cisco/enic/vnic_devcmd.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic_res.c b/drivers/net/ethernet/cisco/enic/enic_res.c index 4a35367de790..31d658880c3c 100644 --- a/drivers/net/ethernet/cisco/enic/enic_res.c +++ b/drivers/net/ethernet/cisco/enic/enic_res.c @@ -44,7 +44,7 @@ int enic_get_vnic_config(struct enic *enic) struct vnic_enet_config *c = &enic->config; int err; - err = vnic_dev_mac_addr(enic->vdev, enic->mac_addr); + err = vnic_dev_get_mac_addr(enic->vdev, enic->mac_addr); if (err) { dev_err(enic_get_dev(enic), "Error getting MAC addr, %d\n", err); diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c index 298ad6f865be..79cb3405bebc 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_dev.c +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c @@ -613,7 +613,7 @@ int vnic_dev_hang_notify(struct vnic_dev *vdev) return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait); } -int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) +int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) { u64 a0, a1; int wait = 1000; @@ -622,7 +622,7 @@ int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) for (i = 0; i < ETH_ALEN; i++) mac_addr[i] = 0; - err = vnic_dev_cmd(vdev, CMD_MAC_ADDR, &a0, &a1, wait); + err = vnic_dev_cmd(vdev, CMD_GET_MAC_ADDR, &a0, &a1, wait); if (err) return err; @@ -803,7 +803,7 @@ int vnic_dev_init(struct vnic_dev *vdev, int arg) /* Emulate these for old CMD_INIT_v1 which * didn't pass a0 so no CMD_INITF_*. */ - vnic_dev_cmd(vdev, CMD_MAC_ADDR, &a0, &a1, wait); + vnic_dev_cmd(vdev, CMD_GET_MAC_ADDR, &a0, &a1, wait); vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait); } } diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.h b/drivers/net/ethernet/cisco/enic/vnic_dev.h index 6a138b625d13..e476c737f61d 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_dev.h +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.h @@ -97,7 +97,7 @@ int vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, int broadcast, int promisc, int allmulti); int vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr); int vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr); -int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); +int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr); int vnic_dev_notify_unset(struct vnic_dev *vdev); int vnic_dev_link_status(struct vnic_dev *vdev); diff --git a/drivers/net/ethernet/cisco/enic/vnic_devcmd.h b/drivers/net/ethernet/cisco/enic/vnic_devcmd.h index 8025e8808d61..8a58dea2fa01 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_devcmd.h +++ b/drivers/net/ethernet/cisco/enic/vnic_devcmd.h @@ -131,7 +131,7 @@ enum vnic_devcmd_cmd { CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8), /* MAC address in (u48)a0 */ - CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ, + CMD_GET_MAC_ADDR = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9), /* add addr from (u48)a0 */ -- GitLab From d6c81bc6dca768dff1a3f127beee11e8102669a7 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Mon, 20 Feb 2012 00:11:53 +0000 Subject: [PATCH 0891/1846] enic: Add new fw devcmd to set mac address of an interface This patch adds a new devcmd CMD_SET_MAC_ADDR to set the mac address of an interface. Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: Sujith Sankar Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/vnic_dev.c | 12 ++++++++++++ drivers/net/ethernet/cisco/enic/vnic_dev.h | 1 + drivers/net/ethernet/cisco/enic/vnic_devcmd.h | 9 +++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index f7c3067d4485..06fba3215f40 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.35" +#define DRV_VERSION "2.1.1.36" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c index 79cb3405bebc..605b22283be1 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_dev.c +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c @@ -1023,3 +1023,15 @@ int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status) { return vnic_dev_cmd_status(vdev, CMD_DEINIT, status); } + +int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) +{ + u64 a0, a1; + int wait = 1000; + int i; + + for (i = 0; i < ETH_ALEN; i++) + ((u8 *)&a0)[i] = mac_addr[i]; + + return vnic_dev_cmd(vdev, CMD_SET_MAC_ADDR, &a0, &a1, wait); +} diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.h b/drivers/net/ethernet/cisco/enic/vnic_dev.h index e476c737f61d..f3d9b79ba77e 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_dev.h +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.h @@ -131,5 +131,6 @@ int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len); int vnic_dev_enable2(struct vnic_dev *vdev, int active); int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status); int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status); +int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); #endif /* _VNIC_DEV_H_ */ diff --git a/drivers/net/ethernet/cisco/enic/vnic_devcmd.h b/drivers/net/ethernet/cisco/enic/vnic_devcmd.h index 8a58dea2fa01..23d555255cf8 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_devcmd.h +++ b/drivers/net/ethernet/cisco/enic/vnic_devcmd.h @@ -337,6 +337,15 @@ enum vnic_devcmd_cmd { * (u32)a2 = maximum timer value in usec */ CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50), + + /* + * cmd_set_mac_addr + * set mac address + * in: + * (u48)a0 = mac addr + * + */ + CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55), }; /* CMD_ENABLE2 flags */ -- GitLab From b476583354fc62cae433eb24d4027597c03be4c9 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Mon, 20 Feb 2012 00:11:58 +0000 Subject: [PATCH 0892/1846] enic: Fix ndo_set_vf_mac and ndo_set_vf_port to set/get the sriov vf's mac This patch fixes the ndo_set_vf_mac netdev op to set the sriov vf mac in adapter using the new fw devcmd CMD_SET_MAC_ADDR. During port profile associate the pf driver gets the vf mac using CMD_GET_MAC_ADDR. Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: Sujith Sankar Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 37 ++++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 06fba3215f40..922b646c7492 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.36" +#define DRV_VERSION "2.1.1.37" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 7dfa567b7e04..2278c43b2c86 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1070,8 +1070,17 @@ static int enic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) return err; if (is_valid_ether_addr(mac)) { - memcpy(pp->vf_mac, mac, ETH_ALEN); - return 0; + if (vf == PORT_SELF_VF) { + memcpy(pp->vf_mac, mac, ETH_ALEN); + return 0; + } else { + /* + * For sriov vf's set the mac in hw + */ + ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, + vnic_dev_set_mac_addr, mac); + return enic_dev_status_to_errno(err); + } } else return -EINVAL; } @@ -1115,12 +1124,23 @@ static int enic_set_vf_port(struct net_device *netdev, int vf, nla_data(port[IFLA_PORT_HOST_UUID]), PORT_UUID_MAX); } - /* Special case handling: mac came from IFLA_VF_MAC */ - if (!is_zero_ether_addr(prev_pp.vf_mac)) - memcpy(pp->mac_addr, prev_pp.vf_mac, ETH_ALEN); + if (vf == PORT_SELF_VF) { + /* Special case handling: mac came from IFLA_VF_MAC */ + if (!is_zero_ether_addr(prev_pp.vf_mac)) + memcpy(pp->mac_addr, prev_pp.vf_mac, ETH_ALEN); - if (vf == PORT_SELF_VF && is_zero_ether_addr(netdev->dev_addr)) - eth_hw_addr_random(netdev); + if (is_zero_ether_addr(netdev->dev_addr)) + eth_hw_addr_random(netdev); + } else { + /* SR-IOV VF: get mac from adapter */ + ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, + vnic_dev_get_mac_addr, pp->mac_addr); + if (err) { + netdev_err(netdev, "Error getting mac for vf %d\n", vf); + memcpy(pp, &prev_pp, sizeof(*pp)); + return enic_dev_status_to_errno(err); + } + } err = enic_process_set_pp_request(enic, vf, &prev_pp, &restore_pp); if (err) { @@ -1148,7 +1168,8 @@ static int enic_set_vf_port(struct net_device *netdev, int vf, } } - memset(pp->vf_mac, 0, ETH_ALEN); + if (vf == PORT_SELF_VF) + memset(pp->vf_mac, 0, ETH_ALEN); return err; } -- GitLab From 2b68c18194b078489a84023564bcf7464b6c7b37 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Mon, 20 Feb 2012 00:12:04 +0000 Subject: [PATCH 0893/1846] enic: Add support for fw init command on sriov vf's This patch fixes enic_probe to do a fw init devcmd for sriov vfs. This enables vf driver in the guest to get into adapter init state without having to explicitly issue an init fw cmd with portprofile info. But a successful init on the vf will require the port profile information to be pre-provisioned by the hypervisor via the pf Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: Sujith Sankar Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 922b646c7492..99998c606d3e 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.37" +#define DRV_VERSION "2.1.1.38" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 2278c43b2c86..e27ec1d3778d 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -2452,7 +2452,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, * called later by an upper layer. */ - if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic)) { + if (!enic_is_dynamic(enic)) { err = vnic_dev_init(enic->vdev, 0); if (err) { dev_err(dev, "vNIC dev init failed, aborting\n"); -- GitLab From 470fe1b540fb50ba8ce01e0ac985602e8fbb108c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:30 +0100 Subject: [PATCH 0894/1846] Bluetooth: Split sending for HCI raw and control sockets The sending functions for HCI raw and control sockets have nothing in common except that they iterate over the socket list. Split them into two so they can do their job more efficient. In addition the code becomes more readable. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 4 +-- net/bluetooth/hci_core.c | 4 +-- net/bluetooth/hci_event.c | 2 +- net/bluetooth/hci_sock.c | 51 ++++++++++++++++++++++++-------- net/bluetooth/mgmt.c | 2 +- 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 2aafeb3a8793..9209e4c8a211 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -953,8 +953,8 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); /* ----- HCI Sockets ----- */ -void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, - struct sock *skip_sk); +void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); +void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); /* Management interface */ #define MGMT_ADDR_BREDR 0x00 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index fabca080ae70..638fa8c393d8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2131,7 +2131,7 @@ static int hci_send_frame(struct sk_buff *skb) /* Time stamp */ __net_timestamp(skb); - hci_send_to_sock(hdev, skb, NULL); + hci_send_to_sock(hdev, skb); } /* Get rid of skb owner, prior to sending to the driver. */ @@ -2818,7 +2818,7 @@ static void hci_rx_work(struct work_struct *work) while ((skb = skb_dequeue(&hdev->rx_q))) { if (atomic_read(&hdev->promisc)) { /* Send copy to the sockets */ - hci_send_to_sock(hdev, skb, NULL); + hci_send_to_sock(hdev, skb); } if (test_bit(HCI_RAW, &hdev->flags)) { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 04fb1f02dfcc..e69db4a7b3ef 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3571,7 +3571,7 @@ void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) bt_cb(skb)->pkt_type = HCI_EVENT_PKT; skb->dev = (void *) hdev; - hci_send_to_sock(hdev, skb, NULL); + hci_send_to_sock(hdev, skb); kfree_skb(skb); } diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 9e854d9fb460..b5b3bc8d2848 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -85,8 +85,7 @@ static struct bt_sock_list hci_sk_list = { }; /* Send frame to RAW socket */ -void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, - struct sock *skip_sk) +void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) { struct sock *sk; struct hlist_node *node; @@ -94,13 +93,11 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, BT_DBG("hdev %p len %d", hdev, skb->len); read_lock(&hci_sk_list.lock); + sk_for_each(sk, node, &hci_sk_list.head) { struct hci_filter *flt; struct sk_buff *nskb; - if (sk == skip_sk) - continue; - if (sk->sk_state != BT_BOUND || hci_pi(sk)->hdev != hdev) continue; @@ -108,12 +105,9 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, if (skb->sk == sk) continue; - if (bt_cb(skb)->channel != hci_pi(sk)->channel) + if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) continue; - if (bt_cb(skb)->channel == HCI_CHANNEL_CONTROL) - goto clone; - /* Apply filter */ flt = &hci_pi(sk)->filter; @@ -137,18 +131,51 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, continue; } -clone: nskb = skb_clone(skb, GFP_ATOMIC); if (!nskb) continue; /* Put type byte before the data */ - if (bt_cb(skb)->channel == HCI_CHANNEL_RAW) - memcpy(skb_push(nskb, 1), &bt_cb(nskb)->pkt_type, 1); + memcpy(skb_push(nskb, 1), &bt_cb(nskb)->pkt_type, 1); + + if (sock_queue_rcv_skb(sk, nskb)) + kfree_skb(nskb); + } + + read_unlock(&hci_sk_list.lock); +} + +/* Send frame to control socket */ +void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk) +{ + struct sock *sk; + struct hlist_node *node; + + BT_DBG("len %d", skb->len); + + read_lock(&hci_sk_list.lock); + + sk_for_each(sk, node, &hci_sk_list.head) { + struct sk_buff *nskb; + + /* Skip the original socket */ + if (sk == skip_sk) + continue; + + if (sk->sk_state != BT_BOUND) + continue; + + if (hci_pi(sk)->channel != HCI_CHANNEL_CONTROL) + continue; + + nskb = skb_clone(skb, GFP_ATOMIC); + if (!nskb) + continue; if (sock_queue_rcv_skb(sk, nskb)) kfree_skb(nskb); } + read_unlock(&hci_sk_list.lock); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 18d593f23934..1695d04d927d 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -924,7 +924,7 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, if (data) memcpy(skb_put(skb, data_len), data, data_len); - hci_send_to_sock(NULL, skb, skip_sk); + hci_send_to_control(skb, skip_sk); kfree_skb(skb); return 0; -- GitLab From a6fb08dfe8654e399c9bbca34be914e213560b5e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:31 +0100 Subject: [PATCH 0895/1846] Bluetooth: Remove unneeded bt_cb(skb)->channel variable The bt_cb(skb)->channel was only needed to make hci_send_to_sock() be used for HCI raw and control sockets. Since they have now separate sending functions this is no longer needed. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/bluetooth.h | 1 - net/bluetooth/mgmt.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 5ca9219fe940..262ebd1747d4 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -222,7 +222,6 @@ struct bt_skb_cb { __u16 tx_seq; __u8 retries; __u8 sar; - unsigned short channel; __u8 force_active; }; #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1695d04d927d..bc71b45ef4e5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -911,8 +911,6 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, if (!skb) return -ENOMEM; - bt_cb(skb)->channel = HCI_CHANNEL_CONTROL; - hdr = (void *) skb_put(skb, sizeof(*hdr)); hdr->opcode = cpu_to_le16(event); if (hdev) -- GitLab From 2f39cdb7a270da24532734dfdfd10c490be981c4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:32 +0100 Subject: [PATCH 0896/1846] Bluetooth: Limit HCI raw socket options to actual raw sockets Currently the socket options of HCI sockets can be set on raw and control sockets, but on control sockets they make no sense. So just return EINVAL in that case. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index b5b3bc8d2848..612bc2af05a9 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -601,6 +601,11 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char lock_sock(sk); + if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) { + err = -EINVAL; + goto done; + } + switch (optname) { case HCI_DATA_DIR: if (get_user(opt, (int __user *)optval)) { @@ -663,6 +668,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char break; } +done: release_sock(sk); return err; } -- GitLab From cedc5469778846ee18c653aaa6d70681961eed93 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:33 +0100 Subject: [PATCH 0897/1846] Bluetooth: Lock socket when reading HCI socket options When reading the HCI raw socket option, the socket was never locked. So lock the socket and in addition return EINVAL on non raw sockets. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 612bc2af05a9..27ec9088508f 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -677,11 +677,20 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char { struct hci_ufilter uf; struct sock *sk = sock->sk; - int len, opt; + int len, opt, err = 0; + + BT_DBG("sk %p, opt %d", sk, optname); if (get_user(len, optlen)) return -EFAULT; + lock_sock(sk); + + if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) { + err = -EINVAL; + goto done; + } + switch (optname) { case HCI_DATA_DIR: if (hci_pi(sk)->cmsg_mask & HCI_CMSG_DIR) @@ -690,7 +699,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char opt = 0; if (put_user(opt, optval)) - return -EFAULT; + err = -EFAULT; break; case HCI_TIME_STAMP: @@ -700,7 +709,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char opt = 0; if (put_user(opt, optval)) - return -EFAULT; + err = -EFAULT; break; case HCI_FILTER: @@ -715,15 +724,17 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char len = min_t(unsigned int, len, sizeof(uf)); if (copy_to_user(optval, &uf, len)) - return -EFAULT; + err = -EFAULT; break; default: - return -ENOPROTOOPT; + err = -ENOPROTOOPT; break; } - return 0; +done: + release_sock(sk); + return err; } static const struct proto_ops hci_sock_ops = { -- GitLab From 3a208627f3ac83d3b749608770f7eb631db31a77 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:34 +0100 Subject: [PATCH 0898/1846] Bluetooth: Add HCI CMSG details only to raw sockets The HCI CMSG specific data is for raw sockets only. So only add them to actual raw sockets. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 27ec9088508f..71a02adbaa77 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -488,7 +488,11 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, skb_reset_transport_header(skb); err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); - hci_sock_cmsg(sk, msg, skb); + switch (hci_pi(sk)->channel) { + case HCI_CHANNEL_RAW: + hci_sock_cmsg(sk, msg, skb); + break; + } skb_free_datagram(sk, skb); -- GitLab From 7cc2ade2cbc6f71090f0f8d0e11cb68886ddc65e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:35 +0100 Subject: [PATCH 0899/1846] Bluetooth: Simplify HCI socket bind handling The HCI socket bind handling checks a few too many times the channel we are binding. So centralize this and make the function easier to read. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 71a02adbaa77..4dda4574db3e 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -367,34 +367,49 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le if (haddr.hci_family != AF_BLUETOOTH) return -EINVAL; - if (haddr.hci_channel > HCI_CHANNEL_CONTROL) - return -EINVAL; - - if (haddr.hci_channel == HCI_CHANNEL_CONTROL) { - if (!enable_mgmt) - return -EINVAL; - set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags); - } - lock_sock(sk); - if (sk->sk_state == BT_BOUND || hci_pi(sk)->hdev) { + if (sk->sk_state == BT_BOUND) { err = -EALREADY; goto done; } - if (haddr.hci_dev != HCI_DEV_NONE) { - hdev = hci_dev_get(haddr.hci_dev); - if (!hdev) { - err = -ENODEV; + switch (haddr.hci_channel) { + case HCI_CHANNEL_RAW: + if (hci_pi(sk)->hdev) { + err = -EALREADY; goto done; } - atomic_inc(&hdev->promisc); + if (haddr.hci_dev != HCI_DEV_NONE) { + hdev = hci_dev_get(haddr.hci_dev); + if (!hdev) { + err = -ENODEV; + goto done; + } + + atomic_inc(&hdev->promisc); + } + + hci_pi(sk)->hdev = hdev; + break; + + case HCI_CHANNEL_CONTROL: + if (haddr.hci_dev != HCI_DEV_NONE || !enable_mgmt) { + err = -EINVAL; + goto done; + } + + set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags); + break; + + default: + err = -EINVAL; + goto done; } + hci_pi(sk)->channel = haddr.hci_channel; - hci_pi(sk)->hdev = hdev; sk->sk_state = BT_BOUND; done: -- GitLab From e0edf3733fb62f91bbb8ec3fab4a90b0ac2dd037 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:36 +0100 Subject: [PATCH 0900/1846] Bluetooth: Fix issue with shared SKB between HCI raw socket and driver Any HCI raw socket gets a copy of each SKB that is either received or send via the Bluetooth subsystem. The raw socket uses SKB clones to send out data, but the problem is that it needs to add an extra packet type byte in front of it. And some drivers need to also add an extra header before submitting the packet. So far this all worked magically fine since all of the drivers and the raw sockets are adding the same byte at the same location. But that is by pure coincidence. Since the data of cloned SKBs is shared, this means that the raw socket and driver kept writing into the shared data area. To fix this the only safe way is if the HCI raw socket creates a copy of the SKB before sending it out. To not always copy all SKBs around, the copy is only created once and only after any of the HCI filter checks succeeded. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 4dda4574db3e..cf940bd7a2b0 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -89,6 +89,7 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) { struct sock *sk; struct hlist_node *node; + struct sk_buff *skb_copy = NULL; BT_DBG("hdev %p len %d", hdev, skb->len); @@ -131,18 +132,27 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) continue; } - nskb = skb_clone(skb, GFP_ATOMIC); + if (!skb_copy) { + /* Create a private copy with headroom */ + skb_copy = __pskb_copy(skb, 1, GFP_ATOMIC); + if (!skb_copy) + continue; + + /* Put type byte before the data */ + memcpy(skb_push(skb_copy, 1), &bt_cb(skb)->pkt_type, 1); + } + + nskb = skb_clone(skb_copy, GFP_ATOMIC); if (!nskb) continue; - /* Put type byte before the data */ - memcpy(skb_push(nskb, 1), &bt_cb(nskb)->pkt_type, 1); - if (sock_queue_rcv_skb(sk, nskb)) kfree_skb(nskb); } read_unlock(&hci_sk_list.lock); + + kfree_skb(skb_copy); } /* Send frame to control socket */ -- GitLab From 040030ef7d907107e6489b39da518bdf94136d68 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 14:50:37 +0100 Subject: [PATCH 0901/1846] Bluetooth: Remove HCI notifier handling The HCI notifier handling was never used outside of Bluetooth core layer and thus remove it and replace it with direct function calls. Also move the stack internal event generation into the HCI socket layer. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 7 +-- net/bluetooth/hci_conn.c | 1 - net/bluetooth/hci_core.c | 16 +---- net/bluetooth/hci_event.c | 29 --------- net/bluetooth/hci_sock.c | 105 ++++++++++++++++++------------- 5 files changed, 64 insertions(+), 94 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9209e4c8a211..41adae509e9c 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -941,21 +941,18 @@ static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data, int hci_register_cb(struct hci_cb *hcb); int hci_unregister_cb(struct hci_cb *hcb); -int hci_register_notifier(struct notifier_block *nb); -int hci_unregister_notifier(struct notifier_block *nb); - int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); -void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); - /* ----- HCI Sockets ----- */ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); +void hci_sock_dev_event(struct hci_dev *hdev, int event); + /* Management interface */ #define MGMT_ADDR_BREDR 0x00 #define MGMT_ADDR_LE_PUBLIC 0x01 diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8549d04e3313..3c68e606d5e5 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 638fa8c393d8..47217281d9ac 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -69,24 +68,11 @@ DEFINE_RWLOCK(hci_dev_list_lock); LIST_HEAD(hci_cb_list); DEFINE_RWLOCK(hci_cb_list_lock); -/* HCI notifiers list */ -static ATOMIC_NOTIFIER_HEAD(hci_notifier); - /* ---- HCI notifications ---- */ -int hci_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&hci_notifier, nb); -} - -int hci_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&hci_notifier, nb); -} - static void hci_notify(struct hci_dev *hdev, int event) { - atomic_notifier_call_chain(&hci_notifier, event, hdev); + hci_sock_dev_event(hdev, event); } /* ---- HCI requests ---- */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e69db4a7b3ef..f00faf0ac32f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -3547,33 +3546,5 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) hdev->stat.evt_rx++; } -/* Generate internal stack event */ -void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) -{ - struct hci_event_hdr *hdr; - struct hci_ev_stack_internal *ev; - struct sk_buff *skb; - - skb = bt_skb_alloc(HCI_EVENT_HDR_SIZE + sizeof(*ev) + dlen, GFP_ATOMIC); - if (!skb) - return; - - hdr = (void *) skb_put(skb, HCI_EVENT_HDR_SIZE); - hdr->evt = HCI_EV_STACK_INTERNAL; - hdr->plen = sizeof(*ev) + dlen; - - ev = (void *) skb_put(skb, sizeof(*ev) + dlen); - ev->type = type; - memcpy(ev->data, data, dlen); - - bt_cb(skb)->incoming = 1; - __net_timestamp(skb); - - bt_cb(skb)->pkt_type = HCI_EVENT_PKT; - skb->dev = (void *) hdev; - hci_send_to_sock(hdev, skb); - kfree_skb(skb); -} - module_param(enable_le, bool, 0644); MODULE_PARM_DESC(enable_le, "Enable LE support"); diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index cf940bd7a2b0..14727cb43f63 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -189,6 +189,67 @@ void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk) read_unlock(&hci_sk_list.lock); } +/* Generate internal stack event */ +static void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) +{ + struct hci_event_hdr *hdr; + struct hci_ev_stack_internal *ev; + struct sk_buff *skb; + + skb = bt_skb_alloc(HCI_EVENT_HDR_SIZE + sizeof(*ev) + dlen, GFP_ATOMIC); + if (!skb) + return; + + hdr = (void *) skb_put(skb, HCI_EVENT_HDR_SIZE); + hdr->evt = HCI_EV_STACK_INTERNAL; + hdr->plen = sizeof(*ev) + dlen; + + ev = (void *) skb_put(skb, sizeof(*ev) + dlen); + ev->type = type; + memcpy(ev->data, data, dlen); + + bt_cb(skb)->incoming = 1; + __net_timestamp(skb); + + bt_cb(skb)->pkt_type = HCI_EVENT_PKT; + skb->dev = (void *) hdev; + hci_send_to_sock(hdev, skb); + kfree_skb(skb); +} + +void hci_sock_dev_event(struct hci_dev *hdev, int event) +{ + struct hci_ev_si_device ev; + + BT_DBG("hdev %s event %d", hdev->name, event); + + /* Send event to sockets */ + ev.event = event; + ev.dev_id = hdev->id; + hci_si_event(NULL, HCI_EV_SI_DEVICE, sizeof(ev), &ev); + + if (event == HCI_DEV_UNREG) { + struct sock *sk; + struct hlist_node *node; + + /* Detach sockets from device */ + read_lock(&hci_sk_list.lock); + sk_for_each(sk, node, &hci_sk_list.head) { + bh_lock_sock_nested(sk); + if (hci_pi(sk)->hdev == hdev) { + hci_pi(sk)->hdev = NULL; + sk->sk_err = EPIPE; + sk->sk_state = BT_OPEN; + sk->sk_state_change(sk); + + hci_dev_put(hdev); + } + bh_unlock_sock(sk); + } + read_unlock(&hci_sk_list.lock); + } +} + static int hci_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -821,52 +882,12 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol, return 0; } -static int hci_sock_dev_event(struct notifier_block *this, unsigned long event, void *ptr) -{ - struct hci_dev *hdev = (struct hci_dev *) ptr; - struct hci_ev_si_device ev; - - BT_DBG("hdev %s event %ld", hdev->name, event); - - /* Send event to sockets */ - ev.event = event; - ev.dev_id = hdev->id; - hci_si_event(NULL, HCI_EV_SI_DEVICE, sizeof(ev), &ev); - - if (event == HCI_DEV_UNREG) { - struct sock *sk; - struct hlist_node *node; - - /* Detach sockets from device */ - read_lock(&hci_sk_list.lock); - sk_for_each(sk, node, &hci_sk_list.head) { - bh_lock_sock_nested(sk); - if (hci_pi(sk)->hdev == hdev) { - hci_pi(sk)->hdev = NULL; - sk->sk_err = EPIPE; - sk->sk_state = BT_OPEN; - sk->sk_state_change(sk); - - hci_dev_put(hdev); - } - bh_unlock_sock(sk); - } - read_unlock(&hci_sk_list.lock); - } - - return NOTIFY_DONE; -} - static const struct net_proto_family hci_sock_family_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .create = hci_sock_create, }; -static struct notifier_block hci_sock_nblock = { - .notifier_call = hci_sock_dev_event -}; - int __init hci_sock_init(void) { int err; @@ -879,8 +900,6 @@ int __init hci_sock_init(void) if (err < 0) goto error; - hci_register_notifier(&hci_sock_nblock); - BT_INFO("HCI socket layer initialized"); return 0; @@ -896,8 +915,6 @@ void hci_sock_cleanup(void) if (bt_sock_unregister(BTPROTO_HCI) < 0) BT_ERR("HCI socket unregistration failed"); - hci_unregister_notifier(&hci_sock_nblock); - proto_unregister(&hci_sk_proto); } -- GitLab From cd82e61c110a36e398323e422896fcfe05879fed Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 20:34:38 +0100 Subject: [PATCH 0902/1846] Bluetooth: Add support for HCI monitor channel The HCI monitor channel can be used to monitor all packets and events from the Bluetooth subsystem. The monitor is not bound to any specific HCI device and allows even capturing multiple devices at the same time. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/hci_mon.h | 51 ++++++++ net/bluetooth/hci_core.c | 13 +- net/bluetooth/hci_sock.c | 207 +++++++++++++++++++++++++++++++ 5 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 include/net/bluetooth/hci_mon.h diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1b634e126878..60a4727be935 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1320,6 +1320,7 @@ struct sockaddr_hci { #define HCI_CHANNEL_RAW 0 #define HCI_CHANNEL_CONTROL 1 +#define HCI_CHANNEL_MONITOR 2 struct hci_filter { unsigned long type_mask; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 41adae509e9c..094b5dbdb130 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -950,6 +950,7 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); /* ----- HCI Sockets ----- */ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); +void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); void hci_sock_dev_event(struct hci_dev *hdev, int event); diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h new file mode 100644 index 000000000000..07a25c92502c --- /dev/null +++ b/include/net/bluetooth/hci_mon.h @@ -0,0 +1,51 @@ +/* + BlueZ - Bluetooth protocol stack for Linux + + Copyright (C) 2011-2012 Intel Corporation + + 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; + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY + CLAIM, OR ANY SPECIAL 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. + + ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, + COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS + SOFTWARE IS DISCLAIMED. +*/ + +#ifndef __HCI_MON_H +#define __HCI_MON_H + +struct hci_mon_hdr { + __le16 opcode; + __le16 index; + __le16 len; +} __packed; +#define HCI_MON_HDR_SIZE 6 + +#define HCI_MON_NEW_INDEX 0 +#define HCI_MON_DEL_INDEX 1 +#define HCI_MON_COMMAND_PKT 2 +#define HCI_MON_EVENT_PKT 3 +#define HCI_MON_ACL_TX_PKT 4 +#define HCI_MON_ACL_RX_PKT 5 +#define HCI_MON_SCO_TX_PKT 6 +#define HCI_MON_SCO_RX_PKT 7 + +struct hci_mon_new_index { + __u8 type; + __u8 bus; + bdaddr_t bdaddr; + char name[8]; +} __packed; +#define HCI_MON_NEW_INDEX_SIZE 16 + +#endif /* __HCI_MON_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 47217281d9ac..87ff7ffdb367 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2113,10 +2113,14 @@ static int hci_send_frame(struct sk_buff *skb) BT_DBG("%s type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len); - if (atomic_read(&hdev->promisc)) { - /* Time stamp */ - __net_timestamp(skb); + /* Time stamp */ + __net_timestamp(skb); + /* Send copy to monitor */ + hci_send_to_monitor(hdev, skb); + + if (atomic_read(&hdev->promisc)) { + /* Send copy to the sockets */ hci_send_to_sock(hdev, skb); } @@ -2802,6 +2806,9 @@ static void hci_rx_work(struct work_struct *work) BT_DBG("%s", hdev->name); while ((skb = skb_dequeue(&hdev->rx_q))) { + /* Send copy to monitor */ + hci_send_to_monitor(hdev, skb); + if (atomic_read(&hdev->promisc)) { /* Send copy to the sockets */ hci_send_to_sock(hdev, skb); diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 14727cb43f63..213697d23771 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -48,9 +48,12 @@ #include #include +#include static bool enable_mgmt; +static atomic_t monitor_promisc = ATOMIC_INIT(0); + /* ----- HCI socket interface ----- */ static inline int hci_test_bit(int nr, void *addr) @@ -189,6 +192,174 @@ void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk) read_unlock(&hci_sk_list.lock); } +/* Send frame to monitor socket */ +void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct sock *sk; + struct hlist_node *node; + struct sk_buff *skb_copy = NULL; + __le16 opcode; + + if (!atomic_read(&monitor_promisc)) + return; + + BT_DBG("hdev %p len %d", hdev, skb->len); + + switch (bt_cb(skb)->pkt_type) { + case HCI_COMMAND_PKT: + opcode = __constant_cpu_to_le16(HCI_MON_COMMAND_PKT); + break; + case HCI_EVENT_PKT: + opcode = __constant_cpu_to_le16(HCI_MON_EVENT_PKT); + break; + case HCI_ACLDATA_PKT: + if (bt_cb(skb)->incoming) + opcode = __constant_cpu_to_le16(HCI_MON_ACL_RX_PKT); + else + opcode = __constant_cpu_to_le16(HCI_MON_ACL_TX_PKT); + break; + case HCI_SCODATA_PKT: + if (bt_cb(skb)->incoming) + opcode = __constant_cpu_to_le16(HCI_MON_SCO_RX_PKT); + else + opcode = __constant_cpu_to_le16(HCI_MON_SCO_TX_PKT); + break; + default: + return; + } + + read_lock(&hci_sk_list.lock); + + sk_for_each(sk, node, &hci_sk_list.head) { + struct sk_buff *nskb; + + if (sk->sk_state != BT_BOUND) + continue; + + if (hci_pi(sk)->channel != HCI_CHANNEL_MONITOR) + continue; + + if (!skb_copy) { + struct hci_mon_hdr *hdr; + + /* Create a private copy with headroom */ + skb_copy = __pskb_copy(skb, HCI_MON_HDR_SIZE, GFP_ATOMIC); + if (!skb_copy) + continue; + + /* Put header before the data */ + hdr = (void *) skb_push(skb_copy, HCI_MON_HDR_SIZE); + hdr->opcode = opcode; + hdr->index = cpu_to_le16(hdev->id); + hdr->len = cpu_to_le16(skb->len); + } + + nskb = skb_clone(skb_copy, GFP_ATOMIC); + if (!nskb) + continue; + + if (sock_queue_rcv_skb(sk, nskb)) + kfree_skb(nskb); + } + + read_unlock(&hci_sk_list.lock); + + kfree_skb(skb_copy); +} + +static void send_monitor_event(struct sk_buff *skb) +{ + struct sock *sk; + struct hlist_node *node; + + BT_DBG("len %d", skb->len); + + read_lock(&hci_sk_list.lock); + + sk_for_each(sk, node, &hci_sk_list.head) { + struct sk_buff *nskb; + + if (sk->sk_state != BT_BOUND) + continue; + + if (hci_pi(sk)->channel != HCI_CHANNEL_MONITOR) + continue; + + nskb = skb_clone(skb, GFP_ATOMIC); + if (!nskb) + continue; + + if (sock_queue_rcv_skb(sk, nskb)) + kfree_skb(nskb); + } + + read_unlock(&hci_sk_list.lock); +} + +static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) +{ + struct hci_mon_hdr *hdr; + struct hci_mon_new_index *ni; + struct sk_buff *skb; + __le16 opcode; + + switch (event) { + case HCI_DEV_REG: + skb = bt_skb_alloc(HCI_MON_NEW_INDEX_SIZE, GFP_ATOMIC); + if (!skb) + return NULL; + + ni = (void *) skb_put(skb, HCI_MON_NEW_INDEX_SIZE); + ni->type = hdev->dev_type; + ni->bus = hdev->bus; + bacpy(&ni->bdaddr, &hdev->bdaddr); + memcpy(ni->name, hdev->name, 8); + + opcode = __constant_cpu_to_le16(HCI_MON_NEW_INDEX); + break; + + case HCI_DEV_UNREG: + skb = bt_skb_alloc(0, GFP_ATOMIC); + if (!skb) + return NULL; + + opcode = __constant_cpu_to_le16(HCI_MON_DEL_INDEX); + break; + + default: + return NULL; + } + + __net_timestamp(skb); + + hdr = (void *) skb_push(skb, HCI_MON_HDR_SIZE); + hdr->opcode = opcode; + hdr->index = cpu_to_le16(hdev->id); + hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); + + return skb; +} + +static void send_monitor_replay(struct sock *sk) +{ + struct hci_dev *hdev; + + read_lock(&hci_dev_list_lock); + + list_for_each_entry(hdev, &hci_dev_list, list) { + struct sk_buff *skb; + + skb = create_monitor_event(hdev, HCI_DEV_REG); + if (!skb) + continue; + + if (sock_queue_rcv_skb(sk, skb)) + kfree_skb(skb); + } + + read_unlock(&hci_dev_list_lock); +} + /* Generate internal stack event */ static void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) { @@ -223,6 +394,17 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event) BT_DBG("hdev %s event %d", hdev->name, event); + /* Send event to monitor */ + if (atomic_read(&monitor_promisc)) { + struct sk_buff *skb; + + skb = create_monitor_event(hdev, event); + if (skb) { + send_monitor_event(skb); + kfree_skb(skb); + } + } + /* Send event to sockets */ ev.event = event; ev.dev_id = hdev->id; @@ -262,6 +444,9 @@ static int hci_sock_release(struct socket *sock) hdev = hci_pi(sk)->hdev; + if (hci_pi(sk)->channel == HCI_CHANNEL_MONITOR) + atomic_dec(&monitor_promisc); + bt_sock_unlink(&hci_sk_list, sk); if (hdev) { @@ -474,6 +659,22 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags); break; + case HCI_CHANNEL_MONITOR: + if (haddr.hci_dev != HCI_DEV_NONE) { + err = -EINVAL; + goto done; + } + + if (!capable(CAP_NET_RAW)) { + err = -EPERM; + goto done; + } + + send_monitor_replay(sk); + + atomic_inc(&monitor_promisc); + break; + default: err = -EINVAL; goto done; @@ -578,6 +779,9 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, case HCI_CHANNEL_RAW: hci_sock_cmsg(sk, msg, skb); break; + case HCI_CHANNEL_MONITOR: + sock_recv_timestamp(msg, sk, skb); + break; } skb_free_datagram(sk, skb); @@ -612,6 +816,9 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, case HCI_CHANNEL_CONTROL: err = mgmt_control(sk, msg, len); goto done; + case HCI_CHANNEL_MONITOR: + err = -EOPNOTSUPP; + goto done; default: err = -EINVAL; goto done; -- GitLab From 801f13bd8ecc58f2cf42ec602a2b5db10fc5a132 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 20:54:10 +0100 Subject: [PATCH 0903/1846] Bluetooth: Restrict access to management interface The management interface on the HCI control channel should be restricted to applications with CAP_NET_ADMIN permission. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 213697d23771..8c429a179aa4 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -656,6 +656,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le goto done; } + if (!capable(CAP_NET_ADMIN)) { + err = -EPERM; + goto done; + } + set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags); break; -- GitLab From d7b7e79688c07b445bc52adfedf9a176be156f4b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 21:47:49 +0100 Subject: [PATCH 0904/1846] Bluetooth: Set supported settings based on enabled HS and/or LE Since neither High Speed (HS) nor Low Energy (LE) are fully implemented yet, only expose them in supported settings when enabled. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_core.c | 5 ----- net/bluetooth/hci_event.c | 5 ----- net/bluetooth/mgmt.c | 18 ++++++++++++++++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 60a4727be935..ad5e94c757e7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1422,5 +1422,6 @@ struct hci_inquiry_req { #define IREQ_CACHE_FLUSH 0x0001 extern bool enable_hs; +extern bool enable_le; #endif /* __HCI_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 87ff7ffdb367..cc52e037440e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -54,8 +54,6 @@ #define AUTO_OFF_TIMEOUT 2000 -bool enable_hs; - static void hci_rx_work(struct work_struct *work); static void hci_cmd_work(struct work_struct *work); static void hci_tx_work(struct work_struct *work); @@ -2913,6 +2911,3 @@ int hci_cancel_inquiry(struct hci_dev *hdev) return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); } - -module_param(enable_hs, bool, 0644); -MODULE_PARM_DESC(enable_hs, "Enable High Speed"); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index f00faf0ac32f..5d0f92a948c2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -44,8 +44,6 @@ #include #include -static bool enable_le; - /* Handle HCI Event packets */ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) @@ -3545,6 +3543,3 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) kfree_skb(skb); hdev->stat.evt_rx++; } - -module_param(enable_le, bool, 0644); -MODULE_PARM_DESC(enable_le, "Enable LE support"); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index bc71b45ef4e5..f7c2969d8829 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -34,6 +34,9 @@ #include #include +bool enable_hs; +bool enable_le; + #define MGMT_VERSION 1 #define MGMT_REVISION 0 @@ -374,8 +377,13 @@ static u32 get_supported_settings(struct hci_dev *hdev) settings |= MGMT_SETTING_LINK_SECURITY; } - if (hdev->features[4] & LMP_LE) - settings |= MGMT_SETTING_LE; + if (enable_hs) + settings |= MGMT_SETTING_HS; + + if (enable_le) { + if (hdev->features[4] & LMP_LE) + settings |= MGMT_SETTING_LE; + } return settings; } @@ -3421,3 +3429,9 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev), cmd ? cmd->sk : NULL); } + +module_param(enable_hs, bool, 0644); +MODULE_PARM_DESC(enable_hs, "Enable High Speed support"); + +module_param(enable_le, bool, 0644); +MODULE_PARM_DESC(enable_le, "Enable Low Energy support"); -- GitLab From 4b95a24ce12c4545fd7d2e3075841dc3119d1d71 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Feb 2012 21:24:37 +0100 Subject: [PATCH 0905/1846] Bluetooth: Always enable management interface The management interface API has reached stable version 1.0 and thus it can now be always enabled. All future changes will be made backwards compatible. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 8c429a179aa4..dd5635064145 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -50,8 +50,6 @@ #include #include -static bool enable_mgmt; - static atomic_t monitor_promisc = ATOMIC_INIT(0); /* ----- HCI socket interface ----- */ @@ -651,7 +649,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le break; case HCI_CHANNEL_CONTROL: - if (haddr.hci_dev != HCI_DEV_NONE || !enable_mgmt) { + if (haddr.hci_dev != HCI_DEV_NONE) { err = -EINVAL; goto done; } @@ -1129,6 +1127,3 @@ void hci_sock_cleanup(void) proto_unregister(&hci_sk_proto); } - -module_param(enable_mgmt, bool, 0644); -MODULE_PARM_DESC(enable_mgmt, "Enable Management interface"); -- GitLab From d930650b59be72342bc373ef52006ca99c1dd09e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Feb 2012 23:25:18 +0200 Subject: [PATCH 0906/1846] Bluetooth: mgmt: Add address type parameter to Stop Discovery command This patch adds an address type parameter to the Stop Discovery command which should match the value given to Start Discovery. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 3 +++ net/bluetooth/mgmt.c | 33 ++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 7e3d38bfaec3..870a3deab6ea 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -283,6 +283,9 @@ struct mgmt_cp_start_discovery { } __packed; #define MGMT_OP_STOP_DISCOVERY 0x0024 +struct mgmt_cp_stop_discovery { + __u8 type; +} __packed; #define MGMT_OP_CONFIRM_NAME 0x0025 struct mgmt_cp_confirm_name { diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f7c2969d8829..3db8525b0293 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2281,8 +2281,9 @@ static int start_discovery(struct sock *sk, u16 index, return err; } -static int stop_discovery(struct sock *sk, u16 index) +static int stop_discovery(struct sock *sk, u16 index, void *data, u16 len) { + struct mgmt_cp_stop_discovery *mgmt_cp = data; struct hci_dev *hdev; struct pending_cmd *cmd; struct hci_cp_remote_name_req_cancel cp; @@ -2291,6 +2292,10 @@ static int stop_discovery(struct sock *sk, u16 index) BT_DBG("hci%u", index); + if (len != sizeof(*mgmt_cp)) + return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, + MGMT_STATUS_INVALID_PARAMS); + hdev = hci_dev_get(index); if (!hdev) return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, @@ -2299,8 +2304,16 @@ static int stop_discovery(struct sock *sk, u16 index) hci_dev_lock(hdev); if (!hci_discovery_active(hdev)) { - err = cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, - MGMT_STATUS_REJECTED); + err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, + MGMT_STATUS_REJECTED, + &mgmt_cp->type, sizeof(mgmt_cp->type)); + goto unlock; + } + + if (hdev->discovery.type != mgmt_cp->type) { + err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, + MGMT_STATUS_INVALID_PARAMS, + &mgmt_cp->type, sizeof(mgmt_cp->type)); goto unlock; } @@ -2323,7 +2336,7 @@ static int stop_discovery(struct sock *sk, u16 index) if (!e) { mgmt_pending_remove(cmd); err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, 0, - NULL, 0); + &mgmt_cp->type, sizeof(mgmt_cp->type)); hci_discovery_set_state(hdev, DISCOVERY_STOPPED); goto unlock; } @@ -2706,7 +2719,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) err = start_discovery(sk, index, cp, len); break; case MGMT_OP_STOP_DISCOVERY: - err = stop_discovery(sk, index); + err = stop_discovery(sk, index, cp, len); break; case MGMT_OP_CONFIRM_NAME: err = confirm_name(sk, index, cp, len); @@ -3369,7 +3382,9 @@ int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status) if (!cmd) return -ENOENT; - err = cmd_status(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status)); + err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status), + &hdev->discovery.type, + sizeof(hdev->discovery.type)); mgmt_pending_remove(cmd); return err; @@ -3389,12 +3404,8 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) if (cmd != NULL) { u8 type = hdev->discovery.type; - if (discovering) - cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, + cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, &type, sizeof(type)); - else - cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, - NULL, 0); mgmt_pending_remove(cmd); } -- GitLab From f963e8e9d3652f4a8065d969206707a1c21ff9b0 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Feb 2012 23:30:44 +0200 Subject: [PATCH 0907/1846] Bluetooth: mgmt: Add address type parameter to Discovering event This patch adds an address type parameter to the Discovering event. The value matches that given to Start/Stop Discovery. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 4 ++++ net/bluetooth/hci_core.c | 3 +-- net/bluetooth/mgmt.c | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 870a3deab6ea..1dbadbe14785 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -402,6 +402,10 @@ struct mgmt_ev_device_found { } __packed; #define MGMT_EV_DISCOVERING 0x0013 +struct mgmt_ev_discovering { + __u8 type; + __u8 discovering; +} __packed; #define MGMT_EV_DEVICE_BLOCKED 0x0014 struct mgmt_ev_device_blocked { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index cc52e037440e..a7439aeb1f9b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -363,10 +363,9 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) switch (state) { case DISCOVERY_STOPPED: - hdev->discovery.type = 0; - if (hdev->discovery.state != DISCOVERY_STARTING) mgmt_discovering(hdev, 0); + hdev->discovery.type = 0; break; case DISCOVERY_STARTING: break; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3db8525b0293..86148b182891 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3392,6 +3392,7 @@ int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status) int mgmt_discovering(struct hci_dev *hdev, u8 discovering) { + struct mgmt_ev_discovering ev; struct pending_cmd *cmd; BT_DBG("%s discovering %u", hdev->name, discovering); @@ -3409,8 +3410,11 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) mgmt_pending_remove(cmd); } - return mgmt_event(MGMT_EV_DISCOVERING, hdev, &discovering, - sizeof(discovering), NULL); + memset(&ev, 0, sizeof(ev)); + ev.type = hdev->discovery.type; + ev.discovering = discovering; + + return mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL); } int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) -- GitLab From 6d80dfd094a7b286e95cdcac79efeb7bbb4e226f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Feb 2012 23:50:38 +0200 Subject: [PATCH 0908/1846] Bluetooth: mgmt: Add basic support for Set High Speed command This patch adds rudimentary support for the Set High Speed command in the form of a new HCI dev flag (HCI_HS_ENABLED). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 1 + net/bluetooth/mgmt.c | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index ad5e94c757e7..ec370494e568 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -95,6 +95,7 @@ enum { HCI_LE_SCAN, HCI_SSP_ENABLED, + HCI_HS_ENABLED, }; /* HCI ioctl defines */ diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 86148b182891..edf84c3e6a2b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -418,6 +418,9 @@ static u32 get_current_settings(struct hci_dev *hdev) if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) settings |= MGMT_SETTING_SSP; + if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags)) + settings |= MGMT_SETTING_HS; + return settings; } @@ -1093,6 +1096,41 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) return err; } +static int set_hs(struct sock *sk, u16 index, void *data, u16 len) +{ + struct mgmt_mode *cp = data; + struct hci_dev *hdev; + int err; + + BT_DBG("request for hci%u", index); + + if (len != sizeof(*cp)) + return cmd_status(sk, index, MGMT_OP_SET_HS, + MGMT_STATUS_INVALID_PARAMS); + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_SET_HS, + MGMT_STATUS_INVALID_PARAMS); + + if (!enable_hs) { + err = cmd_status(sk, index, MGMT_OP_SET_HS, + MGMT_STATUS_NOT_SUPPORTED); + goto failed; + } + + if (cp->val) + set_bit(HCI_HS_ENABLED, &hdev->dev_flags); + else + clear_bit(HCI_HS_ENABLED, &hdev->dev_flags); + + err = send_settings_rsp(sk, MGMT_OP_SET_HS, hdev); + +failed: + hci_dev_put(hdev); + return err; +} + static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_add_uuid *cp = data; @@ -2655,6 +2693,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_SET_SSP: err = set_ssp(sk, index, cp, len); break; + case MGMT_OP_SET_HS: + err = set_hs(sk, index, cp, len); + break; case MGMT_OP_ADD_UUID: err = add_uuid(sk, index, cp, len); break; -- GitLab From 1e16357480fdeaeff7c5572f1afba7835473fcb6 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Feb 2012 23:53:46 +0200 Subject: [PATCH 0909/1846] Bluetooth: mgmt: Fix Set SSP check for supported feature If the local controller doesn't support SSP we should always return an error for the Set SSP command. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index edf84c3e6a2b..aa0d64040fac 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1065,6 +1065,12 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) goto failed; } + if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { + err = cmd_status(sk, index, MGMT_OP_SET_SSP, + MGMT_STATUS_NOT_SUPPORTED); + goto failed; + } + if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_BUSY); goto failed; -- GitLab From cacaf52f51697f832a26e8fdaa7b8e85785085da Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 00:52:42 +0200 Subject: [PATCH 0910/1846] Bluetooth: mgmt: Clear EIR data when disabling SSP EIR shouldn't be enabled if SSP isn't enabled. This patch adds the clearing of EIR data when disabling SSP and restores the data when SSP is re-enabled. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index aa0d64040fac..a5a2a6844aea 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3250,6 +3250,18 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) return err; } +static int clear_eir(struct hci_dev *hdev) +{ + struct hci_cp_write_eir cp; + + if (!(hdev->features[6] & LMP_EXT_INQ)) + return 0; + + memset(&cp, 0, sizeof(cp)); + + return hci_send_cmd(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp); +} + int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status) { struct cmd_lookup match = { NULL, hdev }; @@ -3268,9 +3280,15 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status) ev = cpu_to_le32(get_current_settings(hdev)); err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); - if (match.sk) + if (match.sk) { sock_put(match.sk); + if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) + update_eir(hdev); + else + clear_eir(hdev); + } + return err; } -- GitLab From 621b4d66b27e70ba9a0e8fa4676d9c4f916c8343 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Mon, 20 Feb 2012 09:59:08 +0000 Subject: [PATCH 0911/1846] use FW 7.2.16 The patch integrates FW 7.2.16 HSI and implements driver part of GRO flow. FW 7.2.16 adds the ability to aggregate packets for GRO (and not just LRO) and also fixes some bugs. 1. Added new aggregation mode: GRO. In this mode packets are aggregated such that the original packets can be reconstructed by the OS. 2. 57712 HW bug workaround - initialized all CAM TM registers to 0x32. 3. Adding the FCoE statistics structures to the BNX2X HSI. 4. Wrong configuration of TX HW input buffer size may cause theoretical performance effect. Performed configuration fix. 5. FCOE - Arrival of packets beyond task IO size can lead to crash. Fix firmware data-in flow. 6. iSCSI - In rare cases of on-chip termination the graceful termination timer hangs, and the termination doesn't complete. Firmware fix to MSL timer tolerance. 7. iSCSI - Chip hangs when target sends FIN out-of-order or with isles open at the initiator side. Firmware implementation corrected to drop FIN received out-of-order or with isles still open. 8. iSCSI - Chip hangs when in case of retransmission not aligned to 4-bytes from the beginning of iSCSI PDU. Firmware implementation corrected to support arbitrary aligned retransmissions. 9. iSCSI - Arrival of target-initiated NOP-IN during intense ISCSI traffic might lead to crash. Firmware fix to relevant flow. Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 12 ++ .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 149 ++++++++++++------ .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 24 ++- .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 57 +++---- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 11 +- .../net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 3 +- .../net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 1 + 8 files changed, 177 insertions(+), 82 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 604060ab8872..3cf9df833cb4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -445,6 +445,8 @@ struct bnx2x_agg_info { u16 vlan_tag; u16 len_on_bd; u32 rxhash; + u16 gro_size; + u16 full_page; }; #define Q_STATS_OFFSET32(stat_name) \ @@ -473,6 +475,11 @@ struct bnx2x_fp_txdata { int txq_index; }; +enum bnx2x_tpa_mode_t { + TPA_MODE_LRO, + TPA_MODE_GRO +}; + struct bnx2x_fastpath { struct bnx2x *bp; /* parent */ @@ -489,6 +496,8 @@ struct bnx2x_fastpath { dma_addr_t status_blk_mapping; + enum bnx2x_tpa_mode_t mode; + u8 max_cos; /* actual number of active tx coses */ struct bnx2x_fp_txdata txdata[BNX2X_MULTI_TX_COS]; @@ -1199,6 +1208,8 @@ struct bnx2x { #define ETH_MIN_PACKET_SIZE 60 #define ETH_MAX_PACKET_SIZE 1500 #define ETH_MAX_JUMBO_PACKET_SIZE 9600 +/* TCP with Timestamp Option (32) + IPv6 (40) */ +#define ETH_MAX_TPA_HEADER_SIZE 72 /* Max supported alignment is 256 (8 shift) */ #define BNX2X_RX_ALIGN_SHIFT min(8, L1_CACHE_SHIFT) @@ -1269,6 +1280,7 @@ struct bnx2x { #define NO_MCP_FLAG (1 << 9) #define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) +#define GRO_ENABLE_FLAG (1 << 10) #define MF_FUNC_DIS (1 << 11) #define OWN_CNIC_IRQ (1 << 12) #define NO_ISCSI_OOO_FLAG (1 << 13) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index aa14502289ce..0a45251edb8f 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -209,13 +209,11 @@ static inline void bnx2x_update_last_max_sge(struct bnx2x_fastpath *fp, fp->last_max_sge = idx; } -static void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp, - struct eth_fast_path_rx_cqe *fp_cqe) +static inline void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp, + u16 sge_len, + struct eth_end_agg_rx_cqe *cqe) { struct bnx2x *bp = fp->bp; - u16 sge_len = SGE_PAGE_ALIGN(le16_to_cpu(fp_cqe->pkt_len) - - le16_to_cpu(fp_cqe->len_on_bd)) >> - SGE_PAGE_SHIFT; u16 last_max, last_elem, first_elem; u16 delta = 0; u16 i; @@ -226,15 +224,15 @@ static void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp, /* First mark all used pages */ for (i = 0; i < sge_len; i++) BIT_VEC64_CLEAR_BIT(fp->sge_mask, - RX_SGE(le16_to_cpu(fp_cqe->sgl_or_raw_data.sgl[i]))); + RX_SGE(le16_to_cpu(cqe->sgl_or_raw_data.sgl[i]))); DP(NETIF_MSG_RX_STATUS, "fp_cqe->sgl[%d] = %d\n", - sge_len - 1, le16_to_cpu(fp_cqe->sgl_or_raw_data.sgl[sge_len - 1])); + sge_len - 1, le16_to_cpu(cqe->sgl_or_raw_data.sgl[sge_len - 1])); /* Here we assume that the last SGE index is the biggest */ prefetch((void *)(fp->sge_mask)); bnx2x_update_last_max_sge(fp, - le16_to_cpu(fp_cqe->sgl_or_raw_data.sgl[sge_len - 1])); + le16_to_cpu(cqe->sgl_or_raw_data.sgl[sge_len - 1])); last_max = RX_SGE(fp->last_max_sge); last_elem = last_max >> BIT_VEC64_ELEM_SHIFT; @@ -328,6 +326,12 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, tpa_info->len_on_bd = le16_to_cpu(cqe->len_on_bd); tpa_info->placement_offset = cqe->placement_offset; tpa_info->rxhash = bnx2x_get_rxhash(bp, cqe); + if (fp->mode == TPA_MODE_GRO) { + u16 gro_size = le16_to_cpu(cqe->pkt_len_or_gro_seg_len); + tpa_info->full_page = + SGE_PAGE_SIZE * PAGES_PER_SGE / gro_size * gro_size; + tpa_info->gro_size = gro_size; + } #ifdef BNX2X_STOP_ON_ERROR fp->tpa_queue_used |= (1 << queue); @@ -384,25 +388,40 @@ static inline u16 bnx2x_set_lro_mss(struct bnx2x *bp, u16 parsing_flags, } static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp, - u16 queue, struct sk_buff *skb, + struct bnx2x_agg_info *tpa_info, + u16 pages, + struct sk_buff *skb, struct eth_end_agg_rx_cqe *cqe, u16 cqe_idx) { struct sw_rx_page *rx_pg, old_rx_pg; - u32 i, frag_len, frag_size, pages; - int err; - int j; - struct bnx2x_agg_info *tpa_info = &fp->tpa_info[queue]; + u32 i, frag_len, frag_size; + int err, j, frag_id = 0; u16 len_on_bd = tpa_info->len_on_bd; + u16 full_page = 0, gro_size = 0; frag_size = le16_to_cpu(cqe->pkt_len) - len_on_bd; - pages = SGE_PAGE_ALIGN(frag_size) >> SGE_PAGE_SHIFT; + + if (fp->mode == TPA_MODE_GRO) { + gro_size = tpa_info->gro_size; + full_page = tpa_info->full_page; + } /* This is needed in order to enable forwarding support */ - if (frag_size) + if (frag_size) { skb_shinfo(skb)->gso_size = bnx2x_set_lro_mss(bp, tpa_info->parsing_flags, len_on_bd); + /* set for GRO */ + if (fp->mode == TPA_MODE_GRO) + skb_shinfo(skb)->gso_type = + (GET_FLAG(tpa_info->parsing_flags, + PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) == + PRS_FLAG_OVERETH_IPV6) ? + SKB_GSO_TCPV6 : SKB_GSO_TCPV4; + } + + #ifdef BNX2X_STOP_ON_ERROR if (pages > min_t(u32, 8, MAX_SKB_FRAGS)*SGE_PAGE_SIZE*PAGES_PER_SGE) { BNX2X_ERR("SGL length is too long: %d. CQE index is %d\n", @@ -419,7 +438,12 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp, /* FW gives the indices of the SGE as if the ring is an array (meaning that "next" element will consume 2 indices) */ - frag_len = min(frag_size, (u32)(SGE_PAGE_SIZE*PAGES_PER_SGE)); + if (fp->mode == TPA_MODE_GRO) + frag_len = min_t(u32, frag_size, (u32)full_page); + else /* LRO */ + frag_len = min_t(u32, frag_size, + (u32)(SGE_PAGE_SIZE * PAGES_PER_SGE)); + rx_pg = &fp->rx_page_ring[sge_idx]; old_rx_pg = *rx_pg; @@ -435,9 +459,21 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp, dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(&old_rx_pg, mapping), SGE_PAGE_SIZE*PAGES_PER_SGE, DMA_FROM_DEVICE); - /* Add one frag and update the appropriate fields in the skb */ - skb_fill_page_desc(skb, j, old_rx_pg.page, 0, frag_len); + if (fp->mode == TPA_MODE_LRO) + skb_fill_page_desc(skb, j, old_rx_pg.page, 0, frag_len); + else { /* GRO */ + int rem; + int offset = 0; + for (rem = frag_len; rem > 0; rem -= gro_size) { + int len = rem > gro_size ? gro_size : rem; + skb_fill_page_desc(skb, frag_id++, + old_rx_pg.page, offset, len); + if (offset) + get_page(old_rx_pg.page); + offset += len; + } + } skb->data_len += frag_len; skb->truesize += SGE_PAGE_SIZE * PAGES_PER_SGE; @@ -449,18 +485,17 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp, return 0; } -static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, - u16 queue, struct eth_end_agg_rx_cqe *cqe, - u16 cqe_idx) +static inline void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, + struct bnx2x_agg_info *tpa_info, + u16 pages, + struct eth_end_agg_rx_cqe *cqe, + u16 cqe_idx) { - struct bnx2x_agg_info *tpa_info = &fp->tpa_info[queue]; struct sw_rx_bd *rx_buf = &tpa_info->first_buf; - u32 pad = tpa_info->placement_offset; + u8 pad = tpa_info->placement_offset; u16 len = tpa_info->len_on_bd; struct sk_buff *skb = NULL; - u8 *data = rx_buf->data; - /* alloc new skb */ - u8 *new_data; + u8 *new_data, *data = rx_buf->data; u8 old_tpa_state = tpa_info->tpa_state; tpa_info->tpa_state = BNX2X_TPA_STOP; @@ -500,7 +535,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, skb->protocol = eth_type_trans(skb, bp->dev); skb->ip_summed = CHECKSUM_UNNECESSARY; - if (!bnx2x_fill_frag_skb(bp, fp, queue, skb, cqe, cqe_idx)) { + if (!bnx2x_fill_frag_skb(bp, fp, tpa_info, pages, + skb, cqe, cqe_idx)) { if (tpa_info->parsing_flags & PARSING_FLAGS_VLAN) __vlan_hwaccel_put_tag(skb, tpa_info->vlan_tag); napi_gro_receive(&fp->napi, skb); @@ -565,7 +601,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) struct eth_fast_path_rx_cqe *cqe_fp; u8 cqe_fp_flags; enum eth_rx_cqe_type cqe_fp_type; - u16 len, pad; + u16 len, pad, queue; u8 *data; #ifdef BNX2X_STOP_ON_ERROR @@ -586,17 +622,21 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) " queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags), cqe_fp_flags, cqe_fp->status_flags, le32_to_cpu(cqe_fp->rss_hash_result), - le16_to_cpu(cqe_fp->vlan_tag), le16_to_cpu(cqe_fp->pkt_len)); + le16_to_cpu(cqe_fp->vlan_tag), + le16_to_cpu(cqe_fp->pkt_len_or_gro_seg_len)); /* is this a slowpath msg? */ if (unlikely(CQE_TYPE_SLOW(cqe_fp_type))) { bnx2x_sp_event(fp, cqe); goto next_cqe; } + rx_buf = &fp->rx_buf_ring[bd_cons]; data = rx_buf->data; if (!CQE_TYPE_FAST(cqe_fp_type)) { + struct bnx2x_agg_info *tpa_info; + u16 frag_size, pages; #ifdef BNX2X_STOP_ON_ERROR /* sanity check */ if (fp->disable_tpa && @@ -616,28 +656,38 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) bnx2x_tpa_start(fp, queue, bd_cons, bd_prod, cqe_fp); + goto next_rx; - } else { - u16 queue = - cqe->end_agg_cqe.queue_index; - DP(NETIF_MSG_RX_STATUS, - "calling tpa_stop on queue %d\n", - queue); - bnx2x_tpa_stop(bp, fp, queue, - &cqe->end_agg_cqe, - comp_ring_cons); + } + queue = cqe->end_agg_cqe.queue_index; + tpa_info = &fp->tpa_info[queue]; + DP(NETIF_MSG_RX_STATUS, + "calling tpa_stop on queue %d\n", + queue); + + frag_size = le16_to_cpu(cqe->end_agg_cqe.pkt_len) - + tpa_info->len_on_bd; + + if (fp->mode == TPA_MODE_GRO) + pages = (frag_size + tpa_info->full_page - 1) / + tpa_info->full_page; + else + pages = SGE_PAGE_ALIGN(frag_size) >> + SGE_PAGE_SHIFT; + + bnx2x_tpa_stop(bp, fp, tpa_info, pages, + &cqe->end_agg_cqe, comp_ring_cons); #ifdef BNX2X_STOP_ON_ERROR - if (bp->panic) - return 0; + if (bp->panic) + return 0; #endif - bnx2x_update_sge_prod(fp, cqe_fp); - goto next_cqe; - } + bnx2x_update_sge_prod(fp, pages, &cqe->end_agg_cqe); + goto next_cqe; } /* non TPA */ - len = le16_to_cpu(cqe_fp->pkt_len); + len = le16_to_cpu(cqe_fp->pkt_len_or_gro_seg_len); pad = cqe_fp->placement_offset; dma_sync_single_for_cpu(&bp->pdev->dev, dma_unmap_addr(rx_buf, mapping), @@ -3440,13 +3490,15 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) } netdev_features_t bnx2x_fix_features(struct net_device *dev, - netdev_features_t features) + netdev_features_t features) { struct bnx2x *bp = netdev_priv(dev); /* TPA requires Rx CSUM offloading */ - if (!(features & NETIF_F_RXCSUM) || bp->disable_tpa) + if (!(features & NETIF_F_RXCSUM) || bp->disable_tpa) { features &= ~NETIF_F_LRO; + features &= ~NETIF_F_GRO; + } return features; } @@ -3462,6 +3514,11 @@ int bnx2x_set_features(struct net_device *dev, netdev_features_t features) else flags &= ~TPA_ENABLE_FLAG; + if (features & NETIF_F_GRO) + flags |= GRO_ENABLE_FLAG; + else + flags &= ~GRO_ENABLE_FLAG; + if (features & NETIF_F_LOOPBACK) { if (bp->link_params.loopback_mode != LOOPBACK_BMAC) { bp->link_params.loopback_mode = LOOPBACK_BMAC; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index f978c6a1aef1..d2093ee9b85e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -534,8 +534,9 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu); */ int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type); #endif + netdev_features_t bnx2x_fix_features(struct net_device *dev, - netdev_features_t features); + netdev_features_t features); int bnx2x_set_features(struct net_device *dev, netdev_features_t features); /** @@ -1491,6 +1492,18 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) return max_cfg; } +/* checks if HW supports GRO for given MTU */ +static inline bool bnx2x_mtu_allows_gro(int mtu) +{ + /* gro frags per page */ + int fpp = SGE_PAGE_SIZE / (mtu - ETH_MAX_TPA_HEADER_SIZE); + + /* + * 1. number of frags should not grow above MAX_SKB_FRAGS + * 2. frag must fit the page + */ + return mtu <= SGE_PAGE_SIZE && (U_ETH_SGL_SIZE * fpp) <= MAX_SKB_FRAGS; +} /** * bnx2x_bz_fp - zero content of the fastpath structure. * @@ -1556,7 +1569,14 @@ static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) * set the tpa flag for each queue. The tpa flag determines the queue * minimal size so it must be set prior to queue memory allocation */ - fp->disable_tpa = (bp->flags & TPA_ENABLE_FLAG) == 0; + fp->disable_tpa = !(bp->flags & TPA_ENABLE_FLAG || + (bp->flags & GRO_ENABLE_FLAG && + bnx2x_mtu_allows_gro(bp->dev->mtu))); + if (bp->flags & TPA_ENABLE_FLAG) + fp->mode = TPA_MODE_LRO; + else if (bp->flags & GRO_ENABLE_FLAG) + fp->mode = TPA_MODE_GRO; + #ifdef BCM_CNIC /* We don't want TPA on an FCoE L2 ring */ if (IS_FCOE_FP(fp)) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 7e57fa40d2e3..9c24d536edef 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -1931,7 +1931,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) if (!CQE_TYPE_FAST(cqe_fp_type) || (cqe_fp_flags & ETH_RX_ERROR_FALGS)) goto test_loopback_rx_exit; - len = le16_to_cpu(cqe->fast_path_cqe.pkt_len); + len = le16_to_cpu(cqe->fast_path_cqe.pkt_len_or_gro_seg_len); if (len != pkt_size) goto test_loopback_rx_exit; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h index 78b77de728b0..a1413ad7757d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h @@ -34,9 +34,10 @@ struct license_key { }; -#define PORT_0 0 -#define PORT_1 1 -#define PORT_MAX 2 +#define PORT_0 0 +#define PORT_1 1 +#define PORT_MAX 2 +#define NVM_PATH_MAX 2 /**************************************************************************** * Shared HW configuration * @@ -618,12 +619,6 @@ struct port_hw_cfg { /* port 0: 0x12c port 1: 0x2bc */ #define PORT_HW_CFG_ENABLE_CMS_DISABLED 0x00000000 #define PORT_HW_CFG_ENABLE_CMS_ENABLED 0x00200000 - /* Enable RJ45 magjack pair swapping on 10GBase-T PHY, 84833 only */ - #define PORT_HW_CFG_RJ45_PR_SWP_MASK 0x00400000 - #define PORT_HW_CFG_RJ45_PR_SWP_SHIFT 22 - #define PORT_HW_CFG_RJ45_PR_SWP_DISABLED 0x00000000 - #define PORT_HW_CFG_RJ45_PR_SWP_ENABLED 0x00400000 - /* Determine the Serdes electrical interface */ #define PORT_HW_CFG_NET_SERDES_IF_MASK 0x0F000000 #define PORT_HW_CFG_NET_SERDES_IF_SHIFT 24 @@ -898,11 +893,6 @@ struct port_feat_cfg { /* port 0: 0x454 port 1: 0x4c8 */ #define PORT_FEAT_CFG_DCBX_DISABLED 0x00000000 #define PORT_FEAT_CFG_DCBX_ENABLED 0x00000100 - #define PORT_FEAT_CFG_AUTOGREEN_MASK 0x00000200 - #define PORT_FEAT_CFG_AUTOGREEN_SHIFT 9 - #define PORT_FEAT_CFG_AUTOGREEN_DISABLED 0x00000000 - #define PORT_FEAT_CFG_AUTOGREEN_ENABLED 0x00000200 - #define PORT_FEATURE_EN_SIZE_MASK 0x0f000000 #define PORT_FEATURE_EN_SIZE_SHIFT 24 #define PORT_FEATURE_WOL_ENABLED 0x01000000 @@ -1139,9 +1129,6 @@ struct shm_dev_info { /* size */ #define FW_ACK_NUM_OF_POLL (FW_ACK_TIME_OUT_MS/FW_ACK_POLL_TIME_MS) -/* LED Blink rate that will achieve ~15.9Hz */ -#define LED_BLINK_RATE_VAL 480 - /**************************************************************************** * Driver <-> FW Mailbox * ****************************************************************************/ @@ -1407,7 +1394,7 @@ struct port_mf_cfg { #define PORT_MF_CFG_E1HOV_TAG_SHIFT 0 #define PORT_MF_CFG_E1HOV_TAG_DEFAULT PORT_MF_CFG_E1HOV_TAG_MASK - u32 reserved[3]; + u32 reserved[1]; }; @@ -1493,7 +1480,8 @@ struct func_ext_cfg { struct mf_cfg { struct shared_mf_cfg shared_mf_config; /* 0x4 */ - struct port_mf_cfg port_mf_config[PORT_MAX]; /* 0x10 * 2 = 0x20 */ + /* 0x8*2*2=0x20 */ + struct port_mf_cfg port_mf_config[NVM_PATH_MAX][PORT_MAX]; /* for all chips, there are 8 mf functions */ struct func_mf_cfg func_mf_config[E1H_FUNC_MAX]; /* 0x18 * 8 = 0xc0 */ /* @@ -2002,6 +1990,7 @@ struct shmem2_region { #define DRV_INFO_CONTROL_VER_SHIFT 0 #define DRV_INFO_CONTROL_OP_CODE_MASK 0x0000ff00 #define DRV_INFO_CONTROL_OP_CODE_SHIFT 8 + u32 ibft_host_addr; /* initialized by option ROM */ }; @@ -2700,8 +2689,8 @@ union drv_info_to_mcp { struct iscsi_stats_info iscsi_stat; }; #define BCM_5710_FW_MAJOR_VERSION 7 -#define BCM_5710_FW_MINOR_VERSION 0 -#define BCM_5710_FW_REVISION_VERSION 29 +#define BCM_5710_FW_MINOR_VERSION 2 +#define BCM_5710_FW_REVISION_VERSION 16 #define BCM_5710_FW_ENGINEERING_VERSION 0 #define BCM_5710_FW_COMPILE_FLAGS 1 @@ -3308,8 +3297,10 @@ struct client_init_rx_data { #define CLIENT_INIT_RX_DATA_TPA_EN_IPV4_SHIFT 0 #define CLIENT_INIT_RX_DATA_TPA_EN_IPV6 (0x1<<1) #define CLIENT_INIT_RX_DATA_TPA_EN_IPV6_SHIFT 1 -#define CLIENT_INIT_RX_DATA_RESERVED5 (0x3F<<2) -#define CLIENT_INIT_RX_DATA_RESERVED5_SHIFT 2 +#define CLIENT_INIT_RX_DATA_TPA_MODE (0x1<<2) +#define CLIENT_INIT_RX_DATA_TPA_MODE_SHIFT 2 +#define CLIENT_INIT_RX_DATA_RESERVED5 (0x1F<<3) +#define CLIENT_INIT_RX_DATA_RESERVED5_SHIFT 3 u8 vmqueue_mode_en_flg; u8 extra_data_over_sgl_en_flg; u8 cache_line_alignment_log_size; @@ -3324,7 +3315,7 @@ struct client_init_rx_data { u8 outer_vlan_removal_enable_flg; u8 status_block_id; u8 rx_sb_index_number; - u8 reserved0; + u8 dont_verify_rings_pause_thr_flg; u8 max_tpa_queues; u8 silent_vlan_removal_flg; __le16 max_bytes_on_bd; @@ -3657,7 +3648,7 @@ struct eth_fast_path_rx_cqe { u8 placement_offset; __le32 rss_hash_result; __le16 vlan_tag; - __le16 pkt_len; + __le16 pkt_len_or_gro_seg_len; __le16 len_on_bd; struct parsing_flags pars_flags; union eth_sgl_or_raw_data sgl_or_raw_data; @@ -4214,6 +4205,15 @@ enum set_mac_action_type { }; +/* + * Ethernet TPA Modes + */ +enum tpa_mode { + TPA_LRO, + TPA_GRO, + MAX_TPA_MODE}; + + /* * tpa update ramrod data */ @@ -4224,7 +4224,8 @@ struct tpa_update_ramrod_data { u8 max_tpa_queues; u8 max_sges_for_packet; u8 complete_on_both_clients; - __le16 reserved1; + u8 dont_verify_rings_pause_thr_flg; + u8 tpa_mode; __le16 sge_buff_size; __le16 max_agg_size; __le32 sge_page_base_lo; @@ -4447,13 +4448,13 @@ enum common_spqe_cmd_id { RAMROD_CMD_ID_COMMON_UNUSED, RAMROD_CMD_ID_COMMON_FUNCTION_START, RAMROD_CMD_ID_COMMON_FUNCTION_STOP, + RAMROD_CMD_ID_COMMON_FUNCTION_UPDATE, RAMROD_CMD_ID_COMMON_CFC_DEL, RAMROD_CMD_ID_COMMON_CFC_DEL_WB, RAMROD_CMD_ID_COMMON_STAT_QUERY, RAMROD_CMD_ID_COMMON_STOP_TRAFFIC, RAMROD_CMD_ID_COMMON_START_TRAFFIC, RAMROD_CMD_ID_COMMON_RESERVED1, - RAMROD_CMD_ID_COMMON_RESERVED2, MAX_COMMON_SPQE_CMD_ID }; @@ -4733,8 +4734,8 @@ enum event_ring_opcode { EVENT_RING_OPCODE_MALICIOUS_VF, EVENT_RING_OPCODE_FORWARD_SETUP, EVENT_RING_OPCODE_RSS_UPDATE_RULES, + EVENT_RING_OPCODE_FUNCTION_UPDATE, EVENT_RING_OPCODE_RESERVED1, - EVENT_RING_OPCODE_RESERVED2, EVENT_RING_OPCODE_SET_MAC, EVENT_RING_OPCODE_CLASSIFICATION_RULES, EVENT_RING_OPCODE_FILTERS_RULES, diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 9831d8c416a9..816e7d42f61c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -2702,6 +2702,8 @@ static inline unsigned long bnx2x_get_q_flags(struct bnx2x *bp, if (!fp->disable_tpa) { __set_bit(BNX2X_Q_FLG_TPA, &flags); __set_bit(BNX2X_Q_FLG_TPA_IPV6, &flags); + if (fp->mode == TPA_MODE_GRO) + __set_bit(BNX2X_Q_FLG_TPA_GRO, &flags); } if (leading) { @@ -10167,10 +10169,10 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp) /* Set TPA flags */ if (bp->disable_tpa) { - bp->flags &= ~TPA_ENABLE_FLAG; + bp->flags &= ~(TPA_ENABLE_FLAG | GRO_ENABLE_FLAG); bp->dev->features &= ~NETIF_F_LRO; } else { - bp->flags |= TPA_ENABLE_FLAG; + bp->flags |= (TPA_ENABLE_FLAG | GRO_ENABLE_FLAG); bp->dev->features |= NETIF_F_LRO; } @@ -10716,8 +10718,9 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, dev->priv_flags |= IFF_UNICAST_FLT; dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | - NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_LRO | - NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_HW_VLAN_TX; + NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | + NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_GRO | + NETIF_F_RXHASH | NETIF_F_HW_VLAN_TX; dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_HIGHDMA; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index ac15f747f8da..adfae6bb430b 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -4431,9 +4431,10 @@ static void bnx2x_q_fill_init_rx_data(struct bnx2x_queue_sp_obj *o, struct client_init_rx_data *rx_data, unsigned long *flags) { - /* Rx data */ rx_data->tpa_en = test_bit(BNX2X_Q_FLG_TPA, flags) * CLIENT_INIT_RX_DATA_TPA_EN_IPV4; + rx_data->tpa_en |= test_bit(BNX2X_Q_FLG_TPA_GRO, flags) * + CLIENT_INIT_RX_DATA_TPA_MODE; rx_data->vmqueue_mode_en_flg = 0; rx_data->cache_line_alignment_log_size = diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h index 71e039b618a7..685d42e1b2fc 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h @@ -774,6 +774,7 @@ enum bnx2x_queue_cmd { enum { BNX2X_Q_FLG_TPA, BNX2X_Q_FLG_TPA_IPV6, + BNX2X_Q_FLG_TPA_GRO, BNX2X_Q_FLG_STATS, BNX2X_Q_FLG_ZERO_STATS, BNX2X_Q_FLG_ACTIVE, -- GitLab From 1101a0d87a8e336914d2f31b528748a231c375ed Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Gollapudi Date: Mon, 20 Feb 2012 09:59:09 +0000 Subject: [PATCH 0912/1846] bnx2fc: HSI dependent changes for 7.2.xx FW with Tx only section for single cached SGEs. Signed-off-by: Bhanu Prakash Gollapudi Signed-off-by: Dmitry Kravkov Signed-off-by: David S. Miller --- drivers/scsi/bnx2fc/bnx2fc_constants.h | 2 +- drivers/scsi/bnx2fc/bnx2fc_hwi.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc_constants.h b/drivers/scsi/bnx2fc/bnx2fc_constants.h index 399cda047a77..c12702bb16d6 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_constants.h +++ b/drivers/scsi/bnx2fc/bnx2fc_constants.h @@ -7,7 +7,7 @@ /* Current FCoE HSI version number composed of two fields (16 bit) */ /* Implies on a change broken previous HSI */ -#define FCOE_HSI_MAJOR_VERSION (1) +#define FCOE_HSI_MAJOR_VERSION (2) /* Implies on a change which does not broken previous HSI */ #define FCOE_HSI_MINOR_VERSION (1) diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c index 1923a25cb6a2..afd570962b8c 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c @@ -1716,15 +1716,19 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req, /* Tx only */ bd_count = bd_tbl->bd_valid; + cached_sge = &task->rxwr_only.union_ctx.read_info.sgl_ctx.cached_sge; if (task_type == FCOE_TASK_TYPE_WRITE) { if ((dev_type == TYPE_DISK) && (bd_count == 1)) { struct fcoe_bd_ctx *fcoe_bd_tbl = bd_tbl->bd_tbl; task->txwr_only.sgl_ctx.cached_sge.cur_buf_addr.lo = + cached_sge->cur_buf_addr.lo = fcoe_bd_tbl->buf_addr_lo; task->txwr_only.sgl_ctx.cached_sge.cur_buf_addr.hi = + cached_sge->cur_buf_addr.hi = fcoe_bd_tbl->buf_addr_hi; task->txwr_only.sgl_ctx.cached_sge.cur_buf_rem = + cached_sge->cur_buf_rem = fcoe_bd_tbl->buf_len; task->txwr_rxrd.const_ctx.init_flags |= 1 << @@ -1790,11 +1794,13 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req, task->rxwr_txrd.var_ctx.rx_id = 0xffff; /* Rx Only */ - cached_sge = &task->rxwr_only.union_ctx.read_info.sgl_ctx.cached_sge; + if (task_type != FCOE_TASK_TYPE_READ) + return; + sgl = &task->rxwr_only.union_ctx.read_info.sgl_ctx.sgl; bd_count = bd_tbl->bd_valid; - if (task_type == FCOE_TASK_TYPE_READ && - dev_type == TYPE_DISK) { + + if (dev_type == TYPE_DISK) { if (bd_count == 1) { struct fcoe_bd_ctx *fcoe_bd_tbl = bd_tbl->bd_tbl; -- GitLab From e65de0716f4fb72b09fb37f603b71f4eabe18322 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Mon, 20 Feb 2012 09:59:10 +0000 Subject: [PATCH 0913/1846] cnic: update for FW 7.2.xx Signed-off-by: Michael Chan Signed-off-by: Dmitry Kravkov Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/cnic_defs.h | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/broadcom/cnic_defs.h b/drivers/net/ethernet/broadcom/cnic_defs.h index 7271f14bda3b..06ca00266d70 100644 --- a/drivers/net/ethernet/broadcom/cnic_defs.h +++ b/drivers/net/ethernet/broadcom/cnic_defs.h @@ -1393,9 +1393,9 @@ struct xstorm_fcoe_extra_ag_context_section { #define __XSTORM_FCOE_EXTRA_AG_CONTEXT_SECTION_RESERVED_DA_EXPIRATION_FLAG_SHIFT 7 #endif u32 snd_nxt; - u32 tx_wnd; - u32 __reserved55; - u32 local_adv_wnd; + u32 __xfrqe_bd_addr_lo; + u32 __xfrqe_bd_addr_hi; + u32 __xfrqe_data1; #if defined(__BIG_ENDIAN) u8 __agg_val8_th; u8 __tx_dest; @@ -1481,13 +1481,13 @@ struct xstorm_fcoe_extra_ag_context_section { #endif u32 __tcp_agg_vars6; #if defined(__BIG_ENDIAN) - u16 __agg_misc6; + u16 __xfrqe_mng; u16 __tcp_agg_vars7; #elif defined(__LITTLE_ENDIAN) u16 __tcp_agg_vars7; - u16 __agg_misc6; + u16 __xfrqe_mng; #endif - u32 __agg_val10; + u32 __xfrqe_data0; u32 __agg_val10_th; #if defined(__BIG_ENDIAN) u16 __reserved3; @@ -1707,11 +1707,11 @@ struct xstorm_fcoe_ag_context { #define XSTORM_FCOE_AG_CONTEXT_AGG_MISC3 (0xFF<<24) #define XSTORM_FCOE_AG_CONTEXT_AGG_MISC3_SHIFT 24 #if defined(__BIG_ENDIAN) - u16 agg_misc0; + u16 __cache_wqe_db; u16 sq_prod; #elif defined(__LITTLE_ENDIAN) u16 sq_prod; - u16 agg_misc0; + u16 __cache_wqe_db; #endif #if defined(__BIG_ENDIAN) u8 agg_val3; @@ -3017,8 +3017,8 @@ struct fcoe_tce_tx_wr_rx_rd_const { #define FCOE_TCE_TX_WR_RX_RD_CONST_RSRV1_SHIFT 5 #define FCOE_TCE_TX_WR_RX_RD_CONST_TX_SEQ_INIT (0x1<<6) #define FCOE_TCE_TX_WR_RX_RD_CONST_TX_SEQ_INIT_SHIFT 6 -#define FCOE_TCE_TX_WR_RX_RD_CONST_RSRV2 (0x1<<7) -#define FCOE_TCE_TX_WR_RX_RD_CONST_RSRV2_SHIFT 7 +#define FCOE_TCE_TX_WR_RX_RD_CONST_TX_COMP_TRNS (0x1<<7) +#define FCOE_TCE_TX_WR_RX_RD_CONST_TX_COMP_TRNS_SHIFT 7 __le16 rsrv3; __le32 verify_tx_seq; }; @@ -4299,7 +4299,7 @@ struct xstorm_eth_context_section { #endif #if defined(__BIG_ENDIAN) u16 reserved_vlan_type; - u16 params; + u16 vlan_params; #define XSTORM_ETH_CONTEXT_SECTION_VLAN_ID (0xFFF<<0) #define XSTORM_ETH_CONTEXT_SECTION_VLAN_ID_SHIFT 0 #define XSTORM_ETH_CONTEXT_SECTION_CFI (0x1<<12) @@ -4307,7 +4307,7 @@ struct xstorm_eth_context_section { #define XSTORM_ETH_CONTEXT_SECTION_PRIORITY (0x7<<13) #define XSTORM_ETH_CONTEXT_SECTION_PRIORITY_SHIFT 13 #elif defined(__LITTLE_ENDIAN) - u16 params; + u16 vlan_params; #define XSTORM_ETH_CONTEXT_SECTION_VLAN_ID (0xFFF<<0) #define XSTORM_ETH_CONTEXT_SECTION_VLAN_ID_SHIFT 0 #define XSTORM_ETH_CONTEXT_SECTION_CFI (0x1<<12) -- GitLab From fe603b4d680a2bba9d8c6d4267450fcf295f30d1 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Mon, 20 Feb 2012 09:59:11 +0000 Subject: [PATCH 0914/1846] bnx2x: add gro_check The patch provides workaround for BUG in FW 7.2.16, which in GRO mode may miscalculate buffer and place on SGE one frag less than it could. It may happen only for some MTUs, we mark these MTUs with gro_check flag during device initialization or MTU change. Next FW should include fix for the issue and the patch could be reverted. Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 4 ++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 12 ++++++++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 7 +++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 ++ 4 files changed, 25 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 3cf9df833cb4..6ebb55d6a98f 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -341,6 +341,7 @@ union db_prod { #define SGE_PAGE_SIZE PAGE_SIZE #define SGE_PAGE_SHIFT PAGE_SHIFT #define SGE_PAGE_ALIGN(addr) PAGE_ALIGN((typeof(PAGE_SIZE))(addr)) +#define SGE_PAGES (SGE_PAGE_SIZE * PAGES_PER_SGE) /* SGE ring related macros */ #define NUM_RX_SGE_PAGES 2 @@ -1210,6 +1211,7 @@ struct bnx2x { #define ETH_MAX_JUMBO_PACKET_SIZE 9600 /* TCP with Timestamp Option (32) + IPv6 (40) */ #define ETH_MAX_TPA_HEADER_SIZE 72 +#define ETH_MIN_TPA_HEADER_SIZE 40 /* Max supported alignment is 256 (8 shift) */ #define BNX2X_RX_ALIGN_SHIFT min(8, L1_CACHE_SHIFT) @@ -1329,6 +1331,8 @@ struct bnx2x { u8 wol; + bool gro_check; + int rx_ring_size; u16 tx_quick_cons_trip_int; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 0a45251edb8f..f82dfff58243 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -330,6 +330,16 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, u16 gro_size = le16_to_cpu(cqe->pkt_len_or_gro_seg_len); tpa_info->full_page = SGE_PAGE_SIZE * PAGES_PER_SGE / gro_size * gro_size; + /* + * FW 7.2.16 BUG workaround: + * if SGE size is (exactly) multiple gro_size + * fw will place one less frag on SGE. + * the calculation is done only for potentially + * dangerous MTUs. + */ + if (unlikely(bp->gro_check)) + if (!(SGE_PAGE_SIZE * PAGES_PER_SGE % gro_size)) + tpa_info->full_page -= gro_size; tpa_info->gro_size = gro_size; } @@ -3486,6 +3496,8 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) */ dev->mtu = new_mtu; + bp->gro_check = bnx2x_need_gro_check(new_mtu); + return bnx2x_reload_if_running(dev); } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index d2093ee9b85e..33aa7de24016 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1504,6 +1504,13 @@ static inline bool bnx2x_mtu_allows_gro(int mtu) */ return mtu <= SGE_PAGE_SIZE && (U_ETH_SGL_SIZE * fpp) <= MAX_SKB_FRAGS; } + +static inline bool bnx2x_need_gro_check(int mtu) +{ + return (SGE_PAGES / (mtu - ETH_MAX_TPA_HEADER_SIZE - 1)) != + (SGE_PAGES / (mtu - ETH_MIN_TPA_HEADER_SIZE + 1)); +} + /** * bnx2x_bz_fp - zero content of the fastpath structure. * diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 816e7d42f61c..b4afef60a25b 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -10214,6 +10214,8 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp) if (CHIP_IS_E3B0(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E3B0; + bp->gro_check = bnx2x_need_gro_check(bp->dev->mtu); + return rc; } -- GitLab From 0b0a635f79f91f3755b6518627ea06dd0dbfd523 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Mon, 20 Feb 2012 09:59:12 +0000 Subject: [PATCH 0915/1846] bnx2x: update driver version to 1.72.10-0 Signed-off-by: Dmitry Kravkov Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 6ebb55d6a98f..c0cf313e6519 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -23,8 +23,8 @@ * (you will need to reboot afterwards) */ /* #define BNX2X_STOP_ON_ERROR */ -#define DRV_MODULE_VERSION "1.72.00-0" -#define DRV_MODULE_RELDATE "2012/01/26" +#define DRV_MODULE_VERSION "1.72.10-0" +#define DRV_MODULE_RELDATE "2012/02/20" #define BNX2X_BC_VER 0x040200 #if defined(CONFIG_DCB) -- GitLab From c059e05353081471908c05029585765614e07cec Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 21 Feb 2012 08:14:26 +0100 Subject: [PATCH 0916/1846] Bluetooth: Fix parameter list for setting local name The parameter list for setting the local name via management interface was missing the short name parameter. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/mgmt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 1dbadbe14785..ac59cdd0fa1b 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -135,6 +135,7 @@ struct mgmt_cp_set_dev_class { #define MGMT_OP_SET_LOCAL_NAME 0x000F struct mgmt_cp_set_local_name { __u8 name[MGMT_MAX_NAME_LENGTH]; + __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; } __packed; #define MGMT_OP_ADD_UUID 0x0010 -- GitLab From f0d4b78a68c4fe3b0d45de9a50e8d29419177b83 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 21 Feb 2012 12:14:25 +0100 Subject: [PATCH 0917/1846] Bluetooth: Only keep controller up after init if powered on When a new controller gets added to the system, it needs to be brought up briefly to read basic information like features, BD_ADDR etc. and after a timeout it will be brought back down. The only command that should overwrite this timeout is the set power command from the management interface. Just reading the controller list or information is not a good reason to keep the controller up. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a5a2a6844aea..c25cb648059e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -339,9 +339,6 @@ static int read_index_list(struct sock *sk) i = 0; list_for_each_entry(d, &hci_dev_list, list) { - if (test_and_clear_bit(HCI_AUTO_OFF, &d->dev_flags)) - cancel_delayed_work(&d->power_off); - if (test_bit(HCI_SETUP, &d->dev_flags)) continue; @@ -392,11 +389,12 @@ static u32 get_current_settings(struct hci_dev *hdev) { u32 settings = 0; - if (test_bit(HCI_UP, &hdev->flags)) - settings |= MGMT_SETTING_POWERED; - else + if (!test_bit(HCI_UP, &hdev->flags)) return settings; + if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) + settings |= MGMT_SETTING_POWERED; + if (test_bit(HCI_PSCAN, &hdev->flags)) settings |= MGMT_SETTING_CONNECTABLE; @@ -623,9 +621,6 @@ static int read_controller_info(struct sock *sk, u16 index) return cmd_status(sk, index, MGMT_OP_READ_INFO, MGMT_STATUS_INVALID_PARAMS); - if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) - cancel_delayed_work_sync(&hdev->power_off); - hci_dev_lock(hdev); if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) @@ -753,6 +748,16 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { + cancel_delayed_work(&hdev->power_off); + + if (cp->val) { + err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev); + mgmt_powered(hdev, 1); + goto failed; + } + } + up = test_bit(HCI_UP, &hdev->flags); if ((cp->val && up) || (!cp->val && !up)) { err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev); -- GitLab From 8ee5654034c85b3915d078147a9d1064cac1852e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 21 Feb 2012 12:33:48 +0100 Subject: [PATCH 0918/1846] Bluetooth: Don't send New Settings event during setup power down When the controller gets brought up for initial setup, it will be brought back down after a timeout. In that case, don't send a New Settings event. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a7439aeb1f9b..a787c9c9d4cd 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -739,9 +739,6 @@ static int hci_dev_do_close(struct hci_dev *hdev) hdev->discov_timeout = 0; } - if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) - cancel_delayed_work(&hdev->power_off); - if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) cancel_delayed_work(&hdev->service_cache); @@ -787,9 +784,11 @@ static int hci_dev_do_close(struct hci_dev *hdev) * and no tasks are scheduled. */ hdev->close(hdev); - hci_dev_lock(hdev); - mgmt_powered(hdev, 0); - hci_dev_unlock(hdev); + if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { + hci_dev_lock(hdev); + mgmt_powered(hdev, 0); + hci_dev_unlock(hdev); + } /* Clear flags */ hdev->flags = 0; @@ -808,7 +807,12 @@ int hci_dev_close(__u16 dev) hdev = hci_dev_get(dev); if (!hdev) return -ENODEV; + + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) + cancel_delayed_work(&hdev->power_off); + err = hci_dev_do_close(hdev); + hci_dev_put(hdev); return err; } @@ -1102,9 +1106,7 @@ static void hci_power_off(struct work_struct *work) BT_DBG("%s", hdev->name); - clear_bit(HCI_AUTO_OFF, &hdev->dev_flags); - - hci_dev_close(hdev->id); + hci_dev_do_close(hdev); } static void hci_discov_off(struct work_struct *work) -- GitLab From 4b34ee782164fbaf29b2e7c0e8cb3a898c0986ca Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 14:13:02 +0200 Subject: [PATCH 0919/1846] Bluetooth: mgmt: Fix powered checks for commands Having the HCI_AUTO_OFF flag set means that from a mgmt interface perspective we're still not powered, so all tests for HCI_UP should also include a test for HCI_AUTO_OFF. This patch adds a convenience macro for it. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c25cb648059e..c27481c3c95d 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -118,6 +118,9 @@ static const u16 mgmt_events[] = { #define SERVICE_CACHE_TIMEOUT (5 * 1000) +#define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \ + !test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) + struct pending_cmd { struct list_head list; u16 opcode; @@ -733,7 +736,7 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len) struct mgmt_mode *cp = data; struct hci_dev *hdev; struct pending_cmd *cmd; - int err, up; + int err; BT_DBG("request for hci%u", index); @@ -758,8 +761,7 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len) } } - up = test_bit(HCI_UP, &hdev->flags); - if ((cp->val && up) || (!cp->val && !up)) { + if (!!cp->val == hdev_is_powered(hdev)) { err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev); goto failed; } @@ -810,7 +812,7 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_NOT_POWERED); goto failed; @@ -877,7 +879,7 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, MGMT_STATUS_NOT_POWERED); goto failed; @@ -1005,7 +1007,7 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, MGMT_STATUS_NOT_POWERED); goto failed; @@ -1064,7 +1066,7 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_NOT_POWERED); goto failed; @@ -1621,7 +1623,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_NOT_POWERED); goto failed; @@ -1690,7 +1692,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, MGMT_STATUS_NOT_POWERED); goto failed; @@ -1933,7 +1935,7 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, mgmt_op, MGMT_STATUS_NOT_POWERED); goto done; } @@ -2109,7 +2111,7 @@ static int read_local_oob_data(struct sock *sk, u16 index) hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, MGMT_STATUS_NOT_POWERED); goto unlock; @@ -2280,7 +2282,7 @@ static int start_discovery(struct sock *sk, u16 index, hci_dev_lock(hdev); - if (!test_bit(HCI_UP, &hdev->flags)) { + if (!hdev_is_powered(hdev)) { err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, MGMT_STATUS_NOT_POWERED); goto failed; -- GitLab From b5235a65ad19f47c5995f054d3dcce90570d1a1c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 14:32:24 +0200 Subject: [PATCH 0920/1846] Bluetooth: mgmt: Fix set_local_name and set_dev_class powered checks Both the Set Local Name and the Set Device Class commands should fail if the adapter is not powered on. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c27481c3c95d..03a13843cd16 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1272,6 +1272,12 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, + MGMT_STATUS_NOT_POWERED); + goto unlock; + } + hdev->major_class = cp->major; hdev->minor_class = cp->minor; @@ -1288,6 +1294,7 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, NULL, 0); +unlock: hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2076,6 +2083,12 @@ static int set_local_name(struct sock *sk, u16 index, void *data, hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, + MGMT_STATUS_NOT_POWERED); + goto failed; + } + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, len); if (!cmd) { -- GitLab From 5400c044f3fac38f521362d76711e4c170f78b89 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 16:40:33 +0200 Subject: [PATCH 0921/1846] Bluetooth: mgmt: Fix set_fast_connectable error return This patch ensures that Set Fast Connectable fails apropriately if we are not already in a connectable state (which is a pre-requisite for fast connectable). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 03a13843cd16..563190c9f7b0 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2560,6 +2560,13 @@ static int set_fast_connectable(struct sock *sk, u16 index, if (!hdev) return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, MGMT_STATUS_INVALID_PARAMS); + if (!hdev_is_powered(hdev)) + return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, + MGMT_STATUS_NOT_POWERED); + + if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) + return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, + MGMT_STATUS_REJECTED); hci_dev_lock(hdev); -- GitLab From 0cbf4ed6e6f43ac399afefdd14a1ee86db8de7d0 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 17:25:22 +0200 Subject: [PATCH 0922/1846] Bluetooth: mgmt: Fix pairable setting upon initialization When mgmt is not in use the HCI_PAIRABLE flag will get implicitly set so that pairing still works with old user space versions. However, as soon as mgmt comes into play we should clear this flag so that it can be properly set through the set_pairable command by user space. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 563190c9f7b0..0f87030f9c30 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -604,9 +604,17 @@ static void service_cache_off(struct work_struct *work) static void mgmt_init_hdev(struct hci_dev *hdev) { - if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) + if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) { INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); + /* Non-mgmt controlled devices get this bit set + * implicitly so that pairing works for them, however + * for mgmt we require user-space to explicitly enable + * it + */ + clear_bit(HCI_PAIRABLE, &hdev->dev_flags); + } + if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) schedule_delayed_work(&hdev->service_cache, msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); -- GitLab From 475be4d85a274d0961593db41cf85689db1d583c Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 19 Feb 2012 19:52:38 -0800 Subject: [PATCH 0923/1846] isdn: whitespace coding style cleanup isdn source code uses a not-current coding style. Update the coding style used on a per-line basis so that git diff -w shows only elided blank lines at EOF. Done with emacs and some scripts and some typing. Built x86 allyesconfig. No detected change in objdump -d or size. Signed-off-by: Joe Perches --- drivers/isdn/act2000/act2000.h | 28 +- drivers/isdn/act2000/act2000_isa.c | 394 +- drivers/isdn/act2000/act2000_isa.h | 32 +- drivers/isdn/act2000/capi.c | 998 +- drivers/isdn/act2000/capi.h | 50 +- drivers/isdn/act2000/module.c | 806 +- drivers/isdn/capi/capi.c | 178 +- drivers/isdn/capi/capidrv.c | 956 +- drivers/isdn/capi/capidrv.h | 42 +- drivers/isdn/capi/capilib.c | 16 +- drivers/isdn/capi/capiutil.c | 628 +- drivers/isdn/capi/kcapi.c | 116 +- drivers/isdn/capi/kcapi.h | 11 +- drivers/isdn/capi/kcapi_proc.c | 14 +- drivers/isdn/divert/divert_init.c | 75 +- drivers/isdn/divert/divert_procfs.c | 152 +- drivers/isdn/divert/isdn_divert.c | 1475 +- drivers/isdn/divert/isdn_divert.h | 116 +- drivers/isdn/gigaset/asyncdata.c | 4 +- drivers/isdn/gigaset/bas-gigaset.c | 42 +- drivers/isdn/gigaset/capi.c | 228 +- drivers/isdn/gigaset/common.c | 14 +- drivers/isdn/gigaset/ev-layer.c | 328 +- drivers/isdn/gigaset/gigaset.h | 30 +- drivers/isdn/gigaset/i4l.c | 8 +- drivers/isdn/gigaset/interface.c | 20 +- drivers/isdn/gigaset/isocdata.c | 192 +- drivers/isdn/gigaset/proc.c | 4 +- drivers/isdn/gigaset/ser-gigaset.c | 6 +- drivers/isdn/gigaset/usb-gigaset.c | 8 +- drivers/isdn/hardware/avm/avm_cs.c | 134 +- drivers/isdn/hardware/avm/avmcard.h | 286 +- drivers/isdn/hardware/avm/b1.c | 192 +- drivers/isdn/hardware/avm/b1dma.c | 178 +- drivers/isdn/hardware/avm/b1isa.c | 18 +- drivers/isdn/hardware/avm/b1pci.c | 44 +- drivers/isdn/hardware/avm/b1pcmcia.c | 28 +- drivers/isdn/hardware/avm/c4.c | 348 +- drivers/isdn/hardware/avm/t1isa.c | 100 +- drivers/isdn/hardware/avm/t1pci.c | 32 +- drivers/isdn/hardware/eicon/capi20.h | 514 +- drivers/isdn/hardware/eicon/capidtmf.c | 1094 +- drivers/isdn/hardware/eicon/capidtmf.h | 78 +- drivers/isdn/hardware/eicon/capifunc.c | 222 +- drivers/isdn/hardware/eicon/capifunc.h | 4 +- drivers/isdn/hardware/eicon/capimain.c | 10 +- drivers/isdn/hardware/eicon/cardtype.h | 1476 +- drivers/isdn/hardware/eicon/cp_vers.h | 32 +- drivers/isdn/hardware/eicon/dadapter.c | 576 +- drivers/isdn/hardware/eicon/dadapter.h | 36 +- drivers/isdn/hardware/eicon/debug.c | 3519 ++- drivers/isdn/hardware/eicon/debug_if.h | 82 +- drivers/isdn/hardware/eicon/debuglib.c | 176 +- drivers/isdn/hardware/eicon/debuglib.h | 272 +- drivers/isdn/hardware/eicon/dfifo.h | 56 +- drivers/isdn/hardware/eicon/di.c | 1430 +- drivers/isdn/hardware/eicon/di.h | 156 +- drivers/isdn/hardware/eicon/di_dbg.h | 34 +- drivers/isdn/hardware/eicon/di_defs.h | 144 +- drivers/isdn/hardware/eicon/did_vers.h | 32 +- drivers/isdn/hardware/eicon/diddfunc.c | 22 +- drivers/isdn/hardware/eicon/diva.c | 160 +- drivers/isdn/hardware/eicon/diva_didd.c | 16 +- drivers/isdn/hardware/eicon/diva_dma.c | 116 +- drivers/isdn/hardware/eicon/diva_dma.h | 62 +- drivers/isdn/hardware/eicon/diva_pci.h | 6 +- drivers/isdn/hardware/eicon/divacapi.h | 630 +- drivers/isdn/hardware/eicon/divamnt.c | 15 +- drivers/isdn/hardware/eicon/divasfunc.c | 34 +- drivers/isdn/hardware/eicon/divasi.c | 56 +- drivers/isdn/hardware/eicon/divasmain.c | 118 +- drivers/isdn/hardware/eicon/divasproc.c | 58 +- drivers/isdn/hardware/eicon/divasync.h | 562 +- drivers/isdn/hardware/eicon/dqueue.c | 14 +- drivers/isdn/hardware/eicon/dqueue.h | 14 +- drivers/isdn/hardware/eicon/dsp_defs.h | 256 +- drivers/isdn/hardware/eicon/dsp_tst.h | 8 +- drivers/isdn/hardware/eicon/dspdids.h | 30 +- drivers/isdn/hardware/eicon/dsrv4bri.h | 34 +- drivers/isdn/hardware/eicon/dsrv_bri.h | 44 +- drivers/isdn/hardware/eicon/dsrv_pri.h | 46 +- drivers/isdn/hardware/eicon/entity.h | 14 +- drivers/isdn/hardware/eicon/helpers.h | 68 +- drivers/isdn/hardware/eicon/idifunc.c | 22 +- drivers/isdn/hardware/eicon/io.c | 1414 +- drivers/isdn/hardware/eicon/io.h | 514 +- drivers/isdn/hardware/eicon/istream.c | 352 +- drivers/isdn/hardware/eicon/kst_ifc.h | 227 +- drivers/isdn/hardware/eicon/maintidi.c | 2277 +- drivers/isdn/hardware/eicon/maintidi.h | 105 +- drivers/isdn/hardware/eicon/man_defs.h | 36 +- drivers/isdn/hardware/eicon/mdm_msg.h | 72 +- drivers/isdn/hardware/eicon/message.c | 28300 +++++++++--------- drivers/isdn/hardware/eicon/mi_pc.h | 86 +- drivers/isdn/hardware/eicon/mntfunc.c | 186 +- drivers/isdn/hardware/eicon/os_4bri.c | 352 +- drivers/isdn/hardware/eicon/os_4bri.h | 2 +- drivers/isdn/hardware/eicon/os_bri.c | 262 +- drivers/isdn/hardware/eicon/os_bri.h | 2 +- drivers/isdn/hardware/eicon/os_capi.h | 10 +- drivers/isdn/hardware/eicon/os_pri.c | 390 +- drivers/isdn/hardware/eicon/os_pri.h | 2 +- drivers/isdn/hardware/eicon/pc.h | 268 +- drivers/isdn/hardware/eicon/pc_init.h | 48 +- drivers/isdn/hardware/eicon/pc_maint.h | 158 +- drivers/isdn/hardware/eicon/pkmaint.h | 43 +- drivers/isdn/hardware/eicon/platform.h | 156 +- drivers/isdn/hardware/eicon/pr_pc.h | 116 +- drivers/isdn/hardware/eicon/s_4bri.c | 488 +- drivers/isdn/hardware/eicon/s_bri.c | 288 +- drivers/isdn/hardware/eicon/s_pri.c | 314 +- drivers/isdn/hardware/eicon/sdp_hdr.h | 130 +- drivers/isdn/hardware/eicon/um_idi.c | 224 +- drivers/isdn/hardware/eicon/um_idi.h | 2 +- drivers/isdn/hardware/eicon/xdi_adapter.h | 12 +- drivers/isdn/hardware/eicon/xdi_msg.h | 2 +- drivers/isdn/hardware/eicon/xdi_vers.h | 32 +- drivers/isdn/hardware/mISDN/avmfritz.c | 68 +- drivers/isdn/hardware/mISDN/hfc_multi.h | 47 +- drivers/isdn/hardware/mISDN/hfc_multi_8xx.h | 28 +- drivers/isdn/hardware/mISDN/hfc_pci.h | 18 +- drivers/isdn/hardware/mISDN/hfcmulti.c | 1364 +- drivers/isdn/hardware/mISDN/hfcpci.c | 356 +- drivers/isdn/hardware/mISDN/hfcsusb.c | 412 +- drivers/isdn/hardware/mISDN/hfcsusb.h | 120 +- drivers/isdn/hardware/mISDN/iohelper.h | 136 +- drivers/isdn/hardware/mISDN/isar.h | 2 +- drivers/isdn/hardware/mISDN/mISDNinfineon.c | 36 +- drivers/isdn/hardware/mISDN/mISDNipac.c | 112 +- drivers/isdn/hardware/mISDN/mISDNisar.c | 208 +- drivers/isdn/hardware/mISDN/netjet.c | 98 +- drivers/isdn/hardware/mISDN/netjet.h | 1 - drivers/isdn/hardware/mISDN/speedfax.c | 22 +- drivers/isdn/hardware/mISDN/w6692.c | 86 +- drivers/isdn/hisax/amd7930_fn.c | 786 +- drivers/isdn/hisax/arcofi.c | 88 +- drivers/isdn/hisax/arcofi.h | 2 +- drivers/isdn/hisax/asuscom.c | 110 +- drivers/isdn/hisax/avm_a1.c | 42 +- drivers/isdn/hisax/avm_a1p.c | 152 +- drivers/isdn/hisax/avm_pci.c | 324 +- drivers/isdn/hisax/avma1_cs.c | 124 +- drivers/isdn/hisax/bkm_a4t.c | 92 +- drivers/isdn/hisax/bkm_a8.c | 184 +- drivers/isdn/hisax/bkm_ax.h | 78 +- drivers/isdn/hisax/callc.c | 1074 +- drivers/isdn/hisax/config.c | 126 +- drivers/isdn/hisax/diva.c | 334 +- drivers/isdn/hisax/elsa.c | 500 +- drivers/isdn/hisax/elsa_cs.c | 164 +- drivers/isdn/hisax/elsa_ser.c | 178 +- drivers/isdn/hisax/enternow_pci.c | 200 +- drivers/isdn/hisax/fsm.c | 38 +- drivers/isdn/hisax/fsm.h | 4 +- drivers/isdn/hisax/gazel.c | 518 +- drivers/isdn/hisax/hfc4s8s_l1.c | 648 +- drivers/isdn/hisax/hfc4s8s_l1.h | 8 +- drivers/isdn/hisax/hfc_2bds0.c | 484 +- drivers/isdn/hisax/hfc_2bds0.h | 28 +- drivers/isdn/hisax/hfc_2bs0.c | 284 +- drivers/isdn/hisax/hfc_2bs0.h | 6 +- drivers/isdn/hisax/hfc_pci.c | 714 +- drivers/isdn/hisax/hfc_pci.h | 96 +- drivers/isdn/hisax/hfc_sx.c | 1126 +- drivers/isdn/hisax/hfc_sx.h | 30 +- drivers/isdn/hisax/hfc_usb.c | 586 +- drivers/isdn/hisax/hfc_usb.h | 10 +- drivers/isdn/hisax/hfcscard.c | 96 +- drivers/isdn/hisax/hisax.h | 172 +- drivers/isdn/hisax/hisax_cfg.h | 6 +- drivers/isdn/hisax/hisax_debug.h | 42 +- drivers/isdn/hisax/hisax_fcpcipnp.c | 92 +- drivers/isdn/hisax/hisax_fcpcipnp.h | 3 +- drivers/isdn/hisax/hisax_if.h | 4 +- drivers/isdn/hisax/hisax_isac.c | 44 +- drivers/isdn/hisax/hscx.c | 136 +- drivers/isdn/hisax/hscx.h | 2 +- drivers/isdn/hisax/hscx_irq.c | 18 +- drivers/isdn/hisax/icc.c | 314 +- drivers/isdn/hisax/icc.h | 6 +- drivers/isdn/hisax/ipac.h | 2 +- drivers/isdn/hisax/ipacx.c | 675 +- drivers/isdn/hisax/isac.c | 320 +- drivers/isdn/hisax/isac.h | 2 +- drivers/isdn/hisax/isar.c | 1796 +- drivers/isdn/hisax/isar.h | 14 +- drivers/isdn/hisax/isdnl1.c | 262 +- drivers/isdn/hisax/isdnl2.c | 342 +- drivers/isdn/hisax/isdnl2.h | 1 - drivers/isdn/hisax/isdnl3.c | 174 +- drivers/isdn/hisax/isdnl3.h | 3 +- drivers/isdn/hisax/isurf.c | 118 +- drivers/isdn/hisax/ix1_micro.c | 100 +- drivers/isdn/hisax/jade.c | 209 +- drivers/isdn/hisax/jade.h | 156 +- drivers/isdn/hisax/jade_irq.c | 48 +- drivers/isdn/hisax/l3_1tr6.c | 196 +- drivers/isdn/hisax/l3dss1.c | 1900 +- drivers/isdn/hisax/l3dss1.h | 20 +- drivers/isdn/hisax/l3ni1.c | 1838 +- drivers/isdn/hisax/l3ni1.h | 28 +- drivers/isdn/hisax/lmgr.c | 28 +- drivers/isdn/hisax/mic.c | 64 +- drivers/isdn/hisax/netjet.c | 623 +- drivers/isdn/hisax/netjet.h | 5 +- drivers/isdn/hisax/niccy.c | 78 +- drivers/isdn/hisax/nj_s.c | 112 +- drivers/isdn/hisax/nj_u.c | 100 +- drivers/isdn/hisax/q931.c | 240 +- drivers/isdn/hisax/s0box.c | 132 +- drivers/isdn/hisax/saphir.c | 122 +- drivers/isdn/hisax/sedlbauer.c | 328 +- drivers/isdn/hisax/sedlbauer_cs.c | 176 +- drivers/isdn/hisax/sportster.c | 126 +- drivers/isdn/hisax/st5481.h | 98 +- drivers/isdn/hisax/st5481_b.c | 124 +- drivers/isdn/hisax/st5481_d.c | 194 +- drivers/isdn/hisax/st5481_init.c | 64 +- drivers/isdn/hisax/st5481_usb.c | 269 +- drivers/isdn/hisax/tei.c | 76 +- drivers/isdn/hisax/teleint.c | 126 +- drivers/isdn/hisax/teles0.c | 126 +- drivers/isdn/hisax/teles3.c | 156 +- drivers/isdn/hisax/teles_cs.c | 134 +- drivers/isdn/hisax/telespci.c | 80 +- drivers/isdn/hisax/w6692.c | 412 +- drivers/isdn/hisax/w6692.h | 10 +- drivers/isdn/hysdn/boardergo.c | 28 +- drivers/isdn/hysdn/boardergo.h | 30 +- drivers/isdn/hysdn/hycapi.c | 374 +- drivers/isdn/hysdn/hysdn_boot.c | 302 +- drivers/isdn/hysdn/hysdn_defs.h | 30 +- drivers/isdn/hysdn/hysdn_init.c | 4 +- drivers/isdn/hysdn/hysdn_net.c | 20 +- drivers/isdn/hysdn/hysdn_pof.h | 26 +- drivers/isdn/hysdn/hysdn_procconf.c | 10 +- drivers/isdn/hysdn/hysdn_proclog.c | 26 +- drivers/isdn/hysdn/hysdn_sched.c | 54 +- drivers/isdn/hysdn/ince1pc.h | 72 +- drivers/isdn/i4l/isdn_audio.c | 126 +- drivers/isdn/i4l/isdn_bsdcomp.c | 374 +- drivers/isdn/i4l/isdn_common.c | 1502 +- drivers/isdn/i4l/isdn_common.h | 18 +- drivers/isdn/i4l/isdn_concap.c | 36 +- drivers/isdn/i4l/isdn_concap.h | 4 +- drivers/isdn/i4l/isdn_net.c | 1498 +- drivers/isdn/i4l/isdn_net.h | 11 +- drivers/isdn/i4l/isdn_ppp.c | 1442 +- drivers/isdn/i4l/isdn_ppp.h | 2 - drivers/isdn/i4l/isdn_tty.c | 2442 +- drivers/isdn/i4l/isdn_tty.h | 10 +- drivers/isdn/i4l/isdn_ttyfax.c | 1092 +- drivers/isdn/i4l/isdn_ttyfax.h | 1 - drivers/isdn/i4l/isdn_v110.c | 294 +- drivers/isdn/i4l/isdn_v110.h | 8 +- drivers/isdn/i4l/isdn_x25iface.c | 226 +- drivers/isdn/i4l/isdn_x25iface.h | 16 +- drivers/isdn/i4l/isdnhdlc.c | 54 +- drivers/isdn/icn/icn.c | 806 +- drivers/isdn/icn/icn.h | 32 +- drivers/isdn/isdnloop/isdnloop.c | 958 +- drivers/isdn/isdnloop/isdnloop.h | 6 +- drivers/isdn/mISDN/clock.c | 25 +- drivers/isdn/mISDN/core.c | 37 +- drivers/isdn/mISDN/core.h | 8 +- drivers/isdn/mISDN/dsp.h | 25 +- drivers/isdn/mISDN/dsp_audio.c | 5 +- drivers/isdn/mISDN/dsp_biquad.h | 6 +- drivers/isdn/mISDN/dsp_blowfish.c | 112 +- drivers/isdn/mISDN/dsp_cmx.c | 1040 +- drivers/isdn/mISDN/dsp_core.c | 181 +- drivers/isdn/mISDN/dsp_dtmf.c | 66 +- drivers/isdn/mISDN/dsp_ecdis.h | 26 +- drivers/isdn/mISDN/dsp_hwec.c | 11 +- drivers/isdn/mISDN/dsp_hwec.h | 1 - drivers/isdn/mISDN/dsp_pipeline.c | 56 +- drivers/isdn/mISDN/dsp_tones.c | 165 +- drivers/isdn/mISDN/fsm.c | 42 +- drivers/isdn/mISDN/hwchannel.c | 22 +- drivers/isdn/mISDN/l1oip.h | 21 +- drivers/isdn/mISDN/l1oip_codec.c | 36 +- drivers/isdn/mISDN/l1oip_core.c | 581 +- drivers/isdn/mISDN/layer1.c | 16 +- drivers/isdn/mISDN/layer1.h | 1 - drivers/isdn/mISDN/layer2.c | 97 +- drivers/isdn/mISDN/layer2.h | 12 +- drivers/isdn/mISDN/socket.c | 89 +- drivers/isdn/mISDN/stack.c | 124 +- drivers/isdn/mISDN/tei.c | 114 +- drivers/isdn/mISDN/timerdev.c | 12 +- drivers/isdn/pcbit/callbacks.c | 303 +- drivers/isdn/pcbit/callbacks.h | 28 +- drivers/isdn/pcbit/capi.c | 585 +- drivers/isdn/pcbit/capi.h | 46 +- drivers/isdn/pcbit/drv.c | 248 +- drivers/isdn/pcbit/edss1.c | 414 +- drivers/isdn/pcbit/edss1.h | 13 +- drivers/isdn/pcbit/layer2.c | 36 +- drivers/isdn/pcbit/layer2.h | 265 +- drivers/isdn/pcbit/module.c | 35 +- drivers/isdn/pcbit/pcbit.h | 32 +- drivers/isdn/sc/card.h | 2 +- drivers/isdn/sc/command.c | 132 +- drivers/isdn/sc/event.c | 24 +- drivers/isdn/sc/hardware.h | 2 +- drivers/isdn/sc/init.c | 122 +- drivers/isdn/sc/interrupt.c | 144 +- drivers/isdn/sc/ioctl.c | 220 +- drivers/isdn/sc/message.c | 126 +- drivers/isdn/sc/message.h | 18 +- drivers/isdn/sc/packet.c | 129 +- drivers/isdn/sc/scioc.h | 5 +- drivers/isdn/sc/shmem.c | 52 +- drivers/isdn/sc/timer.c | 25 +- 314 files changed, 50359 insertions(+), 50455 deletions(-) diff --git a/drivers/isdn/act2000/act2000.h b/drivers/isdn/act2000/act2000.h index 88c9423500d8..321d437f579e 100644 --- a/drivers/isdn/act2000/act2000.h +++ b/drivers/isdn/act2000/act2000.h @@ -4,7 +4,7 @@ * * Author Fritz Elfert * Copyright by Fritz Elfert - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -40,21 +40,21 @@ /* Struct for adding new cards */ typedef struct act2000_cdef { int bus; - int port; - int irq; - char id[10]; + int port; + int irq; + char id[10]; } act2000_cdef; /* Struct for downloading firmware */ typedef struct act2000_ddef { - int length; /* Length of code */ - char __user *buffer; /* Ptr. to code */ + int length; /* Length of code */ + char __user *buffer; /* Ptr. to code */ } act2000_ddef; typedef struct act2000_fwid { - char isdn[4]; - char revlen[2]; - char revision[504]; + char isdn[4]; + char revlen[2]; + char revision[504]; } act2000_fwid; #if defined(__KERNEL__) || defined(__DEBUGVAR__) @@ -128,8 +128,8 @@ typedef struct act2000_chan { typedef struct msn_entry { char eaz; - char msn[16]; - struct msn_entry * next; + char msn[16]; + struct msn_entry *next; } msn_entry; typedef struct irq_data_isa { @@ -183,17 +183,17 @@ typedef struct act2000_card { static inline void act2000_schedule_tx(act2000_card *card) { - schedule_work(&card->snd_tq); + schedule_work(&card->snd_tq); } static inline void act2000_schedule_rx(act2000_card *card) { - schedule_work(&card->rcv_tq); + schedule_work(&card->rcv_tq); } static inline void act2000_schedule_poll(act2000_card *card) { - schedule_work(&card->poll_tq); + schedule_work(&card->poll_tq); } extern char *act2000_find_eaz(act2000_card *, char); diff --git a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c index fea5b783335d..b5fad29a9ba6 100644 --- a/drivers/isdn/act2000/act2000_isa.c +++ b/drivers/isdn/act2000/act2000_isa.c @@ -4,7 +4,7 @@ * * Author Fritz Elfert * Copyright by Fritz Elfert - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -25,99 +25,99 @@ static int act2000_isa_reset(unsigned short portbase) { - unsigned char reg; - int i; - int found; - int serial = 0; - - found = 0; - if ((reg = inb(portbase + ISA_COR)) != 0xff) { - outb(reg | ISA_COR_RESET, portbase + ISA_COR); - mdelay(10); - outb(reg, portbase + ISA_COR); - mdelay(10); - - for (i = 0; i < 16; i++) { - if (inb(portbase + ISA_ISR) & ISA_ISR_SERIAL) - serial |= 0x10000; - serial >>= 1; - } - if (serial == ISA_SER_ID) - found++; - } - return found; + unsigned char reg; + int i; + int found; + int serial = 0; + + found = 0; + if ((reg = inb(portbase + ISA_COR)) != 0xff) { + outb(reg | ISA_COR_RESET, portbase + ISA_COR); + mdelay(10); + outb(reg, portbase + ISA_COR); + mdelay(10); + + for (i = 0; i < 16; i++) { + if (inb(portbase + ISA_ISR) & ISA_ISR_SERIAL) + serial |= 0x10000; + serial >>= 1; + } + if (serial == ISA_SER_ID) + found++; + } + return found; } int act2000_isa_detect(unsigned short portbase) { - int ret = 0; + int ret = 0; if (request_region(portbase, ACT2000_PORTLEN, "act2000isa")) { - ret = act2000_isa_reset(portbase); + ret = act2000_isa_reset(portbase); release_region(portbase, ISA_REGION); } - return ret; + return ret; } static irqreturn_t act2000_isa_interrupt(int dummy, void *dev_id) { - act2000_card *card = dev_id; - u_char istatus; + act2000_card *card = dev_id; + u_char istatus; - istatus = (inb(ISA_PORT_ISR) & 0x07); - if (istatus & ISA_ISR_OUT) { - /* RX fifo has data */ + istatus = (inb(ISA_PORT_ISR) & 0x07); + if (istatus & ISA_ISR_OUT) { + /* RX fifo has data */ istatus &= ISA_ISR_OUT_MASK; outb(0, ISA_PORT_SIS); act2000_isa_receive(card); outb(ISA_SIS_INT, ISA_PORT_SIS); - } - if (istatus & ISA_ISR_ERR) { - /* Error Interrupt */ + } + if (istatus & ISA_ISR_ERR) { + /* Error Interrupt */ istatus &= ISA_ISR_ERR_MASK; - printk(KERN_WARNING "act2000: errIRQ\n"); - } + printk(KERN_WARNING "act2000: errIRQ\n"); + } if (istatus) printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", card->irq, istatus); return IRQ_HANDLED; } static void -act2000_isa_select_irq(act2000_card * card) +act2000_isa_select_irq(act2000_card *card) { unsigned char reg; reg = (inb(ISA_PORT_COR) & ~ISA_COR_IRQOFF) | ISA_COR_PERR; switch (card->irq) { - case 3: - reg = ISA_COR_IRQ03; - break; - case 5: - reg = ISA_COR_IRQ05; - break; - case 7: - reg = ISA_COR_IRQ07; - break; - case 10: - reg = ISA_COR_IRQ10; - break; - case 11: - reg = ISA_COR_IRQ11; - break; - case 12: - reg = ISA_COR_IRQ12; - break; - case 15: - reg = ISA_COR_IRQ15; - break; + case 3: + reg = ISA_COR_IRQ03; + break; + case 5: + reg = ISA_COR_IRQ05; + break; + case 7: + reg = ISA_COR_IRQ07; + break; + case 10: + reg = ISA_COR_IRQ10; + break; + case 11: + reg = ISA_COR_IRQ11; + break; + case 12: + reg = ISA_COR_IRQ12; + break; + case 15: + reg = ISA_COR_IRQ15; + break; } outb(reg, ISA_PORT_COR); } static void -act2000_isa_enable_irq(act2000_card * card) +act2000_isa_enable_irq(act2000_card *card) { act2000_isa_select_irq(card); /* Enable READ irq */ @@ -129,102 +129,102 @@ act2000_isa_enable_irq(act2000_card * card) * If irq is -1, choose next free irq, else irq is given explicitly. */ int -act2000_isa_config_irq(act2000_card * card, short irq) +act2000_isa_config_irq(act2000_card *card, short irq) { int old_irq; - if (card->flags & ACT2000_FLAGS_IVALID) { - free_irq(card->irq, card); - } - card->flags &= ~ACT2000_FLAGS_IVALID; - outb(ISA_COR_IRQOFF, ISA_PORT_COR); - if (!irq) - return 0; + if (card->flags & ACT2000_FLAGS_IVALID) { + free_irq(card->irq, card); + } + card->flags &= ~ACT2000_FLAGS_IVALID; + outb(ISA_COR_IRQOFF, ISA_PORT_COR); + if (!irq) + return 0; old_irq = card->irq; card->irq = irq; if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { card->irq = old_irq; card->flags |= ACT2000_FLAGS_IVALID; - printk(KERN_WARNING - "act2000: Could not request irq %d\n",irq); - return -EBUSY; - } else { + printk(KERN_WARNING + "act2000: Could not request irq %d\n", irq); + return -EBUSY; + } else { act2000_isa_select_irq(card); - /* Disable READ and WRITE irq */ - outb(0, ISA_PORT_SIS); - outb(0, ISA_PORT_SOS); - } - return 0; + /* Disable READ and WRITE irq */ + outb(0, ISA_PORT_SIS); + outb(0, ISA_PORT_SOS); + } + return 0; } int -act2000_isa_config_port(act2000_card * card, unsigned short portbase) +act2000_isa_config_port(act2000_card *card, unsigned short portbase) { - if (card->flags & ACT2000_FLAGS_PVALID) { - release_region(card->port, ISA_REGION); - card->flags &= ~ACT2000_FLAGS_PVALID; - } + if (card->flags & ACT2000_FLAGS_PVALID) { + release_region(card->port, ISA_REGION); + card->flags &= ~ACT2000_FLAGS_PVALID; + } if (request_region(portbase, ACT2000_PORTLEN, card->regname) == NULL) return -EBUSY; else { - card->port = portbase; - card->flags |= ACT2000_FLAGS_PVALID; - return 0; - } + card->port = portbase; + card->flags |= ACT2000_FLAGS_PVALID; + return 0; + } } /* * Release ressources, used by an adaptor. */ void -act2000_isa_release(act2000_card * card) +act2000_isa_release(act2000_card *card) { - unsigned long flags; + unsigned long flags; - spin_lock_irqsave(&card->lock, flags); - if (card->flags & ACT2000_FLAGS_IVALID) - free_irq(card->irq, card); + spin_lock_irqsave(&card->lock, flags); + if (card->flags & ACT2000_FLAGS_IVALID) + free_irq(card->irq, card); - card->flags &= ~ACT2000_FLAGS_IVALID; - if (card->flags & ACT2000_FLAGS_PVALID) - release_region(card->port, ISA_REGION); - card->flags &= ~ACT2000_FLAGS_PVALID; - spin_unlock_irqrestore(&card->lock, flags); + card->flags &= ~ACT2000_FLAGS_IVALID; + if (card->flags & ACT2000_FLAGS_PVALID) + release_region(card->port, ISA_REGION); + card->flags &= ~ACT2000_FLAGS_PVALID; + spin_unlock_irqrestore(&card->lock, flags); } static int -act2000_isa_writeb(act2000_card * card, u_char data) +act2000_isa_writeb(act2000_card *card, u_char data) { - u_char timeout = 40; - - while (timeout) { - if (inb(ISA_PORT_SOS) & ISA_SOS_READY) { - outb(data, ISA_PORT_SDO); - return 0; - } else { - timeout--; - udelay(10); - } - } - return 1; + u_char timeout = 40; + + while (timeout) { + if (inb(ISA_PORT_SOS) & ISA_SOS_READY) { + outb(data, ISA_PORT_SDO); + return 0; + } else { + timeout--; + udelay(10); + } + } + return 1; } static int -act2000_isa_readb(act2000_card * card, u_char * data) +act2000_isa_readb(act2000_card *card, u_char *data) { - u_char timeout = 40; - - while (timeout) { - if (inb(ISA_PORT_SIS) & ISA_SIS_READY) { - *data = inb(ISA_PORT_SDI); - return 0; - } else { - timeout--; - udelay(10); - } - } - return 1; + u_char timeout = 40; + + while (timeout) { + if (inb(ISA_PORT_SIS) & ISA_SIS_READY) { + *data = inb(ISA_PORT_SDI); + return 0; + } else { + timeout--; + udelay(10); + } + } + return 1; } void @@ -232,11 +232,11 @@ act2000_isa_receive(act2000_card *card) { u_char c; - if (test_and_set_bit(ACT2000_LOCK_RX, (void *) &card->ilock) != 0) + if (test_and_set_bit(ACT2000_LOCK_RX, (void *) &card->ilock) != 0) return; while (!act2000_isa_readb(card, &c)) { if (card->idat.isa.rcvidx < 8) { - card->idat.isa.rcvhdr[card->idat.isa.rcvidx++] = c; + card->idat.isa.rcvhdr[card->idat.isa.rcvidx++] = c; if (card->idat.isa.rcvidx == 8) { int valid = actcapi_chkhdr(card, (actcapi_msghdr *)&card->idat.isa.rcvhdr); @@ -291,14 +291,14 @@ act2000_isa_receive(act2000_card *card) } void -act2000_isa_send(act2000_card * card) +act2000_isa_send(act2000_card *card) { unsigned long flags; struct sk_buff *skb; actcapi_msg *msg; int l; - if (test_and_set_bit(ACT2000_LOCK_TX, (void *) &card->ilock) != 0) + if (test_and_set_bit(ACT2000_LOCK_TX, (void *) &card->ilock) != 0) return; while (1) { spin_lock_irqsave(&card->lock, flags); @@ -307,7 +307,7 @@ act2000_isa_send(act2000_card * card) card->ack_msg = card->sbuf->data; msg = (actcapi_msg *)card->sbuf->data; if ((msg->hdr.cmd.cmd == 0x86) && - (msg->hdr.cmd.subcmd == 0) ) { + (msg->hdr.cmd.subcmd == 0)) { /* Save flags in message */ card->need_b3ack = msg->msg.data_b3_req.flags; msg->msg.data_b3_req.flags = 0; @@ -335,7 +335,7 @@ act2000_isa_send(act2000_card * card) } msg = (actcapi_msg *)card->ack_msg; if ((msg->hdr.cmd.cmd == 0x86) && - (msg->hdr.cmd.subcmd == 0) ) { + (msg->hdr.cmd.subcmd == 0)) { /* * If it's user data, reset data-ptr * and put skb into ackq. @@ -354,90 +354,90 @@ act2000_isa_send(act2000_card * card) * Get firmware ID, check for 'ISDN' signature. */ static int -act2000_isa_getid(act2000_card * card) +act2000_isa_getid(act2000_card *card) { - act2000_fwid fid; - u_char *p = (u_char *) & fid; - int count = 0; - - while (1) { - if (count > 510) - return -EPROTO; - if (act2000_isa_readb(card, p++)) - break; - count++; - } - if (count <= 20) { - printk(KERN_WARNING "act2000: No Firmware-ID!\n"); - return -ETIME; - } - *p = '\0'; - fid.revlen[0] = '\0'; - if (strcmp(fid.isdn, "ISDN")) { - printk(KERN_WARNING "act2000: Wrong Firmware-ID!\n"); - return -EPROTO; - } + act2000_fwid fid; + u_char *p = (u_char *)&fid; + int count = 0; + + while (1) { + if (count > 510) + return -EPROTO; + if (act2000_isa_readb(card, p++)) + break; + count++; + } + if (count <= 20) { + printk(KERN_WARNING "act2000: No Firmware-ID!\n"); + return -ETIME; + } + *p = '\0'; + fid.revlen[0] = '\0'; + if (strcmp(fid.isdn, "ISDN")) { + printk(KERN_WARNING "act2000: Wrong Firmware-ID!\n"); + return -EPROTO; + } if ((p = strchr(fid.revision, '\n'))) *p = '\0'; - printk(KERN_INFO "act2000: Firmware-ID: %s\n", fid.revision); + printk(KERN_INFO "act2000: Firmware-ID: %s\n", fid.revision); if (card->flags & ACT2000_FLAGS_IVALID) { printk(KERN_DEBUG "Enabling Interrupts ...\n"); act2000_isa_enable_irq(card); } - return 0; + return 0; } /* * Download microcode into card, check Firmware signature. */ int -act2000_isa_download(act2000_card * card, act2000_ddef __user * cb) +act2000_isa_download(act2000_card *card, act2000_ddef __user *cb) { - unsigned int length; - int l; - int c; - long timeout; - u_char *b; - u_char __user *p; - u_char *buf; - act2000_ddef cblock; - - if (!act2000_isa_reset(card->port)) - return -ENXIO; - msleep_interruptible(500); - if (copy_from_user(&cblock, cb, sizeof(cblock))) - return -EFAULT; - length = cblock.length; - p = cblock.buffer; - if (!access_ok(VERIFY_READ, p, length)) - return -EFAULT; - buf = kmalloc(1024, GFP_KERNEL); - if (!buf) - return -ENOMEM; - timeout = 0; - while (length) { - l = (length > 1024) ? 1024 : length; - c = 0; - b = buf; - if (copy_from_user(buf, p, l)) { - kfree(buf); - return -EFAULT; - } - while (c < l) { - if (act2000_isa_writeb(card, *b++)) { - printk(KERN_WARNING - "act2000: loader timed out" - " len=%d c=%d\n", length, c); - kfree(buf); - return -ETIME; - } - c++; - } - length -= l; - p += l; - } - kfree(buf); - msleep_interruptible(500); - return (act2000_isa_getid(card)); + unsigned int length; + int l; + int c; + long timeout; + u_char *b; + u_char __user *p; + u_char *buf; + act2000_ddef cblock; + + if (!act2000_isa_reset(card->port)) + return -ENXIO; + msleep_interruptible(500); + if (copy_from_user(&cblock, cb, sizeof(cblock))) + return -EFAULT; + length = cblock.length; + p = cblock.buffer; + if (!access_ok(VERIFY_READ, p, length)) + return -EFAULT; + buf = kmalloc(1024, GFP_KERNEL); + if (!buf) + return -ENOMEM; + timeout = 0; + while (length) { + l = (length > 1024) ? 1024 : length; + c = 0; + b = buf; + if (copy_from_user(buf, p, l)) { + kfree(buf); + return -EFAULT; + } + while (c < l) { + if (act2000_isa_writeb(card, *b++)) { + printk(KERN_WARNING + "act2000: loader timed out" + " len=%d c=%d\n", length, c); + kfree(buf); + return -ETIME; + } + c++; + } + length -= l; + p += l; + } + kfree(buf); + msleep_interruptible(500); + return (act2000_isa_getid(card)); } diff --git a/drivers/isdn/act2000/act2000_isa.h b/drivers/isdn/act2000/act2000_isa.h index ad86c5ed9aad..1a728984ede1 100644 --- a/drivers/isdn/act2000/act2000_isa.h +++ b/drivers/isdn/act2000/act2000_isa.h @@ -4,7 +4,7 @@ * * Author Fritz Elfert * Copyright by Fritz Elfert - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -18,9 +18,9 @@ #define ISA_POLL_LOOP 40 /* Try to read-write before give up */ typedef enum { - INT_NO_CHANGE = 0, /* Do not change the Mask */ - INT_ON = 1, /* Set to Enable */ - INT_OFF = 2, /* Set to Disable */ + INT_NO_CHANGE = 0, /* Do not change the Mask */ + INT_ON = 1, /* Set to Enable */ + INT_OFF = 2, /* Set to Disable */ } ISA_INT_T; /**************************************************************************/ @@ -114,22 +114,22 @@ typedef enum { /* Macros for accessing ports */ -#define ISA_PORT_COR (card->port+ISA_COR) -#define ISA_PORT_ISR (card->port+ISA_ISR) -#define ISA_PORT_EPR (card->port+ISA_EPR) -#define ISA_PORT_EER (card->port+ISA_EER) -#define ISA_PORT_SDI (card->port+ISA_SDI) -#define ISA_PORT_SDO (card->port+ISA_SDO) -#define ISA_PORT_SIS (card->port+ISA_SIS) -#define ISA_PORT_SOS (card->port+ISA_SOS) +#define ISA_PORT_COR (card->port + ISA_COR) +#define ISA_PORT_ISR (card->port + ISA_ISR) +#define ISA_PORT_EPR (card->port + ISA_EPR) +#define ISA_PORT_EER (card->port + ISA_EER) +#define ISA_PORT_SDI (card->port + ISA_SDI) +#define ISA_PORT_SDO (card->port + ISA_SDO) +#define ISA_PORT_SIS (card->port + ISA_SIS) +#define ISA_PORT_SOS (card->port + ISA_SOS) /* Prototypes */ extern int act2000_isa_detect(unsigned short portbase); -extern int act2000_isa_config_irq(act2000_card * card, short irq); -extern int act2000_isa_config_port(act2000_card * card, unsigned short portbase); -extern int act2000_isa_download(act2000_card * card, act2000_ddef __user * cb); -extern void act2000_isa_release(act2000_card * card); +extern int act2000_isa_config_irq(act2000_card *card, short irq); +extern int act2000_isa_config_port(act2000_card *card, unsigned short portbase); +extern int act2000_isa_download(act2000_card *card, act2000_ddef __user *cb); +extern void act2000_isa_release(act2000_card *card); extern void act2000_isa_receive(act2000_card *card); extern void act2000_isa_send(act2000_card *card); diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c index 1f0a94906465..3f66ca20b5e5 100644 --- a/drivers/isdn/act2000/capi.c +++ b/drivers/isdn/act2000/capi.c @@ -5,7 +5,7 @@ * * Author Fritz Elfert * Copyright by Fritz Elfert - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -64,14 +64,14 @@ static actcapi_msgdsc valid_msg[] = { {{ 0x86, 0x00}, "DATA_B3_REQ"}, {{ 0xff, 0x00}, "MANUFACTURER_REQ"}, /* Responses */ - {{ 0x01, 0x03}, "RESET_B3_RESP"}, - {{ 0x02, 0x03}, "CONNECT_RESP"}, - {{ 0x03, 0x03}, "CONNECT_ACTIVE_RESP"}, - {{ 0x04, 0x03}, "DISCONNECT_RESP"}, - {{ 0x07, 0x03}, "INFO_RESP"}, - {{ 0x08, 0x03}, "DATA_RESP"}, - {{ 0x82, 0x03}, "CONNECT_B3_RESP"}, - {{ 0x83, 0x03}, "CONNECT_B3_ACTIVE_RESP"}, + {{ 0x01, 0x03}, "RESET_B3_RESP"}, + {{ 0x02, 0x03}, "CONNECT_RESP"}, + {{ 0x03, 0x03}, "CONNECT_ACTIVE_RESP"}, + {{ 0x04, 0x03}, "DISCONNECT_RESP"}, + {{ 0x07, 0x03}, "INFO_RESP"}, + {{ 0x08, 0x03}, "DATA_RESP"}, + {{ 0x82, 0x03}, "CONNECT_B3_RESP"}, + {{ 0x83, 0x03}, "CONNECT_B3_ACTIVE_RESP"}, {{ 0x84, 0x03}, "DISCONNECT_B3_RESP"}, {{ 0x86, 0x03}, "DATA_B3_RESP"}, {{ 0xff, 0x03}, "MANUFACTURER_RESP"}, @@ -88,7 +88,7 @@ static actcapi_msgdsc valid_msg[] = { * 2 = Valid message, B-Channel-data */ int -actcapi_chkhdr(act2000_card * card, actcapi_msghdr *hdr) +actcapi_chkhdr(act2000_card *card, actcapi_msghdr *hdr) { int i; @@ -99,33 +99,33 @@ actcapi_chkhdr(act2000_card * card, actcapi_msghdr *hdr) for (i = 0; i < num_valid_imsg; i++) if ((hdr->cmd.cmd == valid_msg[i].cmd.cmd) && (hdr->cmd.subcmd == valid_msg[i].cmd.subcmd)) { - return (i?1:2); + return (i ? 1 : 2); } return 0; } -#define ACTCAPI_MKHDR(l, c, s) { \ - skb = alloc_skb(l + 8, GFP_ATOMIC); \ - if (skb) { \ - m = (actcapi_msg *)skb_put(skb, l + 8); \ - m->hdr.len = l + 8; \ - m->hdr.applicationID = 1; \ - m->hdr.cmd.cmd = c; \ - m->hdr.cmd.subcmd = s; \ - m->hdr.msgnum = actcapi_nextsmsg(card); \ - } else m = NULL;\ -} +#define ACTCAPI_MKHDR(l, c, s) { \ + skb = alloc_skb(l + 8, GFP_ATOMIC); \ + if (skb) { \ + m = (actcapi_msg *)skb_put(skb, l + 8); \ + m->hdr.len = l + 8; \ + m->hdr.applicationID = 1; \ + m->hdr.cmd.cmd = c; \ + m->hdr.cmd.subcmd = s; \ + m->hdr.msgnum = actcapi_nextsmsg(card); \ + } else m = NULL; \ + } -#define ACTCAPI_CHKSKB if (!skb) { \ - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); \ - return; \ -} +#define ACTCAPI_CHKSKB if (!skb) { \ + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); \ + return; \ + } -#define ACTCAPI_QUEUE_TX { \ - actcapi_debug_msg(skb, 1); \ - skb_queue_tail(&card->sndq, skb); \ - act2000_schedule_tx(card); \ -} +#define ACTCAPI_QUEUE_TX { \ + actcapi_debug_msg(skb, 1); \ + skb_queue_tail(&card->sndq, skb); \ + act2000_schedule_tx(card); \ + } int actcapi_listen_req(act2000_card *card) @@ -138,16 +138,16 @@ actcapi_listen_req(act2000_card *card) for (i = 0; i < ACT2000_BCH; i++) eazmask |= card->bch[i].eazmask; ACTCAPI_MKHDR(9, 0x05, 0x00); - if (!skb) { - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); - return -ENOMEM; - } + if (!skb) { + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); + return -ENOMEM; + } m->msg.listen_req.controller = 0; m->msg.listen_req.infomask = 0x3f; /* All information */ m->msg.listen_req.eazmask = eazmask; - m->msg.listen_req.simask = (eazmask)?0x86:0; /* All SI's */ + m->msg.listen_req.simask = (eazmask) ? 0x86 : 0; /* All SI's */ ACTCAPI_QUEUE_TX; - return 0; + return 0; } int @@ -159,7 +159,7 @@ actcapi_connect_req(act2000_card *card, act2000_chan *chan, char *phone, ACTCAPI_MKHDR((11 + strlen(phone)), 0x02, 0x00); if (!skb) { - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); chan->fsm_state = ACT2000_STATE_NULL; return -ENOMEM; } @@ -168,7 +168,7 @@ actcapi_connect_req(act2000_card *card, act2000_chan *chan, char *phone, m->msg.connect_req.infomask = 0x3f; m->msg.connect_req.si1 = si1; m->msg.connect_req.si2 = si2; - m->msg.connect_req.eaz = eaz?eaz:'0'; + m->msg.connect_req.eaz = eaz ? eaz : '0'; m->msg.connect_req.addr.len = strlen(phone) + 1; m->msg.connect_req.addr.tnp = 0x81; memcpy(m->msg.connect_req.addr.num, phone, strlen(phone)); @@ -203,21 +203,21 @@ actcapi_manufacturer_req_net(act2000_card *card) struct sk_buff *skb; ACTCAPI_MKHDR(5, 0xff, 0x00); - if (!skb) { - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); - return -ENOMEM; - } + if (!skb) { + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); + return -ENOMEM; + } m->msg.manufacturer_req_net.manuf_msg = 0x11; m->msg.manufacturer_req_net.controller = 1; - m->msg.manufacturer_req_net.nettype = (card->ptype == ISDN_PTYPE_EURO)?1:0; + m->msg.manufacturer_req_net.nettype = (card->ptype == ISDN_PTYPE_EURO) ? 1 : 0; ACTCAPI_QUEUE_TX; printk(KERN_INFO "act2000 %s: D-channel protocol now %s\n", - card->interface.id, (card->ptype == ISDN_PTYPE_EURO)?"euro":"1tr6"); + card->interface.id, (card->ptype == ISDN_PTYPE_EURO) ? "euro" : "1tr6"); card->interface.features &= ~(ISDN_FEATURE_P_UNKNOWN | ISDN_FEATURE_P_EURO | ISDN_FEATURE_P_1TR6); card->interface.features |= - ((card->ptype == ISDN_PTYPE_EURO)?ISDN_FEATURE_P_EURO:ISDN_FEATURE_P_1TR6); - return 0; + ((card->ptype == ISDN_PTYPE_EURO) ? ISDN_FEATURE_P_EURO : ISDN_FEATURE_P_1TR6); + return 0; } /* @@ -231,16 +231,16 @@ actcapi_manufacturer_req_v42(act2000_card *card, ulong arg) struct sk_buff *skb; ACTCAPI_MKHDR(8, 0xff, 0x00); - if (!skb) { + if (!skb) { - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); - return -ENOMEM; - } + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); + return -ENOMEM; + } m->msg.manufacturer_req_v42.manuf_msg = 0x10; m->msg.manufacturer_req_v42.controller = 0; - m->msg.manufacturer_req_v42.v42control = (arg?1:0); + m->msg.manufacturer_req_v42.v42control = (arg ? 1 : 0); ACTCAPI_QUEUE_TX; - return 0; + return 0; } #endif /* 0 */ @@ -254,15 +254,15 @@ actcapi_manufacturer_req_errh(act2000_card *card) struct sk_buff *skb; ACTCAPI_MKHDR(4, 0xff, 0x00); - if (!skb) { + if (!skb) { - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); - return -ENOMEM; - } + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); + return -ENOMEM; + } m->msg.manufacturer_req_err.manuf_msg = 0x03; m->msg.manufacturer_req_err.controller = 0; ACTCAPI_QUEUE_TX; - return 0; + return 0; } /* @@ -295,7 +295,7 @@ actcapi_manufacturer_req_msn(act2000_card *card) } p = p->next; } - return 0; + return 0; } void @@ -311,24 +311,24 @@ actcapi_select_b2_protocol_req(act2000_card *card, act2000_chan *chan) sizeof(m->msg.select_b2_protocol_req.dlpd)); m->msg.select_b2_protocol_req.dlpd.len = 6; switch (chan->l2prot) { - case ISDN_PROTO_L2_TRANS: - m->msg.select_b2_protocol_req.protocol = 0x03; - m->msg.select_b2_protocol_req.dlpd.dlen = 4000; - break; - case ISDN_PROTO_L2_HDLC: - m->msg.select_b2_protocol_req.protocol = 0x02; - m->msg.select_b2_protocol_req.dlpd.dlen = 4000; - break; - case ISDN_PROTO_L2_X75I: - case ISDN_PROTO_L2_X75UI: - case ISDN_PROTO_L2_X75BUI: - m->msg.select_b2_protocol_req.protocol = 0x01; - m->msg.select_b2_protocol_req.dlpd.dlen = 4000; - m->msg.select_b2_protocol_req.dlpd.laa = 3; - m->msg.select_b2_protocol_req.dlpd.lab = 1; - m->msg.select_b2_protocol_req.dlpd.win = 7; - m->msg.select_b2_protocol_req.dlpd.modulo = 8; - break; + case ISDN_PROTO_L2_TRANS: + m->msg.select_b2_protocol_req.protocol = 0x03; + m->msg.select_b2_protocol_req.dlpd.dlen = 4000; + break; + case ISDN_PROTO_L2_HDLC: + m->msg.select_b2_protocol_req.protocol = 0x02; + m->msg.select_b2_protocol_req.dlpd.dlen = 4000; + break; + case ISDN_PROTO_L2_X75I: + case ISDN_PROTO_L2_X75UI: + case ISDN_PROTO_L2_X75BUI: + m->msg.select_b2_protocol_req.protocol = 0x01; + m->msg.select_b2_protocol_req.dlpd.dlen = 4000; + m->msg.select_b2_protocol_req.dlpd.laa = 3; + m->msg.select_b2_protocol_req.dlpd.lab = 1; + m->msg.select_b2_protocol_req.dlpd.win = 7; + m->msg.select_b2_protocol_req.dlpd.modulo = 8; + break; } ACTCAPI_QUEUE_TX; } @@ -345,11 +345,11 @@ actcapi_select_b3_protocol_req(act2000_card *card, act2000_chan *chan) memset(&m->msg.select_b3_protocol_req.ncpd, 0, sizeof(m->msg.select_b3_protocol_req.ncpd)); switch (chan->l3prot) { - case ISDN_PROTO_L3_TRANS: - m->msg.select_b3_protocol_req.protocol = 0x04; - m->msg.select_b3_protocol_req.ncpd.len = 13; - m->msg.select_b3_protocol_req.ncpd.modulo = 8; - break; + case ISDN_PROTO_L3_TRANS: + m->msg.select_b3_protocol_req.protocol = 0x04; + m->msg.select_b3_protocol_req.ncpd.len = 13; + m->msg.select_b3_protocol_req.ncpd.modulo = 8; + break; } ACTCAPI_QUEUE_TX; } @@ -434,7 +434,7 @@ actcapi_connect_b3_resp(act2000_card *card, act2000_chan *chan, __u8 rejectcause actcapi_msg *m; struct sk_buff *skb; - ACTCAPI_MKHDR((rejectcause?3:17), 0x82, 0x03); + ACTCAPI_MKHDR((rejectcause ? 3 : 17), 0x82, 0x03); ACTCAPI_CHKSKB; m->msg.connect_b3_resp.ncci = chan->ncci; m->msg.connect_b3_resp.rejectcause = rejectcause; @@ -563,10 +563,10 @@ actcapi_data_b3_ind(act2000_card *card, struct sk_buff *skb) { blocknr = msg->msg.data_b3_ind.blocknr; skb_pull(skb, 19); card->interface.rcvcallb_skb(card->myid, chan, skb); - if (!(skb = alloc_skb(11, GFP_ATOMIC))) { - printk(KERN_WARNING "actcapi: alloc_skb failed\n"); - return 1; - } + if (!(skb = alloc_skb(11, GFP_ATOMIC))) { + printk(KERN_WARNING "actcapi: alloc_skb failed\n"); + return 1; + } msg = (actcapi_msg *)skb_put(skb, 11); msg->hdr.len = 11; msg->hdr.applicationID = 1; @@ -595,34 +595,34 @@ handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) { spin_lock_irqsave(&card->lock, flags); skb = skb_peek(&card->ackq); spin_unlock_irqrestore(&card->lock, flags); - if (!skb) { + if (!skb) { printk(KERN_WARNING "act2000: handle_ack nothing found!\n"); return 0; } - tmp = skb; - while (1) { - m = (actcapi_msg *)tmp->data; - if ((((m->msg.data_b3_req.fakencci >> 8) & 0xff) == chan->ncci) && + tmp = skb; + while (1) { + m = (actcapi_msg *)tmp->data; + if ((((m->msg.data_b3_req.fakencci >> 8) & 0xff) == chan->ncci) && (m->msg.data_b3_req.blocknr == blocknr)) { /* found corresponding DATA_B3_REQ */ - skb_unlink(tmp, &card->ackq); + skb_unlink(tmp, &card->ackq); chan->queued -= m->msg.data_b3_req.datalen; if (m->msg.data_b3_req.flags) ret = m->msg.data_b3_req.datalen; dev_kfree_skb(tmp); if (chan->queued < 0) chan->queued = 0; - return ret; - } - spin_lock_irqsave(&card->lock, flags); - tmp = skb_peek((struct sk_buff_head *)tmp); - spin_unlock_irqrestore(&card->lock, flags); - if ((tmp == skb) || (tmp == NULL)) { + return ret; + } + spin_lock_irqsave(&card->lock, flags); + tmp = skb_peek((struct sk_buff_head *)tmp); + spin_unlock_irqrestore(&card->lock, flags); + if ((tmp == skb) || (tmp == NULL)) { /* reached end of queue */ printk(KERN_WARNING "act2000: handle_ack nothing found!\n"); - return 0; + return 0; } - } + } } void @@ -644,294 +644,294 @@ actcapi_dispatch(struct work_struct *work) msg = (actcapi_msg *)skb->data; ccmd = ((msg->hdr.cmd.cmd << 8) | msg->hdr.cmd.subcmd); switch (ccmd) { - case 0x8602: - /* DATA_B3_IND */ - if (actcapi_data_b3_ind(card, skb)) - return; - break; - case 0x8601: - /* DATA_B3_CONF */ - chan = find_ncci(card, msg->msg.data_b3_conf.ncci); - if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_ACTIVE)) { - if (msg->msg.data_b3_conf.info != 0) - printk(KERN_WARNING "act2000: DATA_B3_CONF: %04x\n", - msg->msg.data_b3_conf.info); - len = handle_ack(card, &card->bch[chan], - msg->msg.data_b3_conf.blocknr); - if (len) { + case 0x8602: + /* DATA_B3_IND */ + if (actcapi_data_b3_ind(card, skb)) + return; + break; + case 0x8601: + /* DATA_B3_CONF */ + chan = find_ncci(card, msg->msg.data_b3_conf.ncci); + if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_ACTIVE)) { + if (msg->msg.data_b3_conf.info != 0) + printk(KERN_WARNING "act2000: DATA_B3_CONF: %04x\n", + msg->msg.data_b3_conf.info); + len = handle_ack(card, &card->bch[chan], + msg->msg.data_b3_conf.blocknr); + if (len) { + cmd.driver = card->myid; + cmd.command = ISDN_STAT_BSENT; + cmd.arg = chan; + cmd.parm.length = len; + card->interface.statcallb(&cmd); + } + } + break; + case 0x0201: + /* CONNECT_CONF */ + chan = find_dialing(card, msg->hdr.msgnum); + if (chan >= 0) { + if (msg->msg.connect_conf.info) { + card->bch[chan].fsm_state = ACT2000_STATE_NULL; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_DHUP; + cmd.arg = chan; + card->interface.statcallb(&cmd); + } else { + card->bch[chan].fsm_state = ACT2000_STATE_OWAIT; + card->bch[chan].plci = msg->msg.connect_conf.plci; + } + } + break; + case 0x0202: + /* CONNECT_IND */ + chan = new_plci(card, msg->msg.connect_ind.plci); + if (chan < 0) { + ctmp = (act2000_chan *)tmp; + ctmp->plci = msg->msg.connect_ind.plci; + actcapi_connect_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ + } else { + card->bch[chan].fsm_state = ACT2000_STATE_ICALL; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_ICALL; + cmd.arg = chan; + cmd.parm.setup.si1 = msg->msg.connect_ind.si1; + cmd.parm.setup.si2 = msg->msg.connect_ind.si2; + if (card->ptype == ISDN_PTYPE_EURO) + strcpy(cmd.parm.setup.eazmsn, + act2000_find_eaz(card, msg->msg.connect_ind.eaz)); + else { + cmd.parm.setup.eazmsn[0] = msg->msg.connect_ind.eaz; + cmd.parm.setup.eazmsn[1] = 0; + } + memset(cmd.parm.setup.phone, 0, sizeof(cmd.parm.setup.phone)); + memcpy(cmd.parm.setup.phone, msg->msg.connect_ind.addr.num, + msg->msg.connect_ind.addr.len - 1); + cmd.parm.setup.plan = msg->msg.connect_ind.addr.tnp; + cmd.parm.setup.screen = 0; + if (card->interface.statcallb(&cmd) == 2) + actcapi_connect_resp(card, &card->bch[chan], 0x15); /* Reject Call */ + } + break; + case 0x0302: + /* CONNECT_ACTIVE_IND */ + chan = find_plci(card, msg->msg.connect_active_ind.plci); + if (chan >= 0) + switch (card->bch[chan].fsm_state) { + case ACT2000_STATE_IWAIT: + actcapi_connect_active_resp(card, &card->bch[chan]); + break; + case ACT2000_STATE_OWAIT: + actcapi_connect_active_resp(card, &card->bch[chan]); + actcapi_select_b2_protocol_req(card, &card->bch[chan]); + break; + } + break; + case 0x8202: + /* CONNECT_B3_IND */ + chan = find_plci(card, msg->msg.connect_b3_ind.plci); + if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_IBWAIT)) { + card->bch[chan].ncci = msg->msg.connect_b3_ind.ncci; + actcapi_connect_b3_resp(card, &card->bch[chan], 0); + } else { + ctmp = (act2000_chan *)tmp; + ctmp->ncci = msg->msg.connect_b3_ind.ncci; + actcapi_connect_b3_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ + } + break; + case 0x8302: + /* CONNECT_B3_ACTIVE_IND */ + chan = find_ncci(card, msg->msg.connect_b3_active_ind.ncci); + if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BWAIT)) { + actcapi_connect_b3_active_resp(card, &card->bch[chan]); + cmd.driver = card->myid; + cmd.command = ISDN_STAT_BCONN; + cmd.arg = chan; + card->interface.statcallb(&cmd); + } + break; + case 0x8402: + /* DISCONNECT_B3_IND */ + chan = find_ncci(card, msg->msg.disconnect_b3_ind.ncci); + if (chan >= 0) { + ctmp = &card->bch[chan]; + actcapi_disconnect_b3_resp(card, ctmp); + switch (ctmp->fsm_state) { + case ACT2000_STATE_ACTIVE: + ctmp->fsm_state = ACT2000_STATE_DHWAIT2; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_BHUP; + cmd.arg = chan; + card->interface.statcallb(&cmd); + break; + case ACT2000_STATE_BHWAIT2: + actcapi_disconnect_req(card, ctmp); + ctmp->fsm_state = ACT2000_STATE_DHWAIT; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_BHUP; + cmd.arg = chan; + card->interface.statcallb(&cmd); + break; + } + } + break; + case 0x0402: + /* DISCONNECT_IND */ + chan = find_plci(card, msg->msg.disconnect_ind.plci); + if (chan >= 0) { + ctmp = &card->bch[chan]; + actcapi_disconnect_resp(card, ctmp); + ctmp->fsm_state = ACT2000_STATE_NULL; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_DHUP; + cmd.arg = chan; + card->interface.statcallb(&cmd); + } else { + ctmp = (act2000_chan *)tmp; + ctmp->plci = msg->msg.disconnect_ind.plci; + actcapi_disconnect_resp(card, ctmp); + } + break; + case 0x4001: + /* SELECT_B2_PROTOCOL_CONF */ + chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci); + if (chan >= 0) + switch (card->bch[chan].fsm_state) { + case ACT2000_STATE_ICALL: + case ACT2000_STATE_OWAIT: + ctmp = &card->bch[chan]; + if (msg->msg.select_b2_protocol_conf.info == 0) + actcapi_select_b3_protocol_req(card, ctmp); + else { + ctmp->fsm_state = ACT2000_STATE_NULL; cmd.driver = card->myid; - cmd.command = ISDN_STAT_BSENT; + cmd.command = ISDN_STAT_DHUP; cmd.arg = chan; - cmd.parm.length = len; card->interface.statcallb(&cmd); } + break; } - break; - case 0x0201: - /* CONNECT_CONF */ - chan = find_dialing(card, msg->hdr.msgnum); - if (chan >= 0) { - if (msg->msg.connect_conf.info) { - card->bch[chan].fsm_state = ACT2000_STATE_NULL; + break; + case 0x8001: + /* SELECT_B3_PROTOCOL_CONF */ + chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci); + if (chan >= 0) + switch (card->bch[chan].fsm_state) { + case ACT2000_STATE_ICALL: + case ACT2000_STATE_OWAIT: + ctmp = &card->bch[chan]; + if (msg->msg.select_b3_protocol_conf.info == 0) + actcapi_listen_b3_req(card, ctmp); + else { + ctmp->fsm_state = ACT2000_STATE_NULL; cmd.driver = card->myid; cmd.command = ISDN_STAT_DHUP; cmd.arg = chan; card->interface.statcallb(&cmd); - } else { - card->bch[chan].fsm_state = ACT2000_STATE_OWAIT; - card->bch[chan].plci = msg->msg.connect_conf.plci; } } - break; - case 0x0202: - /* CONNECT_IND */ - chan = new_plci(card, msg->msg.connect_ind.plci); - if (chan < 0) { - ctmp = (act2000_chan *)tmp; - ctmp->plci = msg->msg.connect_ind.plci; - actcapi_connect_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ - } else { - card->bch[chan].fsm_state = ACT2000_STATE_ICALL; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_ICALL; - cmd.arg = chan; - cmd.parm.setup.si1 = msg->msg.connect_ind.si1; - cmd.parm.setup.si2 = msg->msg.connect_ind.si2; - if (card->ptype == ISDN_PTYPE_EURO) - strcpy(cmd.parm.setup.eazmsn, - act2000_find_eaz(card, msg->msg.connect_ind.eaz)); + break; + case 0x8101: + /* LISTEN_B3_CONF */ + chan = find_plci(card, msg->msg.listen_b3_conf.plci); + if (chan >= 0) + switch (card->bch[chan].fsm_state) { + case ACT2000_STATE_ICALL: + ctmp = &card->bch[chan]; + if (msg->msg.listen_b3_conf.info == 0) + actcapi_connect_resp(card, ctmp, 0); else { - cmd.parm.setup.eazmsn[0] = msg->msg.connect_ind.eaz; - cmd.parm.setup.eazmsn[1] = 0; - } - memset(cmd.parm.setup.phone, 0, sizeof(cmd.parm.setup.phone)); - memcpy(cmd.parm.setup.phone, msg->msg.connect_ind.addr.num, - msg->msg.connect_ind.addr.len - 1); - cmd.parm.setup.plan = msg->msg.connect_ind.addr.tnp; - cmd.parm.setup.screen = 0; - if (card->interface.statcallb(&cmd) == 2) - actcapi_connect_resp(card, &card->bch[chan], 0x15); /* Reject Call */ - } - break; - case 0x0302: - /* CONNECT_ACTIVE_IND */ - chan = find_plci(card, msg->msg.connect_active_ind.plci); - if (chan >= 0) - switch (card->bch[chan].fsm_state) { - case ACT2000_STATE_IWAIT: - actcapi_connect_active_resp(card, &card->bch[chan]); - break; - case ACT2000_STATE_OWAIT: - actcapi_connect_active_resp(card, &card->bch[chan]); - actcapi_select_b2_protocol_req(card, &card->bch[chan]); - break; + ctmp->fsm_state = ACT2000_STATE_NULL; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_DHUP; + cmd.arg = chan; + card->interface.statcallb(&cmd); } - break; - case 0x8202: - /* CONNECT_B3_IND */ - chan = find_plci(card, msg->msg.connect_b3_ind.plci); - if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_IBWAIT)) { - card->bch[chan].ncci = msg->msg.connect_b3_ind.ncci; - actcapi_connect_b3_resp(card, &card->bch[chan], 0); - } else { - ctmp = (act2000_chan *)tmp; - ctmp->ncci = msg->msg.connect_b3_ind.ncci; - actcapi_connect_b3_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ - } - break; - case 0x8302: - /* CONNECT_B3_ACTIVE_IND */ - chan = find_ncci(card, msg->msg.connect_b3_active_ind.ncci); - if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BWAIT)) { - actcapi_connect_b3_active_resp(card, &card->bch[chan]); - cmd.driver = card->myid; - cmd.command = ISDN_STAT_BCONN; - cmd.arg = chan; - card->interface.statcallb(&cmd); - } - break; - case 0x8402: - /* DISCONNECT_B3_IND */ - chan = find_ncci(card, msg->msg.disconnect_b3_ind.ncci); - if (chan >= 0) { + break; + case ACT2000_STATE_OWAIT: ctmp = &card->bch[chan]; - actcapi_disconnect_b3_resp(card, ctmp); - switch (ctmp->fsm_state) { - case ACT2000_STATE_ACTIVE: - ctmp->fsm_state = ACT2000_STATE_DHWAIT2; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_BHUP; - cmd.arg = chan; - card->interface.statcallb(&cmd); - break; - case ACT2000_STATE_BHWAIT2: - actcapi_disconnect_req(card, ctmp); - ctmp->fsm_state = ACT2000_STATE_DHWAIT; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_BHUP; - cmd.arg = chan; - card->interface.statcallb(&cmd); - break; + if (msg->msg.listen_b3_conf.info == 0) { + actcapi_connect_b3_req(card, ctmp); + ctmp->fsm_state = ACT2000_STATE_OBWAIT; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_DCONN; + cmd.arg = chan; + card->interface.statcallb(&cmd); + } else { + ctmp->fsm_state = ACT2000_STATE_NULL; + cmd.driver = card->myid; + cmd.command = ISDN_STAT_DHUP; + cmd.arg = chan; + card->interface.statcallb(&cmd); } + break; } - break; - case 0x0402: - /* DISCONNECT_IND */ - chan = find_plci(card, msg->msg.disconnect_ind.plci); - if (chan >= 0) { - ctmp = &card->bch[chan]; - actcapi_disconnect_resp(card, ctmp); + break; + case 0x8201: + /* CONNECT_B3_CONF */ + chan = find_plci(card, msg->msg.connect_b3_conf.plci); + if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) { + ctmp = &card->bch[chan]; + if (msg->msg.connect_b3_conf.info) { ctmp->fsm_state = ACT2000_STATE_NULL; cmd.driver = card->myid; cmd.command = ISDN_STAT_DHUP; cmd.arg = chan; card->interface.statcallb(&cmd); } else { - ctmp = (act2000_chan *)tmp; - ctmp->plci = msg->msg.disconnect_ind.plci; - actcapi_disconnect_resp(card, ctmp); + ctmp->ncci = msg->msg.connect_b3_conf.ncci; + ctmp->fsm_state = ACT2000_STATE_BWAIT; } - break; - case 0x4001: - /* SELECT_B2_PROTOCOL_CONF */ - chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci); - if (chan >= 0) - switch (card->bch[chan].fsm_state) { - case ACT2000_STATE_ICALL: - case ACT2000_STATE_OWAIT: - ctmp = &card->bch[chan]; - if (msg->msg.select_b2_protocol_conf.info == 0) - actcapi_select_b3_protocol_req(card, ctmp); - else { - ctmp->fsm_state = ACT2000_STATE_NULL; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg = chan; - card->interface.statcallb(&cmd); - } - break; - } - break; - case 0x8001: - /* SELECT_B3_PROTOCOL_CONF */ - chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci); - if (chan >= 0) - switch (card->bch[chan].fsm_state) { - case ACT2000_STATE_ICALL: - case ACT2000_STATE_OWAIT: - ctmp = &card->bch[chan]; - if (msg->msg.select_b3_protocol_conf.info == 0) - actcapi_listen_b3_req(card, ctmp); - else { - ctmp->fsm_state = ACT2000_STATE_NULL; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg = chan; - card->interface.statcallb(&cmd); - } - } - break; - case 0x8101: - /* LISTEN_B3_CONF */ - chan = find_plci(card, msg->msg.listen_b3_conf.plci); - if (chan >= 0) - switch (card->bch[chan].fsm_state) { - case ACT2000_STATE_ICALL: - ctmp = &card->bch[chan]; - if (msg->msg.listen_b3_conf.info == 0) - actcapi_connect_resp(card, ctmp, 0); - else { - ctmp->fsm_state = ACT2000_STATE_NULL; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg = chan; - card->interface.statcallb(&cmd); - } - break; - case ACT2000_STATE_OWAIT: - ctmp = &card->bch[chan]; - if (msg->msg.listen_b3_conf.info == 0) { - actcapi_connect_b3_req(card, ctmp); - ctmp->fsm_state = ACT2000_STATE_OBWAIT; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DCONN; - cmd.arg = chan; - card->interface.statcallb(&cmd); - } else { - ctmp->fsm_state = ACT2000_STATE_NULL; - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg = chan; - card->interface.statcallb(&cmd); - } - break; - } - break; - case 0x8201: - /* CONNECT_B3_CONF */ - chan = find_plci(card, msg->msg.connect_b3_conf.plci); - if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) { - ctmp = &card->bch[chan]; - if (msg->msg.connect_b3_conf.info) { - ctmp->fsm_state = ACT2000_STATE_NULL; + } + break; + case 0x8401: + /* DISCONNECT_B3_CONF */ + chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci); + if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT)) + card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2; + break; + case 0x0702: + /* INFO_IND */ + chan = find_plci(card, msg->msg.info_ind.plci); + if (chan >= 0) + /* TODO: Eval Charging info / cause */ + actcapi_info_resp(card, &card->bch[chan]); + break; + case 0x0401: + /* LISTEN_CONF */ + case 0x0501: + /* LISTEN_CONF */ + case 0xff01: + /* MANUFACTURER_CONF */ + break; + case 0xff02: + /* MANUFACTURER_IND */ + if (msg->msg.manuf_msg == 3) { + memset(tmp, 0, sizeof(tmp)); + strncpy(tmp, + &msg->msg.manufacturer_ind_err.errstring, + msg->hdr.len - 16); + if (msg->msg.manufacturer_ind_err.errcode) + printk(KERN_WARNING "act2000: %s\n", tmp); + else { + printk(KERN_DEBUG "act2000: %s\n", tmp); + if ((!strncmp(tmp, "INFO: Trace buffer con", 22)) || + (!strncmp(tmp, "INFO: Compile Date/Tim", 22))) { + card->flags |= ACT2000_FLAGS_RUNNING; + cmd.command = ISDN_STAT_RUN; cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg = chan; + cmd.arg = 0; + actcapi_manufacturer_req_net(card); + actcapi_manufacturer_req_msn(card); + actcapi_listen_req(card); card->interface.statcallb(&cmd); - } else { - ctmp->ncci = msg->msg.connect_b3_conf.ncci; - ctmp->fsm_state = ACT2000_STATE_BWAIT; } } - break; - case 0x8401: - /* DISCONNECT_B3_CONF */ - chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci); - if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT)) - card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2; - break; - case 0x0702: - /* INFO_IND */ - chan = find_plci(card, msg->msg.info_ind.plci); - if (chan >= 0) - /* TODO: Eval Charging info / cause */ - actcapi_info_resp(card, &card->bch[chan]); - break; - case 0x0401: - /* LISTEN_CONF */ - case 0x0501: - /* LISTEN_CONF */ - case 0xff01: - /* MANUFACTURER_CONF */ - break; - case 0xff02: - /* MANUFACTURER_IND */ - if (msg->msg.manuf_msg == 3) { - memset(tmp, 0, sizeof(tmp)); - strncpy(tmp, - &msg->msg.manufacturer_ind_err.errstring, - msg->hdr.len - 16); - if (msg->msg.manufacturer_ind_err.errcode) - printk(KERN_WARNING "act2000: %s\n", tmp); - else { - printk(KERN_DEBUG "act2000: %s\n", tmp); - if ((!strncmp(tmp, "INFO: Trace buffer con", 22)) || - (!strncmp(tmp, "INFO: Compile Date/Tim", 22))) { - card->flags |= ACT2000_FLAGS_RUNNING; - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - actcapi_manufacturer_req_net(card); - actcapi_manufacturer_req_msn(card); - actcapi_listen_req(card); - card->interface.statcallb(&cmd); - } - } - } - break; - default: - printk(KERN_WARNING "act2000: UNHANDLED Message %04x\n", ccmd); - break; + } + break; + default: + printk(KERN_WARNING "act2000: UNHANDLED Message %04x\n", ccmd); + break; } dev_kfree_skb(skb); } @@ -1015,7 +1015,7 @@ actcapi_debug_msg(struct sk_buff *skb, int direction) char *descr; int i; char tmp[170]; - + #ifndef DEBUG_DATA_MSG if (msg->hdr.cmd.cmd == 0x86) return; @@ -1030,151 +1030,151 @@ actcapi_debug_msg(struct sk_buff *skb, int direction) descr = valid_msg[i].description; break; } - printk(KERN_DEBUG "%s %s msg\n", direction?"Outgoing":"Incoming", descr); + printk(KERN_DEBUG "%s %s msg\n", direction ? "Outgoing" : "Incoming", descr); printk(KERN_DEBUG " ApplID = %d\n", msg->hdr.applicationID); printk(KERN_DEBUG " Len = %d\n", msg->hdr.len); printk(KERN_DEBUG " MsgNum = 0x%04x\n", msg->hdr.msgnum); printk(KERN_DEBUG " Cmd = 0x%02x\n", msg->hdr.cmd.cmd); printk(KERN_DEBUG " SubCmd = 0x%02x\n", msg->hdr.cmd.subcmd); switch (i) { - case 0: - /* DATA B3 IND */ - printk(KERN_DEBUG " BLOCK = 0x%02x\n", - msg->msg.data_b3_ind.blocknr); - break; - case 2: - /* CONNECT CONF */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.connect_conf.plci); - printk(KERN_DEBUG " Info = 0x%04x\n", - msg->msg.connect_conf.info); - break; + case 0: + /* DATA B3 IND */ + printk(KERN_DEBUG " BLOCK = 0x%02x\n", + msg->msg.data_b3_ind.blocknr); + break; + case 2: + /* CONNECT CONF */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.connect_conf.plci); + printk(KERN_DEBUG " Info = 0x%04x\n", + msg->msg.connect_conf.info); + break; + case 3: + /* CONNECT IND */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.connect_ind.plci); + printk(KERN_DEBUG " Contr = %d\n", + msg->msg.connect_ind.controller); + printk(KERN_DEBUG " SI1 = %d\n", + msg->msg.connect_ind.si1); + printk(KERN_DEBUG " SI2 = %d\n", + msg->msg.connect_ind.si2); + printk(KERN_DEBUG " EAZ = '%c'\n", + msg->msg.connect_ind.eaz); + actcapi_debug_caddr(&msg->msg.connect_ind.addr); + break; + case 5: + /* CONNECT ACTIVE IND */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.connect_active_ind.plci); + actcapi_debug_caddr(&msg->msg.connect_active_ind.addr); + break; + case 8: + /* LISTEN CONF */ + printk(KERN_DEBUG " Contr = %d\n", + msg->msg.listen_conf.controller); + printk(KERN_DEBUG " Info = 0x%04x\n", + msg->msg.listen_conf.info); + break; + case 11: + /* INFO IND */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.info_ind.plci); + printk(KERN_DEBUG " Imsk = 0x%04x\n", + msg->msg.info_ind.nr.mask); + if (msg->hdr.len > 12) { + int l = msg->hdr.len - 12; + int j; + char *p = tmp; + for (j = 0; j < l; j++) + p += sprintf(p, "%02x ", msg->msg.info_ind.el.display[j]); + printk(KERN_DEBUG " D = '%s'\n", tmp); + } + break; + case 14: + /* SELECT B2 PROTOCOL CONF */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.select_b2_protocol_conf.plci); + printk(KERN_DEBUG " Info = 0x%04x\n", + msg->msg.select_b2_protocol_conf.info); + break; + case 15: + /* SELECT B3 PROTOCOL CONF */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.select_b3_protocol_conf.plci); + printk(KERN_DEBUG " Info = 0x%04x\n", + msg->msg.select_b3_protocol_conf.info); + break; + case 16: + /* LISTEN B3 CONF */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.listen_b3_conf.plci); + printk(KERN_DEBUG " Info = 0x%04x\n", + msg->msg.listen_b3_conf.info); + break; + case 18: + /* CONNECT B3 IND */ + printk(KERN_DEBUG " NCCI = 0x%04x\n", + msg->msg.connect_b3_ind.ncci); + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.connect_b3_ind.plci); + actcapi_debug_ncpi(&msg->msg.connect_b3_ind.ncpi); + break; + case 19: + /* CONNECT B3 ACTIVE IND */ + printk(KERN_DEBUG " NCCI = 0x%04x\n", + msg->msg.connect_b3_active_ind.ncci); + actcapi_debug_ncpi(&msg->msg.connect_b3_active_ind.ncpi); + break; + case 26: + /* MANUFACTURER IND */ + printk(KERN_DEBUG " Mmsg = 0x%02x\n", + msg->msg.manufacturer_ind_err.manuf_msg); + switch (msg->msg.manufacturer_ind_err.manuf_msg) { case 3: - /* CONNECT IND */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.connect_ind.plci); printk(KERN_DEBUG " Contr = %d\n", - msg->msg.connect_ind.controller); - printk(KERN_DEBUG " SI1 = %d\n", - msg->msg.connect_ind.si1); - printk(KERN_DEBUG " SI2 = %d\n", - msg->msg.connect_ind.si2); - printk(KERN_DEBUG " EAZ = '%c'\n", - msg->msg.connect_ind.eaz); - actcapi_debug_caddr(&msg->msg.connect_ind.addr); - break; - case 5: - /* CONNECT ACTIVE IND */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.connect_active_ind.plci); - actcapi_debug_caddr(&msg->msg.connect_active_ind.addr); - break; - case 8: - /* LISTEN CONF */ - printk(KERN_DEBUG " Contr = %d\n", - msg->msg.listen_conf.controller); - printk(KERN_DEBUG " Info = 0x%04x\n", - msg->msg.listen_conf.info); - break; - case 11: - /* INFO IND */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.info_ind.plci); - printk(KERN_DEBUG " Imsk = 0x%04x\n", - msg->msg.info_ind.nr.mask); - if (msg->hdr.len > 12) { - int l = msg->hdr.len - 12; - int j; - char *p = tmp; - for (j = 0; j < l ; j++) - p += sprintf(p, "%02x ", msg->msg.info_ind.el.display[j]); - printk(KERN_DEBUG " D = '%s'\n", tmp); - } - break; - case 14: - /* SELECT B2 PROTOCOL CONF */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.select_b2_protocol_conf.plci); - printk(KERN_DEBUG " Info = 0x%04x\n", - msg->msg.select_b2_protocol_conf.info); - break; - case 15: - /* SELECT B3 PROTOCOL CONF */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.select_b3_protocol_conf.plci); - printk(KERN_DEBUG " Info = 0x%04x\n", - msg->msg.select_b3_protocol_conf.info); - break; - case 16: - /* LISTEN B3 CONF */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.listen_b3_conf.plci); - printk(KERN_DEBUG " Info = 0x%04x\n", - msg->msg.listen_b3_conf.info); - break; - case 18: - /* CONNECT B3 IND */ - printk(KERN_DEBUG " NCCI = 0x%04x\n", - msg->msg.connect_b3_ind.ncci); - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.connect_b3_ind.plci); - actcapi_debug_ncpi(&msg->msg.connect_b3_ind.ncpi); - break; - case 19: - /* CONNECT B3 ACTIVE IND */ - printk(KERN_DEBUG " NCCI = 0x%04x\n", - msg->msg.connect_b3_active_ind.ncci); - actcapi_debug_ncpi(&msg->msg.connect_b3_active_ind.ncpi); - break; - case 26: - /* MANUFACTURER IND */ - printk(KERN_DEBUG " Mmsg = 0x%02x\n", - msg->msg.manufacturer_ind_err.manuf_msg); - switch (msg->msg.manufacturer_ind_err.manuf_msg) { - case 3: - printk(KERN_DEBUG " Contr = %d\n", - msg->msg.manufacturer_ind_err.controller); - printk(KERN_DEBUG " Code = 0x%08x\n", - msg->msg.manufacturer_ind_err.errcode); - memset(tmp, 0, sizeof(tmp)); - strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring, - msg->hdr.len - 16); - printk(KERN_DEBUG " Emsg = '%s'\n", tmp); - break; - } - break; - case 30: - /* LISTEN REQ */ - printk(KERN_DEBUG " Imsk = 0x%08x\n", - msg->msg.listen_req.infomask); - printk(KERN_DEBUG " Emsk = 0x%04x\n", - msg->msg.listen_req.eazmask); - printk(KERN_DEBUG " Smsk = 0x%04x\n", - msg->msg.listen_req.simask); - break; - case 35: - /* SELECT_B2_PROTOCOL_REQ */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.select_b2_protocol_req.plci); - printk(KERN_DEBUG " prot = 0x%02x\n", - msg->msg.select_b2_protocol_req.protocol); - if (msg->hdr.len >= 11) - printk(KERN_DEBUG "No dlpd\n"); - else - actcapi_debug_dlpd(&msg->msg.select_b2_protocol_req.dlpd); - break; - case 44: - /* CONNECT RESP */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.connect_resp.plci); - printk(KERN_DEBUG " CAUSE = 0x%02x\n", - msg->msg.connect_resp.rejectcause); - break; - case 45: - /* CONNECT ACTIVE RESP */ - printk(KERN_DEBUG " PLCI = 0x%04x\n", - msg->msg.connect_active_resp.plci); + msg->msg.manufacturer_ind_err.controller); + printk(KERN_DEBUG " Code = 0x%08x\n", + msg->msg.manufacturer_ind_err.errcode); + memset(tmp, 0, sizeof(tmp)); + strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring, + msg->hdr.len - 16); + printk(KERN_DEBUG " Emsg = '%s'\n", tmp); break; + } + break; + case 30: + /* LISTEN REQ */ + printk(KERN_DEBUG " Imsk = 0x%08x\n", + msg->msg.listen_req.infomask); + printk(KERN_DEBUG " Emsk = 0x%04x\n", + msg->msg.listen_req.eazmask); + printk(KERN_DEBUG " Smsk = 0x%04x\n", + msg->msg.listen_req.simask); + break; + case 35: + /* SELECT_B2_PROTOCOL_REQ */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.select_b2_protocol_req.plci); + printk(KERN_DEBUG " prot = 0x%02x\n", + msg->msg.select_b2_protocol_req.protocol); + if (msg->hdr.len >= 11) + printk(KERN_DEBUG "No dlpd\n"); + else + actcapi_debug_dlpd(&msg->msg.select_b2_protocol_req.dlpd); + break; + case 44: + /* CONNECT RESP */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.connect_resp.plci); + printk(KERN_DEBUG " CAUSE = 0x%02x\n", + msg->msg.connect_resp.rejectcause); + break; + case 45: + /* CONNECT ACTIVE RESP */ + printk(KERN_DEBUG " PLCI = 0x%04x\n", + msg->msg.connect_active_resp.plci); + break; } } #endif diff --git a/drivers/isdn/act2000/capi.h b/drivers/isdn/act2000/capi.h index e55f6a931f66..01ccdecd43f7 100644 --- a/drivers/isdn/act2000/capi.h +++ b/drivers/isdn/act2000/capi.h @@ -4,7 +4,7 @@ * * Author Fritz Elfert * Copyright by Fritz Elfert - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -46,10 +46,10 @@ typedef struct actcapi_addr { typedef union actcapi_infonr { /* info number */ __u16 mask; /* info-mask field */ struct bmask { /* bit definitions */ - unsigned codes : 3; /* code set */ - unsigned rsvd : 5; /* reserved */ - unsigned svind : 1; /* single, variable length ind. */ - unsigned wtype : 7; /* W-element type */ + unsigned codes:3; /* code set */ + unsigned rsvd:5; /* reserved */ + unsigned svind:1; /* single, variable length ind. */ + unsigned wtype:7; /* W-element type */ } bmask; } actcapi_infonr; @@ -59,13 +59,13 @@ typedef union actcapi_infoel { /* info element */ __u8 display[40]; /* display contents */ __u8 uuinfo[40]; /* User-user info field */ struct cause { /* Cause information */ - unsigned ext2 : 1; /* extension */ - unsigned cod : 2; /* coding standard */ - unsigned spare : 1; /* spare */ - unsigned loc : 4; /* location */ - unsigned ext1 : 1; /* extension */ - unsigned cval : 7; /* Cause value */ - } cause; + unsigned ext2:1; /* extension */ + unsigned cod:2; /* coding standard */ + unsigned spare:1; /* spare */ + unsigned loc:4; /* location */ + unsigned ext1:1; /* extension */ + unsigned cval:7; /* Cause value */ + } cause; struct charge { /* Charging information */ __u8 toc; /* type of charging info */ __u8 unit[10]; /* charging units */ @@ -111,14 +111,14 @@ typedef struct actcapi_ncpd { * Bit 5-7 = Controller * Bit 8-15 = NCCI */ -#define MAKE_NCCI(plci,contr,ncci) \ - ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8)) +#define MAKE_NCCI(plci, contr, ncci) \ + ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8)) -#define EVAL_NCCI(fakencci,plci,contr,ncci) { \ - plci = fakencci & 0x1f; \ - contr = (fakencci >> 5) & 0x7; \ - ncci = (fakencci >> 8) & 0xff; \ -} +#define EVAL_NCCI(fakencci, plci, contr, ncci) { \ + plci = fakencci & 0x1f; \ + contr = (fakencci >> 5) & 0x7; \ + ncci = (fakencci >> 8) & 0xff; \ + } /* * Layout of PLCI field in a B3 DATA CAPI message is different from @@ -128,13 +128,13 @@ typedef struct actcapi_ncpd { * Bit 5-7 = Controller * Bit 8-15 = reserved (must be 0) */ -#define MAKE_PLCI(plci,contr) \ - ((plci & 0x1f) | ((contr & 0x7) << 5)) +#define MAKE_PLCI(plci, contr) \ + ((plci & 0x1f) | ((contr & 0x7) << 5)) -#define EVAL_PLCI(fakeplci,plci,contr) { \ - plci = fakeplci & 0x1f; \ - contr = (fakeplci >> 5) & 0x7; \ -} +#define EVAL_PLCI(fakeplci, plci, contr) { \ + plci = fakeplci & 0x1f; \ + contr = (fakeplci >> 5) & 0x7; \ + } typedef struct actcapi_msg { actcapi_msghdr hdr; diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c index 05ed72c4cf59..b4147c0b14b7 100644 --- a/drivers/isdn/act2000/module.c +++ b/drivers/isdn/act2000/module.c @@ -4,7 +4,7 @@ * * Author Fritz Elfert * Copyright by Fritz Elfert - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -21,8 +21,8 @@ static unsigned short act2000_isa_ports[] = { - 0x0200, 0x0240, 0x0280, 0x02c0, 0x0300, 0x0340, 0x0380, - 0xcfe0, 0xcfa0, 0xcf60, 0xcf20, 0xcee0, 0xcea0, 0xce60, + 0x0200, 0x0240, 0x0280, 0x02c0, 0x0300, 0x0340, 0x0380, + 0xcfe0, 0xcfa0, 0xcf60, 0xcf20, 0xcee0, 0xcea0, 0xce60, }; static act2000_card *cards = (act2000_card *) NULL; @@ -33,14 +33,14 @@ static int act_port = -1; /* -1 = Autoprobe */ static int act_irq = -1; static char *act_id = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; -MODULE_DESCRIPTION( "ISDN4Linux: Driver for IBM Active 2000 ISDN card"); -MODULE_AUTHOR( "Fritz Elfert"); -MODULE_LICENSE( "GPL"); +MODULE_DESCRIPTION("ISDN4Linux: Driver for IBM Active 2000 ISDN card"); +MODULE_AUTHOR("Fritz Elfert"); +MODULE_LICENSE("GPL"); MODULE_PARM_DESC(act_bus, "BusType of first card, 1=ISA, 2=MCA, 3=PCMCIA, currently only ISA"); MODULE_PARM_DESC(membase, "Base port address of first card"); MODULE_PARM_DESC(act_irq, "IRQ of first card"); -MODULE_PARM_DESC(act_id, "ID-String of first card"); -module_param(act_bus, int, 0); +MODULE_PARM_DESC(act_id, "ID-String of first card"); +module_param(act_bus, int, 0); module_param(act_port, int, 0); module_param(act_irq, int, 0); module_param(act_id, charp, 0); @@ -51,7 +51,7 @@ static act2000_chan * find_channel(act2000_card *card, int channel) { if ((channel >= 0) && (channel < ACT2000_BCH)) - return &(card->bch[channel]); + return &(card->bch[channel]); printk(KERN_WARNING "act2000: Invalid channel %d\n", channel); return NULL; } @@ -84,7 +84,7 @@ act2000_clear_msn(act2000_card *card) static __u16 act2000_find_msn(act2000_card *card, char *msn, int ia5) { - struct msn_entry *p = card->msn_list; + struct msn_entry *p = card->msn_list; __u8 eaz = '0'; while (p) { @@ -107,14 +107,14 @@ act2000_find_msn(act2000_card *card, char *msn, int ia5) char * act2000_find_eaz(act2000_card *card, char eaz) { - struct msn_entry *p = card->msn_list; + struct msn_entry *p = card->msn_list; while (p) { if (p->eaz == eaz) - return(p->msn); + return (p->msn); p = p->next; } - return("\0"); + return ("\0"); } /* @@ -126,11 +126,11 @@ act2000_find_eaz(act2000_card *card, char eaz) static int act2000_set_msn(act2000_card *card, char *eazmsn) { - struct msn_entry *p = card->msn_list; - struct msn_entry *q = NULL; + struct msn_entry *p = card->msn_list; + struct msn_entry *q = NULL; unsigned long flags; int i; - + if (!strlen(eazmsn)) return 0; if (strlen(eazmsn) > 16) @@ -138,7 +138,7 @@ act2000_set_msn(act2000_card *card, char *eazmsn) for (i = 0; i < strlen(eazmsn); i++) if (!isdigit(eazmsn[i])) return -EINVAL; - if (strlen(eazmsn) == 1) { + if (strlen(eazmsn) == 1) { /* Delete a single MSN */ while (p) { if (p->eaz == eazmsn[0]) { @@ -158,7 +158,7 @@ act2000_set_msn(act2000_card *card, char *eazmsn) p = p->next; } return 0; - } + } /* Add a single MSN */ while (p) { /* Found in list, replace MSN */ @@ -198,14 +198,14 @@ act2000_transmit(struct work_struct *work) container_of(work, struct act2000_card, snd_tq); switch (card->bus) { - case ACT2000_BUS_ISA: - act2000_isa_send(card); - break; - case ACT2000_BUS_PCMCIA: - case ACT2000_BUS_MCA: - default: - printk(KERN_WARNING - "act2000_transmit: Illegal bustype %d\n", card->bus); + case ACT2000_BUS_ISA: + act2000_isa_send(card); + break; + case ACT2000_BUS_PCMCIA: + case ACT2000_BUS_MCA: + default: + printk(KERN_WARNING + "act2000_transmit: Illegal bustype %d\n", card->bus); } } @@ -216,221 +216,221 @@ act2000_receive(struct work_struct *work) container_of(work, struct act2000_card, poll_tq); switch (card->bus) { - case ACT2000_BUS_ISA: - act2000_isa_receive(card); - break; - case ACT2000_BUS_PCMCIA: - case ACT2000_BUS_MCA: - default: - printk(KERN_WARNING - "act2000_receive: Illegal bustype %d\n", card->bus); + case ACT2000_BUS_ISA: + act2000_isa_receive(card); + break; + case ACT2000_BUS_PCMCIA: + case ACT2000_BUS_MCA: + default: + printk(KERN_WARNING + "act2000_receive: Illegal bustype %d\n", card->bus); } } static void act2000_poll(unsigned long data) { - act2000_card * card = (act2000_card *)data; + act2000_card *card = (act2000_card *)data; unsigned long flags; act2000_receive(&card->poll_tq); spin_lock_irqsave(&card->lock, flags); - mod_timer(&card->ptimer, jiffies+3); + mod_timer(&card->ptimer, jiffies + 3); spin_unlock_irqrestore(&card->lock, flags); } static int -act2000_command(act2000_card * card, isdn_ctrl * c) +act2000_command(act2000_card *card, isdn_ctrl *c) { - ulong a; - act2000_chan *chan; + ulong a; + act2000_chan *chan; act2000_cdef cdef; isdn_ctrl cmd; char tmp[17]; int ret; unsigned long flags; void __user *arg; - - switch (c->command) { - case ISDN_CMD_IOCTL: - memcpy(&a, c->parm.num, sizeof(ulong)); - arg = (void __user *)a; - switch (c->arg) { - case ACT2000_IOCTL_LOADBOOT: - switch (card->bus) { - case ACT2000_BUS_ISA: - ret = act2000_isa_download(card, - arg); - if (!ret) { - card->flags |= ACT2000_FLAGS_LOADED; - if (!(card->flags & ACT2000_FLAGS_IVALID)) { - card->ptimer.expires = jiffies + 3; - card->ptimer.function = act2000_poll; - card->ptimer.data = (unsigned long)card; - add_timer(&card->ptimer); - } - actcapi_manufacturer_req_errh(card); - } - break; - default: - printk(KERN_WARNING - "act2000: Illegal BUS type %d\n", - card->bus); - ret = -EIO; + + switch (c->command) { + case ISDN_CMD_IOCTL: + memcpy(&a, c->parm.num, sizeof(ulong)); + arg = (void __user *)a; + switch (c->arg) { + case ACT2000_IOCTL_LOADBOOT: + switch (card->bus) { + case ACT2000_BUS_ISA: + ret = act2000_isa_download(card, + arg); + if (!ret) { + card->flags |= ACT2000_FLAGS_LOADED; + if (!(card->flags & ACT2000_FLAGS_IVALID)) { + card->ptimer.expires = jiffies + 3; + card->ptimer.function = act2000_poll; + card->ptimer.data = (unsigned long)card; + add_timer(&card->ptimer); } - return ret; - case ACT2000_IOCTL_SETPROTO: - card->ptype = a?ISDN_PTYPE_EURO:ISDN_PTYPE_1TR6; - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return 0; - actcapi_manufacturer_req_net(card); - return 0; - case ACT2000_IOCTL_SETMSN: - if (copy_from_user(tmp, arg, - sizeof(tmp))) - return -EFAULT; - if ((ret = act2000_set_msn(card, tmp))) - return ret; - if (card->flags & ACT2000_FLAGS_RUNNING) - return(actcapi_manufacturer_req_msn(card)); - return 0; - case ACT2000_IOCTL_ADDCARD: - if (copy_from_user(&cdef, arg, - sizeof(cdef))) - return -EFAULT; - if (act2000_addcard(cdef.bus, cdef.port, cdef.irq, cdef.id)) - return -EIO; - return 0; - case ACT2000_IOCTL_TEST: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - return 0; - default: - return -EINVAL; - } - break; - case ISDN_CMD_DIAL: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x0f))) + actcapi_manufacturer_req_errh(card); + } break; - spin_lock_irqsave(&card->lock, flags); - if (chan->fsm_state != ACT2000_STATE_NULL) { - spin_unlock_irqrestore(&card->lock, flags); - printk(KERN_WARNING "Dial on channel with state %d\n", - chan->fsm_state); - return -EBUSY; - } - if (card->ptype == ISDN_PTYPE_EURO) - tmp[0] = act2000_find_msn(card, c->parm.setup.eazmsn, 1); - else - tmp[0] = c->parm.setup.eazmsn[0]; - chan->fsm_state = ACT2000_STATE_OCALL; - chan->callref = 0xffff; - spin_unlock_irqrestore(&card->lock, flags); - ret = actcapi_connect_req(card, chan, c->parm.setup.phone, - tmp[0], c->parm.setup.si1, - c->parm.setup.si2); - if (ret) { - cmd.driver = card->myid; - cmd.command = ISDN_STAT_DHUP; - cmd.arg &= 0x0f; - card->interface.statcallb(&cmd); + default: + printk(KERN_WARNING + "act2000: Illegal BUS type %d\n", + card->bus); + ret = -EIO; } return ret; - case ISDN_CMD_ACCEPTD: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x0f))) - break; - if (chan->fsm_state == ACT2000_STATE_ICALL) - actcapi_select_b2_protocol_req(card, chan); - return 0; - case ISDN_CMD_ACCEPTB: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - return 0; - case ISDN_CMD_HANGUP: + case ACT2000_IOCTL_SETPROTO: + card->ptype = a ? ISDN_PTYPE_EURO : ISDN_PTYPE_1TR6; if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x0f))) - break; - switch (chan->fsm_state) { - case ACT2000_STATE_ICALL: - case ACT2000_STATE_BSETUP: - actcapi_connect_resp(card, chan, 0x15); - break; - case ACT2000_STATE_ACTIVE: - actcapi_disconnect_b3_req(card, chan); - break; - } + return 0; + actcapi_manufacturer_req_net(card); return 0; - case ISDN_CMD_SETEAZ: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x0f))) - break; - if (strlen(c->parm.num)) { - if (card->ptype == ISDN_PTYPE_EURO) { - chan->eazmask = act2000_find_msn(card, c->parm.num, 0); - } - if (card->ptype == ISDN_PTYPE_1TR6) { - int i; - chan->eazmask = 0; - for (i = 0; i < strlen(c->parm.num); i++) - if (isdigit(c->parm.num[i])) - chan->eazmask |= (1 << (c->parm.num[i] - '0')); - } - } else - chan->eazmask = 0x3ff; - actcapi_listen_req(card); + case ACT2000_IOCTL_SETMSN: + if (copy_from_user(tmp, arg, + sizeof(tmp))) + return -EFAULT; + if ((ret = act2000_set_msn(card, tmp))) + return ret; + if (card->flags & ACT2000_FLAGS_RUNNING) + return (actcapi_manufacturer_req_msn(card)); return 0; - case ISDN_CMD_CLREAZ: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x0f))) - break; - chan->eazmask = 0; - actcapi_listen_req(card); + case ACT2000_IOCTL_ADDCARD: + if (copy_from_user(&cdef, arg, + sizeof(cdef))) + return -EFAULT; + if (act2000_addcard(cdef.bus, cdef.port, cdef.irq, cdef.id)) + return -EIO; return 0; - case ISDN_CMD_SETL2: + case ACT2000_IOCTL_TEST: if (!(card->flags & ACT2000_FLAGS_RUNNING)) return -ENODEV; - if (!(chan = find_channel(card, c->arg & 0x0f))) - break; - chan->l2prot = (c->arg >> 8); return 0; - case ISDN_CMD_SETL3: - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - if ((c->arg >> 8) != ISDN_PROTO_L3_TRANS) { - printk(KERN_WARNING "L3 protocol unknown\n"); - return -1; + default: + return -EINVAL; + } + break; + case ISDN_CMD_DIAL: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + spin_lock_irqsave(&card->lock, flags); + if (chan->fsm_state != ACT2000_STATE_NULL) { + spin_unlock_irqrestore(&card->lock, flags); + printk(KERN_WARNING "Dial on channel with state %d\n", + chan->fsm_state); + return -EBUSY; + } + if (card->ptype == ISDN_PTYPE_EURO) + tmp[0] = act2000_find_msn(card, c->parm.setup.eazmsn, 1); + else + tmp[0] = c->parm.setup.eazmsn[0]; + chan->fsm_state = ACT2000_STATE_OCALL; + chan->callref = 0xffff; + spin_unlock_irqrestore(&card->lock, flags); + ret = actcapi_connect_req(card, chan, c->parm.setup.phone, + tmp[0], c->parm.setup.si1, + c->parm.setup.si2); + if (ret) { + cmd.driver = card->myid; + cmd.command = ISDN_STAT_DHUP; + cmd.arg &= 0x0f; + card->interface.statcallb(&cmd); + } + return ret; + case ISDN_CMD_ACCEPTD: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + if (chan->fsm_state == ACT2000_STATE_ICALL) + actcapi_select_b2_protocol_req(card, chan); + return 0; + case ISDN_CMD_ACCEPTB: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + return 0; + case ISDN_CMD_HANGUP: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + switch (chan->fsm_state) { + case ACT2000_STATE_ICALL: + case ACT2000_STATE_BSETUP: + actcapi_connect_resp(card, chan, 0x15); + break; + case ACT2000_STATE_ACTIVE: + actcapi_disconnect_b3_req(card, chan); + break; + } + return 0; + case ISDN_CMD_SETEAZ: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + if (strlen(c->parm.num)) { + if (card->ptype == ISDN_PTYPE_EURO) { + chan->eazmask = act2000_find_msn(card, c->parm.num, 0); } - if (!(chan = find_channel(card, c->arg & 0x0f))) - break; - chan->l3prot = (c->arg >> 8); - return 0; - } - - return -EINVAL; + if (card->ptype == ISDN_PTYPE_1TR6) { + int i; + chan->eazmask = 0; + for (i = 0; i < strlen(c->parm.num); i++) + if (isdigit(c->parm.num[i])) + chan->eazmask |= (1 << (c->parm.num[i] - '0')); + } + } else + chan->eazmask = 0x3ff; + actcapi_listen_req(card); + return 0; + case ISDN_CMD_CLREAZ: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + chan->eazmask = 0; + actcapi_listen_req(card); + return 0; + case ISDN_CMD_SETL2: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + chan->l2prot = (c->arg >> 8); + return 0; + case ISDN_CMD_SETL3: + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + if ((c->arg >> 8) != ISDN_PROTO_L3_TRANS) { + printk(KERN_WARNING "L3 protocol unknown\n"); + return -1; + } + if (!(chan = find_channel(card, c->arg & 0x0f))) + break; + chan->l3prot = (c->arg >> 8); + return 0; + } + + return -EINVAL; } static int act2000_sendbuf(act2000_card *card, int channel, int ack, struct sk_buff *skb) { - struct sk_buff *xmit_skb; - int len; - act2000_chan *chan; + struct sk_buff *xmit_skb; + int len; + act2000_chan *chan; actcapi_msg *msg; - if (!(chan = find_channel(card, channel))) + if (!(chan = find_channel(card, channel))) + return -1; + if (chan->fsm_state != ACT2000_STATE_ACTIVE) return -1; - if (chan->fsm_state != ACT2000_STATE_ACTIVE) - return -1; - len = skb->len; - if ((chan->queued + len) >= ACT2000_MAX_QUEUED) - return 0; + len = skb->len; + if ((chan->queued + len) >= ACT2000_MAX_QUEUED) + return 0; if (!len) return 0; if (skb_headroom(skb) < 19) { @@ -462,28 +462,28 @@ act2000_sendbuf(act2000_card *card, int channel, int ack, struct sk_buff *skb) msg->msg.data_b3_req.fakencci = MAKE_NCCI(chan->plci, 0, chan->ncci); msg->msg.data_b3_req.flags = ack; /* Will be set to 0 on actual sending */ actcapi_debug_msg(xmit_skb, 1); - chan->queued += len; + chan->queued += len; skb_queue_tail(&card->sndq, xmit_skb); act2000_schedule_tx(card); - return len; + return len; } /* Read the Status-replies from the Interface */ static int -act2000_readstatus(u_char __user * buf, int len, act2000_card * card) +act2000_readstatus(u_char __user *buf, int len, act2000_card *card) { - int count; - u_char __user *p; + int count; + u_char __user *p; - for (p = buf, count = 0; count < len; p++, count++) { - if (card->status_buf_read == card->status_buf_write) - return count; + for (p = buf, count = 0; count < len; p++, count++) { + if (card->status_buf_read == card->status_buf_write) + return count; put_user(*card->status_buf_read++, p); - if (card->status_buf_read > card->status_buf_end) - card->status_buf_read = card->status_buf; - } - return count; + if (card->status_buf_read > card->status_buf_end) + card->status_buf_read = card->status_buf; + } + return count; } /* @@ -492,75 +492,75 @@ act2000_readstatus(u_char __user * buf, int len, act2000_card * card) static inline act2000_card * act2000_findcard(int driverid) { - act2000_card *p = cards; - - while (p) { - if (p->myid == driverid) - return p; - p = p->next; - } - return (act2000_card *) 0; + act2000_card *p = cards; + + while (p) { + if (p->myid == driverid) + return p; + p = p->next; + } + return (act2000_card *) 0; } /* * Wrapper functions for interface to linklevel */ static int -if_command(isdn_ctrl * c) +if_command(isdn_ctrl *c) { - act2000_card *card = act2000_findcard(c->driver); - - if (card) - return (act2000_command(card, c)); - printk(KERN_ERR - "act2000: if_command %d called with invalid driverId %d!\n", - c->command, c->driver); - return -ENODEV; + act2000_card *card = act2000_findcard(c->driver); + + if (card) + return (act2000_command(card, c)); + printk(KERN_ERR + "act2000: if_command %d called with invalid driverId %d!\n", + c->command, c->driver); + return -ENODEV; } static int if_writecmd(const u_char __user *buf, int len, int id, int channel) { - act2000_card *card = act2000_findcard(id); - - if (card) { - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - return (len); - } - printk(KERN_ERR - "act2000: if_writecmd called with invalid driverId!\n"); - return -ENODEV; + act2000_card *card = act2000_findcard(id); + + if (card) { + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + return (len); + } + printk(KERN_ERR + "act2000: if_writecmd called with invalid driverId!\n"); + return -ENODEV; } static int -if_readstatus(u_char __user * buf, int len, int id, int channel) +if_readstatus(u_char __user *buf, int len, int id, int channel) { - act2000_card *card = act2000_findcard(id); - - if (card) { - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; - return (act2000_readstatus(buf, len, card)); - } - printk(KERN_ERR - "act2000: if_readstatus called with invalid driverId!\n"); - return -ENODEV; + act2000_card *card = act2000_findcard(id); + + if (card) { + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; + return (act2000_readstatus(buf, len, card)); + } + printk(KERN_ERR + "act2000: if_readstatus called with invalid driverId!\n"); + return -ENODEV; } static int if_sendbuf(int id, int channel, int ack, struct sk_buff *skb) { - act2000_card *card = act2000_findcard(id); - - if (card) { - if (!(card->flags & ACT2000_FLAGS_RUNNING)) - return -ENODEV; + act2000_card *card = act2000_findcard(id); + + if (card) { + if (!(card->flags & ACT2000_FLAGS_RUNNING)) + return -ENODEV; return (act2000_sendbuf(card, channel, ack, skb)); - } - printk(KERN_ERR - "act2000: if_sendbuf called with invalid driverId!\n"); - return -ENODEV; + } + printk(KERN_ERR + "act2000: if_sendbuf called with invalid driverId!\n"); + return -ENODEV; } @@ -572,14 +572,14 @@ static void act2000_alloccard(int bus, int port, int irq, char *id) { int i; - act2000_card *card; - if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) { - printk(KERN_WARNING + act2000_card *card; + if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) { + printk(KERN_WARNING "act2000: (%s) Could not allocate card-struct.\n", id); - return; - } - spin_lock_init(&card->lock); - spin_lock_init(&card->mnlock); + return; + } + spin_lock_init(&card->lock); + spin_lock_init(&card->mnlock); skb_queue_head_init(&card->sndq); skb_queue_head_init(&card->rcvq); skb_queue_head_init(&card->ackq); @@ -588,82 +588,82 @@ act2000_alloccard(int bus, int port, int irq, char *id) INIT_WORK(&card->poll_tq, act2000_receive); init_timer(&card->ptimer); card->interface.owner = THIS_MODULE; - card->interface.channels = ACT2000_BCH; - card->interface.maxbufsize = 4000; - card->interface.command = if_command; - card->interface.writebuf_skb = if_sendbuf; - card->interface.writecmd = if_writecmd; - card->interface.readstat = if_readstatus; - card->interface.features = + card->interface.channels = ACT2000_BCH; + card->interface.maxbufsize = 4000; + card->interface.command = if_command; + card->interface.writebuf_skb = if_sendbuf; + card->interface.writecmd = if_writecmd; + card->interface.readstat = if_readstatus; + card->interface.features = ISDN_FEATURE_L2_X75I | ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L3_TRANS | ISDN_FEATURE_P_UNKNOWN; - card->interface.hl_hdrlen = 20; - card->ptype = ISDN_PTYPE_EURO; - strlcpy(card->interface.id, id, sizeof(card->interface.id)); - for (i=0; ibch[i].plci = 0x8000; - card->bch[i].ncci = 0x8000; - card->bch[i].l2prot = ISDN_PROTO_L2_X75I; - card->bch[i].l3prot = ISDN_PROTO_L3_TRANS; - } - card->myid = -1; - card->bus = bus; - card->port = port; - card->irq = irq; - card->next = cards; - cards = card; + card->interface.hl_hdrlen = 20; + card->ptype = ISDN_PTYPE_EURO; + strlcpy(card->interface.id, id, sizeof(card->interface.id)); + for (i = 0; i < ACT2000_BCH; i++) { + card->bch[i].plci = 0x8000; + card->bch[i].ncci = 0x8000; + card->bch[i].l2prot = ISDN_PROTO_L2_X75I; + card->bch[i].l3prot = ISDN_PROTO_L3_TRANS; + } + card->myid = -1; + card->bus = bus; + card->port = port; + card->irq = irq; + card->next = cards; + cards = card; } /* * register card at linklevel */ static int -act2000_registercard(act2000_card * card) +act2000_registercard(act2000_card *card) { - switch (card->bus) { - case ACT2000_BUS_ISA: - break; - case ACT2000_BUS_MCA: - case ACT2000_BUS_PCMCIA: - default: - printk(KERN_WARNING - "act2000: Illegal BUS type %d\n", - card->bus); - return -1; - } - if (!register_isdn(&card->interface)) { - printk(KERN_WARNING - "act2000: Unable to register %s\n", - card->interface.id); - return -1; - } - card->myid = card->interface.channels; - sprintf(card->regname, "act2000-isdn (%s)", card->interface.id); - return 0; + switch (card->bus) { + case ACT2000_BUS_ISA: + break; + case ACT2000_BUS_MCA: + case ACT2000_BUS_PCMCIA: + default: + printk(KERN_WARNING + "act2000: Illegal BUS type %d\n", + card->bus); + return -1; + } + if (!register_isdn(&card->interface)) { + printk(KERN_WARNING + "act2000: Unable to register %s\n", + card->interface.id); + return -1; + } + card->myid = card->interface.channels; + sprintf(card->regname, "act2000-isdn (%s)", card->interface.id); + return 0; } static void -unregister_card(act2000_card * card) +unregister_card(act2000_card *card) { - isdn_ctrl cmd; + isdn_ctrl cmd; - cmd.command = ISDN_STAT_UNLOAD; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - switch (card->bus) { - case ACT2000_BUS_ISA: - act2000_isa_release(card); - break; - case ACT2000_BUS_MCA: - case ACT2000_BUS_PCMCIA: - default: - printk(KERN_WARNING - "act2000: Invalid BUS type %d\n", - card->bus); - break; - } + cmd.command = ISDN_STAT_UNLOAD; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + switch (card->bus) { + case ACT2000_BUS_ISA: + act2000_isa_release(card); + break; + case ACT2000_BUS_MCA: + case ACT2000_BUS_PCMCIA: + default: + printk(KERN_WARNING + "act2000: Invalid BUS type %d\n", + card->bus); + break; + } } static int @@ -690,23 +690,23 @@ act2000_addcard(int bus, int port, int irq, char *id) for (i = 0; i < ARRAY_SIZE(act2000_isa_ports); i++) if (act2000_isa_detect(act2000_isa_ports[i])) { printk(KERN_INFO "act2000: Detected " - "ISA card at port 0x%x\n", - act2000_isa_ports[i]); + "ISA card at port 0x%x\n", + act2000_isa_ports[i]); act2000_alloccard(bus, - act2000_isa_ports[i], irq, id); + act2000_isa_ports[i], irq, id); } break; case ACT2000_BUS_MCA: case ACT2000_BUS_PCMCIA: default: printk(KERN_WARNING - "act2000: addcard: Invalid BUS type %d\n", bus); + "act2000: addcard: Invalid BUS type %d\n", bus); } } if (!cards) return 1; - p = cards; - while (p) { + p = cards; + while (p) { initialized = 0; if (!p->interface.statcallb) { /* Not yet registered. @@ -714,99 +714,99 @@ act2000_addcard(int bus, int port, int irq, char *id) */ added++; switch (p->bus) { - case ACT2000_BUS_ISA: - if (act2000_isa_detect(p->port)) { - if (act2000_registercard(p)) - break; - if (act2000_isa_config_port(p, p->port)) { - printk(KERN_WARNING - "act2000: Could not request port 0x%04x\n", - p->port); - unregister_card(p); - p->interface.statcallb = NULL; - break; - } - if (act2000_isa_config_irq(p, p->irq)) { - printk(KERN_INFO - "act2000: No IRQ available, fallback to polling\n"); - /* Fall back to polled operation */ - p->irq = 0; - } - printk(KERN_INFO - "act2000: ISA" - "-type card at port " - "0x%04x ", + case ACT2000_BUS_ISA: + if (act2000_isa_detect(p->port)) { + if (act2000_registercard(p)) + break; + if (act2000_isa_config_port(p, p->port)) { + printk(KERN_WARNING + "act2000: Could not request port 0x%04x\n", p->port); - if (p->irq) - printk("irq %d\n", p->irq); - else - printk("polled\n"); - initialized = 1; + unregister_card(p); + p->interface.statcallb = NULL; + break; + } + if (act2000_isa_config_irq(p, p->irq)) { + printk(KERN_INFO + "act2000: No IRQ available, fallback to polling\n"); + /* Fall back to polled operation */ + p->irq = 0; } - break; - case ACT2000_BUS_MCA: - case ACT2000_BUS_PCMCIA: - default: - printk(KERN_WARNING - "act2000: addcard: Invalid BUS type %d\n", - p->bus); + printk(KERN_INFO + "act2000: ISA" + "-type card at port " + "0x%04x ", + p->port); + if (p->irq) + printk("irq %d\n", p->irq); + else + printk("polled\n"); + initialized = 1; + } + break; + case ACT2000_BUS_MCA: + case ACT2000_BUS_PCMCIA: + default: + printk(KERN_WARNING + "act2000: addcard: Invalid BUS type %d\n", + p->bus); } } else /* Card already initialized */ initialized = 1; - if (initialized) { + if (initialized) { /* Init OK, next card ... */ - q = p; - p = p->next; - } else { - /* Init failed, remove card from list, free memory */ - printk(KERN_WARNING - "act2000: Initialization of %s failed\n", - p->interface.id); - if (q) { - q->next = p->next; - kfree(p); - p = q->next; - } else { - cards = p->next; - kfree(p); - p = cards; - } + q = p; + p = p->next; + } else { + /* Init failed, remove card from list, free memory */ + printk(KERN_WARNING + "act2000: Initialization of %s failed\n", + p->interface.id); + if (q) { + q->next = p->next; + kfree(p); + p = q->next; + } else { + cards = p->next; + kfree(p); + p = cards; + } failed++; - } + } } - return (added - failed); + return (added - failed); } #define DRIVERNAME "IBM Active 2000 ISDN driver" static int __init act2000_init(void) { - printk(KERN_INFO "%s\n", DRIVERNAME); - if (!cards) + printk(KERN_INFO "%s\n", DRIVERNAME); + if (!cards) act2000_addcard(act_bus, act_port, act_irq, act_id); - if (!cards) - printk(KERN_INFO "act2000: No cards defined yet\n"); - return 0; + if (!cards) + printk(KERN_INFO "act2000: No cards defined yet\n"); + return 0; } static void __exit act2000_exit(void) { - act2000_card *card = cards; - act2000_card *last; - while (card) { - unregister_card(card); + act2000_card *card = cards; + act2000_card *last; + while (card) { + unregister_card(card); del_timer(&card->ptimer); - card = card->next; - } - card = cards; - while (card) { - last = card; - card = card->next; + card = card->next; + } + card = cards; + while (card) { + last = card; + card = card->next; act2000_clear_msn(last); - kfree(last); - } - printk(KERN_INFO "%s unloaded\n", DRIVERNAME); + kfree(last); + } + printk(KERN_INFO "%s unloaded\n", DRIVERNAME); } module_init(act2000_init); diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index e44933d58790..d33a70c49180 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -164,7 +164,7 @@ static int capiminor_del_ack(struct capiminor *mp, u16 datahandle) spin_lock_bh(&mp->ackqlock); list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { - if (p->datahandle == datahandle) { + if (p->datahandle == datahandle) { list_del(&p->list); mp->nack--; spin_unlock_bh(&mp->ackqlock); @@ -199,8 +199,8 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) unsigned int minor; mp = kzalloc(sizeof(*mp), GFP_KERNEL); - if (!mp) { - printk(KERN_ERR "capi: can't alloc capiminor\n"); + if (!mp) { + printk(KERN_ERR "capi: can't alloc capiminor\n"); return NULL; } @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb) struct sk_buff *nskb; nskb = alloc_skb(CAPI_DATA_B3_RESP_LEN, GFP_KERNEL); if (nskb) { - u16 datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4+4+2); + u16 datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 4 + 2); unsigned char *s = skb_put(nskb, CAPI_DATA_B3_RESP_LEN); capimsg_setu16(s, 0, CAPI_DATA_B3_RESP_LEN); capimsg_setu16(s, 2, mp->ap->applid); @@ -418,7 +418,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) pr_debug("capi: currently no receiver\n"); return -1; } - + ld = tty_ldisc_ref(tty); if (!ld) { /* fatal error, do not requeue */ @@ -459,7 +459,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) ld->ops->receive_buf(tty, skb->data, NULL, skb->len); } else { printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n", - errcode); + errcode); kfree_skb(nskb); if (errcode == CAPI_SENDQUEUEFULL) @@ -618,7 +618,7 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) goto unlock_out; } if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND) { - datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+4+2); + datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 4 + 2); pr_debug("capi_signal: DATA_B3_IND %u len=%d\n", datahandle, skb->len-CAPIMSG_LEN(skb->data)); skb_queue_tail(&mp->inqueue, skb); @@ -627,10 +627,10 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) } else if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_CONF) { - datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4); + datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4); pr_debug("capi_signal: DATA_B3_CONF %u 0x%x\n", datahandle, - CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+2)); + CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 2)); kfree_skb(skb); capiminor_del_ack(mp, datahandle); tty = tty_port_tty_get(&mp->port); @@ -669,7 +669,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) if (file->f_flags & O_NONBLOCK) return -EAGAIN; err = wait_event_interruptible(cdev->recvwait, - (skb = skb_dequeue(&cdev->recvqueue))); + (skb = skb_dequeue(&cdev->recvqueue))); if (err) return err; } @@ -736,7 +736,7 @@ capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos } static unsigned int -capi_poll(struct file *file, poll_table * wait) +capi_poll(struct file *file, poll_table *wait) { struct capidev *cdev = file->private_data; unsigned int mask = 0; @@ -786,75 +786,75 @@ capi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return retval; case CAPI_GET_VERSION: - { - if (copy_from_user(&data.contr, argp, - sizeof(data.contr))) - return -EFAULT; - cdev->errcode = capi20_get_version(data.contr, &data.version); - if (cdev->errcode) - return -EIO; - if (copy_to_user(argp, &data.version, - sizeof(data.version))) - return -EFAULT; - } - return 0; + { + if (copy_from_user(&data.contr, argp, + sizeof(data.contr))) + return -EFAULT; + cdev->errcode = capi20_get_version(data.contr, &data.version); + if (cdev->errcode) + return -EIO; + if (copy_to_user(argp, &data.version, + sizeof(data.version))) + return -EFAULT; + } + return 0; case CAPI_GET_SERIAL: - { - if (copy_from_user(&data.contr, argp, - sizeof(data.contr))) - return -EFAULT; - cdev->errcode = capi20_get_serial (data.contr, data.serial); - if (cdev->errcode) - return -EIO; - if (copy_to_user(argp, data.serial, - sizeof(data.serial))) - return -EFAULT; - } - return 0; + { + if (copy_from_user(&data.contr, argp, + sizeof(data.contr))) + return -EFAULT; + cdev->errcode = capi20_get_serial(data.contr, data.serial); + if (cdev->errcode) + return -EIO; + if (copy_to_user(argp, data.serial, + sizeof(data.serial))) + return -EFAULT; + } + return 0; case CAPI_GET_PROFILE: - { - if (copy_from_user(&data.contr, argp, - sizeof(data.contr))) - return -EFAULT; + { + if (copy_from_user(&data.contr, argp, + sizeof(data.contr))) + return -EFAULT; - if (data.contr == 0) { - cdev->errcode = capi20_get_profile(data.contr, &data.profile); - if (cdev->errcode) - return -EIO; + if (data.contr == 0) { + cdev->errcode = capi20_get_profile(data.contr, &data.profile); + if (cdev->errcode) + return -EIO; - retval = copy_to_user(argp, - &data.profile.ncontroller, - sizeof(data.profile.ncontroller)); + retval = copy_to_user(argp, + &data.profile.ncontroller, + sizeof(data.profile.ncontroller)); - } else { - cdev->errcode = capi20_get_profile(data.contr, &data.profile); - if (cdev->errcode) - return -EIO; + } else { + cdev->errcode = capi20_get_profile(data.contr, &data.profile); + if (cdev->errcode) + return -EIO; - retval = copy_to_user(argp, &data.profile, - sizeof(data.profile)); - } - if (retval) - return -EFAULT; + retval = copy_to_user(argp, &data.profile, + sizeof(data.profile)); } - return 0; + if (retval) + return -EFAULT; + } + return 0; case CAPI_GET_MANUFACTURER: - { - if (copy_from_user(&data.contr, argp, - sizeof(data.contr))) - return -EFAULT; - cdev->errcode = capi20_get_manufacturer(data.contr, data.manufacturer); - if (cdev->errcode) - return -EIO; + { + if (copy_from_user(&data.contr, argp, + sizeof(data.contr))) + return -EFAULT; + cdev->errcode = capi20_get_manufacturer(data.contr, data.manufacturer); + if (cdev->errcode) + return -EIO; - if (copy_to_user(argp, data.manufacturer, - sizeof(data.manufacturer))) - return -EFAULT; + if (copy_to_user(argp, data.manufacturer, + sizeof(data.manufacturer))) + return -EFAULT; - } - return 0; + } + return 0; case CAPI_GET_ERRCODE: data.errcode = cdev->errcode; cdev->errcode = CAPI_NOERROR; @@ -871,15 +871,15 @@ capi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -ENXIO; case CAPI_MANUFACTURER_CMD: - { - struct capi_manufacturer_cmd mcmd; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (copy_from_user(&mcmd, argp, sizeof(mcmd))) - return -EFAULT; - return capi20_manufacturer(mcmd.cmd, mcmd.data); - } - return 0; + { + struct capi_manufacturer_cmd mcmd; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user(&mcmd, argp, sizeof(mcmd))) + return -EFAULT; + return capi20_manufacturer(mcmd.cmd, mcmd.data); + } + return 0; case CAPI_SET_FLAGS: case CAPI_CLR_FLAGS: { @@ -1070,7 +1070,7 @@ static int capinc_tty_write(struct tty_struct *tty, mp->outbytes += skb->len; } - skb = alloc_skb(CAPI_DATA_B3_REQ_LEN+count, GFP_ATOMIC); + skb = alloc_skb(CAPI_DATA_B3_REQ_LEN + count, GFP_ATOMIC); if (!skb) { printk(KERN_ERR "capinc_tty_write: alloc_skb failed\n"); spin_unlock_bh(&mp->outlock); @@ -1111,7 +1111,7 @@ static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) invoke_send = true; } - skb = alloc_skb(CAPI_DATA_B3_REQ_LEN+CAPI_MAX_BLKSIZE, GFP_ATOMIC); + skb = alloc_skb(CAPI_DATA_B3_REQ_LEN + CAPI_MAX_BLKSIZE, GFP_ATOMIC); if (skb) { skb_reserve(skb, CAPI_DATA_B3_REQ_LEN); *(skb_put(skb, 1)) = ch; @@ -1175,12 +1175,12 @@ static int capinc_tty_chars_in_buffer(struct tty_struct *tty) } static int capinc_tty_ioctl(struct tty_struct *tty, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { return -ENOIOCTLCMD; } -static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios * old) +static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old) { pr_debug("capinc_tty_set_termios\n"); } @@ -1344,18 +1344,18 @@ static inline void capinc_tty_exit(void) { } */ static int capi20_proc_show(struct seq_file *m, void *v) { - struct capidev *cdev; + struct capidev *cdev; struct list_head *l; mutex_lock(&capidev_list_lock); list_for_each(l, &capidev_list) { cdev = list_entry(l, struct capidev, list); seq_printf(m, "0 %d %lu %lu %lu %lu\n", - cdev->ap.applid, - cdev->ap.nrecvctlpkt, - cdev->ap.nrecvdatapkt, - cdev->ap.nsentctlpkt, - cdev->ap.nsentdatapkt); + cdev->ap.applid, + cdev->ap.nrecvctlpkt, + cdev->ap.nrecvdatapkt, + cdev->ap.nsentctlpkt, + cdev->ap.nsentdatapkt); } mutex_unlock(&capidev_list_lock); return 0; @@ -1450,9 +1450,9 @@ static int __init capi_init(void) proc_init(); #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - compileinfo = " (middleware)"; + compileinfo = " (middleware)"; #else - compileinfo = " (no middleware)"; + compileinfo = " (no middleware)"; #endif printk(KERN_NOTICE "CAPI 2.0 started up with major %d%s\n", capi_major, compileinfo); diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 92607ed25e2e..6f5016b479f8 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c @@ -40,7 +40,7 @@ static int debugmode = 0; MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux"); MODULE_AUTHOR("Carsten Paeth"); MODULE_LICENSE("GPL"); -module_param(debugmode, uint, S_IRUGO|S_IWUSR); +module_param(debugmode, uint, S_IRUGO | S_IWUSR); /* -------- type definitions ----------------------------------------- */ @@ -64,7 +64,7 @@ struct capidrv_contr { int state; u32 cipmask; u32 cipmask2; - struct timer_list listentimer; + struct timer_list listentimer; /* * ID of capi message sent @@ -105,9 +105,9 @@ struct capidrv_contr { /* */ u16 datahandle; struct ncci_datahandle_queue { - struct ncci_datahandle_queue *next; - u16 datahandle; - int len; + struct ncci_datahandle_queue *next; + u16 datahandle; + int len; } *ackqueue; } *ncci_list; } *plcip; @@ -142,7 +142,7 @@ static capidrv_data global; static DEFINE_SPINLOCK(global_lock); static void handle_dtrace_data(capidrv_contr *card, - int send, int level2, u8 *data, u16 len); + int send, int level2, u8 *data, u16 len); /* -------- convert functions ---------------------------------------- */ @@ -158,11 +158,11 @@ static inline u32 b1prot(int l2, int l3) return 0; case ISDN_PROTO_L2_TRANS: return 1; - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: + case ISDN_PROTO_L2_V11096: + case ISDN_PROTO_L2_V11019: + case ISDN_PROTO_L2_V11038: return 2; - case ISDN_PROTO_L2_FAX: + case ISDN_PROTO_L2_FAX: return 4; case ISDN_PROTO_L2_MODEM: return 8; @@ -179,12 +179,12 @@ static inline u32 b2prot(int l2, int l3) return 0; case ISDN_PROTO_L2_HDLC: case ISDN_PROTO_L2_TRANS: - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: + case ISDN_PROTO_L2_V11096: + case ISDN_PROTO_L2_V11019: + case ISDN_PROTO_L2_V11038: case ISDN_PROTO_L2_MODEM: return 1; - case ISDN_PROTO_L2_FAX: + case ISDN_PROTO_L2_FAX: return 4; } } @@ -197,13 +197,13 @@ static inline u32 b3prot(int l2, int l3) case ISDN_PROTO_L2_X75BUI: case ISDN_PROTO_L2_HDLC: case ISDN_PROTO_L2_TRANS: - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: + case ISDN_PROTO_L2_V11096: + case ISDN_PROTO_L2_V11019: + case ISDN_PROTO_L2_V11038: case ISDN_PROTO_L2_MODEM: default: return 0; - case ISDN_PROTO_L2_FAX: + case ISDN_PROTO_L2_FAX: return 4; } } @@ -231,38 +231,38 @@ static _cstruct b1config(int l2, int l3) case ISDN_PROTO_L2_TRANS: default: return NULL; - case ISDN_PROTO_L2_V11096: - return b1config_async_v110(9600); - case ISDN_PROTO_L2_V11019: - return b1config_async_v110(19200); - case ISDN_PROTO_L2_V11038: - return b1config_async_v110(38400); + case ISDN_PROTO_L2_V11096: + return b1config_async_v110(9600); + case ISDN_PROTO_L2_V11019: + return b1config_async_v110(19200); + case ISDN_PROTO_L2_V11038: + return b1config_async_v110(38400); } } static inline u16 si2cip(u8 si1, u8 si2) { static const u8 cip[17][5] = - { - /* 0 1 2 3 4 */ - {0, 0, 0, 0, 0}, /*0 */ - {16, 16, 4, 26, 16}, /*1 */ - {17, 17, 17, 4, 4}, /*2 */ - {2, 2, 2, 2, 2}, /*3 */ - {18, 18, 18, 18, 18}, /*4 */ - {2, 2, 2, 2, 2}, /*5 */ - {0, 0, 0, 0, 0}, /*6 */ - {2, 2, 2, 2, 2}, /*7 */ - {2, 2, 2, 2, 2}, /*8 */ - {21, 21, 21, 21, 21}, /*9 */ - {19, 19, 19, 19, 19}, /*10 */ - {0, 0, 0, 0, 0}, /*11 */ - {0, 0, 0, 0, 0}, /*12 */ - {0, 0, 0, 0, 0}, /*13 */ - {0, 0, 0, 0, 0}, /*14 */ - {22, 22, 22, 22, 22}, /*15 */ - {27, 27, 27, 28, 27} /*16 */ - }; + { + /* 0 1 2 3 4 */ + {0, 0, 0, 0, 0}, /*0 */ + {16, 16, 4, 26, 16}, /*1 */ + {17, 17, 17, 4, 4}, /*2 */ + {2, 2, 2, 2, 2}, /*3 */ + {18, 18, 18, 18, 18}, /*4 */ + {2, 2, 2, 2, 2}, /*5 */ + {0, 0, 0, 0, 0}, /*6 */ + {2, 2, 2, 2, 2}, /*7 */ + {2, 2, 2, 2, 2}, /*8 */ + {21, 21, 21, 21, 21}, /*9 */ + {19, 19, 19, 19, 19}, /*10 */ + {0, 0, 0, 0, 0}, /*11 */ + {0, 0, 0, 0, 0}, /*12 */ + {0, 0, 0, 0, 0}, /*13 */ + {0, 0, 0, 0, 0}, /*14 */ + {22, 22, 22, 22, 22}, /*15 */ + {27, 27, 27, 28, 27} /*16 */ + }; if (si1 > 16) si1 = 0; if (si2 > 4) @@ -274,10 +274,10 @@ static inline u16 si2cip(u8 si1, u8 si2) static inline u8 cip2si1(u16 cipval) { static const u8 si[32] = - {7, 1, 7, 7, 1, 1, 7, 7, /*0-7 */ - 7, 1, 0, 0, 0, 0, 0, 0, /*8-15 */ - 1, 2, 4, 10, 9, 9, 15, 7, /*16-23 */ - 7, 7, 1, 16, 16, 0, 0, 0}; /*24-31 */ + {7, 1, 7, 7, 1, 1, 7, 7, /*0-7 */ + 7, 1, 0, 0, 0, 0, 0, 0, /*8-15 */ + 1, 2, 4, 10, 9, 9, 15, 7, /*16-23 */ + 7, 7, 1, 16, 16, 0, 0, 0}; /*24-31 */ if (cipval > 31) cipval = 0; /* .... */ @@ -287,10 +287,10 @@ static inline u8 cip2si1(u16 cipval) static inline u8 cip2si2(u16 cipval) { static const u8 si[32] = - {0, 0, 0, 0, 2, 3, 0, 0, /*0-7 */ - 0, 3, 0, 0, 0, 0, 0, 0, /*8-15 */ - 1, 2, 0, 0, 9, 0, 0, 0, /*16-23 */ - 0, 0, 3, 2, 3, 0, 0, 0}; /*24-31 */ + {0, 0, 0, 0, 2, 3, 0, 0, /*0-7 */ + 0, 3, 0, 0, 0, 0, 0, 0, /*8-15 */ + 1, 2, 0, 0, 9, 0, 0, 0, /*16-23 */ + 0, 0, 3, 2, 3, 0, 0, 0}; /*24-31 */ if (cipval > 31) cipval = 0; /* .... */ @@ -302,7 +302,7 @@ static inline u8 cip2si2(u16 cipval) static inline capidrv_contr *findcontrbydriverid(int driverid) { - unsigned long flags; + unsigned long flags; capidrv_contr *p; spin_lock_irqsave(&global_lock, flags); @@ -329,7 +329,7 @@ static capidrv_contr *findcontrbynumber(u32 contr) /* -------- plci management ------------------------------------------ */ -static capidrv_plci *new_plci(capidrv_contr * card, int chan) +static capidrv_plci *new_plci(capidrv_contr *card, int chan) { capidrv_plci *plcip; @@ -349,7 +349,7 @@ static capidrv_plci *new_plci(capidrv_contr * card, int chan) return plcip; } -static capidrv_plci *find_plci_by_plci(capidrv_contr * card, u32 plci) +static capidrv_plci *find_plci_by_plci(capidrv_contr *card, u32 plci) { capidrv_plci *p; for (p = card->plci_list; p; p = p->next) @@ -358,7 +358,7 @@ static capidrv_plci *find_plci_by_plci(capidrv_contr * card, u32 plci) return NULL; } -static capidrv_plci *find_plci_by_msgid(capidrv_contr * card, u16 msgid) +static capidrv_plci *find_plci_by_msgid(capidrv_contr *card, u16 msgid) { capidrv_plci *p; for (p = card->plci_list; p; p = p->next) @@ -367,7 +367,7 @@ static capidrv_plci *find_plci_by_msgid(capidrv_contr * card, u16 msgid) return NULL; } -static capidrv_plci *find_plci_by_ncci(capidrv_contr * card, u32 ncci) +static capidrv_plci *find_plci_by_ncci(capidrv_contr *card, u32 ncci) { capidrv_plci *p; for (p = card->plci_list; p; p = p->next) @@ -376,7 +376,7 @@ static capidrv_plci *find_plci_by_ncci(capidrv_contr * card, u32 ncci) return NULL; } -static void free_plci(capidrv_contr * card, capidrv_plci * plcip) +static void free_plci(capidrv_contr *card, capidrv_plci *plcip) { capidrv_plci **pp; @@ -396,8 +396,8 @@ static void free_plci(capidrv_contr * card, capidrv_plci * plcip) /* -------- ncci management ------------------------------------------ */ -static inline capidrv_ncci *new_ncci(capidrv_contr * card, - capidrv_plci * plcip, +static inline capidrv_ncci *new_ncci(capidrv_contr *card, + capidrv_plci *plcip, u32 ncci) { capidrv_ncci *nccip; @@ -421,7 +421,7 @@ static inline capidrv_ncci *new_ncci(capidrv_contr * card, return nccip; } -static inline capidrv_ncci *find_ncci(capidrv_contr * card, u32 ncci) +static inline capidrv_ncci *find_ncci(capidrv_contr *card, u32 ncci) { capidrv_plci *plcip; capidrv_ncci *p; @@ -435,7 +435,7 @@ static inline capidrv_ncci *find_ncci(capidrv_contr * card, u32 ncci) return NULL; } -static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr * card, +static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr *card, u32 ncci, u16 msgid) { capidrv_plci *plcip; @@ -450,7 +450,7 @@ static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr * card, return NULL; } -static void free_ncci(capidrv_contr * card, struct capidrv_ncci *nccip) +static void free_ncci(capidrv_contr *card, struct capidrv_ncci *nccip) { struct capidrv_ncci **pp; @@ -465,20 +465,20 @@ static void free_ncci(capidrv_contr * card, struct capidrv_ncci *nccip) } static int capidrv_add_ack(struct capidrv_ncci *nccip, - u16 datahandle, int len) + u16 datahandle, int len) { struct ncci_datahandle_queue *n, **pp; n = (struct ncci_datahandle_queue *) kmalloc(sizeof(struct ncci_datahandle_queue), GFP_ATOMIC); if (!n) { - printk(KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n"); - return -1; + printk(KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n"); + return -1; } n->next = NULL; n->datahandle = datahandle; n->len = len; - for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) ; + for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next); *pp = n; return 0; } @@ -489,11 +489,11 @@ static int capidrv_del_ack(struct capidrv_ncci *nccip, u16 datahandle) int len; for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) { - if ((*pp)->datahandle == datahandle) { + if ((*pp)->datahandle == datahandle) { p = *pp; len = p->len; *pp = (*pp)->next; - kfree(p); + kfree(p); return len; } } @@ -502,7 +502,7 @@ static int capidrv_del_ack(struct capidrv_ncci *nccip, u16 datahandle) /* -------- convert and send capi message ---------------------------- */ -static void send_message(capidrv_contr * card, _cmsg * cmsg) +static void send_message(capidrv_contr *card, _cmsg *cmsg) { struct sk_buff *skb; size_t len; @@ -529,18 +529,18 @@ struct listenstatechange { static struct listenstatechange listentable[] = { - {ST_LISTEN_NONE, ST_LISTEN_WAIT_CONF, EV_LISTEN_REQ}, - {ST_LISTEN_ACTIVE, ST_LISTEN_ACTIVE_WAIT_CONF, EV_LISTEN_REQ}, - {ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_ERROR}, - {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_ERROR}, - {ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, - {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, - {ST_LISTEN_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, - {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, - {}, + {ST_LISTEN_NONE, ST_LISTEN_WAIT_CONF, EV_LISTEN_REQ}, + {ST_LISTEN_ACTIVE, ST_LISTEN_ACTIVE_WAIT_CONF, EV_LISTEN_REQ}, + {ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_ERROR}, + {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_ERROR}, + {ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, + {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, + {ST_LISTEN_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, + {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, + {}, }; -static void listen_change_state(capidrv_contr * card, int event) +static void listen_change_state(capidrv_contr *card, int event) { struct listenstatechange *p = listentable; while (p->event) { @@ -560,7 +560,7 @@ static void listen_change_state(capidrv_contr * card, int event) /* ------------------------------------------------------------------ */ -static void p0(capidrv_contr * card, capidrv_plci * plci) +static void p0(capidrv_contr *card, capidrv_plci *plci) { isdn_ctrl cmd; @@ -578,71 +578,71 @@ struct plcistatechange { int actstate; int nextstate; int event; - void (*changefunc) (capidrv_contr * card, capidrv_plci * plci); + void (*changefunc)(capidrv_contr *card, capidrv_plci *plci); }; static struct plcistatechange plcitable[] = { - /* P-0 */ - {ST_PLCI_NONE, ST_PLCI_OUTGOING, EV_PLCI_CONNECT_REQ, NULL}, - {ST_PLCI_NONE, ST_PLCI_ALLOCATED, EV_PLCI_FACILITY_IND_UP, NULL}, - {ST_PLCI_NONE, ST_PLCI_INCOMING, EV_PLCI_CONNECT_IND, NULL}, - {ST_PLCI_NONE, ST_PLCI_RESUMEING, EV_PLCI_RESUME_REQ, NULL}, - /* P-0.1 */ - {ST_PLCI_OUTGOING, ST_PLCI_NONE, EV_PLCI_CONNECT_CONF_ERROR, p0}, - {ST_PLCI_OUTGOING, ST_PLCI_ALLOCATED, EV_PLCI_CONNECT_CONF_OK, NULL}, - /* P-1 */ - {ST_PLCI_ALLOCATED, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, - {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, - {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, - {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, - /* P-ACT */ - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, - {ST_PLCI_ACTIVE, ST_PLCI_HELD, EV_PLCI_HOLD_IND, NULL}, - {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_SUSPEND_IND, NULL}, - /* P-2 */ - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, - {ST_PLCI_INCOMING, ST_PLCI_FACILITY_IND, EV_PLCI_FACILITY_IND_UP, NULL}, - {ST_PLCI_INCOMING, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_RESP, NULL}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, - {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CD_IND, NULL}, - /* P-3 */ - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, - {ST_PLCI_FACILITY_IND, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, - {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, - /* P-4 */ - {ST_PLCI_ACCEPTING, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, - {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, - {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, - {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, - /* P-5 */ - {ST_PLCI_DISCONNECTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, - /* P-6 */ - {ST_PLCI_DISCONNECTED, ST_PLCI_NONE, EV_PLCI_DISCONNECT_RESP, p0}, - /* P-0.Res */ - {ST_PLCI_RESUMEING, ST_PLCI_NONE, EV_PLCI_RESUME_CONF_ERROR, p0}, - {ST_PLCI_RESUMEING, ST_PLCI_RESUME, EV_PLCI_RESUME_CONF_OK, NULL}, - /* P-RES */ - {ST_PLCI_RESUME, ST_PLCI_ACTIVE, EV_PLCI_RESUME_IND, NULL}, - /* P-HELD */ - {ST_PLCI_HELD, ST_PLCI_ACTIVE, EV_PLCI_RETRIEVE_IND, NULL}, - {}, + /* P-0 */ + {ST_PLCI_NONE, ST_PLCI_OUTGOING, EV_PLCI_CONNECT_REQ, NULL}, + {ST_PLCI_NONE, ST_PLCI_ALLOCATED, EV_PLCI_FACILITY_IND_UP, NULL}, + {ST_PLCI_NONE, ST_PLCI_INCOMING, EV_PLCI_CONNECT_IND, NULL}, + {ST_PLCI_NONE, ST_PLCI_RESUMEING, EV_PLCI_RESUME_REQ, NULL}, + /* P-0.1 */ + {ST_PLCI_OUTGOING, ST_PLCI_NONE, EV_PLCI_CONNECT_CONF_ERROR, p0}, + {ST_PLCI_OUTGOING, ST_PLCI_ALLOCATED, EV_PLCI_CONNECT_CONF_OK, NULL}, + /* P-1 */ + {ST_PLCI_ALLOCATED, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, + {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + /* P-ACT */ + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_HELD, EV_PLCI_HOLD_IND, NULL}, + {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_SUSPEND_IND, NULL}, + /* P-2 */ + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_FACILITY_IND, EV_PLCI_FACILITY_IND_UP, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_RESP, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CD_IND, NULL}, + /* P-3 */ + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + /* P-4 */ + {ST_PLCI_ACCEPTING, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, + {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, + {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, + {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + /* P-5 */ + {ST_PLCI_DISCONNECTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, + /* P-6 */ + {ST_PLCI_DISCONNECTED, ST_PLCI_NONE, EV_PLCI_DISCONNECT_RESP, p0}, + /* P-0.Res */ + {ST_PLCI_RESUMEING, ST_PLCI_NONE, EV_PLCI_RESUME_CONF_ERROR, p0}, + {ST_PLCI_RESUMEING, ST_PLCI_RESUME, EV_PLCI_RESUME_CONF_OK, NULL}, + /* P-RES */ + {ST_PLCI_RESUME, ST_PLCI_ACTIVE, EV_PLCI_RESUME_IND, NULL}, + /* P-HELD */ + {ST_PLCI_HELD, ST_PLCI_ACTIVE, EV_PLCI_RETRIEVE_IND, NULL}, + {}, }; -static void plci_change_state(capidrv_contr * card, capidrv_plci * plci, int event) +static void plci_change_state(capidrv_contr *card, capidrv_plci *plci, int event) { struct plcistatechange *p = plcitable; while (p->event) { if (plci->state == p->actstate && p->event == event) { if (debugmode) printk(KERN_DEBUG "capidrv-%d: plci_change_state:0x%x %d -> %d\n", - card->contrnr, plci->plci, plci->state, p->nextstate); + card->contrnr, plci->plci, plci->state, p->nextstate); plci->state = p->nextstate; if (p->changefunc) p->changefunc(card, plci); @@ -658,7 +658,7 @@ static void plci_change_state(capidrv_contr * card, capidrv_plci * plci, int eve static _cmsg cmsg; -static void n0(capidrv_contr * card, capidrv_ncci * ncci) +static void n0(capidrv_contr *card, capidrv_ncci *ncci) { isdn_ctrl cmd; @@ -670,7 +670,7 @@ static void n0(capidrv_contr * card, capidrv_ncci * ncci) NULL, /* Keypadfacility */ NULL, /* Useruserdata */ /* $$$$ */ NULL /* Facilitydataarray */ - ); + ); plci_change_state(card, ncci->plcip, EV_PLCI_DISCONNECT_REQ); send_message(card, &cmsg); @@ -687,51 +687,51 @@ struct nccistatechange { int actstate; int nextstate; int event; - void (*changefunc) (capidrv_contr * card, capidrv_ncci * ncci); + void (*changefunc)(capidrv_contr *card, capidrv_ncci *ncci); }; static struct nccistatechange nccitable[] = { - /* N-0 */ - {ST_NCCI_NONE, ST_NCCI_OUTGOING, EV_NCCI_CONNECT_B3_REQ, NULL}, - {ST_NCCI_NONE, ST_NCCI_INCOMING, EV_NCCI_CONNECT_B3_IND, NULL}, - /* N-0.1 */ - {ST_NCCI_OUTGOING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_CONF_OK, NULL}, - {ST_NCCI_OUTGOING, ST_NCCI_NONE, EV_NCCI_CONNECT_B3_CONF_ERROR, n0}, - /* N-1 */ - {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_CONNECT_B3_REJECT, NULL}, - {ST_NCCI_INCOMING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_RESP, NULL}, - {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, - {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, - /* N-2 */ - {ST_NCCI_ALLOCATED, ST_NCCI_ACTIVE, EV_NCCI_CONNECT_B3_ACTIVE_IND, NULL}, - {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, - {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, - /* N-ACT */ - {ST_NCCI_ACTIVE, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, - {ST_NCCI_ACTIVE, ST_NCCI_RESETING, EV_NCCI_RESET_B3_REQ, NULL}, - {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, - {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, - /* N-3 */ - {ST_NCCI_RESETING, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, - {ST_NCCI_RESETING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, - {ST_NCCI_RESETING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, - /* N-4 */ - {ST_NCCI_DISCONNECTING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, - {ST_NCCI_DISCONNECTING, ST_NCCI_PREVIOUS, EV_NCCI_DISCONNECT_B3_CONF_ERROR,NULL}, - /* N-5 */ - {ST_NCCI_DISCONNECTED, ST_NCCI_NONE, EV_NCCI_DISCONNECT_B3_RESP, n0}, - {}, + /* N-0 */ + {ST_NCCI_NONE, ST_NCCI_OUTGOING, EV_NCCI_CONNECT_B3_REQ, NULL}, + {ST_NCCI_NONE, ST_NCCI_INCOMING, EV_NCCI_CONNECT_B3_IND, NULL}, + /* N-0.1 */ + {ST_NCCI_OUTGOING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_CONF_OK, NULL}, + {ST_NCCI_OUTGOING, ST_NCCI_NONE, EV_NCCI_CONNECT_B3_CONF_ERROR, n0}, + /* N-1 */ + {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_CONNECT_B3_REJECT, NULL}, + {ST_NCCI_INCOMING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_RESP, NULL}, + {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, + /* N-2 */ + {ST_NCCI_ALLOCATED, ST_NCCI_ACTIVE, EV_NCCI_CONNECT_B3_ACTIVE_IND, NULL}, + {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, + /* N-ACT */ + {ST_NCCI_ACTIVE, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, + {ST_NCCI_ACTIVE, ST_NCCI_RESETING, EV_NCCI_RESET_B3_REQ, NULL}, + {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, + /* N-3 */ + {ST_NCCI_RESETING, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, + {ST_NCCI_RESETING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_RESETING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, + /* N-4 */ + {ST_NCCI_DISCONNECTING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, + {ST_NCCI_DISCONNECTING, ST_NCCI_PREVIOUS, EV_NCCI_DISCONNECT_B3_CONF_ERROR, NULL}, + /* N-5 */ + {ST_NCCI_DISCONNECTED, ST_NCCI_NONE, EV_NCCI_DISCONNECT_B3_RESP, n0}, + {}, }; -static void ncci_change_state(capidrv_contr * card, capidrv_ncci * ncci, int event) +static void ncci_change_state(capidrv_contr *card, capidrv_ncci *ncci, int event) { struct nccistatechange *p = nccitable; while (p->event) { if (ncci->state == p->actstate && p->event == event) { if (debugmode) printk(KERN_DEBUG "capidrv-%d: ncci_change_state:0x%x %d -> %d\n", - card->contrnr, ncci->ncci, ncci->state, p->nextstate); + card->contrnr, ncci->ncci, ncci->state, p->nextstate); if (p->nextstate == ST_NCCI_PREVIOUS) { ncci->state = ncci->oldstate; ncci->oldstate = p->actstate; @@ -751,7 +751,7 @@ static void ncci_change_state(capidrv_contr * card, capidrv_ncci * ncci, int eve /* ------------------------------------------------------------------- */ -static inline int new_bchan(capidrv_contr * card) +static inline int new_bchan(capidrv_contr *card) { int i; for (i = 0; i < card->nbchan; i++) { @@ -765,7 +765,7 @@ static inline int new_bchan(capidrv_contr * card) /* ------------------------------------------------------------------- */ -static void handle_controller(_cmsg * cmsg) +static void handle_controller(_cmsg *cmsg) { capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); @@ -791,54 +791,54 @@ static void handle_controller(_cmsg * cmsg) break; case CAPI_MANUFACTURER_IND: /* Controller */ - if ( cmsg->ManuID == 0x214D5641 + if (cmsg->ManuID == 0x214D5641 && cmsg->Class == 0 && cmsg->Function == 1) { - u8 *data = cmsg->ManuData+3; - u16 len = cmsg->ManuData[0]; - u16 layer; - int direction; - if (len == 255) { - len = (cmsg->ManuData[1] | (cmsg->ManuData[2] << 8)); - data += 2; - } - len -= 2; - layer = ((*(data-1)) << 8) | *(data-2); - if (layer & 0x300) - direction = (layer & 0x200) ? 0 : 1; - else direction = (layer & 0x800) ? 0 : 1; - if (layer & 0x0C00) { - if ((layer & 0xff) == 0x80) { - handle_dtrace_data(card, direction, 1, data, len); - break; - } - } else if ((layer & 0xff) < 0x80) { - handle_dtrace_data(card, direction, 0, data, len); - break; - } - printk(KERN_INFO "capidrv-%d: %s from controller 0x%x layer 0x%x, ignored\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->adr.adrController, layer); - break; + u8 *data = cmsg->ManuData + 3; + u16 len = cmsg->ManuData[0]; + u16 layer; + int direction; + if (len == 255) { + len = (cmsg->ManuData[1] | (cmsg->ManuData[2] << 8)); + data += 2; + } + len -= 2; + layer = ((*(data - 1)) << 8) | *(data - 2); + if (layer & 0x300) + direction = (layer & 0x200) ? 0 : 1; + else direction = (layer & 0x800) ? 0 : 1; + if (layer & 0x0C00) { + if ((layer & 0xff) == 0x80) { + handle_dtrace_data(card, direction, 1, data, len); + break; + } + } else if ((layer & 0xff) < 0x80) { + handle_dtrace_data(card, direction, 0, data, len); + break; + } + printk(KERN_INFO "capidrv-%d: %s from controller 0x%x layer 0x%x, ignored\n", + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->adr.adrController, layer); + break; } goto ignored; case CAPI_MANUFACTURER_CONF: /* Controller */ if (cmsg->ManuID == 0x214D5641) { - char *s = NULL; - switch (cmsg->Class) { - case 0: break; - case 1: s = "unknown class"; break; - case 2: s = "unknown function"; break; - default: s = "unknown error"; break; - } - if (s) - printk(KERN_INFO "capidrv-%d: %s from controller 0x%x function %d: %s\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->adr.adrController, - cmsg->Function, s); - break; + char *s = NULL; + switch (cmsg->Class) { + case 0: break; + case 1: s = "unknown class"; break; + case 2: s = "unknown function"; break; + default: s = "unknown error"; break; + } + if (s) + printk(KERN_INFO "capidrv-%d: %s from controller 0x%x function %d: %s\n", + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->adr.adrController, + cmsg->Function, s); + break; } goto ignored; case CAPI_FACILITY_IND: /* Controller/plci/ncci */ @@ -858,14 +858,14 @@ static void handle_controller(_cmsg * cmsg) } return; - ignored: +ignored: printk(KERN_INFO "capidrv-%d: %s from controller 0x%x ignored\n", card->contrnr, capi_cmd2str(cmsg->Command, cmsg->Subcommand), cmsg->adr.adrController); } -static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) +static void handle_incoming_call(capidrv_contr *card, _cmsg *cmsg) { capidrv_plci *plcip; capidrv_bchan *bchan; @@ -890,27 +890,27 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) cmd.arg = chan; memset(&cmd.parm.setup, 0, sizeof(cmd.parm.setup)); strncpy(cmd.parm.setup.phone, - cmsg->CallingPartyNumber + 3, + cmsg->CallingPartyNumber + 3, cmsg->CallingPartyNumber[0] - 2); strncpy(cmd.parm.setup.eazmsn, - cmsg->CalledPartyNumber + 2, + cmsg->CalledPartyNumber + 2, cmsg->CalledPartyNumber[0] - 1); cmd.parm.setup.si1 = cip2si1(cmsg->CIPValue); cmd.parm.setup.si2 = cip2si2(cmsg->CIPValue); cmd.parm.setup.plan = cmsg->CallingPartyNumber[1]; cmd.parm.setup.screen = cmsg->CallingPartyNumber[2]; - printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s\n", - card->contrnr, - cmd.parm.setup.phone, - cmd.parm.setup.si1, - cmd.parm.setup.si2, - cmd.parm.setup.eazmsn); + printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s\n", + card->contrnr, + cmd.parm.setup.phone, + cmd.parm.setup.si1, + cmd.parm.setup.si2, + cmd.parm.setup.eazmsn); if (cmd.parm.setup.si1 == 1 && cmd.parm.setup.si2 != 0) { - printk(KERN_INFO "capidrv-%d: patching si2=%d to 0 for VBOX\n", - card->contrnr, - cmd.parm.setup.si2); + printk(KERN_INFO "capidrv-%d: patching si2=%d to 0 for VBOX\n", + card->contrnr, + cmd.parm.setup.si2); cmd.parm.setup.si2 = 0; } @@ -927,11 +927,11 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) plci_change_state(card, plcip, EV_PLCI_CONNECT_REJECT); send_message(card, cmsg); printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s ignored\n", - card->contrnr, - cmd.parm.setup.phone, - cmd.parm.setup.si1, - cmd.parm.setup.si2, - cmd.parm.setup.eazmsn); + card->contrnr, + cmd.parm.setup.phone, + cmd.parm.setup.si1, + cmd.parm.setup.si2, + cmd.parm.setup.eazmsn); break; case 1: /* At least one device matching this call (RING on ttyI) @@ -945,11 +945,11 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) */ if (plcip->state == ST_PLCI_INCOMING) { printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s tty alerting\n", - card->contrnr, - cmd.parm.setup.phone, - cmd.parm.setup.si1, - cmd.parm.setup.si2, - cmd.parm.setup.eazmsn); + card->contrnr, + cmd.parm.setup.phone, + cmd.parm.setup.si1, + cmd.parm.setup.si2, + cmd.parm.setup.eazmsn); capi_fill_ALERT_REQ(cmsg, global.ap.applid, card->msgid++, @@ -958,16 +958,16 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) NULL,/* Keypadfacility */ NULL,/* Useruserdata */ NULL /* Facilitydataarray */ - ); + ); plcip->msgid = cmsg->Messagenumber; send_message(card, cmsg); } else { printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s on netdev\n", - card->contrnr, - cmd.parm.setup.phone, - cmd.parm.setup.si1, - cmd.parm.setup.si2, - cmd.parm.setup.eazmsn); + card->contrnr, + cmd.parm.setup.phone, + cmd.parm.setup.si1, + cmd.parm.setup.si2, + cmd.parm.setup.eazmsn); } break; @@ -990,7 +990,7 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) return; } -static void handle_plci(_cmsg * cmsg) +static void handle_plci(_cmsg *cmsg) { capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); capidrv_plci *plcip; @@ -1008,8 +1008,8 @@ static void handle_plci(_cmsg * cmsg) case CAPI_DISCONNECT_IND: /* plci */ if (cmsg->Reason) { printk(KERN_INFO "capidrv-%d: %s reason 0x%x (%s) for plci 0x%x\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), cmsg->Reason, capi_info2str(cmsg->Reason), cmsg->adr.adrPLCI); } if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) { @@ -1027,9 +1027,9 @@ static void handle_plci(_cmsg * cmsg) case CAPI_DISCONNECT_CONF: /* plci */ if (cmsg->Info) { printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for plci 0x%x\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->Info, capi_info2str(cmsg->Info), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->Info, capi_info2str(cmsg->Info), cmsg->adr.adrPLCI); } if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) @@ -1041,9 +1041,9 @@ static void handle_plci(_cmsg * cmsg) case CAPI_ALERT_CONF: /* plci */ if (cmsg->Info) { printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for plci 0x%x\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->Info, capi_info2str(cmsg->Info), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->Info, capi_info2str(cmsg->Info), cmsg->adr.adrPLCI); } break; @@ -1055,9 +1055,9 @@ static void handle_plci(_cmsg * cmsg) case CAPI_CONNECT_CONF: /* plci */ if (cmsg->Info) { printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for plci 0x%x\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->Info, capi_info2str(cmsg->Info), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->Info, capi_info2str(cmsg->Info), cmsg->adr.adrPLCI); } if (!(plcip = find_plci_by_msgid(card, cmsg->Messagenumber))) @@ -1096,7 +1096,7 @@ static void handle_plci(_cmsg * cmsg) card->msgid++, plcip->plci, /* adr */ NULL /* NCPI */ - ); + ); nccip->msgid = cmsg->Messagenumber; plci_change_state(card, plcip, EV_PLCI_CONNECT_ACTIVE_IND); @@ -1122,8 +1122,8 @@ static void handle_plci(_cmsg * cmsg) sprintf(cmd.parm.num, "%lu", (unsigned long) ((u32) cmsg->InfoElement[1] - | ((u32) (cmsg->InfoElement[2]) << 8) - | ((u32) (cmsg->InfoElement[3]) << 16) + | ((u32) (cmsg->InfoElement[2]) << 8) + | ((u32) (cmsg->InfoElement[3]) << 16) | ((u32) (cmsg->InfoElement[4]) << 24))); card->interface.statcallb(&cmd); break; @@ -1132,11 +1132,11 @@ static void handle_plci(_cmsg * cmsg) cdb = capi_cmsg2str(cmsg); if (cdb) { printk(KERN_WARNING "capidrv-%d: %s\n", - card->contrnr, cdb->buf); + card->contrnr, cdb->buf); cdebbuf_free(cdb); } else printk(KERN_WARNING "capidrv-%d: CAPI_INFO_IND InfoNumber %x not handled\n", - card->contrnr, cmsg->InfoNumber); + card->contrnr, cmsg->InfoNumber); break; @@ -1159,13 +1159,13 @@ static void handle_plci(_cmsg * cmsg) cmsg->adr.adrPLCI); } return; - ignored: +ignored: printk(KERN_INFO "capidrv-%d: %s for plci 0x%x ignored\n", card->contrnr, capi_cmd2str(cmsg->Command, cmsg->Subcommand), cmsg->adr.adrPLCI); return; - notfound: +notfound: printk(KERN_ERR "capidrv-%d: %s: plci 0x%x not found\n", card->contrnr, capi_cmd2str(cmsg->Command, cmsg->Subcommand), @@ -1173,7 +1173,7 @@ static void handle_plci(_cmsg * cmsg) return; } -static void handle_ncci(_cmsg * cmsg) +static void handle_ncci(_cmsg *cmsg) { capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); capidrv_plci *plcip; @@ -1222,7 +1222,7 @@ static void handle_ncci(_cmsg * cmsg) nccip->ncci, /* adr */ 0, /* Reject */ NULL /* NCPI */ - ); + ); ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_RESP); send_message(card, cmsg); break; @@ -1230,8 +1230,8 @@ static void handle_ncci(_cmsg * cmsg) printk(KERN_ERR "capidrv-%d: no mem for ncci, sorry\n", card->contrnr); } else { printk(KERN_ERR "capidrv-%d: %s: plci for ncci 0x%x not found\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), cmsg->adr.adrNCCI); } capi_fill_CONNECT_B3_RESP(cmsg, @@ -1240,7 +1240,7 @@ static void handle_ncci(_cmsg * cmsg) cmsg->adr.adrNCCI, 2, /* Reject */ NULL /* NCPI */ - ); + ); send_message(card, cmsg); break; @@ -1254,9 +1254,9 @@ static void handle_ncci(_cmsg * cmsg) nccip->ncci = cmsg->adr.adrNCCI; if (cmsg->Info) { printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for ncci 0x%x\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->Info, capi_info2str(cmsg->Info), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->Info, capi_info2str(cmsg->Info), cmsg->adr.adrNCCI); } @@ -1278,7 +1278,7 @@ static void handle_ncci(_cmsg * cmsg) case CAPI_DATA_B3_CONF: /* ncci */ if (cmsg->Info) { printk(KERN_WARNING "CAPI_DATA_B3_CONF: Info %x - %s\n", - cmsg->Info, capi_info2str(cmsg->Info)); + cmsg->Info, capi_info2str(cmsg->Info)); } if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) goto notfound; @@ -1286,11 +1286,11 @@ static void handle_ncci(_cmsg * cmsg) len = capidrv_del_ack(nccip, cmsg->DataHandle); if (len < 0) break; - cmd.command = ISDN_STAT_BSENT; - cmd.driver = card->myid; - cmd.arg = nccip->chan; + cmd.command = ISDN_STAT_BSENT; + cmd.driver = card->myid; + cmd.arg = nccip->chan; cmd.parm.length = len; - card->interface.statcallb(&cmd); + card->interface.statcallb(&cmd); break; case CAPI_DISCONNECT_B3_IND: /* ncci */ @@ -1309,9 +1309,9 @@ static void handle_ncci(_cmsg * cmsg) goto notfound; if (cmsg->Info) { printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for ncci 0x%x\n", - card->contrnr, - capi_cmd2str(cmsg->Command, cmsg->Subcommand), - cmsg->Info, capi_info2str(cmsg->Info), + card->contrnr, + capi_cmd2str(cmsg->Command, cmsg->Subcommand), + cmsg->Info, capi_info2str(cmsg->Info), cmsg->adr.adrNCCI); ncci_change_state(card, nccip, EV_NCCI_DISCONNECT_B3_CONF_ERROR); } @@ -1340,13 +1340,13 @@ static void handle_ncci(_cmsg * cmsg) cmsg->adr.adrNCCI); } return; - ignored: +ignored: printk(KERN_INFO "capidrv-%d: %s for ncci 0x%x ignored\n", card->contrnr, capi_cmd2str(cmsg->Command, cmsg->Subcommand), cmsg->adr.adrNCCI); return; - notfound: +notfound: printk(KERN_ERR "capidrv-%d: %s: ncci 0x%x not found\n", card->contrnr, capi_cmd2str(cmsg->Command, cmsg->Subcommand), @@ -1354,7 +1354,7 @@ static void handle_ncci(_cmsg * cmsg) } -static void handle_data(_cmsg * cmsg, struct sk_buff *skb) +static void handle_data(_cmsg *cmsg, struct sk_buff *skb) { capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); capidrv_ncci *nccip; @@ -1390,12 +1390,12 @@ static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb) if (cdb) { printk(KERN_DEBUG "%s: applid=%d %s\n", __func__, - ap->applid, cdb->buf); + ap->applid, cdb->buf); cdebbuf_free(cdb); } else printk(KERN_DEBUG "%s: applid=%d %s not traced\n", - __func__, ap->applid, - capi_cmd2str(s_cmsg.Command, s_cmsg.Subcommand)); + __func__, ap->applid, + capi_cmd2str(s_cmsg.Command, s_cmsg.Subcommand)); } if (s_cmsg.Command == CAPI_DATA_B3 && s_cmsg.Subcommand == CAPI_IND) { @@ -1418,38 +1418,38 @@ static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb) /* ------------------------------------------------------------------- */ -#define PUTBYTE_TO_STATUS(card, byte) \ - do { \ - *(card)->q931_write++ = (byte); \ - if ((card)->q931_write > (card)->q931_end) \ - (card)->q931_write = (card)->q931_buf; \ +#define PUTBYTE_TO_STATUS(card, byte) \ + do { \ + *(card)->q931_write++ = (byte); \ + if ((card)->q931_write > (card)->q931_end) \ + (card)->q931_write = (card)->q931_buf; \ } while (0) static void handle_dtrace_data(capidrv_contr *card, - int send, int level2, u8 *data, u16 len) + int send, int level2, u8 *data, u16 len) { - u8 *p, *end; - isdn_ctrl cmd; + u8 *p, *end; + isdn_ctrl cmd; - if (!len) { + if (!len) { printk(KERN_DEBUG "capidrv-%d: avmb1_q931_data: len == %d\n", - card->contrnr, len); + card->contrnr, len); return; } if (level2) { PUTBYTE_TO_STATUS(card, 'D'); PUTBYTE_TO_STATUS(card, '2'); - PUTBYTE_TO_STATUS(card, send ? '>' : '<'); - PUTBYTE_TO_STATUS(card, ':'); + PUTBYTE_TO_STATUS(card, send ? '>' : '<'); + PUTBYTE_TO_STATUS(card, ':'); } else { - PUTBYTE_TO_STATUS(card, 'D'); - PUTBYTE_TO_STATUS(card, '3'); - PUTBYTE_TO_STATUS(card, send ? '>' : '<'); - PUTBYTE_TO_STATUS(card, ':'); - } + PUTBYTE_TO_STATUS(card, 'D'); + PUTBYTE_TO_STATUS(card, '3'); + PUTBYTE_TO_STATUS(card, send ? '>' : '<'); + PUTBYTE_TO_STATUS(card, ':'); + } - for (p = data, end = data+len; p < end; p++) { + for (p = data, end = data + len; p < end; p++) { PUTBYTE_TO_STATUS(card, ' '); PUTBYTE_TO_STATUS(card, hex_asc_hi(*p)); PUTBYTE_TO_STATUS(card, hex_asc_lo(*p)); @@ -1458,7 +1458,7 @@ static void handle_dtrace_data(capidrv_contr *card, cmd.command = ISDN_STAT_STAVAIL; cmd.driver = card->myid; - cmd.arg = len*3+5; + cmd.arg = len * 3 + 5; card->interface.statcallb(&cmd); } @@ -1466,17 +1466,17 @@ static void handle_dtrace_data(capidrv_contr *card, static _cmsg cmdcmsg; -static int capidrv_ioctl(isdn_ctrl * c, capidrv_contr * card) +static int capidrv_ioctl(isdn_ctrl *c, capidrv_contr *card) { switch (c->arg) { case 1: debugmode = (int)(*((unsigned int *)c->parm.num)); printk(KERN_DEBUG "capidrv-%d: debugmode=%d\n", - card->contrnr, debugmode); + card->contrnr, debugmode); return 0; default: printk(KERN_DEBUG "capidrv-%d: capidrv_ioctl(%ld) called ??\n", - card->contrnr, c->arg); + card->contrnr, c->arg); return -EINVAL; } return -EINVAL; @@ -1487,9 +1487,9 @@ static int capidrv_ioctl(isdn_ctrl * c, capidrv_contr * card) */ struct internal_bchannelinfo { - unsigned short channelalloc; - unsigned short operation; - unsigned char cmask[31]; + unsigned short channelalloc; + unsigned short operation; + unsigned char cmask[31]; }; static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep) @@ -1540,10 +1540,10 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep) if (digit2 <= 0 || digit2 > 30) return -4; if (*s == 0 || *s == ',' || *s == ' ') { if (digit1 > digit2) - for (i = digit2; i <= digit1 ; i++) + for (i = digit2; i <= digit1; i++) bmask |= (1 << i); - else - for (i = digit1; i <= digit2 ; i++) + else + for (i = digit1; i <= digit2; i++) bmask |= (1 << i); digit1 = digit2 = 0; if (*s) s++; @@ -1556,131 +1556,131 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep) return 0; } -static int FVteln2capi20(char *teln, u8 AdditionalInfo[1+2+2+31]) +static int FVteln2capi20(char *teln, u8 AdditionalInfo[1 + 2 + 2 + 31]) { unsigned long bmask; int active; int rc, i; - + rc = decodeFVteln(teln, &bmask, &active); if (rc) return rc; /* Length */ - AdditionalInfo[0] = 2+2+31; - /* Channel: 3 => use channel allocation */ - AdditionalInfo[1] = 3; AdditionalInfo[2] = 0; + AdditionalInfo[0] = 2 + 2 + 31; + /* Channel: 3 => use channel allocation */ + AdditionalInfo[1] = 3; AdditionalInfo[2] = 0; /* Operation: 0 => DTE mode, 1 => DCE mode */ - if (active) { - AdditionalInfo[3] = 0; AdditionalInfo[4] = 0; - } else { - AdditionalInfo[3] = 1; AdditionalInfo[4] = 0; + if (active) { + AdditionalInfo[3] = 0; AdditionalInfo[4] = 0; + } else { + AdditionalInfo[3] = 1; AdditionalInfo[4] = 0; } /* Channel mask array */ AdditionalInfo[5] = 0; /* no D-Channel */ - for (i=1; i <= 30; i++) - AdditionalInfo[5+i] = (bmask & (1 << i)) ? 0xff : 0; + for (i = 1; i <= 30; i++) + AdditionalInfo[5 + i] = (bmask & (1 << i)) ? 0xff : 0; return 0; } -static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) +static int capidrv_command(isdn_ctrl *c, capidrv_contr *card) { isdn_ctrl cmd; struct capidrv_bchan *bchan; struct capidrv_plci *plcip; - u8 AdditionalInfo[1+2+2+31]; - int rc, isleasedline = 0; + u8 AdditionalInfo[1 + 2 + 2 + 31]; + int rc, isleasedline = 0; if (c->command == ISDN_CMD_IOCTL) return capidrv_ioctl(c, card); switch (c->command) { case ISDN_CMD_DIAL:{ - u8 calling[ISDN_MSNLEN + 3]; - u8 called[ISDN_MSNLEN + 2]; + u8 calling[ISDN_MSNLEN + 3]; + u8 called[ISDN_MSNLEN + 2]; - if (debugmode) - printk(KERN_DEBUG "capidrv-%d: ISDN_CMD_DIAL(ch=%ld,\"%s,%d,%d,%s\")\n", - card->contrnr, - c->arg, - c->parm.setup.phone, - c->parm.setup.si1, - c->parm.setup.si2, - c->parm.setup.eazmsn); - - bchan = &card->bchans[c->arg % card->nbchan]; - - if (bchan->plcip) { - printk(KERN_ERR "capidrv-%d: dail ch=%ld,\"%s,%d,%d,%s\" in use (plci=0x%x)\n", - card->contrnr, - c->arg, - c->parm.setup.phone, - c->parm.setup.si1, - c->parm.setup.si2, - c->parm.setup.eazmsn, - bchan->plcip->plci); - return 0; - } - bchan->si1 = c->parm.setup.si1; - bchan->si2 = c->parm.setup.si2; - - strncpy(bchan->num, c->parm.setup.phone, sizeof(bchan->num)); - strncpy(bchan->mynum, c->parm.setup.eazmsn, sizeof(bchan->mynum)); - rc = FVteln2capi20(bchan->num, AdditionalInfo); - isleasedline = (rc == 0); - if (rc < 0) - printk(KERN_ERR "capidrv-%d: WARNING: invalid leased linedefinition \"%s\"\n", card->contrnr, bchan->num); - - if (isleasedline) { - calling[0] = 0; - called[0] = 0; - if (debugmode) - printk(KERN_DEBUG "capidrv-%d: connecting leased line\n", card->contrnr); - } else { - calling[0] = strlen(bchan->mynum) + 2; - calling[1] = 0; - calling[2] = 0x80; - strncpy(calling + 3, bchan->mynum, ISDN_MSNLEN); - called[0] = strlen(bchan->num) + 1; - called[1] = 0x80; - strncpy(called + 2, bchan->num, ISDN_MSNLEN); - } + if (debugmode) + printk(KERN_DEBUG "capidrv-%d: ISDN_CMD_DIAL(ch=%ld,\"%s,%d,%d,%s\")\n", + card->contrnr, + c->arg, + c->parm.setup.phone, + c->parm.setup.si1, + c->parm.setup.si2, + c->parm.setup.eazmsn); - capi_fill_CONNECT_REQ(&cmdcmsg, - global.ap.applid, - card->msgid++, - card->contrnr, /* adr */ - si2cip(bchan->si1, bchan->si2), /* cipvalue */ - called, /* CalledPartyNumber */ - calling, /* CallingPartyNumber */ - NULL, /* CalledPartySubaddress */ - NULL, /* CallingPartySubaddress */ - b1prot(bchan->l2, bchan->l3), /* B1protocol */ - b2prot(bchan->l2, bchan->l3), /* B2protocol */ - b3prot(bchan->l2, bchan->l3), /* B3protocol */ - b1config(bchan->l2, bchan->l3), /* B1configuration */ - NULL, /* B2configuration */ - NULL, /* B3configuration */ - NULL, /* BC */ - NULL, /* LLC */ - NULL, /* HLC */ - /* BChannelinformation */ - isleasedline ? AdditionalInfo : NULL, - NULL, /* Keypadfacility */ - NULL, /* Useruserdata */ - NULL /* Facilitydataarray */ - ); - if ((plcip = new_plci(card, (c->arg % card->nbchan))) == NULL) { - cmd.command = ISDN_STAT_DHUP; - cmd.driver = card->myid; - cmd.arg = (c->arg % card->nbchan); - card->interface.statcallb(&cmd); - return -1; - } - plcip->msgid = cmdcmsg.Messagenumber; - plcip->leasedline = isleasedline; - plci_change_state(card, plcip, EV_PLCI_CONNECT_REQ); - send_message(card, &cmdcmsg); + bchan = &card->bchans[c->arg % card->nbchan]; + + if (bchan->plcip) { + printk(KERN_ERR "capidrv-%d: dail ch=%ld,\"%s,%d,%d,%s\" in use (plci=0x%x)\n", + card->contrnr, + c->arg, + c->parm.setup.phone, + c->parm.setup.si1, + c->parm.setup.si2, + c->parm.setup.eazmsn, + bchan->plcip->plci); return 0; } + bchan->si1 = c->parm.setup.si1; + bchan->si2 = c->parm.setup.si2; + + strncpy(bchan->num, c->parm.setup.phone, sizeof(bchan->num)); + strncpy(bchan->mynum, c->parm.setup.eazmsn, sizeof(bchan->mynum)); + rc = FVteln2capi20(bchan->num, AdditionalInfo); + isleasedline = (rc == 0); + if (rc < 0) + printk(KERN_ERR "capidrv-%d: WARNING: invalid leased linedefinition \"%s\"\n", card->contrnr, bchan->num); + + if (isleasedline) { + calling[0] = 0; + called[0] = 0; + if (debugmode) + printk(KERN_DEBUG "capidrv-%d: connecting leased line\n", card->contrnr); + } else { + calling[0] = strlen(bchan->mynum) + 2; + calling[1] = 0; + calling[2] = 0x80; + strncpy(calling + 3, bchan->mynum, ISDN_MSNLEN); + called[0] = strlen(bchan->num) + 1; + called[1] = 0x80; + strncpy(called + 2, bchan->num, ISDN_MSNLEN); + } + + capi_fill_CONNECT_REQ(&cmdcmsg, + global.ap.applid, + card->msgid++, + card->contrnr, /* adr */ + si2cip(bchan->si1, bchan->si2), /* cipvalue */ + called, /* CalledPartyNumber */ + calling, /* CallingPartyNumber */ + NULL, /* CalledPartySubaddress */ + NULL, /* CallingPartySubaddress */ + b1prot(bchan->l2, bchan->l3), /* B1protocol */ + b2prot(bchan->l2, bchan->l3), /* B2protocol */ + b3prot(bchan->l2, bchan->l3), /* B3protocol */ + b1config(bchan->l2, bchan->l3), /* B1configuration */ + NULL, /* B2configuration */ + NULL, /* B3configuration */ + NULL, /* BC */ + NULL, /* LLC */ + NULL, /* HLC */ + /* BChannelinformation */ + isleasedline ? AdditionalInfo : NULL, + NULL, /* Keypadfacility */ + NULL, /* Useruserdata */ + NULL /* Facilitydataarray */ + ); + if ((plcip = new_plci(card, (c->arg % card->nbchan))) == NULL) { + cmd.command = ISDN_STAT_DHUP; + cmd.driver = card->myid; + cmd.arg = (c->arg % card->nbchan); + card->interface.statcallb(&cmd); + return -1; + } + plcip->msgid = cmdcmsg.Messagenumber; + plcip->leasedline = isleasedline; + plci_change_state(card, plcip, EV_PLCI_CONNECT_REQ); + send_message(card, &cmdcmsg); + return 0; + } case ISDN_CMD_ACCEPTD: @@ -1708,7 +1708,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) NULL, /* Keypadfacility */ NULL, /* Useruserdata */ NULL /* Facilitydataarray */ - ); + ); capi_cmsg2message(&cmdcmsg, cmdcmsg.buf); plci_change_state(card, bchan->plcip, EV_PLCI_CONNECT_RESP); send_message(card, &cmdcmsg); @@ -1742,7 +1742,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) card->msgid++, bchan->nccip->ncci, NULL /* NCPI */ - ); + ); ncci_change_state(card, bchan->nccip, EV_NCCI_DISCONNECT_B3_REQ); send_message(card, &cmdcmsg); return 0; @@ -1761,12 +1761,12 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) capi_fill_DISCONNECT_REQ(&cmdcmsg, global.ap.applid, card->msgid++, - bchan->plcip->plci, + bchan->plcip->plci, NULL, /* BChannelinformation */ NULL, /* Keypadfacility */ NULL, /* Useruserdata */ NULL /* Facilitydataarray */ - ); + ); plci_change_state(card, bchan->plcip, EV_PLCI_DISCONNECT_REQ); send_message(card, &cmdcmsg); return 0; @@ -1778,8 +1778,8 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) } } printk(KERN_ERR "capidrv-%d: chan %ld disconnect request on free channel\n", - card->contrnr, - c->arg); + card->contrnr, + c->arg); return -EINVAL; /* ready */ @@ -1813,20 +1813,20 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) case ISDN_CMD_CLREAZ: if (debugmode) printk(KERN_DEBUG "capidrv-%d: clearing EAZ on chan %ld\n", - card->contrnr, c->arg); + card->contrnr, c->arg); bchan = &card->bchans[c->arg % card->nbchan]; bchan->msn[0] = 0; return 0; default: printk(KERN_ERR "capidrv-%d: ISDN_CMD_%d, Huh?\n", - card->contrnr, c->command); + card->contrnr, c->command); return -EINVAL; } return 0; } -static int if_command(isdn_ctrl * c) +static int if_command(isdn_ctrl *c) { capidrv_contr *card = findcontrbydriverid(c->driver); @@ -1834,8 +1834,8 @@ static int if_command(isdn_ctrl * c) return capidrv_command(c, card); printk(KERN_ERR - "capidrv: if_command %d called with invalid driverId %d!\n", - c->command, c->driver); + "capidrv: if_command %d called with invalid driverId %d!\n", + c->command, c->driver); return -ENODEV; } @@ -1859,7 +1859,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) } if (debugmode > 4) printk(KERN_DEBUG "capidrv-%d: sendbuf len=%d skb=%p doack=%d\n", - card->contrnr, len, skb, doack); + card->contrnr, len, skb, doack); bchan = &card->bchans[channel % card->nbchan]; nccip = bchan->nccip; if (!nccip || nccip->state != ST_NCCI_ACTIVE) { @@ -1891,10 +1891,10 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) skb->len, /* DataLength */ datahandle, /* DataHandle */ 0 /* Flags */ - ); + ); if (capidrv_add_ack(nccip, datahandle, doack ? (int)skb->len : -1) < 0) - return 0; + return 0; capi_cmsg2message(&sendcmsg, sendcmsg.buf); msglen = CAPIMSG_LEN(sendcmsg.buf); @@ -1902,8 +1902,8 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) struct sk_buff *nskb = skb_realloc_headroom(skb, msglen); if (!nskb) { printk(KERN_ERR "capidrv-%d: if_sendbuf: no memory\n", - card->contrnr); - (void)capidrv_del_ack(nccip, datahandle); + card->contrnr); + (void)capidrv_del_ack(nccip, datahandle); return 0; } printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n", @@ -1917,9 +1917,9 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) } if (debugmode > 3) printk(KERN_DEBUG "capidrv-%d: sendbuf putmsg ret(%x) - %s\n", - card->contrnr, errcode, capi_info2str(errcode)); - (void)capidrv_del_ack(nccip, datahandle); - dev_kfree_skb(nskb); + card->contrnr, errcode, capi_info2str(errcode)); + (void)capidrv_del_ack(nccip, datahandle); + dev_kfree_skb(nskb); return errcode == CAPI_SENDQUEUEFULL ? 0 : -1; } else { memcpy(skb_push(skb, msglen), sendcmsg.buf, msglen); @@ -1930,9 +1930,9 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) } if (debugmode > 3) printk(KERN_DEBUG "capidrv-%d: sendbuf putmsg ret(%x) - %s\n", - card->contrnr, errcode, capi_info2str(errcode)); + card->contrnr, errcode, capi_info2str(errcode)); skb_pull(skb, msglen); - (void)capidrv_del_ack(nccip, datahandle); + (void)capidrv_del_ack(nccip, datahandle); return errcode == CAPI_SENDQUEUEFULL ? 0 : -1; } } @@ -1949,11 +1949,11 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel) return -ENODEV; } - for (p=buf, count=0; count < len; p++, count++) { + for (p = buf, count = 0; count < len; p++, count++) { if (put_user(*card->q931_read++, p)) return -EFAULT; - if (card->q931_read > card->q931_end) - card->q931_read = card->q931_buf; + if (card->q931_read > card->q931_end) + card->q931_read = card->q931_buf; } return count; @@ -1961,35 +1961,35 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel) static void enable_dchannel_trace(capidrv_contr *card) { - u8 manufacturer[CAPI_MANUFACTURER_LEN]; - capi_version version; + u8 manufacturer[CAPI_MANUFACTURER_LEN]; + capi_version version; u16 contr = card->contrnr; u16 errcode; u16 avmversion[3]; - errcode = capi20_get_manufacturer(contr, manufacturer); - if (errcode != CAPI_NOERROR) { - printk(KERN_ERR "%s: can't get manufacturer (0x%x)\n", - card->name, errcode); - return; + errcode = capi20_get_manufacturer(contr, manufacturer); + if (errcode != CAPI_NOERROR) { + printk(KERN_ERR "%s: can't get manufacturer (0x%x)\n", + card->name, errcode); + return; } if (strstr(manufacturer, "AVM") == NULL) { - printk(KERN_ERR "%s: not from AVM, no d-channel trace possible (%s)\n", - card->name, manufacturer); - return; + printk(KERN_ERR "%s: not from AVM, no d-channel trace possible (%s)\n", + card->name, manufacturer); + return; } - errcode = capi20_get_version(contr, &version); - if (errcode != CAPI_NOERROR) { - printk(KERN_ERR "%s: can't get version (0x%x)\n", - card->name, errcode); - return; + errcode = capi20_get_version(contr, &version); + if (errcode != CAPI_NOERROR) { + printk(KERN_ERR "%s: can't get version (0x%x)\n", + card->name, errcode); + return; } avmversion[0] = (version.majormanuversion >> 4) & 0x0f; avmversion[1] = (version.majormanuversion << 4) & 0xf0; avmversion[1] |= (version.minormanuversion >> 4) & 0x0f; avmversion[2] |= version.minormanuversion & 0x0f; - if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) { + if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) { printk(KERN_INFO "%s: D2 trace enabled\n", card->name); capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.ap.applid, card->msgid++, @@ -2030,8 +2030,8 @@ static void listentimerfunc(unsigned long x) capidrv_contr *card = (capidrv_contr *)x; if (card->state != ST_LISTEN_NONE && card->state != ST_LISTEN_ACTIVE) printk(KERN_ERR "%s: controller dead ??\n", card->name); - send_listen(card); - mod_timer(&card->listentimer, jiffies + 60*HZ); + send_listen(card); + mod_timer(&card->listentimer, jiffies + 60 * HZ); } @@ -2050,7 +2050,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) } if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) { printk(KERN_WARNING - "capidrv: (%s) Could not allocate contr-struct.\n", id); + "capidrv: (%s) Could not allocate contr-struct.\n", id); return -1; } card->owner = THIS_MODULE; @@ -2061,7 +2061,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); if (!card->bchans) { printk(KERN_WARNING - "capidrv: (%s) Could not allocate bchan-structs.\n", id); + "capidrv: (%s) Could not allocate bchan-structs.\n", id); module_put(card->owner); kfree(card); return -1; @@ -2073,17 +2073,17 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) card->interface.writecmd = NULL; card->interface.readstat = if_readstat; card->interface.features = ISDN_FEATURE_L2_HDLC | - ISDN_FEATURE_L2_TRANS | - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_UNKNOWN | - ISDN_FEATURE_L2_X75I | - ISDN_FEATURE_L2_X75UI | - ISDN_FEATURE_L2_X75BUI; - if (profp->support1 & (1<<2)) + ISDN_FEATURE_L2_TRANS | + ISDN_FEATURE_L3_TRANS | + ISDN_FEATURE_P_UNKNOWN | + ISDN_FEATURE_L2_X75I | + ISDN_FEATURE_L2_X75UI | + ISDN_FEATURE_L2_X75BUI; + if (profp->support1 & (1 << 2)) card->interface.features |= ISDN_FEATURE_L2_V11096 | - ISDN_FEATURE_L2_V11019 | - ISDN_FEATURE_L2_V11038; - if (profp->support1 & (1<<8)) + ISDN_FEATURE_L2_V11019 | + ISDN_FEATURE_L2_V11038; + if (profp->support1 & (1 << 8)) card->interface.features |= ISDN_FEATURE_L2_MODEM; card->interface.hl_hdrlen = 22; /* len of DATA_B3_REQ */ strncpy(card->interface.id, id, sizeof(card->interface.id) - 1); @@ -2122,10 +2122,10 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) card->listentimer.data = (unsigned long)card; card->listentimer.function = listentimerfunc; send_listen(card); - mod_timer(&card->listentimer, jiffies + 60*HZ); + mod_timer(&card->listentimer, jiffies + 60 * HZ); printk(KERN_INFO "%s: now up (%d B channels)\n", - card->name, card->nbchan); + card->name, card->nbchan); enable_dchannel_trace(card); @@ -2158,7 +2158,7 @@ static int capidrv_delcontr(u16 contr) if (debugmode) printk(KERN_DEBUG "capidrv-%d: id=%d unloading\n", - card->contrnr, card->myid); + card->contrnr, card->myid); cmd.command = ISDN_STAT_STOP; cmd.driver = card->myid; @@ -2168,17 +2168,17 @@ static int capidrv_delcontr(u16 contr) cmd.command = ISDN_STAT_DISCH; cmd.driver = card->myid; - cmd.arg = card->nbchan-1; - cmd.parm.num[0] = 0; + cmd.arg = card->nbchan - 1; + cmd.parm.num[0] = 0; if (debugmode) printk(KERN_DEBUG "capidrv-%d: id=%d disable chan=%ld\n", - card->contrnr, card->myid, cmd.arg); + card->contrnr, card->myid, cmd.arg); card->interface.statcallb(&cmd); - if (card->bchans[card->nbchan-1].nccip) - free_ncci(card, card->bchans[card->nbchan-1].nccip); - if (card->bchans[card->nbchan-1].plcip) - free_plci(card, card->bchans[card->nbchan-1].plcip); + if (card->bchans[card->nbchan - 1].nccip) + free_ncci(card, card->bchans[card->nbchan - 1].nccip); + if (card->bchans[card->nbchan - 1].plcip) + free_plci(card, card->bchans[card->nbchan - 1].plcip); if (card->plci_list) printk(KERN_ERR "capidrv: bug in free_plci()\n"); card->nbchan--; @@ -2188,7 +2188,7 @@ static int capidrv_delcontr(u16 contr) if (debugmode) printk(KERN_DEBUG "capidrv-%d: id=%d isdn unload\n", - card->contrnr, card->myid); + card->contrnr, card->myid); cmd.command = ISDN_STAT_UNLOAD; cmd.driver = card->myid; @@ -2196,7 +2196,7 @@ static int capidrv_delcontr(u16 contr) if (debugmode) printk(KERN_DEBUG "capidrv-%d: id=%d remove contr from list\n", - card->contrnr, card->myid); + card->contrnr, card->myid); spin_lock_irqsave(&global_lock, flags); for (pp = &global.contr_list; *pp; pp = &(*pp)->next) { @@ -2243,10 +2243,10 @@ lower_callback(struct notifier_block *nb, unsigned long val, void *v) static int capidrv_proc_show(struct seq_file *m, void *v) { seq_printf(m, "%lu %lu %lu %lu\n", - global.ap.nrecvctlpkt, - global.ap.nrecvdatapkt, - global.ap.nsentctlpkt, - global.ap.nsentdatapkt); + global.ap.nrecvctlpkt, + global.ap.nrecvdatapkt, + global.ap.nsentctlpkt, + global.ap.nsentdatapkt); return 0; } diff --git a/drivers/isdn/capi/capidrv.h b/drivers/isdn/capi/capidrv.h index 1e698e1e269f..4466b2e0176d 100644 --- a/drivers/isdn/capi/capidrv.h +++ b/drivers/isdn/capi/capidrv.h @@ -34,7 +34,7 @@ * per plci state machine */ #define ST_PLCI_NONE 0 /* P-0 */ -#define ST_PLCI_OUTGOING 1 /* P-0.1 */ +#define ST_PLCI_OUTGOING 1 /* P-0.1 */ #define ST_PLCI_ALLOCATED 2 /* P-1 */ #define ST_PLCI_ACTIVE 3 /* P-ACT */ #define ST_PLCI_INCOMING 4 /* P-2 */ @@ -47,20 +47,20 @@ #define ST_PLCI_HELD 11 /* P-HELD */ #define EV_PLCI_CONNECT_REQ 1 /* P-0 -> P-0.1 - */ + */ #define EV_PLCI_CONNECT_CONF_ERROR 2 /* P-0.1 -> P-0 - */ + */ #define EV_PLCI_CONNECT_CONF_OK 3 /* P-0.1 -> P-1 - */ + */ #define EV_PLCI_FACILITY_IND_UP 4 /* P-0 -> P-1 - */ + */ #define EV_PLCI_CONNECT_IND 5 /* P-0 -> P-2 - */ + */ #define EV_PLCI_CONNECT_ACTIVE_IND 6 /* P-1 -> P-ACT - */ + */ #define EV_PLCI_CONNECT_REJECT 7 /* P-2 -> P-5 P-3 -> P-5 - */ + */ #define EV_PLCI_DISCONNECT_REQ 8 /* P-1 -> P-5 P-2 -> P-5 P-3 -> P-5 @@ -68,7 +68,7 @@ P-ACT -> P-5 P-Res -> P-5 (*) P-HELD -> P-5 (*) - */ + */ #define EV_PLCI_DISCONNECT_IND 9 /* P-1 -> P-6 P-2 -> P-6 P-3 -> P-6 @@ -77,35 +77,35 @@ P-ACT -> P-6 P-Res -> P-6 (*) P-HELD -> P-6 (*) - */ + */ #define EV_PLCI_FACILITY_IND_DOWN 10 /* P-0.1 -> P-5 P-1 -> P-5 P-ACT -> P-5 P-2 -> P-5 P-3 -> P-5 P-4 -> P-5 - */ + */ #define EV_PLCI_DISCONNECT_RESP 11 /* P-6 -> P-0 - */ + */ #define EV_PLCI_CONNECT_RESP 12 /* P-6 -> P-0 - */ + */ #define EV_PLCI_RESUME_REQ 13 /* P-0 -> P-0.Res - */ + */ #define EV_PLCI_RESUME_CONF_OK 14 /* P-0.Res -> P-Res - */ + */ #define EV_PLCI_RESUME_CONF_ERROR 15 /* P-0.Res -> P-0 - */ + */ #define EV_PLCI_RESUME_IND 16 /* P-Res -> P-ACT - */ + */ #define EV_PLCI_HOLD_IND 17 /* P-ACT -> P-HELD - */ + */ #define EV_PLCI_RETRIEVE_IND 18 /* P-HELD -> P-ACT - */ + */ #define EV_PLCI_SUSPEND_IND 19 /* P-ACT -> P-5 - */ + */ #define EV_PLCI_CD_IND 20 /* P-2 -> P-5 - */ + */ /* * per ncci state machine diff --git a/drivers/isdn/capi/capilib.c b/drivers/isdn/capi/capilib.c index 0b041df2108c..33361f833c01 100644 --- a/drivers/isdn/capi/capilib.c +++ b/drivers/isdn/capi/capilib.c @@ -4,9 +4,9 @@ #include #include -#define DBG(format, arg...) do { \ -printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ -} while (0) +#define DBG(format, arg...) do { \ + printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ + } while (0) struct capilib_msgidqueue { struct capilib_msgidqueue *next; @@ -28,7 +28,7 @@ struct capilib_ncci { // --------------------------------------------------------------------------- // NCCI Handling -static inline void mq_init(struct capilib_ncci * np) +static inline void mq_init(struct capilib_ncci *np) { u_int i; np->msgidqueue = NULL; @@ -42,7 +42,7 @@ static inline void mq_init(struct capilib_ncci * np) } } -static inline int mq_enqueue(struct capilib_ncci * np, u16 msgid) +static inline int mq_enqueue(struct capilib_ncci *np, u16 msgid) { struct capilib_msgidqueue *mq; if ((mq = np->msgidfree) == NULL) @@ -59,7 +59,7 @@ static inline int mq_enqueue(struct capilib_ncci * np, u16 msgid) return 1; } -static inline int mq_dequeue(struct capilib_ncci * np, u16 msgid) +static inline int mq_dequeue(struct capilib_ncci *np, u16 msgid) { struct capilib_msgidqueue **pp; for (pp = &np->msgidqueue; *pp; pp = &(*pp)->next) { @@ -165,7 +165,7 @@ u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid) continue; if (np->ncci != ncci) continue; - + if (mq_enqueue(np, msgid) == 0) return CAPI_SENDQUEUEFULL; @@ -188,7 +188,7 @@ void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgi continue; if (np->ncci != ncci) continue; - + if (mq_dequeue(np, msgid) == 0) { printk(KERN_ERR "kcapi: msgid %hu ncci 0x%x not on queue\n", msgid, ncci); diff --git a/drivers/isdn/capi/capiutil.c b/drivers/isdn/capi/capiutil.c index 03c469e4451f..d26f17033b68 100644 --- a/drivers/isdn/capi/capiutil.c +++ b/drivers/isdn/capi/capiutil.c @@ -25,149 +25,149 @@ #ifndef CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON char *capi_info2str(u16 reason) { - return ".."; + return ".."; } #else char *capi_info2str(u16 reason) { - switch (reason) { + switch (reason) { /*-- informative values (corresponding message was processed) -----*/ case 0x0001: - return "NCPI not supported by current protocol, NCPI ignored"; + return "NCPI not supported by current protocol, NCPI ignored"; case 0x0002: - return "Flags not supported by current protocol, flags ignored"; + return "Flags not supported by current protocol, flags ignored"; case 0x0003: - return "Alert already sent by another application"; + return "Alert already sent by another application"; /*-- error information concerning CAPI_REGISTER -----*/ case 0x1001: - return "Too many applications"; + return "Too many applications"; case 0x1002: - return "Logical block size too small, must be at least 128 Bytes"; + return "Logical block size too small, must be at least 128 Bytes"; case 0x1003: - return "Buffer exceeds 64 kByte"; + return "Buffer exceeds 64 kByte"; case 0x1004: - return "Message buffer size too small, must be at least 1024 Bytes"; + return "Message buffer size too small, must be at least 1024 Bytes"; case 0x1005: - return "Max. number of logical connections not supported"; + return "Max. number of logical connections not supported"; case 0x1006: - return "Reserved"; + return "Reserved"; case 0x1007: - return "The message could not be accepted because of an internal busy condition"; + return "The message could not be accepted because of an internal busy condition"; case 0x1008: - return "OS resource error (no memory ?)"; + return "OS resource error (no memory ?)"; case 0x1009: - return "CAPI not installed"; + return "CAPI not installed"; case 0x100A: - return "Controller does not support external equipment"; + return "Controller does not support external equipment"; case 0x100B: - return "Controller does only support external equipment"; + return "Controller does only support external equipment"; /*-- error information concerning message exchange functions -----*/ case 0x1101: - return "Illegal application number"; + return "Illegal application number"; case 0x1102: - return "Illegal command or subcommand or message length less than 12 bytes"; + return "Illegal command or subcommand or message length less than 12 bytes"; case 0x1103: - return "The message could not be accepted because of a queue full condition !! The error code does not imply that CAPI cannot receive messages directed to another controller, PLCI or NCCI"; + return "The message could not be accepted because of a queue full condition !! The error code does not imply that CAPI cannot receive messages directed to another controller, PLCI or NCCI"; case 0x1104: - return "Queue is empty"; + return "Queue is empty"; case 0x1105: - return "Queue overflow, a message was lost !! This indicates a configuration error. The only recovery from this error is to perform a CAPI_RELEASE"; + return "Queue overflow, a message was lost !! This indicates a configuration error. The only recovery from this error is to perform a CAPI_RELEASE"; case 0x1106: - return "Unknown notification parameter"; + return "Unknown notification parameter"; case 0x1107: - return "The Message could not be accepted because of an internal busy condition"; + return "The Message could not be accepted because of an internal busy condition"; case 0x1108: - return "OS Resource error (no memory ?)"; + return "OS Resource error (no memory ?)"; case 0x1109: - return "CAPI not installed"; + return "CAPI not installed"; case 0x110A: - return "Controller does not support external equipment"; + return "Controller does not support external equipment"; case 0x110B: - return "Controller does only support external equipment"; + return "Controller does only support external equipment"; /*-- error information concerning resource / coding problems -----*/ case 0x2001: - return "Message not supported in current state"; + return "Message not supported in current state"; case 0x2002: - return "Illegal Controller / PLCI / NCCI"; + return "Illegal Controller / PLCI / NCCI"; case 0x2003: - return "Out of PLCI"; + return "Out of PLCI"; case 0x2004: - return "Out of NCCI"; + return "Out of NCCI"; case 0x2005: - return "Out of LISTEN"; + return "Out of LISTEN"; case 0x2006: - return "Out of FAX resources (protocol T.30)"; + return "Out of FAX resources (protocol T.30)"; case 0x2007: - return "Illegal message parameter coding"; + return "Illegal message parameter coding"; /*-- error information concerning requested services -----*/ case 0x3001: - return "B1 protocol not supported"; - case 0x3002: - return "B2 protocol not supported"; - case 0x3003: - return "B3 protocol not supported"; - case 0x3004: - return "B1 protocol parameter not supported"; - case 0x3005: - return "B2 protocol parameter not supported"; - case 0x3006: - return "B3 protocol parameter not supported"; - case 0x3007: - return "B protocol combination not supported"; - case 0x3008: - return "NCPI not supported"; - case 0x3009: - return "CIP Value unknown"; - case 0x300A: - return "Flags not supported (reserved bits)"; - case 0x300B: - return "Facility not supported"; - case 0x300C: - return "Data length not supported by current protocol"; - case 0x300D: - return "Reset procedure not supported by current protocol"; + return "B1 protocol not supported"; + case 0x3002: + return "B2 protocol not supported"; + case 0x3003: + return "B3 protocol not supported"; + case 0x3004: + return "B1 protocol parameter not supported"; + case 0x3005: + return "B2 protocol parameter not supported"; + case 0x3006: + return "B3 protocol parameter not supported"; + case 0x3007: + return "B protocol combination not supported"; + case 0x3008: + return "NCPI not supported"; + case 0x3009: + return "CIP Value unknown"; + case 0x300A: + return "Flags not supported (reserved bits)"; + case 0x300B: + return "Facility not supported"; + case 0x300C: + return "Data length not supported by current protocol"; + case 0x300D: + return "Reset procedure not supported by current protocol"; /*-- informations about the clearing of a physical connection -----*/ - case 0x3301: - return "Protocol error layer 1 (broken line or B-channel removed by signalling protocol)"; - case 0x3302: - return "Protocol error layer 2"; - case 0x3303: - return "Protocol error layer 3"; - case 0x3304: - return "Another application got that call"; + case 0x3301: + return "Protocol error layer 1 (broken line or B-channel removed by signalling protocol)"; + case 0x3302: + return "Protocol error layer 2"; + case 0x3303: + return "Protocol error layer 3"; + case 0x3304: + return "Another application got that call"; /*-- T.30 specific reasons -----*/ - case 0x3311: - return "Connecting not successful (remote station is no FAX G3 machine)"; - case 0x3312: - return "Connecting not successful (training error)"; - case 0x3313: - return "Disconnected before transfer (remote station does not support transfer mode, e.g. resolution)"; - case 0x3314: - return "Disconnected during transfer (remote abort)"; - case 0x3315: - return "Disconnected during transfer (remote procedure error, e.g. unsuccessful repetition of T.30 commands)"; - case 0x3316: - return "Disconnected during transfer (local tx data underrun)"; - case 0x3317: - return "Disconnected during transfer (local rx data overflow)"; - case 0x3318: - return "Disconnected during transfer (local abort)"; - case 0x3319: - return "Illegal parameter coding (e.g. SFF coding error)"; + case 0x3311: + return "Connecting not successful (remote station is no FAX G3 machine)"; + case 0x3312: + return "Connecting not successful (training error)"; + case 0x3313: + return "Disconnected before transfer (remote station does not support transfer mode, e.g. resolution)"; + case 0x3314: + return "Disconnected during transfer (remote abort)"; + case 0x3315: + return "Disconnected during transfer (remote procedure error, e.g. unsuccessful repetition of T.30 commands)"; + case 0x3316: + return "Disconnected during transfer (local tx data underrun)"; + case 0x3317: + return "Disconnected during transfer (local rx data overflow)"; + case 0x3318: + return "Disconnected during transfer (local abort)"; + case 0x3319: + return "Illegal parameter coding (e.g. SFF coding error)"; /*-- disconnect causes from the network according to ETS 300 102-1/Q.931 -----*/ case 0x3481: return "Unallocated (unassigned) number"; case 0x3482: return "No route to specified transit network"; case 0x3483: return "No route to destination"; case 0x3486: return "Channel unacceptable"; - case 0x3487: - return "Call awarded and being delivered in an established channel"; + case 0x3487: + return "Call awarded and being delivered in an established channel"; case 0x3490: return "Normal call clearing"; case 0x3491: return "User busy"; case 0x3492: return "No user responding"; @@ -217,7 +217,7 @@ char *capi_info2str(u16 reason) case 0x34FF: return "Interworking, unspecified"; default: return "No additional information"; - } + } } #endif @@ -235,169 +235,169 @@ typedef struct { static _cdef cdef[] = { - /*00 */ - {_CEND}, - /*01 */ - {_CEND}, - /*02 */ - {_CEND}, - /*03 */ - {_CDWORD, offsetof(_cmsg, adr.adrController)}, - /*04 */ - {_CMSTRUCT, offsetof(_cmsg, AdditionalInfo)}, - /*05 */ - {_CSTRUCT, offsetof(_cmsg, B1configuration)}, - /*06 */ - {_CWORD, offsetof(_cmsg, B1protocol)}, - /*07 */ - {_CSTRUCT, offsetof(_cmsg, B2configuration)}, - /*08 */ - {_CWORD, offsetof(_cmsg, B2protocol)}, - /*09 */ - {_CSTRUCT, offsetof(_cmsg, B3configuration)}, - /*0a */ - {_CWORD, offsetof(_cmsg, B3protocol)}, - /*0b */ - {_CSTRUCT, offsetof(_cmsg, BC)}, - /*0c */ - {_CSTRUCT, offsetof(_cmsg, BChannelinformation)}, - /*0d */ - {_CMSTRUCT, offsetof(_cmsg, BProtocol)}, - /*0e */ - {_CSTRUCT, offsetof(_cmsg, CalledPartyNumber)}, - /*0f */ - {_CSTRUCT, offsetof(_cmsg, CalledPartySubaddress)}, - /*10 */ - {_CSTRUCT, offsetof(_cmsg, CallingPartyNumber)}, - /*11 */ - {_CSTRUCT, offsetof(_cmsg, CallingPartySubaddress)}, - /*12 */ - {_CDWORD, offsetof(_cmsg, CIPmask)}, - /*13 */ - {_CDWORD, offsetof(_cmsg, CIPmask2)}, - /*14 */ - {_CWORD, offsetof(_cmsg, CIPValue)}, - /*15 */ - {_CDWORD, offsetof(_cmsg, Class)}, - /*16 */ - {_CSTRUCT, offsetof(_cmsg, ConnectedNumber)}, - /*17 */ - {_CSTRUCT, offsetof(_cmsg, ConnectedSubaddress)}, - /*18 */ - {_CDWORD, offsetof(_cmsg, Data)}, - /*19 */ - {_CWORD, offsetof(_cmsg, DataHandle)}, - /*1a */ - {_CWORD, offsetof(_cmsg, DataLength)}, - /*1b */ - {_CSTRUCT, offsetof(_cmsg, FacilityConfirmationParameter)}, - /*1c */ - {_CSTRUCT, offsetof(_cmsg, Facilitydataarray)}, - /*1d */ - {_CSTRUCT, offsetof(_cmsg, FacilityIndicationParameter)}, - /*1e */ - {_CSTRUCT, offsetof(_cmsg, FacilityRequestParameter)}, - /*1f */ - {_CWORD, offsetof(_cmsg, FacilitySelector)}, - /*20 */ - {_CWORD, offsetof(_cmsg, Flags)}, - /*21 */ - {_CDWORD, offsetof(_cmsg, Function)}, - /*22 */ - {_CSTRUCT, offsetof(_cmsg, HLC)}, - /*23 */ - {_CWORD, offsetof(_cmsg, Info)}, - /*24 */ - {_CSTRUCT, offsetof(_cmsg, InfoElement)}, - /*25 */ - {_CDWORD, offsetof(_cmsg, InfoMask)}, - /*26 */ - {_CWORD, offsetof(_cmsg, InfoNumber)}, - /*27 */ - {_CSTRUCT, offsetof(_cmsg, Keypadfacility)}, - /*28 */ - {_CSTRUCT, offsetof(_cmsg, LLC)}, - /*29 */ - {_CSTRUCT, offsetof(_cmsg, ManuData)}, - /*2a */ - {_CDWORD, offsetof(_cmsg, ManuID)}, - /*2b */ - {_CSTRUCT, offsetof(_cmsg, NCPI)}, - /*2c */ - {_CWORD, offsetof(_cmsg, Reason)}, - /*2d */ - {_CWORD, offsetof(_cmsg, Reason_B3)}, - /*2e */ - {_CWORD, offsetof(_cmsg, Reject)}, - /*2f */ - {_CSTRUCT, offsetof(_cmsg, Useruserdata)} + /*00 */ + {_CEND}, + /*01 */ + {_CEND}, + /*02 */ + {_CEND}, + /*03 */ + {_CDWORD, offsetof(_cmsg, adr.adrController)}, + /*04 */ + {_CMSTRUCT, offsetof(_cmsg, AdditionalInfo)}, + /*05 */ + {_CSTRUCT, offsetof(_cmsg, B1configuration)}, + /*06 */ + {_CWORD, offsetof(_cmsg, B1protocol)}, + /*07 */ + {_CSTRUCT, offsetof(_cmsg, B2configuration)}, + /*08 */ + {_CWORD, offsetof(_cmsg, B2protocol)}, + /*09 */ + {_CSTRUCT, offsetof(_cmsg, B3configuration)}, + /*0a */ + {_CWORD, offsetof(_cmsg, B3protocol)}, + /*0b */ + {_CSTRUCT, offsetof(_cmsg, BC)}, + /*0c */ + {_CSTRUCT, offsetof(_cmsg, BChannelinformation)}, + /*0d */ + {_CMSTRUCT, offsetof(_cmsg, BProtocol)}, + /*0e */ + {_CSTRUCT, offsetof(_cmsg, CalledPartyNumber)}, + /*0f */ + {_CSTRUCT, offsetof(_cmsg, CalledPartySubaddress)}, + /*10 */ + {_CSTRUCT, offsetof(_cmsg, CallingPartyNumber)}, + /*11 */ + {_CSTRUCT, offsetof(_cmsg, CallingPartySubaddress)}, + /*12 */ + {_CDWORD, offsetof(_cmsg, CIPmask)}, + /*13 */ + {_CDWORD, offsetof(_cmsg, CIPmask2)}, + /*14 */ + {_CWORD, offsetof(_cmsg, CIPValue)}, + /*15 */ + {_CDWORD, offsetof(_cmsg, Class)}, + /*16 */ + {_CSTRUCT, offsetof(_cmsg, ConnectedNumber)}, + /*17 */ + {_CSTRUCT, offsetof(_cmsg, ConnectedSubaddress)}, + /*18 */ + {_CDWORD, offsetof(_cmsg, Data)}, + /*19 */ + {_CWORD, offsetof(_cmsg, DataHandle)}, + /*1a */ + {_CWORD, offsetof(_cmsg, DataLength)}, + /*1b */ + {_CSTRUCT, offsetof(_cmsg, FacilityConfirmationParameter)}, + /*1c */ + {_CSTRUCT, offsetof(_cmsg, Facilitydataarray)}, + /*1d */ + {_CSTRUCT, offsetof(_cmsg, FacilityIndicationParameter)}, + /*1e */ + {_CSTRUCT, offsetof(_cmsg, FacilityRequestParameter)}, + /*1f */ + {_CWORD, offsetof(_cmsg, FacilitySelector)}, + /*20 */ + {_CWORD, offsetof(_cmsg, Flags)}, + /*21 */ + {_CDWORD, offsetof(_cmsg, Function)}, + /*22 */ + {_CSTRUCT, offsetof(_cmsg, HLC)}, + /*23 */ + {_CWORD, offsetof(_cmsg, Info)}, + /*24 */ + {_CSTRUCT, offsetof(_cmsg, InfoElement)}, + /*25 */ + {_CDWORD, offsetof(_cmsg, InfoMask)}, + /*26 */ + {_CWORD, offsetof(_cmsg, InfoNumber)}, + /*27 */ + {_CSTRUCT, offsetof(_cmsg, Keypadfacility)}, + /*28 */ + {_CSTRUCT, offsetof(_cmsg, LLC)}, + /*29 */ + {_CSTRUCT, offsetof(_cmsg, ManuData)}, + /*2a */ + {_CDWORD, offsetof(_cmsg, ManuID)}, + /*2b */ + {_CSTRUCT, offsetof(_cmsg, NCPI)}, + /*2c */ + {_CWORD, offsetof(_cmsg, Reason)}, + /*2d */ + {_CWORD, offsetof(_cmsg, Reason_B3)}, + /*2e */ + {_CWORD, offsetof(_cmsg, Reject)}, + /*2f */ + {_CSTRUCT, offsetof(_cmsg, Useruserdata)} }; static unsigned char *cpars[] = { - /* ALERT_REQ */ [0x01] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", - /* CONNECT_REQ */ [0x02] = "\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", - /* DISCONNECT_REQ */ [0x04] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", - /* LISTEN_REQ */ [0x05] = "\x03\x25\x12\x13\x10\x11\x01", - /* INFO_REQ */ [0x08] = "\x03\x0e\x04\x0c\x27\x2f\x1c\x01\x01", - /* FACILITY_REQ */ [0x09] = "\x03\x1f\x1e\x01", - /* SELECT_B_PROTOCOL_REQ */ [0x0a] = "\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", - /* CONNECT_B3_REQ */ [0x0b] = "\x03\x2b\x01", - /* DISCONNECT_B3_REQ */ [0x0d] = "\x03\x2b\x01", - /* DATA_B3_REQ */ [0x0f] = "\x03\x18\x1a\x19\x20\x01", - /* RESET_B3_REQ */ [0x10] = "\x03\x2b\x01", - /* ALERT_CONF */ [0x13] = "\x03\x23\x01", - /* CONNECT_CONF */ [0x14] = "\x03\x23\x01", - /* DISCONNECT_CONF */ [0x16] = "\x03\x23\x01", - /* LISTEN_CONF */ [0x17] = "\x03\x23\x01", - /* MANUFACTURER_REQ */ [0x18] = "\x03\x2a\x15\x21\x29\x01", - /* INFO_CONF */ [0x1a] = "\x03\x23\x01", - /* FACILITY_CONF */ [0x1b] = "\x03\x23\x1f\x1b\x01", - /* SELECT_B_PROTOCOL_CONF */ [0x1c] = "\x03\x23\x01", - /* CONNECT_B3_CONF */ [0x1d] = "\x03\x23\x01", - /* DISCONNECT_B3_CONF */ [0x1f] = "\x03\x23\x01", - /* DATA_B3_CONF */ [0x21] = "\x03\x19\x23\x01", - /* RESET_B3_CONF */ [0x22] = "\x03\x23\x01", - /* CONNECT_IND */ [0x26] = "\x03\x14\x0e\x10\x0f\x11\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", - /* CONNECT_ACTIVE_IND */ [0x27] = "\x03\x16\x17\x28\x01", - /* DISCONNECT_IND */ [0x28] = "\x03\x2c\x01", - /* MANUFACTURER_CONF */ [0x2a] = "\x03\x2a\x15\x21\x29\x01", - /* INFO_IND */ [0x2c] = "\x03\x26\x24\x01", - /* FACILITY_IND */ [0x2d] = "\x03\x1f\x1d\x01", - /* CONNECT_B3_IND */ [0x2f] = "\x03\x2b\x01", - /* CONNECT_B3_ACTIVE_IND */ [0x30] = "\x03\x2b\x01", - /* DISCONNECT_B3_IND */ [0x31] = "\x03\x2d\x2b\x01", - /* DATA_B3_IND */ [0x33] = "\x03\x18\x1a\x19\x20\x01", - /* RESET_B3_IND */ [0x34] = "\x03\x2b\x01", - /* CONNECT_B3_T90_ACTIVE_IND */ [0x35] = "\x03\x2b\x01", - /* CONNECT_RESP */ [0x38] = "\x03\x2e\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x28\x04\x0c\x27\x2f\x1c\x01\x01", - /* CONNECT_ACTIVE_RESP */ [0x39] = "\x03\x01", - /* DISCONNECT_RESP */ [0x3a] = "\x03\x01", - /* MANUFACTURER_IND */ [0x3c] = "\x03\x2a\x15\x21\x29\x01", - /* INFO_RESP */ [0x3e] = "\x03\x01", - /* FACILITY_RESP */ [0x3f] = "\x03\x1f\x01", - /* CONNECT_B3_RESP */ [0x41] = "\x03\x2e\x2b\x01", - /* CONNECT_B3_ACTIVE_RESP */ [0x42] = "\x03\x01", - /* DISCONNECT_B3_RESP */ [0x43] = "\x03\x01", - /* DATA_B3_RESP */ [0x45] = "\x03\x19\x01", - /* RESET_B3_RESP */ [0x46] = "\x03\x01", - /* CONNECT_B3_T90_ACTIVE_RESP */ [0x47] = "\x03\x01", - /* MANUFACTURER_RESP */ [0x4e] = "\x03\x2a\x15\x21\x29\x01", + /* ALERT_REQ */ [0x01] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", + /* CONNECT_REQ */ [0x02] = "\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", + /* DISCONNECT_REQ */ [0x04] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", + /* LISTEN_REQ */ [0x05] = "\x03\x25\x12\x13\x10\x11\x01", + /* INFO_REQ */ [0x08] = "\x03\x0e\x04\x0c\x27\x2f\x1c\x01\x01", + /* FACILITY_REQ */ [0x09] = "\x03\x1f\x1e\x01", + /* SELECT_B_PROTOCOL_REQ */ [0x0a] = "\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", + /* CONNECT_B3_REQ */ [0x0b] = "\x03\x2b\x01", + /* DISCONNECT_B3_REQ */ [0x0d] = "\x03\x2b\x01", + /* DATA_B3_REQ */ [0x0f] = "\x03\x18\x1a\x19\x20\x01", + /* RESET_B3_REQ */ [0x10] = "\x03\x2b\x01", + /* ALERT_CONF */ [0x13] = "\x03\x23\x01", + /* CONNECT_CONF */ [0x14] = "\x03\x23\x01", + /* DISCONNECT_CONF */ [0x16] = "\x03\x23\x01", + /* LISTEN_CONF */ [0x17] = "\x03\x23\x01", + /* MANUFACTURER_REQ */ [0x18] = "\x03\x2a\x15\x21\x29\x01", + /* INFO_CONF */ [0x1a] = "\x03\x23\x01", + /* FACILITY_CONF */ [0x1b] = "\x03\x23\x1f\x1b\x01", + /* SELECT_B_PROTOCOL_CONF */ [0x1c] = "\x03\x23\x01", + /* CONNECT_B3_CONF */ [0x1d] = "\x03\x23\x01", + /* DISCONNECT_B3_CONF */ [0x1f] = "\x03\x23\x01", + /* DATA_B3_CONF */ [0x21] = "\x03\x19\x23\x01", + /* RESET_B3_CONF */ [0x22] = "\x03\x23\x01", + /* CONNECT_IND */ [0x26] = "\x03\x14\x0e\x10\x0f\x11\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", + /* CONNECT_ACTIVE_IND */ [0x27] = "\x03\x16\x17\x28\x01", + /* DISCONNECT_IND */ [0x28] = "\x03\x2c\x01", + /* MANUFACTURER_CONF */ [0x2a] = "\x03\x2a\x15\x21\x29\x01", + /* INFO_IND */ [0x2c] = "\x03\x26\x24\x01", + /* FACILITY_IND */ [0x2d] = "\x03\x1f\x1d\x01", + /* CONNECT_B3_IND */ [0x2f] = "\x03\x2b\x01", + /* CONNECT_B3_ACTIVE_IND */ [0x30] = "\x03\x2b\x01", + /* DISCONNECT_B3_IND */ [0x31] = "\x03\x2d\x2b\x01", + /* DATA_B3_IND */ [0x33] = "\x03\x18\x1a\x19\x20\x01", + /* RESET_B3_IND */ [0x34] = "\x03\x2b\x01", + /* CONNECT_B3_T90_ACTIVE_IND */ [0x35] = "\x03\x2b\x01", + /* CONNECT_RESP */ [0x38] = "\x03\x2e\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x28\x04\x0c\x27\x2f\x1c\x01\x01", + /* CONNECT_ACTIVE_RESP */ [0x39] = "\x03\x01", + /* DISCONNECT_RESP */ [0x3a] = "\x03\x01", + /* MANUFACTURER_IND */ [0x3c] = "\x03\x2a\x15\x21\x29\x01", + /* INFO_RESP */ [0x3e] = "\x03\x01", + /* FACILITY_RESP */ [0x3f] = "\x03\x1f\x01", + /* CONNECT_B3_RESP */ [0x41] = "\x03\x2e\x2b\x01", + /* CONNECT_B3_ACTIVE_RESP */ [0x42] = "\x03\x01", + /* DISCONNECT_B3_RESP */ [0x43] = "\x03\x01", + /* DATA_B3_RESP */ [0x45] = "\x03\x19\x01", + /* RESET_B3_RESP */ [0x46] = "\x03\x01", + /* CONNECT_B3_T90_ACTIVE_RESP */ [0x47] = "\x03\x01", + /* MANUFACTURER_RESP */ [0x4e] = "\x03\x2a\x15\x21\x29\x01", }; /*-------------------------------------------------------*/ -#define byteTLcpy(x,y) *(u8 *)(x)=*(u8 *)(y); -#define wordTLcpy(x,y) *(u16 *)(x)=*(u16 *)(y); -#define dwordTLcpy(x,y) memcpy(x,y,4); -#define structTLcpy(x,y,l) memcpy (x,y,l) -#define structTLcpyovl(x,y,l) memmove (x,y,l) +#define byteTLcpy(x, y) *(u8 *)(x) = *(u8 *)(y); +#define wordTLcpy(x, y) *(u16 *)(x) = *(u16 *)(y); +#define dwordTLcpy(x, y) memcpy(x, y, 4); +#define structTLcpy(x, y, l) memcpy(x, y, l) +#define structTLcpyovl(x, y, l) memmove(x, y, l) -#define byteTRcpy(x,y) *(u8 *)(y)=*(u8 *)(x); -#define wordTRcpy(x,y) *(u16 *)(y)=*(u16 *)(x); -#define dwordTRcpy(x,y) memcpy(y,x,4); -#define structTRcpy(x,y,l) memcpy (y,x,l) -#define structTRcpyovl(x,y,l) memmove (y,x,l) +#define byteTRcpy(x, y) *(u8 *)(y) = *(u8 *)(x); +#define wordTRcpy(x, y) *(u16 *)(y) = *(u16 *)(x); +#define dwordTRcpy(x, y) memcpy(y, x, 4); +#define structTRcpy(x, y, l) memcpy(y, x, l) +#define structTRcpyovl(x, y, l) memmove(y, x, l) /*-------------------------------------------------------*/ static unsigned command_2_index(unsigned c, unsigned sc) @@ -414,9 +414,9 @@ static unsigned command_2_index(unsigned c, unsigned sc) /*-------------------------------------------------------*/ #define TYP (cdef[cmsg->par[cmsg->p]].typ) -#define OFF (((u8 *)cmsg)+cdef[cmsg->par[cmsg->p]].off) +#define OFF (((u8 *)cmsg) + cdef[cmsg->par[cmsg->p]].off) -static void jumpcstruct(_cmsg * cmsg) +static void jumpcstruct(_cmsg *cmsg) { unsigned layer; for (cmsg->p++, layer = 1; layer;) { @@ -433,7 +433,7 @@ static void jumpcstruct(_cmsg * cmsg) } } /*-------------------------------------------------------*/ -static void pars_2_message(_cmsg * cmsg) +static void pars_2_message(_cmsg *cmsg) { for (; TYP != _CEND; cmsg->p++) { @@ -499,7 +499,7 @@ static void pars_2_message(_cmsg * cmsg) * Return value: 0 for success */ -unsigned capi_cmsg2message(_cmsg * cmsg, u8 * msg) +unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg) { cmsg->m = msg; cmsg->l = 8; @@ -518,7 +518,7 @@ unsigned capi_cmsg2message(_cmsg * cmsg, u8 * msg) } /*-------------------------------------------------------*/ -static void message_2_pars(_cmsg * cmsg) +static void message_2_pars(_cmsg *cmsg) { for (; TYP != _CEND; cmsg->p++) { @@ -569,7 +569,7 @@ static void message_2_pars(_cmsg * cmsg) * Return value: 0 for success */ -unsigned capi_message2cmsg(_cmsg * cmsg, u8 * msg) +unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg) { memset(cmsg, 0, sizeof(_cmsg)); cmsg->m = msg; @@ -600,7 +600,7 @@ unsigned capi_message2cmsg(_cmsg * cmsg, u8 * msg) * Return value: 0 for success */ -unsigned capi_cmsg_header(_cmsg * cmsg, u16 _ApplId, +unsigned capi_cmsg_header(_cmsg *cmsg, u16 _ApplId, u8 _Command, u8 _Subcommand, u16 _Messagenumber, u32 _Controller) { @@ -689,54 +689,54 @@ char *capi_cmd2str(u8 cmd, u8 subcmd) static char *pnames[] = { - /*00 */ NULL, - /*01 */ NULL, - /*02 */ NULL, - /*03 */ "Controller/PLCI/NCCI", - /*04 */ "AdditionalInfo", - /*05 */ "B1configuration", - /*06 */ "B1protocol", - /*07 */ "B2configuration", - /*08 */ "B2protocol", - /*09 */ "B3configuration", - /*0a */ "B3protocol", - /*0b */ "BC", - /*0c */ "BChannelinformation", - /*0d */ "BProtocol", - /*0e */ "CalledPartyNumber", - /*0f */ "CalledPartySubaddress", - /*10 */ "CallingPartyNumber", - /*11 */ "CallingPartySubaddress", - /*12 */ "CIPmask", - /*13 */ "CIPmask2", - /*14 */ "CIPValue", - /*15 */ "Class", - /*16 */ "ConnectedNumber", - /*17 */ "ConnectedSubaddress", - /*18 */ "Data32", - /*19 */ "DataHandle", - /*1a */ "DataLength", - /*1b */ "FacilityConfirmationParameter", - /*1c */ "Facilitydataarray", - /*1d */ "FacilityIndicationParameter", - /*1e */ "FacilityRequestParameter", - /*1f */ "FacilitySelector", - /*20 */ "Flags", - /*21 */ "Function", - /*22 */ "HLC", - /*23 */ "Info", - /*24 */ "InfoElement", - /*25 */ "InfoMask", - /*26 */ "InfoNumber", - /*27 */ "Keypadfacility", - /*28 */ "LLC", - /*29 */ "ManuData", - /*2a */ "ManuID", - /*2b */ "NCPI", - /*2c */ "Reason", - /*2d */ "Reason_B3", - /*2e */ "Reject", - /*2f */ "Useruserdata" + /*00 */ NULL, + /*01 */ NULL, + /*02 */ NULL, + /*03 */ "Controller/PLCI/NCCI", + /*04 */ "AdditionalInfo", + /*05 */ "B1configuration", + /*06 */ "B1protocol", + /*07 */ "B2configuration", + /*08 */ "B2protocol", + /*09 */ "B3configuration", + /*0a */ "B3protocol", + /*0b */ "BC", + /*0c */ "BChannelinformation", + /*0d */ "BProtocol", + /*0e */ "CalledPartyNumber", + /*0f */ "CalledPartySubaddress", + /*10 */ "CallingPartyNumber", + /*11 */ "CallingPartySubaddress", + /*12 */ "CIPmask", + /*13 */ "CIPmask2", + /*14 */ "CIPValue", + /*15 */ "Class", + /*16 */ "ConnectedNumber", + /*17 */ "ConnectedSubaddress", + /*18 */ "Data32", + /*19 */ "DataHandle", + /*1a */ "DataLength", + /*1b */ "FacilityConfirmationParameter", + /*1c */ "Facilitydataarray", + /*1d */ "FacilityIndicationParameter", + /*1e */ "FacilityRequestParameter", + /*1f */ "FacilitySelector", + /*20 */ "Flags", + /*21 */ "Function", + /*22 */ "HLC", + /*23 */ "Info", + /*24 */ "InfoElement", + /*25 */ "InfoMask", + /*26 */ "InfoNumber", + /*27 */ "Keypadfacility", + /*28 */ "LLC", + /*29 */ "ManuData", + /*2a */ "ManuID", + /*2b */ "NCPI", + /*2c */ "Reason", + /*2d */ "Reason_B3", + /*2e */ "Reject", + /*2f */ "Useruserdata" }; @@ -744,10 +744,10 @@ static char *pnames[] = #include /*-------------------------------------------------------*/ -static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt,...) +static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt, ...) { va_list f; - size_t n,r; + size_t n, r; if (!cdb) return NULL; @@ -783,7 +783,7 @@ static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt,...) return cdb; } -static _cdebbuf *printstructlen(_cdebbuf *cdb, u8 * m, unsigned len) +static _cdebbuf *printstructlen(_cdebbuf *cdb, u8 *m, unsigned len) { unsigned hex = 0; @@ -807,7 +807,7 @@ static _cdebbuf *printstructlen(_cdebbuf *cdb, u8 * m, unsigned len) return cdb; } -static _cdebbuf *printstruct(_cdebbuf *cdb, u8 * m) +static _cdebbuf *printstruct(_cdebbuf *cdb, u8 *m) { unsigned len; @@ -940,7 +940,7 @@ void cdebbuf_free(_cdebbuf *cdb) * The returned buffer should be freed by a call to cdebbuf_free() after use. */ -_cdebbuf *capi_message2str(u8 * msg) +_cdebbuf *capi_message2str(u8 *msg) { _cdebbuf *cdb; _cmsg *cmsg; @@ -964,10 +964,10 @@ _cdebbuf *capi_message2str(u8 * msg) cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)]; cdb = bufprint(cdb, "%-26s ID=%03d #0x%04x LEN=%04d\n", - mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], - ((unsigned short *) msg)[1], - ((unsigned short *) msg)[3], - ((unsigned short *) msg)[0]); + mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], + ((unsigned short *) msg)[1], + ((unsigned short *) msg)[3], + ((unsigned short *) msg)[0]); cdb = protocol_message_2_pars(cdb, cmsg, 1); if (unlikely(cmsg != g_cmsg)) @@ -986,7 +986,7 @@ _cdebbuf *capi_message2str(u8 * msg) * The returned buffer should be freed by a call to cdebbuf_free() after use. */ -_cdebbuf *capi_cmsg2str(_cmsg * cmsg) +_cdebbuf *capi_cmsg2str(_cmsg *cmsg) { _cdebbuf *cdb; @@ -998,17 +998,17 @@ _cdebbuf *capi_cmsg2str(_cmsg * cmsg) cmsg->l = 8; cmsg->p = 0; cdb = bufprint(cdb, "%s ID=%03d #0x%04x LEN=%04d\n", - mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], - ((u16 *) cmsg->m)[1], - ((u16 *) cmsg->m)[3], - ((u16 *) cmsg->m)[0]); + mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], + ((u16 *) cmsg->m)[1], + ((u16 *) cmsg->m)[3], + ((u16 *) cmsg->m)[0]); cdb = protocol_message_2_pars(cdb, cmsg, 1); return cdb; } int __init cdebug_init(void) { - g_cmsg= kmalloc(sizeof(_cmsg), GFP_KERNEL); + g_cmsg = kmalloc(sizeof(_cmsg), GFP_KERNEL); if (!g_cmsg) return -ENOMEM; g_debbuf = kmalloc(sizeof(_cdebbuf), GFP_KERNEL); @@ -1041,12 +1041,12 @@ void __exit cdebug_exit(void) static _cdebbuf g_debbuf = {"CONFIG_CAPI_TRACE not enabled", NULL, 0, 0}; -_cdebbuf *capi_message2str(u8 * msg) +_cdebbuf *capi_message2str(u8 *msg) { return &g_debbuf; } -_cdebbuf *capi_cmsg2str(_cmsg * cmsg) +_cdebbuf *capi_cmsg2str(_cmsg *cmsg) { return &g_debbuf; } diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 2b33b2627fce..9b1b274c7d25 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -1,10 +1,10 @@ /* $Id: kcapi.c,v 1.1.2.8 2004/03/26 19:57:20 armin Exp $ - * + * * Kernel CAPI 2.0 Module - * + * * Copyright 1999 by Carsten Paeth * Copyright 2002 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -55,7 +55,7 @@ struct capictr_event { /* ------------------------------------------------------------- */ -static struct capi_version driver_version = {2, 0, 1, 1<<4}; +static struct capi_version driver_version = {2, 0, 1, 1 << 4}; static char driver_serial[CAPI_SERIAL_LEN] = "0004711"; static char capi_manufakturer[64] = "AVM Berlin"; @@ -172,7 +172,7 @@ register_appl(struct capi_ctr *ctr, u16 applid, capi_register_params *rparam) static void release_appl(struct capi_ctr *ctr, u16 applid) { DBG("applid %#x", applid); - + ctr->release_appl(ctr, applid); capi_ctr_put(ctr); } @@ -186,7 +186,7 @@ static void notify_up(u32 contr) mutex_lock(&capi_controller_lock); if (showcapimsgs & 1) - printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr); + printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr); ctr = get_capi_ctr_by_nr(contr); if (ctr) { @@ -352,16 +352,16 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl, cdb = capi_message2str(skb->data); if (cdb) { printk(KERN_INFO "kcapi: controller [%03d] not active, got: %s", - ctr->cnr, cdb->buf); + ctr->cnr, cdb->buf); cdebbuf_free(cdb); } else printk(KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n", - ctr->cnr); + ctr->cnr); goto error; } cmd = CAPIMSG_COMMAND(skb->data); - subcmd = CAPIMSG_SUBCOMMAND(skb->data); + subcmd = CAPIMSG_SUBCOMMAND(skb->data); if (cmd == CAPI_DATA_B3 && subcmd == CAPI_IND) { ctr->nrecvdatapkt++; if (ctr->traceflag > 2) @@ -382,13 +382,13 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl, cdb = capi_message2str(skb->data); if (cdb) { printk(KERN_DEBUG "kcapi: got [%03d] %s\n", - ctr->cnr, cdb->buf); + ctr->cnr, cdb->buf); cdebbuf_free(cdb); } else printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u, cannot trace\n", - ctr->cnr, CAPIMSG_APPID(skb->data), - capi_cmd2str(cmd, subcmd), - CAPIMSG_LEN(skb->data)); + ctr->cnr, CAPIMSG_APPID(skb->data), + capi_cmd2str(cmd, subcmd), + CAPIMSG_LEN(skb->data)); } } @@ -400,12 +400,12 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl, cdb = capi_message2str(skb->data); if (cdb) { printk(KERN_ERR "kcapi: handle_message: applid %d state released (%s)\n", - CAPIMSG_APPID(skb->data), cdb->buf); + CAPIMSG_APPID(skb->data), cdb->buf); cdebbuf_free(cdb); } else printk(KERN_ERR "kcapi: handle_message: applid %d state released (%s) cannot trace\n", - CAPIMSG_APPID(skb->data), - capi_cmd2str(cmd, subcmd)); + CAPIMSG_APPID(skb->data), + capi_cmd2str(cmd, subcmd)); goto error; } skb_queue_tail(&ap->recv_queue, skb); @@ -519,7 +519,7 @@ int attach_capi_ctr(struct capi_ctr *ctr) if (i == CAPI_MAXCONTR) { mutex_unlock(&capi_controller_lock); printk(KERN_ERR "kcapi: out of controller slots\n"); - return -EBUSY; + return -EBUSY; } capi_controller[i] = ctr; @@ -541,7 +541,7 @@ int attach_capi_ctr(struct capi_ctr *ctr) mutex_unlock(&capi_controller_lock); printk(KERN_NOTICE "kcapi: controller [%03d]: %s attached\n", - ctr->cnr, ctr->name); + ctr->cnr, ctr->name); return 0; } @@ -772,7 +772,7 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb) u8 cmd, subcmd; DBG("applid %#x", ap->applid); - + if (ncontrollers == 0) return CAPI_REGNOTINSTALLED; if ((ap->applid == 0) || ap->release_in_progress) @@ -794,9 +794,9 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb) return CAPI_SENDQUEUEFULL; cmd = CAPIMSG_COMMAND(skb->data); - subcmd = CAPIMSG_SUBCOMMAND(skb->data); + subcmd = CAPIMSG_SUBCOMMAND(skb->data); - if (cmd == CAPI_DATA_B3 && subcmd== CAPI_REQ) { + if (cmd == CAPI_DATA_B3 && subcmd == CAPI_REQ) { ctr->nsentdatapkt++; ap->nsentdatapkt++; if (ctr->traceflag > 2) @@ -819,15 +819,15 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb) _cdebbuf *cdb = capi_message2str(skb->data); if (cdb) { printk(KERN_DEBUG "kcapi: put [%03d] %s\n", - CAPIMSG_CONTROLLER(skb->data), - cdb->buf); + CAPIMSG_CONTROLLER(skb->data), + cdb->buf); cdebbuf_free(cdb); } else printk(KERN_DEBUG "kcapi: put [%03d] id#%d %s len=%u cannot trace\n", - CAPIMSG_CONTROLLER(skb->data), - CAPIMSG_APPID(skb->data), - capi_cmd2str(cmd, subcmd), - CAPIMSG_LEN(skb->data)); + CAPIMSG_CONTROLLER(skb->data), + CAPIMSG_APPID(skb->data), + capi_cmd2str(cmd, subcmd), + CAPIMSG_LEN(skb->data)); } } return ctr->send_message(ctr, skb); @@ -1028,14 +1028,14 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) case AVMB1_ADDCARD: case AVMB1_ADDCARD_WITH_TYPE: if (cmd == AVMB1_ADDCARD) { - if ((retval = copy_from_user(&cdef, data, - sizeof(avmb1_carddef)))) - return -EFAULT; - cdef.cardtype = AVM_CARDTYPE_B1; + if ((retval = copy_from_user(&cdef, data, + sizeof(avmb1_carddef)))) + return -EFAULT; + cdef.cardtype = AVM_CARDTYPE_B1; } else { - if ((retval = copy_from_user(&cdef, data, - sizeof(avmb1_extcarddef)))) - return -EFAULT; + if ((retval = copy_from_user(&cdef, data, + sizeof(avmb1_extcarddef)))) + return -EFAULT; } cparams.port = cdef.port; cparams.irq = cdef.irq; @@ -1043,24 +1043,24 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) mutex_lock(&capi_drivers_lock); - switch (cdef.cardtype) { - case AVM_CARDTYPE_B1: - list_for_each(l, &capi_drivers) { - driver = list_entry(l, struct capi_driver, list); - if (strcmp(driver->name, "b1isa") == 0) - break; - } - break; - case AVM_CARDTYPE_T1: - list_for_each(l, &capi_drivers) { - driver = list_entry(l, struct capi_driver, list); - if (strcmp(driver->name, "t1isa") == 0) - break; - } - break; - default: - driver = NULL; - break; + switch (cdef.cardtype) { + case AVM_CARDTYPE_B1: + list_for_each(l, &capi_drivers) { + driver = list_entry(l, struct capi_driver, list); + if (strcmp(driver->name, "b1isa") == 0) + break; + } + break; + case AVM_CARDTYPE_T1: + list_for_each(l, &capi_drivers) { + driver = list_entry(l, struct capi_driver, list); + if (strcmp(driver->name, "t1isa") == 0) + break; + } + break; + default: + driver = NULL; + break; } if (!driver) { printk(KERN_ERR "kcapi: driver not loaded.\n"); @@ -1136,7 +1136,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) retval = wait_on_ctr_state(ctr, CAPI_CTR_RUNNING); -load_unlock_out: + load_unlock_out: mutex_unlock(&capi_controller_lock); return retval; @@ -1167,7 +1167,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) retval = wait_on_ctr_state(ctr, CAPI_CTR_DETECTED); -reset_unlock_out: + reset_unlock_out: mutex_unlock(&capi_controller_lock); return retval; } @@ -1235,7 +1235,7 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) cparams.membase = cdef.membase; cparams.cardnr = cdef.cardnr; cparams.cardtype = 0; - cdef.driver[sizeof(cdef.driver)-1] = 0; + cdef.driver[sizeof(cdef.driver) - 1] = 0; mutex_lock(&capi_drivers_lock); @@ -1246,7 +1246,7 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) } if (driver == NULL) { printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n", - cdef.driver); + cdef.driver); retval = -ESRCH; } else if (!driver->add_card) { printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver); @@ -1260,7 +1260,7 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) default: printk(KERN_ERR "kcapi: manufacturer command %d unknown.\n", - cmd); + cmd); break; } @@ -1305,7 +1305,7 @@ static int __init kcapi_init(void) static void __exit kcapi_exit(void) { - kcapi_proc_exit(); + kcapi_proc_exit(); unregister_capictr_notifier(&capictr_nb); cdebug_exit(); diff --git a/drivers/isdn/capi/kcapi.h b/drivers/isdn/capi/kcapi.h index f4620b38ec51..6d439f9a76b2 100644 --- a/drivers/isdn/capi/kcapi.h +++ b/drivers/isdn/capi/kcapi.h @@ -1,9 +1,9 @@ /* * Kernel CAPI 2.0 Module - * + * * Copyright 1999 by Carsten Paeth * Copyright 2002 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -16,9 +16,9 @@ #include #ifdef KCAPI_DEBUG -#define DBG(format, arg...) do { \ -printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ -} while (0) +#define DBG(format, arg...) do { \ + printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ + } while (0) #else #define DBG(format, arg...) /* */ #endif @@ -49,4 +49,3 @@ static inline void kcapi_proc_init(void) { }; static inline void kcapi_proc_exit(void) { }; #endif - diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c index 8d51cd1bf674..68db3c5a1063 100644 --- a/drivers/isdn/capi/kcapi_proc.c +++ b/drivers/isdn/capi/kcapi_proc.c @@ -1,9 +1,9 @@ /* * Kernel CAPI 2.0 Module - /proc/capi handling - * + * * Copyright 1999 by Carsten Paeth * Copyright 2002 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -29,7 +29,7 @@ static char *state2str(unsigned short state) // /proc/capi // =========================================================================== -// /proc/capi/controller: +// /proc/capi/controller: // cnr driver cardstate name driverinfo // /proc/capi/contrstats: // cnr nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt @@ -85,7 +85,7 @@ static int contrstats_show(struct seq_file *seq, void *v) return 0; seq_printf(seq, "%d %lu %lu %lu %lu\n", - ctr->cnr, + ctr->cnr, ctr->nrecvctlpkt, ctr->nrecvdatapkt, ctr->nsentctlpkt, @@ -134,9 +134,9 @@ static const struct file_operations proc_contrstats_ops = { .release = seq_release, }; -// /proc/capi/applications: +// /proc/capi/applications: // applid l3cnt dblkcnt dblklen #ncci recvqueuelen -// /proc/capi/applstats: +// /proc/capi/applstats: // applid nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt // --------------------------------------------------------------------------- @@ -297,7 +297,7 @@ static const struct file_operations proc_driver_ops = { // --------------------------------------------------------------------------- -void __init +void __init kcapi_proc_init(void) { proc_mkdir("capi", NULL); diff --git a/drivers/isdn/divert/divert_init.c b/drivers/isdn/divert/divert_init.c index 2f7c9fc2e898..5374c25f036c 100644 --- a/drivers/isdn/divert/divert_init.c +++ b/drivers/isdn/divert/divert_init.c @@ -3,7 +3,7 @@ * Module init for DSS1 diversion services for i4l. * * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -23,13 +23,13 @@ MODULE_LICENSE("GPL"); /* structure containing interface to hl */ /****************************************/ isdn_divert_if divert_if = - { DIVERT_IF_MAGIC, /* magic value */ - DIVERT_CMD_REG, /* register cmd */ - ll_callback, /* callback routine from ll */ - NULL, /* command still not specified */ - NULL, /* drv_to_name */ - NULL, /* name_to_drv */ - }; +{ DIVERT_IF_MAGIC, /* magic value */ + DIVERT_CMD_REG, /* register cmd */ + ll_callback, /* callback routine from ll */ + NULL, /* command still not specified */ + NULL, /* drv_to_name */ + NULL, /* name_to_drv */ +}; /*************************/ /* Module interface code */ @@ -38,17 +38,17 @@ isdn_divert_if divert_if = static int __init divert_init(void) { int i; - if (divert_dev_init()) - { printk(KERN_WARNING "dss1_divert: cannot install device, not loaded\n"); - return(-EIO); - } - if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR) - { divert_dev_deinit(); - printk(KERN_WARNING "dss1_divert: error %d registering module, not loaded\n",i); - return(-EIO); - } - printk(KERN_INFO "dss1_divert module successfully installed\n"); - return(0); + if (divert_dev_init()) + { printk(KERN_WARNING "dss1_divert: cannot install device, not loaded\n"); + return (-EIO); + } + if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR) + { divert_dev_deinit(); + printk(KERN_WARNING "dss1_divert: error %d registering module, not loaded\n", i); + return (-EIO); + } + printk(KERN_INFO "dss1_divert module successfully installed\n"); + return (0); } /**********************/ @@ -56,27 +56,26 @@ static int __init divert_init(void) /**********************/ static void __exit divert_exit(void) { - unsigned long flags; - int i; + unsigned long flags; + int i; - spin_lock_irqsave(&divert_lock, flags); - divert_if.cmd = DIVERT_CMD_REL; /* release */ - if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR) - { printk(KERN_WARNING "dss1_divert: error %d releasing module\n",i); - spin_unlock_irqrestore(&divert_lock, flags); - return; - } - if (divert_dev_deinit()) - { printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n"); - spin_unlock_irqrestore(&divert_lock, flags); - return; - } - spin_unlock_irqrestore(&divert_lock, flags); - deleterule(-1); /* delete all rules and free mem */ - deleteprocs(); - printk(KERN_INFO "dss1_divert module successfully removed \n"); + spin_lock_irqsave(&divert_lock, flags); + divert_if.cmd = DIVERT_CMD_REL; /* release */ + if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR) + { printk(KERN_WARNING "dss1_divert: error %d releasing module\n", i); + spin_unlock_irqrestore(&divert_lock, flags); + return; + } + if (divert_dev_deinit()) + { printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n"); + spin_unlock_irqrestore(&divert_lock, flags); + return; + } + spin_unlock_irqrestore(&divert_lock, flags); + deleterule(-1); /* delete all rules and free mem */ + deleteprocs(); + printk(KERN_INFO "dss1_divert module successfully removed \n"); } module_init(divert_init); module_exit(divert_exit); - diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c index 9021182c4b76..fb4f1bac0133 100644 --- a/drivers/isdn/divert/divert_procfs.c +++ b/drivers/isdn/divert/divert_procfs.c @@ -50,10 +50,10 @@ put_info_buffer(char *cp) if (!*cp) return; if (!(ib = kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC))) - return; /* no memory */ + return; /* no memory */ strcpy(ib->info_start, cp); /* set output string */ ib->next = NULL; - spin_lock_irqsave( &divert_info_lock, flags ); + spin_lock_irqsave(&divert_info_lock, flags); ib->usage_cnt = if_used; if (!divert_info_head) divert_info_head = ib; /* new head */ @@ -71,7 +71,7 @@ put_info_buffer(char *cp) } else break; } /* divert_info_head->next */ - spin_unlock_irqrestore( &divert_info_lock, flags ); + spin_unlock_irqrestore(&divert_info_lock, flags); wake_up_interruptible(&(rd_queue)); } /* put_info_buffer */ @@ -81,7 +81,7 @@ put_info_buffer(char *cp) /* deflection device read routine */ /**********************************/ static ssize_t -isdn_divert_read(struct file *file, char __user *buf, size_t count, loff_t * off) +isdn_divert_read(struct file *file, char __user *buf, size_t count, loff_t *off) { struct divert_info *inf; int len; @@ -109,7 +109,7 @@ isdn_divert_read(struct file *file, char __user *buf, size_t count, loff_t * off /* deflection device write routine */ /**********************************/ static ssize_t -isdn_divert_write(struct file *file, const char __user *buf, size_t count, loff_t * off) +isdn_divert_write(struct file *file, const char __user *buf, size_t count, loff_t *off) { return (-ENODEV); } /* isdn_divert_write */ @@ -119,7 +119,7 @@ isdn_divert_write(struct file *file, const char __user *buf, size_t count, loff_ /* select routines for various kernels */ /***************************************/ static unsigned int -isdn_divert_poll(struct file *file, poll_table * wait) +isdn_divert_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; @@ -139,13 +139,13 @@ isdn_divert_open(struct inode *ino, struct file *filep) { unsigned long flags; - spin_lock_irqsave( &divert_info_lock, flags ); - if_used++; + spin_lock_irqsave(&divert_info_lock, flags); + if_used++; if (divert_info_head) filep->private_data = &(divert_info_tail->next); else filep->private_data = &divert_info_head; - spin_unlock_irqrestore( &divert_info_lock, flags ); + spin_unlock_irqrestore(&divert_info_lock, flags); /* start_divert(); */ return nonseekable_open(ino, filep); } /* isdn_divert_open */ @@ -159,7 +159,7 @@ isdn_divert_close(struct inode *ino, struct file *filep) struct divert_info *inf; unsigned long flags; - spin_lock_irqsave( &divert_info_lock, flags ); + spin_lock_irqsave(&divert_info_lock, flags); if_used--; inf = *((struct divert_info **) filep->private_data); while (inf) { @@ -172,7 +172,7 @@ isdn_divert_close(struct inode *ino, struct file *filep) divert_info_head = divert_info_head->next; kfree(inf); } - spin_unlock_irqrestore( &divert_info_lock, flags ); + spin_unlock_irqrestore(&divert_info_lock, flags); return (0); } /* isdn_divert_close */ @@ -191,75 +191,75 @@ static int isdn_divert_ioctl_unlocked(struct file *file, uint cmd, ulong arg) return -EFAULT; switch (cmd) { - case IIOCGETVER: - dioctl.drv_version = DIVERT_IIOC_VERSION; /* set version */ - break; - - case IIOCGETDRV: - if ((dioctl.getid.drvid = divert_if.name_to_drv(dioctl.getid.drvnam)) < 0) - return (-EINVAL); - break; - - case IIOCGETNAM: - cp = divert_if.drv_to_name(dioctl.getid.drvid); - if (!cp) - return (-EINVAL); - if (!*cp) - return (-EINVAL); - strcpy(dioctl.getid.drvnam, cp); - break; - - case IIOCGETRULE: - if (!(rulep = getruleptr(dioctl.getsetrule.ruleidx))) - return (-EINVAL); - dioctl.getsetrule.rule = *rulep; /* copy data */ - break; - - case IIOCMODRULE: - if (!(rulep = getruleptr(dioctl.getsetrule.ruleidx))) - return (-EINVAL); - spin_lock_irqsave(&divert_lock, flags); - *rulep = dioctl.getsetrule.rule; /* copy data */ - spin_unlock_irqrestore(&divert_lock, flags); - return (0); /* no copy required */ - break; + case IIOCGETVER: + dioctl.drv_version = DIVERT_IIOC_VERSION; /* set version */ + break; - case IIOCINSRULE: - return (insertrule(dioctl.getsetrule.ruleidx, &dioctl.getsetrule.rule)); - break; + case IIOCGETDRV: + if ((dioctl.getid.drvid = divert_if.name_to_drv(dioctl.getid.drvnam)) < 0) + return (-EINVAL); + break; - case IIOCDELRULE: - return (deleterule(dioctl.getsetrule.ruleidx)); - break; + case IIOCGETNAM: + cp = divert_if.drv_to_name(dioctl.getid.drvid); + if (!cp) + return (-EINVAL); + if (!*cp) + return (-EINVAL); + strcpy(dioctl.getid.drvnam, cp); + break; - case IIOCDODFACT: - return (deflect_extern_action(dioctl.fwd_ctrl.subcmd, - dioctl.fwd_ctrl.callid, - dioctl.fwd_ctrl.to_nr)); - - case IIOCDOCFACT: - case IIOCDOCFDIS: - case IIOCDOCFINT: - if (!divert_if.drv_to_name(dioctl.cf_ctrl.drvid)) - return (-EINVAL); /* invalid driver */ - if (strnlen(dioctl.cf_ctrl.msn, sizeof(dioctl.cf_ctrl.msn)) == - sizeof(dioctl.cf_ctrl.msn)) - return -EINVAL; - if (strnlen(dioctl.cf_ctrl.fwd_nr, sizeof(dioctl.cf_ctrl.fwd_nr)) == - sizeof(dioctl.cf_ctrl.fwd_nr)) - return -EINVAL; - if ((i = cf_command(dioctl.cf_ctrl.drvid, - (cmd == IIOCDOCFACT) ? 1 : (cmd == IIOCDOCFDIS) ? 0 : 2, - dioctl.cf_ctrl.cfproc, - dioctl.cf_ctrl.msn, - dioctl.cf_ctrl.service, - dioctl.cf_ctrl.fwd_nr, - &dioctl.cf_ctrl.procid))) - return (i); - break; + case IIOCGETRULE: + if (!(rulep = getruleptr(dioctl.getsetrule.ruleidx))) + return (-EINVAL); + dioctl.getsetrule.rule = *rulep; /* copy data */ + break; - default: + case IIOCMODRULE: + if (!(rulep = getruleptr(dioctl.getsetrule.ruleidx))) return (-EINVAL); + spin_lock_irqsave(&divert_lock, flags); + *rulep = dioctl.getsetrule.rule; /* copy data */ + spin_unlock_irqrestore(&divert_lock, flags); + return (0); /* no copy required */ + break; + + case IIOCINSRULE: + return (insertrule(dioctl.getsetrule.ruleidx, &dioctl.getsetrule.rule)); + break; + + case IIOCDELRULE: + return (deleterule(dioctl.getsetrule.ruleidx)); + break; + + case IIOCDODFACT: + return (deflect_extern_action(dioctl.fwd_ctrl.subcmd, + dioctl.fwd_ctrl.callid, + dioctl.fwd_ctrl.to_nr)); + + case IIOCDOCFACT: + case IIOCDOCFDIS: + case IIOCDOCFINT: + if (!divert_if.drv_to_name(dioctl.cf_ctrl.drvid)) + return (-EINVAL); /* invalid driver */ + if (strnlen(dioctl.cf_ctrl.msn, sizeof(dioctl.cf_ctrl.msn)) == + sizeof(dioctl.cf_ctrl.msn)) + return -EINVAL; + if (strnlen(dioctl.cf_ctrl.fwd_nr, sizeof(dioctl.cf_ctrl.fwd_nr)) == + sizeof(dioctl.cf_ctrl.fwd_nr)) + return -EINVAL; + if ((i = cf_command(dioctl.cf_ctrl.drvid, + (cmd == IIOCDOCFACT) ? 1 : (cmd == IIOCDOCFDIS) ? 0 : 2, + dioctl.cf_ctrl.cfproc, + dioctl.cf_ctrl.msn, + dioctl.cf_ctrl.service, + dioctl.cf_ctrl.fwd_nr, + &dioctl.cf_ctrl.procid))) + return (i); + break; + + default: + return (-EINVAL); } /* switch cmd */ return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0; } /* isdn_divert_ioctl */ @@ -284,7 +284,7 @@ static const struct file_operations isdn_fops = .poll = isdn_divert_poll, .unlocked_ioctl = isdn_divert_ioctl, .open = isdn_divert_open, - .release = isdn_divert_close, + .release = isdn_divert_close, }; /****************************/ diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c index 48e6d220f62c..e61e55f1f193 100644 --- a/drivers/isdn/divert/isdn_divert.c +++ b/drivers/isdn/divert/isdn_divert.c @@ -3,7 +3,7 @@ * DSS1 main diversion supplementary handling for i4l. * * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -20,24 +20,24 @@ /* structure keeping calling info */ /**********************************/ struct call_struc - { isdn_ctrl ics; /* delivered setup + driver parameters */ - ulong divert_id; /* Id delivered to user */ - unsigned char akt_state; /* actual state */ - char deflect_dest[35]; /* deflection destination */ - struct timer_list timer; /* timer control structure */ - char info[90]; /* device info output */ - struct call_struc *next; /* pointer to next entry */ - struct call_struc *prev; - }; +{ isdn_ctrl ics; /* delivered setup + driver parameters */ + ulong divert_id; /* Id delivered to user */ + unsigned char akt_state; /* actual state */ + char deflect_dest[35]; /* deflection destination */ + struct timer_list timer; /* timer control structure */ + char info[90]; /* device info output */ + struct call_struc *next; /* pointer to next entry */ + struct call_struc *prev; +}; /********************************************/ /* structure keeping deflection table entry */ /********************************************/ struct deflect_struc - { struct deflect_struc *next,*prev; - divert_rule rule; /* used rule */ - }; +{ struct deflect_struc *next, *prev; + divert_rule rule; /* used rule */ +}; /*****************************************/ @@ -45,10 +45,10 @@ struct deflect_struc /*****************************************/ /* diversion/deflection processes */ static struct call_struc *divert_head = NULL; /* head of remembered entrys */ -static ulong next_id = 1; /* next info id */ +static ulong next_id = 1; /* next info id */ static struct deflect_struc *table_head = NULL; -static struct deflect_struc *table_tail = NULL; -static unsigned char extern_wait_max = 4; /* maximum wait in s for external process */ +static struct deflect_struc *table_tail = NULL; +static unsigned char extern_wait_max = 4; /* maximum wait in s for external process */ DEFINE_SPINLOCK(divert_lock); @@ -57,50 +57,50 @@ DEFINE_SPINLOCK(divert_lock); /***************************/ static void deflect_timer_expire(ulong arg) { - unsigned long flags; - struct call_struc *cs = (struct call_struc *) arg; - - spin_lock_irqsave(&divert_lock, flags); - del_timer(&cs->timer); /* delete active timer */ - spin_unlock_irqrestore(&divert_lock, flags); - - switch(cs->akt_state) - { case DEFLECT_PROCEED: - cs->ics.command = ISDN_CMD_HANGUP; /* cancel action */ - divert_if.ll_cmd(&cs->ics); - spin_lock_irqsave(&divert_lock, flags); - cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ - cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); - add_timer(&cs->timer); - spin_unlock_irqrestore(&divert_lock, flags); - break; - - case DEFLECT_ALERT: - cs->ics.command = ISDN_CMD_REDIR; /* protocol */ - strlcpy(cs->ics.parm.setup.phone, cs->deflect_dest, sizeof(cs->ics.parm.setup.phone)); - strcpy(cs->ics.parm.setup.eazmsn,"Testtext delayed"); - divert_if.ll_cmd(&cs->ics); - spin_lock_irqsave(&divert_lock, flags); - cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ - cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); - add_timer(&cs->timer); - spin_unlock_irqrestore(&divert_lock, flags); - break; - - case DEFLECT_AUTODEL: - default: - spin_lock_irqsave(&divert_lock, flags); - if (cs->prev) - cs->prev->next = cs->next; /* forward link */ - else - divert_head = cs->next; - if (cs->next) - cs->next->prev = cs->prev; /* back link */ - spin_unlock_irqrestore(&divert_lock, flags); - kfree(cs); - return; - - } /* switch */ + unsigned long flags; + struct call_struc *cs = (struct call_struc *) arg; + + spin_lock_irqsave(&divert_lock, flags); + del_timer(&cs->timer); /* delete active timer */ + spin_unlock_irqrestore(&divert_lock, flags); + + switch (cs->akt_state) + { case DEFLECT_PROCEED: + cs->ics.command = ISDN_CMD_HANGUP; /* cancel action */ + divert_if.ll_cmd(&cs->ics); + spin_lock_irqsave(&divert_lock, flags); + cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ + cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); + add_timer(&cs->timer); + spin_unlock_irqrestore(&divert_lock, flags); + break; + + case DEFLECT_ALERT: + cs->ics.command = ISDN_CMD_REDIR; /* protocol */ + strlcpy(cs->ics.parm.setup.phone, cs->deflect_dest, sizeof(cs->ics.parm.setup.phone)); + strcpy(cs->ics.parm.setup.eazmsn, "Testtext delayed"); + divert_if.ll_cmd(&cs->ics); + spin_lock_irqsave(&divert_lock, flags); + cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ + cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); + add_timer(&cs->timer); + spin_unlock_irqrestore(&divert_lock, flags); + break; + + case DEFLECT_AUTODEL: + default: + spin_lock_irqsave(&divert_lock, flags); + if (cs->prev) + cs->prev->next = cs->next; /* forward link */ + else + divert_head = cs->next; + if (cs->next) + cs->next->prev = cs->prev; /* back link */ + spin_unlock_irqrestore(&divert_lock, flags); + kfree(cs); + return; + + } /* switch */ } /* deflect_timer_func */ @@ -108,94 +108,94 @@ static void deflect_timer_expire(ulong arg) /* handle call forwarding de/activations */ /* 0 = deact, 1 = act, 2 = interrogate */ /*****************************************/ -int cf_command(int drvid, int mode, - u_char proc, char *msn, - u_char service, char *fwd_nr, ulong *procid) +int cf_command(int drvid, int mode, + u_char proc, char *msn, + u_char service, char *fwd_nr, ulong *procid) { unsigned long flags; - int retval,msnlen; - int fwd_len; - char *p,*ielenp,tmp[60]; - struct call_struc *cs; - - if (strchr(msn,'.')) return(-EINVAL); /* subaddress not allowed in msn */ - if ((proc & 0x7F) > 2) return(-EINVAL); - proc &= 3; - p = tmp; - *p++ = 0x30; /* enumeration */ - ielenp = p++; /* remember total length position */ - *p++ = 0xa; /* proc tag */ - *p++ = 1; /* length */ - *p++ = proc & 0x7F; /* procedure to de/activate/interrogate */ - *p++ = 0xa; /* service tag */ - *p++ = 1; /* length */ - *p++ = service; /* service to handle */ - - if (mode == 1) - { if (!*fwd_nr) return(-EINVAL); /* destination missing */ - if (strchr(fwd_nr,'.')) return(-EINVAL); /* subaddress not allowed */ - fwd_len = strlen(fwd_nr); - *p++ = 0x30; /* number enumeration */ - *p++ = fwd_len + 2; /* complete forward to len */ - *p++ = 0x80; /* fwd to nr */ - *p++ = fwd_len; /* length of number */ - strcpy(p,fwd_nr); /* copy number */ - p += fwd_len; /* pointer beyond fwd */ - } /* activate */ - - msnlen = strlen(msn); - *p++ = 0x80; /* msn number */ - if (msnlen > 1) - { *p++ = msnlen; /* length */ - strcpy(p,msn); - p += msnlen; - } - else *p++ = 0; - - *ielenp = p - ielenp - 1; /* set total IE length */ - - /* allocate mem for information struct */ - if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) - return(-ENOMEM); /* no memory */ - init_timer(&cs->timer); - cs->info[0] = '\0'; - cs->timer.function = deflect_timer_expire; - cs->timer.data = (ulong) cs; /* pointer to own structure */ - cs->ics.driver = drvid; - cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */ - cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */ - cs->ics.parm.dss1_io.proc = (mode == 1) ? 7: (mode == 2) ? 11:8; /* operation */ - cs->ics.parm.dss1_io.timeout = 4000; /* from ETS 300 207-1 */ - cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */ - cs->ics.parm.dss1_io.data = tmp; /* start of buffer */ - - spin_lock_irqsave(&divert_lock, flags); - cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */ - spin_unlock_irqrestore(&divert_lock, flags); - *procid = cs->ics.parm.dss1_io.ll_id; - - sprintf(cs->info,"%d 0x%lx %s%s 0 %s %02x %d%s%s\n", - (!mode ) ? DIVERT_DEACTIVATE : (mode == 1) ? DIVERT_ACTIVATE : DIVERT_REPORT, - cs->ics.parm.dss1_io.ll_id, - (mode != 2) ? "" : "0 ", - divert_if.drv_to_name(cs->ics.driver), - msn, - service & 0xFF, - proc, - (mode != 1) ? "" : " 0 ", - (mode != 1) ? "" : fwd_nr); - - retval = divert_if.ll_cmd(&cs->ics); /* execute command */ - - if (!retval) - { cs->prev = NULL; - spin_lock_irqsave(&divert_lock, flags); - cs->next = divert_head; - divert_head = cs; - spin_unlock_irqrestore(&divert_lock, flags); - } - else - kfree(cs); - return(retval); + int retval, msnlen; + int fwd_len; + char *p, *ielenp, tmp[60]; + struct call_struc *cs; + + if (strchr(msn, '.')) return (-EINVAL); /* subaddress not allowed in msn */ + if ((proc & 0x7F) > 2) return (-EINVAL); + proc &= 3; + p = tmp; + *p++ = 0x30; /* enumeration */ + ielenp = p++; /* remember total length position */ + *p++ = 0xa; /* proc tag */ + *p++ = 1; /* length */ + *p++ = proc & 0x7F; /* procedure to de/activate/interrogate */ + *p++ = 0xa; /* service tag */ + *p++ = 1; /* length */ + *p++ = service; /* service to handle */ + + if (mode == 1) + { if (!*fwd_nr) return (-EINVAL); /* destination missing */ + if (strchr(fwd_nr, '.')) return (-EINVAL); /* subaddress not allowed */ + fwd_len = strlen(fwd_nr); + *p++ = 0x30; /* number enumeration */ + *p++ = fwd_len + 2; /* complete forward to len */ + *p++ = 0x80; /* fwd to nr */ + *p++ = fwd_len; /* length of number */ + strcpy(p, fwd_nr); /* copy number */ + p += fwd_len; /* pointer beyond fwd */ + } /* activate */ + + msnlen = strlen(msn); + *p++ = 0x80; /* msn number */ + if (msnlen > 1) + { *p++ = msnlen; /* length */ + strcpy(p, msn); + p += msnlen; + } + else *p++ = 0; + + *ielenp = p - ielenp - 1; /* set total IE length */ + + /* allocate mem for information struct */ + if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) + return (-ENOMEM); /* no memory */ + init_timer(&cs->timer); + cs->info[0] = '\0'; + cs->timer.function = deflect_timer_expire; + cs->timer.data = (ulong) cs; /* pointer to own structure */ + cs->ics.driver = drvid; + cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */ + cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */ + cs->ics.parm.dss1_io.proc = (mode == 1) ? 7 : (mode == 2) ? 11 : 8; /* operation */ + cs->ics.parm.dss1_io.timeout = 4000; /* from ETS 300 207-1 */ + cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */ + cs->ics.parm.dss1_io.data = tmp; /* start of buffer */ + + spin_lock_irqsave(&divert_lock, flags); + cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */ + spin_unlock_irqrestore(&divert_lock, flags); + *procid = cs->ics.parm.dss1_io.ll_id; + + sprintf(cs->info, "%d 0x%lx %s%s 0 %s %02x %d%s%s\n", + (!mode) ? DIVERT_DEACTIVATE : (mode == 1) ? DIVERT_ACTIVATE : DIVERT_REPORT, + cs->ics.parm.dss1_io.ll_id, + (mode != 2) ? "" : "0 ", + divert_if.drv_to_name(cs->ics.driver), + msn, + service & 0xFF, + proc, + (mode != 1) ? "" : " 0 ", + (mode != 1) ? "" : fwd_nr); + + retval = divert_if.ll_cmd(&cs->ics); /* execute command */ + + if (!retval) + { cs->prev = NULL; + spin_lock_irqsave(&divert_lock, flags); + cs->next = divert_head; + divert_head = cs; + spin_unlock_irqrestore(&divert_lock, flags); + } + else + kfree(cs); + return (retval); } /* cf_command */ @@ -204,165 +204,165 @@ int cf_command(int drvid, int mode, /****************************************/ int deflect_extern_action(u_char cmd, ulong callid, char *to_nr) { struct call_struc *cs; - isdn_ctrl ic; - unsigned long flags; - int i; - - if ((cmd & 0x7F) > 2) return(-EINVAL); /* invalid command */ - cs = divert_head; /* start of parameter list */ - while (cs) - { if (cs->divert_id == callid) break; /* found */ - cs = cs->next; - } /* search entry */ - if (!cs) return(-EINVAL); /* invalid callid */ - - ic.driver = cs->ics.driver; - ic.arg = cs->ics.arg; - i = -EINVAL; - if (cs->akt_state == DEFLECT_AUTODEL) return(i); /* no valid call */ - switch (cmd & 0x7F) - { case 0: /* hangup */ - del_timer(&cs->timer); - ic.command = ISDN_CMD_HANGUP; - i = divert_if.ll_cmd(&ic); - spin_lock_irqsave(&divert_lock, flags); - cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ - cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); - add_timer(&cs->timer); - spin_unlock_irqrestore(&divert_lock, flags); - break; - - case 1: /* alert */ - if (cs->akt_state == DEFLECT_ALERT) return(0); - cmd &= 0x7F; /* never wait */ - del_timer(&cs->timer); - ic.command = ISDN_CMD_ALERT; - if ((i = divert_if.ll_cmd(&ic))) - { - spin_lock_irqsave(&divert_lock, flags); - cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ - cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); - add_timer(&cs->timer); - spin_unlock_irqrestore(&divert_lock, flags); - } - else - cs->akt_state = DEFLECT_ALERT; - break; - - case 2: /* redir */ - del_timer(&cs->timer); - strlcpy(cs->ics.parm.setup.phone, to_nr, sizeof(cs->ics.parm.setup.phone)); - strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual"); - ic.command = ISDN_CMD_REDIR; - if ((i = divert_if.ll_cmd(&ic))) - { - spin_lock_irqsave(&divert_lock, flags); - cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ - cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); - add_timer(&cs->timer); - spin_unlock_irqrestore(&divert_lock, flags); - } - else - cs->akt_state = DEFLECT_ALERT; - break; - - } /* switch */ - return(i); + isdn_ctrl ic; + unsigned long flags; + int i; + + if ((cmd & 0x7F) > 2) return (-EINVAL); /* invalid command */ + cs = divert_head; /* start of parameter list */ + while (cs) + { if (cs->divert_id == callid) break; /* found */ + cs = cs->next; + } /* search entry */ + if (!cs) return (-EINVAL); /* invalid callid */ + + ic.driver = cs->ics.driver; + ic.arg = cs->ics.arg; + i = -EINVAL; + if (cs->akt_state == DEFLECT_AUTODEL) return (i); /* no valid call */ + switch (cmd & 0x7F) + { case 0: /* hangup */ + del_timer(&cs->timer); + ic.command = ISDN_CMD_HANGUP; + i = divert_if.ll_cmd(&ic); + spin_lock_irqsave(&divert_lock, flags); + cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ + cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); + add_timer(&cs->timer); + spin_unlock_irqrestore(&divert_lock, flags); + break; + + case 1: /* alert */ + if (cs->akt_state == DEFLECT_ALERT) return (0); + cmd &= 0x7F; /* never wait */ + del_timer(&cs->timer); + ic.command = ISDN_CMD_ALERT; + if ((i = divert_if.ll_cmd(&ic))) + { + spin_lock_irqsave(&divert_lock, flags); + cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ + cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); + add_timer(&cs->timer); + spin_unlock_irqrestore(&divert_lock, flags); + } + else + cs->akt_state = DEFLECT_ALERT; + break; + + case 2: /* redir */ + del_timer(&cs->timer); + strlcpy(cs->ics.parm.setup.phone, to_nr, sizeof(cs->ics.parm.setup.phone)); + strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual"); + ic.command = ISDN_CMD_REDIR; + if ((i = divert_if.ll_cmd(&ic))) + { + spin_lock_irqsave(&divert_lock, flags); + cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ + cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); + add_timer(&cs->timer); + spin_unlock_irqrestore(&divert_lock, flags); + } + else + cs->akt_state = DEFLECT_ALERT; + break; + + } /* switch */ + return (i); } /* deflect_extern_action */ /********************************/ /* insert a new rule before idx */ /********************************/ int insertrule(int idx, divert_rule *newrule) -{ struct deflect_struc *ds,*ds1=NULL; - unsigned long flags; - - if (!(ds = kmalloc(sizeof(struct deflect_struc), - GFP_KERNEL))) - return(-ENOMEM); /* no memory */ - - ds->rule = *newrule; /* set rule */ - - spin_lock_irqsave(&divert_lock, flags); - - if (idx >= 0) - { ds1 = table_head; - while ((ds1) && (idx > 0)) - { idx--; - ds1 = ds1->next; - } - if (!ds1) idx = -1; - } - - if (idx < 0) - { ds->prev = table_tail; /* previous entry */ - ds->next = NULL; /* end of chain */ - if (ds->prev) - ds->prev->next = ds; /* last forward */ - else - table_head = ds; /* is first entry */ - table_tail = ds; /* end of queue */ - } - else - { ds->next = ds1; /* next entry */ - ds->prev = ds1->prev; /* prev entry */ - ds1->prev = ds; /* backward chain old element */ - if (!ds->prev) - table_head = ds; /* first element */ - } - - spin_unlock_irqrestore(&divert_lock, flags); - return(0); +{ struct deflect_struc *ds, *ds1 = NULL; + unsigned long flags; + + if (!(ds = kmalloc(sizeof(struct deflect_struc), + GFP_KERNEL))) + return (-ENOMEM); /* no memory */ + + ds->rule = *newrule; /* set rule */ + + spin_lock_irqsave(&divert_lock, flags); + + if (idx >= 0) + { ds1 = table_head; + while ((ds1) && (idx > 0)) + { idx--; + ds1 = ds1->next; + } + if (!ds1) idx = -1; + } + + if (idx < 0) + { ds->prev = table_tail; /* previous entry */ + ds->next = NULL; /* end of chain */ + if (ds->prev) + ds->prev->next = ds; /* last forward */ + else + table_head = ds; /* is first entry */ + table_tail = ds; /* end of queue */ + } + else + { ds->next = ds1; /* next entry */ + ds->prev = ds1->prev; /* prev entry */ + ds1->prev = ds; /* backward chain old element */ + if (!ds->prev) + table_head = ds; /* first element */ + } + + spin_unlock_irqrestore(&divert_lock, flags); + return (0); } /* insertrule */ /***********************************/ /* delete the rule at position idx */ /***********************************/ int deleterule(int idx) -{ struct deflect_struc *ds,*ds1; - unsigned long flags; - - if (idx < 0) - { spin_lock_irqsave(&divert_lock, flags); - ds = table_head; - table_head = NULL; - table_tail = NULL; - spin_unlock_irqrestore(&divert_lock, flags); - while (ds) - { ds1 = ds; - ds = ds->next; - kfree(ds1); - } - return(0); - } - - spin_lock_irqsave(&divert_lock, flags); - ds = table_head; - - while ((ds) && (idx > 0)) - { idx--; - ds = ds->next; - } - - if (!ds) - { - spin_unlock_irqrestore(&divert_lock, flags); - return(-EINVAL); - } - - if (ds->next) - ds->next->prev = ds->prev; /* backward chain */ - else - table_tail = ds->prev; /* end of chain */ - - if (ds->prev) - ds->prev->next = ds->next; /* forward chain */ - else - table_head = ds->next; /* start of chain */ - - spin_unlock_irqrestore(&divert_lock, flags); - kfree(ds); - return(0); +{ struct deflect_struc *ds, *ds1; + unsigned long flags; + + if (idx < 0) + { spin_lock_irqsave(&divert_lock, flags); + ds = table_head; + table_head = NULL; + table_tail = NULL; + spin_unlock_irqrestore(&divert_lock, flags); + while (ds) + { ds1 = ds; + ds = ds->next; + kfree(ds1); + } + return (0); + } + + spin_lock_irqsave(&divert_lock, flags); + ds = table_head; + + while ((ds) && (idx > 0)) + { idx--; + ds = ds->next; + } + + if (!ds) + { + spin_unlock_irqrestore(&divert_lock, flags); + return (-EINVAL); + } + + if (ds->next) + ds->next->prev = ds->prev; /* backward chain */ + else + table_tail = ds->prev; /* end of chain */ + + if (ds->prev) + ds->prev->next = ds->next; /* forward chain */ + else + table_head = ds->next; /* start of chain */ + + spin_unlock_irqrestore(&divert_lock, flags); + kfree(ds); + return (0); } /* deleterule */ /*******************************************/ @@ -370,16 +370,16 @@ int deleterule(int idx) /*******************************************/ divert_rule *getruleptr(int idx) { struct deflect_struc *ds = table_head; - - if (idx < 0) return(NULL); - while ((ds) && (idx >= 0)) - { if (!(idx--)) - { return(&ds->rule); - break; - } - ds = ds->next; - } - return(NULL); + + if (idx < 0) return (NULL); + while ((ds) && (idx >= 0)) + { if (!(idx--)) + { return (&ds->rule); + break; + } + ds = ds->next; + } + return (NULL); } /* getruleptr */ /*************************************************/ @@ -387,168 +387,168 @@ divert_rule *getruleptr(int idx) /*************************************************/ static int isdn_divert_icall(isdn_ctrl *ic) { int retval = 0; - unsigned long flags; - struct call_struc *cs = NULL; - struct deflect_struc *dv; - char *p,*p1; - u_char accept; - - /* first check the internal deflection table */ - for (dv = table_head; dv ; dv = dv->next ) - { /* scan table */ - if (((dv->rule.callopt == 1) && (ic->command == ISDN_STAT_ICALLW)) || - ((dv->rule.callopt == 2) && (ic->command == ISDN_STAT_ICALL))) - continue; /* call option check */ - if (!(dv->rule.drvid & (1L << ic->driver))) - continue; /* driver not matching */ - if ((dv->rule.si1) && (dv->rule.si1 != ic->parm.setup.si1)) - continue; /* si1 not matching */ - if ((dv->rule.si2) && (dv->rule.si2 != ic->parm.setup.si2)) - continue; /* si2 not matching */ - - p = dv->rule.my_msn; - p1 = ic->parm.setup.eazmsn; - accept = 0; - while (*p) - { /* complete compare */ - if (*p == '-') - { accept = 1; /* call accepted */ - break; - } - if (*p++ != *p1++) - break; /* not accepted */ - if ((!*p) && (!*p1)) - accept = 1; - } /* complete compare */ - if (!accept) continue; /* not accepted */ - - if ((strcmp(dv->rule.caller,"0")) || (ic->parm.setup.phone[0])) - { p = dv->rule.caller; - p1 = ic->parm.setup.phone; - accept = 0; - while (*p) - { /* complete compare */ - if (*p == '-') - { accept = 1; /* call accepted */ - break; - } - if (*p++ != *p1++) - break; /* not accepted */ - if ((!*p) && (!*p1)) - accept = 1; - } /* complete compare */ - if (!accept) continue; /* not accepted */ - } - - switch (dv->rule.action) - { case DEFLECT_IGNORE: - return(0); - break; - - case DEFLECT_ALERT: - case DEFLECT_PROCEED: - case DEFLECT_REPORT: - case DEFLECT_REJECT: - if (dv->rule.action == DEFLECT_PROCEED) - if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) - return(0); /* no external deflection needed */ - if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) - return(0); /* no memory */ - init_timer(&cs->timer); - cs->info[0] = '\0'; - cs->timer.function = deflect_timer_expire; - cs->timer.data = (ulong) cs; /* pointer to own structure */ - - cs->ics = *ic; /* copy incoming data */ - if (!cs->ics.parm.setup.phone[0]) strcpy(cs->ics.parm.setup.phone,"0"); - if (!cs->ics.parm.setup.eazmsn[0]) strcpy(cs->ics.parm.setup.eazmsn,"0"); - cs->ics.parm.setup.screen = dv->rule.screen; - if (dv->rule.waittime) - cs->timer.expires = jiffies + (HZ * dv->rule.waittime); - else - if (dv->rule.action == DEFLECT_PROCEED) - cs->timer.expires = jiffies + (HZ * extern_wait_max); - else - cs->timer.expires = 0; - cs->akt_state = dv->rule.action; - spin_lock_irqsave(&divert_lock, flags); - cs->divert_id = next_id++; /* new sequence number */ - spin_unlock_irqrestore(&divert_lock, flags); - cs->prev = NULL; - if (cs->akt_state == DEFLECT_ALERT) - { strcpy(cs->deflect_dest,dv->rule.to_nr); - if (!cs->timer.expires) - { strcpy(ic->parm.setup.eazmsn,"Testtext direct"); - ic->parm.setup.screen = dv->rule.screen; - strlcpy(ic->parm.setup.phone, dv->rule.to_nr, sizeof(ic->parm.setup.phone)); - cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ - cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); - retval = 5; - } - else - retval = 1; /* alerting */ - } - else - { cs->deflect_dest[0] = '\0'; - retval = 4; /* only proceed */ - } - sprintf(cs->info,"%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n", - cs->akt_state, - cs->divert_id, - divert_if.drv_to_name(cs->ics.driver), - (ic->command == ISDN_STAT_ICALLW) ? "1":"0", - cs->ics.parm.setup.phone, - cs->ics.parm.setup.eazmsn, - cs->ics.parm.setup.si1, - cs->ics.parm.setup.si2, - cs->ics.parm.setup.screen, - dv->rule.waittime, - cs->deflect_dest); - if ((dv->rule.action == DEFLECT_REPORT) || - (dv->rule.action == DEFLECT_REJECT)) - { put_info_buffer(cs->info); - kfree(cs); /* remove */ - return((dv->rule.action == DEFLECT_REPORT) ? 0:2); /* nothing to do */ - } - break; - - default: - return(0); /* ignore call */ - break; - } /* switch action */ - break; - } /* scan_table */ - - if (cs) - { cs->prev = NULL; - spin_lock_irqsave(&divert_lock, flags); - cs->next = divert_head; - divert_head = cs; - if (cs->timer.expires) add_timer(&cs->timer); - spin_unlock_irqrestore(&divert_lock, flags); - - put_info_buffer(cs->info); - return(retval); - } - else - return(0); + unsigned long flags; + struct call_struc *cs = NULL; + struct deflect_struc *dv; + char *p, *p1; + u_char accept; + + /* first check the internal deflection table */ + for (dv = table_head; dv; dv = dv->next) + { /* scan table */ + if (((dv->rule.callopt == 1) && (ic->command == ISDN_STAT_ICALLW)) || + ((dv->rule.callopt == 2) && (ic->command == ISDN_STAT_ICALL))) + continue; /* call option check */ + if (!(dv->rule.drvid & (1L << ic->driver))) + continue; /* driver not matching */ + if ((dv->rule.si1) && (dv->rule.si1 != ic->parm.setup.si1)) + continue; /* si1 not matching */ + if ((dv->rule.si2) && (dv->rule.si2 != ic->parm.setup.si2)) + continue; /* si2 not matching */ + + p = dv->rule.my_msn; + p1 = ic->parm.setup.eazmsn; + accept = 0; + while (*p) + { /* complete compare */ + if (*p == '-') + { accept = 1; /* call accepted */ + break; + } + if (*p++ != *p1++) + break; /* not accepted */ + if ((!*p) && (!*p1)) + accept = 1; + } /* complete compare */ + if (!accept) continue; /* not accepted */ + + if ((strcmp(dv->rule.caller, "0")) || (ic->parm.setup.phone[0])) + { p = dv->rule.caller; + p1 = ic->parm.setup.phone; + accept = 0; + while (*p) + { /* complete compare */ + if (*p == '-') + { accept = 1; /* call accepted */ + break; + } + if (*p++ != *p1++) + break; /* not accepted */ + if ((!*p) && (!*p1)) + accept = 1; + } /* complete compare */ + if (!accept) continue; /* not accepted */ + } + + switch (dv->rule.action) + { case DEFLECT_IGNORE: + return (0); + break; + + case DEFLECT_ALERT: + case DEFLECT_PROCEED: + case DEFLECT_REPORT: + case DEFLECT_REJECT: + if (dv->rule.action == DEFLECT_PROCEED) + if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) + return (0); /* no external deflection needed */ + if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) + return (0); /* no memory */ + init_timer(&cs->timer); + cs->info[0] = '\0'; + cs->timer.function = deflect_timer_expire; + cs->timer.data = (ulong) cs; /* pointer to own structure */ + + cs->ics = *ic; /* copy incoming data */ + if (!cs->ics.parm.setup.phone[0]) strcpy(cs->ics.parm.setup.phone, "0"); + if (!cs->ics.parm.setup.eazmsn[0]) strcpy(cs->ics.parm.setup.eazmsn, "0"); + cs->ics.parm.setup.screen = dv->rule.screen; + if (dv->rule.waittime) + cs->timer.expires = jiffies + (HZ * dv->rule.waittime); + else + if (dv->rule.action == DEFLECT_PROCEED) + cs->timer.expires = jiffies + (HZ * extern_wait_max); + else + cs->timer.expires = 0; + cs->akt_state = dv->rule.action; + spin_lock_irqsave(&divert_lock, flags); + cs->divert_id = next_id++; /* new sequence number */ + spin_unlock_irqrestore(&divert_lock, flags); + cs->prev = NULL; + if (cs->akt_state == DEFLECT_ALERT) + { strcpy(cs->deflect_dest, dv->rule.to_nr); + if (!cs->timer.expires) + { strcpy(ic->parm.setup.eazmsn, "Testtext direct"); + ic->parm.setup.screen = dv->rule.screen; + strlcpy(ic->parm.setup.phone, dv->rule.to_nr, sizeof(ic->parm.setup.phone)); + cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ + cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); + retval = 5; + } + else + retval = 1; /* alerting */ + } + else + { cs->deflect_dest[0] = '\0'; + retval = 4; /* only proceed */ + } + sprintf(cs->info, "%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n", + cs->akt_state, + cs->divert_id, + divert_if.drv_to_name(cs->ics.driver), + (ic->command == ISDN_STAT_ICALLW) ? "1" : "0", + cs->ics.parm.setup.phone, + cs->ics.parm.setup.eazmsn, + cs->ics.parm.setup.si1, + cs->ics.parm.setup.si2, + cs->ics.parm.setup.screen, + dv->rule.waittime, + cs->deflect_dest); + if ((dv->rule.action == DEFLECT_REPORT) || + (dv->rule.action == DEFLECT_REJECT)) + { put_info_buffer(cs->info); + kfree(cs); /* remove */ + return ((dv->rule.action == DEFLECT_REPORT) ? 0 : 2); /* nothing to do */ + } + break; + + default: + return (0); /* ignore call */ + break; + } /* switch action */ + break; + } /* scan_table */ + + if (cs) + { cs->prev = NULL; + spin_lock_irqsave(&divert_lock, flags); + cs->next = divert_head; + divert_head = cs; + if (cs->timer.expires) add_timer(&cs->timer); + spin_unlock_irqrestore(&divert_lock, flags); + + put_info_buffer(cs->info); + return (retval); + } + else + return (0); } /* isdn_divert_icall */ void deleteprocs(void) -{ struct call_struc *cs, *cs1; - unsigned long flags; - - spin_lock_irqsave(&divert_lock, flags); - cs = divert_head; - divert_head = NULL; - while (cs) - { del_timer(&cs->timer); - cs1 = cs; - cs = cs->next; - kfree(cs1); - } - spin_unlock_irqrestore(&divert_lock, flags); +{ struct call_struc *cs, *cs1; + unsigned long flags; + + spin_lock_irqsave(&divert_lock, flags); + cs = divert_head; + divert_head = NULL; + while (cs) + { del_timer(&cs->timer); + cs1 = cs; + cs = cs->next; + kfree(cs1); + } + spin_unlock_irqrestore(&divert_lock, flags); } /* deleteprocs */ /****************************************************/ @@ -556,42 +556,42 @@ void deleteprocs(void) /****************************************************/ static int put_address(char *st, u_char *p, int len) { u_char retval = 0; - u_char adr_typ = 0; /* network standard */ - - if (len < 2) return(retval); - if (*p == 0xA1) - { retval = *(++p) + 2; /* total length */ - if (retval > len) return(0); /* too short */ - len = retval - 2; /* remaining length */ - if (len < 3) return(0); - if ((*(++p) != 0x0A) || (*(++p) != 1)) return(0); - adr_typ = *(++p); - len -= 3; - p++; - if (len < 2) return(0); - if (*p++ != 0x12) return(0); - if (*p > len) return(0); /* check number length */ - len = *p++; - } - else - if (*p == 0x80) - { retval = *(++p) + 2; /* total length */ - if (retval > len) return(0); - len = retval - 2; - p++; - } - else - return(0); /* invalid address information */ - - sprintf(st,"%d ",adr_typ); - st += strlen(st); - if (!len) - *st++ = '-'; - else - while (len--) - *st++ = *p++; - *st = '\0'; - return(retval); + u_char adr_typ = 0; /* network standard */ + + if (len < 2) return (retval); + if (*p == 0xA1) + { retval = *(++p) + 2; /* total length */ + if (retval > len) return (0); /* too short */ + len = retval - 2; /* remaining length */ + if (len < 3) return (0); + if ((*(++p) != 0x0A) || (*(++p) != 1)) return (0); + adr_typ = *(++p); + len -= 3; + p++; + if (len < 2) return (0); + if (*p++ != 0x12) return (0); + if (*p > len) return (0); /* check number length */ + len = *p++; + } + else + if (*p == 0x80) + { retval = *(++p) + 2; /* total length */ + if (retval > len) return (0); + len = retval - 2; + p++; + } + else + return (0); /* invalid address information */ + + sprintf(st, "%d ", adr_typ); + st += strlen(st); + if (!len) + *st++ = '-'; + else + while (len--) + *st++ = *p++; + *st = '\0'; + return (retval); } /* put_address */ /*************************************/ @@ -599,93 +599,93 @@ static int put_address(char *st, u_char *p, int len) /*************************************/ static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs) { char *src = ic->parm.dss1_io.data; - int restlen = ic->parm.dss1_io.datalen; - int cnt = 1; - u_char n,n1; - char st[90], *p, *stp; - - if (restlen < 2) return(-100); /* frame too short */ - if (*src++ != 0x30) return(-101); - if ((n = *src++) > 0x81) return(-102); /* invalid length field */ - restlen -= 2; /* remaining bytes */ - if (n == 0x80) - { if (restlen < 2) return(-103); - if ((*(src+restlen-1)) || (*(src+restlen-2))) return(-104); - restlen -= 2; - } - else - if ( n == 0x81) - { n = *src++; - restlen--; - if (n > restlen) return(-105); - restlen = n; - } - else - if (n > restlen) return(-106); - else - restlen = n; /* standard format */ - if (restlen < 3) return(-107); /* no procedure */ - if ((*src++ != 2) || (*src++ != 1) || (*src++ != 0x0B)) return(-108); - restlen -= 3; - if (restlen < 2) return(-109); /* list missing */ - if (*src == 0x31) - { src++; - if ((n = *src++) > 0x81) return(-110); /* invalid length field */ - restlen -= 2; /* remaining bytes */ - if (n == 0x80) - { if (restlen < 2) return(-111); - if ((*(src+restlen-1)) || (*(src+restlen-2))) return(-112); - restlen -= 2; - } - else - if ( n == 0x81) - { n = *src++; - restlen--; - if (n > restlen) return(-113); - restlen = n; - } - else - if (n > restlen) return(-114); - else - restlen = n; /* standard format */ - } /* result list header */ - - while (restlen >= 2) - { stp = st; - sprintf(stp,"%d 0x%lx %d %s ",DIVERT_REPORT, ic->parm.dss1_io.ll_id, - cnt++,divert_if.drv_to_name(ic->driver)); - stp += strlen(stp); - if (*src++ != 0x30) return(-115); /* invalid enum */ - n = *src++; - restlen -= 2; - if (n > restlen) return(-116); /* enum length wrong */ - restlen -= n; - p = src; /* one entry */ - src += n; - if (!(n1 = put_address(stp,p,n & 0xFF))) continue; - stp += strlen(stp); - p += n1; - n -= n1; - if (n < 6) continue; /* no service and proc */ - if ((*p++ != 0x0A) || (*p++ != 1)) continue; - sprintf(stp," 0x%02x ",(*p++) & 0xFF); - stp += strlen(stp); - if ((*p++ != 0x0A) || (*p++ != 1)) continue; - sprintf(stp,"%d ",(*p++) & 0xFF); - stp += strlen(stp); - n -= 6; - if (n > 2) - { if (*p++ != 0x30) continue; - if (*p > (n-2)) continue; - n = *p++; - if (!(n1 = put_address(stp,p,n & 0xFF))) continue; - stp += strlen(stp); - } - sprintf(stp,"\n"); - put_info_buffer(st); - } /* while restlen */ - if (restlen) return(-117); - return(0); + int restlen = ic->parm.dss1_io.datalen; + int cnt = 1; + u_char n, n1; + char st[90], *p, *stp; + + if (restlen < 2) return (-100); /* frame too short */ + if (*src++ != 0x30) return (-101); + if ((n = *src++) > 0x81) return (-102); /* invalid length field */ + restlen -= 2; /* remaining bytes */ + if (n == 0x80) + { if (restlen < 2) return (-103); + if ((*(src + restlen - 1)) || (*(src + restlen - 2))) return (-104); + restlen -= 2; + } + else + if (n == 0x81) + { n = *src++; + restlen--; + if (n > restlen) return (-105); + restlen = n; + } + else + if (n > restlen) return (-106); + else + restlen = n; /* standard format */ + if (restlen < 3) return (-107); /* no procedure */ + if ((*src++ != 2) || (*src++ != 1) || (*src++ != 0x0B)) return (-108); + restlen -= 3; + if (restlen < 2) return (-109); /* list missing */ + if (*src == 0x31) + { src++; + if ((n = *src++) > 0x81) return (-110); /* invalid length field */ + restlen -= 2; /* remaining bytes */ + if (n == 0x80) + { if (restlen < 2) return (-111); + if ((*(src + restlen - 1)) || (*(src + restlen - 2))) return (-112); + restlen -= 2; + } + else + if (n == 0x81) + { n = *src++; + restlen--; + if (n > restlen) return (-113); + restlen = n; + } + else + if (n > restlen) return (-114); + else + restlen = n; /* standard format */ + } /* result list header */ + + while (restlen >= 2) + { stp = st; + sprintf(stp, "%d 0x%lx %d %s ", DIVERT_REPORT, ic->parm.dss1_io.ll_id, + cnt++, divert_if.drv_to_name(ic->driver)); + stp += strlen(stp); + if (*src++ != 0x30) return (-115); /* invalid enum */ + n = *src++; + restlen -= 2; + if (n > restlen) return (-116); /* enum length wrong */ + restlen -= n; + p = src; /* one entry */ + src += n; + if (!(n1 = put_address(stp, p, n & 0xFF))) continue; + stp += strlen(stp); + p += n1; + n -= n1; + if (n < 6) continue; /* no service and proc */ + if ((*p++ != 0x0A) || (*p++ != 1)) continue; + sprintf(stp, " 0x%02x ", (*p++) & 0xFF); + stp += strlen(stp); + if ((*p++ != 0x0A) || (*p++ != 1)) continue; + sprintf(stp, "%d ", (*p++) & 0xFF); + stp += strlen(stp); + n -= 6; + if (n > 2) + { if (*p++ != 0x30) continue; + if (*p > (n - 2)) continue; + n = *p++; + if (!(n1 = put_address(stp, p, n & 0xFF))) continue; + stp += strlen(stp); + } + sprintf(stp, "\n"); + put_info_buffer(st); + } /* while restlen */ + if (restlen) return (-117); + return (0); } /* interrogate_success */ /*********************************************/ @@ -693,90 +693,90 @@ static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs) /*********************************************/ static int prot_stat_callback(isdn_ctrl *ic) { struct call_struc *cs, *cs1; - int i; - unsigned long flags; - - cs = divert_head; /* start of list */ - cs1 = NULL; - while (cs) - { if (ic->driver == cs->ics.driver) - { switch (cs->ics.arg) - { case DSS1_CMD_INVOKE: - if ((cs->ics.parm.dss1_io.ll_id == ic->parm.dss1_io.ll_id) && - (cs->ics.parm.dss1_io.hl_id == ic->parm.dss1_io.hl_id)) - { switch (ic->arg) - { case DSS1_STAT_INVOKE_ERR: - sprintf(cs->info,"128 0x%lx 0x%x\n", - ic->parm.dss1_io.ll_id, - ic->parm.dss1_io.timeout); - put_info_buffer(cs->info); - break; - - case DSS1_STAT_INVOKE_RES: - switch (cs->ics.parm.dss1_io.proc) - { case 7: - case 8: - put_info_buffer(cs->info); - break; - - case 11: - i = interrogate_success(ic,cs); - if (i) - sprintf(cs->info,"%d 0x%lx %d\n",DIVERT_REPORT, - ic->parm.dss1_io.ll_id,i); - put_info_buffer(cs->info); - break; - - default: - printk(KERN_WARNING "dss1_divert: unknown proc %d\n",cs->ics.parm.dss1_io.proc); - break; - } - - - break; - - default: - printk(KERN_WARNING "dss1_divert unknown invoke answer %lx\n",ic->arg); - break; - } - cs1 = cs; /* remember structure */ - cs = NULL; - continue; /* abort search */ - } /* id found */ - break; - - case DSS1_CMD_INVOKE_ABORT: - printk(KERN_WARNING "dss1_divert unhandled invoke abort\n"); - break; - - default: - printk(KERN_WARNING "dss1_divert unknown cmd 0x%lx\n",cs->ics.arg); - break; - } /* switch ics.arg */ - cs = cs->next; - } /* driver ok */ - } - - if (!cs1) - { printk(KERN_WARNING "dss1_divert unhandled process\n"); - return(0); - } - - if (cs1->ics.driver == -1) - { - spin_lock_irqsave(&divert_lock, flags); - del_timer(&cs1->timer); - if (cs1->prev) - cs1->prev->next = cs1->next; /* forward link */ - else - divert_head = cs1->next; - if (cs1->next) - cs1->next->prev = cs1->prev; /* back link */ - spin_unlock_irqrestore(&divert_lock, flags); - kfree(cs1); - } - - return(0); + int i; + unsigned long flags; + + cs = divert_head; /* start of list */ + cs1 = NULL; + while (cs) + { if (ic->driver == cs->ics.driver) + { switch (cs->ics.arg) + { case DSS1_CMD_INVOKE: + if ((cs->ics.parm.dss1_io.ll_id == ic->parm.dss1_io.ll_id) && + (cs->ics.parm.dss1_io.hl_id == ic->parm.dss1_io.hl_id)) + { switch (ic->arg) + { case DSS1_STAT_INVOKE_ERR: + sprintf(cs->info, "128 0x%lx 0x%x\n", + ic->parm.dss1_io.ll_id, + ic->parm.dss1_io.timeout); + put_info_buffer(cs->info); + break; + + case DSS1_STAT_INVOKE_RES: + switch (cs->ics.parm.dss1_io.proc) + { case 7: + case 8: + put_info_buffer(cs->info); + break; + + case 11: + i = interrogate_success(ic, cs); + if (i) + sprintf(cs->info, "%d 0x%lx %d\n", DIVERT_REPORT, + ic->parm.dss1_io.ll_id, i); + put_info_buffer(cs->info); + break; + + default: + printk(KERN_WARNING "dss1_divert: unknown proc %d\n", cs->ics.parm.dss1_io.proc); + break; + } + + + break; + + default: + printk(KERN_WARNING "dss1_divert unknown invoke answer %lx\n", ic->arg); + break; + } + cs1 = cs; /* remember structure */ + cs = NULL; + continue; /* abort search */ + } /* id found */ + break; + + case DSS1_CMD_INVOKE_ABORT: + printk(KERN_WARNING "dss1_divert unhandled invoke abort\n"); + break; + + default: + printk(KERN_WARNING "dss1_divert unknown cmd 0x%lx\n", cs->ics.arg); + break; + } /* switch ics.arg */ + cs = cs->next; + } /* driver ok */ + } + + if (!cs1) + { printk(KERN_WARNING "dss1_divert unhandled process\n"); + return (0); + } + + if (cs1->ics.driver == -1) + { + spin_lock_irqsave(&divert_lock, flags); + del_timer(&cs1->timer); + if (cs1->prev) + cs1->prev->next = cs1->next; /* forward link */ + else + divert_head = cs1->next; + if (cs1->next) + cs1->next->prev = cs1->prev; /* back link */ + spin_unlock_irqrestore(&divert_lock, flags); + kfree(cs1); + } + + return (0); } /* prot_stat_callback */ @@ -785,79 +785,78 @@ static int prot_stat_callback(isdn_ctrl *ic) /***************************/ static int isdn_divert_stat_callback(isdn_ctrl *ic) { struct call_struc *cs, *cs1; - unsigned long flags; - int retval; - - retval = -1; - cs = divert_head; /* start of list */ - while (cs) - { if ((ic->driver == cs->ics.driver) && (ic->arg == cs->ics.arg)) - { switch (ic->command) - { case ISDN_STAT_DHUP: - sprintf(cs->info,"129 0x%lx\n",cs->divert_id); - del_timer(&cs->timer); - cs->ics.driver = -1; - break; - - case ISDN_STAT_CAUSE: - sprintf(cs->info,"130 0x%lx %s\n",cs->divert_id,ic->parm.num); - break; - - case ISDN_STAT_REDIR: - sprintf(cs->info,"131 0x%lx\n",cs->divert_id); - del_timer(&cs->timer); - cs->ics.driver = -1; - break; - - default: - sprintf(cs->info,"999 0x%lx 0x%x\n",cs->divert_id,(int)(ic->command)); - break; - } - put_info_buffer(cs->info); - retval = 0; - } - cs1 = cs; - cs = cs->next; - if (cs1->ics.driver == -1) - { - spin_lock_irqsave(&divert_lock, flags); - if (cs1->prev) - cs1->prev->next = cs1->next; /* forward link */ - else - divert_head = cs1->next; - if (cs1->next) - cs1->next->prev = cs1->prev; /* back link */ - spin_unlock_irqrestore(&divert_lock, flags); - kfree(cs1); - } - } - return(retval); /* not found */ -} /* isdn_divert_stat_callback */ + unsigned long flags; + int retval; + + retval = -1; + cs = divert_head; /* start of list */ + while (cs) + { if ((ic->driver == cs->ics.driver) && (ic->arg == cs->ics.arg)) + { switch (ic->command) + { case ISDN_STAT_DHUP: + sprintf(cs->info, "129 0x%lx\n", cs->divert_id); + del_timer(&cs->timer); + cs->ics.driver = -1; + break; + + case ISDN_STAT_CAUSE: + sprintf(cs->info, "130 0x%lx %s\n", cs->divert_id, ic->parm.num); + break; + + case ISDN_STAT_REDIR: + sprintf(cs->info, "131 0x%lx\n", cs->divert_id); + del_timer(&cs->timer); + cs->ics.driver = -1; + break; + + default: + sprintf(cs->info, "999 0x%lx 0x%x\n", cs->divert_id, (int)(ic->command)); + break; + } + put_info_buffer(cs->info); + retval = 0; + } + cs1 = cs; + cs = cs->next; + if (cs1->ics.driver == -1) + { + spin_lock_irqsave(&divert_lock, flags); + if (cs1->prev) + cs1->prev->next = cs1->next; /* forward link */ + else + divert_head = cs1->next; + if (cs1->next) + cs1->next->prev = cs1->prev; /* back link */ + spin_unlock_irqrestore(&divert_lock, flags); + kfree(cs1); + } + } + return (retval); /* not found */ +} /* isdn_divert_stat_callback */ /********************/ /* callback from ll */ -/********************/ +/********************/ int ll_callback(isdn_ctrl *ic) { - switch (ic->command) - { case ISDN_STAT_ICALL: - case ISDN_STAT_ICALLW: - return(isdn_divert_icall(ic)); - break; - - case ISDN_STAT_PROT: - if ((ic->arg & 0xFF) == ISDN_PTYPE_EURO) - { if (ic->arg != DSS1_STAT_INVOKE_BRD) - return(prot_stat_callback(ic)); - else - return(0); /* DSS1 invoke broadcast */ - } - else - return(-1); /* protocol not euro */ - - default: - return(isdn_divert_stat_callback(ic)); - } + switch (ic->command) + { case ISDN_STAT_ICALL: + case ISDN_STAT_ICALLW: + return (isdn_divert_icall(ic)); + break; + + case ISDN_STAT_PROT: + if ((ic->arg & 0xFF) == ISDN_PTYPE_EURO) + { if (ic->arg != DSS1_STAT_INVOKE_BRD) + return (prot_stat_callback(ic)); + else + return (0); /* DSS1 invoke broadcast */ + } + else + return (-1); /* protocol not euro */ + + default: + return (isdn_divert_stat_callback(ic)); + } } /* ll_callback */ - diff --git a/drivers/isdn/divert/isdn_divert.h b/drivers/isdn/divert/isdn_divert.h index 19439a6176a9..42f289320d2d 100644 --- a/drivers/isdn/divert/isdn_divert.h +++ b/drivers/isdn/divert/isdn_divert.h @@ -3,7 +3,7 @@ * Header for the diversion supplementary ioctl interface. * * Copyright 1998 by Werner Cornelius (werner@ikt.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -20,13 +20,13 @@ #define IIOCGETDRV _IO('I', 2) /* get driver number */ #define IIOCGETNAM _IO('I', 3) /* get driver name */ #define IIOCGETRULE _IO('I', 4) /* read one rule */ -#define IIOCMODRULE _IO('I', 5) /* modify/replace a rule */ +#define IIOCMODRULE _IO('I', 5) /* modify/replace a rule */ #define IIOCINSRULE _IO('I', 6) /* insert/append one rule */ #define IIOCDELRULE _IO('I', 7) /* delete a rule */ #define IIOCDODFACT _IO('I', 8) /* hangup/reject/alert/immediately deflect a call */ #define IIOCDOCFACT _IO('I', 9) /* activate control forwarding in PBX */ -#define IIOCDOCFDIS _IO('I',10) /* deactivate control forwarding in PBX */ -#define IIOCDOCFINT _IO('I',11) /* interrogate control forwarding in PBX */ +#define IIOCDOCFDIS _IO('I', 10) /* deactivate control forwarding in PBX */ +#define IIOCDOCFINT _IO('I', 11) /* interrogate control forwarding in PBX */ /*************************************/ /* states reported through interface */ @@ -34,65 +34,65 @@ #define DEFLECT_IGNORE 0 /* ignore incoming call */ #define DEFLECT_REPORT 1 /* only report */ #define DEFLECT_PROCEED 2 /* deflect when externally triggered */ -#define DEFLECT_ALERT 3 /* alert and deflect after delay */ +#define DEFLECT_ALERT 3 /* alert and deflect after delay */ #define DEFLECT_REJECT 4 /* reject immediately */ #define DIVERT_ACTIVATE 5 /* diversion activate */ #define DIVERT_DEACTIVATE 6 /* diversion deactivate */ -#define DIVERT_REPORT 7 /* interrogation result */ -#define DEFLECT_AUTODEL 255 /* only for internal use */ +#define DIVERT_REPORT 7 /* interrogation result */ +#define DEFLECT_AUTODEL 255 /* only for internal use */ #define DEFLECT_ALL_IDS 0xFFFFFFFF /* all drivers selected */ typedef struct - { ulong drvid; /* driver ids, bit mapped */ - char my_msn[35]; /* desired msn, subaddr allowed */ - char caller[35]; /* caller id, partial string with * + subaddr allowed */ - char to_nr[35]; /* deflected to number incl. subaddress */ - u_char si1,si2; /* service indicators, si1=bitmask, si1+2 0 = all */ - u_char screen; /* screening: 0 = no info, 1 = info, 2 = nfo with nr */ - u_char callopt; /* option for call handling: - 0 = all calls - 1 = only non waiting calls - 2 = only waiting calls */ - u_char action; /* desired action: - 0 = don't report call -> ignore - 1 = report call, do not allow/proceed for deflection - 2 = report call, send proceed, wait max waittime secs - 3 = report call, alert and deflect after waittime - 4 = report call, reject immediately - actions 1-2 only take place if interface is opened - */ - u_char waittime; /* maximum wait time for proceeding */ - } divert_rule; +{ ulong drvid; /* driver ids, bit mapped */ + char my_msn[35]; /* desired msn, subaddr allowed */ + char caller[35]; /* caller id, partial string with * + subaddr allowed */ + char to_nr[35]; /* deflected to number incl. subaddress */ + u_char si1, si2; /* service indicators, si1=bitmask, si1+2 0 = all */ + u_char screen; /* screening: 0 = no info, 1 = info, 2 = nfo with nr */ + u_char callopt; /* option for call handling: + 0 = all calls + 1 = only non waiting calls + 2 = only waiting calls */ + u_char action; /* desired action: + 0 = don't report call -> ignore + 1 = report call, do not allow/proceed for deflection + 2 = report call, send proceed, wait max waittime secs + 3 = report call, alert and deflect after waittime + 4 = report call, reject immediately + actions 1-2 only take place if interface is opened + */ + u_char waittime; /* maximum wait time for proceeding */ +} divert_rule; typedef union - { int drv_version; /* return of driver version */ - struct - { int drvid; /* id of driver */ - char drvnam[30]; /* name of driver */ - } getid; - struct - { int ruleidx; /* index of rule */ - divert_rule rule; /* rule parms */ - } getsetrule; - struct - { u_char subcmd; /* 0 = hangup/reject, - 1 = alert, - 2 = deflect */ - ulong callid; /* id of call delivered by ascii output */ - char to_nr[35]; /* destination when deflect, - else uus1 string (maxlen 31), - data from rule used if empty */ - } fwd_ctrl; - struct - { int drvid; /* id of driver */ - u_char cfproc; /* cfu = 0, cfb = 1, cfnr = 2 */ - ulong procid; /* process id returned when no error */ - u_char service; /* basically coded service, 0 = all */ - char msn[25]; /* desired msn, empty = all */ - char fwd_nr[35];/* forwarded to number + subaddress */ - } cf_ctrl; - } divert_ioctl; +{ int drv_version; /* return of driver version */ + struct + { int drvid; /* id of driver */ + char drvnam[30]; /* name of driver */ + } getid; + struct + { int ruleidx; /* index of rule */ + divert_rule rule; /* rule parms */ + } getsetrule; + struct + { u_char subcmd; /* 0 = hangup/reject, + 1 = alert, + 2 = deflect */ + ulong callid; /* id of call delivered by ascii output */ + char to_nr[35]; /* destination when deflect, + else uus1 string (maxlen 31), + data from rule used if empty */ + } fwd_ctrl; + struct + { int drvid; /* id of driver */ + u_char cfproc; /* cfu = 0, cfb = 1, cfnr = 2 */ + ulong procid; /* process id returned when no error */ + u_char service; /* basically coded service, 0 = all */ + char msn[25]; /* desired msn, empty = all */ + char fwd_nr[35];/* forwarded to number + subaddress */ + } cf_ctrl; +} divert_ioctl; #ifdef __KERNEL__ @@ -105,10 +105,10 @@ typedef union /* structure keeping ascii info for device output */ /**************************************************/ struct divert_info - { struct divert_info *next; - ulong usage_cnt; /* number of files still to work */ - char info_start[2]; /* info string start */ - }; +{ struct divert_info *next; + ulong usage_cnt; /* number of files still to work */ + char info_start[2]; /* info string start */ +}; /**************/ diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c index fddae72e3f98..c90dca5abeac 100644 --- a/drivers/isdn/gigaset/asyncdata.c +++ b/drivers/isdn/gigaset/asyncdata.c @@ -214,7 +214,7 @@ static unsigned hdlc_loop(unsigned numbytes, struct inbuf_t *inbuf) } else if (fcs != PPP_GOODFCS) { /* frame check error */ dev_err(cs->dev, - "Checksum failed, %u bytes corrupted!\n", + "Checksum failed, %u bytes corrupted!\n", skb->len); gigaset_isdn_rcv_err(bcs); dev_kfree_skb_any(skb); @@ -543,7 +543,7 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb) /* size of new buffer (worst case = every byte must be stuffed): * 2 * original size + room for link layer header */ - iraw_skb = dev_alloc_skb(2*skb->len + skb->mac_len); + iraw_skb = dev_alloc_skb(2 * skb->len + skb->mac_len); if (!iraw_skb) { dev_kfree_skb_any(skb); return NULL; diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index 3913f47ef86d..afa080258bfa 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c @@ -410,10 +410,10 @@ static void check_pending(struct bas_cardstate *ucs) if (!(ucs->basstate & BS_RESETTING)) ucs->pending = 0; break; - /* - * HD_READ_ATMESSAGE and HD_WRITE_ATMESSAGE are handled separately - * and should never end up here - */ + /* + * HD_READ_ATMESSAGE and HD_WRITE_ATMESSAGE are handled separately + * and should never end up here + */ default: dev_warn(&ucs->interface->dev, "unknown pending request 0x%02x cleared\n", @@ -491,7 +491,7 @@ static void read_ctrl_callback(struct urb *urb) numbytes = urb->actual_length; if (unlikely(numbytes != ucs->rcvbuf_size)) { dev_warn(cs->dev, - "control read: received %d chars, expected %d\n", + "control read: received %d chars, expected %d\n", numbytes, ucs->rcvbuf_size); if (numbytes > ucs->rcvbuf_size) numbytes = ucs->rcvbuf_size; @@ -710,7 +710,7 @@ static void read_int_callback(struct urb *urb) } l = (unsigned) ucs->int_in_buf[1] + - (((unsigned) ucs->int_in_buf[2]) << 8); + (((unsigned) ucs->int_in_buf[2]) << 8); gig_dbg(DEBUG_USBREQ, "<-------%d: 0x%02x (%u [0x%02x 0x%02x])", urb->actual_length, (int)ucs->int_in_buf[0], l, @@ -770,14 +770,14 @@ static void read_int_callback(struct urb *urb) case HD_RECEIVEATDATA_ACK: /* AT response ready to be received */ if (!l) { dev_warn(cs->dev, - "HD_RECEIVEATDATA_ACK with length 0 ignored\n"); + "HD_RECEIVEATDATA_ACK with length 0 ignored\n"); break; } spin_lock_irqsave(&cs->lock, flags); if (ucs->basstate & BS_ATRDPEND) { spin_unlock_irqrestore(&cs->lock, flags); dev_warn(cs->dev, - "HD_RECEIVEATDATA_ACK(%d) during HD_READ_ATMESSAGE(%d) ignored\n", + "HD_RECEIVEATDATA_ACK(%d) during HD_READ_ATMESSAGE(%d) ignored\n", l, ucs->rcvbuf_size); break; } @@ -878,7 +878,7 @@ static void read_iso_callback(struct urb *urb) ubc->isoinlost += urb->iso_frame_desc[i].actual_length; if (unlikely(urb->iso_frame_desc[i].status != 0 && urb->iso_frame_desc[i].status != - -EINPROGRESS)) + -EINPROGRESS)) ubc->loststatus = urb->iso_frame_desc[i].status; urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].actual_length = 0; @@ -891,7 +891,7 @@ static void read_iso_callback(struct urb *urb) rc = usb_submit_urb(urb, GFP_ATOMIC); if (unlikely(rc != 0 && rc != -ENODEV)) { dev_err(bcs->cs->dev, - "could not resubmit isoc read URB: %s\n", + "could not resubmit isoc read URB: %s\n", get_usb_rcmsg(rc)); dump_urb(DEBUG_ISO, "isoc read", urb); error_hangup(bcs); @@ -1017,17 +1017,17 @@ static int starturbs(struct bc_state *bcs) } /* keep one URB free, submit the others */ - for (k = 0; k < BAS_OUTURBS-1; ++k) { + for (k = 0; k < BAS_OUTURBS - 1; ++k) { dump_urb(DEBUG_ISO, "Initial isoc write", urb); rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC); if (rc != 0) goto error; } dump_urb(DEBUG_ISO, "Initial isoc write (free)", urb); - ubc->isooutfree = &ubc->isoouturbs[BAS_OUTURBS-1]; + ubc->isooutfree = &ubc->isoouturbs[BAS_OUTURBS - 1]; ubc->isooutdone = ubc->isooutovfl = NULL; return 0; - error: +error: stopurbs(ubc); return rc; } @@ -1229,7 +1229,7 @@ static void write_iso_tasklet(unsigned long data) if (ifd->status || ifd->actual_length != ifd->length) { dev_warn(cs->dev, - "isoc write: frame %d[%d/%d]: %s\n", + "isoc write: frame %d[%d/%d]: %s\n", i, ifd->actual_length, ifd->length, get_usb_statmsg(ifd->status)); @@ -1316,7 +1316,7 @@ static void read_iso_tasklet(unsigned long data) ubc->isoindone = NULL; if (unlikely(ubc->loststatus != -EINPROGRESS)) { dev_warn(cs->dev, - "isoc read overrun, URB dropped (status: %s, %d bytes)\n", + "isoc read overrun, URB dropped (status: %s, %d bytes)\n", get_usb_statmsg(ubc->loststatus), ubc->isoinlost); ubc->loststatus = -EINPROGRESS; @@ -1965,7 +1965,7 @@ static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb) int rc; gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? - DEBUG_TRANSCMD : DEBUG_LOCKCMD, + DEBUG_TRANSCMD : DEBUG_LOCKCMD, "CMD Transmit", cb->len, cb->buf); /* translate "+++" escape sequence sent as a single separate command @@ -2453,13 +2453,13 @@ static int gigaset_suspend(struct usb_interface *intf, pm_message_t message) /* wait a bit for blocking conditions to go away */ rc = wait_event_timeout(ucs->waitqueue, - !(ucs->basstate & - (BS_B1OPEN|BS_B2OPEN|BS_ATRDPEND|BS_ATWRPEND)), - BAS_TIMEOUT*HZ/10); + !(ucs->basstate & + (BS_B1OPEN | BS_B2OPEN | BS_ATRDPEND | BS_ATWRPEND)), + BAS_TIMEOUT * HZ / 10); gig_dbg(DEBUG_SUSPEND, "wait_event_timeout() -> %d", rc); /* check for conditions preventing suspend */ - if (ucs->basstate & (BS_B1OPEN|BS_B2OPEN|BS_ATRDPEND|BS_ATWRPEND)) { + if (ucs->basstate & (BS_B1OPEN | BS_B2OPEN | BS_ATRDPEND | BS_ATWRPEND)) { dev_warn(cs->dev, "cannot suspend:\n"); if (ucs->basstate & BS_B1OPEN) dev_warn(cs->dev, " B channel 1 open\n"); @@ -2482,7 +2482,7 @@ static int gigaset_suspend(struct usb_interface *intf, pm_message_t message) return rc; } wait_event_timeout(ucs->waitqueue, !ucs->pending, - BAS_TIMEOUT*HZ/10); + BAS_TIMEOUT * HZ / 10); /* in case of timeout, proceed anyway */ } diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c index 6d5ceeece9f2..343b5c80cb7b 100644 --- a/drivers/isdn/gigaset/capi.c +++ b/drivers/isdn/gigaset/capi.c @@ -26,17 +26,17 @@ #define CapiFacilitySpecificFunctionNotSupported 0x3011 /* missing from capicmd.h */ -#define CAPI_CONNECT_IND_BASELEN (CAPI_MSG_BASELEN+4+2+8*1) -#define CAPI_CONNECT_ACTIVE_IND_BASELEN (CAPI_MSG_BASELEN+4+3*1) -#define CAPI_CONNECT_B3_IND_BASELEN (CAPI_MSG_BASELEN+4+1) -#define CAPI_CONNECT_B3_ACTIVE_IND_BASELEN (CAPI_MSG_BASELEN+4+1) -#define CAPI_DATA_B3_REQ_LEN64 (CAPI_MSG_BASELEN+4+4+2+2+2+8) -#define CAPI_DATA_B3_CONF_LEN (CAPI_MSG_BASELEN+4+2+2) -#define CAPI_DISCONNECT_IND_LEN (CAPI_MSG_BASELEN+4+2) -#define CAPI_DISCONNECT_B3_IND_BASELEN (CAPI_MSG_BASELEN+4+2+1) -#define CAPI_FACILITY_CONF_BASELEN (CAPI_MSG_BASELEN+4+2+2+1) +#define CAPI_CONNECT_IND_BASELEN (CAPI_MSG_BASELEN + 4 + 2 + 8 * 1) +#define CAPI_CONNECT_ACTIVE_IND_BASELEN (CAPI_MSG_BASELEN + 4 + 3 * 1) +#define CAPI_CONNECT_B3_IND_BASELEN (CAPI_MSG_BASELEN + 4 + 1) +#define CAPI_CONNECT_B3_ACTIVE_IND_BASELEN (CAPI_MSG_BASELEN + 4 + 1) +#define CAPI_DATA_B3_REQ_LEN64 (CAPI_MSG_BASELEN + 4 + 4 + 2 + 2 + 2 + 8) +#define CAPI_DATA_B3_CONF_LEN (CAPI_MSG_BASELEN + 4 + 2 + 2) +#define CAPI_DISCONNECT_IND_LEN (CAPI_MSG_BASELEN + 4 + 2) +#define CAPI_DISCONNECT_B3_IND_BASELEN (CAPI_MSG_BASELEN + 4 + 2 + 1) +#define CAPI_FACILITY_CONF_BASELEN (CAPI_MSG_BASELEN + 4 + 2 + 2 + 1) /* most _CONF messages contain only Controller/PLCI/NCCI and Info parameters */ -#define CAPI_STDCONF_LEN (CAPI_MSG_BASELEN+4+2) +#define CAPI_STDCONF_LEN (CAPI_MSG_BASELEN + 4 + 2) #define CAPI_FACILITY_HANDSET 0x0000 #define CAPI_FACILITY_DTMF 0x0001 @@ -97,10 +97,10 @@ struct gigaset_capi_ctr { /* two _cmsg structures possibly used concurrently: */ _cmsg hcmsg; /* for message composition triggered from hardware */ _cmsg acmsg; /* for dissection of messages sent from application */ - u8 bc_buf[MAX_BC_OCTETS+1]; - u8 hlc_buf[MAX_HLC_OCTETS+1]; - u8 cgpty_buf[MAX_NUMBER_DIGITS+3]; - u8 cdpty_buf[MAX_NUMBER_DIGITS+2]; + u8 bc_buf[MAX_BC_OCTETS + 1]; + u8 hlc_buf[MAX_HLC_OCTETS + 1]; + u8 cgpty_buf[MAX_NUMBER_DIGITS + 3]; + u8 cdpty_buf[MAX_NUMBER_DIGITS + 2]; }; /* CIP Value table (from CAPI 2.0 standard, ch. 6.1) */ @@ -109,50 +109,50 @@ static struct { u8 *hlc; } cip2bchlc[] = { [1] = { "8090A3", NULL }, - /* Speech (A-law) */ + /* Speech (A-law) */ [2] = { "8890", NULL }, - /* Unrestricted digital information */ + /* Unrestricted digital information */ [3] = { "8990", NULL }, - /* Restricted digital information */ + /* Restricted digital information */ [4] = { "9090A3", NULL }, - /* 3,1 kHz audio (A-law) */ + /* 3,1 kHz audio (A-law) */ [5] = { "9190", NULL }, - /* 7 kHz audio */ + /* 7 kHz audio */ [6] = { "9890", NULL }, - /* Video */ + /* Video */ [7] = { "88C0C6E6", NULL }, - /* Packet mode */ + /* Packet mode */ [8] = { "8890218F", NULL }, - /* 56 kbit/s rate adaptation */ + /* 56 kbit/s rate adaptation */ [9] = { "9190A5", NULL }, - /* Unrestricted digital information with tones/announcements */ + /* Unrestricted digital information with tones/announcements */ [16] = { "8090A3", "9181" }, - /* Telephony */ + /* Telephony */ [17] = { "9090A3", "9184" }, - /* Group 2/3 facsimile */ + /* Group 2/3 facsimile */ [18] = { "8890", "91A1" }, - /* Group 4 facsimile Class 1 */ + /* Group 4 facsimile Class 1 */ [19] = { "8890", "91A4" }, - /* Teletex service basic and mixed mode - and Group 4 facsimile service Classes II and III */ + /* Teletex service basic and mixed mode + and Group 4 facsimile service Classes II and III */ [20] = { "8890", "91A8" }, - /* Teletex service basic and processable mode */ + /* Teletex service basic and processable mode */ [21] = { "8890", "91B1" }, - /* Teletex service basic mode */ + /* Teletex service basic mode */ [22] = { "8890", "91B2" }, - /* International interworking for Videotex */ + /* International interworking for Videotex */ [23] = { "8890", "91B5" }, - /* Telex */ + /* Telex */ [24] = { "8890", "91B8" }, - /* Message Handling Systems in accordance with X.400 */ + /* Message Handling Systems in accordance with X.400 */ [25] = { "8890", "91C1" }, - /* OSI application in accordance with X.200 */ + /* OSI application in accordance with X.200 */ [26] = { "9190A5", "9181" }, - /* 7 kHz telephony */ + /* 7 kHz telephony */ [27] = { "9190A5", "916001" }, - /* Video telephony, first connection */ + /* Video telephony, first connection */ [28] = { "8890", "916002" }, - /* Video telephony, second connection */ + /* Video telephony, second connection */ }; /* @@ -164,7 +164,7 @@ static struct { * emit unsupported parameter warning */ static inline void ignore_cstruct_param(struct cardstate *cs, _cstruct param, - char *msgname, char *paramname) + char *msgname, char *paramname) { if (param && *param) dev_warn(cs->dev, "%s: ignoring unsupported parameter: %s\n", @@ -259,15 +259,15 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, CAPIMSG_APPID(data), CAPIMSG_MSGID(data), l, CAPIMSG_CONTROL(data)); l -= 12; - dbgline = kmalloc(3*l, GFP_ATOMIC); + dbgline = kmalloc(3 * l, GFP_ATOMIC); if (!dbgline) return; for (i = 0; i < l; i++) { - dbgline[3*i] = hex_asc_hi(data[12+i]); - dbgline[3*i+1] = hex_asc_lo(data[12+i]); - dbgline[3*i+2] = ' '; + dbgline[3 * i] = hex_asc_hi(data[12 + i]); + dbgline[3 * i + 1] = hex_asc_lo(data[12 + i]); + dbgline[3 * i + 2] = ' '; } - dbgline[3*l-1] = '\0'; + dbgline[3 * l - 1] = '\0'; gig_dbg(level, " %s", dbgline); kfree(dbgline); if (CAPIMSG_COMMAND(data) == CAPI_DATA_B3 && @@ -279,16 +279,16 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, return; if (l > 64) l = 64; /* arbitrary limit */ - dbgline = kmalloc(3*l, GFP_ATOMIC); + dbgline = kmalloc(3 * l, GFP_ATOMIC); if (!dbgline) return; data += CAPIMSG_LEN(data); for (i = 0; i < l; i++) { - dbgline[3*i] = hex_asc_hi(data[i]); - dbgline[3*i+1] = hex_asc_lo(data[i]); - dbgline[3*i+2] = ' '; + dbgline[3 * i] = hex_asc_hi(data[i]); + dbgline[3 * i + 1] = hex_asc_lo(data[i]); + dbgline[3 * i + 2] = ' '; } - dbgline[3*l-1] = '\0'; + dbgline[3 * l - 1] = '\0'; gig_dbg(level, " %s", dbgline); kfree(dbgline); } @@ -301,7 +301,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, static const char *format_ie(const char *ie) { - static char result[3*MAX_FMT_IE_LEN]; + static char result[3 * MAX_FMT_IE_LEN]; int len, count; char *pout = result; @@ -310,7 +310,7 @@ static const char *format_ie(const char *ie) count = len = ie[0]; if (count > MAX_FMT_IE_LEN) - count = MAX_FMT_IE_LEN-1; + count = MAX_FMT_IE_LEN - 1; while (count--) { *pout++ = hex_asc_hi(*++ie); *pout++ = hex_asc_lo(*ie); @@ -403,8 +403,8 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb) send_data_b3_conf(cs, &iif->ctr, ap->id, CAPIMSG_MSGID(req), bcs->channel + 1, CAPIMSG_HANDLE_REQ(req), (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION) ? - CapiFlagsNotSupportedByProtocol : - CAPI_NOERROR); + CapiFlagsNotSupportedByProtocol : + CAPI_NOERROR); } EXPORT_SYMBOL_GPL(gigaset_skb_sent); @@ -589,7 +589,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state) } iif->cdpty_buf[0] = i + 1; iif->cdpty_buf[1] = 0x80; /* type / numbering plan unknown */ - memcpy(iif->cdpty_buf+2, at_state->str_var[STR_ZCPN], i); + memcpy(iif->cdpty_buf + 2, at_state->str_var[STR_ZCPN], i); iif->hcmsg.CalledPartyNumber = iif->cdpty_buf; msgsize += iif->hcmsg.CalledPartyNumber[0]; } @@ -605,7 +605,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state) iif->cgpty_buf[0] = i + 2; iif->cgpty_buf[1] = 0x00; /* type / numbering plan unknown */ iif->cgpty_buf[2] = 0x80; /* pres. allowed, not screened */ - memcpy(iif->cgpty_buf+3, at_state->str_var[STR_NMBR], i); + memcpy(iif->cgpty_buf + 3, at_state->str_var[STR_NMBR], i); iif->hcmsg.CallingPartyNumber = iif->cgpty_buf; msgsize += iif->hcmsg.CallingPartyNumber[0]; } @@ -977,7 +977,7 @@ void gigaset_isdn_stop(struct cardstate *cs) * register CAPI application */ static void gigaset_register_appl(struct capi_ctr *ctr, u16 appl, - capi_register_params *rp) + capi_register_params *rp) { struct gigaset_capi_ctr *iif = container_of(ctr, struct gigaset_capi_ctr, ctr); @@ -1181,21 +1181,21 @@ static void do_facility_req(struct gigaset_capi_ctr *iif, } if (CAPIMSG_U32(pparam, 4) != 0) { dev_notice(cs->dev, - "%s: unsupported supplementary service notification mask 0x%x\n", - "FACILITY_REQ", CAPIMSG_U32(pparam, 4)); + "%s: unsupported supplementary service notification mask 0x%x\n", + "FACILITY_REQ", CAPIMSG_U32(pparam, 4)); info = CapiFacilitySpecificFunctionNotSupported; confparam[3] = 2; /* length */ capimsg_setu16(confparam, 4, - CapiSupplementaryServiceNotSupported); + CapiSupplementaryServiceNotSupported); } info = CapiSuccess; confparam[3] = 2; /* length */ capimsg_setu16(confparam, 4, CapiSuccess); break; - /* ToDo: add supported services */ + /* ToDo: add supported services */ default: dev_notice(cs->dev, - "%s: unsupported supplementary service function 0x%04x\n", + "%s: unsupported supplementary service function 0x%04x\n", "FACILITY_REQ", function); info = CapiFacilitySpecificFunctionNotSupported; /* Supplementary Service specific parameter */ @@ -1318,7 +1318,7 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8; /* build command table */ - commands = kzalloc(AT_NUM*(sizeof *commands), GFP_KERNEL); + commands = kzalloc(AT_NUM * (sizeof *commands), GFP_KERNEL); if (!commands) goto oom; @@ -1353,10 +1353,10 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, commands[AT_TYPE] = kstrdup(s, GFP_KERNEL); if (!commands[AT_TYPE]) goto oom; - commands[AT_DIAL] = kmalloc(l+3, GFP_KERNEL); + commands[AT_DIAL] = kmalloc(l + 3, GFP_KERNEL); if (!commands[AT_DIAL]) goto oom; - snprintf(commands[AT_DIAL], l+3, "D%.*s\r", l, pp); + snprintf(commands[AT_DIAL], l + 3, "D%.*s\r", l, pp); /* encode parameter: Calling party number */ pp = cmsg->CallingPartyNumber; @@ -1406,10 +1406,10 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, if (l) { /* number */ - commands[AT_MSN] = kmalloc(l+8, GFP_KERNEL); + commands[AT_MSN] = kmalloc(l + 8, GFP_KERNEL); if (!commands[AT_MSN]) goto oom; - snprintf(commands[AT_MSN], l+8, "^SMSN=%*s\r", l, pp); + snprintf(commands[AT_MSN], l + 8, "^SMSN=%*s\r", l, pp); } } @@ -1430,13 +1430,13 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, /* determine lengths */ if (cmsg->BC && cmsg->BC[0]) /* BC specified explicitly */ - lbc = 2*cmsg->BC[0]; + lbc = 2 * cmsg->BC[0]; else if (cip2bchlc[cmsg->CIPValue].bc) /* BC derived from CIP */ lbc = strlen(cip2bchlc[cmsg->CIPValue].bc); else /* no BC */ lbc = 0; if (cmsg->HLC && cmsg->HLC[0]) /* HLC specified explicitly */ - lhlc = 2*cmsg->HLC[0]; + lhlc = 2 * cmsg->HLC[0]; else if (cip2bchlc[cmsg->CIPValue].hlc) /* HLC derived from CIP */ lhlc = strlen(cip2bchlc[cmsg->CIPValue].hlc); else /* no HLC */ @@ -1481,7 +1481,7 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, if (cmsg->BProtocol == CAPI_DEFAULT) { bcs->proto2 = L2_HDLC; dev_warn(cs->dev, - "B2 Protocol X.75 SLP unsupported, using Transparent\n"); + "B2 Protocol X.75 SLP unsupported, using Transparent\n"); } else { switch (cmsg->B1protocol) { case 0: @@ -1492,24 +1492,24 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, break; default: dev_warn(cs->dev, - "B1 Protocol %u unsupported, using Transparent\n", + "B1 Protocol %u unsupported, using Transparent\n", cmsg->B1protocol); bcs->proto2 = L2_VOICE; } if (cmsg->B2protocol != 1) dev_warn(cs->dev, - "B2 Protocol %u unsupported, using Transparent\n", + "B2 Protocol %u unsupported, using Transparent\n", cmsg->B2protocol); if (cmsg->B3protocol != 0) dev_warn(cs->dev, - "B3 Protocol %u unsupported, using Transparent\n", + "B3 Protocol %u unsupported, using Transparent\n", cmsg->B3protocol); ignore_cstruct_param(cs, cmsg->B1configuration, - "CONNECT_REQ", "B1 Configuration"); + "CONNECT_REQ", "B1 Configuration"); ignore_cstruct_param(cs, cmsg->B2configuration, - "CONNECT_REQ", "B2 Configuration"); + "CONNECT_REQ", "B2 Configuration"); ignore_cstruct_param(cs, cmsg->B3configuration, - "CONNECT_REQ", "B3 Configuration"); + "CONNECT_REQ", "B3 Configuration"); } commands[AT_PROTO] = kmalloc(9, GFP_KERNEL); if (!commands[AT_PROTO]) @@ -1518,20 +1518,20 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, /* ToDo: check/encode remaining parameters */ ignore_cstruct_param(cs, cmsg->CalledPartySubaddress, - "CONNECT_REQ", "Called pty subaddr"); + "CONNECT_REQ", "Called pty subaddr"); ignore_cstruct_param(cs, cmsg->CallingPartySubaddress, - "CONNECT_REQ", "Calling pty subaddr"); + "CONNECT_REQ", "Calling pty subaddr"); ignore_cstruct_param(cs, cmsg->LLC, - "CONNECT_REQ", "LLC"); + "CONNECT_REQ", "LLC"); if (cmsg->AdditionalInfo != CAPI_DEFAULT) { ignore_cstruct_param(cs, cmsg->BChannelinformation, - "CONNECT_REQ", "B Channel Information"); + "CONNECT_REQ", "B Channel Information"); ignore_cstruct_param(cs, cmsg->Keypadfacility, - "CONNECT_REQ", "Keypad Facility"); + "CONNECT_REQ", "Keypad Facility"); ignore_cstruct_param(cs, cmsg->Useruserdata, - "CONNECT_REQ", "User-User Data"); + "CONNECT_REQ", "User-User Data"); ignore_cstruct_param(cs, cmsg->Facilitydataarray, - "CONNECT_REQ", "Facility Data Array"); + "CONNECT_REQ", "Facility Data Array"); } /* encode parameter: B channel to use */ @@ -1602,7 +1602,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif, if (oap != ap) { spin_unlock_irqrestore(&bcs->aplock, flags); send_disconnect_ind(bcs, oap, - CapiCallGivenToOtherApplication); + CapiCallGivenToOtherApplication); spin_lock_irqsave(&bcs->aplock, flags); } } @@ -1619,7 +1619,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif, if (cmsg->BProtocol == CAPI_DEFAULT) { bcs->proto2 = L2_HDLC; dev_warn(cs->dev, - "B2 Protocol X.75 SLP unsupported, using Transparent\n"); + "B2 Protocol X.75 SLP unsupported, using Transparent\n"); } else { switch (cmsg->B1protocol) { case 0: @@ -1630,46 +1630,46 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif, break; default: dev_warn(cs->dev, - "B1 Protocol %u unsupported, using Transparent\n", + "B1 Protocol %u unsupported, using Transparent\n", cmsg->B1protocol); bcs->proto2 = L2_VOICE; } if (cmsg->B2protocol != 1) dev_warn(cs->dev, - "B2 Protocol %u unsupported, using Transparent\n", + "B2 Protocol %u unsupported, using Transparent\n", cmsg->B2protocol); if (cmsg->B3protocol != 0) dev_warn(cs->dev, - "B3 Protocol %u unsupported, using Transparent\n", + "B3 Protocol %u unsupported, using Transparent\n", cmsg->B3protocol); ignore_cstruct_param(cs, cmsg->B1configuration, - "CONNECT_RESP", "B1 Configuration"); + "CONNECT_RESP", "B1 Configuration"); ignore_cstruct_param(cs, cmsg->B2configuration, - "CONNECT_RESP", "B2 Configuration"); + "CONNECT_RESP", "B2 Configuration"); ignore_cstruct_param(cs, cmsg->B3configuration, - "CONNECT_RESP", "B3 Configuration"); + "CONNECT_RESP", "B3 Configuration"); } /* ToDo: check/encode remaining parameters */ ignore_cstruct_param(cs, cmsg->ConnectedNumber, - "CONNECT_RESP", "Connected Number"); + "CONNECT_RESP", "Connected Number"); ignore_cstruct_param(cs, cmsg->ConnectedSubaddress, - "CONNECT_RESP", "Connected Subaddress"); + "CONNECT_RESP", "Connected Subaddress"); ignore_cstruct_param(cs, cmsg->LLC, - "CONNECT_RESP", "LLC"); + "CONNECT_RESP", "LLC"); if (cmsg->AdditionalInfo != CAPI_DEFAULT) { ignore_cstruct_param(cs, cmsg->BChannelinformation, - "CONNECT_RESP", "BChannel Information"); + "CONNECT_RESP", "BChannel Information"); ignore_cstruct_param(cs, cmsg->Keypadfacility, - "CONNECT_RESP", "Keypad Facility"); + "CONNECT_RESP", "Keypad Facility"); ignore_cstruct_param(cs, cmsg->Useruserdata, - "CONNECT_RESP", "User-User Data"); + "CONNECT_RESP", "User-User Data"); ignore_cstruct_param(cs, cmsg->Facilitydataarray, - "CONNECT_RESP", "Facility Data Array"); + "CONNECT_RESP", "Facility Data Array"); } /* Accept call */ - if (!gigaset_add_event(cs, &cs->bcs[channel-1].at_state, + if (!gigaset_add_event(cs, &cs->bcs[channel - 1].at_state, EV_ACCEPT, NULL, 0, NULL)) return; gigaset_schedule_event(cs); @@ -1712,7 +1712,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif, if (oap != ap) { spin_unlock_irqrestore(&bcs->aplock, flags); send_disconnect_ind(bcs, oap, - CapiCallGivenToOtherApplication); + CapiCallGivenToOtherApplication); spin_lock_irqsave(&bcs->aplock, flags); } } @@ -1723,7 +1723,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif, /* reject call - will trigger DISCONNECT_IND for this app */ dev_info(cs->dev, "%s: Reject=%x\n", "CONNECT_RESP", cmsg->Reject); - if (!gigaset_add_event(cs, &cs->bcs[channel-1].at_state, + if (!gigaset_add_event(cs, &cs->bcs[channel - 1].at_state, EV_HUP, NULL, 0, NULL)) return; gigaset_schedule_event(cs); @@ -1756,7 +1756,7 @@ static void do_connect_b3_req(struct gigaset_capi_ctr *iif, send_conf(iif, ap, skb, CapiIllContrPlciNcci); return; } - bcs = &cs->bcs[channel-1]; + bcs = &cs->bcs[channel - 1]; /* mark logical connection active */ bcs->apconnstate = APCONN_ACTIVE; @@ -1767,7 +1767,7 @@ static void do_connect_b3_req(struct gigaset_capi_ctr *iif, /* NCPI parameter: not applicable for B3 Transparent */ ignore_cstruct_param(cs, cmsg->NCPI, "CONNECT_B3_REQ", "NCPI"); send_conf(iif, ap, skb, (cmsg->NCPI && cmsg->NCPI[0]) ? - CapiNcpiNotSupportedByProtocol : CapiSuccess); + CapiNcpiNotSupportedByProtocol : CapiSuccess); } /* @@ -1801,7 +1801,7 @@ static void do_connect_b3_resp(struct gigaset_capi_ctr *iif, dev_kfree_skb_any(skb); return; } - bcs = &cs->bcs[channel-1]; + bcs = &cs->bcs[channel - 1]; if (cmsg->Reject) { /* Reject: clear B3 connect received flag */ @@ -1905,7 +1905,7 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif, return; } capi_cmsg2message(b3cmsg, - __skb_put(b3skb, CAPI_DISCONNECT_B3_IND_BASELEN)); + __skb_put(b3skb, CAPI_DISCONNECT_B3_IND_BASELEN)); kfree(b3cmsg); capi_ctr_handle_message(&iif->ctr, ap->id, b3skb); } @@ -1947,7 +1947,7 @@ static void do_disconnect_b3_req(struct gigaset_capi_ctr *iif, send_conf(iif, ap, skb, CapiIllContrPlciNcci); return; } - bcs = &cs->bcs[channel-1]; + bcs = &cs->bcs[channel - 1]; /* reject if logical connection not active */ if (bcs->apconnstate < APCONN_ACTIVE) { @@ -1965,9 +1965,9 @@ static void do_disconnect_b3_req(struct gigaset_capi_ctr *iif, /* NCPI parameter: not applicable for B3 Transparent */ ignore_cstruct_param(cs, cmsg->NCPI, - "DISCONNECT_B3_REQ", "NCPI"); + "DISCONNECT_B3_REQ", "NCPI"); send_conf(iif, ap, skb, (cmsg->NCPI && cmsg->NCPI[0]) ? - CapiNcpiNotSupportedByProtocol : CapiSuccess); + CapiNcpiNotSupportedByProtocol : CapiSuccess); } /* @@ -1997,7 +1997,7 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif, send_conf(iif, ap, skb, CapiIllContrPlciNcci); return; } - bcs = &cs->bcs[channel-1]; + bcs = &cs->bcs[channel - 1]; if (msglen != CAPI_DATA_B3_REQ_LEN && msglen != CAPI_DATA_B3_REQ_LEN64) dev_notice(cs->dev, "%s: unexpected length %d\n", "DATA_B3_REQ", msglen); @@ -2040,7 +2040,7 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif, if (!(flags & CAPI_FLAGS_DELIVERY_CONFIRMATION)) send_data_b3_conf(cs, &iif->ctr, ap->id, msgid, channel, handle, flags ? CapiFlagsNotSupportedByProtocol - : CAPI_NOERROR); + : CAPI_NOERROR); } /* @@ -2258,11 +2258,11 @@ static int gigaset_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "name", ctr->name); seq_printf(m, "%-16s %s %s\n", "dev", - dev_driver_string(cs->dev), dev_name(cs->dev)); + dev_driver_string(cs->dev), dev_name(cs->dev)); seq_printf(m, "%-16s %d\n", "id", cs->myid); if (cs->gotfwver) seq_printf(m, "%-16s %d.%d.%d.%d\n", "firmware", - cs->fwver[0], cs->fwver[1], cs->fwver[2], cs->fwver[3]); + cs->fwver[0], cs->fwver[1], cs->fwver[2], cs->fwver[3]); seq_printf(m, "%-16s %d\n", "channels", cs->channels); seq_printf(m, "%-16s %s\n", "onechannel", cs->onechannel ? "yes" : "no"); @@ -2315,13 +2315,13 @@ static int gigaset_proc_show(struct seq_file *m, void *v) for (i = 0; i < cs->channels; i++) { seq_printf(m, "[%d]%-13s %d\n", i, "corrupted", - cs->bcs[i].corrupted); + cs->bcs[i].corrupted); seq_printf(m, "[%d]%-13s %d\n", i, "trans_down", - cs->bcs[i].trans_down); + cs->bcs[i].trans_down); seq_printf(m, "[%d]%-13s %d\n", i, "trans_up", - cs->bcs[i].trans_up); + cs->bcs[i].trans_up); seq_printf(m, "[%d]%-13s %d\n", i, "chstate", - cs->bcs[i].chstate); + cs->bcs[i].chstate); switch (cs->bcs[i].proto2) { case L2_BITSYNC: s = "bitsync"; diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index db621db67f61..e55aabf8df87 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c @@ -30,7 +30,7 @@ /* Module parameters */ int gigaset_debuglevel; EXPORT_SYMBOL_GPL(gigaset_debuglevel); -module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR); +module_param_named(debug, gigaset_debuglevel, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug level"); /* driver state flags */ @@ -123,7 +123,7 @@ int gigaset_enterconfigmode(struct cardstate *cs) if (r < 0) goto error; } - r = setflags(cs, TIOCM_RTS|TIOCM_DTR, 800); + r = setflags(cs, TIOCM_RTS | TIOCM_DTR, 800); if (r < 0) goto error; @@ -131,8 +131,8 @@ int gigaset_enterconfigmode(struct cardstate *cs) error: dev_err(cs->dev, "error %d on setuartbits\n", -r); - cs->control_state = TIOCM_RTS|TIOCM_DTR; - cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR); + cs->control_state = TIOCM_RTS | TIOCM_DTR; + cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS | TIOCM_DTR); return -1; } @@ -591,7 +591,7 @@ int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, if (head > tail) n = head - 1 - tail; else if (head == 0) - n = (RBUFSIZE-1) - tail; + n = (RBUFSIZE - 1) - tail; else n = RBUFSIZE - tail; if (!n) { @@ -911,10 +911,10 @@ int gigaset_start(struct cardstate *cs) spin_unlock_irqrestore(&cs->lock, flags); if (cs->mstate != MS_LOCKED) { - cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS); + cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR | TIOCM_RTS); cs->ops->baud_rate(cs, B115200); cs->ops->set_line_ctrl(cs, CS8); - cs->control_state = TIOCM_DTR|TIOCM_RTS; + cs->control_state = TIOCM_DTR | TIOCM_RTS; } cs->waiting = 1; diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c index 6d12623c1db0..624a8256a77f 100644 --- a/drivers/isdn/gigaset/ev-layer.c +++ b/drivers/isdn/gigaset/ev-layer.c @@ -153,104 +153,104 @@ struct reply_t gigaset_tab_nocid[] = * action, command */ /* initialize device, set cid mode if possible */ -{RSP_INIT, -1, -1, SEQ_INIT, 100, 1, {ACT_TIMEOUT} }, + {RSP_INIT, -1, -1, SEQ_INIT, 100, 1, {ACT_TIMEOUT} }, -{EV_TIMEOUT, 100, 100, -1, 101, 3, {0}, "Z\r"}, -{RSP_OK, 101, 103, -1, 120, 5, {ACT_GETSTRING}, - "+GMR\r"}, + {EV_TIMEOUT, 100, 100, -1, 101, 3, {0}, "Z\r"}, + {RSP_OK, 101, 103, -1, 120, 5, {ACT_GETSTRING}, + "+GMR\r"}, -{EV_TIMEOUT, 101, 101, -1, 102, 5, {0}, "Z\r"}, -{RSP_ERROR, 101, 101, -1, 102, 5, {0}, "Z\r"}, + {EV_TIMEOUT, 101, 101, -1, 102, 5, {0}, "Z\r"}, + {RSP_ERROR, 101, 101, -1, 102, 5, {0}, "Z\r"}, -{EV_TIMEOUT, 102, 102, -1, 108, 5, {ACT_SETDLE1}, - "^SDLE=0\r"}, -{RSP_OK, 108, 108, -1, 104, -1}, -{RSP_ZDLE, 104, 104, 0, 103, 5, {0}, "Z\r"}, -{EV_TIMEOUT, 104, 104, -1, 0, 0, {ACT_FAILINIT} }, -{RSP_ERROR, 108, 108, -1, 0, 0, {ACT_FAILINIT} }, + {EV_TIMEOUT, 102, 102, -1, 108, 5, {ACT_SETDLE1}, + "^SDLE=0\r"}, + {RSP_OK, 108, 108, -1, 104, -1}, + {RSP_ZDLE, 104, 104, 0, 103, 5, {0}, "Z\r"}, + {EV_TIMEOUT, 104, 104, -1, 0, 0, {ACT_FAILINIT} }, + {RSP_ERROR, 108, 108, -1, 0, 0, {ACT_FAILINIT} }, -{EV_TIMEOUT, 108, 108, -1, 105, 2, {ACT_SETDLE0, - ACT_HUPMODEM, - ACT_TIMEOUT} }, -{EV_TIMEOUT, 105, 105, -1, 103, 5, {0}, "Z\r"}, + {EV_TIMEOUT, 108, 108, -1, 105, 2, {ACT_SETDLE0, + ACT_HUPMODEM, + ACT_TIMEOUT} }, + {EV_TIMEOUT, 105, 105, -1, 103, 5, {0}, "Z\r"}, -{RSP_ERROR, 102, 102, -1, 107, 5, {0}, "^GETPRE\r"}, -{RSP_OK, 107, 107, -1, 0, 0, {ACT_CONFIGMODE} }, -{RSP_ERROR, 107, 107, -1, 0, 0, {ACT_FAILINIT} }, -{EV_TIMEOUT, 107, 107, -1, 0, 0, {ACT_FAILINIT} }, + {RSP_ERROR, 102, 102, -1, 107, 5, {0}, "^GETPRE\r"}, + {RSP_OK, 107, 107, -1, 0, 0, {ACT_CONFIGMODE} }, + {RSP_ERROR, 107, 107, -1, 0, 0, {ACT_FAILINIT} }, + {EV_TIMEOUT, 107, 107, -1, 0, 0, {ACT_FAILINIT} }, -{RSP_ERROR, 103, 103, -1, 0, 0, {ACT_FAILINIT} }, -{EV_TIMEOUT, 103, 103, -1, 0, 0, {ACT_FAILINIT} }, + {RSP_ERROR, 103, 103, -1, 0, 0, {ACT_FAILINIT} }, + {EV_TIMEOUT, 103, 103, -1, 0, 0, {ACT_FAILINIT} }, -{RSP_STRING, 120, 120, -1, 121, -1, {ACT_SETVER} }, + {RSP_STRING, 120, 120, -1, 121, -1, {ACT_SETVER} }, -{EV_TIMEOUT, 120, 121, -1, 0, 0, {ACT_FAILVER, - ACT_INIT} }, -{RSP_ERROR, 120, 121, -1, 0, 0, {ACT_FAILVER, - ACT_INIT} }, -{RSP_OK, 121, 121, -1, 0, 0, {ACT_GOTVER, - ACT_INIT} }, + {EV_TIMEOUT, 120, 121, -1, 0, 0, {ACT_FAILVER, + ACT_INIT} }, + {RSP_ERROR, 120, 121, -1, 0, 0, {ACT_FAILVER, + ACT_INIT} }, + {RSP_OK, 121, 121, -1, 0, 0, {ACT_GOTVER, + ACT_INIT} }, /* leave dle mode */ -{RSP_INIT, 0, 0, SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"}, -{RSP_OK, 201, 201, -1, 202, -1}, -{RSP_ZDLE, 202, 202, 0, 0, 0, {ACT_DLE0} }, -{RSP_NODEV, 200, 249, -1, 0, 0, {ACT_FAKEDLE0} }, -{RSP_ERROR, 200, 249, -1, 0, 0, {ACT_FAILDLE0} }, -{EV_TIMEOUT, 200, 249, -1, 0, 0, {ACT_FAILDLE0} }, + {RSP_INIT, 0, 0, SEQ_DLE0, 201, 5, {0}, "^SDLE=0\r"}, + {RSP_OK, 201, 201, -1, 202, -1}, + {RSP_ZDLE, 202, 202, 0, 0, 0, {ACT_DLE0} }, + {RSP_NODEV, 200, 249, -1, 0, 0, {ACT_FAKEDLE0} }, + {RSP_ERROR, 200, 249, -1, 0, 0, {ACT_FAILDLE0} }, + {EV_TIMEOUT, 200, 249, -1, 0, 0, {ACT_FAILDLE0} }, /* enter dle mode */ -{RSP_INIT, 0, 0, SEQ_DLE1, 251, 5, {0}, "^SDLE=1\r"}, -{RSP_OK, 251, 251, -1, 252, -1}, -{RSP_ZDLE, 252, 252, 1, 0, 0, {ACT_DLE1} }, -{RSP_ERROR, 250, 299, -1, 0, 0, {ACT_FAILDLE1} }, -{EV_TIMEOUT, 250, 299, -1, 0, 0, {ACT_FAILDLE1} }, + {RSP_INIT, 0, 0, SEQ_DLE1, 251, 5, {0}, "^SDLE=1\r"}, + {RSP_OK, 251, 251, -1, 252, -1}, + {RSP_ZDLE, 252, 252, 1, 0, 0, {ACT_DLE1} }, + {RSP_ERROR, 250, 299, -1, 0, 0, {ACT_FAILDLE1} }, + {EV_TIMEOUT, 250, 299, -1, 0, 0, {ACT_FAILDLE1} }, /* incoming call */ -{RSP_RING, -1, -1, -1, -1, -1, {ACT_RING} }, + {RSP_RING, -1, -1, -1, -1, -1, {ACT_RING} }, /* get cid */ -{RSP_INIT, 0, 0, SEQ_CID, 301, 5, {0}, "^SGCI?\r"}, -{RSP_OK, 301, 301, -1, 302, -1}, -{RSP_ZGCI, 302, 302, -1, 0, 0, {ACT_CID} }, -{RSP_ERROR, 301, 349, -1, 0, 0, {ACT_FAILCID} }, -{EV_TIMEOUT, 301, 349, -1, 0, 0, {ACT_FAILCID} }, + {RSP_INIT, 0, 0, SEQ_CID, 301, 5, {0}, "^SGCI?\r"}, + {RSP_OK, 301, 301, -1, 302, -1}, + {RSP_ZGCI, 302, 302, -1, 0, 0, {ACT_CID} }, + {RSP_ERROR, 301, 349, -1, 0, 0, {ACT_FAILCID} }, + {EV_TIMEOUT, 301, 349, -1, 0, 0, {ACT_FAILCID} }, /* enter cid mode */ -{RSP_INIT, 0, 0, SEQ_CIDMODE, 150, 5, {0}, "^SGCI=1\r"}, -{RSP_OK, 150, 150, -1, 0, 0, {ACT_CMODESET} }, -{RSP_ERROR, 150, 150, -1, 0, 0, {ACT_FAILCMODE} }, -{EV_TIMEOUT, 150, 150, -1, 0, 0, {ACT_FAILCMODE} }, + {RSP_INIT, 0, 0, SEQ_CIDMODE, 150, 5, {0}, "^SGCI=1\r"}, + {RSP_OK, 150, 150, -1, 0, 0, {ACT_CMODESET} }, + {RSP_ERROR, 150, 150, -1, 0, 0, {ACT_FAILCMODE} }, + {EV_TIMEOUT, 150, 150, -1, 0, 0, {ACT_FAILCMODE} }, /* leave cid mode */ -{RSP_INIT, 0, 0, SEQ_UMMODE, 160, 5, {0}, "Z\r"}, -{RSP_OK, 160, 160, -1, 0, 0, {ACT_UMODESET} }, -{RSP_ERROR, 160, 160, -1, 0, 0, {ACT_FAILUMODE} }, -{EV_TIMEOUT, 160, 160, -1, 0, 0, {ACT_FAILUMODE} }, + {RSP_INIT, 0, 0, SEQ_UMMODE, 160, 5, {0}, "Z\r"}, + {RSP_OK, 160, 160, -1, 0, 0, {ACT_UMODESET} }, + {RSP_ERROR, 160, 160, -1, 0, 0, {ACT_FAILUMODE} }, + {EV_TIMEOUT, 160, 160, -1, 0, 0, {ACT_FAILUMODE} }, /* abort getting cid */ -{RSP_INIT, 0, 0, SEQ_NOCID, 0, 0, {ACT_ABORTCID} }, + {RSP_INIT, 0, 0, SEQ_NOCID, 0, 0, {ACT_ABORTCID} }, /* reset */ -{RSP_INIT, 0, 0, SEQ_SHUTDOWN, 504, 5, {0}, "Z\r"}, -{RSP_OK, 504, 504, -1, 0, 0, {ACT_SDOWN} }, -{RSP_ERROR, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} }, -{EV_TIMEOUT, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} }, -{RSP_NODEV, 501, 599, -1, 0, 0, {ACT_FAKESDOWN} }, - -{EV_PROC_CIDMODE, -1, -1, -1, -1, -1, {ACT_PROC_CIDMODE} }, -{EV_IF_LOCK, -1, -1, -1, -1, -1, {ACT_IF_LOCK} }, -{EV_IF_VER, -1, -1, -1, -1, -1, {ACT_IF_VER} }, -{EV_START, -1, -1, -1, -1, -1, {ACT_START} }, -{EV_STOP, -1, -1, -1, -1, -1, {ACT_STOP} }, -{EV_SHUTDOWN, -1, -1, -1, -1, -1, {ACT_SHUTDOWN} }, + {RSP_INIT, 0, 0, SEQ_SHUTDOWN, 504, 5, {0}, "Z\r"}, + {RSP_OK, 504, 504, -1, 0, 0, {ACT_SDOWN} }, + {RSP_ERROR, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} }, + {EV_TIMEOUT, 501, 599, -1, 0, 0, {ACT_FAILSDOWN} }, + {RSP_NODEV, 501, 599, -1, 0, 0, {ACT_FAKESDOWN} }, + + {EV_PROC_CIDMODE, -1, -1, -1, -1, -1, {ACT_PROC_CIDMODE} }, + {EV_IF_LOCK, -1, -1, -1, -1, -1, {ACT_IF_LOCK} }, + {EV_IF_VER, -1, -1, -1, -1, -1, {ACT_IF_VER} }, + {EV_START, -1, -1, -1, -1, -1, {ACT_START} }, + {EV_STOP, -1, -1, -1, -1, -1, {ACT_STOP} }, + {EV_SHUTDOWN, -1, -1, -1, -1, -1, {ACT_SHUTDOWN} }, /* misc. */ -{RSP_ERROR, -1, -1, -1, -1, -1, {ACT_ERROR} }, -{RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} }, -{RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} }, -{RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} }, -{RSP_LAST} + {RSP_ERROR, -1, -1, -1, -1, -1, {ACT_ERROR} }, + {RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} }, + {RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} }, + {RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} }, + {RSP_LAST} }; /* 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring, @@ -261,91 +261,91 @@ struct reply_t gigaset_tab_cid[] = * action, command */ /* dial */ -{EV_DIAL, -1, -1, -1, -1, -1, {ACT_DIAL} }, -{RSP_INIT, 0, 0, SEQ_DIAL, 601, 5, {ACT_CMD+AT_BC} }, -{RSP_OK, 601, 601, -1, 603, 5, {ACT_CMD+AT_PROTO} }, -{RSP_OK, 603, 603, -1, 604, 5, {ACT_CMD+AT_TYPE} }, -{RSP_OK, 604, 604, -1, 605, 5, {ACT_CMD+AT_MSN} }, -{RSP_NULL, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} }, -{RSP_OK, 605, 605, -1, 606, 5, {ACT_CMD+AT_CLIP} }, -{RSP_NULL, 606, 606, -1, 607, 5, {ACT_CMD+AT_ISO} }, -{RSP_OK, 606, 606, -1, 607, 5, {ACT_CMD+AT_ISO} }, -{RSP_OK, 607, 607, -1, 608, 5, {0}, "+VLS=17\r"}, -{RSP_OK, 608, 608, -1, 609, -1}, -{RSP_ZSAU, 609, 609, ZSAU_PROCEEDING, 610, 5, {ACT_CMD+AT_DIAL} }, -{RSP_OK, 610, 610, -1, 650, 0, {ACT_DIALING} }, - -{RSP_ERROR, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} }, -{EV_TIMEOUT, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} }, + {EV_DIAL, -1, -1, -1, -1, -1, {ACT_DIAL} }, + {RSP_INIT, 0, 0, SEQ_DIAL, 601, 5, {ACT_CMD + AT_BC} }, + {RSP_OK, 601, 601, -1, 603, 5, {ACT_CMD + AT_PROTO} }, + {RSP_OK, 603, 603, -1, 604, 5, {ACT_CMD + AT_TYPE} }, + {RSP_OK, 604, 604, -1, 605, 5, {ACT_CMD + AT_MSN} }, + {RSP_NULL, 605, 605, -1, 606, 5, {ACT_CMD + AT_CLIP} }, + {RSP_OK, 605, 605, -1, 606, 5, {ACT_CMD + AT_CLIP} }, + {RSP_NULL, 606, 606, -1, 607, 5, {ACT_CMD + AT_ISO} }, + {RSP_OK, 606, 606, -1, 607, 5, {ACT_CMD + AT_ISO} }, + {RSP_OK, 607, 607, -1, 608, 5, {0}, "+VLS=17\r"}, + {RSP_OK, 608, 608, -1, 609, -1}, + {RSP_ZSAU, 609, 609, ZSAU_PROCEEDING, 610, 5, {ACT_CMD + AT_DIAL} }, + {RSP_OK, 610, 610, -1, 650, 0, {ACT_DIALING} }, + + {RSP_ERROR, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} }, + {EV_TIMEOUT, 601, 610, -1, 0, 0, {ACT_ABORTDIAL} }, /* optional dialing responses */ -{EV_BC_OPEN, 650, 650, -1, 651, -1}, -{RSP_ZVLS, 609, 651, 17, -1, -1, {ACT_DEBUG} }, -{RSP_ZCTP, 610, 651, -1, -1, -1, {ACT_DEBUG} }, -{RSP_ZCPN, 610, 651, -1, -1, -1, {ACT_DEBUG} }, -{RSP_ZSAU, 650, 651, ZSAU_CALL_DELIVERED, -1, -1, {ACT_DEBUG} }, + {EV_BC_OPEN, 650, 650, -1, 651, -1}, + {RSP_ZVLS, 609, 651, 17, -1, -1, {ACT_DEBUG} }, + {RSP_ZCTP, 610, 651, -1, -1, -1, {ACT_DEBUG} }, + {RSP_ZCPN, 610, 651, -1, -1, -1, {ACT_DEBUG} }, + {RSP_ZSAU, 650, 651, ZSAU_CALL_DELIVERED, -1, -1, {ACT_DEBUG} }, /* connect */ -{RSP_ZSAU, 650, 650, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} }, -{RSP_ZSAU, 651, 651, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT, - ACT_NOTIFY_BC_UP} }, -{RSP_ZSAU, 750, 750, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} }, -{RSP_ZSAU, 751, 751, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT, - ACT_NOTIFY_BC_UP} }, -{EV_BC_OPEN, 800, 800, -1, 800, -1, {ACT_NOTIFY_BC_UP} }, + {RSP_ZSAU, 650, 650, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} }, + {RSP_ZSAU, 651, 651, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT, + ACT_NOTIFY_BC_UP} }, + {RSP_ZSAU, 750, 750, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT} }, + {RSP_ZSAU, 751, 751, ZSAU_ACTIVE, 800, -1, {ACT_CONNECT, + ACT_NOTIFY_BC_UP} }, + {EV_BC_OPEN, 800, 800, -1, 800, -1, {ACT_NOTIFY_BC_UP} }, /* remote hangup */ -{RSP_ZSAU, 650, 651, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT} }, -{RSP_ZSAU, 750, 751, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} }, -{RSP_ZSAU, 800, 800, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} }, + {RSP_ZSAU, 650, 651, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT} }, + {RSP_ZSAU, 750, 751, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} }, + {RSP_ZSAU, 800, 800, ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP} }, /* hangup */ -{EV_HUP, -1, -1, -1, -1, -1, {ACT_HUP} }, -{RSP_INIT, -1, -1, SEQ_HUP, 401, 5, {0}, "+VLS=0\r"}, -{RSP_OK, 401, 401, -1, 402, 5}, -{RSP_ZVLS, 402, 402, 0, 403, 5}, -{RSP_ZSAU, 403, 403, ZSAU_DISCONNECT_REQ, -1, -1, {ACT_DEBUG} }, -{RSP_ZSAU, 403, 403, ZSAU_NULL, 0, 0, {ACT_DISCONNECT} }, -{RSP_NODEV, 401, 403, -1, 0, 0, {ACT_FAKEHUP} }, -{RSP_ERROR, 401, 401, -1, 0, 0, {ACT_ABORTHUP} }, -{EV_TIMEOUT, 401, 403, -1, 0, 0, {ACT_ABORTHUP} }, - -{EV_BC_CLOSED, 0, 0, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} }, + {EV_HUP, -1, -1, -1, -1, -1, {ACT_HUP} }, + {RSP_INIT, -1, -1, SEQ_HUP, 401, 5, {0}, "+VLS=0\r"}, + {RSP_OK, 401, 401, -1, 402, 5}, + {RSP_ZVLS, 402, 402, 0, 403, 5}, + {RSP_ZSAU, 403, 403, ZSAU_DISCONNECT_REQ, -1, -1, {ACT_DEBUG} }, + {RSP_ZSAU, 403, 403, ZSAU_NULL, 0, 0, {ACT_DISCONNECT} }, + {RSP_NODEV, 401, 403, -1, 0, 0, {ACT_FAKEHUP} }, + {RSP_ERROR, 401, 401, -1, 0, 0, {ACT_ABORTHUP} }, + {EV_TIMEOUT, 401, 403, -1, 0, 0, {ACT_ABORTHUP} }, + + {EV_BC_CLOSED, 0, 0, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} }, /* ring */ -{RSP_ZBC, 700, 700, -1, -1, -1, {0} }, -{RSP_ZHLC, 700, 700, -1, -1, -1, {0} }, -{RSP_NMBR, 700, 700, -1, -1, -1, {0} }, -{RSP_ZCPN, 700, 700, -1, -1, -1, {0} }, -{RSP_ZCTP, 700, 700, -1, -1, -1, {0} }, -{EV_TIMEOUT, 700, 700, -1, 720, 720, {ACT_ICALL} }, -{EV_BC_CLOSED, 720, 720, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} }, + {RSP_ZBC, 700, 700, -1, -1, -1, {0} }, + {RSP_ZHLC, 700, 700, -1, -1, -1, {0} }, + {RSP_NMBR, 700, 700, -1, -1, -1, {0} }, + {RSP_ZCPN, 700, 700, -1, -1, -1, {0} }, + {RSP_ZCTP, 700, 700, -1, -1, -1, {0} }, + {EV_TIMEOUT, 700, 700, -1, 720, 720, {ACT_ICALL} }, + {EV_BC_CLOSED, 720, 720, -1, 0, -1, {ACT_NOTIFY_BC_DOWN} }, /*accept icall*/ -{EV_ACCEPT, -1, -1, -1, -1, -1, {ACT_ACCEPT} }, -{RSP_INIT, 720, 720, SEQ_ACCEPT, 721, 5, {ACT_CMD+AT_PROTO} }, -{RSP_OK, 721, 721, -1, 722, 5, {ACT_CMD+AT_ISO} }, -{RSP_OK, 722, 722, -1, 723, 5, {0}, "+VLS=17\r"}, -{RSP_OK, 723, 723, -1, 724, 5, {0} }, -{RSP_ZVLS, 724, 724, 17, 750, 50, {ACT_ACCEPTED} }, -{RSP_ERROR, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} }, -{EV_TIMEOUT, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} }, -{RSP_ZSAU, 700, 729, ZSAU_NULL, 0, 0, {ACT_ABORTACCEPT} }, -{RSP_ZSAU, 700, 729, ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT} }, -{RSP_ZSAU, 700, 729, ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT} }, - -{EV_BC_OPEN, 750, 750, -1, 751, -1}, -{EV_TIMEOUT, 750, 751, -1, 0, 0, {ACT_CONNTIMEOUT} }, + {EV_ACCEPT, -1, -1, -1, -1, -1, {ACT_ACCEPT} }, + {RSP_INIT, 720, 720, SEQ_ACCEPT, 721, 5, {ACT_CMD + AT_PROTO} }, + {RSP_OK, 721, 721, -1, 722, 5, {ACT_CMD + AT_ISO} }, + {RSP_OK, 722, 722, -1, 723, 5, {0}, "+VLS=17\r"}, + {RSP_OK, 723, 723, -1, 724, 5, {0} }, + {RSP_ZVLS, 724, 724, 17, 750, 50, {ACT_ACCEPTED} }, + {RSP_ERROR, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} }, + {EV_TIMEOUT, 721, 729, -1, 0, 0, {ACT_ABORTACCEPT} }, + {RSP_ZSAU, 700, 729, ZSAU_NULL, 0, 0, {ACT_ABORTACCEPT} }, + {RSP_ZSAU, 700, 729, ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT} }, + {RSP_ZSAU, 700, 729, ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT} }, + + {EV_BC_OPEN, 750, 750, -1, 751, -1}, + {EV_TIMEOUT, 750, 751, -1, 0, 0, {ACT_CONNTIMEOUT} }, /* B channel closed (general case) */ -{EV_BC_CLOSED, -1, -1, -1, -1, -1, {ACT_NOTIFY_BC_DOWN} }, + {EV_BC_CLOSED, -1, -1, -1, -1, -1, {ACT_NOTIFY_BC_DOWN} }, /* misc. */ -{RSP_ZCON, -1, -1, -1, -1, -1, {ACT_DEBUG} }, -{RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} }, -{RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} }, -{RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} }, -{RSP_LAST} + {RSP_ZCON, -1, -1, -1, -1, -1, {ACT_DEBUG} }, + {RSP_ZCAU, -1, -1, -1, -1, -1, {ACT_ZCAU} }, + {RSP_NONE, -1, -1, -1, -1, -1, {ACT_DEBUG} }, + {RSP_ANY, -1, -1, -1, -1, -1, {ACT_WARN} }, + {RSP_LAST} }; @@ -453,7 +453,7 @@ void gigaset_handle_modem_response(struct cardstate *cs) case '=': if (params > MAX_REC_PARAMS) { dev_warn(cs->dev, - "too many parameters in response\n"); + "too many parameters in response\n"); /* need last parameter (might be CID) */ params--; } @@ -461,7 +461,7 @@ void gigaset_handle_modem_response(struct cardstate *cs) } rawstring = 0; - cid = params > 1 ? cid_of_response(argv[params-1]) : 0; + cid = params > 1 ? cid_of_response(argv[params - 1]) : 0; if (cid < 0) { gigaset_add_event(cs, &cs->at_state, RSP_INVAL, NULL, 0, NULL); @@ -550,7 +550,7 @@ void gigaset_handle_modem_response(struct cardstate *cs) event->parameter = zr->code; if (!zr->str) dev_warn(cs->dev, - "%s: unknown parameter %s after ZSAU\n", + "%s: unknown parameter %s after ZSAU\n", __func__, argv[curarg]); ++curarg; break; @@ -648,8 +648,8 @@ static void disconnect(struct at_state_t **at_state_p) static inline struct at_state_t *get_free_channel(struct cardstate *cs, int cid) /* cids: >0: siemens-cid - 0: without cid - -1: no cid assigned yet + 0: without cid + -1: no cid assigned yet */ { unsigned long flags; @@ -722,12 +722,12 @@ static void send_command(struct cardstate *cs, const char *cmd, int cid, } if (cid > 0 && cid <= 65535) cb->len = snprintf(cb->buf, buflen, - dle ? "\020(AT%d%s\020)" : "AT%d%s", - cid, cmd); + dle ? "\020(AT%d%s\020)" : "AT%d%s", + cid, cmd); else cb->len = snprintf(cb->buf, buflen, - dle ? "\020(AT%s\020)" : "AT%s", - cmd); + dle ? "\020(AT%s\020)" : "AT%s", + cmd); cb->offset = 0; cb->next = NULL; cb->wake_tasklet = NULL; @@ -790,7 +790,7 @@ static void bchannel_up(struct bc_state *bcs) } static void start_dial(struct at_state_t *at_state, void *data, - unsigned seq_index) + unsigned seq_index) { struct bc_state *bcs = at_state->bcs; struct cardstate *cs = at_state->cs; @@ -937,10 +937,10 @@ static int reinit_and_retry(struct cardstate *cs, int channel) if (channel < 0) dev_warn(cs->dev, - "Could not enter cid mode. Reinit device and try again.\n"); + "Could not enter cid mode. Reinit device and try again.\n"); else { dev_warn(cs->dev, - "Could not get a call id. Reinit device and try again.\n"); + "Could not get a call id. Reinit device and try again.\n"); cs->bcs[channel].at_state.pending_commands |= PC_CID; } schedule_init(cs, MS_INIT); @@ -1155,7 +1155,7 @@ static void do_action(int action, struct cardstate *cs, at_state2 = get_free_channel(cs, ev->parameter); if (!at_state2) { dev_warn(cs->dev, - "RING ignored: could not allocate channel structure\n"); + "RING ignored: could not allocate channel structure\n"); break; } @@ -1372,7 +1372,7 @@ static void do_action(int action, struct cardstate *cs, ev->parameter, at_state->ConState); break; - /* events from the LL */ + /* events from the LL */ case ACT_DIAL: start_dial(at_state, ev->ptr, ev->parameter); break; @@ -1385,7 +1385,7 @@ static void do_action(int action, struct cardstate *cs, cs->commands_pending = 1; break; - /* hotplug events */ + /* hotplug events */ case ACT_STOP: do_stop(cs); break; @@ -1393,7 +1393,7 @@ static void do_action(int action, struct cardstate *cs, do_start(cs); break; - /* events from the interface */ + /* events from the interface */ case ACT_IF_LOCK: cs->cmd_result = ev->parameter ? do_lock(cs) : do_unlock(cs); cs->waiting = 0; @@ -1412,7 +1412,7 @@ static void do_action(int action, struct cardstate *cs, wake_up(&cs->waitqueue); break; - /* events from the proc file system */ + /* events from the proc file system */ case ACT_PROC_CIDMODE: spin_lock_irqsave(&cs->lock, flags); if (ev->parameter != cs->cidmode) { @@ -1431,7 +1431,7 @@ static void do_action(int action, struct cardstate *cs, wake_up(&cs->waitqueue); break; - /* events from the hardware drivers */ + /* events from the hardware drivers */ case ACT_NOTIFY_BC_DOWN: bchannel_down(bcs); break; @@ -1533,15 +1533,15 @@ static void process_event(struct cardstate *cs, struct event_t *ev) if (rcode == RSP_LAST) { /* found nothing...*/ dev_warn(cs->dev, "%s: rcode=RSP_LAST: " - "resp_code %d in ConState %d!\n", + "resp_code %d in ConState %d!\n", __func__, ev->type, at_state->ConState); return; } if ((rcode == RSP_ANY || rcode == ev->type) - && ((int) at_state->ConState >= rep->min_ConState) - && (rep->max_ConState < 0 - || (int) at_state->ConState <= rep->max_ConState) - && (rep->parameter < 0 || rep->parameter == ev->parameter)) + && ((int) at_state->ConState >= rep->min_ConState) + && (rep->max_ConState < 0 + || (int) at_state->ConState <= rep->max_ConState) + && (rep->parameter < 0 || rep->parameter == ev->parameter)) break; } diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index 212efaf9a4e4..8fad99e5dbd4 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h @@ -91,11 +91,11 @@ enum debuglevel { #ifdef CONFIG_GIGASET_DEBUG -#define gig_dbg(level, format, arg...) \ - do { \ +#define gig_dbg(level, format, arg...) \ + do { \ if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \ - ## arg); \ + ## arg); \ } while (0) #define DEBUG_DEFAULT (DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) @@ -164,7 +164,7 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, #define BAS_CORRFRAMES 4 /* flow control multiplicator */ #define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) - /* size of isoc in buf per URB */ +/* size of isoc in buf per URB */ #define BAS_OUTBUFSIZE 4096 /* size of common isoc out buffer */ #define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isoc out buf */ @@ -473,17 +473,17 @@ struct cardstate { int commands_pending; /* flag(s) in xxx.commands_pending have been set */ struct tasklet_struct event_tasklet; - /* tasklet for serializing AT commands. - * Scheduled - * -> for modem reponses (and - * incoming data for M10x) - * -> on timeout - * -> after setting bits in - * xxx.at_state.pending_command - * (e.g. command from LL) */ + /* tasklet for serializing AT commands. + * Scheduled + * -> for modem reponses (and + * incoming data for M10x) + * -> on timeout + * -> after setting bits in + * xxx.at_state.pending_command + * (e.g. command from LL) */ struct tasklet_struct write_tasklet; - /* tasklet for serial output - * (not used in base driver) */ + /* tasklet for serial output + * (not used in base driver) */ /* event queue */ struct event_t events[MAX_EVENTS]; @@ -491,7 +491,7 @@ struct cardstate { spinlock_t ev_lock; /* current modem response */ - unsigned char respdata[MAX_RESP_SIZE+1]; + unsigned char respdata[MAX_RESP_SIZE + 1]; unsigned cbytes; /* private data of hardware drivers */ diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c index 1793ba1b6a89..0f13eb1de657 100644 --- a/drivers/isdn/gigaset/i4l.c +++ b/drivers/isdn/gigaset/i4l.c @@ -243,7 +243,7 @@ static int command_from_LL(isdn_ctrl *cntrl) dev_kfree_skb(bcs->rx_skb); gigaset_new_rx_skb(bcs); - commands = kzalloc(AT_NUM*(sizeof *commands), GFP_ATOMIC); + commands = kzalloc(AT_NUM * (sizeof *commands), GFP_ATOMIC); if (!commands) { gigaset_free_channel(bcs); dev_err(cs->dev, "ISDN_CMD_DIAL: out of memory\n"); @@ -261,7 +261,7 @@ static int command_from_LL(isdn_ctrl *cntrl) if (!commands[AT_TYPE]) goto oom; snprintf(commands[AT_DIAL], l, - "D%s\r", cntrl->parm.setup.phone+2); + "D%s\r", cntrl->parm.setup.phone + 2); } else { commands[AT_TYPE] = kstrdup("^SCTP=1\r", GFP_ATOMIC); if (!commands[AT_TYPE]) @@ -482,7 +482,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state) response.parm.setup.si2 = 2; } else { dev_warn(cs->dev, "RING ignored - unsupported BC %s\n", - at_state->str_var[STR_ZBC]); + at_state->str_var[STR_ZBC]); return ICALL_IGNORE; } if (at_state->str_var[STR_NMBR]) { @@ -518,7 +518,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state) return ICALL_REJECT; case 3: /* incomplete */ dev_warn(cs->dev, - "LL requested unsupported feature: Incomplete Number\n"); + "LL requested unsupported feature: Incomplete Number\n"); return ICALL_IGNORE; case 4: /* proceeding */ /* Gigaset will send ALERTING anyway. diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index ee0a549a933a..da2486e59102 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -33,10 +33,10 @@ static int if_lock(struct cardstate *cs, int *arg) } if (!cmd && cs->mstate == MS_LOCKED && cs->connected) { - cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS); + cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR | TIOCM_RTS); cs->ops->baud_rate(cs, B115200); cs->ops->set_line_ctrl(cs, CS8); - cs->control_state = TIOCM_DTR|TIOCM_RTS; + cs->control_state = TIOCM_DTR | TIOCM_RTS; } cs->waiting = 1; @@ -252,17 +252,17 @@ static int if_ioctl(struct tty_struct *tty, break; case GIGASET_BRKCHARS: retval = copy_from_user(&buf, - (const unsigned char __user *) arg, 6) + (const unsigned char __user *) arg, 6) ? -EFAULT : 0; if (retval >= 0) { gigaset_dbg_buffer(DEBUG_IF, "GIGASET_BRKCHARS", - 6, (const unsigned char *) arg); + 6, (const unsigned char *) arg); retval = cs->ops->brkchars(cs, buf); } break; case GIGASET_VERSION: retval = copy_from_user(version, - (unsigned __user *) arg, sizeof version) + (unsigned __user *) arg, sizeof version) ? -EFAULT : 0; if (retval >= 0) retval = if_version(cs, version); @@ -299,7 +299,7 @@ static int if_tiocmget(struct tty_struct *tty) if (mutex_lock_interruptible(&cs->mutex)) return -ERESTARTSYS; - retval = cs->control_state & (TIOCM_RTS|TIOCM_DTR); + retval = cs->control_state & (TIOCM_RTS | TIOCM_DTR); mutex_unlock(&cs->mutex); @@ -329,7 +329,7 @@ static int if_tiocmset(struct tty_struct *tty, gig_dbg(DEBUG_IF, "not connected"); retval = -ENODEV; } else { - mc = (cs->control_state | set) & ~clear & (TIOCM_RTS|TIOCM_DTR); + mc = (cs->control_state | set) & ~clear & (TIOCM_RTS | TIOCM_DTR); retval = cs->ops->set_modem_ctrl(cs, cs->control_state, mc); cs->control_state = mc; } @@ -680,9 +680,9 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, goto enomem; tty->magic = TTY_DRIVER_MAGIC, - tty->type = TTY_DRIVER_TYPE_SERIAL, - tty->subtype = SERIAL_TYPE_NORMAL, - tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + tty->type = TTY_DRIVER_TYPE_SERIAL, + tty->subtype = SERIAL_TYPE_NORMAL, + tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; tty->driver_name = procname; tty->name = devname; diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c index f39ccdf87a17..a351c16705bd 100644 --- a/drivers/isdn/gigaset/isocdata.c +++ b/drivers/isdn/gigaset/isocdata.c @@ -250,94 +250,94 @@ static inline void dump_bytes(enum debuglevel level, const char *tag, */ static const u16 stufftab[5 * 256] = { /* previous 1s = 0: */ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, - 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x203e, 0x205f, - 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x209f, - 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x207c, 0x207d, 0x20be, 0x20df, - 0x0480, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487, 0x0488, 0x0489, 0x048a, 0x048b, 0x048c, 0x048d, 0x048e, 0x048f, - 0x0490, 0x0491, 0x0492, 0x0493, 0x0494, 0x0495, 0x0496, 0x0497, 0x0498, 0x0499, 0x049a, 0x049b, 0x049c, 0x049d, 0x049e, 0x251f, - 0x04a0, 0x04a1, 0x04a2, 0x04a3, 0x04a4, 0x04a5, 0x04a6, 0x04a7, 0x04a8, 0x04a9, 0x04aa, 0x04ab, 0x04ac, 0x04ad, 0x04ae, 0x04af, - 0x04b0, 0x04b1, 0x04b2, 0x04b3, 0x04b4, 0x04b5, 0x04b6, 0x04b7, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc, 0x04bd, 0x253e, 0x255f, - 0x08c0, 0x08c1, 0x08c2, 0x08c3, 0x08c4, 0x08c5, 0x08c6, 0x08c7, 0x08c8, 0x08c9, 0x08ca, 0x08cb, 0x08cc, 0x08cd, 0x08ce, 0x08cf, - 0x08d0, 0x08d1, 0x08d2, 0x08d3, 0x08d4, 0x08d5, 0x08d6, 0x08d7, 0x08d8, 0x08d9, 0x08da, 0x08db, 0x08dc, 0x08dd, 0x08de, 0x299f, - 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x0cef, - 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x2ddf, + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, + 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x201f, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x203e, 0x205f, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x209f, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x207c, 0x207d, 0x20be, 0x20df, + 0x0480, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487, 0x0488, 0x0489, 0x048a, 0x048b, 0x048c, 0x048d, 0x048e, 0x048f, + 0x0490, 0x0491, 0x0492, 0x0493, 0x0494, 0x0495, 0x0496, 0x0497, 0x0498, 0x0499, 0x049a, 0x049b, 0x049c, 0x049d, 0x049e, 0x251f, + 0x04a0, 0x04a1, 0x04a2, 0x04a3, 0x04a4, 0x04a5, 0x04a6, 0x04a7, 0x04a8, 0x04a9, 0x04aa, 0x04ab, 0x04ac, 0x04ad, 0x04ae, 0x04af, + 0x04b0, 0x04b1, 0x04b2, 0x04b3, 0x04b4, 0x04b5, 0x04b6, 0x04b7, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc, 0x04bd, 0x253e, 0x255f, + 0x08c0, 0x08c1, 0x08c2, 0x08c3, 0x08c4, 0x08c5, 0x08c6, 0x08c7, 0x08c8, 0x08c9, 0x08ca, 0x08cb, 0x08cc, 0x08cd, 0x08ce, 0x08cf, + 0x08d0, 0x08d1, 0x08d2, 0x08d3, 0x08d4, 0x08d5, 0x08d6, 0x08d7, 0x08d8, 0x08d9, 0x08da, 0x08db, 0x08dc, 0x08dd, 0x08de, 0x299f, + 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x0cef, + 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x2ddf, /* previous 1s = 1: */ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x200f, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x202f, - 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x204f, - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x203e, 0x206f, - 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x208f, - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x20af, - 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x20cf, - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x207c, 0x207d, 0x20be, 0x20ef, - 0x0480, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487, 0x0488, 0x0489, 0x048a, 0x048b, 0x048c, 0x048d, 0x048e, 0x250f, - 0x0490, 0x0491, 0x0492, 0x0493, 0x0494, 0x0495, 0x0496, 0x0497, 0x0498, 0x0499, 0x049a, 0x049b, 0x049c, 0x049d, 0x049e, 0x252f, - 0x04a0, 0x04a1, 0x04a2, 0x04a3, 0x04a4, 0x04a5, 0x04a6, 0x04a7, 0x04a8, 0x04a9, 0x04aa, 0x04ab, 0x04ac, 0x04ad, 0x04ae, 0x254f, - 0x04b0, 0x04b1, 0x04b2, 0x04b3, 0x04b4, 0x04b5, 0x04b6, 0x04b7, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc, 0x04bd, 0x253e, 0x256f, - 0x08c0, 0x08c1, 0x08c2, 0x08c3, 0x08c4, 0x08c5, 0x08c6, 0x08c7, 0x08c8, 0x08c9, 0x08ca, 0x08cb, 0x08cc, 0x08cd, 0x08ce, 0x298f, - 0x08d0, 0x08d1, 0x08d2, 0x08d3, 0x08d4, 0x08d5, 0x08d6, 0x08d7, 0x08d8, 0x08d9, 0x08da, 0x08db, 0x08dc, 0x08dd, 0x08de, 0x29af, - 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dcf, - 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x31ef, + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x200f, + 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x202f, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x204f, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x203e, 0x206f, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x208f, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x20af, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x20cf, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x207c, 0x207d, 0x20be, 0x20ef, + 0x0480, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x0487, 0x0488, 0x0489, 0x048a, 0x048b, 0x048c, 0x048d, 0x048e, 0x250f, + 0x0490, 0x0491, 0x0492, 0x0493, 0x0494, 0x0495, 0x0496, 0x0497, 0x0498, 0x0499, 0x049a, 0x049b, 0x049c, 0x049d, 0x049e, 0x252f, + 0x04a0, 0x04a1, 0x04a2, 0x04a3, 0x04a4, 0x04a5, 0x04a6, 0x04a7, 0x04a8, 0x04a9, 0x04aa, 0x04ab, 0x04ac, 0x04ad, 0x04ae, 0x254f, + 0x04b0, 0x04b1, 0x04b2, 0x04b3, 0x04b4, 0x04b5, 0x04b6, 0x04b7, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc, 0x04bd, 0x253e, 0x256f, + 0x08c0, 0x08c1, 0x08c2, 0x08c3, 0x08c4, 0x08c5, 0x08c6, 0x08c7, 0x08c8, 0x08c9, 0x08ca, 0x08cb, 0x08cc, 0x08cd, 0x08ce, 0x298f, + 0x08d0, 0x08d1, 0x08d2, 0x08d3, 0x08d4, 0x08d5, 0x08d6, 0x08d7, 0x08d8, 0x08d9, 0x08da, 0x08db, 0x08dc, 0x08dd, 0x08de, 0x29af, + 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dcf, + 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x10f7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x31ef, /* previous 1s = 2: */ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x2007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x2017, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x2027, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x2037, - 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x2047, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x2057, - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x2067, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x203e, 0x2077, - 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x2087, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x2097, - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x20a7, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x20b7, - 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x20c7, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x20d7, - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x20e7, 0x0078, 0x0079, 0x007a, 0x007b, 0x207c, 0x207d, 0x20be, 0x20f7, - 0x0480, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x2507, 0x0488, 0x0489, 0x048a, 0x048b, 0x048c, 0x048d, 0x048e, 0x2517, - 0x0490, 0x0491, 0x0492, 0x0493, 0x0494, 0x0495, 0x0496, 0x2527, 0x0498, 0x0499, 0x049a, 0x049b, 0x049c, 0x049d, 0x049e, 0x2537, - 0x04a0, 0x04a1, 0x04a2, 0x04a3, 0x04a4, 0x04a5, 0x04a6, 0x2547, 0x04a8, 0x04a9, 0x04aa, 0x04ab, 0x04ac, 0x04ad, 0x04ae, 0x2557, - 0x04b0, 0x04b1, 0x04b2, 0x04b3, 0x04b4, 0x04b5, 0x04b6, 0x2567, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc, 0x04bd, 0x253e, 0x2577, - 0x08c0, 0x08c1, 0x08c2, 0x08c3, 0x08c4, 0x08c5, 0x08c6, 0x2987, 0x08c8, 0x08c9, 0x08ca, 0x08cb, 0x08cc, 0x08cd, 0x08ce, 0x2997, - 0x08d0, 0x08d1, 0x08d2, 0x08d3, 0x08d4, 0x08d5, 0x08d6, 0x29a7, 0x08d8, 0x08d9, 0x08da, 0x08db, 0x08dc, 0x08dd, 0x08de, 0x29b7, - 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dc7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dd7, - 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x31e7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x41f7, + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x2007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x2017, + 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x2027, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x2037, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x2047, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x2057, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x2067, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x203e, 0x2077, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x2087, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x2097, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x20a7, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x20b7, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x20c7, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x20d7, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x20e7, 0x0078, 0x0079, 0x007a, 0x007b, 0x207c, 0x207d, 0x20be, 0x20f7, + 0x0480, 0x0481, 0x0482, 0x0483, 0x0484, 0x0485, 0x0486, 0x2507, 0x0488, 0x0489, 0x048a, 0x048b, 0x048c, 0x048d, 0x048e, 0x2517, + 0x0490, 0x0491, 0x0492, 0x0493, 0x0494, 0x0495, 0x0496, 0x2527, 0x0498, 0x0499, 0x049a, 0x049b, 0x049c, 0x049d, 0x049e, 0x2537, + 0x04a0, 0x04a1, 0x04a2, 0x04a3, 0x04a4, 0x04a5, 0x04a6, 0x2547, 0x04a8, 0x04a9, 0x04aa, 0x04ab, 0x04ac, 0x04ad, 0x04ae, 0x2557, + 0x04b0, 0x04b1, 0x04b2, 0x04b3, 0x04b4, 0x04b5, 0x04b6, 0x2567, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc, 0x04bd, 0x253e, 0x2577, + 0x08c0, 0x08c1, 0x08c2, 0x08c3, 0x08c4, 0x08c5, 0x08c6, 0x2987, 0x08c8, 0x08c9, 0x08ca, 0x08cb, 0x08cc, 0x08cd, 0x08ce, 0x2997, + 0x08d0, 0x08d1, 0x08d2, 0x08d3, 0x08d4, 0x08d5, 0x08d6, 0x29a7, 0x08d8, 0x08d9, 0x08da, 0x08db, 0x08dc, 0x08dd, 0x08de, 0x29b7, + 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dc7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced, 0x0cee, 0x2dd7, + 0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6, 0x31e7, 0x20f8, 0x20f9, 0x20fa, 0x20fb, 0x257c, 0x257d, 0x29be, 0x41f7, /* previous 1s = 3: */ - 0x0000, 0x0001, 0x0002, 0x2003, 0x0004, 0x0005, 0x0006, 0x200b, 0x0008, 0x0009, 0x000a, 0x2013, 0x000c, 0x000d, 0x000e, 0x201b, - 0x0010, 0x0011, 0x0012, 0x2023, 0x0014, 0x0015, 0x0016, 0x202b, 0x0018, 0x0019, 0x001a, 0x2033, 0x001c, 0x001d, 0x001e, 0x203b, - 0x0020, 0x0021, 0x0022, 0x2043, 0x0024, 0x0025, 0x0026, 0x204b, 0x0028, 0x0029, 0x002a, 0x2053, 0x002c, 0x002d, 0x002e, 0x205b, - 0x0030, 0x0031, 0x0032, 0x2063, 0x0034, 0x0035, 0x0036, 0x206b, 0x0038, 0x0039, 0x003a, 0x2073, 0x003c, 0x003d, 0x203e, 0x207b, - 0x0040, 0x0041, 0x0042, 0x2083, 0x0044, 0x0045, 0x0046, 0x208b, 0x0048, 0x0049, 0x004a, 0x2093, 0x004c, 0x004d, 0x004e, 0x209b, - 0x0050, 0x0051, 0x0052, 0x20a3, 0x0054, 0x0055, 0x0056, 0x20ab, 0x0058, 0x0059, 0x005a, 0x20b3, 0x005c, 0x005d, 0x005e, 0x20bb, - 0x0060, 0x0061, 0x0062, 0x20c3, 0x0064, 0x0065, 0x0066, 0x20cb, 0x0068, 0x0069, 0x006a, 0x20d3, 0x006c, 0x006d, 0x006e, 0x20db, - 0x0070, 0x0071, 0x0072, 0x20e3, 0x0074, 0x0075, 0x0076, 0x20eb, 0x0078, 0x0079, 0x007a, 0x20f3, 0x207c, 0x207d, 0x20be, 0x40fb, - 0x0480, 0x0481, 0x0482, 0x2503, 0x0484, 0x0485, 0x0486, 0x250b, 0x0488, 0x0489, 0x048a, 0x2513, 0x048c, 0x048d, 0x048e, 0x251b, - 0x0490, 0x0491, 0x0492, 0x2523, 0x0494, 0x0495, 0x0496, 0x252b, 0x0498, 0x0499, 0x049a, 0x2533, 0x049c, 0x049d, 0x049e, 0x253b, - 0x04a0, 0x04a1, 0x04a2, 0x2543, 0x04a4, 0x04a5, 0x04a6, 0x254b, 0x04a8, 0x04a9, 0x04aa, 0x2553, 0x04ac, 0x04ad, 0x04ae, 0x255b, - 0x04b0, 0x04b1, 0x04b2, 0x2563, 0x04b4, 0x04b5, 0x04b6, 0x256b, 0x04b8, 0x04b9, 0x04ba, 0x2573, 0x04bc, 0x04bd, 0x253e, 0x257b, - 0x08c0, 0x08c1, 0x08c2, 0x2983, 0x08c4, 0x08c5, 0x08c6, 0x298b, 0x08c8, 0x08c9, 0x08ca, 0x2993, 0x08cc, 0x08cd, 0x08ce, 0x299b, - 0x08d0, 0x08d1, 0x08d2, 0x29a3, 0x08d4, 0x08d5, 0x08d6, 0x29ab, 0x08d8, 0x08d9, 0x08da, 0x29b3, 0x08dc, 0x08dd, 0x08de, 0x29bb, - 0x0ce0, 0x0ce1, 0x0ce2, 0x2dc3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dcb, 0x0ce8, 0x0ce9, 0x0cea, 0x2dd3, 0x0cec, 0x0ced, 0x0cee, 0x2ddb, - 0x10f0, 0x10f1, 0x10f2, 0x31e3, 0x10f4, 0x10f5, 0x10f6, 0x31eb, 0x20f8, 0x20f9, 0x20fa, 0x41f3, 0x257c, 0x257d, 0x29be, 0x46fb, + 0x0000, 0x0001, 0x0002, 0x2003, 0x0004, 0x0005, 0x0006, 0x200b, 0x0008, 0x0009, 0x000a, 0x2013, 0x000c, 0x000d, 0x000e, 0x201b, + 0x0010, 0x0011, 0x0012, 0x2023, 0x0014, 0x0015, 0x0016, 0x202b, 0x0018, 0x0019, 0x001a, 0x2033, 0x001c, 0x001d, 0x001e, 0x203b, + 0x0020, 0x0021, 0x0022, 0x2043, 0x0024, 0x0025, 0x0026, 0x204b, 0x0028, 0x0029, 0x002a, 0x2053, 0x002c, 0x002d, 0x002e, 0x205b, + 0x0030, 0x0031, 0x0032, 0x2063, 0x0034, 0x0035, 0x0036, 0x206b, 0x0038, 0x0039, 0x003a, 0x2073, 0x003c, 0x003d, 0x203e, 0x207b, + 0x0040, 0x0041, 0x0042, 0x2083, 0x0044, 0x0045, 0x0046, 0x208b, 0x0048, 0x0049, 0x004a, 0x2093, 0x004c, 0x004d, 0x004e, 0x209b, + 0x0050, 0x0051, 0x0052, 0x20a3, 0x0054, 0x0055, 0x0056, 0x20ab, 0x0058, 0x0059, 0x005a, 0x20b3, 0x005c, 0x005d, 0x005e, 0x20bb, + 0x0060, 0x0061, 0x0062, 0x20c3, 0x0064, 0x0065, 0x0066, 0x20cb, 0x0068, 0x0069, 0x006a, 0x20d3, 0x006c, 0x006d, 0x006e, 0x20db, + 0x0070, 0x0071, 0x0072, 0x20e3, 0x0074, 0x0075, 0x0076, 0x20eb, 0x0078, 0x0079, 0x007a, 0x20f3, 0x207c, 0x207d, 0x20be, 0x40fb, + 0x0480, 0x0481, 0x0482, 0x2503, 0x0484, 0x0485, 0x0486, 0x250b, 0x0488, 0x0489, 0x048a, 0x2513, 0x048c, 0x048d, 0x048e, 0x251b, + 0x0490, 0x0491, 0x0492, 0x2523, 0x0494, 0x0495, 0x0496, 0x252b, 0x0498, 0x0499, 0x049a, 0x2533, 0x049c, 0x049d, 0x049e, 0x253b, + 0x04a0, 0x04a1, 0x04a2, 0x2543, 0x04a4, 0x04a5, 0x04a6, 0x254b, 0x04a8, 0x04a9, 0x04aa, 0x2553, 0x04ac, 0x04ad, 0x04ae, 0x255b, + 0x04b0, 0x04b1, 0x04b2, 0x2563, 0x04b4, 0x04b5, 0x04b6, 0x256b, 0x04b8, 0x04b9, 0x04ba, 0x2573, 0x04bc, 0x04bd, 0x253e, 0x257b, + 0x08c0, 0x08c1, 0x08c2, 0x2983, 0x08c4, 0x08c5, 0x08c6, 0x298b, 0x08c8, 0x08c9, 0x08ca, 0x2993, 0x08cc, 0x08cd, 0x08ce, 0x299b, + 0x08d0, 0x08d1, 0x08d2, 0x29a3, 0x08d4, 0x08d5, 0x08d6, 0x29ab, 0x08d8, 0x08d9, 0x08da, 0x29b3, 0x08dc, 0x08dd, 0x08de, 0x29bb, + 0x0ce0, 0x0ce1, 0x0ce2, 0x2dc3, 0x0ce4, 0x0ce5, 0x0ce6, 0x2dcb, 0x0ce8, 0x0ce9, 0x0cea, 0x2dd3, 0x0cec, 0x0ced, 0x0cee, 0x2ddb, + 0x10f0, 0x10f1, 0x10f2, 0x31e3, 0x10f4, 0x10f5, 0x10f6, 0x31eb, 0x20f8, 0x20f9, 0x20fa, 0x41f3, 0x257c, 0x257d, 0x29be, 0x46fb, /* previous 1s = 4: */ - 0x0000, 0x2001, 0x0002, 0x2005, 0x0004, 0x2009, 0x0006, 0x200d, 0x0008, 0x2011, 0x000a, 0x2015, 0x000c, 0x2019, 0x000e, 0x201d, - 0x0010, 0x2021, 0x0012, 0x2025, 0x0014, 0x2029, 0x0016, 0x202d, 0x0018, 0x2031, 0x001a, 0x2035, 0x001c, 0x2039, 0x001e, 0x203d, - 0x0020, 0x2041, 0x0022, 0x2045, 0x0024, 0x2049, 0x0026, 0x204d, 0x0028, 0x2051, 0x002a, 0x2055, 0x002c, 0x2059, 0x002e, 0x205d, - 0x0030, 0x2061, 0x0032, 0x2065, 0x0034, 0x2069, 0x0036, 0x206d, 0x0038, 0x2071, 0x003a, 0x2075, 0x003c, 0x2079, 0x203e, 0x407d, - 0x0040, 0x2081, 0x0042, 0x2085, 0x0044, 0x2089, 0x0046, 0x208d, 0x0048, 0x2091, 0x004a, 0x2095, 0x004c, 0x2099, 0x004e, 0x209d, - 0x0050, 0x20a1, 0x0052, 0x20a5, 0x0054, 0x20a9, 0x0056, 0x20ad, 0x0058, 0x20b1, 0x005a, 0x20b5, 0x005c, 0x20b9, 0x005e, 0x20bd, - 0x0060, 0x20c1, 0x0062, 0x20c5, 0x0064, 0x20c9, 0x0066, 0x20cd, 0x0068, 0x20d1, 0x006a, 0x20d5, 0x006c, 0x20d9, 0x006e, 0x20dd, - 0x0070, 0x20e1, 0x0072, 0x20e5, 0x0074, 0x20e9, 0x0076, 0x20ed, 0x0078, 0x20f1, 0x007a, 0x20f5, 0x207c, 0x40f9, 0x20be, 0x417d, - 0x0480, 0x2501, 0x0482, 0x2505, 0x0484, 0x2509, 0x0486, 0x250d, 0x0488, 0x2511, 0x048a, 0x2515, 0x048c, 0x2519, 0x048e, 0x251d, - 0x0490, 0x2521, 0x0492, 0x2525, 0x0494, 0x2529, 0x0496, 0x252d, 0x0498, 0x2531, 0x049a, 0x2535, 0x049c, 0x2539, 0x049e, 0x253d, - 0x04a0, 0x2541, 0x04a2, 0x2545, 0x04a4, 0x2549, 0x04a6, 0x254d, 0x04a8, 0x2551, 0x04aa, 0x2555, 0x04ac, 0x2559, 0x04ae, 0x255d, - 0x04b0, 0x2561, 0x04b2, 0x2565, 0x04b4, 0x2569, 0x04b6, 0x256d, 0x04b8, 0x2571, 0x04ba, 0x2575, 0x04bc, 0x2579, 0x253e, 0x467d, - 0x08c0, 0x2981, 0x08c2, 0x2985, 0x08c4, 0x2989, 0x08c6, 0x298d, 0x08c8, 0x2991, 0x08ca, 0x2995, 0x08cc, 0x2999, 0x08ce, 0x299d, - 0x08d0, 0x29a1, 0x08d2, 0x29a5, 0x08d4, 0x29a9, 0x08d6, 0x29ad, 0x08d8, 0x29b1, 0x08da, 0x29b5, 0x08dc, 0x29b9, 0x08de, 0x29bd, - 0x0ce0, 0x2dc1, 0x0ce2, 0x2dc5, 0x0ce4, 0x2dc9, 0x0ce6, 0x2dcd, 0x0ce8, 0x2dd1, 0x0cea, 0x2dd5, 0x0cec, 0x2dd9, 0x0cee, 0x2ddd, - 0x10f0, 0x31e1, 0x10f2, 0x31e5, 0x10f4, 0x31e9, 0x10f6, 0x31ed, 0x20f8, 0x41f1, 0x20fa, 0x41f5, 0x257c, 0x46f9, 0x29be, 0x4b7d + 0x0000, 0x2001, 0x0002, 0x2005, 0x0004, 0x2009, 0x0006, 0x200d, 0x0008, 0x2011, 0x000a, 0x2015, 0x000c, 0x2019, 0x000e, 0x201d, + 0x0010, 0x2021, 0x0012, 0x2025, 0x0014, 0x2029, 0x0016, 0x202d, 0x0018, 0x2031, 0x001a, 0x2035, 0x001c, 0x2039, 0x001e, 0x203d, + 0x0020, 0x2041, 0x0022, 0x2045, 0x0024, 0x2049, 0x0026, 0x204d, 0x0028, 0x2051, 0x002a, 0x2055, 0x002c, 0x2059, 0x002e, 0x205d, + 0x0030, 0x2061, 0x0032, 0x2065, 0x0034, 0x2069, 0x0036, 0x206d, 0x0038, 0x2071, 0x003a, 0x2075, 0x003c, 0x2079, 0x203e, 0x407d, + 0x0040, 0x2081, 0x0042, 0x2085, 0x0044, 0x2089, 0x0046, 0x208d, 0x0048, 0x2091, 0x004a, 0x2095, 0x004c, 0x2099, 0x004e, 0x209d, + 0x0050, 0x20a1, 0x0052, 0x20a5, 0x0054, 0x20a9, 0x0056, 0x20ad, 0x0058, 0x20b1, 0x005a, 0x20b5, 0x005c, 0x20b9, 0x005e, 0x20bd, + 0x0060, 0x20c1, 0x0062, 0x20c5, 0x0064, 0x20c9, 0x0066, 0x20cd, 0x0068, 0x20d1, 0x006a, 0x20d5, 0x006c, 0x20d9, 0x006e, 0x20dd, + 0x0070, 0x20e1, 0x0072, 0x20e5, 0x0074, 0x20e9, 0x0076, 0x20ed, 0x0078, 0x20f1, 0x007a, 0x20f5, 0x207c, 0x40f9, 0x20be, 0x417d, + 0x0480, 0x2501, 0x0482, 0x2505, 0x0484, 0x2509, 0x0486, 0x250d, 0x0488, 0x2511, 0x048a, 0x2515, 0x048c, 0x2519, 0x048e, 0x251d, + 0x0490, 0x2521, 0x0492, 0x2525, 0x0494, 0x2529, 0x0496, 0x252d, 0x0498, 0x2531, 0x049a, 0x2535, 0x049c, 0x2539, 0x049e, 0x253d, + 0x04a0, 0x2541, 0x04a2, 0x2545, 0x04a4, 0x2549, 0x04a6, 0x254d, 0x04a8, 0x2551, 0x04aa, 0x2555, 0x04ac, 0x2559, 0x04ae, 0x255d, + 0x04b0, 0x2561, 0x04b2, 0x2565, 0x04b4, 0x2569, 0x04b6, 0x256d, 0x04b8, 0x2571, 0x04ba, 0x2575, 0x04bc, 0x2579, 0x253e, 0x467d, + 0x08c0, 0x2981, 0x08c2, 0x2985, 0x08c4, 0x2989, 0x08c6, 0x298d, 0x08c8, 0x2991, 0x08ca, 0x2995, 0x08cc, 0x2999, 0x08ce, 0x299d, + 0x08d0, 0x29a1, 0x08d2, 0x29a5, 0x08d4, 0x29a9, 0x08d6, 0x29ad, 0x08d8, 0x29b1, 0x08da, 0x29b5, 0x08dc, 0x29b9, 0x08de, 0x29bd, + 0x0ce0, 0x2dc1, 0x0ce2, 0x2dc5, 0x0ce4, 0x2dc9, 0x0ce6, 0x2dcd, 0x0ce8, 0x2dd1, 0x0cea, 0x2dd5, 0x0cec, 0x2dd9, 0x0cee, 0x2ddd, + 0x10f0, 0x31e1, 0x10f2, 0x31e5, 0x10f4, 0x31e9, 0x10f6, 0x31ed, 0x20f8, 0x41f1, 0x20fa, 0x41f5, 0x257c, 0x46f9, 0x29be, 0x4b7d }; /* hdlc_bitstuff_byte @@ -598,22 +598,22 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits) * bit 7 set if there are 5 or more "interior" consecutive '1' bits */ static const unsigned char bitcounts[256] = { - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x80, 0x06, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, - 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x80, 0x81, 0x80, 0x07, - 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x14, - 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x15, - 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x14, - 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x90, 0x16, - 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x23, 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x24, - 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x23, 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x25, - 0x30, 0x31, 0x30, 0x32, 0x30, 0x31, 0x30, 0x33, 0x30, 0x31, 0x30, 0x32, 0x30, 0x31, 0x30, 0x34, - 0x40, 0x41, 0x40, 0x42, 0x40, 0x41, 0x40, 0x43, 0x50, 0x51, 0x50, 0x52, 0x60, 0x61, 0x70, 0x78 + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x80, 0x06, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, + 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x80, 0x81, 0x80, 0x07, + 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x14, + 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x15, + 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x14, + 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x10, 0x13, 0x10, 0x11, 0x10, 0x12, 0x10, 0x11, 0x90, 0x16, + 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x23, 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x24, + 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x23, 0x20, 0x21, 0x20, 0x22, 0x20, 0x21, 0x20, 0x25, + 0x30, 0x31, 0x30, 0x32, 0x30, 0x31, 0x30, 0x33, 0x30, 0x31, 0x30, 0x32, 0x30, 0x31, 0x30, 0x34, + 0x40, 0x41, 0x40, 0x42, 0x40, 0x41, 0x40, 0x43, 0x50, 0x51, 0x50, 0x52, 0x60, 0x61, 0x70, 0x78 }; /* hdlc_unpack diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c index b943efbff44d..e3f9d0f089fa 100644 --- a/drivers/isdn/gigaset/proc.c +++ b/drivers/isdn/gigaset/proc.c @@ -35,7 +35,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, if (!isspace(*end++)) return -EINVAL; if (value < 0 || value > 1) - return -EINVAL; + return -EINVAL; if (mutex_lock_interruptible(&cs->mutex)) return -ERESTARTSYS; @@ -56,7 +56,7 @@ static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr, return count; } -static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); +static DEVICE_ATTR(cidmode, S_IRUGO | S_IWUSR, show_cidmode, set_cidmode); /* free sysfs for device */ void gigaset_free_dev_sysfs(struct cardstate *cs) diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c index 86a5c4f7775e..6f3fd4cf4378 100644 --- a/drivers/isdn/gigaset/ser-gigaset.c +++ b/drivers/isdn/gigaset/ser-gigaset.c @@ -246,7 +246,7 @@ static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb) unsigned long flags; gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? - DEBUG_TRANSCMD : DEBUG_LOCKCMD, + DEBUG_TRANSCMD : DEBUG_LOCKCMD, "CMD Transmit", cb->len, cb->buf); spin_lock_irqsave(&cs->cmdlock, flags); @@ -773,8 +773,8 @@ static int __init ser_gigaset_init(void) /* allocate memory for our driver state and initialize it */ driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, - GIGASET_MODULENAME, GIGASET_DEVNAME, - &ops, THIS_MODULE); + GIGASET_MODULENAME, GIGASET_DEVNAME, + &ops, THIS_MODULE); if (!driver) goto error; diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c index 5e3300d8a2a5..049da67f6392 100644 --- a/drivers/isdn/gigaset/usb-gigaset.c +++ b/drivers/isdn/gigaset/usb-gigaset.c @@ -184,7 +184,7 @@ static int set_value(struct cardstate *cs, u8 req, u16 val) (unsigned)req, (unsigned)val); r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x12, 0x41, 0xf /*?*/, 0, NULL, 0, 2000 /*?*/); - /* no idea what this does */ + /* no idea what this does */ if (r < 0) { dev_err(&udev->dev, "error %d on request 0x12\n", -r); return r; @@ -365,7 +365,7 @@ static void gigaset_read_int_callback(struct urb *urb) src = cs->hw.usb->rcvbuf; if (unlikely(*src)) dev_warn(cs->dev, - "%s: There was no leading 0, but 0x%02x!\n", + "%s: There was no leading 0, but 0x%02x!\n", __func__, (unsigned) *src); ++src; /* skip leading 0x00 */ --numbytes; @@ -465,7 +465,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb) usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev, usb_sndbulkpipe(ucs->udev, - ucs->bulk_out_endpointAddr & 0x0f), + ucs->bulk_out_endpointAddr & 0x0f), cb->buf + cb->offset, count, gigaset_write_bulk_callback, cs); @@ -499,7 +499,7 @@ static int gigaset_write_cmd(struct cardstate *cs, struct cmdbuf_t *cb) unsigned long flags; gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? - DEBUG_TRANSCMD : DEBUG_LOCKCMD, + DEBUG_TRANSCMD : DEBUG_LOCKCMD, "CMD Transmit", cb->len, cb->buf); spin_lock_irqsave(&cs->cmdlock, flags); diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index 61f516f376dc..44b50cc645e6 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -44,12 +44,12 @@ static void avmcs_detach(struct pcmcia_device *p_dev); static int avmcs_probe(struct pcmcia_device *p_dev) { - /* General socket configuration */ - p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - p_dev->config_index = 1; - p_dev->config_regs = PRESENT_OPTION; + /* General socket configuration */ + p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; + p_dev->config_index = 1; + p_dev->config_regs = PRESENT_OPTION; - return avmcs_config(p_dev); + return avmcs_config(p_dev); } /* avmcs_attach */ @@ -69,75 +69,75 @@ static int avmcs_configcheck(struct pcmcia_device *p_dev, void *priv_data) static int avmcs_config(struct pcmcia_device *link) { - int i = -1; - char devname[128]; - int cardtype; - int (*addcard)(unsigned int port, unsigned irq); - - devname[0] = 0; - if (link->prod_id[1]) - strlcpy(devname, link->prod_id[1], sizeof(devname)); - - /* - * find IO port - */ - if (pcmcia_loop_config(link, avmcs_configcheck, NULL)) - return -ENODEV; - - do { - if (!link->irq) { - /* undo */ - pcmcia_disable_device(link); - break; - } + int i = -1; + char devname[128]; + int cardtype; + int (*addcard)(unsigned int port, unsigned irq); + + devname[0] = 0; + if (link->prod_id[1]) + strlcpy(devname, link->prod_id[1], sizeof(devname)); /* - * configure the PCMCIA socket - */ - i = pcmcia_enable_device(link); + * find IO port + */ + if (pcmcia_loop_config(link, avmcs_configcheck, NULL)) + return -ENODEV; + + do { + if (!link->irq) { + /* undo */ + pcmcia_disable_device(link); + break; + } + + /* + * configure the PCMCIA socket + */ + i = pcmcia_enable_device(link); + if (i != 0) { + pcmcia_disable_device(link); + break; + } + + } while (0); + + if (devname[0]) { + char *s = strrchr(devname, ' '); + if (!s) + s = devname; + else s++; + if (strcmp("M1", s) == 0) { + cardtype = AVM_CARDTYPE_M1; + } else if (strcmp("M2", s) == 0) { + cardtype = AVM_CARDTYPE_M2; + } else { + cardtype = AVM_CARDTYPE_B1; + } + } else + cardtype = AVM_CARDTYPE_B1; + + /* If any step failed, release any partially configured state */ if (i != 0) { - pcmcia_disable_device(link); - break; - } - - } while (0); - - if (devname[0]) { - char *s = strrchr(devname, ' '); - if (!s) - s = devname; - else s++; - if (strcmp("M1", s) == 0) { - cardtype = AVM_CARDTYPE_M1; - } else if (strcmp("M2", s) == 0) { - cardtype = AVM_CARDTYPE_M2; - } else { - cardtype = AVM_CARDTYPE_B1; + avmcs_release(link); + return -ENODEV; } - } else - cardtype = AVM_CARDTYPE_B1; - - /* If any step failed, release any partially configured state */ - if (i != 0) { - avmcs_release(link); - return -ENODEV; - } - switch (cardtype) { - case AVM_CARDTYPE_M1: addcard = b1pcmcia_addcard_m1; break; - case AVM_CARDTYPE_M2: addcard = b1pcmcia_addcard_m2; break; + switch (cardtype) { + case AVM_CARDTYPE_M1: addcard = b1pcmcia_addcard_m1; break; + case AVM_CARDTYPE_M2: addcard = b1pcmcia_addcard_m2; break; default: - case AVM_CARDTYPE_B1: addcard = b1pcmcia_addcard_b1; break; - } - if ((i = (*addcard)(link->resource[0]->start, link->irq)) < 0) { - dev_err(&link->dev, - "avm_cs: failed to add AVM-Controller at i/o %#x, irq %d\n", - (unsigned int) link->resource[0]->start, link->irq); - avmcs_release(link); - return -ENODEV; - } - return 0; + case AVM_CARDTYPE_B1: addcard = b1pcmcia_addcard_b1; break; + } + if ((i = (*addcard)(link->resource[0]->start, link->irq)) < 0) { + dev_err(&link->dev, + "avm_cs: failed to add AVM-Controller at i/o %#x, irq %d\n", + (unsigned int) link->resource[0]->start, link->irq); + avmcs_release(link); + return -ENODEV; + } + return 0; } /* avmcs_config */ diff --git a/drivers/isdn/hardware/avm/avmcard.h b/drivers/isdn/hardware/avm/avmcard.h index a70e8854461d..c95712dbfa9f 100644 --- a/drivers/isdn/hardware/avm/avmcard.h +++ b/drivers/isdn/hardware/avm/avmcard.h @@ -44,16 +44,16 @@ enum avmcardtype { }; typedef struct avmcard_dmabuf { - long size; - u8 *dmabuf; - dma_addr_t dmaaddr; + long size; + u8 *dmabuf; + dma_addr_t dmaaddr; } avmcard_dmabuf; typedef struct avmcard_dmainfo { u32 recvlen; - avmcard_dmabuf recvbuf; + avmcard_dmabuf recvbuf; - avmcard_dmabuf sendbuf; + avmcard_dmabuf sendbuf; struct sk_buff_head send_queue; struct pci_dev *pcidev; @@ -61,22 +61,22 @@ typedef struct avmcard_dmainfo { typedef struct avmctrl_info { char cardname[32]; - + int versionlen; char versionbuf[1024]; char *version[AVM_MAXVERSION]; - + char infobuf[128]; /* for function procinfo */ - + struct avmcard *card; struct capi_ctr capi_ctrl; - + struct list_head ncci_head; } avmctrl_info; typedef struct avmcard { char name[32]; - + spinlock_t lock; unsigned int port; unsigned irq; @@ -103,95 +103,95 @@ typedef struct avmcard { extern int b1_irq_table[16]; /* - * LLI Messages to the ISDN-ControllerISDN Controller + * LLI Messages to the ISDN-ControllerISDN Controller */ #define SEND_POLL 0x72 /* - * after load <- RECEIVE_POLL + * after load <- RECEIVE_POLL */ #define SEND_INIT 0x11 /* - * first message <- RECEIVE_INIT - * int32 NumApplications int32 - * NumNCCIs int32 BoardNumber + * first message <- RECEIVE_INIT + * int32 NumApplications int32 + * NumNCCIs int32 BoardNumber */ #define SEND_REGISTER 0x12 /* - * register an application int32 - * ApplIDId int32 NumMessages - * int32 NumB3Connections int32 - * NumB3Blocks int32 B3Size - * - * AnzB3Connection != 0 && - * AnzB3Blocks >= 1 && B3Size >= 1 + * register an application int32 + * ApplIDId int32 NumMessages + * int32 NumB3Connections int32 + * NumB3Blocks int32 B3Size + * + * AnzB3Connection != 0 && + * AnzB3Blocks >= 1 && B3Size >= 1 */ #define SEND_RELEASE 0x14 /* - * deregister an application int32 - * ApplID + * deregister an application int32 + * ApplID */ #define SEND_MESSAGE 0x15 /* - * send capi-message int32 length - * capi-data ... + * send capi-message int32 length + * capi-data ... */ #define SEND_DATA_B3_REQ 0x13 /* - * send capi-data-message int32 - * MsgLength capi-data ... int32 - * B3Length data .... + * send capi-data-message int32 + * MsgLength capi-data ... int32 + * B3Length data .... */ #define SEND_CONFIG 0x21 /* - */ + */ #define SEND_POLLACK 0x73 /* T1 Watchdog */ /* - * LLI Messages from the ISDN-ControllerISDN Controller + * LLI Messages from the ISDN-ControllerISDN Controller */ #define RECEIVE_POLL 0x32 /* - * <- after SEND_POLL + * <- after SEND_POLL */ #define RECEIVE_INIT 0x27 /* - * <- after SEND_INIT int32 length - * byte total length b1struct board - * driver revision b1struct card - * type b1struct reserved b1struct - * serial number b1struct driver - * capability b1struct d-channel - * protocol b1struct CAPI-2.0 - * profile b1struct capi version + * <- after SEND_INIT int32 length + * byte total length b1struct board + * driver revision b1struct card + * type b1struct reserved b1struct + * serial number b1struct driver + * capability b1struct d-channel + * protocol b1struct CAPI-2.0 + * profile b1struct capi version */ #define RECEIVE_MESSAGE 0x21 /* - * <- after SEND_MESSAGE int32 - * AppllID int32 Length capi-data - * .... + * <- after SEND_MESSAGE int32 + * AppllID int32 Length capi-data + * .... */ #define RECEIVE_DATA_B3_IND 0x22 /* - * received data int32 AppllID - * int32 Length capi-data ... - * int32 B3Length data ... + * received data int32 AppllID + * int32 Length capi-data ... + * int32 B3Length data ... */ #define RECEIVE_START 0x23 /* - * Handshake + * Handshake */ #define RECEIVE_STOP 0x24 /* - * Handshake + * Handshake */ #define RECEIVE_NEW_NCCI 0x25 /* - * int32 AppllID int32 NCCI int32 - * WindowSize + * int32 AppllID int32 NCCI int32 + * WindowSize */ #define RECEIVE_FREE_NCCI 0x26 /* - * int32 AppllID int32 NCCI + * int32 AppllID int32 NCCI */ #define RECEIVE_RELEASE 0x26 /* - * int32 AppllID int32 0xffffffff + * int32 AppllID int32 0xffffffff */ #define RECEIVE_TASK_READY 0x31 /* - * int32 tasknr - * int32 Length Taskname ... + * int32 tasknr + * int32 Length Taskname ... */ #define RECEIVE_DEBUGMSG 0x71 /* - * int32 Length message - * + * int32 Length message + * */ #define RECEIVE_POLLDWORD 0x75 /* t1pci in dword mode */ @@ -264,7 +264,7 @@ static inline void b1_put_byte(unsigned int base, unsigned char val) static inline int b1_save_put_byte(unsigned int base, unsigned char val) { unsigned long stop = jiffies + 2 * HZ; - while (!b1_tx_empty(base) && time_before(jiffies,stop)); + while (!b1_tx_empty(base) && time_before(jiffies, stop)); if (!b1_tx_empty(base)) return -1; b1outp(base, B1_WRITE, val); return 0; @@ -298,21 +298,21 @@ static inline void b1_put_slice(unsigned int base, } static void b1_wr_reg(unsigned int base, - unsigned int reg, + unsigned int reg, unsigned int value) { b1_put_byte(base, WRITE_REGISTER); - b1_put_word(base, reg); - b1_put_word(base, value); + b1_put_word(base, reg); + b1_put_word(base, value); } static inline unsigned int b1_rd_reg(unsigned int base, - unsigned int reg) + unsigned int reg) { b1_put_byte(base, READ_REGISTER); - b1_put_word(base, reg); - return b1_get_word(base); - + b1_put_word(base, reg); + return b1_get_word(base); + } static inline void b1_reset(unsigned int base) @@ -338,13 +338,13 @@ static inline void b1_set_test_bit(unsigned int base, enum avmcardtype cardtype, int onoff) { - b1_wr_reg(base, B1_STAT0(cardtype), onoff ? 0x21 : 0x20); + b1_wr_reg(base, B1_STAT0(cardtype), onoff ? 0x21 : 0x20); } static inline int b1_get_test_bit(unsigned int base, - enum avmcardtype cardtype) + enum avmcardtype cardtype) { - return (b1_rd_reg(base, B1_STAT0(cardtype)) & 0x01) != 0; + return (b1_rd_reg(base, B1_STAT0(cardtype)) & 0x01) != 0; } /* ---------------------------------------------------------------- */ @@ -391,7 +391,7 @@ static inline void t1outp(unsigned int base, } static inline unsigned char t1inp(unsigned int base, - unsigned short offset) + unsigned short offset) { return inb(base + offset); } @@ -415,42 +415,42 @@ static inline unsigned int t1_get_slice(unsigned int base, #endif len = i = b1_get_word(base); - if (t1_isfastlink(base)) { + if (t1_isfastlink(base)) { int status; while (i > 0) { - status = t1_fifostatus(base) & (T1F_IREADY|T1F_IHALF); + status = t1_fifostatus(base) & (T1F_IREADY | T1F_IHALF); if (i >= FIFO_INPBSIZE) status |= T1F_IFULL; switch (status) { - case T1F_IREADY|T1F_IHALF|T1F_IFULL: - insb(base+B1_READ, dp, FIFO_INPBSIZE); - dp += FIFO_INPBSIZE; - i -= FIFO_INPBSIZE; + case T1F_IREADY | T1F_IHALF | T1F_IFULL: + insb(base + B1_READ, dp, FIFO_INPBSIZE); + dp += FIFO_INPBSIZE; + i -= FIFO_INPBSIZE; #ifdef FASTLINK_DEBUG - wcnt += FIFO_INPBSIZE; + wcnt += FIFO_INPBSIZE; #endif - break; - case T1F_IREADY|T1F_IHALF: - insb(base+B1_READ,dp, i); + break; + case T1F_IREADY | T1F_IHALF: + insb(base + B1_READ, dp, i); #ifdef FASTLINK_DEBUG - wcnt += i; + wcnt += i; #endif - dp += i; - i = 0; - break; - default: - *dp++ = b1_get_byte(base); - i--; + dp += i; + i = 0; + break; + default: + *dp++ = b1_get_byte(base); + i--; #ifdef FASTLINK_DEBUG - bcnt++; + bcnt++; #endif - break; + break; } - } + } #ifdef FASTLINK_DEBUG - if (wcnt) - printk(KERN_DEBUG "b1lli(0x%x): get_slice l=%d w=%d b=%d\n", - base, len, wcnt, bcnt); + if (wcnt) + printk(KERN_DEBUG "b1lli(0x%x): get_slice l=%d w=%d b=%d\n", + base, len, wcnt, bcnt); #endif } else { while (i-- > 0) @@ -464,26 +464,26 @@ static inline void t1_put_slice(unsigned int base, { unsigned i = len; b1_put_word(base, i); - if (t1_isfastlink(base)) { + if (t1_isfastlink(base)) { int status; while (i > 0) { - status = t1_fifostatus(base) & (T1F_OREADY|T1F_OHALF); + status = t1_fifostatus(base) & (T1F_OREADY | T1F_OHALF); if (i >= FIFO_OUTBSIZE) status |= T1F_OEMPTY; switch (status) { - case T1F_OREADY|T1F_OHALF|T1F_OEMPTY: - outsb(base+B1_WRITE, dp, FIFO_OUTBSIZE); - dp += FIFO_OUTBSIZE; - i -= FIFO_OUTBSIZE; - break; - case T1F_OREADY|T1F_OHALF: - outsb(base+B1_WRITE, dp, i); - dp += i; - i = 0; - break; - default: - b1_put_byte(base, *dp++); - i--; - break; + case T1F_OREADY | T1F_OHALF | T1F_OEMPTY: + outsb(base + B1_WRITE, dp, FIFO_OUTBSIZE); + dp += FIFO_OUTBSIZE; + i -= FIFO_OUTBSIZE; + break; + case T1F_OREADY | T1F_OHALF: + outsb(base + B1_WRITE, dp, i); + dp += i; + i = 0; + break; + default: + b1_put_byte(base, *dp++); + i--; + break; } } } else { @@ -494,18 +494,18 @@ static inline void t1_put_slice(unsigned int base, static inline void t1_disable_irq(unsigned int base) { - t1outp(base, T1_IRQMASTER, 0x00); + t1outp(base, T1_IRQMASTER, 0x00); } static inline void t1_reset(unsigned int base) { - /* reset T1 Controller */ - b1_reset(base); - /* disable irq on HEMA */ - t1outp(base, B1_INSTAT, 0x00); - t1outp(base, B1_OUTSTAT, 0x00); - t1outp(base, T1_IRQMASTER, 0x00); - /* reset HEMA board configuration */ + /* reset T1 Controller */ + b1_reset(base); + /* disable irq on HEMA */ + t1outp(base, B1_INSTAT, 0x00); + t1outp(base, B1_OUTSTAT, 0x00); + t1outp(base, T1_IRQMASTER, 0x00); + /* reset HEMA board configuration */ t1outp(base, T1_RESETBOARD, 0xf); } @@ -513,29 +513,29 @@ static inline void b1_setinterrupt(unsigned int base, unsigned irq, enum avmcardtype cardtype) { switch (cardtype) { - case avm_t1isa: - t1outp(base, B1_INSTAT, 0x00); - t1outp(base, B1_INSTAT, 0x02); - t1outp(base, T1_IRQMASTER, 0x08); - break; - case avm_b1isa: - b1outp(base, B1_INSTAT, 0x00); - b1outp(base, B1_RESET, b1_irq_table[irq]); - b1outp(base, B1_INSTAT, 0x02); - break; - default: - case avm_m1: - case avm_m2: - case avm_b1pci: - b1outp(base, B1_INSTAT, 0x00); - b1outp(base, B1_RESET, 0xf0); - b1outp(base, B1_INSTAT, 0x02); - break; - case avm_c4: - case avm_t1pci: - b1outp(base, B1_RESET, 0xf0); - break; - } + case avm_t1isa: + t1outp(base, B1_INSTAT, 0x00); + t1outp(base, B1_INSTAT, 0x02); + t1outp(base, T1_IRQMASTER, 0x08); + break; + case avm_b1isa: + b1outp(base, B1_INSTAT, 0x00); + b1outp(base, B1_RESET, b1_irq_table[irq]); + b1outp(base, B1_INSTAT, 0x02); + break; + default: + case avm_m1: + case avm_m2: + case avm_b1pci: + b1outp(base, B1_INSTAT, 0x00); + b1outp(base, B1_RESET, 0xf0); + b1outp(base, B1_INSTAT, 0x02); + break; + case avm_c4: + case avm_t1pci: + b1outp(base, B1_RESET, 0xf0); + break; + } } /* b1.c */ @@ -543,14 +543,14 @@ avmcard *b1_alloc_card(int nr_controllers); void b1_free_card(avmcard *card); int b1_detect(unsigned int base, enum avmcardtype cardtype); void b1_getrevision(avmcard *card); -int b1_load_t4file(avmcard *card, capiloaddatapart * t4file); -int b1_load_config(avmcard *card, capiloaddatapart * config); +int b1_load_t4file(avmcard *card, capiloaddatapart *t4file); +int b1_load_config(avmcard *card, capiloaddatapart *config); int b1_loaded(avmcard *card); int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data); void b1_reset_ctr(struct capi_ctr *ctrl); void b1_register_appl(struct capi_ctr *ctrl, u16 appl, - capi_register_params *rp); + capi_register_params *rp); void b1_release_appl(struct capi_ctr *ctrl, u16 appl); u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); void b1_parse_version(avmctrl_info *card); @@ -572,8 +572,8 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data); void b1dma_reset_ctr(struct capi_ctr *ctrl); void b1dma_remove_ctr(struct capi_ctr *ctrl); void b1dma_register_appl(struct capi_ctr *ctrl, - u16 appl, - capi_register_params *rp); + u16 appl, + capi_register_params *rp); void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl); u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); extern const struct file_operations b1dmactl_proc_fops; diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c index 2a57da590d79..821f7ac33b37 100644 --- a/drivers/isdn/hardware/avm/b1.c +++ b/drivers/isdn/hardware/avm/b1.c @@ -1,7 +1,7 @@ /* $Id: b1.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $ - * + * * Common module for AVM B1 cards. - * + * * Copyright 1999 by Carsten Paeth * * This software may be used and distributed according to the terms @@ -60,7 +60,7 @@ int b1_irq_table[16] = 112, /* irq 15 */ }; -/* ------------------------------------------------------------- */ +/* ------------------------------------------------------------- */ avmcard *b1_alloc_card(int nr_controllers) { @@ -104,13 +104,13 @@ int b1_detect(unsigned int base, enum avmcardtype cardtype) int onoff, i; /* - * Statusregister 0000 00xx + * Statusregister 0000 00xx */ if ((inb(base + B1_INSTAT) & 0xfc) || (inb(base + B1_OUTSTAT) & 0xfc)) return 1; /* - * Statusregister 0000 001x + * Statusregister 0000 001x */ b1outp(base, B1_INSTAT, 0x2); /* enable irq */ /* b1outp(base, B1_OUTSTAT, 0x2); */ @@ -118,38 +118,38 @@ int b1_detect(unsigned int base, enum avmcardtype cardtype) /* || (inb(base + B1_OUTSTAT) & 0xfe) != 0x2 */) return 2; /* - * Statusregister 0000 000x + * Statusregister 0000 000x */ b1outp(base, B1_INSTAT, 0x0); /* disable irq */ b1outp(base, B1_OUTSTAT, 0x0); if ((inb(base + B1_INSTAT) & 0xfe) || (inb(base + B1_OUTSTAT) & 0xfe)) return 3; - - for (onoff = !0, i= 0; i < 10 ; i++) { + + for (onoff = !0, i = 0; i < 10; i++) { b1_set_test_bit(base, cardtype, onoff); if (b1_get_test_bit(base, cardtype) != onoff) - return 4; + return 4; onoff = !onoff; } if (cardtype == avm_m1) - return 0; + return 0; - if ((b1_rd_reg(base, B1_STAT1(cardtype)) & 0x0f) != 0x01) - return 5; + if ((b1_rd_reg(base, B1_STAT1(cardtype)) & 0x0f) != 0x01) + return 5; return 0; } void b1_getrevision(avmcard *card) { - card->class = inb(card->port + B1_ANALYSE); - card->revision = inb(card->port + B1_REVISION); + card->class = inb(card->port + B1_ANALYSE); + card->revision = inb(card->port + B1_REVISION); } #define FWBUF_SIZE 256 -int b1_load_t4file(avmcard *card, capiloaddatapart * t4file) +int b1_load_t4file(avmcard *card, capiloaddatapart *t4file) { unsigned char buf[FWBUF_SIZE]; unsigned char *dp; @@ -168,7 +168,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart * t4file) for (i = 0; i < FWBUF_SIZE; i++) if (b1_save_put_byte(base, buf[i]) < 0) { printk(KERN_ERR "%s: corrupted firmware file ?\n", - card->name); + card->name); return -EIO; } left -= FWBUF_SIZE; @@ -184,14 +184,14 @@ int b1_load_t4file(avmcard *card, capiloaddatapart * t4file) for (i = 0; i < left; i++) if (b1_save_put_byte(base, buf[i]) < 0) { printk(KERN_ERR "%s: corrupted firmware file ?\n", - card->name); + card->name); return -EIO; } } return 0; } -int b1_load_config(avmcard *card, capiloaddatapart * config) +int b1_load_config(avmcard *card, capiloaddatapart *config) { unsigned char buf[FWBUF_SIZE]; unsigned char *dp; @@ -202,9 +202,9 @@ int b1_load_config(avmcard *card, capiloaddatapart * config) left = config->len; if (left) { b1_put_byte(base, SEND_CONFIG); - b1_put_word(base, 1); + b1_put_word(base, 1); b1_put_byte(base, SEND_CONFIG); - b1_put_word(base, left); + b1_put_word(base, left); } while (left > FWBUF_SIZE) { if (config->user) { @@ -215,7 +215,7 @@ int b1_load_config(avmcard *card, capiloaddatapart * config) } for (i = 0; i < FWBUF_SIZE; ) { b1_put_byte(base, SEND_CONFIG); - for (j=0; j < 4; j++) { + for (j = 0; j < 4; j++) { b1_put_byte(base, buf[i++]); } } @@ -231,7 +231,7 @@ int b1_load_config(avmcard *card, capiloaddatapart * config) } for (i = 0; i < left; ) { b1_put_byte(base, SEND_CONFIG); - for (j=0; j < 4; j++) { + for (j = 0; j < 4; j++) { if (i < left) b1_put_byte(base, buf[i++]); else @@ -255,7 +255,7 @@ int b1_loaded(avmcard *card) } if (!b1_tx_empty(base)) { printk(KERN_ERR "%s: b1_loaded: tx err, corrupted t4 file ?\n", - card->name); + card->name); return 0; } b1_put_byte(base, SEND_POLL); @@ -265,7 +265,7 @@ int b1_loaded(avmcard *card) return 1; } printk(KERN_ERR "%s: b1_loaded: got 0x%x, firmware not running\n", - card->name, ans); + card->name, ans); return 0; } } @@ -288,7 +288,7 @@ int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_t4file(card, &data->firmware))) { b1_reset(port); printk(KERN_ERR "%s: failed to load t4file!!\n", - card->name); + card->name); return retval; } @@ -298,7 +298,7 @@ int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_config(card, &data->configuration))) { b1_reset(port); printk(KERN_ERR "%s: failed to load config!!\n", - card->name); + card->name); return retval; } } @@ -312,7 +312,7 @@ int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) b1_setinterrupt(port, card->irq, card->cardtype); b1_put_byte(port, SEND_INIT); b1_put_word(port, CAPI_MAXAPPL); - b1_put_word(port, AVM_NCCI_PER_CHANNEL*2); + b1_put_word(port, AVM_NCCI_PER_CHANNEL * 2); b1_put_word(port, ctrl->cnr - 1); spin_unlock_irqrestore(&card->lock, flags); @@ -337,8 +337,8 @@ void b1_reset_ctr(struct capi_ctr *ctrl) } void b1_register_appl(struct capi_ctr *ctrl, - u16 appl, - capi_register_params *rp) + u16 appl, + capi_register_params *rp) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; @@ -353,7 +353,7 @@ void b1_register_appl(struct capi_ctr *ctrl, spin_lock_irqsave(&card->lock, flags); b1_put_byte(port, SEND_REGISTER); b1_put_word(port, appl); - b1_put_word(port, 1024 * (nconn+1)); + b1_put_word(port, 1024 * (nconn + 1)); b1_put_word(port, nconn); b1_put_word(port, rp->datablkcnt); b1_put_word(port, rp->datablklen); @@ -430,7 +430,7 @@ void b1_parse_version(avmctrl_info *cinfo) cinfo->version[j] = &cinfo->versionbuf[i + 1]; strlcpy(ctrl->serial, cinfo->version[VER_SERIAL], sizeof(ctrl->serial)); - memcpy(&ctrl->profile, cinfo->version[VER_PROFILE],sizeof(capi_profile)); + memcpy(&ctrl->profile, cinfo->version[VER_PROFILE], sizeof(capi_profile)); strlcpy(ctrl->manu, "AVM GmbH", sizeof(ctrl->manu)); dversion = cinfo->version[VER_DRIVER]; ctrl->version.majorversion = 2; @@ -439,49 +439,49 @@ void b1_parse_version(avmctrl_info *cinfo) ctrl->version.majormanuversion |= ((dversion[2] - '0') & 0xf); ctrl->version.minormanuversion = (dversion[3] - '0') << 4; ctrl->version.minormanuversion |= - (dversion[5] - '0') * 10 + ((dversion[6] - '0') & 0xf); + (dversion[5] - '0') * 10 + ((dversion[6] - '0') & 0xf); profp = &ctrl->profile; flag = ((u8 *)(profp->manu))[1]; switch (flag) { case 0: if (cinfo->version[VER_CARDTYPE]) - strcpy(cinfo->cardname, cinfo->version[VER_CARDTYPE]); - else strcpy(cinfo->cardname, "B1"); + strcpy(cinfo->cardname, cinfo->version[VER_CARDTYPE]); + else strcpy(cinfo->cardname, "B1"); break; - case 3: strcpy(cinfo->cardname,"PCMCIA B"); break; - case 4: strcpy(cinfo->cardname,"PCMCIA M1"); break; - case 5: strcpy(cinfo->cardname,"PCMCIA M2"); break; - case 6: strcpy(cinfo->cardname,"B1 V3.0"); break; - case 7: strcpy(cinfo->cardname,"B1 PCI"); break; + case 3: strcpy(cinfo->cardname, "PCMCIA B"); break; + case 4: strcpy(cinfo->cardname, "PCMCIA M1"); break; + case 5: strcpy(cinfo->cardname, "PCMCIA M2"); break; + case 6: strcpy(cinfo->cardname, "B1 V3.0"); break; + case 7: strcpy(cinfo->cardname, "B1 PCI"); break; default: sprintf(cinfo->cardname, "AVM?%u", (unsigned int)flag); break; - } - printk(KERN_NOTICE "%s: card %d \"%s\" ready.\n", - card->name, ctrl->cnr, cinfo->cardname); + } + printk(KERN_NOTICE "%s: card %d \"%s\" ready.\n", + card->name, ctrl->cnr, cinfo->cardname); - flag = ((u8 *)(profp->manu))[3]; - if (flag) + flag = ((u8 *)(profp->manu))[3]; + if (flag) printk(KERN_NOTICE "%s: card %d Protocol:%s%s%s%s%s%s%s\n", - card->name, - ctrl->cnr, - (flag & 0x01) ? " DSS1" : "", - (flag & 0x02) ? " CT1" : "", - (flag & 0x04) ? " VN3" : "", - (flag & 0x08) ? " NI1" : "", - (flag & 0x10) ? " AUSTEL" : "", - (flag & 0x20) ? " ESS" : "", - (flag & 0x40) ? " 1TR6" : "" + card->name, + ctrl->cnr, + (flag & 0x01) ? " DSS1" : "", + (flag & 0x02) ? " CT1" : "", + (flag & 0x04) ? " VN3" : "", + (flag & 0x08) ? " NI1" : "", + (flag & 0x10) ? " AUSTEL" : "", + (flag & 0x20) ? " ESS" : "", + (flag & 0x40) ? " 1TR6" : "" ); - flag = ((u8 *)(profp->manu))[5]; + flag = ((u8 *)(profp->manu))[5]; if (flag) printk(KERN_NOTICE "%s: card %d Linetype:%s%s%s%s\n", - card->name, - ctrl->cnr, - (flag & 0x01) ? " point to point" : "", - (flag & 0x02) ? " point to multipoint" : "", - (flag & 0x08) ? " leased line without D-channel" : "", - (flag & 0x04) ? " leased line with D-channel" : "" + card->name, + ctrl->cnr, + (flag & 0x01) ? " point to point" : "", + (flag & 0x02) ? " point to multipoint" : "", + (flag & 0x08) ? " leased line without D-channel" : "", + (flag & 0x04) ? " leased line with D-channel" : "" ); } @@ -521,13 +521,13 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) spin_unlock_irqrestore(&card->lock, flags); if (MsgLen < 30) { /* not CAPI 64Bit */ - memset(card->msgbuf+MsgLen, 0, 30-MsgLen); + memset(card->msgbuf + MsgLen, 0, 30-MsgLen); MsgLen = 30; CAPIMSG_SETLEN(card->msgbuf, 30); } if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); @@ -541,7 +541,7 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) MsgLen = b1_get_slice(card->port, card->msgbuf); if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); spin_unlock_irqrestore(&card->lock, flags); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); @@ -573,7 +573,7 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) break; case RECEIVE_START: - /* b1_put_byte(card->port, SEND_POLLACK); */ + /* b1_put_byte(card->port, SEND_POLLACK); */ spin_unlock_irqrestore(&card->lock, flags); capi_ctr_resume_output(ctrl); break; @@ -600,24 +600,24 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) MsgLen = b1_get_slice(card->port, card->msgbuf); spin_unlock_irqrestore(&card->lock, flags); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: task %d \"%s\" ready.\n", - card->name, ApplId, card->msgbuf); + card->name, ApplId, card->msgbuf); break; case RECEIVE_DEBUGMSG: MsgLen = b1_get_slice(card->port, card->msgbuf); spin_unlock_irqrestore(&card->lock, flags); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); @@ -630,7 +630,7 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) default: spin_unlock_irqrestore(&card->lock, flags); printk(KERN_ERR "%s: b1_interrupt: 0x%x ???\n", - card->name, b1cmd); + card->name, b1cmd); return IRQ_HANDLED; } return IRQ_HANDLED; @@ -671,29 +671,29 @@ static int b1ctl_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "ver_serial", s); if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[3]; - if (flag) + flag = ((u8 *)(ctrl->profile.manu))[3]; + if (flag) seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", - "protocol", - (flag & 0x01) ? " DSS1" : "", - (flag & 0x02) ? " CT1" : "", - (flag & 0x04) ? " VN3" : "", - (flag & 0x08) ? " NI1" : "", - (flag & 0x10) ? " AUSTEL" : "", - (flag & 0x20) ? " ESS" : "", - (flag & 0x40) ? " 1TR6" : "" - ); + "protocol", + (flag & 0x01) ? " DSS1" : "", + (flag & 0x02) ? " CT1" : "", + (flag & 0x04) ? " VN3" : "", + (flag & 0x08) ? " NI1" : "", + (flag & 0x10) ? " AUSTEL" : "", + (flag & 0x20) ? " ESS" : "", + (flag & 0x40) ? " 1TR6" : "" + ); } if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[5]; + flag = ((u8 *)(ctrl->profile.manu))[5]; if (flag) seq_printf(m, "%-16s%s%s%s%s\n", - "linetype", - (flag & 0x01) ? " point to point" : "", - (flag & 0x02) ? " point to multipoint" : "", - (flag & 0x08) ? " leased line without D-channel" : "", - (flag & 0x04) ? " leased line with D-channel" : "" - ); + "linetype", + (flag & 0x01) ? " point to point" : "", + (flag & 0x02) ? " point to multipoint" : "", + (flag & 0x08) ? " leased line without D-channel" : "", + (flag & 0x04) ? " leased line with D-channel" : "" + ); } seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname); @@ -750,12 +750,12 @@ avmcard_dma_alloc(char *name, struct pci_dev *pdev, long rsize, long ssize) return p; - err_free_consistent: +err_free_consistent: pci_free_consistent(p->pcidev, p->recvbuf.size, p->recvbuf.dmabuf, p->recvbuf.dmaaddr); - err_kfree: +err_kfree: kfree(p); - err: +err: return NULL; } @@ -800,7 +800,7 @@ static int __init b1_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c index a0ed668d4d2a..0896aa86fc08 100644 --- a/drivers/isdn/hardware/avm/b1dma.c +++ b/drivers/isdn/hardware/avm/b1dma.c @@ -1,9 +1,9 @@ /* $Id: b1dma.c,v 1.1.2.3 2004/02/10 01:07:12 keil Exp $ - * + * * Common module for AVM B1 cards that support dma with AMCC - * + * * Copyright 2000 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -110,11 +110,11 @@ static int b1dma_tolink(avmcard *card, void *buf, unsigned int len) unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */ unsigned char *s = (unsigned char *)buf; while (len--) { - while ( !b1dma_tx_empty(card->port) + while (!b1dma_tx_empty(card->port) && time_before(jiffies, stop)); - if (!b1dma_tx_empty(card->port)) + if (!b1dma_tx_empty(card->port)) return -1; - t1outp(card->port, 0x01, *s++); + t1outp(card->port, 0x01, *s++); } return 0; } @@ -124,11 +124,11 @@ static int b1dma_fromlink(avmcard *card, void *buf, unsigned int len) unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */ unsigned char *s = (unsigned char *)buf; while (len--) { - while ( !b1dma_rx_full(card->port) + while (!b1dma_rx_full(card->port) && time_before(jiffies, stop)); - if (!b1dma_rx_full(card->port)) + if (!b1dma_rx_full(card->port)) return -1; - *s++ = t1inp(card->port, 0x00); + *s++ = t1inp(card->port, 0x00); } return 0; } @@ -136,7 +136,7 @@ static int b1dma_fromlink(avmcard *card, void *buf, unsigned int len) static int WriteReg(avmcard *card, u32 reg, u8 val) { u8 cmd = 0x00; - if ( b1dma_tolink(card, &cmd, 1) == 0 + if (b1dma_tolink(card, &cmd, 1) == 0 && b1dma_tolink(card, ®, 4) == 0) { u32 tmp = val; return b1dma_tolink(card, &tmp, 4); @@ -147,7 +147,7 @@ static int WriteReg(avmcard *card, u32 reg, u8 val) static u8 ReadReg(avmcard *card, u32 reg) { u8 cmd = 0x01; - if ( b1dma_tolink(card, &cmd, 1) == 0 + if (b1dma_tolink(card, &cmd, 1) == 0 && b1dma_tolink(card, ®, 4) == 0) { u32 tmp; if (b1dma_fromlink(card, &tmp, 4) == 0) @@ -258,30 +258,30 @@ static int b1dma_detect(avmcard *card) b1dma_writel(card, 0xffffffff, AMCC_RXPTR); b1dma_writel(card, 0xffffffff, AMCC_TXPTR); - if ( b1dma_readl(card, AMCC_RXPTR) != 0xfffffffc + if (b1dma_readl(card, AMCC_RXPTR) != 0xfffffffc || b1dma_readl(card, AMCC_TXPTR) != 0xfffffffc) return 2; b1dma_writel(card, 0x0, AMCC_RXPTR); b1dma_writel(card, 0x0, AMCC_TXPTR); - if ( b1dma_readl(card, AMCC_RXPTR) != 0x0 + if (b1dma_readl(card, AMCC_RXPTR) != 0x0 || b1dma_readl(card, AMCC_TXPTR) != 0x0) return 3; t1outp(card->port, 0x10, 0x00); t1outp(card->port, 0x07, 0x00); - + t1outp(card->port, 0x02, 0x02); t1outp(card->port, 0x03, 0x02); - if ( (t1inp(card->port, 0x02) & 0xFE) != 0x02 + if ((t1inp(card->port, 0x02) & 0xFE) != 0x02 || t1inp(card->port, 0x3) != 0x03) return 4; t1outp(card->port, 0x02, 0x00); t1outp(card->port, 0x03, 0x00); - if ( (t1inp(card->port, 0x02) & 0xFE) != 0x00 + if ((t1inp(card->port, 0x02) & 0xFE) != 0x00 || t1inp(card->port, 0x3) != 0x01) return 5; @@ -294,28 +294,28 @@ int t1pci_detect(avmcard *card) if ((ret = b1dma_detect(card)) != 0) return ret; - + /* Transputer test */ - - if ( WriteReg(card, 0x80001000, 0x11) != 0 + + if (WriteReg(card, 0x80001000, 0x11) != 0 || WriteReg(card, 0x80101000, 0x22) != 0 || WriteReg(card, 0x80201000, 0x33) != 0 || WriteReg(card, 0x80301000, 0x44) != 0) return 6; - if ( ReadReg(card, 0x80001000) != 0x11 + if (ReadReg(card, 0x80001000) != 0x11 || ReadReg(card, 0x80101000) != 0x22 || ReadReg(card, 0x80201000) != 0x33 || ReadReg(card, 0x80301000) != 0x44) return 7; - if ( WriteReg(card, 0x80001000, 0x55) != 0 + if (WriteReg(card, 0x80001000, 0x55) != 0 || WriteReg(card, 0x80101000, 0x66) != 0 || WriteReg(card, 0x80201000, 0x77) != 0 || WriteReg(card, 0x80301000, 0x88) != 0) return 8; - if ( ReadReg(card, 0x80001000) != 0x55 + if (ReadReg(card, 0x80001000) != 0x55 || ReadReg(card, 0x80101000) != 0x66 || ReadReg(card, 0x80201000) != 0x77 || ReadReg(card, 0x80301000) != 0x88) @@ -330,20 +330,20 @@ int b1pciv4_detect(avmcard *card) if ((ret = b1dma_detect(card)) != 0) return ret; - - for (i=0; i < 5 ; i++) { + + for (i = 0; i < 5; i++) { if (WriteReg(card, 0x80A00000, 0x21) != 0) return 6; if ((ReadReg(card, 0x80A00000) & 0x01) != 0x01) return 7; } - for (i=0; i < 5 ; i++) { + for (i = 0; i < 5; i++) { if (WriteReg(card, 0x80A00000, 0x20) != 0) return 8; if ((ReadReg(card, 0x80A00000) & 0x01) != 0x00) return 9; } - + return 0; } @@ -373,7 +373,7 @@ static void b1dma_dispatch_tx(avmcard *card) u16 len; u32 txlen; void *p; - + skb = skb_dequeue(&dma->send_queue); len = CAPIMSG_LEN(skb->data); @@ -398,13 +398,13 @@ static void b1dma_dispatch_tx(avmcard *card) printk(KERN_DEBUG "tx: put msg len=%d\n", txlen); #endif } else { - txlen = skb->len-2; + txlen = skb->len - 2; #ifdef AVM_B1DMA_POLLDEBUG if (skb->data[2] == SEND_POLLACK) printk(KERN_INFO "%s: send ack\n", card->name); #endif #ifdef AVM_B1DMA_DEBUG - printk(KERN_DEBUG "tx: put 0x%x len=%d\n", + printk(KERN_DEBUG "tx: put 0x%x len=%d\n", skb->data[2], txlen); #endif skb_copy_from_linear_data_offset(skb, 2, dma->sendbuf.dmabuf, @@ -430,7 +430,7 @@ static void queue_pollack(avmcard *card) skb = alloc_skb(3, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost poll ack\n", - card->name); + card->name); return; } p = skb->data; @@ -450,14 +450,14 @@ static void b1dma_handle_rx(avmcard *card) avmcard_dmainfo *dma = card->dma; struct capi_ctr *ctrl = &cinfo->capi_ctrl; struct sk_buff *skb; - void *p = dma->recvbuf.dmabuf+4; + void *p = dma->recvbuf.dmabuf + 4; u32 ApplId, MsgLen, DataB3Len, NCCI, WindowSize; u8 b1cmd = _get_byte(&p); #ifdef AVM_B1DMA_DEBUG printk(KERN_DEBUG "rx: 0x%x %lu\n", b1cmd, (unsigned long)dma->recvlen); #endif - + switch (b1cmd) { case RECEIVE_DATA_B3_IND: @@ -466,13 +466,13 @@ static void b1dma_handle_rx(avmcard *card) DataB3Len = _get_slice(&p, card->databuf); if (MsgLen < 30) { /* not CAPI 64Bit */ - memset(card->msgbuf+MsgLen, 0, 30-MsgLen); + memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); MsgLen = 30; CAPIMSG_SETLEN(card->msgbuf, 30); } - if (!(skb = alloc_skb(DataB3Len+MsgLen, GFP_ATOMIC))) { + if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); @@ -486,14 +486,14 @@ static void b1dma_handle_rx(avmcard *card) MsgLen = _get_slice(&p, card->msgbuf); if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) { spin_lock(&card->lock); capilib_data_b3_conf(&cinfo->ncci_head, ApplId, - CAPIMSG_NCCI(skb->data), - CAPIMSG_MSGID(skb->data)); + CAPIMSG_NCCI(skb->data), + CAPIMSG_MSGID(skb->data)); spin_unlock(&card->lock); } capi_ctr_handle_message(ctrl, ApplId, skb); @@ -550,23 +550,23 @@ static void b1dma_handle_rx(avmcard *card) ApplId = (unsigned) _get_word(&p); MsgLen = _get_slice(&p, card->msgbuf); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: task %d \"%s\" ready.\n", - card->name, ApplId, card->msgbuf); + card->name, ApplId, card->msgbuf); break; case RECEIVE_DEBUGMSG: MsgLen = _get_slice(&p, card->msgbuf); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); @@ -574,7 +574,7 @@ static void b1dma_handle_rx(avmcard *card) default: printk(KERN_ERR "%s: b1dma_interrupt: 0x%x ???\n", - card->name, b1cmd); + card->name, b1cmd); return; } } @@ -594,7 +594,7 @@ static void b1dma_handle_interrupt(avmcard *card) return; } - newcsr = card->csr | (status & ALL_INT); + newcsr = card->csr | (status & ALL_INT); if (status & TX_TC_INT) newcsr &= ~EN_TX_TC_INT; if (status & RX_TC_INT) newcsr &= ~EN_RX_TC_INT; b1dma_writel(card, newcsr, AMCC_INTCSR); @@ -602,23 +602,23 @@ static void b1dma_handle_interrupt(avmcard *card) if ((status & RX_TC_INT) != 0) { struct avmcard_dmainfo *dma = card->dma; u32 rxlen; - if (card->dma->recvlen == 0) { - rxlen = b1dma_readl(card, AMCC_RXLEN); + if (card->dma->recvlen == 0) { + rxlen = b1dma_readl(card, AMCC_RXLEN); if (rxlen == 0) { dma->recvlen = *((u32 *)dma->recvbuf.dmabuf); rxlen = (dma->recvlen + 3) & ~3; - b1dma_writel(card, dma->recvbuf.dmaaddr+4, AMCC_RXPTR); + b1dma_writel(card, dma->recvbuf.dmaaddr + 4, AMCC_RXPTR); b1dma_writel(card, rxlen, AMCC_RXLEN); #ifdef AVM_B1DMA_DEBUG } else { printk(KERN_ERR "%s: rx not complete (%d).\n", - card->name, rxlen); + card->name, rxlen); #endif } } else { spin_unlock(&card->lock); b1dma_handle_rx(card); - dma->recvlen = 0; + dma->recvlen = 0; spin_lock(&card->lock); b1dma_writel(card, dma->recvbuf.dmaaddr, AMCC_RXPTR); b1dma_writel(card, 4, AMCC_RXLEN); @@ -659,7 +659,7 @@ static int b1dma_loaded(avmcard *card) } if (!b1_tx_empty(base)) { printk(KERN_ERR "%s: b1dma_loaded: tx err, corrupted t4 file ?\n", - card->name); + card->name); return 0; } b1_put_byte(base, SEND_POLLACK); @@ -686,7 +686,7 @@ static void b1dma_send_init(avmcard *card) skb = alloc_skb(15, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost register appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -694,7 +694,7 @@ static void b1dma_send_init(avmcard *card) _put_byte(&p, 0); _put_byte(&p, SEND_INIT); _put_word(&p, CAPI_MAXAPPL); - _put_word(&p, AVM_NCCI_PER_CHANNEL*30); + _put_word(&p, AVM_NCCI_PER_CHANNEL * 30); _put_word(&p, card->cardnr - 1); skb_put(skb, (u8 *)p - (u8 *)skb->data); @@ -712,7 +712,7 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_t4file(card, &data->firmware))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load t4file!!\n", - card->name); + card->name); return retval; } @@ -720,7 +720,7 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_config(card, &data->configuration))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load config!!\n", - card->name); + card->name); return retval; } } @@ -733,8 +733,8 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) card->csr = AVM_FLAG; b1dma_writel(card, card->csr, AMCC_INTCSR); - b1dma_writel(card, EN_A2P_TRANSFERS|EN_P2A_TRANSFERS|A2P_HI_PRIORITY| - P2A_HI_PRIORITY|RESET_A2P_FLAGS|RESET_P2A_FLAGS, + b1dma_writel(card, EN_A2P_TRANSFERS | EN_P2A_TRANSFERS | A2P_HI_PRIORITY | + P2A_HI_PRIORITY | RESET_A2P_FLAGS | RESET_P2A_FLAGS, AMCC_MCSR); t1outp(card->port, 0x07, 0x30); t1outp(card->port, 0x10, 0xF0); @@ -745,7 +745,7 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) card->csr |= EN_RX_TC_INT; b1dma_writel(card, card->csr, AMCC_INTCSR); - b1dma_send_init(card); + b1dma_send_init(card); return 0; } @@ -757,7 +757,7 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl) unsigned long flags; spin_lock_irqsave(&card->lock, flags); - b1dma_reset(card); + b1dma_reset(card); memset(cinfo->version, 0, sizeof(cinfo->version)); capilib_release(&cinfo->ncci_head); @@ -768,8 +768,8 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl) /* ------------------------------------------------------------- */ void b1dma_register_appl(struct capi_ctr *ctrl, - u16 appl, - capi_register_params *rp) + u16 appl, + capi_register_params *rp) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; @@ -785,7 +785,7 @@ void b1dma_register_appl(struct capi_ctr *ctrl, skb = alloc_skb(23, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost register appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -793,7 +793,7 @@ void b1dma_register_appl(struct capi_ctr *ctrl, _put_byte(&p, 0); _put_byte(&p, SEND_REGISTER); _put_word(&p, appl); - _put_word(&p, 1024 * (nconn+1)); + _put_word(&p, 1024 * (nconn + 1)); _put_word(&p, nconn); _put_word(&p, rp->datablkcnt); _put_word(&p, rp->datablklen); @@ -819,7 +819,7 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl) skb = alloc_skb(7, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost release appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -841,7 +841,7 @@ u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) avmcard *card = cinfo->card; u16 retval = CAPI_NOERROR; - if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) { + if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) { unsigned long flags; spin_lock_irqsave(&card->lock, flags); retval = capilib_data_b3_req(&cinfo->ncci_head, @@ -850,7 +850,7 @@ u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) CAPIMSG_MSGID(skb->data)); spin_unlock_irqrestore(&card->lock, flags); } - if (retval == CAPI_NOERROR) + if (retval == CAPI_NOERROR) b1dma_queue_tx(card, skb); return retval; @@ -893,29 +893,29 @@ static int b1dmactl_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "ver_serial", s); if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[3]; - if (flag) + flag = ((u8 *)(ctrl->profile.manu))[3]; + if (flag) seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", - "protocol", - (flag & 0x01) ? " DSS1" : "", - (flag & 0x02) ? " CT1" : "", - (flag & 0x04) ? " VN3" : "", - (flag & 0x08) ? " NI1" : "", - (flag & 0x10) ? " AUSTEL" : "", - (flag & 0x20) ? " ESS" : "", - (flag & 0x40) ? " 1TR6" : "" - ); + "protocol", + (flag & 0x01) ? " DSS1" : "", + (flag & 0x02) ? " CT1" : "", + (flag & 0x04) ? " VN3" : "", + (flag & 0x08) ? " NI1" : "", + (flag & 0x10) ? " AUSTEL" : "", + (flag & 0x20) ? " ESS" : "", + (flag & 0x40) ? " 1TR6" : "" + ); } if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[5]; + flag = ((u8 *)(ctrl->profile.manu))[5]; if (flag) seq_printf(m, "%-16s%s%s%s%s\n", - "linetype", - (flag & 0x01) ? " point to point" : "", - (flag & 0x02) ? " point to multipoint" : "", - (flag & 0x08) ? " leased line without D-channel" : "", - (flag & 0x04) ? " leased line with D-channel" : "" - ); + "linetype", + (flag & 0x01) ? " point to point" : "", + (flag & 0x02) ? " point to multipoint" : "", + (flag & 0x08) ? " leased line without D-channel" : "", + (flag & 0x04) ? " leased line with D-channel" : "" + ); } seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname); @@ -977,7 +977,7 @@ static int __init b1dma_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, sizeof(rev)); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/b1isa.c b/drivers/isdn/hardware/avm/b1isa.c index ff5390546f92..31ef8130a87f 100644 --- a/drivers/isdn/hardware/avm/b1isa.c +++ b/drivers/isdn/hardware/avm/b1isa.c @@ -1,9 +1,9 @@ /* $Id: b1isa.c,v 1.1.2.3 2004/02/10 01:07:12 keil Exp $ - * + * * Module for AVM B1 ISA-card. - * + * * Copyright 1999 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -80,7 +80,7 @@ static int b1isa_probe(struct pci_dev *pdev) card->cardtype = avm_b1isa; sprintf(card->name, "b1isa-%x", card->port); - if ( card->port != 0x150 && card->port != 0x250 + if (card->port != 0x150 && card->port != 0x250 && card->port != 0x300 && card->port != 0x340) { printk(KERN_WARNING "b1isa: invalid port 0x%x.\n", card->port); retval = -EINVAL; @@ -136,13 +136,13 @@ static int b1isa_probe(struct pci_dev *pdev) pci_set_drvdata(pdev, cinfo); return 0; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_release_region: +err_release_region: release_region(card->port, AVMB1_PORTLEN); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -206,7 +206,7 @@ static int __init b1isa_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/b1pci.c b/drivers/isdn/hardware/avm/b1pci.c index c97e4315079d..b305e6b2b8ee 100644 --- a/drivers/isdn/hardware/avm/b1pci.c +++ b/drivers/isdn/hardware/avm/b1pci.c @@ -1,9 +1,9 @@ /* $Id: b1pci.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $ - * + * * Module for AVM B1 PCI-card. - * + * * Copyright 1999 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -79,7 +79,7 @@ static int b1pci_probe(struct capicardparams *p, struct pci_dev *pdev) card->port = p->port; card->irq = p->irq; card->cardtype = avm_b1pci; - + if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { printk(KERN_WARNING "b1pci: ports 0x%03x-0x%03x in use.\n", card->port, card->port + AVMB1_PORTLEN); @@ -96,14 +96,14 @@ static int b1pci_probe(struct capicardparams *p, struct pci_dev *pdev) } b1_reset(card->port); b1_getrevision(card); - + retval = request_irq(card->irq, b1_interrupt, IRQF_SHARED, card->name, card); if (retval) { printk(KERN_ERR "b1pci: unable to get IRQ %d.\n", card->irq); retval = -EBUSY; goto err_release_region; } - + cinfo->capi_ctrl.driver_name = "b1pci"; cinfo->capi_ctrl.driverdata = cinfo; cinfo->capi_ctrl.register_appl = b1_register_appl; @@ -133,13 +133,13 @@ static int b1pci_probe(struct capicardparams *p, struct pci_dev *pdev) pci_set_drvdata(pdev, card); return 0; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_release_region: +err_release_region: release_region(card->port, AVMB1_PORTLEN); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -193,7 +193,7 @@ static int b1pciv4_probe(struct capicardparams *p, struct pci_dev *pdev) goto err; } - card->dma = avmcard_dma_alloc("b1pci", pdev, 2048+128, 2048+128); + card->dma = avmcard_dma_alloc("b1pci", pdev, 2048 + 128, 2048 + 128); if (!card->dma) { printk(KERN_WARNING "b1pci: dma alloc.\n"); retval = -ENOMEM; @@ -267,17 +267,17 @@ static int b1pciv4_probe(struct capicardparams *p, struct pci_dev *pdev) pci_set_drvdata(pdev, card); return 0; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_unmap: +err_unmap: iounmap(card->mbase); - err_release_region: +err_release_region: release_region(card->port, AVMB1_PORTLEN); - err_free_dma: +err_free_dma: avmcard_dma_free(card->dma); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -287,13 +287,13 @@ static void b1pciv4_remove(struct pci_dev *pdev) avmcard *card = pci_get_drvdata(pdev); avmctrl_info *cinfo = card->ctrlinfo; - b1dma_reset(card); + b1dma_reset(card); detach_capi_ctr(&cinfo->capi_ctrl); free_irq(card->irq, card); iounmap(card->mbase); release_region(card->port, AVMB1_PORTLEN); - avmcard_dma_free(card->dma); + avmcard_dma_free(card->dma); b1_free_card(card); } @@ -326,7 +326,7 @@ static int __devinit b1pci_pci_probe(struct pci_dev *pdev, retval = b1pci_probe(¶m, pdev); #endif if (retval != 0) { - printk(KERN_ERR "b1pci: no AVM-B1 V4 at i/o %#x, irq %d, mem %#x detected\n", + printk(KERN_ERR "b1pci: no AVM-B1 V4 at i/o %#x, irq %d, mem %#x detected\n", param.port, param.irq, param.membase); } } else { @@ -337,7 +337,7 @@ static int __devinit b1pci_pci_probe(struct pci_dev *pdev, param.port, param.irq); retval = b1pci_probe(¶m, pdev); if (retval != 0) { - printk(KERN_ERR "b1pci: no AVM-B1 at i/o %#x, irq %d detected\n", + printk(KERN_ERR "b1pci: no AVM-B1 at i/o %#x, irq %d detected\n", param.port, param.irq); } } @@ -385,7 +385,7 @@ static int __init b1pci_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/b1pcmcia.c b/drivers/isdn/hardware/avm/b1pcmcia.c index d6391e0afeea..6b0d19d963d5 100644 --- a/drivers/isdn/hardware/avm/b1pcmcia.c +++ b/drivers/isdn/hardware/avm/b1pcmcia.c @@ -1,9 +1,9 @@ /* $Id: b1pcmcia.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $ - * + * * Module for AVM B1/M1/M2 PCMCIA-card. - * + * * Copyright 1999 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -74,9 +74,9 @@ static int b1pcmcia_add_card(unsigned int port, unsigned irq, cinfo = card->ctrlinfo; switch (cardtype) { - case avm_m1: sprintf(card->name, "m1-%x", port); break; - case avm_m2: sprintf(card->name, "m2-%x", port); break; - default: sprintf(card->name, "b1pcmcia-%x", port); break; + case avm_m1: sprintf(card->name, "m1-%x", port); break; + case avm_m2: sprintf(card->name, "m2-%x", port); break; + default: sprintf(card->name, "b1pcmcia-%x", port); break; } card->port = port; card->irq = irq; @@ -117,9 +117,9 @@ static int b1pcmcia_add_card(unsigned int port, unsigned irq, goto err_free_irq; } switch (cardtype) { - case avm_m1: cardname = "M1"; break; - case avm_m2: cardname = "M2"; break; - default : cardname = "B1 PCMCIA"; break; + case avm_m1: cardname = "M1"; break; + case avm_m2: cardname = "M2"; break; + default: cardname = "B1 PCMCIA"; break; } printk(KERN_INFO "b1pcmcia: AVM %s at i/o %#x, irq %d, revision %d\n", @@ -128,11 +128,11 @@ static int b1pcmcia_add_card(unsigned int port, unsigned irq, list_add(&card->list, &cards); return cinfo->capi_ctrl.cnr; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -175,7 +175,7 @@ int b1pcmcia_delcard(unsigned int port, unsigned irq) { struct list_head *l; avmcard *card; - + list_for_each(l, &cards) { card = list_entry(l, avmcard, list); if (card->port == port && card->irq == irq) { @@ -204,7 +204,7 @@ static int __init b1pcmcia_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c index 9743b24ef9d6..98f18812441d 100644 --- a/drivers/isdn/hardware/avm/c4.c +++ b/drivers/isdn/hardware/avm/c4.c @@ -1,7 +1,7 @@ /* $Id: c4.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $ - * + * * Module for AVM C4 & C2 card. - * + * * Copyright 1999 by Carsten Paeth * * This software may be used and distributed according to the terms @@ -129,8 +129,8 @@ static void c4_dispatch_tx(avmcard *card); /* ------------------------------------------------------------- */ -#define RESET_TIMEOUT (15*HZ) /* 15 sec */ -#define PEEK_POKE_TIMEOUT (HZ/10) /* 0.1 sec */ +#define RESET_TIMEOUT (15 * HZ) /* 15 sec */ +#define PEEK_POKE_TIMEOUT (HZ / 10) /* 0.1 sec */ /* ------------------------------------------------------------- */ @@ -148,7 +148,7 @@ static inline int wait_for_doorbell(avmcard *card, unsigned long t) unsigned long stop; stop = jiffies + t; - while (c4inmeml(card->mbase+DOORBELL) != 0xffffffff) { + while (c4inmeml(card->mbase + DOORBELL) != 0xffffffff) { if (!time_before(jiffies, stop)) return -1; mb(); @@ -159,40 +159,40 @@ static inline int wait_for_doorbell(avmcard *card, unsigned long t) static int c4_poke(avmcard *card, unsigned long off, unsigned long value) { - if (wait_for_doorbell(card, HZ/10) < 0) + if (wait_for_doorbell(card, HZ / 10) < 0) return -1; - - c4outmeml(card->mbase+MBOX_PEEK_POKE, off); - c4outmeml(card->mbase+DOORBELL, DBELL_ADDR); - if (wait_for_doorbell(card, HZ/10) < 0) + c4outmeml(card->mbase + MBOX_PEEK_POKE, off); + c4outmeml(card->mbase + DOORBELL, DBELL_ADDR); + + if (wait_for_doorbell(card, HZ / 10) < 0) return -1; - c4outmeml(card->mbase+MBOX_PEEK_POKE, value); - c4outmeml(card->mbase+DOORBELL, DBELL_DATA | DBELL_ADDR); + c4outmeml(card->mbase + MBOX_PEEK_POKE, value); + c4outmeml(card->mbase + DOORBELL, DBELL_DATA | DBELL_ADDR); return 0; } static int c4_peek(avmcard *card, unsigned long off, unsigned long *valuep) { - if (wait_for_doorbell(card, HZ/10) < 0) + if (wait_for_doorbell(card, HZ / 10) < 0) return -1; - c4outmeml(card->mbase+MBOX_PEEK_POKE, off); - c4outmeml(card->mbase+DOORBELL, DBELL_RNWR | DBELL_ADDR); + c4outmeml(card->mbase + MBOX_PEEK_POKE, off); + c4outmeml(card->mbase + DOORBELL, DBELL_RNWR | DBELL_ADDR); - if (wait_for_doorbell(card, HZ/10) < 0) + if (wait_for_doorbell(card, HZ / 10) < 0) return -1; - *valuep = c4inmeml(card->mbase+MBOX_PEEK_POKE); + *valuep = c4inmeml(card->mbase + MBOX_PEEK_POKE); return 0; } /* ------------------------------------------------------------- */ -static int c4_load_t4file(avmcard *card, capiloaddatapart * t4file) +static int c4_load_t4file(avmcard *card, capiloaddatapart *t4file) { u32 val; unsigned char *dp; @@ -202,7 +202,7 @@ static int c4_load_t4file(avmcard *card, capiloaddatapart * t4file) dp = t4file->data; left = t4file->len; while (left >= sizeof(u32)) { - if (t4file->user) { + if (t4file->user) { if (copy_from_user(&val, dp, sizeof(val))) return -EFAULT; } else { @@ -210,7 +210,7 @@ static int c4_load_t4file(avmcard *card, capiloaddatapart * t4file) } if (c4_poke(card, loadoff, val)) { printk(KERN_ERR "%s: corrupted firmware file ?\n", - card->name); + card->name); return -EIO; } left -= sizeof(u32); @@ -227,7 +227,7 @@ static int c4_load_t4file(avmcard *card, capiloaddatapart * t4file) } if (c4_poke(card, loadoff, val)) { printk(KERN_ERR "%s: corrupted firmware file ?\n", - card->name); + card->name); return -EIO; } } @@ -297,13 +297,13 @@ static void c4_reset(avmcard *card) { unsigned long stop; - c4outmeml(card->mbase+DOORBELL, DBELL_RESET_ARM); + c4outmeml(card->mbase + DOORBELL, DBELL_RESET_ARM); - stop = jiffies + HZ*10; - while (c4inmeml(card->mbase+DOORBELL) != 0xffffffff) { + stop = jiffies + HZ * 10; + while (c4inmeml(card->mbase + DOORBELL) != 0xffffffff) { if (!time_before(jiffies, stop)) return; - c4outmeml(card->mbase+DOORBELL, DBELL_ADDR); + c4outmeml(card->mbase + DOORBELL, DBELL_ADDR); mb(); } @@ -317,89 +317,89 @@ static int c4_detect(avmcard *card) { unsigned long stop, dummy; - c4outmeml(card->mbase+PCI_OUT_INT_MASK, 0x0c); - if (c4inmeml(card->mbase+PCI_OUT_INT_MASK) != 0x0c) + c4outmeml(card->mbase + PCI_OUT_INT_MASK, 0x0c); + if (c4inmeml(card->mbase + PCI_OUT_INT_MASK) != 0x0c) return 1; - c4outmeml(card->mbase+DOORBELL, DBELL_RESET_ARM); + c4outmeml(card->mbase + DOORBELL, DBELL_RESET_ARM); - stop = jiffies + HZ*10; - while (c4inmeml(card->mbase+DOORBELL) != 0xffffffff) { + stop = jiffies + HZ * 10; + while (c4inmeml(card->mbase + DOORBELL) != 0xffffffff) { if (!time_before(jiffies, stop)) return 2; - c4outmeml(card->mbase+DOORBELL, DBELL_ADDR); + c4outmeml(card->mbase + DOORBELL, DBELL_ADDR); mb(); } c4_poke(card, DC21285_ARMCSR_BASE + CHAN_1_CONTROL, 0); c4_poke(card, DC21285_ARMCSR_BASE + CHAN_2_CONTROL, 0); - c4outmeml(card->mbase+MAILBOX_0, 0x55aa55aa); - if (c4inmeml(card->mbase+MAILBOX_0) != 0x55aa55aa) return 3; + c4outmeml(card->mbase + MAILBOX_0, 0x55aa55aa); + if (c4inmeml(card->mbase + MAILBOX_0) != 0x55aa55aa) return 3; - c4outmeml(card->mbase+MAILBOX_0, 0xaa55aa55); - if (c4inmeml(card->mbase+MAILBOX_0) != 0xaa55aa55) return 4; + c4outmeml(card->mbase + MAILBOX_0, 0xaa55aa55); + if (c4inmeml(card->mbase + MAILBOX_0) != 0xaa55aa55) return 4; - if (c4_poke(card, DC21285_ARMCSR_BASE+DBELL_SA_MASK, 0)) return 5; - if (c4_poke(card, DC21285_ARMCSR_BASE+DBELL_PCI_MASK, 0)) return 6; - if (c4_poke(card, DC21285_ARMCSR_BASE+SA_CONTROL, SA_CTL_ALLRIGHT)) + if (c4_poke(card, DC21285_ARMCSR_BASE + DBELL_SA_MASK, 0)) return 5; + if (c4_poke(card, DC21285_ARMCSR_BASE + DBELL_PCI_MASK, 0)) return 6; + if (c4_poke(card, DC21285_ARMCSR_BASE + SA_CONTROL, SA_CTL_ALLRIGHT)) return 7; - if (c4_poke(card, DC21285_ARMCSR_BASE+XBUS_CYCLE, INIT_XBUS_CYCLE)) + if (c4_poke(card, DC21285_ARMCSR_BASE + XBUS_CYCLE, INIT_XBUS_CYCLE)) return 8; - if (c4_poke(card, DC21285_ARMCSR_BASE+XBUS_STROBE, INIT_XBUS_STROBE)) + if (c4_poke(card, DC21285_ARMCSR_BASE + XBUS_STROBE, INIT_XBUS_STROBE)) return 8; - if (c4_poke(card, DC21285_ARMCSR_BASE+DRAM_TIMING, 0)) return 9; + if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_TIMING, 0)) return 9; - mdelay(1); + mdelay(1); if (c4_peek(card, DC21285_DRAM_A0MR, &dummy)) return 10; if (c4_peek(card, DC21285_DRAM_A1MR, &dummy)) return 11; if (c4_peek(card, DC21285_DRAM_A2MR, &dummy)) return 12; if (c4_peek(card, DC21285_DRAM_A3MR, &dummy)) return 13; - if (c4_poke(card, DC21285_DRAM_A0MR+CAS_OFFSET, 0)) return 14; - if (c4_poke(card, DC21285_DRAM_A1MR+CAS_OFFSET, 0)) return 15; - if (c4_poke(card, DC21285_DRAM_A2MR+CAS_OFFSET, 0)) return 16; - if (c4_poke(card, DC21285_DRAM_A3MR+CAS_OFFSET, 0)) return 17; + if (c4_poke(card, DC21285_DRAM_A0MR + CAS_OFFSET, 0)) return 14; + if (c4_poke(card, DC21285_DRAM_A1MR + CAS_OFFSET, 0)) return 15; + if (c4_poke(card, DC21285_DRAM_A2MR + CAS_OFFSET, 0)) return 16; + if (c4_poke(card, DC21285_DRAM_A3MR + CAS_OFFSET, 0)) return 17; - mdelay(1); + mdelay(1); - if (c4_poke(card, DC21285_ARMCSR_BASE+DRAM_TIMING, DRAM_TIMING_DEF)) + if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_TIMING, DRAM_TIMING_DEF)) return 18; - if (c4_poke(card, DC21285_ARMCSR_BASE+DRAM_ADDR_SIZE_0,DRAM_AD_SZ_DEF0)) + if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_0, DRAM_AD_SZ_DEF0)) return 19; - if (c4_poke(card, DC21285_ARMCSR_BASE+DRAM_ADDR_SIZE_1,DRAM_AD_SZ_NULL)) + if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_1, DRAM_AD_SZ_NULL)) return 20; - if (c4_poke(card, DC21285_ARMCSR_BASE+DRAM_ADDR_SIZE_2,DRAM_AD_SZ_NULL)) + if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_2, DRAM_AD_SZ_NULL)) return 21; - if (c4_poke(card, DC21285_ARMCSR_BASE+DRAM_ADDR_SIZE_3,DRAM_AD_SZ_NULL)) + if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_3, DRAM_AD_SZ_NULL)) return 22; /* Transputer test */ - - if ( c4_poke(card, 0x000000, 0x11111111) + + if (c4_poke(card, 0x000000, 0x11111111) || c4_poke(card, 0x400000, 0x22222222) - || c4_poke(card, 0x800000, 0x33333333) - || c4_poke(card, 0xC00000, 0x44444444)) + || c4_poke(card, 0x800000, 0x33333333) + || c4_poke(card, 0xC00000, 0x44444444)) return 23; - if ( c4_peek(card, 0x000000, &dummy) || dummy != 0x11111111 + if (c4_peek(card, 0x000000, &dummy) || dummy != 0x11111111 || c4_peek(card, 0x400000, &dummy) || dummy != 0x22222222 - || c4_peek(card, 0x800000, &dummy) || dummy != 0x33333333 - || c4_peek(card, 0xC00000, &dummy) || dummy != 0x44444444) + || c4_peek(card, 0x800000, &dummy) || dummy != 0x33333333 + || c4_peek(card, 0xC00000, &dummy) || dummy != 0x44444444) return 24; - if ( c4_poke(card, 0x000000, 0x55555555) + if (c4_poke(card, 0x000000, 0x55555555) || c4_poke(card, 0x400000, 0x66666666) - || c4_poke(card, 0x800000, 0x77777777) - || c4_poke(card, 0xC00000, 0x88888888)) + || c4_poke(card, 0x800000, 0x77777777) + || c4_poke(card, 0xC00000, 0x88888888)) return 25; - if ( c4_peek(card, 0x000000, &dummy) || dummy != 0x55555555 + if (c4_peek(card, 0x000000, &dummy) || dummy != 0x55555555 || c4_peek(card, 0x400000, &dummy) || dummy != 0x66666666 - || c4_peek(card, 0x800000, &dummy) || dummy != 0x77777777 - || c4_peek(card, 0xC00000, &dummy) || dummy != 0x88888888) + || c4_peek(card, 0x800000, &dummy) || dummy != 0x77777777 + || c4_peek(card, 0xC00000, &dummy) || dummy != 0x88888888) return 26; return 0; @@ -451,26 +451,26 @@ static void c4_dispatch_tx(avmcard *card) printk(KERN_DEBUG "%s: tx put msg len=%d\n", card->name, txlen); #endif } else { - txlen = skb->len-2; + txlen = skb->len - 2; #ifdef AVM_C4_POLLDEBUG if (skb->data[2] == SEND_POLLACK) printk(KERN_INFO "%s: ack to c4\n", card->name); #endif #ifdef AVM_C4_DEBUG printk(KERN_DEBUG "%s: tx put 0x%x len=%d\n", - card->name, skb->data[2], txlen); + card->name, skb->data[2], txlen); #endif skb_copy_from_linear_data_offset(skb, 2, dma->sendbuf.dmabuf, skb->len - 2); } txlen = (txlen + 3) & ~3; - c4outmeml(card->mbase+MBOX_DOWN_ADDR, dma->sendbuf.dmaaddr); - c4outmeml(card->mbase+MBOX_DOWN_LEN, txlen); + c4outmeml(card->mbase + MBOX_DOWN_ADDR, dma->sendbuf.dmaaddr); + c4outmeml(card->mbase + MBOX_DOWN_LEN, txlen); card->csr |= DBELL_DOWN_ARM; - c4outmeml(card->mbase+DOORBELL, DBELL_DOWN_ARM); + c4outmeml(card->mbase + DOORBELL, DBELL_DOWN_ARM); dev_kfree_skb_any(skb); } @@ -485,7 +485,7 @@ static void queue_pollack(avmcard *card) skb = alloc_skb(3, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost poll ack\n", - card->name); + card->name); return; } p = skb->data; @@ -514,9 +514,9 @@ static void c4_handle_rx(avmcard *card) #ifdef AVM_C4_DEBUG printk(KERN_DEBUG "%s: rx 0x%x len=%lu\n", card->name, - b1cmd, (unsigned long)dma->recvlen); + b1cmd, (unsigned long)dma->recvlen); #endif - + switch (b1cmd) { case RECEIVE_DATA_B3_IND: @@ -528,13 +528,13 @@ static void c4_handle_rx(avmcard *card) ctrl = &card->ctrlinfo[cidx].capi_ctrl; if (MsgLen < 30) { /* not CAPI 64Bit */ - memset(card->msgbuf+MsgLen, 0, 30-MsgLen); + memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); MsgLen = 30; CAPIMSG_SETLEN(card->msgbuf, 30); } - if (!(skb = alloc_skb(DataB3Len+MsgLen, GFP_ATOMIC))) { + if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); @@ -553,7 +553,7 @@ static void c4_handle_rx(avmcard *card) if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) @@ -570,7 +570,7 @@ static void c4_handle_rx(avmcard *card) ApplId = _get_word(&p); NCCI = _get_word(&p); WindowSize = _get_word(&p); - cidx = (NCCI&0x7f) - card->cardnr; + cidx = (NCCI & 0x7f) - card->cardnr; if (cidx >= card->nlogcontr) cidx = 0; capilib_new_ncci(&card->ctrlinfo[cidx].ncci_head, ApplId, NCCI, WindowSize); @@ -583,7 +583,7 @@ static void c4_handle_rx(avmcard *card) NCCI = _get_word(&p); if (NCCI != 0xffffffff) { - cidx = (NCCI&0x7f) - card->cardnr; + cidx = (NCCI & 0x7f) - card->cardnr; if (cidx >= card->nlogcontr) cidx = 0; capilib_free_ncci(&card->ctrlinfo[cidx].ncci_head, ApplId, NCCI); } @@ -595,14 +595,14 @@ static void c4_handle_rx(avmcard *card) #endif if (!suppress_pollack) queue_pollack(card); - for (cidx=0; cidx < card->nr_controllers; cidx++) { + for (cidx = 0; cidx < card->nr_controllers; cidx++) { ctrl = &card->ctrlinfo[cidx].capi_ctrl; capi_ctr_resume_output(ctrl); } break; case RECEIVE_STOP: - for (cidx=0; cidx < card->nr_controllers; cidx++) { + for (cidx = 0; cidx < card->nr_controllers; cidx++) { ctrl = &card->ctrlinfo[cidx].capi_ctrl; capi_ctr_suspend_output(ctrl); } @@ -610,14 +610,14 @@ static void c4_handle_rx(avmcard *card) case RECEIVE_INIT: - cidx = card->nlogcontr; + cidx = card->nlogcontr; if (cidx >= card->nr_controllers) { printk(KERN_ERR "%s: card with %d controllers ??\n", - card->name, cidx+1); + card->name, cidx + 1); break; } - card->nlogcontr++; - cinfo = &card->ctrlinfo[cidx]; + card->nlogcontr++; + cinfo = &card->ctrlinfo[cidx]; ctrl = &cinfo->capi_ctrl; cinfo->versionlen = _get_slice(&p, cinfo->versionbuf); b1_parse_version(cinfo); @@ -632,23 +632,23 @@ static void c4_handle_rx(avmcard *card) ApplId = (unsigned) _get_word(&p); MsgLen = _get_slice(&p, card->msgbuf); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: task %d \"%s\" ready.\n", - card->name, ApplId, card->msgbuf); + card->name, ApplId, card->msgbuf); break; case RECEIVE_DEBUGMSG: MsgLen = _get_slice(&p, card->msgbuf); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); @@ -656,7 +656,7 @@ static void c4_handle_rx(avmcard *card) default: printk(KERN_ERR "%s: c4_interrupt: 0x%x ???\n", - card->name, b1cmd); + card->name, b1cmd); return; } } @@ -669,16 +669,16 @@ static irqreturn_t c4_handle_interrupt(avmcard *card) u32 status; spin_lock_irqsave(&card->lock, flags); - status = c4inmeml(card->mbase+DOORBELL); + status = c4inmeml(card->mbase + DOORBELL); if (status & DBELL_RESET_HOST) { u_int i; - c4outmeml(card->mbase+PCI_OUT_INT_MASK, 0x0c); + c4outmeml(card->mbase + PCI_OUT_INT_MASK, 0x0c); spin_unlock_irqrestore(&card->lock, flags); if (card->nlogcontr == 0) return IRQ_HANDLED; printk(KERN_ERR "%s: unexpected reset\n", card->name); - for (i=0; i < card->nr_controllers; i++) { + for (i = 0; i < card->nr_controllers; i++) { avmctrl_info *cinfo = &card->ctrlinfo[i]; memset(cinfo->version, 0, sizeof(cinfo->version)); spin_lock_irqsave(&card->lock, flags); @@ -695,23 +695,23 @@ static irqreturn_t c4_handle_interrupt(avmcard *card) spin_unlock_irqrestore(&card->lock, flags); return IRQ_HANDLED; } - c4outmeml(card->mbase+DOORBELL, status); + c4outmeml(card->mbase + DOORBELL, status); if ((status & DBELL_UP_HOST) != 0) { - card->dma->recvlen = c4inmeml(card->mbase+MBOX_UP_LEN); - c4outmeml(card->mbase+MBOX_UP_LEN, 0); + card->dma->recvlen = c4inmeml(card->mbase + MBOX_UP_LEN); + c4outmeml(card->mbase + MBOX_UP_LEN, 0); c4_handle_rx(card); card->dma->recvlen = 0; - c4outmeml(card->mbase+MBOX_UP_LEN, card->dma->recvbuf.size); - c4outmeml(card->mbase+DOORBELL, DBELL_UP_ARM); + c4outmeml(card->mbase + MBOX_UP_LEN, card->dma->recvbuf.size); + c4outmeml(card->mbase + DOORBELL, DBELL_UP_ARM); } if ((status & DBELL_DOWN_HOST) != 0) { card->csr &= ~DBELL_DOWN_ARM; - c4_dispatch_tx(card); + c4_dispatch_tx(card); } else if (card->csr & DBELL_DOWN_HOST) { - if (c4inmeml(card->mbase+MBOX_DOWN_LEN) == 0) { - card->csr &= ~DBELL_DOWN_ARM; + if (c4inmeml(card->mbase + MBOX_DOWN_LEN) == 0) { + card->csr &= ~DBELL_DOWN_ARM; c4_dispatch_tx(card); } } @@ -737,7 +737,7 @@ static void c4_send_init(avmcard *card) skb = alloc_skb(15, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost register appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -745,7 +745,7 @@ static void c4_send_init(avmcard *card) _put_byte(&p, 0); _put_byte(&p, SEND_INIT); _put_word(&p, CAPI_MAXAPPL); - _put_word(&p, AVM_NCCI_PER_CHANNEL*30); + _put_word(&p, AVM_NCCI_PER_CHANNEL * 30); _put_word(&p, card->cardnr - 1); skb_put(skb, (u8 *)p - (u8 *)skb->data); @@ -761,10 +761,10 @@ static int queue_sendconfigword(avmcard *card, u32 val) unsigned long flags; void *p; - skb = alloc_skb(3+4, GFP_ATOMIC); + skb = alloc_skb(3 + 4, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, send config\n", - card->name); + card->name); return -ENOMEM; } p = skb->data; @@ -787,10 +787,10 @@ static int queue_sendconfig(avmcard *card, char cval[4]) unsigned long flags; void *p; - skb = alloc_skb(3+4, GFP_ATOMIC); + skb = alloc_skb(3 + 4, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, send config\n", - card->name); + card->name); return -ENOMEM; } p = skb->data; @@ -804,20 +804,20 @@ static int queue_sendconfig(avmcard *card, char cval[4]) skb_put(skb, (u8 *)p - (u8 *)skb->data); skb_queue_tail(&card->dma->send_queue, skb); - + spin_lock_irqsave(&card->lock, flags); c4_dispatch_tx(card); spin_unlock_irqrestore(&card->lock, flags); return 0; } -static int c4_send_config(avmcard *card, capiloaddatapart * config) +static int c4_send_config(avmcard *card, capiloaddatapart *config) { u8 val[4]; unsigned char *dp; u_int left; int retval; - + if ((retval = queue_sendconfigword(card, 1)) != 0) return retval; if ((retval = queue_sendconfigword(card, config->len)) != 0) @@ -826,7 +826,7 @@ static int c4_send_config(avmcard *card, capiloaddatapart * config) dp = config->data; left = config->len; while (left >= sizeof(u32)) { - if (config->user) { + if (config->user) { if (copy_from_user(val, dp, sizeof(val))) return -EFAULT; } else { @@ -860,37 +860,37 @@ static int c4_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = c4_load_t4file(card, &data->firmware))) { printk(KERN_ERR "%s: failed to load t4file!!\n", - card->name); + card->name); c4_reset(card); return retval; } card->csr = 0; - c4outmeml(card->mbase+MBOX_UP_LEN, 0); - c4outmeml(card->mbase+MBOX_DOWN_LEN, 0); - c4outmeml(card->mbase+DOORBELL, DBELL_INIT); + c4outmeml(card->mbase + MBOX_UP_LEN, 0); + c4outmeml(card->mbase + MBOX_DOWN_LEN, 0); + c4outmeml(card->mbase + DOORBELL, DBELL_INIT); mdelay(1); - c4outmeml(card->mbase+DOORBELL, - DBELL_UP_HOST | DBELL_DOWN_HOST | DBELL_RESET_HOST); + c4outmeml(card->mbase + DOORBELL, + DBELL_UP_HOST | DBELL_DOWN_HOST | DBELL_RESET_HOST); - c4outmeml(card->mbase+PCI_OUT_INT_MASK, 0x08); + c4outmeml(card->mbase + PCI_OUT_INT_MASK, 0x08); card->dma->recvlen = 0; - c4outmeml(card->mbase+MBOX_UP_ADDR, card->dma->recvbuf.dmaaddr); - c4outmeml(card->mbase+MBOX_UP_LEN, card->dma->recvbuf.size); - c4outmeml(card->mbase+DOORBELL, DBELL_UP_ARM); + c4outmeml(card->mbase + MBOX_UP_ADDR, card->dma->recvbuf.dmaaddr); + c4outmeml(card->mbase + MBOX_UP_LEN, card->dma->recvbuf.size); + c4outmeml(card->mbase + DOORBELL, DBELL_UP_ARM); if (data->configuration.len > 0 && data->configuration.data) { retval = c4_send_config(card, &data->configuration); if (retval) { printk(KERN_ERR "%s: failed to set config!!\n", - card->name); + card->name); c4_reset(card); return retval; } } - c4_send_init(card); + c4_send_init(card); return 0; } @@ -905,11 +905,11 @@ static void c4_reset_ctr(struct capi_ctr *ctrl) spin_lock_irqsave(&card->lock, flags); - c4_reset(card); + c4_reset(card); spin_unlock_irqrestore(&card->lock, flags); - for (i=0; i < card->nr_controllers; i++) { + for (i = 0; i < card->nr_controllers; i++) { cinfo = &card->ctrlinfo[i]; memset(cinfo->version, 0, sizeof(cinfo->version)); capi_ctr_down(&cinfo->capi_ctrl); @@ -926,9 +926,9 @@ static void c4_remove(struct pci_dev *pdev) if (!card) return; - c4_reset(card); + c4_reset(card); - for (i=0; i < card->nr_controllers; i++) { + for (i = 0; i < card->nr_controllers; i++) { cinfo = &card->ctrlinfo[i]; detach_capi_ctr(&cinfo->capi_ctrl); } @@ -936,8 +936,8 @@ static void c4_remove(struct pci_dev *pdev) free_irq(card->irq, card); iounmap(card->mbase); release_region(card->port, AVMB1_PORTLEN); - avmcard_dma_free(card->dma); - pci_set_drvdata(pdev, NULL); + avmcard_dma_free(card->dma); + pci_set_drvdata(pdev, NULL); b1_free_card(card); } @@ -945,8 +945,8 @@ static void c4_remove(struct pci_dev *pdev) static void c4_register_appl(struct capi_ctr *ctrl, - u16 appl, - capi_register_params *rp) + u16 appl, + capi_register_params *rp) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; @@ -965,7 +965,7 @@ static void c4_register_appl(struct capi_ctr *ctrl, skb = alloc_skb(23, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost register appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -973,14 +973,14 @@ static void c4_register_appl(struct capi_ctr *ctrl, _put_byte(&p, 0); _put_byte(&p, SEND_REGISTER); _put_word(&p, appl); - _put_word(&p, 1024 * (nconn+1)); + _put_word(&p, 1024 * (nconn + 1)); _put_word(&p, nconn); _put_word(&p, rp->datablkcnt); _put_word(&p, rp->datablklen); skb_put(skb, (u8 *)p - (u8 *)skb->data); skb_queue_tail(&card->dma->send_queue, skb); - + spin_lock_irqsave(&card->lock, flags); c4_dispatch_tx(card); spin_unlock_irqrestore(&card->lock, flags); @@ -1005,7 +1005,7 @@ static void c4_release_appl(struct capi_ctr *ctrl, u16 appl) skb = alloc_skb(7, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost release appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -1098,29 +1098,29 @@ static int c4_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "ver_serial", s); if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[3]; - if (flag) + flag = ((u8 *)(ctrl->profile.manu))[3]; + if (flag) seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", - "protocol", - (flag & 0x01) ? " DSS1" : "", - (flag & 0x02) ? " CT1" : "", - (flag & 0x04) ? " VN3" : "", - (flag & 0x08) ? " NI1" : "", - (flag & 0x10) ? " AUSTEL" : "", - (flag & 0x20) ? " ESS" : "", - (flag & 0x40) ? " 1TR6" : "" - ); + "protocol", + (flag & 0x01) ? " DSS1" : "", + (flag & 0x02) ? " CT1" : "", + (flag & 0x04) ? " VN3" : "", + (flag & 0x08) ? " NI1" : "", + (flag & 0x10) ? " AUSTEL" : "", + (flag & 0x20) ? " ESS" : "", + (flag & 0x40) ? " 1TR6" : "" + ); } if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[5]; + flag = ((u8 *)(ctrl->profile.manu))[5]; if (flag) seq_printf(m, "%-16s%s%s%s%s\n", - "linetype", - (flag & 0x01) ? " point to point" : "", - (flag & 0x02) ? " point to multipoint" : "", - (flag & 0x08) ? " leased line without D-channel" : "", - (flag & 0x04) ? " leased line with D-channel" : "" - ); + "linetype", + (flag & 0x01) ? " point to point" : "", + (flag & 0x02) ? " point to multipoint" : "", + (flag & 0x08) ? " leased line without D-channel" : "", + (flag & 0x04) ? " leased line with D-channel" : "" + ); } seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname); @@ -1156,7 +1156,7 @@ static int c4_add_card(struct capicardparams *p, struct pci_dev *dev, retval = -ENOMEM; goto err; } - card->dma = avmcard_dma_alloc("c4", dev, 2048+128, 2048+128); + card->dma = avmcard_dma_alloc("c4", dev, 2048 + 128, 2048 + 128); if (!card->dma) { printk(KERN_WARNING "c4: no memory.\n"); retval = -ENOMEM; @@ -1195,12 +1195,12 @@ static int c4_add_card(struct capicardparams *p, struct pci_dev *dev, retval = request_irq(card->irq, c4_interrupt, IRQF_SHARED, card->name, card); if (retval) { - printk(KERN_ERR "c4: unable to get IRQ %d.\n",card->irq); + printk(KERN_ERR "c4: unable to get IRQ %d.\n", card->irq); retval = -EBUSY; goto err_unmap; } - for (i=0; i < nr_controllers ; i++) { + for (i = 0; i < nr_controllers; i++) { cinfo = &card->ctrlinfo[i]; cinfo->capi_ctrl.owner = THIS_MODULE; cinfo->capi_ctrl.driver_name = "c4"; @@ -1233,17 +1233,17 @@ static int c4_add_card(struct capicardparams *p, struct pci_dev *dev, pci_set_drvdata(dev, card); return 0; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_unmap: +err_unmap: iounmap(card->mbase); - err_release_region: +err_release_region: release_region(card->port, AVMB1_PORTLEN); - err_free_dma: +err_free_dma: avmcard_dma_free(card->dma); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -1265,10 +1265,10 @@ static int __devinit c4_probe(struct pci_dev *dev, param.port = pci_resource_start(dev, 1); param.irq = dev->irq; param.membase = pci_resource_start(dev, 0); - + printk(KERN_INFO "c4: PCI BIOS reports AVM-C%d at i/o %#x, irq %d, mem %#x\n", nr, param.port, param.irq, param.membase); - + retval = c4_add_card(¶m, dev, nr); if (retval != 0) { printk(KERN_ERR "c4: no AVM-C%d at i/o %#x, irq %d detected, mem %#x\n", @@ -1280,10 +1280,10 @@ static int __devinit c4_probe(struct pci_dev *dev, } static struct pci_driver c4_pci_driver = { - .name = "c4", - .id_table = c4_pci_tbl, - .probe = c4_probe, - .remove = c4_remove, + .name = "c4", + .id_table = c4_pci_tbl, + .probe = c4_probe, + .remove = c4_remove, }; static struct capi_driver capi_driver_c2 = { @@ -1305,7 +1305,7 @@ static int __init c4_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c index 08216b14be13..72ef18853951 100644 --- a/drivers/isdn/hardware/avm/t1isa.c +++ b/drivers/isdn/hardware/avm/t1isa.c @@ -1,9 +1,9 @@ /* $Id: t1isa.c,v 1.1.2.3 2004/02/10 01:07:12 keil Exp $ - * + * * Module for AVM T1 HEMA-card. - * + * * Copyright 1999 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -67,7 +67,7 @@ static int t1_detectandinit(unsigned int base, unsigned irq, int cardnr) int i; reverse_cardnr = ((cardnr & 0x01) << 3) | ((cardnr & 0x02) << 1) - | ((cardnr & 0x04) >> 1) | ((cardnr & 0x08) >> 3); + | ((cardnr & 0x04) >> 1) | ((cardnr & 0x08) >> 3); cregs[0] = (HEMA_VERSION_ID << 4) | (reverse_cardnr & 0xf); cregs[1] = 0x00; /* fast & slow link connected to CON1 */ cregs[2] = 0x05; /* fast link 20MBit, slow link 20 MBit */ @@ -86,50 +86,50 @@ static int t1_detectandinit(unsigned int base, unsigned irq, int cardnr) /* board reset */ t1outp(base, T1_RESETBOARD, 0xf); mdelay(100); - dummy = t1inp(base, T1_FASTLINK+T1_OUTSTAT); /* first read */ + dummy = t1inp(base, T1_FASTLINK + T1_OUTSTAT); /* first read */ /* write config */ dummy = (base >> 4) & 0xff; - for (i=1;i<=0xf;i++) t1outp(base, i, dummy); + for (i = 1; i <= 0xf; i++) t1outp(base, i, dummy); t1outp(base, HEMA_PAL_ID & 0xf, dummy); t1outp(base, HEMA_PAL_ID >> 4, cregs[0]); - for(i=1;i<7;i++) t1outp(base, 0, cregs[i]); + for (i = 1; i < 7; i++) t1outp(base, 0, cregs[i]); t1outp(base, ((base >> 4)) & 0x3, cregs[7]); /* restore_flags(flags); */ mdelay(100); - t1outp(base, T1_FASTLINK+T1_RESETLINK, 0); - t1outp(base, T1_SLOWLINK+T1_RESETLINK, 0); + t1outp(base, T1_FASTLINK + T1_RESETLINK, 0); + t1outp(base, T1_SLOWLINK + T1_RESETLINK, 0); mdelay(10); - t1outp(base, T1_FASTLINK+T1_RESETLINK, 1); - t1outp(base, T1_SLOWLINK+T1_RESETLINK, 1); + t1outp(base, T1_FASTLINK + T1_RESETLINK, 1); + t1outp(base, T1_SLOWLINK + T1_RESETLINK, 1); mdelay(100); - t1outp(base, T1_FASTLINK+T1_RESETLINK, 0); - t1outp(base, T1_SLOWLINK+T1_RESETLINK, 0); + t1outp(base, T1_FASTLINK + T1_RESETLINK, 0); + t1outp(base, T1_SLOWLINK + T1_RESETLINK, 0); mdelay(10); - t1outp(base, T1_FASTLINK+T1_ANALYSE, 0); + t1outp(base, T1_FASTLINK + T1_ANALYSE, 0); mdelay(5); - t1outp(base, T1_SLOWLINK+T1_ANALYSE, 0); + t1outp(base, T1_SLOWLINK + T1_ANALYSE, 0); - if (t1inp(base, T1_FASTLINK+T1_OUTSTAT) != 0x1) /* tx empty */ + if (t1inp(base, T1_FASTLINK + T1_OUTSTAT) != 0x1) /* tx empty */ return 1; - if (t1inp(base, T1_FASTLINK+T1_INSTAT) != 0x0) /* rx empty */ + if (t1inp(base, T1_FASTLINK + T1_INSTAT) != 0x0) /* rx empty */ return 2; - if (t1inp(base, T1_FASTLINK+T1_IRQENABLE) != 0x0) + if (t1inp(base, T1_FASTLINK + T1_IRQENABLE) != 0x0) return 3; - if ((t1inp(base, T1_FASTLINK+T1_FIFOSTAT) & 0xf0) != 0x70) + if ((t1inp(base, T1_FASTLINK + T1_FIFOSTAT) & 0xf0) != 0x70) return 4; - if ((t1inp(base, T1_FASTLINK+T1_IRQMASTER) & 0x0e) != 0) + if ((t1inp(base, T1_FASTLINK + T1_IRQMASTER) & 0x0e) != 0) return 5; - if ((t1inp(base, T1_FASTLINK+T1_IDENT) & 0x7d) != 1) + if ((t1inp(base, T1_FASTLINK + T1_IDENT) & 0x7d) != 1) return 6; - if (t1inp(base, T1_SLOWLINK+T1_OUTSTAT) != 0x1) /* tx empty */ + if (t1inp(base, T1_SLOWLINK + T1_OUTSTAT) != 0x1) /* tx empty */ return 7; - if ((t1inp(base, T1_SLOWLINK+T1_IRQMASTER) & 0x0e) != 0) + if ((t1inp(base, T1_SLOWLINK + T1_IRQMASTER) & 0x0e) != 0) return 8; - if ((t1inp(base, T1_SLOWLINK+T1_IDENT) & 0x7d) != 0) + if ((t1inp(base, T1_SLOWLINK + T1_IDENT) & 0x7d) != 0) return 9; - return 0; + return 0; } static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) @@ -163,13 +163,13 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) spin_unlock_irqrestore(&card->lock, flags); if (MsgLen < 30) { /* not CAPI 64Bit */ - memset(card->msgbuf+MsgLen, 0, 30-MsgLen); + memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); MsgLen = 30; CAPIMSG_SETLEN(card->msgbuf, 30); } - if (!(skb = alloc_skb(DataB3Len+MsgLen, GFP_ATOMIC))) { + if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); @@ -184,7 +184,7 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { spin_unlock_irqrestore(&card->lock, flags); printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3) @@ -242,24 +242,24 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) MsgLen = t1_get_slice(card->port, card->msgbuf); spin_unlock_irqrestore(&card->lock, flags); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: task %d \"%s\" ready.\n", - card->name, ApplId, card->msgbuf); + card->name, ApplId, card->msgbuf); break; case RECEIVE_DEBUGMSG: MsgLen = t1_get_slice(card->port, card->msgbuf); spin_unlock_irqrestore(&card->lock, flags); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); @@ -273,7 +273,7 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) default: spin_unlock_irqrestore(&card->lock, flags); printk(KERN_ERR "%s: b1_interrupt: 0x%x ???\n", - card->name, b1cmd); + card->name, b1cmd); return IRQ_NONE; } } @@ -296,7 +296,7 @@ static int t1isa_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_t4file(card, &data->firmware))) { b1_reset(port); printk(KERN_ERR "%s: failed to load t4file!!\n", - card->name); + card->name); return retval; } @@ -304,7 +304,7 @@ static int t1isa_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_config(card, &data->configuration))) { b1_reset(port); printk(KERN_ERR "%s: failed to load config!!\n", - card->name); + card->name); return retval; } } @@ -318,7 +318,7 @@ static int t1isa_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) b1_setinterrupt(port, card->irq, card->cardtype); b1_put_byte(port, SEND_INIT); b1_put_word(port, CAPI_MAXAPPL); - b1_put_word(port, AVM_NCCI_PER_CHANNEL*30); + b1_put_word(port, AVM_NCCI_PER_CHANNEL * 30); b1_put_word(port, ctrl->cnr - 1); spin_unlock_irqrestore(&card->lock, flags); @@ -347,7 +347,7 @@ static void t1isa_remove(struct pci_dev *pdev) { avmctrl_info *cinfo = pci_get_drvdata(pdev); avmcard *card; - + if (!cinfo) return; @@ -393,7 +393,7 @@ static int t1isa_probe(struct pci_dev *pdev, int cardnr) printk(KERN_WARNING "t1isa: invalid port 0x%x.\n", card->port); retval = -EINVAL; goto err_free; - } + } if (hema_irq_table[card->irq & 0xf] == 0) { printk(KERN_WARNING "t1isa: irq %d not valid.\n", card->irq); retval = -EINVAL; @@ -412,7 +412,7 @@ static int t1isa_probe(struct pci_dev *pdev, int cardnr) goto err_release_region; } - if ((retval = t1_detectandinit(card->port, card->irq, card->cardnr)) != 0) { + if ((retval = t1_detectandinit(card->port, card->irq, card->cardnr)) != 0) { printk(KERN_INFO "t1isa: NO card at 0x%x (%d)\n", card->port, retval); retval = -ENODEV; @@ -445,13 +445,13 @@ static int t1isa_probe(struct pci_dev *pdev, int cardnr) pci_set_drvdata(pdev, cinfo); return 0; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_release_region: +err_release_region: release_region(card->port, AVMB1_PORTLEN); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -555,7 +555,7 @@ static int __init t1isa_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/avm/t1pci.c b/drivers/isdn/hardware/avm/t1pci.c index a79eb5afb92d..cb9a30427bd2 100644 --- a/drivers/isdn/hardware/avm/t1pci.c +++ b/drivers/isdn/hardware/avm/t1pci.c @@ -1,9 +1,9 @@ /* $Id: t1pci.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $ - * + * * Module for AVM T1 PCI-card. - * + * * Copyright 1999 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -59,7 +59,7 @@ static int t1pci_add_card(struct capicardparams *p, struct pci_dev *pdev) goto err; } - card->dma = avmcard_dma_alloc("t1pci", pdev, 2048+128, 2048+128); + card->dma = avmcard_dma_alloc("t1pci", pdev, 2048 + 128, 2048 + 128); if (!card->dma) { printk(KERN_WARNING "t1pci: no memory.\n"); retval = -ENOMEM; @@ -136,17 +136,17 @@ static int t1pci_add_card(struct capicardparams *p, struct pci_dev *pdev) pci_set_drvdata(pdev, card); return 0; - err_free_irq: +err_free_irq: free_irq(card->irq, card); - err_unmap: +err_unmap: iounmap(card->mbase); - err_release_region: +err_release_region: release_region(card->port, AVMB1_PORTLEN); - err_free_dma: +err_free_dma: avmcard_dma_free(card->dma); - err_free: +err_free: b1_free_card(card); - err: +err: return retval; } @@ -157,7 +157,7 @@ static void t1pci_remove(struct pci_dev *pdev) avmcard *card = pci_get_drvdata(pdev); avmctrl_info *cinfo = card->ctrlinfo; - b1dma_reset(card); + b1dma_reset(card); detach_capi_ctr(&cinfo->capi_ctrl); free_irq(card->irq, card); @@ -217,10 +217,10 @@ static int __devinit t1pci_probe(struct pci_dev *dev, } static struct pci_driver t1pci_pci_driver = { - .name = "t1pci", - .id_table = t1pci_pci_tbl, - .probe = t1pci_probe, - .remove = t1pci_remove, + .name = "t1pci", + .id_table = t1pci_pci_tbl, + .probe = t1pci_probe, + .remove = t1pci_remove, }; static struct capi_driver capi_driver_t1pci = { @@ -237,7 +237,7 @@ static int __init t1pci_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, 32); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); diff --git a/drivers/isdn/hardware/eicon/capi20.h b/drivers/isdn/hardware/eicon/capi20.h index 27ecd61888de..391e4175b0b5 100644 --- a/drivers/isdn/hardware/eicon/capi20.h +++ b/drivers/isdn/hardware/eicon/capi20.h @@ -1,74 +1,74 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#ifndef _INC_CAPI20 +#ifndef _INC_CAPI20 #define _INC_CAPI20 - /* operations on message queues */ - /* the common device type for CAPI20 drivers */ +/* operations on message queues */ +/* the common device type for CAPI20 drivers */ #define FILE_DEVICE_CAPI20 0x8001 - /* DEVICE_CONTROL codes for user and kernel mode applications */ +/* DEVICE_CONTROL codes for user and kernel mode applications */ #define CAPI20_CTL_REGISTER 0x0801 #define CAPI20_CTL_RELEASE 0x0802 #define CAPI20_CTL_GET_MANUFACTURER 0x0805 #define CAPI20_CTL_GET_VERSION 0x0806 #define CAPI20_CTL_GET_SERIAL 0x0807 #define CAPI20_CTL_GET_PROFILE 0x0808 - /* INTERNAL_DEVICE_CONTROL codes for kernel mode applicatios only */ +/* INTERNAL_DEVICE_CONTROL codes for kernel mode applicatios only */ #define CAPI20_CTL_PUT_MESSAGE 0x0803 #define CAPI20_CTL_GET_MESSAGE 0x0804 - /* the wrapped codes as required by the system */ -#define CAPI_CTL_CODE(f,m) CTL_CODE(FILE_DEVICE_CAPI20,f,m,FILE_ANY_ACCESS) -#define IOCTL_CAPI_REGISTER CAPI_CTL_CODE(CAPI20_CTL_REGISTER,METHOD_BUFFERED) -#define IOCTL_CAPI_RELEASE CAPI_CTL_CODE(CAPI20_CTL_RELEASE,METHOD_BUFFERED) -#define IOCTL_CAPI_GET_MANUFACTURER CAPI_CTL_CODE(CAPI20_CTL_GET_MANUFACTURER,METHOD_BUFFERED) -#define IOCTL_CAPI_GET_VERSION CAPI_CTL_CODE(CAPI20_CTL_GET_VERSION,METHOD_BUFFERED) -#define IOCTL_CAPI_GET_SERIAL CAPI_CTL_CODE(CAPI20_CTL_GET_SERIAL,METHOD_BUFFERED) -#define IOCTL_CAPI_GET_PROFILE CAPI_CTL_CODE(CAPI20_CTL_GET_PROFILE,METHOD_BUFFERED) -#define IOCTL_CAPI_PUT_MESSAGE CAPI_CTL_CODE(CAPI20_CTL_PUT_MESSAGE,METHOD_BUFFERED) -#define IOCTL_CAPI_GET_MESSAGE CAPI_CTL_CODE(CAPI20_CTL_GET_MESSAGE,METHOD_BUFFERED) +/* the wrapped codes as required by the system */ +#define CAPI_CTL_CODE(f, m) CTL_CODE(FILE_DEVICE_CAPI20, f, m, FILE_ANY_ACCESS) +#define IOCTL_CAPI_REGISTER CAPI_CTL_CODE(CAPI20_CTL_REGISTER, METHOD_BUFFERED) +#define IOCTL_CAPI_RELEASE CAPI_CTL_CODE(CAPI20_CTL_RELEASE, METHOD_BUFFERED) +#define IOCTL_CAPI_GET_MANUFACTURER CAPI_CTL_CODE(CAPI20_CTL_GET_MANUFACTURER, METHOD_BUFFERED) +#define IOCTL_CAPI_GET_VERSION CAPI_CTL_CODE(CAPI20_CTL_GET_VERSION, METHOD_BUFFERED) +#define IOCTL_CAPI_GET_SERIAL CAPI_CTL_CODE(CAPI20_CTL_GET_SERIAL, METHOD_BUFFERED) +#define IOCTL_CAPI_GET_PROFILE CAPI_CTL_CODE(CAPI20_CTL_GET_PROFILE, METHOD_BUFFERED) +#define IOCTL_CAPI_PUT_MESSAGE CAPI_CTL_CODE(CAPI20_CTL_PUT_MESSAGE, METHOD_BUFFERED) +#define IOCTL_CAPI_GET_MESSAGE CAPI_CTL_CODE(CAPI20_CTL_GET_MESSAGE, METHOD_BUFFERED) struct divas_capi_register_params { - word MessageBufferSize; - word maxLogicalConnection; - word maxBDataBlocks; - word maxBDataLen; + word MessageBufferSize; + word maxLogicalConnection; + word maxBDataBlocks; + word maxBDataLen; }; struct divas_capi_version { - word CapiMajor; - word CapiMinor; - word ManuMajor; - word ManuMinor; + word CapiMajor; + word CapiMinor; + word ManuMajor; + word ManuMinor; }; typedef struct api_profile_s { - word Number; - word Channels; - dword Global_Options; - dword B1_Protocols; - dword B2_Protocols; - dword B3_Protocols; + word Number; + word Channels; + dword Global_Options; + dword B1_Protocols; + dword B2_Protocols; + dword B3_Protocols; } API_PROFILE; - /* ISDN Common API message types */ +/* ISDN Common API message types */ #define _ALERT_R 0x8001 #define _CONNECT_R 0x8002 #define _CONNECT_I 0x8202 @@ -93,9 +93,9 @@ typedef struct api_profile_s { #define _CONNECT_B3_T90_ACTIVE_I 0x8288 #define _MANUFACTURER_R 0x80ff #define _MANUFACTURER_I 0x82ff - /* OR this to convert a REQUEST to a CONFIRM */ +/* OR this to convert a REQUEST to a CONFIRM */ #define CONFIRM 0x0100 - /* OR this to convert a INDICATION to a RESPONSE */ +/* OR this to convert a INDICATION to a RESPONSE */ #define RESPONSE 0x0100 /*------------------------------------------------------------------*/ /* diehl isdn private MANUFACTURER codes */ @@ -115,248 +115,248 @@ typedef struct api_profile_s { /*------------------------------------------------------------------*/ /* parameter structures */ /*------------------------------------------------------------------*/ - /* ALERT-REQUEST */ +/* ALERT-REQUEST */ typedef struct { - byte structs[0]; /* Additional Info */ + byte structs[0]; /* Additional Info */ } _ALT_REQP; - /* ALERT-CONFIRM */ +/* ALERT-CONFIRM */ typedef struct { - word Info; + word Info; } _ALT_CONP; - /* CONNECT-REQUEST */ -typedef struct { - word CIP_Value; - byte structs[0]; /* Called party number, - Called party subaddress, - Calling party number, - Calling party subaddress, - B_protocol, - BC, - LLC, - HLC, - Additional Info */ +/* CONNECT-REQUEST */ +typedef struct { + word CIP_Value; + byte structs[0]; /* Called party number, + Called party subaddress, + Calling party number, + Calling party subaddress, + B_protocol, + BC, + LLC, + HLC, + Additional Info */ } _CON_REQP; - /* CONNECT-CONFIRM */ +/* CONNECT-CONFIRM */ typedef struct { - word Info; + word Info; } _CON_CONP; - /* CONNECT-INDICATION */ -typedef struct { - word CIP_Value; - byte structs[0]; /* Called party number, - Called party subaddress, - Calling party number, - Calling party subaddress, - BC, - LLC, - HLC, - Additional Info */ +/* CONNECT-INDICATION */ +typedef struct { + word CIP_Value; + byte structs[0]; /* Called party number, + Called party subaddress, + Calling party number, + Calling party subaddress, + BC, + LLC, + HLC, + Additional Info */ } _CON_INDP; - /* CONNECT-RESPONSE */ +/* CONNECT-RESPONSE */ typedef struct { - word Accept; - byte structs[0]; /* B_protocol, - Connected party number, - Connected party subaddress, - LLC */ + word Accept; + byte structs[0]; /* B_protocol, + Connected party number, + Connected party subaddress, + LLC */ } _CON_RESP; - /* CONNECT-ACTIVE-INDICATION */ +/* CONNECT-ACTIVE-INDICATION */ typedef struct { - byte structs[0]; /* Connected party number, - Connected party subaddress, - LLC */ + byte structs[0]; /* Connected party number, + Connected party subaddress, + LLC */ } _CON_A_INDP; - /* CONNECT-ACTIVE-RESPONSE */ +/* CONNECT-ACTIVE-RESPONSE */ typedef struct { - byte structs[0]; /* empty */ + byte structs[0]; /* empty */ } _CON_A_RESP; - /* DISCONNECT-REQUEST */ +/* DISCONNECT-REQUEST */ typedef struct { - byte structs[0]; /* Additional Info */ + byte structs[0]; /* Additional Info */ } _DIS_REQP; - /* DISCONNECT-CONFIRM */ +/* DISCONNECT-CONFIRM */ typedef struct { - word Info; + word Info; } _DIS_CONP; - /* DISCONNECT-INDICATION */ +/* DISCONNECT-INDICATION */ typedef struct { - word Info; + word Info; } _DIS_INDP; - /* DISCONNECT-RESPONSE */ +/* DISCONNECT-RESPONSE */ typedef struct { - byte structs[0]; /* empty */ + byte structs[0]; /* empty */ } _DIS_RESP; - /* LISTEN-REQUEST */ +/* LISTEN-REQUEST */ typedef struct { - dword Info_Mask; - dword CIP_Mask; - byte structs[0]; /* Calling party number, - Calling party subaddress */ + dword Info_Mask; + dword CIP_Mask; + byte structs[0]; /* Calling party number, + Calling party subaddress */ } _LIS_REQP; - /* LISTEN-CONFIRM */ +/* LISTEN-CONFIRM */ typedef struct { - word Info; + word Info; } _LIS_CONP; - /* INFO-REQUEST */ +/* INFO-REQUEST */ typedef struct { - byte structs[0]; /* Called party number, - Additional Info */ + byte structs[0]; /* Called party number, + Additional Info */ } _INF_REQP; - /* INFO-CONFIRM */ +/* INFO-CONFIRM */ typedef struct { - word Info; + word Info; } _INF_CONP; - /* INFO-INDICATION */ +/* INFO-INDICATION */ typedef struct { - word Number; - byte structs[0]; /* Info element */ + word Number; + byte structs[0]; /* Info element */ } _INF_INDP; - /* INFO-RESPONSE */ +/* INFO-RESPONSE */ typedef struct { - byte structs[0]; /* empty */ + byte structs[0]; /* empty */ } _INF_RESP; - /* SELECT-B-REQUEST */ +/* SELECT-B-REQUEST */ typedef struct { - byte structs[0]; /* B-protocol */ + byte structs[0]; /* B-protocol */ } _SEL_B_REQP; - /* SELECT-B-CONFIRM */ +/* SELECT-B-CONFIRM */ typedef struct { - word Info; + word Info; } _SEL_B_CONP; - /* FACILITY-REQUEST */ +/* FACILITY-REQUEST */ typedef struct { - word Selector; - byte structs[0]; /* Facility parameters */ + word Selector; + byte structs[0]; /* Facility parameters */ } _FAC_REQP; - /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */ +/* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */ typedef struct { - byte struct_length; - word function; - byte length; - word SupplementaryServiceInfo; - dword SupportedServices; + byte struct_length; + word function; + byte length; + word SupplementaryServiceInfo; + dword SupportedServices; } _FAC_CON_STRUCTS; - /* FACILITY-CONFIRM */ +/* FACILITY-CONFIRM */ typedef struct { - word Info; - word Selector; - byte structs[0]; /* Facility parameters */ + word Info; + word Selector; + byte structs[0]; /* Facility parameters */ } _FAC_CONP; - /* FACILITY-INDICATION */ +/* FACILITY-INDICATION */ typedef struct { - word Selector; - byte structs[0]; /* Facility parameters */ + word Selector; + byte structs[0]; /* Facility parameters */ } _FAC_INDP; - /* FACILITY-RESPONSE */ +/* FACILITY-RESPONSE */ typedef struct { - word Selector; - byte structs[0]; /* Facility parameters */ + word Selector; + byte structs[0]; /* Facility parameters */ } _FAC_RESP; - /* CONNECT-B3-REQUEST */ +/* CONNECT-B3-REQUEST */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_REQP; - /* CONNECT-B3-CONFIRM */ +/* CONNECT-B3-CONFIRM */ typedef struct { - word Info; + word Info; } _CON_B3_CONP; - /* CONNECT-B3-INDICATION */ +/* CONNECT-B3-INDICATION */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_INDP; - /* CONNECT-B3-RESPONSE */ +/* CONNECT-B3-RESPONSE */ typedef struct { - word Accept; - byte structs[0]; /* NCPI */ + word Accept; + byte structs[0]; /* NCPI */ } _CON_B3_RESP; - /* CONNECT-B3-ACTIVE-INDICATION */ +/* CONNECT-B3-ACTIVE-INDICATION */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_A_INDP; - /* CONNECT-B3-ACTIVE-RESPONSE */ +/* CONNECT-B3-ACTIVE-RESPONSE */ typedef struct { - byte structs[0]; /* empty */ + byte structs[0]; /* empty */ } _CON_B3_A_RESP; - /* DISCONNECT-B3-REQUEST */ +/* DISCONNECT-B3-REQUEST */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _DIS_B3_REQP; - /* DISCONNECT-B3-CONFIRM */ +/* DISCONNECT-B3-CONFIRM */ typedef struct { - word Info; + word Info; } _DIS_B3_CONP; - /* DISCONNECT-B3-INDICATION */ +/* DISCONNECT-B3-INDICATION */ typedef struct { - word Info; - byte structs[0]; /* NCPI */ + word Info; + byte structs[0]; /* NCPI */ } _DIS_B3_INDP; - /* DISCONNECT-B3-RESPONSE */ +/* DISCONNECT-B3-RESPONSE */ typedef struct { - byte structs[0]; /* empty */ + byte structs[0]; /* empty */ } _DIS_B3_RESP; - /* DATA-B3-REQUEST */ +/* DATA-B3-REQUEST */ typedef struct { - dword Data; - word Data_Length; - word Number; - word Flags; + dword Data; + word Data_Length; + word Number; + word Flags; } _DAT_B3_REQP; - /* DATA-B3-REQUEST 64 BIT Systems */ +/* DATA-B3-REQUEST 64 BIT Systems */ typedef struct { - dword Data; - word Data_Length; - word Number; - word Flags; - void *pData; + dword Data; + word Data_Length; + word Number; + word Flags; + void *pData; } _DAT_B3_REQ64P; - /* DATA-B3-CONFIRM */ +/* DATA-B3-CONFIRM */ typedef struct { - word Number; - word Info; + word Number; + word Info; } _DAT_B3_CONP; - /* DATA-B3-INDICATION */ +/* DATA-B3-INDICATION */ typedef struct { - dword Data; - word Data_Length; - word Number; - word Flags; + dword Data; + word Data_Length; + word Number; + word Flags; } _DAT_B3_INDP; - /* DATA-B3-INDICATION 64 BIT Systems */ +/* DATA-B3-INDICATION 64 BIT Systems */ typedef struct { - dword Data; - word Data_Length; - word Number; - word Flags; - void *pData; + dword Data; + word Data_Length; + word Number; + word Flags; + void *pData; } _DAT_B3_IND64P; - /* DATA-B3-RESPONSE */ +/* DATA-B3-RESPONSE */ typedef struct { - word Number; + word Number; } _DAT_B3_RESP; - /* RESET-B3-REQUEST */ +/* RESET-B3-REQUEST */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _RES_B3_REQP; - /* RESET-B3-CONFIRM */ +/* RESET-B3-CONFIRM */ typedef struct { - word Info; + word Info; } _RES_B3_CONP; - /* RESET-B3-INDICATION */ +/* RESET-B3-INDICATION */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _RES_B3_INDP; - /* RESET-B3-RESPONSE */ +/* RESET-B3-RESPONSE */ typedef struct { - byte structs[0]; /* empty */ + byte structs[0]; /* empty */ } _RES_B3_RESP; - /* CONNECT-B3-T90-ACTIVE-INDICATION */ +/* CONNECT-B3-T90-ACTIVE-INDICATION */ typedef struct { - byte structs[0]; /* NCPI */ + byte structs[0]; /* NCPI */ } _CON_B3_T90_A_INDP; - /* CONNECT-B3-T90-ACTIVE-RESPONSE */ +/* CONNECT-B3-T90-ACTIVE-RESPONSE */ typedef struct { - word Reject; - byte structs[0]; /* NCPI */ + word Reject; + byte structs[0]; /* NCPI */ } _CON_B3_T90_A_RESP; /*------------------------------------------------------------------*/ /* message structure */ @@ -364,64 +364,64 @@ typedef struct { typedef struct _API_MSG CAPI_MSG; typedef struct _MSG_HEADER CAPI_MSG_HEADER; struct _API_MSG { - struct _MSG_HEADER { - word length; - word appl_id; - word command; - word number; - byte controller; - byte plci; - word ncci; - } header; - union { - _ALT_REQP alert_req; - _ALT_CONP alert_con; - _CON_REQP connect_req; - _CON_CONP connect_con; - _CON_INDP connect_ind; - _CON_RESP connect_res; - _CON_A_INDP connect_a_ind; - _CON_A_RESP connect_a_res; - _DIS_REQP disconnect_req; - _DIS_CONP disconnect_con; - _DIS_INDP disconnect_ind; - _DIS_RESP disconnect_res; - _LIS_REQP listen_req; - _LIS_CONP listen_con; - _INF_REQP info_req; - _INF_CONP info_con; - _INF_INDP info_ind; - _INF_RESP info_res; - _SEL_B_REQP select_b_req; - _SEL_B_CONP select_b_con; - _FAC_REQP facility_req; - _FAC_CONP facility_con; - _FAC_INDP facility_ind; - _FAC_RESP facility_res; - _CON_B3_REQP connect_b3_req; - _CON_B3_CONP connect_b3_con; - _CON_B3_INDP connect_b3_ind; - _CON_B3_RESP connect_b3_res; - _CON_B3_A_INDP connect_b3_a_ind; - _CON_B3_A_RESP connect_b3_a_res; - _DIS_B3_REQP disconnect_b3_req; - _DIS_B3_CONP disconnect_b3_con; - _DIS_B3_INDP disconnect_b3_ind; - _DIS_B3_RESP disconnect_b3_res; - _DAT_B3_REQP data_b3_req; - _DAT_B3_REQ64P data_b3_req64; - _DAT_B3_CONP data_b3_con; - _DAT_B3_INDP data_b3_ind; - _DAT_B3_IND64P data_b3_ind64; - _DAT_B3_RESP data_b3_res; - _RES_B3_REQP reset_b3_req; - _RES_B3_CONP reset_b3_con; - _RES_B3_INDP reset_b3_ind; - _RES_B3_RESP reset_b3_res; - _CON_B3_T90_A_INDP connect_b3_t90_a_ind; - _CON_B3_T90_A_RESP connect_b3_t90_a_res; - byte b[200]; - } info; + struct _MSG_HEADER { + word length; + word appl_id; + word command; + word number; + byte controller; + byte plci; + word ncci; + } header; + union { + _ALT_REQP alert_req; + _ALT_CONP alert_con; + _CON_REQP connect_req; + _CON_CONP connect_con; + _CON_INDP connect_ind; + _CON_RESP connect_res; + _CON_A_INDP connect_a_ind; + _CON_A_RESP connect_a_res; + _DIS_REQP disconnect_req; + _DIS_CONP disconnect_con; + _DIS_INDP disconnect_ind; + _DIS_RESP disconnect_res; + _LIS_REQP listen_req; + _LIS_CONP listen_con; + _INF_REQP info_req; + _INF_CONP info_con; + _INF_INDP info_ind; + _INF_RESP info_res; + _SEL_B_REQP select_b_req; + _SEL_B_CONP select_b_con; + _FAC_REQP facility_req; + _FAC_CONP facility_con; + _FAC_INDP facility_ind; + _FAC_RESP facility_res; + _CON_B3_REQP connect_b3_req; + _CON_B3_CONP connect_b3_con; + _CON_B3_INDP connect_b3_ind; + _CON_B3_RESP connect_b3_res; + _CON_B3_A_INDP connect_b3_a_ind; + _CON_B3_A_RESP connect_b3_a_res; + _DIS_B3_REQP disconnect_b3_req; + _DIS_B3_CONP disconnect_b3_con; + _DIS_B3_INDP disconnect_b3_ind; + _DIS_B3_RESP disconnect_b3_res; + _DAT_B3_REQP data_b3_req; + _DAT_B3_REQ64P data_b3_req64; + _DAT_B3_CONP data_b3_con; + _DAT_B3_INDP data_b3_ind; + _DAT_B3_IND64P data_b3_ind64; + _DAT_B3_RESP data_b3_res; + _RES_B3_REQP reset_b3_req; + _RES_B3_CONP reset_b3_con; + _RES_B3_INDP reset_b3_ind; + _RES_B3_RESP reset_b3_res; + _CON_B3_T90_A_INDP connect_b3_t90_a_ind; + _CON_B3_T90_A_RESP connect_b3_t90_a_res; + byte b[200]; + } info; }; /*------------------------------------------------------------------*/ /* non-fatal errors */ @@ -696,4 +696,4 @@ struct _API_MSG { /* function prototypes */ /*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/ -#endif /* _INC_CAPI20 */ +#endif /* _INC_CAPI20 */ diff --git a/drivers/isdn/hardware/eicon/capidtmf.c b/drivers/isdn/hardware/eicon/capidtmf.c index f130724144f3..e3f778415199 100644 --- a/drivers/isdn/hardware/eicon/capidtmf.c +++ b/drivers/isdn/hardware/eicon/capidtmf.c @@ -1,34 +1,34 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" - - + + @@ -51,74 +51,74 @@ static short capidtmf_expand_table_alaw[0x0100] = { - -5504, 5504, -344, 344, -22016, 22016, -1376, 1376, - -2752, 2752, -88, 88, -11008, 11008, -688, 688, - -7552, 7552, -472, 472, -30208, 30208, -1888, 1888, - -3776, 3776, -216, 216, -15104, 15104, -944, 944, - -4480, 4480, -280, 280, -17920, 17920, -1120, 1120, - -2240, 2240, -24, 24, -8960, 8960, -560, 560, - -6528, 6528, -408, 408, -26112, 26112, -1632, 1632, - -3264, 3264, -152, 152, -13056, 13056, -816, 816, - -6016, 6016, -376, 376, -24064, 24064, -1504, 1504, - -3008, 3008, -120, 120, -12032, 12032, -752, 752, - -8064, 8064, -504, 504, -32256, 32256, -2016, 2016, - -4032, 4032, -248, 248, -16128, 16128, -1008, 1008, - -4992, 4992, -312, 312, -19968, 19968, -1248, 1248, - -2496, 2496, -56, 56, -9984, 9984, -624, 624, - -7040, 7040, -440, 440, -28160, 28160, -1760, 1760, - -3520, 3520, -184, 184, -14080, 14080, -880, 880, - -5248, 5248, -328, 328, -20992, 20992, -1312, 1312, - -2624, 2624, -72, 72, -10496, 10496, -656, 656, - -7296, 7296, -456, 456, -29184, 29184, -1824, 1824, - -3648, 3648, -200, 200, -14592, 14592, -912, 912, - -4224, 4224, -264, 264, -16896, 16896, -1056, 1056, - -2112, 2112, -8, 8, -8448, 8448, -528, 528, - -6272, 6272, -392, 392, -25088, 25088, -1568, 1568, - -3136, 3136, -136, 136, -12544, 12544, -784, 784, - -5760, 5760, -360, 360, -23040, 23040, -1440, 1440, - -2880, 2880, -104, 104, -11520, 11520, -720, 720, - -7808, 7808, -488, 488, -31232, 31232, -1952, 1952, - -3904, 3904, -232, 232, -15616, 15616, -976, 976, - -4736, 4736, -296, 296, -18944, 18944, -1184, 1184, - -2368, 2368, -40, 40, -9472, 9472, -592, 592, - -6784, 6784, -424, 424, -27136, 27136, -1696, 1696, - -3392, 3392, -168, 168, -13568, 13568, -848, 848 + -5504, 5504, -344, 344, -22016, 22016, -1376, 1376, + -2752, 2752, -88, 88, -11008, 11008, -688, 688, + -7552, 7552, -472, 472, -30208, 30208, -1888, 1888, + -3776, 3776, -216, 216, -15104, 15104, -944, 944, + -4480, 4480, -280, 280, -17920, 17920, -1120, 1120, + -2240, 2240, -24, 24, -8960, 8960, -560, 560, + -6528, 6528, -408, 408, -26112, 26112, -1632, 1632, + -3264, 3264, -152, 152, -13056, 13056, -816, 816, + -6016, 6016, -376, 376, -24064, 24064, -1504, 1504, + -3008, 3008, -120, 120, -12032, 12032, -752, 752, + -8064, 8064, -504, 504, -32256, 32256, -2016, 2016, + -4032, 4032, -248, 248, -16128, 16128, -1008, 1008, + -4992, 4992, -312, 312, -19968, 19968, -1248, 1248, + -2496, 2496, -56, 56, -9984, 9984, -624, 624, + -7040, 7040, -440, 440, -28160, 28160, -1760, 1760, + -3520, 3520, -184, 184, -14080, 14080, -880, 880, + -5248, 5248, -328, 328, -20992, 20992, -1312, 1312, + -2624, 2624, -72, 72, -10496, 10496, -656, 656, + -7296, 7296, -456, 456, -29184, 29184, -1824, 1824, + -3648, 3648, -200, 200, -14592, 14592, -912, 912, + -4224, 4224, -264, 264, -16896, 16896, -1056, 1056, + -2112, 2112, -8, 8, -8448, 8448, -528, 528, + -6272, 6272, -392, 392, -25088, 25088, -1568, 1568, + -3136, 3136, -136, 136, -12544, 12544, -784, 784, + -5760, 5760, -360, 360, -23040, 23040, -1440, 1440, + -2880, 2880, -104, 104, -11520, 11520, -720, 720, + -7808, 7808, -488, 488, -31232, 31232, -1952, 1952, + -3904, 3904, -232, 232, -15616, 15616, -976, 976, + -4736, 4736, -296, 296, -18944, 18944, -1184, 1184, + -2368, 2368, -40, 40, -9472, 9472, -592, 592, + -6784, 6784, -424, 424, -27136, 27136, -1696, 1696, + -3392, 3392, -168, 168, -13568, 13568, -848, 848 }; static short capidtmf_expand_table_ulaw[0x0100] = { - -32124, 32124, -1884, 1884, -7932, 7932, -372, 372, - -15996, 15996, -876, 876, -3900, 3900, -120, 120, - -23932, 23932, -1372, 1372, -5884, 5884, -244, 244, - -11900, 11900, -620, 620, -2876, 2876, -56, 56, - -28028, 28028, -1628, 1628, -6908, 6908, -308, 308, - -13948, 13948, -748, 748, -3388, 3388, -88, 88, - -19836, 19836, -1116, 1116, -4860, 4860, -180, 180, - -9852, 9852, -492, 492, -2364, 2364, -24, 24, - -30076, 30076, -1756, 1756, -7420, 7420, -340, 340, - -14972, 14972, -812, 812, -3644, 3644, -104, 104, - -21884, 21884, -1244, 1244, -5372, 5372, -212, 212, - -10876, 10876, -556, 556, -2620, 2620, -40, 40, - -25980, 25980, -1500, 1500, -6396, 6396, -276, 276, - -12924, 12924, -684, 684, -3132, 3132, -72, 72, - -17788, 17788, -988, 988, -4348, 4348, -148, 148, - -8828, 8828, -428, 428, -2108, 2108, -8, 8, - -31100, 31100, -1820, 1820, -7676, 7676, -356, 356, - -15484, 15484, -844, 844, -3772, 3772, -112, 112, - -22908, 22908, -1308, 1308, -5628, 5628, -228, 228, - -11388, 11388, -588, 588, -2748, 2748, -48, 48, - -27004, 27004, -1564, 1564, -6652, 6652, -292, 292, - -13436, 13436, -716, 716, -3260, 3260, -80, 80, - -18812, 18812, -1052, 1052, -4604, 4604, -164, 164, - -9340, 9340, -460, 460, -2236, 2236, -16, 16, - -29052, 29052, -1692, 1692, -7164, 7164, -324, 324, - -14460, 14460, -780, 780, -3516, 3516, -96, 96, - -20860, 20860, -1180, 1180, -5116, 5116, -196, 196, - -10364, 10364, -524, 524, -2492, 2492, -32, 32, - -24956, 24956, -1436, 1436, -6140, 6140, -260, 260, - -12412, 12412, -652, 652, -3004, 3004, -64, 64, - -16764, 16764, -924, 924, -4092, 4092, -132, 132, - -8316, 8316, -396, 396, -1980, 1980, 0, 0 + -32124, 32124, -1884, 1884, -7932, 7932, -372, 372, + -15996, 15996, -876, 876, -3900, 3900, -120, 120, + -23932, 23932, -1372, 1372, -5884, 5884, -244, 244, + -11900, 11900, -620, 620, -2876, 2876, -56, 56, + -28028, 28028, -1628, 1628, -6908, 6908, -308, 308, + -13948, 13948, -748, 748, -3388, 3388, -88, 88, + -19836, 19836, -1116, 1116, -4860, 4860, -180, 180, + -9852, 9852, -492, 492, -2364, 2364, -24, 24, + -30076, 30076, -1756, 1756, -7420, 7420, -340, 340, + -14972, 14972, -812, 812, -3644, 3644, -104, 104, + -21884, 21884, -1244, 1244, -5372, 5372, -212, 212, + -10876, 10876, -556, 556, -2620, 2620, -40, 40, + -25980, 25980, -1500, 1500, -6396, 6396, -276, 276, + -12924, 12924, -684, 684, -3132, 3132, -72, 72, + -17788, 17788, -988, 988, -4348, 4348, -148, 148, + -8828, 8828, -428, 428, -2108, 2108, -8, 8, + -31100, 31100, -1820, 1820, -7676, 7676, -356, 356, + -15484, 15484, -844, 844, -3772, 3772, -112, 112, + -22908, 22908, -1308, 1308, -5628, 5628, -228, 228, + -11388, 11388, -588, 588, -2748, 2748, -48, 48, + -27004, 27004, -1564, 1564, -6652, 6652, -292, 292, + -13436, 13436, -716, 716, -3260, 3260, -80, 80, + -18812, 18812, -1052, 1052, -4604, 4604, -164, 164, + -9340, 9340, -460, 460, -2236, 2236, -16, 16, + -29052, 29052, -1692, 1692, -7164, 7164, -324, 324, + -14460, 14460, -780, 780, -3516, 3516, -96, 96, + -20860, 20860, -1180, 1180, -5116, 5116, -196, 196, + -10364, 10364, -524, 524, -2492, 2492, -32, 32, + -24956, 24956, -1436, 1436, -6140, 6140, -260, 260, + -12412, 12412, -652, 652, -3004, 3004, -64, 64, + -16764, 16764, -924, 924, -4092, 4092, -132, 132, + -8316, 8316, -396, 396, -1980, 1980, 0, 0 }; @@ -126,52 +126,52 @@ static short capidtmf_expand_table_ulaw[0x0100] = static short capidtmf_recv_window_function[CAPIDTMF_RECV_ACCUMULATE_CYCLES] = { - -500L, -999L, -1499L, -1998L, -2496L, -2994L, -3491L, -3988L, - -4483L, -4978L, -5471L, -5963L, -6454L, -6943L, -7431L, -7917L, - -8401L, -8883L, -9363L, -9840L, -10316L, -10789L, -11259L, -11727L, - -12193L, -12655L, -13115L, -13571L, -14024L, -14474L, -14921L, -15364L, - -15804L, -16240L, -16672L, -17100L, -17524L, -17944L, -18360L, -18772L, - -19180L, -19583L, -19981L, -20375L, -20764L, -21148L, -21527L, -21901L, - -22270L, -22634L, -22993L, -23346L, -23694L, -24037L, -24374L, -24705L, - -25030L, -25350L, -25664L, -25971L, -26273L, -26568L, -26858L, -27141L, - -27418L, -27688L, -27952L, -28210L, -28461L, -28705L, -28943L, -29174L, - -29398L, -29615L, -29826L, -30029L, -30226L, -30415L, -30598L, -30773L, - -30941L, -31102L, -31256L, -31402L, -31541L, -31673L, -31797L, -31914L, - -32024L, -32126L, -32221L, -32308L, -32388L, -32460L, -32524L, -32581L, - -32631L, -32673L, -32707L, -32734L, -32753L, -32764L, -32768L, -32764L, - -32753L, -32734L, -32707L, -32673L, -32631L, -32581L, -32524L, -32460L, - -32388L, -32308L, -32221L, -32126L, -32024L, -31914L, -31797L, -31673L, - -31541L, -31402L, -31256L, -31102L, -30941L, -30773L, -30598L, -30415L, - -30226L, -30029L, -29826L, -29615L, -29398L, -29174L, -28943L, -28705L, - -28461L, -28210L, -27952L, -27688L, -27418L, -27141L, -26858L, -26568L, - -26273L, -25971L, -25664L, -25350L, -25030L, -24705L, -24374L, -24037L, - -23694L, -23346L, -22993L, -22634L, -22270L, -21901L, -21527L, -21148L, - -20764L, -20375L, -19981L, -19583L, -19180L, -18772L, -18360L, -17944L, - -17524L, -17100L, -16672L, -16240L, -15804L, -15364L, -14921L, -14474L, - -14024L, -13571L, -13115L, -12655L, -12193L, -11727L, -11259L, -10789L, - -10316L, -9840L, -9363L, -8883L, -8401L, -7917L, -7431L, -6943L, - -6454L, -5963L, -5471L, -4978L, -4483L, -3988L, -3491L, -2994L, - -2496L, -1998L, -1499L, -999L, -500L, + -500L, -999L, -1499L, -1998L, -2496L, -2994L, -3491L, -3988L, + -4483L, -4978L, -5471L, -5963L, -6454L, -6943L, -7431L, -7917L, + -8401L, -8883L, -9363L, -9840L, -10316L, -10789L, -11259L, -11727L, + -12193L, -12655L, -13115L, -13571L, -14024L, -14474L, -14921L, -15364L, + -15804L, -16240L, -16672L, -17100L, -17524L, -17944L, -18360L, -18772L, + -19180L, -19583L, -19981L, -20375L, -20764L, -21148L, -21527L, -21901L, + -22270L, -22634L, -22993L, -23346L, -23694L, -24037L, -24374L, -24705L, + -25030L, -25350L, -25664L, -25971L, -26273L, -26568L, -26858L, -27141L, + -27418L, -27688L, -27952L, -28210L, -28461L, -28705L, -28943L, -29174L, + -29398L, -29615L, -29826L, -30029L, -30226L, -30415L, -30598L, -30773L, + -30941L, -31102L, -31256L, -31402L, -31541L, -31673L, -31797L, -31914L, + -32024L, -32126L, -32221L, -32308L, -32388L, -32460L, -32524L, -32581L, + -32631L, -32673L, -32707L, -32734L, -32753L, -32764L, -32768L, -32764L, + -32753L, -32734L, -32707L, -32673L, -32631L, -32581L, -32524L, -32460L, + -32388L, -32308L, -32221L, -32126L, -32024L, -31914L, -31797L, -31673L, + -31541L, -31402L, -31256L, -31102L, -30941L, -30773L, -30598L, -30415L, + -30226L, -30029L, -29826L, -29615L, -29398L, -29174L, -28943L, -28705L, + -28461L, -28210L, -27952L, -27688L, -27418L, -27141L, -26858L, -26568L, + -26273L, -25971L, -25664L, -25350L, -25030L, -24705L, -24374L, -24037L, + -23694L, -23346L, -22993L, -22634L, -22270L, -21901L, -21527L, -21148L, + -20764L, -20375L, -19981L, -19583L, -19180L, -18772L, -18360L, -17944L, + -17524L, -17100L, -16672L, -16240L, -15804L, -15364L, -14921L, -14474L, + -14024L, -13571L, -13115L, -12655L, -12193L, -11727L, -11259L, -10789L, + -10316L, -9840L, -9363L, -8883L, -8401L, -7917L, -7431L, -6943L, + -6454L, -5963L, -5471L, -4978L, -4483L, -3988L, -3491L, -2994L, + -2496L, -1998L, -1499L, -999L, -500L, }; static byte capidtmf_leading_zeroes_table[0x100] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #define capidtmf_byte_leading_zeroes(b) (capidtmf_leading_zeroes_table[(BYTE)(b)]) @@ -182,140 +182,140 @@ static byte capidtmf_leading_zeroes_table[0x100] = /*---------------------------------------------------------------------------*/ -static void capidtmf_goertzel_loop (long *buffer, long *coeffs, short *sample, long count) +static void capidtmf_goertzel_loop(long *buffer, long *coeffs, short *sample, long count) { - int i, j; - long c, d, q0, q1, q2; - - for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT - 1; i++) - { - q1 = buffer[i]; - q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; - d = coeffs[i] >> 1; - c = d << 1; - if (c >= 0) - { - for (j = 0; j < count; j++) - { - q0 = sample[j] - q2 + (c * (q1 >> 16)) + (((dword)(((dword) d) * ((dword)(q1 & 0xffff)))) >> 15); - q2 = q1; - q1 = q0; - } - } - else - { - c = -c; - d = -d; - for (j = 0; j < count; j++) - { - q0 = sample[j] - q2 - ((c * (q1 >> 16)) + (((dword)(((dword) d) * ((dword)(q1 & 0xffff)))) >> 15)); - q2 = q1; - q1 = q0; - } - } - buffer[i] = q1; - buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = q2; - } - q1 = buffer[i]; - q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; - c = (coeffs[i] >> 1) << 1; - if (c >= 0) - { - for (j = 0; j < count; j++) - { - q0 = sample[j] - q2 + (c * (q1 >> 16)) + (((dword)(((dword)(c >> 1)) * ((dword)(q1 & 0xffff)))) >> 15); - q2 = q1; - q1 = q0; - c -= CAPIDTMF_RECV_FUNDAMENTAL_DECREMENT; - } - } - else - { - c = -c; - for (j = 0; j < count; j++) - { - q0 = sample[j] - q2 - ((c * (q1 >> 16)) + (((dword)(((dword)(c >> 1)) * ((dword)(q1 & 0xffff)))) >> 15)); - q2 = q1; - q1 = q0; - c += CAPIDTMF_RECV_FUNDAMENTAL_DECREMENT; - } - } - coeffs[i] = c; - buffer[i] = q1; - buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = q2; + int i, j; + long c, d, q0, q1, q2; + + for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT - 1; i++) + { + q1 = buffer[i]; + q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; + d = coeffs[i] >> 1; + c = d << 1; + if (c >= 0) + { + for (j = 0; j < count; j++) + { + q0 = sample[j] - q2 + (c * (q1 >> 16)) + (((dword)(((dword) d) * ((dword)(q1 & 0xffff)))) >> 15); + q2 = q1; + q1 = q0; + } + } + else + { + c = -c; + d = -d; + for (j = 0; j < count; j++) + { + q0 = sample[j] - q2 - ((c * (q1 >> 16)) + (((dword)(((dword) d) * ((dword)(q1 & 0xffff)))) >> 15)); + q2 = q1; + q1 = q0; + } + } + buffer[i] = q1; + buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = q2; + } + q1 = buffer[i]; + q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; + c = (coeffs[i] >> 1) << 1; + if (c >= 0) + { + for (j = 0; j < count; j++) + { + q0 = sample[j] - q2 + (c * (q1 >> 16)) + (((dword)(((dword)(c >> 1)) * ((dword)(q1 & 0xffff)))) >> 15); + q2 = q1; + q1 = q0; + c -= CAPIDTMF_RECV_FUNDAMENTAL_DECREMENT; + } + } + else + { + c = -c; + for (j = 0; j < count; j++) + { + q0 = sample[j] - q2 - ((c * (q1 >> 16)) + (((dword)(((dword)(c >> 1)) * ((dword)(q1 & 0xffff)))) >> 15)); + q2 = q1; + q1 = q0; + c += CAPIDTMF_RECV_FUNDAMENTAL_DECREMENT; + } + } + coeffs[i] = c; + buffer[i] = q1; + buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = q2; } -static void capidtmf_goertzel_result (long *buffer, long *coeffs) +static void capidtmf_goertzel_result(long *buffer, long *coeffs) { - int i; - long d, e, q1, q2, lo, mid, hi; - dword k; - - for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) - { - q1 = buffer[i]; - q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; - d = coeffs[i] >> 1; - if (d >= 0) - d = ((d << 1) * (-q1 >> 16)) + (((dword)(((dword) d) * ((dword)(-q1 & 0xffff)))) >> 15); - else - d = ((-d << 1) * (-q1 >> 16)) + (((dword)(((dword) -d) * ((dword)(-q1 & 0xffff)))) >> 15); - e = (q2 >= 0) ? q2 : -q2; - if (d >= 0) - { - k = ((dword)(d & 0xffff)) * ((dword)(e & 0xffff)); - lo = k & 0xffff; - mid = k >> 16; - k = ((dword)(d >> 16)) * ((dword)(e & 0xffff)); - mid += k & 0xffff; - hi = k >> 16; - k = ((dword)(d & 0xffff)) * ((dword)(e >> 16)); - mid += k & 0xffff; - hi += k >> 16; - hi += ((dword)(d >> 16)) * ((dword)(e >> 16)); - } - else - { - d = -d; - k = ((dword)(d & 0xffff)) * ((dword)(e & 0xffff)); - lo = -((long)(k & 0xffff)); - mid = -((long)(k >> 16)); - k = ((dword)(d >> 16)) * ((dword)(e & 0xffff)); - mid -= k & 0xffff; - hi = -((long)(k >> 16)); - k = ((dword)(d & 0xffff)) * ((dword)(e >> 16)); - mid -= k & 0xffff; - hi -= k >> 16; - hi -= ((dword)(d >> 16)) * ((dword)(e >> 16)); - } - if (q2 < 0) - { - lo = -lo; - mid = -mid; - hi = -hi; - } - d = (q1 >= 0) ? q1 : -q1; - k = ((dword)(d & 0xffff)) * ((dword)(d & 0xffff)); - lo += k & 0xffff; - mid += k >> 16; - k = ((dword)(d >> 16)) * ((dword)(d & 0xffff)); - mid += (k & 0xffff) << 1; - hi += (k >> 16) << 1; - hi += ((dword)(d >> 16)) * ((dword)(d >> 16)); - d = (q2 >= 0) ? q2 : -q2; - k = ((dword)(d & 0xffff)) * ((dword)(d & 0xffff)); - lo += k & 0xffff; - mid += k >> 16; - k = ((dword)(d >> 16)) * ((dword)(d & 0xffff)); - mid += (k & 0xffff) << 1; - hi += (k >> 16) << 1; - hi += ((dword)(d >> 16)) * ((dword)(d >> 16)); - mid += lo >> 16; - hi += mid >> 16; - buffer[i] = (lo & 0xffff) | (mid << 16); - buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = hi; - } + int i; + long d, e, q1, q2, lo, mid, hi; + dword k; + + for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) + { + q1 = buffer[i]; + q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; + d = coeffs[i] >> 1; + if (d >= 0) + d = ((d << 1) * (-q1 >> 16)) + (((dword)(((dword) d) * ((dword)(-q1 & 0xffff)))) >> 15); + else + d = ((-d << 1) * (-q1 >> 16)) + (((dword)(((dword) -d) * ((dword)(-q1 & 0xffff)))) >> 15); + e = (q2 >= 0) ? q2 : -q2; + if (d >= 0) + { + k = ((dword)(d & 0xffff)) * ((dword)(e & 0xffff)); + lo = k & 0xffff; + mid = k >> 16; + k = ((dword)(d >> 16)) * ((dword)(e & 0xffff)); + mid += k & 0xffff; + hi = k >> 16; + k = ((dword)(d & 0xffff)) * ((dword)(e >> 16)); + mid += k & 0xffff; + hi += k >> 16; + hi += ((dword)(d >> 16)) * ((dword)(e >> 16)); + } + else + { + d = -d; + k = ((dword)(d & 0xffff)) * ((dword)(e & 0xffff)); + lo = -((long)(k & 0xffff)); + mid = -((long)(k >> 16)); + k = ((dword)(d >> 16)) * ((dword)(e & 0xffff)); + mid -= k & 0xffff; + hi = -((long)(k >> 16)); + k = ((dword)(d & 0xffff)) * ((dword)(e >> 16)); + mid -= k & 0xffff; + hi -= k >> 16; + hi -= ((dword)(d >> 16)) * ((dword)(e >> 16)); + } + if (q2 < 0) + { + lo = -lo; + mid = -mid; + hi = -hi; + } + d = (q1 >= 0) ? q1 : -q1; + k = ((dword)(d & 0xffff)) * ((dword)(d & 0xffff)); + lo += k & 0xffff; + mid += k >> 16; + k = ((dword)(d >> 16)) * ((dword)(d & 0xffff)); + mid += (k & 0xffff) << 1; + hi += (k >> 16) << 1; + hi += ((dword)(d >> 16)) * ((dword)(d >> 16)); + d = (q2 >= 0) ? q2 : -q2; + k = ((dword)(d & 0xffff)) * ((dword)(d & 0xffff)); + lo += k & 0xffff; + mid += k >> 16; + k = ((dword)(d >> 16)) * ((dword)(d & 0xffff)); + mid += (k & 0xffff) << 1; + hi += (k >> 16) << 1; + hi += ((dword)(d >> 16)) * ((dword)(d >> 16)); + mid += lo >> 16; + hi += mid >> 16; + buffer[i] = (lo & 0xffff) | (mid << 16); + buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = hi; + } } @@ -346,339 +346,339 @@ static void capidtmf_goertzel_result (long *buffer, long *coeffs) static long capidtmf_recv_goertzel_coef_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = { - 0xda97L * 2, /* 697 Hz (Low group 697 Hz) */ - 0xd299L * 2, /* 770 Hz (Low group 770 Hz) */ - 0xc8cbL * 2, /* 852 Hz (Low group 852 Hz) */ - 0xbd36L * 2, /* 941 Hz (Low group 941 Hz) */ - 0x9501L * 2, /* 1209 Hz (High group 1209 Hz) */ - 0x7f89L * 2, /* 1336 Hz (High group 1336 Hz) */ - 0x6639L * 2, /* 1477 Hz (High group 1477 Hz) */ - 0x48c6L * 2, /* 1633 Hz (High group 1633 Hz) */ - 0xe14cL * 2, /* 630 Hz (Lower guard of low group 631 Hz) */ - 0xb2e0L * 2, /* 1015 Hz (Upper guard of low group 1039 Hz) */ - 0xa1a0L * 2, /* 1130 Hz (Lower guard of high group 1140 Hz) */ - 0x8a87L * 2, /* 1272 Hz (Guard between 1209 Hz and 1336 Hz: 1271 Hz) */ - 0x7353L * 2, /* 1405 Hz (2nd harmonics of 697 Hz and guard between 1336 Hz and 1477 Hz: 1405 Hz) */ - 0x583bL * 2, /* 1552 Hz (2nd harmonics of 770 Hz and guard between 1477 Hz and 1633 Hz: 1553 Hz) */ - 0x37d8L * 2, /* 1720 Hz (2nd harmonics of 852 Hz and upper guard of high group: 1715 Hz) */ - 0x0000L * 2 /* 100-630 Hz (fundamentals) */ + 0xda97L * 2, /* 697 Hz (Low group 697 Hz) */ + 0xd299L * 2, /* 770 Hz (Low group 770 Hz) */ + 0xc8cbL * 2, /* 852 Hz (Low group 852 Hz) */ + 0xbd36L * 2, /* 941 Hz (Low group 941 Hz) */ + 0x9501L * 2, /* 1209 Hz (High group 1209 Hz) */ + 0x7f89L * 2, /* 1336 Hz (High group 1336 Hz) */ + 0x6639L * 2, /* 1477 Hz (High group 1477 Hz) */ + 0x48c6L * 2, /* 1633 Hz (High group 1633 Hz) */ + 0xe14cL * 2, /* 630 Hz (Lower guard of low group 631 Hz) */ + 0xb2e0L * 2, /* 1015 Hz (Upper guard of low group 1039 Hz) */ + 0xa1a0L * 2, /* 1130 Hz (Lower guard of high group 1140 Hz) */ + 0x8a87L * 2, /* 1272 Hz (Guard between 1209 Hz and 1336 Hz: 1271 Hz) */ + 0x7353L * 2, /* 1405 Hz (2nd harmonics of 697 Hz and guard between 1336 Hz and 1477 Hz: 1405 Hz) */ + 0x583bL * 2, /* 1552 Hz (2nd harmonics of 770 Hz and guard between 1477 Hz and 1633 Hz: 1553 Hz) */ + 0x37d8L * 2, /* 1720 Hz (2nd harmonics of 852 Hz and upper guard of high group: 1715 Hz) */ + 0x0000L * 2 /* 100-630 Hz (fundamentals) */ }; static word capidtmf_recv_guard_snr_low_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = { - 14, /* Low group peak versus 697 Hz */ - 14, /* Low group peak versus 770 Hz */ - 16, /* Low group peak versus 852 Hz */ - 16, /* Low group peak versus 941 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1209 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1336 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1477 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1633 Hz */ - 14, /* Low group peak versus 635 Hz */ - 16, /* Low group peak versus 1010 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1140 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1272 Hz */ - DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 8, /* Low group peak versus 1405 Hz */ - DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 4, /* Low group peak versus 1555 Hz */ - DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 4, /* Low group peak versus 1715 Hz */ - 12 /* Low group peak versus 100-630 Hz */ + 14, /* Low group peak versus 697 Hz */ + 14, /* Low group peak versus 770 Hz */ + 16, /* Low group peak versus 852 Hz */ + 16, /* Low group peak versus 941 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1209 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1336 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1477 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1633 Hz */ + 14, /* Low group peak versus 635 Hz */ + 16, /* Low group peak versus 1010 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1140 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1272 Hz */ + DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 8, /* Low group peak versus 1405 Hz */ + DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 4, /* Low group peak versus 1555 Hz */ + DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 4, /* Low group peak versus 1715 Hz */ + 12 /* Low group peak versus 100-630 Hz */ }; static word capidtmf_recv_guard_snr_high_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = { - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 697 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 770 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 852 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 941 Hz */ - 20, /* High group peak versus 1209 Hz */ - 20, /* High group peak versus 1336 Hz */ - 20, /* High group peak versus 1477 Hz */ - 20, /* High group peak versus 1633 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 635 Hz */ - CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 1010 Hz */ - 16, /* High group peak versus 1140 Hz */ - 4, /* High group peak versus 1272 Hz */ - 6, /* High group peak versus 1405 Hz */ - 8, /* High group peak versus 1555 Hz */ - 16, /* High group peak versus 1715 Hz */ - 12 /* High group peak versus 100-630 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 697 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 770 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 852 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 941 Hz */ + 20, /* High group peak versus 1209 Hz */ + 20, /* High group peak versus 1336 Hz */ + 20, /* High group peak versus 1477 Hz */ + 20, /* High group peak versus 1633 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 635 Hz */ + CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 1010 Hz */ + 16, /* High group peak versus 1140 Hz */ + 4, /* High group peak versus 1272 Hz */ + 6, /* High group peak versus 1405 Hz */ + 8, /* High group peak versus 1555 Hz */ + 16, /* High group peak versus 1715 Hz */ + 12 /* High group peak versus 100-630 Hz */ }; /*---------------------------------------------------------------------------*/ -static void capidtmf_recv_init (t_capidtmf_state *p_state) +static void capidtmf_recv_init(t_capidtmf_state *p_state) { - p_state->recv.min_gap_duration = 1; - p_state->recv.min_digit_duration = 1; - - p_state->recv.cycle_counter = 0; - p_state->recv.current_digit_on_time = 0; - p_state->recv.current_digit_off_time = 0; - p_state->recv.current_digit_value = CAPIDTMF_RECV_NO_DIGIT; - - p_state->recv.digit_write_pos = 0; - p_state->recv.digit_read_pos = 0; - p_state->recv.indication_state = 0; - p_state->recv.indication_state_ack = 0; - p_state->recv.state = CAPIDTMF_RECV_STATE_IDLE; + p_state->recv.min_gap_duration = 1; + p_state->recv.min_digit_duration = 1; + + p_state->recv.cycle_counter = 0; + p_state->recv.current_digit_on_time = 0; + p_state->recv.current_digit_off_time = 0; + p_state->recv.current_digit_value = CAPIDTMF_RECV_NO_DIGIT; + + p_state->recv.digit_write_pos = 0; + p_state->recv.digit_read_pos = 0; + p_state->recv.indication_state = 0; + p_state->recv.indication_state_ack = 0; + p_state->recv.state = CAPIDTMF_RECV_STATE_IDLE; } -void capidtmf_recv_enable (t_capidtmf_state *p_state, word min_digit_duration, word min_gap_duration) +void capidtmf_recv_enable(t_capidtmf_state *p_state, word min_digit_duration, word min_gap_duration) { - p_state->recv.indication_state_ack &= CAPIDTMF_RECV_INDICATION_DIGIT; - p_state->recv.min_digit_duration = (word)(((((dword) min_digit_duration) * 8) + - ((dword)(CAPIDTMF_RECV_TIME_GRANULARITY / 2))) / ((dword) CAPIDTMF_RECV_TIME_GRANULARITY)); - if (p_state->recv.min_digit_duration <= 1) - p_state->recv.min_digit_duration = 1; - else - (p_state->recv.min_digit_duration)--; - p_state->recv.min_gap_duration = - (word)((((dword) min_gap_duration) * 8) / ((dword) CAPIDTMF_RECV_TIME_GRANULARITY)); - if (p_state->recv.min_gap_duration <= 1) - p_state->recv.min_gap_duration = 1; - else - (p_state->recv.min_gap_duration)--; - p_state->recv.state |= CAPIDTMF_RECV_STATE_DTMF_ACTIVE; + p_state->recv.indication_state_ack &= CAPIDTMF_RECV_INDICATION_DIGIT; + p_state->recv.min_digit_duration = (word)(((((dword) min_digit_duration) * 8) + + ((dword)(CAPIDTMF_RECV_TIME_GRANULARITY / 2))) / ((dword) CAPIDTMF_RECV_TIME_GRANULARITY)); + if (p_state->recv.min_digit_duration <= 1) + p_state->recv.min_digit_duration = 1; + else + (p_state->recv.min_digit_duration)--; + p_state->recv.min_gap_duration = + (word)((((dword) min_gap_duration) * 8) / ((dword) CAPIDTMF_RECV_TIME_GRANULARITY)); + if (p_state->recv.min_gap_duration <= 1) + p_state->recv.min_gap_duration = 1; + else + (p_state->recv.min_gap_duration)--; + p_state->recv.state |= CAPIDTMF_RECV_STATE_DTMF_ACTIVE; } -void capidtmf_recv_disable (t_capidtmf_state *p_state) +void capidtmf_recv_disable(t_capidtmf_state *p_state) { - p_state->recv.state &= ~CAPIDTMF_RECV_STATE_DTMF_ACTIVE; - if (p_state->recv.state == CAPIDTMF_RECV_STATE_IDLE) - capidtmf_recv_init (p_state); - else - { - p_state->recv.cycle_counter = 0; - p_state->recv.current_digit_on_time = 0; - p_state->recv.current_digit_off_time = 0; - p_state->recv.current_digit_value = CAPIDTMF_RECV_NO_DIGIT; - } + p_state->recv.state &= ~CAPIDTMF_RECV_STATE_DTMF_ACTIVE; + if (p_state->recv.state == CAPIDTMF_RECV_STATE_IDLE) + capidtmf_recv_init(p_state); + else + { + p_state->recv.cycle_counter = 0; + p_state->recv.current_digit_on_time = 0; + p_state->recv.current_digit_off_time = 0; + p_state->recv.current_digit_value = CAPIDTMF_RECV_NO_DIGIT; + } } -word capidtmf_recv_indication (t_capidtmf_state *p_state, byte *buffer) +word capidtmf_recv_indication(t_capidtmf_state *p_state, byte *buffer) { - word i, j, k, flags; - - flags = p_state->recv.indication_state ^ p_state->recv.indication_state_ack; - p_state->recv.indication_state_ack ^= flags & CAPIDTMF_RECV_INDICATION_DIGIT; - if (p_state->recv.digit_write_pos != p_state->recv.digit_read_pos) - { - i = 0; - k = p_state->recv.digit_write_pos; - j = p_state->recv.digit_read_pos; - do - { - buffer[i++] = p_state->recv.digit_buffer[j]; - j = (j == CAPIDTMF_RECV_DIGIT_BUFFER_SIZE - 1) ? 0 : j + 1; - } while (j != k); - p_state->recv.digit_read_pos = k; - return (i); - } - p_state->recv.indication_state_ack ^= flags; - return (0); + word i, j, k, flags; + + flags = p_state->recv.indication_state ^ p_state->recv.indication_state_ack; + p_state->recv.indication_state_ack ^= flags & CAPIDTMF_RECV_INDICATION_DIGIT; + if (p_state->recv.digit_write_pos != p_state->recv.digit_read_pos) + { + i = 0; + k = p_state->recv.digit_write_pos; + j = p_state->recv.digit_read_pos; + do + { + buffer[i++] = p_state->recv.digit_buffer[j]; + j = (j == CAPIDTMF_RECV_DIGIT_BUFFER_SIZE - 1) ? 0 : j + 1; + } while (j != k); + p_state->recv.digit_read_pos = k; + return (i); + } + p_state->recv.indication_state_ack ^= flags; + return (0); } #define CAPIDTMF_RECV_WINDOWED_SAMPLES 32 -void capidtmf_recv_block (t_capidtmf_state *p_state, byte *buffer, word length) +void capidtmf_recv_block(t_capidtmf_state *p_state, byte *buffer, word length) { - byte result_digit; - word sample_number, cycle_counter, n, i; - word low_peak, high_peak; - dword lo, hi; - byte *p; - short *q; - byte goertzel_result_buffer[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; - short windowed_sample_buffer[CAPIDTMF_RECV_WINDOWED_SAMPLES]; - - - if (p_state->recv.state & CAPIDTMF_RECV_STATE_DTMF_ACTIVE) - { - cycle_counter = p_state->recv.cycle_counter; - sample_number = 0; - while (sample_number < length) - { - if (cycle_counter < CAPIDTMF_RECV_ACCUMULATE_CYCLES) - { - if (cycle_counter == 0) - { - for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) - { - p_state->recv.goertzel_buffer[0][i] = 0; - p_state->recv.goertzel_buffer[1][i] = 0; - } - } - n = CAPIDTMF_RECV_ACCUMULATE_CYCLES - cycle_counter; - if (n > length - sample_number) - n = length - sample_number; - if (n > CAPIDTMF_RECV_WINDOWED_SAMPLES) - n = CAPIDTMF_RECV_WINDOWED_SAMPLES; - p = buffer + sample_number; - q = capidtmf_recv_window_function + cycle_counter; - if (p_state->ulaw) - { - for (i = 0; i < n; i++) - { - windowed_sample_buffer[i] = - (short)((capidtmf_expand_table_ulaw[p[i]] * ((long)(q[i]))) >> 15); - } - } - else - { - for (i = 0; i < n; i++) - { - windowed_sample_buffer[i] = - (short)((capidtmf_expand_table_alaw[p[i]] * ((long)(q[i]))) >> 15); - } - } - capidtmf_recv_goertzel_coef_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT - 1] = CAPIDTMF_RECV_FUNDAMENTAL_OFFSET; - capidtmf_goertzel_loop (p_state->recv.goertzel_buffer[0], - capidtmf_recv_goertzel_coef_table, windowed_sample_buffer, n); - cycle_counter += n; - sample_number += n; - } - else - { - capidtmf_goertzel_result (p_state->recv.goertzel_buffer[0], - capidtmf_recv_goertzel_coef_table); - for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) - { - lo = (dword)(p_state->recv.goertzel_buffer[0][i]); - hi = (dword)(p_state->recv.goertzel_buffer[1][i]); - if (hi != 0) - { - n = capidtmf_dword_leading_zeroes (hi); - hi = (hi << n) | (lo >> (32 - n)); - } - else - { - n = capidtmf_dword_leading_zeroes (lo); - hi = lo << n; - n += 32; - } - n = 195 - 3 * n; - if (hi >= 0xcb300000L) - n += 2; - else if (hi >= 0xa1450000L) - n++; - goertzel_result_buffer[i] = (byte) n; - } - low_peak = DSPDTMF_RX_SENSITIVITY_LOW_DEFAULT; - result_digit = CAPIDTMF_RECV_NO_DIGIT; - for (i = 0; i < CAPIDTMF_LOW_GROUP_FREQUENCIES; i++) - { - if (goertzel_result_buffer[i] > low_peak) - { - low_peak = goertzel_result_buffer[i]; - result_digit = (byte) i; - } - } - high_peak = DSPDTMF_RX_SENSITIVITY_HIGH_DEFAULT; - n = CAPIDTMF_RECV_NO_DIGIT; - for (i = CAPIDTMF_LOW_GROUP_FREQUENCIES; i < CAPIDTMF_RECV_BASE_FREQUENCY_COUNT; i++) - { - if (goertzel_result_buffer[i] > high_peak) - { - high_peak = goertzel_result_buffer[i]; - n = (i - CAPIDTMF_LOW_GROUP_FREQUENCIES) << 2; - } - } - result_digit |= (byte) n; - if (low_peak + DSPDTMF_RX_HIGH_EXCEEDING_LOW_DEFAULT < high_peak) - result_digit = CAPIDTMF_RECV_NO_DIGIT; - if (high_peak + DSPDTMF_RX_LOW_EXCEEDING_HIGH_DEFAULT < low_peak) - result_digit = CAPIDTMF_RECV_NO_DIGIT; - n = 0; - for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) - { - if ((((short)(low_peak - goertzel_result_buffer[i] - capidtmf_recv_guard_snr_low_table[i])) < 0) - || (((short)(high_peak - goertzel_result_buffer[i] - capidtmf_recv_guard_snr_high_table[i])) < 0)) - { - n++; - } - } - if (n != 2) - result_digit = CAPIDTMF_RECV_NO_DIGIT; - - if (result_digit == CAPIDTMF_RECV_NO_DIGIT) - { - if (p_state->recv.current_digit_on_time != 0) - { - if (++(p_state->recv.current_digit_off_time) >= p_state->recv.min_gap_duration) - { - p_state->recv.current_digit_on_time = 0; - p_state->recv.current_digit_off_time = 0; - } - } - else - { - if (p_state->recv.current_digit_off_time != 0) - (p_state->recv.current_digit_off_time)--; - } - } - else - { - if ((p_state->recv.current_digit_on_time == 0) - && (p_state->recv.current_digit_off_time != 0)) - { - (p_state->recv.current_digit_off_time)--; - } - else - { - n = p_state->recv.current_digit_off_time; - if ((p_state->recv.current_digit_on_time != 0) - && (result_digit != p_state->recv.current_digit_value)) - { - p_state->recv.current_digit_on_time = 0; - n = 0; - } - p_state->recv.current_digit_value = result_digit; - p_state->recv.current_digit_off_time = 0; - if (p_state->recv.current_digit_on_time != 0xffff) - { - p_state->recv.current_digit_on_time += n + 1; - if (p_state->recv.current_digit_on_time >= p_state->recv.min_digit_duration) - { - p_state->recv.current_digit_on_time = 0xffff; - i = (p_state->recv.digit_write_pos == CAPIDTMF_RECV_DIGIT_BUFFER_SIZE - 1) ? - 0 : p_state->recv.digit_write_pos + 1; - if (i == p_state->recv.digit_read_pos) - { - trace (dprintf ("%s,%d: Receive digit overrun", - (char *)(FILE_), __LINE__)); - } - else - { - p_state->recv.digit_buffer[p_state->recv.digit_write_pos] = result_digit; - p_state->recv.digit_write_pos = i; - p_state->recv.indication_state = - (p_state->recv.indication_state & ~CAPIDTMF_RECV_INDICATION_DIGIT) | - (~p_state->recv.indication_state_ack & CAPIDTMF_RECV_INDICATION_DIGIT); - } - } - } - } - } - cycle_counter = 0; - sample_number++; - } - } - p_state->recv.cycle_counter = cycle_counter; - } + byte result_digit; + word sample_number, cycle_counter, n, i; + word low_peak, high_peak; + dword lo, hi; + byte *p; + short *q; + byte goertzel_result_buffer[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; + short windowed_sample_buffer[CAPIDTMF_RECV_WINDOWED_SAMPLES]; + + + if (p_state->recv.state & CAPIDTMF_RECV_STATE_DTMF_ACTIVE) + { + cycle_counter = p_state->recv.cycle_counter; + sample_number = 0; + while (sample_number < length) + { + if (cycle_counter < CAPIDTMF_RECV_ACCUMULATE_CYCLES) + { + if (cycle_counter == 0) + { + for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) + { + p_state->recv.goertzel_buffer[0][i] = 0; + p_state->recv.goertzel_buffer[1][i] = 0; + } + } + n = CAPIDTMF_RECV_ACCUMULATE_CYCLES - cycle_counter; + if (n > length - sample_number) + n = length - sample_number; + if (n > CAPIDTMF_RECV_WINDOWED_SAMPLES) + n = CAPIDTMF_RECV_WINDOWED_SAMPLES; + p = buffer + sample_number; + q = capidtmf_recv_window_function + cycle_counter; + if (p_state->ulaw) + { + for (i = 0; i < n; i++) + { + windowed_sample_buffer[i] = + (short)((capidtmf_expand_table_ulaw[p[i]] * ((long)(q[i]))) >> 15); + } + } + else + { + for (i = 0; i < n; i++) + { + windowed_sample_buffer[i] = + (short)((capidtmf_expand_table_alaw[p[i]] * ((long)(q[i]))) >> 15); + } + } + capidtmf_recv_goertzel_coef_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT - 1] = CAPIDTMF_RECV_FUNDAMENTAL_OFFSET; + capidtmf_goertzel_loop(p_state->recv.goertzel_buffer[0], + capidtmf_recv_goertzel_coef_table, windowed_sample_buffer, n); + cycle_counter += n; + sample_number += n; + } + else + { + capidtmf_goertzel_result(p_state->recv.goertzel_buffer[0], + capidtmf_recv_goertzel_coef_table); + for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) + { + lo = (dword)(p_state->recv.goertzel_buffer[0][i]); + hi = (dword)(p_state->recv.goertzel_buffer[1][i]); + if (hi != 0) + { + n = capidtmf_dword_leading_zeroes(hi); + hi = (hi << n) | (lo >> (32 - n)); + } + else + { + n = capidtmf_dword_leading_zeroes(lo); + hi = lo << n; + n += 32; + } + n = 195 - 3 * n; + if (hi >= 0xcb300000L) + n += 2; + else if (hi >= 0xa1450000L) + n++; + goertzel_result_buffer[i] = (byte) n; + } + low_peak = DSPDTMF_RX_SENSITIVITY_LOW_DEFAULT; + result_digit = CAPIDTMF_RECV_NO_DIGIT; + for (i = 0; i < CAPIDTMF_LOW_GROUP_FREQUENCIES; i++) + { + if (goertzel_result_buffer[i] > low_peak) + { + low_peak = goertzel_result_buffer[i]; + result_digit = (byte) i; + } + } + high_peak = DSPDTMF_RX_SENSITIVITY_HIGH_DEFAULT; + n = CAPIDTMF_RECV_NO_DIGIT; + for (i = CAPIDTMF_LOW_GROUP_FREQUENCIES; i < CAPIDTMF_RECV_BASE_FREQUENCY_COUNT; i++) + { + if (goertzel_result_buffer[i] > high_peak) + { + high_peak = goertzel_result_buffer[i]; + n = (i - CAPIDTMF_LOW_GROUP_FREQUENCIES) << 2; + } + } + result_digit |= (byte) n; + if (low_peak + DSPDTMF_RX_HIGH_EXCEEDING_LOW_DEFAULT < high_peak) + result_digit = CAPIDTMF_RECV_NO_DIGIT; + if (high_peak + DSPDTMF_RX_LOW_EXCEEDING_HIGH_DEFAULT < low_peak) + result_digit = CAPIDTMF_RECV_NO_DIGIT; + n = 0; + for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) + { + if ((((short)(low_peak - goertzel_result_buffer[i] - capidtmf_recv_guard_snr_low_table[i])) < 0) + || (((short)(high_peak - goertzel_result_buffer[i] - capidtmf_recv_guard_snr_high_table[i])) < 0)) + { + n++; + } + } + if (n != 2) + result_digit = CAPIDTMF_RECV_NO_DIGIT; + + if (result_digit == CAPIDTMF_RECV_NO_DIGIT) + { + if (p_state->recv.current_digit_on_time != 0) + { + if (++(p_state->recv.current_digit_off_time) >= p_state->recv.min_gap_duration) + { + p_state->recv.current_digit_on_time = 0; + p_state->recv.current_digit_off_time = 0; + } + } + else + { + if (p_state->recv.current_digit_off_time != 0) + (p_state->recv.current_digit_off_time)--; + } + } + else + { + if ((p_state->recv.current_digit_on_time == 0) + && (p_state->recv.current_digit_off_time != 0)) + { + (p_state->recv.current_digit_off_time)--; + } + else + { + n = p_state->recv.current_digit_off_time; + if ((p_state->recv.current_digit_on_time != 0) + && (result_digit != p_state->recv.current_digit_value)) + { + p_state->recv.current_digit_on_time = 0; + n = 0; + } + p_state->recv.current_digit_value = result_digit; + p_state->recv.current_digit_off_time = 0; + if (p_state->recv.current_digit_on_time != 0xffff) + { + p_state->recv.current_digit_on_time += n + 1; + if (p_state->recv.current_digit_on_time >= p_state->recv.min_digit_duration) + { + p_state->recv.current_digit_on_time = 0xffff; + i = (p_state->recv.digit_write_pos == CAPIDTMF_RECV_DIGIT_BUFFER_SIZE - 1) ? + 0 : p_state->recv.digit_write_pos + 1; + if (i == p_state->recv.digit_read_pos) + { + trace(dprintf("%s,%d: Receive digit overrun", + (char *)(FILE_), __LINE__)); + } + else + { + p_state->recv.digit_buffer[p_state->recv.digit_write_pos] = result_digit; + p_state->recv.digit_write_pos = i; + p_state->recv.indication_state = + (p_state->recv.indication_state & ~CAPIDTMF_RECV_INDICATION_DIGIT) | + (~p_state->recv.indication_state_ack & CAPIDTMF_RECV_INDICATION_DIGIT); + } + } + } + } + } + cycle_counter = 0; + sample_number++; + } + } + p_state->recv.cycle_counter = cycle_counter; + } } -void capidtmf_init (t_capidtmf_state *p_state, byte ulaw) +void capidtmf_init(t_capidtmf_state *p_state, byte ulaw) { - p_state->ulaw = ulaw; - capidtmf_recv_init (p_state); + p_state->ulaw = ulaw; + capidtmf_recv_init(p_state); } diff --git a/drivers/isdn/hardware/eicon/capidtmf.h b/drivers/isdn/hardware/eicon/capidtmf.h index 242048fb2dd7..0a9cf59bb224 100644 --- a/drivers/isdn/hardware/eicon/capidtmf.h +++ b/drivers/isdn/hardware/eicon/capidtmf.h @@ -1,29 +1,29 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#ifndef CAPIDTMF_H_ +#ifndef CAPIDTMF_H_ #define CAPIDTMF_H_ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -48,32 +48,32 @@ #define CAPIDTMF_RECV_STATE_DTMF_ACTIVE 0x01 typedef struct tag_capidtmf_recv_state { - byte digit_buffer[CAPIDTMF_RECV_DIGIT_BUFFER_SIZE]; - word digit_write_pos; - word digit_read_pos; - word indication_state; - word indication_state_ack; - long goertzel_buffer[2][CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; - word min_gap_duration; - word min_digit_duration; - word cycle_counter; - word current_digit_on_time; - word current_digit_off_time; - byte current_digit_value; - byte state; + byte digit_buffer[CAPIDTMF_RECV_DIGIT_BUFFER_SIZE]; + word digit_write_pos; + word digit_read_pos; + word indication_state; + word indication_state_ack; + long goertzel_buffer[2][CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; + word min_gap_duration; + word min_digit_duration; + word cycle_counter; + word current_digit_on_time; + word current_digit_off_time; + byte current_digit_value; + byte state; } t_capidtmf_recv_state; typedef struct tag_capidtmf_state { - byte ulaw; - t_capidtmf_recv_state recv; + byte ulaw; + t_capidtmf_recv_state recv; } t_capidtmf_state; -word capidtmf_recv_indication (t_capidtmf_state *p_state, byte *buffer); -void capidtmf_recv_block (t_capidtmf_state *p_state, byte *buffer, word length); -void capidtmf_init (t_capidtmf_state *p_state, byte ulaw); -void capidtmf_recv_enable (t_capidtmf_state *p_state, word min_digit_duration, word min_gap_duration); -void capidtmf_recv_disable (t_capidtmf_state *p_state); -#define capidtmf_indication(p_state,buffer) (((p_state)->recv.indication_state != (p_state)->recv.indication_state_ack) ? capidtmf_recv_indication (p_state, buffer) : 0) -#define capidtmf_recv_process_block(p_state,buffer,length) { if ((p_state)->recv.state != CAPIDTMF_RECV_STATE_IDLE) capidtmf_recv_block (p_state, buffer, length); } +word capidtmf_recv_indication(t_capidtmf_state *p_state, byte *buffer); +void capidtmf_recv_block(t_capidtmf_state *p_state, byte *buffer, word length); +void capidtmf_init(t_capidtmf_state *p_state, byte ulaw); +void capidtmf_recv_enable(t_capidtmf_state *p_state, word min_digit_duration, word min_gap_duration); +void capidtmf_recv_disable(t_capidtmf_state *p_state); +#define capidtmf_indication(p_state, buffer) (((p_state)->recv.indication_state != (p_state)->recv.indication_state_ack) ? capidtmf_recv_indication(p_state, buffer) : 0) +#define capidtmf_recv_process_block(p_state, buffer, length) { if ((p_state)->recv.state != CAPIDTMF_RECV_STATE_IDLE) capidtmf_recv_block(p_state, buffer, length); } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ -#endif +#endif diff --git a/drivers/isdn/hardware/eicon/capifunc.c b/drivers/isdn/hardware/eicon/capifunc.c index 4d425c644d41..a576f32e6635 100644 --- a/drivers/isdn/hardware/eicon/capifunc.c +++ b/drivers/isdn/hardware/eicon/capifunc.c @@ -2,10 +2,10 @@ * * ISDN interface module for Eicon active cards DIVA. * CAPI Interface common functions - * - * Copyright 2000-2003 by Armin Schindler (mac@melware.de) + * + * Copyright 2000-2003 by Armin Schindler (mac@melware.de) * Copyright 2000-2003 Cytronics & Melware (info@melware.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -43,7 +43,7 @@ static diva_os_spin_lock_t api_lock; static LIST_HEAD(cards); static dword notify_handle; -static void DIRequest(ENTITY * e); +static void DIRequest(ENTITY *e); static DESCRIPTOR MAdapter; static DESCRIPTOR DAdapter; static byte ControllerMap[MAX_DESCRIPTORS + 1]; @@ -160,7 +160,7 @@ static int find_free_id(void) break; num++; } - return(num + 1); + return (num + 1); } /* @@ -176,23 +176,23 @@ static diva_card *find_card_by_ctrl(word controller) if (ControllerMap[card->Id] == controller) { if (card->remove_in_progress) card = NULL; - return(card); + return (card); } } return (diva_card *) 0; } /* - * Buffer RX/TX + * Buffer RX/TX */ -void *TransmitBufferSet(APPL * appl, dword ref) +void *TransmitBufferSet(APPL *appl, dword ref) { appl->xbuffer_used[ref] = true; DBG_PRV1(("%d:xbuf_used(%d)", appl->Id, ref + 1)) - return (void *)(long)ref; + return (void *)(long)ref; } -void *TransmitBufferGet(APPL * appl, void *p) +void *TransmitBufferGet(APPL *appl, void *p) { if (appl->xbuffer_internal[(dword)(long)p]) return appl->xbuffer_internal[(dword)(long)p]; @@ -200,13 +200,13 @@ void *TransmitBufferGet(APPL * appl, void *p) return appl->xbuffer_ptr[(dword)(long)p]; } -void TransmitBufferFree(APPL * appl, void *p) +void TransmitBufferFree(APPL *appl, void *p) { appl->xbuffer_used[(dword)(long)p] = false; DBG_PRV1(("%d:xbuf_free(%d)", appl->Id, ((dword)(long)p) + 1)) -} + } -void *ReceiveBufferGet(APPL * appl, int Num) +void *ReceiveBufferGet(APPL *appl, int Num) { return &appl->ReceiveBuffer[Num * appl->MaxDataLength]; } @@ -217,12 +217,12 @@ void *ReceiveBufferGet(APPL * appl, int Num) void api_remove_complete(void) { DBG_PRV1(("api_remove_complete")) -} + } /* * main function called by message.c */ -void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...) +void sendf(APPL *appl, word command, dword Id, word Number, byte *format, ...) { word i, j; word length = 12, dlength = 0; @@ -240,14 +240,14 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...) DBG_PRV1(("sendf(a=%d,cmd=%x,format=%s)", appl->Id, command, (byte *) format)) - PUT_WORD(&msg.header.appl_id, appl->Id); + PUT_WORD(&msg.header.appl_id, appl->Id); PUT_WORD(&msg.header.command, command); if ((byte) (command >> 8) == 0x82) Number = appl->Number++; PUT_WORD(&msg.header.number, Number); PUT_DWORD(&msg.header.controller, Id); - write = (byte *) & msg; + write = (byte *)&msg; write += 12; va_start(ap, format); @@ -287,16 +287,16 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...) if (command == _DATA_B3_I) dlength = GET_WORD( - ((byte *) & msg.info.data_b3_ind.Data_Length)); + ((byte *)&msg.info.data_b3_ind.Data_Length)); if (!(dmb = diva_os_alloc_message_buffer(length + dlength, - (void **) &write))) { + (void **) &write))) { DBG_ERR(("sendf: alloc_message_buffer failed, incoming msg dropped.")) - return; + return; } /* copy msg header to sk_buff */ - memcpy(write, (byte *) & msg, length); + memcpy(write, (byte *)&msg, length); /* if DATA_B3_IND, copy data too */ if (command == _DATA_B3_I) { @@ -318,10 +318,10 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...) if (myDriverDebugHandle.dbgMask & DL_BLK) { xlog("\x00\x02", &msg, 0x81, length); for (i = 0; i < dlength; i += 256) { - DBG_BLK((((char *)(long)GET_DWORD(&msg.info.data_b3_ind.Data)) + i, - ((dlength - i) < 256) ? (dlength - i) : 256)) - if (!(myDriverDebugHandle.dbgMask & DL_PRV0)) - break; /* not more if not explicitly requested */ + DBG_BLK((((char *)(long)GET_DWORD(&msg.info.data_b3_ind.Data)) + i, + ((dlength - i) < 256) ? (dlength - i) : 256)) + if (!(myDriverDebugHandle.dbgMask & DL_PRV0)) + break; /* not more if not explicitly requested */ } } break; @@ -333,7 +333,7 @@ void sendf(APPL * appl, word command, dword Id, word Number, byte * format, ...) if (!(card = find_card_by_ctrl(write[8] & 0x7f))) { DBG_ERR(("sendf - controller %d not found, incoming msg dropped", write[8] & 0x7f)) - diva_os_free_message_buffer(dmb); + diva_os_free_message_buffer(dmb); return; } /* send capi msg to capi layer */ @@ -388,7 +388,7 @@ static void clean_adapter(int id, struct list_head *free_mem_q) * remove a card, but ensures consistent state of LI tables * in the time adapter is removed */ -static void divacapi_remove_card(DESCRIPTOR * d) +static void divacapi_remove_card(DESCRIPTOR *d) { diva_card *card = NULL; diva_os_spin_lock_magic_t old_irql; @@ -427,14 +427,14 @@ static void divacapi_remove_card(DESCRIPTOR * d) clean_adapter(card->Id - 1, &free_mem_q); DBG_TRC(("DelAdapterMap (%d) -> (%d)", - ControllerMap[card->Id], card->Id)) - ControllerMap[card->Id] = 0; + ControllerMap[card->Id], card->Id)) + ControllerMap[card->Id] = 0; DBG_TRC(("adapter remove, max_adapter=%d", - max_adapter)); + max_adapter)); diva_os_leave_spin_lock(&api_lock, &old_irql, "remove card"); - + /* After releasing the lock, we can free the memory */ - diva_os_free (0, card); + diva_os_free(0, card); } /* free queued memory areas */ @@ -469,13 +469,13 @@ static void divacapi_remove_cards(void) /* * sync_callback */ -static void sync_callback(ENTITY * e) +static void sync_callback(ENTITY *e) { diva_os_spin_lock_magic_t old_irql; DBG_TRC(("cb:Id=%x,Rc=%x,Ind=%x", e->Id, e->Rc, e->Ind)) - diva_os_enter_spin_lock(&api_lock, &old_irql, "sync_callback"); + diva_os_enter_spin_lock(&api_lock, &old_irql, "sync_callback"); callback(e); diva_os_leave_spin_lock(&api_lock, &old_irql, "sync_callback"); } @@ -483,7 +483,7 @@ static void sync_callback(ENTITY * e) /* * add a new card */ -static int diva_add_card(DESCRIPTOR * d) +static int diva_add_card(DESCRIPTOR *d) { int k = 0, i = 0; diva_os_spin_lock_magic_t old_irql; @@ -492,19 +492,19 @@ static int diva_add_card(DESCRIPTOR * d) DIVA_CAPI_ADAPTER *a = NULL; IDI_SYNC_REQ sync_req; char serial[16]; - void* mem_to_free; + void *mem_to_free; LI_CONFIG *new_li_config_table; int j; if (!(card = (diva_card *) diva_os_malloc(0, sizeof(diva_card)))) { DBG_ERR(("diva_add_card: failed to allocate card struct.")) - return (0); + return (0); } memset((char *) card, 0x00, sizeof(diva_card)); memcpy(&card->d, d, sizeof(DESCRIPTOR)); sync_req.GetName.Req = 0; sync_req.GetName.Rc = IDI_SYNC_REQ_GET_NAME; - card->d.request((ENTITY *) & sync_req); + card->d.request((ENTITY *)&sync_req); strlcpy(card->name, sync_req.GetName.name, sizeof(card->name)); ctrl = &card->capi_ctrl; strcpy(ctrl->name, card->name); @@ -517,14 +517,14 @@ static int diva_add_card(DESCRIPTOR * d) if (attach_capi_ctr(ctrl)) { DBG_ERR(("diva_add_card: failed to attach controller.")) - diva_os_free(0, card); + diva_os_free(0, card); return (0); } - + diva_os_enter_spin_lock(&api_lock, &old_irql, "find id"); card->Id = find_free_id(); diva_os_leave_spin_lock(&api_lock, &old_irql, "find id"); - + strlcpy(ctrl->manu, M_COMPANY, sizeof(ctrl->manu)); ctrl->version.majorversion = 2; ctrl->version.minorversion = 0; @@ -533,7 +533,7 @@ static int diva_add_card(DESCRIPTOR * d) sync_req.GetSerial.Req = 0; sync_req.GetSerial.Rc = IDI_SYNC_REQ_GET_SERIAL; sync_req.GetSerial.serial = 0; - card->d.request((ENTITY *) & sync_req); + card->d.request((ENTITY *)&sync_req); if ((i = ((sync_req.GetSerial.serial & 0xff000000) >> 24))) { sprintf(serial, "%ld-%d", sync_req.GetSerial.serial & 0x00ffffff, i + 1); @@ -550,15 +550,15 @@ static int diva_add_card(DESCRIPTOR * d) DBG_TRC(("AddAdapterMap (%d) -> (%d)", ctrl->cnr, card->Id)) - sync_req.xdi_capi_prms.Req = 0; + sync_req.xdi_capi_prms.Req = 0; sync_req.xdi_capi_prms.Rc = IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS; sync_req.xdi_capi_prms.info.structure_length = - sizeof(diva_xdi_get_capi_parameters_t); - card->d.request((ENTITY *) & sync_req); + sizeof(diva_xdi_get_capi_parameters_t); + card->d.request((ENTITY *)&sync_req); a->flag_dynamic_l1_down = - sync_req.xdi_capi_prms.info.flag_dynamic_l1_down; + sync_req.xdi_capi_prms.info.flag_dynamic_l1_down; a->group_optimization_enabled = - sync_req.xdi_capi_prms.info.group_optimization_enabled; + sync_req.xdi_capi_prms.info.group_optimization_enabled; a->request = DIRequest; /* card->d.request; */ a->max_plci = card->d.channels + 30; a->max_listen = (card->d.channels > 2) ? 8 : 2; @@ -566,7 +566,7 @@ static int diva_add_card(DESCRIPTOR * d) (a->plci = (PLCI *) diva_os_malloc(0, sizeof(PLCI) * a->max_plci))) { DBG_ERR(("diva_add_card: failed alloc plci struct.")) - memset(a, 0, sizeof(DIVA_CAPI_ADAPTER)); + memset(a, 0, sizeof(DIVA_CAPI_ADAPTER)); return (0); } memset(a->plci, 0, sizeof(PLCI) * a->max_plci); @@ -625,13 +625,13 @@ static int diva_add_card(DESCRIPTOR * d) (LI_CONFIG *) diva_os_malloc(0, ((k * sizeof(LI_CONFIG) + 3) & ~3) + (2 * k) * ((k + 3) & ~3)); if (new_li_config_table == NULL) { DBG_ERR(("diva_add_card: failed alloc li_config table.")) - memset(a, 0, sizeof(DIVA_CAPI_ADAPTER)); + memset(a, 0, sizeof(DIVA_CAPI_ADAPTER)); return (0); } /* Prevent access to line interconnect table in process update */ diva_os_enter_spin_lock(&api_lock, &old_irql, "add card"); - + j = 0; for (i = 0; i < k; i++) { if ((i >= a->li_base) && (i < a->li_base + a->li_channels)) @@ -659,11 +659,11 @@ static int diva_add_card(DESCRIPTOR * d) memset(&new_li_config_table[i].coef_table[a->li_base], 0, a->li_channels); if (a->li_base + a->li_channels < k) { memcpy(&new_li_config_table[i].flag_table[a->li_base + - a->li_channels], + a->li_channels], &li_config_table[j].flag_table[a->li_base], k - (a->li_base + a->li_channels)); memcpy(&new_li_config_table[i].coef_table[a->li_base + - a->li_channels], + a->li_channels], &li_config_table[j].coef_table[a->li_base], k - (a->li_base + a->li_channels)); } @@ -689,7 +689,7 @@ static int diva_add_card(DESCRIPTOR * d) diva_os_leave_spin_lock(&api_lock, &old_irql, "add card"); if (mem_to_free) { - diva_os_free (0, mem_to_free); + diva_os_free(0, mem_to_free); } i = 0; @@ -722,7 +722,7 @@ static int diva_add_card(DESCRIPTOR * d) * register appl */ static void diva_register_appl(struct capi_ctr *ctrl, __u16 appl, - capi_register_params * rp) + capi_register_params *rp) { APPL *this; word bnum, xnum; @@ -737,38 +737,38 @@ static void diva_register_appl(struct capi_ctr *ctrl, __u16 appl, if (diva_os_in_irq()) { DBG_ERR(("CAPI_REGISTER - in irq context !")) - return; + return; } DBG_TRC(("application register Id=%d", appl)) - if (appl > MAX_APPL) { - DBG_ERR(("CAPI_REGISTER - appl.Id exceeds MAX_APPL")) - return; - } + if (appl > MAX_APPL) { + DBG_ERR(("CAPI_REGISTER - appl.Id exceeds MAX_APPL")) + return; + } if (nconn <= 0) nconn = ctrl->profile.nbchannel * -nconn; - if (nconn == 0) + if (nconn == 0) nconn = ctrl->profile.nbchannel; DBG_LOG(("CAPI_REGISTER - Id = %d", appl)) - DBG_LOG((" MaxLogicalConnections = %d(%d)", nconn, rp->level3cnt)) - DBG_LOG((" MaxBDataBuffers = %d", rp->datablkcnt)) - DBG_LOG((" MaxBDataLength = %d", rp->datablklen)) - - if (nconn < 1 || - nconn > 255 || - rp->datablklen < 80 || - rp->datablklen > 2150 || rp->datablkcnt > 255) { - DBG_ERR(("CAPI_REGISTER - invalid parameters")) - return; - } + DBG_LOG((" MaxLogicalConnections = %d(%d)", nconn, rp->level3cnt)) + DBG_LOG((" MaxBDataBuffers = %d", rp->datablkcnt)) + DBG_LOG((" MaxBDataLength = %d", rp->datablklen)) + + if (nconn < 1 || + nconn > 255 || + rp->datablklen < 80 || + rp->datablklen > 2150 || rp->datablkcnt > 255) { + DBG_ERR(("CAPI_REGISTER - invalid parameters")) + return; + } if (application[appl - 1].Id == appl) { DBG_LOG(("CAPI_REGISTER - appl already registered")) - return; /* appl already registered */ + return; /* appl already registered */ } /* alloc memory */ @@ -785,10 +785,10 @@ static void diva_register_appl(struct capi_ctr *ctrl, __u16 appl, mem_len += xnum * rp->datablklen; /* xbuffer_ptr[xnum] */ DBG_LOG((" Allocated Memory = %d", mem_len)) - if (!(p = diva_os_malloc(0, mem_len))) { - DBG_ERR(("CAPI_REGISTER - memory allocation failed")) - return; - } + if (!(p = diva_os_malloc(0, mem_len))) { + DBG_ERR(("CAPI_REGISTER - memory allocation failed")) + return; + } memset(p, 0, mem_len); DataNCCI = (void *)p; @@ -853,10 +853,10 @@ static void diva_release_appl(struct capi_ctr *ctrl, __u16 appl) DBG_TRC(("application %d(%d) cleanup", this->Id, appl)) - if (diva_os_in_irq()) { - DBG_ERR(("CAPI_RELEASE - in irq context !")) - return; - } + if (diva_os_in_irq()) { + DBG_ERR(("CAPI_RELEASE - in irq context !")) + return; + } diva_os_enter_spin_lock(&api_lock, &old_irql, "release_appl"); if (this->Id) { @@ -876,7 +876,7 @@ static void diva_release_appl(struct capi_ctr *ctrl, __u16 appl) * send message */ static u16 diva_send_message(struct capi_ctr *ctrl, - diva_os_message_buffer_s * dmb) + diva_os_message_buffer_s *dmb) { int i = 0; word ret = 0; @@ -891,14 +891,14 @@ static u16 diva_send_message(struct capi_ctr *ctrl, if (diva_os_in_irq()) { DBG_ERR(("CAPI_SEND_MSG - in irq context !")) - return CAPI_REGOSRESOURCEERR; + return CAPI_REGOSRESOURCEERR; } DBG_PRV1(("Write - appl = %d, cmd = 0x%x", this->Id, command)) - if (card->remove_in_progress) { - DBG_ERR(("CAPI_SEND_MSG - remove in progress!")) - return CAPI_REGOSRESOURCEERR; - } + if (card->remove_in_progress) { + DBG_ERR(("CAPI_SEND_MSG - remove in progress!")) + return CAPI_REGOSRESOURCEERR; + } diva_os_enter_spin_lock(&api_lock, &old_irql, "send message"); @@ -909,7 +909,7 @@ static u16 diva_send_message(struct capi_ctr *ctrl, /* patch controller number */ msg->header.controller = ControllerMap[card->Id] - | (msg->header.controller & 0x80); /* preserve external controller bit */ + | (msg->header.controller & 0x80); /* preserve external controller bit */ switch (command) { default: @@ -937,15 +937,15 @@ static u16 diva_send_message(struct capi_ctr *ctrl, || GET_WORD(&msg->info.data_b3_req.Data_Length) > (length - clength)) { DBG_ERR(("Write - invalid message size")) - retval = CAPI_ILLCMDORSUBCMDORMSGTOSMALL; + retval = CAPI_ILLCMDORSUBCMDORMSGTOSMALL; goto write_end; } for (i = 0; i < (MAX_DATA_B3 * this->MaxNCCI) - && this->xbuffer_used[i]; i++); + && this->xbuffer_used[i]; i++); if (i == (MAX_DATA_B3 * this->MaxNCCI)) { DBG_ERR(("Write - too many data pending")) - retval = CAPI_SENDQUEUEFULL; + retval = CAPI_SENDQUEUEFULL; goto write_end; } msg->info.data_b3_req.Data = i; @@ -959,13 +959,13 @@ static u16 diva_send_message(struct capi_ctr *ctrl, && (myDriverDebugHandle.dbgMask & DL_XLOG)) { int j; for (j = 0; j < - GET_WORD(&msg->info.data_b3_req.Data_Length); + GET_WORD(&msg->info.data_b3_req.Data_Length); j += 256) { DBG_BLK((((char *) this->xbuffer_ptr[i]) + j, - ((GET_WORD(&msg->info.data_b3_req.Data_Length) - j) < + ((GET_WORD(&msg->info.data_b3_req.Data_Length) - j) < 256) ? (GET_WORD(&msg->info.data_b3_req.Data_Length) - j) : 256)) - if (!(myDriverDebugHandle.dbgMask & DL_PRV0)) - break; /* not more if not explicitly requested */ + if (!(myDriverDebugHandle.dbgMask & DL_PRV0)) + break; /* not more if not explicitly requested */ } } #endif @@ -984,19 +984,19 @@ static u16 diva_send_message(struct capi_ctr *ctrl, break; case _BAD_MSG: DBG_ERR(("Write - bad message")) - retval = CAPI_ILLCMDORSUBCMDORMSGTOSMALL; + retval = CAPI_ILLCMDORSUBCMDORMSGTOSMALL; break; case _QUEUE_FULL: DBG_ERR(("Write - queue full")) - retval = CAPI_SENDQUEUEFULL; + retval = CAPI_SENDQUEUEFULL; break; default: DBG_ERR(("Write - api_put returned unknown error")) - retval = CAPI_UNKNOWNNOTPAR; + retval = CAPI_UNKNOWNNOTPAR; break; } - write_end: +write_end: diva_os_leave_spin_lock(&api_lock, &old_irql, "send message"); if (retval == CAPI_NOERROR) diva_os_free_message_buffer(dmb); @@ -1007,7 +1007,7 @@ static u16 diva_send_message(struct capi_ctr *ctrl, /* * cards request function */ -static void DIRequest(ENTITY * e) +static void DIRequest(ENTITY *e) { DIVA_CAPI_ADAPTER *a = &(adapter[(byte) e->user[0]]); diva_card *os_card = (diva_card *) a->os_card; @@ -1022,7 +1022,7 @@ static void DIRequest(ENTITY * e) /* * callback function from didd */ -static void didd_callback(void *context, DESCRIPTOR * adapter, int removal) +static void didd_callback(void *context, DESCRIPTOR *adapter, int removal) { if (adapter->type == IDI_DADAPTER) { DBG_ERR(("Notification about IDI_DADAPTER change ! Oops.")); @@ -1071,17 +1071,17 @@ static int divacapi_connect_didd(void) memcpy(&DAdapter, &DIDD_Table[x], sizeof(DAdapter)); req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = - IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; + IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; req.didd_notify.info.callback = (void *)didd_callback; req.didd_notify.info.context = NULL; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); if (req.didd_notify.e.Rc != 0xff) { stop_dbg(); return (0); } notify_handle = req.didd_notify.info.handle; } - else if ((DIDD_Table[x].type > 0) && (DIDD_Table[x].type < 16)) { /* IDI Adapter found */ + else if ((DIDD_Table[x].type > 0) && (DIDD_Table[x].type < 16)) { /* IDI Adapter found */ diva_add_card(&DIDD_Table[x]); } } @@ -1105,12 +1105,12 @@ static void divacapi_disconnect_didd(void) req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY; req.didd_notify.info.handle = notify_handle; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); } /* * we do not provide date/time here, - * the application should do this. + * the application should do this. */ int fax_head_line_time(char *buffer) { @@ -1124,19 +1124,19 @@ static int DIVA_INIT_FUNCTION init_main_structs(void) { if (!(mapped_msg = (CAPI_MSG *) diva_os_malloc(0, MAX_MSG_SIZE))) { DBG_ERR(("init: failed alloc mapped_msg.")) - return 0; + return 0; } if (!(adapter = diva_os_malloc(0, sizeof(DIVA_CAPI_ADAPTER) * MAX_DESCRIPTORS))) { DBG_ERR(("init: failed alloc adapter struct.")) - diva_os_free(0, mapped_msg); + diva_os_free(0, mapped_msg); return 0; } memset(adapter, 0, sizeof(DIVA_CAPI_ADAPTER) * MAX_DESCRIPTORS); if (!(application = diva_os_malloc(0, sizeof(APPL) * MAX_APPL))) { DBG_ERR(("init: failed alloc application struct.")) - diva_os_free(0, mapped_msg); + diva_os_free(0, mapped_msg); diva_os_free(0, adapter); return 0; } @@ -1176,7 +1176,7 @@ static void do_api_remove_start(void) if (ret) DBG_ERR(("could not remove signaling ID's")) -} + } /* * init @@ -1190,13 +1190,13 @@ int DIVA_INIT_FUNCTION init_capifunc(void) if (!init_main_structs()) { DBG_ERR(("init: failed to init main structs.")) - diva_os_destroy_spin_lock(&api_lock, "capifunc"); + diva_os_destroy_spin_lock(&api_lock, "capifunc"); return (0); } if (!divacapi_connect_didd()) { DBG_ERR(("init: failed to connect to DIDD.")) - do_api_remove_start(); + do_api_remove_start(); divacapi_remove_cards(); remove_main_structs(); diva_os_destroy_spin_lock(&api_lock, "capifunc"); diff --git a/drivers/isdn/hardware/eicon/capifunc.h b/drivers/isdn/hardware/eicon/capifunc.h index bd256f29738c..e96c45bb5638 100644 --- a/drivers/isdn/hardware/eicon/capifunc.h +++ b/drivers/isdn/hardware/eicon/capifunc.h @@ -2,8 +2,8 @@ * * ISDN interface module for Eicon active cards DIVA. * CAPI Interface common functions - * - * Copyright 2000-2003 by Armin Schindler (mac@melware.de) + * + * Copyright 2000-2003 by Armin Schindler (mac@melware.de) * Copyright 2000-2003 Cytronics & Melware (info@melware.de) * * This software may be used and distributed according to the terms diff --git a/drivers/isdn/hardware/eicon/capimain.c b/drivers/isdn/hardware/eicon/capimain.c index 97a20964cfc7..eabe0fa1b627 100644 --- a/drivers/isdn/hardware/eicon/capimain.c +++ b/drivers/isdn/hardware/eicon/capimain.c @@ -2,10 +2,10 @@ * * ISDN interface module for Eicon active cards DIVA. * CAPI Interface - * - * Copyright 2000-2003 by Armin Schindler (mac@melware.de) + * + * Copyright 2000-2003 by Armin Schindler (mac@melware.de) * Copyright 2000-2003 Cytronics & Melware (info@melware.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. */ @@ -28,7 +28,7 @@ static char *main_revision = "$Revision: 1.24 $"; static char *DRIVERNAME = - "Eicon DIVA - CAPI Interface driver (http://www.melware.net)"; + "Eicon DIVA - CAPI Interface driver (http://www.melware.net)"; static char *DRIVERLNAME = "divacapi"; MODULE_DESCRIPTION("CAPI driver for Eicon DIVA cards"); @@ -69,7 +69,7 @@ diva_os_message_buffer_s *diva_os_alloc_message_buffer(unsigned long size, /* * free a message buffer */ -void diva_os_free_message_buffer(diva_os_message_buffer_s * dmb) +void diva_os_free_message_buffer(diva_os_message_buffer_s *dmb) { kfree_skb(dmb); } diff --git a/drivers/isdn/hardware/eicon/cardtype.h b/drivers/isdn/hardware/eicon/cardtype.h index 18a5c42fffdb..8b20e22cae1e 100644 --- a/drivers/isdn/hardware/eicon/cardtype.h +++ b/drivers/isdn/hardware/eicon/cardtype.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef _CARDTYPE_H_ @@ -94,7 +94,7 @@ */ #define CARD_UNKNOWN 0 #define CARD_NONE 0 - /* DIVA cards */ +/* DIVA cards */ #define CARDTYPE_DIVA_MCA 0 #define CARDTYPE_DIVA_ISA 1 #define CARDTYPE_DIVA_PCM 2 @@ -102,10 +102,10 @@ #define CARDTYPE_DIVAPRO_PCM 4 #define CARDTYPE_DIVAPICO_ISA 5 #define CARDTYPE_DIVAPICO_PCM 6 - /* DIVA 2.0 cards */ +/* DIVA 2.0 cards */ #define CARDTYPE_DIVAPRO20_PCI 7 #define CARDTYPE_DIVA20_PCI 8 - /* S cards */ +/* S cards */ #define CARDTYPE_QUADRO_ISA 9 #define CARDTYPE_S_ISA 10 #define CARDTYPE_S_MCA 11 @@ -117,57 +117,57 @@ #define CARDTYPE_SCOM_MCA 17 #define CARDTYPE_PR_ISA 18 #define CARDTYPE_PR_MCA 19 - /* Diva Server cards (formerly called Maestra, later Amadeo) */ +/* Diva Server cards (formerly called Maestra, later Amadeo) */ #define CARDTYPE_MAESTRA_ISA 20 #define CARDTYPE_MAESTRA_PCI 21 - /* Diva Server cards to be developed (Quadro, Primary rate) */ +/* Diva Server cards to be developed (Quadro, Primary rate) */ #define CARDTYPE_DIVASRV_Q_8M_PCI 22 #define CARDTYPE_DIVASRV_P_30M_PCI 23 #define CARDTYPE_DIVASRV_P_2M_PCI 24 #define CARDTYPE_DIVASRV_P_9M_PCI 25 - /* DIVA 2.0 cards */ +/* DIVA 2.0 cards */ #define CARDTYPE_DIVA20_ISA 26 #define CARDTYPE_DIVA20U_ISA 27 #define CARDTYPE_DIVA20U_PCI 28 #define CARDTYPE_DIVAPRO20_ISA 29 #define CARDTYPE_DIVAPRO20U_ISA 30 #define CARDTYPE_DIVAPRO20U_PCI 31 - /* DIVA combi cards (piccola ISDN + rockwell V.34 modem) */ +/* DIVA combi cards (piccola ISDN + rockwell V.34 modem) */ #define CARDTYPE_DIVAMOBILE_PCM 32 #define CARDTYPE_TDKGLOBALPRO_PCM 33 - /* DIVA Pro PC OEM card for 'New Media Corporation' */ +/* DIVA Pro PC OEM card for 'New Media Corporation' */ #define CARDTYPE_NMC_DIVAPRO_PCM 34 - /* DIVA Pro 2.0 OEM cards for 'British Telecom' */ +/* DIVA Pro 2.0 OEM cards for 'British Telecom' */ #define CARDTYPE_BT_EXLANE_PCI 35 #define CARDTYPE_BT_EXLANE_ISA 36 - /* DIVA low cost cards, 1st name DIVA 3.0, 2nd DIVA 2.01, 3rd ??? */ +/* DIVA low cost cards, 1st name DIVA 3.0, 2nd DIVA 2.01, 3rd ??? */ #define CARDTYPE_DIVALOW_ISA 37 #define CARDTYPE_DIVALOWU_ISA 38 #define CARDTYPE_DIVALOW_PCI 39 #define CARDTYPE_DIVALOWU_PCI 40 - /* DIVA combi cards (piccola ISDN + rockwell V.90 modem) */ +/* DIVA combi cards (piccola ISDN + rockwell V.90 modem) */ #define CARDTYPE_DIVAMOBILE_V90_PCM 41 #define CARDTYPE_TDKGLOBPRO_V90_PCM 42 #define CARDTYPE_DIVASRV_P_23M_PCI 43 #define CARDTYPE_DIVALOW_USB 44 - /* DIVA Audio (CT) family */ +/* DIVA Audio (CT) family */ #define CARDTYPE_DIVA_CT_ST 45 #define CARDTYPE_DIVA_CT_U 46 #define CARDTYPE_DIVA_CTLITE_ST 47 #define CARDTYPE_DIVA_CTLITE_U 48 - /* DIVA ISDN plus V.90 series */ +/* DIVA ISDN plus V.90 series */ #define CARDTYPE_DIVAISDN_V90_PCM 49 #define CARDTYPE_DIVAISDN_V90_PCI 50 #define CARDTYPE_DIVAISDN_TA 51 - /* DIVA Server Voice cards */ +/* DIVA Server Voice cards */ #define CARDTYPE_DIVASRV_VOICE_Q_8M_PCI 52 - /* DIVA Server V2 cards */ +/* DIVA Server V2 cards */ #define CARDTYPE_DIVASRV_Q_8M_V2_PCI 53 #define CARDTYPE_DIVASRV_P_30M_V2_PCI 54 - /* DIVA Server Voice V2 cards */ +/* DIVA Server Voice V2 cards */ #define CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI 55 #define CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI 56 - /* Diva LAN */ +/* Diva LAN */ #define CARDTYPE_DIVAISDN_LAN 57 #define CARDTYPE_DIVA_202_PCI_ST 58 #define CARDTYPE_DIVA_202_PCI_U 59 @@ -182,7 +182,7 @@ #define CARDTYPE_DIVA_V2_PCM 67 /* Re-badged Diva Pro PC Card */ #define CARDTYPE_DIVA_PC_CARD 68 - /* next free card type identifier */ +/* next free card type identifier */ #define CARDTYPE_MAX 69 /* * The card families @@ -246,47 +246,47 @@ */ typedef struct CARD_PROPERTIES { char *Name; /* official marketing name */ - unsigned short PnPId; /* plug and play ID (for non PCMIA cards) */ - unsigned short Version; /* major and minor version no of the card */ - unsigned char DescType; /* card type to set in the IDI descriptor */ - unsigned char Family; /* basic family of the card */ - unsigned short Features; /* features bits to set in the IDI desc. */ - unsigned char Card; /* basic card type */ - unsigned char IType; /* internal type of S cards (read from ram) */ - unsigned char Bus; /* bus type this card is designed for */ - unsigned char Chip; /* chipset used on card */ - unsigned char Adapters; /* number of adapters on card */ - unsigned char Channels; /* # of channels per adapter */ - unsigned short E_info; /* # of ram entity info structs per adapter */ - unsigned short SizeIo; /* size of IO window per adapter */ - unsigned short SizeMem; /* size of memory window per adapter */ + unsigned short PnPId; /* plug and play ID (for non PCMIA cards) */ + unsigned short Version; /* major and minor version no of the card */ + unsigned char DescType; /* card type to set in the IDI descriptor */ + unsigned char Family; /* basic family of the card */ + unsigned short Features; /* features bits to set in the IDI desc. */ + unsigned char Card; /* basic card type */ + unsigned char IType; /* internal type of S cards (read from ram) */ + unsigned char Bus; /* bus type this card is designed for */ + unsigned char Chip; /* chipset used on card */ + unsigned char Adapters; /* number of adapters on card */ + unsigned char Channels; /* # of channels per adapter */ + unsigned short E_info; /* # of ram entity info structs per adapter */ + unsigned short SizeIo; /* size of IO window per adapter */ + unsigned short SizeMem; /* size of memory window per adapter */ } CARD_PROPERTIES; typedef struct CARD_RESOURCE -{ unsigned char Int [10]; - unsigned short IoFirst; - unsigned short IoStep; - unsigned short IoCnt; - unsigned long MemFirst; - unsigned long MemStep; - unsigned short MemCnt; +{ unsigned char Int[10]; + unsigned short IoFirst; + unsigned short IoStep; + unsigned short IoCnt; + unsigned long MemFirst; + unsigned long MemStep; + unsigned short MemCnt; } CARD_RESOURCE; /* test if the card of type 't' is a plug & play card */ -#define IS_PNP(t) \ -( \ - ( \ - CardProperties[t].Bus != BUS_ISA \ - && \ - CardProperties[t].Bus != BUS_MCA \ - ) \ - || \ - ( \ - CardProperties[t].Family != FAMILY_S \ - && \ - CardProperties[t].Card != CARD_DIVA \ - ) \ -) +#define IS_PNP(t) \ + ( \ + ( \ + CardProperties[t].Bus != BUS_ISA \ + && \ + CardProperties[t].Bus != BUS_MCA \ + ) \ + || \ + ( \ + CardProperties[t].Family != FAMILY_S \ + && \ + CardProperties[t].Card != CARD_DIVA \ + ) \ + ) /* extract IDI Descriptor info for card type 't' (p == DescType/Features) */ -#define IDI_PROP(t,p) (CardProperties[t].p) +#define IDI_PROP(t, p) (CardProperties[t].p) #if CARDTYPE_H_WANT_DATA #if CARDTYPE_H_WANT_IDI_DATA /* include "di_defs.h" for IDI adapter type and feature flag definitions */ @@ -328,502 +328,502 @@ typedef struct CARD_RESOURCE #define DI_SOFT_V110 0 #endif /*--- CardProperties [Index=CARDTYPE_....] ---------------------------------*/ -CARD_PROPERTIES CardProperties [ ] = +CARD_PROPERTIES CardProperties[] = { -{ /* 0 */ - "Diva MCA", 0x6336, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3, - CARD_DIVA, CARD_I_NONE, BUS_MCA, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 1 */ - "Diva ISA", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3, - CARD_DIVA, CARD_I_NONE, BUS_ISA, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 2 */ - "Diva/PCM", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3, - CARD_DIVA, CARD_I_NONE, BUS_PCM, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 3 */ - "Diva PRO ISA", 0x0031, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 4 */ - "Diva PRO PC-Card", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_PRO, CARD_I_NONE, BUS_PCM, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 5 */ - "Diva PICCOLA ISA", 0x0051, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_ISA, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 6 */ - "Diva PICCOLA PCM", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 7 */ - "Diva PRO 2.0 S/T PCI", 0xe001, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, - CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 8 */ - "Diva 2.0 S/T PCI", 0xe002, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCI, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 9 */ - "QUADRO ISA", 0x0000, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_NULL, - CARD_QUAD, CARD_I_QUAD, BUS_ISA, CHIP_NONE, - 4, 2, 16, 0, 0x800 -}, -{ /* 10 */ - "S ISA", 0x0000, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_CODEC, - CARD_S, CARD_I_S, BUS_ISA, CHIP_NONE, - 1, 1, 16, 0, 0x800 -}, -{ /* 11 */ - "S MCA", 0x6a93, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_CODEC, - CARD_S, CARD_I_S, BUS_MCA, CHIP_NONE, - 1, 1, 16, 16, 0x400 -}, -{ /* 12 */ - "SX ISA", 0x0000, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_NULL, - CARD_SX, CARD_I_SX, BUS_ISA, CHIP_NONE, - 1, 2, 16, 0, 0x800 -}, -{ /* 13 */ - "SX MCA", 0x6a93, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_NULL, - CARD_SX, CARD_I_SX, BUS_MCA, CHIP_NONE, - 1, 2, 16, 16, 0x400 -}, -{ /* 14 */ - "SXN ISA", 0x0000, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_NULL, - CARD_SXN, CARD_I_SCOM, BUS_ISA, CHIP_NONE, - 1, 2, 16, 0, 0x800 -}, -{ /* 15 */ - "SXN MCA", 0x6a93, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_NULL, - CARD_SXN, CARD_I_SCOM, BUS_MCA, CHIP_NONE, - 1, 2, 16, 16, 0x400 -}, -{ /* 16 */ - "SCOM ISA", 0x0000, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_CODEC, - CARD_SCOM, CARD_I_SCOM, BUS_ISA, CHIP_NONE, - 1, 2, 16, 0, 0x800 -}, -{ /* 17 */ - "SCOM MCA", 0x6a93, 0x0100, - IDI_ADAPTER_S, FAMILY_S, DI_CODEC, - CARD_SCOM, CARD_I_SCOM, BUS_MCA, CHIP_NONE, - 1, 2, 16, 16, 0x400 -}, -{ /* 18 */ - "S2M ISA", 0x0000, 0x0100, - IDI_ADAPTER_PR, FAMILY_S, DI_NULL, - CARD_PR, CARD_I_PR, BUS_ISA, CHIP_NONE, - 1, 30, 256, 0, 0x4000 -}, -{ /* 19 */ - "S2M MCA", 0x6abb, 0x0100, - IDI_ADAPTER_PR, FAMILY_S, DI_NULL, - CARD_PR, CARD_I_PR, BUS_MCA, CHIP_NONE, - 1, 30, 256, 16, 0x4000 -}, -{ /* 20 */ - "Diva Server BRI-2M ISA", 0x0041, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAE, CARD_I_NONE, BUS_ISA, CHIP_DSP, - 1, 2, 16, 8, 0 -}, -{ /* 21 */ - "Diva Server BRI-2M PCI", 0xE010, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAE, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 16, 8, 0 -}, -{ /* 22 */ - "Diva Server 4BRI-8M PCI", 0xE012, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 4, 2, 16, 8, 0 -}, -{ /* 23 */ - "Diva Server PRI-30M PCI", 0xE014, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 30, 256, 8, 0 -}, -{ /* 24 */ - "Diva Server PRI-2M PCI", 0xe014, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 30, 256, 8, 0 -}, -{ /* 25 */ - "Diva Server PRI-9M PCI", 0x0000, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 30, 256, 8, 0 -}, -{ /* 26 */ - "Diva 2.0 S/T ISA", 0x0071, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_ISA, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 27 */ - "Diva 2.0 U ISA", 0x0091, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_ISA, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 28 */ - "Diva 2.0 U PCI", 0xe004, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCI, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 29 */ - "Diva PRO 2.0 S/T ISA", 0x0061, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, - CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 30 */ - "Diva PRO 2.0 U ISA", 0x0081, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, - CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 31 */ - "Diva PRO 2.0 U PCI", 0xe003, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, - CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 32 */ - "Diva MOBILE", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 33 */ - "TDK DFI3600", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 34 (OEM version of 4 - "Diva PRO PC-Card") */ - "New Media ISDN", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_PRO, CARD_I_NONE, BUS_PCM, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 35 (OEM version of 7 - "Diva PRO 2.0 S/T PCI") */ - "BT ExLane PCI", 0xe101, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, - CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 36 (OEM version of 29 - "Diva PRO 2.0 S/T ISA") */ - "BT ExLane ISA", 0x1061, 0x0200, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, - CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -{ /* 37 */ - "Diva 2.01 S/T ISA", 0x00A1, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_ISA, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 38 */ - "Diva 2.01 U ISA", 0x00B1, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_ISA, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 39 */ - "Diva 2.01 S/T PCI", 0xe005, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 40 no ID yet */ - "Diva 2.01 U PCI", 0x0000, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 41 */ - "Diva MOBILE V.90", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 42 */ - "TDK DFI3600 V.90", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, - 1, 2, 0, 8, 0 -}, -{ /* 43 */ - "Diva Server PRI-23M PCI", 0xe014, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 30, 256, 8, 0 -}, -{ /* 44 */ - "Diva 2.01 S/T USB", 0x1000, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_USB, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 45 */ - "Diva CT S/T PCI", 0xe006, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 0, 0 -}, -{ /* 46 */ - "Diva CT U PCI", 0xe007, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 0, 0 -}, -{ /* 47 */ - "Diva CT Lite S/T PCI", 0xe008, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 0, 0 -}, -{ /* 48 */ - "Diva CT Lite U PCI", 0xe009, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 0, 0 -}, -{ /* 49 */ - "Diva ISDN+V.90 PC Card", 0x8D8C, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_DIVALOW, CARD_I_NONE, BUS_PCM, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 50 */ - "Diva ISDN+V.90 PCI", 0xe00A, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPAC, - 1, 2, 0, 8, 0 -}, -{ /* 51 (DivaTA) no ID */ - "Diva TA", 0x0000, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V110 | DI_FAX3 | SOFT_DSP_ADD_FEATURES, - CARD_DIVATA, CARD_I_NONE, BUS_COM, CHIP_EXTERN, - 1, 1, 0, 8, 0 -}, -{ /* 52 (Diva Server 4BRI-8M PCI adapter enabled for Voice) */ - "Diva Server Voice 4BRI-8M PCI", 0xE016, 0x0100, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, - CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 4, 2, 16, 8, 0 -}, -{ /* 53 (Diva Server 4BRI 2.0 adapter) */ - "Diva Server 4BRI-8M 2.0 PCI", 0xE013, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 4, 2, 16, 8, 0 -}, -{ /* 54 (Diva Server PRI 2.0 adapter) */ - "Diva Server PRI 2.0 PCI", 0xE015, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 30, 256, 8, 0 -}, -{ /* 55 (Diva Server 4BRI-8M 2.0 PCI adapter enabled for Voice) */ - "Diva Server Voice 4BRI-8M 2.0 PCI", 0xE017, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, - CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 4, 2, 16, 8, 0 -}, -{ /* 56 (Diva Server PRI 2.0 PCI adapter enabled for Voice) */ - "Diva Server Voice PRI 2.0 PCI", 0xE019, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, - CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 30, 256, 8, 0 -}, -{ - /* 57 (DivaLan ) no ID */ - "Diva LAN", 0x0000, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V110 | DI_FAX3 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALAN, CARD_I_NONE, BUS_LAN, CHIP_EXTERN, - 1, 1, 0, 8, 0 -}, -{ /* 58 */ - "Diva 2.02 PCI S/T", 0xE00B, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES | DI_SOFT_V110, - CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPACX, - 1, 2, 0, 8, 0 -}, -{ /* 59 */ - "Diva 2.02 PCI U", 0xE00C, 0x0300, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPACX, - 1, 2, 0, 8, 0 -}, -{ /* 60 */ - "Diva Server BRI-2M 2.0 PCI", 0xE018, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_MAE2, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 16, 8, 0 -}, -{ /* 61 (the previous name was Diva Server BRI-2F 2.0 PCI) */ - "Diva Server 2FX", 0xE01A, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_SOFT_V110, - CARD_MAE2, CARD_I_NONE, BUS_PCI, CHIP_IPACX, - 1, 2, 16, 8, 0 -}, -{ /* 62 */ - " Diva ISDN USB 2.0", 0x1003, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_DIVALOW, CARD_I_NONE, BUS_USB, CHIP_IPACX, - 1, 2, 0, 8, 0 -}, -{ /* 63 (Diva Server BRI-2M 2.0 PCI adapter enabled for Voice) */ - "Diva Server Voice BRI-2M 2.0 PCI", 0xE01B, 0x0200, - IDI_ADAPTER_MAESTRA,FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, - CARD_MAE2, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 16, 8, 0 -}, -{ /* 64 */ - "Diva Pro 3.0 PCI", 0xe00d, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM, - CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 0, 0 -}, -{ /* 65 */ - "Diva ISDN + CT 2.0", 0xE00E, 0x0300, - IDI_ADAPTER_DIVA ,FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, - CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, - 1, 2, 0, 0, 0 -}, -{ /* 66 */ - "Diva Mobile V.90 PC Card", 0x8331, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_IPACX, - 1, 2, 0, 8, 0 -}, -{ /* 67 */ - "Diva ISDN PC Card", 0x8311, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_IPACX, - 1, 2, 0, 8, 0 -}, -{ /* 68 */ - "Diva ISDN PC Card", 0x0000, 0x0100, - IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, - CARD_PRO, CARD_I_NONE, BUS_PCM, CHIP_DSP, - 1, 2, 0, 8, 0 -}, -} ; + { /* 0 */ + "Diva MCA", 0x6336, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3, + CARD_DIVA, CARD_I_NONE, BUS_MCA, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 1 */ + "Diva ISA", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3, + CARD_DIVA, CARD_I_NONE, BUS_ISA, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 2 */ + "Diva/PCM", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3, + CARD_DIVA, CARD_I_NONE, BUS_PCM, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 3 */ + "Diva PRO ISA", 0x0031, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 4 */ + "Diva PRO PC-Card", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_PRO, CARD_I_NONE, BUS_PCM, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 5 */ + "Diva PICCOLA ISA", 0x0051, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_ISA, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 6 */ + "Diva PICCOLA PCM", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 7 */ + "Diva PRO 2.0 S/T PCI", 0xe001, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, + CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 8 */ + "Diva 2.0 S/T PCI", 0xe002, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCI, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 9 */ + "QUADRO ISA", 0x0000, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_NULL, + CARD_QUAD, CARD_I_QUAD, BUS_ISA, CHIP_NONE, + 4, 2, 16, 0, 0x800 + }, + { /* 10 */ + "S ISA", 0x0000, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_CODEC, + CARD_S, CARD_I_S, BUS_ISA, CHIP_NONE, + 1, 1, 16, 0, 0x800 + }, + { /* 11 */ + "S MCA", 0x6a93, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_CODEC, + CARD_S, CARD_I_S, BUS_MCA, CHIP_NONE, + 1, 1, 16, 16, 0x400 + }, + { /* 12 */ + "SX ISA", 0x0000, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_NULL, + CARD_SX, CARD_I_SX, BUS_ISA, CHIP_NONE, + 1, 2, 16, 0, 0x800 + }, + { /* 13 */ + "SX MCA", 0x6a93, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_NULL, + CARD_SX, CARD_I_SX, BUS_MCA, CHIP_NONE, + 1, 2, 16, 16, 0x400 + }, + { /* 14 */ + "SXN ISA", 0x0000, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_NULL, + CARD_SXN, CARD_I_SCOM, BUS_ISA, CHIP_NONE, + 1, 2, 16, 0, 0x800 + }, + { /* 15 */ + "SXN MCA", 0x6a93, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_NULL, + CARD_SXN, CARD_I_SCOM, BUS_MCA, CHIP_NONE, + 1, 2, 16, 16, 0x400 + }, + { /* 16 */ + "SCOM ISA", 0x0000, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_CODEC, + CARD_SCOM, CARD_I_SCOM, BUS_ISA, CHIP_NONE, + 1, 2, 16, 0, 0x800 + }, + { /* 17 */ + "SCOM MCA", 0x6a93, 0x0100, + IDI_ADAPTER_S, FAMILY_S, DI_CODEC, + CARD_SCOM, CARD_I_SCOM, BUS_MCA, CHIP_NONE, + 1, 2, 16, 16, 0x400 + }, + { /* 18 */ + "S2M ISA", 0x0000, 0x0100, + IDI_ADAPTER_PR, FAMILY_S, DI_NULL, + CARD_PR, CARD_I_PR, BUS_ISA, CHIP_NONE, + 1, 30, 256, 0, 0x4000 + }, + { /* 19 */ + "S2M MCA", 0x6abb, 0x0100, + IDI_ADAPTER_PR, FAMILY_S, DI_NULL, + CARD_PR, CARD_I_PR, BUS_MCA, CHIP_NONE, + 1, 30, 256, 16, 0x4000 + }, + { /* 20 */ + "Diva Server BRI-2M ISA", 0x0041, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAE, CARD_I_NONE, BUS_ISA, CHIP_DSP, + 1, 2, 16, 8, 0 + }, + { /* 21 */ + "Diva Server BRI-2M PCI", 0xE010, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAE, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 16, 8, 0 + }, + { /* 22 */ + "Diva Server 4BRI-8M PCI", 0xE012, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 4, 2, 16, 8, 0 + }, + { /* 23 */ + "Diva Server PRI-30M PCI", 0xE014, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 30, 256, 8, 0 + }, + { /* 24 */ + "Diva Server PRI-2M PCI", 0xe014, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 30, 256, 8, 0 + }, + { /* 25 */ + "Diva Server PRI-9M PCI", 0x0000, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 30, 256, 8, 0 + }, + { /* 26 */ + "Diva 2.0 S/T ISA", 0x0071, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_ISA, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 27 */ + "Diva 2.0 U ISA", 0x0091, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_ISA, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 28 */ + "Diva 2.0 U PCI", 0xe004, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | DI_POTS | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCI, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 29 */ + "Diva PRO 2.0 S/T ISA", 0x0061, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, + CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 30 */ + "Diva PRO 2.0 U ISA", 0x0081, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, + CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 31 */ + "Diva PRO 2.0 U PCI", 0xe003, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, + CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 32 */ + "Diva MOBILE", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 33 */ + "TDK DFI3600", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 34 (OEM version of 4 - "Diva PRO PC-Card") */ + "New Media ISDN", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_PRO, CARD_I_NONE, BUS_PCM, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 35 (OEM version of 7 - "Diva PRO 2.0 S/T PCI") */ + "BT ExLane PCI", 0xe101, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, + CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 36 (OEM version of 29 - "Diva PRO 2.0 S/T ISA") */ + "BT ExLane ISA", 0x1061, 0x0200, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_POTS, + CARD_PRO, CARD_I_NONE, BUS_ISA, CHIP_DSP, + 1, 2, 0, 8, 0 + }, + { /* 37 */ + "Diva 2.01 S/T ISA", 0x00A1, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_ISA, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 38 */ + "Diva 2.01 U ISA", 0x00B1, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_ISA, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 39 */ + "Diva 2.01 S/T PCI", 0xe005, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 40 no ID yet */ + "Diva 2.01 U PCI", 0x0000, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 41 */ + "Diva MOBILE V.90", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 42 */ + "TDK DFI3600 V.90", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_HSCX, + 1, 2, 0, 8, 0 + }, + { /* 43 */ + "Diva Server PRI-23M PCI", 0xe014, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 30, 256, 8, 0 + }, + { /* 44 */ + "Diva 2.01 S/T USB", 0x1000, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_USB, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 45 */ + "Diva CT S/T PCI", 0xe006, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 0, 0 + }, + { /* 46 */ + "Diva CT U PCI", 0xe007, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 0, 0 + }, + { /* 47 */ + "Diva CT Lite S/T PCI", 0xe008, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 0, 0 + }, + { /* 48 */ + "Diva CT Lite U PCI", 0xe009, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 0, 0 + }, + { /* 49 */ + "Diva ISDN+V.90 PC Card", 0x8D8C, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_DIVALOW, CARD_I_NONE, BUS_PCM, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 50 */ + "Diva ISDN+V.90 PCI", 0xe00A, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPAC, + 1, 2, 0, 8, 0 + }, + { /* 51 (DivaTA) no ID */ + "Diva TA", 0x0000, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V110 | DI_FAX3 | SOFT_DSP_ADD_FEATURES, + CARD_DIVATA, CARD_I_NONE, BUS_COM, CHIP_EXTERN, + 1, 1, 0, 8, 0 + }, + { /* 52 (Diva Server 4BRI-8M PCI adapter enabled for Voice) */ + "Diva Server Voice 4BRI-8M PCI", 0xE016, 0x0100, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, + CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 4, 2, 16, 8, 0 + }, + { /* 53 (Diva Server 4BRI 2.0 adapter) */ + "Diva Server 4BRI-8M 2.0 PCI", 0xE013, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 4, 2, 16, 8, 0 + }, + { /* 54 (Diva Server PRI 2.0 adapter) */ + "Diva Server PRI 2.0 PCI", 0xE015, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 30, 256, 8, 0 + }, + { /* 55 (Diva Server 4BRI-8M 2.0 PCI adapter enabled for Voice) */ + "Diva Server Voice 4BRI-8M 2.0 PCI", 0xE017, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, + CARD_MAEQ, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 4, 2, 16, 8, 0 + }, + { /* 56 (Diva Server PRI 2.0 PCI adapter enabled for Voice) */ + "Diva Server Voice PRI 2.0 PCI", 0xE019, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, + CARD_MAEP, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 30, 256, 8, 0 + }, + { + /* 57 (DivaLan ) no ID */ + "Diva LAN", 0x0000, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V110 | DI_FAX3 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALAN, CARD_I_NONE, BUS_LAN, CHIP_EXTERN, + 1, 1, 0, 8, 0 + }, + { /* 58 */ + "Diva 2.02 PCI S/T", 0xE00B, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES | DI_SOFT_V110, + CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPACX, + 1, 2, 0, 8, 0 + }, + { /* 59 */ + "Diva 2.02 PCI U", 0xE00C, 0x0300, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_PCI, CHIP_IPACX, + 1, 2, 0, 8, 0 + }, + { /* 60 */ + "Diva Server BRI-2M 2.0 PCI", 0xE018, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_MAE2, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 16, 8, 0 + }, + { /* 61 (the previous name was Diva Server BRI-2F 2.0 PCI) */ + "Diva Server 2FX", 0xE01A, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_SOFT_V110, + CARD_MAE2, CARD_I_NONE, BUS_PCI, CHIP_IPACX, + 1, 2, 16, 8, 0 + }, + { /* 62 */ + " Diva ISDN USB 2.0", 0x1003, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_DIVALOW, CARD_I_NONE, BUS_USB, CHIP_IPACX, + 1, 2, 0, 8, 0 + }, + { /* 63 (Diva Server BRI-2M 2.0 PCI adapter enabled for Voice) */ + "Diva Server Voice BRI-2M 2.0 PCI", 0xE01B, 0x0200, + IDI_ADAPTER_MAESTRA, FAMILY_MAESTRA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_VOICE_OVER_IP, + CARD_MAE2, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 16, 8, 0 + }, + { /* 64 */ + "Diva Pro 3.0 PCI", 0xe00d, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM, + CARD_PRO, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 0, 0 + }, + { /* 65 */ + "Diva ISDN + CT 2.0", 0xE00E, 0x0300, + IDI_ADAPTER_DIVA , FAMILY_DIVA, DI_V1x0 | DI_FAX3 | DI_MODEM | DI_CODEC, + CARD_CT, CARD_I_NONE, BUS_PCI, CHIP_DSP, + 1, 2, 0, 0, 0 + }, + { /* 66 */ + "Diva Mobile V.90 PC Card", 0x8331, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_IPACX, + 1, 2, 0, 8, 0 + }, + { /* 67 */ + "Diva ISDN PC Card", 0x8311, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PICO, CARD_I_NONE, BUS_PCM, CHIP_IPACX, + 1, 2, 0, 8, 0 + }, + { /* 68 */ + "Diva ISDN PC Card", 0x0000, 0x0100, + IDI_ADAPTER_DIVA, FAMILY_DIVA, DI_V120 | SOFT_DSP_ADD_FEATURES, + CARD_PRO, CARD_I_NONE, BUS_PCM, CHIP_DSP, + 1, 2, 0, 8, 0 + }, +}; #if CARDTYPE_H_WANT_RESOURCE_DATA /*--- CardResource [Index=CARDTYPE_....] ---------------------------(GEI)-*/ -CARD_RESOURCE CardResource [ ] = { +CARD_RESOURCE CardResource[] = { /* Interrupts IO-Address Mem-Address */ -/* 0*/ { 3,4,9,0,0,0,0,0,0,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA MCA -/* 1*/ { 3,4,9,10,11,12,0,0,0,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA ISA -/* 2*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PCMCIA -/* 3*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PRO ISA -/* 4*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PRO PCMCIA -/* 5*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PICCOLA ISA -/* 6*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA PICCOLA PCMCIA -/* 7*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PRO 2.0 PCI -/* 8*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.0 PCI -/* 9*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0x80000,0x2000,64 }, // QUADRO ISA -/*10*/ { 3,4,9,10,11,12,0,0,0,0, 0x0,0x0,0, 0xc0000,0x2000,16 }, // S ISA -/*11*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // S MCA -/*12*/ { 3,4,9,10,11,12,0,0,0,0, 0x0,0x0,0, 0xc0000,0x2000,16 }, // SX ISA -/*13*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // SX MCA -/*14*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0x80000,0x0800,256 }, // SXN ISA -/*15*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // SXN MCA -/*16*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0x80000,0x0800,256 }, // SCOM ISA -/*17*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // SCOM MCA -/*18*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0xc0000,0x4000,16 }, // S2M ISA -/*19*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x4000,16 }, // S2M MCA -/*20*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // MAESTRA ISA -/*21*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA PCI -/*22*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // MAESTRA QUADRO ISA -/*23*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA QUADRO PCI -/*24*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // MAESTRA PRIMARY ISA -/*25*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA PRIMARY PCI -/*26*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.0 ISA -/*27*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.0 /U ISA -/*28*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.0 /U PCI -/*29*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PRO 2.0 ISA -/*30*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PRO 2.0 /U ISA -/*31*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PRO 2.0 /U PCI -/*32*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA MOBILE -/*33*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // TDK DFI3600 (same as DIVA MOBILE [32]) -/*34*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // New Media ISDN (same as DIVA PRO PCMCIA [4]) -/*35*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // BT ExLane PCI (same as DIVA PRO 2.0 PCI [7]) -/*36*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // BT ExLane ISA (same as DIVA PRO 2.0 ISA [29]) -/*37*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.01 S/T ISA -/*38*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.01 U ISA -/*39*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.01 S/T PCI -/*40*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.01 U PCI -/*41*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA MOBILE V.90 -/*42*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // TDK DFI3600 V.90 (same as DIVA MOBILE V.90 [39]) -/*43*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // DIVA Server PRI-23M PCI -/*44*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA 2.01 S/T USB -/*45*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT S/T PCI -/*46*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT U PCI -/*47*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT Lite S/T PCI -/*48*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT Lite U PCI -/*49*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA ISDN+V.90 PC Card -/*50*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA ISDN+V.90 PCI -/*51*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA TA -/*52*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA VOICE QUADRO PCI -/*53*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA VOICE QUADRO PCI -/*54*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA VOICE PRIMARY PCI -/*55*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA VOICE QUADRO PCI -/*56*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA VOICE PRIMARY PCI -/*57*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA LAN -/*58*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.02 S/T PCI -/*59*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.02 U PCI -/*60*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // Diva Server BRI-2M 2.0 PCI -/*61*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // Diva Server BRI-2F PCI -/*62*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA 2.01 S/T USB -/*63*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // Diva Server Voice BRI-2M 2.0 PCI -/*64*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 3.0 PCI -/*65*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT S/T PCI V2.0 -/*66*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA Mobile V.90 PC Card -/*67*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA ISDN PC Card -/*68*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA ISDN PC Card + /* 0*/ { 3,4,9,0,0,0,0,0,0,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA MCA + /* 1*/ { 3,4,9,10,11,12,0,0,0,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA ISA + /* 2*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PCMCIA + /* 3*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PRO ISA + /* 4*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PRO PCMCIA + /* 5*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PICCOLA ISA + /* 6*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA PICCOLA PCMCIA + /* 7*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PRO 2.0 PCI + /* 8*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.0 PCI + /* 9*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0x80000,0x2000,64 }, // QUADRO ISA + /*10*/ { 3,4,9,10,11,12,0,0,0,0, 0x0,0x0,0, 0xc0000,0x2000,16 }, // S ISA + /*11*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // S MCA + /*12*/ { 3,4,9,10,11,12,0,0,0,0, 0x0,0x0,0, 0xc0000,0x2000,16 }, // SX ISA + /*13*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // SX MCA + /*14*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0x80000,0x0800,256 }, // SXN ISA + /*15*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // SXN MCA + /*16*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0x80000,0x0800,256 }, // SCOM ISA + /*17*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x2000,16 }, // SCOM MCA + /*18*/ { 3,4,5,7,9,10,11,12,0,0, 0x0,0x0,0, 0xc0000,0x4000,16 }, // S2M ISA + /*19*/ { 3,4,9,0,0,0,0,0,0,0, 0xc00,0x10,16, 0xc0000,0x4000,16 }, // S2M MCA + /*20*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // MAESTRA ISA + /*21*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA PCI + /*22*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // MAESTRA QUADRO ISA + /*23*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA QUADRO PCI + /*24*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // MAESTRA PRIMARY ISA + /*25*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA PRIMARY PCI + /*26*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.0 ISA + /*27*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.0 /U ISA + /*28*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.0 /U PCI + /*29*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PRO 2.0 ISA + /*30*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA PRO 2.0 /U ISA + /*31*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA PRO 2.0 /U PCI + /*32*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA MOBILE + /*33*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // TDK DFI3600 (same as DIVA MOBILE [32]) + /*34*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // New Media ISDN (same as DIVA PRO PCMCIA [4]) + /*35*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // BT ExLane PCI (same as DIVA PRO 2.0 PCI [7]) + /*36*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // BT ExLane ISA (same as DIVA PRO 2.0 ISA [29]) + /*37*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.01 S/T ISA + /*38*/ { 3,5,7,9,10,11,12,14,15,0, 0x200,0x20,16, 0x0,0x0,0 }, // DIVA 2.01 U ISA + /*39*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.01 S/T PCI + /*40*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.01 U PCI + /*41*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA MOBILE V.90 + /*42*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // TDK DFI3600 V.90 (same as DIVA MOBILE V.90 [39]) + /*43*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // DIVA Server PRI-23M PCI + /*44*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA 2.01 S/T USB + /*45*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT S/T PCI + /*46*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT U PCI + /*47*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT Lite S/T PCI + /*48*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT Lite U PCI + /*49*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA ISDN+V.90 PC Card + /*50*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA ISDN+V.90 PCI + /*51*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA TA + /*52*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA VOICE QUADRO PCI + /*53*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA VOICE QUADRO PCI + /*54*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA VOICE PRIMARY PCI + /*55*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x20,2048, 0x0,0x0,0 }, // MAESTRA VOICE QUADRO PCI + /*56*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // MAESTRA VOICE PRIMARY PCI + /*57*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA LAN + /*58*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.02 S/T PCI + /*59*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 2.02 U PCI + /*60*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // Diva Server BRI-2M 2.0 PCI + /*61*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // Diva Server BRI-2F PCI + /*62*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA 2.01 S/T USB + /*63*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // Diva Server Voice BRI-2M 2.0 PCI + /*64*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA 3.0 PCI + /*65*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA CT S/T PCI V2.0 + /*66*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA Mobile V.90 PC Card + /*67*/ { 0,0,0,0,0,0,0,0,0,0, 0x0,0x0,0, 0x0,0x0,0 }, // DIVA ISDN PC Card + /*68*/ { 3,4,5,7,9,10,11,12,14,15, 0x0,0x8,8192, 0x0,0x0,0 }, // DIVA ISDN PC Card }; #endif /*CARDTYPE_H_WANT_RESOURCE_DATA*/ #else /*!CARDTYPE_H_WANT_DATA*/ -extern CARD_PROPERTIES CardProperties [] ; -extern CARD_RESOURCE CardResource [] ; +extern CARD_PROPERTIES CardProperties[]; +extern CARD_RESOURCE CardResource[]; #endif /*CARDTYPE_H_WANT_DATA*/ /* * all existing download files @@ -902,197 +902,197 @@ extern CARD_RESOURCE CardResource [] ; #define CARD_D_NEW_DSP_COMBIFILE 63 typedef struct CARD_FILES_DATA { - char * Name; - unsigned char Type; + char *Name; + unsigned char Type; } -CARD_FILES_DATA; + CARD_FILES_DATA; typedef struct CARD_FILES { - unsigned char Boot; - unsigned char Dsp [CARD_DSP_CNT]; - unsigned char DspTelindus; - unsigned char Prot [CARD_PROT_CNT]; + unsigned char Boot; + unsigned char Dsp[CARD_DSP_CNT]; + unsigned char DspTelindus; + unsigned char Prot[CARD_PROT_CNT]; } -CARD_FILES; + CARD_FILES; #if CARDTYPE_H_WANT_DATA #if CARDTYPE_H_WANT_FILE_DATA -CARD_FILES_DATA CardFData [] = { +CARD_FILES_DATA CardFData[] = { // Filename Filetype - 0, CARD_FT_UNKNOWN, - "didnload.bin", CARD_FT_B, - "diprload.bin", CARD_FT_B, - "didiva.bin", CARD_FT_D, - "didivapp.bin", CARD_FT_D, - "dihscx.bin", CARD_FT_D, - "div110.bin", CARD_FT_D, - "dimodem.bin", CARD_FT_D, - "difax.bin", CARD_FT_D, - "di_etsi.bin", CARD_FT_S, - "di_1tr6.bin", CARD_FT_S, - "di_belg.bin", CARD_FT_S, - "di_franc.bin", CARD_FT_S, - "di_atel.bin", CARD_FT_S, - "di_ni.bin", CARD_FT_S, - "di_5ess.bin", CARD_FT_S, - "di_japan.bin", CARD_FT_S, - "di_etsi.sx", CARD_FT_S, - "di_1tr6.sx", CARD_FT_S, - "di_belg.sx", CARD_FT_S, - "di_franc.sx", CARD_FT_S, - "di_atel.sx", CARD_FT_S, - "di_ni.sx", CARD_FT_S, - "di_5ess.sx", CARD_FT_S, - "di_japan.sx", CARD_FT_S, - "di_etsi.sy", CARD_FT_S, - "di_1tr6.sy", CARD_FT_S, - "di_belg.sy", CARD_FT_S, - "di_franc.sy", CARD_FT_S, - "di_atel.sy", CARD_FT_S, - "di_ni.sy", CARD_FT_S, - "di_5ess.sy", CARD_FT_S, - "di_japan.sy", CARD_FT_S, - "di_etsi.sq", CARD_FT_S, - "di_1tr6.sq", CARD_FT_S, - "di_belg.sq", CARD_FT_S, - "di_franc.sq", CARD_FT_S, - "di_atel.sq", CARD_FT_S, - "di_ni.sq", CARD_FT_S, - "di_5ess.sq", CARD_FT_S, - "di_japan.sq", CARD_FT_S, - "di_etsi.p", CARD_FT_S, - "di_1tr6.p", CARD_FT_S, - "di_belg.p", CARD_FT_S, - "di_franc.p", CARD_FT_S, - "di_atel.p", CARD_FT_S, - "di_ni.p", CARD_FT_S, - "di_5ess.p", CARD_FT_S, - "di_japan.p", CARD_FT_S, - "di_etsi.sm", CARD_FT_M, - "di_1tr6.sm", CARD_FT_M, - "di_belg.sm", CARD_FT_M, - "di_franc.sm", CARD_FT_M, - "di_atel.sm", CARD_FT_M, - "di_ni.sm", CARD_FT_M, - "di_5ess.sm", CARD_FT_M, - "di_japan.sm", CARD_FT_M, - "di_swed.bin", CARD_FT_S, - "di_swed.sx", CARD_FT_S, - "di_swed.sy", CARD_FT_S, - "di_swed.sq", CARD_FT_S, - "di_swed.p", CARD_FT_S, - "di_swed.sm", CARD_FT_M, - "didspdld.bin", CARD_FT_NEW_DSP_COMBIFILE + 0, CARD_FT_UNKNOWN, + "didnload.bin", CARD_FT_B, + "diprload.bin", CARD_FT_B, + "didiva.bin", CARD_FT_D, + "didivapp.bin", CARD_FT_D, + "dihscx.bin", CARD_FT_D, + "div110.bin", CARD_FT_D, + "dimodem.bin", CARD_FT_D, + "difax.bin", CARD_FT_D, + "di_etsi.bin", CARD_FT_S, + "di_1tr6.bin", CARD_FT_S, + "di_belg.bin", CARD_FT_S, + "di_franc.bin", CARD_FT_S, + "di_atel.bin", CARD_FT_S, + "di_ni.bin", CARD_FT_S, + "di_5ess.bin", CARD_FT_S, + "di_japan.bin", CARD_FT_S, + "di_etsi.sx", CARD_FT_S, + "di_1tr6.sx", CARD_FT_S, + "di_belg.sx", CARD_FT_S, + "di_franc.sx", CARD_FT_S, + "di_atel.sx", CARD_FT_S, + "di_ni.sx", CARD_FT_S, + "di_5ess.sx", CARD_FT_S, + "di_japan.sx", CARD_FT_S, + "di_etsi.sy", CARD_FT_S, + "di_1tr6.sy", CARD_FT_S, + "di_belg.sy", CARD_FT_S, + "di_franc.sy", CARD_FT_S, + "di_atel.sy", CARD_FT_S, + "di_ni.sy", CARD_FT_S, + "di_5ess.sy", CARD_FT_S, + "di_japan.sy", CARD_FT_S, + "di_etsi.sq", CARD_FT_S, + "di_1tr6.sq", CARD_FT_S, + "di_belg.sq", CARD_FT_S, + "di_franc.sq", CARD_FT_S, + "di_atel.sq", CARD_FT_S, + "di_ni.sq", CARD_FT_S, + "di_5ess.sq", CARD_FT_S, + "di_japan.sq", CARD_FT_S, + "di_etsi.p", CARD_FT_S, + "di_1tr6.p", CARD_FT_S, + "di_belg.p", CARD_FT_S, + "di_franc.p", CARD_FT_S, + "di_atel.p", CARD_FT_S, + "di_ni.p", CARD_FT_S, + "di_5ess.p", CARD_FT_S, + "di_japan.p", CARD_FT_S, + "di_etsi.sm", CARD_FT_M, + "di_1tr6.sm", CARD_FT_M, + "di_belg.sm", CARD_FT_M, + "di_franc.sm", CARD_FT_M, + "di_atel.sm", CARD_FT_M, + "di_ni.sm", CARD_FT_M, + "di_5ess.sm", CARD_FT_M, + "di_japan.sm", CARD_FT_M, + "di_swed.bin", CARD_FT_S, + "di_swed.sx", CARD_FT_S, + "di_swed.sy", CARD_FT_S, + "di_swed.sq", CARD_FT_S, + "di_swed.p", CARD_FT_S, + "di_swed.sm", CARD_FT_M, + "didspdld.bin", CARD_FT_NEW_DSP_COMBIFILE }; -CARD_FILES CardFiles [] = +CARD_FILES CardFiles[] = { - { /* CARD_UNKNOWN */ - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE - }, - { /* CARD_DIVA */ - CARD_FILE_NONE, - CARD_D_K1, CARD_D_H, CARD_D_V, CARD_FILE_NONE, CARD_D_F, - CARD_D_NEW_DSP_COMBIFILE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE - }, - { /* CARD_PRO */ - CARD_FILE_NONE, - CARD_D_K2, CARD_D_H, CARD_D_V, CARD_D_M, CARD_D_F, - CARD_D_NEW_DSP_COMBIFILE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE - }, - { /* CARD_PICO */ - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE - }, - { /* CARD_S */ - CARD_B_S, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_P_S_E, CARD_P_S_1, CARD_P_S_B, CARD_P_S_F, - CARD_P_S_A, CARD_P_S_N, CARD_P_S_5, CARD_P_S_J, - CARD_P_S_S - }, - { /* CARD_SX */ - CARD_B_S, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_P_SX_E, CARD_P_SX_1, CARD_P_SX_B, CARD_P_SX_F, - CARD_P_SX_A, CARD_P_SX_N, CARD_P_SX_5, CARD_P_SX_J, - CARD_P_SX_S - }, - { /* CARD_SXN */ - CARD_B_S, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_P_SY_E, CARD_P_SY_1, CARD_P_SY_B, CARD_P_SY_F, - CARD_P_SY_A, CARD_P_SY_N, CARD_P_SY_5, CARD_P_SY_J, - CARD_P_SY_S - }, - { /* CARD_SCOM */ - CARD_B_S, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_P_SY_E, CARD_P_SY_1, CARD_P_SY_B, CARD_P_SY_F, - CARD_P_SY_A, CARD_P_SY_N, CARD_P_SY_5, CARD_P_SY_J, - CARD_P_SY_S - }, - { /* CARD_QUAD */ - CARD_B_S, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_P_SQ_E, CARD_P_SQ_1, CARD_P_SQ_B, CARD_P_SQ_F, - CARD_P_SQ_A, CARD_P_SQ_N, CARD_P_SQ_5, CARD_P_SQ_J, - CARD_P_SQ_S - }, - { /* CARD_PR */ - CARD_B_P, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_P_P_E, CARD_P_P_1, CARD_P_P_B, CARD_P_P_F, - CARD_P_P_A, CARD_P_P_N, CARD_P_P_5, CARD_P_P_J, - CARD_P_P_S - }, - { /* CARD_MAE */ - CARD_FILE_NONE, - CARD_D_K2, CARD_D_H, CARD_D_V, CARD_D_M, CARD_D_F, - CARD_D_NEW_DSP_COMBIFILE, - CARD_P_M_E, CARD_P_M_1, CARD_P_M_B, CARD_P_M_F, - CARD_P_M_A, CARD_P_M_N, CARD_P_M_5, CARD_P_M_J, - CARD_P_M_S - }, - { /* CARD_MAEQ */ /* currently not supported */ - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE - }, - { /* CARD_MAEP */ /* currently not supported */ - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, - CARD_FILE_NONE - } + { /* CARD_UNKNOWN */ + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE + }, + { /* CARD_DIVA */ + CARD_FILE_NONE, + CARD_D_K1, CARD_D_H, CARD_D_V, CARD_FILE_NONE, CARD_D_F, + CARD_D_NEW_DSP_COMBIFILE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE + }, + { /* CARD_PRO */ + CARD_FILE_NONE, + CARD_D_K2, CARD_D_H, CARD_D_V, CARD_D_M, CARD_D_F, + CARD_D_NEW_DSP_COMBIFILE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE + }, + { /* CARD_PICO */ + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE + }, + { /* CARD_S */ + CARD_B_S, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_P_S_E, CARD_P_S_1, CARD_P_S_B, CARD_P_S_F, + CARD_P_S_A, CARD_P_S_N, CARD_P_S_5, CARD_P_S_J, + CARD_P_S_S + }, + { /* CARD_SX */ + CARD_B_S, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_P_SX_E, CARD_P_SX_1, CARD_P_SX_B, CARD_P_SX_F, + CARD_P_SX_A, CARD_P_SX_N, CARD_P_SX_5, CARD_P_SX_J, + CARD_P_SX_S + }, + { /* CARD_SXN */ + CARD_B_S, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_P_SY_E, CARD_P_SY_1, CARD_P_SY_B, CARD_P_SY_F, + CARD_P_SY_A, CARD_P_SY_N, CARD_P_SY_5, CARD_P_SY_J, + CARD_P_SY_S + }, + { /* CARD_SCOM */ + CARD_B_S, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_P_SY_E, CARD_P_SY_1, CARD_P_SY_B, CARD_P_SY_F, + CARD_P_SY_A, CARD_P_SY_N, CARD_P_SY_5, CARD_P_SY_J, + CARD_P_SY_S + }, + { /* CARD_QUAD */ + CARD_B_S, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_P_SQ_E, CARD_P_SQ_1, CARD_P_SQ_B, CARD_P_SQ_F, + CARD_P_SQ_A, CARD_P_SQ_N, CARD_P_SQ_5, CARD_P_SQ_J, + CARD_P_SQ_S + }, + { /* CARD_PR */ + CARD_B_P, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_P_P_E, CARD_P_P_1, CARD_P_P_B, CARD_P_P_F, + CARD_P_P_A, CARD_P_P_N, CARD_P_P_5, CARD_P_P_J, + CARD_P_P_S + }, + { /* CARD_MAE */ + CARD_FILE_NONE, + CARD_D_K2, CARD_D_H, CARD_D_V, CARD_D_M, CARD_D_F, + CARD_D_NEW_DSP_COMBIFILE, + CARD_P_M_E, CARD_P_M_1, CARD_P_M_B, CARD_P_M_F, + CARD_P_M_A, CARD_P_M_N, CARD_P_M_5, CARD_P_M_J, + CARD_P_M_S + }, + { /* CARD_MAEQ */ /* currently not supported */ + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE + }, + { /* CARD_MAEP */ /* currently not supported */ + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, CARD_FILE_NONE, + CARD_FILE_NONE + } }; #endif /*CARDTYPE_H_WANT_FILE_DATA*/ #else /*!CARDTYPE_H_WANT_DATA*/ -extern CARD_FILES_DATA CardFData [] ; -extern CARD_FILES CardFiles [] ; +extern CARD_FILES_DATA CardFData[]; +extern CARD_FILES CardFiles[]; #endif /*CARDTYPE_H_WANT_DATA*/ #endif /* _CARDTYPE_H_ */ diff --git a/drivers/isdn/hardware/eicon/cp_vers.h b/drivers/isdn/hardware/eicon/cp_vers.h index cb5ada31111c..c97230c60e71 100644 --- a/drivers/isdn/hardware/eicon/cp_vers.h +++ b/drivers/isdn/hardware/eicon/cp_vers.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -static char diva_capi_common_code_build[] = "102-28"; +static char diva_capi_common_code_build[] = "102-28"; diff --git a/drivers/isdn/hardware/eicon/dadapter.c b/drivers/isdn/hardware/eicon/dadapter.c index 89497890158d..51420999418d 100644 --- a/drivers/isdn/hardware/eicon/dadapter.c +++ b/drivers/isdn/hardware/eicon/dadapter.c @@ -1,26 +1,25 @@ - /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -30,337 +29,336 @@ #include "divasync.h" #include "dadapter.h" /* -------------------------------------------------------------------------- - Adapter array change notification framework + Adapter array change notification framework -------------------------------------------------------------------------- */ typedef struct _didd_adapter_change_notification { - didd_adapter_change_callback_t callback; - void IDI_CALL_ENTITY_T * context; -} didd_adapter_change_notification_t, \ - * IDI_CALL_ENTITY_T pdidd_adapter_change_notification_t; + didd_adapter_change_callback_t callback; + void IDI_CALL_ENTITY_T *context; +} didd_adapter_change_notification_t, \ + * IDI_CALL_ENTITY_T pdidd_adapter_change_notification_t; #define DIVA_DIDD_MAX_NOTIFICATIONS 256 -static didd_adapter_change_notification_t\ - NotificationTable[DIVA_DIDD_MAX_NOTIFICATIONS]; +static didd_adapter_change_notification_t \ +NotificationTable[DIVA_DIDD_MAX_NOTIFICATIONS]; /* -------------------------------------------------------------------------- - Array to held adapter information + Array to held adapter information -------------------------------------------------------------------------- */ static DESCRIPTOR HandleTable[NEW_MAX_DESCRIPTORS]; static dword Adapters = 0; /* Number of adapters */ /* -------------------------------------------------------------------------- - Shadow IDI_DIMAINT - and 'shadow' debug stuff + Shadow IDI_DIMAINT + and 'shadow' debug stuff -------------------------------------------------------------------------- */ -static void no_printf (unsigned char * format, ...) +static void no_printf(unsigned char *format, ...) { #ifdef EBUG va_list ap; - va_start (ap, format); + va_start(ap, format); debug((format, ap)); - va_end (ap); + va_end(ap); #endif } /* ------------------------------------------------------------------------- - Portable debug Library - ------------------------------------------------------------------------- */ + Portable debug Library + ------------------------------------------------------------------------- */ #include "debuglib.c" - + static DESCRIPTOR MAdapter = {IDI_DIMAINT, /* Adapter Type */ - 0x00, /* Channels */ - 0x0000, /* Features */ - (IDI_CALL)no_printf}; + 0x00, /* Channels */ + 0x0000, /* Features */ + (IDI_CALL)no_printf}; /* -------------------------------------------------------------------------- - DAdapter. Only IDI clients with buffer, that is huge enough to - get all descriptors will receive information about DAdapter - { byte type, byte channels, word features, IDI_CALL request } + DAdapter. Only IDI clients with buffer, that is huge enough to + get all descriptors will receive information about DAdapter + { byte type, byte channels, word features, IDI_CALL request } -------------------------------------------------------------------------- */ -static void IDI_CALL_LINK_T diva_dadapter_request (ENTITY IDI_CALL_ENTITY_T *); +static void IDI_CALL_LINK_T diva_dadapter_request(ENTITY IDI_CALL_ENTITY_T *); static DESCRIPTOR DAdapter = {IDI_DADAPTER, /* Adapter Type */ - 0x00, /* Channels */ - 0x0000, /* Features */ - diva_dadapter_request }; + 0x00, /* Channels */ + 0x0000, /* Features */ + diva_dadapter_request }; /* -------------------------------------------------------------------------- - LOCALS + LOCALS -------------------------------------------------------------------------- */ -static dword diva_register_adapter_callback (\ - didd_adapter_change_callback_t callback, - void IDI_CALL_ENTITY_T* context); -static void diva_remove_adapter_callback (dword handle); -static void diva_notify_adapter_change (DESCRIPTOR* d, int removal); +static dword diva_register_adapter_callback(\ + didd_adapter_change_callback_t callback, + void IDI_CALL_ENTITY_T *context); +static void diva_remove_adapter_callback(dword handle); +static void diva_notify_adapter_change(DESCRIPTOR *d, int removal); static diva_os_spin_lock_t didd_spin; /* -------------------------------------------------------------------------- - Should be called as first step, after driver init - -------------------------------------------------------------------------- */ -void diva_didd_load_time_init (void) { - memset (&HandleTable[0], 0x00, sizeof(HandleTable)); - memset (&NotificationTable[0], 0x00, sizeof(NotificationTable)); - diva_os_initialize_spin_lock (&didd_spin, "didd"); + Should be called as first step, after driver init + -------------------------------------------------------------------------- */ +void diva_didd_load_time_init(void) { + memset(&HandleTable[0], 0x00, sizeof(HandleTable)); + memset(&NotificationTable[0], 0x00, sizeof(NotificationTable)); + diva_os_initialize_spin_lock(&didd_spin, "didd"); } /* -------------------------------------------------------------------------- - Should be called as last step, if driver does unload - -------------------------------------------------------------------------- */ -void diva_didd_load_time_finit (void) { - diva_os_destroy_spin_lock (&didd_spin, "didd"); + Should be called as last step, if driver does unload + -------------------------------------------------------------------------- */ +void diva_didd_load_time_finit(void) { + diva_os_destroy_spin_lock(&didd_spin, "didd"); } /* -------------------------------------------------------------------------- - Called in order to register new adapter in adapter array - return adapter handle (> 0) on success - return -1 adapter array overflow - -------------------------------------------------------------------------- */ -static int diva_didd_add_descriptor (DESCRIPTOR* d) { - diva_os_spin_lock_magic_t irql; - int i; - if (d->type == IDI_DIMAINT) { - if (d->request) { - MAdapter.request = d->request; - dprintf = (DIVA_DI_PRINTF)d->request; - diva_notify_adapter_change (&MAdapter, 0); /* Inserted */ - DBG_TRC (("DIMAINT registered, dprintf=%08x", d->request)) - } else { - DBG_TRC (("DIMAINT removed")) - diva_notify_adapter_change (&MAdapter, 1); /* About to remove */ - MAdapter.request = (IDI_CALL)no_printf; - dprintf = no_printf; - } - return (NEW_MAX_DESCRIPTORS); - } - for (i = 0; i < NEW_MAX_DESCRIPTORS; i++) { - diva_os_enter_spin_lock (&didd_spin, &irql, "didd_add"); - if (HandleTable[i].type == 0) { - memcpy (&HandleTable[i], d, sizeof(*d)); - Adapters++; - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_add"); - diva_notify_adapter_change (d, 0); /* we have new adapter */ - DBG_TRC (("Add adapter[%d], request=%08x", (i+1), d->request)) - return (i+1); - } - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_add"); - } - DBG_ERR (("Can't add adapter, out of resources")) - return (-1); + Called in order to register new adapter in adapter array + return adapter handle (> 0) on success + return -1 adapter array overflow + -------------------------------------------------------------------------- */ +static int diva_didd_add_descriptor(DESCRIPTOR *d) { + diva_os_spin_lock_magic_t irql; + int i; + if (d->type == IDI_DIMAINT) { + if (d->request) { + MAdapter.request = d->request; + dprintf = (DIVA_DI_PRINTF)d->request; + diva_notify_adapter_change(&MAdapter, 0); /* Inserted */ + DBG_TRC(("DIMAINT registered, dprintf=%08x", d->request)) + } else { + DBG_TRC(("DIMAINT removed")) + diva_notify_adapter_change(&MAdapter, 1); /* About to remove */ + MAdapter.request = (IDI_CALL)no_printf; + dprintf = no_printf; + } + return (NEW_MAX_DESCRIPTORS); + } + for (i = 0; i < NEW_MAX_DESCRIPTORS; i++) { + diva_os_enter_spin_lock(&didd_spin, &irql, "didd_add"); + if (HandleTable[i].type == 0) { + memcpy(&HandleTable[i], d, sizeof(*d)); + Adapters++; + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_add"); + diva_notify_adapter_change(d, 0); /* we have new adapter */ + DBG_TRC(("Add adapter[%d], request=%08x", (i + 1), d->request)) + return (i + 1); + } + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_add"); + } + DBG_ERR(("Can't add adapter, out of resources")) + return (-1); } /* -------------------------------------------------------------------------- - Called in order to remove one registered adapter from array - return adapter handle (> 0) on success - return 0 on success - -------------------------------------------------------------------------- */ -static int diva_didd_remove_descriptor (IDI_CALL request) { - diva_os_spin_lock_magic_t irql; - int i; - if (request == MAdapter.request) { - DBG_TRC(("DIMAINT removed")) - dprintf = no_printf; - diva_notify_adapter_change (&MAdapter, 1); /* About to remove */ - MAdapter.request = (IDI_CALL)no_printf; - return (0); - } - for (i = 0; (Adapters && (i < NEW_MAX_DESCRIPTORS)); i++) { - if (HandleTable[i].request == request) { - diva_notify_adapter_change (&HandleTable[i], 1); /* About to remove */ - diva_os_enter_spin_lock (&didd_spin, &irql, "didd_rm"); - memset (&HandleTable[i], 0x00, sizeof(HandleTable[0])); - Adapters--; - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_rm"); - DBG_TRC (("Remove adapter[%d], request=%08x", (i+1), request)) - return (0); - } - } - DBG_ERR (("Invalid request=%08x, can't remove adapter", request)) - return (-1); + Called in order to remove one registered adapter from array + return adapter handle (> 0) on success + return 0 on success + -------------------------------------------------------------------------- */ +static int diva_didd_remove_descriptor(IDI_CALL request) { + diva_os_spin_lock_magic_t irql; + int i; + if (request == MAdapter.request) { + DBG_TRC(("DIMAINT removed")) + dprintf = no_printf; + diva_notify_adapter_change(&MAdapter, 1); /* About to remove */ + MAdapter.request = (IDI_CALL)no_printf; + return (0); + } + for (i = 0; (Adapters && (i < NEW_MAX_DESCRIPTORS)); i++) { + if (HandleTable[i].request == request) { + diva_notify_adapter_change(&HandleTable[i], 1); /* About to remove */ + diva_os_enter_spin_lock(&didd_spin, &irql, "didd_rm"); + memset(&HandleTable[i], 0x00, sizeof(HandleTable[0])); + Adapters--; + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_rm"); + DBG_TRC(("Remove adapter[%d], request=%08x", (i + 1), request)) + return (0); + } + } + DBG_ERR(("Invalid request=%08x, can't remove adapter", request)) + return (-1); } /* -------------------------------------------------------------------------- - Read adapter array - return 1 if not enough space to save all available adapters + Read adapter array + return 1 if not enough space to save all available adapters -------------------------------------------------------------------------- */ -static int diva_didd_read_adapter_array (DESCRIPTOR* buffer, int length) { - diva_os_spin_lock_magic_t irql; - int src, dst; - memset (buffer, 0x00, length); - length /= sizeof(DESCRIPTOR); - DBG_TRC (("DIDD_Read, space = %d, Adapters = %d", length, Adapters+2)) - - diva_os_enter_spin_lock (&didd_spin, &irql, "didd_read"); - for (src = 0, dst = 0; - (Adapters && (src < NEW_MAX_DESCRIPTORS) && (dst < length)); - src++) { - if (HandleTable[src].type) { - memcpy (&buffer[dst], &HandleTable[src], sizeof(DESCRIPTOR)); - dst++; - } - } - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_read"); - if (dst < length) { - memcpy (&buffer[dst], &MAdapter, sizeof(DESCRIPTOR)); - dst++; - } else { - DBG_ERR (("Can't write DIMAINT. Array too small")) - } - if (dst < length) { - memcpy (&buffer[dst], &DAdapter, sizeof(DESCRIPTOR)); - dst++; - } else { - DBG_ERR (("Can't write DADAPTER. Array too small")) - } - DBG_TRC (("Read %d adapters", dst)) - return (dst == length); +static int diva_didd_read_adapter_array(DESCRIPTOR *buffer, int length) { + diva_os_spin_lock_magic_t irql; + int src, dst; + memset(buffer, 0x00, length); + length /= sizeof(DESCRIPTOR); + DBG_TRC(("DIDD_Read, space = %d, Adapters = %d", length, Adapters + 2)) + + diva_os_enter_spin_lock(&didd_spin, &irql, "didd_read"); + for (src = 0, dst = 0; + (Adapters && (src < NEW_MAX_DESCRIPTORS) && (dst < length)); + src++) { + if (HandleTable[src].type) { + memcpy(&buffer[dst], &HandleTable[src], sizeof(DESCRIPTOR)); + dst++; + } + } + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_read"); + if (dst < length) { + memcpy(&buffer[dst], &MAdapter, sizeof(DESCRIPTOR)); + dst++; + } else { + DBG_ERR(("Can't write DIMAINT. Array too small")) + } + if (dst < length) { + memcpy(&buffer[dst], &DAdapter, sizeof(DESCRIPTOR)); + dst++; + } else { + DBG_ERR(("Can't write DADAPTER. Array too small")) + } + DBG_TRC(("Read %d adapters", dst)) + return (dst == length); } /* -------------------------------------------------------------------------- - DAdapter request function. - This function does process only synchronous requests, and is used - for reception/registration of new interfaces + DAdapter request function. + This function does process only synchronous requests, and is used + for reception/registration of new interfaces -------------------------------------------------------------------------- */ -static void IDI_CALL_LINK_T diva_dadapter_request (\ - ENTITY IDI_CALL_ENTITY_T *e) { - IDI_SYNC_REQ *syncReq = (IDI_SYNC_REQ *)e ; - if (e->Req) { /* We do not process it, also return error */ - e->Rc = OUT_OF_RESOURCES; - DBG_ERR (("Can't process async request, Req=%02x", e->Req)) - return; - } - /* - So, we process sync request - */ - switch (e->Rc) { - case IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY: { - diva_didd_adapter_notify_t* pinfo = &syncReq->didd_notify.info; - pinfo->handle = diva_register_adapter_callback (\ - (didd_adapter_change_callback_t)pinfo->callback, - (void IDI_CALL_ENTITY_T *)pinfo->context); - e->Rc = 0xff; - } break; - case IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY: { - diva_didd_adapter_notify_t* pinfo = &syncReq->didd_notify.info; - diva_remove_adapter_callback (pinfo->handle); - e->Rc = 0xff; - } break; - case IDI_SYNC_REQ_DIDD_ADD_ADAPTER: { - diva_didd_add_adapter_t* pinfo = &syncReq->didd_add_adapter.info; - if (diva_didd_add_descriptor ((DESCRIPTOR*)pinfo->descriptor) < 0) { - e->Rc = OUT_OF_RESOURCES; - } else { - e->Rc = 0xff; - } - } break; - case IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER: { - diva_didd_remove_adapter_t* pinfo = &syncReq->didd_remove_adapter.info; - if (diva_didd_remove_descriptor ((IDI_CALL)pinfo->p_request) < 0) { - e->Rc = OUT_OF_RESOURCES; - } else { - e->Rc = 0xff; - } - } break; - case IDI_SYNC_REQ_DIDD_READ_ADAPTER_ARRAY: { - diva_didd_read_adapter_array_t* pinfo =\ - &syncReq->didd_read_adapter_array.info; - if (diva_didd_read_adapter_array ((DESCRIPTOR*)pinfo->buffer, - (int)pinfo->length)) { - e->Rc = OUT_OF_RESOURCES; - } else { - e->Rc = 0xff; - } - } break; - default: - DBG_ERR (("Can't process sync request, Req=%02x", e->Rc)) - e->Rc = OUT_OF_RESOURCES; - } +static void IDI_CALL_LINK_T diva_dadapter_request( \ + ENTITY IDI_CALL_ENTITY_T *e) { + IDI_SYNC_REQ *syncReq = (IDI_SYNC_REQ *)e; + if (e->Req) { /* We do not process it, also return error */ + e->Rc = OUT_OF_RESOURCES; + DBG_ERR(("Can't process async request, Req=%02x", e->Req)) + return; + } + /* + So, we process sync request + */ + switch (e->Rc) { + case IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY: { + diva_didd_adapter_notify_t *pinfo = &syncReq->didd_notify.info; + pinfo->handle = diva_register_adapter_callback( \ + (didd_adapter_change_callback_t)pinfo->callback, + (void IDI_CALL_ENTITY_T *)pinfo->context); + e->Rc = 0xff; + } break; + case IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY: { + diva_didd_adapter_notify_t *pinfo = &syncReq->didd_notify.info; + diva_remove_adapter_callback(pinfo->handle); + e->Rc = 0xff; + } break; + case IDI_SYNC_REQ_DIDD_ADD_ADAPTER: { + diva_didd_add_adapter_t *pinfo = &syncReq->didd_add_adapter.info; + if (diva_didd_add_descriptor((DESCRIPTOR *)pinfo->descriptor) < 0) { + e->Rc = OUT_OF_RESOURCES; + } else { + e->Rc = 0xff; + } + } break; + case IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER: { + diva_didd_remove_adapter_t *pinfo = &syncReq->didd_remove_adapter.info; + if (diva_didd_remove_descriptor((IDI_CALL)pinfo->p_request) < 0) { + e->Rc = OUT_OF_RESOURCES; + } else { + e->Rc = 0xff; + } + } break; + case IDI_SYNC_REQ_DIDD_READ_ADAPTER_ARRAY: { + diva_didd_read_adapter_array_t *pinfo =\ + &syncReq->didd_read_adapter_array.info; + if (diva_didd_read_adapter_array((DESCRIPTOR *)pinfo->buffer, + (int)pinfo->length)) { + e->Rc = OUT_OF_RESOURCES; + } else { + e->Rc = 0xff; + } + } break; + default: + DBG_ERR(("Can't process sync request, Req=%02x", e->Rc)) + e->Rc = OUT_OF_RESOURCES; + } } /* -------------------------------------------------------------------------- - IDI client does register his notification function - -------------------------------------------------------------------------- */ -static dword diva_register_adapter_callback (\ - didd_adapter_change_callback_t callback, - void IDI_CALL_ENTITY_T* context) { - diva_os_spin_lock_magic_t irql; - dword i; - - for (i = 0; i < DIVA_DIDD_MAX_NOTIFICATIONS; i++) { - diva_os_enter_spin_lock (&didd_spin, &irql, "didd_nfy_add"); - if (!NotificationTable[i].callback) { - NotificationTable[i].callback = callback; - NotificationTable[i].context = context; - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_nfy_add"); - DBG_TRC(("Register adapter notification[%d]=%08x", i+1, callback)) - return (i+1); - } - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_nfy_add"); - } - DBG_ERR (("Can't register adapter notification, overflow")) - return (0); + IDI client does register his notification function + -------------------------------------------------------------------------- */ +static dword diva_register_adapter_callback( \ + didd_adapter_change_callback_t callback, + void IDI_CALL_ENTITY_T *context) { + diva_os_spin_lock_magic_t irql; + dword i; + + for (i = 0; i < DIVA_DIDD_MAX_NOTIFICATIONS; i++) { + diva_os_enter_spin_lock(&didd_spin, &irql, "didd_nfy_add"); + if (!NotificationTable[i].callback) { + NotificationTable[i].callback = callback; + NotificationTable[i].context = context; + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_nfy_add"); + DBG_TRC(("Register adapter notification[%d]=%08x", i + 1, callback)) + return (i + 1); + } + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_nfy_add"); + } + DBG_ERR(("Can't register adapter notification, overflow")) + return (0); } /* -------------------------------------------------------------------------- - IDI client does register his notification function - -------------------------------------------------------------------------- */ -static void diva_remove_adapter_callback (dword handle) { - diva_os_spin_lock_magic_t irql; - if (handle && ((--handle) < DIVA_DIDD_MAX_NOTIFICATIONS)) { - diva_os_enter_spin_lock (&didd_spin, &irql, "didd_nfy_rm"); - NotificationTable[handle].callback = NULL; - NotificationTable[handle].context = NULL; - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_nfy_rm"); - DBG_TRC(("Remove adapter notification[%d]", (int)(handle+1))) - return; - } - DBG_ERR(("Can't remove adapter notification, handle=%d", handle)) -} + IDI client does register his notification function + -------------------------------------------------------------------------- */ +static void diva_remove_adapter_callback(dword handle) { + diva_os_spin_lock_magic_t irql; + if (handle && ((--handle) < DIVA_DIDD_MAX_NOTIFICATIONS)) { + diva_os_enter_spin_lock(&didd_spin, &irql, "didd_nfy_rm"); + NotificationTable[handle].callback = NULL; + NotificationTable[handle].context = NULL; + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_nfy_rm"); + DBG_TRC(("Remove adapter notification[%d]", (int)(handle + 1))) + return; + } + DBG_ERR(("Can't remove adapter notification, handle=%d", handle)) + } /* -------------------------------------------------------------------------- - Notify all client about adapter array change - Does suppose following behavior in the client side: - Step 1: Redister Notification - Step 2: Read Adapter Array - -------------------------------------------------------------------------- */ -static void diva_notify_adapter_change (DESCRIPTOR* d, int removal) { - int i, do_notify; - didd_adapter_change_notification_t nfy; - diva_os_spin_lock_magic_t irql; - for (i = 0; i < DIVA_DIDD_MAX_NOTIFICATIONS; i++) { - do_notify = 0; - diva_os_enter_spin_lock (&didd_spin, &irql, "didd_nfy"); - if (NotificationTable[i].callback) { - memcpy (&nfy, &NotificationTable[i], sizeof(nfy)); - do_notify = 1; - } - diva_os_leave_spin_lock (&didd_spin, &irql, "didd_nfy"); - if (do_notify) { - (*(nfy.callback))(nfy.context, d, removal); - } - } + Notify all client about adapter array change + Does suppose following behavior in the client side: + Step 1: Redister Notification + Step 2: Read Adapter Array + -------------------------------------------------------------------------- */ +static void diva_notify_adapter_change(DESCRIPTOR *d, int removal) { + int i, do_notify; + didd_adapter_change_notification_t nfy; + diva_os_spin_lock_magic_t irql; + for (i = 0; i < DIVA_DIDD_MAX_NOTIFICATIONS; i++) { + do_notify = 0; + diva_os_enter_spin_lock(&didd_spin, &irql, "didd_nfy"); + if (NotificationTable[i].callback) { + memcpy(&nfy, &NotificationTable[i], sizeof(nfy)); + do_notify = 1; + } + diva_os_leave_spin_lock(&didd_spin, &irql, "didd_nfy"); + if (do_notify) { + (*(nfy.callback))(nfy.context, d, removal); + } + } } /* -------------------------------------------------------------------------- - For all systems, that are linked by Kernel Mode Linker this is ONLY one - function thet should be exported by this device driver - IDI clients should look for IDI_DADAPTER, and use request function - of this adapter (sync request) in order to receive appropriate services: - - add new adapter - - remove existing adapter - - add adapter array notification - - remove adapter array notification - (read adapter is redundant in this case) - INPUT: + For all systems, that are linked by Kernel Mode Linker this is ONLY one + function thet should be exported by this device driver + IDI clients should look for IDI_DADAPTER, and use request function + of this adapter (sync request) in order to receive appropriate services: + - add new adapter + - remove existing adapter + - add adapter array notification + - remove adapter array notification + (read adapter is redundant in this case) + INPUT: buffer - pointer to buffer that will receive adapter array length - length (in bytes) of space in buffer - OUTPUT: + OUTPUT: Adapter array will be written to memory described by 'buffer' If the last adapter seen in the returned adapter array is IDI_DADAPTER or if last adapter in array does have type '0', then it was enougth space in buffer to accommodate all available adapter descriptors - *NOTE 1 (debug interface): + *NOTE 1 (debug interface): The IDI adapter of type 'IDI_DIMAINT' does register as 'request' famous 'dprintf' function (of type DI_PRINTF, please look include/debuglib.c and include/debuglib.h) for details. So dprintf is not exported from module debug module directly, instead of this IDI_DIMAINT is registered. Module load order will receive in this case: - 1. DIDD (this file) - 2. DIMAINT does load and register 'IDI_DIMAINT', at this step - DIDD should be able to get 'dprintf', save it, and - register with DIDD by means of 'dprintf' function. - 3. any other driver is loaded and is able to access adapter array - and debug interface + 1. DIDD (this file) + 2. DIMAINT does load and register 'IDI_DIMAINT', at this step + DIDD should be able to get 'dprintf', save it, and + register with DIDD by means of 'dprintf' function. + 3. any other driver is loaded and is able to access adapter array + and debug interface This approach does allow to load/unload debug interface on demand, and save memory, it it is necessary. - -------------------------------------------------------------------------- */ -void IDI_CALL_LINK_T DIVA_DIDD_Read (void IDI_CALL_ENTITY_T * buffer, - int length) { - diva_didd_read_adapter_array (buffer, length); + -------------------------------------------------------------------------- */ +void IDI_CALL_LINK_T DIVA_DIDD_Read(void IDI_CALL_ENTITY_T *buffer, + int length) { + diva_didd_read_adapter_array(buffer, length); } - diff --git a/drivers/isdn/hardware/eicon/dadapter.h b/drivers/isdn/hardware/eicon/dadapter.h index 3575ac912e6c..5540f46a5be3 100644 --- a/drivers/isdn/hardware/eicon/dadapter.h +++ b/drivers/isdn/hardware/eicon/dadapter.h @@ -1,33 +1,33 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_DIDD_DADAPTER_INC__ #define __DIVA_DIDD_DADAPTER_INC__ - -void diva_didd_load_time_init (void); -void diva_didd_load_time_finit (void); + +void diva_didd_load_time_init(void); +void diva_didd_load_time_finit(void); #define NEW_MAX_DESCRIPTORS 64 diff --git a/drivers/isdn/hardware/eicon/debug.c b/drivers/isdn/hardware/eicon/debug.c index 7a9894cb4557..b5226af6ddec 100644 --- a/drivers/isdn/hardware/eicon/debug.c +++ b/drivers/isdn/hardware/eicon/debug.c @@ -9,67 +9,67 @@ /* LOCALS - */ +*/ #define DBG_MAGIC (0x47114711L) -static void DI_register (void *arg); -static void DI_deregister (pDbgHandle hDbg); -static void DI_format (int do_lock, word id, int type, char *format, va_list argument_list); -static void DI_format_locked (word id, int type, char *format, va_list argument_list); -static void DI_format_old (word id, char *format, va_list ap) { } -static void DiProcessEventLog (unsigned short id, unsigned long msgID, va_list ap) { } -static void single_p (byte * P, word * PLength, byte Id); -static void diva_maint_xdi_cb (ENTITY* e); -static word SuperTraceCreateReadReq (byte* P, const char* path); -static int diva_mnt_cmp_nmbr (const char* nmbr); -static void diva_free_dma_descriptor (IDI_CALL request, int nr); -static int diva_get_dma_descriptor (IDI_CALL request, dword *dma_magic); -void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...); - -static dword MaxDumpSize = 256 ; -static dword MaxXlogSize = 2 + 128 ; -static char TraceFilter[DIVA_MAX_SELECTIVE_FILTER_LENGTH+1]; +static void DI_register(void *arg); +static void DI_deregister(pDbgHandle hDbg); +static void DI_format(int do_lock, word id, int type, char *format, va_list argument_list); +static void DI_format_locked(word id, int type, char *format, va_list argument_list); +static void DI_format_old(word id, char *format, va_list ap) { } +static void DiProcessEventLog(unsigned short id, unsigned long msgID, va_list ap) { } +static void single_p(byte *P, word *PLength, byte Id); +static void diva_maint_xdi_cb(ENTITY *e); +static word SuperTraceCreateReadReq(byte *P, const char *path); +static int diva_mnt_cmp_nmbr(const char *nmbr); +static void diva_free_dma_descriptor(IDI_CALL request, int nr); +static int diva_get_dma_descriptor(IDI_CALL request, dword *dma_magic); +void diva_mnt_internal_dprintf(dword drv_id, dword type, char *p, ...); + +static dword MaxDumpSize = 256; +static dword MaxXlogSize = 2 + 128; +static char TraceFilter[DIVA_MAX_SELECTIVE_FILTER_LENGTH + 1]; static int TraceFilterIdent = -1; static int TraceFilterChannel = -1; typedef struct _diva_maint_client { - dword sec; - dword usec; - pDbgHandle hDbg; - char drvName[128]; - dword dbgMask; - dword last_dbgMask; - IDI_CALL request; - _DbgHandle_ Dbg; - int logical; - int channels; - diva_strace_library_interface_t* pIdiLib; - BUFFERS XData; - char xbuffer[2048+512]; - byte* pmem; - int request_pending; - int dma_handle; + dword sec; + dword usec; + pDbgHandle hDbg; + char drvName[128]; + dword dbgMask; + dword last_dbgMask; + IDI_CALL request; + _DbgHandle_ Dbg; + int logical; + int channels; + diva_strace_library_interface_t *pIdiLib; + BUFFERS XData; + char xbuffer[2048 + 512]; + byte *pmem; + int request_pending; + int dma_handle; } diva_maint_client_t; static diva_maint_client_t clients[MAX_DESCRIPTORS]; -static void diva_change_management_debug_mask (diva_maint_client_t* pC, dword old_mask); +static void diva_change_management_debug_mask(diva_maint_client_t *pC, dword old_mask); -static void diva_maint_error (void* user_context, - diva_strace_library_interface_t* hLib, - int Adapter, - int error, - const char* file, - int line); -static void diva_maint_state_change_notify (void* user_context, - diva_strace_library_interface_t* hLib, - int Adapter, - diva_trace_line_state_t* channel, - int notify_subject); -static void diva_maint_trace_notify (void* user_context, - diva_strace_library_interface_t* hLib, - int Adapter, - void* xlog_buffer, - int length); +static void diva_maint_error(void *user_context, + diva_strace_library_interface_t *hLib, + int Adapter, + int error, + const char *file, + int line); +static void diva_maint_state_change_notify(void *user_context, + diva_strace_library_interface_t *hLib, + int Adapter, + diva_trace_line_state_t *channel, + int notify_subject); +static void diva_maint_trace_notify(void *user_context, + diva_strace_library_interface_t *hLib, + int Adapter, + void *xlog_buffer, + int length); @@ -79,36 +79,36 @@ typedef struct MSG_QUEUE { byte *High; /* Base + Size (constant) */ byte *Head; /* first message in queue (if any) */ byte *Tail; /* first free position */ - byte *Wrap; /* current wraparound position */ + byte *Wrap; /* current wraparound position */ dword Count; /* current no of bytes in queue */ } MSG_QUEUE; typedef struct MSG_HEAD { volatile dword Size; /* size of data following MSG_HEAD */ -#define MSG_INCOMPLETE 0x8000 /* ored to Size until queueCompleteMsg */ +#define MSG_INCOMPLETE 0x8000 /* ored to Size until queueCompleteMsg */ } MSG_HEAD; -#define queueCompleteMsg(p) do{ ((MSG_HEAD *)p - 1)->Size &= ~MSG_INCOMPLETE; }while(0) +#define queueCompleteMsg(p) do { ((MSG_HEAD *)p - 1)->Size &= ~MSG_INCOMPLETE; } while (0) #define queueCount(q) ((q)->Count) -#define MSG_NEED(size) \ - ( (sizeof(MSG_HEAD) + size + sizeof(dword) - 1) & ~(sizeof(dword) - 1) ) +#define MSG_NEED(size) \ + ((sizeof(MSG_HEAD) + size + sizeof(dword) - 1) & ~(sizeof(dword) - 1)) -static void queueInit (MSG_QUEUE *Q, byte *Buffer, dword sizeBuffer) { +static void queueInit(MSG_QUEUE *Q, byte *Buffer, dword sizeBuffer) { Q->Size = sizeBuffer; Q->Base = Q->Head = Q->Tail = Buffer; Q->High = Buffer + sizeBuffer; Q->Wrap = NULL; - Q->Count= 0; + Q->Count = 0; } -static byte *queueAllocMsg (MSG_QUEUE *Q, word size) { +static byte *queueAllocMsg(MSG_QUEUE *Q, word size) { /* Allocate 'size' bytes at tail of queue which will be filled later - * directly with callers own message header info and/or message. - * An 'alloced' message is marked incomplete by oring the 'Size' field - * with MSG_INCOMPLETE. - * This must be reset via queueCompleteMsg() after the message is filled. - * As long as a message is marked incomplete queuePeekMsg() will return - * a 'queue empty' condition when it reaches such a message. */ + * directly with callers own message header info and/or message. + * An 'alloced' message is marked incomplete by oring the 'Size' field + * with MSG_INCOMPLETE. + * This must be reset via queueCompleteMsg() after the message is filled. + * As long as a message is marked incomplete queuePeekMsg() will return + * a 'queue empty' condition when it reaches such a message. */ MSG_HEAD *Msg; word need = MSG_NEED(size); @@ -119,7 +119,7 @@ static byte *queueAllocMsg (MSG_QUEUE *Q, word size) { } goto alloc; /* empty */ } - + if (Q->Tail > Q->Head) { if (Q->Tail + need <= Q->High) goto alloc; /* append */ if (Q->Base + need > Q->Head) { @@ -145,10 +145,10 @@ static byte *queueAllocMsg (MSG_QUEUE *Q, word size) { - return ((byte*)(Msg + 1)); + return ((byte *)(Msg + 1)); } -static void queueFreeMsg (MSG_QUEUE *Q) { +static void queueFreeMsg(MSG_QUEUE *Q) { /* Free the message at head of queue */ word size = ((MSG_HEAD *)Q->Head)->Size & ~MSG_INCOMPLETE; @@ -166,10 +166,10 @@ static void queueFreeMsg (MSG_QUEUE *Q) { } } -static byte *queuePeekMsg (MSG_QUEUE *Q, word *size) { +static byte *queuePeekMsg(MSG_QUEUE *Q, word *size) { /* Show the first valid message in queue BUT DON'T free the message. - * After looking on the message contents it can be freed queueFreeMsg() - * or simply remain in message queue. */ + * After looking on the message contents it can be freed queueFreeMsg() + * or simply remain in message queue. */ MSG_HEAD *Msg = (MSG_HEAD *)Q->Head; @@ -184,9 +184,9 @@ static byte *queuePeekMsg (MSG_QUEUE *Q, word *size) { /* Message queue header - */ -static MSG_QUEUE* dbg_queue; -static byte* dbg_base; +*/ +static MSG_QUEUE *dbg_queue; +static byte *dbg_base; static int external_dbg_queue; static diva_os_spin_lock_t dbg_q_lock; static diva_os_spin_lock_t dbg_adapter_lock; @@ -196,1147 +196,1147 @@ static dword start_sec; static dword start_usec; /* - INTERFACE: - Initialize run time queue structures. - base: base of the message queue - length: length of the message queue - do_init: perfor queue reset - - return: zero on success, -1 on error - */ -int diva_maint_init (byte* base, unsigned long length, int do_init) { - if (dbg_queue || (!base) || (length < (4096*4))) { - return (-1); - } + INTERFACE: + Initialize run time queue structures. + base: base of the message queue + length: length of the message queue + do_init: perfor queue reset + + return: zero on success, -1 on error +*/ +int diva_maint_init(byte *base, unsigned long length, int do_init) { + if (dbg_queue || (!base) || (length < (4096 * 4))) { + return (-1); + } - TraceFilter[0] = 0; - TraceFilterIdent = -1; - TraceFilterChannel = -1; + TraceFilter[0] = 0; + TraceFilterIdent = -1; + TraceFilterChannel = -1; - dbg_base = base; + dbg_base = base; - diva_os_get_time (&start_sec, &start_usec); + diva_os_get_time(&start_sec, &start_usec); - *(dword*)base = (dword)DBG_MAGIC; /* Store Magic */ - base += sizeof(dword); - length -= sizeof(dword); + *(dword *)base = (dword)DBG_MAGIC; /* Store Magic */ + base += sizeof(dword); + length -= sizeof(dword); - *(dword*)base = 2048; /* Extension Field Length */ - base += sizeof(dword); - length -= sizeof(dword); + *(dword *)base = 2048; /* Extension Field Length */ + base += sizeof(dword); + length -= sizeof(dword); - strcpy (base, "KERNEL MODE BUFFER\n"); - base += 2048; - length -= 2048; + strcpy(base, "KERNEL MODE BUFFER\n"); + base += 2048; + length -= 2048; - *(dword*)base = 0; /* Terminate extension */ - base += sizeof(dword); - length -= sizeof(dword); + *(dword *)base = 0; /* Terminate extension */ + base += sizeof(dword); + length -= sizeof(dword); - *(void**)base = (void*)(base+sizeof(void*)); /* Store Base */ - base += sizeof(void*); - length -= sizeof(void*); + *(void **)base = (void *)(base + sizeof(void *)); /* Store Base */ + base += sizeof(void *); + length -= sizeof(void *); - dbg_queue = (MSG_QUEUE*)base; - queueInit (dbg_queue, base + sizeof(MSG_QUEUE), length - sizeof(MSG_QUEUE) - 512); - external_dbg_queue = 0; + dbg_queue = (MSG_QUEUE *)base; + queueInit(dbg_queue, base + sizeof(MSG_QUEUE), length - sizeof(MSG_QUEUE) - 512); + external_dbg_queue = 0; - if (!do_init) { - external_dbg_queue = 1; /* memory was located on the external device */ - } + if (!do_init) { + external_dbg_queue = 1; /* memory was located on the external device */ + } - if (diva_os_initialize_spin_lock (&dbg_q_lock, "dbg_init")) { - dbg_queue = NULL; - dbg_base = NULL; - external_dbg_queue = 0; + if (diva_os_initialize_spin_lock(&dbg_q_lock, "dbg_init")) { + dbg_queue = NULL; + dbg_base = NULL; + external_dbg_queue = 0; return (-1); - } + } - if (diva_os_initialize_spin_lock (&dbg_adapter_lock, "dbg_init")) { - diva_os_destroy_spin_lock(&dbg_q_lock, "dbg_init"); - dbg_queue = NULL; - dbg_base = NULL; - external_dbg_queue = 0; + if (diva_os_initialize_spin_lock(&dbg_adapter_lock, "dbg_init")) { + diva_os_destroy_spin_lock(&dbg_q_lock, "dbg_init"); + dbg_queue = NULL; + dbg_base = NULL; + external_dbg_queue = 0; return (-1); - } + } - return (0); + return (0); } /* INTERFACE: - Finit at unload time - return address of internal queue or zero if queue - was external - */ -void* diva_maint_finit (void) { - void* ret = (void*)dbg_base; - int i; - - dbg_queue = NULL; - dbg_base = NULL; - - if (ret) { - diva_os_destroy_spin_lock(&dbg_q_lock, "dbg_finit"); - diva_os_destroy_spin_lock(&dbg_adapter_lock, "dbg_finit"); - } - - if (external_dbg_queue) { - ret = NULL; - } - external_dbg_queue = 0; - - for (i = 1; i < ARRAY_SIZE(clients); i++) { - if (clients[i].pmem) { - diva_os_free (0, clients[i].pmem); - } - } - - return (ret); + Finit at unload time + return address of internal queue or zero if queue + was external +*/ +void *diva_maint_finit(void) { + void *ret = (void *)dbg_base; + int i; + + dbg_queue = NULL; + dbg_base = NULL; + + if (ret) { + diva_os_destroy_spin_lock(&dbg_q_lock, "dbg_finit"); + diva_os_destroy_spin_lock(&dbg_adapter_lock, "dbg_finit"); + } + + if (external_dbg_queue) { + ret = NULL; + } + external_dbg_queue = 0; + + for (i = 1; i < ARRAY_SIZE(clients); i++) { + if (clients[i].pmem) { + diva_os_free(0, clients[i].pmem); + } + } + + return (ret); } /* INTERFACE: - Return amount of messages in debug queue - */ -dword diva_dbg_q_length (void) { + Return amount of messages in debug queue +*/ +dword diva_dbg_q_length(void) { return (dbg_queue ? queueCount(dbg_queue) : 0); } /* INTERFACE: - Lock message queue and return the pointer to the first - entry. - */ -diva_dbg_entry_head_t* diva_maint_get_message (word* size, - diva_os_spin_lock_magic_t* old_irql) { - diva_dbg_entry_head_t* pmsg = NULL; - - diva_os_enter_spin_lock (&dbg_q_lock, old_irql, "read"); - if (dbg_q_busy) { - diva_os_leave_spin_lock (&dbg_q_lock, old_irql, "read_busy"); - return NULL; - } - dbg_q_busy = 1; - - if (!(pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, size))) { - dbg_q_busy = 0; - diva_os_leave_spin_lock (&dbg_q_lock, old_irql, "read_empty"); - } - - return (pmsg); + Lock message queue and return the pointer to the first + entry. +*/ +diva_dbg_entry_head_t *diva_maint_get_message(word *size, + diva_os_spin_lock_magic_t *old_irql) { + diva_dbg_entry_head_t *pmsg = NULL; + + diva_os_enter_spin_lock(&dbg_q_lock, old_irql, "read"); + if (dbg_q_busy) { + diva_os_leave_spin_lock(&dbg_q_lock, old_irql, "read_busy"); + return NULL; + } + dbg_q_busy = 1; + + if (!(pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, size))) { + dbg_q_busy = 0; + diva_os_leave_spin_lock(&dbg_q_lock, old_irql, "read_empty"); + } + + return (pmsg); } /* INTERFACE: - acknowledge last message and unlock queue - */ -void diva_maint_ack_message (int do_release, - diva_os_spin_lock_magic_t* old_irql) { + acknowledge last message and unlock queue +*/ +void diva_maint_ack_message(int do_release, + diva_os_spin_lock_magic_t *old_irql) { if (!dbg_q_busy) { return; } if (do_release) { - queueFreeMsg (dbg_queue); + queueFreeMsg(dbg_queue); } dbg_q_busy = 0; - diva_os_leave_spin_lock (&dbg_q_lock, old_irql, "read_ack"); + diva_os_leave_spin_lock(&dbg_q_lock, old_irql, "read_ack"); } /* INTERFACE: - PRT COMP function used to register - with MAINT adapter or log in compatibility - mode in case older driver version is connected too - */ -void diva_maint_prtComp (char *format, ...) { - void *hDbg; - va_list ap; - - if (!format) - return; - - va_start(ap, format); - - /* - register to new log driver functions - */ - if ((format[0] == 0) && ((unsigned char)format[1] == 255)) { - hDbg = va_arg(ap, void *); /* ptr to DbgHandle */ - DI_register (hDbg); - } - - va_end (ap); + PRT COMP function used to register + with MAINT adapter or log in compatibility + mode in case older driver version is connected too +*/ +void diva_maint_prtComp(char *format, ...) { + void *hDbg; + va_list ap; + + if (!format) + return; + + va_start(ap, format); + + /* + register to new log driver functions + */ + if ((format[0] == 0) && ((unsigned char)format[1] == 255)) { + hDbg = va_arg(ap, void *); /* ptr to DbgHandle */ + DI_register(hDbg); + } + + va_end(ap); } -static void DI_register (void *arg) { - diva_os_spin_lock_magic_t old_irql; - dword sec, usec; - pDbgHandle hDbg ; - int id, free_id = -1, best_id = 0; - - diva_os_get_time (&sec, &usec); - - hDbg = (pDbgHandle)arg ; - /* - Check for bad args, specially for the old obsolete debug handle - */ - if ((hDbg == NULL) || - ((hDbg->id == 0) && (((_OldDbgHandle_ *)hDbg)->id == -1)) || - (hDbg->Registered != 0)) { - return ; - } - - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "register"); - - for (id = 1; id < ARRAY_SIZE(clients); id++) { - if (clients[id].hDbg == hDbg) { - /* - driver already registered - */ - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register"); - return; - } - if (clients[id].hDbg) { /* slot is busy */ - continue; - } - free_id = id; - if (!strcmp (clients[id].drvName, hDbg->drvName)) { - /* - This driver was already registered with this name - and slot is still free - reuse it - */ - best_id = 1; - break; - } - if (!clients[id].hDbg) { /* slot is busy */ - break; - } - } - - if (free_id != -1) { - diva_dbg_entry_head_t* pmsg = NULL; - int len; - char tmp[256]; - word size; - - /* - Register new driver with id == free_id - */ - clients[free_id].hDbg = hDbg; - clients[free_id].sec = sec; - clients[free_id].usec = usec; - strcpy (clients[free_id].drvName, hDbg->drvName); - - clients[free_id].dbgMask = hDbg->dbgMask; - if (best_id) { - hDbg->dbgMask |= clients[free_id].last_dbgMask; - } else { - clients[free_id].last_dbgMask = 0; - } - - hDbg->Registered = DBG_HANDLE_REG_NEW ; - hDbg->id = (byte)free_id; - hDbg->dbg_end = DI_deregister; - hDbg->dbg_prt = DI_format_locked; - hDbg->dbg_ev = DiProcessEventLog; - hDbg->dbg_irq = DI_format_locked; - if (hDbg->Version > 0) { - hDbg->dbg_old = DI_format_old; - } - hDbg->next = (pDbgHandle)DBG_MAGIC; - - /* - Log driver register, MAINT driver ID is '0' - */ - len = sprintf (tmp, "DIMAINT - drv # %d = '%s' registered", - free_id, hDbg->drvName); - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)(len+1+sizeof(*pmsg))))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - - if (pmsg) { - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_STRING; - pmsg->dli = DLI_REG; - pmsg->drv_id = 0; /* id 0 - DIMAINT */ - pmsg->di_cpu = 0; - pmsg->data_length = len+1; - - memcpy (&pmsg[1], tmp, len+1); - queueCompleteMsg (pmsg); - diva_maint_wakeup_read(); - } - } - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register"); +static void DI_register(void *arg) { + diva_os_spin_lock_magic_t old_irql; + dword sec, usec; + pDbgHandle hDbg; + int id, free_id = -1, best_id = 0; + + diva_os_get_time(&sec, &usec); + + hDbg = (pDbgHandle)arg; + /* + Check for bad args, specially for the old obsolete debug handle + */ + if ((hDbg == NULL) || + ((hDbg->id == 0) && (((_OldDbgHandle_ *)hDbg)->id == -1)) || + (hDbg->Registered != 0)) { + return; + } + + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "register"); + + for (id = 1; id < ARRAY_SIZE(clients); id++) { + if (clients[id].hDbg == hDbg) { + /* + driver already registered + */ + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "register"); + return; + } + if (clients[id].hDbg) { /* slot is busy */ + continue; + } + free_id = id; + if (!strcmp(clients[id].drvName, hDbg->drvName)) { + /* + This driver was already registered with this name + and slot is still free - reuse it + */ + best_id = 1; + break; + } + if (!clients[id].hDbg) { /* slot is busy */ + break; + } + } + + if (free_id != -1) { + diva_dbg_entry_head_t *pmsg = NULL; + int len; + char tmp[256]; + word size; + + /* + Register new driver with id == free_id + */ + clients[free_id].hDbg = hDbg; + clients[free_id].sec = sec; + clients[free_id].usec = usec; + strcpy(clients[free_id].drvName, hDbg->drvName); + + clients[free_id].dbgMask = hDbg->dbgMask; + if (best_id) { + hDbg->dbgMask |= clients[free_id].last_dbgMask; + } else { + clients[free_id].last_dbgMask = 0; + } + + hDbg->Registered = DBG_HANDLE_REG_NEW; + hDbg->id = (byte)free_id; + hDbg->dbg_end = DI_deregister; + hDbg->dbg_prt = DI_format_locked; + hDbg->dbg_ev = DiProcessEventLog; + hDbg->dbg_irq = DI_format_locked; + if (hDbg->Version > 0) { + hDbg->dbg_old = DI_format_old; + } + hDbg->next = (pDbgHandle)DBG_MAGIC; + + /* + Log driver register, MAINT driver ID is '0' + */ + len = sprintf(tmp, "DIMAINT - drv # %d = '%s' registered", + free_id, hDbg->drvName); + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)(len + 1 + sizeof(*pmsg))))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + + if (pmsg) { + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_STRING; + pmsg->dli = DLI_REG; + pmsg->drv_id = 0; /* id 0 - DIMAINT */ + pmsg->di_cpu = 0; + pmsg->data_length = len + 1; + + memcpy(&pmsg[1], tmp, len + 1); + queueCompleteMsg(pmsg); + diva_maint_wakeup_read(); + } + } + + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "register"); } -static void DI_deregister (pDbgHandle hDbg) { - diva_os_spin_lock_magic_t old_irql, old_irql1; - dword sec, usec; - int i; - word size; - byte* pmem = NULL; - - diva_os_get_time (&sec, &usec); - - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "read"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "read"); - - for (i = 1; i < ARRAY_SIZE(clients); i++) { - if (clients[i].hDbg == hDbg) { - diva_dbg_entry_head_t* pmsg; - char tmp[256]; - int len; - - clients[i].hDbg = NULL; - - hDbg->id = -1; - hDbg->dbgMask = 0; - hDbg->dbg_end = NULL; - hDbg->dbg_prt = NULL; - hDbg->dbg_irq = NULL; - if (hDbg->Version > 0) - hDbg->dbg_old = NULL; - hDbg->Registered = 0; - hDbg->next = NULL; - - if (clients[i].pIdiLib) { - (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib); - clients[i].pIdiLib = NULL; - - pmem = clients[i].pmem; - clients[i].pmem = NULL; - } - - /* - Log driver register, MAINT driver ID is '0' - */ - len = sprintf (tmp, "DIMAINT - drv # %d = '%s' de-registered", - i, hDbg->drvName); - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)(len+1+sizeof(*pmsg))))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - - if (pmsg) { - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_STRING; - pmsg->dli = DLI_REG; - pmsg->drv_id = 0; /* id 0 - DIMAINT */ - pmsg->di_cpu = 0; - pmsg->data_length = len+1; - - memcpy (&pmsg[1], tmp, len+1); - queueCompleteMsg (pmsg); - diva_maint_wakeup_read(); - } - - break; - } - } - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "read_ack"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "read_ack"); - - if (pmem) { - diva_os_free (0, pmem); - } +static void DI_deregister(pDbgHandle hDbg) { + diva_os_spin_lock_magic_t old_irql, old_irql1; + dword sec, usec; + int i; + word size; + byte *pmem = NULL; + + diva_os_get_time(&sec, &usec); + + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "read"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "read"); + + for (i = 1; i < ARRAY_SIZE(clients); i++) { + if (clients[i].hDbg == hDbg) { + diva_dbg_entry_head_t *pmsg; + char tmp[256]; + int len; + + clients[i].hDbg = NULL; + + hDbg->id = -1; + hDbg->dbgMask = 0; + hDbg->dbg_end = NULL; + hDbg->dbg_prt = NULL; + hDbg->dbg_irq = NULL; + if (hDbg->Version > 0) + hDbg->dbg_old = NULL; + hDbg->Registered = 0; + hDbg->next = NULL; + + if (clients[i].pIdiLib) { + (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib); + clients[i].pIdiLib = NULL; + + pmem = clients[i].pmem; + clients[i].pmem = NULL; + } + + /* + Log driver register, MAINT driver ID is '0' + */ + len = sprintf(tmp, "DIMAINT - drv # %d = '%s' de-registered", + i, hDbg->drvName); + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)(len + 1 + sizeof(*pmsg))))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + + if (pmsg) { + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_STRING; + pmsg->dli = DLI_REG; + pmsg->drv_id = 0; /* id 0 - DIMAINT */ + pmsg->di_cpu = 0; + pmsg->data_length = len + 1; + + memcpy(&pmsg[1], tmp, len + 1); + queueCompleteMsg(pmsg); + diva_maint_wakeup_read(); + } + + break; + } + } + + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "read_ack"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "read_ack"); + + if (pmem) { + diva_os_free(0, pmem); + } } -static void DI_format_locked (unsigned short id, - int type, - char *format, - va_list argument_list) { - DI_format (1, id, type, format, argument_list); +static void DI_format_locked(unsigned short id, + int type, + char *format, + va_list argument_list) { + DI_format(1, id, type, format, argument_list); } -static void DI_format (int do_lock, - unsigned short id, - int type, - char *format, - va_list ap) { - diva_os_spin_lock_magic_t old_irql; - dword sec, usec; - diva_dbg_entry_head_t* pmsg = NULL; - dword length; - word size; - static char fmtBuf[MSG_FRAME_MAX_SIZE+sizeof(*pmsg)+1]; - char *data; - unsigned short code; - - if (diva_os_in_irq()) { - dbg_sequence++; - return; - } +static void DI_format(int do_lock, + unsigned short id, + int type, + char *format, + va_list ap) { + diva_os_spin_lock_magic_t old_irql; + dword sec, usec; + diva_dbg_entry_head_t *pmsg = NULL; + dword length; + word size; + static char fmtBuf[MSG_FRAME_MAX_SIZE + sizeof(*pmsg) + 1]; + char *data; + unsigned short code; + + if (diva_os_in_irq()) { + dbg_sequence++; + return; + } if ((!format) || - ((TraceFilter[0] != 0) && ((TraceFilterIdent < 0) || (TraceFilterChannel < 0)))) { + ((TraceFilter[0] != 0) && ((TraceFilterIdent < 0) || (TraceFilterChannel < 0)))) { return; } - - diva_os_get_time (&sec, &usec); - - if (do_lock) { - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "format"); - } - - switch (type) { - case DLI_MXLOG : - case DLI_BLK : - case DLI_SEND: - case DLI_RECV: - if (!(length = va_arg(ap, unsigned long))) { - break; - } - if (length > MaxDumpSize) { - length = MaxDumpSize; - } - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)length+sizeof(*pmsg)))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - if (pmsg) { - memcpy (&pmsg[1], format, length); - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_BINARY ; - pmsg->dli = type; /* DLI_XXX */ - pmsg->drv_id = id; /* driver MAINT id */ - pmsg->di_cpu = 0; - pmsg->data_length = length; - queueCompleteMsg (pmsg); - } + + diva_os_get_time(&sec, &usec); + + if (do_lock) { + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "format"); + } + + switch (type) { + case DLI_MXLOG: + case DLI_BLK: + case DLI_SEND: + case DLI_RECV: + if (!(length = va_arg(ap, unsigned long))) { + break; + } + if (length > MaxDumpSize) { + length = MaxDumpSize; + } + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)length + sizeof(*pmsg)))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + if (pmsg) { + memcpy(&pmsg[1], format, length); + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_BINARY; + pmsg->dli = type; /* DLI_XXX */ + pmsg->drv_id = id; /* driver MAINT id */ + pmsg->di_cpu = 0; + pmsg->data_length = length; + queueCompleteMsg(pmsg); + } break; - case DLI_XLOG: { - byte* p; - data = va_arg(ap, char*); - code = (unsigned short)va_arg(ap, unsigned int); - length = (unsigned long) va_arg(ap, unsigned int); - - if (length > MaxXlogSize) - length = MaxXlogSize; - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)length+sizeof(*pmsg)+2))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - if (pmsg) { - p = (byte*)&pmsg[1]; - p[0] = (char)(code) ; - p[1] = (char)(code >> 8) ; - if (data && length) { - memcpy (&p[2], &data[0], length) ; - } - length += 2 ; - - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_BINARY ; - pmsg->dli = type; /* DLI_XXX */ - pmsg->drv_id = id; /* driver MAINT id */ - pmsg->di_cpu = 0; - pmsg->data_length = length; - queueCompleteMsg (pmsg); - } - } break; - - case DLI_LOG : - case DLI_FTL : - case DLI_ERR : - case DLI_TRC : - case DLI_REG : - case DLI_MEM : - case DLI_SPL : - case DLI_IRP : - case DLI_TIM : - case DLI_TAPI: - case DLI_NDIS: - case DLI_CONN: - case DLI_STAT: - case DLI_PRV0: - case DLI_PRV1: - case DLI_PRV2: - case DLI_PRV3: - if ((length = (unsigned long)vsprintf (&fmtBuf[0], format, ap)) > 0) { - length += (sizeof(*pmsg)+1); - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)length))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_STRING; - pmsg->dli = type; /* DLI_XXX */ - pmsg->drv_id = id; /* driver MAINT id */ - pmsg->di_cpu = 0; - pmsg->data_length = length - sizeof(*pmsg); - - memcpy (&pmsg[1], fmtBuf, pmsg->data_length); - queueCompleteMsg (pmsg); - } - break; - - } /* switch type */ - - - if (queueCount(dbg_queue)) { - diva_maint_wakeup_read(); - } - - if (do_lock) { - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "format"); - } + case DLI_XLOG: { + byte *p; + data = va_arg(ap, char *); + code = (unsigned short)va_arg(ap, unsigned int); + length = (unsigned long)va_arg(ap, unsigned int); + + if (length > MaxXlogSize) + length = MaxXlogSize; + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)length + sizeof(*pmsg) + 2))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + if (pmsg) { + p = (byte *)&pmsg[1]; + p[0] = (char)(code); + p[1] = (char)(code >> 8); + if (data && length) { + memcpy(&p[2], &data[0], length); + } + length += 2; + + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_BINARY; + pmsg->dli = type; /* DLI_XXX */ + pmsg->drv_id = id; /* driver MAINT id */ + pmsg->di_cpu = 0; + pmsg->data_length = length; + queueCompleteMsg(pmsg); + } + } break; + + case DLI_LOG: + case DLI_FTL: + case DLI_ERR: + case DLI_TRC: + case DLI_REG: + case DLI_MEM: + case DLI_SPL: + case DLI_IRP: + case DLI_TIM: + case DLI_TAPI: + case DLI_NDIS: + case DLI_CONN: + case DLI_STAT: + case DLI_PRV0: + case DLI_PRV1: + case DLI_PRV2: + case DLI_PRV3: + if ((length = (unsigned long)vsprintf(&fmtBuf[0], format, ap)) > 0) { + length += (sizeof(*pmsg) + 1); + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)length))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_STRING; + pmsg->dli = type; /* DLI_XXX */ + pmsg->drv_id = id; /* driver MAINT id */ + pmsg->di_cpu = 0; + pmsg->data_length = length - sizeof(*pmsg); + + memcpy(&pmsg[1], fmtBuf, pmsg->data_length); + queueCompleteMsg(pmsg); + } + break; + + } /* switch type */ + + + if (queueCount(dbg_queue)) { + diva_maint_wakeup_read(); + } + + if (do_lock) { + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "format"); + } } /* Write driver ID and driver revision to callers buffer - */ -int diva_get_driver_info (dword id, byte* data, int data_length) { - diva_os_spin_lock_magic_t old_irql; - byte* p = data; - int to_copy; - - if (!data || !id || (data_length < 17) || - (id >= ARRAY_SIZE(clients))) { - return (-1); - } - - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "driver info"); - - if (clients[id].hDbg) { - *p++ = 1; - *p++ = (byte)clients[id].sec; /* save seconds */ - *p++ = (byte)(clients[id].sec >> 8); - *p++ = (byte)(clients[id].sec >> 16); - *p++ = (byte)(clients[id].sec >> 24); - - *p++ = (byte)(clients[id].usec/1000); /* save mseconds */ - *p++ = (byte)((clients[id].usec/1000) >> 8); - *p++ = (byte)((clients[id].usec/1000) >> 16); - *p++ = (byte)((clients[id].usec/1000) >> 24); - - data_length -= 9; - - if ((to_copy = min(strlen(clients[id].drvName), (size_t)(data_length-1)))) { - memcpy (p, clients[id].drvName, to_copy); - p += to_copy; - data_length -= to_copy; - if ((data_length >= 4) && clients[id].hDbg->drvTag[0]) { - *p++ = '('; - data_length -= 1; - if ((to_copy = min(strlen(clients[id].hDbg->drvTag), (size_t)(data_length-2)))) { - memcpy (p, clients[id].hDbg->drvTag, to_copy); - p += to_copy; - data_length -= to_copy; - if (data_length >= 2) { - *p++ = ')'; - data_length--; - } - } - } - } - } - *p++ = 0; - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "driver info"); - - return (p - data); -} +*/ +int diva_get_driver_info(dword id, byte *data, int data_length) { + diva_os_spin_lock_magic_t old_irql; + byte *p = data; + int to_copy; + + if (!data || !id || (data_length < 17) || + (id >= ARRAY_SIZE(clients))) { + return (-1); + } -int diva_get_driver_dbg_mask (dword id, byte* data) { - diva_os_spin_lock_magic_t old_irql; - int ret = -1; + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "driver info"); + + if (clients[id].hDbg) { + *p++ = 1; + *p++ = (byte)clients[id].sec; /* save seconds */ + *p++ = (byte)(clients[id].sec >> 8); + *p++ = (byte)(clients[id].sec >> 16); + *p++ = (byte)(clients[id].sec >> 24); + + *p++ = (byte)(clients[id].usec / 1000); /* save mseconds */ + *p++ = (byte)((clients[id].usec / 1000) >> 8); + *p++ = (byte)((clients[id].usec / 1000) >> 16); + *p++ = (byte)((clients[id].usec / 1000) >> 24); + + data_length -= 9; + + if ((to_copy = min(strlen(clients[id].drvName), (size_t)(data_length - 1)))) { + memcpy(p, clients[id].drvName, to_copy); + p += to_copy; + data_length -= to_copy; + if ((data_length >= 4) && clients[id].hDbg->drvTag[0]) { + *p++ = '('; + data_length -= 1; + if ((to_copy = min(strlen(clients[id].hDbg->drvTag), (size_t)(data_length - 2)))) { + memcpy(p, clients[id].hDbg->drvTag, to_copy); + p += to_copy; + data_length -= to_copy; + if (data_length >= 2) { + *p++ = ')'; + data_length--; + } + } + } + } + } + *p++ = 0; - if (!data || !id || (id >= ARRAY_SIZE(clients))) { - return (-1); - } - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "driver info"); + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "driver info"); - if (clients[id].hDbg) { - ret = 4; - *data++= (byte)(clients[id].hDbg->dbgMask); - *data++= (byte)(clients[id].hDbg->dbgMask >> 8); - *data++= (byte)(clients[id].hDbg->dbgMask >> 16); - *data++= (byte)(clients[id].hDbg->dbgMask >> 24); - } + return (p - data); +} + +int diva_get_driver_dbg_mask(dword id, byte *data) { + diva_os_spin_lock_magic_t old_irql; + int ret = -1; + + if (!data || !id || (id >= ARRAY_SIZE(clients))) { + return (-1); + } + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "driver info"); + + if (clients[id].hDbg) { + ret = 4; + *data++ = (byte)(clients[id].hDbg->dbgMask); + *data++ = (byte)(clients[id].hDbg->dbgMask >> 8); + *data++ = (byte)(clients[id].hDbg->dbgMask >> 16); + *data++ = (byte)(clients[id].hDbg->dbgMask >> 24); + } - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "driver info"); + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "driver info"); - return (ret); + return (ret); } -int diva_set_driver_dbg_mask (dword id, dword mask) { - diva_os_spin_lock_magic_t old_irql, old_irql1; - int ret = -1; - +int diva_set_driver_dbg_mask(dword id, dword mask) { + diva_os_spin_lock_magic_t old_irql, old_irql1; + int ret = -1; - if (!id || (id >= ARRAY_SIZE(clients))) { - return (-1); - } - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "dbg mask"); + if (!id || (id >= ARRAY_SIZE(clients))) { + return (-1); + } - if (clients[id].hDbg) { - dword old_mask = clients[id].hDbg->dbgMask; - mask &= 0x7fffffff; - clients[id].hDbg->dbgMask = mask; - clients[id].last_dbgMask = (clients[id].hDbg->dbgMask | clients[id].dbgMask); - ret = 4; - diva_change_management_debug_mask (&clients[id], old_mask); - } + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "dbg mask"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "dbg mask"); + if (clients[id].hDbg) { + dword old_mask = clients[id].hDbg->dbgMask; + mask &= 0x7fffffff; + clients[id].hDbg->dbgMask = mask; + clients[id].last_dbgMask = (clients[id].hDbg->dbgMask | clients[id].dbgMask); + ret = 4; + diva_change_management_debug_mask(&clients[id], old_mask); + } - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "dbg mask"); - if (clients[id].request_pending) { - clients[id].request_pending = 0; - (*(clients[id].request))((ENTITY*)(*(clients[id].pIdiLib->DivaSTraceGetHandle))(clients[id].pIdiLib->hLib)); - } + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "dbg mask"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask"); + if (clients[id].request_pending) { + clients[id].request_pending = 0; + (*(clients[id].request))((ENTITY *)(*(clients[id].pIdiLib->DivaSTraceGetHandle))(clients[id].pIdiLib->hLib)); + } + + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "dbg mask"); - return (ret); + return (ret); } -static int diva_get_idi_adapter_info (IDI_CALL request, dword* serial, dword* logical) { - IDI_SYNC_REQ sync_req; +static int diva_get_idi_adapter_info(IDI_CALL request, dword *serial, dword *logical) { + IDI_SYNC_REQ sync_req; - sync_req.xdi_logical_adapter_number.Req = 0; - sync_req.xdi_logical_adapter_number.Rc = IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER; - (*request)((ENTITY *)&sync_req); - *logical = sync_req.xdi_logical_adapter_number.info.logical_adapter_number; + sync_req.xdi_logical_adapter_number.Req = 0; + sync_req.xdi_logical_adapter_number.Rc = IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER; + (*request)((ENTITY *)&sync_req); + *logical = sync_req.xdi_logical_adapter_number.info.logical_adapter_number; - sync_req.GetSerial.Req = 0; - sync_req.GetSerial.Rc = IDI_SYNC_REQ_GET_SERIAL; - sync_req.GetSerial.serial = 0; - (*request)((ENTITY *)&sync_req); + sync_req.GetSerial.Req = 0; + sync_req.GetSerial.Rc = IDI_SYNC_REQ_GET_SERIAL; + sync_req.GetSerial.serial = 0; + (*request)((ENTITY *)&sync_req); *serial = sync_req.GetSerial.serial; - return (0); + return (0); } /* Register XDI adapter as MAINT compatible driver - */ -void diva_mnt_add_xdi_adapter (const DESCRIPTOR* d) { - diva_os_spin_lock_magic_t old_irql, old_irql1; - dword sec, usec, logical, serial, org_mask; - int id, free_id = -1; - char tmp[128]; - diva_dbg_entry_head_t* pmsg = NULL; - int len; - word size; - byte* pmem; - - diva_os_get_time (&sec, &usec); - diva_get_idi_adapter_info (d->request, &serial, &logical); - if (serial & 0xff000000) { - sprintf (tmp, "ADAPTER:%d SN:%u-%d", - (int)logical, - serial & 0x00ffffff, - (byte)(((serial & 0xff000000) >> 24) + 1)); - } else { - sprintf (tmp, "ADAPTER:%d SN:%u", (int)logical, serial); - } - - if (!(pmem = diva_os_malloc (0, DivaSTraceGetMemotyRequirement (d->channels)))) { - return; - } - memset (pmem, 0x00, DivaSTraceGetMemotyRequirement (d->channels)); - - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "register"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "register"); - - for (id = 1; id < ARRAY_SIZE(clients); id++) { - if (clients[id].hDbg && (clients[id].request == d->request)) { - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register"); - diva_os_free(0, pmem); - return; - } - if (clients[id].hDbg) { /* slot is busy */ - continue; - } - if (free_id < 0) { - free_id = id; - } - if (!strcmp (clients[id].drvName, tmp)) { - /* - This driver was already registered with this name - and slot is still free - reuse it - */ - free_id = id; - break; - } - } - - if (free_id < 0) { - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register"); - diva_os_free (0, pmem); - return; - } - - id = free_id; - clients[id].request = d->request; - clients[id].request_pending = 0; - clients[id].hDbg = &clients[id].Dbg; - clients[id].sec = sec; - clients[id].usec = usec; - strcpy (clients[id].drvName, tmp); - strcpy (clients[id].Dbg.drvName, tmp); - clients[id].Dbg.drvTag[0] = 0; - clients[id].logical = (int)logical; - clients[id].channels = (int)d->channels; - clients[id].dma_handle = -1; - - clients[id].Dbg.dbgMask = 0; - clients[id].dbgMask = clients[id].Dbg.dbgMask; - if (id) { - clients[id].Dbg.dbgMask |= clients[free_id].last_dbgMask; - } else { - clients[id].last_dbgMask = 0; - } - clients[id].Dbg.Registered = DBG_HANDLE_REG_NEW; - clients[id].Dbg.id = (byte)id; - clients[id].Dbg.dbg_end = DI_deregister; - clients[id].Dbg.dbg_prt = DI_format_locked; - clients[id].Dbg.dbg_ev = DiProcessEventLog; - clients[id].Dbg.dbg_irq = DI_format_locked; - clients[id].Dbg.next = (pDbgHandle)DBG_MAGIC; - - { - diva_trace_library_user_interface_t diva_maint_user_ifc = { &clients[id], - diva_maint_state_change_notify, - diva_maint_trace_notify, - diva_maint_error }; - - /* - Attach to adapter management interface - */ - if ((clients[id].pIdiLib = - DivaSTraceLibraryCreateInstance ((int)logical, &diva_maint_user_ifc, pmem))) { - if (((*(clients[id].pIdiLib->DivaSTraceLibraryStart))(clients[id].pIdiLib->hLib))) { - diva_mnt_internal_dprintf (0, DLI_ERR, "Adapter(%d) Start failed", (int)logical); - (*(clients[id].pIdiLib->DivaSTraceLibraryFinit))(clients[id].pIdiLib->hLib); - clients[id].pIdiLib = NULL; - } - } else { - diva_mnt_internal_dprintf (0, DLI_ERR, "A(%d) management init failed", (int)logical); - } - } - - if (!clients[id].pIdiLib) { - clients[id].request = NULL; - clients[id].request_pending = 0; - clients[id].hDbg = NULL; - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register"); - diva_os_free (0, pmem); - return; - } - - /* - Log driver register, MAINT driver ID is '0' - */ - len = sprintf (tmp, "DIMAINT - drv # %d = '%s' registered", - id, clients[id].Dbg.drvName); - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)(len+1+sizeof(*pmsg))))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - - if (pmsg) { - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_STRING; - pmsg->dli = DLI_REG; - pmsg->drv_id = 0; /* id 0 - DIMAINT */ - pmsg->di_cpu = 0; - pmsg->data_length = len+1; - - memcpy (&pmsg[1], tmp, len+1); - queueCompleteMsg (pmsg); - diva_maint_wakeup_read(); - } - - org_mask = clients[id].Dbg.dbgMask; - clients[id].Dbg.dbgMask = 0; - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "register"); - - if (clients[id].request_pending) { - clients[id].request_pending = 0; - (*(clients[id].request))((ENTITY*)(*(clients[id].pIdiLib->DivaSTraceGetHandle))(clients[id].pIdiLib->hLib)); - } - - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "register"); - - diva_set_driver_dbg_mask (id, org_mask); +*/ +void diva_mnt_add_xdi_adapter(const DESCRIPTOR *d) { + diva_os_spin_lock_magic_t old_irql, old_irql1; + dword sec, usec, logical, serial, org_mask; + int id, free_id = -1; + char tmp[128]; + diva_dbg_entry_head_t *pmsg = NULL; + int len; + word size; + byte *pmem; + + diva_os_get_time(&sec, &usec); + diva_get_idi_adapter_info(d->request, &serial, &logical); + if (serial & 0xff000000) { + sprintf(tmp, "ADAPTER:%d SN:%u-%d", + (int)logical, + serial & 0x00ffffff, + (byte)(((serial & 0xff000000) >> 24) + 1)); + } else { + sprintf(tmp, "ADAPTER:%d SN:%u", (int)logical, serial); + } + + if (!(pmem = diva_os_malloc(0, DivaSTraceGetMemotyRequirement(d->channels)))) { + return; + } + memset(pmem, 0x00, DivaSTraceGetMemotyRequirement(d->channels)); + + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "register"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "register"); + + for (id = 1; id < ARRAY_SIZE(clients); id++) { + if (clients[id].hDbg && (clients[id].request == d->request)) { + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "register"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "register"); + diva_os_free(0, pmem); + return; + } + if (clients[id].hDbg) { /* slot is busy */ + continue; + } + if (free_id < 0) { + free_id = id; + } + if (!strcmp(clients[id].drvName, tmp)) { + /* + This driver was already registered with this name + and slot is still free - reuse it + */ + free_id = id; + break; + } + } + + if (free_id < 0) { + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "register"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "register"); + diva_os_free(0, pmem); + return; + } + + id = free_id; + clients[id].request = d->request; + clients[id].request_pending = 0; + clients[id].hDbg = &clients[id].Dbg; + clients[id].sec = sec; + clients[id].usec = usec; + strcpy(clients[id].drvName, tmp); + strcpy(clients[id].Dbg.drvName, tmp); + clients[id].Dbg.drvTag[0] = 0; + clients[id].logical = (int)logical; + clients[id].channels = (int)d->channels; + clients[id].dma_handle = -1; + + clients[id].Dbg.dbgMask = 0; + clients[id].dbgMask = clients[id].Dbg.dbgMask; + if (id) { + clients[id].Dbg.dbgMask |= clients[free_id].last_dbgMask; + } else { + clients[id].last_dbgMask = 0; + } + clients[id].Dbg.Registered = DBG_HANDLE_REG_NEW; + clients[id].Dbg.id = (byte)id; + clients[id].Dbg.dbg_end = DI_deregister; + clients[id].Dbg.dbg_prt = DI_format_locked; + clients[id].Dbg.dbg_ev = DiProcessEventLog; + clients[id].Dbg.dbg_irq = DI_format_locked; + clients[id].Dbg.next = (pDbgHandle)DBG_MAGIC; + + { + diva_trace_library_user_interface_t diva_maint_user_ifc = { &clients[id], + diva_maint_state_change_notify, + diva_maint_trace_notify, + diva_maint_error }; + + /* + Attach to adapter management interface + */ + if ((clients[id].pIdiLib = + DivaSTraceLibraryCreateInstance((int)logical, &diva_maint_user_ifc, pmem))) { + if (((*(clients[id].pIdiLib->DivaSTraceLibraryStart))(clients[id].pIdiLib->hLib))) { + diva_mnt_internal_dprintf(0, DLI_ERR, "Adapter(%d) Start failed", (int)logical); + (*(clients[id].pIdiLib->DivaSTraceLibraryFinit))(clients[id].pIdiLib->hLib); + clients[id].pIdiLib = NULL; + } + } else { + diva_mnt_internal_dprintf(0, DLI_ERR, "A(%d) management init failed", (int)logical); + } + } + + if (!clients[id].pIdiLib) { + clients[id].request = NULL; + clients[id].request_pending = 0; + clients[id].hDbg = NULL; + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "register"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "register"); + diva_os_free(0, pmem); + return; + } + + /* + Log driver register, MAINT driver ID is '0' + */ + len = sprintf(tmp, "DIMAINT - drv # %d = '%s' registered", + id, clients[id].Dbg.drvName); + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)(len + 1 + sizeof(*pmsg))))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + + if (pmsg) { + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_STRING; + pmsg->dli = DLI_REG; + pmsg->drv_id = 0; /* id 0 - DIMAINT */ + pmsg->di_cpu = 0; + pmsg->data_length = len + 1; + + memcpy(&pmsg[1], tmp, len + 1); + queueCompleteMsg(pmsg); + diva_maint_wakeup_read(); + } + + org_mask = clients[id].Dbg.dbgMask; + clients[id].Dbg.dbgMask = 0; + + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "register"); + + if (clients[id].request_pending) { + clients[id].request_pending = 0; + (*(clients[id].request))((ENTITY *)(*(clients[id].pIdiLib->DivaSTraceGetHandle))(clients[id].pIdiLib->hLib)); + } + + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "register"); + + diva_set_driver_dbg_mask(id, org_mask); } /* De-Register XDI adapter - */ -void diva_mnt_remove_xdi_adapter (const DESCRIPTOR* d) { - diva_os_spin_lock_magic_t old_irql, old_irql1; - dword sec, usec; - int i; - word size; - byte* pmem = NULL; - - diva_os_get_time (&sec, &usec); - - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "read"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "read"); - - for (i = 1; i < ARRAY_SIZE(clients); i++) { - if (clients[i].hDbg && (clients[i].request == d->request)) { - diva_dbg_entry_head_t* pmsg; - char tmp[256]; - int len; - - if (clients[i].pIdiLib) { - (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib); - clients[i].pIdiLib = NULL; - - pmem = clients[i].pmem; - clients[i].pmem = NULL; - } - - clients[i].hDbg = NULL; - clients[i].request_pending = 0; - if (clients[i].dma_handle >= 0) { - /* - Free DMA handle - */ - diva_free_dma_descriptor (clients[i].request, clients[i].dma_handle); - clients[i].dma_handle = -1; - } - clients[i].request = NULL; - - /* - Log driver register, MAINT driver ID is '0' - */ - len = sprintf (tmp, "DIMAINT - drv # %d = '%s' de-registered", - i, clients[i].Dbg.drvName); - - memset (&clients[i].Dbg, 0x00, sizeof(clients[i].Dbg)); - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)(len+1+sizeof(*pmsg))))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - - if (pmsg) { - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_STRING; - pmsg->dli = DLI_REG; - pmsg->drv_id = 0; /* id 0 - DIMAINT */ - pmsg->di_cpu = 0; - pmsg->data_length = len+1; - - memcpy (&pmsg[1], tmp, len+1); - queueCompleteMsg (pmsg); - diva_maint_wakeup_read(); - } - - break; - } - } - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "read_ack"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "read_ack"); - - if (pmem) { - diva_os_free (0, pmem); - } +*/ +void diva_mnt_remove_xdi_adapter(const DESCRIPTOR *d) { + diva_os_spin_lock_magic_t old_irql, old_irql1; + dword sec, usec; + int i; + word size; + byte *pmem = NULL; + + diva_os_get_time(&sec, &usec); + + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "read"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "read"); + + for (i = 1; i < ARRAY_SIZE(clients); i++) { + if (clients[i].hDbg && (clients[i].request == d->request)) { + diva_dbg_entry_head_t *pmsg; + char tmp[256]; + int len; + + if (clients[i].pIdiLib) { + (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib); + clients[i].pIdiLib = NULL; + + pmem = clients[i].pmem; + clients[i].pmem = NULL; + } + + clients[i].hDbg = NULL; + clients[i].request_pending = 0; + if (clients[i].dma_handle >= 0) { + /* + Free DMA handle + */ + diva_free_dma_descriptor(clients[i].request, clients[i].dma_handle); + clients[i].dma_handle = -1; + } + clients[i].request = NULL; + + /* + Log driver register, MAINT driver ID is '0' + */ + len = sprintf(tmp, "DIMAINT - drv # %d = '%s' de-registered", + i, clients[i].Dbg.drvName); + + memset(&clients[i].Dbg, 0x00, sizeof(clients[i].Dbg)); + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)(len + 1 + sizeof(*pmsg))))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + + if (pmsg) { + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_STRING; + pmsg->dli = DLI_REG; + pmsg->drv_id = 0; /* id 0 - DIMAINT */ + pmsg->di_cpu = 0; + pmsg->data_length = len + 1; + + memcpy(&pmsg[1], tmp, len + 1); + queueCompleteMsg(pmsg); + diva_maint_wakeup_read(); + } + + break; + } + } + + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "read_ack"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "read_ack"); + + if (pmem) { + diva_os_free(0, pmem); + } } /* ---------------------------------------------------------------- - Low level interface for management interface client + Low level interface for management interface client ---------------------------------------------------------------- */ /* Return handle to client structure - */ -void* SuperTraceOpenAdapter (int AdapterNumber) { - int i; +*/ +void *SuperTraceOpenAdapter(int AdapterNumber) { + int i; - for (i = 1; i < ARRAY_SIZE(clients); i++) { - if (clients[i].hDbg && clients[i].request && (clients[i].logical == AdapterNumber)) { - return (&clients[i]); - } - } + for (i = 1; i < ARRAY_SIZE(clients); i++) { + if (clients[i].hDbg && clients[i].request && (clients[i].logical == AdapterNumber)) { + return (&clients[i]); + } + } - return NULL; + return NULL; } -int SuperTraceCloseAdapter (void* AdapterHandle) { - return (0); +int SuperTraceCloseAdapter(void *AdapterHandle) { + return (0); } -int SuperTraceReadRequest (void* AdapterHandle, const char* name, byte* data) { - diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle; +int SuperTraceReadRequest(void *AdapterHandle, const char *name, byte *data) { + diva_maint_client_t *pC = (diva_maint_client_t *)AdapterHandle; - if (pC && pC->pIdiLib && pC->request) { - ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); - byte* xdata = (byte*)&pC->xbuffer[0]; - char tmp = 0; - word length; + if (pC && pC->pIdiLib && pC->request) { + ENTITY *e = (ENTITY *)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); + byte *xdata = (byte *)&pC->xbuffer[0]; + char tmp = 0; + word length; - if (!strcmp(name, "\\")) { /* Read ROOT */ - name = &tmp; - } - length = SuperTraceCreateReadReq (xdata, name); - single_p (xdata, &length, 0); /* End Of Message */ + if (!strcmp(name, "\\")) { /* Read ROOT */ + name = &tmp; + } + length = SuperTraceCreateReadReq(xdata, name); + single_p(xdata, &length, 0); /* End Of Message */ - e->Req = MAN_READ; - e->ReqCh = 0; - e->X->PLength = length; - e->X->P = (byte*)xdata; + e->Req = MAN_READ; + e->ReqCh = 0; + e->X->PLength = length; + e->X->P = (byte *)xdata; - pC->request_pending = 1; + pC->request_pending = 1; - return (0); - } + return (0); + } - return (-1); + return (-1); } -int SuperTraceGetNumberOfChannels (void* AdapterHandle) { - if (AdapterHandle) { - diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle; +int SuperTraceGetNumberOfChannels(void *AdapterHandle) { + if (AdapterHandle) { + diva_maint_client_t *pC = (diva_maint_client_t *)AdapterHandle; - return (pC->channels); - } + return (pC->channels); + } - return (0); + return (0); } -int SuperTraceASSIGN (void* AdapterHandle, byte* data) { - diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle; - - if (pC && pC->pIdiLib && pC->request) { - ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); - IDI_SYNC_REQ* preq; - char buffer[((sizeof(preq->xdi_extended_features)+4) > sizeof(ENTITY)) ? (sizeof(preq->xdi_extended_features)+4) : sizeof(ENTITY)]; - char features[4]; - word assign_data_length = 1; - - features[0] = 0; - pC->xbuffer[0] = 0; - preq = (IDI_SYNC_REQ*)&buffer[0]; - preq->xdi_extended_features.Req = 0; - preq->xdi_extended_features.Rc = IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES; - preq->xdi_extended_features.info.buffer_length_in_bytes = sizeof(features); - preq->xdi_extended_features.info.features = &features[0]; - - (*(pC->request))((ENTITY*)preq); - - if ((features[0] & DIVA_XDI_EXTENDED_FEATURES_VALID) && - (features[0] & DIVA_XDI_EXTENDED_FEATURE_MANAGEMENT_DMA)) { - dword uninitialized_var(rx_dma_magic); - if ((pC->dma_handle = diva_get_dma_descriptor (pC->request, &rx_dma_magic)) >= 0) { - pC->xbuffer[0] = LLI; - pC->xbuffer[1] = 8; - pC->xbuffer[2] = 0x40; - pC->xbuffer[3] = (byte)pC->dma_handle; - pC->xbuffer[4] = (byte)rx_dma_magic; - pC->xbuffer[5] = (byte)(rx_dma_magic >> 8); - pC->xbuffer[6] = (byte)(rx_dma_magic >> 16); - pC->xbuffer[7] = (byte)(rx_dma_magic >> 24); - pC->xbuffer[8] = (byte)(DIVA_MAX_MANAGEMENT_TRANSFER_SIZE & 0xFF); - pC->xbuffer[9] = (byte)(DIVA_MAX_MANAGEMENT_TRANSFER_SIZE >> 8); - pC->xbuffer[10] = 0; - - assign_data_length = 11; - } - } else { - pC->dma_handle = -1; - } - - e->Id = MAN_ID; - e->callback = diva_maint_xdi_cb; - e->XNum = 1; - e->X = &pC->XData; - e->Req = ASSIGN; - e->ReqCh = 0; - e->X->PLength = assign_data_length; - e->X->P = (byte*)&pC->xbuffer[0]; - - pC->request_pending = 1; - - return (0); - } - - return (-1); +int SuperTraceASSIGN(void *AdapterHandle, byte *data) { + diva_maint_client_t *pC = (diva_maint_client_t *)AdapterHandle; + + if (pC && pC->pIdiLib && pC->request) { + ENTITY *e = (ENTITY *)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); + IDI_SYNC_REQ *preq; + char buffer[((sizeof(preq->xdi_extended_features) + 4) > sizeof(ENTITY)) ? (sizeof(preq->xdi_extended_features) + 4) : sizeof(ENTITY)]; + char features[4]; + word assign_data_length = 1; + + features[0] = 0; + pC->xbuffer[0] = 0; + preq = (IDI_SYNC_REQ *)&buffer[0]; + preq->xdi_extended_features.Req = 0; + preq->xdi_extended_features.Rc = IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES; + preq->xdi_extended_features.info.buffer_length_in_bytes = sizeof(features); + preq->xdi_extended_features.info.features = &features[0]; + + (*(pC->request))((ENTITY *)preq); + + if ((features[0] & DIVA_XDI_EXTENDED_FEATURES_VALID) && + (features[0] & DIVA_XDI_EXTENDED_FEATURE_MANAGEMENT_DMA)) { + dword uninitialized_var(rx_dma_magic); + if ((pC->dma_handle = diva_get_dma_descriptor(pC->request, &rx_dma_magic)) >= 0) { + pC->xbuffer[0] = LLI; + pC->xbuffer[1] = 8; + pC->xbuffer[2] = 0x40; + pC->xbuffer[3] = (byte)pC->dma_handle; + pC->xbuffer[4] = (byte)rx_dma_magic; + pC->xbuffer[5] = (byte)(rx_dma_magic >> 8); + pC->xbuffer[6] = (byte)(rx_dma_magic >> 16); + pC->xbuffer[7] = (byte)(rx_dma_magic >> 24); + pC->xbuffer[8] = (byte)(DIVA_MAX_MANAGEMENT_TRANSFER_SIZE & 0xFF); + pC->xbuffer[9] = (byte)(DIVA_MAX_MANAGEMENT_TRANSFER_SIZE >> 8); + pC->xbuffer[10] = 0; + + assign_data_length = 11; + } + } else { + pC->dma_handle = -1; + } + + e->Id = MAN_ID; + e->callback = diva_maint_xdi_cb; + e->XNum = 1; + e->X = &pC->XData; + e->Req = ASSIGN; + e->ReqCh = 0; + e->X->PLength = assign_data_length; + e->X->P = (byte *)&pC->xbuffer[0]; + + pC->request_pending = 1; + + return (0); + } + + return (-1); } -int SuperTraceREMOVE (void* AdapterHandle) { - diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle; +int SuperTraceREMOVE(void *AdapterHandle) { + diva_maint_client_t *pC = (diva_maint_client_t *)AdapterHandle; - if (pC && pC->pIdiLib && pC->request) { - ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); + if (pC && pC->pIdiLib && pC->request) { + ENTITY *e = (ENTITY *)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); - e->XNum = 1; - e->X = &pC->XData; - e->Req = REMOVE; - e->ReqCh = 0; - e->X->PLength = 1; - e->X->P = (byte*)&pC->xbuffer[0]; - pC->xbuffer[0] = 0; + e->XNum = 1; + e->X = &pC->XData; + e->Req = REMOVE; + e->ReqCh = 0; + e->X->PLength = 1; + e->X->P = (byte *)&pC->xbuffer[0]; + pC->xbuffer[0] = 0; - pC->request_pending = 1; + pC->request_pending = 1; - return (0); - } + return (0); + } - return (-1); + return (-1); } -int SuperTraceTraceOnRequest(void* hAdapter, const char* name, byte* data) { - diva_maint_client_t* pC = (diva_maint_client_t*)hAdapter; +int SuperTraceTraceOnRequest(void *hAdapter, const char *name, byte *data) { + diva_maint_client_t *pC = (diva_maint_client_t *)hAdapter; - if (pC && pC->pIdiLib && pC->request) { - ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); - byte* xdata = (byte*)&pC->xbuffer[0]; - char tmp = 0; - word length; + if (pC && pC->pIdiLib && pC->request) { + ENTITY *e = (ENTITY *)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); + byte *xdata = (byte *)&pC->xbuffer[0]; + char tmp = 0; + word length; - if (!strcmp(name, "\\")) { /* Read ROOT */ - name = &tmp; - } - length = SuperTraceCreateReadReq (xdata, name); - single_p (xdata, &length, 0); /* End Of Message */ - e->Req = MAN_EVENT_ON; - e->ReqCh = 0; - e->X->PLength = length; - e->X->P = (byte*)xdata; + if (!strcmp(name, "\\")) { /* Read ROOT */ + name = &tmp; + } + length = SuperTraceCreateReadReq(xdata, name); + single_p(xdata, &length, 0); /* End Of Message */ + e->Req = MAN_EVENT_ON; + e->ReqCh = 0; + e->X->PLength = length; + e->X->P = (byte *)xdata; - pC->request_pending = 1; + pC->request_pending = 1; - return (0); - } + return (0); + } - return (-1); + return (-1); } -int SuperTraceWriteVar (void* AdapterHandle, - byte* data, - const char* name, - void* var, - byte type, - byte var_length) { - diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle; - - if (pC && pC->pIdiLib && pC->request) { - ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); - diva_man_var_header_t* pVar = (diva_man_var_header_t*)&pC->xbuffer[0]; - word length = SuperTraceCreateReadReq ((byte*)pVar, name); - - memcpy (&pC->xbuffer[length], var, var_length); - length += var_length; - pVar->length += var_length; - pVar->value_length = var_length; - pVar->type = type; - single_p ((byte*)pVar, &length, 0); /* End Of Message */ - - e->Req = MAN_WRITE; - e->ReqCh = 0; - e->X->PLength = length; - e->X->P = (byte*)pVar; - - pC->request_pending = 1; - - return (0); - } - - return (-1); +int SuperTraceWriteVar(void *AdapterHandle, + byte *data, + const char *name, + void *var, + byte type, + byte var_length) { + diva_maint_client_t *pC = (diva_maint_client_t *)AdapterHandle; + + if (pC && pC->pIdiLib && pC->request) { + ENTITY *e = (ENTITY *)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); + diva_man_var_header_t *pVar = (diva_man_var_header_t *)&pC->xbuffer[0]; + word length = SuperTraceCreateReadReq((byte *)pVar, name); + + memcpy(&pC->xbuffer[length], var, var_length); + length += var_length; + pVar->length += var_length; + pVar->value_length = var_length; + pVar->type = type; + single_p((byte *)pVar, &length, 0); /* End Of Message */ + + e->Req = MAN_WRITE; + e->ReqCh = 0; + e->X->PLength = length; + e->X->P = (byte *)pVar; + + pC->request_pending = 1; + + return (0); + } + + return (-1); } -int SuperTraceExecuteRequest (void* AdapterHandle, - const char* name, - byte* data) { - diva_maint_client_t* pC = (diva_maint_client_t*)AdapterHandle; +int SuperTraceExecuteRequest(void *AdapterHandle, + const char *name, + byte *data) { + diva_maint_client_t *pC = (diva_maint_client_t *)AdapterHandle; - if (pC && pC->pIdiLib && pC->request) { - ENTITY* e = (ENTITY*)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); - byte* xdata = (byte*)&pC->xbuffer[0]; - word length; + if (pC && pC->pIdiLib && pC->request) { + ENTITY *e = (ENTITY *)(*(pC->pIdiLib->DivaSTraceGetHandle))(pC->pIdiLib->hLib); + byte *xdata = (byte *)&pC->xbuffer[0]; + word length; - length = SuperTraceCreateReadReq (xdata, name); - single_p (xdata, &length, 0); /* End Of Message */ + length = SuperTraceCreateReadReq(xdata, name); + single_p(xdata, &length, 0); /* End Of Message */ - e->Req = MAN_EXECUTE; - e->ReqCh = 0; - e->X->PLength = length; - e->X->P = (byte*)xdata; + e->Req = MAN_EXECUTE; + e->ReqCh = 0; + e->X->PLength = length; + e->X->P = (byte *)xdata; - pC->request_pending = 1; + pC->request_pending = 1; - return (0); - } + return (0); + } - return (-1); + return (-1); } -static word SuperTraceCreateReadReq (byte* P, const char* path) { +static word SuperTraceCreateReadReq(byte *P, const char *path) { byte var_length; - byte* plen; + byte *plen; - var_length = (byte)strlen (path); + var_length = (byte)strlen(path); *P++ = ESC; plen = P++; @@ -1346,708 +1346,708 @@ static word SuperTraceCreateReadReq (byte* P, const char* path) { *P++ = 0x00; /* Status */ *P++ = 0x00; /* Variable Length */ *P++ = var_length; - memcpy (P, path, var_length); + memcpy(P, path, var_length); P += var_length; *plen = var_length + 0x06; return ((word)(var_length + 0x08)); } -static void single_p (byte * P, word * PLength, byte Id) { - P[(*PLength)++] = Id; +static void single_p(byte *P, word *PLength, byte Id) { + P[(*PLength)++] = Id; } -static void diva_maint_xdi_cb (ENTITY* e) { - diva_strace_context_t* pLib = DIVAS_CONTAINING_RECORD(e,diva_strace_context_t,e); - diva_maint_client_t* pC; - diva_os_spin_lock_magic_t old_irql, old_irql1; +static void diva_maint_xdi_cb(ENTITY *e) { + diva_strace_context_t *pLib = DIVAS_CONTAINING_RECORD(e, diva_strace_context_t, e); + diva_maint_client_t *pC; + diva_os_spin_lock_magic_t old_irql, old_irql1; - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "xdi_cb"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "xdi_cb"); + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "xdi_cb"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "xdi_cb"); - pC = (diva_maint_client_t*)pLib->hAdapter; + pC = (diva_maint_client_t *)pLib->hAdapter; - if ((e->complete == 255) || (pC->dma_handle < 0)) { - if ((*(pLib->instance.DivaSTraceMessageInput))(&pLib->instance)) { - diva_mnt_internal_dprintf (0, DLI_ERR, "Trace internal library error"); - } - } else { - /* - Process combined management interface indication - */ - if ((*(pLib->instance.DivaSTraceMessageInput))(&pLib->instance)) { - diva_mnt_internal_dprintf (0, DLI_ERR, "Trace internal library error (DMA mode)"); - } - } + if ((e->complete == 255) || (pC->dma_handle < 0)) { + if ((*(pLib->instance.DivaSTraceMessageInput))(&pLib->instance)) { + diva_mnt_internal_dprintf(0, DLI_ERR, "Trace internal library error"); + } + } else { + /* + Process combined management interface indication + */ + if ((*(pLib->instance.DivaSTraceMessageInput))(&pLib->instance)) { + diva_mnt_internal_dprintf(0, DLI_ERR, "Trace internal library error (DMA mode)"); + } + } - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "xdi_cb"); + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "xdi_cb"); if (pC->request_pending) { - pC->request_pending = 0; - (*(pC->request))(e); + pC->request_pending = 0; + (*(pC->request))(e); } - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "xdi_cb"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "xdi_cb"); } -static void diva_maint_error (void* user_context, - diva_strace_library_interface_t* hLib, - int Adapter, - int error, - const char* file, - int line) { - diva_mnt_internal_dprintf (0, DLI_ERR, - "Trace library error(%d) A(%d) %s %d", error, Adapter, file, line); +static void diva_maint_error(void *user_context, + diva_strace_library_interface_t *hLib, + int Adapter, + int error, + const char *file, + int line) { + diva_mnt_internal_dprintf(0, DLI_ERR, + "Trace library error(%d) A(%d) %s %d", error, Adapter, file, line); } -static void print_ie (diva_trace_ie_t* ie, char* buffer, int length) { +static void print_ie(diva_trace_ie_t *ie, char *buffer, int length) { int i; - buffer[0] = 0; - - if (length > 32) { - for (i = 0; ((i < ie->length) && (length > 3)); i++) { - sprintf (buffer, "%02x", ie->data[i]); - buffer += 2; - length -= 2; - if (i < (ie->length-1)) { - strcpy (buffer, " "); - buffer++; - length--; - } - } - } + buffer[0] = 0; + + if (length > 32) { + for (i = 0; ((i < ie->length) && (length > 3)); i++) { + sprintf(buffer, "%02x", ie->data[i]); + buffer += 2; + length -= 2; + if (i < (ie->length - 1)) { + strcpy(buffer, " "); + buffer++; + length--; + } + } + } } -static void diva_maint_state_change_notify (void* user_context, - diva_strace_library_interface_t* hLib, - int Adapter, - diva_trace_line_state_t* channel, - int notify_subject) { - diva_maint_client_t* pC = (diva_maint_client_t*)user_context; - diva_trace_fax_state_t* fax = &channel->fax; - diva_trace_modem_state_t* modem = &channel->modem; - char tmp[256]; - - if (!pC->hDbg) { - return; - } - - switch (notify_subject) { - case DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE: { - int view = (TraceFilter[0] == 0); - /* - Process selective Trace - */ - if (channel->Line[0] == 'I' && channel->Line[1] == 'd' && - channel->Line[2] == 'l' && channel->Line[3] == 'e') { - if ((TraceFilterIdent == pC->hDbg->id) && (TraceFilterChannel == (int)channel->ChannelNumber)) { - (*(hLib->DivaSTraceSetBChannel))(hLib, (int)channel->ChannelNumber, 0); - (*(hLib->DivaSTraceSetAudioTap))(hLib, (int)channel->ChannelNumber, 0); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, "Selective Trace OFF for Ch=%d", - (int)channel->ChannelNumber); - TraceFilterIdent = -1; - TraceFilterChannel = -1; - view = 1; - } - } else if (TraceFilter[0] && (TraceFilterIdent < 0) && !(diva_mnt_cmp_nmbr (&channel->RemoteAddress[0]) && - diva_mnt_cmp_nmbr (&channel->LocalAddress[0]))) { - - if ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0) { /* Activate B-channel trace */ - (*(hLib->DivaSTraceSetBChannel))(hLib, (int)channel->ChannelNumber, 1); - } - if ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0) { /* Activate AudioTap Trace */ - (*(hLib->DivaSTraceSetAudioTap))(hLib, (int)channel->ChannelNumber, 1); - } - - TraceFilterIdent = pC->hDbg->id; - TraceFilterChannel = (int)channel->ChannelNumber; - - if (TraceFilterIdent >= 0) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, "Selective Trace ON for Ch=%d", - (int)channel->ChannelNumber); - view = 1; - } - } - if (view && (pC->hDbg->dbgMask & DIVA_MGT_DBG_LINE_EVENTS)) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Ch = %d", - (int)channel->ChannelNumber); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Status = <%s>", &channel->Line[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Layer1 = <%s>", &channel->Framing[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Layer2 = <%s>", &channel->Layer2[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Layer3 = <%s>", &channel->Layer3[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L RAddr = <%s>", - &channel->RemoteAddress[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L RSAddr = <%s>", - &channel->RemoteSubAddress[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L LAddr = <%s>", - &channel->LocalAddress[0]); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L LSAddr = <%s>", - &channel->LocalSubAddress[0]); - print_ie(&channel->call_BC, tmp, sizeof(tmp)); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L BC = <%s>", tmp); - print_ie(&channel->call_HLC, tmp, sizeof(tmp)); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L HLC = <%s>", tmp); - print_ie(&channel->call_LLC, tmp, sizeof(tmp)); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L LLC = <%s>", tmp); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L CR = 0x%x", channel->CallReference); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Disc = 0x%x", - channel->LastDisconnecCause); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, "L Owner = <%s>", &channel->UserID[0]); - } - - } break; - - case DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE: - if (pC->hDbg->dbgMask & DIVA_MGT_DBG_MDM_PROGRESS) { - { - int ch = TraceFilterChannel; - int id = TraceFilterIdent; - - if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) && - (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) { - if (ch != (int)modem->ChannelNumber) { - break; - } - } else if (TraceFilter[0] != 0) { +static void diva_maint_state_change_notify(void *user_context, + diva_strace_library_interface_t *hLib, + int Adapter, + diva_trace_line_state_t *channel, + int notify_subject) { + diva_maint_client_t *pC = (diva_maint_client_t *)user_context; + diva_trace_fax_state_t *fax = &channel->fax; + diva_trace_modem_state_t *modem = &channel->modem; + char tmp[256]; + + if (!pC->hDbg) { + return; + } + + switch (notify_subject) { + case DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE: { + int view = (TraceFilter[0] == 0); + /* + Process selective Trace + */ + if (channel->Line[0] == 'I' && channel->Line[1] == 'd' && + channel->Line[2] == 'l' && channel->Line[3] == 'e') { + if ((TraceFilterIdent == pC->hDbg->id) && (TraceFilterChannel == (int)channel->ChannelNumber)) { + (*(hLib->DivaSTraceSetBChannel))(hLib, (int)channel->ChannelNumber, 0); + (*(hLib->DivaSTraceSetAudioTap))(hLib, (int)channel->ChannelNumber, 0); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, "Selective Trace OFF for Ch=%d", + (int)channel->ChannelNumber); + TraceFilterIdent = -1; + TraceFilterChannel = -1; + view = 1; + } + } else if (TraceFilter[0] && (TraceFilterIdent < 0) && !(diva_mnt_cmp_nmbr(&channel->RemoteAddress[0]) && + diva_mnt_cmp_nmbr(&channel->LocalAddress[0]))) { + + if ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0) { /* Activate B-channel trace */ + (*(hLib->DivaSTraceSetBChannel))(hLib, (int)channel->ChannelNumber, 1); + } + if ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0) { /* Activate AudioTap Trace */ + (*(hLib->DivaSTraceSetAudioTap))(hLib, (int)channel->ChannelNumber, 1); + } + + TraceFilterIdent = pC->hDbg->id; + TraceFilterChannel = (int)channel->ChannelNumber; + + if (TraceFilterIdent >= 0) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, "Selective Trace ON for Ch=%d", + (int)channel->ChannelNumber); + view = 1; + } + } + if (view && (pC->hDbg->dbgMask & DIVA_MGT_DBG_LINE_EVENTS)) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Ch = %d", + (int)channel->ChannelNumber); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Status = <%s>", &channel->Line[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Layer1 = <%s>", &channel->Framing[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Layer2 = <%s>", &channel->Layer2[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Layer3 = <%s>", &channel->Layer3[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L RAddr = <%s>", + &channel->RemoteAddress[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L RSAddr = <%s>", + &channel->RemoteSubAddress[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L LAddr = <%s>", + &channel->LocalAddress[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L LSAddr = <%s>", + &channel->LocalSubAddress[0]); + print_ie(&channel->call_BC, tmp, sizeof(tmp)); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L BC = <%s>", tmp); + print_ie(&channel->call_HLC, tmp, sizeof(tmp)); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L HLC = <%s>", tmp); + print_ie(&channel->call_LLC, tmp, sizeof(tmp)); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L LLC = <%s>", tmp); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L CR = 0x%x", channel->CallReference); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Disc = 0x%x", + channel->LastDisconnecCause); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "L Owner = <%s>", &channel->UserID[0]); + } + + } break; + + case DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE: + if (pC->hDbg->dbgMask & DIVA_MGT_DBG_MDM_PROGRESS) { + { + int ch = TraceFilterChannel; + int id = TraceFilterIdent; + + if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) && + (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) { + if (ch != (int)modem->ChannelNumber) { break; } + } else if (TraceFilter[0] != 0) { + break; } + } + + + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Ch = %lu", + (int)modem->ChannelNumber); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Event = %lu", modem->Event); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Norm = %lu", modem->Norm); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Opts. = 0x%08x", modem->Options); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Tx = %lu Bps", modem->TxSpeed); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Rx = %lu Bps", modem->RxSpeed); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RT = %lu mSec", + modem->RoundtripMsec); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Sr = %lu", modem->SymbolRate); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Rxl = %d dBm", modem->RxLeveldBm); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM El = %d dBm", modem->EchoLeveldBm); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM SNR = %lu dB", modem->SNRdb); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM MAE = %lu", modem->MAE); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM LRet = %lu", + modem->LocalRetrains); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RRet = %lu", + modem->RemoteRetrains); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM LRes = %lu", modem->LocalResyncs); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RRes = %lu", + modem->RemoteResyncs); + if (modem->Event == 3) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Disc = %lu", modem->DiscReason); + } + } + if ((modem->Event == 3) && (pC->hDbg->dbgMask & DIVA_MGT_DBG_MDM_STATISTICS)) { + (*(pC->pIdiLib->DivaSTraceGetModemStatistics))(pC->pIdiLib); + } + break; + case DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE: + if (pC->hDbg->dbgMask & DIVA_MGT_DBG_FAX_PROGRESS) { + { + int ch = TraceFilterChannel; + int id = TraceFilterIdent; - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Ch = %lu", - (int)modem->ChannelNumber); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Event = %lu", modem->Event); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Norm = %lu", modem->Norm); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Opts. = 0x%08x", modem->Options); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Tx = %lu Bps", modem->TxSpeed); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Rx = %lu Bps", modem->RxSpeed); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RT = %lu mSec", - modem->RoundtripMsec); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Sr = %lu", modem->SymbolRate); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM Rxl = %d dBm", modem->RxLeveldBm); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM El = %d dBm", modem->EchoLeveldBm); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM SNR = %lu dB", modem->SNRdb); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM MAE = %lu", modem->MAE); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM LRet = %lu", - modem->LocalRetrains); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RRet = %lu", - modem->RemoteRetrains); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM LRes = %lu", modem->LocalResyncs); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "MDM RRes = %lu", - modem->RemoteResyncs); - if (modem->Event == 3) { - diva_mnt_internal_dprintf(pC->hDbg->id,DLI_STAT,"MDM Disc = %lu", modem->DiscReason); - } - } - if ((modem->Event == 3) && (pC->hDbg->dbgMask & DIVA_MGT_DBG_MDM_STATISTICS)) { - (*(pC->pIdiLib->DivaSTraceGetModemStatistics))(pC->pIdiLib); - } - break; - - case DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE: - if (pC->hDbg->dbgMask & DIVA_MGT_DBG_FAX_PROGRESS) { - { - int ch = TraceFilterChannel; - int id = TraceFilterIdent; - - if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) && - (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) { - if (ch != (int)fax->ChannelNumber) { - break; - } - } else if (TraceFilter[0] != 0) { + if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) && + (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) { + if (ch != (int)fax->ChannelNumber) { break; } + } else if (TraceFilter[0] != 0) { + break; } + } + + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Ch = %lu", (int)fax->ChannelNumber); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Event = %lu", fax->Event); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Pages = %lu", fax->Page_Counter); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Feat. = 0x%08x", fax->Features); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX ID = <%s>", &fax->Station_ID[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Saddr = <%s>", &fax->Subaddress[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Pwd = <%s>", &fax->Password[0]); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Speed = %lu", fax->Speed); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Res. = 0x%08x", fax->Resolution); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Width = %lu", fax->Paper_Width); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Length= %lu", fax->Paper_Length); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX SLT = %lu", fax->Scanline_Time); + if (fax->Event == 3) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Disc = %lu", fax->Disc_Reason); + } + } + if ((fax->Event == 3) && (pC->hDbg->dbgMask & DIVA_MGT_DBG_FAX_STATISTICS)) { + (*(pC->pIdiLib->DivaSTraceGetFaxStatistics))(pC->pIdiLib); + } + break; + + case DIVA_SUPER_TRACE_INTERFACE_CHANGE: + if (pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_EVENTS) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, + "Layer 1 -> [%s]", channel->pInterface->Layer1); + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, + "Layer 2 -> [%s]", channel->pInterface->Layer2); + } + break; + + case DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE: + if (pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_STATISTICS) { + /* + Incoming Statistics + */ + if (channel->pInterfaceStat->inc.Calls) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Calls =%lu", channel->pInterfaceStat->inc.Calls); + } + if (channel->pInterfaceStat->inc.Connected) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Connected =%lu", channel->pInterfaceStat->inc.Connected); + } + if (channel->pInterfaceStat->inc.User_Busy) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Busy =%lu", channel->pInterfaceStat->inc.User_Busy); + } + if (channel->pInterfaceStat->inc.Call_Rejected) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Rejected =%lu", channel->pInterfaceStat->inc.Call_Rejected); + } + if (channel->pInterfaceStat->inc.Wrong_Number) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Wrong Nr =%lu", channel->pInterfaceStat->inc.Wrong_Number); + } + if (channel->pInterfaceStat->inc.Incompatible_Dst) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Incomp. Dest =%lu", channel->pInterfaceStat->inc.Incompatible_Dst); + } + if (channel->pInterfaceStat->inc.Out_of_Order) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Out of Order =%lu", channel->pInterfaceStat->inc.Out_of_Order); + } + if (channel->pInterfaceStat->inc.Ignored) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Inc Ignored =%lu", channel->pInterfaceStat->inc.Ignored); + } + + /* + Outgoing Statistics + */ + if (channel->pInterfaceStat->outg.Calls) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg Calls =%lu", channel->pInterfaceStat->outg.Calls); + } + if (channel->pInterfaceStat->outg.Connected) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg Connected =%lu", channel->pInterfaceStat->outg.Connected); + } + if (channel->pInterfaceStat->outg.User_Busy) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg Busy =%lu", channel->pInterfaceStat->outg.User_Busy); + } + if (channel->pInterfaceStat->outg.No_Answer) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg No Answer =%lu", channel->pInterfaceStat->outg.No_Answer); + } + if (channel->pInterfaceStat->outg.Wrong_Number) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg Wrong Nr =%lu", channel->pInterfaceStat->outg.Wrong_Number); + } + if (channel->pInterfaceStat->outg.Call_Rejected) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg Rejected =%lu", channel->pInterfaceStat->outg.Call_Rejected); + } + if (channel->pInterfaceStat->outg.Other_Failures) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "Outg Other Failures =%lu", channel->pInterfaceStat->outg.Other_Failures); + } + } + break; + + case DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE: + if (channel->pInterfaceStat->mdm.Disc_Normal) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Normal = %lu", channel->pInterfaceStat->mdm.Disc_Normal); + } + if (channel->pInterfaceStat->mdm.Disc_Unspecified) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Unsp. = %lu", channel->pInterfaceStat->mdm.Disc_Unspecified); + } + if (channel->pInterfaceStat->mdm.Disc_Busy_Tone) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Busy Tone = %lu", channel->pInterfaceStat->mdm.Disc_Busy_Tone); + } + if (channel->pInterfaceStat->mdm.Disc_Congestion) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Congestion = %lu", channel->pInterfaceStat->mdm.Disc_Congestion); + } + if (channel->pInterfaceStat->mdm.Disc_Carr_Wait) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Carrier Wait = %lu", channel->pInterfaceStat->mdm.Disc_Carr_Wait); + } + if (channel->pInterfaceStat->mdm.Disc_Trn_Timeout) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Trn. T.o. = %lu", channel->pInterfaceStat->mdm.Disc_Trn_Timeout); + } + if (channel->pInterfaceStat->mdm.Disc_Incompat) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Incompatible = %lu", channel->pInterfaceStat->mdm.Disc_Incompat); + } + if (channel->pInterfaceStat->mdm.Disc_Frame_Rej) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc Frame Reject = %lu", channel->pInterfaceStat->mdm.Disc_Frame_Rej); + } + if (channel->pInterfaceStat->mdm.Disc_V42bis) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "MDM Disc V.42bis = %lu", channel->pInterfaceStat->mdm.Disc_V42bis); + } + break; - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Ch = %lu",(int)fax->ChannelNumber); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Event = %lu", fax->Event); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Pages = %lu", fax->Page_Counter); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Feat. = 0x%08x", fax->Features); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX ID = <%s>", &fax->Station_ID[0]); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Saddr = <%s>", &fax->Subaddress[0]); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Pwd = <%s>", &fax->Password[0]); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Speed = %lu", fax->Speed); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Res. = 0x%08x", fax->Resolution); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Width = %lu", fax->Paper_Width); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Length= %lu", fax->Paper_Length); - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX SLT = %lu", fax->Scanline_Time); - if (fax->Event == 3) { - diva_mnt_internal_dprintf(pC->hDbg->id, DLI_STAT, "FAX Disc = %lu", fax->Disc_Reason); - } - } - if ((fax->Event == 3) && (pC->hDbg->dbgMask & DIVA_MGT_DBG_FAX_STATISTICS)) { - (*(pC->pIdiLib->DivaSTraceGetFaxStatistics))(pC->pIdiLib); - } - break; - - case DIVA_SUPER_TRACE_INTERFACE_CHANGE: - if (pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_EVENTS) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, - "Layer 1 -> [%s]", channel->pInterface->Layer1); - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_STAT, - "Layer 2 -> [%s]", channel->pInterface->Layer2); - } - break; - - case DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE: - if (pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_STATISTICS) { - /* - Incoming Statistics - */ - if (channel->pInterfaceStat->inc.Calls) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Calls =%lu", channel->pInterfaceStat->inc.Calls); - } - if (channel->pInterfaceStat->inc.Connected) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Connected =%lu", channel->pInterfaceStat->inc.Connected); - } - if (channel->pInterfaceStat->inc.User_Busy) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Busy =%lu", channel->pInterfaceStat->inc.User_Busy); - } - if (channel->pInterfaceStat->inc.Call_Rejected) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Rejected =%lu", channel->pInterfaceStat->inc.Call_Rejected); - } - if (channel->pInterfaceStat->inc.Wrong_Number) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Wrong Nr =%lu", channel->pInterfaceStat->inc.Wrong_Number); - } - if (channel->pInterfaceStat->inc.Incompatible_Dst) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Incomp. Dest =%lu", channel->pInterfaceStat->inc.Incompatible_Dst); - } - if (channel->pInterfaceStat->inc.Out_of_Order) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Out of Order =%lu", channel->pInterfaceStat->inc.Out_of_Order); - } - if (channel->pInterfaceStat->inc.Ignored) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Inc Ignored =%lu", channel->pInterfaceStat->inc.Ignored); - } - - /* - Outgoing Statistics - */ - if (channel->pInterfaceStat->outg.Calls) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg Calls =%lu", channel->pInterfaceStat->outg.Calls); - } - if (channel->pInterfaceStat->outg.Connected) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg Connected =%lu", channel->pInterfaceStat->outg.Connected); - } - if (channel->pInterfaceStat->outg.User_Busy) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg Busy =%lu", channel->pInterfaceStat->outg.User_Busy); - } - if (channel->pInterfaceStat->outg.No_Answer) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg No Answer =%lu", channel->pInterfaceStat->outg.No_Answer); - } - if (channel->pInterfaceStat->outg.Wrong_Number) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg Wrong Nr =%lu", channel->pInterfaceStat->outg.Wrong_Number); - } - if (channel->pInterfaceStat->outg.Call_Rejected) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg Rejected =%lu", channel->pInterfaceStat->outg.Call_Rejected); - } - if (channel->pInterfaceStat->outg.Other_Failures) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "Outg Other Failures =%lu", channel->pInterfaceStat->outg.Other_Failures); - } - } - break; - - case DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE: - if (channel->pInterfaceStat->mdm.Disc_Normal) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Normal = %lu", channel->pInterfaceStat->mdm.Disc_Normal); - } - if (channel->pInterfaceStat->mdm.Disc_Unspecified) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Unsp. = %lu", channel->pInterfaceStat->mdm.Disc_Unspecified); - } - if (channel->pInterfaceStat->mdm.Disc_Busy_Tone) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Busy Tone = %lu", channel->pInterfaceStat->mdm.Disc_Busy_Tone); - } - if (channel->pInterfaceStat->mdm.Disc_Congestion) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Congestion = %lu", channel->pInterfaceStat->mdm.Disc_Congestion); - } - if (channel->pInterfaceStat->mdm.Disc_Carr_Wait) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Carrier Wait = %lu", channel->pInterfaceStat->mdm.Disc_Carr_Wait); - } - if (channel->pInterfaceStat->mdm.Disc_Trn_Timeout) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Trn. T.o. = %lu", channel->pInterfaceStat->mdm.Disc_Trn_Timeout); - } - if (channel->pInterfaceStat->mdm.Disc_Incompat) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Incompatible = %lu", channel->pInterfaceStat->mdm.Disc_Incompat); - } - if (channel->pInterfaceStat->mdm.Disc_Frame_Rej) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc Frame Reject = %lu", channel->pInterfaceStat->mdm.Disc_Frame_Rej); - } - if (channel->pInterfaceStat->mdm.Disc_V42bis) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "MDM Disc V.42bis = %lu", channel->pInterfaceStat->mdm.Disc_V42bis); - } - break; - - case DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE: - if (channel->pInterfaceStat->fax.Disc_Normal) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Normal = %lu", channel->pInterfaceStat->fax.Disc_Normal); - } - if (channel->pInterfaceStat->fax.Disc_Not_Ident) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Not Ident. = %lu", channel->pInterfaceStat->fax.Disc_Not_Ident); - } - if (channel->pInterfaceStat->fax.Disc_No_Response) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc No Response = %lu", channel->pInterfaceStat->fax.Disc_No_Response); - } - if (channel->pInterfaceStat->fax.Disc_Retries) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Max Retries = %lu", channel->pInterfaceStat->fax.Disc_Retries); - } - if (channel->pInterfaceStat->fax.Disc_Unexp_Msg) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Unexp. Msg. = %lu", channel->pInterfaceStat->fax.Disc_Unexp_Msg); - } - if (channel->pInterfaceStat->fax.Disc_No_Polling) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc No Polling = %lu", channel->pInterfaceStat->fax.Disc_No_Polling); - } - if (channel->pInterfaceStat->fax.Disc_Training) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Training = %lu", channel->pInterfaceStat->fax.Disc_Training); - } - if (channel->pInterfaceStat->fax.Disc_Unexpected) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Unexpected = %lu", channel->pInterfaceStat->fax.Disc_Unexpected); - } - if (channel->pInterfaceStat->fax.Disc_Application) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Application = %lu", channel->pInterfaceStat->fax.Disc_Application); - } - if (channel->pInterfaceStat->fax.Disc_Incompat) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Incompatible = %lu", channel->pInterfaceStat->fax.Disc_Incompat); - } - if (channel->pInterfaceStat->fax.Disc_No_Command) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc No Command = %lu", channel->pInterfaceStat->fax.Disc_No_Command); - } - if (channel->pInterfaceStat->fax.Disc_Long_Msg) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Long Msg. = %lu", channel->pInterfaceStat->fax.Disc_Long_Msg); - } - if (channel->pInterfaceStat->fax.Disc_Supervisor) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Supervisor = %lu", channel->pInterfaceStat->fax.Disc_Supervisor); - } - if (channel->pInterfaceStat->fax.Disc_SUB_SEP_PWD) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc SUP SEP PWD = %lu", channel->pInterfaceStat->fax.Disc_SUB_SEP_PWD); - } - if (channel->pInterfaceStat->fax.Disc_Invalid_Msg) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Invalid Msg. = %lu", channel->pInterfaceStat->fax.Disc_Invalid_Msg); - } - if (channel->pInterfaceStat->fax.Disc_Page_Coding) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Page Coding = %lu", channel->pInterfaceStat->fax.Disc_Page_Coding); - } - if (channel->pInterfaceStat->fax.Disc_App_Timeout) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Appl. T.o. = %lu", channel->pInterfaceStat->fax.Disc_App_Timeout); - } - if (channel->pInterfaceStat->fax.Disc_Unspecified) { - diva_mnt_internal_dprintf (pC->hDbg->id, DLI_LOG, - "FAX Disc Unspec. = %lu", channel->pInterfaceStat->fax.Disc_Unspecified); - } - break; - } + case DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE: + if (channel->pInterfaceStat->fax.Disc_Normal) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Normal = %lu", channel->pInterfaceStat->fax.Disc_Normal); + } + if (channel->pInterfaceStat->fax.Disc_Not_Ident) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Not Ident. = %lu", channel->pInterfaceStat->fax.Disc_Not_Ident); + } + if (channel->pInterfaceStat->fax.Disc_No_Response) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc No Response = %lu", channel->pInterfaceStat->fax.Disc_No_Response); + } + if (channel->pInterfaceStat->fax.Disc_Retries) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Max Retries = %lu", channel->pInterfaceStat->fax.Disc_Retries); + } + if (channel->pInterfaceStat->fax.Disc_Unexp_Msg) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Unexp. Msg. = %lu", channel->pInterfaceStat->fax.Disc_Unexp_Msg); + } + if (channel->pInterfaceStat->fax.Disc_No_Polling) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc No Polling = %lu", channel->pInterfaceStat->fax.Disc_No_Polling); + } + if (channel->pInterfaceStat->fax.Disc_Training) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Training = %lu", channel->pInterfaceStat->fax.Disc_Training); + } + if (channel->pInterfaceStat->fax.Disc_Unexpected) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Unexpected = %lu", channel->pInterfaceStat->fax.Disc_Unexpected); + } + if (channel->pInterfaceStat->fax.Disc_Application) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Application = %lu", channel->pInterfaceStat->fax.Disc_Application); + } + if (channel->pInterfaceStat->fax.Disc_Incompat) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Incompatible = %lu", channel->pInterfaceStat->fax.Disc_Incompat); + } + if (channel->pInterfaceStat->fax.Disc_No_Command) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc No Command = %lu", channel->pInterfaceStat->fax.Disc_No_Command); + } + if (channel->pInterfaceStat->fax.Disc_Long_Msg) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Long Msg. = %lu", channel->pInterfaceStat->fax.Disc_Long_Msg); + } + if (channel->pInterfaceStat->fax.Disc_Supervisor) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Supervisor = %lu", channel->pInterfaceStat->fax.Disc_Supervisor); + } + if (channel->pInterfaceStat->fax.Disc_SUB_SEP_PWD) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc SUP SEP PWD = %lu", channel->pInterfaceStat->fax.Disc_SUB_SEP_PWD); + } + if (channel->pInterfaceStat->fax.Disc_Invalid_Msg) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Invalid Msg. = %lu", channel->pInterfaceStat->fax.Disc_Invalid_Msg); + } + if (channel->pInterfaceStat->fax.Disc_Page_Coding) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Page Coding = %lu", channel->pInterfaceStat->fax.Disc_Page_Coding); + } + if (channel->pInterfaceStat->fax.Disc_App_Timeout) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Appl. T.o. = %lu", channel->pInterfaceStat->fax.Disc_App_Timeout); + } + if (channel->pInterfaceStat->fax.Disc_Unspecified) { + diva_mnt_internal_dprintf(pC->hDbg->id, DLI_LOG, + "FAX Disc Unspec. = %lu", channel->pInterfaceStat->fax.Disc_Unspecified); + } + break; + } } /* Receive trace information from the Management Interface and store it in the internal trace buffer with MSG_TYPE_MLOG as is, without any filtering. Event Filtering and formatting is done in Management Interface self. - */ -static void diva_maint_trace_notify (void* user_context, - diva_strace_library_interface_t* hLib, - int Adapter, - void* xlog_buffer, - int length) { - diva_maint_client_t* pC = (diva_maint_client_t*)user_context; - diva_dbg_entry_head_t* pmsg; - word size; - dword sec, usec; - int ch = TraceFilterChannel; - int id = TraceFilterIdent; - - /* - Selective trace - */ - if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) && - (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) { - const char* p = NULL; - int ch_value = -1; - MI_XLOG_HDR *TrcData = (MI_XLOG_HDR *)xlog_buffer; - - if (Adapter != clients[id].logical) { - return; /* Ignore all trace messages from other adapters */ - } - - if (TrcData->code == 24) { - p = (char*)&TrcData->code; - p += 2; - } - - /* - All L1 messages start as [dsp,ch], so we can filter this information - and filter out all messages that use different channel - */ - if (p && p[0] == '[') { - if (p[2] == ',') { - p += 3; - ch_value = *p - '0'; - } else if (p[3] == ',') { - p += 4; - ch_value = *p - '0'; - } - if (ch_value >= 0) { - if (p[2] == ']') { - ch_value = ch_value * 10 + p[1] - '0'; - } - if (ch_value != ch) { - return; /* Ignore other channels */ - } - } - } +*/ +static void diva_maint_trace_notify(void *user_context, + diva_strace_library_interface_t *hLib, + int Adapter, + void *xlog_buffer, + int length) { + diva_maint_client_t *pC = (diva_maint_client_t *)user_context; + diva_dbg_entry_head_t *pmsg; + word size; + dword sec, usec; + int ch = TraceFilterChannel; + int id = TraceFilterIdent; + + /* + Selective trace + */ + if ((id >= 0) && (ch >= 0) && (id < ARRAY_SIZE(clients)) && + (clients[id].Dbg.id == (byte)id) && (clients[id].pIdiLib == hLib)) { + const char *p = NULL; + int ch_value = -1; + MI_XLOG_HDR *TrcData = (MI_XLOG_HDR *)xlog_buffer; + + if (Adapter != clients[id].logical) { + return; /* Ignore all trace messages from other adapters */ + } + + if (TrcData->code == 24) { + p = (char *)&TrcData->code; + p += 2; + } + + /* + All L1 messages start as [dsp,ch], so we can filter this information + and filter out all messages that use different channel + */ + if (p && p[0] == '[') { + if (p[2] == ',') { + p += 3; + ch_value = *p - '0'; + } else if (p[3] == ',') { + p += 4; + ch_value = *p - '0'; + } + if (ch_value >= 0) { + if (p[2] == ']') { + ch_value = ch_value * 10 + p[1] - '0'; + } + if (ch_value != ch) { + return; /* Ignore other channels */ + } + } + } } else if (TraceFilter[0] != 0) { - return; /* Ignore trace if trace filter is activated, but idle */ - } - - diva_os_get_time (&sec, &usec); - - while (!(pmsg = (diva_dbg_entry_head_t*)queueAllocMsg (dbg_queue, - (word)length+sizeof(*pmsg)))) { - if ((pmsg = (diva_dbg_entry_head_t*)queuePeekMsg (dbg_queue, &size))) { - queueFreeMsg (dbg_queue); - } else { - break; - } - } - if (pmsg) { - memcpy (&pmsg[1], xlog_buffer, length); - pmsg->sequence = dbg_sequence++; - pmsg->time_sec = sec; - pmsg->time_usec = usec; - pmsg->facility = MSG_TYPE_MLOG; - pmsg->dli = pC->logical; - pmsg->drv_id = pC->hDbg->id; - pmsg->di_cpu = 0; - pmsg->data_length = length; - queueCompleteMsg (pmsg); - if (queueCount(dbg_queue)) { - diva_maint_wakeup_read(); - } - } + return; /* Ignore trace if trace filter is activated, but idle */ + } + + diva_os_get_time(&sec, &usec); + + while (!(pmsg = (diva_dbg_entry_head_t *)queueAllocMsg(dbg_queue, + (word)length + sizeof(*pmsg)))) { + if ((pmsg = (diva_dbg_entry_head_t *)queuePeekMsg(dbg_queue, &size))) { + queueFreeMsg(dbg_queue); + } else { + break; + } + } + if (pmsg) { + memcpy(&pmsg[1], xlog_buffer, length); + pmsg->sequence = dbg_sequence++; + pmsg->time_sec = sec; + pmsg->time_usec = usec; + pmsg->facility = MSG_TYPE_MLOG; + pmsg->dli = pC->logical; + pmsg->drv_id = pC->hDbg->id; + pmsg->di_cpu = 0; + pmsg->data_length = length; + queueCompleteMsg(pmsg); + if (queueCount(dbg_queue)) { + diva_maint_wakeup_read(); + } + } } /* Convert MAINT trace mask to management interface trace mask/work/facility and issue command to management interface - */ -static void diva_change_management_debug_mask (diva_maint_client_t* pC, dword old_mask) { - if (pC->request && pC->hDbg && pC->pIdiLib) { - dword changed = pC->hDbg->dbgMask ^ old_mask; - - if (changed & DIVA_MGT_DBG_TRACE) { - (*(pC->pIdiLib->DivaSTraceSetInfo))(pC->pIdiLib, - (pC->hDbg->dbgMask & DIVA_MGT_DBG_TRACE) != 0); - } - if (changed & DIVA_MGT_DBG_DCHAN) { - (*(pC->pIdiLib->DivaSTraceSetDChannel))(pC->pIdiLib, - (pC->hDbg->dbgMask & DIVA_MGT_DBG_DCHAN) != 0); - } - if (!TraceFilter[0]) { - if (changed & DIVA_MGT_DBG_IFC_BCHANNEL) { - int i, state = ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0); - - for (i = 0; i < pC->channels; i++) { - (*(pC->pIdiLib->DivaSTraceSetBChannel))(pC->pIdiLib, i+1, state); - } - } - if (changed & DIVA_MGT_DBG_IFC_AUDIO) { - int i, state = ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0); - - for (i = 0; i < pC->channels; i++) { - (*(pC->pIdiLib->DivaSTraceSetAudioTap))(pC->pIdiLib, i+1, state); - } - } - } - } +*/ +static void diva_change_management_debug_mask(diva_maint_client_t *pC, dword old_mask) { + if (pC->request && pC->hDbg && pC->pIdiLib) { + dword changed = pC->hDbg->dbgMask ^ old_mask; + + if (changed & DIVA_MGT_DBG_TRACE) { + (*(pC->pIdiLib->DivaSTraceSetInfo))(pC->pIdiLib, + (pC->hDbg->dbgMask & DIVA_MGT_DBG_TRACE) != 0); + } + if (changed & DIVA_MGT_DBG_DCHAN) { + (*(pC->pIdiLib->DivaSTraceSetDChannel))(pC->pIdiLib, + (pC->hDbg->dbgMask & DIVA_MGT_DBG_DCHAN) != 0); + } + if (!TraceFilter[0]) { + if (changed & DIVA_MGT_DBG_IFC_BCHANNEL) { + int i, state = ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0); + + for (i = 0; i < pC->channels; i++) { + (*(pC->pIdiLib->DivaSTraceSetBChannel))(pC->pIdiLib, i + 1, state); + } + } + if (changed & DIVA_MGT_DBG_IFC_AUDIO) { + int i, state = ((pC->hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0); + + for (i = 0; i < pC->channels; i++) { + (*(pC->pIdiLib->DivaSTraceSetAudioTap))(pC->pIdiLib, i + 1, state); + } + } + } + } } -void diva_mnt_internal_dprintf (dword drv_id, dword type, char* fmt, ...) { - va_list ap; +void diva_mnt_internal_dprintf(dword drv_id, dword type, char *fmt, ...) { + va_list ap; va_start(ap, fmt); - DI_format (0, (word)drv_id, (int)type, fmt, ap); + DI_format(0, (word)drv_id, (int)type, fmt, ap); va_end(ap); } /* Shutdown all adapters before driver removal - */ -int diva_mnt_shutdown_xdi_adapters (void) { - diva_os_spin_lock_magic_t old_irql, old_irql1; - int i, fret = 0; - byte * pmem; - - - for (i = 1; i < ARRAY_SIZE(clients); i++) { - pmem = NULL; - - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "unload"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "unload"); - - if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request) { - if ((*(clients[i].pIdiLib->DivaSTraceLibraryStop))(clients[i].pIdiLib) == 1) { - /* - Adapter removal complete - */ - if (clients[i].pIdiLib) { - (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib); - clients[i].pIdiLib = NULL; - - pmem = clients[i].pmem; - clients[i].pmem = NULL; - } - clients[i].hDbg = NULL; - clients[i].request_pending = 0; - - if (clients[i].dma_handle >= 0) { - /* - Free DMA handle - */ - diva_free_dma_descriptor (clients[i].request, clients[i].dma_handle); - clients[i].dma_handle = -1; +*/ +int diva_mnt_shutdown_xdi_adapters(void) { + diva_os_spin_lock_magic_t old_irql, old_irql1; + int i, fret = 0; + byte *pmem; + + + for (i = 1; i < ARRAY_SIZE(clients); i++) { + pmem = NULL; + + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "unload"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "unload"); + + if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request) { + if ((*(clients[i].pIdiLib->DivaSTraceLibraryStop))(clients[i].pIdiLib) == 1) { + /* + Adapter removal complete + */ + if (clients[i].pIdiLib) { + (*(clients[i].pIdiLib->DivaSTraceLibraryFinit))(clients[i].pIdiLib->hLib); + clients[i].pIdiLib = NULL; + + pmem = clients[i].pmem; + clients[i].pmem = NULL; } - clients[i].request = NULL; - } else { - fret = -1; - } - } - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "unload"); - if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request && clients[i].request_pending) { - clients[i].request_pending = 0; - (*(clients[i].request))((ENTITY*)(*(clients[i].pIdiLib->DivaSTraceGetHandle))(clients[i].pIdiLib->hLib)); - if (clients[i].dma_handle >= 0) { - diva_free_dma_descriptor (clients[i].request, clients[i].dma_handle); - clients[i].dma_handle = -1; - } - } - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "unload"); - - if (pmem) { - diva_os_free (0, pmem); - } - } - - return (fret); + clients[i].hDbg = NULL; + clients[i].request_pending = 0; + + if (clients[i].dma_handle >= 0) { + /* + Free DMA handle + */ + diva_free_dma_descriptor(clients[i].request, clients[i].dma_handle); + clients[i].dma_handle = -1; + } + clients[i].request = NULL; + } else { + fret = -1; + } + } + + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "unload"); + if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request && clients[i].request_pending) { + clients[i].request_pending = 0; + (*(clients[i].request))((ENTITY *)(*(clients[i].pIdiLib->DivaSTraceGetHandle))(clients[i].pIdiLib->hLib)); + if (clients[i].dma_handle >= 0) { + diva_free_dma_descriptor(clients[i].request, clients[i].dma_handle); + clients[i].dma_handle = -1; + } + } + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "unload"); + + if (pmem) { + diva_os_free(0, pmem); + } + } + + return (fret); } /* Set/Read the trace filter used for selective tracing. Affects B- and Audio Tap trace mask at run time - */ -int diva_set_trace_filter (int filter_length, const char* filter) { - diva_os_spin_lock_magic_t old_irql, old_irql1; - int i, ch, on, client_b_on, client_atap_on; - - diva_os_enter_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask"); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "write_filter"); - - if (filter_length <= DIVA_MAX_SELECTIVE_FILTER_LENGTH) { - memcpy (&TraceFilter[0], filter, filter_length); - if (TraceFilter[filter_length]) { - TraceFilter[filter_length] = 0; - } - if (TraceFilter[0] == '*') { - TraceFilter[0] = 0; - } - } else { - filter_length = -1; - } - - TraceFilterIdent = -1; - TraceFilterChannel = -1; - - on = (TraceFilter[0] == 0); - - for (i = 1; i < ARRAY_SIZE(clients); i++) { - if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request) { - client_b_on = on && ((clients[i].hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0); - client_atap_on = on && ((clients[i].hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0); - for (ch = 0; ch < clients[i].channels; ch++) { - (*(clients[i].pIdiLib->DivaSTraceSetBChannel))(clients[i].pIdiLib->hLib, ch+1, client_b_on); - (*(clients[i].pIdiLib->DivaSTraceSetAudioTap))(clients[i].pIdiLib->hLib, ch+1, client_atap_on); - } - } - } - - for (i = 1; i < ARRAY_SIZE(clients); i++) { - if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request && clients[i].request_pending) { - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "write_filter"); - clients[i].request_pending = 0; - (*(clients[i].request))((ENTITY*)(*(clients[i].pIdiLib->DivaSTraceGetHandle))(clients[i].pIdiLib->hLib)); - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "write_filter"); - } - } - - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "write_filter"); - diva_os_leave_spin_lock (&dbg_adapter_lock, &old_irql1, "dbg mask"); - - return (filter_length); +*/ +int diva_set_trace_filter(int filter_length, const char *filter) { + diva_os_spin_lock_magic_t old_irql, old_irql1; + int i, ch, on, client_b_on, client_atap_on; + + diva_os_enter_spin_lock(&dbg_adapter_lock, &old_irql1, "dbg mask"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "write_filter"); + + if (filter_length <= DIVA_MAX_SELECTIVE_FILTER_LENGTH) { + memcpy(&TraceFilter[0], filter, filter_length); + if (TraceFilter[filter_length]) { + TraceFilter[filter_length] = 0; + } + if (TraceFilter[0] == '*') { + TraceFilter[0] = 0; + } + } else { + filter_length = -1; + } + + TraceFilterIdent = -1; + TraceFilterChannel = -1; + + on = (TraceFilter[0] == 0); + + for (i = 1; i < ARRAY_SIZE(clients); i++) { + if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request) { + client_b_on = on && ((clients[i].hDbg->dbgMask & DIVA_MGT_DBG_IFC_BCHANNEL) != 0); + client_atap_on = on && ((clients[i].hDbg->dbgMask & DIVA_MGT_DBG_IFC_AUDIO) != 0); + for (ch = 0; ch < clients[i].channels; ch++) { + (*(clients[i].pIdiLib->DivaSTraceSetBChannel))(clients[i].pIdiLib->hLib, ch + 1, client_b_on); + (*(clients[i].pIdiLib->DivaSTraceSetAudioTap))(clients[i].pIdiLib->hLib, ch + 1, client_atap_on); + } + } + } + + for (i = 1; i < ARRAY_SIZE(clients); i++) { + if (clients[i].hDbg && clients[i].pIdiLib && clients[i].request && clients[i].request_pending) { + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "write_filter"); + clients[i].request_pending = 0; + (*(clients[i].request))((ENTITY *)(*(clients[i].pIdiLib->DivaSTraceGetHandle))(clients[i].pIdiLib->hLib)); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "write_filter"); + } + } + + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "write_filter"); + diva_os_leave_spin_lock(&dbg_adapter_lock, &old_irql1, "dbg mask"); + + return (filter_length); } -int diva_get_trace_filter (int max_length, char* filter) { - diva_os_spin_lock_magic_t old_irql; - int len; +int diva_get_trace_filter(int max_length, char *filter) { + diva_os_spin_lock_magic_t old_irql; + int len; - diva_os_enter_spin_lock (&dbg_q_lock, &old_irql, "read_filter"); - len = strlen (&TraceFilter[0]) + 1; - if (max_length >= len) { - memcpy (filter, &TraceFilter[0], len); - } - diva_os_leave_spin_lock (&dbg_q_lock, &old_irql, "read_filter"); + diva_os_enter_spin_lock(&dbg_q_lock, &old_irql, "read_filter"); + len = strlen(&TraceFilter[0]) + 1; + if (max_length >= len) { + memcpy(filter, &TraceFilter[0], len); + } + diva_os_leave_spin_lock(&dbg_q_lock, &old_irql, "read_filter"); - return (len); + return (len); } -static int diva_dbg_cmp_key (const char* ref, const char* key) { +static int diva_dbg_cmp_key(const char *ref, const char *key) { while (*key && (*ref++ == *key++)); - return (!*key && !*ref); + return (!*key && !*ref); } /* @@ -2055,78 +2055,77 @@ static int diva_dbg_cmp_key (const char* ref, const char* key) { all following characters are interpreted as command. Followings commands are available: - single, trace single call at time, independent from CPN/CiPN - */ -static int diva_mnt_cmp_nmbr (const char* nmbr) { - const char* ref = &TraceFilter[0]; - int ref_len = strlen(&TraceFilter[0]), nmbr_len = strlen(nmbr); - - if (ref[0] == 'C') { - if (diva_dbg_cmp_key (&ref[1], "single")) { - return (0); - } - return (-1); - } - - if (!ref_len || (ref_len > nmbr_len)) { - return (-1); - } - - nmbr = nmbr + nmbr_len - 1; - ref = ref + ref_len - 1; - - while (ref_len--) { - if (*nmbr-- != *ref--) { - return (-1); - } - } - - return (0); +*/ +static int diva_mnt_cmp_nmbr(const char *nmbr) { + const char *ref = &TraceFilter[0]; + int ref_len = strlen(&TraceFilter[0]), nmbr_len = strlen(nmbr); + + if (ref[0] == 'C') { + if (diva_dbg_cmp_key(&ref[1], "single")) { + return (0); + } + return (-1); + } + + if (!ref_len || (ref_len > nmbr_len)) { + return (-1); + } + + nmbr = nmbr + nmbr_len - 1; + ref = ref + ref_len - 1; + + while (ref_len--) { + if (*nmbr-- != *ref--) { + return (-1); + } + } + + return (0); } -static int diva_get_dma_descriptor (IDI_CALL request, dword *dma_magic) { - ENTITY e; - IDI_SYNC_REQ* pReq = (IDI_SYNC_REQ*)&e; +static int diva_get_dma_descriptor(IDI_CALL request, dword *dma_magic) { + ENTITY e; + IDI_SYNC_REQ *pReq = (IDI_SYNC_REQ *)&e; - if (!request) { - return (-1); - } + if (!request) { + return (-1); + } - pReq->xdi_dma_descriptor_operation.Req = 0; - pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; + pReq->xdi_dma_descriptor_operation.Req = 0; + pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; - pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC; - pReq->xdi_dma_descriptor_operation.info.descriptor_number = -1; - pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; - pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; + pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC; + pReq->xdi_dma_descriptor_operation.info.descriptor_number = -1; + pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; + pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; - (*request)((ENTITY*)pReq); + (*request)((ENTITY *)pReq); - if (!pReq->xdi_dma_descriptor_operation.info.operation && - (pReq->xdi_dma_descriptor_operation.info.descriptor_number >= 0) && - pReq->xdi_dma_descriptor_operation.info.descriptor_magic) { - *dma_magic = pReq->xdi_dma_descriptor_operation.info.descriptor_magic; - return (pReq->xdi_dma_descriptor_operation.info.descriptor_number); - } else { - return (-1); - } + if (!pReq->xdi_dma_descriptor_operation.info.operation && + (pReq->xdi_dma_descriptor_operation.info.descriptor_number >= 0) && + pReq->xdi_dma_descriptor_operation.info.descriptor_magic) { + *dma_magic = pReq->xdi_dma_descriptor_operation.info.descriptor_magic; + return (pReq->xdi_dma_descriptor_operation.info.descriptor_number); + } else { + return (-1); + } } -static void diva_free_dma_descriptor (IDI_CALL request, int nr) { - ENTITY e; - IDI_SYNC_REQ* pReq = (IDI_SYNC_REQ*)&e; +static void diva_free_dma_descriptor(IDI_CALL request, int nr) { + ENTITY e; + IDI_SYNC_REQ *pReq = (IDI_SYNC_REQ *)&e; - if (!request || (nr < 0)) { - return; - } + if (!request || (nr < 0)) { + return; + } - pReq->xdi_dma_descriptor_operation.Req = 0; - pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; + pReq->xdi_dma_descriptor_operation.Req = 0; + pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; - pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE; - pReq->xdi_dma_descriptor_operation.info.descriptor_number = nr; - pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; - pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; + pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE; + pReq->xdi_dma_descriptor_operation.info.descriptor_number = nr; + pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; + pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; - (*request)((ENTITY*)pReq); + (*request)((ENTITY *)pReq); } - diff --git a/drivers/isdn/hardware/eicon/debug_if.h b/drivers/isdn/hardware/eicon/debug_if.h index 4db739d5803c..fc5953a35ff6 100644 --- a/drivers/isdn/hardware/eicon/debug_if.h +++ b/drivers/isdn/hardware/eicon/debug_if.h @@ -1,23 +1,23 @@ /* * - Copyright (c) Eicon Technology Corporation, 2000. + Copyright (c) Eicon Technology Corporation, 2000. * - This source file is supplied for the use with Eicon - Technology Corporation's range of DIVA Server Adapters. + This source file is supplied for the use with Eicon + Technology Corporation's range of DIVA Server Adapters. * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_DEBUG_IF_H__ @@ -31,35 +31,35 @@ #define MSG_FRAME_MAX_SIZE 2150 typedef struct _diva_dbg_entry_head { - dword sequence; - dword time_sec; - dword time_usec; - dword facility; - dword dli; - dword drv_id; - dword di_cpu; - dword data_length; + dword sequence; + dword time_sec; + dword time_usec; + dword facility; + dword dli; + dword drv_id; + dword di_cpu; + dword data_length; } diva_dbg_entry_head_t; -int diva_maint_init (byte* base, unsigned long length, int do_init); -void* diva_maint_finit (void); -dword diva_dbg_q_length (void); -diva_dbg_entry_head_t* diva_maint_get_message (word* size, - diva_os_spin_lock_magic_t* old_irql); -void diva_maint_ack_message (int do_release, - diva_os_spin_lock_magic_t* old_irql); -void diva_maint_prtComp (char *format, ...); -void diva_maint_wakeup_read (void); -int diva_get_driver_info (dword id, byte* data, int data_length); -int diva_get_driver_dbg_mask (dword id, byte* data); -int diva_set_driver_dbg_mask (dword id, dword mask); -void diva_mnt_remove_xdi_adapter (const DESCRIPTOR* d); -void diva_mnt_add_xdi_adapter (const DESCRIPTOR* d); -int diva_mnt_shutdown_xdi_adapters (void); +int diva_maint_init(byte *base, unsigned long length, int do_init); +void *diva_maint_finit(void); +dword diva_dbg_q_length(void); +diva_dbg_entry_head_t *diva_maint_get_message(word *size, + diva_os_spin_lock_magic_t *old_irql); +void diva_maint_ack_message(int do_release, + diva_os_spin_lock_magic_t *old_irql); +void diva_maint_prtComp(char *format, ...); +void diva_maint_wakeup_read(void); +int diva_get_driver_info(dword id, byte *data, int data_length); +int diva_get_driver_dbg_mask(dword id, byte *data); +int diva_set_driver_dbg_mask(dword id, dword mask); +void diva_mnt_remove_xdi_adapter(const DESCRIPTOR *d); +void diva_mnt_add_xdi_adapter(const DESCRIPTOR *d); +int diva_mnt_shutdown_xdi_adapters(void); #define DIVA_MAX_SELECTIVE_FILTER_LENGTH 127 -int diva_set_trace_filter (int filter_length, const char* filter); -int diva_get_trace_filter (int max_length, char* filter); +int diva_set_trace_filter(int filter_length, const char *filter); +int diva_get_trace_filter(int max_length, char *filter); #define DITRACE_CMD_GET_DRIVER_INFO 1 @@ -72,7 +72,7 @@ int diva_get_trace_filter (int max_length, char* filter); /* Trace lavels for debug via management interface - */ +*/ #define DIVA_MGT_DBG_TRACE 0x00000001 /* All trace messages from the card */ #define DIVA_MGT_DBG_DCHAN 0x00000002 /* All D-channel relater trace messages */ #define DIVA_MGT_DBG_MDM_PROGRESS 0x00000004 /* Modem progress events */ @@ -86,5 +86,3 @@ int diva_get_trace_filter (int max_length, char* filter); #define DIVA_MGT_DBG_IFC_AUDIO 0x00000400 /* Audio Tap trace for all channels */ # endif /* DEBUG_IF___H */ - - diff --git a/drivers/isdn/hardware/eicon/debuglib.c b/drivers/isdn/hardware/eicon/debuglib.c index e39c5c1f623e..d5b1092a54f0 100644 --- a/drivers/isdn/hardware/eicon/debuglib.c +++ b/drivers/isdn/hardware/eicon/debuglib.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -29,35 +29,35 @@ #ifdef DIVA_NO_DEBUGLIB static DIVA_DI_PRINTF dprintf; #else /* DIVA_NO_DEBUGLIB */ - + _DbgHandle_ myDriverDebugHandle = { 0 /*!Registered*/, DBG_HANDLE_VERSION }; DIVA_DI_PRINTF dprintf = no_printf; /*****************************************************************************/ -#define DBG_FUNC(name) \ -void \ -myDbgPrint_##name (char *format, ...) \ -{ va_list ap ; \ - if ( myDriverDebugHandle.dbg_prt ) \ - { va_start (ap, format) ; \ - (myDriverDebugHandle.dbg_prt) \ - (myDriverDebugHandle.id, DLI_##name, format, ap) ; \ - va_end (ap) ; \ -} } +#define DBG_FUNC(name) \ + void \ + myDbgPrint_##name(char *format, ...) \ + { va_list ap; \ + if (myDriverDebugHandle.dbg_prt) \ + { va_start(ap, format); \ + (myDriverDebugHandle.dbg_prt) \ + (myDriverDebugHandle.id, DLI_##name, format, ap); \ + va_end(ap); \ + } } DBG_FUNC(LOG) DBG_FUNC(FTL) DBG_FUNC(ERR) DBG_FUNC(TRC) DBG_FUNC(MXLOG) DBG_FUNC(FTL_MXLOG) -void -myDbgPrint_EVL (long msgID, ...) -{ va_list ap ; - if ( myDriverDebugHandle.dbg_ev ) - { va_start (ap, msgID) ; - (myDriverDebugHandle.dbg_ev) - (myDriverDebugHandle.id, (unsigned long)msgID, ap) ; - va_end (ap) ; -} } +void +myDbgPrint_EVL(long msgID, ...) +{ va_list ap; + if (myDriverDebugHandle.dbg_ev) + { va_start(ap, msgID); + (myDriverDebugHandle.dbg_ev) + (myDriverDebugHandle.id, (unsigned long)msgID, ap); + va_end(ap); + } } DBG_FUNC(REG) DBG_FUNC(MEM) DBG_FUNC(SPL) @@ -76,81 +76,81 @@ DBG_FUNC(PRV2) DBG_FUNC(PRV3) /*****************************************************************************/ int -DbgRegister (char *drvName, char *drvTag, unsigned long dbgMask) +DbgRegister(char *drvName, char *drvTag, unsigned long dbgMask) { - int len; + int len; /* * deregister (if already registered) and zero out myDriverDebugHandle */ - DbgDeregister () ; + DbgDeregister(); /* * initialize the debug handle */ - myDriverDebugHandle.Version = DBG_HANDLE_VERSION ; - myDriverDebugHandle.id = -1 ; - myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG) ; - len = strlen (drvName) ; - memcpy (myDriverDebugHandle.drvName, drvName, - (len < sizeof(myDriverDebugHandle.drvName)) ? - len : sizeof(myDriverDebugHandle.drvName) - 1) ; - len = strlen (drvTag) ; - memcpy (myDriverDebugHandle.drvTag, drvTag, - (len < sizeof(myDriverDebugHandle.drvTag)) ? - len : sizeof(myDriverDebugHandle.drvTag) - 1) ; + myDriverDebugHandle.Version = DBG_HANDLE_VERSION; + myDriverDebugHandle.id = -1; + myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG); + len = strlen(drvName); + memcpy(myDriverDebugHandle.drvName, drvName, + (len < sizeof(myDriverDebugHandle.drvName)) ? + len : sizeof(myDriverDebugHandle.drvName) - 1); + len = strlen(drvTag); + memcpy(myDriverDebugHandle.drvTag, drvTag, + (len < sizeof(myDriverDebugHandle.drvTag)) ? + len : sizeof(myDriverDebugHandle.drvTag) - 1); /* * Try to register debugging via old (and only) interface */ - dprintf("\000\377", &myDriverDebugHandle) ; - if ( myDriverDebugHandle.dbg_prt ) - { - return (1) ; - } + dprintf("\000\377", &myDriverDebugHandle); + if (myDriverDebugHandle.dbg_prt) + { + return (1); + } /* * Check if we registered with an old maint driver (see debuglib.h) */ - if ( myDriverDebugHandle.dbg_end != NULL - /* location of 'dbg_prt' in _OldDbgHandle_ struct */ - && (myDriverDebugHandle.regTime.LowPart || - myDriverDebugHandle.regTime.HighPart ) ) - /* same location as in _OldDbgHandle_ struct */ - { - dprintf("%s: Cannot log to old maint driver !", drvName) ; - myDriverDebugHandle.dbg_end = - ((_OldDbgHandle_ *)&myDriverDebugHandle)->dbg_end ; - DbgDeregister () ; - } - return (0) ; + if (myDriverDebugHandle.dbg_end != NULL + /* location of 'dbg_prt' in _OldDbgHandle_ struct */ + && (myDriverDebugHandle.regTime.LowPart || + myDriverDebugHandle.regTime.HighPart)) + /* same location as in _OldDbgHandle_ struct */ + { + dprintf("%s: Cannot log to old maint driver !", drvName); + myDriverDebugHandle.dbg_end = + ((_OldDbgHandle_ *)&myDriverDebugHandle)->dbg_end; + DbgDeregister(); + } + return (0); } /*****************************************************************************/ void -DbgSetLevel (unsigned long dbgMask) +DbgSetLevel(unsigned long dbgMask) { - myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG) ; + myDriverDebugHandle.dbgMask = dbgMask | (DL_EVL | DL_FTL | DL_LOG); } /*****************************************************************************/ void -DbgDeregister (void) +DbgDeregister(void) { - if ( myDriverDebugHandle.dbg_end ) - { - (myDriverDebugHandle.dbg_end)(&myDriverDebugHandle) ; - } - memset (&myDriverDebugHandle, 0, sizeof(myDriverDebugHandle)) ; + if (myDriverDebugHandle.dbg_end) + { + (myDriverDebugHandle.dbg_end)(&myDriverDebugHandle); + } + memset(&myDriverDebugHandle, 0, sizeof(myDriverDebugHandle)); } -void xdi_dbg_xlog (char* x, ...) { - va_list ap; - va_start (ap, x); - if (myDriverDebugHandle.dbg_end && - (myDriverDebugHandle.dbg_irq || myDriverDebugHandle.dbg_old) && - (myDriverDebugHandle.dbgMask & DL_STAT)) { - if (myDriverDebugHandle.dbg_irq) { - (*(myDriverDebugHandle.dbg_irq))(myDriverDebugHandle.id, - (x[0] != 0) ? DLI_TRC : DLI_XLOG, x, ap); - } else { - (*(myDriverDebugHandle.dbg_old))(myDriverDebugHandle.id, x, ap); - } - } - va_end(ap); +void xdi_dbg_xlog(char *x, ...) { + va_list ap; + va_start(ap, x); + if (myDriverDebugHandle.dbg_end && + (myDriverDebugHandle.dbg_irq || myDriverDebugHandle.dbg_old) && + (myDriverDebugHandle.dbgMask & DL_STAT)) { + if (myDriverDebugHandle.dbg_irq) { + (*(myDriverDebugHandle.dbg_irq))(myDriverDebugHandle.id, + (x[0] != 0) ? DLI_TRC : DLI_XLOG, x, ap); + } else { + (*(myDriverDebugHandle.dbg_old))(myDriverDebugHandle.id, x, ap); + } + } + va_end(ap); } /*****************************************************************************/ #endif /* DIVA_NO_DEBUGLIB */ diff --git a/drivers/isdn/hardware/eicon/debuglib.h b/drivers/isdn/hardware/eicon/debuglib.h index 02eed6b4354c..6dcbf6afb8f9 100644 --- a/drivers/isdn/hardware/eicon/debuglib.h +++ b/drivers/isdn/hardware/eicon/debuglib.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #if !defined(__DEBUGLIB_H__) @@ -103,43 +103,43 @@ #define DL_TO_KERNEL 0x40000000 #ifdef DIVA_NO_DEBUGLIB -#define myDbgPrint_LOG(x...) do { } while(0); -#define myDbgPrint_FTL(x...) do { } while(0); -#define myDbgPrint_ERR(x...) do { } while(0); -#define myDbgPrint_TRC(x...) do { } while(0); -#define myDbgPrint_MXLOG(x...) do { } while(0); -#define myDbgPrint_EVL(x...) do { } while(0); -#define myDbgPrint_REG(x...) do { } while(0); -#define myDbgPrint_MEM(x...) do { } while(0); -#define myDbgPrint_SPL(x...) do { } while(0); -#define myDbgPrint_IRP(x...) do { } while(0); -#define myDbgPrint_TIM(x...) do { } while(0); -#define myDbgPrint_BLK(x...) do { } while(0); -#define myDbgPrint_TAPI(x...) do { } while(0); -#define myDbgPrint_NDIS(x...) do { } while(0); -#define myDbgPrint_CONN(x...) do { } while(0); -#define myDbgPrint_STAT(x...) do { } while(0); -#define myDbgPrint_SEND(x...) do { } while(0); -#define myDbgPrint_RECV(x...) do { } while(0); -#define myDbgPrint_PRV0(x...) do { } while(0); -#define myDbgPrint_PRV1(x...) do { } while(0); -#define myDbgPrint_PRV2(x...) do { } while(0); -#define myDbgPrint_PRV3(x...) do { } while(0); -#define DBG_TEST(func,args) do { } while(0); -#define DBG_EVL_ID(args) do { } while(0); +#define myDbgPrint_LOG(x...) do { } while (0); +#define myDbgPrint_FTL(x...) do { } while (0); +#define myDbgPrint_ERR(x...) do { } while (0); +#define myDbgPrint_TRC(x...) do { } while (0); +#define myDbgPrint_MXLOG(x...) do { } while (0); +#define myDbgPrint_EVL(x...) do { } while (0); +#define myDbgPrint_REG(x...) do { } while (0); +#define myDbgPrint_MEM(x...) do { } while (0); +#define myDbgPrint_SPL(x...) do { } while (0); +#define myDbgPrint_IRP(x...) do { } while (0); +#define myDbgPrint_TIM(x...) do { } while (0); +#define myDbgPrint_BLK(x...) do { } while (0); +#define myDbgPrint_TAPI(x...) do { } while (0); +#define myDbgPrint_NDIS(x...) do { } while (0); +#define myDbgPrint_CONN(x...) do { } while (0); +#define myDbgPrint_STAT(x...) do { } while (0); +#define myDbgPrint_SEND(x...) do { } while (0); +#define myDbgPrint_RECV(x...) do { } while (0); +#define myDbgPrint_PRV0(x...) do { } while (0); +#define myDbgPrint_PRV1(x...) do { } while (0); +#define myDbgPrint_PRV2(x...) do { } while (0); +#define myDbgPrint_PRV3(x...) do { } while (0); +#define DBG_TEST(func, args) do { } while (0); +#define DBG_EVL_ID(args) do { } while (0); #else /* DIVA_NO_DEBUGLIB */ /* * define low level macros for formatted & raw debugging */ -#define DBG_DECL(func) extern void myDbgPrint_##func (char *, ...) ; +#define DBG_DECL(func) extern void myDbgPrint_##func(char *, ...); DBG_DECL(LOG) DBG_DECL(FTL) DBG_DECL(ERR) DBG_DECL(TRC) DBG_DECL(MXLOG) DBG_DECL(FTL_MXLOG) -extern void myDbgPrint_EVL (long, ...) ; +extern void myDbgPrint_EVL(long, ...); DBG_DECL(REG) DBG_DECL(MEM) DBG_DECL(SPL) @@ -156,34 +156,34 @@ DBG_DECL(PRV0) DBG_DECL(PRV1) DBG_DECL(PRV2) DBG_DECL(PRV3) -#ifdef _KERNEL_DBG_PRINT_ +#ifdef _KERNEL_DBG_PRINT_ /* * tracing to maint and kernel if selected in the trace mask. */ -#define DBG_TEST(func,args) \ -{ if ( (myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func ) \ - { \ - if ( (myDriverDebugHandle.dbgMask) & DL_TO_KERNEL ) \ - {DbgPrint args; DbgPrint ("\r\n");} \ - myDbgPrint_##func args ; \ -} } +#define DBG_TEST(func, args) \ + { if ((myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func) \ + { \ + if ((myDriverDebugHandle.dbgMask) & DL_TO_KERNEL) \ + { DbgPrint args; DbgPrint("\r\n"); } \ + myDbgPrint_##func args; \ + } } #else /* * Standard tracing to maint driver. */ -#define DBG_TEST(func,args) \ -{ if ( (myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func ) \ - { myDbgPrint_##func args ; \ -} } +#define DBG_TEST(func, args) \ + { if ((myDriverDebugHandle.dbgMask) & (unsigned long)DL_##func) \ + { myDbgPrint_##func args; \ + } } #endif /* * For event level debug use a separate define, the parameter are * different and cause compiler errors on some systems. */ -#define DBG_EVL_ID(args) \ -{ if ( (myDriverDebugHandle.dbgMask) & (unsigned long)DL_EVL ) \ - { myDbgPrint_EVL args ; \ -} } +#define DBG_EVL_ID(args) \ + { if ((myDriverDebugHandle.dbgMask) & (unsigned long)DL_EVL) \ + { myDbgPrint_EVL args; \ + } } #endif /* DIVA_NO_DEBUGLIB */ @@ -214,109 +214,109 @@ DBG_DECL(PRV3) * prototypes for debug register/deregister functions in "debuglib.c" */ #ifdef DIVA_NO_DEBUGLIB -#define DbgRegister(name,tag, mask) do { } while(0) -#define DbgDeregister() do { } while(0) -#define DbgSetLevel(mask) do { } while(0) +#define DbgRegister(name, tag, mask) do { } while (0) +#define DbgDeregister() do { } while (0) +#define DbgSetLevel(mask) do { } while (0) #else extern DIVA_DI_PRINTF dprintf; -extern int DbgRegister (char *drvName, char *drvTag, unsigned long dbgMask) ; -extern void DbgDeregister (void) ; -extern void DbgSetLevel (unsigned long dbgMask) ; +extern int DbgRegister(char *drvName, char *drvTag, unsigned long dbgMask); +extern void DbgDeregister(void); +extern void DbgSetLevel(unsigned long dbgMask); #endif /* * driver internal structure for debug handling; * in client drivers this structure is maintained in "debuglib.c", * in the debug driver "debug.c" maintains a chain of such structs. */ -typedef struct _DbgHandle_ *pDbgHandle ; -typedef void ( * DbgEnd) (pDbgHandle) ; -typedef void ( * DbgLog) (unsigned short, int, char *, va_list) ; -typedef void ( * DbgOld) (unsigned short, char *, va_list) ; -typedef void ( * DbgEv) (unsigned short, unsigned long, va_list) ; -typedef void ( * DbgIrq) (unsigned short, int, char *, va_list) ; +typedef struct _DbgHandle_ *pDbgHandle; +typedef void (*DbgEnd)(pDbgHandle); +typedef void (*DbgLog)(unsigned short, int, char *, va_list); +typedef void (*DbgOld)(unsigned short, char *, va_list); +typedef void (*DbgEv)(unsigned short, unsigned long, va_list); +typedef void (*DbgIrq)(unsigned short, int, char *, va_list); typedef struct _DbgHandle_ -{ char Registered ; /* driver successfully registered */ +{ char Registered; /* driver successfully registered */ #define DBG_HANDLE_REG_NEW 0x01 /* this (new) structure */ #define DBG_HANDLE_REG_OLD 0x7f /* old structure (see below) */ - char Version; /* version of this structure */ + char Version; /* version of this structure */ #define DBG_HANDLE_VERSION 1 /* contains dbg_old function now */ #define DBG_HANDLE_VER_EXT 2 /* pReserved points to extended info*/ - short id ; /* internal id of registered driver */ - struct _DbgHandle_ *next ; /* ptr to next registered driver */ - struct /*LARGE_INTEGER*/ { - unsigned long LowPart; - long HighPart; - } regTime ; /* timestamp for registration */ - void *pIrp ; /* ptr to pending i/o request */ - unsigned long dbgMask ; /* current debug mask */ - char drvName[128] ; /* ASCII name of registered driver */ - char drvTag[64] ; /* revision string */ - DbgEnd dbg_end ; /* function for debug closing */ - DbgLog dbg_prt ; /* function for debug appending */ - DbgOld dbg_old ; /* function for old debug appending */ - DbgEv dbg_ev ; /* function for Windows NT Eventlog */ - DbgIrq dbg_irq ; /* function for irql checked debug */ - void *pReserved3 ; -} _DbgHandle_ ; -extern _DbgHandle_ myDriverDebugHandle ; + short id; /* internal id of registered driver */ + struct _DbgHandle_ *next; /* ptr to next registered driver */ + struct /*LARGE_INTEGER*/ { + unsigned long LowPart; + long HighPart; + } regTime; /* timestamp for registration */ + void *pIrp; /* ptr to pending i/o request */ + unsigned long dbgMask; /* current debug mask */ + char drvName[128]; /* ASCII name of registered driver */ + char drvTag[64]; /* revision string */ + DbgEnd dbg_end; /* function for debug closing */ + DbgLog dbg_prt; /* function for debug appending */ + DbgOld dbg_old; /* function for old debug appending */ + DbgEv dbg_ev; /* function for Windows NT Eventlog */ + DbgIrq dbg_irq; /* function for irql checked debug */ + void *pReserved3; +} _DbgHandle_; +extern _DbgHandle_ myDriverDebugHandle; typedef struct _OldDbgHandle_ -{ struct _OldDbgHandle_ *next ; - void *pIrp ; - long regTime[2] ; - unsigned long dbgMask ; - short id ; - char drvName[78] ; - DbgEnd dbg_end ; - DbgLog dbg_prt ; -} _OldDbgHandle_ ; +{ struct _OldDbgHandle_ *next; + void *pIrp; + long regTime[2]; + unsigned long dbgMask; + short id; + char drvName[78]; + DbgEnd dbg_end; + DbgLog dbg_prt; +} _OldDbgHandle_; /* the differences in DbgHandles old: tmp: new: - 0 long next char Registered char Registered - char filler char Version - short id short id - 4 long pIrp long regTime.lo long next - 8 long regTime.lo long regTime.hi long regTime.lo - 12 long regTime.hi long next long regTime.hi - 16 long dbgMask long pIrp long pIrp - 20 short id long dbgMask long dbgMask - 22 char drvName[78] .. - 24 .. char drvName[16] char drvName[16] - 40 .. char drvTag[64] char drvTag[64] - 100 void *dbg_end .. .. - 104 void *dbg_prt void *dbg_end void *dbg_end - 108 .. void *dbg_prt void *dbg_prt - 112 .. .. void *dbg_old - 116 .. .. void *dbg_ev - 120 .. .. void *dbg_irq - 124 .. .. void *pReserved3 - ( new->id == 0 && *((short *)&new->dbgMask) == -1 ) identifies "old", - new->Registered and new->Version overlay old->next, - new->next overlays old->pIrp, new->regTime matches old->regTime and - thus these fields can be maintained in new struct whithout trouble; - id, dbgMask, drvName, dbg_end and dbg_prt need special handling ! + 0 long next char Registered char Registered + char filler char Version + short id short id + 4 long pIrp long regTime.lo long next + 8 long regTime.lo long regTime.hi long regTime.lo + 12 long regTime.hi long next long regTime.hi + 16 long dbgMask long pIrp long pIrp + 20 short id long dbgMask long dbgMask + 22 char drvName[78] .. + 24 .. char drvName[16] char drvName[16] + 40 .. char drvTag[64] char drvTag[64] + 100 void *dbg_end .. .. + 104 void *dbg_prt void *dbg_end void *dbg_end + 108 .. void *dbg_prt void *dbg_prt + 112 .. .. void *dbg_old + 116 .. .. void *dbg_ev + 120 .. .. void *dbg_irq + 124 .. .. void *pReserved3 + ( new->id == 0 && *((short *)&new->dbgMask) == -1 ) identifies "old", + new->Registered and new->Version overlay old->next, + new->next overlays old->pIrp, new->regTime matches old->regTime and + thus these fields can be maintained in new struct whithout trouble; + id, dbgMask, drvName, dbg_end and dbg_prt need special handling ! */ #define DBG_EXT_TYPE_CARD_TRACE 0x00000001 typedef struct { - unsigned long ExtendedType; - union - { - /* DBG_EXT_TYPE_CARD_TRACE */ - struct - { - void ( * MaskChangedNotify) (void *pContext); - unsigned long ModuleTxtMask; - unsigned long DebugLevel; - unsigned long B_ChannelMask; - unsigned long LogBufferSize; - } CardTrace; - }Data; + unsigned long ExtendedType; + union + { + /* DBG_EXT_TYPE_CARD_TRACE */ + struct + { + void (*MaskChangedNotify)(void *pContext); + unsigned long ModuleTxtMask; + unsigned long DebugLevel; + unsigned long B_ChannelMask; + unsigned long LogBufferSize; + } CardTrace; + } Data; } _DbgExtendedInfo_; #ifndef DIVA_NO_DEBUGLIB /* ------------------------------------------------------------- - Function used for xlog-style debug + Function used for xlog-style debug ------------------------------------------------------------- */ #define XDI_USE_XLOG 1 -void xdi_dbg_xlog (char* x, ...); +void xdi_dbg_xlog(char *x, ...); #endif /* DIVA_NO_DEBUGLIB */ #endif /* __DEBUGLIB_H__ */ diff --git a/drivers/isdn/hardware/eicon/dfifo.h b/drivers/isdn/hardware/eicon/dfifo.h index 9a109c71e935..6a1d3337f99e 100644 --- a/drivers/isdn/hardware/eicon/dfifo.h +++ b/drivers/isdn/hardware/eicon/dfifo.h @@ -1,54 +1,54 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_IDI_DFIFO_INC__ #define __DIVA_IDI_DFIFO_INC__ #define DIVA_DFIFO_CACHE_SZ 64 /* Used to isolate pipe from - rest of the world - should be divisible by 4 - */ -#define DIVA_DFIFO_RAW_SZ (2512*8) + rest of the world + should be divisible by 4 + */ +#define DIVA_DFIFO_RAW_SZ (2512 * 8) #define DIVA_DFIFO_DATA_SZ 68 #define DIVA_DFIFO_HDR_SZ 4 -#define DIVA_DFIFO_SEGMENT_SZ (DIVA_DFIFO_DATA_SZ+DIVA_DFIFO_HDR_SZ) -#define DIVA_DFIFO_SEGMENTS ((DIVA_DFIFO_RAW_SZ)/(DIVA_DFIFO_SEGMENT_SZ)+1) -#define DIVA_DFIFO_MEM_SZ (\ - (DIVA_DFIFO_SEGMENT_SZ)*(DIVA_DFIFO_SEGMENTS)+\ - (DIVA_DFIFO_CACHE_SZ)*2\ - ) +#define DIVA_DFIFO_SEGMENT_SZ (DIVA_DFIFO_DATA_SZ + DIVA_DFIFO_HDR_SZ) +#define DIVA_DFIFO_SEGMENTS ((DIVA_DFIFO_RAW_SZ) / (DIVA_DFIFO_SEGMENT_SZ) + 1) +#define DIVA_DFIFO_MEM_SZ ( \ + (DIVA_DFIFO_SEGMENT_SZ) * (DIVA_DFIFO_SEGMENTS) + \ + (DIVA_DFIFO_CACHE_SZ) * 2 \ + ) #define DIVA_DFIFO_STEP DIVA_DFIFO_SEGMENT_SZ /* ------------------------------------------------------------------------- - Block header layout is: + Block header layout is: byte[0] -> flags byte[1] -> length of data in block byte[2] -> reserved byte[4] -> reserved - ------------------------------------------------------------------------- */ + ------------------------------------------------------------------------- */ #define DIVA_DFIFO_WRAP 0x80 /* This is the last block in fifo */ #define DIVA_DFIFO_READY 0x40 /* This block is ready for processing */ #define DIVA_DFIFO_LAST 0x20 /* This block is last in message */ #define DIVA_DFIFO_AUTO 0x10 /* Don't look for 'ready', don't ack */ -int diva_dfifo_create (void* start, int length); +int diva_dfifo_create(void *start, int length); #endif diff --git a/drivers/isdn/hardware/eicon/di.c b/drivers/isdn/hardware/eicon/di.c index cb14ae3e7154..cd3fba1add12 100644 --- a/drivers/isdn/hardware/eicon/di.c +++ b/drivers/isdn/hardware/eicon/di.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -29,9 +29,9 @@ #include "di_defs.h" #include "di.h" #if !defined USE_EXTENDED_DEBUGS - #include "dimaint.h" +#include "dimaint.h" #else - #define dprintf +#define dprintf #endif #include "io.h" #include "dfifo.h" @@ -40,315 +40,315 @@ /*------------------------------------------------------------------*/ /* local function prototypes */ /*------------------------------------------------------------------*/ -void pr_out(ADAPTER * a); -byte pr_dpc(ADAPTER * a); -static byte pr_ready(ADAPTER * a); +void pr_out(ADAPTER *a); +byte pr_dpc(ADAPTER *a); +static byte pr_ready(ADAPTER *a); static byte isdn_rc(ADAPTER *, byte, byte, byte, word, dword, dword); static byte isdn_ind(ADAPTER *, byte, byte, byte, PBUFFER *, byte, word); /* ----------------------------------------------------------------- - Functions used for the extended XDI Debug - macros - global convergence counter (used by all adapters) - Look by the implementation part of the functions - about the parameters. - If you change the dubugging parameters, then you should update - the aididbg.doc in the IDI doc's. + Functions used for the extended XDI Debug + macros + global convergence counter (used by all adapters) + Look by the implementation part of the functions + about the parameters. + If you change the dubugging parameters, then you should update + the aididbg.doc in the IDI doc's. ----------------------------------------------------------------- */ #if defined(XDI_USE_XLOG) #define XDI_A_NR(_x_) ((byte)(((ISDN_ADAPTER *)(_x_->io))->ANum)) -static void xdi_xlog (byte *msg, word code, int length); +static void xdi_xlog(byte *msg, word code, int length); static byte xdi_xlog_sec = 0; #else #define XDI_A_NR(_x_) ((byte)0) #endif -static void xdi_xlog_rc_event (byte Adapter, - byte Id, byte Ch, byte Rc, byte cb, byte type); -static void xdi_xlog_request (byte Adapter, byte Id, - byte Ch, byte Req, byte type); -static void xdi_xlog_ind (byte Adapter, - byte Id, - byte Ch, - byte Ind, - byte rnr_valid, - byte rnr, - byte type); +static void xdi_xlog_rc_event(byte Adapter, + byte Id, byte Ch, byte Rc, byte cb, byte type); +static void xdi_xlog_request(byte Adapter, byte Id, + byte Ch, byte Req, byte type); +static void xdi_xlog_ind(byte Adapter, + byte Id, + byte Ch, + byte Ind, + byte rnr_valid, + byte rnr, + byte type); /*------------------------------------------------------------------*/ /* output function */ /*------------------------------------------------------------------*/ -void pr_out(ADAPTER * a) +void pr_out(ADAPTER *a) { - byte e_no; - ENTITY * this = NULL; - BUFFERS *X; - word length; - word i; - word clength; - REQ * ReqOut; - byte more; - byte ReadyCount; - byte ReqCount; - byte Id; - dtrc(dprintf("pr_out")); - /* while a request is pending ... */ - e_no = look_req(a); - if(!e_no) - { - dtrc(dprintf("no_req")); - return; - } - ReadyCount = pr_ready(a); - if(!ReadyCount) - { - dtrc(dprintf("not_ready")); - return; - } - ReqCount = 0; - while(e_no && ReadyCount) { - next_req(a); - this = entity_ptr(a, e_no); + byte e_no; + ENTITY *this = NULL; + BUFFERS *X; + word length; + word i; + word clength; + REQ *ReqOut; + byte more; + byte ReadyCount; + byte ReqCount; + byte Id; + dtrc(dprintf("pr_out")); + /* while a request is pending ... */ + e_no = look_req(a); + if (!e_no) + { + dtrc(dprintf("no_req")); + return; + } + ReadyCount = pr_ready(a); + if (!ReadyCount) + { + dtrc(dprintf("not_ready")); + return; + } + ReqCount = 0; + while (e_no && ReadyCount) { + next_req(a); + this = entity_ptr(a, e_no); #ifdef USE_EXTENDED_DEBUGS - if ( !this ) - { - DBG_FTL(("XDI: [%02x] !A%d ==> NULL entity ptr - try to ignore", - xdi_xlog_sec++, (int)((ISDN_ADAPTER *)a->io)->ANum)) - e_no = look_req(a) ; - ReadyCount-- ; - continue ; - } - { - DBG_TRC((">A%d Id=0x%x Req=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, this->Id, this->Req)) - } + if (!this) + { + DBG_FTL(("XDI: [%02x] !A%d ==> NULL entity ptr - try to ignore", + xdi_xlog_sec++, (int)((ISDN_ADAPTER *)a->io)->ANum)) + e_no = look_req(a); + ReadyCount--; + continue; + } + { + DBG_TRC((">A%d Id=0x%x Req=0x%x", ((ISDN_ADAPTER *)a->io)->ANum, this->Id, this->Req)) + } #else - dbug(dprintf("out:Req=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh)); + dbug(dprintf("out:Req=%x,Id=%x,Ch=%x", this->Req, this->Id, this->ReqCh)); #endif - /* get address of next available request buffer */ - ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)]; + /* get address of next available request buffer */ + ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)]; #if defined(DIVA_ISTREAM) - if (!(a->tx_stream[this->Id] && - this->Req == N_DATA)) { + if (!(a->tx_stream[this->Id] && + this->Req == N_DATA)) { #endif - /* now copy the data from the current data buffer into the */ - /* adapters request buffer */ - length = 0; - i = this->XCurrent; - X = PTR_X(a,this); - while(iXNum && length<270) { - clength = min((word)(270-length),(word)(X[i].PLength-this->XOffset)); - a->ram_out_buffer(a, - &ReqOut->XBuffer.P[length], - PTR_P(a,this,&X[i].P[this->XOffset]), - clength); - length +=clength; - this->XOffset +=clength; - if(this->XOffset==X[i].PLength) { - this->XCurrent = (byte)++i; - this->XOffset = 0; - } - } + /* now copy the data from the current data buffer into the */ + /* adapters request buffer */ + length = 0; + i = this->XCurrent; + X = PTR_X(a, this); + while (i < this->XNum && length < 270) { + clength = min((word)(270 - length), (word)(X[i].PLength-this->XOffset)); + a->ram_out_buffer(a, + &ReqOut->XBuffer.P[length], + PTR_P(a, this, &X[i].P[this->XOffset]), + clength); + length += clength; + this->XOffset += clength; + if (this->XOffset == X[i].PLength) { + this->XCurrent = (byte)++i; + this->XOffset = 0; + } + } #if defined(DIVA_ISTREAM) - } else { /* Use CMA extension in order to transfer data to the card */ - i = this->XCurrent; - X = PTR_X(a,this); - while (i < this->XNum) { - diva_istream_write (a, - this->Id, - PTR_P(a,this,&X[i].P[0]), - X[i].PLength, - ((i+1) == this->XNum), - 0, 0); - this->XCurrent = (byte)++i; - } - length = 0; - } + } else { /* Use CMA extension in order to transfer data to the card */ + i = this->XCurrent; + X = PTR_X(a, this); + while (i < this->XNum) { + diva_istream_write(a, + this->Id, + PTR_P(a, this, &X[i].P[0]), + X[i].PLength, + ((i + 1) == this->XNum), + 0, 0); + this->XCurrent = (byte)++i; + } + length = 0; + } #endif - a->ram_outw(a, &ReqOut->XBuffer.length, length); - a->ram_out(a, &ReqOut->ReqId, this->Id); - a->ram_out(a, &ReqOut->ReqCh, this->ReqCh); - /* if it's a specific request (no ASSIGN) ... */ - if(this->Id &0x1f) { - /* if buffers are left in the list of data buffers do */ - /* do chaining (LL_MDATA, N_MDATA) */ - this->More++; - if(iXNum && this->MInd) { - xdi_xlog_request (XDI_A_NR(a), this->Id, this->ReqCh, this->MInd, - a->IdTypeTable[this->No]); - a->ram_out(a, &ReqOut->Req, this->MInd); - more = true; - } - else { - xdi_xlog_request (XDI_A_NR(a), this->Id, this->ReqCh, this->Req, - a->IdTypeTable[this->No]); - this->More |=XMOREF; - a->ram_out(a, &ReqOut->Req, this->Req); - more = false; - if (a->FlowControlIdTable[this->ReqCh] == this->Id) - a->FlowControlSkipTable[this->ReqCh] = true; - /* - Note that remove request was sent to the card - */ - if (this->Req == REMOVE) { - a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_REMOVE_PENDING; - } - } - /* if we did chaining, this entity is put back into the */ - /* request queue */ - if(more) { - req_queue(a,this->No); - } - } - /* else it's a ASSIGN */ - else { - /* save the request code used for buffer chaining */ - this->MInd = 0; - if (this->Id==BLLC_ID) this->MInd = LL_MDATA; - if (this->Id==NL_ID || - this->Id==TASK_ID || - this->Id==MAN_ID - ) this->MInd = N_MDATA; - /* send the ASSIGN */ - a->IdTypeTable[this->No] = this->Id; - xdi_xlog_request (XDI_A_NR(a),this->Id,this->ReqCh,this->Req, this->Id); - this->More |=XMOREF; - a->ram_out(a, &ReqOut->Req, this->Req); - /* save the reference of the ASSIGN */ - assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference)); - } - a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next)); - ReadyCount--; - ReqCount++; - e_no = look_req(a); - } - /* send the filled request buffers to the ISDN adapter */ - a->ram_out(a, &PR_RAM->ReqInput, - (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount)); - /* if it is a 'unreturncoded' UREMOVE request, remove the */ - /* Id from our table after sending the request */ - if(this && (this->Req==UREMOVE) && this->Id) { - Id = this->Id; - e_no = a->IdTable[Id]; - free_entity(a, e_no); - for (i = 0; i < 256; i++) - { - if (a->FlowControlIdTable[i] == Id) - a->FlowControlIdTable[i] = 0; - } - a->IdTable[Id] = 0; - this->Id = 0; - } + a->ram_outw(a, &ReqOut->XBuffer.length, length); + a->ram_out(a, &ReqOut->ReqId, this->Id); + a->ram_out(a, &ReqOut->ReqCh, this->ReqCh); + /* if it's a specific request (no ASSIGN) ... */ + if (this->Id & 0x1f) { + /* if buffers are left in the list of data buffers do */ + /* do chaining (LL_MDATA, N_MDATA) */ + this->More++; + if (i < this->XNum && this->MInd) { + xdi_xlog_request(XDI_A_NR(a), this->Id, this->ReqCh, this->MInd, + a->IdTypeTable[this->No]); + a->ram_out(a, &ReqOut->Req, this->MInd); + more = true; + } + else { + xdi_xlog_request(XDI_A_NR(a), this->Id, this->ReqCh, this->Req, + a->IdTypeTable[this->No]); + this->More |= XMOREF; + a->ram_out(a, &ReqOut->Req, this->Req); + more = false; + if (a->FlowControlIdTable[this->ReqCh] == this->Id) + a->FlowControlSkipTable[this->ReqCh] = true; + /* + Note that remove request was sent to the card + */ + if (this->Req == REMOVE) { + a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_REMOVE_PENDING; + } + } + /* if we did chaining, this entity is put back into the */ + /* request queue */ + if (more) { + req_queue(a, this->No); + } + } + /* else it's a ASSIGN */ + else { + /* save the request code used for buffer chaining */ + this->MInd = 0; + if (this->Id == BLLC_ID) this->MInd = LL_MDATA; + if (this->Id == NL_ID || + this->Id == TASK_ID || + this->Id == MAN_ID + ) this->MInd = N_MDATA; + /* send the ASSIGN */ + a->IdTypeTable[this->No] = this->Id; + xdi_xlog_request(XDI_A_NR(a), this->Id, this->ReqCh, this->Req, this->Id); + this->More |= XMOREF; + a->ram_out(a, &ReqOut->Req, this->Req); + /* save the reference of the ASSIGN */ + assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference)); + } + a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next)); + ReadyCount--; + ReqCount++; + e_no = look_req(a); + } + /* send the filled request buffers to the ISDN adapter */ + a->ram_out(a, &PR_RAM->ReqInput, + (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount)); + /* if it is a 'unreturncoded' UREMOVE request, remove the */ + /* Id from our table after sending the request */ + if (this && (this->Req == UREMOVE) && this->Id) { + Id = this->Id; + e_no = a->IdTable[Id]; + free_entity(a, e_no); + for (i = 0; i < 256; i++) + { + if (a->FlowControlIdTable[i] == Id) + a->FlowControlIdTable[i] = 0; + } + a->IdTable[Id] = 0; + this->Id = 0; + } } -static byte pr_ready(ADAPTER * a) +static byte pr_ready(ADAPTER *a) { - byte ReadyCount; - ReadyCount = (byte)(a->ram_in(a, &PR_RAM->ReqOutput) - - a->ram_in(a, &PR_RAM->ReqInput)); - if(!ReadyCount) { - if(!a->ReadyInt) { - a->ram_inc(a, &PR_RAM->ReadyInt); - a->ReadyInt++; - } - } - return ReadyCount; + byte ReadyCount; + ReadyCount = (byte)(a->ram_in(a, &PR_RAM->ReqOutput) - + a->ram_in(a, &PR_RAM->ReqInput)); + if (!ReadyCount) { + if (!a->ReadyInt) { + a->ram_inc(a, &PR_RAM->ReadyInt); + a->ReadyInt++; + } + } + return ReadyCount; } /*------------------------------------------------------------------*/ /* isdn interrupt handler */ /*------------------------------------------------------------------*/ -byte pr_dpc(ADAPTER * a) +byte pr_dpc(ADAPTER *a) { - byte Count; - RC * RcIn; - IND * IndIn; - byte c; - byte RNRId; - byte Rc; - byte Ind; - /* if return codes are available ... */ - if((Count = a->ram_in(a, &PR_RAM->RcOutput)) != 0) { - dtrc(dprintf("#Rc=%x",Count)); - /* get the buffer address of the first return code */ - RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextRc)]; - /* for all return codes do ... */ - while(Count--) { - if((Rc=a->ram_in(a, &RcIn->Rc)) != 0) { - dword tmp[2]; - /* - Get extended information, associated with return code - */ - a->ram_in_buffer(a, - &RcIn->Reserved2[0], - (byte*)&tmp[0], - 8); - /* call return code handler, if it is not our return code */ - /* the handler returns 2 */ - /* for all return codes we process, we clear the Rc field */ - isdn_rc(a, - Rc, - a->ram_in(a, &RcIn->RcId), - a->ram_in(a, &RcIn->RcCh), - a->ram_inw(a, &RcIn->Reference), - tmp[0], /* type of extended information */ - tmp[1]); /* extended information */ - a->ram_out(a, &RcIn->Rc, 0); - } - /* get buffer address of next return code */ - RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &RcIn->next)]; - } - /* clear all return codes (no chaining!) */ - a->ram_out(a, &PR_RAM->RcOutput ,0); - /* call output function */ - pr_out(a); - } - /* clear RNR flag */ - RNRId = 0; - /* if indications are available ... */ - if((Count = a->ram_in(a, &PR_RAM->IndOutput)) != 0) { - dtrc(dprintf("#Ind=%x",Count)); - /* get the buffer address of the first indication */ - IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextInd)]; - /* for all indications do ... */ - while(Count--) { - /* if the application marks an indication as RNR, all */ - /* indications from the same Id delivered in this interrupt */ - /* are marked RNR */ - if(RNRId && RNRId==a->ram_in(a, &IndIn->IndId)) { - a->ram_out(a, &IndIn->Ind, 0); - a->ram_out(a, &IndIn->RNR, true); - } - else { - Ind = a->ram_in(a, &IndIn->Ind); - if(Ind) { - RNRId = 0; - /* call indication handler, a return value of 2 means chain */ - /* a return value of 1 means RNR */ - /* for all indications we process, we clear the Ind field */ - c = isdn_ind(a, - Ind, - a->ram_in(a, &IndIn->IndId), - a->ram_in(a, &IndIn->IndCh), - &IndIn->RBuffer, - a->ram_in(a, &IndIn->MInd), - a->ram_inw(a, &IndIn->MLength)); - if(c==1) { - dtrc(dprintf("RNR")); - a->ram_out(a, &IndIn->Ind, 0); - RNRId = a->ram_in(a, &IndIn->IndId); - a->ram_out(a, &IndIn->RNR, true); - } - } - } - /* get buffer address of next indication */ - IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &IndIn->next)]; - } - a->ram_out(a, &PR_RAM->IndOutput, 0); - } - return false; + byte Count; + RC *RcIn; + IND *IndIn; + byte c; + byte RNRId; + byte Rc; + byte Ind; + /* if return codes are available ... */ + if ((Count = a->ram_in(a, &PR_RAM->RcOutput)) != 0) { + dtrc(dprintf("#Rc=%x", Count)); + /* get the buffer address of the first return code */ + RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextRc)]; + /* for all return codes do ... */ + while (Count--) { + if ((Rc = a->ram_in(a, &RcIn->Rc)) != 0) { + dword tmp[2]; + /* + Get extended information, associated with return code + */ + a->ram_in_buffer(a, + &RcIn->Reserved2[0], + (byte *)&tmp[0], + 8); + /* call return code handler, if it is not our return code */ + /* the handler returns 2 */ + /* for all return codes we process, we clear the Rc field */ + isdn_rc(a, + Rc, + a->ram_in(a, &RcIn->RcId), + a->ram_in(a, &RcIn->RcCh), + a->ram_inw(a, &RcIn->Reference), + tmp[0], /* type of extended information */ + tmp[1]); /* extended information */ + a->ram_out(a, &RcIn->Rc, 0); + } + /* get buffer address of next return code */ + RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &RcIn->next)]; + } + /* clear all return codes (no chaining!) */ + a->ram_out(a, &PR_RAM->RcOutput, 0); + /* call output function */ + pr_out(a); + } + /* clear RNR flag */ + RNRId = 0; + /* if indications are available ... */ + if ((Count = a->ram_in(a, &PR_RAM->IndOutput)) != 0) { + dtrc(dprintf("#Ind=%x", Count)); + /* get the buffer address of the first indication */ + IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextInd)]; + /* for all indications do ... */ + while (Count--) { + /* if the application marks an indication as RNR, all */ + /* indications from the same Id delivered in this interrupt */ + /* are marked RNR */ + if (RNRId && RNRId == a->ram_in(a, &IndIn->IndId)) { + a->ram_out(a, &IndIn->Ind, 0); + a->ram_out(a, &IndIn->RNR, true); + } + else { + Ind = a->ram_in(a, &IndIn->Ind); + if (Ind) { + RNRId = 0; + /* call indication handler, a return value of 2 means chain */ + /* a return value of 1 means RNR */ + /* for all indications we process, we clear the Ind field */ + c = isdn_ind(a, + Ind, + a->ram_in(a, &IndIn->IndId), + a->ram_in(a, &IndIn->IndCh), + &IndIn->RBuffer, + a->ram_in(a, &IndIn->MInd), + a->ram_inw(a, &IndIn->MLength)); + if (c == 1) { + dtrc(dprintf("RNR")); + a->ram_out(a, &IndIn->Ind, 0); + RNRId = a->ram_in(a, &IndIn->IndId); + a->ram_out(a, &IndIn->RNR, true); + } + } + } + /* get buffer address of next indication */ + IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &IndIn->next)]; + } + a->ram_out(a, &PR_RAM->IndOutput, 0); + } + return false; } -byte scom_test_int(ADAPTER * a) +byte scom_test_int(ADAPTER *a) { - return a->ram_in(a,(void *)0x3fe); + return a->ram_in(a, (void *)0x3fe); } -void scom_clear_int(ADAPTER * a) +void scom_clear_int(ADAPTER *a) { - a->ram_out(a,(void *)0x3fe,0); + a->ram_out(a, (void *)0x3fe, 0); } /*------------------------------------------------------------------*/ /* return code handler */ @@ -361,196 +361,196 @@ static byte isdn_rc(ADAPTER *a, dword extended_info_type, dword extended_info) { - ENTITY * this; - byte e_no; - word i; - int cancel_rc; + ENTITY *this; + byte e_no; + word i; + int cancel_rc; #ifdef USE_EXTENDED_DEBUGS - { - DBG_TRC(("io)->ANum, Id, Rc)) - } + { + DBG_TRC(("io)->ANum, Id, Rc)) + } #else - dbug(dprintf("isdn_rc(Rc=%x,Id=%x,Ch=%x)",Rc,Id,Ch)); + dbug(dprintf("isdn_rc(Rc=%x,Id=%x,Ch=%x)", Rc, Id, Ch)); #endif - /* check for ready interrupt */ - if(Rc==READY_INT) { - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 0, 0); - if(a->ReadyInt) { - a->ReadyInt--; - return 0; - } - return 2; - } - /* if we know this Id ... */ - e_no = a->IdTable[Id]; - if(e_no) { - this = entity_ptr(a,e_no); - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 0, a->IdTypeTable[this->No]); - this->RcCh = Ch; - /* if it is a return code to a REMOVE request, remove the */ - /* Id from our table */ - if ((a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_REMOVE_PENDING) && - (Rc==OK)) { - if (a->IdTypeTable[e_no] == NL_ID) { - if (a->RcExtensionSupported && - (extended_info_type != DIVA_RC_TYPE_REMOVE_COMPLETE)) { - dtrc(dprintf("XDI: N-REMOVE, A(%02x) Id:%02x, ignore RC=OK", - XDI_A_NR(a),Id)); - return (0); - } - if (extended_info_type == DIVA_RC_TYPE_REMOVE_COMPLETE) - a->RcExtensionSupported = true; - } - a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_REMOVE_PENDING; - a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_NO_RC_CANCELLING; - free_entity(a, e_no); - for (i = 0; i < 256; i++) - { - if (a->FlowControlIdTable[i] == Id) - a->FlowControlIdTable[i] = 0; - } - a->IdTable[Id] = 0; - this->Id = 0; - /* --------------------------------------------------------------- - If we send N_DISC or N_DISK_ACK after we have received OK_FC - then the card will respond with OK_FC and later with RC==OK. - If we send N_REMOVE in this state we will receive only RC==OK - This will create the state in that the XDI is waiting for the - additional RC and does not delivery the RC to the client. This - code corrects the counter of outstanding RC's in this case. - --------------------------------------------------------------- */ - if ((this->More & XMOREC) > 1) { - this->More &= ~XMOREC; - this->More |= 1; - dtrc(dprintf("XDI: correct MORE on REMOVE A(%02x) Id:%02x", - XDI_A_NR(a),Id)); - } - } - if (Rc==OK_FC) { - a->FlowControlIdTable[Ch] = Id; - a->FlowControlSkipTable[Ch] = false; - this->Rc = Rc; - this->More &= ~(XBUSY | XMOREC); - this->complete=0xff; - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); - CALLBACK(a, this); - return 0; - } - /* - New protocol code sends return codes that comes from release - of flow control condition marked with DIVA_RC_TYPE_OK_FC extended - information element type. - If like return code arrives then application is able to process - all return codes self and XDI should not cances return codes. - This return code does not decrement XMOREC partial return code - counter due to fact that it was no request for this return code, - also XMOREC was not incremented. - */ - if (extended_info_type == DIVA_RC_TYPE_OK_FC) { - a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_NO_RC_CANCELLING; - this->Rc = Rc; - this->complete=0xff; - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); - DBG_TRC(("XDI OK_FC A(%02x) Id:%02x Ch:%02x Rc:%02x", - XDI_A_NR(a), Id, Ch, Rc)) - CALLBACK(a, this); - return 0; - } - cancel_rc = !(a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_NO_RC_CANCELLING); - if (cancel_rc && (a->FlowControlIdTable[Ch] == Id)) - { - a->FlowControlIdTable[Ch] = 0; - if ((Rc != OK) || !a->FlowControlSkipTable[Ch]) - { - this->Rc = Rc; - if (Ch == this->ReqCh) - { - this->More &=~(XBUSY | XMOREC); - this->complete=0xff; - } - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); - CALLBACK(a, this); - } - return 0; - } - if (this->More &XMOREC) - this->More--; - /* call the application callback function */ - if (((!cancel_rc) || (this->More & XMOREF)) && !(this->More & XMOREC)) { - this->Rc = Rc; - this->More &=~XBUSY; - this->complete=0xff; - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); - CALLBACK(a, this); - } - return 0; - } - /* if it's an ASSIGN return code check if it's a return */ - /* code to an ASSIGN request from us */ - if((Rc &0xf0)==ASSIGN_RC) { - e_no = get_assign(a, Ref); - if(e_no) { - this = entity_ptr(a,e_no); - this->Id = Id; - xdi_xlog_rc_event (XDI_A_NR(a), Id, Ch, Rc, 2, a->IdTypeTable[this->No]); - /* call the application callback function */ - this->Rc = Rc; - this->More &=~XBUSY; - this->complete=0xff; + /* check for ready interrupt */ + if (Rc == READY_INT) { + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 0, 0); + if (a->ReadyInt) { + a->ReadyInt--; + return 0; + } + return 2; + } + /* if we know this Id ... */ + e_no = a->IdTable[Id]; + if (e_no) { + this = entity_ptr(a, e_no); + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 0, a->IdTypeTable[this->No]); + this->RcCh = Ch; + /* if it is a return code to a REMOVE request, remove the */ + /* Id from our table */ + if ((a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_REMOVE_PENDING) && + (Rc == OK)) { + if (a->IdTypeTable[e_no] == NL_ID) { + if (a->RcExtensionSupported && + (extended_info_type != DIVA_RC_TYPE_REMOVE_COMPLETE)) { + dtrc(dprintf("XDI: N-REMOVE, A(%02x) Id:%02x, ignore RC=OK", + XDI_A_NR(a), Id)); + return (0); + } + if (extended_info_type == DIVA_RC_TYPE_REMOVE_COMPLETE) + a->RcExtensionSupported = true; + } + a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_REMOVE_PENDING; + a->misc_flags_table[e_no] &= ~DIVA_MISC_FLAGS_NO_RC_CANCELLING; + free_entity(a, e_no); + for (i = 0; i < 256; i++) + { + if (a->FlowControlIdTable[i] == Id) + a->FlowControlIdTable[i] = 0; + } + a->IdTable[Id] = 0; + this->Id = 0; + /* --------------------------------------------------------------- + If we send N_DISC or N_DISK_ACK after we have received OK_FC + then the card will respond with OK_FC and later with RC==OK. + If we send N_REMOVE in this state we will receive only RC==OK + This will create the state in that the XDI is waiting for the + additional RC and does not delivery the RC to the client. This + code corrects the counter of outstanding RC's in this case. + --------------------------------------------------------------- */ + if ((this->More & XMOREC) > 1) { + this->More &= ~XMOREC; + this->More |= 1; + dtrc(dprintf("XDI: correct MORE on REMOVE A(%02x) Id:%02x", + XDI_A_NR(a), Id)); + } + } + if (Rc == OK_FC) { + a->FlowControlIdTable[Ch] = Id; + a->FlowControlSkipTable[Ch] = false; + this->Rc = Rc; + this->More &= ~(XBUSY | XMOREC); + this->complete = 0xff; + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); + CALLBACK(a, this); + return 0; + } + /* + New protocol code sends return codes that comes from release + of flow control condition marked with DIVA_RC_TYPE_OK_FC extended + information element type. + If like return code arrives then application is able to process + all return codes self and XDI should not cances return codes. + This return code does not decrement XMOREC partial return code + counter due to fact that it was no request for this return code, + also XMOREC was not incremented. + */ + if (extended_info_type == DIVA_RC_TYPE_OK_FC) { + a->misc_flags_table[e_no] |= DIVA_MISC_FLAGS_NO_RC_CANCELLING; + this->Rc = Rc; + this->complete = 0xff; + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); + DBG_TRC(("XDI OK_FC A(%02x) Id:%02x Ch:%02x Rc:%02x", + XDI_A_NR(a), Id, Ch, Rc)) + CALLBACK(a, this); + return 0; + } + cancel_rc = !(a->misc_flags_table[e_no] & DIVA_MISC_FLAGS_NO_RC_CANCELLING); + if (cancel_rc && (a->FlowControlIdTable[Ch] == Id)) + { + a->FlowControlIdTable[Ch] = 0; + if ((Rc != OK) || !a->FlowControlSkipTable[Ch]) + { + this->Rc = Rc; + if (Ch == this->ReqCh) + { + this->More &= ~(XBUSY | XMOREC); + this->complete = 0xff; + } + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); + CALLBACK(a, this); + } + return 0; + } + if (this->More & XMOREC) + this->More--; + /* call the application callback function */ + if (((!cancel_rc) || (this->More & XMOREF)) && !(this->More & XMOREC)) { + this->Rc = Rc; + this->More &= ~XBUSY; + this->complete = 0xff; + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 1, a->IdTypeTable[this->No]); + CALLBACK(a, this); + } + return 0; + } + /* if it's an ASSIGN return code check if it's a return */ + /* code to an ASSIGN request from us */ + if ((Rc & 0xf0) == ASSIGN_RC) { + e_no = get_assign(a, Ref); + if (e_no) { + this = entity_ptr(a, e_no); + this->Id = Id; + xdi_xlog_rc_event(XDI_A_NR(a), Id, Ch, Rc, 2, a->IdTypeTable[this->No]); + /* call the application callback function */ + this->Rc = Rc; + this->More &= ~XBUSY; + this->complete = 0xff; #if defined(DIVA_ISTREAM) /* { */ - if ((Rc == ASSIGN_OK) && a->ram_offset && - (a->IdTypeTable[this->No] == NL_ID) && - ((extended_info_type == DIVA_RC_TYPE_RX_DMA) || - (extended_info_type == DIVA_RC_TYPE_CMA_PTR)) && - extended_info) { - dword offset = (*(a->ram_offset)) (a); - dword tmp[2]; - extended_info -= offset; + if ((Rc == ASSIGN_OK) && a->ram_offset && + (a->IdTypeTable[this->No] == NL_ID) && + ((extended_info_type == DIVA_RC_TYPE_RX_DMA) || + (extended_info_type == DIVA_RC_TYPE_CMA_PTR)) && + extended_info) { + dword offset = (*(a->ram_offset)) (a); + dword tmp[2]; + extended_info -= offset; #ifdef PLATFORM_GT_32BIT - a->ram_in_dw(a, (void*)ULongToPtr(extended_info), (dword*)&tmp[0], 2); + a->ram_in_dw(a, (void *)ULongToPtr(extended_info), (dword *)&tmp[0], 2); #else - a->ram_in_dw(a, (void*)extended_info, (dword*)&tmp[0], 2); + a->ram_in_dw(a, (void *)extended_info, (dword *)&tmp[0], 2); #endif - a->tx_stream[Id] = tmp[0]; - a->rx_stream[Id] = tmp[1]; - if (extended_info_type == DIVA_RC_TYPE_RX_DMA) { - DBG_TRC(("Id=0x%x RxDMA=%08x:%08x", - Id, a->tx_stream[Id], a->rx_stream[Id])) - a->misc_flags_table[this->No] |= DIVA_MISC_FLAGS_RX_DMA; - } else { - DBG_TRC(("Id=0x%x CMA=%08x:%08x", - Id, a->tx_stream[Id], a->rx_stream[Id])) - a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA; - a->rx_pos[Id] = 0; - a->rx_stream[Id] -= offset; - } - a->tx_pos[Id] = 0; - a->tx_stream[Id] -= offset; - } else { - a->tx_stream[Id] = 0; - a->rx_stream[Id] = 0; - a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA; - } + a->tx_stream[Id] = tmp[0]; + a->rx_stream[Id] = tmp[1]; + if (extended_info_type == DIVA_RC_TYPE_RX_DMA) { + DBG_TRC(("Id=0x%x RxDMA=%08x:%08x", + Id, a->tx_stream[Id], a->rx_stream[Id])) + a->misc_flags_table[this->No] |= DIVA_MISC_FLAGS_RX_DMA; + } else { + DBG_TRC(("Id=0x%x CMA=%08x:%08x", + Id, a->tx_stream[Id], a->rx_stream[Id])) + a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA; + a->rx_pos[Id] = 0; + a->rx_stream[Id] -= offset; + } + a->tx_pos[Id] = 0; + a->tx_stream[Id] -= offset; + } else { + a->tx_stream[Id] = 0; + a->rx_stream[Id] = 0; + a->misc_flags_table[this->No] &= ~DIVA_MISC_FLAGS_RX_DMA; + } #endif /* } */ - CALLBACK(a, this); - if(Rc==ASSIGN_OK) { - a->IdTable[Id] = e_no; - } - else - { - free_entity(a, e_no); - for (i = 0; i < 256; i++) - { - if (a->FlowControlIdTable[i] == Id) - a->FlowControlIdTable[i] = 0; - } - a->IdTable[Id] = 0; - this->Id = 0; - } - return 1; - } - } - return 2; + CALLBACK(a, this); + if (Rc == ASSIGN_OK) { + a->IdTable[Id] = e_no; + } + else + { + free_entity(a, e_no); + for (i = 0; i < 256; i++) + { + if (a->FlowControlIdTable[i] == Id) + a->FlowControlIdTable[i] = 0; + } + a->IdTable[Id] = 0; + this->Id = 0; + } + return 1; + } + } + return 2; } /*------------------------------------------------------------------*/ /* indication handler */ @@ -563,273 +563,273 @@ static byte isdn_ind(ADAPTER *a, byte MInd, word MLength) { - ENTITY * this; - word clength; - word offset; - BUFFERS *R; - byte* cma = NULL; + ENTITY *this; + word clength; + word offset; + BUFFERS *R; + byte *cma = NULL; #ifdef USE_EXTENDED_DEBUGS - { - DBG_TRC(("io)->ANum, Id, Ind)) - } + { + DBG_TRC(("io)->ANum, Id, Ind)) + } #else - dbug(dprintf("isdn_ind(Ind=%x,Id=%x,Ch=%x)",Ind,Id,Ch)); + dbug(dprintf("isdn_ind(Ind=%x,Id=%x,Ch=%x)", Ind, Id, Ch)); #endif - if(a->IdTable[Id]) { - this = entity_ptr(a,a->IdTable[Id]); - this->IndCh = Ch; - xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, - 0/* rnr_valid */, 0 /* rnr */, a->IdTypeTable[this->No]); - /* if the Receive More flag is not yet set, this is the */ - /* first buffer of the packet */ - if(this->RCurrent==0xff) { - /* check for receive buffer chaining */ - if(Ind==this->MInd) { - this->complete = 0; - this->Ind = MInd; - } - else { - this->complete = 1; - this->Ind = Ind; - } - /* call the application callback function for the receive */ - /* look ahead */ - this->RLength = MLength; + if (a->IdTable[Id]) { + this = entity_ptr(a, a->IdTable[Id]); + this->IndCh = Ch; + xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind, + 0/* rnr_valid */, 0 /* rnr */, a->IdTypeTable[this->No]); + /* if the Receive More flag is not yet set, this is the */ + /* first buffer of the packet */ + if (this->RCurrent == 0xff) { + /* check for receive buffer chaining */ + if (Ind == this->MInd) { + this->complete = 0; + this->Ind = MInd; + } + else { + this->complete = 1; + this->Ind = Ind; + } + /* call the application callback function for the receive */ + /* look ahead */ + this->RLength = MLength; #if defined(DIVA_ISTREAM) - if ((a->rx_stream[this->Id] || - (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA)) && - ((Ind == N_DATA) || - (a->protocol_capabilities & PROTCAP_CMA_ALLPR))) { - PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io ; - if (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA) { + if ((a->rx_stream[this->Id] || + (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA)) && + ((Ind == N_DATA) || + (a->protocol_capabilities & PROTCAP_CMA_ALLPR))) { + PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io; + if (a->misc_flags_table[this->No] & DIVA_MISC_FLAGS_RX_DMA) { #if defined(DIVA_IDI_RX_DMA) - dword d; - diva_get_dma_map_entry (\ - (struct _diva_dma_map_entry*)IoAdapter->dma_map, - (int)a->rx_stream[this->Id], (void**)&cma, &d); + dword d; + diva_get_dma_map_entry(\ + (struct _diva_dma_map_entry *)IoAdapter->dma_map, + (int)a->rx_stream[this->Id], (void **)&cma, &d); #else - cma = &a->stream_buffer[0]; - cma[0] = cma[1] = cma[2] = cma[3] = 0; + cma = &a->stream_buffer[0]; + cma[0] = cma[1] = cma[2] = cma[3] = 0; #endif - this->RLength = MLength = (word)*(dword*)cma; - cma += 4; - } else { - int final = 0; - cma = &a->stream_buffer[0]; - this->RLength = MLength = (word)diva_istream_read (a, - Id, - cma, - sizeof(a->stream_buffer), - &final, NULL, NULL); - } - IoAdapter->RBuffer.length = min(MLength, (word)270); - if (IoAdapter->RBuffer.length != MLength) { - this->complete = 0; - } else { - this->complete = 1; - } - memcpy (IoAdapter->RBuffer.P, cma, IoAdapter->RBuffer.length) ; - this->RBuffer = (DBUFFER *)&IoAdapter->RBuffer ; - } + this->RLength = MLength = (word)*(dword *)cma; + cma += 4; + } else { + int final = 0; + cma = &a->stream_buffer[0]; + this->RLength = MLength = (word)diva_istream_read(a, + Id, + cma, + sizeof(a->stream_buffer), + &final, NULL, NULL); + } + IoAdapter->RBuffer.length = min(MLength, (word)270); + if (IoAdapter->RBuffer.length != MLength) { + this->complete = 0; + } else { + this->complete = 1; + } + memcpy(IoAdapter->RBuffer.P, cma, IoAdapter->RBuffer.length); + this->RBuffer = (DBUFFER *)&IoAdapter->RBuffer; + } #endif - if (!cma) { - a->ram_look_ahead(a, RBuffer, this); - } - this->RNum = 0; - CALLBACK(a, this); - /* map entity ptr, selector could be re-mapped by call to */ - /* IDI from within callback */ - this = entity_ptr(a,a->IdTable[Id]); - xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, - 1/* rnr_valid */, this->RNR/* rnr */, a->IdTypeTable[this->No]); - /* check for RNR */ - if(this->RNR==1) { - this->RNR = 0; - return 1; - } - /* if no buffers are provided by the application, the */ - /* application want to copy the data itself including */ - /* N_MDATA/LL_MDATA chaining */ - if(!this->RNR && !this->RNum) { - xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, - 2/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]); - return 0; - } - /* if there is no RNR, set the More flag */ - this->RCurrent = 0; - this->ROffset = 0; - } - if(this->RNR==2) { - if(Ind!=this->MInd) { - this->RCurrent = 0xff; - this->RNR = 0; - } - return 0; - } - /* if we have received buffers from the application, copy */ - /* the data into these buffers */ - offset = 0; - R = PTR_R(a,this); - do { - if(this->ROffset==R[this->RCurrent].PLength) { - this->ROffset = 0; - this->RCurrent++; - } - if (cma) { - clength = min(MLength, (word)(R[this->RCurrent].PLength-this->ROffset)); - } else { - clength = min(a->ram_inw(a, &RBuffer->length)-offset, - R[this->RCurrent].PLength-this->ROffset); - } - if(R[this->RCurrent].P) { - if (cma) { - memcpy (PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]), - &cma[offset], - clength); - } else { - a->ram_in_buffer(a, - &RBuffer->P[offset], - PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]), - clength); - } - } - offset +=clength; - this->ROffset +=clength; - if (cma) { - if (offset >= MLength) { - break; - } - continue; - } - } while(offset<(a->ram_inw(a, &RBuffer->length))); - /* if it's the last buffer of the packet, call the */ - /* application callback function for the receive complete */ - /* call */ - if(Ind!=this->MInd) { - R[this->RCurrent].PLength = this->ROffset; - if(this->ROffset) this->RCurrent++; - this->RNum = this->RCurrent; - this->RCurrent = 0xff; - this->Ind = Ind; - this->complete = 2; - xdi_xlog_ind (XDI_A_NR(a), Id, Ch, Ind, - 3/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]); - CALLBACK(a, this); - } - return 0; - } - return 2; + if (!cma) { + a->ram_look_ahead(a, RBuffer, this); + } + this->RNum = 0; + CALLBACK(a, this); + /* map entity ptr, selector could be re-mapped by call to */ + /* IDI from within callback */ + this = entity_ptr(a, a->IdTable[Id]); + xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind, + 1/* rnr_valid */, this->RNR/* rnr */, a->IdTypeTable[this->No]); + /* check for RNR */ + if (this->RNR == 1) { + this->RNR = 0; + return 1; + } + /* if no buffers are provided by the application, the */ + /* application want to copy the data itself including */ + /* N_MDATA/LL_MDATA chaining */ + if (!this->RNR && !this->RNum) { + xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind, + 2/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]); + return 0; + } + /* if there is no RNR, set the More flag */ + this->RCurrent = 0; + this->ROffset = 0; + } + if (this->RNR == 2) { + if (Ind != this->MInd) { + this->RCurrent = 0xff; + this->RNR = 0; + } + return 0; + } + /* if we have received buffers from the application, copy */ + /* the data into these buffers */ + offset = 0; + R = PTR_R(a, this); + do { + if (this->ROffset == R[this->RCurrent].PLength) { + this->ROffset = 0; + this->RCurrent++; + } + if (cma) { + clength = min(MLength, (word)(R[this->RCurrent].PLength-this->ROffset)); + } else { + clength = min(a->ram_inw(a, &RBuffer->length)-offset, + R[this->RCurrent].PLength-this->ROffset); + } + if (R[this->RCurrent].P) { + if (cma) { + memcpy(PTR_P(a, this, &R[this->RCurrent].P[this->ROffset]), + &cma[offset], + clength); + } else { + a->ram_in_buffer(a, + &RBuffer->P[offset], + PTR_P(a, this, &R[this->RCurrent].P[this->ROffset]), + clength); + } + } + offset += clength; + this->ROffset += clength; + if (cma) { + if (offset >= MLength) { + break; + } + continue; + } + } while (offset < (a->ram_inw(a, &RBuffer->length))); + /* if it's the last buffer of the packet, call the */ + /* application callback function for the receive complete */ + /* call */ + if (Ind != this->MInd) { + R[this->RCurrent].PLength = this->ROffset; + if (this->ROffset) this->RCurrent++; + this->RNum = this->RCurrent; + this->RCurrent = 0xff; + this->Ind = Ind; + this->complete = 2; + xdi_xlog_ind(XDI_A_NR(a), Id, Ch, Ind, + 3/* rnr_valid */, 0/* rnr */, a->IdTypeTable[this->No]); + CALLBACK(a, this); + } + return 0; + } + return 2; } #if defined(XDI_USE_XLOG) /* ----------------------------------------------------------- This function works in the same way as xlog on the active board ----------------------------------------------------------- */ -static void xdi_xlog (byte *msg, word code, int length) { - xdi_dbg_xlog ("\x00\x02", msg, code, length); +static void xdi_xlog(byte *msg, word code, int length) { + xdi_dbg_xlog("\x00\x02", msg, code, length); } #endif /* ----------------------------------------------------------- - This function writes the information about the Return Code - processing in the trace buffer. Trace ID is 221. - INPUT: - Adapter - system unicue adapter number (0 ... 255) - Id - Id of the entity that had sent this return code - Ch - Channel of the entity that had sent this return code - Rc - return code value - cb: (0...2) - switch (cb) { - case 0: printf ("DELIVERY"); break; - case 1: printf ("CALLBACK"); break; - case 2: printf ("ASSIGN"); break; - } - DELIVERY - have entered isdn_rc with this RC - CALLBACK - about to make callback to the application - for this RC - ASSIGN - about to make callback for RC that is result - of ASSIGN request. It is no DELIVERY message - before of this message - type - the Id that was sent by the ASSIGN of this entity. - This should be global Id like NL_ID, DSIG_ID, MAN_ID. - An unknown Id will cause "?-" in the front of the request. - In this case the log.c is to be extended. + This function writes the information about the Return Code + processing in the trace buffer. Trace ID is 221. + INPUT: + Adapter - system unicue adapter number (0 ... 255) + Id - Id of the entity that had sent this return code + Ch - Channel of the entity that had sent this return code + Rc - return code value + cb: (0...2) + switch (cb) { + case 0: printf ("DELIVERY"); break; + case 1: printf ("CALLBACK"); break; + case 2: printf ("ASSIGN"); break; + } + DELIVERY - have entered isdn_rc with this RC + CALLBACK - about to make callback to the application + for this RC + ASSIGN - about to make callback for RC that is result + of ASSIGN request. It is no DELIVERY message + before of this message + type - the Id that was sent by the ASSIGN of this entity. + This should be global Id like NL_ID, DSIG_ID, MAN_ID. + An unknown Id will cause "?-" in the front of the request. + In this case the log.c is to be extended. ----------------------------------------------------------- */ -static void xdi_xlog_rc_event (byte Adapter, - byte Id, byte Ch, byte Rc, byte cb, byte type) { +static void xdi_xlog_rc_event(byte Adapter, + byte Id, byte Ch, byte Rc, byte cb, byte type) { #if defined(XDI_USE_XLOG) - word LogInfo[4]; - PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); - PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); - PUT_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8))); - PUT_WORD(&LogInfo[3], cb); - xdi_xlog ((byte*)&LogInfo[0], 221, sizeof(LogInfo)); + word LogInfo[4]; + PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); + PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); + PUT_WORD(&LogInfo[2], ((word)Rc | (word)(type << 8))); + PUT_WORD(&LogInfo[3], cb); + xdi_xlog((byte *)&LogInfo[0], 221, sizeof(LogInfo)); #endif } /* ------------------------------------------------------------------------ - This function writes the information about the request processing - in the trace buffer. Trace ID is 220. - INPUT: - Adapter - system unicue adapter number (0 ... 255) - Id - Id of the entity that had sent this request - Ch - Channel of the entity that had sent this request - Req - Code of the request - type - the Id that was sent by the ASSIGN of this entity. - This should be global Id like NL_ID, DSIG_ID, MAN_ID. - An unknown Id will cause "?-" in the front of the request. - In this case the log.c is to be extended. + This function writes the information about the request processing + in the trace buffer. Trace ID is 220. + INPUT: + Adapter - system unicue adapter number (0 ... 255) + Id - Id of the entity that had sent this request + Ch - Channel of the entity that had sent this request + Req - Code of the request + type - the Id that was sent by the ASSIGN of this entity. + This should be global Id like NL_ID, DSIG_ID, MAN_ID. + An unknown Id will cause "?-" in the front of the request. + In this case the log.c is to be extended. ------------------------------------------------------------------------ */ -static void xdi_xlog_request (byte Adapter, byte Id, - byte Ch, byte Req, byte type) { +static void xdi_xlog_request(byte Adapter, byte Id, + byte Ch, byte Req, byte type) { #if defined(XDI_USE_XLOG) - word LogInfo[3]; - PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); - PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); - PUT_WORD(&LogInfo[2], ((word)Req | (word)(type << 8))); - xdi_xlog ((byte*)&LogInfo[0], 220, sizeof(LogInfo)); + word LogInfo[3]; + PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); + PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); + PUT_WORD(&LogInfo[2], ((word)Req | (word)(type << 8))); + xdi_xlog((byte *)&LogInfo[0], 220, sizeof(LogInfo)); #endif } /* ------------------------------------------------------------------------ - This function writes the information about the indication processing - in the trace buffer. Trace ID is 222. - INPUT: - Adapter - system unicue adapter number (0 ... 255) - Id - Id of the entity that had sent this indication - Ch - Channel of the entity that had sent this indication - Ind - Code of the indication - rnr_valid: (0 .. 3) supported - switch (rnr_valid) { - case 0: printf ("DELIVERY"); break; - case 1: printf ("RNR=%d", rnr); - case 2: printf ("RNum=0"); - case 3: printf ("COMPLETE"); - } - DELIVERY - indication entered isdn_rc function - RNR=... - application had returned RNR=... after the - look ahead callback - RNum=0 - application had not returned any buffer to copy - this indication and will copy it self - COMPLETE - XDI had copied the data to the buffers provided - bu the application and is about to issue the - final callback - rnr: Look case 1 of the rnr_valid - type: the Id that was sent by the ASSIGN of this entity. This should - be global Id like NL_ID, DSIG_ID, MAN_ID. An unknown Id will - cause "?-" in the front of the request. In this case the - log.c is to be extended. + This function writes the information about the indication processing + in the trace buffer. Trace ID is 222. + INPUT: + Adapter - system unicue adapter number (0 ... 255) + Id - Id of the entity that had sent this indication + Ch - Channel of the entity that had sent this indication + Ind - Code of the indication + rnr_valid: (0 .. 3) supported + switch (rnr_valid) { + case 0: printf ("DELIVERY"); break; + case 1: printf ("RNR=%d", rnr); + case 2: printf ("RNum=0"); + case 3: printf ("COMPLETE"); + } + DELIVERY - indication entered isdn_rc function + RNR=... - application had returned RNR=... after the + look ahead callback + RNum=0 - application had not returned any buffer to copy + this indication and will copy it self + COMPLETE - XDI had copied the data to the buffers provided + bu the application and is about to issue the + final callback + rnr: Look case 1 of the rnr_valid + type: the Id that was sent by the ASSIGN of this entity. This should + be global Id like NL_ID, DSIG_ID, MAN_ID. An unknown Id will + cause "?-" in the front of the request. In this case the + log.c is to be extended. ------------------------------------------------------------------------ */ -static void xdi_xlog_ind (byte Adapter, - byte Id, - byte Ch, - byte Ind, - byte rnr_valid, - byte rnr, - byte type) { +static void xdi_xlog_ind(byte Adapter, + byte Id, + byte Ch, + byte Ind, + byte rnr_valid, + byte rnr, + byte type) { #if defined(XDI_USE_XLOG) - word LogInfo[4]; - PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); - PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); - PUT_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8))); - PUT_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8))); - xdi_xlog ((byte*)&LogInfo[0], 222, sizeof(LogInfo)); + word LogInfo[4]; + PUT_WORD(&LogInfo[0], ((word)Adapter | (word)(xdi_xlog_sec++ << 8))); + PUT_WORD(&LogInfo[1], ((word)Id | (word)(Ch << 8))); + PUT_WORD(&LogInfo[2], ((word)Ind | (word)(type << 8))); + PUT_WORD(&LogInfo[3], ((word)rnr | (word)(rnr_valid << 8))); + xdi_xlog((byte *)&LogInfo[0], 222, sizeof(LogInfo)); #endif } diff --git a/drivers/isdn/hardware/eicon/di.h b/drivers/isdn/hardware/eicon/di.h index dcf37b10f5dc..ff26c65631d6 100644 --- a/drivers/isdn/hardware/eicon/di.h +++ b/drivers/isdn/hardware/eicon/di.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* @@ -35,83 +35,83 @@ #define DIVA_MISC_FLAGS_REMOVE_PENDING 0x01 #define DIVA_MISC_FLAGS_NO_RC_CANCELLING 0x02 #define DIVA_MISC_FLAGS_RX_DMA 0x04 - /* structure for all information we have to keep on a per */ - /* adapater basis */ +/* structure for all information we have to keep on a per */ +/* adapater basis */ typedef struct adapter_s ADAPTER; struct adapter_s { - void * io; - byte IdTable[256]; - byte IdTypeTable[256]; - byte FlowControlIdTable[256]; - byte FlowControlSkipTable[256]; - byte ReadyInt; - byte RcExtensionSupported; - byte misc_flags_table[256]; - dword protocol_capabilities; - byte ( * ram_in)(ADAPTER * a, void * adr); - word ( * ram_inw)(ADAPTER * a, void * adr); - void (* ram_in_buffer)(ADAPTER * a, void * adr, void * P, word length); - void (* ram_look_ahead)(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e); - void ( * ram_out)(ADAPTER * a, void * adr, byte data); - void ( * ram_outw)(ADAPTER * a, void * adr, word data); - void (* ram_out_buffer)(ADAPTER * a, void * adr, void * P, word length); - void ( * ram_inc)(ADAPTER * a, void * adr); + void *io; + byte IdTable[256]; + byte IdTypeTable[256]; + byte FlowControlIdTable[256]; + byte FlowControlSkipTable[256]; + byte ReadyInt; + byte RcExtensionSupported; + byte misc_flags_table[256]; + dword protocol_capabilities; + byte (*ram_in)(ADAPTER *a, void *adr); + word (*ram_inw)(ADAPTER *a, void *adr); + void (*ram_in_buffer)(ADAPTER *a, void *adr, void *P, word length); + void (*ram_look_ahead)(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e); + void (*ram_out)(ADAPTER *a, void *adr, byte data); + void (*ram_outw)(ADAPTER *a, void *adr, word data); + void (*ram_out_buffer)(ADAPTER *a, void *adr, void *P, word length); + void (*ram_inc)(ADAPTER *a, void *adr); #if defined(DIVA_ISTREAM) - dword rx_stream[256]; - dword tx_stream[256]; - word tx_pos[256]; - word rx_pos[256]; - byte stream_buffer[2512]; - dword ( * ram_offset)(ADAPTER * a); - void ( * ram_out_dw) (ADAPTER *a, - void *addr, - const dword* data, - int dwords); - void ( * ram_in_dw) (ADAPTER *a, - void *addr, - dword* data, - int dwords); - void ( * istream_wakeup)(ADAPTER* a); + dword rx_stream[256]; + dword tx_stream[256]; + word tx_pos[256]; + word rx_pos[256]; + byte stream_buffer[2512]; + dword (*ram_offset)(ADAPTER *a); + void (*ram_out_dw)(ADAPTER *a, + void *addr, + const dword *data, + int dwords); + void (*ram_in_dw)(ADAPTER *a, + void *addr, + dword *data, + int dwords); + void (*istream_wakeup)(ADAPTER *a); #else - byte stream_buffer[4]; + byte stream_buffer[4]; #endif }; /*------------------------------------------------------------------*/ /* public functions of IDI common code */ /*------------------------------------------------------------------*/ -void pr_out(ADAPTER * a); -byte pr_dpc(ADAPTER * a); -byte scom_test_int(ADAPTER * a); -void scom_clear_int(ADAPTER * a); +void pr_out(ADAPTER *a); +byte pr_dpc(ADAPTER *a); +byte scom_test_int(ADAPTER *a); +void scom_clear_int(ADAPTER *a); /*------------------------------------------------------------------*/ /* OS specific functions used by IDI common code */ /*------------------------------------------------------------------*/ -void free_entity(ADAPTER * a, byte e_no); -void assign_queue(ADAPTER * a, byte e_no, word ref); -byte get_assign(ADAPTER * a, word ref); -void req_queue(ADAPTER * a, byte e_no); -byte look_req(ADAPTER * a); -void next_req(ADAPTER * a); -ENTITY * entity_ptr(ADAPTER * a, byte e_no); +void free_entity(ADAPTER *a, byte e_no); +void assign_queue(ADAPTER *a, byte e_no, word ref); +byte get_assign(ADAPTER *a, word ref); +void req_queue(ADAPTER *a, byte e_no); +byte look_req(ADAPTER *a); +void next_req(ADAPTER *a); +ENTITY *entity_ptr(ADAPTER *a, byte e_no); #if defined(DIVA_ISTREAM) struct _diva_xdi_stream_interface; -void diva_xdi_provide_istream_info (ADAPTER* a, - struct _diva_xdi_stream_interface* pI); -void pr_stream (ADAPTER * a); -int diva_istream_write (void* context, - int Id, - void* data, - int length, - int final, - byte usr1, - byte usr2); -int diva_istream_read (void* context, - int Id, - void* data, - int max_length, - int* final, - byte* usr1, - byte* usr2); +void diva_xdi_provide_istream_info(ADAPTER *a, + struct _diva_xdi_stream_interface *pI); +void pr_stream(ADAPTER *a); +int diva_istream_write(void *context, + int Id, + void *data, + int length, + int final, + byte usr1, + byte usr2); +int diva_istream_read(void *context, + int Id, + void *data, + int max_length, + int *final, + byte *usr1, + byte *usr2); #if defined(DIVA_IDI_RX_DMA) #include "diva_dma.h" #endif diff --git a/drivers/isdn/hardware/eicon/di_dbg.h b/drivers/isdn/hardware/eicon/di_dbg.h index d576ff31d44c..1380b60e526e 100644 --- a/drivers/isdn/hardware/eicon/di_dbg.h +++ b/drivers/isdn/hardware/eicon/di_dbg.h @@ -1,34 +1,34 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_DI_DBG_INC__ #define __DIVA_DI_DBG_INC__ -#if !defined (dtrc) +#if !defined(dtrc) #define dtrc(a) #endif -#if !defined (dbug) +#if !defined(dbug) #define dbug(a) #endif #if !defined USE_EXTENDED_DEBUGS diff --git a/drivers/isdn/hardware/eicon/di_defs.h b/drivers/isdn/hardware/eicon/di_defs.h index 4c2f61267df1..a5094d221086 100644 --- a/drivers/isdn/hardware/eicon/di_defs.h +++ b/drivers/isdn/hardware/eicon/di_defs.h @@ -1,31 +1,31 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#ifndef _DI_DEFS_ +#ifndef _DI_DEFS_ #define _DI_DEFS_ - /* typedefs for our data structures */ +/* typedefs for our data structures */ typedef struct get_name_s GET_NAME; /* The entity_s structure is used to pass all parameters between application and IDI */ @@ -38,72 +38,72 @@ typedef struct get_para_s GET_PARA; #define IDI_CALL_ENTITY_T /* typedef void ( * IDI_CALL)(ENTITY *); */ /* -------------------------------------------------------- - IDI_CALL + IDI_CALL -------------------------------------------------------- */ -typedef void (IDI_CALL_LINK_T * IDI_CALL)(ENTITY IDI_CALL_ENTITY_T *); +typedef void (IDI_CALL_LINK_T *IDI_CALL)(ENTITY IDI_CALL_ENTITY_T *); typedef struct { - word length; /* length of data/parameter field */ - byte P[270]; /* data/parameter field */ + word length; /* length of data/parameter field */ + byte P[270]; /* data/parameter field */ } DBUFFER; struct get_name_s { - word command; /* command = 0x0100 */ - byte name[BOARD_NAME_LENGTH]; + word command; /* command = 0x0100 */ + byte name[BOARD_NAME_LENGTH]; }; struct postcall_s { - word command; /* command = 0x0300 */ - word dummy; /* not used */ - void ( * callback)(void *); /* call back */ - void *context; /* context pointer */ + word command; /* command = 0x0300 */ + word dummy; /* not used */ + void (*callback)(void *); /* call back */ + void *context; /* context pointer */ }; #define REQ_PARA 0x0600 /* request command line parameters */ #define REQ_PARA_LEN 1 /* number of data bytes */ #define L1_STARTUP_DOWN_POS 0 /* '-y' command line parameter in......*/ #define L1_STARTUP_DOWN_MSK 0x01 /* first byte position (index 0) with value 0x01 */ struct get_para_s { - word command; /* command = 0x0600 */ - byte len; /* max length of para field in bytes */ - byte para[REQ_PARA_LEN]; /* parameter field */ + word command; /* command = 0x0600 */ + byte len; /* max length of para field in bytes */ + byte para[REQ_PARA_LEN]; /* parameter field */ }; struct buffers_s { - word PLength; - byte * P; + word PLength; + byte *P; }; struct entity_s { - byte Req; /* pending request */ - byte Rc; /* return code received */ - byte Ind; /* indication received */ - byte ReqCh; /* channel of current Req */ - byte RcCh; /* channel of current Rc */ - byte IndCh; /* channel of current Ind */ - byte Id; /* ID used by this entity */ - byte GlobalId; /* reserved field */ - byte XNum; /* number of X-buffers */ - byte RNum; /* number of R-buffers */ - BUFFERS * X; /* pointer to X-buffer list */ - BUFFERS * R; /* pointer to R-buffer list */ - word RLength; /* length of current R-data */ - DBUFFER * RBuffer; /* buffer of current R-data */ - byte RNR; /* receive not ready flag */ - byte complete; /* receive complete status */ - IDI_CALL callback; - word user[2]; - /* fields used by the driver internally */ - byte No; /* entity number */ - byte reserved2; /* reserved field */ - byte More; /* R/X More flags */ - byte MInd; /* MDATA coding for this ID */ - byte XCurrent; /* current transmit buffer */ - byte RCurrent; /* current receive buffer */ - word XOffset; /* offset in x-buffer */ - word ROffset; /* offset in r-buffer */ + byte Req; /* pending request */ + byte Rc; /* return code received */ + byte Ind; /* indication received */ + byte ReqCh; /* channel of current Req */ + byte RcCh; /* channel of current Rc */ + byte IndCh; /* channel of current Ind */ + byte Id; /* ID used by this entity */ + byte GlobalId; /* reserved field */ + byte XNum; /* number of X-buffers */ + byte RNum; /* number of R-buffers */ + BUFFERS *X; /* pointer to X-buffer list */ + BUFFERS *R; /* pointer to R-buffer list */ + word RLength; /* length of current R-data */ + DBUFFER *RBuffer; /* buffer of current R-data */ + byte RNR; /* receive not ready flag */ + byte complete; /* receive complete status */ + IDI_CALL callback; + word user[2]; + /* fields used by the driver internally */ + byte No; /* entity number */ + byte reserved2; /* reserved field */ + byte More; /* R/X More flags */ + byte MInd; /* MDATA coding for this ID */ + byte XCurrent; /* current transmit buffer */ + byte RCurrent; /* current receive buffer */ + word XOffset; /* offset in x-buffer */ + word ROffset; /* offset in r-buffer */ }; typedef struct { - byte type; - byte channels; - word features; - IDI_CALL request; + byte type; + byte channels; + word features; + IDI_CALL request; } DESCRIPTOR; - /* descriptor type field coding */ +/* descriptor type field coding */ #define IDI_ADAPTER_S 1 #define IDI_ADAPTER_PR 2 #define IDI_ADAPTER_DIVA 3 @@ -113,7 +113,7 @@ typedef struct { #define IDI_DADAPTER 0xfd #define IDI_DIDDPNP 0xfe #define IDI_DIMAINT 0xff - /* Hardware IDs ISA PNP */ +/* Hardware IDs ISA PNP */ #define HW_ID_DIVA_PRO 3 /* same as IDI_ADAPTER_DIVA */ #define HW_ID_MAESTRA 4 /* same as IDI_ADAPTER_MAESTRA */ #define HW_ID_PICCOLA 5 @@ -123,7 +123,7 @@ typedef struct { #define HW_ID_DIVA20_U 9 #define HW_ID_DIVA30 10 #define HW_ID_DIVA30_U 11 - /* Hardware IDs PCI */ +/* Hardware IDs PCI */ #define HW_ID_EICON_PCI 0x1133 #define HW_ID_SIEMENS_PCI 0x8001 /* unused SubVendor ID for Siemens Cornet-N cards */ #define HW_ID_PROTTYPE_CORNETN 0x0014 /* SubDevice ID for Siemens Cornet-N cards */ @@ -153,16 +153,16 @@ typedef struct { #define HW_ID_DSRV_VOICE_P30M_V2_PCI 0xe019 #define HW_ID_DSRV_B2F_PCI 0xe01a #define HW_ID_DSRV_VOICE_B2M_V2_PCI 0xe01b - /* Hardware IDs USB */ +/* Hardware IDs USB */ #define EICON_USB_VENDOR_ID 0x071D #define HW_ID_DIVA_USB_REV1 0x1000 #define HW_ID_DIVA_USB_REV2 0x1003 #define HW_ID_TELEDAT_SURF_USB_REV2 0x1004 #define HW_ID_TELEDAT_SURF_USB_REV1 0x2000 /* -------------------------------------------------------------------------- - Adapter array change notification framework - -------------------------------------------------------------------------- */ -typedef void (IDI_CALL_LINK_T* didd_adapter_change_callback_t)( void IDI_CALL_ENTITY_T * context, DESCRIPTOR* adapter, int removal); + Adapter array change notification framework + -------------------------------------------------------------------------- */ +typedef void (IDI_CALL_LINK_T *didd_adapter_change_callback_t)(void IDI_CALL_ENTITY_T *context, DESCRIPTOR *adapter, int removal); /* -------------------------------------------------------------------------- */ #define DI_VOICE 0x0 /* obsolete define */ #define DI_FAX3 0x1 @@ -177,5 +177,5 @@ typedef void (IDI_CALL_LINK_T* didd_adapter_change_callback_t)( void IDI_CAL #define DI_EXTD_FAX 0x0200 /* Extended FAX (ECM, 2D, T.6, Polling) */ #define DI_AT_PARSER 0x0400 /* Build-in AT Parser in the L2 */ #define DI_VOICE_OVER_IP 0x0800 /* Voice over IP support */ -typedef void (IDI_CALL_LINK_T* _IDI_CALL)(void*, ENTITY*); -#endif +typedef void (IDI_CALL_LINK_T *_IDI_CALL)(void *, ENTITY *); +#endif diff --git a/drivers/isdn/hardware/eicon/did_vers.h b/drivers/isdn/hardware/eicon/did_vers.h index 538c590fdf42..fa8db8249235 100644 --- a/drivers/isdn/hardware/eicon/did_vers.h +++ b/drivers/isdn/hardware/eicon/did_vers.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -static char diva_didd_common_code_build[] = "102-51"; +static char diva_didd_common_code_build[] = "102-51"; diff --git a/drivers/isdn/hardware/eicon/diddfunc.c b/drivers/isdn/hardware/eicon/diddfunc.c index 3029234178d8..c4c8220c9d72 100644 --- a/drivers/isdn/hardware/eicon/diddfunc.c +++ b/drivers/isdn/hardware/eicon/diddfunc.c @@ -1,12 +1,12 @@ /* $Id: diddfunc.c,v 1.14.6.2 2004/08/28 20:03:53 armin Exp $ * * DIDD Interface module for Eicon active cards. - * - * Functions are in dadapter.c - * - * Copyright 2002-2003 by Armin Schindler (mac@melware.de) + * + * Functions are in dadapter.c + * + * Copyright 2002-2003 by Armin Schindler (mac@melware.de) * Copyright 2002-2003 Cytronics & Melware (info@melware.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. */ @@ -28,12 +28,12 @@ static DESCRIPTOR _DAdapter; /* * didd callback function */ -static void *didd_callback(void *context, DESCRIPTOR * adapter, +static void *didd_callback(void *context, DESCRIPTOR *adapter, int removal) { if (adapter->type == IDI_DADAPTER) { DBG_ERR(("Notification about IDI_DADAPTER change ! Oops.")) - return (NULL); + return (NULL); } else if (adapter->type == IDI_DIMAINT) { if (removal) { DbgDeregister(); @@ -62,10 +62,10 @@ static int DIVA_INIT_FUNCTION connect_didd(void) memcpy(&_DAdapter, &DIDD_Table[x], sizeof(_DAdapter)); req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = - IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; + IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; req.didd_notify.info.callback = (void *)didd_callback; req.didd_notify.info.context = NULL; - _DAdapter.request((ENTITY *) & req); + _DAdapter.request((ENTITY *)&req); if (req.didd_notify.e.Rc != 0xff) return (0); notify_handle = req.didd_notify.info.handle; @@ -86,7 +86,7 @@ static void DIVA_EXIT_FUNCTION disconnect_didd(void) req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY; req.didd_notify.info.handle = notify_handle; - _DAdapter.request((ENTITY *) & req); + _DAdapter.request((ENTITY *)&req); } /* @@ -98,7 +98,7 @@ int DIVA_INIT_FUNCTION diddfunc_init(void) if (!connect_didd()) { DBG_ERR(("init: failed to connect to DIDD.")) - diva_didd_load_time_finit(); + diva_didd_load_time_finit(); return (0); } return (1); diff --git a/drivers/isdn/hardware/eicon/diva.c b/drivers/isdn/hardware/eicon/diva.c index 1403a5458e68..d91dd580e978 100644 --- a/drivers/isdn/hardware/eicon/diva.c +++ b/drivers/isdn/hardware/eicon/diva.c @@ -28,12 +28,12 @@ PISDN_ADAPTER IoAdapters[MAX_ADAPTER]; extern IDI_CALL Requests[MAX_ADAPTER]; -extern int create_adapter_proc(diva_os_xdi_adapter_t * a); -extern void remove_adapter_proc(diva_os_xdi_adapter_t * a); +extern int create_adapter_proc(diva_os_xdi_adapter_t *a); +extern void remove_adapter_proc(diva_os_xdi_adapter_t *a); -#define DivaIdiReqFunc(N) \ -static void DivaIdiRequest##N(ENTITY *e) \ -{ if ( IoAdapters[N] ) (* IoAdapters[N]->DIRequest)(IoAdapters[N], e) ; } +#define DivaIdiReqFunc(N) \ + static void DivaIdiRequest##N(ENTITY *e) \ + { if (IoAdapters[N]) (*IoAdapters[N]->DIRequest)(IoAdapters[N], e); } /* ** Create own 32 Adapters @@ -91,44 +91,44 @@ typedef struct _diva_supported_cards_info { static diva_supported_cards_info_t divas_supported_cards[] = { #ifdef CONFIG_ISDN_DIVAS_PRIPCI /* - PRI Cards - */ + PRI Cards + */ {CARDTYPE_DIVASRV_P_30M_PCI, diva_pri_init_card}, /* - PRI Rev.2 Cards - */ + PRI Rev.2 Cards + */ {CARDTYPE_DIVASRV_P_30M_V2_PCI, diva_pri_init_card}, /* - PRI Rev.2 VoIP Cards - */ + PRI Rev.2 VoIP Cards + */ {CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI, diva_pri_init_card}, #endif #ifdef CONFIG_ISDN_DIVAS_BRIPCI /* - 4BRI Rev 1 Cards - */ + 4BRI Rev 1 Cards + */ {CARDTYPE_DIVASRV_Q_8M_PCI, diva_4bri_init_card}, {CARDTYPE_DIVASRV_VOICE_Q_8M_PCI, diva_4bri_init_card}, /* - 4BRI Rev 2 Cards - */ + 4BRI Rev 2 Cards + */ {CARDTYPE_DIVASRV_Q_8M_V2_PCI, diva_4bri_init_card}, {CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI, diva_4bri_init_card}, /* - 4BRI Based BRI Rev 2 Cards - */ + 4BRI Based BRI Rev 2 Cards + */ {CARDTYPE_DIVASRV_B_2M_V2_PCI, diva_4bri_init_card}, {CARDTYPE_DIVASRV_B_2F_PCI, diva_4bri_init_card}, {CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI, diva_4bri_init_card}, /* - BRI - */ + BRI + */ {CARDTYPE_MAESTRA_PCI, diva_bri_init_card}, #endif /* - EOL - */ + EOL + */ {-1} }; @@ -150,18 +150,18 @@ static int diva_find_free_adapters(int base, int nr) return (0); } -static diva_os_xdi_adapter_t *diva_q_get_next(struct list_head * what) +static diva_os_xdi_adapter_t *diva_q_get_next(struct list_head *what) { diva_os_xdi_adapter_t *a = NULL; if (what && (what->next != &adapter_queue)) a = list_entry(what->next, diva_os_xdi_adapter_t, link); - return(a); + return (a); } /* -------------------------------------------------------------------------- - Add card to the card list + Add card to the card list -------------------------------------------------------------------------- */ void *diva_driver_add_card(void *pdev, unsigned long CardOrdinal) { @@ -203,7 +203,7 @@ void *diva_driver_add_card(void *pdev, unsigned long CardOrdinal) [CardOrdinal].Name, pdiva->controller)) - diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add card"); + diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add card"); pa = pdiva; for (j = 1; j < nr; j++) { /* slave adapters, if any */ pa = diva_q_get_next(&pa->link); @@ -214,11 +214,11 @@ void *diva_driver_add_card(void *pdev, unsigned long CardOrdinal) diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add card"); DBG_LOG(("add slave adapter (%d)", pa->controller)) - create_adapter_proc(pa); /* add adapter to proc file system */ + create_adapter_proc(pa); /* add adapter to proc file system */ diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add card"); } else { DBG_ERR(("slave adapter problem")) - break; + break; } } @@ -230,10 +230,10 @@ void *diva_driver_add_card(void *pdev, unsigned long CardOrdinal) diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add card"); /* - Not able to add adapter - remove it and return error - */ + Not able to add adapter - remove it and return error + */ DBG_ERR(("can not alloc request array")) - diva_driver_remove_card(pdiva); + diva_driver_remove_card(pdiva); return NULL; } @@ -243,7 +243,7 @@ void *diva_driver_add_card(void *pdev, unsigned long CardOrdinal) } /* -------------------------------------------------------------------------- - Called on driver load, MAIN, main, DriverEntry + Called on driver load, MAIN, main, DriverEntry -------------------------------------------------------------------------- */ int divasa_xdi_driver_entry(void) { @@ -255,7 +255,7 @@ int divasa_xdi_driver_entry(void) } /* -------------------------------------------------------------------------- - Remove adapter from list + Remove adapter from list -------------------------------------------------------------------------- */ static diva_os_xdi_adapter_t *get_and_remove_from_queue(void) { @@ -274,7 +274,7 @@ static diva_os_xdi_adapter_t *get_and_remove_from_queue(void) } /* -------------------------------------------------------------------------- - Remove card from the card list + Remove card from the card list -------------------------------------------------------------------------- */ void diva_driver_remove_card(void *pdiva) { @@ -318,7 +318,7 @@ void diva_driver_remove_card(void *pdiva) } /* -------------------------------------------------------------------------- - Create diva PCI adapter and init internal adapter structures + Create diva PCI adapter and init internal adapter structures -------------------------------------------------------------------------- */ static void *divas_create_pci_card(int handle, void *pci_dev_handle) { @@ -328,10 +328,10 @@ static void *divas_create_pci_card(int handle, void *pci_dev_handle) DBG_LOG(("found %d-%s", pI->CardOrdinal, CardProperties[pI->CardOrdinal].Name)) - if (!(a = (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) { - DBG_ERR(("A: can't alloc adapter")); - return NULL; - } + if (!(a = (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) { + DBG_ERR(("A: can't alloc adapter")); + return NULL; + } memset(a, 0x00, sizeof(*a)); @@ -344,9 +344,9 @@ static void *divas_create_pci_card(int handle, void *pci_dev_handle) a->resources.pci.hdev = pci_dev_handle; /* - Add master adapter first, so slave adapters will receive higher - numbers as master adapter - */ + Add master adapter first, so slave adapters will receive higher + numbers as master adapter + */ diva_os_enter_spin_lock(&adapter_lock, &old_irql, "found_pci_card"); list_add_tail(&a->link, &adapter_queue); diva_os_leave_spin_lock(&adapter_lock, &old_irql, "found_pci_card"); @@ -364,7 +364,7 @@ static void *divas_create_pci_card(int handle, void *pci_dev_handle) } /* -------------------------------------------------------------------------- - Called on driver unload FINIT, finit, Unload + Called on driver unload FINIT, finit, Unload -------------------------------------------------------------------------- */ void divasa_xdi_driver_unload(void) { @@ -398,11 +398,11 @@ void *diva_xdi_open_adapter(void *os_handle, const void __user *src, if (length < sizeof(diva_xdi_um_cfg_cmd_t)) { DBG_ERR(("A: A(?) open, msg too small (%d < %d)", length, sizeof(diva_xdi_um_cfg_cmd_t))) - return NULL; + return NULL; } if ((*cp_fn) (os_handle, &msg, src, sizeof(msg)) <= 0) { DBG_ERR(("A: A(?) open, write error")) - return NULL; + return NULL; } diva_os_enter_spin_lock(&adapter_lock, &old_irql, "open_adapter"); list_for_each(tmp, &adapter_queue) { @@ -415,7 +415,7 @@ void *diva_xdi_open_adapter(void *os_handle, const void __user *src, if (!a) { DBG_ERR(("A: A(%d) open, adapter not found", msg.adapter)) - } + } return (a); } @@ -443,19 +443,19 @@ diva_xdi_write(void *adapter, void *os_handle, const void __user *src, if (a->xdi_mbox.status & DIVA_XDI_MBOX_BUSY) { DBG_ERR(("A: A(%d) write, mbox busy", a->controller)) - return (-1); + return (-1); } if (length < sizeof(diva_xdi_um_cfg_cmd_t)) { DBG_ERR(("A: A(%d) write, message too small (%d < %d)", a->controller, length, sizeof(diva_xdi_um_cfg_cmd_t))) - return (-3); + return (-3); } if (!(data = diva_os_malloc(0, length))) { DBG_ERR(("A: A(%d) write, ENOMEM", a->controller)) - return (-2); + return (-2); } length = (*cp_fn) (os_handle, data, src, length); @@ -467,7 +467,7 @@ diva_xdi_write(void *adapter, void *os_handle, const void __user *src, } else { DBG_ERR(("A: A(%d) write error (%d)", a->controller, length)) - } + } diva_os_free(0, data); @@ -486,23 +486,23 @@ diva_xdi_read(void *adapter, void *os_handle, void __user *dst, if (!(a->xdi_mbox.status & DIVA_XDI_MBOX_BUSY)) { DBG_ERR(("A: A(%d) rx mbox empty", a->controller)) - return (-1); + return (-1); } if (!a->xdi_mbox.data) { a->xdi_mbox.status &= ~DIVA_XDI_MBOX_BUSY; DBG_ERR(("A: A(%d) rx ENOMEM", a->controller)) - return (-2); + return (-2); } if (max_length < a->xdi_mbox.data_length) { DBG_ERR(("A: A(%d) rx buffer too short(%d < %d)", a->controller, max_length, a->xdi_mbox.data_length)) - return (-3); + return (-3); } ret = (*cp_fn) (os_handle, dst, a->xdi_mbox.data, - a->xdi_mbox.data_length); + a->xdi_mbox.data_length); if (ret > 0) { diva_os_free(0, a->xdi_mbox.data); a->xdi_mbox.data = NULL; @@ -577,33 +577,33 @@ void diva_xdi_display_adapter_features(int card) features = IoAdapters[card]->Properties.Features; DBG_LOG(("FEATURES FOR ADAPTER: %d", card + 1)) - DBG_LOG((" DI_FAX3 : %s", - (features & DI_FAX3) ? "Y" : "N")) - DBG_LOG((" DI_MODEM : %s", - (features & DI_MODEM) ? "Y" : "N")) - DBG_LOG((" DI_POST : %s", - (features & DI_POST) ? "Y" : "N")) - DBG_LOG((" DI_V110 : %s", - (features & DI_V110) ? "Y" : "N")) - DBG_LOG((" DI_V120 : %s", - (features & DI_V120) ? "Y" : "N")) - DBG_LOG((" DI_POTS : %s", - (features & DI_POTS) ? "Y" : "N")) - DBG_LOG((" DI_CODEC : %s", - (features & DI_CODEC) ? "Y" : "N")) - DBG_LOG((" DI_MANAGE : %s", - (features & DI_MANAGE) ? "Y" : "N")) - DBG_LOG((" DI_V_42 : %s", - (features & DI_V_42) ? "Y" : "N")) - DBG_LOG((" DI_EXTD_FAX : %s", - (features & DI_EXTD_FAX) ? "Y" : "N")) - DBG_LOG((" DI_AT_PARSER : %s", - (features & DI_AT_PARSER) ? "Y" : "N")) - DBG_LOG((" DI_VOICE_OVER_IP : %s", - (features & DI_VOICE_OVER_IP) ? "Y" : "N")) -} + DBG_LOG((" DI_FAX3 : %s", + (features & DI_FAX3) ? "Y" : "N")) + DBG_LOG((" DI_MODEM : %s", + (features & DI_MODEM) ? "Y" : "N")) + DBG_LOG((" DI_POST : %s", + (features & DI_POST) ? "Y" : "N")) + DBG_LOG((" DI_V110 : %s", + (features & DI_V110) ? "Y" : "N")) + DBG_LOG((" DI_V120 : %s", + (features & DI_V120) ? "Y" : "N")) + DBG_LOG((" DI_POTS : %s", + (features & DI_POTS) ? "Y" : "N")) + DBG_LOG((" DI_CODEC : %s", + (features & DI_CODEC) ? "Y" : "N")) + DBG_LOG((" DI_MANAGE : %s", + (features & DI_MANAGE) ? "Y" : "N")) + DBG_LOG((" DI_V_42 : %s", + (features & DI_V_42) ? "Y" : "N")) + DBG_LOG((" DI_EXTD_FAX : %s", + (features & DI_EXTD_FAX) ? "Y" : "N")) + DBG_LOG((" DI_AT_PARSER : %s", + (features & DI_AT_PARSER) ? "Y" : "N")) + DBG_LOG((" DI_VOICE_OVER_IP : %s", + (features & DI_VOICE_OVER_IP) ? "Y" : "N")) + } -void diva_add_slave_adapter(diva_os_xdi_adapter_t * a) +void diva_add_slave_adapter(diva_os_xdi_adapter_t *a) { diva_os_spin_lock_magic_t old_irql; @@ -612,7 +612,7 @@ void diva_add_slave_adapter(diva_os_xdi_adapter_t * a) diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add_slave"); } -int diva_card_read_xlog(diva_os_xdi_adapter_t * a) +int diva_card_read_xlog(diva_os_xdi_adapter_t *a) { diva_get_xlog_t *req; byte *data; diff --git a/drivers/isdn/hardware/eicon/diva_didd.c b/drivers/isdn/hardware/eicon/diva_didd.c index 5d06a7437824..d1d3de03cced 100644 --- a/drivers/isdn/hardware/eicon/diva_didd.c +++ b/drivers/isdn/hardware/eicon/diva_didd.c @@ -1,12 +1,12 @@ /* $Id: diva_didd.c,v 1.13.6.4 2005/02/11 19:40:25 armin Exp $ * * DIDD Interface module for Eicon active cards. - * - * Functions are in dadapter.c - * - * Copyright 2002-2003 by Armin Schindler (mac@melware.de) + * + * Functions are in dadapter.c + * + * Copyright 2002-2003 by Armin Schindler (mac@melware.de) * Copyright 2002-2003 Cytronics & Melware (info@melware.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. */ @@ -27,7 +27,7 @@ static char *main_revision = "$Revision: 1.13.6.4 $"; static char *DRIVERNAME = - "Eicon DIVA - DIDD table (http://www.melware.net)"; + "Eicon DIVA - DIDD table (http://www.melware.net)"; static char *DRIVERLNAME = "divadidd"; char *DRIVERRELEASE_DIDD = "2.0"; @@ -72,7 +72,7 @@ static int divadidd_proc_show(struct seq_file *m, void *v) seq_printf(m, "name : %s\n", DRIVERLNAME); seq_printf(m, "release : %s\n", DRIVERRELEASE_DIDD); seq_printf(m, "build : %s(%s)\n", - diva_didd_common_code_build, DIVA_BUILD); + diva_didd_common_code_build, DIVA_BUILD); seq_printf(m, "revision : %s\n", getrev(tmprev)); return 0; @@ -137,7 +137,7 @@ static int DIVA_INIT_FUNCTION divadidd_init(void) goto out; } - out: +out: return (ret); } diff --git a/drivers/isdn/hardware/eicon/diva_dma.c b/drivers/isdn/hardware/eicon/diva_dma.c index f53a7407605f..217b6aa9f612 100644 --- a/drivers/isdn/hardware/eicon/diva_dma.c +++ b/drivers/isdn/hardware/eicon/diva_dma.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -28,67 +28,67 @@ /* Every entry has length of PAGE_SIZE and represents one single physical page - */ +*/ struct _diva_dma_map_entry { - int busy; - dword phys_bus_addr; /* 32bit address as seen by the card */ - void* local_ram_addr; /* local address as seen by the host */ - void* addr_handle; /* handle uset to free allocated memory */ + int busy; + dword phys_bus_addr; /* 32bit address as seen by the card */ + void *local_ram_addr; /* local address as seen by the host */ + void *addr_handle; /* handle uset to free allocated memory */ }; /* Create local mapping structure and init it to default state - */ -struct _diva_dma_map_entry* diva_alloc_dma_map (void* os_context, int nentries) { - diva_dma_map_entry_t* pmap = diva_os_malloc(0, sizeof(*pmap)*(nentries+1)); - if (pmap) - memset (pmap, 0, sizeof(*pmap)*(nentries+1)); - return pmap; +*/ +struct _diva_dma_map_entry *diva_alloc_dma_map(void *os_context, int nentries) { + diva_dma_map_entry_t *pmap = diva_os_malloc(0, sizeof(*pmap) * (nentries + 1)); + if (pmap) + memset(pmap, 0, sizeof(*pmap) * (nentries + 1)); + return pmap; } /* Free local map (context should be freed before) if any - */ -void diva_free_dma_mapping (struct _diva_dma_map_entry* pmap) { - if (pmap) { - diva_os_free (0, pmap); - } +*/ +void diva_free_dma_mapping(struct _diva_dma_map_entry *pmap) { + if (pmap) { + diva_os_free(0, pmap); + } } /* Set information saved on the map entry - */ -void diva_init_dma_map_entry (struct _diva_dma_map_entry* pmap, - int nr, void* virt, dword phys, - void* addr_handle) { - pmap[nr].phys_bus_addr = phys; - pmap[nr].local_ram_addr = virt; - pmap[nr].addr_handle = addr_handle; +*/ +void diva_init_dma_map_entry(struct _diva_dma_map_entry *pmap, + int nr, void *virt, dword phys, + void *addr_handle) { + pmap[nr].phys_bus_addr = phys; + pmap[nr].local_ram_addr = virt; + pmap[nr].addr_handle = addr_handle; } /* Allocate one single entry in the map - */ -int diva_alloc_dma_map_entry (struct _diva_dma_map_entry* pmap) { - int i; - for (i = 0; (pmap && pmap[i].local_ram_addr); i++) { - if (!pmap[i].busy) { - pmap[i].busy = 1; - return (i); - } - } - return (-1); +*/ +int diva_alloc_dma_map_entry(struct _diva_dma_map_entry *pmap) { + int i; + for (i = 0; (pmap && pmap[i].local_ram_addr); i++) { + if (!pmap[i].busy) { + pmap[i].busy = 1; + return (i); + } + } + return (-1); } /* Free one single entry in the map - */ -void diva_free_dma_map_entry (struct _diva_dma_map_entry* pmap, int nr) { - pmap[nr].busy = 0; +*/ +void diva_free_dma_map_entry(struct _diva_dma_map_entry *pmap, int nr) { + pmap[nr].busy = 0; } /* Get information saved on the map entry - */ -void diva_get_dma_map_entry (struct _diva_dma_map_entry* pmap, int nr, - void** pvirt, dword* pphys) { - *pphys = pmap[nr].phys_bus_addr; - *pvirt = pmap[nr].local_ram_addr; +*/ +void diva_get_dma_map_entry(struct _diva_dma_map_entry *pmap, int nr, + void **pvirt, dword *pphys) { + *pphys = pmap[nr].phys_bus_addr; + *pvirt = pmap[nr].local_ram_addr; } -void* diva_get_entry_handle (struct _diva_dma_map_entry* pmap, int nr) { - return (pmap[nr].addr_handle); +void *diva_get_entry_handle(struct _diva_dma_map_entry *pmap, int nr) { + return (pmap[nr].addr_handle); } diff --git a/drivers/isdn/hardware/eicon/diva_dma.h b/drivers/isdn/hardware/eicon/diva_dma.h index dff80724cdbd..d32c91be562b 100644 --- a/drivers/isdn/hardware/eicon/diva_dma.h +++ b/drivers/isdn/hardware/eicon/diva_dma.h @@ -1,48 +1,48 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_DMA_MAPPING_IFC_H__ #define __DIVA_DMA_MAPPING_IFC_H__ typedef struct _diva_dma_map_entry diva_dma_map_entry_t; -struct _diva_dma_map_entry* diva_alloc_dma_map (void* os_context, int nentries); -void diva_init_dma_map_entry (struct _diva_dma_map_entry* pmap, - int nr, void* virt, dword phys, - void* addr_handle); -int diva_alloc_dma_map_entry (struct _diva_dma_map_entry* pmap); -void diva_free_dma_map_entry (struct _diva_dma_map_entry* pmap, int entry); -void diva_get_dma_map_entry (struct _diva_dma_map_entry* pmap, int nr, - void** pvirt, dword* pphys); -void diva_free_dma_mapping (struct _diva_dma_map_entry* pmap); +struct _diva_dma_map_entry *diva_alloc_dma_map(void *os_context, int nentries); +void diva_init_dma_map_entry(struct _diva_dma_map_entry *pmap, + int nr, void *virt, dword phys, + void *addr_handle); +int diva_alloc_dma_map_entry(struct _diva_dma_map_entry *pmap); +void diva_free_dma_map_entry(struct _diva_dma_map_entry *pmap, int entry); +void diva_get_dma_map_entry(struct _diva_dma_map_entry *pmap, int nr, + void **pvirt, dword *pphys); +void diva_free_dma_mapping(struct _diva_dma_map_entry *pmap); /* Functionality to be implemented by OS wrapper and running in process context - */ -void diva_init_dma_map (void* hdev, - struct _diva_dma_map_entry** ppmap, - int nentries); -void diva_free_dma_map (void* hdev, - struct _diva_dma_map_entry* pmap); -void* diva_get_entry_handle (struct _diva_dma_map_entry* pmap, int nr); +*/ +void diva_init_dma_map(void *hdev, + struct _diva_dma_map_entry **ppmap, + int nentries); +void diva_free_dma_map(void *hdev, + struct _diva_dma_map_entry *pmap); +void *diva_get_entry_handle(struct _diva_dma_map_entry *pmap, int nr); #endif diff --git a/drivers/isdn/hardware/eicon/diva_pci.h b/drivers/isdn/hardware/eicon/diva_pci.h index cc0d5102723a..bb4b562050f6 100644 --- a/drivers/isdn/hardware/eicon/diva_pci.h +++ b/drivers/isdn/hardware/eicon/diva_pci.h @@ -4,9 +4,9 @@ #define __DIVA_PCI_INTERFACE_H__ void __iomem *divasa_remap_pci_bar(diva_os_xdi_adapter_t *a, - int id, - unsigned long bar, - unsigned long area_length); + int id, + unsigned long bar, + unsigned long area_length); void divasa_unmap_pci_bar(void __iomem *bar); unsigned long divasa_get_pci_irq(unsigned char bus, unsigned char func, void *pci_dev_handle); diff --git a/drivers/isdn/hardware/eicon/divacapi.h b/drivers/isdn/hardware/eicon/divacapi.h index e330da0c5fc0..3942efbbfb58 100644 --- a/drivers/isdn/hardware/eicon/divacapi.h +++ b/drivers/isdn/hardware/eicon/divacapi.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -29,8 +29,8 @@ - - + + @@ -82,7 +82,7 @@ #define CODEC_PERMANENT 0x02 #define ADV_VOICE 0x03 #define MAX_CIP_TYPES 5 /* kind of CIP types for group optimization */ -#define C_IND_MASK_DWORDS ((MAX_APPL+32) >> 5) +#define C_IND_MASK_DWORDS ((MAX_APPL + 32) >> 5) #define FAX_CONNECT_INFO_BUFFER_SIZE 256 @@ -116,289 +116,289 @@ typedef struct msn_config_max_s MSN_CONFIG_MAX; typedef struct msn_ld_s MSN_LD; struct manufacturer_profile_s { - dword private_options; - dword rtp_primary_payloads; - dword rtp_additional_payloads; + dword private_options; + dword rtp_primary_payloads; + dword rtp_additional_payloads; }; struct fax_ncpi_s { - word options; - word format; + word options; + word format; }; struct msn_config_s { - byte msn[MAX_CPN_MASK_SIZE]; + byte msn[MAX_CPN_MASK_SIZE]; }; struct msn_config_max_s { - MSN_CONFIG msn_conf[MAX_MSN_CONFIG]; + MSN_CONFIG msn_conf[MAX_MSN_CONFIG]; }; struct msn_ld_s { - dword low; - dword high; + dword low; + dword high; }; struct api_parse_s { - word length; - byte * info; + word length; + byte *info; }; struct api_save_s { - API_PARSE parms[MAX_MSG_PARMS+1]; - byte info[MAX_MSG_SIZE]; + API_PARSE parms[MAX_MSG_PARMS + 1]; + byte info[MAX_MSG_SIZE]; }; struct _DATA_B3_DESC { - word Handle; - word Number; - word Flags; - word Length; - void * P; + word Handle; + word Number; + word Flags; + word Length; + void *P; }; struct _DATA_ACK_DESC { - word Handle; - word Number; + word Handle; + word Number; }; -typedef void (* t_std_internal_command)(dword Id, PLCI *plci, byte Rc); +typedef void (*t_std_internal_command)(dword Id, PLCI *plci, byte Rc); /************************************************************************/ /* Don't forget to adapt dos.asm after changing the _APPL structure!!!! */ struct _APPL { - word Id; - word NullCREnable; - word CDEnable; - dword S_Handle; + word Id; + word NullCREnable; + word CDEnable; + dword S_Handle; - LIST_ENTRY s_function; - dword s_context; - word s_count; - APPL * s_next; - byte * xbuffer_used; - void ** xbuffer_internal; - void ** xbuffer_ptr; + LIST_ENTRY s_function; + dword s_context; + word s_count; + APPL *s_next; + byte *xbuffer_used; + void **xbuffer_internal; + void **xbuffer_ptr; - byte * queue; - word queue_size; - word queue_free; - word queue_read; - word queue_write; - word queue_signal; - byte msg_lost; - byte appl_flags; - word Number; + byte *queue; + word queue_size; + word queue_free; + word queue_read; + word queue_write; + word queue_signal; + byte msg_lost; + byte appl_flags; + word Number; - word MaxBuffer; - byte MaxNCCI; - byte MaxNCCIData; - word MaxDataLength; - word NCCIDataFlowCtrlTimer; - byte * ReceiveBuffer; - word * DataNCCI; - word * DataFlags; + word MaxBuffer; + byte MaxNCCI; + byte MaxNCCIData; + word MaxDataLength; + word NCCIDataFlowCtrlTimer; + byte *ReceiveBuffer; + word *DataNCCI; + word *DataFlags; }; struct _PLCI { - ENTITY Sig; - ENTITY NL; - word RNum; - word RFlags; - BUFFERS RData[2]; - BUFFERS XData[1]; - BUFFERS NData[2]; - - DIVA_CAPI_ADAPTER *adapter; - APPL *appl; - PLCI *relatedPTYPLCI; - byte Id; - byte State; - byte sig_req; - byte nl_req; - byte SuppState; - byte channels; - byte tel; - byte B1_resource; - byte B2_prot; - byte B3_prot; - - word command; - word m_command; - word internal_command; - word number; - word req_in_start; - word req_in; - word req_out; - word msg_in_write_pos; - word msg_in_read_pos; - word msg_in_wrap_pos; - - void * data_sent_ptr; - byte data_sent; - byte send_disc; - byte sig_global_req; - byte sig_remove_id; - byte nl_global_req; - byte nl_remove_id; - byte b_channel; - byte adv_nl; - byte manufacturer; - byte call_dir; - byte hook_state; - byte spoofed_msg; - byte ptyState; - byte cr_enquiry; - word hangup_flow_ctrl_timer; - - word ncci_ring_list; - byte inc_dis_ncci_table[MAX_CHANNELS_PER_PLCI]; - t_std_internal_command internal_command_queue[MAX_INTERNAL_COMMAND_LEVELS]; - dword c_ind_mask_table[C_IND_MASK_DWORDS]; - dword group_optimization_mask_table[C_IND_MASK_DWORDS]; - byte RBuffer[200]; - dword msg_in_queue[MSG_IN_QUEUE_SIZE/sizeof(dword)]; - API_SAVE saved_msg; - API_SAVE B_protocol; - byte fax_connect_info_length; - byte fax_connect_info_buffer[FAX_CONNECT_INFO_BUFFER_SIZE]; - byte fax_edata_ack_length; - word nsf_control_bits; - byte ncpi_state; - byte ncpi_buffer[NCPI_BUFFER_SIZE]; - - byte internal_req_buffer[INTERNAL_REQ_BUFFER_SIZE]; - byte internal_ind_buffer[INTERNAL_IND_BUFFER_SIZE + 3]; - dword requested_options_conn; - dword requested_options; - word B1_facilities; - API_SAVE *adjust_b_parms_msg; - word adjust_b_facilities; - word adjust_b_command; - word adjust_b_ncci; - word adjust_b_mode; - word adjust_b_state; - byte adjust_b_restore; - - byte dtmf_rec_active; - word dtmf_rec_pulse_ms; - word dtmf_rec_pause_ms; - byte dtmf_send_requests; - word dtmf_send_pulse_ms; - word dtmf_send_pause_ms; - word dtmf_cmd; - word dtmf_msg_number_queue[8]; - byte dtmf_parameter_length; - byte dtmf_parameter_buffer[DTMF_PARAMETER_BUFFER_SIZE]; - - - t_capidtmf_state capidtmf_state; - - - byte li_bchannel_id; /* BRI: 1..2, PRI: 1..32 */ - byte li_channel_bits; - byte li_notify_update; - word li_cmd; - word li_write_command; - word li_write_channel; - word li_plci_b_write_pos; - word li_plci_b_read_pos; - word li_plci_b_req_pos; - dword li_plci_b_queue[LI_PLCI_B_QUEUE_ENTRIES]; - - - word ec_cmd; - word ec_idi_options; - word ec_tail_length; - - - byte tone_last_indication_code; - - byte vswitchstate; - byte vsprot; - byte vsprotdialect; - byte notifiedcall; /* Flag if it is a spoofed call */ - - int rx_dma_descriptor; - dword rx_dma_magic; + ENTITY Sig; + ENTITY NL; + word RNum; + word RFlags; + BUFFERS RData[2]; + BUFFERS XData[1]; + BUFFERS NData[2]; + + DIVA_CAPI_ADAPTER *adapter; + APPL *appl; + PLCI *relatedPTYPLCI; + byte Id; + byte State; + byte sig_req; + byte nl_req; + byte SuppState; + byte channels; + byte tel; + byte B1_resource; + byte B2_prot; + byte B3_prot; + + word command; + word m_command; + word internal_command; + word number; + word req_in_start; + word req_in; + word req_out; + word msg_in_write_pos; + word msg_in_read_pos; + word msg_in_wrap_pos; + + void *data_sent_ptr; + byte data_sent; + byte send_disc; + byte sig_global_req; + byte sig_remove_id; + byte nl_global_req; + byte nl_remove_id; + byte b_channel; + byte adv_nl; + byte manufacturer; + byte call_dir; + byte hook_state; + byte spoofed_msg; + byte ptyState; + byte cr_enquiry; + word hangup_flow_ctrl_timer; + + word ncci_ring_list; + byte inc_dis_ncci_table[MAX_CHANNELS_PER_PLCI]; + t_std_internal_command internal_command_queue[MAX_INTERNAL_COMMAND_LEVELS]; + dword c_ind_mask_table[C_IND_MASK_DWORDS]; + dword group_optimization_mask_table[C_IND_MASK_DWORDS]; + byte RBuffer[200]; + dword msg_in_queue[MSG_IN_QUEUE_SIZE/sizeof(dword)]; + API_SAVE saved_msg; + API_SAVE B_protocol; + byte fax_connect_info_length; + byte fax_connect_info_buffer[FAX_CONNECT_INFO_BUFFER_SIZE]; + byte fax_edata_ack_length; + word nsf_control_bits; + byte ncpi_state; + byte ncpi_buffer[NCPI_BUFFER_SIZE]; + + byte internal_req_buffer[INTERNAL_REQ_BUFFER_SIZE]; + byte internal_ind_buffer[INTERNAL_IND_BUFFER_SIZE + 3]; + dword requested_options_conn; + dword requested_options; + word B1_facilities; + API_SAVE *adjust_b_parms_msg; + word adjust_b_facilities; + word adjust_b_command; + word adjust_b_ncci; + word adjust_b_mode; + word adjust_b_state; + byte adjust_b_restore; + + byte dtmf_rec_active; + word dtmf_rec_pulse_ms; + word dtmf_rec_pause_ms; + byte dtmf_send_requests; + word dtmf_send_pulse_ms; + word dtmf_send_pause_ms; + word dtmf_cmd; + word dtmf_msg_number_queue[8]; + byte dtmf_parameter_length; + byte dtmf_parameter_buffer[DTMF_PARAMETER_BUFFER_SIZE]; + + + t_capidtmf_state capidtmf_state; + + + byte li_bchannel_id; /* BRI: 1..2, PRI: 1..32 */ + byte li_channel_bits; + byte li_notify_update; + word li_cmd; + word li_write_command; + word li_write_channel; + word li_plci_b_write_pos; + word li_plci_b_read_pos; + word li_plci_b_req_pos; + dword li_plci_b_queue[LI_PLCI_B_QUEUE_ENTRIES]; + + + word ec_cmd; + word ec_idi_options; + word ec_tail_length; + + + byte tone_last_indication_code; + + byte vswitchstate; + byte vsprot; + byte vsprotdialect; + byte notifiedcall; /* Flag if it is a spoofed call */ + + int rx_dma_descriptor; + dword rx_dma_magic; }; struct _NCCI { - byte data_out; - byte data_pending; - byte data_ack_out; - byte data_ack_pending; - DATA_B3_DESC DBuffer[MAX_DATA_B3]; - DATA_ACK_DESC DataAck[MAX_DATA_ACK]; + byte data_out; + byte data_pending; + byte data_ack_out; + byte data_ack_pending; + DATA_B3_DESC DBuffer[MAX_DATA_B3]; + DATA_ACK_DESC DataAck[MAX_DATA_ACK]; }; struct _DIVA_CAPI_ADAPTER { - IDI_CALL request; - byte Id; - byte max_plci; - byte max_listen; - byte listen_active; - PLCI *plci; - byte ch_ncci[MAX_NL_CHANNEL+1]; - byte ncci_ch[MAX_NCCI+1]; - byte ncci_plci[MAX_NCCI+1]; - byte ncci_state[MAX_NCCI+1]; - byte ncci_next[MAX_NCCI+1]; - NCCI ncci[MAX_NCCI+1]; - - byte ch_flow_control[MAX_NL_CHANNEL+1]; /* Used by XON protocol */ - byte ch_flow_control_pending; - byte ch_flow_plci[MAX_NL_CHANNEL+1]; - int last_flow_control_ch; - - dword Info_Mask[MAX_APPL]; - dword CIP_Mask[MAX_APPL]; - - dword Notification_Mask[MAX_APPL]; - PLCI *codec_listen[MAX_APPL]; - dword requested_options_table[MAX_APPL]; - API_PROFILE profile; - MANUFACTURER_PROFILE man_profile; - dword manufacturer_features; - - byte AdvCodecFLAG; - PLCI *AdvCodecPLCI; - PLCI *AdvSignalPLCI; - APPL *AdvSignalAppl; - byte TelOAD[23]; - byte TelOSA[23]; - byte scom_appl_disable; - PLCI *automatic_lawPLCI; - byte automatic_law; - byte u_law; - - byte adv_voice_coef_length; - byte adv_voice_coef_buffer[ADV_VOICE_COEF_BUFFER_SIZE]; - - byte li_pri; - byte li_channels; - word li_base; - - byte adapter_disabled; - byte group_optimization_enabled; /* use application groups if enabled */ - dword sdram_bar; - byte flag_dynamic_l1_down; /* for hunt groups:down layer 1 if no appl present*/ - byte FlowControlIdTable[256]; - byte FlowControlSkipTable[256]; - void* os_card; /* pointer to associated OS dependent adapter structure */ + IDI_CALL request; + byte Id; + byte max_plci; + byte max_listen; + byte listen_active; + PLCI *plci; + byte ch_ncci[MAX_NL_CHANNEL + 1]; + byte ncci_ch[MAX_NCCI + 1]; + byte ncci_plci[MAX_NCCI + 1]; + byte ncci_state[MAX_NCCI + 1]; + byte ncci_next[MAX_NCCI + 1]; + NCCI ncci[MAX_NCCI + 1]; + + byte ch_flow_control[MAX_NL_CHANNEL + 1]; /* Used by XON protocol */ + byte ch_flow_control_pending; + byte ch_flow_plci[MAX_NL_CHANNEL + 1]; + int last_flow_control_ch; + + dword Info_Mask[MAX_APPL]; + dword CIP_Mask[MAX_APPL]; + + dword Notification_Mask[MAX_APPL]; + PLCI *codec_listen[MAX_APPL]; + dword requested_options_table[MAX_APPL]; + API_PROFILE profile; + MANUFACTURER_PROFILE man_profile; + dword manufacturer_features; + + byte AdvCodecFLAG; + PLCI *AdvCodecPLCI; + PLCI *AdvSignalPLCI; + APPL *AdvSignalAppl; + byte TelOAD[23]; + byte TelOSA[23]; + byte scom_appl_disable; + PLCI *automatic_lawPLCI; + byte automatic_law; + byte u_law; + + byte adv_voice_coef_length; + byte adv_voice_coef_buffer[ADV_VOICE_COEF_BUFFER_SIZE]; + + byte li_pri; + byte li_channels; + word li_base; + + byte adapter_disabled; + byte group_optimization_enabled; /* use application groups if enabled */ + dword sdram_bar; + byte flag_dynamic_l1_down; /* for hunt groups:down layer 1 if no appl present*/ + byte FlowControlIdTable[256]; + byte FlowControlSkipTable[256]; + void *os_card; /* pointer to associated OS dependent adapter structure */ }; @@ -451,23 +451,23 @@ struct _DIVA_CAPI_ADAPTER { typedef struct t30_info_s T30_INFO; struct t30_info_s { - byte code; - byte rate_div_2400; - byte resolution; - byte data_format; - byte pages_low; - byte pages_high; - byte operating_mode; - byte control_bits_low; - byte control_bits_high; - byte feature_bits_low; - byte feature_bits_high; - byte recording_properties; - byte universal_6; - byte universal_7; - byte station_id_len; - byte head_line_len; - byte station_id[T30_MAX_STATION_ID_LENGTH]; + byte code; + byte rate_div_2400; + byte resolution; + byte data_format; + byte pages_low; + byte pages_high; + byte operating_mode; + byte control_bits_low; + byte control_bits_high; + byte feature_bits_low; + byte feature_bits_high; + byte recording_properties; + byte universal_6; + byte universal_7; + byte station_id_len; + byte head_line_len; + byte station_id[T30_MAX_STATION_ID_LENGTH]; /* byte head_line[]; */ /* byte sub_sep_length; */ /* byte sub_sep_field[]; */ @@ -528,13 +528,13 @@ struct t30_info_s { #define T30_OPERATING_MODE_CAPI_NEG 4 #define T30_OPERATING_MODE_COUNT 5 - /* EDATA transmit messages */ +/* EDATA transmit messages */ #define EDATA_T30_DIS 0x01 #define EDATA_T30_FTT 0x02 #define EDATA_T30_MCF 0x03 #define EDATA_T30_PARAMETERS 0x04 - /* EDATA receive messages */ +/* EDATA receive messages */ #define EDATA_T30_DCS 0x81 #define EDATA_T30_TRAIN_OK 0x82 #define EDATA_T30_EOP 0x83 @@ -639,11 +639,11 @@ struct t30_info_s { typedef struct async_s ASYNC_FORMAT; struct async_s { - unsigned pe: 1; - unsigned parity:2; - unsigned spare: 2; - unsigned stp: 1; - unsigned ch_len:2; /* 3th octett in CAI */ + unsigned pe:1; + unsigned parity:2; + unsigned spare:2; + unsigned stp:1; + unsigned ch_len:2; /* 3th octett in CAI */ }; @@ -686,14 +686,14 @@ struct async_s { /*------------------------------------------------------------------*/ /* Capi IE + Msg types */ /*------------------------------------------------------------------*/ -#define ESC_CAUSE 0x800|CAU /* Escape cause element */ -#define ESC_MSGTYPE 0x800|MSGTYPEIE /* Escape message type */ -#define ESC_CHI 0x800|CHI /* Escape channel id */ -#define ESC_LAW 0x800|BC /* Escape law info */ -#define ESC_CR 0x800|CRIE /* Escape CallReference */ -#define ESC_PROFILE 0x800|PROFILEIE /* Escape profile */ -#define ESC_SSEXT 0x800|SSEXTIE /* Escape Supplem. Serv.*/ -#define ESC_VSWITCH 0x800|VSWITCHIE /* Escape VSwitch */ +#define ESC_CAUSE 0x800 | CAU /* Escape cause element */ +#define ESC_MSGTYPE 0x800 | MSGTYPEIE /* Escape message type */ +#define ESC_CHI 0x800 | CHI /* Escape channel id */ +#define ESC_LAW 0x800 | BC /* Escape law info */ +#define ESC_CR 0x800 | CRIE /* Escape CallReference */ +#define ESC_PROFILE 0x800 | PROFILEIE /* Escape profile */ +#define ESC_SSEXT 0x800 | SSEXTIE /* Escape Supplem. Serv.*/ +#define ESC_VSWITCH 0x800 | VSWITCHIE /* Escape VSwitch */ #define CST 0x14 /* Call State i.e. */ #define PI 0x1E /* Progress Indicator */ #define NI 0x27 /* Notification Ind */ @@ -903,25 +903,25 @@ struct async_s { typedef struct li_config_s LI_CONFIG; struct xconnect_card_address_s { - dword low; - dword high; + dword low; + dword high; }; struct xconnect_transfer_address_s { - struct xconnect_card_address_s card_address; - dword offset; + struct xconnect_card_address_s card_address; + dword offset; }; struct li_config_s { - DIVA_CAPI_ADAPTER *adapter; - PLCI *plci; - struct xconnect_transfer_address_s send_b; - struct xconnect_transfer_address_s send_pc; - byte *flag_table; /* dword aligned and sized */ - byte *coef_table; /* dword aligned and sized */ - byte channel; - byte curchnl; - byte chflags; + DIVA_CAPI_ADAPTER *adapter; + PLCI *plci; + struct xconnect_transfer_address_s send_b; + struct xconnect_transfer_address_s send_pc; + byte *flag_table; /* dword aligned and sized */ + byte *coef_table; /* dword aligned and sized */ + byte channel; + byte curchnl; + byte chflags; }; extern LI_CONFIG *li_config_table; @@ -1110,33 +1110,33 @@ extern word li_total_channels; #define B1_PIAFS 29 #define B2_PIAFS 29 -#define PRIVATE_PIAFS 29 +#define PRIVATE_PIAFS 29 /* B2 configuration for PIAFS: -+---------------------+------+-----------------------------------------+ -| PIAFS Protocol | byte | Bit 1 - Protocol Speed | -| Speed configuration | | 0 - 32K | -| | | 1 - 64K (default) | -| | | Bit 2 - Variable Protocol Speed | -| | | 0 - Speed is fix | -| | | 1 - Speed is variable (default) | -+---------------------+------+-----------------------------------------+ -| Direction | word | Enable compression/decompression for | -| | | 0: All direction | -| | | 1: disable outgoing data | -| | | 2: disable incomming data | -| | | 3: disable both direction (default) | -+---------------------+------+-----------------------------------------+ -| Number of code | word | Parameter P1 of V.42bis in accordance | -| words | | with V.42bis | -+---------------------+------+-----------------------------------------+ -| Maximum String | word | Parameter P2 of V.42bis in accordance | -| Length | | with V.42bis | -+---------------------+------+-----------------------------------------+ -| control (UDATA) | byte | enable PIAFS control communication | -| abilities | | | -+---------------------+------+-----------------------------------------+ + +---------------------+------+-----------------------------------------+ + | PIAFS Protocol | byte | Bit 1 - Protocol Speed | + | Speed configuration | | 0 - 32K | + | | | 1 - 64K (default) | + | | | Bit 2 - Variable Protocol Speed | + | | | 0 - Speed is fix | + | | | 1 - Speed is variable (default) | + +---------------------+------+-----------------------------------------+ + | Direction | word | Enable compression/decompression for | + | | | 0: All direction | + | | | 1: disable outgoing data | + | | | 2: disable incomming data | + | | | 3: disable both direction (default) | + +---------------------+------+-----------------------------------------+ + | Number of code | word | Parameter P1 of V.42bis in accordance | + | words | | with V.42bis | + +---------------------+------+-----------------------------------------+ + | Maximum String | word | Parameter P2 of V.42bis in accordance | + | Length | | with V.42bis | + +---------------------+------+-----------------------------------------+ + | control (UDATA) | byte | enable PIAFS control communication | + | abilities | | | + +---------------------+------+-----------------------------------------+ */ #define PIAFS_UDATA_ABILITIES 0x80 diff --git a/drivers/isdn/hardware/eicon/divamnt.c b/drivers/isdn/hardware/eicon/divamnt.c index f1d464f1e107..ffa0c31be745 100644 --- a/drivers/isdn/hardware/eicon/divamnt.c +++ b/drivers/isdn/hardware/eicon/divamnt.c @@ -38,7 +38,7 @@ static unsigned long diva_dbg_mem = 0; module_param(diva_dbg_mem, ulong, 0); static char *DRIVERNAME = - "Eicon DIVA - MAINT module (http://www.melware.net)"; + "Eicon DIVA - MAINT module (http://www.melware.net)"; static char *DRIVERLNAME = "diva_mnt"; static char *DEVNAME = "DivasMAINT"; char *DRIVERRELEASE_MNT = "2.0"; @@ -86,7 +86,7 @@ int diva_os_copy_from_user(void *os_handle, void *dst, const void __user *src, /* * get time */ -void diva_os_get_time(dword * sec, dword * usec) +void diva_os_get_time(dword *sec, dword *usec) { struct timeval tv; @@ -115,7 +115,7 @@ void diva_os_get_time(dword * sec, dword * usec) /* * device node operations */ -static unsigned int maint_poll(struct file *file, poll_table * wait) +static unsigned int maint_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; @@ -153,18 +153,18 @@ static int maint_close(struct inode *ino, struct file *filep) /* clear 'used' flag */ clear_bit(0, &opened); - + return (0); } static ssize_t divas_maint_write(struct file *file, const char __user *buf, - size_t count, loff_t * ppos) + size_t count, loff_t *ppos) { return (maint_read_write((char __user *) buf, (int) count)); } static ssize_t divas_maint_read(struct file *file, char __user *buf, - size_t count, loff_t * ppos) + size_t count, loff_t *ppos) { return (maint_read_write(buf, (int) count)); } @@ -238,7 +238,7 @@ static int DIVA_INIT_FUNCTION maint_init(void) DRIVERLNAME, buffer, (buffer_length / 1024), (diva_dbg_mem == 0) ? "internal" : "external", major); - out: +out: return (ret); } @@ -255,4 +255,3 @@ static void DIVA_EXIT_FUNCTION maint_exit(void) module_init(maint_init); module_exit(maint_exit); - diff --git a/drivers/isdn/hardware/eicon/divasfunc.c b/drivers/isdn/hardware/eicon/divasfunc.c index 0bbee7824d78..60aaf9580956 100644 --- a/drivers/isdn/hardware/eicon/divasfunc.c +++ b/drivers/isdn/hardware/eicon/divasfunc.c @@ -34,7 +34,7 @@ static DESCRIPTOR DAdapter; static DESCRIPTOR MAdapter; /* -------------------------------------------------------------------------- - MAINT driver connector section + MAINT driver connector section -------------------------------------------------------------------------- */ static void no_printf(unsigned char *x, ...) { @@ -74,17 +74,17 @@ void diva_xdi_didd_register_adapter(int card) d.features = IoAdapters[card - 1]->Properties.Features; DBG_TRC(("DIDD register A(%d) channels=%d", card, d.channels)) - /* workaround for different Name in structure */ - strlcpy(IoAdapters[card - 1]->Name, - IoAdapters[card - 1]->Properties.Name, - sizeof(IoAdapters[card - 1]->Name)); + /* workaround for different Name in structure */ + strlcpy(IoAdapters[card - 1]->Name, + IoAdapters[card - 1]->Properties.Name, + sizeof(IoAdapters[card - 1]->Name)); req.didd_remove_adapter.e.Req = 0; req.didd_add_adapter.e.Rc = IDI_SYNC_REQ_DIDD_ADD_ADAPTER; req.didd_add_adapter.info.descriptor = (void *) &d; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); if (req.didd_add_adapter.e.Rc != 0xff) { DBG_ERR(("DIDD register A(%d) failed !", card)) - } + } IoAdapters[card - 1]->os_trap_nfy_Fnc = NULL; } } @@ -99,11 +99,11 @@ void diva_xdi_didd_remove_adapter(int card) IoAdapters[card - 1]->os_trap_nfy_Fnc = NULL; DBG_TRC(("DIDD de-register A(%d)", card)) - req.didd_remove_adapter.e.Req = 0; + req.didd_remove_adapter.e.Req = 0; req.didd_remove_adapter.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER; req.didd_remove_adapter.info.p_request = - (IDI_CALL) Requests[card - 1]; - DAdapter.request((ENTITY *) & req); + (IDI_CALL) Requests[card - 1]; + DAdapter.request((ENTITY *)&req); memset(&(a->IdTable), 0x00, 256); } @@ -115,7 +115,7 @@ static void start_dbg(void) DbgRegister("DIVAS", DRIVERRELEASE_DIVAS, (debugmask) ? debugmask : DBG_DEFAULT); DBG_LOG(("DIVA ISDNXDI BUILD (%s[%s])", DIVA_BUILD, diva_xdi_common_code_build)) -} + } /* * stop debug @@ -130,7 +130,7 @@ static void stop_dbg(void) /* * didd callback function */ -static void *didd_callback(void *context, DESCRIPTOR * adapter, +static void *didd_callback(void *context, DESCRIPTOR *adapter, int removal) { if (adapter->type == IDI_DADAPTER) { @@ -168,10 +168,10 @@ static int DIVA_INIT_FUNCTION connect_didd(void) memcpy(&DAdapter, &DIDD_Table[x], sizeof(DAdapter)); req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = - IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; + IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; req.didd_notify.info.callback = (void *)didd_callback; req.didd_notify.info.context = NULL; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); if (req.didd_notify.e.Rc != 0xff) { stop_dbg(); return (0); @@ -203,7 +203,7 @@ static void disconnect_didd(void) req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY; req.didd_notify.info.handle = notify_handle; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); } /* @@ -214,10 +214,10 @@ int DIVA_INIT_FUNCTION divasfunc_init(int dbgmask) char *version; debugmask = dbgmask; - + if (!connect_didd()) { DBG_ERR(("divasfunc: failed to connect to DIDD.")) - return (0); + return (0); } version = diva_xdi_common_code_build; diff --git a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c index 42d3b8346034..a5c8f90b3b37 100644 --- a/drivers/isdn/hardware/eicon/divasi.c +++ b/drivers/isdn/hardware/eicon/divasi.c @@ -1,7 +1,7 @@ /* $Id: divasi.c,v 1.25.6.2 2005/01/31 12:22:20 armin Exp $ * * Driver for Eicon DIVA Server ISDN cards. - * User Mode IDI Interface + * User Mode IDI Interface * * Copyright 2000-2003 by Armin Schindler (mac@melware.de) * Copyright 2000-2003 Cytronics & Melware (info@melware.de) @@ -71,10 +71,10 @@ static char *getrev(const char *revision) * LOCALS */ static ssize_t um_idi_read(struct file *file, char __user *buf, size_t count, - loff_t * offset); + loff_t *offset); static ssize_t um_idi_write(struct file *file, const char __user *buf, - size_t count, loff_t * offset); -static unsigned int um_idi_poll(struct file *file, poll_table * wait); + size_t count, loff_t *offset); +static unsigned int um_idi_poll(struct file *file, poll_table *wait); static int um_idi_open(struct inode *inode, struct file *file); static int um_idi_release(struct inode *inode, struct file *file); static int remove_entity(void *entity); @@ -194,7 +194,7 @@ static int DIVA_INIT_FUNCTION divasi_init(void) } printk(KERN_INFO "%s: started with major %d\n", DRIVERLNAME, major); - out: +out: return (ret); } @@ -228,7 +228,7 @@ divas_um_idi_copy_to_user(void *os_handle, void *dst, const void *src, } static ssize_t -um_idi_read(struct file *file, char __user *buf, size_t count, loff_t * offset) +um_idi_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { diva_um_idi_os_context_t *p_os; int ret = -EINVAL; @@ -292,7 +292,7 @@ static int um_idi_open_adapter(struct file *file, int adapter_nr) { diva_um_idi_os_context_t *p_os; void *e = - divas_um_idi_create_entity((dword) adapter_nr, (void *) file); + divas_um_idi_create_entity((dword) adapter_nr, (void *) file); if (!(file->private_data = e)) { return (0); @@ -310,7 +310,7 @@ static int um_idi_open_adapter(struct file *file, int adapter_nr) static ssize_t um_idi_write(struct file *file, const char __user *buf, size_t count, - loff_t * offset) + loff_t *offset) { diva_um_idi_os_context_t *p_os; int ret = -EINVAL; @@ -331,8 +331,8 @@ um_idi_write(struct file *file, const char __user *buf, size_t count, } if (!(p_os = - (diva_um_idi_os_context_t *) diva_um_id_get_os_context(file-> - private_data))) + (diva_um_idi_os_context_t *) diva_um_id_get_os_context(file-> + private_data))) { return (-ENODEV); } @@ -367,7 +367,7 @@ um_idi_write(struct file *file, const char __user *buf, size_t count, return (ret); } -static unsigned int um_idi_poll(struct file *file, poll_table * wait) +static unsigned int um_idi_poll(struct file *file, poll_table *wait) { diva_um_idi_os_context_t *p_os; @@ -417,7 +417,7 @@ static int um_idi_release(struct inode *inode, struct file *file) } if (!(p_os = - (diva_um_idi_os_context_t *) diva_um_id_get_os_context(file->private_data))) { + (diva_um_idi_os_context_t *) diva_um_id_get_os_context(file->private_data))) { ret = -ENODEV; goto out; } @@ -434,7 +434,7 @@ static int um_idi_release(struct inode *inode, struct file *file) goto out; } - out: +out: return (ret); } @@ -446,14 +446,14 @@ int diva_os_get_context_size(void) void diva_os_wakeup_read(void *os_context) { diva_um_idi_os_context_t *p_os = - (diva_um_idi_os_context_t *) os_context; + (diva_um_idi_os_context_t *) os_context; wake_up_interruptible(&p_os->read_wait); } void diva_os_wakeup_close(void *os_context) { diva_um_idi_os_context_t *p_os = - (diva_um_idi_os_context_t *) os_context; + (diva_um_idi_os_context_t *) os_context; wake_up_interruptible(&p_os->close_wait); } @@ -466,7 +466,7 @@ void diva_um_timer_function(unsigned long data) wake_up_interruptible(&p_os->read_wait); wake_up_interruptible(&p_os->close_wait); DBG_ERR(("entity removal watchdog")) -} + } /* ** If application exits without entity removal this function will remove @@ -481,30 +481,30 @@ static int remove_entity(void *entity) if (!entity) { DBG_FTL(("Zero entity on remove")) - return (0); + return (0); } if (!(p_os = - (diva_um_idi_os_context_t *) - diva_um_id_get_os_context(entity))) { + (diva_um_idi_os_context_t *) + diva_um_id_get_os_context(entity))) { DBG_FTL(("Zero entity os context on remove")) - return (0); + return (0); } if (!divas_um_idi_entity_assigned(entity) || p_os->aborted) { /* - Entity is not assigned, also can be removed - */ + Entity is not assigned, also can be removed + */ return (0); } DBG_TRC(("E(%08x) check remove", entity)) - /* - If adapter not answers on remove request inside of - 10 Sec, then adapter is dead - */ - diva_um_idi_start_wdog(entity); + /* + If adapter not answers on remove request inside of + 10 Sec, then adapter is dead + */ + diva_um_idi_start_wdog(entity); { DECLARE_WAITQUEUE(wait, curtask); @@ -542,7 +542,7 @@ static int remove_entity(void *entity) DBG_TRC(("E(%08x) remove complete, aborted:%d", entity, p_os->aborted)) - diva_um_idi_stop_wdog(entity); + diva_um_idi_stop_wdog(entity); p_os->aborted = 0; diff --git a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c index f332b60eff6b..7eaab06276f9 100644 --- a/drivers/isdn/hardware/eicon/divasmain.c +++ b/drivers/isdn/hardware/eicon/divasmain.c @@ -50,7 +50,7 @@ module_param(dbgmask, int, 0); MODULE_PARM_DESC(dbgmask, "initial debug mask"); static char *DRIVERNAME = - "Eicon DIVA Server driver (http://www.melware.net)"; + "Eicon DIVA Server driver (http://www.melware.net)"; static char *DRIVERLNAME = "divas"; static char *DEVNAME = "Divas"; char *DRIVERRELEASE_DIVAS = "2.0"; @@ -68,7 +68,7 @@ typedef struct _diva_os_thread_dpc { } diva_os_thread_dpc_t; /* -------------------------------------------------------------------------- - PCI driver interface section + PCI driver interface section -------------------------------------------------------------------------- */ /* vendor, device Vendor and device ID to match (or PCI_ANY_ID) @@ -77,7 +77,7 @@ typedef struct _diva_os_thread_dpc { class, Device class to match. The class_mask tells which bits class_mask of the class are honored during the comparison. driver_data Data private to the driver. - */ +*/ #if !defined(PCI_DEVICE_ID_EICON_MAESTRAP_2) #define PCI_DEVICE_ID_EICON_MAESTRAP_2 0xE015 @@ -109,41 +109,41 @@ typedef struct _diva_os_thread_dpc { /* This table should be sorted by PCI device ID - */ +*/ static struct pci_device_id divas_pci_tbl[] = { /* Diva Server BRI-2M PCI 0xE010 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRA), - CARDTYPE_MAESTRA_PCI }, + CARDTYPE_MAESTRA_PCI }, /* Diva Server 4BRI-8M PCI 0xE012 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAQ), - CARDTYPE_DIVASRV_Q_8M_PCI }, + CARDTYPE_DIVASRV_Q_8M_PCI }, /* Diva Server 4BRI-8M 2.0 PCI 0xE013 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAQ_U), - CARDTYPE_DIVASRV_Q_8M_V2_PCI }, + CARDTYPE_DIVASRV_Q_8M_V2_PCI }, /* Diva Server PRI-30M PCI 0xE014 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAP), - CARDTYPE_DIVASRV_P_30M_PCI }, + CARDTYPE_DIVASRV_P_30M_PCI }, /* Diva Server PRI 2.0 adapter 0xE015 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAP_2), - CARDTYPE_DIVASRV_P_30M_V2_PCI }, + CARDTYPE_DIVASRV_P_30M_V2_PCI }, /* Diva Server Voice 4BRI-8M PCI 0xE016 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_4BRI_VOIP), - CARDTYPE_DIVASRV_VOICE_Q_8M_PCI }, + CARDTYPE_DIVASRV_VOICE_Q_8M_PCI }, /* Diva Server Voice 4BRI-8M 2.0 PCI 0xE017 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_4BRI_2_VOIP), - CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI }, + CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI }, /* Diva Server BRI-2M 2.0 PCI 0xE018 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_BRI2M_2), - CARDTYPE_DIVASRV_B_2M_V2_PCI }, + CARDTYPE_DIVASRV_B_2M_V2_PCI }, /* Diva Server Voice PRI 2.0 PCI 0xE019 */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRAP_2_VOIP), - CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI }, + CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI }, /* Diva Server 2FX 0xE01A */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_2F), - CARDTYPE_DIVASRV_B_2F_PCI }, + CARDTYPE_DIVASRV_B_2F_PCI }, /* Diva Server Voice BRI-2M 2.0 PCI 0xE01B */ { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_BRI2M_2_VOIP), - CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI }, + CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI }, { 0, } /* 0 terminated list. */ }; MODULE_DEVICE_TABLE(pci, divas_pci_tbl); @@ -197,7 +197,7 @@ void divas_get_version(char *p) } /* -------------------------------------------------------------------------- - PCI Bus services + PCI Bus services -------------------------------------------------------------------------- */ byte diva_os_get_pci_bus(void *pci_dev_handle) { @@ -332,10 +332,10 @@ void PCIread(byte bus, byte func, int offset, void *data, int length, Init map with DMA pages. It is not problem if some allocations fail - the channels that will not get one DMA page will use standard PIO interface - */ +*/ static void *diva_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, - dma_addr_t * dma_handle, + dma_addr_t *dma_handle, void **addr_handle) { void *addr = pci_alloc_consistent(hwdev, size, dma_handle); @@ -350,7 +350,7 @@ void diva_init_dma_map(void *hdev, { struct pci_dev *pdev = (struct pci_dev *) hdev; struct _diva_dma_map_entry *pmap = - diva_alloc_dma_map(hdev, nentries); + diva_alloc_dma_map(hdev, nentries); if (pmap) { int i; @@ -381,7 +381,7 @@ void diva_init_dma_map(void *hdev, /* Free all contained in the map entries and memory used by the map Should be always called after adapter removal from DIDD array - */ +*/ void diva_free_dma_map(void *hdev, struct _diva_dma_map_entry *pmap) { struct pci_dev *pdev = (struct pci_dev *) hdev; @@ -403,14 +403,14 @@ void diva_free_dma_map(void *hdev, struct _diva_dma_map_entry *pmap) DBG_TRC(("dma map free [%d]=(%08lx:%08x:%08lx)", i, (unsigned long) cpu_addr, (dword) dma_handle, (unsigned long) addr_handle)) - } + } diva_free_dma_mapping(pmap); } /********************************************************* - ** I/O port utilities + ** I/O port utilities *********************************************************/ int @@ -420,7 +420,7 @@ diva_os_register_io_port(void *adapter, int on, unsigned long port, if (on) { if (!request_region(port, length, name)) { DBG_ERR(("A: I/O: can't register port=%08x", port)) - return (-1); + return (-1); } } else { release_region(port, length); @@ -443,7 +443,7 @@ void divasa_unmap_pci_bar(void __iomem *bar) } /********************************************************* - ** I/O port access + ** I/O port access *********************************************************/ byte __inline__ inpp(void __iomem *addr) { @@ -476,7 +476,7 @@ void __inline__ outpp(void __iomem *addr, word p) } /* -------------------------------------------------------------------------- - IRQ request / remove + IRQ request / remove -------------------------------------------------------------------------- */ int diva_os_register_irq(void *context, byte irq, const char *name) { @@ -491,7 +491,7 @@ void diva_os_remove_irq(void *context, byte irq) } /* -------------------------------------------------------------------------- - DPC framework implementation + DPC framework implementation -------------------------------------------------------------------------- */ static void diva_os_dpc_proc(unsigned long context) { @@ -501,7 +501,7 @@ static void diva_os_dpc_proc(unsigned long context) (*(pisr->callback)) (pisr, pisr->callback_context); } -int diva_os_initialize_soft_isr(diva_os_soft_isr_t * psoft_isr, +int diva_os_initialize_soft_isr(diva_os_soft_isr_t *psoft_isr, diva_os_soft_isr_callback_t callback, void *callback_context) { @@ -520,11 +520,11 @@ int diva_os_initialize_soft_isr(diva_os_soft_isr_t * psoft_isr, return (0); } -int diva_os_schedule_soft_isr(diva_os_soft_isr_t * psoft_isr) +int diva_os_schedule_soft_isr(diva_os_soft_isr_t *psoft_isr) { if (psoft_isr && psoft_isr->object) { diva_os_thread_dpc_t *pdpc = - (diva_os_thread_dpc_t *) psoft_isr->object; + (diva_os_thread_dpc_t *) psoft_isr->object; tasklet_schedule(&pdpc->divas_task); } @@ -532,16 +532,16 @@ int diva_os_schedule_soft_isr(diva_os_soft_isr_t * psoft_isr) return (1); } -int diva_os_cancel_soft_isr(diva_os_soft_isr_t * psoft_isr) +int diva_os_cancel_soft_isr(diva_os_soft_isr_t *psoft_isr) { return (0); } -void diva_os_remove_soft_isr(diva_os_soft_isr_t * psoft_isr) +void diva_os_remove_soft_isr(diva_os_soft_isr_t *psoft_isr) { if (psoft_isr && psoft_isr->object) { diva_os_thread_dpc_t *pdpc = - (diva_os_thread_dpc_t *) psoft_isr->object; + (diva_os_thread_dpc_t *) psoft_isr->object; void *mem; tasklet_kill(&pdpc->divas_task); @@ -589,7 +589,7 @@ static int divas_release(struct inode *inode, struct file *file) } static ssize_t divas_write(struct file *file, const char __user *buf, - size_t count, loff_t * ppos) + size_t count, loff_t *ppos) { int ret = -EINVAL; @@ -620,7 +620,7 @@ static ssize_t divas_write(struct file *file, const char __user *buf, } static ssize_t divas_read(struct file *file, char __user *buf, - size_t count, loff_t * ppos) + size_t count, loff_t *ppos) { int ret = -EINVAL; @@ -650,7 +650,7 @@ static ssize_t divas_read(struct file *file, char __user *buf, return (ret); } -static unsigned int divas_poll(struct file *file, poll_table * wait) +static unsigned int divas_poll(struct file *file, poll_table *wait) { if (!file->private_data) { return (POLLERR); @@ -686,7 +686,7 @@ static int DIVA_INIT_FUNCTION divas_register_chrdev(void) } /* -------------------------------------------------------------------------- - PCI driver section + PCI driver section -------------------------------------------------------------------------- */ static int __devinit divas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) @@ -698,9 +698,9 @@ static int __devinit divas_init_one(struct pci_dev *pdev, DBG_TRC(("%s bus: %08x fn: %08x insertion.\n", CardProperties[ent->driver_data].Name, pdev->bus->number, pdev->devfn)) - printk(KERN_INFO "%s: %s bus: %08x fn: %08x insertion.\n", - DRIVERLNAME, CardProperties[ent->driver_data].Name, - pdev->bus->number, pdev->devfn); + printk(KERN_INFO "%s: %s bus: %08x fn: %08x insertion.\n", + DRIVERLNAME, CardProperties[ent->driver_data].Name, + pdev->bus->number, pdev->devfn); if (pci_enable_device(pdev)) { DBG_TRC(("%s: %s bus: %08x fn: %08x device init failed.\n", @@ -708,12 +708,12 @@ static int __devinit divas_init_one(struct pci_dev *pdev, CardProperties[ent->driver_data].Name, pdev->bus->number, pdev->devfn)) - printk(KERN_ERR - "%s: %s bus: %08x fn: %08x device init failed.\n", - DRIVERLNAME, - CardProperties[ent->driver_data]. - Name, pdev->bus->number, - pdev->devfn); + printk(KERN_ERR + "%s: %s bus: %08x fn: %08x device init failed.\n", + DRIVERLNAME, + CardProperties[ent->driver_data]. + Name, pdev->bus->number, + pdev->devfn); return (-EIO); } @@ -723,9 +723,9 @@ static int __devinit divas_init_one(struct pci_dev *pdev, if (!pci_latency) { DBG_TRC(("%s: bus: %08x fn: %08x fix latency.\n", DRIVERLNAME, pdev->bus->number, pdev->devfn)) - printk(KERN_INFO - "%s: bus: %08x fn: %08x fix latency.\n", - DRIVERLNAME, pdev->bus->number, pdev->devfn); + printk(KERN_INFO + "%s: bus: %08x fn: %08x fix latency.\n", + DRIVERLNAME, pdev->bus->number, pdev->devfn); pci_write_config_byte(pdev, PCI_LATENCY_TIMER, new_latency); } @@ -735,12 +735,12 @@ static int __devinit divas_init_one(struct pci_dev *pdev, CardProperties[ent->driver_data].Name, pdev->bus->number, pdev->devfn)) - printk(KERN_ERR - "%s: %s bus: %08x fn: %08x card init failed.\n", - DRIVERLNAME, - CardProperties[ent->driver_data]. - Name, pdev->bus->number, - pdev->devfn); + printk(KERN_ERR + "%s: %s bus: %08x fn: %08x card init failed.\n", + DRIVERLNAME, + CardProperties[ent->driver_data]. + Name, pdev->bus->number, + pdev->devfn); return (-EIO); } @@ -755,8 +755,8 @@ static void __devexit divas_remove_one(struct pci_dev *pdev) DBG_TRC(("bus: %08x fn: %08x removal.\n", pdev->bus->number, pdev->devfn)) - printk(KERN_INFO "%s: bus: %08x fn: %08x removal.\n", - DRIVERLNAME, pdev->bus->number, pdev->devfn); + printk(KERN_INFO "%s: bus: %08x fn: %08x removal.\n", + DRIVERLNAME, pdev->bus->number, pdev->devfn); if (pdiva) { diva_driver_remove_card(pdiva); @@ -765,7 +765,7 @@ static void __devexit divas_remove_one(struct pci_dev *pdev) } /* -------------------------------------------------------------------------- - Driver Load / Startup + Driver Load / Startup -------------------------------------------------------------------------- */ static int DIVA_INIT_FUNCTION divas_init(void) { @@ -824,12 +824,12 @@ static int DIVA_INIT_FUNCTION divas_init(void) } printk(KERN_INFO "%s: started with major %d\n", DRIVERLNAME, major); - out: +out: return (ret); } /* -------------------------------------------------------------------------- - Driver Unload + Driver Unload -------------------------------------------------------------------------- */ static void DIVA_EXIT_FUNCTION divas_exit(void) { diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c index 46d44a942624..af4fd3d036c1 100644 --- a/drivers/isdn/hardware/eicon/divasproc.c +++ b/drivers/isdn/hardware/eicon/divasproc.c @@ -55,7 +55,7 @@ extern struct proc_dir_entry *proc_net_eicon; static struct proc_dir_entry *divas_proc_entry = NULL; static ssize_t -divas_read(struct file *file, char __user *buf, size_t count, loff_t * off) +divas_read(struct file *file, char __user *buf, size_t count, loff_t *off) { int len = 0; int cadapter; @@ -94,12 +94,12 @@ divas_read(struct file *file, char __user *buf, size_t count, loff_t * off) } static ssize_t -divas_write(struct file *file, const char __user *buf, size_t count, loff_t * off) +divas_write(struct file *file, const char __user *buf, size_t count, loff_t *off) { return (-ENODEV); } -static unsigned int divas_poll(struct file *file, poll_table * wait) +static unsigned int divas_poll(struct file *file, poll_table *wait) { return (POLLERR); } @@ -127,7 +127,7 @@ static const struct file_operations divas_fops = { int create_divas_proc(void) { divas_proc_entry = proc_create(divas_proc_name, S_IFREG | S_IRUGO, - proc_net_eicon, &divas_fops); + proc_net_eicon, &divas_fops); if (!divas_proc_entry) return (0); @@ -155,11 +155,11 @@ static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer, switch (c) { case '0': IoAdapter->capi_cfg.cfg_1 &= - ~DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; + ~DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; break; case '1': IoAdapter->capi_cfg.cfg_1 |= - DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; + DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; break; default: return (-EINVAL); @@ -182,11 +182,11 @@ static ssize_t d_l1_down_proc_write(struct file *file, const char __user *buffer switch (c) { case '0': IoAdapter->capi_cfg.cfg_1 &= - ~DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; + ~DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; break; case '1': IoAdapter->capi_cfg.cfg_1 |= - DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; + DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; break; default: return (-EINVAL); @@ -202,9 +202,9 @@ static int d_l1_down_proc_show(struct seq_file *m, void *v) PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; seq_printf(m, "%s\n", - (IoAdapter->capi_cfg. - cfg_1 & DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? "1" : - "0"); + (IoAdapter->capi_cfg. + cfg_1 & DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? "1" : + "0"); return 0; } @@ -228,9 +228,9 @@ static int grp_opt_proc_show(struct seq_file *m, void *v) PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; seq_printf(m, "%s\n", - (IoAdapter->capi_cfg. - cfg_1 & DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) - ? "1" : "0"); + (IoAdapter->capi_cfg. + cfg_1 & DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) + ? "1" : "0"); return 0; } @@ -281,7 +281,7 @@ static int info_proc_show(struct seq_file *m, void *v) seq_printf(m, "DSP state : %08x\n", a->dsp_mask); seq_printf(m, "Channels : %02d\n", IoAdapter->Properties.Channels); seq_printf(m, "E. max/used : %03d/%03d\n", - IoAdapter->e_max, IoAdapter->e_count); + IoAdapter->e_max, IoAdapter->e_count); diva_get_vserial_number(IoAdapter, tmpser); seq_printf(m, "Serial : %s\n", tmpser); seq_printf(m, "IRQ : %d\n", IoAdapter->irq_info.irq_nr); @@ -289,8 +289,8 @@ static int info_proc_show(struct seq_file *m, void *v) seq_printf(m, "CardOrdinal : %d\n", a->CardOrdinal); seq_printf(m, "Controller : %d\n", a->controller); seq_printf(m, "Bus-Type : %s\n", - (a->Bus == - DIVAS_XDI_ADAPTER_BUS_ISA) ? "ISA" : "PCI"); + (a->Bus == + DIVAS_XDI_ADAPTER_BUS_ISA) ? "ISA" : "PCI"); seq_printf(m, "Port-Name : %s\n", a->port_name); if (a->Bus == DIVAS_XDI_ADAPTER_BUS_PCI) { seq_printf(m, "PCI-bus : %d\n", a->resources.pci.bus); @@ -298,15 +298,15 @@ static int info_proc_show(struct seq_file *m, void *v) for (i = 0; i < 8; i++) { if (a->resources.pci.bar[i]) { seq_printf(m, - "Mem / I/O %d : 0x%x / mapped : 0x%lx", - i, a->resources.pci.bar[i], - (unsigned long) a->resources. - pci.addr[i]); + "Mem / I/O %d : 0x%x / mapped : 0x%lx", + i, a->resources.pci.bar[i], + (unsigned long) a->resources. + pci.addr[i]); if (a->resources.pci.length[i]) { seq_printf(m, - " / length : %d", - a->resources.pci. - length[i]); + " / length : %d", + a->resources.pci. + length[i]); } seq_putc(m, '\n'); } @@ -314,7 +314,7 @@ static int info_proc_show(struct seq_file *m, void *v) } if ((!a->xdi_adapter.port) && ((!a->xdi_adapter.ram) || - (!a->xdi_adapter.reset) + (!a->xdi_adapter.reset) || (!a->xdi_adapter.cfg))) { if (!IoAdapter->irq_info.irq_nr) { p = "slave"; @@ -352,9 +352,9 @@ static const struct file_operations info_proc_fops = { */ /* -------------------------------------------------------------------------- - Create adapter directory and files in proc file system + Create adapter directory and files in proc file system -------------------------------------------------------------------------- */ -int create_adapter_proc(diva_os_xdi_adapter_t * a) +int create_adapter_proc(diva_os_xdi_adapter_t *a) { struct proc_dir_entry *de, *pe; char tmp[16]; @@ -385,9 +385,9 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a) } /* -------------------------------------------------------------------------- - Remove adapter directory and files in proc file system + Remove adapter directory and files in proc file system -------------------------------------------------------------------------- */ -void remove_adapter_proc(diva_os_xdi_adapter_t * a) +void remove_adapter_proc(diva_os_xdi_adapter_t *a) { char tmp[16]; diff --git a/drivers/isdn/hardware/eicon/divasync.h b/drivers/isdn/hardware/eicon/divasync.h index 85784a7ffb25..dd6b53a2c2c8 100644 --- a/drivers/isdn/hardware/eicon/divasync.h +++ b/drivers/isdn/hardware/eicon/divasync.h @@ -1,29 +1,29 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#ifndef __DIVA_SYNC__H +#ifndef __DIVA_SYNC__H #define __DIVA_SYNC__H #define IDI_SYNC_REQ_REMOVE 0x00 #define IDI_SYNC_REQ_GET_NAME 0x01 @@ -59,26 +59,26 @@ /******************************************************************************/ #define IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES 0x92 /* - To receive XDI features: - 1. set 'buffer_length_in_bytes' to length of you buffer - 2. set 'features' to pointer to your buffer - 3. issue synchronous request to XDI - 4. Check that feature 'DIVA_XDI_EXTENDED_FEATURES_VALID' is present - after call. This feature does indicate that your request - was processed and XDI does support this synchronous request - 5. if on return bit 31 (0x80000000) in 'buffer_length_in_bytes' is - set then provided buffer was too small, and bits 30-0 does - contain necessary length of buffer. - in this case only features that do find place in the buffer - are indicated to caller + To receive XDI features: + 1. set 'buffer_length_in_bytes' to length of you buffer + 2. set 'features' to pointer to your buffer + 3. issue synchronous request to XDI + 4. Check that feature 'DIVA_XDI_EXTENDED_FEATURES_VALID' is present + after call. This feature does indicate that your request + was processed and XDI does support this synchronous request + 5. if on return bit 31 (0x80000000) in 'buffer_length_in_bytes' is + set then provided buffer was too small, and bits 30-0 does + contain necessary length of buffer. + in this case only features that do find place in the buffer + are indicated to caller */ typedef struct _diva_xdi_get_extended_xdi_features { - dword buffer_length_in_bytes; - byte *features; + dword buffer_length_in_bytes; + byte *features; } diva_xdi_get_extended_xdi_features_t; /* - features[0] - */ + features[0] +*/ #define DIVA_XDI_EXTENDED_FEATURES_VALID 0x01 #define DIVA_XDI_EXTENDED_FEATURE_CMA 0x02 #define DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR 0x04 @@ -91,17 +91,17 @@ typedef struct _diva_xdi_get_extended_xdi_features { /******************************************************************************/ #define IDI_SYNC_REQ_XDI_GET_ADAPTER_SDRAM_BAR 0x93 typedef struct _diva_xdi_get_adapter_sdram_bar { - dword bar; + dword bar; } diva_xdi_get_adapter_sdram_bar_t; /******************************************************************************/ #define IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS 0x94 /* CAPI Parameters will be written in the caller's buffer - */ +*/ typedef struct _diva_xdi_get_capi_parameters { - dword structure_length; - byte flag_dynamic_l1_down; - byte group_optimization_enabled; + dword structure_length; + byte flag_dynamic_l1_down; + byte group_optimization_enabled; } diva_xdi_get_capi_parameters_t; /******************************************************************************/ #define IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER 0x95 @@ -111,11 +111,11 @@ typedef struct _diva_xdi_get_capi_parameters { in case of one adapter that supports multiple interfaces 'controller' is zero for Master adapter (and adapter that supports only one interface) - */ +*/ typedef struct _diva_xdi_get_logical_adapter_number { - dword logical_adapter_number; - dword controller; - dword total_controllers; + dword logical_adapter_number; + dword controller; + dword total_controllers; } diva_xdi_get_logical_adapter_number_s_t; /******************************************************************************/ #define IDI_SYNC_REQ_UP1DM_OPERATION 0x96 @@ -124,10 +124,10 @@ typedef struct _diva_xdi_get_logical_adapter_number { #define IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC 0x01 #define IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE 0x02 typedef struct _diva_xdi_dma_descriptor_operation { - int operation; - int descriptor_number; - void* descriptor_address; - dword descriptor_magic; + int operation; + int descriptor_number; + void *descriptor_address; + dword descriptor_magic; } diva_xdi_dma_descriptor_operation_t; /******************************************************************************/ #define IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY 0x01 @@ -137,22 +137,22 @@ typedef struct _diva_xdi_dma_descriptor_operation { #define IDI_SYNC_REQ_DIDD_READ_ADAPTER_ARRAY 0x05 #define IDI_SYNC_REQ_DIDD_GET_CFG_LIB_IFC 0x10 typedef struct _diva_didd_adapter_notify { - dword handle; /* Notification handle */ - void * callback; - void * context; + dword handle; /* Notification handle */ + void *callback; + void *context; } diva_didd_adapter_notify_t; typedef struct _diva_didd_add_adapter { - void * descriptor; + void *descriptor; } diva_didd_add_adapter_t; typedef struct _diva_didd_remove_adapter { - IDI_CALL p_request; + IDI_CALL p_request; } diva_didd_remove_adapter_t; typedef struct _diva_didd_read_adapter_array { - void * buffer; - dword length; + void *buffer; + dword length; } diva_didd_read_adapter_array_t; typedef struct _diva_didd_get_cfg_lib_ifc { - void* ifc; + void *ifc; } diva_didd_get_cfg_lib_ifc_t; /******************************************************************************/ #define IDI_SYNC_REQ_XDI_GET_STREAM 0x91 @@ -163,31 +163,31 @@ typedef struct _diva_didd_get_cfg_lib_ifc { #define DIVA_ISTREAM_COMPLETE_READ 1 #define DIVA_ISTREAM_COMPLETE_WRITE 2 typedef struct _diva_xdi_stream_interface { - unsigned char Id; /* filled by XDI client */ - unsigned char provided_service; /* filled by XDI */ - unsigned char requested_service; /* filled by XDI Client */ - void* xdi_context; /* filled by XDI */ - void* client_context; /* filled by XDI client */ - int (*write)(void* context, - int Id, - void* data, - int length, - int final, - byte usr1, - byte usr2); - int (*read)(void* context, - int Id, - void* data, - int max_length, - int* final, - byte* usr1, - byte* usr2); - int (*complete)(void* client_context, - int Id, - int what, - void* data, - int length, - int* final); + unsigned char Id; /* filled by XDI client */ + unsigned char provided_service; /* filled by XDI */ + unsigned char requested_service; /* filled by XDI Client */ + void *xdi_context; /* filled by XDI */ + void *client_context; /* filled by XDI client */ + int (*write)(void *context, + int Id, + void *data, + int length, + int final, + byte usr1, + byte usr2); + int (*read)(void *context, + int Id, + void *data, + int max_length, + int *final, + byte *usr1, + byte *usr2); + int (*complete)(void *client_context, + int Id, + int what, + void *data, + int length, + int *final); } diva_xdi_stream_interface_t; /******************************************************************************/ /* @@ -196,37 +196,37 @@ typedef struct _diva_xdi_stream_interface { typedef struct { unsigned char LineState; /* Modem line state (STATUS_R) */ #define SERIAL_GSM_CELL 0x01 /* GSM or CELL cable attached */ - unsigned char CardState; /* PCMCIA card state (0 = down) */ - unsigned char IsdnState; /* ISDN layer 1 state (0 = down)*/ - unsigned char HookState; /* current logical hook state */ + unsigned char CardState; /* PCMCIA card state (0 = down) */ + unsigned char IsdnState; /* ISDN layer 1 state (0 = down)*/ + unsigned char HookState; /* current logical hook state */ #define SERIAL_ON_HOOK 0x02 /* set in DIVA CTRL_R register */ } SERIAL_STATE; -typedef int ( * SERIAL_INT_CB) (void *Context) ; -typedef int ( * SERIAL_DPC_CB) (void *Context) ; -typedef unsigned char ( * SERIAL_I_SYNC) (void *Context) ; +typedef int (*SERIAL_INT_CB)(void *Context); +typedef int (*SERIAL_DPC_CB)(void *Context); +typedef unsigned char (*SERIAL_I_SYNC)(void *Context); typedef struct { /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */ - unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (is the request) */ - unsigned char Function; /* private function code */ + unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (is the request) */ + unsigned char Function; /* private function code */ #define SERIAL_HOOK_ATTACH 0x81 #define SERIAL_HOOK_STATUS 0x82 #define SERIAL_HOOK_I_SYNC 0x83 #define SERIAL_HOOK_NOECHO 0x84 #define SERIAL_HOOK_RING 0x85 #define SERIAL_HOOK_DETACH 0x8f - unsigned char Flags; /* function refinements */ - /* parameters passed by the ATTACH request */ - SERIAL_INT_CB InterruptHandler; /* called on each interrupt */ - SERIAL_DPC_CB DeferredHandler; /* called on hook state changes */ - void *HandlerContext; /* context for both handlers */ - /* return values for both the ATTACH and the STATUS request */ - unsigned long IoBase; /* IO port assigned to UART */ - SERIAL_STATE State; - /* parameters and return values for the I_SYNC function */ - SERIAL_I_SYNC SyncFunction; /* to be called synchronized */ - void *SyncContext; /* context for this function */ - unsigned char SyncResult; /* return value of function */ + unsigned char Flags; /* function refinements */ + /* parameters passed by the ATTACH request */ + SERIAL_INT_CB InterruptHandler; /* called on each interrupt */ + SERIAL_DPC_CB DeferredHandler; /* called on hook state changes */ + void *HandlerContext; /* context for both handlers */ + /* return values for both the ATTACH and the STATUS request */ + unsigned long IoBase; /* IO port assigned to UART */ + SERIAL_STATE State; + /* parameters and return values for the I_SYNC function */ + SERIAL_I_SYNC SyncFunction; /* to be called synchronized */ + void *SyncContext; /* context for this function */ + unsigned char SyncResult; /* return value of function */ } SERIAL_HOOK; /* * IDI_SYNC_REQ_XCHANGE_STATUS - exchange the status between IDI and WMP @@ -234,22 +234,22 @@ typedef struct */ typedef struct { /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */ - unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (is the request) */ + unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (is the request) */ #define DRIVER_STATUS_BOOT 0xA1 #define DRIVER_STATUS_INIT_DEV 0xA2 #define DRIVER_STATUS_RUNNING 0xA3 #define DRIVER_STATUS_SHUTDOWN 0xAF #define DRIVER_STATUS_TRAPPED 0xAE - unsigned char wmpStatus; /* exported by WMP */ - unsigned char idiStatus; /* exported by IDI */ - unsigned long wizProto ; /* from WMP registry to IDI */ - /* the cardtype value is defined by cardtype.h */ - unsigned long cardType ; /* from IDI registry to WMP */ - unsigned long nt2 ; /* from IDI registry to WMP */ - unsigned long permanent ; /* from IDI registry to WMP */ - unsigned long stableL2 ; /* from IDI registry to WMP */ - unsigned long tei ; /* from IDI registry to WMP */ + unsigned char wmpStatus; /* exported by WMP */ + unsigned char idiStatus; /* exported by IDI */ + unsigned long wizProto; /* from WMP registry to IDI */ + /* the cardtype value is defined by cardtype.h */ + unsigned long cardType; /* from IDI registry to WMP */ + unsigned long nt2; /* from IDI registry to WMP */ + unsigned long permanent; /* from IDI registry to WMP */ + unsigned long stableL2; /* from IDI registry to WMP */ + unsigned long tei; /* from IDI registry to WMP */ #define CRC4_MASK 0x00000003 #define L1_TRISTATE_MASK 0x00000004 #define WATCHDOG_MASK 0x00000008 @@ -271,36 +271,36 @@ typedef struct #define SET_STABLEL2 0x20000000 #define SET_TEI 0x40000000 #define SET_NUMBERLEN 0x80000000 - unsigned long Flag ; /* |31-Type-16|15-Mask-0| */ - unsigned long NumberLen ; /* reconfiguration: union is empty */ - union { - struct { /* possible reconfiguration, but ... ; SET_BOARD */ - unsigned long SerialNumber ; - char *pCardname ; /* di_defs.h: BOARD_NAME_LENGTH */ - } board ; - struct { /* reset: need resources */ - void * pRawResources ; - void * pXlatResources ; - } res ; - struct { /* reconfiguration: wizProto == PROTTYPE_RBSCAS */ + unsigned long Flag; /* |31-Type-16|15-Mask-0| */ + unsigned long NumberLen; /* reconfiguration: union is empty */ + union { + struct { /* possible reconfiguration, but ... ; SET_BOARD */ + unsigned long SerialNumber; + char *pCardname; /* di_defs.h: BOARD_NAME_LENGTH */ + } board; + struct { /* reset: need resources */ + void *pRawResources; + void *pXlatResources; + } res; + struct { /* reconfiguration: wizProto == PROTTYPE_RBSCAS */ #define GLARE_RESOLVE_MASK 0x00000001 #define DID_MASK 0x00000002 #define BEARER_CAP_MASK 0x0000000c #define SET_GLARE_RESOLVE 0x00010000 #define SET_DID 0x00020000 #define SET_BEARER_CAP 0x000c0000 - unsigned long Flag ; /* |31-Type-16|15-VALUE-0| */ - unsigned short DigitTimeout ; - unsigned short AnswerDelay ; - } rbs ; - struct { /* reconfiguration: wizProto == PROTTYPE_QSIG */ + unsigned long Flag; /* |31-Type-16|15-VALUE-0| */ + unsigned short DigitTimeout; + unsigned short AnswerDelay; + } rbs; + struct { /* reconfiguration: wizProto == PROTTYPE_QSIG */ #define CALL_REF_LENGTH1_MASK 0x00000001 #define BRI_CHANNEL_ID_MASK 0x00000002 #define SET_CALL_REF_LENGTH 0x00010000 #define SET_BRI_CHANNEL_ID 0x00020000 - unsigned long Flag ; /* |31-Type-16|15-VALUE-0| */ - } qsig ; - struct { /* reconfiguration: NumberLen != 0 */ + unsigned long Flag; /* |31-Type-16|15-VALUE-0| */ + } qsig; + struct { /* reconfiguration: NumberLen != 0 */ #define SET_SPID1 0x00010000 #define SET_NUMBER1 0x00020000 #define SET_SUBADDRESS1 0x00040000 @@ -308,50 +308,50 @@ typedef struct #define SET_NUMBER2 0x00200000 #define SET_SUBADDRESS2 0x00400000 #define MASK_SET 0xffff0000 - unsigned long Flag ; /* |31-Type-16|15-Channel-0| */ - unsigned char *pBuffer ; /* number value */ - } isdnNo ; - } -parms -; -} isdnProps ; + unsigned long Flag; /* |31-Type-16|15-Channel-0| */ + unsigned char *pBuffer; /* number value */ + } isdnNo; + } + parms + ; +} isdnProps; /* * IDI_SYNC_REQ_PORTDRV_HOOK - signal plug/unplug (Award Cardware only) */ -typedef void ( * PORTDRV_HOOK_CB) (void *Context, int Plug) ; +typedef void (*PORTDRV_HOOK_CB)(void *Context, int Plug); typedef struct { /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */ - unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (is the request) */ - unsigned char Function; /* private function code */ - unsigned char Flags; /* function refinements */ - PORTDRV_HOOK_CB Callback; /* to be called on plug/unplug */ - void *Context; /* context for callback */ - unsigned long Info; /* more info if needed */ -} PORTDRV_HOOK ; + unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (is the request) */ + unsigned char Function; /* private function code */ + unsigned char Flags; /* function refinements */ + PORTDRV_HOOK_CB Callback; /* to be called on plug/unplug */ + void *Context; /* context for callback */ + unsigned long Info; /* more info if needed */ +} PORTDRV_HOOK; /* Codes for the 'Rc' element in structure below. */ #define SLI_INSTALL (0xA1) #define SLI_UNINSTALL (0xA2) -typedef int ( * SLIENTRYPOINT)(void* p3SignalAPI, void* pContext); +typedef int (*SLIENTRYPOINT)(void *p3SignalAPI, void *pContext); typedef struct { /* 'Req' and 'Rc' must be at the same place as in the ENTITY struct */ - unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (is the request) */ - unsigned char Function; /* private function code */ - unsigned char Flags; /* function refinements */ - SLIENTRYPOINT Callback; /* to be called on plug/unplug */ - void *Context; /* context for callback */ - unsigned long Info; /* more info if needed */ -} SLIENTRYPOINT_REQ ; + unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (is the request) */ + unsigned char Function; /* private function code */ + unsigned char Flags; /* function refinements */ + SLIENTRYPOINT Callback; /* to be called on plug/unplug */ + void *Context; /* context for callback */ + unsigned long Info; /* more info if needed */ +} SLIENTRYPOINT_REQ; /******************************************************************************/ /* * Definitions for DIVA USB */ -typedef int ( * USB_SEND_REQ) (unsigned char PipeIndex, unsigned char Type,void *Data, int sizeData); -typedef int ( * USB_START_DEV) (void *Adapter, void *Ipac) ; +typedef int (*USB_SEND_REQ)(unsigned char PipeIndex, unsigned char Type, void *Data, int sizeData); +typedef int (*USB_START_DEV)(void *Adapter, void *Ipac); /* called from WDM */ -typedef void ( * USB_RECV_NOTIFY) (void *Ipac, void *msg) ; -typedef void ( * USB_XMIT_NOTIFY) (void *Ipac, unsigned char PipeIndex) ; +typedef void (*USB_RECV_NOTIFY)(void *Ipac, void *msg); +typedef void (*USB_XMIT_NOTIFY)(void *Ipac, unsigned char PipeIndex); /******************************************************************************/ /* * Parameter description for synchronous requests. @@ -361,129 +361,129 @@ typedef void ( * USB_XMIT_NOTIFY) (void *Ipac, unsigned char PipeIndex) ; */ typedef union { ENTITY Entity; - struct - { /* 'Req' and 'Rc' are at the same place as in the ENTITY struct */ - unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (is the request) */ - } Request; - struct - { unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (0x01) */ - unsigned char name[BOARD_NAME_LENGTH]; - } GetName; - struct - { unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (0x02) */ - unsigned long serial; /* serial number */ - } GetSerial; - struct - { unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (0x02) */ - unsigned long lineIdx;/* line, 0 if card has only one */ - } GetLineIdx; - struct - { unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (0x02) */ - unsigned long cardtype;/* card type */ - } GetCardType; - struct - { unsigned short command;/* command = 0x0300 */ - unsigned short dummy; /* not used */ - IDI_CALL callback;/* routine to call back */ - ENTITY *contxt; /* ptr to entity to use */ - } PostCall; - struct - { unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (0x04) */ - unsigned char pcm[1]; /* buffer (a pc_maint struct) */ - } GetXlog; - struct - { unsigned char Req; /* request (must be always 0) */ - unsigned char Rc; /* return code (0x05) */ - unsigned short features;/* feature defines see below */ - } GetFeatures; - SERIAL_HOOK SerialHook; + struct + { /* 'Req' and 'Rc' are at the same place as in the ENTITY struct */ + unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (is the request) */ + } Request; + struct + { unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (0x01) */ + unsigned char name[BOARD_NAME_LENGTH]; + } GetName; + struct + { unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (0x02) */ + unsigned long serial; /* serial number */ + } GetSerial; + struct + { unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (0x02) */ + unsigned long lineIdx;/* line, 0 if card has only one */ + } GetLineIdx; + struct + { unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (0x02) */ + unsigned long cardtype;/* card type */ + } GetCardType; + struct + { unsigned short command;/* command = 0x0300 */ + unsigned short dummy; /* not used */ + IDI_CALL callback;/* routine to call back */ + ENTITY *contxt; /* ptr to entity to use */ + } PostCall; + struct + { unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (0x04) */ + unsigned char pcm[1]; /* buffer (a pc_maint struct) */ + } GetXlog; + struct + { unsigned char Req; /* request (must be always 0) */ + unsigned char Rc; /* return code (0x05) */ + unsigned short features;/* feature defines see below */ + } GetFeatures; + SERIAL_HOOK SerialHook; /* Added for DIVA USB */ - struct - { unsigned char Req; - unsigned char Rc; - USB_SEND_REQ UsbSendRequest; /* function in Diva Usb WDM driver in usb_os.c, */ - /* called from usb_drv.c to send a message to our device */ - /* eg UsbSendRequest (USB_PIPE_SIGNAL, USB_IPAC_START, 0, 0) ; */ - USB_RECV_NOTIFY usb_recv; /* called from usb_os.c to pass a received message and ptr to IPAC */ - /* on to usb_drv.c by a call to usb_recv(). */ - USB_XMIT_NOTIFY usb_xmit; /* called from usb_os.c in DivaUSB.sys WDM to indicate a completed transmit */ - /* to usb_drv.c by a call to usb_xmit(). */ - USB_START_DEV UsbStartDevice; /* Start the USB Device, in usb_os.c */ - IDI_CALL callback; /* routine to call back */ - ENTITY *contxt; /* ptr to entity to use */ - void ** ipac_ptr; /* pointer to struct IPAC in VxD */ - } Usb_Msg_old; + struct + { unsigned char Req; + unsigned char Rc; + USB_SEND_REQ UsbSendRequest; /* function in Diva Usb WDM driver in usb_os.c, */ + /* called from usb_drv.c to send a message to our device */ + /* eg UsbSendRequest (USB_PIPE_SIGNAL, USB_IPAC_START, 0, 0); */ + USB_RECV_NOTIFY usb_recv; /* called from usb_os.c to pass a received message and ptr to IPAC */ + /* on to usb_drv.c by a call to usb_recv(). */ + USB_XMIT_NOTIFY usb_xmit; /* called from usb_os.c in DivaUSB.sys WDM to indicate a completed transmit */ + /* to usb_drv.c by a call to usb_xmit(). */ + USB_START_DEV UsbStartDevice; /* Start the USB Device, in usb_os.c */ + IDI_CALL callback; /* routine to call back */ + ENTITY *contxt; /* ptr to entity to use */ + void **ipac_ptr; /* pointer to struct IPAC in VxD */ + } Usb_Msg_old; /* message used by WDM and VXD to pass pointers of function and IPAC* */ - struct - { unsigned char Req; - unsigned char Rc; - USB_SEND_REQ pUsbSendRequest;/* function in Diva Usb WDM driver in usb_os.c, */ - /* called from usb_drv.c to send a message to our device */ - /* eg UsbSendRequest (USB_PIPE_SIGNAL, USB_IPAC_START, 0, 0) ; */ - USB_RECV_NOTIFY p_usb_recv; /* called from usb_os.c to pass a received message and ptr to IPAC */ - /* on to usb_drv.c by a call to usb_recv(). */ - USB_XMIT_NOTIFY p_usb_xmit; /* called from usb_os.c in DivaUSB.sys WDM to indicate a completed transmit */ - /* to usb_drv.c by a call to usb_xmit().*/ - void *ipac_ptr; /* &Diva.ipac pointer to struct IPAC in VxD */ - } Usb_Msg; - PORTDRV_HOOK PortdrvHook; - SLIENTRYPOINT_REQ sliEntryPointReq; - struct { - unsigned char Req; - unsigned char Rc; - diva_xdi_stream_interface_t info; - } xdi_stream_info; - struct { - unsigned char Req; - unsigned char Rc; - diva_xdi_get_extended_xdi_features_t info; - } xdi_extended_features; - struct { - unsigned char Req; - unsigned char Rc; - diva_xdi_get_adapter_sdram_bar_t info; - } xdi_sdram_bar; - struct { - unsigned char Req; - unsigned char Rc; - diva_xdi_get_capi_parameters_t info; - } xdi_capi_prms; - struct { - ENTITY e; - diva_didd_adapter_notify_t info; - } didd_notify; - struct { - ENTITY e; - diva_didd_add_adapter_t info; - } didd_add_adapter; - struct { - ENTITY e; - diva_didd_remove_adapter_t info; - } didd_remove_adapter; - struct { - ENTITY e; - diva_didd_read_adapter_array_t info; - } didd_read_adapter_array; - struct { - ENTITY e; - diva_didd_get_cfg_lib_ifc_t info; - } didd_get_cfg_lib_ifc; - struct { - unsigned char Req; - unsigned char Rc; - diva_xdi_get_logical_adapter_number_s_t info; - } xdi_logical_adapter_number; - struct { - unsigned char Req; - unsigned char Rc; - diva_xdi_dma_descriptor_operation_t info; - } xdi_dma_descriptor_operation; + struct + { unsigned char Req; + unsigned char Rc; + USB_SEND_REQ pUsbSendRequest;/* function in Diva Usb WDM driver in usb_os.c, */ + /* called from usb_drv.c to send a message to our device */ + /* eg UsbSendRequest (USB_PIPE_SIGNAL, USB_IPAC_START, 0, 0); */ + USB_RECV_NOTIFY p_usb_recv; /* called from usb_os.c to pass a received message and ptr to IPAC */ + /* on to usb_drv.c by a call to usb_recv(). */ + USB_XMIT_NOTIFY p_usb_xmit; /* called from usb_os.c in DivaUSB.sys WDM to indicate a completed transmit */ + /* to usb_drv.c by a call to usb_xmit().*/ + void *ipac_ptr; /* &Diva.ipac pointer to struct IPAC in VxD */ + } Usb_Msg; + PORTDRV_HOOK PortdrvHook; + SLIENTRYPOINT_REQ sliEntryPointReq; + struct { + unsigned char Req; + unsigned char Rc; + diva_xdi_stream_interface_t info; + } xdi_stream_info; + struct { + unsigned char Req; + unsigned char Rc; + diva_xdi_get_extended_xdi_features_t info; + } xdi_extended_features; + struct { + unsigned char Req; + unsigned char Rc; + diva_xdi_get_adapter_sdram_bar_t info; + } xdi_sdram_bar; + struct { + unsigned char Req; + unsigned char Rc; + diva_xdi_get_capi_parameters_t info; + } xdi_capi_prms; + struct { + ENTITY e; + diva_didd_adapter_notify_t info; + } didd_notify; + struct { + ENTITY e; + diva_didd_add_adapter_t info; + } didd_add_adapter; + struct { + ENTITY e; + diva_didd_remove_adapter_t info; + } didd_remove_adapter; + struct { + ENTITY e; + diva_didd_read_adapter_array_t info; + } didd_read_adapter_array; + struct { + ENTITY e; + diva_didd_get_cfg_lib_ifc_t info; + } didd_get_cfg_lib_ifc; + struct { + unsigned char Req; + unsigned char Rc; + diva_xdi_get_logical_adapter_number_s_t info; + } xdi_logical_adapter_number; + struct { + unsigned char Req; + unsigned char Rc; + diva_xdi_dma_descriptor_operation_t info; + } xdi_dma_descriptor_operation; } IDI_SYNC_REQ; /******************************************************************************/ -#endif /* __DIVA_SYNC__H */ +#endif /* __DIVA_SYNC__H */ diff --git a/drivers/isdn/hardware/eicon/dqueue.c b/drivers/isdn/hardware/eicon/dqueue.c index 982258225174..7958a2536a10 100644 --- a/drivers/isdn/hardware/eicon/dqueue.c +++ b/drivers/isdn/hardware/eicon/dqueue.c @@ -14,7 +14,7 @@ #include "dqueue.h" int -diva_data_q_init(diva_um_idi_data_queue_t * q, +diva_data_q_init(diva_um_idi_data_queue_t *q, int max_length, int max_segments) { int i; @@ -38,7 +38,7 @@ diva_data_q_init(diva_um_idi_data_queue_t * q, return (0); } -int diva_data_q_finit(diva_um_idi_data_queue_t * q) +int diva_data_q_finit(diva_um_idi_data_queue_t *q) { int i; @@ -54,12 +54,12 @@ int diva_data_q_finit(diva_um_idi_data_queue_t * q) return (0); } -int diva_data_q_get_max_length(const diva_um_idi_data_queue_t * q) +int diva_data_q_get_max_length(const diva_um_idi_data_queue_t *q) { return (q->max_length); } -void *diva_data_q_get_segment4write(diva_um_idi_data_queue_t * q) +void *diva_data_q_get_segment4write(diva_um_idi_data_queue_t *q) { if ((!q->segment_pending) && (q->count < q->segments)) { q->segment_pending = 1; @@ -70,7 +70,7 @@ void *diva_data_q_get_segment4write(diva_um_idi_data_queue_t * q) } void -diva_data_q_ack_segment4write(diva_um_idi_data_queue_t * q, int length) +diva_data_q_ack_segment4write(diva_um_idi_data_queue_t *q, int length) { if (q->segment_pending) { q->length[q->write] = length; @@ -92,12 +92,12 @@ const void *diva_data_q_get_segment4read(const diva_um_idi_data_queue_t * return NULL; } -int diva_data_q_get_segment_length(const diva_um_idi_data_queue_t * q) +int diva_data_q_get_segment_length(const diva_um_idi_data_queue_t *q) { return (q->length[q->read]); } -void diva_data_q_ack_segment4read(diva_um_idi_data_queue_t * q) +void diva_data_q_ack_segment4read(diva_um_idi_data_queue_t *q) { if (q->count) { q->length[q->read] = 0; diff --git a/drivers/isdn/hardware/eicon/dqueue.h b/drivers/isdn/hardware/eicon/dqueue.h index 72d21c967227..6992c45457a4 100644 --- a/drivers/isdn/hardware/eicon/dqueue.h +++ b/drivers/isdn/hardware/eicon/dqueue.h @@ -16,16 +16,16 @@ typedef struct _diva_um_idi_data_queue { int length[DIVA_UM_IDI_MAX_MSGS]; } diva_um_idi_data_queue_t; -int diva_data_q_init(diva_um_idi_data_queue_t * q, +int diva_data_q_init(diva_um_idi_data_queue_t *q, int max_length, int max_segments); -int diva_data_q_finit(diva_um_idi_data_queue_t * q); -int diva_data_q_get_max_length(const diva_um_idi_data_queue_t * q); -void *diva_data_q_get_segment4write(diva_um_idi_data_queue_t * q); -void diva_data_q_ack_segment4write(diva_um_idi_data_queue_t * q, +int diva_data_q_finit(diva_um_idi_data_queue_t *q); +int diva_data_q_get_max_length(const diva_um_idi_data_queue_t *q); +void *diva_data_q_get_segment4write(diva_um_idi_data_queue_t *q); +void diva_data_q_ack_segment4write(diva_um_idi_data_queue_t *q, int length); const void *diva_data_q_get_segment4read(const diva_um_idi_data_queue_t * q); -int diva_data_q_get_segment_length(const diva_um_idi_data_queue_t * q); -void diva_data_q_ack_segment4read(diva_um_idi_data_queue_t * q); +int diva_data_q_get_segment_length(const diva_um_idi_data_queue_t *q); +void diva_data_q_ack_segment4read(diva_um_idi_data_queue_t *q); #endif diff --git a/drivers/isdn/hardware/eicon/dsp_defs.h b/drivers/isdn/hardware/eicon/dsp_defs.h index fec1e381a688..94828c87e2a4 100644 --- a/drivers/isdn/hardware/eicon/dsp_defs.h +++ b/drivers/isdn/hardware/eicon/dsp_defs.h @@ -1,33 +1,33 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#ifndef DSP_DEFS_H_ +#ifndef DSP_DEFS_H_ #define DSP_DEFS_H_ #include "dspdids.h" /*---------------------------------------------------------------------------*/ -#define dsp_download_reserve_space(fp,length) +#define dsp_download_reserve_space(fp, length) /*****************************************************************************/ /* * OS file access abstraction layer @@ -35,25 +35,25 @@ * I/O functions returns -1 on error, 0 on EOF */ struct _OsFileHandle_; -typedef long ( * OsFileIo) (struct _OsFileHandle_ *handle, - void *buffer, - long size) ; -typedef long ( * OsFileSeek)(struct _OsFileHandle_ *handle, - long position, - int mode) ; -typedef long ( * OsCardLoad)(struct _OsFileHandle_ *handle, - long length, - void * *addr) ; +typedef long (*OsFileIo)(struct _OsFileHandle_ *handle, + void *buffer, + long size); +typedef long (*OsFileSeek)(struct _OsFileHandle_ *handle, + long position, + int mode); +typedef long (*OsCardLoad)(struct _OsFileHandle_ *handle, + long length, + void **addr); typedef struct _OsFileHandle_ -{ void *sysFileDesc ; - unsigned long sysFileSize ; - OsFileIo sysFileRead ; - OsFileSeek sysFileSeek ; - void *sysLoadDesc ; - OsCardLoad sysCardLoad ; -} OsFileHandle ; -extern OsFileHandle *OsOpenFile (char *path_name) ; -extern void OsCloseFile (OsFileHandle *fp) ; +{ void *sysFileDesc; + unsigned long sysFileSize; + OsFileIo sysFileRead; + OsFileSeek sysFileSeek; + void *sysLoadDesc; + OsCardLoad sysCardLoad; +} OsFileHandle; +extern OsFileHandle *OsOpenFile(char *path_name); +extern void OsCloseFile(OsFileHandle *fp); /*****************************************************************************/ #define DSP_TELINDUS_FILE "dspdload.bin" /* special DSP file for BRI cards for Qsig and CornetN because of missing memory */ @@ -93,109 +93,109 @@ extern void OsCloseFile (OsFileHandle *fp) ; #define DSP_FILE_FORMAT_VERSION_BCD 0x0100 typedef struct tag_dsp_combifile_header { - char format_identification[DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE]; - word format_version_bcd; - word header_size; - word combifile_description_size; - word directory_entries; - word directory_size; - word download_count; - word usage_mask_size; + char format_identification[DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE]; + word format_version_bcd; + word header_size; + word combifile_description_size; + word directory_entries; + word directory_size; + word download_count; + word usage_mask_size; } t_dsp_combifile_header; typedef struct tag_dsp_combifile_directory_entry { - word card_type_number; - word file_set_number; + word card_type_number; + word file_set_number; } t_dsp_combifile_directory_entry; typedef struct tag_dsp_file_header { - char format_identification[DSP_FILE_FORMAT_IDENTIFICATION_SIZE]; - word format_version_bcd; - word download_id; - word download_flags; - word required_processing_power; - word interface_channel_count; - word header_size; - word download_description_size; - word memory_block_table_size; - word memory_block_count; - word segment_table_size; - word segment_count; - word symbol_table_size; - word symbol_count; - word total_data_size_dm; - word data_block_count_dm; - word total_data_size_pm; - word data_block_count_pm; + char format_identification[DSP_FILE_FORMAT_IDENTIFICATION_SIZE]; + word format_version_bcd; + word download_id; + word download_flags; + word required_processing_power; + word interface_channel_count; + word header_size; + word download_description_size; + word memory_block_table_size; + word memory_block_count; + word segment_table_size; + word segment_count; + word symbol_table_size; + word symbol_count; + word total_data_size_dm; + word data_block_count_dm; + word total_data_size_pm; + word data_block_count_pm; } t_dsp_file_header; typedef struct tag_dsp_memory_block_desc { - word alias_memory_block; - word memory_type; - word address; - word size; /* DSP words */ + word alias_memory_block; + word memory_type; + word address; + word size; /* DSP words */ } t_dsp_memory_block_desc; typedef struct tag_dsp_segment_desc { - word memory_block; - word attributes; - word base; - word size; - word alignment; /* ==0 -> no other legal start address than base */ + word memory_block; + word attributes; + word base; + word size; + word alignment; /* ==0 -> no other legal start address than base */ } t_dsp_segment_desc; typedef struct tag_dsp_symbol_desc { - word symbol_id; - word segment; - word offset; - word size; /* DSP words */ + word symbol_id; + word segment; + word offset; + word size; /* DSP words */ } t_dsp_symbol_desc; typedef struct tag_dsp_data_block_header { - word attributes; - word segment; - word offset; - word size; /* DSP words */ + word attributes; + word segment; + word offset; + word size; /* DSP words */ } t_dsp_data_block_header; typedef struct tag_dsp_download_desc { - word download_id; - word download_flags; - word required_processing_power; - word interface_channel_count; - word excess_header_size; - word memory_block_count; - word segment_count; - word symbol_count; - word data_block_count_dm; - word data_block_count_pm; - byte * p_excess_header_data; - char * p_download_description; - t_dsp_memory_block_desc *p_memory_block_table; - t_dsp_segment_desc *p_segment_table; - t_dsp_symbol_desc *p_symbol_table; - word * p_data_blocks_dm; - word * p_data_blocks_pm; + word download_id; + word download_flags; + word required_processing_power; + word interface_channel_count; + word excess_header_size; + word memory_block_count; + word segment_count; + word symbol_count; + word data_block_count_dm; + word data_block_count_pm; + byte *p_excess_header_data; + char *p_download_description; + t_dsp_memory_block_desc *p_memory_block_table; + t_dsp_segment_desc *p_segment_table; + t_dsp_symbol_desc *p_symbol_table; + word *p_data_blocks_dm; + word *p_data_blocks_pm; } t_dsp_desc; typedef struct tag_dsp_portable_download_desc /* be sure to keep native alignment for MAESTRA's */ { - word download_id; - word download_flags; - word required_processing_power; - word interface_channel_count; - word excess_header_size; - word memory_block_count; - word segment_count; - word symbol_count; - word data_block_count_dm; - word data_block_count_pm; - dword p_excess_header_data; - dword p_download_description; - dword p_memory_block_table; - dword p_segment_table; - dword p_symbol_table; - dword p_data_blocks_dm; - dword p_data_blocks_pm; + word download_id; + word download_flags; + word required_processing_power; + word interface_channel_count; + word excess_header_size; + word memory_block_count; + word segment_count; + word symbol_count; + word data_block_count_dm; + word data_block_count_pm; + dword p_excess_header_data; + dword p_download_description; + dword p_memory_block_table; + dword p_segment_table; + dword p_symbol_table; + dword p_data_blocks_dm; + dword p_data_blocks_pm; } t_dsp_portable_desc; #define DSP_DOWNLOAD_INDEX_KERNEL 0 #define DSP30TX_DOWNLOAD_INDEX_KERNEL 1 @@ -204,7 +204,7 @@ typedef struct tag_dsp_portable_download_desc /* be sure to keep native alignmen #define DSP_DOWNLOAD_MAX_SEGMENTS 16 #define DSP_UDATA_REQUEST_RECONFIGURE 0 /* -parameters: + parameters: reconfigure delay (in 8kHz samples) reconfigure code reconfigure hdlc preamble flags @@ -229,11 +229,11 @@ typedef struct tag_dsp_portable_download_desc /* be sure to keep native alignmen #define DSP_RECONFIGURE_V17_12000 11 #define DSP_RECONFIGURE_V17_14400 12 /* -data indications if transparent framer + data indications if transparent framer data 0 data 1 ... -data indications if HDLC framer + data indications if HDLC framer data 0 data 1 ... @@ -243,17 +243,17 @@ data indications if HDLC framer */ #define DSP_UDATA_INDICATION_SYNC 0 /* -returns: + returns: time of sync (sampled from counter at 8kHz) */ #define DSP_UDATA_INDICATION_DCD_OFF 1 /* -returns: + returns: time of DCD off (sampled from counter at 8kHz) */ #define DSP_UDATA_INDICATION_DCD_ON 2 /* -returns: + returns: time of DCD on (sampled from counter at 8kHz) connected norm connected options @@ -261,12 +261,12 @@ data indications if HDLC framer */ #define DSP_UDATA_INDICATION_CTS_OFF 3 /* -returns: + returns: time of CTS off (sampled from counter at 8kHz) */ #define DSP_UDATA_INDICATION_CTS_ON 4 /* -returns: + returns: time of CTS on (sampled from counter at 8kHz) connected norm connected options @@ -292,10 +292,10 @@ data indications if HDLC framer #define DSP_CONNECTED_NORM_V17 17 #define DSP_CONNECTED_OPTION_TRELLIS 0x0001 /*---------------------------------------------------------------------------*/ -extern char *dsp_read_file (OsFileHandle *fp, - word card_type_number, - word *p_dsp_download_count, - t_dsp_desc *p_dsp_download_table, - t_dsp_portable_desc *p_dsp_portable_download_table) ; +extern char *dsp_read_file(OsFileHandle *fp, + word card_type_number, + word *p_dsp_download_count, + t_dsp_desc *p_dsp_download_table, + t_dsp_portable_desc *p_dsp_portable_download_table); /*---------------------------------------------------------------------------*/ -#endif /* DSP_DEFS_H_ */ +#endif /* DSP_DEFS_H_ */ diff --git a/drivers/isdn/hardware/eicon/dsp_tst.h b/drivers/isdn/hardware/eicon/dsp_tst.h index a6021e5b1ae7..fe36f138be8b 100644 --- a/drivers/isdn/hardware/eicon/dsp_tst.h +++ b/drivers/isdn/hardware/eicon/dsp_tst.h @@ -4,8 +4,8 @@ #define __DIVA_PRI_HOST_TEST_DSPS_H__ /* - DSP registers on maestra pri - */ + DSP registers on maestra pri +*/ #define DSP1_PORT (0x00) #define DSP2_PORT (0x8) #define DSP3_PORT (0x800) @@ -39,9 +39,9 @@ #define DSP_ADR_OFFS 0x80 /*------------------------------------------------------------------ - Dsp related definitions + Dsp related definitions ------------------------------------------------------------------ */ #define DSP_SIGNATURE_PROBE_WORD 0x5a5a -#define dsp_make_address_ex(pm,address) ((word)((pm) ? (address) : (address) + 0x4000)) +#define dsp_make_address_ex(pm, address) ((word)((pm) ? (address) : (address) + 0x4000)) #endif diff --git a/drivers/isdn/hardware/eicon/dspdids.h b/drivers/isdn/hardware/eicon/dspdids.h index ebe131a53b9c..957b33cc0022 100644 --- a/drivers/isdn/hardware/eicon/dspdids.h +++ b/drivers/isdn/hardware/eicon/dspdids.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef DSPDIDS_H_ diff --git a/drivers/isdn/hardware/eicon/dsrv4bri.h b/drivers/isdn/hardware/eicon/dsrv4bri.h index 732d22dfe4a5..f353fb6b8933 100644 --- a/drivers/isdn/hardware/eicon/dsrv4bri.h +++ b/drivers/isdn/hardware/eicon/dsrv4bri.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_XDI_DSRV_4_BRI_INC__ @@ -35,6 +35,6 @@ #define PLX9054_SOFT_RESET 0x4000 #define PLX9054_RELOAD_EEPROM 0x2000 #define DIVA_4BRI_REVISION(__x__) (((__x__)->cardType == CARDTYPE_DIVASRV_Q_8M_V2_PCI) || ((__x__)->cardType == CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI) || ((__x__)->cardType == CARDTYPE_DIVASRV_B_2M_V2_PCI) || ((__x__)->cardType == CARDTYPE_DIVASRV_B_2F_PCI) || ((__x__)->cardType == CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI)) -void diva_os_set_qBri_functions (PISDN_ADAPTER IoAdapter); -void diva_os_set_qBri2_functions (PISDN_ADAPTER IoAdapter); +void diva_os_set_qBri_functions(PISDN_ADAPTER IoAdapter); +void diva_os_set_qBri2_functions(PISDN_ADAPTER IoAdapter); #endif diff --git a/drivers/isdn/hardware/eicon/dsrv_bri.h b/drivers/isdn/hardware/eicon/dsrv_bri.h index f38ebbe53332..8a67dbc65be4 100644 --- a/drivers/isdn/hardware/eicon/dsrv_bri.h +++ b/drivers/isdn/hardware/eicon/dsrv_bri.h @@ -1,37 +1,37 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_XDI_DSRV_BRI_INC__ #define __DIVA_XDI_DSRV_BRI_INC__ /* - Functions exported from os dependent part of - BRI card configuration and used in - OS independed part - */ + Functions exported from os dependent part of + BRI card configuration and used in + OS independed part +*/ /* - Prepare OS dependent part of BRI functions - */ -void diva_os_prepare_maestra_functions (PISDN_ADAPTER IoAdapter); + Prepare OS dependent part of BRI functions +*/ +void diva_os_prepare_maestra_functions(PISDN_ADAPTER IoAdapter); #endif diff --git a/drivers/isdn/hardware/eicon/dsrv_pri.h b/drivers/isdn/hardware/eicon/dsrv_pri.h index 861182666c89..fd1a9ff9f195 100644 --- a/drivers/isdn/hardware/eicon/dsrv_pri.h +++ b/drivers/isdn/hardware/eicon/dsrv_pri.h @@ -1,38 +1,38 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_XDI_DSRV_PRI_INC__ #define __DIVA_XDI_DSRV_PRI_INC__ /* - Functions exported from os dependent part of - PRI card configuration and used in - OS independed part - */ + Functions exported from os dependent part of + PRI card configuration and used in + OS independed part +*/ /* - Prepare OS dependent part of PRI/PRI Rev.2 functions - */ -void diva_os_prepare_pri_functions (PISDN_ADAPTER IoAdapter); -void diva_os_prepare_pri2_functions (PISDN_ADAPTER IoAdapter); + Prepare OS dependent part of PRI/PRI Rev.2 functions +*/ +void diva_os_prepare_pri_functions(PISDN_ADAPTER IoAdapter); +void diva_os_prepare_pri2_functions(PISDN_ADAPTER IoAdapter); #endif diff --git a/drivers/isdn/hardware/eicon/entity.h b/drivers/isdn/hardware/eicon/entity.h index 16252cf164bb..fdb83416af31 100644 --- a/drivers/isdn/hardware/eicon/entity.h +++ b/drivers/isdn/hardware/eicon/entity.h @@ -11,17 +11,17 @@ typedef struct _divas_um_idi_entity { struct list_head link; - diva_um_idi_adapter_t* adapter; /* Back to adapter */ - ENTITY e; - void* os_ref; - dword status; - void* os_context; - int rc_count; + diva_um_idi_adapter_t *adapter; /* Back to adapter */ + ENTITY e; + void *os_ref; + dword status; + void *os_context; + int rc_count; diva_um_idi_data_queue_t data; /* definad by user 1 ... MAX */ diva_um_idi_data_queue_t rc; /* two entries */ BUFFERS XData; BUFFERS RData; - byte buffer[2048+512]; + byte buffer[2048 + 512]; } divas_um_idi_entity_t; diff --git a/drivers/isdn/hardware/eicon/helpers.h b/drivers/isdn/hardware/eicon/helpers.h index b2123119e430..c9156b0acaba 100644 --- a/drivers/isdn/hardware/eicon/helpers.h +++ b/drivers/isdn/hardware/eicon/helpers.h @@ -1,51 +1,51 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_XDI_CARD_CONFIG_HELPERS_INC__ #define __DIVA_XDI_CARD_CONFIG_HELPERS_INC__ -dword diva_get_protocol_file_features (byte* File, - int offset, - char *IdStringBuffer, - dword IdBufferSize); -void diva_configure_protocol (PISDN_ADAPTER IoAdapter); +dword diva_get_protocol_file_features(byte *File, + int offset, + char *IdStringBuffer, + dword IdBufferSize); +void diva_configure_protocol(PISDN_ADAPTER IoAdapter); /* - Low level file access system abstraction - */ + Low level file access system abstraction +*/ /* ------------------------------------------------------------------------- - Access to single file - Return pointer to the image of the requested file, - write image length to 'FileLength' - ------------------------------------------------------------------------- */ -void *xdiLoadFile (char *FileName, dword *FileLength, unsigned long MaxLoadSize) ; + Access to single file + Return pointer to the image of the requested file, + write image length to 'FileLength' + ------------------------------------------------------------------------- */ +void *xdiLoadFile(char *FileName, dword *FileLength, unsigned long MaxLoadSize); /* ------------------------------------------------------------------------- - Dependent on the protocol settings does read return pointer - to the image of appropriate protocol file - ------------------------------------------------------------------------- */ -void *xdiLoadArchive (PISDN_ADAPTER IoAdapter, dword *FileLength, unsigned long MaxLoadSize) ; + Dependent on the protocol settings does read return pointer + to the image of appropriate protocol file + ------------------------------------------------------------------------- */ +void *xdiLoadArchive(PISDN_ADAPTER IoAdapter, dword *FileLength, unsigned long MaxLoadSize); /* -------------------------------------------------------------------------- - Free all system resources accessed by xdiLoadFile and xdiLoadArchive - -------------------------------------------------------------------------- */ -void xdiFreeFile (void* handle); + Free all system resources accessed by xdiLoadFile and xdiLoadArchive + -------------------------------------------------------------------------- */ +void xdiFreeFile(void *handle); #endif diff --git a/drivers/isdn/hardware/eicon/idifunc.c b/drivers/isdn/hardware/eicon/idifunc.c index db87d5105422..d153e3cdecf7 100644 --- a/drivers/isdn/hardware/eicon/idifunc.c +++ b/drivers/isdn/hardware/eicon/idifunc.c @@ -1,7 +1,7 @@ /* $Id: idifunc.c,v 1.14.4.4 2004/08/28 20:03:53 armin Exp $ * * Driver for Eicon DIVA Server ISDN cards. - * User Mode IDI Interface + * User Mode IDI Interface * * Copyright 2000-2003 by Armin Schindler (mac@melware.de) * Copyright 2000-2003 Cytronics & Melware (info@melware.de) @@ -58,7 +58,7 @@ static diva_os_spin_lock_t ll_lock; /* * find card in list */ -static udiva_card *find_card_in_list(DESCRIPTOR * d) +static udiva_card *find_card_in_list(DESCRIPTOR *d) { udiva_card *card; struct list_head *tmp; @@ -80,7 +80,7 @@ static udiva_card *find_card_in_list(DESCRIPTOR * d) /* * new card */ -static void um_new_card(DESCRIPTOR * d) +static void um_new_card(DESCRIPTOR *d) { int adapter_nr = 0; udiva_card *card = NULL; @@ -94,10 +94,10 @@ static void um_new_card(DESCRIPTOR * d) memcpy(&card->d, d, sizeof(DESCRIPTOR)); sync_req.xdi_logical_adapter_number.Req = 0; sync_req.xdi_logical_adapter_number.Rc = - IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER; - card->d.request((ENTITY *) & sync_req); + IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER; + card->d.request((ENTITY *)&sync_req); adapter_nr = - sync_req.xdi_logical_adapter_number.info.logical_adapter_number; + sync_req.xdi_logical_adapter_number.info.logical_adapter_number; card->Id = adapter_nr; if (!(diva_user_mode_idi_create_adapter(d, adapter_nr))) { diva_os_enter_spin_lock(&ll_lock, &old_irql, "add card"); @@ -113,7 +113,7 @@ static void um_new_card(DESCRIPTOR * d) /* * remove card */ -static void um_remove_card(DESCRIPTOR * d) +static void um_remove_card(DESCRIPTOR *d) { diva_os_spin_lock_magic_t old_irql; udiva_card *card = NULL; @@ -154,7 +154,7 @@ static void DIVA_EXIT_FUNCTION remove_all_idi_proc(void) /* * DIDD notify callback */ -static void *didd_callback(void *context, DESCRIPTOR * adapter, +static void *didd_callback(void *context, DESCRIPTOR *adapter, int removal) { if (adapter->type == IDI_DADAPTER) { @@ -196,10 +196,10 @@ static int DIVA_INIT_FUNCTION connect_didd(void) memcpy(&DAdapter, &DIDD_Table[x], sizeof(DAdapter)); req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = - IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; + IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; req.didd_notify.info.callback = (void *)didd_callback; req.didd_notify.info.context = NULL; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); if (req.didd_notify.e.Rc != 0xff) { stop_dbg(); return (0); @@ -234,7 +234,7 @@ static void DIVA_EXIT_FUNCTION disconnect_didd(void) req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY; req.didd_notify.info.handle = notify_handle; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); } /* diff --git a/drivers/isdn/hardware/eicon/io.c b/drivers/isdn/hardware/eicon/io.c index 6fd9b007417d..8851ce580c23 100644 --- a/drivers/isdn/hardware/eicon/io.c +++ b/drivers/isdn/hardware/eicon/io.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -33,16 +33,16 @@ #include "di.h" #include "mi_pc.h" #include "io.h" -extern ADAPTER * adapter[MAX_ADAPTER]; +extern ADAPTER *adapter[MAX_ADAPTER]; extern PISDN_ADAPTER IoAdapters[MAX_ADAPTER]; -void request (PISDN_ADAPTER, ENTITY *); -static void pcm_req (PISDN_ADAPTER, ENTITY *); +void request(PISDN_ADAPTER, ENTITY *); +static void pcm_req(PISDN_ADAPTER, ENTITY *); /* -------------------------------------------------------------------------- - local functions - -------------------------------------------------------------------------- */ -#define ReqFunc(N) \ -static void Request##N(ENTITY *e) \ -{ if ( IoAdapters[N] ) (* IoAdapters[N]->DIRequest)(IoAdapters[N], e) ; } + local functions + -------------------------------------------------------------------------- */ +#define ReqFunc(N) \ + static void Request##N(ENTITY *e) \ + { if (IoAdapters[N]) (*IoAdapters[N]->DIRequest)(IoAdapters[N], e); } ReqFunc(0) ReqFunc(1) ReqFunc(2) @@ -61,792 +61,792 @@ ReqFunc(14) ReqFunc(15) IDI_CALL Requests[MAX_ADAPTER] = { &Request0, &Request1, &Request2, &Request3, - &Request4, &Request5, &Request6, &Request7, - &Request8, &Request9, &Request10, &Request11, - &Request12, &Request13, &Request14, &Request15 + &Request4, &Request5, &Request6, &Request7, + &Request8, &Request9, &Request10, &Request11, + &Request12, &Request13, &Request14, &Request15 }; /*****************************************************************************/ /* This array should indicate all new services, that this version of XDI is able to provide to his clients - */ -static byte extended_xdi_features[DIVA_XDI_EXTENDED_FEATURES_MAX_SZ+1] = { - (DIVA_XDI_EXTENDED_FEATURES_VALID | - DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR | - DIVA_XDI_EXTENDED_FEATURE_CAPI_PRMS | +*/ +static byte extended_xdi_features[DIVA_XDI_EXTENDED_FEATURES_MAX_SZ + 1] = { + (DIVA_XDI_EXTENDED_FEATURES_VALID | + DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR | + DIVA_XDI_EXTENDED_FEATURE_CAPI_PRMS | #if defined(DIVA_IDI_RX_DMA) - DIVA_XDI_EXTENDED_FEATURE_CMA | - DIVA_XDI_EXTENDED_FEATURE_RX_DMA | - DIVA_XDI_EXTENDED_FEATURE_MANAGEMENT_DMA | + DIVA_XDI_EXTENDED_FEATURE_CMA | + DIVA_XDI_EXTENDED_FEATURE_RX_DMA | + DIVA_XDI_EXTENDED_FEATURE_MANAGEMENT_DMA | #endif - DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC), - 0 + DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC), + 0 }; /*****************************************************************************/ void -dump_xlog_buffer (PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc) -{ - dword logLen ; - word *Xlog = xlogDesc->buf ; - word logCnt = xlogDesc->cnt ; - word logOut = xlogDesc->out / sizeof(*Xlog) ; - DBG_FTL(("%s: ************* XLOG recovery (%d) *************", - &IoAdapter->Name[0], (int)logCnt)) - DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0])) - for ( ; logCnt > 0 ; --logCnt ) - { - if ( !GET_WORD(&Xlog[logOut]) ) - { - if ( --logCnt == 0 ) - break ; - logOut = 0 ; - } - if ( GET_WORD(&Xlog[logOut]) <= (logOut * sizeof(*Xlog)) ) - { - if ( logCnt > 2 ) - { - DBG_FTL(("Possibly corrupted XLOG: %d entries left", - (int)logCnt)) - } - break ; - } - logLen = (dword)(GET_WORD(&Xlog[logOut]) - (logOut * sizeof(*Xlog))) ; - DBG_FTL_MXLOG(( (char *)&Xlog[logOut + 1], (dword)(logLen - 2) )) - logOut = (GET_WORD(&Xlog[logOut]) + 1) / sizeof(*Xlog) ; - } - DBG_FTL(("%s: ***************** end of XLOG *****************", - &IoAdapter->Name[0])) -} +dump_xlog_buffer(PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc) +{ + dword logLen; + word *Xlog = xlogDesc->buf; + word logCnt = xlogDesc->cnt; + word logOut = xlogDesc->out / sizeof(*Xlog); + DBG_FTL(("%s: ************* XLOG recovery (%d) *************", + &IoAdapter->Name[0], (int)logCnt)) + DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0])) + for (; logCnt > 0; --logCnt) + { + if (!GET_WORD(&Xlog[logOut])) + { + if (--logCnt == 0) + break; + logOut = 0; + } + if (GET_WORD(&Xlog[logOut]) <= (logOut * sizeof(*Xlog))) + { + if (logCnt > 2) + { + DBG_FTL(("Possibly corrupted XLOG: %d entries left", + (int)logCnt)) + } + break; + } + logLen = (dword)(GET_WORD(&Xlog[logOut]) - (logOut * sizeof(*Xlog))); + DBG_FTL_MXLOG(((char *)&Xlog[logOut + 1], (dword)(logLen - 2))) + logOut = (GET_WORD(&Xlog[logOut]) + 1) / sizeof(*Xlog); + } + DBG_FTL(("%s: ***************** end of XLOG *****************", + &IoAdapter->Name[0])) + } /*****************************************************************************/ #if defined(XDI_USE_XLOG) static char *(ExceptionCauseTable[]) = { - "Interrupt", - "TLB mod /IBOUND", - "TLB load /DBOUND", - "TLB store", - "Address error load", - "Address error store", - "Instruction load bus error", - "Data load/store bus error", - "Syscall", - "Breakpoint", - "Reverd instruction", - "Coprocessor unusable", - "Overflow", - "TRAP", - "VCEI", - "Floating Point Exception", - "CP2", - "Reserved 17", - "Reserved 18", - "Reserved 19", - "Reserved 20", - "Reserved 21", - "Reserved 22", - "WATCH", - "Reserved 24", - "Reserved 25", - "Reserved 26", - "Reserved 27", - "Reserved 28", - "Reserved 29", - "Reserved 30", - "VCED" -} ; + "Interrupt", + "TLB mod /IBOUND", + "TLB load /DBOUND", + "TLB store", + "Address error load", + "Address error store", + "Instruction load bus error", + "Data load/store bus error", + "Syscall", + "Breakpoint", + "Reverd instruction", + "Coprocessor unusable", + "Overflow", + "TRAP", + "VCEI", + "Floating Point Exception", + "CP2", + "Reserved 17", + "Reserved 18", + "Reserved 19", + "Reserved 20", + "Reserved 21", + "Reserved 22", + "WATCH", + "Reserved 24", + "Reserved 25", + "Reserved 26", + "Reserved 27", + "Reserved 28", + "Reserved 29", + "Reserved 30", + "VCED" +}; #endif void -dump_trap_frame (PISDN_ADAPTER IoAdapter, byte __iomem *exceptionFrame) -{ - MP_XCPTC __iomem *xcept = (MP_XCPTC __iomem *)exceptionFrame ; - dword __iomem *regs; - regs = &xcept->regs[0] ; - DBG_FTL(("%s: ***************** CPU TRAPPED *****************", - &IoAdapter->Name[0])) - DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0])) - DBG_FTL(("Cause: %s", - ExceptionCauseTable[(READ_DWORD(&xcept->cr) & 0x0000007c) >> 2])) - DBG_FTL(("sr 0x%08x cr 0x%08x epc 0x%08x vaddr 0x%08x", - READ_DWORD(&xcept->sr), READ_DWORD(&xcept->cr), - READ_DWORD(&xcept->epc), READ_DWORD(&xcept->vaddr))) - DBG_FTL(("zero 0x%08x at 0x%08x v0 0x%08x v1 0x%08x", - READ_DWORD(®s[ 0]), READ_DWORD(®s[ 1]), - READ_DWORD(®s[ 2]), READ_DWORD(®s[ 3]))) - DBG_FTL(("a0 0x%08x a1 0x%08x a2 0x%08x a3 0x%08x", - READ_DWORD(®s[ 4]), READ_DWORD(®s[ 5]), - READ_DWORD(®s[ 6]), READ_DWORD(®s[ 7]))) - DBG_FTL(("t0 0x%08x t1 0x%08x t2 0x%08x t3 0x%08x", - READ_DWORD(®s[ 8]), READ_DWORD(®s[ 9]), - READ_DWORD(®s[10]), READ_DWORD(®s[11]))) - DBG_FTL(("t4 0x%08x t5 0x%08x t6 0x%08x t7 0x%08x", - READ_DWORD(®s[12]), READ_DWORD(®s[13]), - READ_DWORD(®s[14]), READ_DWORD(®s[15]))) - DBG_FTL(("s0 0x%08x s1 0x%08x s2 0x%08x s3 0x%08x", - READ_DWORD(®s[16]), READ_DWORD(®s[17]), - READ_DWORD(®s[18]), READ_DWORD(®s[19]))) - DBG_FTL(("s4 0x%08x s5 0x%08x s6 0x%08x s7 0x%08x", - READ_DWORD(®s[20]), READ_DWORD(®s[21]), - READ_DWORD(®s[22]), READ_DWORD(®s[23]))) - DBG_FTL(("t8 0x%08x t9 0x%08x k0 0x%08x k1 0x%08x", - READ_DWORD(®s[24]), READ_DWORD(®s[25]), - READ_DWORD(®s[26]), READ_DWORD(®s[27]))) - DBG_FTL(("gp 0x%08x sp 0x%08x s8 0x%08x ra 0x%08x", - READ_DWORD(®s[28]), READ_DWORD(®s[29]), - READ_DWORD(®s[30]), READ_DWORD(®s[31]))) - DBG_FTL(("md 0x%08x|%08x resvd 0x%08x class 0x%08x", - READ_DWORD(&xcept->mdhi), READ_DWORD(&xcept->mdlo), - READ_DWORD(&xcept->reseverd), READ_DWORD(&xcept->xclass))) -} +dump_trap_frame(PISDN_ADAPTER IoAdapter, byte __iomem *exceptionFrame) +{ + MP_XCPTC __iomem *xcept = (MP_XCPTC __iomem *)exceptionFrame; + dword __iomem *regs; + regs = &xcept->regs[0]; + DBG_FTL(("%s: ***************** CPU TRAPPED *****************", + &IoAdapter->Name[0])) + DBG_FTL(("Microcode: %s", &IoAdapter->ProtocolIdString[0])) + DBG_FTL(("Cause: %s", + ExceptionCauseTable[(READ_DWORD(&xcept->cr) & 0x0000007c) >> 2])) + DBG_FTL(("sr 0x%08x cr 0x%08x epc 0x%08x vaddr 0x%08x", + READ_DWORD(&xcept->sr), READ_DWORD(&xcept->cr), + READ_DWORD(&xcept->epc), READ_DWORD(&xcept->vaddr))) + DBG_FTL(("zero 0x%08x at 0x%08x v0 0x%08x v1 0x%08x", + READ_DWORD(®s[0]), READ_DWORD(®s[1]), + READ_DWORD(®s[2]), READ_DWORD(®s[3]))) + DBG_FTL(("a0 0x%08x a1 0x%08x a2 0x%08x a3 0x%08x", + READ_DWORD(®s[4]), READ_DWORD(®s[5]), + READ_DWORD(®s[6]), READ_DWORD(®s[7]))) + DBG_FTL(("t0 0x%08x t1 0x%08x t2 0x%08x t3 0x%08x", + READ_DWORD(®s[8]), READ_DWORD(®s[9]), + READ_DWORD(®s[10]), READ_DWORD(®s[11]))) + DBG_FTL(("t4 0x%08x t5 0x%08x t6 0x%08x t7 0x%08x", + READ_DWORD(®s[12]), READ_DWORD(®s[13]), + READ_DWORD(®s[14]), READ_DWORD(®s[15]))) + DBG_FTL(("s0 0x%08x s1 0x%08x s2 0x%08x s3 0x%08x", + READ_DWORD(®s[16]), READ_DWORD(®s[17]), + READ_DWORD(®s[18]), READ_DWORD(®s[19]))) + DBG_FTL(("s4 0x%08x s5 0x%08x s6 0x%08x s7 0x%08x", + READ_DWORD(®s[20]), READ_DWORD(®s[21]), + READ_DWORD(®s[22]), READ_DWORD(®s[23]))) + DBG_FTL(("t8 0x%08x t9 0x%08x k0 0x%08x k1 0x%08x", + READ_DWORD(®s[24]), READ_DWORD(®s[25]), + READ_DWORD(®s[26]), READ_DWORD(®s[27]))) + DBG_FTL(("gp 0x%08x sp 0x%08x s8 0x%08x ra 0x%08x", + READ_DWORD(®s[28]), READ_DWORD(®s[29]), + READ_DWORD(®s[30]), READ_DWORD(®s[31]))) + DBG_FTL(("md 0x%08x|%08x resvd 0x%08x class 0x%08x", + READ_DWORD(&xcept->mdhi), READ_DWORD(&xcept->mdlo), + READ_DWORD(&xcept->reseverd), READ_DWORD(&xcept->xclass))) + } /* -------------------------------------------------------------------------- - Real XDI Request function - -------------------------------------------------------------------------- */ -void request(PISDN_ADAPTER IoAdapter, ENTITY * e) + Real XDI Request function + -------------------------------------------------------------------------- */ +void request(PISDN_ADAPTER IoAdapter, ENTITY *e) { - byte i; - diva_os_spin_lock_magic_t irql; + byte i; + diva_os_spin_lock_magic_t irql; /* * if the Req field in the entity structure is 0, * we treat this request as a special function call */ - if ( !e->Req ) - { - IDI_SYNC_REQ *syncReq = (IDI_SYNC_REQ *)e ; - switch (e->Rc) - { + if (!e->Req) + { + IDI_SYNC_REQ *syncReq = (IDI_SYNC_REQ *)e; + switch (e->Rc) + { #if defined(DIVA_IDI_RX_DMA) - case IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION: { - diva_xdi_dma_descriptor_operation_t* pI = \ - &syncReq->xdi_dma_descriptor_operation.info; - if (!IoAdapter->dma_map) { - pI->operation = -1; - pI->descriptor_number = -1; - return; - } - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, &irql, "dma_op"); - if (pI->operation == IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC) { - pI->descriptor_number = diva_alloc_dma_map_entry (\ - (struct _diva_dma_map_entry*)IoAdapter->dma_map); - if (pI->descriptor_number >= 0) { - dword dma_magic; - void* local_addr; - diva_get_dma_map_entry (\ - (struct _diva_dma_map_entry*)IoAdapter->dma_map, - pI->descriptor_number, - &local_addr, &dma_magic); - pI->descriptor_address = local_addr; - pI->descriptor_magic = dma_magic; - pI->operation = 0; - } else { - pI->operation = -1; - } - } else if ((pI->operation == IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE) && - (pI->descriptor_number >= 0)) { - diva_free_dma_map_entry((struct _diva_dma_map_entry*)IoAdapter->dma_map, - pI->descriptor_number); - pI->descriptor_number = -1; - pI->operation = 0; - } else { - pI->descriptor_number = -1; - pI->operation = -1; - } - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "dma_op"); - } return; + case IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION: { + diva_xdi_dma_descriptor_operation_t *pI = \ + &syncReq->xdi_dma_descriptor_operation.info; + if (!IoAdapter->dma_map) { + pI->operation = -1; + pI->descriptor_number = -1; + return; + } + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, &irql, "dma_op"); + if (pI->operation == IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC) { + pI->descriptor_number = diva_alloc_dma_map_entry(\ + (struct _diva_dma_map_entry *)IoAdapter->dma_map); + if (pI->descriptor_number >= 0) { + dword dma_magic; + void *local_addr; + diva_get_dma_map_entry(\ + (struct _diva_dma_map_entry *)IoAdapter->dma_map, + pI->descriptor_number, + &local_addr, &dma_magic); + pI->descriptor_address = local_addr; + pI->descriptor_magic = dma_magic; + pI->operation = 0; + } else { + pI->operation = -1; + } + } else if ((pI->operation == IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE) && + (pI->descriptor_number >= 0)) { + diva_free_dma_map_entry((struct _diva_dma_map_entry *)IoAdapter->dma_map, + pI->descriptor_number); + pI->descriptor_number = -1; + pI->operation = 0; + } else { + pI->descriptor_number = -1; + pI->operation = -1; + } + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "dma_op"); + } return; #endif - case IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER: { - diva_xdi_get_logical_adapter_number_s_t *pI = \ - &syncReq->xdi_logical_adapter_number.info; - pI->logical_adapter_number = IoAdapter->ANum; - pI->controller = IoAdapter->ControllerNumber; - pI->total_controllers = IoAdapter->Properties.Adapters; - } return; - case IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS: { - diva_xdi_get_capi_parameters_t prms, *pI = &syncReq->xdi_capi_prms.info; - memset (&prms, 0x00, sizeof(prms)); - prms.structure_length = min_t(size_t, sizeof(prms), pI->structure_length); - memset (pI, 0x00, pI->structure_length); - prms.flag_dynamic_l1_down = (IoAdapter->capi_cfg.cfg_1 & \ - DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? 1 : 0; - prms.group_optimization_enabled = (IoAdapter->capi_cfg.cfg_1 & \ - DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) ? 1 : 0; - memcpy (pI, &prms, prms.structure_length); - } return; - case IDI_SYNC_REQ_XDI_GET_ADAPTER_SDRAM_BAR: - syncReq->xdi_sdram_bar.info.bar = IoAdapter->sdram_bar; - return; - case IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES: { - dword i; - diva_xdi_get_extended_xdi_features_t* pI =\ - &syncReq->xdi_extended_features.info; - pI->buffer_length_in_bytes &= ~0x80000000; - if (pI->buffer_length_in_bytes && pI->features) { - memset (pI->features, 0x00, pI->buffer_length_in_bytes); - } - for (i = 0; ((pI->features) && (i < pI->buffer_length_in_bytes) && - (i < DIVA_XDI_EXTENDED_FEATURES_MAX_SZ)); i++) { - pI->features[i] = extended_xdi_features[i]; - } - if ((pI->buffer_length_in_bytes < DIVA_XDI_EXTENDED_FEATURES_MAX_SZ) || - (!pI->features)) { - pI->buffer_length_in_bytes =\ - (0x80000000 | DIVA_XDI_EXTENDED_FEATURES_MAX_SZ); - } - } return; - case IDI_SYNC_REQ_XDI_GET_STREAM: - if (IoAdapter) { - diva_xdi_provide_istream_info (&IoAdapter->a, - &syncReq->xdi_stream_info.info); - } else { - syncReq->xdi_stream_info.info.provided_service = 0; - } - return; - case IDI_SYNC_REQ_GET_NAME: - if ( IoAdapter ) - { - strcpy (&syncReq->GetName.name[0], IoAdapter->Name) ; - DBG_TRC(("xdi: Adapter %d / Name '%s'", - IoAdapter->ANum, IoAdapter->Name)) - return ; - } - syncReq->GetName.name[0] = '\0' ; - break ; - case IDI_SYNC_REQ_GET_SERIAL: - if ( IoAdapter ) - { - syncReq->GetSerial.serial = IoAdapter->serialNo ; - DBG_TRC(("xdi: Adapter %d / SerialNo %ld", - IoAdapter->ANum, IoAdapter->serialNo)) - return ; - } - syncReq->GetSerial.serial = 0 ; - break ; - case IDI_SYNC_REQ_GET_CARDTYPE: - if ( IoAdapter ) - { - syncReq->GetCardType.cardtype = IoAdapter->cardType ; - DBG_TRC(("xdi: Adapter %d / CardType %ld", - IoAdapter->ANum, IoAdapter->cardType)) - return ; - } - syncReq->GetCardType.cardtype = 0 ; - break ; - case IDI_SYNC_REQ_GET_XLOG: - if ( IoAdapter ) - { - pcm_req (IoAdapter, e) ; - return ; - } - e->Ind = 0 ; - break ; - case IDI_SYNC_REQ_GET_DBG_XLOG: - if ( IoAdapter ) - { - pcm_req (IoAdapter, e) ; - return ; - } - e->Ind = 0 ; - break ; - case IDI_SYNC_REQ_GET_FEATURES: - if ( IoAdapter ) - { - syncReq->GetFeatures.features = - (unsigned short)IoAdapter->features ; - return ; - } - syncReq->GetFeatures.features = 0 ; - break ; - case IDI_SYNC_REQ_PORTDRV_HOOK: - if ( IoAdapter ) - { - DBG_TRC(("Xdi:IDI_SYNC_REQ_PORTDRV_HOOK - ignored")) - return ; - } - break; - } - if ( IoAdapter ) - { - return ; - } - } - DBG_TRC(("xdi: Id 0x%x / Req 0x%x / Rc 0x%x", e->Id, e->Req, e->Rc)) - if ( !IoAdapter ) - { - DBG_FTL(("xdi: uninitialized Adapter used - ignore request")) - return ; - } - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req"); + case IDI_SYNC_REQ_XDI_GET_LOGICAL_ADAPTER_NUMBER: { + diva_xdi_get_logical_adapter_number_s_t *pI = \ + &syncReq->xdi_logical_adapter_number.info; + pI->logical_adapter_number = IoAdapter->ANum; + pI->controller = IoAdapter->ControllerNumber; + pI->total_controllers = IoAdapter->Properties.Adapters; + } return; + case IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS: { + diva_xdi_get_capi_parameters_t prms, *pI = &syncReq->xdi_capi_prms.info; + memset(&prms, 0x00, sizeof(prms)); + prms.structure_length = min_t(size_t, sizeof(prms), pI->structure_length); + memset(pI, 0x00, pI->structure_length); + prms.flag_dynamic_l1_down = (IoAdapter->capi_cfg.cfg_1 & \ + DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? 1 : 0; + prms.group_optimization_enabled = (IoAdapter->capi_cfg.cfg_1 & \ + DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) ? 1 : 0; + memcpy(pI, &prms, prms.structure_length); + } return; + case IDI_SYNC_REQ_XDI_GET_ADAPTER_SDRAM_BAR: + syncReq->xdi_sdram_bar.info.bar = IoAdapter->sdram_bar; + return; + case IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES: { + dword i; + diva_xdi_get_extended_xdi_features_t *pI =\ + &syncReq->xdi_extended_features.info; + pI->buffer_length_in_bytes &= ~0x80000000; + if (pI->buffer_length_in_bytes && pI->features) { + memset(pI->features, 0x00, pI->buffer_length_in_bytes); + } + for (i = 0; ((pI->features) && (i < pI->buffer_length_in_bytes) && + (i < DIVA_XDI_EXTENDED_FEATURES_MAX_SZ)); i++) { + pI->features[i] = extended_xdi_features[i]; + } + if ((pI->buffer_length_in_bytes < DIVA_XDI_EXTENDED_FEATURES_MAX_SZ) || + (!pI->features)) { + pI->buffer_length_in_bytes =\ + (0x80000000 | DIVA_XDI_EXTENDED_FEATURES_MAX_SZ); + } + } return; + case IDI_SYNC_REQ_XDI_GET_STREAM: + if (IoAdapter) { + diva_xdi_provide_istream_info(&IoAdapter->a, + &syncReq->xdi_stream_info.info); + } else { + syncReq->xdi_stream_info.info.provided_service = 0; + } + return; + case IDI_SYNC_REQ_GET_NAME: + if (IoAdapter) + { + strcpy(&syncReq->GetName.name[0], IoAdapter->Name); + DBG_TRC(("xdi: Adapter %d / Name '%s'", + IoAdapter->ANum, IoAdapter->Name)) + return; + } + syncReq->GetName.name[0] = '\0'; + break; + case IDI_SYNC_REQ_GET_SERIAL: + if (IoAdapter) + { + syncReq->GetSerial.serial = IoAdapter->serialNo; + DBG_TRC(("xdi: Adapter %d / SerialNo %ld", + IoAdapter->ANum, IoAdapter->serialNo)) + return; + } + syncReq->GetSerial.serial = 0; + break; + case IDI_SYNC_REQ_GET_CARDTYPE: + if (IoAdapter) + { + syncReq->GetCardType.cardtype = IoAdapter->cardType; + DBG_TRC(("xdi: Adapter %d / CardType %ld", + IoAdapter->ANum, IoAdapter->cardType)) + return; + } + syncReq->GetCardType.cardtype = 0; + break; + case IDI_SYNC_REQ_GET_XLOG: + if (IoAdapter) + { + pcm_req(IoAdapter, e); + return; + } + e->Ind = 0; + break; + case IDI_SYNC_REQ_GET_DBG_XLOG: + if (IoAdapter) + { + pcm_req(IoAdapter, e); + return; + } + e->Ind = 0; + break; + case IDI_SYNC_REQ_GET_FEATURES: + if (IoAdapter) + { + syncReq->GetFeatures.features = + (unsigned short)IoAdapter->features; + return; + } + syncReq->GetFeatures.features = 0; + break; + case IDI_SYNC_REQ_PORTDRV_HOOK: + if (IoAdapter) + { + DBG_TRC(("Xdi:IDI_SYNC_REQ_PORTDRV_HOOK - ignored")) + return; + } + break; + } + if (IoAdapter) + { + return; + } + } + DBG_TRC(("xdi: Id 0x%x / Req 0x%x / Rc 0x%x", e->Id, e->Req, e->Rc)) + if (!IoAdapter) + { + DBG_FTL(("xdi: uninitialized Adapter used - ignore request")) + return; + } + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req"); /* * assign an entity */ - if ( !(e->Id &0x1f) ) - { - if ( IoAdapter->e_count >= IoAdapter->e_max ) - { - DBG_FTL(("xdi: all Ids in use (max=%d) --> Req ignored", - IoAdapter->e_max)) - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req"); - return ; - } + if (!(e->Id & 0x1f)) + { + if (IoAdapter->e_count >= IoAdapter->e_max) + { + DBG_FTL(("xdi: all Ids in use (max=%d) --> Req ignored", + IoAdapter->e_max)) + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req"); + return; + } /* * find a new free id */ - for ( i = 1 ; IoAdapter->e_tbl[i].e ; ++i ) ; - IoAdapter->e_tbl[i].e = e ; - IoAdapter->e_count++ ; - e->No = (byte)i ; - e->More = 0 ; - e->RCurrent = 0xff ; - } - else - { - i = e->No ; - } + for (i = 1; IoAdapter->e_tbl[i].e; ++i); + IoAdapter->e_tbl[i].e = e; + IoAdapter->e_count++; + e->No = (byte)i; + e->More = 0; + e->RCurrent = 0xff; + } + else + { + i = e->No; + } /* * if the entity is still busy, ignore the request call */ - if ( e->More & XBUSY ) - { - DBG_FTL(("xdi: Id 0x%x busy --> Req 0x%x ignored", e->Id, e->Req)) - if ( !IoAdapter->trapped && IoAdapter->trapFnc ) - { - IoAdapter->trapFnc (IoAdapter) ; - /* - Firs trap, also notify user if supported - */ - if (IoAdapter->trapped && IoAdapter->os_trap_nfy_Fnc) { - (*(IoAdapter->os_trap_nfy_Fnc))(IoAdapter, IoAdapter->ANum); - } - } - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req"); - return ; - } + if (e->More & XBUSY) + { + DBG_FTL(("xdi: Id 0x%x busy --> Req 0x%x ignored", e->Id, e->Req)) + if (!IoAdapter->trapped && IoAdapter->trapFnc) + { + IoAdapter->trapFnc(IoAdapter); + /* + Firs trap, also notify user if supported + */ + if (IoAdapter->trapped && IoAdapter->os_trap_nfy_Fnc) { + (*(IoAdapter->os_trap_nfy_Fnc))(IoAdapter, IoAdapter->ANum); + } + } + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req"); + return; + } /* * initialize transmit status variables */ - e->More |= XBUSY ; - e->More &= ~XMOREF ; - e->XCurrent = 0 ; - e->XOffset = 0 ; + e->More |= XBUSY; + e->More &= ~XMOREF; + e->XCurrent = 0; + e->XOffset = 0; /* * queue this entity in the adapter request queue */ - IoAdapter->e_tbl[i].next = 0 ; - if ( IoAdapter->head ) - { - IoAdapter->e_tbl[IoAdapter->tail].next = i ; - IoAdapter->tail = i ; - } - else - { - IoAdapter->head = i ; - IoAdapter->tail = i ; - } + IoAdapter->e_tbl[i].next = 0; + if (IoAdapter->head) + { + IoAdapter->e_tbl[IoAdapter->tail].next = i; + IoAdapter->tail = i; + } + else + { + IoAdapter->head = i; + IoAdapter->tail = i; + } /* * queue the DPC to process the request */ - diva_os_schedule_soft_isr (&IoAdapter->req_soft_isr); - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req"); + diva_os_schedule_soft_isr(&IoAdapter->req_soft_isr); + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req"); } /* --------------------------------------------------------------------- - Main DPC routine + Main DPC routine --------------------------------------------------------------------- */ -void DIDpcRoutine (struct _diva_os_soft_isr* psoft_isr, void* Context) { - PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)Context ; - ADAPTER* a = &IoAdapter->a ; - diva_os_atomic_t* pin_dpc = &IoAdapter->in_dpc; - if (diva_os_atomic_increment (pin_dpc) == 1) { - do { - if ( IoAdapter->tst_irq (a) ) - { - if ( !IoAdapter->Unavailable ) - IoAdapter->dpc (a) ; - IoAdapter->clr_irq (a) ; - } - IoAdapter->out (a) ; - } while (diva_os_atomic_decrement (pin_dpc) > 0); - /* ---------------------------------------------------------------- - Look for XLOG request (cards with indirect addressing) - ---------------------------------------------------------------- */ - if (IoAdapter->pcm_pending) { - struct pc_maint *pcm; - diva_os_spin_lock_magic_t OldIrql ; - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_dpc"); - pcm = (struct pc_maint *)IoAdapter->pcm_data; - switch (IoAdapter->pcm_pending) { - case 1: /* ask card for XLOG */ - a->ram_out (a, &IoAdapter->pcm->rc, 0) ; - a->ram_out (a, &IoAdapter->pcm->req, pcm->req) ; - IoAdapter->pcm_pending = 2; - break; - case 2: /* Try to get XLOG from the card */ - if ((int)(a->ram_in (a, &IoAdapter->pcm->rc))) { - a->ram_in_buffer (a, IoAdapter->pcm, pcm, sizeof(*pcm)) ; - IoAdapter->pcm_pending = 3; - } - break; - case 3: /* let XDI recovery XLOG */ - break; - } - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_dpc"); - } - /* ---------------------------------------------------------------- */ - } +void DIDpcRoutine(struct _diva_os_soft_isr *psoft_isr, void *Context) { + PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)Context; + ADAPTER *a = &IoAdapter->a; + diva_os_atomic_t *pin_dpc = &IoAdapter->in_dpc; + if (diva_os_atomic_increment(pin_dpc) == 1) { + do { + if (IoAdapter->tst_irq(a)) + { + if (!IoAdapter->Unavailable) + IoAdapter->dpc(a); + IoAdapter->clr_irq(a); + } + IoAdapter->out(a); + } while (diva_os_atomic_decrement(pin_dpc) > 0); + /* ---------------------------------------------------------------- + Look for XLOG request (cards with indirect addressing) + ---------------------------------------------------------------- */ + if (IoAdapter->pcm_pending) { + struct pc_maint *pcm; + diva_os_spin_lock_magic_t OldIrql; + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_dpc"); + pcm = (struct pc_maint *)IoAdapter->pcm_data; + switch (IoAdapter->pcm_pending) { + case 1: /* ask card for XLOG */ + a->ram_out(a, &IoAdapter->pcm->rc, 0); + a->ram_out(a, &IoAdapter->pcm->req, pcm->req); + IoAdapter->pcm_pending = 2; + break; + case 2: /* Try to get XLOG from the card */ + if ((int)(a->ram_in(a, &IoAdapter->pcm->rc))) { + a->ram_in_buffer(a, IoAdapter->pcm, pcm, sizeof(*pcm)); + IoAdapter->pcm_pending = 3; + } + break; + case 3: /* let XDI recovery XLOG */ + break; + } + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_dpc"); + } + /* ---------------------------------------------------------------- */ + } } /* -------------------------------------------------------------------------- - XLOG interface - -------------------------------------------------------------------------- */ + XLOG interface + -------------------------------------------------------------------------- */ static void -pcm_req (PISDN_ADAPTER IoAdapter, ENTITY *e) +pcm_req(PISDN_ADAPTER IoAdapter, ENTITY *e) { - diva_os_spin_lock_magic_t OldIrql ; - int i, rc ; - ADAPTER *a = &IoAdapter->a ; - struct pc_maint *pcm = (struct pc_maint *)&e->Ind ; + diva_os_spin_lock_magic_t OldIrql; + int i, rc; + ADAPTER *a = &IoAdapter->a; + struct pc_maint *pcm = (struct pc_maint *)&e->Ind; /* * special handling of I/O based card interface * the memory access isn't an atomic operation ! */ - if ( IoAdapter->Properties.Card == CARD_MAE ) - { - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_1"); - IoAdapter->pcm_data = (void *)pcm; - IoAdapter->pcm_pending = 1; - diva_os_schedule_soft_isr (&IoAdapter->req_soft_isr); - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_1"); - for ( rc = 0, i = (IoAdapter->trapped ? 3000 : 250) ; !rc && (i > 0) ; --i ) - { - diva_os_sleep (1) ; - if (IoAdapter->pcm_pending == 3) { - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_3"); - IoAdapter->pcm_pending = 0; - IoAdapter->pcm_data = NULL ; - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_3"); - return ; - } - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_2"); - diva_os_schedule_soft_isr (&IoAdapter->req_soft_isr); - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_2"); - } - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_4"); - IoAdapter->pcm_pending = 0; - IoAdapter->pcm_data = NULL ; - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, - &OldIrql, - "data_pcm_4"); - goto Trapped ; - } + if (IoAdapter->Properties.Card == CARD_MAE) + { + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_1"); + IoAdapter->pcm_data = (void *)pcm; + IoAdapter->pcm_pending = 1; + diva_os_schedule_soft_isr(&IoAdapter->req_soft_isr); + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_1"); + for (rc = 0, i = (IoAdapter->trapped ? 3000 : 250); !rc && (i > 0); --i) + { + diva_os_sleep(1); + if (IoAdapter->pcm_pending == 3) { + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_3"); + IoAdapter->pcm_pending = 0; + IoAdapter->pcm_data = NULL; + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_3"); + return; + } + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_2"); + diva_os_schedule_soft_isr(&IoAdapter->req_soft_isr); + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_2"); + } + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_4"); + IoAdapter->pcm_pending = 0; + IoAdapter->pcm_data = NULL; + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, + &OldIrql, + "data_pcm_4"); + goto Trapped; + } /* * memory based shared ram is accessible from different * processors without disturbing concurrent processes. */ - a->ram_out (a, &IoAdapter->pcm->rc, 0) ; - a->ram_out (a, &IoAdapter->pcm->req, pcm->req) ; - for ( i = (IoAdapter->trapped ? 3000 : 250) ; --i > 0 ; ) - { - diva_os_sleep (1) ; - rc = (int)(a->ram_in (a, &IoAdapter->pcm->rc)) ; - if ( rc ) - { - a->ram_in_buffer (a, IoAdapter->pcm, pcm, sizeof(*pcm)) ; - return ; - } - } + a->ram_out(a, &IoAdapter->pcm->rc, 0); + a->ram_out(a, &IoAdapter->pcm->req, pcm->req); + for (i = (IoAdapter->trapped ? 3000 : 250); --i > 0;) + { + diva_os_sleep(1); + rc = (int)(a->ram_in(a, &IoAdapter->pcm->rc)); + if (rc) + { + a->ram_in_buffer(a, IoAdapter->pcm, pcm, sizeof(*pcm)); + return; + } + } Trapped: - if ( IoAdapter->trapFnc ) - { - int trapped = IoAdapter->trapped; - IoAdapter->trapFnc (IoAdapter) ; - /* - Firs trap, also notify user if supported - */ - if (!trapped && IoAdapter->trapped && IoAdapter->os_trap_nfy_Fnc) { - (*(IoAdapter->os_trap_nfy_Fnc))(IoAdapter, IoAdapter->ANum); - } - } + if (IoAdapter->trapFnc) + { + int trapped = IoAdapter->trapped; + IoAdapter->trapFnc(IoAdapter); + /* + Firs trap, also notify user if supported + */ + if (!trapped && IoAdapter->trapped && IoAdapter->os_trap_nfy_Fnc) { + (*(IoAdapter->os_trap_nfy_Fnc))(IoAdapter, IoAdapter->ANum); + } + } } /*------------------------------------------------------------------*/ /* ram access functions for memory mapped cards */ /*------------------------------------------------------------------*/ -byte mem_in (ADAPTER *a, void *addr) +byte mem_in(ADAPTER *a, void *addr) { - byte val; - volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - val = READ_BYTE(Base + (unsigned long)addr); - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); - return (val); + byte val; + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + val = READ_BYTE(Base + (unsigned long)addr); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + return (val); } -word mem_inw (ADAPTER *a, void *addr) +word mem_inw(ADAPTER *a, void *addr) { - word val; - volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - val = READ_WORD((Base + (unsigned long)addr)); - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); - return (val); + word val; + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + val = READ_WORD((Base + (unsigned long)addr)); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + return (val); } -void mem_in_dw (ADAPTER *a, void *addr, dword* data, int dwords) +void mem_in_dw(ADAPTER *a, void *addr, dword *data, int dwords) { - volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - while (dwords--) { - *data++ = READ_DWORD((Base + (unsigned long)addr)); - addr+=4; - } - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + while (dwords--) { + *data++ = READ_DWORD((Base + (unsigned long)addr)); + addr += 4; + } + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } -void mem_in_buffer (ADAPTER *a, void *addr, void *buffer, word length) +void mem_in_buffer(ADAPTER *a, void *addr, void *buffer, word length) { - volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - memcpy_fromio(buffer, (Base + (unsigned long)addr), length); - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + memcpy_fromio(buffer, (Base + (unsigned long)addr), length); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } -void mem_look_ahead (ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) +void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) { - PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io ; - IoAdapter->RBuffer.length = mem_inw (a, &RBuffer->length) ; - mem_in_buffer (a, RBuffer->P, IoAdapter->RBuffer.P, - IoAdapter->RBuffer.length) ; - e->RBuffer = (DBUFFER *)&IoAdapter->RBuffer ; + PISDN_ADAPTER IoAdapter = (PISDN_ADAPTER)a->io; + IoAdapter->RBuffer.length = mem_inw(a, &RBuffer->length); + mem_in_buffer(a, RBuffer->P, IoAdapter->RBuffer.P, + IoAdapter->RBuffer.length); + e->RBuffer = (DBUFFER *)&IoAdapter->RBuffer; } -void mem_out (ADAPTER *a, void *addr, byte data) +void mem_out(ADAPTER *a, void *addr, byte data) { - volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - WRITE_BYTE(Base + (unsigned long)addr, data); - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + WRITE_BYTE(Base + (unsigned long)addr, data); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } -void mem_outw (ADAPTER *a, void *addr, word data) +void mem_outw(ADAPTER *a, void *addr, word data) { - volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - WRITE_WORD((Base + (unsigned long)addr), data); - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + WRITE_WORD((Base + (unsigned long)addr), data); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } -void mem_out_dw (ADAPTER *a, void *addr, const dword* data, int dwords) +void mem_out_dw(ADAPTER *a, void *addr, const dword *data, int dwords) { - volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - while (dwords--) { - WRITE_DWORD((Base + (unsigned long)addr), *data); - addr+=4; - data++; - } - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + while (dwords--) { + WRITE_DWORD((Base + (unsigned long)addr), *data); + addr += 4; + data++; + } + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } -void mem_out_buffer (ADAPTER *a, void *addr, void *buffer, word length) +void mem_out_buffer(ADAPTER *a, void *addr, void *buffer, word length) { - volatile byte __iomem * Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - memcpy_toio((Base + (unsigned long)addr), buffer, length) ; - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + memcpy_toio((Base + (unsigned long)addr), buffer, length); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } -void mem_inc (ADAPTER *a, void *addr) +void mem_inc(ADAPTER *a, void *addr) { - volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); - byte x = READ_BYTE(Base + (unsigned long)addr); - WRITE_BYTE(Base + (unsigned long)addr, x + 1); - DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); + volatile byte __iomem *Base = DIVA_OS_MEM_ATTACH_RAM((PISDN_ADAPTER)a->io); + byte x = READ_BYTE(Base + (unsigned long)addr); + WRITE_BYTE(Base + (unsigned long)addr, x + 1); + DIVA_OS_MEM_DETACH_RAM((PISDN_ADAPTER)a->io, Base); } /*------------------------------------------------------------------*/ /* ram access functions for io-mapped cards */ /*------------------------------------------------------------------*/ -byte io_in(ADAPTER * a, void * adr) -{ - byte val; - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - outppw(Port + 4, (word)(unsigned long)adr); - val = inpp(Port); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); - return(val); -} -word io_inw(ADAPTER * a, void * adr) -{ - word val; - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - outppw(Port + 4, (word)(unsigned long)adr); - val = inppw(Port); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); - return(val); -} -void io_in_buffer(ADAPTER * a, void * adr, void * buffer, word len) -{ - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - byte* P = (byte*)buffer; - if ((long)adr & 1) { - outppw(Port+4, (word)(unsigned long)adr); - *P = inpp(Port); - P++; - adr = ((byte *) adr) + 1; - len--; - if (!len) { +byte io_in(ADAPTER *a, void *adr) +{ + byte val; + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + outppw(Port + 4, (word)(unsigned long)adr); + val = inpp(Port); + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); + return (val); +} +word io_inw(ADAPTER *a, void *adr) +{ + word val; + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + outppw(Port + 4, (word)(unsigned long)adr); + val = inppw(Port); + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); + return (val); +} +void io_in_buffer(ADAPTER *a, void *adr, void *buffer, word len) +{ + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + byte *P = (byte *)buffer; + if ((long)adr & 1) { + outppw(Port + 4, (word)(unsigned long)adr); + *P = inpp(Port); + P++; + adr = ((byte *) adr) + 1; + len--; + if (!len) { + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); + return; + } + } + outppw(Port + 4, (word)(unsigned long)adr); + inppw_buffer(Port, P, len + 1); + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); +} +void io_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e) +{ + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + outppw(Port + 4, (word)(unsigned long)RBuffer); + ((PISDN_ADAPTER)a->io)->RBuffer.length = inppw(Port); + inppw_buffer(Port, ((PISDN_ADAPTER)a->io)->RBuffer.P, ((PISDN_ADAPTER)a->io)->RBuffer.length + 1); + e->RBuffer = (DBUFFER *) &(((PISDN_ADAPTER)a->io)->RBuffer); DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); - return; - } - } - outppw(Port+4, (word)(unsigned long)adr); - inppw_buffer (Port, P, len+1); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); -} -void io_look_ahead(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e) -{ - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - outppw(Port+4, (word)(unsigned long)RBuffer); - ((PISDN_ADAPTER)a->io)->RBuffer.length = inppw(Port); - inppw_buffer (Port, ((PISDN_ADAPTER)a->io)->RBuffer.P, ((PISDN_ADAPTER)a->io)->RBuffer.length + 1); - e->RBuffer = (DBUFFER *) &(((PISDN_ADAPTER)a->io)->RBuffer); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); -} -void io_out(ADAPTER * a, void * adr, byte data) -{ - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - outppw(Port+4, (word)(unsigned long)adr); - outpp(Port, data); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); -} -void io_outw(ADAPTER * a, void * adr, word data) -{ - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - outppw(Port+4, (word)(unsigned long)adr); - outppw(Port, data); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); -} -void io_out_buffer(ADAPTER * a, void * adr, void * buffer, word len) -{ - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - byte* P = (byte*)buffer; - if ((long)adr & 1) { - outppw(Port+4, (word)(unsigned long)adr); - outpp(Port, *P); - P++; - adr = ((byte *) adr) + 1; - len--; - if (!len) { +} +void io_out(ADAPTER *a, void *adr, byte data) +{ + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + outppw(Port + 4, (word)(unsigned long)adr); + outpp(Port, data); + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); +} +void io_outw(ADAPTER *a, void *adr, word data) +{ + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + outppw(Port + 4, (word)(unsigned long)adr); + outppw(Port, data); + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); +} +void io_out_buffer(ADAPTER *a, void *adr, void *buffer, word len) +{ + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + byte *P = (byte *)buffer; + if ((long)adr & 1) { + outppw(Port + 4, (word)(unsigned long)adr); + outpp(Port, *P); + P++; + adr = ((byte *) adr) + 1; + len--; + if (!len) { + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); + return; + } + } + outppw(Port + 4, (word)(unsigned long)adr); + outppw_buffer(Port, P, len + 1); + DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); +} +void io_inc(ADAPTER *a, void *adr) +{ + byte x; + byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); + outppw(Port + 4, (word)(unsigned long)adr); + x = inpp(Port); + outppw(Port + 4, (word)(unsigned long)adr); + outpp(Port, x + 1); DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); - return; - } - } - outppw(Port+4, (word)(unsigned long)adr); - outppw_buffer (Port, P, len+1); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); -} -void io_inc(ADAPTER * a, void * adr) -{ - byte x; - byte __iomem *Port = DIVA_OS_MEM_ATTACH_PORT((PISDN_ADAPTER)a->io); - outppw(Port+4, (word)(unsigned long)adr); - x = inpp(Port); - outppw(Port+4, (word)(unsigned long)adr); - outpp(Port, x+1); - DIVA_OS_MEM_DETACH_PORT((PISDN_ADAPTER)a->io, Port); } /*------------------------------------------------------------------*/ /* OS specific functions related to queuing of entities */ /*------------------------------------------------------------------*/ -void free_entity(ADAPTER * a, byte e_no) -{ - PISDN_ADAPTER IoAdapter; - diva_os_spin_lock_magic_t irql; - IoAdapter = (PISDN_ADAPTER) a->io; - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_free"); - IoAdapter->e_tbl[e_no].e = NULL; - IoAdapter->e_count--; - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_free"); -} -void assign_queue(ADAPTER * a, byte e_no, word ref) -{ - PISDN_ADAPTER IoAdapter; - diva_os_spin_lock_magic_t irql; - IoAdapter = (PISDN_ADAPTER) a->io; - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_assign"); - IoAdapter->e_tbl[e_no].assign_ref = ref; - IoAdapter->e_tbl[e_no].next = (byte)IoAdapter->assign; - IoAdapter->assign = e_no; - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_assign"); -} -byte get_assign(ADAPTER * a, word ref) -{ - PISDN_ADAPTER IoAdapter; - diva_os_spin_lock_magic_t irql; - byte e_no; - IoAdapter = (PISDN_ADAPTER) a->io; - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, - &irql, - "data_assign_get"); - for(e_no = (byte)IoAdapter->assign; - e_no && IoAdapter->e_tbl[e_no].assign_ref!=ref; - e_no = IoAdapter->e_tbl[e_no].next); - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, - &irql, - "data_assign_get"); - return e_no; -} -void req_queue(ADAPTER * a, byte e_no) -{ - PISDN_ADAPTER IoAdapter; - diva_os_spin_lock_magic_t irql; - IoAdapter = (PISDN_ADAPTER) a->io; - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req_q"); - IoAdapter->e_tbl[e_no].next = 0; - if(IoAdapter->head) { - IoAdapter->e_tbl[IoAdapter->tail].next = e_no; - IoAdapter->tail = e_no; - } - else { - IoAdapter->head = e_no; - IoAdapter->tail = e_no; - } - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req_q"); -} -byte look_req(ADAPTER * a) -{ - PISDN_ADAPTER IoAdapter; - IoAdapter = (PISDN_ADAPTER) a->io; - return ((byte)IoAdapter->head) ; -} -void next_req(ADAPTER * a) -{ - PISDN_ADAPTER IoAdapter; - diva_os_spin_lock_magic_t irql; - IoAdapter = (PISDN_ADAPTER) a->io; - diva_os_enter_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req_next"); - IoAdapter->head = IoAdapter->e_tbl[IoAdapter->head].next; - if(!IoAdapter->head) IoAdapter->tail = 0; - diva_os_leave_spin_lock (&IoAdapter->data_spin_lock, &irql, "data_req_next"); +void free_entity(ADAPTER *a, byte e_no) +{ + PISDN_ADAPTER IoAdapter; + diva_os_spin_lock_magic_t irql; + IoAdapter = (PISDN_ADAPTER) a->io; + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_free"); + IoAdapter->e_tbl[e_no].e = NULL; + IoAdapter->e_count--; + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_free"); +} +void assign_queue(ADAPTER *a, byte e_no, word ref) +{ + PISDN_ADAPTER IoAdapter; + diva_os_spin_lock_magic_t irql; + IoAdapter = (PISDN_ADAPTER) a->io; + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_assign"); + IoAdapter->e_tbl[e_no].assign_ref = ref; + IoAdapter->e_tbl[e_no].next = (byte)IoAdapter->assign; + IoAdapter->assign = e_no; + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_assign"); +} +byte get_assign(ADAPTER *a, word ref) +{ + PISDN_ADAPTER IoAdapter; + diva_os_spin_lock_magic_t irql; + byte e_no; + IoAdapter = (PISDN_ADAPTER) a->io; + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, + &irql, + "data_assign_get"); + for (e_no = (byte)IoAdapter->assign; + e_no && IoAdapter->e_tbl[e_no].assign_ref != ref; + e_no = IoAdapter->e_tbl[e_no].next); + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, + &irql, + "data_assign_get"); + return e_no; +} +void req_queue(ADAPTER *a, byte e_no) +{ + PISDN_ADAPTER IoAdapter; + diva_os_spin_lock_magic_t irql; + IoAdapter = (PISDN_ADAPTER) a->io; + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req_q"); + IoAdapter->e_tbl[e_no].next = 0; + if (IoAdapter->head) { + IoAdapter->e_tbl[IoAdapter->tail].next = e_no; + IoAdapter->tail = e_no; + } + else { + IoAdapter->head = e_no; + IoAdapter->tail = e_no; + } + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req_q"); +} +byte look_req(ADAPTER *a) +{ + PISDN_ADAPTER IoAdapter; + IoAdapter = (PISDN_ADAPTER) a->io; + return ((byte)IoAdapter->head); +} +void next_req(ADAPTER *a) +{ + PISDN_ADAPTER IoAdapter; + diva_os_spin_lock_magic_t irql; + IoAdapter = (PISDN_ADAPTER) a->io; + diva_os_enter_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req_next"); + IoAdapter->head = IoAdapter->e_tbl[IoAdapter->head].next; + if (!IoAdapter->head) IoAdapter->tail = 0; + diva_os_leave_spin_lock(&IoAdapter->data_spin_lock, &irql, "data_req_next"); } /*------------------------------------------------------------------*/ /* memory map functions */ /*------------------------------------------------------------------*/ -ENTITY * entity_ptr(ADAPTER * a, byte e_no) +ENTITY *entity_ptr(ADAPTER *a, byte e_no) { - PISDN_ADAPTER IoAdapter; - IoAdapter = (PISDN_ADAPTER) a->io; - return (IoAdapter->e_tbl[e_no].e); + PISDN_ADAPTER IoAdapter; + IoAdapter = (PISDN_ADAPTER)a->io; + return (IoAdapter->e_tbl[e_no].e); } -void * PTR_X(ADAPTER * a, ENTITY * e) +void *PTR_X(ADAPTER *a, ENTITY *e) { - return ((void *) e->X); + return ((void *) e->X); } -void * PTR_R(ADAPTER * a, ENTITY * e) +void *PTR_R(ADAPTER *a, ENTITY *e) { - return ((void *) e->R); + return ((void *) e->R); } -void * PTR_P(ADAPTER * a, ENTITY * e, void * P) +void *PTR_P(ADAPTER *a, ENTITY *e, void *P) { - return P; + return P; } -void CALLBACK(ADAPTER * a, ENTITY * e) +void CALLBACK(ADAPTER *a, ENTITY *e) { - if ( e && e->callback ) - e->callback (e) ; + if (e && e->callback) + e->callback(e); } diff --git a/drivers/isdn/hardware/eicon/io.h b/drivers/isdn/hardware/eicon/io.h index a6f175596364..01deced18ab8 100644 --- a/drivers/isdn/hardware/eicon/io.h +++ b/drivers/isdn/hardware/eicon/io.h @@ -1,308 +1,308 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_XDI_COMMON_IO_H_INC__ /* { */ #define __DIVA_XDI_COMMON_IO_H_INC__ /* - maximum = 16 adapters - */ + maximum = 16 adapters +*/ #define DI_MAX_LINKS MAX_ADAPTER #define ISDN_MAX_NUM_LEN 60 /* -------------------------------------------------------------------------- - structure for quadro card management (obsolete for - systems that do provide per card load event) - -------------------------------------------------------------------------- */ + structure for quadro card management (obsolete for + systems that do provide per card load event) + -------------------------------------------------------------------------- */ typedef struct { - dword Num ; - DEVICE_NAME DeviceName[4] ; - PISDN_ADAPTER QuadroAdapter[4] ; -} ADAPTER_LIST_ENTRY, *PADAPTER_LIST_ENTRY ; + dword Num; + DEVICE_NAME DeviceName[4]; + PISDN_ADAPTER QuadroAdapter[4]; +} ADAPTER_LIST_ENTRY, *PADAPTER_LIST_ENTRY; /* -------------------------------------------------------------------------- - Special OS memory support structures - -------------------------------------------------------------------------- */ + Special OS memory support structures + -------------------------------------------------------------------------- */ #define MAX_MAPPED_ENTRIES 8 typedef struct { - void * Address; - dword Length; -} ADAPTER_MEMORY ; + void *Address; + dword Length; +} ADAPTER_MEMORY; /* -------------------------------------------------------------------------- - Configuration of XDI clients carried by XDI - -------------------------------------------------------------------------- */ + Configuration of XDI clients carried by XDI + -------------------------------------------------------------------------- */ #define DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON 0x01 #define DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON 0x02 typedef struct _diva_xdi_capi_cfg { - byte cfg_1; + byte cfg_1; } diva_xdi_capi_cfg_t; /* -------------------------------------------------------------------------- - Main data structure kept per adapter - -------------------------------------------------------------------------- */ + Main data structure kept per adapter + -------------------------------------------------------------------------- */ struct _ISDN_ADAPTER { - void (* DIRequest)(PISDN_ADAPTER, ENTITY *) ; - int State ; /* from NT4 1.srv, a good idea, but a poor achievement */ - int Initialized ; - int RegisteredWithDidd ; - int Unavailable ; /* callback function possible? */ - int ResourcesClaimed ; - int PnpBiosConfigUsed ; - dword Logging ; - dword features ; - char ProtocolIdString[80] ; - /* - remember mapped memory areas - */ - ADAPTER_MEMORY MappedMemory[MAX_MAPPED_ENTRIES] ; - CARD_PROPERTIES Properties ; - dword cardType ; - dword protocol_id ; /* configured protocol identifier */ - char protocol_name[8] ; /* readable name of protocol */ - dword BusType ; - dword BusNumber ; - dword slotNumber ; - dword slotId ; - dword ControllerNumber ; /* for QUADRO cards only */ - PISDN_ADAPTER MultiMaster ; /* for 4-BRI card only - use MultiMaster or QuadroList */ - PADAPTER_LIST_ENTRY QuadroList ; /* for QUADRO card only */ - PDEVICE_OBJECT DeviceObject ; - dword DeviceId ; - diva_os_adapter_irq_info_t irq_info; - dword volatile IrqCount ; - int trapped ; - dword DspCodeBaseAddr ; - dword MaxDspCodeSize ; - dword downloadAddr ; - dword DspCodeBaseAddrTable[4] ; /* add. for MultiMaster */ - dword MaxDspCodeSizeTable[4] ; /* add. for MultiMaster */ - dword downloadAddrTable[4] ; /* add. for MultiMaster */ - dword MemoryBase ; - dword MemorySize ; - byte __iomem *Address ; - byte __iomem *Config ; - byte __iomem *Control ; - byte __iomem *reset ; - byte __iomem *port ; - byte __iomem *ram ; - byte __iomem *cfg ; - byte __iomem *prom ; - byte __iomem *ctlReg ; - struct pc_maint *pcm ; - diva_os_dependent_devica_name_t os_name; - byte Name[32] ; - dword serialNo ; - dword ANum ; - dword ArchiveType ; /* ARCHIVE_TYPE_NONE ..._SINGLE ..._USGEN ..._MULTI */ - char *ProtocolSuffix ; /* internal protocolfile table */ - char Archive[32] ; - char Protocol[32] ; - char AddDownload[32] ; /* Dsp- or other additional download files */ - char Oad1[ISDN_MAX_NUM_LEN] ; - char Osa1[ISDN_MAX_NUM_LEN] ; - char Oad2[ISDN_MAX_NUM_LEN] ; - char Osa2[ISDN_MAX_NUM_LEN] ; - char Spid1[ISDN_MAX_NUM_LEN] ; - char Spid2[ISDN_MAX_NUM_LEN] ; - byte nosig ; - byte BriLayer2LinkCount ; /* amount of TEI's that adapter will support in P2MP mode */ - dword Channels ; - dword tei ; - dword nt2 ; - dword TerminalCount ; - dword WatchDog ; - dword Permanent ; - dword BChMask ; /* B channel mask for unchannelized modes */ - dword StableL2 ; - dword DidLen ; - dword NoOrderCheck ; - dword ForceLaw; /* VoiceCoding - default:0, a-law: 1, my-law: 2 */ - dword SigFlags ; - dword LowChannel ; - dword NoHscx30 ; - dword ProtVersion ; - dword crc4 ; - dword L1TristateOrQsig ; /* enable Layer 1 Tristate (bit 2)Or Qsig params (bit 0,1)*/ - dword InitialDspInfo ; - dword ModemGuardTone ; - dword ModemMinSpeed ; - dword ModemMaxSpeed ; - dword ModemOptions ; - dword ModemOptions2 ; - dword ModemNegotiationMode ; - dword ModemModulationsMask ; - dword ModemTransmitLevel ; - dword FaxOptions ; - dword FaxMaxSpeed ; - dword Part68LevelLimiter ; - dword UsEktsNumCallApp ; - byte UsEktsFeatAddConf ; - byte UsEktsFeatRemoveConf ; - byte UsEktsFeatCallTransfer ; - byte UsEktsFeatMsgWaiting ; - byte QsigDialect; - byte ForceVoiceMailAlert; - byte DisableAutoSpid; - byte ModemCarrierWaitTimeSec; - byte ModemCarrierLossWaitTimeTenthSec; - byte PiafsLinkTurnaroundInFrames; - byte DiscAfterProgress; - byte AniDniLimiter[3]; - byte TxAttenuation; /* PRI/E1 only: attenuate TX signal */ - word QsigFeatures; - dword GenerateRingtone ; - dword SupplementaryServicesFeatures; - dword R2Dialect; - dword R2CasOptions; - dword FaxV34Options; - dword DisabledDspMask; - dword AdapterTestMask; - dword DspImageLength; - word AlertToIn20mSecTicks; - word ModemEyeSetup; - byte R2CtryLength; - byte CCBSRelTimer; - byte *PcCfgBufferFile;/* flexible parameter via file */ - byte *PcCfgBuffer ; /* flexible parameter via multistring */ - diva_os_dump_file_t dump_file; /* dump memory to file at lowest irq level */ - diva_os_board_trace_t board_trace ; /* traces from the board */ - diva_os_spin_lock_t isr_spin_lock; - diva_os_spin_lock_t data_spin_lock; - diva_os_soft_isr_t req_soft_isr; - diva_os_soft_isr_t isr_soft_isr; - diva_os_atomic_t in_dpc; - PBUFFER RBuffer; /* Copy of receive lookahead buffer */ - word e_max; - word e_count; - E_INFO *e_tbl; - word assign; /* list of pending ASSIGNs */ - word head; /* head of request queue */ - word tail; /* tail of request queue */ - ADAPTER a ; /* not a separate structure */ - void (* out)(ADAPTER * a) ; - byte (* dpc)(ADAPTER * a) ; - byte (* tst_irq)(ADAPTER * a) ; - void (* clr_irq)(ADAPTER * a) ; - int (* load)(PISDN_ADAPTER) ; - int (* mapmem)(PISDN_ADAPTER) ; - int (* chkIrq)(PISDN_ADAPTER) ; - void (* disIrq)(PISDN_ADAPTER) ; - void (* start)(PISDN_ADAPTER) ; - void (* stop)(PISDN_ADAPTER) ; - void (* rstFnc)(PISDN_ADAPTER) ; - void (* trapFnc)(PISDN_ADAPTER) ; - dword (* DetectDsps)(PISDN_ADAPTER) ; - void (* os_trap_nfy_Fnc)(PISDN_ADAPTER, dword) ; - diva_os_isr_callback_t diva_isr_handler; - dword sdram_bar; /* must be 32 bit */ - dword fpga_features; - volatile int pcm_pending; - volatile void * pcm_data; - diva_xdi_capi_cfg_t capi_cfg; - dword tasks; - void *dma_map; - int (*DivaAdapterTestProc)(PISDN_ADAPTER); - void *AdapterTestMemoryStart; - dword AdapterTestMemoryLength; - const byte* cfg_lib_memory_init; - dword cfg_lib_memory_init_length; + void (*DIRequest)(PISDN_ADAPTER, ENTITY *); + int State; /* from NT4 1.srv, a good idea, but a poor achievement */ + int Initialized; + int RegisteredWithDidd; + int Unavailable; /* callback function possible? */ + int ResourcesClaimed; + int PnpBiosConfigUsed; + dword Logging; + dword features; + char ProtocolIdString[80]; + /* + remember mapped memory areas + */ + ADAPTER_MEMORY MappedMemory[MAX_MAPPED_ENTRIES]; + CARD_PROPERTIES Properties; + dword cardType; + dword protocol_id; /* configured protocol identifier */ + char protocol_name[8]; /* readable name of protocol */ + dword BusType; + dword BusNumber; + dword slotNumber; + dword slotId; + dword ControllerNumber; /* for QUADRO cards only */ + PISDN_ADAPTER MultiMaster; /* for 4-BRI card only - use MultiMaster or QuadroList */ + PADAPTER_LIST_ENTRY QuadroList; /* for QUADRO card only */ + PDEVICE_OBJECT DeviceObject; + dword DeviceId; + diva_os_adapter_irq_info_t irq_info; + dword volatile IrqCount; + int trapped; + dword DspCodeBaseAddr; + dword MaxDspCodeSize; + dword downloadAddr; + dword DspCodeBaseAddrTable[4]; /* add. for MultiMaster */ + dword MaxDspCodeSizeTable[4]; /* add. for MultiMaster */ + dword downloadAddrTable[4]; /* add. for MultiMaster */ + dword MemoryBase; + dword MemorySize; + byte __iomem *Address; + byte __iomem *Config; + byte __iomem *Control; + byte __iomem *reset; + byte __iomem *port; + byte __iomem *ram; + byte __iomem *cfg; + byte __iomem *prom; + byte __iomem *ctlReg; + struct pc_maint *pcm; + diva_os_dependent_devica_name_t os_name; + byte Name[32]; + dword serialNo; + dword ANum; + dword ArchiveType; /* ARCHIVE_TYPE_NONE ..._SINGLE ..._USGEN ..._MULTI */ + char *ProtocolSuffix; /* internal protocolfile table */ + char Archive[32]; + char Protocol[32]; + char AddDownload[32]; /* Dsp- or other additional download files */ + char Oad1[ISDN_MAX_NUM_LEN]; + char Osa1[ISDN_MAX_NUM_LEN]; + char Oad2[ISDN_MAX_NUM_LEN]; + char Osa2[ISDN_MAX_NUM_LEN]; + char Spid1[ISDN_MAX_NUM_LEN]; + char Spid2[ISDN_MAX_NUM_LEN]; + byte nosig; + byte BriLayer2LinkCount; /* amount of TEI's that adapter will support in P2MP mode */ + dword Channels; + dword tei; + dword nt2; + dword TerminalCount; + dword WatchDog; + dword Permanent; + dword BChMask; /* B channel mask for unchannelized modes */ + dword StableL2; + dword DidLen; + dword NoOrderCheck; + dword ForceLaw; /* VoiceCoding - default:0, a-law: 1, my-law: 2 */ + dword SigFlags; + dword LowChannel; + dword NoHscx30; + dword ProtVersion; + dword crc4; + dword L1TristateOrQsig; /* enable Layer 1 Tristate (bit 2)Or Qsig params (bit 0,1)*/ + dword InitialDspInfo; + dword ModemGuardTone; + dword ModemMinSpeed; + dword ModemMaxSpeed; + dword ModemOptions; + dword ModemOptions2; + dword ModemNegotiationMode; + dword ModemModulationsMask; + dword ModemTransmitLevel; + dword FaxOptions; + dword FaxMaxSpeed; + dword Part68LevelLimiter; + dword UsEktsNumCallApp; + byte UsEktsFeatAddConf; + byte UsEktsFeatRemoveConf; + byte UsEktsFeatCallTransfer; + byte UsEktsFeatMsgWaiting; + byte QsigDialect; + byte ForceVoiceMailAlert; + byte DisableAutoSpid; + byte ModemCarrierWaitTimeSec; + byte ModemCarrierLossWaitTimeTenthSec; + byte PiafsLinkTurnaroundInFrames; + byte DiscAfterProgress; + byte AniDniLimiter[3]; + byte TxAttenuation; /* PRI/E1 only: attenuate TX signal */ + word QsigFeatures; + dword GenerateRingtone; + dword SupplementaryServicesFeatures; + dword R2Dialect; + dword R2CasOptions; + dword FaxV34Options; + dword DisabledDspMask; + dword AdapterTestMask; + dword DspImageLength; + word AlertToIn20mSecTicks; + word ModemEyeSetup; + byte R2CtryLength; + byte CCBSRelTimer; + byte *PcCfgBufferFile;/* flexible parameter via file */ + byte *PcCfgBuffer; /* flexible parameter via multistring */ + diva_os_dump_file_t dump_file; /* dump memory to file at lowest irq level */ + diva_os_board_trace_t board_trace; /* traces from the board */ + diva_os_spin_lock_t isr_spin_lock; + diva_os_spin_lock_t data_spin_lock; + diva_os_soft_isr_t req_soft_isr; + diva_os_soft_isr_t isr_soft_isr; + diva_os_atomic_t in_dpc; + PBUFFER RBuffer; /* Copy of receive lookahead buffer */ + word e_max; + word e_count; + E_INFO *e_tbl; + word assign; /* list of pending ASSIGNs */ + word head; /* head of request queue */ + word tail; /* tail of request queue */ + ADAPTER a; /* not a separate structure */ + void (*out)(ADAPTER *a); + byte (*dpc)(ADAPTER *a); + byte (*tst_irq)(ADAPTER *a); + void (*clr_irq)(ADAPTER *a); + int (*load)(PISDN_ADAPTER); + int (*mapmem)(PISDN_ADAPTER); + int (*chkIrq)(PISDN_ADAPTER); + void (*disIrq)(PISDN_ADAPTER); + void (*start)(PISDN_ADAPTER); + void (*stop)(PISDN_ADAPTER); + void (*rstFnc)(PISDN_ADAPTER); + void (*trapFnc)(PISDN_ADAPTER); + dword (*DetectDsps)(PISDN_ADAPTER); + void (*os_trap_nfy_Fnc)(PISDN_ADAPTER, dword); + diva_os_isr_callback_t diva_isr_handler; + dword sdram_bar; /* must be 32 bit */ + dword fpga_features; + volatile int pcm_pending; + volatile void *pcm_data; + diva_xdi_capi_cfg_t capi_cfg; + dword tasks; + void *dma_map; + int (*DivaAdapterTestProc)(PISDN_ADAPTER); + void *AdapterTestMemoryStart; + dword AdapterTestMemoryLength; + const byte *cfg_lib_memory_init; + dword cfg_lib_memory_init_length; }; /* --------------------------------------------------------------------- - Entity table + Entity table --------------------------------------------------------------------- */ struct e_info_s { - ENTITY * e; - byte next; /* chaining index */ - word assign_ref; /* assign reference */ + ENTITY *e; + byte next; /* chaining index */ + word assign_ref; /* assign reference */ }; /* --------------------------------------------------------------------- - S-cards shared ram structure for loading + S-cards shared ram structure for loading --------------------------------------------------------------------- */ struct s_load { - byte ctrl; - byte card; - byte msize; - byte fill0; - word ebit; - word elocl; - word eloch; - byte reserved[20]; - word signature; - byte fill[224]; - byte b[256]; + byte ctrl; + byte card; + byte msize; + byte fill0; + word ebit; + word elocl; + word eloch; + byte reserved[20]; + word signature; + byte fill[224]; + byte b[256]; }; #define PR_RAM ((struct pr_ram *)0) #define RAM ((struct dual *)0) /* --------------------------------------------------------------------- - platform specific conversions + platform specific conversions --------------------------------------------------------------------- */ -extern void * PTR_P(ADAPTER * a, ENTITY * e, void * P); -extern void * PTR_X(ADAPTER * a, ENTITY * e); -extern void * PTR_R(ADAPTER * a, ENTITY * e); -extern void CALLBACK(ADAPTER * a, ENTITY * e); -extern void set_ram(void * * adr_ptr); +extern void *PTR_P(ADAPTER *a, ENTITY *e, void *P); +extern void *PTR_X(ADAPTER *a, ENTITY *e); +extern void *PTR_R(ADAPTER *a, ENTITY *e); +extern void CALLBACK(ADAPTER *a, ENTITY *e); +extern void set_ram(void **adr_ptr); /* --------------------------------------------------------------------- - ram access functions for io mapped cards + ram access functions for io mapped cards --------------------------------------------------------------------- */ -byte io_in(ADAPTER * a, void * adr); -word io_inw(ADAPTER * a, void * adr); -void io_in_buffer(ADAPTER * a, void * adr, void * P, word length); -void io_look_ahead(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e); -void io_out(ADAPTER * a, void * adr, byte data); -void io_outw(ADAPTER * a, void * adr, word data); -void io_out_buffer(ADAPTER * a, void * adr, void * P, word length); -void io_inc(ADAPTER * a, void * adr); -void bri_in_buffer (PISDN_ADAPTER IoAdapter, dword Pos, - void *Buf, dword Len); -int bri_out_buffer (PISDN_ADAPTER IoAdapter, dword Pos, - void *Buf, dword Len, int Verify); +byte io_in(ADAPTER *a, void *adr); +word io_inw(ADAPTER *a, void *adr); +void io_in_buffer(ADAPTER *a, void *adr, void *P, word length); +void io_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e); +void io_out(ADAPTER *a, void *adr, byte data); +void io_outw(ADAPTER *a, void *adr, word data); +void io_out_buffer(ADAPTER *a, void *adr, void *P, word length); +void io_inc(ADAPTER *a, void *adr); +void bri_in_buffer(PISDN_ADAPTER IoAdapter, dword Pos, + void *Buf, dword Len); +int bri_out_buffer(PISDN_ADAPTER IoAdapter, dword Pos, + void *Buf, dword Len, int Verify); /* --------------------------------------------------------------------- - ram access functions for memory mapped cards + ram access functions for memory mapped cards --------------------------------------------------------------------- */ -byte mem_in(ADAPTER * a, void * adr); -word mem_inw(ADAPTER * a, void * adr); -void mem_in_buffer(ADAPTER * a, void * adr, void * P, word length); -void mem_look_ahead(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e); -void mem_out(ADAPTER * a, void * adr, byte data); -void mem_outw(ADAPTER * a, void * adr, word data); -void mem_out_buffer(ADAPTER * a, void * adr, void * P, word length); -void mem_inc(ADAPTER * a, void * adr); -void mem_in_dw (ADAPTER *a, void *addr, dword* data, int dwords); -void mem_out_dw (ADAPTER *a, void *addr, const dword* data, int dwords); +byte mem_in(ADAPTER *a, void *adr); +word mem_inw(ADAPTER *a, void *adr); +void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length); +void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e); +void mem_out(ADAPTER *a, void *adr, byte data); +void mem_outw(ADAPTER *a, void *adr, word data); +void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length); +void mem_inc(ADAPTER *a, void *adr); +void mem_in_dw(ADAPTER *a, void *addr, dword *data, int dwords); +void mem_out_dw(ADAPTER *a, void *addr, const dword *data, int dwords); /* --------------------------------------------------------------------- - functions exported by io.c + functions exported by io.c --------------------------------------------------------------------- */ -extern IDI_CALL Requests[MAX_ADAPTER] ; -extern void DIDpcRoutine (struct _diva_os_soft_isr* psoft_isr, - void* context); -extern void request (PISDN_ADAPTER, ENTITY *) ; +extern IDI_CALL Requests[MAX_ADAPTER]; +extern void DIDpcRoutine(struct _diva_os_soft_isr *psoft_isr, + void *context); +extern void request(PISDN_ADAPTER, ENTITY *); /* --------------------------------------------------------------------- - trapFn helpers, used to recover debug trace from dead card + trapFn helpers, used to recover debug trace from dead card --------------------------------------------------------------------- */ typedef struct { - word *buf ; - word cnt ; - word out ; -} Xdesc ; -extern void dump_trap_frame (PISDN_ADAPTER IoAdapter, byte __iomem *exception) ; -extern void dump_xlog_buffer (PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc) ; + word *buf; + word cnt; + word out; +} Xdesc; +extern void dump_trap_frame(PISDN_ADAPTER IoAdapter, byte __iomem *exception); +extern void dump_xlog_buffer(PISDN_ADAPTER IoAdapter, Xdesc *xlogDesc); /* --------------------------------------------------------------------- */ #endif /* } __DIVA_XDI_COMMON_IO_H_INC__ */ diff --git a/drivers/isdn/hardware/eicon/istream.c b/drivers/isdn/hardware/eicon/istream.c index 7bd5baa547be..045bda5c839f 100644 --- a/drivers/isdn/hardware/eicon/istream.c +++ b/drivers/isdn/hardware/eicon/istream.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -31,196 +31,196 @@ #include "divasync.h" #include "di.h" #if !defined USE_EXTENDED_DEBUGS - #include "dimaint.h" +#include "dimaint.h" #else - #define dprintf +#define dprintf #endif #include "dfifo.h" -int diva_istream_write (void* context, - int Id, - void* data, - int length, - int final, - byte usr1, - byte usr2); -int diva_istream_read (void* context, - int Id, - void* data, - int max_length, - int* final, - byte* usr1, - byte* usr2); +int diva_istream_write(void *context, + int Id, + void *data, + int length, + int final, + byte usr1, + byte usr2); +int diva_istream_read(void *context, + int Id, + void *data, + int max_length, + int *final, + byte *usr1, + byte *usr2); /* ------------------------------------------------------------------- - Does provide iStream interface to the client + Does provide iStream interface to the client ------------------------------------------------------------------- */ -void diva_xdi_provide_istream_info (ADAPTER* a, - diva_xdi_stream_interface_t* pi) { - pi->provided_service = 0; +void diva_xdi_provide_istream_info(ADAPTER *a, + diva_xdi_stream_interface_t *pi) { + pi->provided_service = 0; } /* ------------------------------------------------------------------ - Does write the data from caller's buffer to the card's - stream interface. - If synchronous service was requested, then function - does return amount of data written to stream. - 'final' does indicate that piece of data to be written is - final part of frame (necessary only by structured datatransfer) - return 0 if zero lengh packet was written - return -1 if stream is full - ------------------------------------------------------------------ */ -int diva_istream_write (void* context, - int Id, - void* data, - int length, - int final, - byte usr1, - byte usr2) { - ADAPTER* a = (ADAPTER*)context; - int written = 0, to_write = -1; - char tmp[4]; - byte* data_ptr = (byte*)data; - for (;;) { - a->ram_in_dw (a, + Does write the data from caller's buffer to the card's + stream interface. + If synchronous service was requested, then function + does return amount of data written to stream. + 'final' does indicate that piece of data to be written is + final part of frame (necessary only by structured datatransfer) + return 0 if zero lengh packet was written + return -1 if stream is full + ------------------------------------------------------------------ */ +int diva_istream_write(void *context, + int Id, + void *data, + int length, + int final, + byte usr1, + byte usr2) { + ADAPTER *a = (ADAPTER *)context; + int written = 0, to_write = -1; + char tmp[4]; + byte *data_ptr = (byte *)data; + for (;;) { + a->ram_in_dw(a, #ifdef PLATFORM_GT_32BIT - ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]), + ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]), #else - (void*)(a->tx_stream[Id] + a->tx_pos[Id]), + (void *)(a->tx_stream[Id] + a->tx_pos[Id]), #endif - (dword*)&tmp[0], - 1); - if (tmp[0] & DIVA_DFIFO_READY) { /* No free blocks more */ - if (to_write < 0) - return (-1); /* was not able to write */ - break; /* only part of message was written */ - } - to_write = min(length, DIVA_DFIFO_DATA_SZ); - if (to_write) { - a->ram_out_buffer (a, + (dword *)&tmp[0], + 1); + if (tmp[0] & DIVA_DFIFO_READY) { /* No free blocks more */ + if (to_write < 0) + return (-1); /* was not able to write */ + break; /* only part of message was written */ + } + to_write = min(length, DIVA_DFIFO_DATA_SZ); + if (to_write) { + a->ram_out_buffer(a, #ifdef PLATFORM_GT_32BIT - ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]+4), + ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id] + 4), #else - (void*)(a->tx_stream[Id] + a->tx_pos[Id] + 4), + (void *)(a->tx_stream[Id] + a->tx_pos[Id] + 4), #endif - data_ptr, - (word)to_write); - length -= to_write; - written += to_write; - data_ptr += to_write; - } - tmp[1] = (char)to_write; - tmp[0] = (tmp[0] & DIVA_DFIFO_WRAP) | - DIVA_DFIFO_READY | - ((!length && final) ? DIVA_DFIFO_LAST : 0); - if (tmp[0] & DIVA_DFIFO_LAST) { - tmp[2] = usr1; - tmp[3] = usr2; - } - a->ram_out_dw (a, + data_ptr, + (word)to_write); + length -= to_write; + written += to_write; + data_ptr += to_write; + } + tmp[1] = (char)to_write; + tmp[0] = (tmp[0] & DIVA_DFIFO_WRAP) | + DIVA_DFIFO_READY | + ((!length && final) ? DIVA_DFIFO_LAST : 0); + if (tmp[0] & DIVA_DFIFO_LAST) { + tmp[2] = usr1; + tmp[3] = usr2; + } + a->ram_out_dw(a, #ifdef PLATFORM_GT_32BIT - ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]), + ULongToPtr(a->tx_stream[Id] + a->tx_pos[Id]), #else - (void*)(a->tx_stream[Id] + a->tx_pos[Id]), + (void *)(a->tx_stream[Id] + a->tx_pos[Id]), #endif - (dword*)&tmp[0], - 1); - if (tmp[0] & DIVA_DFIFO_WRAP) { - a->tx_pos[Id] = 0; - } else { - a->tx_pos[Id] += DIVA_DFIFO_STEP; - } - if (!length) { - break; - } - } - return (written); + (dword *)&tmp[0], + 1); + if (tmp[0] & DIVA_DFIFO_WRAP) { + a->tx_pos[Id] = 0; + } else { + a->tx_pos[Id] += DIVA_DFIFO_STEP; + } + if (!length) { + break; + } + } + return (written); } /* ------------------------------------------------------------------- - In case of SYNCRONOUS service: - Does write data from stream in caller's buffer. - Does return amount of data written to buffer - Final flag is set on return if last part of structured frame - was received - return 0 if zero packet was received - return -1 if stream is empty - return -2 if read buffer does not profide sufficient space - to accommodate entire segment - max_length should be at least 68 bytes - ------------------------------------------------------------------- */ -int diva_istream_read (void* context, - int Id, - void* data, - int max_length, - int* final, - byte* usr1, - byte* usr2) { - ADAPTER* a = (ADAPTER*)context; - int read = 0, to_read = -1; - char tmp[4]; - byte* data_ptr = (byte*)data; - *final = 0; - for (;;) { - a->ram_in_dw (a, + In case of SYNCRONOUS service: + Does write data from stream in caller's buffer. + Does return amount of data written to buffer + Final flag is set on return if last part of structured frame + was received + return 0 if zero packet was received + return -1 if stream is empty + return -2 if read buffer does not profide sufficient space + to accommodate entire segment + max_length should be at least 68 bytes + ------------------------------------------------------------------- */ +int diva_istream_read(void *context, + int Id, + void *data, + int max_length, + int *final, + byte *usr1, + byte *usr2) { + ADAPTER *a = (ADAPTER *)context; + int read = 0, to_read = -1; + char tmp[4]; + byte *data_ptr = (byte *)data; + *final = 0; + for (;;) { + a->ram_in_dw(a, #ifdef PLATFORM_GT_32BIT - ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id]), + ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id]), #else - (void*)(a->rx_stream[Id] + a->rx_pos[Id]), + (void *)(a->rx_stream[Id] + a->rx_pos[Id]), #endif - (dword*)&tmp[0], - 1); - if (tmp[1] > max_length) { - if (to_read < 0) - return (-2); /* was not able to read */ - break; - } - if (!(tmp[0] & DIVA_DFIFO_READY)) { - if (to_read < 0) - return (-1); /* was not able to read */ - break; - } - to_read = min(max_length, (int)tmp[1]); - if (to_read) { - a->ram_in_buffer(a, + (dword *)&tmp[0], + 1); + if (tmp[1] > max_length) { + if (to_read < 0) + return (-2); /* was not able to read */ + break; + } + if (!(tmp[0] & DIVA_DFIFO_READY)) { + if (to_read < 0) + return (-1); /* was not able to read */ + break; + } + to_read = min(max_length, (int)tmp[1]); + if (to_read) { + a->ram_in_buffer(a, #ifdef PLATFORM_GT_32BIT - ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id] + 4), + ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id] + 4), #else - (void*)(a->rx_stream[Id] + a->rx_pos[Id] + 4), + (void *)(a->rx_stream[Id] + a->rx_pos[Id] + 4), #endif - data_ptr, - (word)to_read); - max_length -= to_read; - read += to_read; - data_ptr += to_read; - } - if (tmp[0] & DIVA_DFIFO_LAST) { - *final = 1; - } - tmp[0] &= DIVA_DFIFO_WRAP; - a->ram_out_dw(a, + data_ptr, + (word)to_read); + max_length -= to_read; + read += to_read; + data_ptr += to_read; + } + if (tmp[0] & DIVA_DFIFO_LAST) { + *final = 1; + } + tmp[0] &= DIVA_DFIFO_WRAP; + a->ram_out_dw(a, #ifdef PLATFORM_GT_32BIT - ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id]), + ULongToPtr(a->rx_stream[Id] + a->rx_pos[Id]), #else - (void*)(a->rx_stream[Id] + a->rx_pos[Id]), + (void *)(a->rx_stream[Id] + a->rx_pos[Id]), #endif - (dword*)&tmp[0], - 1); - if (tmp[0] & DIVA_DFIFO_WRAP) { - a->rx_pos[Id] = 0; - } else { - a->rx_pos[Id] += DIVA_DFIFO_STEP; - } - if (*final) { - if (usr1) - *usr1 = tmp[2]; - if (usr2) - *usr2 = tmp[3]; - break; - } - } - return (read); + (dword *)&tmp[0], + 1); + if (tmp[0] & DIVA_DFIFO_WRAP) { + a->rx_pos[Id] = 0; + } else { + a->rx_pos[Id] += DIVA_DFIFO_STEP; + } + if (*final) { + if (usr1) + *usr1 = tmp[2]; + if (usr2) + *usr2 = tmp[3]; + break; + } + } + return (read); } /* --------------------------------------------------------------------- - Does check if one of streams had caused interrupt and does - wake up corresponding application + Does check if one of streams had caused interrupt and does + wake up corresponding application --------------------------------------------------------------------- */ -void pr_stream (ADAPTER * a) { +void pr_stream(ADAPTER *a) { } #endif /* } */ diff --git a/drivers/isdn/hardware/eicon/kst_ifc.h b/drivers/isdn/hardware/eicon/kst_ifc.h index 203189a010c2..894fdfda1090 100644 --- a/drivers/isdn/hardware/eicon/kst_ifc.h +++ b/drivers/isdn/hardware/eicon/kst_ifc.h @@ -1,25 +1,25 @@ /* * - Copyright (c) Eicon Networks, 2000. + Copyright (c) Eicon Networks, 2000. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 1.9 + Eicon File Revision : 1.9 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_EICON_TRACE_API__ @@ -35,9 +35,9 @@ typedef struct _diva_trace_ie { } diva_trace_ie_t; /* - Structure used to represent "State\\BX\\Modem" directory - to user. - */ + Structure used to represent "State\\BX\\Modem" directory + to user. +*/ typedef struct _diva_trace_modem_state { dword ChannelNumber; @@ -70,8 +70,8 @@ typedef struct _diva_trace_modem_state { } diva_trace_modem_state_t; /* - Representation of "State\\BX\\FAX" directory - */ + Representation of "State\\BX\\FAX" directory +*/ typedef struct _diva_trace_fax_state { dword ChannelNumber; dword Event; @@ -90,9 +90,9 @@ typedef struct _diva_trace_fax_state { } diva_trace_fax_state_t; /* - Structure used to represent Interface State in the abstract - and interface/D-channel protocol independent form. - */ + Structure used to represent Interface State in the abstract + and interface/D-channel protocol independent form. +*/ typedef struct _diva_trace_interface_state { char Layer1[DIVA_TRACE_LINE_TYPE_LEN]; char Layer2[DIVA_TRACE_LINE_TYPE_LEN]; @@ -164,18 +164,18 @@ typedef struct _diva_prot_statistics { typedef struct _diva_ifc_statistics { diva_incoming_call_statistics_t inc; diva_outgoing_call_statistics_t outg; - diva_modem_call_statistics_t mdm; - diva_fax_call_statistics_t fax; - diva_prot_statistics_t b1; - diva_prot_statistics_t b2; - diva_prot_statistics_t d1; - diva_prot_statistics_t d2; + diva_modem_call_statistics_t mdm; + diva_fax_call_statistics_t fax; + diva_prot_statistics_t b1; + diva_prot_statistics_t b2; + diva_prot_statistics_t d1; + diva_prot_statistics_t d2; } diva_ifc_statistics_t; /* - Structure used to represent "State\\BX" directory - to user. - */ + Structure used to represent "State\\BX" directory + to user. +*/ typedef struct _diva_trace_line_state { dword ChannelNumber; @@ -192,9 +192,9 @@ typedef struct _diva_trace_line_state { char LocalAddress[DIVA_TRACE_LINE_TYPE_LEN]; char LocalSubAddress[DIVA_TRACE_LINE_TYPE_LEN]; - diva_trace_ie_t call_BC; - diva_trace_ie_t call_HLC; - diva_trace_ie_t call_LLC; + diva_trace_ie_t call_BC; + diva_trace_ie_t call_HLC; + diva_trace_ie_t call_LLC; dword Charges; @@ -205,11 +205,11 @@ typedef struct _diva_trace_line_state { char UserID[DIVA_TRACE_LINE_TYPE_LEN]; diva_trace_modem_state_t modem; - diva_trace_fax_state_t fax; + diva_trace_fax_state_t fax; - diva_trace_interface_state_t* pInterface; + diva_trace_interface_state_t *pInterface; - diva_ifc_statistics_t* pInterfaceStat; + diva_ifc_statistics_t *pInterfaceStat; } diva_trace_line_state_t; @@ -222,115 +222,114 @@ typedef struct _diva_trace_line_state { #define DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE ('F') struct _diva_strace_library_interface; -typedef void (*diva_trace_channel_state_change_proc_t)(void* user_context, - struct _diva_strace_library_interface* hLib, - int Adapter, - diva_trace_line_state_t* channel, int notify_subject); -typedef void (*diva_trace_channel_trace_proc_t)(void* user_context, - struct _diva_strace_library_interface* hLib, - int Adapter, void* xlog_buffer, int length); -typedef void (*diva_trace_error_proc_t)(void* user_context, - struct _diva_strace_library_interface* hLib, - int Adapter, - int error, const char* file, int line); +typedef void (*diva_trace_channel_state_change_proc_t)(void *user_context, + struct _diva_strace_library_interface *hLib, + int Adapter, + diva_trace_line_state_t *channel, int notify_subject); +typedef void (*diva_trace_channel_trace_proc_t)(void *user_context, + struct _diva_strace_library_interface *hLib, + int Adapter, void *xlog_buffer, int length); +typedef void (*diva_trace_error_proc_t)(void *user_context, + struct _diva_strace_library_interface *hLib, + int Adapter, + int error, const char *file, int line); /* - This structure creates interface from user to library - */ + This structure creates interface from user to library +*/ typedef struct _diva_trace_library_user_interface { - void* user_context; - diva_trace_channel_state_change_proc_t notify_proc; - diva_trace_channel_trace_proc_t trace_proc; - diva_trace_error_proc_t error_notify_proc; + void *user_context; + diva_trace_channel_state_change_proc_t notify_proc; + diva_trace_channel_trace_proc_t trace_proc; + diva_trace_error_proc_t error_notify_proc; } diva_trace_library_user_interface_t; /* - Interface from Library to User - */ -typedef int (*DivaSTraceLibraryStart_proc_t)(void* hLib); -typedef int (*DivaSTraceLibraryFinit_proc_t)(void* hLib); -typedef int (*DivaSTraceMessageInput_proc_t)(void* hLib); -typedef void* (*DivaSTraceGetHandle_proc_t)(void* hLib); + Interface from Library to User +*/ +typedef int (*DivaSTraceLibraryStart_proc_t)(void *hLib); +typedef int (*DivaSTraceLibraryFinit_proc_t)(void *hLib); +typedef int (*DivaSTraceMessageInput_proc_t)(void *hLib); +typedef void* (*DivaSTraceGetHandle_proc_t)(void *hLib); /* - Turn Audio Tap trace on/off - Channel should be in the range 1 ... Number of Channels - */ -typedef int (*DivaSTraceSetAudioTap_proc_t)(void* hLib, int Channel, int on); + Turn Audio Tap trace on/off + Channel should be in the range 1 ... Number of Channels +*/ +typedef int (*DivaSTraceSetAudioTap_proc_t)(void *hLib, int Channel, int on); /* - Turn B-channel trace on/off - Channel should be in the range 1 ... Number of Channels - */ -typedef int (*DivaSTraceSetBChannel_proc_t)(void* hLib, int Channel, int on); + Turn B-channel trace on/off + Channel should be in the range 1 ... Number of Channels +*/ +typedef int (*DivaSTraceSetBChannel_proc_t)(void *hLib, int Channel, int on); /* - Turn D-channel (Layer1/Layer2/Layer3) trace on/off - Layer1 - All D-channel frames received/sent over the interface - inclusive Layer 2 headers, Layer 2 frames and TEI management frames - Layer2 - Events from LAPD protocol instance with SAPI of signalling protocol - Layer3 - All D-channel frames addressed to assigned to the card TEI and - SAPI of signalling protocol, and signalling protocol events. - */ -typedef int (*DivaSTraceSetDChannel_proc_t)(void* hLib, int on); + Turn D-channel (Layer1/Layer2/Layer3) trace on/off + Layer1 - All D-channel frames received/sent over the interface + inclusive Layer 2 headers, Layer 2 frames and TEI management frames + Layer2 - Events from LAPD protocol instance with SAPI of signalling protocol + Layer3 - All D-channel frames addressed to assigned to the card TEI and + SAPI of signalling protocol, and signalling protocol events. +*/ +typedef int (*DivaSTraceSetDChannel_proc_t)(void *hLib, int on); /* - Get overall card statistics - */ -typedef int (*DivaSTraceGetOutgoingCallStatistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetIncomingCallStatistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetModemStatistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetFaxStatistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetBLayer1Statistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetBLayer2Statistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetDLayer1Statistics_proc_t)(void* hLib); -typedef int (*DivaSTraceGetDLayer2Statistics_proc_t)(void* hLib); + Get overall card statistics +*/ +typedef int (*DivaSTraceGetOutgoingCallStatistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetIncomingCallStatistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetModemStatistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetFaxStatistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetBLayer1Statistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetBLayer2Statistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetDLayer1Statistics_proc_t)(void *hLib); +typedef int (*DivaSTraceGetDLayer2Statistics_proc_t)(void *hLib); /* - Call control - */ -typedef int (*DivaSTraceClearCall_proc_t)(void* hLib, int Channel); + Call control +*/ +typedef int (*DivaSTraceClearCall_proc_t)(void *hLib, int Channel); typedef struct _diva_strace_library_interface { - void* hLib; - DivaSTraceLibraryStart_proc_t DivaSTraceLibraryStart; - DivaSTraceLibraryStart_proc_t DivaSTraceLibraryStop; + void *hLib; + DivaSTraceLibraryStart_proc_t DivaSTraceLibraryStart; + DivaSTraceLibraryStart_proc_t DivaSTraceLibraryStop; DivaSTraceLibraryFinit_proc_t DivaSTraceLibraryFinit; DivaSTraceMessageInput_proc_t DivaSTraceMessageInput; - DivaSTraceGetHandle_proc_t DivaSTraceGetHandle; - DivaSTraceSetAudioTap_proc_t DivaSTraceSetAudioTap; - DivaSTraceSetBChannel_proc_t DivaSTraceSetBChannel; - DivaSTraceSetDChannel_proc_t DivaSTraceSetDChannel; - DivaSTraceSetDChannel_proc_t DivaSTraceSetInfo; + DivaSTraceGetHandle_proc_t DivaSTraceGetHandle; + DivaSTraceSetAudioTap_proc_t DivaSTraceSetAudioTap; + DivaSTraceSetBChannel_proc_t DivaSTraceSetBChannel; + DivaSTraceSetDChannel_proc_t DivaSTraceSetDChannel; + DivaSTraceSetDChannel_proc_t DivaSTraceSetInfo; DivaSTraceGetOutgoingCallStatistics_proc_t \ - DivaSTraceGetOutgoingCallStatistics; + DivaSTraceGetOutgoingCallStatistics; DivaSTraceGetIncomingCallStatistics_proc_t \ - DivaSTraceGetIncomingCallStatistics; + DivaSTraceGetIncomingCallStatistics; DivaSTraceGetModemStatistics_proc_t \ - DivaSTraceGetModemStatistics; + DivaSTraceGetModemStatistics; DivaSTraceGetFaxStatistics_proc_t \ - DivaSTraceGetFaxStatistics; + DivaSTraceGetFaxStatistics; DivaSTraceGetBLayer1Statistics_proc_t \ - DivaSTraceGetBLayer1Statistics; + DivaSTraceGetBLayer1Statistics; DivaSTraceGetBLayer2Statistics_proc_t \ - DivaSTraceGetBLayer2Statistics; + DivaSTraceGetBLayer2Statistics; DivaSTraceGetDLayer1Statistics_proc_t \ - DivaSTraceGetDLayer1Statistics; + DivaSTraceGetDLayer1Statistics; DivaSTraceGetDLayer2Statistics_proc_t \ - DivaSTraceGetDLayer2Statistics; - DivaSTraceClearCall_proc_t DivaSTraceClearCall; + DivaSTraceGetDLayer2Statistics; + DivaSTraceClearCall_proc_t DivaSTraceClearCall; } diva_strace_library_interface_t; /* - Create and return Library interface - */ -diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, - const diva_trace_library_user_interface_t* user_proc, - byte* pmem); -dword DivaSTraceGetMemotyRequirement (int channels); + Create and return Library interface +*/ +diva_strace_library_interface_t *DivaSTraceLibraryCreateInstance(int Adapter, + const diva_trace_library_user_interface_t *user_proc, + byte *pmem); +dword DivaSTraceGetMemotyRequirement(int channels); #define DIVA_MAX_ADAPTERS 64 #define DIVA_MAX_LINES 32 #endif - diff --git a/drivers/isdn/hardware/eicon/maintidi.c b/drivers/isdn/hardware/eicon/maintidi.c index 534978bdf382..2ee789f95867 100644 --- a/drivers/isdn/hardware/eicon/maintidi.c +++ b/drivers/isdn/hardware/eicon/maintidi.c @@ -1,25 +1,25 @@ /* * - Copyright (c) Eicon Networks, 2000. + Copyright (c) Eicon Networks, 2000. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 1.9 + Eicon File Revision : 1.9 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -30,7 +30,7 @@ #include "man_defs.h" -extern void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...); +extern void diva_mnt_internal_dprintf(dword drv_id, dword type, char *p, ...); #define MODEM_PARSE_ENTRIES 16 /* amount of variables of interest */ #define FAX_PARSE_ENTRIES 12 /* amount of variables of interest */ @@ -38,77 +38,77 @@ extern void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...); #define STAT_PARSE_ENTRIES 70 /* amount of variables of interest */ /* - LOCAL FUNCTIONS - */ -static int DivaSTraceLibraryStart (void* hLib); -static int DivaSTraceLibraryStop (void* hLib); -static int SuperTraceLibraryFinit (void* hLib); -static void* SuperTraceGetHandle (void* hLib); -static int SuperTraceMessageInput (void* hLib); -static int SuperTraceSetAudioTap (void* hLib, int Channel, int on); -static int SuperTraceSetBChannel (void* hLib, int Channel, int on); -static int SuperTraceSetDChannel (void* hLib, int on); -static int SuperTraceSetInfo (void* hLib, int on); -static int SuperTraceClearCall (void* hLib, int Channel); -static int SuperTraceGetOutgoingCallStatistics (void* hLib); -static int SuperTraceGetIncomingCallStatistics (void* hLib); -static int SuperTraceGetModemStatistics (void* hLib); -static int SuperTraceGetFaxStatistics (void* hLib); -static int SuperTraceGetBLayer1Statistics (void* hLib); -static int SuperTraceGetBLayer2Statistics (void* hLib); -static int SuperTraceGetDLayer1Statistics (void* hLib); -static int SuperTraceGetDLayer2Statistics (void* hLib); + LOCAL FUNCTIONS +*/ +static int DivaSTraceLibraryStart(void *hLib); +static int DivaSTraceLibraryStop(void *hLib); +static int SuperTraceLibraryFinit(void *hLib); +static void *SuperTraceGetHandle(void *hLib); +static int SuperTraceMessageInput(void *hLib); +static int SuperTraceSetAudioTap(void *hLib, int Channel, int on); +static int SuperTraceSetBChannel(void *hLib, int Channel, int on); +static int SuperTraceSetDChannel(void *hLib, int on); +static int SuperTraceSetInfo(void *hLib, int on); +static int SuperTraceClearCall(void *hLib, int Channel); +static int SuperTraceGetOutgoingCallStatistics(void *hLib); +static int SuperTraceGetIncomingCallStatistics(void *hLib); +static int SuperTraceGetModemStatistics(void *hLib); +static int SuperTraceGetFaxStatistics(void *hLib); +static int SuperTraceGetBLayer1Statistics(void *hLib); +static int SuperTraceGetBLayer2Statistics(void *hLib); +static int SuperTraceGetDLayer1Statistics(void *hLib); +static int SuperTraceGetDLayer2Statistics(void *hLib); /* - LOCAL FUNCTIONS - */ -static int ScheduleNextTraceRequest (diva_strace_context_t* pLib); -static int process_idi_event (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar); -static int process_idi_info (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar); -static int diva_modem_event (diva_strace_context_t* pLib, int Channel); -static int diva_fax_event (diva_strace_context_t* pLib, int Channel); -static int diva_line_event (diva_strace_context_t* pLib, int Channel); -static int diva_modem_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar); -static int diva_fax_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar); -static int diva_line_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar); -static int diva_ifc_statistics (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar); -static diva_man_var_header_t* get_next_var (diva_man_var_header_t* pVar); -static diva_man_var_header_t* find_var (diva_man_var_header_t* pVar, - const char* name); -static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var); -static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var); -static int diva_strace_read_asz (diva_man_var_header_t* pVar, char* var); -static int diva_strace_read_asc (diva_man_var_header_t* pVar, char* var); -static int diva_strace_read_ie (diva_man_var_header_t* pVar, - diva_trace_ie_t* var); -static void diva_create_parse_table (diva_strace_context_t* pLib); -static void diva_trace_error (diva_strace_context_t* pLib, - int error, const char* file, int line); -static void diva_trace_notify_user (diva_strace_context_t* pLib, - int Channel, - int notify_subject); -static int diva_trace_read_variable (diva_man_var_header_t* pVar, - void* variable); + LOCAL FUNCTIONS +*/ +static int ScheduleNextTraceRequest(diva_strace_context_t *pLib); +static int process_idi_event(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar); +static int process_idi_info(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar); +static int diva_modem_event(diva_strace_context_t *pLib, int Channel); +static int diva_fax_event(diva_strace_context_t *pLib, int Channel); +static int diva_line_event(diva_strace_context_t *pLib, int Channel); +static int diva_modem_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar); +static int diva_fax_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar); +static int diva_line_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar); +static int diva_ifc_statistics(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar); +static diva_man_var_header_t *get_next_var(diva_man_var_header_t *pVar); +static diva_man_var_header_t *find_var(diva_man_var_header_t *pVar, + const char *name); +static int diva_strace_read_int(diva_man_var_header_t *pVar, int *var); +static int diva_strace_read_uint(diva_man_var_header_t *pVar, dword *var); +static int diva_strace_read_asz(diva_man_var_header_t *pVar, char *var); +static int diva_strace_read_asc(diva_man_var_header_t *pVar, char *var); +static int diva_strace_read_ie(diva_man_var_header_t *pVar, + diva_trace_ie_t *var); +static void diva_create_parse_table(diva_strace_context_t *pLib); +static void diva_trace_error(diva_strace_context_t *pLib, + int error, const char *file, int line); +static void diva_trace_notify_user(diva_strace_context_t *pLib, + int Channel, + int notify_subject); +static int diva_trace_read_variable(diva_man_var_header_t *pVar, + void *variable); /* - Initialize the library and return context - of the created trace object that will represent - the IDI adapter. - Return 0 on error. - */ -diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, - const diva_trace_library_user_interface_t* user_proc, - byte* pmem) { - diva_strace_context_t* pLib = (diva_strace_context_t*)pmem; + Initialize the library and return context + of the created trace object that will represent + the IDI adapter. + Return 0 on error. +*/ +diva_strace_library_interface_t *DivaSTraceLibraryCreateInstance(int Adapter, + const diva_trace_library_user_interface_t *user_proc, + byte *pmem) { + diva_strace_context_t *pLib = (diva_strace_context_t *)pmem; int i; if (!pLib) { @@ -121,11 +121,11 @@ diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, pLib->Adapter = Adapter; /* - Set up Library Interface - */ + Set up Library Interface + */ pLib->instance.hLib = pLib; - pLib->instance.DivaSTraceLibraryStart = DivaSTraceLibraryStart; - pLib->instance.DivaSTraceLibraryStop = DivaSTraceLibraryStop; + pLib->instance.DivaSTraceLibraryStart = DivaSTraceLibraryStart; + pLib->instance.DivaSTraceLibraryStop = DivaSTraceLibraryStop; pLib->instance.DivaSTraceLibraryFinit = SuperTraceLibraryFinit; pLib->instance.DivaSTraceMessageInput = SuperTraceMessageInput; pLib->instance.DivaSTraceGetHandle = SuperTraceGetHandle; @@ -134,21 +134,21 @@ diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, pLib->instance.DivaSTraceSetDChannel = SuperTraceSetDChannel; pLib->instance.DivaSTraceSetInfo = SuperTraceSetInfo; pLib->instance.DivaSTraceGetOutgoingCallStatistics = \ - SuperTraceGetOutgoingCallStatistics; + SuperTraceGetOutgoingCallStatistics; pLib->instance.DivaSTraceGetIncomingCallStatistics = \ - SuperTraceGetIncomingCallStatistics; + SuperTraceGetIncomingCallStatistics; pLib->instance.DivaSTraceGetModemStatistics = \ - SuperTraceGetModemStatistics; + SuperTraceGetModemStatistics; pLib->instance.DivaSTraceGetFaxStatistics = \ - SuperTraceGetFaxStatistics; + SuperTraceGetFaxStatistics; pLib->instance.DivaSTraceGetBLayer1Statistics = \ - SuperTraceGetBLayer1Statistics; + SuperTraceGetBLayer1Statistics; pLib->instance.DivaSTraceGetBLayer2Statistics = \ - SuperTraceGetBLayer2Statistics; + SuperTraceGetBLayer2Statistics; pLib->instance.DivaSTraceGetDLayer1Statistics = \ - SuperTraceGetDLayer1Statistics; + SuperTraceGetDLayer1Statistics; pLib->instance.DivaSTraceGetDLayer2Statistics = \ - SuperTraceGetDLayer2Statistics; + SuperTraceGetDLayer2Statistics; pLib->instance.DivaSTraceClearCall = SuperTraceClearCall; @@ -159,272 +159,272 @@ diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter, pLib->user_proc_table.error_notify_proc = user_proc->error_notify_proc; } - if (!(pLib->hAdapter = SuperTraceOpenAdapter (Adapter))) { - diva_mnt_internal_dprintf (0, DLI_ERR, "Can not open XDI adapter"); + if (!(pLib->hAdapter = SuperTraceOpenAdapter(Adapter))) { + diva_mnt_internal_dprintf(0, DLI_ERR, "Can not open XDI adapter"); return NULL; } - pLib->Channels = SuperTraceGetNumberOfChannels (pLib->hAdapter); + pLib->Channels = SuperTraceGetNumberOfChannels(pLib->hAdapter); /* - Calculate amount of parte table entites necessary to translate - information from all events of onterest - */ + Calculate amount of parte table entites necessary to translate + information from all events of onterest + */ pLib->parse_entries = (MODEM_PARSE_ENTRIES + FAX_PARSE_ENTRIES + \ - STAT_PARSE_ENTRIES + \ - LINE_PARSE_ENTRIES + 1) * pLib->Channels; - pLib->parse_table = (diva_strace_path2action_t*)pmem; + STAT_PARSE_ENTRIES + \ + LINE_PARSE_ENTRIES + 1) * pLib->Channels; + pLib->parse_table = (diva_strace_path2action_t *)pmem; for (i = 0; i < 30; i++) { pLib->lines[i].pInterface = &pLib->Interface; pLib->lines[i].pInterfaceStat = &pLib->InterfaceStat; } - pLib->e.R = &pLib->RData; + pLib->e.R = &pLib->RData; pLib->req_busy = 1; pLib->rc_ok = ASSIGN_OK; - diva_create_parse_table (pLib); + diva_create_parse_table(pLib); - return ((diva_strace_library_interface_t*)pLib); + return ((diva_strace_library_interface_t *)pLib); } -static int DivaSTraceLibraryStart (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int DivaSTraceLibraryStart(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; - return (SuperTraceASSIGN (pLib->hAdapter, pLib->buffer)); + return (SuperTraceASSIGN(pLib->hAdapter, pLib->buffer)); } /* Return (-1) on error Return (0) if was initiated or pending Return (1) if removal is complete - */ -static int DivaSTraceLibraryStop (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +*/ +static int DivaSTraceLibraryStop(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; - if (!pLib->e.Id) { /* Was never started/assigned */ - return (1); - } + if (!pLib->e.Id) { /* Was never started/assigned */ + return (1); + } - switch (pLib->removal_state) { - case 0: - pLib->removal_state = 1; - ScheduleNextTraceRequest(pLib); - break; + switch (pLib->removal_state) { + case 0: + pLib->removal_state = 1; + ScheduleNextTraceRequest(pLib); + break; - case 3: - return (1); - } + case 3: + return (1); + } - return (0); + return (0); } -static int SuperTraceLibraryFinit (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceLibraryFinit(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if (pLib) { if (pLib->hAdapter) { - SuperTraceCloseAdapter (pLib->hAdapter); + SuperTraceCloseAdapter(pLib->hAdapter); } return (0); } return (-1); } -static void* SuperTraceGetHandle (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static void *SuperTraceGetHandle(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; - return (&pLib->e); + return (&pLib->e); } /* - After library handle object is gone in signaled state - this function should be called and will pick up incoming - IDI messages (return codes and indications). - */ -static int SuperTraceMessageInput (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; + After library handle object is gone in signaled state + this function should be called and will pick up incoming + IDI messages (return codes and indications). +*/ +static int SuperTraceMessageInput(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; int ret = 0; - byte Rc, Ind; + byte Rc, Ind; - if (pLib->e.complete == 255) { - /* - Process return code - */ - pLib->req_busy = 0; - Rc = pLib->e.Rc; - pLib->e.Rc = 0; + if (pLib->e.complete == 255) { + /* + Process return code + */ + pLib->req_busy = 0; + Rc = pLib->e.Rc; + pLib->e.Rc = 0; - if (pLib->removal_state == 2) { - pLib->removal_state = 3; - return (0); - } + if (pLib->removal_state == 2) { + pLib->removal_state = 3; + return (0); + } if (Rc != pLib->rc_ok) { - int ignore = 0; - /* - Auto-detect amount of events/channels and features - */ - if (pLib->general_b_ch_event == 1) { - pLib->general_b_ch_event = 2; - ignore = 1; - } else if (pLib->general_fax_event == 1) { - pLib->general_fax_event = 2; - ignore = 1; - } else if (pLib->general_mdm_event == 1) { - pLib->general_mdm_event = 2; - ignore = 1; - } else if ((pLib->ChannelsTraceActive < pLib->Channels) && pLib->ChannelsTraceActive) { - pLib->ChannelsTraceActive = pLib->Channels; - ignore = 1; - } else if (pLib->ModemTraceActive < pLib->Channels) { - pLib->ModemTraceActive = pLib->Channels; - ignore = 1; - } else if (pLib->FaxTraceActive < pLib->Channels) { - pLib->FaxTraceActive = pLib->Channels; - ignore = 1; - } else if (pLib->audio_trace_init == 2) { - ignore = 1; - pLib->audio_trace_init = 1; - } else if (pLib->eye_pattern_pending) { + int ignore = 0; + /* + Auto-detect amount of events/channels and features + */ + if (pLib->general_b_ch_event == 1) { + pLib->general_b_ch_event = 2; + ignore = 1; + } else if (pLib->general_fax_event == 1) { + pLib->general_fax_event = 2; + ignore = 1; + } else if (pLib->general_mdm_event == 1) { + pLib->general_mdm_event = 2; + ignore = 1; + } else if ((pLib->ChannelsTraceActive < pLib->Channels) && pLib->ChannelsTraceActive) { + pLib->ChannelsTraceActive = pLib->Channels; + ignore = 1; + } else if (pLib->ModemTraceActive < pLib->Channels) { + pLib->ModemTraceActive = pLib->Channels; + ignore = 1; + } else if (pLib->FaxTraceActive < pLib->Channels) { + pLib->FaxTraceActive = pLib->Channels; + ignore = 1; + } else if (pLib->audio_trace_init == 2) { + ignore = 1; + pLib->audio_trace_init = 1; + } else if (pLib->eye_pattern_pending) { pLib->eye_pattern_pending = 0; ignore = 1; } else if (pLib->audio_tap_pending) { pLib->audio_tap_pending = 0; ignore = 1; - } - - if (!ignore) { - return (-1); /* request failed */ - } - } else { - if (pLib->general_b_ch_event == 1) { - pLib->ChannelsTraceActive = pLib->Channels; - pLib->general_b_ch_event = 2; - } else if (pLib->general_fax_event == 1) { - pLib->general_fax_event = 2; - pLib->FaxTraceActive = pLib->Channels; - } else if (pLib->general_mdm_event == 1) { - pLib->general_mdm_event = 2; - pLib->ModemTraceActive = pLib->Channels; - } - } - if (pLib->audio_trace_init == 2) { - pLib->audio_trace_init = 1; - } - pLib->rc_ok = 0xff; /* default OK after assign was done */ - if ((ret = ScheduleNextTraceRequest(pLib))) { - return (-1); - } - } else { - /* - Process indication - Always 'RNR' indication if return code is pending - */ - Ind = pLib->e.Ind; - pLib->e.Ind = 0; - if (pLib->removal_state) { - pLib->e.RNum = 0; - pLib->e.RNR = 2; - } else if (pLib->req_busy) { - pLib->e.RNum = 0; - pLib->e.RNR = 1; - } else { - if (pLib->e.complete != 0x02) { - /* - Look-ahead call, set up buffers - */ - pLib->e.RNum = 1; - pLib->e.R->P = (byte*)&pLib->buffer[0]; - pLib->e.R->PLength = (word)(sizeof(pLib->buffer) - 1); - - } else { - /* - Indication reception complete, process it now - */ - byte* p = (byte*)&pLib->buffer[0]; - pLib->buffer[pLib->e.R->PLength] = 0; /* terminate I.E. with zero */ - - switch (Ind) { - case MAN_COMBI_IND: { - int total_length = pLib->e.R->PLength; - word this_ind_length; - - while (total_length > 3 && *p) { - Ind = *p++; - this_ind_length = (word)p[0] | ((word)p[1] << 8); - p += 2; - - switch (Ind) { - case MAN_INFO_IND: - if (process_idi_info (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_EVENT_IND: - if (process_idi_event (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_TRACE_IND: - if (pLib->trace_on == 1) { - /* - Ignore first trace event that is result of - EVENT_ON operation - */ - pLib->trace_on++; - } else { - /* - Delivery XLOG buffer to application - */ - if (pLib->user_proc_table.trace_proc) { - (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, - &pLib->instance, pLib->Adapter, - p, this_ind_length); - } - } - break; - default: - diva_mnt_internal_dprintf (0, DLI_ERR, "Unknown IDI Ind (DMA mode): %02x", Ind); - } - p += (this_ind_length+1); - total_length -= (4 + this_ind_length); - } - } break; - case MAN_INFO_IND: - if (process_idi_info (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_EVENT_IND: - if (process_idi_event (pLib, (diva_man_var_header_t*)p)) { - return (-1); - } - break; - case MAN_TRACE_IND: - if (pLib->trace_on == 1) { - /* - Ignore first trace event that is result of - EVENT_ON operation - */ - pLib->trace_on++; - } else { - /* - Delivery XLOG buffer to application - */ - if (pLib->user_proc_table.trace_proc) { - (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, - &pLib->instance, pLib->Adapter, - p, pLib->e.R->PLength); - } - } - break; - default: - diva_mnt_internal_dprintf (0, DLI_ERR, "Unknown IDI Ind: %02x", Ind); - } - } - } - } + } + + if (!ignore) { + return (-1); /* request failed */ + } + } else { + if (pLib->general_b_ch_event == 1) { + pLib->ChannelsTraceActive = pLib->Channels; + pLib->general_b_ch_event = 2; + } else if (pLib->general_fax_event == 1) { + pLib->general_fax_event = 2; + pLib->FaxTraceActive = pLib->Channels; + } else if (pLib->general_mdm_event == 1) { + pLib->general_mdm_event = 2; + pLib->ModemTraceActive = pLib->Channels; + } + } + if (pLib->audio_trace_init == 2) { + pLib->audio_trace_init = 1; + } + pLib->rc_ok = 0xff; /* default OK after assign was done */ + if ((ret = ScheduleNextTraceRequest(pLib))) { + return (-1); + } + } else { + /* + Process indication + Always 'RNR' indication if return code is pending + */ + Ind = pLib->e.Ind; + pLib->e.Ind = 0; + if (pLib->removal_state) { + pLib->e.RNum = 0; + pLib->e.RNR = 2; + } else if (pLib->req_busy) { + pLib->e.RNum = 0; + pLib->e.RNR = 1; + } else { + if (pLib->e.complete != 0x02) { + /* + Look-ahead call, set up buffers + */ + pLib->e.RNum = 1; + pLib->e.R->P = (byte *)&pLib->buffer[0]; + pLib->e.R->PLength = (word)(sizeof(pLib->buffer) - 1); + + } else { + /* + Indication reception complete, process it now + */ + byte *p = (byte *)&pLib->buffer[0]; + pLib->buffer[pLib->e.R->PLength] = 0; /* terminate I.E. with zero */ + + switch (Ind) { + case MAN_COMBI_IND: { + int total_length = pLib->e.R->PLength; + word this_ind_length; + + while (total_length > 3 && *p) { + Ind = *p++; + this_ind_length = (word)p[0] | ((word)p[1] << 8); + p += 2; + + switch (Ind) { + case MAN_INFO_IND: + if (process_idi_info(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_EVENT_IND: + if (process_idi_event(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_TRACE_IND: + if (pLib->trace_on == 1) { + /* + Ignore first trace event that is result of + EVENT_ON operation + */ + pLib->trace_on++; + } else { + /* + Delivery XLOG buffer to application + */ + if (pLib->user_proc_table.trace_proc) { + (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, + &pLib->instance, pLib->Adapter, + p, this_ind_length); + } + } + break; + default: + diva_mnt_internal_dprintf(0, DLI_ERR, "Unknown IDI Ind (DMA mode): %02x", Ind); + } + p += (this_ind_length + 1); + total_length -= (4 + this_ind_length); + } + } break; + case MAN_INFO_IND: + if (process_idi_info(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_EVENT_IND: + if (process_idi_event(pLib, (diva_man_var_header_t *)p)) { + return (-1); + } + break; + case MAN_TRACE_IND: + if (pLib->trace_on == 1) { + /* + Ignore first trace event that is result of + EVENT_ON operation + */ + pLib->trace_on++; + } else { + /* + Delivery XLOG buffer to application + */ + if (pLib->user_proc_table.trace_proc) { + (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context, + &pLib->instance, pLib->Adapter, + p, pLib->e.R->PLength); + } + } + break; + default: + diva_mnt_internal_dprintf(0, DLI_ERR, "Unknown IDI Ind: %02x", Ind); + } + } + } + } if ((ret = ScheduleNextTraceRequest(pLib))) { return (-1); @@ -434,9 +434,9 @@ static int SuperTraceMessageInput (void* hLib) { } /* - Internal state machine responsible for scheduling of requests - */ -static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { + Internal state machine responsible for scheduling of requests +*/ +static int ScheduleNextTraceRequest(diva_strace_context_t *pLib) { char name[64]; int ret = 0; int i; @@ -445,50 +445,50 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { return (0); } - if (pLib->removal_state == 1) { - if (SuperTraceREMOVE (pLib->hAdapter)) { - pLib->removal_state = 3; - } else { - pLib->req_busy = 1; - pLib->removal_state = 2; - } - return (0); - } + if (pLib->removal_state == 1) { + if (SuperTraceREMOVE(pLib->hAdapter)) { + pLib->removal_state = 3; + } else { + pLib->req_busy = 1; + pLib->removal_state = 2; + } + return (0); + } - if (pLib->removal_state) { - return (0); - } + if (pLib->removal_state) { + return (0); + } - if (!pLib->general_b_ch_event) { + if (!pLib->general_b_ch_event) { if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\B Event", pLib->buffer))) { - return (-1); - } - pLib->general_b_ch_event = 1; + return (-1); + } + pLib->general_b_ch_event = 1; pLib->req_busy = 1; return (0); - } + } - if (!pLib->general_fax_event) { + if (!pLib->general_fax_event) { if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\FAX Event", pLib->buffer))) { - return (-1); - } - pLib->general_fax_event = 1; + return (-1); + } + pLib->general_fax_event = 1; pLib->req_busy = 1; return (0); - } + } - if (!pLib->general_mdm_event) { + if (!pLib->general_mdm_event) { if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\Modem Event", pLib->buffer))) { - return (-1); - } - pLib->general_mdm_event = 1; + return (-1); + } + pLib->general_mdm_event = 1; pLib->req_busy = 1; return (0); - } + } if (pLib->ChannelsTraceActive < pLib->Channels) { pLib->ChannelsTraceActive++; - sprintf (name, "State\\B%d\\Line", pLib->ChannelsTraceActive); + sprintf(name, "State\\B%d\\Line", pLib->ChannelsTraceActive); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->ChannelsTraceActive--; return (-1); @@ -499,7 +499,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (pLib->ModemTraceActive < pLib->Channels) { pLib->ModemTraceActive++; - sprintf (name, "State\\B%d\\Modem\\Event", pLib->ModemTraceActive); + sprintf(name, "State\\B%d\\Modem\\Event", pLib->ModemTraceActive); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->ModemTraceActive--; return (-1); @@ -510,7 +510,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (pLib->FaxTraceActive < pLib->Channels) { pLib->FaxTraceActive++; - sprintf (name, "State\\B%d\\FAX\\Event", pLib->FaxTraceActive); + sprintf(name, "State\\B%d\\FAX\\Event", pLib->FaxTraceActive); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->FaxTraceActive--; return (-1); @@ -521,12 +521,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->trace_mask_init) { word tmp = 0x0000; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\Event Enable", - &tmp, - 0x87, /* MI_BITFLD */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\Event Enable", + &tmp, + 0x87, /* MI_BITFLD */ + sizeof(tmp))) { return (-1); } pLib->trace_mask_init = 1; @@ -536,12 +536,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->audio_trace_init) { dword tmp = 0x00000000; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\AudioCh# Enable", - &tmp, - 0x87, /* MI_BITFLD */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\AudioCh# Enable", + &tmp, + 0x87, /* MI_BITFLD */ + sizeof(tmp))) { return (-1); } pLib->audio_trace_init = 2; @@ -551,12 +551,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->bchannel_init) { dword tmp = 0x00000000; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\B-Ch# Enable", - &tmp, - 0x87, /* MI_BITFLD */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\B-Ch# Enable", + &tmp, + 0x87, /* MI_BITFLD */ + sizeof(tmp))) { return (-1); } pLib->bchannel_init = 1; @@ -566,12 +566,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->trace_length_init) { word tmp = 30; - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\Max Log Length", - &tmp, - 0x82, /* MI_UINT */ - sizeof(tmp))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\Max Log Length", + &tmp, + 0x82, /* MI_UINT */ + sizeof(tmp))) { return (-1); } pLib->trace_length_init = 1; @@ -580,9 +580,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->trace_on) { - if (SuperTraceTraceOnRequest (pLib->hAdapter, - "Trace\\Log Buffer", - pLib->buffer)) { + if (SuperTraceTraceOnRequest(pLib->hAdapter, + "Trace\\Log Buffer", + pLib->buffer)) { return (-1); } pLib->trace_on = 1; @@ -591,12 +591,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->trace_event_mask != pLib->current_trace_event_mask) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\Event Enable", - &pLib->trace_event_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->trace_event_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\Event Enable", + &pLib->trace_event_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->trace_event_mask))) { return (-1); } pLib->current_trace_event_mask = pLib->trace_event_mask; @@ -605,12 +605,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if ((pLib->audio_tap_pending >= 0) && (pLib->audio_tap_mask != pLib->current_audio_tap_mask)) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\AudioCh# Enable", - &pLib->audio_tap_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->audio_tap_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\AudioCh# Enable", + &pLib->audio_tap_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->audio_tap_mask))) { return (-1); } pLib->current_audio_tap_mask = pLib->audio_tap_mask; @@ -620,12 +620,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if ((pLib->eye_pattern_pending >= 0) && (pLib->audio_tap_mask != pLib->current_eye_pattern_mask)) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\EyeCh# Enable", - &pLib->audio_tap_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->audio_tap_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\EyeCh# Enable", + &pLib->audio_tap_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->audio_tap_mask))) { return (-1); } pLib->current_eye_pattern_mask = pLib->audio_tap_mask; @@ -635,12 +635,12 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->bchannel_trace_mask != pLib->current_bchannel_trace_mask) { - if (SuperTraceWriteVar (pLib->hAdapter, - pLib->buffer, - "Trace\\B-Ch# Enable", - &pLib->bchannel_trace_mask, - 0x87, /* MI_BITFLD */ - sizeof(pLib->bchannel_trace_mask))) { + if (SuperTraceWriteVar(pLib->hAdapter, + pLib->buffer, + "Trace\\B-Ch# Enable", + &pLib->bchannel_trace_mask, + 0x87, /* MI_BITFLD */ + sizeof(pLib->bchannel_trace_mask))) { return (-1); } pLib->current_bchannel_trace_mask = pLib->bchannel_trace_mask; @@ -649,9 +649,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->trace_events_down) { - if (SuperTraceTraceOnRequest (pLib->hAdapter, - "Events Down", - pLib->buffer)) { + if (SuperTraceTraceOnRequest(pLib->hAdapter, + "Events Down", + pLib->buffer)) { return (-1); } pLib->trace_events_down = 1; @@ -660,9 +660,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->l1_trace) { - if (SuperTraceTraceOnRequest (pLib->hAdapter, - "State\\Layer1", - pLib->buffer)) { + if (SuperTraceTraceOnRequest(pLib->hAdapter, + "State\\Layer1", + pLib->buffer)) { return (-1); } pLib->l1_trace = 1; @@ -671,9 +671,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->l2_trace) { - if (SuperTraceTraceOnRequest (pLib->hAdapter, - "State\\Layer2 No1", - pLib->buffer)) { + if (SuperTraceTraceOnRequest(pLib->hAdapter, + "State\\Layer2 No1", + pLib->buffer)) { return (-1); } pLib->l2_trace = 1; @@ -683,8 +683,8 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { for (i = 0; i < 30; i++) { if (pLib->pending_line_status & (1L << i)) { - sprintf (name, "State\\B%d", i+1); - if (SuperTraceReadRequest (pLib->hAdapter, name, pLib->buffer)) { + sprintf(name, "State\\B%d", i + 1); + if (SuperTraceReadRequest(pLib->hAdapter, name, pLib->buffer)) { return (-1); } pLib->pending_line_status &= ~(1L << i); @@ -692,8 +692,8 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { return (0); } if (pLib->pending_modem_status & (1L << i)) { - sprintf (name, "State\\B%d\\Modem", i+1); - if (SuperTraceReadRequest (pLib->hAdapter, name, pLib->buffer)) { + sprintf(name, "State\\B%d\\Modem", i + 1); + if (SuperTraceReadRequest(pLib->hAdapter, name, pLib->buffer)) { return (-1); } pLib->pending_modem_status &= ~(1L << i); @@ -701,8 +701,8 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { return (0); } if (pLib->pending_fax_status & (1L << i)) { - sprintf (name, "State\\B%d\\FAX", i+1); - if (SuperTraceReadRequest (pLib->hAdapter, name, pLib->buffer)) { + sprintf(name, "State\\B%d\\FAX", i + 1); + if (SuperTraceReadRequest(pLib->hAdapter, name, pLib->buffer)) { return (-1); } pLib->pending_fax_status &= ~(1L << i); @@ -710,8 +710,8 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { return (0); } if (pLib->clear_call_command & (1L << i)) { - sprintf (name, "State\\B%d\\Clear Call", i+1); - if (SuperTraceExecuteRequest (pLib->hAdapter, name, pLib->buffer)) { + sprintf(name, "State\\B%d\\Clear Call", i + 1); + if (SuperTraceExecuteRequest(pLib->hAdapter, name, pLib->buffer)) { return (-1); } pLib->clear_call_command &= ~(1L << i); @@ -721,9 +721,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->outgoing_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\Outgoing Calls", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\Outgoing Calls", + pLib->buffer)) { return (-1); } pLib->outgoing_ifc_stats = 0; @@ -732,9 +732,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->incoming_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\Incoming Calls", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\Incoming Calls", + pLib->buffer)) { return (-1); } pLib->incoming_ifc_stats = 0; @@ -743,9 +743,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->modem_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\Modem", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\Modem", + pLib->buffer)) { return (-1); } pLib->modem_ifc_stats = 0; @@ -754,9 +754,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->fax_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\FAX", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\FAX", + pLib->buffer)) { return (-1); } pLib->fax_ifc_stats = 0; @@ -765,9 +765,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->b1_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\B-Layer1", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\B-Layer1", + pLib->buffer)) { return (-1); } pLib->b1_ifc_stats = 0; @@ -776,9 +776,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->b2_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\B-Layer2", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\B-Layer2", + pLib->buffer)) { return (-1); } pLib->b2_ifc_stats = 0; @@ -787,9 +787,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->d1_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\D-Layer1", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\D-Layer1", + pLib->buffer)) { return (-1); } pLib->d1_ifc_stats = 0; @@ -798,9 +798,9 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (pLib->d2_ifc_stats) { - if (SuperTraceReadRequest (pLib->hAdapter, - "Statistics\\D-Layer2", - pLib->buffer)) { + if (SuperTraceReadRequest(pLib->hAdapter, + "Statistics\\D-Layer2", + pLib->buffer)) { return (-1); } pLib->d2_ifc_stats = 0; @@ -810,7 +810,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { if (!pLib->IncomingCallsCallsActive) { pLib->IncomingCallsCallsActive = 1; - sprintf (name, "%s", "Statistics\\Incoming Calls\\Calls"); + sprintf(name, "%s", "Statistics\\Incoming Calls\\Calls"); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->IncomingCallsCallsActive = 0; return (-1); @@ -820,7 +820,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->IncomingCallsConnectedActive) { pLib->IncomingCallsConnectedActive = 1; - sprintf (name, "%s", "Statistics\\Incoming Calls\\Connected"); + sprintf(name, "%s", "Statistics\\Incoming Calls\\Connected"); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->IncomingCallsConnectedActive = 0; return (-1); @@ -830,7 +830,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->OutgoingCallsCallsActive) { pLib->OutgoingCallsCallsActive = 1; - sprintf (name, "%s", "Statistics\\Outgoing Calls\\Calls"); + sprintf(name, "%s", "Statistics\\Outgoing Calls\\Calls"); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->OutgoingCallsCallsActive = 0; return (-1); @@ -840,7 +840,7 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { } if (!pLib->OutgoingCallsConnectedActive) { pLib->OutgoingCallsConnectedActive = 1; - sprintf (name, "%s", "Statistics\\Outgoing Calls\\Connected"); + sprintf(name, "%s", "Statistics\\Outgoing Calls\\Connected"); if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) { pLib->OutgoingCallsConnectedActive = 0; return (-1); @@ -852,241 +852,241 @@ static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) { return (0); } -static int process_idi_event (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar) { - const char* path = (char*)&pVar->path_length+1; +static int process_idi_event(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar) { + const char *path = (char *)&pVar->path_length + 1; char name[64]; int i; if (!strncmp("State\\B Event", path, pVar->path_length)) { - dword ch_id; - if (!diva_trace_read_variable (pVar, &ch_id)) { - if (!pLib->line_init_event && !pLib->pending_line_status) { - for (i = 1; i <= pLib->Channels; i++) { - diva_line_event(pLib, i); - } - return (0); - } else if (ch_id && ch_id <= pLib->Channels) { - return (diva_line_event(pLib, (int)ch_id)); - } - return (0); - } - return (-1); - } + dword ch_id; + if (!diva_trace_read_variable(pVar, &ch_id)) { + if (!pLib->line_init_event && !pLib->pending_line_status) { + for (i = 1; i <= pLib->Channels; i++) { + diva_line_event(pLib, i); + } + return (0); + } else if (ch_id && ch_id <= pLib->Channels) { + return (diva_line_event(pLib, (int)ch_id)); + } + return (0); + } + return (-1); + } if (!strncmp("State\\FAX Event", path, pVar->path_length)) { - dword ch_id; - if (!diva_trace_read_variable (pVar, &ch_id)) { - if (!pLib->pending_fax_status && !pLib->fax_init_event) { - for (i = 1; i <= pLib->Channels; i++) { - diva_fax_event(pLib, i); - } - return (0); - } else if (ch_id && ch_id <= pLib->Channels) { - return (diva_fax_event(pLib, (int)ch_id)); - } - return (0); - } - return (-1); - } + dword ch_id; + if (!diva_trace_read_variable(pVar, &ch_id)) { + if (!pLib->pending_fax_status && !pLib->fax_init_event) { + for (i = 1; i <= pLib->Channels; i++) { + diva_fax_event(pLib, i); + } + return (0); + } else if (ch_id && ch_id <= pLib->Channels) { + return (diva_fax_event(pLib, (int)ch_id)); + } + return (0); + } + return (-1); + } if (!strncmp("State\\Modem Event", path, pVar->path_length)) { - dword ch_id; - if (!diva_trace_read_variable (pVar, &ch_id)) { - if (!pLib->pending_modem_status && !pLib->modem_init_event) { - for (i = 1; i <= pLib->Channels; i++) { - diva_modem_event(pLib, i); - } - return (0); - } else if (ch_id && ch_id <= pLib->Channels) { - return (diva_modem_event(pLib, (int)ch_id)); - } - return (0); - } - return (-1); - } + dword ch_id; + if (!diva_trace_read_variable(pVar, &ch_id)) { + if (!pLib->pending_modem_status && !pLib->modem_init_event) { + for (i = 1; i <= pLib->Channels; i++) { + diva_modem_event(pLib, i); + } + return (0); + } else if (ch_id && ch_id <= pLib->Channels) { + return (diva_modem_event(pLib, (int)ch_id)); + } + return (0); + } + return (-1); + } /* - First look for Line Event - */ + First look for Line Event + */ for (i = 1; i <= pLib->Channels; i++) { - sprintf (name, "State\\B%d\\Line", i); - if (find_var (pVar, name)) { + sprintf(name, "State\\B%d\\Line", i); + if (find_var(pVar, name)) { return (diva_line_event(pLib, i)); } } /* - Look for Moden Progress Event - */ + Look for Moden Progress Event + */ for (i = 1; i <= pLib->Channels; i++) { - sprintf (name, "State\\B%d\\Modem\\Event", i); - if (find_var (pVar, name)) { - return (diva_modem_event (pLib, i)); + sprintf(name, "State\\B%d\\Modem\\Event", i); + if (find_var(pVar, name)) { + return (diva_modem_event(pLib, i)); } } /* - Look for Fax Event - */ + Look for Fax Event + */ for (i = 1; i <= pLib->Channels; i++) { - sprintf (name, "State\\B%d\\FAX\\Event", i); - if (find_var (pVar, name)) { - return (diva_fax_event (pLib, i)); + sprintf(name, "State\\B%d\\FAX\\Event", i); + if (find_var(pVar, name)) { + return (diva_fax_event(pLib, i)); } } /* - Notification about loss of events - */ + Notification about loss of events + */ if (!strncmp("Events Down", path, pVar->path_length)) { if (pLib->trace_events_down == 1) { pLib->trace_events_down = 2; } else { - diva_trace_error (pLib, 1, "Events Down", 0); + diva_trace_error(pLib, 1, "Events Down", 0); } return (0); } if (!strncmp("State\\Layer1", path, pVar->path_length)) { - diva_strace_read_asz (pVar, &pLib->lines[0].pInterface->Layer1[0]); + diva_strace_read_asz(pVar, &pLib->lines[0].pInterface->Layer1[0]); if (pLib->l1_trace == 1) { pLib->l1_trace = 2; } else { - diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE); + diva_trace_notify_user(pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE); } return (0); } if (!strncmp("State\\Layer2 No1", path, pVar->path_length)) { - char* tmp = &pLib->lines[0].pInterface->Layer2[0]; + char *tmp = &pLib->lines[0].pInterface->Layer2[0]; dword l2_state; if (diva_strace_read_uint(pVar, &l2_state)) return -1; switch (l2_state) { - case 0: - strcpy (tmp, "Idle"); - break; - case 1: - strcpy (tmp, "Layer2 UP"); - break; - case 2: - strcpy (tmp, "Layer2 Disconnecting"); - break; - case 3: - strcpy (tmp, "Layer2 Connecting"); - break; - case 4: - strcpy (tmp, "SPID Initializing"); - break; - case 5: - strcpy (tmp, "SPID Initialised"); - break; - case 6: - strcpy (tmp, "Layer2 Connecting"); - break; - - case 7: - strcpy (tmp, "Auto SPID Stopped"); - break; - - case 8: - strcpy (tmp, "Auto SPID Idle"); - break; - - case 9: - strcpy (tmp, "Auto SPID Requested"); - break; - - case 10: - strcpy (tmp, "Auto SPID Delivery"); - break; - - case 11: - strcpy (tmp, "Auto SPID Complete"); - break; - - default: - sprintf (tmp, "U:%d", (int)l2_state); + case 0: + strcpy(tmp, "Idle"); + break; + case 1: + strcpy(tmp, "Layer2 UP"); + break; + case 2: + strcpy(tmp, "Layer2 Disconnecting"); + break; + case 3: + strcpy(tmp, "Layer2 Connecting"); + break; + case 4: + strcpy(tmp, "SPID Initializing"); + break; + case 5: + strcpy(tmp, "SPID Initialised"); + break; + case 6: + strcpy(tmp, "Layer2 Connecting"); + break; + + case 7: + strcpy(tmp, "Auto SPID Stopped"); + break; + + case 8: + strcpy(tmp, "Auto SPID Idle"); + break; + + case 9: + strcpy(tmp, "Auto SPID Requested"); + break; + + case 10: + strcpy(tmp, "Auto SPID Delivery"); + break; + + case 11: + strcpy(tmp, "Auto SPID Complete"); + break; + + default: + sprintf(tmp, "U:%d", (int)l2_state); } if (pLib->l2_trace == 1) { pLib->l2_trace = 2; } else { - diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE); + diva_trace_notify_user(pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE); } return (0); } if (!strncmp("Statistics\\Incoming Calls\\Calls", path, pVar->path_length) || - !strncmp("Statistics\\Incoming Calls\\Connected", path, pVar->path_length)) { - return (SuperTraceGetIncomingCallStatistics (pLib)); + !strncmp("Statistics\\Incoming Calls\\Connected", path, pVar->path_length)) { + return (SuperTraceGetIncomingCallStatistics(pLib)); } if (!strncmp("Statistics\\Outgoing Calls\\Calls", path, pVar->path_length) || - !strncmp("Statistics\\Outgoing Calls\\Connected", path, pVar->path_length)) { - return (SuperTraceGetOutgoingCallStatistics (pLib)); + !strncmp("Statistics\\Outgoing Calls\\Connected", path, pVar->path_length)) { + return (SuperTraceGetOutgoingCallStatistics(pLib)); } return (-1); } -static int diva_line_event (diva_strace_context_t* pLib, int Channel) { - pLib->pending_line_status |= (1L << (Channel-1)); +static int diva_line_event(diva_strace_context_t *pLib, int Channel) { + pLib->pending_line_status |= (1L << (Channel - 1)); return (0); } -static int diva_modem_event (diva_strace_context_t* pLib, int Channel) { - pLib->pending_modem_status |= (1L << (Channel-1)); +static int diva_modem_event(diva_strace_context_t *pLib, int Channel) { + pLib->pending_modem_status |= (1L << (Channel - 1)); return (0); } -static int diva_fax_event (diva_strace_context_t* pLib, int Channel) { - pLib->pending_fax_status |= (1L << (Channel-1)); +static int diva_fax_event(diva_strace_context_t *pLib, int Channel) { + pLib->pending_fax_status |= (1L << (Channel - 1)); return (0); } /* - Process INFO indications that arrive from the card - Uses path of first I.E. to detect the source of the - infication - */ -static int process_idi_info (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar) { - const char* path = (char*)&pVar->path_length+1; + Process INFO indications that arrive from the card + Uses path of first I.E. to detect the source of the + infication +*/ +static int process_idi_info(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar) { + const char *path = (char *)&pVar->path_length + 1; char name[64]; int i, len; /* - First look for Modem Status Info - */ + First look for Modem Status Info + */ for (i = pLib->Channels; i > 0; i--) { - len = sprintf (name, "State\\B%d\\Modem", i); + len = sprintf(name, "State\\B%d\\Modem", i); if (!strncmp(name, path, len)) { - return (diva_modem_info (pLib, i, pVar)); + return (diva_modem_info(pLib, i, pVar)); } } /* - Look for Fax Status Info - */ + Look for Fax Status Info + */ for (i = pLib->Channels; i > 0; i--) { - len = sprintf (name, "State\\B%d\\FAX", i); + len = sprintf(name, "State\\B%d\\FAX", i); if (!strncmp(name, path, len)) { - return (diva_fax_info (pLib, i, pVar)); + return (diva_fax_info(pLib, i, pVar)); } } /* - Look for Line Status Info - */ + Look for Line Status Info + */ for (i = pLib->Channels; i > 0; i--) { - len = sprintf (name, "State\\B%d", i); + len = sprintf(name, "State\\B%d", i); if (!strncmp(name, path, len)) { - return (diva_line_info (pLib, i, pVar)); + return (diva_line_info(pLib, i, pVar)); } } - if (!diva_ifc_statistics (pLib, pVar)) { + if (!diva_ifc_statistics(pLib, pVar)) { return (0); } @@ -1094,38 +1094,38 @@ static int process_idi_info (diva_strace_context_t* pLib, } /* - MODEM INSTANCE STATE UPDATE - - Update Modem Status Information and issue notification to user, - that will inform about change in the state of modem instance, that is - associuated with this channel - */ -static int diva_modem_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar) { - diva_man_var_header_t* cur; + MODEM INSTANCE STATE UPDATE + + Update Modem Status Information and issue notification to user, + that will inform about change in the state of modem instance, that is + associuated with this channel +*/ +static int diva_modem_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar) { + diva_man_var_header_t *cur; int i, nr = Channel - 1; for (i = pLib->modem_parse_entry_first[nr]; - i <= pLib->modem_parse_entry_last[nr]; i++) { - if ((cur = find_var (pVar, pLib->parse_table[i].path))) { - if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { - diva_trace_error (pLib, -3 , __FILE__, __LINE__); + i <= pLib->modem_parse_entry_last[nr]; i++) { + if ((cur = find_var(pVar, pLib->parse_table[i].path))) { + if (diva_trace_read_variable(cur, pLib->parse_table[i].variable)) { + diva_trace_error(pLib, -3, __FILE__, __LINE__); return (-1); } } else { - diva_trace_error (pLib, -2 , __FILE__, __LINE__); + diva_trace_error(pLib, -2, __FILE__, __LINE__); return (-1); } } /* - We do not use first event to notify user - this is the event that is - generated as result of EVENT ON operation and is used only to initialize - internal variables of application - */ + We do not use first event to notify user - this is the event that is + generated as result of EVENT ON operation and is used only to initialize + internal variables of application + */ if (pLib->modem_init_event & (1L << nr)) { - diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE); + diva_trace_notify_user(pLib, nr, DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE); } else { pLib->modem_init_event |= (1L << nr); } @@ -1133,32 +1133,32 @@ static int diva_modem_info (diva_strace_context_t* pLib, return (0); } -static int diva_fax_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar) { - diva_man_var_header_t* cur; +static int diva_fax_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar) { + diva_man_var_header_t *cur; int i, nr = Channel - 1; for (i = pLib->fax_parse_entry_first[nr]; - i <= pLib->fax_parse_entry_last[nr]; i++) { - if ((cur = find_var (pVar, pLib->parse_table[i].path))) { - if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { - diva_trace_error (pLib, -3 , __FILE__, __LINE__); + i <= pLib->fax_parse_entry_last[nr]; i++) { + if ((cur = find_var(pVar, pLib->parse_table[i].path))) { + if (diva_trace_read_variable(cur, pLib->parse_table[i].variable)) { + diva_trace_error(pLib, -3, __FILE__, __LINE__); return (-1); } } else { - diva_trace_error (pLib, -2 , __FILE__, __LINE__); + diva_trace_error(pLib, -2, __FILE__, __LINE__); return (-1); } } /* - We do not use first event to notify user - this is the event that is - generated as result of EVENT ON operation and is used only to initialize - internal variables of application - */ + We do not use first event to notify user - this is the event that is + generated as result of EVENT ON operation and is used only to initialize + internal variables of application + */ if (pLib->fax_init_event & (1L << nr)) { - diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE); + diva_trace_notify_user(pLib, nr, DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE); } else { pLib->fax_init_event |= (1L << nr); } @@ -1167,43 +1167,43 @@ static int diva_fax_info (diva_strace_context_t* pLib, } /* - LINE STATE UPDATE - Update Line Status Information and issue notification to user, - that will inform about change in the line state. - */ -static int diva_line_info (diva_strace_context_t* pLib, - int Channel, - diva_man_var_header_t* pVar) { - diva_man_var_header_t* cur; + LINE STATE UPDATE + Update Line Status Information and issue notification to user, + that will inform about change in the line state. +*/ +static int diva_line_info(diva_strace_context_t *pLib, + int Channel, + diva_man_var_header_t *pVar) { + diva_man_var_header_t *cur; int i, nr = Channel - 1; - for (i = pLib->line_parse_entry_first[nr]; - i <= pLib->line_parse_entry_last[nr]; i++) { - if ((cur = find_var (pVar, pLib->parse_table[i].path))) { - if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { - diva_trace_error (pLib, -3 , __FILE__, __LINE__); + for (i = pLib->line_parse_entry_first[nr]; + i <= pLib->line_parse_entry_last[nr]; i++) { + if ((cur = find_var(pVar, pLib->parse_table[i].path))) { + if (diva_trace_read_variable(cur, pLib->parse_table[i].variable)) { + diva_trace_error(pLib, -3, __FILE__, __LINE__); return (-1); } } else { - diva_trace_error (pLib, -2 , __FILE__, __LINE__); + diva_trace_error(pLib, -2 , __FILE__, __LINE__); return (-1); } } /* - We do not use first event to notify user - this is the event that is - generated as result of EVENT ON operation and is used only to initialize - internal variables of application + We do not use first event to notify user - this is the event that is + generated as result of EVENT ON operation and is used only to initialize + internal variables of application - Exception is is if the line is "online". In this case we have to notify - user about this confition. - */ + Exception is is if the line is "online". In this case we have to notify + user about this confition. + */ if (pLib->line_init_event & (1L << nr)) { - diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE); + diva_trace_notify_user(pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE); } else { pLib->line_init_event |= (1L << nr); - if (strcmp (&pLib->lines[nr].Line[0], "Idle")) { - diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE); + if (strcmp(&pLib->lines[nr].Line[0], "Idle")) { + diva_trace_notify_user(pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE); } } @@ -1211,49 +1211,49 @@ static int diva_line_info (diva_strace_context_t* pLib, } /* - Move position to next vatianle in the chain - */ -static diva_man_var_header_t* get_next_var (diva_man_var_header_t* pVar) { - byte* msg = (byte*)pVar; - byte* start; + Move position to next vatianle in the chain +*/ +static diva_man_var_header_t *get_next_var(diva_man_var_header_t *pVar) { + byte *msg = (byte *)pVar; + byte *start; int msg_length; if (*msg != ESC) return NULL; start = msg + 2; - msg_length = *(msg+1); - msg = (start+msg_length); + msg_length = *(msg + 1); + msg = (start + msg_length); if (*msg != ESC) return NULL; - return ((diva_man_var_header_t*)msg); + return ((diva_man_var_header_t *)msg); } /* - Move position to variable with given name - */ -static diva_man_var_header_t* find_var (diva_man_var_header_t* pVar, - const char* name) { - const char* path; + Move position to variable with given name +*/ +static diva_man_var_header_t *find_var(diva_man_var_header_t *pVar, + const char *name) { + const char *path; do { - path = (char*)&pVar->path_length+1; + path = (char *)&pVar->path_length + 1; - if (!strncmp (name, path, pVar->path_length)) { + if (!strncmp(name, path, pVar->path_length)) { break; } - } while ((pVar = get_next_var (pVar))); + } while ((pVar = get_next_var(pVar))); return (pVar); } -static void diva_create_line_parse_table (diva_strace_context_t* pLib, - int Channel) { - diva_trace_line_state_t* pLine = &pLib->lines[Channel]; - int nr = Channel+1; +static void diva_create_line_parse_table(diva_strace_context_t *pLib, + int Channel) { + diva_trace_line_state_t *pLine = &pLib->lines[Channel]; + int nr = Channel + 1; if ((pLib->cur_parse_entry + LINE_PARSE_ENTRIES) >= pLib->parse_entries) { - diva_trace_error (pLib, -1, __FILE__, __LINE__); + diva_trace_error(pLib, -1, __FILE__, __LINE__); return; } @@ -1261,674 +1261,674 @@ static void diva_create_line_parse_table (diva_strace_context_t* pLib, pLib->line_parse_entry_first[Channel] = pLib->cur_parse_entry; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Framing", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Framing", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Framing[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Line", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Line", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Line[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Layer2", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Layer2", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Layer2[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Layer3", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Layer3", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Layer3[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Remote Address", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Remote Address", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLine->RemoteAddress[0]; + &pLine->RemoteAddress[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Remote SubAddr", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Remote SubAddr", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLine->RemoteSubAddress[0]; + &pLine->RemoteSubAddress[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Local Address", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Local Address", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLine->LocalAddress[0]; + &pLine->LocalAddress[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Local SubAddr", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Local SubAddr", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLine->LocalSubAddress[0]; + &pLine->LocalSubAddress[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\BC", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\BC", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->call_BC; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\HLC", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\HLC", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->call_HLC; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\LLC", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\LLC", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->call_LLC; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Charges", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Charges", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Charges; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Call Reference", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Call Reference", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->CallReference; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Last Disc Cause", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Last Disc Cause", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLine->LastDisconnecCause; + &pLine->LastDisconnecCause; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\User ID", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\User ID", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->UserID[0]; pLib->line_parse_entry_last[Channel] = pLib->cur_parse_entry - 1; } -static void diva_create_fax_parse_table (diva_strace_context_t* pLib, - int Channel) { - diva_trace_fax_state_t* pFax = &pLib->lines[Channel].fax; - int nr = Channel+1; +static void diva_create_fax_parse_table(diva_strace_context_t *pLib, + int Channel) { + diva_trace_fax_state_t *pFax = &pLib->lines[Channel].fax; + int nr = Channel + 1; if ((pLib->cur_parse_entry + FAX_PARSE_ENTRIES) >= pLib->parse_entries) { - diva_trace_error (pLib, -1, __FILE__, __LINE__); + diva_trace_error(pLib, -1, __FILE__, __LINE__); return; } pFax->ChannelNumber = nr; pLib->fax_parse_entry_first[Channel] = pLib->cur_parse_entry; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Event", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Event", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Event; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Page Counter", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Page Counter", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Page_Counter; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Features", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Features", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Features; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Station ID", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Station ID", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Station_ID[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Subaddress", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Subaddress", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Subaddress[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Password", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Password", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Password[0]; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Speed", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Speed", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Speed; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Resolution", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Resolution", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Resolution; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Paper Width", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Paper Width", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Paper_Width; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Paper Length", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Paper Length", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Paper_Length; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Scanline Time", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Scanline Time", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Scanline_Time; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\FAX\\Disc Reason", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\FAX\\Disc Reason", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Disc_Reason; pLib->fax_parse_entry_last[Channel] = pLib->cur_parse_entry - 1; } -static void diva_create_modem_parse_table (diva_strace_context_t* pLib, - int Channel) { - diva_trace_modem_state_t* pModem = &pLib->lines[Channel].modem; - int nr = Channel+1; +static void diva_create_modem_parse_table(diva_strace_context_t *pLib, + int Channel) { + diva_trace_modem_state_t *pModem = &pLib->lines[Channel].modem; + int nr = Channel + 1; if ((pLib->cur_parse_entry + MODEM_PARSE_ENTRIES) >= pLib->parse_entries) { - diva_trace_error (pLib, -1, __FILE__, __LINE__); + diva_trace_error(pLib, -1, __FILE__, __LINE__); return; } pModem->ChannelNumber = nr; pLib->modem_parse_entry_first[Channel] = pLib->cur_parse_entry; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Event", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Event", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->Event; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Norm", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Norm", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->Norm; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Options", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Options", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->Options; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\TX Speed", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\TX Speed", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->TxSpeed; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\RX Speed", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\RX Speed", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RxSpeed; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Roundtrip ms", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Roundtrip ms", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RoundtripMsec; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Symbol Rate", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Symbol Rate", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->SymbolRate; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\RX Level dBm", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\RX Level dBm", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RxLeveldBm; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Echo Level dBm", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Echo Level dBm", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->EchoLeveldBm; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\SNR dB", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\SNR dB", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->SNRdb; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\MAE", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\MAE", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->MAE; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Local Retrains", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Local Retrains", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->LocalRetrains; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Remote Retrains", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Remote Retrains", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RemoteRetrains; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Local Resyncs", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Local Resyncs", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->LocalResyncs; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Remote Resyncs", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Remote Resyncs", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RemoteResyncs; - sprintf (pLib->parse_table[pLib->cur_parse_entry].path, - "State\\B%d\\Modem\\Disc Reason", nr); + sprintf(pLib->parse_table[pLib->cur_parse_entry].path, + "State\\B%d\\Modem\\Disc Reason", nr); pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->DiscReason; pLib->modem_parse_entry_last[Channel] = pLib->cur_parse_entry - 1; } -static void diva_create_parse_table (diva_strace_context_t* pLib) { +static void diva_create_parse_table(diva_strace_context_t *pLib) { int i; for (i = 0; i < pLib->Channels; i++) { - diva_create_line_parse_table (pLib, i); - diva_create_modem_parse_table (pLib, i); - diva_create_fax_parse_table (pLib, i); + diva_create_line_parse_table(pLib, i); + diva_create_modem_parse_table(pLib, i); + diva_create_fax_parse_table(pLib, i); } pLib->statistic_parse_first = pLib->cur_parse_entry; /* - Outgoing Calls - */ - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\Calls"); + Outgoing Calls + */ + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\Calls"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.Calls; + &pLib->InterfaceStat.outg.Calls; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\Connected"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\Connected"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.Connected; + &pLib->InterfaceStat.outg.Connected; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\User Busy"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\User Busy"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.User_Busy; + &pLib->InterfaceStat.outg.User_Busy; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\No Answer"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\No Answer"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.No_Answer; + &pLib->InterfaceStat.outg.No_Answer; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\Wrong Number"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\Wrong Number"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.Wrong_Number; + &pLib->InterfaceStat.outg.Wrong_Number; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\Call Rejected"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\Call Rejected"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.Call_Rejected; + &pLib->InterfaceStat.outg.Call_Rejected; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Outgoing Calls\\Other Failures"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Outgoing Calls\\Other Failures"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.outg.Other_Failures; + &pLib->InterfaceStat.outg.Other_Failures; /* - Incoming Calls - */ - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Calls"); + Incoming Calls + */ + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Calls"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Calls; + &pLib->InterfaceStat.inc.Calls; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Connected"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Connected"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Connected; + &pLib->InterfaceStat.inc.Connected; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\User Busy"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\User Busy"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.User_Busy; + &pLib->InterfaceStat.inc.User_Busy; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Call Rejected"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Call Rejected"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Call_Rejected; + &pLib->InterfaceStat.inc.Call_Rejected; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Wrong Number"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Wrong Number"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Wrong_Number; + &pLib->InterfaceStat.inc.Wrong_Number; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Incompatible Dst"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Incompatible Dst"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Incompatible_Dst; + &pLib->InterfaceStat.inc.Incompatible_Dst; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Out of Order"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Out of Order"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Out_of_Order; + &pLib->InterfaceStat.inc.Out_of_Order; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Incoming Calls\\Ignored"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Incoming Calls\\Ignored"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.inc.Ignored; + &pLib->InterfaceStat.inc.Ignored; /* - Modem Statistics - */ + Modem Statistics + */ pLib->mdm_statistic_parse_first = pLib->cur_parse_entry; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Normal"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Normal"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Normal; + &pLib->InterfaceStat.mdm.Disc_Normal; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Unspecified"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Unspecified"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Unspecified; + &pLib->InterfaceStat.mdm.Disc_Unspecified; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Busy Tone"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Busy Tone"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Busy_Tone; + &pLib->InterfaceStat.mdm.Disc_Busy_Tone; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Congestion"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Congestion"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Congestion; + &pLib->InterfaceStat.mdm.Disc_Congestion; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Carr. Wait"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Carr. Wait"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Carr_Wait; + &pLib->InterfaceStat.mdm.Disc_Carr_Wait; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Trn Timeout"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Trn Timeout"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Trn_Timeout; + &pLib->InterfaceStat.mdm.Disc_Trn_Timeout; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Incompat."); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Incompat."); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Incompat; + &pLib->InterfaceStat.mdm.Disc_Incompat; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc Frame Rej."); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc Frame Rej."); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_Frame_Rej; + &pLib->InterfaceStat.mdm.Disc_Frame_Rej; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\Modem\\Disc V42bis"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\Modem\\Disc V42bis"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.mdm.Disc_V42bis; + &pLib->InterfaceStat.mdm.Disc_V42bis; pLib->mdm_statistic_parse_last = pLib->cur_parse_entry - 1; /* - Fax Statistics - */ + Fax Statistics + */ pLib->fax_statistic_parse_first = pLib->cur_parse_entry; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Normal"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Normal"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Normal; + &pLib->InterfaceStat.fax.Disc_Normal; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Not Ident."); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Not Ident."); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Not_Ident; + &pLib->InterfaceStat.fax.Disc_Not_Ident; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc No Response"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc No Response"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_No_Response; + &pLib->InterfaceStat.fax.Disc_No_Response; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Retries"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Retries"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Retries; + &pLib->InterfaceStat.fax.Disc_Retries; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Unexp. Msg."); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Unexp. Msg."); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Unexp_Msg; + &pLib->InterfaceStat.fax.Disc_Unexp_Msg; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc No Polling."); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc No Polling."); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_No_Polling; + &pLib->InterfaceStat.fax.Disc_No_Polling; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Training"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Training"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Training; + &pLib->InterfaceStat.fax.Disc_Training; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Unexpected"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Unexpected"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Unexpected; + &pLib->InterfaceStat.fax.Disc_Unexpected; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Application"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Application"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Application; + &pLib->InterfaceStat.fax.Disc_Application; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Incompat."); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Incompat."); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Incompat; + &pLib->InterfaceStat.fax.Disc_Incompat; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc No Command"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc No Command"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_No_Command; + &pLib->InterfaceStat.fax.Disc_No_Command; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Long Msg"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Long Msg"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Long_Msg; + &pLib->InterfaceStat.fax.Disc_Long_Msg; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Supervisor"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Supervisor"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Supervisor; + &pLib->InterfaceStat.fax.Disc_Supervisor; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc SUB SEP PWD"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc SUB SEP PWD"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_SUB_SEP_PWD; + &pLib->InterfaceStat.fax.Disc_SUB_SEP_PWD; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Invalid Msg"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Invalid Msg"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Invalid_Msg; + &pLib->InterfaceStat.fax.Disc_Invalid_Msg; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Page Coding"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Page Coding"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Page_Coding; + &pLib->InterfaceStat.fax.Disc_Page_Coding; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc App Timeout"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc App Timeout"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_App_Timeout; + &pLib->InterfaceStat.fax.Disc_App_Timeout; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\FAX\\Disc Unspecified"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\FAX\\Disc Unspecified"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.fax.Disc_Unspecified; + &pLib->InterfaceStat.fax.Disc_Unspecified; pLib->fax_statistic_parse_last = pLib->cur_parse_entry - 1; /* - B-Layer1" - */ - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer1\\X-Frames"); + B-Layer1" + */ + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer1\\X-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b1.X_Frames; + &pLib->InterfaceStat.b1.X_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer1\\X-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer1\\X-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b1.X_Bytes; + &pLib->InterfaceStat.b1.X_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer1\\X-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer1\\X-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b1.X_Errors; + &pLib->InterfaceStat.b1.X_Errors; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer1\\R-Frames"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer1\\R-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b1.R_Frames; + &pLib->InterfaceStat.b1.R_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer1\\R-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer1\\R-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b1.R_Bytes; + &pLib->InterfaceStat.b1.R_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer1\\R-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer1\\R-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b1.R_Errors; + &pLib->InterfaceStat.b1.R_Errors; /* - B-Layer2 - */ - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer2\\X-Frames"); + B-Layer2 + */ + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer2\\X-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b2.X_Frames; + &pLib->InterfaceStat.b2.X_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer2\\X-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer2\\X-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b2.X_Bytes; + &pLib->InterfaceStat.b2.X_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer2\\X-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer2\\X-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b2.X_Errors; + &pLib->InterfaceStat.b2.X_Errors; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer2\\R-Frames"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer2\\R-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b2.R_Frames; + &pLib->InterfaceStat.b2.R_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer2\\R-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer2\\R-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b2.R_Bytes; + &pLib->InterfaceStat.b2.R_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\B-Layer2\\R-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\B-Layer2\\R-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.b2.R_Errors; + &pLib->InterfaceStat.b2.R_Errors; /* - D-Layer1 - */ - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer1\\X-Frames"); + D-Layer1 + */ + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer1\\X-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d1.X_Frames; + &pLib->InterfaceStat.d1.X_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer1\\X-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer1\\X-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d1.X_Bytes; + &pLib->InterfaceStat.d1.X_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer1\\X-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer1\\X-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d1.X_Errors; + &pLib->InterfaceStat.d1.X_Errors; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer1\\R-Frames"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer1\\R-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d1.R_Frames; + &pLib->InterfaceStat.d1.R_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer1\\R-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer1\\R-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d1.R_Bytes; + &pLib->InterfaceStat.d1.R_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer1\\R-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer1\\R-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d1.R_Errors; + &pLib->InterfaceStat.d1.R_Errors; /* - D-Layer2 - */ - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer2\\X-Frames"); + D-Layer2 + */ + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer2\\X-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d2.X_Frames; + &pLib->InterfaceStat.d2.X_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer2\\X-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer2\\X-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d2.X_Bytes; + &pLib->InterfaceStat.d2.X_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer2\\X-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer2\\X-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d2.X_Errors; + &pLib->InterfaceStat.d2.X_Errors; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer2\\R-Frames"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer2\\R-Frames"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d2.R_Frames; + &pLib->InterfaceStat.d2.R_Frames; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer2\\R-Bytes"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer2\\R-Bytes"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d2.R_Bytes; + &pLib->InterfaceStat.d2.R_Bytes; - strcpy (pLib->parse_table[pLib->cur_parse_entry].path, - "Statistics\\D-Layer2\\R-Errors"); + strcpy(pLib->parse_table[pLib->cur_parse_entry].path, + "Statistics\\D-Layer2\\R-Errors"); pLib->parse_table[pLib->cur_parse_entry++].variable = \ - &pLib->InterfaceStat.d2.R_Errors; + &pLib->InterfaceStat.d2.R_Errors; pLib->statistic_parse_last = pLib->cur_parse_entry - 1; } -static void diva_trace_error (diva_strace_context_t* pLib, - int error, const char* file, int line) { +static void diva_trace_error(diva_strace_context_t *pLib, + int error, const char *file, int line) { if (pLib->user_proc_table.error_notify_proc) { (*(pLib->user_proc_table.error_notify_proc))(\ - pLib->user_proc_table.user_context, - &pLib->instance, pLib->Adapter, - error, file, line); + pLib->user_proc_table.user_context, + &pLib->instance, pLib->Adapter, + error, file, line); } } /* - Delivery notification to user - */ -static void diva_trace_notify_user (diva_strace_context_t* pLib, - int Channel, - int notify_subject) { + Delivery notification to user +*/ +static void diva_trace_notify_user(diva_strace_context_t *pLib, + int Channel, + int notify_subject) { if (pLib->user_proc_table.notify_proc) { (*(pLib->user_proc_table.notify_proc))(pLib->user_proc_table.user_context, - &pLib->instance, - pLib->Adapter, - &pLib->lines[Channel], - notify_subject); + &pLib->instance, + pLib->Adapter, + &pLib->lines[Channel], + notify_subject); } } /* - Read variable value to they destination based on the variable type - */ -static int diva_trace_read_variable (diva_man_var_header_t* pVar, - void* variable) { + Read variable value to they destination based on the variable type +*/ +static int diva_trace_read_variable(diva_man_var_header_t *pVar, + void *variable) { switch (pVar->type) { - case 0x03: /* MI_ASCIIZ - syting */ - return (diva_strace_read_asz (pVar, (char*)variable)); - case 0x04: /* MI_ASCII - string */ - return (diva_strace_read_asc (pVar, (char*)variable)); - case 0x05: /* MI_NUMBER - counted sequence of bytes */ - return (diva_strace_read_ie (pVar, (diva_trace_ie_t*)variable)); - case 0x81: /* MI_INT - signed integer */ - return (diva_strace_read_int (pVar, (int*)variable)); - case 0x82: /* MI_UINT - unsigned integer */ - return (diva_strace_read_uint (pVar, (dword*)variable)); - case 0x83: /* MI_HINT - unsigned integer, hex representetion */ - return (diva_strace_read_uint (pVar, (dword*)variable)); - case 0x87: /* MI_BITFLD - unsigned integer, bit representation */ - return (diva_strace_read_uint (pVar, (dword*)variable)); + case 0x03: /* MI_ASCIIZ - syting */ + return (diva_strace_read_asz(pVar, (char *)variable)); + case 0x04: /* MI_ASCII - string */ + return (diva_strace_read_asc(pVar, (char *)variable)); + case 0x05: /* MI_NUMBER - counted sequence of bytes */ + return (diva_strace_read_ie(pVar, (diva_trace_ie_t *)variable)); + case 0x81: /* MI_INT - signed integer */ + return (diva_strace_read_int(pVar, (int *)variable)); + case 0x82: /* MI_UINT - unsigned integer */ + return (diva_strace_read_uint(pVar, (dword *)variable)); + case 0x83: /* MI_HINT - unsigned integer, hex representetion */ + return (diva_strace_read_uint(pVar, (dword *)variable)); + case 0x87: /* MI_BITFLD - unsigned integer, bit representation */ + return (diva_strace_read_uint(pVar, (dword *)variable)); } /* - This type of variable is not handled, indicate error - Or one problem in management interface, or in application recodeing - table, or this application should handle it. - */ + This type of variable is not handled, indicate error + Or one problem in management interface, or in application recodeing + table, or this application should handle it. + */ return (-1); } /* - Read signed integer to destination - */ -static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var) { - byte* ptr = (char*)&pVar->path_length; + Read signed integer to destination +*/ +static int diva_strace_read_int(diva_man_var_header_t *pVar, int *var) { + byte *ptr = (char *)&pVar->path_length; int value; ptr += (pVar->path_length + 1); switch (pVar->value_length) { - case 1: - value = *(char*)ptr; - break; + case 1: + value = *(char *)ptr; + break; - case 2: - value = (short)GET_WORD(ptr); - break; + case 2: + value = (short)GET_WORD(ptr); + break; - case 4: - value = (int)GET_DWORD(ptr); - break; + case 4: + value = (int)GET_DWORD(ptr); + break; - default: - return (-1); + default: + return (-1); } *var = value; @@ -1936,32 +1936,32 @@ static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var) { return (0); } -static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var) { - byte* ptr = (char*)&pVar->path_length; +static int diva_strace_read_uint(diva_man_var_header_t *pVar, dword *var) { + byte *ptr = (char *)&pVar->path_length; dword value; ptr += (pVar->path_length + 1); switch (pVar->value_length) { - case 1: - value = (byte)(*ptr); - break; + case 1: + value = (byte)(*ptr); + break; - case 2: - value = (word)GET_WORD(ptr); - break; + case 2: + value = (word)GET_WORD(ptr); + break; - case 3: - value = (dword)GET_DWORD(ptr); - value &= 0x00ffffff; - break; + case 3: + value = (dword)GET_DWORD(ptr); + value &= 0x00ffffff; + break; - case 4: - value = (dword)GET_DWORD(ptr); - break; + case 4: + value = (dword)GET_DWORD(ptr); + break; - default: - return (-1); + default: + return (-1); } *var = value; @@ -1970,54 +1970,54 @@ static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var) { } /* - Read zero terminated ASCII string - */ -static int diva_strace_read_asz (diva_man_var_header_t* pVar, char* var) { - char* ptr = (char*)&pVar->path_length; + Read zero terminated ASCII string +*/ +static int diva_strace_read_asz(diva_man_var_header_t *pVar, char *var) { + char *ptr = (char *)&pVar->path_length; int length; ptr += (pVar->path_length + 1); if (!(length = pVar->value_length)) { - length = strlen (ptr); + length = strlen(ptr); } - memcpy (var, ptr, length); + memcpy(var, ptr, length); var[length] = 0; return (0); } /* - Read counted (with leading length byte) ASCII string - */ -static int diva_strace_read_asc (diva_man_var_header_t* pVar, char* var) { - char* ptr = (char*)&pVar->path_length; + Read counted (with leading length byte) ASCII string +*/ +static int diva_strace_read_asc(diva_man_var_header_t *pVar, char *var) { + char *ptr = (char *)&pVar->path_length; ptr += (pVar->path_length + 1); - memcpy (var, ptr+1, *ptr); + memcpy(var, ptr + 1, *ptr); var[(int)*ptr] = 0; return (0); } /* - Read one information element - i.e. one string of byte values with - one length byte in front - */ -static int diva_strace_read_ie (diva_man_var_header_t* pVar, - diva_trace_ie_t* var) { - char* ptr = (char*)&pVar->path_length; + Read one information element - i.e. one string of byte values with + one length byte in front +*/ +static int diva_strace_read_ie(diva_man_var_header_t *pVar, + diva_trace_ie_t *var) { + char *ptr = (char *)&pVar->path_length; ptr += (pVar->path_length + 1); var->length = *ptr; - memcpy (&var->data[0], ptr+1, *ptr); + memcpy(&var->data[0], ptr + 1, *ptr); return (0); } -static int SuperTraceSetAudioTap (void* hLib, int Channel, int on) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceSetAudioTap(void *hLib, int Channel, int on) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if ((Channel < 1) || (Channel > pLib->Channels)) { return (-1); @@ -2030,21 +2030,21 @@ static int SuperTraceSetAudioTap (void* hLib, int Channel, int on) { pLib->audio_tap_mask &= ~(1L << Channel); } - /* - EYE patterns have TM_M_DATA set as additional - condition - */ - if (pLib->audio_tap_mask) { - pLib->trace_event_mask |= TM_M_DATA; - } else { - pLib->trace_event_mask &= ~TM_M_DATA; - } + /* + EYE patterns have TM_M_DATA set as additional + condition + */ + if (pLib->audio_tap_mask) { + pLib->trace_event_mask |= TM_M_DATA; + } else { + pLib->trace_event_mask &= ~TM_M_DATA; + } - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceSetBChannel (void* hLib, int Channel, int on) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceSetBChannel(void *hLib, int Channel, int on) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if ((Channel < 1) || (Channel > pLib->Channels)) { return (-1); @@ -2057,11 +2057,11 @@ static int SuperTraceSetBChannel (void* hLib, int Channel, int on) { pLib->bchannel_trace_mask &= ~(1L << Channel); } - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceSetDChannel (void* hLib, int on) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceSetDChannel(void *hLib, int on) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if (on) { pLib->trace_event_mask |= (TM_D_CHAN | TM_C_COMM | TM_DL_ERR | TM_LAYER1); @@ -2069,11 +2069,11 @@ static int SuperTraceSetDChannel (void* hLib, int on) { pLib->trace_event_mask &= ~(TM_D_CHAN | TM_C_COMM | TM_DL_ERR | TM_LAYER1); } - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceSetInfo (void* hLib, int on) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceSetInfo(void *hLib, int on) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if (on) { pLib->trace_event_mask |= TM_STRING; @@ -2081,11 +2081,11 @@ static int SuperTraceSetInfo (void* hLib, int on) { pLib->trace_event_mask &= ~TM_STRING; } - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceClearCall (void* hLib, int Channel) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceClearCall(void *hLib, int Channel) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; if ((Channel < 1) || (Channel > pLib->Channels)) { return (-1); @@ -2094,102 +2094,101 @@ static int SuperTraceClearCall (void* hLib, int Channel) { pLib->clear_call_command |= (1L << Channel); - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } /* - Parse and update cumulative statistice - */ -static int diva_ifc_statistics (diva_strace_context_t* pLib, - diva_man_var_header_t* pVar) { - diva_man_var_header_t* cur; + Parse and update cumulative statistice +*/ +static int diva_ifc_statistics(diva_strace_context_t *pLib, + diva_man_var_header_t *pVar) { + diva_man_var_header_t *cur; int i, one_updated = 0, mdm_updated = 0, fax_updated = 0; for (i = pLib->statistic_parse_first; i <= pLib->statistic_parse_last; i++) { - if ((cur = find_var (pVar, pLib->parse_table[i].path))) { - if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) { - diva_trace_error (pLib, -3 , __FILE__, __LINE__); + if ((cur = find_var(pVar, pLib->parse_table[i].path))) { + if (diva_trace_read_variable(cur, pLib->parse_table[i].variable)) { + diva_trace_error(pLib, -3 , __FILE__, __LINE__); return (-1); } one_updated = 1; - if ((i >= pLib->mdm_statistic_parse_first) && (i <= pLib->mdm_statistic_parse_last)) { - mdm_updated = 1; - } - if ((i >= pLib->fax_statistic_parse_first) && (i <= pLib->fax_statistic_parse_last)) { - fax_updated = 1; - } + if ((i >= pLib->mdm_statistic_parse_first) && (i <= pLib->mdm_statistic_parse_last)) { + mdm_updated = 1; + } + if ((i >= pLib->fax_statistic_parse_first) && (i <= pLib->fax_statistic_parse_last)) { + fax_updated = 1; + } } } /* - We do not use first event to notify user - this is the event that is - generated as result of EVENT ON operation and is used only to initialize - internal variables of application - */ - if (mdm_updated) { - diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE); - } else if (fax_updated) { - diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE); - } else if (one_updated) { - diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE); + We do not use first event to notify user - this is the event that is + generated as result of EVENT ON operation and is used only to initialize + internal variables of application + */ + if (mdm_updated) { + diva_trace_notify_user(pLib, 0, DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE); + } else if (fax_updated) { + diva_trace_notify_user(pLib, 0, DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE); + } else if (one_updated) { + diva_trace_notify_user(pLib, 0, DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE); } return (one_updated ? 0 : -1); } -static int SuperTraceGetOutgoingCallStatistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetOutgoingCallStatistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->outgoing_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetIncomingCallStatistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetIncomingCallStatistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->incoming_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetModemStatistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetModemStatistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->modem_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetFaxStatistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetFaxStatistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->fax_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetBLayer1Statistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetBLayer1Statistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->b1_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetBLayer2Statistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetBLayer2Statistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->b2_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetDLayer1Statistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetDLayer1Statistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->d1_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -static int SuperTraceGetDLayer2Statistics (void* hLib) { - diva_strace_context_t* pLib = (diva_strace_context_t*)hLib; +static int SuperTraceGetDLayer2Statistics(void *hLib) { + diva_strace_context_t *pLib = (diva_strace_context_t *)hLib; pLib->d2_ifc_stats = 1; - return (ScheduleNextTraceRequest (pLib)); + return (ScheduleNextTraceRequest(pLib)); } -dword DivaSTraceGetMemotyRequirement (int channels) { - dword parse_entries = (MODEM_PARSE_ENTRIES + FAX_PARSE_ENTRIES + \ - STAT_PARSE_ENTRIES + \ - LINE_PARSE_ENTRIES + 1) * channels; - return (sizeof(diva_strace_context_t) + \ - (parse_entries * sizeof(diva_strace_path2action_t))); +dword DivaSTraceGetMemotyRequirement(int channels) { + dword parse_entries = (MODEM_PARSE_ENTRIES + FAX_PARSE_ENTRIES + \ + STAT_PARSE_ENTRIES + \ + LINE_PARSE_ENTRIES + 1) * channels; + return (sizeof(diva_strace_context_t) + \ + (parse_entries * sizeof(diva_strace_path2action_t))); } - diff --git a/drivers/isdn/hardware/eicon/maintidi.h b/drivers/isdn/hardware/eicon/maintidi.h index 4f06294966b8..2b46147c5532 100644 --- a/drivers/isdn/hardware/eicon/maintidi.h +++ b/drivers/isdn/hardware/eicon/maintidi.h @@ -1,52 +1,52 @@ /* * - Copyright (c) Eicon Networks, 2000. + Copyright (c) Eicon Networks, 2000. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 1.9 + Eicon File Revision : 1.9 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_EICON_TRACE_IDI_IFC_H__ #define __DIVA_EICON_TRACE_IDI_IFC_H__ -void* SuperTraceOpenAdapter (int AdapterNumber); -int SuperTraceCloseAdapter (void* AdapterHandle); -int SuperTraceWrite (void* AdapterHandle, - const void* data, int length); -int SuperTraceReadRequest (void* AdapterHandle,const char* name,byte* data); -int SuperTraceGetNumberOfChannels (void* AdapterHandle); -int SuperTraceASSIGN (void* AdapterHandle, byte* data); -int SuperTraceREMOVE (void* AdapterHandle); -int SuperTraceTraceOnRequest(void* hAdapter, const char* name, byte* data); -int SuperTraceWriteVar (void* AdapterHandle, - byte* data, - const char* name, - void* var, - byte type, - byte var_length); -int SuperTraceExecuteRequest (void* AdapterHandle, - const char* name, - byte* data); +void *SuperTraceOpenAdapter(int AdapterNumber); +int SuperTraceCloseAdapter(void *AdapterHandle); +int SuperTraceWrite(void *AdapterHandle, + const void *data, int length); +int SuperTraceReadRequest(void *AdapterHandle, const char *name, byte *data); +int SuperTraceGetNumberOfChannels(void *AdapterHandle); +int SuperTraceASSIGN(void *AdapterHandle, byte *data); +int SuperTraceREMOVE(void *AdapterHandle); +int SuperTraceTraceOnRequest(void *hAdapter, const char *name, byte *data); +int SuperTraceWriteVar(void *AdapterHandle, + byte *data, + const char *name, + void *var, + byte type, + byte var_length); +int SuperTraceExecuteRequest(void *AdapterHandle, + const char *name, + byte *data); typedef struct _diva_strace_path2action { - char path[64]; /* Full path to variable */ - void* variable; /* Variable that will receive value */ + char path[64]; /* Full path to variable */ + void *variable; /* Variable that will receive value */ } diva_strace_path2action_t; #define DIVA_MAX_MANAGEMENT_TRANSFER_SIZE 4096 @@ -54,27 +54,27 @@ typedef struct _diva_strace_path2action { typedef struct _diva_strace_context { diva_strace_library_interface_t instance; - int Adapter; - void* hAdapter; + int Adapter; + void *hAdapter; int Channels; - int req_busy; + int req_busy; - ENTITY e; - IDI_CALL request; - BUFFERS XData; - BUFFERS RData; + ENTITY e; + IDI_CALL request; + BUFFERS XData; + BUFFERS RData; byte buffer[DIVA_MAX_MANAGEMENT_TRANSFER_SIZE + 1]; - int removal_state; - int general_b_ch_event; - int general_fax_event; - int general_mdm_event; + int removal_state; + int general_b_ch_event; + int general_fax_event; + int general_mdm_event; - byte rc_ok; + byte rc_ok; /* - Initialization request state machine - */ + Initialization request state machine + */ int ChannelsTraceActive; int ModemTraceActive; int FaxTraceActive; @@ -93,8 +93,8 @@ typedef struct _diva_strace_context { int l2_trace; /* - Trace\Event Enable - */ + Trace\Event Enable + */ word trace_event_mask; word current_trace_event_mask; @@ -112,7 +112,7 @@ typedef struct _diva_strace_context { int parse_entries; int cur_parse_entry; - diva_strace_path2action_t* parse_table; + diva_strace_path2action_t *parse_table; diva_trace_library_user_interface_t user_proc_table; @@ -169,4 +169,3 @@ typedef struct _diva_man_var_header { } diva_man_var_header_t; #endif - diff --git a/drivers/isdn/hardware/eicon/man_defs.h b/drivers/isdn/hardware/eicon/man_defs.h index cb4ef4cae6c1..249c471700e7 100644 --- a/drivers/isdn/hardware/eicon/man_defs.h +++ b/drivers/isdn/hardware/eicon/man_defs.h @@ -1,25 +1,25 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 1.9 + Eicon File Revision : 1.9 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* Definitions for use with the Management Information Element */ @@ -104,9 +104,9 @@ typedef struct mi_xlog_hdr_s MI_XLOG_HDR; struct mi_xlog_hdr_s { - unsigned long time; /* Timestamp in msec units */ - unsigned short size; /* Size of data that follows */ - unsigned short code; /* code of trace event */ + unsigned long time; /* Timestamp in msec units */ + unsigned short size; /* Size of data that follows */ + unsigned short code; /* code of trace event */ }; /* unspecified data follows this header */ /*------------------------------------------------------------------*/ diff --git a/drivers/isdn/hardware/eicon/mdm_msg.h b/drivers/isdn/hardware/eicon/mdm_msg.h index 7a737e10bce0..0e6b2e009a74 100644 --- a/drivers/isdn/hardware/eicon/mdm_msg.h +++ b/drivers/isdn/hardware/eicon/mdm_msg.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __EICON_MDM_MSG_H__ @@ -30,18 +30,18 @@ #define DSP_UDATA_INDICATION_CTS_OFF 0x03 #define DSP_UDATA_INDICATION_CTS_ON 0x04 /* ===================================================================== -DCD_OFF Message: - time of DCD off (sampled from counter at 8kHz) -DCD_ON Message: - time of DCD on (sampled from counter at 8kHz) - connected norm - connected options - connected speed (bit/s, max of tx and rx speed) - roundtrip delay (ms) - connected speed tx (bit/s) - connected speed rx (bit/s) - Size of this message == 19 bytes, but we will receive only 11 - ===================================================================== */ + DCD_OFF Message: + time of DCD off (sampled from counter at 8kHz) + DCD_ON Message: + time of DCD on (sampled from counter at 8kHz) + connected norm + connected options + connected speed (bit/s, max of tx and rx speed) + roundtrip delay (ms) + connected speed tx (bit/s) + connected speed rx (bit/s) + Size of this message == 19 bytes, but we will receive only 11 + ===================================================================== */ #define DSP_CONNECTED_NORM_UNSPECIFIED 0 #define DSP_CONNECTED_NORM_V21 1 #define DSP_CONNECTED_NORM_V23 2 @@ -129,14 +129,14 @@ DCD_ON Message: #define DSP_CONNECTED_OPTION_MASK_COMPRESSION 0x0320 #define DSP_UDATA_INDICATION_DISCONNECT 5 /* -returns: + returns: cause */ /* ========================================================== - DLC: B2 modem configuration + DLC: B2 modem configuration ========================================================== */ /* -Fields in assign DLC information element for modem protocol V.42/MNP: + Fields in assign DLC information element for modem protocol V.42/MNP: length of information element information field length address A (not used, default 3) @@ -172,10 +172,10 @@ Fields in assign DLC information element for modem protocol V.42/MNP: #define DLC_MODEMPROT_APPL_EARLY_CONNECT 0x01 #define DLC_MODEMPROT_APPL_PASS_INDICATIONS 0x02 /* ========================================================== - CAI parameters used for the modem L1 configuration + CAI parameters used for the modem L1 configuration ========================================================== */ /* -Fields in assign CAI information element: + Fields in assign CAI information element: length of information element info field and B-channel hardware rate adaptation bit rate @@ -311,21 +311,21 @@ Fields in assign CAI information element: #define DSP_CAI_MODEM_SPEAKER_VOLUME_MAX 0x0c #define DSP_CAI_MODEM_SPEAKER_VOLUME_MASK 0x0c /* ========================================================== - DCD/CTS State + DCD/CTS State ========================================================== */ #define MDM_WANT_CONNECT_B3_ACTIVE_I 0x01 #define MDM_NCPI_VALID 0x02 #define MDM_NCPI_CTS_ON_RECEIVED 0x04 #define MDM_NCPI_DCD_ON_RECEIVED 0x08 /* ========================================================== - CAPI NCPI Constants + CAPI NCPI Constants ========================================================== */ #define MDM_NCPI_ECM_V42 0x0001 #define MDM_NCPI_ECM_MNP 0x0002 #define MDM_NCPI_TRANSPARENT 0x0004 #define MDM_NCPI_COMPRESSED 0x0010 /* ========================================================== - CAPI B2 Config Constants + CAPI B2 Config Constants ========================================================== */ #define MDM_B2_DISABLE_V42bis 0x0001 #define MDM_B2_DISABLE_MNP 0x0002 @@ -333,7 +333,7 @@ Fields in assign CAI information element: #define MDM_B2_DISABLE_V42 0x0008 #define MDM_B2_DISABLE_COMP 0x0010 /* ========================================================== - CAPI B1 Config Constants + CAPI B1 Config Constants ========================================================== */ #define MDM_CAPI_DISABLE_RETRAIN 0x0001 #define MDM_CAPI_DISABLE_RING_TONE 0x0002 diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c index a3395986df3d..a82e542ffc21 100644 --- a/drivers/isdn/hardware/eicon/message.c +++ b/drivers/isdn/hardware/eicon/message.c @@ -1,25 +1,25 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ @@ -64,178 +64,178 @@ static dword diva_xdi_extended_features = 0; /* CAPI can request to process all return codes self only if: protocol code supports this && xdi supports this - */ -#define DIVA_CAPI_SUPPORTS_NO_CANCEL(__a__) (((__a__)->manufacturer_features&MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL)&& ((__a__)->manufacturer_features & MANUFACTURER_FEATURE_OK_FC_LABEL) && (diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_NO_CANCEL)) +*/ +#define DIVA_CAPI_SUPPORTS_NO_CANCEL(__a__) (((__a__)->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL) && ((__a__)->manufacturer_features & MANUFACTURER_FEATURE_OK_FC_LABEL) && (diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_NO_CANCEL)) /*------------------------------------------------------------------*/ /* local function prototypes */ /*------------------------------------------------------------------*/ -static void group_optimization(DIVA_CAPI_ADAPTER * a, PLCI * plci); -static void set_group_ind_mask (PLCI *plci); -static void clear_group_ind_mask_bit (PLCI *plci, word b); -static byte test_group_ind_mask_bit (PLCI *plci, word b); -void AutomaticLaw(DIVA_CAPI_ADAPTER *); +static void group_optimization(DIVA_CAPI_ADAPTER *a, PLCI *plci); +static void set_group_ind_mask(PLCI *plci); +static void clear_group_ind_mask_bit(PLCI *plci, word b); +static byte test_group_ind_mask_bit(PLCI *plci, word b); +void AutomaticLaw(DIVA_CAPI_ADAPTER *); word CapiRelease(word); word CapiRegister(word); -word api_put(APPL *, CAPI_MSG *); -static word api_parse(byte *, word, byte *, API_PARSE *); -static void api_save_msg(API_PARSE *in, byte *format, API_SAVE *out); -static void api_load_msg(API_SAVE *in, API_PARSE *out); +word api_put(APPL *, CAPI_MSG *); +static word api_parse(byte *, word, byte *, API_PARSE *); +static void api_save_msg(API_PARSE *in, byte *format, API_SAVE *out); +static void api_load_msg(API_SAVE *in, API_PARSE *out); word api_remove_start(void); void api_remove_complete(void); -static void plci_remove(PLCI *); -static void diva_get_extended_adapter_features (DIVA_CAPI_ADAPTER * a); -static void diva_ask_for_xdi_sdram_bar (DIVA_CAPI_ADAPTER *, IDI_SYNC_REQ *); - -void callback(ENTITY *); - -static void control_rc(PLCI *, byte, byte, byte, byte, byte); -static void data_rc(PLCI *, byte); -static void data_ack(PLCI *, byte); -static void sig_ind(PLCI *); -static void SendInfo(PLCI *, dword, byte * *, byte); -static void SendSetupInfo(APPL *, PLCI *, dword, byte * *, byte); -static void SendSSExtInd(APPL *, PLCI * plci, dword Id, byte * * parms); - -static void VSwitchReqInd(PLCI *plci, dword Id, byte **parms); - -static void nl_ind(PLCI *); - -static byte connect_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte connect_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte connect_a_res(dword,word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte disconnect_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte disconnect_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte listen_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte info_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte info_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte alert_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte facility_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte facility_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte connect_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte connect_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte connect_b3_a_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte disconnect_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte disconnect_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte data_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte data_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte reset_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte reset_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte connect_b3_t90_a_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte select_b_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte manufacturer_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); -static byte manufacturer_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); - -static word get_plci(DIVA_CAPI_ADAPTER *); -static void add_p(PLCI *, byte, byte *); -static void add_s(PLCI * plci, byte code, API_PARSE * p); -static void add_ss(PLCI * plci, byte code, API_PARSE * p); -static void add_ie(PLCI * plci, byte code, byte * p, word p_length); -static void add_d(PLCI *, word, byte *); -static void add_ai(PLCI *, API_PARSE *); -static word add_b1(PLCI *, API_PARSE *, word, word); -static word add_b23(PLCI *, API_PARSE *); -static word add_modem_b23 (PLCI * plci, API_PARSE* bp_parms); -static void sig_req(PLCI *, byte, byte); -static void nl_req_ncci(PLCI *, byte, byte); -static void send_req(PLCI *); -static void send_data(PLCI *); -static word plci_remove_check(PLCI *); -static void listen_check(DIVA_CAPI_ADAPTER *); -static byte AddInfo(byte **, byte **, byte *, byte *); +static void plci_remove(PLCI *); +static void diva_get_extended_adapter_features(DIVA_CAPI_ADAPTER *a); +static void diva_ask_for_xdi_sdram_bar(DIVA_CAPI_ADAPTER *, IDI_SYNC_REQ *); + +void callback(ENTITY *); + +static void control_rc(PLCI *, byte, byte, byte, byte, byte); +static void data_rc(PLCI *, byte); +static void data_ack(PLCI *, byte); +static void sig_ind(PLCI *); +static void SendInfo(PLCI *, dword, byte **, byte); +static void SendSetupInfo(APPL *, PLCI *, dword, byte **, byte); +static void SendSSExtInd(APPL *, PLCI *plci, dword Id, byte **parms); + +static void VSwitchReqInd(PLCI *plci, dword Id, byte **parms); + +static void nl_ind(PLCI *); + +static byte connect_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte connect_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte connect_a_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte disconnect_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte disconnect_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte listen_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte info_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte info_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte alert_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte facility_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte facility_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte connect_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte connect_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte connect_b3_a_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte disconnect_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte disconnect_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte data_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte data_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte reset_b3_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte reset_b3_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte connect_b3_t90_a_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte select_b_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte manufacturer_req(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); +static byte manufacturer_res(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); + +static word get_plci(DIVA_CAPI_ADAPTER *); +static void add_p(PLCI *, byte, byte *); +static void add_s(PLCI *plci, byte code, API_PARSE *p); +static void add_ss(PLCI *plci, byte code, API_PARSE *p); +static void add_ie(PLCI *plci, byte code, byte *p, word p_length); +static void add_d(PLCI *, word, byte *); +static void add_ai(PLCI *, API_PARSE *); +static word add_b1(PLCI *, API_PARSE *, word, word); +static word add_b23(PLCI *, API_PARSE *); +static word add_modem_b23(PLCI *plci, API_PARSE *bp_parms); +static void sig_req(PLCI *, byte, byte); +static void nl_req_ncci(PLCI *, byte, byte); +static void send_req(PLCI *); +static void send_data(PLCI *); +static word plci_remove_check(PLCI *); +static void listen_check(DIVA_CAPI_ADAPTER *); +static byte AddInfo(byte **, byte **, byte *, byte *); static byte getChannel(API_PARSE *); -static void IndParse(PLCI *, word *, byte **, byte); -static byte ie_compare(byte *, byte *); -static word find_cip(DIVA_CAPI_ADAPTER *, byte *, byte *); -static word CPN_filter_ok(byte *cpn,DIVA_CAPI_ADAPTER *,word); +static void IndParse(PLCI *, word *, byte **, byte); +static byte ie_compare(byte *, byte *); +static word find_cip(DIVA_CAPI_ADAPTER *, byte *, byte *); +static word CPN_filter_ok(byte *cpn, DIVA_CAPI_ADAPTER *, word); /* XON protocol helpers - */ -static void channel_flow_control_remove (PLCI * plci); -static void channel_x_off (PLCI * plci, byte ch, byte flag); -static void channel_x_on (PLCI * plci, byte ch); -static void channel_request_xon (PLCI * plci, byte ch); -static void channel_xmit_xon (PLCI * plci); -static int channel_can_xon (PLCI * plci, byte ch); -static void channel_xmit_extended_xon (PLCI * plci); - -static byte SendMultiIE(PLCI * plci, dword Id, byte * * parms, byte ie_type, dword info_mask, byte setupParse); -static word AdvCodecSupport(DIVA_CAPI_ADAPTER *, PLCI *, APPL *, byte); -static void CodecIdCheck(DIVA_CAPI_ADAPTER *, PLCI *); -static void SetVoiceChannel(PLCI *, byte *, DIVA_CAPI_ADAPTER * ); -static void VoiceChannelOff(PLCI *plci); -static void adv_voice_write_coefs (PLCI *plci, word write_command); -static void adv_voice_clear_config (PLCI *plci); - -static word get_b1_facilities (PLCI * plci, byte b1_resource); -static byte add_b1_facilities (PLCI * plci, byte b1_resource, word b1_facilities); -static void adjust_b1_facilities (PLCI *plci, byte new_b1_resource, word new_b1_facilities); -static word adjust_b_process (dword Id, PLCI *plci, byte Rc); -static void adjust_b1_resource (dword Id, PLCI *plci, API_SAVE *bp_msg, word b1_facilities, word internal_command); -static void adjust_b_restore (dword Id, PLCI *plci, byte Rc); -static void reset_b3_command (dword Id, PLCI *plci, byte Rc); -static void select_b_command (dword Id, PLCI *plci, byte Rc); -static void fax_connect_ack_command (dword Id, PLCI *plci, byte Rc); -static void fax_edata_ack_command (dword Id, PLCI *plci, byte Rc); -static void fax_connect_info_command (dword Id, PLCI *plci, byte Rc); -static void fax_adjust_b23_command (dword Id, PLCI *plci, byte Rc); -static void fax_disconnect_command (dword Id, PLCI *plci, byte Rc); -static void hold_save_command (dword Id, PLCI *plci, byte Rc); -static void retrieve_restore_command (dword Id, PLCI *plci, byte Rc); -static void init_b1_config (PLCI *plci); -static void clear_b1_config (PLCI *plci); - -static void dtmf_command (dword Id, PLCI *plci, byte Rc); -static byte dtmf_request (dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg); -static void dtmf_confirmation (dword Id, PLCI *plci); -static void dtmf_indication (dword Id, PLCI *plci, byte *msg, word length); -static void dtmf_parameter_write (PLCI *plci); - - -static void mixer_set_bchannel_id_esc (PLCI *plci, byte bchannel_id); -static void mixer_set_bchannel_id (PLCI *plci, byte *chi); -static void mixer_clear_config (PLCI *plci); -static void mixer_notify_update (PLCI *plci, byte others); -static void mixer_command (dword Id, PLCI *plci, byte Rc); -static byte mixer_request (dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg); -static void mixer_indication_coefs_set (dword Id, PLCI *plci); -static void mixer_indication_xconnect_from (dword Id, PLCI *plci, byte *msg, word length); -static void mixer_indication_xconnect_to (dword Id, PLCI *plci, byte *msg, word length); -static void mixer_remove (PLCI *plci); - - -static void ec_command (dword Id, PLCI *plci, byte Rc); -static byte ec_request (dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg); -static void ec_indication (dword Id, PLCI *plci, byte *msg, word length); - - -static void rtp_connect_b3_req_command (dword Id, PLCI *plci, byte Rc); -static void rtp_connect_b3_res_command (dword Id, PLCI *plci, byte Rc); - - -static int diva_get_dma_descriptor (PLCI *plci, dword *dma_magic); -static void diva_free_dma_descriptor (PLCI *plci, int nr); +*/ +static void channel_flow_control_remove(PLCI *plci); +static void channel_x_off(PLCI *plci, byte ch, byte flag); +static void channel_x_on(PLCI *plci, byte ch); +static void channel_request_xon(PLCI *plci, byte ch); +static void channel_xmit_xon(PLCI *plci); +static int channel_can_xon(PLCI *plci, byte ch); +static void channel_xmit_extended_xon(PLCI *plci); + +static byte SendMultiIE(PLCI *plci, dword Id, byte **parms, byte ie_type, dword info_mask, byte setupParse); +static word AdvCodecSupport(DIVA_CAPI_ADAPTER *, PLCI *, APPL *, byte); +static void CodecIdCheck(DIVA_CAPI_ADAPTER *, PLCI *); +static void SetVoiceChannel(PLCI *, byte *, DIVA_CAPI_ADAPTER *); +static void VoiceChannelOff(PLCI *plci); +static void adv_voice_write_coefs(PLCI *plci, word write_command); +static void adv_voice_clear_config(PLCI *plci); + +static word get_b1_facilities(PLCI *plci, byte b1_resource); +static byte add_b1_facilities(PLCI *plci, byte b1_resource, word b1_facilities); +static void adjust_b1_facilities(PLCI *plci, byte new_b1_resource, word new_b1_facilities); +static word adjust_b_process(dword Id, PLCI *plci, byte Rc); +static void adjust_b1_resource(dword Id, PLCI *plci, API_SAVE *bp_msg, word b1_facilities, word internal_command); +static void adjust_b_restore(dword Id, PLCI *plci, byte Rc); +static void reset_b3_command(dword Id, PLCI *plci, byte Rc); +static void select_b_command(dword Id, PLCI *plci, byte Rc); +static void fax_connect_ack_command(dword Id, PLCI *plci, byte Rc); +static void fax_edata_ack_command(dword Id, PLCI *plci, byte Rc); +static void fax_connect_info_command(dword Id, PLCI *plci, byte Rc); +static void fax_adjust_b23_command(dword Id, PLCI *plci, byte Rc); +static void fax_disconnect_command(dword Id, PLCI *plci, byte Rc); +static void hold_save_command(dword Id, PLCI *plci, byte Rc); +static void retrieve_restore_command(dword Id, PLCI *plci, byte Rc); +static void init_b1_config(PLCI *plci); +static void clear_b1_config(PLCI *plci); + +static void dtmf_command(dword Id, PLCI *plci, byte Rc); +static byte dtmf_request(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg); +static void dtmf_confirmation(dword Id, PLCI *plci); +static void dtmf_indication(dword Id, PLCI *plci, byte *msg, word length); +static void dtmf_parameter_write(PLCI *plci); + + +static void mixer_set_bchannel_id_esc(PLCI *plci, byte bchannel_id); +static void mixer_set_bchannel_id(PLCI *plci, byte *chi); +static void mixer_clear_config(PLCI *plci); +static void mixer_notify_update(PLCI *plci, byte others); +static void mixer_command(dword Id, PLCI *plci, byte Rc); +static byte mixer_request(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg); +static void mixer_indication_coefs_set(dword Id, PLCI *plci); +static void mixer_indication_xconnect_from(dword Id, PLCI *plci, byte *msg, word length); +static void mixer_indication_xconnect_to(dword Id, PLCI *plci, byte *msg, word length); +static void mixer_remove(PLCI *plci); + + +static void ec_command(dword Id, PLCI *plci, byte Rc); +static byte ec_request(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg); +static void ec_indication(dword Id, PLCI *plci, byte *msg, word length); + + +static void rtp_connect_b3_req_command(dword Id, PLCI *plci, byte Rc); +static void rtp_connect_b3_res_command(dword Id, PLCI *plci, byte Rc); + + +static int diva_get_dma_descriptor(PLCI *plci, dword *dma_magic); +static void diva_free_dma_descriptor(PLCI *plci, int nr); /*------------------------------------------------------------------*/ /* external function prototypes */ /*------------------------------------------------------------------*/ -extern byte MapController (byte); -extern byte UnMapController (byte); -#define MapId(Id) (((Id) & 0xffffff00L) | MapController ((byte)(Id))) -#define UnMapId(Id) (((Id) & 0xffffff00L) | UnMapController ((byte)(Id))) +extern byte MapController(byte); +extern byte UnMapController(byte); +#define MapId(Id)(((Id) & 0xffffff00L) | MapController((byte)(Id))) +#define UnMapId(Id)(((Id) & 0xffffff00L) | UnMapController((byte)(Id))) -void sendf(APPL *, word, dword, word, byte *, ...); -void * TransmitBufferSet(APPL * appl, dword ref); -void * TransmitBufferGet(APPL * appl, void * p); -void TransmitBufferFree(APPL * appl, void * p); -void * ReceiveBufferGet(APPL * appl, int Num); +void sendf(APPL *, word, dword, word, byte *, ...); +void *TransmitBufferSet(APPL *appl, dword ref); +void *TransmitBufferGet(APPL *appl, void *p); +void TransmitBufferFree(APPL *appl, void *p); +void *ReceiveBufferGet(APPL *appl, int Num); -int fax_head_line_time (char *buffer); +int fax_head_line_time(char *buffer); /*------------------------------------------------------------------*/ @@ -243,8 +243,8 @@ int fax_head_line_time (char *buffer); /*------------------------------------------------------------------*/ extern byte max_adapter; extern byte max_appl; -extern DIVA_CAPI_ADAPTER * adapter; -extern APPL * application; +extern DIVA_CAPI_ADAPTER *adapter; +extern APPL *application; @@ -257,102 +257,102 @@ static PLCI dummy_plci; static struct _ftable { - word command; - byte * format; - byte (* function)(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); + word command; + byte *format; + byte (*function)(dword, word, DIVA_CAPI_ADAPTER *, PLCI *, APPL *, API_PARSE *); } ftable[] = { - {_DATA_B3_R, "dwww", data_b3_req}, - {_DATA_B3_I|RESPONSE, "w", data_b3_res}, - {_INFO_R, "ss", info_req}, - {_INFO_I|RESPONSE, "", info_res}, - {_CONNECT_R, "wsssssssss", connect_req}, - {_CONNECT_I|RESPONSE, "wsssss", connect_res}, - {_CONNECT_ACTIVE_I|RESPONSE, "", connect_a_res}, - {_DISCONNECT_R, "s", disconnect_req}, - {_DISCONNECT_I|RESPONSE, "", disconnect_res}, - {_LISTEN_R, "dddss", listen_req}, - {_ALERT_R, "s", alert_req}, - {_FACILITY_R, "ws", facility_req}, - {_FACILITY_I|RESPONSE, "ws", facility_res}, - {_CONNECT_B3_R, "s", connect_b3_req}, - {_CONNECT_B3_I|RESPONSE, "ws", connect_b3_res}, - {_CONNECT_B3_ACTIVE_I|RESPONSE, "", connect_b3_a_res}, - {_DISCONNECT_B3_R, "s", disconnect_b3_req}, - {_DISCONNECT_B3_I|RESPONSE, "", disconnect_b3_res}, - {_RESET_B3_R, "s", reset_b3_req}, - {_RESET_B3_I|RESPONSE, "", reset_b3_res}, - {_CONNECT_B3_T90_ACTIVE_I|RESPONSE, "ws", connect_b3_t90_a_res}, - {_CONNECT_B3_T90_ACTIVE_I|RESPONSE, "", connect_b3_t90_a_res}, - {_SELECT_B_REQ, "s", select_b_req}, - {_MANUFACTURER_R, "dws", manufacturer_req}, - {_MANUFACTURER_I|RESPONSE, "dws", manufacturer_res}, - {_MANUFACTURER_I|RESPONSE, "", manufacturer_res} + {_DATA_B3_R, "dwww", data_b3_req}, + {_DATA_B3_I | RESPONSE, "w", data_b3_res}, + {_INFO_R, "ss", info_req}, + {_INFO_I | RESPONSE, "", info_res}, + {_CONNECT_R, "wsssssssss", connect_req}, + {_CONNECT_I | RESPONSE, "wsssss", connect_res}, + {_CONNECT_ACTIVE_I | RESPONSE, "", connect_a_res}, + {_DISCONNECT_R, "s", disconnect_req}, + {_DISCONNECT_I | RESPONSE, "", disconnect_res}, + {_LISTEN_R, "dddss", listen_req}, + {_ALERT_R, "s", alert_req}, + {_FACILITY_R, "ws", facility_req}, + {_FACILITY_I | RESPONSE, "ws", facility_res}, + {_CONNECT_B3_R, "s", connect_b3_req}, + {_CONNECT_B3_I | RESPONSE, "ws", connect_b3_res}, + {_CONNECT_B3_ACTIVE_I | RESPONSE, "", connect_b3_a_res}, + {_DISCONNECT_B3_R, "s", disconnect_b3_req}, + {_DISCONNECT_B3_I | RESPONSE, "", disconnect_b3_res}, + {_RESET_B3_R, "s", reset_b3_req}, + {_RESET_B3_I | RESPONSE, "", reset_b3_res}, + {_CONNECT_B3_T90_ACTIVE_I | RESPONSE, "ws", connect_b3_t90_a_res}, + {_CONNECT_B3_T90_ACTIVE_I | RESPONSE, "", connect_b3_t90_a_res}, + {_SELECT_B_REQ, "s", select_b_req}, + {_MANUFACTURER_R, "dws", manufacturer_req}, + {_MANUFACTURER_I | RESPONSE, "dws", manufacturer_res}, + {_MANUFACTURER_I | RESPONSE, "", manufacturer_res} }; -static byte * cip_bc[29][2] = { - { "", "" }, /* 0 */ - { "\x03\x80\x90\xa3", "\x03\x80\x90\xa2" }, /* 1 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 2 */ - { "\x02\x89\x90", "\x02\x89\x90" }, /* 3 */ - { "\x03\x90\x90\xa3", "\x03\x90\x90\xa2" }, /* 4 */ - { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 5 */ - { "\x02\x98\x90", "\x02\x98\x90" }, /* 6 */ - { "\x04\x88\xc0\xc6\xe6", "\x04\x88\xc0\xc6\xe6" }, /* 7 */ - { "\x04\x88\x90\x21\x8f", "\x04\x88\x90\x21\x8f" }, /* 8 */ - { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 9 */ - { "", "" }, /* 10 */ - { "", "" }, /* 11 */ - { "", "" }, /* 12 */ - { "", "" }, /* 13 */ - { "", "" }, /* 14 */ - { "", "" }, /* 15 */ - - { "\x03\x80\x90\xa3", "\x03\x80\x90\xa2" }, /* 16 */ - { "\x03\x90\x90\xa3", "\x03\x90\x90\xa2" }, /* 17 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 18 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 19 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 20 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 21 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 22 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 23 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 24 */ - { "\x02\x88\x90", "\x02\x88\x90" }, /* 25 */ - { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 26 */ - { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 27 */ - { "\x02\x88\x90", "\x02\x88\x90" } /* 28 */ +static byte *cip_bc[29][2] = { + { "", "" }, /* 0 */ + { "\x03\x80\x90\xa3", "\x03\x80\x90\xa2" }, /* 1 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 2 */ + { "\x02\x89\x90", "\x02\x89\x90" }, /* 3 */ + { "\x03\x90\x90\xa3", "\x03\x90\x90\xa2" }, /* 4 */ + { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 5 */ + { "\x02\x98\x90", "\x02\x98\x90" }, /* 6 */ + { "\x04\x88\xc0\xc6\xe6", "\x04\x88\xc0\xc6\xe6" }, /* 7 */ + { "\x04\x88\x90\x21\x8f", "\x04\x88\x90\x21\x8f" }, /* 8 */ + { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 9 */ + { "", "" }, /* 10 */ + { "", "" }, /* 11 */ + { "", "" }, /* 12 */ + { "", "" }, /* 13 */ + { "", "" }, /* 14 */ + { "", "" }, /* 15 */ + + { "\x03\x80\x90\xa3", "\x03\x80\x90\xa2" }, /* 16 */ + { "\x03\x90\x90\xa3", "\x03\x90\x90\xa2" }, /* 17 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 18 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 19 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 20 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 21 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 22 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 23 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 24 */ + { "\x02\x88\x90", "\x02\x88\x90" }, /* 25 */ + { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 26 */ + { "\x03\x91\x90\xa5", "\x03\x91\x90\xa5" }, /* 27 */ + { "\x02\x88\x90", "\x02\x88\x90" } /* 28 */ }; -static byte * cip_hlc[29] = { - "", /* 0 */ - "", /* 1 */ - "", /* 2 */ - "", /* 3 */ - "", /* 4 */ - "", /* 5 */ - "", /* 6 */ - "", /* 7 */ - "", /* 8 */ - "", /* 9 */ - "", /* 10 */ - "", /* 11 */ - "", /* 12 */ - "", /* 13 */ - "", /* 14 */ - "", /* 15 */ - - "\x02\x91\x81", /* 16 */ - "\x02\x91\x84", /* 17 */ - "\x02\x91\xa1", /* 18 */ - "\x02\x91\xa4", /* 19 */ - "\x02\x91\xa8", /* 20 */ - "\x02\x91\xb1", /* 21 */ - "\x02\x91\xb2", /* 22 */ - "\x02\x91\xb5", /* 23 */ - "\x02\x91\xb8", /* 24 */ - "\x02\x91\xc1", /* 25 */ - "\x02\x91\x81", /* 26 */ - "\x03\x91\xe0\x01", /* 27 */ - "\x03\x91\xe0\x02" /* 28 */ +static byte *cip_hlc[29] = { + "", /* 0 */ + "", /* 1 */ + "", /* 2 */ + "", /* 3 */ + "", /* 4 */ + "", /* 5 */ + "", /* 6 */ + "", /* 7 */ + "", /* 8 */ + "", /* 9 */ + "", /* 10 */ + "", /* 11 */ + "", /* 12 */ + "", /* 13 */ + "", /* 14 */ + "", /* 15 */ + + "\x02\x91\x81", /* 16 */ + "\x02\x91\x84", /* 17 */ + "\x02\x91\xa1", /* 18 */ + "\x02\x91\xa4", /* 19 */ + "\x02\x91\xa8", /* 20 */ + "\x02\x91\xb1", /* 21 */ + "\x02\x91\xb2", /* 22 */ + "\x02\x91\xb5", /* 23 */ + "\x02\x91\xb8", /* 24 */ + "\x02\x91\xc1", /* 25 */ + "\x02\x91\x81", /* 26 */ + "\x03\x91\xe0\x01", /* 27 */ + "\x03\x91\xe0\x02" /* 28 */ }; /*------------------------------------------------------------------*/ @@ -367,14 +367,14 @@ static byte * cip_hlc[29] = { static byte v120_default_header[] = { - 0x83 /* Ext, BR , res, res, C2 , C1 , B , F */ + 0x83 /* Ext, BR , res, res, C2 , C1 , B , F */ }; static byte v120_break_header[] = { - 0xc3 | V120_HEADER_BREAK_BIT /* Ext, BR , res, res, C2 , C1 , B , F */ + 0xc3 | V120_HEADER_BREAK_BIT /* Ext, BR , res, res, C2 , C1 , B , F */ }; @@ -383,206 +383,206 @@ static byte v120_break_header[] = /* API_PUT function */ /*------------------------------------------------------------------*/ -word api_put(APPL * appl, CAPI_MSG * msg) -{ - word i, j, k, l, n; - word ret; - byte c; - byte controller; - DIVA_CAPI_ADAPTER * a; - PLCI * plci; - NCCI * ncci_ptr; - word ncci; - CAPI_MSG *m; - API_PARSE msg_parms[MAX_MSG_PARMS+1]; - - if (msg->header.length < sizeof (msg->header) || - msg->header.length > MAX_MSG_SIZE) { - dbug(1,dprintf("bad len")); - return _BAD_MSG; - } - - controller = (byte)((msg->header.controller &0x7f)-1); - - /* controller starts with 0 up to (max_adapter - 1) */ - if ( controller >= max_adapter ) - { - dbug(1,dprintf("invalid ctrl")); - return _BAD_MSG; - } - - a = &adapter[controller]; - plci = NULL; - if ((msg->header.plci != 0) && (msg->header.plci <= a->max_plci) && !a->adapter_disabled) - { - dbug(1,dprintf("plci=%x",msg->header.plci)); - plci = &a->plci[msg->header.plci-1]; - ncci = GET_WORD(&msg->header.ncci); - if (plci->Id - && (plci->appl - || (plci->State == INC_CON_PENDING) - || (plci->State == INC_CON_ALERT) - || (msg->header.command == (_DISCONNECT_I|RESPONSE))) - && ((ncci == 0) - || (msg->header.command == (_DISCONNECT_B3_I|RESPONSE)) - || ((ncci < MAX_NCCI+1) && (a->ncci_plci[ncci] == plci->Id)))) - { - i = plci->msg_in_read_pos; - j = plci->msg_in_write_pos; - if (j >= i) - { - if (j + msg->header.length + MSG_IN_OVERHEAD <= MSG_IN_QUEUE_SIZE) - i += MSG_IN_QUEUE_SIZE - j; - else - j = 0; - } - else - { - - n = (((CAPI_MSG *)(plci->msg_in_queue))->header.length + MSG_IN_OVERHEAD + 3) & 0xfffc; - - if (i > MSG_IN_QUEUE_SIZE - n) - i = MSG_IN_QUEUE_SIZE - n + 1; - i -= j; - } - - if (i <= ((msg->header.length + MSG_IN_OVERHEAD + 3) & 0xfffc)) - - { - dbug(0,dprintf("Q-FULL1(msg) - len=%d write=%d read=%d wrap=%d free=%d", - msg->header.length, plci->msg_in_write_pos, - plci->msg_in_read_pos, plci->msg_in_wrap_pos, i)); - - return _QUEUE_FULL; - } - c = false; - if ((((byte *) msg) < ((byte *)(plci->msg_in_queue))) - || (((byte *) msg) >= ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) - { - if (plci->msg_in_write_pos != plci->msg_in_read_pos) - c = true; - } - if (msg->header.command == _DATA_B3_R) - { - if (msg->header.length < 20) - { - dbug(1,dprintf("DATA_B3 REQ wrong length %d", msg->header.length)); - return _BAD_MSG; - } - ncci_ptr = &(a->ncci[ncci]); - n = ncci_ptr->data_pending; - l = ncci_ptr->data_ack_pending; - k = plci->msg_in_read_pos; - while (k != plci->msg_in_write_pos) - { - if (k == plci->msg_in_wrap_pos) - k = 0; - if ((((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->header.command == _DATA_B3_R) - && (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->header.ncci == ncci)) - { - n++; - if (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->info.data_b3_req.Flags & 0x0004) - l++; - } - - k += (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->header.length + - MSG_IN_OVERHEAD + 3) & 0xfffc; - - } - if ((n >= MAX_DATA_B3) || (l >= MAX_DATA_ACK)) - { - dbug(0,dprintf("Q-FULL2(data) - pending=%d/%d ack_pending=%d/%d", - ncci_ptr->data_pending, n, ncci_ptr->data_ack_pending, l)); - - return _QUEUE_FULL; - } - if (plci->req_in || plci->internal_command) - { - if ((((byte *) msg) >= ((byte *)(plci->msg_in_queue))) - && (((byte *) msg) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) - { - dbug(0,dprintf("Q-FULL3(requeue)")); - - return _QUEUE_FULL; - } - c = true; - } - } - else - { - if (plci->req_in || plci->internal_command) - c = true; - else - { - plci->command = msg->header.command; - plci->number = msg->header.number; - } - } - if (c) - { - dbug(1,dprintf("enqueue msg(0x%04x,0x%x,0x%x) - len=%d write=%d read=%d wrap=%d free=%d", - msg->header.command, plci->req_in, plci->internal_command, - msg->header.length, plci->msg_in_write_pos, - plci->msg_in_read_pos, plci->msg_in_wrap_pos, i)); - if (j == 0) - plci->msg_in_wrap_pos = plci->msg_in_write_pos; - m = (CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[j]); - for (i = 0; i < msg->header.length; i++) - ((byte *)(plci->msg_in_queue))[j++] = ((byte *) msg)[i]; - if (m->header.command == _DATA_B3_R) - { - - m->info.data_b3_req.Data = (dword)(long)(TransmitBufferSet (appl, m->info.data_b3_req.Data)); - - } - - j = (j + 3) & 0xfffc; - - *((APPL * *)(&((byte *)(plci->msg_in_queue))[j])) = appl; - plci->msg_in_write_pos = j + MSG_IN_OVERHEAD; - return 0; - } - } - else - { - plci = NULL; - } - } - dbug(1,dprintf("com=%x",msg->header.command)); - - for(j=0;jheader.command) { - /* break loop if the message is correct, otherwise continue scan */ - /* (for example: CONNECT_B3_T90_ACT_RES has two specifications) */ - if(!api_parse(msg->info.b,(word)(msg->header.length-12),ftable[i].format,msg_parms)) { - ret = 0; - break; - } - for(j=0;jcommand = 0; - return ret; - } - - - c = ftable[i].function(GET_DWORD(&msg->header.controller), - msg->header.number, - a, - plci, - appl, - msg_parms); - - channel_xmit_extended_xon (plci); - - if(c==1) send_req(plci); - if(c==2 && plci) plci->req_in = plci->req_in_start = plci->req_out = 0; - if(plci && !plci->req_in) plci->command = 0; - return 0; +word api_put(APPL *appl, CAPI_MSG *msg) +{ + word i, j, k, l, n; + word ret; + byte c; + byte controller; + DIVA_CAPI_ADAPTER *a; + PLCI *plci; + NCCI *ncci_ptr; + word ncci; + CAPI_MSG *m; + API_PARSE msg_parms[MAX_MSG_PARMS + 1]; + + if (msg->header.length < sizeof(msg->header) || + msg->header.length > MAX_MSG_SIZE) { + dbug(1, dprintf("bad len")); + return _BAD_MSG; + } + + controller = (byte)((msg->header.controller & 0x7f) - 1); + + /* controller starts with 0 up to (max_adapter - 1) */ + if (controller >= max_adapter) + { + dbug(1, dprintf("invalid ctrl")); + return _BAD_MSG; + } + + a = &adapter[controller]; + plci = NULL; + if ((msg->header.plci != 0) && (msg->header.plci <= a->max_plci) && !a->adapter_disabled) + { + dbug(1, dprintf("plci=%x", msg->header.plci)); + plci = &a->plci[msg->header.plci - 1]; + ncci = GET_WORD(&msg->header.ncci); + if (plci->Id + && (plci->appl + || (plci->State == INC_CON_PENDING) + || (plci->State == INC_CON_ALERT) + || (msg->header.command == (_DISCONNECT_I | RESPONSE))) + && ((ncci == 0) + || (msg->header.command == (_DISCONNECT_B3_I | RESPONSE)) + || ((ncci < MAX_NCCI + 1) && (a->ncci_plci[ncci] == plci->Id)))) + { + i = plci->msg_in_read_pos; + j = plci->msg_in_write_pos; + if (j >= i) + { + if (j + msg->header.length + MSG_IN_OVERHEAD <= MSG_IN_QUEUE_SIZE) + i += MSG_IN_QUEUE_SIZE - j; + else + j = 0; + } + else + { + + n = (((CAPI_MSG *)(plci->msg_in_queue))->header.length + MSG_IN_OVERHEAD + 3) & 0xfffc; + + if (i > MSG_IN_QUEUE_SIZE - n) + i = MSG_IN_QUEUE_SIZE - n + 1; + i -= j; + } + + if (i <= ((msg->header.length + MSG_IN_OVERHEAD + 3) & 0xfffc)) + + { + dbug(0, dprintf("Q-FULL1(msg) - len=%d write=%d read=%d wrap=%d free=%d", + msg->header.length, plci->msg_in_write_pos, + plci->msg_in_read_pos, plci->msg_in_wrap_pos, i)); + + return _QUEUE_FULL; + } + c = false; + if ((((byte *) msg) < ((byte *)(plci->msg_in_queue))) + || (((byte *) msg) >= ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) + { + if (plci->msg_in_write_pos != plci->msg_in_read_pos) + c = true; + } + if (msg->header.command == _DATA_B3_R) + { + if (msg->header.length < 20) + { + dbug(1, dprintf("DATA_B3 REQ wrong length %d", msg->header.length)); + return _BAD_MSG; + } + ncci_ptr = &(a->ncci[ncci]); + n = ncci_ptr->data_pending; + l = ncci_ptr->data_ack_pending; + k = plci->msg_in_read_pos; + while (k != plci->msg_in_write_pos) + { + if (k == plci->msg_in_wrap_pos) + k = 0; + if ((((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->header.command == _DATA_B3_R) + && (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->header.ncci == ncci)) + { + n++; + if (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->info.data_b3_req.Flags & 0x0004) + l++; + } + + k += (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[k]))->header.length + + MSG_IN_OVERHEAD + 3) & 0xfffc; + + } + if ((n >= MAX_DATA_B3) || (l >= MAX_DATA_ACK)) + { + dbug(0, dprintf("Q-FULL2(data) - pending=%d/%d ack_pending=%d/%d", + ncci_ptr->data_pending, n, ncci_ptr->data_ack_pending, l)); + + return _QUEUE_FULL; + } + if (plci->req_in || plci->internal_command) + { + if ((((byte *) msg) >= ((byte *)(plci->msg_in_queue))) + && (((byte *) msg) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) + { + dbug(0, dprintf("Q-FULL3(requeue)")); + + return _QUEUE_FULL; + } + c = true; + } + } + else + { + if (plci->req_in || plci->internal_command) + c = true; + else + { + plci->command = msg->header.command; + plci->number = msg->header.number; + } + } + if (c) + { + dbug(1, dprintf("enqueue msg(0x%04x,0x%x,0x%x) - len=%d write=%d read=%d wrap=%d free=%d", + msg->header.command, plci->req_in, plci->internal_command, + msg->header.length, plci->msg_in_write_pos, + plci->msg_in_read_pos, plci->msg_in_wrap_pos, i)); + if (j == 0) + plci->msg_in_wrap_pos = plci->msg_in_write_pos; + m = (CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[j]); + for (i = 0; i < msg->header.length; i++) + ((byte *)(plci->msg_in_queue))[j++] = ((byte *) msg)[i]; + if (m->header.command == _DATA_B3_R) + { + + m->info.data_b3_req.Data = (dword)(long)(TransmitBufferSet(appl, m->info.data_b3_req.Data)); + + } + + j = (j + 3) & 0xfffc; + + *((APPL **)(&((byte *)(plci->msg_in_queue))[j])) = appl; + plci->msg_in_write_pos = j + MSG_IN_OVERHEAD; + return 0; + } + } + else + { + plci = NULL; + } + } + dbug(1, dprintf("com=%x", msg->header.command)); + + for (j = 0; j < MAX_MSG_PARMS + 1; j++) msg_parms[j].length = 0; + for (i = 0, ret = _BAD_MSG; i < ARRAY_SIZE(ftable); i++) { + + if (ftable[i].command == msg->header.command) { + /* break loop if the message is correct, otherwise continue scan */ + /* (for example: CONNECT_B3_T90_ACT_RES has two specifications) */ + if (!api_parse(msg->info.b, (word)(msg->header.length - 12), ftable[i].format, msg_parms)) { + ret = 0; + break; + } + for (j = 0; j < MAX_MSG_PARMS + 1; j++) msg_parms[j].length = 0; + } + } + if (ret) { + dbug(1, dprintf("BAD_MSG")); + if (plci) plci->command = 0; + return ret; + } + + + c = ftable[i].function(GET_DWORD(&msg->header.controller), + msg->header.number, + a, + plci, + appl, + msg_parms); + + channel_xmit_extended_xon(plci); + + if (c == 1) send_req(plci); + if (c == 2 && plci) plci->req_in = plci->req_in_start = plci->req_out = 0; + if (plci && !plci->req_in) plci->command = 0; + return 0; } @@ -592,85 +592,85 @@ word api_put(APPL * appl, CAPI_MSG * msg) static word api_parse(byte *msg, word length, byte *format, API_PARSE *parms) { - word i; - word p; - - for(i=0,p=0; format[i]; i++) { - if(parms) - { - parms[i].info = &msg[p]; - } - switch(format[i]) { - case 'b': - p +=1; - break; - case 'w': - p +=2; - break; - case 'd': - p +=4; - break; - case 's': - if(msg[p]==0xff) { - parms[i].info +=2; - parms[i].length = msg[p+1] + (msg[p+2]<<8); - p +=(parms[i].length +3); - } - else { - parms[i].length = msg[p]; - p +=(parms[i].length +1); - } - break; - } - - if(p>length) return true; - } - if(parms) parms[i].info = NULL; - return false; + word i; + word p; + + for (i = 0, p = 0; format[i]; i++) { + if (parms) + { + parms[i].info = &msg[p]; + } + switch (format[i]) { + case 'b': + p += 1; + break; + case 'w': + p += 2; + break; + case 'd': + p += 4; + break; + case 's': + if (msg[p] == 0xff) { + parms[i].info += 2; + parms[i].length = msg[p + 1] + (msg[p + 2] << 8); + p += (parms[i].length + 3); + } + else { + parms[i].length = msg[p]; + p += (parms[i].length + 1); + } + break; + } + + if (p > length) return true; + } + if (parms) parms[i].info = NULL; + return false; } static void api_save_msg(API_PARSE *in, byte *format, API_SAVE *out) { - word i, j, n = 0; - byte *p; - - p = out->info; - for (i = 0; format[i] != '\0'; i++) - { - out->parms[i].info = p; - out->parms[i].length = in[i].length; - switch (format[i]) - { - case 'b': - n = 1; - break; - case 'w': - n = 2; - break; - case 'd': - n = 4; - break; - case 's': - n = in[i].length + 1; - break; - } - for (j = 0; j < n; j++) - *(p++) = in[i].info[j]; - } - out->parms[i].info = NULL; - out->parms[i].length = 0; + word i, j, n = 0; + byte *p; + + p = out->info; + for (i = 0; format[i] != '\0'; i++) + { + out->parms[i].info = p; + out->parms[i].length = in[i].length; + switch (format[i]) + { + case 'b': + n = 1; + break; + case 'w': + n = 2; + break; + case 'd': + n = 4; + break; + case 's': + n = in[i].length + 1; + break; + } + for (j = 0; j < n; j++) + *(p++) = in[i].info[j]; + } + out->parms[i].info = NULL; + out->parms[i].length = 0; } static void api_load_msg(API_SAVE *in, API_PARSE *out) { - word i; + word i; - i = 0; - do - { - out[i].info = in->parms[i].info; - out[i].length = in->parms[i].length; - } while (in->parms[i++].info); + i = 0; + do + { + out[i].info = in->parms[i].info; + out[i].length = in->parms[i].length; + } while (in->parms[i++].info); } @@ -680,31 +680,31 @@ static void api_load_msg(API_SAVE *in, API_PARSE *out) word api_remove_start(void) { - word i; - word j; - - if(!remove_started) { - remove_started = true; - for(i=0;iinternal_command = 0; - for (i = 0; i < MAX_INTERNAL_COMMAND_LEVELS; i++) - plci->internal_command_queue[i] = NULL; + plci->internal_command = 0; + for (i = 0; i < MAX_INTERNAL_COMMAND_LEVELS; i++) + plci->internal_command_queue[i] = NULL; } -static void start_internal_command (dword Id, PLCI *plci, t_std_internal_command command_function) +static void start_internal_command(dword Id, PLCI *plci, t_std_internal_command command_function) { - word i; + word i; - dbug (1, dprintf ("[%06lx] %s,%d: start_internal_command", - UnMapId (Id), (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: start_internal_command", + UnMapId(Id), (char *)(FILE_), __LINE__)); - if (plci->internal_command == 0) - { - plci->internal_command_queue[0] = command_function; - (* command_function)(Id, plci, OK); - } - else - { - i = 1; - while (plci->internal_command_queue[i] != NULL) - i++; - plci->internal_command_queue[i] = command_function; - } + if (plci->internal_command == 0) + { + plci->internal_command_queue[0] = command_function; + (*command_function)(Id, plci, OK); + } + else + { + i = 1; + while (plci->internal_command_queue[i] != NULL) + i++; + plci->internal_command_queue[i] = command_function; + } } -static void next_internal_command (dword Id, PLCI *plci) +static void next_internal_command(dword Id, PLCI *plci) { - word i; + word i; - dbug (1, dprintf ("[%06lx] %s,%d: next_internal_command", - UnMapId (Id), (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: next_internal_command", + UnMapId(Id), (char *)(FILE_), __LINE__)); - plci->internal_command = 0; - plci->internal_command_queue[0] = NULL; - while (plci->internal_command_queue[1] != NULL) - { - for (i = 0; i < MAX_INTERNAL_COMMAND_LEVELS - 1; i++) - plci->internal_command_queue[i] = plci->internal_command_queue[i+1]; - plci->internal_command_queue[MAX_INTERNAL_COMMAND_LEVELS - 1] = NULL; - (*(plci->internal_command_queue[0]))(Id, plci, OK); - if (plci->internal_command != 0) - return; - plci->internal_command_queue[0] = NULL; - } + plci->internal_command = 0; + plci->internal_command_queue[0] = NULL; + while (plci->internal_command_queue[1] != NULL) + { + for (i = 0; i < MAX_INTERNAL_COMMAND_LEVELS - 1; i++) + plci->internal_command_queue[i] = plci->internal_command_queue[i + 1]; + plci->internal_command_queue[MAX_INTERNAL_COMMAND_LEVELS - 1] = NULL; + (*(plci->internal_command_queue[0]))(Id, plci, OK); + if (plci->internal_command != 0) + return; + plci->internal_command_queue[0] = NULL; + } } @@ -775,238 +775,238 @@ static void next_internal_command (dword Id, PLCI *plci) static dword ncci_mapping_bug = 0; -static word get_ncci (PLCI *plci, byte ch, word force_ncci) -{ - DIVA_CAPI_ADAPTER *a; - word ncci, i, j, k; - - a = plci->adapter; - if (!ch || a->ch_ncci[ch]) - { - ncci_mapping_bug++; - dbug(1,dprintf("NCCI mapping exists %ld %02x %02x %02x-%02x", - ncci_mapping_bug, ch, force_ncci, a->ncci_ch[a->ch_ncci[ch]], a->ch_ncci[ch])); - ncci = ch; - } - else - { - if (force_ncci) - ncci = force_ncci; - else - { - if ((ch < MAX_NCCI+1) && !a->ncci_ch[ch]) - ncci = ch; - else - { - ncci = 1; - while ((ncci < MAX_NCCI+1) && a->ncci_ch[ncci]) - ncci++; - if (ncci == MAX_NCCI+1) - { - ncci_mapping_bug++; - i = 1; - do - { - j = 1; - while ((j < MAX_NCCI+1) && (a->ncci_ch[j] != i)) - j++; - k = j; - if (j < MAX_NCCI+1) - { - do - { - j++; - } while ((j < MAX_NCCI+1) && (a->ncci_ch[j] != i)); - } - } while ((i < MAX_NL_CHANNEL+1) && (j < MAX_NCCI+1)); - if (i < MAX_NL_CHANNEL+1) - { - dbug(1,dprintf("NCCI mapping overflow %ld %02x %02x %02x-%02x-%02x", - ncci_mapping_bug, ch, force_ncci, i, k, j)); - } - else - { - dbug(1,dprintf("NCCI mapping overflow %ld %02x %02x", - ncci_mapping_bug, ch, force_ncci)); - } - ncci = ch; - } - } - a->ncci_plci[ncci] = plci->Id; - a->ncci_state[ncci] = IDLE; - if (!plci->ncci_ring_list) - plci->ncci_ring_list = ncci; - else - a->ncci_next[ncci] = a->ncci_next[plci->ncci_ring_list]; - a->ncci_next[plci->ncci_ring_list] = (byte) ncci; - } - a->ncci_ch[ncci] = ch; - a->ch_ncci[ch] = (byte) ncci; - dbug(1,dprintf("NCCI mapping established %ld %02x %02x %02x-%02x", - ncci_mapping_bug, ch, force_ncci, ch, ncci)); - } - return (ncci); -} - - -static void ncci_free_receive_buffers (PLCI *plci, word ncci) -{ - DIVA_CAPI_ADAPTER *a; - APPL *appl; - word i, ncci_code; - dword Id; - - a = plci->adapter; - Id = (((dword) ncci) << 16) | (((word)(plci->Id)) << 8) | a->Id; - if (ncci) - { - if (a->ncci_plci[ncci] == plci->Id) - { - if (!plci->appl) - { - ncci_mapping_bug++; - dbug(1,dprintf("NCCI mapping appl expected %ld %08lx", - ncci_mapping_bug, Id)); - } - else - { - appl = plci->appl; - ncci_code = ncci | (((word) a->Id) << 8); - for (i = 0; i < appl->MaxBuffer; i++) - { - if ((appl->DataNCCI[i] == ncci_code) - && (((byte)(appl->DataFlags[i] >> 8)) == plci->Id)) - { - appl->DataNCCI[i] = 0; - } - } - } - } - } - else - { - for (ncci = 1; ncci < MAX_NCCI+1; ncci++) - { - if (a->ncci_plci[ncci] == plci->Id) - { - if (!plci->appl) - { - ncci_mapping_bug++; - dbug(1,dprintf("NCCI mapping no appl %ld %08lx", - ncci_mapping_bug, Id)); - } - else - { - appl = plci->appl; - ncci_code = ncci | (((word) a->Id) << 8); - for (i = 0; i < appl->MaxBuffer; i++) - { - if ((appl->DataNCCI[i] == ncci_code) - && (((byte)(appl->DataFlags[i] >> 8)) == plci->Id)) - { - appl->DataNCCI[i] = 0; - } - } - } - } - } - } -} - - -static void cleanup_ncci_data (PLCI *plci, word ncci) -{ - NCCI *ncci_ptr; - - if (ncci && (plci->adapter->ncci_plci[ncci] == plci->Id)) - { - ncci_ptr = &(plci->adapter->ncci[ncci]); - if (plci->appl) - { - while (ncci_ptr->data_pending != 0) - { - if (!plci->data_sent || (ncci_ptr->DBuffer[ncci_ptr->data_out].P != plci->data_sent_ptr)) - TransmitBufferFree (plci->appl, ncci_ptr->DBuffer[ncci_ptr->data_out].P); - (ncci_ptr->data_out)++; - if (ncci_ptr->data_out == MAX_DATA_B3) - ncci_ptr->data_out = 0; - (ncci_ptr->data_pending)--; - } - } - ncci_ptr->data_out = 0; - ncci_ptr->data_pending = 0; - ncci_ptr->data_ack_out = 0; - ncci_ptr->data_ack_pending = 0; - } -} - - -static void ncci_remove (PLCI *plci, word ncci, byte preserve_ncci) -{ - DIVA_CAPI_ADAPTER *a; - dword Id; - word i; - - a = plci->adapter; - Id = (((dword) ncci) << 16) | (((word)(plci->Id)) << 8) | a->Id; - if (!preserve_ncci) - ncci_free_receive_buffers (plci, ncci); - if (ncci) - { - if (a->ncci_plci[ncci] != plci->Id) - { - ncci_mapping_bug++; - dbug(1,dprintf("NCCI mapping doesn't exist %ld %08lx %02x", - ncci_mapping_bug, Id, preserve_ncci)); - } - else - { - cleanup_ncci_data (plci, ncci); - dbug(1,dprintf("NCCI mapping released %ld %08lx %02x %02x-%02x", - ncci_mapping_bug, Id, preserve_ncci, a->ncci_ch[ncci], ncci)); - a->ch_ncci[a->ncci_ch[ncci]] = 0; - if (!preserve_ncci) - { - a->ncci_ch[ncci] = 0; - a->ncci_plci[ncci] = 0; - a->ncci_state[ncci] = IDLE; - i = plci->ncci_ring_list; - while ((i != 0) && (a->ncci_next[i] != plci->ncci_ring_list) && (a->ncci_next[i] != ncci)) - i = a->ncci_next[i]; - if ((i != 0) && (a->ncci_next[i] == ncci)) - { - if (i == ncci) - plci->ncci_ring_list = 0; - else if (plci->ncci_ring_list == ncci) - plci->ncci_ring_list = i; - a->ncci_next[i] = a->ncci_next[ncci]; - } - a->ncci_next[ncci] = 0; - } - } - } - else - { - for (ncci = 1; ncci < MAX_NCCI+1; ncci++) - { - if (a->ncci_plci[ncci] == plci->Id) - { - cleanup_ncci_data (plci, ncci); - dbug(1,dprintf("NCCI mapping released %ld %08lx %02x %02x-%02x", - ncci_mapping_bug, Id, preserve_ncci, a->ncci_ch[ncci], ncci)); - a->ch_ncci[a->ncci_ch[ncci]] = 0; - if (!preserve_ncci) - { - a->ncci_ch[ncci] = 0; - a->ncci_plci[ncci] = 0; - a->ncci_state[ncci] = IDLE; - a->ncci_next[ncci] = 0; - } - } - } - if (!preserve_ncci) - plci->ncci_ring_list = 0; - } +static word get_ncci(PLCI *plci, byte ch, word force_ncci) +{ + DIVA_CAPI_ADAPTER *a; + word ncci, i, j, k; + + a = plci->adapter; + if (!ch || a->ch_ncci[ch]) + { + ncci_mapping_bug++; + dbug(1, dprintf("NCCI mapping exists %ld %02x %02x %02x-%02x", + ncci_mapping_bug, ch, force_ncci, a->ncci_ch[a->ch_ncci[ch]], a->ch_ncci[ch])); + ncci = ch; + } + else + { + if (force_ncci) + ncci = force_ncci; + else + { + if ((ch < MAX_NCCI + 1) && !a->ncci_ch[ch]) + ncci = ch; + else + { + ncci = 1; + while ((ncci < MAX_NCCI + 1) && a->ncci_ch[ncci]) + ncci++; + if (ncci == MAX_NCCI + 1) + { + ncci_mapping_bug++; + i = 1; + do + { + j = 1; + while ((j < MAX_NCCI + 1) && (a->ncci_ch[j] != i)) + j++; + k = j; + if (j < MAX_NCCI + 1) + { + do + { + j++; + } while ((j < MAX_NCCI + 1) && (a->ncci_ch[j] != i)); + } + } while ((i < MAX_NL_CHANNEL + 1) && (j < MAX_NCCI + 1)); + if (i < MAX_NL_CHANNEL + 1) + { + dbug(1, dprintf("NCCI mapping overflow %ld %02x %02x %02x-%02x-%02x", + ncci_mapping_bug, ch, force_ncci, i, k, j)); + } + else + { + dbug(1, dprintf("NCCI mapping overflow %ld %02x %02x", + ncci_mapping_bug, ch, force_ncci)); + } + ncci = ch; + } + } + a->ncci_plci[ncci] = plci->Id; + a->ncci_state[ncci] = IDLE; + if (!plci->ncci_ring_list) + plci->ncci_ring_list = ncci; + else + a->ncci_next[ncci] = a->ncci_next[plci->ncci_ring_list]; + a->ncci_next[plci->ncci_ring_list] = (byte) ncci; + } + a->ncci_ch[ncci] = ch; + a->ch_ncci[ch] = (byte) ncci; + dbug(1, dprintf("NCCI mapping established %ld %02x %02x %02x-%02x", + ncci_mapping_bug, ch, force_ncci, ch, ncci)); + } + return (ncci); +} + + +static void ncci_free_receive_buffers(PLCI *plci, word ncci) +{ + DIVA_CAPI_ADAPTER *a; + APPL *appl; + word i, ncci_code; + dword Id; + + a = plci->adapter; + Id = (((dword) ncci) << 16) | (((word)(plci->Id)) << 8) | a->Id; + if (ncci) + { + if (a->ncci_plci[ncci] == plci->Id) + { + if (!plci->appl) + { + ncci_mapping_bug++; + dbug(1, dprintf("NCCI mapping appl expected %ld %08lx", + ncci_mapping_bug, Id)); + } + else + { + appl = plci->appl; + ncci_code = ncci | (((word) a->Id) << 8); + for (i = 0; i < appl->MaxBuffer; i++) + { + if ((appl->DataNCCI[i] == ncci_code) + && (((byte)(appl->DataFlags[i] >> 8)) == plci->Id)) + { + appl->DataNCCI[i] = 0; + } + } + } + } + } + else + { + for (ncci = 1; ncci < MAX_NCCI + 1; ncci++) + { + if (a->ncci_plci[ncci] == plci->Id) + { + if (!plci->appl) + { + ncci_mapping_bug++; + dbug(1, dprintf("NCCI mapping no appl %ld %08lx", + ncci_mapping_bug, Id)); + } + else + { + appl = plci->appl; + ncci_code = ncci | (((word) a->Id) << 8); + for (i = 0; i < appl->MaxBuffer; i++) + { + if ((appl->DataNCCI[i] == ncci_code) + && (((byte)(appl->DataFlags[i] >> 8)) == plci->Id)) + { + appl->DataNCCI[i] = 0; + } + } + } + } + } + } +} + + +static void cleanup_ncci_data(PLCI *plci, word ncci) +{ + NCCI *ncci_ptr; + + if (ncci && (plci->adapter->ncci_plci[ncci] == plci->Id)) + { + ncci_ptr = &(plci->adapter->ncci[ncci]); + if (plci->appl) + { + while (ncci_ptr->data_pending != 0) + { + if (!plci->data_sent || (ncci_ptr->DBuffer[ncci_ptr->data_out].P != plci->data_sent_ptr)) + TransmitBufferFree(plci->appl, ncci_ptr->DBuffer[ncci_ptr->data_out].P); + (ncci_ptr->data_out)++; + if (ncci_ptr->data_out == MAX_DATA_B3) + ncci_ptr->data_out = 0; + (ncci_ptr->data_pending)--; + } + } + ncci_ptr->data_out = 0; + ncci_ptr->data_pending = 0; + ncci_ptr->data_ack_out = 0; + ncci_ptr->data_ack_pending = 0; + } +} + + +static void ncci_remove(PLCI *plci, word ncci, byte preserve_ncci) +{ + DIVA_CAPI_ADAPTER *a; + dword Id; + word i; + + a = plci->adapter; + Id = (((dword) ncci) << 16) | (((word)(plci->Id)) << 8) | a->Id; + if (!preserve_ncci) + ncci_free_receive_buffers(plci, ncci); + if (ncci) + { + if (a->ncci_plci[ncci] != plci->Id) + { + ncci_mapping_bug++; + dbug(1, dprintf("NCCI mapping doesn't exist %ld %08lx %02x", + ncci_mapping_bug, Id, preserve_ncci)); + } + else + { + cleanup_ncci_data(plci, ncci); + dbug(1, dprintf("NCCI mapping released %ld %08lx %02x %02x-%02x", + ncci_mapping_bug, Id, preserve_ncci, a->ncci_ch[ncci], ncci)); + a->ch_ncci[a->ncci_ch[ncci]] = 0; + if (!preserve_ncci) + { + a->ncci_ch[ncci] = 0; + a->ncci_plci[ncci] = 0; + a->ncci_state[ncci] = IDLE; + i = plci->ncci_ring_list; + while ((i != 0) && (a->ncci_next[i] != plci->ncci_ring_list) && (a->ncci_next[i] != ncci)) + i = a->ncci_next[i]; + if ((i != 0) && (a->ncci_next[i] == ncci)) + { + if (i == ncci) + plci->ncci_ring_list = 0; + else if (plci->ncci_ring_list == ncci) + plci->ncci_ring_list = i; + a->ncci_next[i] = a->ncci_next[ncci]; + } + a->ncci_next[ncci] = 0; + } + } + } + else + { + for (ncci = 1; ncci < MAX_NCCI + 1; ncci++) + { + if (a->ncci_plci[ncci] == plci->Id) + { + cleanup_ncci_data(plci, ncci); + dbug(1, dprintf("NCCI mapping released %ld %08lx %02x %02x-%02x", + ncci_mapping_bug, Id, preserve_ncci, a->ncci_ch[ncci], ncci)); + a->ch_ncci[a->ncci_ch[ncci]] = 0; + if (!preserve_ncci) + { + a->ncci_ch[ncci] = 0; + a->ncci_plci[ncci] = 0; + a->ncci_state[ncci] = IDLE; + a->ncci_next[ncci] = 0; + } + } + } + if (!preserve_ncci) + plci->ncci_ring_list = 0; + } } @@ -1014,170 +1014,170 @@ static void ncci_remove (PLCI *plci, word ncci, byte preserve_ncci) /* PLCI remove function */ /*------------------------------------------------------------------*/ -static void plci_free_msg_in_queue (PLCI *plci) -{ - word i; - - if (plci->appl) - { - i = plci->msg_in_read_pos; - while (i != plci->msg_in_write_pos) - { - if (i == plci->msg_in_wrap_pos) - i = 0; - if (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->header.command == _DATA_B3_R) - { - - TransmitBufferFree (plci->appl, - (byte *)(long)(((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->info.data_b3_req.Data)); - - } - - i += (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->header.length + - MSG_IN_OVERHEAD + 3) & 0xfffc; - - } - } - plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; -} - - -static void plci_remove(PLCI * plci) -{ - - if(!plci) { - dbug(1,dprintf("plci_remove(no plci)")); - return; - } - init_internal_command_queue (plci); - dbug(1,dprintf("plci_remove(%x,tel=%x)",plci->Id,plci->tel)); - if(plci_remove_check(plci)) - { - return; - } - if (plci->Sig.Id == 0xff) - { - dbug(1,dprintf("D-channel X.25 plci->NL.Id:%0x", plci->NL.Id)); - if (plci->NL.Id && !plci->nl_remove_id) - { - nl_req_ncci(plci,REMOVE,0); - send_req(plci); - } - } - else - { - if (!plci->sig_remove_id - && (plci->Sig.Id - || (plci->req_in!=plci->req_out) - || (plci->nl_req || plci->sig_req))) - { - sig_req(plci,HANGUP,0); - send_req(plci); - } - } - ncci_remove (plci, 0, false); - plci_free_msg_in_queue (plci); - - plci->channels = 0; - plci->appl = NULL; - if ((plci->State == INC_CON_PENDING) || (plci->State == INC_CON_ALERT)) - plci->State = OUTG_DIS_PENDING; +static void plci_free_msg_in_queue(PLCI *plci) +{ + word i; + + if (plci->appl) + { + i = plci->msg_in_read_pos; + while (i != plci->msg_in_write_pos) + { + if (i == plci->msg_in_wrap_pos) + i = 0; + if (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->header.command == _DATA_B3_R) + { + + TransmitBufferFree(plci->appl, + (byte *)(long)(((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->info.data_b3_req.Data)); + + } + + i += (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[i]))->header.length + + MSG_IN_OVERHEAD + 3) & 0xfffc; + + } + } + plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; +} + + +static void plci_remove(PLCI *plci) +{ + + if (!plci) { + dbug(1, dprintf("plci_remove(no plci)")); + return; + } + init_internal_command_queue(plci); + dbug(1, dprintf("plci_remove(%x,tel=%x)", plci->Id, plci->tel)); + if (plci_remove_check(plci)) + { + return; + } + if (plci->Sig.Id == 0xff) + { + dbug(1, dprintf("D-channel X.25 plci->NL.Id:%0x", plci->NL.Id)); + if (plci->NL.Id && !plci->nl_remove_id) + { + nl_req_ncci(plci, REMOVE, 0); + send_req(plci); + } + } + else + { + if (!plci->sig_remove_id + && (plci->Sig.Id + || (plci->req_in != plci->req_out) + || (plci->nl_req || plci->sig_req))) + { + sig_req(plci, HANGUP, 0); + send_req(plci); + } + } + ncci_remove(plci, 0, false); + plci_free_msg_in_queue(plci); + + plci->channels = 0; + plci->appl = NULL; + if ((plci->State == INC_CON_PENDING) || (plci->State == INC_CON_ALERT)) + plci->State = OUTG_DIS_PENDING; } /*------------------------------------------------------------------*/ /* Application Group function helpers */ /*------------------------------------------------------------------*/ -static void set_group_ind_mask (PLCI *plci) +static void set_group_ind_mask(PLCI *plci) { - word i; + word i; - for (i = 0; i < C_IND_MASK_DWORDS; i++) - plci->group_optimization_mask_table[i] = 0xffffffffL; + for (i = 0; i < C_IND_MASK_DWORDS; i++) + plci->group_optimization_mask_table[i] = 0xffffffffL; } -static void clear_group_ind_mask_bit (PLCI *plci, word b) +static void clear_group_ind_mask_bit(PLCI *plci, word b) { - plci->group_optimization_mask_table[b >> 5] &= ~(1L << (b & 0x1f)); + plci->group_optimization_mask_table[b >> 5] &= ~(1L << (b & 0x1f)); } -static byte test_group_ind_mask_bit (PLCI *plci, word b) +static byte test_group_ind_mask_bit(PLCI *plci, word b) { - return ((plci->group_optimization_mask_table[b >> 5] & (1L << (b & 0x1f))) != 0); + return ((plci->group_optimization_mask_table[b >> 5] & (1L << (b & 0x1f))) != 0); } /*------------------------------------------------------------------*/ /* c_ind_mask operations for arbitrary MAX_APPL */ /*------------------------------------------------------------------*/ -static void clear_c_ind_mask (PLCI *plci) +static void clear_c_ind_mask(PLCI *plci) { - word i; + word i; - for (i = 0; i < C_IND_MASK_DWORDS; i++) - plci->c_ind_mask_table[i] = 0; + for (i = 0; i < C_IND_MASK_DWORDS; i++) + plci->c_ind_mask_table[i] = 0; } -static byte c_ind_mask_empty (PLCI *plci) +static byte c_ind_mask_empty(PLCI *plci) { - word i; + word i; - i = 0; - while ((i < C_IND_MASK_DWORDS) && (plci->c_ind_mask_table[i] == 0)) - i++; - return (i == C_IND_MASK_DWORDS); + i = 0; + while ((i < C_IND_MASK_DWORDS) && (plci->c_ind_mask_table[i] == 0)) + i++; + return (i == C_IND_MASK_DWORDS); } -static void set_c_ind_mask_bit (PLCI *plci, word b) +static void set_c_ind_mask_bit(PLCI *plci, word b) { - plci->c_ind_mask_table[b >> 5] |= (1L << (b & 0x1f)); + plci->c_ind_mask_table[b >> 5] |= (1L << (b & 0x1f)); } -static void clear_c_ind_mask_bit (PLCI *plci, word b) +static void clear_c_ind_mask_bit(PLCI *plci, word b) { - plci->c_ind_mask_table[b >> 5] &= ~(1L << (b & 0x1f)); + plci->c_ind_mask_table[b >> 5] &= ~(1L << (b & 0x1f)); } -static byte test_c_ind_mask_bit (PLCI *plci, word b) +static byte test_c_ind_mask_bit(PLCI *plci, word b) { - return ((plci->c_ind_mask_table[b >> 5] & (1L << (b & 0x1f))) != 0); + return ((plci->c_ind_mask_table[b >> 5] & (1L << (b & 0x1f))) != 0); } -static void dump_c_ind_mask (PLCI *plci) +static void dump_c_ind_mask(PLCI *plci) { -static char hex_digit_table[0x10] = - {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - word i, j, k; - dword d; - char *p; - char buf[40]; + static char hex_digit_table[0x10] = + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + word i, j, k; + dword d; + char *p; + char buf[40]; - for (i = 0; i < C_IND_MASK_DWORDS; i += 4) - { - p = buf + 36; - *p = '\0'; - for (j = 0; j < 4; j++) - { - if (i+j < C_IND_MASK_DWORDS) - { - d = plci->c_ind_mask_table[i+j]; - for (k = 0; k < 8; k++) - { - *(--p) = hex_digit_table[d & 0xf]; - d >>= 4; - } - } - else if (i != 0) - { - for (k = 0; k < 8; k++) - *(--p) = ' '; - } - *(--p) = ' '; - } - dbug(1,dprintf ("c_ind_mask =%s", (char *) p)); - } + for (i = 0; i < C_IND_MASK_DWORDS; i += 4) + { + p = buf + 36; + *p = '\0'; + for (j = 0; j < 4; j++) + { + if (i + j < C_IND_MASK_DWORDS) + { + d = plci->c_ind_mask_table[i + j]; + for (k = 0; k < 8; k++) + { + *(--p) = hex_digit_table[d & 0xf]; + d >>= 4; + } + } + else if (i != 0) + { + for (k = 0; k < 8; k++) + *(--p) = ' '; + } + *(--p) = ' '; + } + dbug(1, dprintf("c_ind_mask =%s", (char *) p)); + } } @@ -1195,6204 +1195,6204 @@ static char hex_digit_table[0x10] = static byte connect_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word ch; - word i; - word Info; - byte LinkLayer; - API_PARSE * ai; - API_PARSE * bp; - API_PARSE ai_parms[5]; - word channel = 0; - dword ch_mask; - byte m; - static byte esc_chi[35] = {0x02,0x18,0x01}; - static byte lli[2] = {0x01,0x00}; - byte noCh = 0; - word dir = 0; - byte *p_chi = ""; - - for(i=0;i<5;i++) ai_parms[i].length = 0; - - dbug(1,dprintf("connect_req(%d)",parms->length)); - Info = _WRONG_IDENTIFIER; - if(a) - { - if(a->adapter_disabled) - { - dbug(1,dprintf("adapter disabled")); - Id = ((word)1<<8)|a->Id; - sendf(appl,_CONNECT_R|CONFIRM,Id,Number,"w",0); - sendf(appl, _DISCONNECT_I, Id, 0, "w", _L1_ERROR); - return false; - } - Info = _OUT_OF_PLCI; - if((i=get_plci(a))) - { - Info = 0; - plci = &a->plci[i-1]; - plci->appl = appl; - plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; - /* check 'external controller' bit for codec support */ - if(Id & EXT_CONTROLLER) - { - if(AdvCodecSupport(a, plci, appl, 0) ) - { - plci->Id = 0; - sendf(appl, _CONNECT_R|CONFIRM, Id, Number, "w", _WRONG_IDENTIFIER); - return 2; - } - } - ai = &parms[9]; - bp = &parms[5]; - ch = 0; - if(bp->length)LinkLayer = bp->info[3]; - else LinkLayer = 0; - if(ai->length) - { - ch=0xffff; - if(!api_parse(&ai->info[1],(word)ai->length,"ssss",ai_parms)) - { - ch = 0; - if(ai_parms[0].length) - { - ch = GET_WORD(ai_parms[0].info+1); - if(ch>4) ch=0; /* safety -> ignore ChannelID */ - if(ch==4) /* explizit CHI in message */ - { - /* check length of B-CH struct */ - if((ai_parms[0].info)[3]>=1) - { - if((ai_parms[0].info)[4]==CHI) - { - p_chi = &((ai_parms[0].info)[5]); - } - else - { - p_chi = &((ai_parms[0].info)[3]); - } - if(p_chi[0]>35) /* check length of channel ID */ - { - Info = _WRONG_MESSAGE_FORMAT; - } - } - else Info = _WRONG_MESSAGE_FORMAT; - } - - if(ch==3 && ai_parms[0].length>=7 && ai_parms[0].length<=36) - { - dir = GET_WORD(ai_parms[0].info+3); - ch_mask = 0; - m = 0x3f; - for(i=0; i+5<=ai_parms[0].length; i++) - { - if(ai_parms[0].info[i+5]!=0) - { - if((ai_parms[0].info[i+5] | m) != 0xff) - Info = _WRONG_MESSAGE_FORMAT; - else - { - if (ch_mask == 0) - channel = i; - ch_mask |= 1L << i; - } - } - m = 0; - } - if (ch_mask == 0) - Info = _WRONG_MESSAGE_FORMAT; - if (!Info) - { - if ((ai_parms[0].length == 36) || (ch_mask != ((dword)(1L << channel)))) - { - esc_chi[0] = (byte)(ai_parms[0].length - 2); - for(i=0; i+5<=ai_parms[0].length; i++) - esc_chi[i+3] = ai_parms[0].info[i+5]; - } - else - esc_chi[0] = 2; - esc_chi[2] = (byte)channel; - plci->b_channel = (byte)channel; /* not correct for ETSI ch 17..31 */ - add_p(plci,LLI,lli); - add_p(plci,ESC,esc_chi); - plci->State = LOCAL_CONNECT; - if(!dir) plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; /* dir 0=DTE, 1=DCE */ - } - } - } - } - else Info = _WRONG_MESSAGE_FORMAT; - } - - dbug(1,dprintf("ch=%x,dir=%x,p_ch=%d",ch,dir,channel)); - plci->command = _CONNECT_R; - plci->number = Number; - /* x.31 or D-ch free SAPI in LinkLayer? */ - if(ch==1 && LinkLayer!=3 && LinkLayer!=12) noCh = true; - if((ch==0 || ch==2 || noCh || ch==3 || ch==4) && !Info) - { - /* B-channel used for B3 connections (ch==0), or no B channel */ - /* is used (ch==2) or perm. connection (3) is used do a CALL */ - if(noCh) Info = add_b1(plci,&parms[5],2,0); /* no resource */ - else Info = add_b1(plci,&parms[5],ch,0); - add_s(plci,OAD,&parms[2]); - add_s(plci,OSA,&parms[4]); - add_s(plci,BC,&parms[6]); - add_s(plci,LLC,&parms[7]); - add_s(plci,HLC,&parms[8]); - if (a->Info_Mask[appl->Id-1] & 0x200) - { - /* early B3 connect (CIP mask bit 9) no release after a disc */ - add_p(plci,LLI,"\x01\x01"); - } - if(GET_WORD(parms[0].info)<29) { - add_p(plci,BC,cip_bc[GET_WORD(parms[0].info)][a->u_law]); - add_p(plci,HLC,cip_hlc[GET_WORD(parms[0].info)]); - } - add_p(plci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(plci,ASSIGN,DSIG_ID); - } - else if(ch==1) { - - /* D-Channel used for B3 connections */ - plci->Sig.Id = 0xff; - Info = 0; - } - - if(!Info && ch!=2 && !noCh ) { - Info = add_b23(plci,&parms[5]); - if(!Info) { - if(!(plci->tel && !plci->adv_nl))nl_req_ncci(plci,ASSIGN,0); - } - } - - if(!Info) - { - if(ch==0 || ch==2 || ch==3 || noCh || ch==4) - { - if(plci->spoofed_msg==SPOOFING_REQUIRED) - { - api_save_msg(parms, "wsssssssss", &plci->saved_msg); - plci->spoofed_msg = CALL_REQ; - plci->internal_command = BLOCK_PLCI; - plci->command = 0; - dbug(1,dprintf("Spoof")); - send_req(plci); - return false; - } - if(ch==4)add_p(plci,CHI,p_chi); - add_s(plci,CPN,&parms[1]); - add_s(plci,DSA,&parms[3]); - if(noCh) add_p(plci,ESC,"\x02\x18\xfd"); /* D-channel, no B-L3 */ - add_ai(plci,&parms[9]); - if(!dir)sig_req(plci,CALL_REQ,0); - else - { - plci->command = PERM_LIST_REQ; - plci->appl = appl; - sig_req(plci,LISTEN_REQ,0); - send_req(plci); - return false; - } - } - send_req(plci); - return false; - } - plci->Id = 0; - } - } - sendf(appl, - _CONNECT_R|CONFIRM, - Id, - Number, - "w",Info); - return 2; + word ch; + word i; + word Info; + byte LinkLayer; + API_PARSE *ai; + API_PARSE *bp; + API_PARSE ai_parms[5]; + word channel = 0; + dword ch_mask; + byte m; + static byte esc_chi[35] = {0x02, 0x18, 0x01}; + static byte lli[2] = {0x01, 0x00}; + byte noCh = 0; + word dir = 0; + byte *p_chi = ""; + + for (i = 0; i < 5; i++) ai_parms[i].length = 0; + + dbug(1, dprintf("connect_req(%d)", parms->length)); + Info = _WRONG_IDENTIFIER; + if (a) + { + if (a->adapter_disabled) + { + dbug(1, dprintf("adapter disabled")); + Id = ((word)1 << 8) | a->Id; + sendf(appl, _CONNECT_R | CONFIRM, Id, Number, "w", 0); + sendf(appl, _DISCONNECT_I, Id, 0, "w", _L1_ERROR); + return false; + } + Info = _OUT_OF_PLCI; + if ((i = get_plci(a))) + { + Info = 0; + plci = &a->plci[i - 1]; + plci->appl = appl; + plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; + /* check 'external controller' bit for codec support */ + if (Id & EXT_CONTROLLER) + { + if (AdvCodecSupport(a, plci, appl, 0)) + { + plci->Id = 0; + sendf(appl, _CONNECT_R | CONFIRM, Id, Number, "w", _WRONG_IDENTIFIER); + return 2; + } + } + ai = &parms[9]; + bp = &parms[5]; + ch = 0; + if (bp->length)LinkLayer = bp->info[3]; + else LinkLayer = 0; + if (ai->length) + { + ch = 0xffff; + if (!api_parse(&ai->info[1], (word)ai->length, "ssss", ai_parms)) + { + ch = 0; + if (ai_parms[0].length) + { + ch = GET_WORD(ai_parms[0].info + 1); + if (ch > 4) ch = 0; /* safety -> ignore ChannelID */ + if (ch == 4) /* explizit CHI in message */ + { + /* check length of B-CH struct */ + if ((ai_parms[0].info)[3] >= 1) + { + if ((ai_parms[0].info)[4] == CHI) + { + p_chi = &((ai_parms[0].info)[5]); + } + else + { + p_chi = &((ai_parms[0].info)[3]); + } + if (p_chi[0] > 35) /* check length of channel ID */ + { + Info = _WRONG_MESSAGE_FORMAT; + } + } + else Info = _WRONG_MESSAGE_FORMAT; + } + + if (ch == 3 && ai_parms[0].length >= 7 && ai_parms[0].length <= 36) + { + dir = GET_WORD(ai_parms[0].info + 3); + ch_mask = 0; + m = 0x3f; + for (i = 0; i + 5 <= ai_parms[0].length; i++) + { + if (ai_parms[0].info[i + 5] != 0) + { + if ((ai_parms[0].info[i + 5] | m) != 0xff) + Info = _WRONG_MESSAGE_FORMAT; + else + { + if (ch_mask == 0) + channel = i; + ch_mask |= 1L << i; + } + } + m = 0; + } + if (ch_mask == 0) + Info = _WRONG_MESSAGE_FORMAT; + if (!Info) + { + if ((ai_parms[0].length == 36) || (ch_mask != ((dword)(1L << channel)))) + { + esc_chi[0] = (byte)(ai_parms[0].length - 2); + for (i = 0; i + 5 <= ai_parms[0].length; i++) + esc_chi[i + 3] = ai_parms[0].info[i + 5]; + } + else + esc_chi[0] = 2; + esc_chi[2] = (byte)channel; + plci->b_channel = (byte)channel; /* not correct for ETSI ch 17..31 */ + add_p(plci, LLI, lli); + add_p(plci, ESC, esc_chi); + plci->State = LOCAL_CONNECT; + if (!dir) plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; /* dir 0=DTE, 1=DCE */ + } + } + } + } + else Info = _WRONG_MESSAGE_FORMAT; + } + + dbug(1, dprintf("ch=%x,dir=%x,p_ch=%d", ch, dir, channel)); + plci->command = _CONNECT_R; + plci->number = Number; + /* x.31 or D-ch free SAPI in LinkLayer? */ + if (ch == 1 && LinkLayer != 3 && LinkLayer != 12) noCh = true; + if ((ch == 0 || ch == 2 || noCh || ch == 3 || ch == 4) && !Info) + { + /* B-channel used for B3 connections (ch==0), or no B channel */ + /* is used (ch==2) or perm. connection (3) is used do a CALL */ + if (noCh) Info = add_b1(plci, &parms[5], 2, 0); /* no resource */ + else Info = add_b1(plci, &parms[5], ch, 0); + add_s(plci, OAD, &parms[2]); + add_s(plci, OSA, &parms[4]); + add_s(plci, BC, &parms[6]); + add_s(plci, LLC, &parms[7]); + add_s(plci, HLC, &parms[8]); + if (a->Info_Mask[appl->Id - 1] & 0x200) + { + /* early B3 connect (CIP mask bit 9) no release after a disc */ + add_p(plci, LLI, "\x01\x01"); + } + if (GET_WORD(parms[0].info) < 29) { + add_p(plci, BC, cip_bc[GET_WORD(parms[0].info)][a->u_law]); + add_p(plci, HLC, cip_hlc[GET_WORD(parms[0].info)]); + } + add_p(plci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(plci, ASSIGN, DSIG_ID); + } + else if (ch == 1) { + + /* D-Channel used for B3 connections */ + plci->Sig.Id = 0xff; + Info = 0; + } + + if (!Info && ch != 2 && !noCh) { + Info = add_b23(plci, &parms[5]); + if (!Info) { + if (!(plci->tel && !plci->adv_nl))nl_req_ncci(plci, ASSIGN, 0); + } + } + + if (!Info) + { + if (ch == 0 || ch == 2 || ch == 3 || noCh || ch == 4) + { + if (plci->spoofed_msg == SPOOFING_REQUIRED) + { + api_save_msg(parms, "wsssssssss", &plci->saved_msg); + plci->spoofed_msg = CALL_REQ; + plci->internal_command = BLOCK_PLCI; + plci->command = 0; + dbug(1, dprintf("Spoof")); + send_req(plci); + return false; + } + if (ch == 4)add_p(plci, CHI, p_chi); + add_s(plci, CPN, &parms[1]); + add_s(plci, DSA, &parms[3]); + if (noCh) add_p(plci, ESC, "\x02\x18\xfd"); /* D-channel, no B-L3 */ + add_ai(plci, &parms[9]); + if (!dir)sig_req(plci, CALL_REQ, 0); + else + { + plci->command = PERM_LIST_REQ; + plci->appl = appl; + sig_req(plci, LISTEN_REQ, 0); + send_req(plci); + return false; + } + } + send_req(plci); + return false; + } + plci->Id = 0; + } + } + sendf(appl, + _CONNECT_R | CONFIRM, + Id, + Number, + "w", Info); + return 2; } static byte connect_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word i, Info; - word Reject; - static byte cau_t[] = {0,0,0x90,0x91,0xac,0x9d,0x86,0xd8,0x9b}; - static byte esc_t[] = {0x03,0x08,0x00,0x00}; - API_PARSE * ai; - API_PARSE ai_parms[5]; - word ch=0; - - if(!plci) { - dbug(1,dprintf("connect_res(no plci)")); - return 0; /* no plci, no send */ - } - - dbug(1,dprintf("connect_res(State=0x%x)",plci->State)); - for(i=0;i<5;i++) ai_parms[i].length = 0; - ai = &parms[5]; - dbug(1,dprintf("ai->length=%d",ai->length)); - - if(ai->length) - { - if(!api_parse(&ai->info[1],(word)ai->length,"ssss",ai_parms)) - { - dbug(1,dprintf("ai_parms[0].length=%d/0x%x",ai_parms[0].length,GET_WORD(ai_parms[0].info+1))); - ch = 0; - if(ai_parms[0].length) - { - ch = GET_WORD(ai_parms[0].info+1); - dbug(1,dprintf("BCH-I=0x%x",ch)); - } - } - } - - if(plci->State==INC_CON_CONNECTED_ALERT) - { - dbug(1,dprintf("Connected Alert Call_Res")); - if (a->Info_Mask[appl->Id-1] & 0x200) - { - /* early B3 connect (CIP mask bit 9) no release after a disc */ - add_p(plci,LLI,"\x01\x01"); - } - add_s(plci, CONN_NR, &parms[2]); - add_s(plci, LLC, &parms[4]); - add_ai(plci, &parms[5]); - plci->State = INC_CON_ACCEPT; - sig_req(plci, CALL_RES,0); - return 1; - } - else if(plci->State==INC_CON_PENDING || plci->State==INC_CON_ALERT) { - clear_c_ind_mask_bit (plci, (word)(appl->Id-1)); - dump_c_ind_mask (plci); - Reject = GET_WORD(parms[0].info); - dbug(1,dprintf("Reject=0x%x",Reject)); - if(Reject) - { - if(c_ind_mask_empty (plci)) - { - if((Reject&0xff00)==0x3400) - { - esc_t[2] = ((byte)(Reject&0x00ff)) | 0x80; - add_p(plci,ESC,esc_t); - add_ai(plci, &parms[5]); - sig_req(plci,REJECT,0); - } - else if(Reject==1 || Reject>9) - { - add_ai(plci, &parms[5]); - sig_req(plci,HANGUP,0); - } - else - { - esc_t[2] = cau_t[(Reject&0x000f)]; - add_p(plci,ESC,esc_t); - add_ai(plci, &parms[5]); - sig_req(plci,REJECT,0); - } - plci->appl = appl; - } - else - { - sendf(appl, _DISCONNECT_I, Id, 0, "w", _OTHER_APPL_CONNECTED); - } - } - else { - plci->appl = appl; - if(Id & EXT_CONTROLLER){ - if(AdvCodecSupport(a, plci, appl, 0)){ - dbug(1,dprintf("connect_res(error from AdvCodecSupport)")); - sig_req(plci,HANGUP,0); - return 1; - } - if(plci->tel == ADV_VOICE && a->AdvCodecPLCI) - { - Info = add_b23(plci, &parms[1]); - if (Info) - { - dbug(1,dprintf("connect_res(error from add_b23)")); - sig_req(plci,HANGUP,0); - return 1; - } - if(plci->adv_nl) - { - nl_req_ncci(plci, ASSIGN, 0); - } - } - } - else - { - plci->tel = 0; - if(ch!=2) - { - Info = add_b23(plci, &parms[1]); - if (Info) - { - dbug(1,dprintf("connect_res(error from add_b23 2)")); - sig_req(plci,HANGUP,0); - return 1; - } - } - nl_req_ncci(plci, ASSIGN, 0); - } - - if(plci->spoofed_msg==SPOOFING_REQUIRED) - { - api_save_msg(parms, "wsssss", &plci->saved_msg); - plci->spoofed_msg = CALL_RES; - plci->internal_command = BLOCK_PLCI; - plci->command = 0; - dbug(1,dprintf("Spoof")); - } - else - { - add_b1 (plci, &parms[1], ch, plci->B1_facilities); - if (a->Info_Mask[appl->Id-1] & 0x200) - { - /* early B3 connect (CIP mask bit 9) no release after a disc */ - add_p(plci,LLI,"\x01\x01"); - } - add_s(plci, CONN_NR, &parms[2]); - add_s(plci, LLC, &parms[4]); - add_ai(plci, &parms[5]); - plci->State = INC_CON_ACCEPT; - sig_req(plci, CALL_RES,0); - } - - for(i=0; iState)); + for (i = 0; i < 5; i++) ai_parms[i].length = 0; + ai = &parms[5]; + dbug(1, dprintf("ai->length=%d", ai->length)); + + if (ai->length) + { + if (!api_parse(&ai->info[1], (word)ai->length, "ssss", ai_parms)) + { + dbug(1, dprintf("ai_parms[0].length=%d/0x%x", ai_parms[0].length, GET_WORD(ai_parms[0].info + 1))); + ch = 0; + if (ai_parms[0].length) + { + ch = GET_WORD(ai_parms[0].info + 1); + dbug(1, dprintf("BCH-I=0x%x", ch)); + } + } + } + + if (plci->State == INC_CON_CONNECTED_ALERT) + { + dbug(1, dprintf("Connected Alert Call_Res")); + if (a->Info_Mask[appl->Id - 1] & 0x200) + { + /* early B3 connect (CIP mask bit 9) no release after a disc */ + add_p(plci, LLI, "\x01\x01"); + } + add_s(plci, CONN_NR, &parms[2]); + add_s(plci, LLC, &parms[4]); + add_ai(plci, &parms[5]); + plci->State = INC_CON_ACCEPT; + sig_req(plci, CALL_RES, 0); + return 1; + } + else if (plci->State == INC_CON_PENDING || plci->State == INC_CON_ALERT) { + clear_c_ind_mask_bit(plci, (word)(appl->Id - 1)); + dump_c_ind_mask(plci); + Reject = GET_WORD(parms[0].info); + dbug(1, dprintf("Reject=0x%x", Reject)); + if (Reject) + { + if (c_ind_mask_empty(plci)) + { + if ((Reject & 0xff00) == 0x3400) + { + esc_t[2] = ((byte)(Reject & 0x00ff)) | 0x80; + add_p(plci, ESC, esc_t); + add_ai(plci, &parms[5]); + sig_req(plci, REJECT, 0); + } + else if (Reject == 1 || Reject > 9) + { + add_ai(plci, &parms[5]); + sig_req(plci, HANGUP, 0); + } + else + { + esc_t[2] = cau_t[(Reject&0x000f)]; + add_p(plci, ESC, esc_t); + add_ai(plci, &parms[5]); + sig_req(plci, REJECT, 0); + } + plci->appl = appl; + } + else + { + sendf(appl, _DISCONNECT_I, Id, 0, "w", _OTHER_APPL_CONNECTED); + } + } + else { + plci->appl = appl; + if (Id & EXT_CONTROLLER) { + if (AdvCodecSupport(a, plci, appl, 0)) { + dbug(1, dprintf("connect_res(error from AdvCodecSupport)")); + sig_req(plci, HANGUP, 0); + return 1; + } + if (plci->tel == ADV_VOICE && a->AdvCodecPLCI) + { + Info = add_b23(plci, &parms[1]); + if (Info) + { + dbug(1, dprintf("connect_res(error from add_b23)")); + sig_req(plci, HANGUP, 0); + return 1; + } + if (plci->adv_nl) + { + nl_req_ncci(plci, ASSIGN, 0); + } + } + } + else + { + plci->tel = 0; + if (ch != 2) + { + Info = add_b23(plci, &parms[1]); + if (Info) + { + dbug(1, dprintf("connect_res(error from add_b23 2)")); + sig_req(plci, HANGUP, 0); + return 1; + } + } + nl_req_ncci(plci, ASSIGN, 0); + } + + if (plci->spoofed_msg == SPOOFING_REQUIRED) + { + api_save_msg(parms, "wsssss", &plci->saved_msg); + plci->spoofed_msg = CALL_RES; + plci->internal_command = BLOCK_PLCI; + plci->command = 0; + dbug(1, dprintf("Spoof")); + } + else + { + add_b1(plci, &parms[1], ch, plci->B1_facilities); + if (a->Info_Mask[appl->Id - 1] & 0x200) + { + /* early B3 connect (CIP mask bit 9) no release after a disc */ + add_p(plci, LLI, "\x01\x01"); + } + add_s(plci, CONN_NR, &parms[2]); + add_s(plci, LLC, &parms[4]); + add_ai(plci, &parms[5]); + plci->State = INC_CON_ACCEPT; + sig_req(plci, CALL_RES, 0); + } + + for (i = 0; i < max_appl; i++) { + if (test_c_ind_mask_bit(plci, i)) { + sendf(&application[i], _DISCONNECT_I, Id, 0, "w", _OTHER_APPL_CONNECTED); + } + } + } + } + return 1; } static byte connect_a_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - dbug(1,dprintf("connect_a_res")); - return false; + dbug(1, dprintf("connect_a_res")); + return false; } static byte disconnect_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - word Info; - word i; - - dbug(1,dprintf("disconnect_req")); - - Info = _WRONG_IDENTIFIER; - - if(plci) - { - if(plci->State==INC_CON_PENDING || plci->State==INC_CON_ALERT) - { - clear_c_ind_mask_bit (plci, (word)(appl->Id-1)); - plci->appl = appl; - for(i=0; iState = OUTG_DIS_PENDING; - } - if(plci->Sig.Id && plci->appl) - { - Info = 0; - if(plci->Sig.Id!=0xff) - { - if(plci->State!=INC_DIS_PENDING) - { - add_ai(plci, &msg[0]); - sig_req(plci,HANGUP,0); - plci->State = OUTG_DIS_PENDING; - return 1; - } - } - else - { - if (plci->NL.Id && !plci->nl_remove_id) - { - mixer_remove (plci); - nl_req_ncci(plci,REMOVE,0); - sendf(appl,_DISCONNECT_R|CONFIRM,Id,Number,"w",0); - sendf(appl, _DISCONNECT_I, Id, 0, "w", 0); - plci->State = INC_DIS_PENDING; - } - return 1; - } - } - } - - if(!appl) return false; - sendf(appl, _DISCONNECT_R|CONFIRM, Id, Number, "w",Info); - return false; + word Info; + word i; + + dbug(1, dprintf("disconnect_req")); + + Info = _WRONG_IDENTIFIER; + + if (plci) + { + if (plci->State == INC_CON_PENDING || plci->State == INC_CON_ALERT) + { + clear_c_ind_mask_bit(plci, (word)(appl->Id - 1)); + plci->appl = appl; + for (i = 0; i < max_appl; i++) + { + if (test_c_ind_mask_bit(plci, i)) + sendf(&application[i], _DISCONNECT_I, Id, 0, "w", 0); + } + plci->State = OUTG_DIS_PENDING; + } + if (plci->Sig.Id && plci->appl) + { + Info = 0; + if (plci->Sig.Id != 0xff) + { + if (plci->State != INC_DIS_PENDING) + { + add_ai(plci, &msg[0]); + sig_req(plci, HANGUP, 0); + plci->State = OUTG_DIS_PENDING; + return 1; + } + } + else + { + if (plci->NL.Id && !plci->nl_remove_id) + { + mixer_remove(plci); + nl_req_ncci(plci, REMOVE, 0); + sendf(appl, _DISCONNECT_R | CONFIRM, Id, Number, "w", 0); + sendf(appl, _DISCONNECT_I, Id, 0, "w", 0); + plci->State = INC_DIS_PENDING; + } + return 1; + } + } + } + + if (!appl) return false; + sendf(appl, _DISCONNECT_R | CONFIRM, Id, Number, "w", Info); + return false; } static byte disconnect_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - dbug(1,dprintf("disconnect_res")); - if(plci) - { - /* clear ind mask bit, just in case of collsion of */ - /* DISCONNECT_IND and CONNECT_RES */ - clear_c_ind_mask_bit (plci, (word)(appl->Id-1)); - ncci_free_receive_buffers (plci, 0); - if(plci_remove_check(plci)) - { - return 0; - } - if(plci->State==INC_DIS_PENDING - || plci->State==SUSPENDING) { - if(c_ind_mask_empty (plci)) { - if(plci->State!=SUSPENDING)plci->State = IDLE; - dbug(1,dprintf("chs=%d",plci->channels)); - if(!plci->channels) { - plci_remove(plci); - } - } - } - } - return 0; + dbug(1, dprintf("disconnect_res")); + if (plci) + { + /* clear ind mask bit, just in case of collsion of */ + /* DISCONNECT_IND and CONNECT_RES */ + clear_c_ind_mask_bit(plci, (word)(appl->Id - 1)); + ncci_free_receive_buffers(plci, 0); + if (plci_remove_check(plci)) + { + return 0; + } + if (plci->State == INC_DIS_PENDING + || plci->State == SUSPENDING) { + if (c_ind_mask_empty(plci)) { + if (plci->State != SUSPENDING) plci->State = IDLE; + dbug(1, dprintf("chs=%d", plci->channels)); + if (!plci->channels) { + plci_remove(plci); + } + } + } + } + return 0; } static byte listen_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word Info; - byte i; - - dbug(1,dprintf("listen_req(Appl=0x%x)",appl->Id)); - - Info = _WRONG_IDENTIFIER; - if(a) { - Info = 0; - a->Info_Mask[appl->Id-1] = GET_DWORD(parms[0].info); - a->CIP_Mask[appl->Id-1] = GET_DWORD(parms[1].info); - dbug(1,dprintf("CIP_MASK=0x%lx",GET_DWORD(parms[1].info))); - if (a->Info_Mask[appl->Id-1] & 0x200){ /* early B3 connect provides */ - a->Info_Mask[appl->Id-1] |= 0x10; /* call progression infos */ - } - - /* check if external controller listen and switch listen on or off*/ - if(Id&EXT_CONTROLLER && GET_DWORD(parms[1].info)){ - if(a->profile.Global_Options & ON_BOARD_CODEC) { - dummy_plci.State = IDLE; - a->codec_listen[appl->Id-1] = &dummy_plci; - a->TelOAD[0] = (byte)(parms[3].length); - for(i=1;parms[3].length>=i && i<22;i++) { - a->TelOAD[i] = parms[3].info[i]; - } - a->TelOAD[i] = 0; - a->TelOSA[0] = (byte)(parms[4].length); - for(i=1;parms[4].length>=i && i<22;i++) { - a->TelOSA[i] = parms[4].info[i]; - } - a->TelOSA[i] = 0; - } - else Info = 0x2002; /* wrong controller, codec not supported */ - } - else{ /* clear listen */ - a->codec_listen[appl->Id-1] = (PLCI *)0; - } - } - sendf(appl, - _LISTEN_R|CONFIRM, - Id, - Number, - "w",Info); - - if (a) listen_check(a); - return false; + word Info; + byte i; + + dbug(1, dprintf("listen_req(Appl=0x%x)", appl->Id)); + + Info = _WRONG_IDENTIFIER; + if (a) { + Info = 0; + a->Info_Mask[appl->Id - 1] = GET_DWORD(parms[0].info); + a->CIP_Mask[appl->Id - 1] = GET_DWORD(parms[1].info); + dbug(1, dprintf("CIP_MASK=0x%lx", GET_DWORD(parms[1].info))); + if (a->Info_Mask[appl->Id - 1] & 0x200) { /* early B3 connect provides */ + a->Info_Mask[appl->Id - 1] |= 0x10; /* call progression infos */ + } + + /* check if external controller listen and switch listen on or off*/ + if (Id&EXT_CONTROLLER && GET_DWORD(parms[1].info)) { + if (a->profile.Global_Options & ON_BOARD_CODEC) { + dummy_plci.State = IDLE; + a->codec_listen[appl->Id - 1] = &dummy_plci; + a->TelOAD[0] = (byte)(parms[3].length); + for (i = 1; parms[3].length >= i && i < 22; i++) { + a->TelOAD[i] = parms[3].info[i]; + } + a->TelOAD[i] = 0; + a->TelOSA[0] = (byte)(parms[4].length); + for (i = 1; parms[4].length >= i && i < 22; i++) { + a->TelOSA[i] = parms[4].info[i]; + } + a->TelOSA[i] = 0; + } + else Info = 0x2002; /* wrong controller, codec not supported */ + } + else{ /* clear listen */ + a->codec_listen[appl->Id - 1] = (PLCI *)0; + } + } + sendf(appl, + _LISTEN_R | CONFIRM, + Id, + Number, + "w", Info); + + if (a) listen_check(a); + return false; } static byte info_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - word i; - API_PARSE * ai; - PLCI * rc_plci = NULL; - API_PARSE ai_parms[5]; - word Info = 0; - - dbug(1,dprintf("info_req")); - for(i=0;i<5;i++) ai_parms[i].length = 0; - - ai = &msg[1]; - - if(ai->length) - { - if(api_parse(&ai->info[1],(word)ai->length,"ssss",ai_parms)) - { - dbug(1,dprintf("AddInfo wrong")); - Info = _WRONG_MESSAGE_FORMAT; - } - } - if(!a) Info = _WRONG_STATE; - - if(!Info && plci) - { /* no fac, with CPN, or KEY */ - rc_plci = plci; - if(!ai_parms[3].length && plci->State && (msg[0].length || ai_parms[1].length) ) - { - /* overlap sending option */ - dbug(1,dprintf("OvlSnd")); - add_s(plci,CPN,&msg[0]); - add_s(plci,KEY,&ai_parms[1]); - sig_req(plci,INFO_REQ,0); - send_req(plci); - return false; - } - - if(plci->State && ai_parms[2].length) - { - /* User_Info option */ - dbug(1,dprintf("UUI")); - add_s(plci,UUI,&ai_parms[2]); - sig_req(plci,USER_DATA,0); - } - else if(plci->State && ai_parms[3].length) - { - /* Facility option */ - dbug(1,dprintf("FAC")); - add_s(plci,CPN,&msg[0]); - add_ai(plci, &msg[1]); - sig_req(plci,FACILITY_REQ,0); - } - else - { - Info = _WRONG_STATE; - } - } - else if((ai_parms[1].length || ai_parms[2].length || ai_parms[3].length) && !Info) - { - /* NCR_Facility option -> send UUI and Keypad too */ - dbug(1,dprintf("NCR_FAC")); - if((i=get_plci(a))) - { - rc_plci = &a->plci[i-1]; - appl->NullCREnable = true; - rc_plci->internal_command = C_NCR_FAC_REQ; - rc_plci->appl = appl; - add_p(rc_plci,CAI,"\x01\x80"); - add_p(rc_plci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rc_plci,ASSIGN,DSIG_ID); - send_req(rc_plci); - } - else - { - Info = _OUT_OF_PLCI; - } - - if(!Info) - { - add_s(rc_plci,CPN,&msg[0]); - add_ai(rc_plci, &msg[1]); - sig_req(rc_plci,NCR_FACILITY,0); - send_req(rc_plci); - return false; - /* for application controlled supplementary services */ - } - } - - if (!rc_plci) - { - Info = _WRONG_MESSAGE_FORMAT; - } - - if(!Info) - { - send_req(rc_plci); - } - else - { /* appl is not assigned to a PLCI or error condition */ - dbug(1,dprintf("localInfoCon")); - sendf(appl, - _INFO_R|CONFIRM, - Id, - Number, - "w",Info); - } - return false; + word i; + API_PARSE *ai; + PLCI *rc_plci = NULL; + API_PARSE ai_parms[5]; + word Info = 0; + + dbug(1, dprintf("info_req")); + for (i = 0; i < 5; i++) ai_parms[i].length = 0; + + ai = &msg[1]; + + if (ai->length) + { + if (api_parse(&ai->info[1], (word)ai->length, "ssss", ai_parms)) + { + dbug(1, dprintf("AddInfo wrong")); + Info = _WRONG_MESSAGE_FORMAT; + } + } + if (!a) Info = _WRONG_STATE; + + if (!Info && plci) + { /* no fac, with CPN, or KEY */ + rc_plci = plci; + if (!ai_parms[3].length && plci->State && (msg[0].length || ai_parms[1].length)) + { + /* overlap sending option */ + dbug(1, dprintf("OvlSnd")); + add_s(plci, CPN, &msg[0]); + add_s(plci, KEY, &ai_parms[1]); + sig_req(plci, INFO_REQ, 0); + send_req(plci); + return false; + } + + if (plci->State && ai_parms[2].length) + { + /* User_Info option */ + dbug(1, dprintf("UUI")); + add_s(plci, UUI, &ai_parms[2]); + sig_req(plci, USER_DATA, 0); + } + else if (plci->State && ai_parms[3].length) + { + /* Facility option */ + dbug(1, dprintf("FAC")); + add_s(plci, CPN, &msg[0]); + add_ai(plci, &msg[1]); + sig_req(plci, FACILITY_REQ, 0); + } + else + { + Info = _WRONG_STATE; + } + } + else if ((ai_parms[1].length || ai_parms[2].length || ai_parms[3].length) && !Info) + { + /* NCR_Facility option -> send UUI and Keypad too */ + dbug(1, dprintf("NCR_FAC")); + if ((i = get_plci(a))) + { + rc_plci = &a->plci[i - 1]; + appl->NullCREnable = true; + rc_plci->internal_command = C_NCR_FAC_REQ; + rc_plci->appl = appl; + add_p(rc_plci, CAI, "\x01\x80"); + add_p(rc_plci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rc_plci, ASSIGN, DSIG_ID); + send_req(rc_plci); + } + else + { + Info = _OUT_OF_PLCI; + } + + if (!Info) + { + add_s(rc_plci, CPN, &msg[0]); + add_ai(rc_plci, &msg[1]); + sig_req(rc_plci, NCR_FACILITY, 0); + send_req(rc_plci); + return false; + /* for application controlled supplementary services */ + } + } + + if (!rc_plci) + { + Info = _WRONG_MESSAGE_FORMAT; + } + + if (!Info) + { + send_req(rc_plci); + } + else + { /* appl is not assigned to a PLCI or error condition */ + dbug(1, dprintf("localInfoCon")); + sendf(appl, + _INFO_R | CONFIRM, + Id, + Number, + "w", Info); + } + return false; } static byte info_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - dbug(1,dprintf("info_res")); - return false; + dbug(1, dprintf("info_res")); + return false; } static byte alert_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - word Info; - byte ret; - - dbug(1,dprintf("alert_req")); - - Info = _WRONG_IDENTIFIER; - ret = false; - if(plci) { - Info = _ALERT_IGNORED; - if(plci->State!=INC_CON_ALERT) { - Info = _WRONG_STATE; - if(plci->State==INC_CON_PENDING) { - Info = 0; - plci->State=INC_CON_ALERT; - add_ai(plci, &msg[0]); - sig_req(plci,CALL_ALERT,0); - ret = 1; - } - } - } - sendf(appl, - _ALERT_R|CONFIRM, - Id, - Number, - "w",Info); - return ret; + word Info; + byte ret; + + dbug(1, dprintf("alert_req")); + + Info = _WRONG_IDENTIFIER; + ret = false; + if (plci) { + Info = _ALERT_IGNORED; + if (plci->State != INC_CON_ALERT) { + Info = _WRONG_STATE; + if (plci->State == INC_CON_PENDING) { + Info = 0; + plci->State = INC_CON_ALERT; + add_ai(plci, &msg[0]); + sig_req(plci, CALL_ALERT, 0); + ret = 1; + } + } + } + sendf(appl, + _ALERT_R | CONFIRM, + Id, + Number, + "w", Info); + return ret; } static byte facility_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - word Info = 0; - word i = 0; - - word selector; - word SSreq; - long relatedPLCIvalue; - DIVA_CAPI_ADAPTER * relatedadapter; - byte * SSparms = ""; - byte RCparms[] = "\x05\x00\x00\x02\x00\x00"; - byte SSstruct[] = "\x09\x00\x00\x06\x00\x00\x00\x00\x00\x00"; - API_PARSE * parms; - API_PARSE ss_parms[11]; - PLCI *rplci; - byte cai[15]; - dword d; - API_PARSE dummy; - - dbug(1,dprintf("facility_req")); - for(i=0;i<9;i++) ss_parms[i].length = 0; - - parms = &msg[1]; - - if(!a) - { - dbug(1,dprintf("wrong Ctrl")); - Info = _WRONG_IDENTIFIER; - } - - selector = GET_WORD(msg[0].info); - - if(!Info) - { - switch(selector) - { - case SELECTOR_HANDSET: - Info = AdvCodecSupport(a, plci, appl, HOOK_SUPPORT); - break; - - case SELECTOR_SU_SERV: - if(!msg[1].length) - { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - SSreq = GET_WORD(&(msg[1].info[1])); - PUT_WORD(&RCparms[1],SSreq); - SSparms = RCparms; - switch(SSreq) - { - case S_GET_SUPPORTED_SERVICES: - if((i=get_plci(a))) - { - rplci = &a->plci[i-1]; - rplci->appl = appl; - add_p(rplci,CAI,"\x01\x80"); - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - } - else - { - PUT_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY); - SSparms = (byte *)SSstruct; - break; - } - rplci->internal_command = GETSERV_REQ_PEND; - rplci->number = Number; - rplci->appl = appl; - sig_req(rplci,S_SUPPORTED,0); - send_req(rplci); - return false; - break; - - case S_LISTEN: - if(parms->length==7) - { - if(api_parse(&parms->info[1],(word)parms->length,"wbd",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - } - else - { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - a->Notification_Mask[appl->Id-1] = GET_DWORD(ss_parms[2].info); - if(a->Notification_Mask[appl->Id-1] & SMASK_MWI) /* MWI active? */ - { - if((i=get_plci(a))) - { - rplci = &a->plci[i-1]; - rplci->appl = appl; - add_p(rplci,CAI,"\x01\x80"); - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - } - else - { - break; - } - rplci->internal_command = GET_MWI_STATE; - rplci->number = Number; - sig_req(rplci,MWI_POLL,0); - send_req(rplci); - } - break; - - case S_HOLD: - api_parse(&parms->info[1],(word)parms->length,"ws",ss_parms); - if(plci && plci->State && plci->SuppState==IDLE) - { - plci->SuppState = HOLD_REQUEST; - plci->command = C_HOLD_REQ; - add_s(plci,CAI,&ss_parms[1]); - sig_req(plci,CALL_HOLD,0); - send_req(plci); - return false; - } - else Info = 0x3010; /* wrong state */ - break; - case S_RETRIEVE: - if(plci && plci->State && plci->SuppState==CALL_HELD) - { - if(Id & EXT_CONTROLLER) - { - if(AdvCodecSupport(a, plci, appl, 0)) - { - Info = 0x3010; /* wrong state */ - break; - } - } - else plci->tel = 0; - - plci->SuppState = RETRIEVE_REQUEST; - plci->command = C_RETRIEVE_REQ; - if(plci->spoofed_msg==SPOOFING_REQUIRED) - { - plci->spoofed_msg = CALL_RETRIEVE; - plci->internal_command = BLOCK_PLCI; - plci->command = 0; - dbug(1,dprintf("Spoof")); - return false; - } - else - { - sig_req(plci,CALL_RETRIEVE,0); - send_req(plci); - return false; - } - } - else Info = 0x3010; /* wrong state */ - break; - case S_SUSPEND: - if(parms->length) - { - if(api_parse(&parms->info[1],(word)parms->length,"wbs",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - } - if(plci && plci->State) - { - add_s(plci,CAI,&ss_parms[2]); - plci->command = SUSPEND_REQ; - sig_req(plci,SUSPEND,0); - plci->State = SUSPENDING; - send_req(plci); - } - else Info = 0x3010; /* wrong state */ - break; - - case S_RESUME: - if(!(i=get_plci(a)) ) - { - Info = _OUT_OF_PLCI; - break; - } - rplci = &a->plci[i-1]; - rplci->appl = appl; - rplci->number = Number; - rplci->tel = 0; - rplci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; - /* check 'external controller' bit for codec support */ - if(Id & EXT_CONTROLLER) - { - if(AdvCodecSupport(a, rplci, appl, 0) ) - { - rplci->Id = 0; - Info = 0x300A; - break; - } - } - if(parms->length) - { - if(api_parse(&parms->info[1],(word)parms->length,"wbs",ss_parms)) - { - dbug(1,dprintf("format wrong")); - rplci->Id = 0; - Info = _WRONG_MESSAGE_FORMAT; - break; - } - } - dummy.length = 0; - dummy.info = "\x00"; - add_b1(rplci, &dummy, 0, 0); - if (a->Info_Mask[appl->Id-1] & 0x200) - { - /* early B3 connect (CIP mask bit 9) no release after a disc */ - add_p(rplci,LLI,"\x01\x01"); - } - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - add_s(rplci,CAI,&ss_parms[2]); - rplci->command = RESUME_REQ; - sig_req(rplci,RESUME,0); - rplci->State = RESUMING; - send_req(rplci); - break; - - case S_CONF_BEGIN: /* Request */ - case S_CONF_DROP: - case S_CONF_ISOLATE: - case S_CONF_REATTACH: - if(api_parse(&parms->info[1],(word)parms->length,"wbd",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if(plci && plci->State && ((plci->SuppState==IDLE)||(plci->SuppState==CALL_HELD))) - { - d = GET_DWORD(ss_parms[2].info); - if(d>=0x80) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - plci->ptyState = (byte)SSreq; - plci->command = 0; - cai[0] = 2; - switch(SSreq) - { - case S_CONF_BEGIN: - cai[1] = CONF_BEGIN; - plci->internal_command = CONF_BEGIN_REQ_PEND; - break; - case S_CONF_DROP: - cai[1] = CONF_DROP; - plci->internal_command = CONF_DROP_REQ_PEND; - break; - case S_CONF_ISOLATE: - cai[1] = CONF_ISOLATE; - plci->internal_command = CONF_ISOLATE_REQ_PEND; - break; - case S_CONF_REATTACH: - cai[1] = CONF_REATTACH; - plci->internal_command = CONF_REATTACH_REQ_PEND; - break; - } - cai[2] = (byte)d; /* Conference Size resp. PartyId */ - add_p(plci,CAI,cai); - sig_req(plci,S_SERVICE,0); - send_req(plci); - return false; - } - else Info = 0x3010; /* wrong state */ - break; - - case S_ECT: - case S_3PTY_BEGIN: - case S_3PTY_END: - case S_CONF_ADD: - if(parms->length==7) - { - if(api_parse(&parms->info[1],(word)parms->length,"wbd",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - } - else if(parms->length==8) /* workaround for the T-View-S */ - { - if(api_parse(&parms->info[1],(word)parms->length,"wbdb",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - } - else - { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if(!msg[1].length) - { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if (!plci) - { - Info = _WRONG_IDENTIFIER; - break; - } - relatedPLCIvalue = GET_DWORD(ss_parms[2].info); - relatedPLCIvalue &= 0x0000FFFF; - dbug(1,dprintf("PTY/ECT/addCONF,relPLCI=%lx",relatedPLCIvalue)); - /* controller starts with 0 up to (max_adapter - 1) */ - if (((relatedPLCIvalue & 0x7f) == 0) - || (MapController ((byte)(relatedPLCIvalue & 0x7f)) == 0) - || (MapController ((byte)(relatedPLCIvalue & 0x7f)) > max_adapter)) - { - if(SSreq==S_3PTY_END) - { - dbug(1, dprintf("wrong Controller use 2nd PLCI=PLCI")); - rplci = plci; - } - else - { - Info = 0x3010; /* wrong state */ - break; - } - } - else - { - relatedadapter = &adapter[MapController ((byte)(relatedPLCIvalue & 0x7f))-1]; - relatedPLCIvalue >>=8; - /* find PLCI PTR*/ - for(i=0,rplci=NULL;imax_plci;i++) - { - if(relatedadapter->plci[i].Id == (byte)relatedPLCIvalue) - { - rplci = &relatedadapter->plci[i]; - } - } - if(!rplci || !relatedPLCIvalue) - { - if(SSreq==S_3PTY_END) - { - dbug(1, dprintf("use 2nd PLCI=PLCI")); - rplci = plci; - } - else - { - Info = 0x3010; /* wrong state */ - break; - } - } - } + word Info = 0; + word i = 0; + + word selector; + word SSreq; + long relatedPLCIvalue; + DIVA_CAPI_ADAPTER *relatedadapter; + byte *SSparms = ""; + byte RCparms[] = "\x05\x00\x00\x02\x00\x00"; + byte SSstruct[] = "\x09\x00\x00\x06\x00\x00\x00\x00\x00\x00"; + API_PARSE *parms; + API_PARSE ss_parms[11]; + PLCI *rplci; + byte cai[15]; + dword d; + API_PARSE dummy; + + dbug(1, dprintf("facility_req")); + for (i = 0; i < 9; i++) ss_parms[i].length = 0; + + parms = &msg[1]; + + if (!a) + { + dbug(1, dprintf("wrong Ctrl")); + Info = _WRONG_IDENTIFIER; + } + + selector = GET_WORD(msg[0].info); + + if (!Info) + { + switch (selector) + { + case SELECTOR_HANDSET: + Info = AdvCodecSupport(a, plci, appl, HOOK_SUPPORT); + break; + + case SELECTOR_SU_SERV: + if (!msg[1].length) + { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + SSreq = GET_WORD(&(msg[1].info[1])); + PUT_WORD(&RCparms[1], SSreq); + SSparms = RCparms; + switch (SSreq) + { + case S_GET_SUPPORTED_SERVICES: + if ((i = get_plci(a))) + { + rplci = &a->plci[i - 1]; + rplci->appl = appl; + add_p(rplci, CAI, "\x01\x80"); + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + } + else + { + PUT_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY); + SSparms = (byte *)SSstruct; + break; + } + rplci->internal_command = GETSERV_REQ_PEND; + rplci->number = Number; + rplci->appl = appl; + sig_req(rplci, S_SUPPORTED, 0); + send_req(rplci); + return false; + break; + + case S_LISTEN: + if (parms->length == 7) + { + if (api_parse(&parms->info[1], (word)parms->length, "wbd", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + } + else + { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + a->Notification_Mask[appl->Id - 1] = GET_DWORD(ss_parms[2].info); + if (a->Notification_Mask[appl->Id - 1] & SMASK_MWI) /* MWI active? */ + { + if ((i = get_plci(a))) + { + rplci = &a->plci[i - 1]; + rplci->appl = appl; + add_p(rplci, CAI, "\x01\x80"); + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + } + else + { + break; + } + rplci->internal_command = GET_MWI_STATE; + rplci->number = Number; + sig_req(rplci, MWI_POLL, 0); + send_req(rplci); + } + break; + + case S_HOLD: + api_parse(&parms->info[1], (word)parms->length, "ws", ss_parms); + if (plci && plci->State && plci->SuppState == IDLE) + { + plci->SuppState = HOLD_REQUEST; + plci->command = C_HOLD_REQ; + add_s(plci, CAI, &ss_parms[1]); + sig_req(plci, CALL_HOLD, 0); + send_req(plci); + return false; + } + else Info = 0x3010; /* wrong state */ + break; + case S_RETRIEVE: + if (plci && plci->State && plci->SuppState == CALL_HELD) + { + if (Id & EXT_CONTROLLER) + { + if (AdvCodecSupport(a, plci, appl, 0)) + { + Info = 0x3010; /* wrong state */ + break; + } + } + else plci->tel = 0; + + plci->SuppState = RETRIEVE_REQUEST; + plci->command = C_RETRIEVE_REQ; + if (plci->spoofed_msg == SPOOFING_REQUIRED) + { + plci->spoofed_msg = CALL_RETRIEVE; + plci->internal_command = BLOCK_PLCI; + plci->command = 0; + dbug(1, dprintf("Spoof")); + return false; + } + else + { + sig_req(plci, CALL_RETRIEVE, 0); + send_req(plci); + return false; + } + } + else Info = 0x3010; /* wrong state */ + break; + case S_SUSPEND: + if (parms->length) + { + if (api_parse(&parms->info[1], (word)parms->length, "wbs", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + } + if (plci && plci->State) + { + add_s(plci, CAI, &ss_parms[2]); + plci->command = SUSPEND_REQ; + sig_req(plci, SUSPEND, 0); + plci->State = SUSPENDING; + send_req(plci); + } + else Info = 0x3010; /* wrong state */ + break; + + case S_RESUME: + if (!(i = get_plci(a))) + { + Info = _OUT_OF_PLCI; + break; + } + rplci = &a->plci[i - 1]; + rplci->appl = appl; + rplci->number = Number; + rplci->tel = 0; + rplci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; + /* check 'external controller' bit for codec support */ + if (Id & EXT_CONTROLLER) + { + if (AdvCodecSupport(a, rplci, appl, 0)) + { + rplci->Id = 0; + Info = 0x300A; + break; + } + } + if (parms->length) + { + if (api_parse(&parms->info[1], (word)parms->length, "wbs", ss_parms)) + { + dbug(1, dprintf("format wrong")); + rplci->Id = 0; + Info = _WRONG_MESSAGE_FORMAT; + break; + } + } + dummy.length = 0; + dummy.info = "\x00"; + add_b1(rplci, &dummy, 0, 0); + if (a->Info_Mask[appl->Id - 1] & 0x200) + { + /* early B3 connect (CIP mask bit 9) no release after a disc */ + add_p(rplci, LLI, "\x01\x01"); + } + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + add_s(rplci, CAI, &ss_parms[2]); + rplci->command = RESUME_REQ; + sig_req(rplci, RESUME, 0); + rplci->State = RESUMING; + send_req(rplci); + break; + + case S_CONF_BEGIN: /* Request */ + case S_CONF_DROP: + case S_CONF_ISOLATE: + case S_CONF_REATTACH: + if (api_parse(&parms->info[1], (word)parms->length, "wbd", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (plci && plci->State && ((plci->SuppState == IDLE) || (plci->SuppState == CALL_HELD))) + { + d = GET_DWORD(ss_parms[2].info); + if (d >= 0x80) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + plci->ptyState = (byte)SSreq; + plci->command = 0; + cai[0] = 2; + switch (SSreq) + { + case S_CONF_BEGIN: + cai[1] = CONF_BEGIN; + plci->internal_command = CONF_BEGIN_REQ_PEND; + break; + case S_CONF_DROP: + cai[1] = CONF_DROP; + plci->internal_command = CONF_DROP_REQ_PEND; + break; + case S_CONF_ISOLATE: + cai[1] = CONF_ISOLATE; + plci->internal_command = CONF_ISOLATE_REQ_PEND; + break; + case S_CONF_REATTACH: + cai[1] = CONF_REATTACH; + plci->internal_command = CONF_REATTACH_REQ_PEND; + break; + } + cai[2] = (byte)d; /* Conference Size resp. PartyId */ + add_p(plci, CAI, cai); + sig_req(plci, S_SERVICE, 0); + send_req(plci); + return false; + } + else Info = 0x3010; /* wrong state */ + break; + + case S_ECT: + case S_3PTY_BEGIN: + case S_3PTY_END: + case S_CONF_ADD: + if (parms->length == 7) + { + if (api_parse(&parms->info[1], (word)parms->length, "wbd", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + } + else if (parms->length == 8) /* workaround for the T-View-S */ + { + if (api_parse(&parms->info[1], (word)parms->length, "wbdb", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + } + else + { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (!msg[1].length) + { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (!plci) + { + Info = _WRONG_IDENTIFIER; + break; + } + relatedPLCIvalue = GET_DWORD(ss_parms[2].info); + relatedPLCIvalue &= 0x0000FFFF; + dbug(1, dprintf("PTY/ECT/addCONF,relPLCI=%lx", relatedPLCIvalue)); + /* controller starts with 0 up to (max_adapter - 1) */ + if (((relatedPLCIvalue & 0x7f) == 0) + || (MapController((byte)(relatedPLCIvalue & 0x7f)) == 0) + || (MapController((byte)(relatedPLCIvalue & 0x7f)) > max_adapter)) + { + if (SSreq == S_3PTY_END) + { + dbug(1, dprintf("wrong Controller use 2nd PLCI=PLCI")); + rplci = plci; + } + else + { + Info = 0x3010; /* wrong state */ + break; + } + } + else + { + relatedadapter = &adapter[MapController((byte)(relatedPLCIvalue & 0x7f)) - 1]; + relatedPLCIvalue >>= 8; + /* find PLCI PTR*/ + for (i = 0, rplci = NULL; i < relatedadapter->max_plci; i++) + { + if (relatedadapter->plci[i].Id == (byte)relatedPLCIvalue) + { + rplci = &relatedadapter->plci[i]; + } + } + if (!rplci || !relatedPLCIvalue) + { + if (SSreq == S_3PTY_END) + { + dbug(1, dprintf("use 2nd PLCI=PLCI")); + rplci = plci; + } + else + { + Info = 0x3010; /* wrong state */ + break; + } + } + } /* - dbug(1,dprintf("rplci:%x",rplci)); - dbug(1,dprintf("plci:%x",plci)); - dbug(1,dprintf("rplci->ptyState:%x",rplci->ptyState)); - dbug(1,dprintf("plci->ptyState:%x",plci->ptyState)); - dbug(1,dprintf("SSreq:%x",SSreq)); - dbug(1,dprintf("rplci->internal_command:%x",rplci->internal_command)); - dbug(1,dprintf("rplci->appl:%x",rplci->appl)); - dbug(1,dprintf("rplci->Id:%x",rplci->Id)); + dbug(1, dprintf("rplci:%x", rplci)); + dbug(1, dprintf("plci:%x", plci)); + dbug(1, dprintf("rplci->ptyState:%x", rplci->ptyState)); + dbug(1, dprintf("plci->ptyState:%x", plci->ptyState)); + dbug(1, dprintf("SSreq:%x", SSreq)); + dbug(1, dprintf("rplci->internal_command:%x", rplci->internal_command)); + dbug(1, dprintf("rplci->appl:%x", rplci->appl)); + dbug(1, dprintf("rplci->Id:%x", rplci->Id)); */ - /* send PTY/ECT req, cannot check all states because of US stuff */ - if( !rplci->internal_command && rplci->appl ) - { - plci->command = 0; - rplci->relatedPTYPLCI = plci; - plci->relatedPTYPLCI = rplci; - rplci->ptyState = (byte)SSreq; - if(SSreq==S_ECT) - { - rplci->internal_command = ECT_REQ_PEND; - cai[1] = ECT_EXECUTE; - - rplci->vswitchstate=0; - rplci->vsprot=0; - rplci->vsprotdialect=0; - plci->vswitchstate=0; - plci->vsprot=0; - plci->vsprotdialect=0; - - } - else if(SSreq==S_CONF_ADD) - { - rplci->internal_command = CONF_ADD_REQ_PEND; - cai[1] = CONF_ADD; - } - else - { - rplci->internal_command = PTY_REQ_PEND; - cai[1] = (byte)(SSreq-3); - } - rplci->number = Number; - if(plci!=rplci) /* explicit invocation */ - { - cai[0] = 2; - cai[2] = plci->Sig.Id; - dbug(1,dprintf("explicit invocation")); - } - else - { - dbug(1,dprintf("implicit invocation")); - cai[0] = 1; - } - add_p(rplci,CAI,cai); - sig_req(rplci,S_SERVICE,0); - send_req(rplci); - return false; - } - else - { - dbug(0,dprintf("Wrong line")); - Info = 0x3010; /* wrong state */ - break; - } - break; - - case S_CALL_DEFLECTION: - if(api_parse(&parms->info[1],(word)parms->length,"wbwss",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if (!plci) - { - Info = _WRONG_IDENTIFIER; - break; - } - /* reuse unused screening indicator */ - ss_parms[3].info[3] = (byte)GET_WORD(&(ss_parms[2].info[0])); - plci->command = 0; - plci->internal_command = CD_REQ_PEND; - appl->CDEnable = true; - cai[0] = 1; - cai[1] = CALL_DEFLECTION; - add_p(plci,CAI,cai); - add_p(plci,CPN,ss_parms[3].info); - sig_req(plci,S_SERVICE,0); - send_req(plci); - return false; - break; - - case S_CALL_FORWARDING_START: - if(api_parse(&parms->info[1],(word)parms->length,"wbdwwsss",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - - if((i=get_plci(a))) - { - rplci = &a->plci[i-1]; - rplci->appl = appl; - add_p(rplci,CAI,"\x01\x80"); - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - } - else - { - Info = _OUT_OF_PLCI; - break; - } - - /* reuse unused screening indicator */ - rplci->internal_command = CF_START_PEND; - rplci->appl = appl; - rplci->number = Number; - appl->S_Handle = GET_DWORD(&(ss_parms[2].info[0])); - cai[0] = 2; - cai[1] = 0x70|(byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */ - cai[2] = (byte)GET_WORD(&(ss_parms[4].info[0])); /* Basic Service */ - add_p(rplci,CAI,cai); - add_p(rplci,OAD,ss_parms[5].info); - add_p(rplci,CPN,ss_parms[6].info); - sig_req(rplci,S_SERVICE,0); - send_req(rplci); - return false; - break; - - case S_INTERROGATE_DIVERSION: - case S_INTERROGATE_NUMBERS: - case S_CALL_FORWARDING_STOP: - case S_CCBS_REQUEST: - case S_CCBS_DEACTIVATE: - case S_CCBS_INTERROGATE: - switch(SSreq) - { - case S_INTERROGATE_NUMBERS: - if(api_parse(&parms->info[1],(word)parms->length,"wbd",ss_parms)) - { - dbug(0,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - } - break; - case S_CCBS_REQUEST: - case S_CCBS_DEACTIVATE: - if(api_parse(&parms->info[1],(word)parms->length,"wbdw",ss_parms)) - { - dbug(0,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - } - break; - case S_CCBS_INTERROGATE: - if(api_parse(&parms->info[1],(word)parms->length,"wbdws",ss_parms)) - { - dbug(0,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - } - break; - default: - if(api_parse(&parms->info[1],(word)parms->length,"wbdwws",ss_parms)) - { - dbug(0,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - break; - } - - if(Info) break; - if((i=get_plci(a))) - { - rplci = &a->plci[i-1]; - switch(SSreq) - { - case S_INTERROGATE_DIVERSION: /* use cai with S_SERVICE below */ - cai[1] = 0x60|(byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */ - rplci->internal_command = INTERR_DIVERSION_REQ_PEND; /* move to rplci if assigned */ - break; - case S_INTERROGATE_NUMBERS: /* use cai with S_SERVICE below */ - cai[1] = DIVERSION_INTERROGATE_NUM; /* Function */ - rplci->internal_command = INTERR_NUMBERS_REQ_PEND; /* move to rplci if assigned */ - break; - case S_CALL_FORWARDING_STOP: - rplci->internal_command = CF_STOP_PEND; - cai[1] = 0x80|(byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */ - break; - case S_CCBS_REQUEST: - cai[1] = CCBS_REQUEST; - rplci->internal_command = CCBS_REQUEST_REQ_PEND; - break; - case S_CCBS_DEACTIVATE: - cai[1] = CCBS_DEACTIVATE; - rplci->internal_command = CCBS_DEACTIVATE_REQ_PEND; - break; - case S_CCBS_INTERROGATE: - cai[1] = CCBS_INTERROGATE; - rplci->internal_command = CCBS_INTERROGATE_REQ_PEND; - break; - default: - cai[1] = 0; - break; - } - rplci->appl = appl; - rplci->number = Number; - add_p(rplci,CAI,"\x01\x80"); - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - } - else - { - Info = _OUT_OF_PLCI; - break; - } - - appl->S_Handle = GET_DWORD(&(ss_parms[2].info[0])); - switch(SSreq) - { - case S_INTERROGATE_NUMBERS: - cai[0] = 1; - add_p(rplci,CAI,cai); - break; - case S_CCBS_REQUEST: - case S_CCBS_DEACTIVATE: - cai[0] = 3; - PUT_WORD(&cai[2],GET_WORD(&(ss_parms[3].info[0]))); - add_p(rplci,CAI,cai); - break; - case S_CCBS_INTERROGATE: - cai[0] = 3; - PUT_WORD(&cai[2],GET_WORD(&(ss_parms[3].info[0]))); - add_p(rplci,CAI,cai); - add_p(rplci,OAD,ss_parms[4].info); - break; - default: - cai[0] = 2; - cai[2] = (byte)GET_WORD(&(ss_parms[4].info[0])); /* Basic Service */ - add_p(rplci,CAI,cai); - add_p(rplci,OAD,ss_parms[5].info); - break; - } - - sig_req(rplci,S_SERVICE,0); - send_req(rplci); - return false; - break; - - case S_MWI_ACTIVATE: - if(api_parse(&parms->info[1],(word)parms->length,"wbwdwwwssss",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if(!plci) - { - if((i=get_plci(a))) - { - rplci = &a->plci[i-1]; - rplci->appl = appl; - rplci->cr_enquiry=true; - add_p(rplci,CAI,"\x01\x80"); - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - } - else - { - Info = _OUT_OF_PLCI; - break; - } - } - else - { - rplci = plci; - rplci->cr_enquiry=false; - } - - rplci->command = 0; - rplci->internal_command = MWI_ACTIVATE_REQ_PEND; - rplci->appl = appl; - rplci->number = Number; - - cai[0] = 13; - cai[1] = ACTIVATION_MWI; /* Function */ - PUT_WORD(&cai[2],GET_WORD(&(ss_parms[2].info[0]))); /* Basic Service */ - PUT_DWORD(&cai[4],GET_DWORD(&(ss_parms[3].info[0]))); /* Number of Messages */ - PUT_WORD(&cai[8],GET_WORD(&(ss_parms[4].info[0]))); /* Message Status */ - PUT_WORD(&cai[10],GET_WORD(&(ss_parms[5].info[0]))); /* Message Reference */ - PUT_WORD(&cai[12],GET_WORD(&(ss_parms[6].info[0]))); /* Invocation Mode */ - add_p(rplci,CAI,cai); - add_p(rplci,CPN,ss_parms[7].info); /* Receiving User Number */ - add_p(rplci,OAD,ss_parms[8].info); /* Controlling User Number */ - add_p(rplci,OSA,ss_parms[9].info); /* Controlling User Provided Number */ - add_p(rplci,UID,ss_parms[10].info); /* Time */ - sig_req(rplci,S_SERVICE,0); - send_req(rplci); - return false; - - case S_MWI_DEACTIVATE: - if(api_parse(&parms->info[1],(word)parms->length,"wbwwss",ss_parms)) - { - dbug(1,dprintf("format wrong")); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if(!plci) - { - if((i=get_plci(a))) - { - rplci = &a->plci[i-1]; - rplci->appl = appl; - rplci->cr_enquiry=true; - add_p(rplci,CAI,"\x01\x80"); - add_p(rplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(rplci,ASSIGN,DSIG_ID); - send_req(rplci); - } - else - { - Info = _OUT_OF_PLCI; - break; - } - } - else - { - rplci = plci; - rplci->cr_enquiry=false; - } - - rplci->command = 0; - rplci->internal_command = MWI_DEACTIVATE_REQ_PEND; - rplci->appl = appl; - rplci->number = Number; - - cai[0] = 5; - cai[1] = DEACTIVATION_MWI; /* Function */ - PUT_WORD(&cai[2],GET_WORD(&(ss_parms[2].info[0]))); /* Basic Service */ - PUT_WORD(&cai[4],GET_WORD(&(ss_parms[3].info[0]))); /* Invocation Mode */ - add_p(rplci,CAI,cai); - add_p(rplci,CPN,ss_parms[4].info); /* Receiving User Number */ - add_p(rplci,OAD,ss_parms[5].info); /* Controlling User Number */ - sig_req(rplci,S_SERVICE,0); - send_req(rplci); - return false; - - default: - Info = 0x300E; /* not supported */ - break; - } - break; /* case SELECTOR_SU_SERV: end */ - - - case SELECTOR_DTMF: - return (dtmf_request (Id, Number, a, plci, appl, msg)); - - - - case SELECTOR_LINE_INTERCONNECT: - return (mixer_request (Id, Number, a, plci, appl, msg)); - - - - case PRIV_SELECTOR_ECHO_CANCELLER: - appl->appl_flags |= APPL_FLAG_PRIV_EC_SPEC; - return (ec_request (Id, Number, a, plci, appl, msg)); - - case SELECTOR_ECHO_CANCELLER: - appl->appl_flags &= ~APPL_FLAG_PRIV_EC_SPEC; - return (ec_request (Id, Number, a, plci, appl, msg)); - - - case SELECTOR_V42BIS: - default: - Info = _FACILITY_NOT_SUPPORTED; - break; - } /* end of switch(selector) */ - } - - dbug(1,dprintf("SendFacRc")); - sendf(appl, - _FACILITY_R|CONFIRM, - Id, - Number, - "wws",Info,selector,SSparms); - return false; + /* send PTY/ECT req, cannot check all states because of US stuff */ + if (!rplci->internal_command && rplci->appl) + { + plci->command = 0; + rplci->relatedPTYPLCI = plci; + plci->relatedPTYPLCI = rplci; + rplci->ptyState = (byte)SSreq; + if (SSreq == S_ECT) + { + rplci->internal_command = ECT_REQ_PEND; + cai[1] = ECT_EXECUTE; + + rplci->vswitchstate = 0; + rplci->vsprot = 0; + rplci->vsprotdialect = 0; + plci->vswitchstate = 0; + plci->vsprot = 0; + plci->vsprotdialect = 0; + + } + else if (SSreq == S_CONF_ADD) + { + rplci->internal_command = CONF_ADD_REQ_PEND; + cai[1] = CONF_ADD; + } + else + { + rplci->internal_command = PTY_REQ_PEND; + cai[1] = (byte)(SSreq - 3); + } + rplci->number = Number; + if (plci != rplci) /* explicit invocation */ + { + cai[0] = 2; + cai[2] = plci->Sig.Id; + dbug(1, dprintf("explicit invocation")); + } + else + { + dbug(1, dprintf("implicit invocation")); + cai[0] = 1; + } + add_p(rplci, CAI, cai); + sig_req(rplci, S_SERVICE, 0); + send_req(rplci); + return false; + } + else + { + dbug(0, dprintf("Wrong line")); + Info = 0x3010; /* wrong state */ + break; + } + break; + + case S_CALL_DEFLECTION: + if (api_parse(&parms->info[1], (word)parms->length, "wbwss", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (!plci) + { + Info = _WRONG_IDENTIFIER; + break; + } + /* reuse unused screening indicator */ + ss_parms[3].info[3] = (byte)GET_WORD(&(ss_parms[2].info[0])); + plci->command = 0; + plci->internal_command = CD_REQ_PEND; + appl->CDEnable = true; + cai[0] = 1; + cai[1] = CALL_DEFLECTION; + add_p(plci, CAI, cai); + add_p(plci, CPN, ss_parms[3].info); + sig_req(plci, S_SERVICE, 0); + send_req(plci); + return false; + break; + + case S_CALL_FORWARDING_START: + if (api_parse(&parms->info[1], (word)parms->length, "wbdwwsss", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + + if ((i = get_plci(a))) + { + rplci = &a->plci[i - 1]; + rplci->appl = appl; + add_p(rplci, CAI, "\x01\x80"); + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + } + else + { + Info = _OUT_OF_PLCI; + break; + } + + /* reuse unused screening indicator */ + rplci->internal_command = CF_START_PEND; + rplci->appl = appl; + rplci->number = Number; + appl->S_Handle = GET_DWORD(&(ss_parms[2].info[0])); + cai[0] = 2; + cai[1] = 0x70 | (byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */ + cai[2] = (byte)GET_WORD(&(ss_parms[4].info[0])); /* Basic Service */ + add_p(rplci, CAI, cai); + add_p(rplci, OAD, ss_parms[5].info); + add_p(rplci, CPN, ss_parms[6].info); + sig_req(rplci, S_SERVICE, 0); + send_req(rplci); + return false; + break; + + case S_INTERROGATE_DIVERSION: + case S_INTERROGATE_NUMBERS: + case S_CALL_FORWARDING_STOP: + case S_CCBS_REQUEST: + case S_CCBS_DEACTIVATE: + case S_CCBS_INTERROGATE: + switch (SSreq) + { + case S_INTERROGATE_NUMBERS: + if (api_parse(&parms->info[1], (word)parms->length, "wbd", ss_parms)) + { + dbug(0, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + } + break; + case S_CCBS_REQUEST: + case S_CCBS_DEACTIVATE: + if (api_parse(&parms->info[1], (word)parms->length, "wbdw", ss_parms)) + { + dbug(0, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + } + break; + case S_CCBS_INTERROGATE: + if (api_parse(&parms->info[1], (word)parms->length, "wbdws", ss_parms)) + { + dbug(0, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + } + break; + default: + if (api_parse(&parms->info[1], (word)parms->length, "wbdwws", ss_parms)) + { + dbug(0, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + break; + } + + if (Info) break; + if ((i = get_plci(a))) + { + rplci = &a->plci[i - 1]; + switch (SSreq) + { + case S_INTERROGATE_DIVERSION: /* use cai with S_SERVICE below */ + cai[1] = 0x60 | (byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */ + rplci->internal_command = INTERR_DIVERSION_REQ_PEND; /* move to rplci if assigned */ + break; + case S_INTERROGATE_NUMBERS: /* use cai with S_SERVICE below */ + cai[1] = DIVERSION_INTERROGATE_NUM; /* Function */ + rplci->internal_command = INTERR_NUMBERS_REQ_PEND; /* move to rplci if assigned */ + break; + case S_CALL_FORWARDING_STOP: + rplci->internal_command = CF_STOP_PEND; + cai[1] = 0x80 | (byte)GET_WORD(&(ss_parms[3].info[0])); /* Function */ + break; + case S_CCBS_REQUEST: + cai[1] = CCBS_REQUEST; + rplci->internal_command = CCBS_REQUEST_REQ_PEND; + break; + case S_CCBS_DEACTIVATE: + cai[1] = CCBS_DEACTIVATE; + rplci->internal_command = CCBS_DEACTIVATE_REQ_PEND; + break; + case S_CCBS_INTERROGATE: + cai[1] = CCBS_INTERROGATE; + rplci->internal_command = CCBS_INTERROGATE_REQ_PEND; + break; + default: + cai[1] = 0; + break; + } + rplci->appl = appl; + rplci->number = Number; + add_p(rplci, CAI, "\x01\x80"); + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + } + else + { + Info = _OUT_OF_PLCI; + break; + } + + appl->S_Handle = GET_DWORD(&(ss_parms[2].info[0])); + switch (SSreq) + { + case S_INTERROGATE_NUMBERS: + cai[0] = 1; + add_p(rplci, CAI, cai); + break; + case S_CCBS_REQUEST: + case S_CCBS_DEACTIVATE: + cai[0] = 3; + PUT_WORD(&cai[2], GET_WORD(&(ss_parms[3].info[0]))); + add_p(rplci, CAI, cai); + break; + case S_CCBS_INTERROGATE: + cai[0] = 3; + PUT_WORD(&cai[2], GET_WORD(&(ss_parms[3].info[0]))); + add_p(rplci, CAI, cai); + add_p(rplci, OAD, ss_parms[4].info); + break; + default: + cai[0] = 2; + cai[2] = (byte)GET_WORD(&(ss_parms[4].info[0])); /* Basic Service */ + add_p(rplci, CAI, cai); + add_p(rplci, OAD, ss_parms[5].info); + break; + } + + sig_req(rplci, S_SERVICE, 0); + send_req(rplci); + return false; + break; + + case S_MWI_ACTIVATE: + if (api_parse(&parms->info[1], (word)parms->length, "wbwdwwwssss", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (!plci) + { + if ((i = get_plci(a))) + { + rplci = &a->plci[i - 1]; + rplci->appl = appl; + rplci->cr_enquiry = true; + add_p(rplci, CAI, "\x01\x80"); + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + } + else + { + Info = _OUT_OF_PLCI; + break; + } + } + else + { + rplci = plci; + rplci->cr_enquiry = false; + } + + rplci->command = 0; + rplci->internal_command = MWI_ACTIVATE_REQ_PEND; + rplci->appl = appl; + rplci->number = Number; + + cai[0] = 13; + cai[1] = ACTIVATION_MWI; /* Function */ + PUT_WORD(&cai[2], GET_WORD(&(ss_parms[2].info[0]))); /* Basic Service */ + PUT_DWORD(&cai[4], GET_DWORD(&(ss_parms[3].info[0]))); /* Number of Messages */ + PUT_WORD(&cai[8], GET_WORD(&(ss_parms[4].info[0]))); /* Message Status */ + PUT_WORD(&cai[10], GET_WORD(&(ss_parms[5].info[0]))); /* Message Reference */ + PUT_WORD(&cai[12], GET_WORD(&(ss_parms[6].info[0]))); /* Invocation Mode */ + add_p(rplci, CAI, cai); + add_p(rplci, CPN, ss_parms[7].info); /* Receiving User Number */ + add_p(rplci, OAD, ss_parms[8].info); /* Controlling User Number */ + add_p(rplci, OSA, ss_parms[9].info); /* Controlling User Provided Number */ + add_p(rplci, UID, ss_parms[10].info); /* Time */ + sig_req(rplci, S_SERVICE, 0); + send_req(rplci); + return false; + + case S_MWI_DEACTIVATE: + if (api_parse(&parms->info[1], (word)parms->length, "wbwwss", ss_parms)) + { + dbug(1, dprintf("format wrong")); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (!plci) + { + if ((i = get_plci(a))) + { + rplci = &a->plci[i - 1]; + rplci->appl = appl; + rplci->cr_enquiry = true; + add_p(rplci, CAI, "\x01\x80"); + add_p(rplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(rplci, ASSIGN, DSIG_ID); + send_req(rplci); + } + else + { + Info = _OUT_OF_PLCI; + break; + } + } + else + { + rplci = plci; + rplci->cr_enquiry = false; + } + + rplci->command = 0; + rplci->internal_command = MWI_DEACTIVATE_REQ_PEND; + rplci->appl = appl; + rplci->number = Number; + + cai[0] = 5; + cai[1] = DEACTIVATION_MWI; /* Function */ + PUT_WORD(&cai[2], GET_WORD(&(ss_parms[2].info[0]))); /* Basic Service */ + PUT_WORD(&cai[4], GET_WORD(&(ss_parms[3].info[0]))); /* Invocation Mode */ + add_p(rplci, CAI, cai); + add_p(rplci, CPN, ss_parms[4].info); /* Receiving User Number */ + add_p(rplci, OAD, ss_parms[5].info); /* Controlling User Number */ + sig_req(rplci, S_SERVICE, 0); + send_req(rplci); + return false; + + default: + Info = 0x300E; /* not supported */ + break; + } + break; /* case SELECTOR_SU_SERV: end */ + + + case SELECTOR_DTMF: + return (dtmf_request(Id, Number, a, plci, appl, msg)); + + + + case SELECTOR_LINE_INTERCONNECT: + return (mixer_request(Id, Number, a, plci, appl, msg)); + + + + case PRIV_SELECTOR_ECHO_CANCELLER: + appl->appl_flags |= APPL_FLAG_PRIV_EC_SPEC; + return (ec_request(Id, Number, a, plci, appl, msg)); + + case SELECTOR_ECHO_CANCELLER: + appl->appl_flags &= ~APPL_FLAG_PRIV_EC_SPEC; + return (ec_request(Id, Number, a, plci, appl, msg)); + + + case SELECTOR_V42BIS: + default: + Info = _FACILITY_NOT_SUPPORTED; + break; + } /* end of switch (selector) */ + } + + dbug(1, dprintf("SendFacRc")); + sendf(appl, + _FACILITY_R | CONFIRM, + Id, + Number, + "wws", Info, selector, SSparms); + return false; } static byte facility_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - dbug(1,dprintf("facility_res")); - return false; + dbug(1, dprintf("facility_res")); + return false; } static byte connect_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word Info = 0; - byte req; - byte len; - word w; - word fax_control_bits, fax_feature_bits, fax_info_change; - API_PARSE * ncpi; - byte pvc[2]; - - API_PARSE fax_parms[9]; - word i; - - - dbug(1,dprintf("connect_b3_req")); - if(plci) - { - if ((plci->State == IDLE) || (plci->State == OUTG_DIS_PENDING) - || (plci->State == INC_DIS_PENDING) || (plci->SuppState != IDLE)) - { - Info = _WRONG_STATE; - } - else - { - /* local reply if assign unsuccessful - or B3 protocol allows only one layer 3 connection - and already connected - or B2 protocol not any LAPD - and connect_b3_req contradicts originate/answer direction */ - if (!plci->NL.Id - || (((plci->B3_prot != B3_T90NL) && (plci->B3_prot != B3_ISO8208) && (plci->B3_prot != B3_X25_DCE)) - && ((plci->channels != 0) - || (((plci->B2_prot != B2_SDLC) && (plci->B2_prot != B2_LAPD) && (plci->B2_prot != B2_LAPD_FREE_SAPI_SEL)) - && ((plci->call_dir & CALL_DIR_ANSWER) && !(plci->call_dir & CALL_DIR_FORCE_OUTG_NL)))))) - { - dbug(1,dprintf("B3 already connected=%d or no NL.Id=0x%x, dir=%d sstate=0x%x", - plci->channels,plci->NL.Id,plci->call_dir,plci->SuppState)); - Info = _WRONG_STATE; - sendf(appl, - _CONNECT_B3_R|CONFIRM, - Id, - Number, - "w",Info); - return false; - } - plci->requested_options_conn = 0; - - req = N_CONNECT; - ncpi = &parms[0]; - if(plci->B3_prot==2 || plci->B3_prot==3) - { - if(ncpi->length>2) - { - /* check for PVC */ - if(ncpi->info[2] || ncpi->info[3]) - { - pvc[0] = ncpi->info[3]; - pvc[1] = ncpi->info[2]; - add_d(plci,2,pvc); - req = N_RESET; - } - else - { - if(ncpi->info[1] &1) req = N_CONNECT | N_D_BIT; - add_d(plci,(word)(ncpi->length-3),&ncpi->info[4]); - } - } - } - else if(plci->B3_prot==5) - { - if (plci->NL.Id && !plci->nl_remove_id) - { - fax_control_bits = GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low); - fax_feature_bits = GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->feature_bits_low); - if (!(fax_control_bits & T30_CONTROL_BIT_MORE_DOCUMENTS) - || (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS)) - { - len = offsetof(T30_INFO, universal_6); - fax_info_change = false; - if (ncpi->length >= 4) - { - w = GET_WORD(&ncpi->info[3]); - if ((w & 0x0001) != ((word)(((T30_INFO *)(plci->fax_connect_info_buffer))->resolution & 0x0001))) - { - ((T30_INFO *)(plci->fax_connect_info_buffer))->resolution = - (byte)((((T30_INFO *)(plci->fax_connect_info_buffer))->resolution & ~T30_RESOLUTION_R8_0770_OR_200) | - ((w & 0x0001) ? T30_RESOLUTION_R8_0770_OR_200 : 0)); - fax_info_change = true; - } - fax_control_bits &= ~(T30_CONTROL_BIT_REQUEST_POLLING | T30_CONTROL_BIT_MORE_DOCUMENTS); - if (w & 0x0002) /* Fax-polling request */ - fax_control_bits |= T30_CONTROL_BIT_REQUEST_POLLING; - if ((w & 0x0004) /* Request to send / poll another document */ - && (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_MORE_DOCUMENTS)) - { - fax_control_bits |= T30_CONTROL_BIT_MORE_DOCUMENTS; - } - if (ncpi->length >= 6) - { - w = GET_WORD(&ncpi->info[5]); - if (((byte) w) != ((T30_INFO *)(plci->fax_connect_info_buffer))->data_format) - { - ((T30_INFO *)(plci->fax_connect_info_buffer))->data_format = (byte) w; - fax_info_change = true; - } - - if ((a->man_profile.private_options & (1L << PRIVATE_FAX_SUB_SEP_PWD)) - && (GET_WORD(&ncpi->info[5]) & 0x8000)) /* Private SEP/SUB/PWD enable */ - { - plci->requested_options_conn |= (1L << PRIVATE_FAX_SUB_SEP_PWD); - } - if ((a->man_profile.private_options & (1L << PRIVATE_FAX_NONSTANDARD)) - && (GET_WORD(&ncpi->info[5]) & 0x4000)) /* Private non-standard facilities enable */ - { - plci->requested_options_conn |= (1L << PRIVATE_FAX_NONSTANDARD); - } - fax_control_bits &= ~(T30_CONTROL_BIT_ACCEPT_SUBADDRESS | T30_CONTROL_BIT_ACCEPT_SEL_POLLING | - T30_CONTROL_BIT_ACCEPT_PASSWORD); - if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[appl->Id-1]) - & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) - { - if (api_parse (&ncpi->info[1], ncpi->length, "wwwwsss", fax_parms)) - Info = _WRONG_MESSAGE_FORMAT; - else - { - if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[appl->Id-1]) - & (1L << PRIVATE_FAX_SUB_SEP_PWD)) - { - fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SUBADDRESS | T30_CONTROL_BIT_ACCEPT_PASSWORD; - if (fax_control_bits & T30_CONTROL_BIT_ACCEPT_POLLING) - fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; - } - w = fax_parms[4].length; - if (w > 20) - w = 20; - ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = (byte) w; - for (i = 0; i < w; i++) - ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id[i] = fax_parms[4].info[1+i]; - ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; - w = fax_parms[5].length; - if (w > 20) - w = 20; - plci->fax_connect_info_buffer[len++] = (byte) w; - for (i = 0; i < w; i++) - plci->fax_connect_info_buffer[len++] = fax_parms[5].info[1+i]; - w = fax_parms[6].length; - if (w > 20) - w = 20; - plci->fax_connect_info_buffer[len++] = (byte) w; - for (i = 0; i < w; i++) - plci->fax_connect_info_buffer[len++] = fax_parms[6].info[1+i]; - if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[appl->Id-1]) - & (1L << PRIVATE_FAX_NONSTANDARD)) - { - if (api_parse (&ncpi->info[1], ncpi->length, "wwwwssss", fax_parms)) - { - dbug(1,dprintf("non-standard facilities info missing or wrong format")); - plci->fax_connect_info_buffer[len++] = 0; - } - else - { - if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2)) - plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]); - plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length); - for (i = 0; i < fax_parms[7].length; i++) - plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1+i]; - } - } - } - } - else - { - len = offsetof(T30_INFO, universal_6); - } - fax_info_change = true; - - } - if (fax_control_bits != GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low)) - { - PUT_WORD (&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low, fax_control_bits); - fax_info_change = true; - } - } - if (Info == GOOD) - { - plci->fax_connect_info_length = len; - if (fax_info_change) - { - if (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS) - { - start_internal_command (Id, plci, fax_connect_info_command); - return false; - } - else - { - start_internal_command (Id, plci, fax_adjust_b23_command); - return false; - } - } - } - } - else Info = _WRONG_STATE; - } - else Info = _WRONG_STATE; - } - - else if (plci->B3_prot == B3_RTP) - { - plci->internal_req_buffer[0] = ncpi->length + 1; - plci->internal_req_buffer[1] = UDATA_REQUEST_RTP_RECONFIGURE; - for (w = 0; w < ncpi->length; w++) - plci->internal_req_buffer[2+w] = ncpi->info[1+w]; - start_internal_command (Id, plci, rtp_connect_b3_req_command); - return false; - } - - if(!Info) - { - nl_req_ncci(plci,req,0); - return 1; - } - } - } - else Info = _WRONG_IDENTIFIER; - - sendf(appl, - _CONNECT_B3_R|CONFIRM, - Id, - Number, - "w",Info); - return false; + word Info = 0; + byte req; + byte len; + word w; + word fax_control_bits, fax_feature_bits, fax_info_change; + API_PARSE *ncpi; + byte pvc[2]; + + API_PARSE fax_parms[9]; + word i; + + + dbug(1, dprintf("connect_b3_req")); + if (plci) + { + if ((plci->State == IDLE) || (plci->State == OUTG_DIS_PENDING) + || (plci->State == INC_DIS_PENDING) || (plci->SuppState != IDLE)) + { + Info = _WRONG_STATE; + } + else + { + /* local reply if assign unsuccessful + or B3 protocol allows only one layer 3 connection + and already connected + or B2 protocol not any LAPD + and connect_b3_req contradicts originate/answer direction */ + if (!plci->NL.Id + || (((plci->B3_prot != B3_T90NL) && (plci->B3_prot != B3_ISO8208) && (plci->B3_prot != B3_X25_DCE)) + && ((plci->channels != 0) + || (((plci->B2_prot != B2_SDLC) && (plci->B2_prot != B2_LAPD) && (plci->B2_prot != B2_LAPD_FREE_SAPI_SEL)) + && ((plci->call_dir & CALL_DIR_ANSWER) && !(plci->call_dir & CALL_DIR_FORCE_OUTG_NL)))))) + { + dbug(1, dprintf("B3 already connected=%d or no NL.Id=0x%x, dir=%d sstate=0x%x", + plci->channels, plci->NL.Id, plci->call_dir, plci->SuppState)); + Info = _WRONG_STATE; + sendf(appl, + _CONNECT_B3_R | CONFIRM, + Id, + Number, + "w", Info); + return false; + } + plci->requested_options_conn = 0; + + req = N_CONNECT; + ncpi = &parms[0]; + if (plci->B3_prot == 2 || plci->B3_prot == 3) + { + if (ncpi->length > 2) + { + /* check for PVC */ + if (ncpi->info[2] || ncpi->info[3]) + { + pvc[0] = ncpi->info[3]; + pvc[1] = ncpi->info[2]; + add_d(plci, 2, pvc); + req = N_RESET; + } + else + { + if (ncpi->info[1] & 1) req = N_CONNECT | N_D_BIT; + add_d(plci, (word)(ncpi->length - 3), &ncpi->info[4]); + } + } + } + else if (plci->B3_prot == 5) + { + if (plci->NL.Id && !plci->nl_remove_id) + { + fax_control_bits = GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low); + fax_feature_bits = GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->feature_bits_low); + if (!(fax_control_bits & T30_CONTROL_BIT_MORE_DOCUMENTS) + || (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS)) + { + len = offsetof(T30_INFO, universal_6); + fax_info_change = false; + if (ncpi->length >= 4) + { + w = GET_WORD(&ncpi->info[3]); + if ((w & 0x0001) != ((word)(((T30_INFO *)(plci->fax_connect_info_buffer))->resolution & 0x0001))) + { + ((T30_INFO *)(plci->fax_connect_info_buffer))->resolution = + (byte)((((T30_INFO *)(plci->fax_connect_info_buffer))->resolution & ~T30_RESOLUTION_R8_0770_OR_200) | + ((w & 0x0001) ? T30_RESOLUTION_R8_0770_OR_200 : 0)); + fax_info_change = true; + } + fax_control_bits &= ~(T30_CONTROL_BIT_REQUEST_POLLING | T30_CONTROL_BIT_MORE_DOCUMENTS); + if (w & 0x0002) /* Fax-polling request */ + fax_control_bits |= T30_CONTROL_BIT_REQUEST_POLLING; + if ((w & 0x0004) /* Request to send / poll another document */ + && (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_MORE_DOCUMENTS)) + { + fax_control_bits |= T30_CONTROL_BIT_MORE_DOCUMENTS; + } + if (ncpi->length >= 6) + { + w = GET_WORD(&ncpi->info[5]); + if (((byte) w) != ((T30_INFO *)(plci->fax_connect_info_buffer))->data_format) + { + ((T30_INFO *)(plci->fax_connect_info_buffer))->data_format = (byte) w; + fax_info_change = true; + } + + if ((a->man_profile.private_options & (1L << PRIVATE_FAX_SUB_SEP_PWD)) + && (GET_WORD(&ncpi->info[5]) & 0x8000)) /* Private SEP/SUB/PWD enable */ + { + plci->requested_options_conn |= (1L << PRIVATE_FAX_SUB_SEP_PWD); + } + if ((a->man_profile.private_options & (1L << PRIVATE_FAX_NONSTANDARD)) + && (GET_WORD(&ncpi->info[5]) & 0x4000)) /* Private non-standard facilities enable */ + { + plci->requested_options_conn |= (1L << PRIVATE_FAX_NONSTANDARD); + } + fax_control_bits &= ~(T30_CONTROL_BIT_ACCEPT_SUBADDRESS | T30_CONTROL_BIT_ACCEPT_SEL_POLLING | + T30_CONTROL_BIT_ACCEPT_PASSWORD); + if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[appl->Id - 1]) + & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) + { + if (api_parse(&ncpi->info[1], ncpi->length, "wwwwsss", fax_parms)) + Info = _WRONG_MESSAGE_FORMAT; + else + { + if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[appl->Id - 1]) + & (1L << PRIVATE_FAX_SUB_SEP_PWD)) + { + fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SUBADDRESS | T30_CONTROL_BIT_ACCEPT_PASSWORD; + if (fax_control_bits & T30_CONTROL_BIT_ACCEPT_POLLING) + fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; + } + w = fax_parms[4].length; + if (w > 20) + w = 20; + ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = (byte) w; + for (i = 0; i < w; i++) + ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id[i] = fax_parms[4].info[1 + i]; + ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; + len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + w = fax_parms[5].length; + if (w > 20) + w = 20; + plci->fax_connect_info_buffer[len++] = (byte) w; + for (i = 0; i < w; i++) + plci->fax_connect_info_buffer[len++] = fax_parms[5].info[1 + i]; + w = fax_parms[6].length; + if (w > 20) + w = 20; + plci->fax_connect_info_buffer[len++] = (byte) w; + for (i = 0; i < w; i++) + plci->fax_connect_info_buffer[len++] = fax_parms[6].info[1 + i]; + if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[appl->Id - 1]) + & (1L << PRIVATE_FAX_NONSTANDARD)) + { + if (api_parse(&ncpi->info[1], ncpi->length, "wwwwssss", fax_parms)) + { + dbug(1, dprintf("non-standard facilities info missing or wrong format")); + plci->fax_connect_info_buffer[len++] = 0; + } + else + { + if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2)) + plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]); + plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length); + for (i = 0; i < fax_parms[7].length; i++) + plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1 + i]; + } + } + } + } + else + { + len = offsetof(T30_INFO, universal_6); + } + fax_info_change = true; + + } + if (fax_control_bits != GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low)) + { + PUT_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low, fax_control_bits); + fax_info_change = true; + } + } + if (Info == GOOD) + { + plci->fax_connect_info_length = len; + if (fax_info_change) + { + if (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS) + { + start_internal_command(Id, plci, fax_connect_info_command); + return false; + } + else + { + start_internal_command(Id, plci, fax_adjust_b23_command); + return false; + } + } + } + } + else Info = _WRONG_STATE; + } + else Info = _WRONG_STATE; + } + + else if (plci->B3_prot == B3_RTP) + { + plci->internal_req_buffer[0] = ncpi->length + 1; + plci->internal_req_buffer[1] = UDATA_REQUEST_RTP_RECONFIGURE; + for (w = 0; w < ncpi->length; w++) + plci->internal_req_buffer[2 + w] = ncpi->info[1 + w]; + start_internal_command(Id, plci, rtp_connect_b3_req_command); + return false; + } + + if (!Info) + { + nl_req_ncci(plci, req, 0); + return 1; + } + } + } + else Info = _WRONG_IDENTIFIER; + + sendf(appl, + _CONNECT_B3_R | CONFIRM, + Id, + Number, + "w", Info); + return false; } static byte connect_b3_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word ncci; - API_PARSE * ncpi; - byte req; - - word w; - - - API_PARSE fax_parms[9]; - word i; - byte len; - - - dbug(1,dprintf("connect_b3_res")); - - ncci = (word)(Id>>16); - if(plci && ncci) { - if(a->ncci_state[ncci]==INC_CON_PENDING) { - if (GET_WORD (&parms[0].info[0]) != 0) - { - a->ncci_state[ncci] = OUTG_REJ_PENDING; - channel_request_xon (plci, a->ncci_ch[ncci]); - channel_xmit_xon (plci); - cleanup_ncci_data (plci, ncci); - nl_req_ncci(plci,N_DISC,(byte)ncci); - return 1; - } - a->ncci_state[ncci] = INC_ACT_PENDING; - - req = N_CONNECT_ACK; - ncpi = &parms[1]; - if ((plci->B3_prot == 4) || (plci->B3_prot == 5) || (plci->B3_prot == 7)) - { - - if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1]) - & (1L << PRIVATE_FAX_NONSTANDARD)) - { - if (((plci->B3_prot == 4) || (plci->B3_prot == 5)) - && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) - && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) - { - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; - if (plci->fax_connect_info_length < len) - { - ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; - ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; - } - if (api_parse (&ncpi->info[1], ncpi->length, "wwwwssss", fax_parms)) - { - dbug(1,dprintf("non-standard facilities info missing or wrong format")); - } - else - { - if (plci->fax_connect_info_length <= len) - plci->fax_connect_info_buffer[len] = 0; - len += 1 + plci->fax_connect_info_buffer[len]; - if (plci->fax_connect_info_length <= len) - plci->fax_connect_info_buffer[len] = 0; - len += 1 + plci->fax_connect_info_buffer[len]; - if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2)) - plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]); - plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length); - for (i = 0; i < fax_parms[7].length; i++) - plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1+i]; - } - plci->fax_connect_info_length = len; - ((T30_INFO *)(plci->fax_connect_info_buffer))->code = 0; - start_internal_command (Id, plci, fax_connect_ack_command); - return false; - } - } - - nl_req_ncci(plci,req,(byte)ncci); - if ((plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - if (plci->B3_prot == 4) - sendf(appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - else - sendf(appl,_CONNECT_B3_ACTIVE_I,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } - } - - else if (plci->B3_prot == B3_RTP) - { - plci->internal_req_buffer[0] = ncpi->length + 1; - plci->internal_req_buffer[1] = UDATA_REQUEST_RTP_RECONFIGURE; - for (w = 0; w < ncpi->length; w++) - plci->internal_req_buffer[2+w] = ncpi->info[1+w]; - start_internal_command (Id, plci, rtp_connect_b3_res_command); - return false; - } - - else - { - if(ncpi->length>2) { - if(ncpi->info[1] &1) req = N_CONNECT_ACK | N_D_BIT; - add_d(plci,(word)(ncpi->length-3),&ncpi->info[4]); - } - nl_req_ncci(plci,req,(byte)ncci); - sendf(appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - if (plci->adjust_b_restore) - { - plci->adjust_b_restore = false; - start_internal_command (Id, plci, adjust_b_restore); - } - } - return 1; - } - } - return false; + word ncci; + API_PARSE *ncpi; + byte req; + + word w; + + + API_PARSE fax_parms[9]; + word i; + byte len; + + + dbug(1, dprintf("connect_b3_res")); + + ncci = (word)(Id >> 16); + if (plci && ncci) { + if (a->ncci_state[ncci] == INC_CON_PENDING) { + if (GET_WORD(&parms[0].info[0]) != 0) + { + a->ncci_state[ncci] = OUTG_REJ_PENDING; + channel_request_xon(plci, a->ncci_ch[ncci]); + channel_xmit_xon(plci); + cleanup_ncci_data(plci, ncci); + nl_req_ncci(plci, N_DISC, (byte)ncci); + return 1; + } + a->ncci_state[ncci] = INC_ACT_PENDING; + + req = N_CONNECT_ACK; + ncpi = &parms[1]; + if ((plci->B3_prot == 4) || (plci->B3_prot == 5) || (plci->B3_prot == 7)) + { + + if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id - 1]) + & (1L << PRIVATE_FAX_NONSTANDARD)) + { + if (((plci->B3_prot == 4) || (plci->B3_prot == 5)) + && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) + && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) + { + len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + if (plci->fax_connect_info_length < len) + { + ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; + ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; + } + if (api_parse(&ncpi->info[1], ncpi->length, "wwwwssss", fax_parms)) + { + dbug(1, dprintf("non-standard facilities info missing or wrong format")); + } + else + { + if (plci->fax_connect_info_length <= len) + plci->fax_connect_info_buffer[len] = 0; + len += 1 + plci->fax_connect_info_buffer[len]; + if (plci->fax_connect_info_length <= len) + plci->fax_connect_info_buffer[len] = 0; + len += 1 + plci->fax_connect_info_buffer[len]; + if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2)) + plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]); + plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length); + for (i = 0; i < fax_parms[7].length; i++) + plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1 + i]; + } + plci->fax_connect_info_length = len; + ((T30_INFO *)(plci->fax_connect_info_buffer))->code = 0; + start_internal_command(Id, plci, fax_connect_ack_command); + return false; + } + } + + nl_req_ncci(plci, req, (byte)ncci); + if ((plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + if (plci->B3_prot == 4) + sendf(appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + else + sendf(appl, _CONNECT_B3_ACTIVE_I, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } + } + + else if (plci->B3_prot == B3_RTP) + { + plci->internal_req_buffer[0] = ncpi->length + 1; + plci->internal_req_buffer[1] = UDATA_REQUEST_RTP_RECONFIGURE; + for (w = 0; w < ncpi->length; w++) + plci->internal_req_buffer[2 + w] = ncpi->info[1+w]; + start_internal_command(Id, plci, rtp_connect_b3_res_command); + return false; + } + + else + { + if (ncpi->length > 2) { + if (ncpi->info[1] & 1) req = N_CONNECT_ACK | N_D_BIT; + add_d(plci, (word)(ncpi->length - 3), &ncpi->info[4]); + } + nl_req_ncci(plci, req, (byte)ncci); + sendf(appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + if (plci->adjust_b_restore) + { + plci->adjust_b_restore = false; + start_internal_command(Id, plci, adjust_b_restore); + } + } + return 1; + } + } + return false; } static byte connect_b3_a_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word ncci; + word ncci; - ncci = (word)(Id>>16); - dbug(1,dprintf("connect_b3_a_res(ncci=0x%x)",ncci)); + ncci = (word)(Id >> 16); + dbug(1, dprintf("connect_b3_a_res(ncci=0x%x)", ncci)); - if (plci && ncci && (plci->State != IDLE) && (plci->State != INC_DIS_PENDING) - && (plci->State != OUTG_DIS_PENDING)) - { - if(a->ncci_state[ncci]==INC_ACT_PENDING) { - a->ncci_state[ncci] = CONNECTED; - if(plci->State!=INC_CON_CONNECTED_ALERT) plci->State = CONNECTED; - channel_request_xon (plci, a->ncci_ch[ncci]); - channel_xmit_xon (plci); - } - } - return false; + if (plci && ncci && (plci->State != IDLE) && (plci->State != INC_DIS_PENDING) + && (plci->State != OUTG_DIS_PENDING)) + { + if (a->ncci_state[ncci] == INC_ACT_PENDING) { + a->ncci_state[ncci] = CONNECTED; + if (plci->State != INC_CON_CONNECTED_ALERT) plci->State = CONNECTED; + channel_request_xon(plci, a->ncci_ch[ncci]); + channel_xmit_xon(plci); + } + } + return false; } static byte disconnect_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word Info; - word ncci; - API_PARSE * ncpi; - - dbug(1,dprintf("disconnect_b3_req")); - - Info = _WRONG_IDENTIFIER; - ncci = (word)(Id>>16); - if (plci && ncci) - { - Info = _WRONG_STATE; - if ((a->ncci_state[ncci] == CONNECTED) - || (a->ncci_state[ncci] == OUTG_CON_PENDING) - || (a->ncci_state[ncci] == INC_CON_PENDING) - || (a->ncci_state[ncci] == INC_ACT_PENDING)) - { - a->ncci_state[ncci] = OUTG_DIS_PENDING; - channel_request_xon (plci, a->ncci_ch[ncci]); - channel_xmit_xon (plci); - - if (a->ncci[ncci].data_pending - && ((plci->B3_prot == B3_TRANSPARENT) - || (plci->B3_prot == B3_T30) - || (plci->B3_prot == B3_T30_WITH_EXTENSIONS))) - { - plci->send_disc = (byte)ncci; - plci->command = 0; - return false; - } - else - { - cleanup_ncci_data (plci, ncci); - - if(plci->B3_prot==2 || plci->B3_prot==3) - { - ncpi = &parms[0]; - if(ncpi->length>3) - { - add_d(plci, (word)(ncpi->length - 3) ,(byte *)&(ncpi->info[4])); - } - } - nl_req_ncci(plci,N_DISC,(byte)ncci); - } - return 1; - } - } - sendf(appl, - _DISCONNECT_B3_R|CONFIRM, - Id, - Number, - "w",Info); - return false; + word Info; + word ncci; + API_PARSE *ncpi; + + dbug(1, dprintf("disconnect_b3_req")); + + Info = _WRONG_IDENTIFIER; + ncci = (word)(Id >> 16); + if (plci && ncci) + { + Info = _WRONG_STATE; + if ((a->ncci_state[ncci] == CONNECTED) + || (a->ncci_state[ncci] == OUTG_CON_PENDING) + || (a->ncci_state[ncci] == INC_CON_PENDING) + || (a->ncci_state[ncci] == INC_ACT_PENDING)) + { + a->ncci_state[ncci] = OUTG_DIS_PENDING; + channel_request_xon(plci, a->ncci_ch[ncci]); + channel_xmit_xon(plci); + + if (a->ncci[ncci].data_pending + && ((plci->B3_prot == B3_TRANSPARENT) + || (plci->B3_prot == B3_T30) + || (plci->B3_prot == B3_T30_WITH_EXTENSIONS))) + { + plci->send_disc = (byte)ncci; + plci->command = 0; + return false; + } + else + { + cleanup_ncci_data(plci, ncci); + + if (plci->B3_prot == 2 || plci->B3_prot == 3) + { + ncpi = &parms[0]; + if (ncpi->length > 3) + { + add_d(plci, (word)(ncpi->length - 3), (byte *)&(ncpi->info[4])); + } + } + nl_req_ncci(plci, N_DISC, (byte)ncci); + } + return 1; + } + } + sendf(appl, + _DISCONNECT_B3_R | CONFIRM, + Id, + Number, + "w", Info); + return false; } static byte disconnect_b3_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word ncci; - word i; - - ncci = (word)(Id>>16); - dbug(1,dprintf("disconnect_b3_res(ncci=0x%x",ncci)); - if(plci && ncci) { - plci->requested_options_conn = 0; - plci->fax_connect_info_length = 0; - plci->ncpi_state = 0x00; - if (((plci->B3_prot != B3_T90NL) && (plci->B3_prot != B3_ISO8208) && (plci->B3_prot != B3_X25_DCE)) - && ((plci->B2_prot != B2_LAPD) && (plci->B2_prot != B2_LAPD_FREE_SAPI_SEL))) - { - plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; - } - for(i=0; iinc_dis_ncci_table[i]!=(byte)ncci; i++); - if(ichannels)plci->channels--; - for(; iinc_dis_ncci_table[i] = plci->inc_dis_ncci_table[i+1]; - plci->inc_dis_ncci_table[MAX_CHANNELS_PER_PLCI-1] = 0; - - ncci_free_receive_buffers (plci, ncci); - - if((plci->State==IDLE || plci->State==SUSPENDING) && !plci->channels){ - if(plci->State == SUSPENDING){ - sendf(plci->appl, - _FACILITY_I, - Id & 0xffffL, - 0, - "ws", (word)3, "\x03\x04\x00\x00"); - sendf(plci->appl, _DISCONNECT_I, Id & 0xffffL, 0, "w", 0); - } - plci_remove(plci); - plci->State=IDLE; - } - } - else - { - if ((a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) - && ((plci->B3_prot == 4) || (plci->B3_prot == 5)) - && (a->ncci_state[ncci] == INC_DIS_PENDING)) - { - ncci_free_receive_buffers (plci, ncci); - - nl_req_ncci(plci,N_EDATA,(byte)ncci); - - plci->adapter->ncci_state[ncci] = IDLE; - start_internal_command (Id, plci, fax_disconnect_command); - return 1; - } - } - } - return false; + word ncci; + word i; + + ncci = (word)(Id >> 16); + dbug(1, dprintf("disconnect_b3_res(ncci=0x%x", ncci)); + if (plci && ncci) { + plci->requested_options_conn = 0; + plci->fax_connect_info_length = 0; + plci->ncpi_state = 0x00; + if (((plci->B3_prot != B3_T90NL) && (plci->B3_prot != B3_ISO8208) && (plci->B3_prot != B3_X25_DCE)) + && ((plci->B2_prot != B2_LAPD) && (plci->B2_prot != B2_LAPD_FREE_SAPI_SEL))) + { + plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; + } + for (i = 0; i < MAX_CHANNELS_PER_PLCI && plci->inc_dis_ncci_table[i] != (byte)ncci; i++); + if (i < MAX_CHANNELS_PER_PLCI) { + if (plci->channels)plci->channels--; + for (; i < MAX_CHANNELS_PER_PLCI - 1; i++) plci->inc_dis_ncci_table[i] = plci->inc_dis_ncci_table[i + 1]; + plci->inc_dis_ncci_table[MAX_CHANNELS_PER_PLCI - 1] = 0; + + ncci_free_receive_buffers(plci, ncci); + + if ((plci->State == IDLE || plci->State == SUSPENDING) && !plci->channels) { + if (plci->State == SUSPENDING) { + sendf(plci->appl, + _FACILITY_I, + Id & 0xffffL, + 0, + "ws", (word)3, "\x03\x04\x00\x00"); + sendf(plci->appl, _DISCONNECT_I, Id & 0xffffL, 0, "w", 0); + } + plci_remove(plci); + plci->State = IDLE; + } + } + else + { + if ((a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) + && ((plci->B3_prot == 4) || (plci->B3_prot == 5)) + && (a->ncci_state[ncci] == INC_DIS_PENDING)) + { + ncci_free_receive_buffers(plci, ncci); + + nl_req_ncci(plci, N_EDATA, (byte)ncci); + + plci->adapter->ncci_state[ncci] = IDLE; + start_internal_command(Id, plci, fax_disconnect_command); + return 1; + } + } + } + return false; } static byte data_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - NCCI *ncci_ptr; - DATA_B3_DESC *data; - word Info; - word ncci; - word i; - - dbug(1,dprintf("data_b3_req")); - - Info = _WRONG_IDENTIFIER; - ncci = (word)(Id>>16); - dbug(1,dprintf("ncci=0x%x, plci=0x%x",ncci,plci)); - - if (plci && ncci) - { - Info = _WRONG_STATE; - if ((a->ncci_state[ncci] == CONNECTED) - || (a->ncci_state[ncci] == INC_ACT_PENDING)) - { - /* queue data */ - ncci_ptr = &(a->ncci[ncci]); - i = ncci_ptr->data_out + ncci_ptr->data_pending; - if (i >= MAX_DATA_B3) - i -= MAX_DATA_B3; - data = &(ncci_ptr->DBuffer[i]); - data->Number = Number; - if ((((byte *)(parms[0].info)) >= ((byte *)(plci->msg_in_queue))) - && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) - { - - data->P = (byte *)(long)(*((dword *)(parms[0].info))); - - } - else - data->P = TransmitBufferSet(appl,*(dword *)parms[0].info); - data->Length = GET_WORD(parms[1].info); - data->Handle = GET_WORD(parms[2].info); - data->Flags = GET_WORD(parms[3].info); - (ncci_ptr->data_pending)++; - - /* check for delivery confirmation */ - if (data->Flags & 0x0004) - { - i = ncci_ptr->data_ack_out + ncci_ptr->data_ack_pending; - if (i >= MAX_DATA_ACK) - i -= MAX_DATA_ACK; - ncci_ptr->DataAck[i].Number = data->Number; - ncci_ptr->DataAck[i].Handle = data->Handle; - (ncci_ptr->data_ack_pending)++; - } - - send_data(plci); - return false; - } - } - if (appl) - { - if (plci) - { - if ((((byte *)(parms[0].info)) >= ((byte *)(plci->msg_in_queue))) - && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) - { - - TransmitBufferFree (appl, (byte *)(long)(*((dword *)(parms[0].info)))); - - } - } - sendf(appl, - _DATA_B3_R|CONFIRM, - Id, - Number, - "ww",GET_WORD(parms[2].info),Info); - } - return false; + NCCI *ncci_ptr; + DATA_B3_DESC *data; + word Info; + word ncci; + word i; + + dbug(1, dprintf("data_b3_req")); + + Info = _WRONG_IDENTIFIER; + ncci = (word)(Id >> 16); + dbug(1, dprintf("ncci=0x%x, plci=0x%x", ncci, plci)); + + if (plci && ncci) + { + Info = _WRONG_STATE; + if ((a->ncci_state[ncci] == CONNECTED) + || (a->ncci_state[ncci] == INC_ACT_PENDING)) + { + /* queue data */ + ncci_ptr = &(a->ncci[ncci]); + i = ncci_ptr->data_out + ncci_ptr->data_pending; + if (i >= MAX_DATA_B3) + i -= MAX_DATA_B3; + data = &(ncci_ptr->DBuffer[i]); + data->Number = Number; + if ((((byte *)(parms[0].info)) >= ((byte *)(plci->msg_in_queue))) + && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) + { + + data->P = (byte *)(long)(*((dword *)(parms[0].info))); + + } + else + data->P = TransmitBufferSet(appl, *(dword *)parms[0].info); + data->Length = GET_WORD(parms[1].info); + data->Handle = GET_WORD(parms[2].info); + data->Flags = GET_WORD(parms[3].info); + (ncci_ptr->data_pending)++; + + /* check for delivery confirmation */ + if (data->Flags & 0x0004) + { + i = ncci_ptr->data_ack_out + ncci_ptr->data_ack_pending; + if (i >= MAX_DATA_ACK) + i -= MAX_DATA_ACK; + ncci_ptr->DataAck[i].Number = data->Number; + ncci_ptr->DataAck[i].Handle = data->Handle; + (ncci_ptr->data_ack_pending)++; + } + + send_data(plci); + return false; + } + } + if (appl) + { + if (plci) + { + if ((((byte *)(parms[0].info)) >= ((byte *)(plci->msg_in_queue))) + && (((byte *)(parms[0].info)) < ((byte *)(plci->msg_in_queue)) + sizeof(plci->msg_in_queue))) + { + + TransmitBufferFree(appl, (byte *)(long)(*((dword *)(parms[0].info)))); + + } + } + sendf(appl, + _DATA_B3_R | CONFIRM, + Id, + Number, + "ww", GET_WORD(parms[2].info), Info); + } + return false; } static byte data_b3_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word n; - word ncci; - word NCCIcode; - - dbug(1,dprintf("data_b3_res")); - - ncci = (word)(Id>>16); - if(plci && ncci) { - n = GET_WORD(parms[0].info); - dbug(1,dprintf("free(%d)",n)); - NCCIcode = ncci | (((word) a->Id) << 8); - if(nMaxBuffer && - appl->DataNCCI[n]==NCCIcode && - (byte)(appl->DataFlags[n]>>8)==plci->Id) { - dbug(1,dprintf("found")); - appl->DataNCCI[n] = 0; - - if (channel_can_xon (plci, a->ncci_ch[ncci])) { - channel_request_xon (plci, a->ncci_ch[ncci]); - } - channel_xmit_xon (plci); - - if(appl->DataFlags[n] &4) { - nl_req_ncci(plci,N_DATA_ACK,(byte)ncci); - return 1; - } - } - } - return false; + word n; + word ncci; + word NCCIcode; + + dbug(1, dprintf("data_b3_res")); + + ncci = (word)(Id >> 16); + if (plci && ncci) { + n = GET_WORD(parms[0].info); + dbug(1, dprintf("free(%d)", n)); + NCCIcode = ncci | (((word) a->Id) << 8); + if (n < appl->MaxBuffer && + appl->DataNCCI[n] == NCCIcode && + (byte)(appl->DataFlags[n] >> 8) == plci->Id) { + dbug(1, dprintf("found")); + appl->DataNCCI[n] = 0; + + if (channel_can_xon(plci, a->ncci_ch[ncci])) { + channel_request_xon(plci, a->ncci_ch[ncci]); + } + channel_xmit_xon(plci); + + if (appl->DataFlags[n] & 4) { + nl_req_ncci(plci, N_DATA_ACK, (byte)ncci); + return 1; + } + } + } + return false; } static byte reset_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word Info; - word ncci; - - dbug(1,dprintf("reset_b3_req")); - - Info = _WRONG_IDENTIFIER; - ncci = (word)(Id>>16); - if(plci && ncci) - { - Info = _WRONG_STATE; - switch (plci->B3_prot) - { - case B3_ISO8208: - case B3_X25_DCE: - if(a->ncci_state[ncci]==CONNECTED) - { - nl_req_ncci(plci,N_RESET,(byte)ncci); - send_req(plci); - Info = GOOD; - } - break; - case B3_TRANSPARENT: - if(a->ncci_state[ncci]==CONNECTED) - { - start_internal_command (Id, plci, reset_b3_command); - Info = GOOD; - } - break; - } - } - /* reset_b3 must result in a reset_b3_con & reset_b3_Ind */ - sendf(appl, - _RESET_B3_R|CONFIRM, - Id, - Number, - "w",Info); - return false; + word Info; + word ncci; + + dbug(1, dprintf("reset_b3_req")); + + Info = _WRONG_IDENTIFIER; + ncci = (word)(Id >> 16); + if (plci && ncci) + { + Info = _WRONG_STATE; + switch (plci->B3_prot) + { + case B3_ISO8208: + case B3_X25_DCE: + if (a->ncci_state[ncci] == CONNECTED) + { + nl_req_ncci(plci, N_RESET, (byte)ncci); + send_req(plci); + Info = GOOD; + } + break; + case B3_TRANSPARENT: + if (a->ncci_state[ncci] == CONNECTED) + { + start_internal_command(Id, plci, reset_b3_command); + Info = GOOD; + } + break; + } + } + /* reset_b3 must result in a reset_b3_con & reset_b3_Ind */ + sendf(appl, + _RESET_B3_R | CONFIRM, + Id, + Number, + "w", Info); + return false; } static byte reset_b3_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word ncci; - - dbug(1,dprintf("reset_b3_res")); - - ncci = (word)(Id>>16); - if(plci && ncci) { - switch (plci->B3_prot) - { - case B3_ISO8208: - case B3_X25_DCE: - if(a->ncci_state[ncci]==INC_RES_PENDING) - { - a->ncci_state[ncci] = CONNECTED; - nl_req_ncci(plci,N_RESET_ACK,(byte)ncci); - return true; - } - break; - } - } - return false; + word ncci; + + dbug(1, dprintf("reset_b3_res")); + + ncci = (word)(Id >> 16); + if (plci && ncci) { + switch (plci->B3_prot) + { + case B3_ISO8208: + case B3_X25_DCE: + if (a->ncci_state[ncci] == INC_RES_PENDING) + { + a->ncci_state[ncci] = CONNECTED; + nl_req_ncci(plci, N_RESET_ACK, (byte)ncci); + return true; + } + break; + } + } + return false; } static byte connect_b3_t90_a_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word ncci; - API_PARSE * ncpi; - byte req; - - dbug(1,dprintf("connect_b3_t90_a_res")); - - ncci = (word)(Id>>16); - if(plci && ncci) { - if(a->ncci_state[ncci]==INC_ACT_PENDING) { - a->ncci_state[ncci] = CONNECTED; - } - else if(a->ncci_state[ncci]==INC_CON_PENDING) { - a->ncci_state[ncci] = CONNECTED; - - req = N_CONNECT_ACK; - - /* parms[0]==0 for CAPI original message definition! */ - if(parms[0].info) { - ncpi = &parms[1]; - if(ncpi->length>2) { - if(ncpi->info[1] &1) req = N_CONNECT_ACK | N_D_BIT; - add_d(plci,(word)(ncpi->length-3),&ncpi->info[4]); - } - } - nl_req_ncci(plci,req,(byte)ncci); - return 1; - } - } - return false; + word ncci; + API_PARSE *ncpi; + byte req; + + dbug(1, dprintf("connect_b3_t90_a_res")); + + ncci = (word)(Id >> 16); + if (plci && ncci) { + if (a->ncci_state[ncci] == INC_ACT_PENDING) { + a->ncci_state[ncci] = CONNECTED; + } + else if (a->ncci_state[ncci] == INC_CON_PENDING) { + a->ncci_state[ncci] = CONNECTED; + + req = N_CONNECT_ACK; + + /* parms[0]==0 for CAPI original message definition! */ + if (parms[0].info) { + ncpi = &parms[1]; + if (ncpi->length > 2) { + if (ncpi->info[1] & 1) req = N_CONNECT_ACK | N_D_BIT; + add_d(plci, (word)(ncpi->length - 3), &ncpi->info[4]); + } + } + nl_req_ncci(plci, req, (byte)ncci); + return 1; + } + } + return false; } static byte select_b_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - word Info=0; - word i; - byte tel; - API_PARSE bp_parms[7]; - - if(!plci || !msg) - { - Info = _WRONG_IDENTIFIER; - } - else - { - dbug(1,dprintf("select_b_req[%d],PLCI=0x%x,Tel=0x%x,NL=0x%x,appl=0x%x,sstate=0x%x", - msg->length,plci->Id,plci->tel,plci->NL.Id,plci->appl,plci->SuppState)); - dbug(1,dprintf("PlciState=0x%x",plci->State)); - for(i=0;i<7;i++) bp_parms[i].length = 0; - - /* check if no channel is open, no B3 connected only */ - if((plci->State == IDLE) || (plci->State == OUTG_DIS_PENDING) || (plci->State == INC_DIS_PENDING) - || (plci->SuppState != IDLE) || plci->channels || plci->nl_remove_id) - { - Info = _WRONG_STATE; - } - /* check message format and fill bp_parms pointer */ - else if(msg->length && api_parse(&msg->info[1], (word)msg->length, "wwwsss", bp_parms)) - { - Info = _WRONG_MESSAGE_FORMAT; - } - else - { - if((plci->State==INC_CON_PENDING) || (plci->State==INC_CON_ALERT)) /* send alert tone inband to the network, */ - { /* e.g. Qsig or RBS or Cornet-N or xess PRI */ - if(Id & EXT_CONTROLLER) - { - sendf(appl, _SELECT_B_REQ|CONFIRM, Id, Number, "w", 0x2002); /* wrong controller */ - return 0; - } - plci->State=INC_CON_CONNECTED_ALERT; - plci->appl = appl; - clear_c_ind_mask_bit (plci, (word)(appl->Id-1)); - dump_c_ind_mask (plci); - for(i=0; isaved_msg); - tel = plci->tel; - if(Id & EXT_CONTROLLER) - { - if(tel) /* external controller in use by this PLCI */ - { - if(a->AdvSignalAppl && a->AdvSignalAppl!=appl) - { - dbug(1,dprintf("Ext_Ctrl in use 1")); - Info = _WRONG_STATE; - } - } - else /* external controller NOT in use by this PLCI ? */ - { - if(a->AdvSignalPLCI) - { - dbug(1,dprintf("Ext_Ctrl in use 2")); - Info = _WRONG_STATE; - } - else /* activate the codec */ - { - dbug(1,dprintf("Ext_Ctrl start")); - if(AdvCodecSupport(a, plci, appl, 0) ) - { - dbug(1,dprintf("Error in codec procedures")); - Info = _WRONG_STATE; - } - else if(plci->spoofed_msg==SPOOFING_REQUIRED) /* wait until codec is active */ - { - plci->spoofed_msg = AWAITING_SELECT_B; - plci->internal_command = BLOCK_PLCI; /* lock other commands */ - plci->command = 0; - dbug(1,dprintf("continue if codec loaded")); - return false; - } - } - } - } - else /* external controller bit is OFF */ - { - if(tel) /* external controller in use, need to switch off */ - { - if(a->AdvSignalAppl==appl) - { - CodecIdCheck(a, plci); - plci->tel = 0; - plci->adv_nl = 0; - dbug(1,dprintf("Ext_Ctrl disable")); - } - else - { - dbug(1,dprintf("Ext_Ctrl not requested")); - } - } - } - if (!Info) - { - if (plci->call_dir & CALL_DIR_OUT) - plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; - else if (plci->call_dir & CALL_DIR_IN) - plci->call_dir = CALL_DIR_IN | CALL_DIR_ANSWER; - start_internal_command (Id, plci, select_b_command); - return false; - } - } - } - sendf(appl, _SELECT_B_REQ|CONFIRM, Id, Number, "w", Info); - return false; + word Info = 0; + word i; + byte tel; + API_PARSE bp_parms[7]; + + if (!plci || !msg) + { + Info = _WRONG_IDENTIFIER; + } + else + { + dbug(1, dprintf("select_b_req[%d],PLCI=0x%x,Tel=0x%x,NL=0x%x,appl=0x%x,sstate=0x%x", + msg->length, plci->Id, plci->tel, plci->NL.Id, plci->appl, plci->SuppState)); + dbug(1, dprintf("PlciState=0x%x", plci->State)); + for (i = 0; i < 7; i++) bp_parms[i].length = 0; + + /* check if no channel is open, no B3 connected only */ + if ((plci->State == IDLE) || (plci->State == OUTG_DIS_PENDING) || (plci->State == INC_DIS_PENDING) + || (plci->SuppState != IDLE) || plci->channels || plci->nl_remove_id) + { + Info = _WRONG_STATE; + } + /* check message format and fill bp_parms pointer */ + else if (msg->length && api_parse(&msg->info[1], (word)msg->length, "wwwsss", bp_parms)) + { + Info = _WRONG_MESSAGE_FORMAT; + } + else + { + if ((plci->State == INC_CON_PENDING) || (plci->State == INC_CON_ALERT)) /* send alert tone inband to the network, */ + { /* e.g. Qsig or RBS or Cornet-N or xess PRI */ + if (Id & EXT_CONTROLLER) + { + sendf(appl, _SELECT_B_REQ | CONFIRM, Id, Number, "w", 0x2002); /* wrong controller */ + return 0; + } + plci->State = INC_CON_CONNECTED_ALERT; + plci->appl = appl; + clear_c_ind_mask_bit(plci, (word)(appl->Id - 1)); + dump_c_ind_mask(plci); + for (i = 0; i < max_appl; i++) /* disconnect the other appls */ + { /* its quasi a connect */ + if (test_c_ind_mask_bit(plci, i)) + sendf(&application[i], _DISCONNECT_I, Id, 0, "w", _OTHER_APPL_CONNECTED); + } + } + + api_save_msg(msg, "s", &plci->saved_msg); + tel = plci->tel; + if (Id & EXT_CONTROLLER) + { + if (tel) /* external controller in use by this PLCI */ + { + if (a->AdvSignalAppl && a->AdvSignalAppl != appl) + { + dbug(1, dprintf("Ext_Ctrl in use 1")); + Info = _WRONG_STATE; + } + } + else /* external controller NOT in use by this PLCI ? */ + { + if (a->AdvSignalPLCI) + { + dbug(1, dprintf("Ext_Ctrl in use 2")); + Info = _WRONG_STATE; + } + else /* activate the codec */ + { + dbug(1, dprintf("Ext_Ctrl start")); + if (AdvCodecSupport(a, plci, appl, 0)) + { + dbug(1, dprintf("Error in codec procedures")); + Info = _WRONG_STATE; + } + else if (plci->spoofed_msg == SPOOFING_REQUIRED) /* wait until codec is active */ + { + plci->spoofed_msg = AWAITING_SELECT_B; + plci->internal_command = BLOCK_PLCI; /* lock other commands */ + plci->command = 0; + dbug(1, dprintf("continue if codec loaded")); + return false; + } + } + } + } + else /* external controller bit is OFF */ + { + if (tel) /* external controller in use, need to switch off */ + { + if (a->AdvSignalAppl == appl) + { + CodecIdCheck(a, plci); + plci->tel = 0; + plci->adv_nl = 0; + dbug(1, dprintf("Ext_Ctrl disable")); + } + else + { + dbug(1, dprintf("Ext_Ctrl not requested")); + } + } + } + if (!Info) + { + if (plci->call_dir & CALL_DIR_OUT) + plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; + else if (plci->call_dir & CALL_DIR_IN) + plci->call_dir = CALL_DIR_IN | CALL_DIR_ANSWER; + start_internal_command(Id, plci, select_b_command); + return false; + } + } + } + sendf(appl, _SELECT_B_REQ | CONFIRM, Id, Number, "w", Info); + return false; } static byte manufacturer_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *parms) { - word command; - word i; - word ncci; - API_PARSE * m; - API_PARSE m_parms[5]; - word codec; - byte req; - byte ch; - byte dir; - static byte chi[2] = {0x01,0x00}; - static byte lli[2] = {0x01,0x00}; - static byte codec_cai[2] = {0x01,0x01}; - static byte null_msg = {0}; - static API_PARSE null_parms = { 0, &null_msg }; - PLCI * v_plci; - word Info=0; - - dbug(1,dprintf("manufacturer_req")); - for(i=0;i<5;i++) m_parms[i].length = 0; - - if(GET_DWORD(parms[0].info)!=_DI_MANU_ID) { - Info = _WRONG_MESSAGE_FORMAT; - } - command = GET_WORD(parms[1].info); - m = &parms[2]; - if (!Info) - { - switch(command) { - case _DI_ASSIGN_PLCI: - if(api_parse(&m->info[1],(word)m->length,"wbbs",m_parms)) { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - codec = GET_WORD(m_parms[0].info); - ch = m_parms[1].info[0]; - dir = m_parms[2].info[0]; - if((i=get_plci(a))) { - plci = &a->plci[i-1]; - plci->appl = appl; - plci->command = _MANUFACTURER_R; - plci->m_command = command; - plci->number = Number; - plci->State = LOCAL_CONNECT; - Id = ( ((word)plci->Id<<8)|plci->adapter->Id|0x80); - dbug(1,dprintf("ManCMD,plci=0x%x",Id)); - - if((ch==1 || ch==2) && (dir<=2)) { - chi[1] = (byte)(0x80|ch); - lli[1] = 0; - plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; - switch(codec) - { - case 0: - Info = add_b1(plci,&m_parms[3],0,0); - break; - case 1: - add_p(plci,CAI,codec_cai); - break; - /* manual 'swich on' to the codec support without signalling */ - /* first 'assign plci' with this function, then use */ - case 2: - if(AdvCodecSupport(a, plci, appl, 0) ) { - Info = _RESOURCE_ERROR; - } - else { - Info = add_b1(plci,&null_parms,0,B1_FACILITY_LOCAL); - lli[1] = 0x10; /* local call codec stream */ - } - break; - } - - plci->State = LOCAL_CONNECT; - plci->manufacturer = true; - plci->command = _MANUFACTURER_R; - plci->m_command = command; - plci->number = Number; - - if(!Info) - { - add_p(plci,LLI,lli); - add_p(plci,CHI,chi); - add_p(plci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(plci,ASSIGN,DSIG_ID); - - if(!codec) - { - Info = add_b23(plci,&m_parms[3]); - if(!Info) - { - nl_req_ncci(plci,ASSIGN,0); - send_req(plci); - } - } - if(!Info) - { - dbug(1,dprintf("dir=0x%x,spoof=0x%x",dir,plci->spoofed_msg)); - if (plci->spoofed_msg==SPOOFING_REQUIRED) - { - api_save_msg (m_parms, "wbbs", &plci->saved_msg); - plci->spoofed_msg = AWAITING_MANUF_CON; - plci->internal_command = BLOCK_PLCI; /* reject other req meanwhile */ - plci->command = 0; - send_req(plci); - return false; - } - if(dir==1) { - sig_req(plci,CALL_REQ,0); - } - else if(!dir){ - sig_req(plci,LISTEN_REQ,0); - } - send_req(plci); - } - else - { - sendf(appl, - _MANUFACTURER_R|CONFIRM, - Id, - Number, - "dww",_DI_MANU_ID,command,Info); - return 2; - } - } - } - } - else Info = _OUT_OF_PLCI; - break; - - case _DI_IDI_CTRL: - if(!plci) - { - Info = _WRONG_IDENTIFIER; - break; - } - if(api_parse(&m->info[1],(word)m->length,"bs",m_parms)) { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - req = m_parms[0].info[0]; - plci->command = _MANUFACTURER_R; - plci->m_command = command; - plci->number = Number; - if(req==CALL_REQ) - { - plci->b_channel = getChannel(&m_parms[1]); - mixer_set_bchannel_id_esc (plci, plci->b_channel); - if(plci->spoofed_msg==SPOOFING_REQUIRED) - { - plci->spoofed_msg = CALL_REQ | AWAITING_MANUF_CON; - plci->internal_command = BLOCK_PLCI; /* reject other req meanwhile */ - plci->command = 0; - break; - } - } - else if(req==LAW_REQ) - { - plci->cr_enquiry = true; - } - add_ss(plci,FTY,&m_parms[1]); - sig_req(plci,req,0); - send_req(plci); - if(req==HANGUP) - { - if (plci->NL.Id && !plci->nl_remove_id) - { - if (plci->channels) - { - for (ncci = 1; ncci < MAX_NCCI+1; ncci++) - { - if ((a->ncci_plci[ncci] == plci->Id) && (a->ncci_state[ncci] == CONNECTED)) - { - a->ncci_state[ncci] = OUTG_DIS_PENDING; - cleanup_ncci_data (plci, ncci); - nl_req_ncci(plci,N_DISC,(byte)ncci); - } - } - } - mixer_remove (plci); - nl_req_ncci(plci,REMOVE,0); - send_req(plci); - } - } - break; - - case _DI_SIG_CTRL: - /* signalling control for loop activation B-channel */ - if(!plci) - { - Info = _WRONG_IDENTIFIER; - break; - } - if(m->length){ - plci->command = _MANUFACTURER_R; - plci->number = Number; - add_ss(plci,FTY,m); - sig_req(plci,SIG_CTRL,0); - send_req(plci); - } - else Info = _WRONG_MESSAGE_FORMAT; - break; - - case _DI_RXT_CTRL: - /* activation control for receiver/transmitter B-channel */ - if(!plci) - { - Info = _WRONG_IDENTIFIER; - break; - } - if(m->length){ - plci->command = _MANUFACTURER_R; - plci->number = Number; - add_ss(plci,FTY,m); - sig_req(plci,DSP_CTRL,0); - send_req(plci); - } - else Info = _WRONG_MESSAGE_FORMAT; - break; - - case _DI_ADV_CODEC: - case _DI_DSP_CTRL: - /* TEL_CTRL commands to support non standard adjustments: */ - /* Ring on/off, Handset micro volume, external micro vol. */ - /* handset+external speaker volume, receiver+transm. gain,*/ - /* handsfree on (hookinfo off), set mixer command */ - - if(command == _DI_ADV_CODEC) - { - if(!a->AdvCodecPLCI) { - Info = _WRONG_STATE; - break; - } - v_plci = a->AdvCodecPLCI; - } - else - { - if (plci - && (m->length >= 3) - && (m->info[1] == 0x1c) - && (m->info[2] >= 1)) - { - if (m->info[3] == DSP_CTRL_OLD_SET_MIXER_COEFFICIENTS) - { - if ((plci->tel != ADV_VOICE) || (plci != a->AdvSignalPLCI)) - { - Info = _WRONG_STATE; - break; - } - a->adv_voice_coef_length = m->info[2] - 1; - if (a->adv_voice_coef_length > m->length - 3) - a->adv_voice_coef_length = (byte)(m->length - 3); - if (a->adv_voice_coef_length > ADV_VOICE_COEF_BUFFER_SIZE) - a->adv_voice_coef_length = ADV_VOICE_COEF_BUFFER_SIZE; - for (i = 0; i < a->adv_voice_coef_length; i++) - a->adv_voice_coef_buffer[i] = m->info[4 + i]; - if (plci->B1_facilities & B1_FACILITY_VOICE) - adv_voice_write_coefs (plci, ADV_VOICE_WRITE_UPDATE); - break; - } - else if (m->info[3] == DSP_CTRL_SET_DTMF_PARAMETERS) - { - if (!(a->manufacturer_features & MANUFACTURER_FEATURE_DTMF_PARAMETERS)) - { - Info = _FACILITY_NOT_SUPPORTED; - break; - } - - plci->dtmf_parameter_length = m->info[2] - 1; - if (plci->dtmf_parameter_length > m->length - 3) - plci->dtmf_parameter_length = (byte)(m->length - 3); - if (plci->dtmf_parameter_length > DTMF_PARAMETER_BUFFER_SIZE) - plci->dtmf_parameter_length = DTMF_PARAMETER_BUFFER_SIZE; - for (i = 0; i < plci->dtmf_parameter_length; i++) - plci->dtmf_parameter_buffer[i] = m->info[4+i]; - if (plci->B1_facilities & B1_FACILITY_DTMFR) - dtmf_parameter_write (plci); - break; - - } - } - v_plci = plci; - } - - if(!v_plci) - { - Info = _WRONG_IDENTIFIER; - break; - } - if(m->length){ - add_ss(v_plci,FTY,m); - sig_req(v_plci,TEL_CTRL,0); - send_req(v_plci); - } - else Info = _WRONG_MESSAGE_FORMAT; - - break; - - case _DI_OPTIONS_REQUEST: - if(api_parse(&m->info[1],(word)m->length,"d",m_parms)) { - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if (GET_DWORD (m_parms[0].info) & ~a->man_profile.private_options) - { - Info = _FACILITY_NOT_SUPPORTED; - break; - } - a->requested_options_table[appl->Id-1] = GET_DWORD (m_parms[0].info); - break; - - - - default: - Info = _WRONG_MESSAGE_FORMAT; - break; - } - } - - sendf(appl, - _MANUFACTURER_R|CONFIRM, - Id, - Number, - "dww",_DI_MANU_ID,command,Info); - return false; + word command; + word i; + word ncci; + API_PARSE *m; + API_PARSE m_parms[5]; + word codec; + byte req; + byte ch; + byte dir; + static byte chi[2] = {0x01, 0x00}; + static byte lli[2] = {0x01, 0x00}; + static byte codec_cai[2] = {0x01, 0x01}; + static byte null_msg = {0}; + static API_PARSE null_parms = { 0, &null_msg }; + PLCI *v_plci; + word Info = 0; + + dbug(1, dprintf("manufacturer_req")); + for (i = 0; i < 5; i++) m_parms[i].length = 0; + + if (GET_DWORD(parms[0].info) != _DI_MANU_ID) { + Info = _WRONG_MESSAGE_FORMAT; + } + command = GET_WORD(parms[1].info); + m = &parms[2]; + if (!Info) + { + switch (command) { + case _DI_ASSIGN_PLCI: + if (api_parse(&m->info[1], (word)m->length, "wbbs", m_parms)) { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + codec = GET_WORD(m_parms[0].info); + ch = m_parms[1].info[0]; + dir = m_parms[2].info[0]; + if ((i = get_plci(a))) { + plci = &a->plci[i - 1]; + plci->appl = appl; + plci->command = _MANUFACTURER_R; + plci->m_command = command; + plci->number = Number; + plci->State = LOCAL_CONNECT; + Id = (((word)plci->Id << 8) | plci->adapter->Id | 0x80); + dbug(1, dprintf("ManCMD,plci=0x%x", Id)); + + if ((ch == 1 || ch == 2) && (dir <= 2)) { + chi[1] = (byte)(0x80 | ch); + lli[1] = 0; + plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; + switch (codec) + { + case 0: + Info = add_b1(plci, &m_parms[3], 0, 0); + break; + case 1: + add_p(plci, CAI, codec_cai); + break; + /* manual 'swich on' to the codec support without signalling */ + /* first 'assign plci' with this function, then use */ + case 2: + if (AdvCodecSupport(a, plci, appl, 0)) { + Info = _RESOURCE_ERROR; + } + else { + Info = add_b1(plci, &null_parms, 0, B1_FACILITY_LOCAL); + lli[1] = 0x10; /* local call codec stream */ + } + break; + } + + plci->State = LOCAL_CONNECT; + plci->manufacturer = true; + plci->command = _MANUFACTURER_R; + plci->m_command = command; + plci->number = Number; + + if (!Info) + { + add_p(plci, LLI, lli); + add_p(plci, CHI, chi); + add_p(plci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(plci, ASSIGN, DSIG_ID); + + if (!codec) + { + Info = add_b23(plci, &m_parms[3]); + if (!Info) + { + nl_req_ncci(plci, ASSIGN, 0); + send_req(plci); + } + } + if (!Info) + { + dbug(1, dprintf("dir=0x%x,spoof=0x%x", dir, plci->spoofed_msg)); + if (plci->spoofed_msg == SPOOFING_REQUIRED) + { + api_save_msg(m_parms, "wbbs", &plci->saved_msg); + plci->spoofed_msg = AWAITING_MANUF_CON; + plci->internal_command = BLOCK_PLCI; /* reject other req meanwhile */ + plci->command = 0; + send_req(plci); + return false; + } + if (dir == 1) { + sig_req(plci, CALL_REQ, 0); + } + else if (!dir) { + sig_req(plci, LISTEN_REQ, 0); + } + send_req(plci); + } + else + { + sendf(appl, + _MANUFACTURER_R | CONFIRM, + Id, + Number, + "dww", _DI_MANU_ID, command, Info); + return 2; + } + } + } + } + else Info = _OUT_OF_PLCI; + break; + + case _DI_IDI_CTRL: + if (!plci) + { + Info = _WRONG_IDENTIFIER; + break; + } + if (api_parse(&m->info[1], (word)m->length, "bs", m_parms)) { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + req = m_parms[0].info[0]; + plci->command = _MANUFACTURER_R; + plci->m_command = command; + plci->number = Number; + if (req == CALL_REQ) + { + plci->b_channel = getChannel(&m_parms[1]); + mixer_set_bchannel_id_esc(plci, plci->b_channel); + if (plci->spoofed_msg == SPOOFING_REQUIRED) + { + plci->spoofed_msg = CALL_REQ | AWAITING_MANUF_CON; + plci->internal_command = BLOCK_PLCI; /* reject other req meanwhile */ + plci->command = 0; + break; + } + } + else if (req == LAW_REQ) + { + plci->cr_enquiry = true; + } + add_ss(plci, FTY, &m_parms[1]); + sig_req(plci, req, 0); + send_req(plci); + if (req == HANGUP) + { + if (plci->NL.Id && !plci->nl_remove_id) + { + if (plci->channels) + { + for (ncci = 1; ncci < MAX_NCCI + 1; ncci++) + { + if ((a->ncci_plci[ncci] == plci->Id) && (a->ncci_state[ncci] == CONNECTED)) + { + a->ncci_state[ncci] = OUTG_DIS_PENDING; + cleanup_ncci_data(plci, ncci); + nl_req_ncci(plci, N_DISC, (byte)ncci); + } + } + } + mixer_remove(plci); + nl_req_ncci(plci, REMOVE, 0); + send_req(plci); + } + } + break; + + case _DI_SIG_CTRL: + /* signalling control for loop activation B-channel */ + if (!plci) + { + Info = _WRONG_IDENTIFIER; + break; + } + if (m->length) { + plci->command = _MANUFACTURER_R; + plci->number = Number; + add_ss(plci, FTY, m); + sig_req(plci, SIG_CTRL, 0); + send_req(plci); + } + else Info = _WRONG_MESSAGE_FORMAT; + break; + + case _DI_RXT_CTRL: + /* activation control for receiver/transmitter B-channel */ + if (!plci) + { + Info = _WRONG_IDENTIFIER; + break; + } + if (m->length) { + plci->command = _MANUFACTURER_R; + plci->number = Number; + add_ss(plci, FTY, m); + sig_req(plci, DSP_CTRL, 0); + send_req(plci); + } + else Info = _WRONG_MESSAGE_FORMAT; + break; + + case _DI_ADV_CODEC: + case _DI_DSP_CTRL: + /* TEL_CTRL commands to support non standard adjustments: */ + /* Ring on/off, Handset micro volume, external micro vol. */ + /* handset+external speaker volume, receiver+transm. gain,*/ + /* handsfree on (hookinfo off), set mixer command */ + + if (command == _DI_ADV_CODEC) + { + if (!a->AdvCodecPLCI) { + Info = _WRONG_STATE; + break; + } + v_plci = a->AdvCodecPLCI; + } + else + { + if (plci + && (m->length >= 3) + && (m->info[1] == 0x1c) + && (m->info[2] >= 1)) + { + if (m->info[3] == DSP_CTRL_OLD_SET_MIXER_COEFFICIENTS) + { + if ((plci->tel != ADV_VOICE) || (plci != a->AdvSignalPLCI)) + { + Info = _WRONG_STATE; + break; + } + a->adv_voice_coef_length = m->info[2] - 1; + if (a->adv_voice_coef_length > m->length - 3) + a->adv_voice_coef_length = (byte)(m->length - 3); + if (a->adv_voice_coef_length > ADV_VOICE_COEF_BUFFER_SIZE) + a->adv_voice_coef_length = ADV_VOICE_COEF_BUFFER_SIZE; + for (i = 0; i < a->adv_voice_coef_length; i++) + a->adv_voice_coef_buffer[i] = m->info[4 + i]; + if (plci->B1_facilities & B1_FACILITY_VOICE) + adv_voice_write_coefs(plci, ADV_VOICE_WRITE_UPDATE); + break; + } + else if (m->info[3] == DSP_CTRL_SET_DTMF_PARAMETERS) + { + if (!(a->manufacturer_features & MANUFACTURER_FEATURE_DTMF_PARAMETERS)) + { + Info = _FACILITY_NOT_SUPPORTED; + break; + } + + plci->dtmf_parameter_length = m->info[2] - 1; + if (plci->dtmf_parameter_length > m->length - 3) + plci->dtmf_parameter_length = (byte)(m->length - 3); + if (plci->dtmf_parameter_length > DTMF_PARAMETER_BUFFER_SIZE) + plci->dtmf_parameter_length = DTMF_PARAMETER_BUFFER_SIZE; + for (i = 0; i < plci->dtmf_parameter_length; i++) + plci->dtmf_parameter_buffer[i] = m->info[4 + i]; + if (plci->B1_facilities & B1_FACILITY_DTMFR) + dtmf_parameter_write(plci); + break; + + } + } + v_plci = plci; + } + + if (!v_plci) + { + Info = _WRONG_IDENTIFIER; + break; + } + if (m->length) { + add_ss(v_plci, FTY, m); + sig_req(v_plci, TEL_CTRL, 0); + send_req(v_plci); + } + else Info = _WRONG_MESSAGE_FORMAT; + + break; + + case _DI_OPTIONS_REQUEST: + if (api_parse(&m->info[1], (word)m->length, "d", m_parms)) { + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (GET_DWORD(m_parms[0].info) & ~a->man_profile.private_options) + { + Info = _FACILITY_NOT_SUPPORTED; + break; + } + a->requested_options_table[appl->Id - 1] = GET_DWORD(m_parms[0].info); + break; + + + + default: + Info = _WRONG_MESSAGE_FORMAT; + break; + } + } + + sendf(appl, + _MANUFACTURER_R | CONFIRM, + Id, + Number, + "dww", _DI_MANU_ID, command, Info); + return false; } static byte manufacturer_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) { - word indication; - - API_PARSE m_parms[3]; - API_PARSE *ncpi; - API_PARSE fax_parms[9]; - word i; - byte len; - - - dbug(1,dprintf("manufacturer_res")); - - if ((msg[0].length == 0) - || (msg[1].length == 0) - || (GET_DWORD(msg[0].info)!=_DI_MANU_ID)) - { - return false; - } - indication = GET_WORD(msg[1].info); - switch (indication) - { - - case _DI_NEGOTIATE_B3: - if(!plci) - break; - if (((plci->B3_prot != 4) && (plci->B3_prot != 5)) - || !(plci->ncpi_state & NCPI_NEGOTIATE_B3_SENT)) - { - dbug(1,dprintf("wrong state for NEGOTIATE_B3 parameters")); - break; - } - if (api_parse (&msg[2].info[1], msg[2].length, "ws", m_parms)) - { - dbug(1,dprintf("wrong format in NEGOTIATE_B3 parameters")); - break; - } - ncpi = &m_parms[1]; - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; - if (plci->fax_connect_info_length < len) - { - ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; - ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; - } - if (api_parse (&ncpi->info[1], ncpi->length, "wwwwssss", fax_parms)) - { - dbug(1,dprintf("non-standard facilities info missing or wrong format")); - } - else - { - if (plci->fax_connect_info_length <= len) - plci->fax_connect_info_buffer[len] = 0; - len += 1 + plci->fax_connect_info_buffer[len]; - if (plci->fax_connect_info_length <= len) - plci->fax_connect_info_buffer[len] = 0; - len += 1 + plci->fax_connect_info_buffer[len]; - if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2)) - plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]); - plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length); - for (i = 0; i < fax_parms[7].length; i++) - plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1+i]; - } - plci->fax_connect_info_length = len; - plci->fax_edata_ack_length = plci->fax_connect_info_length; - start_internal_command (Id, plci, fax_edata_ack_command); - break; - - } - return false; + word indication; + + API_PARSE m_parms[3]; + API_PARSE *ncpi; + API_PARSE fax_parms[9]; + word i; + byte len; + + + dbug(1, dprintf("manufacturer_res")); + + if ((msg[0].length == 0) + || (msg[1].length == 0) + || (GET_DWORD(msg[0].info) != _DI_MANU_ID)) + { + return false; + } + indication = GET_WORD(msg[1].info); + switch (indication) + { + + case _DI_NEGOTIATE_B3: + if (!plci) + break; + if (((plci->B3_prot != 4) && (plci->B3_prot != 5)) + || !(plci->ncpi_state & NCPI_NEGOTIATE_B3_SENT)) + { + dbug(1, dprintf("wrong state for NEGOTIATE_B3 parameters")); + break; + } + if (api_parse(&msg[2].info[1], msg[2].length, "ws", m_parms)) + { + dbug(1, dprintf("wrong format in NEGOTIATE_B3 parameters")); + break; + } + ncpi = &m_parms[1]; + len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + if (plci->fax_connect_info_length < len) + { + ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; + ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; + } + if (api_parse(&ncpi->info[1], ncpi->length, "wwwwssss", fax_parms)) + { + dbug(1, dprintf("non-standard facilities info missing or wrong format")); + } + else + { + if (plci->fax_connect_info_length <= len) + plci->fax_connect_info_buffer[len] = 0; + len += 1 + plci->fax_connect_info_buffer[len]; + if (plci->fax_connect_info_length <= len) + plci->fax_connect_info_buffer[len] = 0; + len += 1 + plci->fax_connect_info_buffer[len]; + if ((fax_parms[7].length >= 3) && (fax_parms[7].info[1] >= 2)) + plci->nsf_control_bits = GET_WORD(&fax_parms[7].info[2]); + plci->fax_connect_info_buffer[len++] = (byte)(fax_parms[7].length); + for (i = 0; i < fax_parms[7].length; i++) + plci->fax_connect_info_buffer[len++] = fax_parms[7].info[1 + i]; + } + plci->fax_connect_info_length = len; + plci->fax_edata_ack_length = plci->fax_connect_info_length; + start_internal_command(Id, plci, fax_edata_ack_command); + break; + + } + return false; } /*------------------------------------------------------------------*/ /* IDI callback function */ /*------------------------------------------------------------------*/ -void callback(ENTITY * e) -{ - DIVA_CAPI_ADAPTER * a; - APPL * appl; - PLCI * plci; - CAPI_MSG *m; - word i, j; - byte rc; - byte ch; - byte req; - byte global_req; - int no_cancel_rc; - - dbug(1,dprintf("%x:CB(%x:Req=%x,Rc=%x,Ind=%x)", - (e->user[0]+1)&0x7fff,e->Id,e->Req,e->Rc,e->Ind)); - - a = &(adapter[(byte)e->user[0]]); - plci = &(a->plci[e->user[1]]); - no_cancel_rc = DIVA_CAPI_SUPPORTS_NO_CANCEL(a); - - /* - If new protocol code and new XDI is used then CAPI should work - fully in accordance with IDI cpec an look on callback field instead - of Rc field for return codes. - */ - if (((e->complete == 0xff) && no_cancel_rc) || - (e->Rc && !no_cancel_rc)) { - rc = e->Rc; - ch = e->RcCh; - req = e->Req; - e->Rc = 0; - - if (e->user[0] & 0x8000) - { - /* - If REMOVE request was sent then we have to wait until - return code with Id set to zero arrives. - All other return codes should be ignored. - */ - if (req == REMOVE) - { - if (e->Id) - { - dbug(1,dprintf("cancel RC in REMOVE state")); - return; - } - channel_flow_control_remove (plci); - for (i = 0; i < 256; i++) - { - if (a->FlowControlIdTable[i] == plci->nl_remove_id) - a->FlowControlIdTable[i] = 0; - } - plci->nl_remove_id = 0; - if (plci->rx_dma_descriptor > 0) { - diva_free_dma_descriptor (plci, plci->rx_dma_descriptor - 1); - plci->rx_dma_descriptor = 0; - } - } - if (rc == OK_FC) - { - a->FlowControlIdTable[ch] = e->Id; - a->FlowControlSkipTable[ch] = 0; - - a->ch_flow_control[ch] |= N_OK_FC_PENDING; - a->ch_flow_plci[ch] = plci->Id; - plci->nl_req = 0; - } - else - { - /* - Cancel return codes self, if feature was requested - */ - if (no_cancel_rc && (a->FlowControlIdTable[ch] == e->Id) && e->Id) { - a->FlowControlIdTable[ch] = 0; - if ((rc == OK) && a->FlowControlSkipTable[ch]) { - dbug(3,dprintf ("XDI CAPI: RC cancelled Id:0x02, Ch:%02x", e->Id, ch)); - return; - } - } - - if (a->ch_flow_control[ch] & N_OK_FC_PENDING) - { - a->ch_flow_control[ch] &= ~N_OK_FC_PENDING; - if (ch == e->ReqCh) - plci->nl_req = 0; - } - else - plci->nl_req = 0; - } - if (plci->nl_req) - control_rc (plci, 0, rc, ch, 0, true); - else - { - if (req == N_XON) - { - channel_x_on (plci, ch); - if (plci->internal_command) - control_rc (plci, req, rc, ch, 0, true); - } - else - { - if (plci->nl_global_req) - { - global_req = plci->nl_global_req; - plci->nl_global_req = 0; - if (rc != ASSIGN_OK) { - e->Id = 0; - if (plci->rx_dma_descriptor > 0) { - diva_free_dma_descriptor (plci, plci->rx_dma_descriptor - 1); - plci->rx_dma_descriptor = 0; - } - } - channel_xmit_xon (plci); - control_rc (plci, 0, rc, ch, global_req, true); - } - else if (plci->data_sent) - { - channel_xmit_xon (plci); - plci->data_sent = false; - plci->NL.XNum = 1; - data_rc (plci, ch); - if (plci->internal_command) - control_rc (plci, req, rc, ch, 0, true); - } - else - { - channel_xmit_xon (plci); - control_rc (plci, req, rc, ch, 0, true); - } - } - } - } - else - { - /* - If REMOVE request was sent then we have to wait until - return code with Id set to zero arrives. - All other return codes should be ignored. - */ - if (req == REMOVE) - { - if (e->Id) - { - dbug(1,dprintf("cancel RC in REMOVE state")); - return; - } - plci->sig_remove_id = 0; - } - plci->sig_req = 0; - if (plci->sig_global_req) - { - global_req = plci->sig_global_req; - plci->sig_global_req = 0; - if (rc != ASSIGN_OK) - e->Id = 0; - channel_xmit_xon (plci); - control_rc (plci, 0, rc, ch, global_req, false); - } - else - { - channel_xmit_xon (plci); - control_rc (plci, req, rc, ch, 0, false); - } - } - /* - Again: in accordance with IDI spec Rc and Ind can't be delivered in the - same callback. Also if new XDI and protocol code used then jump - direct to finish. - */ - if (no_cancel_rc) { - channel_xmit_xon(plci); - goto capi_callback_suffix; - } - } - - channel_xmit_xon(plci); - - if (e->Ind) { - if (e->user[0] &0x8000) { - byte Ind = e->Ind & 0x0f; - byte Ch = e->IndCh; - if (((Ind==N_DISC) || (Ind==N_DISC_ACK)) && - (a->ch_flow_plci[Ch] == plci->Id)) { - if (a->ch_flow_control[Ch] & N_RX_FLOW_CONTROL_MASK) { - dbug(3,dprintf ("XDI CAPI: I: pending N-XON Ch:%02x", Ch)); - } - a->ch_flow_control[Ch] &= ~N_RX_FLOW_CONTROL_MASK; - } - nl_ind(plci); - if ((e->RNR != 1) && - (a->ch_flow_plci[Ch] == plci->Id) && - (a->ch_flow_control[Ch] & N_RX_FLOW_CONTROL_MASK)) { - a->ch_flow_control[Ch] &= ~N_RX_FLOW_CONTROL_MASK; - dbug(3,dprintf ("XDI CAPI: I: remove faked N-XON Ch:%02x", Ch)); - } - } else { - sig_ind(plci); - } - e->Ind = 0; - } +void callback(ENTITY *e) +{ + DIVA_CAPI_ADAPTER *a; + APPL *appl; + PLCI *plci; + CAPI_MSG *m; + word i, j; + byte rc; + byte ch; + byte req; + byte global_req; + int no_cancel_rc; + + dbug(1, dprintf("%x:CB(%x:Req=%x,Rc=%x,Ind=%x)", + (e->user[0] + 1) & 0x7fff, e->Id, e->Req, e->Rc, e->Ind)); + + a = &(adapter[(byte)e->user[0]]); + plci = &(a->plci[e->user[1]]); + no_cancel_rc = DIVA_CAPI_SUPPORTS_NO_CANCEL(a); + + /* + If new protocol code and new XDI is used then CAPI should work + fully in accordance with IDI cpec an look on callback field instead + of Rc field for return codes. + */ + if (((e->complete == 0xff) && no_cancel_rc) || + (e->Rc && !no_cancel_rc)) { + rc = e->Rc; + ch = e->RcCh; + req = e->Req; + e->Rc = 0; + + if (e->user[0] & 0x8000) + { + /* + If REMOVE request was sent then we have to wait until + return code with Id set to zero arrives. + All other return codes should be ignored. + */ + if (req == REMOVE) + { + if (e->Id) + { + dbug(1, dprintf("cancel RC in REMOVE state")); + return; + } + channel_flow_control_remove(plci); + for (i = 0; i < 256; i++) + { + if (a->FlowControlIdTable[i] == plci->nl_remove_id) + a->FlowControlIdTable[i] = 0; + } + plci->nl_remove_id = 0; + if (plci->rx_dma_descriptor > 0) { + diva_free_dma_descriptor(plci, plci->rx_dma_descriptor - 1); + plci->rx_dma_descriptor = 0; + } + } + if (rc == OK_FC) + { + a->FlowControlIdTable[ch] = e->Id; + a->FlowControlSkipTable[ch] = 0; + + a->ch_flow_control[ch] |= N_OK_FC_PENDING; + a->ch_flow_plci[ch] = plci->Id; + plci->nl_req = 0; + } + else + { + /* + Cancel return codes self, if feature was requested + */ + if (no_cancel_rc && (a->FlowControlIdTable[ch] == e->Id) && e->Id) { + a->FlowControlIdTable[ch] = 0; + if ((rc == OK) && a->FlowControlSkipTable[ch]) { + dbug(3, dprintf("XDI CAPI: RC cancelled Id:0x02, Ch:%02x", e->Id, ch)); + return; + } + } + + if (a->ch_flow_control[ch] & N_OK_FC_PENDING) + { + a->ch_flow_control[ch] &= ~N_OK_FC_PENDING; + if (ch == e->ReqCh) + plci->nl_req = 0; + } + else + plci->nl_req = 0; + } + if (plci->nl_req) + control_rc(plci, 0, rc, ch, 0, true); + else + { + if (req == N_XON) + { + channel_x_on(plci, ch); + if (plci->internal_command) + control_rc(plci, req, rc, ch, 0, true); + } + else + { + if (plci->nl_global_req) + { + global_req = plci->nl_global_req; + plci->nl_global_req = 0; + if (rc != ASSIGN_OK) { + e->Id = 0; + if (plci->rx_dma_descriptor > 0) { + diva_free_dma_descriptor(plci, plci->rx_dma_descriptor - 1); + plci->rx_dma_descriptor = 0; + } + } + channel_xmit_xon(plci); + control_rc(plci, 0, rc, ch, global_req, true); + } + else if (plci->data_sent) + { + channel_xmit_xon(plci); + plci->data_sent = false; + plci->NL.XNum = 1; + data_rc(plci, ch); + if (plci->internal_command) + control_rc(plci, req, rc, ch, 0, true); + } + else + { + channel_xmit_xon(plci); + control_rc(plci, req, rc, ch, 0, true); + } + } + } + } + else + { + /* + If REMOVE request was sent then we have to wait until + return code with Id set to zero arrives. + All other return codes should be ignored. + */ + if (req == REMOVE) + { + if (e->Id) + { + dbug(1, dprintf("cancel RC in REMOVE state")); + return; + } + plci->sig_remove_id = 0; + } + plci->sig_req = 0; + if (plci->sig_global_req) + { + global_req = plci->sig_global_req; + plci->sig_global_req = 0; + if (rc != ASSIGN_OK) + e->Id = 0; + channel_xmit_xon(plci); + control_rc(plci, 0, rc, ch, global_req, false); + } + else + { + channel_xmit_xon(plci); + control_rc(plci, req, rc, ch, 0, false); + } + } + /* + Again: in accordance with IDI spec Rc and Ind can't be delivered in the + same callback. Also if new XDI and protocol code used then jump + direct to finish. + */ + if (no_cancel_rc) { + channel_xmit_xon(plci); + goto capi_callback_suffix; + } + } + + channel_xmit_xon(plci); + + if (e->Ind) { + if (e->user[0] & 0x8000) { + byte Ind = e->Ind & 0x0f; + byte Ch = e->IndCh; + if (((Ind == N_DISC) || (Ind == N_DISC_ACK)) && + (a->ch_flow_plci[Ch] == plci->Id)) { + if (a->ch_flow_control[Ch] & N_RX_FLOW_CONTROL_MASK) { + dbug(3, dprintf("XDI CAPI: I: pending N-XON Ch:%02x", Ch)); + } + a->ch_flow_control[Ch] &= ~N_RX_FLOW_CONTROL_MASK; + } + nl_ind(plci); + if ((e->RNR != 1) && + (a->ch_flow_plci[Ch] == plci->Id) && + (a->ch_flow_control[Ch] & N_RX_FLOW_CONTROL_MASK)) { + a->ch_flow_control[Ch] &= ~N_RX_FLOW_CONTROL_MASK; + dbug(3, dprintf("XDI CAPI: I: remove faked N-XON Ch:%02x", Ch)); + } + } else { + sig_ind(plci); + } + e->Ind = 0; + } capi_callback_suffix: - while (!plci->req_in - && !plci->internal_command - && (plci->msg_in_write_pos != plci->msg_in_read_pos)) - { - j = (plci->msg_in_read_pos == plci->msg_in_wrap_pos) ? 0 : plci->msg_in_read_pos; - - i = (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[j]))->header.length + 3) & 0xfffc; - - m = (CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[j]); - appl = *((APPL * *)(&((byte *)(plci->msg_in_queue))[j+i])); - dbug(1,dprintf("dequeue msg(0x%04x) - write=%d read=%d wrap=%d", - m->header.command, plci->msg_in_write_pos, plci->msg_in_read_pos, plci->msg_in_wrap_pos)); - if (plci->msg_in_read_pos == plci->msg_in_wrap_pos) - { - plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_read_pos = i + MSG_IN_OVERHEAD; - } - else - { - plci->msg_in_read_pos = j + i + MSG_IN_OVERHEAD; - } - if (plci->msg_in_read_pos == plci->msg_in_write_pos) - { - plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; - } - else if (plci->msg_in_read_pos == plci->msg_in_wrap_pos) - { - plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; - } - i = api_put (appl, m); - if (i != 0) - { - if (m->header.command == _DATA_B3_R) - - TransmitBufferFree (appl, (byte *)(long)(m->info.data_b3_req.Data)); - - dbug(1,dprintf("Error 0x%04x from msg(0x%04x)", i, m->header.command)); - break; - } - - if (plci->li_notify_update) - { - plci->li_notify_update = false; - mixer_notify_update (plci, false); - } - - } - send_data(plci); - send_req(plci); + while (!plci->req_in + && !plci->internal_command + && (plci->msg_in_write_pos != plci->msg_in_read_pos)) + { + j = (plci->msg_in_read_pos == plci->msg_in_wrap_pos) ? 0 : plci->msg_in_read_pos; + + i = (((CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[j]))->header.length + 3) & 0xfffc; + + m = (CAPI_MSG *)(&((byte *)(plci->msg_in_queue))[j]); + appl = *((APPL **)(&((byte *)(plci->msg_in_queue))[j + i])); + dbug(1, dprintf("dequeue msg(0x%04x) - write=%d read=%d wrap=%d", + m->header.command, plci->msg_in_write_pos, plci->msg_in_read_pos, plci->msg_in_wrap_pos)); + if (plci->msg_in_read_pos == plci->msg_in_wrap_pos) + { + plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_read_pos = i + MSG_IN_OVERHEAD; + } + else + { + plci->msg_in_read_pos = j + i + MSG_IN_OVERHEAD; + } + if (plci->msg_in_read_pos == plci->msg_in_write_pos) + { + plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; + } + else if (plci->msg_in_read_pos == plci->msg_in_wrap_pos) + { + plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; + } + i = api_put(appl, m); + if (i != 0) + { + if (m->header.command == _DATA_B3_R) + + TransmitBufferFree(appl, (byte *)(long)(m->info.data_b3_req.Data)); + + dbug(1, dprintf("Error 0x%04x from msg(0x%04x)", i, m->header.command)); + break; + } + + if (plci->li_notify_update) + { + plci->li_notify_update = false; + mixer_notify_update(plci, false); + } + + } + send_data(plci); + send_req(plci); } static void control_rc(PLCI *plci, byte req, byte rc, byte ch, byte global_req, byte nl_rc) { - dword Id; - dword rId; - word Number; - word Info=0; - word i; - word ncci; - DIVA_CAPI_ADAPTER * a; - APPL * appl; - PLCI * rplci; - byte SSparms[] = "\x05\x00\x00\x02\x00\x00"; - byte SSstruct[] = "\x09\x00\x00\x06\x00\x00\x00\x00\x00\x00"; - - if (!plci) { - dbug(0,dprintf("A: control_rc, no plci %02x:%02x:%02x:%02x:%02x", req, rc, ch, global_req, nl_rc)); - return; - } - dbug(1,dprintf("req0_in/out=%d/%d",plci->req_in,plci->req_out)); - if(plci->req_in!=plci->req_out) - { - if (nl_rc || (global_req != ASSIGN) || (rc == ASSIGN_OK)) - { - dbug(1,dprintf("req_1return")); - return; - } - /* cancel outstanding request on the PLCI after SIG ASSIGN failure */ - } - plci->req_in = plci->req_in_start = plci->req_out = 0; - dbug(1,dprintf("control_rc")); - - appl = plci->appl; - a = plci->adapter; - ncci = a->ch_ncci[ch]; - if(appl) - { - Id = (((dword)(ncci ? ncci : ch)) << 16) | ((word)plci->Id << 8) | a->Id; - if(plci->tel && plci->SuppState!=CALL_HELD) Id|=EXT_CONTROLLER; - Number = plci->number; - dbug(1,dprintf("Contr_RC-Id=%08lx,plci=%x,tel=%x, entity=0x%x, command=0x%x, int_command=0x%x",Id,plci->Id,plci->tel,plci->Sig.Id,plci->command,plci->internal_command)); - dbug(1,dprintf("channels=0x%x",plci->channels)); - if (plci_remove_check(plci)) - return; - if(req==REMOVE && rc==ASSIGN_OK) - { - sig_req(plci,HANGUP,0); - sig_req(plci,REMOVE,0); - send_req(plci); - } - if(plci->command) - { - switch(plci->command) - { - case C_HOLD_REQ: - dbug(1,dprintf("HoldRC=0x%x",rc)); - SSparms[1] = (byte)S_HOLD; - if(rc!=OK) - { - plci->SuppState = IDLE; - Info = 0x2001; - } - sendf(appl,_FACILITY_R|CONFIRM,Id,Number,"wws",Info,3,SSparms); - break; - - case C_RETRIEVE_REQ: - dbug(1,dprintf("RetrieveRC=0x%x",rc)); - SSparms[1] = (byte)S_RETRIEVE; - if(rc!=OK) - { - plci->SuppState = CALL_HELD; - Info = 0x2001; - } - sendf(appl,_FACILITY_R|CONFIRM,Id,Number,"wws",Info,3,SSparms); - break; - - case _INFO_R: - dbug(1,dprintf("InfoRC=0x%x",rc)); - if(rc!=OK) Info=_WRONG_STATE; - sendf(appl,_INFO_R|CONFIRM,Id,Number,"w",Info); - break; - - case _CONNECT_R: - dbug(1,dprintf("Connect_R=0x%x/0x%x/0x%x/0x%x",req,rc,global_req,nl_rc)); - if (plci->State == INC_DIS_PENDING) - break; - if(plci->Sig.Id!=0xff) - { - if (((global_req == ASSIGN) && (rc != ASSIGN_OK)) - || (!nl_rc && (req == CALL_REQ) && (rc != OK))) - { - dbug(1,dprintf("No more IDs/Call_Req failed")); - sendf(appl,_CONNECT_R|CONFIRM,Id&0xffL,Number,"w",_OUT_OF_PLCI); - plci_remove(plci); - plci->State = IDLE; - break; - } - if(plci->State!=LOCAL_CONNECT)plci->State = OUTG_CON_PENDING; - sendf(appl,_CONNECT_R|CONFIRM,Id,Number,"w",0); - } - else /* D-ch activation */ - { - if (rc != ASSIGN_OK) - { - dbug(1,dprintf("No more IDs/X.25 Call_Req failed")); - sendf(appl,_CONNECT_R|CONFIRM,Id&0xffL,Number,"w",_OUT_OF_PLCI); - plci_remove(plci); - plci->State = IDLE; - break; - } - sendf(appl,_CONNECT_R|CONFIRM,Id,Number,"w",0); - sendf(plci->appl,_CONNECT_ACTIVE_I,Id,0,"sss","","",""); - plci->State = INC_ACT_PENDING; - } - break; - - case _CONNECT_I|RESPONSE: - if (plci->State != INC_DIS_PENDING) - plci->State = INC_CON_ACCEPT; - break; - - case _DISCONNECT_R: - if (plci->State == INC_DIS_PENDING) - break; - if(plci->Sig.Id!=0xff) - { - plci->State = OUTG_DIS_PENDING; - sendf(appl,_DISCONNECT_R|CONFIRM,Id,Number,"w",0); - } - break; - - case SUSPEND_REQ: - break; - - case RESUME_REQ: - break; - - case _CONNECT_B3_R: - if(rc!=OK) - { - sendf(appl,_CONNECT_B3_R|CONFIRM,Id,Number,"w",_WRONG_IDENTIFIER); - break; - } - ncci = get_ncci (plci, ch, 0); - Id = (Id & 0xffff) | (((dword) ncci) << 16); - plci->channels++; - if(req==N_RESET) - { - a->ncci_state[ncci] = INC_ACT_PENDING; - sendf(appl,_CONNECT_B3_R|CONFIRM,Id,Number,"w",0); - sendf(appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - } - else - { - a->ncci_state[ncci] = OUTG_CON_PENDING; - sendf(appl,_CONNECT_B3_R|CONFIRM,Id,Number,"w",0); - } - break; - - case _CONNECT_B3_I|RESPONSE: - break; - - case _RESET_B3_R: -/* sendf(appl,_RESET_B3_R|CONFIRM,Id,Number,"w",0);*/ - break; - - case _DISCONNECT_B3_R: - sendf(appl,_DISCONNECT_B3_R|CONFIRM,Id,Number,"w",0); - break; - - case _MANUFACTURER_R: - break; - - case PERM_LIST_REQ: - if(rc!=OK) - { - Info = _WRONG_IDENTIFIER; - sendf(plci->appl,_CONNECT_R|CONFIRM,Id,Number,"w",Info); - plci_remove(plci); - } - else - sendf(plci->appl,_CONNECT_R|CONFIRM,Id,Number,"w",Info); - break; - - default: - break; - } - plci->command = 0; - } - else if (plci->internal_command) - { - switch(plci->internal_command) - { - case BLOCK_PLCI: - return; - - case GET_MWI_STATE: - if(rc==OK) /* command supported, wait for indication */ - { - return; - } - plci_remove(plci); - break; - - /* Get Supported Services */ - case GETSERV_REQ_PEND: - if(rc==OK) /* command supported, wait for indication */ - { - break; - } - PUT_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY); - sendf(appl, _FACILITY_R|CONFIRM, Id, Number, "wws",0,3,SSstruct); - plci_remove(plci); - break; - - case INTERR_DIVERSION_REQ_PEND: /* Interrogate Parameters */ - case INTERR_NUMBERS_REQ_PEND: - case CF_START_PEND: /* Call Forwarding Start pending */ - case CF_STOP_PEND: /* Call Forwarding Stop pending */ - case CCBS_REQUEST_REQ_PEND: - case CCBS_DEACTIVATE_REQ_PEND: - case CCBS_INTERROGATE_REQ_PEND: - switch(plci->internal_command) - { - case INTERR_DIVERSION_REQ_PEND: - SSparms[1] = S_INTERROGATE_DIVERSION; - break; - case INTERR_NUMBERS_REQ_PEND: - SSparms[1] = S_INTERROGATE_NUMBERS; - break; - case CF_START_PEND: - SSparms[1] = S_CALL_FORWARDING_START; - break; - case CF_STOP_PEND: - SSparms[1] = S_CALL_FORWARDING_STOP; - break; - case CCBS_REQUEST_REQ_PEND: - SSparms[1] = S_CCBS_REQUEST; - break; - case CCBS_DEACTIVATE_REQ_PEND: - SSparms[1] = S_CCBS_DEACTIVATE; - break; - case CCBS_INTERROGATE_REQ_PEND: - SSparms[1] = S_CCBS_INTERROGATE; - break; - } - if(global_req==ASSIGN) - { - dbug(1,dprintf("AssignDiversion_RC=0x%x/0x%x",req,rc)); - return; - } - if(!plci->appl) break; - if(rc==ISDN_GUARD_REJ) - { - Info = _CAPI_GUARD_ERROR; - } - else if(rc!=OK) - { - Info = _SUPPLEMENTARY_SERVICE_NOT_SUPPORTED; - } - sendf(plci->appl,_FACILITY_R|CONFIRM,Id&0x7, - plci->number,"wws",Info,(word)3,SSparms); - if(Info) plci_remove(plci); - break; - - /* 3pty conference pending */ - case PTY_REQ_PEND: - if(!plci->relatedPTYPLCI) break; - rplci = plci->relatedPTYPLCI; - SSparms[1] = plci->ptyState; - rId = ((word)rplci->Id<<8)|rplci->adapter->Id; - if(rplci->tel) rId|=EXT_CONTROLLER; - if(rc!=OK) - { - Info = 0x300E; /* not supported */ - plci->relatedPTYPLCI = NULL; - plci->ptyState = 0; - } - sendf(rplci->appl, - _FACILITY_R|CONFIRM, - rId, - plci->number, - "wws",Info,(word)3,SSparms); - break; - - /* Explicit Call Transfer pending */ - case ECT_REQ_PEND: - dbug(1,dprintf("ECT_RC=0x%x/0x%x",req,rc)); - if(!plci->relatedPTYPLCI) break; - rplci = plci->relatedPTYPLCI; - SSparms[1] = S_ECT; - rId = ((word)rplci->Id<<8)|rplci->adapter->Id; - if(rplci->tel) rId|=EXT_CONTROLLER; - if(rc!=OK) - { - Info = 0x300E; /* not supported */ - plci->relatedPTYPLCI = NULL; - plci->ptyState = 0; - } - sendf(rplci->appl, - _FACILITY_R|CONFIRM, - rId, - plci->number, - "wws",Info,(word)3,SSparms); - break; - - case _MANUFACTURER_R: - dbug(1,dprintf("_Manufacturer_R=0x%x/0x%x",req,rc)); - if ((global_req == ASSIGN) && (rc != ASSIGN_OK)) - { - dbug(1,dprintf("No more IDs")); - sendf(appl,_MANUFACTURER_R|CONFIRM,Id,Number,"dww",_DI_MANU_ID,_MANUFACTURER_R,_OUT_OF_PLCI); - plci_remove(plci); /* after codec init, internal codec commands pending */ - } - break; - - case _CONNECT_R: - dbug(1,dprintf("_Connect_R=0x%x/0x%x",req,rc)); - if ((global_req == ASSIGN) && (rc != ASSIGN_OK)) - { - dbug(1,dprintf("No more IDs")); - sendf(appl,_CONNECT_R|CONFIRM,Id&0xffL,Number,"w",_OUT_OF_PLCI); - plci_remove(plci); /* after codec init, internal codec commands pending */ - } - break; - - case PERM_COD_HOOK: /* finished with Hook_Ind */ - return; - - case PERM_COD_CALL: - dbug(1,dprintf("***Codec Connect_Pending A, Rc = 0x%x",rc)); - plci->internal_command = PERM_COD_CONN_PEND; - return; - - case PERM_COD_ASSIGN: - dbug(1,dprintf("***Codec Assign A, Rc = 0x%x",rc)); - if(rc!=ASSIGN_OK) break; - sig_req(plci,CALL_REQ,0); - send_req(plci); - plci->internal_command = PERM_COD_CALL; - return; - - /* Null Call Reference Request pending */ - case C_NCR_FAC_REQ: - dbug(1,dprintf("NCR_FAC=0x%x/0x%x",req,rc)); - if(global_req==ASSIGN) - { - if(rc==ASSIGN_OK) - { - return; - } - else - { - sendf(appl,_INFO_R|CONFIRM,Id&0xf,Number,"w",_WRONG_STATE); - appl->NullCREnable = false; - plci_remove(plci); - } - } - else if(req==NCR_FACILITY) - { - if(rc==OK) - { - sendf(appl,_INFO_R|CONFIRM,Id&0xf,Number,"w",0); - } - else - { - sendf(appl,_INFO_R|CONFIRM,Id&0xf,Number,"w",_WRONG_STATE); - appl->NullCREnable = false; - } - plci_remove(plci); - } - break; - - case HOOK_ON_REQ: - if(plci->channels) - { - if(a->ncci_state[ncci]==CONNECTED) - { - a->ncci_state[ncci] = OUTG_DIS_PENDING; - cleanup_ncci_data (plci, ncci); - nl_req_ncci(plci,N_DISC,(byte)ncci); - } - break; - } - break; - - case HOOK_OFF_REQ: - if (plci->State == INC_DIS_PENDING) - break; - sig_req(plci,CALL_REQ,0); - send_req(plci); - plci->State=OUTG_CON_PENDING; - break; - - - case MWI_ACTIVATE_REQ_PEND: - case MWI_DEACTIVATE_REQ_PEND: - if(global_req == ASSIGN && rc==ASSIGN_OK) - { - dbug(1,dprintf("MWI_REQ assigned")); - return; - } - else if(rc!=OK) - { - if(rc==WRONG_IE) - { - Info = 0x2007; /* Illegal message parameter coding */ - dbug(1,dprintf("MWI_REQ invalid parameter")); - } - else - { - Info = 0x300B; /* not supported */ - dbug(1,dprintf("MWI_REQ not supported")); - } - /* 0x3010: Request not allowed in this state */ - PUT_WORD(&SSparms[4],0x300E); /* SS not supported */ - - } - if(plci->internal_command==MWI_ACTIVATE_REQ_PEND) - { - PUT_WORD(&SSparms[1],S_MWI_ACTIVATE); - } - else PUT_WORD(&SSparms[1],S_MWI_DEACTIVATE); - - if(plci->cr_enquiry) - { - sendf(plci->appl, - _FACILITY_R|CONFIRM, - Id&0xf, - plci->number, - "wws",Info,(word)3,SSparms); - if(rc!=OK) plci_remove(plci); - } - else - { - sendf(plci->appl, - _FACILITY_R|CONFIRM, - Id, - plci->number, - "wws",Info,(word)3,SSparms); - } - break; - - case CONF_BEGIN_REQ_PEND: - case CONF_ADD_REQ_PEND: - case CONF_SPLIT_REQ_PEND: - case CONF_DROP_REQ_PEND: - case CONF_ISOLATE_REQ_PEND: - case CONF_REATTACH_REQ_PEND: - dbug(1,dprintf("CONF_RC=0x%x/0x%x",req,rc)); - if((plci->internal_command==CONF_ADD_REQ_PEND)&&(!plci->relatedPTYPLCI)) break; - rplci = plci; - rId = Id; - switch(plci->internal_command) - { - case CONF_BEGIN_REQ_PEND: - SSparms[1] = S_CONF_BEGIN; - break; - case CONF_ADD_REQ_PEND: - SSparms[1] = S_CONF_ADD; - rplci = plci->relatedPTYPLCI; - rId = ((word)rplci->Id<<8)|rplci->adapter->Id; - break; - case CONF_SPLIT_REQ_PEND: - SSparms[1] = S_CONF_SPLIT; - break; - case CONF_DROP_REQ_PEND: - SSparms[1] = S_CONF_DROP; - break; - case CONF_ISOLATE_REQ_PEND: - SSparms[1] = S_CONF_ISOLATE; - break; - case CONF_REATTACH_REQ_PEND: - SSparms[1] = S_CONF_REATTACH; - break; - } - - if(rc!=OK) - { - Info = 0x300E; /* not supported */ - plci->relatedPTYPLCI = NULL; - plci->ptyState = 0; - } - sendf(rplci->appl, - _FACILITY_R|CONFIRM, - rId, - plci->number, - "wws",Info,(word)3,SSparms); - break; - - case VSWITCH_REQ_PEND: - if(rc!=OK) - { - if(plci->relatedPTYPLCI) - { - plci->relatedPTYPLCI->vswitchstate=0; - plci->relatedPTYPLCI->vsprot=0; - plci->relatedPTYPLCI->vsprotdialect=0; - } - plci->vswitchstate=0; - plci->vsprot=0; - plci->vsprotdialect=0; - } - else - { - if(plci->relatedPTYPLCI && - plci->vswitchstate==1 && - plci->relatedPTYPLCI->vswitchstate==3) /* join complete */ - plci->vswitchstate=3; - } - break; - - /* Call Deflection Request pending (SSCT) */ - case CD_REQ_PEND: - SSparms[1] = S_CALL_DEFLECTION; - if(rc!=OK) - { - Info = 0x300E; /* not supported */ - plci->appl->CDEnable = 0; - } - sendf(plci->appl,_FACILITY_R|CONFIRM,Id, - plci->number,"wws",Info,(word)3,SSparms); - break; - - case RTP_CONNECT_B3_REQ_COMMAND_2: - if (rc == OK) - { - ncci = get_ncci (plci, ch, 0); - Id = (Id & 0xffff) | (((dword) ncci) << 16); - plci->channels++; - a->ncci_state[ncci] = OUTG_CON_PENDING; - } - - default: - if (plci->internal_command_queue[0]) - { - (*(plci->internal_command_queue[0]))(Id, plci, rc); - if (plci->internal_command) - return; - } - break; - } - next_internal_command (Id, plci); - } - } - else /* appl==0 */ - { - Id = ((word)plci->Id<<8)|plci->adapter->Id; - if(plci->tel) Id|=EXT_CONTROLLER; - - switch(plci->internal_command) - { - case BLOCK_PLCI: - return; - - case START_L1_SIG_ASSIGN_PEND: - case REM_L1_SIG_ASSIGN_PEND: - if(global_req == ASSIGN) - { - break; - } - else - { - dbug(1,dprintf("***L1 Req rem PLCI")); - plci->internal_command = 0; - sig_req(plci,REMOVE,0); - send_req(plci); - } - break; - - /* Call Deflection Request pending, just no appl ptr assigned */ - case CD_REQ_PEND: - SSparms[1] = S_CALL_DEFLECTION; - if(rc!=OK) - { - Info = 0x300E; /* not supported */ - } - for(i=0; inumber,"wws",Info,(word)3,SSparms); - if(Info) application[i].CDEnable = 0; - } - } - } - plci->internal_command = 0; - break; - - case PERM_COD_HOOK: /* finished with Hook_Ind */ - return; - - case PERM_COD_CALL: - plci->internal_command = PERM_COD_CONN_PEND; - dbug(1,dprintf("***Codec Connect_Pending, Rc = 0x%x",rc)); - return; - - case PERM_COD_ASSIGN: - dbug(1,dprintf("***Codec Assign, Rc = 0x%x",rc)); - plci->internal_command = 0; - if(rc!=ASSIGN_OK) break; - plci->internal_command = PERM_COD_CALL; - sig_req(plci,CALL_REQ,0); - send_req(plci); - return; - - case LISTEN_SIG_ASSIGN_PEND: - if(rc == ASSIGN_OK) - { - plci->internal_command = 0; - dbug(1,dprintf("ListenCheck, new SIG_ID = 0x%x",plci->Sig.Id)); - add_p(plci,ESC,"\x02\x18\x00"); /* support call waiting */ - sig_req(plci,INDICATE_REQ,0); - send_req(plci); - } - else - { - dbug(1,dprintf("ListenCheck failed (assignRc=0x%x)",rc)); - a->listen_active--; - plci_remove(plci); - plci->State = IDLE; - } - break; - - case USELAW_REQ: - if(global_req == ASSIGN) - { - if (rc==ASSIGN_OK) - { - sig_req(plci,LAW_REQ,0); - send_req(plci); - dbug(1,dprintf("Auto-Law assigned")); - } - else - { - dbug(1,dprintf("Auto-Law assign failed")); - a->automatic_law = 3; - plci->internal_command = 0; - a->automatic_lawPLCI = NULL; - } - break; - } - else if(req == LAW_REQ && rc==OK) - { - dbug(1,dprintf("Auto-Law initiated")); - a->automatic_law = 2; - plci->internal_command = 0; - } - else - { - dbug(1,dprintf("Auto-Law not supported")); - a->automatic_law = 3; - plci->internal_command = 0; - sig_req(plci,REMOVE,0); - send_req(plci); - a->automatic_lawPLCI = NULL; - } - break; - } - plci_remove_check(plci); - } + dword Id; + dword rId; + word Number; + word Info = 0; + word i; + word ncci; + DIVA_CAPI_ADAPTER *a; + APPL *appl; + PLCI *rplci; + byte SSparms[] = "\x05\x00\x00\x02\x00\x00"; + byte SSstruct[] = "\x09\x00\x00\x06\x00\x00\x00\x00\x00\x00"; + + if (!plci) { + dbug(0, dprintf("A: control_rc, no plci %02x:%02x:%02x:%02x:%02x", req, rc, ch, global_req, nl_rc)); + return; + } + dbug(1, dprintf("req0_in/out=%d/%d", plci->req_in, plci->req_out)); + if (plci->req_in != plci->req_out) + { + if (nl_rc || (global_req != ASSIGN) || (rc == ASSIGN_OK)) + { + dbug(1, dprintf("req_1return")); + return; + } + /* cancel outstanding request on the PLCI after SIG ASSIGN failure */ + } + plci->req_in = plci->req_in_start = plci->req_out = 0; + dbug(1, dprintf("control_rc")); + + appl = plci->appl; + a = plci->adapter; + ncci = a->ch_ncci[ch]; + if (appl) + { + Id = (((dword)(ncci ? ncci : ch)) << 16) | ((word)plci->Id << 8) | a->Id; + if (plci->tel && plci->SuppState != CALL_HELD) Id |= EXT_CONTROLLER; + Number = plci->number; + dbug(1, dprintf("Contr_RC-Id=%08lx,plci=%x,tel=%x, entity=0x%x, command=0x%x, int_command=0x%x", Id, plci->Id, plci->tel, plci->Sig.Id, plci->command, plci->internal_command)); + dbug(1, dprintf("channels=0x%x", plci->channels)); + if (plci_remove_check(plci)) + return; + if (req == REMOVE && rc == ASSIGN_OK) + { + sig_req(plci, HANGUP, 0); + sig_req(plci, REMOVE, 0); + send_req(plci); + } + if (plci->command) + { + switch (plci->command) + { + case C_HOLD_REQ: + dbug(1, dprintf("HoldRC=0x%x", rc)); + SSparms[1] = (byte)S_HOLD; + if (rc != OK) + { + plci->SuppState = IDLE; + Info = 0x2001; + } + sendf(appl, _FACILITY_R | CONFIRM, Id, Number, "wws", Info, 3, SSparms); + break; + + case C_RETRIEVE_REQ: + dbug(1, dprintf("RetrieveRC=0x%x", rc)); + SSparms[1] = (byte)S_RETRIEVE; + if (rc != OK) + { + plci->SuppState = CALL_HELD; + Info = 0x2001; + } + sendf(appl, _FACILITY_R | CONFIRM, Id, Number, "wws", Info, 3, SSparms); + break; + + case _INFO_R: + dbug(1, dprintf("InfoRC=0x%x", rc)); + if (rc != OK) Info = _WRONG_STATE; + sendf(appl, _INFO_R | CONFIRM, Id, Number, "w", Info); + break; + + case _CONNECT_R: + dbug(1, dprintf("Connect_R=0x%x/0x%x/0x%x/0x%x", req, rc, global_req, nl_rc)); + if (plci->State == INC_DIS_PENDING) + break; + if (plci->Sig.Id != 0xff) + { + if (((global_req == ASSIGN) && (rc != ASSIGN_OK)) + || (!nl_rc && (req == CALL_REQ) && (rc != OK))) + { + dbug(1, dprintf("No more IDs/Call_Req failed")); + sendf(appl, _CONNECT_R | CONFIRM, Id & 0xffL, Number, "w", _OUT_OF_PLCI); + plci_remove(plci); + plci->State = IDLE; + break; + } + if (plci->State != LOCAL_CONNECT) plci->State = OUTG_CON_PENDING; + sendf(appl, _CONNECT_R | CONFIRM, Id, Number, "w", 0); + } + else /* D-ch activation */ + { + if (rc != ASSIGN_OK) + { + dbug(1, dprintf("No more IDs/X.25 Call_Req failed")); + sendf(appl, _CONNECT_R | CONFIRM, Id & 0xffL, Number, "w", _OUT_OF_PLCI); + plci_remove(plci); + plci->State = IDLE; + break; + } + sendf(appl, _CONNECT_R | CONFIRM, Id, Number, "w", 0); + sendf(plci->appl, _CONNECT_ACTIVE_I, Id, 0, "sss", "", "", ""); + plci->State = INC_ACT_PENDING; + } + break; + + case _CONNECT_I | RESPONSE: + if (plci->State != INC_DIS_PENDING) + plci->State = INC_CON_ACCEPT; + break; + + case _DISCONNECT_R: + if (plci->State == INC_DIS_PENDING) + break; + if (plci->Sig.Id != 0xff) + { + plci->State = OUTG_DIS_PENDING; + sendf(appl, _DISCONNECT_R | CONFIRM, Id, Number, "w", 0); + } + break; + + case SUSPEND_REQ: + break; + + case RESUME_REQ: + break; + + case _CONNECT_B3_R: + if (rc != OK) + { + sendf(appl, _CONNECT_B3_R | CONFIRM, Id, Number, "w", _WRONG_IDENTIFIER); + break; + } + ncci = get_ncci(plci, ch, 0); + Id = (Id & 0xffff) | (((dword) ncci) << 16); + plci->channels++; + if (req == N_RESET) + { + a->ncci_state[ncci] = INC_ACT_PENDING; + sendf(appl, _CONNECT_B3_R | CONFIRM, Id, Number, "w", 0); + sendf(appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + } + else + { + a->ncci_state[ncci] = OUTG_CON_PENDING; + sendf(appl, _CONNECT_B3_R | CONFIRM, Id, Number, "w", 0); + } + break; + + case _CONNECT_B3_I | RESPONSE: + break; + + case _RESET_B3_R: +/* sendf(appl, _RESET_B3_R | CONFIRM, Id, Number, "w", 0);*/ + break; + + case _DISCONNECT_B3_R: + sendf(appl, _DISCONNECT_B3_R | CONFIRM, Id, Number, "w", 0); + break; + + case _MANUFACTURER_R: + break; + + case PERM_LIST_REQ: + if (rc != OK) + { + Info = _WRONG_IDENTIFIER; + sendf(plci->appl, _CONNECT_R | CONFIRM, Id, Number, "w", Info); + plci_remove(plci); + } + else + sendf(plci->appl, _CONNECT_R | CONFIRM, Id, Number, "w", Info); + break; + + default: + break; + } + plci->command = 0; + } + else if (plci->internal_command) + { + switch (plci->internal_command) + { + case BLOCK_PLCI: + return; + + case GET_MWI_STATE: + if (rc == OK) /* command supported, wait for indication */ + { + return; + } + plci_remove(plci); + break; + + /* Get Supported Services */ + case GETSERV_REQ_PEND: + if (rc == OK) /* command supported, wait for indication */ + { + break; + } + PUT_DWORD(&SSstruct[6], MASK_TERMINAL_PORTABILITY); + sendf(appl, _FACILITY_R | CONFIRM, Id, Number, "wws", 0, 3, SSstruct); + plci_remove(plci); + break; + + case INTERR_DIVERSION_REQ_PEND: /* Interrogate Parameters */ + case INTERR_NUMBERS_REQ_PEND: + case CF_START_PEND: /* Call Forwarding Start pending */ + case CF_STOP_PEND: /* Call Forwarding Stop pending */ + case CCBS_REQUEST_REQ_PEND: + case CCBS_DEACTIVATE_REQ_PEND: + case CCBS_INTERROGATE_REQ_PEND: + switch (plci->internal_command) + { + case INTERR_DIVERSION_REQ_PEND: + SSparms[1] = S_INTERROGATE_DIVERSION; + break; + case INTERR_NUMBERS_REQ_PEND: + SSparms[1] = S_INTERROGATE_NUMBERS; + break; + case CF_START_PEND: + SSparms[1] = S_CALL_FORWARDING_START; + break; + case CF_STOP_PEND: + SSparms[1] = S_CALL_FORWARDING_STOP; + break; + case CCBS_REQUEST_REQ_PEND: + SSparms[1] = S_CCBS_REQUEST; + break; + case CCBS_DEACTIVATE_REQ_PEND: + SSparms[1] = S_CCBS_DEACTIVATE; + break; + case CCBS_INTERROGATE_REQ_PEND: + SSparms[1] = S_CCBS_INTERROGATE; + break; + } + if (global_req == ASSIGN) + { + dbug(1, dprintf("AssignDiversion_RC=0x%x/0x%x", req, rc)); + return; + } + if (!plci->appl) break; + if (rc == ISDN_GUARD_REJ) + { + Info = _CAPI_GUARD_ERROR; + } + else if (rc != OK) + { + Info = _SUPPLEMENTARY_SERVICE_NOT_SUPPORTED; + } + sendf(plci->appl, _FACILITY_R | CONFIRM, Id & 0x7, + plci->number, "wws", Info, (word)3, SSparms); + if (Info) plci_remove(plci); + break; + + /* 3pty conference pending */ + case PTY_REQ_PEND: + if (!plci->relatedPTYPLCI) break; + rplci = plci->relatedPTYPLCI; + SSparms[1] = plci->ptyState; + rId = ((word)rplci->Id << 8) | rplci->adapter->Id; + if (rplci->tel) rId |= EXT_CONTROLLER; + if (rc != OK) + { + Info = 0x300E; /* not supported */ + plci->relatedPTYPLCI = NULL; + plci->ptyState = 0; + } + sendf(rplci->appl, + _FACILITY_R | CONFIRM, + rId, + plci->number, + "wws", Info, (word)3, SSparms); + break; + + /* Explicit Call Transfer pending */ + case ECT_REQ_PEND: + dbug(1, dprintf("ECT_RC=0x%x/0x%x", req, rc)); + if (!plci->relatedPTYPLCI) break; + rplci = plci->relatedPTYPLCI; + SSparms[1] = S_ECT; + rId = ((word)rplci->Id << 8) | rplci->adapter->Id; + if (rplci->tel) rId |= EXT_CONTROLLER; + if (rc != OK) + { + Info = 0x300E; /* not supported */ + plci->relatedPTYPLCI = NULL; + plci->ptyState = 0; + } + sendf(rplci->appl, + _FACILITY_R | CONFIRM, + rId, + plci->number, + "wws", Info, (word)3, SSparms); + break; + + case _MANUFACTURER_R: + dbug(1, dprintf("_Manufacturer_R=0x%x/0x%x", req, rc)); + if ((global_req == ASSIGN) && (rc != ASSIGN_OK)) + { + dbug(1, dprintf("No more IDs")); + sendf(appl, _MANUFACTURER_R | CONFIRM, Id, Number, "dww", _DI_MANU_ID, _MANUFACTURER_R, _OUT_OF_PLCI); + plci_remove(plci); /* after codec init, internal codec commands pending */ + } + break; + + case _CONNECT_R: + dbug(1, dprintf("_Connect_R=0x%x/0x%x", req, rc)); + if ((global_req == ASSIGN) && (rc != ASSIGN_OK)) + { + dbug(1, dprintf("No more IDs")); + sendf(appl, _CONNECT_R | CONFIRM, Id & 0xffL, Number, "w", _OUT_OF_PLCI); + plci_remove(plci); /* after codec init, internal codec commands pending */ + } + break; + + case PERM_COD_HOOK: /* finished with Hook_Ind */ + return; + + case PERM_COD_CALL: + dbug(1, dprintf("***Codec Connect_Pending A, Rc = 0x%x", rc)); + plci->internal_command = PERM_COD_CONN_PEND; + return; + + case PERM_COD_ASSIGN: + dbug(1, dprintf("***Codec Assign A, Rc = 0x%x", rc)); + if (rc != ASSIGN_OK) break; + sig_req(plci, CALL_REQ, 0); + send_req(plci); + plci->internal_command = PERM_COD_CALL; + return; + + /* Null Call Reference Request pending */ + case C_NCR_FAC_REQ: + dbug(1, dprintf("NCR_FAC=0x%x/0x%x", req, rc)); + if (global_req == ASSIGN) + { + if (rc == ASSIGN_OK) + { + return; + } + else + { + sendf(appl, _INFO_R | CONFIRM, Id & 0xf, Number, "w", _WRONG_STATE); + appl->NullCREnable = false; + plci_remove(plci); + } + } + else if (req == NCR_FACILITY) + { + if (rc == OK) + { + sendf(appl, _INFO_R | CONFIRM, Id & 0xf, Number, "w", 0); + } + else + { + sendf(appl, _INFO_R | CONFIRM, Id & 0xf, Number, "w", _WRONG_STATE); + appl->NullCREnable = false; + } + plci_remove(plci); + } + break; + + case HOOK_ON_REQ: + if (plci->channels) + { + if (a->ncci_state[ncci] == CONNECTED) + { + a->ncci_state[ncci] = OUTG_DIS_PENDING; + cleanup_ncci_data(plci, ncci); + nl_req_ncci(plci, N_DISC, (byte)ncci); + } + break; + } + break; + + case HOOK_OFF_REQ: + if (plci->State == INC_DIS_PENDING) + break; + sig_req(plci, CALL_REQ, 0); + send_req(plci); + plci->State = OUTG_CON_PENDING; + break; + + + case MWI_ACTIVATE_REQ_PEND: + case MWI_DEACTIVATE_REQ_PEND: + if (global_req == ASSIGN && rc == ASSIGN_OK) + { + dbug(1, dprintf("MWI_REQ assigned")); + return; + } + else if (rc != OK) + { + if (rc == WRONG_IE) + { + Info = 0x2007; /* Illegal message parameter coding */ + dbug(1, dprintf("MWI_REQ invalid parameter")); + } + else + { + Info = 0x300B; /* not supported */ + dbug(1, dprintf("MWI_REQ not supported")); + } + /* 0x3010: Request not allowed in this state */ + PUT_WORD(&SSparms[4], 0x300E); /* SS not supported */ + + } + if (plci->internal_command == MWI_ACTIVATE_REQ_PEND) + { + PUT_WORD(&SSparms[1], S_MWI_ACTIVATE); + } + else PUT_WORD(&SSparms[1], S_MWI_DEACTIVATE); + + if (plci->cr_enquiry) + { + sendf(plci->appl, + _FACILITY_R | CONFIRM, + Id & 0xf, + plci->number, + "wws", Info, (word)3, SSparms); + if (rc != OK) plci_remove(plci); + } + else + { + sendf(plci->appl, + _FACILITY_R | CONFIRM, + Id, + plci->number, + "wws", Info, (word)3, SSparms); + } + break; + + case CONF_BEGIN_REQ_PEND: + case CONF_ADD_REQ_PEND: + case CONF_SPLIT_REQ_PEND: + case CONF_DROP_REQ_PEND: + case CONF_ISOLATE_REQ_PEND: + case CONF_REATTACH_REQ_PEND: + dbug(1, dprintf("CONF_RC=0x%x/0x%x", req, rc)); + if ((plci->internal_command == CONF_ADD_REQ_PEND) && (!plci->relatedPTYPLCI)) break; + rplci = plci; + rId = Id; + switch (plci->internal_command) + { + case CONF_BEGIN_REQ_PEND: + SSparms[1] = S_CONF_BEGIN; + break; + case CONF_ADD_REQ_PEND: + SSparms[1] = S_CONF_ADD; + rplci = plci->relatedPTYPLCI; + rId = ((word)rplci->Id << 8) | rplci->adapter->Id; + break; + case CONF_SPLIT_REQ_PEND: + SSparms[1] = S_CONF_SPLIT; + break; + case CONF_DROP_REQ_PEND: + SSparms[1] = S_CONF_DROP; + break; + case CONF_ISOLATE_REQ_PEND: + SSparms[1] = S_CONF_ISOLATE; + break; + case CONF_REATTACH_REQ_PEND: + SSparms[1] = S_CONF_REATTACH; + break; + } + + if (rc != OK) + { + Info = 0x300E; /* not supported */ + plci->relatedPTYPLCI = NULL; + plci->ptyState = 0; + } + sendf(rplci->appl, + _FACILITY_R | CONFIRM, + rId, + plci->number, + "wws", Info, (word)3, SSparms); + break; + + case VSWITCH_REQ_PEND: + if (rc != OK) + { + if (plci->relatedPTYPLCI) + { + plci->relatedPTYPLCI->vswitchstate = 0; + plci->relatedPTYPLCI->vsprot = 0; + plci->relatedPTYPLCI->vsprotdialect = 0; + } + plci->vswitchstate = 0; + plci->vsprot = 0; + plci->vsprotdialect = 0; + } + else + { + if (plci->relatedPTYPLCI && + plci->vswitchstate == 1 && + plci->relatedPTYPLCI->vswitchstate == 3) /* join complete */ + plci->vswitchstate = 3; + } + break; + + /* Call Deflection Request pending (SSCT) */ + case CD_REQ_PEND: + SSparms[1] = S_CALL_DEFLECTION; + if (rc != OK) + { + Info = 0x300E; /* not supported */ + plci->appl->CDEnable = 0; + } + sendf(plci->appl, _FACILITY_R | CONFIRM, Id, + plci->number, "wws", Info, (word)3, SSparms); + break; + + case RTP_CONNECT_B3_REQ_COMMAND_2: + if (rc == OK) + { + ncci = get_ncci(plci, ch, 0); + Id = (Id & 0xffff) | (((dword) ncci) << 16); + plci->channels++; + a->ncci_state[ncci] = OUTG_CON_PENDING; + } + + default: + if (plci->internal_command_queue[0]) + { + (*(plci->internal_command_queue[0]))(Id, plci, rc); + if (plci->internal_command) + return; + } + break; + } + next_internal_command(Id, plci); + } + } + else /* appl==0 */ + { + Id = ((word)plci->Id << 8) | plci->adapter->Id; + if (plci->tel) Id |= EXT_CONTROLLER; + + switch (plci->internal_command) + { + case BLOCK_PLCI: + return; + + case START_L1_SIG_ASSIGN_PEND: + case REM_L1_SIG_ASSIGN_PEND: + if (global_req == ASSIGN) + { + break; + } + else + { + dbug(1, dprintf("***L1 Req rem PLCI")); + plci->internal_command = 0; + sig_req(plci, REMOVE, 0); + send_req(plci); + } + break; + + /* Call Deflection Request pending, just no appl ptr assigned */ + case CD_REQ_PEND: + SSparms[1] = S_CALL_DEFLECTION; + if (rc != OK) + { + Info = 0x300E; /* not supported */ + } + for (i = 0; i < max_appl; i++) + { + if (application[i].CDEnable) + { + if (!application[i].Id) application[i].CDEnable = 0; + else + { + sendf(&application[i], _FACILITY_R | CONFIRM, Id, + plci->number, "wws", Info, (word)3, SSparms); + if (Info) application[i].CDEnable = 0; + } + } + } + plci->internal_command = 0; + break; + + case PERM_COD_HOOK: /* finished with Hook_Ind */ + return; + + case PERM_COD_CALL: + plci->internal_command = PERM_COD_CONN_PEND; + dbug(1, dprintf("***Codec Connect_Pending, Rc = 0x%x", rc)); + return; + + case PERM_COD_ASSIGN: + dbug(1, dprintf("***Codec Assign, Rc = 0x%x", rc)); + plci->internal_command = 0; + if (rc != ASSIGN_OK) break; + plci->internal_command = PERM_COD_CALL; + sig_req(plci, CALL_REQ, 0); + send_req(plci); + return; + + case LISTEN_SIG_ASSIGN_PEND: + if (rc == ASSIGN_OK) + { + plci->internal_command = 0; + dbug(1, dprintf("ListenCheck, new SIG_ID = 0x%x", plci->Sig.Id)); + add_p(plci, ESC, "\x02\x18\x00"); /* support call waiting */ + sig_req(plci, INDICATE_REQ, 0); + send_req(plci); + } + else + { + dbug(1, dprintf("ListenCheck failed (assignRc=0x%x)", rc)); + a->listen_active--; + plci_remove(plci); + plci->State = IDLE; + } + break; + + case USELAW_REQ: + if (global_req == ASSIGN) + { + if (rc == ASSIGN_OK) + { + sig_req(plci, LAW_REQ, 0); + send_req(plci); + dbug(1, dprintf("Auto-Law assigned")); + } + else + { + dbug(1, dprintf("Auto-Law assign failed")); + a->automatic_law = 3; + plci->internal_command = 0; + a->automatic_lawPLCI = NULL; + } + break; + } + else if (req == LAW_REQ && rc == OK) + { + dbug(1, dprintf("Auto-Law initiated")); + a->automatic_law = 2; + plci->internal_command = 0; + } + else + { + dbug(1, dprintf("Auto-Law not supported")); + a->automatic_law = 3; + plci->internal_command = 0; + sig_req(plci, REMOVE, 0); + send_req(plci); + a->automatic_lawPLCI = NULL; + } + break; + } + plci_remove_check(plci); + } } static void data_rc(PLCI *plci, byte ch) { - dword Id; - DIVA_CAPI_ADAPTER * a; - NCCI *ncci_ptr; - DATA_B3_DESC *data; - word ncci; - - if (plci->appl) - { - TransmitBufferFree (plci->appl, plci->data_sent_ptr); - a = plci->adapter; - ncci = a->ch_ncci[ch]; - if (ncci && (a->ncci_plci[ncci] == plci->Id)) - { - ncci_ptr = &(a->ncci[ncci]); - dbug(1,dprintf("data_out=%d, data_pending=%d",ncci_ptr->data_out,ncci_ptr->data_pending)); - if (ncci_ptr->data_pending) - { - data = &(ncci_ptr->DBuffer[ncci_ptr->data_out]); - if (!(data->Flags &4) && a->ncci_state[ncci]) - { - Id = (((dword)ncci)<<16)|((word)plci->Id<<8)|a->Id; - if(plci->tel) Id|=EXT_CONTROLLER; - sendf(plci->appl,_DATA_B3_R|CONFIRM,Id,data->Number, - "ww",data->Handle,0); - } - (ncci_ptr->data_out)++; - if (ncci_ptr->data_out == MAX_DATA_B3) - ncci_ptr->data_out = 0; - (ncci_ptr->data_pending)--; - } - } - } + dword Id; + DIVA_CAPI_ADAPTER *a; + NCCI *ncci_ptr; + DATA_B3_DESC *data; + word ncci; + + if (plci->appl) + { + TransmitBufferFree(plci->appl, plci->data_sent_ptr); + a = plci->adapter; + ncci = a->ch_ncci[ch]; + if (ncci && (a->ncci_plci[ncci] == plci->Id)) + { + ncci_ptr = &(a->ncci[ncci]); + dbug(1, dprintf("data_out=%d, data_pending=%d", ncci_ptr->data_out, ncci_ptr->data_pending)); + if (ncci_ptr->data_pending) + { + data = &(ncci_ptr->DBuffer[ncci_ptr->data_out]); + if (!(data->Flags & 4) && a->ncci_state[ncci]) + { + Id = (((dword)ncci) << 16) | ((word)plci->Id << 8) | a->Id; + if (plci->tel) Id |= EXT_CONTROLLER; + sendf(plci->appl, _DATA_B3_R | CONFIRM, Id, data->Number, + "ww", data->Handle, 0); + } + (ncci_ptr->data_out)++; + if (ncci_ptr->data_out == MAX_DATA_B3) + ncci_ptr->data_out = 0; + (ncci_ptr->data_pending)--; + } + } + } } static void data_ack(PLCI *plci, byte ch) { - dword Id; - DIVA_CAPI_ADAPTER * a; - NCCI *ncci_ptr; - word ncci; - - a = plci->adapter; - ncci = a->ch_ncci[ch]; - ncci_ptr = &(a->ncci[ncci]); - if (ncci_ptr->data_ack_pending) - { - if (a->ncci_state[ncci] && (a->ncci_plci[ncci] == plci->Id)) - { - Id = (((dword)ncci)<<16)|((word)plci->Id<<8)|a->Id; - if(plci->tel) Id|=EXT_CONTROLLER; - sendf(plci->appl,_DATA_B3_R|CONFIRM,Id,ncci_ptr->DataAck[ncci_ptr->data_ack_out].Number, - "ww",ncci_ptr->DataAck[ncci_ptr->data_ack_out].Handle,0); - } - (ncci_ptr->data_ack_out)++; - if (ncci_ptr->data_ack_out == MAX_DATA_ACK) - ncci_ptr->data_ack_out = 0; - (ncci_ptr->data_ack_pending)--; - } + dword Id; + DIVA_CAPI_ADAPTER *a; + NCCI *ncci_ptr; + word ncci; + + a = plci->adapter; + ncci = a->ch_ncci[ch]; + ncci_ptr = &(a->ncci[ncci]); + if (ncci_ptr->data_ack_pending) + { + if (a->ncci_state[ncci] && (a->ncci_plci[ncci] == plci->Id)) + { + Id = (((dword)ncci) << 16) | ((word)plci->Id << 8) | a->Id; + if (plci->tel) Id |= EXT_CONTROLLER; + sendf(plci->appl, _DATA_B3_R | CONFIRM, Id, ncci_ptr->DataAck[ncci_ptr->data_ack_out].Number, + "ww", ncci_ptr->DataAck[ncci_ptr->data_ack_out].Handle, 0); + } + (ncci_ptr->data_ack_out)++; + if (ncci_ptr->data_ack_out == MAX_DATA_ACK) + ncci_ptr->data_ack_out = 0; + (ncci_ptr->data_ack_pending)--; + } } static void sig_ind(PLCI *plci) { - dword x_Id; - dword Id; - dword rId; - word i; - word cip; - dword cip_mask; - byte *ie; - DIVA_CAPI_ADAPTER * a; - API_PARSE saved_parms[MAX_MSG_PARMS+1]; + dword x_Id; + dword Id; + dword rId; + word i; + word cip; + dword cip_mask; + byte *ie; + DIVA_CAPI_ADAPTER *a; + API_PARSE saved_parms[MAX_MSG_PARMS + 1]; #define MAXPARMSIDS 31 - byte * parms[MAXPARMSIDS]; - byte * add_i[4]; - byte * multi_fac_parms[MAX_MULTI_IE]; - byte * multi_pi_parms [MAX_MULTI_IE]; - byte * multi_ssext_parms [MAX_MULTI_IE]; - byte * multi_CiPN_parms [MAX_MULTI_IE]; - - byte * multi_vswitch_parms [MAX_MULTI_IE]; - - byte ai_len; - byte *esc_chi = ""; - byte *esc_law = ""; - byte *pty_cai = ""; - byte *esc_cr = ""; - byte *esc_profile = ""; - - byte facility[256]; - PLCI * tplci = NULL; - byte chi[] = "\x02\x18\x01"; - byte voice_cai[] = "\x06\x14\x00\x00\x00\x00\x08"; - byte resume_cau[] = "\x05\x05\x00\x02\x00\x00"; - /* ESC_MSGTYPE must be the last but one message, a new IE has to be */ - /* included before the ESC_MSGTYPE and MAXPARMSIDS has to be incremented */ - /* SMSG is situated at the end because its 0 (for compatibility reasons */ - /* (see Info_Mask Bit 4, first IE. then the message type) */ - word parms_id[] = - {MAXPARMSIDS, CPN, 0xff, DSA, OSA, BC, LLC, HLC, ESC_CAUSE, DSP, DT, CHA, - UUI, CONG_RR, CONG_RNR, ESC_CHI, KEY, CHI, CAU, ESC_LAW, - RDN, RDX, CONN_NR, RIN, NI, CAI, ESC_CR, - CST, ESC_PROFILE, 0xff, ESC_MSGTYPE, SMSG}; - /* 14 FTY repl by ESC_CHI */ - /* 18 PI repl by ESC_LAW */ - /* removed OAD changed to 0xff for future use, OAD is multiIE now */ - word multi_fac_id[] = {1, FTY}; - word multi_pi_id[] = {1, PI}; - word multi_CiPN_id[] = {1, OAD}; - word multi_ssext_id[] = {1, ESC_SSEXT}; - - word multi_vswitch_id[] = {1, ESC_VSWITCH}; - - byte * cau; - word ncci; - byte SS_Ind[] = "\x05\x02\x00\x02\x00\x00"; /* Hold_Ind struct*/ - byte CF_Ind[] = "\x09\x02\x00\x06\x00\x00\x00\x00\x00\x00"; - byte Interr_Err_Ind[] = "\x0a\x02\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; - byte CONF_Ind[] = "\x09\x16\x00\x06\x00\x00\0x00\0x00\0x00\0x00"; - byte force_mt_info = false; - byte dir; - dword d; - word w; - - a = plci->adapter; - Id = ((word)plci->Id<<8)|a->Id; - PUT_WORD(&SS_Ind[4],0x0000); - - if (plci->sig_remove_id) - { - plci->Sig.RNR = 2; /* discard */ - dbug(1,dprintf("SIG discard while remove pending")); - return; - } - if(plci->tel && plci->SuppState!=CALL_HELD) Id|=EXT_CONTROLLER; - dbug(1,dprintf("SigInd-Id=%08lx,plci=%x,tel=%x,state=0x%x,channels=%d,Discflowcl=%d", - Id,plci->Id,plci->tel,plci->State,plci->channels,plci->hangup_flow_ctrl_timer)); - if(plci->Sig.Ind==CALL_HOLD_ACK && plci->channels) - { - plci->Sig.RNR = 1; - return; - } - if(plci->Sig.Ind==HANGUP && plci->channels) - { - plci->Sig.RNR = 1; - plci->hangup_flow_ctrl_timer++; - /* recover the network layer after timeout */ - if(plci->hangup_flow_ctrl_timer==100) - { - dbug(1,dprintf("Exceptional disc")); - plci->Sig.RNR = 0; - plci->hangup_flow_ctrl_timer = 0; - for (ncci = 1; ncci < MAX_NCCI+1; ncci++) - { - if (a->ncci_plci[ncci] == plci->Id) - { - cleanup_ncci_data (plci, ncci); - if(plci->channels)plci->channels--; - if (plci->appl) - sendf(plci->appl,_DISCONNECT_B3_I, (((dword) ncci) << 16) | Id,0,"ws",0,""); - } - } - if (plci->appl) - sendf(plci->appl, _DISCONNECT_I, Id, 0, "w", 0); - plci_remove(plci); - plci->State=IDLE; - } - return; - } - - /* do first parse the info with no OAD in, because OAD will be converted */ - /* first the multiple facility IE, then mult. progress ind. */ - /* then the parameters for the info_ind + conn_ind */ - IndParse(plci,multi_fac_id,multi_fac_parms,MAX_MULTI_IE); - IndParse(plci,multi_pi_id,multi_pi_parms,MAX_MULTI_IE); - IndParse(plci,multi_ssext_id,multi_ssext_parms,MAX_MULTI_IE); - - IndParse(plci,multi_vswitch_id,multi_vswitch_parms,MAX_MULTI_IE); - - IndParse(plci,parms_id,parms,0); - IndParse(plci,multi_CiPN_id,multi_CiPN_parms,MAX_MULTI_IE); - esc_chi = parms[14]; - esc_law = parms[18]; - pty_cai = parms[24]; - esc_cr = parms[25]; - esc_profile = parms[27]; - if(esc_cr[0] && plci) - { - if(plci->cr_enquiry && plci->appl) - { - plci->cr_enquiry = false; - /* d = MANU_ID */ - /* w = m_command */ - /* b = total length */ - /* b = indication type */ - /* b = length of all IEs */ - /* b = IE1 */ - /* S = IE1 length + cont. */ - /* b = IE2 */ - /* S = IE2 length + cont. */ - sendf(plci->appl, - _MANUFACTURER_I, - Id, - 0, - "dwbbbbSbS",_DI_MANU_ID,plci->m_command, - 2+1+1+esc_cr[0]+1+1+esc_law[0],plci->Sig.Ind,1+1+esc_cr[0]+1+1+esc_law[0],ESC,esc_cr,ESC,esc_law); - } - } - /* create the additional info structure */ - add_i[1] = parms[15]; /* KEY of additional info */ - add_i[2] = parms[11]; /* UUI of additional info */ - ai_len = AddInfo(add_i,multi_fac_parms, esc_chi, facility); - - /* the ESC_LAW indicates if u-Law or a-Law is actually used by the card */ - /* indication returns by the card if requested by the function */ - /* AutomaticLaw() after driver init */ - if (a->automatic_law<4) - { - if(esc_law[0]){ - if(esc_law[2]){ - dbug(0,dprintf("u-Law selected")); - a->u_law = 1; - } - else { - dbug(0,dprintf("a-Law selected")); - a->u_law = 0; - } - a->automatic_law = 4; - if(plci==a->automatic_lawPLCI) { - plci->internal_command = 0; - sig_req(plci,REMOVE,0); - send_req(plci); - a->automatic_lawPLCI = NULL; - } - } - if (esc_profile[0]) - { - dbug (1, dprintf ("[%06x] CardProfile: %lx %lx %lx %lx %lx", - UnMapController (a->Id), GET_DWORD (&esc_profile[6]), - GET_DWORD (&esc_profile[10]), GET_DWORD (&esc_profile[14]), - GET_DWORD (&esc_profile[18]), GET_DWORD (&esc_profile[46]))); - - a->profile.Global_Options &= 0x000000ffL; - a->profile.B1_Protocols &= 0x000003ffL; - a->profile.B2_Protocols &= 0x00001fdfL; - a->profile.B3_Protocols &= 0x000000b7L; - - a->profile.Global_Options &= GET_DWORD (&esc_profile[6]) | - GL_BCHANNEL_OPERATION_SUPPORTED; - a->profile.B1_Protocols &= GET_DWORD (&esc_profile[10]); - a->profile.B2_Protocols &= GET_DWORD (&esc_profile[14]); - a->profile.B3_Protocols &= GET_DWORD (&esc_profile[18]); - a->manufacturer_features = GET_DWORD (&esc_profile[46]); - a->man_profile.private_options = 0; - - if (a->manufacturer_features & MANUFACTURER_FEATURE_ECHO_CANCELLER) - { - a->man_profile.private_options |= 1L << PRIVATE_ECHO_CANCELLER; - a->profile.Global_Options |= GL_ECHO_CANCELLER_SUPPORTED; - } - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_RTP) - a->man_profile.private_options |= 1L << PRIVATE_RTP; - a->man_profile.rtp_primary_payloads = GET_DWORD (&esc_profile[50]); - a->man_profile.rtp_additional_payloads = GET_DWORD (&esc_profile[54]); - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_T38) - a->man_profile.private_options |= 1L << PRIVATE_T38; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_SUB_SEP_PWD) - a->man_profile.private_options |= 1L << PRIVATE_FAX_SUB_SEP_PWD; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_V18) - a->man_profile.private_options |= 1L << PRIVATE_V18; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_DTMF_TONE) - a->man_profile.private_options |= 1L << PRIVATE_DTMF_TONE; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_PIAFS) - a->man_profile.private_options |= 1L << PRIVATE_PIAFS; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) - a->man_profile.private_options |= 1L << PRIVATE_FAX_PAPER_FORMATS; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_VOWN) - a->man_profile.private_options |= 1L << PRIVATE_VOWN; - - - if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_NONSTANDARD) - a->man_profile.private_options |= 1L << PRIVATE_FAX_NONSTANDARD; - - } - else - { - a->profile.Global_Options &= 0x0000007fL; - a->profile.B1_Protocols &= 0x000003dfL; - a->profile.B2_Protocols &= 0x00001adfL; - a->profile.B3_Protocols &= 0x000000b7L; - a->manufacturer_features &= MANUFACTURER_FEATURE_HARDDTMF; - } - if (a->manufacturer_features & (MANUFACTURER_FEATURE_HARDDTMF | - MANUFACTURER_FEATURE_SOFTDTMF_SEND | MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE)) - { - a->profile.Global_Options |= GL_DTMF_SUPPORTED; - } - a->manufacturer_features &= ~MANUFACTURER_FEATURE_OOB_CHANNEL; - dbug (1, dprintf ("[%06x] Profile: %lx %lx %lx %lx %lx", - UnMapController (a->Id), a->profile.Global_Options, - a->profile.B1_Protocols, a->profile.B2_Protocols, - a->profile.B3_Protocols, a->manufacturer_features)); - } - /* codec plci for the handset/hook state support is just an internal id */ - if(plci!=a->AdvCodecPLCI) - { - force_mt_info = SendMultiIE(plci,Id,multi_fac_parms, FTY, 0x20, 0); - force_mt_info |= SendMultiIE(plci,Id,multi_pi_parms, PI, 0x210, 0); - SendSSExtInd(NULL,plci,Id,multi_ssext_parms); - SendInfo(plci,Id, parms, force_mt_info); - - VSwitchReqInd(plci,Id,multi_vswitch_parms); - - } - - /* switch the codec to the b-channel */ - if(esc_chi[0] && plci && !plci->SuppState){ - plci->b_channel = esc_chi[esc_chi[0]]&0x1f; - mixer_set_bchannel_id_esc (plci, plci->b_channel); - dbug(1,dprintf("storeChannel=0x%x",plci->b_channel)); - if(plci->tel==ADV_VOICE && plci->appl) { - SetVoiceChannel(a->AdvCodecPLCI, esc_chi, a); - } - } - - if(plci->appl) plci->appl->Number++; - - switch(plci->Sig.Ind) { - /* Response to Get_Supported_Services request */ - case S_SUPPORTED: - dbug(1,dprintf("S_Supported")); - if(!plci->appl) break; - if(pty_cai[0]==4) - { - PUT_DWORD(&CF_Ind[6],GET_DWORD(&pty_cai[1]) ); - } - else - { - PUT_DWORD(&CF_Ind[6],MASK_TERMINAL_PORTABILITY | MASK_HOLD_RETRIEVE); - } - PUT_WORD (&CF_Ind[1], 0); - PUT_WORD (&CF_Ind[4], 0); - sendf(plci->appl,_FACILITY_R|CONFIRM,Id&0x7,plci->number, "wws",0,3,CF_Ind); - plci_remove(plci); - break; - - /* Supplementary Service rejected */ - case S_SERVICE_REJ: - dbug(1,dprintf("S_Reject=0x%x",pty_cai[5])); - if(!pty_cai[0]) break; - switch (pty_cai[5]) - { - case ECT_EXECUTE: - case THREE_PTY_END: - case THREE_PTY_BEGIN: - if(!plci->relatedPTYPLCI) break; - tplci = plci->relatedPTYPLCI; - rId = ( (word)tplci->Id<<8)|tplci->adapter->Id; - if(tplci->tel) rId|=EXT_CONTROLLER; - if(pty_cai[5]==ECT_EXECUTE) - { - PUT_WORD(&SS_Ind[1],S_ECT); - - plci->vswitchstate=0; - plci->relatedPTYPLCI->vswitchstate=0; - - } - else - { - PUT_WORD(&SS_Ind[1],pty_cai[5]+3); - } - if(pty_cai[2]!=0xff) - { - PUT_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]); - } - else - { - PUT_WORD(&SS_Ind[4],0x300E); - } - plci->relatedPTYPLCI = NULL; - plci->ptyState = 0; - sendf(tplci->appl,_FACILITY_I,rId,0,"ws",3, SS_Ind); - break; - - case CALL_DEFLECTION: - if(pty_cai[2]!=0xff) - { - PUT_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]); - } - else - { - PUT_WORD(&SS_Ind[4],0x300E); - } - PUT_WORD(&SS_Ind[1],pty_cai[5]); - for(i=0; iappl) break; - if(pty_cai[2]!=0xff) - { - PUT_WORD(&Interr_Err_Ind[4],0x3600|(word)pty_cai[2]); - } - else - { - PUT_WORD(&Interr_Err_Ind[4],0x300E); - } - switch (pty_cai[5]) - { - case DEACTIVATION_DIVERSION: - dbug(1,dprintf("Deact_Div")); - Interr_Err_Ind[0]=0x9; - Interr_Err_Ind[3]=0x6; - PUT_WORD(&Interr_Err_Ind[1],S_CALL_FORWARDING_STOP); - break; - case ACTIVATION_DIVERSION: - dbug(1,dprintf("Act_Div")); - Interr_Err_Ind[0]=0x9; - Interr_Err_Ind[3]=0x6; - PUT_WORD(&Interr_Err_Ind[1],S_CALL_FORWARDING_START); - break; - case DIVERSION_INTERROGATE_CFU: - case DIVERSION_INTERROGATE_CFB: - case DIVERSION_INTERROGATE_CFNR: - dbug(1,dprintf("Interr_Div")); - Interr_Err_Ind[0]=0xa; - Interr_Err_Ind[3]=0x7; - PUT_WORD(&Interr_Err_Ind[1],S_INTERROGATE_DIVERSION); - break; - case DIVERSION_INTERROGATE_NUM: - dbug(1,dprintf("Interr_Num")); - Interr_Err_Ind[0]=0xa; - Interr_Err_Ind[3]=0x7; - PUT_WORD(&Interr_Err_Ind[1],S_INTERROGATE_NUMBERS); - break; - case CCBS_REQUEST: - dbug(1,dprintf("CCBS Request")); - Interr_Err_Ind[0]=0xd; - Interr_Err_Ind[3]=0xa; - PUT_WORD(&Interr_Err_Ind[1],S_CCBS_REQUEST); - break; - case CCBS_DEACTIVATE: - dbug(1,dprintf("CCBS Deactivate")); - Interr_Err_Ind[0]=0x9; - Interr_Err_Ind[3]=0x6; - PUT_WORD(&Interr_Err_Ind[1],S_CCBS_DEACTIVATE); - break; - case CCBS_INTERROGATE: - dbug(1,dprintf("CCBS Interrogate")); - Interr_Err_Ind[0]=0xb; - Interr_Err_Ind[3]=0x8; - PUT_WORD(&Interr_Err_Ind[1],S_CCBS_INTERROGATE); - break; - } - PUT_DWORD(&Interr_Err_Ind[6],plci->appl->S_Handle); - sendf(plci->appl,_FACILITY_I,Id&0x7,0,"ws",3, Interr_Err_Ind); - plci_remove(plci); - break; - case ACTIVATION_MWI: - case DEACTIVATION_MWI: - if(pty_cai[5]==ACTIVATION_MWI) - { - PUT_WORD(&SS_Ind[1],S_MWI_ACTIVATE); - } - else PUT_WORD(&SS_Ind[1],S_MWI_DEACTIVATE); - - if(pty_cai[2]!=0xff) - { - PUT_WORD(&SS_Ind[4],0x3600|(word)pty_cai[2]); - } - else - { - PUT_WORD(&SS_Ind[4],0x300E); - } - - if(plci->cr_enquiry) - { - sendf(plci->appl,_FACILITY_I,Id&0xf,0,"ws",3, SS_Ind); - plci_remove(plci); - } - else - { - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, SS_Ind); - } - break; - case CONF_ADD: /* ERROR */ - case CONF_BEGIN: - case CONF_DROP: - case CONF_ISOLATE: - case CONF_REATTACH: - CONF_Ind[0]=9; - CONF_Ind[3]=6; - switch(pty_cai[5]) - { - case CONF_BEGIN: - PUT_WORD(&CONF_Ind[1],S_CONF_BEGIN); - plci->ptyState = 0; - break; - case CONF_DROP: - CONF_Ind[0]=5; - CONF_Ind[3]=2; - PUT_WORD(&CONF_Ind[1],S_CONF_DROP); - plci->ptyState = CONNECTED; - break; - case CONF_ISOLATE: - CONF_Ind[0]=5; - CONF_Ind[3]=2; - PUT_WORD(&CONF_Ind[1],S_CONF_ISOLATE); - plci->ptyState = CONNECTED; - break; - case CONF_REATTACH: - CONF_Ind[0]=5; - CONF_Ind[3]=2; - PUT_WORD(&CONF_Ind[1],S_CONF_REATTACH); - plci->ptyState = CONNECTED; - break; - case CONF_ADD: - PUT_WORD(&CONF_Ind[1],S_CONF_ADD); - plci->relatedPTYPLCI = NULL; - tplci=plci->relatedPTYPLCI; - if(tplci) tplci->ptyState = CONNECTED; - plci->ptyState = CONNECTED; - break; - } - - if(pty_cai[2]!=0xff) - { - PUT_WORD(&CONF_Ind[4],0x3600|(word)pty_cai[2]); - } - else - { - PUT_WORD(&CONF_Ind[4],0x3303); /* Time-out: network did not respond - within the required time */ - } - - PUT_DWORD(&CONF_Ind[6],0x0); - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, CONF_Ind); - break; - } - break; - - /* Supplementary Service indicates success */ - case S_SERVICE: - dbug(1,dprintf("Service_Ind")); - PUT_WORD (&CF_Ind[4], 0); - switch (pty_cai[5]) - { - case THREE_PTY_END: - case THREE_PTY_BEGIN: - case ECT_EXECUTE: - if(!plci->relatedPTYPLCI) break; - tplci = plci->relatedPTYPLCI; - rId = ( (word)tplci->Id<<8)|tplci->adapter->Id; - if(tplci->tel) rId|=EXT_CONTROLLER; - if(pty_cai[5]==ECT_EXECUTE) - { - PUT_WORD(&SS_Ind[1],S_ECT); - - if(plci->vswitchstate!=3) - { - - plci->ptyState = IDLE; - plci->relatedPTYPLCI = NULL; - plci->ptyState = 0; - - } - - dbug(1,dprintf("ECT OK")); - sendf(tplci->appl,_FACILITY_I,rId,0,"ws",3, SS_Ind); - - - - } - else - { - switch (plci->ptyState) - { - case S_3PTY_BEGIN: - plci->ptyState = CONNECTED; - dbug(1,dprintf("3PTY ON")); - break; - - case S_3PTY_END: - plci->ptyState = IDLE; - plci->relatedPTYPLCI = NULL; - plci->ptyState = 0; - dbug(1,dprintf("3PTY OFF")); - break; - } - PUT_WORD(&SS_Ind[1],pty_cai[5]+3); - sendf(tplci->appl,_FACILITY_I,rId,0,"ws",3, SS_Ind); - } - break; - - case CALL_DEFLECTION: - PUT_WORD(&SS_Ind[1],pty_cai[5]); - for(i=0; iappl) break; - PUT_WORD(&CF_Ind[1],pty_cai[5]+2); - PUT_DWORD(&CF_Ind[6],plci->appl->S_Handle); - sendf(plci->appl,_FACILITY_I,Id&0x7,0,"ws",3, CF_Ind); - plci_remove(plci); - break; - - case DIVERSION_INTERROGATE_CFU: - case DIVERSION_INTERROGATE_CFB: - case DIVERSION_INTERROGATE_CFNR: - case DIVERSION_INTERROGATE_NUM: - case CCBS_REQUEST: - case CCBS_DEACTIVATE: - case CCBS_INTERROGATE: - if(!plci->appl) break; - switch (pty_cai[5]) - { - case DIVERSION_INTERROGATE_CFU: - case DIVERSION_INTERROGATE_CFB: - case DIVERSION_INTERROGATE_CFNR: - dbug(1,dprintf("Interr_Div")); - PUT_WORD(&pty_cai[1],S_INTERROGATE_DIVERSION); - pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */ - break; - case DIVERSION_INTERROGATE_NUM: - dbug(1,dprintf("Interr_Num")); - PUT_WORD(&pty_cai[1],S_INTERROGATE_NUMBERS); - pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */ - break; - case CCBS_REQUEST: - dbug(1,dprintf("CCBS Request")); - PUT_WORD(&pty_cai[1],S_CCBS_REQUEST); - pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */ - break; - case CCBS_DEACTIVATE: - dbug(1,dprintf("CCBS Deactivate")); - PUT_WORD(&pty_cai[1],S_CCBS_DEACTIVATE); - pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */ - break; - case CCBS_INTERROGATE: - dbug(1,dprintf("CCBS Interrogate")); - PUT_WORD(&pty_cai[1],S_CCBS_INTERROGATE); - pty_cai[3]=pty_cai[0]-3; /* Supplementary Service-specific parameter len */ - break; - } - PUT_WORD(&pty_cai[4],0); /* Supplementary Service Reason */ - PUT_DWORD(&pty_cai[6],plci->appl->S_Handle); - sendf(plci->appl,_FACILITY_I,Id&0x7,0,"wS",3, pty_cai); - plci_remove(plci); - break; - - case ACTIVATION_MWI: - case DEACTIVATION_MWI: - if(pty_cai[5]==ACTIVATION_MWI) - { - PUT_WORD(&SS_Ind[1],S_MWI_ACTIVATE); - } - else PUT_WORD(&SS_Ind[1],S_MWI_DEACTIVATE); - if(plci->cr_enquiry) - { - sendf(plci->appl,_FACILITY_I,Id&0xf,0,"ws",3, SS_Ind); - plci_remove(plci); - } - else - { - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, SS_Ind); - } - break; - case MWI_INDICATION: - if(pty_cai[0]>=0x12) - { - PUT_WORD(&pty_cai[3],S_MWI_INDICATE); - pty_cai[2]=pty_cai[0]-2; /* len Parameter */ - pty_cai[5]=pty_cai[0]-5; /* Supplementary Service-specific parameter len */ - if(plci->appl && (a->Notification_Mask[plci->appl->Id-1]&SMASK_MWI)) - { - if(plci->internal_command==GET_MWI_STATE) /* result on Message Waiting Listen */ - { - sendf(plci->appl,_FACILITY_I,Id&0xf,0,"wS",3, &pty_cai[2]); - plci_remove(plci); - return; - } - else sendf(plci->appl,_FACILITY_I,Id,0,"wS",3, &pty_cai[2]); - pty_cai[0]=0; - } - else - { - for(i=0; iNotification_Mask[i]&SMASK_MWI) - { - sendf(&application[i],_FACILITY_I,Id&0x7,0,"wS",3, &pty_cai[2]); - pty_cai[0]=0; - } - } - } - - if(!pty_cai[0]) - { /* acknowledge */ - facility[2]= 0; /* returncode */ - } - else facility[2]= 0xff; - } - else - { - /* reject */ - facility[2]= 0xff; /* returncode */ - } - facility[0]= 2; - facility[1]= MWI_RESPONSE; /* Function */ - add_p(plci,CAI,facility); - add_p(plci,ESC,multi_ssext_parms[0]); /* remembered parameter -> only one possible */ - sig_req(plci,S_SERVICE,0); - send_req(plci); - plci->command = 0; - next_internal_command (Id, plci); - break; - case CONF_ADD: /* OK */ - case CONF_BEGIN: - case CONF_DROP: - case CONF_ISOLATE: - case CONF_REATTACH: - case CONF_PARTYDISC: - CONF_Ind[0]=9; - CONF_Ind[3]=6; - switch(pty_cai[5]) - { - case CONF_BEGIN: - PUT_WORD(&CONF_Ind[1],S_CONF_BEGIN); - if(pty_cai[0]==6) - { - d=pty_cai[6]; - PUT_DWORD(&CONF_Ind[6],d); /* PartyID */ - } - else - { - PUT_DWORD(&CONF_Ind[6],0x0); - } - break; - case CONF_ISOLATE: - PUT_WORD(&CONF_Ind[1],S_CONF_ISOLATE); - CONF_Ind[0]=5; - CONF_Ind[3]=2; - break; - case CONF_REATTACH: - PUT_WORD(&CONF_Ind[1],S_CONF_REATTACH); - CONF_Ind[0]=5; - CONF_Ind[3]=2; - break; - case CONF_DROP: - PUT_WORD(&CONF_Ind[1],S_CONF_DROP); - CONF_Ind[0]=5; - CONF_Ind[3]=2; - break; - case CONF_ADD: - PUT_WORD(&CONF_Ind[1],S_CONF_ADD); - d=pty_cai[6]; - PUT_DWORD(&CONF_Ind[6],d); /* PartyID */ - tplci=plci->relatedPTYPLCI; - if(tplci) tplci->ptyState = CONNECTED; - break; - case CONF_PARTYDISC: - CONF_Ind[0]=7; - CONF_Ind[3]=4; - PUT_WORD(&CONF_Ind[1],S_CONF_PARTYDISC); - d=pty_cai[6]; - PUT_DWORD(&CONF_Ind[4],d); /* PartyID */ - break; - } - plci->ptyState = CONNECTED; - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, CONF_Ind); - break; - case CCBS_INFO_RETAIN: - case CCBS_ERASECALLLINKAGEID: - case CCBS_STOP_ALERTING: - CONF_Ind[0]=5; - CONF_Ind[3]=2; - switch(pty_cai[5]) - { - case CCBS_INFO_RETAIN: - PUT_WORD(&CONF_Ind[1],S_CCBS_INFO_RETAIN); - break; - case CCBS_STOP_ALERTING: - PUT_WORD(&CONF_Ind[1],S_CCBS_STOP_ALERTING); - break; - case CCBS_ERASECALLLINKAGEID: - PUT_WORD(&CONF_Ind[1],S_CCBS_ERASECALLLINKAGEID); - CONF_Ind[0]=7; - CONF_Ind[3]=4; - CONF_Ind[6]=0; - CONF_Ind[7]=0; - break; - } - w=pty_cai[6]; - PUT_WORD(&CONF_Ind[4],w); /* PartyID */ - - if(plci->appl && (a->Notification_Mask[plci->appl->Id-1]&SMASK_CCBS)) - { - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, CONF_Ind); - } - else - { - for(i=0; iNotification_Mask[i]&SMASK_CCBS) - sendf(&application[i],_FACILITY_I,Id&0x7,0,"ws",3, CONF_Ind); - } - break; - } - break; - case CALL_HOLD_REJ: - cau = parms[7]; - if(cau) - { - i = _L3_CAUSE | cau[2]; - if(cau[2]==0) i = 0x3603; - } - else - { - i = 0x3603; - } - PUT_WORD(&SS_Ind[1],S_HOLD); - PUT_WORD(&SS_Ind[4],i); - if(plci->SuppState == HOLD_REQUEST) - { - plci->SuppState = IDLE; - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, SS_Ind); - } - break; - - case CALL_HOLD_ACK: - if(plci->SuppState == HOLD_REQUEST) - { - plci->SuppState = CALL_HELD; - CodecIdCheck(a, plci); - start_internal_command (Id, plci, hold_save_command); - } - break; - - case CALL_RETRIEVE_REJ: - cau = parms[7]; - if(cau) - { - i = _L3_CAUSE | cau[2]; - if(cau[2]==0) i = 0x3603; - } - else - { - i = 0x3603; - } - PUT_WORD(&SS_Ind[1],S_RETRIEVE); - PUT_WORD(&SS_Ind[4],i); - if(plci->SuppState == RETRIEVE_REQUEST) - { - plci->SuppState = CALL_HELD; - CodecIdCheck(a, plci); - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, SS_Ind); - } - break; - - case CALL_RETRIEVE_ACK: - PUT_WORD(&SS_Ind[1],S_RETRIEVE); - if(plci->SuppState == RETRIEVE_REQUEST) - { - plci->SuppState = IDLE; - plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; - plci->b_channel = esc_chi[esc_chi[0]]&0x1f; - if(plci->tel) - { - mixer_set_bchannel_id_esc (plci, plci->b_channel); - dbug(1,dprintf("RetrChannel=0x%x",plci->b_channel)); - SetVoiceChannel(a->AdvCodecPLCI, esc_chi, a); - if(plci->B2_prot==B2_TRANSPARENT && plci->B3_prot==B3_TRANSPARENT) - { - dbug(1,dprintf("Get B-ch")); - start_internal_command (Id, plci, retrieve_restore_command); - } - else - sendf(plci->appl,_FACILITY_I,Id,0,"ws",3, SS_Ind); - } - else - start_internal_command (Id, plci, retrieve_restore_command); - } - break; - - case INDICATE_IND: - if(plci->State != LISTENING) { - sig_req(plci,HANGUP,0); - send_req(plci); - break; - } - cip = find_cip(a,parms[4],parms[6]); - cip_mask = 1L<adapter_disabled) - { - set_c_ind_mask_bit (plci, MAX_APPL); - group_optimization(a, plci); - for(i=0; iCIP_Mask[i]&1 || a->CIP_Mask[i]&cip_mask) - && CPN_filter_ok(parms[0],a,i) - && test_group_ind_mask_bit (plci, i) ) { - dbug(1,dprintf("storedcip_mask[%d]=0x%lx",i,a->CIP_Mask[i] )); - set_c_ind_mask_bit (plci, i); - dump_c_ind_mask (plci); - plci->State = INC_CON_PENDING; - plci->call_dir = (plci->call_dir & ~(CALL_DIR_OUT | CALL_DIR_ORIGINATE)) | - CALL_DIR_IN | CALL_DIR_ANSWER; - if(esc_chi[0]) { - plci->b_channel = esc_chi[esc_chi[0]]&0x1f; - mixer_set_bchannel_id_esc (plci, plci->b_channel); - } - /* if a listen on the ext controller is done, check if hook states */ - /* are supported or if just a on board codec must be activated */ - if(a->codec_listen[i] && !a->AdvSignalPLCI) { - if(a->profile.Global_Options & HANDSET) - plci->tel = ADV_VOICE; - else if(a->profile.Global_Options & ON_BOARD_CODEC) - plci->tel = CODEC; - if(plci->tel) Id|=EXT_CONTROLLER; - a->codec_listen[i] = plci; - } - - sendf(&application[i],_CONNECT_I,Id,0, - "wSSSSSSSbSSSSS", cip, /* CIP */ - parms[0], /* CalledPartyNumber */ - multi_CiPN_parms[0], /* CallingPartyNumber */ - parms[2], /* CalledPartySubad */ - parms[3], /* CallingPartySubad */ - parms[4], /* BearerCapability */ - parms[5], /* LowLC */ - parms[6], /* HighLC */ - ai_len, /* nested struct add_i */ - add_i[0], /* B channel info */ - add_i[1], /* keypad facility */ - add_i[2], /* user user data */ - add_i[3], /* nested facility */ - multi_CiPN_parms[1] /* second CiPN(SCR) */ - ); - SendSSExtInd(&application[i], - plci, - Id, - multi_ssext_parms); - SendSetupInfo(&application[i], - plci, - Id, - parms, - SendMultiIE(plci,Id,multi_pi_parms, PI, 0x210, true)); - } - } - clear_c_ind_mask_bit (plci, MAX_APPL); - dump_c_ind_mask (plci); - } - if(c_ind_mask_empty (plci)) { - sig_req(plci,HANGUP,0); - send_req(plci); - plci->State = IDLE; - } - plci->notifiedcall = 0; - a->listen_active--; - listen_check(a); - break; - - case CALL_PEND_NOTIFY: - plci->notifiedcall = 1; - listen_check(a); - break; - - case CALL_IND: - case CALL_CON: - if(plci->State==ADVANCED_VOICE_SIG || plci->State==ADVANCED_VOICE_NOSIG) - { - if(plci->internal_command==PERM_COD_CONN_PEND) - { - if(plci->State==ADVANCED_VOICE_NOSIG) - { - dbug(1,dprintf("***Codec OK")); - if(a->AdvSignalPLCI) - { - tplci = a->AdvSignalPLCI; - if(tplci->spoofed_msg) - { - dbug(1,dprintf("***Spoofed Msg(0x%x)",tplci->spoofed_msg)); - tplci->command = 0; - tplci->internal_command = 0; - x_Id = ((word)tplci->Id<<8)|tplci->adapter->Id | 0x80; - switch (tplci->spoofed_msg) - { - case CALL_RES: - tplci->command = _CONNECT_I|RESPONSE; - api_load_msg (&tplci->saved_msg, saved_parms); - add_b1(tplci,&saved_parms[1],0,tplci->B1_facilities); - if (tplci->adapter->Info_Mask[tplci->appl->Id-1] & 0x200) - { - /* early B3 connect (CIP mask bit 9) no release after a disc */ - add_p(tplci,LLI,"\x01\x01"); - } - add_s(tplci, CONN_NR, &saved_parms[2]); - add_s(tplci, LLC, &saved_parms[4]); - add_ai(tplci, &saved_parms[5]); - tplci->State = INC_CON_ACCEPT; - sig_req(tplci, CALL_RES,0); - send_req(tplci); - break; - - case AWAITING_SELECT_B: - dbug(1,dprintf("Select_B continue")); - start_internal_command (x_Id, tplci, select_b_command); - break; - - case AWAITING_MANUF_CON: /* Get_Plci per Manufacturer_Req to ext controller */ - if(!tplci->Sig.Id) - { - dbug(1,dprintf("No SigID!")); - sendf(tplci->appl, _MANUFACTURER_R|CONFIRM,x_Id,tplci->number, "dww",_DI_MANU_ID,_MANUFACTURER_R,_OUT_OF_PLCI); - plci_remove(tplci); - break; - } - tplci->command = _MANUFACTURER_R; - api_load_msg (&tplci->saved_msg, saved_parms); - dir = saved_parms[2].info[0]; - if(dir==1) { - sig_req(tplci,CALL_REQ,0); - } - else if(!dir){ - sig_req(tplci,LISTEN_REQ,0); - } - send_req(tplci); - sendf(tplci->appl, _MANUFACTURER_R|CONFIRM,x_Id,tplci->number, "dww",_DI_MANU_ID,_MANUFACTURER_R,0); - break; - - case (CALL_REQ|AWAITING_MANUF_CON): - sig_req(tplci,CALL_REQ,0); - send_req(tplci); - break; - - case CALL_REQ: - if(!tplci->Sig.Id) - { - dbug(1,dprintf("No SigID!")); - sendf(tplci->appl,_CONNECT_R|CONFIRM,tplci->adapter->Id,0,"w",_OUT_OF_PLCI); - plci_remove(tplci); - break; - } - tplci->command = _CONNECT_R; - api_load_msg (&tplci->saved_msg, saved_parms); - add_s(tplci,CPN,&saved_parms[1]); - add_s(tplci,DSA,&saved_parms[3]); - add_ai(tplci,&saved_parms[9]); - sig_req(tplci,CALL_REQ,0); - send_req(tplci); - break; - - case CALL_RETRIEVE: - tplci->command = C_RETRIEVE_REQ; - sig_req(tplci,CALL_RETRIEVE,0); - send_req(tplci); - break; - } - tplci->spoofed_msg = 0; - if (tplci->internal_command == 0) - next_internal_command (x_Id, tplci); - } - } - next_internal_command (Id, plci); - break; - } - dbug(1,dprintf("***Codec Hook Init Req")); - plci->internal_command = PERM_COD_HOOK; - add_p(plci,FTY,"\x01\x09"); /* Get Hook State*/ - sig_req(plci,TEL_CTRL,0); - send_req(plci); - } - } - else if(plci->command != _MANUFACTURER_R /* old style permanent connect */ - && plci->State!=INC_ACT_PENDING) - { - mixer_set_bchannel_id_esc (plci, plci->b_channel); - if(plci->tel == ADV_VOICE && plci->SuppState == IDLE) /* with permanent codec switch on immediately */ - { - chi[2] = plci->b_channel; - SetVoiceChannel(a->AdvCodecPLCI, chi, a); - } - sendf(plci->appl,_CONNECT_ACTIVE_I,Id,0,"Sss",parms[21],"",""); - plci->State = INC_ACT_PENDING; - } - break; - - case TEL_CTRL: - ie = multi_fac_parms[0]; /* inspect the facility hook indications */ - if(plci->State==ADVANCED_VOICE_SIG && ie[0]){ - switch (ie[1]&0x91) { - case 0x80: /* hook off */ - case 0x81: - if(plci->internal_command==PERM_COD_HOOK) - { - dbug(1,dprintf("init:hook_off")); - plci->hook_state = ie[1]; - next_internal_command (Id, plci); - break; - } - else /* ignore doubled hook indications */ - { - if( ((plci->hook_state)&0xf0)==0x80) - { - dbug(1,dprintf("ignore hook")); - break; - } - plci->hook_state = ie[1]&0x91; - } - /* check for incoming call pending */ - /* and signal '+'.Appl must decide */ - /* with connect_res if call must */ - /* accepted or not */ - for(i=0, tplci=NULL;icodec_listen[i] - && (a->codec_listen[i]->State==INC_CON_PENDING - ||a->codec_listen[i]->State==INC_CON_ALERT) ){ - tplci = a->codec_listen[i]; - tplci->appl = &application[i]; - } - } - /* no incoming call, do outgoing call */ - /* and signal '+' if outg. setup */ - if(!a->AdvSignalPLCI && !tplci){ - if((i=get_plci(a))) { - a->AdvSignalPLCI = &a->plci[i-1]; - tplci = a->AdvSignalPLCI; - tplci->tel = ADV_VOICE; - PUT_WORD(&voice_cai[5],a->AdvSignalAppl->MaxDataLength); - if (a->Info_Mask[a->AdvSignalAppl->Id-1] & 0x200){ - /* early B3 connect (CIP mask bit 9) no release after a disc */ - add_p(tplci,LLI,"\x01\x01"); - } - add_p(tplci, CAI, voice_cai); - add_p(tplci, OAD, a->TelOAD); - add_p(tplci, OSA, a->TelOSA); - add_p(tplci,SHIFT|6,NULL); - add_p(tplci,SIN,"\x02\x01\x00"); - add_p(tplci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(tplci,ASSIGN,DSIG_ID); - a->AdvSignalPLCI->internal_command = HOOK_OFF_REQ; - a->AdvSignalPLCI->command = 0; - tplci->appl = a->AdvSignalAppl; - tplci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; - send_req(tplci); - } - - } - - if(!tplci) break; - Id = ((word)tplci->Id<<8)|a->Id; - Id|=EXT_CONTROLLER; - sendf(tplci->appl, - _FACILITY_I, - Id, - 0, - "ws", (word)0, "\x01+"); - break; - - case 0x90: /* hook on */ - case 0x91: - if(plci->internal_command==PERM_COD_HOOK) - { - dbug(1,dprintf("init:hook_on")); - plci->hook_state = ie[1]&0x91; - next_internal_command (Id, plci); - break; - } - else /* ignore doubled hook indications */ - { - if( ((plci->hook_state)&0xf0)==0x90) break; - plci->hook_state = ie[1]&0x91; - } - /* hangup the adv. voice call and signal '-' to the appl */ - if(a->AdvSignalPLCI) { - Id = ((word)a->AdvSignalPLCI->Id<<8)|a->Id; - if(plci->tel) Id|=EXT_CONTROLLER; - sendf(a->AdvSignalAppl, - _FACILITY_I, - Id, - 0, - "ws", (word)0, "\x01-"); - a->AdvSignalPLCI->internal_command = HOOK_ON_REQ; - a->AdvSignalPLCI->command = 0; - sig_req(a->AdvSignalPLCI,HANGUP,0); - send_req(a->AdvSignalPLCI); - } - break; - } - } - break; - - case RESUME: - clear_c_ind_mask_bit (plci, (word)(plci->appl->Id-1)); - PUT_WORD(&resume_cau[4],GOOD); - sendf(plci->appl,_FACILITY_I,Id,0,"ws", (word)3, resume_cau); - break; - - case SUSPEND: - clear_c_ind_mask (plci); - - if (plci->NL.Id && !plci->nl_remove_id) { - mixer_remove (plci); - nl_req_ncci(plci,REMOVE,0); - } - if (!plci->sig_remove_id) { - plci->internal_command = 0; - sig_req(plci,REMOVE,0); - } - send_req(plci); - if(!plci->channels) { - sendf(plci->appl,_FACILITY_I,Id,0,"ws", (word)3, "\x05\x04\x00\x02\x00\x00"); - sendf(plci->appl, _DISCONNECT_I, Id, 0, "w", 0); - } - break; - - case SUSPEND_REJ: - break; - - case HANGUP: - plci->hangup_flow_ctrl_timer=0; - if(plci->manufacturer && plci->State==LOCAL_CONNECT) break; - cau = parms[7]; - if(cau) { - i = _L3_CAUSE | cau[2]; - if(cau[2]==0) i = 0; - else if(cau[2]==8) i = _L1_ERROR; - else if(cau[2]==9 || cau[2]==10) i = _L2_ERROR; - else if(cau[2]==5) i = _CAPI_GUARD_ERROR; - } - else { - i = _L3_ERROR; - } - - if(plci->State==INC_CON_PENDING || plci->State==INC_CON_ALERT) - { - for(i=0; iappl) - { - if (plci->State == LISTENING) - { - plci->notifiedcall=0; - a->listen_active--; - } - plci->State = INC_DIS_PENDING; - if(c_ind_mask_empty (plci)) - { - plci->State = IDLE; - if (plci->NL.Id && !plci->nl_remove_id) - { - mixer_remove (plci); - nl_req_ncci(plci,REMOVE,0); - } - if (!plci->sig_remove_id) - { - plci->internal_command = 0; - sig_req(plci,REMOVE,0); - } - send_req(plci); - } - } - else - { - /* collision of DISCONNECT or CONNECT_RES with HANGUP can */ - /* result in a second HANGUP! Don't generate another */ - /* DISCONNECT */ - if(plci->State!=IDLE && plci->State!=INC_DIS_PENDING) - { - if(plci->State==RESUMING) - { - PUT_WORD(&resume_cau[4],i); - sendf(plci->appl,_FACILITY_I,Id,0,"ws", (word)3, resume_cau); - } - plci->State = INC_DIS_PENDING; - sendf(plci->appl,_DISCONNECT_I,Id,0,"w",i); - } - } - break; - - case SSEXT_IND: - SendSSExtInd(NULL,plci,Id,multi_ssext_parms); - break; - - case VSWITCH_REQ: - VSwitchReqInd(plci,Id,multi_vswitch_parms); - break; - case VSWITCH_IND: - if(plci->relatedPTYPLCI && - plci->vswitchstate==3 && - plci->relatedPTYPLCI->vswitchstate==3 && - parms[MAXPARMSIDS-1][0]) - { - add_p(plci->relatedPTYPLCI,SMSG,parms[MAXPARMSIDS-1]); - sig_req(plci->relatedPTYPLCI,VSWITCH_REQ,0); - send_req(plci->relatedPTYPLCI); - } - else VSwitchReqInd(plci,Id,multi_vswitch_parms); - break; - - } -} - - -static void SendSetupInfo(APPL * appl, PLCI * plci, dword Id, byte * * parms, byte Info_Sent_Flag) -{ - word i; - byte * ie; - word Info_Number; - byte * Info_Element; - word Info_Mask = 0; - - dbug(1,dprintf("SetupInfo")); - - for(i=0; iadapter->Info_Mask[appl->Id-1] & Info_Mask) { - sendf(appl,_INFO_I,Id,0,"wS",Info_Number,Info_Element); - } - } - } + byte *parms[MAXPARMSIDS]; + byte *add_i[4]; + byte *multi_fac_parms[MAX_MULTI_IE]; + byte *multi_pi_parms[MAX_MULTI_IE]; + byte *multi_ssext_parms[MAX_MULTI_IE]; + byte *multi_CiPN_parms[MAX_MULTI_IE]; + + byte *multi_vswitch_parms[MAX_MULTI_IE]; + + byte ai_len; + byte *esc_chi = ""; + byte *esc_law = ""; + byte *pty_cai = ""; + byte *esc_cr = ""; + byte *esc_profile = ""; + + byte facility[256]; + PLCI *tplci = NULL; + byte chi[] = "\x02\x18\x01"; + byte voice_cai[] = "\x06\x14\x00\x00\x00\x00\x08"; + byte resume_cau[] = "\x05\x05\x00\x02\x00\x00"; + /* ESC_MSGTYPE must be the last but one message, a new IE has to be */ + /* included before the ESC_MSGTYPE and MAXPARMSIDS has to be incremented */ + /* SMSG is situated at the end because its 0 (for compatibility reasons */ + /* (see Info_Mask Bit 4, first IE. then the message type) */ + word parms_id[] = + {MAXPARMSIDS, CPN, 0xff, DSA, OSA, BC, LLC, HLC, ESC_CAUSE, DSP, DT, CHA, + UUI, CONG_RR, CONG_RNR, ESC_CHI, KEY, CHI, CAU, ESC_LAW, + RDN, RDX, CONN_NR, RIN, NI, CAI, ESC_CR, + CST, ESC_PROFILE, 0xff, ESC_MSGTYPE, SMSG}; + /* 14 FTY repl by ESC_CHI */ + /* 18 PI repl by ESC_LAW */ + /* removed OAD changed to 0xff for future use, OAD is multiIE now */ + word multi_fac_id[] = {1, FTY}; + word multi_pi_id[] = {1, PI}; + word multi_CiPN_id[] = {1, OAD}; + word multi_ssext_id[] = {1, ESC_SSEXT}; + + word multi_vswitch_id[] = {1, ESC_VSWITCH}; + + byte *cau; + word ncci; + byte SS_Ind[] = "\x05\x02\x00\x02\x00\x00"; /* Hold_Ind struct*/ + byte CF_Ind[] = "\x09\x02\x00\x06\x00\x00\x00\x00\x00\x00"; + byte Interr_Err_Ind[] = "\x0a\x02\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + byte CONF_Ind[] = "\x09\x16\x00\x06\x00\x00\0x00\0x00\0x00\0x00"; + byte force_mt_info = false; + byte dir; + dword d; + word w; + + a = plci->adapter; + Id = ((word)plci->Id << 8) | a->Id; + PUT_WORD(&SS_Ind[4], 0x0000); + + if (plci->sig_remove_id) + { + plci->Sig.RNR = 2; /* discard */ + dbug(1, dprintf("SIG discard while remove pending")); + return; + } + if (plci->tel && plci->SuppState != CALL_HELD) Id |= EXT_CONTROLLER; + dbug(1, dprintf("SigInd-Id=%08lx,plci=%x,tel=%x,state=0x%x,channels=%d,Discflowcl=%d", + Id, plci->Id, plci->tel, plci->State, plci->channels, plci->hangup_flow_ctrl_timer)); + if (plci->Sig.Ind == CALL_HOLD_ACK && plci->channels) + { + plci->Sig.RNR = 1; + return; + } + if (plci->Sig.Ind == HANGUP && plci->channels) + { + plci->Sig.RNR = 1; + plci->hangup_flow_ctrl_timer++; + /* recover the network layer after timeout */ + if (plci->hangup_flow_ctrl_timer == 100) + { + dbug(1, dprintf("Exceptional disc")); + plci->Sig.RNR = 0; + plci->hangup_flow_ctrl_timer = 0; + for (ncci = 1; ncci < MAX_NCCI + 1; ncci++) + { + if (a->ncci_plci[ncci] == plci->Id) + { + cleanup_ncci_data(plci, ncci); + if (plci->channels)plci->channels--; + if (plci->appl) + sendf(plci->appl, _DISCONNECT_B3_I, (((dword) ncci) << 16) | Id, 0, "ws", 0, ""); + } + } + if (plci->appl) + sendf(plci->appl, _DISCONNECT_I, Id, 0, "w", 0); + plci_remove(plci); + plci->State = IDLE; + } + return; + } + + /* do first parse the info with no OAD in, because OAD will be converted */ + /* first the multiple facility IE, then mult. progress ind. */ + /* then the parameters for the info_ind + conn_ind */ + IndParse(plci, multi_fac_id, multi_fac_parms, MAX_MULTI_IE); + IndParse(plci, multi_pi_id, multi_pi_parms, MAX_MULTI_IE); + IndParse(plci, multi_ssext_id, multi_ssext_parms, MAX_MULTI_IE); + + IndParse(plci, multi_vswitch_id, multi_vswitch_parms, MAX_MULTI_IE); + + IndParse(plci, parms_id, parms, 0); + IndParse(plci, multi_CiPN_id, multi_CiPN_parms, MAX_MULTI_IE); + esc_chi = parms[14]; + esc_law = parms[18]; + pty_cai = parms[24]; + esc_cr = parms[25]; + esc_profile = parms[27]; + if (esc_cr[0] && plci) + { + if (plci->cr_enquiry && plci->appl) + { + plci->cr_enquiry = false; + /* d = MANU_ID */ + /* w = m_command */ + /* b = total length */ + /* b = indication type */ + /* b = length of all IEs */ + /* b = IE1 */ + /* S = IE1 length + cont. */ + /* b = IE2 */ + /* S = IE2 length + cont. */ + sendf(plci->appl, + _MANUFACTURER_I, + Id, + 0, + "dwbbbbSbS", _DI_MANU_ID, plci->m_command, + 2 + 1 + 1 + esc_cr[0] + 1 + 1 + esc_law[0], plci->Sig.Ind, 1 + 1 + esc_cr[0] + 1 + 1 + esc_law[0], ESC, esc_cr, ESC, esc_law); + } + } + /* create the additional info structure */ + add_i[1] = parms[15]; /* KEY of additional info */ + add_i[2] = parms[11]; /* UUI of additional info */ + ai_len = AddInfo(add_i, multi_fac_parms, esc_chi, facility); + + /* the ESC_LAW indicates if u-Law or a-Law is actually used by the card */ + /* indication returns by the card if requested by the function */ + /* AutomaticLaw() after driver init */ + if (a->automatic_law < 4) + { + if (esc_law[0]) { + if (esc_law[2]) { + dbug(0, dprintf("u-Law selected")); + a->u_law = 1; + } + else { + dbug(0, dprintf("a-Law selected")); + a->u_law = 0; + } + a->automatic_law = 4; + if (plci == a->automatic_lawPLCI) { + plci->internal_command = 0; + sig_req(plci, REMOVE, 0); + send_req(plci); + a->automatic_lawPLCI = NULL; + } + } + if (esc_profile[0]) + { + dbug(1, dprintf("[%06x] CardProfile: %lx %lx %lx %lx %lx", + UnMapController(a->Id), GET_DWORD(&esc_profile[6]), + GET_DWORD(&esc_profile[10]), GET_DWORD(&esc_profile[14]), + GET_DWORD(&esc_profile[18]), GET_DWORD(&esc_profile[46]))); + + a->profile.Global_Options &= 0x000000ffL; + a->profile.B1_Protocols &= 0x000003ffL; + a->profile.B2_Protocols &= 0x00001fdfL; + a->profile.B3_Protocols &= 0x000000b7L; + + a->profile.Global_Options &= GET_DWORD(&esc_profile[6]) | + GL_BCHANNEL_OPERATION_SUPPORTED; + a->profile.B1_Protocols &= GET_DWORD(&esc_profile[10]); + a->profile.B2_Protocols &= GET_DWORD(&esc_profile[14]); + a->profile.B3_Protocols &= GET_DWORD(&esc_profile[18]); + a->manufacturer_features = GET_DWORD(&esc_profile[46]); + a->man_profile.private_options = 0; + + if (a->manufacturer_features & MANUFACTURER_FEATURE_ECHO_CANCELLER) + { + a->man_profile.private_options |= 1L << PRIVATE_ECHO_CANCELLER; + a->profile.Global_Options |= GL_ECHO_CANCELLER_SUPPORTED; + } + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_RTP) + a->man_profile.private_options |= 1L << PRIVATE_RTP; + a->man_profile.rtp_primary_payloads = GET_DWORD(&esc_profile[50]); + a->man_profile.rtp_additional_payloads = GET_DWORD(&esc_profile[54]); + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_T38) + a->man_profile.private_options |= 1L << PRIVATE_T38; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_SUB_SEP_PWD) + a->man_profile.private_options |= 1L << PRIVATE_FAX_SUB_SEP_PWD; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_V18) + a->man_profile.private_options |= 1L << PRIVATE_V18; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_DTMF_TONE) + a->man_profile.private_options |= 1L << PRIVATE_DTMF_TONE; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_PIAFS) + a->man_profile.private_options |= 1L << PRIVATE_PIAFS; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) + a->man_profile.private_options |= 1L << PRIVATE_FAX_PAPER_FORMATS; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_VOWN) + a->man_profile.private_options |= 1L << PRIVATE_VOWN; + + + if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_NONSTANDARD) + a->man_profile.private_options |= 1L << PRIVATE_FAX_NONSTANDARD; + + } + else + { + a->profile.Global_Options &= 0x0000007fL; + a->profile.B1_Protocols &= 0x000003dfL; + a->profile.B2_Protocols &= 0x00001adfL; + a->profile.B3_Protocols &= 0x000000b7L; + a->manufacturer_features &= MANUFACTURER_FEATURE_HARDDTMF; + } + if (a->manufacturer_features & (MANUFACTURER_FEATURE_HARDDTMF | + MANUFACTURER_FEATURE_SOFTDTMF_SEND | MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE)) + { + a->profile.Global_Options |= GL_DTMF_SUPPORTED; + } + a->manufacturer_features &= ~MANUFACTURER_FEATURE_OOB_CHANNEL; + dbug(1, dprintf("[%06x] Profile: %lx %lx %lx %lx %lx", + UnMapController(a->Id), a->profile.Global_Options, + a->profile.B1_Protocols, a->profile.B2_Protocols, + a->profile.B3_Protocols, a->manufacturer_features)); + } + /* codec plci for the handset/hook state support is just an internal id */ + if (plci != a->AdvCodecPLCI) + { + force_mt_info = SendMultiIE(plci, Id, multi_fac_parms, FTY, 0x20, 0); + force_mt_info |= SendMultiIE(plci, Id, multi_pi_parms, PI, 0x210, 0); + SendSSExtInd(NULL, plci, Id, multi_ssext_parms); + SendInfo(plci, Id, parms, force_mt_info); + + VSwitchReqInd(plci, Id, multi_vswitch_parms); + + } + + /* switch the codec to the b-channel */ + if (esc_chi[0] && plci && !plci->SuppState) { + plci->b_channel = esc_chi[esc_chi[0]]&0x1f; + mixer_set_bchannel_id_esc(plci, plci->b_channel); + dbug(1, dprintf("storeChannel=0x%x", plci->b_channel)); + if (plci->tel == ADV_VOICE && plci->appl) { + SetVoiceChannel(a->AdvCodecPLCI, esc_chi, a); + } + } + + if (plci->appl) plci->appl->Number++; + + switch (plci->Sig.Ind) { + /* Response to Get_Supported_Services request */ + case S_SUPPORTED: + dbug(1, dprintf("S_Supported")); + if (!plci->appl) break; + if (pty_cai[0] == 4) + { + PUT_DWORD(&CF_Ind[6], GET_DWORD(&pty_cai[1])); + } + else + { + PUT_DWORD(&CF_Ind[6], MASK_TERMINAL_PORTABILITY | MASK_HOLD_RETRIEVE); + } + PUT_WORD(&CF_Ind[1], 0); + PUT_WORD(&CF_Ind[4], 0); + sendf(plci->appl, _FACILITY_R | CONFIRM, Id & 0x7, plci->number, "wws", 0, 3, CF_Ind); + plci_remove(plci); + break; + + /* Supplementary Service rejected */ + case S_SERVICE_REJ: + dbug(1, dprintf("S_Reject=0x%x", pty_cai[5])); + if (!pty_cai[0]) break; + switch (pty_cai[5]) + { + case ECT_EXECUTE: + case THREE_PTY_END: + case THREE_PTY_BEGIN: + if (!plci->relatedPTYPLCI) break; + tplci = plci->relatedPTYPLCI; + rId = ((word)tplci->Id << 8) | tplci->adapter->Id; + if (tplci->tel) rId |= EXT_CONTROLLER; + if (pty_cai[5] == ECT_EXECUTE) + { + PUT_WORD(&SS_Ind[1], S_ECT); + + plci->vswitchstate = 0; + plci->relatedPTYPLCI->vswitchstate = 0; + + } + else + { + PUT_WORD(&SS_Ind[1], pty_cai[5] + 3); + } + if (pty_cai[2] != 0xff) + { + PUT_WORD(&SS_Ind[4], 0x3600 | (word)pty_cai[2]); + } + else + { + PUT_WORD(&SS_Ind[4], 0x300E); + } + plci->relatedPTYPLCI = NULL; + plci->ptyState = 0; + sendf(tplci->appl, _FACILITY_I, rId, 0, "ws", 3, SS_Ind); + break; + + case CALL_DEFLECTION: + if (pty_cai[2] != 0xff) + { + PUT_WORD(&SS_Ind[4], 0x3600 | (word)pty_cai[2]); + } + else + { + PUT_WORD(&SS_Ind[4], 0x300E); + } + PUT_WORD(&SS_Ind[1], pty_cai[5]); + for (i = 0; i < max_appl; i++) + { + if (application[i].CDEnable) + { + if (application[i].Id) sendf(&application[i], _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + application[i].CDEnable = false; + } + } + break; + + case DEACTIVATION_DIVERSION: + case ACTIVATION_DIVERSION: + case DIVERSION_INTERROGATE_CFU: + case DIVERSION_INTERROGATE_CFB: + case DIVERSION_INTERROGATE_CFNR: + case DIVERSION_INTERROGATE_NUM: + case CCBS_REQUEST: + case CCBS_DEACTIVATE: + case CCBS_INTERROGATE: + if (!plci->appl) break; + if (pty_cai[2] != 0xff) + { + PUT_WORD(&Interr_Err_Ind[4], 0x3600 | (word)pty_cai[2]); + } + else + { + PUT_WORD(&Interr_Err_Ind[4], 0x300E); + } + switch (pty_cai[5]) + { + case DEACTIVATION_DIVERSION: + dbug(1, dprintf("Deact_Div")); + Interr_Err_Ind[0] = 0x9; + Interr_Err_Ind[3] = 0x6; + PUT_WORD(&Interr_Err_Ind[1], S_CALL_FORWARDING_STOP); + break; + case ACTIVATION_DIVERSION: + dbug(1, dprintf("Act_Div")); + Interr_Err_Ind[0] = 0x9; + Interr_Err_Ind[3] = 0x6; + PUT_WORD(&Interr_Err_Ind[1], S_CALL_FORWARDING_START); + break; + case DIVERSION_INTERROGATE_CFU: + case DIVERSION_INTERROGATE_CFB: + case DIVERSION_INTERROGATE_CFNR: + dbug(1, dprintf("Interr_Div")); + Interr_Err_Ind[0] = 0xa; + Interr_Err_Ind[3] = 0x7; + PUT_WORD(&Interr_Err_Ind[1], S_INTERROGATE_DIVERSION); + break; + case DIVERSION_INTERROGATE_NUM: + dbug(1, dprintf("Interr_Num")); + Interr_Err_Ind[0] = 0xa; + Interr_Err_Ind[3] = 0x7; + PUT_WORD(&Interr_Err_Ind[1], S_INTERROGATE_NUMBERS); + break; + case CCBS_REQUEST: + dbug(1, dprintf("CCBS Request")); + Interr_Err_Ind[0] = 0xd; + Interr_Err_Ind[3] = 0xa; + PUT_WORD(&Interr_Err_Ind[1], S_CCBS_REQUEST); + break; + case CCBS_DEACTIVATE: + dbug(1, dprintf("CCBS Deactivate")); + Interr_Err_Ind[0] = 0x9; + Interr_Err_Ind[3] = 0x6; + PUT_WORD(&Interr_Err_Ind[1], S_CCBS_DEACTIVATE); + break; + case CCBS_INTERROGATE: + dbug(1, dprintf("CCBS Interrogate")); + Interr_Err_Ind[0] = 0xb; + Interr_Err_Ind[3] = 0x8; + PUT_WORD(&Interr_Err_Ind[1], S_CCBS_INTERROGATE); + break; + } + PUT_DWORD(&Interr_Err_Ind[6], plci->appl->S_Handle); + sendf(plci->appl, _FACILITY_I, Id & 0x7, 0, "ws", 3, Interr_Err_Ind); + plci_remove(plci); + break; + case ACTIVATION_MWI: + case DEACTIVATION_MWI: + if (pty_cai[5] == ACTIVATION_MWI) + { + PUT_WORD(&SS_Ind[1], S_MWI_ACTIVATE); + } + else PUT_WORD(&SS_Ind[1], S_MWI_DEACTIVATE); + + if (pty_cai[2] != 0xff) + { + PUT_WORD(&SS_Ind[4], 0x3600 | (word)pty_cai[2]); + } + else + { + PUT_WORD(&SS_Ind[4], 0x300E); + } + + if (plci->cr_enquiry) + { + sendf(plci->appl, _FACILITY_I, Id & 0xf, 0, "ws", 3, SS_Ind); + plci_remove(plci); + } + else + { + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + } + break; + case CONF_ADD: /* ERROR */ + case CONF_BEGIN: + case CONF_DROP: + case CONF_ISOLATE: + case CONF_REATTACH: + CONF_Ind[0] = 9; + CONF_Ind[3] = 6; + switch (pty_cai[5]) + { + case CONF_BEGIN: + PUT_WORD(&CONF_Ind[1], S_CONF_BEGIN); + plci->ptyState = 0; + break; + case CONF_DROP: + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + PUT_WORD(&CONF_Ind[1], S_CONF_DROP); + plci->ptyState = CONNECTED; + break; + case CONF_ISOLATE: + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + PUT_WORD(&CONF_Ind[1], S_CONF_ISOLATE); + plci->ptyState = CONNECTED; + break; + case CONF_REATTACH: + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + PUT_WORD(&CONF_Ind[1], S_CONF_REATTACH); + plci->ptyState = CONNECTED; + break; + case CONF_ADD: + PUT_WORD(&CONF_Ind[1], S_CONF_ADD); + plci->relatedPTYPLCI = NULL; + tplci = plci->relatedPTYPLCI; + if (tplci) tplci->ptyState = CONNECTED; + plci->ptyState = CONNECTED; + break; + } + + if (pty_cai[2] != 0xff) + { + PUT_WORD(&CONF_Ind[4], 0x3600 | (word)pty_cai[2]); + } + else + { + PUT_WORD(&CONF_Ind[4], 0x3303); /* Time-out: network did not respond + within the required time */ + } + + PUT_DWORD(&CONF_Ind[6], 0x0); + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, CONF_Ind); + break; + } + break; + + /* Supplementary Service indicates success */ + case S_SERVICE: + dbug(1, dprintf("Service_Ind")); + PUT_WORD(&CF_Ind[4], 0); + switch (pty_cai[5]) + { + case THREE_PTY_END: + case THREE_PTY_BEGIN: + case ECT_EXECUTE: + if (!plci->relatedPTYPLCI) break; + tplci = plci->relatedPTYPLCI; + rId = ((word)tplci->Id << 8) | tplci->adapter->Id; + if (tplci->tel) rId |= EXT_CONTROLLER; + if (pty_cai[5] == ECT_EXECUTE) + { + PUT_WORD(&SS_Ind[1], S_ECT); + + if (plci->vswitchstate != 3) + { + + plci->ptyState = IDLE; + plci->relatedPTYPLCI = NULL; + plci->ptyState = 0; + + } + + dbug(1, dprintf("ECT OK")); + sendf(tplci->appl, _FACILITY_I, rId, 0, "ws", 3, SS_Ind); + + + + } + else + { + switch (plci->ptyState) + { + case S_3PTY_BEGIN: + plci->ptyState = CONNECTED; + dbug(1, dprintf("3PTY ON")); + break; + + case S_3PTY_END: + plci->ptyState = IDLE; + plci->relatedPTYPLCI = NULL; + plci->ptyState = 0; + dbug(1, dprintf("3PTY OFF")); + break; + } + PUT_WORD(&SS_Ind[1], pty_cai[5] + 3); + sendf(tplci->appl, _FACILITY_I, rId, 0, "ws", 3, SS_Ind); + } + break; + + case CALL_DEFLECTION: + PUT_WORD(&SS_Ind[1], pty_cai[5]); + for (i = 0; i < max_appl; i++) + { + if (application[i].CDEnable) + { + if (application[i].Id) sendf(&application[i], _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + application[i].CDEnable = false; + } + } + break; + + case DEACTIVATION_DIVERSION: + case ACTIVATION_DIVERSION: + if (!plci->appl) break; + PUT_WORD(&CF_Ind[1], pty_cai[5] + 2); + PUT_DWORD(&CF_Ind[6], plci->appl->S_Handle); + sendf(plci->appl, _FACILITY_I, Id & 0x7, 0, "ws", 3, CF_Ind); + plci_remove(plci); + break; + + case DIVERSION_INTERROGATE_CFU: + case DIVERSION_INTERROGATE_CFB: + case DIVERSION_INTERROGATE_CFNR: + case DIVERSION_INTERROGATE_NUM: + case CCBS_REQUEST: + case CCBS_DEACTIVATE: + case CCBS_INTERROGATE: + if (!plci->appl) break; + switch (pty_cai[5]) + { + case DIVERSION_INTERROGATE_CFU: + case DIVERSION_INTERROGATE_CFB: + case DIVERSION_INTERROGATE_CFNR: + dbug(1, dprintf("Interr_Div")); + PUT_WORD(&pty_cai[1], S_INTERROGATE_DIVERSION); + pty_cai[3] = pty_cai[0] - 3; /* Supplementary Service-specific parameter len */ + break; + case DIVERSION_INTERROGATE_NUM: + dbug(1, dprintf("Interr_Num")); + PUT_WORD(&pty_cai[1], S_INTERROGATE_NUMBERS); + pty_cai[3] = pty_cai[0] - 3; /* Supplementary Service-specific parameter len */ + break; + case CCBS_REQUEST: + dbug(1, dprintf("CCBS Request")); + PUT_WORD(&pty_cai[1], S_CCBS_REQUEST); + pty_cai[3] = pty_cai[0] - 3; /* Supplementary Service-specific parameter len */ + break; + case CCBS_DEACTIVATE: + dbug(1, dprintf("CCBS Deactivate")); + PUT_WORD(&pty_cai[1], S_CCBS_DEACTIVATE); + pty_cai[3] = pty_cai[0] - 3; /* Supplementary Service-specific parameter len */ + break; + case CCBS_INTERROGATE: + dbug(1, dprintf("CCBS Interrogate")); + PUT_WORD(&pty_cai[1], S_CCBS_INTERROGATE); + pty_cai[3] = pty_cai[0] - 3; /* Supplementary Service-specific parameter len */ + break; + } + PUT_WORD(&pty_cai[4], 0); /* Supplementary Service Reason */ + PUT_DWORD(&pty_cai[6], plci->appl->S_Handle); + sendf(plci->appl, _FACILITY_I, Id & 0x7, 0, "wS", 3, pty_cai); + plci_remove(plci); + break; + + case ACTIVATION_MWI: + case DEACTIVATION_MWI: + if (pty_cai[5] == ACTIVATION_MWI) + { + PUT_WORD(&SS_Ind[1], S_MWI_ACTIVATE); + } + else PUT_WORD(&SS_Ind[1], S_MWI_DEACTIVATE); + if (plci->cr_enquiry) + { + sendf(plci->appl, _FACILITY_I, Id & 0xf, 0, "ws", 3, SS_Ind); + plci_remove(plci); + } + else + { + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + } + break; + case MWI_INDICATION: + if (pty_cai[0] >= 0x12) + { + PUT_WORD(&pty_cai[3], S_MWI_INDICATE); + pty_cai[2] = pty_cai[0] - 2; /* len Parameter */ + pty_cai[5] = pty_cai[0] - 5; /* Supplementary Service-specific parameter len */ + if (plci->appl && (a->Notification_Mask[plci->appl->Id - 1] & SMASK_MWI)) + { + if (plci->internal_command == GET_MWI_STATE) /* result on Message Waiting Listen */ + { + sendf(plci->appl, _FACILITY_I, Id & 0xf, 0, "wS", 3, &pty_cai[2]); + plci_remove(plci); + return; + } + else sendf(plci->appl, _FACILITY_I, Id, 0, "wS", 3, &pty_cai[2]); + pty_cai[0] = 0; + } + else + { + for (i = 0; i < max_appl; i++) + { + if (a->Notification_Mask[i]&SMASK_MWI) + { + sendf(&application[i], _FACILITY_I, Id & 0x7, 0, "wS", 3, &pty_cai[2]); + pty_cai[0] = 0; + } + } + } + + if (!pty_cai[0]) + { /* acknowledge */ + facility[2] = 0; /* returncode */ + } + else facility[2] = 0xff; + } + else + { + /* reject */ + facility[2] = 0xff; /* returncode */ + } + facility[0] = 2; + facility[1] = MWI_RESPONSE; /* Function */ + add_p(plci, CAI, facility); + add_p(plci, ESC, multi_ssext_parms[0]); /* remembered parameter -> only one possible */ + sig_req(plci, S_SERVICE, 0); + send_req(plci); + plci->command = 0; + next_internal_command(Id, plci); + break; + case CONF_ADD: /* OK */ + case CONF_BEGIN: + case CONF_DROP: + case CONF_ISOLATE: + case CONF_REATTACH: + case CONF_PARTYDISC: + CONF_Ind[0] = 9; + CONF_Ind[3] = 6; + switch (pty_cai[5]) + { + case CONF_BEGIN: + PUT_WORD(&CONF_Ind[1], S_CONF_BEGIN); + if (pty_cai[0] == 6) + { + d = pty_cai[6]; + PUT_DWORD(&CONF_Ind[6], d); /* PartyID */ + } + else + { + PUT_DWORD(&CONF_Ind[6], 0x0); + } + break; + case CONF_ISOLATE: + PUT_WORD(&CONF_Ind[1], S_CONF_ISOLATE); + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + break; + case CONF_REATTACH: + PUT_WORD(&CONF_Ind[1], S_CONF_REATTACH); + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + break; + case CONF_DROP: + PUT_WORD(&CONF_Ind[1], S_CONF_DROP); + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + break; + case CONF_ADD: + PUT_WORD(&CONF_Ind[1], S_CONF_ADD); + d = pty_cai[6]; + PUT_DWORD(&CONF_Ind[6], d); /* PartyID */ + tplci = plci->relatedPTYPLCI; + if (tplci) tplci->ptyState = CONNECTED; + break; + case CONF_PARTYDISC: + CONF_Ind[0] = 7; + CONF_Ind[3] = 4; + PUT_WORD(&CONF_Ind[1], S_CONF_PARTYDISC); + d = pty_cai[6]; + PUT_DWORD(&CONF_Ind[4], d); /* PartyID */ + break; + } + plci->ptyState = CONNECTED; + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, CONF_Ind); + break; + case CCBS_INFO_RETAIN: + case CCBS_ERASECALLLINKAGEID: + case CCBS_STOP_ALERTING: + CONF_Ind[0] = 5; + CONF_Ind[3] = 2; + switch (pty_cai[5]) + { + case CCBS_INFO_RETAIN: + PUT_WORD(&CONF_Ind[1], S_CCBS_INFO_RETAIN); + break; + case CCBS_STOP_ALERTING: + PUT_WORD(&CONF_Ind[1], S_CCBS_STOP_ALERTING); + break; + case CCBS_ERASECALLLINKAGEID: + PUT_WORD(&CONF_Ind[1], S_CCBS_ERASECALLLINKAGEID); + CONF_Ind[0] = 7; + CONF_Ind[3] = 4; + CONF_Ind[6] = 0; + CONF_Ind[7] = 0; + break; + } + w = pty_cai[6]; + PUT_WORD(&CONF_Ind[4], w); /* PartyID */ + + if (plci->appl && (a->Notification_Mask[plci->appl->Id - 1] & SMASK_CCBS)) + { + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, CONF_Ind); + } + else + { + for (i = 0; i < max_appl; i++) + if (a->Notification_Mask[i] & SMASK_CCBS) + sendf(&application[i], _FACILITY_I, Id & 0x7, 0, "ws", 3, CONF_Ind); + } + break; + } + break; + case CALL_HOLD_REJ: + cau = parms[7]; + if (cau) + { + i = _L3_CAUSE | cau[2]; + if (cau[2] == 0) i = 0x3603; + } + else + { + i = 0x3603; + } + PUT_WORD(&SS_Ind[1], S_HOLD); + PUT_WORD(&SS_Ind[4], i); + if (plci->SuppState == HOLD_REQUEST) + { + plci->SuppState = IDLE; + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + } + break; + + case CALL_HOLD_ACK: + if (plci->SuppState == HOLD_REQUEST) + { + plci->SuppState = CALL_HELD; + CodecIdCheck(a, plci); + start_internal_command(Id, plci, hold_save_command); + } + break; + + case CALL_RETRIEVE_REJ: + cau = parms[7]; + if (cau) + { + i = _L3_CAUSE | cau[2]; + if (cau[2] == 0) i = 0x3603; + } + else + { + i = 0x3603; + } + PUT_WORD(&SS_Ind[1], S_RETRIEVE); + PUT_WORD(&SS_Ind[4], i); + if (plci->SuppState == RETRIEVE_REQUEST) + { + plci->SuppState = CALL_HELD; + CodecIdCheck(a, plci); + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + } + break; + + case CALL_RETRIEVE_ACK: + PUT_WORD(&SS_Ind[1], S_RETRIEVE); + if (plci->SuppState == RETRIEVE_REQUEST) + { + plci->SuppState = IDLE; + plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; + plci->b_channel = esc_chi[esc_chi[0]]&0x1f; + if (plci->tel) + { + mixer_set_bchannel_id_esc(plci, plci->b_channel); + dbug(1, dprintf("RetrChannel=0x%x", plci->b_channel)); + SetVoiceChannel(a->AdvCodecPLCI, esc_chi, a); + if (plci->B2_prot == B2_TRANSPARENT && plci->B3_prot == B3_TRANSPARENT) + { + dbug(1, dprintf("Get B-ch")); + start_internal_command(Id, plci, retrieve_restore_command); + } + else + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", 3, SS_Ind); + } + else + start_internal_command(Id, plci, retrieve_restore_command); + } + break; + + case INDICATE_IND: + if (plci->State != LISTENING) { + sig_req(plci, HANGUP, 0); + send_req(plci); + break; + } + cip = find_cip(a, parms[4], parms[6]); + cip_mask = 1L << cip; + dbug(1, dprintf("cip=%d,cip_mask=%lx", cip, cip_mask)); + clear_c_ind_mask(plci); + if (!remove_started && !a->adapter_disabled) + { + set_c_ind_mask_bit(plci, MAX_APPL); + group_optimization(a, plci); + for (i = 0; i < max_appl; i++) { + if (application[i].Id + && (a->CIP_Mask[i] & 1 || a->CIP_Mask[i] & cip_mask) + && CPN_filter_ok(parms[0], a, i) + && test_group_ind_mask_bit(plci, i)) { + dbug(1, dprintf("storedcip_mask[%d]=0x%lx", i, a->CIP_Mask[i])); + set_c_ind_mask_bit(plci, i); + dump_c_ind_mask(plci); + plci->State = INC_CON_PENDING; + plci->call_dir = (plci->call_dir & ~(CALL_DIR_OUT | CALL_DIR_ORIGINATE)) | + CALL_DIR_IN | CALL_DIR_ANSWER; + if (esc_chi[0]) { + plci->b_channel = esc_chi[esc_chi[0]] & 0x1f; + mixer_set_bchannel_id_esc(plci, plci->b_channel); + } + /* if a listen on the ext controller is done, check if hook states */ + /* are supported or if just a on board codec must be activated */ + if (a->codec_listen[i] && !a->AdvSignalPLCI) { + if (a->profile.Global_Options & HANDSET) + plci->tel = ADV_VOICE; + else if (a->profile.Global_Options & ON_BOARD_CODEC) + plci->tel = CODEC; + if (plci->tel) Id |= EXT_CONTROLLER; + a->codec_listen[i] = plci; + } + + sendf(&application[i], _CONNECT_I, Id, 0, + "wSSSSSSSbSSSSS", cip, /* CIP */ + parms[0], /* CalledPartyNumber */ + multi_CiPN_parms[0], /* CallingPartyNumber */ + parms[2], /* CalledPartySubad */ + parms[3], /* CallingPartySubad */ + parms[4], /* BearerCapability */ + parms[5], /* LowLC */ + parms[6], /* HighLC */ + ai_len, /* nested struct add_i */ + add_i[0], /* B channel info */ + add_i[1], /* keypad facility */ + add_i[2], /* user user data */ + add_i[3], /* nested facility */ + multi_CiPN_parms[1] /* second CiPN(SCR) */ + ); + SendSSExtInd(&application[i], + plci, + Id, + multi_ssext_parms); + SendSetupInfo(&application[i], + plci, + Id, + parms, + SendMultiIE(plci, Id, multi_pi_parms, PI, 0x210, true)); + } + } + clear_c_ind_mask_bit(plci, MAX_APPL); + dump_c_ind_mask(plci); + } + if (c_ind_mask_empty(plci)) { + sig_req(plci, HANGUP, 0); + send_req(plci); + plci->State = IDLE; + } + plci->notifiedcall = 0; + a->listen_active--; + listen_check(a); + break; + + case CALL_PEND_NOTIFY: + plci->notifiedcall = 1; + listen_check(a); + break; + + case CALL_IND: + case CALL_CON: + if (plci->State == ADVANCED_VOICE_SIG || plci->State == ADVANCED_VOICE_NOSIG) + { + if (plci->internal_command == PERM_COD_CONN_PEND) + { + if (plci->State == ADVANCED_VOICE_NOSIG) + { + dbug(1, dprintf("***Codec OK")); + if (a->AdvSignalPLCI) + { + tplci = a->AdvSignalPLCI; + if (tplci->spoofed_msg) + { + dbug(1, dprintf("***Spoofed Msg(0x%x)", tplci->spoofed_msg)); + tplci->command = 0; + tplci->internal_command = 0; + x_Id = ((word)tplci->Id << 8) | tplci->adapter->Id | 0x80; + switch (tplci->spoofed_msg) + { + case CALL_RES: + tplci->command = _CONNECT_I | RESPONSE; + api_load_msg(&tplci->saved_msg, saved_parms); + add_b1(tplci, &saved_parms[1], 0, tplci->B1_facilities); + if (tplci->adapter->Info_Mask[tplci->appl->Id - 1] & 0x200) + { + /* early B3 connect (CIP mask bit 9) no release after a disc */ + add_p(tplci, LLI, "\x01\x01"); + } + add_s(tplci, CONN_NR, &saved_parms[2]); + add_s(tplci, LLC, &saved_parms[4]); + add_ai(tplci, &saved_parms[5]); + tplci->State = INC_CON_ACCEPT; + sig_req(tplci, CALL_RES, 0); + send_req(tplci); + break; + + case AWAITING_SELECT_B: + dbug(1, dprintf("Select_B continue")); + start_internal_command(x_Id, tplci, select_b_command); + break; + + case AWAITING_MANUF_CON: /* Get_Plci per Manufacturer_Req to ext controller */ + if (!tplci->Sig.Id) + { + dbug(1, dprintf("No SigID!")); + sendf(tplci->appl, _MANUFACTURER_R | CONFIRM, x_Id, tplci->number, "dww", _DI_MANU_ID, _MANUFACTURER_R, _OUT_OF_PLCI); + plci_remove(tplci); + break; + } + tplci->command = _MANUFACTURER_R; + api_load_msg(&tplci->saved_msg, saved_parms); + dir = saved_parms[2].info[0]; + if (dir == 1) { + sig_req(tplci, CALL_REQ, 0); + } + else if (!dir) { + sig_req(tplci, LISTEN_REQ, 0); + } + send_req(tplci); + sendf(tplci->appl, _MANUFACTURER_R | CONFIRM, x_Id, tplci->number, "dww", _DI_MANU_ID, _MANUFACTURER_R, 0); + break; + + case (CALL_REQ | AWAITING_MANUF_CON): + sig_req(tplci, CALL_REQ, 0); + send_req(tplci); + break; + + case CALL_REQ: + if (!tplci->Sig.Id) + { + dbug(1, dprintf("No SigID!")); + sendf(tplci->appl, _CONNECT_R | CONFIRM, tplci->adapter->Id, 0, "w", _OUT_OF_PLCI); + plci_remove(tplci); + break; + } + tplci->command = _CONNECT_R; + api_load_msg(&tplci->saved_msg, saved_parms); + add_s(tplci, CPN, &saved_parms[1]); + add_s(tplci, DSA, &saved_parms[3]); + add_ai(tplci, &saved_parms[9]); + sig_req(tplci, CALL_REQ, 0); + send_req(tplci); + break; + + case CALL_RETRIEVE: + tplci->command = C_RETRIEVE_REQ; + sig_req(tplci, CALL_RETRIEVE, 0); + send_req(tplci); + break; + } + tplci->spoofed_msg = 0; + if (tplci->internal_command == 0) + next_internal_command(x_Id, tplci); + } + } + next_internal_command(Id, plci); + break; + } + dbug(1, dprintf("***Codec Hook Init Req")); + plci->internal_command = PERM_COD_HOOK; + add_p(plci, FTY, "\x01\x09"); /* Get Hook State*/ + sig_req(plci, TEL_CTRL, 0); + send_req(plci); + } + } + else if (plci->command != _MANUFACTURER_R /* old style permanent connect */ + && plci->State != INC_ACT_PENDING) + { + mixer_set_bchannel_id_esc(plci, plci->b_channel); + if (plci->tel == ADV_VOICE && plci->SuppState == IDLE) /* with permanent codec switch on immediately */ + { + chi[2] = plci->b_channel; + SetVoiceChannel(a->AdvCodecPLCI, chi, a); + } + sendf(plci->appl, _CONNECT_ACTIVE_I, Id, 0, "Sss", parms[21], "", ""); + plci->State = INC_ACT_PENDING; + } + break; + + case TEL_CTRL: + ie = multi_fac_parms[0]; /* inspect the facility hook indications */ + if (plci->State == ADVANCED_VOICE_SIG && ie[0]) { + switch (ie[1] & 0x91) { + case 0x80: /* hook off */ + case 0x81: + if (plci->internal_command == PERM_COD_HOOK) + { + dbug(1, dprintf("init:hook_off")); + plci->hook_state = ie[1]; + next_internal_command(Id, plci); + break; + } + else /* ignore doubled hook indications */ + { + if (((plci->hook_state) & 0xf0) == 0x80) + { + dbug(1, dprintf("ignore hook")); + break; + } + plci->hook_state = ie[1]&0x91; + } + /* check for incoming call pending */ + /* and signal '+'.Appl must decide */ + /* with connect_res if call must */ + /* accepted or not */ + for (i = 0, tplci = NULL; i < max_appl; i++) { + if (a->codec_listen[i] + && (a->codec_listen[i]->State == INC_CON_PENDING + || a->codec_listen[i]->State == INC_CON_ALERT)) { + tplci = a->codec_listen[i]; + tplci->appl = &application[i]; + } + } + /* no incoming call, do outgoing call */ + /* and signal '+' if outg. setup */ + if (!a->AdvSignalPLCI && !tplci) { + if ((i = get_plci(a))) { + a->AdvSignalPLCI = &a->plci[i - 1]; + tplci = a->AdvSignalPLCI; + tplci->tel = ADV_VOICE; + PUT_WORD(&voice_cai[5], a->AdvSignalAppl->MaxDataLength); + if (a->Info_Mask[a->AdvSignalAppl->Id - 1] & 0x200) { + /* early B3 connect (CIP mask bit 9) no release after a disc */ + add_p(tplci, LLI, "\x01\x01"); + } + add_p(tplci, CAI, voice_cai); + add_p(tplci, OAD, a->TelOAD); + add_p(tplci, OSA, a->TelOSA); + add_p(tplci, SHIFT | 6, NULL); + add_p(tplci, SIN, "\x02\x01\x00"); + add_p(tplci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(tplci, ASSIGN, DSIG_ID); + a->AdvSignalPLCI->internal_command = HOOK_OFF_REQ; + a->AdvSignalPLCI->command = 0; + tplci->appl = a->AdvSignalAppl; + tplci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; + send_req(tplci); + } + + } + + if (!tplci) break; + Id = ((word)tplci->Id << 8) | a->Id; + Id |= EXT_CONTROLLER; + sendf(tplci->appl, + _FACILITY_I, + Id, + 0, + "ws", (word)0, "\x01+"); + break; + + case 0x90: /* hook on */ + case 0x91: + if (plci->internal_command == PERM_COD_HOOK) + { + dbug(1, dprintf("init:hook_on")); + plci->hook_state = ie[1] & 0x91; + next_internal_command(Id, plci); + break; + } + else /* ignore doubled hook indications */ + { + if (((plci->hook_state) & 0xf0) == 0x90) break; + plci->hook_state = ie[1] & 0x91; + } + /* hangup the adv. voice call and signal '-' to the appl */ + if (a->AdvSignalPLCI) { + Id = ((word)a->AdvSignalPLCI->Id << 8) | a->Id; + if (plci->tel) Id |= EXT_CONTROLLER; + sendf(a->AdvSignalAppl, + _FACILITY_I, + Id, + 0, + "ws", (word)0, "\x01-"); + a->AdvSignalPLCI->internal_command = HOOK_ON_REQ; + a->AdvSignalPLCI->command = 0; + sig_req(a->AdvSignalPLCI, HANGUP, 0); + send_req(a->AdvSignalPLCI); + } + break; + } + } + break; + + case RESUME: + clear_c_ind_mask_bit(plci, (word)(plci->appl->Id - 1)); + PUT_WORD(&resume_cau[4], GOOD); + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", (word)3, resume_cau); + break; + + case SUSPEND: + clear_c_ind_mask(plci); + + if (plci->NL.Id && !plci->nl_remove_id) { + mixer_remove(plci); + nl_req_ncci(plci, REMOVE, 0); + } + if (!plci->sig_remove_id) { + plci->internal_command = 0; + sig_req(plci, REMOVE, 0); + } + send_req(plci); + if (!plci->channels) { + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", (word)3, "\x05\x04\x00\x02\x00\x00"); + sendf(plci->appl, _DISCONNECT_I, Id, 0, "w", 0); + } + break; + + case SUSPEND_REJ: + break; + + case HANGUP: + plci->hangup_flow_ctrl_timer = 0; + if (plci->manufacturer && plci->State == LOCAL_CONNECT) break; + cau = parms[7]; + if (cau) { + i = _L3_CAUSE | cau[2]; + if (cau[2] == 0) i = 0; + else if (cau[2] == 8) i = _L1_ERROR; + else if (cau[2] == 9 || cau[2] == 10) i = _L2_ERROR; + else if (cau[2] == 5) i = _CAPI_GUARD_ERROR; + } + else { + i = _L3_ERROR; + } + + if (plci->State == INC_CON_PENDING || plci->State == INC_CON_ALERT) + { + for (i = 0; i < max_appl; i++) + { + if (test_c_ind_mask_bit(plci, i)) + sendf(&application[i], _DISCONNECT_I, Id, 0, "w", 0); + } + } + else + { + clear_c_ind_mask(plci); + } + if (!plci->appl) + { + if (plci->State == LISTENING) + { + plci->notifiedcall = 0; + a->listen_active--; + } + plci->State = INC_DIS_PENDING; + if (c_ind_mask_empty(plci)) + { + plci->State = IDLE; + if (plci->NL.Id && !plci->nl_remove_id) + { + mixer_remove(plci); + nl_req_ncci(plci, REMOVE, 0); + } + if (!plci->sig_remove_id) + { + plci->internal_command = 0; + sig_req(plci, REMOVE, 0); + } + send_req(plci); + } + } + else + { + /* collision of DISCONNECT or CONNECT_RES with HANGUP can */ + /* result in a second HANGUP! Don't generate another */ + /* DISCONNECT */ + if (plci->State != IDLE && plci->State != INC_DIS_PENDING) + { + if (plci->State == RESUMING) + { + PUT_WORD(&resume_cau[4], i); + sendf(plci->appl, _FACILITY_I, Id, 0, "ws", (word)3, resume_cau); + } + plci->State = INC_DIS_PENDING; + sendf(plci->appl, _DISCONNECT_I, Id, 0, "w", i); + } + } + break; + + case SSEXT_IND: + SendSSExtInd(NULL, plci, Id, multi_ssext_parms); + break; + + case VSWITCH_REQ: + VSwitchReqInd(plci, Id, multi_vswitch_parms); + break; + case VSWITCH_IND: + if (plci->relatedPTYPLCI && + plci->vswitchstate == 3 && + plci->relatedPTYPLCI->vswitchstate == 3 && + parms[MAXPARMSIDS - 1][0]) + { + add_p(plci->relatedPTYPLCI, SMSG, parms[MAXPARMSIDS - 1]); + sig_req(plci->relatedPTYPLCI, VSWITCH_REQ, 0); + send_req(plci->relatedPTYPLCI); + } + else VSwitchReqInd(plci, Id, multi_vswitch_parms); + break; + + } +} + + +static void SendSetupInfo(APPL *appl, PLCI *plci, dword Id, byte **parms, byte Info_Sent_Flag) +{ + word i; + byte *ie; + word Info_Number; + byte *Info_Element; + word Info_Mask = 0; + + dbug(1, dprintf("SetupInfo")); + + for (i = 0; i < MAXPARMSIDS; i++) { + ie = parms[i]; + Info_Number = 0; + Info_Element = ie; + if (ie[0]) { + switch (i) { + case 0: + dbug(1, dprintf("CPN ")); + Info_Number = 0x0070; + Info_Mask = 0x80; + Info_Sent_Flag = true; + break; + case 8: /* display */ + dbug(1, dprintf("display(%d)", i)); + Info_Number = 0x0028; + Info_Mask = 0x04; + Info_Sent_Flag = true; + break; + case 16: /* Channel Id */ + dbug(1, dprintf("CHI")); + Info_Number = 0x0018; + Info_Mask = 0x100; + Info_Sent_Flag = true; + mixer_set_bchannel_id(plci, Info_Element); + break; + case 19: /* Redirected Number */ + dbug(1, dprintf("RDN")); + Info_Number = 0x0074; + Info_Mask = 0x400; + Info_Sent_Flag = true; + break; + case 20: /* Redirected Number extended */ + dbug(1, dprintf("RDX")); + Info_Number = 0x0073; + Info_Mask = 0x400; + Info_Sent_Flag = true; + break; + case 22: /* Redirecing Number */ + dbug(1, dprintf("RIN")); + Info_Number = 0x0076; + Info_Mask = 0x400; + Info_Sent_Flag = true; + break; + default: + Info_Number = 0; + break; + } + } + + if (i == MAXPARMSIDS - 2) { /* to indicate the message type "Setup" */ + Info_Number = 0x8000 | 5; + Info_Mask = 0x10; + Info_Element = ""; + } + + if (Info_Sent_Flag && Info_Number) { + if (plci->adapter->Info_Mask[appl->Id - 1] & Info_Mask) { + sendf(appl, _INFO_I, Id, 0, "wS", Info_Number, Info_Element); + } + } + } } static void SendInfo(PLCI *plci, dword Id, byte **parms, byte iesent) { - word i; - word j; - word k; - byte * ie; - word Info_Number; - byte * Info_Element; - word Info_Mask = 0; - static byte charges[5] = {4,0,0,0,0}; - static byte cause[] = {0x02,0x80,0x00}; - APPL *appl; - - dbug(1,dprintf("InfoParse ")); - - if( - !plci->appl - && !plci->State - && plci->Sig.Ind!=NCR_FACILITY - ) - { - dbug(1,dprintf("NoParse ")); - return; - } - cause[2] = 0; - for(i=0; iSig.Ind==NCR_FACILITY) /* check controller broadcast */ - { - for(j=0; jId - && plci->adapter->Info_Mask[appl->Id-1] &Info_Mask) - { - dbug(1,dprintf("NCR_Ind")); - iesent=true; - sendf(&application[j],_INFO_I,Id&0x0f,0,"wS",Info_Number,Info_Element); - } - } - } - else if(!plci->appl) - { /* overlap receiving broadcast */ - if(Info_Number==CPN - || Info_Number==KEY - || Info_Number==NI - || Info_Number==DSP - || Info_Number==UUI ) - { - for(j=0; jadapter->Info_Mask[plci->appl->Id-1] &Info_Mask) - { - dbug(1,dprintf("Std_Ind")); - iesent=true; - sendf(plci->appl,_INFO_I,Id,0,"wS",Info_Number,Info_Element); - } - } + word i; + word j; + word k; + byte *ie; + word Info_Number; + byte *Info_Element; + word Info_Mask = 0; + static byte charges[5] = {4, 0, 0, 0, 0}; + static byte cause[] = {0x02, 0x80, 0x00}; + APPL *appl; + + dbug(1, dprintf("InfoParse ")); + + if ( + !plci->appl + && !plci->State + && plci->Sig.Ind != NCR_FACILITY + ) + { + dbug(1, dprintf("NoParse ")); + return; + } + cause[2] = 0; + for (i = 0; i < MAXPARMSIDS; i++) { + ie = parms[i]; + Info_Number = 0; + Info_Element = ie; + if (ie[0]) { + switch (i) { + case 0: + dbug(1, dprintf("CPN ")); + Info_Number = 0x0070; + Info_Mask = 0x80; + break; + case 7: /* ESC_CAU */ + dbug(1, dprintf("cau(0x%x)", ie[2])); + Info_Number = 0x0008; + Info_Mask = 0x00; + cause[2] = ie[2]; + Info_Element = NULL; + break; + case 8: /* display */ + dbug(1, dprintf("display(%d)", i)); + Info_Number = 0x0028; + Info_Mask = 0x04; + break; + case 9: /* Date display */ + dbug(1, dprintf("date(%d)", i)); + Info_Number = 0x0029; + Info_Mask = 0x02; + break; + case 10: /* charges */ + for (j = 0; j < 4; j++) charges[1 + j] = 0; + for (j = 0; j < ie[0] && !(ie[1 + j] & 0x80); j++); + for (k = 1, j++; j < ie[0] && k <= 4; j++, k++) charges[k] = ie[1 + j]; + Info_Number = 0x4000; + Info_Mask = 0x40; + Info_Element = charges; + break; + case 11: /* user user info */ + dbug(1, dprintf("uui")); + Info_Number = 0x007E; + Info_Mask = 0x08; + break; + case 12: /* congestion receiver ready */ + dbug(1, dprintf("clRDY")); + Info_Number = 0x00B0; + Info_Mask = 0x08; + Info_Element = ""; + break; + case 13: /* congestion receiver not ready */ + dbug(1, dprintf("clNRDY")); + Info_Number = 0x00BF; + Info_Mask = 0x08; + Info_Element = ""; + break; + case 15: /* Keypad Facility */ + dbug(1, dprintf("KEY")); + Info_Number = 0x002C; + Info_Mask = 0x20; + break; + case 16: /* Channel Id */ + dbug(1, dprintf("CHI")); + Info_Number = 0x0018; + Info_Mask = 0x100; + mixer_set_bchannel_id(plci, Info_Element); + break; + case 17: /* if no 1tr6 cause, send full cause, else esc_cause */ + dbug(1, dprintf("q9cau(0x%x)", ie[2])); + if (!cause[2] || cause[2] < 0x80) break; /* eg. layer 1 error */ + Info_Number = 0x0008; + Info_Mask = 0x01; + if (cause[2] != ie[2]) Info_Element = cause; + break; + case 19: /* Redirected Number */ + dbug(1, dprintf("RDN")); + Info_Number = 0x0074; + Info_Mask = 0x400; + break; + case 22: /* Redirecing Number */ + dbug(1, dprintf("RIN")); + Info_Number = 0x0076; + Info_Mask = 0x400; + break; + case 23: /* Notification Indicator */ + dbug(1, dprintf("NI")); + Info_Number = (word)NI; + Info_Mask = 0x210; + break; + case 26: /* Call State */ + dbug(1, dprintf("CST")); + Info_Number = (word)CST; + Info_Mask = 0x01; /* do with cause i.e. for now */ + break; + case MAXPARMSIDS - 2: /* Escape Message Type, must be the last indication */ + dbug(1, dprintf("ESC/MT[0x%x]", ie[3])); + Info_Number = 0x8000 | ie[3]; + if (iesent) Info_Mask = 0xffff; + else Info_Mask = 0x10; + Info_Element = ""; + break; + default: + Info_Number = 0; + Info_Mask = 0; + Info_Element = ""; + break; + } + } + + if (plci->Sig.Ind == NCR_FACILITY) /* check controller broadcast */ + { + for (j = 0; j < max_appl; j++) + { + appl = &application[j]; + if (Info_Number + && appl->Id + && plci->adapter->Info_Mask[appl->Id - 1] & Info_Mask) + { + dbug(1, dprintf("NCR_Ind")); + iesent = true; + sendf(&application[j], _INFO_I, Id & 0x0f, 0, "wS", Info_Number, Info_Element); + } + } + } + else if (!plci->appl) + { /* overlap receiving broadcast */ + if (Info_Number == CPN + || Info_Number == KEY + || Info_Number == NI + || Info_Number == DSP + || Info_Number == UUI) + { + for (j = 0; j < max_appl; j++) + { + if (test_c_ind_mask_bit(plci, j)) + { + dbug(1, dprintf("Ovl_Ind")); + iesent = true; + sendf(&application[j], _INFO_I, Id, 0, "wS", Info_Number, Info_Element); + } + } + } + } /* all other signalling states */ + else if (Info_Number + && plci->adapter->Info_Mask[plci->appl->Id - 1] & Info_Mask) + { + dbug(1, dprintf("Std_Ind")); + iesent = true; + sendf(plci->appl, _INFO_I, Id, 0, "wS", Info_Number, Info_Element); + } + } } static byte SendMultiIE(PLCI *plci, dword Id, byte **parms, byte ie_type, dword info_mask, byte setupParse) { - word i; - word j; - byte * ie; - word Info_Number; - byte * Info_Element; - APPL *appl; - word Info_Mask = 0; - byte iesent=0; - - if( - !plci->appl - && !plci->State - && plci->Sig.Ind!=NCR_FACILITY - && !setupParse - ) - { - dbug(1,dprintf("NoM-IEParse ")); - return 0; - } - dbug(1,dprintf("M-IEParse ")); - - for(i=0; iSig.Ind,ie_type)); - Info_Number = (word)ie_type; - Info_Mask = (word)info_mask; - } - - if(plci->Sig.Ind==NCR_FACILITY) /* check controller broadcast */ - { - for(j=0; jId - && plci->adapter->Info_Mask[appl->Id-1] &Info_Mask) - { - iesent = true; - dbug(1,dprintf("Mlt_NCR_Ind")); - sendf(&application[j],_INFO_I,Id&0x0f,0,"wS",Info_Number,Info_Element); - } - } - } - else if(!plci->appl && Info_Number) - { /* overlap receiving broadcast */ - for(j=0; jadapter->Info_Mask[plci->appl->Id-1] &Info_Mask) - { - iesent = true; - dbug(1,dprintf("Mlt_Std_Ind")); - sendf(plci->appl,_INFO_I,Id,0,"wS",Info_Number,Info_Element); - } - } - return iesent; -} - -static void SendSSExtInd(APPL * appl, PLCI * plci, dword Id, byte * * parms) -{ - word i; - /* Format of multi_ssext_parms[i][]: - 0 byte length - 1 byte SSEXTIE - 2 byte SSEXT_REQ/SSEXT_IND - 3 byte length - 4 word SSExtCommand - 6... Params - */ - if( - plci - && plci->State - && plci->Sig.Ind!=NCR_FACILITY - ) - for(i=0;iappl) - { - parms[i][0]=0; /* kill it */ - sendf(plci->appl,_MANUFACTURER_I, - Id, - 0, - "dwS", - _DI_MANU_ID, - _DI_SSEXT_CTRL, - &parms[i][3]); - } - } + word i; + word j; + byte *ie; + word Info_Number; + byte *Info_Element; + APPL *appl; + word Info_Mask = 0; + byte iesent = 0; + + if ( + !plci->appl + && !plci->State + && plci->Sig.Ind != NCR_FACILITY + && !setupParse + ) + { + dbug(1, dprintf("NoM-IEParse ")); + return 0; + } + dbug(1, dprintf("M-IEParse ")); + + for (i = 0; i < MAX_MULTI_IE; i++) + { + ie = parms[i]; + Info_Number = 0; + Info_Element = ie; + if (ie[0]) + { + dbug(1, dprintf("[Ind0x%x]:IE=0x%x", plci->Sig.Ind, ie_type)); + Info_Number = (word)ie_type; + Info_Mask = (word)info_mask; + } + + if (plci->Sig.Ind == NCR_FACILITY) /* check controller broadcast */ + { + for (j = 0; j < max_appl; j++) + { + appl = &application[j]; + if (Info_Number + && appl->Id + && plci->adapter->Info_Mask[appl->Id - 1] & Info_Mask) + { + iesent = true; + dbug(1, dprintf("Mlt_NCR_Ind")); + sendf(&application[j], _INFO_I, Id & 0x0f, 0, "wS", Info_Number, Info_Element); + } + } + } + else if (!plci->appl && Info_Number) + { /* overlap receiving broadcast */ + for (j = 0; j < max_appl; j++) + { + if (test_c_ind_mask_bit(plci, j)) + { + iesent = true; + dbug(1, dprintf("Mlt_Ovl_Ind")); + sendf(&application[j] , _INFO_I, Id, 0, "wS", Info_Number, Info_Element); + } + } + } /* all other signalling states */ + else if (Info_Number + && plci->adapter->Info_Mask[plci->appl->Id - 1] & Info_Mask) + { + iesent = true; + dbug(1, dprintf("Mlt_Std_Ind")); + sendf(plci->appl, _INFO_I, Id, 0, "wS", Info_Number, Info_Element); + } + } + return iesent; +} + +static void SendSSExtInd(APPL *appl, PLCI *plci, dword Id, byte **parms) +{ + word i; + /* Format of multi_ssext_parms[i][]: + 0 byte length + 1 byte SSEXTIE + 2 byte SSEXT_REQ/SSEXT_IND + 3 byte length + 4 word SSExtCommand + 6... Params + */ + if ( + plci + && plci->State + && plci->Sig.Ind != NCR_FACILITY + ) + for (i = 0; i < MAX_MULTI_IE; i++) + { + if (parms[i][0] < 6) continue; + if (parms[i][2] == SSEXT_REQ) continue; + + if (appl) + { + parms[i][0] = 0; /* kill it */ + sendf(appl, _MANUFACTURER_I, + Id, + 0, + "dwS", + _DI_MANU_ID, + _DI_SSEXT_CTRL, + &parms[i][3]); + } + else if (plci->appl) + { + parms[i][0] = 0; /* kill it */ + sendf(plci->appl, _MANUFACTURER_I, + Id, + 0, + "dwS", + _DI_MANU_ID, + _DI_SSEXT_CTRL, + &parms[i][3]); + } + } }; static void nl_ind(PLCI *plci) { - byte ch; - word ncci; - dword Id; - DIVA_CAPI_ADAPTER * a; - word NCCIcode; - APPL * APPLptr; - word count; - word Num; - word i, ncpi_state; - byte len, ncci_state; - word msg; - word info = 0; - word fax_feature_bits; - byte fax_send_edata_ack; - static byte v120_header_buffer[2 + 3]; - static word fax_info[] = { - 0, /* T30_SUCCESS */ - _FAX_NO_CONNECTION, /* T30_ERR_NO_DIS_RECEIVED */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_NO_RESPONSE */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_RESPONSE */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_TOO_MANY_REPEATS */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_UNEXPECTED_MESSAGE */ - _FAX_REMOTE_ABORT, /* T30_ERR_UNEXPECTED_DCN */ - _FAX_LOCAL_ABORT, /* T30_ERR_DTC_UNSUPPORTED */ - _FAX_TRAINING_ERROR, /* T30_ERR_ALL_RATES_FAILED */ - _FAX_TRAINING_ERROR, /* T30_ERR_TOO_MANY_TRAINS */ - _FAX_PARAMETER_ERROR, /* T30_ERR_RECEIVE_CORRUPTED */ - _FAX_REMOTE_ABORT, /* T30_ERR_UNEXPECTED_DISC */ - _FAX_LOCAL_ABORT, /* T30_ERR_APPLICATION_DISC */ - _FAX_REMOTE_REJECT, /* T30_ERR_INCOMPATIBLE_DIS */ - _FAX_LOCAL_ABORT, /* T30_ERR_INCOMPATIBLE_DCS */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_NO_COMMAND */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_COMMAND */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_COMMAND_TOO_LONG */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_RESPONSE_TOO_LONG */ - _FAX_NO_CONNECTION, /* T30_ERR_NOT_IDENTIFIED */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_SUPERVISORY_TIMEOUT */ - _FAX_PARAMETER_ERROR, /* T30_ERR_TOO_LONG_SCAN_LINE */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_PAGE_AFTER_MPS */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_PAGE_AFTER_CFR */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCS_AFTER_FTT */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCS_AFTER_EOM */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCS_AFTER_MPS */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCN_AFTER_MCF */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCN_AFTER_RTN */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_CFR */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_MCF_AFTER_EOP */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_MCF_AFTER_EOM */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_MCF_AFTER_MPS */ - 0x331d, /* T30_ERR_SUB_SEP_UNSUPPORTED */ - 0x331e, /* T30_ERR_PWD_UNSUPPORTED */ - 0x331f, /* T30_ERR_SUB_SEP_PWD_UNSUPPORTED */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_INVALID_COMMAND_FRAME */ - _FAX_PARAMETER_ERROR, /* T30_ERR_UNSUPPORTED_PAGE_CODING */ - _FAX_PARAMETER_ERROR, /* T30_ERR_INVALID_PAGE_CODING */ - _FAX_REMOTE_REJECT, /* T30_ERR_INCOMPATIBLE_PAGE_CONFIG */ - _FAX_LOCAL_ABORT, /* T30_ERR_TIMEOUT_FROM_APPLICATION */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_NO_REACTION_ON_MARK */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_TRAINING_TIMEOUT */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_UNEXPECTED_V21 */ - _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_PRIMARY_CTS_ON */ - _FAX_LOCAL_ABORT, /* T30_ERR_V34FAX_TURNAROUND_POLLING */ - _FAX_LOCAL_ABORT /* T30_ERR_V34FAX_V8_INCOMPATIBILITY */ - }; - - byte dtmf_code_buffer[CAPIDTMF_RECV_DIGIT_BUFFER_SIZE + 1]; - - - static word rtp_info[] = { - GOOD, /* RTP_SUCCESS */ - 0x3600 /* RTP_ERR_SSRC_OR_PAYLOAD_CHANGE */ - }; - - static dword udata_forwarding_table[0x100 / sizeof(dword)] = - { - 0x0020301e, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000 - }; - - ch = plci->NL.IndCh; - a = plci->adapter; - ncci = a->ch_ncci[ch]; - Id = (((dword)(ncci ? ncci : ch)) << 16) | (((word) plci->Id) << 8) | a->Id; - if(plci->tel) Id|=EXT_CONTROLLER; - APPLptr = plci->appl; - dbug(1,dprintf("NL_IND-Id(NL:0x%x)=0x%08lx,plci=%x,tel=%x,state=0x%x,ch=0x%x,chs=%d,Ind=%x", - plci->NL.Id,Id,plci->Id,plci->tel,plci->State,ch,plci->channels,plci->NL.Ind &0x0f)); - - /* in the case if no connect_active_Ind was sent to the appl we wait for */ - - if (plci->nl_remove_id) - { - plci->NL.RNR = 2; /* discard */ - dbug(1,dprintf("NL discard while remove pending")); - return; - } - if((plci->NL.Ind &0x0f)==N_CONNECT) - { - if(plci->State==INC_DIS_PENDING - || plci->State==OUTG_DIS_PENDING - || plci->State==IDLE) - { - plci->NL.RNR = 2; /* discard */ - dbug(1,dprintf("discard n_connect")); - return; - } - if(plci->State < INC_ACT_PENDING) - { - plci->NL.RNR = 1; /* flow control */ - channel_x_off (plci, ch, N_XON_CONNECT_IND); - return; - } - } - - if(!APPLptr) /* no application or invalid data */ - { /* while reloading the DSP */ - dbug(1,dprintf("discard1")); - plci->NL.RNR = 2; - return; - } - - if (((plci->NL.Ind &0x0f) == N_UDATA) - && (((plci->B2_prot != B2_SDLC) && ((plci->B1_resource == 17) || (plci->B1_resource == 18))) - || (plci->B2_prot == 7) - || (plci->B3_prot == 7)) ) - { - plci->ncpi_buffer[0] = 0; - - ncpi_state = plci->ncpi_state; - if (plci->NL.complete == 1) - { - byte * data = &plci->NL.RBuffer->P[0]; - - if ((plci->NL.RBuffer->length >= 12) - &&( (*data == DSP_UDATA_INDICATION_DCD_ON) - ||(*data == DSP_UDATA_INDICATION_CTS_ON)) ) - { - word conn_opt, ncpi_opt = 0x00; + byte ch; + word ncci; + dword Id; + DIVA_CAPI_ADAPTER *a; + word NCCIcode; + APPL *APPLptr; + word count; + word Num; + word i, ncpi_state; + byte len, ncci_state; + word msg; + word info = 0; + word fax_feature_bits; + byte fax_send_edata_ack; + static byte v120_header_buffer[2 + 3]; + static word fax_info[] = { + 0, /* T30_SUCCESS */ + _FAX_NO_CONNECTION, /* T30_ERR_NO_DIS_RECEIVED */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_NO_RESPONSE */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_RESPONSE */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_TOO_MANY_REPEATS */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_UNEXPECTED_MESSAGE */ + _FAX_REMOTE_ABORT, /* T30_ERR_UNEXPECTED_DCN */ + _FAX_LOCAL_ABORT, /* T30_ERR_DTC_UNSUPPORTED */ + _FAX_TRAINING_ERROR, /* T30_ERR_ALL_RATES_FAILED */ + _FAX_TRAINING_ERROR, /* T30_ERR_TOO_MANY_TRAINS */ + _FAX_PARAMETER_ERROR, /* T30_ERR_RECEIVE_CORRUPTED */ + _FAX_REMOTE_ABORT, /* T30_ERR_UNEXPECTED_DISC */ + _FAX_LOCAL_ABORT, /* T30_ERR_APPLICATION_DISC */ + _FAX_REMOTE_REJECT, /* T30_ERR_INCOMPATIBLE_DIS */ + _FAX_LOCAL_ABORT, /* T30_ERR_INCOMPATIBLE_DCS */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_NO_COMMAND */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_COMMAND */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_COMMAND_TOO_LONG */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_TIMEOUT_RESPONSE_TOO_LONG */ + _FAX_NO_CONNECTION, /* T30_ERR_NOT_IDENTIFIED */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_SUPERVISORY_TIMEOUT */ + _FAX_PARAMETER_ERROR, /* T30_ERR_TOO_LONG_SCAN_LINE */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_PAGE_AFTER_MPS */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_PAGE_AFTER_CFR */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCS_AFTER_FTT */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCS_AFTER_EOM */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCS_AFTER_MPS */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCN_AFTER_MCF */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_DCN_AFTER_RTN */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_CFR */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_MCF_AFTER_EOP */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_MCF_AFTER_EOM */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_RETRY_NO_MCF_AFTER_MPS */ + 0x331d, /* T30_ERR_SUB_SEP_UNSUPPORTED */ + 0x331e, /* T30_ERR_PWD_UNSUPPORTED */ + 0x331f, /* T30_ERR_SUB_SEP_PWD_UNSUPPORTED */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_INVALID_COMMAND_FRAME */ + _FAX_PARAMETER_ERROR, /* T30_ERR_UNSUPPORTED_PAGE_CODING */ + _FAX_PARAMETER_ERROR, /* T30_ERR_INVALID_PAGE_CODING */ + _FAX_REMOTE_REJECT, /* T30_ERR_INCOMPATIBLE_PAGE_CONFIG */ + _FAX_LOCAL_ABORT, /* T30_ERR_TIMEOUT_FROM_APPLICATION */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_NO_REACTION_ON_MARK */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_TRAINING_TIMEOUT */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_UNEXPECTED_V21 */ + _FAX_PROTOCOL_ERROR, /* T30_ERR_V34FAX_PRIMARY_CTS_ON */ + _FAX_LOCAL_ABORT, /* T30_ERR_V34FAX_TURNAROUND_POLLING */ + _FAX_LOCAL_ABORT /* T30_ERR_V34FAX_V8_INCOMPATIBILITY */ + }; + + byte dtmf_code_buffer[CAPIDTMF_RECV_DIGIT_BUFFER_SIZE + 1]; + + + static word rtp_info[] = { + GOOD, /* RTP_SUCCESS */ + 0x3600 /* RTP_ERR_SSRC_OR_PAYLOAD_CHANGE */ + }; + + static dword udata_forwarding_table[0x100 / sizeof(dword)] = + { + 0x0020301e, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000 + }; + + ch = plci->NL.IndCh; + a = plci->adapter; + ncci = a->ch_ncci[ch]; + Id = (((dword)(ncci ? ncci : ch)) << 16) | (((word) plci->Id) << 8) | a->Id; + if (plci->tel) Id |= EXT_CONTROLLER; + APPLptr = plci->appl; + dbug(1, dprintf("NL_IND-Id(NL:0x%x)=0x%08lx,plci=%x,tel=%x,state=0x%x,ch=0x%x,chs=%d,Ind=%x", + plci->NL.Id, Id, plci->Id, plci->tel, plci->State, ch, plci->channels, plci->NL.Ind & 0x0f)); + + /* in the case if no connect_active_Ind was sent to the appl we wait for */ + + if (plci->nl_remove_id) + { + plci->NL.RNR = 2; /* discard */ + dbug(1, dprintf("NL discard while remove pending")); + return; + } + if ((plci->NL.Ind & 0x0f) == N_CONNECT) + { + if (plci->State == INC_DIS_PENDING + || plci->State == OUTG_DIS_PENDING + || plci->State == IDLE) + { + plci->NL.RNR = 2; /* discard */ + dbug(1, dprintf("discard n_connect")); + return; + } + if (plci->State < INC_ACT_PENDING) + { + plci->NL.RNR = 1; /* flow control */ + channel_x_off(plci, ch, N_XON_CONNECT_IND); + return; + } + } + + if (!APPLptr) /* no application or invalid data */ + { /* while reloading the DSP */ + dbug(1, dprintf("discard1")); + plci->NL.RNR = 2; + return; + } + + if (((plci->NL.Ind & 0x0f) == N_UDATA) + && (((plci->B2_prot != B2_SDLC) && ((plci->B1_resource == 17) || (plci->B1_resource == 18))) + || (plci->B2_prot == 7) + || (plci->B3_prot == 7))) + { + plci->ncpi_buffer[0] = 0; + + ncpi_state = plci->ncpi_state; + if (plci->NL.complete == 1) + { + byte *data = &plci->NL.RBuffer->P[0]; + + if ((plci->NL.RBuffer->length >= 12) + && ((*data == DSP_UDATA_INDICATION_DCD_ON) + || (*data == DSP_UDATA_INDICATION_CTS_ON))) + { + word conn_opt, ncpi_opt = 0x00; /* HexDump ("MDM N_UDATA:", plci->NL.RBuffer->length, data); */ - if (*data == DSP_UDATA_INDICATION_DCD_ON) - plci->ncpi_state |= NCPI_MDM_DCD_ON_RECEIVED; - if (*data == DSP_UDATA_INDICATION_CTS_ON) - plci->ncpi_state |= NCPI_MDM_CTS_ON_RECEIVED; - - data++; /* indication code */ - data += 2; /* timestamp */ - if ((*data == DSP_CONNECTED_NORM_V18) || (*data == DSP_CONNECTED_NORM_VOWN)) - ncpi_state &= ~(NCPI_MDM_DCD_ON_RECEIVED | NCPI_MDM_CTS_ON_RECEIVED); - data++; /* connected norm */ - conn_opt = GET_WORD(data); - data += 2; /* connected options */ - - PUT_WORD (&(plci->ncpi_buffer[1]), (word)(GET_DWORD(data) & 0x0000FFFF)); - - if (conn_opt & DSP_CONNECTED_OPTION_MASK_V42) - { - ncpi_opt |= MDM_NCPI_ECM_V42; - } - else if (conn_opt & DSP_CONNECTED_OPTION_MASK_MNP) - { - ncpi_opt |= MDM_NCPI_ECM_MNP; - } - else - { - ncpi_opt |= MDM_NCPI_TRANSPARENT; - } - if (conn_opt & DSP_CONNECTED_OPTION_MASK_COMPRESSION) - { - ncpi_opt |= MDM_NCPI_COMPRESSED; - } - PUT_WORD (&(plci->ncpi_buffer[3]), ncpi_opt); - plci->ncpi_buffer[0] = 4; - - plci->ncpi_state |= NCPI_VALID_CONNECT_B3_IND | NCPI_VALID_CONNECT_B3_ACT | NCPI_VALID_DISC_B3_IND; - } - } - if (plci->B3_prot == 7) - { - if (((a->ncci_state[ncci] == INC_ACT_PENDING) || (a->ncci_state[ncci] == OUTG_CON_PENDING)) - && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - a->ncci_state[ncci] = INC_ACT_PENDING; - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } - } - - if (!((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1]) - & ((1L << PRIVATE_V18) | (1L << PRIVATE_VOWN))) - || !(ncpi_state & NCPI_MDM_DCD_ON_RECEIVED) - || !(ncpi_state & NCPI_MDM_CTS_ON_RECEIVED)) - - { - plci->NL.RNR = 2; - return; - } - } - - if(plci->NL.complete == 2) - { - if (((plci->NL.Ind &0x0f) == N_UDATA) - && !(udata_forwarding_table[plci->RData[0].P[0] >> 5] & (1L << (plci->RData[0].P[0] & 0x1f)))) - { - switch(plci->RData[0].P[0]) - { - - case DTMF_UDATA_INDICATION_FAX_CALLING_TONE: - if (plci->dtmf_rec_active & DTMF_LISTEN_ACTIVE_FLAG) - sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0,"ws", SELECTOR_DTMF, "\x01X"); - break; - case DTMF_UDATA_INDICATION_ANSWER_TONE: - if (plci->dtmf_rec_active & DTMF_LISTEN_ACTIVE_FLAG) - sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0,"ws", SELECTOR_DTMF, "\x01Y"); - break; - case DTMF_UDATA_INDICATION_DIGITS_RECEIVED: - dtmf_indication (Id, plci, plci->RData[0].P, plci->RData[0].PLength); - break; - case DTMF_UDATA_INDICATION_DIGITS_SENT: - dtmf_confirmation (Id, plci); - break; - - - case UDATA_INDICATION_MIXER_TAP_DATA: - capidtmf_recv_process_block (&(plci->capidtmf_state), plci->RData[0].P + 1, (word)(plci->RData[0].PLength - 1)); - i = capidtmf_indication (&(plci->capidtmf_state), dtmf_code_buffer + 1); - if (i != 0) - { - dtmf_code_buffer[0] = DTMF_UDATA_INDICATION_DIGITS_RECEIVED; - dtmf_indication (Id, plci, dtmf_code_buffer, (word)(i + 1)); - } - break; - - - case UDATA_INDICATION_MIXER_COEFS_SET: - mixer_indication_coefs_set (Id, plci); - break; - case UDATA_INDICATION_XCONNECT_FROM: - mixer_indication_xconnect_from (Id, plci, plci->RData[0].P, plci->RData[0].PLength); - break; - case UDATA_INDICATION_XCONNECT_TO: - mixer_indication_xconnect_to (Id, plci, plci->RData[0].P, plci->RData[0].PLength); - break; - - - case LEC_UDATA_INDICATION_DISABLE_DETECT: - ec_indication (Id, plci, plci->RData[0].P, plci->RData[0].PLength); - break; - - - - default: - break; - } - } - else - { - if ((plci->RData[0].PLength != 0) - && ((plci->B2_prot == B2_V120_ASYNC) - || (plci->B2_prot == B2_V120_ASYNC_V42BIS) - || (plci->B2_prot == B2_V120_BIT_TRANSPARENT))) - { - - sendf(plci->appl,_DATA_B3_I,Id,0, - "dwww", - plci->RData[1].P, - (plci->NL.RNum < 2) ? 0 : plci->RData[1].PLength, - plci->RNum, - plci->RFlags); - - } - else - { - - sendf(plci->appl,_DATA_B3_I,Id,0, - "dwww", - plci->RData[0].P, - plci->RData[0].PLength, - plci->RNum, - plci->RFlags); - - } - } - return; - } - - fax_feature_bits = 0; - if((plci->NL.Ind &0x0f)==N_CONNECT || - (plci->NL.Ind &0x0f)==N_CONNECT_ACK || - (plci->NL.Ind &0x0f)==N_DISC || - (plci->NL.Ind &0x0f)==N_EDATA || - (plci->NL.Ind &0x0f)==N_DISC_ACK) - { - info = 0; - plci->ncpi_buffer[0] = 0; - switch (plci->B3_prot) { - case 0: /*XPARENT*/ - case 1: /*T.90 NL*/ - break; /* no network control protocol info - jfr */ - case 2: /*ISO8202*/ - case 3: /*X25 DCE*/ - for(i=0; iNL.RLength; i++) plci->ncpi_buffer[4+i] = plci->NL.RBuffer->P[i]; - plci->ncpi_buffer[0] = (byte)(i+3); - plci->ncpi_buffer[1] = (byte)(plci->NL.Ind &N_D_BIT? 1:0); - plci->ncpi_buffer[2] = 0; - plci->ncpi_buffer[3] = 0; - break; - case 4: /*T.30 - FAX*/ - case 5: /*T.30 - FAX*/ - if(plci->NL.RLength>=sizeof(T30_INFO)) - { - dbug(1,dprintf("FaxStatus %04x", ((T30_INFO *)plci->NL.RBuffer->P)->code)); - len = 9; - PUT_WORD(&(plci->ncpi_buffer[1]),((T30_INFO *)plci->NL.RBuffer->P)->rate_div_2400 * 2400); - fax_feature_bits = GET_WORD(&((T30_INFO *)plci->NL.RBuffer->P)->feature_bits_low); - i = (((T30_INFO *)plci->NL.RBuffer->P)->resolution & T30_RESOLUTION_R8_0770_OR_200) ? 0x0001 : 0x0000; - if (plci->B3_prot == 5) - { - if (!(fax_feature_bits & T30_FEATURE_BIT_ECM)) - i |= 0x8000; /* This is not an ECM connection */ - if (fax_feature_bits & T30_FEATURE_BIT_T6_CODING) - i |= 0x4000; /* This is a connection with MMR compression */ - if (fax_feature_bits & T30_FEATURE_BIT_2D_CODING) - i |= 0x2000; /* This is a connection with MR compression */ - if (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS) - i |= 0x0004; /* More documents */ - if (fax_feature_bits & T30_FEATURE_BIT_POLLING) - i |= 0x0002; /* Fax-polling indication */ - } - dbug(1,dprintf("FAX Options %04x %04x",fax_feature_bits,i)); - PUT_WORD(&(plci->ncpi_buffer[3]),i); - PUT_WORD(&(plci->ncpi_buffer[5]),((T30_INFO *)plci->NL.RBuffer->P)->data_format); - plci->ncpi_buffer[7] = ((T30_INFO *)plci->NL.RBuffer->P)->pages_low; - plci->ncpi_buffer[8] = ((T30_INFO *)plci->NL.RBuffer->P)->pages_high; - plci->ncpi_buffer[len] = 0; - if(((T30_INFO *)plci->NL.RBuffer->P)->station_id_len) - { - plci->ncpi_buffer[len] = 20; - for (i = 0; i < T30_MAX_STATION_ID_LENGTH; i++) - plci->ncpi_buffer[++len] = ((T30_INFO *)plci->NL.RBuffer->P)->station_id[i]; - } - if (((plci->NL.Ind & 0x0f) == N_DISC) || ((plci->NL.Ind & 0x0f) == N_DISC_ACK)) - { - if (((T30_INFO *)plci->NL.RBuffer->P)->code < ARRAY_SIZE(fax_info)) - info = fax_info[((T30_INFO *)plci->NL.RBuffer->P)->code]; - else - info = _FAX_PROTOCOL_ERROR; - } - - if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1]) - & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) - { - i = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + ((T30_INFO *)plci->NL.RBuffer->P)->head_line_len; - while (i < plci->NL.RBuffer->length) - plci->ncpi_buffer[++len] = plci->NL.RBuffer->P[i++]; - } - - plci->ncpi_buffer[0] = len; - fax_feature_bits = GET_WORD(&((T30_INFO *)plci->NL.RBuffer->P)->feature_bits_low); - PUT_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->feature_bits_low, fax_feature_bits); - - plci->ncpi_state |= NCPI_VALID_CONNECT_B3_IND; - if (((plci->NL.Ind &0x0f) == N_CONNECT_ACK) - || (((plci->NL.Ind &0x0f) == N_CONNECT) - && (fax_feature_bits & T30_FEATURE_BIT_POLLING)) - || (((plci->NL.Ind &0x0f) == N_EDATA) - && ((((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_TRAIN_OK) - || (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_DIS) - || (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_DTC)))) - { - plci->ncpi_state |= NCPI_VALID_CONNECT_B3_ACT; - } - if (((plci->NL.Ind &0x0f) == N_DISC) - || ((plci->NL.Ind &0x0f) == N_DISC_ACK) - || (((plci->NL.Ind &0x0f) == N_EDATA) - && (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_EOP_CAPI))) - { - plci->ncpi_state |= NCPI_VALID_CONNECT_B3_ACT | NCPI_VALID_DISC_B3_IND; - } - } - break; - - case B3_RTP: - if (((plci->NL.Ind & 0x0f) == N_DISC) || ((plci->NL.Ind & 0x0f) == N_DISC_ACK)) - { - if (plci->NL.RLength != 0) - { - info = rtp_info[plci->NL.RBuffer->P[0]]; - plci->ncpi_buffer[0] = plci->NL.RLength - 1; - for (i = 1; i < plci->NL.RLength; i++) - plci->ncpi_buffer[i] = plci->NL.RBuffer->P[i]; - } - } - break; - - } - plci->NL.RNR = 2; - } - switch(plci->NL.Ind &0x0f) { - case N_EDATA: - if ((plci->B3_prot == 4) || (plci->B3_prot == 5)) - { - dbug(1,dprintf("EDATA ncci=0x%x state=%d code=%02x", ncci, a->ncci_state[ncci], - ((T30_INFO *)plci->NL.RBuffer->P)->code)); - fax_send_edata_ack = (((T30_INFO *)(plci->fax_connect_info_buffer))->operating_mode == T30_OPERATING_MODE_CAPI_NEG); - - if ((plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) - && (plci->nsf_control_bits & (T30_NSF_CONTROL_BIT_NEGOTIATE_IND | T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) - && (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_DIS) - && (a->ncci_state[ncci] == OUTG_CON_PENDING) - && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_NEGOTIATE_B3_SENT)) - { - ((T30_INFO *)(plci->fax_connect_info_buffer))->code = ((T30_INFO *)plci->NL.RBuffer->P)->code; - sendf(plci->appl,_MANUFACTURER_I,Id,0,"dwbS",_DI_MANU_ID,_DI_NEGOTIATE_B3, - (byte)(plci->ncpi_buffer[0] + 1), plci->ncpi_buffer); - plci->ncpi_state |= NCPI_NEGOTIATE_B3_SENT; - if (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP) - fax_send_edata_ack = false; - } - - if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) - { - switch (((T30_INFO *)plci->NL.RBuffer->P)->code) - { - case EDATA_T30_DIS: - if ((a->ncci_state[ncci] == OUTG_CON_PENDING) - && !(GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low) & T30_CONTROL_BIT_REQUEST_POLLING) - && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - a->ncci_state[ncci] = INC_ACT_PENDING; - if (plci->B3_prot == 4) - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - else - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } - break; - - case EDATA_T30_TRAIN_OK: - if ((a->ncci_state[ncci] == INC_ACT_PENDING) - && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - if (plci->B3_prot == 4) - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - else - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } - break; - - case EDATA_T30_EOP_CAPI: - if (a->ncci_state[ncci] == CONNECTED) - { - sendf(plci->appl,_DISCONNECT_B3_I,Id,0,"wS",GOOD,plci->ncpi_buffer); - a->ncci_state[ncci] = INC_DIS_PENDING; - plci->ncpi_state = 0; - fax_send_edata_ack = false; - } - break; - } - } - else - { - switch (((T30_INFO *)plci->NL.RBuffer->P)->code) - { - case EDATA_T30_TRAIN_OK: - if ((a->ncci_state[ncci] == INC_ACT_PENDING) - && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - if (plci->B3_prot == 4) - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - else - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } - break; - } - } - if (fax_send_edata_ack) - { - ((T30_INFO *)(plci->fax_connect_info_buffer))->code = ((T30_INFO *)plci->NL.RBuffer->P)->code; - plci->fax_edata_ack_length = 1; - start_internal_command (Id, plci, fax_edata_ack_command); - } - } - else - { - dbug(1,dprintf("EDATA ncci=0x%x state=%d", ncci, a->ncci_state[ncci])); - } - break; - case N_CONNECT: - if (!a->ch_ncci[ch]) - { - ncci = get_ncci (plci, ch, 0); - Id = (Id & 0xffff) | (((dword) ncci) << 16); - } - dbug(1,dprintf("N_CONNECT: ch=%d state=%d plci=%lx plci_Id=%lx plci_State=%d", - ch, a->ncci_state[ncci], a->ncci_plci[ncci], plci->Id, plci->State)); - - msg = _CONNECT_B3_I; - if (a->ncci_state[ncci] == IDLE) - plci->channels++; - else if (plci->B3_prot == 1) - msg = _CONNECT_B3_T90_ACTIVE_I; - - a->ncci_state[ncci] = INC_CON_PENDING; - if(plci->B3_prot == 4) - sendf(plci->appl,msg,Id,0,"s",""); - else - sendf(plci->appl,msg,Id,0,"S",plci->ncpi_buffer); - break; - case N_CONNECT_ACK: - dbug(1,dprintf("N_connect_Ack")); - if (plci->internal_command_queue[0] - && ((plci->adjust_b_state == ADJUST_B_CONNECT_2) - || (plci->adjust_b_state == ADJUST_B_CONNECT_3) - || (plci->adjust_b_state == ADJUST_B_CONNECT_4))) - { - (*(plci->internal_command_queue[0]))(Id, plci, 0); - if (!plci->internal_command) - next_internal_command (Id, plci); - break; - } - msg = _CONNECT_B3_ACTIVE_I; - if (plci->B3_prot == 1) - { - if (a->ncci_state[ncci] != OUTG_CON_PENDING) - msg = _CONNECT_B3_T90_ACTIVE_I; - a->ncci_state[ncci] = INC_ACT_PENDING; - sendf(plci->appl,msg,Id,0,"S",plci->ncpi_buffer); - } - else if ((plci->B3_prot == 4) || (plci->B3_prot == 5) || (plci->B3_prot == 7)) - { - if ((a->ncci_state[ncci] == OUTG_CON_PENDING) - && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - a->ncci_state[ncci] = INC_ACT_PENDING; - if (plci->B3_prot == 4) - sendf(plci->appl,msg,Id,0,"s",""); - else - sendf(plci->appl,msg,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } - } - else - { - a->ncci_state[ncci] = INC_ACT_PENDING; - sendf(plci->appl,msg,Id,0,"S",plci->ncpi_buffer); - } - if (plci->adjust_b_restore) - { - plci->adjust_b_restore = false; - start_internal_command (Id, plci, adjust_b_restore); - } - break; - case N_DISC: - case N_DISC_ACK: - if (plci->internal_command_queue[0] - && ((plci->internal_command == FAX_DISCONNECT_COMMAND_1) - || (plci->internal_command == FAX_DISCONNECT_COMMAND_2) - || (plci->internal_command == FAX_DISCONNECT_COMMAND_3))) - { - (*(plci->internal_command_queue[0]))(Id, plci, 0); - if (!plci->internal_command) - next_internal_command (Id, plci); - } - ncci_state = a->ncci_state[ncci]; - ncci_remove (plci, ncci, false); - - /* with N_DISC or N_DISC_ACK the IDI frees the respective */ - /* channel, so we cannot store the state in ncci_state! The */ - /* information which channel we received a N_DISC is thus */ - /* stored in the inc_dis_ncci_table buffer. */ - for(i=0; plci->inc_dis_ncci_table[i]; i++); - plci->inc_dis_ncci_table[i] = (byte) ncci; - - /* need a connect_b3_ind before a disconnect_b3_ind with FAX */ - if (!plci->channels - && (plci->B1_resource == 16) - && (plci->State <= CONNECTED)) - { - len = 9; - i = ((T30_INFO *)plci->fax_connect_info_buffer)->rate_div_2400 * 2400; - PUT_WORD (&plci->ncpi_buffer[1], i); - PUT_WORD (&plci->ncpi_buffer[3], 0); - i = ((T30_INFO *)plci->fax_connect_info_buffer)->data_format; - PUT_WORD (&plci->ncpi_buffer[5], i); - PUT_WORD (&plci->ncpi_buffer[7], 0); - plci->ncpi_buffer[len] = 0; - plci->ncpi_buffer[0] = len; - if(plci->B3_prot == 4) - sendf(plci->appl,_CONNECT_B3_I,Id,0,"s",""); - else - { - - if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1]) - & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) - { - plci->ncpi_buffer[++len] = 0; - plci->ncpi_buffer[++len] = 0; - plci->ncpi_buffer[++len] = 0; - plci->ncpi_buffer[0] = len; - } - - sendf(plci->appl,_CONNECT_B3_I,Id,0,"S",plci->ncpi_buffer); - } - sendf(plci->appl,_DISCONNECT_B3_I,Id,0,"wS",info,plci->ncpi_buffer); - plci->ncpi_state = 0; - sig_req(plci,HANGUP,0); - send_req(plci); - plci->State = OUTG_DIS_PENDING; - /* disc here */ - } - else if ((a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) - && ((plci->B3_prot == 4) || (plci->B3_prot == 5)) - && ((ncci_state == INC_DIS_PENDING) || (ncci_state == IDLE))) - { - if (ncci_state == IDLE) - { - if (plci->channels) - plci->channels--; - if((plci->State==IDLE || plci->State==SUSPENDING) && !plci->channels){ - if(plci->State == SUSPENDING){ - sendf(plci->appl, - _FACILITY_I, - Id & 0xffffL, - 0, - "ws", (word)3, "\x03\x04\x00\x00"); - sendf(plci->appl, _DISCONNECT_I, Id & 0xffffL, 0, "w", 0); - } - plci_remove(plci); - plci->State=IDLE; - } - } - } - else if (plci->channels) - { - sendf(plci->appl,_DISCONNECT_B3_I,Id,0,"wS",info,plci->ncpi_buffer); - plci->ncpi_state = 0; - if ((ncci_state == OUTG_REJ_PENDING) - && ((plci->B3_prot != B3_T90NL) && (plci->B3_prot != B3_ISO8208) && (plci->B3_prot != B3_X25_DCE))) - { - sig_req(plci,HANGUP,0); - send_req(plci); - plci->State = OUTG_DIS_PENDING; - } - } - break; - case N_RESET: - a->ncci_state[ncci] = INC_RES_PENDING; - sendf(plci->appl,_RESET_B3_I,Id,0,"S",plci->ncpi_buffer); - break; - case N_RESET_ACK: - a->ncci_state[ncci] = CONNECTED; - sendf(plci->appl,_RESET_B3_I,Id,0,"S",plci->ncpi_buffer); - break; - - case N_UDATA: - if (!(udata_forwarding_table[plci->NL.RBuffer->P[0] >> 5] & (1L << (plci->NL.RBuffer->P[0] & 0x1f)))) - { - plci->RData[0].P = plci->internal_ind_buffer + (-((int)(long)(plci->internal_ind_buffer)) & 3); - plci->RData[0].PLength = INTERNAL_IND_BUFFER_SIZE; - plci->NL.R = plci->RData; - plci->NL.RNum = 1; - return; - } - case N_BDATA: - case N_DATA: - if (((a->ncci_state[ncci] != CONNECTED) && (plci->B2_prot == 1)) /* transparent */ - || (a->ncci_state[ncci] == IDLE) - || (a->ncci_state[ncci] == INC_DIS_PENDING)) - { - plci->NL.RNR = 2; - break; - } - if ((a->ncci_state[ncci] != CONNECTED) - && (a->ncci_state[ncci] != OUTG_DIS_PENDING) - && (a->ncci_state[ncci] != OUTG_REJ_PENDING)) - { - dbug(1,dprintf("flow control")); - plci->NL.RNR = 1; /* flow control */ - channel_x_off (plci, ch, 0); - break; - } - - NCCIcode = ncci | (((word)a->Id) << 8); - - /* count all buffers within the Application pool */ - /* belonging to the same NCCI. If this is below the */ - /* number of buffers available per NCCI we accept */ - /* this packet, otherwise we reject it */ - count = 0; - Num = 0xffff; - for(i=0; iMaxBuffer; i++) { - if(NCCIcode==APPLptr->DataNCCI[i]) count++; - if(!APPLptr->DataNCCI[i] && Num==0xffff) Num = i; - } - - if(count>=APPLptr->MaxNCCIData || Num==0xffff) - { - dbug(3,dprintf("Flow-Control")); - plci->NL.RNR = 1; - if( ++(APPLptr->NCCIDataFlowCtrlTimer)>= - (word)((a->manufacturer_features & MANUFACTURER_FEATURE_OOB_CHANNEL) ? 40 : 2000)) - { - plci->NL.RNR = 2; - dbug(3,dprintf("DiscardData")); - } else { - channel_x_off (plci, ch, 0); - } - break; - } - else - { - APPLptr->NCCIDataFlowCtrlTimer = 0; - } - - plci->RData[0].P = ReceiveBufferGet(APPLptr,Num); - if(!plci->RData[0].P) { - plci->NL.RNR = 1; - channel_x_off (plci, ch, 0); - break; - } - - APPLptr->DataNCCI[Num] = NCCIcode; - APPLptr->DataFlags[Num] = (plci->Id<<8) | (plci->NL.Ind>>4); - dbug(3,dprintf("Buffer(%d), Max = %d",Num,APPLptr->MaxBuffer)); - - plci->RNum = Num; - plci->RFlags = plci->NL.Ind>>4; - plci->RData[0].PLength = APPLptr->MaxDataLength; - plci->NL.R = plci->RData; - if ((plci->NL.RLength != 0) - && ((plci->B2_prot == B2_V120_ASYNC) - || (plci->B2_prot == B2_V120_ASYNC_V42BIS) - || (plci->B2_prot == B2_V120_BIT_TRANSPARENT))) - { - plci->RData[1].P = plci->RData[0].P; - plci->RData[1].PLength = plci->RData[0].PLength; - plci->RData[0].P = v120_header_buffer + (-((unsigned long)v120_header_buffer) & 3); - if ((plci->NL.RBuffer->P[0] & V120_HEADER_EXTEND_BIT) || (plci->NL.RLength == 1)) - plci->RData[0].PLength = 1; - else - plci->RData[0].PLength = 2; - if (plci->NL.RBuffer->P[0] & V120_HEADER_BREAK_BIT) - plci->RFlags |= 0x0010; - if (plci->NL.RBuffer->P[0] & (V120_HEADER_C1_BIT | V120_HEADER_C2_BIT)) - plci->RFlags |= 0x8000; - plci->NL.RNum = 2; - } - else - { - if((plci->NL.Ind &0x0f)==N_UDATA) - plci->RFlags |= 0x0010; - - else if ((plci->B3_prot == B3_RTP) && ((plci->NL.Ind & 0x0f) == N_BDATA)) - plci->RFlags |= 0x0001; - - plci->NL.RNum = 1; - } - break; - case N_DATA_ACK: - data_ack (plci, ch); - break; - default: - plci->NL.RNR = 2; - break; - } + if (*data == DSP_UDATA_INDICATION_DCD_ON) + plci->ncpi_state |= NCPI_MDM_DCD_ON_RECEIVED; + if (*data == DSP_UDATA_INDICATION_CTS_ON) + plci->ncpi_state |= NCPI_MDM_CTS_ON_RECEIVED; + + data++; /* indication code */ + data += 2; /* timestamp */ + if ((*data == DSP_CONNECTED_NORM_V18) || (*data == DSP_CONNECTED_NORM_VOWN)) + ncpi_state &= ~(NCPI_MDM_DCD_ON_RECEIVED | NCPI_MDM_CTS_ON_RECEIVED); + data++; /* connected norm */ + conn_opt = GET_WORD(data); + data += 2; /* connected options */ + + PUT_WORD(&(plci->ncpi_buffer[1]), (word)(GET_DWORD(data) & 0x0000FFFF)); + + if (conn_opt & DSP_CONNECTED_OPTION_MASK_V42) + { + ncpi_opt |= MDM_NCPI_ECM_V42; + } + else if (conn_opt & DSP_CONNECTED_OPTION_MASK_MNP) + { + ncpi_opt |= MDM_NCPI_ECM_MNP; + } + else + { + ncpi_opt |= MDM_NCPI_TRANSPARENT; + } + if (conn_opt & DSP_CONNECTED_OPTION_MASK_COMPRESSION) + { + ncpi_opt |= MDM_NCPI_COMPRESSED; + } + PUT_WORD(&(plci->ncpi_buffer[3]), ncpi_opt); + plci->ncpi_buffer[0] = 4; + + plci->ncpi_state |= NCPI_VALID_CONNECT_B3_IND | NCPI_VALID_CONNECT_B3_ACT | NCPI_VALID_DISC_B3_IND; + } + } + if (plci->B3_prot == 7) + { + if (((a->ncci_state[ncci] == INC_ACT_PENDING) || (a->ncci_state[ncci] == OUTG_CON_PENDING)) + && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + a->ncci_state[ncci] = INC_ACT_PENDING; + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } + } + + if (!((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id - 1]) + & ((1L << PRIVATE_V18) | (1L << PRIVATE_VOWN))) + || !(ncpi_state & NCPI_MDM_DCD_ON_RECEIVED) + || !(ncpi_state & NCPI_MDM_CTS_ON_RECEIVED)) + + { + plci->NL.RNR = 2; + return; + } + } + + if (plci->NL.complete == 2) + { + if (((plci->NL.Ind & 0x0f) == N_UDATA) + && !(udata_forwarding_table[plci->RData[0].P[0] >> 5] & (1L << (plci->RData[0].P[0] & 0x1f)))) + { + switch (plci->RData[0].P[0]) + { + + case DTMF_UDATA_INDICATION_FAX_CALLING_TONE: + if (plci->dtmf_rec_active & DTMF_LISTEN_ACTIVE_FLAG) + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", SELECTOR_DTMF, "\x01X"); + break; + case DTMF_UDATA_INDICATION_ANSWER_TONE: + if (plci->dtmf_rec_active & DTMF_LISTEN_ACTIVE_FLAG) + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", SELECTOR_DTMF, "\x01Y"); + break; + case DTMF_UDATA_INDICATION_DIGITS_RECEIVED: + dtmf_indication(Id, plci, plci->RData[0].P, plci->RData[0].PLength); + break; + case DTMF_UDATA_INDICATION_DIGITS_SENT: + dtmf_confirmation(Id, plci); + break; + + + case UDATA_INDICATION_MIXER_TAP_DATA: + capidtmf_recv_process_block(&(plci->capidtmf_state), plci->RData[0].P + 1, (word)(plci->RData[0].PLength - 1)); + i = capidtmf_indication(&(plci->capidtmf_state), dtmf_code_buffer + 1); + if (i != 0) + { + dtmf_code_buffer[0] = DTMF_UDATA_INDICATION_DIGITS_RECEIVED; + dtmf_indication(Id, plci, dtmf_code_buffer, (word)(i + 1)); + } + break; + + + case UDATA_INDICATION_MIXER_COEFS_SET: + mixer_indication_coefs_set(Id, plci); + break; + case UDATA_INDICATION_XCONNECT_FROM: + mixer_indication_xconnect_from(Id, plci, plci->RData[0].P, plci->RData[0].PLength); + break; + case UDATA_INDICATION_XCONNECT_TO: + mixer_indication_xconnect_to(Id, plci, plci->RData[0].P, plci->RData[0].PLength); + break; + + + case LEC_UDATA_INDICATION_DISABLE_DETECT: + ec_indication(Id, plci, plci->RData[0].P, plci->RData[0].PLength); + break; + + + + default: + break; + } + } + else + { + if ((plci->RData[0].PLength != 0) + && ((plci->B2_prot == B2_V120_ASYNC) + || (plci->B2_prot == B2_V120_ASYNC_V42BIS) + || (plci->B2_prot == B2_V120_BIT_TRANSPARENT))) + { + + sendf(plci->appl, _DATA_B3_I, Id, 0, + "dwww", + plci->RData[1].P, + (plci->NL.RNum < 2) ? 0 : plci->RData[1].PLength, + plci->RNum, + plci->RFlags); + + } + else + { + + sendf(plci->appl, _DATA_B3_I, Id, 0, + "dwww", + plci->RData[0].P, + plci->RData[0].PLength, + plci->RNum, + plci->RFlags); + + } + } + return; + } + + fax_feature_bits = 0; + if ((plci->NL.Ind & 0x0f) == N_CONNECT || + (plci->NL.Ind & 0x0f) == N_CONNECT_ACK || + (plci->NL.Ind & 0x0f) == N_DISC || + (plci->NL.Ind & 0x0f) == N_EDATA || + (plci->NL.Ind & 0x0f) == N_DISC_ACK) + { + info = 0; + plci->ncpi_buffer[0] = 0; + switch (plci->B3_prot) { + case 0: /*XPARENT*/ + case 1: /*T.90 NL*/ + break; /* no network control protocol info - jfr */ + case 2: /*ISO8202*/ + case 3: /*X25 DCE*/ + for (i = 0; i < plci->NL.RLength; i++) plci->ncpi_buffer[4 + i] = plci->NL.RBuffer->P[i]; + plci->ncpi_buffer[0] = (byte)(i + 3); + plci->ncpi_buffer[1] = (byte)(plci->NL.Ind & N_D_BIT ? 1 : 0); + plci->ncpi_buffer[2] = 0; + plci->ncpi_buffer[3] = 0; + break; + case 4: /*T.30 - FAX*/ + case 5: /*T.30 - FAX*/ + if (plci->NL.RLength >= sizeof(T30_INFO)) + { + dbug(1, dprintf("FaxStatus %04x", ((T30_INFO *)plci->NL.RBuffer->P)->code)); + len = 9; + PUT_WORD(&(plci->ncpi_buffer[1]), ((T30_INFO *)plci->NL.RBuffer->P)->rate_div_2400 * 2400); + fax_feature_bits = GET_WORD(&((T30_INFO *)plci->NL.RBuffer->P)->feature_bits_low); + i = (((T30_INFO *)plci->NL.RBuffer->P)->resolution & T30_RESOLUTION_R8_0770_OR_200) ? 0x0001 : 0x0000; + if (plci->B3_prot == 5) + { + if (!(fax_feature_bits & T30_FEATURE_BIT_ECM)) + i |= 0x8000; /* This is not an ECM connection */ + if (fax_feature_bits & T30_FEATURE_BIT_T6_CODING) + i |= 0x4000; /* This is a connection with MMR compression */ + if (fax_feature_bits & T30_FEATURE_BIT_2D_CODING) + i |= 0x2000; /* This is a connection with MR compression */ + if (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS) + i |= 0x0004; /* More documents */ + if (fax_feature_bits & T30_FEATURE_BIT_POLLING) + i |= 0x0002; /* Fax-polling indication */ + } + dbug(1, dprintf("FAX Options %04x %04x", fax_feature_bits, i)); + PUT_WORD(&(plci->ncpi_buffer[3]), i); + PUT_WORD(&(plci->ncpi_buffer[5]), ((T30_INFO *)plci->NL.RBuffer->P)->data_format); + plci->ncpi_buffer[7] = ((T30_INFO *)plci->NL.RBuffer->P)->pages_low; + plci->ncpi_buffer[8] = ((T30_INFO *)plci->NL.RBuffer->P)->pages_high; + plci->ncpi_buffer[len] = 0; + if (((T30_INFO *)plci->NL.RBuffer->P)->station_id_len) + { + plci->ncpi_buffer[len] = 20; + for (i = 0; i < T30_MAX_STATION_ID_LENGTH; i++) + plci->ncpi_buffer[++len] = ((T30_INFO *)plci->NL.RBuffer->P)->station_id[i]; + } + if (((plci->NL.Ind & 0x0f) == N_DISC) || ((plci->NL.Ind & 0x0f) == N_DISC_ACK)) + { + if (((T30_INFO *)plci->NL.RBuffer->P)->code < ARRAY_SIZE(fax_info)) + info = fax_info[((T30_INFO *)plci->NL.RBuffer->P)->code]; + else + info = _FAX_PROTOCOL_ERROR; + } + + if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id - 1]) + & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) + { + i = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + ((T30_INFO *)plci->NL.RBuffer->P)->head_line_len; + while (i < plci->NL.RBuffer->length) + plci->ncpi_buffer[++len] = plci->NL.RBuffer->P[i++]; + } + + plci->ncpi_buffer[0] = len; + fax_feature_bits = GET_WORD(&((T30_INFO *)plci->NL.RBuffer->P)->feature_bits_low); + PUT_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->feature_bits_low, fax_feature_bits); + + plci->ncpi_state |= NCPI_VALID_CONNECT_B3_IND; + if (((plci->NL.Ind & 0x0f) == N_CONNECT_ACK) + || (((plci->NL.Ind & 0x0f) == N_CONNECT) + && (fax_feature_bits & T30_FEATURE_BIT_POLLING)) + || (((plci->NL.Ind & 0x0f) == N_EDATA) + && ((((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_TRAIN_OK) + || (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_DIS) + || (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_DTC)))) + { + plci->ncpi_state |= NCPI_VALID_CONNECT_B3_ACT; + } + if (((plci->NL.Ind & 0x0f) == N_DISC) + || ((plci->NL.Ind & 0x0f) == N_DISC_ACK) + || (((plci->NL.Ind & 0x0f) == N_EDATA) + && (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_EOP_CAPI))) + { + plci->ncpi_state |= NCPI_VALID_CONNECT_B3_ACT | NCPI_VALID_DISC_B3_IND; + } + } + break; + + case B3_RTP: + if (((plci->NL.Ind & 0x0f) == N_DISC) || ((plci->NL.Ind & 0x0f) == N_DISC_ACK)) + { + if (plci->NL.RLength != 0) + { + info = rtp_info[plci->NL.RBuffer->P[0]]; + plci->ncpi_buffer[0] = plci->NL.RLength - 1; + for (i = 1; i < plci->NL.RLength; i++) + plci->ncpi_buffer[i] = plci->NL.RBuffer->P[i]; + } + } + break; + + } + plci->NL.RNR = 2; + } + switch (plci->NL.Ind & 0x0f) { + case N_EDATA: + if ((plci->B3_prot == 4) || (plci->B3_prot == 5)) + { + dbug(1, dprintf("EDATA ncci=0x%x state=%d code=%02x", ncci, a->ncci_state[ncci], + ((T30_INFO *)plci->NL.RBuffer->P)->code)); + fax_send_edata_ack = (((T30_INFO *)(plci->fax_connect_info_buffer))->operating_mode == T30_OPERATING_MODE_CAPI_NEG); + + if ((plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) + && (plci->nsf_control_bits & (T30_NSF_CONTROL_BIT_NEGOTIATE_IND | T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) + && (((T30_INFO *)plci->NL.RBuffer->P)->code == EDATA_T30_DIS) + && (a->ncci_state[ncci] == OUTG_CON_PENDING) + && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_NEGOTIATE_B3_SENT)) + { + ((T30_INFO *)(plci->fax_connect_info_buffer))->code = ((T30_INFO *)plci->NL.RBuffer->P)->code; + sendf(plci->appl, _MANUFACTURER_I, Id, 0, "dwbS", _DI_MANU_ID, _DI_NEGOTIATE_B3, + (byte)(plci->ncpi_buffer[0] + 1), plci->ncpi_buffer); + plci->ncpi_state |= NCPI_NEGOTIATE_B3_SENT; + if (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP) + fax_send_edata_ack = false; + } + + if (a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) + { + switch (((T30_INFO *)plci->NL.RBuffer->P)->code) + { + case EDATA_T30_DIS: + if ((a->ncci_state[ncci] == OUTG_CON_PENDING) + && !(GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low) & T30_CONTROL_BIT_REQUEST_POLLING) + && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + a->ncci_state[ncci] = INC_ACT_PENDING; + if (plci->B3_prot == 4) + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + else + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } + break; + + case EDATA_T30_TRAIN_OK: + if ((a->ncci_state[ncci] == INC_ACT_PENDING) + && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + if (plci->B3_prot == 4) + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + else + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } + break; + + case EDATA_T30_EOP_CAPI: + if (a->ncci_state[ncci] == CONNECTED) + { + sendf(plci->appl, _DISCONNECT_B3_I, Id, 0, "wS", GOOD, plci->ncpi_buffer); + a->ncci_state[ncci] = INC_DIS_PENDING; + plci->ncpi_state = 0; + fax_send_edata_ack = false; + } + break; + } + } + else + { + switch (((T30_INFO *)plci->NL.RBuffer->P)->code) + { + case EDATA_T30_TRAIN_OK: + if ((a->ncci_state[ncci] == INC_ACT_PENDING) + && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + if (plci->B3_prot == 4) + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + else + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } + break; + } + } + if (fax_send_edata_ack) + { + ((T30_INFO *)(plci->fax_connect_info_buffer))->code = ((T30_INFO *)plci->NL.RBuffer->P)->code; + plci->fax_edata_ack_length = 1; + start_internal_command(Id, plci, fax_edata_ack_command); + } + } + else + { + dbug(1, dprintf("EDATA ncci=0x%x state=%d", ncci, a->ncci_state[ncci])); + } + break; + case N_CONNECT: + if (!a->ch_ncci[ch]) + { + ncci = get_ncci(plci, ch, 0); + Id = (Id & 0xffff) | (((dword) ncci) << 16); + } + dbug(1, dprintf("N_CONNECT: ch=%d state=%d plci=%lx plci_Id=%lx plci_State=%d", + ch, a->ncci_state[ncci], a->ncci_plci[ncci], plci->Id, plci->State)); + + msg = _CONNECT_B3_I; + if (a->ncci_state[ncci] == IDLE) + plci->channels++; + else if (plci->B3_prot == 1) + msg = _CONNECT_B3_T90_ACTIVE_I; + + a->ncci_state[ncci] = INC_CON_PENDING; + if (plci->B3_prot == 4) + sendf(plci->appl, msg, Id, 0, "s", ""); + else + sendf(plci->appl, msg, Id, 0, "S", plci->ncpi_buffer); + break; + case N_CONNECT_ACK: + dbug(1, dprintf("N_connect_Ack")); + if (plci->internal_command_queue[0] + && ((plci->adjust_b_state == ADJUST_B_CONNECT_2) + || (plci->adjust_b_state == ADJUST_B_CONNECT_3) + || (plci->adjust_b_state == ADJUST_B_CONNECT_4))) + { + (*(plci->internal_command_queue[0]))(Id, plci, 0); + if (!plci->internal_command) + next_internal_command(Id, plci); + break; + } + msg = _CONNECT_B3_ACTIVE_I; + if (plci->B3_prot == 1) + { + if (a->ncci_state[ncci] != OUTG_CON_PENDING) + msg = _CONNECT_B3_T90_ACTIVE_I; + a->ncci_state[ncci] = INC_ACT_PENDING; + sendf(plci->appl, msg, Id, 0, "S", plci->ncpi_buffer); + } + else if ((plci->B3_prot == 4) || (plci->B3_prot == 5) || (plci->B3_prot == 7)) + { + if ((a->ncci_state[ncci] == OUTG_CON_PENDING) + && (plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + a->ncci_state[ncci] = INC_ACT_PENDING; + if (plci->B3_prot == 4) + sendf(plci->appl, msg, Id, 0, "s", ""); + else + sendf(plci->appl, msg, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } + } + else + { + a->ncci_state[ncci] = INC_ACT_PENDING; + sendf(plci->appl, msg, Id, 0, "S", plci->ncpi_buffer); + } + if (plci->adjust_b_restore) + { + plci->adjust_b_restore = false; + start_internal_command(Id, plci, adjust_b_restore); + } + break; + case N_DISC: + case N_DISC_ACK: + if (plci->internal_command_queue[0] + && ((plci->internal_command == FAX_DISCONNECT_COMMAND_1) + || (plci->internal_command == FAX_DISCONNECT_COMMAND_2) + || (plci->internal_command == FAX_DISCONNECT_COMMAND_3))) + { + (*(plci->internal_command_queue[0]))(Id, plci, 0); + if (!plci->internal_command) + next_internal_command(Id, plci); + } + ncci_state = a->ncci_state[ncci]; + ncci_remove(plci, ncci, false); + + /* with N_DISC or N_DISC_ACK the IDI frees the respective */ + /* channel, so we cannot store the state in ncci_state! The */ + /* information which channel we received a N_DISC is thus */ + /* stored in the inc_dis_ncci_table buffer. */ + for (i = 0; plci->inc_dis_ncci_table[i]; i++); + plci->inc_dis_ncci_table[i] = (byte) ncci; + + /* need a connect_b3_ind before a disconnect_b3_ind with FAX */ + if (!plci->channels + && (plci->B1_resource == 16) + && (plci->State <= CONNECTED)) + { + len = 9; + i = ((T30_INFO *)plci->fax_connect_info_buffer)->rate_div_2400 * 2400; + PUT_WORD(&plci->ncpi_buffer[1], i); + PUT_WORD(&plci->ncpi_buffer[3], 0); + i = ((T30_INFO *)plci->fax_connect_info_buffer)->data_format; + PUT_WORD(&plci->ncpi_buffer[5], i); + PUT_WORD(&plci->ncpi_buffer[7], 0); + plci->ncpi_buffer[len] = 0; + plci->ncpi_buffer[0] = len; + if (plci->B3_prot == 4) + sendf(plci->appl, _CONNECT_B3_I, Id, 0, "s", ""); + else + { + + if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id - 1]) + & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) + { + plci->ncpi_buffer[++len] = 0; + plci->ncpi_buffer[++len] = 0; + plci->ncpi_buffer[++len] = 0; + plci->ncpi_buffer[0] = len; + } + + sendf(plci->appl, _CONNECT_B3_I, Id, 0, "S", plci->ncpi_buffer); + } + sendf(plci->appl, _DISCONNECT_B3_I, Id, 0, "wS", info, plci->ncpi_buffer); + plci->ncpi_state = 0; + sig_req(plci, HANGUP, 0); + send_req(plci); + plci->State = OUTG_DIS_PENDING; + /* disc here */ + } + else if ((a->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) + && ((plci->B3_prot == 4) || (plci->B3_prot == 5)) + && ((ncci_state == INC_DIS_PENDING) || (ncci_state == IDLE))) + { + if (ncci_state == IDLE) + { + if (plci->channels) + plci->channels--; + if ((plci->State == IDLE || plci->State == SUSPENDING) && !plci->channels) { + if (plci->State == SUSPENDING) { + sendf(plci->appl, + _FACILITY_I, + Id & 0xffffL, + 0, + "ws", (word)3, "\x03\x04\x00\x00"); + sendf(plci->appl, _DISCONNECT_I, Id & 0xffffL, 0, "w", 0); + } + plci_remove(plci); + plci->State = IDLE; + } + } + } + else if (plci->channels) + { + sendf(plci->appl, _DISCONNECT_B3_I, Id, 0, "wS", info, plci->ncpi_buffer); + plci->ncpi_state = 0; + if ((ncci_state == OUTG_REJ_PENDING) + && ((plci->B3_prot != B3_T90NL) && (plci->B3_prot != B3_ISO8208) && (plci->B3_prot != B3_X25_DCE))) + { + sig_req(plci, HANGUP, 0); + send_req(plci); + plci->State = OUTG_DIS_PENDING; + } + } + break; + case N_RESET: + a->ncci_state[ncci] = INC_RES_PENDING; + sendf(plci->appl, _RESET_B3_I, Id, 0, "S", plci->ncpi_buffer); + break; + case N_RESET_ACK: + a->ncci_state[ncci] = CONNECTED; + sendf(plci->appl, _RESET_B3_I, Id, 0, "S", plci->ncpi_buffer); + break; + + case N_UDATA: + if (!(udata_forwarding_table[plci->NL.RBuffer->P[0] >> 5] & (1L << (plci->NL.RBuffer->P[0] & 0x1f)))) + { + plci->RData[0].P = plci->internal_ind_buffer + (-((int)(long)(plci->internal_ind_buffer)) & 3); + plci->RData[0].PLength = INTERNAL_IND_BUFFER_SIZE; + plci->NL.R = plci->RData; + plci->NL.RNum = 1; + return; + } + case N_BDATA: + case N_DATA: + if (((a->ncci_state[ncci] != CONNECTED) && (plci->B2_prot == 1)) /* transparent */ + || (a->ncci_state[ncci] == IDLE) + || (a->ncci_state[ncci] == INC_DIS_PENDING)) + { + plci->NL.RNR = 2; + break; + } + if ((a->ncci_state[ncci] != CONNECTED) + && (a->ncci_state[ncci] != OUTG_DIS_PENDING) + && (a->ncci_state[ncci] != OUTG_REJ_PENDING)) + { + dbug(1, dprintf("flow control")); + plci->NL.RNR = 1; /* flow control */ + channel_x_off(plci, ch, 0); + break; + } + + NCCIcode = ncci | (((word)a->Id) << 8); + + /* count all buffers within the Application pool */ + /* belonging to the same NCCI. If this is below the */ + /* number of buffers available per NCCI we accept */ + /* this packet, otherwise we reject it */ + count = 0; + Num = 0xffff; + for (i = 0; i < APPLptr->MaxBuffer; i++) { + if (NCCIcode == APPLptr->DataNCCI[i]) count++; + if (!APPLptr->DataNCCI[i] && Num == 0xffff) Num = i; + } + + if (count >= APPLptr->MaxNCCIData || Num == 0xffff) + { + dbug(3, dprintf("Flow-Control")); + plci->NL.RNR = 1; + if (++(APPLptr->NCCIDataFlowCtrlTimer) >= + (word)((a->manufacturer_features & MANUFACTURER_FEATURE_OOB_CHANNEL) ? 40 : 2000)) + { + plci->NL.RNR = 2; + dbug(3, dprintf("DiscardData")); + } else { + channel_x_off(plci, ch, 0); + } + break; + } + else + { + APPLptr->NCCIDataFlowCtrlTimer = 0; + } + + plci->RData[0].P = ReceiveBufferGet(APPLptr, Num); + if (!plci->RData[0].P) { + plci->NL.RNR = 1; + channel_x_off(plci, ch, 0); + break; + } + + APPLptr->DataNCCI[Num] = NCCIcode; + APPLptr->DataFlags[Num] = (plci->Id << 8) | (plci->NL.Ind >> 4); + dbug(3, dprintf("Buffer(%d), Max = %d", Num, APPLptr->MaxBuffer)); + + plci->RNum = Num; + plci->RFlags = plci->NL.Ind >> 4; + plci->RData[0].PLength = APPLptr->MaxDataLength; + plci->NL.R = plci->RData; + if ((plci->NL.RLength != 0) + && ((plci->B2_prot == B2_V120_ASYNC) + || (plci->B2_prot == B2_V120_ASYNC_V42BIS) + || (plci->B2_prot == B2_V120_BIT_TRANSPARENT))) + { + plci->RData[1].P = plci->RData[0].P; + plci->RData[1].PLength = plci->RData[0].PLength; + plci->RData[0].P = v120_header_buffer + (-((unsigned long)v120_header_buffer) & 3); + if ((plci->NL.RBuffer->P[0] & V120_HEADER_EXTEND_BIT) || (plci->NL.RLength == 1)) + plci->RData[0].PLength = 1; + else + plci->RData[0].PLength = 2; + if (plci->NL.RBuffer->P[0] & V120_HEADER_BREAK_BIT) + plci->RFlags |= 0x0010; + if (plci->NL.RBuffer->P[0] & (V120_HEADER_C1_BIT | V120_HEADER_C2_BIT)) + plci->RFlags |= 0x8000; + plci->NL.RNum = 2; + } + else + { + if ((plci->NL.Ind & 0x0f) == N_UDATA) + plci->RFlags |= 0x0010; + + else if ((plci->B3_prot == B3_RTP) && ((plci->NL.Ind & 0x0f) == N_BDATA)) + plci->RFlags |= 0x0001; + + plci->NL.RNum = 1; + } + break; + case N_DATA_ACK: + data_ack(plci, ch); + break; + default: + plci->NL.RNR = 2; + break; + } } /*------------------------------------------------------------------*/ -/* find a free PLCI */ +/* find a free PLCI */ /*------------------------------------------------------------------*/ static word get_plci(DIVA_CAPI_ADAPTER *a) { - word i,j; - PLCI * plci; - - dump_plcis (a); - for(i=0;imax_plci && a->plci[i].Id;i++); - if(i==a->max_plci) { - dbug(1,dprintf("get_plci: out of PLCIs")); - return 0; - } - plci = &a->plci[i]; - plci->Id = (byte)(i+1); - - plci->Sig.Id = 0; - plci->NL.Id = 0; - plci->sig_req = 0; - plci->nl_req = 0; - - plci->appl = NULL; - plci->relatedPTYPLCI = NULL; - plci->State = IDLE; - plci->SuppState = IDLE; - plci->channels = 0; - plci->tel = 0; - plci->B1_resource = 0; - plci->B2_prot = 0; - plci->B3_prot = 0; - - plci->command = 0; - plci->m_command = 0; - init_internal_command_queue (plci); - plci->number = 0; - plci->req_in_start = 0; - plci->req_in = 0; - plci->req_out = 0; - plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; - plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; - - plci->data_sent = false; - plci->send_disc = 0; - plci->sig_global_req = 0; - plci->sig_remove_id = 0; - plci->nl_global_req = 0; - plci->nl_remove_id = 0; - plci->adv_nl = 0; - plci->manufacturer = false; - plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; - plci->spoofed_msg = 0; - plci->ptyState = 0; - plci->cr_enquiry = false; - plci->hangup_flow_ctrl_timer = 0; - - plci->ncci_ring_list = 0; - for(j=0;jinc_dis_ncci_table[j] = 0; - clear_c_ind_mask (plci); - set_group_ind_mask (plci); - plci->fax_connect_info_length = 0; - plci->nsf_control_bits = 0; - plci->ncpi_state = 0x00; - plci->ncpi_buffer[0] = 0; - - plci->requested_options_conn = 0; - plci->requested_options = 0; - plci->notifiedcall = 0; - plci->vswitchstate = 0; - plci->vsprot = 0; - plci->vsprotdialect = 0; - init_b1_config (plci); - dbug(1,dprintf("get_plci(%x)",plci->Id)); - return i+1; + word i, j; + PLCI *plci; + + dump_plcis(a); + for (i = 0; i < a->max_plci && a->plci[i].Id; i++); + if (i == a->max_plci) { + dbug(1, dprintf("get_plci: out of PLCIs")); + return 0; + } + plci = &a->plci[i]; + plci->Id = (byte)(i + 1); + + plci->Sig.Id = 0; + plci->NL.Id = 0; + plci->sig_req = 0; + plci->nl_req = 0; + + plci->appl = NULL; + plci->relatedPTYPLCI = NULL; + plci->State = IDLE; + plci->SuppState = IDLE; + plci->channels = 0; + plci->tel = 0; + plci->B1_resource = 0; + plci->B2_prot = 0; + plci->B3_prot = 0; + + plci->command = 0; + plci->m_command = 0; + init_internal_command_queue(plci); + plci->number = 0; + plci->req_in_start = 0; + plci->req_in = 0; + plci->req_out = 0; + plci->msg_in_write_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_read_pos = MSG_IN_QUEUE_SIZE; + plci->msg_in_wrap_pos = MSG_IN_QUEUE_SIZE; + + plci->data_sent = false; + plci->send_disc = 0; + plci->sig_global_req = 0; + plci->sig_remove_id = 0; + plci->nl_global_req = 0; + plci->nl_remove_id = 0; + plci->adv_nl = 0; + plci->manufacturer = false; + plci->call_dir = CALL_DIR_OUT | CALL_DIR_ORIGINATE; + plci->spoofed_msg = 0; + plci->ptyState = 0; + plci->cr_enquiry = false; + plci->hangup_flow_ctrl_timer = 0; + + plci->ncci_ring_list = 0; + for (j = 0; j < MAX_CHANNELS_PER_PLCI; j++) plci->inc_dis_ncci_table[j] = 0; + clear_c_ind_mask(plci); + set_group_ind_mask(plci); + plci->fax_connect_info_length = 0; + plci->nsf_control_bits = 0; + plci->ncpi_state = 0x00; + plci->ncpi_buffer[0] = 0; + + plci->requested_options_conn = 0; + plci->requested_options = 0; + plci->notifiedcall = 0; + plci->vswitchstate = 0; + plci->vsprot = 0; + plci->vsprotdialect = 0; + init_b1_config(plci); + dbug(1, dprintf("get_plci(%x)", plci->Id)); + return i + 1; } /*------------------------------------------------------------------*/ /* put a parameter in the parameter buffer */ /*------------------------------------------------------------------*/ -static void add_p(PLCI * plci, byte code, byte * p) +static void add_p(PLCI *plci, byte code, byte *p) { - word p_length; + word p_length; - p_length = 0; - if(p) p_length = p[0]; - add_ie(plci, code, p, p_length); + p_length = 0; + if (p) p_length = p[0]; + add_ie(plci, code, p, p_length); } /*------------------------------------------------------------------*/ /* put a structure in the parameter buffer */ /*------------------------------------------------------------------*/ -static void add_s(PLCI * plci, byte code, API_PARSE * p) +static void add_s(PLCI *plci, byte code, API_PARSE *p) { - if(p) add_ie(plci, code, p->info, (word)p->length); + if (p) add_ie(plci, code, p->info, (word)p->length); } /*------------------------------------------------------------------*/ /* put multiple structures in the parameter buffer */ /*------------------------------------------------------------------*/ -static void add_ss(PLCI * plci, byte code, API_PARSE * p) +static void add_ss(PLCI *plci, byte code, API_PARSE *p) { - byte i; + byte i; - if(p){ - dbug(1,dprintf("add_ss(%x,len=%d)",code,p->length)); - for(i=2;i<(byte)p->length;i+=p->info[i]+2){ - dbug(1,dprintf("add_ss_ie(%x,len=%d)",p->info[i-1],p->info[i])); - add_ie(plci, p->info[i-1], (byte *)&(p->info[i]), (word)p->info[i]); - } - } + if (p) { + dbug(1, dprintf("add_ss(%x,len=%d)", code, p->length)); + for (i = 2; i < (byte)p->length; i += p->info[i] + 2) { + dbug(1, dprintf("add_ss_ie(%x,len=%d)", p->info[i - 1], p->info[i])); + add_ie(plci, p->info[i - 1], (byte *)&(p->info[i]), (word)p->info[i]); + } + } } /*------------------------------------------------------------------*/ /* return the channel number sent by the application in a esc_chi */ /*------------------------------------------------------------------*/ -static byte getChannel(API_PARSE * p) +static byte getChannel(API_PARSE *p) { - byte i; + byte i; - if(p){ - for(i=2;i<(byte)p->length;i+=p->info[i]+2){ - if(p->info[i]==2){ - if(p->info[i-1]==ESC && p->info[i+1]==CHI) return (p->info[i+2]); - } - } - } - return 0; + if (p) { + for (i = 2; i < (byte)p->length; i += p->info[i] + 2) { + if (p->info[i] == 2) { + if (p->info[i - 1] == ESC && p->info[i + 1] == CHI) return (p->info[i + 2]); + } + } + } + return 0; } @@ -7400,26 +7400,26 @@ static byte getChannel(API_PARSE * p) /* put an information element in the parameter buffer */ /*------------------------------------------------------------------*/ -static void add_ie(PLCI * plci, byte code, byte * p, word p_length) +static void add_ie(PLCI *plci, byte code, byte *p, word p_length) { - word i; + word i; - if(!(code &0x80) && !p_length) return; + if (!(code & 0x80) && !p_length) return; - if(plci->req_in==plci->req_in_start) { - plci->req_in +=2; - } - else { - plci->req_in--; - } - plci->RBuffer[plci->req_in++] = code; + if (plci->req_in == plci->req_in_start) { + plci->req_in += 2; + } + else { + plci->req_in--; + } + plci->RBuffer[plci->req_in++] = code; - if(p) { - plci->RBuffer[plci->req_in++] = (byte)p_length; - for(i=0;iRBuffer[plci->req_in++] = p[1+i]; - } + if (p) { + plci->RBuffer[plci->req_in++] = (byte)p_length; + for (i = 0; i < p_length; i++) plci->RBuffer[plci->req_in++] = p[1 + i]; + } - plci->RBuffer[plci->req_in++] = 0; + plci->RBuffer[plci->req_in++] = 0; } /*------------------------------------------------------------------*/ @@ -7428,15 +7428,15 @@ static void add_ie(PLCI * plci, byte code, byte * p, word p_length) static void add_d(PLCI *plci, word length, byte *p) { - word i; + word i; - if(plci->req_in==plci->req_in_start) { - plci->req_in +=2; - } - else { - plci->req_in--; - } - for(i=0;iRBuffer[plci->req_in++] = p[i]; + if (plci->req_in == plci->req_in_start) { + plci->req_in += 2; + } + else { + plci->req_in--; + } + for (i = 0; i < length; i++) plci->RBuffer[plci->req_in++] = p[i]; } /*------------------------------------------------------------------*/ @@ -7446,19 +7446,19 @@ static void add_d(PLCI *plci, word length, byte *p) static void add_ai(PLCI *plci, API_PARSE *ai) { - word i; - API_PARSE ai_parms[5]; + word i; + API_PARSE ai_parms[5]; - for(i=0;i<5;i++) ai_parms[i].length = 0; + for (i = 0; i < 5; i++) ai_parms[i].length = 0; - if(!ai->length) - return; - if(api_parse(&ai->info[1], (word)ai->length, "ssss", ai_parms)) - return; + if (!ai->length) + return; + if (api_parse(&ai->info[1], (word)ai->length, "ssss", ai_parms)) + return; - add_s (plci,KEY,&ai_parms[1]); - add_s (plci,UUI,&ai_parms[2]); - add_ss(plci,FTY,&ai_parms[3]); + add_s(plci, KEY, &ai_parms[1]); + add_s(plci, UUI, &ai_parms[2]); + add_ss(plci, FTY, &ai_parms[3]); } /*------------------------------------------------------------------*/ @@ -7468,462 +7468,462 @@ static void add_ai(PLCI *plci, API_PARSE *ai) static word add_b1(PLCI *plci, API_PARSE *bp, word b_channel_info, word b1_facilities) { - API_PARSE bp_parms[8]; - API_PARSE mdm_cfg[9]; - API_PARSE global_config[2]; - byte cai[256]; - byte resource[] = {5,9,13,12,16,39,9,17,17,18}; - byte voice_cai[] = "\x06\x14\x00\x00\x00\x00\x08"; - word i; - - API_PARSE mdm_cfg_v18[4]; - word j, n, w; - dword d; - - - for(i=0;i<8;i++) bp_parms[i].length = 0; - for(i=0;i<2;i++) global_config[i].length = 0; - - dbug(1,dprintf("add_b1")); - api_save_msg(bp, "s", &plci->B_protocol); - - if(b_channel_info==2){ - plci->B1_resource = 0; - adjust_b1_facilities (plci, plci->B1_resource, b1_facilities); - add_p(plci, CAI, "\x01\x00"); - dbug(1,dprintf("Cai=1,0 (no resource)")); - return 0; - } - - if(plci->tel == CODEC_PERMANENT) return 0; - else if(plci->tel == CODEC){ - plci->B1_resource = 1; - adjust_b1_facilities (plci, plci->B1_resource, b1_facilities); - add_p(plci, CAI, "\x01\x01"); - dbug(1,dprintf("Cai=1,1 (Codec)")); - return 0; - } - else if(plci->tel == ADV_VOICE){ - plci->B1_resource = add_b1_facilities (plci, 9, (word)(b1_facilities | B1_FACILITY_VOICE)); - adjust_b1_facilities (plci, plci->B1_resource, (word)(b1_facilities | B1_FACILITY_VOICE)); - voice_cai[1] = plci->B1_resource; - PUT_WORD (&voice_cai[5], plci->appl->MaxDataLength); - add_p(plci, CAI, voice_cai); - dbug(1,dprintf("Cai=1,0x%x (AdvVoice)",voice_cai[1])); - return 0; - } - plci->call_dir &= ~(CALL_DIR_ORIGINATE | CALL_DIR_ANSWER); - if (plci->call_dir & CALL_DIR_OUT) - plci->call_dir |= CALL_DIR_ORIGINATE; - else if (plci->call_dir & CALL_DIR_IN) - plci->call_dir |= CALL_DIR_ANSWER; - - if(!bp->length){ - plci->B1_resource = 0x5; - adjust_b1_facilities (plci, plci->B1_resource, b1_facilities); - add_p(plci, CAI, "\x01\x05"); - return 0; - } - - dbug(1,dprintf("b_prot_len=%d",(word)bp->length)); - if(bp->length>256) return _WRONG_MESSAGE_FORMAT; - if(api_parse(&bp->info[1], (word)bp->length, "wwwsssb", bp_parms)) - { - bp_parms[6].length = 0; - if(api_parse(&bp->info[1], (word)bp->length, "wwwsss", bp_parms)) - { - dbug(1,dprintf("b-form.!")); - return _WRONG_MESSAGE_FORMAT; - } - } - else if (api_parse(&bp->info[1], (word)bp->length, "wwwssss", bp_parms)) - { - dbug(1,dprintf("b-form.!")); - return _WRONG_MESSAGE_FORMAT; - } - - if(bp_parms[6].length) - { - if(api_parse(&bp_parms[6].info[1], (word)bp_parms[6].length, "w", global_config)) - { - return _WRONG_MESSAGE_FORMAT; - } - switch(GET_WORD(global_config[0].info)) - { - case 1: - plci->call_dir = (plci->call_dir & ~CALL_DIR_ANSWER) | CALL_DIR_ORIGINATE; - break; - case 2: - plci->call_dir = (plci->call_dir & ~CALL_DIR_ORIGINATE) | CALL_DIR_ANSWER; - break; - } - } - dbug(1,dprintf("call_dir=%04x", plci->call_dir)); - - - if ((GET_WORD(bp_parms[0].info) == B1_RTP) - && (plci->adapter->man_profile.private_options & (1L << PRIVATE_RTP))) - { - plci->B1_resource = add_b1_facilities (plci, 31, (word)(b1_facilities & ~B1_FACILITY_VOICE)); - adjust_b1_facilities (plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE)); - cai[1] = plci->B1_resource; - cai[2] = 0; - cai[3] = 0; - cai[4] = 0; - PUT_WORD(&cai[5],plci->appl->MaxDataLength); - for (i = 0; i < bp_parms[3].length; i++) - cai[7+i] = bp_parms[3].info[1+i]; - cai[0] = 6 + bp_parms[3].length; - add_p(plci, CAI, cai); - return 0; - } - - - if ((GET_WORD(bp_parms[0].info) == B1_PIAFS) - && (plci->adapter->man_profile.private_options & (1L << PRIVATE_PIAFS))) - { - plci->B1_resource = add_b1_facilities (plci, 35/* PIAFS HARDWARE FACILITY */, (word)(b1_facilities & ~B1_FACILITY_VOICE)); - adjust_b1_facilities (plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE)); - cai[1] = plci->B1_resource; - cai[2] = 0; - cai[3] = 0; - cai[4] = 0; - PUT_WORD(&cai[5],plci->appl->MaxDataLength); - cai[0] = 6; - add_p(plci, CAI, cai); - return 0; - } - - - if ((GET_WORD(bp_parms[0].info) >= 32) - || (!((1L << GET_WORD(bp_parms[0].info)) & plci->adapter->profile.B1_Protocols) - && ((GET_WORD(bp_parms[0].info) != 3) - || !((1L << B1_HDLC) & plci->adapter->profile.B1_Protocols) - || ((bp_parms[3].length != 0) && (GET_WORD(&bp_parms[3].info[1]) != 0) && (GET_WORD(&bp_parms[3].info[1]) != 56000))))) - { - return _B1_NOT_SUPPORTED; - } - plci->B1_resource = add_b1_facilities (plci, resource[GET_WORD(bp_parms[0].info)], - (word)(b1_facilities & ~B1_FACILITY_VOICE)); - adjust_b1_facilities (plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE)); - cai[0] = 6; - cai[1] = plci->B1_resource; - for (i=2;i", GET_WORD(mdm_cfg[0].info))); - - PUT_WORD (&cai[13], 0); /* Min Tx speed */ - PUT_WORD (&cai[15], GET_WORD(mdm_cfg[0].info)); /* Max Tx speed */ - PUT_WORD (&cai[17], 0); /* Min Rx speed */ - PUT_WORD (&cai[19], GET_WORD(mdm_cfg[0].info)); /* Max Rx speed */ - - cai[3] = 0; /* Async framing parameters */ - switch (GET_WORD (mdm_cfg[2].info)) - { /* Parity */ - case 1: /* odd parity */ - cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_ODD); - dbug(1,dprintf("MDM: odd parity")); - break; - - case 2: /* even parity */ - cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_EVEN); - dbug(1,dprintf("MDM: even parity")); - break; - - default: - dbug(1,dprintf("MDM: no parity")); - break; - } - - switch (GET_WORD (mdm_cfg[3].info)) - { /* stop bits */ - case 1: /* 2 stop bits */ - cai[3] |= DSP_CAI_ASYNC_TWO_STOP_BITS; - dbug(1,dprintf("MDM: 2 stop bits")); - break; - - default: - dbug(1,dprintf("MDM: 1 stop bit")); - break; - } - - switch (GET_WORD (mdm_cfg[1].info)) - { /* char length */ - case 5: - cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_5; - dbug(1,dprintf("MDM: 5 bits")); - break; - - case 6: - cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_6; - dbug(1,dprintf("MDM: 6 bits")); - break; - - case 7: - cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_7; - dbug(1,dprintf("MDM: 7 bits")); - break; - - default: - dbug(1,dprintf("MDM: 8 bits")); - break; - } - - cai[7] = 0; /* Line taking options */ - cai[8] = 0; /* Modulation negotiation options */ - cai[9] = 0; /* Modulation options */ - - if (((plci->call_dir & CALL_DIR_ORIGINATE) != 0) ^ ((plci->call_dir & CALL_DIR_OUT) != 0)) - { - cai[9] |= DSP_CAI_MODEM_REVERSE_DIRECTION; - dbug(1, dprintf("MDM: Reverse direction")); - } - - if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_DISABLE_RETRAIN) - { - cai[9] |= DSP_CAI_MODEM_DISABLE_RETRAIN; - dbug(1, dprintf("MDM: Disable retrain")); - } - - if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_DISABLE_RING_TONE) - { - cai[7] |= DSP_CAI_MODEM_DISABLE_CALLING_TONE | DSP_CAI_MODEM_DISABLE_ANSWER_TONE; - dbug(1, dprintf("MDM: Disable ring tone")); - } - - if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_GUARD_1800) - { - cai[8] |= DSP_CAI_MODEM_GUARD_TONE_1800HZ; - dbug(1, dprintf("MDM: 1800 guard tone")); - } - else if (GET_WORD (mdm_cfg[4].info) & MDM_CAPI_GUARD_550 ) - { - cai[8] |= DSP_CAI_MODEM_GUARD_TONE_550HZ; - dbug(1, dprintf("MDM: 550 guard tone")); - } - - if ((GET_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_V100) - { - cai[8] |= DSP_CAI_MODEM_NEGOTIATE_V100; - dbug(1, dprintf("MDM: V100")); - } - else if ((GET_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_MOD_CLASS) - { - cai[8] |= DSP_CAI_MODEM_NEGOTIATE_IN_CLASS; - dbug(1, dprintf("MDM: IN CLASS")); - } - else if ((GET_WORD (mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_DISABLED) - { - cai[8] |= DSP_CAI_MODEM_NEGOTIATE_DISABLED; - dbug(1, dprintf("MDM: DISABLED")); - } - cai[0] = 20; - - if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_V18)) - && (GET_WORD(mdm_cfg[5].info) & 0x8000)) /* Private V.18 enable */ - { - plci->requested_options |= 1L << PRIVATE_V18; - } - if (GET_WORD(mdm_cfg[5].info) & 0x4000) /* Private VOWN enable */ - plci->requested_options |= 1L << PRIVATE_VOWN; - - if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1]) - & ((1L << PRIVATE_V18) | (1L << PRIVATE_VOWN))) - { - if (!api_parse(&bp_parms[3].info[1],(word)bp_parms[3].length,"wwwwwws", mdm_cfg)) - { - i = 27; - if (mdm_cfg[6].length >= 4) - { - d = GET_DWORD(&mdm_cfg[6].info[1]); - cai[7] |= (byte) d; /* line taking options */ - cai[9] |= (byte)(d >> 8); /* modulation options */ - cai[++i] = (byte)(d >> 16); /* vown modulation options */ - cai[++i] = (byte)(d >> 24); - if (mdm_cfg[6].length >= 8) - { - d = GET_DWORD(&mdm_cfg[6].info[5]); - cai[10] |= (byte) d; /* disabled modulations mask */ - cai[11] |= (byte)(d >> 8); - if (mdm_cfg[6].length >= 12) - { - d = GET_DWORD(&mdm_cfg[6].info[9]); - cai[12] = (byte) d; /* enabled modulations mask */ - cai[++i] = (byte)(d >> 8); /* vown enabled modulations */ - cai[++i] = (byte)(d >> 16); - cai[++i] = (byte)(d >> 24); - cai[++i] = 0; - if (mdm_cfg[6].length >= 14) - { - w = GET_WORD(&mdm_cfg[6].info[13]); - if (w != 0) - PUT_WORD(&cai[13], w); /* min tx speed */ - if (mdm_cfg[6].length >= 16) - { - w = GET_WORD(&mdm_cfg[6].info[15]); - if (w != 0) - PUT_WORD(&cai[15], w); /* max tx speed */ - if (mdm_cfg[6].length >= 18) - { - w = GET_WORD(&mdm_cfg[6].info[17]); - if (w != 0) - PUT_WORD(&cai[17], w); /* min rx speed */ - if (mdm_cfg[6].length >= 20) - { - w = GET_WORD(&mdm_cfg[6].info[19]); - if (w != 0) - PUT_WORD(&cai[19], w); /* max rx speed */ - if (mdm_cfg[6].length >= 22) - { - w = GET_WORD(&mdm_cfg[6].info[21]); - cai[23] = (byte)(-((short) w)); /* transmit level */ - if (mdm_cfg[6].length >= 24) - { - w = GET_WORD(&mdm_cfg[6].info[23]); - cai[22] |= (byte) w; /* info options mask */ - cai[21] |= (byte)(w >> 8); /* disabled symbol rates */ - } - } - } - } - } - } - } - } - } - cai[27] = i - 27; - i++; - if (!api_parse(&bp_parms[3].info[1],(word)bp_parms[3].length,"wwwwwwss", mdm_cfg)) - { - if (!api_parse(&mdm_cfg[7].info[1],(word)mdm_cfg[7].length,"sss", mdm_cfg_v18)) - { - for (n = 0; n < 3; n++) - { - cai[i] = (byte)(mdm_cfg_v18[n].length); - for (j = 1; j < ((word)(cai[i] + 1)); j++) - cai[i+j] = mdm_cfg_v18[n].info[j]; - i += cai[i] + 1; - } - } - } - cai[0] = (byte)(i - 1); - } - } - - } - } - if(GET_WORD(bp_parms[0].info)==2 || /* V.110 async */ - GET_WORD(bp_parms[0].info)==3 ) /* V.110 sync */ - { - if(bp_parms[3].length){ - dbug(1,dprintf("V.110,%d",GET_WORD(&bp_parms[3].info[1]))); - switch(GET_WORD(&bp_parms[3].info[1])){ /* Rate */ - case 0: - case 56000: - if(GET_WORD(bp_parms[0].info)==3){ /* V.110 sync 56k */ - dbug(1,dprintf("56k sync HSCX")); - cai[1] = 8; - cai[2] = 0; - cai[3] = 0; - } - else if(GET_WORD(bp_parms[0].info)==2){ - dbug(1,dprintf("56k async DSP")); - cai[2] = 9; - } - break; - case 50: cai[2] = 1; break; - case 75: cai[2] = 1; break; - case 110: cai[2] = 1; break; - case 150: cai[2] = 1; break; - case 200: cai[2] = 1; break; - case 300: cai[2] = 1; break; - case 600: cai[2] = 1; break; - case 1200: cai[2] = 2; break; - case 2400: cai[2] = 3; break; - case 4800: cai[2] = 4; break; - case 7200: cai[2] = 10; break; - case 9600: cai[2] = 5; break; - case 12000: cai[2] = 13; break; - case 24000: cai[2] = 0; break; - case 14400: cai[2] = 11; break; - case 19200: cai[2] = 6; break; - case 28800: cai[2] = 12; break; - case 38400: cai[2] = 7; break; - case 48000: cai[2] = 8; break; - case 76: cai[2] = 15; break; /* 75/1200 */ - case 1201: cai[2] = 14; break; /* 1200/75 */ - case 56001: cai[2] = 9; break; /* V.110 56000 */ - - default: - return _B1_PARM_NOT_SUPPORTED; - } - cai[3] = 0; - if (cai[1] == 13) /* v.110 async */ - { - if (bp_parms[3].length >= 8) - { - switch (GET_WORD (&bp_parms[3].info[3])) - { /* char length */ - case 5: - cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_5; - break; - case 6: - cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_6; - break; - case 7: - cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_7; - break; - } - switch (GET_WORD (&bp_parms[3].info[5])) - { /* Parity */ - case 1: /* odd parity */ - cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_ODD); - break; - case 2: /* even parity */ - cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_EVEN); - break; - } - switch (GET_WORD (&bp_parms[3].info[7])) - { /* stop bits */ - case 1: /* 2 stop bits */ - cai[3] |= DSP_CAI_ASYNC_TWO_STOP_BITS; - break; - } - } - } - } - else if(cai[1]==8 || GET_WORD(bp_parms[0].info)==3 ){ - dbug(1,dprintf("V.110 default 56k sync")); - cai[1] = 8; - cai[2] = 0; - cai[3] = 0; - } - else { - dbug(1,dprintf("V.110 default 9600 async")); - cai[2] = 5; - } - } - PUT_WORD(&cai[5],plci->appl->MaxDataLength); - dbug(1,dprintf("CAI[%d]=%x,%x,%x,%x,%x,%x", cai[0], cai[1], cai[2], cai[3], cai[4], cai[5], cai[6])); + API_PARSE bp_parms[8]; + API_PARSE mdm_cfg[9]; + API_PARSE global_config[2]; + byte cai[256]; + byte resource[] = {5, 9, 13, 12, 16, 39, 9, 17, 17, 18}; + byte voice_cai[] = "\x06\x14\x00\x00\x00\x00\x08"; + word i; + + API_PARSE mdm_cfg_v18[4]; + word j, n, w; + dword d; + + + for (i = 0; i < 8; i++) bp_parms[i].length = 0; + for (i = 0; i < 2; i++) global_config[i].length = 0; + + dbug(1, dprintf("add_b1")); + api_save_msg(bp, "s", &plci->B_protocol); + + if (b_channel_info == 2) { + plci->B1_resource = 0; + adjust_b1_facilities(plci, plci->B1_resource, b1_facilities); + add_p(plci, CAI, "\x01\x00"); + dbug(1, dprintf("Cai=1,0 (no resource)")); + return 0; + } + + if (plci->tel == CODEC_PERMANENT) return 0; + else if (plci->tel == CODEC) { + plci->B1_resource = 1; + adjust_b1_facilities(plci, plci->B1_resource, b1_facilities); + add_p(plci, CAI, "\x01\x01"); + dbug(1, dprintf("Cai=1,1 (Codec)")); + return 0; + } + else if (plci->tel == ADV_VOICE) { + plci->B1_resource = add_b1_facilities(plci, 9, (word)(b1_facilities | B1_FACILITY_VOICE)); + adjust_b1_facilities(plci, plci->B1_resource, (word)(b1_facilities | B1_FACILITY_VOICE)); + voice_cai[1] = plci->B1_resource; + PUT_WORD(&voice_cai[5], plci->appl->MaxDataLength); + add_p(plci, CAI, voice_cai); + dbug(1, dprintf("Cai=1,0x%x (AdvVoice)", voice_cai[1])); + return 0; + } + plci->call_dir &= ~(CALL_DIR_ORIGINATE | CALL_DIR_ANSWER); + if (plci->call_dir & CALL_DIR_OUT) + plci->call_dir |= CALL_DIR_ORIGINATE; + else if (plci->call_dir & CALL_DIR_IN) + plci->call_dir |= CALL_DIR_ANSWER; + + if (!bp->length) { + plci->B1_resource = 0x5; + adjust_b1_facilities(plci, plci->B1_resource, b1_facilities); + add_p(plci, CAI, "\x01\x05"); + return 0; + } + + dbug(1, dprintf("b_prot_len=%d", (word)bp->length)); + if (bp->length > 256) return _WRONG_MESSAGE_FORMAT; + if (api_parse(&bp->info[1], (word)bp->length, "wwwsssb", bp_parms)) + { + bp_parms[6].length = 0; + if (api_parse(&bp->info[1], (word)bp->length, "wwwsss", bp_parms)) + { + dbug(1, dprintf("b-form.!")); + return _WRONG_MESSAGE_FORMAT; + } + } + else if (api_parse(&bp->info[1], (word)bp->length, "wwwssss", bp_parms)) + { + dbug(1, dprintf("b-form.!")); + return _WRONG_MESSAGE_FORMAT; + } + + if (bp_parms[6].length) + { + if (api_parse(&bp_parms[6].info[1], (word)bp_parms[6].length, "w", global_config)) + { + return _WRONG_MESSAGE_FORMAT; + } + switch (GET_WORD(global_config[0].info)) + { + case 1: + plci->call_dir = (plci->call_dir & ~CALL_DIR_ANSWER) | CALL_DIR_ORIGINATE; + break; + case 2: + plci->call_dir = (plci->call_dir & ~CALL_DIR_ORIGINATE) | CALL_DIR_ANSWER; + break; + } + } + dbug(1, dprintf("call_dir=%04x", plci->call_dir)); + + + if ((GET_WORD(bp_parms[0].info) == B1_RTP) + && (plci->adapter->man_profile.private_options & (1L << PRIVATE_RTP))) + { + plci->B1_resource = add_b1_facilities(plci, 31, (word)(b1_facilities & ~B1_FACILITY_VOICE)); + adjust_b1_facilities(plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE)); + cai[1] = plci->B1_resource; + cai[2] = 0; + cai[3] = 0; + cai[4] = 0; + PUT_WORD(&cai[5], plci->appl->MaxDataLength); + for (i = 0; i < bp_parms[3].length; i++) + cai[7 + i] = bp_parms[3].info[1 + i]; + cai[0] = 6 + bp_parms[3].length; + add_p(plci, CAI, cai); + return 0; + } + + + if ((GET_WORD(bp_parms[0].info) == B1_PIAFS) + && (plci->adapter->man_profile.private_options & (1L << PRIVATE_PIAFS))) + { + plci->B1_resource = add_b1_facilities(plci, 35/* PIAFS HARDWARE FACILITY */, (word)(b1_facilities & ~B1_FACILITY_VOICE)); + adjust_b1_facilities(plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE)); + cai[1] = plci->B1_resource; + cai[2] = 0; + cai[3] = 0; + cai[4] = 0; + PUT_WORD(&cai[5], plci->appl->MaxDataLength); + cai[0] = 6; + add_p(plci, CAI, cai); + return 0; + } + + + if ((GET_WORD(bp_parms[0].info) >= 32) + || (!((1L << GET_WORD(bp_parms[0].info)) & plci->adapter->profile.B1_Protocols) + && ((GET_WORD(bp_parms[0].info) != 3) + || !((1L << B1_HDLC) & plci->adapter->profile.B1_Protocols) + || ((bp_parms[3].length != 0) && (GET_WORD(&bp_parms[3].info[1]) != 0) && (GET_WORD(&bp_parms[3].info[1]) != 56000))))) + { + return _B1_NOT_SUPPORTED; + } + plci->B1_resource = add_b1_facilities(plci, resource[GET_WORD(bp_parms[0].info)], + (word)(b1_facilities & ~B1_FACILITY_VOICE)); + adjust_b1_facilities(plci, plci->B1_resource, (word)(b1_facilities & ~B1_FACILITY_VOICE)); + cai[0] = 6; + cai[1] = plci->B1_resource; + for (i = 2; i < sizeof(cai); i++) cai[i] = 0; + + if ((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE) + || (GET_WORD(bp_parms[0].info) == B1_MODEM_ASYNC) + || (GET_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC)) + { /* B1 - modem */ + for (i = 0; i < 7; i++) mdm_cfg[i].length = 0; + + if (bp_parms[3].length) + { + if (api_parse(&bp_parms[3].info[1], (word)bp_parms[3].length, "wwwwww", mdm_cfg)) + { + return (_WRONG_MESSAGE_FORMAT); + } + + cai[2] = 0; /* Bit rate for adaptation */ + + dbug(1, dprintf("MDM Max Bit Rate:<%d>", GET_WORD(mdm_cfg[0].info))); + + PUT_WORD(&cai[13], 0); /* Min Tx speed */ + PUT_WORD(&cai[15], GET_WORD(mdm_cfg[0].info)); /* Max Tx speed */ + PUT_WORD(&cai[17], 0); /* Min Rx speed */ + PUT_WORD(&cai[19], GET_WORD(mdm_cfg[0].info)); /* Max Rx speed */ + + cai[3] = 0; /* Async framing parameters */ + switch (GET_WORD(mdm_cfg[2].info)) + { /* Parity */ + case 1: /* odd parity */ + cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_ODD); + dbug(1, dprintf("MDM: odd parity")); + break; + + case 2: /* even parity */ + cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_EVEN); + dbug(1, dprintf("MDM: even parity")); + break; + + default: + dbug(1, dprintf("MDM: no parity")); + break; + } + + switch (GET_WORD(mdm_cfg[3].info)) + { /* stop bits */ + case 1: /* 2 stop bits */ + cai[3] |= DSP_CAI_ASYNC_TWO_STOP_BITS; + dbug(1, dprintf("MDM: 2 stop bits")); + break; + + default: + dbug(1, dprintf("MDM: 1 stop bit")); + break; + } + + switch (GET_WORD(mdm_cfg[1].info)) + { /* char length */ + case 5: + cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_5; + dbug(1, dprintf("MDM: 5 bits")); + break; + + case 6: + cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_6; + dbug(1, dprintf("MDM: 6 bits")); + break; + + case 7: + cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_7; + dbug(1, dprintf("MDM: 7 bits")); + break; + + default: + dbug(1, dprintf("MDM: 8 bits")); + break; + } + + cai[7] = 0; /* Line taking options */ + cai[8] = 0; /* Modulation negotiation options */ + cai[9] = 0; /* Modulation options */ + + if (((plci->call_dir & CALL_DIR_ORIGINATE) != 0) ^ ((plci->call_dir & CALL_DIR_OUT) != 0)) + { + cai[9] |= DSP_CAI_MODEM_REVERSE_DIRECTION; + dbug(1, dprintf("MDM: Reverse direction")); + } + + if (GET_WORD(mdm_cfg[4].info) & MDM_CAPI_DISABLE_RETRAIN) + { + cai[9] |= DSP_CAI_MODEM_DISABLE_RETRAIN; + dbug(1, dprintf("MDM: Disable retrain")); + } + + if (GET_WORD(mdm_cfg[4].info) & MDM_CAPI_DISABLE_RING_TONE) + { + cai[7] |= DSP_CAI_MODEM_DISABLE_CALLING_TONE | DSP_CAI_MODEM_DISABLE_ANSWER_TONE; + dbug(1, dprintf("MDM: Disable ring tone")); + } + + if (GET_WORD(mdm_cfg[4].info) & MDM_CAPI_GUARD_1800) + { + cai[8] |= DSP_CAI_MODEM_GUARD_TONE_1800HZ; + dbug(1, dprintf("MDM: 1800 guard tone")); + } + else if (GET_WORD(mdm_cfg[4].info) & MDM_CAPI_GUARD_550) + { + cai[8] |= DSP_CAI_MODEM_GUARD_TONE_550HZ; + dbug(1, dprintf("MDM: 550 guard tone")); + } + + if ((GET_WORD(mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_V100) + { + cai[8] |= DSP_CAI_MODEM_NEGOTIATE_V100; + dbug(1, dprintf("MDM: V100")); + } + else if ((GET_WORD(mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_MOD_CLASS) + { + cai[8] |= DSP_CAI_MODEM_NEGOTIATE_IN_CLASS; + dbug(1, dprintf("MDM: IN CLASS")); + } + else if ((GET_WORD(mdm_cfg[5].info) & 0x00ff) == MDM_CAPI_NEG_DISABLED) + { + cai[8] |= DSP_CAI_MODEM_NEGOTIATE_DISABLED; + dbug(1, dprintf("MDM: DISABLED")); + } + cai[0] = 20; + + if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_V18)) + && (GET_WORD(mdm_cfg[5].info) & 0x8000)) /* Private V.18 enable */ + { + plci->requested_options |= 1L << PRIVATE_V18; + } + if (GET_WORD(mdm_cfg[5].info) & 0x4000) /* Private VOWN enable */ + plci->requested_options |= 1L << PRIVATE_VOWN; + + if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id - 1]) + & ((1L << PRIVATE_V18) | (1L << PRIVATE_VOWN))) + { + if (!api_parse(&bp_parms[3].info[1], (word)bp_parms[3].length, "wwwwwws", mdm_cfg)) + { + i = 27; + if (mdm_cfg[6].length >= 4) + { + d = GET_DWORD(&mdm_cfg[6].info[1]); + cai[7] |= (byte) d; /* line taking options */ + cai[9] |= (byte)(d >> 8); /* modulation options */ + cai[++i] = (byte)(d >> 16); /* vown modulation options */ + cai[++i] = (byte)(d >> 24); + if (mdm_cfg[6].length >= 8) + { + d = GET_DWORD(&mdm_cfg[6].info[5]); + cai[10] |= (byte) d; /* disabled modulations mask */ + cai[11] |= (byte)(d >> 8); + if (mdm_cfg[6].length >= 12) + { + d = GET_DWORD(&mdm_cfg[6].info[9]); + cai[12] = (byte) d; /* enabled modulations mask */ + cai[++i] = (byte)(d >> 8); /* vown enabled modulations */ + cai[++i] = (byte)(d >> 16); + cai[++i] = (byte)(d >> 24); + cai[++i] = 0; + if (mdm_cfg[6].length >= 14) + { + w = GET_WORD(&mdm_cfg[6].info[13]); + if (w != 0) + PUT_WORD(&cai[13], w); /* min tx speed */ + if (mdm_cfg[6].length >= 16) + { + w = GET_WORD(&mdm_cfg[6].info[15]); + if (w != 0) + PUT_WORD(&cai[15], w); /* max tx speed */ + if (mdm_cfg[6].length >= 18) + { + w = GET_WORD(&mdm_cfg[6].info[17]); + if (w != 0) + PUT_WORD(&cai[17], w); /* min rx speed */ + if (mdm_cfg[6].length >= 20) + { + w = GET_WORD(&mdm_cfg[6].info[19]); + if (w != 0) + PUT_WORD(&cai[19], w); /* max rx speed */ + if (mdm_cfg[6].length >= 22) + { + w = GET_WORD(&mdm_cfg[6].info[21]); + cai[23] = (byte)(-((short) w)); /* transmit level */ + if (mdm_cfg[6].length >= 24) + { + w = GET_WORD(&mdm_cfg[6].info[23]); + cai[22] |= (byte) w; /* info options mask */ + cai[21] |= (byte)(w >> 8); /* disabled symbol rates */ + } + } + } + } + } + } + } + } + } + cai[27] = i - 27; + i++; + if (!api_parse(&bp_parms[3].info[1], (word)bp_parms[3].length, "wwwwwwss", mdm_cfg)) + { + if (!api_parse(&mdm_cfg[7].info[1], (word)mdm_cfg[7].length, "sss", mdm_cfg_v18)) + { + for (n = 0; n < 3; n++) + { + cai[i] = (byte)(mdm_cfg_v18[n].length); + for (j = 1; j < ((word)(cai[i] + 1)); j++) + cai[i + j] = mdm_cfg_v18[n].info[j]; + i += cai[i] + 1; + } + } + } + cai[0] = (byte)(i - 1); + } + } + + } + } + if (GET_WORD(bp_parms[0].info) == 2 || /* V.110 async */ + GET_WORD(bp_parms[0].info) == 3) /* V.110 sync */ + { + if (bp_parms[3].length) { + dbug(1, dprintf("V.110,%d", GET_WORD(&bp_parms[3].info[1]))); + switch (GET_WORD(&bp_parms[3].info[1])) { /* Rate */ + case 0: + case 56000: + if (GET_WORD(bp_parms[0].info) == 3) { /* V.110 sync 56k */ + dbug(1, dprintf("56k sync HSCX")); + cai[1] = 8; + cai[2] = 0; + cai[3] = 0; + } + else if (GET_WORD(bp_parms[0].info) == 2) { + dbug(1, dprintf("56k async DSP")); + cai[2] = 9; + } + break; + case 50: cai[2] = 1; break; + case 75: cai[2] = 1; break; + case 110: cai[2] = 1; break; + case 150: cai[2] = 1; break; + case 200: cai[2] = 1; break; + case 300: cai[2] = 1; break; + case 600: cai[2] = 1; break; + case 1200: cai[2] = 2; break; + case 2400: cai[2] = 3; break; + case 4800: cai[2] = 4; break; + case 7200: cai[2] = 10; break; + case 9600: cai[2] = 5; break; + case 12000: cai[2] = 13; break; + case 24000: cai[2] = 0; break; + case 14400: cai[2] = 11; break; + case 19200: cai[2] = 6; break; + case 28800: cai[2] = 12; break; + case 38400: cai[2] = 7; break; + case 48000: cai[2] = 8; break; + case 76: cai[2] = 15; break; /* 75/1200 */ + case 1201: cai[2] = 14; break; /* 1200/75 */ + case 56001: cai[2] = 9; break; /* V.110 56000 */ + + default: + return _B1_PARM_NOT_SUPPORTED; + } + cai[3] = 0; + if (cai[1] == 13) /* v.110 async */ + { + if (bp_parms[3].length >= 8) + { + switch (GET_WORD(&bp_parms[3].info[3])) + { /* char length */ + case 5: + cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_5; + break; + case 6: + cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_6; + break; + case 7: + cai[3] |= DSP_CAI_ASYNC_CHAR_LENGTH_7; + break; + } + switch (GET_WORD(&bp_parms[3].info[5])) + { /* Parity */ + case 1: /* odd parity */ + cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_ODD); + break; + case 2: /* even parity */ + cai[3] |= (DSP_CAI_ASYNC_PARITY_ENABLE | DSP_CAI_ASYNC_PARITY_EVEN); + break; + } + switch (GET_WORD(&bp_parms[3].info[7])) + { /* stop bits */ + case 1: /* 2 stop bits */ + cai[3] |= DSP_CAI_ASYNC_TWO_STOP_BITS; + break; + } + } + } + } + else if (cai[1] == 8 || GET_WORD(bp_parms[0].info) == 3) { + dbug(1, dprintf("V.110 default 56k sync")); + cai[1] = 8; + cai[2] = 0; + cai[3] = 0; + } + else { + dbug(1, dprintf("V.110 default 9600 async")); + cai[2] = 5; + } + } + PUT_WORD(&cai[5], plci->appl->MaxDataLength); + dbug(1, dprintf("CAI[%d]=%x,%x,%x,%x,%x,%x", cai[0], cai[1], cai[2], cai[3], cai[4], cai[5], cai[6])); /* HexDump ("CAI", sizeof(cai), &cai[0]); */ - add_p(plci, CAI, cai); - return 0; + add_p(plci, CAI, cai); + return 0; } /*------------------------------------------------------------------*/ @@ -7932,624 +7932,624 @@ static word add_b1(PLCI *plci, API_PARSE *bp, word b_channel_info, static word add_b23(PLCI *plci, API_PARSE *bp) { - word i, fax_control_bits; - byte pos, len; - byte SAPI = 0x40; /* default SAPI 16 for x.31 */ - API_PARSE bp_parms[8]; - API_PARSE * b1_config; - API_PARSE * b2_config; - API_PARSE b2_config_parms[8]; - API_PARSE * b3_config; - API_PARSE b3_config_parms[6]; - API_PARSE global_config[2]; - - static byte llc[3] = {2,0,0}; - static byte dlc[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - static byte nlc[256]; - static byte lli[12] = {1,1}; - - const byte llc2_out[] = {1,2,4,6,2,0,0,0, X75_V42BIS,V120_L2,V120_V42BIS,V120_L2,6}; - const byte llc2_in[] = {1,3,4,6,3,0,0,0, X75_V42BIS,V120_L2,V120_V42BIS,V120_L2,6}; - - const byte llc3[] = {4,3,2,2,6,6,0}; - const byte header[] = {0,2,3,3,0,0,0}; - - for(i=0;i<8;i++) bp_parms[i].length = 0; - for(i=0;i<6;i++) b2_config_parms[i].length = 0; - for(i=0;i<5;i++) b3_config_parms[i].length = 0; - - lli[0] = 1; - lli[1] = 1; - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL) - lli[1] |= 2; - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_OOB_CHANNEL) - lli[1] |= 4; - - if ((lli[1] & 0x02) && (diva_xdi_extended_features & DIVA_CAPI_USE_CMA)) { - lli[1] |= 0x10; - if (plci->rx_dma_descriptor <= 0) { - plci->rx_dma_descriptor=diva_get_dma_descriptor(plci,&plci->rx_dma_magic); - if (plci->rx_dma_descriptor >= 0) - plci->rx_dma_descriptor++; - } - if (plci->rx_dma_descriptor > 0) { - lli[0] = 6; - lli[1] |= 0x40; - lli[2] = (byte)(plci->rx_dma_descriptor - 1); - lli[3] = (byte)plci->rx_dma_magic; - lli[4] = (byte)(plci->rx_dma_magic >> 8); - lli[5] = (byte)(plci->rx_dma_magic >> 16); - lli[6] = (byte)(plci->rx_dma_magic >> 24); - } - } - - if (DIVA_CAPI_SUPPORTS_NO_CANCEL(plci->adapter)) { - lli[1] |= 0x20; - } - - dbug(1,dprintf("add_b23")); - api_save_msg(bp, "s", &plci->B_protocol); - - if(!bp->length && plci->tel) - { - plci->adv_nl = true; - dbug(1,dprintf("Default adv.Nl")); - add_p(plci,LLI,lli); - plci->B2_prot = 1 /*XPARENT*/; - plci->B3_prot = 0 /*XPARENT*/; - llc[1] = 2; - llc[2] = 4; - add_p(plci, LLC, llc); - dlc[0] = 2; - PUT_WORD(&dlc[1],plci->appl->MaxDataLength); - add_p(plci, DLC, dlc); - return 0; - } - - if(!bp->length) /*default*/ - { - dbug(1,dprintf("ret default")); - add_p(plci,LLI,lli); - plci->B2_prot = 0 /*X.75 */; - plci->B3_prot = 0 /*XPARENT*/; - llc[1] = 1; - llc[2] = 4; - add_p(plci, LLC, llc); - dlc[0] = 2; - PUT_WORD(&dlc[1],plci->appl->MaxDataLength); - add_p(plci, DLC, dlc); - return 0; - } - dbug(1,dprintf("b_prot_len=%d",(word)bp->length)); - if((word)bp->length > 256) return _WRONG_MESSAGE_FORMAT; - - if(api_parse(&bp->info[1], (word)bp->length, "wwwsssb", bp_parms)) - { - bp_parms[6].length = 0; - if(api_parse(&bp->info[1], (word)bp->length, "wwwsss", bp_parms)) - { - dbug(1,dprintf("b-form.!")); - return _WRONG_MESSAGE_FORMAT; - } - } - else if (api_parse(&bp->info[1], (word)bp->length, "wwwssss", bp_parms)) - { - dbug(1,dprintf("b-form.!")); - return _WRONG_MESSAGE_FORMAT; - } - - if(plci->tel==ADV_VOICE) /* transparent B on advanced voice */ - { - if(GET_WORD(bp_parms[1].info)!=1 - || GET_WORD(bp_parms[2].info)!=0) return _B2_NOT_SUPPORTED; - plci->adv_nl = true; - } - else if(plci->tel) return _B2_NOT_SUPPORTED; - - - if ((GET_WORD(bp_parms[1].info) == B2_RTP) - && (GET_WORD(bp_parms[2].info) == B3_RTP) - && (plci->adapter->man_profile.private_options & (1L << PRIVATE_RTP))) - { - add_p(plci,LLI,lli); - plci->B2_prot = (byte) GET_WORD(bp_parms[1].info); - plci->B3_prot = (byte) GET_WORD(bp_parms[2].info); - llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? 14 : 13; - llc[2] = 4; - add_p(plci, LLC, llc); - dlc[0] = 2; - PUT_WORD(&dlc[1],plci->appl->MaxDataLength); - dlc[3] = 3; /* Addr A */ - dlc[4] = 1; /* Addr B */ - dlc[5] = 7; /* modulo mode */ - dlc[6] = 7; /* window size */ - dlc[7] = 0; /* XID len Lo */ - dlc[8] = 0; /* XID len Hi */ - for (i = 0; i < bp_parms[4].length; i++) - dlc[9+i] = bp_parms[4].info[1+i]; - dlc[0] = (byte)(8 + bp_parms[4].length); - add_p(plci, DLC, dlc); - for (i = 0; i < bp_parms[5].length; i++) - nlc[1+i] = bp_parms[5].info[1+i]; - nlc[0] = (byte)(bp_parms[5].length); - add_p(plci, NLC, nlc); - return 0; - } - - - - if ((GET_WORD(bp_parms[1].info) >= 32) - || (!((1L << GET_WORD(bp_parms[1].info)) & plci->adapter->profile.B2_Protocols) - && ((GET_WORD(bp_parms[1].info) != B2_PIAFS) - || !(plci->adapter->man_profile.private_options & (1L << PRIVATE_PIAFS))))) - - { - return _B2_NOT_SUPPORTED; - } - if ((GET_WORD(bp_parms[2].info) >= 32) - || !((1L << GET_WORD(bp_parms[2].info)) & plci->adapter->profile.B3_Protocols)) - { - return _B3_NOT_SUPPORTED; - } - if ((GET_WORD(bp_parms[1].info) != B2_SDLC) - && ((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE) - || (GET_WORD(bp_parms[0].info) == B1_MODEM_ASYNC) - || (GET_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC))) - { - return (add_modem_b23 (plci, bp_parms)); - } - - add_p(plci,LLI,lli); - - plci->B2_prot = (byte) GET_WORD(bp_parms[1].info); - plci->B3_prot = (byte) GET_WORD(bp_parms[2].info); - if(plci->B2_prot==12) SAPI = 0; /* default SAPI D-channel */ - - if(bp_parms[6].length) - { - if(api_parse(&bp_parms[6].info[1], (word)bp_parms[6].length, "w", global_config)) - { - return _WRONG_MESSAGE_FORMAT; - } - switch(GET_WORD(global_config[0].info)) - { - case 1: - plci->call_dir = (plci->call_dir & ~CALL_DIR_ANSWER) | CALL_DIR_ORIGINATE; - break; - case 2: - plci->call_dir = (plci->call_dir & ~CALL_DIR_ORIGINATE) | CALL_DIR_ANSWER; - break; - } - } - dbug(1,dprintf("call_dir=%04x", plci->call_dir)); - - - if (plci->B2_prot == B2_PIAFS) - llc[1] = PIAFS_CRC; - else + word i, fax_control_bits; + byte pos, len; + byte SAPI = 0x40; /* default SAPI 16 for x.31 */ + API_PARSE bp_parms[8]; + API_PARSE *b1_config; + API_PARSE *b2_config; + API_PARSE b2_config_parms[8]; + API_PARSE *b3_config; + API_PARSE b3_config_parms[6]; + API_PARSE global_config[2]; + + static byte llc[3] = {2,0,0}; + static byte dlc[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + static byte nlc[256]; + static byte lli[12] = {1,1}; + + const byte llc2_out[] = {1,2,4,6,2,0,0,0, X75_V42BIS,V120_L2,V120_V42BIS,V120_L2,6}; + const byte llc2_in[] = {1,3,4,6,3,0,0,0, X75_V42BIS,V120_L2,V120_V42BIS,V120_L2,6}; + + const byte llc3[] = {4,3,2,2,6,6,0}; + const byte header[] = {0,2,3,3,0,0,0}; + + for (i = 0; i < 8; i++) bp_parms[i].length = 0; + for (i = 0; i < 6; i++) b2_config_parms[i].length = 0; + for (i = 0; i < 5; i++) b3_config_parms[i].length = 0; + + lli[0] = 1; + lli[1] = 1; + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL) + lli[1] |= 2; + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_OOB_CHANNEL) + lli[1] |= 4; + + if ((lli[1] & 0x02) && (diva_xdi_extended_features & DIVA_CAPI_USE_CMA)) { + lli[1] |= 0x10; + if (plci->rx_dma_descriptor <= 0) { + plci->rx_dma_descriptor = diva_get_dma_descriptor(plci, &plci->rx_dma_magic); + if (plci->rx_dma_descriptor >= 0) + plci->rx_dma_descriptor++; + } + if (plci->rx_dma_descriptor > 0) { + lli[0] = 6; + lli[1] |= 0x40; + lli[2] = (byte)(plci->rx_dma_descriptor - 1); + lli[3] = (byte)plci->rx_dma_magic; + lli[4] = (byte)(plci->rx_dma_magic >> 8); + lli[5] = (byte)(plci->rx_dma_magic >> 16); + lli[6] = (byte)(plci->rx_dma_magic >> 24); + } + } + + if (DIVA_CAPI_SUPPORTS_NO_CANCEL(plci->adapter)) { + lli[1] |= 0x20; + } + + dbug(1, dprintf("add_b23")); + api_save_msg(bp, "s", &plci->B_protocol); + + if (!bp->length && plci->tel) + { + plci->adv_nl = true; + dbug(1, dprintf("Default adv.Nl")); + add_p(plci, LLI, lli); + plci->B2_prot = 1 /*XPARENT*/; + plci->B3_prot = 0 /*XPARENT*/; + llc[1] = 2; + llc[2] = 4; + add_p(plci, LLC, llc); + dlc[0] = 2; + PUT_WORD(&dlc[1], plci->appl->MaxDataLength); + add_p(plci, DLC, dlc); + return 0; + } + + if (!bp->length) /*default*/ + { + dbug(1, dprintf("ret default")); + add_p(plci, LLI, lli); + plci->B2_prot = 0 /*X.75 */; + plci->B3_prot = 0 /*XPARENT*/; + llc[1] = 1; + llc[2] = 4; + add_p(plci, LLC, llc); + dlc[0] = 2; + PUT_WORD(&dlc[1], plci->appl->MaxDataLength); + add_p(plci, DLC, dlc); + return 0; + } + dbug(1, dprintf("b_prot_len=%d", (word)bp->length)); + if ((word)bp->length > 256) return _WRONG_MESSAGE_FORMAT; + + if (api_parse(&bp->info[1], (word)bp->length, "wwwsssb", bp_parms)) + { + bp_parms[6].length = 0; + if (api_parse(&bp->info[1], (word)bp->length, "wwwsss", bp_parms)) + { + dbug(1, dprintf("b-form.!")); + return _WRONG_MESSAGE_FORMAT; + } + } + else if (api_parse(&bp->info[1], (word)bp->length, "wwwssss", bp_parms)) + { + dbug(1, dprintf("b-form.!")); + return _WRONG_MESSAGE_FORMAT; + } + + if (plci->tel == ADV_VOICE) /* transparent B on advanced voice */ + { + if (GET_WORD(bp_parms[1].info) != 1 + || GET_WORD(bp_parms[2].info) != 0) return _B2_NOT_SUPPORTED; + plci->adv_nl = true; + } + else if (plci->tel) return _B2_NOT_SUPPORTED; + + + if ((GET_WORD(bp_parms[1].info) == B2_RTP) + && (GET_WORD(bp_parms[2].info) == B3_RTP) + && (plci->adapter->man_profile.private_options & (1L << PRIVATE_RTP))) + { + add_p(plci, LLI, lli); + plci->B2_prot = (byte) GET_WORD(bp_parms[1].info); + plci->B3_prot = (byte) GET_WORD(bp_parms[2].info); + llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? 14 : 13; + llc[2] = 4; + add_p(plci, LLC, llc); + dlc[0] = 2; + PUT_WORD(&dlc[1], plci->appl->MaxDataLength); + dlc[3] = 3; /* Addr A */ + dlc[4] = 1; /* Addr B */ + dlc[5] = 7; /* modulo mode */ + dlc[6] = 7; /* window size */ + dlc[7] = 0; /* XID len Lo */ + dlc[8] = 0; /* XID len Hi */ + for (i = 0; i < bp_parms[4].length; i++) + dlc[9 + i] = bp_parms[4].info[1 + i]; + dlc[0] = (byte)(8 + bp_parms[4].length); + add_p(plci, DLC, dlc); + for (i = 0; i < bp_parms[5].length; i++) + nlc[1 + i] = bp_parms[5].info[1 + i]; + nlc[0] = (byte)(bp_parms[5].length); + add_p(plci, NLC, nlc); + return 0; + } + + + + if ((GET_WORD(bp_parms[1].info) >= 32) + || (!((1L << GET_WORD(bp_parms[1].info)) & plci->adapter->profile.B2_Protocols) + && ((GET_WORD(bp_parms[1].info) != B2_PIAFS) + || !(plci->adapter->man_profile.private_options & (1L << PRIVATE_PIAFS))))) + + { + return _B2_NOT_SUPPORTED; + } + if ((GET_WORD(bp_parms[2].info) >= 32) + || !((1L << GET_WORD(bp_parms[2].info)) & plci->adapter->profile.B3_Protocols)) + { + return _B3_NOT_SUPPORTED; + } + if ((GET_WORD(bp_parms[1].info) != B2_SDLC) + && ((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE) + || (GET_WORD(bp_parms[0].info) == B1_MODEM_ASYNC) + || (GET_WORD(bp_parms[0].info) == B1_MODEM_SYNC_HDLC))) + { + return (add_modem_b23(plci, bp_parms)); + } + + add_p(plci, LLI, lli); + + plci->B2_prot = (byte)GET_WORD(bp_parms[1].info); + plci->B3_prot = (byte)GET_WORD(bp_parms[2].info); + if (plci->B2_prot == 12) SAPI = 0; /* default SAPI D-channel */ + + if (bp_parms[6].length) + { + if (api_parse(&bp_parms[6].info[1], (word)bp_parms[6].length, "w", global_config)) + { + return _WRONG_MESSAGE_FORMAT; + } + switch (GET_WORD(global_config[0].info)) + { + case 1: + plci->call_dir = (plci->call_dir & ~CALL_DIR_ANSWER) | CALL_DIR_ORIGINATE; + break; + case 2: + plci->call_dir = (plci->call_dir & ~CALL_DIR_ORIGINATE) | CALL_DIR_ANSWER; + break; + } + } + dbug(1, dprintf("call_dir=%04x", plci->call_dir)); + + + if (plci->B2_prot == B2_PIAFS) + llc[1] = PIAFS_CRC; + else /* IMPLEMENT_PIAFS */ - { - llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? - llc2_out[GET_WORD(bp_parms[1].info)] : llc2_in[GET_WORD(bp_parms[1].info)]; - } - llc[2] = llc3[GET_WORD(bp_parms[2].info)]; - - add_p(plci, LLC, llc); - - dlc[0] = 2; - PUT_WORD(&dlc[1], plci->appl->MaxDataLength + - header[GET_WORD(bp_parms[2].info)]); - - b1_config = &bp_parms[3]; - nlc[0] = 0; - if(plci->B3_prot == 4 - || plci->B3_prot == 5) - { - for (i=0;iadapter->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) - ((T30_INFO *)&nlc[1])->operating_mode = T30_OPERATING_MODE_CAPI; - ((T30_INFO *)&nlc[1])->rate_div_2400 = 0xff; - if(b1_config->length>=2) - { - ((T30_INFO *)&nlc[1])->rate_div_2400 = (byte)(GET_WORD(&b1_config->info[1])/2400); - } - } - b2_config = &bp_parms[4]; - - - if (llc[1] == PIAFS_CRC) - { - if (plci->B3_prot != B3_TRANSPARENT) - { - return _B_STACK_NOT_SUPPORTED; - } - if(b2_config->length && api_parse(&b2_config->info[1], (word)b2_config->length, "bwww", b2_config_parms)) { - return _WRONG_MESSAGE_FORMAT; - } - PUT_WORD(&dlc[1],plci->appl->MaxDataLength); - dlc[3] = 0; /* Addr A */ - dlc[4] = 0; /* Addr B */ - dlc[5] = 0; /* modulo mode */ - dlc[6] = 0; /* window size */ - if (b2_config->length >= 7){ - dlc[ 7] = 7; - dlc[ 8] = 0; - dlc[ 9] = b2_config_parms[0].info[0]; /* PIAFS protocol Speed configuration */ - dlc[10] = b2_config_parms[1].info[0]; /* V.42bis P0 */ - dlc[11] = b2_config_parms[1].info[1]; /* V.42bis P0 */ - dlc[12] = b2_config_parms[2].info[0]; /* V.42bis P1 */ - dlc[13] = b2_config_parms[2].info[1]; /* V.42bis P1 */ - dlc[14] = b2_config_parms[3].info[0]; /* V.42bis P2 */ - dlc[15] = b2_config_parms[3].info[1]; /* V.42bis P2 */ - dlc[ 0] = 15; - if(b2_config->length >= 8) { /* PIAFS control abilities */ - dlc[ 7] = 10; - dlc[16] = 2; /* Length of PIAFS extension */ - dlc[17] = PIAFS_UDATA_ABILITIES; /* control (UDATA) ability */ - dlc[18] = b2_config_parms[4].info[0]; /* value */ - dlc[ 0] = 18; - } - } - else /* default values, 64K, variable, no compression */ - { - dlc[ 7] = 7; - dlc[ 8] = 0; - dlc[ 9] = 0x03; /* PIAFS protocol Speed configuration */ - dlc[10] = 0x03; /* V.42bis P0 */ - dlc[11] = 0; /* V.42bis P0 */ - dlc[12] = 0; /* V.42bis P1 */ - dlc[13] = 0; /* V.42bis P1 */ - dlc[14] = 0; /* V.42bis P2 */ - dlc[15] = 0; /* V.42bis P2 */ - dlc[ 0] = 15; - } - add_p(plci, DLC, dlc); - } - else - - if ((llc[1] == V120_L2) || (llc[1] == V120_V42BIS)) - { - if (plci->B3_prot != B3_TRANSPARENT) - return _B_STACK_NOT_SUPPORTED; - - dlc[0] = 6; - PUT_WORD (&dlc[1], GET_WORD (&dlc[1]) + 2); - dlc[3] = 0x08; - dlc[4] = 0x01; - dlc[5] = 127; - dlc[6] = 7; - if (b2_config->length != 0) - { - if((llc[1]==V120_V42BIS) && api_parse(&b2_config->info[1], (word)b2_config->length, "bbbbwww", b2_config_parms)) { - return _WRONG_MESSAGE_FORMAT; - } - dlc[3] = (byte)((b2_config->info[2] << 3) | ((b2_config->info[1] >> 5) & 0x04)); - dlc[4] = (byte)((b2_config->info[1] << 1) | 0x01); - if (b2_config->info[3] != 128) - { - dbug(1,dprintf("1D-dlc= %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4])); - return _B2_PARM_NOT_SUPPORTED; - } - dlc[5] = (byte)(b2_config->info[3] - 1); - dlc[6] = b2_config->info[4]; - if(llc[1]==V120_V42BIS){ - if (b2_config->length >= 10){ - dlc[ 7] = 6; - dlc[ 8] = 0; - dlc[ 9] = b2_config_parms[4].info[0]; - dlc[10] = b2_config_parms[4].info[1]; - dlc[11] = b2_config_parms[5].info[0]; - dlc[12] = b2_config_parms[5].info[1]; - dlc[13] = b2_config_parms[6].info[0]; - dlc[14] = b2_config_parms[6].info[1]; - dlc[ 0] = 14; - dbug(1,dprintf("b2_config_parms[4].info[0] [1]: %x %x", b2_config_parms[4].info[0], b2_config_parms[4].info[1])); - dbug(1,dprintf("b2_config_parms[5].info[0] [1]: %x %x", b2_config_parms[5].info[0], b2_config_parms[5].info[1])); - dbug(1,dprintf("b2_config_parms[6].info[0] [1]: %x %x", b2_config_parms[6].info[0], b2_config_parms[6].info[1])); - } - else { - dlc[ 6] = 14; - } - } - } - } - else - { - if(b2_config->length) - { - dbug(1,dprintf("B2-Config")); - if(llc[1]==X75_V42BIS){ - if(api_parse(&b2_config->info[1], (word)b2_config->length, "bbbbwww", b2_config_parms)) - { - return _WRONG_MESSAGE_FORMAT; - } - } - else { - if(api_parse(&b2_config->info[1], (word)b2_config->length, "bbbbs", b2_config_parms)) - { - return _WRONG_MESSAGE_FORMAT; - } - } - /* if B2 Protocol is LAPD, b2_config structure is different */ - if(llc[1]==6) - { - dlc[0] = 4; - if(b2_config->length>=1) dlc[2] = b2_config->info[1]; /* TEI */ - else dlc[2] = 0x01; - if( (b2_config->length>=2) && (plci->B2_prot==12) ) - { - SAPI = b2_config->info[2]; /* SAPI */ - } - dlc[1] = SAPI; - if( (b2_config->length>=3) && (b2_config->info[3]==128) ) - { - dlc[3] = 127; /* Mode */ - } - else - { - dlc[3] = 7; /* Mode */ - } - - if(b2_config->length>=4) dlc[4] = b2_config->info[4]; /* Window */ - else dlc[4] = 1; - dbug(1,dprintf("D-dlc[%d]=%x,%x,%x,%x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4])); - if(b2_config->length>5) return _B2_PARM_NOT_SUPPORTED; - } - else - { - dlc[0] = (byte)(b2_config_parms[4].length+6); - dlc[3] = b2_config->info[1]; - dlc[4] = b2_config->info[2]; - if(b2_config->info[3]!=8 && b2_config->info[3]!=128){ - dbug(1,dprintf("1D-dlc= %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4])); - return _B2_PARM_NOT_SUPPORTED; - } - - dlc[5] = (byte)(b2_config->info[3]-1); - dlc[6] = b2_config->info[4]; - if(dlc[6]>dlc[5]){ - dbug(1,dprintf("2D-dlc= %x %x %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4], dlc[5], dlc[6])); - return _B2_PARM_NOT_SUPPORTED; - } - - if(llc[1]==X75_V42BIS) { - if (b2_config->length >= 10){ - dlc[ 7] = 6; - dlc[ 8] = 0; - dlc[ 9] = b2_config_parms[4].info[0]; - dlc[10] = b2_config_parms[4].info[1]; - dlc[11] = b2_config_parms[5].info[0]; - dlc[12] = b2_config_parms[5].info[1]; - dlc[13] = b2_config_parms[6].info[0]; - dlc[14] = b2_config_parms[6].info[1]; - dlc[ 0] = 14; - dbug(1,dprintf("b2_config_parms[4].info[0] [1]: %x %x", b2_config_parms[4].info[0], b2_config_parms[4].info[1])); - dbug(1,dprintf("b2_config_parms[5].info[0] [1]: %x %x", b2_config_parms[5].info[0], b2_config_parms[5].info[1])); - dbug(1,dprintf("b2_config_parms[6].info[0] [1]: %x %x", b2_config_parms[6].info[0], b2_config_parms[6].info[1])); - } - else { - dlc[ 6] = 14; - } - - } - else { - PUT_WORD(&dlc[7], (word)b2_config_parms[4].length); - for(i=0; ilength) - { - if(plci->B3_prot == 4 - || plci->B3_prot == 5) - { - if(api_parse(&b3_config->info[1], (word)b3_config->length, "wwss", b3_config_parms)) - { - return _WRONG_MESSAGE_FORMAT; - } - i = GET_WORD((byte *)(b3_config_parms[0].info)); - ((T30_INFO *)&nlc[1])->resolution = (byte)(((i & 0x0001) || - ((plci->B3_prot == 4) && (((byte)(GET_WORD((byte *)b3_config_parms[1].info))) != 5))) ? T30_RESOLUTION_R8_0770_OR_200 : 0); - ((T30_INFO *)&nlc[1])->data_format = (byte)(GET_WORD((byte *)b3_config_parms[1].info)); - fax_control_bits = T30_CONTROL_BIT_ALL_FEATURES; - if ((((T30_INFO *)&nlc[1])->rate_div_2400 != 0) && (((T30_INFO *)&nlc[1])->rate_div_2400 <= 6)) - fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_V34FAX; - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) - { - - if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1]) - & (1L << PRIVATE_FAX_PAPER_FORMATS)) - { - ((T30_INFO *)&nlc[1])->resolution |= T30_RESOLUTION_R8_1540 | - T30_RESOLUTION_R16_1540_OR_400 | T30_RESOLUTION_300_300 | - T30_RESOLUTION_INCH_BASED | T30_RESOLUTION_METRIC_BASED; - } - - ((T30_INFO *)&nlc[1])->recording_properties = - T30_RECORDING_WIDTH_ISO_A3 | - (T30_RECORDING_LENGTH_UNLIMITED << 2) | - (T30_MIN_SCANLINE_TIME_00_00_00 << 4); - } - if(plci->B3_prot == 5) - { - if (i & 0x0002) /* Accept incoming fax-polling requests */ - fax_control_bits |= T30_CONTROL_BIT_ACCEPT_POLLING; - if (i & 0x2000) /* Do not use MR compression */ - fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_2D_CODING; - if (i & 0x4000) /* Do not use MMR compression */ - fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_T6_CODING; - if (i & 0x8000) /* Do not use ECM */ - fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_ECM; - if (plci->fax_connect_info_length != 0) - { - ((T30_INFO *)&nlc[1])->resolution = ((T30_INFO *)plci->fax_connect_info_buffer)->resolution; - ((T30_INFO *)&nlc[1])->data_format = ((T30_INFO *)plci->fax_connect_info_buffer)->data_format; - ((T30_INFO *)&nlc[1])->recording_properties = ((T30_INFO *)plci->fax_connect_info_buffer)->recording_properties; - fax_control_bits |= GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low) & - (T30_CONTROL_BIT_REQUEST_POLLING | T30_CONTROL_BIT_MORE_DOCUMENTS); - } - } - /* copy station id to NLC */ - for(i=0; i < T30_MAX_STATION_ID_LENGTH; i++) - { - if(istation_id[i] = ((byte *)b3_config_parms[2].info)[1+i]; - } - else - { - ((T30_INFO *)&nlc[1])->station_id[i] = ' '; - } - } - ((T30_INFO *)&nlc[1])->station_id_len = T30_MAX_STATION_ID_LENGTH; - /* copy head line to NLC */ - if(b3_config_parms[3].length) - { - - pos = (byte)(fax_head_line_time (&(((T30_INFO *)&nlc[1])->station_id[T30_MAX_STATION_ID_LENGTH]))); - if (pos != 0) - { - if (CAPI_MAX_DATE_TIME_LENGTH + 2 + b3_config_parms[3].length > CAPI_MAX_HEAD_LINE_SPACE) - pos = 0; - else - { - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; - len = (byte)b3_config_parms[2].length; - if (len > 20) - len = 20; - if (CAPI_MAX_DATE_TIME_LENGTH + 2 + len + 2 + b3_config_parms[3].length <= CAPI_MAX_HEAD_LINE_SPACE) - { - for (i = 0; i < len; i++) - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((byte *)b3_config_parms[2].info)[1+i]; - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; - } - } - } - - len = (byte)b3_config_parms[3].length; - if (len > CAPI_MAX_HEAD_LINE_SPACE - pos) - len = (byte)(CAPI_MAX_HEAD_LINE_SPACE - pos); - ((T30_INFO *)&nlc[1])->head_line_len = (byte)(pos + len); - nlc[0] += (byte)(pos + len); - for (i = 0; i < len; i++) - nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((byte *)b3_config_parms[3].info)[1+i]; - } else - ((T30_INFO *)&nlc[1])->head_line_len = 0; - - plci->nsf_control_bits = 0; - if(plci->B3_prot == 5) - { - if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_FAX_SUB_SEP_PWD)) - && (GET_WORD((byte *)b3_config_parms[1].info) & 0x8000)) /* Private SUB/SEP/PWD enable */ - { - plci->requested_options |= 1L << PRIVATE_FAX_SUB_SEP_PWD; - } - if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_FAX_NONSTANDARD)) - && (GET_WORD((byte *)b3_config_parms[1].info) & 0x4000)) /* Private non-standard facilities enable */ - { - plci->requested_options |= 1L << PRIVATE_FAX_NONSTANDARD; - } - if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1]) - & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) - { - if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1]) - & (1L << PRIVATE_FAX_SUB_SEP_PWD)) - { - fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SUBADDRESS | T30_CONTROL_BIT_ACCEPT_PASSWORD; - if (fax_control_bits & T30_CONTROL_BIT_ACCEPT_POLLING) - fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; - } - len = nlc[0]; - pos = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; - if (pos < plci->fax_connect_info_length) - { - for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) - nlc[++len] = plci->fax_connect_info_buffer[pos++]; - } - else - nlc[++len] = 0; - if (pos < plci->fax_connect_info_length) - { - for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) - nlc[++len] = plci->fax_connect_info_buffer[pos++]; - } - else - nlc[++len] = 0; - if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id-1]) - & (1L << PRIVATE_FAX_NONSTANDARD)) - { - if ((pos < plci->fax_connect_info_length) && (plci->fax_connect_info_buffer[pos] != 0)) - { - if ((plci->fax_connect_info_buffer[pos] >= 3) && (plci->fax_connect_info_buffer[pos+1] >= 2)) - plci->nsf_control_bits = GET_WORD(&plci->fax_connect_info_buffer[pos+2]); - for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) - nlc[++len] = plci->fax_connect_info_buffer[pos++]; - } - else - { - if(api_parse(&b3_config->info[1], (word)b3_config->length, "wwsss", b3_config_parms)) - { - dbug(1,dprintf("non-standard facilities info missing or wrong format")); - nlc[++len] = 0; - } - else - { - if ((b3_config_parms[4].length >= 3) && (b3_config_parms[4].info[1] >= 2)) - plci->nsf_control_bits = GET_WORD(&b3_config_parms[4].info[2]); - nlc[++len] = (byte)(b3_config_parms[4].length); - for (i = 0; i < b3_config_parms[4].length; i++) - nlc[++len] = b3_config_parms[4].info[1+i]; - } - } - } - nlc[0] = len; - if ((plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) - && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) - { - ((T30_INFO *)&nlc[1])->operating_mode = T30_OPERATING_MODE_CAPI_NEG; - } - } - } - - PUT_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits); - len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; - for (i = 0; i < len; i++) - plci->fax_connect_info_buffer[i] = nlc[1+i]; - ((T30_INFO *) plci->fax_connect_info_buffer)->head_line_len = 0; - i += ((T30_INFO *)&nlc[1])->head_line_len; - while (i < nlc[0]) - plci->fax_connect_info_buffer[len++] = nlc[++i]; - plci->fax_connect_info_length = len; - } - else - { - nlc[0] = 14; - if(b3_config->length!=16) - return _B3_PARM_NOT_SUPPORTED; - for(i=0; i<12; i++) nlc[1+i] = b3_config->info[1+i]; - if(GET_WORD(&b3_config->info[13])!=8 && GET_WORD(&b3_config->info[13])!=128) - return _B3_PARM_NOT_SUPPORTED; - nlc[13] = b3_config->info[13]; - if(GET_WORD(&b3_config->info[15])>=nlc[13]) - return _B3_PARM_NOT_SUPPORTED; - nlc[14] = b3_config->info[15]; - } - } - else - { - if (plci->B3_prot == 4 - || plci->B3_prot == 5 /*T.30 - FAX*/ ) return _B3_PARM_NOT_SUPPORTED; - } - add_p(plci, NLC, nlc); - return 0; + { + llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? + llc2_out[GET_WORD(bp_parms[1].info)] : llc2_in[GET_WORD(bp_parms[1].info)]; + } + llc[2] = llc3[GET_WORD(bp_parms[2].info)]; + + add_p(plci, LLC, llc); + + dlc[0] = 2; + PUT_WORD(&dlc[1], plci->appl->MaxDataLength + + header[GET_WORD(bp_parms[2].info)]); + + b1_config = &bp_parms[3]; + nlc[0] = 0; + if (plci->B3_prot == 4 + || plci->B3_prot == 5) + { + for (i = 0; i < sizeof(T30_INFO); i++) nlc[i] = 0; + nlc[0] = sizeof(T30_INFO); + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) + ((T30_INFO *)&nlc[1])->operating_mode = T30_OPERATING_MODE_CAPI; + ((T30_INFO *)&nlc[1])->rate_div_2400 = 0xff; + if (b1_config->length >= 2) + { + ((T30_INFO *)&nlc[1])->rate_div_2400 = (byte)(GET_WORD(&b1_config->info[1]) / 2400); + } + } + b2_config = &bp_parms[4]; + + + if (llc[1] == PIAFS_CRC) + { + if (plci->B3_prot != B3_TRANSPARENT) + { + return _B_STACK_NOT_SUPPORTED; + } + if (b2_config->length && api_parse(&b2_config->info[1], (word)b2_config->length, "bwww", b2_config_parms)) { + return _WRONG_MESSAGE_FORMAT; + } + PUT_WORD(&dlc[1], plci->appl->MaxDataLength); + dlc[3] = 0; /* Addr A */ + dlc[4] = 0; /* Addr B */ + dlc[5] = 0; /* modulo mode */ + dlc[6] = 0; /* window size */ + if (b2_config->length >= 7) { + dlc[7] = 7; + dlc[8] = 0; + dlc[9] = b2_config_parms[0].info[0]; /* PIAFS protocol Speed configuration */ + dlc[10] = b2_config_parms[1].info[0]; /* V.42bis P0 */ + dlc[11] = b2_config_parms[1].info[1]; /* V.42bis P0 */ + dlc[12] = b2_config_parms[2].info[0]; /* V.42bis P1 */ + dlc[13] = b2_config_parms[2].info[1]; /* V.42bis P1 */ + dlc[14] = b2_config_parms[3].info[0]; /* V.42bis P2 */ + dlc[15] = b2_config_parms[3].info[1]; /* V.42bis P2 */ + dlc[0] = 15; + if (b2_config->length >= 8) { /* PIAFS control abilities */ + dlc[7] = 10; + dlc[16] = 2; /* Length of PIAFS extension */ + dlc[17] = PIAFS_UDATA_ABILITIES; /* control (UDATA) ability */ + dlc[18] = b2_config_parms[4].info[0]; /* value */ + dlc[0] = 18; + } + } + else /* default values, 64K, variable, no compression */ + { + dlc[7] = 7; + dlc[8] = 0; + dlc[9] = 0x03; /* PIAFS protocol Speed configuration */ + dlc[10] = 0x03; /* V.42bis P0 */ + dlc[11] = 0; /* V.42bis P0 */ + dlc[12] = 0; /* V.42bis P1 */ + dlc[13] = 0; /* V.42bis P1 */ + dlc[14] = 0; /* V.42bis P2 */ + dlc[15] = 0; /* V.42bis P2 */ + dlc[0] = 15; + } + add_p(plci, DLC, dlc); + } + else + + if ((llc[1] == V120_L2) || (llc[1] == V120_V42BIS)) + { + if (plci->B3_prot != B3_TRANSPARENT) + return _B_STACK_NOT_SUPPORTED; + + dlc[0] = 6; + PUT_WORD(&dlc[1], GET_WORD(&dlc[1]) + 2); + dlc[3] = 0x08; + dlc[4] = 0x01; + dlc[5] = 127; + dlc[6] = 7; + if (b2_config->length != 0) + { + if ((llc[1] == V120_V42BIS) && api_parse(&b2_config->info[1], (word)b2_config->length, "bbbbwww", b2_config_parms)) { + return _WRONG_MESSAGE_FORMAT; + } + dlc[3] = (byte)((b2_config->info[2] << 3) | ((b2_config->info[1] >> 5) & 0x04)); + dlc[4] = (byte)((b2_config->info[1] << 1) | 0x01); + if (b2_config->info[3] != 128) + { + dbug(1, dprintf("1D-dlc= %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4])); + return _B2_PARM_NOT_SUPPORTED; + } + dlc[5] = (byte)(b2_config->info[3] - 1); + dlc[6] = b2_config->info[4]; + if (llc[1] == V120_V42BIS) { + if (b2_config->length >= 10) { + dlc[7] = 6; + dlc[8] = 0; + dlc[9] = b2_config_parms[4].info[0]; + dlc[10] = b2_config_parms[4].info[1]; + dlc[11] = b2_config_parms[5].info[0]; + dlc[12] = b2_config_parms[5].info[1]; + dlc[13] = b2_config_parms[6].info[0]; + dlc[14] = b2_config_parms[6].info[1]; + dlc[0] = 14; + dbug(1, dprintf("b2_config_parms[4].info[0] [1]: %x %x", b2_config_parms[4].info[0], b2_config_parms[4].info[1])); + dbug(1, dprintf("b2_config_parms[5].info[0] [1]: %x %x", b2_config_parms[5].info[0], b2_config_parms[5].info[1])); + dbug(1, dprintf("b2_config_parms[6].info[0] [1]: %x %x", b2_config_parms[6].info[0], b2_config_parms[6].info[1])); + } + else { + dlc[6] = 14; + } + } + } + } + else + { + if (b2_config->length) + { + dbug(1, dprintf("B2-Config")); + if (llc[1] == X75_V42BIS) { + if (api_parse(&b2_config->info[1], (word)b2_config->length, "bbbbwww", b2_config_parms)) + { + return _WRONG_MESSAGE_FORMAT; + } + } + else { + if (api_parse(&b2_config->info[1], (word)b2_config->length, "bbbbs", b2_config_parms)) + { + return _WRONG_MESSAGE_FORMAT; + } + } + /* if B2 Protocol is LAPD, b2_config structure is different */ + if (llc[1] == 6) + { + dlc[0] = 4; + if (b2_config->length >= 1) dlc[2] = b2_config->info[1]; /* TEI */ + else dlc[2] = 0x01; + if ((b2_config->length >= 2) && (plci->B2_prot == 12)) + { + SAPI = b2_config->info[2]; /* SAPI */ + } + dlc[1] = SAPI; + if ((b2_config->length >= 3) && (b2_config->info[3] == 128)) + { + dlc[3] = 127; /* Mode */ + } + else + { + dlc[3] = 7; /* Mode */ + } + + if (b2_config->length >= 4) dlc[4] = b2_config->info[4]; /* Window */ + else dlc[4] = 1; + dbug(1, dprintf("D-dlc[%d]=%x,%x,%x,%x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4])); + if (b2_config->length > 5) return _B2_PARM_NOT_SUPPORTED; + } + else + { + dlc[0] = (byte)(b2_config_parms[4].length + 6); + dlc[3] = b2_config->info[1]; + dlc[4] = b2_config->info[2]; + if (b2_config->info[3] != 8 && b2_config->info[3] != 128) { + dbug(1, dprintf("1D-dlc= %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4])); + return _B2_PARM_NOT_SUPPORTED; + } + + dlc[5] = (byte)(b2_config->info[3] - 1); + dlc[6] = b2_config->info[4]; + if (dlc[6] > dlc[5]) { + dbug(1, dprintf("2D-dlc= %x %x %x %x %x %x %x", dlc[0], dlc[1], dlc[2], dlc[3], dlc[4], dlc[5], dlc[6])); + return _B2_PARM_NOT_SUPPORTED; + } + + if (llc[1] == X75_V42BIS) { + if (b2_config->length >= 10) { + dlc[7] = 6; + dlc[8] = 0; + dlc[9] = b2_config_parms[4].info[0]; + dlc[10] = b2_config_parms[4].info[1]; + dlc[11] = b2_config_parms[5].info[0]; + dlc[12] = b2_config_parms[5].info[1]; + dlc[13] = b2_config_parms[6].info[0]; + dlc[14] = b2_config_parms[6].info[1]; + dlc[0] = 14; + dbug(1, dprintf("b2_config_parms[4].info[0] [1]: %x %x", b2_config_parms[4].info[0], b2_config_parms[4].info[1])); + dbug(1, dprintf("b2_config_parms[5].info[0] [1]: %x %x", b2_config_parms[5].info[0], b2_config_parms[5].info[1])); + dbug(1, dprintf("b2_config_parms[6].info[0] [1]: %x %x", b2_config_parms[6].info[0], b2_config_parms[6].info[1])); + } + else { + dlc[6] = 14; + } + + } + else { + PUT_WORD(&dlc[7], (word)b2_config_parms[4].length); + for (i = 0; i < b2_config_parms[4].length; i++) + dlc[11 + i] = b2_config_parms[4].info[1 + i]; + } + } + } + } + add_p(plci, DLC, dlc); + + b3_config = &bp_parms[5]; + if (b3_config->length) + { + if (plci->B3_prot == 4 + || plci->B3_prot == 5) + { + if (api_parse(&b3_config->info[1], (word)b3_config->length, "wwss", b3_config_parms)) + { + return _WRONG_MESSAGE_FORMAT; + } + i = GET_WORD((byte *)(b3_config_parms[0].info)); + ((T30_INFO *)&nlc[1])->resolution = (byte)(((i & 0x0001) || + ((plci->B3_prot == 4) && (((byte)(GET_WORD((byte *)b3_config_parms[1].info))) != 5))) ? T30_RESOLUTION_R8_0770_OR_200 : 0); + ((T30_INFO *)&nlc[1])->data_format = (byte)(GET_WORD((byte *)b3_config_parms[1].info)); + fax_control_bits = T30_CONTROL_BIT_ALL_FEATURES; + if ((((T30_INFO *)&nlc[1])->rate_div_2400 != 0) && (((T30_INFO *)&nlc[1])->rate_div_2400 <= 6)) + fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_V34FAX; + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_FAX_PAPER_FORMATS) + { + + if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id - 1]) + & (1L << PRIVATE_FAX_PAPER_FORMATS)) + { + ((T30_INFO *)&nlc[1])->resolution |= T30_RESOLUTION_R8_1540 | + T30_RESOLUTION_R16_1540_OR_400 | T30_RESOLUTION_300_300 | + T30_RESOLUTION_INCH_BASED | T30_RESOLUTION_METRIC_BASED; + } + + ((T30_INFO *)&nlc[1])->recording_properties = + T30_RECORDING_WIDTH_ISO_A3 | + (T30_RECORDING_LENGTH_UNLIMITED << 2) | + (T30_MIN_SCANLINE_TIME_00_00_00 << 4); + } + if (plci->B3_prot == 5) + { + if (i & 0x0002) /* Accept incoming fax-polling requests */ + fax_control_bits |= T30_CONTROL_BIT_ACCEPT_POLLING; + if (i & 0x2000) /* Do not use MR compression */ + fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_2D_CODING; + if (i & 0x4000) /* Do not use MMR compression */ + fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_T6_CODING; + if (i & 0x8000) /* Do not use ECM */ + fax_control_bits &= ~T30_CONTROL_BIT_ENABLE_ECM; + if (plci->fax_connect_info_length != 0) + { + ((T30_INFO *)&nlc[1])->resolution = ((T30_INFO *)plci->fax_connect_info_buffer)->resolution; + ((T30_INFO *)&nlc[1])->data_format = ((T30_INFO *)plci->fax_connect_info_buffer)->data_format; + ((T30_INFO *)&nlc[1])->recording_properties = ((T30_INFO *)plci->fax_connect_info_buffer)->recording_properties; + fax_control_bits |= GET_WORD(&((T30_INFO *)plci->fax_connect_info_buffer)->control_bits_low) & + (T30_CONTROL_BIT_REQUEST_POLLING | T30_CONTROL_BIT_MORE_DOCUMENTS); + } + } + /* copy station id to NLC */ + for (i = 0; i < T30_MAX_STATION_ID_LENGTH; i++) + { + if (i < b3_config_parms[2].length) + { + ((T30_INFO *)&nlc[1])->station_id[i] = ((byte *)b3_config_parms[2].info)[1 + i]; + } + else + { + ((T30_INFO *)&nlc[1])->station_id[i] = ' '; + } + } + ((T30_INFO *)&nlc[1])->station_id_len = T30_MAX_STATION_ID_LENGTH; + /* copy head line to NLC */ + if (b3_config_parms[3].length) + { + + pos = (byte)(fax_head_line_time(&(((T30_INFO *)&nlc[1])->station_id[T30_MAX_STATION_ID_LENGTH]))); + if (pos != 0) + { + if (CAPI_MAX_DATE_TIME_LENGTH + 2 + b3_config_parms[3].length > CAPI_MAX_HEAD_LINE_SPACE) + pos = 0; + else + { + nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; + nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; + len = (byte)b3_config_parms[2].length; + if (len > 20) + len = 20; + if (CAPI_MAX_DATE_TIME_LENGTH + 2 + len + 2 + b3_config_parms[3].length <= CAPI_MAX_HEAD_LINE_SPACE) + { + for (i = 0; i < len; i++) + nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((byte *)b3_config_parms[2].info)[1 + i]; + nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; + nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ' '; + } + } + } + + len = (byte)b3_config_parms[3].length; + if (len > CAPI_MAX_HEAD_LINE_SPACE - pos) + len = (byte)(CAPI_MAX_HEAD_LINE_SPACE - pos); + ((T30_INFO *)&nlc[1])->head_line_len = (byte)(pos + len); + nlc[0] += (byte)(pos + len); + for (i = 0; i < len; i++) + nlc[1 + offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH + pos++] = ((byte *)b3_config_parms[3].info)[1 + i]; + } else + ((T30_INFO *)&nlc[1])->head_line_len = 0; + + plci->nsf_control_bits = 0; + if (plci->B3_prot == 5) + { + if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_FAX_SUB_SEP_PWD)) + && (GET_WORD((byte *)b3_config_parms[1].info) & 0x8000)) /* Private SUB/SEP/PWD enable */ + { + plci->requested_options |= 1L << PRIVATE_FAX_SUB_SEP_PWD; + } + if ((plci->adapter->man_profile.private_options & (1L << PRIVATE_FAX_NONSTANDARD)) + && (GET_WORD((byte *)b3_config_parms[1].info) & 0x4000)) /* Private non-standard facilities enable */ + { + plci->requested_options |= 1L << PRIVATE_FAX_NONSTANDARD; + } + if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id - 1]) + & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) + { + if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id - 1]) + & (1L << PRIVATE_FAX_SUB_SEP_PWD)) + { + fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SUBADDRESS | T30_CONTROL_BIT_ACCEPT_PASSWORD; + if (fax_control_bits & T30_CONTROL_BIT_ACCEPT_POLLING) + fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; + } + len = nlc[0]; + pos = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + if (pos < plci->fax_connect_info_length) + { + for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) + nlc[++len] = plci->fax_connect_info_buffer[pos++]; + } + else + nlc[++len] = 0; + if (pos < plci->fax_connect_info_length) + { + for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) + nlc[++len] = plci->fax_connect_info_buffer[pos++]; + } + else + nlc[++len] = 0; + if ((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[plci->appl->Id - 1]) + & (1L << PRIVATE_FAX_NONSTANDARD)) + { + if ((pos < plci->fax_connect_info_length) && (plci->fax_connect_info_buffer[pos] != 0)) + { + if ((plci->fax_connect_info_buffer[pos] >= 3) && (plci->fax_connect_info_buffer[pos + 1] >= 2)) + plci->nsf_control_bits = GET_WORD(&plci->fax_connect_info_buffer[pos + 2]); + for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) + nlc[++len] = plci->fax_connect_info_buffer[pos++]; + } + else + { + if (api_parse(&b3_config->info[1], (word)b3_config->length, "wwsss", b3_config_parms)) + { + dbug(1, dprintf("non-standard facilities info missing or wrong format")); + nlc[++len] = 0; + } + else + { + if ((b3_config_parms[4].length >= 3) && (b3_config_parms[4].info[1] >= 2)) + plci->nsf_control_bits = GET_WORD(&b3_config_parms[4].info[2]); + nlc[++len] = (byte)(b3_config_parms[4].length); + for (i = 0; i < b3_config_parms[4].length; i++) + nlc[++len] = b3_config_parms[4].info[1 + i]; + } + } + } + nlc[0] = len; + if ((plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) + && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) + { + ((T30_INFO *)&nlc[1])->operating_mode = T30_OPERATING_MODE_CAPI_NEG; + } + } + } + + PUT_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits); + len = offsetof(T30_INFO, station_id) + T30_MAX_STATION_ID_LENGTH; + for (i = 0; i < len; i++) + plci->fax_connect_info_buffer[i] = nlc[1 + i]; + ((T30_INFO *) plci->fax_connect_info_buffer)->head_line_len = 0; + i += ((T30_INFO *)&nlc[1])->head_line_len; + while (i < nlc[0]) + plci->fax_connect_info_buffer[len++] = nlc[++i]; + plci->fax_connect_info_length = len; + } + else + { + nlc[0] = 14; + if (b3_config->length != 16) + return _B3_PARM_NOT_SUPPORTED; + for (i = 0; i < 12; i++) nlc[1 + i] = b3_config->info[1 + i]; + if (GET_WORD(&b3_config->info[13]) != 8 && GET_WORD(&b3_config->info[13]) != 128) + return _B3_PARM_NOT_SUPPORTED; + nlc[13] = b3_config->info[13]; + if (GET_WORD(&b3_config->info[15]) >= nlc[13]) + return _B3_PARM_NOT_SUPPORTED; + nlc[14] = b3_config->info[15]; + } + } + else + { + if (plci->B3_prot == 4 + || plci->B3_prot == 5 /*T.30 - FAX*/) return _B3_PARM_NOT_SUPPORTED; + } + add_p(plci, NLC, nlc); + return 0; } /*----------------------------------------------------------------*/ @@ -8567,136 +8567,136 @@ static word add_b23(PLCI *plci, API_PARSE *bp) /* B3 Configuration for modem: */ /* empty */ /*----------------------------------------------------------------*/ -static word add_modem_b23 (PLCI * plci, API_PARSE* bp_parms) -{ - static byte lli[12] = {1,1}; - static byte llc[3] = {2,0,0}; - static byte dlc[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - API_PARSE mdm_config[2]; - word i; - word b2_config = 0; - - for(i=0;i<2;i++) mdm_config[i].length = 0; - for(i=0;iB2_prot = (byte) GET_WORD(bp_parms[1].info); - plci->B3_prot = (byte) GET_WORD(bp_parms[2].info); - - if ((GET_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION) && bp_parms[4].length) - { - if (api_parse (&bp_parms[4].info[1], - (word)bp_parms[4].length, "w", - mdm_config)) - { - return (_WRONG_MESSAGE_FORMAT); - } - b2_config = GET_WORD(mdm_config[0].info); - } - - /* OK, L2 is modem */ - - lli[0] = 1; - lli[1] = 1; - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL) - lli[1] |= 2; - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_OOB_CHANNEL) - lli[1] |= 4; - - if ((lli[1] & 0x02) && (diva_xdi_extended_features & DIVA_CAPI_USE_CMA)) { - lli[1] |= 0x10; - if (plci->rx_dma_descriptor <= 0) { - plci->rx_dma_descriptor=diva_get_dma_descriptor(plci,&plci->rx_dma_magic); - if (plci->rx_dma_descriptor >= 0) - plci->rx_dma_descriptor++; - } - if (plci->rx_dma_descriptor > 0) { - lli[1] |= 0x40; - lli[0] = 6; - lli[2] = (byte)(plci->rx_dma_descriptor - 1); - lli[3] = (byte)plci->rx_dma_magic; - lli[4] = (byte)(plci->rx_dma_magic >> 8); - lli[5] = (byte)(plci->rx_dma_magic >> 16); - lli[6] = (byte)(plci->rx_dma_magic >> 24); - } - } - - if (DIVA_CAPI_SUPPORTS_NO_CANCEL(plci->adapter)) { - lli[1] |= 0x20; - } - - llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? - /*V42*/ 10 : /*V42_IN*/ 9; - llc[2] = 4; /* pass L3 always transparent */ - add_p(plci, LLI, lli); - add_p(plci, LLC, llc); - i = 1; - PUT_WORD (&dlc[i], plci->appl->MaxDataLength); - i += 2; - if (GET_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION) - { - if (bp_parms[4].length) - { - dbug(1, dprintf("MDM b2_config=%02x", b2_config)); - dlc[i++] = 3; /* Addr A */ - dlc[i++] = 1; /* Addr B */ - dlc[i++] = 7; /* modulo mode */ - dlc[i++] = 7; /* window size */ - dlc[i++] = 0; /* XID len Lo */ - dlc[i++] = 0; /* XID len Hi */ - - if (b2_config & MDM_B2_DISABLE_V42bis) - { - dlc[i] |= DLC_MODEMPROT_DISABLE_V42_V42BIS; - } - if (b2_config & MDM_B2_DISABLE_MNP) - { - dlc[i] |= DLC_MODEMPROT_DISABLE_MNP_MNP5; - } - if (b2_config & MDM_B2_DISABLE_TRANS) - { - dlc[i] |= DLC_MODEMPROT_REQUIRE_PROTOCOL; - } - if (b2_config & MDM_B2_DISABLE_V42) - { - dlc[i] |= DLC_MODEMPROT_DISABLE_V42_DETECT; - } - if (b2_config & MDM_B2_DISABLE_COMP) - { - dlc[i] |= DLC_MODEMPROT_DISABLE_COMPRESSION; - } - i++; - } - } - else - { - dlc[i++] = 3; /* Addr A */ - dlc[i++] = 1; /* Addr B */ - dlc[i++] = 7; /* modulo mode */ - dlc[i++] = 7; /* window size */ - dlc[i++] = 0; /* XID len Lo */ - dlc[i++] = 0; /* XID len Hi */ - dlc[i++] = DLC_MODEMPROT_DISABLE_V42_V42BIS | - DLC_MODEMPROT_DISABLE_MNP_MNP5 | - DLC_MODEMPROT_DISABLE_V42_DETECT | - DLC_MODEMPROT_DISABLE_COMPRESSION; - } - dlc[0] = (byte)(i - 1); +static word add_modem_b23(PLCI *plci, API_PARSE *bp_parms) +{ + static byte lli[12] = {1,1}; + static byte llc[3] = {2,0,0}; + static byte dlc[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + API_PARSE mdm_config[2]; + word i; + word b2_config = 0; + + for (i = 0; i < 2; i++) mdm_config[i].length = 0; + for (i = 0; i < sizeof(dlc); i++) dlc[i] = 0; + + if (((GET_WORD(bp_parms[0].info) == B1_MODEM_ALL_NEGOTIATE) + && (GET_WORD(bp_parms[1].info) != B2_MODEM_EC_COMPRESSION)) + || ((GET_WORD(bp_parms[0].info) != B1_MODEM_ALL_NEGOTIATE) + && (GET_WORD(bp_parms[1].info) != B2_TRANSPARENT))) + { + return (_B_STACK_NOT_SUPPORTED); + } + if ((GET_WORD(bp_parms[2].info) != B3_MODEM) + && (GET_WORD(bp_parms[2].info) != B3_TRANSPARENT)) + { + return (_B_STACK_NOT_SUPPORTED); + } + + plci->B2_prot = (byte) GET_WORD(bp_parms[1].info); + plci->B3_prot = (byte) GET_WORD(bp_parms[2].info); + + if ((GET_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION) && bp_parms[4].length) + { + if (api_parse(&bp_parms[4].info[1], + (word)bp_parms[4].length, "w", + mdm_config)) + { + return (_WRONG_MESSAGE_FORMAT); + } + b2_config = GET_WORD(mdm_config[0].info); + } + + /* OK, L2 is modem */ + + lli[0] = 1; + lli[1] = 1; + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL) + lli[1] |= 2; + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_OOB_CHANNEL) + lli[1] |= 4; + + if ((lli[1] & 0x02) && (diva_xdi_extended_features & DIVA_CAPI_USE_CMA)) { + lli[1] |= 0x10; + if (plci->rx_dma_descriptor <= 0) { + plci->rx_dma_descriptor = diva_get_dma_descriptor(plci, &plci->rx_dma_magic); + if (plci->rx_dma_descriptor >= 0) + plci->rx_dma_descriptor++; + } + if (plci->rx_dma_descriptor > 0) { + lli[1] |= 0x40; + lli[0] = 6; + lli[2] = (byte)(plci->rx_dma_descriptor - 1); + lli[3] = (byte)plci->rx_dma_magic; + lli[4] = (byte)(plci->rx_dma_magic >> 8); + lli[5] = (byte)(plci->rx_dma_magic >> 16); + lli[6] = (byte)(plci->rx_dma_magic >> 24); + } + } + + if (DIVA_CAPI_SUPPORTS_NO_CANCEL(plci->adapter)) { + lli[1] |= 0x20; + } + + llc[1] = (plci->call_dir & (CALL_DIR_ORIGINATE | CALL_DIR_FORCE_OUTG_NL)) ? + /*V42*/ 10 : /*V42_IN*/ 9; + llc[2] = 4; /* pass L3 always transparent */ + add_p(plci, LLI, lli); + add_p(plci, LLC, llc); + i = 1; + PUT_WORD(&dlc[i], plci->appl->MaxDataLength); + i += 2; + if (GET_WORD(bp_parms[1].info) == B2_MODEM_EC_COMPRESSION) + { + if (bp_parms[4].length) + { + dbug(1, dprintf("MDM b2_config=%02x", b2_config)); + dlc[i++] = 3; /* Addr A */ + dlc[i++] = 1; /* Addr B */ + dlc[i++] = 7; /* modulo mode */ + dlc[i++] = 7; /* window size */ + dlc[i++] = 0; /* XID len Lo */ + dlc[i++] = 0; /* XID len Hi */ + + if (b2_config & MDM_B2_DISABLE_V42bis) + { + dlc[i] |= DLC_MODEMPROT_DISABLE_V42_V42BIS; + } + if (b2_config & MDM_B2_DISABLE_MNP) + { + dlc[i] |= DLC_MODEMPROT_DISABLE_MNP_MNP5; + } + if (b2_config & MDM_B2_DISABLE_TRANS) + { + dlc[i] |= DLC_MODEMPROT_REQUIRE_PROTOCOL; + } + if (b2_config & MDM_B2_DISABLE_V42) + { + dlc[i] |= DLC_MODEMPROT_DISABLE_V42_DETECT; + } + if (b2_config & MDM_B2_DISABLE_COMP) + { + dlc[i] |= DLC_MODEMPROT_DISABLE_COMPRESSION; + } + i++; + } + } + else + { + dlc[i++] = 3; /* Addr A */ + dlc[i++] = 1; /* Addr B */ + dlc[i++] = 7; /* modulo mode */ + dlc[i++] = 7; /* window size */ + dlc[i++] = 0; /* XID len Lo */ + dlc[i++] = 0; /* XID len Hi */ + dlc[i++] = DLC_MODEMPROT_DISABLE_V42_V42BIS | + DLC_MODEMPROT_DISABLE_MNP_MNP5 | + DLC_MODEMPROT_DISABLE_V42_DETECT | + DLC_MODEMPROT_DISABLE_COMPRESSION; + } + dlc[0] = (byte)(i - 1); /* HexDump ("DLC", sizeof(dlc), &dlc[0]); */ - add_p(plci, DLC, dlc); - return (0); + add_p(plci, DLC, dlc); + return (0); } @@ -8706,20 +8706,20 @@ static word add_modem_b23 (PLCI * plci, API_PARSE* bp_parms) static void sig_req(PLCI *plci, byte req, byte Id) { - if(!plci) return; - if(plci->adapter->adapter_disabled) return; - dbug(1,dprintf("sig_req(%x)",req)); - if (req == REMOVE) - plci->sig_remove_id = plci->Sig.Id; - if(plci->req_in==plci->req_in_start) { - plci->req_in +=2; - plci->RBuffer[plci->req_in++] = 0; - } - PUT_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start-2); - plci->RBuffer[plci->req_in++] = Id; /* sig/nl flag */ - plci->RBuffer[plci->req_in++] = req; /* request */ - plci->RBuffer[plci->req_in++] = 0; /* channel */ - plci->req_in_start = plci->req_in; + if (!plci) return; + if (plci->adapter->adapter_disabled) return; + dbug(1, dprintf("sig_req(%x)", req)); + if (req == REMOVE) + plci->sig_remove_id = plci->Sig.Id; + if (plci->req_in == plci->req_in_start) { + plci->req_in += 2; + plci->RBuffer[plci->req_in++] = 0; + } + PUT_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start - 2); + plci->RBuffer[plci->req_in++] = Id; /* sig/nl flag */ + plci->RBuffer[plci->req_in++] = req; /* request */ + plci->RBuffer[plci->req_in++] = 0; /* channel */ + plci->req_in_start = plci->req_in; } /*------------------------------------------------------------------*/ @@ -8728,198 +8728,198 @@ static void sig_req(PLCI *plci, byte req, byte Id) static void nl_req_ncci(PLCI *plci, byte req, byte ncci) { - if(!plci) return; - if(plci->adapter->adapter_disabled) return; - dbug(1,dprintf("nl_req %02x %02x %02x", plci->Id, req, ncci)); - if (req == REMOVE) - { - plci->nl_remove_id = plci->NL.Id; - ncci_remove (plci, 0, (byte)(ncci != 0)); - ncci = 0; - } - if(plci->req_in==plci->req_in_start) { - plci->req_in +=2; - plci->RBuffer[plci->req_in++] = 0; - } - PUT_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start-2); - plci->RBuffer[plci->req_in++] = 1; /* sig/nl flag */ - plci->RBuffer[plci->req_in++] = req; /* request */ - plci->RBuffer[plci->req_in++] = plci->adapter->ncci_ch[ncci]; /* channel */ - plci->req_in_start = plci->req_in; + if (!plci) return; + if (plci->adapter->adapter_disabled) return; + dbug(1, dprintf("nl_req %02x %02x %02x", plci->Id, req, ncci)); + if (req == REMOVE) + { + plci->nl_remove_id = plci->NL.Id; + ncci_remove(plci, 0, (byte)(ncci != 0)); + ncci = 0; + } + if (plci->req_in == plci->req_in_start) { + plci->req_in += 2; + plci->RBuffer[plci->req_in++] = 0; + } + PUT_WORD(&plci->RBuffer[plci->req_in_start], plci->req_in-plci->req_in_start - 2); + plci->RBuffer[plci->req_in++] = 1; /* sig/nl flag */ + plci->RBuffer[plci->req_in++] = req; /* request */ + plci->RBuffer[plci->req_in++] = plci->adapter->ncci_ch[ncci]; /* channel */ + plci->req_in_start = plci->req_in; } static void send_req(PLCI *plci) { - ENTITY * e; - word l; + ENTITY *e; + word l; /* word i; */ - if(!plci) return; - if(plci->adapter->adapter_disabled) return; - channel_xmit_xon (plci); - - /* if nothing to do, return */ - if(plci->req_in==plci->req_out) return; - dbug(1,dprintf("send_req(in=%d,out=%d)",plci->req_in,plci->req_out)); - - if(plci->nl_req || plci->sig_req) return; - - l = GET_WORD(&plci->RBuffer[plci->req_out]); - plci->req_out += 2; - plci->XData[0].P = &plci->RBuffer[plci->req_out]; - plci->req_out += l; - if(plci->RBuffer[plci->req_out]==1) - { - e = &plci->NL; - plci->req_out++; - e->Req = plci->nl_req = plci->RBuffer[plci->req_out++]; - e->ReqCh = plci->RBuffer[plci->req_out++]; - if(!(e->Id & 0x1f)) - { - e->Id = NL_ID; - plci->RBuffer[plci->req_out-4] = CAI; - plci->RBuffer[plci->req_out-3] = 1; - plci->RBuffer[plci->req_out-2] = (plci->Sig.Id==0xff) ? 0 : plci->Sig.Id; - plci->RBuffer[plci->req_out-1] = 0; - l+=3; - plci->nl_global_req = plci->nl_req; - } - dbug(1,dprintf("%x:NLREQ(%x:%x:%x)",plci->adapter->Id,e->Id,e->Req,e->ReqCh)); - } - else - { - e = &plci->Sig; - if(plci->RBuffer[plci->req_out]) - e->Id = plci->RBuffer[plci->req_out]; - plci->req_out++; - e->Req = plci->sig_req = plci->RBuffer[plci->req_out++]; - e->ReqCh = plci->RBuffer[plci->req_out++]; - if(!(e->Id & 0x1f)) - plci->sig_global_req = plci->sig_req; - dbug(1,dprintf("%x:SIGREQ(%x:%x:%x)",plci->adapter->Id,e->Id,e->Req,e->ReqCh)); - } - plci->XData[0].PLength = l; - e->X = plci->XData; - plci->adapter->request(e); - dbug(1,dprintf("send_ok")); + if (!plci) return; + if (plci->adapter->adapter_disabled) return; + channel_xmit_xon(plci); + + /* if nothing to do, return */ + if (plci->req_in == plci->req_out) return; + dbug(1, dprintf("send_req(in=%d,out=%d)", plci->req_in, plci->req_out)); + + if (plci->nl_req || plci->sig_req) return; + + l = GET_WORD(&plci->RBuffer[plci->req_out]); + plci->req_out += 2; + plci->XData[0].P = &plci->RBuffer[plci->req_out]; + plci->req_out += l; + if (plci->RBuffer[plci->req_out] == 1) + { + e = &plci->NL; + plci->req_out++; + e->Req = plci->nl_req = plci->RBuffer[plci->req_out++]; + e->ReqCh = plci->RBuffer[plci->req_out++]; + if (!(e->Id & 0x1f)) + { + e->Id = NL_ID; + plci->RBuffer[plci->req_out - 4] = CAI; + plci->RBuffer[plci->req_out - 3] = 1; + plci->RBuffer[plci->req_out - 2] = (plci->Sig.Id == 0xff) ? 0 : plci->Sig.Id; + plci->RBuffer[plci->req_out - 1] = 0; + l += 3; + plci->nl_global_req = plci->nl_req; + } + dbug(1, dprintf("%x:NLREQ(%x:%x:%x)", plci->adapter->Id, e->Id, e->Req, e->ReqCh)); + } + else + { + e = &plci->Sig; + if (plci->RBuffer[plci->req_out]) + e->Id = plci->RBuffer[plci->req_out]; + plci->req_out++; + e->Req = plci->sig_req = plci->RBuffer[plci->req_out++]; + e->ReqCh = plci->RBuffer[plci->req_out++]; + if (!(e->Id & 0x1f)) + plci->sig_global_req = plci->sig_req; + dbug(1, dprintf("%x:SIGREQ(%x:%x:%x)", plci->adapter->Id, e->Id, e->Req, e->ReqCh)); + } + plci->XData[0].PLength = l; + e->X = plci->XData; + plci->adapter->request(e); + dbug(1, dprintf("send_ok")); } static void send_data(PLCI *plci) { - DIVA_CAPI_ADAPTER * a; - DATA_B3_DESC * data; - NCCI *ncci_ptr; - word ncci; - - if (!plci->nl_req && plci->ncci_ring_list) - { - a = plci->adapter; - ncci = plci->ncci_ring_list; - do - { - ncci = a->ncci_next[ncci]; - ncci_ptr = &(a->ncci[ncci]); - if (!(a->ncci_ch[ncci] - && (a->ch_flow_control[a->ncci_ch[ncci]] & N_OK_FC_PENDING))) - { - if (ncci_ptr->data_pending) - { - if ((a->ncci_state[ncci] == CONNECTED) - || (a->ncci_state[ncci] == INC_ACT_PENDING) - || (plci->send_disc == ncci)) - { - data = &(ncci_ptr->DBuffer[ncci_ptr->data_out]); - if ((plci->B2_prot == B2_V120_ASYNC) - || (plci->B2_prot == B2_V120_ASYNC_V42BIS) - || (plci->B2_prot == B2_V120_BIT_TRANSPARENT)) - { - plci->NData[1].P = TransmitBufferGet (plci->appl, data->P); - plci->NData[1].PLength = data->Length; - if (data->Flags & 0x10) - plci->NData[0].P = v120_break_header; - else - plci->NData[0].P = v120_default_header; - plci->NData[0].PLength = 1 ; - plci->NL.XNum = 2; - plci->NL.Req = plci->nl_req = (byte)((data->Flags&0x07)<<4 |N_DATA); - } - else - { - plci->NData[0].P = TransmitBufferGet (plci->appl, data->P); - plci->NData[0].PLength = data->Length; - if (data->Flags & 0x10) - plci->NL.Req = plci->nl_req = (byte)N_UDATA; - - else if ((plci->B3_prot == B3_RTP) && (data->Flags & 0x01)) - plci->NL.Req = plci->nl_req = (byte)N_BDATA; - - else - plci->NL.Req = plci->nl_req = (byte)((data->Flags&0x07)<<4 |N_DATA); - } - plci->NL.X = plci->NData; - plci->NL.ReqCh = a->ncci_ch[ncci]; - dbug(1,dprintf("%x:DREQ(%x:%x)",a->Id,plci->NL.Id,plci->NL.Req)); - plci->data_sent = true; - plci->data_sent_ptr = data->P; - a->request(&plci->NL); - } - else { - cleanup_ncci_data (plci, ncci); - } - } - else if (plci->send_disc == ncci) - { - /* dprintf("N_DISC"); */ - plci->NData[0].PLength = 0; - plci->NL.ReqCh = a->ncci_ch[ncci]; - plci->NL.Req = plci->nl_req = N_DISC; - a->request(&plci->NL); - plci->command = _DISCONNECT_B3_R; - plci->send_disc = 0; - } - } - } while (!plci->nl_req && (ncci != plci->ncci_ring_list)); - plci->ncci_ring_list = ncci; - } + DIVA_CAPI_ADAPTER *a; + DATA_B3_DESC *data; + NCCI *ncci_ptr; + word ncci; + + if (!plci->nl_req && plci->ncci_ring_list) + { + a = plci->adapter; + ncci = plci->ncci_ring_list; + do + { + ncci = a->ncci_next[ncci]; + ncci_ptr = &(a->ncci[ncci]); + if (!(a->ncci_ch[ncci] + && (a->ch_flow_control[a->ncci_ch[ncci]] & N_OK_FC_PENDING))) + { + if (ncci_ptr->data_pending) + { + if ((a->ncci_state[ncci] == CONNECTED) + || (a->ncci_state[ncci] == INC_ACT_PENDING) + || (plci->send_disc == ncci)) + { + data = &(ncci_ptr->DBuffer[ncci_ptr->data_out]); + if ((plci->B2_prot == B2_V120_ASYNC) + || (plci->B2_prot == B2_V120_ASYNC_V42BIS) + || (plci->B2_prot == B2_V120_BIT_TRANSPARENT)) + { + plci->NData[1].P = TransmitBufferGet(plci->appl, data->P); + plci->NData[1].PLength = data->Length; + if (data->Flags & 0x10) + plci->NData[0].P = v120_break_header; + else + plci->NData[0].P = v120_default_header; + plci->NData[0].PLength = 1; + plci->NL.XNum = 2; + plci->NL.Req = plci->nl_req = (byte)((data->Flags & 0x07) << 4 | N_DATA); + } + else + { + plci->NData[0].P = TransmitBufferGet(plci->appl, data->P); + plci->NData[0].PLength = data->Length; + if (data->Flags & 0x10) + plci->NL.Req = plci->nl_req = (byte)N_UDATA; + + else if ((plci->B3_prot == B3_RTP) && (data->Flags & 0x01)) + plci->NL.Req = plci->nl_req = (byte)N_BDATA; + + else + plci->NL.Req = plci->nl_req = (byte)((data->Flags & 0x07) << 4 | N_DATA); + } + plci->NL.X = plci->NData; + plci->NL.ReqCh = a->ncci_ch[ncci]; + dbug(1, dprintf("%x:DREQ(%x:%x)", a->Id, plci->NL.Id, plci->NL.Req)); + plci->data_sent = true; + plci->data_sent_ptr = data->P; + a->request(&plci->NL); + } + else { + cleanup_ncci_data(plci, ncci); + } + } + else if (plci->send_disc == ncci) + { + /* dprintf("N_DISC"); */ + plci->NData[0].PLength = 0; + plci->NL.ReqCh = a->ncci_ch[ncci]; + plci->NL.Req = plci->nl_req = N_DISC; + a->request(&plci->NL); + plci->command = _DISCONNECT_B3_R; + plci->send_disc = 0; + } + } + } while (!plci->nl_req && (ncci != plci->ncci_ring_list)); + plci->ncci_ring_list = ncci; + } } static void listen_check(DIVA_CAPI_ADAPTER *a) { - word i,j; - PLCI * plci; - byte activnotifiedcalls = 0; - - dbug(1,dprintf("listen_check(%d,%d)",a->listen_active,a->max_listen)); - if (!remove_started && !a->adapter_disabled) - { - for(i=0;imax_plci;i++) - { - plci = &(a->plci[i]); - if(plci->notifiedcall) activnotifiedcalls++; - } - dbug(1,dprintf("listen_check(%d)",activnotifiedcalls)); - - for(i=a->listen_active; i < ((word)(a->max_listen+activnotifiedcalls)); i++) { - if((j=get_plci(a))) { - a->listen_active++; - plci = &a->plci[j-1]; - plci->State = LISTENING; - - add_p(plci,OAD,"\x01\xfd"); - - add_p(plci,KEY,"\x04\x43\x41\x32\x30"); - - add_p(plci,CAI,"\x01\xc0"); - add_p(plci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - add_p(plci,LLI,"\x01\xc4"); /* support Dummy CR FAC + MWI + SpoofNotify */ - add_p(plci,SHIFT|6,NULL); - add_p(plci,SIN,"\x02\x00\x00"); - plci->internal_command = LISTEN_SIG_ASSIGN_PEND; /* do indicate_req if OK */ - sig_req(plci,ASSIGN,DSIG_ID); - send_req(plci); - } - } - } + word i, j; + PLCI *plci; + byte activnotifiedcalls = 0; + + dbug(1, dprintf("listen_check(%d,%d)", a->listen_active, a->max_listen)); + if (!remove_started && !a->adapter_disabled) + { + for (i = 0; i < a->max_plci; i++) + { + plci = &(a->plci[i]); + if (plci->notifiedcall) activnotifiedcalls++; + } + dbug(1, dprintf("listen_check(%d)", activnotifiedcalls)); + + for (i = a->listen_active; i < ((word)(a->max_listen + activnotifiedcalls)); i++) { + if ((j = get_plci(a))) { + a->listen_active++; + plci = &a->plci[j - 1]; + plci->State = LISTENING; + + add_p(plci, OAD, "\x01\xfd"); + + add_p(plci, KEY, "\x04\x43\x41\x32\x30"); + + add_p(plci, CAI, "\x01\xc0"); + add_p(plci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + add_p(plci, LLI, "\x01\xc4"); /* support Dummy CR FAC + MWI + SpoofNotify */ + add_p(plci, SHIFT | 6, NULL); + add_p(plci, SIN, "\x02\x00\x00"); + plci->internal_command = LISTEN_SIG_ASSIGN_PEND; /* do indicate_req if OK */ + sig_req(plci, ASSIGN, DSIG_ID); + send_req(plci); + } + } + } } /*------------------------------------------------------------------*/ @@ -8928,83 +8928,83 @@ static void listen_check(DIVA_CAPI_ADAPTER *a) static void IndParse(PLCI *plci, word *parms_id, byte **parms, byte multiIEsize) { - word ploc; /* points to current location within packet */ - byte w; - byte wlen; - byte codeset,lock; - byte * in; - word i; - word code; - word mIEindex = 0; - ploc = 0; - codeset = 0; - lock = 0; - - in = plci->Sig.RBuffer->P; - for(i=0; iSig.RBuffer->length-1) { - - /* read information element id and length */ - w = in[ploc]; - - if(w & 0x80) { + word ploc; /* points to current location within packet */ + byte w; + byte wlen; + byte codeset, lock; + byte *in; + word i; + word code; + word mIEindex = 0; + ploc = 0; + codeset = 0; + lock = 0; + + in = plci->Sig.RBuffer->P; + for (i = 0; i < parms_id[0]; i++) /* multiIE parms_id contains just the 1st */ + { /* element but parms array is larger */ + parms[i] = (byte *)""; + } + for (i = 0; i < multiIEsize; i++) + { + parms[i] = (byte *)""; + } + + while (ploc < plci->Sig.RBuffer->length - 1) { + + /* read information element id and length */ + w = in[ploc]; + + if (w & 0x80) { /* w &=0xf0; removed, cannot detect congestion levels */ /* upper 4 bit masked with w==SHIFT now */ - wlen = 0; - } - else { - wlen = (byte)(in[ploc+1]+1); - } - /* check if length valid (not exceeding end of packet) */ - if((ploc+wlen) > 270) return ; - if(lock & 0x80) lock &=0x7f; - else codeset = lock; - - if((w&0xf0)==SHIFT) { - codeset = in[ploc]; - if(!(codeset & 0x08)) lock = (byte)(codeset & 7); - codeset &=7; - lock |=0x80; - } - else { - if(w==ESC && wlen>=3) code = in[ploc+2] |0x800; - else code = w; - code |= (codeset<<8); - - for(i=1; i 270) return; + if (lock & 0x80) lock &= 0x7f; + else codeset = lock; + + if ((w & 0xf0) == SHIFT) { + codeset = in[ploc]; + if (!(codeset & 0x08)) lock = (byte)(codeset & 7); + codeset &= 7; + lock |= 0x80; + } + else { + if (w == ESC && wlen >= 3) code = in[ploc + 2] | 0x800; + else code = w; + code |= (codeset << 8); + + for (i = 1; i < parms_id[0] + 1 && parms_id[i] != code; i++); + + if (i < parms_id[0] + 1) { + if (!multiIEsize) { /* with multiIEs use next field index, */ + mIEindex = i - 1; /* with normal IEs use same index like parms_id */ + } + + parms[mIEindex] = &in[ploc + 1]; + dbug(1, dprintf("mIE[%d]=0x%x", *parms[mIEindex], in[ploc])); + if (parms_id[i] == OAD + || parms_id[i] == CONN_NR + || parms_id[i] == CAD) { + if (in[ploc + 2] & 0x80) { + in[ploc + 0] = (byte)(in[ploc + 1] + 1); + in[ploc + 1] = (byte)(in[ploc + 2] & 0x7f); + in[ploc + 2] = 0x80; + parms[mIEindex] = &in[ploc]; + } + } + mIEindex++; /* effects multiIEs only */ + } + } + + ploc += (wlen + 1); + } + return; } /*------------------------------------------------------------------*/ @@ -9013,75 +9013,75 @@ static void IndParse(PLCI *plci, word *parms_id, byte **parms, byte multiIEsize) static byte ie_compare(byte *ie1, byte *ie2) { - word i; - if(!ie1 || ! ie2) return false; - if(!ie1[0]) return false; - for(i=0;i<(word)(ie1[0]+1);i++) if(ie1[i]!=ie2[i]) return false; - return true; + word i; + if (!ie1 || !ie2) return false; + if (!ie1[0]) return false; + for (i = 0; i < (word)(ie1[0] + 1); i++) if (ie1[i] != ie2[i]) return false; + return true; } static word find_cip(DIVA_CAPI_ADAPTER *a, byte *bc, byte *hlc) { - word i; - word j; + word i; + word j; - for(i=9;i && !ie_compare(bc,cip_bc[i][a->u_law]);i--); + for (i = 9; i && !ie_compare(bc, cip_bc[i][a->u_law]); i--); - for(j=16;j<29 && - (!ie_compare(bc,cip_bc[j][a->u_law]) || !ie_compare(hlc,cip_hlc[j])); j++); - if(j==29) return i; - return j; + for (j = 16; j < 29 && + (!ie_compare(bc, cip_bc[j][a->u_law]) || !ie_compare(hlc, cip_hlc[j])); j++); + if (j == 29) return i; + return j; } -static byte AddInfo(byte **add_i, - byte **fty_i, - byte *esc_chi, - byte *facility) +static byte AddInfo(byte **add_i, + byte **fty_i, + byte *esc_chi, + byte *facility) { - byte i; - byte j; - byte k; - byte flen; - byte len=0; - /* facility is a nested structure */ - /* FTY can be more than once */ + byte i; + byte j; + byte k; + byte flen; + byte len = 0; + /* facility is a nested structure */ + /* FTY can be more than once */ if (esc_chi[0] && !(esc_chi[esc_chi[0]] & 0x7f)) - { - add_i[0] = (byte *)"\x02\x02\x00"; /* use neither b nor d channel */ - } - - else - { - add_i[0] = (byte *)""; - } - if(!fty_i[0][0]) - { - add_i[3] = (byte *)""; - } - else - { /* facility array found */ - for(i=0,j=1;iAdvSignalPLCI) - { - adv_voice_write_coefs (a->AdvSignalPLCI, ADV_VOICE_WRITE_ACTIVATION); - } + byte voice_chi[] = "\x02\x18\x01"; + byte channel; + + channel = chi[chi[0]] & 0x3; + dbug(1, dprintf("ExtDevON(Ch=0x%x)", channel)); + voice_chi[2] = (channel) ? channel : 1; + add_p(plci, FTY, "\x02\x01\x07"); /* B On, default on 1 */ + add_p(plci, ESC, voice_chi); /* Channel */ + sig_req(plci, TEL_CTRL, 0); + send_req(plci); + if (a->AdvSignalPLCI) + { + adv_voice_write_coefs(a->AdvSignalPLCI, ADV_VOICE_WRITE_ACTIVATION); + } } static void VoiceChannelOff(PLCI *plci) { - dbug(1,dprintf("ExtDevOFF")); - add_p(plci,FTY,"\x02\x01\x08"); /* B Off */ - sig_req(plci,TEL_CTRL,0); - send_req(plci); - if(plci->adapter->AdvSignalPLCI) - { - adv_voice_clear_config (plci->adapter->AdvSignalPLCI); - } + dbug(1, dprintf("ExtDevOFF")); + add_p(plci, FTY, "\x02\x01\x08"); /* B Off */ + sig_req(plci, TEL_CTRL, 0); + send_req(plci); + if (plci->adapter->AdvSignalPLCI) + { + adv_voice_clear_config(plci->adapter->AdvSignalPLCI); + } } static word AdvCodecSupport(DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, byte hook_listen) { - word j; - PLCI *splci; - - /* check if hardware supports handset with hook states (adv.codec) */ - /* or if just a on board codec is supported */ - /* the advanced codec plci is just for internal use */ - - /* diva Pro with on-board codec: */ - if(a->profile.Global_Options & HANDSET) - { - /* new call, but hook states are already signalled */ - if(a->AdvCodecFLAG) - { - if(a->AdvSignalAppl!=appl || a->AdvSignalPLCI) - { - dbug(1,dprintf("AdvSigPlci=0x%x",a->AdvSignalPLCI)); - return 0x2001; /* codec in use by another application */ - } - if(plci!=NULL) - { - a->AdvSignalPLCI = plci; - plci->tel=ADV_VOICE; - } - return 0; /* adv codec still used */ - } - if((j=get_plci(a))) - { - splci = &a->plci[j-1]; - splci->tel = CODEC_PERMANENT; - /* hook_listen indicates if a facility_req with handset/hook support */ - /* was sent. Otherwise if just a call on an external device was made */ - /* the codec will be used but the hook info will be discarded (just */ - /* the external controller is in use */ - if(hook_listen) splci->State = ADVANCED_VOICE_SIG; - else - { - splci->State = ADVANCED_VOICE_NOSIG; - if(plci) - { - plci->spoofed_msg = SPOOFING_REQUIRED; - } - /* indicate D-ch connect if */ - } /* codec is connected OK */ - if(plci!=NULL) - { - a->AdvSignalPLCI = plci; - plci->tel=ADV_VOICE; - } - a->AdvSignalAppl = appl; - a->AdvCodecFLAG = true; - a->AdvCodecPLCI = splci; - add_p(splci,CAI,"\x01\x15"); - add_p(splci,LLI,"\x01\x00"); - add_p(splci,ESC,"\x02\x18\x00"); - add_p(splci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - splci->internal_command = PERM_COD_ASSIGN; - dbug(1,dprintf("Codec Assign")); - sig_req(splci,ASSIGN,DSIG_ID); - send_req(splci); - } - else - { - return 0x2001; /* wrong state, no more plcis */ - } - } - else if(a->profile.Global_Options & ON_BOARD_CODEC) - { - if(hook_listen) return 0x300B; /* Facility not supported */ - /* no hook with SCOM */ - if(plci!=NULL) plci->tel = CODEC; - dbug(1,dprintf("S/SCOM codec")); - /* first time we use the scom-s codec we must shut down the internal */ - /* handset application of the card. This can be done by an assign with */ - /* a cai with the 0x80 bit set. Assign return code is 'out of resource'*/ - if(!a->scom_appl_disable){ - if((j=get_plci(a))) { - splci = &a->plci[j-1]; - add_p(splci,CAI,"\x01\x80"); - add_p(splci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - sig_req(splci,ASSIGN,0xC0); /* 0xc0 is the TEL_ID */ - send_req(splci); - a->scom_appl_disable = true; - } - else{ - return 0x2001; /* wrong state, no more plcis */ - } - } - } - else return 0x300B; /* Facility not supported */ - - return 0; + word j; + PLCI *splci; + + /* check if hardware supports handset with hook states (adv.codec) */ + /* or if just a on board codec is supported */ + /* the advanced codec plci is just for internal use */ + + /* diva Pro with on-board codec: */ + if (a->profile.Global_Options & HANDSET) + { + /* new call, but hook states are already signalled */ + if (a->AdvCodecFLAG) + { + if (a->AdvSignalAppl != appl || a->AdvSignalPLCI) + { + dbug(1, dprintf("AdvSigPlci=0x%x", a->AdvSignalPLCI)); + return 0x2001; /* codec in use by another application */ + } + if (plci != NULL) + { + a->AdvSignalPLCI = plci; + plci->tel = ADV_VOICE; + } + return 0; /* adv codec still used */ + } + if ((j = get_plci(a))) + { + splci = &a->plci[j - 1]; + splci->tel = CODEC_PERMANENT; + /* hook_listen indicates if a facility_req with handset/hook support */ + /* was sent. Otherwise if just a call on an external device was made */ + /* the codec will be used but the hook info will be discarded (just */ + /* the external controller is in use */ + if (hook_listen) splci->State = ADVANCED_VOICE_SIG; + else + { + splci->State = ADVANCED_VOICE_NOSIG; + if (plci) + { + plci->spoofed_msg = SPOOFING_REQUIRED; + } + /* indicate D-ch connect if */ + } /* codec is connected OK */ + if (plci != NULL) + { + a->AdvSignalPLCI = plci; + plci->tel = ADV_VOICE; + } + a->AdvSignalAppl = appl; + a->AdvCodecFLAG = true; + a->AdvCodecPLCI = splci; + add_p(splci, CAI, "\x01\x15"); + add_p(splci, LLI, "\x01\x00"); + add_p(splci, ESC, "\x02\x18\x00"); + add_p(splci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + splci->internal_command = PERM_COD_ASSIGN; + dbug(1, dprintf("Codec Assign")); + sig_req(splci, ASSIGN, DSIG_ID); + send_req(splci); + } + else + { + return 0x2001; /* wrong state, no more plcis */ + } + } + else if (a->profile.Global_Options & ON_BOARD_CODEC) + { + if (hook_listen) return 0x300B; /* Facility not supported */ + /* no hook with SCOM */ + if (plci != NULL) plci->tel = CODEC; + dbug(1, dprintf("S/SCOM codec")); + /* first time we use the scom-s codec we must shut down the internal */ + /* handset application of the card. This can be done by an assign with */ + /* a cai with the 0x80 bit set. Assign return code is 'out of resource'*/ + if (!a->scom_appl_disable) { + if ((j = get_plci(a))) { + splci = &a->plci[j - 1]; + add_p(splci, CAI, "\x01\x80"); + add_p(splci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + sig_req(splci, ASSIGN, 0xC0); /* 0xc0 is the TEL_ID */ + send_req(splci); + a->scom_appl_disable = true; + } + else{ + return 0x2001; /* wrong state, no more plcis */ + } + } + } + else return 0x300B; /* Facility not supported */ + + return 0; } static void CodecIdCheck(DIVA_CAPI_ADAPTER *a, PLCI *plci) { - dbug(1,dprintf("CodecIdCheck")); + dbug(1, dprintf("CodecIdCheck")); - if(a->AdvSignalPLCI == plci) - { - dbug(1,dprintf("PLCI owns codec")); - VoiceChannelOff(a->AdvCodecPLCI); - if(a->AdvCodecPLCI->State == ADVANCED_VOICE_NOSIG) - { - dbug(1,dprintf("remove temp codec PLCI")); - plci_remove(a->AdvCodecPLCI); - a->AdvCodecFLAG = 0; - a->AdvCodecPLCI = NULL; - a->AdvSignalAppl = NULL; - } - a->AdvSignalPLCI = NULL; - } + if (a->AdvSignalPLCI == plci) + { + dbug(1, dprintf("PLCI owns codec")); + VoiceChannelOff(a->AdvCodecPLCI); + if (a->AdvCodecPLCI->State == ADVANCED_VOICE_NOSIG) + { + dbug(1, dprintf("remove temp codec PLCI")); + plci_remove(a->AdvCodecPLCI); + a->AdvCodecFLAG = 0; + a->AdvCodecPLCI = NULL; + a->AdvSignalAppl = NULL; + } + a->AdvSignalPLCI = NULL; + } } /* ------------------------------------------------------------------- - Ask for physical address of card on PCI bus + Ask for physical address of card on PCI bus ------------------------------------------------------------------- */ -static void diva_ask_for_xdi_sdram_bar (DIVA_CAPI_ADAPTER * a, - IDI_SYNC_REQ * preq) { - a->sdram_bar = 0; - if (diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_SDRAM_BAR) { - ENTITY * e = (ENTITY *)preq; +static void diva_ask_for_xdi_sdram_bar(DIVA_CAPI_ADAPTER *a, + IDI_SYNC_REQ *preq) { + a->sdram_bar = 0; + if (diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_SDRAM_BAR) { + ENTITY *e = (ENTITY *)preq; - e->user[0] = a->Id - 1; - preq->xdi_sdram_bar.info.bar = 0; - preq->xdi_sdram_bar.Req = 0; - preq->xdi_sdram_bar.Rc = IDI_SYNC_REQ_XDI_GET_ADAPTER_SDRAM_BAR; + e->user[0] = a->Id - 1; + preq->xdi_sdram_bar.info.bar = 0; + preq->xdi_sdram_bar.Req = 0; + preq->xdi_sdram_bar.Rc = IDI_SYNC_REQ_XDI_GET_ADAPTER_SDRAM_BAR; - (*(a->request))(e); + (*(a->request))(e); - a->sdram_bar = preq->xdi_sdram_bar.info.bar; - dbug(3,dprintf("A(%d) SDRAM BAR = %08x", a->Id, a->sdram_bar)); - } + a->sdram_bar = preq->xdi_sdram_bar.info.bar; + dbug(3, dprintf("A(%d) SDRAM BAR = %08x", a->Id, a->sdram_bar)); + } } /* ------------------------------------------------------------------- - Ask XDI about extended features + Ask XDI about extended features ------------------------------------------------------------------- */ -static void diva_get_extended_adapter_features (DIVA_CAPI_ADAPTER * a) { - IDI_SYNC_REQ * preq; - char buffer[ ((sizeof(preq->xdi_extended_features)+4) > sizeof(ENTITY)) ? (sizeof(preq->xdi_extended_features)+4) : sizeof(ENTITY)]; - - char features[4]; - preq = (IDI_SYNC_REQ *)&buffer[0]; - - if (!diva_xdi_extended_features) { - ENTITY * e = (ENTITY *)preq; - diva_xdi_extended_features |= 0x80000000; - - e->user[0] = a->Id - 1; - preq->xdi_extended_features.Req = 0; - preq->xdi_extended_features.Rc = IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES; - preq->xdi_extended_features.info.buffer_length_in_bytes = sizeof(features); - preq->xdi_extended_features.info.features = &features[0]; - - (*(a->request))(e); - - if (features[0] & DIVA_XDI_EXTENDED_FEATURES_VALID) { - /* - Check features located in the byte '0' - */ - if (features[0] & DIVA_XDI_EXTENDED_FEATURE_CMA) { - diva_xdi_extended_features |= DIVA_CAPI_USE_CMA; - } - if (features[0] & DIVA_XDI_EXTENDED_FEATURE_RX_DMA) { - diva_xdi_extended_features |= DIVA_CAPI_XDI_PROVIDES_RX_DMA; - dbug(1,dprintf("XDI provides RxDMA")); - } - if (features[0] & DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR) { - diva_xdi_extended_features |= DIVA_CAPI_XDI_PROVIDES_SDRAM_BAR; - } - if (features[0] & DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC) { - diva_xdi_extended_features |= DIVA_CAPI_XDI_PROVIDES_NO_CANCEL; - dbug(3,dprintf("XDI provides NO_CANCEL_RC feature")); - } - - } - } - - diva_ask_for_xdi_sdram_bar (a, preq); +static void diva_get_extended_adapter_features(DIVA_CAPI_ADAPTER *a) { + IDI_SYNC_REQ *preq; + char buffer[((sizeof(preq->xdi_extended_features) + 4) > sizeof(ENTITY)) ? (sizeof(preq->xdi_extended_features) + 4) : sizeof(ENTITY)]; + + char features[4]; + preq = (IDI_SYNC_REQ *)&buffer[0]; + + if (!diva_xdi_extended_features) { + ENTITY *e = (ENTITY *)preq; + diva_xdi_extended_features |= 0x80000000; + + e->user[0] = a->Id - 1; + preq->xdi_extended_features.Req = 0; + preq->xdi_extended_features.Rc = IDI_SYNC_REQ_XDI_GET_EXTENDED_FEATURES; + preq->xdi_extended_features.info.buffer_length_in_bytes = sizeof(features); + preq->xdi_extended_features.info.features = &features[0]; + + (*(a->request))(e); + + if (features[0] & DIVA_XDI_EXTENDED_FEATURES_VALID) { + /* + Check features located in the byte '0' + */ + if (features[0] & DIVA_XDI_EXTENDED_FEATURE_CMA) { + diva_xdi_extended_features |= DIVA_CAPI_USE_CMA; + } + if (features[0] & DIVA_XDI_EXTENDED_FEATURE_RX_DMA) { + diva_xdi_extended_features |= DIVA_CAPI_XDI_PROVIDES_RX_DMA; + dbug(1, dprintf("XDI provides RxDMA")); + } + if (features[0] & DIVA_XDI_EXTENDED_FEATURE_SDRAM_BAR) { + diva_xdi_extended_features |= DIVA_CAPI_XDI_PROVIDES_SDRAM_BAR; + } + if (features[0] & DIVA_XDI_EXTENDED_FEATURE_NO_CANCEL_RC) { + diva_xdi_extended_features |= DIVA_CAPI_XDI_PROVIDES_NO_CANCEL; + dbug(3, dprintf("XDI provides NO_CANCEL_RC feature")); + } + + } + } + + diva_ask_for_xdi_sdram_bar(a, preq); } /*------------------------------------------------------------------*/ @@ -9310,188 +9310,188 @@ static void diva_get_extended_adapter_features (DIVA_CAPI_ADAPTER * a) { /*------------------------------------------------------------------*/ /* called from OS specific part after init time to get the Law */ /* a-law (Euro) and u-law (us,japan) use different BCs in the Setup message */ -void AutomaticLaw(DIVA_CAPI_ADAPTER *a) -{ - word j; - PLCI *splci; - - if(a->automatic_law) { - return; - } - if((j=get_plci(a))) { - diva_get_extended_adapter_features (a); - splci = &a->plci[j-1]; - a->automatic_lawPLCI = splci; - a->automatic_law = 1; - add_p(splci,CAI,"\x01\x80"); - add_p(splci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - splci->internal_command = USELAW_REQ; - splci->command = 0; - splci->number = 0; - sig_req(splci,ASSIGN,DSIG_ID); - send_req(splci); - } +void AutomaticLaw(DIVA_CAPI_ADAPTER *a) +{ + word j; + PLCI *splci; + + if (a->automatic_law) { + return; + } + if ((j = get_plci(a))) { + diva_get_extended_adapter_features(a); + splci = &a->plci[j - 1]; + a->automatic_lawPLCI = splci; + a->automatic_law = 1; + add_p(splci, CAI, "\x01\x80"); + add_p(splci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + splci->internal_command = USELAW_REQ; + splci->command = 0; + splci->number = 0; + sig_req(splci, ASSIGN, DSIG_ID); + send_req(splci); + } } /* called from OS specific part if an application sends an Capi20Release */ word CapiRelease(word Id) { - word i, j, appls_found; - PLCI *plci; - APPL *this; - DIVA_CAPI_ADAPTER *a; - - if (!Id) - { - dbug(0,dprintf("A: CapiRelease(Id==0)")); - return (_WRONG_APPL_ID); - } - - this = &application[Id-1]; /* get application pointer */ - - for(i=0,appls_found=0; irequest) - { - a->Info_Mask[Id-1] = 0; - a->CIP_Mask[Id-1] = 0; - a->Notification_Mask[Id-1] = 0; - a->codec_listen[Id-1] = NULL; - a->requested_options_table[Id-1] = 0; - for(j=0; jmax_plci; j++) /* and all PLCIs connected */ - { /* with this application */ - plci = &a->plci[j]; - if(plci->Id) /* if plci owns no application */ - { /* it may be not jet connected */ - if(plci->State==INC_CON_PENDING - || plci->State==INC_CON_ALERT) - { - if(test_c_ind_mask_bit (plci, (word)(Id-1))) - { - clear_c_ind_mask_bit (plci, (word)(Id-1)); - if(c_ind_mask_empty (plci)) - { - sig_req(plci,HANGUP,0); - send_req(plci); - plci->State = OUTG_DIS_PENDING; - } - } - } - if(test_c_ind_mask_bit (plci, (word)(Id-1))) - { - clear_c_ind_mask_bit (plci, (word)(Id-1)); - if(c_ind_mask_empty (plci)) - { - if(!plci->appl) - { - plci_remove(plci); - plci->State = IDLE; - } - } - } - if(plci->appl==this) - { - plci->appl = NULL; - plci_remove(plci); - plci->State = IDLE; - } - } - } - listen_check(a); - - if(a->flag_dynamic_l1_down) - { - if(appls_found==1) /* last application does a capi release */ - { - if((j=get_plci(a))) - { - plci = &a->plci[j-1]; - plci->command = 0; - add_p(plci,OAD,"\x01\xfd"); - add_p(plci,CAI,"\x01\x80"); - add_p(plci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - add_p(plci,SHIFT|6,NULL); - add_p(plci,SIN,"\x02\x00\x00"); - plci->internal_command = REM_L1_SIG_ASSIGN_PEND; - sig_req(plci,ASSIGN,DSIG_ID); - add_p(plci,FTY,"\x02\xff\x06"); /* l1 down */ - sig_req(plci,SIG_CTRL,0); - send_req(plci); - } - } - } - if(a->AdvSignalAppl==this) - { - this->NullCREnable = false; - if (a->AdvCodecPLCI) - { - plci_remove(a->AdvCodecPLCI); - a->AdvCodecPLCI->tel = 0; - a->AdvCodecPLCI->adv_nl = 0; - } - a->AdvSignalAppl = NULL; - a->AdvSignalPLCI = NULL; - a->AdvCodecFLAG = 0; - a->AdvCodecPLCI = NULL; - } - } - } - - this->Id = 0; - - return GOOD; -} - -static word plci_remove_check(PLCI *plci) -{ - if(!plci) return true; - if(!plci->NL.Id && c_ind_mask_empty (plci)) - { - if(plci->Sig.Id == 0xff) - plci->Sig.Id = 0; - if(!plci->Sig.Id) - { - dbug(1,dprintf("plci_remove_complete(%x)",plci->Id)); - dbug(1,dprintf("tel=0x%x,Sig=0x%x",plci->tel,plci->Sig.Id)); - if (plci->Id) - { - CodecIdCheck(plci->adapter, plci); - clear_b1_config (plci); - ncci_remove (plci, 0, false); - plci_free_msg_in_queue (plci); - channel_flow_control_remove (plci); - plci->Id = 0; - plci->State = IDLE; - plci->channels = 0; - plci->appl = NULL; - plci->notifiedcall = 0; - } - listen_check(plci->adapter); - return true; - } - } - return false; + word i, j, appls_found; + PLCI *plci; + APPL *this; + DIVA_CAPI_ADAPTER *a; + + if (!Id) + { + dbug(0, dprintf("A: CapiRelease(Id==0)")); + return (_WRONG_APPL_ID); + } + + this = &application[Id - 1]; /* get application pointer */ + + for (i = 0, appls_found = 0; i < max_appl; i++) + { + if (application[i].Id) /* an application has been found */ + { + appls_found++; + } + } + + for (i = 0; i < max_adapter; i++) /* scan all adapters... */ + { + a = &adapter[i]; + if (a->request) + { + a->Info_Mask[Id - 1] = 0; + a->CIP_Mask[Id - 1] = 0; + a->Notification_Mask[Id - 1] = 0; + a->codec_listen[Id - 1] = NULL; + a->requested_options_table[Id - 1] = 0; + for (j = 0; j < a->max_plci; j++) /* and all PLCIs connected */ + { /* with this application */ + plci = &a->plci[j]; + if (plci->Id) /* if plci owns no application */ + { /* it may be not jet connected */ + if (plci->State == INC_CON_PENDING + || plci->State == INC_CON_ALERT) + { + if (test_c_ind_mask_bit(plci, (word)(Id - 1))) + { + clear_c_ind_mask_bit(plci, (word)(Id - 1)); + if (c_ind_mask_empty(plci)) + { + sig_req(plci, HANGUP, 0); + send_req(plci); + plci->State = OUTG_DIS_PENDING; + } + } + } + if (test_c_ind_mask_bit(plci, (word)(Id - 1))) + { + clear_c_ind_mask_bit(plci, (word)(Id - 1)); + if (c_ind_mask_empty(plci)) + { + if (!plci->appl) + { + plci_remove(plci); + plci->State = IDLE; + } + } + } + if (plci->appl == this) + { + plci->appl = NULL; + plci_remove(plci); + plci->State = IDLE; + } + } + } + listen_check(a); + + if (a->flag_dynamic_l1_down) + { + if (appls_found == 1) /* last application does a capi release */ + { + if ((j = get_plci(a))) + { + plci = &a->plci[j - 1]; + plci->command = 0; + add_p(plci, OAD, "\x01\xfd"); + add_p(plci, CAI, "\x01\x80"); + add_p(plci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + add_p(plci, SHIFT | 6, NULL); + add_p(plci, SIN, "\x02\x00\x00"); + plci->internal_command = REM_L1_SIG_ASSIGN_PEND; + sig_req(plci, ASSIGN, DSIG_ID); + add_p(plci, FTY, "\x02\xff\x06"); /* l1 down */ + sig_req(plci, SIG_CTRL, 0); + send_req(plci); + } + } + } + if (a->AdvSignalAppl == this) + { + this->NullCREnable = false; + if (a->AdvCodecPLCI) + { + plci_remove(a->AdvCodecPLCI); + a->AdvCodecPLCI->tel = 0; + a->AdvCodecPLCI->adv_nl = 0; + } + a->AdvSignalAppl = NULL; + a->AdvSignalPLCI = NULL; + a->AdvCodecFLAG = 0; + a->AdvCodecPLCI = NULL; + } + } + } + + this->Id = 0; + + return GOOD; +} + +static word plci_remove_check(PLCI *plci) +{ + if (!plci) return true; + if (!plci->NL.Id && c_ind_mask_empty(plci)) + { + if (plci->Sig.Id == 0xff) + plci->Sig.Id = 0; + if (!plci->Sig.Id) + { + dbug(1, dprintf("plci_remove_complete(%x)", plci->Id)); + dbug(1, dprintf("tel=0x%x,Sig=0x%x", plci->tel, plci->Sig.Id)); + if (plci->Id) + { + CodecIdCheck(plci->adapter, plci); + clear_b1_config(plci); + ncci_remove(plci, 0, false); + plci_free_msg_in_queue(plci); + channel_flow_control_remove(plci); + plci->Id = 0; + plci->State = IDLE; + plci->channels = 0; + plci->appl = NULL; + plci->notifiedcall = 0; + } + listen_check(plci->adapter); + return true; + } + } + return false; } /*------------------------------------------------------------------*/ -static byte plci_nl_busy (PLCI *plci) +static byte plci_nl_busy(PLCI *plci) { - /* only applicable for non-multiplexed protocols */ - return (plci->nl_req - || (plci->ncci_ring_list - && plci->adapter->ncci_ch[plci->ncci_ring_list] - && (plci->adapter->ch_flow_control[plci->adapter->ncci_ch[plci->ncci_ring_list]] & N_OK_FC_PENDING))); + /* only applicable for non-multiplexed protocols */ + return (plci->nl_req + || (plci->ncci_ring_list + && plci->adapter->ncci_ch[plci->ncci_ring_list] + && (plci->adapter->ch_flow_control[plci->adapter->ncci_ch[plci->ncci_ring_list]] & N_OK_FC_PENDING))); } @@ -9502,681 +9502,681 @@ static byte plci_nl_busy (PLCI *plci) static struct { - byte send_mask; - byte listen_mask; - byte character; - byte code; + byte send_mask; + byte listen_mask; + byte character; + byte code; } dtmf_digit_map[] = { - { 0x01, 0x01, 0x23, DTMF_DIGIT_TONE_CODE_HASHMARK }, - { 0x01, 0x01, 0x2a, DTMF_DIGIT_TONE_CODE_STAR }, - { 0x01, 0x01, 0x30, DTMF_DIGIT_TONE_CODE_0 }, - { 0x01, 0x01, 0x31, DTMF_DIGIT_TONE_CODE_1 }, - { 0x01, 0x01, 0x32, DTMF_DIGIT_TONE_CODE_2 }, - { 0x01, 0x01, 0x33, DTMF_DIGIT_TONE_CODE_3 }, - { 0x01, 0x01, 0x34, DTMF_DIGIT_TONE_CODE_4 }, - { 0x01, 0x01, 0x35, DTMF_DIGIT_TONE_CODE_5 }, - { 0x01, 0x01, 0x36, DTMF_DIGIT_TONE_CODE_6 }, - { 0x01, 0x01, 0x37, DTMF_DIGIT_TONE_CODE_7 }, - { 0x01, 0x01, 0x38, DTMF_DIGIT_TONE_CODE_8 }, - { 0x01, 0x01, 0x39, DTMF_DIGIT_TONE_CODE_9 }, - { 0x01, 0x01, 0x41, DTMF_DIGIT_TONE_CODE_A }, - { 0x01, 0x01, 0x42, DTMF_DIGIT_TONE_CODE_B }, - { 0x01, 0x01, 0x43, DTMF_DIGIT_TONE_CODE_C }, - { 0x01, 0x01, 0x44, DTMF_DIGIT_TONE_CODE_D }, - { 0x01, 0x00, 0x61, DTMF_DIGIT_TONE_CODE_A }, - { 0x01, 0x00, 0x62, DTMF_DIGIT_TONE_CODE_B }, - { 0x01, 0x00, 0x63, DTMF_DIGIT_TONE_CODE_C }, - { 0x01, 0x00, 0x64, DTMF_DIGIT_TONE_CODE_D }, - - { 0x04, 0x04, 0x80, DTMF_SIGNAL_NO_TONE }, - { 0x00, 0x04, 0x81, DTMF_SIGNAL_UNIDENTIFIED_TONE }, - { 0x04, 0x04, 0x82, DTMF_SIGNAL_DIAL_TONE }, - { 0x04, 0x04, 0x83, DTMF_SIGNAL_PABX_INTERNAL_DIAL_TONE }, - { 0x04, 0x04, 0x84, DTMF_SIGNAL_SPECIAL_DIAL_TONE }, - { 0x04, 0x04, 0x85, DTMF_SIGNAL_SECOND_DIAL_TONE }, - { 0x04, 0x04, 0x86, DTMF_SIGNAL_RINGING_TONE }, - { 0x04, 0x04, 0x87, DTMF_SIGNAL_SPECIAL_RINGING_TONE }, - { 0x04, 0x04, 0x88, DTMF_SIGNAL_BUSY_TONE }, - { 0x04, 0x04, 0x89, DTMF_SIGNAL_CONGESTION_TONE }, - { 0x04, 0x04, 0x8a, DTMF_SIGNAL_SPECIAL_INFORMATION_TONE }, - { 0x04, 0x04, 0x8b, DTMF_SIGNAL_COMFORT_TONE }, - { 0x04, 0x04, 0x8c, DTMF_SIGNAL_HOLD_TONE }, - { 0x04, 0x04, 0x8d, DTMF_SIGNAL_RECORD_TONE }, - { 0x04, 0x04, 0x8e, DTMF_SIGNAL_CALLER_WAITING_TONE }, - { 0x04, 0x04, 0x8f, DTMF_SIGNAL_CALL_WAITING_TONE }, - { 0x04, 0x04, 0x90, DTMF_SIGNAL_PAY_TONE }, - { 0x04, 0x04, 0x91, DTMF_SIGNAL_POSITIVE_INDICATION_TONE }, - { 0x04, 0x04, 0x92, DTMF_SIGNAL_NEGATIVE_INDICATION_TONE }, - { 0x04, 0x04, 0x93, DTMF_SIGNAL_WARNING_TONE }, - { 0x04, 0x04, 0x94, DTMF_SIGNAL_INTRUSION_TONE }, - { 0x04, 0x04, 0x95, DTMF_SIGNAL_CALLING_CARD_SERVICE_TONE }, - { 0x04, 0x04, 0x96, DTMF_SIGNAL_PAYPHONE_RECOGNITION_TONE }, - { 0x04, 0x04, 0x97, DTMF_SIGNAL_CPE_ALERTING_SIGNAL }, - { 0x04, 0x04, 0x98, DTMF_SIGNAL_OFF_HOOK_WARNING_TONE }, - { 0x04, 0x04, 0xbf, DTMF_SIGNAL_INTERCEPT_TONE }, - { 0x04, 0x04, 0xc0, DTMF_SIGNAL_MODEM_CALLING_TONE }, - { 0x04, 0x04, 0xc1, DTMF_SIGNAL_FAX_CALLING_TONE }, - { 0x04, 0x04, 0xc2, DTMF_SIGNAL_ANSWER_TONE }, - { 0x04, 0x04, 0xc3, DTMF_SIGNAL_REVERSED_ANSWER_TONE }, - { 0x04, 0x04, 0xc4, DTMF_SIGNAL_ANSAM_TONE }, - { 0x04, 0x04, 0xc5, DTMF_SIGNAL_REVERSED_ANSAM_TONE }, - { 0x04, 0x04, 0xc6, DTMF_SIGNAL_BELL103_ANSWER_TONE }, - { 0x04, 0x04, 0xc7, DTMF_SIGNAL_FAX_FLAGS }, - { 0x04, 0x04, 0xc8, DTMF_SIGNAL_G2_FAX_GROUP_ID }, - { 0x00, 0x04, 0xc9, DTMF_SIGNAL_HUMAN_SPEECH }, - { 0x04, 0x04, 0xca, DTMF_SIGNAL_ANSWERING_MACHINE_390 }, - { 0x02, 0x02, 0xf1, DTMF_MF_DIGIT_TONE_CODE_1 }, - { 0x02, 0x02, 0xf2, DTMF_MF_DIGIT_TONE_CODE_2 }, - { 0x02, 0x02, 0xf3, DTMF_MF_DIGIT_TONE_CODE_3 }, - { 0x02, 0x02, 0xf4, DTMF_MF_DIGIT_TONE_CODE_4 }, - { 0x02, 0x02, 0xf5, DTMF_MF_DIGIT_TONE_CODE_5 }, - { 0x02, 0x02, 0xf6, DTMF_MF_DIGIT_TONE_CODE_6 }, - { 0x02, 0x02, 0xf7, DTMF_MF_DIGIT_TONE_CODE_7 }, - { 0x02, 0x02, 0xf8, DTMF_MF_DIGIT_TONE_CODE_8 }, - { 0x02, 0x02, 0xf9, DTMF_MF_DIGIT_TONE_CODE_9 }, - { 0x02, 0x02, 0xfa, DTMF_MF_DIGIT_TONE_CODE_0 }, - { 0x02, 0x02, 0xfb, DTMF_MF_DIGIT_TONE_CODE_K1 }, - { 0x02, 0x02, 0xfc, DTMF_MF_DIGIT_TONE_CODE_K2 }, - { 0x02, 0x02, 0xfd, DTMF_MF_DIGIT_TONE_CODE_KP }, - { 0x02, 0x02, 0xfe, DTMF_MF_DIGIT_TONE_CODE_S1 }, - { 0x02, 0x02, 0xff, DTMF_MF_DIGIT_TONE_CODE_ST }, + { 0x01, 0x01, 0x23, DTMF_DIGIT_TONE_CODE_HASHMARK }, + { 0x01, 0x01, 0x2a, DTMF_DIGIT_TONE_CODE_STAR }, + { 0x01, 0x01, 0x30, DTMF_DIGIT_TONE_CODE_0 }, + { 0x01, 0x01, 0x31, DTMF_DIGIT_TONE_CODE_1 }, + { 0x01, 0x01, 0x32, DTMF_DIGIT_TONE_CODE_2 }, + { 0x01, 0x01, 0x33, DTMF_DIGIT_TONE_CODE_3 }, + { 0x01, 0x01, 0x34, DTMF_DIGIT_TONE_CODE_4 }, + { 0x01, 0x01, 0x35, DTMF_DIGIT_TONE_CODE_5 }, + { 0x01, 0x01, 0x36, DTMF_DIGIT_TONE_CODE_6 }, + { 0x01, 0x01, 0x37, DTMF_DIGIT_TONE_CODE_7 }, + { 0x01, 0x01, 0x38, DTMF_DIGIT_TONE_CODE_8 }, + { 0x01, 0x01, 0x39, DTMF_DIGIT_TONE_CODE_9 }, + { 0x01, 0x01, 0x41, DTMF_DIGIT_TONE_CODE_A }, + { 0x01, 0x01, 0x42, DTMF_DIGIT_TONE_CODE_B }, + { 0x01, 0x01, 0x43, DTMF_DIGIT_TONE_CODE_C }, + { 0x01, 0x01, 0x44, DTMF_DIGIT_TONE_CODE_D }, + { 0x01, 0x00, 0x61, DTMF_DIGIT_TONE_CODE_A }, + { 0x01, 0x00, 0x62, DTMF_DIGIT_TONE_CODE_B }, + { 0x01, 0x00, 0x63, DTMF_DIGIT_TONE_CODE_C }, + { 0x01, 0x00, 0x64, DTMF_DIGIT_TONE_CODE_D }, + + { 0x04, 0x04, 0x80, DTMF_SIGNAL_NO_TONE }, + { 0x00, 0x04, 0x81, DTMF_SIGNAL_UNIDENTIFIED_TONE }, + { 0x04, 0x04, 0x82, DTMF_SIGNAL_DIAL_TONE }, + { 0x04, 0x04, 0x83, DTMF_SIGNAL_PABX_INTERNAL_DIAL_TONE }, + { 0x04, 0x04, 0x84, DTMF_SIGNAL_SPECIAL_DIAL_TONE }, + { 0x04, 0x04, 0x85, DTMF_SIGNAL_SECOND_DIAL_TONE }, + { 0x04, 0x04, 0x86, DTMF_SIGNAL_RINGING_TONE }, + { 0x04, 0x04, 0x87, DTMF_SIGNAL_SPECIAL_RINGING_TONE }, + { 0x04, 0x04, 0x88, DTMF_SIGNAL_BUSY_TONE }, + { 0x04, 0x04, 0x89, DTMF_SIGNAL_CONGESTION_TONE }, + { 0x04, 0x04, 0x8a, DTMF_SIGNAL_SPECIAL_INFORMATION_TONE }, + { 0x04, 0x04, 0x8b, DTMF_SIGNAL_COMFORT_TONE }, + { 0x04, 0x04, 0x8c, DTMF_SIGNAL_HOLD_TONE }, + { 0x04, 0x04, 0x8d, DTMF_SIGNAL_RECORD_TONE }, + { 0x04, 0x04, 0x8e, DTMF_SIGNAL_CALLER_WAITING_TONE }, + { 0x04, 0x04, 0x8f, DTMF_SIGNAL_CALL_WAITING_TONE }, + { 0x04, 0x04, 0x90, DTMF_SIGNAL_PAY_TONE }, + { 0x04, 0x04, 0x91, DTMF_SIGNAL_POSITIVE_INDICATION_TONE }, + { 0x04, 0x04, 0x92, DTMF_SIGNAL_NEGATIVE_INDICATION_TONE }, + { 0x04, 0x04, 0x93, DTMF_SIGNAL_WARNING_TONE }, + { 0x04, 0x04, 0x94, DTMF_SIGNAL_INTRUSION_TONE }, + { 0x04, 0x04, 0x95, DTMF_SIGNAL_CALLING_CARD_SERVICE_TONE }, + { 0x04, 0x04, 0x96, DTMF_SIGNAL_PAYPHONE_RECOGNITION_TONE }, + { 0x04, 0x04, 0x97, DTMF_SIGNAL_CPE_ALERTING_SIGNAL }, + { 0x04, 0x04, 0x98, DTMF_SIGNAL_OFF_HOOK_WARNING_TONE }, + { 0x04, 0x04, 0xbf, DTMF_SIGNAL_INTERCEPT_TONE }, + { 0x04, 0x04, 0xc0, DTMF_SIGNAL_MODEM_CALLING_TONE }, + { 0x04, 0x04, 0xc1, DTMF_SIGNAL_FAX_CALLING_TONE }, + { 0x04, 0x04, 0xc2, DTMF_SIGNAL_ANSWER_TONE }, + { 0x04, 0x04, 0xc3, DTMF_SIGNAL_REVERSED_ANSWER_TONE }, + { 0x04, 0x04, 0xc4, DTMF_SIGNAL_ANSAM_TONE }, + { 0x04, 0x04, 0xc5, DTMF_SIGNAL_REVERSED_ANSAM_TONE }, + { 0x04, 0x04, 0xc6, DTMF_SIGNAL_BELL103_ANSWER_TONE }, + { 0x04, 0x04, 0xc7, DTMF_SIGNAL_FAX_FLAGS }, + { 0x04, 0x04, 0xc8, DTMF_SIGNAL_G2_FAX_GROUP_ID }, + { 0x00, 0x04, 0xc9, DTMF_SIGNAL_HUMAN_SPEECH }, + { 0x04, 0x04, 0xca, DTMF_SIGNAL_ANSWERING_MACHINE_390 }, + { 0x02, 0x02, 0xf1, DTMF_MF_DIGIT_TONE_CODE_1 }, + { 0x02, 0x02, 0xf2, DTMF_MF_DIGIT_TONE_CODE_2 }, + { 0x02, 0x02, 0xf3, DTMF_MF_DIGIT_TONE_CODE_3 }, + { 0x02, 0x02, 0xf4, DTMF_MF_DIGIT_TONE_CODE_4 }, + { 0x02, 0x02, 0xf5, DTMF_MF_DIGIT_TONE_CODE_5 }, + { 0x02, 0x02, 0xf6, DTMF_MF_DIGIT_TONE_CODE_6 }, + { 0x02, 0x02, 0xf7, DTMF_MF_DIGIT_TONE_CODE_7 }, + { 0x02, 0x02, 0xf8, DTMF_MF_DIGIT_TONE_CODE_8 }, + { 0x02, 0x02, 0xf9, DTMF_MF_DIGIT_TONE_CODE_9 }, + { 0x02, 0x02, 0xfa, DTMF_MF_DIGIT_TONE_CODE_0 }, + { 0x02, 0x02, 0xfb, DTMF_MF_DIGIT_TONE_CODE_K1 }, + { 0x02, 0x02, 0xfc, DTMF_MF_DIGIT_TONE_CODE_K2 }, + { 0x02, 0x02, 0xfd, DTMF_MF_DIGIT_TONE_CODE_KP }, + { 0x02, 0x02, 0xfe, DTMF_MF_DIGIT_TONE_CODE_S1 }, + { 0x02, 0x02, 0xff, DTMF_MF_DIGIT_TONE_CODE_ST }, }; #define DTMF_DIGIT_MAP_ENTRIES ARRAY_SIZE(dtmf_digit_map) -static void dtmf_enable_receiver (PLCI *plci, byte enable_mask) +static void dtmf_enable_receiver(PLCI *plci, byte enable_mask) { - word min_digit_duration, min_gap_duration; + word min_digit_duration, min_gap_duration; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_enable_receiver %02x", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, enable_mask)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_enable_receiver %02x", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, enable_mask)); - if (enable_mask != 0) - { - min_digit_duration = (plci->dtmf_rec_pulse_ms == 0) ? 40 : plci->dtmf_rec_pulse_ms; - min_gap_duration = (plci->dtmf_rec_pause_ms == 0) ? 40 : plci->dtmf_rec_pause_ms; - plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_ENABLE_RECEIVER; - PUT_WORD (&plci->internal_req_buffer[1], min_digit_duration); - PUT_WORD (&plci->internal_req_buffer[3], min_gap_duration); - plci->NData[0].PLength = 5; + if (enable_mask != 0) + { + min_digit_duration = (plci->dtmf_rec_pulse_ms == 0) ? 40 : plci->dtmf_rec_pulse_ms; + min_gap_duration = (plci->dtmf_rec_pause_ms == 0) ? 40 : plci->dtmf_rec_pause_ms; + plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_ENABLE_RECEIVER; + PUT_WORD(&plci->internal_req_buffer[1], min_digit_duration); + PUT_WORD(&plci->internal_req_buffer[3], min_gap_duration); + plci->NData[0].PLength = 5; - PUT_WORD (&plci->internal_req_buffer[5], INTERNAL_IND_BUFFER_SIZE); - plci->NData[0].PLength += 2; - capidtmf_recv_enable (&(plci->capidtmf_state), min_digit_duration, min_gap_duration); + PUT_WORD(&plci->internal_req_buffer[5], INTERNAL_IND_BUFFER_SIZE); + plci->NData[0].PLength += 2; + capidtmf_recv_enable(&(plci->capidtmf_state), min_digit_duration, min_gap_duration); - } - else - { - plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_DISABLE_RECEIVER; - plci->NData[0].PLength = 1; + } + else + { + plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_DISABLE_RECEIVER; + plci->NData[0].PLength = 1; - capidtmf_recv_disable (&(plci->capidtmf_state)); + capidtmf_recv_disable(&(plci->capidtmf_state)); - } - plci->NData[0].P = plci->internal_req_buffer; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_UDATA; - plci->adapter->request (&plci->NL); + } + plci->NData[0].P = plci->internal_req_buffer; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_UDATA; + plci->adapter->request(&plci->NL); } -static void dtmf_send_digits (PLCI *plci, byte *digit_buffer, word digit_count) +static void dtmf_send_digits(PLCI *plci, byte *digit_buffer, word digit_count) { - word w, i; + word w, i; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_send_digits %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, digit_count)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_send_digits %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, digit_count)); - plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_SEND_DIGITS; - w = (plci->dtmf_send_pulse_ms == 0) ? 40 : plci->dtmf_send_pulse_ms; - PUT_WORD (&plci->internal_req_buffer[1], w); - w = (plci->dtmf_send_pause_ms == 0) ? 40 : plci->dtmf_send_pause_ms; - PUT_WORD (&plci->internal_req_buffer[3], w); - for (i = 0; i < digit_count; i++) - { - w = 0; - while ((w < DTMF_DIGIT_MAP_ENTRIES) - && (digit_buffer[i] != dtmf_digit_map[w].character)) - { - w++; - } - plci->internal_req_buffer[5+i] = (w < DTMF_DIGIT_MAP_ENTRIES) ? - dtmf_digit_map[w].code : DTMF_DIGIT_TONE_CODE_STAR; - } - plci->NData[0].PLength = 5 + digit_count; - plci->NData[0].P = plci->internal_req_buffer; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_UDATA; - plci->adapter->request (&plci->NL); + plci->internal_req_buffer[0] = DTMF_UDATA_REQUEST_SEND_DIGITS; + w = (plci->dtmf_send_pulse_ms == 0) ? 40 : plci->dtmf_send_pulse_ms; + PUT_WORD(&plci->internal_req_buffer[1], w); + w = (plci->dtmf_send_pause_ms == 0) ? 40 : plci->dtmf_send_pause_ms; + PUT_WORD(&plci->internal_req_buffer[3], w); + for (i = 0; i < digit_count; i++) + { + w = 0; + while ((w < DTMF_DIGIT_MAP_ENTRIES) + && (digit_buffer[i] != dtmf_digit_map[w].character)) + { + w++; + } + plci->internal_req_buffer[5 + i] = (w < DTMF_DIGIT_MAP_ENTRIES) ? + dtmf_digit_map[w].code : DTMF_DIGIT_TONE_CODE_STAR; + } + plci->NData[0].PLength = 5 + digit_count; + plci->NData[0].P = plci->internal_req_buffer; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_UDATA; + plci->adapter->request(&plci->NL); } -static void dtmf_rec_clear_config (PLCI *plci) +static void dtmf_rec_clear_config(PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_rec_clear_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - plci->dtmf_rec_active = 0; - plci->dtmf_rec_pulse_ms = 0; - plci->dtmf_rec_pause_ms = 0; - - capidtmf_init (&(plci->capidtmf_state), plci->adapter->u_law); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_rec_clear_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); -} - - -static void dtmf_send_clear_config (PLCI *plci) -{ + plci->dtmf_rec_active = 0; + plci->dtmf_rec_pulse_ms = 0; + plci->dtmf_rec_pause_ms = 0; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_send_clear_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); + capidtmf_init(&(plci->capidtmf_state), plci->adapter->u_law); - plci->dtmf_send_requests = 0; - plci->dtmf_send_pulse_ms = 0; - plci->dtmf_send_pause_ms = 0; } -static void dtmf_prepare_switch (dword Id, PLCI *plci) +static void dtmf_send_clear_config(PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_prepare_switch", - UnMapId (Id), (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_send_clear_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); - while (plci->dtmf_send_requests != 0) - dtmf_confirmation (Id, plci); + plci->dtmf_send_requests = 0; + plci->dtmf_send_pulse_ms = 0; + plci->dtmf_send_pause_ms = 0; } -static word dtmf_save_config (dword Id, PLCI *plci, byte Rc) +static void dtmf_prepare_switch(dword Id, PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_save_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_prepare_switch", + UnMapId(Id), (char *)(FILE_), __LINE__)); - return (GOOD); + while (plci->dtmf_send_requests != 0) + dtmf_confirmation(Id, plci); } -static word dtmf_restore_config (dword Id, PLCI *plci, byte Rc) +static word dtmf_save_config(dword Id, PLCI *plci, byte Rc) { - word Info; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_restore_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_save_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - Info = GOOD; - if (plci->B1_facilities & B1_FACILITY_DTMFR) - { - switch (plci->adjust_b_state) - { - case ADJUST_B_RESTORE_DTMF_1: - plci->internal_command = plci->adjust_b_command; - if (plci_nl_busy (plci)) - { - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; - break; - } - dtmf_enable_receiver (plci, plci->dtmf_rec_active); - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_2; - break; - case ADJUST_B_RESTORE_DTMF_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Reenable DTMF receiver failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - break; - } - } - return (Info); + return (GOOD); } -static void dtmf_command (dword Id, PLCI *plci, byte Rc) +static word dtmf_restore_config(dword Id, PLCI *plci, byte Rc) { - word internal_command, Info; - byte mask; - byte result[4]; + word Info; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_command %02x %04x %04x %d %d %d %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command, - plci->dtmf_cmd, plci->dtmf_rec_pulse_ms, plci->dtmf_rec_pause_ms, - plci->dtmf_send_pulse_ms, plci->dtmf_send_pause_ms)); - - Info = GOOD; - result[0] = 2; - PUT_WORD (&result[1], DTMF_SUCCESS); - internal_command = plci->internal_command; - plci->internal_command = 0; - mask = 0x01; - switch (plci->dtmf_cmd) - { + dbug(1, dprintf("[%06lx] %s,%d: dtmf_restore_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - case DTMF_LISTEN_TONE_START: - mask <<= 1; - case DTMF_LISTEN_MF_START: - mask <<= 1; - - case DTMF_LISTEN_START: - switch (internal_command) - { - default: - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities | - B1_FACILITY_DTMFR), DTMF_COMMAND_1); - case DTMF_COMMAND_1: - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Load DTMF failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (plci->internal_command) - return; - case DTMF_COMMAND_2: - if (plci_nl_busy (plci)) - { - plci->internal_command = DTMF_COMMAND_2; - return; - } - plci->internal_command = DTMF_COMMAND_3; - dtmf_enable_receiver (plci, (byte)(plci->dtmf_rec_active | mask)); - return; - case DTMF_COMMAND_3: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Enable DTMF receiver failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - - plci->tone_last_indication_code = DTMF_SIGNAL_NO_TONE; - - plci->dtmf_rec_active |= mask; - break; - } - break; - - - case DTMF_LISTEN_TONE_STOP: - mask <<= 1; - case DTMF_LISTEN_MF_STOP: - mask <<= 1; - - case DTMF_LISTEN_STOP: - switch (internal_command) - { - default: - plci->dtmf_rec_active &= ~mask; - if (plci->dtmf_rec_active) - break; -/* - case DTMF_COMMAND_1: - if (plci->dtmf_rec_active) - { - if (plci_nl_busy (plci)) - { - plci->internal_command = DTMF_COMMAND_1; - return; - } - plci->dtmf_rec_active &= ~mask; - plci->internal_command = DTMF_COMMAND_2; - dtmf_enable_receiver (plci, false); - return; - } - Rc = OK; - case DTMF_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Disable DTMF receiver failed %02x", - UnMapId (Id), (char far *)(FILE_), __LINE__, Rc)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } -*/ - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities & - ~(B1_FACILITY_DTMFX | B1_FACILITY_DTMFR)), DTMF_COMMAND_3); - case DTMF_COMMAND_3: - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Unload DTMF failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (plci->internal_command) - return; - break; - } - break; - - - case DTMF_SEND_TONE: - mask <<= 1; - case DTMF_SEND_MF: - mask <<= 1; - - case DTMF_DIGITS_SEND: - switch (internal_command) - { - default: - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities | - ((plci->dtmf_parameter_length != 0) ? B1_FACILITY_DTMFX | B1_FACILITY_DTMFR : B1_FACILITY_DTMFX)), - DTMF_COMMAND_1); - case DTMF_COMMAND_1: - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Load DTMF failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (plci->internal_command) - return; - case DTMF_COMMAND_2: - if (plci_nl_busy (plci)) - { - plci->internal_command = DTMF_COMMAND_2; - return; - } - plci->dtmf_msg_number_queue[(plci->dtmf_send_requests)++] = plci->number; - plci->internal_command = DTMF_COMMAND_3; - dtmf_send_digits (plci, &plci->saved_msg.parms[3].info[1], plci->saved_msg.parms[3].length); - return; - case DTMF_COMMAND_3: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Send DTMF digits failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - if (plci->dtmf_send_requests != 0) - (plci->dtmf_send_requests)--; - Info = _FACILITY_NOT_SUPPORTED; - break; - } - return; - } - break; - } - sendf (plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->number, - "wws", Info, SELECTOR_DTMF, result); + Info = GOOD; + if (plci->B1_facilities & B1_FACILITY_DTMFR) + { + switch (plci->adjust_b_state) + { + case ADJUST_B_RESTORE_DTMF_1: + plci->internal_command = plci->adjust_b_command; + if (plci_nl_busy(plci)) + { + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; + break; + } + dtmf_enable_receiver(plci, plci->dtmf_rec_active); + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_2; + break; + case ADJUST_B_RESTORE_DTMF_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Reenable DTMF receiver failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + break; + } + } + return (Info); } -static byte dtmf_request (dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) +static void dtmf_command(dword Id, PLCI *plci, byte Rc) { - word Info; - word i, j; - byte mask; - API_PARSE dtmf_parms[5]; - byte result[40]; + word internal_command, Info; + byte mask; + byte result[4]; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_request", - UnMapId (Id), (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_command %02x %04x %04x %d %d %d %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command, + plci->dtmf_cmd, plci->dtmf_rec_pulse_ms, plci->dtmf_rec_pause_ms, + plci->dtmf_send_pulse_ms, plci->dtmf_send_pause_ms)); - Info = GOOD; - result[0] = 2; - PUT_WORD (&result[1], DTMF_SUCCESS); - if (!(a->profile.Global_Options & GL_DTMF_SUPPORTED)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Facility not supported", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - } - else if (api_parse (&msg[1].info[1], msg[1].length, "w", dtmf_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - } + Info = GOOD; + result[0] = 2; + PUT_WORD(&result[1], DTMF_SUCCESS); + internal_command = plci->internal_command; + plci->internal_command = 0; + mask = 0x01; + switch (plci->dtmf_cmd) + { - else if ((GET_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES) - || (GET_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_SEND_CODES)) - { - if (!((a->requested_options_table[appl->Id-1]) - & (1L << PRIVATE_DTMF_TONE))) - { - dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, GET_WORD (dtmf_parms[0].info))); - PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST); - } - else - { - for (i = 0; i < 32; i++) - result[4 + i] = 0; - if (GET_WORD (dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES) - { - for (i = 0; i < DTMF_DIGIT_MAP_ENTRIES; i++) - { - if (dtmf_digit_map[i].listen_mask != 0) - result[4 + (dtmf_digit_map[i].character >> 3)] |= (1 << (dtmf_digit_map[i].character & 0x7)); - } - } - else - { - for (i = 0; i < DTMF_DIGIT_MAP_ENTRIES; i++) - { - if (dtmf_digit_map[i].send_mask != 0) - result[4 + (dtmf_digit_map[i].character >> 3)] |= (1 << (dtmf_digit_map[i].character & 0x7)); - } - } - result[0] = 3 + 32; - result[3] = 32; - } - } + case DTMF_LISTEN_TONE_START: + mask <<= 1; + case DTMF_LISTEN_MF_START: + mask <<= 1; - else if (plci == NULL) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong PLCI", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_IDENTIFIER; - } - else + case DTMF_LISTEN_START: + switch (internal_command) + { + default: + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities | + B1_FACILITY_DTMFR), DTMF_COMMAND_1); + case DTMF_COMMAND_1: + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Load DTMF failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (plci->internal_command) + return; + case DTMF_COMMAND_2: + if (plci_nl_busy(plci)) + { + plci->internal_command = DTMF_COMMAND_2; + return; + } + plci->internal_command = DTMF_COMMAND_3; + dtmf_enable_receiver(plci, (byte)(plci->dtmf_rec_active | mask)); + return; + case DTMF_COMMAND_3: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Enable DTMF receiver failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + + plci->tone_last_indication_code = DTMF_SIGNAL_NO_TONE; + + plci->dtmf_rec_active |= mask; + break; + } + break; + + + case DTMF_LISTEN_TONE_STOP: + mask <<= 1; + case DTMF_LISTEN_MF_STOP: + mask <<= 1; + + case DTMF_LISTEN_STOP: + switch (internal_command) + { + default: + plci->dtmf_rec_active &= ~mask; + if (plci->dtmf_rec_active) + break; +/* + case DTMF_COMMAND_1: + if (plci->dtmf_rec_active) { - if (!plci->State - || !plci->NL.Id || plci->nl_remove_id) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong state", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_STATE; - } - else - { - plci->command = 0; - plci->dtmf_cmd = GET_WORD (dtmf_parms[0].info); - mask = 0x01; - switch (plci->dtmf_cmd) - { - - case DTMF_LISTEN_TONE_START: - case DTMF_LISTEN_TONE_STOP: - mask <<= 1; - case DTMF_LISTEN_MF_START: - case DTMF_LISTEN_MF_STOP: - mask <<= 1; - if (!((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[appl->Id-1]) - & (1L << PRIVATE_DTMF_TONE))) - { - dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, GET_WORD (dtmf_parms[0].info))); - PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST); - break; - } - - case DTMF_LISTEN_START: - case DTMF_LISTEN_STOP: - if (!(a->manufacturer_features & MANUFACTURER_FEATURE_HARDDTMF) - && !(a->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Facility not supported", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (mask & DTMF_LISTEN_ACTIVE_FLAG) - { - if (api_parse (&msg[1].info[1], msg[1].length, "wwws", dtmf_parms)) - { - plci->dtmf_rec_pulse_ms = 0; - plci->dtmf_rec_pause_ms = 0; - } - else - { - plci->dtmf_rec_pulse_ms = GET_WORD (dtmf_parms[1].info); - plci->dtmf_rec_pause_ms = GET_WORD (dtmf_parms[2].info); - } - } - start_internal_command (Id, plci, dtmf_command); - return (false); - - - case DTMF_SEND_TONE: - mask <<= 1; - case DTMF_SEND_MF: - mask <<= 1; - if (!((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[appl->Id-1]) - & (1L << PRIVATE_DTMF_TONE))) - { - dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, GET_WORD (dtmf_parms[0].info))); - PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST); - break; - } - - case DTMF_DIGITS_SEND: - if (api_parse (&msg[1].info[1], msg[1].length, "wwws", dtmf_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - if (mask & DTMF_LISTEN_ACTIVE_FLAG) - { - plci->dtmf_send_pulse_ms = GET_WORD (dtmf_parms[1].info); - plci->dtmf_send_pause_ms = GET_WORD (dtmf_parms[2].info); - } - i = 0; - j = 0; - while ((i < dtmf_parms[3].length) && (j < DTMF_DIGIT_MAP_ENTRIES)) - { - j = 0; - while ((j < DTMF_DIGIT_MAP_ENTRIES) - && ((dtmf_parms[3].info[i+1] != dtmf_digit_map[j].character) - || ((dtmf_digit_map[j].send_mask & mask) == 0))) - { - j++; - } - i++; - } - if (j == DTMF_DIGIT_MAP_ENTRIES) - { - dbug (1, dprintf ("[%06lx] %s,%d: Incorrect DTMF digit %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, dtmf_parms[3].info[i])); - PUT_WORD (&result[1], DTMF_INCORRECT_DIGIT); - break; - } - if (plci->dtmf_send_requests >= ARRAY_SIZE(plci->dtmf_msg_number_queue)) - { - dbug (1, dprintf ("[%06lx] %s,%d: DTMF request overrun", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_STATE; - break; - } - api_save_msg (dtmf_parms, "wwws", &plci->saved_msg); - start_internal_command (Id, plci, dtmf_command); - return (false); - - default: - dbug (1, dprintf ("[%06lx] %s,%d: DTMF unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, plci->dtmf_cmd)); - PUT_WORD (&result[1], DTMF_UNKNOWN_REQUEST); - } - } - } - sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, - "wws", Info, SELECTOR_DTMF, result); - return (false); -} - - -static void dtmf_confirmation (dword Id, PLCI *plci) -{ - word i; - byte result[4]; - - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_confirmation", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - result[0] = 2; - PUT_WORD (&result[1], DTMF_SUCCESS); - if (plci->dtmf_send_requests != 0) + if (plci_nl_busy (plci)) { - sendf (plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->dtmf_msg_number_queue[0], - "wws", GOOD, SELECTOR_DTMF, result); - (plci->dtmf_send_requests)--; - for (i = 0; i < plci->dtmf_send_requests; i++) - plci->dtmf_msg_number_queue[i] = plci->dtmf_msg_number_queue[i+1]; + plci->internal_command = DTMF_COMMAND_1; + return; } -} - - -static void dtmf_indication (dword Id, PLCI *plci, byte *msg, word length) -{ - word i, j, n; - - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_indication", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - n = 0; - for (i = 1; i < length; i++) - { - j = 0; - while ((j < DTMF_DIGIT_MAP_ENTRIES) - && ((msg[i] != dtmf_digit_map[j].code) - || ((dtmf_digit_map[j].listen_mask & plci->dtmf_rec_active) == 0))) - { - j++; - } - if (j < DTMF_DIGIT_MAP_ENTRIES) - { - - if ((dtmf_digit_map[j].listen_mask & DTMF_TONE_LISTEN_ACTIVE_FLAG) - && (plci->tone_last_indication_code == DTMF_SIGNAL_NO_TONE) - && (dtmf_digit_map[j].character != DTMF_SIGNAL_UNIDENTIFIED_TONE)) - { - if (n + 1 == i) - { - for (i = length; i > n + 1; i--) - msg[i] = msg[i - 1]; - length++; - i++; - } - msg[++n] = DTMF_SIGNAL_UNIDENTIFIED_TONE; - } - plci->tone_last_indication_code = dtmf_digit_map[j].character; - - msg[++n] = dtmf_digit_map[j].character; - } + plci->dtmf_rec_active &= ~mask; + plci->internal_command = DTMF_COMMAND_2; + dtmf_enable_receiver (plci, false); + return; } - if (n != 0) + Rc = OK; + case DTMF_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) { - msg[0] = (byte) n; - sendf (plci->appl, _FACILITY_I, Id & 0xffffL, 0, "wS", SELECTOR_DTMF, msg); + dbug (1, dprintf("[%06lx] %s,%d: Disable DTMF receiver failed %02x", + UnMapId (Id), (char far *)(FILE_), __LINE__, Rc)); + Info = _FACILITY_NOT_SUPPORTED; + break; } +*/ + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities & + ~(B1_FACILITY_DTMFX | B1_FACILITY_DTMFR)), DTMF_COMMAND_3); + case DTMF_COMMAND_3: + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Unload DTMF failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (plci->internal_command) + return; + break; + } + break; + + + case DTMF_SEND_TONE: + mask <<= 1; + case DTMF_SEND_MF: + mask <<= 1; + + case DTMF_DIGITS_SEND: + switch (internal_command) + { + default: + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities | + ((plci->dtmf_parameter_length != 0) ? B1_FACILITY_DTMFX | B1_FACILITY_DTMFR : B1_FACILITY_DTMFX)), + DTMF_COMMAND_1); + case DTMF_COMMAND_1: + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Load DTMF failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (plci->internal_command) + return; + case DTMF_COMMAND_2: + if (plci_nl_busy(plci)) + { + plci->internal_command = DTMF_COMMAND_2; + return; + } + plci->dtmf_msg_number_queue[(plci->dtmf_send_requests)++] = plci->number; + plci->internal_command = DTMF_COMMAND_3; + dtmf_send_digits(plci, &plci->saved_msg.parms[3].info[1], plci->saved_msg.parms[3].length); + return; + case DTMF_COMMAND_3: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Send DTMF digits failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + if (plci->dtmf_send_requests != 0) + (plci->dtmf_send_requests)--; + Info = _FACILITY_NOT_SUPPORTED; + break; + } + return; + } + break; + } + sendf(plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->number, + "wws", Info, SELECTOR_DTMF, result); +} + + +static byte dtmf_request(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) +{ + word Info; + word i, j; + byte mask; + API_PARSE dtmf_parms[5]; + byte result[40]; + + dbug(1, dprintf("[%06lx] %s,%d: dtmf_request", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + Info = GOOD; + result[0] = 2; + PUT_WORD(&result[1], DTMF_SUCCESS); + if (!(a->profile.Global_Options & GL_DTMF_SUPPORTED)) + { + dbug(1, dprintf("[%06lx] %s,%d: Facility not supported", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + } + else if (api_parse(&msg[1].info[1], msg[1].length, "w", dtmf_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + } + + else if ((GET_WORD(dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES) + || (GET_WORD(dtmf_parms[0].info) == DTMF_GET_SUPPORTED_SEND_CODES)) + { + if (!((a->requested_options_table[appl->Id - 1]) + & (1L << PRIVATE_DTMF_TONE))) + { + dbug(1, dprintf("[%06lx] %s,%d: DTMF unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, GET_WORD(dtmf_parms[0].info))); + PUT_WORD(&result[1], DTMF_UNKNOWN_REQUEST); + } + else + { + for (i = 0; i < 32; i++) + result[4 + i] = 0; + if (GET_WORD(dtmf_parms[0].info) == DTMF_GET_SUPPORTED_DETECT_CODES) + { + for (i = 0; i < DTMF_DIGIT_MAP_ENTRIES; i++) + { + if (dtmf_digit_map[i].listen_mask != 0) + result[4 + (dtmf_digit_map[i].character >> 3)] |= (1 << (dtmf_digit_map[i].character & 0x7)); + } + } + else + { + for (i = 0; i < DTMF_DIGIT_MAP_ENTRIES; i++) + { + if (dtmf_digit_map[i].send_mask != 0) + result[4 + (dtmf_digit_map[i].character >> 3)] |= (1 << (dtmf_digit_map[i].character & 0x7)); + } + } + result[0] = 3 + 32; + result[3] = 32; + } + } + + else if (plci == NULL) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong PLCI", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_IDENTIFIER; + } + else + { + if (!plci->State + || !plci->NL.Id || plci->nl_remove_id) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong state", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_STATE; + } + else + { + plci->command = 0; + plci->dtmf_cmd = GET_WORD(dtmf_parms[0].info); + mask = 0x01; + switch (plci->dtmf_cmd) + { + + case DTMF_LISTEN_TONE_START: + case DTMF_LISTEN_TONE_STOP: + mask <<= 1; + case DTMF_LISTEN_MF_START: + case DTMF_LISTEN_MF_STOP: + mask <<= 1; + if (!((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[appl->Id - 1]) + & (1L << PRIVATE_DTMF_TONE))) + { + dbug(1, dprintf("[%06lx] %s,%d: DTMF unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, GET_WORD(dtmf_parms[0].info))); + PUT_WORD(&result[1], DTMF_UNKNOWN_REQUEST); + break; + } + + case DTMF_LISTEN_START: + case DTMF_LISTEN_STOP: + if (!(a->manufacturer_features & MANUFACTURER_FEATURE_HARDDTMF) + && !(a->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE)) + { + dbug(1, dprintf("[%06lx] %s,%d: Facility not supported", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (mask & DTMF_LISTEN_ACTIVE_FLAG) + { + if (api_parse(&msg[1].info[1], msg[1].length, "wwws", dtmf_parms)) + { + plci->dtmf_rec_pulse_ms = 0; + plci->dtmf_rec_pause_ms = 0; + } + else + { + plci->dtmf_rec_pulse_ms = GET_WORD(dtmf_parms[1].info); + plci->dtmf_rec_pause_ms = GET_WORD(dtmf_parms[2].info); + } + } + start_internal_command(Id, plci, dtmf_command); + return (false); + + + case DTMF_SEND_TONE: + mask <<= 1; + case DTMF_SEND_MF: + mask <<= 1; + if (!((plci->requested_options_conn | plci->requested_options | plci->adapter->requested_options_table[appl->Id - 1]) + & (1L << PRIVATE_DTMF_TONE))) + { + dbug(1, dprintf("[%06lx] %s,%d: DTMF unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, GET_WORD(dtmf_parms[0].info))); + PUT_WORD(&result[1], DTMF_UNKNOWN_REQUEST); + break; + } + + case DTMF_DIGITS_SEND: + if (api_parse(&msg[1].info[1], msg[1].length, "wwws", dtmf_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + if (mask & DTMF_LISTEN_ACTIVE_FLAG) + { + plci->dtmf_send_pulse_ms = GET_WORD(dtmf_parms[1].info); + plci->dtmf_send_pause_ms = GET_WORD(dtmf_parms[2].info); + } + i = 0; + j = 0; + while ((i < dtmf_parms[3].length) && (j < DTMF_DIGIT_MAP_ENTRIES)) + { + j = 0; + while ((j < DTMF_DIGIT_MAP_ENTRIES) + && ((dtmf_parms[3].info[i + 1] != dtmf_digit_map[j].character) + || ((dtmf_digit_map[j].send_mask & mask) == 0))) + { + j++; + } + i++; + } + if (j == DTMF_DIGIT_MAP_ENTRIES) + { + dbug(1, dprintf("[%06lx] %s,%d: Incorrect DTMF digit %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, dtmf_parms[3].info[i])); + PUT_WORD(&result[1], DTMF_INCORRECT_DIGIT); + break; + } + if (plci->dtmf_send_requests >= ARRAY_SIZE(plci->dtmf_msg_number_queue)) + { + dbug(1, dprintf("[%06lx] %s,%d: DTMF request overrun", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_STATE; + break; + } + api_save_msg(dtmf_parms, "wwws", &plci->saved_msg); + start_internal_command(Id, plci, dtmf_command); + return (false); + + default: + dbug(1, dprintf("[%06lx] %s,%d: DTMF unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, plci->dtmf_cmd)); + PUT_WORD(&result[1], DTMF_UNKNOWN_REQUEST); + } + } + } + sendf(appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, + "wws", Info, SELECTOR_DTMF, result); + return (false); +} + + +static void dtmf_confirmation(dword Id, PLCI *plci) +{ + word i; + byte result[4]; + + dbug(1, dprintf("[%06lx] %s,%d: dtmf_confirmation", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + result[0] = 2; + PUT_WORD(&result[1], DTMF_SUCCESS); + if (plci->dtmf_send_requests != 0) + { + sendf(plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->dtmf_msg_number_queue[0], + "wws", GOOD, SELECTOR_DTMF, result); + (plci->dtmf_send_requests)--; + for (i = 0; i < plci->dtmf_send_requests; i++) + plci->dtmf_msg_number_queue[i] = plci->dtmf_msg_number_queue[i + 1]; + } +} + + +static void dtmf_indication(dword Id, PLCI *plci, byte *msg, word length) +{ + word i, j, n; + + dbug(1, dprintf("[%06lx] %s,%d: dtmf_indication", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + n = 0; + for (i = 1; i < length; i++) + { + j = 0; + while ((j < DTMF_DIGIT_MAP_ENTRIES) + && ((msg[i] != dtmf_digit_map[j].code) + || ((dtmf_digit_map[j].listen_mask & plci->dtmf_rec_active) == 0))) + { + j++; + } + if (j < DTMF_DIGIT_MAP_ENTRIES) + { + + if ((dtmf_digit_map[j].listen_mask & DTMF_TONE_LISTEN_ACTIVE_FLAG) + && (plci->tone_last_indication_code == DTMF_SIGNAL_NO_TONE) + && (dtmf_digit_map[j].character != DTMF_SIGNAL_UNIDENTIFIED_TONE)) + { + if (n + 1 == i) + { + for (i = length; i > n + 1; i--) + msg[i] = msg[i - 1]; + length++; + i++; + } + msg[++n] = DTMF_SIGNAL_UNIDENTIFIED_TONE; + } + plci->tone_last_indication_code = dtmf_digit_map[j].character; + + msg[++n] = dtmf_digit_map[j].character; + } + } + if (n != 0) + { + msg[0] = (byte) n; + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, "wS", SELECTOR_DTMF, msg); + } } @@ -10184,90 +10184,90 @@ static void dtmf_indication (dword Id, PLCI *plci, byte *msg, word length) /* DTMF parameters */ /*------------------------------------------------------------------*/ -static void dtmf_parameter_write (PLCI *plci) +static void dtmf_parameter_write(PLCI *plci) { - word i; - byte parameter_buffer[DTMF_PARAMETER_BUFFER_SIZE + 2]; + word i; + byte parameter_buffer[DTMF_PARAMETER_BUFFER_SIZE + 2]; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_parameter_write", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_parameter_write", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); - parameter_buffer[0] = plci->dtmf_parameter_length + 1; - parameter_buffer[1] = DSP_CTRL_SET_DTMF_PARAMETERS; - for (i = 0; i < plci->dtmf_parameter_length; i++) - parameter_buffer[2+i] = plci->dtmf_parameter_buffer[i]; - add_p (plci, FTY, parameter_buffer); - sig_req (plci, TEL_CTRL, 0); - send_req (plci); + parameter_buffer[0] = plci->dtmf_parameter_length + 1; + parameter_buffer[1] = DSP_CTRL_SET_DTMF_PARAMETERS; + for (i = 0; i < plci->dtmf_parameter_length; i++) + parameter_buffer[2 + i] = plci->dtmf_parameter_buffer[i]; + add_p(plci, FTY, parameter_buffer); + sig_req(plci, TEL_CTRL, 0); + send_req(plci); } -static void dtmf_parameter_clear_config (PLCI *plci) +static void dtmf_parameter_clear_config(PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_parameter_clear_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_parameter_clear_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); - plci->dtmf_parameter_length = 0; + plci->dtmf_parameter_length = 0; } -static void dtmf_parameter_prepare_switch (dword Id, PLCI *plci) +static void dtmf_parameter_prepare_switch(dword Id, PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_parameter_prepare_switch", - UnMapId (Id), (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_parameter_prepare_switch", + UnMapId(Id), (char *)(FILE_), __LINE__)); } -static word dtmf_parameter_save_config (dword Id, PLCI *plci, byte Rc) +static word dtmf_parameter_save_config(dword Id, PLCI *plci, byte Rc) { - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_parameter_save_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_parameter_save_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - return (GOOD); + return (GOOD); } -static word dtmf_parameter_restore_config (dword Id, PLCI *plci, byte Rc) +static word dtmf_parameter_restore_config(dword Id, PLCI *plci, byte Rc) { - word Info; + word Info; - dbug (1, dprintf ("[%06lx] %s,%d: dtmf_parameter_restore_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + dbug(1, dprintf("[%06lx] %s,%d: dtmf_parameter_restore_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - Info = GOOD; - if ((plci->B1_facilities & B1_FACILITY_DTMFR) - && (plci->dtmf_parameter_length != 0)) - { - switch (plci->adjust_b_state) - { - case ADJUST_B_RESTORE_DTMF_PARAMETER_1: - plci->internal_command = plci->adjust_b_command; - if (plci->sig_req) - { - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_PARAMETER_1; - break; - } - dtmf_parameter_write (plci); - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_PARAMETER_2; - break; - case ADJUST_B_RESTORE_DTMF_PARAMETER_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Restore DTMF parameters failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - break; - } - } - return (Info); + Info = GOOD; + if ((plci->B1_facilities & B1_FACILITY_DTMFR) + && (plci->dtmf_parameter_length != 0)) + { + switch (plci->adjust_b_state) + { + case ADJUST_B_RESTORE_DTMF_PARAMETER_1: + plci->internal_command = plci->adjust_b_command; + if (plci->sig_req) + { + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_PARAMETER_1; + break; + } + dtmf_parameter_write(plci); + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_PARAMETER_2; + break; + case ADJUST_B_RESTORE_DTMF_PARAMETER_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Restore DTMF parameters failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + break; + } + } + return (Info); } @@ -10290,3059 +10290,3059 @@ word li_total_channels; /* if channels is provided we accept more than one channel. */ /*------------------------------------------------------------------*/ -static byte chi_to_channel (byte *chi, dword *pchannelmap) -{ - int p; - int i; - dword map; - byte excl; - byte ofs; - byte ch; - - if (pchannelmap) *pchannelmap = 0; - if(!chi[0]) return 0xff; - excl = 0; - - if(chi[1] & 0x20) { - if(chi[0]==1 && chi[1]==0xac) return 0xfd; /* exclusive d-channel */ - for(i=1; i30) return 0xfe; - map = 0; - for(i=p; i<=chi[0]; i++) { - if ((chi[i] &0x7f) > 31) return 0xfe; - map |= (1L << (chi[i] &0x7f)); - } - } - else { - if(p!=chi[0]) return 0xfe; - if (ch > 31) return 0xfe; - map = (1L << ch); - } - if(chi[p] &0x40) return 0xfe; - } - if (pchannelmap) *pchannelmap = map; - else if (map != ((dword)(1L << ch))) return 0xfe; - return (byte)(excl | ch); - } - else { /* not PRI */ - for(i=1; i 30) return 0xfe; + map = 0; + for (i = p; i <= chi[0]; i++) { + if ((chi[i] & 0x7f) > 31) return 0xfe; + map |= (1L << (chi[i] & 0x7f)); + } + } + else { + if (p != chi[0]) return 0xfe; + if (ch > 31) return 0xfe; + map = (1L << ch); + } + if (chi[p] & 0x40) return 0xfe; + } + if (pchannelmap) *pchannelmap = map; + else if (map != ((dword)(1L << ch))) return 0xfe; + return (byte)(excl | ch); + } + else { /* not PRI */ + for (i = 1; i < chi[0] && !(chi[i] & 0x80); i++); + if (i != chi[0] || !(chi[i] & 0x80)) return 0xfe; + if (chi[1] & 0x08) excl = 0x40; + + switch (chi[1] | 0x98) { + case 0x98: return 0; + case 0x99: + if (pchannelmap) *pchannelmap = 2; + return excl | 1; + case 0x9a: + if (pchannelmap) *pchannelmap = 4; + return excl | 2; + case 0x9b: return 0xff; + case 0x9c: return 0xfd; /* d-ch */ + default: return 0xfe; + } + } +} + + +static void mixer_set_bchannel_id_esc(PLCI *plci, byte bchannel_id) +{ + DIVA_CAPI_ADAPTER *a; + PLCI *splci; + byte old_id; + + a = plci->adapter; + old_id = plci->li_bchannel_id; + if (a->li_pri) + { + if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) + li_config_table[a->li_base + (old_id - 1)].plci = NULL; + plci->li_bchannel_id = (bchannel_id & 0x1f) + 1; + if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) + li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; + } + else + { + if (((bchannel_id & 0x03) == 1) || ((bchannel_id & 0x03) == 2)) + { + if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) + li_config_table[a->li_base + (old_id - 1)].plci = NULL; + plci->li_bchannel_id = bchannel_id & 0x03; + if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI != plci) && (a->AdvSignalPLCI->tel == ADV_VOICE)) + { + splci = a->AdvSignalPLCI; + if (li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci == NULL) + { + if ((splci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci == splci)) + { + li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci = NULL; + } + splci->li_bchannel_id = 3 - plci->li_bchannel_id; + li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci = splci; + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_set_bchannel_id_esc %d", + (dword)((splci->Id << 8) | UnMapController(splci->adapter->Id)), + (char *)(FILE_), __LINE__, splci->li_bchannel_id)); + } + } + if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) + li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; + } + } + if ((old_id == 0) && (plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + mixer_clear_config(plci); + } + dbug(1, dprintf("[%06lx] %s,%d: mixer_set_bchannel_id_esc %d %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, bchannel_id, plci->li_bchannel_id)); +} + + +static void mixer_set_bchannel_id(PLCI *plci, byte *chi) +{ + DIVA_CAPI_ADAPTER *a; + PLCI *splci; + byte ch, old_id; + + a = plci->adapter; + old_id = plci->li_bchannel_id; + ch = chi_to_channel(chi, NULL); + if (!(ch & 0x80)) + { + if (a->li_pri) + { + if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) + li_config_table[a->li_base + (old_id - 1)].plci = NULL; + plci->li_bchannel_id = (ch & 0x1f) + 1; + if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) + li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; + } + else + { + if (((ch & 0x1f) == 1) || ((ch & 0x1f) == 2)) + { + if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) + li_config_table[a->li_base + (old_id - 1)].plci = NULL; + plci->li_bchannel_id = ch & 0x1f; + if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI != plci) && (a->AdvSignalPLCI->tel == ADV_VOICE)) + { + splci = a->AdvSignalPLCI; + if (li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci == NULL) + { + if ((splci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci == splci)) + { + li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci = NULL; + } + splci->li_bchannel_id = 3 - plci->li_bchannel_id; + li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci = splci; + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_set_bchannel_id %d", + (dword)((splci->Id << 8) | UnMapController(splci->adapter->Id)), + (char *)(FILE_), __LINE__, splci->li_bchannel_id)); + } + } + if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) + li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; + } + } + } + if ((old_id == 0) && (plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + mixer_clear_config(plci); + } + dbug(1, dprintf("[%06lx] %s,%d: mixer_set_bchannel_id %02x %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, ch, plci->li_bchannel_id)); } -static void mixer_set_bchannel_id_esc (PLCI *plci, byte bchannel_id) -{ - DIVA_CAPI_ADAPTER *a; - PLCI *splci; - byte old_id; +#define MIXER_MAX_DUMP_CHANNELS 34 - a = plci->adapter; - old_id = plci->li_bchannel_id; - if (a->li_pri) - { - if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) - li_config_table[a->li_base + (old_id - 1)].plci = NULL; - plci->li_bchannel_id = (bchannel_id & 0x1f) + 1; - if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) - li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; - } - else - { - if (((bchannel_id & 0x03) == 1) || ((bchannel_id & 0x03) == 2)) - { - if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) - li_config_table[a->li_base + (old_id - 1)].plci = NULL; - plci->li_bchannel_id = bchannel_id & 0x03; - if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI != plci) && (a->AdvSignalPLCI->tel == ADV_VOICE)) - { - splci = a->AdvSignalPLCI; - if (li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci == NULL) - { - if ((splci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci == splci)) - { - li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci = NULL; - } - splci->li_bchannel_id = 3 - plci->li_bchannel_id; - li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci = splci; - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_set_bchannel_id_esc %d", - (dword)((splci->Id << 8) | UnMapController (splci->adapter->Id)), - (char *)(FILE_), __LINE__, splci->li_bchannel_id)); - } - } - if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) - li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; - } - } - if ((old_id == 0) && (plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - mixer_clear_config (plci); - } - dbug (1, dprintf ("[%06lx] %s,%d: mixer_set_bchannel_id_esc %d %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, bchannel_id, plci->li_bchannel_id)); +static void mixer_calculate_coefs(DIVA_CAPI_ADAPTER *a) +{ + static char hex_digit_table[0x10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + word n, i, j; + char *p; + char hex_line[2 * MIXER_MAX_DUMP_CHANNELS + MIXER_MAX_DUMP_CHANNELS / 8 + 4]; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_calculate_coefs", + (dword)(UnMapController(a->Id)), (char *)(FILE_), __LINE__)); + + for (i = 0; i < li_total_channels; i++) + { + li_config_table[i].channel &= LI_CHANNEL_ADDRESSES_SET; + if (li_config_table[i].chflags != 0) + li_config_table[i].channel |= LI_CHANNEL_INVOLVED; + else + { + for (j = 0; j < li_total_channels; j++) + { + if (((li_config_table[i].flag_table[j]) != 0) + || ((li_config_table[j].flag_table[i]) != 0)) + { + li_config_table[i].channel |= LI_CHANNEL_INVOLVED; + } + if (((li_config_table[i].flag_table[j] & LI_FLAG_CONFERENCE) != 0) + || ((li_config_table[j].flag_table[i] & LI_FLAG_CONFERENCE) != 0)) + { + li_config_table[i].channel |= LI_CHANNEL_CONFERENCE; + } + } + } + } + for (i = 0; i < li_total_channels; i++) + { + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].coef_table[j] &= ~(LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC); + if (li_config_table[i].flag_table[j] & LI_FLAG_CONFERENCE) + li_config_table[i].coef_table[j] |= LI_COEF_CH_CH; + } + } + for (n = 0; n < li_total_channels; n++) + { + if (li_config_table[n].channel & LI_CHANNEL_CONFERENCE) + { + for (i = 0; i < li_total_channels; i++) + { + if (li_config_table[i].channel & LI_CHANNEL_CONFERENCE) + { + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].coef_table[j] |= + li_config_table[i].coef_table[n] & li_config_table[n].coef_table[j]; + } + } + } + } + } + for (i = 0; i < li_total_channels; i++) + { + if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) + { + li_config_table[i].coef_table[i] &= ~LI_COEF_CH_CH; + for (j = 0; j < li_total_channels; j++) + { + if (li_config_table[i].coef_table[j] & LI_COEF_CH_CH) + li_config_table[i].flag_table[j] |= LI_FLAG_CONFERENCE; + } + if (li_config_table[i].flag_table[i] & LI_FLAG_CONFERENCE) + li_config_table[i].coef_table[i] |= LI_COEF_CH_CH; + } + } + for (i = 0; i < li_total_channels; i++) + { + if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) + { + for (j = 0; j < li_total_channels; j++) + { + if (li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) + li_config_table[i].coef_table[j] |= LI_COEF_CH_CH; + if (li_config_table[i].flag_table[j] & LI_FLAG_MONITOR) + li_config_table[i].coef_table[j] |= LI_COEF_CH_PC; + if (li_config_table[i].flag_table[j] & LI_FLAG_MIX) + li_config_table[i].coef_table[j] |= LI_COEF_PC_CH; + if (li_config_table[i].flag_table[j] & LI_FLAG_PCCONNECT) + li_config_table[i].coef_table[j] |= LI_COEF_PC_PC; + } + if (li_config_table[i].chflags & LI_CHFLAG_MONITOR) + { + for (j = 0; j < li_total_channels; j++) + { + if (li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) + { + li_config_table[i].coef_table[j] |= LI_COEF_CH_PC; + if (li_config_table[j].chflags & LI_CHFLAG_MIX) + li_config_table[i].coef_table[j] |= LI_COEF_PC_CH | LI_COEF_PC_PC; + } + } + } + if (li_config_table[i].chflags & LI_CHFLAG_MIX) + { + for (j = 0; j < li_total_channels; j++) + { + if (li_config_table[j].flag_table[i] & LI_FLAG_INTERCONNECT) + li_config_table[j].coef_table[i] |= LI_COEF_PC_CH; + } + } + if (li_config_table[i].chflags & LI_CHFLAG_LOOP) + { + for (j = 0; j < li_total_channels; j++) + { + if (li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) + { + for (n = 0; n < li_total_channels; n++) + { + if (li_config_table[n].flag_table[i] & LI_FLAG_INTERCONNECT) + { + li_config_table[n].coef_table[j] |= LI_COEF_CH_CH; + if (li_config_table[j].chflags & LI_CHFLAG_MIX) + { + li_config_table[n].coef_table[j] |= LI_COEF_PC_CH; + if (li_config_table[n].chflags & LI_CHFLAG_MONITOR) + li_config_table[n].coef_table[j] |= LI_COEF_CH_PC | LI_COEF_PC_PC; + } + else if (li_config_table[n].chflags & LI_CHFLAG_MONITOR) + li_config_table[n].coef_table[j] |= LI_COEF_CH_PC; + } + } + } + } + } + } + } + for (i = 0; i < li_total_channels; i++) + { + if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) + { + if (li_config_table[i].chflags & (LI_CHFLAG_MONITOR | LI_CHFLAG_MIX | LI_CHFLAG_LOOP)) + li_config_table[i].channel |= LI_CHANNEL_ACTIVE; + if (li_config_table[i].chflags & LI_CHFLAG_MONITOR) + li_config_table[i].channel |= LI_CHANNEL_RX_DATA; + if (li_config_table[i].chflags & LI_CHFLAG_MIX) + li_config_table[i].channel |= LI_CHANNEL_TX_DATA; + for (j = 0; j < li_total_channels; j++) + { + if ((li_config_table[i].flag_table[j] & + (LI_FLAG_INTERCONNECT | LI_FLAG_PCCONNECT | LI_FLAG_CONFERENCE | LI_FLAG_MONITOR)) + || (li_config_table[j].flag_table[i] & + (LI_FLAG_INTERCONNECT | LI_FLAG_PCCONNECT | LI_FLAG_CONFERENCE | LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX))) + { + li_config_table[i].channel |= LI_CHANNEL_ACTIVE; + } + if (li_config_table[i].flag_table[j] & (LI_FLAG_PCCONNECT | LI_FLAG_MONITOR)) + li_config_table[i].channel |= LI_CHANNEL_RX_DATA; + if (li_config_table[j].flag_table[i] & (LI_FLAG_PCCONNECT | LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX)) + li_config_table[i].channel |= LI_CHANNEL_TX_DATA; + } + if (!(li_config_table[i].channel & LI_CHANNEL_ACTIVE)) + { + li_config_table[i].coef_table[i] |= LI_COEF_PC_CH | LI_COEF_CH_PC; + li_config_table[i].channel |= LI_CHANNEL_TX_DATA | LI_CHANNEL_RX_DATA; + } + } + } + for (i = 0; i < li_total_channels; i++) + { + if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) + { + j = 0; + while ((j < li_total_channels) && !(li_config_table[i].flag_table[j] & LI_FLAG_ANNOUNCEMENT)) + j++; + if (j < li_total_channels) + { + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].coef_table[j] &= ~(LI_COEF_CH_CH | LI_COEF_PC_CH); + if (li_config_table[i].flag_table[j] & LI_FLAG_ANNOUNCEMENT) + li_config_table[i].coef_table[j] |= LI_COEF_PC_CH; + } + } + } + } + n = li_total_channels; + if (n > MIXER_MAX_DUMP_CHANNELS) + n = MIXER_MAX_DUMP_CHANNELS; + p = hex_line; + for (j = 0; j < n; j++) + { + if ((j & 0x7) == 0) + *(p++) = ' '; + *(p++) = hex_digit_table[li_config_table[j].curchnl >> 4]; + *(p++) = hex_digit_table[li_config_table[j].curchnl & 0xf]; + } + *p = '\0'; + dbug(1, dprintf("[%06lx] CURRENT %s", + (dword)(UnMapController(a->Id)), (char *)hex_line)); + p = hex_line; + for (j = 0; j < n; j++) + { + if ((j & 0x7) == 0) + *(p++) = ' '; + *(p++) = hex_digit_table[li_config_table[j].channel >> 4]; + *(p++) = hex_digit_table[li_config_table[j].channel & 0xf]; + } + *p = '\0'; + dbug(1, dprintf("[%06lx] CHANNEL %s", + (dword)(UnMapController(a->Id)), (char *)hex_line)); + p = hex_line; + for (j = 0; j < n; j++) + { + if ((j & 0x7) == 0) + *(p++) = ' '; + *(p++) = hex_digit_table[li_config_table[j].chflags >> 4]; + *(p++) = hex_digit_table[li_config_table[j].chflags & 0xf]; + } + *p = '\0'; + dbug(1, dprintf("[%06lx] CHFLAG %s", + (dword)(UnMapController(a->Id)), (char *)hex_line)); + for (i = 0; i < n; i++) + { + p = hex_line; + for (j = 0; j < n; j++) + { + if ((j & 0x7) == 0) + *(p++) = ' '; + *(p++) = hex_digit_table[li_config_table[i].flag_table[j] >> 4]; + *(p++) = hex_digit_table[li_config_table[i].flag_table[j] & 0xf]; + } + *p = '\0'; + dbug(1, dprintf("[%06lx] FLAG[%02x]%s", + (dword)(UnMapController(a->Id)), i, (char *)hex_line)); + } + for (i = 0; i < n; i++) + { + p = hex_line; + for (j = 0; j < n; j++) + { + if ((j & 0x7) == 0) + *(p++) = ' '; + *(p++) = hex_digit_table[li_config_table[i].coef_table[j] >> 4]; + *(p++) = hex_digit_table[li_config_table[i].coef_table[j] & 0xf]; + } + *p = '\0'; + dbug(1, dprintf("[%06lx] COEF[%02x]%s", + (dword)(UnMapController(a->Id)), i, (char *)hex_line)); + } } -static void mixer_set_bchannel_id (PLCI *plci, byte *chi) +static struct { - DIVA_CAPI_ADAPTER *a; - PLCI *splci; - byte ch, old_id; - - a = plci->adapter; - old_id = plci->li_bchannel_id; - ch = chi_to_channel (chi, NULL); - if (!(ch & 0x80)) - { - if (a->li_pri) - { - if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) - li_config_table[a->li_base + (old_id - 1)].plci = NULL; - plci->li_bchannel_id = (ch & 0x1f) + 1; - if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) - li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; - } - else - { - if (((ch & 0x1f) == 1) || ((ch & 0x1f) == 2)) - { - if ((old_id != 0) && (li_config_table[a->li_base + (old_id - 1)].plci == plci)) - li_config_table[a->li_base + (old_id - 1)].plci = NULL; - plci->li_bchannel_id = ch & 0x1f; - if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI != plci) && (a->AdvSignalPLCI->tel == ADV_VOICE)) - { - splci = a->AdvSignalPLCI; - if (li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci == NULL) - { - if ((splci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci == splci)) - { - li_config_table[a->li_base + (splci->li_bchannel_id - 1)].plci = NULL; - } - splci->li_bchannel_id = 3 - plci->li_bchannel_id; - li_config_table[a->li_base + (2 - plci->li_bchannel_id)].plci = splci; - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_set_bchannel_id %d", - (dword)((splci->Id << 8) | UnMapController (splci->adapter->Id)), - (char *)(FILE_), __LINE__, splci->li_bchannel_id)); - } - } - if (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == NULL) - li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci = plci; - } - } - } - if ((old_id == 0) && (plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - mixer_clear_config (plci); - } - dbug (1, dprintf ("[%06lx] %s,%d: mixer_set_bchannel_id %02x %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, ch, plci->li_bchannel_id)); -} - + byte mask; + byte line_flags; +} mixer_write_prog_pri[] = +{ + { LI_COEF_CH_CH, 0 }, + { LI_COEF_CH_PC, MIXER_COEF_LINE_TO_PC_FLAG }, + { LI_COEF_PC_CH, MIXER_COEF_LINE_FROM_PC_FLAG }, + { LI_COEF_PC_PC, MIXER_COEF_LINE_TO_PC_FLAG | MIXER_COEF_LINE_FROM_PC_FLAG } +}; -#define MIXER_MAX_DUMP_CHANNELS 34 +static struct +{ + byte from_ch; + byte to_ch; + byte mask; + byte xconnect_override; +} mixer_write_prog_bri[] = +{ + { 0, 0, LI_COEF_CH_CH, 0x01 }, /* B to B */ + { 1, 0, LI_COEF_CH_CH, 0x01 }, /* Alt B to B */ + { 0, 0, LI_COEF_PC_CH, 0x80 }, /* PC to B */ + { 1, 0, LI_COEF_PC_CH, 0x01 }, /* Alt PC to B */ + { 2, 0, LI_COEF_CH_CH, 0x00 }, /* IC to B */ + { 3, 0, LI_COEF_CH_CH, 0x00 }, /* Alt IC to B */ + { 0, 0, LI_COEF_CH_PC, 0x80 }, /* B to PC */ + { 1, 0, LI_COEF_CH_PC, 0x01 }, /* Alt B to PC */ + { 0, 0, LI_COEF_PC_PC, 0x01 }, /* PC to PC */ + { 1, 0, LI_COEF_PC_PC, 0x01 }, /* Alt PC to PC */ + { 2, 0, LI_COEF_CH_PC, 0x00 }, /* IC to PC */ + { 3, 0, LI_COEF_CH_PC, 0x00 }, /* Alt IC to PC */ + { 0, 2, LI_COEF_CH_CH, 0x00 }, /* B to IC */ + { 1, 2, LI_COEF_CH_CH, 0x00 }, /* Alt B to IC */ + { 0, 2, LI_COEF_PC_CH, 0x00 }, /* PC to IC */ + { 1, 2, LI_COEF_PC_CH, 0x00 }, /* Alt PC to IC */ + { 2, 2, LI_COEF_CH_CH, 0x00 }, /* IC to IC */ + { 3, 2, LI_COEF_CH_CH, 0x00 }, /* Alt IC to IC */ + { 1, 1, LI_COEF_CH_CH, 0x01 }, /* Alt B to Alt B */ + { 0, 1, LI_COEF_CH_CH, 0x01 }, /* B to Alt B */ + { 1, 1, LI_COEF_PC_CH, 0x80 }, /* Alt PC to Alt B */ + { 0, 1, LI_COEF_PC_CH, 0x01 }, /* PC to Alt B */ + { 3, 1, LI_COEF_CH_CH, 0x00 }, /* Alt IC to Alt B */ + { 2, 1, LI_COEF_CH_CH, 0x00 }, /* IC to Alt B */ + { 1, 1, LI_COEF_CH_PC, 0x80 }, /* Alt B to Alt PC */ + { 0, 1, LI_COEF_CH_PC, 0x01 }, /* B to Alt PC */ + { 1, 1, LI_COEF_PC_PC, 0x01 }, /* Alt PC to Alt PC */ + { 0, 1, LI_COEF_PC_PC, 0x01 }, /* PC to Alt PC */ + { 3, 1, LI_COEF_CH_PC, 0x00 }, /* Alt IC to Alt PC */ + { 2, 1, LI_COEF_CH_PC, 0x00 }, /* IC to Alt PC */ + { 1, 3, LI_COEF_CH_CH, 0x00 }, /* Alt B to Alt IC */ + { 0, 3, LI_COEF_CH_CH, 0x00 }, /* B to Alt IC */ + { 1, 3, LI_COEF_PC_CH, 0x00 }, /* Alt PC to Alt IC */ + { 0, 3, LI_COEF_PC_CH, 0x00 }, /* PC to Alt IC */ + { 3, 3, LI_COEF_CH_CH, 0x00 }, /* Alt IC to Alt IC */ + { 2, 3, LI_COEF_CH_CH, 0x00 } /* IC to Alt IC */ +}; -static void mixer_calculate_coefs (DIVA_CAPI_ADAPTER *a) +static byte mixer_swapped_index_bri[] = { -static char hex_digit_table[0x10] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - word n, i, j; - char *p; - char hex_line[2 * MIXER_MAX_DUMP_CHANNELS + MIXER_MAX_DUMP_CHANNELS / 8 + 4]; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_calculate_coefs", - (dword)(UnMapController (a->Id)), (char *)(FILE_), __LINE__)); - - for (i = 0; i < li_total_channels; i++) - { - li_config_table[i].channel &= LI_CHANNEL_ADDRESSES_SET; - if (li_config_table[i].chflags != 0) - li_config_table[i].channel |= LI_CHANNEL_INVOLVED; - else - { - for (j = 0; j < li_total_channels; j++) - { - if (((li_config_table[i].flag_table[j]) != 0) - || ((li_config_table[j].flag_table[i]) != 0)) - { - li_config_table[i].channel |= LI_CHANNEL_INVOLVED; - } - if (((li_config_table[i].flag_table[j] & LI_FLAG_CONFERENCE) != 0) - || ((li_config_table[j].flag_table[i] & LI_FLAG_CONFERENCE) != 0)) - { - li_config_table[i].channel |= LI_CHANNEL_CONFERENCE; - } - } - } - } - for (i = 0; i < li_total_channels; i++) - { - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].coef_table[j] &= ~(LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC); - if (li_config_table[i].flag_table[j] & LI_FLAG_CONFERENCE) - li_config_table[i].coef_table[j] |= LI_COEF_CH_CH; - } - } - for (n = 0; n < li_total_channels; n++) - { - if (li_config_table[n].channel & LI_CHANNEL_CONFERENCE) - { - for (i = 0; i < li_total_channels; i++) - { - if (li_config_table[i].channel & LI_CHANNEL_CONFERENCE) - { - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].coef_table[j] |= - li_config_table[i].coef_table[n] & li_config_table[n].coef_table[j]; - } - } - } - } - } - for (i = 0; i < li_total_channels; i++) - { - if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) - { - li_config_table[i].coef_table[i] &= ~LI_COEF_CH_CH; - for (j = 0; j < li_total_channels; j++) - { - if (li_config_table[i].coef_table[j] & LI_COEF_CH_CH) - li_config_table[i].flag_table[j] |= LI_FLAG_CONFERENCE; - } - if (li_config_table[i].flag_table[i] & LI_FLAG_CONFERENCE) - li_config_table[i].coef_table[i] |= LI_COEF_CH_CH; - } - } - for (i = 0; i < li_total_channels; i++) - { - if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) - { - for (j = 0; j < li_total_channels; j++) - { - if (li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) - li_config_table[i].coef_table[j] |= LI_COEF_CH_CH; - if (li_config_table[i].flag_table[j] & LI_FLAG_MONITOR) - li_config_table[i].coef_table[j] |= LI_COEF_CH_PC; - if (li_config_table[i].flag_table[j] & LI_FLAG_MIX) - li_config_table[i].coef_table[j] |= LI_COEF_PC_CH; - if (li_config_table[i].flag_table[j] & LI_FLAG_PCCONNECT) - li_config_table[i].coef_table[j] |= LI_COEF_PC_PC; - } - if (li_config_table[i].chflags & LI_CHFLAG_MONITOR) - { - for (j = 0; j < li_total_channels; j++) - { - if (li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) - { - li_config_table[i].coef_table[j] |= LI_COEF_CH_PC; - if (li_config_table[j].chflags & LI_CHFLAG_MIX) - li_config_table[i].coef_table[j] |= LI_COEF_PC_CH | LI_COEF_PC_PC; - } - } - } - if (li_config_table[i].chflags & LI_CHFLAG_MIX) - { - for (j = 0; j < li_total_channels; j++) - { - if (li_config_table[j].flag_table[i] & LI_FLAG_INTERCONNECT) - li_config_table[j].coef_table[i] |= LI_COEF_PC_CH; - } - } - if (li_config_table[i].chflags & LI_CHFLAG_LOOP) - { - for (j = 0; j < li_total_channels; j++) - { - if (li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) - { - for (n = 0; n < li_total_channels; n++) - { - if (li_config_table[n].flag_table[i] & LI_FLAG_INTERCONNECT) - { - li_config_table[n].coef_table[j] |= LI_COEF_CH_CH; - if (li_config_table[j].chflags & LI_CHFLAG_MIX) - { - li_config_table[n].coef_table[j] |= LI_COEF_PC_CH; - if (li_config_table[n].chflags & LI_CHFLAG_MONITOR) - li_config_table[n].coef_table[j] |= LI_COEF_CH_PC | LI_COEF_PC_PC; - } - else if (li_config_table[n].chflags & LI_CHFLAG_MONITOR) - li_config_table[n].coef_table[j] |= LI_COEF_CH_PC; - } - } - } - } - } - } - } - for (i = 0; i < li_total_channels; i++) - { - if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) - { - if (li_config_table[i].chflags & (LI_CHFLAG_MONITOR | LI_CHFLAG_MIX | LI_CHFLAG_LOOP)) - li_config_table[i].channel |= LI_CHANNEL_ACTIVE; - if (li_config_table[i].chflags & LI_CHFLAG_MONITOR) - li_config_table[i].channel |= LI_CHANNEL_RX_DATA; - if (li_config_table[i].chflags & LI_CHFLAG_MIX) - li_config_table[i].channel |= LI_CHANNEL_TX_DATA; - for (j = 0; j < li_total_channels; j++) - { - if ((li_config_table[i].flag_table[j] & - (LI_FLAG_INTERCONNECT | LI_FLAG_PCCONNECT | LI_FLAG_CONFERENCE | LI_FLAG_MONITOR)) - || (li_config_table[j].flag_table[i] & - (LI_FLAG_INTERCONNECT | LI_FLAG_PCCONNECT | LI_FLAG_CONFERENCE | LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX))) - { - li_config_table[i].channel |= LI_CHANNEL_ACTIVE; - } - if (li_config_table[i].flag_table[j] & (LI_FLAG_PCCONNECT | LI_FLAG_MONITOR)) - li_config_table[i].channel |= LI_CHANNEL_RX_DATA; - if (li_config_table[j].flag_table[i] & (LI_FLAG_PCCONNECT | LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX)) - li_config_table[i].channel |= LI_CHANNEL_TX_DATA; - } - if (!(li_config_table[i].channel & LI_CHANNEL_ACTIVE)) - { - li_config_table[i].coef_table[i] |= LI_COEF_PC_CH | LI_COEF_CH_PC; - li_config_table[i].channel |= LI_CHANNEL_TX_DATA | LI_CHANNEL_RX_DATA; - } - } - } - for (i = 0; i < li_total_channels; i++) - { - if (li_config_table[i].channel & LI_CHANNEL_INVOLVED) - { - j = 0; - while ((j < li_total_channels) && !(li_config_table[i].flag_table[j] & LI_FLAG_ANNOUNCEMENT)) - j++; - if (j < li_total_channels) - { - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].coef_table[j] &= ~(LI_COEF_CH_CH | LI_COEF_PC_CH); - if (li_config_table[i].flag_table[j] & LI_FLAG_ANNOUNCEMENT) - li_config_table[i].coef_table[j] |= LI_COEF_PC_CH; - } - } - } - } - n = li_total_channels; - if (n > MIXER_MAX_DUMP_CHANNELS) - n = MIXER_MAX_DUMP_CHANNELS; - p = hex_line; - for (j = 0; j < n; j++) - { - if ((j & 0x7) == 0) - *(p++) = ' '; - *(p++) = hex_digit_table[li_config_table[j].curchnl >> 4]; - *(p++) = hex_digit_table[li_config_table[j].curchnl & 0xf]; - } - *p = '\0'; - dbug (1, dprintf ("[%06lx] CURRENT %s", - (dword)(UnMapController (a->Id)), (char *) hex_line)); - p = hex_line; - for (j = 0; j < n; j++) - { - if ((j & 0x7) == 0) - *(p++) = ' '; - *(p++) = hex_digit_table[li_config_table[j].channel >> 4]; - *(p++) = hex_digit_table[li_config_table[j].channel & 0xf]; - } - *p = '\0'; - dbug (1, dprintf ("[%06lx] CHANNEL %s", - (dword)(UnMapController (a->Id)), (char *) hex_line)); - p = hex_line; - for (j = 0; j < n; j++) - { - if ((j & 0x7) == 0) - *(p++) = ' '; - *(p++) = hex_digit_table[li_config_table[j].chflags >> 4]; - *(p++) = hex_digit_table[li_config_table[j].chflags & 0xf]; - } - *p = '\0'; - dbug (1, dprintf ("[%06lx] CHFLAG %s", - (dword)(UnMapController (a->Id)), (char *) hex_line)); - for (i = 0; i < n; i++) - { - p = hex_line; - for (j = 0; j < n; j++) - { - if ((j & 0x7) == 0) - *(p++) = ' '; - *(p++) = hex_digit_table[li_config_table[i].flag_table[j] >> 4]; - *(p++) = hex_digit_table[li_config_table[i].flag_table[j] & 0xf]; - } - *p = '\0'; - dbug (1, dprintf ("[%06lx] FLAG[%02x]%s", - (dword)(UnMapController (a->Id)), i, (char *) hex_line)); - } - for (i = 0; i < n; i++) - { - p = hex_line; - for (j = 0; j < n; j++) - { - if ((j & 0x7) == 0) - *(p++) = ' '; - *(p++) = hex_digit_table[li_config_table[i].coef_table[j] >> 4]; - *(p++) = hex_digit_table[li_config_table[i].coef_table[j] & 0xf]; - } - *p = '\0'; - dbug (1, dprintf ("[%06lx] COEF[%02x]%s", - (dword)(UnMapController (a->Id)), i, (char *) hex_line)); - } -} - - -static struct -{ - byte mask; - byte line_flags; -} mixer_write_prog_pri[] = -{ - { LI_COEF_CH_CH, 0 }, - { LI_COEF_CH_PC, MIXER_COEF_LINE_TO_PC_FLAG }, - { LI_COEF_PC_CH, MIXER_COEF_LINE_FROM_PC_FLAG }, - { LI_COEF_PC_PC, MIXER_COEF_LINE_TO_PC_FLAG | MIXER_COEF_LINE_FROM_PC_FLAG } -}; + 18, /* B to B */ + 19, /* Alt B to B */ + 20, /* PC to B */ + 21, /* Alt PC to B */ + 22, /* IC to B */ + 23, /* Alt IC to B */ + 24, /* B to PC */ + 25, /* Alt B to PC */ + 26, /* PC to PC */ + 27, /* Alt PC to PC */ + 28, /* IC to PC */ + 29, /* Alt IC to PC */ + 30, /* B to IC */ + 31, /* Alt B to IC */ + 32, /* PC to IC */ + 33, /* Alt PC to IC */ + 34, /* IC to IC */ + 35, /* Alt IC to IC */ + 0, /* Alt B to Alt B */ + 1, /* B to Alt B */ + 2, /* Alt PC to Alt B */ + 3, /* PC to Alt B */ + 4, /* Alt IC to Alt B */ + 5, /* IC to Alt B */ + 6, /* Alt B to Alt PC */ + 7, /* B to Alt PC */ + 8, /* Alt PC to Alt PC */ + 9, /* PC to Alt PC */ + 10, /* Alt IC to Alt PC */ + 11, /* IC to Alt PC */ + 12, /* Alt B to Alt IC */ + 13, /* B to Alt IC */ + 14, /* Alt PC to Alt IC */ + 15, /* PC to Alt IC */ + 16, /* Alt IC to Alt IC */ + 17 /* IC to Alt IC */ +}; static struct { - byte from_ch; - byte to_ch; - byte mask; - byte xconnect_override; -} mixer_write_prog_bri[] = -{ - { 0, 0, LI_COEF_CH_CH, 0x01 }, /* B to B */ - { 1, 0, LI_COEF_CH_CH, 0x01 }, /* Alt B to B */ - { 0, 0, LI_COEF_PC_CH, 0x80 }, /* PC to B */ - { 1, 0, LI_COEF_PC_CH, 0x01 }, /* Alt PC to B */ - { 2, 0, LI_COEF_CH_CH, 0x00 }, /* IC to B */ - { 3, 0, LI_COEF_CH_CH, 0x00 }, /* Alt IC to B */ - { 0, 0, LI_COEF_CH_PC, 0x80 }, /* B to PC */ - { 1, 0, LI_COEF_CH_PC, 0x01 }, /* Alt B to PC */ - { 0, 0, LI_COEF_PC_PC, 0x01 }, /* PC to PC */ - { 1, 0, LI_COEF_PC_PC, 0x01 }, /* Alt PC to PC */ - { 2, 0, LI_COEF_CH_PC, 0x00 }, /* IC to PC */ - { 3, 0, LI_COEF_CH_PC, 0x00 }, /* Alt IC to PC */ - { 0, 2, LI_COEF_CH_CH, 0x00 }, /* B to IC */ - { 1, 2, LI_COEF_CH_CH, 0x00 }, /* Alt B to IC */ - { 0, 2, LI_COEF_PC_CH, 0x00 }, /* PC to IC */ - { 1, 2, LI_COEF_PC_CH, 0x00 }, /* Alt PC to IC */ - { 2, 2, LI_COEF_CH_CH, 0x00 }, /* IC to IC */ - { 3, 2, LI_COEF_CH_CH, 0x00 }, /* Alt IC to IC */ - { 1, 1, LI_COEF_CH_CH, 0x01 }, /* Alt B to Alt B */ - { 0, 1, LI_COEF_CH_CH, 0x01 }, /* B to Alt B */ - { 1, 1, LI_COEF_PC_CH, 0x80 }, /* Alt PC to Alt B */ - { 0, 1, LI_COEF_PC_CH, 0x01 }, /* PC to Alt B */ - { 3, 1, LI_COEF_CH_CH, 0x00 }, /* Alt IC to Alt B */ - { 2, 1, LI_COEF_CH_CH, 0x00 }, /* IC to Alt B */ - { 1, 1, LI_COEF_CH_PC, 0x80 }, /* Alt B to Alt PC */ - { 0, 1, LI_COEF_CH_PC, 0x01 }, /* B to Alt PC */ - { 1, 1, LI_COEF_PC_PC, 0x01 }, /* Alt PC to Alt PC */ - { 0, 1, LI_COEF_PC_PC, 0x01 }, /* PC to Alt PC */ - { 3, 1, LI_COEF_CH_PC, 0x00 }, /* Alt IC to Alt PC */ - { 2, 1, LI_COEF_CH_PC, 0x00 }, /* IC to Alt PC */ - { 1, 3, LI_COEF_CH_CH, 0x00 }, /* Alt B to Alt IC */ - { 0, 3, LI_COEF_CH_CH, 0x00 }, /* B to Alt IC */ - { 1, 3, LI_COEF_PC_CH, 0x00 }, /* Alt PC to Alt IC */ - { 0, 3, LI_COEF_PC_CH, 0x00 }, /* PC to Alt IC */ - { 3, 3, LI_COEF_CH_CH, 0x00 }, /* Alt IC to Alt IC */ - { 2, 3, LI_COEF_CH_CH, 0x00 } /* IC to Alt IC */ -}; - -static byte mixer_swapped_index_bri[] = -{ - 18, /* B to B */ - 19, /* Alt B to B */ - 20, /* PC to B */ - 21, /* Alt PC to B */ - 22, /* IC to B */ - 23, /* Alt IC to B */ - 24, /* B to PC */ - 25, /* Alt B to PC */ - 26, /* PC to PC */ - 27, /* Alt PC to PC */ - 28, /* IC to PC */ - 29, /* Alt IC to PC */ - 30, /* B to IC */ - 31, /* Alt B to IC */ - 32, /* PC to IC */ - 33, /* Alt PC to IC */ - 34, /* IC to IC */ - 35, /* Alt IC to IC */ - 0, /* Alt B to Alt B */ - 1, /* B to Alt B */ - 2, /* Alt PC to Alt B */ - 3, /* PC to Alt B */ - 4, /* Alt IC to Alt B */ - 5, /* IC to Alt B */ - 6, /* Alt B to Alt PC */ - 7, /* B to Alt PC */ - 8, /* Alt PC to Alt PC */ - 9, /* PC to Alt PC */ - 10, /* Alt IC to Alt PC */ - 11, /* IC to Alt PC */ - 12, /* Alt B to Alt IC */ - 13, /* B to Alt IC */ - 14, /* Alt PC to Alt IC */ - 15, /* PC to Alt IC */ - 16, /* Alt IC to Alt IC */ - 17 /* IC to Alt IC */ -}; - -static struct -{ - byte mask; - byte from_pc; - byte to_pc; -} xconnect_write_prog[] = -{ - { LI_COEF_CH_CH, false, false }, - { LI_COEF_CH_PC, false, true }, - { LI_COEF_PC_CH, true, false }, - { LI_COEF_PC_PC, true, true } -}; - - -static void xconnect_query_addresses (PLCI *plci) -{ - DIVA_CAPI_ADAPTER *a; - word w, ch; - byte *p; - - dbug (1, dprintf ("[%06lx] %s,%d: xconnect_query_addresses", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - a = plci->adapter; - if (a->li_pri && ((plci->li_bchannel_id == 0) - || (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci != plci))) - { - dbug (1, dprintf ("[%06x] %s,%d: Channel id wiped out", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - return; - } - p = plci->internal_req_buffer; - ch = (a->li_pri) ? plci->li_bchannel_id - 1 : 0; - *(p++) = UDATA_REQUEST_XCONNECT_FROM; - w = ch; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - w = ch | XCONNECT_CHANNEL_PORT_PC; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - plci->NData[0].P = plci->internal_req_buffer; - plci->NData[0].PLength = p - plci->internal_req_buffer; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_UDATA; - plci->adapter->request (&plci->NL); -} - - -static void xconnect_write_coefs (PLCI *plci, word internal_command) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: xconnect_write_coefs %04x", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, internal_command)); - - plci->li_write_command = internal_command; - plci->li_write_channel = 0; -} - - -static byte xconnect_write_coefs_process (dword Id, PLCI *plci, byte Rc) -{ - DIVA_CAPI_ADAPTER *a; - word w, n, i, j, r, s, to_ch; - dword d; - byte *p; - struct xconnect_transfer_address_s *transfer_address; - byte ch_map[MIXER_CHANNELS_BRI]; - - dbug (1, dprintf ("[%06x] %s,%d: xconnect_write_coefs_process %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->li_write_channel)); - - a = plci->adapter; - if ((plci->li_bchannel_id == 0) - || (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci != plci)) - { - dbug (1, dprintf ("[%06x] %s,%d: Channel id wiped out", - UnMapId (Id), (char *)(FILE_), __LINE__)); - return (true); - } - i = a->li_base + (plci->li_bchannel_id - 1); - j = plci->li_write_channel; - p = plci->internal_req_buffer; - if (j != 0) - { - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI write coefs failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - return (false); - } - } - if (li_config_table[i].adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - { - r = 0; - s = 0; - if (j < li_total_channels) - { - if (li_config_table[i].channel & LI_CHANNEL_ADDRESSES_SET) - { - s = ((li_config_table[i].send_b.card_address.low | li_config_table[i].send_b.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_PC | LI_COEF_PC_PC)) & - ((li_config_table[i].send_pc.card_address.low | li_config_table[i].send_pc.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_PC_CH)); - } - r = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - while ((j < li_total_channels) - && ((r == 0) - || (!(li_config_table[j].channel & LI_CHANNEL_ADDRESSES_SET)) - || (!li_config_table[j].adapter->li_pri - && (j >= li_config_table[j].adapter->li_base + MIXER_BCHANNELS_BRI)) - || (((li_config_table[j].send_b.card_address.low != li_config_table[i].send_b.card_address.low) - || (li_config_table[j].send_b.card_address.high != li_config_table[i].send_b.card_address.high)) - && (!(a->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT) - || !(li_config_table[j].adapter->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT))) - || ((li_config_table[j].adapter->li_base != a->li_base) - && !(r & s & - ((li_config_table[j].send_b.card_address.low | li_config_table[j].send_b.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_PC_CH | LI_COEF_PC_PC)) & - ((li_config_table[j].send_pc.card_address.low | li_config_table[j].send_pc.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_CH_PC)))))) - { - j++; - if (j < li_total_channels) - r = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - } - } - if (j < li_total_channels) - { - plci->internal_command = plci->li_write_command; - if (plci_nl_busy (plci)) - return (true); - to_ch = (a->li_pri) ? plci->li_bchannel_id - 1 : 0; - *(p++) = UDATA_REQUEST_XCONNECT_TO; - do - { - if (li_config_table[j].adapter->li_base != a->li_base) - { - r &= s & - ((li_config_table[j].send_b.card_address.low | li_config_table[j].send_b.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_PC_CH | LI_COEF_PC_PC)) & - ((li_config_table[j].send_pc.card_address.low | li_config_table[j].send_pc.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_CH_PC)); - } - n = 0; - do - { - if (r & xconnect_write_prog[n].mask) - { - if (xconnect_write_prog[n].from_pc) - transfer_address = &(li_config_table[j].send_pc); - else - transfer_address = &(li_config_table[j].send_b); - d = transfer_address->card_address.low; - *(p++) = (byte) d; - *(p++) = (byte)(d >> 8); - *(p++) = (byte)(d >> 16); - *(p++) = (byte)(d >> 24); - d = transfer_address->card_address.high; - *(p++) = (byte) d; - *(p++) = (byte)(d >> 8); - *(p++) = (byte)(d >> 16); - *(p++) = (byte)(d >> 24); - d = transfer_address->offset; - *(p++) = (byte) d; - *(p++) = (byte)(d >> 8); - *(p++) = (byte)(d >> 16); - *(p++) = (byte)(d >> 24); - w = xconnect_write_prog[n].to_pc ? to_ch | XCONNECT_CHANNEL_PORT_PC : to_ch; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - w = ((li_config_table[i].coef_table[j] & xconnect_write_prog[n].mask) == 0) ? 0x01 : - (li_config_table[i].adapter->u_law ? - (li_config_table[j].adapter->u_law ? 0x80 : 0x86) : - (li_config_table[j].adapter->u_law ? 0x7a : 0x80)); - *(p++) = (byte) w; - *(p++) = (byte) 0; - li_config_table[i].coef_table[j] ^= xconnect_write_prog[n].mask << 4; - } - n++; - } while ((n < ARRAY_SIZE(xconnect_write_prog)) - && ((p - plci->internal_req_buffer) + 16 < INTERNAL_REQ_BUFFER_SIZE)); - if (n == ARRAY_SIZE(xconnect_write_prog)) - { - do - { - j++; - if (j < li_total_channels) - r = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - } while ((j < li_total_channels) - && ((r == 0) - || (!(li_config_table[j].channel & LI_CHANNEL_ADDRESSES_SET)) - || (!li_config_table[j].adapter->li_pri - && (j >= li_config_table[j].adapter->li_base + MIXER_BCHANNELS_BRI)) - || (((li_config_table[j].send_b.card_address.low != li_config_table[i].send_b.card_address.low) - || (li_config_table[j].send_b.card_address.high != li_config_table[i].send_b.card_address.high)) - && (!(a->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT) - || !(li_config_table[j].adapter->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT))) - || ((li_config_table[j].adapter->li_base != a->li_base) - && !(r & s & - ((li_config_table[j].send_b.card_address.low | li_config_table[j].send_b.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_PC_CH | LI_COEF_PC_PC)) & - ((li_config_table[j].send_pc.card_address.low | li_config_table[j].send_pc.card_address.high) ? - (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_CH_PC)))))); - } - } while ((j < li_total_channels) - && ((p - plci->internal_req_buffer) + 16 < INTERNAL_REQ_BUFFER_SIZE)); - } - else if (j == li_total_channels) - { - plci->internal_command = plci->li_write_command; - if (plci_nl_busy (plci)) - return (true); - if (a->li_pri) - { - *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_PRI_SYNC; - w = 0; - if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) - w |= MIXER_FEATURE_ENABLE_TX_DATA; - if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) - w |= MIXER_FEATURE_ENABLE_RX_DATA; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - } - else - { - *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_BRI; - w = 0; - if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI) - && (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length)) - { - w = GET_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE); - } - if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) - w |= MIXER_FEATURE_ENABLE_TX_DATA; - if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) - w |= MIXER_FEATURE_ENABLE_RX_DATA; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - for (j = 0; j < sizeof(ch_map); j += 2) - { - if (plci->li_bchannel_id == 2) - { - ch_map[j] = (byte)(j+1); - ch_map[j+1] = (byte) j; - } - else - { - ch_map[j] = (byte) j; - ch_map[j+1] = (byte)(j+1); - } - } - for (n = 0; n < ARRAY_SIZE(mixer_write_prog_bri); n++) - { - i = a->li_base + ch_map[mixer_write_prog_bri[n].to_ch]; - j = a->li_base + ch_map[mixer_write_prog_bri[n].from_ch]; - if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED) - { - *p = (mixer_write_prog_bri[n].xconnect_override != 0) ? - mixer_write_prog_bri[n].xconnect_override : - ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01); - if ((i >= a->li_base + MIXER_BCHANNELS_BRI) || (j >= a->li_base + MIXER_BCHANNELS_BRI)) - { - w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - li_config_table[i].coef_table[j] ^= (w & mixer_write_prog_bri[n].mask) << 4; - } - } - else - { - *p = 0x00; - if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI->tel == ADV_VOICE)) - { - w = (plci == a->AdvSignalPLCI) ? n : mixer_swapped_index_bri[n]; - if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w < a->adv_voice_coef_length) - *p = a->adv_voice_coef_buffer[ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w]; - } - } - p++; - } - } - j = li_total_channels + 1; - } - } - else - { - if (j <= li_total_channels) - { - plci->internal_command = plci->li_write_command; - if (plci_nl_busy (plci)) - return (true); - if (j < a->li_base) - j = a->li_base; - if (a->li_pri) - { - *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_PRI_SYNC; - w = 0; - if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) - w |= MIXER_FEATURE_ENABLE_TX_DATA; - if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) - w |= MIXER_FEATURE_ENABLE_RX_DATA; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - for (n = 0; n < ARRAY_SIZE(mixer_write_prog_pri); n++) - { - *(p++) = (byte)((plci->li_bchannel_id - 1) | mixer_write_prog_pri[n].line_flags); - for (j = a->li_base; j < a->li_base + MIXER_CHANNELS_PRI; j++) - { - w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - if (w & mixer_write_prog_pri[n].mask) - { - *(p++) = (li_config_table[i].coef_table[j] & mixer_write_prog_pri[n].mask) ? 0x80 : 0x01; - li_config_table[i].coef_table[j] ^= mixer_write_prog_pri[n].mask << 4; - } - else - *(p++) = 0x00; - } - *(p++) = (byte)((plci->li_bchannel_id - 1) | MIXER_COEF_LINE_ROW_FLAG | mixer_write_prog_pri[n].line_flags); - for (j = a->li_base; j < a->li_base + MIXER_CHANNELS_PRI; j++) - { - w = ((li_config_table[j].coef_table[i] & 0xf) ^ (li_config_table[j].coef_table[i] >> 4)); - if (w & mixer_write_prog_pri[n].mask) - { - *(p++) = (li_config_table[j].coef_table[i] & mixer_write_prog_pri[n].mask) ? 0x80 : 0x01; - li_config_table[j].coef_table[i] ^= mixer_write_prog_pri[n].mask << 4; - } - else - *(p++) = 0x00; - } - } - } - else - { - *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_BRI; - w = 0; - if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI) - && (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length)) - { - w = GET_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE); - } - if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) - w |= MIXER_FEATURE_ENABLE_TX_DATA; - if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) - w |= MIXER_FEATURE_ENABLE_RX_DATA; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - for (j = 0; j < sizeof(ch_map); j += 2) - { - if (plci->li_bchannel_id == 2) - { - ch_map[j] = (byte)(j+1); - ch_map[j+1] = (byte) j; - } - else - { - ch_map[j] = (byte) j; - ch_map[j+1] = (byte)(j+1); - } - } - for (n = 0; n < ARRAY_SIZE(mixer_write_prog_bri); n++) - { - i = a->li_base + ch_map[mixer_write_prog_bri[n].to_ch]; - j = a->li_base + ch_map[mixer_write_prog_bri[n].from_ch]; - if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED) - { - *p = ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01); - w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - li_config_table[i].coef_table[j] ^= (w & mixer_write_prog_bri[n].mask) << 4; - } - else - { - *p = 0x00; - if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI->tel == ADV_VOICE)) - { - w = (plci == a->AdvSignalPLCI) ? n : mixer_swapped_index_bri[n]; - if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w < a->adv_voice_coef_length) - *p = a->adv_voice_coef_buffer[ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w]; - } - } - p++; - } - } - j = li_total_channels + 1; - } - } - plci->li_write_channel = j; - if (p != plci->internal_req_buffer) - { - plci->NData[0].P = plci->internal_req_buffer; - plci->NData[0].PLength = p - plci->internal_req_buffer; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_UDATA; - plci->adapter->request (&plci->NL); - } - return (true); -} - - -static void mixer_notify_update (PLCI *plci, byte others) -{ - DIVA_CAPI_ADAPTER *a; - word i, w; - PLCI *notify_plci; - byte msg[sizeof(CAPI_MSG_HEADER) + 6]; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_notify_update %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, others)); - - a = plci->adapter; - if (a->profile.Global_Options & GL_LINE_INTERCONNECT_SUPPORTED) - { - if (others) - plci->li_notify_update = true; - i = 0; - do - { - notify_plci = NULL; - if (others) - { - while ((i < li_total_channels) && (li_config_table[i].plci == NULL)) - i++; - if (i < li_total_channels) - notify_plci = li_config_table[i++].plci; - } - else - { - if ((plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - notify_plci = plci; - } - } - if ((notify_plci != NULL) - && !notify_plci->li_notify_update - && (notify_plci->appl != NULL) - && (notify_plci->State) - && notify_plci->NL.Id && !notify_plci->nl_remove_id) - { - notify_plci->li_notify_update = true; - ((CAPI_MSG *) msg)->header.length = 18; - ((CAPI_MSG *) msg)->header.appl_id = notify_plci->appl->Id; - ((CAPI_MSG *) msg)->header.command = _FACILITY_R; - ((CAPI_MSG *) msg)->header.number = 0; - ((CAPI_MSG *) msg)->header.controller = notify_plci->adapter->Id; - ((CAPI_MSG *) msg)->header.plci = notify_plci->Id; - ((CAPI_MSG *) msg)->header.ncci = 0; - ((CAPI_MSG *) msg)->info.facility_req.Selector = SELECTOR_LINE_INTERCONNECT; - ((CAPI_MSG *) msg)->info.facility_req.structs[0] = 3; - PUT_WORD (&(((CAPI_MSG *) msg)->info.facility_req.structs[1]), LI_REQ_SILENT_UPDATE); - ((CAPI_MSG *) msg)->info.facility_req.structs[3] = 0; - w = api_put (notify_plci->appl, (CAPI_MSG *) msg); - if (w != _QUEUE_FULL) - { - if (w != 0) - { - dbug (1, dprintf ("[%06lx] %s,%d: Interconnect notify failed %06x %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, - (dword)((notify_plci->Id << 8) | UnMapController (notify_plci->adapter->Id)), w)); - } - notify_plci->li_notify_update = false; - } - } - } while (others && (notify_plci != NULL)); - if (others) - plci->li_notify_update = false; - } -} - - -static void mixer_clear_config (PLCI *plci) -{ - DIVA_CAPI_ADAPTER *a; - word i, j; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_clear_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - plci->li_notify_update = false; - plci->li_plci_b_write_pos = 0; - plci->li_plci_b_read_pos = 0; - plci->li_plci_b_req_pos = 0; - a = plci->adapter; - if ((plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - i = a->li_base + (plci->li_bchannel_id - 1); - li_config_table[i].curchnl = 0; - li_config_table[i].channel = 0; - li_config_table[i].chflags = 0; - for (j = 0; j < li_total_channels; j++) - { - li_config_table[j].flag_table[i] = 0; - li_config_table[i].flag_table[j] = 0; - li_config_table[i].coef_table[j] = 0; - li_config_table[j].coef_table[i] = 0; - } - if (!a->li_pri) - { - li_config_table[i].coef_table[i] |= LI_COEF_CH_PC_SET | LI_COEF_PC_CH_SET; - if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) - { - i = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); - li_config_table[i].curchnl = 0; - li_config_table[i].channel = 0; - li_config_table[i].chflags = 0; - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].flag_table[j] = 0; - li_config_table[j].flag_table[i] = 0; - li_config_table[i].coef_table[j] = 0; - li_config_table[j].coef_table[i] = 0; - } - if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) - { - i = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); - li_config_table[i].curchnl = 0; - li_config_table[i].channel = 0; - li_config_table[i].chflags = 0; - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].flag_table[j] = 0; - li_config_table[j].flag_table[i] = 0; - li_config_table[i].coef_table[j] = 0; - li_config_table[j].coef_table[i] = 0; - } - } - } - } - } -} - - -static void mixer_prepare_switch (dword Id, PLCI *plci) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_prepare_switch", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - do - { - mixer_indication_coefs_set (Id, plci); - } while (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos); -} - - -static word mixer_save_config (dword Id, PLCI *plci, byte Rc) -{ - DIVA_CAPI_ADAPTER *a; - word i, j; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_save_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - - a = plci->adapter; - if ((plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - i = a->li_base + (plci->li_bchannel_id - 1); - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].coef_table[j] &= 0xf; - li_config_table[j].coef_table[i] &= 0xf; - } - if (!a->li_pri) - li_config_table[i].coef_table[i] |= LI_COEF_CH_PC_SET | LI_COEF_PC_CH_SET; - } - return (GOOD); -} - - -static word mixer_restore_config (dword Id, PLCI *plci, byte Rc) -{ - DIVA_CAPI_ADAPTER *a; - word Info; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_restore_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - - Info = GOOD; - a = plci->adapter; - if ((plci->B1_facilities & B1_FACILITY_MIXER) - && (plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - switch (plci->adjust_b_state) - { - case ADJUST_B_RESTORE_MIXER_1: - if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - { - plci->internal_command = plci->adjust_b_command; - if (plci_nl_busy (plci)) - { - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_1; - break; - } - xconnect_query_addresses (plci); - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_2; - break; - } - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_5; - Rc = OK; - case ADJUST_B_RESTORE_MIXER_2: - case ADJUST_B_RESTORE_MIXER_3: - case ADJUST_B_RESTORE_MIXER_4: - if ((Rc != OK) && (Rc != OK_FC) && (Rc != 0)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B query addresses failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - if (Rc == OK) - { - if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_2) - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_3; - else if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_4) - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_5; - } - else if (Rc == 0) - { - if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_2) - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_4; - else if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_3) - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_5; - } - if (plci->adjust_b_state != ADJUST_B_RESTORE_MIXER_5) - { - plci->internal_command = plci->adjust_b_command; - break; - } - case ADJUST_B_RESTORE_MIXER_5: - xconnect_write_coefs (plci, plci->adjust_b_command); - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_6; - Rc = OK; - case ADJUST_B_RESTORE_MIXER_6: - if (!xconnect_write_coefs_process (Id, plci, Rc)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Write mixer coefs failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (plci->internal_command) - break; - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_7; - case ADJUST_B_RESTORE_MIXER_7: - break; - } - } - return (Info); -} - - -static void mixer_command (dword Id, PLCI *plci, byte Rc) -{ - DIVA_CAPI_ADAPTER *a; - word i, internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_command %02x %04x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command, - plci->li_cmd)); - - a = plci->adapter; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (plci->li_cmd) - { - case LI_REQ_CONNECT: - case LI_REQ_DISCONNECT: - case LI_REQ_SILENT_UPDATE: - switch (internal_command) - { - default: - if (plci->li_channel_bits & LI_CHANNEL_INVOLVED) - { - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities | - B1_FACILITY_MIXER), MIXER_COMMAND_1); - } - case MIXER_COMMAND_1: - if (plci->li_channel_bits & LI_CHANNEL_INVOLVED) - { - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Load mixer failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - } - plci->li_plci_b_req_pos = plci->li_plci_b_write_pos; - if ((plci->li_channel_bits & LI_CHANNEL_INVOLVED) - || ((get_b1_facilities (plci, plci->B1_resource) & B1_FACILITY_MIXER) - && (add_b1_facilities (plci, plci->B1_resource, (word)(plci->B1_facilities & - ~B1_FACILITY_MIXER)) == plci->B1_resource))) - { - xconnect_write_coefs (plci, MIXER_COMMAND_2); - } - else - { - do - { - mixer_indication_coefs_set (Id, plci); - } while (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos); - } - case MIXER_COMMAND_2: - if ((plci->li_channel_bits & LI_CHANNEL_INVOLVED) - || ((get_b1_facilities (plci, plci->B1_resource) & B1_FACILITY_MIXER) - && (add_b1_facilities (plci, plci->B1_resource, (word)(plci->B1_facilities & - ~B1_FACILITY_MIXER)) == plci->B1_resource))) - { - if (!xconnect_write_coefs_process (Id, plci, Rc)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Write mixer coefs failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - if (plci->li_plci_b_write_pos != plci->li_plci_b_req_pos) - { - do - { - plci->li_plci_b_write_pos = (plci->li_plci_b_write_pos == 0) ? - LI_PLCI_B_QUEUE_ENTRIES-1 : plci->li_plci_b_write_pos - 1; - i = (plci->li_plci_b_write_pos == 0) ? - LI_PLCI_B_QUEUE_ENTRIES-1 : plci->li_plci_b_write_pos - 1; - } while ((plci->li_plci_b_write_pos != plci->li_plci_b_req_pos) - && !(plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)); - } - break; - } - if (plci->internal_command) - return; - } - if (!(plci->li_channel_bits & LI_CHANNEL_INVOLVED)) - { - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities & - ~B1_FACILITY_MIXER), MIXER_COMMAND_3); - } - case MIXER_COMMAND_3: - if (!(plci->li_channel_bits & LI_CHANNEL_INVOLVED)) - { - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Unload mixer failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - } - break; - } - break; - } - if ((plci->li_bchannel_id == 0) - || (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci != plci)) - { - dbug (1, dprintf ("[%06x] %s,%d: Channel id wiped out %d", - UnMapId (Id), (char *)(FILE_), __LINE__, (int)(plci->li_bchannel_id))); - } - else - { - i = a->li_base + (plci->li_bchannel_id - 1); - li_config_table[i].curchnl = plci->li_channel_bits; - if (!a->li_pri && (plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) - { - i = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); - li_config_table[i].curchnl = plci->li_channel_bits; - if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) - { - i = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); - li_config_table[i].curchnl = plci->li_channel_bits; - } - } - } -} - - -static void li_update_connect (dword Id, DIVA_CAPI_ADAPTER *a, PLCI *plci, - dword plci_b_id, byte connect, dword li_flags) -{ - word i, ch_a, ch_a_v, ch_a_s, ch_b, ch_b_v, ch_b_s; - PLCI *plci_b; - DIVA_CAPI_ADAPTER *a_b; - - a_b = &(adapter[MapController ((byte)(plci_b_id & 0x7f)) - 1]); - plci_b = &(a_b->plci[((plci_b_id >> 8) & 0xff) - 1]); - ch_a = a->li_base + (plci->li_bchannel_id - 1); - if (!a->li_pri && (plci->tel == ADV_VOICE) - && (plci == a->AdvSignalPLCI) && (Id & EXT_CONTROLLER)) - { - ch_a_v = ch_a + MIXER_IC_CHANNEL_BASE; - ch_a_s = (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? - a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id) : ch_a_v; - } - else - { - ch_a_v = ch_a; - ch_a_s = ch_a; - } - ch_b = a_b->li_base + (plci_b->li_bchannel_id - 1); - if (!a_b->li_pri && (plci_b->tel == ADV_VOICE) - && (plci_b == a_b->AdvSignalPLCI) && (plci_b_id & EXT_CONTROLLER)) - { - ch_b_v = ch_b + MIXER_IC_CHANNEL_BASE; - ch_b_s = (a_b->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? - a_b->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci_b->li_bchannel_id) : ch_b_v; - } - else - { - ch_b_v = ch_b; - ch_b_s = ch_b; - } - if (connect) - { - li_config_table[ch_a].flag_table[ch_a_v] &= ~LI_FLAG_MONITOR; - li_config_table[ch_a].flag_table[ch_a_s] &= ~LI_FLAG_MONITOR; - li_config_table[ch_a_v].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); - li_config_table[ch_a_s].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); - } - li_config_table[ch_a].flag_table[ch_b_v] &= ~LI_FLAG_MONITOR; - li_config_table[ch_a].flag_table[ch_b_s] &= ~LI_FLAG_MONITOR; - li_config_table[ch_b_v].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); - li_config_table[ch_b_s].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); - if (ch_a_v == ch_b_v) - { - li_config_table[ch_a_v].flag_table[ch_b_v] &= ~LI_FLAG_CONFERENCE; - li_config_table[ch_a_s].flag_table[ch_b_s] &= ~LI_FLAG_CONFERENCE; - } - else - { - if (li_config_table[ch_a_v].flag_table[ch_b_v] & LI_FLAG_CONFERENCE) - { - for (i = 0; i < li_total_channels; i++) - { - if (i != ch_a_v) - li_config_table[ch_a_v].flag_table[i] &= ~LI_FLAG_CONFERENCE; - } - } - if (li_config_table[ch_a_s].flag_table[ch_b_v] & LI_FLAG_CONFERENCE) - { - for (i = 0; i < li_total_channels; i++) - { - if (i != ch_a_s) - li_config_table[ch_a_s].flag_table[i] &= ~LI_FLAG_CONFERENCE; - } - } - if (li_config_table[ch_b_v].flag_table[ch_a_v] & LI_FLAG_CONFERENCE) - { - for (i = 0; i < li_total_channels; i++) - { - if (i != ch_a_v) - li_config_table[i].flag_table[ch_a_v] &= ~LI_FLAG_CONFERENCE; - } - } - if (li_config_table[ch_b_v].flag_table[ch_a_s] & LI_FLAG_CONFERENCE) - { - for (i = 0; i < li_total_channels; i++) - { - if (i != ch_a_s) - li_config_table[i].flag_table[ch_a_s] &= ~LI_FLAG_CONFERENCE; - } - } - } - if (li_flags & LI_FLAG_CONFERENCE_A_B) - { - li_config_table[ch_b_v].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; - li_config_table[ch_b_s].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; - li_config_table[ch_b_v].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; - li_config_table[ch_b_s].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; - } - if (li_flags & LI_FLAG_CONFERENCE_B_A) - { - li_config_table[ch_a_v].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; - li_config_table[ch_a_v].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; - li_config_table[ch_a_s].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; - li_config_table[ch_a_s].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; - } - if (li_flags & LI_FLAG_MONITOR_A) - { - li_config_table[ch_a].flag_table[ch_a_v] |= LI_FLAG_MONITOR; - li_config_table[ch_a].flag_table[ch_a_s] |= LI_FLAG_MONITOR; - } - if (li_flags & LI_FLAG_MONITOR_B) - { - li_config_table[ch_a].flag_table[ch_b_v] |= LI_FLAG_MONITOR; - li_config_table[ch_a].flag_table[ch_b_s] |= LI_FLAG_MONITOR; - } - if (li_flags & LI_FLAG_ANNOUNCEMENT_A) - { - li_config_table[ch_a_v].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; - li_config_table[ch_a_s].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; - } - if (li_flags & LI_FLAG_ANNOUNCEMENT_B) - { - li_config_table[ch_b_v].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; - li_config_table[ch_b_s].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; - } - if (li_flags & LI_FLAG_MIX_A) - { - li_config_table[ch_a_v].flag_table[ch_a] |= LI_FLAG_MIX; - li_config_table[ch_a_s].flag_table[ch_a] |= LI_FLAG_MIX; - } - if (li_flags & LI_FLAG_MIX_B) - { - li_config_table[ch_b_v].flag_table[ch_a] |= LI_FLAG_MIX; - li_config_table[ch_b_s].flag_table[ch_a] |= LI_FLAG_MIX; - } - if (ch_a_v != ch_a_s) - { - li_config_table[ch_a_v].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; - li_config_table[ch_a_s].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; - } - if (ch_b_v != ch_b_s) - { - li_config_table[ch_b_v].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; - li_config_table[ch_b_s].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; - } -} - - -static void li2_update_connect (dword Id, DIVA_CAPI_ADAPTER *a, PLCI *plci, - dword plci_b_id, byte connect, dword li_flags) -{ - word ch_a, ch_a_v, ch_a_s, ch_b, ch_b_v, ch_b_s; - PLCI *plci_b; - DIVA_CAPI_ADAPTER *a_b; - - a_b = &(adapter[MapController ((byte)(plci_b_id & 0x7f)) - 1]); - plci_b = &(a_b->plci[((plci_b_id >> 8) & 0xff) - 1]); - ch_a = a->li_base + (plci->li_bchannel_id - 1); - if (!a->li_pri && (plci->tel == ADV_VOICE) - && (plci == a->AdvSignalPLCI) && (Id & EXT_CONTROLLER)) - { - ch_a_v = ch_a + MIXER_IC_CHANNEL_BASE; - ch_a_s = (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? - a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id) : ch_a_v; - } - else - { - ch_a_v = ch_a; - ch_a_s = ch_a; - } - ch_b = a_b->li_base + (plci_b->li_bchannel_id - 1); - if (!a_b->li_pri && (plci_b->tel == ADV_VOICE) - && (plci_b == a_b->AdvSignalPLCI) && (plci_b_id & EXT_CONTROLLER)) - { - ch_b_v = ch_b + MIXER_IC_CHANNEL_BASE; - ch_b_s = (a_b->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? - a_b->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci_b->li_bchannel_id) : ch_b_v; - } - else - { - ch_b_v = ch_b; - ch_b_s = ch_b; - } - if (connect) - { - li_config_table[ch_b].flag_table[ch_b_v] &= ~LI_FLAG_MONITOR; - li_config_table[ch_b].flag_table[ch_b_s] &= ~LI_FLAG_MONITOR; - li_config_table[ch_b_v].flag_table[ch_b] &= ~LI_FLAG_MIX; - li_config_table[ch_b_s].flag_table[ch_b] &= ~LI_FLAG_MIX; - li_config_table[ch_b].flag_table[ch_b] &= ~LI_FLAG_PCCONNECT; - li_config_table[ch_b].chflags &= ~(LI_CHFLAG_MONITOR | LI_CHFLAG_MIX | LI_CHFLAG_LOOP); - } - li_config_table[ch_b_v].flag_table[ch_a_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_b_s].flag_table[ch_a_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_b_v].flag_table[ch_a_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_b_s].flag_table[ch_a_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_a_v].flag_table[ch_b_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_a_v].flag_table[ch_b_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_a_s].flag_table[ch_b_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - li_config_table[ch_a_s].flag_table[ch_b_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); - if (li_flags & LI2_FLAG_INTERCONNECT_A_B) - { - li_config_table[ch_b_v].flag_table[ch_a_v] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_b_s].flag_table[ch_a_v] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_b_v].flag_table[ch_a_s] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_b_s].flag_table[ch_a_s] |= LI_FLAG_INTERCONNECT; - } - if (li_flags & LI2_FLAG_INTERCONNECT_B_A) - { - li_config_table[ch_a_v].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_a_v].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_a_s].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_a_s].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; - } - if (li_flags & LI2_FLAG_MONITOR_B) - { - li_config_table[ch_b].flag_table[ch_b_v] |= LI_FLAG_MONITOR; - li_config_table[ch_b].flag_table[ch_b_s] |= LI_FLAG_MONITOR; - } - if (li_flags & LI2_FLAG_MIX_B) - { - li_config_table[ch_b_v].flag_table[ch_b] |= LI_FLAG_MIX; - li_config_table[ch_b_s].flag_table[ch_b] |= LI_FLAG_MIX; - } - if (li_flags & LI2_FLAG_MONITOR_X) - li_config_table[ch_b].chflags |= LI_CHFLAG_MONITOR; - if (li_flags & LI2_FLAG_MIX_X) - li_config_table[ch_b].chflags |= LI_CHFLAG_MIX; - if (li_flags & LI2_FLAG_LOOP_B) - { - li_config_table[ch_b_v].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_b_s].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_b_v].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; - li_config_table[ch_b_s].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; - } - if (li_flags & LI2_FLAG_LOOP_PC) - li_config_table[ch_b].flag_table[ch_b] |= LI_FLAG_PCCONNECT; - if (li_flags & LI2_FLAG_LOOP_X) - li_config_table[ch_b].chflags |= LI_CHFLAG_LOOP; - if (li_flags & LI2_FLAG_PCCONNECT_A_B) - li_config_table[ch_b_s].flag_table[ch_a_s] |= LI_FLAG_PCCONNECT; - if (li_flags & LI2_FLAG_PCCONNECT_B_A) - li_config_table[ch_a_s].flag_table[ch_b_s] |= LI_FLAG_PCCONNECT; - if (ch_a_v != ch_a_s) - { - li_config_table[ch_a_v].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; - li_config_table[ch_a_s].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; - } - if (ch_b_v != ch_b_s) - { - li_config_table[ch_b_v].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; - li_config_table[ch_b_s].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; - } -} - - -static word li_check_main_plci (dword Id, PLCI *plci) -{ - if (plci == NULL) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong PLCI", - UnMapId (Id), (char *)(FILE_), __LINE__)); - return (_WRONG_IDENTIFIER); - } - if (!plci->State - || !plci->NL.Id || plci->nl_remove_id - || (plci->li_bchannel_id == 0)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong state", - UnMapId (Id), (char *)(FILE_), __LINE__)); - return (_WRONG_STATE); - } - li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci = plci; - return (GOOD); -} - - -static PLCI *li_check_plci_b (dword Id, PLCI *plci, - dword plci_b_id, word plci_b_write_pos, byte *p_result) -{ - byte ctlr_b; - PLCI *plci_b; - - if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : - LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 2) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI request overrun", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE); - return (NULL); - } - ctlr_b = 0; - if ((plci_b_id & 0x7f) != 0) - { - ctlr_b = MapController ((byte)(plci_b_id & 0x7f)); - if ((ctlr_b > max_adapter) || ((ctlr_b != 0) && (adapter[ctlr_b - 1].request == NULL))) - ctlr_b = 0; - } - if ((ctlr_b == 0) - || (((plci_b_id >> 8) & 0xff) == 0) - || (((plci_b_id >> 8) & 0xff) > adapter[ctlr_b - 1].max_plci)) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI invalid second PLCI %08lx", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b_id)); - PUT_WORD (p_result, _WRONG_IDENTIFIER); - return (NULL); - } - plci_b = &(adapter[ctlr_b - 1].plci[((plci_b_id >> 8) & 0xff) - 1]); - if (!plci_b->State - || !plci_b->NL.Id || plci_b->nl_remove_id - || (plci_b->li_bchannel_id == 0)) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI peer in wrong state %08lx", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b_id)); - PUT_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE); - return (NULL); - } - li_config_table[plci_b->adapter->li_base + (plci_b->li_bchannel_id - 1)].plci = plci_b; - if (((byte)(plci_b_id & ~EXT_CONTROLLER)) != - ((byte)(UnMapController (plci->adapter->Id) & ~EXT_CONTROLLER)) - && (!(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - || !(plci_b->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT))) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI not on same ctrl %08lx", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b_id)); - PUT_WORD (p_result, _WRONG_IDENTIFIER); - return (NULL); - } - if (!(get_b1_facilities (plci_b, add_b1_facilities (plci_b, plci_b->B1_resource, - (word)(plci_b->B1_facilities | B1_FACILITY_MIXER))) & B1_FACILITY_MIXER)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Interconnect peer cannot mix %d", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b->B1_resource)); - PUT_WORD (p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE); - return (NULL); - } - return (plci_b); -} - - -static PLCI *li2_check_plci_b (dword Id, PLCI *plci, - dword plci_b_id, word plci_b_write_pos, byte *p_result) -{ - byte ctlr_b; - PLCI *plci_b; - - if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : - LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 2) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI request overrun", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (p_result, _WRONG_STATE); - return (NULL); - } - ctlr_b = 0; - if ((plci_b_id & 0x7f) != 0) - { - ctlr_b = MapController ((byte)(plci_b_id & 0x7f)); - if ((ctlr_b > max_adapter) || ((ctlr_b != 0) && (adapter[ctlr_b - 1].request == NULL))) - ctlr_b = 0; - } - if ((ctlr_b == 0) - || (((plci_b_id >> 8) & 0xff) == 0) - || (((plci_b_id >> 8) & 0xff) > adapter[ctlr_b - 1].max_plci)) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI invalid second PLCI %08lx", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b_id)); - PUT_WORD (p_result, _WRONG_IDENTIFIER); - return (NULL); - } - plci_b = &(adapter[ctlr_b - 1].plci[((plci_b_id >> 8) & 0xff) - 1]); - if (!plci_b->State - || !plci_b->NL.Id || plci_b->nl_remove_id - || (plci_b->li_bchannel_id == 0) - || (li_config_table[plci_b->adapter->li_base + (plci_b->li_bchannel_id - 1)].plci != plci_b)) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI peer in wrong state %08lx", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b_id)); - PUT_WORD (p_result, _WRONG_STATE); - return (NULL); - } - if (((byte)(plci_b_id & ~EXT_CONTROLLER)) != - ((byte)(UnMapController (plci->adapter->Id) & ~EXT_CONTROLLER)) - && (!(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - || !(plci_b->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT))) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI not on same ctrl %08lx", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b_id)); - PUT_WORD (p_result, _WRONG_IDENTIFIER); - return (NULL); - } - if (!(get_b1_facilities (plci_b, add_b1_facilities (plci_b, plci_b->B1_resource, - (word)(plci_b->B1_facilities | B1_FACILITY_MIXER))) & B1_FACILITY_MIXER)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Interconnect peer cannot mix %d", - UnMapId (Id), (char *)(FILE_), __LINE__, plci_b->B1_resource)); - PUT_WORD (p_result, _WRONG_STATE); - return (NULL); - } - return (plci_b); -} - - -static byte mixer_request (dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) -{ - word Info; - word i; - dword d, li_flags, plci_b_id; - PLCI *plci_b; - API_PARSE li_parms[3]; - API_PARSE li_req_parms[3]; - API_PARSE li_participant_struct[2]; - API_PARSE li_participant_parms[3]; - word participant_parms_pos; - byte result_buffer[32]; - byte *result; - word result_pos; - word plci_b_write_pos; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_request", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - Info = GOOD; - result = result_buffer; - result_buffer[0] = 0; - if (!(a->profile.Global_Options & GL_LINE_INTERCONNECT_SUPPORTED)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Facility not supported", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - } - else if (api_parse (&msg[1].info[1], msg[1].length, "ws", li_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - } - else - { - result_buffer[0] = 3; - PUT_WORD (&result_buffer[1], GET_WORD (li_parms[0].info)); - result_buffer[3] = 0; - switch (GET_WORD (li_parms[0].info)) - { - case LI_GET_SUPPORTED_SERVICES: - if (appl->appl_flags & APPL_FLAG_OLD_LI_SPEC) - { - result_buffer[0] = 17; - result_buffer[3] = 14; - PUT_WORD (&result_buffer[4], GOOD); - d = 0; - if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_CH) - d |= LI_CONFERENCING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_PC) - d |= LI_MONITORING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_PC_CH) - d |= LI_ANNOUNCEMENTS_SUPPORTED | LI_MIXING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - d |= LI_CROSS_CONTROLLER_SUPPORTED; - PUT_DWORD (&result_buffer[6], d); - if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - { - d = 0; - for (i = 0; i < li_total_channels; i++) - { - if ((li_config_table[i].adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - && (li_config_table[i].adapter->li_pri - || (i < li_config_table[i].adapter->li_base + MIXER_BCHANNELS_BRI))) - { - d++; - } - } - } - else - { - d = a->li_pri ? a->li_channels : MIXER_BCHANNELS_BRI; - } - PUT_DWORD (&result_buffer[10], d / 2); - PUT_DWORD (&result_buffer[14], d); - } - else - { - result_buffer[0] = 25; - result_buffer[3] = 22; - PUT_WORD (&result_buffer[4], GOOD); - d = LI2_ASYMMETRIC_SUPPORTED | LI2_B_LOOPING_SUPPORTED | LI2_X_LOOPING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_PC) - d |= LI2_MONITORING_SUPPORTED | LI2_REMOTE_MONITORING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_PC_CH) - d |= LI2_MIXING_SUPPORTED | LI2_REMOTE_MIXING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_PC_PC) - d |= LI2_PC_LOOPING_SUPPORTED; - if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - d |= LI2_CROSS_CONTROLLER_SUPPORTED; - PUT_DWORD (&result_buffer[6], d); - d = a->li_pri ? a->li_channels : MIXER_BCHANNELS_BRI; - PUT_DWORD (&result_buffer[10], d / 2); - PUT_DWORD (&result_buffer[14], d - 1); - if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - { - d = 0; - for (i = 0; i < li_total_channels; i++) - { - if ((li_config_table[i].adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) - && (li_config_table[i].adapter->li_pri - || (i < li_config_table[i].adapter->li_base + MIXER_BCHANNELS_BRI))) - { - d++; - } - } - } - PUT_DWORD (&result_buffer[18], d / 2); - PUT_DWORD (&result_buffer[22], d - 1); - } - break; - - case LI_REQ_CONNECT: - if (li_parms[1].length == 8) - { - appl->appl_flags |= APPL_FLAG_OLD_LI_SPEC; - if (api_parse (&li_parms[1].info[1], li_parms[1].length, "dd", li_req_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - plci_b_id = GET_DWORD (li_req_parms[0].info) & 0xffff; - li_flags = GET_DWORD (li_req_parms[1].info); - Info = li_check_main_plci (Id, plci); - result_buffer[0] = 9; - result_buffer[3] = 6; - PUT_DWORD (&result_buffer[4], plci_b_id); - PUT_WORD (&result_buffer[8], GOOD); - if (Info != GOOD) - break; - result = plci->saved_msg.info; - for (i = 0; i <= result_buffer[0]; i++) - result[i] = result_buffer[i]; - plci_b_write_pos = plci->li_plci_b_write_pos; - plci_b = li_check_plci_b (Id, plci, plci_b_id, plci_b_write_pos, &result[8]); - if (plci_b == NULL) - break; - li_update_connect (Id, a, plci, plci_b_id, true, li_flags); - plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_LAST_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - plci->li_plci_b_write_pos = plci_b_write_pos; - } - else - { - appl->appl_flags &= ~APPL_FLAG_OLD_LI_SPEC; - if (api_parse (&li_parms[1].info[1], li_parms[1].length, "ds", li_req_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - li_flags = GET_DWORD (li_req_parms[0].info) & ~(LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A); - Info = li_check_main_plci (Id, plci); - result_buffer[0] = 7; - result_buffer[3] = 4; - PUT_WORD (&result_buffer[4], Info); - result_buffer[6] = 0; - if (Info != GOOD) - break; - result = plci->saved_msg.info; - for (i = 0; i <= result_buffer[0]; i++) - result[i] = result_buffer[i]; - plci_b_write_pos = plci->li_plci_b_write_pos; - participant_parms_pos = 0; - result_pos = 7; - li2_update_connect (Id, a, plci, UnMapId (Id), true, li_flags); - while (participant_parms_pos < li_req_parms[1].length) - { - result[result_pos] = 6; - result_pos += 7; - PUT_DWORD (&result[result_pos - 6], 0); - PUT_WORD (&result[result_pos - 2], GOOD); - if (api_parse (&li_req_parms[1].info[1 + participant_parms_pos], - (word)(li_parms[1].length - participant_parms_pos), "s", li_participant_struct)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); - break; - } - if (api_parse (&li_participant_struct[0].info[1], - li_participant_struct[0].length, "dd", li_participant_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); - break; - } - plci_b_id = GET_DWORD (li_participant_parms[0].info) & 0xffff; - li_flags = GET_DWORD (li_participant_parms[1].info); - PUT_DWORD (&result[result_pos - 6], plci_b_id); - if (sizeof(result) - result_pos < 7) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI result overrun", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (&result[result_pos - 2], _WRONG_STATE); - break; - } - plci_b = li2_check_plci_b (Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]); - if (plci_b != NULL) - { - li2_update_connect (Id, a, plci, plci_b_id, true, li_flags); - plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | - ((li_flags & (LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A | - LI2_FLAG_PCCONNECT_A_B | LI2_FLAG_PCCONNECT_B_A)) ? 0 : LI_PLCI_B_DISC_FLAG); - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - } - participant_parms_pos = (word)((&li_participant_struct[0].info[1 + li_participant_struct[0].length]) - - (&li_req_parms[1].info[1])); - } - result[0] = (byte)(result_pos - 1); - result[3] = (byte)(result_pos - 4); - result[6] = (byte)(result_pos - 7); - i = (plci_b_write_pos == 0) ? LI_PLCI_B_QUEUE_ENTRIES-1 : plci_b_write_pos - 1; - if ((plci_b_write_pos == plci->li_plci_b_read_pos) - || (plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)) - { - plci->li_plci_b_queue[plci_b_write_pos] = LI_PLCI_B_SKIP_FLAG | LI_PLCI_B_LAST_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - } - else - plci->li_plci_b_queue[i] |= LI_PLCI_B_LAST_FLAG; - plci->li_plci_b_write_pos = plci_b_write_pos; - } - mixer_calculate_coefs (a); - plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel; - mixer_notify_update (plci, true); - sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, - "wwS", Info, SELECTOR_LINE_INTERCONNECT, result); - plci->command = 0; - plci->li_cmd = GET_WORD (li_parms[0].info); - start_internal_command (Id, plci, mixer_command); - return (false); - - case LI_REQ_DISCONNECT: - if (li_parms[1].length == 4) - { - appl->appl_flags |= APPL_FLAG_OLD_LI_SPEC; - if (api_parse (&li_parms[1].info[1], li_parms[1].length, "d", li_req_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - plci_b_id = GET_DWORD (li_req_parms[0].info) & 0xffff; - Info = li_check_main_plci (Id, plci); - result_buffer[0] = 9; - result_buffer[3] = 6; - PUT_DWORD (&result_buffer[4], GET_DWORD (li_req_parms[0].info)); - PUT_WORD (&result_buffer[8], GOOD); - if (Info != GOOD) - break; - result = plci->saved_msg.info; - for (i = 0; i <= result_buffer[0]; i++) - result[i] = result_buffer[i]; - plci_b_write_pos = plci->li_plci_b_write_pos; - plci_b = li_check_plci_b (Id, plci, plci_b_id, plci_b_write_pos, &result[8]); - if (plci_b == NULL) - break; - li_update_connect (Id, a, plci, plci_b_id, false, 0); - plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_DISC_FLAG | LI_PLCI_B_LAST_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - plci->li_plci_b_write_pos = plci_b_write_pos; - } - else - { - appl->appl_flags &= ~APPL_FLAG_OLD_LI_SPEC; - if (api_parse (&li_parms[1].info[1], li_parms[1].length, "s", li_req_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - break; - } - Info = li_check_main_plci (Id, plci); - result_buffer[0] = 7; - result_buffer[3] = 4; - PUT_WORD (&result_buffer[4], Info); - result_buffer[6] = 0; - if (Info != GOOD) - break; - result = plci->saved_msg.info; - for (i = 0; i <= result_buffer[0]; i++) - result[i] = result_buffer[i]; - plci_b_write_pos = plci->li_plci_b_write_pos; - participant_parms_pos = 0; - result_pos = 7; - while (participant_parms_pos < li_req_parms[0].length) - { - result[result_pos] = 6; - result_pos += 7; - PUT_DWORD (&result[result_pos - 6], 0); - PUT_WORD (&result[result_pos - 2], GOOD); - if (api_parse (&li_req_parms[0].info[1 + participant_parms_pos], - (word)(li_parms[1].length - participant_parms_pos), "s", li_participant_struct)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); - break; - } - if (api_parse (&li_participant_struct[0].info[1], - li_participant_struct[0].length, "d", li_participant_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); - break; - } - plci_b_id = GET_DWORD (li_participant_parms[0].info) & 0xffff; - PUT_DWORD (&result[result_pos - 6], plci_b_id); - if (sizeof(result) - result_pos < 7) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI result overrun", - UnMapId (Id), (char *)(FILE_), __LINE__)); - PUT_WORD (&result[result_pos - 2], _WRONG_STATE); - break; - } - plci_b = li2_check_plci_b (Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]); - if (plci_b != NULL) - { - li2_update_connect (Id, a, plci, plci_b_id, false, 0); - plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_DISC_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - } - participant_parms_pos = (word)((&li_participant_struct[0].info[1 + li_participant_struct[0].length]) - - (&li_req_parms[0].info[1])); - } - result[0] = (byte)(result_pos - 1); - result[3] = (byte)(result_pos - 4); - result[6] = (byte)(result_pos - 7); - i = (plci_b_write_pos == 0) ? LI_PLCI_B_QUEUE_ENTRIES-1 : plci_b_write_pos - 1; - if ((plci_b_write_pos == plci->li_plci_b_read_pos) - || (plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)) - { - plci->li_plci_b_queue[plci_b_write_pos] = LI_PLCI_B_SKIP_FLAG | LI_PLCI_B_LAST_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - } - else - plci->li_plci_b_queue[i] |= LI_PLCI_B_LAST_FLAG; - plci->li_plci_b_write_pos = plci_b_write_pos; - } - mixer_calculate_coefs (a); - plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel; - mixer_notify_update (plci, true); - sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, - "wwS", Info, SELECTOR_LINE_INTERCONNECT, result); - plci->command = 0; - plci->li_cmd = GET_WORD (li_parms[0].info); - start_internal_command (Id, plci, mixer_command); - return (false); - - case LI_REQ_SILENT_UPDATE: - if (!plci || !plci->State - || !plci->NL.Id || plci->nl_remove_id - || (plci->li_bchannel_id == 0) - || (li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci != plci)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong state", - UnMapId (Id), (char *)(FILE_), __LINE__)); - return (false); - } - plci_b_write_pos = plci->li_plci_b_write_pos; - if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : - LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 2) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI request overrun", - UnMapId (Id), (char *)(FILE_), __LINE__)); - return (false); - } - i = (plci_b_write_pos == 0) ? LI_PLCI_B_QUEUE_ENTRIES-1 : plci_b_write_pos - 1; - if ((plci_b_write_pos == plci->li_plci_b_read_pos) - || (plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)) - { - plci->li_plci_b_queue[plci_b_write_pos] = LI_PLCI_B_SKIP_FLAG | LI_PLCI_B_LAST_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - } - else - plci->li_plci_b_queue[i] |= LI_PLCI_B_LAST_FLAG; - plci->li_plci_b_write_pos = plci_b_write_pos; - plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel; - plci->command = 0; - plci->li_cmd = GET_WORD (li_parms[0].info); - start_internal_command (Id, plci, mixer_command); - return (false); - - default: - dbug (1, dprintf ("[%06lx] %s,%d: LI unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, GET_WORD (li_parms[0].info))); - Info = _FACILITY_NOT_SUPPORTED; - } - } - sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, - "wwS", Info, SELECTOR_LINE_INTERCONNECT, result); - return (false); -} - - -static void mixer_indication_coefs_set (dword Id, PLCI *plci) -{ - dword d; - byte result[12]; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_indication_coefs_set", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - if (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos) - { - do - { - d = plci->li_plci_b_queue[plci->li_plci_b_read_pos]; - if (!(d & LI_PLCI_B_SKIP_FLAG)) - { - if (plci->appl->appl_flags & APPL_FLAG_OLD_LI_SPEC) - { - if (d & LI_PLCI_B_DISC_FLAG) - { - result[0] = 5; - PUT_WORD (&result[1], LI_IND_DISCONNECT); - result[3] = 2; - PUT_WORD (&result[4], _LI_USER_INITIATED); - } - else - { - result[0] = 7; - PUT_WORD (&result[1], LI_IND_CONNECT_ACTIVE); - result[3] = 4; - PUT_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK); - } - } - else - { - if (d & LI_PLCI_B_DISC_FLAG) - { - result[0] = 9; - PUT_WORD (&result[1], LI_IND_DISCONNECT); - result[3] = 6; - PUT_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK); - PUT_WORD (&result[8], _LI_USER_INITIATED); - } - else - { - result[0] = 7; - PUT_WORD (&result[1], LI_IND_CONNECT_ACTIVE); - result[3] = 4; - PUT_DWORD (&result[4], d & ~LI_PLCI_B_FLAG_MASK); - } - } - sendf (plci->appl, _FACILITY_I, Id & 0xffffL, 0, - "ws", SELECTOR_LINE_INTERCONNECT, result); - } - plci->li_plci_b_read_pos = (plci->li_plci_b_read_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? - 0 : plci->li_plci_b_read_pos + 1; - } while (!(d & LI_PLCI_B_LAST_FLAG) && (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos)); - } -} - - -static void mixer_indication_xconnect_from (dword Id, PLCI *plci, byte *msg, word length) -{ - word i, j, ch; - struct xconnect_transfer_address_s s, *p; - DIVA_CAPI_ADAPTER *a; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_indication_xconnect_from %d", - UnMapId (Id), (char *)(FILE_), __LINE__, (int) length)); - - a = plci->adapter; - i = 1; - for (i = 1; i < length; i += 16) - { - s.card_address.low = msg[i] | (msg[i+1] << 8) | (((dword)(msg[i+2])) << 16) | (((dword)(msg[i+3])) << 24); - s.card_address.high = msg[i+4] | (msg[i+5] << 8) | (((dword)(msg[i+6])) << 16) | (((dword)(msg[i+7])) << 24); - s.offset = msg[i+8] | (msg[i+9] << 8) | (((dword)(msg[i+10])) << 16) | (((dword)(msg[i+11])) << 24); - ch = msg[i+12] | (msg[i+13] << 8); - j = ch & XCONNECT_CHANNEL_NUMBER_MASK; - if (!a->li_pri && (plci->li_bchannel_id == 2)) - j = 1 - j; - j += a->li_base; - if (ch & XCONNECT_CHANNEL_PORT_PC) - p = &(li_config_table[j].send_pc); - else - p = &(li_config_table[j].send_b); - p->card_address.low = s.card_address.low; - p->card_address.high = s.card_address.high; - p->offset = s.offset; - li_config_table[j].channel |= LI_CHANNEL_ADDRESSES_SET; - } - if (plci->internal_command_queue[0] - && ((plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_2) - || (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_3) - || (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_4))) - { - (*(plci->internal_command_queue[0]))(Id, plci, 0); - if (!plci->internal_command) - next_internal_command (Id, plci); - } - mixer_notify_update (plci, true); -} - - -static void mixer_indication_xconnect_to (dword Id, PLCI *plci, byte *msg, word length) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_indication_xconnect_to %d", - UnMapId (Id), (char *)(FILE_), __LINE__, (int) length)); - -} - - -static byte mixer_notify_source_removed (PLCI *plci, dword plci_b_id) -{ - word plci_b_write_pos; - - plci_b_write_pos = plci->li_plci_b_write_pos; - if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : - LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 1) - { - dbug (1, dprintf ("[%06lx] %s,%d: LI request overrun", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - return (false); - } - plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_DISC_FLAG; - plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES-1) ? 0 : plci_b_write_pos + 1; - plci->li_plci_b_write_pos = plci_b_write_pos; - return (true); -} - - -static void mixer_remove (PLCI *plci) -{ - DIVA_CAPI_ADAPTER *a; - PLCI *notify_plci; - dword plci_b_id; - word i, j; - - dbug (1, dprintf ("[%06lx] %s,%d: mixer_remove", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - a = plci->adapter; - plci_b_id = (plci->Id << 8) | UnMapController (plci->adapter->Id); - if (a->profile.Global_Options & GL_LINE_INTERCONNECT_SUPPORTED) - { - if ((plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - i = a->li_base + (plci->li_bchannel_id - 1); - if ((li_config_table[i].curchnl | li_config_table[i].channel) & LI_CHANNEL_INVOLVED) - { - for (j = 0; j < li_total_channels; j++) - { - if ((li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) - || (li_config_table[j].flag_table[i] & LI_FLAG_INTERCONNECT)) - { - notify_plci = li_config_table[j].plci; - if ((notify_plci != NULL) - && (notify_plci != plci) - && (notify_plci->appl != NULL) - && !(notify_plci->appl->appl_flags & APPL_FLAG_OLD_LI_SPEC) - && (notify_plci->State) - && notify_plci->NL.Id && !notify_plci->nl_remove_id) - { - mixer_notify_source_removed (notify_plci, plci_b_id); - } - } - } - mixer_clear_config (plci); - mixer_calculate_coefs (a); - mixer_notify_update (plci, true); - } - li_config_table[i].plci = NULL; - plci->li_bchannel_id = 0; - } - } -} - - -/*------------------------------------------------------------------*/ -/* Echo canceller facilities */ -/*------------------------------------------------------------------*/ - - -static void ec_write_parameters (PLCI *plci) -{ - word w; - byte parameter_buffer[6]; - - dbug (1, dprintf ("[%06lx] %s,%d: ec_write_parameters", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - parameter_buffer[0] = 5; - parameter_buffer[1] = DSP_CTRL_SET_LEC_PARAMETERS; - PUT_WORD (¶meter_buffer[2], plci->ec_idi_options); - plci->ec_idi_options &= ~LEC_RESET_COEFFICIENTS; - w = (plci->ec_tail_length == 0) ? 128 : plci->ec_tail_length; - PUT_WORD (¶meter_buffer[4], w); - add_p (plci, FTY, parameter_buffer); - sig_req (plci, TEL_CTRL, 0); - send_req (plci); -} - - -static void ec_clear_config (PLCI *plci) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: ec_clear_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - plci->ec_idi_options = LEC_ENABLE_ECHO_CANCELLER | - LEC_MANUAL_DISABLE | LEC_ENABLE_NONLINEAR_PROCESSING; - plci->ec_tail_length = 0; -} - - -static void ec_prepare_switch (dword Id, PLCI *plci) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: ec_prepare_switch", - UnMapId (Id), (char *)(FILE_), __LINE__)); - -} - - -static word ec_save_config (dword Id, PLCI *plci, byte Rc) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: ec_save_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - - return (GOOD); -} - - -static word ec_restore_config (dword Id, PLCI *plci, byte Rc) -{ - word Info; - - dbug (1, dprintf ("[%06lx] %s,%d: ec_restore_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - - Info = GOOD; - if (plci->B1_facilities & B1_FACILITY_EC) - { - switch (plci->adjust_b_state) - { - case ADJUST_B_RESTORE_EC_1: - plci->internal_command = plci->adjust_b_command; - if (plci->sig_req) - { - plci->adjust_b_state = ADJUST_B_RESTORE_EC_1; - break; - } - ec_write_parameters (plci); - plci->adjust_b_state = ADJUST_B_RESTORE_EC_2; - break; - case ADJUST_B_RESTORE_EC_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Restore EC failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - break; - } - } - return (Info); -} - - -static void ec_command (dword Id, PLCI *plci, byte Rc) -{ - word internal_command, Info; - byte result[8]; - - dbug (1, dprintf ("[%06lx] %s,%d: ec_command %02x %04x %04x %04x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command, - plci->ec_cmd, plci->ec_idi_options, plci->ec_tail_length)); - - Info = GOOD; - if (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) - { - result[0] = 2; - PUT_WORD (&result[1], EC_SUCCESS); - } - else - { - result[0] = 5; - PUT_WORD (&result[1], plci->ec_cmd); - result[3] = 2; - PUT_WORD (&result[4], GOOD); - } - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (plci->ec_cmd) - { - case EC_ENABLE_OPERATION: - case EC_FREEZE_COEFFICIENTS: - case EC_RESUME_COEFFICIENT_UPDATE: - case EC_RESET_COEFFICIENTS: - switch (internal_command) - { - default: - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities | - B1_FACILITY_EC), EC_COMMAND_1); - case EC_COMMAND_1: - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Load EC failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (plci->internal_command) - return; - case EC_COMMAND_2: - if (plci->sig_req) - { - plci->internal_command = EC_COMMAND_2; - return; - } - plci->internal_command = EC_COMMAND_3; - ec_write_parameters (plci); - return; - case EC_COMMAND_3: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Enable EC failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - break; - } - break; - - case EC_DISABLE_OPERATION: - switch (internal_command) - { - default: - case EC_COMMAND_1: - if (plci->B1_facilities & B1_FACILITY_EC) - { - if (plci->sig_req) - { - plci->internal_command = EC_COMMAND_1; - return; - } - plci->internal_command = EC_COMMAND_2; - ec_write_parameters (plci); - return; - } - Rc = OK; - case EC_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Disable EC failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - adjust_b1_resource (Id, plci, NULL, (word)(plci->B1_facilities & - ~B1_FACILITY_EC), EC_COMMAND_3); - case EC_COMMAND_3: - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Unload EC failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - break; - } - if (plci->internal_command) - return; - break; - } - break; - } - sendf (plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->number, - "wws", Info, (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) ? - PRIV_SELECTOR_ECHO_CANCELLER : SELECTOR_ECHO_CANCELLER, result); -} - - -static byte ec_request (dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) -{ - word Info; - word opt; - API_PARSE ec_parms[3]; - byte result[16]; - - dbug (1, dprintf ("[%06lx] %s,%d: ec_request", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - Info = GOOD; - result[0] = 0; - if (!(a->man_profile.private_options & (1L << PRIVATE_ECHO_CANCELLER))) - { - dbug (1, dprintf ("[%06lx] %s,%d: Facility not supported", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _FACILITY_NOT_SUPPORTED; - } - else - { - if (appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) - { - if (api_parse (&msg[1].info[1], msg[1].length, "w", ec_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - } - else - { - if (plci == NULL) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong PLCI", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_IDENTIFIER; - } - else if (!plci->State || !plci->NL.Id || plci->nl_remove_id) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong state", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_STATE; - } - else - { - plci->command = 0; - plci->ec_cmd = GET_WORD (ec_parms[0].info); - plci->ec_idi_options &= ~(LEC_MANUAL_DISABLE | LEC_RESET_COEFFICIENTS); - result[0] = 2; - PUT_WORD (&result[1], EC_SUCCESS); - if (msg[1].length >= 4) - { - opt = GET_WORD (&ec_parms[0].info[2]); - plci->ec_idi_options &= ~(LEC_ENABLE_NONLINEAR_PROCESSING | - LEC_ENABLE_2100HZ_DETECTOR | LEC_REQUIRE_2100HZ_REVERSALS); - if (!(opt & EC_DISABLE_NON_LINEAR_PROCESSING)) - plci->ec_idi_options |= LEC_ENABLE_NONLINEAR_PROCESSING; - if (opt & EC_DETECT_DISABLE_TONE) - plci->ec_idi_options |= LEC_ENABLE_2100HZ_DETECTOR; - if (!(opt & EC_DO_NOT_REQUIRE_REVERSALS)) - plci->ec_idi_options |= LEC_REQUIRE_2100HZ_REVERSALS; - if (msg[1].length >= 6) - { - plci->ec_tail_length = GET_WORD (&ec_parms[0].info[4]); - } - } - switch (plci->ec_cmd) - { - case EC_ENABLE_OPERATION: - plci->ec_idi_options &= ~LEC_FREEZE_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - case EC_DISABLE_OPERATION: - plci->ec_idi_options = LEC_ENABLE_ECHO_CANCELLER | - LEC_MANUAL_DISABLE | LEC_ENABLE_NONLINEAR_PROCESSING | - LEC_RESET_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - case EC_FREEZE_COEFFICIENTS: - plci->ec_idi_options |= LEC_FREEZE_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - case EC_RESUME_COEFFICIENT_UPDATE: - plci->ec_idi_options &= ~LEC_FREEZE_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - case EC_RESET_COEFFICIENTS: - plci->ec_idi_options |= LEC_RESET_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - default: - dbug (1, dprintf ("[%06lx] %s,%d: EC unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, plci->ec_cmd)); - PUT_WORD (&result[1], EC_UNSUPPORTED_OPERATION); - } - } - } - } - else - { - if (api_parse (&msg[1].info[1], msg[1].length, "ws", ec_parms)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong message format", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_MESSAGE_FORMAT; - } - else - { - if (GET_WORD (ec_parms[0].info) == EC_GET_SUPPORTED_SERVICES) - { - result[0] = 11; - PUT_WORD (&result[1], EC_GET_SUPPORTED_SERVICES); - result[3] = 8; - PUT_WORD (&result[4], GOOD); - PUT_WORD (&result[6], 0x0007); - PUT_WORD (&result[8], LEC_MAX_SUPPORTED_TAIL_LENGTH); - PUT_WORD (&result[10], 0); - } - else if (plci == NULL) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong PLCI", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_IDENTIFIER; - } - else if (!plci->State || !plci->NL.Id || plci->nl_remove_id) - { - dbug (1, dprintf ("[%06lx] %s,%d: Wrong state", - UnMapId (Id), (char *)(FILE_), __LINE__)); - Info = _WRONG_STATE; - } - else - { - plci->command = 0; - plci->ec_cmd = GET_WORD (ec_parms[0].info); - plci->ec_idi_options &= ~(LEC_MANUAL_DISABLE | LEC_RESET_COEFFICIENTS); - result[0] = 5; - PUT_WORD (&result[1], plci->ec_cmd); - result[3] = 2; - PUT_WORD (&result[4], GOOD); - plci->ec_idi_options &= ~(LEC_ENABLE_NONLINEAR_PROCESSING | - LEC_ENABLE_2100HZ_DETECTOR | LEC_REQUIRE_2100HZ_REVERSALS); - plci->ec_tail_length = 0; - if (ec_parms[1].length >= 2) - { - opt = GET_WORD (&ec_parms[1].info[1]); - if (opt & EC_ENABLE_NON_LINEAR_PROCESSING) - plci->ec_idi_options |= LEC_ENABLE_NONLINEAR_PROCESSING; - if (opt & EC_DETECT_DISABLE_TONE) - plci->ec_idi_options |= LEC_ENABLE_2100HZ_DETECTOR; - if (!(opt & EC_DO_NOT_REQUIRE_REVERSALS)) - plci->ec_idi_options |= LEC_REQUIRE_2100HZ_REVERSALS; - if (ec_parms[1].length >= 4) - { - plci->ec_tail_length = GET_WORD (&ec_parms[1].info[3]); - } - } - switch (plci->ec_cmd) - { - case EC_ENABLE_OPERATION: - plci->ec_idi_options &= ~LEC_FREEZE_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - case EC_DISABLE_OPERATION: - plci->ec_idi_options = LEC_ENABLE_ECHO_CANCELLER | - LEC_MANUAL_DISABLE | LEC_ENABLE_NONLINEAR_PROCESSING | - LEC_RESET_COEFFICIENTS; - start_internal_command (Id, plci, ec_command); - return (false); - - default: - dbug (1, dprintf ("[%06lx] %s,%d: EC unknown request %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, plci->ec_cmd)); - PUT_WORD (&result[4], _FACILITY_SPECIFIC_FUNCTION_NOT_SUPP); - } - } - } - } - } - sendf (appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, - "wws", Info, (appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) ? - PRIV_SELECTOR_ECHO_CANCELLER : SELECTOR_ECHO_CANCELLER, result); - return (false); -} - - -static void ec_indication (dword Id, PLCI *plci, byte *msg, word length) -{ - byte result[8]; - - dbug (1, dprintf ("[%06lx] %s,%d: ec_indication", - UnMapId (Id), (char *)(FILE_), __LINE__)); - - if (!(plci->ec_idi_options & LEC_MANUAL_DISABLE)) - { - if (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) - { - result[0] = 2; - PUT_WORD (&result[1], 0); - switch (msg[1]) - { - case LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ: - PUT_WORD (&result[1], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ); - break; - case LEC_DISABLE_TYPE_REVERSED_2100HZ: - PUT_WORD (&result[1], EC_BYPASS_DUE_TO_REVERSED_2100HZ); - break; - case LEC_DISABLE_RELEASED: - PUT_WORD (&result[1], EC_BYPASS_RELEASED); - break; - } - } - else - { - result[0] = 5; - PUT_WORD (&result[1], EC_BYPASS_INDICATION); - result[3] = 2; - PUT_WORD (&result[4], 0); - switch (msg[1]) - { - case LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ: - PUT_WORD (&result[4], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ); - break; - case LEC_DISABLE_TYPE_REVERSED_2100HZ: - PUT_WORD (&result[4], EC_BYPASS_DUE_TO_REVERSED_2100HZ); - break; - case LEC_DISABLE_RELEASED: - PUT_WORD (&result[4], EC_BYPASS_RELEASED); - break; - } - } - sendf (plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) ? - PRIV_SELECTOR_ECHO_CANCELLER : SELECTOR_ECHO_CANCELLER, result); - } -} - - - -/*------------------------------------------------------------------*/ -/* Advanced voice */ -/*------------------------------------------------------------------*/ - -static void adv_voice_write_coefs (PLCI *plci, word write_command) + byte mask; + byte from_pc; + byte to_pc; +} xconnect_write_prog[] = { - DIVA_CAPI_ADAPTER *a; - word i; - byte *p; - - word w, n, j, k; - byte ch_map[MIXER_CHANNELS_BRI]; - - byte coef_buffer[ADV_VOICE_COEF_BUFFER_SIZE + 2]; - - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_write_coefs %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, write_command)); - - a = plci->adapter; - p = coef_buffer + 1; - *(p++) = DSP_CTRL_OLD_SET_MIXER_COEFFICIENTS; - i = 0; - while (i + sizeof(word) <= a->adv_voice_coef_length) - { - PUT_WORD (p, GET_WORD (a->adv_voice_coef_buffer + i)); - p += 2; - i += 2; - } - while (i < ADV_VOICE_OLD_COEF_COUNT * sizeof(word)) - { - PUT_WORD (p, 0x8000); - p += 2; - i += 2; - } + { LI_COEF_CH_CH, false, false }, + { LI_COEF_CH_PC, false, true }, + { LI_COEF_PC_CH, true, false }, + { LI_COEF_PC_PC, true, true } +}; - if (!a->li_pri && (plci->li_bchannel_id == 0)) - { - if ((li_config_table[a->li_base].plci == NULL) && (li_config_table[a->li_base + 1].plci != NULL)) - { - plci->li_bchannel_id = 1; - li_config_table[a->li_base].plci = plci; - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_set_bchannel_id %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, plci->li_bchannel_id)); - } - else if ((li_config_table[a->li_base].plci != NULL) && (li_config_table[a->li_base + 1].plci == NULL)) - { - plci->li_bchannel_id = 2; - li_config_table[a->li_base + 1].plci = plci; - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_set_bchannel_id %d", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, plci->li_bchannel_id)); - } - } - if (!a->li_pri && (plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - i = a->li_base + (plci->li_bchannel_id - 1); - switch (write_command) - { - case ADV_VOICE_WRITE_ACTIVATION: - j = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); - k = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); - if (!(plci->B1_facilities & B1_FACILITY_MIXER)) - { - li_config_table[j].flag_table[i] |= LI_FLAG_CONFERENCE | LI_FLAG_MIX; - li_config_table[i].flag_table[j] |= LI_FLAG_CONFERENCE | LI_FLAG_MONITOR; - } - if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) - { - li_config_table[k].flag_table[i] |= LI_FLAG_CONFERENCE | LI_FLAG_MIX; - li_config_table[i].flag_table[k] |= LI_FLAG_CONFERENCE | LI_FLAG_MONITOR; - li_config_table[k].flag_table[j] |= LI_FLAG_CONFERENCE; - li_config_table[j].flag_table[k] |= LI_FLAG_CONFERENCE; - } - mixer_calculate_coefs (a); - li_config_table[i].curchnl = li_config_table[i].channel; - li_config_table[j].curchnl = li_config_table[j].channel; - if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) - li_config_table[k].curchnl = li_config_table[k].channel; - break; - - case ADV_VOICE_WRITE_DEACTIVATION: - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].flag_table[j] = 0; - li_config_table[j].flag_table[i] = 0; - } - k = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); - for (j = 0; j < li_total_channels; j++) - { - li_config_table[k].flag_table[j] = 0; - li_config_table[j].flag_table[k] = 0; - } - if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) - { - k = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); - for (j = 0; j < li_total_channels; j++) - { - li_config_table[k].flag_table[j] = 0; - li_config_table[j].flag_table[k] = 0; - } - } - mixer_calculate_coefs (a); - break; - } - if (plci->B1_facilities & B1_FACILITY_MIXER) - { - w = 0; - if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length) - w = GET_WORD (a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE); - if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) - w |= MIXER_FEATURE_ENABLE_TX_DATA; - if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) - w |= MIXER_FEATURE_ENABLE_RX_DATA; - *(p++) = (byte) w; - *(p++) = (byte)(w >> 8); - for (j = 0; j < sizeof(ch_map); j += 2) - { - ch_map[j] = (byte)(j + (plci->li_bchannel_id - 1)); - ch_map[j+1] = (byte)(j + (2 - plci->li_bchannel_id)); - } - for (n = 0; n < ARRAY_SIZE(mixer_write_prog_bri); n++) - { - i = a->li_base + ch_map[mixer_write_prog_bri[n].to_ch]; - j = a->li_base + ch_map[mixer_write_prog_bri[n].from_ch]; - if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED) - { - *(p++) = ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01); - w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); - li_config_table[i].coef_table[j] ^= (w & mixer_write_prog_bri[n].mask) << 4; - } - else - { - *(p++) = (ADV_VOICE_NEW_COEF_BASE + sizeof(word) + n < a->adv_voice_coef_length) ? - a->adv_voice_coef_buffer[ADV_VOICE_NEW_COEF_BASE + sizeof(word) + n] : 0x00; - } - } - } - else - { - for (i = ADV_VOICE_NEW_COEF_BASE; i < a->adv_voice_coef_length; i++) - *(p++) = a->adv_voice_coef_buffer[i]; - } - } - else - { - for (i = ADV_VOICE_NEW_COEF_BASE; i < a->adv_voice_coef_length; i++) - *(p++) = a->adv_voice_coef_buffer[i]; - } - coef_buffer[0] = (p - coef_buffer) - 1; - add_p (plci, FTY, coef_buffer); - sig_req (plci, TEL_CTRL, 0); - send_req (plci); +static void xconnect_query_addresses(PLCI *plci) +{ + DIVA_CAPI_ADAPTER *a; + word w, ch; + byte *p; + + dbug(1, dprintf("[%06lx] %s,%d: xconnect_query_addresses", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + + a = plci->adapter; + if (a->li_pri && ((plci->li_bchannel_id == 0) + || (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci != plci))) + { + dbug(1, dprintf("[%06x] %s,%d: Channel id wiped out", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + return; + } + p = plci->internal_req_buffer; + ch = (a->li_pri) ? plci->li_bchannel_id - 1 : 0; + *(p++) = UDATA_REQUEST_XCONNECT_FROM; + w = ch; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + w = ch | XCONNECT_CHANNEL_PORT_PC; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + plci->NData[0].P = plci->internal_req_buffer; + plci->NData[0].PLength = p - plci->internal_req_buffer; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_UDATA; + plci->adapter->request(&plci->NL); +} + + +static void xconnect_write_coefs(PLCI *plci, word internal_command) +{ + + dbug(1, dprintf("[%06lx] %s,%d: xconnect_write_coefs %04x", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, internal_command)); + + plci->li_write_command = internal_command; + plci->li_write_channel = 0; +} + + +static byte xconnect_write_coefs_process(dword Id, PLCI *plci, byte Rc) +{ + DIVA_CAPI_ADAPTER *a; + word w, n, i, j, r, s, to_ch; + dword d; + byte *p; + struct xconnect_transfer_address_s *transfer_address; + byte ch_map[MIXER_CHANNELS_BRI]; + + dbug(1, dprintf("[%06x] %s,%d: xconnect_write_coefs_process %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->li_write_channel)); + + a = plci->adapter; + if ((plci->li_bchannel_id == 0) + || (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci != plci)) + { + dbug(1, dprintf("[%06x] %s,%d: Channel id wiped out", + UnMapId(Id), (char *)(FILE_), __LINE__)); + return (true); + } + i = a->li_base + (plci->li_bchannel_id - 1); + j = plci->li_write_channel; + p = plci->internal_req_buffer; + if (j != 0) + { + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: LI write coefs failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + return (false); + } + } + if (li_config_table[i].adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + { + r = 0; + s = 0; + if (j < li_total_channels) + { + if (li_config_table[i].channel & LI_CHANNEL_ADDRESSES_SET) + { + s = ((li_config_table[i].send_b.card_address.low | li_config_table[i].send_b.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_PC | LI_COEF_PC_PC)) & + ((li_config_table[i].send_pc.card_address.low | li_config_table[i].send_pc.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_PC_CH)); + } + r = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + while ((j < li_total_channels) + && ((r == 0) + || (!(li_config_table[j].channel & LI_CHANNEL_ADDRESSES_SET)) + || (!li_config_table[j].adapter->li_pri + && (j >= li_config_table[j].adapter->li_base + MIXER_BCHANNELS_BRI)) + || (((li_config_table[j].send_b.card_address.low != li_config_table[i].send_b.card_address.low) + || (li_config_table[j].send_b.card_address.high != li_config_table[i].send_b.card_address.high)) + && (!(a->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT) + || !(li_config_table[j].adapter->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT))) + || ((li_config_table[j].adapter->li_base != a->li_base) + && !(r & s & + ((li_config_table[j].send_b.card_address.low | li_config_table[j].send_b.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_PC_CH | LI_COEF_PC_PC)) & + ((li_config_table[j].send_pc.card_address.low | li_config_table[j].send_pc.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_CH_PC)))))) + { + j++; + if (j < li_total_channels) + r = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + } + } + if (j < li_total_channels) + { + plci->internal_command = plci->li_write_command; + if (plci_nl_busy(plci)) + return (true); + to_ch = (a->li_pri) ? plci->li_bchannel_id - 1 : 0; + *(p++) = UDATA_REQUEST_XCONNECT_TO; + do + { + if (li_config_table[j].adapter->li_base != a->li_base) + { + r &= s & + ((li_config_table[j].send_b.card_address.low | li_config_table[j].send_b.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_PC_CH | LI_COEF_PC_PC)) & + ((li_config_table[j].send_pc.card_address.low | li_config_table[j].send_pc.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_CH_PC)); + } + n = 0; + do + { + if (r & xconnect_write_prog[n].mask) + { + if (xconnect_write_prog[n].from_pc) + transfer_address = &(li_config_table[j].send_pc); + else + transfer_address = &(li_config_table[j].send_b); + d = transfer_address->card_address.low; + *(p++) = (byte) d; + *(p++) = (byte)(d >> 8); + *(p++) = (byte)(d >> 16); + *(p++) = (byte)(d >> 24); + d = transfer_address->card_address.high; + *(p++) = (byte) d; + *(p++) = (byte)(d >> 8); + *(p++) = (byte)(d >> 16); + *(p++) = (byte)(d >> 24); + d = transfer_address->offset; + *(p++) = (byte) d; + *(p++) = (byte)(d >> 8); + *(p++) = (byte)(d >> 16); + *(p++) = (byte)(d >> 24); + w = xconnect_write_prog[n].to_pc ? to_ch | XCONNECT_CHANNEL_PORT_PC : to_ch; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + w = ((li_config_table[i].coef_table[j] & xconnect_write_prog[n].mask) == 0) ? 0x01 : + (li_config_table[i].adapter->u_law ? + (li_config_table[j].adapter->u_law ? 0x80 : 0x86) : + (li_config_table[j].adapter->u_law ? 0x7a : 0x80)); + *(p++) = (byte) w; + *(p++) = (byte) 0; + li_config_table[i].coef_table[j] ^= xconnect_write_prog[n].mask << 4; + } + n++; + } while ((n < ARRAY_SIZE(xconnect_write_prog)) + && ((p - plci->internal_req_buffer) + 16 < INTERNAL_REQ_BUFFER_SIZE)); + if (n == ARRAY_SIZE(xconnect_write_prog)) + { + do + { + j++; + if (j < li_total_channels) + r = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + } while ((j < li_total_channels) + && ((r == 0) + || (!(li_config_table[j].channel & LI_CHANNEL_ADDRESSES_SET)) + || (!li_config_table[j].adapter->li_pri + && (j >= li_config_table[j].adapter->li_base + MIXER_BCHANNELS_BRI)) + || (((li_config_table[j].send_b.card_address.low != li_config_table[i].send_b.card_address.low) + || (li_config_table[j].send_b.card_address.high != li_config_table[i].send_b.card_address.high)) + && (!(a->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT) + || !(li_config_table[j].adapter->manufacturer_features & MANUFACTURER_FEATURE_DMACONNECT))) + || ((li_config_table[j].adapter->li_base != a->li_base) + && !(r & s & + ((li_config_table[j].send_b.card_address.low | li_config_table[j].send_b.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_PC_CH | LI_COEF_PC_PC)) & + ((li_config_table[j].send_pc.card_address.low | li_config_table[j].send_pc.card_address.high) ? + (LI_COEF_CH_CH | LI_COEF_CH_PC | LI_COEF_PC_CH | LI_COEF_PC_PC) : (LI_COEF_CH_CH | LI_COEF_CH_PC)))))); + } + } while ((j < li_total_channels) + && ((p - plci->internal_req_buffer) + 16 < INTERNAL_REQ_BUFFER_SIZE)); + } + else if (j == li_total_channels) + { + plci->internal_command = plci->li_write_command; + if (plci_nl_busy(plci)) + return (true); + if (a->li_pri) + { + *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_PRI_SYNC; + w = 0; + if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) + w |= MIXER_FEATURE_ENABLE_TX_DATA; + if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) + w |= MIXER_FEATURE_ENABLE_RX_DATA; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + } + else + { + *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_BRI; + w = 0; + if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI) + && (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length)) + { + w = GET_WORD(a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE); + } + if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) + w |= MIXER_FEATURE_ENABLE_TX_DATA; + if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) + w |= MIXER_FEATURE_ENABLE_RX_DATA; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + for (j = 0; j < sizeof(ch_map); j += 2) + { + if (plci->li_bchannel_id == 2) + { + ch_map[j] = (byte)(j + 1); + ch_map[j + 1] = (byte) j; + } + else + { + ch_map[j] = (byte) j; + ch_map[j + 1] = (byte)(j + 1); + } + } + for (n = 0; n < ARRAY_SIZE(mixer_write_prog_bri); n++) + { + i = a->li_base + ch_map[mixer_write_prog_bri[n].to_ch]; + j = a->li_base + ch_map[mixer_write_prog_bri[n].from_ch]; + if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED) + { + *p = (mixer_write_prog_bri[n].xconnect_override != 0) ? + mixer_write_prog_bri[n].xconnect_override : + ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01); + if ((i >= a->li_base + MIXER_BCHANNELS_BRI) || (j >= a->li_base + MIXER_BCHANNELS_BRI)) + { + w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + li_config_table[i].coef_table[j] ^= (w & mixer_write_prog_bri[n].mask) << 4; + } + } + else + { + *p = 0x00; + if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI->tel == ADV_VOICE)) + { + w = (plci == a->AdvSignalPLCI) ? n : mixer_swapped_index_bri[n]; + if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w < a->adv_voice_coef_length) + *p = a->adv_voice_coef_buffer[ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w]; + } + } + p++; + } + } + j = li_total_channels + 1; + } + } + else + { + if (j <= li_total_channels) + { + plci->internal_command = plci->li_write_command; + if (plci_nl_busy(plci)) + return (true); + if (j < a->li_base) + j = a->li_base; + if (a->li_pri) + { + *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_PRI_SYNC; + w = 0; + if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) + w |= MIXER_FEATURE_ENABLE_TX_DATA; + if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) + w |= MIXER_FEATURE_ENABLE_RX_DATA; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + for (n = 0; n < ARRAY_SIZE(mixer_write_prog_pri); n++) + { + *(p++) = (byte)((plci->li_bchannel_id - 1) | mixer_write_prog_pri[n].line_flags); + for (j = a->li_base; j < a->li_base + MIXER_CHANNELS_PRI; j++) + { + w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + if (w & mixer_write_prog_pri[n].mask) + { + *(p++) = (li_config_table[i].coef_table[j] & mixer_write_prog_pri[n].mask) ? 0x80 : 0x01; + li_config_table[i].coef_table[j] ^= mixer_write_prog_pri[n].mask << 4; + } + else + *(p++) = 0x00; + } + *(p++) = (byte)((plci->li_bchannel_id - 1) | MIXER_COEF_LINE_ROW_FLAG | mixer_write_prog_pri[n].line_flags); + for (j = a->li_base; j < a->li_base + MIXER_CHANNELS_PRI; j++) + { + w = ((li_config_table[j].coef_table[i] & 0xf) ^ (li_config_table[j].coef_table[i] >> 4)); + if (w & mixer_write_prog_pri[n].mask) + { + *(p++) = (li_config_table[j].coef_table[i] & mixer_write_prog_pri[n].mask) ? 0x80 : 0x01; + li_config_table[j].coef_table[i] ^= mixer_write_prog_pri[n].mask << 4; + } + else + *(p++) = 0x00; + } + } + } + else + { + *(p++) = UDATA_REQUEST_SET_MIXER_COEFS_BRI; + w = 0; + if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI) + && (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length)) + { + w = GET_WORD(a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE); + } + if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) + w |= MIXER_FEATURE_ENABLE_TX_DATA; + if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) + w |= MIXER_FEATURE_ENABLE_RX_DATA; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + for (j = 0; j < sizeof(ch_map); j += 2) + { + if (plci->li_bchannel_id == 2) + { + ch_map[j] = (byte)(j + 1); + ch_map[j + 1] = (byte) j; + } + else + { + ch_map[j] = (byte) j; + ch_map[j + 1] = (byte)(j + 1); + } + } + for (n = 0; n < ARRAY_SIZE(mixer_write_prog_bri); n++) + { + i = a->li_base + ch_map[mixer_write_prog_bri[n].to_ch]; + j = a->li_base + ch_map[mixer_write_prog_bri[n].from_ch]; + if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED) + { + *p = ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01); + w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + li_config_table[i].coef_table[j] ^= (w & mixer_write_prog_bri[n].mask) << 4; + } + else + { + *p = 0x00; + if ((a->AdvSignalPLCI != NULL) && (a->AdvSignalPLCI->tel == ADV_VOICE)) + { + w = (plci == a->AdvSignalPLCI) ? n : mixer_swapped_index_bri[n]; + if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w < a->adv_voice_coef_length) + *p = a->adv_voice_coef_buffer[ADV_VOICE_NEW_COEF_BASE + sizeof(word) + w]; + } + } + p++; + } + } + j = li_total_channels + 1; + } + } + plci->li_write_channel = j; + if (p != plci->internal_req_buffer) + { + plci->NData[0].P = plci->internal_req_buffer; + plci->NData[0].PLength = p - plci->internal_req_buffer; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_UDATA; + plci->adapter->request(&plci->NL); + } + return (true); +} + + +static void mixer_notify_update(PLCI *plci, byte others) +{ + DIVA_CAPI_ADAPTER *a; + word i, w; + PLCI *notify_plci; + byte msg[sizeof(CAPI_MSG_HEADER) + 6]; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_notify_update %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, others)); + + a = plci->adapter; + if (a->profile.Global_Options & GL_LINE_INTERCONNECT_SUPPORTED) + { + if (others) + plci->li_notify_update = true; + i = 0; + do + { + notify_plci = NULL; + if (others) + { + while ((i < li_total_channels) && (li_config_table[i].plci == NULL)) + i++; + if (i < li_total_channels) + notify_plci = li_config_table[i++].plci; + } + else + { + if ((plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + notify_plci = plci; + } + } + if ((notify_plci != NULL) + && !notify_plci->li_notify_update + && (notify_plci->appl != NULL) + && (notify_plci->State) + && notify_plci->NL.Id && !notify_plci->nl_remove_id) + { + notify_plci->li_notify_update = true; + ((CAPI_MSG *) msg)->header.length = 18; + ((CAPI_MSG *) msg)->header.appl_id = notify_plci->appl->Id; + ((CAPI_MSG *) msg)->header.command = _FACILITY_R; + ((CAPI_MSG *) msg)->header.number = 0; + ((CAPI_MSG *) msg)->header.controller = notify_plci->adapter->Id; + ((CAPI_MSG *) msg)->header.plci = notify_plci->Id; + ((CAPI_MSG *) msg)->header.ncci = 0; + ((CAPI_MSG *) msg)->info.facility_req.Selector = SELECTOR_LINE_INTERCONNECT; + ((CAPI_MSG *) msg)->info.facility_req.structs[0] = 3; + PUT_WORD(&(((CAPI_MSG *) msg)->info.facility_req.structs[1]), LI_REQ_SILENT_UPDATE); + ((CAPI_MSG *) msg)->info.facility_req.structs[3] = 0; + w = api_put(notify_plci->appl, (CAPI_MSG *) msg); + if (w != _QUEUE_FULL) + { + if (w != 0) + { + dbug(1, dprintf("[%06lx] %s,%d: Interconnect notify failed %06x %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, + (dword)((notify_plci->Id << 8) | UnMapController(notify_plci->adapter->Id)), w)); + } + notify_plci->li_notify_update = false; + } + } + } while (others && (notify_plci != NULL)); + if (others) + plci->li_notify_update = false; + } +} + + +static void mixer_clear_config(PLCI *plci) +{ + DIVA_CAPI_ADAPTER *a; + word i, j; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_clear_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + + plci->li_notify_update = false; + plci->li_plci_b_write_pos = 0; + plci->li_plci_b_read_pos = 0; + plci->li_plci_b_req_pos = 0; + a = plci->adapter; + if ((plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + i = a->li_base + (plci->li_bchannel_id - 1); + li_config_table[i].curchnl = 0; + li_config_table[i].channel = 0; + li_config_table[i].chflags = 0; + for (j = 0; j < li_total_channels; j++) + { + li_config_table[j].flag_table[i] = 0; + li_config_table[i].flag_table[j] = 0; + li_config_table[i].coef_table[j] = 0; + li_config_table[j].coef_table[i] = 0; + } + if (!a->li_pri) + { + li_config_table[i].coef_table[i] |= LI_COEF_CH_PC_SET | LI_COEF_PC_CH_SET; + if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) + { + i = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); + li_config_table[i].curchnl = 0; + li_config_table[i].channel = 0; + li_config_table[i].chflags = 0; + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].flag_table[j] = 0; + li_config_table[j].flag_table[i] = 0; + li_config_table[i].coef_table[j] = 0; + li_config_table[j].coef_table[i] = 0; + } + if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) + { + i = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); + li_config_table[i].curchnl = 0; + li_config_table[i].channel = 0; + li_config_table[i].chflags = 0; + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].flag_table[j] = 0; + li_config_table[j].flag_table[i] = 0; + li_config_table[i].coef_table[j] = 0; + li_config_table[j].coef_table[i] = 0; + } + } + } + } + } +} + + +static void mixer_prepare_switch(dword Id, PLCI *plci) +{ + + dbug(1, dprintf("[%06lx] %s,%d: mixer_prepare_switch", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + do + { + mixer_indication_coefs_set(Id, plci); + } while (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos); +} + + +static word mixer_save_config(dword Id, PLCI *plci, byte Rc) +{ + DIVA_CAPI_ADAPTER *a; + word i, j; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_save_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + a = plci->adapter; + if ((plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + i = a->li_base + (plci->li_bchannel_id - 1); + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].coef_table[j] &= 0xf; + li_config_table[j].coef_table[i] &= 0xf; + } + if (!a->li_pri) + li_config_table[i].coef_table[i] |= LI_COEF_CH_PC_SET | LI_COEF_PC_CH_SET; + } + return (GOOD); +} + + +static word mixer_restore_config(dword Id, PLCI *plci, byte Rc) +{ + DIVA_CAPI_ADAPTER *a; + word Info; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_restore_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + Info = GOOD; + a = plci->adapter; + if ((plci->B1_facilities & B1_FACILITY_MIXER) + && (plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + switch (plci->adjust_b_state) + { + case ADJUST_B_RESTORE_MIXER_1: + if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + { + plci->internal_command = plci->adjust_b_command; + if (plci_nl_busy(plci)) + { + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_1; + break; + } + xconnect_query_addresses(plci); + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_2; + break; + } + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_5; + Rc = OK; + case ADJUST_B_RESTORE_MIXER_2: + case ADJUST_B_RESTORE_MIXER_3: + case ADJUST_B_RESTORE_MIXER_4: + if ((Rc != OK) && (Rc != OK_FC) && (Rc != 0)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B query addresses failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + if (Rc == OK) + { + if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_2) + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_3; + else if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_4) + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_5; + } + else if (Rc == 0) + { + if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_2) + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_4; + else if (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_3) + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_5; + } + if (plci->adjust_b_state != ADJUST_B_RESTORE_MIXER_5) + { + plci->internal_command = plci->adjust_b_command; + break; + } + case ADJUST_B_RESTORE_MIXER_5: + xconnect_write_coefs(plci, plci->adjust_b_command); + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_6; + Rc = OK; + case ADJUST_B_RESTORE_MIXER_6: + if (!xconnect_write_coefs_process(Id, plci, Rc)) + { + dbug(1, dprintf("[%06lx] %s,%d: Write mixer coefs failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (plci->internal_command) + break; + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_7; + case ADJUST_B_RESTORE_MIXER_7: + break; + } + } + return (Info); +} + + +static void mixer_command(dword Id, PLCI *plci, byte Rc) +{ + DIVA_CAPI_ADAPTER *a; + word i, internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_command %02x %04x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command, + plci->li_cmd)); + + a = plci->adapter; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (plci->li_cmd) + { + case LI_REQ_CONNECT: + case LI_REQ_DISCONNECT: + case LI_REQ_SILENT_UPDATE: + switch (internal_command) + { + default: + if (plci->li_channel_bits & LI_CHANNEL_INVOLVED) + { + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities | + B1_FACILITY_MIXER), MIXER_COMMAND_1); + } + case MIXER_COMMAND_1: + if (plci->li_channel_bits & LI_CHANNEL_INVOLVED) + { + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Load mixer failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + } + plci->li_plci_b_req_pos = plci->li_plci_b_write_pos; + if ((plci->li_channel_bits & LI_CHANNEL_INVOLVED) + || ((get_b1_facilities(plci, plci->B1_resource) & B1_FACILITY_MIXER) + && (add_b1_facilities(plci, plci->B1_resource, (word)(plci->B1_facilities & + ~B1_FACILITY_MIXER)) == plci->B1_resource))) + { + xconnect_write_coefs(plci, MIXER_COMMAND_2); + } + else + { + do + { + mixer_indication_coefs_set(Id, plci); + } while (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos); + } + case MIXER_COMMAND_2: + if ((plci->li_channel_bits & LI_CHANNEL_INVOLVED) + || ((get_b1_facilities(plci, plci->B1_resource) & B1_FACILITY_MIXER) + && (add_b1_facilities(plci, plci->B1_resource, (word)(plci->B1_facilities & + ~B1_FACILITY_MIXER)) == plci->B1_resource))) + { + if (!xconnect_write_coefs_process(Id, plci, Rc)) + { + dbug(1, dprintf("[%06lx] %s,%d: Write mixer coefs failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + if (plci->li_plci_b_write_pos != plci->li_plci_b_req_pos) + { + do + { + plci->li_plci_b_write_pos = (plci->li_plci_b_write_pos == 0) ? + LI_PLCI_B_QUEUE_ENTRIES - 1 : plci->li_plci_b_write_pos - 1; + i = (plci->li_plci_b_write_pos == 0) ? + LI_PLCI_B_QUEUE_ENTRIES - 1 : plci->li_plci_b_write_pos - 1; + } while ((plci->li_plci_b_write_pos != plci->li_plci_b_req_pos) + && !(plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)); + } + break; + } + if (plci->internal_command) + return; + } + if (!(plci->li_channel_bits & LI_CHANNEL_INVOLVED)) + { + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities & + ~B1_FACILITY_MIXER), MIXER_COMMAND_3); + } + case MIXER_COMMAND_3: + if (!(plci->li_channel_bits & LI_CHANNEL_INVOLVED)) + { + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Unload mixer failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + } + break; + } + break; + } + if ((plci->li_bchannel_id == 0) + || (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci != plci)) + { + dbug(1, dprintf("[%06x] %s,%d: Channel id wiped out %d", + UnMapId(Id), (char *)(FILE_), __LINE__, (int)(plci->li_bchannel_id))); + } + else + { + i = a->li_base + (plci->li_bchannel_id - 1); + li_config_table[i].curchnl = plci->li_channel_bits; + if (!a->li_pri && (plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) + { + i = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); + li_config_table[i].curchnl = plci->li_channel_bits; + if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) + { + i = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); + li_config_table[i].curchnl = plci->li_channel_bits; + } + } + } +} + + +static void li_update_connect(dword Id, DIVA_CAPI_ADAPTER *a, PLCI *plci, + dword plci_b_id, byte connect, dword li_flags) +{ + word i, ch_a, ch_a_v, ch_a_s, ch_b, ch_b_v, ch_b_s; + PLCI *plci_b; + DIVA_CAPI_ADAPTER *a_b; + + a_b = &(adapter[MapController((byte)(plci_b_id & 0x7f)) - 1]); + plci_b = &(a_b->plci[((plci_b_id >> 8) & 0xff) - 1]); + ch_a = a->li_base + (plci->li_bchannel_id - 1); + if (!a->li_pri && (plci->tel == ADV_VOICE) + && (plci == a->AdvSignalPLCI) && (Id & EXT_CONTROLLER)) + { + ch_a_v = ch_a + MIXER_IC_CHANNEL_BASE; + ch_a_s = (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? + a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id) : ch_a_v; + } + else + { + ch_a_v = ch_a; + ch_a_s = ch_a; + } + ch_b = a_b->li_base + (plci_b->li_bchannel_id - 1); + if (!a_b->li_pri && (plci_b->tel == ADV_VOICE) + && (plci_b == a_b->AdvSignalPLCI) && (plci_b_id & EXT_CONTROLLER)) + { + ch_b_v = ch_b + MIXER_IC_CHANNEL_BASE; + ch_b_s = (a_b->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? + a_b->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci_b->li_bchannel_id) : ch_b_v; + } + else + { + ch_b_v = ch_b; + ch_b_s = ch_b; + } + if (connect) + { + li_config_table[ch_a].flag_table[ch_a_v] &= ~LI_FLAG_MONITOR; + li_config_table[ch_a].flag_table[ch_a_s] &= ~LI_FLAG_MONITOR; + li_config_table[ch_a_v].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); + li_config_table[ch_a_s].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); + } + li_config_table[ch_a].flag_table[ch_b_v] &= ~LI_FLAG_MONITOR; + li_config_table[ch_a].flag_table[ch_b_s] &= ~LI_FLAG_MONITOR; + li_config_table[ch_b_v].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); + li_config_table[ch_b_s].flag_table[ch_a] &= ~(LI_FLAG_ANNOUNCEMENT | LI_FLAG_MIX); + if (ch_a_v == ch_b_v) + { + li_config_table[ch_a_v].flag_table[ch_b_v] &= ~LI_FLAG_CONFERENCE; + li_config_table[ch_a_s].flag_table[ch_b_s] &= ~LI_FLAG_CONFERENCE; + } + else + { + if (li_config_table[ch_a_v].flag_table[ch_b_v] & LI_FLAG_CONFERENCE) + { + for (i = 0; i < li_total_channels; i++) + { + if (i != ch_a_v) + li_config_table[ch_a_v].flag_table[i] &= ~LI_FLAG_CONFERENCE; + } + } + if (li_config_table[ch_a_s].flag_table[ch_b_v] & LI_FLAG_CONFERENCE) + { + for (i = 0; i < li_total_channels; i++) + { + if (i != ch_a_s) + li_config_table[ch_a_s].flag_table[i] &= ~LI_FLAG_CONFERENCE; + } + } + if (li_config_table[ch_b_v].flag_table[ch_a_v] & LI_FLAG_CONFERENCE) + { + for (i = 0; i < li_total_channels; i++) + { + if (i != ch_a_v) + li_config_table[i].flag_table[ch_a_v] &= ~LI_FLAG_CONFERENCE; + } + } + if (li_config_table[ch_b_v].flag_table[ch_a_s] & LI_FLAG_CONFERENCE) + { + for (i = 0; i < li_total_channels; i++) + { + if (i != ch_a_s) + li_config_table[i].flag_table[ch_a_s] &= ~LI_FLAG_CONFERENCE; + } + } + } + if (li_flags & LI_FLAG_CONFERENCE_A_B) + { + li_config_table[ch_b_v].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; + li_config_table[ch_b_s].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; + li_config_table[ch_b_v].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; + li_config_table[ch_b_s].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; + } + if (li_flags & LI_FLAG_CONFERENCE_B_A) + { + li_config_table[ch_a_v].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; + li_config_table[ch_a_v].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; + li_config_table[ch_a_s].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; + li_config_table[ch_a_s].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; + } + if (li_flags & LI_FLAG_MONITOR_A) + { + li_config_table[ch_a].flag_table[ch_a_v] |= LI_FLAG_MONITOR; + li_config_table[ch_a].flag_table[ch_a_s] |= LI_FLAG_MONITOR; + } + if (li_flags & LI_FLAG_MONITOR_B) + { + li_config_table[ch_a].flag_table[ch_b_v] |= LI_FLAG_MONITOR; + li_config_table[ch_a].flag_table[ch_b_s] |= LI_FLAG_MONITOR; + } + if (li_flags & LI_FLAG_ANNOUNCEMENT_A) + { + li_config_table[ch_a_v].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; + li_config_table[ch_a_s].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; + } + if (li_flags & LI_FLAG_ANNOUNCEMENT_B) + { + li_config_table[ch_b_v].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; + li_config_table[ch_b_s].flag_table[ch_a] |= LI_FLAG_ANNOUNCEMENT; + } + if (li_flags & LI_FLAG_MIX_A) + { + li_config_table[ch_a_v].flag_table[ch_a] |= LI_FLAG_MIX; + li_config_table[ch_a_s].flag_table[ch_a] |= LI_FLAG_MIX; + } + if (li_flags & LI_FLAG_MIX_B) + { + li_config_table[ch_b_v].flag_table[ch_a] |= LI_FLAG_MIX; + li_config_table[ch_b_s].flag_table[ch_a] |= LI_FLAG_MIX; + } + if (ch_a_v != ch_a_s) + { + li_config_table[ch_a_v].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; + li_config_table[ch_a_s].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; + } + if (ch_b_v != ch_b_s) + { + li_config_table[ch_b_v].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; + li_config_table[ch_b_s].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; + } +} + + +static void li2_update_connect(dword Id, DIVA_CAPI_ADAPTER *a, PLCI *plci, + dword plci_b_id, byte connect, dword li_flags) +{ + word ch_a, ch_a_v, ch_a_s, ch_b, ch_b_v, ch_b_s; + PLCI *plci_b; + DIVA_CAPI_ADAPTER *a_b; + + a_b = &(adapter[MapController((byte)(plci_b_id & 0x7f)) - 1]); + plci_b = &(a_b->plci[((plci_b_id >> 8) & 0xff) - 1]); + ch_a = a->li_base + (plci->li_bchannel_id - 1); + if (!a->li_pri && (plci->tel == ADV_VOICE) + && (plci == a->AdvSignalPLCI) && (Id & EXT_CONTROLLER)) + { + ch_a_v = ch_a + MIXER_IC_CHANNEL_BASE; + ch_a_s = (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? + a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id) : ch_a_v; + } + else + { + ch_a_v = ch_a; + ch_a_s = ch_a; + } + ch_b = a_b->li_base + (plci_b->li_bchannel_id - 1); + if (!a_b->li_pri && (plci_b->tel == ADV_VOICE) + && (plci_b == a_b->AdvSignalPLCI) && (plci_b_id & EXT_CONTROLLER)) + { + ch_b_v = ch_b + MIXER_IC_CHANNEL_BASE; + ch_b_s = (a_b->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) ? + a_b->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci_b->li_bchannel_id) : ch_b_v; + } + else + { + ch_b_v = ch_b; + ch_b_s = ch_b; + } + if (connect) + { + li_config_table[ch_b].flag_table[ch_b_v] &= ~LI_FLAG_MONITOR; + li_config_table[ch_b].flag_table[ch_b_s] &= ~LI_FLAG_MONITOR; + li_config_table[ch_b_v].flag_table[ch_b] &= ~LI_FLAG_MIX; + li_config_table[ch_b_s].flag_table[ch_b] &= ~LI_FLAG_MIX; + li_config_table[ch_b].flag_table[ch_b] &= ~LI_FLAG_PCCONNECT; + li_config_table[ch_b].chflags &= ~(LI_CHFLAG_MONITOR | LI_CHFLAG_MIX | LI_CHFLAG_LOOP); + } + li_config_table[ch_b_v].flag_table[ch_a_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_b_s].flag_table[ch_a_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_b_v].flag_table[ch_a_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_b_s].flag_table[ch_a_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_a_v].flag_table[ch_b_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_a_v].flag_table[ch_b_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_a_s].flag_table[ch_b_v] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + li_config_table[ch_a_s].flag_table[ch_b_s] &= ~(LI_FLAG_INTERCONNECT | LI_FLAG_CONFERENCE); + if (li_flags & LI2_FLAG_INTERCONNECT_A_B) + { + li_config_table[ch_b_v].flag_table[ch_a_v] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_b_s].flag_table[ch_a_v] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_b_v].flag_table[ch_a_s] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_b_s].flag_table[ch_a_s] |= LI_FLAG_INTERCONNECT; + } + if (li_flags & LI2_FLAG_INTERCONNECT_B_A) + { + li_config_table[ch_a_v].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_a_v].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_a_s].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_a_s].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; + } + if (li_flags & LI2_FLAG_MONITOR_B) + { + li_config_table[ch_b].flag_table[ch_b_v] |= LI_FLAG_MONITOR; + li_config_table[ch_b].flag_table[ch_b_s] |= LI_FLAG_MONITOR; + } + if (li_flags & LI2_FLAG_MIX_B) + { + li_config_table[ch_b_v].flag_table[ch_b] |= LI_FLAG_MIX; + li_config_table[ch_b_s].flag_table[ch_b] |= LI_FLAG_MIX; + } + if (li_flags & LI2_FLAG_MONITOR_X) + li_config_table[ch_b].chflags |= LI_CHFLAG_MONITOR; + if (li_flags & LI2_FLAG_MIX_X) + li_config_table[ch_b].chflags |= LI_CHFLAG_MIX; + if (li_flags & LI2_FLAG_LOOP_B) + { + li_config_table[ch_b_v].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_b_s].flag_table[ch_b_v] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_b_v].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; + li_config_table[ch_b_s].flag_table[ch_b_s] |= LI_FLAG_INTERCONNECT; + } + if (li_flags & LI2_FLAG_LOOP_PC) + li_config_table[ch_b].flag_table[ch_b] |= LI_FLAG_PCCONNECT; + if (li_flags & LI2_FLAG_LOOP_X) + li_config_table[ch_b].chflags |= LI_CHFLAG_LOOP; + if (li_flags & LI2_FLAG_PCCONNECT_A_B) + li_config_table[ch_b_s].flag_table[ch_a_s] |= LI_FLAG_PCCONNECT; + if (li_flags & LI2_FLAG_PCCONNECT_B_A) + li_config_table[ch_a_s].flag_table[ch_b_s] |= LI_FLAG_PCCONNECT; + if (ch_a_v != ch_a_s) + { + li_config_table[ch_a_v].flag_table[ch_a_s] |= LI_FLAG_CONFERENCE; + li_config_table[ch_a_s].flag_table[ch_a_v] |= LI_FLAG_CONFERENCE; + } + if (ch_b_v != ch_b_s) + { + li_config_table[ch_b_v].flag_table[ch_b_s] |= LI_FLAG_CONFERENCE; + li_config_table[ch_b_s].flag_table[ch_b_v] |= LI_FLAG_CONFERENCE; + } +} + + +static word li_check_main_plci(dword Id, PLCI *plci) +{ + if (plci == NULL) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong PLCI", + UnMapId(Id), (char *)(FILE_), __LINE__)); + return (_WRONG_IDENTIFIER); + } + if (!plci->State + || !plci->NL.Id || plci->nl_remove_id + || (plci->li_bchannel_id == 0)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong state", + UnMapId(Id), (char *)(FILE_), __LINE__)); + return (_WRONG_STATE); + } + li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci = plci; + return (GOOD); +} + + +static PLCI *li_check_plci_b(dword Id, PLCI *plci, + dword plci_b_id, word plci_b_write_pos, byte *p_result) +{ + byte ctlr_b; + PLCI *plci_b; + + if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : + LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 2) + { + dbug(1, dprintf("[%06lx] %s,%d: LI request overrun", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE); + return (NULL); + } + ctlr_b = 0; + if ((plci_b_id & 0x7f) != 0) + { + ctlr_b = MapController((byte)(plci_b_id & 0x7f)); + if ((ctlr_b > max_adapter) || ((ctlr_b != 0) && (adapter[ctlr_b - 1].request == NULL))) + ctlr_b = 0; + } + if ((ctlr_b == 0) + || (((plci_b_id >> 8) & 0xff) == 0) + || (((plci_b_id >> 8) & 0xff) > adapter[ctlr_b - 1].max_plci)) + { + dbug(1, dprintf("[%06lx] %s,%d: LI invalid second PLCI %08lx", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b_id)); + PUT_WORD(p_result, _WRONG_IDENTIFIER); + return (NULL); + } + plci_b = &(adapter[ctlr_b - 1].plci[((plci_b_id >> 8) & 0xff) - 1]); + if (!plci_b->State + || !plci_b->NL.Id || plci_b->nl_remove_id + || (plci_b->li_bchannel_id == 0)) + { + dbug(1, dprintf("[%06lx] %s,%d: LI peer in wrong state %08lx", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b_id)); + PUT_WORD(p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE); + return (NULL); + } + li_config_table[plci_b->adapter->li_base + (plci_b->li_bchannel_id - 1)].plci = plci_b; + if (((byte)(plci_b_id & ~EXT_CONTROLLER)) != + ((byte)(UnMapController(plci->adapter->Id) & ~EXT_CONTROLLER)) + && (!(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + || !(plci_b->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT))) + { + dbug(1, dprintf("[%06lx] %s,%d: LI not on same ctrl %08lx", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b_id)); + PUT_WORD(p_result, _WRONG_IDENTIFIER); + return (NULL); + } + if (!(get_b1_facilities(plci_b, add_b1_facilities(plci_b, plci_b->B1_resource, + (word)(plci_b->B1_facilities | B1_FACILITY_MIXER))) & B1_FACILITY_MIXER)) + { + dbug(1, dprintf("[%06lx] %s,%d: Interconnect peer cannot mix %d", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b->B1_resource)); + PUT_WORD(p_result, _REQUEST_NOT_ALLOWED_IN_THIS_STATE); + return (NULL); + } + return (plci_b); +} + + +static PLCI *li2_check_plci_b(dword Id, PLCI *plci, + dword plci_b_id, word plci_b_write_pos, byte *p_result) +{ + byte ctlr_b; + PLCI *plci_b; + + if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : + LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 2) + { + dbug(1, dprintf("[%06lx] %s,%d: LI request overrun", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(p_result, _WRONG_STATE); + return (NULL); + } + ctlr_b = 0; + if ((plci_b_id & 0x7f) != 0) + { + ctlr_b = MapController((byte)(plci_b_id & 0x7f)); + if ((ctlr_b > max_adapter) || ((ctlr_b != 0) && (adapter[ctlr_b - 1].request == NULL))) + ctlr_b = 0; + } + if ((ctlr_b == 0) + || (((plci_b_id >> 8) & 0xff) == 0) + || (((plci_b_id >> 8) & 0xff) > adapter[ctlr_b - 1].max_plci)) + { + dbug(1, dprintf("[%06lx] %s,%d: LI invalid second PLCI %08lx", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b_id)); + PUT_WORD(p_result, _WRONG_IDENTIFIER); + return (NULL); + } + plci_b = &(adapter[ctlr_b - 1].plci[((plci_b_id >> 8) & 0xff) - 1]); + if (!plci_b->State + || !plci_b->NL.Id || plci_b->nl_remove_id + || (plci_b->li_bchannel_id == 0) + || (li_config_table[plci_b->adapter->li_base + (plci_b->li_bchannel_id - 1)].plci != plci_b)) + { + dbug(1, dprintf("[%06lx] %s,%d: LI peer in wrong state %08lx", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b_id)); + PUT_WORD(p_result, _WRONG_STATE); + return (NULL); + } + if (((byte)(plci_b_id & ~EXT_CONTROLLER)) != + ((byte)(UnMapController(plci->adapter->Id) & ~EXT_CONTROLLER)) + && (!(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + || !(plci_b->adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT))) + { + dbug(1, dprintf("[%06lx] %s,%d: LI not on same ctrl %08lx", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b_id)); + PUT_WORD(p_result, _WRONG_IDENTIFIER); + return (NULL); + } + if (!(get_b1_facilities(plci_b, add_b1_facilities(plci_b, plci_b->B1_resource, + (word)(plci_b->B1_facilities | B1_FACILITY_MIXER))) & B1_FACILITY_MIXER)) + { + dbug(1, dprintf("[%06lx] %s,%d: Interconnect peer cannot mix %d", + UnMapId(Id), (char *)(FILE_), __LINE__, plci_b->B1_resource)); + PUT_WORD(p_result, _WRONG_STATE); + return (NULL); + } + return (plci_b); +} + + +static byte mixer_request(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) +{ + word Info; + word i; + dword d, li_flags, plci_b_id; + PLCI *plci_b; + API_PARSE li_parms[3]; + API_PARSE li_req_parms[3]; + API_PARSE li_participant_struct[2]; + API_PARSE li_participant_parms[3]; + word participant_parms_pos; + byte result_buffer[32]; + byte *result; + word result_pos; + word plci_b_write_pos; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_request", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + Info = GOOD; + result = result_buffer; + result_buffer[0] = 0; + if (!(a->profile.Global_Options & GL_LINE_INTERCONNECT_SUPPORTED)) + { + dbug(1, dprintf("[%06lx] %s,%d: Facility not supported", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + } + else if (api_parse(&msg[1].info[1], msg[1].length, "ws", li_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + } + else + { + result_buffer[0] = 3; + PUT_WORD(&result_buffer[1], GET_WORD(li_parms[0].info)); + result_buffer[3] = 0; + switch (GET_WORD(li_parms[0].info)) + { + case LI_GET_SUPPORTED_SERVICES: + if (appl->appl_flags & APPL_FLAG_OLD_LI_SPEC) + { + result_buffer[0] = 17; + result_buffer[3] = 14; + PUT_WORD(&result_buffer[4], GOOD); + d = 0; + if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_CH) + d |= LI_CONFERENCING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_PC) + d |= LI_MONITORING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_PC_CH) + d |= LI_ANNOUNCEMENTS_SUPPORTED | LI_MIXING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + d |= LI_CROSS_CONTROLLER_SUPPORTED; + PUT_DWORD(&result_buffer[6], d); + if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + { + d = 0; + for (i = 0; i < li_total_channels; i++) + { + if ((li_config_table[i].adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + && (li_config_table[i].adapter->li_pri + || (i < li_config_table[i].adapter->li_base + MIXER_BCHANNELS_BRI))) + { + d++; + } + } + } + else + { + d = a->li_pri ? a->li_channels : MIXER_BCHANNELS_BRI; + } + PUT_DWORD(&result_buffer[10], d / 2); + PUT_DWORD(&result_buffer[14], d); + } + else + { + result_buffer[0] = 25; + result_buffer[3] = 22; + PUT_WORD(&result_buffer[4], GOOD); + d = LI2_ASYMMETRIC_SUPPORTED | LI2_B_LOOPING_SUPPORTED | LI2_X_LOOPING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_CH_PC) + d |= LI2_MONITORING_SUPPORTED | LI2_REMOTE_MONITORING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_PC_CH) + d |= LI2_MIXING_SUPPORTED | LI2_REMOTE_MIXING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_MIXER_PC_PC) + d |= LI2_PC_LOOPING_SUPPORTED; + if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + d |= LI2_CROSS_CONTROLLER_SUPPORTED; + PUT_DWORD(&result_buffer[6], d); + d = a->li_pri ? a->li_channels : MIXER_BCHANNELS_BRI; + PUT_DWORD(&result_buffer[10], d / 2); + PUT_DWORD(&result_buffer[14], d - 1); + if (a->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + { + d = 0; + for (i = 0; i < li_total_channels; i++) + { + if ((li_config_table[i].adapter->manufacturer_features & MANUFACTURER_FEATURE_XCONNECT) + && (li_config_table[i].adapter->li_pri + || (i < li_config_table[i].adapter->li_base + MIXER_BCHANNELS_BRI))) + { + d++; + } + } + } + PUT_DWORD(&result_buffer[18], d / 2); + PUT_DWORD(&result_buffer[22], d - 1); + } + break; + + case LI_REQ_CONNECT: + if (li_parms[1].length == 8) + { + appl->appl_flags |= APPL_FLAG_OLD_LI_SPEC; + if (api_parse(&li_parms[1].info[1], li_parms[1].length, "dd", li_req_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + plci_b_id = GET_DWORD(li_req_parms[0].info) & 0xffff; + li_flags = GET_DWORD(li_req_parms[1].info); + Info = li_check_main_plci(Id, plci); + result_buffer[0] = 9; + result_buffer[3] = 6; + PUT_DWORD(&result_buffer[4], plci_b_id); + PUT_WORD(&result_buffer[8], GOOD); + if (Info != GOOD) + break; + result = plci->saved_msg.info; + for (i = 0; i <= result_buffer[0]; i++) + result[i] = result_buffer[i]; + plci_b_write_pos = plci->li_plci_b_write_pos; + plci_b = li_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[8]); + if (plci_b == NULL) + break; + li_update_connect(Id, a, plci, plci_b_id, true, li_flags); + plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_LAST_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + plci->li_plci_b_write_pos = plci_b_write_pos; + } + else + { + appl->appl_flags &= ~APPL_FLAG_OLD_LI_SPEC; + if (api_parse(&li_parms[1].info[1], li_parms[1].length, "ds", li_req_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + li_flags = GET_DWORD(li_req_parms[0].info) & ~(LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A); + Info = li_check_main_plci(Id, plci); + result_buffer[0] = 7; + result_buffer[3] = 4; + PUT_WORD(&result_buffer[4], Info); + result_buffer[6] = 0; + if (Info != GOOD) + break; + result = plci->saved_msg.info; + for (i = 0; i <= result_buffer[0]; i++) + result[i] = result_buffer[i]; + plci_b_write_pos = plci->li_plci_b_write_pos; + participant_parms_pos = 0; + result_pos = 7; + li2_update_connect(Id, a, plci, UnMapId(Id), true, li_flags); + while (participant_parms_pos < li_req_parms[1].length) + { + result[result_pos] = 6; + result_pos += 7; + PUT_DWORD(&result[result_pos - 6], 0); + PUT_WORD(&result[result_pos - 2], GOOD); + if (api_parse(&li_req_parms[1].info[1 + participant_parms_pos], + (word)(li_parms[1].length - participant_parms_pos), "s", li_participant_struct)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); + break; + } + if (api_parse(&li_participant_struct[0].info[1], + li_participant_struct[0].length, "dd", li_participant_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); + break; + } + plci_b_id = GET_DWORD(li_participant_parms[0].info) & 0xffff; + li_flags = GET_DWORD(li_participant_parms[1].info); + PUT_DWORD(&result[result_pos - 6], plci_b_id); + if (sizeof(result) - result_pos < 7) + { + dbug(1, dprintf("[%06lx] %s,%d: LI result overrun", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(&result[result_pos - 2], _WRONG_STATE); + break; + } + plci_b = li2_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]); + if (plci_b != NULL) + { + li2_update_connect(Id, a, plci, plci_b_id, true, li_flags); + plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | + ((li_flags & (LI2_FLAG_INTERCONNECT_A_B | LI2_FLAG_INTERCONNECT_B_A | + LI2_FLAG_PCCONNECT_A_B | LI2_FLAG_PCCONNECT_B_A)) ? 0 : LI_PLCI_B_DISC_FLAG); + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + } + participant_parms_pos = (word)((&li_participant_struct[0].info[1 + li_participant_struct[0].length]) - + (&li_req_parms[1].info[1])); + } + result[0] = (byte)(result_pos - 1); + result[3] = (byte)(result_pos - 4); + result[6] = (byte)(result_pos - 7); + i = (plci_b_write_pos == 0) ? LI_PLCI_B_QUEUE_ENTRIES - 1 : plci_b_write_pos - 1; + if ((plci_b_write_pos == plci->li_plci_b_read_pos) + || (plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)) + { + plci->li_plci_b_queue[plci_b_write_pos] = LI_PLCI_B_SKIP_FLAG | LI_PLCI_B_LAST_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + } + else + plci->li_plci_b_queue[i] |= LI_PLCI_B_LAST_FLAG; + plci->li_plci_b_write_pos = plci_b_write_pos; + } + mixer_calculate_coefs(a); + plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel; + mixer_notify_update(plci, true); + sendf(appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, + "wwS", Info, SELECTOR_LINE_INTERCONNECT, result); + plci->command = 0; + plci->li_cmd = GET_WORD(li_parms[0].info); + start_internal_command(Id, plci, mixer_command); + return (false); + + case LI_REQ_DISCONNECT: + if (li_parms[1].length == 4) + { + appl->appl_flags |= APPL_FLAG_OLD_LI_SPEC; + if (api_parse(&li_parms[1].info[1], li_parms[1].length, "d", li_req_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + plci_b_id = GET_DWORD(li_req_parms[0].info) & 0xffff; + Info = li_check_main_plci(Id, plci); + result_buffer[0] = 9; + result_buffer[3] = 6; + PUT_DWORD(&result_buffer[4], GET_DWORD(li_req_parms[0].info)); + PUT_WORD(&result_buffer[8], GOOD); + if (Info != GOOD) + break; + result = plci->saved_msg.info; + for (i = 0; i <= result_buffer[0]; i++) + result[i] = result_buffer[i]; + plci_b_write_pos = plci->li_plci_b_write_pos; + plci_b = li_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[8]); + if (plci_b == NULL) + break; + li_update_connect(Id, a, plci, plci_b_id, false, 0); + plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_DISC_FLAG | LI_PLCI_B_LAST_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + plci->li_plci_b_write_pos = plci_b_write_pos; + } + else + { + appl->appl_flags &= ~APPL_FLAG_OLD_LI_SPEC; + if (api_parse(&li_parms[1].info[1], li_parms[1].length, "s", li_req_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + break; + } + Info = li_check_main_plci(Id, plci); + result_buffer[0] = 7; + result_buffer[3] = 4; + PUT_WORD(&result_buffer[4], Info); + result_buffer[6] = 0; + if (Info != GOOD) + break; + result = plci->saved_msg.info; + for (i = 0; i <= result_buffer[0]; i++) + result[i] = result_buffer[i]; + plci_b_write_pos = plci->li_plci_b_write_pos; + participant_parms_pos = 0; + result_pos = 7; + while (participant_parms_pos < li_req_parms[0].length) + { + result[result_pos] = 6; + result_pos += 7; + PUT_DWORD(&result[result_pos - 6], 0); + PUT_WORD(&result[result_pos - 2], GOOD); + if (api_parse(&li_req_parms[0].info[1 + participant_parms_pos], + (word)(li_parms[1].length - participant_parms_pos), "s", li_participant_struct)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); + break; + } + if (api_parse(&li_participant_struct[0].info[1], + li_participant_struct[0].length, "d", li_participant_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(&result[result_pos - 2], _WRONG_MESSAGE_FORMAT); + break; + } + plci_b_id = GET_DWORD(li_participant_parms[0].info) & 0xffff; + PUT_DWORD(&result[result_pos - 6], plci_b_id); + if (sizeof(result) - result_pos < 7) + { + dbug(1, dprintf("[%06lx] %s,%d: LI result overrun", + UnMapId(Id), (char *)(FILE_), __LINE__)); + PUT_WORD(&result[result_pos - 2], _WRONG_STATE); + break; + } + plci_b = li2_check_plci_b(Id, plci, plci_b_id, plci_b_write_pos, &result[result_pos - 2]); + if (plci_b != NULL) + { + li2_update_connect(Id, a, plci, plci_b_id, false, 0); + plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_DISC_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + } + participant_parms_pos = (word)((&li_participant_struct[0].info[1 + li_participant_struct[0].length]) - + (&li_req_parms[0].info[1])); + } + result[0] = (byte)(result_pos - 1); + result[3] = (byte)(result_pos - 4); + result[6] = (byte)(result_pos - 7); + i = (plci_b_write_pos == 0) ? LI_PLCI_B_QUEUE_ENTRIES - 1 : plci_b_write_pos - 1; + if ((plci_b_write_pos == plci->li_plci_b_read_pos) + || (plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)) + { + plci->li_plci_b_queue[plci_b_write_pos] = LI_PLCI_B_SKIP_FLAG | LI_PLCI_B_LAST_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + } + else + plci->li_plci_b_queue[i] |= LI_PLCI_B_LAST_FLAG; + plci->li_plci_b_write_pos = plci_b_write_pos; + } + mixer_calculate_coefs(a); + plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel; + mixer_notify_update(plci, true); + sendf(appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, + "wwS", Info, SELECTOR_LINE_INTERCONNECT, result); + plci->command = 0; + plci->li_cmd = GET_WORD(li_parms[0].info); + start_internal_command(Id, plci, mixer_command); + return (false); + + case LI_REQ_SILENT_UPDATE: + if (!plci || !plci->State + || !plci->NL.Id || plci->nl_remove_id + || (plci->li_bchannel_id == 0) + || (li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci != plci)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong state", + UnMapId(Id), (char *)(FILE_), __LINE__)); + return (false); + } + plci_b_write_pos = plci->li_plci_b_write_pos; + if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : + LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 2) + { + dbug(1, dprintf("[%06lx] %s,%d: LI request overrun", + UnMapId(Id), (char *)(FILE_), __LINE__)); + return (false); + } + i = (plci_b_write_pos == 0) ? LI_PLCI_B_QUEUE_ENTRIES - 1 : plci_b_write_pos - 1; + if ((plci_b_write_pos == plci->li_plci_b_read_pos) + || (plci->li_plci_b_queue[i] & LI_PLCI_B_LAST_FLAG)) + { + plci->li_plci_b_queue[plci_b_write_pos] = LI_PLCI_B_SKIP_FLAG | LI_PLCI_B_LAST_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + } + else + plci->li_plci_b_queue[i] |= LI_PLCI_B_LAST_FLAG; + plci->li_plci_b_write_pos = plci_b_write_pos; + plci->li_channel_bits = li_config_table[a->li_base + (plci->li_bchannel_id - 1)].channel; + plci->command = 0; + plci->li_cmd = GET_WORD(li_parms[0].info); + start_internal_command(Id, plci, mixer_command); + return (false); + + default: + dbug(1, dprintf("[%06lx] %s,%d: LI unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, GET_WORD(li_parms[0].info))); + Info = _FACILITY_NOT_SUPPORTED; + } + } + sendf(appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, + "wwS", Info, SELECTOR_LINE_INTERCONNECT, result); + return (false); +} + + +static void mixer_indication_coefs_set(dword Id, PLCI *plci) +{ + dword d; + byte result[12]; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_indication_coefs_set", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + if (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos) + { + do + { + d = plci->li_plci_b_queue[plci->li_plci_b_read_pos]; + if (!(d & LI_PLCI_B_SKIP_FLAG)) + { + if (plci->appl->appl_flags & APPL_FLAG_OLD_LI_SPEC) + { + if (d & LI_PLCI_B_DISC_FLAG) + { + result[0] = 5; + PUT_WORD(&result[1], LI_IND_DISCONNECT); + result[3] = 2; + PUT_WORD(&result[4], _LI_USER_INITIATED); + } + else + { + result[0] = 7; + PUT_WORD(&result[1], LI_IND_CONNECT_ACTIVE); + result[3] = 4; + PUT_DWORD(&result[4], d & ~LI_PLCI_B_FLAG_MASK); + } + } + else + { + if (d & LI_PLCI_B_DISC_FLAG) + { + result[0] = 9; + PUT_WORD(&result[1], LI_IND_DISCONNECT); + result[3] = 6; + PUT_DWORD(&result[4], d & ~LI_PLCI_B_FLAG_MASK); + PUT_WORD(&result[8], _LI_USER_INITIATED); + } + else + { + result[0] = 7; + PUT_WORD(&result[1], LI_IND_CONNECT_ACTIVE); + result[3] = 4; + PUT_DWORD(&result[4], d & ~LI_PLCI_B_FLAG_MASK); + } + } + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, + "ws", SELECTOR_LINE_INTERCONNECT, result); + } + plci->li_plci_b_read_pos = (plci->li_plci_b_read_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? + 0 : plci->li_plci_b_read_pos + 1; + } while (!(d & LI_PLCI_B_LAST_FLAG) && (plci->li_plci_b_read_pos != plci->li_plci_b_req_pos)); + } +} + + +static void mixer_indication_xconnect_from(dword Id, PLCI *plci, byte *msg, word length) +{ + word i, j, ch; + struct xconnect_transfer_address_s s, *p; + DIVA_CAPI_ADAPTER *a; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_indication_xconnect_from %d", + UnMapId(Id), (char *)(FILE_), __LINE__, (int)length)); + + a = plci->adapter; + i = 1; + for (i = 1; i < length; i += 16) + { + s.card_address.low = msg[i] | (msg[i + 1] << 8) | (((dword)(msg[i + 2])) << 16) | (((dword)(msg[i + 3])) << 24); + s.card_address.high = msg[i + 4] | (msg[i + 5] << 8) | (((dword)(msg[i + 6])) << 16) | (((dword)(msg[i + 7])) << 24); + s.offset = msg[i + 8] | (msg[i + 9] << 8) | (((dword)(msg[i + 10])) << 16) | (((dword)(msg[i + 11])) << 24); + ch = msg[i + 12] | (msg[i + 13] << 8); + j = ch & XCONNECT_CHANNEL_NUMBER_MASK; + if (!a->li_pri && (plci->li_bchannel_id == 2)) + j = 1 - j; + j += a->li_base; + if (ch & XCONNECT_CHANNEL_PORT_PC) + p = &(li_config_table[j].send_pc); + else + p = &(li_config_table[j].send_b); + p->card_address.low = s.card_address.low; + p->card_address.high = s.card_address.high; + p->offset = s.offset; + li_config_table[j].channel |= LI_CHANNEL_ADDRESSES_SET; + } + if (plci->internal_command_queue[0] + && ((plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_2) + || (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_3) + || (plci->adjust_b_state == ADJUST_B_RESTORE_MIXER_4))) + { + (*(plci->internal_command_queue[0]))(Id, plci, 0); + if (!plci->internal_command) + next_internal_command(Id, plci); + } + mixer_notify_update(plci, true); +} + + +static void mixer_indication_xconnect_to(dword Id, PLCI *plci, byte *msg, word length) +{ + + dbug(1, dprintf("[%06lx] %s,%d: mixer_indication_xconnect_to %d", + UnMapId(Id), (char *)(FILE_), __LINE__, (int) length)); + +} + + +static byte mixer_notify_source_removed(PLCI *plci, dword plci_b_id) +{ + word plci_b_write_pos; + + plci_b_write_pos = plci->li_plci_b_write_pos; + if (((plci->li_plci_b_read_pos > plci_b_write_pos) ? plci->li_plci_b_read_pos : + LI_PLCI_B_QUEUE_ENTRIES + plci->li_plci_b_read_pos) - plci_b_write_pos - 1 < 1) + { + dbug(1, dprintf("[%06lx] %s,%d: LI request overrun", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + return (false); + } + plci->li_plci_b_queue[plci_b_write_pos] = plci_b_id | LI_PLCI_B_DISC_FLAG; + plci_b_write_pos = (plci_b_write_pos == LI_PLCI_B_QUEUE_ENTRIES - 1) ? 0 : plci_b_write_pos + 1; + plci->li_plci_b_write_pos = plci_b_write_pos; + return (true); +} + + +static void mixer_remove(PLCI *plci) +{ + DIVA_CAPI_ADAPTER *a; + PLCI *notify_plci; + dword plci_b_id; + word i, j; + + dbug(1, dprintf("[%06lx] %s,%d: mixer_remove", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + + a = plci->adapter; + plci_b_id = (plci->Id << 8) | UnMapController(plci->adapter->Id); + if (a->profile.Global_Options & GL_LINE_INTERCONNECT_SUPPORTED) + { + if ((plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + i = a->li_base + (plci->li_bchannel_id - 1); + if ((li_config_table[i].curchnl | li_config_table[i].channel) & LI_CHANNEL_INVOLVED) + { + for (j = 0; j < li_total_channels; j++) + { + if ((li_config_table[i].flag_table[j] & LI_FLAG_INTERCONNECT) + || (li_config_table[j].flag_table[i] & LI_FLAG_INTERCONNECT)) + { + notify_plci = li_config_table[j].plci; + if ((notify_plci != NULL) + && (notify_plci != plci) + && (notify_plci->appl != NULL) + && !(notify_plci->appl->appl_flags & APPL_FLAG_OLD_LI_SPEC) + && (notify_plci->State) + && notify_plci->NL.Id && !notify_plci->nl_remove_id) + { + mixer_notify_source_removed(notify_plci, plci_b_id); + } + } + } + mixer_clear_config(plci); + mixer_calculate_coefs(a); + mixer_notify_update(plci, true); + } + li_config_table[i].plci = NULL; + plci->li_bchannel_id = 0; + } + } } -static void adv_voice_clear_config (PLCI *plci) -{ - DIVA_CAPI_ADAPTER *a; - - word i, j; +/*------------------------------------------------------------------*/ +/* Echo canceller facilities */ +/*------------------------------------------------------------------*/ - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_clear_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); +static void ec_write_parameters(PLCI *plci) +{ + word w; + byte parameter_buffer[6]; - a = plci->adapter; - if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) - { - a->adv_voice_coef_length = 0; - - if (!a->li_pri && (plci->li_bchannel_id != 0) - && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - i = a->li_base + (plci->li_bchannel_id - 1); - li_config_table[i].curchnl = 0; - li_config_table[i].channel = 0; - li_config_table[i].chflags = 0; - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].flag_table[j] = 0; - li_config_table[j].flag_table[i] = 0; - li_config_table[i].coef_table[j] = 0; - li_config_table[j].coef_table[i] = 0; - } - li_config_table[i].coef_table[i] |= LI_COEF_CH_PC_SET | LI_COEF_PC_CH_SET; - i = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); - li_config_table[i].curchnl = 0; - li_config_table[i].channel = 0; - li_config_table[i].chflags = 0; - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].flag_table[j] = 0; - li_config_table[j].flag_table[i] = 0; - li_config_table[i].coef_table[j] = 0; - li_config_table[j].coef_table[i] = 0; - } - if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) - { - i = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); - li_config_table[i].curchnl = 0; - li_config_table[i].channel = 0; - li_config_table[i].chflags = 0; - for (j = 0; j < li_total_channels; j++) - { - li_config_table[i].flag_table[j] = 0; - li_config_table[j].flag_table[i] = 0; - li_config_table[i].coef_table[j] = 0; - li_config_table[j].coef_table[i] = 0; - } - } - } + dbug(1, dprintf("[%06lx] %s,%d: ec_write_parameters", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); - } + parameter_buffer[0] = 5; + parameter_buffer[1] = DSP_CTRL_SET_LEC_PARAMETERS; + PUT_WORD(¶meter_buffer[2], plci->ec_idi_options); + plci->ec_idi_options &= ~LEC_RESET_COEFFICIENTS; + w = (plci->ec_tail_length == 0) ? 128 : plci->ec_tail_length; + PUT_WORD(¶meter_buffer[4], w); + add_p(plci, FTY, parameter_buffer); + sig_req(plci, TEL_CTRL, 0); + send_req(plci); } -static void adv_voice_prepare_switch (dword Id, PLCI *plci) +static void ec_clear_config(PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_prepare_switch", - UnMapId (Id), (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: ec_clear_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + plci->ec_idi_options = LEC_ENABLE_ECHO_CANCELLER | + LEC_MANUAL_DISABLE | LEC_ENABLE_NONLINEAR_PROCESSING; + plci->ec_tail_length = 0; } -static word adv_voice_save_config (dword Id, PLCI *plci, byte Rc) +static void ec_prepare_switch(dword Id, PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_save_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + dbug(1, dprintf("[%06lx] %s,%d: ec_prepare_switch", + UnMapId(Id), (char *)(FILE_), __LINE__)); - return (GOOD); } -static word adv_voice_restore_config (dword Id, PLCI *plci, byte Rc) -{ - DIVA_CAPI_ADAPTER *a; - word Info; +static word ec_save_config(dword Id, PLCI *plci, byte Rc) +{ + + dbug(1, dprintf("[%06lx] %s,%d: ec_save_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + return (GOOD); +} + + +static word ec_restore_config(dword Id, PLCI *plci, byte Rc) +{ + word Info; + + dbug(1, dprintf("[%06lx] %s,%d: ec_restore_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + Info = GOOD; + if (plci->B1_facilities & B1_FACILITY_EC) + { + switch (plci->adjust_b_state) + { + case ADJUST_B_RESTORE_EC_1: + plci->internal_command = plci->adjust_b_command; + if (plci->sig_req) + { + plci->adjust_b_state = ADJUST_B_RESTORE_EC_1; + break; + } + ec_write_parameters(plci); + plci->adjust_b_state = ADJUST_B_RESTORE_EC_2; + break; + case ADJUST_B_RESTORE_EC_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Restore EC failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + break; + } + } + return (Info); +} + + +static void ec_command(dword Id, PLCI *plci, byte Rc) +{ + word internal_command, Info; + byte result[8]; + + dbug(1, dprintf("[%06lx] %s,%d: ec_command %02x %04x %04x %04x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command, + plci->ec_cmd, plci->ec_idi_options, plci->ec_tail_length)); + + Info = GOOD; + if (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) + { + result[0] = 2; + PUT_WORD(&result[1], EC_SUCCESS); + } + else + { + result[0] = 5; + PUT_WORD(&result[1], plci->ec_cmd); + result[3] = 2; + PUT_WORD(&result[4], GOOD); + } + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (plci->ec_cmd) + { + case EC_ENABLE_OPERATION: + case EC_FREEZE_COEFFICIENTS: + case EC_RESUME_COEFFICIENT_UPDATE: + case EC_RESET_COEFFICIENTS: + switch (internal_command) + { + default: + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities | + B1_FACILITY_EC), EC_COMMAND_1); + case EC_COMMAND_1: + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Load EC failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (plci->internal_command) + return; + case EC_COMMAND_2: + if (plci->sig_req) + { + plci->internal_command = EC_COMMAND_2; + return; + } + plci->internal_command = EC_COMMAND_3; + ec_write_parameters(plci); + return; + case EC_COMMAND_3: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Enable EC failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + break; + } + break; + + case EC_DISABLE_OPERATION: + switch (internal_command) + { + default: + case EC_COMMAND_1: + if (plci->B1_facilities & B1_FACILITY_EC) + { + if (plci->sig_req) + { + plci->internal_command = EC_COMMAND_1; + return; + } + plci->internal_command = EC_COMMAND_2; + ec_write_parameters(plci); + return; + } + Rc = OK; + case EC_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Disable EC failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + adjust_b1_resource(Id, plci, NULL, (word)(plci->B1_facilities & + ~B1_FACILITY_EC), EC_COMMAND_3); + case EC_COMMAND_3: + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Unload EC failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + break; + } + if (plci->internal_command) + return; + break; + } + break; + } + sendf(plci->appl, _FACILITY_R | CONFIRM, Id & 0xffffL, plci->number, + "wws", Info, (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) ? + PRIV_SELECTOR_ECHO_CANCELLER : SELECTOR_ECHO_CANCELLER, result); +} + + +static byte ec_request(dword Id, word Number, DIVA_CAPI_ADAPTER *a, PLCI *plci, APPL *appl, API_PARSE *msg) +{ + word Info; + word opt; + API_PARSE ec_parms[3]; + byte result[16]; + + dbug(1, dprintf("[%06lx] %s,%d: ec_request", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + Info = GOOD; + result[0] = 0; + if (!(a->man_profile.private_options & (1L << PRIVATE_ECHO_CANCELLER))) + { + dbug(1, dprintf("[%06lx] %s,%d: Facility not supported", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _FACILITY_NOT_SUPPORTED; + } + else + { + if (appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) + { + if (api_parse(&msg[1].info[1], msg[1].length, "w", ec_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + } + else + { + if (plci == NULL) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong PLCI", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_IDENTIFIER; + } + else if (!plci->State || !plci->NL.Id || plci->nl_remove_id) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong state", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_STATE; + } + else + { + plci->command = 0; + plci->ec_cmd = GET_WORD(ec_parms[0].info); + plci->ec_idi_options &= ~(LEC_MANUAL_DISABLE | LEC_RESET_COEFFICIENTS); + result[0] = 2; + PUT_WORD(&result[1], EC_SUCCESS); + if (msg[1].length >= 4) + { + opt = GET_WORD(&ec_parms[0].info[2]); + plci->ec_idi_options &= ~(LEC_ENABLE_NONLINEAR_PROCESSING | + LEC_ENABLE_2100HZ_DETECTOR | LEC_REQUIRE_2100HZ_REVERSALS); + if (!(opt & EC_DISABLE_NON_LINEAR_PROCESSING)) + plci->ec_idi_options |= LEC_ENABLE_NONLINEAR_PROCESSING; + if (opt & EC_DETECT_DISABLE_TONE) + plci->ec_idi_options |= LEC_ENABLE_2100HZ_DETECTOR; + if (!(opt & EC_DO_NOT_REQUIRE_REVERSALS)) + plci->ec_idi_options |= LEC_REQUIRE_2100HZ_REVERSALS; + if (msg[1].length >= 6) + { + plci->ec_tail_length = GET_WORD(&ec_parms[0].info[4]); + } + } + switch (plci->ec_cmd) + { + case EC_ENABLE_OPERATION: + plci->ec_idi_options &= ~LEC_FREEZE_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + case EC_DISABLE_OPERATION: + plci->ec_idi_options = LEC_ENABLE_ECHO_CANCELLER | + LEC_MANUAL_DISABLE | LEC_ENABLE_NONLINEAR_PROCESSING | + LEC_RESET_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + case EC_FREEZE_COEFFICIENTS: + plci->ec_idi_options |= LEC_FREEZE_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + case EC_RESUME_COEFFICIENT_UPDATE: + plci->ec_idi_options &= ~LEC_FREEZE_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + case EC_RESET_COEFFICIENTS: + plci->ec_idi_options |= LEC_RESET_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + default: + dbug(1, dprintf("[%06lx] %s,%d: EC unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, plci->ec_cmd)); + PUT_WORD(&result[1], EC_UNSUPPORTED_OPERATION); + } + } + } + } + else + { + if (api_parse(&msg[1].info[1], msg[1].length, "ws", ec_parms)) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong message format", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_MESSAGE_FORMAT; + } + else + { + if (GET_WORD(ec_parms[0].info) == EC_GET_SUPPORTED_SERVICES) + { + result[0] = 11; + PUT_WORD(&result[1], EC_GET_SUPPORTED_SERVICES); + result[3] = 8; + PUT_WORD(&result[4], GOOD); + PUT_WORD(&result[6], 0x0007); + PUT_WORD(&result[8], LEC_MAX_SUPPORTED_TAIL_LENGTH); + PUT_WORD(&result[10], 0); + } + else if (plci == NULL) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong PLCI", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_IDENTIFIER; + } + else if (!plci->State || !plci->NL.Id || plci->nl_remove_id) + { + dbug(1, dprintf("[%06lx] %s,%d: Wrong state", + UnMapId(Id), (char *)(FILE_), __LINE__)); + Info = _WRONG_STATE; + } + else + { + plci->command = 0; + plci->ec_cmd = GET_WORD(ec_parms[0].info); + plci->ec_idi_options &= ~(LEC_MANUAL_DISABLE | LEC_RESET_COEFFICIENTS); + result[0] = 5; + PUT_WORD(&result[1], plci->ec_cmd); + result[3] = 2; + PUT_WORD(&result[4], GOOD); + plci->ec_idi_options &= ~(LEC_ENABLE_NONLINEAR_PROCESSING | + LEC_ENABLE_2100HZ_DETECTOR | LEC_REQUIRE_2100HZ_REVERSALS); + plci->ec_tail_length = 0; + if (ec_parms[1].length >= 2) + { + opt = GET_WORD(&ec_parms[1].info[1]); + if (opt & EC_ENABLE_NON_LINEAR_PROCESSING) + plci->ec_idi_options |= LEC_ENABLE_NONLINEAR_PROCESSING; + if (opt & EC_DETECT_DISABLE_TONE) + plci->ec_idi_options |= LEC_ENABLE_2100HZ_DETECTOR; + if (!(opt & EC_DO_NOT_REQUIRE_REVERSALS)) + plci->ec_idi_options |= LEC_REQUIRE_2100HZ_REVERSALS; + if (ec_parms[1].length >= 4) + { + plci->ec_tail_length = GET_WORD(&ec_parms[1].info[3]); + } + } + switch (plci->ec_cmd) + { + case EC_ENABLE_OPERATION: + plci->ec_idi_options &= ~LEC_FREEZE_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + case EC_DISABLE_OPERATION: + plci->ec_idi_options = LEC_ENABLE_ECHO_CANCELLER | + LEC_MANUAL_DISABLE | LEC_ENABLE_NONLINEAR_PROCESSING | + LEC_RESET_COEFFICIENTS; + start_internal_command(Id, plci, ec_command); + return (false); + + default: + dbug(1, dprintf("[%06lx] %s,%d: EC unknown request %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, plci->ec_cmd)); + PUT_WORD(&result[4], _FACILITY_SPECIFIC_FUNCTION_NOT_SUPP); + } + } + } + } + } + sendf(appl, _FACILITY_R | CONFIRM, Id & 0xffffL, Number, + "wws", Info, (appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) ? + PRIV_SELECTOR_ECHO_CANCELLER : SELECTOR_ECHO_CANCELLER, result); + return (false); +} + + +static void ec_indication(dword Id, PLCI *plci, byte *msg, word length) +{ + byte result[8]; + + dbug(1, dprintf("[%06lx] %s,%d: ec_indication", + UnMapId(Id), (char *)(FILE_), __LINE__)); + + if (!(plci->ec_idi_options & LEC_MANUAL_DISABLE)) + { + if (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) + { + result[0] = 2; + PUT_WORD(&result[1], 0); + switch (msg[1]) + { + case LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ: + PUT_WORD(&result[1], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ); + break; + case LEC_DISABLE_TYPE_REVERSED_2100HZ: + PUT_WORD(&result[1], EC_BYPASS_DUE_TO_REVERSED_2100HZ); + break; + case LEC_DISABLE_RELEASED: + PUT_WORD(&result[1], EC_BYPASS_RELEASED); + break; + } + } + else + { + result[0] = 5; + PUT_WORD(&result[1], EC_BYPASS_INDICATION); + result[3] = 2; + PUT_WORD(&result[4], 0); + switch (msg[1]) + { + case LEC_DISABLE_TYPE_CONTIGNUOUS_2100HZ: + PUT_WORD(&result[4], EC_BYPASS_DUE_TO_CONTINUOUS_2100HZ); + break; + case LEC_DISABLE_TYPE_REVERSED_2100HZ: + PUT_WORD(&result[4], EC_BYPASS_DUE_TO_REVERSED_2100HZ); + break; + case LEC_DISABLE_RELEASED: + PUT_WORD(&result[4], EC_BYPASS_RELEASED); + break; + } + } + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", (plci->appl->appl_flags & APPL_FLAG_PRIV_EC_SPEC) ? + PRIV_SELECTOR_ECHO_CANCELLER : SELECTOR_ECHO_CANCELLER, result); + } +} + + + +/*------------------------------------------------------------------*/ +/* Advanced voice */ +/*------------------------------------------------------------------*/ - dbug (1, dprintf ("[%06lx] %s,%d: adv_voice_restore_config %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); +static void adv_voice_write_coefs(PLCI *plci, word write_command) +{ + DIVA_CAPI_ADAPTER *a; + word i; + byte *p; + + word w, n, j, k; + byte ch_map[MIXER_CHANNELS_BRI]; + + byte coef_buffer[ADV_VOICE_COEF_BUFFER_SIZE + 2]; + + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_write_coefs %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, write_command)); + + a = plci->adapter; + p = coef_buffer + 1; + *(p++) = DSP_CTRL_OLD_SET_MIXER_COEFFICIENTS; + i = 0; + while (i + sizeof(word) <= a->adv_voice_coef_length) + { + PUT_WORD(p, GET_WORD(a->adv_voice_coef_buffer + i)); + p += 2; + i += 2; + } + while (i < ADV_VOICE_OLD_COEF_COUNT * sizeof(word)) + { + PUT_WORD(p, 0x8000); + p += 2; + i += 2; + } + + if (!a->li_pri && (plci->li_bchannel_id == 0)) + { + if ((li_config_table[a->li_base].plci == NULL) && (li_config_table[a->li_base + 1].plci != NULL)) + { + plci->li_bchannel_id = 1; + li_config_table[a->li_base].plci = plci; + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_set_bchannel_id %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, plci->li_bchannel_id)); + } + else if ((li_config_table[a->li_base].plci != NULL) && (li_config_table[a->li_base + 1].plci == NULL)) + { + plci->li_bchannel_id = 2; + li_config_table[a->li_base + 1].plci = plci; + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_set_bchannel_id %d", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, plci->li_bchannel_id)); + } + } + if (!a->li_pri && (plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + i = a->li_base + (plci->li_bchannel_id - 1); + switch (write_command) + { + case ADV_VOICE_WRITE_ACTIVATION: + j = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); + k = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); + if (!(plci->B1_facilities & B1_FACILITY_MIXER)) + { + li_config_table[j].flag_table[i] |= LI_FLAG_CONFERENCE | LI_FLAG_MIX; + li_config_table[i].flag_table[j] |= LI_FLAG_CONFERENCE | LI_FLAG_MONITOR; + } + if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) + { + li_config_table[k].flag_table[i] |= LI_FLAG_CONFERENCE | LI_FLAG_MIX; + li_config_table[i].flag_table[k] |= LI_FLAG_CONFERENCE | LI_FLAG_MONITOR; + li_config_table[k].flag_table[j] |= LI_FLAG_CONFERENCE; + li_config_table[j].flag_table[k] |= LI_FLAG_CONFERENCE; + } + mixer_calculate_coefs(a); + li_config_table[i].curchnl = li_config_table[i].channel; + li_config_table[j].curchnl = li_config_table[j].channel; + if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) + li_config_table[k].curchnl = li_config_table[k].channel; + break; + + case ADV_VOICE_WRITE_DEACTIVATION: + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].flag_table[j] = 0; + li_config_table[j].flag_table[i] = 0; + } + k = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); + for (j = 0; j < li_total_channels; j++) + { + li_config_table[k].flag_table[j] = 0; + li_config_table[j].flag_table[k] = 0; + } + if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) + { + k = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); + for (j = 0; j < li_total_channels; j++) + { + li_config_table[k].flag_table[j] = 0; + li_config_table[j].flag_table[k] = 0; + } + } + mixer_calculate_coefs(a); + break; + } + if (plci->B1_facilities & B1_FACILITY_MIXER) + { + w = 0; + if (ADV_VOICE_NEW_COEF_BASE + sizeof(word) <= a->adv_voice_coef_length) + w = GET_WORD(a->adv_voice_coef_buffer + ADV_VOICE_NEW_COEF_BASE); + if (li_config_table[i].channel & LI_CHANNEL_TX_DATA) + w |= MIXER_FEATURE_ENABLE_TX_DATA; + if (li_config_table[i].channel & LI_CHANNEL_RX_DATA) + w |= MIXER_FEATURE_ENABLE_RX_DATA; + *(p++) = (byte) w; + *(p++) = (byte)(w >> 8); + for (j = 0; j < sizeof(ch_map); j += 2) + { + ch_map[j] = (byte)(j + (plci->li_bchannel_id - 1)); + ch_map[j + 1] = (byte)(j + (2 - plci->li_bchannel_id)); + } + for (n = 0; n < ARRAY_SIZE(mixer_write_prog_bri); n++) + { + i = a->li_base + ch_map[mixer_write_prog_bri[n].to_ch]; + j = a->li_base + ch_map[mixer_write_prog_bri[n].from_ch]; + if (li_config_table[i].channel & li_config_table[j].channel & LI_CHANNEL_INVOLVED) + { + *(p++) = ((li_config_table[i].coef_table[j] & mixer_write_prog_bri[n].mask) ? 0x80 : 0x01); + w = ((li_config_table[i].coef_table[j] & 0xf) ^ (li_config_table[i].coef_table[j] >> 4)); + li_config_table[i].coef_table[j] ^= (w & mixer_write_prog_bri[n].mask) << 4; + } + else + { + *(p++) = (ADV_VOICE_NEW_COEF_BASE + sizeof(word) + n < a->adv_voice_coef_length) ? + a->adv_voice_coef_buffer[ADV_VOICE_NEW_COEF_BASE + sizeof(word) + n] : 0x00; + } + } + } + else + { + for (i = ADV_VOICE_NEW_COEF_BASE; i < a->adv_voice_coef_length; i++) + *(p++) = a->adv_voice_coef_buffer[i]; + } + } + else + + { + for (i = ADV_VOICE_NEW_COEF_BASE; i < a->adv_voice_coef_length; i++) + *(p++) = a->adv_voice_coef_buffer[i]; + } + coef_buffer[0] = (p - coef_buffer) - 1; + add_p(plci, FTY, coef_buffer); + sig_req(plci, TEL_CTRL, 0); + send_req(plci); +} + + +static void adv_voice_clear_config(PLCI *plci) +{ + DIVA_CAPI_ADAPTER *a; + + word i, j; + + + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_clear_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + + a = plci->adapter; + if ((plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) + { + a->adv_voice_coef_length = 0; + + if (!a->li_pri && (plci->li_bchannel_id != 0) + && (li_config_table[a->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + i = a->li_base + (plci->li_bchannel_id - 1); + li_config_table[i].curchnl = 0; + li_config_table[i].channel = 0; + li_config_table[i].chflags = 0; + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].flag_table[j] = 0; + li_config_table[j].flag_table[i] = 0; + li_config_table[i].coef_table[j] = 0; + li_config_table[j].coef_table[i] = 0; + } + li_config_table[i].coef_table[i] |= LI_COEF_CH_PC_SET | LI_COEF_PC_CH_SET; + i = a->li_base + MIXER_IC_CHANNEL_BASE + (plci->li_bchannel_id - 1); + li_config_table[i].curchnl = 0; + li_config_table[i].channel = 0; + li_config_table[i].chflags = 0; + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].flag_table[j] = 0; + li_config_table[j].flag_table[i] = 0; + li_config_table[i].coef_table[j] = 0; + li_config_table[j].coef_table[i] = 0; + } + if (a->manufacturer_features & MANUFACTURER_FEATURE_SLAVE_CODEC) + { + i = a->li_base + MIXER_IC_CHANNEL_BASE + (2 - plci->li_bchannel_id); + li_config_table[i].curchnl = 0; + li_config_table[i].channel = 0; + li_config_table[i].chflags = 0; + for (j = 0; j < li_total_channels; j++) + { + li_config_table[i].flag_table[j] = 0; + li_config_table[j].flag_table[i] = 0; + li_config_table[i].coef_table[j] = 0; + li_config_table[j].coef_table[i] = 0; + } + } + } + + } +} + + +static void adv_voice_prepare_switch(dword Id, PLCI *plci) +{ + + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_prepare_switch", + UnMapId(Id), (char *)(FILE_), __LINE__)); + +} + + +static word adv_voice_save_config(dword Id, PLCI *plci, byte Rc) +{ + + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_save_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + return (GOOD); +} + + +static word adv_voice_restore_config(dword Id, PLCI *plci, byte Rc) +{ + DIVA_CAPI_ADAPTER *a; + word Info; - Info = GOOD; - a = plci->adapter; - if ((plci->B1_facilities & B1_FACILITY_VOICE) - && (plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) - { - switch (plci->adjust_b_state) - { - case ADJUST_B_RESTORE_VOICE_1: - plci->internal_command = plci->adjust_b_command; - if (plci->sig_req) - { - plci->adjust_b_state = ADJUST_B_RESTORE_VOICE_1; - break; - } - adv_voice_write_coefs (plci, ADV_VOICE_WRITE_UPDATE); - plci->adjust_b_state = ADJUST_B_RESTORE_VOICE_2; - break; - case ADJUST_B_RESTORE_VOICE_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Restore voice config failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - break; - } - } - return (Info); + dbug(1, dprintf("[%06lx] %s,%d: adv_voice_restore_config %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + Info = GOOD; + a = plci->adapter; + if ((plci->B1_facilities & B1_FACILITY_VOICE) + && (plci->tel == ADV_VOICE) && (plci == a->AdvSignalPLCI)) + { + switch (plci->adjust_b_state) + { + case ADJUST_B_RESTORE_VOICE_1: + plci->internal_command = plci->adjust_b_command; + if (plci->sig_req) + { + plci->adjust_b_state = ADJUST_B_RESTORE_VOICE_1; + break; + } + adv_voice_write_coefs(plci, ADV_VOICE_WRITE_UPDATE); + plci->adjust_b_state = ADJUST_B_RESTORE_VOICE_2; + break; + case ADJUST_B_RESTORE_VOICE_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Restore voice config failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + break; + } + } + return (Info); } @@ -13354,1373 +13354,1373 @@ static word adv_voice_restore_config (dword Id, PLCI *plci, byte Rc) static byte b1_facilities_table[] = { - 0x00, /* 0 No bchannel resources */ - 0x00, /* 1 Codec (automatic law) */ - 0x00, /* 2 Codec (A-law) */ - 0x00, /* 3 Codec (y-law) */ - 0x00, /* 4 HDLC for X.21 */ - 0x00, /* 5 HDLC */ - 0x00, /* 6 External Device 0 */ - 0x00, /* 7 External Device 1 */ - 0x00, /* 8 HDLC 56k */ - 0x00, /* 9 Transparent */ - 0x00, /* 10 Loopback to network */ - 0x00, /* 11 Test pattern to net */ - 0x00, /* 12 Rate adaptation sync */ - 0x00, /* 13 Rate adaptation async */ - 0x00, /* 14 R-Interface */ - 0x00, /* 15 HDLC 128k leased line */ - 0x00, /* 16 FAX */ - 0x00, /* 17 Modem async */ - 0x00, /* 18 Modem sync HDLC */ - 0x00, /* 19 V.110 async HDLC */ - 0x12, /* 20 Adv voice (Trans,mixer) */ - 0x00, /* 21 Codec connected to IC */ - 0x0c, /* 22 Trans,DTMF */ - 0x1e, /* 23 Trans,DTMF+mixer */ - 0x1f, /* 24 Trans,DTMF+mixer+local */ - 0x13, /* 25 Trans,mixer+local */ - 0x12, /* 26 HDLC,mixer */ - 0x12, /* 27 HDLC 56k,mixer */ - 0x2c, /* 28 Trans,LEC+DTMF */ - 0x3e, /* 29 Trans,LEC+DTMF+mixer */ - 0x3f, /* 30 Trans,LEC+DTMF+mixer+local */ - 0x2c, /* 31 RTP,LEC+DTMF */ - 0x3e, /* 32 RTP,LEC+DTMF+mixer */ - 0x3f, /* 33 RTP,LEC+DTMF+mixer+local */ - 0x00, /* 34 Signaling task */ - 0x00, /* 35 PIAFS */ - 0x0c, /* 36 Trans,DTMF+TONE */ - 0x1e, /* 37 Trans,DTMF+TONE+mixer */ - 0x1f /* 38 Trans,DTMF+TONE+mixer+local*/ + 0x00, /* 0 No bchannel resources */ + 0x00, /* 1 Codec (automatic law) */ + 0x00, /* 2 Codec (A-law) */ + 0x00, /* 3 Codec (y-law) */ + 0x00, /* 4 HDLC for X.21 */ + 0x00, /* 5 HDLC */ + 0x00, /* 6 External Device 0 */ + 0x00, /* 7 External Device 1 */ + 0x00, /* 8 HDLC 56k */ + 0x00, /* 9 Transparent */ + 0x00, /* 10 Loopback to network */ + 0x00, /* 11 Test pattern to net */ + 0x00, /* 12 Rate adaptation sync */ + 0x00, /* 13 Rate adaptation async */ + 0x00, /* 14 R-Interface */ + 0x00, /* 15 HDLC 128k leased line */ + 0x00, /* 16 FAX */ + 0x00, /* 17 Modem async */ + 0x00, /* 18 Modem sync HDLC */ + 0x00, /* 19 V.110 async HDLC */ + 0x12, /* 20 Adv voice (Trans,mixer) */ + 0x00, /* 21 Codec connected to IC */ + 0x0c, /* 22 Trans,DTMF */ + 0x1e, /* 23 Trans,DTMF+mixer */ + 0x1f, /* 24 Trans,DTMF+mixer+local */ + 0x13, /* 25 Trans,mixer+local */ + 0x12, /* 26 HDLC,mixer */ + 0x12, /* 27 HDLC 56k,mixer */ + 0x2c, /* 28 Trans,LEC+DTMF */ + 0x3e, /* 29 Trans,LEC+DTMF+mixer */ + 0x3f, /* 30 Trans,LEC+DTMF+mixer+local */ + 0x2c, /* 31 RTP,LEC+DTMF */ + 0x3e, /* 32 RTP,LEC+DTMF+mixer */ + 0x3f, /* 33 RTP,LEC+DTMF+mixer+local */ + 0x00, /* 34 Signaling task */ + 0x00, /* 35 PIAFS */ + 0x0c, /* 36 Trans,DTMF+TONE */ + 0x1e, /* 37 Trans,DTMF+TONE+mixer */ + 0x1f /* 38 Trans,DTMF+TONE+mixer+local*/ }; -static word get_b1_facilities (PLCI * plci, byte b1_resource) +static word get_b1_facilities(PLCI *plci, byte b1_resource) { - word b1_facilities; + word b1_facilities; - b1_facilities = b1_facilities_table[b1_resource]; - if ((b1_resource == 9) || (b1_resource == 20) || (b1_resource == 25)) - { + b1_facilities = b1_facilities_table[b1_resource]; + if ((b1_resource == 9) || (b1_resource == 20) || (b1_resource == 25)) + { - if (!(((plci->requested_options_conn | plci->requested_options) & (1L << PRIVATE_DTMF_TONE)) - || (plci->appl && (plci->adapter->requested_options_table[plci->appl->Id-1] & (1L << PRIVATE_DTMF_TONE))))) + if (!(((plci->requested_options_conn | plci->requested_options) & (1L << PRIVATE_DTMF_TONE)) + || (plci->appl && (plci->adapter->requested_options_table[plci->appl->Id - 1] & (1L << PRIVATE_DTMF_TONE))))) - { - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_SEND) - b1_facilities |= B1_FACILITY_DTMFX; - if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE) - b1_facilities |= B1_FACILITY_DTMFR; - } - } - if ((b1_resource == 17) || (b1_resource == 18)) - { - if (plci->adapter->manufacturer_features & (MANUFACTURER_FEATURE_V18 | MANUFACTURER_FEATURE_VOWN)) - b1_facilities |= B1_FACILITY_DTMFX | B1_FACILITY_DTMFR; - } + { + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_SEND) + b1_facilities |= B1_FACILITY_DTMFX; + if (plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE) + b1_facilities |= B1_FACILITY_DTMFR; + } + } + if ((b1_resource == 17) || (b1_resource == 18)) + { + if (plci->adapter->manufacturer_features & (MANUFACTURER_FEATURE_V18 | MANUFACTURER_FEATURE_VOWN)) + b1_facilities |= B1_FACILITY_DTMFX | B1_FACILITY_DTMFR; + } /* - dbug (1, dprintf ("[%06lx] %s,%d: get_b1_facilities %d %04x", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char far *)(FILE_), __LINE__, b1_resource, b1_facilites)); + dbug (1, dprintf("[%06lx] %s,%d: get_b1_facilities %d %04x", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char far *)(FILE_), __LINE__, b1_resource, b1_facilites)); */ - return (b1_facilities); -} - - -static byte add_b1_facilities (PLCI * plci, byte b1_resource, word b1_facilities) -{ - byte b; - - switch (b1_resource) - { - case 5: - case 26: - if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 26; - else - b = 5; - break; - - case 8: - case 27: - if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 27; - else - b = 8; - break; - - case 9: - case 20: - case 22: - case 23: - case 24: - case 25: - case 28: - case 29: - case 30: - case 36: - case 37: - case 38: - if (b1_facilities & B1_FACILITY_EC) - { - if (b1_facilities & B1_FACILITY_LOCAL) - b = 30; - else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 29; - else - b = 28; - } - - else if ((b1_facilities & (B1_FACILITY_DTMFX | B1_FACILITY_DTMFR | B1_FACILITY_MIXER)) - && (((plci->requested_options_conn | plci->requested_options) & (1L << PRIVATE_DTMF_TONE)) - || (plci->appl && (plci->adapter->requested_options_table[plci->appl->Id-1] & (1L << PRIVATE_DTMF_TONE))))) - { - if (b1_facilities & B1_FACILITY_LOCAL) - b = 38; - else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 37; - else - b = 36; - } - - else if (((plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_HARDDTMF) - && !(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE)) - || ((b1_facilities & B1_FACILITY_DTMFR) - && ((b1_facilities & B1_FACILITY_MIXER) - || !(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE))) - || ((b1_facilities & B1_FACILITY_DTMFX) - && ((b1_facilities & B1_FACILITY_MIXER) - || !(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_SEND)))) - { - if (b1_facilities & B1_FACILITY_LOCAL) - b = 24; - else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 23; - else - b = 22; - } - else - { - if (b1_facilities & B1_FACILITY_LOCAL) - b = 25; - else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 20; - else - b = 9; - } - break; - - case 31: - case 32: - case 33: - if (b1_facilities & B1_FACILITY_LOCAL) - b = 33; - else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) - b = 32; - else - b = 31; - break; - - default: - b = b1_resource; - } - dbug (1, dprintf ("[%06lx] %s,%d: add_b1_facilities %d %04x %d %04x", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, - b1_resource, b1_facilities, b, get_b1_facilities (plci, b))); - return (b); -} - - -static void adjust_b1_facilities (PLCI *plci, byte new_b1_resource, word new_b1_facilities) -{ - word removed_facilities; - - dbug (1, dprintf ("[%06lx] %s,%d: adjust_b1_facilities %d %04x %04x", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__, new_b1_resource, new_b1_facilities, - new_b1_facilities & get_b1_facilities (plci, new_b1_resource))); - - new_b1_facilities &= get_b1_facilities (plci, new_b1_resource); - removed_facilities = plci->B1_facilities & ~new_b1_facilities; - - if (removed_facilities & B1_FACILITY_EC) - ec_clear_config (plci); - - - if (removed_facilities & B1_FACILITY_DTMFR) - { - dtmf_rec_clear_config (plci); - dtmf_parameter_clear_config (plci); - } - if (removed_facilities & B1_FACILITY_DTMFX) - dtmf_send_clear_config (plci); - - - if (removed_facilities & B1_FACILITY_MIXER) - mixer_clear_config (plci); - - if (removed_facilities & B1_FACILITY_VOICE) - adv_voice_clear_config (plci); - plci->B1_facilities = new_b1_facilities; -} - - -static void adjust_b_clear (PLCI *plci) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: adjust_b_clear", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - plci->adjust_b_restore = false; -} - - -static word adjust_b_process (dword Id, PLCI *plci, byte Rc) -{ - word Info; - byte b1_resource; - NCCI * ncci_ptr; - API_PARSE bp[2]; - - dbug (1, dprintf ("[%06lx] %s,%d: adjust_b_process %02x %d", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); - - Info = GOOD; - switch (plci->adjust_b_state) - { - case ADJUST_B_START: - if ((plci->adjust_b_parms_msg == NULL) - && (plci->adjust_b_mode & ADJUST_B_MODE_SWITCH_L1) - && ((plci->adjust_b_mode & ~(ADJUST_B_MODE_SAVE | ADJUST_B_MODE_SWITCH_L1 | - ADJUST_B_MODE_NO_RESOURCE | ADJUST_B_MODE_RESTORE)) == 0)) - { - b1_resource = (plci->adjust_b_mode == ADJUST_B_MODE_NO_RESOURCE) ? - 0 : add_b1_facilities (plci, plci->B1_resource, plci->adjust_b_facilities); - if (b1_resource == plci->B1_resource) - { - adjust_b1_facilities (plci, b1_resource, plci->adjust_b_facilities); - break; - } - if (plci->adjust_b_facilities & ~get_b1_facilities (plci, b1_resource)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B nonsupported facilities %d %d %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, - plci->B1_resource, b1_resource, plci->adjust_b_facilities)); - Info = _WRONG_STATE; - break; - } - } - if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) - { - - mixer_prepare_switch (Id, plci); - - - dtmf_prepare_switch (Id, plci); - dtmf_parameter_prepare_switch (Id, plci); - - - ec_prepare_switch (Id, plci); - - adv_voice_prepare_switch (Id, plci); - } - plci->adjust_b_state = ADJUST_B_SAVE_MIXER_1; - Rc = OK; - case ADJUST_B_SAVE_MIXER_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) - { - - Info = mixer_save_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_SAVE_DTMF_1; - Rc = OK; - case ADJUST_B_SAVE_DTMF_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) - { - - Info = dtmf_save_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_REMOVE_L23_1; - case ADJUST_B_REMOVE_L23_1: - if ((plci->adjust_b_mode & ADJUST_B_MODE_REMOVE_L23) - && plci->NL.Id && !plci->nl_remove_id) - { - plci->internal_command = plci->adjust_b_command; - if (plci->adjust_b_ncci != 0) - { - ncci_ptr = &(plci->adapter->ncci[plci->adjust_b_ncci]); - while (ncci_ptr->data_pending) - { - plci->data_sent_ptr = ncci_ptr->DBuffer[ncci_ptr->data_out].P; - data_rc (plci, plci->adapter->ncci_ch[plci->adjust_b_ncci]); - } - while (ncci_ptr->data_ack_pending) - data_ack (plci, plci->adapter->ncci_ch[plci->adjust_b_ncci]); - } - nl_req_ncci (plci, REMOVE, - (byte)((plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) ? plci->adjust_b_ncci : 0)); - send_req (plci); - plci->adjust_b_state = ADJUST_B_REMOVE_L23_2; - break; - } - plci->adjust_b_state = ADJUST_B_REMOVE_L23_2; - Rc = OK; - case ADJUST_B_REMOVE_L23_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B remove failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - if (plci->adjust_b_mode & ADJUST_B_MODE_REMOVE_L23) - { - if (plci_nl_busy (plci)) - { - plci->internal_command = plci->adjust_b_command; - break; - } - } - plci->adjust_b_state = ADJUST_B_SAVE_EC_1; - Rc = OK; - case ADJUST_B_SAVE_EC_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) - { - - Info = ec_save_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_SAVE_DTMF_PARAMETER_1; - Rc = OK; - case ADJUST_B_SAVE_DTMF_PARAMETER_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) - { - - Info = dtmf_parameter_save_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_SAVE_VOICE_1; - Rc = OK; - case ADJUST_B_SAVE_VOICE_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) - { - Info = adv_voice_save_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - } - plci->adjust_b_state = ADJUST_B_SWITCH_L1_1; - case ADJUST_B_SWITCH_L1_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_SWITCH_L1) - { - if (plci->sig_req) - { - plci->internal_command = plci->adjust_b_command; - break; - } - if (plci->adjust_b_parms_msg != NULL) - api_load_msg (plci->adjust_b_parms_msg, bp); - else - api_load_msg (&plci->B_protocol, bp); - Info = add_b1 (plci, bp, - (word)((plci->adjust_b_mode & ADJUST_B_MODE_NO_RESOURCE) ? 2 : 0), - plci->adjust_b_facilities); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B invalid L1 parameters %d %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, - plci->B1_resource, plci->adjust_b_facilities)); - break; - } - plci->internal_command = plci->adjust_b_command; - sig_req (plci, RESOURCES, 0); - send_req (plci); - plci->adjust_b_state = ADJUST_B_SWITCH_L1_2; - break; - } - plci->adjust_b_state = ADJUST_B_SWITCH_L1_2; - Rc = OK; - case ADJUST_B_SWITCH_L1_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B switch failed %02x %d %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, - Rc, plci->B1_resource, plci->adjust_b_facilities)); - Info = _WRONG_STATE; - break; - } - plci->adjust_b_state = ADJUST_B_RESTORE_VOICE_1; - Rc = OK; - case ADJUST_B_RESTORE_VOICE_1: - case ADJUST_B_RESTORE_VOICE_2: - if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) - { - Info = adv_voice_restore_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - } - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_PARAMETER_1; - Rc = OK; - case ADJUST_B_RESTORE_DTMF_PARAMETER_1: - case ADJUST_B_RESTORE_DTMF_PARAMETER_2: - if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) - { - - Info = dtmf_parameter_restore_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_RESTORE_EC_1; - Rc = OK; - case ADJUST_B_RESTORE_EC_1: - case ADJUST_B_RESTORE_EC_2: - if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) - { - - Info = ec_restore_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_ASSIGN_L23_1; - case ADJUST_B_ASSIGN_L23_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_ASSIGN_L23) - { - if (plci_nl_busy (plci)) - { - plci->internal_command = plci->adjust_b_command; - break; - } - if (plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) - plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; - if (plci->adjust_b_parms_msg != NULL) - api_load_msg (plci->adjust_b_parms_msg, bp); - else - api_load_msg (&plci->B_protocol, bp); - Info = add_b23 (plci, bp); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B invalid L23 parameters %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Info)); - break; - } - plci->internal_command = plci->adjust_b_command; - nl_req_ncci (plci, ASSIGN, 0); - send_req (plci); - plci->adjust_b_state = ADJUST_B_ASSIGN_L23_2; - break; - } - plci->adjust_b_state = ADJUST_B_ASSIGN_L23_2; - Rc = ASSIGN_OK; - case ADJUST_B_ASSIGN_L23_2: - if ((Rc != OK) && (Rc != OK_FC) && (Rc != ASSIGN_OK)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B assign failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - if (plci->adjust_b_mode & ADJUST_B_MODE_ASSIGN_L23) - { - if (Rc != ASSIGN_OK) - { - plci->internal_command = plci->adjust_b_command; - break; - } - } - if (plci->adjust_b_mode & ADJUST_B_MODE_USER_CONNECT) - { - plci->adjust_b_restore = true; - break; - } - plci->adjust_b_state = ADJUST_B_CONNECT_1; - case ADJUST_B_CONNECT_1: - if (plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) - { - plci->internal_command = plci->adjust_b_command; - if (plci_nl_busy (plci)) - break; - nl_req_ncci (plci, N_CONNECT, 0); - send_req (plci); - plci->adjust_b_state = ADJUST_B_CONNECT_2; - break; - } - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; - Rc = OK; - case ADJUST_B_CONNECT_2: - case ADJUST_B_CONNECT_3: - case ADJUST_B_CONNECT_4: - if ((Rc != OK) && (Rc != OK_FC) && (Rc != 0)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B connect failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - if (Rc == OK) - { - if (plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) - { - get_ncci (plci, (byte)(Id >> 16), plci->adjust_b_ncci); - Id = (Id & 0xffff) | (((dword)(plci->adjust_b_ncci)) << 16); - } - if (plci->adjust_b_state == ADJUST_B_CONNECT_2) - plci->adjust_b_state = ADJUST_B_CONNECT_3; - else if (plci->adjust_b_state == ADJUST_B_CONNECT_4) - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; - } - else if (Rc == 0) - { - if (plci->adjust_b_state == ADJUST_B_CONNECT_2) - plci->adjust_b_state = ADJUST_B_CONNECT_4; - else if (plci->adjust_b_state == ADJUST_B_CONNECT_3) - plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; - } - if (plci->adjust_b_state != ADJUST_B_RESTORE_DTMF_1) - { - plci->internal_command = plci->adjust_b_command; - break; - } - Rc = OK; - case ADJUST_B_RESTORE_DTMF_1: - case ADJUST_B_RESTORE_DTMF_2: - if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) - { - - Info = dtmf_restore_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_1; - Rc = OK; - case ADJUST_B_RESTORE_MIXER_1: - case ADJUST_B_RESTORE_MIXER_2: - case ADJUST_B_RESTORE_MIXER_3: - case ADJUST_B_RESTORE_MIXER_4: - case ADJUST_B_RESTORE_MIXER_5: - case ADJUST_B_RESTORE_MIXER_6: - case ADJUST_B_RESTORE_MIXER_7: - if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) - { - - Info = mixer_restore_config (Id, plci, Rc); - if ((Info != GOOD) || plci->internal_command) - break; - - } - plci->adjust_b_state = ADJUST_B_END; - case ADJUST_B_END: - break; - } - return (Info); -} - - -static void adjust_b1_resource (dword Id, PLCI *plci, API_SAVE *bp_msg, word b1_facilities, word internal_command) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: adjust_b1_resource %d %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, - plci->B1_resource, b1_facilities)); - - plci->adjust_b_parms_msg = bp_msg; - plci->adjust_b_facilities = b1_facilities; - plci->adjust_b_command = internal_command; - plci->adjust_b_ncci = (word)(Id >> 16); - if ((bp_msg == NULL) && (plci->B1_resource == 0)) - plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_NO_RESOURCE | ADJUST_B_MODE_SWITCH_L1; - else - plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_SWITCH_L1 | ADJUST_B_MODE_RESTORE; - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B1 resource %d %04x...", - UnMapId (Id), (char *)(FILE_), __LINE__, - plci->B1_resource, b1_facilities)); -} - - -static void adjust_b_restore (dword Id, PLCI *plci, byte Rc) -{ - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: adjust_b_restore %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - if (plci->req_in != 0) - { - plci->internal_command = ADJUST_B_RESTORE_1; - break; - } - Rc = OK; - case ADJUST_B_RESTORE_1: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B enqueued failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - } - plci->adjust_b_parms_msg = NULL; - plci->adjust_b_facilities = plci->B1_facilities; - plci->adjust_b_command = ADJUST_B_RESTORE_2; - plci->adjust_b_ncci = (word)(Id >> 16); - plci->adjust_b_mode = ADJUST_B_MODE_RESTORE; - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B restore...", - UnMapId (Id), (char *)(FILE_), __LINE__)); - case ADJUST_B_RESTORE_2: - if (adjust_b_process (Id, plci, Rc) != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Adjust B restore failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - } - if (plci->internal_command) - break; - break; - } -} - - -static void reset_b3_command (dword Id, PLCI *plci, byte Rc) -{ - word Info; - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: reset_b3_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - plci->adjust_b_parms_msg = NULL; - plci->adjust_b_facilities = plci->B1_facilities; - plci->adjust_b_command = RESET_B3_COMMAND_1; - plci->adjust_b_ncci = (word)(Id >> 16); - plci->adjust_b_mode = ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_ASSIGN_L23 | ADJUST_B_MODE_CONNECT; - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: Reset B3...", - UnMapId (Id), (char *)(FILE_), __LINE__)); - case RESET_B3_COMMAND_1: - Info = adjust_b_process (Id, plci, Rc); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Reset failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - break; - } + return (b1_facilities); +} + + +static byte add_b1_facilities(PLCI *plci, byte b1_resource, word b1_facilities) +{ + byte b; + + switch (b1_resource) + { + case 5: + case 26: + if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 26; + else + b = 5; + break; + + case 8: + case 27: + if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 27; + else + b = 8; + break; + + case 9: + case 20: + case 22: + case 23: + case 24: + case 25: + case 28: + case 29: + case 30: + case 36: + case 37: + case 38: + if (b1_facilities & B1_FACILITY_EC) + { + if (b1_facilities & B1_FACILITY_LOCAL) + b = 30; + else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 29; + else + b = 28; + } + + else if ((b1_facilities & (B1_FACILITY_DTMFX | B1_FACILITY_DTMFR | B1_FACILITY_MIXER)) + && (((plci->requested_options_conn | plci->requested_options) & (1L << PRIVATE_DTMF_TONE)) + || (plci->appl && (plci->adapter->requested_options_table[plci->appl->Id - 1] & (1L << PRIVATE_DTMF_TONE))))) + { + if (b1_facilities & B1_FACILITY_LOCAL) + b = 38; + else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 37; + else + b = 36; + } + + else if (((plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_HARDDTMF) + && !(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE)) + || ((b1_facilities & B1_FACILITY_DTMFR) + && ((b1_facilities & B1_FACILITY_MIXER) + || !(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_RECEIVE))) + || ((b1_facilities & B1_FACILITY_DTMFX) + && ((b1_facilities & B1_FACILITY_MIXER) + || !(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_SOFTDTMF_SEND)))) + { + if (b1_facilities & B1_FACILITY_LOCAL) + b = 24; + else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 23; + else + b = 22; + } + else + { + if (b1_facilities & B1_FACILITY_LOCAL) + b = 25; + else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 20; + else + b = 9; + } + break; + + case 31: + case 32: + case 33: + if (b1_facilities & B1_FACILITY_LOCAL) + b = 33; + else if (b1_facilities & (B1_FACILITY_MIXER | B1_FACILITY_VOICE)) + b = 32; + else + b = 31; + break; + + default: + b = b1_resource; + } + dbug(1, dprintf("[%06lx] %s,%d: add_b1_facilities %d %04x %d %04x", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, + b1_resource, b1_facilities, b, get_b1_facilities(plci, b))); + return (b); +} + + +static void adjust_b1_facilities(PLCI *plci, byte new_b1_resource, word new_b1_facilities) +{ + word removed_facilities; + + dbug(1, dprintf("[%06lx] %s,%d: adjust_b1_facilities %d %04x %04x", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__, new_b1_resource, new_b1_facilities, + new_b1_facilities & get_b1_facilities(plci, new_b1_resource))); + + new_b1_facilities &= get_b1_facilities(plci, new_b1_resource); + removed_facilities = plci->B1_facilities & ~new_b1_facilities; + + if (removed_facilities & B1_FACILITY_EC) + ec_clear_config(plci); + + + if (removed_facilities & B1_FACILITY_DTMFR) + { + dtmf_rec_clear_config(plci); + dtmf_parameter_clear_config(plci); + } + if (removed_facilities & B1_FACILITY_DTMFX) + dtmf_send_clear_config(plci); + + + if (removed_facilities & B1_FACILITY_MIXER) + mixer_clear_config(plci); + + if (removed_facilities & B1_FACILITY_VOICE) + adv_voice_clear_config(plci); + plci->B1_facilities = new_b1_facilities; +} + + +static void adjust_b_clear(PLCI *plci) +{ + + dbug(1, dprintf("[%06lx] %s,%d: adjust_b_clear", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); + + plci->adjust_b_restore = false; +} + + +static word adjust_b_process(dword Id, PLCI *plci, byte Rc) +{ + word Info; + byte b1_resource; + NCCI *ncci_ptr; + API_PARSE bp[2]; + + dbug(1, dprintf("[%06lx] %s,%d: adjust_b_process %02x %d", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->adjust_b_state)); + + Info = GOOD; + switch (plci->adjust_b_state) + { + case ADJUST_B_START: + if ((plci->adjust_b_parms_msg == NULL) + && (plci->adjust_b_mode & ADJUST_B_MODE_SWITCH_L1) + && ((plci->adjust_b_mode & ~(ADJUST_B_MODE_SAVE | ADJUST_B_MODE_SWITCH_L1 | + ADJUST_B_MODE_NO_RESOURCE | ADJUST_B_MODE_RESTORE)) == 0)) + { + b1_resource = (plci->adjust_b_mode == ADJUST_B_MODE_NO_RESOURCE) ? + 0 : add_b1_facilities(plci, plci->B1_resource, plci->adjust_b_facilities); + if (b1_resource == plci->B1_resource) + { + adjust_b1_facilities(plci, b1_resource, plci->adjust_b_facilities); + break; + } + if (plci->adjust_b_facilities & ~get_b1_facilities(plci, b1_resource)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B nonsupported facilities %d %d %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, + plci->B1_resource, b1_resource, plci->adjust_b_facilities)); + Info = _WRONG_STATE; + break; + } + } + if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) + { + + mixer_prepare_switch(Id, plci); + + + dtmf_prepare_switch(Id, plci); + dtmf_parameter_prepare_switch(Id, plci); + + + ec_prepare_switch(Id, plci); + + adv_voice_prepare_switch(Id, plci); + } + plci->adjust_b_state = ADJUST_B_SAVE_MIXER_1; + Rc = OK; + case ADJUST_B_SAVE_MIXER_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) + { + + Info = mixer_save_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_SAVE_DTMF_1; + Rc = OK; + case ADJUST_B_SAVE_DTMF_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) + { + + Info = dtmf_save_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_REMOVE_L23_1; + case ADJUST_B_REMOVE_L23_1: + if ((plci->adjust_b_mode & ADJUST_B_MODE_REMOVE_L23) + && plci->NL.Id && !plci->nl_remove_id) + { + plci->internal_command = plci->adjust_b_command; + if (plci->adjust_b_ncci != 0) + { + ncci_ptr = &(plci->adapter->ncci[plci->adjust_b_ncci]); + while (ncci_ptr->data_pending) + { + plci->data_sent_ptr = ncci_ptr->DBuffer[ncci_ptr->data_out].P; + data_rc(plci, plci->adapter->ncci_ch[plci->adjust_b_ncci]); + } + while (ncci_ptr->data_ack_pending) + data_ack(plci, plci->adapter->ncci_ch[plci->adjust_b_ncci]); + } + nl_req_ncci(plci, REMOVE, + (byte)((plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) ? plci->adjust_b_ncci : 0)); + send_req(plci); + plci->adjust_b_state = ADJUST_B_REMOVE_L23_2; + break; + } + plci->adjust_b_state = ADJUST_B_REMOVE_L23_2; + Rc = OK; + case ADJUST_B_REMOVE_L23_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B remove failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + if (plci->adjust_b_mode & ADJUST_B_MODE_REMOVE_L23) + { + if (plci_nl_busy(plci)) + { + plci->internal_command = plci->adjust_b_command; + break; + } + } + plci->adjust_b_state = ADJUST_B_SAVE_EC_1; + Rc = OK; + case ADJUST_B_SAVE_EC_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) + { + + Info = ec_save_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_SAVE_DTMF_PARAMETER_1; + Rc = OK; + case ADJUST_B_SAVE_DTMF_PARAMETER_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) + { + + Info = dtmf_parameter_save_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_SAVE_VOICE_1; + Rc = OK; + case ADJUST_B_SAVE_VOICE_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_SAVE) + { + Info = adv_voice_save_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + } + plci->adjust_b_state = ADJUST_B_SWITCH_L1_1; + case ADJUST_B_SWITCH_L1_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_SWITCH_L1) + { + if (plci->sig_req) + { + plci->internal_command = plci->adjust_b_command; + break; + } + if (plci->adjust_b_parms_msg != NULL) + api_load_msg(plci->adjust_b_parms_msg, bp); + else + api_load_msg(&plci->B_protocol, bp); + Info = add_b1(plci, bp, + (word)((plci->adjust_b_mode & ADJUST_B_MODE_NO_RESOURCE) ? 2 : 0), + plci->adjust_b_facilities); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B invalid L1 parameters %d %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, + plci->B1_resource, plci->adjust_b_facilities)); + break; + } + plci->internal_command = plci->adjust_b_command; + sig_req(plci, RESOURCES, 0); + send_req(plci); + plci->adjust_b_state = ADJUST_B_SWITCH_L1_2; + break; + } + plci->adjust_b_state = ADJUST_B_SWITCH_L1_2; + Rc = OK; + case ADJUST_B_SWITCH_L1_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B switch failed %02x %d %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, + Rc, plci->B1_resource, plci->adjust_b_facilities)); + Info = _WRONG_STATE; + break; + } + plci->adjust_b_state = ADJUST_B_RESTORE_VOICE_1; + Rc = OK; + case ADJUST_B_RESTORE_VOICE_1: + case ADJUST_B_RESTORE_VOICE_2: + if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) + { + Info = adv_voice_restore_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + } + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_PARAMETER_1; + Rc = OK; + case ADJUST_B_RESTORE_DTMF_PARAMETER_1: + case ADJUST_B_RESTORE_DTMF_PARAMETER_2: + if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) + { + + Info = dtmf_parameter_restore_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_RESTORE_EC_1; + Rc = OK; + case ADJUST_B_RESTORE_EC_1: + case ADJUST_B_RESTORE_EC_2: + if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) + { + + Info = ec_restore_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_ASSIGN_L23_1; + case ADJUST_B_ASSIGN_L23_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_ASSIGN_L23) + { + if (plci_nl_busy(plci)) + { + plci->internal_command = plci->adjust_b_command; + break; + } + if (plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) + plci->call_dir |= CALL_DIR_FORCE_OUTG_NL; + if (plci->adjust_b_parms_msg != NULL) + api_load_msg(plci->adjust_b_parms_msg, bp); + else + api_load_msg(&plci->B_protocol, bp); + Info = add_b23(plci, bp); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B invalid L23 parameters %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Info)); + break; + } + plci->internal_command = plci->adjust_b_command; + nl_req_ncci(plci, ASSIGN, 0); + send_req(plci); + plci->adjust_b_state = ADJUST_B_ASSIGN_L23_2; + break; + } + plci->adjust_b_state = ADJUST_B_ASSIGN_L23_2; + Rc = ASSIGN_OK; + case ADJUST_B_ASSIGN_L23_2: + if ((Rc != OK) && (Rc != OK_FC) && (Rc != ASSIGN_OK)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B assign failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + if (plci->adjust_b_mode & ADJUST_B_MODE_ASSIGN_L23) + { + if (Rc != ASSIGN_OK) + { + plci->internal_command = plci->adjust_b_command; + break; + } + } + if (plci->adjust_b_mode & ADJUST_B_MODE_USER_CONNECT) + { + plci->adjust_b_restore = true; + break; + } + plci->adjust_b_state = ADJUST_B_CONNECT_1; + case ADJUST_B_CONNECT_1: + if (plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) + { + plci->internal_command = plci->adjust_b_command; + if (plci_nl_busy(plci)) + break; + nl_req_ncci(plci, N_CONNECT, 0); + send_req(plci); + plci->adjust_b_state = ADJUST_B_CONNECT_2; + break; + } + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; + Rc = OK; + case ADJUST_B_CONNECT_2: + case ADJUST_B_CONNECT_3: + case ADJUST_B_CONNECT_4: + if ((Rc != OK) && (Rc != OK_FC) && (Rc != 0)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B connect failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + if (Rc == OK) + { + if (plci->adjust_b_mode & ADJUST_B_MODE_CONNECT) + { + get_ncci(plci, (byte)(Id >> 16), plci->adjust_b_ncci); + Id = (Id & 0xffff) | (((dword)(plci->adjust_b_ncci)) << 16); + } + if (plci->adjust_b_state == ADJUST_B_CONNECT_2) + plci->adjust_b_state = ADJUST_B_CONNECT_3; + else if (plci->adjust_b_state == ADJUST_B_CONNECT_4) + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; + } + else if (Rc == 0) + { + if (plci->adjust_b_state == ADJUST_B_CONNECT_2) + plci->adjust_b_state = ADJUST_B_CONNECT_4; + else if (plci->adjust_b_state == ADJUST_B_CONNECT_3) + plci->adjust_b_state = ADJUST_B_RESTORE_DTMF_1; + } + if (plci->adjust_b_state != ADJUST_B_RESTORE_DTMF_1) + { + plci->internal_command = plci->adjust_b_command; + break; + } + Rc = OK; + case ADJUST_B_RESTORE_DTMF_1: + case ADJUST_B_RESTORE_DTMF_2: + if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) + { + + Info = dtmf_restore_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_RESTORE_MIXER_1; + Rc = OK; + case ADJUST_B_RESTORE_MIXER_1: + case ADJUST_B_RESTORE_MIXER_2: + case ADJUST_B_RESTORE_MIXER_3: + case ADJUST_B_RESTORE_MIXER_4: + case ADJUST_B_RESTORE_MIXER_5: + case ADJUST_B_RESTORE_MIXER_6: + case ADJUST_B_RESTORE_MIXER_7: + if (plci->adjust_b_mode & ADJUST_B_MODE_RESTORE) + { + + Info = mixer_restore_config(Id, plci, Rc); + if ((Info != GOOD) || plci->internal_command) + break; + + } + plci->adjust_b_state = ADJUST_B_END; + case ADJUST_B_END: + break; + } + return (Info); +} + + +static void adjust_b1_resource(dword Id, PLCI *plci, API_SAVE *bp_msg, word b1_facilities, word internal_command) +{ + + dbug(1, dprintf("[%06lx] %s,%d: adjust_b1_resource %d %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, + plci->B1_resource, b1_facilities)); + + plci->adjust_b_parms_msg = bp_msg; + plci->adjust_b_facilities = b1_facilities; + plci->adjust_b_command = internal_command; + plci->adjust_b_ncci = (word)(Id >> 16); + if ((bp_msg == NULL) && (plci->B1_resource == 0)) + plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_NO_RESOURCE | ADJUST_B_MODE_SWITCH_L1; + else + plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_SWITCH_L1 | ADJUST_B_MODE_RESTORE; + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: Adjust B1 resource %d %04x...", + UnMapId(Id), (char *)(FILE_), __LINE__, + plci->B1_resource, b1_facilities)); +} + + +static void adjust_b_restore(dword Id, PLCI *plci, byte Rc) +{ + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: adjust_b_restore %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + if (plci->req_in != 0) + { + plci->internal_command = ADJUST_B_RESTORE_1; + break; + } + Rc = OK; + case ADJUST_B_RESTORE_1: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B enqueued failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + } + plci->adjust_b_parms_msg = NULL; + plci->adjust_b_facilities = plci->B1_facilities; + plci->adjust_b_command = ADJUST_B_RESTORE_2; + plci->adjust_b_ncci = (word)(Id >> 16); + plci->adjust_b_mode = ADJUST_B_MODE_RESTORE; + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: Adjust B restore...", + UnMapId(Id), (char *)(FILE_), __LINE__)); + case ADJUST_B_RESTORE_2: + if (adjust_b_process(Id, plci, Rc) != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Adjust B restore failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + } + if (plci->internal_command) + break; + break; + } +} + + +static void reset_b3_command(dword Id, PLCI *plci, byte Rc) +{ + word Info; + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: reset_b3_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + plci->adjust_b_parms_msg = NULL; + plci->adjust_b_facilities = plci->B1_facilities; + plci->adjust_b_command = RESET_B3_COMMAND_1; + plci->adjust_b_ncci = (word)(Id >> 16); + plci->adjust_b_mode = ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_ASSIGN_L23 | ADJUST_B_MODE_CONNECT; + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: Reset B3...", + UnMapId(Id), (char *)(FILE_), __LINE__)); + case RESET_B3_COMMAND_1: + Info = adjust_b_process(Id, plci, Rc); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Reset failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + break; + } /* sendf (plci->appl, _RESET_B3_R | CONFIRM, Id, plci->number, "w", Info);*/ - sendf(plci->appl,_RESET_B3_I,Id,0,"s",""); -} - - -static void select_b_command (dword Id, PLCI *plci, byte Rc) -{ - word Info; - word internal_command; - byte esc_chi[3]; - - dbug (1, dprintf ("[%06lx] %s,%d: select_b_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - plci->adjust_b_parms_msg = &plci->saved_msg; - if ((plci->tel == ADV_VOICE) && (plci == plci->adapter->AdvSignalPLCI)) - plci->adjust_b_facilities = plci->B1_facilities | B1_FACILITY_VOICE; - else - plci->adjust_b_facilities = plci->B1_facilities & ~B1_FACILITY_VOICE; - plci->adjust_b_command = SELECT_B_COMMAND_1; - plci->adjust_b_ncci = (word)(Id >> 16); - if (plci->saved_msg.parms[0].length == 0) - { - plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_SWITCH_L1 | - ADJUST_B_MODE_NO_RESOURCE; - } - else - { - plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_SWITCH_L1 | - ADJUST_B_MODE_ASSIGN_L23 | ADJUST_B_MODE_USER_CONNECT | ADJUST_B_MODE_RESTORE; - } - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: Select B protocol...", - UnMapId (Id), (char *)(FILE_), __LINE__)); - case SELECT_B_COMMAND_1: - Info = adjust_b_process (Id, plci, Rc); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: Select B protocol failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - if (plci->tel == ADV_VOICE) - { - esc_chi[0] = 0x02; - esc_chi[1] = 0x18; - esc_chi[2] = plci->b_channel; - SetVoiceChannel (plci->adapter->AdvCodecPLCI, esc_chi, plci->adapter); - } - break; - } - sendf (plci->appl, _SELECT_B_REQ | CONFIRM, Id, plci->number, "w", Info); -} - - -static void fax_connect_ack_command (dword Id, PLCI *plci, byte Rc) -{ - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: fax_connect_ack_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - case FAX_CONNECT_ACK_COMMAND_1: - if (plci_nl_busy (plci)) - { - plci->internal_command = FAX_CONNECT_ACK_COMMAND_1; - return; - } - plci->internal_command = FAX_CONNECT_ACK_COMMAND_2; - plci->NData[0].P = plci->fax_connect_info_buffer; - plci->NData[0].PLength = plci->fax_connect_info_length; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_CONNECT_ACK; - plci->adapter->request (&plci->NL); - return; - case FAX_CONNECT_ACK_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: FAX issue CONNECT ACK failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - break; - } - } - if ((plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) - && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) - { - if (plci->B3_prot == 4) - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"s",""); - else - sendf(plci->appl,_CONNECT_B3_ACTIVE_I,Id,0,"S",plci->ncpi_buffer); - plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; - } -} - - -static void fax_edata_ack_command (dword Id, PLCI *plci, byte Rc) -{ - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: fax_edata_ack_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - case FAX_EDATA_ACK_COMMAND_1: - if (plci_nl_busy (plci)) - { - plci->internal_command = FAX_EDATA_ACK_COMMAND_1; - return; - } - plci->internal_command = FAX_EDATA_ACK_COMMAND_2; - plci->NData[0].P = plci->fax_connect_info_buffer; - plci->NData[0].PLength = plci->fax_edata_ack_length; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_EDATA; - plci->adapter->request (&plci->NL); - return; - case FAX_EDATA_ACK_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: FAX issue EDATA ACK failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - break; - } - } -} - - -static void fax_connect_info_command (dword Id, PLCI *plci, byte Rc) -{ - word Info; - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: fax_connect_info_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - case FAX_CONNECT_INFO_COMMAND_1: - if (plci_nl_busy (plci)) - { - plci->internal_command = FAX_CONNECT_INFO_COMMAND_1; - return; - } - plci->internal_command = FAX_CONNECT_INFO_COMMAND_2; - plci->NData[0].P = plci->fax_connect_info_buffer; - plci->NData[0].PLength = plci->fax_connect_info_length; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_EDATA; - plci->adapter->request (&plci->NL); - return; - case FAX_CONNECT_INFO_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: FAX setting connect info failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - if (plci_nl_busy (plci)) - { - plci->internal_command = FAX_CONNECT_INFO_COMMAND_2; - return; - } - plci->command = _CONNECT_B3_R; - nl_req_ncci (plci, N_CONNECT, 0); - send_req (plci); - return; - } - sendf (plci->appl, _CONNECT_B3_R | CONFIRM, Id, plci->number, "w", Info); + sendf(plci->appl, _RESET_B3_I, Id, 0, "s", ""); +} + + +static void select_b_command(dword Id, PLCI *plci, byte Rc) +{ + word Info; + word internal_command; + byte esc_chi[3]; + + dbug(1, dprintf("[%06lx] %s,%d: select_b_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + plci->adjust_b_parms_msg = &plci->saved_msg; + if ((plci->tel == ADV_VOICE) && (plci == plci->adapter->AdvSignalPLCI)) + plci->adjust_b_facilities = plci->B1_facilities | B1_FACILITY_VOICE; + else + plci->adjust_b_facilities = plci->B1_facilities & ~B1_FACILITY_VOICE; + plci->adjust_b_command = SELECT_B_COMMAND_1; + plci->adjust_b_ncci = (word)(Id >> 16); + if (plci->saved_msg.parms[0].length == 0) + { + plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_SWITCH_L1 | + ADJUST_B_MODE_NO_RESOURCE; + } + else + { + plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_SWITCH_L1 | + ADJUST_B_MODE_ASSIGN_L23 | ADJUST_B_MODE_USER_CONNECT | ADJUST_B_MODE_RESTORE; + } + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: Select B protocol...", + UnMapId(Id), (char *)(FILE_), __LINE__)); + case SELECT_B_COMMAND_1: + Info = adjust_b_process(Id, plci, Rc); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: Select B protocol failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + if (plci->tel == ADV_VOICE) + { + esc_chi[0] = 0x02; + esc_chi[1] = 0x18; + esc_chi[2] = plci->b_channel; + SetVoiceChannel(plci->adapter->AdvCodecPLCI, esc_chi, plci->adapter); + } + break; + } + sendf(plci->appl, _SELECT_B_REQ | CONFIRM, Id, plci->number, "w", Info); +} + + +static void fax_connect_ack_command(dword Id, PLCI *plci, byte Rc) +{ + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: fax_connect_ack_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + case FAX_CONNECT_ACK_COMMAND_1: + if (plci_nl_busy(plci)) + { + plci->internal_command = FAX_CONNECT_ACK_COMMAND_1; + return; + } + plci->internal_command = FAX_CONNECT_ACK_COMMAND_2; + plci->NData[0].P = plci->fax_connect_info_buffer; + plci->NData[0].PLength = plci->fax_connect_info_length; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_CONNECT_ACK; + plci->adapter->request(&plci->NL); + return; + case FAX_CONNECT_ACK_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: FAX issue CONNECT ACK failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + break; + } + } + if ((plci->ncpi_state & NCPI_VALID_CONNECT_B3_ACT) + && !(plci->ncpi_state & NCPI_CONNECT_B3_ACT_SENT)) + { + if (plci->B3_prot == 4) + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + else + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "S", plci->ncpi_buffer); + plci->ncpi_state |= NCPI_CONNECT_B3_ACT_SENT; + } +} + + +static void fax_edata_ack_command(dword Id, PLCI *plci, byte Rc) +{ + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: fax_edata_ack_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + case FAX_EDATA_ACK_COMMAND_1: + if (plci_nl_busy(plci)) + { + plci->internal_command = FAX_EDATA_ACK_COMMAND_1; + return; + } + plci->internal_command = FAX_EDATA_ACK_COMMAND_2; + plci->NData[0].P = plci->fax_connect_info_buffer; + plci->NData[0].PLength = plci->fax_edata_ack_length; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_EDATA; + plci->adapter->request(&plci->NL); + return; + case FAX_EDATA_ACK_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: FAX issue EDATA ACK failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + break; + } + } +} + + +static void fax_connect_info_command(dword Id, PLCI *plci, byte Rc) +{ + word Info; + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: fax_connect_info_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + case FAX_CONNECT_INFO_COMMAND_1: + if (plci_nl_busy(plci)) + { + plci->internal_command = FAX_CONNECT_INFO_COMMAND_1; + return; + } + plci->internal_command = FAX_CONNECT_INFO_COMMAND_2; + plci->NData[0].P = plci->fax_connect_info_buffer; + plci->NData[0].PLength = plci->fax_connect_info_length; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_EDATA; + plci->adapter->request(&plci->NL); + return; + case FAX_CONNECT_INFO_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: FAX setting connect info failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + if (plci_nl_busy(plci)) + { + plci->internal_command = FAX_CONNECT_INFO_COMMAND_2; + return; + } + plci->command = _CONNECT_B3_R; + nl_req_ncci(plci, N_CONNECT, 0); + send_req(plci); + return; + } + sendf(plci->appl, _CONNECT_B3_R | CONFIRM, Id, plci->number, "w", Info); +} + + +static void fax_adjust_b23_command(dword Id, PLCI *plci, byte Rc) +{ + word Info; + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: fax_adjust_b23_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + plci->adjust_b_parms_msg = NULL; + plci->adjust_b_facilities = plci->B1_facilities; + plci->adjust_b_command = FAX_ADJUST_B23_COMMAND_1; + plci->adjust_b_ncci = (word)(Id >> 16); + plci->adjust_b_mode = ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_ASSIGN_L23; + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: FAX adjust B23...", + UnMapId(Id), (char *)(FILE_), __LINE__)); + case FAX_ADJUST_B23_COMMAND_1: + Info = adjust_b_process(Id, plci, Rc); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: FAX adjust failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + case FAX_ADJUST_B23_COMMAND_2: + if (plci_nl_busy(plci)) + { + plci->internal_command = FAX_ADJUST_B23_COMMAND_2; + return; + } + plci->command = _CONNECT_B3_R; + nl_req_ncci(plci, N_CONNECT, 0); + send_req(plci); + return; + } + sendf(plci->appl, _CONNECT_B3_R | CONFIRM, Id, plci->number, "w", Info); +} + + +static void fax_disconnect_command(dword Id, PLCI *plci, byte Rc) +{ + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: fax_disconnect_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + plci->internal_command = FAX_DISCONNECT_COMMAND_1; + return; + case FAX_DISCONNECT_COMMAND_1: + case FAX_DISCONNECT_COMMAND_2: + case FAX_DISCONNECT_COMMAND_3: + if ((Rc != OK) && (Rc != OK_FC) && (Rc != 0)) + { + dbug(1, dprintf("[%06lx] %s,%d: FAX disconnect EDATA failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + break; + } + if (Rc == OK) + { + if ((internal_command == FAX_DISCONNECT_COMMAND_1) + || (internal_command == FAX_DISCONNECT_COMMAND_2)) + { + plci->internal_command = FAX_DISCONNECT_COMMAND_2; + } + } + else if (Rc == 0) + { + if (internal_command == FAX_DISCONNECT_COMMAND_1) + plci->internal_command = FAX_DISCONNECT_COMMAND_3; + } + return; + } +} + + + +static void rtp_connect_b3_req_command(dword Id, PLCI *plci, byte Rc) +{ + word Info; + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: rtp_connect_b3_req_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + case RTP_CONNECT_B3_REQ_COMMAND_1: + if (plci_nl_busy(plci)) + { + plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_1; + return; + } + plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_2; + nl_req_ncci(plci, N_CONNECT, 0); + send_req(plci); + return; + case RTP_CONNECT_B3_REQ_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: RTP setting connect info failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + Info = _WRONG_STATE; + break; + } + if (plci_nl_busy(plci)) + { + plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_2; + return; + } + plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_3; + plci->NData[0].PLength = plci->internal_req_buffer[0]; + plci->NData[0].P = plci->internal_req_buffer + 1; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_UDATA; + plci->adapter->request(&plci->NL); + break; + case RTP_CONNECT_B3_REQ_COMMAND_3: + return; + } + sendf(plci->appl, _CONNECT_B3_R | CONFIRM, Id, plci->number, "w", Info); +} + + +static void rtp_connect_b3_res_command(dword Id, PLCI *plci, byte Rc) +{ + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: rtp_connect_b3_res_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + case RTP_CONNECT_B3_RES_COMMAND_1: + if (plci_nl_busy(plci)) + { + plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_1; + return; + } + plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_2; + nl_req_ncci(plci, N_CONNECT_ACK, (byte)(Id >> 16)); + send_req(plci); + return; + case RTP_CONNECT_B3_RES_COMMAND_2: + if ((Rc != OK) && (Rc != OK_FC)) + { + dbug(1, dprintf("[%06lx] %s,%d: RTP setting connect resp info failed %02x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc)); + break; + } + if (plci_nl_busy(plci)) + { + plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_2; + return; + } + sendf(plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); + plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_3; + plci->NData[0].PLength = plci->internal_req_buffer[0]; + plci->NData[0].P = plci->internal_req_buffer + 1; + plci->NL.X = plci->NData; + plci->NL.ReqCh = 0; + plci->NL.Req = plci->nl_req = (byte) N_UDATA; + plci->adapter->request(&plci->NL); + return; + case RTP_CONNECT_B3_RES_COMMAND_3: + return; + } +} + + + +static void hold_save_command(dword Id, PLCI *plci, byte Rc) +{ + byte SS_Ind[] = "\x05\x02\x00\x02\x00\x00"; /* Hold_Ind struct*/ + word Info; + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: hold_save_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + if (!plci->NL.Id) + break; + plci->command = 0; + plci->adjust_b_parms_msg = NULL; + plci->adjust_b_facilities = plci->B1_facilities; + plci->adjust_b_command = HOLD_SAVE_COMMAND_1; + plci->adjust_b_ncci = (word)(Id >> 16); + plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_REMOVE_L23; + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: HOLD save...", + UnMapId(Id), (char *)(FILE_), __LINE__)); + case HOLD_SAVE_COMMAND_1: + Info = adjust_b_process(Id, plci, Rc); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: HOLD save failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + } + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", 3, SS_Ind); +} + + +static void retrieve_restore_command(dword Id, PLCI *plci, byte Rc) +{ + byte SS_Ind[] = "\x05\x03\x00\x02\x00\x00"; /* Retrieve_Ind struct*/ + word Info; + word internal_command; + + dbug(1, dprintf("[%06lx] %s,%d: retrieve_restore_command %02x %04x", + UnMapId(Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + + Info = GOOD; + internal_command = plci->internal_command; + plci->internal_command = 0; + switch (internal_command) + { + default: + plci->command = 0; + plci->adjust_b_parms_msg = NULL; + plci->adjust_b_facilities = plci->B1_facilities; + plci->adjust_b_command = RETRIEVE_RESTORE_COMMAND_1; + plci->adjust_b_ncci = (word)(Id >> 16); + plci->adjust_b_mode = ADJUST_B_MODE_ASSIGN_L23 | ADJUST_B_MODE_USER_CONNECT | ADJUST_B_MODE_RESTORE; + plci->adjust_b_state = ADJUST_B_START; + dbug(1, dprintf("[%06lx] %s,%d: RETRIEVE restore...", + UnMapId(Id), (char *)(FILE_), __LINE__)); + case RETRIEVE_RESTORE_COMMAND_1: + Info = adjust_b_process(Id, plci, Rc); + if (Info != GOOD) + { + dbug(1, dprintf("[%06lx] %s,%d: RETRIEVE restore failed", + UnMapId(Id), (char *)(FILE_), __LINE__)); + break; + } + if (plci->internal_command) + return; + } + sendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", 3, SS_Ind); } -static void fax_adjust_b23_command (dword Id, PLCI *plci, byte Rc) +static void init_b1_config(PLCI *plci) { - word Info; - word internal_command; - dbug (1, dprintf ("[%06lx] %s,%d: fax_adjust_b23_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + dbug(1, dprintf("[%06lx] %s,%d: init_b1_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - plci->adjust_b_parms_msg = NULL; - plci->adjust_b_facilities = plci->B1_facilities; - plci->adjust_b_command = FAX_ADJUST_B23_COMMAND_1; - plci->adjust_b_ncci = (word)(Id >> 16); - plci->adjust_b_mode = ADJUST_B_MODE_REMOVE_L23 | ADJUST_B_MODE_ASSIGN_L23; - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: FAX adjust B23...", - UnMapId (Id), (char *)(FILE_), __LINE__)); - case FAX_ADJUST_B23_COMMAND_1: - Info = adjust_b_process (Id, plci, Rc); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: FAX adjust failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - case FAX_ADJUST_B23_COMMAND_2: - if (plci_nl_busy (plci)) - { - plci->internal_command = FAX_ADJUST_B23_COMMAND_2; - return; - } - plci->command = _CONNECT_B3_R; - nl_req_ncci (plci, N_CONNECT, 0); - send_req (plci); - return; - } - sendf (plci->appl, _CONNECT_B3_R | CONFIRM, Id, plci->number, "w", Info); -} - - -static void fax_disconnect_command (dword Id, PLCI *plci, byte Rc) -{ - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: fax_disconnect_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - plci->internal_command = FAX_DISCONNECT_COMMAND_1; - return; - case FAX_DISCONNECT_COMMAND_1: - case FAX_DISCONNECT_COMMAND_2: - case FAX_DISCONNECT_COMMAND_3: - if ((Rc != OK) && (Rc != OK_FC) && (Rc != 0)) - { - dbug (1, dprintf ("[%06lx] %s,%d: FAX disconnect EDATA failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - break; - } - if (Rc == OK) - { - if ((internal_command == FAX_DISCONNECT_COMMAND_1) - || (internal_command == FAX_DISCONNECT_COMMAND_2)) - { - plci->internal_command = FAX_DISCONNECT_COMMAND_2; - } - } - else if (Rc == 0) - { - if (internal_command == FAX_DISCONNECT_COMMAND_1) - plci->internal_command = FAX_DISCONNECT_COMMAND_3; - } - return; - } -} - - - -static void rtp_connect_b3_req_command (dword Id, PLCI *plci, byte Rc) -{ - word Info; - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: rtp_connect_b3_req_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - case RTP_CONNECT_B3_REQ_COMMAND_1: - if (plci_nl_busy (plci)) - { - plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_1; - return; - } - plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_2; - nl_req_ncci (plci, N_CONNECT, 0); - send_req (plci); - return; - case RTP_CONNECT_B3_REQ_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: RTP setting connect info failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - Info = _WRONG_STATE; - break; - } - if (plci_nl_busy (plci)) - { - plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_2; - return; - } - plci->internal_command = RTP_CONNECT_B3_REQ_COMMAND_3; - plci->NData[0].PLength = plci->internal_req_buffer[0]; - plci->NData[0].P = plci->internal_req_buffer + 1; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_UDATA; - plci->adapter->request (&plci->NL); - break; - case RTP_CONNECT_B3_REQ_COMMAND_3: - return; - } - sendf (plci->appl, _CONNECT_B3_R | CONFIRM, Id, plci->number, "w", Info); -} - - -static void rtp_connect_b3_res_command (dword Id, PLCI *plci, byte Rc) -{ - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: rtp_connect_b3_res_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - case RTP_CONNECT_B3_RES_COMMAND_1: - if (plci_nl_busy (plci)) - { - plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_1; - return; - } - plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_2; - nl_req_ncci (plci, N_CONNECT_ACK, (byte)(Id >> 16)); - send_req (plci); - return; - case RTP_CONNECT_B3_RES_COMMAND_2: - if ((Rc != OK) && (Rc != OK_FC)) - { - dbug (1, dprintf ("[%06lx] %s,%d: RTP setting connect resp info failed %02x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc)); - break; - } - if (plci_nl_busy (plci)) - { - plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_2; - return; - } - sendf (plci->appl, _CONNECT_B3_ACTIVE_I, Id, 0, "s", ""); - plci->internal_command = RTP_CONNECT_B3_RES_COMMAND_3; - plci->NData[0].PLength = plci->internal_req_buffer[0]; - plci->NData[0].P = plci->internal_req_buffer + 1; - plci->NL.X = plci->NData; - plci->NL.ReqCh = 0; - plci->NL.Req = plci->nl_req = (byte) N_UDATA; - plci->adapter->request (&plci->NL); - return; - case RTP_CONNECT_B3_RES_COMMAND_3: - return; - } -} - - - -static void hold_save_command (dword Id, PLCI *plci, byte Rc) -{ - byte SS_Ind[] = "\x05\x02\x00\x02\x00\x00"; /* Hold_Ind struct*/ - word Info; - word internal_command; + plci->B1_resource = 0; + plci->B1_facilities = 0; - dbug (1, dprintf ("[%06lx] %s,%d: hold_save_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); + plci->li_bchannel_id = 0; + mixer_clear_config(plci); - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - if (!plci->NL.Id) - break; - plci->command = 0; - plci->adjust_b_parms_msg = NULL; - plci->adjust_b_facilities = plci->B1_facilities; - plci->adjust_b_command = HOLD_SAVE_COMMAND_1; - plci->adjust_b_ncci = (word)(Id >> 16); - plci->adjust_b_mode = ADJUST_B_MODE_SAVE | ADJUST_B_MODE_REMOVE_L23; - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: HOLD save...", - UnMapId (Id), (char *)(FILE_), __LINE__)); - case HOLD_SAVE_COMMAND_1: - Info = adjust_b_process (Id, plci, Rc); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: HOLD save failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - } - sendf (plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", 3, SS_Ind); -} - - -static void retrieve_restore_command (dword Id, PLCI *plci, byte Rc) -{ - byte SS_Ind[] = "\x05\x03\x00\x02\x00\x00"; /* Retrieve_Ind struct*/ - word Info; - word internal_command; - - dbug (1, dprintf ("[%06lx] %s,%d: retrieve_restore_command %02x %04x", - UnMapId (Id), (char *)(FILE_), __LINE__, Rc, plci->internal_command)); - - Info = GOOD; - internal_command = plci->internal_command; - plci->internal_command = 0; - switch (internal_command) - { - default: - plci->command = 0; - plci->adjust_b_parms_msg = NULL; - plci->adjust_b_facilities = plci->B1_facilities; - plci->adjust_b_command = RETRIEVE_RESTORE_COMMAND_1; - plci->adjust_b_ncci = (word)(Id >> 16); - plci->adjust_b_mode = ADJUST_B_MODE_ASSIGN_L23 | ADJUST_B_MODE_USER_CONNECT | ADJUST_B_MODE_RESTORE; - plci->adjust_b_state = ADJUST_B_START; - dbug (1, dprintf ("[%06lx] %s,%d: RETRIEVE restore...", - UnMapId (Id), (char *)(FILE_), __LINE__)); - case RETRIEVE_RESTORE_COMMAND_1: - Info = adjust_b_process (Id, plci, Rc); - if (Info != GOOD) - { - dbug (1, dprintf ("[%06lx] %s,%d: RETRIEVE restore failed", - UnMapId (Id), (char *)(FILE_), __LINE__)); - break; - } - if (plci->internal_command) - return; - } - sendf (plci->appl, _FACILITY_I, Id & 0xffffL, 0, "ws", 3, SS_Ind); -} - - -static void init_b1_config (PLCI *plci) -{ - - dbug (1, dprintf ("[%06lx] %s,%d: init_b1_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); - - plci->B1_resource = 0; - plci->B1_facilities = 0; - plci->li_bchannel_id = 0; - mixer_clear_config (plci); + ec_clear_config(plci); - ec_clear_config (plci); + dtmf_rec_clear_config(plci); + dtmf_send_clear_config(plci); + dtmf_parameter_clear_config(plci); - - dtmf_rec_clear_config (plci); - dtmf_send_clear_config (plci); - dtmf_parameter_clear_config (plci); - - adv_voice_clear_config (plci); - adjust_b_clear (plci); + adv_voice_clear_config(plci); + adjust_b_clear(plci); } -static void clear_b1_config (PLCI *plci) +static void clear_b1_config(PLCI *plci) { - dbug (1, dprintf ("[%06lx] %s,%d: clear_b1_config", - (dword)((plci->Id << 8) | UnMapController (plci->adapter->Id)), - (char *)(FILE_), __LINE__)); + dbug(1, dprintf("[%06lx] %s,%d: clear_b1_config", + (dword)((plci->Id << 8) | UnMapController(plci->adapter->Id)), + (char *)(FILE_), __LINE__)); - adv_voice_clear_config (plci); - adjust_b_clear (plci); + adv_voice_clear_config(plci); + adjust_b_clear(plci); - ec_clear_config (plci); + ec_clear_config(plci); - dtmf_rec_clear_config (plci); - dtmf_send_clear_config (plci); - dtmf_parameter_clear_config (plci); + dtmf_rec_clear_config(plci); + dtmf_send_clear_config(plci); + dtmf_parameter_clear_config(plci); - if ((plci->li_bchannel_id != 0) - && (li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci == plci)) - { - mixer_clear_config (plci); - li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci = NULL; - plci->li_bchannel_id = 0; - } + if ((plci->li_bchannel_id != 0) + && (li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci == plci)) + { + mixer_clear_config(plci); + li_config_table[plci->adapter->li_base + (plci->li_bchannel_id - 1)].plci = NULL; + plci->li_bchannel_id = 0; + } - plci->B1_resource = 0; - plci->B1_facilities = 0; + plci->B1_resource = 0; + plci->B1_facilities = 0; } /* ----------------------------------------------------------------- - XON protocol local helpers + XON protocol local helpers ----------------------------------------------------------------- */ -static void channel_flow_control_remove (PLCI * plci) { - DIVA_CAPI_ADAPTER * a = plci->adapter; - word i; - for(i=1;ich_flow_plci[i] == plci->Id) { - a->ch_flow_plci[i] = 0; - a->ch_flow_control[i] = 0; - } - } -} - -static void channel_x_on (PLCI * plci, byte ch) { - DIVA_CAPI_ADAPTER * a = plci->adapter; - if (a->ch_flow_control[ch] & N_XON_SENT) { - a->ch_flow_control[ch] &= ~N_XON_SENT; - } -} - -static void channel_x_off (PLCI * plci, byte ch, byte flag) { - DIVA_CAPI_ADAPTER * a = plci->adapter; - if ((a->ch_flow_control[ch] & N_RX_FLOW_CONTROL_MASK) == 0) { - a->ch_flow_control[ch] |= (N_CH_XOFF | flag); - a->ch_flow_plci[ch] = plci->Id; - a->ch_flow_control_pending++; - } -} - -static void channel_request_xon (PLCI * plci, byte ch) { - DIVA_CAPI_ADAPTER * a = plci->adapter; - - if (a->ch_flow_control[ch] & N_CH_XOFF) { - a->ch_flow_control[ch] |= N_XON_REQ; - a->ch_flow_control[ch] &= ~N_CH_XOFF; - a->ch_flow_control[ch] &= ~N_XON_CONNECT_IND; - } -} - -static void channel_xmit_extended_xon (PLCI * plci) { - DIVA_CAPI_ADAPTER * a; - int max_ch = ARRAY_SIZE(a->ch_flow_control); - int i, one_requested = 0; - - if ((!plci) || (!plci->Id) || ((a = plci->adapter) == NULL)) { - return; - } - - for (i = 0; i < max_ch; i++) { - if ((a->ch_flow_control[i] & N_CH_XOFF) && - (a->ch_flow_control[i] & N_XON_CONNECT_IND) && - (plci->Id == a->ch_flow_plci[i])) { - channel_request_xon (plci, (byte)i); - one_requested = 1; - } - } - - if (one_requested) { - channel_xmit_xon (plci); - } +static void channel_flow_control_remove(PLCI *plci) { + DIVA_CAPI_ADAPTER *a = plci->adapter; + word i; + for (i = 1; i < MAX_NL_CHANNEL + 1; i++) { + if (a->ch_flow_plci[i] == plci->Id) { + a->ch_flow_plci[i] = 0; + a->ch_flow_control[i] = 0; + } + } +} + +static void channel_x_on(PLCI *plci, byte ch) { + DIVA_CAPI_ADAPTER *a = plci->adapter; + if (a->ch_flow_control[ch] & N_XON_SENT) { + a->ch_flow_control[ch] &= ~N_XON_SENT; + } +} + +static void channel_x_off(PLCI *plci, byte ch, byte flag) { + DIVA_CAPI_ADAPTER *a = plci->adapter; + if ((a->ch_flow_control[ch] & N_RX_FLOW_CONTROL_MASK) == 0) { + a->ch_flow_control[ch] |= (N_CH_XOFF | flag); + a->ch_flow_plci[ch] = plci->Id; + a->ch_flow_control_pending++; + } +} + +static void channel_request_xon(PLCI *plci, byte ch) { + DIVA_CAPI_ADAPTER *a = plci->adapter; + + if (a->ch_flow_control[ch] & N_CH_XOFF) { + a->ch_flow_control[ch] |= N_XON_REQ; + a->ch_flow_control[ch] &= ~N_CH_XOFF; + a->ch_flow_control[ch] &= ~N_XON_CONNECT_IND; + } +} + +static void channel_xmit_extended_xon(PLCI *plci) { + DIVA_CAPI_ADAPTER *a; + int max_ch = ARRAY_SIZE(a->ch_flow_control); + int i, one_requested = 0; + + if ((!plci) || (!plci->Id) || ((a = plci->adapter) == NULL)) { + return; + } + + for (i = 0; i < max_ch; i++) { + if ((a->ch_flow_control[i] & N_CH_XOFF) && + (a->ch_flow_control[i] & N_XON_CONNECT_IND) && + (plci->Id == a->ch_flow_plci[i])) { + channel_request_xon(plci, (byte)i); + one_requested = 1; + } + } + + if (one_requested) { + channel_xmit_xon(plci); + } } /* Try to xmit next X_ON - */ -static int find_channel_with_pending_x_on (DIVA_CAPI_ADAPTER * a, PLCI * plci) { - int max_ch = ARRAY_SIZE(a->ch_flow_control); - int i; - - if (!(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL)) { - return (0); - } - - if (a->last_flow_control_ch >= max_ch) { - a->last_flow_control_ch = 1; - } - for (i=a->last_flow_control_ch; i < max_ch; i++) { - if ((a->ch_flow_control[i] & N_XON_REQ) && - (plci->Id == a->ch_flow_plci[i])) { - a->last_flow_control_ch = i+1; - return (i); - } - } - - for (i = 1; i < a->last_flow_control_ch; i++) { - if ((a->ch_flow_control[i] & N_XON_REQ) && - (plci->Id == a->ch_flow_plci[i])) { - a->last_flow_control_ch = i+1; - return (i); - } - } - - return (0); -} - -static void channel_xmit_xon (PLCI * plci) { - DIVA_CAPI_ADAPTER * a = plci->adapter; - byte ch; - - if (plci->nl_req || !plci->NL.Id || plci->nl_remove_id) { - return; - } - if ((ch = (byte)find_channel_with_pending_x_on (a, plci)) == 0) { - return; - } - a->ch_flow_control[ch] &= ~N_XON_REQ; - a->ch_flow_control[ch] |= N_XON_SENT; - - plci->NL.Req = plci->nl_req = (byte)N_XON; - plci->NL.ReqCh = ch; - plci->NL.X = plci->NData; - plci->NL.XNum = 1; - plci->NData[0].P = &plci->RBuffer[0]; - plci->NData[0].PLength = 0; - - plci->adapter->request(&plci->NL); -} - -static int channel_can_xon (PLCI * plci, byte ch) { - APPL * APPLptr; - DIVA_CAPI_ADAPTER * a; - word NCCIcode; - dword count; - word Num; - word i; - - APPLptr = plci->appl; - a = plci->adapter; - - if (!APPLptr) - return (0); - - NCCIcode = a->ch_ncci[ch] | (((word) a->Id) << 8); - - /* count all buffers within the Application pool */ - /* belonging to the same NCCI. XON if a first is */ - /* used. */ - count = 0; - Num = 0xffff; - for(i=0; iMaxBuffer; i++) { - if(NCCIcode==APPLptr->DataNCCI[i]) count++; - if(!APPLptr->DataNCCI[i] && Num==0xffff) Num = i; - } - if ((count > 2) || (Num == 0xffff)) { - return (0); - } - return (1); +*/ +static int find_channel_with_pending_x_on(DIVA_CAPI_ADAPTER *a, PLCI *plci) { + int max_ch = ARRAY_SIZE(a->ch_flow_control); + int i; + + if (!(plci->adapter->manufacturer_features & MANUFACTURER_FEATURE_XONOFF_FLOW_CONTROL)) { + return (0); + } + + if (a->last_flow_control_ch >= max_ch) { + a->last_flow_control_ch = 1; + } + for (i = a->last_flow_control_ch; i < max_ch; i++) { + if ((a->ch_flow_control[i] & N_XON_REQ) && + (plci->Id == a->ch_flow_plci[i])) { + a->last_flow_control_ch = i + 1; + return (i); + } + } + + for (i = 1; i < a->last_flow_control_ch; i++) { + if ((a->ch_flow_control[i] & N_XON_REQ) && + (plci->Id == a->ch_flow_plci[i])) { + a->last_flow_control_ch = i + 1; + return (i); + } + } + + return (0); +} + +static void channel_xmit_xon(PLCI *plci) { + DIVA_CAPI_ADAPTER *a = plci->adapter; + byte ch; + + if (plci->nl_req || !plci->NL.Id || plci->nl_remove_id) { + return; + } + if ((ch = (byte)find_channel_with_pending_x_on(a, plci)) == 0) { + return; + } + a->ch_flow_control[ch] &= ~N_XON_REQ; + a->ch_flow_control[ch] |= N_XON_SENT; + + plci->NL.Req = plci->nl_req = (byte)N_XON; + plci->NL.ReqCh = ch; + plci->NL.X = plci->NData; + plci->NL.XNum = 1; + plci->NData[0].P = &plci->RBuffer[0]; + plci->NData[0].PLength = 0; + + plci->adapter->request(&plci->NL); +} + +static int channel_can_xon(PLCI *plci, byte ch) { + APPL *APPLptr; + DIVA_CAPI_ADAPTER *a; + word NCCIcode; + dword count; + word Num; + word i; + + APPLptr = plci->appl; + a = plci->adapter; + + if (!APPLptr) + return (0); + + NCCIcode = a->ch_ncci[ch] | (((word) a->Id) << 8); + + /* count all buffers within the Application pool */ + /* belonging to the same NCCI. XON if a first is */ + /* used. */ + count = 0; + Num = 0xffff; + for (i = 0; i < APPLptr->MaxBuffer; i++) { + if (NCCIcode == APPLptr->DataNCCI[i]) count++; + if (!APPLptr->DataNCCI[i] && Num == 0xffff) Num = i; + } + if ((count > 2) || (Num == 0xffff)) { + return (0); + } + return (1); } /*------------------------------------------------------------------*/ -static word CPN_filter_ok(byte *cpn,DIVA_CAPI_ADAPTER * a,word offset) +static word CPN_filter_ok(byte *cpn, DIVA_CAPI_ADAPTER *a, word offset) { - return 1; + return 1; } @@ -14733,116 +14733,116 @@ static word CPN_filter_ok(byte *cpn,DIVA_CAPI_ADAPTER * a,word offset) /* function must be enabled by setting "a->group_optimization_enabled" from the */ /* OS specific part (per adapter). */ /**********************************************************************************/ -static void group_optimization(DIVA_CAPI_ADAPTER * a, PLCI * plci) -{ - word i,j,k,busy,group_found; - dword info_mask_group[MAX_CIP_TYPES]; - dword cip_mask_group[MAX_CIP_TYPES]; - word appl_number_group_type[MAX_APPL]; - PLCI *auxplci; - - set_group_ind_mask (plci); /* all APPLs within this inc. call are allowed to dial in */ - - if(!a->group_optimization_enabled) - { - dbug(1,dprintf("No group optimization")); - return; - } - - dbug(1,dprintf("Group optimization = 0x%x...", a->group_optimization_enabled)); - - for(i=0;i 1 && (a->CIP_Mask[i]) && (a->group_optimization_enabled ==1) ) - { - dbug(1,dprintf("Multi-Instance capable, no optimization required")); - return; /* allow good application unfiltered access */ - } - } - for(i=0; iCIP_Mask[i] ) - { - for(k=0,busy=false; kmax_plci; k++) - { - if(a->plci[k].Id) - { - auxplci = &a->plci[k]; - if(auxplci->appl == &application[i]) /* application has a busy PLCI */ - { - busy = true; - dbug(1,dprintf("Appl 0x%x is busy",i+1)); - } - else if(test_c_ind_mask_bit (auxplci, i)) /* application has an incoming call pending */ - { - busy = true; - dbug(1,dprintf("Appl 0x%x has inc. call pending",i+1)); - } - } - } - - for(j=0,group_found=0; j<=(MAX_CIP_TYPES) && !busy &&!group_found; j++) /* build groups with free applications only */ - { - if(j==MAX_CIP_TYPES) /* all groups are in use but group still not found */ - { /* the MAX_CIP_TYPES group enables all calls because of field overflow */ - appl_number_group_type[i] = MAX_CIP_TYPES; - group_found=true; - dbug(1,dprintf("Field overflow appl 0x%x",i+1)); - } - else if( (info_mask_group[j]==a->CIP_Mask[i]) && (cip_mask_group[j]==a->Info_Mask[i]) ) - { /* is group already present ? */ - appl_number_group_type[i] = j|0x80; /* store the group number for each application */ - group_found=true; - dbug(1,dprintf("Group 0x%x found with appl 0x%x, CIP=0x%lx",appl_number_group_type[i],i+1,info_mask_group[j])); - } - else if(!info_mask_group[j]) - { /* establish a new group */ - appl_number_group_type[i] = j|0x80; /* store the group number for each application */ - info_mask_group[j] = a->CIP_Mask[i]; /* store the new CIP mask for the new group */ - cip_mask_group[j] = a->Info_Mask[i]; /* store the new Info_Mask for this new group */ - group_found=true; - dbug(1,dprintf("New Group 0x%x established with appl 0x%x, CIP=0x%lx",appl_number_group_type[i],i+1,info_mask_group[j])); - } - } - } - } - - for(i=0; igroup_optimization_enabled) + { + dbug(1, dprintf("No group optimization")); + return; + } + + dbug(1, dprintf("Group optimization = 0x%x...", a->group_optimization_enabled)); + + for (i = 0; i < MAX_CIP_TYPES; i++) + { + info_mask_group[i] = 0; + cip_mask_group[i] = 0; + } + for (i = 0; i < MAX_APPL; i++) + { + appl_number_group_type[i] = 0; + } + for (i = 0; i < max_appl; i++) /* check if any multi instance capable application is present */ + { /* group_optimization set to 1 means not to optimize multi-instance capable applications (default) */ + if (application[i].Id && (application[i].MaxNCCI) > 1 && (a->CIP_Mask[i]) && (a->group_optimization_enabled == 1)) + { + dbug(1, dprintf("Multi-Instance capable, no optimization required")); + return; /* allow good application unfiltered access */ + } + } + for (i = 0; i < max_appl; i++) /* Build CIP Groups */ + { + if (application[i].Id && a->CIP_Mask[i]) + { + for (k = 0, busy = false; k < a->max_plci; k++) + { + if (a->plci[k].Id) + { + auxplci = &a->plci[k]; + if (auxplci->appl == &application[i]) /* application has a busy PLCI */ + { + busy = true; + dbug(1, dprintf("Appl 0x%x is busy", i + 1)); + } + else if (test_c_ind_mask_bit(auxplci, i)) /* application has an incoming call pending */ + { + busy = true; + dbug(1, dprintf("Appl 0x%x has inc. call pending", i + 1)); + } + } + } + + for (j = 0, group_found = 0; j <= (MAX_CIP_TYPES) && !busy && !group_found; j++) /* build groups with free applications only */ + { + if (j == MAX_CIP_TYPES) /* all groups are in use but group still not found */ + { /* the MAX_CIP_TYPES group enables all calls because of field overflow */ + appl_number_group_type[i] = MAX_CIP_TYPES; + group_found = true; + dbug(1, dprintf("Field overflow appl 0x%x", i + 1)); + } + else if ((info_mask_group[j] == a->CIP_Mask[i]) && (cip_mask_group[j] == a->Info_Mask[i])) + { /* is group already present ? */ + appl_number_group_type[i] = j | 0x80; /* store the group number for each application */ + group_found = true; + dbug(1, dprintf("Group 0x%x found with appl 0x%x, CIP=0x%lx", appl_number_group_type[i], i + 1, info_mask_group[j])); + } + else if (!info_mask_group[j]) + { /* establish a new group */ + appl_number_group_type[i] = j | 0x80; /* store the group number for each application */ + info_mask_group[j] = a->CIP_Mask[i]; /* store the new CIP mask for the new group */ + cip_mask_group[j] = a->Info_Mask[i]; /* store the new Info_Mask for this new group */ + group_found = true; + dbug(1, dprintf("New Group 0x%x established with appl 0x%x, CIP=0x%lx", appl_number_group_type[i], i + 1, info_mask_group[j])); + } + } + } + } + + for (i = 0; i < max_appl; i++) /* Build group_optimization_mask_table */ + { + if (appl_number_group_type[i]) /* application is free, has listens and is member of a group */ + { + if (appl_number_group_type[i] == MAX_CIP_TYPES) + { + dbug(1, dprintf("OverflowGroup 0x%x, valid appl = 0x%x, call enabled", appl_number_group_type[i], i + 1)); + } + else + { + dbug(1, dprintf("Group 0x%x, valid appl = 0x%x", appl_number_group_type[i], i + 1)); + for (j = i + 1; j < max_appl; j++) /* search other group members and mark them as busy */ + { + if (appl_number_group_type[i] == appl_number_group_type[j]) + { + dbug(1, dprintf("Appl 0x%x is member of group 0x%x, no call", j + 1, appl_number_group_type[j])); + clear_group_ind_mask_bit(plci, j); /* disable call on other group members */ + appl_number_group_type[j] = 0; /* remove disabled group member from group list */ + } + } + } + } + else /* application should not get a call */ + { + clear_group_ind_mask_bit(plci, i); + } + } } @@ -14851,201 +14851,201 @@ static void group_optimization(DIVA_CAPI_ADAPTER * a, PLCI * plci) /* OS notifies the driver about a application Capi_Register */ word CapiRegister(word id) { - word i,j,appls_found; - - PLCI *plci; - DIVA_CAPI_ADAPTER *a; - - for(i=0,appls_found=0; irequest) - { - if(a->flag_dynamic_l1_down) /* remove adapter from L1 tristate (Huntgroup) */ - { - if(!appls_found) /* first application does a capi register */ - { - if((j=get_plci(a))) /* activate L1 of all adapters */ - { - plci = &a->plci[j-1]; - plci->command = 0; - add_p(plci,OAD,"\x01\xfd"); - add_p(plci,CAI,"\x01\x80"); - add_p(plci,UID,"\x06\x43\x61\x70\x69\x32\x30"); - add_p(plci,SHIFT|6,NULL); - add_p(plci,SIN,"\x02\x00\x00"); - plci->internal_command = START_L1_SIG_ASSIGN_PEND; - sig_req(plci,ASSIGN,DSIG_ID); - add_p(plci,FTY,"\x02\xff\x07"); /* l1 start */ - sig_req(plci,SIG_CTRL,0); - send_req(plci); - } - } - } - } - } - return false; + word i, j, appls_found; + + PLCI *plci; + DIVA_CAPI_ADAPTER *a; + + for (i = 0, appls_found = 0; i < max_appl; i++) + { + if (application[i].Id && (application[i].Id != id)) + { + appls_found++; /* an application has been found */ + } + } + + if (appls_found) return true; + for (i = 0; i < max_adapter; i++) /* scan all adapters... */ + { + a = &adapter[i]; + if (a->request) + { + if (a->flag_dynamic_l1_down) /* remove adapter from L1 tristate (Huntgroup) */ + { + if (!appls_found) /* first application does a capi register */ + { + if ((j = get_plci(a))) /* activate L1 of all adapters */ + { + plci = &a->plci[j - 1]; + plci->command = 0; + add_p(plci, OAD, "\x01\xfd"); + add_p(plci, CAI, "\x01\x80"); + add_p(plci, UID, "\x06\x43\x61\x70\x69\x32\x30"); + add_p(plci, SHIFT | 6, NULL); + add_p(plci, SIN, "\x02\x00\x00"); + plci->internal_command = START_L1_SIG_ASSIGN_PEND; + sig_req(plci, ASSIGN, DSIG_ID); + add_p(plci, FTY, "\x02\xff\x07"); /* l1 start */ + sig_req(plci, SIG_CTRL, 0); + send_req(plci); + } + } + } + } + } + return false; } /*------------------------------------------------------------------*/ /* Functions for virtual Switching e.g. Transfer by join, Conference */ -static void VSwitchReqInd(PLCI *plci, dword Id, byte **parms) -{ - word i; - /* Format of vswitch_t: - 0 byte length - 1 byte VSWITCHIE - 2 byte VSWITCH_REQ/VSWITCH_IND - 3 byte reserved - 4 word VSwitchcommand - 6 word returnerror - 8... Params - */ - if(!plci || - !plci->appl || - !plci->State || - plci->Sig.Ind==NCR_FACILITY - ) - return; - - for(i=0;irelatedPTYPLCI || - (plci->ptyState!=S_ECT && plci->relatedPTYPLCI->ptyState!=S_ECT)) - { /* Error */ - break; - } - /* remember all necessary informations */ - if(parms[i][0]!=11 || parms[i][8]!=3) /* Length Test */ - { - break; - } - if(parms[i][2]==VSWITCH_IND && parms[i][9]==1) - { /* first indication after ECT-Request on Consultation Call */ - plci->vswitchstate=parms[i][9]; - parms[i][9]=2; /* State */ - /* now ask first Call to join */ - } - else if(parms[i][2]==VSWITCH_REQ && parms[i][9]==3) - { /* Answer of VSWITCH_REQ from first Call */ - plci->vswitchstate=parms[i][9]; - /* tell consultation call to join - and the protocol capabilities of the first call */ - } - else - { /* Error */ - break; - } - plci->vsprot=parms[i][10]; /* protocol */ - plci->vsprotdialect=parms[i][11]; /* protocoldialect */ - /* send join request to related PLCI */ - parms[i][1]=VSWITCHIE; - parms[i][2]=VSWITCH_REQ; - - plci->relatedPTYPLCI->command = 0; - plci->relatedPTYPLCI->internal_command = VSWITCH_REQ_PEND; - add_p(plci->relatedPTYPLCI,ESC,&parms[i][0]); - sig_req(plci->relatedPTYPLCI,VSWITCH_REQ,0); - send_req(plci->relatedPTYPLCI); - break; - case VSTRANSPORT: - default: - if(plci->relatedPTYPLCI && - plci->vswitchstate==3 && - plci->relatedPTYPLCI->vswitchstate==3) - { - add_p(plci->relatedPTYPLCI,ESC,&parms[i][0]); - sig_req(plci->relatedPTYPLCI,VSWITCH_REQ,0); - send_req(plci->relatedPTYPLCI); - } - break; - } - parms[i][0]=0; /* kill it */ - } +static void VSwitchReqInd(PLCI *plci, dword Id, byte **parms) +{ + word i; + /* Format of vswitch_t: + 0 byte length + 1 byte VSWITCHIE + 2 byte VSWITCH_REQ/VSWITCH_IND + 3 byte reserved + 4 word VSwitchcommand + 6 word returnerror + 8... Params + */ + if (!plci || + !plci->appl || + !plci->State || + plci->Sig.Ind == NCR_FACILITY + ) + return; + + for (i = 0; i < MAX_MULTI_IE; i++) + { + if (!parms[i][0]) continue; + if (parms[i][0] < 7) + { + parms[i][0] = 0; /* kill it */ + continue; + } + dbug(1, dprintf("VSwitchReqInd(%d)", parms[i][4])); + switch (parms[i][4]) + { + case VSJOIN: + if (!plci->relatedPTYPLCI || + (plci->ptyState != S_ECT && plci->relatedPTYPLCI->ptyState != S_ECT)) + { /* Error */ + break; + } + /* remember all necessary informations */ + if (parms[i][0] != 11 || parms[i][8] != 3) /* Length Test */ + { + break; + } + if (parms[i][2] == VSWITCH_IND && parms[i][9] == 1) + { /* first indication after ECT-Request on Consultation Call */ + plci->vswitchstate = parms[i][9]; + parms[i][9] = 2; /* State */ + /* now ask first Call to join */ + } + else if (parms[i][2] == VSWITCH_REQ && parms[i][9] == 3) + { /* Answer of VSWITCH_REQ from first Call */ + plci->vswitchstate = parms[i][9]; + /* tell consultation call to join + and the protocol capabilities of the first call */ + } + else + { /* Error */ + break; + } + plci->vsprot = parms[i][10]; /* protocol */ + plci->vsprotdialect = parms[i][11]; /* protocoldialect */ + /* send join request to related PLCI */ + parms[i][1] = VSWITCHIE; + parms[i][2] = VSWITCH_REQ; + + plci->relatedPTYPLCI->command = 0; + plci->relatedPTYPLCI->internal_command = VSWITCH_REQ_PEND; + add_p(plci->relatedPTYPLCI, ESC, &parms[i][0]); + sig_req(plci->relatedPTYPLCI, VSWITCH_REQ, 0); + send_req(plci->relatedPTYPLCI); + break; + case VSTRANSPORT: + default: + if (plci->relatedPTYPLCI && + plci->vswitchstate == 3 && + plci->relatedPTYPLCI->vswitchstate == 3) + { + add_p(plci->relatedPTYPLCI, ESC, &parms[i][0]); + sig_req(plci->relatedPTYPLCI, VSWITCH_REQ, 0); + send_req(plci->relatedPTYPLCI); + } + break; + } + parms[i][0] = 0; /* kill it */ + } } /*------------------------------------------------------------------*/ -static int diva_get_dma_descriptor (PLCI *plci, dword *dma_magic) { - ENTITY e; - IDI_SYNC_REQ* pReq = (IDI_SYNC_REQ*)&e; - - if (!(diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_RX_DMA)) { - return (-1); - } - - pReq->xdi_dma_descriptor_operation.Req = 0; - pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; - - pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC; - pReq->xdi_dma_descriptor_operation.info.descriptor_number = -1; - pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; - pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; - - e.user[0] = plci->adapter->Id - 1; - plci->adapter->request((ENTITY*)pReq); - - if (!pReq->xdi_dma_descriptor_operation.info.operation && - (pReq->xdi_dma_descriptor_operation.info.descriptor_number >= 0) && - pReq->xdi_dma_descriptor_operation.info.descriptor_magic) { - *dma_magic = pReq->xdi_dma_descriptor_operation.info.descriptor_magic; - dbug(3,dprintf("dma_alloc, a:%d (%d-%08x)", - plci->adapter->Id, - pReq->xdi_dma_descriptor_operation.info.descriptor_number, - *dma_magic)); - return (pReq->xdi_dma_descriptor_operation.info.descriptor_number); - } else { - dbug(1,dprintf("dma_alloc failed")); - return (-1); - } -} - -static void diva_free_dma_descriptor (PLCI *plci, int nr) { - ENTITY e; - IDI_SYNC_REQ* pReq = (IDI_SYNC_REQ*)&e; - - if (nr < 0) { - return; - } - - pReq->xdi_dma_descriptor_operation.Req = 0; - pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; - - pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE; - pReq->xdi_dma_descriptor_operation.info.descriptor_number = nr; - pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; - pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; - - e.user[0] = plci->adapter->Id - 1; - plci->adapter->request((ENTITY*)pReq); - - if (!pReq->xdi_dma_descriptor_operation.info.operation) { - dbug(1,dprintf("dma_free(%d)", nr)); - } else { - dbug(1,dprintf("dma_free failed (%d)", nr)); - } +static int diva_get_dma_descriptor(PLCI *plci, dword *dma_magic) { + ENTITY e; + IDI_SYNC_REQ *pReq = (IDI_SYNC_REQ *)&e; + + if (!(diva_xdi_extended_features & DIVA_CAPI_XDI_PROVIDES_RX_DMA)) { + return (-1); + } + + pReq->xdi_dma_descriptor_operation.Req = 0; + pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; + + pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_ALLOC; + pReq->xdi_dma_descriptor_operation.info.descriptor_number = -1; + pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; + pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; + + e.user[0] = plci->adapter->Id - 1; + plci->adapter->request((ENTITY *)pReq); + + if (!pReq->xdi_dma_descriptor_operation.info.operation && + (pReq->xdi_dma_descriptor_operation.info.descriptor_number >= 0) && + pReq->xdi_dma_descriptor_operation.info.descriptor_magic) { + *dma_magic = pReq->xdi_dma_descriptor_operation.info.descriptor_magic; + dbug(3, dprintf("dma_alloc, a:%d (%d-%08x)", + plci->adapter->Id, + pReq->xdi_dma_descriptor_operation.info.descriptor_number, + *dma_magic)); + return (pReq->xdi_dma_descriptor_operation.info.descriptor_number); + } else { + dbug(1, dprintf("dma_alloc failed")); + return (-1); + } +} + +static void diva_free_dma_descriptor(PLCI *plci, int nr) { + ENTITY e; + IDI_SYNC_REQ *pReq = (IDI_SYNC_REQ *)&e; + + if (nr < 0) { + return; + } + + pReq->xdi_dma_descriptor_operation.Req = 0; + pReq->xdi_dma_descriptor_operation.Rc = IDI_SYNC_REQ_DMA_DESCRIPTOR_OPERATION; + + pReq->xdi_dma_descriptor_operation.info.operation = IDI_SYNC_REQ_DMA_DESCRIPTOR_FREE; + pReq->xdi_dma_descriptor_operation.info.descriptor_number = nr; + pReq->xdi_dma_descriptor_operation.info.descriptor_address = NULL; + pReq->xdi_dma_descriptor_operation.info.descriptor_magic = 0; + + e.user[0] = plci->adapter->Id - 1; + plci->adapter->request((ENTITY *)pReq); + + if (!pReq->xdi_dma_descriptor_operation.info.operation) { + dbug(1, dprintf("dma_free(%d)", nr)); + } else { + dbug(1, dprintf("dma_free failed (%d)", nr)); + } } /*------------------------------------------------------------------*/ diff --git a/drivers/isdn/hardware/eicon/mi_pc.h b/drivers/isdn/hardware/eicon/mi_pc.h index a861dac1f784..83e9ed8c1bf3 100644 --- a/drivers/isdn/hardware/eicon/mi_pc.h +++ b/drivers/isdn/hardware/eicon/mi_pc.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /*---------------------------------------------------------------------------- @@ -68,30 +68,30 @@ /* CPU exception context structure in MP shared ram after trap */ typedef struct mp_xcptcontext_s MP_XCPTC; struct mp_xcptcontext_s { - dword sr; - dword cr; - dword epc; - dword vaddr; - dword regs[32]; - dword mdlo; - dword mdhi; - dword reseverd; - dword xclass; + dword sr; + dword cr; + dword epc; + dword vaddr; + dword regs[32]; + dword mdlo; + dword mdhi; + dword reseverd; + dword xclass; }; /* boot interface structure for PRI */ struct mp_load { - dword volatile cmd; - dword volatile addr; - dword volatile len; - dword volatile err; - dword volatile live; - dword volatile res1[0x1b]; - dword volatile TrapId; /* has value 0x999999XX on a CPU trap */ - dword volatile res2[0x03]; - MP_XCPTC volatile xcpt; /* contains register dump */ - dword volatile rest[((0x1020>>2)-6) - 0x1b - 1 - 0x03 - (sizeof(MP_XCPTC)>>2)]; - dword volatile signature; - dword data[60000]; /* real interface description */ + dword volatile cmd; + dword volatile addr; + dword volatile len; + dword volatile err; + dword volatile live; + dword volatile res1[0x1b]; + dword volatile TrapId; /* has value 0x999999XX on a CPU trap */ + dword volatile res2[0x03]; + MP_XCPTC volatile xcpt; /* contains register dump */ + dword volatile rest[((0x1020 >> 2) - 6) - 0x1b - 1 - 0x03 - (sizeof(MP_XCPTC) >> 2)]; + dword volatile signature; + dword data[60000]; /* real interface description */ }; /*----------------------------------------------------------------------------*/ /* SERVER 4BRI (Quattro PCI) */ @@ -150,11 +150,11 @@ struct mp_load { #define CS_BASEREG 0x0018 #define BOOT_BASEREG 0x001c #define GTREGS_BASEREG 0x0024 /*GTRegsBase reg-contain the base addr where*/ - /*the GT64010 internal regs where mapped */ + /*the GT64010 internal regs where mapped */ /* * GT64010 internal registers */ - /* DRAM device coding */ +/* DRAM device coding */ #define LOW_RAS0_DREG 0x0400 /*Ras0 low decode address*/ #define HI_RAS0_DREG 0x0404 /*Ras0 high decode address*/ #define LOW_RAS1_DREG 0x0408 /*Ras1 low decode address*/ @@ -163,7 +163,7 @@ struct mp_load { #define HI_RAS2_DREG 0x0414 /*Ras2 high decode address*/ #define LOW_RAS3_DREG 0x0418 /*Ras3 low decode address*/ #define HI_RAS3_DREG 0x041c /*Ras3 high decode address*/ - /* I/O CS device coding */ +/* I/O CS device coding */ #define LOW_CS0_DREG 0x0420 /* CS0* low decode register */ #define HI_CS0_DREG 0x0424 /* CS0* high decode register */ #define LOW_CS1_DREG 0x0428 /* CS1* low decode register */ @@ -172,20 +172,20 @@ struct mp_load { #define HI_CS2_DREG 0x0434 /* CS2* high decode register */ #define LOW_CS3_DREG 0x0438 /* CS3* low decode register */ #define HI_CS3_DREG 0x043c /* CS3* high decode register */ - /* Boot PROM device coding */ +/* Boot PROM device coding */ #define LOW_BOOTCS_DREG 0x0440 /* Boot CS low decode register */ #define HI_BOOTCS_DREG 0x0444 /* Boot CS High decode register */ - /* DRAM group coding (for CPU) */ +/* DRAM group coding (for CPU) */ #define LO_RAS10_GREG 0x0008 /*Ras1..0 group low decode address*/ #define HI_RAS10_GREG 0x0010 /*Ras1..0 group high decode address*/ #define LO_RAS32_GREG 0x0018 /*Ras3..2 group low decode address */ #define HI_RAS32_GREG 0x0020 /*Ras3..2 group high decode address */ - /* I/O CS group coding for (CPU) */ +/* I/O CS group coding for (CPU) */ #define LO_CS20_GREG 0x0028 /* CS2..0 group low decode register */ #define HI_CS20_GREG 0x0030 /* CS2..0 group high decode register */ #define LO_CS3B_GREG 0x0038 /* CS3 & PROM group low decode register */ #define HI_CS3B_GREG 0x0040 /* CS3 & PROM group high decode register */ - /* Galileo specific PCI config. */ +/* Galileo specific PCI config. */ #define PCI_TIMEOUT_RET 0x0c04 /* Time Out and retry register */ #define RAS10_BANKSIZE 0x0c08 /* RAS 1..0 group PCI bank size */ #define RAS32_BANKSIZE 0x0c0c /* RAS 3..2 group PCI bank size */ diff --git a/drivers/isdn/hardware/eicon/mntfunc.c b/drivers/isdn/hardware/eicon/mntfunc.c index a564b7560031..d6072607305c 100644 --- a/drivers/isdn/hardware/eicon/mntfunc.c +++ b/drivers/isdn/hardware/eicon/mntfunc.c @@ -27,7 +27,7 @@ static dword notify_handle; static DESCRIPTOR DAdapter; static DESCRIPTOR MAdapter; static DESCRIPTOR MaintDescriptor = - { IDI_DIMAINT, 0, 0, (IDI_CALL) diva_maint_prtComp }; +{ IDI_DIMAINT, 0, 0, (IDI_CALL) diva_maint_prtComp }; extern int diva_os_copy_to_user(void *os_handle, void __user *dst, const void *src, int length); @@ -44,7 +44,7 @@ static void no_printf(unsigned char *x, ...) /* * DIDD callback function */ -static void *didd_callback(void *context, DESCRIPTOR * adapter, +static void *didd_callback(void *context, DESCRIPTOR *adapter, int removal) { if (adapter->type == IDI_DADAPTER) { @@ -87,20 +87,20 @@ static int DIVA_INIT_FUNCTION connect_didd(void) memcpy(&DAdapter, &DIDD_Table[x], sizeof(DAdapter)); req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = - IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; + IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; req.didd_notify.info.callback = (void *)didd_callback; req.didd_notify.info.context = NULL; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); if (req.didd_notify.e.Rc != 0xff) return (0); notify_handle = req.didd_notify.info.handle; /* Register MAINT (me) */ req.didd_add_adapter.e.Req = 0; req.didd_add_adapter.e.Rc = - IDI_SYNC_REQ_DIDD_ADD_ADAPTER; + IDI_SYNC_REQ_DIDD_ADD_ADAPTER; req.didd_add_adapter.info.descriptor = - (void *) &MaintDescriptor; - DAdapter.request((ENTITY *) & req); + (void *) &MaintDescriptor; + DAdapter.request((ENTITY *)&req); if (req.didd_add_adapter.e.Rc != 0xff) return (0); } else if ((DIDD_Table[x].type > 0) @@ -121,13 +121,13 @@ static void DIVA_EXIT_FUNCTION disconnect_didd(void) req.didd_notify.e.Req = 0; req.didd_notify.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY; req.didd_notify.info.handle = notify_handle; - DAdapter.request((ENTITY *) & req); + DAdapter.request((ENTITY *)&req); req.didd_remove_adapter.e.Req = 0; req.didd_remove_adapter.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER; req.didd_remove_adapter.info.p_request = - (IDI_CALL) MaintDescriptor.request; - DAdapter.request((ENTITY *) & req); + (IDI_CALL) MaintDescriptor.request; + DAdapter.request((ENTITY *)&req); } /* @@ -147,9 +147,9 @@ int maint_read_write(void __user *buf, int count) return (-EFAULT); } - cmd = *(dword *) & data[0]; /* command */ - id = *(dword *) & data[4]; /* driver id */ - mask = *(dword *) & data[8]; /* mask or size */ + cmd = *(dword *)&data[0]; /* command */ + id = *(dword *)&data[4]; /* driver id */ + mask = *(dword *)&data[8]; /* mask or size */ switch (cmd) { case DITRACE_CMD_GET_DRIVER_INFO: @@ -178,19 +178,19 @@ int maint_read_write(void __user *buf, int count) } break; - /* - Filter commands will ignore the ID due to fact that filtering affects - the B- channel and Audio Tap trace levels only. Also MAINT driver will - select the right trace ID by itself - */ + /* + Filter commands will ignore the ID due to fact that filtering affects + the B- channel and Audio Tap trace levels only. Also MAINT driver will + select the right trace ID by itself + */ case DITRACE_WRITE_SELECTIVE_TRACE_FILTER: if (!mask) { - ret = diva_set_trace_filter (1, "*"); + ret = diva_set_trace_filter(1, "*"); } else if (mask < sizeof(data)) { - if (diva_os_copy_from_user(NULL, data, (char __user *)buf+12, mask)) { + if (diva_os_copy_from_user(NULL, data, (char __user *)buf + 12, mask)) { ret = -EFAULT; } else { - ret = diva_set_trace_filter ((int)mask, data); + ret = diva_set_trace_filter((int)mask, data); } } else { ret = -EINVAL; @@ -198,8 +198,8 @@ int maint_read_write(void __user *buf, int count) break; case DITRACE_READ_SELECTIVE_TRACE_FILTER: - if ((ret = diva_get_trace_filter (sizeof(data), data)) > 0) { - if (diva_os_copy_to_user (NULL, buf, data, ret)) + if ((ret = diva_get_trace_filter(sizeof(data), data)) > 0) { + if (diva_os_copy_to_user(NULL, buf, data, ret)) ret = -EFAULT; } else { ret = -ENODEV; @@ -207,88 +207,88 @@ int maint_read_write(void __user *buf, int count) break; case DITRACE_READ_TRACE_ENTRY:{ - diva_os_spin_lock_magic_t old_irql; - word size; - diva_dbg_entry_head_t *pmsg; - byte *pbuf; + diva_os_spin_lock_magic_t old_irql; + word size; + diva_dbg_entry_head_t *pmsg; + byte *pbuf; - if (!(pbuf = diva_os_malloc(0, mask))) { - return (-ENOMEM); - } + if (!(pbuf = diva_os_malloc(0, mask))) { + return (-ENOMEM); + } - for(;;) { - if (!(pmsg = - diva_maint_get_message(&size, &old_irql))) { - break; - } - if (size > mask) { - diva_maint_ack_message(0, &old_irql); - ret = -EINVAL; - break; - } - ret = size; - memcpy(pbuf, pmsg, size); - diva_maint_ack_message(1, &old_irql); - if ((count < size) || - diva_os_copy_to_user (NULL, buf, (void *) pbuf, size)) - ret = -EFAULT; + for (;;) { + if (!(pmsg = + diva_maint_get_message(&size, &old_irql))) { + break; + } + if (size > mask) { + diva_maint_ack_message(0, &old_irql); + ret = -EINVAL; break; } - diva_os_free(0, pbuf); + ret = size; + memcpy(pbuf, pmsg, size); + diva_maint_ack_message(1, &old_irql); + if ((count < size) || + diva_os_copy_to_user(NULL, buf, (void *) pbuf, size)) + ret = -EFAULT; + break; } + diva_os_free(0, pbuf); + } break; case DITRACE_READ_TRACE_ENTRYS:{ - diva_os_spin_lock_magic_t old_irql; - word size; - diva_dbg_entry_head_t *pmsg; - byte *pbuf = NULL; - int written = 0; + diva_os_spin_lock_magic_t old_irql; + word size; + diva_dbg_entry_head_t *pmsg; + byte *pbuf = NULL; + int written = 0; - if (mask < 4096) { - ret = -EINVAL; + if (mask < 4096) { + ret = -EINVAL; + break; + } + if (!(pbuf = diva_os_malloc(0, mask))) { + return (-ENOMEM); + } + + for (;;) { + if (!(pmsg = + diva_maint_get_message(&size, &old_irql))) { break; } - if (!(pbuf = diva_os_malloc(0, mask))) { - return (-ENOMEM); - } - - for (;;) { - if (!(pmsg = - diva_maint_get_message(&size, &old_irql))) { - break; - } - if ((size + 8) > mask) { - diva_maint_ack_message(0, &old_irql); - break; - } - /* - Write entry length - */ - pbuf[written++] = (byte) size; - pbuf[written++] = (byte) (size >> 8); - pbuf[written++] = 0; - pbuf[written++] = 0; - /* - Write message - */ - memcpy(&pbuf[written], pmsg, size); - diva_maint_ack_message(1, &old_irql); - written += size; - mask -= (size + 4); + if ((size + 8) > mask) { + diva_maint_ack_message(0, &old_irql); + break; } + /* + Write entry length + */ + pbuf[written++] = (byte) size; + pbuf[written++] = (byte) (size >> 8); pbuf[written++] = 0; pbuf[written++] = 0; - pbuf[written++] = 0; - pbuf[written++] = 0; + /* + Write message + */ + memcpy(&pbuf[written], pmsg, size); + diva_maint_ack_message(1, &old_irql); + written += size; + mask -= (size + 4); + } + pbuf[written++] = 0; + pbuf[written++] = 0; + pbuf[written++] = 0; + pbuf[written++] = 0; - if ((count < written) || diva_os_copy_to_user(NULL, buf, (void *) pbuf, written)) { - ret = -EFAULT; - } else { - ret = written; - } - diva_os_free(0, pbuf); + if ((count < written) || diva_os_copy_to_user(NULL, buf, (void *) pbuf, written)) { + ret = -EFAULT; + } else { + ret = written; } + diva_os_free(0, pbuf); + } break; default: @@ -316,7 +316,7 @@ int DIVA_INIT_FUNCTION mntfunc_init(int *buffer_length, void **buffer, } else { while ((*buffer_length >= (64 * 1024)) && - (!(*buffer = diva_os_malloc (0, *buffer_length)))) { + (!(*buffer = diva_os_malloc(0, *buffer_length)))) { *buffer_length -= 1024; } @@ -328,7 +328,7 @@ int DIVA_INIT_FUNCTION mntfunc_init(int *buffer_length, void **buffer, if (diva_maint_init(*buffer, *buffer_length, (diva_dbg_mem == 0))) { if (!diva_dbg_mem) { - diva_os_free (0, *buffer); + diva_os_free(0, *buffer); } DBG_ERR(("init: maint init failed")); return (0); @@ -338,7 +338,7 @@ int DIVA_INIT_FUNCTION mntfunc_init(int *buffer_length, void **buffer, DBG_ERR(("init: failed to connect to DIDD.")); diva_maint_finit(); if (!diva_dbg_mem) { - diva_os_free (0, *buffer); + diva_os_free(0, *buffer); } return (0); } @@ -362,7 +362,7 @@ void DIVA_EXIT_FUNCTION mntfunc_finit(void) disconnect_didd(); if ((buffer = diva_maint_finit())) { - diva_os_free (0, buffer); + diva_os_free(0, buffer); } memset(&MAdapter, 0, sizeof(MAdapter)); diff --git a/drivers/isdn/hardware/eicon/os_4bri.c b/drivers/isdn/hardware/eicon/os_4bri.c index cb7616c5b60a..1891246807ed 100644 --- a/drivers/isdn/hardware/eicon/os_4bri.c +++ b/drivers/isdn/hardware/eicon/os_4bri.c @@ -27,12 +27,12 @@ static dword diva_xdiLoadFileLength = 0; extern void prepare_qBri_functions(PISDN_ADAPTER IoAdapter); extern void prepare_qBri2_functions(PISDN_ADAPTER IoAdapter); extern void diva_xdi_display_adapter_features(int card); -extern void diva_add_slave_adapter(diva_os_xdi_adapter_t * a); +extern void diva_add_slave_adapter(diva_os_xdi_adapter_t *a); extern int qBri_FPGA_download(PISDN_ADAPTER IoAdapter); extern void start_qBri_hardware(PISDN_ADAPTER IoAdapter); -extern int diva_card_read_xlog(diva_os_xdi_adapter_t * a); +extern int diva_card_read_xlog(diva_os_xdi_adapter_t *a); /* ** LOCALS @@ -57,23 +57,23 @@ static unsigned long _4bri_v2_bri_bar_length[4] = { }; -static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a); -static int _4bri_get_serial_number(diva_os_xdi_adapter_t * a); +static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t *a); +static int _4bri_get_serial_number(diva_os_xdi_adapter_t *a); static int diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, - diva_xdi_um_cfg_cmd_t * cmd, + diva_xdi_um_cfg_cmd_t *cmd, int length); -static int diva_4bri_cleanup_slave_adapters(diva_os_xdi_adapter_t * a); -static int diva_4bri_write_fpga_image(diva_os_xdi_adapter_t * a, - byte * data, dword length); +static int diva_4bri_cleanup_slave_adapters(diva_os_xdi_adapter_t *a); +static int diva_4bri_write_fpga_image(diva_os_xdi_adapter_t *a, + byte *data, dword length); static int diva_4bri_reset_adapter(PISDN_ADAPTER IoAdapter); static int diva_4bri_write_sdram_block(PISDN_ADAPTER IoAdapter, dword address, - const byte * data, + const byte *data, dword length, dword limit); static int diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter, dword start_address, dword features); static int check_qBri_interrupt(PISDN_ADAPTER IoAdapter); -static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t * a); +static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t *a); static int _4bri_is_rev_2_card(int card_ordinal) { @@ -112,8 +112,8 @@ static void diva_4bri_set_addresses(diva_os_xdi_adapter_t *a) a->resources.pci.mem_type_id[MEM_TYPE_PROM] = 0; /* - Set up hardware related pointers - */ + Set up hardware related pointers + */ a->xdi_adapter.Address = a->resources.pci.addr[2]; /* BAR2 SDRAM */ a->xdi_adapter.Address += c_offset; @@ -121,15 +121,15 @@ static void diva_4bri_set_addresses(diva_os_xdi_adapter_t *a) a->xdi_adapter.ram = a->resources.pci.addr[2]; /* BAR2 SDRAM */ a->xdi_adapter.ram += c_offset + (offset - MQ_SHARED_RAM_SIZE); - + a->xdi_adapter.reset = a->resources.pci.addr[0]; /* BAR0 CONFIG */ /* - ctlReg contains the register address for the MIPS CPU reset control - */ + ctlReg contains the register address for the MIPS CPU reset control + */ a->xdi_adapter.ctlReg = a->resources.pci.addr[3]; /* BAR3 CNTRL */ /* - prom contains the register address for FPGA and EEPROM programming - */ + prom contains the register address for FPGA and EEPROM programming + */ a->xdi_adapter.prom = &a->xdi_adapter.reset[0x6E]; } @@ -141,7 +141,7 @@ static void diva_4bri_set_addresses(diva_os_xdi_adapter_t *a) ** ** Called by master adapter, that will initialize and add slave adapters */ -int diva_4bri_init_card(diva_os_xdi_adapter_t * a) +int diva_4bri_init_card(diva_os_xdi_adapter_t *a) { int bar, i; byte __iomem *p; @@ -168,48 +168,48 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) DBG_TRC(("SDRAM_LENGTH=%08x, tasks=%d, factor=%d", bar_length[2], tasks, factor)) - /* - Get Serial Number - The serial number of 4BRI is accessible in accordance with PCI spec - via command register located in configuration space, also we do not - have to map any BAR before we can access it - */ - if (!_4bri_get_serial_number(a)) { - DBG_ERR(("A: 4BRI can't get Serial Number")) - diva_4bri_cleanup_adapter(a); - return (-1); - } + /* + Get Serial Number + The serial number of 4BRI is accessible in accordance with PCI spec + via command register located in configuration space, also we do not + have to map any BAR before we can access it + */ + if (!_4bri_get_serial_number(a)) { + DBG_ERR(("A: 4BRI can't get Serial Number")) + diva_4bri_cleanup_adapter(a); + return (-1); + } /* - Set properties - */ + Set properties + */ a->xdi_adapter.Properties = CardProperties[a->CardOrdinal]; DBG_LOG(("Load %s, SN:%ld, bus:%02x, func:%02x", a->xdi_adapter.Properties.Name, a->xdi_adapter.serialNo, a->resources.pci.bus, a->resources.pci.func)) - /* - First initialization step: get and check hardware resoures. - Do not map resources and do not access card at this step - */ - for (bar = 0; bar < 4; bar++) { - a->resources.pci.bar[bar] = - divasa_get_pci_bar(a->resources.pci.bus, - a->resources.pci.func, bar, - a->resources.pci.hdev); - if (!a->resources.pci.bar[bar] - || (a->resources.pci.bar[bar] == 0xFFFFFFF0)) { - DBG_ERR( - ("A: invalid bar[%d]=%08x", bar, - a->resources.pci.bar[bar])) - return (-1); + /* + First initialization step: get and check hardware resoures. + Do not map resources and do not access card at this step + */ + for (bar = 0; bar < 4; bar++) { + a->resources.pci.bar[bar] = + divasa_get_pci_bar(a->resources.pci.bus, + a->resources.pci.func, bar, + a->resources.pci.hdev); + if (!a->resources.pci.bar[bar] + || (a->resources.pci.bar[bar] == 0xFFFFFFF0)) { + DBG_ERR( + ("A: invalid bar[%d]=%08x", bar, + a->resources.pci.bar[bar])) + return (-1); + } } - } a->resources.pci.irq = - (byte) divasa_get_pci_irq(a->resources.pci.bus, - a->resources.pci.func, - a->resources.pci.hdev); + (byte) divasa_get_pci_irq(a->resources.pci.bus, + a->resources.pci.func, + a->resources.pci.hdev); if (!a->resources.pci.irq) { DBG_ERR(("A: invalid irq")); return (-1); @@ -218,30 +218,30 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) a->xdi_adapter.sdram_bar = a->resources.pci.bar[2]; /* - Map all MEMORY BAR's - */ + Map all MEMORY BAR's + */ for (bar = 0; bar < 4; bar++) { if (bar != 1) { /* ignore I/O */ a->resources.pci.addr[bar] = - divasa_remap_pci_bar(a, bar, a->resources.pci.bar[bar], - bar_length[bar]); + divasa_remap_pci_bar(a, bar, a->resources.pci.bar[bar], + bar_length[bar]); if (!a->resources.pci.addr[bar]) { DBG_ERR(("A: 4BRI: can't map bar[%d]", bar)) - diva_4bri_cleanup_adapter(a); + diva_4bri_cleanup_adapter(a); return (-1); } } } /* - Register I/O port - */ + Register I/O port + */ sprintf(&a->port_name[0], "DIVA 4BRI %ld", (long) a->xdi_adapter.serialNo); if (diva_os_register_io_port(a, 1, a->resources.pci.bar[1], bar_length[1], &a->port_name[0], 1)) { DBG_ERR(("A: 4BRI: can't register bar[1]")) - diva_4bri_cleanup_adapter(a); + diva_4bri_cleanup_adapter(a); return (-1); } @@ -249,23 +249,23 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) (void *) (unsigned long) a->resources.pci.bar[1]; /* - Set cleanup pointer for base adapter only, so slave adapter - will be unable to get cleanup - */ + Set cleanup pointer for base adapter only, so slave adapter + will be unable to get cleanup + */ a->interface.cleanup_adapter_proc = diva_4bri_cleanup_adapter; /* - Create slave adapters - */ + Create slave adapters + */ if (tasks > 1) { if (!(a->slave_adapters[0] = - (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) + (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) { diva_4bri_cleanup_adapter(a); return (-1); } if (!(a->slave_adapters[1] = - (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) + (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) { diva_os_free(0, a->slave_adapters[0]); a->slave_adapters[0] = NULL; @@ -273,7 +273,7 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) return (-1); } if (!(a->slave_adapters[2] = - (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) + (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) { diva_os_free(0, a->slave_adapters[0]); diva_os_free(0, a->slave_adapters[1]); @@ -293,10 +293,10 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) adapter_list[3] = a->slave_adapters[2]; /* - Allocate slave list - */ + Allocate slave list + */ quadro_list = - (PADAPTER_LIST_ENTRY) diva_os_malloc(0, sizeof(*quadro_list)); + (PADAPTER_LIST_ENTRY) diva_os_malloc(0, sizeof(*quadro_list)); if (!(a->slave_list = quadro_list)) { for (i = 0; i < (tasks - 1); i++) { diva_os_free(0, a->slave_adapters[i]); @@ -308,14 +308,14 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) memset(quadro_list, 0x00, sizeof(*quadro_list)); /* - Set interfaces - */ + Set interfaces + */ a->xdi_adapter.QuadroList = quadro_list; for (i = 0; i < tasks; i++) { adapter_list[i]->xdi_adapter.ControllerNumber = i; adapter_list[i]->xdi_adapter.tasks = tasks; quadro_list->QuadroAdapter[i] = - &adapter_list[i]->xdi_adapter; + &adapter_list[i]->xdi_adapter; } for (i = 0; i < tasks; i++) { @@ -324,21 +324,21 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) diva_current->dsp_mask = 0x00000003; diva_current->xdi_adapter.a.io = - &diva_current->xdi_adapter; + &diva_current->xdi_adapter; diva_current->xdi_adapter.DIRequest = request; diva_current->interface.cmd_proc = diva_4bri_cmd_card_proc; diva_current->xdi_adapter.Properties = - CardProperties[a->CardOrdinal]; + CardProperties[a->CardOrdinal]; diva_current->CardOrdinal = a->CardOrdinal; diva_current->xdi_adapter.Channels = - CardProperties[a->CardOrdinal].Channels; + CardProperties[a->CardOrdinal].Channels; diva_current->xdi_adapter.e_max = - CardProperties[a->CardOrdinal].E_info; + CardProperties[a->CardOrdinal].E_info; diva_current->xdi_adapter.e_tbl = - diva_os_malloc(0, - diva_current->xdi_adapter.e_max * - sizeof(E_INFO)); + diva_os_malloc(0, + diva_current->xdi_adapter.e_max * + sizeof(E_INFO)); if (!diva_current->xdi_adapter.e_tbl) { diva_4bri_cleanup_slave_adapters(a); @@ -370,8 +370,8 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) strcpy(diva_current->xdi_adapter.req_soft_isr. dpc_thread_name, "kdivas4brid"); - if (diva_os_initialize_soft_isr (&diva_current->xdi_adapter.req_soft_isr, DIDpcRoutine, - &diva_current->xdi_adapter)) { + if (diva_os_initialize_soft_isr(&diva_current->xdi_adapter.req_soft_isr, DIDpcRoutine, + &diva_current->xdi_adapter)) { diva_4bri_cleanup_slave_adapters(a); diva_4bri_cleanup_adapter(a); for (i = 1; i < (tasks - 1); i++) { @@ -381,10 +381,10 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) } /* - Do not initialize second DPC - only one thread will be created - */ + Do not initialize second DPC - only one thread will be created + */ diva_current->xdi_adapter.isr_soft_isr.object = - diva_current->xdi_adapter.req_soft_isr.object; + diva_current->xdi_adapter.req_soft_isr.object; } if (v2) { @@ -397,12 +397,12 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) diva_current = adapter_list[i]; if (i) memcpy(&diva_current->resources, &a->resources, sizeof(divas_card_resources_t)); - diva_current->resources.pci.qoffset = (a->xdi_adapter.MemorySize >> factor); + diva_current->resources.pci.qoffset = (a->xdi_adapter.MemorySize >> factor); } /* - Set up hardware related pointers - */ + Set up hardware related pointers + */ a->xdi_adapter.cfg = (void *) (unsigned long) a->resources.pci.bar[0]; /* BAR0 CONFIG */ a->xdi_adapter.port = (void *) (unsigned long) a->resources.pci.bar[1]; /* BAR1 */ a->xdi_adapter.ctlReg = (void *) (unsigned long) a->resources.pci.bar[3]; /* BAR3 CNTRL */ @@ -415,21 +415,21 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) Slave->sdram_bar = a->xdi_adapter.sdram_bar; if (i) { Slave->serialNo = ((dword) (Slave->ControllerNumber << 24)) | - a->xdi_adapter.serialNo; + a->xdi_adapter.serialNo; Slave->cardType = a->xdi_adapter.cardType; } } /* - reset contains the base address for the PLX 9054 register set - */ + reset contains the base address for the PLX 9054 register set + */ p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter); WRITE_BYTE(&p[PLX9054_INTCSR], 0x00); /* disable PCI interrupts */ DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p); /* - Set IRQ handler - */ + Set IRQ handler + */ a->xdi_adapter.irq_info.irq_nr = a->resources.pci.irq; sprintf(a->xdi_adapter.irq_info.irq_name, "DIVA 4BRI %ld", (long) a->xdi_adapter.serialNo); @@ -447,8 +447,8 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) a->xdi_adapter.irq_info.registered = 1; /* - Add three slave adapters - */ + Add three slave adapters + */ if (tasks > 1) { diva_add_slave_adapter(adapter_list[1]); diva_add_slave_adapter(adapter_list[2]); @@ -466,33 +466,33 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a) ** this is guaranteed by design: cleanup callback is set ** by master adapter only */ -static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a) +static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t *a) { int bar; /* - Stop adapter if running - */ + Stop adapter if running + */ if (a->xdi_adapter.Initialized) { diva_4bri_stop_adapter(a); } /* - Remove IRQ handler - */ + Remove IRQ handler + */ if (a->xdi_adapter.irq_info.registered) { diva_os_remove_irq(a, a->xdi_adapter.irq_info.irq_nr); } a->xdi_adapter.irq_info.registered = 0; /* - Free DPC's and spin locks on all adapters - */ + Free DPC's and spin locks on all adapters + */ diva_4bri_cleanup_slave_adapters(a); /* - Unmap all BARS - */ + Unmap all BARS + */ for (bar = 0; bar < 4; bar++) { if (bar != 1) { if (a->resources.pci.bar[bar] @@ -505,8 +505,8 @@ static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a) } /* - Unregister I/O - */ + Unregister I/O + */ if (a->resources.pci.bar[1] && a->resources.pci.addr[1]) { diva_os_register_io_port(a, 0, a->resources.pci.bar[1], _4bri_is_rev_2_card(a-> @@ -526,7 +526,7 @@ static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a) return (0); } -static int _4bri_get_serial_number(diva_os_xdi_adapter_t * a) +static int _4bri_get_serial_number(diva_os_xdi_adapter_t *a) { dword data[64]; dword serNo; @@ -551,13 +551,13 @@ static int _4bri_get_serial_number(diva_os_xdi_adapter_t * a) } if (j >= 5) { DBG_ERR(("EEPROM[%d] read failed (0x%x)", i * 4, addr)) - return (0); + return (0); } PCIread(Bus, Slot, 0x50, &data[i], sizeof(data[i]), hdev); } DBG_BLK(((char *) &data[0], sizeof(data))) - serNo = data[32]; + serNo = data[32]; if (serNo == 0 || serNo == 0xffffffff) serNo = data[63]; @@ -572,13 +572,13 @@ static int _4bri_get_serial_number(diva_os_xdi_adapter_t * a) DBG_REG(("Serial No. : %ld", a->xdi_adapter.serialNo)) - return (serNo); + return (serNo); } /* ** Release resources of slave adapters */ -static int diva_4bri_cleanup_slave_adapters(diva_os_xdi_adapter_t * a) +static int diva_4bri_cleanup_slave_adapters(diva_os_xdi_adapter_t *a) { diva_os_xdi_adapter_t *adapter_list[4]; diva_os_xdi_adapter_t *diva_current; @@ -625,24 +625,24 @@ static int diva_4bri_cleanup_slave_adapters(diva_os_xdi_adapter_t * a) static int diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, - diva_xdi_um_cfg_cmd_t * cmd, int length) + diva_xdi_um_cfg_cmd_t *cmd, int length) { int ret = -1; if (cmd->adapter != a->controller) { DBG_ERR(("A: 4bri_cmd, invalid controller=%d != %d", cmd->adapter, a->controller)) - return (-1); + return (-1); } switch (cmd->command) { case DIVA_XDI_UM_CMD_GET_CARD_ORDINAL: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { *(dword *) a->xdi_mbox.data = - (dword) a->CardOrdinal; + (dword) a->CardOrdinal; a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY; ret = 0; } @@ -651,10 +651,10 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_SERIAL_NR: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { *(dword *) a->xdi_mbox.data = - (dword) a->xdi_adapter.serialNo; + (dword) a->xdi_adapter.serialNo; a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY; ret = 0; } @@ -663,11 +663,11 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_PCI_HW_CONFIG: if (!a->xdi_adapter.ControllerNumber) { /* - Only master adapter can access hardware config - */ + Only master adapter can access hardware config + */ a->xdi_mbox.data_length = sizeof(dword) * 9; a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { int i; dword *data = (dword *) a->xdi_mbox.data; @@ -686,7 +686,7 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, if (!a->xdi_adapter.ControllerNumber) { a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { dword *data = (dword *) a->xdi_mbox.data; if (!a->xdi_adapter.ram @@ -709,11 +709,11 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_WRITE_FPGA: if (!a->xdi_adapter.ControllerNumber) { ret = - diva_4bri_write_fpga_image(a, - (byte *) & cmd[1], - cmd->command_data. - write_fpga. - image_length); + diva_4bri_write_fpga_image(a, + (byte *)&cmd[1], + cmd->command_data. + write_fpga. + image_length); } break; @@ -754,12 +754,12 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_SET_PROTOCOL_FEATURES: if (!a->xdi_adapter.ControllerNumber) { a->xdi_adapter.features = - cmd->command_data.features.features; + cmd->command_data.features.features; a->xdi_adapter.a.protocol_capabilities = - a->xdi_adapter.features; + a->xdi_adapter.features; DBG_TRC(("Set raw protocol features (%08x)", a->xdi_adapter.features)) - ret = 0; + ret = 0; } break; @@ -777,16 +777,16 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, if (!a->xdi_adapter.ControllerNumber && a->xdi_adapter.Address) { if ( - (a->xdi_mbox.data_length = - cmd->command_data.read_sdram.length)) { + (a->xdi_mbox.data_length = + cmd->command_data.read_sdram.length)) { if ( - (a->xdi_mbox.data_length + - cmd->command_data.read_sdram.offset) < - a->xdi_adapter.MemorySize) { + (a->xdi_mbox.data_length + + cmd->command_data.read_sdram.offset) < + a->xdi_adapter.MemorySize) { a->xdi_mbox.data = - diva_os_malloc(0, - a->xdi_mbox. - data_length); + diva_os_malloc(0, + a->xdi_mbox. + data_length); if (a->xdi_mbox.data) { byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter); byte __iomem *src = p; @@ -810,7 +810,7 @@ diva_4bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, default: DBG_ERR(("A: A(%d) invalid cmd=%d", a->controller, cmd->command)) - } + } return (ret); } @@ -838,7 +838,7 @@ void diva_os_set_qBri2_functions(PISDN_ADAPTER IoAdapter) } static int -diva_4bri_write_fpga_image(diva_os_xdi_adapter_t * a, byte * data, +diva_4bri_write_fpga_image(diva_os_xdi_adapter_t *a, byte *data, dword length) { int ret; @@ -865,12 +865,12 @@ static int diva_4bri_reset_adapter(PISDN_ADAPTER IoAdapter) if (IoAdapter->Initialized) { DBG_ERR(("A: A(%d) can't reset 4BRI adapter - please stop first", IoAdapter->ANum)) - return (-1); + return (-1); } /* - Forget all entities on all adapters - */ + Forget all entities on all adapters + */ for (i = 0; ((i < IoAdapter->tasks) && IoAdapter->QuadroList); i++) { Slave = IoAdapter->QuadroList->QuadroAdapter[i]; Slave->e_count = 0; @@ -908,7 +908,7 @@ static int diva_4bri_reset_adapter(PISDN_ADAPTER IoAdapter) static int diva_4bri_write_sdram_block(PISDN_ADAPTER IoAdapter, dword address, - const byte * data, dword length, dword limit) + const byte *data, dword length, dword limit) { byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter); byte __iomem *mem = p; @@ -917,7 +917,7 @@ diva_4bri_write_sdram_block(PISDN_ADAPTER IoAdapter, DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p); DBG_ERR(("A: A(%d) write 4BRI address=0x%08lx", IoAdapter->ANum, address + length)) - return (-1); + return (-1); } mem += address; @@ -939,14 +939,14 @@ diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter, byte __iomem *p; /* - start adapter - */ + start adapter + */ start_qBri_hardware(IoAdapter); p = DIVA_OS_MEM_ATTACH_RAM(IoAdapter); /* - wait for signature in shared memory (max. 3 seconds) - */ + wait for signature in shared memory (max. 3 seconds) + */ signature = (volatile word __iomem *) (&p[0x1E]); for (i = 0; i < 300; ++i) { @@ -954,23 +954,23 @@ diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter, if (READ_WORD(&signature[0]) == 0x4447) { DBG_TRC(("Protocol startup time %d.%02d seconds", (i / 100), (i % 100))) - started = 1; + started = 1; break; } } for (i = 1; i < IoAdapter->tasks; i++) { IoAdapter->QuadroList->QuadroAdapter[i]->features = - IoAdapter->features; + IoAdapter->features; IoAdapter->QuadroList->QuadroAdapter[i]->a. - protocol_capabilities = IoAdapter->features; + protocol_capabilities = IoAdapter->features; } if (!started) { DBG_FTL(("%s: Adapter selftest failed, signature=%04x", IoAdapter->Properties.Name, READ_WORD(&signature[0]))) - DIVA_OS_MEM_DETACH_RAM(IoAdapter, p); + DIVA_OS_MEM_DETACH_RAM(IoAdapter, p); (*(IoAdapter->trapFnc)) (IoAdapter); IoAdapter->stop(IoAdapter); return (-1); @@ -985,9 +985,9 @@ diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter, if (check_qBri_interrupt(IoAdapter)) { DBG_ERR(("A: A(%d) interrupt test failed", IoAdapter->ANum)) - for (i = 0; i < IoAdapter->tasks; i++) { - IoAdapter->QuadroList->QuadroAdapter[i]->Initialized = 0; - } + for (i = 0; i < IoAdapter->tasks; i++) { + IoAdapter->QuadroList->QuadroAdapter[i]->Initialized = 0; + } IoAdapter->stop(IoAdapter); return (-1); } @@ -999,7 +999,7 @@ diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter, DBG_LOG(("A(%d) %s adapter successfully started", IoAdapter->QuadroList->QuadroAdapter[i]->ANum, (IoAdapter->tasks == 1) ? "BRI 2.0" : "4BRI")) - diva_xdi_didd_register_adapter(IoAdapter->QuadroList->QuadroAdapter[i]->ANum); + diva_xdi_didd_register_adapter(IoAdapter->QuadroList->QuadroAdapter[i]->ANum); IoAdapter->QuadroList->QuadroAdapter[i]->Properties.Features = (word) features; } @@ -1022,8 +1022,8 @@ static int check_qBri_interrupt(PISDN_ADAPTER IoAdapter) WRITE_BYTE(&p[PLX9054_INTCSR], PLX9054_INT_ENABLE); DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); /* - interrupt test - */ + interrupt test + */ a->ReadyInt = 1; a->ram_out(a, &PR_RAM->ReadyInt, 1); @@ -1034,14 +1034,14 @@ static int check_qBri_interrupt(PISDN_ADAPTER IoAdapter) dword volatile __iomem *qBriIrq; byte __iomem *p; /* - Reset on-board interrupt register - */ + Reset on-board interrupt register + */ IoAdapter->IrqCount = 0; p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); qBriIrq = (dword volatile __iomem *) (&p[_4bri_is_rev_2_card - (IoAdapter-> - cardType) ? (MQ2_BREG_IRQ_TEST) - : (MQ_BREG_IRQ_TEST)]); + (IoAdapter-> + cardType) ? (MQ2_BREG_IRQ_TEST) + : (MQ_BREG_IRQ_TEST)]); WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); @@ -1056,13 +1056,13 @@ static int check_qBri_interrupt(PISDN_ADAPTER IoAdapter) #endif /* SUPPORT_INTERRUPT_TEST_ON_4BRI */ } -static void diva_4bri_clear_interrupts(diva_os_xdi_adapter_t * a) +static void diva_4bri_clear_interrupts(diva_os_xdi_adapter_t *a) { PISDN_ADAPTER IoAdapter = &a->xdi_adapter; /* - clear any pending interrupt - */ + clear any pending interrupt + */ IoAdapter->disIrq(IoAdapter); IoAdapter->tst_irq(&IoAdapter->a); @@ -1070,13 +1070,13 @@ static void diva_4bri_clear_interrupts(diva_os_xdi_adapter_t * a) IoAdapter->tst_irq(&IoAdapter->a); /* - kill pending dpcs - */ + kill pending dpcs + */ diva_os_cancel_soft_isr(&IoAdapter->req_soft_isr); diva_os_cancel_soft_isr(&IoAdapter->isr_soft_isr); } -static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t * a) +static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t *a) { PISDN_ADAPTER IoAdapter = &a->xdi_adapter; int i; @@ -1088,7 +1088,7 @@ static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t * a) if (!IoAdapter->Initialized) { DBG_ERR(("A: A(%d) can't stop PRI adapter - not running", IoAdapter->ANum)) - return (-1); /* nothing to stop */ + return (-1); /* nothing to stop */ } for (i = 0; i < IoAdapter->tasks; i++) { @@ -1096,8 +1096,8 @@ static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t * a) } /* - Disconnect Adapters from DIDD - */ + Disconnect Adapters from DIDD + */ for (i = 0; i < IoAdapter->tasks; i++) { diva_xdi_didd_remove_adapter(IoAdapter->QuadroList->QuadroAdapter[i]->ANum); } @@ -1105,8 +1105,8 @@ static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t * a) i = 100; /* - Stop interrupts - */ + Stop interrupts + */ a->clear_interrupts_proc = diva_4bri_clear_interrupts; IoAdapter->a.ReadyInt = 1; IoAdapter->a.ram_inc(&IoAdapter->a, &PR_RAM->ReadyInt); @@ -1119,12 +1119,12 @@ static int diva_4bri_stop_adapter(diva_os_xdi_adapter_t * a) a->clear_interrupts_proc = NULL; DBG_ERR(("A: A(%d) no final interrupt from 4BRI adapter", IoAdapter->ANum)) - } + } IoAdapter->a.ReadyInt = 0; /* - Stop and reset adapter - */ + Stop and reset adapter + */ IoAdapter->stop(IoAdapter); return (0); diff --git a/drivers/isdn/hardware/eicon/os_4bri.h b/drivers/isdn/hardware/eicon/os_4bri.h index 665f0af27ce7..72253278d4f5 100644 --- a/drivers/isdn/hardware/eicon/os_4bri.h +++ b/drivers/isdn/hardware/eicon/os_4bri.h @@ -3,6 +3,6 @@ #ifndef __DIVA_OS_4_BRI_H__ #define __DIVA_OS_4_BRI_H__ -int diva_4bri_init_card(diva_os_xdi_adapter_t * a); +int diva_4bri_init_card(diva_os_xdi_adapter_t *a); #endif diff --git a/drivers/isdn/hardware/eicon/os_bri.c b/drivers/isdn/hardware/eicon/os_bri.c index 08f01993f46b..20f2653c58fa 100644 --- a/drivers/isdn/hardware/eicon/os_bri.c +++ b/drivers/isdn/hardware/eicon/os_bri.c @@ -23,7 +23,7 @@ */ extern void prepare_maestra_functions(PISDN_ADAPTER IoAdapter); extern void diva_xdi_display_adapter_features(int card); -extern int diva_card_read_xlog(diva_os_xdi_adapter_t * a); +extern int diva_card_read_xlog(diva_os_xdi_adapter_t *a); /* ** LOCALS @@ -33,20 +33,20 @@ static int bri_bar_length[3] = { 0x80, 0x20 }; -static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a); -static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a); +static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t *a); +static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t *a); static int diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, - diva_xdi_um_cfg_cmd_t * cmd, int length); -static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a); + diva_xdi_um_cfg_cmd_t *cmd, int length); +static int diva_bri_reregister_io(diva_os_xdi_adapter_t *a); static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter); static int diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter, dword address, - const byte * data, dword length); + const byte *data, dword length); static int diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, dword start_address, dword features); -static int diva_bri_stop_adapter(diva_os_xdi_adapter_t * a); +static int diva_bri_stop_adapter(diva_os_xdi_adapter_t *a); -static void diva_bri_set_addresses(diva_os_xdi_adapter_t * a) +static void diva_bri_set_addresses(diva_os_xdi_adapter_t *a) { a->resources.pci.mem_type_id[MEM_TYPE_RAM] = 0; a->resources.pci.mem_type_id[MEM_TYPE_CFG] = 1; @@ -54,7 +54,7 @@ static void diva_bri_set_addresses(diva_os_xdi_adapter_t * a) a->resources.pci.mem_type_id[MEM_TYPE_RESET] = 1; a->resources.pci.mem_type_id[MEM_TYPE_PORT] = 2; a->resources.pci.mem_type_id[MEM_TYPE_CTLREG] = 2; - + a->xdi_adapter.ram = a->resources.pci.addr[0]; a->xdi_adapter.cfg = a->resources.pci.addr[1]; a->xdi_adapter.Address = a->resources.pci.addr[2]; @@ -72,7 +72,7 @@ static void diva_bri_set_addresses(diva_os_xdi_adapter_t * a) ** BAR1 - I/O Addr - 0x80 ** BAR2 - I/O Addr - 0x20 */ -int diva_bri_init_card(diva_os_xdi_adapter_t * a) +int diva_bri_init_card(diva_os_xdi_adapter_t *a) { int bar; dword bar2 = 0, bar2_length = 0xffffffff; @@ -82,75 +82,75 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) byte __iomem *p; /* - Set properties - */ + Set properties + */ a->xdi_adapter.Properties = CardProperties[a->CardOrdinal]; DBG_LOG(("Load %s", a->xdi_adapter.Properties.Name)) - /* - Get resources - */ - for (bar = 0; bar < 3; bar++) { - a->resources.pci.bar[bar] = - divasa_get_pci_bar(a->resources.pci.bus, - a->resources.pci.func, bar, - a->resources.pci.hdev); - if (!a->resources.pci.bar[bar]) { - DBG_ERR(("A: can't get BAR[%d]", bar)) - return (-1); + /* + Get resources + */ + for (bar = 0; bar < 3; bar++) { + a->resources.pci.bar[bar] = + divasa_get_pci_bar(a->resources.pci.bus, + a->resources.pci.func, bar, + a->resources.pci.hdev); + if (!a->resources.pci.bar[bar]) { + DBG_ERR(("A: can't get BAR[%d]", bar)) + return (-1); + } } - } a->resources.pci.irq = - (byte) divasa_get_pci_irq(a->resources.pci.bus, - a->resources.pci.func, - a->resources.pci.hdev); + (byte) divasa_get_pci_irq(a->resources.pci.bus, + a->resources.pci.func, + a->resources.pci.hdev); if (!a->resources.pci.irq) { DBG_ERR(("A: invalid irq")); return (-1); } /* - Get length of I/O bar 2 - it is different by older - EEPROM version - */ + Get length of I/O bar 2 - it is different by older + EEPROM version + */ Bus = a->resources.pci.bus; Slot = a->resources.pci.func; hdev = a->resources.pci.hdev; /* - Get plain original values of the BAR2 CDM registers - */ + Get plain original values of the BAR2 CDM registers + */ PCIread(Bus, Slot, 0x18, &bar2, sizeof(bar2), hdev); PCIread(Bus, Slot, 0x04, &cmd_org, sizeof(cmd_org), hdev); /* - Disable device and get BAR2 length - */ + Disable device and get BAR2 length + */ PCIwrite(Bus, Slot, 0x04, &cmd, sizeof(cmd), hdev); PCIwrite(Bus, Slot, 0x18, &bar2_length, sizeof(bar2_length), hdev); PCIread(Bus, Slot, 0x18, &bar2_length, sizeof(bar2_length), hdev); /* - Restore BAR2 and CMD registers - */ + Restore BAR2 and CMD registers + */ PCIwrite(Bus, Slot, 0x18, &bar2, sizeof(bar2), hdev); PCIwrite(Bus, Slot, 0x04, &cmd_org, sizeof(cmd_org), hdev); /* - Calculate BAR2 length - */ + Calculate BAR2 length + */ bar2_length = (~(bar2_length & ~7)) + 1; DBG_LOG(("BAR[2] length=%lx", bar2_length)) - /* - Map and register resources - */ - if (!(a->resources.pci.addr[0] = - divasa_remap_pci_bar(a, 0, a->resources.pci.bar[0], - bri_bar_length[0]))) { - DBG_ERR(("A: BRI, can't map BAR[0]")) - diva_bri_cleanup_adapter(a); - return (-1); - } + /* + Map and register resources + */ + if (!(a->resources.pci.addr[0] = + divasa_remap_pci_bar(a, 0, a->resources.pci.bar[0], + bri_bar_length[0]))) { + DBG_ERR(("A: BRI, can't map BAR[0]")) + diva_bri_cleanup_adapter(a); + return (-1); + } sprintf(&a->port_name[0], "BRI %02x:%02x", a->resources.pci.bus, a->resources.pci.func); @@ -158,7 +158,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) if (diva_os_register_io_port(a, 1, a->resources.pci.bar[1], bri_bar_length[1], &a->port_name[0], 1)) { DBG_ERR(("A: BRI, can't register BAR[1]")) - diva_bri_cleanup_adapter(a); + diva_bri_cleanup_adapter(a); return (-1); } a->resources.pci.addr[1] = (void *) (unsigned long) a->resources.pci.bar[1]; @@ -167,33 +167,33 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) if (diva_os_register_io_port(a, 1, a->resources.pci.bar[2], bar2_length, &a->port_name[0], 2)) { DBG_ERR(("A: BRI, can't register BAR[2]")) - diva_bri_cleanup_adapter(a); + diva_bri_cleanup_adapter(a); return (-1); } a->resources.pci.addr[2] = (void *) (unsigned long) a->resources.pci.bar[2]; a->resources.pci.length[2] = bar2_length; /* - Set all memory areas - */ + Set all memory areas + */ diva_bri_set_addresses(a); /* - Get Serial Number - */ + Get Serial Number + */ a->xdi_adapter.serialNo = diva_bri_get_serial_number(a); /* - Register I/O ports with correct name now - */ + Register I/O ports with correct name now + */ if (diva_bri_reregister_io(a)) { diva_bri_cleanup_adapter(a); return (-1); } /* - Initialize OS dependent objects - */ + Initialize OS dependent objects + */ if (diva_os_initialize_spin_lock (&a->xdi_adapter.isr_spin_lock, "isr")) { diva_bri_cleanup_adapter(a); @@ -213,13 +213,13 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) return (-1); } /* - Do not initialize second DPC - only one thread will be created - */ + Do not initialize second DPC - only one thread will be created + */ a->xdi_adapter.isr_soft_isr.object = a->xdi_adapter.req_soft_isr.object; /* - Create entity table - */ + Create entity table + */ a->xdi_adapter.Channels = CardProperties[a->CardOrdinal].Channels; a->xdi_adapter.e_max = CardProperties[a->CardOrdinal].E_info; a->xdi_adapter.e_tbl = diva_os_malloc(0, a->xdi_adapter.e_max * sizeof(E_INFO)); @@ -230,8 +230,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) memset(a->xdi_adapter.e_tbl, 0x00, a->xdi_adapter.e_max * sizeof(E_INFO)); /* - Set up interface - */ + Set up interface + */ a->xdi_adapter.a.io = &a->xdi_adapter; a->xdi_adapter.DIRequest = request; a->interface.cleanup_adapter_proc = diva_bri_cleanup_adapter; @@ -246,8 +246,8 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) a->dsp_mask = 0x00000003; /* - Set IRQ handler - */ + Set IRQ handler + */ a->xdi_adapter.irq_info.irq_nr = a->resources.pci.irq; sprintf(a->xdi_adapter.irq_info.irq_name, "DIVA BRI %ld", (long) a->xdi_adapter.serialNo); @@ -265,7 +265,7 @@ int diva_bri_init_card(diva_os_xdi_adapter_t * a) } -static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a) +static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t *a) { int i; @@ -274,8 +274,8 @@ static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a) } /* - Remove ISR Handler - */ + Remove ISR Handler + */ if (a->xdi_adapter.irq_info.registered) { diva_os_remove_irq(a, a->xdi_adapter.irq_info.irq_nr); } @@ -300,8 +300,8 @@ static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a) } /* - Free OS objects - */ + Free OS objects + */ diva_os_cancel_soft_isr(&a->xdi_adapter.req_soft_isr); diva_os_cancel_soft_isr(&a->xdi_adapter.isr_soft_isr); @@ -312,8 +312,8 @@ static int diva_bri_cleanup_adapter(diva_os_xdi_adapter_t * a) diva_os_destroy_spin_lock(&a->xdi_adapter.data_spin_lock, "rm"); /* - Free memory - */ + Free memory + */ if (a->xdi_adapter.e_tbl) { diva_os_free(0, a->xdi_adapter.e_tbl); a->xdi_adapter.e_tbl = NULL; @@ -329,7 +329,7 @@ void diva_os_prepare_maestra_functions(PISDN_ADAPTER IoAdapter) /* ** Get serial number */ -static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a) +static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t *a) { dword serNo = 0; byte __iomem *confIO; @@ -345,7 +345,7 @@ static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a) if ((serNo == 0) || (serNo == 0xFFFFFFFF)) { DBG_FTL(("W: BRI use BAR[0] to get card serial number")) - confMem = (word __iomem *)DIVA_OS_MEM_ATTACH_RAM(&a->xdi_adapter); + confMem = (word __iomem *)DIVA_OS_MEM_ATTACH_RAM(&a->xdi_adapter); serHi = (word) (READ_WORD(&confMem[0x11]) & 0x0FFF); serLo = (word) (READ_WORD(&confMem[0x13]) & 0x0FFF); serNo = (((dword) serHi) << 16) | ((dword) serLo); @@ -354,14 +354,14 @@ static dword diva_bri_get_serial_number(diva_os_xdi_adapter_t * a) DBG_LOG(("Serial Number=%ld", serNo)) - return (serNo); + return (serNo); } /* ** Unregister I/O and register it with new name, ** based on Serial Number */ -static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a) +static int diva_bri_reregister_io(diva_os_xdi_adapter_t *a) { int i; @@ -380,10 +380,10 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a) a->resources.pci.length[i], &a->port_name[0], i)) { DBG_ERR(("A: failed to reregister BAR[%d]", i)) - return (-1); + return (-1); } a->resources.pci.addr[i] = - (void *) (unsigned long) a->resources.pci.bar[i]; + (void *) (unsigned long) a->resources.pci.bar[i]; } return (0); @@ -394,24 +394,24 @@ static int diva_bri_reregister_io(diva_os_xdi_adapter_t * a) */ static int diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, - diva_xdi_um_cfg_cmd_t * cmd, int length) + diva_xdi_um_cfg_cmd_t *cmd, int length) { int ret = -1; if (cmd->adapter != a->controller) { DBG_ERR(("A: pri_cmd, invalid controller=%d != %d", cmd->adapter, a->controller)) - return (-1); + return (-1); } switch (cmd->command) { case DIVA_XDI_UM_CMD_GET_CARD_ORDINAL: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { *(dword *) a->xdi_mbox.data = - (dword) a->CardOrdinal; + (dword) a->CardOrdinal; a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY; ret = 0; } @@ -420,10 +420,10 @@ diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_SERIAL_NR: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { *(dword *) a->xdi_mbox.data = - (dword) a->xdi_adapter.serialNo; + (dword) a->xdi_adapter.serialNo; a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY; ret = 0; } @@ -432,7 +432,7 @@ diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_PCI_HW_CONFIG: a->xdi_mbox.data_length = sizeof(dword) * 9; a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { int i; dword *data = (dword *) a->xdi_mbox.data; @@ -449,7 +449,7 @@ diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_CARD_STATE: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { dword *data = (dword *) a->xdi_mbox.data; if (!a->xdi_adapter.port) { @@ -474,7 +474,7 @@ diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, ret = diva_bri_write_sdram_block(&a->xdi_adapter, cmd->command_data. write_sdram.offset, - (byte *) & cmd[1], + (byte *)&cmd[1], cmd->command_data. write_sdram.length); break; @@ -489,9 +489,9 @@ diva_bri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_SET_PROTOCOL_FEATURES: a->xdi_adapter.features = - cmd->command_data.features.features; + cmd->command_data.features.features; a->xdi_adapter.a.protocol_capabilities = - a->xdi_adapter.features; + a->xdi_adapter.features; DBG_TRC( ("Set raw protocol features (%08x)", a->xdi_adapter.features)) ret = 0; @@ -530,18 +530,18 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) diva_os_wait(100); Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); addrHi = Port + - ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); addrLo = Port + ADDR; ioaddr = Port + DATA; /* - recover - */ + recover + */ outpp(addrHi, (byte) 0); outppw(addrLo, (word) 0); outppw(ioaddr, (word) 0); /* - clear shared memory - */ + clear shared memory + */ outpp(addrHi, (byte) ( (IoAdapter->MemoryBase + IoAdapter->MemorySize - @@ -551,8 +551,8 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) diva_os_wait(100); /* - clear signature - */ + clear signature + */ outpp(addrHi, (byte) ( (IoAdapter->MemoryBase + IoAdapter->MemorySize - @@ -568,8 +568,8 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port); /* - Forget all outstanding entities - */ + Forget all outstanding entities + */ IoAdapter->e_count = 0; if (IoAdapter->e_tbl) { memset(IoAdapter->e_tbl, 0x00, @@ -602,7 +602,7 @@ static int diva_bri_reset_adapter(PISDN_ADAPTER IoAdapter) static int diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter, - dword address, const byte * data, dword length) + dword address, const byte *data, dword length) { byte __iomem *addrHi, *addrLo, *ioaddr; byte __iomem *Port; @@ -613,7 +613,7 @@ diva_bri_write_sdram_block(PISDN_ADAPTER IoAdapter, Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); addrHi = Port + - ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); addrLo = Port + ADDR; ioaddr = Port + DATA; @@ -651,9 +651,9 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, sprintf(IoAdapter->Name, "A(%d)", (int) IoAdapter->ANum); DBG_LOG(("A(%d) start BRI", IoAdapter->ANum)) - Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); + Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); addrHi = Port + - ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); addrLo = Port + ADDR; ioaddr = Port + DATA; @@ -666,20 +666,20 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port); /* - start the protocol code - */ + start the protocol code + */ Port = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); outpp(Port, 0x08); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, Port); Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); addrHi = Port + - ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); addrLo = Port + ADDR; ioaddr = Port + DATA; /* - wait for signature (max. 3 seconds) - */ + wait for signature (max. 3 seconds) + */ for (i = 0; i < 300; ++i) { diva_os_wait(10); outpp(addrHi, @@ -693,7 +693,7 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, DBG_LOG( ("Protocol startup time %d.%02d seconds", (i / 100), (i % 100))) - started = 1; + started = 1; break; } } @@ -703,15 +703,15 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, DBG_FTL(("A: A(%d) %s: Adapter selftest failed 0x%04X", IoAdapter->ANum, IoAdapter->Properties.Name, test)) - (*(IoAdapter->trapFnc)) (IoAdapter); + (*(IoAdapter->trapFnc)) (IoAdapter); return (-1); } IoAdapter->Initialized = 1; /* - Check Interrupt - */ + Check Interrupt + */ IoAdapter->IrqCount = 0; a->ReadyInt = 1; @@ -729,7 +729,7 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, DBG_ERR( ("A: A(%d) interrupt test failed", IoAdapter->ANum)) - IoAdapter->Initialized = 0; + IoAdapter->Initialized = 0; IoAdapter->stop(IoAdapter); return (-1); } @@ -737,21 +737,21 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter, IoAdapter->Properties.Features = (word) features; diva_xdi_display_adapter_features(IoAdapter->ANum); DBG_LOG(("A(%d) BRI adapter successfully started", IoAdapter->ANum)) - /* - Register with DIDD - */ - diva_xdi_didd_register_adapter(IoAdapter->ANum); + /* + Register with DIDD + */ + diva_xdi_didd_register_adapter(IoAdapter->ANum); return (0); } -static void diva_bri_clear_interrupts(diva_os_xdi_adapter_t * a) +static void diva_bri_clear_interrupts(diva_os_xdi_adapter_t *a) { PISDN_ADAPTER IoAdapter = &a->xdi_adapter; /* - clear any pending interrupt - */ + clear any pending interrupt + */ IoAdapter->disIrq(IoAdapter); IoAdapter->tst_irq(&IoAdapter->a); @@ -759,8 +759,8 @@ static void diva_bri_clear_interrupts(diva_os_xdi_adapter_t * a) IoAdapter->tst_irq(&IoAdapter->a); /* - kill pending dpcs - */ + kill pending dpcs + */ diva_os_cancel_soft_isr(&IoAdapter->req_soft_isr); diva_os_cancel_soft_isr(&IoAdapter->isr_soft_isr); } @@ -768,7 +768,7 @@ static void diva_bri_clear_interrupts(diva_os_xdi_adapter_t * a) /* ** Stop card */ -static int diva_bri_stop_adapter(diva_os_xdi_adapter_t * a) +static int diva_bri_stop_adapter(diva_os_xdi_adapter_t *a) { PISDN_ADAPTER IoAdapter = &a->xdi_adapter; int i = 100; @@ -779,18 +779,18 @@ static int diva_bri_stop_adapter(diva_os_xdi_adapter_t * a) if (!IoAdapter->Initialized) { DBG_ERR(("A: A(%d) can't stop BRI adapter - not running", IoAdapter->ANum)) - return (-1); /* nothing to stop */ + return (-1); /* nothing to stop */ } IoAdapter->Initialized = 0; /* - Disconnect Adapter from DIDD - */ + Disconnect Adapter from DIDD + */ diva_xdi_didd_remove_adapter(IoAdapter->ANum); /* - Stop interrupts - */ + Stop interrupts + */ a->clear_interrupts_proc = diva_bri_clear_interrupts; IoAdapter->a.ReadyInt = 1; IoAdapter->a.ram_inc(&IoAdapter->a, &PR_RAM->ReadyInt); @@ -802,12 +802,12 @@ static int diva_bri_stop_adapter(diva_os_xdi_adapter_t * a) a->clear_interrupts_proc = NULL; DBG_ERR(("A: A(%d) no final interrupt from BRI adapter", IoAdapter->ANum)) - } + } IoAdapter->a.ReadyInt = 0; /* - Stop and reset adapter - */ + Stop and reset adapter + */ IoAdapter->stop(IoAdapter); return (0); diff --git a/drivers/isdn/hardware/eicon/os_bri.h b/drivers/isdn/hardware/eicon/os_bri.h index a54f0ce58e13..02e7456f8962 100644 --- a/drivers/isdn/hardware/eicon/os_bri.h +++ b/drivers/isdn/hardware/eicon/os_bri.h @@ -3,6 +3,6 @@ #ifndef __DIVA_OS_BRI_REV_1_H__ #define __DIVA_OS_BRI_REV_1_H__ -int diva_bri_init_card(diva_os_xdi_adapter_t * a); +int diva_bri_init_card(diva_os_xdi_adapter_t *a); #endif diff --git a/drivers/isdn/hardware/eicon/os_capi.h b/drivers/isdn/hardware/eicon/os_capi.h index 726f915a09e5..e72394b95d50 100644 --- a/drivers/isdn/hardware/eicon/os_capi.h +++ b/drivers/isdn/hardware/eicon/os_capi.h @@ -1,16 +1,16 @@ /* $Id: os_capi.h,v 1.7 2003/04/12 21:40:49 schindler Exp $ * * ISDN interface module for Eicon active cards DIVA. - * CAPI Interface OS include files - * - * Copyright 2000-2003 by Armin Schindler (mac@melware.de) + * CAPI Interface OS include files + * + * Copyright 2000-2003 by Armin Schindler (mac@melware.de) * Copyright 2000-2003 Cytronics & Melware (info@melware.de) - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. */ -#ifndef __OS_CAPI_H__ +#ifndef __OS_CAPI_H__ #define __OS_CAPI_H__ #include diff --git a/drivers/isdn/hardware/eicon/os_pri.c b/drivers/isdn/hardware/eicon/os_pri.c index 5d65405c75f4..da4957abb422 100644 --- a/drivers/isdn/hardware/eicon/os_pri.c +++ b/drivers/isdn/hardware/eicon/os_pri.c @@ -24,11 +24,11 @@ OS Dependent part of XDI driver for DIVA PRI Adapter DSP detection/validation by Anthony Booth (Eicon Networks, www.eicon.com) --------------------------------------------------------------------------- */ + -------------------------------------------------------------------------- */ #define DIVA_PRI_NO_PCI_BIOS_WORKAROUND 1 -extern int diva_card_read_xlog(diva_os_xdi_adapter_t * a); +extern int diva_card_read_xlog(diva_os_xdi_adapter_t *a); /* ** IMPORTS @@ -37,12 +37,12 @@ extern void prepare_pri_functions(PISDN_ADAPTER IoAdapter); extern void prepare_pri2_functions(PISDN_ADAPTER IoAdapter); extern void diva_xdi_display_adapter_features(int card); -static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a); +static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t *a); static int diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, - diva_xdi_um_cfg_cmd_t * cmd, int length); -static int pri_get_serial_number(diva_os_xdi_adapter_t * a); -static int diva_pri_stop_adapter(diva_os_xdi_adapter_t * a); -static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t * a); + diva_xdi_um_cfg_cmd_t *cmd, int length); +static int pri_get_serial_number(diva_os_xdi_adapter_t *a); +static int diva_pri_stop_adapter(diva_os_xdi_adapter_t *a); +static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t *a); /* ** Check card revision @@ -57,7 +57,7 @@ static int pri_is_rev_2_card(int card_ordinal) return (0); } -static void diva_pri_set_addresses(diva_os_xdi_adapter_t * a) +static void diva_pri_set_addresses(diva_os_xdi_adapter_t *a) { a->resources.pci.mem_type_id[MEM_TYPE_ADDRESS] = 0; a->resources.pci.mem_type_id[MEM_TYPE_CONTROL] = 2; @@ -66,7 +66,7 @@ static void diva_pri_set_addresses(diva_os_xdi_adapter_t * a) a->resources.pci.mem_type_id[MEM_TYPE_RESET] = 2; a->resources.pci.mem_type_id[MEM_TYPE_CFG] = 4; a->resources.pci.mem_type_id[MEM_TYPE_PROM] = 3; - + a->xdi_adapter.Address = a->resources.pci.addr[0]; a->xdi_adapter.Control = a->resources.pci.addr[2]; a->xdi_adapter.Config = a->resources.pci.addr[4]; @@ -92,7 +92,7 @@ static void diva_pri_set_addresses(diva_os_xdi_adapter_t * a) ** BAR3 - FLASH (REG), 0x8000 ** BAR4 - CONFIG (CFG), 0x1000 */ -int diva_pri_init_card(diva_os_xdi_adapter_t * a) +int diva_pri_init_card(diva_os_xdi_adapter_t *a) { int bar = 0; int pri_rev_2; @@ -110,59 +110,59 @@ int diva_pri_init_card(diva_os_xdi_adapter_t * a) bar_length[0] = MP2_MEMORY_SIZE; } /* - Set properties - */ + Set properties + */ a->xdi_adapter.Properties = CardProperties[a->CardOrdinal]; DBG_LOG(("Load %s", a->xdi_adapter.Properties.Name)) - /* - First initialization step: get and check hardware resoures. - Do not map resources and do not acecess card at this step - */ - for (bar = 0; bar < 5; bar++) { - a->resources.pci.bar[bar] = - divasa_get_pci_bar(a->resources.pci.bus, - a->resources.pci.func, bar, - a->resources.pci.hdev); - if (!a->resources.pci.bar[bar] - || (a->resources.pci.bar[bar] == 0xFFFFFFF0)) { - DBG_ERR(("A: invalid bar[%d]=%08x", bar, - a->resources.pci.bar[bar])) - return (-1); + /* + First initialization step: get and check hardware resoures. + Do not map resources and do not acecess card at this step + */ + for (bar = 0; bar < 5; bar++) { + a->resources.pci.bar[bar] = + divasa_get_pci_bar(a->resources.pci.bus, + a->resources.pci.func, bar, + a->resources.pci.hdev); + if (!a->resources.pci.bar[bar] + || (a->resources.pci.bar[bar] == 0xFFFFFFF0)) { + DBG_ERR(("A: invalid bar[%d]=%08x", bar, + a->resources.pci.bar[bar])) + return (-1); + } } - } a->resources.pci.irq = - (byte) divasa_get_pci_irq(a->resources.pci.bus, - a->resources.pci.func, - a->resources.pci.hdev); + (byte) divasa_get_pci_irq(a->resources.pci.bus, + a->resources.pci.func, + a->resources.pci.hdev); if (!a->resources.pci.irq) { DBG_ERR(("A: invalid irq")); return (-1); } /* - Map all BAR's - */ + Map all BAR's + */ for (bar = 0; bar < 5; bar++) { a->resources.pci.addr[bar] = - divasa_remap_pci_bar(a, bar, a->resources.pci.bar[bar], - bar_length[bar]); + divasa_remap_pci_bar(a, bar, a->resources.pci.bar[bar], + bar_length[bar]); if (!a->resources.pci.addr[bar]) { DBG_ERR(("A: A(%d), can't map bar[%d]", a->controller, bar)) - diva_pri_cleanup_adapter(a); + diva_pri_cleanup_adapter(a); return (-1); } } /* - Set all memory areas - */ + Set all memory areas + */ diva_pri_set_addresses(a); /* - Get Serial Number of this adapter - */ + Get Serial Number of this adapter + */ if (pri_get_serial_number(a)) { dword serNo; serNo = a->resources.pci.bar[1] & 0xffff0000; @@ -171,12 +171,12 @@ int diva_pri_init_card(diva_os_xdi_adapter_t * a) a->xdi_adapter.serialNo = serNo & ~0xFF000000; DBG_ERR(("A: A(%d) can't get Serial Number, generated serNo=%ld", a->controller, a->xdi_adapter.serialNo)) - } + } /* - Initialize os objects - */ + Initialize os objects + */ if (diva_os_initialize_spin_lock(&a->xdi_adapter.isr_spin_lock, "isr")) { diva_pri_cleanup_adapter(a); return (-1); @@ -196,20 +196,20 @@ int diva_pri_init_card(diva_os_xdi_adapter_t * a) } /* - Do not initialize second DPC - only one thread will be created - */ + Do not initialize second DPC - only one thread will be created + */ a->xdi_adapter.isr_soft_isr.object = - a->xdi_adapter.req_soft_isr.object; + a->xdi_adapter.req_soft_isr.object; /* - Next step of card initialization: - set up all interface pointers - */ + Next step of card initialization: + set up all interface pointers + */ a->xdi_adapter.Channels = CardProperties[a->CardOrdinal].Channels; a->xdi_adapter.e_max = CardProperties[a->CardOrdinal].E_info; a->xdi_adapter.e_tbl = - diva_os_malloc(0, a->xdi_adapter.e_max * sizeof(E_INFO)); + diva_os_malloc(0, a->xdi_adapter.e_max * sizeof(E_INFO)); if (!a->xdi_adapter.e_tbl) { diva_pri_cleanup_adapter(a); return (-1); @@ -230,16 +230,16 @@ int diva_pri_init_card(diva_os_xdi_adapter_t * a) a->dsp_mask = diva_pri_detect_dsps(a); /* - Allocate DMA map - */ + Allocate DMA map + */ if (pri_rev_2) { diva_init_dma_map(a->resources.pci.hdev, (struct _diva_dma_map_entry **) &a->xdi_adapter.dma_map, 32); } /* - Set IRQ handler - */ + Set IRQ handler + */ a->xdi_adapter.irq_info.irq_nr = a->resources.pci.irq; sprintf(a->xdi_adapter.irq_info.irq_name, "DIVA PRI %ld", (long) a->xdi_adapter.serialNo); @@ -257,28 +257,28 @@ int diva_pri_init_card(diva_os_xdi_adapter_t * a) return (0); } -static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a) +static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t *a) { int bar = 0; /* - Stop Adapter if adapter is running - */ + Stop Adapter if adapter is running + */ if (a->xdi_adapter.Initialized) { diva_pri_stop_adapter(a); } /* - Remove ISR Handler - */ + Remove ISR Handler + */ if (a->xdi_adapter.irq_info.registered) { diva_os_remove_irq(a, a->xdi_adapter.irq_info.irq_nr); } a->xdi_adapter.irq_info.registered = 0; /* - Step 1: unmap all BAR's, if any was mapped - */ + Step 1: unmap all BAR's, if any was mapped + */ for (bar = 0; bar < 5; bar++) { if (a->resources.pci.bar[bar] && a->resources.pci.addr[bar]) { @@ -289,8 +289,8 @@ static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a) } /* - Free OS objects - */ + Free OS objects + */ diva_os_cancel_soft_isr(&a->xdi_adapter.isr_soft_isr); diva_os_cancel_soft_isr(&a->xdi_adapter.req_soft_isr); @@ -301,8 +301,8 @@ static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a) diva_os_destroy_spin_lock(&a->xdi_adapter.data_spin_lock, "rm"); /* - Free memory accupied by XDI adapter - */ + Free memory accupied by XDI adapter + */ if (a->xdi_adapter.e_tbl) { diva_os_free(0, a->xdi_adapter.e_tbl); a->xdi_adapter.e_tbl = NULL; @@ -312,8 +312,8 @@ static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a) /* - Free adapter DMA map - */ + Free adapter DMA map + */ diva_free_dma_map(a->resources.pci.hdev, (struct _diva_dma_map_entry *) a->xdi_adapter. dma_map); @@ -321,8 +321,8 @@ static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a) /* - Detach this adapter from debug driver - */ + Detach this adapter from debug driver + */ return (0); } @@ -341,7 +341,7 @@ static int diva_pri_reset_adapter(PISDN_ADAPTER IoAdapter) if (IoAdapter->Initialized) { DBG_ERR(("A: A(%d) can't reset PRI adapter - please stop first", IoAdapter->ANum)) - return (-1); + return (-1); } boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter); @@ -360,20 +360,20 @@ static int diva_pri_reset_adapter(PISDN_ADAPTER IoAdapter) DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); DBG_ERR(("A: A(%d) CPU on PRI %ld is not alive!", IoAdapter->ANum, IoAdapter->serialNo)) - return (-1); + return (-1); } if (READ_DWORD(&boot->err)) { DBG_ERR(("A: A(%d) PRI %ld Board Selftest failed, error=%08lx", IoAdapter->ANum, IoAdapter->serialNo, READ_DWORD(&boot->err))) - DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); + DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); return (-1); } DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); /* - Forget all outstanding entities - */ + Forget all outstanding entities + */ IoAdapter->e_count = 0; if (IoAdapter->e_tbl) { memset(IoAdapter->e_tbl, 0x00, @@ -407,7 +407,7 @@ static int diva_pri_reset_adapter(PISDN_ADAPTER IoAdapter) static int diva_pri_write_sdram_block(PISDN_ADAPTER IoAdapter, dword address, - const byte * data, dword length, dword limit) + const byte *data, dword length, dword limit) { byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter); byte __iomem *mem = p; @@ -416,7 +416,7 @@ diva_pri_write_sdram_block(PISDN_ADAPTER IoAdapter, DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p); DBG_ERR(("A: A(%d) write PRI address=0x%08lx", IoAdapter->ANum, address + length)) - return (-1); + return (-1); } mem += address; @@ -443,20 +443,20 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter, DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); DBG_ERR(("A: A(%d) pri_start_adapter, adapter already running", IoAdapter->ANum)) - return (-1); + return (-1); } if (!boot) { DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); DBG_ERR(("A: PRI %ld can't start, adapter not mapped", IoAdapter->serialNo)) - return (-1); + return (-1); } sprintf(IoAdapter->Name, "A(%d)", (int) IoAdapter->ANum); DBG_LOG(("A(%d) start PRI at 0x%08lx", IoAdapter->ANum, start_address)) - WRITE_DWORD(&boot->addr, start_address); + WRITE_DWORD(&boot->addr, start_address); WRITE_DWORD(&boot->cmd, 3); for (i = 0; i < 300; ++i) { @@ -464,7 +464,7 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter, if ((READ_DWORD(&boot->signature) >> 16) == 0x4447) { DBG_LOG(("A(%d) Protocol startup time %d.%02d seconds", IoAdapter->ANum, (i / 100), (i % 100))) - started = 1; + started = 1; break; } } @@ -478,7 +478,7 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter, DBG_ERR(("A(%d) Adapter start failed 0x%08lx, TrapId=%08lx, debug=%08lx", IoAdapter->ANum, READ_DWORD(&boot->signature), TrapId, debug)) - DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); + DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot); if (IoAdapter->trapFnc) { (*(IoAdapter->trapFnc)) (IoAdapter); } @@ -490,11 +490,11 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter, IoAdapter->Initialized = true; /* - Check Interrupt - */ + Check Interrupt + */ IoAdapter->IrqCount = 0; p = DIVA_OS_MEM_ATTACH_CFG(IoAdapter); - WRITE_DWORD(p, (dword) ~ 0x03E00000); + WRITE_DWORD(p, (dword)~0x03E00000); DIVA_OS_MEM_DETACH_CFG(IoAdapter, p); a->ReadyInt = 1; a->ram_out(a, &PR_RAM->ReadyInt, 1); @@ -504,7 +504,7 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter, if (!IoAdapter->IrqCount) { DBG_ERR(("A: A(%d) interrupt test failed", IoAdapter->ANum)) - IoAdapter->Initialized = false; + IoAdapter->Initialized = false; IoAdapter->stop(IoAdapter); return (-1); } @@ -514,21 +514,21 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter, diva_xdi_display_adapter_features(IoAdapter->ANum); DBG_LOG(("A(%d) PRI adapter successfully started", IoAdapter->ANum)) - /* - Register with DIDD - */ - diva_xdi_didd_register_adapter(IoAdapter->ANum); + /* + Register with DIDD + */ + diva_xdi_didd_register_adapter(IoAdapter->ANum); return (0); } -static void diva_pri_clear_interrupts(diva_os_xdi_adapter_t * a) +static void diva_pri_clear_interrupts(diva_os_xdi_adapter_t *a) { PISDN_ADAPTER IoAdapter = &a->xdi_adapter; /* - clear any pending interrupt - */ + clear any pending interrupt + */ IoAdapter->disIrq(IoAdapter); IoAdapter->tst_irq(&IoAdapter->a); @@ -536,8 +536,8 @@ static void diva_pri_clear_interrupts(diva_os_xdi_adapter_t * a) IoAdapter->tst_irq(&IoAdapter->a); /* - kill pending dpcs - */ + kill pending dpcs + */ diva_os_cancel_soft_isr(&IoAdapter->req_soft_isr); diva_os_cancel_soft_isr(&IoAdapter->isr_soft_isr); } @@ -546,7 +546,7 @@ static void diva_pri_clear_interrupts(diva_os_xdi_adapter_t * a) ** Stop Adapter, but do not unmap/unregister - adapter ** will be restarted later */ -static int diva_pri_stop_adapter(diva_os_xdi_adapter_t * a) +static int diva_pri_stop_adapter(diva_os_xdi_adapter_t *a) { PISDN_ADAPTER IoAdapter = &a->xdi_adapter; int i = 100; @@ -557,18 +557,18 @@ static int diva_pri_stop_adapter(diva_os_xdi_adapter_t * a) if (!IoAdapter->Initialized) { DBG_ERR(("A: A(%d) can't stop PRI adapter - not running", IoAdapter->ANum)) - return (-1); /* nothing to stop */ + return (-1); /* nothing to stop */ } IoAdapter->Initialized = 0; /* - Disconnect Adapter from DIDD - */ + Disconnect Adapter from DIDD + */ diva_xdi_didd_remove_adapter(IoAdapter->ANum); /* - Stop interrupts - */ + Stop interrupts + */ a->clear_interrupts_proc = diva_pri_clear_interrupts; IoAdapter->a.ReadyInt = 1; IoAdapter->a.ram_inc(&IoAdapter->a, &PR_RAM->ReadyInt); @@ -581,12 +581,12 @@ static int diva_pri_stop_adapter(diva_os_xdi_adapter_t * a) a->clear_interrupts_proc = NULL; DBG_ERR(("A: A(%d) no final interrupt from PRI adapter", IoAdapter->ANum)) - } + } IoAdapter->a.ReadyInt = 0; /* - Stop and reset adapter - */ + Stop and reset adapter + */ IoAdapter->stop(IoAdapter); return (0); @@ -600,24 +600,24 @@ static int diva_pri_stop_adapter(diva_os_xdi_adapter_t * a) */ static int diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, - diva_xdi_um_cfg_cmd_t * cmd, int length) + diva_xdi_um_cfg_cmd_t *cmd, int length) { int ret = -1; if (cmd->adapter != a->controller) { DBG_ERR(("A: pri_cmd, invalid controller=%d != %d", cmd->adapter, a->controller)) - return (-1); + return (-1); } switch (cmd->command) { case DIVA_XDI_UM_CMD_GET_CARD_ORDINAL: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { *(dword *) a->xdi_mbox.data = - (dword) a->CardOrdinal; + (dword) a->CardOrdinal; a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY; ret = 0; } @@ -626,10 +626,10 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_SERIAL_NR: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { *(dword *) a->xdi_mbox.data = - (dword) a->xdi_adapter.serialNo; + (dword) a->xdi_adapter.serialNo; a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY; ret = 0; } @@ -638,7 +638,7 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_GET_PCI_HW_CONFIG: a->xdi_mbox.data_length = sizeof(dword) * 9; a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { int i; dword *data = (dword *) a->xdi_mbox.data; @@ -660,7 +660,7 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, ret = diva_pri_write_sdram_block(&a->xdi_adapter, cmd->command_data. write_sdram.offset, - (byte *) & cmd[1], + (byte *)&cmd[1], cmd->command_data. write_sdram.length, pri_is_rev_2_card(a-> @@ -683,22 +683,22 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_SET_PROTOCOL_FEATURES: a->xdi_adapter.features = - cmd->command_data.features.features; + cmd->command_data.features.features; a->xdi_adapter.a.protocol_capabilities = - a->xdi_adapter.features; + a->xdi_adapter.features; DBG_TRC(("Set raw protocol features (%08x)", a->xdi_adapter.features)) - ret = 0; + ret = 0; break; case DIVA_XDI_UM_CMD_GET_CARD_STATE: a->xdi_mbox.data_length = sizeof(dword); a->xdi_mbox.data = - diva_os_malloc(0, a->xdi_mbox.data_length); + diva_os_malloc(0, a->xdi_mbox.data_length); if (a->xdi_mbox.data) { dword *data = (dword *) a->xdi_mbox.data; if (!a->xdi_adapter.ram || - !a->xdi_adapter.reset || + !a->xdi_adapter.reset || !a->xdi_adapter.cfg) { *data = 3; } else if (a->xdi_adapter.trapped) { @@ -720,16 +720,16 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, case DIVA_XDI_UM_CMD_READ_SDRAM: if (a->xdi_adapter.Address) { if ( - (a->xdi_mbox.data_length = - cmd->command_data.read_sdram.length)) { + (a->xdi_mbox.data_length = + cmd->command_data.read_sdram.length)) { if ( - (a->xdi_mbox.data_length + - cmd->command_data.read_sdram.offset) < - a->xdi_adapter.MemorySize) { + (a->xdi_mbox.data_length + + cmd->command_data.read_sdram.offset) < + a->xdi_adapter.MemorySize) { a->xdi_mbox.data = - diva_os_malloc(0, - a->xdi_mbox. - data_length); + diva_os_malloc(0, + a->xdi_mbox. + data_length); if (a->xdi_mbox.data) { byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter); byte __iomem *src = p; @@ -753,7 +753,7 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, default: DBG_ERR(("A: A(%d) invalid cmd=%d", a->controller, cmd->command)) - } + } return (ret); } @@ -761,7 +761,7 @@ diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a, /* ** Get Serial Number */ -static int pri_get_serial_number(diva_os_xdi_adapter_t * a) +static int pri_get_serial_number(diva_os_xdi_adapter_t *a) { byte data[64]; int i; @@ -773,28 +773,28 @@ static int pri_get_serial_number(diva_os_xdi_adapter_t * a) /* * First set some GT6401x config registers before accessing the BOOT-ROM */ - config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); + config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); c = READ_BYTE(&config[0xc3c]); if (!(c & 0x08)) { WRITE_BYTE(&config[0xc3c], c); /* Base Address enable register */ } WRITE_BYTE(&config[LOW_BOOTCS_DREG], 0x00); WRITE_BYTE(&config[HI_BOOTCS_DREG], 0xFF); - DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); + DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); /* * Read only the last 64 bytes of manufacturing data */ memset(data, '\0', len); - flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter); + flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter); for (i = 0; i < len; i++) { data[i] = READ_BYTE(&flash[0x8000 - len + i]); } - DIVA_OS_MEM_DETACH_PROM(&a->xdi_adapter, flash); + DIVA_OS_MEM_DETACH_PROM(&a->xdi_adapter, flash); - config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); + config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); WRITE_BYTE(&config[LOW_BOOTCS_DREG], 0xFC); /* Disable FLASH EPROM access */ WRITE_BYTE(&config[HI_BOOTCS_DREG], 0xFF); - DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); + DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); if (memcmp(&data[48], "DIVAserverPR", 12)) { #if !defined(DIVA_PRI_NO_PCI_BIOS_WORKAROUND) /* { */ @@ -808,11 +808,11 @@ static int pri_get_serial_number(diva_os_xdi_adapter_t * a) addr1 = a->resources.pci.bar[1]; /* unused */ DBG_ERR(("A: apply Compaq BIOS workaround")) - DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - data[0], data[1], data[2], data[3], - data[4], data[5], data[6], data[7])) + DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + data[0], data[1], data[2], data[3], + data[4], data[5], data[6], data[7])) - Bus = a->resources.pci.bus; + Bus = a->resources.pci.bus; Slot = a->resources.pci.func; hdev = a->resources.pci.hdev; PCIread(Bus, Slot, 0x04, &cmd_org, sizeof(cmd_org), hdev); @@ -832,69 +832,69 @@ static int pri_get_serial_number(diva_os_xdi_adapter_t * a) a->resources.pci.bar[4] = addr1; /* - Try to read Flash again - */ + Try to read Flash again + */ len = sizeof(data); - config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); + config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); if (!(config[0xc3c] & 0x08)) { config[0xc3c] |= 0x08; /* Base Address enable register */ } config[LOW_BOOTCS_DREG] = 0x00; config[HI_BOOTCS_DREG] = 0xFF; - DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); + DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); memset(data, '\0', len); - flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter); + flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter); for (i = 0; i < len; i++) { data[i] = flash[0x8000 - len + i]; } - DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter, flash); - config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); + DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter, flash); + config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter); config[LOW_BOOTCS_DREG] = 0xFC; config[HI_BOOTCS_DREG] = 0xFF; - DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); + DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config); if (memcmp(&data[48], "DIVAserverPR", 12)) { DBG_ERR(("A: failed to read serial number")) - DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - data[0], data[1], data[2], data[3], - data[4], data[5], data[6], data[7])) - return (-1); + DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + data[0], data[1], data[2], data[3], + data[4], data[5], data[6], data[7])) + return (-1); } #else /* } { */ DBG_ERR(("A: failed to read DIVA signature word")) - DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - data[0], data[1], data[2], data[3], - data[4], data[5], data[6], data[7])) - DBG_LOG(("%02x:%02x:%02x:%02x", data[47], data[46], - data[45], data[44])) + DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + data[0], data[1], data[2], data[3], + data[4], data[5], data[6], data[7])) + DBG_LOG(("%02x:%02x:%02x:%02x", data[47], data[46], + data[45], data[44])) #endif /* } */ - } + } a->xdi_adapter.serialNo = - (data[47] << 24) | (data[46] << 16) | (data[45] << 8) | - data[44]; + (data[47] << 24) | (data[46] << 16) | (data[45] << 8) | + data[44]; if (!a->xdi_adapter.serialNo || (a->xdi_adapter.serialNo == 0xffffffff)) { a->xdi_adapter.serialNo = 0; DBG_ERR(("A: failed to read serial number")) - return (-1); + return (-1); } DBG_LOG(("Serial No. : %ld", a->xdi_adapter.serialNo)) - DBG_TRC(("Board Revision : %d.%02d", (int) data[41], - (int) data[40])) - DBG_TRC(("PLD revision : %d.%02d", (int) data[33], - (int) data[32])) - DBG_TRC(("Boot loader version : %d.%02d", (int) data[37], - (int) data[36])) + DBG_TRC(("Board Revision : %d.%02d", (int) data[41], + (int) data[40])) + DBG_TRC(("PLD revision : %d.%02d", (int) data[33], + (int) data[32])) + DBG_TRC(("Boot loader version : %d.%02d", (int) data[37], + (int) data[36])) - DBG_TRC(("Manufacturing Date : %d/%02d/%02d (yyyy/mm/dd)", - (int) ((data[28] > 90) ? 1900 : 2000) + - (int) data[28], (int) data[29], (int) data[30])) + DBG_TRC(("Manufacturing Date : %d/%02d/%02d (yyyy/mm/dd)", + (int) ((data[28] > 90) ? 1900 : 2000) + + (int) data[28], (int) data[29], (int) data[30])) - return (0); + return (0); } void diva_os_prepare_pri2_functions(PISDN_ADAPTER IoAdapter) @@ -909,7 +909,7 @@ void diva_os_prepare_pri_functions(PISDN_ADAPTER IoAdapter) ** Checks presence of DSP on board */ static int -dsp_check_presence(volatile byte __iomem * addr, volatile byte __iomem * data, int dsp) +dsp_check_presence(volatile byte __iomem *addr, volatile byte __iomem *data, int dsp) { word pattern; @@ -922,7 +922,7 @@ dsp_check_presence(volatile byte __iomem * addr, volatile byte __iomem * data, i if (pattern != DSP_SIGNATURE_PROBE_WORD) { DBG_TRC(("W: DSP[%d] %04x(is) != %04x(should)", dsp, pattern, DSP_SIGNATURE_PROBE_WORD)) - return (-1); + return (-1); } WRITE_WORD(addr, 0x4000); @@ -931,15 +931,15 @@ dsp_check_presence(volatile byte __iomem * addr, volatile byte __iomem * data, i WRITE_WORD(addr, 0x4000); pattern = READ_WORD(data); - if (pattern != (word) ~ DSP_SIGNATURE_PROBE_WORD) { + if (pattern != (word)~DSP_SIGNATURE_PROBE_WORD) { DBG_ERR(("A: DSP[%d] %04x(is) != %04x(should)", - dsp, pattern, (word) ~ DSP_SIGNATURE_PROBE_WORD)) - return (-2); + dsp, pattern, (word)~DSP_SIGNATURE_PROBE_WORD)) + return (-2); } DBG_TRC(("DSP[%d] present", dsp)) - return (0); + return (0); } @@ -952,7 +952,7 @@ dsp_check_presence(volatile byte __iomem * addr, volatile byte __iomem * data, i ** ... ** Bit 29 - DSP30 */ -static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t * a) +static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t *a) { byte __iomem *base; byte __iomem *p; @@ -1008,8 +1008,8 @@ static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t * a) diva_os_wait(5); /* - Verify modules - */ + Verify modules + */ for (dsp_row = 0; dsp_row < 4; dsp_row++) { row_state = ((ret >> (dsp_row * 7)) & 0x7F); if (row_state && (row_state != 0x7F)) { @@ -1018,35 +1018,35 @@ static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t * a) DBG_ERR(("A: MODULE[%d]-DSP[%d] failed", dsp_row + 1, dsp_index + 1)) - } + } } } } if (!(ret & 0x10000000)) { DBG_ERR(("A: ON BOARD-DSP[1] failed")) - } + } if (!(ret & 0x20000000)) { DBG_ERR(("A: ON BOARD-DSP[2] failed")) - } + } /* - Print module population now - */ - DBG_LOG(("+-----------------------+")) - DBG_LOG(("| DSP MODULE POPULATION |")) - DBG_LOG(("+-----------------------+")) - DBG_LOG(("| 1 | 2 | 3 | 4 |")) - DBG_LOG(("+-----------------------+")) - DBG_LOG(("| %s | %s | %s | %s |", - ((ret >> (0 * 7)) & 0x7F) ? "Y" : "N", - ((ret >> (1 * 7)) & 0x7F) ? "Y" : "N", - ((ret >> (2 * 7)) & 0x7F) ? "Y" : "N", - ((ret >> (3 * 7)) & 0x7F) ? "Y" : "N")) + Print module population now + */ DBG_LOG(("+-----------------------+")) - - DBG_LOG(("DSP's(present-absent):%08x-%08x", ret, - ~ret & 0x3fffffff)) - - return (ret); + DBG_LOG(("| DSP MODULE POPULATION |")) + DBG_LOG(("+-----------------------+")) + DBG_LOG(("| 1 | 2 | 3 | 4 |")) + DBG_LOG(("+-----------------------+")) + DBG_LOG(("| %s | %s | %s | %s |", + ((ret >> (0 * 7)) & 0x7F) ? "Y" : "N", + ((ret >> (1 * 7)) & 0x7F) ? "Y" : "N", + ((ret >> (2 * 7)) & 0x7F) ? "Y" : "N", + ((ret >> (3 * 7)) & 0x7F) ? "Y" : "N")) + DBG_LOG(("+-----------------------+")) + + DBG_LOG(("DSP's(present-absent):%08x-%08x", ret, + ~ret & 0x3fffffff)) + + return (ret); } diff --git a/drivers/isdn/hardware/eicon/os_pri.h b/drivers/isdn/hardware/eicon/os_pri.h index a7c42f94d78a..537c74d042e7 100644 --- a/drivers/isdn/hardware/eicon/os_pri.h +++ b/drivers/isdn/hardware/eicon/os_pri.h @@ -3,6 +3,6 @@ #ifndef __DIVA_OS_PRI_REV_1_H__ #define __DIVA_OS_PRI_REV_1_H__ -int diva_pri_init_card(diva_os_xdi_adapter_t * a); +int diva_pri_init_card(diva_os_xdi_adapter_t *a); #endif diff --git a/drivers/isdn/hardware/eicon/pc.h b/drivers/isdn/hardware/eicon/pc.h index bf6b01812400..889dc984bbca 100644 --- a/drivers/isdn/hardware/eicon/pc.h +++ b/drivers/isdn/hardware/eicon/pc.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef PC_H_INCLUDED /* { */ @@ -29,42 +29,42 @@ /* buffer definition */ /*------------------------------------------------------------------*/ typedef struct { - word length; /* length of data/parameter field */ - byte P[270]; /* data/parameter field */ + word length; /* length of data/parameter field */ + byte P[270]; /* data/parameter field */ } PBUFFER; /*------------------------------------------------------------------*/ /* dual port ram structure */ /*------------------------------------------------------------------*/ struct dual { - byte Req; /* request register */ - byte ReqId; /* request task/entity identification */ - byte Rc; /* return code register */ - byte RcId; /* return code task/entity identification */ - byte Ind; /* Indication register */ - byte IndId; /* Indication task/entity identification */ - byte IMask; /* Interrupt Mask Flag */ - byte RNR; /* Receiver Not Ready (set by PC) */ - byte XLock; /* XBuffer locked Flag */ - byte Int; /* ISDN-S interrupt */ - byte ReqCh; /* Channel field for layer-3 Requests */ - byte RcCh; /* Channel field for layer-3 Returncodes */ - byte IndCh; /* Channel field for layer-3 Indications */ - byte MInd; /* more data indication field */ - word MLength; /* more data total packet length */ - byte ReadyInt; /* request field for ready interrupt */ - byte SWReg; /* Software register for special purposes */ - byte Reserved[11]; /* reserved space */ - byte InterfaceType; /* interface type 1=16K interface */ - word Signature; /* ISDN-S adapter Signature (GD) */ - PBUFFER XBuffer; /* Transmit Buffer */ - PBUFFER RBuffer; /* Receive Buffer */ + byte Req; /* request register */ + byte ReqId; /* request task/entity identification */ + byte Rc; /* return code register */ + byte RcId; /* return code task/entity identification */ + byte Ind; /* Indication register */ + byte IndId; /* Indication task/entity identification */ + byte IMask; /* Interrupt Mask Flag */ + byte RNR; /* Receiver Not Ready (set by PC) */ + byte XLock; /* XBuffer locked Flag */ + byte Int; /* ISDN-S interrupt */ + byte ReqCh; /* Channel field for layer-3 Requests */ + byte RcCh; /* Channel field for layer-3 Returncodes */ + byte IndCh; /* Channel field for layer-3 Indications */ + byte MInd; /* more data indication field */ + word MLength; /* more data total packet length */ + byte ReadyInt; /* request field for ready interrupt */ + byte SWReg; /* Software register for special purposes */ + byte Reserved[11]; /* reserved space */ + byte InterfaceType; /* interface type 1=16K interface */ + word Signature; /* ISDN-S adapter Signature (GD) */ + PBUFFER XBuffer; /* Transmit Buffer */ + PBUFFER RBuffer; /* Receive Buffer */ }; /*------------------------------------------------------------------*/ /* SWReg Values (0 means no command) */ /*------------------------------------------------------------------*/ #define SWREG_DIE_WITH_LEDON 0x01 -#define SWREG_HALT_CPU 0x02 /* Push CPU into a while(1) loop */ +#define SWREG_HALT_CPU 0x02 /* Push CPU into a while (1) loop */ /*------------------------------------------------------------------*/ /* Id Fields Coding */ /*------------------------------------------------------------------*/ @@ -273,7 +273,7 @@ struct dual #define MORE 0xa0 /* more data */ #define SDNCMPL 0xa1 /* sending complete */ #define CL 0xb0 /* congestion level */ - /* codeset 0 */ +/* codeset 0 */ #define SMSG 0x00 /* segmented message */ #define BC 0x04 /* Bearer Capability */ #define CAU 0x08 /* cause */ @@ -307,7 +307,7 @@ struct dual #define NLC 0x21 /* network layer configuration */ #define REDIRECT_IE 0x22 /* redirection request/indication data */ #define REDIRECT_NET_IE 0x23 /* redirection network override data */ - /* codeset 6 */ +/* codeset 6 */ #define SIN 0x01 /* service indicator */ #define CIF 0x02 /* charging information */ #define DATE 0x03 /* date */ @@ -387,13 +387,13 @@ struct dual #define SMASK_CCNR 0x00000200 #define SMASK_CONF 0x00000400 /* ---------------------------------------------- - Types of transfers used to transfer the - information in the 'struct RC->Reserved2[8]' - The information is transferred as 2 dwords - (2 4Byte unsigned values) - First of them is the transfer type. - 2^32-1 possible messages are possible in this way. - The context of the second one had no meaning + Types of transfers used to transfer the + information in the 'struct RC->Reserved2[8]' + The information is transferred as 2 dwords + (2 4Byte unsigned values) + First of them is the transfer type. + 2^32-1 possible messages are possible in this way. + The context of the second one had no meaning ---------------------------------------------- */ #define DIVA_RC_TYPE_NONE 0x00000000 #define DIVA_RC_TYPE_REMOVE_COMPLETE 0x00000008 @@ -402,14 +402,14 @@ struct dual #define DIVA_RC_TYPE_OK_FC 0x0000000b #define DIVA_RC_TYPE_RX_DMA 0x0000000c /* ------------------------------------------------------ - IO Control codes for IN BAND SIGNALING + IO Control codes for IN BAND SIGNALING ------------------------------------------------------ */ #define CTRL_L1_SET_SIG_ID 5 #define CTRL_L1_SET_DAD 6 #define CTRL_L1_RESOURCES 7 /* ------------------------------------------------------ */ /* ------------------------------------------------------ - Layer 2 types + Layer 2 types ------------------------------------------------------ */ #define X75T 1 /* x.75 for ttx */ #define TRF 2 /* transparent with hdlc framing */ @@ -439,31 +439,31 @@ struct dual #define PIAFS_UDATA_ABILITY_DCDON 0x01 #define PIAFS_UDATA_ABILITY_DDI 0x80 /* -DLC of PIAFS : -Byte | 8 7 6 5 4 3 2 1 ------+-------------------------------------------------------- - 0 | 0 0 1 0 0 0 0 0 Data Link Configuration - 1 | X X X X X X X X Length of IE (at least 15 Bytes) - 2 | 0 0 0 0 0 0 0 0 max. information field, LOW byte (not used, fix 73 Bytes) - 3 | 0 0 0 0 0 0 0 0 max. information field, HIGH byte (not used, fix 73 Bytes) - 4 | 0 0 0 0 0 0 0 0 address A (not used) - 5 | 0 0 0 0 0 0 0 0 address B (not used) - 6 | 0 0 0 0 0 0 0 0 Mode (not used, fix 128) - 7 | 0 0 0 0 0 0 0 0 Window Size (not used, fix 127) - 8 | X X X X X X X X XID Length, Low Byte (at least 7 Bytes) - 9 | X X X X X X X X XID Length, High Byte + DLC of PIAFS : + Byte | 8 7 6 5 4 3 2 1 + -----+-------------------------------------------------------- + 0 | 0 0 1 0 0 0 0 0 Data Link Configuration + 1 | X X X X X X X X Length of IE (at least 15 Bytes) + 2 | 0 0 0 0 0 0 0 0 max. information field, LOW byte (not used, fix 73 Bytes) + 3 | 0 0 0 0 0 0 0 0 max. information field, HIGH byte (not used, fix 73 Bytes) + 4 | 0 0 0 0 0 0 0 0 address A (not used) + 5 | 0 0 0 0 0 0 0 0 address B (not used) + 6 | 0 0 0 0 0 0 0 0 Mode (not used, fix 128) + 7 | 0 0 0 0 0 0 0 0 Window Size (not used, fix 127) + 8 | X X X X X X X X XID Length, Low Byte (at least 7 Bytes) + 9 | X X X X X X X X XID Length, High Byte 10 | 0 0 0 0 0 C V S PIAFS Protocol Speed configuration -> Note(1) - | S = 0 -> Protocol Speed is 32K - | S = 1 -> Protocol Speed is 64K - | V = 0 -> Protocol Speed is fixed - | V = 1 -> Protocol Speed is variable - | C = 0 -> speed setting according to standard - | C = 1 -> speed setting for chinese implementation + | S = 0 -> Protocol Speed is 32K + | S = 1 -> Protocol Speed is 64K + | V = 0 -> Protocol Speed is fixed + | V = 1 -> Protocol Speed is variable + | C = 0 -> speed setting according to standard + | C = 1 -> speed setting for chinese implementation 11 | 0 0 0 0 0 0 R T P0 - V42bis Compression enable/disable, Low Byte - | T = 0 -> Transmit Direction enable - | T = 1 -> Transmit Direction disable - | R = 0 -> Receive Direction enable - | R = 1 -> Receive Direction disable + | T = 0 -> Transmit Direction enable + | T = 1 -> Transmit Direction disable + | R = 0 -> Receive Direction enable + | R = 1 -> Receive Direction disable 13 | 0 0 0 0 0 0 0 0 P0 - V42bis Compression enable/disable, High Byte 14 | X X X X X X X X P1 - V42bis Dictionary Size, Low Byte 15 | X X X X X X X X P1 - V42bis Dictionary Size, High Byte @@ -472,61 +472,61 @@ Byte | 8 7 6 5 4 3 2 1 18 | X X X X X X X X PIAFS extension length 19 | 1 0 0 0 0 0 0 0 PIAFS extension Id (0x80) - UDATA abilities 20 | U 0 0 0 0 0 0 D UDATA abilities -> Note (2) - | up to now the following Bits are defined: - | D - signal DCD ON - | U - use extensive UDATA control communication - | for DDI test application -+ Note (1): ----------+------+-----------------------------------------+ -| PIAFS Protocol | Bit | | -| Speed configuration | S | Bit 1 - Protocol Speed | -| | | 0 - 32K | -| | | 1 - 64K (default) | -| | V | Bit 2 - Variable Protocol Speed | -| | | 0 - Speed is fix | -| | | 1 - Speed is variable (default) | -| | | OVERWRITES 32k Bit 1 | -| | C | Bit 3 0 - Speed Settings according to | -| | | PIAFS specification | -| | | 1 - Speed setting for chinese | -| | | PIAFS implementation | -| | | Explanation for chinese speed settings: | -| | | if Bit 3 is set the following | -| | | rules apply: | -| | | Bit1=0 Bit2=0: 32k fix | -| | | Bit1=1 Bit2=0: 64k fix | -| | | Bit1=0 Bit2=1: PIAFS is trying | -| | | to negotiate 32k is that is | -| | | not possible it tries to | -| | | negotiate 64k | -| | | Bit1=1 Bit2=1: PIAFS is trying | -| | | to negotiate 64k is that is | -| | | not possible it tries to | -| | | negotiate 32k | -+ Note (2): ----------+------+-----------------------------------------+ -| PIAFS | Bit | this byte defines the usage of UDATA | -| Implementation | | control communication | -| UDATA usage | D | Bit 1 - DCD-ON signalling | -| | | 0 - no DCD-ON is signalled | -| | | (default) | -| | | 1 - DCD-ON will be signalled | -| | U | Bit 8 - DDI test application UDATA | -| | | control communication | -| | | 0 - no UDATA control | -| | | communication (default) | -| | | sets as well the DCD-ON | -| | | signalling | -| | | 1 - UDATA control communication | -| | | ATTENTION: Do not use these | -| | | setting if you | -| | | are not really | -| | | that you need it | -| | | and you know | -| | | exactly what you | -| | | are doing. | -| | | You can easily | -| | | disable any | -| | | data transfer. | -+---------------------+------+-----------------------------------------+ + | up to now the following Bits are defined: + | D - signal DCD ON + | U - use extensive UDATA control communication + | for DDI test application + + Note (1): ----------+------+-----------------------------------------+ + | PIAFS Protocol | Bit | | + | Speed configuration | S | Bit 1 - Protocol Speed | + | | | 0 - 32K | + | | | 1 - 64K (default) | + | | V | Bit 2 - Variable Protocol Speed | + | | | 0 - Speed is fix | + | | | 1 - Speed is variable (default) | + | | | OVERWRITES 32k Bit 1 | + | | C | Bit 3 0 - Speed Settings according to | + | | | PIAFS specification | + | | | 1 - Speed setting for chinese | + | | | PIAFS implementation | + | | | Explanation for chinese speed settings: | + | | | if Bit 3 is set the following | + | | | rules apply: | + | | | Bit1=0 Bit2=0: 32k fix | + | | | Bit1=1 Bit2=0: 64k fix | + | | | Bit1=0 Bit2=1: PIAFS is trying | + | | | to negotiate 32k is that is | + | | | not possible it tries to | + | | | negotiate 64k | + | | | Bit1=1 Bit2=1: PIAFS is trying | + | | | to negotiate 64k is that is | + | | | not possible it tries to | + | | | negotiate 32k | + + Note (2): ----------+------+-----------------------------------------+ + | PIAFS | Bit | this byte defines the usage of UDATA | + | Implementation | | control communication | + | UDATA usage | D | Bit 1 - DCD-ON signalling | + | | | 0 - no DCD-ON is signalled | + | | | (default) | + | | | 1 - DCD-ON will be signalled | + | | U | Bit 8 - DDI test application UDATA | + | | | control communication | + | | | 0 - no UDATA control | + | | | communication (default) | + | | | sets as well the DCD-ON | + | | | signalling | + | | | 1 - UDATA control communication | + | | | ATTENTION: Do not use these | + | | | setting if you | + | | | are not really | + | | | that you need it | + | | | and you know | + | | | exactly what you | + | | | are doing. | + | | | You can easily | + | | | disable any | + | | | data transfer. | + +---------------------+------+-----------------------------------------+ */ /* ------------------------------------------------------ LISTENER DLC DEFINITIONS @@ -712,11 +712,11 @@ Byte | 8 7 6 5 4 3 2 1 /*#define RESERVED85 0x85*/ #define ADVICE_OF_CHARGE 0x86 /*1111 0001 -to -1111 1111 -F1H - Reserved for network operator use -to -FFH*/ + to + 1111 1111 + F1H - Reserved for network operator use + to + FFH*/ /* Parameter Types */ #define DATE_AND_TIME 1 #define CLI_PARAMETER_TYPE 2 diff --git a/drivers/isdn/hardware/eicon/pc_init.h b/drivers/isdn/hardware/eicon/pc_init.h index a616fc9d32e9..d1d00866e8d4 100644 --- a/drivers/isdn/hardware/eicon/pc_init.h +++ b/drivers/isdn/hardware/eicon/pc_init.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef PC_INIT_H_ @@ -57,15 +57,15 @@ 0x0060 length (8) 0x0061 RBS Answer Delay 0x0062 RBS Config Bit 3, 4: - 0 0 -> Wink Start - 1 0 -> Loop Start - 0 1 -> Ground Start - 1 1 -> reserved - Bit 5, 6: - 0 0 -> Pulse Dial -> Rotary - 1 0 -> DTMF - 0 1 -> MF - 1 1 -> reserved + 0 0 -> Wink Start + 1 0 -> Loop Start + 0 1 -> Ground Start + 1 1 -> reserved + Bit 5, 6: + 0 0 -> Pulse Dial -> Rotary + 1 0 -> DTMF + 0 1 -> MF + 1 1 -> reserved 0x0063 RBS RX Digit Timeout 0x0064 RBS Bearer Capability 0x0065-0x0069 RBS Debug Mask diff --git a/drivers/isdn/hardware/eicon/pc_maint.h b/drivers/isdn/hardware/eicon/pc_maint.h index 352ab8dafb22..496f018fb5a2 100644 --- a/drivers/isdn/hardware/eicon/pc_maint.h +++ b/drivers/isdn/hardware/eicon/pc_maint.h @@ -1,31 +1,31 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifdef PLATFORM_GT_32BIT /* #define POINTER_32BIT byte * __ptr32 */ -#define POINTER_32BIT dword +#define POINTER_32BIT dword #else #define POINTER_32BIT byte * #endif @@ -70,91 +70,91 @@ #define NO_EVENT 1 struct DSigStruc { - byte Id; - byte u; - byte listen; - byte active; - byte sin[3]; - byte bc[6]; - byte llc[6]; - byte hlc[6]; - byte oad[20]; + byte Id; + byte u; + byte listen; + byte active; + byte sin[3]; + byte bc[6]; + byte llc[6]; + byte hlc[6]; + byte oad[20]; }; struct BL1Struc { - dword cx_b1; - dword cx_b2; - dword cr_b1; - dword cr_b2; - dword px_b1; - dword px_b2; - dword pr_b1; - dword pr_b2; - word er_b1; - word er_b2; + dword cx_b1; + dword cx_b2; + dword cr_b1; + dword cr_b2; + dword px_b1; + dword px_b2; + dword pr_b1; + dword pr_b2; + word er_b1; + word er_b2; }; struct L2Struc { - dword XTotal; - dword RTotal; - word XError; - word RError; + dword XTotal; + dword RTotal; + word XError; + word RError; }; struct OSStruc { - dword free_n; + dword free_n; }; typedef union { - struct DSigStruc DSigStats; - struct BL1Struc BL1Stats; - struct L2Struc L2Stats; - struct OSStruc OSStats; - byte b[BUFFER_SZ]; - word w[BUFFER_SZ>>1]; - word l[BUFFER_SZ>>2]; /* word is wrong, do not use! Use 'd' instead. */ - dword d[BUFFER_SZ>>2]; + struct DSigStruc DSigStats; + struct BL1Struc BL1Stats; + struct L2Struc L2Stats; + struct OSStruc OSStats; + byte b[BUFFER_SZ]; + word w[BUFFER_SZ >> 1]; + word l[BUFFER_SZ >> 2]; /* word is wrong, do not use! Use 'd' instead. */ + dword d[BUFFER_SZ >> 2]; } BUFFER; typedef union { - struct DSigStruc DSigStats; - struct BL1Struc BL1Stats; - struct L2Struc L2Stats; - struct OSStruc OSStats; - byte b[MIPS_BUFFER_SZ]; - word w[MIPS_BUFFER_SZ>>1]; - word l[BUFFER_SZ>>2]; /* word is wrong, do not use! Use 'd' instead. */ - dword d[MIPS_BUFFER_SZ>>2]; + struct DSigStruc DSigStats; + struct BL1Struc BL1Stats; + struct L2Struc L2Stats; + struct OSStruc OSStats; + byte b[MIPS_BUFFER_SZ]; + word w[MIPS_BUFFER_SZ >> 1]; + word l[BUFFER_SZ >> 2]; /* word is wrong, do not use! Use 'd' instead. */ + dword d[MIPS_BUFFER_SZ >> 2]; } MIPS_BUFFER; #if !defined(MIPS_SCOM) struct pc_maint { - byte req; - byte rc; - POINTER_32BIT mem; - short length; - word port; - byte fill[6]; - BUFFER data; + byte req; + byte rc; + POINTER_32BIT mem; + short length; + word port; + byte fill[6]; + BUFFER data; }; #else struct pc_maint { - byte req; - byte rc; - byte reserved[2]; /* R3000 alignment ... */ - POINTER_32BIT mem; - short length; - word port; - byte fill[4]; /* data at offset 16 */ - BUFFER data; + byte req; + byte rc; + byte reserved[2]; /* R3000 alignment ... */ + POINTER_32BIT mem; + short length; + word port; + byte fill[4]; /* data at offset 16 */ + BUFFER data; }; #endif struct mi_pc_maint { - byte req; - byte rc; - byte reserved[2]; /* R3000 alignment ... */ - POINTER_32BIT mem; - short length; - word port; - byte fill[4]; /* data at offset 16 */ - MIPS_BUFFER data; + byte req; + byte rc; + byte reserved[2]; /* R3000 alignment ... */ + POINTER_32BIT mem; + short length; + word port; + byte fill[4]; /* data at offset 16 */ + MIPS_BUFFER data; }; diff --git a/drivers/isdn/hardware/eicon/pkmaint.h b/drivers/isdn/hardware/eicon/pkmaint.h index 722f85fe42f6..cf3fb14a8e6f 100644 --- a/drivers/isdn/hardware/eicon/pkmaint.h +++ b/drivers/isdn/hardware/eicon/pkmaint.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_XDI_OS_DEPENDENT_PACK_MAIN_ON_BYTE_INC__ @@ -28,17 +28,16 @@ /* - Only one purpose of this compiler dependent file to pack - structures, described in pc_maint.h so that no padding - will be included. + Only one purpose of this compiler dependent file to pack + structures, described in pc_maint.h so that no padding + will be included. - With microsoft compile it is done by "pshpack1.h" and - after is restored by "poppack.h" - */ + With microsoft compile it is done by "pshpack1.h" and + after is restored by "poppack.h" +*/ #include "pc_maint.h" #endif - diff --git a/drivers/isdn/hardware/eicon/platform.h b/drivers/isdn/hardware/eicon/platform.h index 15d4942de53b..7331c3b14a5f 100644 --- a/drivers/isdn/hardware/eicon/platform.h +++ b/drivers/isdn/hardware/eicon/platform.h @@ -1,10 +1,10 @@ /* $Id: platform.h,v 1.37.4.6 2005/01/31 12:22:20 armin Exp $ * * platform.h - * + * * * Copyright 2000-2003 by Armin Schindler (mac@melware.de) - * Copyright 2000 Eicon Networks + * Copyright 2000 Eicon Networks * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. @@ -112,40 +112,40 @@ #define DIVA_OS_MEM_ATTACH_CONFIG(a) ((a)->Config) #define DIVA_OS_MEM_ATTACH_CONTROL(a) ((a)->Control) -#define DIVA_OS_MEM_DETACH_RAM(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_PORT(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_PROM(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_CTLREG(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_RESET(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_CFG(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_ADDRESS(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_CONFIG(a, x) do { } while(0) -#define DIVA_OS_MEM_DETACH_CONTROL(a, x) do { } while(0) +#define DIVA_OS_MEM_DETACH_RAM(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_PORT(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_PROM(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_CTLREG(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_RESET(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_CFG(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_ADDRESS(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_CONFIG(a, x) do { } while (0) +#define DIVA_OS_MEM_DETACH_CONTROL(a, x) do { } while (0) #define DIVA_INVALID_FILE_HANDLE ((dword)(-1)) -#define DIVAS_CONTAINING_RECORD(address, type, field) \ - ((type *)((char*)(address) - (char*)(&((type *)0)->field))) +#define DIVAS_CONTAINING_RECORD(address, type, field) \ + ((type *)((char *)(address) - (char *)(&((type *)0)->field))) -extern int sprintf(char *, const char*, ...); +extern int sprintf(char *, const char *, ...); -typedef void* LIST_ENTRY; +typedef void *LIST_ENTRY; -typedef char DEVICE_NAME[64]; -typedef struct _ISDN_ADAPTER ISDN_ADAPTER; -typedef struct _ISDN_ADAPTER* PISDN_ADAPTER; +typedef char DEVICE_NAME[64]; +typedef struct _ISDN_ADAPTER ISDN_ADAPTER; +typedef struct _ISDN_ADAPTER *PISDN_ADAPTER; -typedef void (* DIVA_DI_PRINTF) (unsigned char *, ...); +typedef void (*DIVA_DI_PRINTF)(unsigned char *, ...); #include "debuglib.h" #define dtrc(p) DBG_PRV0(p) -#define dbug(a,p) DBG_PRV1(p) +#define dbug(a, p) DBG_PRV1(p) -typedef struct e_info_s E_INFO ; +typedef struct e_info_s E_INFO; typedef char diva_os_dependent_devica_name_t[64]; -typedef void* PDEVICE_OBJECT; +typedef void *PDEVICE_OBJECT; struct _diva_os_soft_isr; struct _diva_os_timer; @@ -156,13 +156,13 @@ void diva_log_info(unsigned char *, ...); /* ** XDI DIDD Interface */ -void diva_xdi_didd_register_adapter (int card); -void diva_xdi_didd_remove_adapter (int card); +void diva_xdi_didd_register_adapter(int card); +void diva_xdi_didd_remove_adapter(int card); /* ** memory allocation */ -static __inline__ void* diva_os_malloc (unsigned long flags, unsigned long size) +static __inline__ void *diva_os_malloc(unsigned long flags, unsigned long size) { void *ret = NULL; @@ -171,7 +171,7 @@ static __inline__ void* diva_os_malloc (unsigned long flags, unsigned long size) } return (ret); } -static __inline__ void diva_os_free (unsigned long flags, void* ptr) +static __inline__ void diva_os_free(unsigned long flags, void *ptr) { vfree(ptr); } @@ -200,34 +200,34 @@ static __inline__ void diva_os_wait(dword mSec) /* ** PCI Configuration space access */ -void PCIwrite (byte bus, byte func, int offset, void* data, int length, void* pci_dev_handle); -void PCIread (byte bus, byte func, int offset, void* data, int length, void* pci_dev_handle); +void PCIwrite(byte bus, byte func, int offset, void *data, int length, void *pci_dev_handle); +void PCIread(byte bus, byte func, int offset, void *data, int length, void *pci_dev_handle); /* ** I/O Port utilities */ -int diva_os_register_io_port (void *adapter, int register, unsigned long port, - unsigned long length, const char* name, int id); +int diva_os_register_io_port(void *adapter, int register, unsigned long port, + unsigned long length, const char *name, int id); /* ** I/O port access abstraction */ -byte inpp (void __iomem *); -word inppw (void __iomem *); -void inppw_buffer (void __iomem *, void*, int); -void outppw (void __iomem *, word); -void outppw_buffer (void __iomem * , void*, int); -void outpp (void __iomem *, word); +byte inpp(void __iomem *); +word inppw(void __iomem *); +void inppw_buffer(void __iomem *, void *, int); +void outppw(void __iomem *, word); +void outppw_buffer(void __iomem * , void*, int); +void outpp(void __iomem *, word); /* -** IRQ +** IRQ */ typedef struct _diva_os_adapter_irq_info { - byte irq_nr; - int registered; - char irq_name[24]; + byte irq_nr; + int registered; + char irq_name[24]; } diva_os_adapter_irq_info_t; -int diva_os_register_irq (void* context, byte irq, const char* name); -void diva_os_remove_irq (void* context, byte irq); +int diva_os_register_irq(void *context, byte irq, const char *name); +void diva_os_remove_irq(void *context, byte irq); #define diva_os_in_irq() in_irq() @@ -236,58 +236,58 @@ void diva_os_remove_irq (void* context, byte irq); */ typedef long diva_os_spin_lock_magic_t; typedef spinlock_t diva_os_spin_lock_t; -static __inline__ int diva_os_initialize_spin_lock (spinlock_t *lock, void * unused) { \ - spin_lock_init (lock); return(0); } -static __inline__ void diva_os_enter_spin_lock (diva_os_spin_lock_t* a, \ - diva_os_spin_lock_magic_t* old_irql, \ - void* dbg) { spin_lock_bh(a); } -static __inline__ void diva_os_leave_spin_lock (diva_os_spin_lock_t* a, \ - diva_os_spin_lock_magic_t* old_irql, \ - void* dbg) { spin_unlock_bh(a); } +static __inline__ int diva_os_initialize_spin_lock(spinlock_t *lock, void *unused) { \ + spin_lock_init(lock); return (0); } +static __inline__ void diva_os_enter_spin_lock(diva_os_spin_lock_t *a, \ + diva_os_spin_lock_magic_t *old_irql, \ + void *dbg) { spin_lock_bh(a); } +static __inline__ void diva_os_leave_spin_lock(diva_os_spin_lock_t *a, \ + diva_os_spin_lock_magic_t *old_irql, \ + void *dbg) { spin_unlock_bh(a); } -#define diva_os_destroy_spin_lock(a,b) do { } while(0) +#define diva_os_destroy_spin_lock(a, b) do { } while (0) /* ** Deffered processing framework */ -typedef int (*diva_os_isr_callback_t)(struct _ISDN_ADAPTER*); -typedef void (*diva_os_soft_isr_callback_t)(struct _diva_os_soft_isr* psoft_isr, void* context); +typedef int (*diva_os_isr_callback_t)(struct _ISDN_ADAPTER *); +typedef void (*diva_os_soft_isr_callback_t)(struct _diva_os_soft_isr *psoft_isr, void *context); typedef struct _diva_os_soft_isr { - void* object; - diva_os_soft_isr_callback_t callback; - void* callback_context; - char dpc_thread_name[24]; + void *object; + diva_os_soft_isr_callback_t callback; + void *callback_context; + char dpc_thread_name[24]; } diva_os_soft_isr_t; -int diva_os_initialize_soft_isr (diva_os_soft_isr_t* psoft_isr, diva_os_soft_isr_callback_t callback, void* callback_context); -int diva_os_schedule_soft_isr (diva_os_soft_isr_t* psoft_isr); -int diva_os_cancel_soft_isr (diva_os_soft_isr_t* psoft_isr); -void diva_os_remove_soft_isr (diva_os_soft_isr_t* psoft_isr); +int diva_os_initialize_soft_isr(diva_os_soft_isr_t *psoft_isr, diva_os_soft_isr_callback_t callback, void *callback_context); +int diva_os_schedule_soft_isr(diva_os_soft_isr_t *psoft_isr); +int diva_os_cancel_soft_isr(diva_os_soft_isr_t *psoft_isr); +void diva_os_remove_soft_isr(diva_os_soft_isr_t *psoft_isr); /* Get time service - */ -void diva_os_get_time (dword* sec, dword* usec); +*/ +void diva_os_get_time(dword *sec, dword *usec); /* ** atomic operation, fake because we use threads */ typedef int diva_os_atomic_t; static diva_os_atomic_t __inline__ -diva_os_atomic_increment(diva_os_atomic_t* pv) +diva_os_atomic_increment(diva_os_atomic_t *pv) { - *pv += 1; - return (*pv); + *pv += 1; + return (*pv); } static diva_os_atomic_t __inline__ -diva_os_atomic_decrement(diva_os_atomic_t* pv) +diva_os_atomic_decrement(diva_os_atomic_t *pv) { - *pv -= 1; - return (*pv); + *pv -= 1; + return (*pv); } -/* +/* ** CAPI SECTION */ #define NO_CORNETN @@ -319,9 +319,9 @@ diva_os_atomic_decrement(diva_os_atomic_t* pv) #define READ_WORD(addr) readw(addr) #define READ_DWORD(addr) readl(addr) -#define WRITE_BYTE(addr,v) writeb(v,addr) -#define WRITE_WORD(addr,v) writew(v,addr) -#define WRITE_DWORD(addr,v) writel(v,addr) +#define WRITE_BYTE(addr, v) writeb(v, addr) +#define WRITE_WORD(addr, v) writew(v, addr) +#define WRITE_DWORD(addr, v) writel(v, addr) static inline __u16 GET_WORD(void *addr) { @@ -344,10 +344,10 @@ static inline void PUT_DWORD(void *addr, __u32 v) ** 32/64 bit macors */ #ifdef BITS_PER_LONG - #if BITS_PER_LONG > 32 - #define PLATFORM_GT_32BIT - #define ULongToPtr(x) (void *)(unsigned long)(x) - #endif +#if BITS_PER_LONG > 32 +#define PLATFORM_GT_32BIT +#define ULongToPtr(x) (void *)(unsigned long)(x) +#endif #endif /* @@ -362,7 +362,7 @@ static inline void PUT_DWORD(void *addr, __u32 v) */ #define diva_os_dump_file_t char #define diva_os_board_trace_t char -#define diva_os_dump_file(__x__) do { } while(0) +#define diva_os_dump_file(__x__) do { } while (0) /* ** size of internal arrays diff --git a/drivers/isdn/hardware/eicon/pr_pc.h b/drivers/isdn/hardware/eicon/pr_pc.h index bf49a5af567f..a08d6d57a486 100644 --- a/drivers/isdn/hardware/eicon/pr_pc.h +++ b/drivers/isdn/hardware/eicon/pr_pc.h @@ -1,76 +1,76 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ struct pr_ram { - word NextReq; /* pointer to next Req Buffer */ - word NextRc; /* pointer to next Rc Buffer */ - word NextInd; /* pointer to next Ind Buffer */ - byte ReqInput; /* number of Req Buffers sent */ - byte ReqOutput; /* number of Req Buffers returned */ - byte ReqReserved; /* number of Req Buffers reserved */ - byte Int; /* ISDN-P interrupt */ - byte XLock; /* Lock field for arbitration */ - byte RcOutput; /* number of Rc buffers received */ - byte IndOutput; /* number of Ind buffers received */ - byte IMask; /* Interrupt Mask Flag */ - byte Reserved1[2]; /* reserved field, do not use */ - byte ReadyInt; /* request field for ready interrupt */ - byte Reserved2[12]; /* reserved field, do not use */ - byte InterfaceType; /* interface type 1=16K interface */ - word Signature; /* ISDN-P initialized indication */ - byte B[1]; /* buffer space for Req,Ind and Rc */ + word NextReq; /* pointer to next Req Buffer */ + word NextRc; /* pointer to next Rc Buffer */ + word NextInd; /* pointer to next Ind Buffer */ + byte ReqInput; /* number of Req Buffers sent */ + byte ReqOutput; /* number of Req Buffers returned */ + byte ReqReserved; /* number of Req Buffers reserved */ + byte Int; /* ISDN-P interrupt */ + byte XLock; /* Lock field for arbitration */ + byte RcOutput; /* number of Rc buffers received */ + byte IndOutput; /* number of Ind buffers received */ + byte IMask; /* Interrupt Mask Flag */ + byte Reserved1[2]; /* reserved field, do not use */ + byte ReadyInt; /* request field for ready interrupt */ + byte Reserved2[12]; /* reserved field, do not use */ + byte InterfaceType; /* interface type 1=16K interface */ + word Signature; /* ISDN-P initialized indication */ + byte B[1]; /* buffer space for Req,Ind and Rc */ }; typedef struct { - word next; - byte Req; - byte ReqId; - byte ReqCh; - byte Reserved1; - word Reference; - byte Reserved[8]; - PBUFFER XBuffer; + word next; + byte Req; + byte ReqId; + byte ReqCh; + byte Reserved1; + word Reference; + byte Reserved[8]; + PBUFFER XBuffer; } REQ; typedef struct { - word next; - byte Rc; - byte RcId; - byte RcCh; - byte Reserved1; - word Reference; - byte Reserved2[8]; + word next; + byte Rc; + byte RcId; + byte RcCh; + byte Reserved1; + word Reference; + byte Reserved2[8]; } RC; typedef struct { - word next; - byte Ind; - byte IndId; - byte IndCh; - byte MInd; - word MLength; - word Reference; - byte RNR; - byte Reserved; - dword Ack; - PBUFFER RBuffer; + word next; + byte Ind; + byte IndId; + byte IndCh; + byte MInd; + word MLength; + word Reference; + byte RNR; + byte Reserved; + dword Ack; + PBUFFER RBuffer; } IND; diff --git a/drivers/isdn/hardware/eicon/s_4bri.c b/drivers/isdn/hardware/eicon/s_4bri.c index 25c5d7feb838..ec12165fbf62 100644 --- a/drivers/isdn/hardware/eicon/s_4bri.c +++ b/drivers/isdn/hardware/eicon/s_4bri.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -42,13 +42,13 @@ #define MAX_XLOG_SIZE (64 * 1024) /* -------------------------------------------------------------------------- - Recovery XLOG from QBRI Card - -------------------------------------------------------------------------- */ -static void qBri_cpu_trapped (PISDN_ADAPTER IoAdapter) { - byte __iomem *base ; - word *Xlog ; - dword regs[4], TrapID, offset, size ; - Xdesc xlogDesc ; + Recovery XLOG from QBRI Card + -------------------------------------------------------------------------- */ +static void qBri_cpu_trapped(PISDN_ADAPTER IoAdapter) { + byte __iomem *base; + word *Xlog; + dword regs[4], TrapID, offset, size; + Xdesc xlogDesc; int factor = (IoAdapter->tasks == 1) ? 1 : 2; /* @@ -56,211 +56,211 @@ static void qBri_cpu_trapped (PISDN_ADAPTER IoAdapter) { */ base = DIVA_OS_MEM_ATTACH_CONTROL(IoAdapter); - offset = IoAdapter->ControllerNumber * (IoAdapter->MemorySize >> factor) ; + offset = IoAdapter->ControllerNumber * (IoAdapter->MemorySize >> factor); - TrapID = READ_DWORD(&base[0x80]) ; + TrapID = READ_DWORD(&base[0x80]); - if ( (TrapID == 0x99999999) || (TrapID == 0x99999901) ) + if ((TrapID == 0x99999999) || (TrapID == 0x99999901)) { - dump_trap_frame (IoAdapter, &base[0x90]) ; - IoAdapter->trapped = 1 ; + dump_trap_frame(IoAdapter, &base[0x90]); + IoAdapter->trapped = 1; } regs[0] = READ_DWORD((base + offset) + 0x70); regs[1] = READ_DWORD((base + offset) + 0x74); regs[2] = READ_DWORD((base + offset) + 0x78); regs[3] = READ_DWORD((base + offset) + 0x7c); - regs[0] &= IoAdapter->MemorySize - 1 ; + regs[0] &= IoAdapter->MemorySize - 1; - if ( (regs[0] >= offset) - && (regs[0] < offset + (IoAdapter->MemorySize >> factor) - 1) ) + if ((regs[0] >= offset) + && (regs[0] < offset + (IoAdapter->MemorySize >> factor) - 1)) { - if ( !(Xlog = (word *)diva_os_malloc (0, MAX_XLOG_SIZE)) ) { + if (!(Xlog = (word *)diva_os_malloc(0, MAX_XLOG_SIZE))) { DIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base); - return ; + return; } - size = offset + (IoAdapter->MemorySize >> factor) - regs[0] ; - if ( size > MAX_XLOG_SIZE ) - size = MAX_XLOG_SIZE ; - memcpy_fromio (Xlog, &base[regs[0]], size) ; - xlogDesc.buf = Xlog ; - xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]) ; - xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]) ; - dump_xlog_buffer (IoAdapter, &xlogDesc) ; - diva_os_free (0, Xlog) ; - IoAdapter->trapped = 2 ; + size = offset + (IoAdapter->MemorySize >> factor) - regs[0]; + if (size > MAX_XLOG_SIZE) + size = MAX_XLOG_SIZE; + memcpy_fromio(Xlog, &base[regs[0]], size); + xlogDesc.buf = Xlog; + xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]); + xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]); + dump_xlog_buffer(IoAdapter, &xlogDesc); + diva_os_free(0, Xlog); + IoAdapter->trapped = 2; } DIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base); } /* -------------------------------------------------------------------------- - Reset QBRI Hardware - -------------------------------------------------------------------------- */ -static void reset_qBri_hardware (PISDN_ADAPTER IoAdapter) { - word volatile __iomem *qBriReset ; - byte volatile __iomem *qBriCntrl ; - byte volatile __iomem *p ; + Reset QBRI Hardware + -------------------------------------------------------------------------- */ +static void reset_qBri_hardware(PISDN_ADAPTER IoAdapter) { + word volatile __iomem *qBriReset; + byte volatile __iomem *qBriCntrl; + byte volatile __iomem *p; qBriReset = (word volatile __iomem *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter); - WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_SOFT_RESET) ; - diva_os_wait (1) ; - WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_SOFT_RESET) ; - diva_os_wait (1); - WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_RELOAD_EEPROM) ; - diva_os_wait (1) ; - WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_RELOAD_EEPROM) ; - diva_os_wait (1); + WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_SOFT_RESET); + diva_os_wait(1); + WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_SOFT_RESET); + diva_os_wait(1); + WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_RELOAD_EEPROM); + diva_os_wait(1); + WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_RELOAD_EEPROM); + diva_os_wait(1); DIVA_OS_MEM_DETACH_PROM(IoAdapter, qBriReset); qBriCntrl = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); p = &qBriCntrl[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_RISC) : (MQ_BREG_RISC)]; - WRITE_DWORD(p, 0) ; + WRITE_DWORD(p, 0); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, qBriCntrl); DBG_TRC(("resetted board @ reset addr 0x%08lx", qBriReset)) - DBG_TRC(("resetted board @ cntrl addr 0x%08lx", p)) -} + DBG_TRC(("resetted board @ cntrl addr 0x%08lx", p)) + } /* -------------------------------------------------------------------------- - Start Card CPU - -------------------------------------------------------------------------- */ -void start_qBri_hardware (PISDN_ADAPTER IoAdapter) { - byte volatile __iomem *qBriReset ; - byte volatile __iomem *p ; + Start Card CPU + -------------------------------------------------------------------------- */ +void start_qBri_hardware(PISDN_ADAPTER IoAdapter) { + byte volatile __iomem *qBriReset; + byte volatile __iomem *p; p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); qBriReset = &p[(DIVA_4BRI_REVISION(IoAdapter)) ? (MQ2_BREG_RISC) : (MQ_BREG_RISC)]; - WRITE_DWORD(qBriReset, MQ_RISC_COLD_RESET_MASK) ; - diva_os_wait (2) ; - WRITE_DWORD(qBriReset, MQ_RISC_WARM_RESET_MASK | MQ_RISC_COLD_RESET_MASK) ; - diva_os_wait (10) ; + WRITE_DWORD(qBriReset, MQ_RISC_COLD_RESET_MASK); + diva_os_wait(2); + WRITE_DWORD(qBriReset, MQ_RISC_WARM_RESET_MASK | MQ_RISC_COLD_RESET_MASK); + diva_os_wait(10); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); DBG_TRC(("started processor @ addr 0x%08lx", qBriReset)) -} + } /* -------------------------------------------------------------------------- - Stop Card CPU - -------------------------------------------------------------------------- */ -static void stop_qBri_hardware (PISDN_ADAPTER IoAdapter) { - byte volatile __iomem *p ; - dword volatile __iomem *qBriReset ; - dword volatile __iomem *qBriIrq ; - dword volatile __iomem *qBriIsacDspReset ; + Stop Card CPU + -------------------------------------------------------------------------- */ +static void stop_qBri_hardware(PISDN_ADAPTER IoAdapter) { + byte volatile __iomem *p; + dword volatile __iomem *qBriReset; + dword volatile __iomem *qBriIrq; + dword volatile __iomem *qBriIsacDspReset; int rev2 = DIVA_4BRI_REVISION(IoAdapter); int reset_offset = rev2 ? (MQ2_BREG_RISC) : (MQ_BREG_RISC); int irq_offset = rev2 ? (MQ2_BREG_IRQ_TEST) : (MQ_BREG_IRQ_TEST); int hw_offset = rev2 ? (MQ2_ISAC_DSP_RESET) : (MQ_ISAC_DSP_RESET); - if ( IoAdapter->ControllerNumber > 0 ) - return ; + if (IoAdapter->ControllerNumber > 0) + return; p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); qBriReset = (dword volatile __iomem *)&p[reset_offset]; qBriIsacDspReset = (dword volatile __iomem *)&p[hw_offset]; /* * clear interrupt line (reset Local Interrupt Test Register) */ - WRITE_DWORD(qBriReset, 0) ; - WRITE_DWORD(qBriIsacDspReset, 0) ; + WRITE_DWORD(qBriReset, 0); + WRITE_DWORD(qBriIsacDspReset, 0); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); - + p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); WRITE_BYTE(&p[PLX9054_INTCSR], 0x00); /* disable PCI interrupts */ DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); - + p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); qBriIrq = (dword volatile __iomem *)&p[irq_offset]; - WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF) ; + WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); DBG_TRC(("stopped processor @ addr 0x%08lx", qBriReset)) -} + } /* -------------------------------------------------------------------------- - FPGA download - -------------------------------------------------------------------------- */ + FPGA download + -------------------------------------------------------------------------- */ #define FPGA_NAME_OFFSET 0x10 -static byte * qBri_check_FPGAsrc (PISDN_ADAPTER IoAdapter, char *FileName, - dword *Length, dword *code) { - byte *File ; - char *fpgaFile, *fpgaType, *fpgaDate, *fpgaTime ; - dword fpgaFlen, fpgaTlen, fpgaDlen, cnt, year, i ; +static byte *qBri_check_FPGAsrc(PISDN_ADAPTER IoAdapter, char *FileName, + dword *Length, dword *code) { + byte *File; + char *fpgaFile, *fpgaType, *fpgaDate, *fpgaTime; + dword fpgaFlen, fpgaTlen, fpgaDlen, cnt, year, i; - if (!(File = (byte *)xdiLoadFile (FileName, Length, 0))) { - return (NULL) ; + if (!(File = (byte *)xdiLoadFile(FileName, Length, 0))) { + return (NULL); } /* * scan file until FF and put id string into buffer */ - for ( i = 0 ; File[i] != 0xff ; ) + for (i = 0; File[i] != 0xff;) { - if ( ++i >= *Length ) + if (++i >= *Length) { DBG_FTL(("FPGA download: start of data header not found")) - xdiFreeFile (File) ; - return (NULL) ; + xdiFreeFile(File); + return (NULL); } } - *code = i++ ; + *code = i++; - if ( (File[i] & 0xF0) != 0x20 ) + if ((File[i] & 0xF0) != 0x20) { DBG_FTL(("FPGA download: data header corrupted")) - xdiFreeFile (File) ; - return (NULL) ; + xdiFreeFile(File); + return (NULL); } - fpgaFlen = (dword) File[FPGA_NAME_OFFSET - 1] ; - if ( fpgaFlen == 0 ) - fpgaFlen = 12 ; - fpgaFile = (char *)&File[FPGA_NAME_OFFSET] ; - fpgaTlen = (dword) fpgaFile[fpgaFlen + 2] ; - if ( fpgaTlen == 0 ) - fpgaTlen = 10 ; - fpgaType = (char *)&fpgaFile[fpgaFlen + 3] ; - fpgaDlen = (dword) fpgaType[fpgaTlen + 2] ; - if ( fpgaDlen == 0 ) - fpgaDlen = 11 ; - fpgaDate = (char *)&fpgaType[fpgaTlen + 3] ; - fpgaTime = (char *)&fpgaDate[fpgaDlen + 3] ; - cnt = (dword)(((File[ i ] & 0x0F) << 20) + (File[i + 1] << 12) - + (File[i + 2] << 4) + (File[i + 3] >> 4)) ; - - if ( (dword)(i + (cnt / 8)) > *Length ) + fpgaFlen = (dword)File[FPGA_NAME_OFFSET - 1]; + if (fpgaFlen == 0) + fpgaFlen = 12; + fpgaFile = (char *)&File[FPGA_NAME_OFFSET]; + fpgaTlen = (dword)fpgaFile[fpgaFlen + 2]; + if (fpgaTlen == 0) + fpgaTlen = 10; + fpgaType = (char *)&fpgaFile[fpgaFlen + 3]; + fpgaDlen = (dword) fpgaType[fpgaTlen + 2]; + if (fpgaDlen == 0) + fpgaDlen = 11; + fpgaDate = (char *)&fpgaType[fpgaTlen + 3]; + fpgaTime = (char *)&fpgaDate[fpgaDlen + 3]; + cnt = (dword)(((File[i] & 0x0F) << 20) + (File[i + 1] << 12) + + (File[i + 2] << 4) + (File[i + 3] >> 4)); + + if ((dword)(i + (cnt / 8)) > *Length) { DBG_FTL(("FPGA download: '%s' file too small (%ld < %ld)", - FileName, *Length, code + ((cnt + 7) / 8) )) - xdiFreeFile (File) ; - return (NULL) ; + FileName, *Length, code + ((cnt + 7) / 8))) + xdiFreeFile(File); + return (NULL); } - i = 0 ; + i = 0; do { - while ( (fpgaDate[i] != '\0') - && ((fpgaDate[i] < '0') || (fpgaDate[i] > '9')) ) + while ((fpgaDate[i] != '\0') + && ((fpgaDate[i] < '0') || (fpgaDate[i] > '9'))) { i++; } - year = 0 ; - while ( (fpgaDate[i] >= '0') && (fpgaDate[i] <= '9') ) - year = year * 10 + (fpgaDate[i++] - '0') ; - } while ( (year < 2000) && (fpgaDate[i] != '\0') ); + year = 0; + while ((fpgaDate[i] >= '0') && (fpgaDate[i] <= '9')) + year = year * 10 + (fpgaDate[i++] - '0'); + } while ((year < 2000) && (fpgaDate[i] != '\0')); switch (IoAdapter->cardType) { - case CARDTYPE_DIVASRV_B_2F_PCI: - break; + case CARDTYPE_DIVASRV_B_2F_PCI: + break; - default: - if ( year >= 2001 ) { - IoAdapter->fpga_features |= PCINIT_FPGA_PLX_ACCESS_SUPPORTED ; - } + default: + if (year >= 2001) { + IoAdapter->fpga_features |= PCINIT_FPGA_PLX_ACCESS_SUPPORTED; + } } DBG_LOG(("FPGA[%s] file %s (%s %s) len %d", - fpgaType, fpgaFile, fpgaDate, fpgaTime, cnt)) - return (File) ; + fpgaType, fpgaFile, fpgaDate, fpgaTime, cnt)) + return (File); } /******************************************************************************/ @@ -272,114 +272,114 @@ static byte * qBri_check_FPGAsrc (PISDN_ADAPTER IoAdapter, char *FileName, #define FPGA_DOUT 0x0400 #define FPGA_DIN FPGA_DOUT /* bidirectional I/O */ -int qBri_FPGA_download (PISDN_ADAPTER IoAdapter) { - int bit ; - byte *File ; - dword code, FileLength ; +int qBri_FPGA_download(PISDN_ADAPTER IoAdapter) { + int bit; + byte *File; + dword code, FileLength; word volatile __iomem *addr = (word volatile __iomem *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter); - word val, baseval = FPGA_CS | FPGA_PROG ; + word val, baseval = FPGA_CS | FPGA_PROG; if (DIVA_4BRI_REVISION(IoAdapter)) { - char* name; + char *name; switch (IoAdapter->cardType) { - case CARDTYPE_DIVASRV_B_2F_PCI: - name = "dsbri2f.bit"; - break; + case CARDTYPE_DIVASRV_B_2F_PCI: + name = "dsbri2f.bit"; + break; - case CARDTYPE_DIVASRV_B_2M_V2_PCI: - case CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI: - name = "dsbri2m.bit"; - break; + case CARDTYPE_DIVASRV_B_2M_V2_PCI: + case CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI: + name = "dsbri2m.bit"; + break; - default: - name = "ds4bri2.bit"; + default: + name = "ds4bri2.bit"; } - File = qBri_check_FPGAsrc (IoAdapter, name, - &FileLength, &code); + File = qBri_check_FPGAsrc(IoAdapter, name, + &FileLength, &code); } else { - File = qBri_check_FPGAsrc (IoAdapter, "ds4bri.bit", - &FileLength, &code) ; + File = qBri_check_FPGAsrc(IoAdapter, "ds4bri.bit", + &FileLength, &code); } - if ( !File ) { + if (!File) { DIVA_OS_MEM_DETACH_PROM(IoAdapter, addr); - return (0) ; + return (0); } /* * prepare download, pulse PROGRAM pin down. */ - WRITE_WORD(addr, baseval & ~FPGA_PROG) ; /* PROGRAM low pulse */ - WRITE_WORD(addr, baseval) ; /* release */ - diva_os_wait (50) ; /* wait until FPGA finished internal memory clear */ + WRITE_WORD(addr, baseval & ~FPGA_PROG); /* PROGRAM low pulse */ + WRITE_WORD(addr, baseval); /* release */ + diva_os_wait(50); /* wait until FPGA finished internal memory clear */ /* * check done pin, must be low */ - if ( READ_WORD(addr) & FPGA_BUSY ) + if (READ_WORD(addr) & FPGA_BUSY) { DBG_FTL(("FPGA download: acknowledge for FPGA memory clear missing")) - xdiFreeFile (File) ; + xdiFreeFile(File); DIVA_OS_MEM_DETACH_PROM(IoAdapter, addr); - return (0) ; + return (0); } /* * put data onto the FPGA */ - while ( code < FileLength ) + while (code < FileLength) { - val = ((word)File[code++]) << 3 ; + val = ((word)File[code++]) << 3; - for ( bit = 8 ; bit-- > 0 ; val <<= 1 ) /* put byte onto FPGA */ + for (bit = 8; bit-- > 0; val <<= 1) /* put byte onto FPGA */ { - baseval &= ~FPGA_DOUT ; /* clr data bit */ - baseval |= (val & FPGA_DOUT) ; /* copy data bit */ - WRITE_WORD(addr, baseval) ; - WRITE_WORD(addr, baseval | FPGA_CCLK) ; /* set CCLK hi */ - WRITE_WORD(addr, baseval | FPGA_CCLK) ; /* set CCLK hi */ - WRITE_WORD(addr, baseval) ; /* set CCLK lo */ + baseval &= ~FPGA_DOUT; /* clr data bit */ + baseval |= (val & FPGA_DOUT); /* copy data bit */ + WRITE_WORD(addr, baseval); + WRITE_WORD(addr, baseval | FPGA_CCLK); /* set CCLK hi */ + WRITE_WORD(addr, baseval | FPGA_CCLK); /* set CCLK hi */ + WRITE_WORD(addr, baseval); /* set CCLK lo */ } } - xdiFreeFile (File) ; - diva_os_wait (100) ; - val = READ_WORD(addr) ; + xdiFreeFile(File); + diva_os_wait(100); + val = READ_WORD(addr); DIVA_OS_MEM_DETACH_PROM(IoAdapter, addr); - if ( !(val & FPGA_BUSY) ) + if (!(val & FPGA_BUSY)) { DBG_FTL(("FPGA download: chip remains in busy state (0x%04x)", val)) - return (0) ; + return (0); } - return (1) ; + return (1); } -static int load_qBri_hardware (PISDN_ADAPTER IoAdapter) { +static int load_qBri_hardware(PISDN_ADAPTER IoAdapter) { return (0); } /* -------------------------------------------------------------------------- - Card ISR - -------------------------------------------------------------------------- */ -static int qBri_ISR (struct _ISDN_ADAPTER* IoAdapter) { - dword volatile __iomem *qBriIrq ; + Card ISR + -------------------------------------------------------------------------- */ +static int qBri_ISR(struct _ISDN_ADAPTER *IoAdapter) { + dword volatile __iomem *qBriIrq; - PADAPTER_LIST_ENTRY QuadroList = IoAdapter->QuadroList ; + PADAPTER_LIST_ENTRY QuadroList = IoAdapter->QuadroList; - word i ; - int serviced = 0 ; + word i; + int serviced = 0; byte __iomem *p; p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); - if ( !(READ_BYTE(&p[PLX9054_INTCSR]) & 0x80) ) { + if (!(READ_BYTE(&p[PLX9054_INTCSR]) & 0x80)) { DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); - return (0) ; + return (0); } DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); @@ -388,34 +388,34 @@ static int qBri_ISR (struct _ISDN_ADAPTER* IoAdapter) { */ p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); qBriIrq = (dword volatile __iomem *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST) : (MQ_BREG_IRQ_TEST)]); - WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF) ; + WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); - for ( i = 0 ; i < IoAdapter->tasks; ++i ) + for (i = 0; i < IoAdapter->tasks; ++i) { - IoAdapter = QuadroList->QuadroAdapter[i] ; + IoAdapter = QuadroList->QuadroAdapter[i]; - if ( IoAdapter && IoAdapter->Initialized - && IoAdapter->tst_irq (&IoAdapter->a) ) + if (IoAdapter && IoAdapter->Initialized + && IoAdapter->tst_irq(&IoAdapter->a)) { - IoAdapter->IrqCount++ ; - serviced = 1 ; - diva_os_schedule_soft_isr (&IoAdapter->isr_soft_isr); + IoAdapter->IrqCount++; + serviced = 1; + diva_os_schedule_soft_isr(&IoAdapter->isr_soft_isr); } } - return (serviced) ; + return (serviced); } /* -------------------------------------------------------------------------- - Does disable the interrupt on the card - -------------------------------------------------------------------------- */ -static void disable_qBri_interrupt (PISDN_ADAPTER IoAdapter) { - dword volatile __iomem *qBriIrq ; + Does disable the interrupt on the card + -------------------------------------------------------------------------- */ +static void disable_qBri_interrupt(PISDN_ADAPTER IoAdapter) { + dword volatile __iomem *qBriIrq; byte __iomem *p; - if ( IoAdapter->ControllerNumber > 0 ) - return ; + if (IoAdapter->ControllerNumber > 0) + return; /* * clear interrupt line (reset Local Interrupt Test Register) */ @@ -425,84 +425,84 @@ static void disable_qBri_interrupt (PISDN_ADAPTER IoAdapter) { p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); qBriIrq = (dword volatile __iomem *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST) : (MQ_BREG_IRQ_TEST)]); - WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF) ; + WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF); DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); } /* -------------------------------------------------------------------------- - Install Adapter Entry Points - -------------------------------------------------------------------------- */ -static void set_common_qBri_functions (PISDN_ADAPTER IoAdapter) { + Install Adapter Entry Points + -------------------------------------------------------------------------- */ +static void set_common_qBri_functions(PISDN_ADAPTER IoAdapter) { ADAPTER *a; - a = &IoAdapter->a ; + a = &IoAdapter->a; - a->ram_in = mem_in ; - a->ram_inw = mem_inw ; - a->ram_in_buffer = mem_in_buffer ; - a->ram_look_ahead = mem_look_ahead ; - a->ram_out = mem_out ; - a->ram_outw = mem_outw ; - a->ram_out_buffer = mem_out_buffer ; - a->ram_inc = mem_inc ; + a->ram_in = mem_in; + a->ram_inw = mem_inw; + a->ram_in_buffer = mem_in_buffer; + a->ram_look_ahead = mem_look_ahead; + a->ram_out = mem_out; + a->ram_outw = mem_outw; + a->ram_out_buffer = mem_out_buffer; + a->ram_inc = mem_inc; - IoAdapter->out = pr_out ; - IoAdapter->dpc = pr_dpc ; - IoAdapter->tst_irq = scom_test_int ; - IoAdapter->clr_irq = scom_clear_int ; - IoAdapter->pcm = (struct pc_maint *)MIPS_MAINT_OFFS ; + IoAdapter->out = pr_out; + IoAdapter->dpc = pr_dpc; + IoAdapter->tst_irq = scom_test_int; + IoAdapter->clr_irq = scom_clear_int; + IoAdapter->pcm = (struct pc_maint *)MIPS_MAINT_OFFS; - IoAdapter->load = load_qBri_hardware ; + IoAdapter->load = load_qBri_hardware; - IoAdapter->disIrq = disable_qBri_interrupt ; - IoAdapter->rstFnc = reset_qBri_hardware ; - IoAdapter->stop = stop_qBri_hardware ; - IoAdapter->trapFnc = qBri_cpu_trapped ; + IoAdapter->disIrq = disable_qBri_interrupt; + IoAdapter->rstFnc = reset_qBri_hardware; + IoAdapter->stop = stop_qBri_hardware; + IoAdapter->trapFnc = qBri_cpu_trapped; IoAdapter->diva_isr_handler = qBri_ISR; - IoAdapter->a.io = (void*)IoAdapter ; + IoAdapter->a.io = (void *)IoAdapter; } -static void set_qBri_functions (PISDN_ADAPTER IoAdapter) { +static void set_qBri_functions(PISDN_ADAPTER IoAdapter) { if (!IoAdapter->tasks) { IoAdapter->tasks = MQ_INSTANCE_COUNT; } - IoAdapter->MemorySize = MQ_MEMORY_SIZE ; - set_common_qBri_functions (IoAdapter) ; - diva_os_set_qBri_functions (IoAdapter) ; + IoAdapter->MemorySize = MQ_MEMORY_SIZE; + set_common_qBri_functions(IoAdapter); + diva_os_set_qBri_functions(IoAdapter); } -static void set_qBri2_functions (PISDN_ADAPTER IoAdapter) { +static void set_qBri2_functions(PISDN_ADAPTER IoAdapter) { if (!IoAdapter->tasks) { IoAdapter->tasks = MQ_INSTANCE_COUNT; } IoAdapter->MemorySize = (IoAdapter->tasks == 1) ? BRI2_MEMORY_SIZE : MQ2_MEMORY_SIZE; - set_common_qBri_functions (IoAdapter) ; - diva_os_set_qBri2_functions (IoAdapter) ; + set_common_qBri_functions(IoAdapter); + diva_os_set_qBri2_functions(IoAdapter); } /******************************************************************************/ -void prepare_qBri_functions (PISDN_ADAPTER IoAdapter) { +void prepare_qBri_functions(PISDN_ADAPTER IoAdapter) { - set_qBri_functions (IoAdapter->QuadroList->QuadroAdapter[0]) ; - set_qBri_functions (IoAdapter->QuadroList->QuadroAdapter[1]) ; - set_qBri_functions (IoAdapter->QuadroList->QuadroAdapter[2]) ; - set_qBri_functions (IoAdapter->QuadroList->QuadroAdapter[3]) ; + set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[0]); + set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[1]); + set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[2]); + set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[3]); } -void prepare_qBri2_functions (PISDN_ADAPTER IoAdapter) { +void prepare_qBri2_functions(PISDN_ADAPTER IoAdapter) { if (!IoAdapter->tasks) { IoAdapter->tasks = MQ_INSTANCE_COUNT; } - set_qBri2_functions (IoAdapter->QuadroList->QuadroAdapter[0]) ; + set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[0]); if (IoAdapter->tasks > 1) { - set_qBri2_functions (IoAdapter->QuadroList->QuadroAdapter[1]) ; - set_qBri2_functions (IoAdapter->QuadroList->QuadroAdapter[2]) ; - set_qBri2_functions (IoAdapter->QuadroList->QuadroAdapter[3]) ; + set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[1]); + set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[2]); + set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[3]); } } diff --git a/drivers/isdn/hardware/eicon/s_bri.c b/drivers/isdn/hardware/eicon/s_bri.c index 5c87552e8c08..6a5bb7462339 100644 --- a/drivers/isdn/hardware/eicon/s_bri.c +++ b/drivers/isdn/hardware/eicon/s_bri.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -38,154 +38,154 @@ /*****************************************************************************/ #define MAX_XLOG_SIZE (64 * 1024) /* -------------------------------------------------------------------------- - Investigate card state, recovery trace buffer - -------------------------------------------------------------------------- */ -static void bri_cpu_trapped (PISDN_ADAPTER IoAdapter) { - byte __iomem *addrHi, *addrLo, *ioaddr ; - word *Xlog ; - dword regs[4], i, size ; - Xdesc xlogDesc ; - byte __iomem *Port; + Investigate card state, recovery trace buffer + -------------------------------------------------------------------------- */ +static void bri_cpu_trapped(PISDN_ADAPTER IoAdapter) { + byte __iomem *addrHi, *addrLo, *ioaddr; + word *Xlog; + dword regs[4], i, size; + Xdesc xlogDesc; + byte __iomem *Port; /* * first read pointers and trap frame */ - if ( !(Xlog = (word *)diva_os_malloc (0, MAX_XLOG_SIZE)) ) - return ; - Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); - addrHi = Port + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH) ; - addrLo = Port + ADDR ; - ioaddr = Port + DATA ; - outpp (addrHi, 0) ; - outppw (addrLo, 0) ; - for ( i = 0 ; i < 0x100 ; Xlog[i++] = inppw(ioaddr) ) ; + if (!(Xlog = (word *)diva_os_malloc(0, MAX_XLOG_SIZE))) + return; + Port = DIVA_OS_MEM_ATTACH_PORT(IoAdapter); + addrHi = Port + ((IoAdapter->Properties.Bus == BUS_PCI) ? M_PCI_ADDRH : ADDRH); + addrLo = Port + ADDR; + ioaddr = Port + DATA; + outpp(addrHi, 0); + outppw(addrLo, 0); + for (i = 0; i < 0x100; Xlog[i++] = inppw(ioaddr)); /* * check for trapped MIPS 3xxx CPU, dump only exception frame */ - if ( GET_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 ) - { - dump_trap_frame (IoAdapter, &((byte *)Xlog)[0x90]) ; - IoAdapter->trapped = 1 ; - } - regs[0] = GET_DWORD(&((byte *)Xlog)[0x70]); - regs[1] = GET_DWORD(&((byte *)Xlog)[0x74]); - regs[2] = GET_DWORD(&((byte *)Xlog)[0x78]); - regs[3] = GET_DWORD(&((byte *)Xlog)[0x7c]); - outpp (addrHi, (regs[1] >> 16) & 0x7F) ; - outppw (addrLo, regs[1] & 0xFFFF) ; - xlogDesc.cnt = inppw(ioaddr) ; - outpp (addrHi, (regs[2] >> 16) & 0x7F) ; - outppw (addrLo, regs[2] & 0xFFFF) ; - xlogDesc.out = inppw(ioaddr) ; - xlogDesc.buf = Xlog ; - regs[0] &= IoAdapter->MemorySize - 1 ; - if ( (regs[0] < IoAdapter->MemorySize - 1) ) - { - size = IoAdapter->MemorySize - regs[0] ; - if ( size > MAX_XLOG_SIZE ) - size = MAX_XLOG_SIZE ; - for ( i = 0 ; i < (size / sizeof(*Xlog)) ; regs[0] += 2 ) - { - outpp (addrHi, (regs[0] >> 16) & 0x7F) ; - outppw (addrLo, regs[0] & 0xFFFF) ; - Xlog[i++] = inppw(ioaddr) ; - } - dump_xlog_buffer (IoAdapter, &xlogDesc) ; - diva_os_free (0, Xlog) ; - IoAdapter->trapped = 2 ; - } - outpp (addrHi, (byte)((BRI_UNCACHED_ADDR (IoAdapter->MemoryBase + IoAdapter->MemorySize - - BRI_SHARED_RAM_SIZE)) >> 16)) ; - outppw (addrLo, 0x00) ; - DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port); + if (GET_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999) + { + dump_trap_frame(IoAdapter, &((byte *)Xlog)[0x90]); + IoAdapter->trapped = 1; + } + regs[0] = GET_DWORD(&((byte *)Xlog)[0x70]); + regs[1] = GET_DWORD(&((byte *)Xlog)[0x74]); + regs[2] = GET_DWORD(&((byte *)Xlog)[0x78]); + regs[3] = GET_DWORD(&((byte *)Xlog)[0x7c]); + outpp(addrHi, (regs[1] >> 16) & 0x7F); + outppw(addrLo, regs[1] & 0xFFFF); + xlogDesc.cnt = inppw(ioaddr); + outpp(addrHi, (regs[2] >> 16) & 0x7F); + outppw(addrLo, regs[2] & 0xFFFF); + xlogDesc.out = inppw(ioaddr); + xlogDesc.buf = Xlog; + regs[0] &= IoAdapter->MemorySize - 1; + if ((regs[0] < IoAdapter->MemorySize - 1)) + { + size = IoAdapter->MemorySize - regs[0]; + if (size > MAX_XLOG_SIZE) + size = MAX_XLOG_SIZE; + for (i = 0; i < (size / sizeof(*Xlog)); regs[0] += 2) + { + outpp(addrHi, (regs[0] >> 16) & 0x7F); + outppw(addrLo, regs[0] & 0xFFFF); + Xlog[i++] = inppw(ioaddr); + } + dump_xlog_buffer(IoAdapter, &xlogDesc); + diva_os_free(0, Xlog); + IoAdapter->trapped = 2; + } + outpp(addrHi, (byte)((BRI_UNCACHED_ADDR(IoAdapter->MemoryBase + IoAdapter->MemorySize - + BRI_SHARED_RAM_SIZE)) >> 16)); + outppw(addrLo, 0x00); + DIVA_OS_MEM_DETACH_PORT(IoAdapter, Port); } /* --------------------------------------------------------------------- Reset hardware - --------------------------------------------------------------------- */ -static void reset_bri_hardware (PISDN_ADAPTER IoAdapter) { - byte __iomem *p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); - outpp (p, 0x00) ; - DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); + --------------------------------------------------------------------- */ +static void reset_bri_hardware(PISDN_ADAPTER IoAdapter) { + byte __iomem *p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); + outpp(p, 0x00); + DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); } /* --------------------------------------------------------------------- Halt system - --------------------------------------------------------------------- */ -static void stop_bri_hardware (PISDN_ADAPTER IoAdapter) { - byte __iomem *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); - if (p) { - outpp (p, 0x00) ; /* disable interrupts ! */ - } - DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); - p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); - outpp (p, 0x00) ; /* clear int, halt cpu */ - DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); + --------------------------------------------------------------------- */ +static void stop_bri_hardware(PISDN_ADAPTER IoAdapter) { + byte __iomem *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); + if (p) { + outpp(p, 0x00); /* disable interrupts ! */ + } + DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); + p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); + outpp(p, 0x00); /* clear int, halt cpu */ + DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); } -static int load_bri_hardware (PISDN_ADAPTER IoAdapter) { - return (0); +static int load_bri_hardware(PISDN_ADAPTER IoAdapter) { + return (0); } /******************************************************************************/ -static int bri_ISR (struct _ISDN_ADAPTER* IoAdapter) { - byte __iomem *p; +static int bri_ISR(struct _ISDN_ADAPTER *IoAdapter) { + byte __iomem *p; - p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); - if ( !(inpp (p) & 0x01) ) { - DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); - return (0) ; - } - /* - clear interrupt line - */ - outpp (p, 0x08) ; - DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); - IoAdapter->IrqCount++ ; - if ( IoAdapter->Initialized ) { - diva_os_schedule_soft_isr (&IoAdapter->isr_soft_isr); - } - return (1) ; + p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); + if (!(inpp(p) & 0x01)) { + DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); + return (0); + } + /* + clear interrupt line + */ + outpp(p, 0x08); + DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); + IoAdapter->IrqCount++; + if (IoAdapter->Initialized) { + diva_os_schedule_soft_isr(&IoAdapter->isr_soft_isr); + } + return (1); } /* -------------------------------------------------------------------------- - Disable IRQ in the card hardware - -------------------------------------------------------------------------- */ -static void disable_bri_interrupt (PISDN_ADAPTER IoAdapter) { - byte __iomem *p; - p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); - if ( p ) - { - outpp (p, 0x00) ; /* disable interrupts ! */ - } - DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); - p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); - outpp (p, 0x00) ; /* clear int, halt cpu */ - DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); + Disable IRQ in the card hardware + -------------------------------------------------------------------------- */ +static void disable_bri_interrupt(PISDN_ADAPTER IoAdapter) { + byte __iomem *p; + p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); + if (p) + { + outpp(p, 0x00); /* disable interrupts ! */ + } + DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); + p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter); + outpp(p, 0x00); /* clear int, halt cpu */ + DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p); } /* ------------------------------------------------------------------------- - Fill card entry points - ------------------------------------------------------------------------- */ -void prepare_maestra_functions (PISDN_ADAPTER IoAdapter) { - ADAPTER *a = &IoAdapter->a ; - a->ram_in = io_in ; - a->ram_inw = io_inw ; - a->ram_in_buffer = io_in_buffer ; - a->ram_look_ahead = io_look_ahead ; - a->ram_out = io_out ; - a->ram_outw = io_outw ; - a->ram_out_buffer = io_out_buffer ; - a->ram_inc = io_inc ; - IoAdapter->MemoryBase = BRI_MEMORY_BASE ; - IoAdapter->MemorySize = BRI_MEMORY_SIZE ; - IoAdapter->out = pr_out ; - IoAdapter->dpc = pr_dpc ; - IoAdapter->tst_irq = scom_test_int ; - IoAdapter->clr_irq = scom_clear_int ; - IoAdapter->pcm = (struct pc_maint *)MIPS_MAINT_OFFS ; - IoAdapter->load = load_bri_hardware ; - IoAdapter->disIrq = disable_bri_interrupt ; - IoAdapter->rstFnc = reset_bri_hardware ; - IoAdapter->stop = stop_bri_hardware ; - IoAdapter->trapFnc = bri_cpu_trapped ; - IoAdapter->diva_isr_handler = bri_ISR; - /* - Prepare OS dependent functions - */ - diva_os_prepare_maestra_functions (IoAdapter); + Fill card entry points + ------------------------------------------------------------------------- */ +void prepare_maestra_functions(PISDN_ADAPTER IoAdapter) { + ADAPTER *a = &IoAdapter->a; + a->ram_in = io_in; + a->ram_inw = io_inw; + a->ram_in_buffer = io_in_buffer; + a->ram_look_ahead = io_look_ahead; + a->ram_out = io_out; + a->ram_outw = io_outw; + a->ram_out_buffer = io_out_buffer; + a->ram_inc = io_inc; + IoAdapter->MemoryBase = BRI_MEMORY_BASE; + IoAdapter->MemorySize = BRI_MEMORY_SIZE; + IoAdapter->out = pr_out; + IoAdapter->dpc = pr_dpc; + IoAdapter->tst_irq = scom_test_int; + IoAdapter->clr_irq = scom_clear_int; + IoAdapter->pcm = (struct pc_maint *)MIPS_MAINT_OFFS; + IoAdapter->load = load_bri_hardware; + IoAdapter->disIrq = disable_bri_interrupt; + IoAdapter->rstFnc = reset_bri_hardware; + IoAdapter->stop = stop_bri_hardware; + IoAdapter->trapFnc = bri_cpu_trapped; + IoAdapter->diva_isr_handler = bri_ISR; + /* + Prepare OS dependent functions + */ + diva_os_prepare_maestra_functions(IoAdapter); } /* -------------------------------------------------------------------------- */ diff --git a/drivers/isdn/hardware/eicon/s_pri.c b/drivers/isdn/hardware/eicon/s_pri.c index 18f287888570..ddd0e0ef8ed7 100644 --- a/drivers/isdn/hardware/eicon/s_pri.c +++ b/drivers/isdn/hardware/eicon/s_pri.c @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" @@ -38,168 +38,168 @@ /*****************************************************************************/ #define MAX_XLOG_SIZE (64 * 1024) /* ------------------------------------------------------------------------- - Does return offset between ADAPTER->ram and real begin of memory - ------------------------------------------------------------------------- */ -static dword pri_ram_offset (ADAPTER* a) { - return ((dword)MP_SHARED_RAM_OFFSET); + Does return offset between ADAPTER->ram and real begin of memory + ------------------------------------------------------------------------- */ +static dword pri_ram_offset(ADAPTER *a) { + return ((dword)MP_SHARED_RAM_OFFSET); } /* ------------------------------------------------------------------------- - Recovery XLOG buffer from the card - ------------------------------------------------------------------------- */ -static void pri_cpu_trapped (PISDN_ADAPTER IoAdapter) { - byte __iomem *base ; - word *Xlog ; - dword regs[4], TrapID, size ; - Xdesc xlogDesc ; + Recovery XLOG buffer from the card + ------------------------------------------------------------------------- */ +static void pri_cpu_trapped(PISDN_ADAPTER IoAdapter) { + byte __iomem *base; + word *Xlog; + dword regs[4], TrapID, size; + Xdesc xlogDesc; /* * check for trapped MIPS 46xx CPU, dump exception frame */ - base = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter); - TrapID = READ_DWORD(&base[0x80]) ; - if ( (TrapID == 0x99999999) || (TrapID == 0x99999901) ) - { - dump_trap_frame (IoAdapter, &base[0x90]) ; - IoAdapter->trapped = 1 ; - } - regs[0] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x70]); - regs[1] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x74]); - regs[2] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x78]); - regs[3] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x7c]); - regs[0] &= IoAdapter->MemorySize - 1 ; - if ( (regs[0] < IoAdapter->MemorySize - 1) ) - { - if ( !(Xlog = (word *)diva_os_malloc (0, MAX_XLOG_SIZE)) ) { - DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, base); - return ; - } - size = IoAdapter->MemorySize - regs[0] ; - if ( size > MAX_XLOG_SIZE ) - size = MAX_XLOG_SIZE ; - memcpy_fromio(Xlog, &base[regs[0]], size) ; - xlogDesc.buf = Xlog ; - xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]) ; - xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]) ; - dump_xlog_buffer (IoAdapter, &xlogDesc) ; - diva_os_free (0, Xlog) ; - IoAdapter->trapped = 2 ; - } - DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, base); + base = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter); + TrapID = READ_DWORD(&base[0x80]); + if ((TrapID == 0x99999999) || (TrapID == 0x99999901)) + { + dump_trap_frame(IoAdapter, &base[0x90]); + IoAdapter->trapped = 1; + } + regs[0] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x70]); + regs[1] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x74]); + regs[2] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x78]); + regs[3] = READ_DWORD(&base[MP_PROTOCOL_OFFSET + 0x7c]); + regs[0] &= IoAdapter->MemorySize - 1; + if ((regs[0] < IoAdapter->MemorySize - 1)) + { + if (!(Xlog = (word *)diva_os_malloc(0, MAX_XLOG_SIZE))) { + DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, base); + return; + } + size = IoAdapter->MemorySize - regs[0]; + if (size > MAX_XLOG_SIZE) + size = MAX_XLOG_SIZE; + memcpy_fromio(Xlog, &base[regs[0]], size); + xlogDesc.buf = Xlog; + xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]); + xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]); + dump_xlog_buffer(IoAdapter, &xlogDesc); + diva_os_free(0, Xlog); + IoAdapter->trapped = 2; + } + DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, base); } /* ------------------------------------------------------------------------- - Hardware reset of PRI card - ------------------------------------------------------------------------- */ -static void reset_pri_hardware (PISDN_ADAPTER IoAdapter) { - byte __iomem *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); - WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2); - diva_os_wait (50) ; - WRITE_BYTE(p, 0x00); - diva_os_wait (50) ; - DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); + Hardware reset of PRI card + ------------------------------------------------------------------------- */ +static void reset_pri_hardware(PISDN_ADAPTER IoAdapter) { + byte __iomem *p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); + WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2); + diva_os_wait(50); + WRITE_BYTE(p, 0x00); + diva_os_wait(50); + DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); } /* ------------------------------------------------------------------------- - Stop Card Hardware - ------------------------------------------------------------------------- */ -static void stop_pri_hardware (PISDN_ADAPTER IoAdapter) { - dword i; - byte __iomem *p; - dword volatile __iomem *cfgReg = (void __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter); - WRITE_DWORD(&cfgReg[3], 0); - WRITE_DWORD(&cfgReg[1], 0); - DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg); - IoAdapter->a.ram_out (&IoAdapter->a, &RAM->SWReg, SWREG_HALT_CPU) ; - i = 0 ; - while ( (i < 100) && (IoAdapter->a.ram_in (&IoAdapter->a, &RAM->SWReg) != 0) ) - { - diva_os_wait (1) ; - i++ ; - } - DBG_TRC(("%s: PRI stopped (%d)", IoAdapter->Name, i)) - cfgReg = (void __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter); - WRITE_DWORD(&cfgReg[0],((dword)(~0x03E00000))); - DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg); - diva_os_wait (1) ; - p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); - WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2); - DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); + Stop Card Hardware + ------------------------------------------------------------------------- */ +static void stop_pri_hardware(PISDN_ADAPTER IoAdapter) { + dword i; + byte __iomem *p; + dword volatile __iomem *cfgReg = (void __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter); + WRITE_DWORD(&cfgReg[3], 0); + WRITE_DWORD(&cfgReg[1], 0); + DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg); + IoAdapter->a.ram_out(&IoAdapter->a, &RAM->SWReg, SWREG_HALT_CPU); + i = 0; + while ((i < 100) && (IoAdapter->a.ram_in(&IoAdapter->a, &RAM->SWReg) != 0)) + { + diva_os_wait(1); + i++; + } + DBG_TRC(("%s: PRI stopped (%d)", IoAdapter->Name, i)) + cfgReg = (void __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter); + WRITE_DWORD(&cfgReg[0], ((dword)(~0x03E00000))); + DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg); + diva_os_wait(1); + p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter); + WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2); + DIVA_OS_MEM_DETACH_RESET(IoAdapter, p); } -static int load_pri_hardware (PISDN_ADAPTER IoAdapter) { - return (0); +static int load_pri_hardware(PISDN_ADAPTER IoAdapter) { + return (0); } /* -------------------------------------------------------------------------- - PRI Adapter interrupt Service Routine + PRI Adapter interrupt Service Routine -------------------------------------------------------------------------- */ -static int pri_ISR (struct _ISDN_ADAPTER* IoAdapter) { - byte __iomem *cfg = DIVA_OS_MEM_ATTACH_CFG(IoAdapter); - if ( !(READ_DWORD(cfg) & 0x80000000) ) { - DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfg); - return (0) ; - } - /* - clear interrupt line - */ - WRITE_DWORD(cfg, (dword)~0x03E00000) ; - DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfg); - IoAdapter->IrqCount++ ; - if ( IoAdapter->Initialized ) - { - diva_os_schedule_soft_isr (&IoAdapter->isr_soft_isr); - } - return (1) ; +static int pri_ISR(struct _ISDN_ADAPTER *IoAdapter) { + byte __iomem *cfg = DIVA_OS_MEM_ATTACH_CFG(IoAdapter); + if (!(READ_DWORD(cfg) & 0x80000000)) { + DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfg); + return (0); + } + /* + clear interrupt line + */ + WRITE_DWORD(cfg, (dword)~0x03E00000); + DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfg); + IoAdapter->IrqCount++; + if (IoAdapter->Initialized) + { + diva_os_schedule_soft_isr(&IoAdapter->isr_soft_isr); + } + return (1); } /* ------------------------------------------------------------------------- - Disable interrupt in the card hardware - ------------------------------------------------------------------------- */ -static void disable_pri_interrupt (PISDN_ADAPTER IoAdapter) { - dword volatile __iomem *cfgReg = (dword volatile __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter) ; - WRITE_DWORD(&cfgReg[3], 0); - WRITE_DWORD(&cfgReg[1], 0); - WRITE_DWORD(&cfgReg[0], (dword)(~0x03E00000)) ; - DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg); + Disable interrupt in the card hardware + ------------------------------------------------------------------------- */ +static void disable_pri_interrupt(PISDN_ADAPTER IoAdapter) { + dword volatile __iomem *cfgReg = (dword volatile __iomem *)DIVA_OS_MEM_ATTACH_CFG(IoAdapter); + WRITE_DWORD(&cfgReg[3], 0); + WRITE_DWORD(&cfgReg[1], 0); + WRITE_DWORD(&cfgReg[0], (dword)(~0x03E00000)); + DIVA_OS_MEM_DETACH_CFG(IoAdapter, cfgReg); } /* ------------------------------------------------------------------------- - Install entry points for PRI Adapter - ------------------------------------------------------------------------- */ -static void prepare_common_pri_functions (PISDN_ADAPTER IoAdapter) { - ADAPTER *a = &IoAdapter->a ; - a->ram_in = mem_in ; - a->ram_inw = mem_inw ; - a->ram_in_buffer = mem_in_buffer ; - a->ram_look_ahead = mem_look_ahead ; - a->ram_out = mem_out ; - a->ram_outw = mem_outw ; - a->ram_out_buffer = mem_out_buffer ; - a->ram_inc = mem_inc ; - a->ram_offset = pri_ram_offset ; - a->ram_out_dw = mem_out_dw; - a->ram_in_dw = mem_in_dw; - a->istream_wakeup = pr_stream; - IoAdapter->out = pr_out ; - IoAdapter->dpc = pr_dpc ; - IoAdapter->tst_irq = scom_test_int ; - IoAdapter->clr_irq = scom_clear_int ; - IoAdapter->pcm = (struct pc_maint *)(MIPS_MAINT_OFFS - - MP_SHARED_RAM_OFFSET) ; - IoAdapter->load = load_pri_hardware ; - IoAdapter->disIrq = disable_pri_interrupt ; - IoAdapter->rstFnc = reset_pri_hardware ; - IoAdapter->stop = stop_pri_hardware ; - IoAdapter->trapFnc = pri_cpu_trapped ; - IoAdapter->diva_isr_handler = pri_ISR; + Install entry points for PRI Adapter + ------------------------------------------------------------------------- */ +static void prepare_common_pri_functions(PISDN_ADAPTER IoAdapter) { + ADAPTER *a = &IoAdapter->a; + a->ram_in = mem_in; + a->ram_inw = mem_inw; + a->ram_in_buffer = mem_in_buffer; + a->ram_look_ahead = mem_look_ahead; + a->ram_out = mem_out; + a->ram_outw = mem_outw; + a->ram_out_buffer = mem_out_buffer; + a->ram_inc = mem_inc; + a->ram_offset = pri_ram_offset; + a->ram_out_dw = mem_out_dw; + a->ram_in_dw = mem_in_dw; + a->istream_wakeup = pr_stream; + IoAdapter->out = pr_out; + IoAdapter->dpc = pr_dpc; + IoAdapter->tst_irq = scom_test_int; + IoAdapter->clr_irq = scom_clear_int; + IoAdapter->pcm = (struct pc_maint *)(MIPS_MAINT_OFFS + - MP_SHARED_RAM_OFFSET); + IoAdapter->load = load_pri_hardware; + IoAdapter->disIrq = disable_pri_interrupt; + IoAdapter->rstFnc = reset_pri_hardware; + IoAdapter->stop = stop_pri_hardware; + IoAdapter->trapFnc = pri_cpu_trapped; + IoAdapter->diva_isr_handler = pri_ISR; } /* ------------------------------------------------------------------------- - Install entry points for PRI Adapter - ------------------------------------------------------------------------- */ -void prepare_pri_functions (PISDN_ADAPTER IoAdapter) { - IoAdapter->MemorySize = MP_MEMORY_SIZE ; - prepare_common_pri_functions (IoAdapter) ; - diva_os_prepare_pri_functions (IoAdapter); + Install entry points for PRI Adapter + ------------------------------------------------------------------------- */ +void prepare_pri_functions(PISDN_ADAPTER IoAdapter) { + IoAdapter->MemorySize = MP_MEMORY_SIZE; + prepare_common_pri_functions(IoAdapter); + diva_os_prepare_pri_functions(IoAdapter); } /* ------------------------------------------------------------------------- - Install entry points for PRI Rev.2 Adapter - ------------------------------------------------------------------------- */ -void prepare_pri2_functions (PISDN_ADAPTER IoAdapter) { - IoAdapter->MemorySize = MP2_MEMORY_SIZE ; - prepare_common_pri_functions (IoAdapter) ; - diva_os_prepare_pri2_functions (IoAdapter); + Install entry points for PRI Rev.2 Adapter + ------------------------------------------------------------------------- */ +void prepare_pri2_functions(PISDN_ADAPTER IoAdapter) { + IoAdapter->MemorySize = MP2_MEMORY_SIZE; + prepare_common_pri_functions(IoAdapter); + diva_os_prepare_pri2_functions(IoAdapter); } /* ------------------------------------------------------------------------- */ diff --git a/drivers/isdn/hardware/eicon/sdp_hdr.h b/drivers/isdn/hardware/eicon/sdp_hdr.h index 8f61c696b9aa..5e20f8d68673 100644 --- a/drivers/isdn/hardware/eicon/sdp_hdr.h +++ b/drivers/isdn/hardware/eicon/sdp_hdr.h @@ -1,48 +1,48 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef __DIVA_SOFT_DSP_TASK_ENTRY_H__ #define __DIVA_SOFT_DSP_TASK_ENTRY_H__ /* - The soft DSP image is described by binary header contained on begin of this - image: -OFFSET FROM IMAGE START | VARIABLE ------------------------------------------------------------------------- - DIVA_MIPS_TASK_IMAGE_LINK_OFFS | link to the next image + The soft DSP image is described by binary header contained on begin of this + image: + OFFSET FROM IMAGE START | VARIABLE + ------------------------------------------------------------------------ + DIVA_MIPS_TASK_IMAGE_LINK_OFFS | link to the next image ---------------------------------------------------------------------- - DIVA_MIPS_TASK_IMAGE_GP_OFFS | image gp register value, void* + DIVA_MIPS_TASK_IMAGE_GP_OFFS | image gp register value, void* ---------------------------------------------------------------------- - DIVA_MIPS_TASK_IMAGE_ENTRY_OFFS | diva_mips_sdp_task_entry_t* + DIVA_MIPS_TASK_IMAGE_ENTRY_OFFS | diva_mips_sdp_task_entry_t* ---------------------------------------------------------------------- - DIVA_MIPS_TASK_IMAGE_LOAD_ADDR_OFFS | image image start address (void*) + DIVA_MIPS_TASK_IMAGE_LOAD_ADDR_OFFS | image image start address (void*) ---------------------------------------------------------------------- - DIVA_MIPS_TASK_IMAGE_END_ADDR_OFFS | image image end address (void*) + DIVA_MIPS_TASK_IMAGE_END_ADDR_OFFS | image image end address (void*) ---------------------------------------------------------------------- - DIVA_MIPS_TASK_IMAGE_ID_STRING_OFFS | image id string char[...]; + DIVA_MIPS_TASK_IMAGE_ID_STRING_OFFS | image id string char[...]; ---------------------------------------------------------------------- - */ +*/ #define DIVA_MIPS_TASK_IMAGE_LINK_OFFS 0x6C #define DIVA_MIPS_TASK_IMAGE_GP_OFFS 0x70 #define DIVA_MIPS_TASK_IMAGE_ENTRY_OFFS 0x74 @@ -50,63 +50,63 @@ OFFSET FROM IMAGE START | VARIABLE #define DIVA_MIPS_TASK_IMAGE_END_ADDR_OFFS 0x7c #define DIVA_MIPS_TASK_IMAGE_ID_STRING_OFFS 0x80 /* - This function is called in order to set GP register of this task - This function should be always called before any function of the - task is called - */ -typedef void (*diva_task_set_prog_gp_proc_t)(void* new_gp); + This function is called in order to set GP register of this task + This function should be always called before any function of the + task is called +*/ +typedef void (*diva_task_set_prog_gp_proc_t)(void *new_gp); /* - This function is called to clear .bss at task initialization step - */ -typedef void (*diva_task_sys_reset_proc_t)(void); + This function is called to clear .bss at task initialization step +*/ +typedef void (*diva_task_sys_reset_proc_t)(void); /* - This function is called in order to provide GP of master call to - task, that will be used by calls from the task to the master - */ -typedef void (*diva_task_set_main_gp_proc_t)(void* main_gp); + This function is called in order to provide GP of master call to + task, that will be used by calls from the task to the master +*/ +typedef void (*diva_task_set_main_gp_proc_t)(void *main_gp); /* - This function is called to provide address of 'dprintf' function - to the task - */ + This function is called to provide address of 'dprintf' function + to the task +*/ typedef word (*diva_prt_proc_t)(char *, ...); typedef void (*diva_task_set_prt_proc_t)(diva_prt_proc_t fn); /* - This function is called to set task PID - */ + This function is called to set task PID +*/ typedef void (*diva_task_set_pid_proc_t)(dword id); /* - This function is called for run-time task init - */ + This function is called for run-time task init +*/ typedef int (*diva_task_run_time_init_proc_t)(void*, dword); /* - This function is called from system scheduler or from timer - */ + This function is called from system scheduler or from timer +*/ typedef void (*diva_task_callback_proc_t)(void); /* - This callback is used by task to get current time im mS - */ + This callback is used by task to get current time im mS +*/ typedef dword (*diva_task_get_tick_count_proc_t)(void); typedef void (*diva_task_set_get_time_proc_t)(\ - diva_task_get_tick_count_proc_t fn); + diva_task_get_tick_count_proc_t fn); typedef struct _diva_mips_sdp_task_entry { - diva_task_set_prog_gp_proc_t set_gp_proc; - diva_task_sys_reset_proc_t sys_reset_proc; - diva_task_set_main_gp_proc_t set_main_gp_proc; - diva_task_set_prt_proc_t set_dprintf_proc; - diva_task_set_pid_proc_t set_pid_proc; - diva_task_run_time_init_proc_t run_time_init_proc; - diva_task_callback_proc_t task_callback_proc; - diva_task_callback_proc_t timer_callback_proc; - diva_task_set_get_time_proc_t set_get_time_proc; - void* last_entry_proc; + diva_task_set_prog_gp_proc_t set_gp_proc; + diva_task_sys_reset_proc_t sys_reset_proc; + diva_task_set_main_gp_proc_t set_main_gp_proc; + diva_task_set_prt_proc_t set_dprintf_proc; + diva_task_set_pid_proc_t set_pid_proc; + diva_task_run_time_init_proc_t run_time_init_proc; + diva_task_callback_proc_t task_callback_proc; + diva_task_callback_proc_t timer_callback_proc; + diva_task_set_get_time_proc_t set_get_time_proc; + void *last_entry_proc; } diva_mips_sdp_task_entry_t; /* - 'last_entry_proc' should be set to zero and is used for future extensuios - */ + 'last_entry_proc' should be set to zero and is used for future extensuios +*/ typedef struct _diva_mips_sw_task { - diva_mips_sdp_task_entry_t sdp_entry; - void* sdp_gp_reg; - void* own_gp_reg; + diva_mips_sdp_task_entry_t sdp_entry; + void *sdp_gp_reg; + void *own_gp_reg; } diva_mips_sw_task_t; #if !defined(DIVA_BRI2F_SDP_1_NAME) #define DIVA_BRI2F_SDP_1_NAME "sdp0.2q0" diff --git a/drivers/isdn/hardware/eicon/um_idi.c b/drivers/isdn/hardware/eicon/um_idi.c index ac0bdd1f23fa..7cab5c3276c2 100644 --- a/drivers/isdn/hardware/eicon/um_idi.c +++ b/drivers/isdn/hardware/eicon/um_idi.c @@ -14,30 +14,30 @@ #define DIVAS_MAX_XDI_ADAPTERS 64 /* -------------------------------------------------------------------------- - IMPORTS + IMPORTS -------------------------------------------------------------------------- */ extern void diva_os_wakeup_read(void *os_context); extern void diva_os_wakeup_close(void *os_context); /* -------------------------------------------------------------------------- - LOCALS + LOCALS -------------------------------------------------------------------------- */ static LIST_HEAD(adapter_q); static diva_os_spin_lock_t adapter_lock; static diva_um_idi_adapter_t *diva_um_idi_find_adapter(dword nr); -static void cleanup_adapter(diva_um_idi_adapter_t * a); -static void cleanup_entity(divas_um_idi_entity_t * e); -static int diva_user_mode_idi_adapter_features(diva_um_idi_adapter_t * a, +static void cleanup_adapter(diva_um_idi_adapter_t *a); +static void cleanup_entity(divas_um_idi_entity_t *e); +static int diva_user_mode_idi_adapter_features(diva_um_idi_adapter_t *a, diva_um_idi_adapter_features_t - * features); -static int process_idi_request(divas_um_idi_entity_t * e, - const diva_um_idi_req_hdr_t * req); -static int process_idi_rc(divas_um_idi_entity_t * e, byte rc); -static int process_idi_ind(divas_um_idi_entity_t * e, byte ind); -static int write_return_code(divas_um_idi_entity_t * e, byte rc); + *features); +static int process_idi_request(divas_um_idi_entity_t *e, + const diva_um_idi_req_hdr_t *req); +static int process_idi_rc(divas_um_idi_entity_t *e, byte rc); +static int process_idi_ind(divas_um_idi_entity_t *e, byte ind); +static int write_return_code(divas_um_idi_entity_t *e, byte rc); /* -------------------------------------------------------------------------- - MAIN + MAIN -------------------------------------------------------------------------- */ int diva_user_mode_idi_init(void) { @@ -46,10 +46,10 @@ int diva_user_mode_idi_init(void) } /* -------------------------------------------------------------------------- - Copy adapter features to user supplied buffer + Copy adapter features to user supplied buffer -------------------------------------------------------------------------- */ static int -diva_user_mode_idi_adapter_features(diva_um_idi_adapter_t * a, +diva_user_mode_idi_adapter_features(diva_um_idi_adapter_t *a, diva_um_idi_adapter_features_t * features) { @@ -63,14 +63,14 @@ diva_user_mode_idi_adapter_features(diva_um_idi_adapter_t * a, sync_req.GetName.Req = 0; sync_req.GetName.Rc = IDI_SYNC_REQ_GET_NAME; - (*(a->d.request)) ((ENTITY *) & sync_req); + (*(a->d.request)) ((ENTITY *)&sync_req); strlcpy(features->name, sync_req.GetName.name, sizeof(features->name)); sync_req.GetSerial.Req = 0; sync_req.GetSerial.Rc = IDI_SYNC_REQ_GET_SERIAL; sync_req.GetSerial.serial = 0; - (*(a->d.request)) ((ENTITY *) & sync_req); + (*(a->d.request))((ENTITY *)&sync_req); features->serial_number = sync_req.GetSerial.serial; } @@ -78,7 +78,7 @@ diva_user_mode_idi_adapter_features(diva_um_idi_adapter_t * a, } /* -------------------------------------------------------------------------- - REMOVE ADAPTER + REMOVE ADAPTER -------------------------------------------------------------------------- */ void diva_user_mode_idi_remove_adapter(int adapter_nr) { @@ -98,7 +98,7 @@ void diva_user_mode_idi_remove_adapter(int adapter_nr) } /* -------------------------------------------------------------------------- - CALLED ON DRIVER EXIT (UNLOAD) + CALLED ON DRIVER EXIT (UNLOAD) -------------------------------------------------------------------------- */ void diva_user_mode_idi_finit(void) { @@ -116,15 +116,15 @@ void diva_user_mode_idi_finit(void) } /* ------------------------------------------------------------------------- - CREATE AND INIT IDI ADAPTER - ------------------------------------------------------------------------- */ -int diva_user_mode_idi_create_adapter(const DESCRIPTOR * d, int adapter_nr) + CREATE AND INIT IDI ADAPTER + ------------------------------------------------------------------------- */ +int diva_user_mode_idi_create_adapter(const DESCRIPTOR *d, int adapter_nr) { diva_os_spin_lock_magic_t old_irql; diva_um_idi_adapter_t *a = - (diva_um_idi_adapter_t *) diva_os_malloc(0, - sizeof - (diva_um_idi_adapter_t)); + (diva_um_idi_adapter_t *) diva_os_malloc(0, + sizeof + (diva_um_idi_adapter_t)); if (!a) { return (-1); @@ -145,7 +145,7 @@ int diva_user_mode_idi_create_adapter(const DESCRIPTOR * d, int adapter_nr) } /* ------------------------------------------------------------------------ - Find adapter by Adapter number + Find adapter by Adapter number ------------------------------------------------------------------------ */ static diva_um_idi_adapter_t *diva_um_idi_find_adapter(dword nr) { @@ -159,14 +159,14 @@ static diva_um_idi_adapter_t *diva_um_idi_find_adapter(dword nr) break; a = NULL; } - return(a); + return (a); } /* ------------------------------------------------------------------------ - Cleanup this adapter and cleanup/delete all entities assigned - to this adapter + Cleanup this adapter and cleanup/delete all entities assigned + to this adapter ------------------------------------------------------------------------ */ -static void cleanup_adapter(diva_um_idi_adapter_t * a) +static void cleanup_adapter(diva_um_idi_adapter_t *a) { struct list_head *tmp, *safe; divas_um_idi_entity_t *e; @@ -184,9 +184,9 @@ static void cleanup_adapter(diva_um_idi_adapter_t * a) } /* ------------------------------------------------------------------------ - Cleanup, but NOT delete this entity + Cleanup, but NOT delete this entity ------------------------------------------------------------------------ */ -static void cleanup_entity(divas_um_idi_entity_t * e) +static void cleanup_entity(divas_um_idi_entity_t *e) { e->os_ref = NULL; e->status = 0; @@ -203,7 +203,7 @@ static void cleanup_entity(divas_um_idi_entity_t * e) /* ------------------------------------------------------------------------ - Create ENTITY, link it to the adapter and remove pointer to entity + Create ENTITY, link it to the adapter and remove pointer to entity ------------------------------------------------------------------------ */ void *divas_um_idi_create_entity(dword adapter_nr, void *file) { @@ -236,12 +236,12 @@ void *divas_um_idi_create_entity(dword adapter_nr, void *file) diva_os_enter_spin_lock(&adapter_lock, &old_irql, "create_entity"); /* - Look for Adapter requested - */ + Look for Adapter requested + */ if (!(a = diva_um_idi_find_adapter(adapter_nr))) { /* - No adapter was found, or this adapter was removed - */ + No adapter was found, or this adapter was removed + */ diva_os_leave_spin_lock(&adapter_lock, &old_irql, "create_entity"); DBG_LOG(("A: no adapter(%ld)", adapter_nr)); @@ -267,7 +267,7 @@ void *divas_um_idi_create_entity(dword adapter_nr, void *file) } /* ------------------------------------------------------------------------ - Unlink entity and free memory + Unlink entity and free memory ------------------------------------------------------------------------ */ int divas_um_idi_delete_entity(int adapter_nr, void *entity) { @@ -296,8 +296,8 @@ int divas_um_idi_delete_entity(int adapter_nr, void *entity) } /* -------------------------------------------------------------------------- - Called by application to read data from IDI - -------------------------------------------------------------------------- */ + Called by application to read data from IDI + -------------------------------------------------------------------------- */ int diva_um_idi_read(void *entity, void *os_handle, void *dst, @@ -319,20 +319,20 @@ int diva_um_idi_read(void *entity, (a->status & DIVA_UM_IDI_ADAPTER_REMOVED)) { diva_os_leave_spin_lock(&adapter_lock, &old_irql, "read"); DBG_ERR(("E(%08x) read failed - adapter removed", e)) - return (-1); + return (-1); } DBG_TRC(("A(%d) E(%08x) read(%d)", a->adapter_nr, e, max_length)); /* - Try to read return code first - */ + Try to read return code first + */ data = diva_data_q_get_segment4read(&e->rc); q = &e->rc; /* - No return codes available, read indications now - */ + No return codes available, read indications now + */ if (!data) { if (!(e->status & DIVA_UM_IDI_RC_PENDING)) { DBG_TRC(("A(%d) E(%08x) read data", a->adapter_nr, e)); @@ -348,8 +348,8 @@ int diva_um_idi_read(void *entity, if ((length = diva_data_q_get_segment_length(q)) > max_length) { /* - Not enough space to read message - */ + Not enough space to read message + */ DBG_ERR(("A: A(%d) E(%08x) read small buffer", a->adapter_nr, e, ret)); diva_os_leave_spin_lock(&adapter_lock, &old_irql, @@ -357,14 +357,14 @@ int diva_um_idi_read(void *entity, return (-2); } /* - Copy it to user, this function does access ONLY locked an verified - memory, also we can access it witch spin lock held - */ + Copy it to user, this function does access ONLY locked an verified + memory, also we can access it witch spin lock held + */ if ((ret = (*cp_fn) (os_handle, dst, data, length)) >= 0) { /* - Acknowledge only if read was successful - */ + Acknowledge only if read was successful + */ diva_data_q_ack_segment4read(q); } } @@ -399,7 +399,7 @@ int diva_um_idi_write(void *entity, (a->status & DIVA_UM_IDI_ADAPTER_REMOVED)) { diva_os_leave_spin_lock(&adapter_lock, &old_irql, "write"); DBG_ERR(("E(%08x) write failed - adapter removed", e)) - return (-1); + return (-1); } DBG_TRC(("A(%d) E(%08x) write(%d)", a->adapter_nr, e, length)); @@ -416,9 +416,9 @@ int diva_um_idi_write(void *entity, } /* - Copy function does access only locked verified memory, - also it can be called with spin lock held - */ + Copy function does access only locked verified memory, + also it can be called with spin lock held + */ if ((ret = (*cp_fn) (os_handle, e->buffer, src, length)) < 0) { DBG_TRC(("A: A(%d) E(%08x) write error=%d", a->adapter_nr, e, ret)); @@ -426,32 +426,32 @@ int diva_um_idi_write(void *entity, return (ret); } - req = (diva_um_idi_req_hdr_t *) & e->buffer[0]; + req = (diva_um_idi_req_hdr_t *)&e->buffer[0]; switch (req->type) { case DIVA_UM_IDI_GET_FEATURES:{ - DBG_LOG(("A(%d) get_features", a->adapter_nr)); - if (!(data = - diva_data_q_get_segment4write(&e->data))) { - DBG_ERR(("A(%d) get_features, no free buffer", - a->adapter_nr)); - diva_os_leave_spin_lock(&adapter_lock, - &old_irql, - "write"); - return (0); - } - diva_user_mode_idi_adapter_features(a, &(((diva_um_idi_ind_hdr_t - *) data)->hdr.features)); - ((diva_um_idi_ind_hdr_t *) data)->type = - DIVA_UM_IDI_IND_FEATURES; - ((diva_um_idi_ind_hdr_t *) data)->data_length = 0; - diva_data_q_ack_segment4write(&e->data, - sizeof(diva_um_idi_ind_hdr_t)); + DBG_LOG(("A(%d) get_features", a->adapter_nr)); + if (!(data = + diva_data_q_get_segment4write(&e->data))) { + DBG_ERR(("A(%d) get_features, no free buffer", + a->adapter_nr)); + diva_os_leave_spin_lock(&adapter_lock, + &old_irql, + "write"); + return (0); + } + diva_user_mode_idi_adapter_features(a, &(((diva_um_idi_ind_hdr_t + *) data)->hdr.features)); + ((diva_um_idi_ind_hdr_t *) data)->type = + DIVA_UM_IDI_IND_FEATURES; + ((diva_um_idi_ind_hdr_t *) data)->data_length = 0; + diva_data_q_ack_segment4write(&e->data, + sizeof(diva_um_idi_ind_hdr_t)); - diva_os_leave_spin_lock(&adapter_lock, &old_irql, "write"); + diva_os_leave_spin_lock(&adapter_lock, &old_irql, "write"); - diva_os_wakeup_read(e->os_context); - } + diva_os_wakeup_read(e->os_context); + } break; case DIVA_UM_IDI_REQ: @@ -486,9 +486,9 @@ int diva_um_idi_write(void *entity, } /* -------------------------------------------------------------------------- - CALLBACK FROM XDI - -------------------------------------------------------------------------- */ -static void diva_um_idi_xdi_callback(ENTITY * entity) + CALLBACK FROM XDI + -------------------------------------------------------------------------- */ +static void diva_um_idi_xdi_callback(ENTITY *entity) { divas_um_idi_entity_t *e = DIVAS_CONTAINING_RECORD(entity, divas_um_idi_entity_t, @@ -529,8 +529,8 @@ static void diva_um_idi_xdi_callback(ENTITY * entity) } } -static int process_idi_request(divas_um_idi_entity_t * e, - const diva_um_idi_req_hdr_t * req) +static int process_idi_request(divas_um_idi_entity_t *e, + const diva_um_idi_req_hdr_t *req) { int assign = 0; byte Req = (byte) req->Req; @@ -579,7 +579,7 @@ static int process_idi_request(divas_um_idi_entity_t * e, e->e.Req = Req; e->e.ReqCh = (byte) req->ReqCh; e->e.X->PLength = (word) req->data_length; - e->e.X->P = (byte *) & req[1]; /* Our buffer is safe */ + e->e.X->P = (byte *)&req[1]; /* Our buffer is safe */ DBG_TRC(("A(%d) E(%08x) request(%02x-%02x-%02x (%d))", e->adapter->adapter_nr, e, e->e.Id, e->e.Req, @@ -595,9 +595,9 @@ static int process_idi_request(divas_um_idi_entity_t * e, if (assign) { if (e->e.Rc == OUT_OF_RESOURCES) { /* - XDI has no entities more, call was not forwarded to the card, - no callback will be scheduled - */ + XDI has no entities more, call was not forwarded to the card, + no callback will be scheduled + */ DBG_ERR(("A: A(%d) E(%08x) XDI out of entities", e->adapter->adapter_nr, e)); @@ -621,7 +621,7 @@ static int process_idi_request(divas_um_idi_entity_t * e, return (0); } -static int process_idi_rc(divas_um_idi_entity_t * e, byte rc) +static int process_idi_rc(divas_um_idi_entity_t *e, byte rc) { DBG_TRC(("A(%d) E(%08x) rc(%02x-%02x-%02x)", e->adapter->adapter_nr, e, e->e.Id, rc, e->e.RcCh)); @@ -674,20 +674,20 @@ static int process_idi_rc(divas_um_idi_entity_t * e, byte rc) return (1); } -static int process_idi_ind(divas_um_idi_entity_t * e, byte ind) +static int process_idi_ind(divas_um_idi_entity_t *e, byte ind) { int do_wakeup = 0; if (e->e.complete != 0x02) { diva_um_idi_ind_hdr_t *pind = - (diva_um_idi_ind_hdr_t *) - diva_data_q_get_segment4write(&e->data); + (diva_um_idi_ind_hdr_t *) + diva_data_q_get_segment4write(&e->data); if (pind) { e->e.RNum = 1; - e->e.R->P = (byte *) & pind[1]; + e->e.R->P = (byte *)&pind[1]; e->e.R->PLength = - (word) (diva_data_q_get_max_length(&e->data) - - sizeof(*pind)); + (word) (diva_data_q_get_max_length(&e->data) - + sizeof(*pind)); DBG_TRC(("A(%d) E(%08x) ind_1(%02x-%02x-%02x)-[%d-%d]", e->adapter->adapter_nr, e, e->e.Id, ind, e->e.IndCh, e->e.RLength, @@ -703,7 +703,7 @@ static int process_idi_ind(divas_um_idi_entity_t * e, byte ind) } } else { diva_um_idi_ind_hdr_t *pind = - (diva_um_idi_ind_hdr_t *) (e->e.R->P); + (diva_um_idi_ind_hdr_t *) (e->e.R->P); DBG_TRC(("A(%d) E(%08x) ind(%02x-%02x-%02x)-[%d]", e->adapter->adapter_nr, e, e->e.Id, ind, @@ -728,14 +728,14 @@ static int process_idi_ind(divas_um_idi_entity_t * e, byte ind) } /* -------------------------------------------------------------------------- - Write return code to the return code queue of entity - -------------------------------------------------------------------------- */ -static int write_return_code(divas_um_idi_entity_t * e, byte rc) + Write return code to the return code queue of entity + -------------------------------------------------------------------------- */ +static int write_return_code(divas_um_idi_entity_t *e, byte rc) { diva_um_idi_ind_hdr_t *prc; if (!(prc = - (diva_um_idi_ind_hdr_t *) diva_data_q_get_segment4write(&e->rc))) + (diva_um_idi_ind_hdr_t *) diva_data_q_get_segment4write(&e->rc))) { DBG_ERR(("A: A(%d) E(%08x) rc(%02x) lost", e->adapter->adapter_nr, e, rc)); @@ -753,9 +753,9 @@ static int write_return_code(divas_um_idi_entity_t * e, byte rc) } /* -------------------------------------------------------------------------- - Return amount of entries that can be bead from this entity or - -1 if adapter was removed - -------------------------------------------------------------------------- */ + Return amount of entries that can be bead from this entity or + -1 if adapter was removed + -------------------------------------------------------------------------- */ int diva_user_mode_idi_ind_ready(void *entity, void *os_handle) { divas_um_idi_entity_t *e; @@ -771,16 +771,16 @@ int diva_user_mode_idi_ind_ready(void *entity, void *os_handle) if ((!a) || (a->status & DIVA_UM_IDI_ADAPTER_REMOVED)) { /* - Adapter was unloaded - */ + Adapter was unloaded + */ diva_os_leave_spin_lock(&adapter_lock, &old_irql, "ind_ready"); return (-1); /* adapter was removed */ } if (e->status & DIVA_UM_IDI_REMOVED) { /* - entity was removed as result of adapter removal - user should assign this entity again - */ + entity was removed as result of adapter removal + user should assign this entity again + */ diva_os_leave_spin_lock(&adapter_lock, &old_irql, "ind_ready"); return (-1); } @@ -827,7 +827,7 @@ int divas_um_idi_entity_assigned(void *entity) DBG_TRC(("Id:%02x, rc_count:%d, status:%08x", e->e.Id, e->rc_count, e->status)) - diva_os_leave_spin_lock(&adapter_lock, &old_irql, "assigned?"); + diva_os_leave_spin_lock(&adapter_lock, &old_irql, "assigned?"); return (ret); } @@ -850,23 +850,23 @@ int divas_um_idi_entity_start_remove(void *entity) if (e->rc_count) { /* - Entity BUSY - */ + Entity BUSY + */ diva_os_leave_spin_lock(&adapter_lock, &old_irql, "start_remove"); return (1); } if (!e->e.Id) { /* - Remove request was already pending, and arrived now - */ + Remove request was already pending, and arrived now + */ diva_os_leave_spin_lock(&adapter_lock, &old_irql, "start_remove"); return (0); /* REMOVE was pending */ } /* - Now send remove request - */ + Now send remove request + */ e->e.Req = REMOVE; e->e.ReqCh = 0; diff --git a/drivers/isdn/hardware/eicon/um_idi.h b/drivers/isdn/hardware/eicon/um_idi.h index 141072f8881e..ffb88f7b42fc 100644 --- a/drivers/isdn/hardware/eicon/um_idi.h +++ b/drivers/isdn/hardware/eicon/um_idi.h @@ -6,7 +6,7 @@ /* interface between UM IDI core and OS dependent part - */ +*/ int diva_user_mode_idi_init(void); void diva_user_mode_idi_finit(void); void *divas_um_idi_create_entity(dword adapter_nr, void *file); diff --git a/drivers/isdn/hardware/eicon/xdi_adapter.h b/drivers/isdn/hardware/eicon/xdi_adapter.h index a3bd163afb8f..d303e65dbe6c 100644 --- a/drivers/isdn/hardware/eicon/xdi_adapter.h +++ b/drivers/isdn/hardware/eicon/xdi_adapter.h @@ -24,12 +24,12 @@ typedef union _divas_card_resources { } divas_card_resources_t; struct _diva_os_xdi_adapter; -typedef int (*diva_init_card_proc_t) (struct _diva_os_xdi_adapter * a); -typedef int (*diva_cmd_card_proc_t) (struct _diva_os_xdi_adapter * a, - diva_xdi_um_cfg_cmd_t * data, - int length); -typedef void (*diva_xdi_clear_interrupts_proc_t) (struct - _diva_os_xdi_adapter *); +typedef int (*diva_init_card_proc_t)(struct _diva_os_xdi_adapter *a); +typedef int (*diva_cmd_card_proc_t)(struct _diva_os_xdi_adapter *a, + diva_xdi_um_cfg_cmd_t *data, + int length); +typedef void (*diva_xdi_clear_interrupts_proc_t)(struct + _diva_os_xdi_adapter *); #define DIVA_XDI_MBOX_BUSY 1 #define DIVA_XDI_MBOX_WAIT_XLOG 2 diff --git a/drivers/isdn/hardware/eicon/xdi_msg.h b/drivers/isdn/hardware/eicon/xdi_msg.h index 3ade28f66698..58368f7b5cba 100644 --- a/drivers/isdn/hardware/eicon/xdi_msg.h +++ b/drivers/isdn/hardware/eicon/xdi_msg.h @@ -80,7 +80,7 @@ /* Set untranslated protocol code features - */ +*/ #define DIVA_XDI_UM_CMD_SET_PROTOCOL_FEATURES 11 typedef struct _diva_xdi_um_cfg_cmd_data_set_features { diff --git a/drivers/isdn/hardware/eicon/xdi_vers.h b/drivers/isdn/hardware/eicon/xdi_vers.h index cf3494185b9d..b3479e59c7c5 100644 --- a/drivers/isdn/hardware/eicon/xdi_vers.h +++ b/drivers/isdn/hardware/eicon/xdi_vers.h @@ -1,26 +1,26 @@ /* * - Copyright (c) Eicon Networks, 2002. + Copyright (c) Eicon Networks, 2002. * - This source file is supplied for the use with - Eicon Networks range of DIVA Server Adapters. + This source file is supplied for the use with + Eicon Networks range of DIVA Server Adapters. * - Eicon File Revision : 2.1 + Eicon File Revision : 2.1 * - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. * - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY - 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 OF ANY KIND WHATSOEVER INCLUDING ANY + 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., 675 Mass Ave, Cambridge, MA 02139, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -static char diva_xdi_common_code_build[] = "102-52"; +static char diva_xdi_common_code_build[] = "102-52"; diff --git a/drivers/isdn/hardware/mISDN/avmfritz.c b/drivers/isdn/hardware/mISDN/avmfritz.c index 861b6511f3ee..05ed4d0cb18b 100644 --- a/drivers/isdn/hardware/mISDN/avmfritz.c +++ b/drivers/isdn/hardware/mISDN/avmfritz.c @@ -257,10 +257,10 @@ static struct bchannel * Sel_BCS(struct fritzcard *fc, u32 channel) { if (test_bit(FLG_ACTIVE, &fc->bch[0].Flags) && - (fc->bch[0].nr & channel)) + (fc->bch[0].nr & channel)) return &fc->bch[0]; else if (test_bit(FLG_ACTIVE, &fc->bch[1].Flags) && - (fc->bch[1].nr & channel)) + (fc->bch[1].nr & channel)) return &fc->bch[1]; else return NULL; @@ -277,7 +277,7 @@ __write_ctrl_pci(struct fritzcard *fc, struct hdlc_hw *hdlc, u32 channel) { static inline void __write_ctrl_pciv2(struct fritzcard *fc, struct hdlc_hw *hdlc, u32 channel) { outl(hdlc->ctrl.ctrl, fc->addr + (channel == 2 ? AVM_HDLC_STATUS_2 : - AVM_HDLC_STATUS_1)); + AVM_HDLC_STATUS_1)); } void @@ -287,7 +287,7 @@ write_ctrl(struct bchannel *bch, int which) { hdlc = &fc->hdlc[(bch->nr - 1) & 1]; pr_debug("%s: hdlc %c wr%x ctrl %x\n", fc->name, '@' + bch->nr, - which, hdlc->ctrl.ctrl); + which, hdlc->ctrl.ctrl); switch (fc->type) { case AVM_FRITZ_PCIV2: __write_ctrl_pciv2(fc, hdlc, bch->nr); @@ -310,7 +310,7 @@ static inline u32 __read_status_pciv2(u_long addr, u32 channel) { return inl(addr + (channel == 2 ? AVM_HDLC_STATUS_2 : - AVM_HDLC_STATUS_1)); + AVM_HDLC_STATUS_1)); } @@ -349,7 +349,7 @@ modehdlc(struct bchannel *bch, int protocol) hdlc = &fc->hdlc[(bch->nr - 1) & 1]; pr_debug("%s: hdlc %c protocol %x-->%x ch %d\n", fc->name, - '@' + bch->nr, bch->state, protocol, bch->nr); + '@' + bch->nr, bch->state, protocol, bch->nr); hdlc->ctrl.ctrl = 0; switch (protocol) { case -1: /* used for init */ @@ -411,14 +411,14 @@ hdlc_empty_fifo(struct bchannel *bch, int count) } if ((bch->rx_skb->len + count) > bch->maxlen) { pr_debug("%s: overrun %d\n", fc->name, - bch->rx_skb->len + count); + bch->rx_skb->len + count); return; } p = skb_put(bch->rx_skb, count); ptr = (u32 *)p; if (AVM_FRITZ_PCIV2 == fc->type) addr = fc->addr + (bch->nr == 2 ? - AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1); + AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1); else { addr = fc->addr + CHIP_WINDOW; outl(bch->nr == 2 ? AVM_HDLC_2 : AVM_HDLC_1, fc->addr); @@ -431,7 +431,7 @@ hdlc_empty_fifo(struct bchannel *bch, int count) } if (debug & DEBUG_HW_BFIFO) { snprintf(fc->log, LOG_SIZE, "B%1d-recv %s %d ", - bch->nr, fc->name, count); + bch->nr, fc->name, count); print_hex_dump_bytes(fc->log, DUMP_PREFIX_OFFSET, p, count); } } @@ -460,14 +460,14 @@ hdlc_fill_fifo(struct bchannel *bch) hdlc->ctrl.sr.cmd |= HDLC_CMD_XME; } pr_debug("%s: %s %d/%d/%d", fc->name, __func__, count, - bch->tx_idx, bch->tx_skb->len); + bch->tx_idx, bch->tx_skb->len); ptr = (u32 *)p; bch->tx_idx += count; hdlc->ctrl.sr.xml = ((count == HDLC_FIFO_SIZE) ? 0 : count); if (AVM_FRITZ_PCIV2 == fc->type) { __write_ctrl_pciv2(fc, hdlc, bch->nr); addr = fc->addr + (bch->nr == 2 ? - AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1); + AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1); } else { __write_ctrl_pci(fc, hdlc, bch->nr); addr = fc->addr + CHIP_WINDOW; @@ -480,7 +480,7 @@ hdlc_fill_fifo(struct bchannel *bch) } if (debug & DEBUG_HW_BFIFO) { snprintf(fc->log, LOG_SIZE, "B%1d-send %s %d ", - bch->nr, fc->name, count); + bch->nr, fc->name, count); print_hex_dump_bytes(fc->log, DUMP_PREFIX_OFFSET, p, count); } } @@ -528,14 +528,14 @@ HDLC_irq(struct bchannel *bch, u32 stat) if (!bch->rx_skb) goto handle_tx; if ((stat & HDLC_STAT_RME) || test_bit(FLG_TRANSPARENT, - &bch->Flags)) { + &bch->Flags)) { if (((stat & HDLC_STAT_CRCVFRRAB) == - HDLC_STAT_CRCVFR) || + HDLC_STAT_CRCVFR) || test_bit(FLG_TRANSPARENT, &bch->Flags)) { recv_Bchannel(bch, 0); } else { pr_debug("%s: got invalid frame\n", - fc->name); + fc->name); skb_trim(bch->rx_skb, 0); } } @@ -549,11 +549,11 @@ HDLC_irq(struct bchannel *bch, u32 stat) */ if (bch->tx_skb) pr_debug("%s: ch%d XDU len(%d) idx(%d) Flags(%lx)\n", - fc->name, bch->nr, bch->tx_skb->len, - bch->tx_idx, bch->Flags); + fc->name, bch->nr, bch->tx_skb->len, + bch->tx_idx, bch->Flags); else pr_debug("%s: ch%d XDU no tx_skb Flags(%lx)\n", - fc->name, bch->nr, bch->Flags); + fc->name, bch->nr, bch->Flags); if (bch->tx_skb && bch->tx_skb->len) { if (!test_bit(FLG_TRANSPARENT, &bch->Flags)) bch->tx_idx = 0; @@ -685,7 +685,7 @@ avm_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&fc->lock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: spin_lock_irqsave(&fc->lock, flags); @@ -693,7 +693,7 @@ avm_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) modehdlc(bch, ISDN_P_NONE); spin_unlock_irqrestore(&fc->lock, flags); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); ret = 0; break; } @@ -749,7 +749,7 @@ reset_avm(struct fritzcard *fc) mdelay(1); if (debug & DEBUG_HW) pr_notice("%s: S0/S1 %x/%x\n", fc->name, - inb(fc->addr + 2), inb(fc->addr + 3)); + inb(fc->addr + 2), inb(fc->addr + 3)); } static int @@ -761,10 +761,10 @@ init_card(struct fritzcard *fc) reset_avm(fc); /* disable IRQ */ if (fc->type == AVM_FRITZ_PCIV2) ret = request_irq(fc->irq, avm_fritzv2_interrupt, - IRQF_SHARED, fc->name, fc); + IRQF_SHARED, fc->name, fc); else ret = request_irq(fc->irq, avm_fritz_interrupt, - IRQF_SHARED, fc->name, fc); + IRQF_SHARED, fc->name, fc); if (ret) { pr_info("%s: couldn't get interrupt %d\n", fc->name, fc->irq); @@ -795,7 +795,7 @@ init_card(struct fritzcard *fc) msleep_interruptible(10); if (debug & DEBUG_HW) pr_notice("%s: IRQ %d count %d\n", fc->name, - fc->irq, fc->irqcnt); + fc->irq, fc->irqcnt); if (!fc->irqcnt) { pr_info("%s: IRQ(%d) getting no IRQs during init %d\n", fc->name, fc->irq, 3 - cnt); @@ -817,7 +817,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_GETOP: cq->op = 0; break; - /* Nothing implemented yet */ + /* Nothing implemented yet */ case MISDN_CTRL_FILL_EMPTY: default: pr_info("%s: %s unknown Op %x\n", fc->name, __func__, cq->op); @@ -931,7 +931,7 @@ avm_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; case CLOSE_CHANNEL: pr_debug("%s: dev(%d) close from %p\n", fc->name, dch->dev.id, - __builtin_return_address(0)); + __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -939,7 +939,7 @@ avm_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; default: pr_debug("%s: %s unknown command %x\n", - fc->name, __func__, cmd); + fc->name, __func__, cmd); return -EINVAL; } return err; @@ -963,7 +963,7 @@ setup_fritz(struct fritzcard *fc) if (debug & DEBUG_HW) { pr_notice("%s: PCI stat %#x\n", fc->name, val); pr_notice("%s: PCI Class %X Rev %d\n", fc->name, - val & 0xff, (val >> 8) & 0xff); + val & 0xff, (val >> 8) & 0xff); pr_notice("%s: HDLC version %x\n", fc->name, ver & 0xf); } ASSIGN_FUNC(V1, ISAC, fc->isac); @@ -975,7 +975,7 @@ setup_fritz(struct fritzcard *fc) if (debug & DEBUG_HW) { pr_notice("%s: PCI V2 stat %#x\n", fc->name, val); pr_notice("%s: PCI V2 Class %X Rev %d\n", fc->name, - val & 0xff, (val>>8) & 0xff); + val & 0xff, (val >> 8) & 0xff); pr_notice("%s: HDLC version %x\n", fc->name, ver & 0xf); } ASSIGN_FUNC(V2, ISAC, fc->isac); @@ -987,8 +987,8 @@ setup_fritz(struct fritzcard *fc) return -ENODEV; } pr_notice("%s: %s config irq:%d base:0x%X\n", fc->name, - (fc->type == AVM_FRITZ_PCI) ? "AVM Fritz!CARD PCI" : - "AVM Fritz!CARD PCIv2", fc->irq, fc->addr); + (fc->type == AVM_FRITZ_PCI) ? "AVM Fritz!CARD PCI" : + "AVM Fritz!CARD PCIv2", fc->irq, fc->addr); return 0; } @@ -1035,7 +1035,7 @@ setup_instance(struct fritzcard *card) mISDNisac_init(&card->isac, card); card->isac.dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | - (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); + (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); card->isac.dch.dev.D.ctrl = avm_dctrl; for (i = 0; i < 2; i++) { card->bch[i].nr = i + 1; @@ -1051,7 +1051,7 @@ setup_instance(struct fritzcard *card) if (err) goto error; err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev, - card->name); + card->name); if (err) goto error_reg; err = init_card(card); @@ -1097,7 +1097,7 @@ fritzpci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } pr_notice("mISDN: found adapter %s at %s\n", - (char *) ent->driver_data, pci_name(pdev)); + (char *) ent->driver_data, pci_name(pdev)); card->addr = pci_resource_start(pdev, 1); card->irq = pdev->irq; diff --git a/drivers/isdn/hardware/mISDN/hfc_multi.h b/drivers/isdn/hardware/mISDN/hfc_multi.h index 0c773866efc7..b0588acbb47d 100644 --- a/drivers/isdn/hardware/mISDN/hfc_multi.h +++ b/drivers/isdn/hardware/mISDN/hfc_multi.h @@ -33,13 +33,13 @@ */ /* -#define MAX_FRAME_SIZE 2048 + #define MAX_FRAME_SIZE 2048 */ struct hfc_chan { struct dchannel *dch; /* link if channel is a D-channel */ struct bchannel *bch; /* link if channel is a B-channel */ - int port; /* the interface port this */ + int port; /* the interface port this */ /* channel is associated with */ int nt_timer; /* -1 if off, 0 if elapsed, >0 if running */ int los, ais, slip_tx, slip_rx, rdi; /* current alarms */ @@ -89,7 +89,7 @@ struct hfcm_hw { #define HFC_CFG_REPORT_RDI 8 /* the card should report remote alarm */ #define HFC_CFG_DTMF 9 /* enable DTMF-detection */ #define HFC_CFG_CRC4 10 /* disable CRC-4 Multiframe mode, */ - /* use double frame instead. */ +/* use double frame instead. */ #define HFC_TYPE_E1 1 /* controller is HFC-E1 */ #define HFC_TYPE_4S 4 /* controller is HFC-4S */ @@ -109,9 +109,9 @@ struct hfcm_hw { #define HFC_CHIP_E1CLOCK_GET 10 /* always get clock from E1 interface */ #define HFC_CHIP_E1CLOCK_PUT 11 /* always put clock from E1 interface */ #define HFC_CHIP_WATCHDOG 12 /* whether we should send signals */ - /* to the watchdog */ +/* to the watchdog */ #define HFC_CHIP_B410P 13 /* whether we have a b410p with echocan in */ - /* hw */ +/* hw */ #define HFC_CHIP_PLXSD 14 /* whether we have a Speech-Design PLX */ #define HFC_CHIP_EMBSD 15 /* whether we have a SD Embedded board */ @@ -148,26 +148,26 @@ struct hfc_multi { int io_mode; /* selects mode */ #ifdef HFC_REGISTER_DEBUG void (*HFC_outb)(struct hfc_multi *hc, u_char reg, - u_char val, const char *function, int line); + u_char val, const char *function, int line); void (*HFC_outb_nodebug)(struct hfc_multi *hc, u_char reg, - u_char val, const char *function, int line); + u_char val, const char *function, int line); u_char (*HFC_inb)(struct hfc_multi *hc, u_char reg, - const char *function, int line); + const char *function, int line); u_char (*HFC_inb_nodebug)(struct hfc_multi *hc, u_char reg, - const char *function, int line); + const char *function, int line); u_short (*HFC_inw)(struct hfc_multi *hc, u_char reg, - const char *function, int line); + const char *function, int line); u_short (*HFC_inw_nodebug)(struct hfc_multi *hc, u_char reg, - const char *function, int line); + const char *function, int line); void (*HFC_wait)(struct hfc_multi *hc, - const char *function, int line); + const char *function, int line); void (*HFC_wait_nodebug)(struct hfc_multi *hc, - const char *function, int line); + const char *function, int line); #else void (*HFC_outb)(struct hfc_multi *hc, u_char reg, - u_char val); + u_char val); void (*HFC_outb_nodebug)(struct hfc_multi *hc, u_char reg, - u_char val); + u_char val); u_char (*HFC_inb)(struct hfc_multi *hc, u_char reg); u_char (*HFC_inb_nodebug)(struct hfc_multi *hc, u_char reg); u_short (*HFC_inw)(struct hfc_multi *hc, u_char reg); @@ -176,9 +176,9 @@ struct hfc_multi { void (*HFC_wait_nodebug)(struct hfc_multi *hc); #endif void (*read_fifo)(struct hfc_multi *hc, u_char *data, - int len); + int len); void (*write_fifo)(struct hfc_multi *hc, u_char *data, - int len); + int len); u_long pci_origmembase, plx_origmembase; void __iomem *pci_membase; /* PCI memory */ void __iomem *plx_membase; /* PLX memory */ @@ -211,10 +211,10 @@ struct hfc_multi { /* an optical Interface */ int dslot; /* channel # of d-channel (E1) default 16 */ - u_long wdcount; /* every 500 ms we need to */ + u_long wdcount; /* every 500 ms we need to */ /* send the watchdog a signal */ u_char wdbyte; /* watchdog toggle byte */ - u_int activity[8]; /* if there is any action on this */ + u_int activity[8]; /* if there is any action on this */ /* port (will be cleared after */ /* showing led-states) */ int e1_state; /* keep track of last state */ @@ -268,7 +268,7 @@ struct hfc_multi { #define PLX_DSP_RES_N PLX_GPIO8 /* GPIO4..8 Enable & Set to OUT, SLAVE_EN_N = 1 */ #define PLX_GPIOC_INIT (PLX_GPIO4_DIR | PLX_GPIO5_DIR | PLX_GPIO6_DIR \ - | PLX_GPIO7_DIR | PLX_GPIO8_DIR | PLX_SLAVE_EN_N) + | PLX_GPIO7_DIR | PLX_GPIO8_DIR | PLX_SLAVE_EN_N) /* PLX Interrupt Control/STATUS */ #define PLX_INTCSR_LINTI1_ENABLE 0x01 @@ -290,7 +290,7 @@ struct hfc_multi { /* write only registers */ #define R_CIRM 0x00 #define R_CTRL 0x01 -#define R_BRG_PCM_CFG 0x02 +#define R_BRG_PCM_CFG 0x02 #define R_RAM_ADDR0 0x08 #define R_RAM_ADDR1 0x09 #define R_RAM_ADDR2 0x0A @@ -687,8 +687,8 @@ struct hfc_multi { #define V_NEG_CLK 0x08 #define V_HCLK 0x10 /* -#define V_JATT_AUTO_DEL 0x20 -#define V_JATT_AUTO 0x40 + #define V_JATT_AUTO_DEL 0x20 + #define V_JATT_AUTO 0x40 */ #define V_JATT_OFF 0x80 /* R_STATE */ @@ -1230,4 +1230,3 @@ struct hfc_register_names { {"R_IRQ_FIFO_BL7", 0xCF}, }; #endif /* HFC_REGISTER_DEBUG */ - diff --git a/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h b/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h index 45ddced956d5..0eafe9f04fca 100644 --- a/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h +++ b/drivers/isdn/hardware/mISDN/hfc_multi_8xx.h @@ -16,9 +16,9 @@ static void #ifdef HFC_REGISTER_DEBUG HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val, - const char *function, int line) + const char *function, int line) #else -HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val) + HFC_outb_embsd(struct hfc_multi *hc, u_char reg, u_char val) #endif { hc->immap->im_ioport.iop_padat |= PA_XHFC_A0; @@ -30,7 +30,7 @@ static u_char #ifdef HFC_REGISTER_DEBUG HFC_inb_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line) #else -HFC_inb_embsd(struct hfc_multi *hc, u_char reg) + HFC_inb_embsd(struct hfc_multi *hc, u_char reg) #endif { hc->immap->im_ioport.iop_padat |= PA_XHFC_A0; @@ -42,7 +42,7 @@ static u_short #ifdef HFC_REGISTER_DEBUG HFC_inw_embsd(struct hfc_multi *hc, u_char reg, const char *function, int line) #else -HFC_inw_embsd(struct hfc_multi *hc, u_char reg) + HFC_inw_embsd(struct hfc_multi *hc, u_char reg) #endif { hc->immap->im_ioport.iop_padat |= PA_XHFC_A0; @@ -54,7 +54,7 @@ static void #ifdef HFC_REGISTER_DEBUG HFC_wait_embsd(struct hfc_multi *hc, const char *function, int line) #else -HFC_wait_embsd(struct hfc_multi *hc) + HFC_wait_embsd(struct hfc_multi *hc) #endif { hc->immap->im_ioport.iop_padat |= PA_XHFC_A0; @@ -96,8 +96,8 @@ static int setup_embedded(struct hfc_multi *hc, struct hm_map *m) { printk(KERN_INFO - "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n", - m->vendor_name, m->card_name, m->clock2 ? "double" : "normal"); + "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n", + m->vendor_name, m->card_name, m->clock2 ? "double" : "normal"); hc->pci_dev = NULL; if (m->clock2) @@ -129,20 +129,20 @@ setup_embedded(struct hfc_multi *hc, struct hm_map *m) hc->write_fifo = write_fifo_embsd; hc->xhfc_origmembase = XHFC_MEMBASE + XHFC_OFFSET * hc->id; hc->xhfc_membase = (u_char *)ioremap(hc->xhfc_origmembase, - XHFC_MEMSIZE); + XHFC_MEMSIZE); if (!hc->xhfc_membase) { printk(KERN_WARNING - "HFC-multi: failed to remap xhfc address space. " - "(internal error)\n"); + "HFC-multi: failed to remap xhfc address space. " + "(internal error)\n"); return -EIO; } hc->xhfc_memaddr = (u_long *)(hc->xhfc_membase + 4); hc->xhfc_memdata = (u_long *)(hc->xhfc_membase); printk(KERN_INFO - "HFC-multi: xhfc_membase:%#lx xhfc_origmembase:%#lx " - "xhfc_memaddr:%#lx xhfc_memdata:%#lx\n", - (u_long)hc->xhfc_membase, hc->xhfc_origmembase, - (u_long)hc->xhfc_memaddr, (u_long)hc->xhfc_memdata); + "HFC-multi: xhfc_membase:%#lx xhfc_origmembase:%#lx " + "xhfc_memaddr:%#lx xhfc_memdata:%#lx\n", + (u_long)hc->xhfc_membase, hc->xhfc_origmembase, + (u_long)hc->xhfc_memaddr, (u_long)hc->xhfc_memdata); break; default: printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n"); diff --git a/drivers/isdn/hardware/mISDN/hfc_pci.h b/drivers/isdn/hardware/mISDN/hfc_pci.h index 3132ddc99fcd..411cd10772e8 100644 --- a/drivers/isdn/hardware/mISDN/hfc_pci.h +++ b/drivers/isdn/hardware/mISDN/hfc_pci.h @@ -58,7 +58,7 @@ /* GCI/IOM bus configuration registers */ #define HFCPCI_MST_EMOD 0xB4 #define HFCPCI_MST_MODE 0xB8 -#define HFCPCI_CONNECT 0xBC +#define HFCPCI_CONNECT 0xBC /* Interrupt and status registers */ @@ -189,18 +189,18 @@ struct zt { struct dfifo { u_char data[D_FIFO_SIZE]; /* FIFO data space */ - u_char fill1[0x20A0-D_FIFO_SIZE]; /* reserved, do not use */ + u_char fill1[0x20A0 - D_FIFO_SIZE]; /* reserved, do not use */ u_char f1, f2; /* f pointers */ - u_char fill2[0x20C0-0x20A2]; /* reserved, do not use */ + u_char fill2[0x20C0 - 0x20A2]; /* reserved, do not use */ /* mask index with D_FREG_MASK for access */ - struct zt za[MAX_D_FRAMES+1]; - u_char fill3[0x4000-0x2100]; /* align 16K */ + struct zt za[MAX_D_FRAMES + 1]; + u_char fill3[0x4000 - 0x2100]; /* align 16K */ }; struct bzfifo { - struct zt za[MAX_B_FRAMES+1]; /* only range 0x0..0x1F allowed */ + struct zt za[MAX_B_FRAMES + 1]; /* only range 0x0..0x1F allowed */ u_char f1, f2; /* f pointers */ - u_char fill[0x2100-0x2082]; /* alignment */ + u_char fill[0x2100 - 0x2082]; /* alignment */ }; @@ -224,5 +224,5 @@ union fifo_area { u_char fill[32768]; }; -#define Write_hfc(a, b, c) (writeb(c, (a->hw.pci_io)+b)) -#define Read_hfc(a, b) (readb((a->hw.pci_io)+b)) +#define Write_hfc(a, b, c) (writeb(c, (a->hw.pci_io) + b)) +#define Read_hfc(a, b) (readb((a->hw.pci_io) + b)) diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c index a440d7fff0ad..033223180b55 100644 --- a/drivers/isdn/hardware/mISDN/hfcmulti.c +++ b/drivers/isdn/hardware/mISDN/hfcmulti.c @@ -142,7 +142,7 @@ * * hwid: * NOTE: only one hwid value must be given once - * Enable special embedded devices with XHFC controllers. + * Enable special embedded devices with XHFC controllers. */ /* @@ -161,8 +161,8 @@ #include /* -#define IRQCOUNT_DEBUG -#define IRQ_DEBUG + #define IRQCOUNT_DEBUG + #define IRQ_DEBUG */ #include "hfc_multi.h" @@ -237,21 +237,21 @@ module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR); module_param(hwid, uint, S_IRUGO | S_IWUSR); /* The hardware ID */ #ifdef HFC_REGISTER_DEBUG -#define HFC_outb(hc, reg, val) \ +#define HFC_outb(hc, reg, val) \ (hc->HFC_outb(hc, reg, val, __func__, __LINE__)) -#define HFC_outb_nodebug(hc, reg, val) \ +#define HFC_outb_nodebug(hc, reg, val) \ (hc->HFC_outb_nodebug(hc, reg, val, __func__, __LINE__)) -#define HFC_inb(hc, reg) \ +#define HFC_inb(hc, reg) \ (hc->HFC_inb(hc, reg, __func__, __LINE__)) -#define HFC_inb_nodebug(hc, reg) \ +#define HFC_inb_nodebug(hc, reg) \ (hc->HFC_inb_nodebug(hc, reg, __func__, __LINE__)) -#define HFC_inw(hc, reg) \ +#define HFC_inw(hc, reg) \ (hc->HFC_inw(hc, reg, __func__, __LINE__)) -#define HFC_inw_nodebug(hc, reg) \ +#define HFC_inw_nodebug(hc, reg) \ (hc->HFC_inw_nodebug(hc, reg, __func__, __LINE__)) -#define HFC_wait(hc) \ +#define HFC_wait(hc) \ (hc->HFC_wait(hc, __func__, __LINE__)) -#define HFC_wait_nodebug(hc) \ +#define HFC_wait_nodebug(hc) \ (hc->HFC_wait_nodebug(hc, __func__, __LINE__)) #else #define HFC_outb(hc, reg, val) (hc->HFC_outb(hc, reg, val)) @@ -274,7 +274,7 @@ static void HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val, const char *function, int line) #else -HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val) + HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val) #endif { writeb(val, hc->pci_membase + reg); @@ -283,7 +283,7 @@ static u_char #ifdef HFC_REGISTER_DEBUG HFC_inb_pcimem(struct hfc_multi *hc, u_char reg, const char *function, int line) #else -HFC_inb_pcimem(struct hfc_multi *hc, u_char reg) + HFC_inb_pcimem(struct hfc_multi *hc, u_char reg) #endif { return readb(hc->pci_membase + reg); @@ -292,7 +292,7 @@ static u_short #ifdef HFC_REGISTER_DEBUG HFC_inw_pcimem(struct hfc_multi *hc, u_char reg, const char *function, int line) #else -HFC_inw_pcimem(struct hfc_multi *hc, u_char reg) + HFC_inw_pcimem(struct hfc_multi *hc, u_char reg) #endif { return readw(hc->pci_membase + reg); @@ -301,7 +301,7 @@ static void #ifdef HFC_REGISTER_DEBUG HFC_wait_pcimem(struct hfc_multi *hc, const char *function, int line) #else -HFC_wait_pcimem(struct hfc_multi *hc) + HFC_wait_pcimem(struct hfc_multi *hc) #endif { while (readb(hc->pci_membase + R_STATUS) & V_BUSY) @@ -312,9 +312,9 @@ HFC_wait_pcimem(struct hfc_multi *hc) static void #ifdef HFC_REGISTER_DEBUG HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val, - const char *function, int line) + const char *function, int line) #else -HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val) + HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val) #endif { outb(reg, hc->pci_iobase + 4); @@ -324,7 +324,7 @@ static u_char #ifdef HFC_REGISTER_DEBUG HFC_inb_regio(struct hfc_multi *hc, u_char reg, const char *function, int line) #else -HFC_inb_regio(struct hfc_multi *hc, u_char reg) + HFC_inb_regio(struct hfc_multi *hc, u_char reg) #endif { outb(reg, hc->pci_iobase + 4); @@ -334,7 +334,7 @@ static u_short #ifdef HFC_REGISTER_DEBUG HFC_inw_regio(struct hfc_multi *hc, u_char reg, const char *function, int line) #else -HFC_inw_regio(struct hfc_multi *hc, u_char reg) + HFC_inw_regio(struct hfc_multi *hc, u_char reg) #endif { outb(reg, hc->pci_iobase + 4); @@ -344,7 +344,7 @@ static void #ifdef HFC_REGISTER_DEBUG HFC_wait_regio(struct hfc_multi *hc, const char *function, int line) #else -HFC_wait_regio(struct hfc_multi *hc) + HFC_wait_regio(struct hfc_multi *hc) #endif { outb(R_STATUS, hc->pci_iobase + 4); @@ -355,7 +355,7 @@ HFC_wait_regio(struct hfc_multi *hc) #ifdef HFC_REGISTER_DEBUG static void HFC_outb_debug(struct hfc_multi *hc, u_char reg, u_char val, - const char *function, int line) + const char *function, int line) { char regname[256] = "", bits[9] = "xxxxxxxx"; int i; @@ -377,8 +377,8 @@ HFC_outb_debug(struct hfc_multi *hc, u_char reg, u_char val, bits[1] = '0' + (!!(val & 64)); bits[0] = '0' + (!!(val & 128)); printk(KERN_DEBUG - "HFC_outb(chip %d, %02x=%s, 0x%02x=%s); in %s() line %d\n", - hc->id, reg, regname, val, bits, function, line); + "HFC_outb(chip %d, %02x=%s, 0x%02x=%s); in %s() line %d\n", + hc->id, reg, regname, val, bits, function, line); HFC_outb_nodebug(hc, reg, val); } static u_char @@ -407,8 +407,8 @@ HFC_inb_debug(struct hfc_multi *hc, u_char reg, const char *function, int line) bits[1] = '0' + (!!(val & 64)); bits[0] = '0' + (!!(val & 128)); printk(KERN_DEBUG - "HFC_inb(chip %d, %02x=%s) = 0x%02x=%s; in %s() line %d\n", - hc->id, reg, regname, val, bits, function, line); + "HFC_inb(chip %d, %02x=%s) = 0x%02x=%s; in %s() line %d\n", + hc->id, reg, regname, val, bits, function, line); return val; } static u_short @@ -429,15 +429,15 @@ HFC_inw_debug(struct hfc_multi *hc, u_char reg, const char *function, int line) strcpy(regname, "register"); printk(KERN_DEBUG - "HFC_inw(chip %d, %02x=%s) = 0x%04x; in %s() line %d\n", - hc->id, reg, regname, val, function, line); + "HFC_inw(chip %d, %02x=%s) = 0x%04x; in %s() line %d\n", + hc->id, reg, regname, val, function, line); return val; } static void HFC_wait_debug(struct hfc_multi *hc, const char *function, int line) { printk(KERN_DEBUG "HFC_wait(chip %d); in %s() line %d\n", - hc->id, function, line); + hc->id, function, line); HFC_wait_nodebug(hc); } #endif @@ -446,13 +446,13 @@ HFC_wait_debug(struct hfc_multi *hc, const char *function, int line) static void write_fifo_regio(struct hfc_multi *hc, u_char *data, int len) { - outb(A_FIFO_DATA0, (hc->pci_iobase)+4); - while (len>>2) { + outb(A_FIFO_DATA0, (hc->pci_iobase) + 4); + while (len >> 2) { outl(cpu_to_le32(*(u32 *)data), hc->pci_iobase); data += 4; len -= 4; } - while (len>>1) { + while (len >> 1) { outw(cpu_to_le16(*(u16 *)data), hc->pci_iobase); data += 2; len -= 2; @@ -467,15 +467,15 @@ write_fifo_regio(struct hfc_multi *hc, u_char *data, int len) static void write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len) { - while (len>>2) { + while (len >> 2) { writel(cpu_to_le32(*(u32 *)data), - hc->pci_membase + A_FIFO_DATA0); + hc->pci_membase + A_FIFO_DATA0); data += 4; len -= 4; } - while (len>>1) { + while (len >> 1) { writew(cpu_to_le16(*(u16 *)data), - hc->pci_membase + A_FIFO_DATA0); + hc->pci_membase + A_FIFO_DATA0); data += 2; len -= 2; } @@ -490,13 +490,13 @@ write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len) static void read_fifo_regio(struct hfc_multi *hc, u_char *data, int len) { - outb(A_FIFO_DATA0, (hc->pci_iobase)+4); - while (len>>2) { + outb(A_FIFO_DATA0, (hc->pci_iobase) + 4); + while (len >> 2) { *(u32 *)data = le32_to_cpu(inl(hc->pci_iobase)); data += 4; len -= 4; } - while (len>>1) { + while (len >> 1) { *(u16 *)data = le16_to_cpu(inw(hc->pci_iobase)); data += 2; len -= 2; @@ -512,13 +512,13 @@ read_fifo_regio(struct hfc_multi *hc, u_char *data, int len) static void read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len) { - while (len>>2) { + while (len >> 2) { *(u32 *)data = le32_to_cpu(readl(hc->pci_membase + A_FIFO_DATA0)); data += 4; len -= 4; } - while (len>>1) { + while (len >> 1) { *(u16 *)data = le16_to_cpu(readw(hc->pci_membase + A_FIFO_DATA0)); data += 2; @@ -607,7 +607,7 @@ writepcibridge(struct hfc_multi *hc, unsigned char address, unsigned char data) outw(cipv, hc->pci_iobase + 4); /* define a 32 bit dword with 4 identical bytes for write sequence */ datav = data | ((__u32) data << 8) | ((__u32) data << 16) | - ((__u32) data << 24); + ((__u32) data << 24); /* * write this 32 bit dword to the bridge data port @@ -699,7 +699,7 @@ vpm_in(struct hfc_multi *c, int which, unsigned short addr) inline void vpm_out(struct hfc_multi *c, int which, unsigned short addr, - unsigned char data) + unsigned char data) { vpm_write_address(c, addr); @@ -717,11 +717,11 @@ vpm_out(struct hfc_multi *c, int which, unsigned short addr, disablepcibridge(c); { - unsigned char regin; - regin = vpm_in(c, which, addr); - if (regin != data) - printk(KERN_DEBUG "Wrote 0x%x to register 0x%x but got back " - "0x%x\n", data, addr, regin); + unsigned char regin; + regin = vpm_in(c, which, addr); + if (regin != data) + printk(KERN_DEBUG "Wrote 0x%x to register 0x%x but got back " + "0x%x\n", data, addr, regin); } } @@ -853,16 +853,16 @@ vpm_echocan_on(struct hfc_multi *hc, int ch, int taps) #ifdef TXADJ skb = _alloc_mISDN_skb(PH_CONTROL_IND, HFC_VOL_CHANGE_TX, - sizeof(int), &txadj, GFP_ATOMIC); + sizeof(int), &txadj, GFP_ATOMIC); if (skb) recv_Bchannel_skb(bch, skb); #endif - timeslot = ((ch/4)*8) + ((ch%4)*4) + 1; + timeslot = ((ch / 4) * 8) + ((ch % 4) * 4) + 1; unit = ch % 4; printk(KERN_NOTICE "vpm_echocan_on called taps [%d] on timeslot %d\n", - taps, timeslot); + taps, timeslot); vpm_out(hc, unit, timeslot, 0x7e); } @@ -886,16 +886,16 @@ vpm_echocan_off(struct hfc_multi *hc, int ch) #ifdef TXADJ skb = _alloc_mISDN_skb(PH_CONTROL_IND, HFC_VOL_CHANGE_TX, - sizeof(int), &txadj, GFP_ATOMIC); + sizeof(int), &txadj, GFP_ATOMIC); if (skb) recv_Bchannel_skb(bch, skb); #endif - timeslot = ((ch/4)*8) + ((ch%4)*4) + 1; + timeslot = ((ch / 4) * 8) + ((ch % 4) * 4) + 1; unit = ch % 4; printk(KERN_NOTICE "vpm_echocan_off called on timeslot %d\n", - timeslot); + timeslot); /* FILLME */ vpm_out(hc, unit, timeslot, 0x01); } @@ -920,7 +920,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm) if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "%s: RESYNC(syncmaster=0x%p)\n", - __func__, syncmaster); + __func__, syncmaster); /* select new master */ if (newmaster) { @@ -949,7 +949,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm) if (hc->ctype == HFC_TYPE_E1) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG - "Schedule SYNC_I\n"); + "Schedule SYNC_I\n"); hc->e1_resync |= 1; /* get SYNC_I */ } } @@ -960,7 +960,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm) hc = newmaster; if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "id=%d (0x%p) = syncronized with " - "interface.\n", hc->id, hc); + "interface.\n", hc->id, hc); /* Enable new sync master */ plx_acc_32 = hc->plx_membase + PLX_GPIOC; pv = readl(plx_acc_32); @@ -968,7 +968,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm) writel(pv, plx_acc_32); /* switch to jatt PLL, if not disabled by RX_SYNC */ if (hc->ctype == HFC_TYPE_E1 - && !test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) { + && !test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "Schedule jatt PLL\n"); hc->e1_resync |= 2; /* switch to jatt */ @@ -978,20 +978,20 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm) hc = pcmmaster; if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG - "id=%d (0x%p) = PCM master syncronized " - "with QUARTZ\n", hc->id, hc); + "id=%d (0x%p) = PCM master syncronized " + "with QUARTZ\n", hc->id, hc); if (hc->ctype == HFC_TYPE_E1) { /* Use the crystal clock for the PCM master card */ if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG - "Schedule QUARTZ for HFC-E1\n"); + "Schedule QUARTZ for HFC-E1\n"); hc->e1_resync |= 4; /* switch quartz */ } else { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG - "QUARTZ is automatically " - "enabled by HFC-%dS\n", hc->ctype); + "QUARTZ is automatically " + "enabled by HFC-%dS\n", hc->ctype); } plx_acc_32 = hc->plx_membase + PLX_GPIOC; pv = readl(plx_acc_32); @@ -1000,7 +1000,7 @@ hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm) } else if (!rm) printk(KERN_ERR "%s no pcm master, this MUST " - "not happen!\n", __func__); + "not happen!\n", __func__); } syncmaster = newmaster; @@ -1016,16 +1016,16 @@ plxsd_checksync(struct hfc_multi *hc, int rm) if (syncmaster == NULL) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "%s: GOT sync on card %d" - " (id=%d)\n", __func__, hc->id + 1, - hc->id); + " (id=%d)\n", __func__, hc->id + 1, + hc->id); hfcmulti_resync(hc, hc, rm); } } else { if (syncmaster == hc) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "%s: LOST sync on card %d" - " (id=%d)\n", __func__, hc->id + 1, - hc->id); + " (id=%d)\n", __func__, hc->id + 1, + hc->id); hfcmulti_resync(hc, NULL, rm); } } @@ -1057,7 +1057,7 @@ release_io_hfcmulti(struct hfc_multi *hc) if (test_bit(HFC_CHIP_PLXSD, &hc->chip) && hc->plx_membase) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "%s: release PLXSD card %d\n", - __func__, hc->id + 1); + __func__, hc->id + 1); spin_lock_irqsave(&plx_lock, plx_flags); plx_acc_32 = hc->plx_membase + PLX_GPIOC; writel(PLX_GPIOC_INIT, plx_acc_32); @@ -1073,7 +1073,7 @@ release_io_hfcmulti(struct hfc_multi *hc) writel(pv, plx_acc_32); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PCM off: PLX_GPIO=%x\n", - __func__, pv); + __func__, pv); spin_unlock_irqrestore(&plx_lock, plx_flags); } @@ -1131,22 +1131,22 @@ init_chip(struct hfc_multi *hc) } rev = HFC_inb(hc, R_CHIP_RV); printk(KERN_INFO - "HFC_multi: detected HFC with chip ID=0x%lx revision=%ld%s\n", - val, rev, (rev == 0 && (hc->ctype != HFC_TYPE_XHFC)) ? - " (old FIFO handling)" : ""); + "HFC_multi: detected HFC with chip ID=0x%lx revision=%ld%s\n", + val, rev, (rev == 0 && (hc->ctype != HFC_TYPE_XHFC)) ? + " (old FIFO handling)" : ""); if (hc->ctype != HFC_TYPE_XHFC && rev == 0) { test_and_set_bit(HFC_CHIP_REVISION0, &hc->chip); printk(KERN_WARNING - "HFC_multi: NOTE: Your chip is revision 0, " - "ask Cologne Chip for update. Newer chips " - "have a better FIFO handling. Old chips " - "still work but may have slightly lower " - "HDLC transmit performance.\n"); + "HFC_multi: NOTE: Your chip is revision 0, " + "ask Cologne Chip for update. Newer chips " + "have a better FIFO handling. Old chips " + "still work but may have slightly lower " + "HDLC transmit performance.\n"); } if (rev > 1) { printk(KERN_WARNING "HFC_multi: WARNING: This driver doesn't " - "consider chip revision = %ld. The chip / " - "bridge may not work.\n", rev); + "consider chip revision = %ld. The chip / " + "bridge may not work.\n", rev); } /* set s-ram size */ @@ -1157,7 +1157,7 @@ init_chip(struct hfc_multi *hc) if (test_bit(HFC_CHIP_EXRAM_128, &hc->chip)) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: changing to 128K extenal RAM\n", - __func__); + __func__); hc->hw.r_ctrl |= V_EXT_RAM; hc->hw.r_ram_sz = 1; hc->Flen = 0x20; @@ -1168,7 +1168,7 @@ init_chip(struct hfc_multi *hc) if (test_bit(HFC_CHIP_EXRAM_512, &hc->chip)) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: changing to 512K extenal RAM\n", - __func__); + __func__); hc->hw.r_ctrl |= V_EXT_RAM; hc->hw.r_ram_sz = 2; hc->Flen = 0x20; @@ -1190,7 +1190,7 @@ init_chip(struct hfc_multi *hc) if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "%s: initializing PLXSD card %d\n", - __func__, hc->id + 1); + __func__, hc->id + 1); spin_lock_irqsave(&plx_lock, plx_flags); plx_acc_32 = hc->plx_membase + PLX_GPIOC; writel(PLX_GPIOC_INIT, plx_acc_32); @@ -1207,7 +1207,7 @@ init_chip(struct hfc_multi *hc) spin_unlock_irqrestore(&plx_lock, plx_flags); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: slave/term: PLX_GPIO=%x\n", - __func__, pv); + __func__, pv); /* * If we are the 3rd PLXSD card or higher, we must turn * termination of last PLXSD card off. @@ -1225,8 +1225,8 @@ init_chip(struct hfc_multi *hc) if (plx_count >= 3) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG "%s: card %d is between, so " - "we disable termination\n", - __func__, plx_last_hc->id + 1); + "we disable termination\n", + __func__, plx_last_hc->id + 1); spin_lock_irqsave(&plx_lock, plx_flags); plx_acc_32 = plx_last_hc->plx_membase + PLX_GPIOC; pv = readl(plx_acc_32); @@ -1235,8 +1235,8 @@ init_chip(struct hfc_multi *hc) spin_unlock_irqrestore(&plx_lock, plx_flags); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: term off: PLX_GPIO=%x\n", - __func__, pv); + "%s: term off: PLX_GPIO=%x\n", + __func__, pv); } spin_unlock_irqrestore(&HFClock, hfc_flags); hc->hw.r_pcm_md0 = V_F0_LEN; /* shift clock for DSP */ @@ -1253,24 +1253,24 @@ init_chip(struct hfc_multi *hc) if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: setting PCM into slave mode\n", - __func__); + __func__); } else - if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip) && !plxsd_master) { - if (debug & DEBUG_HFCMULTI_INIT) - printk(KERN_DEBUG "%s: setting PCM into master mode\n", - __func__); - hc->hw.r_pcm_md0 |= V_PCM_MD; - } else { - if (debug & DEBUG_HFCMULTI_INIT) - printk(KERN_DEBUG "%s: performing PCM auto detect\n", - __func__); - } + if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip) && !plxsd_master) { + if (debug & DEBUG_HFCMULTI_INIT) + printk(KERN_DEBUG "%s: setting PCM into master mode\n", + __func__); + hc->hw.r_pcm_md0 |= V_PCM_MD; + } else { + if (debug & DEBUG_HFCMULTI_INIT) + printk(KERN_DEBUG "%s: performing PCM auto detect\n", + __func__); + } /* soft reset */ HFC_outb(hc, R_CTRL, hc->hw.r_ctrl); if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, 0x0C /* R_FIFO_THRES */, - 0x11 /* 16 Bytes TX/RX */); + 0x11 /* 16 Bytes TX/RX */); else HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz); HFC_outb(hc, R_FIFO_MD, 0); @@ -1298,13 +1298,13 @@ init_chip(struct hfc_multi *hc) pv |= PLX_SYNC_O_EN; if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: master: PLX_GPIO=%x\n", - __func__, pv); + __func__, pv); } else { pv &= ~(PLX_MASTER_EN | PLX_SLAVE_EN_N); pv &= ~PLX_SYNC_O_EN; if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: slave: PLX_GPIO=%x\n", - __func__, pv); + __func__, pv); } writel(pv, plx_acc_32); spin_unlock_irqrestore(&plx_lock, plx_flags); @@ -1338,7 +1338,7 @@ init_chip(struct hfc_multi *hc) if (test_bit(HFC_CHIP_CLOCK2, &hc->chip)) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: setting double clock\n", __func__); + "%s: setting double clock\n", __func__); HFC_outb(hc, R_BRG_PCM_CFG, V_PCM_CLK); } @@ -1360,48 +1360,48 @@ init_chip(struct hfc_multi *hc) val += HFC_inb(hc, R_F0_CNTH) << 8; if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "HFC_multi F0_CNT %ld after reset\n", val); + "HFC_multi F0_CNT %ld after reset\n", val); spin_unlock_irqrestore(&hc->lock, flags); set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((HZ/100)?:1); /* Timeout minimum 10ms */ + schedule_timeout((HZ / 100) ? : 1); /* Timeout minimum 10ms */ spin_lock_irqsave(&hc->lock, flags); val2 = HFC_inb(hc, R_F0_CNTL); val2 += HFC_inb(hc, R_F0_CNTH) << 8; if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "HFC_multi F0_CNT %ld after 10 ms (1st try)\n", - val2); - if (val2 >= val+8) { /* 1 ms */ + "HFC_multi F0_CNT %ld after 10 ms (1st try)\n", + val2); + if (val2 >= val + 8) { /* 1 ms */ /* it counts, so we keep the pcm mode */ if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) printk(KERN_INFO "controller is PCM bus MASTER\n"); else - if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) - printk(KERN_INFO "controller is PCM bus SLAVE\n"); - else { - test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); - printk(KERN_INFO "controller is PCM bus SLAVE " - "(auto detected)\n"); - } + if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) + printk(KERN_INFO "controller is PCM bus SLAVE\n"); + else { + test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip); + printk(KERN_INFO "controller is PCM bus SLAVE " + "(auto detected)\n"); + } } else { /* does not count */ if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) { -controller_fail: + controller_fail: printk(KERN_ERR "HFC_multi ERROR, getting no 125us " - "pulse. Seems that controller fails.\n"); + "pulse. Seems that controller fails.\n"); err = -EIO; goto out; } if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) { printk(KERN_INFO "controller is PCM bus SLAVE " - "(ignoring missing PCM clock)\n"); + "(ignoring missing PCM clock)\n"); } else { /* only one pcm master */ if (test_bit(HFC_CHIP_PLXSD, &hc->chip) - && plxsd_master) { + && plxsd_master) { printk(KERN_ERR "HFC_multi ERROR, no clock " - "on another Speech Design card found. " - "Please be sure to connect PCM cable.\n"); + "on another Speech Design card found. " + "Please be sure to connect PCM cable.\n"); err = -EIO; goto out; } @@ -1416,24 +1416,24 @@ init_chip(struct hfc_multi *hc) spin_unlock_irqrestore(&plx_lock, plx_flags); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: master: " - "PLX_GPIO=%x\n", __func__, pv); + "PLX_GPIO=%x\n", __func__, pv); } hc->hw.r_pcm_md0 |= V_PCM_MD; HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00); spin_unlock_irqrestore(&hc->lock, flags); set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((HZ/100)?:1); /* Timeout min. 10ms */ + schedule_timeout((HZ / 100) ?: 1); /* Timeout min. 10ms */ spin_lock_irqsave(&hc->lock, flags); val2 = HFC_inb(hc, R_F0_CNTL); val2 += HFC_inb(hc, R_F0_CNTH) << 8; if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "HFC_multi F0_CNT %ld after " - "10 ms (2nd try)\n", val2); - if (val2 >= val+8) { /* 1 ms */ + "10 ms (2nd try)\n", val2); + if (val2 >= val + 8) { /* 1 ms */ test_and_set_bit(HFC_CHIP_PCM_MASTER, - &hc->chip); + &hc->chip); printk(KERN_INFO "controller is PCM bus MASTER " - "(auto detected)\n"); + "(auto detected)\n"); } else goto controller_fail; } @@ -1451,21 +1451,21 @@ init_chip(struct hfc_multi *hc) spin_unlock_irqrestore(&plx_lock, plx_flags); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: reset off: PLX_GPIO=%x\n", - __func__, pv); + __func__, pv); } /* pcm id */ if (hc->pcm) printk(KERN_INFO "controller has given PCM BUS ID %d\n", - hc->pcm); + hc->pcm); else { if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip) - || test_bit(HFC_CHIP_PLXSD, &hc->chip)) { + || test_bit(HFC_CHIP_PLXSD, &hc->chip)) { PCM_cnt++; /* SD has proprietary bridging */ } hc->pcm = PCM_cnt; printk(KERN_INFO "controller has PCM BUS ID %d " - "(auto selected)\n", hc->pcm); + "(auto selected)\n", hc->pcm); } /* set up timer */ @@ -1480,7 +1480,7 @@ init_chip(struct hfc_multi *hc) if (test_bit(HFC_CHIP_DTMF, &hc->chip)) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: enabling DTMF detection " - "for all B-channel\n", __func__); + "for all B-channel\n", __func__); hc->hw.r_dtmf = V_DTMF_EN | V_DTMF_STOP; if (test_bit(HFC_CHIP_ULAW, &hc->chip)) hc->hw.r_dtmf |= V_ULAW_SEL; @@ -1527,8 +1527,8 @@ init_chip(struct hfc_multi *hc) if (hc->masterclk >= 0) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: setting ST master clock " - "to port %d (0..%d)\n", - __func__, hc->masterclk, hc->ports-1); + "to port %d (0..%d)\n", + __func__, hc->masterclk, hc->ports - 1); hc->hw.r_st_sync |= (hc->masterclk | V_AUTO_SYNC); HFC_outb(hc, R_ST_SYNC, hc->hw.r_st_sync); } @@ -1539,7 +1539,7 @@ init_chip(struct hfc_multi *hc) HFC_outb(hc, R_IRQMSK_MISC, hc->hw.r_irqmsk_misc); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "r_irqmsk_misc.2: 0x%x\n", - hc->hw.r_irqmsk_misc); + hc->hw.r_irqmsk_misc); /* RAM access test */ HFC_outb(hc, R_RAM_ADDR0, 0); @@ -1547,7 +1547,7 @@ init_chip(struct hfc_multi *hc) HFC_outb(hc, R_RAM_ADDR2, 0); for (i = 0; i < 256; i++) { HFC_outb_nodebug(hc, R_RAM_ADDR0, i); - HFC_outb_nodebug(hc, R_RAM_DATA, ((i*3)&0xff)); + HFC_outb_nodebug(hc, R_RAM_DATA, ((i * 3) & 0xff)); } for (i = 0; i < 256; i++) { HFC_outb_nodebug(hc, R_RAM_ADDR0, i); @@ -1555,8 +1555,8 @@ init_chip(struct hfc_multi *hc) rval = HFC_inb_nodebug(hc, R_INT_DATA); if (rval != ((i * 3) & 0xff)) { printk(KERN_DEBUG - "addr:%x val:%x should:%x\n", i, rval, - (i * 3) & 0xff); + "addr:%x val:%x should:%x\n", i, rval, + (i * 3) & 0xff); err++; } } @@ -1585,9 +1585,9 @@ hfcmulti_watchdog(struct hfc_multi *hc) if (hc->wdcount > 10) { hc->wdcount = 0; hc->wdbyte = hc->wdbyte == V_GPIO_OUT2 ? - V_GPIO_OUT3 : V_GPIO_OUT2; + V_GPIO_OUT3 : V_GPIO_OUT2; - /* printk("Sending Watchdog Kill %x\n",hc->wdbyte); */ + /* printk("Sending Watchdog Kill %x\n",hc->wdbyte); */ HFC_outb(hc, R_GPIO_EN0, V_GPIO_EN2 | V_GPIO_EN3); HFC_outb(hc, R_GPIO_OUT0, hc->wdbyte); } @@ -1623,10 +1623,10 @@ hfcmulti_leds(struct hfc_multi *hc) */ if (hc->chan[hc->dslot].sync != 2) { /* no frame sync */ if (hc->chan[hc->dslot].dch->dev.D.protocol - != ISDN_P_NT_E1) { + != ISDN_P_NT_E1) { led[0] = 1; led[1] = 1; - } else if (hc->ledcount>>11) { + } else if (hc->ledcount >> 11) { led[0] = 1; led[1] = 1; } else { @@ -1643,7 +1643,7 @@ hfcmulti_leds(struct hfc_multi *hc) led[3] = 1; } leds = (led[0] | (led[1]<<2) | (led[2]<<1) | (led[3]<<3))^0xF; - /* leds are inverted */ + /* leds are inverted */ if (leds != (int)hc->ledstate) { HFC_outb_nodebug(hc, R_GPIO_OUT1, leds); hc->ledstate = leds; @@ -1674,7 +1674,7 @@ hfcmulti_leds(struct hfc_multi *hc) /* TE mode: led red */ led[i] = 2; else - if (hc->ledcount>>11) + if (hc->ledcount >> 11) /* led red */ led[i] = 2; else @@ -1700,9 +1700,9 @@ hfcmulti_leds(struct hfc_multi *hc) } } else { leds = ((led[3] > 0) << 0) | ((led[1] > 0) << 1) | - ((led[0] > 0) << 2) | ((led[2] > 0) << 3) | - ((led[3] & 1) << 4) | ((led[1] & 1) << 5) | - ((led[0] & 1) << 6) | ((led[2] & 1) << 7); + ((led[0] > 0) << 2) | ((led[2] > 0) << 3) | + ((led[3] & 1) << 4) | ((led[1] & 1) << 5) | + ((led[0] & 1) << 6) | ((led[2] & 1) << 7); if (leds != (int)hc->ledstate) { HFC_outb_nodebug(hc, R_GPIO_EN1, leds & 0x0F); HFC_outb_nodebug(hc, R_GPIO_OUT1, leds >> 4); @@ -1746,13 +1746,13 @@ hfcmulti_leds(struct hfc_multi *hc) } - leds = (led[0] > 0) | ((led[1] > 0)<<1) | ((led[0]&1)<<2) - | ((led[1]&1)<<3); + leds = (led[0] > 0) | ((led[1] > 0) << 1) | ((led[0]&1) << 2) + | ((led[1]&1) << 3); if (leds != (int)hc->ledstate) { HFC_outb_nodebug(hc, R_GPIO_EN1, - ((led[0] > 0) << 2) | ((led[1] > 0) << 3)); + ((led[0] > 0) << 2) | ((led[1] > 0) << 3)); HFC_outb_nodebug(hc, R_GPIO_OUT1, - ((led[0] & 1) << 2) | ((led[1] & 1) << 3)); + ((led[0] & 1) << 2) | ((led[1] & 1) << 3)); hc->ledstate = leds; } break; @@ -1784,7 +1784,7 @@ hfcmulti_leds(struct hfc_multi *hc) leddw = lled << 24 | lled << 16 | lled << 8 | lled; if (leddw != hc->ledstate) { /* HFC_outb(hc, R_BRG_PCM_CFG, 1); - HFC_outb(c, R_BRG_PCM_CFG, (0x0 << 6) | 0x3); */ + HFC_outb(c, R_BRG_PCM_CFG, (0x0 << 6) | 0x3); */ /* was _io before */ HFC_outb_nodebug(hc, R_BRG_PCM_CFG, 1 | V_PCM_CLK); outw(0x4000, hc->pci_iobase + 4); @@ -1826,16 +1826,16 @@ hfcmulti_dtmf(struct hfc_multi *hc) continue; if (debug & DEBUG_HFCMULTI_DTMF) printk(KERN_DEBUG "%s: dtmf channel %d:", - __func__, ch); + __func__, ch); coeff = &(hc->chan[ch].coeff[hc->chan[ch].coeff_count * 16]); dtmf = 1; for (co = 0; co < 8; co++) { /* read W(n-1) coefficient */ - addr = hc->DTMFbase + ((co<<7) | (ch<<2)); + addr = hc->DTMFbase + ((co << 7) | (ch << 2)); HFC_outb_nodebug(hc, R_RAM_ADDR0, addr); - HFC_outb_nodebug(hc, R_RAM_ADDR1, addr>>8); - HFC_outb_nodebug(hc, R_RAM_ADDR2, (addr>>16) - | V_ADDR_INC); + HFC_outb_nodebug(hc, R_RAM_ADDR1, addr >> 8); + HFC_outb_nodebug(hc, R_RAM_ADDR2, (addr >> 16) + | V_ADDR_INC); w_float = HFC_inb_nodebug(hc, R_RAM_DATA); w_float |= (HFC_inb_nodebug(hc, R_RAM_DATA) << 8); if (debug & DEBUG_HFCMULTI_DTMF) @@ -1845,14 +1845,14 @@ hfcmulti_dtmf(struct hfc_multi *hc) mantissa = w_float & 0x0fff; if (w_float & 0x8000) mantissa |= 0xfffff000; - exponent = (w_float>>12) & 0x7; + exponent = (w_float >> 12) & 0x7; if (exponent) { mantissa ^= 0x1000; - mantissa <<= (exponent-1); + mantissa <<= (exponent - 1); } /* store coefficient */ - coeff[co<<1] = mantissa; + coeff[co << 1] = mantissa; /* read W(n) coefficient */ w_float = HFC_inb_nodebug(hc, R_RAM_DATA); @@ -1864,27 +1864,27 @@ hfcmulti_dtmf(struct hfc_multi *hc) mantissa = w_float & 0x0fff; if (w_float & 0x8000) mantissa |= 0xfffff000; - exponent = (w_float>>12) & 0x7; + exponent = (w_float >> 12) & 0x7; if (exponent) { mantissa ^= 0x1000; - mantissa <<= (exponent-1); + mantissa <<= (exponent - 1); } /* store coefficient */ - coeff[(co<<1)|1] = mantissa; + coeff[(co << 1) | 1] = mantissa; } if (debug & DEBUG_HFCMULTI_DTMF) printk(" DTMF ready %08x %08x %08x %08x " - "%08x %08x %08x %08x\n", - coeff[0], coeff[1], coeff[2], coeff[3], - coeff[4], coeff[5], coeff[6], coeff[7]); + "%08x %08x %08x %08x\n", + coeff[0], coeff[1], coeff[2], coeff[3], + coeff[4], coeff[5], coeff[6], coeff[7]); hc->chan[ch].coeff_count++; if (hc->chan[ch].coeff_count == 8) { hc->chan[ch].coeff_count = 0; skb = mI_alloc_skb(512, GFP_ATOMIC); if (!skb) { printk(KERN_DEBUG "%s: No memory for skb\n", - __func__); + __func__); continue; } hh = mISDN_HEAD_P(skb); @@ -1966,8 +1966,8 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) while (f2 != (temp = HFC_inb_nodebug(hc, A_F2))) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG - "%s(card %d): reread f2 because %d!=%d\n", - __func__, hc->id + 1, temp, f2); + "%s(card %d): reread f2 because %d!=%d\n", + __func__, hc->id + 1, temp, f2); f2 = temp; /* repeat until F2 is equal */ } Fspace = f2 - f1 - 1; @@ -1999,7 +1999,7 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) while (z2 != (temp = (HFC_inw_nodebug(hc, A_Z2) - hc->Zmin))) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG "%s(card %d): reread z2 because " - "%d!=%d\n", __func__, hc->id + 1, temp, z2); + "%d!=%d\n", __func__, hc->id + 1, temp, z2); z2 = temp; /* repeat unti Z2 is equal */ } hc->chan[ch].Zfill = z1 - z2; @@ -2023,28 +2023,28 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) *txpending && slot_tx >= 0) { if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG - "%s: reconnecting PCM due to no " - "more FIFO data: channel %d " - "slot_tx %d\n", - __func__, ch, slot_tx); + "%s: reconnecting PCM due to no " + "more FIFO data: channel %d " + "slot_tx %d\n", + __func__, ch, slot_tx); /* connect slot */ if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, A_CON_HDLC, 0xc0 - | 0x07 << 2 | V_HDLC_TRP | V_IFF); - /* Enable FIFO, no interrupt */ + | 0x07 << 2 | V_HDLC_TRP | V_IFF); + /* Enable FIFO, no interrupt */ else HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 | - V_HDLC_TRP | V_IFF); - HFC_outb_nodebug(hc, R_FIFO, ch<<1 | 1); + V_HDLC_TRP | V_IFF); + HFC_outb_nodebug(hc, R_FIFO, ch << 1 | 1); HFC_wait_nodebug(hc); if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, A_CON_HDLC, 0xc0 - | 0x07 << 2 | V_HDLC_TRP | V_IFF); - /* Enable FIFO, no interrupt */ + | 0x07 << 2 | V_HDLC_TRP | V_IFF); + /* Enable FIFO, no interrupt */ else HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 | - V_HDLC_TRP | V_IFF); - HFC_outb_nodebug(hc, R_FIFO, ch<<1); + V_HDLC_TRP | V_IFF); + HFC_outb_nodebug(hc, R_FIFO, ch << 1); HFC_wait_nodebug(hc); } *txpending = 0; @@ -2054,10 +2054,10 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) /* "fill fifo if empty" feature */ if (bch && test_bit(FLG_FILLEMPTY, &bch->Flags) - && !test_bit(FLG_HDLC, &bch->Flags) && z2 == z1) { + && !test_bit(FLG_HDLC, &bch->Flags) && z2 == z1) { if (debug & DEBUG_HFCMULTI_FILL) printk(KERN_DEBUG "%s: buffer empty, so we have " - "underrun\n", __func__); + "underrun\n", __func__); /* fill buffer, to prevent future underrun */ hc->write_fifo(hc, hc->silence_data, poll >> 1); Zspace -= (poll >> 1); @@ -2065,29 +2065,29 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) /* if audio data and connected slot */ if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) && (!*txpending) - && slot_tx >= 0) { + && slot_tx >= 0) { if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG "%s: disconnecting PCM due to " - "FIFO data: channel %d slot_tx %d\n", - __func__, ch, slot_tx); + "FIFO data: channel %d slot_tx %d\n", + __func__, ch, slot_tx); /* disconnect slot */ if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, A_CON_HDLC, 0x80 - | 0x07 << 2 | V_HDLC_TRP | V_IFF); - /* Enable FIFO, no interrupt */ + | 0x07 << 2 | V_HDLC_TRP | V_IFF); + /* Enable FIFO, no interrupt */ else HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 | - V_HDLC_TRP | V_IFF); - HFC_outb_nodebug(hc, R_FIFO, ch<<1 | 1); + V_HDLC_TRP | V_IFF); + HFC_outb_nodebug(hc, R_FIFO, ch << 1 | 1); HFC_wait_nodebug(hc); if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, A_CON_HDLC, 0x80 - | 0x07 << 2 | V_HDLC_TRP | V_IFF); - /* Enable FIFO, no interrupt */ + | 0x07 << 2 | V_HDLC_TRP | V_IFF); + /* Enable FIFO, no interrupt */ else HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 | - V_HDLC_TRP | V_IFF); - HFC_outb_nodebug(hc, R_FIFO, ch<<1); + V_HDLC_TRP | V_IFF); + HFC_outb_nodebug(hc, R_FIFO, ch << 1); HFC_wait_nodebug(hc); } *txpending = 1; @@ -2107,9 +2107,9 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) ii = Zspace + i; if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG "%s(card %d): fifo(%d) has %d bytes space " - "left (z1=%04x, z2=%04x) sending %d of %d bytes %s\n", - __func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i, - temp ? "HDLC" : "TRANS"); + "left (z1=%04x, z2=%04x) sending %d of %d bytes %s\n", + __func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i, + temp ? "HDLC" : "TRANS"); /* Have to prep the audio data */ hc->write_fifo(hc, d, ii - i); @@ -2189,9 +2189,9 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) (hc->chan[ch].protocol == ISDN_P_B_RAW) && (hc->chan[ch].slot_rx < 0) && (hc->chan[ch].slot_tx < 0)) - HFC_outb_nodebug(hc, R_FIFO, 0x20 | (ch<<1) | 1); + HFC_outb_nodebug(hc, R_FIFO, 0x20 | (ch << 1) | 1); else - HFC_outb_nodebug(hc, R_FIFO, (ch<<1)|1); + HFC_outb_nodebug(hc, R_FIFO, (ch << 1) | 1); HFC_wait_nodebug(hc); /* ignore if rx is off BUT change fifo (above) to start pending TX */ @@ -2203,8 +2203,8 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) while (f1 != (temp = HFC_inb_nodebug(hc, A_F1))) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG - "%s(card %d): reread f1 because %d!=%d\n", - __func__, hc->id + 1, temp, f1); + "%s(card %d): reread f1 because %d!=%d\n", + __func__, hc->id + 1, temp, f1); f1 = temp; /* repeat until F1 is equal */ } f2 = HFC_inb_nodebug(hc, A_F2); @@ -2213,7 +2213,7 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) while (z1 != (temp = (HFC_inw_nodebug(hc, A_Z1) - hc->Zmin))) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG "%s(card %d): reread z2 because " - "%d!=%d\n", __func__, hc->id + 1, temp, z2); + "%d!=%d\n", __func__, hc->id + 1, temp, z2); z1 = temp; /* repeat until Z1 is equal */ } z2 = HFC_inw_nodebug(hc, A_Z2) - hc->Zmin; @@ -2231,7 +2231,7 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) *sp = mI_alloc_skb(maxlen + 3, GFP_ATOMIC); if (*sp == NULL) { printk(KERN_DEBUG "%s: No mem for rx_skb\n", - __func__); + __func__); return; } } @@ -2242,16 +2242,16 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) if (dch || test_bit(FLG_HDLC, &bch->Flags)) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG "%s(card %d): fifo(%d) reading %d " - "bytes (z1=%04x, z2=%04x) HDLC %s (f1=%d, f2=%d) " - "got=%d (again %d)\n", __func__, hc->id + 1, ch, - Zsize, z1, z2, (f1 == f2) ? "fragment" : "COMPLETE", - f1, f2, Zsize + (*sp)->len, again); + "bytes (z1=%04x, z2=%04x) HDLC %s (f1=%d, f2=%d) " + "got=%d (again %d)\n", __func__, hc->id + 1, ch, + Zsize, z1, z2, (f1 == f2) ? "fragment" : "COMPLETE", + f1, f2, Zsize + (*sp)->len, again); /* HDLC */ if ((Zsize + (*sp)->len) > (maxlen + 3)) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG - "%s(card %d): hdlc-frame too large.\n", - __func__, hc->id + 1); + "%s(card %d): hdlc-frame too large.\n", + __func__, hc->id + 1); skb_trim(*sp, 0); HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_RES_F); HFC_wait_nodebug(hc); @@ -2268,8 +2268,8 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) if ((*sp)->len < 4) { if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG - "%s(card %d): Frame below minimum " - "size\n", __func__, hc->id + 1); + "%s(card %d): Frame below minimum " + "size\n", __func__, hc->id + 1); skb_trim(*sp, 0); goto next_frame; } @@ -2277,7 +2277,7 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) if ((*sp)->data[(*sp)->len - 1]) { if (debug & DEBUG_HFCMULTI_CRC) printk(KERN_DEBUG - "%s: CRC-error\n", __func__); + "%s: CRC-error\n", __func__); skb_trim(*sp, 0); goto next_frame; } @@ -2287,11 +2287,11 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) *sp = mI_alloc_skb(skb->len, GFP_ATOMIC); if (*sp) { memcpy(skb_put(*sp, skb->len), - skb->data, skb->len); + skb->data, skb->len); skb_trim(skb, 0); } else { printk(KERN_DEBUG "%s: No mem\n", - __func__); + __func__); *sp = skb; skb = NULL; } @@ -2300,7 +2300,7 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) } if (debug & DEBUG_HFCMULTI_FIFO) { printk(KERN_DEBUG "%s(card %d):", - __func__, hc->id + 1); + __func__, hc->id + 1); temp = 0; while (temp < (*sp)->len) printk(" %02x", (*sp)->data[temp++]); @@ -2325,7 +2325,7 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) *sp = mI_alloc_skb(skb->len, GFP_ATOMIC); if (*sp) { memcpy(skb_put(*sp, skb->len), - skb->data, skb->len); + skb->data, skb->len); skb_trim(skb, 0); } else { printk(KERN_DEBUG "%s: No mem\n", __func__); @@ -2337,9 +2337,9 @@ hfcmulti_rx(struct hfc_multi *hc, int ch) } if (debug & DEBUG_HFCMULTI_FIFO) printk(KERN_DEBUG - "%s(card %d): fifo(%d) reading %d bytes " - "(z1=%04x, z2=%04x) TRANS\n", - __func__, hc->id + 1, ch, Zsize, z1, z2); + "%s(card %d): fifo(%d) reading %d bytes " + "(z1=%04x, z2=%04x) TRANS\n", + __func__, hc->id + 1, ch, Zsize, z1, z2); /* only bch is transparent */ recv_Bchannel(bch, hc->chan[ch].Zfill); *sp = skb; @@ -2362,7 +2362,7 @@ signal_state_up(struct dchannel *dch, int info, char *msg) id = TEI_SAPI | (GROUP_TEI << 8); /* manager address */ skb = _alloc_mISDN_skb(MPH_INFORMATION_IND, id, sizeof(data), &data, - GFP_ATOMIC); + GFP_ATOMIC); if (!skb) return; recv_Dchannel_skb(dch, skb); @@ -2395,10 +2395,10 @@ handle_timer_irq(struct hfc_multi *hc) if (hc->e1_resync & 4) { if (debug & DEBUG_HFCMULTI_PLXSD) printk(KERN_DEBUG - "Enable QUARTZ for HFC-E1\n"); + "Enable QUARTZ for HFC-E1\n"); /* set jatt to quartz */ HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC - | V_JATT_OFF); + | V_JATT_OFF); /* switch to JATT, in case it is not already */ HFC_outb(hc, R_SYNC_OUT, 0); } @@ -2417,14 +2417,14 @@ handle_timer_irq(struct hfc_multi *hc) dch = hc->chan[ch].dch; if (!(--hc->chan[ch].nt_timer)) { schedule_event(dch, - FLG_PHCHANGE); + FLG_PHCHANGE); if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: nt_timer at " - "state %x\n", - __func__, - dch->state); + "%s: nt_timer at " + "state %x\n", + __func__, + dch->state); } } } @@ -2436,10 +2436,10 @@ handle_timer_irq(struct hfc_multi *hc) temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_SIG_LOS; if (!temp && hc->chan[hc->dslot].los) signal_state_up(dch, L1_SIGNAL_LOS_ON, - "LOS detected"); + "LOS detected"); if (temp && !hc->chan[hc->dslot].los) signal_state_up(dch, L1_SIGNAL_LOS_OFF, - "LOS gone"); + "LOS gone"); hc->chan[hc->dslot].los = temp; } if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dslot].cfg)) { @@ -2447,10 +2447,10 @@ handle_timer_irq(struct hfc_multi *hc) temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_AIS; if (!temp && hc->chan[hc->dslot].ais) signal_state_up(dch, L1_SIGNAL_AIS_ON, - "AIS detected"); + "AIS detected"); if (temp && !hc->chan[hc->dslot].ais) signal_state_up(dch, L1_SIGNAL_AIS_OFF, - "AIS gone"); + "AIS gone"); hc->chan[hc->dslot].ais = temp; } if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dslot].cfg)) { @@ -2458,12 +2458,12 @@ handle_timer_irq(struct hfc_multi *hc) temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_RX; if (!temp && hc->chan[hc->dslot].slip_rx) signal_state_up(dch, L1_SIGNAL_SLIP_RX, - " bit SLIP detected RX"); + " bit SLIP detected RX"); hc->chan[hc->dslot].slip_rx = temp; temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_TX; if (!temp && hc->chan[hc->dslot].slip_tx) signal_state_up(dch, L1_SIGNAL_SLIP_TX, - " bit SLIP detected TX"); + " bit SLIP detected TX"); hc->chan[hc->dslot].slip_tx = temp; } if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dslot].cfg)) { @@ -2471,10 +2471,10 @@ handle_timer_irq(struct hfc_multi *hc) temp = HFC_inb_nodebug(hc, R_RX_SL0_0) & V_A; if (!temp && hc->chan[hc->dslot].rdi) signal_state_up(dch, L1_SIGNAL_RDI_ON, - "RDI detected"); + "RDI detected"); if (temp && !hc->chan[hc->dslot].rdi) signal_state_up(dch, L1_SIGNAL_RDI_OFF, - "RDI gone"); + "RDI gone"); hc->chan[hc->dslot].rdi = temp; } temp = HFC_inb_nodebug(hc, R_JATT_DIR); @@ -2483,13 +2483,13 @@ handle_timer_irq(struct hfc_multi *hc) if ((temp & 0x60) == 0x60) { if (debug & DEBUG_HFCMULTI_SYNC) printk(KERN_DEBUG - "%s: (id=%d) E1 now " - "in clock sync\n", - __func__, hc->id); + "%s: (id=%d) E1 now " + "in clock sync\n", + __func__, hc->id); HFC_outb(hc, R_RX_OFF, - hc->chan[hc->dslot].jitter | V_RX_INIT); + hc->chan[hc->dslot].jitter | V_RX_INIT); HFC_outb(hc, R_TX_OFF, - hc->chan[hc->dslot].jitter | V_RX_INIT); + hc->chan[hc->dslot].jitter | V_RX_INIT); hc->chan[hc->dslot].sync = 1; goto check_framesync; } @@ -2498,20 +2498,20 @@ handle_timer_irq(struct hfc_multi *hc) if ((temp & 0x60) != 0x60) { if (debug & DEBUG_HFCMULTI_SYNC) printk(KERN_DEBUG - "%s: (id=%d) E1 " - "lost clock sync\n", - __func__, hc->id); + "%s: (id=%d) E1 " + "lost clock sync\n", + __func__, hc->id); hc->chan[hc->dslot].sync = 0; break; } -check_framesync: + check_framesync: temp = HFC_inb_nodebug(hc, R_SYNC_STA); if (temp == 0x27) { if (debug & DEBUG_HFCMULTI_SYNC) printk(KERN_DEBUG - "%s: (id=%d) E1 " - "now in frame sync\n", - __func__, hc->id); + "%s: (id=%d) E1 " + "now in frame sync\n", + __func__, hc->id); hc->chan[hc->dslot].sync = 2; } break; @@ -2519,9 +2519,9 @@ handle_timer_irq(struct hfc_multi *hc) if ((temp & 0x60) != 0x60) { if (debug & DEBUG_HFCMULTI_SYNC) printk(KERN_DEBUG - "%s: (id=%d) E1 lost " - "clock & frame sync\n", - __func__, hc->id); + "%s: (id=%d) E1 lost " + "clock & frame sync\n", + __func__, hc->id); hc->chan[hc->dslot].sync = 0; break; } @@ -2529,9 +2529,9 @@ handle_timer_irq(struct hfc_multi *hc) if (temp != 0x27) { if (debug & DEBUG_HFCMULTI_SYNC) printk(KERN_DEBUG - "%s: (id=%d) E1 " - "lost frame sync\n", - __func__, hc->id); + "%s: (id=%d) E1 " + "lost frame sync\n", + __func__, hc->id); hc->chan[hc->dslot].sync = 1; } break; @@ -2559,30 +2559,30 @@ ph_state_irq(struct hfc_multi *hc, u_char r_irq_statech) dch = hc->chan[ch].dch; if (r_irq_statech & 1) { HFC_outb_nodebug(hc, R_ST_SEL, - hc->chan[ch].port); + hc->chan[ch].port); /* undocumented: delay after R_ST_SEL */ udelay(1); /* undocumented: status changes during read */ st_status = HFC_inb_nodebug(hc, A_ST_RD_STATE); while (st_status != (temp = - HFC_inb_nodebug(hc, A_ST_RD_STATE))) { + HFC_inb_nodebug(hc, A_ST_RD_STATE))) { if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG "%s: reread " - "STATE because %d!=%d\n", - __func__, temp, - st_status); + "STATE because %d!=%d\n", + __func__, temp, + st_status); st_status = temp; /* repeat */ } /* Speech Design TE-sync indication */ if (test_bit(HFC_CHIP_PLXSD, &hc->chip) && - dch->dev.D.protocol == ISDN_P_TE_S0) { + dch->dev.D.protocol == ISDN_P_TE_S0) { if (st_status & V_FR_SYNC_ST) hc->syncronized |= - (1 << hc->chan[ch].port); + (1 << hc->chan[ch].port); else hc->syncronized &= - ~(1 << hc->chan[ch].port); + ~(1 << hc->chan[ch].port); } dch->state = st_status & 0x0f; if (dch->dev.D.protocol == ISDN_P_NT_S0) @@ -2591,19 +2591,19 @@ ph_state_irq(struct hfc_multi *hc, u_char r_irq_statech) active = 7; if (dch->state == active) { HFC_outb_nodebug(hc, R_FIFO, - (ch << 1) | 1); + (ch << 1) | 1); HFC_wait_nodebug(hc); HFC_outb_nodebug(hc, - R_INC_RES_FIFO, V_RES_F); + R_INC_RES_FIFO, V_RES_F); HFC_wait_nodebug(hc); dch->tx_idx = 0; } schedule_event(dch, FLG_PHCHANGE); if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: S/T newstate %x port %d\n", - __func__, dch->state, - hc->chan[ch].port); + "%s: S/T newstate %x port %d\n", + __func__, dch->state, + hc->chan[ch].port); } r_irq_statech >>= 1; } @@ -2665,7 +2665,7 @@ hfcmulti_interrupt(int intno, void *dev_id) { #ifdef IRQCOUNT_DEBUG static int iq1 = 0, iq2 = 0, iq3 = 0, iq4 = 0, - iq5 = 0, iq6 = 0, iqcnt = 0; + iq5 = 0, iq6 = 0, iqcnt = 0; #endif struct hfc_multi *hc = dev_id; struct dchannel *dch; @@ -2686,7 +2686,7 @@ hfcmulti_interrupt(int intno, void *dev_id) #ifdef IRQ_DEBUG if (irqsem) printk(KERN_ERR "irq for card %d during irq from " - "card %d, this is no bug.\n", hc->id + 1, irqsem); + "card %d, this is no bug.\n", hc->id + 1, irqsem); irqsem = hc->id + 1; #endif #ifdef CONFIG_MISDN_HFCMULTI_8xx @@ -2719,14 +2719,14 @@ hfcmulti_interrupt(int intno, void *dev_id) iq6++; if (iqcnt++ > 5000) { printk(KERN_ERR "iq1:%x iq2:%x iq3:%x iq4:%x iq5:%x iq6:%x\n", - iq1, iq2, iq3, iq4, iq5, iq6); + iq1, iq2, iq3, iq4, iq5, iq6); iqcnt = 0; } #endif if (!r_irq_statech && !(status & (V_DTMF_STA | V_LOST_STA | V_EXT_IRQSTA | - V_MISC_IRQSTA | V_FR_IRQSTA))) { + V_MISC_IRQSTA | V_FR_IRQSTA))) { /* irq is not for us */ goto irq_notforus; } @@ -2751,7 +2751,7 @@ hfcmulti_interrupt(int intno, void *dev_id) dch = hc->chan[hc->dslot].dch; e1_syncsta = HFC_inb_nodebug(hc, R_SYNC_STA); if (test_bit(HFC_CHIP_PLXSD, &hc->chip) - && hc->e1_getclock) { + && hc->e1_getclock) { if (e1_syncsta & V_FR_SYNC_E1) hc->syncronized = 1; else @@ -2760,12 +2760,12 @@ hfcmulti_interrupt(int intno, void *dev_id) /* undocumented: status changes during read */ dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA); while (dch->state != (temp = - HFC_inb_nodebug(hc, R_E1_RD_STA))) { + HFC_inb_nodebug(hc, R_E1_RD_STA))) { if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG "%s: reread " - "STATE because %d!=%d\n", - __func__, temp, - dch->state); + "STATE because %d!=%d\n", + __func__, temp, + dch->state); dch->state = temp; /* repeat */ } dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA) @@ -2773,8 +2773,8 @@ hfcmulti_interrupt(int intno, void *dev_id) schedule_event(dch, FLG_PHCHANGE); if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: E1 (id=%d) newstate %x\n", - __func__, hc->id, dch->state); + "%s: E1 (id=%d) newstate %x\n", + __func__, hc->id, dch->state); if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) plxsd_checksync(hc, 0); } @@ -2792,7 +2792,7 @@ hfcmulti_interrupt(int intno, void *dev_id) static int irq_proc_cnt; if (!irq_proc_cnt++) printk(KERN_DEBUG "%s: got V_IRQ_PROC -" - " this should not happen\n", __func__); + " this should not happen\n", __func__); } } @@ -2841,7 +2841,7 @@ hfcmulti_dbusy_timer(struct hfc_multi *hc) */ static int mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, - int bank_tx, int slot_rx, int bank_rx) + int bank_tx, int slot_rx, int bank_rx) { int flow_tx = 0, flow_rx = 0, routing = 0; int oslot_tx, oslot_rx; @@ -2855,28 +2855,28 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG - "%s: card %d channel %d protocol %x slot old=%d new=%d " - "bank new=%d (TX) slot old=%d new=%d bank new=%d (RX)\n", - __func__, hc->id, ch, protocol, oslot_tx, slot_tx, - bank_tx, oslot_rx, slot_rx, bank_rx); + "%s: card %d channel %d protocol %x slot old=%d new=%d " + "bank new=%d (TX) slot old=%d new=%d bank new=%d (RX)\n", + __func__, hc->id, ch, protocol, oslot_tx, slot_tx, + bank_tx, oslot_rx, slot_rx, bank_rx); if (oslot_tx >= 0 && slot_tx != oslot_tx) { /* remove from slot */ if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG "%s: remove from slot %d (TX)\n", - __func__, oslot_tx); - if (hc->slot_owner[oslot_tx<<1] == ch) { + __func__, oslot_tx); + if (hc->slot_owner[oslot_tx << 1] == ch) { HFC_outb(hc, R_SLOT, oslot_tx << 1); HFC_outb(hc, A_SL_CFG, 0); if (hc->ctype != HFC_TYPE_XHFC) HFC_outb(hc, A_CONF, 0); - hc->slot_owner[oslot_tx<<1] = -1; + hc->slot_owner[oslot_tx << 1] = -1; } else { if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG - "%s: we are not owner of this tx slot " - "anymore, channel %d is.\n", - __func__, hc->slot_owner[oslot_tx<<1]); + "%s: we are not owner of this tx slot " + "anymore, channel %d is.\n", + __func__, hc->slot_owner[oslot_tx << 1]); } } @@ -2884,8 +2884,8 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, /* remove from slot */ if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG - "%s: remove from slot %d (RX)\n", - __func__, oslot_rx); + "%s: remove from slot %d (RX)\n", + __func__, oslot_rx); if (hc->slot_owner[(oslot_rx << 1) | 1] == ch) { HFC_outb(hc, R_SLOT, (oslot_rx << 1) | V_SL_DIR); HFC_outb(hc, A_SL_CFG, 0); @@ -2893,10 +2893,10 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, } else { if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG - "%s: we are not owner of this rx slot " - "anymore, channel %d is.\n", - __func__, - hc->slot_owner[(oslot_rx << 1) | 1]); + "%s: we are not owner of this rx slot " + "anymore, channel %d is.\n", + __func__, + hc->slot_owner[(oslot_rx << 1) | 1]); } } @@ -2917,14 +2917,14 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, routing = 0x40; /* loop */ if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG "%s: put channel %d to slot %d bank" - " %d flow %02x routing %02x conf %d (TX)\n", - __func__, ch, slot_tx, bank_tx, - flow_tx, routing, conf); + " %d flow %02x routing %02x conf %d (TX)\n", + __func__, ch, slot_tx, bank_tx, + flow_tx, routing, conf); HFC_outb(hc, R_SLOT, slot_tx << 1); - HFC_outb(hc, A_SL_CFG, (ch<<1) | routing); + HFC_outb(hc, A_SL_CFG, (ch << 1) | routing); if (hc->ctype != HFC_TYPE_XHFC) HFC_outb(hc, A_CONF, - (conf < 0) ? 0 : (conf | V_CONF_SL)); + (conf < 0) ? 0 : (conf | V_CONF_SL)); hc->slot_owner[slot_tx << 1] = ch; hc->chan[ch].slot_tx = slot_tx; hc->chan[ch].bank_tx = bank_tx; @@ -2946,12 +2946,12 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, routing = 0x40; /* loop */ if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG "%s: put channel %d to slot %d bank" - " %d flow %02x routing %02x conf %d (RX)\n", - __func__, ch, slot_rx, bank_rx, - flow_rx, routing, conf); - HFC_outb(hc, R_SLOT, (slot_rx<<1) | V_SL_DIR); - HFC_outb(hc, A_SL_CFG, (ch<<1) | V_CH_DIR | routing); - hc->slot_owner[(slot_rx<<1)|1] = ch; + " %d flow %02x routing %02x conf %d (RX)\n", + __func__, ch, slot_rx, bank_rx, + flow_rx, routing, conf); + HFC_outb(hc, R_SLOT, (slot_rx << 1) | V_SL_DIR); + HFC_outb(hc, A_SL_CFG, (ch << 1) | V_CH_DIR | routing); + hc->slot_owner[(slot_rx << 1) | 1] = ch; hc->chan[ch].slot_rx = slot_rx; hc->chan[ch].bank_rx = bank_rx; } @@ -2967,7 +2967,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); HFC_wait(hc); /* disable RX fifo */ - HFC_outb(hc, R_FIFO, (ch<<1)|1); + HFC_outb(hc, R_FIFO, (ch << 1) | 1); HFC_wait(hc); HFC_outb(hc, A_CON_HDLC, flow_rx | 0x00); HFC_outb(hc, A_SUBCH_CFG, 0); @@ -2976,17 +2976,17 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, HFC_wait(hc); if (hc->chan[ch].bch && hc->ctype != HFC_TYPE_E1) { hc->hw.a_st_ctrl0[hc->chan[ch].port] &= - ((ch & 0x3) == 0) ? ~V_B1_EN : ~V_B2_EN; + ((ch & 0x3) == 0) ? ~V_B1_EN : ~V_B2_EN; HFC_outb(hc, R_ST_SEL, hc->chan[ch].port); /* undocumented: delay after R_ST_SEL */ udelay(1); HFC_outb(hc, A_ST_CTRL0, - hc->hw.a_st_ctrl0[hc->chan[ch].port]); + hc->hw.a_st_ctrl0[hc->chan[ch].port]); } if (hc->chan[ch].bch) { test_and_clear_bit(FLG_HDLC, &hc->chan[ch].bch->Flags); test_and_clear_bit(FLG_TRANSPARENT, - &hc->chan[ch].bch->Flags); + &hc->chan[ch].bch->Flags); } break; case (ISDN_P_B_RAW): /* B-channel */ @@ -2996,20 +2996,20 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, (hc->chan[ch].slot_tx < 0)) { printk(KERN_DEBUG - "Setting B-channel %d to echo cancelable " - "state on PCM slot %d\n", ch, - ((ch / 4) * 8) + ((ch % 4) * 4) + 1); + "Setting B-channel %d to echo cancelable " + "state on PCM slot %d\n", ch, + ((ch / 4) * 8) + ((ch % 4) * 4) + 1); printk(KERN_DEBUG - "Enabling pass through for channel\n"); + "Enabling pass through for channel\n"); vpm_out(hc, ch, ((ch / 4) * 8) + - ((ch % 4) * 4) + 1, 0x01); + ((ch % 4) * 4) + 1, 0x01); /* rx path */ /* S/T -> PCM */ HFC_outb(hc, R_FIFO, (ch << 1)); HFC_wait(hc); HFC_outb(hc, A_CON_HDLC, 0xc0 | V_HDLC_TRP | V_IFF); HFC_outb(hc, R_SLOT, (((ch / 4) * 8) + - ((ch % 4) * 4) + 1) << 1); + ((ch % 4) * 4) + 1) << 1); HFC_outb(hc, A_SL_CFG, 0x80 | (ch << 1)); /* PCM -> FIFO */ @@ -3021,7 +3021,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); HFC_wait(hc); HFC_outb(hc, R_SLOT, ((((ch / 4) * 8) + - ((ch % 4) * 4) + 1) << 1) | 1); + ((ch % 4) * 4) + 1) << 1) | 1); HFC_outb(hc, A_SL_CFG, 0x80 | 0x20 | (ch << 1) | 1); /* tx path */ @@ -3030,7 +3030,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, HFC_wait(hc); HFC_outb(hc, A_CON_HDLC, 0xc0 | V_HDLC_TRP | V_IFF); HFC_outb(hc, R_SLOT, ((((ch / 4) * 8) + - ((ch % 4) * 4)) << 1) | 1); + ((ch % 4) * 4)) << 1) | 1); HFC_outb(hc, A_SL_CFG, 0x80 | 0x40 | (ch << 1) | 1); /* FIFO -> PCM */ @@ -3044,7 +3044,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, /* tx silence */ HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence); HFC_outb(hc, R_SLOT, (((ch / 4) * 8) + - ((ch % 4) * 4)) << 1); + ((ch % 4) * 4)) << 1); HFC_outb(hc, A_SL_CFG, 0x80 | 0x20 | (ch << 1)); } else { /* enable TX fifo */ @@ -3052,11 +3052,11 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, HFC_wait(hc); if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, A_CON_HDLC, flow_tx | 0x07 << 2 | - V_HDLC_TRP | V_IFF); - /* Enable FIFO, no interrupt */ + V_HDLC_TRP | V_IFF); + /* Enable FIFO, no interrupt */ else HFC_outb(hc, A_CON_HDLC, flow_tx | 0x00 | - V_HDLC_TRP | V_IFF); + V_HDLC_TRP | V_IFF); HFC_outb(hc, A_SUBCH_CFG, 0); HFC_outb(hc, A_IRQ_MSK, 0); HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); @@ -3064,15 +3064,15 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, /* tx silence */ HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence); /* enable RX fifo */ - HFC_outb(hc, R_FIFO, (ch<<1)|1); + HFC_outb(hc, R_FIFO, (ch << 1) | 1); HFC_wait(hc); if (hc->ctype == HFC_TYPE_XHFC) HFC_outb(hc, A_CON_HDLC, flow_rx | 0x07 << 2 | - V_HDLC_TRP); - /* Enable FIFO, no interrupt*/ + V_HDLC_TRP); + /* Enable FIFO, no interrupt*/ else HFC_outb(hc, A_CON_HDLC, flow_rx | 0x00 | - V_HDLC_TRP); + V_HDLC_TRP); HFC_outb(hc, A_SUBCH_CFG, 0); HFC_outb(hc, A_IRQ_MSK, 0); HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); @@ -3080,16 +3080,16 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, } if (hc->ctype != HFC_TYPE_E1) { hc->hw.a_st_ctrl0[hc->chan[ch].port] |= - ((ch & 0x3) == 0) ? V_B1_EN : V_B2_EN; + ((ch & 0x3) == 0) ? V_B1_EN : V_B2_EN; HFC_outb(hc, R_ST_SEL, hc->chan[ch].port); /* undocumented: delay after R_ST_SEL */ udelay(1); HFC_outb(hc, A_ST_CTRL0, - hc->hw.a_st_ctrl0[hc->chan[ch].port]); + hc->hw.a_st_ctrl0[hc->chan[ch].port]); } if (hc->chan[ch].bch) test_and_set_bit(FLG_TRANSPARENT, - &hc->chan[ch].bch->Flags); + &hc->chan[ch].bch->Flags); break; case (ISDN_P_B_HDLC): /* B-channel */ case (ISDN_P_TE_S0): /* D-channel */ @@ -3097,7 +3097,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, case (ISDN_P_TE_E1): case (ISDN_P_NT_E1): /* enable TX fifo */ - HFC_outb(hc, R_FIFO, ch<<1); + HFC_outb(hc, R_FIFO, ch << 1); HFC_wait(hc); if (hc->ctype == HFC_TYPE_E1 || hc->chan[ch].bch) { /* E1 or B-channel */ @@ -3112,7 +3112,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); HFC_wait(hc); /* enable RX fifo */ - HFC_outb(hc, R_FIFO, (ch<<1)|1); + HFC_outb(hc, R_FIFO, (ch << 1) | 1); HFC_wait(hc); HFC_outb(hc, A_CON_HDLC, flow_rx | 0x04); if (hc->ctype == HFC_TYPE_E1 || hc->chan[ch].bch) @@ -3126,18 +3126,18 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, test_and_set_bit(FLG_HDLC, &hc->chan[ch].bch->Flags); if (hc->ctype != HFC_TYPE_E1) { hc->hw.a_st_ctrl0[hc->chan[ch].port] |= - ((ch&0x3) == 0) ? V_B1_EN : V_B2_EN; + ((ch & 0x3) == 0) ? V_B1_EN : V_B2_EN; HFC_outb(hc, R_ST_SEL, hc->chan[ch].port); /* undocumented: delay after R_ST_SEL */ udelay(1); HFC_outb(hc, A_ST_CTRL0, - hc->hw.a_st_ctrl0[hc->chan[ch].port]); + hc->hw.a_st_ctrl0[hc->chan[ch].port]); } } break; default: printk(KERN_DEBUG "%s: protocol not known %x\n", - __func__, protocol); + __func__, protocol); hc->chan[ch].protocol = ISDN_P_NONE; return -ENOPROTOOPT; } @@ -3152,7 +3152,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx, static void hfcmulti_pcm(struct hfc_multi *hc, int ch, int slot_tx, int bank_tx, - int slot_rx, int bank_rx) + int slot_rx, int bank_rx) { if (slot_tx < 0 || slot_rx < 0 || bank_tx < 0 || bank_rx < 0) { /* disable PCM */ @@ -3162,7 +3162,7 @@ hfcmulti_pcm(struct hfc_multi *hc, int ch, int slot_tx, int bank_tx, /* enable pcm */ mode_hfcmulti(hc, ch, hc->chan[ch].protocol, slot_tx, bank_tx, - slot_rx, bank_rx); + slot_rx, bank_rx); } /* @@ -3177,8 +3177,8 @@ hfcmulti_conf(struct hfc_multi *hc, int ch, int num) else hc->chan[ch].conf = -1; mode_hfcmulti(hc, ch, hc->chan[ch].protocol, hc->chan[ch].slot_tx, - hc->chan[ch].bank_tx, hc->chan[ch].slot_rx, - hc->chan[ch].bank_rx); + hc->chan[ch].bank_tx, hc->chan[ch].slot_rx, + hc->chan[ch].bank_rx); } @@ -3207,8 +3207,8 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) if (hc->ctype == HFC_TYPE_E1) { if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: HW_RESET_REQ no BRI\n", - __func__); + "%s: HW_RESET_REQ no BRI\n", + __func__); } else { HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port); /* undocumented: delay after R_ST_SEL */ @@ -3216,8 +3216,8 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) HFC_outb(hc, A_ST_WR_STATE, V_ST_LD_STA | 3); /* F3 */ udelay(6); /* wait at least 5,21us */ HFC_outb(hc, A_ST_WR_STATE, 3); - HFC_outb(hc, A_ST_WR_STATE, 3 | (V_ST_ACT*3)); - /* activate */ + HFC_outb(hc, A_ST_WR_STATE, 3 | (V_ST_ACT * 3)); + /* activate */ } spin_unlock_irqrestore(&hc->lock, flags); l1_event(dch->l1, HW_POWERUP_IND); @@ -3228,17 +3228,17 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) if (hc->ctype == HFC_TYPE_E1) { if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: HW_DEACT_REQ no BRI\n", - __func__); + "%s: HW_DEACT_REQ no BRI\n", + __func__); } else { HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port); /* undocumented: delay after R_ST_SEL */ udelay(1); - HFC_outb(hc, A_ST_WR_STATE, V_ST_ACT*2); - /* deactivate */ + HFC_outb(hc, A_ST_WR_STATE, V_ST_ACT * 2); + /* deactivate */ if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { hc->syncronized &= - ~(1 << hc->chan[dch->slot].port); + ~(1 << hc->chan[dch->slot].port); plxsd_checksync(hc, 0); } } @@ -3262,8 +3262,8 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) if (hc->ctype == HFC_TYPE_E1) { if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: HW_POWERUP_REQ no BRI\n", - __func__); + "%s: HW_POWERUP_REQ no BRI\n", + __func__); } else { HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port); /* undocumented: delay after R_ST_SEL */ @@ -3277,17 +3277,17 @@ hfcm_l1callback(struct dchannel *dch, u_int cmd) case PH_ACTIVATE_IND: test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; case PH_DEACTIVATE_IND: test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: unknown command %x\n", - __func__, cmd); + __func__, cmd); return -1; } return 0; @@ -3332,27 +3332,27 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) ret = 0; if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: PH_ACTIVATE port %d (0..%d)\n", - __func__, hc->chan[dch->slot].port, - hc->ports-1); + "%s: PH_ACTIVATE port %d (0..%d)\n", + __func__, hc->chan[dch->slot].port, + hc->ports - 1); /* start activation */ if (hc->ctype == HFC_TYPE_E1) { ph_state_change(dch); if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: E1 report state %x \n", - __func__, dch->state); + "%s: E1 report state %x \n", + __func__, dch->state); } else { HFC_outb(hc, R_ST_SEL, - hc->chan[dch->slot].port); + hc->chan[dch->slot].port); /* undocumented: delay after R_ST_SEL */ udelay(1); HFC_outb(hc, A_ST_WR_STATE, V_ST_LD_STA | 1); - /* G1 */ + /* G1 */ udelay(6); /* wait at least 5,21us */ HFC_outb(hc, A_ST_WR_STATE, 1); HFC_outb(hc, A_ST_WR_STATE, 1 | - (V_ST_ACT*3)); /* activate */ + (V_ST_ACT * 3)); /* activate */ dch->state = 1; } spin_unlock_irqrestore(&hc->lock, flags); @@ -3365,22 +3365,22 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) spin_lock_irqsave(&hc->lock, flags); if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: PH_DEACTIVATE port %d (0..%d)\n", - __func__, hc->chan[dch->slot].port, - hc->ports-1); + "%s: PH_DEACTIVATE port %d (0..%d)\n", + __func__, hc->chan[dch->slot].port, + hc->ports - 1); /* start deactivation */ if (hc->ctype == HFC_TYPE_E1) { if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: PH_DEACTIVATE no BRI\n", - __func__); + "%s: PH_DEACTIVATE no BRI\n", + __func__); } else { HFC_outb(hc, R_ST_SEL, - hc->chan[dch->slot].port); + hc->chan[dch->slot].port); /* undocumented: delay after R_ST_SEL */ udelay(1); HFC_outb(hc, A_ST_WR_STATE, V_ST_ACT * 2); - /* deactivate */ + /* deactivate */ dch->state = 1; } skb_queue_purge(&dch->squeue); @@ -3460,28 +3460,28 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) case PH_ACTIVATE_REQ: if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: PH_ACTIVATE ch %d (0..32)\n", - __func__, bch->slot); + __func__, bch->slot); spin_lock_irqsave(&hc->lock, flags); /* activate B-channel if not already activated */ if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags)) { hc->chan[bch->slot].txpending = 0; ret = mode_hfcmulti(hc, bch->slot, - ch->protocol, - hc->chan[bch->slot].slot_tx, - hc->chan[bch->slot].bank_tx, - hc->chan[bch->slot].slot_rx, - hc->chan[bch->slot].bank_rx); + ch->protocol, + hc->chan[bch->slot].slot_tx, + hc->chan[bch->slot].bank_tx, + hc->chan[bch->slot].slot_rx, + hc->chan[bch->slot].bank_rx); if (!ret) { if (ch->protocol == ISDN_P_B_RAW && !hc->dtmf - && test_bit(HFC_CHIP_DTMF, &hc->chip)) { + && test_bit(HFC_CHIP_DTMF, &hc->chip)) { /* start decoder */ hc->dtmf = 1; if (debug & DEBUG_HFCMULTI_DTMF) printk(KERN_DEBUG - "%s: start dtmf decoder\n", - __func__); + "%s: start dtmf decoder\n", + __func__); HFC_outb(hc, R_DTMF, hc->hw.r_dtmf | - V_RST_DTMF); + V_RST_DTMF); } } } else @@ -3489,7 +3489,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&hc->lock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, NULL, - GFP_KERNEL); + GFP_KERNEL); break; case PH_CONTROL_REQ: spin_lock_irqsave(&hc->lock, flags); @@ -3497,20 +3497,20 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) case HFC_SPL_LOOP_ON: /* set sample loop */ if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: HFC_SPL_LOOP_ON (len = %d)\n", - __func__, skb->len); + "%s: HFC_SPL_LOOP_ON (len = %d)\n", + __func__, skb->len); ret = 0; break; case HFC_SPL_LOOP_OFF: /* set silence */ if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: HFC_SPL_LOOP_OFF\n", - __func__); + __func__); ret = 0; break; default: printk(KERN_ERR - "%s: unknown PH_CONTROL_REQ info %x\n", - __func__, hh->id); + "%s: unknown PH_CONTROL_REQ info %x\n", + __func__, hh->id); ret = -EINVAL; } spin_unlock_irqrestore(&hc->lock, flags); @@ -3518,7 +3518,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) case PH_DEACTIVATE_REQ: deactivate_bchannel(bch); /* locked there */ _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, NULL, - GFP_KERNEL); + GFP_KERNEL); ret = 0; break; } @@ -3559,18 +3559,18 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) } if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: RX_OFF request (nr=%d off=%d)\n", - __func__, bch->nr, hc->chan[bch->slot].rx_off); + __func__, bch->nr, hc->chan[bch->slot].rx_off); break; case MISDN_CTRL_FILL_EMPTY: /* fill fifo, if empty */ test_and_set_bit(FLG_FILLEMPTY, &bch->Flags); if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d " - "off=%d)\n", __func__, bch->nr, !!cq->p1); + "off=%d)\n", __func__, bch->nr, !!cq->p1); break; case MISDN_CTRL_HW_FEATURES: /* fill features structure */ if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: HW_FEATURE request\n", - __func__); + __func__); /* create confirm */ features->hfc_id = hc->id; if (test_bit(HFC_CHIP_DTMF, &hc->chip)) @@ -3593,40 +3593,40 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) bank_rx = cq->p2 >> 8; if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG - "%s: HFC_PCM_CONN slot %d bank %d (TX) " - "slot %d bank %d (RX)\n", - __func__, slot_tx, bank_tx, - slot_rx, bank_rx); + "%s: HFC_PCM_CONN slot %d bank %d (TX) " + "slot %d bank %d (RX)\n", + __func__, slot_tx, bank_tx, + slot_rx, bank_rx); if (slot_tx < hc->slots && bank_tx <= 2 && slot_rx < hc->slots && bank_rx <= 2) hfcmulti_pcm(hc, bch->slot, - slot_tx, bank_tx, slot_rx, bank_rx); + slot_tx, bank_tx, slot_rx, bank_rx); else { printk(KERN_WARNING - "%s: HFC_PCM_CONN slot %d bank %d (TX) " - "slot %d bank %d (RX) out of range\n", - __func__, slot_tx, bank_tx, - slot_rx, bank_rx); + "%s: HFC_PCM_CONN slot %d bank %d (TX) " + "slot %d bank %d (RX) out of range\n", + __func__, slot_tx, bank_tx, + slot_rx, bank_rx); ret = -EINVAL; } break; case MISDN_CTRL_HFC_PCM_DISC: /* release interface from pcm timeslot */ if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: HFC_PCM_DISC\n", - __func__); + __func__); hfcmulti_pcm(hc, bch->slot, -1, 0, -1, 0); break; case MISDN_CTRL_HFC_CONF_JOIN: /* join conference (0..7) */ num = cq->p1 & 0xff; if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: HFC_CONF_JOIN conf %d\n", - __func__, num); + __func__, num); if (num <= 7) hfcmulti_conf(hc, bch->slot, num); else { printk(KERN_WARNING - "%s: HW_CONF_JOIN conf %d out of range\n", - __func__, num); + "%s: HW_CONF_JOIN conf %d out of range\n", + __func__, num); ret = -EINVAL; } break; @@ -3647,7 +3647,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_HFC_ECHOCAN_OFF: if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: HFC_ECHOCAN_OFF\n", - __func__); + __func__); if (test_bit(HFC_CHIP_B410P, &hc->chip)) vpm_echocan_off(hc, bch->slot); else @@ -3655,7 +3655,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) break; default: printk(KERN_WARNING "%s: unknown Op %x\n", - __func__, cq->op); + __func__, cq->op); ret = -EINVAL; break; } @@ -3672,7 +3672,7 @@ hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (bch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: cmd:%x %p\n", - __func__, cmd, arg); + __func__, cmd, arg); switch (cmd) { case CLOSE_CHANNEL: test_and_clear_bit(FLG_OPEN, &bch->Flags); @@ -3690,7 +3690,7 @@ hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) break; default: printk(KERN_WARNING "%s: unknown prim(%x)\n", - __func__, cmd); + __func__, cmd); } return err; } @@ -3717,13 +3717,13 @@ ph_state_change(struct dchannel *dch) if (dch->dev.D.protocol == ISDN_P_TE_E1) { if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: E1 TE (id=%d) newstate %x\n", - __func__, hc->id, dch->state); + "%s: E1 TE (id=%d) newstate %x\n", + __func__, hc->id, dch->state); } else { if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: E1 NT (id=%d) newstate %x\n", - __func__, hc->id, dch->state); + "%s: E1 NT (id=%d) newstate %x\n", + __func__, hc->id, dch->state); } switch (dch->state) { case (1): @@ -3731,16 +3731,16 @@ ph_state_change(struct dchannel *dch) for (i = 1; i <= 31; i++) { /* reset fifos on e1 activation */ HFC_outb_nodebug(hc, R_FIFO, - (i << 1) | 1); + (i << 1) | 1); HFC_wait_nodebug(hc); HFC_outb_nodebug(hc, R_INC_RES_FIFO, - V_RES_F); + V_RES_F); HFC_wait_nodebug(hc); } } test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); break; default: @@ -3748,15 +3748,15 @@ ph_state_change(struct dchannel *dch) return; test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); } hc->e1_state = dch->state; } else { if (dch->dev.D.protocol == ISDN_P_TE_S0) { if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG - "%s: S/T TE newstate %x\n", - __func__, dch->state); + "%s: S/T TE newstate %x\n", + __func__, dch->state); switch (dch->state) { case (0): l1_event(dch->l1, HW_RESET_IND); @@ -3778,38 +3778,38 @@ ph_state_change(struct dchannel *dch) } else { if (debug & DEBUG_HFCMULTI_STATE) printk(KERN_DEBUG "%s: S/T NT newstate %x\n", - __func__, dch->state); + __func__, dch->state); switch (dch->state) { case (2): if (hc->chan[ch].nt_timer == 0) { hc->chan[ch].nt_timer = -1; HFC_outb(hc, R_ST_SEL, - hc->chan[ch].port); + hc->chan[ch].port); /* undocumented: delay after R_ST_SEL */ udelay(1); HFC_outb(hc, A_ST_WR_STATE, 4 | - V_ST_LD_STA); /* G4 */ + V_ST_LD_STA); /* G4 */ udelay(6); /* wait at least 5,21us */ HFC_outb(hc, A_ST_WR_STATE, 4); dch->state = 4; } else { /* one extra count for the next event */ hc->chan[ch].nt_timer = - nt_t1_count[poll_timer] + 1; + nt_t1_count[poll_timer] + 1; HFC_outb(hc, R_ST_SEL, - hc->chan[ch].port); + hc->chan[ch].port); /* undocumented: delay after R_ST_SEL */ udelay(1); /* allow G2 -> G3 transition */ HFC_outb(hc, A_ST_WR_STATE, 2 | - V_SET_G2_G3); + V_SET_G2_G3); } break; case (1): hc->chan[ch].nt_timer = -1; test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); break; case (4): hc->chan[ch].nt_timer = -1; @@ -3818,7 +3818,7 @@ ph_state_change(struct dchannel *dch) hc->chan[ch].nt_timer = -1; test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); break; } } @@ -3845,7 +3845,7 @@ hfcmulti_initmode(struct dchannel *dch) hc->chan[hc->dslot].conf = -1; if (hc->dslot) { mode_hfcmulti(hc, hc->dslot, dch->dev.D.protocol, - -1, 0, -1, 0); + -1, 0, -1, 0); dch->timer.function = (void *) hfcmulti_dbusy_timer; dch->timer.data = (long) dch; init_timer(&dch->timer); @@ -3887,13 +3887,13 @@ hfcmulti_initmode(struct dchannel *dch) if (dch->dev.D.protocol == ISDN_P_NT_E1) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: E1 port is NT-mode\n", - __func__); + __func__); r_e1_wr_sta = 0; /* G0 */ hc->e1_getclock = 0; } else { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: E1 port is TE-mode\n", - __func__); + __func__); r_e1_wr_sta = 0; /* F0 */ hc->e1_getclock = 1; } @@ -3909,26 +3909,26 @@ hfcmulti_initmode(struct dchannel *dch) /* SLAVE (clock master) */ if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: E1 port is clock master " - "(clock from PCM)\n", __func__); + "%s: E1 port is clock master " + "(clock from PCM)\n", __func__); HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC | V_PCM_SYNC); } else { if (hc->e1_getclock) { /* MASTER (clock slave) */ if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: E1 port is clock slave " - "(clock to PCM)\n", __func__); + "%s: E1 port is clock slave " + "(clock to PCM)\n", __func__); HFC_outb(hc, R_SYNC_CTRL, V_SYNC_OFFS); } else { /* MASTER (clock master) */ if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: E1 port is " - "clock master " - "(clock from QUARTZ)\n", - __func__); + "clock master " + "(clock from QUARTZ)\n", + __func__); HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC | - V_PCM_SYNC | V_JATT_OFF); + V_PCM_SYNC | V_JATT_OFF); HFC_outb(hc, R_SYNC_OUT, 0); } } @@ -3970,8 +3970,8 @@ hfcmulti_initmode(struct dchannel *dch) if (dch->dev.D.protocol == ISDN_P_NT_S0) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: ST port %d is NT-mode\n", - __func__, pt); + "%s: ST port %d is NT-mode\n", + __func__, pt); /* clock delay */ HFC_outb(hc, A_ST_CLK_DLY, clockdelay_nt); a_st_wr_state = 1; /* G1 */ @@ -3979,8 +3979,8 @@ hfcmulti_initmode(struct dchannel *dch) } else { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: ST port %d is TE-mode\n", - __func__, pt); + "%s: ST port %d is TE-mode\n", + __func__, pt); /* clock delay */ HFC_outb(hc, A_ST_CLK_DLY, clockdelay_te); a_st_wr_state = 2; /* F2 */ @@ -3991,7 +3991,7 @@ hfcmulti_initmode(struct dchannel *dch) if (hc->ctype == HFC_TYPE_XHFC) { hc->hw.a_st_ctrl0[pt] |= 0x40 /* V_ST_PU_CTRL */; HFC_outb(hc, 0x35 /* A_ST_CTRL3 */, - 0x7c << 1 /* V_ST_PULSE */); + 0x7c << 1 /* V_ST_PULSE */); } /* line setup */ HFC_outb(hc, A_ST_CTRL0, hc->hw.a_st_ctrl0[pt]); @@ -4013,7 +4013,7 @@ hfcmulti_initmode(struct dchannel *dch) /* unset sync on port */ if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { hc->syncronized &= - ~(1 << hc->chan[dch->slot].port); + ~(1 << hc->chan[dch->slot].port); plxsd_checksync(hc, 0); } } @@ -4024,21 +4024,21 @@ hfcmulti_initmode(struct dchannel *dch) static int open_dchannel(struct hfc_multi *hc, struct dchannel *dch, - struct channel_req *rq) + struct channel_req *rq) { int err = 0; u_long flags; if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: dev(%d) open from %p\n", __func__, - dch->dev.id, __builtin_return_address(0)); + dch->dev.id, __builtin_return_address(0)); if (rq->protocol == ISDN_P_NONE) return -EINVAL; if ((dch->dev.D.protocol != ISDN_P_NONE) && (dch->dev.D.protocol != rq->protocol)) { if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG "%s: change protocol %x to %x\n", - __func__, dch->dev.D.protocol, rq->protocol); + __func__, dch->dev.D.protocol, rq->protocol); } if ((dch->dev.D.protocol == ISDN_P_TE_S0) && (rq->protocol != ISDN_P_TE_S0)) @@ -4060,7 +4060,7 @@ open_dchannel(struct hfc_multi *hc, struct dchannel *dch, ((rq->protocol == ISDN_P_NT_E1) && (dch->state == 1)) || ((rq->protocol == ISDN_P_TE_E1) && (dch->state == 1))) { _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); } rq->ch = &dch->dev.D; if (!try_module_get(THIS_MODULE)) @@ -4070,7 +4070,7 @@ open_dchannel(struct hfc_multi *hc, struct dchannel *dch, static int open_bchannel(struct hfc_multi *hc, struct dchannel *dch, - struct channel_req *rq) + struct channel_req *rq) { struct bchannel *bch; int ch; @@ -4086,7 +4086,7 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch, bch = hc->chan[ch].bch; if (!bch) { printk(KERN_ERR "%s:internal error ch %d has no bch\n", - __func__, ch); + __func__, ch); return -EINVAL; } if (test_and_set_bit(FLG_OPEN, &bch->Flags)) @@ -4119,8 +4119,8 @@ channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq) wd_mode = !!(cq->p1 >> 4); if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: MISDN_CTRL_HFC_WD_INIT mode %s" - ", counter 0x%x\n", __func__, - wd_mode ? "AUTO" : "MANUAL", wd_cnt); + ", counter 0x%x\n", __func__, + wd_mode ? "AUTO" : "MANUAL", wd_cnt); /* set the watchdog timer */ HFC_outb(hc, R_TI_WD, poll_timer | (wd_cnt << 4)); hc->hw.r_bert_wd_md = (wd_mode ? V_AUTO_WD_RES : 0); @@ -4139,12 +4139,12 @@ channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_HFC_WD_RESET: /* reset the watchdog counter */ if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: MISDN_CTRL_HFC_WD_RESET\n", - __func__); + __func__); HFC_outb(hc, R_BERT_WD_MD, hc->hw.r_bert_wd_md | V_WD_RES); break; default: printk(KERN_WARNING "%s: unknown Op %x\n", - __func__, cq->op); + __func__, cq->op); ret = -EINVAL; break; } @@ -4163,7 +4163,7 @@ hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: cmd:%x %p\n", - __func__, cmd, arg); + __func__, cmd, arg); switch (cmd) { case OPEN_CHANNEL: rq = arg; @@ -4193,8 +4193,8 @@ hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) case CLOSE_CHANNEL: if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: dev(%d) close from %p\n", - __func__, dch->dev.id, - __builtin_return_address(0)); + __func__, dch->dev.id, + __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -4205,7 +4205,7 @@ hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: unknown command %x\n", - __func__, cmd); + __func__, cmd); err = -EINVAL; } return err; @@ -4246,9 +4246,9 @@ init_card(struct hfc_multi *hc) spin_unlock_irqrestore(&hc->lock, flags); if (request_irq(hc->irq, hfcmulti_interrupt, IRQF_SHARED, - "HFC-multi", hc)) { + "HFC-multi", hc)) { printk(KERN_WARNING "mISDN: Could not get interrupt %d.\n", - hc->irq); + hc->irq); hc->irq = 0; return -EIO; } @@ -4257,13 +4257,13 @@ init_card(struct hfc_multi *hc) spin_lock_irqsave(&plx_lock, plx_flags); plx_acc = hc->plx_membase + PLX_INTCSR; writew((PLX_INTCSR_PCIINT_ENABLE | PLX_INTCSR_LINTI1_ENABLE), - plx_acc); /* enable PCI & LINT1 irq */ + plx_acc); /* enable PCI & LINT1 irq */ spin_unlock_irqrestore(&plx_lock, plx_flags); } if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: IRQ %d count %d\n", - __func__, hc->irq, hc->irqcnt); + __func__, hc->irq, hc->irqcnt); err = init_chip(hc); if (err) goto error; @@ -4277,14 +4277,14 @@ init_card(struct hfc_multi *hc) spin_unlock_irqrestore(&hc->lock, flags); /* printk(KERN_DEBUG "no master irq set!!!\n"); */ set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((100*HZ)/1000); /* Timeout 100ms */ + schedule_timeout((100 * HZ) / 1000); /* Timeout 100ms */ /* turn IRQ off until chip is completely initialized */ spin_lock_irqsave(&hc->lock, flags); disable_hwirq(hc); spin_unlock_irqrestore(&hc->lock, flags); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: IRQ %d count %d\n", - __func__, hc->irq, hc->irqcnt); + __func__, hc->irq, hc->irqcnt); if (hc->irqcnt) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: done\n", __func__); @@ -4297,7 +4297,7 @@ init_card(struct hfc_multi *hc) } printk(KERN_ERR "HFC PCI: IRQ(%d) getting no interrupts during init.\n", - hc->irq); + hc->irq); err = -EIO; @@ -4327,13 +4327,13 @@ init_card(struct hfc_multi *hc) static int setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, - const struct pci_device_id *ent) + const struct pci_device_id *ent) { struct hm_map *m = (struct hm_map *)ent->driver_data; printk(KERN_INFO - "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n", - m->vendor_name, m->card_name, m->clock2 ? "double" : "normal"); + "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n", + m->vendor_name, m->card_name, m->clock2 ? "double" : "normal"); hc->pci_dev = pdev; if (m->clock2) @@ -4380,7 +4380,7 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, if (!hc->plx_origmembase) { printk(KERN_WARNING - "HFC-multi: No IO-Memory for PCI PLX bridge found\n"); + "HFC-multi: No IO-Memory for PCI PLX bridge found\n"); pci_disable_device(hc->pci_dev); return -EIO; } @@ -4388,20 +4388,20 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, hc->plx_membase = ioremap(hc->plx_origmembase, 0x80); if (!hc->plx_membase) { printk(KERN_WARNING - "HFC-multi: failed to remap plx address space. " - "(internal error)\n"); + "HFC-multi: failed to remap plx address space. " + "(internal error)\n"); pci_disable_device(hc->pci_dev); return -EIO; } printk(KERN_INFO - "HFC-multi: plx_membase:%#lx plx_origmembase:%#lx\n", - (u_long)hc->plx_membase, hc->plx_origmembase); + "HFC-multi: plx_membase:%#lx plx_origmembase:%#lx\n", + (u_long)hc->plx_membase, hc->plx_origmembase); hc->pci_origmembase = hc->pci_dev->resource[2].start; - /* MEMBASE 1 is PLX PCI Bridge */ + /* MEMBASE 1 is PLX PCI Bridge */ if (!hc->pci_origmembase) { printk(KERN_WARNING - "HFC-multi: No IO-Memory for PCI card found\n"); + "HFC-multi: No IO-Memory for PCI card found\n"); pci_disable_device(hc->pci_dev); return -EIO; } @@ -4409,16 +4409,16 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, hc->pci_membase = ioremap(hc->pci_origmembase, 0x400); if (!hc->pci_membase) { printk(KERN_WARNING "HFC-multi: failed to remap io " - "address space. (internal error)\n"); + "address space. (internal error)\n"); pci_disable_device(hc->pci_dev); return -EIO; } printk(KERN_INFO - "card %d: defined at MEMBASE %#lx (%#lx) IRQ %d HZ %d " - "leds-type %d\n", - hc->id, (u_long)hc->pci_membase, hc->pci_origmembase, - hc->pci_dev->irq, HZ, hc->leds); + "card %d: defined at MEMBASE %#lx (%#lx) IRQ %d HZ %d " + "leds-type %d\n", + hc->id, (u_long)hc->pci_membase, hc->pci_origmembase, + hc->pci_dev->irq, HZ, hc->leds); pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO); break; case HFC_IO_MODE_PCIMEM: @@ -4431,7 +4431,7 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, hc->pci_origmembase = hc->pci_dev->resource[1].start; if (!hc->pci_origmembase) { printk(KERN_WARNING - "HFC-multi: No IO-Memory for PCI card found\n"); + "HFC-multi: No IO-Memory for PCI card found\n"); pci_disable_device(hc->pci_dev); return -EIO; } @@ -4439,14 +4439,14 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, hc->pci_membase = ioremap(hc->pci_origmembase, 256); if (!hc->pci_membase) { printk(KERN_WARNING - "HFC-multi: failed to remap io address space. " - "(internal error)\n"); + "HFC-multi: failed to remap io address space. " + "(internal error)\n"); pci_disable_device(hc->pci_dev); return -EIO; } printk(KERN_INFO "card %d: defined at MEMBASE %#lx (%#lx) IRQ " - "%d HZ %d leds-type %d\n", hc->id, (u_long)hc->pci_membase, - hc->pci_origmembase, hc->pci_dev->irq, HZ, hc->leds); + "%d HZ %d leds-type %d\n", hc->id, (u_long)hc->pci_membase, + hc->pci_origmembase, hc->pci_dev->irq, HZ, hc->leds); pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO); break; case HFC_IO_MODE_REGIO: @@ -4459,23 +4459,23 @@ setup_pci(struct hfc_multi *hc, struct pci_dev *pdev, hc->pci_iobase = (u_int) hc->pci_dev->resource[0].start; if (!hc->pci_iobase) { printk(KERN_WARNING - "HFC-multi: No IO for PCI card found\n"); + "HFC-multi: No IO for PCI card found\n"); pci_disable_device(hc->pci_dev); return -EIO; } if (!request_region(hc->pci_iobase, 8, "hfcmulti")) { printk(KERN_WARNING "HFC-multi: failed to request " - "address space at 0x%08lx (internal error)\n", - hc->pci_iobase); + "address space at 0x%08lx (internal error)\n", + hc->pci_iobase); pci_disable_device(hc->pci_dev); return -EIO; } printk(KERN_INFO - "%s %s: defined at IOBASE %#x IRQ %d HZ %d leds-type %d\n", - m->vendor_name, m->card_name, (u_int) hc->pci_iobase, - hc->pci_dev->irq, HZ, hc->leds); + "%s %s: defined at IOBASE %#x IRQ %d HZ %d leds-type %d\n", + m->vendor_name, m->card_name, (u_int) hc->pci_iobase, + hc->pci_dev->irq, HZ, hc->leds); pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_REGIO); break; default: @@ -4508,17 +4508,17 @@ release_port(struct hfc_multi *hc, struct dchannel *dch) if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: entered for port %d\n", - __func__, pt + 1); + __func__, pt + 1); if (pt >= hc->ports) { printk(KERN_WARNING "%s: ERROR port out of range (%d).\n", - __func__, pt + 1); + __func__, pt + 1); return; } if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: releasing port=%d\n", - __func__, pt + 1); + __func__, pt + 1); if (dch->dev.D.protocol == ISDN_P_TE_S0) l1_event(dch->l1, CLOSE_CHANNEL); @@ -4548,8 +4548,8 @@ release_port(struct hfc_multi *hc, struct dchannel *dch) if (hc->chan[i].bch) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: free port %d channel %d\n", - __func__, hc->chan[i].port+1, i); + "%s: free port %d channel %d\n", + __func__, hc->chan[i].port + 1, i); pb = hc->chan[i].bch; hc->chan[i].bch = NULL; spin_unlock_irqrestore(&hc->lock, flags); @@ -4563,16 +4563,16 @@ release_port(struct hfc_multi *hc, struct dchannel *dch) /* remove sync */ if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) { hc->syncronized &= - ~(1 << hc->chan[ci].port); + ~(1 << hc->chan[ci].port); plxsd_checksync(hc, 1); } /* free channels */ if (hc->chan[ci - 2].bch) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: free port %d channel %d\n", - __func__, hc->chan[ci - 2].port+1, - ci - 2); + "%s: free port %d channel %d\n", + __func__, hc->chan[ci - 2].port + 1, + ci - 2); pb = hc->chan[ci - 2].bch; hc->chan[ci - 2].bch = NULL; spin_unlock_irqrestore(&hc->lock, flags); @@ -4584,9 +4584,9 @@ release_port(struct hfc_multi *hc, struct dchannel *dch) if (hc->chan[ci - 1].bch) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: free port %d channel %d\n", - __func__, hc->chan[ci - 1].port+1, - ci - 1); + "%s: free port %d channel %d\n", + __func__, hc->chan[ci - 1].port + 1, + ci - 1); pb = hc->chan[ci - 1].bch; hc->chan[ci - 1].bch = NULL; spin_unlock_irqrestore(&hc->lock, flags); @@ -4616,7 +4616,7 @@ release_card(struct hfc_multi *hc) if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: release card (%d) entered\n", - __func__, hc->id); + __func__, hc->id); /* unregister clock source */ if (hc->iclock) @@ -4635,7 +4635,7 @@ release_card(struct hfc_multi *hc) /* disable D-channels & B-channels */ if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: disable all channels (d and b)\n", - __func__); + __func__); for (ch = 0; ch <= 31; ch++) { if (hc->chan[ch].dch) release_port(hc, hc->chan[ch].dch); @@ -4645,7 +4645,7 @@ release_card(struct hfc_multi *hc) if (hc->irq) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: free irq %d\n", - __func__, hc->irq); + __func__, hc->irq); free_irq(hc->irq, hc); hc->irq = 0; @@ -4654,7 +4654,7 @@ release_card(struct hfc_multi *hc) if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: remove instance from list\n", - __func__); + __func__); list_del(&hc->list); if (debug & DEBUG_HFCMULTI_INIT) @@ -4664,7 +4664,7 @@ release_card(struct hfc_multi *hc) kfree(hc); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: card successfully removed\n", - __func__); + __func__); } static int @@ -4683,7 +4683,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m) dch->hw = hc; dch->dev.Dprotocols = (1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1); dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | - (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); + (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); dch->dev.D.send = handle_dmsg; dch->dev.D.ctrl = hfcm_dctrl; dch->dev.nrbchan = (hc->dslot) ? 30 : 31; @@ -4697,14 +4697,14 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m) bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL); if (!bch) { printk(KERN_ERR "%s: no memory for bchannel\n", - __func__); + __func__); ret = -ENOMEM; goto free_chan; } hc->chan[ch].coeff = kzalloc(512, GFP_KERNEL); if (!hc->chan[ch].coeff) { printk(KERN_ERR "%s: no memory for coeffs\n", - __func__); + __func__); ret = -ENOMEM; kfree(bch); goto free_chan; @@ -4726,93 +4726,93 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m) if (port[Port_cnt] & 0x001) { if (!m->opticalsupport) { printk(KERN_INFO - "This board has no optical " - "support\n"); + "This board has no optical " + "support\n"); } else { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PORT set optical " - "interfacs: card(%d) " - "port(%d)\n", - __func__, - HFC_cnt + 1, 1); + "%s: PORT set optical " + "interfacs: card(%d) " + "port(%d)\n", + __func__, + HFC_cnt + 1, 1); test_and_set_bit(HFC_CFG_OPTICAL, - &hc->chan[hc->dslot].cfg); + &hc->chan[hc->dslot].cfg); } } /* set LOS report */ if (port[Port_cnt] & 0x004) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PORT set " - "LOS report: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + "LOS report: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CFG_REPORT_LOS, - &hc->chan[hc->dslot].cfg); + &hc->chan[hc->dslot].cfg); } /* set AIS report */ if (port[Port_cnt] & 0x008) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PORT set " - "AIS report: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + "AIS report: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CFG_REPORT_AIS, - &hc->chan[hc->dslot].cfg); + &hc->chan[hc->dslot].cfg); } /* set SLIP report */ if (port[Port_cnt] & 0x010) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PORT set SLIP report: " - "card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + "%s: PORT set SLIP report: " + "card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CFG_REPORT_SLIP, - &hc->chan[hc->dslot].cfg); + &hc->chan[hc->dslot].cfg); } /* set RDI report */ if (port[Port_cnt] & 0x020) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PORT set RDI report: " - "card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + "%s: PORT set RDI report: " + "card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CFG_REPORT_RDI, - &hc->chan[hc->dslot].cfg); + &hc->chan[hc->dslot].cfg); } /* set CRC-4 Mode */ if (!(port[Port_cnt] & 0x100)) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PORT turn on CRC4 report:" - " card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + " card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CFG_CRC4, - &hc->chan[hc->dslot].cfg); + &hc->chan[hc->dslot].cfg); } else { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PORT turn off CRC4" - " report: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + " report: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); } /* set forced clock */ if (port[Port_cnt] & 0x0200) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PORT force getting clock from " - "E1: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + "E1: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CHIP_E1CLOCK_GET, &hc->chip); } else - if (port[Port_cnt] & 0x0400) { - if (debug & DEBUG_HFCMULTI_INIT) - printk(KERN_DEBUG "%s: PORT force putting clock to " - "E1: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); - test_and_set_bit(HFC_CHIP_E1CLOCK_PUT, &hc->chip); - } + if (port[Port_cnt] & 0x0400) { + if (debug & DEBUG_HFCMULTI_INIT) + printk(KERN_DEBUG "%s: PORT force putting clock to " + "E1: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); + test_and_set_bit(HFC_CHIP_E1CLOCK_PUT, &hc->chip); + } /* set JATT PLL */ if (port[Port_cnt] & 0x0800) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: PORT disable JATT PLL on " - "E1: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, 1); + "E1: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, 1); test_and_set_bit(HFC_CHIP_RX_SYNC, &hc->chip); } /* set elastic jitter buffer */ @@ -4820,10 +4820,10 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m) hc->chan[hc->dslot].jitter = (port[Port_cnt]>>12) & 0x3; if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PORT set elastic " - "buffer to %d: card(%d) port(%d)\n", - __func__, hc->chan[hc->dslot].jitter, - HFC_cnt + 1, 1); + "%s: PORT set elastic " + "buffer to %d: card(%d) port(%d)\n", + __func__, hc->chan[hc->dslot].jitter, + HFC_cnt + 1, 1); } else hc->chan[hc->dslot].jitter = 2; /* default */ snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1); @@ -4853,7 +4853,7 @@ init_multi_port(struct hfc_multi *hc, int pt) dch->hw = hc; dch->dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0); dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | - (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); + (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); dch->dev.D.send = handle_dmsg; dch->dev.D.ctrl = hfcm_dctrl; dch->dev.nrbchan = 2; @@ -4866,14 +4866,14 @@ init_multi_port(struct hfc_multi *hc, int pt) bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL); if (!bch) { printk(KERN_ERR "%s: no memory for bchannel\n", - __func__); + __func__); ret = -ENOMEM; goto free_chan; } hc->chan[i + ch].coeff = kzalloc(512, GFP_KERNEL); if (!hc->chan[i + ch].coeff) { printk(KERN_ERR "%s: no memory for coeffs\n", - __func__); + __func__); ret = -ENOMEM; kfree(bch); goto free_chan; @@ -4895,22 +4895,22 @@ init_multi_port(struct hfc_multi *hc, int pt) if (port[Port_cnt] & 0x001) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PROTOCOL set master clock: " - "card(%d) port(%d)\n", - __func__, HFC_cnt + 1, pt + 1); + "%s: PROTOCOL set master clock: " + "card(%d) port(%d)\n", + __func__, HFC_cnt + 1, pt + 1); if (dch->dev.D.protocol != ISDN_P_TE_S0) { printk(KERN_ERR "Error: Master clock " - "for port(%d) of card(%d) is only" - " possible with TE-mode\n", - pt + 1, HFC_cnt + 1); + "for port(%d) of card(%d) is only" + " possible with TE-mode\n", + pt + 1, HFC_cnt + 1); ret = -EINVAL; goto free_chan; } if (hc->masterclk >= 0) { printk(KERN_ERR "Error: Master clock " - "for port(%d) of card(%d) already " - "defined for port(%d)\n", - pt + 1, HFC_cnt + 1, hc->masterclk+1); + "for port(%d) of card(%d) already " + "defined for port(%d)\n", + pt + 1, HFC_cnt + 1, hc->masterclk + 1); ret = -EINVAL; goto free_chan; } @@ -4920,29 +4920,29 @@ init_multi_port(struct hfc_multi *hc, int pt) if (port[Port_cnt] & 0x002) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PROTOCOL set non capacitive " - "transmitter: card(%d) port(%d)\n", - __func__, HFC_cnt + 1, pt + 1); + "%s: PROTOCOL set non capacitive " + "transmitter: card(%d) port(%d)\n", + __func__, HFC_cnt + 1, pt + 1); test_and_set_bit(HFC_CFG_NONCAP_TX, - &hc->chan[i + 2].cfg); + &hc->chan[i + 2].cfg); } /* disable E-channel */ if (port[Port_cnt] & 0x004) { if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: PROTOCOL disable E-channel: " - "card(%d) port(%d)\n", - __func__, HFC_cnt + 1, pt + 1); + "%s: PROTOCOL disable E-channel: " + "card(%d) port(%d)\n", + __func__, HFC_cnt + 1, pt + 1); test_and_set_bit(HFC_CFG_DIS_ECHANNEL, - &hc->chan[i + 2].cfg); + &hc->chan[i + 2].cfg); } if (hc->ctype == HFC_TYPE_XHFC) { snprintf(name, MISDN_MAX_IDLEN - 1, "xhfc.%d-%d", - HFC_cnt + 1, pt + 1); + HFC_cnt + 1, pt + 1); ret = mISDN_register_device(&dch->dev, NULL, name); } else { snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d-%d", - hc->ctype, HFC_cnt + 1, pt + 1); + hc->ctype, HFC_cnt + 1, pt + 1); ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name); } if (ret) @@ -4956,7 +4956,7 @@ init_multi_port(struct hfc_multi *hc, int pt) static int hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, - const struct pci_device_id *ent) + const struct pci_device_id *ent) { int ret_err = 0; int pt; @@ -4967,22 +4967,22 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, if (HFC_cnt >= MAX_CARDS) { printk(KERN_ERR "too many cards (max=%d).\n", - MAX_CARDS); + MAX_CARDS); return -EINVAL; } if ((type[HFC_cnt] & 0xff) && (type[HFC_cnt] & 0xff) != m->type) { printk(KERN_WARNING "HFC-MULTI: Card '%s:%s' type %d found but " - "type[%d] %d was supplied as module parameter\n", - m->vendor_name, m->card_name, m->type, HFC_cnt, - type[HFC_cnt] & 0xff); + "type[%d] %d was supplied as module parameter\n", + m->vendor_name, m->card_name, m->type, HFC_cnt, + type[HFC_cnt] & 0xff); printk(KERN_WARNING "HFC-MULTI: Load module without parameters " - "first, to see cards and their types."); + "first, to see cards and their types."); return -EINVAL; } if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "%s: Registering %s:%s chip type %d (0x%x)\n", - __func__, m->vendor_name, m->card_name, m->type, - type[HFC_cnt]); + __func__, m->vendor_name, m->card_name, m->type, + type[HFC_cnt]); /* allocate card+fifo structure */ hc = kzalloc(sizeof(struct hfc_multi), GFP_KERNEL); @@ -5000,13 +5000,13 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, if (dslot[HFC_cnt] < 0 && hc->ctype == HFC_TYPE_E1) { hc->dslot = 0; printk(KERN_INFO "HFC-E1 card has disabled D-channel, but " - "31 B-channels\n"); + "31 B-channels\n"); } if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32 && hc->ctype == HFC_TYPE_E1) { hc->dslot = dslot[HFC_cnt]; printk(KERN_INFO "HFC-E1 card has alternating D-channel on " - "time slot %d\n", dslot[HFC_cnt]); + "time slot %d\n", dslot[HFC_cnt]); } else hc->dslot = 16; @@ -5019,7 +5019,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, hc->silence = 0x2a; /* alaw silence */ if ((poll >> 1) > sizeof(hc->silence_data)) { printk(KERN_ERR "HFCMULTI error: silence_data too small, " - "please fix\n"); + "please fix\n"); return -EINVAL; } for (i = 0; i < (poll >> 1); i++) @@ -5086,7 +5086,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, for (pt = 0; pt < hc->ports; pt++) { if (Port_cnt >= MAX_PORTS) { printk(KERN_ERR "too many ports (max=%d).\n", - MAX_PORTS); + MAX_PORTS); ret_err = -EINVAL; goto free_card; } @@ -5096,9 +5096,9 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, ret_err = init_multi_port(hc, pt); if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG - "%s: Registering D-channel, card(%d) port(%d)" - "result %d\n", - __func__, HFC_cnt + 1, pt, ret_err); + "%s: Registering D-channel, card(%d) port(%d)" + "result %d\n", + __func__, HFC_cnt + 1, pt, ret_err); if (ret_err) { while (pt) { /* release already registered ports */ @@ -5129,7 +5129,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, pmj = ~pmj & 0xf; printk(KERN_INFO "%s: %s DIPs(0x%x) jumpers(0x%x)\n", - m->vendor_name, m->card_name, dips, pmj); + m->vendor_name, m->card_name, dips, pmj); break; case DIP_8S: /* @@ -5151,16 +5151,16 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev, /* disable PCI auxbridge function */ HFC_outb(hc, R_BRG_PCM_CFG, V_PCM_CLK); printk(KERN_INFO "%s: %s DIPs(0x%x)\n", - m->vendor_name, m->card_name, dips); + m->vendor_name, m->card_name, dips); break; case DIP_E1: /* * get DIP Setting for beroNet E1 cards * DIP Setting: collect GPI 4/5/6/7 (R_GPI_IN0) */ - dips = (~HFC_inb(hc, R_GPI_IN0) & 0xF0)>>4; + dips = (~HFC_inb(hc, R_GPI_IN0) & 0xF0) >> 4; printk(KERN_INFO "%s: %s DIPs(0x%x)\n", - m->vendor_name, m->card_name, dips); + m->vendor_name, m->card_name, dips); break; } @@ -5203,9 +5203,9 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev) if (debug) printk(KERN_INFO "removing hfc_multi card vendor:%x " - "device:%x subvendor:%x subdevice:%x\n", - pdev->vendor, pdev->device, - pdev->subsystem_vendor, pdev->subsystem_device); + "device:%x subvendor:%x subdevice:%x\n", + pdev->vendor, pdev->device, + pdev->subsystem_vendor, pdev->subsystem_device); if (card) { spin_lock_irqsave(&HFClock, flags); @@ -5214,7 +5214,7 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev) } else { if (debug) printk(KERN_DEBUG "%s: drvdata already removed\n", - __func__); + __func__); } } @@ -5225,50 +5225,50 @@ static void __devexit hfc_remove_pci(struct pci_dev *pdev) #define VENDOR_PRIM "PrimuX" static const struct hm_map hfcm_map[] = { -/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0, 0}, -/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, -/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, -/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, -/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0, 0}, -/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0, 0}, -/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, -/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0, 0}, -/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO, 0}, -/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0, 0}, -/*10*/ {VENDOR_JH, "HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0, 0}, -/*11*/ {VENDOR_PRIM, "HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0, 0}, - -/*12*/ {VENDOR_BN, "HFC-8S Card", 8, 8, 1, 0, 0, 0, 0, 0}, -/*13*/ {VENDOR_BN, "HFC-8S Card (+)", 8, 8, 1, 8, 0, DIP_8S, - HFC_IO_MODE_REGIO, 0}, -/*14*/ {VENDOR_CCD, "HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0, 0}, -/*15*/ {VENDOR_CCD, "HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0, 0}, - -/*16*/ {VENDOR_CCD, "HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0, 0}, -/*17*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0}, -/*18*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0}, - -/*19*/ {VENDOR_BN, "HFC-E1 Card", 1, 1, 0, 1, 0, DIP_E1, 0, 0}, -/*20*/ {VENDOR_BN, "HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0, 0}, -/*21*/ {VENDOR_BN, "HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0}, -/*22*/ {VENDOR_BN, "HFC-E1 Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0}, - -/*23*/ {VENDOR_CCD, "HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0, 0}, -/*24*/ {VENDOR_CCD, "HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0, 0}, -/*25*/ {VENDOR_CCD, "HFC-E1", 1, 1, 0, 1, 0, 0, 0, 0}, - -/*26*/ {VENDOR_CCD, "HFC-4S Speech Design", 4, 4, 0, 0, 0, 0, - HFC_IO_MODE_PLXSD, 0}, -/*27*/ {VENDOR_CCD, "HFC-E1 Speech Design", 1, 1, 0, 0, 0, 0, - HFC_IO_MODE_PLXSD, 0}, -/*28*/ {VENDOR_CCD, "HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0, 0}, -/*29*/ {VENDOR_CCD, "HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0, 0}, -/*30*/ {VENDOR_CCD, "HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0, 0}, -/*31*/ {VENDOR_CCD, "XHFC-4S Speech Design", 5, 4, 0, 0, 0, 0, - HFC_IO_MODE_EMBSD, XHFC_IRQ}, -/*32*/ {VENDOR_JH, "HFC-8S (junghanns)", 8, 8, 1, 0, 0, 0, 0, 0}, -/*33*/ {VENDOR_BN, "HFC-2S Beronet Card PCIe", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, -/*34*/ {VENDOR_BN, "HFC-4S Beronet Card PCIe", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, + /*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0, 0}, + /*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, + /*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, + /*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, + /*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0, 0}, + /*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0, 0}, + /*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, + /*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0, 0}, + /*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO, 0}, + /*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0, 0}, + /*10*/ {VENDOR_JH, "HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0, 0}, + /*11*/ {VENDOR_PRIM, "HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0, 0}, + + /*12*/ {VENDOR_BN, "HFC-8S Card", 8, 8, 1, 0, 0, 0, 0, 0}, + /*13*/ {VENDOR_BN, "HFC-8S Card (+)", 8, 8, 1, 8, 0, DIP_8S, + HFC_IO_MODE_REGIO, 0}, + /*14*/ {VENDOR_CCD, "HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0, 0}, + /*15*/ {VENDOR_CCD, "HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0, 0}, + + /*16*/ {VENDOR_CCD, "HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0, 0}, + /*17*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0}, + /*18*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0, 0}, + + /*19*/ {VENDOR_BN, "HFC-E1 Card", 1, 1, 0, 1, 0, DIP_E1, 0, 0}, + /*20*/ {VENDOR_BN, "HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0, 0}, + /*21*/ {VENDOR_BN, "HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0}, + /*22*/ {VENDOR_BN, "HFC-E1 Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0, 0}, + + /*23*/ {VENDOR_CCD, "HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0, 0}, + /*24*/ {VENDOR_CCD, "HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0, 0}, + /*25*/ {VENDOR_CCD, "HFC-E1", 1, 1, 0, 1, 0, 0, 0, 0}, + + /*26*/ {VENDOR_CCD, "HFC-4S Speech Design", 4, 4, 0, 0, 0, 0, + HFC_IO_MODE_PLXSD, 0}, + /*27*/ {VENDOR_CCD, "HFC-E1 Speech Design", 1, 1, 0, 0, 0, 0, + HFC_IO_MODE_PLXSD, 0}, + /*28*/ {VENDOR_CCD, "HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0, 0}, + /*29*/ {VENDOR_CCD, "HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0, 0}, + /*30*/ {VENDOR_CCD, "HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0, 0}, + /*31*/ {VENDOR_CCD, "XHFC-4S Speech Design", 5, 4, 0, 0, 0, 0, + HFC_IO_MODE_EMBSD, XHFC_IRQ}, + /*32*/ {VENDOR_JH, "HFC-8S (junghanns)", 8, 8, 1, 0, 0, 0, 0, 0}, + /*33*/ {VENDOR_BN, "HFC-2S Beronet Card PCIe", 4, 2, 1, 3, 0, DIP_4S, 0, 0}, + /*34*/ {VENDOR_BN, "HFC-4S Beronet Card PCIe", 4, 4, 1, 2, 0, DIP_4S, 0, 0}, }; #undef H @@ -5277,83 +5277,83 @@ static struct pci_device_id hfmultipci_ids[] __devinitdata = { /* Cards with HFC-4S Chip */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN1SM, 0, 0, H(0)}, /* BN1S mini PCI */ + PCI_SUBDEVICE_ID_CCD_BN1SM, 0, 0, H(0)}, /* BN1S mini PCI */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN2S, 0, 0, H(1)}, /* BN2S */ + PCI_SUBDEVICE_ID_CCD_BN2S, 0, 0, H(1)}, /* BN2S */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN2SM, 0, 0, H(2)}, /* BN2S mini PCI */ + PCI_SUBDEVICE_ID_CCD_BN2SM, 0, 0, H(2)}, /* BN2S mini PCI */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN4S, 0, 0, H(3)}, /* BN4S */ + PCI_SUBDEVICE_ID_CCD_BN4S, 0, 0, H(3)}, /* BN4S */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN4SM, 0, 0, H(4)}, /* BN4S mini PCI */ + PCI_SUBDEVICE_ID_CCD_BN4SM, 0, 0, H(4)}, /* BN4S mini PCI */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_DEVICE_ID_CCD_HFC4S, 0, 0, H(5)}, /* Old Eval */ + PCI_DEVICE_ID_CCD_HFC4S, 0, 0, H(5)}, /* Old Eval */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_IOB4ST, 0, 0, H(6)}, /* IOB4ST */ + PCI_SUBDEVICE_ID_CCD_IOB4ST, 0, 0, H(6)}, /* IOB4ST */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_HFC4S, 0, 0, H(7)}, /* 4S */ + PCI_SUBDEVICE_ID_CCD_HFC4S, 0, 0, H(7)}, /* 4S */ { PCI_VENDOR_ID_DIGIUM, PCI_DEVICE_ID_DIGIUM_HFC4S, - PCI_VENDOR_ID_DIGIUM, PCI_DEVICE_ID_DIGIUM_HFC4S, 0, 0, H(8)}, + PCI_VENDOR_ID_DIGIUM, PCI_DEVICE_ID_DIGIUM_HFC4S, 0, 0, H(8)}, { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_SWYX4S, 0, 0, H(9)}, /* 4S Swyx */ + PCI_SUBDEVICE_ID_CCD_SWYX4S, 0, 0, H(9)}, /* 4S Swyx */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_JH4S20, 0, 0, H(10)}, + PCI_SUBDEVICE_ID_CCD_JH4S20, 0, 0, H(10)}, { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_PMX2S, 0, 0, H(11)}, /* Primux */ + PCI_SUBDEVICE_ID_CCD_PMX2S, 0, 0, H(11)}, /* Primux */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_OV4S, 0, 0, H(28)}, /* OpenVox 4 */ + PCI_SUBDEVICE_ID_CCD_OV4S, 0, 0, H(28)}, /* OpenVox 4 */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_OV2S, 0, 0, H(29)}, /* OpenVox 2 */ + PCI_SUBDEVICE_ID_CCD_OV2S, 0, 0, H(29)}, /* OpenVox 2 */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - 0xb761, 0, 0, H(33)}, /* BN2S PCIe */ + 0xb761, 0, 0, H(33)}, /* BN2S PCIe */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, - 0xb762, 0, 0, H(34)}, /* BN4S PCIe */ + 0xb762, 0, 0, H(34)}, /* BN4S PCIe */ /* Cards with HFC-8S Chip */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN8S, 0, 0, H(12)}, /* BN8S */ + PCI_SUBDEVICE_ID_CCD_BN8S, 0, 0, H(12)}, /* BN8S */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BN8SP, 0, 0, H(13)}, /* BN8S+ */ + PCI_SUBDEVICE_ID_CCD_BN8SP, 0, 0, H(13)}, /* BN8S+ */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_DEVICE_ID_CCD_HFC8S, 0, 0, H(14)}, /* old Eval */ + PCI_DEVICE_ID_CCD_HFC8S, 0, 0, H(14)}, /* old Eval */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)}, /* IOB8ST Recording */ + PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)}, /* IOB8ST Recording */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_IOB8ST, 0, 0, H(16)}, /* IOB8ST */ + PCI_SUBDEVICE_ID_CCD_IOB8ST, 0, 0, H(16)}, /* IOB8ST */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_IOB8ST_1, 0, 0, H(17)}, /* IOB8ST */ + PCI_SUBDEVICE_ID_CCD_IOB8ST_1, 0, 0, H(17)}, /* IOB8ST */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_HFC8S, 0, 0, H(18)}, /* 8S */ + PCI_SUBDEVICE_ID_CCD_HFC8S, 0, 0, H(18)}, /* 8S */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_OV8S, 0, 0, H(30)}, /* OpenVox 8 */ + PCI_SUBDEVICE_ID_CCD_OV8S, 0, 0, H(30)}, /* OpenVox 8 */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_JH8S, 0, 0, H(32)}, /* Junganns 8S */ + PCI_SUBDEVICE_ID_CCD_JH8S, 0, 0, H(32)}, /* Junganns 8S */ /* Cards with HFC-E1 Chip */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BNE1, 0, 0, H(19)}, /* BNE1 */ + PCI_SUBDEVICE_ID_CCD_BNE1, 0, 0, H(19)}, /* BNE1 */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BNE1M, 0, 0, H(20)}, /* BNE1 mini PCI */ + PCI_SUBDEVICE_ID_CCD_BNE1M, 0, 0, H(20)}, /* BNE1 mini PCI */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BNE1DP, 0, 0, H(21)}, /* BNE1 + (Dual) */ + PCI_SUBDEVICE_ID_CCD_BNE1DP, 0, 0, H(21)}, /* BNE1 + (Dual) */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_BNE1D, 0, 0, H(22)}, /* BNE1 (Dual) */ + PCI_SUBDEVICE_ID_CCD_BNE1D, 0, 0, H(22)}, /* BNE1 (Dual) */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_DEVICE_ID_CCD_HFCE1, 0, 0, H(23)}, /* Old Eval */ + PCI_DEVICE_ID_CCD_HFCE1, 0, 0, H(23)}, /* Old Eval */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_IOB1E1, 0, 0, H(24)}, /* IOB1E1 */ + PCI_SUBDEVICE_ID_CCD_IOB1E1, 0, 0, H(24)}, /* IOB1E1 */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_HFCE1, 0, 0, H(25)}, /* E1 */ + PCI_SUBDEVICE_ID_CCD_HFCE1, 0, 0, H(25)}, /* E1 */ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_SPD4S, 0, 0, H(26)}, /* PLX PCI Bridge */ + PCI_SUBDEVICE_ID_CCD_SPD4S, 0, 0, H(26)}, /* PLX PCI Bridge */ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_SPDE1, 0, 0, H(27)}, /* PLX PCI Bridge */ + PCI_SUBDEVICE_ID_CCD_SPDE1, 0, 0, H(27)}, /* PLX PCI Bridge */ { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD, - PCI_SUBDEVICE_ID_CCD_JHSE1, 0, 0, H(25)}, /* Junghanns E1 */ + PCI_SUBDEVICE_ID_CCD_JHSE1, 0, 0, H(25)}, /* Junghanns E1 */ { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_HFC4S), 0 }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_HFC8S), 0 }, @@ -5371,16 +5371,16 @@ hfcmulti_probe(struct pci_dev *pdev, const struct pci_device_id *ent) int ret; if (m == NULL && ent->vendor == PCI_VENDOR_ID_CCD && ( - ent->device == PCI_DEVICE_ID_CCD_HFC4S || - ent->device == PCI_DEVICE_ID_CCD_HFC8S || - ent->device == PCI_DEVICE_ID_CCD_HFCE1)) { + ent->device == PCI_DEVICE_ID_CCD_HFC4S || + ent->device == PCI_DEVICE_ID_CCD_HFC8S || + ent->device == PCI_DEVICE_ID_CCD_HFCE1)) { printk(KERN_ERR - "Unknown HFC multiport controller (vendor:%04x device:%04x " - "subvendor:%04x subdevice:%04x)\n", pdev->vendor, - pdev->device, pdev->subsystem_vendor, - pdev->subsystem_device); + "Unknown HFC multiport controller (vendor:%04x device:%04x " + "subvendor:%04x subdevice:%04x)\n", pdev->vendor, + pdev->device, pdev->subsystem_vendor, + pdev->subsystem_device); printk(KERN_ERR - "Please contact the driver maintainer for support.\n"); + "Please contact the driver maintainer for support.\n"); return -ENODEV; } ret = hfcmulti_init(m, pdev, ent); @@ -5453,7 +5453,7 @@ HFCmulti_init(void) break; default: printk(KERN_ERR - "%s: Wrong poll value (%d).\n", __func__, poll); + "%s: Wrong poll value (%d).\n", __func__, poll); err = -EINVAL; return err; @@ -5485,7 +5485,7 @@ HFCmulti_init(void) err = hfcmulti_init(&m, NULL, NULL); if (err) { printk(KERN_ERR "error registering embedded driver: " - "%x\n", err); + "%x\n", err); return err; } HFC_cnt++; diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c index 3261de18a91e..d055ae7fa040 100644 --- a/drivers/isdn/hardware/mISDN/hfcpci.c +++ b/drivers/isdn/hardware/mISDN/hfcpci.c @@ -109,11 +109,11 @@ struct hfcPCI_hw { unsigned char bswapped; unsigned char protocol; int nt_timer; - unsigned char __iomem *pci_io; /* start of PCI IO memory */ + unsigned char __iomem *pci_io; /* start of PCI IO memory */ dma_addr_t dmahandle; void *fifos; /* FIFO memory */ int last_bfifo_cnt[2]; - /* marker saving last b-fifo frame count */ + /* marker saving last b-fifo frame count */ struct timer_list timer; }; @@ -216,7 +216,7 @@ reset_hfcpci(struct hfc_pci *hc) disable_hwirq(hc); /* enable memory ports + busmaster */ pci_write_config_word(hc->pdev, PCI_COMMAND, - PCI_ENA_MEMIO + PCI_ENA_MASTER); + PCI_ENA_MEMIO + PCI_ENA_MASTER); val = Read_hfc(hc, HFCPCI_STATUS); printk(KERN_DEBUG "HFC-PCI status(%x) before reset\n", val); hc->hw.cirm = HFCPCI_RESET; /* Reset On */ @@ -255,7 +255,7 @@ reset_hfcpci(struct hfc_pci *hc) Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt); hc->hw.int_m1 = HFCPCI_INTS_DTRANS | HFCPCI_INTS_DREC | - HFCPCI_INTS_L1STATE | HFCPCI_INTS_TIMER; + HFCPCI_INTS_L1STATE | HFCPCI_INTS_TIMER; Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1); /* Clear already pending ints */ @@ -319,10 +319,10 @@ static struct bchannel * Sel_BCS(struct hfc_pci *hc, int channel) { if (test_bit(FLG_ACTIVE, &hc->bch[0].Flags) && - (hc->bch[0].nr & channel)) + (hc->bch[0].nr & channel)) return &hc->bch[0]; else if (test_bit(FLG_ACTIVE, &hc->bch[1].Flags) && - (hc->bch[1].nr & channel)) + (hc->bch[1].nr & channel)) return &hc->bch[1]; else return NULL; @@ -352,7 +352,7 @@ hfcpci_clear_fifo_rx(struct hfc_pci *hc, int fifo) bzr->f2 = bzr->f1; /* init F pointers to remain constant */ bzr->za[MAX_B_FRAMES].z1 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 1); bzr->za[MAX_B_FRAMES].z2 = cpu_to_le16( - le16_to_cpu(bzr->za[MAX_B_FRAMES].z1)); + le16_to_cpu(bzr->za[MAX_B_FRAMES].z1)); if (fifo_state) hc->hw.fifo_en |= fifo_state; Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en); @@ -378,11 +378,11 @@ static void hfcpci_clear_fifo_tx(struct hfc_pci *hc, int fifo) Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en); if (hc->bch[fifo].debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG "hfcpci_clear_fifo_tx%d f1(%x) f2(%x) " - "z1(%x) z2(%x) state(%x)\n", - fifo, bzt->f1, bzt->f2, - le16_to_cpu(bzt->za[MAX_B_FRAMES].z1), - le16_to_cpu(bzt->za[MAX_B_FRAMES].z2), - fifo_state); + "z1(%x) z2(%x) state(%x)\n", + fifo, bzt->f1, bzt->f2, + le16_to_cpu(bzt->za[MAX_B_FRAMES].z1), + le16_to_cpu(bzt->za[MAX_B_FRAMES].z2), + fifo_state); bzt->f2 = MAX_B_FRAMES; bzt->f1 = bzt->f2; /* init F pointers to remain constant */ bzt->za[MAX_B_FRAMES].z1 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 1); @@ -392,10 +392,10 @@ static void hfcpci_clear_fifo_tx(struct hfc_pci *hc, int fifo) Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en); if (hc->bch[fifo].debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG - "hfcpci_clear_fifo_tx%d f1(%x) f2(%x) z1(%x) z2(%x)\n", - fifo, bzt->f1, bzt->f2, - le16_to_cpu(bzt->za[MAX_B_FRAMES].z1), - le16_to_cpu(bzt->za[MAX_B_FRAMES].z2)); + "hfcpci_clear_fifo_tx%d f1(%x) f2(%x) z1(%x) z2(%x)\n", + fifo, bzt->f1, bzt->f2, + le16_to_cpu(bzt->za[MAX_B_FRAMES].z1), + le16_to_cpu(bzt->za[MAX_B_FRAMES].z2)); } /* @@ -403,7 +403,7 @@ static void hfcpci_clear_fifo_tx(struct hfc_pci *hc, int fifo) */ static void hfcpci_empty_bfifo(struct bchannel *bch, struct bzfifo *bz, - u_char *bdata, int count) + u_char *bdata, int count) { u_char *ptr, *ptr1, new_f2; int maxlen, new_z2; @@ -420,7 +420,7 @@ hfcpci_empty_bfifo(struct bchannel *bch, struct bzfifo *bz, (*(bdata + (le16_to_cpu(zp->z1) - B_SUB_VAL)))) { if (bch->debug & DEBUG_HW) printk(KERN_DEBUG "hfcpci_empty_fifo: incoming packet " - "invalid length %d or crc\n", count); + "invalid length %d or crc\n", count); #ifdef ERROR_STATISTIC bch->err_inv++; #endif @@ -439,10 +439,10 @@ hfcpci_empty_bfifo(struct bchannel *bch, struct bzfifo *bz, maxlen = count; /* complete transfer */ else maxlen = B_FIFO_SIZE + B_SUB_VAL - - le16_to_cpu(zp->z2); /* maximum */ + le16_to_cpu(zp->z2); /* maximum */ ptr1 = bdata + (le16_to_cpu(zp->z2) - B_SUB_VAL); - /* start of data */ + /* start of data */ memcpy(ptr, ptr1, maxlen); /* copy data */ count -= maxlen; @@ -480,33 +480,33 @@ receive_dmsg(struct hfc_pci *hc) rcnt++; if (dch->debug & DEBUG_HW_DCHANNEL) printk(KERN_DEBUG - "hfcpci recd f1(%d) f2(%d) z1(%x) z2(%x) cnt(%d)\n", - df->f1, df->f2, - le16_to_cpu(zp->z1), - le16_to_cpu(zp->z2), - rcnt); + "hfcpci recd f1(%d) f2(%d) z1(%x) z2(%x) cnt(%d)\n", + df->f1, df->f2, + le16_to_cpu(zp->z1), + le16_to_cpu(zp->z2), + rcnt); if ((rcnt > MAX_DFRAME_LEN + 3) || (rcnt < 4) || (df->data[le16_to_cpu(zp->z1)])) { if (dch->debug & DEBUG_HW) printk(KERN_DEBUG - "empty_fifo hfcpci paket inv. len " - "%d or crc %d\n", - rcnt, - df->data[le16_to_cpu(zp->z1)]); + "empty_fifo hfcpci paket inv. len " + "%d or crc %d\n", + rcnt, + df->data[le16_to_cpu(zp->z1)]); #ifdef ERROR_STATISTIC cs->err_rx++; #endif df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) | - (MAX_D_FRAMES + 1); /* next buffer */ + (MAX_D_FRAMES + 1); /* next buffer */ df->za[df->f2 & D_FREG_MASK].z2 = - cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) & - (D_FIFO_SIZE - 1)); + cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) & + (D_FIFO_SIZE - 1)); } else { dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC); if (!dch->rx_skb) { printk(KERN_WARNING - "HFC-PCI: D receive out of memory\n"); + "HFC-PCI: D receive out of memory\n"); break; } total = rcnt; @@ -517,10 +517,10 @@ receive_dmsg(struct hfc_pci *hc) maxlen = rcnt; /* complete transfer */ else maxlen = D_FIFO_SIZE - le16_to_cpu(zp->z2); - /* maximum */ + /* maximum */ ptr1 = df->data + le16_to_cpu(zp->z2); - /* start of data */ + /* start of data */ memcpy(ptr, ptr1, maxlen); /* copy data */ rcnt -= maxlen; @@ -530,9 +530,9 @@ receive_dmsg(struct hfc_pci *hc) memcpy(ptr, ptr1, rcnt); /* rest */ } df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) | - (MAX_D_FRAMES + 1); /* next buffer */ + (MAX_D_FRAMES + 1); /* next buffer */ df->za[df->f2 & D_FREG_MASK].z2 = cpu_to_le16(( - le16_to_cpu(zp->z2) + total) & (D_FIFO_SIZE - 1)); + le16_to_cpu(zp->z2) + total) & (D_FIFO_SIZE - 1)); recv_Dchannel(dch); } } @@ -544,9 +544,9 @@ receive_dmsg(struct hfc_pci *hc) */ static void hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *rxbz, - struct bzfifo *txbz, u_char *bdata) + struct bzfifo *txbz, u_char *bdata) { - __le16 *z1r, *z2r, *z1t, *z2t; + __le16 *z1r, *z2r, *z1t, *z2t; int new_z2, fcnt_rx, fcnt_tx, maxlen; u_char *ptr, *ptr1; @@ -573,9 +573,9 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *rxbz, fcnt_tx = le16_to_cpu(*z2t) - le16_to_cpu(*z1t); if (fcnt_tx <= 0) fcnt_tx += B_FIFO_SIZE; - /* fcnt_tx contains available bytes in tx-fifo */ + /* fcnt_tx contains available bytes in tx-fifo */ fcnt_tx = B_FIFO_SIZE - fcnt_tx; - /* remaining bytes to send (bytes in tx-fifo) */ + /* remaining bytes to send (bytes in tx-fifo) */ bch->rx_skb = mI_alloc_skb(fcnt_rx, GFP_ATOMIC); if (bch->rx_skb) { @@ -584,10 +584,10 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *rxbz, maxlen = fcnt_rx; /* complete transfer */ else maxlen = B_FIFO_SIZE + B_SUB_VAL - le16_to_cpu(*z2r); - /* maximum */ + /* maximum */ ptr1 = bdata + (le16_to_cpu(*z2r) - B_SUB_VAL); - /* start of data */ + /* start of data */ memcpy(ptr, ptr1, maxlen); /* copy data */ fcnt_rx -= maxlen; @@ -632,7 +632,7 @@ main_rec_hfcpci(struct bchannel *bch) if (rxbz->f1 != rxbz->f2) { if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG "hfcpci rec ch(%x) f1(%d) f2(%d)\n", - bch->nr, rxbz->f1, rxbz->f2); + bch->nr, rxbz->f1, rxbz->f2); zp = &rxbz->za[rxbz->f2]; rcnt = le16_to_cpu(zp->z1) - le16_to_cpu(zp->z2); @@ -641,9 +641,9 @@ main_rec_hfcpci(struct bchannel *bch) rcnt++; if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG - "hfcpci rec ch(%x) z1(%x) z2(%x) cnt(%d)\n", - bch->nr, le16_to_cpu(zp->z1), - le16_to_cpu(zp->z2), rcnt); + "hfcpci rec ch(%x) z1(%x) z2(%x) cnt(%d)\n", + bch->nr, le16_to_cpu(zp->z1), + le16_to_cpu(zp->z2), rcnt); hfcpci_empty_bfifo(bch, rxbz, bdata, rcnt); rcnt = rxbz->f1 - rxbz->f2; if (rcnt < 0) @@ -691,15 +691,15 @@ hfcpci_fill_dfifo(struct hfc_pci *hc) if (dch->debug & DEBUG_HW_DFIFO) printk(KERN_DEBUG "%s:f1(%d) f2(%d) z1(f1)(%x)\n", __func__, - df->f1, df->f2, - le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1)); + df->f1, df->f2, + le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1)); fcnt = df->f1 - df->f2; /* frame count actually buffered */ if (fcnt < 0) fcnt += (MAX_D_FRAMES + 1); /* if wrap around */ if (fcnt > (MAX_D_FRAMES - 1)) { if (dch->debug & DEBUG_HW_DCHANNEL) printk(KERN_DEBUG - "hfcpci_fill_Dfifo more as 14 frames\n"); + "hfcpci_fill_Dfifo more as 14 frames\n"); #ifdef ERROR_STATISTIC cs->err_tx++; #endif @@ -707,25 +707,25 @@ hfcpci_fill_dfifo(struct hfc_pci *hc) } /* now determine free bytes in FIFO buffer */ maxlen = le16_to_cpu(df->za[df->f2 & D_FREG_MASK].z2) - - le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1) - 1; + le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1) - 1; if (maxlen <= 0) maxlen += D_FIFO_SIZE; /* count now contains available bytes */ if (dch->debug & DEBUG_HW_DCHANNEL) printk(KERN_DEBUG "hfcpci_fill_Dfifo count(%d/%d)\n", - count, maxlen); + count, maxlen); if (count > maxlen) { if (dch->debug & DEBUG_HW_DCHANNEL) printk(KERN_DEBUG "hfcpci_fill_Dfifo no fifo mem\n"); return; } new_z1 = (le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1) + count) & - (D_FIFO_SIZE - 1); + (D_FIFO_SIZE - 1); new_f1 = ((df->f1 + 1) & D_FREG_MASK) | (D_FREG_MASK + 1); src = dch->tx_skb->data + dch->tx_idx; /* source pointer */ dst = df->data + le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1); maxlen = D_FIFO_SIZE - le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1); - /* end fifo */ + /* end fifo */ if (maxlen > count) maxlen = count; /* limit size */ memcpy(dst, src, maxlen); /* first copy */ @@ -737,9 +737,9 @@ hfcpci_fill_dfifo(struct hfc_pci *hc) memcpy(dst, src, count); } df->za[new_f1 & D_FREG_MASK].z1 = cpu_to_le16(new_z1); - /* for next buffer */ + /* for next buffer */ df->za[df->f1 & D_FREG_MASK].z1 = cpu_to_le16(new_z1); - /* new pos actual buffer */ + /* new pos actual buffer */ df->f1 = new_f1; /* next frame */ dch->tx_idx = dch->tx_skb->len; } @@ -750,7 +750,7 @@ hfcpci_fill_dfifo(struct hfc_pci *hc) static void hfcpci_fill_fifo(struct bchannel *bch) { - struct hfc_pci *hc = bch->hw; + struct hfc_pci *hc = bch->hw; int maxlen, fcnt; int count, new_z1; struct bzfifo *bz; @@ -776,35 +776,35 @@ hfcpci_fill_fifo(struct bchannel *bch) z2t = z1t + 1; if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG "hfcpci_fill_fifo_trans ch(%x) " - "cnt(%d) z1(%x) z2(%x)\n", bch->nr, count, - le16_to_cpu(*z1t), le16_to_cpu(*z2t)); + "cnt(%d) z1(%x) z2(%x)\n", bch->nr, count, + le16_to_cpu(*z1t), le16_to_cpu(*z2t)); fcnt = le16_to_cpu(*z2t) - le16_to_cpu(*z1t); if (fcnt <= 0) fcnt += B_FIFO_SIZE; - /* fcnt contains available bytes in fifo */ + /* fcnt contains available bytes in fifo */ fcnt = B_FIFO_SIZE - fcnt; - /* remaining bytes to send (bytes in fifo) */ + /* remaining bytes to send (bytes in fifo) */ /* "fill fifo if empty" feature */ if (test_bit(FLG_FILLEMPTY, &bch->Flags) && !fcnt) { /* printk(KERN_DEBUG "%s: buffer empty, so we have " - "underrun\n", __func__); */ + "underrun\n", __func__); */ /* fill buffer, to prevent future underrun */ count = HFCPCI_FILLEMPTY; new_z1 = le16_to_cpu(*z1t) + count; - /* new buffer Position */ + /* new buffer Position */ if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL)) new_z1 -= B_FIFO_SIZE; /* buffer wrap */ dst = bdata + (le16_to_cpu(*z1t) - B_SUB_VAL); maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(*z1t); - /* end of fifo */ + /* end of fifo */ if (bch->debug & DEBUG_HW_BFIFO) printk(KERN_DEBUG "hfcpci_FFt fillempty " - "fcnt(%d) maxl(%d) nz1(%x) dst(%p)\n", - fcnt, maxlen, new_z1, dst); + "fcnt(%d) maxl(%d) nz1(%x) dst(%p)\n", + fcnt, maxlen, new_z1, dst); fcnt += count; if (maxlen > count) - maxlen = count; /* limit size */ + maxlen = count; /* limit size */ memset(dst, 0x2a, maxlen); /* first copy */ count -= maxlen; /* remaining bytes */ if (count) { @@ -814,7 +814,7 @@ hfcpci_fill_fifo(struct bchannel *bch) *z1t = cpu_to_le16(new_z1); /* now send data */ } -next_t_frame: + next_t_frame: count = bch->tx_skb->len - bch->tx_idx; /* maximum fill shall be poll*2 */ if (count > (poll << 1) - fcnt) @@ -823,18 +823,18 @@ hfcpci_fill_fifo(struct bchannel *bch) return; /* data is suitable for fifo */ new_z1 = le16_to_cpu(*z1t) + count; - /* new buffer Position */ + /* new buffer Position */ if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL)) new_z1 -= B_FIFO_SIZE; /* buffer wrap */ src = bch->tx_skb->data + bch->tx_idx; - /* source pointer */ + /* source pointer */ dst = bdata + (le16_to_cpu(*z1t) - B_SUB_VAL); maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(*z1t); - /* end of fifo */ + /* end of fifo */ if (bch->debug & DEBUG_HW_BFIFO) printk(KERN_DEBUG "hfcpci_FFt fcnt(%d) " - "maxl(%d) nz1(%x) dst(%p)\n", - fcnt, maxlen, new_z1, dst); + "maxl(%d) nz1(%x) dst(%p)\n", + fcnt, maxlen, new_z1, dst); fcnt += count; bch->tx_idx += count; if (maxlen > count) @@ -859,27 +859,27 @@ hfcpci_fill_fifo(struct bchannel *bch) } if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG - "%s: ch(%x) f1(%d) f2(%d) z1(f1)(%x)\n", - __func__, bch->nr, bz->f1, bz->f2, - bz->za[bz->f1].z1); + "%s: ch(%x) f1(%d) f2(%d) z1(f1)(%x)\n", + __func__, bch->nr, bz->f1, bz->f2, + bz->za[bz->f1].z1); fcnt = bz->f1 - bz->f2; /* frame count actually buffered */ if (fcnt < 0) fcnt += (MAX_B_FRAMES + 1); /* if wrap around */ if (fcnt > (MAX_B_FRAMES - 1)) { if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG - "hfcpci_fill_Bfifo more as 14 frames\n"); + "hfcpci_fill_Bfifo more as 14 frames\n"); return; } /* now determine free bytes in FIFO buffer */ maxlen = le16_to_cpu(bz->za[bz->f2].z2) - - le16_to_cpu(bz->za[bz->f1].z1) - 1; + le16_to_cpu(bz->za[bz->f1].z1) - 1; if (maxlen <= 0) maxlen += B_FIFO_SIZE; /* count now contains available bytes */ if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG "hfcpci_fill_fifo ch(%x) count(%d/%d)\n", - bch->nr, count, maxlen); + bch->nr, count, maxlen); if (maxlen < count) { if (bch->debug & DEBUG_HW_BCHANNEL) @@ -887,7 +887,7 @@ hfcpci_fill_fifo(struct bchannel *bch) return; } new_z1 = le16_to_cpu(bz->za[bz->f1].z1) + count; - /* new buffer Position */ + /* new buffer Position */ if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL)) new_z1 -= B_FIFO_SIZE; /* buffer wrap */ @@ -895,7 +895,7 @@ hfcpci_fill_fifo(struct bchannel *bch) src = bch->tx_skb->data + bch->tx_idx; /* source pointer */ dst = bdata + (le16_to_cpu(bz->za[bz->f1].z1) - B_SUB_VAL); maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(bz->za[bz->f1].z1); - /* end fifo */ + /* end fifo */ if (maxlen > count) maxlen = count; /* limit size */ memcpy(dst, src, maxlen); /* first copy */ @@ -923,7 +923,7 @@ ph_state_te(struct dchannel *dch) { if (dch->debug) printk(KERN_DEBUG "%s: TE newstate %x\n", - __func__, dch->state); + __func__, dch->state); switch (dch->state) { case 0: l1_event(dch->l1, HW_RESET_IND); @@ -961,7 +961,7 @@ handle_nt_timer3(struct dchannel *dch) { hc->hw.mst_m |= HFCPCI_MASTER; Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m); _queue_data(&dch->dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); } static void @@ -971,7 +971,7 @@ ph_state_nt(struct dchannel *dch) if (dch->debug) printk(KERN_DEBUG "%s: NT newstate %x\n", - __func__, dch->state); + __func__, dch->state); switch (dch->state) { case 2: if (hc->hw.nt_timer < 0) { @@ -993,7 +993,7 @@ ph_state_nt(struct dchannel *dch) hc->hw.ctmt &= ~HFCPCI_AUTO_TIMER; hc->hw.ctmt |= HFCPCI_TIM3_125; Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt | - HFCPCI_CLTIMER); + HFCPCI_CLTIMER); test_and_clear_bit(FLG_HFC_TIMER_T3, &dch->Flags); test_and_set_bit(FLG_HFC_TIMER_T1, &dch->Flags); /* allow G2 -> G3 transition */ @@ -1013,7 +1013,7 @@ ph_state_nt(struct dchannel *dch) Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m); test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags); _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); break; case 4: hc->hw.nt_timer = 0; @@ -1025,7 +1025,7 @@ ph_state_nt(struct dchannel *dch) case 3: if (!test_and_set_bit(FLG_HFC_TIMER_T3, &dch->Flags)) { if (!test_and_clear_bit(FLG_L2_ACTIVATED, - &dch->Flags)) { + &dch->Flags)) { handle_nt_timer3(dch); break; } @@ -1036,7 +1036,7 @@ ph_state_nt(struct dchannel *dch) hc->hw.ctmt &= ~HFCPCI_AUTO_TIMER; hc->hw.ctmt |= HFCPCI_TIM3_125; Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt | - HFCPCI_CLTIMER); + HFCPCI_CLTIMER); } break; } @@ -1081,7 +1081,7 @@ hfc_l1callback(struct dchannel *dch, u_int cmd) hc->hw.mst_m |= HFCPCI_MASTER; Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m); Write_hfc(hc, HFCPCI_STATES, HFCPCI_ACTIVATE | - HFCPCI_DO_ACTION); + HFCPCI_DO_ACTION); l1_event(dch->l1, HW_POWERUP_IND); break; case HW_DEACT_REQ: @@ -1107,17 +1107,17 @@ hfc_l1callback(struct dchannel *dch, u_int cmd) case PH_ACTIVATE_IND: test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; case PH_DEACTIVATE_IND: test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: unknown command %x\n", - __func__, cmd); + __func__, cmd); return -1; } return 0; @@ -1170,7 +1170,7 @@ hfcpci_int(int intno, void *dev_id) val = Read_hfc(hc, HFCPCI_INT_S1); if (hc->dch.debug & DEBUG_HW_DCHANNEL) printk(KERN_DEBUG - "HFC-PCI: stat(%02x) s1(%02x)\n", stat, val); + "HFC-PCI: stat(%02x) s1(%02x)\n", stat, val); } else { /* shared */ spin_unlock(&hc->lock); @@ -1185,7 +1185,7 @@ hfcpci_int(int intno, void *dev_id) exval = Read_hfc(hc, HFCPCI_STATES) & 0xf; if (hc->dch.debug & DEBUG_HW_DCHANNEL) printk(KERN_DEBUG "ph_state chg %d->%d\n", - hc->dch.state, exval); + hc->dch.state, exval); hc->dch.state = exval; schedule_event(&hc->dch, FLG_PHCHANGE); val &= ~0x40; @@ -1198,7 +1198,7 @@ hfcpci_int(int intno, void *dev_id) val &= ~0x80; Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt | HFCPCI_CLTIMER); } - if (val & 0x08) { /* B1 rx */ + if (val & 0x08) { /* B1 rx */ bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1); if (bch) main_rec_hfcpci(bch); @@ -1257,22 +1257,22 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol) if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG - "HFCPCI bchannel protocol %x-->%x ch %x-->%x\n", - bch->state, protocol, bch->nr, bc); + "HFCPCI bchannel protocol %x-->%x ch %x-->%x\n", + bch->state, protocol, bch->nr, bc); fifo2 = bc; - pcm_mode = (bc>>24) & 0xff; + pcm_mode = (bc >> 24) & 0xff; if (pcm_mode) { /* PCM SLOT USE */ if (!test_bit(HFC_CFG_PCM, &hc->cfg)) printk(KERN_WARNING - "%s: pcm channel id without HFC_CFG_PCM\n", - __func__); - rx_slot = (bc>>8) & 0xff; - tx_slot = (bc>>16) & 0xff; + "%s: pcm channel id without HFC_CFG_PCM\n", + __func__); + rx_slot = (bc >> 8) & 0xff; + tx_slot = (bc >> 16) & 0xff; bc = bc & 0xff; } else if (test_bit(HFC_CFG_PCM, &hc->cfg) && (protocol > ISDN_P_NONE)) printk(KERN_WARNING "%s: no pcm channel id but HFC_CFG_PCM\n", - __func__); + __func__); if (hc->chanlimit > 1) { hc->hw.bswapped = 0; /* B1 and B2 normal mode */ hc->hw.sctrl_e &= ~0x80; @@ -1308,11 +1308,11 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol) if (fifo2 & 2) { hc->hw.fifo_en &= ~HFCPCI_FIFOEN_B2; hc->hw.int_m1 &= ~(HFCPCI_INTS_B2TRANS + - HFCPCI_INTS_B2REC); + HFCPCI_INTS_B2REC); } else { hc->hw.fifo_en &= ~HFCPCI_FIFOEN_B1; hc->hw.int_m1 &= ~(HFCPCI_INTS_B1TRANS + - HFCPCI_INTS_B1REC); + HFCPCI_INTS_B1REC); } #ifdef REVERSE_BITORDER if (bch->nr & 2) @@ -1347,14 +1347,14 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol) hc->hw.fifo_en |= HFCPCI_FIFOEN_B2; if (!tics) hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS + - HFCPCI_INTS_B2REC); + HFCPCI_INTS_B2REC); hc->hw.ctmt |= 2; hc->hw.conn &= ~0x18; } else { hc->hw.fifo_en |= HFCPCI_FIFOEN_B1; if (!tics) hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS + - HFCPCI_INTS_B1REC); + HFCPCI_INTS_B1REC); hc->hw.ctmt |= 1; hc->hw.conn &= ~0x03; } @@ -1376,14 +1376,14 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol) hc->hw.last_bfifo_cnt[1] = 0; hc->hw.fifo_en |= HFCPCI_FIFOEN_B2; hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS + - HFCPCI_INTS_B2REC); + HFCPCI_INTS_B2REC); hc->hw.ctmt &= ~2; hc->hw.conn &= ~0x18; } else { hc->hw.last_bfifo_cnt[0] = 0; hc->hw.fifo_en |= HFCPCI_FIFOEN_B1; hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS + - HFCPCI_INTS_B1REC); + HFCPCI_INTS_B1REC); hc->hw.ctmt &= ~1; hc->hw.conn &= ~0x03; } @@ -1395,7 +1395,7 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol) } if (test_bit(HFC_CFG_PCM, &hc->cfg)) { if ((protocol == ISDN_P_NONE) || - (protocol == -1)) { /* init case */ + (protocol == -1)) { /* init case */ rx_slot = 0; tx_slot = 0; } else { @@ -1411,18 +1411,18 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol) hc->hw.conn &= 0xc7; hc->hw.conn |= 0x08; printk(KERN_DEBUG "%s: Write_hfc: B2_SSL 0x%x\n", - __func__, tx_slot); + __func__, tx_slot); printk(KERN_DEBUG "%s: Write_hfc: B2_RSL 0x%x\n", - __func__, rx_slot); + __func__, rx_slot); Write_hfc(hc, HFCPCI_B2_SSL, tx_slot); Write_hfc(hc, HFCPCI_B2_RSL, rx_slot); } else { hc->hw.conn &= 0xf8; hc->hw.conn |= 0x01; printk(KERN_DEBUG "%s: Write_hfc: B1_SSL 0x%x\n", - __func__, tx_slot); + __func__, tx_slot); printk(KERN_DEBUG "%s: Write_hfc: B1_RSL 0x%x\n", - __func__, rx_slot); + __func__, rx_slot); Write_hfc(hc, HFCPCI_B1_SSL, tx_slot); Write_hfc(hc, HFCPCI_B1_RSL, rx_slot); } @@ -1447,12 +1447,12 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan) if (bch->debug & DEBUG_HW_BCHANNEL) printk(KERN_DEBUG - "HFCPCI bchannel test rx protocol %x-->%x ch %x-->%x\n", - bch->state, protocol, bch->nr, chan); + "HFCPCI bchannel test rx protocol %x-->%x ch %x-->%x\n", + bch->state, protocol, bch->nr, chan); if (bch->nr != chan) { printk(KERN_DEBUG - "HFCPCI rxtest wrong channel parameter %x/%x\n", - bch->nr, chan); + "HFCPCI rxtest wrong channel parameter %x/%x\n", + bch->nr, chan); return -EINVAL; } switch (protocol) { @@ -1543,7 +1543,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) test_and_set_bit(FLG_FILLEMPTY, &bch->Flags); if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d " - "off=%d)\n", __func__, bch->nr, !!cq->p1); + "off=%d)\n", __func__, bch->nr, !!cq->p1); break; default: printk(KERN_WARNING "%s: unknown Op %x\n", __func__, cq->op); @@ -1593,7 +1593,7 @@ hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) break; default: printk(KERN_WARNING "%s: unknown prim(%x)\n", - __func__, cmd); + __func__, cmd); } return ret; } @@ -1635,12 +1635,12 @@ hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) if (test_bit(FLG_ACTIVE, &dch->Flags)) { spin_unlock_irqrestore(&hc->lock, flags); _queue_data(&dch->dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); break; } test_and_set_bit(FLG_L2_ACTIVATED, &dch->Flags); Write_hfc(hc, HFCPCI_STATES, HFCPCI_ACTIVATE | - HFCPCI_DO_ACTION | 1); + HFCPCI_DO_ACTION | 1); } else ret = l1_event(dch->l1, hh->prim); spin_unlock_irqrestore(&hc->lock, flags); @@ -1718,12 +1718,12 @@ hfcpci_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&hc->lock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: deactivate_bchannel(bch); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); ret = 0; break; } @@ -1763,7 +1763,7 @@ init_card(struct hfc_pci *hc) spin_unlock_irqrestore(&hc->lock, flags); if (request_irq(hc->irq, hfcpci_int, IRQF_SHARED, "HFC PCI", hc)) { printk(KERN_WARNING - "mISDN: couldn't get interrupt %d\n", hc->irq); + "mISDN: couldn't get interrupt %d\n", hc->irq); return -EIO; } spin_lock_irqsave(&hc->lock, flags); @@ -1779,9 +1779,9 @@ init_card(struct hfc_pci *hc) spin_unlock_irqrestore(&hc->lock, flags); /* Timeout 80ms */ current->state = TASK_UNINTERRUPTIBLE; - schedule_timeout((80*HZ)/1000); + schedule_timeout((80 * HZ) / 1000); printk(KERN_INFO "HFC PCI: IRQ %d count %d\n", - hc->irq, hc->irqcnt); + hc->irq, hc->irqcnt); /* now switch timer interrupt off */ spin_lock_irqsave(&hc->lock, flags); hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER; @@ -1790,8 +1790,8 @@ init_card(struct hfc_pci *hc) Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m); if (!hc->irqcnt) { printk(KERN_WARNING - "HFC PCI: IRQ(%d) getting no interrupts " - "during init %d\n", hc->irq, 4 - cnt); + "HFC PCI: IRQ(%d) getting no interrupts " + "during init %d\n", hc->irq, 4 - cnt); if (cnt == 1) break; else { @@ -1819,7 +1819,7 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) switch (cq->op) { case MISDN_CTRL_GETOP: cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_CONNECT | - MISDN_CTRL_DISCONNECT; + MISDN_CTRL_DISCONNECT; break; case MISDN_CTRL_LOOP: /* channel 0 disabled loop */ @@ -1833,7 +1833,7 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) else slot = 0x80; printk(KERN_DEBUG "%s: Write_hfc: B1_SSL/RSL 0x%x\n", - __func__, slot); + __func__, slot); Write_hfc(hc, HFCPCI_B1_SSL, slot); Write_hfc(hc, HFCPCI_B1_RSL, slot); hc->hw.conn = (hc->hw.conn & ~7) | 6; @@ -1845,7 +1845,7 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) else slot = 0x81; printk(KERN_DEBUG "%s: Write_hfc: B2_SSL/RSL 0x%x\n", - __func__, slot); + __func__, slot); Write_hfc(hc, HFCPCI_B2_SSL, slot); Write_hfc(hc, HFCPCI_B2_RSL, slot); hc->hw.conn = (hc->hw.conn & ~0x38) | 0x30; @@ -1875,7 +1875,7 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) else slot = 0x80; printk(KERN_DEBUG "%s: Write_hfc: B1_SSL/RSL 0x%x\n", - __func__, slot); + __func__, slot); Write_hfc(hc, HFCPCI_B1_SSL, slot); Write_hfc(hc, HFCPCI_B2_RSL, slot); if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg)) @@ -1883,7 +1883,7 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) else slot = 0x81; printk(KERN_DEBUG "%s: Write_hfc: B2_SSL/RSL 0x%x\n", - __func__, slot); + __func__, slot); Write_hfc(hc, HFCPCI_B2_SSL, slot); Write_hfc(hc, HFCPCI_B1_RSL, slot); hc->hw.conn = (hc->hw.conn & ~0x3f) | 0x36; @@ -1898,7 +1898,7 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) break; default: printk(KERN_WARNING "%s: unknown Op %x\n", - __func__, cq->op); + __func__, cq->op); ret = -EINVAL; break; } @@ -1907,13 +1907,13 @@ channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq) static int open_dchannel(struct hfc_pci *hc, struct mISDNchannel *ch, - struct channel_req *rq) + struct channel_req *rq) { int err = 0; if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: dev(%d) open from %p\n", __func__, - hc->dch.dev.id, __builtin_return_address(0)); + hc->dch.dev.id, __builtin_return_address(0)); if (rq->protocol == ISDN_P_NONE) return -EINVAL; if (rq->adr.channel == 1) { @@ -1949,7 +1949,7 @@ open_dchannel(struct hfc_pci *hc, struct mISDNchannel *ch, if (((ch->protocol == ISDN_P_NT_S0) && (hc->dch.state == 3)) || ((ch->protocol == ISDN_P_TE_S0) && (hc->dch.state == 7))) { _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); } rq->ch = ch; if (!try_module_get(THIS_MODULE)) @@ -1991,7 +1991,7 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: cmd:%x %p\n", - __func__, cmd, arg); + __func__, cmd, arg); switch (cmd) { case OPEN_CHANNEL: rq = arg; @@ -2004,8 +2004,8 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) case CLOSE_CHANNEL: if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: dev(%d) close from %p\n", - __func__, hc->dch.dev.id, - __builtin_return_address(0)); + __func__, hc->dch.dev.id, + __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -2014,7 +2014,7 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: unknown command %x\n", - __func__, cmd); + __func__, cmd); return -EINVAL; } return err; @@ -2047,16 +2047,16 @@ setup_hw(struct hfc_pci *hc) /* We silently assume the address is okay if nonzero */ if (!buffer) { printk(KERN_WARNING - "HFC-PCI: Error allocating memory for FIFO!\n"); + "HFC-PCI: Error allocating memory for FIFO!\n"); return 1; } hc->hw.fifos = buffer; pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle); hc->hw.pci_io = ioremap((ulong) hc->hw.pci_io, 256); printk(KERN_INFO - "HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n", - (u_long) hc->hw.pci_io, (u_long) hc->hw.fifos, - (u_long) hc->hw.dmahandle, hc->irq, HZ); + "HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n", + (u_long) hc->hw.pci_io, (u_long) hc->hw.fifos, + (u_long) hc->hw.dmahandle, hc->irq, HZ); /* enable memory mapped ports, disable busmaster */ pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO); hc->hw.int_m2 = 0; @@ -2113,7 +2113,7 @@ setup_card(struct hfc_pci *card) card->dch.hw = card; card->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0); card->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | - (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); + (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); card->dch.dev.D.send = hfcpci_l2l1D; card->dch.dev.D.ctrl = hfc_dctrl; card->dch.dev.nrbchan = 2; @@ -2174,13 +2174,13 @@ static const struct _hfc_map hfc_map[] = {HFC_ANIGMA_MC145575, 0, "Motorola MC145575"}, {HFC_ZOLTRIX_2BD0, 0, "Zoltrix 2BD0"}, {HFC_DIGI_DF_M_IOM2_E, 0, - "Digi International DataFire Micro V IOM2 (Europe)"}, + "Digi International DataFire Micro V IOM2 (Europe)"}, {HFC_DIGI_DF_M_E, 0, - "Digi International DataFire Micro V (Europe)"}, + "Digi International DataFire Micro V (Europe)"}, {HFC_DIGI_DF_M_IOM2_A, 0, - "Digi International DataFire Micro V IOM2 (North America)"}, + "Digi International DataFire Micro V IOM2 (North America)"}, {HFC_DIGI_DF_M_A, 0, - "Digi International DataFire Micro V (North America)"}, + "Digi International DataFire Micro V (North America)"}, {HFC_SITECOM_DC105V2, 0, "Sitecom Connectivity DC-105 ISDN TA"}, {}, }; @@ -2188,51 +2188,51 @@ static const struct _hfc_map hfc_map[] = static struct pci_device_id hfc_ids[] = { { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_2BD0), - (unsigned long) &hfc_map[0] }, + (unsigned long) &hfc_map[0] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B000), - (unsigned long) &hfc_map[1] }, + (unsigned long) &hfc_map[1] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B006), - (unsigned long) &hfc_map[2] }, + (unsigned long) &hfc_map[2] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B007), - (unsigned long) &hfc_map[3] }, + (unsigned long) &hfc_map[3] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B008), - (unsigned long) &hfc_map[4] }, + (unsigned long) &hfc_map[4] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B009), - (unsigned long) &hfc_map[5] }, + (unsigned long) &hfc_map[5] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B00A), - (unsigned long) &hfc_map[6] }, + (unsigned long) &hfc_map[6] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B00B), - (unsigned long) &hfc_map[7] }, + (unsigned long) &hfc_map[7] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B00C), - (unsigned long) &hfc_map[8] }, + (unsigned long) &hfc_map[8] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B100), - (unsigned long) &hfc_map[9] }, + (unsigned long) &hfc_map[9] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B700), - (unsigned long) &hfc_map[10] }, + (unsigned long) &hfc_map[10] }, { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B701), - (unsigned long) &hfc_map[11] }, + (unsigned long) &hfc_map[11] }, { PCI_VDEVICE(ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1), - (unsigned long) &hfc_map[12] }, + (unsigned long) &hfc_map[12] }, { PCI_VDEVICE(ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675), - (unsigned long) &hfc_map[13] }, + (unsigned long) &hfc_map[13] }, { PCI_VDEVICE(BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT), - (unsigned long) &hfc_map[14] }, + (unsigned long) &hfc_map[14] }, { PCI_VDEVICE(BERKOM, PCI_DEVICE_ID_BERKOM_A1T), - (unsigned long) &hfc_map[15] }, + (unsigned long) &hfc_map[15] }, { PCI_VDEVICE(ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575), - (unsigned long) &hfc_map[16] }, + (unsigned long) &hfc_map[16] }, { PCI_VDEVICE(ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0), - (unsigned long) &hfc_map[17] }, + (unsigned long) &hfc_map[17] }, { PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E), - (unsigned long) &hfc_map[18] }, + (unsigned long) &hfc_map[18] }, { PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_E), - (unsigned long) &hfc_map[19] }, + (unsigned long) &hfc_map[19] }, { PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A), - (unsigned long) &hfc_map[20] }, + (unsigned long) &hfc_map[20] }, { PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_A), - (unsigned long) &hfc_map[21] }, + (unsigned long) &hfc_map[21] }, { PCI_VDEVICE(SITECOM, PCI_DEVICE_ID_SITECOM_DC105V2), - (unsigned long) &hfc_map[22] }, + (unsigned long) &hfc_map[22] }, {}, }; @@ -2277,7 +2277,7 @@ hfc_remove_pci(struct pci_dev *pdev) else if (debug) printk(KERN_DEBUG "%s: drvdata already removed\n", - __func__); + __func__); } @@ -2317,7 +2317,7 @@ static void hfcpci_softirq(void *arg) { (void) driver_for_each_device(&hfc_driver.driver, NULL, arg, - _hfcpci_softirq); + _hfcpci_softirq); /* if next event would be in the past ... */ if ((s32)(hfc_jiffies + tics - jiffies) <= 0) @@ -2343,14 +2343,14 @@ HFC_init(void) poll = (tics * 8000) / HZ; if (poll > 256 || poll < 8) { printk(KERN_ERR "%s: Wrong poll value %d not in range " - "of 8..256.\n", __func__, poll); + "of 8..256.\n", __func__, poll); err = -EINVAL; return err; } } if (poll != HFCPCI_BTRANS_THRESHOLD) { printk(KERN_INFO "%s: Using alternative poll value of %d\n", - __func__, poll); + __func__, poll); hfc_tl.function = (void *)hfcpci_softirq; hfc_tl.data = 0; init_timer(&hfc_tl); diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c index 43b4d29e5475..602338734634 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.c +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c @@ -75,9 +75,9 @@ ctrl_start_transfer(struct hfcsusb *hw) hw->ctrl_urb->transfer_buffer = NULL; hw->ctrl_urb->transfer_buffer_length = 0; hw->ctrl_write.wIndex = - cpu_to_le16(hw->ctrl_buff[hw->ctrl_out_idx].hfcs_reg); + cpu_to_le16(hw->ctrl_buff[hw->ctrl_out_idx].hfcs_reg); hw->ctrl_write.wValue = - cpu_to_le16(hw->ctrl_buff[hw->ctrl_out_idx].reg_val); + cpu_to_le16(hw->ctrl_buff[hw->ctrl_out_idx].reg_val); usb_submit_urb(hw->ctrl_urb, GFP_ATOMIC); } @@ -93,7 +93,7 @@ static int write_reg(struct hfcsusb *hw, __u8 reg, __u8 val) if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s reg(0x%02x) val(0x%02x)\n", - hw->name, __func__, reg, val); + hw->name, __func__, reg, val); spin_lock(&hw->ctrl_lock); if (hw->ctrl_cnt >= HFC_CTRL_BUFSIZE) { @@ -196,8 +196,8 @@ handle_led(struct hfcsusb *hw, int event) if (hw->led_state != tmpled) { if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s reg(0x%02x) val(x%02x)\n", - hw->name, __func__, - HFCUSB_P_DATA, hw->led_state); + hw->name, __func__, + HFCUSB_P_DATA, hw->led_state); write_reg(hw, HFCUSB_P_DATA, hw->led_state); } @@ -225,7 +225,7 @@ hfcusb_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&hw->lock, flags); if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s PH_DATA_REQ ret(%i)\n", - hw->name, __func__, ret); + hw->name, __func__, ret); if (ret > 0) { /* * other l1 drivers don't send early confirms on @@ -244,12 +244,12 @@ hfcusb_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) ret = 0; if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: deactivate_bchannel(bch); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); ret = 0; break; } @@ -270,7 +270,7 @@ hfcsusb_ph_info(struct hfcsusb *hw) int i; phi = kzalloc(sizeof(struct ph_info) + - dch->dev.nrbchan * sizeof(struct ph_info_ch), GFP_ATOMIC); + dch->dev.nrbchan * sizeof(struct ph_info_ch), GFP_ATOMIC); phi->dch.ch.protocol = hw->protocol; phi->dch.ch.Flags = dch->Flags; phi->dch.state = dch->state; @@ -280,8 +280,8 @@ hfcsusb_ph_info(struct hfcsusb *hw) phi->bch[i].Flags = hw->bch[i].Flags; } _queue_data(&dch->dev.D, MPH_INFORMATION_IND, MISDN_ID_ANY, - sizeof(struct ph_info_dch) + dch->dev.nrbchan * - sizeof(struct ph_info_ch), phi, GFP_ATOMIC); + sizeof(struct ph_info_dch) + dch->dev.nrbchan * + sizeof(struct ph_info_ch), phi, GFP_ATOMIC); kfree(phi); } @@ -302,7 +302,7 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) case PH_DATA_REQ: if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s: PH_DATA_REQ\n", - hw->name, __func__); + hw->name, __func__); spin_lock_irqsave(&hw->lock, flags); ret = dchannel_senddata(dch, skb); @@ -316,20 +316,20 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) case PH_ACTIVATE_REQ: if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s: PH_ACTIVATE_REQ %s\n", - hw->name, __func__, - (hw->protocol == ISDN_P_NT_S0) ? "NT" : "TE"); + hw->name, __func__, + (hw->protocol == ISDN_P_NT_S0) ? "NT" : "TE"); if (hw->protocol == ISDN_P_NT_S0) { ret = 0; if (test_bit(FLG_ACTIVE, &dch->Flags)) { _queue_data(&dch->dev.D, - PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_ATOMIC); + PH_ACTIVATE_IND, MISDN_ID_ANY, 0, + NULL, GFP_ATOMIC); } else { hfcsusb_ph_command(hw, - HFC_L1_ACTIVATE_NT); + HFC_L1_ACTIVATE_NT); test_and_set_bit(FLG_L2_ACTIVATED, - &dch->Flags); + &dch->Flags); } } else { hfcsusb_ph_command(hw, HFC_L1_ACTIVATE_TE); @@ -340,7 +340,7 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) case PH_DEACTIVATE_REQ: if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s: PH_DEACTIVATE_REQ\n", - hw->name, __func__); + hw->name, __func__); test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags); if (hw->protocol == ISDN_P_NT_S0) { @@ -385,7 +385,7 @@ hfc_l1callback(struct dchannel *dch, u_int cmd) if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s cmd 0x%x\n", - hw->name, __func__, cmd); + hw->name, __func__, cmd); switch (cmd) { case INFO3_P8: @@ -410,17 +410,17 @@ hfc_l1callback(struct dchannel *dch, u_int cmd) case PH_ACTIVATE_IND: test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; case PH_DEACTIVATE_IND: test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: unknown cmd %x\n", - hw->name, __func__, cmd); + hw->name, __func__, cmd); return -1; } hfcsusb_ph_info(hw); @@ -429,14 +429,14 @@ hfc_l1callback(struct dchannel *dch, u_int cmd) static int open_dchannel(struct hfcsusb *hw, struct mISDNchannel *ch, - struct channel_req *rq) + struct channel_req *rq) { int err = 0; if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: %s: dev(%d) open addr(%i) from %p\n", - hw->name, __func__, hw->dch.dev.id, rq->adr.channel, - __builtin_return_address(0)); + hw->name, __func__, hw->dch.dev.id, rq->adr.channel, + __builtin_return_address(0)); if (rq->protocol == ISDN_P_NONE) return -EINVAL; @@ -450,7 +450,7 @@ open_dchannel(struct hfcsusb *hw, struct mISDNchannel *ch, hfcsusb_start_endpoint(hw, HFC_CHAN_E); set_bit(FLG_ACTIVE, &hw->ech.Flags); _queue_data(&hw->ech.dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); } else return -EINVAL; } @@ -473,11 +473,11 @@ open_dchannel(struct hfcsusb *hw, struct mISDNchannel *ch, if (((ch->protocol == ISDN_P_NT_S0) && (hw->dch.state == 3)) || ((ch->protocol == ISDN_P_TE_S0) && (hw->dch.state == 7))) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); rq->ch = ch; if (!try_module_get(THIS_MODULE)) printk(KERN_WARNING "%s: %s: cannot get module\n", - hw->name, __func__); + hw->name, __func__); return 0; } @@ -493,7 +493,7 @@ open_bchannel(struct hfcsusb *hw, struct channel_req *rq) if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s B%i\n", - hw->name, __func__, rq->adr.channel); + hw->name, __func__, rq->adr.channel); bch = &hw->bch[rq->adr.channel - 1]; if (test_and_set_bit(FLG_OPEN, &bch->Flags)) @@ -510,7 +510,7 @@ open_bchannel(struct hfcsusb *hw, struct channel_req *rq) if (!try_module_get(THIS_MODULE)) printk(KERN_WARNING "%s: %s:cannot get module\n", - hw->name, __func__); + hw->name, __func__); return 0; } @@ -521,16 +521,16 @@ channel_ctrl(struct hfcsusb *hw, struct mISDN_ctrl_req *cq) if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s op(0x%x) channel(0x%x)\n", - hw->name, __func__, (cq->op), (cq->channel)); + hw->name, __func__, (cq->op), (cq->channel)); switch (cq->op) { case MISDN_CTRL_GETOP: cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_CONNECT | - MISDN_CTRL_DISCONNECT; + MISDN_CTRL_DISCONNECT; break; default: printk(KERN_WARNING "%s: %s: unknown Op %x\n", - hw->name, __func__, cq->op); + hw->name, __func__, cq->op); ret = -EINVAL; break; } @@ -551,7 +551,7 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: cmd:%x %p\n", - hw->name, __func__, cmd, arg); + hw->name, __func__, cmd, arg); switch (cmd) { case OPEN_CHANNEL: rq = arg; @@ -567,9 +567,9 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) hw->open--; if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG - "%s: %s: dev(%d) close from %p (open %d)\n", - hw->name, __func__, hw->dch.dev.id, - __builtin_return_address(0), hw->open); + "%s: %s: dev(%d) close from %p (open %d)\n", + hw->name, __func__, hw->dch.dev.id, + __builtin_return_address(0), hw->open); if (!hw->open) { hfcsusb_stop_endpoint(hw, HFC_CHAN_D); if (hw->fifos[HFCUSB_PCM_RX].pipe) @@ -584,7 +584,7 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: unknown command %x\n", - hw->name, __func__, cmd); + hw->name, __func__, cmd); return -EINVAL; } return err; @@ -601,10 +601,10 @@ ph_state_te(struct dchannel *dch) if (debug & DEBUG_HW) { if (dch->state <= HFC_MAX_TE_LAYER1_STATE) printk(KERN_DEBUG "%s: %s: %s\n", hw->name, __func__, - HFC_TE_LAYER1_STATES[dch->state]); + HFC_TE_LAYER1_STATES[dch->state]); else printk(KERN_DEBUG "%s: %s: TE F%d\n", - hw->name, __func__, dch->state); + hw->name, __func__, dch->state); } switch (dch->state) { @@ -642,12 +642,12 @@ ph_state_nt(struct dchannel *dch) if (debug & DEBUG_HW) { if (dch->state <= HFC_MAX_NT_LAYER1_STATE) printk(KERN_DEBUG "%s: %s: %s\n", - hw->name, __func__, - HFC_NT_LAYER1_STATES[dch->state]); + hw->name, __func__, + HFC_NT_LAYER1_STATES[dch->state]); else printk(KERN_INFO DRIVER_NAME "%s: %s: NT G%d\n", - hw->name, __func__, dch->state); + hw->name, __func__, dch->state); } switch (dch->state) { @@ -676,7 +676,7 @@ ph_state_nt(struct dchannel *dch) hw->timers &= ~NT_ACTIVATION_TIMER; test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); handle_led(hw, LED_S0_ON); break; case (4): @@ -711,8 +711,8 @@ hfcsusb_setup_bch(struct bchannel *bch, int protocol) if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: protocol %x-->%x B%d\n", - hw->name, __func__, bch->state, protocol, - bch->nr); + hw->name, __func__, bch->state, protocol, + bch->nr); /* setup val for CON_HDLC */ conhdlc = 0; @@ -742,7 +742,7 @@ hfcsusb_setup_bch(struct bchannel *bch, int protocol) default: if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: prot not known %x\n", - hw->name, __func__, protocol); + hw->name, __func__, protocol); return -ENOPROTOOPT; } @@ -771,7 +771,7 @@ hfcsusb_setup_bch(struct bchannel *bch, int protocol) handle_led(hw, (bch->nr == 1) ? LED_B1_ON : LED_B2_ON); else handle_led(hw, (bch->nr == 1) ? LED_B1_OFF : - LED_B2_OFF); + LED_B2_OFF); } hfcsusb_ph_info(hw); return 0; @@ -782,7 +782,7 @@ hfcsusb_ph_command(struct hfcsusb *hw, u_char command) { if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: %x\n", - hw->name, __func__, command); + hw->name, __func__, command); switch (command) { case HFC_L1_ACTIVATE_TE: @@ -800,15 +800,15 @@ hfcsusb_ph_command(struct hfcsusb *hw, u_char command) case HFC_L1_ACTIVATE_NT: if (hw->dch.state == 3) _queue_data(&hw->dch.dev.D, PH_ACTIVATE_IND, - MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); + MISDN_ID_ANY, 0, NULL, GFP_ATOMIC); else write_reg(hw, HFCUSB_STATES, HFCUSB_ACTIVATE | - HFCUSB_DO_ACTION | HFCUSB_NT_G2_G3); + HFCUSB_DO_ACTION | HFCUSB_NT_G2_G3); break; case HFC_L1_DEACTIVATE_NT: write_reg(hw, HFCUSB_STATES, - HFCUSB_DO_ACTION); + HFCUSB_DO_ACTION); break; } } @@ -829,7 +829,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) test_and_set_bit(FLG_FILLEMPTY, &bch->Flags); if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d " - "off=%d)\n", __func__, bch->nr, !!cq->p1); + "off=%d)\n", __func__, bch->nr, !!cq->p1); break; default: printk(KERN_WARNING "%s: unknown Op %x\n", __func__, cq->op); @@ -842,7 +842,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) /* collect data from incoming interrupt or isochron USB data */ static void hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, - int finish) + int finish) { struct hfcsusb *hw = fifo->hw; struct sk_buff *rx_skb = NULL; @@ -853,9 +853,9 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, if (debug & DBG_HFC_CALL_TRACE) printk(KERN_DEBUG "%s: %s: fifo(%i) len(%i) " - "dch(%p) bch(%p) ech(%p)\n", - hw->name, __func__, fifon, len, - fifo->dch, fifo->bch, fifo->ech); + "dch(%p) bch(%p) ech(%p)\n", + hw->name, __func__, fifon, len, + fifo->dch, fifo->bch, fifo->ech); if (!len) return; @@ -895,7 +895,7 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, skb_trim(rx_skb, 0); } else { printk(KERN_DEBUG "%s: %s: No mem for rx_skb\n", - hw->name, __func__); + hw->name, __func__); spin_unlock(&hw->lock); return; } @@ -905,8 +905,8 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, /* D/E-Channel SKB range check */ if ((rx_skb->len + len) >= MAX_DFRAME_LEN_L1) { printk(KERN_DEBUG "%s: %s: sbk mem exceeded " - "for fifo(%d) HFCUSB_D_RX\n", - hw->name, __func__, fifon); + "for fifo(%d) HFCUSB_D_RX\n", + hw->name, __func__, fifon); skb_trim(rx_skb, 0); spin_unlock(&hw->lock); return; @@ -915,8 +915,8 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, /* B-Channel SKB range check */ if ((rx_skb->len + len) >= (MAX_BCH_SIZE + 3)) { printk(KERN_DEBUG "%s: %s: sbk mem exceeded " - "for fifo(%d) HFCUSB_B_RX\n", - hw->name, __func__, fifon); + "for fifo(%d) HFCUSB_B_RX\n", + hw->name, __func__, fifon); skb_trim(rx_skb, 0); spin_unlock(&hw->lock); return; @@ -929,16 +929,16 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, /* we have a complete hdlc packet */ if (finish) { if ((rx_skb->len > 3) && - (!(rx_skb->data[rx_skb->len - 1]))) { + (!(rx_skb->data[rx_skb->len - 1]))) { if (debug & DBG_HFC_FIFO_VERBOSE) { printk(KERN_DEBUG "%s: %s: fifon(%i)" - " new RX len(%i): ", - hw->name, __func__, fifon, - rx_skb->len); + " new RX len(%i): ", + hw->name, __func__, fifon, + rx_skb->len); i = 0; while (i < rx_skb->len) printk("%02x ", - rx_skb->data[i++]); + rx_skb->data[i++]); printk("\n"); } @@ -951,17 +951,17 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, recv_Bchannel(fifo->bch, MISDN_ID_ANY); if (fifo->ech) recv_Echannel(fifo->ech, - &hw->dch); + &hw->dch); } else { if (debug & DBG_HFC_FIFO_VERBOSE) { printk(KERN_DEBUG - "%s: CRC or minlen ERROR fifon(%i) " - "RX len(%i): ", - hw->name, fifon, rx_skb->len); + "%s: CRC or minlen ERROR fifon(%i) " + "RX len(%i): ", + hw->name, fifon, rx_skb->len); i = 0; while (i < rx_skb->len) printk("%02x ", - rx_skb->data[i++]); + rx_skb->data[i++]); printk("\n"); } skb_trim(rx_skb, 0); @@ -983,7 +983,7 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, int k; usb_fill_bulk_urb(urb, dev, pipe, buf, packet_size * num_packets, - complete, context); + complete, context); urb->number_of_packets = num_packets; urb->transfer_flags = URB_ISO_ASAP; @@ -1005,7 +1005,7 @@ rx_iso_complete(struct urb *urb) struct usb_fifo *fifo = context_iso_urb->owner_fifo; struct hfcsusb *hw = fifo->hw; int k, len, errcode, offset, num_isoc_packets, fifon, maxlen, - status, iso_status, i; + status, iso_status, i; __u8 *buf; static __u8 eof[8]; __u8 s0_state; @@ -1029,8 +1029,8 @@ rx_iso_complete(struct urb *urb) if (status == -EXDEV) { if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: with -EXDEV " - "urb->status %d, fifonum %d\n", - hw->name, __func__, status, fifon); + "urb->status %d, fifonum %d\n", + hw->name, __func__, status, fifon); /* clear status, so go on with ISO transfers */ status = 0; @@ -1049,18 +1049,18 @@ rx_iso_complete(struct urb *urb) if (iso_status && (debug & DBG_HFC_FIFO_VERBOSE)) { printk(KERN_DEBUG "%s: %s: " - "ISO packet %i, status: %i\n", - hw->name, __func__, k, iso_status); + "ISO packet %i, status: %i\n", + hw->name, __func__, k, iso_status); } /* USB data log for every D ISO in */ if ((fifon == HFCUSB_D_RX) && (debug & DBG_HFC_USB_VERBOSE)) { printk(KERN_DEBUG - "%s: %s: %d (%d/%d) len(%d) ", - hw->name, __func__, urb->start_frame, - k, num_isoc_packets-1, - len); + "%s: %s: %d (%d/%d) len(%d) ", + hw->name, __func__, urb->start_frame, + k, num_isoc_packets - 1, + len); for (i = 0; i < len; i++) printk("%x ", buf[i]); printk("\n"); @@ -1081,12 +1081,12 @@ rx_iso_complete(struct urb *urb) eof[fifon] = buf[0] & 1; if (len > 2) hfcsusb_rx_frame(fifo, buf + 2, - len - 2, (len < maxlen) - ? eof[fifon] : 0); + len - 2, (len < maxlen) + ? eof[fifon] : 0); } else hfcsusb_rx_frame(fifo, buf, len, - (len < maxlen) ? - eof[fifon] : 0); + (len < maxlen) ? + eof[fifon] : 0); fifo->last_urblen = len; } } @@ -1106,14 +1106,14 @@ rx_iso_complete(struct urb *urb) if (errcode < 0) { if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: error submitting " - "ISO URB: %d\n", - hw->name, __func__, errcode); + "ISO URB: %d\n", + hw->name, __func__, errcode); } } else { if (status && (debug & DBG_HFC_URB_INFO)) printk(KERN_DEBUG "%s: %s: rx_iso_complete : " - "urb->status %d, fifonum %d\n", - hw->name, __func__, status, fifon); + "urb->status %d, fifonum %d\n", + hw->name, __func__, status, fifon); } } @@ -1140,8 +1140,8 @@ rx_int_complete(struct urb *urb) if ((!fifo->active) || (urb->status)) { if (debug & DBG_HFC_URB_ERROR) printk(KERN_DEBUG - "%s: %s: RX-Fifo %i is going down (%i)\n", - hw->name, __func__, fifon, urb->status); + "%s: %s: RX-Fifo %i is going down (%i)\n", + hw->name, __func__, fifon, urb->status); fifo->urb->interval = 0; /* cancel automatic rescheduling */ return; @@ -1153,7 +1153,7 @@ rx_int_complete(struct urb *urb) /* USB data log for every D INT in */ if ((fifon == HFCUSB_D_RX) && (debug & DBG_HFC_USB_VERBOSE)) { printk(KERN_DEBUG "%s: %s: D RX INT len(%d) ", - hw->name, __func__, len); + hw->name, __func__, len); for (i = 0; i < len; i++) printk("%02x ", buf[i]); printk("\n"); @@ -1173,8 +1173,8 @@ rx_int_complete(struct urb *urb) /* if we have more than the 2 status bytes -> collect data */ if (len > 2) hfcsusb_rx_frame(fifo, buf + 2, - urb->actual_length - 2, - (len < maxlen) ? eof[fifon] : 0); + urb->actual_length - 2, + (len < maxlen) ? eof[fifon] : 0); } else { hfcsusb_rx_frame(fifo, buf, urb->actual_length, (len < maxlen) ? eof[fifon] : 0); @@ -1185,7 +1185,7 @@ rx_int_complete(struct urb *urb) if (status) { if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: error resubmitting USB\n", - hw->name, __func__); + hw->name, __func__); } } @@ -1198,7 +1198,7 @@ tx_iso_complete(struct urb *urb) struct hfcsusb *hw = fifo->hw; struct sk_buff *tx_skb; int k, tx_offset, num_isoc_packets, sink, remain, current_len, - errcode, hdlc, i; + errcode, hdlc, i; int *tx_idx; int frame_complete, fifon, status; __u8 threshbit; @@ -1221,7 +1221,7 @@ tx_iso_complete(struct urb *urb) hdlc = test_bit(FLG_HDLC, &fifo->bch->Flags); } else { printk(KERN_DEBUG "%s: %s: neither BCH nor DCH\n", - hw->name, __func__); + hw->name, __func__); spin_unlock(&hw->lock); return; } @@ -1238,8 +1238,8 @@ tx_iso_complete(struct urb *urb) if (status == -EXDEV) { if (debug & DBG_HFC_URB_ERROR) printk(KERN_DEBUG "%s: %s: " - "-EXDEV (%i) fifon (%d)\n", - hw->name, __func__, status, fifon); + "-EXDEV (%i) fifon (%d)\n", + hw->name, __func__, status, fifon); /* clear status, so go on with ISO transfers */ status = 0; @@ -1269,8 +1269,8 @@ tx_iso_complete(struct urb *urb) errcode = urb->iso_frame_desc[k].status; if (errcode) { printk(KERN_DEBUG "%s: %s: " - "ISO packet %i, status: %i\n", - hw->name, __func__, k, errcode); + "ISO packet %i, status: %i\n", + hw->name, __func__, k, errcode); } } @@ -1298,7 +1298,7 @@ tx_iso_complete(struct urb *urb) if (hdlc) { /* signal frame completion */ context_iso_urb-> - buffer[tx_offset] = 1; + buffer[tx_offset] = 1; /* add 2 byte flags and 16bit * CRC at end of ISDN frame */ fifo->bit_line += 32; @@ -1318,21 +1318,21 @@ tx_iso_complete(struct urb *urb) if ((fifon == HFCUSB_D_RX) && (debug & DBG_HFC_USB_VERBOSE)) { printk(KERN_DEBUG - "%s: %s (%d/%d) offs(%d) len(%d) ", - hw->name, __func__, - k, num_isoc_packets-1, - urb->iso_frame_desc[k].offset, - urb->iso_frame_desc[k].length); + "%s: %s (%d/%d) offs(%d) len(%d) ", + hw->name, __func__, + k, num_isoc_packets - 1, + urb->iso_frame_desc[k].offset, + urb->iso_frame_desc[k].length); for (i = urb->iso_frame_desc[k].offset; i < (urb->iso_frame_desc[k].offset - + urb->iso_frame_desc[k].length); + + urb->iso_frame_desc[k].length); i++) printk("%x ", - context_iso_urb->buffer[i]); + context_iso_urb->buffer[i]); printk(" skb->len(%i) tx-idx(%d)\n", - tx_skb->len, *tx_idx); + tx_skb->len, *tx_idx); } tx_offset += (current_len + 1); @@ -1350,13 +1350,13 @@ tx_iso_complete(struct urb *urb) if (debug & DBG_HFC_FIFO_VERBOSE) { printk(KERN_DEBUG "%s: %s: " - "fifon(%i) new TX len(%i): ", - hw->name, __func__, - fifon, tx_skb->len); + "fifon(%i) new TX len(%i): ", + hw->name, __func__, + fifon, tx_skb->len); i = 0; while (i < tx_skb->len) printk("%02x ", - tx_skb->data[i++]); + tx_skb->data[i++]); printk("\n"); } @@ -1365,9 +1365,9 @@ tx_iso_complete(struct urb *urb) if (fifo->dch && get_next_dframe(fifo->dch)) tx_skb = fifo->dch->tx_skb; else if (fifo->bch && - get_next_bframe(fifo->bch)) { + get_next_bframe(fifo->bch)) { if (test_bit(FLG_TRANSPARENT, - &fifo->bch->Flags)) + &fifo->bch->Flags)) confirm_Bsend(fifo->bch); tx_skb = fifo->bch->tx_skb; } @@ -1377,8 +1377,8 @@ tx_iso_complete(struct urb *urb) if (errcode < 0) { if (debug & DEBUG_HW) printk(KERN_DEBUG - "%s: %s: error submitting ISO URB: %d \n", - hw->name, __func__, errcode); + "%s: %s: error submitting ISO URB: %d \n", + hw->name, __func__, errcode); } /* @@ -1395,9 +1395,9 @@ tx_iso_complete(struct urb *urb) } else { if (status && (debug & DBG_HFC_URB_ERROR)) printk(KERN_DEBUG "%s: %s: urb->status %s (%i)" - "fifonum=%d\n", - hw->name, __func__, - symbolic(urb_errlist, status), status, fifon); + "fifonum=%d\n", + hw->name, __func__, + symbolic(urb_errlist, status), status, fifon); } spin_unlock(&hw->lock); } @@ -1415,17 +1415,17 @@ start_isoc_chain(struct usb_fifo *fifo, int num_packets_per_urb, if (debug) printk(KERN_DEBUG "%s: %s: fifo %i\n", - hw->name, __func__, fifo->fifonum); + hw->name, __func__, fifo->fifonum); /* allocate Memory for Iso out Urbs */ for (i = 0; i < 2; i++) { if (!(fifo->iso[i].urb)) { fifo->iso[i].urb = - usb_alloc_urb(num_packets_per_urb, GFP_KERNEL); + usb_alloc_urb(num_packets_per_urb, GFP_KERNEL); if (!(fifo->iso[i].urb)) { printk(KERN_DEBUG - "%s: %s: alloc urb for fifo %i failed", - hw->name, __func__, fifo->fifonum); + "%s: %s: alloc urb for fifo %i failed", + hw->name, __func__, fifo->fifonum); } fifo->iso[i].owner_fifo = (struct usb_fifo *) fifo; fifo->iso[i].indx = i; @@ -1435,27 +1435,27 @@ start_isoc_chain(struct usb_fifo *fifo, int num_packets_per_urb, (fifo->usb_packet_maxlen * num_packets_per_urb)) { fill_isoc_urb(fifo->iso[i].urb, - fifo->hw->dev, fifo->pipe, - fifo->iso[i].buffer, - num_packets_per_urb, - fifo->usb_packet_maxlen, - fifo->intervall, complete, - &fifo->iso[i]); + fifo->hw->dev, fifo->pipe, + fifo->iso[i].buffer, + num_packets_per_urb, + fifo->usb_packet_maxlen, + fifo->intervall, complete, + &fifo->iso[i]); memset(fifo->iso[i].buffer, 0, sizeof(fifo->iso[i].buffer)); for (k = 0; k < num_packets_per_urb; k++) { fifo->iso[i].urb-> - iso_frame_desc[k].offset = - k * packet_size; + iso_frame_desc[k].offset = + k * packet_size; fifo->iso[i].urb-> - iso_frame_desc[k].length = - packet_size; + iso_frame_desc[k].length = + packet_size; } } else { printk(KERN_DEBUG - "%s: %s: ISO Buffer size to small!\n", - hw->name, __func__); + "%s: %s: ISO Buffer size to small!\n", + hw->name, __func__); } } fifo->bit_line = BITLINE_INF; @@ -1465,8 +1465,8 @@ start_isoc_chain(struct usb_fifo *fifo, int num_packets_per_urb, fifo->stop_gracefull = 0; if (errcode < 0) { printk(KERN_DEBUG "%s: %s: %s URB nr:%d\n", - hw->name, __func__, - symbolic(urb_errlist, errcode), i); + hw->name, __func__, + symbolic(urb_errlist, errcode), i); } } return fifo->active; @@ -1491,10 +1491,10 @@ stop_iso_gracefull(struct usb_fifo *fifo) for (i = 0; i < 2; i++) { timeout = 3; while (fifo->stop_gracefull && timeout--) - schedule_timeout_interruptible((HZ/1000)*16); + schedule_timeout_interruptible((HZ / 1000) * 16); if (debug && fifo->stop_gracefull) printk(KERN_DEBUG "%s: ERROR %s for fifo %i.%i\n", - hw->name, __func__, fifo->fifonum, i); + hw->name, __func__, fifo->fifonum, i); } } @@ -1514,7 +1514,7 @@ stop_int_gracefull(struct usb_fifo *fifo) timeout = 3; while (fifo->stop_gracefull && timeout--) - schedule_timeout_interruptible((HZ/1000)*3); + schedule_timeout_interruptible((HZ / 1000) * 3); if (debug && fifo->stop_gracefull) printk(KERN_DEBUG "%s: ERROR %s for fifo %i\n", hw->name, __func__, fifo->fifonum); @@ -1529,7 +1529,7 @@ start_int_fifo(struct usb_fifo *fifo) if (debug) printk(KERN_DEBUG "%s: %s: INT IN fifo:%d\n", - hw->name, __func__, fifo->fifonum); + hw->name, __func__, fifo->fifonum); if (!fifo->urb) { fifo->urb = usb_alloc_urb(0, GFP_KERNEL); @@ -1537,14 +1537,14 @@ start_int_fifo(struct usb_fifo *fifo) return; } usb_fill_int_urb(fifo->urb, fifo->hw->dev, fifo->pipe, - fifo->buffer, fifo->usb_packet_maxlen, - (usb_complete_t)rx_int_complete, fifo, fifo->intervall); + fifo->buffer, fifo->usb_packet_maxlen, + (usb_complete_t)rx_int_complete, fifo, fifo->intervall); fifo->active = 1; fifo->stop_gracefull = 0; errcode = usb_submit_urb(fifo->urb, GFP_KERNEL); if (errcode) { printk(KERN_DEBUG "%s: %s: submit URB: status:%i\n", - hw->name, __func__, errcode); + hw->name, __func__, errcode); fifo->active = 0; } } @@ -1554,7 +1554,7 @@ setPortMode(struct hfcsusb *hw) { if (debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s %s\n", hw->name, __func__, - (hw->protocol == ISDN_P_TE_S0) ? "TE" : "NT"); + (hw->protocol == ISDN_P_TE_S0) ? "TE" : "NT"); if (hw->protocol == ISDN_P_TE_S0) { write_reg(hw, HFCUSB_SCTRL, 0x40); @@ -1588,7 +1588,7 @@ reset_hfcsusb(struct hfcsusb *hw) /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */ write_reg(hw, HFCUSB_USB_SIZE, (hw->packet_size / 8) | - ((hw->packet_size / 8) << 4)); + ((hw->packet_size / 8) << 4)); /* set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers */ write_reg(hw, HFCUSB_USB_SIZE_I, hw->iso_packet_size); @@ -1599,13 +1599,13 @@ reset_hfcsusb(struct hfcsusb *hw) /* init the fifos */ write_reg(hw, HFCUSB_F_THRES, - (HFCUSB_TX_THRESHOLD / 8) | ((HFCUSB_RX_THRESHOLD / 8) << 4)); + (HFCUSB_TX_THRESHOLD / 8) | ((HFCUSB_RX_THRESHOLD / 8) << 4)); fifo = hw->fifos; for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { write_reg(hw, HFCUSB_FIFO, i); /* select the desired fifo */ fifo[i].max_size = - (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; + (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; fifo[i].last_urblen = 0; /* set 2 bit for D- & E-channel */ @@ -1614,7 +1614,7 @@ reset_hfcsusb(struct hfcsusb *hw) /* enable all fifos */ if (i == HFCUSB_D_TX) write_reg(hw, HFCUSB_CON_HDLC, - (hw->protocol == ISDN_P_NT_S0) ? 0x08 : 0x09); + (hw->protocol == ISDN_P_NT_S0) ? 0x08 : 0x09); else write_reg(hw, HFCUSB_CON_HDLC, 0x08); write_reg(hw, HFCUSB_INC_RES_F, 2); /* reset the fifo */ @@ -1640,34 +1640,34 @@ hfcsusb_start_endpoint(struct hfcsusb *hw, int channel) /* start rx endpoints using USB INT IN method */ if (hw->cfg_used == CNF_3INT3ISO || hw->cfg_used == CNF_4INT3ISO) - start_int_fifo(hw->fifos + channel*2 + 1); + start_int_fifo(hw->fifos + channel * 2 + 1); /* start rx endpoints using USB ISO IN method */ if (hw->cfg_used == CNF_3ISO3ISO || hw->cfg_used == CNF_4ISO3ISO) { switch (channel) { case HFC_CHAN_D: start_isoc_chain(hw->fifos + HFCUSB_D_RX, - ISOC_PACKETS_D, - (usb_complete_t)rx_iso_complete, - 16); + ISOC_PACKETS_D, + (usb_complete_t)rx_iso_complete, + 16); break; case HFC_CHAN_E: start_isoc_chain(hw->fifos + HFCUSB_PCM_RX, - ISOC_PACKETS_D, - (usb_complete_t)rx_iso_complete, - 16); + ISOC_PACKETS_D, + (usb_complete_t)rx_iso_complete, + 16); break; case HFC_CHAN_B1: start_isoc_chain(hw->fifos + HFCUSB_B1_RX, - ISOC_PACKETS_B, - (usb_complete_t)rx_iso_complete, - 16); + ISOC_PACKETS_B, + (usb_complete_t)rx_iso_complete, + 16); break; case HFC_CHAN_B2: start_isoc_chain(hw->fifos + HFCUSB_B2_RX, - ISOC_PACKETS_B, - (usb_complete_t)rx_iso_complete, - 16); + ISOC_PACKETS_B, + (usb_complete_t)rx_iso_complete, + 16); break; } } @@ -1676,18 +1676,18 @@ hfcsusb_start_endpoint(struct hfcsusb *hw, int channel) switch (channel) { case HFC_CHAN_D: start_isoc_chain(hw->fifos + HFCUSB_D_TX, - ISOC_PACKETS_B, - (usb_complete_t)tx_iso_complete, 1); + ISOC_PACKETS_B, + (usb_complete_t)tx_iso_complete, 1); break; case HFC_CHAN_B1: start_isoc_chain(hw->fifos + HFCUSB_B1_TX, - ISOC_PACKETS_D, - (usb_complete_t)tx_iso_complete, 1); + ISOC_PACKETS_D, + (usb_complete_t)tx_iso_complete, 1); break; case HFC_CHAN_B2: start_isoc_chain(hw->fifos + HFCUSB_B2_TX, - ISOC_PACKETS_B, - (usb_complete_t)tx_iso_complete, 1); + ISOC_PACKETS_B, + (usb_complete_t)tx_iso_complete, 1); break; } } @@ -1708,15 +1708,15 @@ hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel) /* rx endpoints using USB INT IN method */ if (hw->cfg_used == CNF_3INT3ISO || hw->cfg_used == CNF_4INT3ISO) - stop_int_gracefull(hw->fifos + channel*2 + 1); + stop_int_gracefull(hw->fifos + channel * 2 + 1); /* rx endpoints using USB ISO IN method */ if (hw->cfg_used == CNF_3ISO3ISO || hw->cfg_used == CNF_4ISO3ISO) - stop_iso_gracefull(hw->fifos + channel*2 + 1); + stop_iso_gracefull(hw->fifos + channel * 2 + 1); /* tx endpoints using USB ISO OUT method */ if (channel != HFC_CHAN_E) - stop_iso_gracefull(hw->fifos + channel*2); + stop_iso_gracefull(hw->fifos + channel * 2); } @@ -1732,12 +1732,12 @@ setup_hfcsusb(struct hfcsusb *hw) /* check the chip id */ if (read_reg_atomic(hw, HFCUSB_CHIP_ID, &b) != 1) { printk(KERN_DEBUG "%s: %s: cannot read chip id\n", - hw->name, __func__); + hw->name, __func__); return 1; } if (b != HFCUSB_CHIPID) { printk(KERN_DEBUG "%s: %s: Invalid chip id 0x%02x\n", - hw->name, __func__, b); + hw->name, __func__, b); return 1; } @@ -1754,8 +1754,8 @@ setup_hfcsusb(struct hfcsusb *hw) hw->ctrl_write.bRequest = 0; hw->ctrl_write.wLength = 0; usb_fill_control_urb(hw->ctrl_urb, hw->dev, hw->ctrl_out_pipe, - (u_char *)&hw->ctrl_write, NULL, 0, - (usb_complete_t)ctrl_complete, hw); + (u_char *)&hw->ctrl_write, NULL, 0, + (usb_complete_t)ctrl_complete, hw); reset_hfcsusb(hw); return 0; @@ -1806,7 +1806,7 @@ deactivate_bchannel(struct bchannel *bch) if (bch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n", - hw->name, __func__, bch->nr); + hw->name, __func__, bch->nr); spin_lock_irqsave(&hw->lock, flags); mISDN_clear_bchannel(bch); @@ -1848,7 +1848,7 @@ hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) break; default: printk(KERN_WARNING "%s: unknown prim(%x)\n", - __func__, cmd); + __func__, cmd); } return ret; } @@ -1877,7 +1877,7 @@ setup_instance(struct hfcsusb *hw, struct device *parent) mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL); hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | - (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); + (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); hw->dch.dev.nrbchan = 2; for (i = 0; i < 2; i++) { hw->bch[i].nr = i + 1; @@ -1905,9 +1905,9 @@ setup_instance(struct hfcsusb *hw, struct device *parent) goto out; snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME, - hfcsusb_cnt + 1); + hfcsusb_cnt + 1); printk(KERN_INFO "%s: registered as '%s'\n", - DRIVER_NAME, hw->name); + DRIVER_NAME, hw->name); err = mISDN_register_device(&hw->dch.dev, parent, hw->name); if (err) @@ -1937,30 +1937,30 @@ hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) struct usb_host_endpoint *ep; struct hfcsusb_vdata *driver_info; int ifnum = iface->desc.bInterfaceNumber, i, idx, alt_idx, - probe_alt_setting, vend_idx, cfg_used, *vcf, attr, cfg_found, - ep_addr, cmptbl[16], small_match, iso_packet_size, packet_size, - alt_used = 0; + probe_alt_setting, vend_idx, cfg_used, *vcf, attr, cfg_found, + ep_addr, cmptbl[16], small_match, iso_packet_size, packet_size, + alt_used = 0; vend_idx = 0xffff; for (i = 0; hfcsusb_idtab[i].idVendor; i++) { if ((le16_to_cpu(dev->descriptor.idVendor) - == hfcsusb_idtab[i].idVendor) && + == hfcsusb_idtab[i].idVendor) && (le16_to_cpu(dev->descriptor.idProduct) - == hfcsusb_idtab[i].idProduct)) { + == hfcsusb_idtab[i].idProduct)) { vend_idx = i; continue; } } printk(KERN_DEBUG - "%s: interface(%d) actalt(%d) minor(%d) vend_idx(%d)\n", - __func__, ifnum, iface->desc.bAlternateSetting, - intf->minor, vend_idx); + "%s: interface(%d) actalt(%d) minor(%d) vend_idx(%d)\n", + __func__, ifnum, iface->desc.bAlternateSetting, + intf->minor, vend_idx); if (vend_idx == 0xffff) { printk(KERN_WARNING - "%s: no valid vendor found in USB descriptor\n", - __func__); + "%s: no valid vendor found in USB descriptor\n", + __func__); return -EIO; } /* if vendor and product ID is OK, start probing alternate settings */ @@ -1996,17 +1996,17 @@ hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) if (cmptbl[idx] == EP_NUL) cfg_found = 0; if (attr == USB_ENDPOINT_XFER_INT - && cmptbl[idx] == EP_INT) + && cmptbl[idx] == EP_INT) cmptbl[idx] = EP_NUL; if (attr == USB_ENDPOINT_XFER_BULK - && cmptbl[idx] == EP_BLK) + && cmptbl[idx] == EP_BLK) cmptbl[idx] = EP_NUL; if (attr == USB_ENDPOINT_XFER_ISOC - && cmptbl[idx] == EP_ISO) + && cmptbl[idx] == EP_ISO) cmptbl[idx] = EP_NUL; if (attr == USB_ENDPOINT_XFER_INT && - ep->desc.bInterval < vcf[17]) { + ep->desc.bInterval < vcf[17]) { cfg_found = 0; } } @@ -2060,27 +2060,27 @@ hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) switch (ep->desc.bmAttributes) { case USB_ENDPOINT_XFER_INT: f->pipe = usb_rcvintpipe(dev, - ep->desc.bEndpointAddress); + ep->desc.bEndpointAddress); f->usb_transfer_mode = USB_INT; packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); break; case USB_ENDPOINT_XFER_BULK: if (ep_addr & 0x80) f->pipe = usb_rcvbulkpipe(dev, - ep->desc.bEndpointAddress); + ep->desc.bEndpointAddress); else f->pipe = usb_sndbulkpipe(dev, - ep->desc.bEndpointAddress); + ep->desc.bEndpointAddress); f->usb_transfer_mode = USB_BULK; packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); break; case USB_ENDPOINT_XFER_ISOC: if (ep_addr & 0x80) f->pipe = usb_rcvisocpipe(dev, - ep->desc.bEndpointAddress); + ep->desc.bEndpointAddress); else f->pipe = usb_sndisocpipe(dev, - ep->desc.bEndpointAddress); + ep->desc.bEndpointAddress); f->usb_transfer_mode = USB_ISOC; iso_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); break; @@ -2092,7 +2092,7 @@ hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) f->fifonum = idx & 7; f->hw = hw; f->usb_packet_maxlen = - le16_to_cpu(ep->desc.wMaxPacketSize); + le16_to_cpu(ep->desc.wMaxPacketSize); f->intervall = ep->desc.bInterval; } ep++; @@ -2114,8 +2114,8 @@ hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) driver_info = (struct hfcsusb_vdata *)hfcsusb_idtab[vend_idx].driver_info; printk(KERN_DEBUG "%s: %s: detected \"%s\" (%s, if=%d alt=%d)\n", - hw->name, __func__, driver_info->vend_name, - conf_str[small_match], ifnum, alt_used); + hw->name, __func__, driver_info->vend_name, + conf_str[small_match], ifnum, alt_used); if (setup_instance(hw, dev->dev.parent)) return -EIO; diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.h b/drivers/isdn/hardware/mISDN/hfcsusb.h index 369196adae03..cb1231b08f78 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.h +++ b/drivers/isdn/hardware/mISDN/hfcsusb.h @@ -36,10 +36,10 @@ #define NT_ACTIVATION_TIMER 0x01 /* enables NT mode activation Timer */ #define NT_T1_COUNT 10 -#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ +#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ -#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ -#define HFCUSB_TX_THRESHOLD 96 /* threshold for fifo report bit tx */ +#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ +#define HFCUSB_TX_THRESHOLD 96 /* threshold for fifo report bit tx */ #define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ #define HFCUSB_CIRM 0x00 /* cirm register index */ @@ -90,8 +90,8 @@ /* defines how much ISO packets are handled in one URB */ static int iso_packets[8] = - { ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, - ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D +{ ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, + ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D }; @@ -100,15 +100,15 @@ static int iso_packets[8] = #define SINK_MIN 48 #define SINK_DMIN 12 #define SINK_DMAX 18 -#define BITLINE_INF (-96*8) +#define BITLINE_INF (-96 * 8) /* HFC-S USB register access by Control-URSs */ -#define write_reg_atomic(a, b, c) \ +#define write_reg_atomic(a, b, c) \ usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), \ - 0, 0, HFC_CTRL_TIMEOUT) -#define read_reg_atomic(a, b, c) \ + 0, 0, HFC_CTRL_TIMEOUT) +#define read_reg_atomic(a, b, c) \ usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), \ - 1, HFC_CTRL_TIMEOUT) + 1, HFC_CTRL_TIMEOUT) #define HFC_CTRL_BUFSIZE 64 struct ctrl_buf { @@ -222,7 +222,7 @@ static char *conf_str[] = { #define LED_B2_DATA 10 #define LED_NORMAL 0 /* LEDs are normal */ -#define LED_INVERTED 1 /* LEDs are inverted */ +#define LED_INVERTED 1 /* LEDs are inverted */ /* time in ms to perform a Flashing LED when B-Channel has traffic */ #define LED_TIME 250 @@ -258,7 +258,7 @@ struct usb_fifo { __u8 usb_transfer_mode; /* switched between ISO and INT */ struct iso_urb iso[2]; /* two urbs to have one always - one pending */ + one pending */ struct dchannel *dch; /* link to hfcsusb_t->dch */ struct bchannel *bch; /* link to hfcsusb_t->bch */ @@ -339,76 +339,76 @@ static const char *HFC_NT_LAYER1_STATES[HFC_MAX_NT_LAYER1_STATE + 1] = { /* supported devices */ static struct usb_device_id hfcsusb_idtab[] = { { - USB_DEVICE(0x0959, 0x2bd0), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_OFF, {4, 0, 2, 1}, - "ISDN USB TA (Cologne Chip HFC-S USB based)"}), + USB_DEVICE(0x0959, 0x2bd0), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_OFF, {4, 0, 2, 1}, + "ISDN USB TA (Cologne Chip HFC-S USB based)"}), }, { - USB_DEVICE(0x0675, 0x1688), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {1, 2, 0, 0}, - "DrayTek miniVigor 128 USB ISDN TA"}), + USB_DEVICE(0x0675, 0x1688), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {1, 2, 0, 0}, + "DrayTek miniVigor 128 USB ISDN TA"}), }, { - USB_DEVICE(0x07b0, 0x0007), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Billion tiny USB ISDN TA 128"}), + USB_DEVICE(0x07b0, 0x0007), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Billion tiny USB ISDN TA 128"}), }, { - USB_DEVICE(0x0742, 0x2008), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {4, 0, 2, 1}, - "Stollmann USB TA"}), + USB_DEVICE(0x0742, 0x2008), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {4, 0, 2, 1}, + "Stollmann USB TA"}), }, { - USB_DEVICE(0x0742, 0x2009), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {4, 0, 2, 1}, - "Aceex USB ISDN TA"}), + USB_DEVICE(0x0742, 0x2009), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {4, 0, 2, 1}, + "Aceex USB ISDN TA"}), }, { - USB_DEVICE(0x0742, 0x200A), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {4, 0, 2, 1}, - "OEM USB ISDN TA"}), + USB_DEVICE(0x0742, 0x200A), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {4, 0, 2, 1}, + "OEM USB ISDN TA"}), }, { - USB_DEVICE(0x08e3, 0x0301), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {2, 0, 1, 4}, - "Olitec USB RNIS"}), + USB_DEVICE(0x08e3, 0x0301), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {2, 0, 1, 4}, + "Olitec USB RNIS"}), }, { - USB_DEVICE(0x07fa, 0x0846), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Bewan Modem RNIS USB"}), + USB_DEVICE(0x07fa, 0x0846), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Bewan Modem RNIS USB"}), }, { - USB_DEVICE(0x07fa, 0x0847), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Djinn Numeris USB"}), + USB_DEVICE(0x07fa, 0x0847), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Djinn Numeris USB"}), }, { - USB_DEVICE(0x07b0, 0x0006), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Twister ISDN TA"}), + USB_DEVICE(0x07b0, 0x0006), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Twister ISDN TA"}), }, { - USB_DEVICE(0x071d, 0x1005), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {0x02, 0, 0x01, 0x04}, - "Eicon DIVA USB 4.0"}), + USB_DEVICE(0x071d, 0x1005), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {0x02, 0, 0x01, 0x04}, + "Eicon DIVA USB 4.0"}), }, { - USB_DEVICE(0x0586, 0x0102), - .driver_info = (unsigned long) &((struct hfcsusb_vdata) - {LED_SCHEME1, {0x88, -64, -32, -16}, - "ZyXEL OMNI.NET USB II"}), + USB_DEVICE(0x0586, 0x0102), + .driver_info = (unsigned long) &((struct hfcsusb_vdata) + {LED_SCHEME1, {0x88, -64, -32, -16}, + "ZyXEL OMNI.NET USB II"}), }, { } }; diff --git a/drivers/isdn/hardware/mISDN/iohelper.h b/drivers/isdn/hardware/mISDN/iohelper.h index b438981107ae..c3e7bb1daa24 100644 --- a/drivers/isdn/hardware/mISDN/iohelper.h +++ b/drivers/isdn/hardware/mISDN/iohelper.h @@ -27,83 +27,83 @@ #define _IOHELPER_H typedef u8 (read_reg_func)(void *hwp, u8 offset); -typedef void (write_reg_func)(void *hwp, u8 offset, u8 value); -typedef void (fifo_func)(void *hwp, u8 offset, u8 *datap, int size); + typedef void (write_reg_func)(void *hwp, u8 offset, u8 value); + typedef void (fifo_func)(void *hwp, u8 offset, u8 *datap, int size); -struct _ioport { - u32 port; - u32 ale; -}; + struct _ioport { + u32 port; + u32 ale; + }; -#define IOFUNC_IO(name, hws, ap) \ - static u8 Read##name##_IO(void *p, u8 off) {\ - struct hws *hw = p;\ - return inb(hw->ap.port + off);\ - } \ - static void Write##name##_IO(void *p, u8 off, u8 val) {\ - struct hws *hw = p;\ - outb(val, hw->ap.port + off);\ - } \ - static void ReadFiFo##name##_IO(void *p, u8 off, u8 *dp, int size) {\ - struct hws *hw = p;\ - insb(hw->ap.port + off, dp, size);\ - } \ - static void WriteFiFo##name##_IO(void *p, u8 off, u8 *dp, int size) {\ - struct hws *hw = p;\ - outsb(hw->ap.port + off, dp, size);\ +#define IOFUNC_IO(name, hws, ap) \ + static u8 Read##name##_IO(void *p, u8 off) { \ + struct hws *hw = p; \ + return inb(hw->ap.port + off); \ + } \ + static void Write##name##_IO(void *p, u8 off, u8 val) { \ + struct hws *hw = p; \ + outb(val, hw->ap.port + off); \ + } \ + static void ReadFiFo##name##_IO(void *p, u8 off, u8 *dp, int size) { \ + struct hws *hw = p; \ + insb(hw->ap.port + off, dp, size); \ + } \ + static void WriteFiFo##name##_IO(void *p, u8 off, u8 *dp, int size) { \ + struct hws *hw = p; \ + outsb(hw->ap.port + off, dp, size); \ } -#define IOFUNC_IND(name, hws, ap) \ - static u8 Read##name##_IND(void *p, u8 off) {\ - struct hws *hw = p;\ - outb(off, hw->ap.ale);\ - return inb(hw->ap.port);\ - } \ - static void Write##name##_IND(void *p, u8 off, u8 val) {\ - struct hws *hw = p;\ - outb(off, hw->ap.ale);\ - outb(val, hw->ap.port);\ - } \ - static void ReadFiFo##name##_IND(void *p, u8 off, u8 *dp, int size) {\ - struct hws *hw = p;\ - outb(off, hw->ap.ale);\ - insb(hw->ap.port, dp, size);\ - } \ - static void WriteFiFo##name##_IND(void *p, u8 off, u8 *dp, int size) {\ - struct hws *hw = p;\ - outb(off, hw->ap.ale);\ - outsb(hw->ap.port, dp, size);\ +#define IOFUNC_IND(name, hws, ap) \ + static u8 Read##name##_IND(void *p, u8 off) { \ + struct hws *hw = p; \ + outb(off, hw->ap.ale); \ + return inb(hw->ap.port); \ + } \ + static void Write##name##_IND(void *p, u8 off, u8 val) { \ + struct hws *hw = p; \ + outb(off, hw->ap.ale); \ + outb(val, hw->ap.port); \ + } \ + static void ReadFiFo##name##_IND(void *p, u8 off, u8 *dp, int size) { \ + struct hws *hw = p; \ + outb(off, hw->ap.ale); \ + insb(hw->ap.port, dp, size); \ + } \ + static void WriteFiFo##name##_IND(void *p, u8 off, u8 *dp, int size) { \ + struct hws *hw = p; \ + outb(off, hw->ap.ale); \ + outsb(hw->ap.port, dp, size); \ } -#define IOFUNC_MEMIO(name, hws, typ, adr) \ - static u8 Read##name##_MIO(void *p, u8 off) {\ - struct hws *hw = p;\ - return readb(((typ *)hw->adr) + off);\ - } \ - static void Write##name##_MIO(void *p, u8 off, u8 val) {\ - struct hws *hw = p;\ - writeb(val, ((typ *)hw->adr) + off);\ - } \ - static void ReadFiFo##name##_MIO(void *p, u8 off, u8 *dp, int size) {\ - struct hws *hw = p;\ - while (size--)\ - *dp++ = readb(((typ *)hw->adr) + off);\ - } \ - static void WriteFiFo##name##_MIO(void *p, u8 off, u8 *dp, int size) {\ - struct hws *hw = p;\ - while (size--)\ - writeb(*dp++, ((typ *)hw->adr) + off);\ +#define IOFUNC_MEMIO(name, hws, typ, adr) \ + static u8 Read##name##_MIO(void *p, u8 off) { \ + struct hws *hw = p; \ + return readb(((typ *)hw->adr) + off); \ + } \ + static void Write##name##_MIO(void *p, u8 off, u8 val) { \ + struct hws *hw = p; \ + writeb(val, ((typ *)hw->adr) + off); \ + } \ + static void ReadFiFo##name##_MIO(void *p, u8 off, u8 *dp, int size) { \ + struct hws *hw = p; \ + while (size--) \ + *dp++ = readb(((typ *)hw->adr) + off); \ + } \ + static void WriteFiFo##name##_MIO(void *p, u8 off, u8 *dp, int size) { \ + struct hws *hw = p; \ + while (size--) \ + writeb(*dp++, ((typ *)hw->adr) + off); \ } -#define ASSIGN_FUNC(typ, name, dest) do {\ - dest.read_reg = &Read##name##_##typ;\ - dest.write_reg = &Write##name##_##typ;\ - dest.read_fifo = &ReadFiFo##name##_##typ;\ - dest.write_fifo = &WriteFiFo##name##_##typ;\ +#define ASSIGN_FUNC(typ, name, dest) do { \ + dest.read_reg = &Read##name##_##typ; \ + dest.write_reg = &Write##name##_##typ; \ + dest.read_fifo = &ReadFiFo##name##_##typ; \ + dest.write_fifo = &WriteFiFo##name##_##typ; \ } while (0) -#define ASSIGN_FUNC_IPAC(typ, target) do {\ - ASSIGN_FUNC(typ, ISAC, target.isac);\ - ASSIGN_FUNC(typ, IPAC, target);\ +#define ASSIGN_FUNC_IPAC(typ, target) do { \ + ASSIGN_FUNC(typ, ISAC, target.isac); \ + ASSIGN_FUNC(typ, IPAC, target); \ } while (0) #endif diff --git a/drivers/isdn/hardware/mISDN/isar.h b/drivers/isdn/hardware/mISDN/isar.h index 9962bdf699c7..cadfc49c9207 100644 --- a/drivers/isdn/hardware/mISDN/isar.h +++ b/drivers/isdn/hardware/mISDN/isar.h @@ -97,7 +97,7 @@ struct isar_hw { #define ISAR_HIS_SDATA 0x20 #define ISAR_HIS_DPS1 0x40 #define ISAR_HIS_DPS2 0x80 -#define SET_DPS(x) ((x<<6) & 0xc0) +#define SET_DPS(x) ((x << 6) & 0xc0) #define ISAR_IIS_MSCMSD 0x3f #define ISAR_IIS_VNR 0x15 diff --git a/drivers/isdn/hardware/mISDN/mISDNinfineon.c b/drivers/isdn/hardware/mISDN/mISDNinfineon.c index 6218775ce87d..631eb3fa63cf 100644 --- a/drivers/isdn/hardware/mISDN/mISDNinfineon.c +++ b/drivers/isdn/hardware/mISDN/mISDNinfineon.c @@ -431,11 +431,11 @@ enable_hwirq(struct inf_hw *hw) break; case INF_GAZEL_R685: outb(GAZEL_ISAC_EN + GAZEL_HSCX_EN + GAZEL_PCI_EN, - (u32)hw->cfg.start + GAZEL_INCSR); + (u32)hw->cfg.start + GAZEL_INCSR); break; case INF_GAZEL_R753: outb(GAZEL_IPAC_EN + GAZEL_PCI_EN, - (u32)hw->cfg.start + GAZEL_INCSR); + (u32)hw->cfg.start + GAZEL_INCSR); break; default: break; @@ -511,21 +511,21 @@ reset_inf(struct inf_hw *hw) /* Workaround PCI9060 */ outb(9, (u32)hw->cfg.start + 0x69); outb(DIVA_RESET_BIT | DIVA_LED_A, - (u32)hw->cfg.start + DIVA_PCI_CTRL); + (u32)hw->cfg.start + DIVA_PCI_CTRL); break; case INF_DIVA201: writel(PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE, - hw->cfg.p + PITA_MISC_REG); + hw->cfg.p + PITA_MISC_REG); mdelay(1); writel(PITA_PARA_MPX_MODE, hw->cfg.p + PITA_MISC_REG); mdelay(10); break; case INF_DIVA202: writel(PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE, - hw->cfg.p + PITA_MISC_REG); + hw->cfg.p + PITA_MISC_REG); mdelay(1); writel(PITA_PARA_MPX_MODE | PITA_SER_SOFTRESET, - hw->cfg.p + PITA_MISC_REG); + hw->cfg.p + PITA_MISC_REG); mdelay(10); break; case INF_SPEEDWIN: @@ -630,7 +630,7 @@ init_irq(struct inf_hw *hw) msleep_interruptible(10); if (debug & DEBUG_HW) pr_notice("%s: IRQ %d count %d\n", hw->name, - hw->irq, hw->irqcnt); + hw->irq, hw->irqcnt); if (!hw->irqcnt) { pr_info("%s: IRQ(%d) got no requests during init %d\n", hw->name, hw->irq, 3 - cnt); @@ -672,11 +672,11 @@ setup_io(struct inf_hw *hw) hw->cfg.size = pci_resource_len(hw->pdev, hw->ci->cfg_bar); if (hw->ci->cfg_mode == AM_MEMIO) { if (!request_mem_region(hw->cfg.start, hw->cfg.size, - hw->name)) + hw->name)) err = -EBUSY; } else { if (!request_region(hw->cfg.start, hw->cfg.size, - hw->name)) + hw->name)) err = -EBUSY; } if (err) { @@ -690,8 +690,8 @@ setup_io(struct inf_hw *hw) hw->cfg.mode = hw->ci->cfg_mode; if (debug & DEBUG_HW) pr_notice("%s: IO cfg %lx (%lu bytes) mode%d\n", - hw->name, (ulong)hw->cfg.start, - (ulong)hw->cfg.size, hw->ci->cfg_mode); + hw->name, (ulong)hw->cfg.start, + (ulong)hw->cfg.size, hw->ci->cfg_mode); } if (hw->ci->addr_mode) { @@ -699,11 +699,11 @@ setup_io(struct inf_hw *hw) hw->addr.size = pci_resource_len(hw->pdev, hw->ci->addr_bar); if (hw->ci->addr_mode == AM_MEMIO) { if (!request_mem_region(hw->addr.start, hw->addr.size, - hw->name)) + hw->name)) err = -EBUSY; } else { if (!request_region(hw->addr.start, hw->addr.size, - hw->name)) + hw->name)) err = -EBUSY; } if (err) { @@ -717,8 +717,8 @@ setup_io(struct inf_hw *hw) hw->addr.mode = hw->ci->addr_mode; if (debug & DEBUG_HW) pr_notice("%s: IO addr %lx (%lu bytes) mode%d\n", - hw->name, (ulong)hw->addr.start, - (ulong)hw->addr.size, hw->ci->addr_mode); + hw->name, (ulong)hw->addr.start, + (ulong)hw->addr.size, hw->ci->addr_mode); } @@ -903,7 +903,7 @@ setup_instance(struct inf_hw *card) ulong flags; snprintf(card->name, MISDN_MAX_IDLEN - 1, "%s.%d", card->ci->name, - inf_cnt + 1); + inf_cnt + 1); write_lock_irqsave(&card_lock, flags); list_add_tail(&card->list, &Cards); write_unlock_irqrestore(&card_lock, flags); @@ -928,7 +928,7 @@ setup_instance(struct inf_hw *card) goto error_setup; err = mISDN_register_device(&card->ipac.isac.dch.dev, - &card->pdev->dev, card->name); + &card->pdev->dev, card->name); if (err) goto error; @@ -1099,7 +1099,7 @@ inf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return -EINVAL; } else pr_notice("mISDN: found adapter %s at %s\n", - card->ci->full, pci_name(pdev)); + card->ci->full, pci_name(pdev)); card->irq = pdev->irq; pci_set_drvdata(pdev, card); diff --git a/drivers/isdn/hardware/mISDN/mISDNipac.c b/drivers/isdn/hardware/mISDN/mISDNipac.c index d2ffb1d9b831..b47e9bed2185 100644 --- a/drivers/isdn/hardware/mISDN/mISDNipac.c +++ b/drivers/isdn/hardware/mISDN/mISDNipac.c @@ -129,7 +129,7 @@ isac_empty_fifo(struct isac_hw *isac, int count) } if ((isac->dch.rx_skb->len + count) >= isac->dch.maxlen) { pr_debug("%s: %s overrun %d\n", isac->name, __func__, - isac->dch.rx_skb->len + count); + isac->dch.rx_skb->len + count); WriteISAC(isac, ISAC_CMDR, 0x80); return; } @@ -140,7 +140,7 @@ isac_empty_fifo(struct isac_hw *isac, int count) char pfx[MISDN_MAX_IDLEN + 16]; snprintf(pfx, MISDN_MAX_IDLEN + 15, "D-recv %s %d ", - isac->name, count); + isac->name, count); print_hex_dump_bytes(pfx, DUMP_PREFIX_OFFSET, ptr, count); } } @@ -178,7 +178,7 @@ isac_fill_fifo(struct isac_hw *isac) char pfx[MISDN_MAX_IDLEN + 16]; snprintf(pfx, MISDN_MAX_IDLEN + 15, "D-send %s %d ", - isac->name, count); + isac->name, count); print_hex_dump_bytes(pfx, DUMP_PREFIX_OFFSET, ptr, count); } } @@ -283,7 +283,7 @@ isac_mos_irq(struct isac_hw *isac) } isac->mon_rx[isac->mon_rxp++] = ReadISAC(isac, ISAC_MOR0); pr_debug("%s: ISAC MOR0 %02x\n", isac->name, - isac->mon_rx[isac->mon_rxp - 1]); + isac->mon_rx[isac->mon_rxp - 1]); if (isac->mon_rxp == 1) { isac->mocr |= 0x04; WriteISAC(isac, ISAC_MOCR, isac->mocr); @@ -313,7 +313,7 @@ isac_mos_irq(struct isac_hw *isac) } isac->mon_rx[isac->mon_rxp++] = ReadISAC(isac, ISAC_MOR1); pr_debug("%s: ISAC MOR1 %02x\n", isac->name, - isac->mon_rx[isac->mon_rxp - 1]); + isac->mon_rx[isac->mon_rxp - 1]); isac->mocr |= 0x40; WriteISAC(isac, ISAC_MOCR, isac->mocr); } @@ -325,7 +325,7 @@ isac_mos_irq(struct isac_hw *isac) WriteISAC(isac, ISAC_MOCR, isac->mocr); if (isac->monitor) { ret = isac->monitor(isac->dch.hw, MONITOR_RX_0, - isac->mon_rx, isac->mon_rxp); + isac->mon_rx, isac->mon_rxp); if (ret) kfree(isac->mon_rx); } else { @@ -343,7 +343,7 @@ isac_mos_irq(struct isac_hw *isac) WriteISAC(isac, ISAC_MOCR, isac->mocr); if (isac->monitor) { ret = isac->monitor(isac->dch.hw, MONITOR_RX_1, - isac->mon_rx, isac->mon_rxp); + isac->mon_rx, isac->mon_rxp); if (ret) kfree(isac->mon_rx); } else { @@ -356,7 +356,7 @@ isac_mos_irq(struct isac_hw *isac) } if (val & 0x02) { if ((!isac->mon_tx) || (isac->mon_txc && - (isac->mon_txp >= isac->mon_txc) && !(val & 0x08))) { + (isac->mon_txp >= isac->mon_txc) && !(val & 0x08))) { isac->mocr &= 0xf0; WriteISAC(isac, ISAC_MOCR, isac->mocr); isac->mocr |= 0x0a; @@ -364,7 +364,7 @@ isac_mos_irq(struct isac_hw *isac) if (isac->mon_txc && (isac->mon_txp >= isac->mon_txc)) { if (isac->monitor) ret = isac->monitor(isac->dch.hw, - MONITOR_TX_0, NULL, 0); + MONITOR_TX_0, NULL, 0); } kfree(isac->mon_tx); isac->mon_tx = NULL; @@ -375,7 +375,7 @@ isac_mos_irq(struct isac_hw *isac) if (isac->mon_txc && (isac->mon_txp >= isac->mon_txc)) { if (isac->monitor) ret = isac->monitor(isac->dch.hw, - MONITOR_TX_0, NULL, 0); + MONITOR_TX_0, NULL, 0); kfree(isac->mon_tx); isac->mon_tx = NULL; isac->mon_txc = 0; @@ -384,12 +384,12 @@ isac_mos_irq(struct isac_hw *isac) } WriteISAC(isac, ISAC_MOX0, isac->mon_tx[isac->mon_txp++]); pr_debug("%s: ISAC %02x -> MOX0\n", isac->name, - isac->mon_tx[isac->mon_txp - 1]); + isac->mon_tx[isac->mon_txp - 1]); } AfterMOX0: if (val & 0x20) { if ((!isac->mon_tx) || (isac->mon_txc && - (isac->mon_txp >= isac->mon_txc) && !(val & 0x80))) { + (isac->mon_txp >= isac->mon_txc) && !(val & 0x80))) { isac->mocr &= 0x0f; WriteISAC(isac, ISAC_MOCR, isac->mocr); isac->mocr |= 0xa0; @@ -397,7 +397,7 @@ isac_mos_irq(struct isac_hw *isac) if (isac->mon_txc && (isac->mon_txp >= isac->mon_txc)) { if (isac->monitor) ret = isac->monitor(isac->dch.hw, - MONITOR_TX_1, NULL, 0); + MONITOR_TX_1, NULL, 0); } kfree(isac->mon_tx); isac->mon_tx = NULL; @@ -408,7 +408,7 @@ isac_mos_irq(struct isac_hw *isac) if (isac->mon_txc && (isac->mon_txp >= isac->mon_txc)) { if (isac->monitor) ret = isac->monitor(isac->dch.hw, - MONITOR_TX_1, NULL, 0); + MONITOR_TX_1, NULL, 0); kfree(isac->mon_tx); isac->mon_tx = NULL; isac->mon_txc = 0; @@ -417,7 +417,7 @@ isac_mos_irq(struct isac_hw *isac) } WriteISAC(isac, ISAC_MOX1, isac->mon_tx[isac->mon_txp++]); pr_debug("%s: ISAC %02x -> MOX1\n", isac->name, - isac->mon_tx[isac->mon_txp - 1]); + isac->mon_tx[isac->mon_txp - 1]); } AfterMOX1: val = 0; /* dummy to avoid warning */ @@ -432,7 +432,7 @@ isac_cisq_irq(struct isac_hw *isac) { pr_debug("%s: ISAC CIR0 %02X\n", isac->name, val); if (val & 2) { pr_debug("%s: ph_state change %x->%x\n", isac->name, - isac->state, (val >> 2) & 0xf); + isac->state, (val >> 2) & 0xf); isac->state = (val >> 2) & 0xf; isac_ph_state_change(isac); } @@ -451,7 +451,7 @@ isacsx_cic_irq(struct isac_hw *isac) pr_debug("%s: ISACX CIR0 %02X\n", isac->name, val); if (val & ISACX_CIR0_CIC0) { pr_debug("%s: ph_state change %x->%x\n", isac->name, - isac->state, val >> 4); + isac->state, val >> 4); isac->state = val >> 4; isac_ph_state_change(isac); } @@ -488,7 +488,7 @@ isacsx_rme_irq(struct isac_hw *isac) if (isac->dch.rx_skb) { skb_trim(isac->dch.rx_skb, isac->dch.rx_skb->len - 1); pr_debug("%s: dchannel received %d\n", isac->name, - isac->dch.rx_skb->len); + isac->dch.rx_skb->len); recv_Dchannel(&isac->dch); } } @@ -628,7 +628,7 @@ isac_ctrl(struct isac_hw *isac, u32 cmd, u_long para) break; default: pr_debug("%s: %s unknown command %x %lx\n", isac->name, - __func__, cmd, para); + __func__, cmd, para); return -1; } return 0; @@ -685,16 +685,16 @@ isac_l1cmd(struct dchannel *dch, u32 cmd) case PH_ACTIVATE_IND: test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; case PH_DEACTIVATE_IND: test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; default: pr_debug("%s: %s unknown command %x\n", isac->name, - __func__, cmd); + __func__, cmd); return -1; } return 0; @@ -731,7 +731,7 @@ dbusy_timer_handler(struct isac_hw *isac) rbch = ReadISAC(isac, ISAC_RBCH); star = ReadISAC(isac, ISAC_STAR); pr_debug("%s: D-Channel Busy RBCH %02x STAR %02x\n", - isac->name, rbch, star); + isac->name, rbch, star); if (rbch & ISAC_RBCH_XAC) /* D-Channel Busy */ test_and_set_bit(FLG_L1_BUSY, &isac->dch.Flags); else { @@ -753,7 +753,7 @@ static int open_dchannel(struct isac_hw *isac, struct channel_req *rq) { pr_debug("%s: %s dev(%d) open from %p\n", isac->name, __func__, - isac->dch.dev.id, __builtin_return_address(1)); + isac->dch.dev.id, __builtin_return_address(1)); if (rq->protocol != ISDN_P_TE_S0) return -EINVAL; if (rq->adr.channel == 1) @@ -763,7 +763,7 @@ open_dchannel(struct isac_hw *isac, struct channel_req *rq) rq->ch->protocol = rq->protocol; if (isac->dch.state == 7) _queue_data(rq->ch, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); return 0; } @@ -807,7 +807,7 @@ isac_init(struct isac_hw *isac) val = ReadISAC(isac, ISACX_ID); if (isac->dch.debug & DEBUG_HW) pr_notice("%s: ISACX Design ID %x\n", - isac->name, val & 0x3f); + isac->name, val & 0x3f); val = ReadISAC(isac, ISACX_CIR0); pr_debug("%s: ISACX CIR0 %02X\n", isac->name, val); isac->state = val >> 4; @@ -832,7 +832,7 @@ isac_init(struct isac_hw *isac) val = ReadISAC(isac, ISAC_RBCH); if (isac->dch.debug & DEBUG_HW) pr_notice("%s: ISAC version (%x): %s\n", isac->name, - val, ISACVer[(val >> 5) & 3]); + val, ISACVer[(val >> 5) & 3]); isac->type |= ((val >> 5) & 3); if (!isac->adf2) isac->adf2 = 0x80; @@ -889,7 +889,7 @@ waitforCEC(struct hscx_hw *hx) } if (to < 50) pr_debug("%s: B%1d CEC %d us\n", hx->ip->name, hx->bch.nr, - 50 - to); + 50 - to); if (!to) pr_info("%s: B%1d CEC timeout\n", hx->ip->name, hx->bch.nr); } @@ -909,7 +909,7 @@ waitforXFW(struct hscx_hw *hx) } if (to < 50) pr_debug("%s: B%1d XFW %d us\n", hx->ip->name, hx->bch.nr, - 50 - to); + 50 - to); if (!to) pr_info("%s: B%1d XFW timeout\n", hx->ip->name, hx->bch.nr); } @@ -942,7 +942,7 @@ hscx_empty_fifo(struct hscx_hw *hscx, u8 count) } if ((hscx->bch.rx_skb->len + count) > hscx->bch.maxlen) { pr_debug("%s: overrun %d\n", hscx->ip->name, - hscx->bch.rx_skb->len + count); + hscx->bch.rx_skb->len + count); skb_trim(hscx->bch.rx_skb, 0); hscx_cmdr(hscx, 0x80); /* RMC */ return; @@ -951,16 +951,16 @@ hscx_empty_fifo(struct hscx_hw *hscx, u8 count) if (hscx->ip->type & IPAC_TYPE_IPACX) hscx->ip->read_fifo(hscx->ip->hw, - hscx->off + IPACX_RFIFOB, p, count); + hscx->off + IPACX_RFIFOB, p, count); else hscx->ip->read_fifo(hscx->ip->hw, - hscx->off, p, count); + hscx->off, p, count); hscx_cmdr(hscx, 0x80); /* RMC */ if (hscx->bch.debug & DEBUG_HW_BFIFO) { snprintf(hscx->log, 64, "B%1d-recv %s %d ", - hscx->bch.nr, hscx->ip->name, count); + hscx->bch.nr, hscx->ip->name, count); print_hex_dump_bytes(hscx->log, DUMP_PREFIX_OFFSET, p, count); } } @@ -984,22 +984,22 @@ hscx_fill_fifo(struct hscx_hw *hscx) more = 1; } pr_debug("%s: B%1d %d/%d/%d\n", hscx->ip->name, hscx->bch.nr, count, - hscx->bch.tx_idx, hscx->bch.tx_skb->len); + hscx->bch.tx_idx, hscx->bch.tx_skb->len); hscx->bch.tx_idx += count; if (hscx->ip->type & IPAC_TYPE_IPACX) hscx->ip->write_fifo(hscx->ip->hw, - hscx->off + IPACX_XFIFOB, p, count); + hscx->off + IPACX_XFIFOB, p, count); else { waitforXFW(hscx); hscx->ip->write_fifo(hscx->ip->hw, - hscx->off, p, count); + hscx->off, p, count); } hscx_cmdr(hscx, more ? 0x08 : 0x0a); if (hscx->bch.debug & DEBUG_HW_BFIFO) { snprintf(hscx->log, 64, "B%1d-send %s %d ", - hscx->bch.nr, hscx->ip->name, count); + hscx->bch.nr, hscx->ip->name, count); print_hex_dump_bytes(hscx->log, DUMP_PREFIX_OFFSET, p, count); } } @@ -1037,18 +1037,18 @@ ipac_rme(struct hscx_hw *hx) if (!(rstab & 0x80)) { if (hx->bch.debug & DEBUG_HW_BCHANNEL) pr_notice("%s: B%1d invalid frame\n", - hx->ip->name, hx->bch.nr); + hx->ip->name, hx->bch.nr); } if (rstab & 0x40) { if (hx->bch.debug & DEBUG_HW_BCHANNEL) pr_notice("%s: B%1d RDO proto=%x\n", - hx->ip->name, hx->bch.nr, - hx->bch.state); + hx->ip->name, hx->bch.nr, + hx->bch.state); } if (!(rstab & 0x20)) { if (hx->bch.debug & DEBUG_HW_BCHANNEL) pr_notice("%s: B%1d CRC error\n", - hx->ip->name, hx->bch.nr); + hx->ip->name, hx->bch.nr); } hscx_cmdr(hx, 0x80); /* Do RMC */ return; @@ -1065,7 +1065,7 @@ ipac_rme(struct hscx_hw *hx) return; if (hx->bch.rx_skb->len < 2) { pr_debug("%s: B%1d frame to short %d\n", - hx->ip->name, hx->bch.nr, hx->bch.rx_skb->len); + hx->ip->name, hx->bch.nr, hx->bch.rx_skb->len); skb_trim(hx->bch.rx_skb, 0); } else { skb_trim(hx->bch.rx_skb, hx->bch.rx_skb->len - 1); @@ -1086,7 +1086,7 @@ ipac_irq(struct hscx_hw *hx, u8 ista) if (m & ista) { exirb = ReadHSCX(hx, IPAC_EXIRB); pr_debug("%s: B%1d EXIRB %02x\n", hx->ip->name, - hx->bch.nr, exirb); + hx->bch.nr, exirb); } } else if (hx->bch.nr & 2) { /* HSCX B */ if (ista & (HSCX__EXA | HSCX__ICA)) @@ -1094,7 +1094,7 @@ ipac_irq(struct hscx_hw *hx, u8 ista) if (ista & HSCX__EXB) { exirb = ReadHSCX(hx, IPAC_EXIRB); pr_debug("%s: B%1d EXIRB %02x\n", hx->ip->name, - hx->bch.nr, exirb); + hx->bch.nr, exirb); } istab = ista & 0xF8; } else { /* HSCX A */ @@ -1102,7 +1102,7 @@ ipac_irq(struct hscx_hw *hx, u8 ista) if (ista & HSCX__EXA) { exirb = ReadHSCX(hx, IPAC_EXIRB); pr_debug("%s: B%1d EXIRB %02x\n", hx->ip->name, - hx->bch.nr, exirb); + hx->bch.nr, exirb); } istab = istab & 0xF8; } @@ -1141,7 +1141,7 @@ ipac_irq(struct hscx_hw *hx, u8 ista) return; } pr_debug("%s: B%1d XDU error at len %d\n", hx->ip->name, - hx->bch.nr, hx->bch.tx_idx); + hx->bch.nr, hx->bch.tx_idx); hx->bch.tx_idx = 0; hscx_cmdr(hx, 0x01); /* XRES */ } @@ -1204,10 +1204,10 @@ mISDNipac_irq(struct ipac_hw *ipac, int maxloop) return IRQ_NONE; if (cnt < maxloop) pr_debug("%s: %d irqloops cpu%d\n", ipac->name, - maxloop - cnt, smp_processor_id()); + maxloop - cnt, smp_processor_id()); if (maxloop && !cnt) pr_notice("%s: %d IRQ LOOP cpu%d\n", ipac->name, - maxloop, smp_processor_id()); + maxloop, smp_processor_id()); return IRQ_HANDLED; } EXPORT_SYMBOL(mISDNipac_irq); @@ -1216,7 +1216,7 @@ static int hscx_mode(struct hscx_hw *hscx, u32 bprotocol) { pr_debug("%s: HSCX %c protocol %x-->%x ch %d\n", hscx->ip->name, - '@' + hscx->bch.nr, hscx->bch.state, bprotocol, hscx->bch.nr); + '@' + hscx->bch.nr, hscx->bch.state, bprotocol, hscx->bch.nr); if (hscx->ip->type & IPAC_TYPE_IPACX) { if (hscx->bch.nr & 1) { /* B1 and ICA */ WriteIPAC(hscx->ip, ISACX_BCHA_TSDP_BC1, 0x80); @@ -1364,7 +1364,7 @@ hscx_l2l1(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(hx->ip->hwlock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: spin_lock_irqsave(hx->ip->hwlock, flags); @@ -1372,7 +1372,7 @@ hscx_l2l1(struct mISDNchannel *ch, struct sk_buff *skb) hscx_mode(hx, ISDN_P_NONE); spin_unlock_irqrestore(hx->ip->hwlock, flags); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); ret = 0; break; default: @@ -1394,7 +1394,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_GETOP: cq->op = 0; break; - /* Nothing implemented yet */ + /* Nothing implemented yet */ case MISDN_CTRL_FILL_EMPTY: default: pr_info("%s: unknown Op %x\n", __func__, cq->op); @@ -1467,7 +1467,7 @@ hscx_init(struct hscx_hw *hx) pr_debug("%s: HSCX VSTR %02x\n", hx->ip->name, val); if (hx->bch.debug & DEBUG_HW) pr_notice("%s: HSCX version %s\n", hx->ip->name, - HSCXVer[val & 0x0f]); + HSCXVer[val & 0x0f]); } else WriteHSCX(hx, IPAC_CCR1, 0x82); WriteHSCX(hx, IPAC_CCR2, 0x30); @@ -1491,7 +1491,7 @@ ipac_init(struct ipac_hw *ipac) val = ReadIPAC(ipac, IPAC_CONF); /* conf is default 0, but can be overwritten by card setup */ pr_debug("%s: IPAC CONF %02x/%02x\n", ipac->name, - val, ipac->conf); + val, ipac->conf); WriteIPAC(ipac, IPAC_CONF, ipac->conf); val = ReadIPAC(ipac, IPAC_ID); if (ipac->hscx[0].bch.debug & DEBUG_HW) @@ -1569,7 +1569,7 @@ ipac_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; case CLOSE_CHANNEL: pr_debug("%s: dev(%d) close from %p\n", ipac->name, - dch->dev.id, __builtin_return_address(0)); + dch->dev.id, __builtin_return_address(0)); module_put(ipac->owner); break; case CONTROL_CHANNEL: @@ -1620,7 +1620,7 @@ mISDNipac_init(struct ipac_hw *ipac, void *hw) ipac->hscx[i].bch.nr = i + 1; set_channelmap(i + 1, ipac->isac.dch.dev.channelmap); list_add(&ipac->hscx[i].bch.ch.list, - &ipac->isac.dch.dev.bchannels); + &ipac->isac.dch.dev.bchannels); mISDN_initbchannel(&ipac->hscx[i].bch, MAX_DATA_MEM); ipac->hscx[i].bch.ch.nr = i + 1; ipac->hscx[i].bch.ch.send = &hscx_l2l1; diff --git a/drivers/isdn/hardware/mISDN/mISDNisar.c b/drivers/isdn/hardware/mISDN/mISDNisar.c index 7034af28d464..10446ab404b5 100644 --- a/drivers/isdn/hardware/mISDN/mISDNisar.c +++ b/drivers/isdn/hardware/mISDN/mISDNisar.c @@ -42,7 +42,7 @@ MODULE_VERSION(ISAR_REV); static const u8 faxmodulation_s[] = "3,24,48,72,73,74,96,97,98,121,122,145,146"; static const u8 faxmodulation[] = {3, 24, 48, 72, 73, 74, 96, 97, 98, 121, - 122, 145, 146}; + 122, 145, 146}; #define FAXMODCNT 13 static void isar_setup(struct isar_hw *); @@ -84,9 +84,9 @@ send_mbox(struct isar_hw *isar, u8 his, u8 creg, u8 len, u8 *msg) while (l < (int)len) { hex_dump_to_buffer(msg + l, len - l, 32, 1, - isar->log, 256, 1); + isar->log, 256, 1); pr_debug("%s: %s %02x: %s\n", isar->name, - __func__, l, isar->log); + __func__, l, isar->log); l += 32; } } @@ -113,9 +113,9 @@ rcv_mbox(struct isar_hw *isar, u8 *msg) while (l < (int)isar->clsb) { hex_dump_to_buffer(msg + l, isar->clsb - l, 32, - 1, isar->log, 256, 1); + 1, isar->log, 256, 1); pr_debug("%s: %s %02x: %s\n", isar->name, - __func__, l, isar->log); + __func__, l, isar->log); l += 32; } } @@ -130,7 +130,7 @@ get_irq_infos(struct isar_hw *isar) isar->cmsb = isar->read_reg(isar->hw, ISAR_CTRL_H); isar->clsb = isar->read_reg(isar->hw, ISAR_CTRL_L); pr_debug("%s: rcv_mbox(%02x,%02x,%d)\n", isar->name, - isar->iis, isar->cmsb, isar->clsb); + isar->iis, isar->cmsb, isar->clsb); } /* @@ -154,7 +154,7 @@ poll_mbox(struct isar_hw *isar, int maxdelay) rcv_mbox(isar, NULL); } pr_debug("%s: pulled %d bytes after %d us\n", - isar->name, isar->clsb, maxdelay - t); + isar->name, isar->clsb, maxdelay - t); return t; } @@ -200,13 +200,13 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) if (1 != isar->version) { pr_err("%s: ISAR wrong version %d firmware download aborted\n", - isar->name, isar->version); + isar->name, isar->version); return -EINVAL; } if (!(saved_debug & DEBUG_HW_FIRMWARE_FIFO)) isar->ch[0].bch.debug &= ~DEBUG_HW_BFIFO; pr_debug("%s: load firmware %d words (%d bytes)\n", - isar->name, size/2, size); + isar->name, size / 2, size); cnt = 0; size /= 2; /* disable ISAR IRQ */ @@ -219,7 +219,7 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) blk_head.d_key = le16_to_cpu(*sp++); cnt += 3; pr_debug("ISAR firmware block (%#x,%d,%#x)\n", - blk_head.sadr, blk_head.len, blk_head.d_key & 0xff); + blk_head.sadr, blk_head.len, blk_head.d_key & 0xff); left = blk_head.len; if (cnt + left > size) { pr_info("%s: firmware error have %d need %d words\n", @@ -229,7 +229,7 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) } spin_lock_irqsave(isar->hwlock, flags); if (!send_mbox(isar, ISAR_HIS_DKEY, blk_head.d_key & 0xff, - 0, NULL)) { + 0, NULL)) { pr_info("ISAR send_mbox dkey failed\n"); ret = -ETIME; goto reterror; @@ -260,7 +260,7 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) cnt += noc; *mp++ = noc; pr_debug("%s: load %3d words at %04x\n", isar->name, - noc, blk_head.sadr); + noc, blk_head.sadr); blk_head.sadr += noc; while (noc) { val = le16_to_cpu(*sp++); @@ -289,7 +289,7 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) } } pr_debug("%s: ISAR firmware block %d words loaded\n", - isar->name, blk_head.len); + isar->name, blk_head.len); } isar->ch[0].bch.debug = saved_debug; /* 10ms delay */ @@ -333,7 +333,7 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) goto reterrflg; } else pr_debug("%s: ISAR general status event %x\n", - isar->name, isar->bstat); + isar->name, isar->bstat); /* 10ms delay */ cnt = 10; while (cnt--) @@ -387,7 +387,7 @@ load_firmware(struct isar_hw *isar, const u8 *buf, int size) } else { if ((isar->cmsb == ISAR_CTRL_SWVER) && (isar->clsb == 1)) { pr_notice("%s: ISAR software version %#x\n", - isar->name, isar->buf[0]); + isar->name, isar->buf[0]); } else { pr_info("%s: ISAR wrong swver response (%x,%x)" " cnt(%d)\n", isar->name, isar->cmsb, @@ -431,7 +431,7 @@ isar_rcv_frame(struct isar_ch *ch) switch (ch->bch.state) { case ISDN_P_NONE: pr_debug("%s: ISAR protocol 0 spurious IIS_RDATA %x/%x/%x\n", - ch->is->name, ch->is->iis, ch->is->cmsb, ch->is->clsb); + ch->is->name, ch->is->iis, ch->is->cmsb, ch->is->clsb); ch->is->write_reg(ch->is->hw, ISAR_IIA, 0); break; case ISDN_P_B_RAW: @@ -439,7 +439,7 @@ isar_rcv_frame(struct isar_ch *ch) case ISDN_P_B_MODEM_ASYNC: if (!ch->bch.rx_skb) { ch->bch.rx_skb = mI_alloc_skb(ch->bch.maxlen, - GFP_ATOMIC); + GFP_ATOMIC); if (unlikely(!ch->bch.rx_skb)) { pr_info("%s: B receive out of memory\n", ch->is->name); @@ -453,7 +453,7 @@ isar_rcv_frame(struct isar_ch *ch) case ISDN_P_B_HDLC: if (!ch->bch.rx_skb) { ch->bch.rx_skb = mI_alloc_skb(ch->bch.maxlen, - GFP_ATOMIC); + GFP_ATOMIC); if (unlikely(!ch->bch.rx_skb)) { pr_info("%s: B receive out of memory\n", ch->is->name); @@ -464,14 +464,14 @@ isar_rcv_frame(struct isar_ch *ch) if ((ch->bch.rx_skb->len + ch->is->clsb) > (ch->bch.maxlen + 2)) { pr_debug("%s: incoming packet too large\n", - ch->is->name); + ch->is->name); ch->is->write_reg(ch->is->hw, ISAR_IIA, 0); skb_trim(ch->bch.rx_skb, 0); break; } if (ch->is->cmsb & HDLC_ERROR) { pr_debug("%s: ISAR frame error %x len %d\n", - ch->is->name, ch->is->cmsb, ch->is->clsb); + ch->is->name, ch->is->cmsb, ch->is->clsb); #ifdef ERROR_STATISTIC if (ch->is->cmsb & HDLC_ERR_RER) ch->bch.err_inv++; @@ -489,7 +489,7 @@ isar_rcv_frame(struct isar_ch *ch) if (ch->is->cmsb & HDLC_FED) { if (ch->bch.rx_skb->len < 3) { /* last 2 are the FCS */ pr_debug("%s: ISAR frame to short %d\n", - ch->is->name, ch->bch.rx_skb->len); + ch->is->name, ch->bch.rx_skb->len); skb_trim(ch->bch.rx_skb, 0); break; } @@ -500,7 +500,7 @@ isar_rcv_frame(struct isar_ch *ch) case ISDN_P_B_T30_FAX: if (ch->state != STFAX_ACTIV) { pr_debug("%s: isar_rcv_frame: not ACTIV\n", - ch->is->name); + ch->is->name); ch->is->write_reg(ch->is->hw, ISAR_IIA, 0); if (ch->bch.rx_skb) skb_trim(ch->bch.rx_skb, 0); @@ -508,7 +508,7 @@ isar_rcv_frame(struct isar_ch *ch) } if (!ch->bch.rx_skb) { ch->bch.rx_skb = mI_alloc_skb(ch->bch.maxlen, - GFP_ATOMIC); + GFP_ATOMIC); if (unlikely(!ch->bch.rx_skb)) { pr_info("%s: B receive out of memory\n", __func__); @@ -519,14 +519,14 @@ isar_rcv_frame(struct isar_ch *ch) if (ch->cmd == PCTRL_CMD_FRM) { rcv_mbox(ch->is, skb_put(ch->bch.rx_skb, ch->is->clsb)); pr_debug("%s: isar_rcv_frame: %d\n", - ch->is->name, ch->bch.rx_skb->len); + ch->is->name, ch->bch.rx_skb->len); if (ch->is->cmsb & SART_NMD) { /* ABORT */ pr_debug("%s: isar_rcv_frame: no more data\n", - ch->is->name); + ch->is->name); ch->is->write_reg(ch->is->hw, ISAR_IIA, 0); send_mbox(ch->is, SET_DPS(ch->dpath) | - ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, - 0, NULL); + ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, + 0, NULL); ch->state = STFAX_ESCAPE; /* set_skb_flag(skb, DF_NOMOREDATA); */ } @@ -537,7 +537,7 @@ isar_rcv_frame(struct isar_ch *ch) } if (ch->cmd != PCTRL_CMD_FRH) { pr_debug("%s: isar_rcv_frame: unknown fax mode %x\n", - ch->is->name, ch->cmd); + ch->is->name, ch->cmd); ch->is->write_reg(ch->is->hw, ISAR_IIA, 0); if (ch->bch.rx_skb) skb_trim(ch->bch.rx_skb, 0); @@ -574,12 +574,12 @@ isar_rcv_frame(struct isar_ch *ch) } if (ch->is->cmsb & SART_NMD) { /* ABORT */ pr_debug("%s: isar_rcv_frame: no more data\n", - ch->is->name); + ch->is->name); ch->is->write_reg(ch->is->hw, ISAR_IIA, 0); if (ch->bch.rx_skb) skb_trim(ch->bch.rx_skb, 0); send_mbox(ch->is, SET_DPS(ch->dpath) | - ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); + ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); ch->state = STFAX_ESCAPE; deliver_status(ch, HW_MOD_NOCARR); } @@ -599,14 +599,14 @@ isar_fill_fifo(struct isar_ch *ch) u8 *ptr; pr_debug("%s: ch%d tx_skb %p tx_idx %d\n", - ch->is->name, ch->bch.nr, ch->bch.tx_skb, ch->bch.tx_idx); + ch->is->name, ch->bch.nr, ch->bch.tx_skb, ch->bch.tx_idx); if (!ch->bch.tx_skb) return; count = ch->bch.tx_skb->len - ch->bch.tx_idx; if (count <= 0) return; if (!(ch->is->bstat & - (ch->dpath == 1 ? BSTAT_RDM1 : BSTAT_RDM2))) + (ch->dpath == 1 ? BSTAT_RDM1 : BSTAT_RDM2))) return; if (count > ch->mml) { msb = 0; @@ -618,17 +618,17 @@ isar_fill_fifo(struct isar_ch *ch) if (!ch->bch.tx_idx) { pr_debug("%s: frame start\n", ch->is->name); if ((ch->bch.state == ISDN_P_B_T30_FAX) && - (ch->cmd == PCTRL_CMD_FTH)) { + (ch->cmd == PCTRL_CMD_FTH)) { if (count > 1) { if ((ptr[0] == 0xff) && (ptr[1] == 0x13)) { /* last frame */ test_and_set_bit(FLG_LASTDATA, - &ch->bch.Flags); + &ch->bch.Flags); pr_debug("%s: set LASTDATA\n", - ch->is->name); + ch->is->name); if (msb == HDLC_FED) test_and_set_bit(FLG_DLEETX, - &ch->bch.Flags); + &ch->bch.Flags); } } } @@ -643,21 +643,21 @@ isar_fill_fifo(struct isar_ch *ch) case ISDN_P_B_L2DTMF: case ISDN_P_B_MODEM_ASYNC: send_mbox(ch->is, SET_DPS(ch->dpath) | ISAR_HIS_SDATA, - 0, count, ptr); + 0, count, ptr); break; case ISDN_P_B_HDLC: send_mbox(ch->is, SET_DPS(ch->dpath) | ISAR_HIS_SDATA, - msb, count, ptr); + msb, count, ptr); break; case ISDN_P_B_T30_FAX: if (ch->state != STFAX_ACTIV) pr_debug("%s: not ACTIV\n", ch->is->name); else if (ch->cmd == PCTRL_CMD_FTH) send_mbox(ch->is, SET_DPS(ch->dpath) | ISAR_HIS_SDATA, - msb, count, ptr); + msb, count, ptr); else if (ch->cmd == PCTRL_CMD_FTM) send_mbox(ch->is, SET_DPS(ch->dpath) | ISAR_HIS_SDATA, - 0, count, ptr); + 0, count, ptr); else pr_debug("%s: not FTH/FTM\n", ch->is->name); break; @@ -687,8 +687,8 @@ static void send_next(struct isar_ch *ch) { pr_debug("%s: %s ch%d tx_skb %p tx_idx %d\n", - ch->is->name, __func__, ch->bch.nr, - ch->bch.tx_skb, ch->bch.tx_idx); + ch->is->name, __func__, ch->bch.nr, + ch->bch.tx_skb, ch->bch.tx_idx); if (ch->bch.state == ISDN_P_B_T30_FAX) { if (ch->cmd == PCTRL_CMD_FTH) { if (test_bit(FLG_LASTDATA, &ch->bch.Flags)) { @@ -713,12 +713,12 @@ send_next(struct isar_ch *ch) else { if (test_and_clear_bit(FLG_DLEETX, &ch->bch.Flags)) { if (test_and_clear_bit(FLG_LASTDATA, - &ch->bch.Flags)) { + &ch->bch.Flags)) { if (test_and_clear_bit(FLG_NMD_DATA, - &ch->bch.Flags)) { + &ch->bch.Flags)) { u8 zd = 0; send_mbox(ch->is, SET_DPS(ch->dpath) | - ISAR_HIS_SDATA, 0x01, 1, &zd); + ISAR_HIS_SDATA, 0x01, 1, &zd); } test_and_set_bit(FLG_LL_OK, &ch->bch.Flags); } else { @@ -738,7 +738,7 @@ check_send(struct isar_hw *isar, u8 rdm) ch = sel_bch_isar(isar, 1); if (ch && test_bit(FLG_ACTIVE, &ch->bch.Flags)) { if (ch->bch.tx_skb && (ch->bch.tx_skb->len > - ch->bch.tx_idx)) + ch->bch.tx_idx)) isar_fill_fifo(ch); else send_next(ch); @@ -748,7 +748,7 @@ check_send(struct isar_hw *isar, u8 rdm) ch = sel_bch_isar(isar, 2); if (ch && test_bit(FLG_ACTIVE, &ch->bch.Flags)) { if (ch->bch.tx_skb && (ch->bch.tx_skb->len > - ch->bch.tx_idx)) + ch->bch.tx_idx)) isar_fill_fifo(ch); else send_next(ch); @@ -757,10 +757,10 @@ check_send(struct isar_hw *isar, u8 rdm) } const char *dmril[] = {"NO SPEED", "1200/75", "NODEF2", "75/1200", "NODEF4", - "300", "600", "1200", "2400", "4800", "7200", - "9600nt", "9600t", "12000", "14400", "WRONG"}; + "300", "600", "1200", "2400", "4800", "7200", + "9600nt", "9600t", "12000", "14400", "WRONG"}; const char *dmrim[] = {"NO MOD", "NO DEF", "V32/V32b", "V22", "V21", - "Bell103", "V23", "Bell202", "V17", "V29", "V27ter"}; + "Bell103", "V23", "Bell202", "V17", "V29", "V27ter"}; static void isar_pump_status_rsp(struct isar_ch *ch) { @@ -892,10 +892,10 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { pr_debug("%s: pump stev LINE_TX_H\n", ch->is->name); ch->state = STFAX_CONT; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_CONT, 0, NULL); + PCTRL_CMD_CONT, 0, NULL); } else { pr_debug("%s: pump stev LINE_TX_H wrong st %x\n", - ch->is->name, ch->state); + ch->is->name, ch->state); } break; case PSEV_LINE_RX_H: @@ -903,10 +903,10 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { pr_debug("%s: pump stev LINE_RX_H\n", ch->is->name); ch->state = STFAX_CONT; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_CONT, 0, NULL); + PCTRL_CMD_CONT, 0, NULL); } else { pr_debug("%s: pump stev LINE_RX_H wrong st %x\n", - ch->is->name, ch->state); + ch->is->name, ch->state); } break; case PSEV_LINE_TX_B: @@ -914,10 +914,10 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { pr_debug("%s: pump stev LINE_TX_B\n", ch->is->name); ch->state = STFAX_CONT; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_CONT, 0, NULL); + PCTRL_CMD_CONT, 0, NULL); } else { pr_debug("%s: pump stev LINE_TX_B wrong st %x\n", - ch->is->name, ch->state); + ch->is->name, ch->state); } break; case PSEV_LINE_RX_B: @@ -925,10 +925,10 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { pr_debug("%s: pump stev LINE_RX_B\n", ch->is->name); ch->state = STFAX_CONT; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_CONT, 0, NULL); + PCTRL_CMD_CONT, 0, NULL); } else { pr_debug("%s: pump stev LINE_RX_B wrong st %x\n", - ch->is->name, ch->state); + ch->is->name, ch->state); } break; case PSEV_RSP_CONN: @@ -941,19 +941,19 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { int delay = (ch->mod == 3) ? 1000 : 200; /* 1s (200 ms) Flags before data */ if (test_and_set_bit(FLG_FTI_RUN, - &ch->bch.Flags)) + &ch->bch.Flags)) del_timer(&ch->ftimer); ch->ftimer.expires = - jiffies + ((delay * HZ)/1000); + jiffies + ((delay * HZ) / 1000); test_and_set_bit(FLG_LL_CONN, - &ch->bch.Flags); + &ch->bch.Flags); add_timer(&ch->ftimer); } else { deliver_status(ch, HW_MOD_CONNECT); } } else { pr_debug("%s: pump stev RSP_CONN wrong st %x\n", - ch->is->name, ch->state); + ch->is->name, ch->state); } break; case PSEV_FLAGS_DET: @@ -961,7 +961,7 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { break; case PSEV_RSP_DISC: pr_debug("%s: pump stev RSP_DISC state(%d)\n", - ch->is->name, ch->state); + ch->is->name, ch->state); if (ch->state == STFAX_ESCAPE) { p1 = 5; switch (ch->newcmd) { @@ -972,7 +972,7 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { p1 = 2; case PCTRL_CMD_FTH: send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_SILON, 1, &p1); + PCTRL_CMD_SILON, 1, &p1); ch->state = STFAX_SILDET; break; case PCTRL_CMD_FRH: @@ -983,13 +983,13 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { ch->cmd = ch->newcmd; ch->newcmd = 0; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - ch->cmd, 1, &p1); + ch->cmd, 1, &p1); ch->state = STFAX_LINE; ch->try_mod = 3; break; default: pr_debug("%s: RSP_DISC unknown newcmd %x\n", - ch->is->name, ch->newcmd); + ch->is->name, ch->newcmd); break; } } else if (ch->state == STFAX_ACTIV) { @@ -1015,7 +1015,7 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { ch->cmd = ch->newcmd; ch->newcmd = 0; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - ch->cmd, 1, &p1); + ch->cmd, 1, &p1); ch->state = STFAX_LINE; ch->try_mod = 3; } @@ -1026,17 +1026,17 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) { case PSEV_RSP_FCERR: if (ch->state == STFAX_LINE) { pr_debug("%s: pump stev RSP_FCERR try %d\n", - ch->is->name, ch->try_mod); + ch->is->name, ch->try_mod); if (ch->try_mod--) { send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, - ch->cmd, 1, &ch->mod); + ch->cmd, 1, &ch->mod); break; } } pr_debug("%s: pump stev RSP_FCERR\n", ch->is->name); ch->state = STFAX_ESCAPE; send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, - 0, NULL); + 0, NULL); deliver_status(ch, HW_MOD_FCERROR); break; default: @@ -1057,8 +1057,8 @@ mISDNisar_irq(struct isar_hw *isar) isar_rcv_frame(ch); else { pr_debug("%s: ISAR spurious IIS_RDATA %x/%x/%x\n", - isar->name, isar->iis, isar->cmsb, - isar->clsb); + isar->name, isar->iis, isar->cmsb, + isar->clsb); isar->write_reg(isar->hw, ISAR_IIA, 0); } break; @@ -1078,7 +1078,7 @@ mISDNisar_irq(struct isar_hw *isar) } #endif pr_debug("%s: Buffer STEV dpath%d msb(%x)\n", - isar->name, isar->iis>>6, isar->cmsb); + isar->name, isar->iis >> 6, isar->cmsb); isar->write_reg(isar->hw, ISAR_IIA, 0); break; case ISAR_IIS_PSTEV: @@ -1100,16 +1100,16 @@ mISDNisar_irq(struct isar_hw *isar) tt += 7; tt |= DTMF_TONE_VAL; _queue_data(&ch->bch.ch, PH_CONTROL_IND, - MISDN_ID_ANY, sizeof(tt), &tt, - GFP_ATOMIC); + MISDN_ID_ANY, sizeof(tt), &tt, + GFP_ATOMIC); } else pr_debug("%s: ISAR IIS_PSTEV pm %d sta %x\n", - isar->name, ch->bch.state, - isar->cmsb); + isar->name, ch->bch.state, + isar->cmsb); } else { pr_debug("%s: ISAR spurious IIS_PSTEV %x/%x/%x\n", - isar->name, isar->iis, isar->cmsb, - isar->clsb); + isar->name, isar->iis, isar->cmsb, + isar->clsb); isar->write_reg(isar->hw, ISAR_IIA, 0); } break; @@ -1120,8 +1120,8 @@ mISDNisar_irq(struct isar_hw *isar) isar_pump_status_rsp(ch); } else { pr_debug("%s: ISAR spurious IIS_PSTRSP %x/%x/%x\n", - isar->name, isar->iis, isar->cmsb, - isar->clsb); + isar->name, isar->iis, isar->cmsb, + isar->clsb); isar->write_reg(isar->hw, ISAR_IIA, 0); } break; @@ -1137,7 +1137,7 @@ mISDNisar_irq(struct isar_hw *isar) default: rcv_mbox(isar, NULL); pr_debug("%s: unhandled msg iis(%x) ctrl(%x/%x)\n", - isar->name, isar->iis, isar->cmsb, isar->clsb); + isar->name, isar->iis, isar->cmsb, isar->clsb); break; } } @@ -1169,11 +1169,11 @@ setup_pump(struct isar_ch *ch) { if (test_bit(FLG_DTMFSEND, &ch->bch.Flags)) { param[0] = 5; /* TOA 5 db */ send_mbox(ch->is, dps | ISAR_HIS_PUMPCFG, - PMOD_DTMF_TRANS, 1, param); + PMOD_DTMF_TRANS, 1, param); } else { param[0] = 40; /* REL -46 dbm */ send_mbox(ch->is, dps | ISAR_HIS_PUMPCFG, - PMOD_DTMF, 1, param); + PMOD_DTMF, 1, param); } case ISDN_P_B_MODEM_ASYNC: ctrl = PMOD_DATAMODEM; @@ -1220,17 +1220,17 @@ setup_sart(struct isar_ch *ch) { switch (ch->bch.state) { case ISDN_P_NONE: send_mbox(ch->is, dps | ISAR_HIS_SARTCFG, SMODE_DISABLE, - 0, NULL); + 0, NULL); break; case ISDN_P_B_RAW: case ISDN_P_B_L2DTMF: send_mbox(ch->is, dps | ISAR_HIS_SARTCFG, SMODE_BINARY, - 2, param); + 2, param); break; case ISDN_P_B_HDLC: case ISDN_P_B_T30_FAX: send_mbox(ch->is, dps | ISAR_HIS_SARTCFG, SMODE_HDLC, - 1, param); + 1, param); break; case ISDN_P_B_MODEM_ASYNC: ctrl = SMODE_V14 | SCTRL_HDMC_BOTH; @@ -1297,7 +1297,7 @@ modeisar(struct isar_ch *ch, u32 bprotocol) if (!test_and_set_bit(ISAR_DP2_USE, &ch->is->Flags)) ch->dpath = 2; else if (!test_and_set_bit(ISAR_DP1_USE, - &ch->is->Flags)) + &ch->is->Flags)) ch->dpath = 1; else { pr_info("modeisar both pathes in use\n"); @@ -1307,7 +1307,7 @@ modeisar(struct isar_ch *ch, u32 bprotocol) test_and_set_bit(FLG_HDLC, &ch->bch.Flags); else test_and_set_bit(FLG_TRANSPARENT, - &ch->bch.Flags); + &ch->bch.Flags); break; case ISDN_P_B_MODEM_ASYNC: case ISDN_P_B_T30_FAX: @@ -1328,7 +1328,7 @@ modeisar(struct isar_ch *ch, u32 bprotocol) } } pr_debug("%s: ISAR ch%d dp%d protocol %x->%x\n", ch->is->name, - ch->bch.nr, ch->dpath, ch->bch.state, bprotocol); + ch->bch.nr, ch->dpath, ch->bch.state, bprotocol); ch->bch.state = bprotocol; setup_pump(ch); setup_iom2(ch); @@ -1353,7 +1353,7 @@ isar_pump_cmd(struct isar_ch *ch, u32 cmd, u8 para) u8 ctrl = 0, nom = 0, p1 = 0; pr_debug("%s: isar_pump_cmd %x/%x state(%x)\n", - ch->is->name, cmd, para, ch->bch.state); + ch->is->name, cmd, para, ch->bch.state); switch (cmd) { case HW_MOD_FTM: if (ch->state == STFAX_READY) { @@ -1367,7 +1367,7 @@ isar_pump_cmd(struct isar_ch *ch, u32 cmd, u8 para) ch->newcmd = 0; ch->try_mod = 3; } else if ((ch->state == STFAX_ACTIV) && - (ch->cmd == PCTRL_CMD_FTM) && (ch->mod == para)) + (ch->cmd == PCTRL_CMD_FTM) && (ch->mod == para)) deliver_status(ch, HW_MOD_CONNECT); else { ch->newmod = para; @@ -1389,8 +1389,8 @@ isar_pump_cmd(struct isar_ch *ch, u32 cmd, u8 para) ch->newcmd = 0; ch->try_mod = 3; } else if ((ch->state == STFAX_ACTIV) && - (ch->cmd == PCTRL_CMD_FTH) && (ch->mod == para)) - deliver_status(ch, HW_MOD_CONNECT); + (ch->cmd == PCTRL_CMD_FTH) && (ch->mod == para)) + deliver_status(ch, HW_MOD_CONNECT); else { ch->newmod = para; ch->newcmd = PCTRL_CMD_FTH; @@ -1411,7 +1411,7 @@ isar_pump_cmd(struct isar_ch *ch, u32 cmd, u8 para) ch->newcmd = 0; ch->try_mod = 3; } else if ((ch->state == STFAX_ACTIV) && - (ch->cmd == PCTRL_CMD_FRM) && (ch->mod == para)) + (ch->cmd == PCTRL_CMD_FRM) && (ch->mod == para)) deliver_status(ch, HW_MOD_CONNECT); else { ch->newmod = para; @@ -1433,7 +1433,7 @@ isar_pump_cmd(struct isar_ch *ch, u32 cmd, u8 para) ch->newcmd = 0; ch->try_mod = 3; } else if ((ch->state == STFAX_ACTIV) && - (ch->cmd == PCTRL_CMD_FRH) && (ch->mod == para)) + (ch->cmd == PCTRL_CMD_FRH) && (ch->mod == para)) deliver_status(ch, HW_MOD_CONNECT); else { ch->newmod = para; @@ -1464,7 +1464,7 @@ isar_setup(struct isar_hw *isar) for (i = 0; i < 2; i++) { /* Buffer Config */ send_mbox(isar, (i ? ISAR_HIS_DPS2 : ISAR_HIS_DPS1) | - ISAR_HIS_P12CFG, 4, 1, &msg); + ISAR_HIS_P12CFG, 4, 1, &msg); isar->ch[i].mml = msg; isar->ch[i].bch.state = 0; isar->ch[i].dpath = i + 1; @@ -1505,7 +1505,7 @@ isar_l2l1(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(ich->is->hwlock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: spin_lock_irqsave(ich->is->hwlock, flags); @@ -1513,15 +1513,15 @@ isar_l2l1(struct mISDNchannel *ch, struct sk_buff *skb) modeisar(ich, ISDN_P_NONE); spin_unlock_irqrestore(ich->is->hwlock, flags); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); ret = 0; break; case PH_CONTROL_REQ: val = (u32 *)skb->data; pr_debug("%s: PH_CONTROL | REQUEST %x/%x\n", ich->is->name, - hh->id, *val); + hh->id, *val); if ((hh->id == 0) && ((*val & ~DTMF_TONE_MASK) == - DTMF_TONE_VAL)) { + DTMF_TONE_VAL)) { if (bch->state == ISDN_P_B_L2DTMF) { char tt = *val & DTMF_TONE_MASK; @@ -1541,7 +1541,7 @@ isar_l2l1(struct mISDNchannel *ch, struct sk_buff *skb) return -EINVAL; } } else if ((hh->id == HW_MOD_FRM) || (hh->id == HW_MOD_FRH) || - (hh->id == HW_MOD_FTM) || (hh->id == HW_MOD_FTH)) { + (hh->id == HW_MOD_FTM) || (hh->id == HW_MOD_FTH)) { for (id = 0; id < FAXMODCNT; id++) if (faxmodulation[id] == *val) break; @@ -1581,7 +1581,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_GETOP: cq->op = 0; break; - /* Nothing implemented yet */ + /* Nothing implemented yet */ case MISDN_CTRL_FILL_EMPTY: default: pr_info("%s: unknown Op %x\n", __func__, cq->op); @@ -1647,7 +1647,7 @@ init_isar(struct isar_hw *isar) isar->version = ISARVersion(isar); if (isar->ch[0].bch.debug & DEBUG_HW) pr_notice("%s: Testing version %d (%d time)\n", - isar->name, isar->version, 3 - cnt); + isar->name, isar->version, 3 - cnt); if (isar->version == 1) break; isar->ctrl(isar->hw, HW_RESET_REQ, 0); diff --git a/drivers/isdn/hardware/mISDN/netjet.c b/drivers/isdn/hardware/mISDN/netjet.c index 5ef9f11ee74b..dd6de9f7a8a3 100644 --- a/drivers/isdn/hardware/mISDN/netjet.c +++ b/drivers/isdn/hardware/mISDN/netjet.c @@ -191,7 +191,7 @@ fill_mem(struct tiger_ch *bc, u32 idx, u32 cnt, u32 fill) u32 mask = 0xff, val; pr_debug("%s: B%1d fill %02x len %d idx %d/%d\n", card->name, - bc->bch.nr, fill, cnt, idx, card->send.idx); + bc->bch.nr, fill, cnt, idx, card->send.idx); if (bc->bch.nr & 2) { fill <<= 8; mask <<= 8; @@ -213,7 +213,7 @@ mode_tiger(struct tiger_ch *bc, u32 protocol) struct tiger_hw *card = bc->bch.hw; pr_debug("%s: B%1d protocol %x-->%x\n", card->name, - bc->bch.nr, bc->bch.state, protocol); + bc->bch.nr, bc->bch.state, protocol); switch (protocol) { case ISDN_P_NONE: if (bc->bch.state == ISDN_P_NONE) @@ -237,7 +237,7 @@ mode_tiger(struct tiger_ch *bc, u32 protocol) test_and_set_bit(FLG_TRANSPARENT, &bc->bch.Flags); bc->bch.state = protocol; bc->idx = 0; - bc->free = card->send.size/2; + bc->free = card->send.size / 2; bc->rxstate = 0; bc->txstate = TX_INIT | TX_IDLE; bc->lastrx = -1; @@ -251,7 +251,7 @@ mode_tiger(struct tiger_ch *bc, u32 protocol) test_and_set_bit(FLG_HDLC, &bc->bch.Flags); bc->bch.state = protocol; bc->idx = 0; - bc->free = card->send.size/2; + bc->free = card->send.size / 2; bc->rxstate = 0; bc->txstate = TX_INIT | TX_IDLE; isdnhdlc_rcv_init(&bc->hrecv, 0); @@ -273,12 +273,12 @@ mode_tiger(struct tiger_ch *bc, u32 protocol) card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2; pr_debug("%s: %s ctrl %x irq %02x/%02x idx %d/%d\n", - card->name, __func__, - inb(card->base + NJ_DMACTRL), - inb(card->base + NJ_IRQMASK0), - inb(card->base + NJ_IRQSTAT0), - card->send.idx, - card->recv.idx); + card->name, __func__, + inb(card->base + NJ_DMACTRL), + inb(card->base + NJ_IRQMASK0), + inb(card->base + NJ_IRQSTAT0), + card->send.idx, + card->recv.idx); return 0; } @@ -311,7 +311,7 @@ inittiger(struct tiger_hw *card) int i; card->dma_p = pci_alloc_consistent(card->pdev, NJ_DMA_SIZE, - &card->dma); + &card->dma); if (!card->dma_p) { pr_info("%s: No DMA memory\n", card->name); return -ENOMEM; @@ -344,9 +344,9 @@ inittiger(struct tiger_hw *card) if (debug & DEBUG_HW) pr_notice("%s: send buffer phy %#x - %#x - %#x virt %p" - " size %zu u32\n", card->name, - card->send.dmastart, card->send.dmairq, - card->send.dmaend, card->send.start, card->send.size); + " size %zu u32\n", card->name, + card->send.dmastart, card->send.dmairq, + card->send.dmaend, card->send.start, card->send.size); outl(card->send.dmastart, card->base + NJ_DMA_READ_START); outl(card->send.dmairq, card->base + NJ_DMA_READ_IRQ); @@ -362,9 +362,9 @@ inittiger(struct tiger_hw *card) if (debug & DEBUG_HW) pr_notice("%s: recv buffer phy %#x - %#x - %#x virt %p" - " size %zu u32\n", card->name, - card->recv.dmastart, card->recv.dmairq, - card->recv.dmaend, card->recv.start, card->recv.size); + " size %zu u32\n", card->name, + card->recv.dmastart, card->recv.dmairq, + card->recv.dmaend, card->recv.start, card->recv.size); outl(card->recv.dmastart, card->base + NJ_DMA_WRITE_START); outl(card->recv.dmairq, card->base + NJ_DMA_WRITE_IRQ); @@ -398,7 +398,7 @@ read_dma(struct tiger_ch *bc, u32 idx, int cnt) if (test_bit(FLG_TRANSPARENT, &bc->bch.Flags)) { if ((bc->bch.rx_skb->len + cnt) > bc->bch.maxlen) { pr_debug("%s: B%1d overrun %d\n", card->name, - bc->bch.nr, bc->bch.rx_skb->len + cnt); + bc->bch.nr, bc->bch.rx_skb->len + cnt); skb_trim(bc->bch.rx_skb, 0); return; } @@ -418,8 +418,8 @@ read_dma(struct tiger_ch *bc, u32 idx, int cnt) next_frame: if (test_bit(FLG_HDLC, &bc->bch.Flags)) { stat = isdnhdlc_decode(&bc->hrecv, pn, cnt, &i, - bc->bch.rx_skb->data, bc->bch.maxlen); - if (stat > 0) /* valid frame received */ + bc->bch.rx_skb->data, bc->bch.maxlen); + if (stat > 0) /* valid frame received */ p = skb_put(bc->bch.rx_skb, stat); else if (stat == -HDLC_CRC_ERROR) pr_info("%s: B%1d receive frame CRC error\n", @@ -431,14 +431,14 @@ read_dma(struct tiger_ch *bc, u32 idx, int cnt) pr_info("%s: B%1d receive frame too long (> %d)\n", card->name, bc->bch.nr, bc->bch.maxlen); } else - stat = cnt; + stat = cnt; if (stat > 0) { if (debug & DEBUG_HW_BFIFO) { snprintf(card->log, LOG_SIZE, "B%1d-recv %s %d ", - bc->bch.nr, card->name, stat); + bc->bch.nr, card->name, stat); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, - p, stat); + p, stat); } recv_Bchannel(&bc->bch, 0); } @@ -447,7 +447,7 @@ read_dma(struct tiger_ch *bc, u32 idx, int cnt) cnt -= i; if (!bc->bch.rx_skb) { bc->bch.rx_skb = mI_alloc_skb(bc->bch.maxlen, - GFP_ATOMIC); + GFP_ATOMIC); if (!bc->bch.rx_skb) { pr_info("%s: B%1d receive out of memory\n", card->name, bc->bch.nr); @@ -498,7 +498,7 @@ resync(struct tiger_ch *bc, struct tiger_hw *card) bc->idx = card->recv.size - 1; bc->txstate = TX_RUN; pr_debug("%s: %s B%1d free %d idx %d/%d\n", card->name, - __func__, bc->bch.nr, bc->free, bc->idx, card->send.idx); + __func__, bc->bch.nr, bc->free, bc->idx, card->send.idx); } static int bc_next_frame(struct tiger_ch *); @@ -514,14 +514,14 @@ fill_hdlc_flag(struct tiger_ch *bc) if (bc->free == 0) return; pr_debug("%s: %s B%1d %d state %x idx %d/%d\n", card->name, - __func__, bc->bch.nr, bc->free, bc->txstate, - bc->idx, card->send.idx); + __func__, bc->bch.nr, bc->free, bc->txstate, + bc->idx, card->send.idx); if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN)) resync(bc, card); count = isdnhdlc_encode(&bc->hsend, NULL, 0, &i, - bc->hsbuf, bc->free); + bc->hsbuf, bc->free); pr_debug("%s: B%1d hdlc encoded %d flags\n", card->name, - bc->bch.nr, count); + bc->bch.nr, count); bc->free -= count; p = bc->hsbuf; m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff; @@ -535,7 +535,7 @@ fill_hdlc_flag(struct tiger_ch *bc) } if (debug & DEBUG_HW_BFIFO) { snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ", - bc->bch.nr, card->name, count); + bc->bch.nr, card->name, count); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count); } } @@ -554,16 +554,16 @@ fill_dma(struct tiger_ch *bc) if (count <= 0) return; pr_debug("%s: %s B%1d %d/%d/%d/%d state %x idx %d/%d\n", card->name, - __func__, bc->bch.nr, count, bc->free, bc->bch.tx_idx, - bc->bch.tx_skb->len, bc->txstate, bc->idx, card->send.idx); + __func__, bc->bch.nr, count, bc->free, bc->bch.tx_idx, + bc->bch.tx_skb->len, bc->txstate, bc->idx, card->send.idx); if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN)) resync(bc, card); p = bc->bch.tx_skb->data + bc->bch.tx_idx; if (test_bit(FLG_HDLC, &bc->bch.Flags)) { count = isdnhdlc_encode(&bc->hsend, p, count, &i, - bc->hsbuf, bc->free); + bc->hsbuf, bc->free); pr_debug("%s: B%1d hdlc encoded %d in %d\n", card->name, - bc->bch.nr, i, count); + bc->bch.nr, i, count); bc->bch.tx_idx += i; bc->free -= count; p = bc->hsbuf; @@ -584,7 +584,7 @@ fill_dma(struct tiger_ch *bc) } if (debug & DEBUG_HW_BFIFO) { snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ", - bc->bch.nr, card->name, count); + bc->bch.nr, card->name, count); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count); } if (bc->free) @@ -633,7 +633,7 @@ send_tiger_bc(struct tiger_hw *card, struct tiger_ch *bc) return; } pr_debug("%s: B%1d TX no data free %d idx %d/%d\n", card->name, - bc->bch.nr, bc->free, bc->idx, card->send.idx); + bc->bch.nr, bc->free, bc->idx, card->send.idx); if (!(bc->txstate & (TX_IDLE | TX_INIT))) { fill_mem(bc, bc->idx, bc->free, 0xff); if (bc->free == card->send.size) @@ -706,8 +706,8 @@ nj_irq(int intno, void *dev_id) s0val |= 0x01; /* the 1st read area is free */ pr_debug("%s: DMA Status %02x/%02x/%02x %d/%d\n", card->name, - s1val, s0val, card->last_is0, - card->recv.idx, card->send.idx); + s1val, s0val, card->last_is0, + card->recv.idx, card->send.idx); /* test if we have a DMA interrupt */ if (s0val != card->last_is0) { if ((s0val & NJ_IRQM0_RD_MASK) != @@ -758,7 +758,7 @@ nj_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&card->lock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: spin_lock_irqsave(&card->lock, flags); @@ -766,7 +766,7 @@ nj_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) mode_tiger(bc, ISDN_P_NONE); spin_unlock_irqrestore(&card->lock, flags); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); ret = 0; break; } @@ -785,7 +785,7 @@ channel_bctrl(struct tiger_ch *bc, struct mISDN_ctrl_req *cq) case MISDN_CTRL_GETOP: cq->op = 0; break; - /* Nothing implemented yet */ + /* Nothing implemented yet */ case MISDN_CTRL_FILL_EMPTY: default: pr_info("%s: %s unknown Op %x\n", card->name, __func__, cq->op); @@ -900,7 +900,7 @@ nj_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; case CLOSE_CHANNEL: pr_debug("%s: dev(%d) close from %p\n", card->name, dch->dev.id, - __builtin_return_address(0)); + __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -908,7 +908,7 @@ nj_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; default: pr_debug("%s: %s unknown command %x\n", - card->name, __func__, cmd); + card->name, __func__, cmd); return -EINVAL; } return err; @@ -968,7 +968,7 @@ nj_release(struct tiger_hw *card) free_irq(card->irq, card); if (card->isac.dch.dev.dev.class) mISDN_unregister_device(&card->isac.dch.dev); - + for (i = 0; i < 2; i++) { mISDN_freebchannel(&card->bc[i].bch); kfree(card->bc[i].hsbuf); @@ -976,7 +976,7 @@ nj_release(struct tiger_hw *card) } if (card->dma_p) pci_free_consistent(card->pdev, NJ_DMA_SIZE, - card->dma_p, card->dma); + card->dma_p, card->dma); write_lock_irqsave(&card_lock, flags); list_del(&card->list); write_unlock_irqrestore(&card_lock, flags); @@ -1033,14 +1033,14 @@ setup_instance(struct tiger_hw *card) card->bc[i].bch.ch.ctrl = nj_bctrl; card->bc[i].bch.ch.nr = i + 1; list_add(&card->bc[i].bch.ch.list, - &card->isac.dch.dev.bchannels); + &card->isac.dch.dev.bchannels); card->bc[i].bch.hw = card; } err = nj_setup(card); if (err) goto error; err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev, - card->name); + card->name); if (err) goto error; err = nj_init_card(card); @@ -1074,7 +1074,7 @@ nj_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } if (pdev->subsystem_vendor == 0xb100 && - pdev->subsystem_device == 0x0003 ) { + pdev->subsystem_device == 0x0003) { pr_notice("Netjet: Digium TDM400P not handled yet\n"); return -ENODEV; } @@ -1094,7 +1094,7 @@ nj_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } printk(KERN_INFO "nj_probe(mISDN): found adapter at %s\n", - pci_name(pdev)); + pci_name(pdev)); pci_set_master(pdev); diff --git a/drivers/isdn/hardware/mISDN/netjet.h b/drivers/isdn/hardware/mISDN/netjet.h index d061ff995607..ddd41ef1a70e 100644 --- a/drivers/isdn/hardware/mISDN/netjet.h +++ b/drivers/isdn/hardware/mISDN/netjet.h @@ -55,4 +55,3 @@ /* 2 * 64 byte is a compromise between IRQ count and latency */ #define NJ_DMA_RXSIZE 128 /* 2 * 64 */ #define NJ_DMA_TXSIZE 128 /* 2 * 64 */ - diff --git a/drivers/isdn/hardware/mISDN/speedfax.c b/drivers/isdn/hardware/mISDN/speedfax.c index 4d0d41ea1228..04689935148b 100644 --- a/drivers/isdn/hardware/mISDN/speedfax.c +++ b/drivers/isdn/hardware/mISDN/speedfax.c @@ -147,10 +147,10 @@ speedfax_irq(int intno, void *dev_id) goto Start_ISAR; if (cnt < irqloops) pr_debug("%s: %d irqloops cpu%d\n", sf->name, - irqloops - cnt, smp_processor_id()); + irqloops - cnt, smp_processor_id()); if (irqloops && !cnt) pr_notice("%s: %d IRQ LOOP cpu%d\n", sf->name, - irqloops, smp_processor_id()); + irqloops, smp_processor_id()); spin_unlock(&sf->lock); return IRQ_HANDLED; } @@ -266,7 +266,7 @@ sfax_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; case CLOSE_CHANNEL: pr_debug("%s: dev(%d) close from %p\n", sf->name, - dch->dev.id, __builtin_return_address(0)); + dch->dev.id, __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -306,10 +306,10 @@ init_card(struct sfax_hw *sf) msleep_interruptible(10); if (debug & DEBUG_HW) pr_notice("%s: IRQ %d count %d\n", sf->name, - sf->irq, sf->irqcnt); + sf->irq, sf->irqcnt); if (!sf->irqcnt) { pr_info("%s: IRQ(%d) got no requests during init %d\n", - sf->name, sf->irq, 3 - cnt); + sf->name, sf->irq, 3 - cnt); } else return 0; } @@ -325,7 +325,7 @@ setup_speedfax(struct sfax_hw *sf) if (!request_region(sf->cfg, 256, sf->name)) { pr_info("mISDN: %s config port %x-%x already in use\n", - sf->name, sf->cfg, sf->cfg + 255); + sf->name, sf->cfg, sf->cfg + 255); return -EIO; } outb(0xff, sf->cfg); @@ -396,7 +396,7 @@ setup_instance(struct sfax_hw *card) } if (debug & DEBUG_HW) pr_notice("%s: got firmware %zu bytes\n", - card->name, firmware->size); + card->name, firmware->size); mISDNisac_init(&card->isac, card); @@ -406,7 +406,7 @@ setup_instance(struct sfax_hw *card) for (i = 0; i < 2; i++) { set_channelmap(i + 1, card->isac.dch.dev.channelmap); list_add(&card->isar.ch[i].bch.ch.list, - &card->isac.dch.dev.bchannels); + &card->isac.dch.dev.bchannels); } err = setup_speedfax(card); @@ -416,7 +416,7 @@ setup_instance(struct sfax_hw *card) if (err) goto error; err = mISDN_register_device(&card->isac.dch.dev, - &card->pdev->dev, card->name); + &card->pdev->dev, card->name); if (err) goto error; err = init_card(card); @@ -466,7 +466,7 @@ sfaxpci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } pr_notice("mISDN: Speedfax found adapter %s at %s\n", - (char *)ent->driver_data, pci_name(pdev)); + (char *)ent->driver_data, pci_name(pdev)); card->cfg = pci_resource_start(pdev, 0); card->irq = pdev->irq; @@ -514,7 +514,7 @@ Speedfax_init(void) int err; pr_notice("Sedlbauer Speedfax+ Driver Rev. %s\n", - SPEEDFAX_REV); + SPEEDFAX_REV); err = pci_register_driver(&sfaxpci_driver); return err; } diff --git a/drivers/isdn/hardware/mISDN/w6692.c b/drivers/isdn/hardware/mISDN/w6692.c index e10e0284533c..7f1e7ba75cd1 100644 --- a/drivers/isdn/hardware/mISDN/w6692.c +++ b/drivers/isdn/hardware/mISDN/w6692.c @@ -171,7 +171,7 @@ W6692Version(struct w6692_hw *card) val = ReadW6692(card, W_D_RBCH); pr_notice("%s: Winbond W6692 version: %s\n", card->name, - W6692Ver[(val >> 6) & 3]); + W6692Ver[(val >> 6) & 3]); } static void @@ -248,7 +248,7 @@ W6692_ph_bh(struct dchannel *dch) break; default: pr_debug("%s: TE unknown state %02x dch state %02x\n", - card->name, card->state, dch->state); + card->name, card->state, dch->state); break; } pr_debug("%s: TE newstate %02x\n", card->name, dch->state); @@ -271,7 +271,7 @@ W6692_empty_Dfifo(struct w6692_hw *card, int count) } if ((dch->rx_skb->len + count) >= dch->maxlen) { pr_debug("%s: empty_Dfifo overrun %d\n", card->name, - dch->rx_skb->len + count); + dch->rx_skb->len + count); WriteW6692(card, W_D_CMDR, W_D_CMDR_RACK); return; } @@ -280,7 +280,7 @@ W6692_empty_Dfifo(struct w6692_hw *card, int count) WriteW6692(card, W_D_CMDR, W_D_CMDR_RACK); if (debug & DEBUG_HW_DFIFO) { snprintf(card->log, 63, "D-recv %s %d ", - card->name, count); + card->name, count); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); } } @@ -312,11 +312,11 @@ W6692_fill_Dfifo(struct w6692_hw *card) del_timer(&dch->timer); } init_timer(&dch->timer); - dch->timer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ)/1000); + dch->timer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ) / 1000); add_timer(&dch->timer); if (debug & DEBUG_HW_DFIFO) { snprintf(card->log, 63, "D-send %s %d ", - card->name, count); + card->name, count); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); } } @@ -426,7 +426,7 @@ handle_statusD(struct w6692_hw *card) if (exval & W_D_EXI_MOC) { /* MOC - not supported */ v1 = ReadW6692(card, W_MOSR); pr_debug("%s: spurious MOC interrupt MOSR %02x\n", - card->name, v1); + card->name, v1); } if (exval & W_D_EXI_ISC) { /* ISC - Level1 change */ cir = ReadW6692(card, W_CIR); @@ -434,7 +434,7 @@ handle_statusD(struct w6692_hw *card) if (cir & W_CIR_ICC) { v1 = cir & W_CIR_COD_MASK; pr_debug("%s: ph_state_change %x -> %x\n", card->name, - dch->state, v1); + dch->state, v1); card->state = v1; if (card->fmask & led) { switch (v1) { @@ -479,13 +479,13 @@ W6692_empty_Bfifo(struct w6692_ch *wch, int count) if (unlikely(!wch->bch.rx_skb)) { pr_info("%s: B receive out of memory\n", card->name); WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RACK | - W_B_CMDR_RACT); + W_B_CMDR_RACT); return; } } if (wch->bch.rx_skb->len + count > wch->bch.maxlen) { pr_debug("%s: empty_Bfifo incoming packet too large\n", - card->name); + card->name); WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT); skb_trim(wch->bch.rx_skb, 0); return; @@ -495,7 +495,7 @@ W6692_empty_Bfifo(struct w6692_ch *wch, int count) WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT); if (debug & DEBUG_HW_DFIFO) { snprintf(card->log, 63, "B%1d-recv %s %d ", - wch->bch.nr, card->name, count); + wch->bch.nr, card->name, count); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); } } @@ -520,13 +520,13 @@ W6692_fill_Bfifo(struct w6692_ch *wch) cmd |= W_B_CMDR_XME; pr_debug("%s: fill Bfifo%d/%d\n", card->name, - count, wch->bch.tx_idx); + count, wch->bch.tx_idx); wch->bch.tx_idx += count; outsb(wch->addr + W_B_XFIFO, ptr, count); WriteW6692B(wch, W_B_CMDR, cmd); if (debug & DEBUG_HW_DFIFO) { snprintf(card->log, 63, "B%1d-send %s %d ", - wch->bch.nr, card->name, count); + wch->bch.nr, card->name, count); print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); } } @@ -586,7 +586,7 @@ disable_pots(struct w6692_ch *wch) wch->b_mode &= ~(W_B_MODE_EPCM | W_B_MODE_BSW0); WriteW6692B(wch, W_B_MODE, wch->b_mode); WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_RACT | - W_B_CMDR_XRST); + W_B_CMDR_XRST); return 0; } @@ -597,7 +597,7 @@ w6692_mode(struct w6692_ch *wch, u32 pr) card = wch->bch.hw; pr_debug("%s: B%d protocol %x-->%x\n", card->name, - wch->bch.nr, wch->bch.state, pr); + wch->bch.nr, wch->bch.state, pr); switch (pr) { case ISDN_P_NONE: if ((card->fmask & pots) && (wch->b_mode & W_B_MODE_EPCM)) @@ -614,7 +614,7 @@ w6692_mode(struct w6692_ch *wch, u32 pr) WriteW6692B(wch, W_B_MODE, wch->b_mode); WriteW6692B(wch, W_B_EXIM, 0); WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_RACT | - W_B_CMDR_XRST); + W_B_CMDR_XRST); test_and_set_bit(FLG_TRANSPARENT, &wch->bch.Flags); break; case ISDN_P_B_HDLC: @@ -624,7 +624,7 @@ w6692_mode(struct w6692_ch *wch, u32 pr) WriteW6692B(wch, W_B_ADM2, 0xff); WriteW6692B(wch, W_B_EXIM, 0); WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_RACT | - W_B_CMDR_XRST); + W_B_CMDR_XRST); test_and_set_bit(FLG_HDLC, &wch->bch.Flags); break; default: @@ -667,7 +667,7 @@ W6692B_interrupt(struct w6692_hw *card, int ch) if ((star & W_B_STAR_RDOV) && test_bit(FLG_ACTIVE, &wch->bch.Flags)) { pr_debug("%s: B%d RDOV proto=%x\n", card->name, - wch->bch.nr, wch->bch.state); + wch->bch.nr, wch->bch.state); #ifdef ERROR_STATISTIC wch->bch.err_rdo++; #endif @@ -675,21 +675,21 @@ W6692B_interrupt(struct w6692_hw *card, int ch) if (test_bit(FLG_HDLC, &wch->bch.Flags)) { if (star & W_B_STAR_CRCE) { pr_debug("%s: B%d CRC error\n", - card->name, wch->bch.nr); + card->name, wch->bch.nr); #ifdef ERROR_STATISTIC wch->bch.err_crc++; #endif } if (star & W_B_STAR_RMB) { pr_debug("%s: B%d message abort\n", - card->name, wch->bch.nr); + card->name, wch->bch.nr); #ifdef ERROR_STATISTIC wch->bch.err_inv++; #endif } } WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RACK | - W_B_CMDR_RRST | W_B_CMDR_RACT); + W_B_CMDR_RRST | W_B_CMDR_RACT); if (wch->bch.rx_skb) skb_trim(wch->bch.rx_skb, 0); } else { @@ -706,12 +706,12 @@ W6692B_interrupt(struct w6692_hw *card, int ch) star = ReadW6692B(wch, W_B_STAR); if (star & W_B_STAR_RDOV) { pr_debug("%s: B%d RDOV proto=%x\n", card->name, - wch->bch.nr, wch->bch.state); + wch->bch.nr, wch->bch.state); #ifdef ERROR_STATISTIC wch->bch.err_rdo++; #endif WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RACK | - W_B_CMDR_RRST | W_B_CMDR_RACT); + W_B_CMDR_RRST | W_B_CMDR_RACT); } else { W6692_empty_Bfifo(wch, W_B_FIFO_THRESH); if (test_bit(FLG_TRANSPARENT, &wch->bch.Flags) && @@ -723,28 +723,28 @@ W6692B_interrupt(struct w6692_hw *card, int ch) /* only if it is not handled yet */ if (!(star & W_B_STAR_RDOV)) { pr_debug("%s: B%d RDOV IRQ proto=%x\n", card->name, - wch->bch.nr, wch->bch.state); + wch->bch.nr, wch->bch.state); #ifdef ERROR_STATISTIC wch->bch.err_rdo++; #endif WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RACK | - W_B_CMDR_RRST | W_B_CMDR_RACT); + W_B_CMDR_RRST | W_B_CMDR_RACT); } } if (stat & W_B_EXI_XFR) { if (!(stat & (W_B_EXI_RME | W_B_EXI_RMR))) { star = ReadW6692B(wch, W_B_STAR); pr_debug("%s: B%d star %02x\n", card->name, - wch->bch.nr, star); + wch->bch.nr, star); } if (star & W_B_STAR_XDOW) { pr_debug("%s: B%d XDOW proto=%x\n", card->name, - wch->bch.nr, wch->bch.state); + wch->bch.nr, wch->bch.state); #ifdef ERROR_STATISTIC wch->bch.err_xdu++; #endif WriteW6692B(wch, W_B_CMDR, W_B_CMDR_XRST | - W_B_CMDR_RACT); + W_B_CMDR_RACT); /* resend */ if (wch->bch.tx_skb) { if (!test_bit(FLG_TRANSPARENT, &wch->bch.Flags)) @@ -757,7 +757,7 @@ W6692B_interrupt(struct w6692_hw *card, int ch) } if (stat & W_B_EXI_XDUN) { pr_debug("%s: B%d XDUN proto=%x\n", card->name, - wch->bch.nr, wch->bch.state); + wch->bch.nr, wch->bch.state); #ifdef ERROR_STATISTIC wch->bch.err_xdu++; #endif @@ -818,7 +818,7 @@ dbusy_timer_handler(struct dchannel *dch) rbch = ReadW6692(card, W_D_RBCH); star = ReadW6692(card, W_D_STAR); pr_debug("%s: D-Channel Busy RBCH %02x STAR %02x\n", - card->name, rbch, star); + card->name, rbch, star); if (star & W_D_STAR_XBZ) /* D-Channel Busy */ test_and_set_bit(FLG_L1_BUSY, &dch->Flags); else { @@ -888,7 +888,7 @@ void initW6692(struct w6692_hw *card) val = ReadW6692(card, W_XADDR); if (debug & DEBUG_HW) pr_notice("%s: W_XADDR=%02x\n", - card->name, val); + card->name, val); } } } @@ -924,7 +924,7 @@ init_card(struct w6692_hw *card) msleep_interruptible(10); if (debug & DEBUG_HW) pr_notice("%s: IRQ %d count %d\n", card->name, - card->irq, card->irqcnt); + card->irq, card->irqcnt); if (!card->irqcnt) { pr_info("%s: IRQ(%d) getting no IRQs during init %d\n", card->name, card->irq, 3 - cnt); @@ -970,7 +970,7 @@ w6692_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&card->lock, flags); if (!ret) _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); break; case PH_DEACTIVATE_REQ: spin_lock_irqsave(&card->lock, flags); @@ -978,7 +978,7 @@ w6692_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) w6692_mode(bc, ISDN_P_NONE); spin_unlock_irqrestore(&card->lock, flags); _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); ret = 0; break; default: @@ -1000,7 +1000,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_GETOP: cq->op = 0; break; - /* Nothing implemented yet */ + /* Nothing implemented yet */ case MISDN_CTRL_FILL_EMPTY: default: pr_info("%s: unknown Op %x\n", __func__, cq->op); @@ -1168,16 +1168,16 @@ w6692_l1callback(struct dchannel *dch, u32 cmd) case PH_ACTIVATE_IND: test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; case PH_DEACTIVATE_IND: test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); break; default: pr_debug("%s: %s unknown command %x\n", card->name, - __func__, cmd); + __func__, cmd); return -1; } return 0; @@ -1187,7 +1187,7 @@ static int open_dchannel(struct w6692_hw *card, struct channel_req *rq) { pr_debug("%s: %s dev(%d) open from %p\n", card->name, __func__, - card->dch.dev.id, __builtin_return_address(1)); + card->dch.dev.id, __builtin_return_address(1)); if (rq->protocol != ISDN_P_TE_S0) return -EINVAL; if (rq->adr.channel == 1) @@ -1197,7 +1197,7 @@ open_dchannel(struct w6692_hw *card, struct channel_req *rq) rq->ch->protocol = rq->protocol; if (card->dch.state == 7) _queue_data(rq->ch, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); return 0; } @@ -1225,7 +1225,7 @@ w6692_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg) break; case CLOSE_CHANNEL: pr_debug("%s: dev(%d) close from %p\n", card->name, - dch->dev.id, __builtin_return_address(0)); + dch->dev.id, __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -1245,7 +1245,7 @@ setup_w6692(struct w6692_hw *card) if (!request_region(card->addr, 256, card->name)) { pr_info("%s: config port %x-%x already in use\n", card->name, - card->addr, card->addr + 255); + card->addr, card->addr + 255); return -EIO; } W6692Version(card); @@ -1333,7 +1333,7 @@ setup_instance(struct w6692_hw *card) if (err) goto error_setup; err = mISDN_register_device(&card->dch.dev, &card->pdev->dev, - card->name); + card->name); if (err) goto error_reg; err = init_card(card); diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c index 5d7278397878..89342f7e0c5b 100644 --- a/drivers/isdn/hisax/amd7930_fn.c +++ b/drivers/isdn/hisax/amd7930_fn.c @@ -101,26 +101,26 @@ static WORD initAMD[] = { static void /* macro wWordAMD */ WriteWordAmd7930(struct IsdnCardState *cs, BYTE reg, WORD val) { - wByteAMD(cs, 0x00, reg); - wByteAMD(cs, 0x01, LOBYTE(val)); - wByteAMD(cs, 0x01, HIBYTE(val)); + wByteAMD(cs, 0x00, reg); + wByteAMD(cs, 0x01, LOBYTE(val)); + wByteAMD(cs, 0x01, HIBYTE(val)); } static WORD /* macro rWordAMD */ ReadWordAmd7930(struct IsdnCardState *cs, BYTE reg) { - WORD res; - /* direct access register */ - if(reg < 8) { - res = rByteAMD(cs, reg); - res += 256*rByteAMD(cs, reg); - } - /* indirect access register */ - else { - wByteAMD(cs, 0x00, reg); - res = rByteAMD(cs, 0x01); - res += 256*rByteAMD(cs, 0x01); - } + WORD res; + /* direct access register */ + if (reg < 8) { + res = rByteAMD(cs, reg); + res += 256 * rByteAMD(cs, reg); + } + /* indirect access register */ + else { + wByteAMD(cs, 0x00, reg); + res = rByteAMD(cs, 0x01); + res += 256 * rByteAMD(cs, 0x01); + } return (res); } @@ -131,23 +131,23 @@ Amd7930_ph_command(struct IsdnCardState *cs, u_char command, char *s) if (cs->debug & L1_DEB_ISAC) debugl1(cs, "AMD7930: %s: ph_command 0x%02X", s, command); - cs->dc.amd7930.lmr1 = command; - wByteAMD(cs, 0xA3, command); + cs->dc.amd7930.lmr1 = command; + wByteAMD(cs, 0xA3, command); } static BYTE i430States[] = { // to reset F3 F4 F5 F6 F7 F8 AR from - 0x01, 0x02, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, // init - 0x01, 0x02, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, // reset - 0x01, 0x02, 0x00, 0x00, 0x00, 0x09, 0x05, 0x04, // F3 - 0x01, 0x02, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, // F4 - 0x01, 0x02, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, // F5 - 0x01, 0x03, 0x00, 0x00, 0x00, 0x06, 0x05, 0x00, // F6 - 0x11, 0x13, 0x00, 0x00, 0x1B, 0x00, 0x15, 0x00, // F7 - 0x01, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // F8 - 0x01, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0A}; // AR + 0x01, 0x02, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, // init + 0x01, 0x02, 0x00, 0x00, 0x00, 0x07, 0x05, 0x00, // reset + 0x01, 0x02, 0x00, 0x00, 0x00, 0x09, 0x05, 0x04, // F3 + 0x01, 0x02, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, // F4 + 0x01, 0x02, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, // F5 + 0x01, 0x03, 0x00, 0x00, 0x00, 0x06, 0x05, 0x00, // F6 + 0x11, 0x13, 0x00, 0x00, 0x1B, 0x00, 0x15, 0x00, // F7 + 0x01, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, // F8 + 0x01, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0A}; // AR /* Row init - reset F3 F4 F5 F6 F7 F8 AR */ @@ -158,9 +158,9 @@ static BYTE stateHelper[] = { 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x static void Amd7930_get_state(struct IsdnCardState *cs) { - BYTE lsr = rByteAMD(cs, 0xA1); - cs->dc.amd7930.ph_state = (lsr & 0x7) + 2; - Amd7930_new_ph(cs); + BYTE lsr = rByteAMD(cs, 0xA1); + cs->dc.amd7930.ph_state = (lsr & 0x7) + 2; + Amd7930_new_ph(cs); } @@ -168,65 +168,65 @@ Amd7930_get_state(struct IsdnCardState *cs) { static void Amd7930_new_ph(struct IsdnCardState *cs) { - u_char index = stateHelper[cs->dc.amd7930.old_state]*8 + stateHelper[cs->dc.amd7930.ph_state]-1; - u_char message = i430States[index]; + u_char index = stateHelper[cs->dc.amd7930.old_state] * 8 + stateHelper[cs->dc.amd7930.ph_state] - 1; + u_char message = i430States[index]; - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "AMD7930: new_ph %d, old_ph %d, message %d, index %d", - cs->dc.amd7930.ph_state, cs->dc.amd7930.old_state, message & 0x0f, index); + cs->dc.amd7930.ph_state, cs->dc.amd7930.old_state, message & 0x0f, index); - cs->dc.amd7930.old_state = cs->dc.amd7930.ph_state; + cs->dc.amd7930.old_state = cs->dc.amd7930.ph_state; - /* abort transmit if nessesary */ - if ((message & 0xf0) && (cs->tx_skb)) { - wByteAMD(cs, 0x21, 0xC2); - wByteAMD(cs, 0x21, 0x02); - } + /* abort transmit if nessesary */ + if ((message & 0xf0) && (cs->tx_skb)) { + wByteAMD(cs, 0x21, 0xC2); + wByteAMD(cs, 0x21, 0x02); + } switch (message & 0x0f) { - case (1): - l1_msg(cs, HW_RESET | INDICATION, NULL); - Amd7930_get_state(cs); - break; - case (2): /* init, Card starts in F3 */ - l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); - break; - case (3): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (4): - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - Amd7930_ph_command(cs, 0x50, "HW_ENABLE REQUEST"); - break; - case (5): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (6): - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - case (7): /* init, Card starts in F7 */ - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - case (8): - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - /* fall through */ - case (9): - Amd7930_ph_command(cs, 0x40, "HW_ENABLE REQ cleared if set"); - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - case (10): - Amd7930_ph_command(cs, 0x40, "T3 expired, HW_ENABLE REQ cleared"); - cs->dc.amd7930.old_state = 3; - break; - case (11): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - default: - break; + case (1): + l1_msg(cs, HW_RESET | INDICATION, NULL); + Amd7930_get_state(cs); + break; + case (2): /* init, Card starts in F3 */ + l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); + break; + case (3): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (4): + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + Amd7930_ph_command(cs, 0x50, "HW_ENABLE REQUEST"); + break; + case (5): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (6): + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + case (7): /* init, Card starts in F7 */ + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + case (8): + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + /* fall through */ + case (9): + Amd7930_ph_command(cs, 0x40, "HW_ENABLE REQ cleared if set"); + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + case (10): + Amd7930_ph_command(cs, 0x40, "T3 expired, HW_ENABLE REQ cleared"); + cs->dc.amd7930.old_state = 3; + break; + case (11): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + default: + break; } } @@ -237,10 +237,10 @@ Amd7930_bh(struct work_struct *work) { struct IsdnCardState *cs = container_of(work, struct IsdnCardState, tqueue); - struct PStack *stptr; + struct PStack *stptr; if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { - if (cs->debug) + if (cs->debug) debugl1(cs, "Amd7930: bh, D-Channel Busy cleared"); stptr = cs->stlist; while (stptr != NULL) { @@ -249,29 +249,29 @@ Amd7930_bh(struct work_struct *work) } } if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "AMD7930: bh, D_L1STATECHANGE"); - Amd7930_new_ph(cs); - } - - if (test_and_clear_bit(D_RCVBUFREADY, &cs->event)) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "AMD7930: bh, D_RCVBUFREADY"); - DChannel_proc_rcv(cs); - } - - if (test_and_clear_bit(D_XMTBUFREADY, &cs->event)) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "AMD7930: bh, D_XMTBUFREADY"); - DChannel_proc_xmt(cs); - } + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "AMD7930: bh, D_L1STATECHANGE"); + Amd7930_new_ph(cs); + } + + if (test_and_clear_bit(D_RCVBUFREADY, &cs->event)) { + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "AMD7930: bh, D_RCVBUFREADY"); + DChannel_proc_rcv(cs); + } + + if (test_and_clear_bit(D_XMTBUFREADY, &cs->event)) { + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "AMD7930: bh, D_XMTBUFREADY"); + DChannel_proc_xmt(cs); + } } static void Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag) { - BYTE stat, der; + BYTE stat, der; BYTE *ptr; struct sk_buff *skb; @@ -288,54 +288,54 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag) /* read D-Channel-Fifo*/ stat = rByteAMD(cs, 0x07); // DSR2 - /* while Data in Fifo ... */ - while ( (stat & 2) && ((ptr-cs->rcvbuf) < MAX_DFRAME_LEN_L1) ) { - *ptr = rByteAMD(cs, 0x04); // DCRB - ptr++; - stat = rByteAMD(cs, 0x07); // DSR2 - cs->rcvidx = ptr - cs->rcvbuf; - - /* Paket ready? */ - if (stat & 1) { - - der = rWordAMD(cs, 0x03); - - /* no errors, packet ok */ - if(!der && !flag) { - rWordAMD(cs, 0x89); // clear DRCR - - if ((cs->rcvidx) > 0) { - if (!(skb = alloc_skb(cs->rcvidx, GFP_ATOMIC))) - printk(KERN_WARNING "HiSax: Amd7930: empty_Dfifo, D receive out of memory!\n"); - else { - /* Debugging */ - if (cs->debug & L1_DEB_ISAC_FIFO) { - char *t = cs->dlog; - - t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx); - QuickHex(t, cs->rcvbuf, cs->rcvidx); - debugl1(cs, cs->dlog); - } - /* moves received data in sk-buffer */ - memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx); - skb_queue_tail(&cs->rq, skb); + /* while Data in Fifo ... */ + while ((stat & 2) && ((ptr-cs->rcvbuf) < MAX_DFRAME_LEN_L1)) { + *ptr = rByteAMD(cs, 0x04); // DCRB + ptr++; + stat = rByteAMD(cs, 0x07); // DSR2 + cs->rcvidx = ptr - cs->rcvbuf; + + /* Paket ready? */ + if (stat & 1) { + + der = rWordAMD(cs, 0x03); + + /* no errors, packet ok */ + if (!der && !flag) { + rWordAMD(cs, 0x89); // clear DRCR + + if ((cs->rcvidx) > 0) { + if (!(skb = alloc_skb(cs->rcvidx, GFP_ATOMIC))) + printk(KERN_WARNING "HiSax: Amd7930: empty_Dfifo, D receive out of memory!\n"); + else { + /* Debugging */ + if (cs->debug & L1_DEB_ISAC_FIFO) { + char *t = cs->dlog; + + t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx); + QuickHex(t, cs->rcvbuf, cs->rcvidx); + debugl1(cs, cs->dlog); } + /* moves received data in sk-buffer */ + memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx); + skb_queue_tail(&cs->rq, skb); } - } - /* throw damaged packets away, reset receive-buffer, indicate RX */ - ptr = cs->rcvbuf; - cs->rcvidx = 0; - schedule_event(cs, D_RCVBUFREADY); + } - } - /* Packet to long, overflow */ - if(cs->rcvidx >= MAX_DFRAME_LEN_L1) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "AMD7930: empty_Dfifo L2-Framelength overrun"); + /* throw damaged packets away, reset receive-buffer, indicate RX */ + ptr = cs->rcvbuf; cs->rcvidx = 0; - return; + schedule_event(cs, D_RCVBUFREADY); } + } + /* Packet to long, overflow */ + if (cs->rcvidx >= MAX_DFRAME_LEN_L1) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "AMD7930: empty_Dfifo L2-Framelength overrun"); + cs->rcvidx = 0; + return; + } /* AMD interrupts on */ AmdIrqOn(cs); } @@ -345,9 +345,9 @@ static void Amd7930_fill_Dfifo(struct IsdnCardState *cs) { - WORD dtcrr, dtcrw, len, count; - BYTE txstat, dmr3; - BYTE *ptr, *deb_ptr; + WORD dtcrr, dtcrw, len, count; + BYTE txstat, dmr3; + BYTE *ptr, *deb_ptr; if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO)) debugl1(cs, "Amd7930: fill_Dfifo"); @@ -355,43 +355,43 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs) if ((!cs->tx_skb) || (cs->tx_skb->len <= 0)) return; - dtcrw = 0; - if(!cs->dc.amd7930.tx_xmtlen) - /* new Frame */ - len = dtcrw = cs->tx_skb->len; - /* continue frame */ - else len = cs->dc.amd7930.tx_xmtlen; + dtcrw = 0; + if (!cs->dc.amd7930.tx_xmtlen) + /* new Frame */ + len = dtcrw = cs->tx_skb->len; + /* continue frame */ + else len = cs->dc.amd7930.tx_xmtlen; /* AMD interrupts off */ AmdIrqOff(cs); - deb_ptr = ptr = cs->tx_skb->data; - - /* while free place in tx-fifo available and data in sk-buffer */ - txstat = 0x10; - while((txstat & 0x10) && (cs->tx_cnt < len)) { - wByteAMD(cs, 0x04, *ptr); - ptr++; - cs->tx_cnt++; - txstat= rByteAMD(cs, 0x07); - } - count = ptr - cs->tx_skb->data; + deb_ptr = ptr = cs->tx_skb->data; + + /* while free place in tx-fifo available and data in sk-buffer */ + txstat = 0x10; + while ((txstat & 0x10) && (cs->tx_cnt < len)) { + wByteAMD(cs, 0x04, *ptr); + ptr++; + cs->tx_cnt++; + txstat = rByteAMD(cs, 0x07); + } + count = ptr - cs->tx_skb->data; skb_pull(cs->tx_skb, count); - dtcrr = rWordAMD(cs, 0x85); // DTCR - dmr3 = rByteAMD(cs, 0x8E); + dtcrr = rWordAMD(cs, 0x85); // DTCR + dmr3 = rByteAMD(cs, 0x8E); if (cs->debug & L1_DEB_ISAC) { debugl1(cs, "Amd7930: fill_Dfifo, DMR3: 0x%02X, DTCR read: 0x%04X write: 0x%02X 0x%02X", dmr3, dtcrr, LOBYTE(dtcrw), HIBYTE(dtcrw)); - } + } - /* writeing of dtcrw starts transmit */ - if(!cs->dc.amd7930.tx_xmtlen) { - wWordAMD(cs, 0x85, dtcrw); - cs->dc.amd7930.tx_xmtlen = dtcrw; - } + /* writeing of dtcrw starts transmit */ + if (!cs->dc.amd7930.tx_xmtlen) { + wWordAMD(cs, 0x85, dtcrw); + cs->dc.amd7930.tx_xmtlen = dtcrw; + } if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { debugl1(cs, "Amd7930: fill_Dfifo dbusytimer running"); @@ -409,260 +409,260 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs) debugl1(cs, cs->dlog); } /* AMD interrupts on */ - AmdIrqOn(cs); + AmdIrqOn(cs); } void Amd7930_interrupt(struct IsdnCardState *cs, BYTE irflags) { BYTE dsr1, dsr2, lsr; - WORD der; + WORD der; - while (irflags) - { + while (irflags) + { - dsr1 = rByteAMD(cs, 0x02); - der = rWordAMD(cs, 0x03); - dsr2 = rByteAMD(cs, 0x07); - lsr = rByteAMD(cs, 0xA1); + dsr1 = rByteAMD(cs, 0x02); + der = rWordAMD(cs, 0x03); + dsr2 = rByteAMD(cs, 0x07); + lsr = rByteAMD(cs, 0xA1); - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "Amd7930: interrupt: flags: 0x%02X, DSR1: 0x%02X, DSR2: 0x%02X, LSR: 0x%02X, DER=0x%04X", irflags, dsr1, dsr2, lsr, der); + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "Amd7930: interrupt: flags: 0x%02X, DSR1: 0x%02X, DSR2: 0x%02X, LSR: 0x%02X, DER=0x%04X", irflags, dsr1, dsr2, lsr, der); - /* D error -> read DER and DSR2 bit 2 */ - if (der || (dsr2 & 4)) { + /* D error -> read DER and DSR2 bit 2 */ + if (der || (dsr2 & 4)) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "Amd7930: interrupt: D error DER=0x%04X", der); + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "Amd7930: interrupt: D error DER=0x%04X", der); + + /* RX, TX abort if collision detected */ + if (der & 2) { + wByteAMD(cs, 0x21, 0xC2); + wByteAMD(cs, 0x21, 0x02); + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); + /* restart frame */ + if (cs->tx_skb) { + skb_push(cs->tx_skb, cs->tx_cnt); + cs->tx_cnt = 0; + cs->dc.amd7930.tx_xmtlen = 0; + Amd7930_fill_Dfifo(cs); + } else { + printk(KERN_WARNING "HiSax: Amd7930 D-Collision, no skb\n"); + debugl1(cs, "Amd7930: interrupt: D-Collision, no skb"); + } + } + /* remove damaged data from fifo */ + Amd7930_empty_Dfifo(cs, 1); - /* RX, TX abort if collision detected */ - if (der & 2) { - wByteAMD(cs, 0x21, 0xC2); - wByteAMD(cs, 0x21, 0x02); if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) del_timer(&cs->dbusytimer); if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) schedule_event(cs, D_CLEARBUSY); - /* restart frame */ - if (cs->tx_skb) { + /* restart TX-Frame */ + if (cs->tx_skb) { skb_push(cs->tx_skb, cs->tx_cnt); cs->tx_cnt = 0; - cs->dc.amd7930.tx_xmtlen = 0; + cs->dc.amd7930.tx_xmtlen = 0; Amd7930_fill_Dfifo(cs); - } else { - printk(KERN_WARNING "HiSax: Amd7930 D-Collision, no skb\n"); - debugl1(cs, "Amd7930: interrupt: D-Collision, no skb"); } - } - /* remove damaged data from fifo */ - Amd7930_empty_Dfifo(cs, 1); - - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); - /* restart TX-Frame */ - if (cs->tx_skb) { - skb_push(cs->tx_skb, cs->tx_cnt); - cs->tx_cnt = 0; - cs->dc.amd7930.tx_xmtlen = 0; - Amd7930_fill_Dfifo(cs); } - } - /* D TX FIFO empty -> fill */ - if (irflags & 1) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "Amd7930: interrupt: clear Timer and fill D-TX-FIFO if data"); + /* D TX FIFO empty -> fill */ + if (irflags & 1) { + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "Amd7930: interrupt: clear Timer and fill D-TX-FIFO if data"); - /* AMD interrupts off */ - AmdIrqOff(cs); + /* AMD interrupts off */ + AmdIrqOff(cs); - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); - if (cs->tx_skb) { - if (cs->tx_skb->len) - Amd7930_fill_Dfifo(cs); + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); + if (cs->tx_skb) { + if (cs->tx_skb->len) + Amd7930_fill_Dfifo(cs); + } + /* AMD interrupts on */ + AmdIrqOn(cs); } - /* AMD interrupts on */ - AmdIrqOn(cs); - } - /* D RX FIFO full or tiny packet in Fifo -> empty */ - if ((irflags & 2) || (dsr1 & 2)) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "Amd7930: interrupt: empty D-FIFO"); - Amd7930_empty_Dfifo(cs, 0); - } + /* D RX FIFO full or tiny packet in Fifo -> empty */ + if ((irflags & 2) || (dsr1 & 2)) { + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "Amd7930: interrupt: empty D-FIFO"); + Amd7930_empty_Dfifo(cs, 0); + } - /* D-Frame transmit complete */ - if (dsr1 & 64) { - if (cs->debug & L1_DEB_ISAC) { - debugl1(cs, "Amd7930: interrupt: transmit packet ready"); - } - /* AMD interrupts off */ - AmdIrqOff(cs); + /* D-Frame transmit complete */ + if (dsr1 & 64) { + if (cs->debug & L1_DEB_ISAC) { + debugl1(cs, "Amd7930: interrupt: transmit packet ready"); + } + /* AMD interrupts off */ + AmdIrqOff(cs); - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "Amd7930: interrupt: TX-Packet ready, freeing skb"); - dev_kfree_skb_irq(cs->tx_skb); - cs->tx_cnt = 0; - cs->dc.amd7930.tx_xmtlen=0; - cs->tx_skb = NULL; - } - if ((cs->tx_skb = skb_dequeue(&cs->sq))) { - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "Amd7930: interrupt: TX-Packet ready, next packet dequeued"); - cs->tx_cnt = 0; - cs->dc.amd7930.tx_xmtlen=0; - Amd7930_fill_Dfifo(cs); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "Amd7930: interrupt: TX-Packet ready, freeing skb"); + dev_kfree_skb_irq(cs->tx_skb); + cs->tx_cnt = 0; + cs->dc.amd7930.tx_xmtlen = 0; + cs->tx_skb = NULL; + } + if ((cs->tx_skb = skb_dequeue(&cs->sq))) { + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "Amd7930: interrupt: TX-Packet ready, next packet dequeued"); + cs->tx_cnt = 0; + cs->dc.amd7930.tx_xmtlen = 0; + Amd7930_fill_Dfifo(cs); + } + else + schedule_event(cs, D_XMTBUFREADY); + /* AMD interrupts on */ + AmdIrqOn(cs); } - else - schedule_event(cs, D_XMTBUFREADY); - /* AMD interrupts on */ - AmdIrqOn(cs); - } - /* LIU status interrupt -> read LSR, check statechanges */ - if (lsr & 0x38) { - /* AMD interrupts off */ - AmdIrqOff(cs); + /* LIU status interrupt -> read LSR, check statechanges */ + if (lsr & 0x38) { + /* AMD interrupts off */ + AmdIrqOff(cs); - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "Amd: interrupt: LSR=0x%02X, LIU is in state %d", lsr, ((lsr & 0x7) +2)); + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "Amd: interrupt: LSR=0x%02X, LIU is in state %d", lsr, ((lsr & 0x7) + 2)); - cs->dc.amd7930.ph_state = (lsr & 0x7) + 2; + cs->dc.amd7930.ph_state = (lsr & 0x7) + 2; - schedule_event(cs, D_L1STATECHANGE); - /* AMD interrupts on */ - AmdIrqOn(cs); - } + schedule_event(cs, D_L1STATECHANGE); + /* AMD interrupts on */ + AmdIrqOn(cs); + } - /* reads Interrupt-Register again. If there is a new interrupt-flag: restart handler */ - irflags = rByteAMD(cs, 0x00); - } + /* reads Interrupt-Register again. If there is a new interrupt-flag: restart handler */ + irflags = rByteAMD(cs, 0x00); + } } static void Amd7930_l1hw(struct PStack *st, int pr, void *arg) { - struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; + struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; struct sk_buff *skb = arg; u_long flags; - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: l1hw called, pr: 0x%04X", pr); switch (pr) { - case (PH_DATA | REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); -#ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "Amd7930: l1hw: PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; - cs->dc.amd7930.tx_xmtlen=0; + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "Amd7930: l1hw: PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "Amd7930: l1hw: PH_DATA Queued", 0); #endif - Amd7930_fill_Dfifo(cs); - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "Amd7930: l1hw: l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - spin_unlock_irqrestore(&cs->lock, flags); - break; - } - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; - cs->dc.amd7930.tx_xmtlen=0; + cs->dc.amd7930.tx_xmtlen = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "Amd7930: l1hw: PH_DATA_PULLED", 0); + Logl2Frame(cs, skb, "Amd7930: l1hw: PH_DATA", 0); #endif Amd7930_fill_Dfifo(cs); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "Amd7930: l1hw: l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; + cs->dc.amd7930.tx_xmtlen = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "Amd7930: l1hw: -> PH_REQUEST_PULL, skb: %s", (cs->tx_skb)? "yes":"no"); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "Amd7930: l1hw: PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - if ((cs->dc.amd7930.ph_state == 8)) { - /* b-channels off, PH-AR cleared - * change to F3 */ - Amd7930_ph_command(cs, 0x20, "HW_RESET REQEST"); //LMR1 bit 5 - spin_unlock_irqrestore(&cs->lock, flags); - } else { - Amd7930_ph_command(cs, 0x40, "HW_RESET REQUEST"); - cs->dc.amd7930.ph_state = 2; - spin_unlock_irqrestore(&cs->lock, flags); - Amd7930_new_ph(cs); - } - break; - case (HW_ENABLE | REQUEST): - cs->dc.amd7930.ph_state = 9; - Amd7930_new_ph(cs); - break; - case (HW_INFO3 | REQUEST): - // automatic - break; - case (HW_TESTLOOP | REQUEST): - /* not implemented yet */ - break; - case (HW_DEACTIVATE | RESPONSE): - skb_queue_purge(&cs->rq); - skb_queue_purge(&cs->sq); - if (cs->tx_skb) { - dev_kfree_skb(cs->tx_skb); - cs->tx_skb = NULL; - } - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); - break; - default: - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "Amd7930: l1hw: unknown %04x", pr); - break; + Amd7930_fill_Dfifo(cs); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG /* psa */ + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "Amd7930: l1hw: -> PH_REQUEST_PULL, skb: %s", (cs->tx_skb) ? "yes" : "no"); +#endif + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + if ((cs->dc.amd7930.ph_state == 8)) { + /* b-channels off, PH-AR cleared + * change to F3 */ + Amd7930_ph_command(cs, 0x20, "HW_RESET REQEST"); //LMR1 bit 5 + spin_unlock_irqrestore(&cs->lock, flags); + } else { + Amd7930_ph_command(cs, 0x40, "HW_RESET REQUEST"); + cs->dc.amd7930.ph_state = 2; + spin_unlock_irqrestore(&cs->lock, flags); + Amd7930_new_ph(cs); + } + break; + case (HW_ENABLE | REQUEST): + cs->dc.amd7930.ph_state = 9; + Amd7930_new_ph(cs); + break; + case (HW_INFO3 | REQUEST): + // automatic + break; + case (HW_TESTLOOP | REQUEST): + /* not implemented yet */ + break; + case (HW_DEACTIVATE | RESPONSE): + skb_queue_purge(&cs->rq); + skb_queue_purge(&cs->sq); + if (cs->tx_skb) { + dev_kfree_skb(cs->tx_skb); + cs->tx_skb = NULL; + } + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "Amd7930: l1hw: unknown %04x", pr); + break; } } @@ -670,16 +670,16 @@ static void setstack_Amd7930(struct PStack *st, struct IsdnCardState *cs) { - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: setstack called"); - st->l1.l1hw = Amd7930_l1hw; + st->l1.l1hw = Amd7930_l1hw; } static void DC_Close_Amd7930(struct IsdnCardState *cs) { - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: DC_Close called"); } @@ -689,23 +689,23 @@ dbusy_timer_handler(struct IsdnCardState *cs) { u_long flags; struct PStack *stptr; - WORD dtcr, der; - BYTE dsr1, dsr2; + WORD dtcr, der; + BYTE dsr1, dsr2; - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: dbusy_timer expired!"); if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { spin_lock_irqsave(&cs->lock, flags); - /* D Transmit Byte Count Register: - * Counts down packet's number of Bytes, 0 if packet ready */ - dtcr = rWordAMD(cs, 0x85); - dsr1 = rByteAMD(cs, 0x02); - dsr2 = rByteAMD(cs, 0x07); - der = rWordAMD(cs, 0x03); - - if (cs->debug & L1_DEB_ISAC) + /* D Transmit Byte Count Register: + * Counts down packet's number of Bytes, 0 if packet ready */ + dtcr = rWordAMD(cs, 0x85); + dsr1 = rByteAMD(cs, 0x02); + dsr2 = rByteAMD(cs, 0x07); + der = rWordAMD(cs, 0x03); + + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: dbusy_timer_handler: DSR1=0x%02X, DSR2=0x%02X, DER=0x%04X, cs->tx_skb->len=%u, tx_stat=%u, dtcr=%u, cs->tx_cnt=%u", dsr1, dsr2, der, cs->tx_skb->len, cs->dc.amd7930.tx_xmtlen, dtcr, cs->tx_cnt); if ((cs->dc.amd7930.tx_xmtlen - dtcr) < cs->tx_cnt) { /* D-Channel Busy */ @@ -724,7 +724,7 @@ dbusy_timer_handler(struct IsdnCardState *cs) dev_kfree_skb_any(cs->tx_skb); cs->tx_cnt = 0; cs->tx_skb = NULL; - cs->dc.amd7930.tx_xmtlen = 0; + cs->dc.amd7930.tx_xmtlen = 0; } else { printk(KERN_WARNING "HiSax: Amd7930: D-Channel Busy no skb\n"); debugl1(cs, "Amd7930: D-Channel Busy no skb"); @@ -736,7 +736,7 @@ dbusy_timer_handler(struct IsdnCardState *cs) spin_unlock_irqrestore(&cs->lock, flags); cs->irq_func(cs->irq, cs); - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: dbusy_timer_handler: Transmitter reset"); } } @@ -746,16 +746,16 @@ dbusy_timer_handler(struct IsdnCardState *cs) void Amd7930_init(struct IsdnCardState *cs) { - WORD *ptr; - BYTE cmd, cnt; + WORD *ptr; + BYTE cmd, cnt; - if (cs->debug & L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "Amd7930: initamd called"); - cs->dc.amd7930.tx_xmtlen = 0; - cs->dc.amd7930.old_state = 0; - cs->dc.amd7930.lmr1 = 0x40; - cs->dc.amd7930.ph_command = Amd7930_ph_command; + cs->dc.amd7930.tx_xmtlen = 0; + cs->dc.amd7930.old_state = 0; + cs->dc.amd7930.lmr1 = 0x40; + cs->dc.amd7930.ph_command = Amd7930_ph_command; cs->setstack_d = setstack_Amd7930; cs->DC_Close = DC_Close_Amd7930; @@ -763,19 +763,19 @@ void Amd7930_init(struct IsdnCardState *cs) for (ptr = initAMD; *ptr != 0xFFFF; ) { cmd = LOBYTE(*ptr); - /* read */ - if (*ptr++ >= 0x100) { + /* read */ + if (*ptr++ >= 0x100) { if (cmd < 8) - /* reset register */ - rByteAMD(cs, cmd); + /* reset register */ + rByteAMD(cs, cmd); else { wByteAMD(cs, 0x00, cmd); for (cnt = *ptr++; cnt > 0; cnt--) rByteAMD(cs, 0x01); } } - /* write */ - else if (cmd < 8) + /* write */ + else if (cmd < 8) wByteAMD(cs, cmd, LOBYTE(*ptr++)); else { @@ -789,7 +789,7 @@ void Amd7930_init(struct IsdnCardState *cs) void __devinit setup_Amd7930(struct IsdnCardState *cs) { - INIT_WORK(&cs->tqueue, Amd7930_bh); + INIT_WORK(&cs->tqueue, Amd7930_bh); cs->dbusytimer.function = (void *) dbusy_timer_handler; cs->dbusytimer.data = (long) cs; init_timer(&cs->dbusytimer); diff --git a/drivers/isdn/hisax/arcofi.c b/drivers/isdn/hisax/arcofi.c index 21cbbe1d5563..29ec2dfbd155 100644 --- a/drivers/isdn/hisax/arcofi.c +++ b/drivers/isdn/hisax/arcofi.c @@ -9,7 +9,7 @@ * of the GNU General Public License, incorporated herein by reference. * */ - + #include #include "hisax.h" #include "isdnl1.h" @@ -22,9 +22,9 @@ static void add_arcofi_timer(struct IsdnCardState *cs) { if (test_and_set_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) { del_timer(&cs->dc.isac.arcofitimer); - } + } init_timer(&cs->dc.isac.arcofitimer); - cs->dc.isac.arcofitimer.expires = jiffies + ((ARCOFI_TIMER_VALUE * HZ)/1000); + cs->dc.isac.arcofitimer.expires = jiffies + ((ARCOFI_TIMER_VALUE * HZ) / 1000); add_timer(&cs->dc.isac.arcofitimer); } @@ -34,11 +34,11 @@ send_arcofi(struct IsdnCardState *cs) { cs->dc.isac.mon_txp = 0; cs->dc.isac.mon_txc = cs->dc.isac.arcofi_list->len; memcpy(cs->dc.isac.mon_tx, cs->dc.isac.arcofi_list->msg, cs->dc.isac.mon_txc); - switch(cs->dc.isac.arcofi_bc) { - case 0: break; - case 1: cs->dc.isac.mon_tx[1] |= 0x40; - break; - default: break; + switch (cs->dc.isac.arcofi_bc) { + case 0: break; + case 1: cs->dc.isac.mon_tx[1] |= 0x40; + break; + default: break; } cs->dc.isac.mocr &= 0x0f; cs->dc.isac.mocr |= 0xa0; @@ -58,42 +58,25 @@ arcofi_fsm(struct IsdnCardState *cs, int event, void *data) { cs->dc.isac.arcofi_state = ARCOFI_NOP; test_and_set_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags); wake_up(&cs->dc.isac.arcofi_wait); - return(1); + return (1); } switch (cs->dc.isac.arcofi_state) { - case ARCOFI_NOP: - if (event == ARCOFI_START) { - cs->dc.isac.arcofi_list = data; - cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT; - send_arcofi(cs); - } - break; - case ARCOFI_TRANSMIT: - if (event == ARCOFI_TX_END) { - if (cs->dc.isac.arcofi_list->receive) { - add_arcofi_timer(cs); - cs->dc.isac.arcofi_state = ARCOFI_RECEIVE; - } else { - if (cs->dc.isac.arcofi_list->next) { - cs->dc.isac.arcofi_list = - cs->dc.isac.arcofi_list->next; - send_arcofi(cs); - } else { - if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) { - del_timer(&cs->dc.isac.arcofitimer); - } - cs->dc.isac.arcofi_state = ARCOFI_NOP; - wake_up(&cs->dc.isac.arcofi_wait); - } - } - } - break; - case ARCOFI_RECEIVE: - if (event == ARCOFI_RX_END) { + case ARCOFI_NOP: + if (event == ARCOFI_START) { + cs->dc.isac.arcofi_list = data; + cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT; + send_arcofi(cs); + } + break; + case ARCOFI_TRANSMIT: + if (event == ARCOFI_TX_END) { + if (cs->dc.isac.arcofi_list->receive) { + add_arcofi_timer(cs); + cs->dc.isac.arcofi_state = ARCOFI_RECEIVE; + } else { if (cs->dc.isac.arcofi_list->next) { cs->dc.isac.arcofi_list = cs->dc.isac.arcofi_list->next; - cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT; send_arcofi(cs); } else { if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) { @@ -103,12 +86,29 @@ arcofi_fsm(struct IsdnCardState *cs, int event, void *data) { wake_up(&cs->dc.isac.arcofi_wait); } } - break; - default: - debugl1(cs, "Arcofi unknown state %x", cs->dc.isac.arcofi_state); - return(2); + } + break; + case ARCOFI_RECEIVE: + if (event == ARCOFI_RX_END) { + if (cs->dc.isac.arcofi_list->next) { + cs->dc.isac.arcofi_list = + cs->dc.isac.arcofi_list->next; + cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT; + send_arcofi(cs); + } else { + if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) { + del_timer(&cs->dc.isac.arcofitimer); + } + cs->dc.isac.arcofi_state = ARCOFI_NOP; + wake_up(&cs->dc.isac.arcofi_wait); + } + } + break; + default: + debugl1(cs, "Arcofi unknown state %x", cs->dc.isac.arcofi_state); + return (2); } - return(0); + return (0); } static void diff --git a/drivers/isdn/hisax/arcofi.h b/drivers/isdn/hisax/arcofi.h index 00c44d3ce972..b9c77529fabf 100644 --- a/drivers/isdn/hisax/arcofi.h +++ b/drivers/isdn/hisax/arcofi.h @@ -9,7 +9,7 @@ * of the GNU General Public License, incorporated herein by reference. * */ - + #define ARCOFI_USE 1 /* states */ diff --git a/drivers/isdn/hisax/asuscom.c b/drivers/isdn/hisax/asuscom.c index 1f879b500d83..2b74a40ad2a0 100644 --- a/drivers/isdn/hisax/asuscom.c +++ b/drivers/isdn/hisax/asuscom.c @@ -22,7 +22,7 @@ static const char *Asuscom_revision = "$Revision: 1.14.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define ASUS_ISAC 0 @@ -51,7 +51,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -66,7 +66,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -87,13 +87,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.asus.adr, cs->hw.asus.isac, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.asus.adr, cs->hw.asus.isac, 0, data, size); } @@ -101,23 +101,23 @@ WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) static u_char ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset) { - return (readreg(cs->hw.asus.adr, cs->hw.asus.isac, offset|0x80)); + return (readreg(cs->hw.asus.adr, cs->hw.asus.isac, offset | 0x80)); } static void WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value) { - writereg(cs->hw.asus.adr, cs->hw.asus.isac, offset|0x80, value); + writereg(cs->hw.asus.adr, cs->hw.asus.isac, offset | 0x80, value); } static void -ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.asus.adr, cs->hw.asus.isac, 0x80, data, size); } static void -WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.asus.adr, cs->hw.asus.isac, 0x80, data, size); } @@ -140,16 +140,16 @@ WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) * fast interrupt HSCX stuff goes here */ -#define READHSCX(cs, nr, reg) readreg(cs->hw.asus.adr, \ - cs->hw.asus.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.asus.adr, \ - cs->hw.asus.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.asus.adr, \ + cs->hw.asus.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.asus.adr, \ + cs->hw.asus.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.asus.adr, \ - cs->hw.asus.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.asus.adr, \ + cs->hw.asus.hscx, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.asus.adr, \ - cs->hw.asus.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.asus.adr, \ + cs->hw.asus.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -162,11 +162,11 @@ asuscom_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_ISTA + 0x40); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.asus.adr, cs->hw.asus.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_ISTA + 0x40); @@ -274,39 +274,39 @@ Asus_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_asuscom(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_asuscom(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - cs->debug |= L1_DEB_IPAC; - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_asuscom(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_asuscom(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + cs->debug |= L1_DEB_IPAC; + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } #ifdef __ISAPNP__ static struct isapnp_device_id asus_ids[] __devinitdata = { { ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), - ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), + ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1688), (unsigned long) "Asus1688 PnP" }, { ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1690), - ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1690), + ISAPNP_VENDOR('A', 'S', 'U'), ISAPNP_FUNCTION(0x1690), (unsigned long) "Asus1690 PnP" }, { ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0020), - ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0020), + ISAPNP_VENDOR('S', 'I', 'E'), ISAPNP_FUNCTION(0x0020), (unsigned long) "Isurf2 PnP" }, { ISAPNP_VENDOR('E', 'L', 'F'), ISAPNP_FUNCTION(0x0000), - ISAPNP_VENDOR('E', 'L', 'F'), ISAPNP_FUNCTION(0x0000), + ISAPNP_VENDOR('E', 'L', 'F'), ISAPNP_FUNCTION(0x0000), (unsigned long) "Iscas TE320" }, { 0, } }; @@ -330,30 +330,30 @@ setup_asuscom(struct IsdnCard *card) #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "AsusPnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); + card->para[0], card->para[1]); pnp_disable_dev(pnp_d); - return(0); + return (0); } break; } else { @@ -362,10 +362,10 @@ setup_asuscom(struct IsdnCard *card) } ipid++; pnp_c = NULL; - } + } if (!ipid->card_vendor) { printk(KERN_INFO "AsusPnP: no ISAPnP card found\n"); - return(0); + return (0); } } #endif @@ -380,14 +380,14 @@ setup_asuscom(struct IsdnCard *card) return (0); } printk(KERN_INFO "ISDNLink: defined at 0x%x IRQ %d\n", - cs->hw.asus.cfg_reg, cs->irq); + cs->hw.asus.cfg_reg, cs->irq); setup_isac(cs); cs->BC_Read_Reg = &ReadHSCX; cs->BC_Write_Reg = &WriteHSCX; cs->BC_Send_Data = &hscx_fill_fifo; cs->cardmsg = &Asus_card_msg; - val = readreg(cs->hw.asus.cfg_reg + ASUS_IPAC_ALE, - cs->hw.asus.cfg_reg + ASUS_IPAC_DATA, IPAC_ID); + val = readreg(cs->hw.asus.cfg_reg + ASUS_IPAC_ALE, + cs->hw.asus.cfg_reg + ASUS_IPAC_DATA, IPAC_ID); if ((val == 1) || (val == 2)) { cs->subtyp = ASUS_IPAC; cs->hw.asus.adr = cs->hw.asus.cfg_reg + ASUS_IPAC_ALE; @@ -415,7 +415,7 @@ setup_asuscom(struct IsdnCard *card) ISACVersion(cs, "ISDNLink:"); if (HscxVersion(cs, "ISDNLink:")) { printk(KERN_WARNING - "ISDNLink: wrong HSCX versions check IO address\n"); + "ISDNLink: wrong HSCX versions check IO address\n"); release_io_asuscom(cs); return (0); } diff --git a/drivers/isdn/hisax/avm_a1.c b/drivers/isdn/hisax/avm_a1.c index eb6b432e261f..402d489cbbf1 100644 --- a/drivers/isdn/hisax/avm_a1.c +++ b/drivers/isdn/hisax/avm_a1.c @@ -22,7 +22,7 @@ static const char *avm_revision = "$Revision: 2.15.2.4 $"; #define AVM_A1_STAT_HSCX 0x02 #define AVM_A1_STAT_TIMER 0x04 -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static inline u_char @@ -39,13 +39,13 @@ writereg(unsigned int adr, u_char off, u_char data) static inline void -read_fifo(unsigned int adr, u_char * data, int size) +read_fifo(unsigned int adr, u_char *data, int size) { insb(adr, data, size); } static void -write_fifo(unsigned int adr, u_char * data, int size) +write_fifo(unsigned int adr, u_char *data, int size) { outsb(adr, data, size); } @@ -65,13 +65,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { read_fifo(cs->hw.avm.isacfifo, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { write_fifo(cs->hw.avm.isacfifo, data, size); } @@ -158,23 +158,23 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - return(0); - case CARD_RELEASE: - release_ioregs(cs, 0x3f); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 1); - byteout(cs->hw.avm.cfg_reg, 0x16); - byteout(cs->hw.avm.cfg_reg, 0x1E); - inithscxisac(cs, 2); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + return (0); + case CARD_RELEASE: + release_ioregs(cs, 0x3f); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 1); + byteout(cs->hw.avm.cfg_reg, 0x16); + byteout(cs->hw.avm.cfg_reg, 0x1E); + inithscxisac(cs, 2); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } int __devinit diff --git a/drivers/isdn/hisax/avm_a1p.c b/drivers/isdn/hisax/avm_a1p.c index 3039c6d68fc4..39347198d643 100644 --- a/drivers/isdn/hisax/avm_a1p.c +++ b/drivers/isdn/hisax/avm_a1p.c @@ -39,7 +39,7 @@ #define ASL0_R_ISAC 0x20 /* active low */ #define ASL0_R_HSCX 0x40 /* active low */ #define ASL0_R_TESTBIT 0x80 -#define ASL0_R_IRQPENDING (ASL0_R_ISAC|ASL0_R_HSCX|ASL0_R_TIMER) +#define ASL0_R_IRQPENDING (ASL0_R_ISAC | ASL0_R_HSCX | ASL0_R_TIMER) /* write bits ASL0 */ #define ASL0_W_RESET 0x01 @@ -52,8 +52,8 @@ #define ASL1_W_LED0 0x10 #define ASL1_W_LED1 0x20 #define ASL1_W_ENABLE_S0 0xC0 - -#define byteout(addr,val) outb(val,addr) + +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static const char *avm_revision = "$Revision: 2.9.2.5 $"; @@ -61,34 +61,34 @@ static const char *avm_revision = "$Revision: 2.9.2.5 $"; static inline u_char ReadISAC(struct IsdnCardState *cs, u_char offset) { - u_char ret; + u_char ret; - offset -= 0x20; - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_REG_OFFSET+offset); - ret = bytein(cs->hw.avm.cfg_reg+DATAREG_OFFSET); + offset -= 0x20; + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, ISAC_REG_OFFSET + offset); + ret = bytein(cs->hw.avm.cfg_reg + DATAREG_OFFSET); return ret; } static inline void WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) { - offset -= 0x20; - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_REG_OFFSET+offset); - byteout(cs->hw.avm.cfg_reg+DATAREG_OFFSET, value); + offset -= 0x20; + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, ISAC_REG_OFFSET + offset); + byteout(cs->hw.avm.cfg_reg + DATAREG_OFFSET, value); } static inline void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_FIFO_OFFSET); - insb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size); + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, ISAC_FIFO_OFFSET); + insb(cs->hw.avm.cfg_reg + DATAREG_OFFSET, data, size); } static inline void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET,ISAC_FIFO_OFFSET); - outsb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size); + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, ISAC_FIFO_OFFSET); + outsb(cs->hw.avm.cfg_reg + DATAREG_OFFSET, data, size); } static inline u_char @@ -96,36 +96,36 @@ ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) { u_char ret; - offset -= 0x20; - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET, - HSCX_REG_OFFSET+hscx*HSCX_CH_DIFF+offset); - ret = bytein(cs->hw.avm.cfg_reg+DATAREG_OFFSET); + offset -= 0x20; + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, + HSCX_REG_OFFSET + hscx * HSCX_CH_DIFF + offset); + ret = bytein(cs->hw.avm.cfg_reg + DATAREG_OFFSET); return ret; } static inline void WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) { - offset -= 0x20; - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET, - HSCX_REG_OFFSET+hscx*HSCX_CH_DIFF+offset); - byteout(cs->hw.avm.cfg_reg+DATAREG_OFFSET, value); + offset -= 0x20; + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, + HSCX_REG_OFFSET + hscx * HSCX_CH_DIFF + offset); + byteout(cs->hw.avm.cfg_reg + DATAREG_OFFSET, value); } static inline void -ReadHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size) +ReadHSCXfifo(struct IsdnCardState *cs, int hscx, u_char *data, int size) { - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET, - HSCX_FIFO_OFFSET+hscx*HSCX_CH_DIFF); - insb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size); + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, + HSCX_FIFO_OFFSET + hscx * HSCX_CH_DIFF); + insb(cs->hw.avm.cfg_reg + DATAREG_OFFSET, data, size); } static inline void -WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size) +WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char *data, int size) { - byteout(cs->hw.avm.cfg_reg+ADDRREG_OFFSET, - HSCX_FIFO_OFFSET+hscx*HSCX_CH_DIFF); - outsb(cs->hw.avm.cfg_reg+DATAREG_OFFSET, data, size); + byteout(cs->hw.avm.cfg_reg + ADDRREG_OFFSET, + HSCX_FIFO_OFFSET + hscx * HSCX_CH_DIFF); + outsb(cs->hw.avm.cfg_reg + DATAREG_OFFSET, data, size); } /* @@ -134,7 +134,7 @@ WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size) #define READHSCX(cs, nr, reg) ReadHSCX(cs, nr, reg) #define WRITEHSCX(cs, nr, reg, data) WriteHSCX(cs, nr, reg, data) -#define READHSCXFIFO(cs, nr, ptr, cnt) ReadHSCXfifo(cs, nr, ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) ReadHSCXfifo(cs, nr, ptr, cnt) #define WRITEHSCXFIFO(cs, nr, ptr, cnt) WriteHSCXfifo(cs, nr, ptr, cnt) #include "hscx_irq.c" @@ -147,11 +147,11 @@ avm_a1p_interrupt(int intno, void *dev_id) u_long flags; spin_lock_irqsave(&cs->lock, flags); - while ((sval = (~bytein(cs->hw.avm.cfg_reg+ASL0_OFFSET) & ASL0_R_IRQPENDING))) { + while ((sval = (~bytein(cs->hw.avm.cfg_reg + ASL0_OFFSET) & ASL0_R_IRQPENDING))) { if (cs->debug & L1_DEB_INTSTAT) debugl1(cs, "avm IntStatus %x", sval); if (sval & ASL0_R_HSCX) { - val = ReadHSCX(cs, 1, HSCX_ISTA); + val = ReadHSCX(cs, 1, HSCX_ISTA); if (val) hscx_int_main(cs, val); } @@ -177,38 +177,38 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00); - HZDELAY(HZ / 5 + 1); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,ASL0_W_RESET); - HZDELAY(HZ / 5 + 1); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00); - spin_unlock_irqrestore(&cs->lock, flags); - return 0; - - case CARD_RELEASE: - /* free_irq is done in HiSax_closecard(). */ - /* free_irq(cs->irq, cs); */ - return 0; - - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,ASL0_W_TDISABLE|ASL0_W_TRESET|ASL0_W_IRQENABLE); - clear_pending_isac_ints(cs); - clear_pending_hscx_ints(cs); - inithscxisac(cs, 1); - inithscxisac(cs, 2); - spin_unlock_irqrestore(&cs->lock, flags); - return 0; - - case CARD_TEST: - /* we really don't need it for the PCMCIA Version */ - return 0; - - default: - /* all card drivers ignore others, so we do the same */ - return 0; + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, 0x00); + HZDELAY(HZ / 5 + 1); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, ASL0_W_RESET); + HZDELAY(HZ / 5 + 1); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, 0x00); + spin_unlock_irqrestore(&cs->lock, flags); + return 0; + + case CARD_RELEASE: + /* free_irq is done in HiSax_closecard(). */ + /* free_irq(cs->irq, cs); */ + return 0; + + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, ASL0_W_TDISABLE | ASL0_W_TRESET | ASL0_W_IRQENABLE); + clear_pending_isac_ints(cs); + clear_pending_hscx_ints(cs); + inithscxisac(cs, 1); + inithscxisac(cs, 2); + spin_unlock_irqrestore(&cs->lock, flags); + return 0; + + case CARD_TEST: + /* we really don't need it for the PCMCIA Version */ + return 0; + + default: + /* all card drivers ignore others, so we do the same */ + return 0; } return 0; } @@ -222,7 +222,7 @@ int __devinit setup_avm_a1_pcmcia(struct IsdnCard *card) strcpy(tmp, avm_revision); printk(KERN_INFO "HiSax: AVM A1 PCMCIA driver Rev. %s\n", - HiSax_getrev(tmp)); + HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_A1_PCMCIA) return (0); @@ -230,20 +230,20 @@ int __devinit setup_avm_a1_pcmcia(struct IsdnCard *card) cs->irq = card->para[0]; - byteout(cs->hw.avm.cfg_reg+ASL1_OFFSET, ASL1_W_ENABLE_S0); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00); + byteout(cs->hw.avm.cfg_reg + ASL1_OFFSET, ASL1_W_ENABLE_S0); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, 0x00); HZDELAY(HZ / 5 + 1); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,ASL0_W_RESET); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, ASL0_W_RESET); HZDELAY(HZ / 5 + 1); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET,0x00); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, 0x00); - byteout(cs->hw.avm.cfg_reg+ASL0_OFFSET, ASL0_W_TDISABLE|ASL0_W_TRESET); + byteout(cs->hw.avm.cfg_reg + ASL0_OFFSET, ASL0_W_TDISABLE | ASL0_W_TRESET); - model = bytein(cs->hw.avm.cfg_reg+MODREG_OFFSET); - vers = bytein(cs->hw.avm.cfg_reg+VERREG_OFFSET); + model = bytein(cs->hw.avm.cfg_reg + MODREG_OFFSET); + vers = bytein(cs->hw.avm.cfg_reg + VERREG_OFFSET); printk(KERN_INFO "AVM A1 PCMCIA: io 0x%x irq %d model %d version %d\n", - cs->hw.avm.cfg_reg, cs->irq, model, vers); + cs->hw.avm.cfg_reg, cs->irq, model, vers); setup_isac(cs); cs->readisac = &ReadISAC; diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c index 0e66af1decd4..979492d69dae 100644 --- a/drivers/isdn/hisax/avm_pci.c +++ b/drivers/isdn/hisax/avm_pci.c @@ -95,14 +95,14 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { outb(AVM_ISAC_FIFO, cs->hw.avm.cfg_reg + 4); insb(cs->hw.avm.isac, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { outb(AVM_ISAC_FIFO, cs->hw.avm.cfg_reg + 4); outsb(cs->hw.avm.isac, data, size); @@ -151,7 +151,7 @@ WriteHDLCPnP(struct IsdnCardState *cs, int chan, u_char offset, u_char value) static u_char ReadHDLC_s(struct IsdnCardState *cs, int chan, u_char offset) { - return(0xff & ReadHDLCPCI(cs, chan, offset)); + return (0xff & ReadHDLCPCI(cs, chan, offset)); } static void @@ -164,11 +164,11 @@ static inline struct BCState *Sel_BCS(struct IsdnCardState *cs, int channel) { if (cs->bcs[0].mode && (cs->bcs[0].channel == channel)) - return(&cs->bcs[0]); + return (&cs->bcs[0]); else if (cs->bcs[1].mode && (cs->bcs[1].channel == channel)) - return(&cs->bcs[1]); + return (&cs->bcs[1]); else - return(NULL); + return (NULL); } static void @@ -182,13 +182,13 @@ write_ctrl(struct BCState *bcs, int which) { } else { if (which & 4) WriteHDLCPnP(bcs->cs, bcs->channel, HDLC_STATUS + 2, - bcs->hw.hdlc.ctrl.sr.mode); + bcs->hw.hdlc.ctrl.sr.mode); if (which & 2) WriteHDLCPnP(bcs->cs, bcs->channel, HDLC_STATUS + 1, - bcs->hw.hdlc.ctrl.sr.xml); + bcs->hw.hdlc.ctrl.sr.xml); if (which & 1) WriteHDLCPnP(bcs->cs, bcs->channel, HDLC_STATUS, - bcs->hw.hdlc.ctrl.sr.cmd); + bcs->hw.hdlc.ctrl.sr.cmd); } } @@ -203,41 +203,41 @@ modehdlc(struct BCState *bcs, int mode, int bc) 'A' + hdlc, bcs->mode, mode, hdlc, bc); bcs->hw.hdlc.ctrl.ctrl = 0; switch (mode) { - case (-1): /* used for init */ - bcs->mode = 1; - bcs->channel = bc; - bc = 0; - case (L1_MODE_NULL): - if (bcs->mode == L1_MODE_NULL) - return; - bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; - bcs->hw.hdlc.ctrl.sr.mode = HDLC_MODE_TRANS; - write_ctrl(bcs, 5); - bcs->mode = L1_MODE_NULL; - bcs->channel = bc; - break; - case (L1_MODE_TRANS): - bcs->mode = mode; - bcs->channel = bc; - bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; - bcs->hw.hdlc.ctrl.sr.mode = HDLC_MODE_TRANS; - write_ctrl(bcs, 5); - bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS; - write_ctrl(bcs, 1); - bcs->hw.hdlc.ctrl.sr.cmd = 0; - schedule_event(bcs, B_XMTBUFREADY); - break; - case (L1_MODE_HDLC): - bcs->mode = mode; - bcs->channel = bc; - bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; - bcs->hw.hdlc.ctrl.sr.mode = HDLC_MODE_ITF_FLG; - write_ctrl(bcs, 5); - bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS; - write_ctrl(bcs, 1); - bcs->hw.hdlc.ctrl.sr.cmd = 0; - schedule_event(bcs, B_XMTBUFREADY); - break; + case (-1): /* used for init */ + bcs->mode = 1; + bcs->channel = bc; + bc = 0; + case (L1_MODE_NULL): + if (bcs->mode == L1_MODE_NULL) + return; + bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; + bcs->hw.hdlc.ctrl.sr.mode = HDLC_MODE_TRANS; + write_ctrl(bcs, 5); + bcs->mode = L1_MODE_NULL; + bcs->channel = bc; + break; + case (L1_MODE_TRANS): + bcs->mode = mode; + bcs->channel = bc; + bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; + bcs->hw.hdlc.ctrl.sr.mode = HDLC_MODE_TRANS; + write_ctrl(bcs, 5); + bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS; + write_ctrl(bcs, 1); + bcs->hw.hdlc.ctrl.sr.cmd = 0; + schedule_event(bcs, B_XMTBUFREADY); + break; + case (L1_MODE_HDLC): + bcs->mode = mode; + bcs->channel = bc; + bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS; + bcs->hw.hdlc.ctrl.sr.mode = HDLC_MODE_ITF_FLG; + write_ctrl(bcs, 5); + bcs->hw.hdlc.ctrl.sr.cmd = HDLC_CMD_XRS; + write_ctrl(bcs, 1); + bcs->hw.hdlc.ctrl.sr.cmd = 0; + schedule_event(bcs, B_XMTBUFREADY); + break; } } @@ -247,7 +247,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count) register u_int *ptr; u_char *p; u_char idx = bcs->channel ? AVM_HDLC_2 : AVM_HDLC_1; - int cnt=0; + int cnt = 0; struct IsdnCardState *cs = bcs->cs; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) @@ -264,7 +264,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count) outl(idx, cs->hw.avm.cfg_reg + 4); while (cnt < count) { #ifdef __powerpc__ - *ptr++ = in_be32((unsigned *)(cs->hw.avm.isac +_IO_BASE)); + *ptr++ = in_be32((unsigned *)(cs->hw.avm.isac + _IO_BASE)); #else *ptr++ = inl(cs->hw.avm.isac); #endif /* __powerpc__ */ @@ -293,7 +293,7 @@ static inline void hdlc_fill_fifo(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; - int count, cnt =0; + int count, cnt = 0; int fifo_size = 32; u_char *p; u_int *ptr; @@ -323,16 +323,16 @@ hdlc_fill_fifo(struct BCState *bcs) bcs->hw.hdlc.ctrl.sr.xml = ((count == fifo_size) ? 0 : count); write_ctrl(bcs, 3); /* sets the correct index too */ if (cs->subtyp == AVM_FRITZ_PCI) { - while (cnthw.avm.isac +_IO_BASE), *ptr++); + out_be32((unsigned *)(cs->hw.avm.isac + _IO_BASE), *ptr++); #else outl(*ptr++, cs->hw.avm.isac); #endif /* __powerpc__ */ cnt += 4; } } else { - while (cnthw.avm.isac); cnt++; } @@ -369,17 +369,17 @@ HDLC_irq(struct BCState *bcs, u_int stat) { write_ctrl(bcs, 1); bcs->hw.hdlc.rcvidx = 0; } else { - if (!(len = (stat & HDLC_STAT_RML_MASK)>>8)) + if (!(len = (stat & HDLC_STAT_RML_MASK) >> 8)) len = 32; hdlc_empty_fifo(bcs, len); if ((stat & HDLC_STAT_RME) || (bcs->mode == L1_MODE_TRANS)) { - if (((stat & HDLC_STAT_CRCVFRRAB)==HDLC_STAT_CRCVFR) || - (bcs->mode == L1_MODE_TRANS)) { + if (((stat & HDLC_STAT_CRCVFRRAB) == HDLC_STAT_CRCVFR) || + (bcs->mode == L1_MODE_TRANS)) { if (!(skb = dev_alloc_skb(bcs->hw.hdlc.rcvidx))) printk(KERN_WARNING "HDLC: receive out of memory\n"); else { memcpy(skb_put(skb, bcs->hw.hdlc.rcvidx), - bcs->hw.hdlc.rcvbuf, bcs->hw.hdlc.rcvidx); + bcs->hw.hdlc.rcvbuf, bcs->hw.hdlc.rcvidx); skb_queue_tail(&bcs->rqueue, skb); } bcs->hw.hdlc.rcvidx = 0; @@ -418,9 +418,9 @@ HDLC_irq(struct BCState *bcs, u_int stat) { hdlc_fill_fifo(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { - u_long flags; + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hdlc.count; spin_unlock_irqrestore(&bcs->aclock, flags); @@ -453,7 +453,7 @@ HDLC_irq_main(struct IsdnCardState *cs) } else { stat = ReadHDLCPnP(cs, 0, HDLC_STATUS); if (stat & HDLC_INT_RPR) - stat |= (ReadHDLCPnP(cs, 0, HDLC_STATUS+1))<<8; + stat |= (ReadHDLCPnP(cs, 0, HDLC_STATUS + 1)) << 8; } if (stat & HDLC_INT_MASK) { if (!(bcs = Sel_BCS(cs, 0))) { @@ -467,7 +467,7 @@ HDLC_irq_main(struct IsdnCardState *cs) } else { stat = ReadHDLCPnP(cs, 1, HDLC_STATUS); if (stat & HDLC_INT_RPR) - stat |= (ReadHDLCPnP(cs, 1, HDLC_STATUS+1))<<8; + stat |= (ReadHDLCPnP(cs, 1, HDLC_STATUS + 1)) << 8; } if (stat & HDLC_INT_MASK) { if (!(bcs = Sel_BCS(cs, 1))) { @@ -486,55 +486,55 @@ hdlc_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->hw.hdlc.count = 0; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "hdlc_l2l1: this shouldn't happen\n"); - } else { - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->tx_skb = skb; - bcs->hw.hdlc.count = 0; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - modehdlc(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - modehdlc(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->hw.hdlc.count = 0; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "hdlc_l2l1: this shouldn't happen\n"); + } else { + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_skb = skb; + bcs->hw.hdlc.count = 0; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + modehdlc(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + modehdlc(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -568,7 +568,7 @@ open_hdlcstate(struct IsdnCardState *cs, struct BCState *bcs) } if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) { printk(KERN_WARNING - "HiSax: No memory for bcs->blog\n"); + "HiSax: No memory for bcs->blog\n"); test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); kfree(bcs->hw.hdlc.rcvbuf); bcs->hw.hdlc.rcvbuf = NULL; @@ -688,34 +688,34 @@ AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_avmpcipnp(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - outb(0, cs->hw.avm.cfg_reg + 2); - release_region(cs->hw.avm.cfg_reg, 32); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - reset_avmpcipnp(cs); - clear_pending_isac_ints(cs); - initisac(cs); - inithdlc(cs); - outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER, - cs->hw.avm.cfg_reg + 2); - WriteISAC(cs, ISAC_MASK, 0); - outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER | - AVM_STATUS0_ENA_IRQ, cs->hw.avm.cfg_reg + 2); - /* RESET Receiver and Transmitter */ - WriteISAC(cs, ISAC_CMDR, 0x41); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_avmpcipnp(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + outb(0, cs->hw.avm.cfg_reg + 2); + release_region(cs->hw.avm.cfg_reg, 32); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + reset_avmpcipnp(cs); + clear_pending_isac_ints(cs); + initisac(cs); + inithdlc(cs); + outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER, + cs->hw.avm.cfg_reg + 2); + WriteISAC(cs, ISAC_MASK, 0); + outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER | + AVM_STATUS0_ENA_IRQ, cs->hw.avm.cfg_reg + 2); + /* RESET Receiver and Transmitter */ + WriteISAC(cs, ISAC_CMDR, 0x41); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } static int __devinit avm_setup_rest(struct IsdnCardState *cs) @@ -724,7 +724,7 @@ static int __devinit avm_setup_rest(struct IsdnCardState *cs) cs->hw.avm.isac = cs->hw.avm.cfg_reg + 0x10; if (!request_region(cs->hw.avm.cfg_reg, 32, - (cs->subtyp == AVM_FRITZ_PCI) ? "avm PCI" : "avm PnP")) { + (cs->subtyp == AVM_FRITZ_PCI) ? "avm PCI" : "avm PnP")) { printk(KERN_WARNING "HiSax: Fritz!PCI/PNP config port %x-%x already in use\n", cs->hw.avm.cfg_reg, @@ -732,28 +732,28 @@ static int __devinit avm_setup_rest(struct IsdnCardState *cs) return (0); } switch (cs->subtyp) { - case AVM_FRITZ_PCI: + case AVM_FRITZ_PCI: val = inl(cs->hw.avm.cfg_reg); printk(KERN_INFO "AVM PCI: stat %#x\n", val); printk(KERN_INFO "AVM PCI: Class %X Rev %d\n", - val & 0xff, (val>>8) & 0xff); + val & 0xff, (val >> 8) & 0xff); cs->BC_Read_Reg = &ReadHDLC_s; cs->BC_Write_Reg = &WriteHDLC_s; break; - case AVM_FRITZ_PNP: + case AVM_FRITZ_PNP: val = inb(cs->hw.avm.cfg_reg); ver = inb(cs->hw.avm.cfg_reg + 1); printk(KERN_INFO "AVM PnP: Class %X Rev %d\n", val, ver); cs->BC_Read_Reg = &ReadHDLCPnP; cs->BC_Write_Reg = &WriteHDLCPnP; break; - default: - printk(KERN_WARNING "AVM unknown subtype %d\n", cs->subtyp); - return(0); + default: + printk(KERN_WARNING "AVM unknown subtype %d\n", cs->subtyp); + return (0); } printk(KERN_INFO "HiSax: %s config irq:%d base:0x%X\n", - (cs->subtyp == AVM_FRITZ_PCI) ? "AVM Fritz!PCI" : "AVM Fritz!PnP", - cs->irq, cs->hw.avm.cfg_reg); + (cs->subtyp == AVM_FRITZ_PCI) ? "AVM Fritz!PCI" : "AVM Fritz!PnP", + cs->irq, cs->hw.avm.cfg_reg); setup_isac(cs); cs->readisac = &ReadISAC; @@ -772,7 +772,7 @@ static int __devinit avm_setup_rest(struct IsdnCardState *cs) static int __devinit avm_pnp_setup(struct IsdnCardState *cs) { - return(1); /* no-op: success */ + return (1); /* no-op: success */ } #else @@ -784,33 +784,33 @@ static int __devinit avm_pnp_setup(struct IsdnCardState *cs) struct pnp_dev *pnp_avm_d = NULL; if (!isapnp_present()) - return(1); /* no-op: success */ + return (1); /* no-op: success */ if ((pnp_avm_c = pnp_find_card( - ISAPNP_VENDOR('A', 'V', 'M'), - ISAPNP_FUNCTION(0x0900), pnp_avm_c))) { + ISAPNP_VENDOR('A', 'V', 'M'), + ISAPNP_FUNCTION(0x0900), pnp_avm_c))) { if ((pnp_avm_d = pnp_find_dev(pnp_avm_c, - ISAPNP_VENDOR('A', 'V', 'M'), - ISAPNP_FUNCTION(0x0900), pnp_avm_d))) { + ISAPNP_VENDOR('A', 'V', 'M'), + ISAPNP_FUNCTION(0x0900), pnp_avm_d))) { int err; pnp_disable_dev(pnp_avm_d); err = pnp_activate_dev(pnp_avm_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } cs->hw.avm.cfg_reg = pnp_port_start(pnp_avm_d, 0); cs->irq = pnp_irq(pnp_avm_d, 0); if (!cs->irq) { printk(KERN_ERR "FritzPnP:No IRQ\n"); - return(0); + return (0); } if (!cs->hw.avm.cfg_reg) { printk(KERN_ERR "FritzPnP:No IO address\n"); - return(0); + return (0); } cs->subtyp = AVM_FRITZ_PNP; @@ -827,7 +827,7 @@ static int __devinit avm_pnp_setup(struct IsdnCardState *cs) static int __devinit avm_pci_setup(struct IsdnCardState *cs) { - return(1); /* no-op: success */ + return (1); /* no-op: success */ } #else @@ -837,27 +837,27 @@ static struct pci_dev *dev_avm __devinitdata = NULL; static int __devinit avm_pci_setup(struct IsdnCardState *cs) { if ((dev_avm = hisax_find_pci_device(PCI_VENDOR_ID_AVM, - PCI_DEVICE_ID_AVM_A1, dev_avm))) { + PCI_DEVICE_ID_AVM_A1, dev_avm))) { if (pci_enable_device(dev_avm)) - return(0); + return (0); cs->irq = dev_avm->irq; if (!cs->irq) { printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n"); - return(0); + return (0); } cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1); if (!cs->hw.avm.cfg_reg) { printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n"); - return(0); + return (0); } cs->subtyp = AVM_FRITZ_PCI; } else { printk(KERN_WARNING "FritzPCI: No PCI card found\n"); - return(0); + return (0); } cs->irq_flags |= IRQF_SHARED; diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 8f0ad2a52e87..33e3c94887d8 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -3,7 +3,7 @@ * * Author Carsten Paeth * Copyright 1998-2001 by Carsten Paeth - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -39,20 +39,20 @@ module_param(isdnprot, int, 0); /*====================================================================*/ -static int avma1cs_config(struct pcmcia_device *link) __devinit ; +static int avma1cs_config(struct pcmcia_device *link) __devinit; static void avma1cs_release(struct pcmcia_device *link); -static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit ; +static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit; static int __devinit avma1cs_probe(struct pcmcia_device *p_dev) { - dev_dbg(&p_dev->dev, "avma1cs_attach()\n"); + dev_dbg(&p_dev->dev, "avma1cs_attach()\n"); - /* General socket configuration */ - p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - p_dev->config_index = 1; - p_dev->config_regs = PRESENT_OPTION; + /* General socket configuration */ + p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; + p_dev->config_index = 1; + p_dev->config_regs = PRESENT_OPTION; - return avma1cs_config(p_dev); + return avma1cs_config(p_dev); } /* avma1cs_attach */ static void __devexit avma1cs_detach(struct pcmcia_device *link) @@ -75,63 +75,63 @@ static int avma1cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) static int __devinit avma1cs_config(struct pcmcia_device *link) { - int i = -1; - char devname[128]; - IsdnCard_t icard; - int busy = 0; - - dev_dbg(&link->dev, "avma1cs_config(0x%p)\n", link); - - devname[0] = 0; - if (link->prod_id[1]) - strlcpy(devname, link->prod_id[1], sizeof(devname)); - - if (pcmcia_loop_config(link, avma1cs_configcheck, NULL)) - return -ENODEV; - - do { - /* - * allocate an interrupt line - */ - if (!link->irq) { - /* undo */ - pcmcia_disable_device(link); - break; - } - - /* - * configure the PCMCIA socket - */ - i = pcmcia_enable_device(link); + int i = -1; + char devname[128]; + IsdnCard_t icard; + int busy = 0; + + dev_dbg(&link->dev, "avma1cs_config(0x%p)\n", link); + + devname[0] = 0; + if (link->prod_id[1]) + strlcpy(devname, link->prod_id[1], sizeof(devname)); + + if (pcmcia_loop_config(link, avma1cs_configcheck, NULL)) + return -ENODEV; + + do { + /* + * allocate an interrupt line + */ + if (!link->irq) { + /* undo */ + pcmcia_disable_device(link); + break; + } + + /* + * configure the PCMCIA socket + */ + i = pcmcia_enable_device(link); + if (i != 0) { + pcmcia_disable_device(link); + break; + } + + } while (0); + + /* If any step failed, release any partially configured state */ if (i != 0) { - pcmcia_disable_device(link); - break; + avma1cs_release(link); + return -ENODEV; } - } while (0); - - /* If any step failed, release any partially configured state */ - if (i != 0) { - avma1cs_release(link); - return -ENODEV; - } - - icard.para[0] = link->irq; - icard.para[1] = link->resource[0]->start; - icard.protocol = isdnprot; - icard.typ = ISDN_CTYPE_A1_PCMCIA; - - i = hisax_init_pcmcia(link, &busy, &icard); - if (i < 0) { - printk(KERN_ERR "avma1_cs: failed to initialize AVM A1 " - "PCMCIA %d at i/o %#x\n", i, - (unsigned int) link->resource[0]->start); - avma1cs_release(link); - return -ENODEV; - } - link->priv = (void *) (unsigned long) i; + icard.para[0] = link->irq; + icard.para[1] = link->resource[0]->start; + icard.protocol = isdnprot; + icard.typ = ISDN_CTYPE_A1_PCMCIA; + + i = hisax_init_pcmcia(link, &busy, &icard); + if (i < 0) { + printk(KERN_ERR "avma1_cs: failed to initialize AVM A1 " + "PCMCIA %d at i/o %#x\n", i, + (unsigned int) link->resource[0]->start); + avma1cs_release(link); + return -ENODEV; + } + link->priv = (void *) (unsigned long) i; - return 0; + return 0; } /* avma1cs_config */ static void avma1cs_release(struct pcmcia_device *link) diff --git a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c index 9f2009c0b69c..f6bf9c68892e 100644 --- a/drivers/isdn/hisax/bkm_a4t.c +++ b/drivers/isdn/hisax/bkm_a4t.c @@ -4,7 +4,7 @@ * * Author Roland Klabunde * Copyright by Roland Klabunde - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -39,7 +39,7 @@ readreg(unsigned int ale, unsigned long adr, u_char off) static inline void -readfifo(unsigned int ale, unsigned long adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned long adr, u_char off, u_char *data, int size) { int i; for (i = 0; i < size; i++) @@ -59,7 +59,7 @@ writereg(unsigned int ale, unsigned long adr, u_char off, u_char data) static inline void -writefifo(unsigned int ale, unsigned long adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned long adr, u_char off, u_char *data, int size) { int i; @@ -83,13 +83,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.ax.isac_ale, cs->hw.ax.isac_adr, 0, data, size); } @@ -110,15 +110,15 @@ WriteJADE(struct IsdnCardState *cs, int jade, u_char offset, u_char value) * fast interrupt JADE stuff goes here */ -#define READJADE(cs, nr, reg) readreg(cs->hw.ax.jade_ale,\ - cs->hw.ax.jade_adr, reg + (nr == -1 ? 0 : (nr ? 0xC0 : 0x80))) -#define WRITEJADE(cs, nr, reg, data) writereg(cs->hw.ax.jade_ale,\ - cs->hw.ax.jade_adr, reg + (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), data) +#define READJADE(cs, nr, reg) readreg(cs->hw.ax.jade_ale, \ + cs->hw.ax.jade_adr, reg + (nr == -1 ? 0 : (nr ? 0xC0 : 0x80))) +#define WRITEJADE(cs, nr, reg, data) writereg(cs->hw.ax.jade_ale, \ + cs->hw.ax.jade_adr, reg + (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), data) -#define READJADEFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ax.jade_ale,\ - cs->hw.ax.jade_adr, (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), ptr, cnt) -#define WRITEJADEFIFO(cs, nr, ptr, cnt) writefifo( cs->hw.ax.jade_ale,\ - cs->hw.ax.jade_adr, (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), ptr, cnt) +#define READJADEFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ax.jade_ale, \ + cs->hw.ax.jade_adr, (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), ptr, cnt) +#define WRITEJADEFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ax.jade_ale, \ + cs->hw.ax.jade_adr, (nr == -1 ? 0 : (nr ? 0xC0 : 0x80)), ptr, cnt) #include "jade_irq.c" @@ -201,11 +201,11 @@ reset_bkm(struct IsdnCardState *cs) pI20_Regs->i20SysControl = sysRESET | sysCFG; /* Issue ISDN reset */ pI20_Regs->i20GuestControl = guestWAIT_CFG | - g_A4T_JADE_RES | - g_A4T_ISAR_RES | - g_A4T_ISAC_RES | - g_A4T_JADE_BOOTR | - g_A4T_ISAR_BOOTR; + g_A4T_JADE_RES | + g_A4T_ISAR_RES | + g_A4T_ISAC_RES | + g_A4T_JADE_BOOTR | + g_A4T_ISAR_BOOTR; mdelay(10); /* Remove RESET state from ISDN */ @@ -222,33 +222,33 @@ BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - /* Disable ints */ - spin_lock_irqsave(&cs->lock, flags); - enable_bkm_int(cs, 0); - reset_bkm(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_RELEASE: - /* Sanity */ - spin_lock_irqsave(&cs->lock, flags); - enable_bkm_int(cs, 0); - reset_bkm(cs); - spin_unlock_irqrestore(&cs->lock, flags); - release_io_bkm(cs); - return (0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - clear_pending_isac_ints(cs); - clear_pending_jade_ints(cs); - initisac(cs); - initjade(cs); - /* Enable ints */ - enable_bkm_int(cs, 1); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_TEST: - return (0); + case CARD_RESET: + /* Disable ints */ + spin_lock_irqsave(&cs->lock, flags); + enable_bkm_int(cs, 0); + reset_bkm(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + /* Sanity */ + spin_lock_irqsave(&cs->lock, flags); + enable_bkm_int(cs, 0); + reset_bkm(cs); + spin_unlock_irqrestore(&cs->lock, flags); + release_io_bkm(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + clear_pending_isac_ints(cs); + clear_pending_jade_ints(cs); + initisac(cs); + initjade(cs); + /* Enable ints */ + enable_bkm_int(cs, 1); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } return (0); } @@ -341,7 +341,7 @@ setup_bkm_a4t(struct IsdnCard *card) return (0); while ((dev_a4t = hisax_find_pci_device(PCI_VENDOR_ID_ZORAN, - PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) { + PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) { ret = a4t_pci_probe(dev_a4t, cs, &found, &pci_memaddr); if (!ret) return (0); diff --git a/drivers/isdn/hisax/bkm_a8.c b/drivers/isdn/hisax/bkm_a8.c index e775706c60e3..c9c98f071af6 100644 --- a/drivers/isdn/hisax/bkm_a8.c +++ b/drivers/isdn/hisax/bkm_a8.c @@ -4,7 +4,7 @@ * * Author Roland Klabunde * Copyright by Roland Klabunde - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -34,7 +34,7 @@ static const char *sct_quadro_subtypes[] = }; -#define wordout(addr,val) outw(val,addr) +#define wordout(addr, val) outw(val, addr) #define wordin(addr) inw(addr) static inline u_char @@ -47,7 +47,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { int i; wordout(ale, off); @@ -64,7 +64,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { int i; wordout(ale, off); @@ -87,13 +87,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.ax.base, cs->hw.ax.data_adr, 0x80, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.ax.base, cs->hw.ax.data_adr, 0x80, data, size); } @@ -117,21 +117,21 @@ set_ipac_active(struct IsdnCardState *cs, u_int active) { /* set irq mask */ writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, - active ? 0xc0 : 0xff); + active ? 0xc0 : 0xff); } /* * fast interrupt HSCX stuff goes here */ -#define READHSCX(cs, nr, reg) readreg(cs->hw.ax.base, \ - cs->hw.ax.data_adr, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ax.base, \ - cs->hw.ax.data_adr, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ax.base, \ - cs->hw.ax.data_adr, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ax.base, \ - cs->hw.ax.data_adr, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCX(cs, nr, reg) readreg(cs->hw.ax.base, \ + cs->hw.ax.data_adr, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ax.base, \ + cs->hw.ax.data_adr, reg + (nr ? 0x40 : 0), data) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ax.base, \ + cs->hw.ax.data_adr, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ax.base, \ + cs->hw.ax.data_adr, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -148,7 +148,7 @@ bkm_interrupt_ipac(int intno, void *dev_id) spin_unlock_irqrestore(&cs->lock, flags); return IRQ_NONE; } - Start_IPAC: +Start_IPAC: if (cs->debug & L1_DEB_IPAC) debugl1(cs, "IPAC ISTA %02X", ista); if (ista & 0x0f) { @@ -224,33 +224,33 @@ BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - /* Disable ints */ - set_ipac_active(cs, 0); - enable_bkm_int(cs, 0); - reset_bkm(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_RELEASE: - /* Sanity */ - spin_lock_irqsave(&cs->lock, flags); - set_ipac_active(cs, 0); - enable_bkm_int(cs, 0); - spin_unlock_irqrestore(&cs->lock, flags); - release_io_sct_quadro(cs); - return (0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - cs->debug |= L1_DEB_IPAC; - set_ipac_active(cs, 1); - inithscxisac(cs, 3); - /* Enable ints */ - enable_bkm_int(cs, 1); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_TEST: - return (0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + /* Disable ints */ + set_ipac_active(cs, 0); + enable_bkm_int(cs, 0); + reset_bkm(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + /* Sanity */ + spin_lock_irqsave(&cs->lock, flags); + set_ipac_active(cs, 0); + enable_bkm_int(cs, 0); + spin_unlock_irqrestore(&cs->lock, flags); + release_io_sct_quadro(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + cs->debug |= L1_DEB_IPAC; + set_ipac_active(cs, 1); + inithscxisac(cs, 3); + /* Enable ints */ + enable_bkm_int(cs, 1); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } return (0); } @@ -260,11 +260,11 @@ sct_alloc_io(u_int adr, u_int len) { if (!request_region(adr, len, "scitel")) { printk(KERN_WARNING - "HiSax: Scitel port %#x-%#x already in use\n", - adr, adr + len); + "HiSax: Scitel port %#x-%#x already in use\n", + adr, adr + len); return (1); } - return(0); + return (0); } static struct pci_dev *dev_a8 __devinitdata = NULL; @@ -298,18 +298,18 @@ setup_sct_quadro(struct IsdnCard *card) return (0); } if ((cs->subtyp != SCT_1) && ((sub_sys_id != PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) || - (sub_vendor_id != PCI_VENDOR_ID_BERKOM))) + (sub_vendor_id != PCI_VENDOR_ID_BERKOM))) return (0); if (cs->subtyp == SCT_1) { while ((dev_a8 = hisax_find_pci_device(PCI_VENDOR_ID_PLX, - PCI_DEVICE_ID_PLX_9050, dev_a8))) { - + PCI_DEVICE_ID_PLX_9050, dev_a8))) { + sub_vendor_id = dev_a8->subsystem_vendor; sub_sys_id = dev_a8->subsystem_device; if ((sub_sys_id == PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) && - (sub_vendor_id == PCI_VENDOR_ID_BERKOM)) { + (sub_vendor_id == PCI_VENDOR_ID_BERKOM)) { if (pci_enable_device(dev_a8)) - return(0); + return (0); pci_ioaddr1 = pci_resource_start(dev_a8, 1); pci_irq = dev_a8->irq; pci_bus = dev_a8->bus->number; @@ -320,23 +320,23 @@ setup_sct_quadro(struct IsdnCard *card) } if (!found) { printk(KERN_WARNING "HiSax: Scitel Quadro (%s): " - "Card not found\n", - sct_quadro_subtypes[cs->subtyp]); + "Card not found\n", + sct_quadro_subtypes[cs->subtyp]); return (0); } #ifdef ATTEMPT_PCI_REMAPPING /* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */ if ((pci_ioaddr1 & 0x80) && (dev_a8->revision == 1)) { printk(KERN_WARNING "HiSax: Scitel Quadro (%s): " - "PLX rev 1, remapping required!\n", - sct_quadro_subtypes[cs->subtyp]); + "PLX rev 1, remapping required!\n", + sct_quadro_subtypes[cs->subtyp]); /* Restart PCI negotiation */ - pci_write_config_dword(dev_a8, PCI_BASE_ADDRESS_1, (u_int) - 1); + pci_write_config_dword(dev_a8, PCI_BASE_ADDRESS_1, (u_int)-1); /* Move up by 0x80 byte */ pci_ioaddr1 += 0x80; pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK; pci_write_config_dword(dev_a8, PCI_BASE_ADDRESS_1, pci_ioaddr1); - dev_a8->resource[ 1].start = pci_ioaddr1; + dev_a8->resource[1].start = pci_ioaddr1; } #endif /* End HACK */ } @@ -371,39 +371,39 @@ setup_sct_quadro(struct IsdnCard *card) /* pci_ioaddr5 is for the first subdevice only */ cs->hw.ax.plx_adr = pci_ioaddr1; /* Enter all ipac_base addresses */ - switch(cs->subtyp) { - case 1: - cs->hw.ax.base = pci_ioaddr5 + 0x00; - if (sct_alloc_io(pci_ioaddr1, 128)) - return(0); - if (sct_alloc_io(pci_ioaddr5, 64)) - return(0); - /* disable all IPAC */ - writereg(pci_ioaddr5, pci_ioaddr5 + 4, - IPAC_MASK, 0xFF); - writereg(pci_ioaddr4 + 0x08, pci_ioaddr4 + 0x0c, - IPAC_MASK, 0xFF); - writereg(pci_ioaddr3 + 0x10, pci_ioaddr3 + 0x14, - IPAC_MASK, 0xFF); - writereg(pci_ioaddr2 + 0x20, pci_ioaddr2 + 0x24, - IPAC_MASK, 0xFF); - break; - case 2: - cs->hw.ax.base = pci_ioaddr4 + 0x08; - if (sct_alloc_io(pci_ioaddr4, 64)) - return(0); - break; - case 3: - cs->hw.ax.base = pci_ioaddr3 + 0x10; - if (sct_alloc_io(pci_ioaddr3, 64)) - return(0); - break; - case 4: - cs->hw.ax.base = pci_ioaddr2 + 0x20; - if (sct_alloc_io(pci_ioaddr2, 64)) - return(0); - break; - } + switch (cs->subtyp) { + case 1: + cs->hw.ax.base = pci_ioaddr5 + 0x00; + if (sct_alloc_io(pci_ioaddr1, 128)) + return (0); + if (sct_alloc_io(pci_ioaddr5, 64)) + return (0); + /* disable all IPAC */ + writereg(pci_ioaddr5, pci_ioaddr5 + 4, + IPAC_MASK, 0xFF); + writereg(pci_ioaddr4 + 0x08, pci_ioaddr4 + 0x0c, + IPAC_MASK, 0xFF); + writereg(pci_ioaddr3 + 0x10, pci_ioaddr3 + 0x14, + IPAC_MASK, 0xFF); + writereg(pci_ioaddr2 + 0x20, pci_ioaddr2 + 0x24, + IPAC_MASK, 0xFF); + break; + case 2: + cs->hw.ax.base = pci_ioaddr4 + 0x08; + if (sct_alloc_io(pci_ioaddr4, 64)) + return (0); + break; + case 3: + cs->hw.ax.base = pci_ioaddr3 + 0x10; + if (sct_alloc_io(pci_ioaddr3, 64)) + return (0); + break; + case 4: + cs->hw.ax.base = pci_ioaddr2 + 0x20; + if (sct_alloc_io(pci_ioaddr2, 64)) + return (0); + break; + } /* For isac and hscx data path */ cs->hw.ax.data_adr = cs->hw.ax.base + 4; @@ -429,7 +429,7 @@ setup_sct_quadro(struct IsdnCard *card) cs->irq_func = &bkm_interrupt_ipac; printk(KERN_INFO "HiSax: Scitel Quadro (%s): IPAC Version %d\n", - sct_quadro_subtypes[cs->subtyp], - readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID)); + sct_quadro_subtypes[cs->subtyp], + readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID)); return (1); } diff --git a/drivers/isdn/hisax/bkm_ax.h b/drivers/isdn/hisax/bkm_ax.h index 029e0a277661..27ff8a88679b 100644 --- a/drivers/isdn/hisax/bkm_ax.h +++ b/drivers/isdn/hisax/bkm_ax.h @@ -4,7 +4,7 @@ * * Author Roland Klabunde * Copyright by Roland Klabunde - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -32,36 +32,36 @@ /* Application specific registers I20 (Siemens SZB6120H) */ typedef struct { - /* Video front end horizontal configuration register */ + /* Video front end horizontal configuration register */ volatile u_int i20VFEHorzCfg; /* Offset 00 */ - /* Video front end vertical configuration register */ - volatile u_int i20VFEVertCfg; /* Offset 04 */ - /* Video front end scaler and pixel format register */ - volatile u_int i20VFEScaler; /* Offset 08 */ - /* Video display top register */ - volatile u_int i20VDispTop; /* Offset 0C */ - /* Video display bottom register */ - volatile u_int i20VDispBottom; /* Offset 10 */ - /* Video stride, status and frame grab register */ - volatile u_int i20VidFrameGrab;/* Offset 14 */ - /* Video display configuration register */ - volatile u_int i20VDispCfg; /* Offset 18 */ - /* Video masking map top */ - volatile u_int i20VMaskTop; /* Offset 1C */ - /* Video masking map bottom */ - volatile u_int i20VMaskBottom; /* Offset 20 */ - /* Overlay control register */ - volatile u_int i20OvlyControl; /* Offset 24 */ - /* System, PCI and general purpose pins control register */ - volatile u_int i20SysControl; /* Offset 28 */ + /* Video front end vertical configuration register */ + volatile u_int i20VFEVertCfg; /* Offset 04 */ + /* Video front end scaler and pixel format register */ + volatile u_int i20VFEScaler; /* Offset 08 */ + /* Video display top register */ + volatile u_int i20VDispTop; /* Offset 0C */ + /* Video display bottom register */ + volatile u_int i20VDispBottom; /* Offset 10 */ + /* Video stride, status and frame grab register */ + volatile u_int i20VidFrameGrab;/* Offset 14 */ + /* Video display configuration register */ + volatile u_int i20VDispCfg; /* Offset 18 */ + /* Video masking map top */ + volatile u_int i20VMaskTop; /* Offset 1C */ + /* Video masking map bottom */ + volatile u_int i20VMaskBottom; /* Offset 20 */ + /* Overlay control register */ + volatile u_int i20OvlyControl; /* Offset 24 */ + /* System, PCI and general purpose pins control register */ + volatile u_int i20SysControl; /* Offset 28 */ #define sysRESET 0x01000000 /* bit 24:Softreset (Low) */ - /* GPIO 4...0: Output fixed for our cfg! */ + /* GPIO 4...0: Output fixed for our cfg! */ #define sysCFG 0x000000E0 /* GPIO 7,6,5: Input */ /* General purpose pins and guest bus control register */ - volatile u_int i20GuestControl;/* Offset 2C */ + volatile u_int i20GuestControl;/* Offset 2C */ #define guestWAIT_CFG 0x00005555 /* 4 PCI waits for all */ #define guestISDN_INT_E 0x01000000 /* ISDN Int en (low) */ -#define guestVID_INT_E 0x02000000 /* Video interrupt en (low) */ +#define guestVID_INT_E 0x02000000 /* Video interrupt en (low) */ #define guestADI1_INT_R 0x04000000 /* ADI #1 int req (low) */ #define guestADI2_INT_R 0x08000000 /* ADI #2 int req (low) */ #define guestISDN_RES 0x10000000 /* ISDN reset bit (high) */ @@ -78,18 +78,18 @@ typedef struct { #define g_A4T_ISAR_INT_S 0x40000000 /* ISAR interrupt pnd (Low) */ #define g_A4T_ISAC_INT_S 0x80000000 /* ISAC interrupt pnd (Low) */ - volatile u_int i20CodeSource; /* Offset 30 */ - volatile u_int i20CodeXferCtrl;/* Offset 34 */ - volatile u_int i20CodeMemPtr; /* Offset 38 */ + volatile u_int i20CodeSource; /* Offset 30 */ + volatile u_int i20CodeXferCtrl;/* Offset 34 */ + volatile u_int i20CodeMemPtr; /* Offset 38 */ - volatile u_int i20IntStatus; /* Offset 3C */ - volatile u_int i20IntCtrl; /* Offset 40 */ + volatile u_int i20IntStatus; /* Offset 3C */ + volatile u_int i20IntCtrl; /* Offset 40 */ #define intISDN 0x40000000 /* GIRQ1En (ISAC/ADI) (High) */ #define intVID 0x20000000 /* GIRQ0En (VSYNC) (High) */ #define intCOD 0x10000000 /* CodRepIrqEn (High) */ -#define intPCI 0x01000000 /* PCI IntA enable (High) */ +#define intPCI 0x01000000 /* PCI IntA enable (High) */ - volatile u_int i20I2CCtrl; /* Offset 44 */ + volatile u_int i20I2CCtrl; /* Offset 44 */ } I20_REGISTER_FILE, *PI20_REGISTER_FILE; /* @@ -98,7 +98,7 @@ typedef struct { */ #define PO_OFFSET 0x00000200 /* Postoffice offset from base */ -#define GCS_0 0x00000000 /* Guest bus chip selects */ +#define GCS_0 0x00000000 /* Guest bus chip selects */ #define GCS_1 0x00100000 #define GCS_2 0x00200000 #define GCS_3 0x00300000 @@ -108,12 +108,12 @@ typedef struct { #define PO_PEND 0x02000000 -#define POSTOFFICE(postoffice) *(volatile unsigned int*)(postoffice) +#define POSTOFFICE(postoffice) *(volatile unsigned int *)(postoffice) -/* Wait unlimited (don't worry) */ -#define __WAITI20__(postoffice) \ -do { \ - while ((POSTOFFICE(postoffice) & PO_PEND)) ; \ -} while (0) +/* Wait unlimited (don't worry) */ +#define __WAITI20__(postoffice) \ + do { \ + while ((POSTOFFICE(postoffice) & PO_PEND)) ; \ + } while (0) #endif /* __BKM_AX_H__ */ diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c index 9ae92b41660f..a47637be0cc5 100644 --- a/drivers/isdn/hisax/callc.c +++ b/drivers/isdn/hisax/callc.c @@ -2,7 +2,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -66,7 +66,7 @@ hisax_findcard(int driverid) } static __printf(3, 4) void -link_debug(struct Channel *chanp, int direction, char *fmt, ...) + link_debug(struct Channel *chanp, int direction, char *fmt, ...) { va_list args; char tmp[16]; @@ -91,9 +91,9 @@ enum { ST_WAIT_DCOMMAND, /* 9 call clear. (receiver), awaiting DCHANNEL message */ ST_WAIT_DRELEASE, /* 10 DISCONNECT sent, awaiting RELEASE */ ST_WAIT_D_REL_CNF, /* 11 RELEASE sent, awaiting RELEASE confirm */ - ST_IN_PROCEED_SEND, /* 12 incoming call, proceeding send */ + ST_IN_PROCEED_SEND, /* 12 incoming call, proceeding send */ }; - + #define STATE_COUNT (ST_IN_PROCEED_SEND + 1) @@ -119,7 +119,7 @@ enum { EV_SETUP_CNF, /* 1 */ EV_ACCEPTB, /* 2 */ EV_DISCONNECT_IND, /* 3 */ - EV_RELEASE, /* 4 */ + EV_RELEASE, /* 4 */ EV_LEASED, /* 5 */ EV_LEASED_REL, /* 6 */ EV_SETUP_IND, /* 7 */ @@ -136,8 +136,8 @@ enum { EV_SETUP_ERR, /* 18 */ EV_CONNECT_ERR, /* 19 */ EV_PROCEED, /* 20 */ - EV_ALERT, /* 21 */ - EV_REDIR, /* 22 */ + EV_ALERT, /* 21 */ + EV_REDIR, /* 22 */ }; #define EVENT_COUNT (EV_REDIR + 1) @@ -232,8 +232,8 @@ lli_leased_in(struct FsmInst *fi, int event, void *arg) ic.parm.setup.si2 = 0; ic.parm.setup.plan = 0; ic.parm.setup.screen = 0; - sprintf(ic.parm.setup.eazmsn,"%d", chanp->chan + 1); - sprintf(ic.parm.setup.phone,"LEASED%d", chanp->cs->myid); + sprintf(ic.parm.setup.eazmsn, "%d", chanp->chan + 1); + sprintf(ic.parm.setup.phone, "LEASED%d", chanp->cs->myid); ret = chanp->cs->iif.statcallb(&ic); if (chanp->debug & 1) link_debug(chanp, 1, "statcallb ret=%d", ret); @@ -356,33 +356,33 @@ lli_deliver_call(struct FsmInst *fi, int event, void *arg) link_debug(chanp, 1, "statcallb ret=%d", ret); switch (ret) { - case 1: /* OK, someone likes this call */ - FsmDelTimer(&chanp->drel_timer, 61); - FsmChangeState(fi, ST_IN_ALERT_SENT); - chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc); - break; - case 5: /* direct redirect */ - case 4: /* Proceeding desired */ - FsmDelTimer(&chanp->drel_timer, 61); - FsmChangeState(fi, ST_IN_PROCEED_SEND); - chanp->d_st->lli.l4l3(chanp->d_st, CC_PROCEED_SEND | REQUEST, chanp->proc); - if (ret == 5) { - memcpy(&chanp->setup, &ic.parm.setup, sizeof(setup_parm)); - chanp->d_st->lli.l4l3(chanp->d_st, CC_REDIR | REQUEST, chanp->proc); - } - break; - case 2: /* Rejecting Call */ - break; - case 3: /* incomplete number */ - FsmDelTimer(&chanp->drel_timer, 61); - chanp->d_st->lli.l4l3(chanp->d_st, CC_MORE_INFO | REQUEST, chanp->proc); - break; - case 0: /* OK, nobody likes this call */ - default: /* statcallb problems */ - chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc); - chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan); - FsmChangeState(fi, ST_NULL); - break; + case 1: /* OK, someone likes this call */ + FsmDelTimer(&chanp->drel_timer, 61); + FsmChangeState(fi, ST_IN_ALERT_SENT); + chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc); + break; + case 5: /* direct redirect */ + case 4: /* Proceeding desired */ + FsmDelTimer(&chanp->drel_timer, 61); + FsmChangeState(fi, ST_IN_PROCEED_SEND); + chanp->d_st->lli.l4l3(chanp->d_st, CC_PROCEED_SEND | REQUEST, chanp->proc); + if (ret == 5) { + memcpy(&chanp->setup, &ic.parm.setup, sizeof(setup_parm)); + chanp->d_st->lli.l4l3(chanp->d_st, CC_REDIR | REQUEST, chanp->proc); + } + break; + case 2: /* Rejecting Call */ + break; + case 3: /* incomplete number */ + FsmDelTimer(&chanp->drel_timer, 61); + chanp->d_st->lli.l4l3(chanp->d_st, CC_MORE_INFO | REQUEST, chanp->proc); + break; + case 0: /* OK, nobody likes this call */ + default: /* statcallb problems */ + chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc); + chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan); + FsmChangeState(fi, ST_NULL); + break; } } else { chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc); @@ -487,7 +487,7 @@ lli_disconnect_req(struct FsmInst *fi, int event, void *arg) if (chanp->proc) chanp->proc->para.cause = 0x10; /* Normal Call Clearing */ chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT | REQUEST, - chanp->proc); + chanp->proc); } } @@ -503,7 +503,7 @@ lli_disconnect_reject(struct FsmInst *fi, int event, void *arg) if (chanp->proc) chanp->proc->para.cause = 0x15; /* Call Rejected */ chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT | REQUEST, - chanp->proc); + chanp->proc); } } @@ -579,7 +579,7 @@ static void lli_bhup_disc(struct FsmInst *fi, int event, void *arg) { struct Channel *chanp = fi->userdata; - + if (chanp->debug & 1) link_debug(chanp, 0, "STAT_BHUP"); HL_LL(chanp, ISDN_STAT_BHUP); @@ -639,7 +639,7 @@ lli_abort(struct FsmInst *fi, int event, void *arg) chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL); lli_bhup_dhup(fi, event, arg); } - + static void lli_release_req(struct FsmInst *fi, int event, void *arg) { @@ -650,7 +650,7 @@ lli_release_req(struct FsmInst *fi, int event, void *arg) } else { FsmChangeState(fi, ST_WAIT_D_REL_CNF); chanp->d_st->lli.l4l3(chanp->d_st, CC_RELEASE | REQUEST, - chanp->proc); + chanp->proc); } } @@ -667,7 +667,7 @@ static void lli_bhup_release_req(struct FsmInst *fi, int event, void *arg) { struct Channel *chanp = fi->userdata; - + if (chanp->debug & 1) link_debug(chanp, 0, "STAT_BHUP"); HL_LL(chanp, ISDN_STAT_BHUP); @@ -698,7 +698,7 @@ lli_dchan_not_ready(struct FsmInst *fi, int event, void *arg) if (chanp->debug & 1) link_debug(chanp, 0, "STAT_DHUP"); - HL_LL(chanp, ISDN_STAT_DHUP); + HL_LL(chanp, ISDN_STAT_DHUP); } static void @@ -709,7 +709,7 @@ lli_no_setup_rsp(struct FsmInst *fi, int event, void *arg) if (chanp->debug & 1) link_debug(chanp, 0, "STAT_DHUP"); HL_LL(chanp, ISDN_STAT_DHUP); - lli_close(fi); + lli_close(fi); } static void @@ -768,69 +768,69 @@ lli_failure_a(struct FsmInst *fi, int event, void *arg) /* *INDENT-OFF* */ static struct FsmNode fnlist[] __initdata = { - {ST_NULL, EV_DIAL, lli_prep_dialout}, - {ST_NULL, EV_RESUME, lli_resume}, - {ST_NULL, EV_SETUP_IND, lli_deliver_call}, - {ST_NULL, EV_LEASED, lli_leased_in}, - {ST_OUT_DIAL, EV_SETUP_CNF, lli_init_bchan_out}, - {ST_OUT_DIAL, EV_HANGUP, lli_disconnect_req}, - {ST_OUT_DIAL, EV_DISCONNECT_IND, lli_release_req}, - {ST_OUT_DIAL, EV_RELEASE, lli_dhup_close}, - {ST_OUT_DIAL, EV_NOSETUP_RSP, lli_no_setup_rsp}, - {ST_OUT_DIAL, EV_SETUP_ERR, lli_error}, - {ST_IN_WAIT_LL, EV_LEASED_REL, lli_failure_l}, - {ST_IN_WAIT_LL, EV_ACCEPTD, lli_setup_rsp}, - {ST_IN_WAIT_LL, EV_HANGUP, lli_reject_req}, - {ST_IN_WAIT_LL, EV_DISCONNECT_IND, lli_release_req}, - {ST_IN_WAIT_LL, EV_RELEASE, lli_dhup_close}, - {ST_IN_WAIT_LL, EV_SETUP_IND, lli_deliver_call}, - {ST_IN_WAIT_LL, EV_SETUP_ERR, lli_error}, - {ST_IN_ALERT_SENT, EV_SETUP_CMPL_IND, lli_init_bchan_in}, - {ST_IN_ALERT_SENT, EV_ACCEPTD, lli_send_dconnect}, - {ST_IN_ALERT_SENT, EV_HANGUP, lli_disconnect_reject}, - {ST_IN_ALERT_SENT, EV_DISCONNECT_IND, lli_release_req}, - {ST_IN_ALERT_SENT, EV_RELEASE, lli_dhup_close}, + {ST_NULL, EV_DIAL, lli_prep_dialout}, + {ST_NULL, EV_RESUME, lli_resume}, + {ST_NULL, EV_SETUP_IND, lli_deliver_call}, + {ST_NULL, EV_LEASED, lli_leased_in}, + {ST_OUT_DIAL, EV_SETUP_CNF, lli_init_bchan_out}, + {ST_OUT_DIAL, EV_HANGUP, lli_disconnect_req}, + {ST_OUT_DIAL, EV_DISCONNECT_IND, lli_release_req}, + {ST_OUT_DIAL, EV_RELEASE, lli_dhup_close}, + {ST_OUT_DIAL, EV_NOSETUP_RSP, lli_no_setup_rsp}, + {ST_OUT_DIAL, EV_SETUP_ERR, lli_error}, + {ST_IN_WAIT_LL, EV_LEASED_REL, lli_failure_l}, + {ST_IN_WAIT_LL, EV_ACCEPTD, lli_setup_rsp}, + {ST_IN_WAIT_LL, EV_HANGUP, lli_reject_req}, + {ST_IN_WAIT_LL, EV_DISCONNECT_IND, lli_release_req}, + {ST_IN_WAIT_LL, EV_RELEASE, lli_dhup_close}, + {ST_IN_WAIT_LL, EV_SETUP_IND, lli_deliver_call}, + {ST_IN_WAIT_LL, EV_SETUP_ERR, lli_error}, + {ST_IN_ALERT_SENT, EV_SETUP_CMPL_IND, lli_init_bchan_in}, + {ST_IN_ALERT_SENT, EV_ACCEPTD, lli_send_dconnect}, + {ST_IN_ALERT_SENT, EV_HANGUP, lli_disconnect_reject}, + {ST_IN_ALERT_SENT, EV_DISCONNECT_IND, lli_release_req}, + {ST_IN_ALERT_SENT, EV_RELEASE, lli_dhup_close}, {ST_IN_ALERT_SENT, EV_REDIR, lli_send_redir}, {ST_IN_PROCEED_SEND, EV_REDIR, lli_send_redir}, {ST_IN_PROCEED_SEND, EV_ALERT, lli_send_alert}, {ST_IN_PROCEED_SEND, EV_ACCEPTD, lli_send_dconnect}, {ST_IN_PROCEED_SEND, EV_HANGUP, lli_disconnect_reject}, {ST_IN_PROCEED_SEND, EV_DISCONNECT_IND, lli_dhup_close}, - {ST_IN_ALERT_SENT, EV_RELEASE, lli_dhup_close}, - {ST_IN_WAIT_CONN_ACK, EV_SETUP_CMPL_IND, lli_init_bchan_in}, - {ST_IN_WAIT_CONN_ACK, EV_HANGUP, lli_disconnect_req}, - {ST_IN_WAIT_CONN_ACK, EV_DISCONNECT_IND, lli_release_req}, - {ST_IN_WAIT_CONN_ACK, EV_RELEASE, lli_dhup_close}, - {ST_IN_WAIT_CONN_ACK, EV_CONNECT_ERR, lli_error}, - {ST_WAIT_BCONN, EV_BC_EST, lli_go_active}, - {ST_WAIT_BCONN, EV_BC_REL, lli_rel_b_disc}, - {ST_WAIT_BCONN, EV_HANGUP, lli_rel_b_disc}, - {ST_WAIT_BCONN, EV_DISCONNECT_IND, lli_rel_b_release_req}, - {ST_WAIT_BCONN, EV_RELEASE, lli_rel_b_dhup}, - {ST_WAIT_BCONN, EV_LEASED_REL, lli_rel_b_fail}, - {ST_WAIT_BCONN, EV_CINF, lli_charge_info}, - {ST_ACTIVE, EV_CINF, lli_charge_info}, - {ST_ACTIVE, EV_BC_REL, lli_bhup_rel_b}, - {ST_ACTIVE, EV_SUSPEND, lli_suspend}, - {ST_ACTIVE, EV_HANGUP, lli_disconn_bchan}, - {ST_ACTIVE, EV_DISCONNECT_IND, lli_release_bchan}, - {ST_ACTIVE, EV_RELEASE, lli_abort}, - {ST_ACTIVE, EV_LEASED_REL, lli_failure_a}, - {ST_WAIT_BRELEASE, EV_BC_REL, lli_bhup_disc}, - {ST_WAIT_BRELEASE, EV_DISCONNECT_IND, lli_bhup_release_req}, - {ST_WAIT_BRELEASE, EV_RELEASE, lli_bhup_dhup}, - {ST_WAIT_BRELEASE, EV_LEASED_REL, lli_bhup_fail}, - {ST_WAIT_BREL_DISC, EV_BC_REL, lli_bhup_release_req}, - {ST_WAIT_BREL_DISC, EV_RELEASE, lli_bhup_dhup}, - {ST_WAIT_DCOMMAND, EV_HANGUP, lli_start_disc}, - {ST_WAIT_DCOMMAND, EV_DISCONNECT_IND, lli_release_req}, - {ST_WAIT_DCOMMAND, EV_RELEASE, lli_dhup_close}, - {ST_WAIT_DCOMMAND, EV_LEASED_REL, lli_failure_l}, - {ST_WAIT_DRELEASE, EV_RELEASE, lli_dhup_close}, - {ST_WAIT_DRELEASE, EV_DIAL, lli_dchan_not_ready}, - /* ETS 300-104 16.1 */ - {ST_WAIT_D_REL_CNF, EV_RELEASE, lli_dhup_close}, - {ST_WAIT_D_REL_CNF, EV_DIAL, lli_dchan_not_ready}, + {ST_IN_ALERT_SENT, EV_RELEASE, lli_dhup_close}, + {ST_IN_WAIT_CONN_ACK, EV_SETUP_CMPL_IND, lli_init_bchan_in}, + {ST_IN_WAIT_CONN_ACK, EV_HANGUP, lli_disconnect_req}, + {ST_IN_WAIT_CONN_ACK, EV_DISCONNECT_IND, lli_release_req}, + {ST_IN_WAIT_CONN_ACK, EV_RELEASE, lli_dhup_close}, + {ST_IN_WAIT_CONN_ACK, EV_CONNECT_ERR, lli_error}, + {ST_WAIT_BCONN, EV_BC_EST, lli_go_active}, + {ST_WAIT_BCONN, EV_BC_REL, lli_rel_b_disc}, + {ST_WAIT_BCONN, EV_HANGUP, lli_rel_b_disc}, + {ST_WAIT_BCONN, EV_DISCONNECT_IND, lli_rel_b_release_req}, + {ST_WAIT_BCONN, EV_RELEASE, lli_rel_b_dhup}, + {ST_WAIT_BCONN, EV_LEASED_REL, lli_rel_b_fail}, + {ST_WAIT_BCONN, EV_CINF, lli_charge_info}, + {ST_ACTIVE, EV_CINF, lli_charge_info}, + {ST_ACTIVE, EV_BC_REL, lli_bhup_rel_b}, + {ST_ACTIVE, EV_SUSPEND, lli_suspend}, + {ST_ACTIVE, EV_HANGUP, lli_disconn_bchan}, + {ST_ACTIVE, EV_DISCONNECT_IND, lli_release_bchan}, + {ST_ACTIVE, EV_RELEASE, lli_abort}, + {ST_ACTIVE, EV_LEASED_REL, lli_failure_a}, + {ST_WAIT_BRELEASE, EV_BC_REL, lli_bhup_disc}, + {ST_WAIT_BRELEASE, EV_DISCONNECT_IND, lli_bhup_release_req}, + {ST_WAIT_BRELEASE, EV_RELEASE, lli_bhup_dhup}, + {ST_WAIT_BRELEASE, EV_LEASED_REL, lli_bhup_fail}, + {ST_WAIT_BREL_DISC, EV_BC_REL, lli_bhup_release_req}, + {ST_WAIT_BREL_DISC, EV_RELEASE, lli_bhup_dhup}, + {ST_WAIT_DCOMMAND, EV_HANGUP, lli_start_disc}, + {ST_WAIT_DCOMMAND, EV_DISCONNECT_IND, lli_release_req}, + {ST_WAIT_DCOMMAND, EV_RELEASE, lli_dhup_close}, + {ST_WAIT_DCOMMAND, EV_LEASED_REL, lli_failure_l}, + {ST_WAIT_DRELEASE, EV_RELEASE, lli_dhup_close}, + {ST_WAIT_DRELEASE, EV_DIAL, lli_dchan_not_ready}, + /* ETS 300-104 16.1 */ + {ST_WAIT_D_REL_CNF, EV_RELEASE, lli_dhup_close}, + {ST_WAIT_D_REL_CNF, EV_DIAL, lli_dchan_not_ready}, }; /* *INDENT-ON* */ @@ -855,21 +855,21 @@ release_b_st(struct Channel *chanp) { struct PStack *st = chanp->b_st; - if(test_and_clear_bit(FLG_START_B, &chanp->Flags)) { + if (test_and_clear_bit(FLG_START_B, &chanp->Flags)) { chanp->bcs->BC_Close(chanp->bcs); switch (chanp->l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - releasestack_isdnl2(st); - break; - case (ISDN_PROTO_L2_HDLC): - case (ISDN_PROTO_L2_HDLC_56K): - case (ISDN_PROTO_L2_TRANS): - case (ISDN_PROTO_L2_MODEM): - case (ISDN_PROTO_L2_FAX): - releasestack_transl2(st); - break; + case (ISDN_PROTO_L2_X75I): + releasestack_isdnl2(st); + break; + case (ISDN_PROTO_L2_HDLC): + case (ISDN_PROTO_L2_HDLC_56K): + case (ISDN_PROTO_L2_TRANS): + case (ISDN_PROTO_L2_MODEM): + case (ISDN_PROTO_L2_FAX): + releasestack_transl2(st); + break; } - } + } } static struct Channel @@ -880,9 +880,9 @@ static struct Channel int i; if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags)) - i=1; + i = 1; else - i=0; + i = 0; if (!bch) { i = 2; /* virtual channel */ @@ -912,10 +912,10 @@ static struct Channel static void stat_redir_result(struct IsdnCardState *cs, int chan, ulong result) { isdn_ctrl ic; - + ic.driver = cs->myid; ic.command = ISDN_STAT_REDIR; - ic.arg = chan; + ic.arg = chan; ic.parm.num[0] = result; cs->iif.statcallb(&ic); } /* stat_redir_result */ @@ -927,7 +927,7 @@ dchan_l3l4(struct PStack *st, int pr, void *arg) struct IsdnCardState *cs = st->l1.hardware; struct Channel *chanp; - if(!pc) + if (!pc) return; if (pr == (CC_SETUP | INDICATION)) { @@ -945,63 +945,63 @@ dchan_l3l4(struct PStack *st, int pr, void *arg) return; switch (pr) { - case (CC_MORE_INFO | INDICATION): - FsmEvent(&chanp->fi, EV_SETUP_IND, NULL); - break; - case (CC_DISCONNECT | INDICATION): - FsmEvent(&chanp->fi, EV_DISCONNECT_IND, NULL); - break; - case (CC_RELEASE | CONFIRM): - FsmEvent(&chanp->fi, EV_RELEASE, NULL); - break; - case (CC_SUSPEND | CONFIRM): - FsmEvent(&chanp->fi, EV_RELEASE, NULL); - break; - case (CC_RESUME | CONFIRM): - FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL); - break; - case (CC_RESUME_ERR): - FsmEvent(&chanp->fi, EV_RELEASE, NULL); - break; - case (CC_RELEASE | INDICATION): - FsmEvent(&chanp->fi, EV_RELEASE, NULL); - break; - case (CC_SETUP_COMPL | INDICATION): - FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL); - break; - case (CC_SETUP | CONFIRM): - FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL); - break; - case (CC_CHARGE | INDICATION): - FsmEvent(&chanp->fi, EV_CINF, NULL); - break; - case (CC_NOSETUP_RSP): - FsmEvent(&chanp->fi, EV_NOSETUP_RSP, NULL); - break; - case (CC_SETUP_ERR): - FsmEvent(&chanp->fi, EV_SETUP_ERR, NULL); - break; - case (CC_CONNECT_ERR): - FsmEvent(&chanp->fi, EV_CONNECT_ERR, NULL); - break; - case (CC_RELEASE_ERR): - FsmEvent(&chanp->fi, EV_RELEASE, NULL); - break; - case (CC_PROCEED_SEND | INDICATION): - case (CC_PROCEEDING | INDICATION): - case (CC_ALERTING | INDICATION): - case (CC_PROGRESS | INDICATION): - case (CC_NOTIFY | INDICATION): - break; - case (CC_REDIR | INDICATION): - stat_redir_result(cs, chanp->chan, pc->redir_result); - break; - default: - if (chanp->debug & 0x800) { - HiSax_putstatus(chanp->cs, "Ch", + case (CC_MORE_INFO | INDICATION): + FsmEvent(&chanp->fi, EV_SETUP_IND, NULL); + break; + case (CC_DISCONNECT | INDICATION): + FsmEvent(&chanp->fi, EV_DISCONNECT_IND, NULL); + break; + case (CC_RELEASE | CONFIRM): + FsmEvent(&chanp->fi, EV_RELEASE, NULL); + break; + case (CC_SUSPEND | CONFIRM): + FsmEvent(&chanp->fi, EV_RELEASE, NULL); + break; + case (CC_RESUME | CONFIRM): + FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL); + break; + case (CC_RESUME_ERR): + FsmEvent(&chanp->fi, EV_RELEASE, NULL); + break; + case (CC_RELEASE | INDICATION): + FsmEvent(&chanp->fi, EV_RELEASE, NULL); + break; + case (CC_SETUP_COMPL | INDICATION): + FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL); + break; + case (CC_SETUP | CONFIRM): + FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL); + break; + case (CC_CHARGE | INDICATION): + FsmEvent(&chanp->fi, EV_CINF, NULL); + break; + case (CC_NOSETUP_RSP): + FsmEvent(&chanp->fi, EV_NOSETUP_RSP, NULL); + break; + case (CC_SETUP_ERR): + FsmEvent(&chanp->fi, EV_SETUP_ERR, NULL); + break; + case (CC_CONNECT_ERR): + FsmEvent(&chanp->fi, EV_CONNECT_ERR, NULL); + break; + case (CC_RELEASE_ERR): + FsmEvent(&chanp->fi, EV_RELEASE, NULL); + break; + case (CC_PROCEED_SEND | INDICATION): + case (CC_PROCEEDING | INDICATION): + case (CC_ALERTING | INDICATION): + case (CC_PROGRESS | INDICATION): + case (CC_NOTIFY | INDICATION): + break; + case (CC_REDIR | INDICATION): + stat_redir_result(cs, chanp->chan, pc->redir_result); + break; + default: + if (chanp->debug & 0x800) { + HiSax_putstatus(chanp->cs, "Ch", "%d L3->L4 unknown primitiv %#x", chanp->chan, pr); - } + } } } @@ -1069,7 +1069,7 @@ init_d_st(struct Channel *chanp) } static __printf(2, 3) void -callc_debug(struct FsmInst *fi, char *fmt, ...) + callc_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; struct Channel *chanp = fi->userdata; @@ -1129,8 +1129,8 @@ CallcNewChan(struct IsdnCardState *csta) { return err; printk(KERN_INFO "HiSax: 2 channels added\n"); - for (i = 0; i < MAX_WAITING_CALLS; i++) { - err = init_chan(i+2,csta); + for (i = 0; i < MAX_WAITING_CALLS; i++) { + err = init_chan(i + 2, csta); if (err) return err; } @@ -1138,7 +1138,7 @@ CallcNewChan(struct IsdnCardState *csta) { if (test_bit(FLG_PTP, &csta->channel->d_st->l2.flag)) { printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n"); csta->channel->d_st->lli.l4l3(csta->channel->d_st, - DL_ESTABLISH | REQUEST, NULL); + DL_ESTABLISH | REQUEST, NULL); } return (0); } @@ -1187,28 +1187,28 @@ lldata_handler(struct PStack *st, int pr, void *arg) struct sk_buff *skb = arg; switch (pr) { - case (DL_DATA | INDICATION): - if (chanp->data_open) { - if (chanp->debug & 0x800) - link_debug(chanp, 0, "lldata: %d", skb->len); - chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb); - } else { - link_debug(chanp, 0, "lldata: channel not open"); - dev_kfree_skb(skb); - } - break; - case (DL_ESTABLISH | INDICATION): - case (DL_ESTABLISH | CONFIRM): - FsmEvent(&chanp->fi, EV_BC_EST, NULL); - break; - case (DL_RELEASE | INDICATION): - case (DL_RELEASE | CONFIRM): - FsmEvent(&chanp->fi, EV_BC_REL, NULL); - break; - default: - printk(KERN_WARNING "lldata_handler unknown primitive %#x\n", - pr); - break; + case (DL_DATA | INDICATION): + if (chanp->data_open) { + if (chanp->debug & 0x800) + link_debug(chanp, 0, "lldata: %d", skb->len); + chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb); + } else { + link_debug(chanp, 0, "lldata: channel not open"); + dev_kfree_skb(skb); + } + break; + case (DL_ESTABLISH | INDICATION): + case (DL_ESTABLISH | CONFIRM): + FsmEvent(&chanp->fi, EV_BC_EST, NULL); + break; + case (DL_RELEASE | INDICATION): + case (DL_RELEASE | CONFIRM): + FsmEvent(&chanp->fi, EV_BC_REL, NULL); + break; + default: + printk(KERN_WARNING "lldata_handler unknown primitive %#x\n", + pr); + break; } } @@ -1219,28 +1219,28 @@ lltrans_handler(struct PStack *st, int pr, void *arg) struct sk_buff *skb = arg; switch (pr) { - case (PH_DATA | INDICATION): - if (chanp->data_open) { - if (chanp->debug & 0x800) - link_debug(chanp, 0, "lltrans: %d", skb->len); - chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb); - } else { - link_debug(chanp, 0, "lltrans: channel not open"); - dev_kfree_skb(skb); - } - break; - case (PH_ACTIVATE | INDICATION): - case (PH_ACTIVATE | CONFIRM): - FsmEvent(&chanp->fi, EV_BC_EST, NULL); - break; - case (PH_DEACTIVATE | INDICATION): - case (PH_DEACTIVATE | CONFIRM): - FsmEvent(&chanp->fi, EV_BC_REL, NULL); - break; - default: - printk(KERN_WARNING "lltrans_handler unknown primitive %#x\n", - pr); - break; + case (PH_DATA | INDICATION): + if (chanp->data_open) { + if (chanp->debug & 0x800) + link_debug(chanp, 0, "lltrans: %d", skb->len); + chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb); + } else { + link_debug(chanp, 0, "lltrans: channel not open"); + dev_kfree_skb(skb); + } + break; + case (PH_ACTIVATE | INDICATION): + case (PH_ACTIVATE | CONFIRM): + FsmEvent(&chanp->fi, EV_BC_EST, NULL); + break; + case (PH_DEACTIVATE | INDICATION): + case (PH_DEACTIVATE | CONFIRM): + FsmEvent(&chanp->fi, EV_BC_REL, NULL); + break; + default: + printk(KERN_WARNING "lltrans_handler unknown primitive %#x\n", + pr); + break; } } @@ -1272,22 +1272,22 @@ init_b_st(struct Channel *chanp, int incoming) else st->l1.bc = chanp->proc->para.bchannel - 1; switch (chanp->l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - case (ISDN_PROTO_L2_HDLC): - st->l1.mode = L1_MODE_HDLC; - break; - case (ISDN_PROTO_L2_HDLC_56K): - st->l1.mode = L1_MODE_HDLC_56K; - break; - case (ISDN_PROTO_L2_TRANS): - st->l1.mode = L1_MODE_TRANS; - break; - case (ISDN_PROTO_L2_MODEM): - st->l1.mode = L1_MODE_V32; - break; - case (ISDN_PROTO_L2_FAX): - st->l1.mode = L1_MODE_FAX; - break; + case (ISDN_PROTO_L2_X75I): + case (ISDN_PROTO_L2_HDLC): + st->l1.mode = L1_MODE_HDLC; + break; + case (ISDN_PROTO_L2_HDLC_56K): + st->l1.mode = L1_MODE_HDLC_56K; + break; + case (ISDN_PROTO_L2_TRANS): + st->l1.mode = L1_MODE_TRANS; + break; + case (ISDN_PROTO_L2_MODEM): + st->l1.mode = L1_MODE_V32; + break; + case (ISDN_PROTO_L2_FAX): + st->l1.mode = L1_MODE_FAX; + break; } chanp->bcs->conmsg = NULL; if (chanp->bcs->BC_SetStack(st, chanp->bcs)) @@ -1303,29 +1303,29 @@ init_b_st(struct Channel *chanp, int incoming) st->l2.T203 = 5000; /* 5000 milliseconds */ st->l3.debug = 0; switch (chanp->l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - sprintf(tmp, "Ch%d X.75", chanp->chan); - setstack_isdnl2(st, tmp); - setstack_l3bc(st, chanp); - st->l2.l2l3 = lldata_handler; - st->lli.userdata = chanp; - test_and_clear_bit(FLG_LLI_L1WAKEUP, &st->lli.flag); - test_and_set_bit(FLG_LLI_L2WAKEUP, &st->lli.flag); - st->l2.l2m.debug = chanp->debug & 16; - st->l2.debug = chanp->debug & 64; - break; - case (ISDN_PROTO_L2_HDLC): - case (ISDN_PROTO_L2_HDLC_56K): - case (ISDN_PROTO_L2_TRANS): - case (ISDN_PROTO_L2_MODEM): - case (ISDN_PROTO_L2_FAX): - st->l1.l1l2 = lltrans_handler; - st->lli.userdata = chanp; - test_and_set_bit(FLG_LLI_L1WAKEUP, &st->lli.flag); - test_and_clear_bit(FLG_LLI_L2WAKEUP, &st->lli.flag); - setstack_transl2(st); - setstack_l3bc(st, chanp); - break; + case (ISDN_PROTO_L2_X75I): + sprintf(tmp, "Ch%d X.75", chanp->chan); + setstack_isdnl2(st, tmp); + setstack_l3bc(st, chanp); + st->l2.l2l3 = lldata_handler; + st->lli.userdata = chanp; + test_and_clear_bit(FLG_LLI_L1WAKEUP, &st->lli.flag); + test_and_set_bit(FLG_LLI_L2WAKEUP, &st->lli.flag); + st->l2.l2m.debug = chanp->debug & 16; + st->l2.debug = chanp->debug & 64; + break; + case (ISDN_PROTO_L2_HDLC): + case (ISDN_PROTO_L2_HDLC_56K): + case (ISDN_PROTO_L2_TRANS): + case (ISDN_PROTO_L2_MODEM): + case (ISDN_PROTO_L2_FAX): + st->l1.l1l2 = lltrans_handler; + st->lli.userdata = chanp; + test_and_set_bit(FLG_LLI_L1WAKEUP, &st->lli.flag); + test_and_clear_bit(FLG_LLI_L2WAKEUP, &st->lli.flag); + setstack_transl2(st); + setstack_l3bc(st, chanp); + break; } test_and_set_bit(FLG_START_B, &chanp->Flags); return (0); @@ -1338,19 +1338,19 @@ leased_l4l3(struct PStack *st, int pr, void *arg) struct sk_buff *skb = arg; switch (pr) { - case (DL_DATA | REQUEST): - link_debug(chanp, 0, "leased line d-channel DATA"); - dev_kfree_skb(skb); - break; - case (DL_ESTABLISH | REQUEST): - st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL); - break; - case (DL_RELEASE | REQUEST): - break; - default: - printk(KERN_WARNING "transd_l4l3 unknown primitive %#x\n", - pr); - break; + case (DL_DATA | REQUEST): + link_debug(chanp, 0, "leased line d-channel DATA"); + dev_kfree_skb(skb); + break; + case (DL_ESTABLISH | REQUEST): + st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL); + break; + case (DL_RELEASE | REQUEST): + break; + default: + printk(KERN_WARNING "transd_l4l3 unknown primitive %#x\n", + pr); + break; } } @@ -1359,32 +1359,32 @@ leased_l1l2(struct PStack *st, int pr, void *arg) { struct Channel *chanp = (struct Channel *) st->lli.userdata; struct sk_buff *skb = arg; - int i,event = EV_LEASED_REL; + int i, event = EV_LEASED_REL; switch (pr) { - case (PH_DATA | INDICATION): - link_debug(chanp, 0, "leased line d-channel DATA"); - dev_kfree_skb(skb); - break; - case (PH_ACTIVATE | INDICATION): - case (PH_ACTIVATE | CONFIRM): - event = EV_LEASED; - case (PH_DEACTIVATE | INDICATION): - case (PH_DEACTIVATE | CONFIRM): - if (test_bit(FLG_TWO_DCHAN, &chanp->cs->HW_Flags)) - i = 1; - else - i = 0; - while (i < 2) { - FsmEvent(&chanp->fi, event, NULL); - chanp++; - i++; - } - break; - default: - printk(KERN_WARNING - "transd_l1l2 unknown primitive %#x\n", pr); - break; + case (PH_DATA | INDICATION): + link_debug(chanp, 0, "leased line d-channel DATA"); + dev_kfree_skb(skb); + break; + case (PH_ACTIVATE | INDICATION): + case (PH_ACTIVATE | CONFIRM): + event = EV_LEASED; + case (PH_DEACTIVATE | INDICATION): + case (PH_DEACTIVATE | CONFIRM): + if (test_bit(FLG_TWO_DCHAN, &chanp->cs->HW_Flags)) + i = 1; + else + i = 0; + while (i < 2) { + FsmEvent(&chanp->fi, event, NULL); + chanp++; + i++; + } + break; + default: + printk(KERN_WARNING + "transd_l1l2 unknown primitive %#x\n", pr); + break; } } @@ -1394,7 +1394,7 @@ distr_debug(struct IsdnCardState *csta, int debugflags) int i; struct Channel *chanp = csta->channel; - for (i = 0; i < (2 + MAX_WAITING_CALLS) ; i++) { + for (i = 0; i < (2 + MAX_WAITING_CALLS); i++) { chanp[i].debug = debugflags; chanp[i].fi.debug = debugflags & 2; chanp[i].d_st->l2.l2m.debug = debugflags & 8; @@ -1421,9 +1421,9 @@ capi_debug(struct Channel *chanp, capi_msg *cm) { char *t = tmpbuf; - t += QuickHex(t, (u_char *)cm, (cm->Length>50)? 50: cm->Length); + t += QuickHex(t, (u_char *)cm, (cm->Length > 50) ? 50 : cm->Length); t--; - *t= 0; + *t = 0; HiSax_putstatus(chanp->cs, "Ch", "%d CAPIMSG %s", chanp->chan, tmpbuf); } @@ -1431,31 +1431,31 @@ static void lli_got_fac_req(struct Channel *chanp, capi_msg *cm) { if ((cm->para[0] != 3) || (cm->para[1] != 0)) return; - if (cm->para[2]<3) + if (cm->para[2] < 3) return; if (cm->para[4] != 0) return; - switch(cm->para[3]) { - case 4: /* Suspend */ - strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] +1); - FsmEvent(&chanp->fi, EV_SUSPEND, cm); - break; - case 5: /* Resume */ - strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] +1); - if (chanp->fi.state == ST_NULL) { - FsmEvent(&chanp->fi, EV_RESUME, cm); - } else { - FsmDelTimer(&chanp->dial_timer, 72); - FsmAddTimer(&chanp->dial_timer, 80, EV_RESUME, cm, 73); - } - break; + switch (cm->para[3]) { + case 4: /* Suspend */ + strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] + 1); + FsmEvent(&chanp->fi, EV_SUSPEND, cm); + break; + case 5: /* Resume */ + strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] + 1); + if (chanp->fi.state == ST_NULL) { + FsmEvent(&chanp->fi, EV_RESUME, cm); + } else { + FsmDelTimer(&chanp->dial_timer, 72); + FsmAddTimer(&chanp->dial_timer, 80, EV_RESUME, cm, 73); + } + break; } } static void lli_got_manufacturer(struct Channel *chanp, struct IsdnCardState *cs, capi_msg *cm) { if ((cs->typ == ISDN_CTYPE_ELSA) || (cs->typ == ISDN_CTYPE_ELSA_PNP) || - (cs->typ == ISDN_CTYPE_ELSA_PCI)) { + (cs->typ == ISDN_CTYPE_ELSA_PCI)) { if (cs->hw.elsa.MFlag) { cs->cardmsg(cs, CARD_AUX_IND, cm->para); } @@ -1466,14 +1466,14 @@ lli_got_manufacturer(struct Channel *chanp, struct IsdnCardState *cs, capi_msg * /***************************************************************/ /* Limit the available number of channels for the current card */ /***************************************************************/ -static int +static int set_channel_limit(struct IsdnCardState *cs, int chanmax) { isdn_ctrl ic; int i, ii; if ((chanmax < 0) || (chanmax > 2)) - return(-EINVAL); + return (-EINVAL); cs->chanlimit = 0; for (ii = 0; ii < 2; ii++) { ic.driver = cs->myid; @@ -1483,16 +1483,16 @@ set_channel_limit(struct IsdnCardState *cs, int chanmax) ic.parm.num[0] = 0; /* disabled */ else ic.parm.num[0] = 1; /* enabled */ - i = cs->iif.statcallb(&ic); - if (i) return(-EINVAL); - if (ii < chanmax) + i = cs->iif.statcallb(&ic); + if (i) return (-EINVAL); + if (ii < chanmax) cs->chanlimit++; } - return(0); + return (0); } /* set_channel_limit */ int -HiSax_command(isdn_ctrl * ic) +HiSax_command(isdn_ctrl *ic) { struct IsdnCardState *csta = hisax_findcard(ic->driver); struct PStack *st; @@ -1502,236 +1502,236 @@ HiSax_command(isdn_ctrl * ic) if (!csta) { printk(KERN_ERR - "HiSax: if_command %d called with invalid driverId %d!\n", - ic->command, ic->driver); + "HiSax: if_command %d called with invalid driverId %d!\n", + ic->command, ic->driver); return -ENODEV; } switch (ic->command) { - case (ISDN_CMD_SETEAZ): - chanp = csta->channel + ic->arg; + case (ISDN_CMD_SETEAZ): + chanp = csta->channel + ic->arg; + break; + case (ISDN_CMD_SETL2): + chanp = csta->channel + (ic->arg & 0xff); + if (chanp->debug & 1) + link_debug(chanp, 1, "SETL2 card %d %ld", + csta->cardnr + 1, ic->arg >> 8); + chanp->l2_protocol = ic->arg >> 8; + break; + case (ISDN_CMD_SETL3): + chanp = csta->channel + (ic->arg & 0xff); + if (chanp->debug & 1) + link_debug(chanp, 1, "SETL3 card %d %ld", + csta->cardnr + 1, ic->arg >> 8); + chanp->l3_protocol = ic->arg >> 8; + break; + case (ISDN_CMD_DIAL): + chanp = csta->channel + (ic->arg & 0xff); + if (chanp->debug & 1) + link_debug(chanp, 1, "DIAL %s -> %s (%d,%d)", + ic->parm.setup.eazmsn, ic->parm.setup.phone, + ic->parm.setup.si1, ic->parm.setup.si2); + memcpy(&chanp->setup, &ic->parm.setup, sizeof(setup_parm)); + if (!strcmp(chanp->setup.eazmsn, "0")) + chanp->setup.eazmsn[0] = '\0'; + /* this solution is dirty and may be change, if + * we make a callreference based callmanager */ + if (chanp->fi.state == ST_NULL) { + FsmEvent(&chanp->fi, EV_DIAL, NULL); + } else { + FsmDelTimer(&chanp->dial_timer, 70); + FsmAddTimer(&chanp->dial_timer, 50, EV_DIAL, NULL, 71); + } + break; + case (ISDN_CMD_ACCEPTB): + chanp = csta->channel + ic->arg; + if (chanp->debug & 1) + link_debug(chanp, 1, "ACCEPTB"); + FsmEvent(&chanp->fi, EV_ACCEPTB, NULL); + break; + case (ISDN_CMD_ACCEPTD): + chanp = csta->channel + ic->arg; + memcpy(&chanp->setup, &ic->parm.setup, sizeof(setup_parm)); + if (chanp->debug & 1) + link_debug(chanp, 1, "ACCEPTD"); + FsmEvent(&chanp->fi, EV_ACCEPTD, NULL); + break; + case (ISDN_CMD_HANGUP): + chanp = csta->channel + ic->arg; + if (chanp->debug & 1) + link_debug(chanp, 1, "HANGUP"); + FsmEvent(&chanp->fi, EV_HANGUP, NULL); + break; + case (CAPI_PUT_MESSAGE): + chanp = csta->channel + ic->arg; + if (chanp->debug & 1) + capi_debug(chanp, &ic->parm.cmsg); + if (ic->parm.cmsg.Length < 8) break; - case (ISDN_CMD_SETL2): - chanp = csta->channel + (ic->arg & 0xff); - if (chanp->debug & 1) - link_debug(chanp, 1, "SETL2 card %d %ld", - csta->cardnr + 1, ic->arg >> 8); - chanp->l2_protocol = ic->arg >> 8; + switch (ic->parm.cmsg.Command) { + case CAPI_FACILITY: + if (ic->parm.cmsg.Subcommand == CAPI_REQ) + lli_got_fac_req(chanp, &ic->parm.cmsg); break; - case (ISDN_CMD_SETL3): - chanp = csta->channel + (ic->arg & 0xff); - if (chanp->debug & 1) - link_debug(chanp, 1, "SETL3 card %d %ld", - csta->cardnr + 1, ic->arg >> 8); - chanp->l3_protocol = ic->arg >> 8; + case CAPI_MANUFACTURER: + if (ic->parm.cmsg.Subcommand == CAPI_REQ) + lli_got_manufacturer(chanp, csta, &ic->parm.cmsg); break; - case (ISDN_CMD_DIAL): - chanp = csta->channel + (ic->arg & 0xff); - if (chanp->debug & 1) - link_debug(chanp, 1, "DIAL %s -> %s (%d,%d)", - ic->parm.setup.eazmsn, ic->parm.setup.phone, - ic->parm.setup.si1, ic->parm.setup.si2); - memcpy(&chanp->setup, &ic->parm.setup, sizeof(setup_parm)); - if (!strcmp(chanp->setup.eazmsn, "0")) - chanp->setup.eazmsn[0] = '\0'; - /* this solution is dirty and may be change, if - * we make a callreference based callmanager */ - if (chanp->fi.state == ST_NULL) { - FsmEvent(&chanp->fi, EV_DIAL, NULL); - } else { - FsmDelTimer(&chanp->dial_timer, 70); - FsmAddTimer(&chanp->dial_timer, 50, EV_DIAL, NULL, 71); - } + default: break; - case (ISDN_CMD_ACCEPTB): - chanp = csta->channel + ic->arg; - if (chanp->debug & 1) - link_debug(chanp, 1, "ACCEPTB"); - FsmEvent(&chanp->fi, EV_ACCEPTB, NULL); + } + break; + case (ISDN_CMD_IOCTL): + switch (ic->arg) { + case (0): + num = *(unsigned int *) ic->parm.num; + HiSax_reportcard(csta->cardnr, num); break; - case (ISDN_CMD_ACCEPTD): - chanp = csta->channel + ic->arg; - memcpy(&chanp->setup, &ic->parm.setup, sizeof(setup_parm)); - if (chanp->debug & 1) - link_debug(chanp, 1, "ACCEPTD"); - FsmEvent(&chanp->fi, EV_ACCEPTD, NULL); + case (1): + num = *(unsigned int *) ic->parm.num; + distr_debug(csta, num); + printk(KERN_DEBUG "HiSax: debugging flags card %d set to %x\n", + csta->cardnr + 1, num); + HiSax_putstatus(csta, "debugging flags ", + "card %d set to %x", csta->cardnr + 1, num); break; - case (ISDN_CMD_HANGUP): - chanp = csta->channel + ic->arg; - if (chanp->debug & 1) - link_debug(chanp, 1, "HANGUP"); - FsmEvent(&chanp->fi, EV_HANGUP, NULL); + case (2): + num = *(unsigned int *) ic->parm.num; + csta->channel[0].b_st->l1.delay = num; + csta->channel[1].b_st->l1.delay = num; + HiSax_putstatus(csta, "delay ", "card %d set to %d ms", + csta->cardnr + 1, num); + printk(KERN_DEBUG "HiSax: delay card %d set to %d ms\n", + csta->cardnr + 1, num); break; - case (CAPI_PUT_MESSAGE): - chanp = csta->channel + ic->arg; - if (chanp->debug & 1) - capi_debug(chanp, &ic->parm.cmsg); - if (ic->parm.cmsg.Length < 8) - break; - switch(ic->parm.cmsg.Command) { - case CAPI_FACILITY: - if (ic->parm.cmsg.Subcommand == CAPI_REQ) - lli_got_fac_req(chanp, &ic->parm.cmsg); - break; - case CAPI_MANUFACTURER: - if (ic->parm.cmsg.Subcommand == CAPI_REQ) - lli_got_manufacturer(chanp, csta, &ic->parm.cmsg); - break; - default: - break; + case (5): /* set card in leased mode */ + num = *(unsigned int *) ic->parm.num; + if ((num < 1) || (num > 2)) { + HiSax_putstatus(csta, "Set LEASED ", + "wrong channel %d", num); + printk(KERN_WARNING "HiSax: Set LEASED wrong channel %d\n", + num); + } else { + num--; + chanp = csta->channel + num; + chanp->leased = 1; + HiSax_putstatus(csta, "Card", + "%d channel %d set leased mode\n", + csta->cardnr + 1, num + 1); + chanp->d_st->l1.l1l2 = leased_l1l2; + chanp->d_st->lli.l4l3 = leased_l4l3; + chanp->d_st->lli.l4l3(chanp->d_st, + DL_ESTABLISH | REQUEST, NULL); } break; - case (ISDN_CMD_IOCTL): - switch (ic->arg) { - case (0): - num = *(unsigned int *) ic->parm.num; - HiSax_reportcard(csta->cardnr, num); - break; - case (1): - num = *(unsigned int *) ic->parm.num; - distr_debug(csta, num); - printk(KERN_DEBUG "HiSax: debugging flags card %d set to %x\n", - csta->cardnr + 1, num); - HiSax_putstatus(csta, "debugging flags ", - "card %d set to %x", csta->cardnr + 1, num); - break; - case (2): - num = *(unsigned int *) ic->parm.num; - csta->channel[0].b_st->l1.delay = num; - csta->channel[1].b_st->l1.delay = num; - HiSax_putstatus(csta, "delay ", "card %d set to %d ms", - csta->cardnr + 1, num); - printk(KERN_DEBUG "HiSax: delay card %d set to %d ms\n", - csta->cardnr + 1, num); - break; - case (5): /* set card in leased mode */ - num = *(unsigned int *) ic->parm.num; - if ((num <1) || (num > 2)) { - HiSax_putstatus(csta, "Set LEASED ", - "wrong channel %d", num); - printk(KERN_WARNING "HiSax: Set LEASED wrong channel %d\n", - num); - } else { - num--; - chanp = csta->channel +num; - chanp->leased = 1; - HiSax_putstatus(csta, "Card", - "%d channel %d set leased mode\n", - csta->cardnr + 1, num + 1); - chanp->d_st->l1.l1l2 = leased_l1l2; - chanp->d_st->lli.l4l3 = leased_l4l3; - chanp->d_st->lli.l4l3(chanp->d_st, - DL_ESTABLISH | REQUEST, NULL); - } - break; - case (6): /* set B-channel test loop */ - num = *(unsigned int *) ic->parm.num; - if (csta->stlist) - csta->stlist->l2.l2l1(csta->stlist, - PH_TESTLOOP | REQUEST, (void *) (long)num); - break; - case (7): /* set card in PTP mode */ - num = *(unsigned int *) ic->parm.num; - if (test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) { - printk(KERN_ERR "HiSax PTP mode only with one TEI possible\n"); - } else if (num) { - test_and_set_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag); - test_and_set_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag); - csta->channel[0].d_st->l2.tei = 0; - HiSax_putstatus(csta, "set card ", "in PTP mode"); - printk(KERN_DEBUG "HiSax: set card in PTP mode\n"); - printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n"); - csta->channel[0].d_st->lli.l4l3(csta->channel[0].d_st, - DL_ESTABLISH | REQUEST, NULL); - } else { - test_and_clear_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag); - test_and_clear_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag); - HiSax_putstatus(csta, "set card ", "in PTMP mode"); - printk(KERN_DEBUG "HiSax: set card in PTMP mode\n"); - } - break; - case (8): /* set card in FIXED TEI mode */ - num = *(unsigned int *) ic->parm.num; - chanp = csta->channel + (num & 1); - num = num >>1; - if (num == 127) { - test_and_clear_bit(FLG_FIXED_TEI, &chanp->d_st->l2.flag); - chanp->d_st->l2.tei = -1; - HiSax_putstatus(csta, "set card ", "in VAR TEI mode"); - printk(KERN_DEBUG "HiSax: set card in VAR TEI mode\n"); - } else { - test_and_set_bit(FLG_FIXED_TEI, &chanp->d_st->l2.flag); - chanp->d_st->l2.tei = num; - HiSax_putstatus(csta, "set card ", "in FIXED TEI (%d) mode", num); - printk(KERN_DEBUG "HiSax: set card in FIXED TEI (%d) mode\n", - num); - } - chanp->d_st->lli.l4l3(chanp->d_st, - DL_ESTABLISH | REQUEST, NULL); - break; - case (11): - num = csta->debug & DEB_DLOG_HEX; - csta->debug = *(unsigned int *) ic->parm.num; - csta->debug |= num; - HiSax_putstatus(cards[0].cs, "l1 debugging ", - "flags card %d set to %x", - csta->cardnr + 1, csta->debug); - printk(KERN_DEBUG "HiSax: l1 debugging flags card %d set to %x\n", - csta->cardnr + 1, csta->debug); - break; - case (13): - csta->channel[0].d_st->l3.debug = *(unsigned int *) ic->parm.num; - csta->channel[1].d_st->l3.debug = *(unsigned int *) ic->parm.num; - HiSax_putstatus(cards[0].cs, "l3 debugging ", - "flags card %d set to %x\n", csta->cardnr + 1, - *(unsigned int *) ic->parm.num); - printk(KERN_DEBUG "HiSax: l3 debugging flags card %d set to %x\n", - csta->cardnr + 1, *(unsigned int *) ic->parm.num); - break; - case (10): - i = *(unsigned int *) ic->parm.num; - return(set_channel_limit(csta, i)); - default: - if (csta->auxcmd) - return(csta->auxcmd(csta, ic)); - printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", - (int) ic->arg); - return (-EINVAL); - } + case (6): /* set B-channel test loop */ + num = *(unsigned int *) ic->parm.num; + if (csta->stlist) + csta->stlist->l2.l2l1(csta->stlist, + PH_TESTLOOP | REQUEST, (void *) (long)num); break; - - case (ISDN_CMD_PROCEED): - chanp = csta->channel + ic->arg; - if (chanp->debug & 1) - link_debug(chanp, 1, "PROCEED"); - FsmEvent(&chanp->fi, EV_PROCEED, NULL); + case (7): /* set card in PTP mode */ + num = *(unsigned int *) ic->parm.num; + if (test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) { + printk(KERN_ERR "HiSax PTP mode only with one TEI possible\n"); + } else if (num) { + test_and_set_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag); + test_and_set_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag); + csta->channel[0].d_st->l2.tei = 0; + HiSax_putstatus(csta, "set card ", "in PTP mode"); + printk(KERN_DEBUG "HiSax: set card in PTP mode\n"); + printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n"); + csta->channel[0].d_st->lli.l4l3(csta->channel[0].d_st, + DL_ESTABLISH | REQUEST, NULL); + } else { + test_and_clear_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag); + test_and_clear_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag); + HiSax_putstatus(csta, "set card ", "in PTMP mode"); + printk(KERN_DEBUG "HiSax: set card in PTMP mode\n"); + } break; - - case (ISDN_CMD_ALERT): - chanp = csta->channel + ic->arg; - if (chanp->debug & 1) - link_debug(chanp, 1, "ALERT"); - FsmEvent(&chanp->fi, EV_ALERT, NULL); + case (8): /* set card in FIXED TEI mode */ + num = *(unsigned int *)ic->parm.num; + chanp = csta->channel + (num & 1); + num = num >> 1; + if (num == 127) { + test_and_clear_bit(FLG_FIXED_TEI, &chanp->d_st->l2.flag); + chanp->d_st->l2.tei = -1; + HiSax_putstatus(csta, "set card ", "in VAR TEI mode"); + printk(KERN_DEBUG "HiSax: set card in VAR TEI mode\n"); + } else { + test_and_set_bit(FLG_FIXED_TEI, &chanp->d_st->l2.flag); + chanp->d_st->l2.tei = num; + HiSax_putstatus(csta, "set card ", "in FIXED TEI (%d) mode", num); + printk(KERN_DEBUG "HiSax: set card in FIXED TEI (%d) mode\n", + num); + } + chanp->d_st->lli.l4l3(chanp->d_st, + DL_ESTABLISH | REQUEST, NULL); break; - - case (ISDN_CMD_REDIR): - chanp = csta->channel + ic->arg; - if (chanp->debug & 1) - link_debug(chanp, 1, "REDIR"); - memcpy(&chanp->setup, &ic->parm.setup, sizeof(setup_parm)); - FsmEvent(&chanp->fi, EV_REDIR, NULL); + case (11): + num = csta->debug & DEB_DLOG_HEX; + csta->debug = *(unsigned int *) ic->parm.num; + csta->debug |= num; + HiSax_putstatus(cards[0].cs, "l1 debugging ", + "flags card %d set to %x", + csta->cardnr + 1, csta->debug); + printk(KERN_DEBUG "HiSax: l1 debugging flags card %d set to %x\n", + csta->cardnr + 1, csta->debug); break; - - /* protocol specific io commands */ - case (ISDN_CMD_PROT_IO): - for (st = csta->stlist; st; st = st->next) - if (st->protocol == (ic->arg & 0xFF)) - return(st->lli.l4l3_proto(st, ic)); - return(-EINVAL); + case (13): + csta->channel[0].d_st->l3.debug = *(unsigned int *) ic->parm.num; + csta->channel[1].d_st->l3.debug = *(unsigned int *) ic->parm.num; + HiSax_putstatus(cards[0].cs, "l3 debugging ", + "flags card %d set to %x\n", csta->cardnr + 1, + *(unsigned int *) ic->parm.num); + printk(KERN_DEBUG "HiSax: l3 debugging flags card %d set to %x\n", + csta->cardnr + 1, *(unsigned int *) ic->parm.num); break; + case (10): + i = *(unsigned int *) ic->parm.num; + return (set_channel_limit(csta, i)); default: if (csta->auxcmd) - return(csta->auxcmd(csta, ic)); - return(-EINVAL); + return (csta->auxcmd(csta, ic)); + printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", + (int) ic->arg); + return (-EINVAL); + } + break; + + case (ISDN_CMD_PROCEED): + chanp = csta->channel + ic->arg; + if (chanp->debug & 1) + link_debug(chanp, 1, "PROCEED"); + FsmEvent(&chanp->fi, EV_PROCEED, NULL); + break; + + case (ISDN_CMD_ALERT): + chanp = csta->channel + ic->arg; + if (chanp->debug & 1) + link_debug(chanp, 1, "ALERT"); + FsmEvent(&chanp->fi, EV_ALERT, NULL); + break; + + case (ISDN_CMD_REDIR): + chanp = csta->channel + ic->arg; + if (chanp->debug & 1) + link_debug(chanp, 1, "REDIR"); + memcpy(&chanp->setup, &ic->parm.setup, sizeof(setup_parm)); + FsmEvent(&chanp->fi, EV_REDIR, NULL); + break; + + /* protocol specific io commands */ + case (ISDN_CMD_PROT_IO): + for (st = csta->stlist; st; st = st->next) + if (st->protocol == (ic->arg & 0xFF)) + return (st->lli.l4l3_proto(st, ic)); + return (-EINVAL); + break; + default: + if (csta->auxcmd) + return (csta->auxcmd(csta, ic)); + return (-EINVAL); } return (0); } @@ -1747,7 +1747,7 @@ HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb) if (!csta) { printk(KERN_ERR - "HiSax: if_sendbuf called with invalid driverId!\n"); + "HiSax: if_sendbuf called with invalid driverId!\n"); return -ENODEV; } chanp = csta->channel + chan; @@ -1759,7 +1759,7 @@ HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb) if (len > MAX_DATA_SIZE) { link_debug(chanp, 1, "writebuf: packet too large (%d bytes)", len); printk(KERN_WARNING "HiSax_writebuf: packet too large (%d bytes) !\n", - len); + len); return -EINVAL; } if (len) { @@ -1771,7 +1771,7 @@ HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb) link_debug(chanp, 1, "writebuf: no buffers for %d bytes", len); return 0; } else if (chanp->debug & 0x800) - link_debug(chanp, 1, "writebuf %d/%d/%d", len, chanp->bcs->tx_cnt,MAX_DATA_MEM); + link_debug(chanp, 1, "writebuf %d/%d/%d", len, chanp->bcs->tx_cnt, MAX_DATA_MEM); nskb = skb_clone(skb, GFP_ATOMIC); if (nskb) { nskb->truesize = nskb->len; diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index c110f8679bab..b5edc0eeec06 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c @@ -3,7 +3,7 @@ * Author Karsten Keil * Copyright by Karsten Keil * by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -61,8 +61,8 @@ * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only) * 25 Teles S0Box p0=irq p1=iobase (from isapnp setup) * 26 AVM A1 PCMCIA (Fritz) p0=irq p1=iobase - * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter) - * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup) + * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter) + * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup) * 29 Siemens I-Surf p0=irq p1=iobase p2=memory (from isapnp setup) * 30 ACER P10 p0=irq p1=iobase (from isapnp setup) * 31 HST Saphir p0=irq p1=iobase @@ -88,200 +88,200 @@ const char *CardType[] = { "Teles PCMCIA", "ITK ix1-micro Rev.2", "Elsa PCMCIA", "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c", "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux", - "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI", + "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI", "Sedlbauer Speed Star (PCMCIA)", "AMD 7930", "NICCY", "S0Box", "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI", "Sedlbauer Speed Fax +", "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T", "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692", "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA", - "Hotplug", "Formula-n enter:now PCI a/b", + "Hotplug", "Formula-n enter:now PCI a/b", }; #ifdef CONFIG_HISAX_ELSA #define DEFAULT_CARD ISDN_CTYPE_ELSA -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_AVM_A1 #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_A1 -#define DEFAULT_CFG {10,0x340,0,0} +#define DEFAULT_CFG {10, 0x340, 0, 0} #endif #ifdef CONFIG_HISAX_AVM_A1_PCMCIA #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA -#define DEFAULT_CFG {11,0x170,0,0} +#define DEFAULT_CFG {11, 0x170, 0, 0} #endif #ifdef CONFIG_HISAX_FRITZPCI #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_16_3 #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_16_3 -#define DEFAULT_CFG {15,0x180,0,0} +#define DEFAULT_CFG {15, 0x180, 0, 0} #endif #ifdef CONFIG_HISAX_S0BOX #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_S0BOX -#define DEFAULT_CFG {7,0x378,0,0} +#define DEFAULT_CFG {7, 0x378, 0, 0} #endif #ifdef CONFIG_HISAX_16_0 #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_16_0 -#define DEFAULT_CFG {15,0xd0000,0xd80,0} +#define DEFAULT_CFG {15, 0xd0000, 0xd80, 0} #endif #ifdef CONFIG_HISAX_TELESPCI #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_TELESPCI -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_IX1MICROR2 #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2 -#define DEFAULT_CFG {5,0x390,0,0} +#define DEFAULT_CFG {5, 0x390, 0, 0} #endif #ifdef CONFIG_HISAX_DIEHLDIVA #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA -#define DEFAULT_CFG {0,0x0,0,0} +#define DEFAULT_CFG {0, 0x0, 0, 0} #endif #ifdef CONFIG_HISAX_ASUSCOM #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM -#define DEFAULT_CFG {5,0x200,0,0} +#define DEFAULT_CFG {5, 0x200, 0, 0} #endif #ifdef CONFIG_HISAX_TELEINT #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_TELEINT -#define DEFAULT_CFG {5,0x300,0,0} +#define DEFAULT_CFG {5, 0x300, 0, 0} #endif #ifdef CONFIG_HISAX_SEDLBAUER #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER -#define DEFAULT_CFG {11,0x270,0,0} +#define DEFAULT_CFG {11, 0x270, 0, 0} #endif #ifdef CONFIG_HISAX_SPORTSTER #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER -#define DEFAULT_CFG {7,0x268,0,0} +#define DEFAULT_CFG {7, 0x268, 0, 0} #endif #ifdef CONFIG_HISAX_MIC #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_MIC -#define DEFAULT_CFG {12,0x3e0,0,0} +#define DEFAULT_CFG {12, 0x3e0, 0, 0} #endif #ifdef CONFIG_HISAX_NETJET #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_NETJET_S -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_HFCS #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_TELES3C -#define DEFAULT_CFG {5,0x500,0,0} +#define DEFAULT_CFG {5, 0x500, 0, 0} #endif #ifdef CONFIG_HISAX_HFC_PCI #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_HFC_PCI -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_HFC_SX #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_HFC_SX -#define DEFAULT_CFG {5,0x2E0,0,0} +#define DEFAULT_CFG {5, 0x2E0, 0, 0} #endif #ifdef CONFIG_HISAX_NICCY #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_NICCY -#define DEFAULT_CFG {0,0x0,0,0} +#define DEFAULT_CFG {0, 0x0, 0, 0} #endif #ifdef CONFIG_HISAX_ISURF #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_ISURF -#define DEFAULT_CFG {5,0x100,0xc8000,0} +#define DEFAULT_CFG {5, 0x100, 0xc8000, 0} #endif #ifdef CONFIG_HISAX_HSTSAPHIR #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_HSTSAPHIR -#define DEFAULT_CFG {5,0x250,0,0} +#define DEFAULT_CFG {5, 0x250, 0, 0} #endif #ifdef CONFIG_HISAX_BKM_A4T #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_BKM_A4T -#define DEFAULT_CFG {0,0x0,0,0} +#define DEFAULT_CFG {0, 0x0, 0, 0} #endif #ifdef CONFIG_HISAX_SCT_QUADRO #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO -#define DEFAULT_CFG {1,0x0,0,0} +#define DEFAULT_CFG {1, 0x0, 0, 0} #endif #ifdef CONFIG_HISAX_GAZEL #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_GAZEL -#define DEFAULT_CFG {15,0x180,0,0} +#define DEFAULT_CFG {15, 0x180, 0, 0} #endif #ifdef CONFIG_HISAX_W6692 #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_W6692 -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_NETJET_U #undef DEFAULT_CARD #undef DEFAULT_CFG #define DEFAULT_CARD ISDN_CTYPE_NETJET_U -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif #ifdef CONFIG_HISAX_1TR6 @@ -306,21 +306,21 @@ const char *CardType[] = { #endif #ifndef DEFAULT_CARD #define DEFAULT_CARD 0 -#define DEFAULT_CFG {0,0,0,0} +#define DEFAULT_CFG {0, 0, 0, 0} #endif -#define FIRST_CARD { \ - DEFAULT_CARD, \ - DEFAULT_PROTO, \ - DEFAULT_CFG, \ - NULL, \ -} +#define FIRST_CARD { \ + DEFAULT_CARD, \ + DEFAULT_PROTO, \ + DEFAULT_CFG, \ + NULL, \ + } struct IsdnCard cards[HISAX_MAX_CARDS] = { FIRST_CARD, }; -#define HISAX_IDSIZE (HISAX_MAX_CARDS*8) +#define HISAX_IDSIZE (HISAX_MAX_CARDS * 8) static char HiSaxID[HISAX_IDSIZE] = { 0, }; static char *HiSax_id = HiSaxID; @@ -400,7 +400,7 @@ static void __init HiSaxVersion(void) } #ifndef MODULE -#define MAX_ARG (HISAX_MAX_CARDS*5) +#define MAX_ARG (HISAX_MAX_CARDS * 5) static int __init HiSax_setup(char *line) { int i, j, argc; @@ -441,7 +441,7 @@ static int __init HiSax_setup(char *line) } i++; } - if (str && *str) { + if (str && *str) { if (strlen(str) < HISAX_IDSIZE) strcpy(HiSaxID, str); else @@ -813,11 +813,11 @@ static irqreturn_t card_irq(int intno, void *dev_id) static int init_card(struct IsdnCardState *cs) { - int irq_cnt, cnt = 3, ret; + int irq_cnt, cnt = 3, ret; if (!cs->irq) { ret = cs->cardmsg(cs, CARD_INIT, NULL); - return(ret); + return (ret); } irq_cnt = cs->irq_cnt = 0; printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ], @@ -1142,12 +1142,12 @@ static int hisax_cs_setup(int cardnr, struct IsdnCard *card, /* init_card only handles interrupts which are not */ /* used here for the loadable driver */ switch (card->typ) { - case ISDN_CTYPE_DYNAMIC: - ret = 0; - break; - default: - ret = init_card(cs); - break; + case ISDN_CTYPE_DYNAMIC: + ret = 0; + break; + default: + ret = init_card(cs); + break; } if (ret) { closecard(cardnr); @@ -1203,10 +1203,10 @@ static int __ref checkcard(int cardnr, char *id, int *busy_flag, ret = hisax_cs_setup(cardnr, card, cs); goto out; - outf_cs: +outf_cs: kfree(cs); card->cs = NULL; - out: +out: return ret; } @@ -1256,8 +1256,8 @@ static int __init HiSax_inithardware(int *busy_flag) /* make sure we don't oops the module */ if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) { printk(KERN_WARNING - "HiSax: Card %s not installed !\n", - CardType[cards[i].typ]); + "HiSax: Card %s not installed !\n", + CardType[cards[i].typ]); } HiSax_shiftcards(i); nrcards--; @@ -1521,15 +1521,15 @@ static int __init HiSax_init(void) return -ENODEV; return 0; - out_tei: +out_tei: TeiFree(); - out_isdnl2: +out_isdnl2: Isdnl2Free(); - out_isdnl3: +out_isdnl3: Isdnl3Free(); - out_callc: +out_callc: CallcFree(); - out: +out: return retval; } @@ -1614,7 +1614,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], sprintf(id, "%s%d", name, i); nrcards++; retval = checkcard(i, id, NULL, hisax_d_if->owner, - hisax_setup_card_dynamic); + hisax_setup_card_dynamic); if (retval == 0) { // yuck cards[i].typ = 0; nrcards--; @@ -1637,7 +1637,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], hisax_d_if->ifc.l1l2 = hisax_d_l1l2; skb_queue_head_init(&hisax_d_if->erq); clear_bit(0, &hisax_d_if->ph_state); - + return 0; } @@ -1674,7 +1674,7 @@ static void hisax_bh(struct work_struct *work) pr = PH_DEACTIVATE | INDICATION; for (st = cs->stlist; st; st = st->next) st->l1.l1l2(st, pr, NULL); - + } } @@ -1764,7 +1764,7 @@ static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg) break; case PH_DATA | CONFIRM: bcs->tx_cnt -= (long)arg; - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += (long)arg; diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c index 780da9bda915..62a2945fa7f2 100644 --- a/drivers/isdn/hisax/diva.c +++ b/drivers/isdn/hisax/diva.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -27,7 +27,7 @@ static const char *Diva_revision = "$Revision: 1.33.2.6 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define DIVA_HSCX_DATA 0 @@ -89,7 +89,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -113,15 +113,15 @@ writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size static inline u_char memreadreg(unsigned long adr, u_char off) { - return(*((unsigned char *) - (((unsigned int *)adr) + off))); + return (*((unsigned char *) + (((unsigned int *)adr) + off))); } static inline void memwritereg(unsigned long adr, u_char off, u_char data) { register u_char *p; - + p = (unsigned char *)(((unsigned int *)adr) + off); *p = data; } @@ -131,7 +131,7 @@ memwritereg(unsigned long adr, u_char off, u_char data) static u_char ReadISAC(struct IsdnCardState *cs, u_char offset) { - return(readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset)); + return (readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset)); } static void @@ -155,23 +155,23 @@ WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) static u_char ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset) { - return (readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset+0x80)); + return (readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset + 0x80)); } static void WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value) { - writereg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset|0x80, value); + writereg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset | 0x80, value); } static void -ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.diva.isac_adr, cs->hw.diva.isac, 0x80, data, size); } static void -WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.diva.isac_adr, cs->hw.diva.isac, 0x80, data, size); } @@ -179,47 +179,47 @@ WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) static u_char ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) { - return(readreg(cs->hw.diva.hscx_adr, - cs->hw.diva.hscx, offset + (hscx ? 0x40 : 0))); + return (readreg(cs->hw.diva.hscx_adr, + cs->hw.diva.hscx, offset + (hscx ? 0x40 : 0))); } static void WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) { writereg(cs->hw.diva.hscx_adr, - cs->hw.diva.hscx, offset + (hscx ? 0x40 : 0), value); + cs->hw.diva.hscx, offset + (hscx ? 0x40 : 0), value); } static u_char MemReadISAC_IPAC(struct IsdnCardState *cs, u_char offset) { - return (memreadreg(cs->hw.diva.cfg_reg, offset+0x80)); + return (memreadreg(cs->hw.diva.cfg_reg, offset + 0x80)); } static void MemWriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value) { - memwritereg(cs->hw.diva.cfg_reg, offset|0x80, value); + memwritereg(cs->hw.diva.cfg_reg, offset | 0x80, value); } static void -MemReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +MemReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { - while(size--) + while (size--) *data++ = memreadreg(cs->hw.diva.cfg_reg, 0x80); } static void -MemWriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +MemWriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { - while(size--) + while (size--) memwritereg(cs->hw.diva.cfg_reg, 0x80, *data++); } static u_char MemReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) { - return(memreadreg(cs->hw.diva.cfg_reg, offset + (hscx ? 0x40 : 0))); + return (memreadreg(cs->hw.diva.cfg_reg, offset + (hscx ? 0x40 : 0))); } static void @@ -242,47 +242,47 @@ MemWriteISAC_IPACX(struct IsdnCardState *cs, u_char offset, u_char value) } static void -MemReadISACfifo_IPACX(struct IsdnCardState *cs, u_char * data, int size) +MemReadISACfifo_IPACX(struct IsdnCardState *cs, u_char *data, int size) { - while(size--) + while (size--) *data++ = memreadreg(cs->hw.diva.cfg_reg, 0); } static void -MemWriteISACfifo_IPACX(struct IsdnCardState *cs, u_char * data, int size) +MemWriteISACfifo_IPACX(struct IsdnCardState *cs, u_char *data, int size) { - while(size--) + while (size--) memwritereg(cs->hw.diva.cfg_reg, 0, *data++); } static u_char MemReadHSCX_IPACX(struct IsdnCardState *cs, int hscx, u_char offset) { - return(memreadreg(cs->hw.diva.cfg_reg, offset + - (hscx ? IPACX_OFF_B2 : IPACX_OFF_B1))); + return (memreadreg(cs->hw.diva.cfg_reg, offset + + (hscx ? IPACX_OFF_B2 : IPACX_OFF_B1))); } static void MemWriteHSCX_IPACX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) { - memwritereg(cs->hw.diva.cfg_reg, offset + - (hscx ? IPACX_OFF_B2 : IPACX_OFF_B1), value); + memwritereg(cs->hw.diva.cfg_reg, offset + + (hscx ? IPACX_OFF_B2 : IPACX_OFF_B1), value); } /* * fast interrupt HSCX stuff goes here */ -#define READHSCX(cs, nr, reg) readreg(cs->hw.diva.hscx_adr, \ - cs->hw.diva.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.diva.hscx_adr, \ - cs->hw.diva.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.diva.hscx_adr, \ + cs->hw.diva.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.diva.hscx_adr, \ + cs->hw.diva.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.diva.hscx_adr, \ - cs->hw.diva.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.diva.hscx_adr, \ + cs->hw.diva.hscx, (nr ? 0x40 : 0), ptr, cnt) #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.diva.hscx_adr, \ - cs->hw.diva.hscx, (nr ? 0x40 : 0), ptr, cnt) + cs->hw.diva.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -292,7 +292,7 @@ diva_interrupt(int intno, void *dev_id) struct IsdnCardState *cs = dev_id; u_char val, sval; u_long flags; - int cnt=5; + int cnt = 5; spin_lock_irqsave(&cs->lock, flags); while (((sval = bytein(cs->hw.diva.ctrl)) & DIVA_IRQ_REQ) && cnt) { @@ -320,9 +320,9 @@ static irqreturn_t diva_irq_ipac_isa(int intno, void *dev_id) { struct IsdnCardState *cs = dev_id; - u_char ista,val; + u_char ista, val; u_long flags; - int icnt=5; + int icnt = 5; spin_lock_irqsave(&cs->lock, flags); ista = readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, IPAC_ISTA); @@ -436,8 +436,8 @@ Memhscx_fill_fifo(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; int more, count, cnt; - int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32; - u_char *ptr,*p; + int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags) ? 64 : 32; + u_char *ptr, *p; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "hscx_fill_fifo"); @@ -459,9 +459,9 @@ Memhscx_fill_fifo(struct BCState *bcs) skb_pull(bcs->tx_skb, count); bcs->tx_cnt -= count; bcs->hw.hscx.count += count; - while(cnt--) + while (cnt--) memwritereg(cs->hw.diva.cfg_reg, bcs->hw.hscx.hscx ? 0x40 : 0, - *p++); + *p++); MemWriteHSCXCMDR(cs, bcs->hw.hscx.hscx, more ? 0x8 : 0xa); if (cs->debug & L1_DEB_HSCX_FIFO) { char *t = bcs->blog; @@ -479,7 +479,7 @@ Memhscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) u_char r; struct BCState *bcs = cs->bcs + hscx; struct sk_buff *skb; - int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32; + int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags) ? 64 : 32; int count; if (!test_bit(BC_FLG_INIT, &bcs->Flag)) @@ -501,7 +501,7 @@ Memhscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) MemWriteHSCXCMDR(cs, hscx, 0x80); } else { count = MemReadHSCX(cs, hscx, HSCX_RBCL) & ( - test_bit(HW_IPAC, &cs->HW_Flags)? 0x3f: 0x1f); + test_bit(HW_IPAC, &cs->HW_Flags) ? 0x3f : 0x1f); if (count == 0) count = fifo_size; Memhscx_empty_fifo(bcs, count); @@ -539,8 +539,8 @@ Memhscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) Memhscx_fill_fifo(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; @@ -548,7 +548,7 @@ Memhscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) schedule_event(bcs, B_ACKPENDING); } dev_kfree_skb_irq(bcs->tx_skb); - bcs->hw.hscx.count = 0; + bcs->hw.hscx.count = 0; bcs->tx_skb = NULL; } } @@ -578,7 +578,7 @@ Memhscx_int_main(struct IsdnCardState *cs, u_char val) Memhscx_fill_fifo(bcs); else { /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. + * restart transmitting the whole frame. */ if (bcs->tx_skb) { skb_push(bcs->tx_skb, bcs->hw.hscx.count); @@ -605,7 +605,7 @@ Memhscx_int_main(struct IsdnCardState *cs, u_char val) Memhscx_fill_fifo(bcs); else { /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. + * restart transmitting the whole frame. */ if (bcs->tx_skb) { skb_push(bcs->tx_skb, bcs->hw.hscx.count); @@ -631,8 +631,8 @@ static irqreturn_t diva_irq_ipac_pci(int intno, void *dev_id) { struct IsdnCardState *cs = dev_id; - u_char ista,val; - int icnt=5; + u_char ista, val; + int icnt = 5; u_char *cfg; u_long flags; @@ -693,11 +693,11 @@ diva_irq_ipacx_pci(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); cfg = (u_char *) cs->hw.diva.pci_cfg; val = *cfg; - if (!(val &PITA_INT0_STATUS)) { + if (!(val & PITA_INT0_STATUS)) { spin_unlock_irqrestore(&cs->lock, flags); return IRQ_NONE; // other shared IRQ } - interrupt_ipacx(cs); // handler for chip + interrupt_ipacx(cs); // handler for chip *cfg = PITA_INT0_STATUS; // Reset PLX interrupt spin_unlock_irqrestore(&cs->lock, flags); return IRQ_HANDLED; @@ -708,11 +708,11 @@ release_io_diva(struct IsdnCardState *cs) { int bytecnt; - if ((cs->subtyp == DIVA_IPAC_PCI) || - (cs->subtyp == DIVA_IPACX_PCI) ) { + if ((cs->subtyp == DIVA_IPAC_PCI) || + (cs->subtyp == DIVA_IPACX_PCI)) { u_int *cfg = (unsigned int *)cs->hw.diva.pci_cfg; - *cfg = 0; /* disable INT0/1 */ + *cfg = 0; /* disable INT0/1 */ *cfg = 2; /* reset pending INT0 */ if (cs->hw.diva.cfg_reg) iounmap((void *)cs->hw.diva.cfg_reg); @@ -761,7 +761,7 @@ reset_diva(struct IsdnCardState *cs) writereg(cs->hw.diva.isac_adr, cs->hw.diva.isac, IPAC_MASK, 0xc0); } else if (cs->subtyp == DIVA_IPAC_PCI) { unsigned int *ireg = (unsigned int *)(cs->hw.diva.pci_cfg + - PITA_MISC_REG); + PITA_MISC_REG); *ireg = PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE; mdelay(10); *ireg = PITA_PARA_MPX_MODE; @@ -769,7 +769,7 @@ reset_diva(struct IsdnCardState *cs) memwritereg(cs->hw.diva.cfg_reg, IPAC_MASK, 0xc0); } else if (cs->subtyp == DIVA_IPACX_PCI) { unsigned int *ireg = (unsigned int *)(cs->hw.diva.pci_cfg + - PITA_MISC_REG); + PITA_MISC_REG); *ireg = PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE; mdelay(10); *ireg = PITA_PARA_MPX_MODE | PITA_SER_SOFTRESET; @@ -802,7 +802,7 @@ diva_led_handler(struct IsdnCardState *cs) if ((cs->subtyp == DIVA_IPAC_ISA) || (cs->subtyp == DIVA_IPAC_PCI) || - (cs->subtyp == DIVA_IPACX_PCI) ) + (cs->subtyp == DIVA_IPACX_PCI)) return; del_timer(&cs->hw.diva.tl); if (cs->hw.diva.status & DIVA_ASSIGN) @@ -822,7 +822,7 @@ diva_led_handler(struct IsdnCardState *cs) blink = 500; } else cs->hw.diva.ctrl_reg &= ~((DIVA_ISA == cs->subtyp) ? - DIVA_ISA_LED_B : DIVA_PCI_LED_B); + DIVA_ISA_LED_B : DIVA_PCI_LED_B); byteout(cs->hw.diva.ctrl, cs->hw.diva.ctrl_reg); if (blink) { @@ -839,69 +839,69 @@ Diva_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_diva(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_diva(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - reset_diva(cs); - if (cs->subtyp == DIVA_IPACX_PCI) { - ireg = (unsigned int *)cs->hw.diva.pci_cfg; - *ireg = PITA_INT0_ENABLE; - init_ipacx(cs, 3); // init chip and enable interrupts - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - } - if (cs->subtyp == DIVA_IPAC_PCI) { - ireg = (unsigned int *)cs->hw.diva.pci_cfg; - *ireg = PITA_INT0_ENABLE; - } - inithscxisac(cs, 3); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_diva(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_diva(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + reset_diva(cs); + if (cs->subtyp == DIVA_IPACX_PCI) { + ireg = (unsigned int *)cs->hw.diva.pci_cfg; + *ireg = PITA_INT0_ENABLE; + init_ipacx(cs, 3); // init chip and enable interrupts spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); - case (MDL_REMOVE | REQUEST): - cs->hw.diva.status = 0; - break; - case (MDL_ASSIGN | REQUEST): - cs->hw.diva.status |= DIVA_ASSIGN; - break; - case MDL_INFO_SETUP: - if ((long)arg) - cs->hw.diva.status |= 0x0200; - else - cs->hw.diva.status |= 0x0100; - break; - case MDL_INFO_CONN: - if ((long)arg) - cs->hw.diva.status |= 0x2000; - else - cs->hw.diva.status |= 0x1000; - break; - case MDL_INFO_REL: - if ((long)arg) { - cs->hw.diva.status &= ~0x2000; - cs->hw.diva.status &= ~0x0200; - } else { - cs->hw.diva.status &= ~0x1000; - cs->hw.diva.status &= ~0x0100; - } - break; + return (0); + } + if (cs->subtyp == DIVA_IPAC_PCI) { + ireg = (unsigned int *)cs->hw.diva.pci_cfg; + *ireg = PITA_INT0_ENABLE; + } + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); + case (MDL_REMOVE | REQUEST): + cs->hw.diva.status = 0; + break; + case (MDL_ASSIGN | REQUEST): + cs->hw.diva.status |= DIVA_ASSIGN; + break; + case MDL_INFO_SETUP: + if ((long)arg) + cs->hw.diva.status |= 0x0200; + else + cs->hw.diva.status |= 0x0100; + break; + case MDL_INFO_CONN: + if ((long)arg) + cs->hw.diva.status |= 0x2000; + else + cs->hw.diva.status |= 0x1000; + break; + case MDL_INFO_REL: + if ((long)arg) { + cs->hw.diva.status &= ~0x2000; + cs->hw.diva.status &= ~0x0200; + } else { + cs->hw.diva.status &= ~0x1000; + cs->hw.diva.status &= ~0x0100; + } + break; } - if ((cs->subtyp != DIVA_IPAC_ISA) && + if ((cs->subtyp != DIVA_IPAC_ISA) && (cs->subtyp != DIVA_IPAC_PCI) && (cs->subtyp != DIVA_IPACX_PCI)) { - spin_lock_irqsave(&cs->lock, flags); + spin_lock_irqsave(&cs->lock, flags); diva_led_handler(cs); spin_unlock_irqrestore(&cs->lock, flags); } - return(0); + return (0); } static int __devinit setup_diva_common(struct IsdnCardState *cs) @@ -915,21 +915,21 @@ static int __devinit setup_diva_common(struct IsdnCardState *cs) bytecnt = 32; printk(KERN_INFO - "Diva: %s card configured at %#lx IRQ %d\n", - (cs->subtyp == DIVA_PCI) ? "PCI" : - (cs->subtyp == DIVA_ISA) ? "ISA" : - (cs->subtyp == DIVA_IPAC_ISA) ? "IPAC ISA" : - (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", - cs->hw.diva.cfg_reg, cs->irq); - if ((cs->subtyp == DIVA_IPAC_PCI) || - (cs->subtyp == DIVA_IPACX_PCI) || - (cs->subtyp == DIVA_PCI) ) + "Diva: %s card configured at %#lx IRQ %d\n", + (cs->subtyp == DIVA_PCI) ? "PCI" : + (cs->subtyp == DIVA_ISA) ? "ISA" : + (cs->subtyp == DIVA_IPAC_ISA) ? "IPAC ISA" : + (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", + cs->hw.diva.cfg_reg, cs->irq); + if ((cs->subtyp == DIVA_IPAC_PCI) || + (cs->subtyp == DIVA_IPACX_PCI) || + (cs->subtyp == DIVA_PCI)) printk(KERN_INFO "Diva: %s space at %#lx\n", - (cs->subtyp == DIVA_PCI) ? "PCI" : - (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", - cs->hw.diva.pci_cfg); + (cs->subtyp == DIVA_PCI) ? "PCI" : + (cs->subtyp == DIVA_IPAC_PCI) ? "IPAC PCI" : "IPACX PCI", + cs->hw.diva.pci_cfg); if ((cs->subtyp != DIVA_IPAC_PCI) && - (cs->subtyp != DIVA_IPACX_PCI) ) { + (cs->subtyp != DIVA_IPACX_PCI)) { if (!request_region(cs->hw.diva.cfg_reg, bytecnt, "diva isdn")) { printk(KERN_WARNING "HiSax: %s config port %lx-%lx already in use\n", @@ -973,8 +973,8 @@ static int __devinit setup_diva_common(struct IsdnCardState *cs) cs->BC_Write_Reg = &MemWriteHSCX_IPACX; cs->BC_Send_Data = NULL; // function located in ipacx module cs->irq_func = &diva_irq_ipacx_pci; - printk(KERN_INFO "Diva: IPACX Design Id: %x\n", - MemReadISAC_IPACX(cs, IPACX_ID) &0x3F); + printk(KERN_INFO "Diva: IPACX Design Id: %x\n", + MemReadISAC_IPACX(cs, IPACX_ID) & 0x3F); } else { /* DIVA 2.0 */ cs->hw.diva.tl.function = (void *) diva_led_handler; cs->hw.diva.tl.data = (long) cs; @@ -987,7 +987,7 @@ static int __devinit setup_diva_common(struct IsdnCardState *cs) ISACVersion(cs, "Diva:"); if (HscxVersion(cs, "Diva:")) { printk(KERN_WARNING - "Diva: wrong HSCX versions check IO address\n"); + "Diva: wrong HSCX versions check IO address\n"); release_io_diva(cs); return (0); } @@ -1008,9 +1008,9 @@ static int __devinit setup_diva_isa(struct IsdnCard *card) cs->hw.diva.ctrl_reg = 0; cs->hw.diva.cfg_reg = card->para[1]; val = readreg(cs->hw.diva.cfg_reg + DIVA_IPAC_ADR, - cs->hw.diva.cfg_reg + DIVA_IPAC_DATA, IPAC_ID); + cs->hw.diva.cfg_reg + DIVA_IPAC_DATA, IPAC_ID); printk(KERN_INFO "Diva: IPAC version %x\n", val); - if ((val == 1) || (val==2)) { + if ((val == 1) || (val == 2)) { cs->subtyp = DIVA_IPAC_ISA; cs->hw.diva.ctrl = 0; cs->hw.diva.isac = card->para[1] + DIVA_IPAC_DATA; @@ -1043,22 +1043,22 @@ static int __devinit setup_diva_isa(struct IsdnCard *card) #ifdef __ISAPNP__ static struct isapnp_device_id diva_ids[] __devinitdata = { { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), - ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), + ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), (unsigned long) "Diva picola" }, { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), - ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x51), + ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x51), (unsigned long) "Diva picola" }, { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), - ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), + ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), (unsigned long) "Diva 2.0" }, { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), - ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x71), + ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x71), (unsigned long) "Diva 2.0" }, { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), - ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), + ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), (unsigned long) "Diva 2.01" }, { ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), - ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0xA1), + ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0xA1), (unsigned long) "Diva 2.01" }, { 0, } }; @@ -1074,30 +1074,30 @@ static int __devinit setup_diva_isapnp(struct IsdnCard *card) if (!isapnp_present()) return (-1); /* card not found; continue search */ - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); - pnp_disable_dev(pnp_d); - return(0); + card->para[0], card->para[1]); + pnp_disable_dev(pnp_d); + return (0); } cs->hw.diva.cfg_reg = card->para[1]; cs->irq = card->para[0]; @@ -1129,12 +1129,12 @@ static int __devinit setup_diva_isapnp(struct IsdnCard *card) return (1); /* card found */ } else { printk(KERN_ERR "Diva PnP: PnP error card found, no device\n"); - return(0); + return (0); } } ipid++; - pnp_c=NULL; - } + pnp_c = NULL; + } return (-1); /* card not found; continue search */ } @@ -1160,23 +1160,23 @@ static int __devinit setup_diva_pci(struct IsdnCard *card) cs->subtyp = 0; if ((dev_diva = hisax_find_pci_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) { + PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) { if (pci_enable_device(dev_diva)) - return(0); + return (0); cs->subtyp = DIVA_PCI; cs->irq = dev_diva->irq; cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2); } else if ((dev_diva_u = hisax_find_pci_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { + PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { if (pci_enable_device(dev_diva_u)) - return(0); + return (0); cs->subtyp = DIVA_PCI; cs->irq = dev_diva_u->irq; cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2); } else if ((dev_diva201 = hisax_find_pci_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { + PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { if (pci_enable_device(dev_diva201)) - return(0); + return (0); cs->subtyp = DIVA_IPAC_PCI; cs->irq = dev_diva201->irq; cs->hw.diva.pci_cfg = @@ -1184,9 +1184,9 @@ static int __devinit setup_diva_pci(struct IsdnCard *card) cs->hw.diva.cfg_reg = (ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096); } else if ((dev_diva202 = hisax_find_pci_device(PCI_VENDOR_ID_EICON, - PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { + PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { if (pci_enable_device(dev_diva202)) - return(0); + return (0); cs->subtyp = DIVA_IPACX_PCI; cs->irq = dev_diva202->irq; cs->hw.diva.pci_cfg = @@ -1200,18 +1200,18 @@ static int __devinit setup_diva_pci(struct IsdnCard *card) if (!cs->irq) { printk(KERN_WARNING "Diva: No IRQ for PCI card found\n"); iounmap_diva(cs); - return(0); + return (0); } if (!cs->hw.diva.cfg_reg) { printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n"); iounmap_diva(cs); - return(0); + return (0); } cs->irq_flags |= IRQF_SHARED; if ((cs->subtyp == DIVA_IPAC_PCI) || - (cs->subtyp == DIVA_IPACX_PCI) ) { + (cs->subtyp == DIVA_IPACX_PCI)) { cs->hw.diva.ctrl = 0; cs->hw.diva.isac = 0; cs->hw.diva.hscx = 0; @@ -1248,7 +1248,7 @@ setup_diva(struct IsdnCard *card) strcpy(tmp, Diva_revision); printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_DIEHLDIVA) - return(0); + return (0); cs->hw.diva.status = 0; rc = setup_diva_isa(card); @@ -1276,7 +1276,7 @@ setup_diva(struct IsdnCard *card) ready: if (!have_card) { printk(KERN_WARNING "Diva: No ISA, ISAPNP or PCI card found\n"); - return(0); + return (0); } return setup_diva_common(card->cs); diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c index 5d9d338814aa..64ba26a4afe6 100644 --- a/drivers/isdn/hisax/elsa.c +++ b/drivers/isdn/hisax/elsa.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -34,14 +34,14 @@ static const char *Elsa_revision = "$Revision: 2.32.2.4 $"; static const char *Elsa_Types[] = {"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro", - "PCMCIA", "QS 1000", "QS 3000", "Microlink PCI", "QS 3000 PCI", + "PCMCIA", "QS 1000", "QS 3000", "Microlink PCI", "QS 3000 PCI", "PCMCIA-IPAC" }; static const char *ITACVer[] = {"?0?", "?1?", "?2?", "?3?", "?4?", "V2.2", "B1", "A1"}; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define ELSA_ISAC 0 @@ -113,25 +113,25 @@ static const char *ITACVer[] = #if ARCOFI_USE static struct arcofi_msg ARCOFI_XOP_F = - {NULL,0,2,{0xa1,0x3f,0,0,0,0,0,0,0,0}}; /* Normal OP */ +{NULL,0,2,{0xa1,0x3f,0,0,0,0,0,0,0,0}}; /* Normal OP */ static struct arcofi_msg ARCOFI_XOP_1 = - {&ARCOFI_XOP_F,0,2,{0xa1,0x31,0,0,0,0,0,0,0,0}}; /* PWR UP */ -static struct arcofi_msg ARCOFI_SOP_F = - {&ARCOFI_XOP_1,0,10,{0xa1,0x1f,0x00,0x50,0x10,0x00,0x00,0x80,0x02,0x12}}; +{&ARCOFI_XOP_F,0,2,{0xa1,0x31,0,0,0,0,0,0,0,0}}; /* PWR UP */ +static struct arcofi_msg ARCOFI_SOP_F = +{&ARCOFI_XOP_1,0,10,{0xa1,0x1f,0x00,0x50,0x10,0x00,0x00,0x80,0x02,0x12}}; static struct arcofi_msg ARCOFI_COP_9 = - {&ARCOFI_SOP_F,0,10,{0xa1,0x29,0x80,0xcb,0xe9,0x88,0x00,0xc8,0xd8,0x80}}; /* RX */ +{&ARCOFI_SOP_F,0,10,{0xa1,0x29,0x80,0xcb,0xe9,0x88,0x00,0xc8,0xd8,0x80}}; /* RX */ static struct arcofi_msg ARCOFI_COP_8 = - {&ARCOFI_COP_9,0,10,{0xa1,0x28,0x49,0x31,0x8,0x13,0x6e,0x88,0x2a,0x61}}; /* TX */ +{&ARCOFI_COP_9,0,10,{0xa1,0x28,0x49,0x31,0x8,0x13,0x6e,0x88,0x2a,0x61}}; /* TX */ static struct arcofi_msg ARCOFI_COP_7 = - {&ARCOFI_COP_8,0,4,{0xa1,0x27,0x80,0x80,0,0,0,0,0,0}}; /* GZ */ +{&ARCOFI_COP_8,0,4,{0xa1,0x27,0x80,0x80,0,0,0,0,0,0}}; /* GZ */ static struct arcofi_msg ARCOFI_COP_6 = - {&ARCOFI_COP_7,0,6,{0xa1,0x26,0,0,0x82,0x7c,0,0,0,0}}; /* GRL GRH */ +{&ARCOFI_COP_7,0,6,{0xa1,0x26,0,0,0x82,0x7c,0,0,0,0}}; /* GRL GRH */ static struct arcofi_msg ARCOFI_COP_5 = - {&ARCOFI_COP_6,0,4,{0xa1,0x25,0xbb,0x4a,0,0,0,0,0,0}}; /* GTX */ +{&ARCOFI_COP_6,0,4,{0xa1,0x25,0xbb,0x4a,0,0,0,0,0,0}}; /* GTX */ static struct arcofi_msg ARCOFI_VERSION = - {NULL,1,2,{0xa0,0,0,0,0,0,0,0,0,0}}; +{NULL,1,2,{0xa0,0,0,0,0,0,0,0,0,0}}; static struct arcofi_msg ARCOFI_XOP_0 = - {NULL,0,2,{0xa1,0x30,0,0,0,0,0,0,0,0}}; /* PWR Down */ +{NULL,0,2,{0xa1,0x30,0,0,0,0,0,0,0,0}}; /* PWR Down */ static void set_arcofi(struct IsdnCardState *cs, int bc); @@ -149,7 +149,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -164,7 +164,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -185,13 +185,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size); } @@ -199,23 +199,23 @@ WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) static u_char ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset) { - return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset+0x80)); + return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset + 0x80)); } static void WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value) { - writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset|0x80, value); + writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset | 0x80, value); } static void -ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size); } static void -WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size); } @@ -267,16 +267,16 @@ TimerRun(struct IsdnCardState *cs) * fast interrupt HSCX stuff goes here */ -#define READHSCX(cs, nr, reg) readreg(cs->hw.elsa.ale, \ - cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.elsa.ale, \ - cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.elsa.ale, \ + cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.elsa.ale, \ + cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.elsa.ale, \ - cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.elsa.ale, \ + cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.elsa.ale, \ - cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.elsa.ale, \ + cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -286,11 +286,11 @@ elsa_interrupt(int intno, void *dev_id) struct IsdnCardState *cs = dev_id; u_long flags; u_char val; - int icnt=5; + int icnt = 5; if ((cs->typ == ISDN_CTYPE_ELSA_PCMCIA) && (*cs->busy_flag == 1)) { - /* The card tends to generate interrupts while being removed - causing us to just crash the kernel. bad. */ + /* The card tends to generate interrupts while being removed + causing us to just crash the kernel. bad. */ printk(KERN_WARNING "Elsa: card not available!\n"); return IRQ_NONE; } @@ -299,18 +299,18 @@ elsa_interrupt(int intno, void *dev_id) if (cs->hw.elsa.MFlag) { val = serial_inp(cs, UART_IIR); if (!(val & UART_IIR_NO_INT)) { - debugl1(cs,"IIR %02x", val); + debugl1(cs, "IIR %02x", val); rs_interrupt_elsa(cs); } } #endif val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40); - Start_HSCX: +Start_HSCX: if (val) { hscx_int_main(cs, val); } val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) { isac_interrupt(cs, val); } @@ -364,8 +364,8 @@ elsa_interrupt_ipac(int intno, void *dev_id) { struct IsdnCardState *cs = dev_id; u_long flags; - u_char ista,val; - int icnt=5; + u_char ista, val; + int icnt = 5; spin_lock_irqsave(&cs->lock, flags); if (cs->subtyp == ELSA_QS1000PCI || cs->subtyp == ELSA_QS3000PCI) { @@ -379,7 +379,7 @@ elsa_interrupt_ipac(int intno, void *dev_id) if (cs->hw.elsa.MFlag) { val = serial_inp(cs, UART_IIR); if (!(val & UART_IIR_NO_INT)) { - debugl1(cs,"IIR %02x", val); + debugl1(cs, "IIR %02x", val); rs_interrupt_elsa(cs); } } @@ -444,13 +444,13 @@ release_io_elsa(struct IsdnCardState *cs) writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff); release_region(cs->hw.elsa.cfg, 0x80); } - if (cs->subtyp == ELSA_PCMCIA_IPAC) { + if (cs->subtyp == ELSA_PCMCIA_IPAC) { writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff); - } + } if ((cs->subtyp == ELSA_PCFPRO) || - (cs->subtyp == ELSA_QS3000) || - (cs->subtyp == ELSA_PCF) || - (cs->subtyp == ELSA_QS3000PCI)) { + (cs->subtyp == ELSA_QS3000) || + (cs->subtyp == ELSA_PCF) || + (cs->subtyp == ELSA_QS3000PCI)) { bytecnt = 16; #if ARCOFI_USE release_modem(cs); @@ -521,84 +521,84 @@ check_arcofi(struct IsdnCardState *cs) u_char *p; if (!cs->dc.isac.mon_tx) - if (!(cs->dc.isac.mon_tx=kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { + if (!(cs->dc.isac.mon_tx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { if (cs->debug & L1_DEB_WARN) debugl1(cs, "ISAC MON TX out of buffers!"); - return(0); + return (0); } cs->dc.isac.arcofi_bc = 0; arcofi_fsm(cs, ARCOFI_START, &ARCOFI_VERSION); interruptible_sleep_on(&cs->dc.isac.arcofi_wait); if (!test_and_clear_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags)) { - debugl1(cs, "Arcofi response received %d bytes", cs->dc.isac.mon_rxp); - p = cs->dc.isac.mon_rx; - t = tmp; - t += sprintf(tmp, "Arcofi data"); - QuickHex(t, p, cs->dc.isac.mon_rxp); - debugl1(cs, tmp); - if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) { - switch(cs->dc.isac.mon_rx[1]) { - case 0x80: - debugl1(cs, "Arcofi 2160 detected"); - arcofi_present = 1; - break; - case 0x82: - debugl1(cs, "Arcofi 2165 detected"); - arcofi_present = 2; - break; - case 0x84: - debugl1(cs, "Arcofi 2163 detected"); - arcofi_present = 3; - break; - default: - debugl1(cs, "unknown Arcofi response"); - break; - } - } else - debugl1(cs, "undefined Monitor response"); - cs->dc.isac.mon_rxp = 0; + debugl1(cs, "Arcofi response received %d bytes", cs->dc.isac.mon_rxp); + p = cs->dc.isac.mon_rx; + t = tmp; + t += sprintf(tmp, "Arcofi data"); + QuickHex(t, p, cs->dc.isac.mon_rxp); + debugl1(cs, tmp); + if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) { + switch (cs->dc.isac.mon_rx[1]) { + case 0x80: + debugl1(cs, "Arcofi 2160 detected"); + arcofi_present = 1; + break; + case 0x82: + debugl1(cs, "Arcofi 2165 detected"); + arcofi_present = 2; + break; + case 0x84: + debugl1(cs, "Arcofi 2163 detected"); + arcofi_present = 3; + break; + default: + debugl1(cs, "unknown Arcofi response"); + break; + } + } else + debugl1(cs, "undefined Monitor response"); + cs->dc.isac.mon_rxp = 0; } else if (cs->dc.isac.mon_tx) { debugl1(cs, "Arcofi not detected"); } if (arcofi_present) { - if (cs->subtyp==ELSA_QS1000) { + if (cs->subtyp == ELSA_QS1000) { cs->subtyp = ELSA_QS3000; printk(KERN_INFO - "Elsa: %s detected modem at 0x%lx\n", - Elsa_Types[cs->subtyp], - cs->hw.elsa.base+8); + "Elsa: %s detected modem at 0x%lx\n", + Elsa_Types[cs->subtyp], + cs->hw.elsa.base + 8); release_region(cs->hw.elsa.base, 8); if (!request_region(cs->hw.elsa.base, 16, "elsa isdn modem")) { printk(KERN_WARNING - "HiSax: %s config port %lx-%lx already in use\n", - Elsa_Types[cs->subtyp], - cs->hw.elsa.base + 8, - cs->hw.elsa.base + 16); + "HiSax: %s config port %lx-%lx already in use\n", + Elsa_Types[cs->subtyp], + cs->hw.elsa.base + 8, + cs->hw.elsa.base + 16); } - } else if (cs->subtyp==ELSA_PCC16) { + } else if (cs->subtyp == ELSA_PCC16) { cs->subtyp = ELSA_PCF; printk(KERN_INFO - "Elsa: %s detected modem at 0x%lx\n", - Elsa_Types[cs->subtyp], - cs->hw.elsa.base+8); + "Elsa: %s detected modem at 0x%lx\n", + Elsa_Types[cs->subtyp], + cs->hw.elsa.base + 8); release_region(cs->hw.elsa.base, 8); if (!request_region(cs->hw.elsa.base, 16, "elsa isdn modem")) { printk(KERN_WARNING - "HiSax: %s config port %lx-%lx already in use\n", - Elsa_Types[cs->subtyp], - cs->hw.elsa.base + 8, - cs->hw.elsa.base + 16); + "HiSax: %s config port %lx-%lx already in use\n", + Elsa_Types[cs->subtyp], + cs->hw.elsa.base + 8, + cs->hw.elsa.base + 16); } } else printk(KERN_INFO - "Elsa: %s detected modem at 0x%lx\n", - Elsa_Types[cs->subtyp], - cs->hw.elsa.base+8); + "Elsa: %s detected modem at 0x%lx\n", + Elsa_Types[cs->subtyp], + cs->hw.elsa.base + 8); arcofi_fsm(cs, ARCOFI_START, &ARCOFI_XOP_0); interruptible_sleep_on(&cs->dc.isac.arcofi_wait); - return(1); + return (1); } - return(0); + return (0); } #endif /* ARCOFI_USE */ @@ -627,7 +627,7 @@ elsa_led_handler(struct IsdnCardState *cs) cs->hw.elsa.ctrl_reg &= ~ELSA_LINE_LED; if ((cs->subtyp == ELSA_QS1000PCI) || - (cs->subtyp == ELSA_QS3000PCI)) { + (cs->subtyp == ELSA_QS3000PCI)) { u_char led = 0xff; if (cs->hw.elsa.ctrl_reg & ELSA_LINE_LED) led ^= ELSA_IPAC_LINE_LED; @@ -650,111 +650,111 @@ Elsa_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_elsa(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_elsa(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + cs->debug |= L1_DEB_IPAC; + reset_elsa(cs); + inithscxisac(cs, 1); + if ((cs->subtyp == ELSA_QS1000) || + (cs->subtyp == ELSA_QS3000)) + { + byteout(cs->hw.elsa.timer, 0); + } + if (cs->hw.elsa.trig) + byteout(cs->hw.elsa.trig, 0xff); + inithscxisac(cs, 2); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + if ((cs->subtyp == ELSA_PCMCIA) || + (cs->subtyp == ELSA_PCMCIA_IPAC) || + (cs->subtyp == ELSA_QS1000PCI)) { + return (0); + } else if (cs->subtyp == ELSA_QS3000PCI) { + ret = 0; + } else { spin_lock_irqsave(&cs->lock, flags); - reset_elsa(cs); + cs->hw.elsa.counter = 0; + cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT; + cs->hw.elsa.status |= ELIRQF_TIMER_AKTIV; + byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); + byteout(cs->hw.elsa.timer, 0); spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_elsa(cs); - return(0); - case CARD_INIT: + msleep(110); spin_lock_irqsave(&cs->lock, flags); - cs->debug |= L1_DEB_IPAC; - reset_elsa(cs); - inithscxisac(cs, 1); - if ((cs->subtyp == ELSA_QS1000) || - (cs->subtyp == ELSA_QS3000)) - { - byteout(cs->hw.elsa.timer, 0); - } - if (cs->hw.elsa.trig) - byteout(cs->hw.elsa.trig, 0xff); - inithscxisac(cs, 2); + cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT; + byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); + cs->hw.elsa.status &= ~ELIRQF_TIMER_AKTIV; spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - if ((cs->subtyp == ELSA_PCMCIA) || - (cs->subtyp == ELSA_PCMCIA_IPAC) || - (cs->subtyp == ELSA_QS1000PCI)) { - return(0); - } else if (cs->subtyp == ELSA_QS3000PCI) { + printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n", + cs->hw.elsa.counter); + if ((cs->hw.elsa.counter > 10) && + (cs->hw.elsa.counter < 16)) { + printk(KERN_INFO "Elsa: timer and irq OK\n"); ret = 0; } else { - spin_lock_irqsave(&cs->lock, flags); - cs->hw.elsa.counter = 0; - cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT; - cs->hw.elsa.status |= ELIRQF_TIMER_AKTIV; - byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); - byteout(cs->hw.elsa.timer, 0); - spin_unlock_irqrestore(&cs->lock, flags); - msleep(110); - spin_lock_irqsave(&cs->lock, flags); - cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT; - byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg); - cs->hw.elsa.status &= ~ELIRQF_TIMER_AKTIV; - spin_unlock_irqrestore(&cs->lock, flags); - printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n", - cs->hw.elsa.counter); - if ((cs->hw.elsa.counter > 10) && - (cs->hw.elsa.counter < 16)) { - printk(KERN_INFO "Elsa: timer and irq OK\n"); - ret = 0; - } else { - printk(KERN_WARNING - "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n", - cs->hw.elsa.counter, cs->irq); - ret = 1; - } + printk(KERN_WARNING + "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n", + cs->hw.elsa.counter, cs->irq); + ret = 1; } + } #if ARCOFI_USE - if (check_arcofi(cs)) { - init_modem(cs); - } + if (check_arcofi(cs)) { + init_modem(cs); + } #endif - elsa_led_handler(cs); - return(ret); - case (MDL_REMOVE | REQUEST): - cs->hw.elsa.status &= 0; - break; - case (MDL_ASSIGN | REQUEST): - cs->hw.elsa.status |= ELSA_ASSIGN; - break; - case MDL_INFO_SETUP: - if ((long) arg) - cs->hw.elsa.status |= 0x0200; - else - cs->hw.elsa.status |= 0x0100; - break; - case MDL_INFO_CONN: - if ((long) arg) - cs->hw.elsa.status |= 0x2000; - else - cs->hw.elsa.status |= 0x1000; - break; - case MDL_INFO_REL: - if ((long) arg) { - cs->hw.elsa.status &= ~0x2000; - cs->hw.elsa.status &= ~0x0200; - } else { - cs->hw.elsa.status &= ~0x1000; - cs->hw.elsa.status &= ~0x0100; - } - break; + elsa_led_handler(cs); + return (ret); + case (MDL_REMOVE | REQUEST): + cs->hw.elsa.status &= 0; + break; + case (MDL_ASSIGN | REQUEST): + cs->hw.elsa.status |= ELSA_ASSIGN; + break; + case MDL_INFO_SETUP: + if ((long) arg) + cs->hw.elsa.status |= 0x0200; + else + cs->hw.elsa.status |= 0x0100; + break; + case MDL_INFO_CONN: + if ((long) arg) + cs->hw.elsa.status |= 0x2000; + else + cs->hw.elsa.status |= 0x1000; + break; + case MDL_INFO_REL: + if ((long) arg) { + cs->hw.elsa.status &= ~0x2000; + cs->hw.elsa.status &= ~0x0200; + } else { + cs->hw.elsa.status &= ~0x1000; + cs->hw.elsa.status &= ~0x0100; + } + break; #if ARCOFI_USE - case CARD_AUX_IND: - if (cs->hw.elsa.MFlag) { - int len; - u_char *msg; - - if (!arg) - return(0); - msg = arg; - len = *msg; - msg++; - modem_write_cmd(cs, msg, len); - } - break; + case CARD_AUX_IND: + if (cs->hw.elsa.MFlag) { + int len; + u_char *msg; + + if (!arg) + return (0); + msg = arg; + len = *msg; + msg++; + modem_write_cmd(cs, msg, len); + } + break; #endif } if (cs->typ == ISDN_CTYPE_ELSA) { @@ -765,14 +765,14 @@ Elsa_card_msg(struct IsdnCardState *cs, int mt, void *arg) cs->hw.elsa.status &= ~ELSA_BAD_PWR; } elsa_led_handler(cs); - return(ret); + return (ret); } static unsigned char probe_elsa_adr(unsigned int adr, int typ) { int i, in1, in2, p16_1 = 0, p16_2 = 0, p8_1 = 0, p8_2 = 0, pc_1 = 0, - pc_2 = 0, pfp_1 = 0, pfp_2 = 0; + pc_2 = 0, pfp_1 = 0, pfp_2 = 0; /* In case of the elsa pcmcia card, this region is in use, reserved for us by the card manager. So we do not check it @@ -822,7 +822,7 @@ probe_elsa(struct IsdnCardState *cs) { int i; unsigned int CARD_portlist[] = - {0x160, 0x170, 0x260, 0x360, 0}; + {0x160, 0x170, 0x260, 0x360, 0}; for (i = 0; CARD_portlist[i]; i++) { if ((cs->subtyp = probe_elsa_adr(CARD_portlist[i], cs->typ))) @@ -867,15 +867,15 @@ setup_elsa_isa(struct IsdnCard *card) val = bytein(cs->hw.elsa.cfg); if (cs->subtyp == ELSA_PC) { const u_char CARD_IrqTab[8] = - {7, 3, 5, 9, 0, 0, 0, 0}; + {7, 3, 5, 9, 0, 0, 0, 0}; cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX_PC) >> 2]; } else if (cs->subtyp == ELSA_PCC8) { const u_char CARD_IrqTab[8] = - {7, 3, 5, 9, 0, 0, 0, 0}; + {7, 3, 5, 9, 0, 0, 0, 0}; cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX_PCC8) >> 4]; } else { const u_char CARD_IrqTab[8] = - {15, 10, 15, 3, 11, 5, 11, 9}; + {15, 10, 15, 3, 11, 5, 11, 9}; cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX) >> 3]; } val = bytein(cs->hw.elsa.ale) & ELSA_HW_RELEASE; @@ -894,7 +894,7 @@ setup_elsa_isa(struct IsdnCard *card) val = bytein(cs->hw.elsa.ale) & ELSA_S0_POWER_BAD; if (val) { printk(KERN_WARNING - "Elsa: Microlink S0 bus power bad\n"); + "Elsa: Microlink S0 bus power bad\n"); cs->hw.elsa.status |= ELSA_BAD_PWR; } @@ -904,10 +904,10 @@ setup_elsa_isa(struct IsdnCard *card) #ifdef __ISAPNP__ static struct isapnp_device_id elsa_ids[] __devinitdata = { { ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133), - ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133), + ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133), (unsigned long) "Elsa QS1000" }, { ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134), - ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134), + ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134), (unsigned long) "Elsa QS3000" }, { 0, } }; @@ -924,31 +924,31 @@ setup_elsa_isapnp(struct IsdnCard *card) #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "Elsa PnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); + card->para[0], card->para[1]); pnp_disable_dev(pnp_d); - return(0); + return (0); } if (ipid->function == ISAPNP_FUNCTION(0x133)) cs->subtyp = ELSA_QS1000; @@ -957,20 +957,20 @@ setup_elsa_isapnp(struct IsdnCard *card) break; } else { printk(KERN_ERR "Elsa PnP: PnP error card found, no device\n"); - return(0); + return (0); } } ipid++; - pnp_c=NULL; - } + pnp_c = NULL; + } if (!ipid->card_vendor) { printk(KERN_INFO "Elsa PnP: no ISAPnP card found\n"); - return(0); + return (0); } } #endif /* __ISAPNP__ */ - if (card->para[1] && card->para[0]) { + if (card->para[1] && card->para[0]) { cs->hw.elsa.base = card->para[1]; cs->irq = card->para[0]; if (!cs->subtyp) @@ -1027,8 +1027,8 @@ setup_elsa_pcmcia(struct IsdnCard *card) } #ifdef CONFIG_PCI -static struct pci_dev *dev_qs1000 __devinitdata = NULL; -static struct pci_dev *dev_qs3000 __devinitdata = NULL; +static struct pci_dev *dev_qs1000 __devinitdata = NULL; +static struct pci_dev *dev_qs3000 __devinitdata = NULL; static int __devinit setup_elsa_pci(struct IsdnCard *card) @@ -1037,33 +1037,33 @@ setup_elsa_pci(struct IsdnCard *card) cs->subtyp = 0; if ((dev_qs1000 = hisax_find_pci_device(PCI_VENDOR_ID_ELSA, - PCI_DEVICE_ID_ELSA_MICROLINK, dev_qs1000))) { + PCI_DEVICE_ID_ELSA_MICROLINK, dev_qs1000))) { if (pci_enable_device(dev_qs1000)) - return(0); + return (0); cs->subtyp = ELSA_QS1000PCI; cs->irq = dev_qs1000->irq; cs->hw.elsa.cfg = pci_resource_start(dev_qs1000, 1); cs->hw.elsa.base = pci_resource_start(dev_qs1000, 3); } else if ((dev_qs3000 = hisax_find_pci_device(PCI_VENDOR_ID_ELSA, - PCI_DEVICE_ID_ELSA_QS3000, dev_qs3000))) { + PCI_DEVICE_ID_ELSA_QS3000, dev_qs3000))) { if (pci_enable_device(dev_qs3000)) - return(0); + return (0); cs->subtyp = ELSA_QS3000PCI; cs->irq = dev_qs3000->irq; cs->hw.elsa.cfg = pci_resource_start(dev_qs3000, 1); cs->hw.elsa.base = pci_resource_start(dev_qs3000, 3); } else { printk(KERN_WARNING "Elsa: No PCI card found\n"); - return(0); + return (0); } if (!cs->irq) { printk(KERN_WARNING "Elsa: No IRQ for PCI card found\n"); - return(0); + return (0); } if (!(cs->hw.elsa.base && cs->hw.elsa.cfg)) { printk(KERN_WARNING "Elsa: No IO-Adr for PCI card found\n"); - return(0); + return (0); } if ((cs->hw.elsa.cfg & 0xff) || (cs->hw.elsa.base & 0xf)) { printk(KERN_WARNING "Elsa: You may have a wrong PCI bios\n"); @@ -1071,8 +1071,8 @@ setup_elsa_pci(struct IsdnCard *card) printk(KERN_WARNING "Elsa: Documentation/isdn/README.HiSax\n"); } cs->hw.elsa.ale = cs->hw.elsa.base; - cs->hw.elsa.isac = cs->hw.elsa.base +1; - cs->hw.elsa.hscx = cs->hw.elsa.base +1; + cs->hw.elsa.isac = cs->hw.elsa.base + 1; + cs->hw.elsa.hscx = cs->hw.elsa.base + 1; test_and_set_bit(HW_IPAC, &cs->HW_Flags); cs->hw.elsa.timer = 0; cs->hw.elsa.trig = 0; @@ -1104,27 +1104,27 @@ setup_elsa_common(struct IsdnCard *card) int bytecnt; switch (cs->subtyp) { - case ELSA_PC: - case ELSA_PCC8: - case ELSA_PCC16: - case ELSA_QS1000: - case ELSA_PCMCIA: - case ELSA_PCMCIA_IPAC: - bytecnt = 8; - break; - case ELSA_PCFPRO: - case ELSA_PCF: - case ELSA_QS3000: - case ELSA_QS3000PCI: - bytecnt = 16; - break; - case ELSA_QS1000PCI: - bytecnt = 2; - break; - default: - printk(KERN_WARNING - "Unknown ELSA subtype %d\n", cs->subtyp); - return (0); + case ELSA_PC: + case ELSA_PCC8: + case ELSA_PCC16: + case ELSA_QS1000: + case ELSA_PCMCIA: + case ELSA_PCMCIA_IPAC: + bytecnt = 8; + break; + case ELSA_PCFPRO: + case ELSA_PCF: + case ELSA_QS3000: + case ELSA_QS3000PCI: + bytecnt = 16; + break; + case ELSA_QS1000PCI: + bytecnt = 2; + break; + default: + printk(KERN_WARNING + "Unknown ELSA subtype %d\n", cs->subtyp); + return (0); } /* In case of the elsa pcmcia card, this region is in use, reserved for us by the card manager. So we do not check it @@ -1140,8 +1140,8 @@ setup_elsa_common(struct IsdnCard *card) if (!request_region(cs->hw.elsa.cfg, 0x80, "elsa isdn pci")) { printk(KERN_WARNING "HiSax: ELSA pci port %x-%x already in use\n", - cs->hw.elsa.cfg, - cs->hw.elsa.cfg + 0x80); + cs->hw.elsa.cfg, + cs->hw.elsa.cfg + 0x80); release_region(cs->hw.elsa.base, bytecnt); return (0); } @@ -1166,7 +1166,7 @@ setup_elsa_common(struct IsdnCard *card) return (0); } } - HZDELAY((HZ/100) + 1); /* wait >=10 ms */ + HZDELAY((HZ / 100) + 1); /* wait >=10 ms */ if (TimerRun(cs)) { printk(KERN_WARNING "Elsa: timer do not run down\n"); release_io_elsa(cs); @@ -1195,7 +1195,7 @@ setup_elsa_common(struct IsdnCard *card) ISACVersion(cs, "Elsa:"); if (HscxVersion(cs, "Elsa:")) { printk(KERN_WARNING - "Elsa: wrong HSCX versions check IO address\n"); + "Elsa: wrong HSCX versions check IO address\n"); release_io_elsa(cs); return (0); } @@ -1244,7 +1244,7 @@ setup_elsa(struct IsdnCard *card) if (!rc) return (0); - } else + } else return (0); return setup_elsa_common(card); diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index f0b6c0ef99bb..fe254e74a850 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -1,39 +1,39 @@ /*====================================================================== - An elsa_cs PCMCIA client driver + An elsa_cs PCMCIA client driver - This driver is for the Elsa PCM ISDN Cards, i.e. the MicroLink + This driver is for the Elsa PCM ISDN Cards, i.e. the MicroLink - The contents of this file are subject to the Mozilla Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ + The contents of this file are subject to the Mozilla Public + License Version 1.1 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. + Software distributed under the License is distributed on an "AS + IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + implied. See the License for the specific language governing + rights and limitations under the License. - The initial developer of the original code is David A. Hinds - . Portions created by David A. Hinds - are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + The initial developer of the original code is David A. Hinds + . Portions created by David A. Hinds + are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - Modifications from dummy_cs.c are Copyright (C) 1999-2001 Klaus - Lichtenwalder . All Rights Reserved. + Modifications from dummy_cs.c are Copyright (C) 1999-2001 Klaus + Lichtenwalder . All Rights Reserved. - Alternatively, the contents of this file may be used under the - terms of the GNU General Public License version 2 (the "GPL"), in - which case the provisions of the GPL are applicable instead of the - above. If you wish to allow the use of your version of this file - only under the terms of the GPL and not to allow others to use - your version of this file under the MPL, indicate your decision - by deleting the provisions above and replace them with the notice - and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this - file under either the MPL or the GPL. + Alternatively, the contents of this file may be used under the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the + above. If you wish to allow the use of your version of this file + only under the terms of the GPL and not to allow others to use + your version of this file under the MPL, indicate your decision + by deleting the provisions above and replace them with the notice + and other provisions required by the GPL. If you do not delete + the provisions above, a recipient may use your version of this + file under either the MPL or the GPL. -======================================================================*/ + ======================================================================*/ #include #include @@ -63,32 +63,32 @@ MODULE_LICENSE("Dual MPL/GPL"); static int protocol = 2; /* EURO-ISDN Default */ module_param(protocol, int, 0); -static int elsa_cs_config(struct pcmcia_device *link) __devinit ; +static int elsa_cs_config(struct pcmcia_device *link) __devinit; static void elsa_cs_release(struct pcmcia_device *link); static void elsa_cs_detach(struct pcmcia_device *p_dev) __devexit; typedef struct local_info_t { struct pcmcia_device *p_dev; - int busy; - int cardnr; + int busy; + int cardnr; } local_info_t; static int __devinit elsa_cs_probe(struct pcmcia_device *link) { - local_info_t *local; + local_info_t *local; - dev_dbg(&link->dev, "elsa_cs_attach()\n"); + dev_dbg(&link->dev, "elsa_cs_attach()\n"); - /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(local_info_t), GFP_KERNEL); - if (!local) return -ENOMEM; + /* Allocate space for private device-specific data */ + local = kzalloc(sizeof(local_info_t), GFP_KERNEL); + if (!local) return -ENOMEM; - local->p_dev = link; - link->priv = local; + local->p_dev = link; + link->priv = local; - local->cardnr = -1; + local->cardnr = -1; - return elsa_cs_config(link); + return elsa_cs_config(link); } /* elsa_cs_attach */ static void __devexit elsa_cs_detach(struct pcmcia_device *link) @@ -129,64 +129,64 @@ static int elsa_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) static int __devinit elsa_cs_config(struct pcmcia_device *link) { - int i; - IsdnCard_t icard; - - dev_dbg(&link->dev, "elsa_config(0x%p)\n", link); - - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - - i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); - if (i != 0) - goto failed; - - if (!link->irq) - goto failed; - - i = pcmcia_enable_device(link); - if (i != 0) - goto failed; - - icard.para[0] = link->irq; - icard.para[1] = link->resource[0]->start; - icard.protocol = protocol; - icard.typ = ISDN_CTYPE_ELSA_PCMCIA; - - i = hisax_init_pcmcia(link, &(((local_info_t*)link->priv)->busy), &icard); - if (i < 0) { - printk(KERN_ERR "elsa_cs: failed to initialize Elsa " - "PCMCIA %d with %pR\n", i, link->resource[0]); - elsa_cs_release(link); - } else - ((local_info_t*)link->priv)->cardnr = i; - - return 0; + int i; + IsdnCard_t icard; + + dev_dbg(&link->dev, "elsa_config(0x%p)\n", link); + + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; + + i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); + if (i != 0) + goto failed; + + if (!link->irq) + goto failed; + + i = pcmcia_enable_device(link); + if (i != 0) + goto failed; + + icard.para[0] = link->irq; + icard.para[1] = link->resource[0]->start; + icard.protocol = protocol; + icard.typ = ISDN_CTYPE_ELSA_PCMCIA; + + i = hisax_init_pcmcia(link, &(((local_info_t *)link->priv)->busy), &icard); + if (i < 0) { + printk(KERN_ERR "elsa_cs: failed to initialize Elsa " + "PCMCIA %d with %pR\n", i, link->resource[0]); + elsa_cs_release(link); + } else + ((local_info_t *)link->priv)->cardnr = i; + + return 0; failed: - elsa_cs_release(link); - return -ENODEV; + elsa_cs_release(link); + return -ENODEV; } /* elsa_cs_config */ static void elsa_cs_release(struct pcmcia_device *link) { - local_info_t *local = link->priv; + local_info_t *local = link->priv; - dev_dbg(&link->dev, "elsa_cs_release(0x%p)\n", link); + dev_dbg(&link->dev, "elsa_cs_release(0x%p)\n", link); - if (local) { - if (local->cardnr >= 0) { - /* no unregister function with hisax */ - HiSax_closecard(local->cardnr); + if (local) { + if (local->cardnr >= 0) { + /* no unregister function with hisax */ + HiSax_closecard(local->cardnr); + } } - } - pcmcia_disable_device(link); + pcmcia_disable_device(link); } /* elsa_cs_release */ static int elsa_suspend(struct pcmcia_device *link) { local_info_t *dev = link->priv; - dev->busy = 1; + dev->busy = 1; return 0; } @@ -195,7 +195,7 @@ static int elsa_resume(struct pcmcia_device *link) { local_info_t *dev = link->priv; - dev->busy = 0; + dev->busy = 0; return 0; } diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c index 3fa9f6171095..d4c98d330bfe 100644 --- a/drivers/isdn/hisax/elsa_ser.c +++ b/drivers/isdn/hisax/elsa_ser.c @@ -12,9 +12,9 @@ #include #define MAX_MODEM_BUF 256 -#define WAKEUP_CHARS (MAX_MODEM_BUF/2) +#define WAKEUP_CHARS (MAX_MODEM_BUF / 2) #define RS_ISR_PASS_LIMIT 256 -#define BASE_BAUD ( 1843200 / 16 ) +#define BASE_BAUD (1843200 / 16) //#define SERIAL_DEBUG_OPEN 1 //#define SERIAL_DEBUG_INTR 1 @@ -27,8 +27,8 @@ #ifdef SERIAL_DEBUG_REG static u_char deb[32]; -const char *ModemIn[] = {"RBR","IER","IIR","LCR","MCR","LSR","MSR","SCR"}; -const char *ModemOut[] = {"THR","IER","FCR","LCR","MCR","LSR","MSR","SCR"}; +const char *ModemIn[] = {"RBR", "IER", "IIR", "LCR", "MCR", "LSR", "MSR", "SCR"}; +const char *ModemOut[] = {"THR", "IER", "FCR", "LCR", "MCR", "LSR", "MSR", "SCR"}; #endif static char *MInit_1 = "AT&F&C1E0&D2\r\0"; @@ -49,8 +49,8 @@ static inline unsigned int serial_in(struct IsdnCardState *cs, int offset) { #ifdef SERIAL_DEBUG_REG u_int val = inb(cs->hw.elsa.base + 8 + offset); - debugl1(cs,"in %s %02x",ModemIn[offset], val); - return(val); + debugl1(cs, "in %s %02x", ModemIn[offset], val); + return (val); #else return inb(cs->hw.elsa.base + 8 + offset); #endif @@ -61,12 +61,12 @@ static inline unsigned int serial_inp(struct IsdnCardState *cs, int offset) #ifdef SERIAL_DEBUG_REG #ifdef ELSA_SERIAL_NOPAUSE_IO u_int val = inb(cs->hw.elsa.base + 8 + offset); - debugl1(cs,"inp %s %02x",ModemIn[offset], val); + debugl1(cs, "inp %s %02x", ModemIn[offset], val); #else u_int val = inb_p(cs->hw.elsa.base + 8 + offset); - debugl1(cs,"inP %s %02x",ModemIn[offset], val); + debugl1(cs, "inP %s %02x", ModemIn[offset], val); #endif - return(val); + return (val); #else #ifdef ELSA_SERIAL_NOPAUSE_IO return inb(cs->hw.elsa.base + 8 + offset); @@ -79,7 +79,7 @@ static inline unsigned int serial_inp(struct IsdnCardState *cs, int offset) static inline void serial_out(struct IsdnCardState *cs, int offset, int value) { #ifdef SERIAL_DEBUG_REG - debugl1(cs,"out %s %02x",ModemOut[offset], value); + debugl1(cs, "out %s %02x", ModemOut[offset], value); #endif outb(value, cs->hw.elsa.base + 8 + offset); } @@ -89,15 +89,15 @@ static inline void serial_outp(struct IsdnCardState *cs, int offset, { #ifdef SERIAL_DEBUG_REG #ifdef ELSA_SERIAL_NOPAUSE_IO - debugl1(cs,"outp %s %02x",ModemOut[offset], value); + debugl1(cs, "outp %s %02x", ModemOut[offset], value); #else - debugl1(cs,"outP %s %02x",ModemOut[offset], value); + debugl1(cs, "outP %s %02x", ModemOut[offset], value); #endif #endif #ifdef ELSA_SERIAL_NOPAUSE_IO outb(value, cs->hw.elsa.base + 8 + offset); #else - outb_p(value, cs->hw.elsa.base + 8 + offset); + outb_p(value, cs->hw.elsa.base + 8 + offset); #endif } @@ -131,7 +131,7 @@ static void change_speed(struct IsdnCardState *cs, int baud) cs->hw.elsa.IER |= UART_IER_MSI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); - debugl1(cs,"modem quot=0x%x", quot); + debugl1(cs, "modem quot=0x%x", quot); serial_outp(cs, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ serial_outp(cs, UART_DLL, quot & 0xff); /* LS of divisor */ serial_outp(cs, UART_DLM, quot >> 8); /* MS of divisor */ @@ -141,7 +141,7 @@ static void change_speed(struct IsdnCardState *cs, int baud) static int mstartup(struct IsdnCardState *cs) { - int retval=0; + int retval = 0; /* * Clear the FIFO buffers and disable them @@ -158,7 +158,7 @@ static int mstartup(struct IsdnCardState *cs) retval = -ENODEV; goto errout; } - + /* * Clear the interrupt registers. */ @@ -167,20 +167,20 @@ static int mstartup(struct IsdnCardState *cs) (void) serial_inp(cs, UART_MSR); /* - * Now, initialize the UART + * Now, initialize the UART */ serial_outp(cs, UART_LCR, UART_LCR_WLEN8); /* reset DLAB */ cs->hw.elsa.MCR = 0; cs->hw.elsa.MCR = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; serial_outp(cs, UART_MCR, cs->hw.elsa.MCR); - + /* * Finally, enable interrupts */ cs->hw.elsa.IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); /* enable interrupts */ - + /* * And clear the interrupt registers again for luck. */ @@ -190,7 +190,7 @@ static int mstartup(struct IsdnCardState *cs) (void)serial_inp(cs, UART_MSR); cs->hw.elsa.transcnt = cs->hw.elsa.transp = 0; - cs->hw.elsa.rcvcnt = cs->hw.elsa.rcvp =0; + cs->hw.elsa.rcvcnt = cs->hw.elsa.rcvp = 0; /* * and set the speed of the serial port @@ -211,7 +211,7 @@ static void mshutdown(struct IsdnCardState *cs) #ifdef SERIAL_DEBUG_OPEN printk(KERN_DEBUG"Shutting down serial ...."); #endif - + /* * clear delta_msr_wait queue to avoid mem leaks: we may free the irq * here so the queue might never be waken up @@ -220,17 +220,17 @@ static void mshutdown(struct IsdnCardState *cs) cs->hw.elsa.IER = 0; serial_outp(cs, UART_IER, 0x00); /* disable all intrs */ cs->hw.elsa.MCR &= ~UART_MCR_OUT2; - + /* disable break condition */ serial_outp(cs, UART_LCR, serial_inp(cs, UART_LCR) & ~UART_LCR_SBC); - - cs->hw.elsa.MCR &= ~(UART_MCR_DTR|UART_MCR_RTS); + + cs->hw.elsa.MCR &= ~(UART_MCR_DTR | UART_MCR_RTS); serial_outp(cs, UART_MCR, cs->hw.elsa.MCR); - /* disable FIFO's */ + /* disable FIFO's */ serial_outp(cs, UART_FCR, (UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT)); serial_inp(cs, UART_RX); /* read data port to reset things */ - + #ifdef SERIAL_DEBUG_OPEN printk(" done\n"); #endif @@ -238,10 +238,10 @@ static void mshutdown(struct IsdnCardState *cs) static inline int write_modem(struct BCState *bcs) { - int ret=0; + int ret = 0; struct IsdnCardState *cs = bcs->cs; int count, len, fp; - + if (!bcs->tx_skb) return 0; if (bcs->tx_skb->len <= 0) @@ -250,7 +250,7 @@ write_modem(struct BCState *bcs) { if (len > MAX_MODEM_BUF - cs->hw.elsa.transcnt) len = MAX_MODEM_BUF - cs->hw.elsa.transcnt; fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp; - fp &= (MAX_MODEM_BUF -1); + fp &= (MAX_MODEM_BUF - 1); count = len; if (count > MAX_MODEM_BUF - fp) { count = MAX_MODEM_BUF - fp; @@ -267,25 +267,25 @@ write_modem(struct BCState *bcs) { skb_pull(bcs->tx_skb, count); cs->hw.elsa.transcnt += count; ret += count; - - if (cs->hw.elsa.transcnt && + + if (cs->hw.elsa.transcnt && !(cs->hw.elsa.IER & UART_IER_THRI)) { - cs->hw.elsa.IER |= UART_IER_THRI; + cs->hw.elsa.IER |= UART_IER_THRI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); } - return(ret); + return (ret); } static inline void modem_fill(struct BCState *bcs) { - + if (bcs->tx_skb) { if (bcs->tx_skb->len) { write_modem(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; @@ -322,7 +322,7 @@ static inline void receive_chars(struct IsdnCardState *cs, #endif if (*status & (UART_LSR_BI | UART_LSR_PE | UART_LSR_FE | UART_LSR_OE)) { - + #ifdef SERIAL_DEBUG_INTR printk("handling exept...."); #endif @@ -333,9 +333,9 @@ static inline void receive_chars(struct IsdnCardState *cs, if (!(skb = dev_alloc_skb(cs->hw.elsa.rcvcnt))) printk(KERN_WARNING "ElsaSER: receive out of memory\n"); else { - memcpy(skb_put(skb, cs->hw.elsa.rcvcnt), cs->hw.elsa.rcvbuf, - cs->hw.elsa.rcvcnt); - skb_queue_tail(& cs->hw.elsa.bcs->rqueue, skb); + memcpy(skb_put(skb, cs->hw.elsa.rcvcnt), cs->hw.elsa.rcvbuf, + cs->hw.elsa.rcvcnt); + skb_queue_tail(&cs->hw.elsa.bcs->rqueue, skb); } schedule_event(cs->hw.elsa.bcs, B_RCVBUFREADY); } else { @@ -352,10 +352,10 @@ static inline void receive_chars(struct IsdnCardState *cs, static inline void transmit_chars(struct IsdnCardState *cs, int *intr_done) { int count; - - debugl1(cs, "transmit_chars: p(%x) cnt(%x)", cs->hw.elsa.transp, + + debugl1(cs, "transmit_chars: p(%x) cnt(%x)", cs->hw.elsa.transp, cs->hw.elsa.transcnt); - + if (cs->hw.elsa.transcnt <= 0) { cs->hw.elsa.IER &= ~UART_IER_THRI; serial_out(cs, UART_IER, cs->hw.elsa.IER); @@ -365,11 +365,11 @@ static inline void transmit_chars(struct IsdnCardState *cs, int *intr_done) do { serial_outp(cs, UART_TX, cs->hw.elsa.transbuf[cs->hw.elsa.transp++]); if (cs->hw.elsa.transp >= MAX_MODEM_BUF) - cs->hw.elsa.transp=0; + cs->hw.elsa.transp = 0; if (--cs->hw.elsa.transcnt <= 0) break; } while (--count > 0); - if ((cs->hw.elsa.transcnt < WAKEUP_CHARS) && (cs->hw.elsa.MFlag==2)) + if ((cs->hw.elsa.transcnt < WAKEUP_CHARS) && (cs->hw.elsa.MFlag == 2)) modem_fill(cs->hw.elsa.bcs); #ifdef SERIAL_DEBUG_INTR @@ -388,14 +388,14 @@ static void rs_interrupt_elsa(struct IsdnCardState *cs) { int status, iir, msr; int pass_counter = 0; - + #ifdef SERIAL_DEBUG_INTR printk(KERN_DEBUG "rs_interrupt_single(%d)...", cs->irq); #endif do { status = serial_inp(cs, UART_LSR); - debugl1(cs,"rs LSR %02x", status); + debugl1(cs, "rs LSR %02x", status); #ifdef SERIAL_DEBUG_INTR printk("status = %x...", status); #endif @@ -408,10 +408,10 @@ static void rs_interrupt_elsa(struct IsdnCardState *cs) break; } iir = serial_inp(cs, UART_IIR); - debugl1(cs,"rs IIR %02x", iir); + debugl1(cs, "rs IIR %02x", iir); if ((iir & 0xf) == 0) { msr = serial_inp(cs, UART_MSR); - debugl1(cs,"rs MSR %02x", msr); + debugl1(cs, "rs MSR %02x", msr); } } while (!(iir & UART_IIR_NO_INT)); #ifdef SERIAL_DEBUG_INTR @@ -447,14 +447,14 @@ static void modem_write_cmd(struct IsdnCardState *cs, u_char *buf, int len) { int count, fp; u_char *msg = buf; - + if (!len) return; if (len > (MAX_MODEM_BUF - cs->hw.elsa.transcnt)) { return; } fp = cs->hw.elsa.transcnt + cs->hw.elsa.transp; - fp &= (MAX_MODEM_BUF -1); + fp &= (MAX_MODEM_BUF - 1); count = len; if (count > MAX_MODEM_BUF - fp) { count = MAX_MODEM_BUF - fp; @@ -466,7 +466,7 @@ modem_write_cmd(struct IsdnCardState *cs, u_char *buf, int len) { } memcpy(cs->hw.elsa.transbuf + fp, msg, count); cs->hw.elsa.transcnt += count; - if (cs->hw.elsa.transcnt && + if (cs->hw.elsa.transcnt && !(cs->hw.elsa.IER & UART_IER_THRI)) { cs->hw.elsa.IER |= UART_IER_THRI; serial_outp(cs, UART_IER, cs->hw.elsa.IER); @@ -480,43 +480,43 @@ modem_set_init(struct IsdnCardState *cs) { #define RCV_DELAY 20 modem_write_cmd(cs, MInit_1, strlen(MInit_1)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_2, strlen(MInit_2)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_3, strlen(MInit_3)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_4, strlen(MInit_4)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_5, strlen(MInit_5)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_6, strlen(MInit_6)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); modem_write_cmd(cs, MInit_7, strlen(MInit_7)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); @@ -529,7 +529,7 @@ modem_set_dial(struct IsdnCardState *cs, int outgoing) { modem_write_cmd(cs, MInit_speed28800, strlen(MInit_speed28800)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); @@ -538,7 +538,7 @@ modem_set_dial(struct IsdnCardState *cs, int outgoing) { else modem_write_cmd(cs, MInit_dialin, strlen(MInit_dialin)); timeout = 1000; - while(timeout-- && cs->hw.elsa.transcnt) + while (timeout-- && cs->hw.elsa.transcnt) udelay(1000); debugl1(cs, "msi tout=%d", timeout); mdelay(RCV_DELAY); @@ -568,15 +568,15 @@ modem_l2l1(struct PStack *st, int pr, void *arg) set_arcofi(bcs->cs, st->l1.bc); mstartup(bcs->cs); modem_set_dial(bcs->cs, test_bit(FLG_ORIG, &st->l2.flag)); - bcs->cs->hw.elsa.MFlag=2; + bcs->cs->hw.elsa.MFlag = 2; } else if (pr == (PH_DEACTIVATE | REQUEST)) { test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); bcs->cs->dc.isac.arcofi_bc = st->l1.bc; arcofi_fsm(bcs->cs, ARCOFI_START, &ARCOFI_XOP_0); interruptible_sleep_on(&bcs->cs->dc.isac.arcofi_wait); - bcs->cs->hw.elsa.MFlag=1; + bcs->cs->hw.elsa.MFlag = 1; } else { - printk(KERN_WARNING"ElsaSer: unknown pr %x\n", pr); + printk(KERN_WARNING "ElsaSer: unknown pr %x\n", pr); } } @@ -586,27 +586,27 @@ setstack_elsa(struct PStack *st, struct BCState *bcs) bcs->channel = st->l1.bc; switch (st->l1.mode) { - case L1_MODE_HDLC: - case L1_MODE_TRANS: - if (open_hscxstate(st->l1.hardware, bcs)) - return (-1); - st->l2.l2l1 = hscx_l2l1; - break; - case L1_MODE_MODEM: - bcs->mode = L1_MODE_MODEM; - if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { - bcs->hw.hscx.rcvbuf = bcs->cs->hw.elsa.rcvbuf; - skb_queue_head_init(&bcs->rqueue); - skb_queue_head_init(&bcs->squeue); - } - bcs->tx_skb = NULL; - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->event = 0; - bcs->hw.hscx.rcvidx = 0; - bcs->tx_cnt = 0; - bcs->cs->hw.elsa.bcs = bcs; - st->l2.l2l1 = modem_l2l1; - break; + case L1_MODE_HDLC: + case L1_MODE_TRANS: + if (open_hscxstate(st->l1.hardware, bcs)) + return (-1); + st->l2.l2l1 = hscx_l2l1; + break; + case L1_MODE_MODEM: + bcs->mode = L1_MODE_MODEM; + if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { + bcs->hw.hscx.rcvbuf = bcs->cs->hw.elsa.rcvbuf; + skb_queue_head_init(&bcs->rqueue); + skb_queue_head_init(&bcs->squeue); + } + bcs->tx_skb = NULL; + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->event = 0; + bcs->hw.hscx.rcvidx = 0; + bcs->tx_cnt = 0; + bcs->cs->hw.elsa.bcs = bcs; + st->l2.l2l1 = modem_l2l1; + break; } st->l1.bcs = bcs; setstack_manager(st); @@ -623,15 +623,15 @@ init_modem(struct IsdnCardState *cs) { cs->bcs[0].BC_Close = close_elsastate; cs->bcs[1].BC_Close = close_elsastate; if (!(cs->hw.elsa.rcvbuf = kmalloc(MAX_MODEM_BUF, - GFP_ATOMIC))) { + GFP_ATOMIC))) { printk(KERN_WARNING - "Elsa: No modem mem hw.elsa.rcvbuf\n"); + "Elsa: No modem mem hw.elsa.rcvbuf\n"); return; } if (!(cs->hw.elsa.transbuf = kmalloc(MAX_MODEM_BUF, - GFP_ATOMIC))) { + GFP_ATOMIC))) { printk(KERN_WARNING - "Elsa: No modem mem hw.elsa.transbuf\n"); + "Elsa: No modem mem hw.elsa.transbuf\n"); kfree(cs->hw.elsa.rcvbuf); cs->hw.elsa.rcvbuf = NULL; return; diff --git a/drivers/isdn/hisax/enternow_pci.c b/drivers/isdn/hisax/enternow_pci.c index f55d29d60826..b1e38b54ebac 100644 --- a/drivers/isdn/hisax/enternow_pci.c +++ b/drivers/isdn/hisax/enternow_pci.c @@ -97,13 +97,13 @@ static unsigned char ReadByteAmd7930(struct IsdnCardState *cs, unsigned char offset) { /* direct register */ - if(offset < 8) - return (inb(cs->hw.njet.isac + 4*offset)); + if (offset < 8) + return (inb(cs->hw.njet.isac + 4 * offset)); /* indirect register */ else { - outb(offset, cs->hw.njet.isac + 4*AMD_CR); - return(inb(cs->hw.njet.isac + 4*AMD_DR)); + outb(offset, cs->hw.njet.isac + 4 * AMD_CR); + return (inb(cs->hw.njet.isac + 4 * AMD_DR)); } } @@ -112,29 +112,29 @@ static void WriteByteAmd7930(struct IsdnCardState *cs, unsigned char offset, unsigned char value) { /* direct register */ - if(offset < 8) - outb(value, cs->hw.njet.isac + 4*offset); + if (offset < 8) + outb(value, cs->hw.njet.isac + 4 * offset); /* indirect register */ else { - outb(offset, cs->hw.njet.isac + 4*AMD_CR); - outb(value, cs->hw.njet.isac + 4*AMD_DR); + outb(offset, cs->hw.njet.isac + 4 * AMD_CR); + outb(value, cs->hw.njet.isac + 4 * AMD_DR); } } static void enpci_setIrqMask(struct IsdnCardState *cs, unsigned char val) { - if (!val) - outb(0x00, cs->hw.njet.base+NETJET_IRQMASK1); - else - outb(TJ_AMD_IRQ, cs->hw.njet.base+NETJET_IRQMASK1); + if (!val) + outb(0x00, cs->hw.njet.base + NETJET_IRQMASK1); + else + outb(TJ_AMD_IRQ, cs->hw.njet.base + NETJET_IRQMASK1); } static unsigned char dummyrr(struct IsdnCardState *cs, int chan, unsigned char off) { - return(5); + return (5); } static void dummywr(struct IsdnCardState *cs, int chan, unsigned char off, unsigned char value) @@ -173,70 +173,70 @@ static int enpci_card_msg(struct IsdnCardState *cs, int mt, void *arg) { u_long flags; - unsigned char *chan; + unsigned char *chan; if (cs->debug & L1_DEB_ISAC) debugl1(cs, "enter:now PCI: card_msg: 0x%04X", mt); - switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_enpci(cs); - Amd7930_init(cs); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case CARD_RELEASE: - release_io_netjet(cs); - break; - case CARD_INIT: - reset_enpci(cs); - inittiger(cs); - /* irq must be on here */ - Amd7930_init(cs); - break; - case CARD_TEST: - break; - case MDL_ASSIGN: - /* TEI assigned, LED1 on */ - cs->hw.njet.auxd = TJ_AMD_IRQ << 1; - outb(cs->hw.njet.auxd, cs->hw.njet.base + NETJET_AUXDATA); - break; - case MDL_REMOVE: - /* TEI removed, LEDs off */ - cs->hw.njet.auxd = 0; - outb(0x00, cs->hw.njet.base + NETJET_AUXDATA); - break; - case MDL_BC_ASSIGN: - /* activate B-channel */ - chan = (unsigned char *)arg; - - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "enter:now PCI: assign phys. BC %d in AMD LMR1", *chan); - - cs->dc.amd7930.ph_command(cs, (cs->dc.amd7930.lmr1 | (*chan + 1)), "MDL_BC_ASSIGN"); - /* at least one b-channel in use, LED 2 on */ - cs->hw.njet.auxd |= TJ_AMD_IRQ << 2; - outb(cs->hw.njet.auxd, cs->hw.njet.base + NETJET_AUXDATA); - break; - case MDL_BC_RELEASE: - /* deactivate B-channel */ - chan = (unsigned char *)arg; - - if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "enter:now PCI: release phys. BC %d in Amd LMR1", *chan); - - cs->dc.amd7930.ph_command(cs, (cs->dc.amd7930.lmr1 & ~(*chan + 1)), "MDL_BC_RELEASE"); - /* no b-channel active -> LED2 off */ - if (!(cs->dc.amd7930.lmr1 & 3)) { - cs->hw.njet.auxd &= ~(TJ_AMD_IRQ << 2); - outb(cs->hw.njet.auxd, cs->hw.njet.base + NETJET_AUXDATA); - } - break; - default: - break; + switch (mt) { + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_enpci(cs); + Amd7930_init(cs); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case CARD_RELEASE: + release_io_netjet(cs); + break; + case CARD_INIT: + reset_enpci(cs); + inittiger(cs); + /* irq must be on here */ + Amd7930_init(cs); + break; + case CARD_TEST: + break; + case MDL_ASSIGN: + /* TEI assigned, LED1 on */ + cs->hw.njet.auxd = TJ_AMD_IRQ << 1; + outb(cs->hw.njet.auxd, cs->hw.njet.base + NETJET_AUXDATA); + break; + case MDL_REMOVE: + /* TEI removed, LEDs off */ + cs->hw.njet.auxd = 0; + outb(0x00, cs->hw.njet.base + NETJET_AUXDATA); + break; + case MDL_BC_ASSIGN: + /* activate B-channel */ + chan = (unsigned char *)arg; + + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "enter:now PCI: assign phys. BC %d in AMD LMR1", *chan); + + cs->dc.amd7930.ph_command(cs, (cs->dc.amd7930.lmr1 | (*chan + 1)), "MDL_BC_ASSIGN"); + /* at least one b-channel in use, LED 2 on */ + cs->hw.njet.auxd |= TJ_AMD_IRQ << 2; + outb(cs->hw.njet.auxd, cs->hw.njet.base + NETJET_AUXDATA); + break; + case MDL_BC_RELEASE: + /* deactivate B-channel */ + chan = (unsigned char *)arg; + + if (cs->debug & L1_DEB_ISAC) + debugl1(cs, "enter:now PCI: release phys. BC %d in Amd LMR1", *chan); + + cs->dc.amd7930.ph_command(cs, (cs->dc.amd7930.lmr1 & ~(*chan + 1)), "MDL_BC_RELEASE"); + /* no b-channel active -> LED2 off */ + if (!(cs->dc.amd7930.lmr1 & 3)) { + cs->hw.njet.auxd &= ~(TJ_AMD_IRQ << 2); + outb(cs->hw.njet.auxd, cs->hw.njet.base + NETJET_AUXDATA); + } + break; + default: + break; } - return(0); + return (0); } static irqreturn_t @@ -249,32 +249,32 @@ enpci_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); s1val = inb(cs->hw.njet.base + NETJET_IRQSTAT1); - /* AMD threw an interrupt */ + /* AMD threw an interrupt */ if (!(s1val & TJ_AMD_IRQ)) { - /* read and clear interrupt-register */ + /* read and clear interrupt-register */ ir = ReadByteAmd7930(cs, 0x00); Amd7930_interrupt(cs, ir); s1val = 1; } else s1val = 0; s0val = inb(cs->hw.njet.base + NETJET_IRQSTAT0); - if ((s0val | s1val)==0) { // shared IRQ + if ((s0val | s1val) == 0) { // shared IRQ spin_unlock_irqrestore(&cs->lock, flags); return IRQ_NONE; - } + } if (s0val) outb(s0val, cs->hw.njet.base + NETJET_IRQSTAT0); /* DMA-Interrupt: B-channel-stuff */ /* set bits in sval to indicate which page is free */ if (inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR) < - inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ)) + inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ)) /* the 2nd write page is free */ s0val = 0x08; else /* the 1st write page is free */ s0val = 0x04; if (inl(cs->hw.njet.base + NETJET_DMA_READ_ADR) < - inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ)) + inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ)) /* the 2nd read page is free */ s0val = s0val | 0x02; else /* the 1st read page is free */ @@ -287,11 +287,11 @@ enpci_interrupt(int intno, void *dev_id) } cs->hw.njet.irqstat0 = s0val; if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) != - (cs->hw.njet.last_is0 & NETJET_IRQM0_READ)) + (cs->hw.njet.last_is0 & NETJET_IRQM0_READ)) /* we have a read dma int */ read_tiger(cs); if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_WRITE) != - (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE)) + (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE)) /* we have a write dma int */ write_tiger(cs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); @@ -304,26 +304,26 @@ static int __devinit en_pci_probe(struct pci_dev *dev_netjet, struct IsdnCardState *cs) { if (pci_enable_device(dev_netjet)) - return(0); + return (0); cs->irq = dev_netjet->irq; if (!cs->irq) { printk(KERN_WARNING "enter:now PCI: No IRQ for PCI card found\n"); - return(0); + return (0); } cs->hw.njet.base = pci_resource_start(dev_netjet, 0); if (!cs->hw.njet.base) { printk(KERN_WARNING "enter:now PCI: No IO-Adr for PCI card found\n"); - return(0); + return (0); } /* checks Sub-Vendor ID because system crashes with Traverse-Card */ if ((dev_netjet->subsystem_vendor != 0x55) || (dev_netjet->subsystem_device != 0x02)) { printk(KERN_WARNING "enter:now: You tried to load this driver with an incompatible TigerJet-card\n"); printk(KERN_WARNING "Use type=20 for Traverse NetJet PCI Card.\n"); - return(0); + return (0); } - return(1); + return (1); } static void __devinit en_cs_init(struct IsdnCard *card, @@ -356,8 +356,8 @@ static int __devinit en_cs_init_rest(struct IsdnCard *card, const int bytecnt = 256; printk(KERN_INFO - "enter:now PCI: PCI card configured at 0x%lx IRQ %d\n", - cs->hw.njet.base, cs->irq); + "enter:now PCI: PCI card configured at 0x%lx IRQ %d\n", + cs->hw.njet.base, cs->irq); if (!request_region(cs->hw.njet.base, bytecnt, "Fn_ISDN")) { printk(KERN_WARNING "HiSax: enter:now config port %lx-%lx already in use\n", @@ -368,13 +368,13 @@ static int __devinit en_cs_init_rest(struct IsdnCard *card, setup_Amd7930(cs); cs->hw.njet.last_is0 = 0; - /* macro rByteAMD */ - cs->readisac = &ReadByteAmd7930; - /* macro wByteAMD */ - cs->writeisac = &WriteByteAmd7930; - cs->dc.amd7930.setIrqMask = &enpci_setIrqMask; + /* macro rByteAMD */ + cs->readisac = &ReadByteAmd7930; + /* macro wByteAMD */ + cs->writeisac = &WriteByteAmd7930; + cs->dc.amd7930.setIrqMask = &enpci_setIrqMask; - cs->BC_Read_Reg = &dummyrr; + cs->BC_Read_Reg = &dummyrr; cs->BC_Write_Reg = &dummywr; cs->BC_Send_Data = &netjet_fill_dma; cs->cardmsg = &enpci_card_msg; @@ -398,27 +398,27 @@ setup_enternow_pci(struct IsdnCard *card) #error "not running on big endian machines now" #endif - strcpy(tmp, enternow_pci_rev); + strcpy(tmp, enternow_pci_rev); printk(KERN_INFO "HiSax: Formula-n Europe AG enter:now ISDN PCI driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_ENTERNOW) - return(0); + return (0); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - for ( ;; ) + for (;;) { if ((dev_netjet = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET, - PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { + PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { ret = en_pci_probe(dev_netjet, cs); if (!ret) - return(0); + return (0); } else { - printk(KERN_WARNING "enter:now PCI: No PCI card found\n"); - return(0); + printk(KERN_WARNING "enter:now PCI: No PCI card found\n"); + return (0); } en_cs_init(card, cs); break; } - return en_cs_init_rest(card, cs); + return en_cs_init_rest(card, cs); } diff --git a/drivers/isdn/hisax/fsm.c b/drivers/isdn/hisax/fsm.c index 732ea633758c..1bb291021fdb 100644 --- a/drivers/isdn/hisax/fsm.c +++ b/drivers/isdn/hisax/fsm.c @@ -5,7 +5,7 @@ * Author Karsten Keil * Copyright by Karsten Keil * by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -27,18 +27,18 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount) int i; fsm->jumpmatrix = (FSMFNPTR *) - kzalloc(sizeof (FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL); + kzalloc(sizeof(FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL); if (!fsm->jumpmatrix) return -ENOMEM; - for (i = 0; i < fncount; i++) - if ((fnlist[i].state>=fsm->state_count) || (fnlist[i].event>=fsm->event_count)) { + for (i = 0; i < fncount; i++) + if ((fnlist[i].state >= fsm->state_count) || (fnlist[i].event >= fsm->event_count)) { printk(KERN_ERR "FsmNew Error line %d st(%ld/%ld) ev(%ld/%ld)\n", - i,(long)fnlist[i].state,(long)fsm->state_count, - (long)fnlist[i].event,(long)fsm->event_count); - } else + i, (long)fnlist[i].state, (long)fsm->state_count, + (long)fnlist[i].event, (long)fsm->event_count); + } else fsm->jumpmatrix[fsm->state_count * fnlist[i].event + - fnlist[i].state] = (FSMFNPTR) fnlist[i].routine; + fnlist[i].state] = (FSMFNPTR)fnlist[i].routine; return 0; } @@ -53,24 +53,24 @@ FsmEvent(struct FsmInst *fi, int event, void *arg) { FSMFNPTR r; - if ((fi->state>=fi->fsm->state_count) || (event >= fi->fsm->event_count)) { + if ((fi->state >= fi->fsm->state_count) || (event >= fi->fsm->event_count)) { printk(KERN_ERR "FsmEvent Error st(%ld/%ld) ev(%d/%ld)\n", - (long)fi->state,(long)fi->fsm->state_count,event,(long)fi->fsm->event_count); - return(1); + (long)fi->state, (long)fi->fsm->state_count, event, (long)fi->fsm->event_count); + return (1); } r = fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state]; if (r) { if (fi->debug) fi->printdebug(fi, "State %s Event %s", - fi->fsm->strState[fi->state], - fi->fsm->strEvent[event]); + fi->fsm->strState[fi->state], + fi->fsm->strEvent[event]); r(fi, event, arg); return (0); } else { if (fi->debug) fi->printdebug(fi, "State %s Event %s no routine", - fi->fsm->strState[fi->state], - fi->fsm->strEvent[event]); + fi->fsm->strState[fi->state], + fi->fsm->strEvent[event]); return (!0); } } @@ -81,7 +81,7 @@ FsmChangeState(struct FsmInst *fi, int newstate) fi->state = newstate; if (fi->debug) fi->printdebug(fi, "ChangeState %s", - fi->fsm->strState[newstate]); + fi->fsm->strState[newstate]); } static void @@ -125,7 +125,7 @@ FsmAddTimer(struct FsmTimer *ft, #if FSM_TIMER_DEBUG if (ft->fi->debug) ft->fi->printdebug(ft->fi, "FsmAddTimer %lx %d %d", - (long) ft, millisec, where); + (long) ft, millisec, where); #endif if (timer_pending(&ft->tl)) { @@ -143,13 +143,13 @@ FsmAddTimer(struct FsmTimer *ft, void FsmRestartTimer(struct FsmTimer *ft, - int millisec, int event, void *arg, int where) + int millisec, int event, void *arg, int where) { #if FSM_TIMER_DEBUG if (ft->fi->debug) ft->fi->printdebug(ft->fi, "FsmRestartTimer %lx %d %d", - (long) ft, millisec, where); + (long) ft, millisec, where); #endif if (timer_pending(&ft->tl)) diff --git a/drivers/isdn/hisax/fsm.h b/drivers/isdn/hisax/fsm.h index f02f7da1688d..8c7385619a46 100644 --- a/drivers/isdn/hisax/fsm.h +++ b/drivers/isdn/hisax/fsm.h @@ -5,7 +5,7 @@ * Author Karsten Keil * Copyright by Karsten Keil * by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -18,7 +18,7 @@ struct FsmInst; -typedef void (* FSMFNPTR)(struct FsmInst *, int, void *); +typedef void (*FSMFNPTR)(struct FsmInst *, int, void *); struct Fsm { FSMFNPTR *jumpmatrix; diff --git a/drivers/isdn/hisax/gazel.c b/drivers/isdn/hisax/gazel.c index 353982fc1436..4fef77562554 100644 --- a/drivers/isdn/hisax/gazel.c +++ b/drivers/isdn/hisax/gazel.c @@ -5,7 +5,7 @@ * Author BeWan Systems * based on source code from Karsten Keil * Copyright by BeWan Systems - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -38,7 +38,7 @@ static const char *gazel_revision = "$Revision: 2.19.2.4 $"; #define INT_IPAC_EN 0x3 /* enable IT ipac */ -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static inline u_char @@ -55,13 +55,13 @@ writereg(unsigned int adr, u_short off, u_char data) static inline void -read_fifo(unsigned int adr, u_char * data, int size) +read_fifo(unsigned int adr, u_char *data, int size) { insb(adr, data, size); } static void -write_fifo(unsigned int adr, u_char * data, int size) +write_fifo(unsigned int adr, u_char *data, int size) { outsb(adr, data, size); } @@ -85,14 +85,14 @@ writereg_ipac(unsigned int adr, u_short off, u_char data) static inline void -read_fifo_ipac(unsigned int adr, u_short off, u_char * data, int size) +read_fifo_ipac(unsigned int adr, u_short off, u_char *data, int size) { byteout(adr, off); insb(adr + 4, data, size); } static void -write_fifo_ipac(unsigned int adr, u_short off, u_char * data, int size) +write_fifo_ipac(unsigned int adr, u_short off, u_char *data, int size) { byteout(adr, off); outsb(adr + 4, data, size); @@ -106,13 +106,13 @@ ReadISAC(struct IsdnCardState *cs, u_char offset) u_short off2 = offset; switch (cs->subtyp) { - case R647: - off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); - case R685: - return (readreg(cs->hw.gazel.isac, off2)); - case R753: - case R742: - return (readreg_ipac(cs->hw.gazel.ipac, 0x80 + off2)); + case R647: + off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); + case R685: + return (readreg(cs->hw.gazel.isac, off2)); + case R753: + case R742: + return (readreg_ipac(cs->hw.gazel.ipac, 0x80 + off2)); } return 0; } @@ -123,75 +123,75 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) u_short off2 = offset; switch (cs->subtyp) { - case R647: - off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); - case R685: - writereg(cs->hw.gazel.isac, off2, value); - break; - case R753: - case R742: - writereg_ipac(cs->hw.gazel.ipac, 0x80 + off2, value); - break; + case R647: + off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); + case R685: + writereg(cs->hw.gazel.isac, off2, value); + break; + case R753: + case R742: + writereg_ipac(cs->hw.gazel.ipac, 0x80 + off2, value); + break; } } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { switch (cs->subtyp) { - case R647: - case R685: - read_fifo(cs->hw.gazel.isacfifo, data, size); - break; - case R753: - case R742: - read_fifo_ipac(cs->hw.gazel.ipac, 0x80, data, size); - break; + case R647: + case R685: + read_fifo(cs->hw.gazel.isacfifo, data, size); + break; + case R753: + case R742: + read_fifo_ipac(cs->hw.gazel.ipac, 0x80, data, size); + break; } } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { switch (cs->subtyp) { - case R647: - case R685: - write_fifo(cs->hw.gazel.isacfifo, data, size); - break; - case R753: - case R742: - write_fifo_ipac(cs->hw.gazel.ipac, 0x80, data, size); - break; + case R647: + case R685: + write_fifo(cs->hw.gazel.isacfifo, data, size); + break; + case R753: + case R742: + write_fifo_ipac(cs->hw.gazel.ipac, 0x80, data, size); + break; } } static void -ReadHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size) +ReadHSCXfifo(struct IsdnCardState *cs, int hscx, u_char *data, int size) { switch (cs->subtyp) { - case R647: - case R685: - read_fifo(cs->hw.gazel.hscxfifo[hscx], data, size); - break; - case R753: - case R742: - read_fifo_ipac(cs->hw.gazel.ipac, hscx * 0x40, data, size); - break; + case R647: + case R685: + read_fifo(cs->hw.gazel.hscxfifo[hscx], data, size); + break; + case R753: + case R742: + read_fifo_ipac(cs->hw.gazel.ipac, hscx * 0x40, data, size); + break; } } static void -WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char * data, int size) +WriteHSCXfifo(struct IsdnCardState *cs, int hscx, u_char *data, int size) { switch (cs->subtyp) { - case R647: - case R685: - write_fifo(cs->hw.gazel.hscxfifo[hscx], data, size); - break; - case R753: - case R742: - write_fifo_ipac(cs->hw.gazel.ipac, hscx * 0x40, data, size); - break; + case R647: + case R685: + write_fifo(cs->hw.gazel.hscxfifo[hscx], data, size); + break; + case R753: + case R742: + write_fifo_ipac(cs->hw.gazel.ipac, hscx * 0x40, data, size); + break; } } @@ -201,13 +201,13 @@ ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) u_short off2 = offset; switch (cs->subtyp) { - case R647: - off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); - case R685: - return (readreg(cs->hw.gazel.hscx[hscx], off2)); - case R753: - case R742: - return (readreg_ipac(cs->hw.gazel.ipac, hscx * 0x40 + off2)); + case R647: + off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); + case R685: + return (readreg(cs->hw.gazel.hscx[hscx], off2)); + case R753: + case R742: + return (readreg_ipac(cs->hw.gazel.ipac, hscx * 0x40 + off2)); } return 0; } @@ -218,15 +218,15 @@ WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) u_short off2 = offset; switch (cs->subtyp) { - case R647: - off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); - case R685: - writereg(cs->hw.gazel.hscx[hscx], off2, value); - break; - case R753: - case R742: - writereg_ipac(cs->hw.gazel.ipac, hscx * 0x40 + off2, value); - break; + case R647: + off2 = ((off2 << 8 & 0xf000) | (off2 & 0xf)); + case R685: + writereg(cs->hw.gazel.hscx[hscx], off2, value); + break; + case R753: + case R742: + writereg_ipac(cs->hw.gazel.ipac, hscx * 0x40 + off2, value); + break; } } @@ -279,7 +279,7 @@ gazel_interrupt_ipac(int intno, void *dev_id) u_char ista, val; int count = 0; u_long flags; - + spin_lock_irqsave(&cs->lock, flags); ista = ReadISAC(cs, IPAC_ISTA - 0x80); do { @@ -322,25 +322,25 @@ release_io_gazel(struct IsdnCardState *cs) unsigned int i; switch (cs->subtyp) { - case R647: - for (i = 0x0000; i < 0xC000; i += 0x1000) - release_region(i + cs->hw.gazel.hscx[0], 16); - release_region(0xC000 + cs->hw.gazel.hscx[0], 1); - break; - - case R685: - release_region(cs->hw.gazel.hscx[0], 0x100); - release_region(cs->hw.gazel.cfg_reg, 0x80); - break; - - case R753: - release_region(cs->hw.gazel.ipac, 0x8); - release_region(cs->hw.gazel.cfg_reg, 0x80); - break; - - case R742: - release_region(cs->hw.gazel.ipac, 8); - break; + case R647: + for (i = 0x0000; i < 0xC000; i += 0x1000) + release_region(i + cs->hw.gazel.hscx[0], 16); + release_region(0xC000 + cs->hw.gazel.hscx[0], 1); + break; + + case R685: + release_region(cs->hw.gazel.hscx[0], 0x100); + release_region(cs->hw.gazel.cfg_reg, 0x80); + break; + + case R753: + release_region(cs->hw.gazel.ipac, 0x8); + release_region(cs->hw.gazel.cfg_reg, 0x80); + break; + + case R742: + release_region(cs->hw.gazel.ipac, 8); + break; } } @@ -350,49 +350,49 @@ reset_gazel(struct IsdnCardState *cs) unsigned long plxcntrl, addr = cs->hw.gazel.cfg_reg; switch (cs->subtyp) { - case R647: - writereg(addr, 0, 0); - HZDELAY(10); - writereg(addr, 0, 1); - HZDELAY(2); - break; - case R685: - plxcntrl = inl(addr + PLX_CNTRL); - plxcntrl |= (RESET_9050 + RESET_GAZEL); - outl(plxcntrl, addr + PLX_CNTRL); - plxcntrl &= ~(RESET_9050 + RESET_GAZEL); - HZDELAY(4); - outl(plxcntrl, addr + PLX_CNTRL); - HZDELAY(10); - outb(INT_ISAC_EN + INT_HSCX_EN + INT_PCI_EN, addr + PLX_INCSR); - break; - case R753: - plxcntrl = inl(addr + PLX_CNTRL); - plxcntrl |= (RESET_9050 + RESET_GAZEL); - outl(plxcntrl, addr + PLX_CNTRL); - plxcntrl &= ~(RESET_9050 + RESET_GAZEL); - WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20); - HZDELAY(4); - outl(plxcntrl, addr + PLX_CNTRL); - HZDELAY(10); - WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00); - WriteISAC(cs, IPAC_ACFG - 0x80, 0xff); - WriteISAC(cs, IPAC_AOE - 0x80, 0x0); - WriteISAC(cs, IPAC_MASK - 0x80, 0xff); - WriteISAC(cs, IPAC_CONF - 0x80, 0x1); - outb(INT_IPAC_EN + INT_PCI_EN, addr + PLX_INCSR); - WriteISAC(cs, IPAC_MASK - 0x80, 0xc0); - break; - case R742: - WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20); - HZDELAY(4); - WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00); - WriteISAC(cs, IPAC_ACFG - 0x80, 0xff); - WriteISAC(cs, IPAC_AOE - 0x80, 0x0); - WriteISAC(cs, IPAC_MASK - 0x80, 0xff); - WriteISAC(cs, IPAC_CONF - 0x80, 0x1); - WriteISAC(cs, IPAC_MASK - 0x80, 0xc0); - break; + case R647: + writereg(addr, 0, 0); + HZDELAY(10); + writereg(addr, 0, 1); + HZDELAY(2); + break; + case R685: + plxcntrl = inl(addr + PLX_CNTRL); + plxcntrl |= (RESET_9050 + RESET_GAZEL); + outl(plxcntrl, addr + PLX_CNTRL); + plxcntrl &= ~(RESET_9050 + RESET_GAZEL); + HZDELAY(4); + outl(plxcntrl, addr + PLX_CNTRL); + HZDELAY(10); + outb(INT_ISAC_EN + INT_HSCX_EN + INT_PCI_EN, addr + PLX_INCSR); + break; + case R753: + plxcntrl = inl(addr + PLX_CNTRL); + plxcntrl |= (RESET_9050 + RESET_GAZEL); + outl(plxcntrl, addr + PLX_CNTRL); + plxcntrl &= ~(RESET_9050 + RESET_GAZEL); + WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20); + HZDELAY(4); + outl(plxcntrl, addr + PLX_CNTRL); + HZDELAY(10); + WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00); + WriteISAC(cs, IPAC_ACFG - 0x80, 0xff); + WriteISAC(cs, IPAC_AOE - 0x80, 0x0); + WriteISAC(cs, IPAC_MASK - 0x80, 0xff); + WriteISAC(cs, IPAC_CONF - 0x80, 0x1); + outb(INT_IPAC_EN + INT_PCI_EN, addr + PLX_INCSR); + WriteISAC(cs, IPAC_MASK - 0x80, 0xc0); + break; + case R742: + WriteISAC(cs, IPAC_POTA2 - 0x80, 0x20); + HZDELAY(4); + WriteISAC(cs, IPAC_POTA2 - 0x80, 0x00); + WriteISAC(cs, IPAC_ACFG - 0x80, 0xff); + WriteISAC(cs, IPAC_AOE - 0x80, 0x0); + WriteISAC(cs, IPAC_MASK - 0x80, 0xff); + WriteISAC(cs, IPAC_CONF - 0x80, 0x1); + WriteISAC(cs, IPAC_MASK - 0x80, 0xc0); + break; } return (0); } @@ -403,28 +403,28 @@ Gazel_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_gazel(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_RELEASE: - release_io_gazel(cs); - return (0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 1); - if ((cs->subtyp==R647)||(cs->subtyp==R685)) { - int i; - for (i=0;i<(2+MAX_WAITING_CALLS);i++) { - cs->bcs[i].hw.hscx.tsaxr0 = 0x1f; - cs->bcs[i].hw.hscx.tsaxr1 = 0x23; - } + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_gazel(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_gazel(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 1); + if ((cs->subtyp == R647) || (cs->subtyp == R685)) { + int i; + for (i = 0; i < (2 + MAX_WAITING_CALLS); i++) { + cs->bcs[i].hw.hscx.tsaxr0 = 0x1f; + cs->bcs[i].hw.hscx.tsaxr1 = 0x23; } - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_TEST: - return (0); + } + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } return (0); } @@ -435,49 +435,49 @@ reserve_regions(struct IsdnCard *card, struct IsdnCardState *cs) unsigned int i, j, base = 0, adr = 0, len = 0; switch (cs->subtyp) { - case R647: - base = cs->hw.gazel.hscx[0]; - if (!request_region(adr = (0xC000 + base), len = 1, "gazel")) - goto error; - for (i = 0x0000; i < 0xC000; i += 0x1000) { - if (!request_region(adr = (i + base), len = 16, "gazel")) - goto error; - } - if (i != 0xC000) { - for (j = 0; j < i; j+= 0x1000) - release_region(j + base, 16); - release_region(0xC000 + base, 1); + case R647: + base = cs->hw.gazel.hscx[0]; + if (!request_region(adr = (0xC000 + base), len = 1, "gazel")) + goto error; + for (i = 0x0000; i < 0xC000; i += 0x1000) { + if (!request_region(adr = (i + base), len = 16, "gazel")) goto error; - } - break; + } + if (i != 0xC000) { + for (j = 0; j < i; j += 0x1000) + release_region(j + base, 16); + release_region(0xC000 + base, 1); + goto error; + } + break; - case R685: - if (!request_region(adr = cs->hw.gazel.hscx[0], len = 0x100, "gazel")) - goto error; - if (!request_region(adr = cs->hw.gazel.cfg_reg, len = 0x80, "gazel")) { - release_region(cs->hw.gazel.hscx[0],0x100); - goto error; - } - break; + case R685: + if (!request_region(adr = cs->hw.gazel.hscx[0], len = 0x100, "gazel")) + goto error; + if (!request_region(adr = cs->hw.gazel.cfg_reg, len = 0x80, "gazel")) { + release_region(cs->hw.gazel.hscx[0], 0x100); + goto error; + } + break; - case R753: - if (!request_region(adr = cs->hw.gazel.ipac, len = 0x8, "gazel")) - goto error; - if (!request_region(adr = cs->hw.gazel.cfg_reg, len = 0x80, "gazel")) { - release_region(cs->hw.gazel.ipac, 8); - goto error; - } - break; + case R753: + if (!request_region(adr = cs->hw.gazel.ipac, len = 0x8, "gazel")) + goto error; + if (!request_region(adr = cs->hw.gazel.cfg_reg, len = 0x80, "gazel")) { + release_region(cs->hw.gazel.ipac, 8); + goto error; + } + break; - case R742: - if (!request_region(adr = cs->hw.gazel.ipac, len = 0x8, "gazel")) - goto error; - break; + case R742: + if (!request_region(adr = cs->hw.gazel.ipac, len = 0x8, "gazel")) + goto error; + break; } return 0; - error: +error: printk(KERN_WARNING "Gazel: io ports 0x%x-0x%x already in use\n", adr, adr + len); return 1; @@ -508,24 +508,24 @@ setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs) cs->hw.gazel.hscxfifo[1] = cs->hw.gazel.hscx[1]; switch (cs->subtyp) { - case R647: - printk(KERN_INFO "Gazel: Card ISA R647/R648 found\n"); - cs->dc.isac.adf2 = 0x87; - printk(KERN_INFO - "Gazel: config irq:%d isac:0x%X cfg:0x%X\n", - cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg); - printk(KERN_INFO - "Gazel: hscx A:0x%X hscx B:0x%X\n", - cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]); - - break; - case R742: - printk(KERN_INFO "Gazel: Card ISA R742 found\n"); - test_and_set_bit(HW_IPAC, &cs->HW_Flags); - printk(KERN_INFO - "Gazel: config irq:%d ipac:0x%X\n", - cs->irq, cs->hw.gazel.ipac); - break; + case R647: + printk(KERN_INFO "Gazel: Card ISA R647/R648 found\n"); + cs->dc.isac.adf2 = 0x87; + printk(KERN_INFO + "Gazel: config irq:%d isac:0x%X cfg:0x%X\n", + cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg); + printk(KERN_INFO + "Gazel: hscx A:0x%X hscx B:0x%X\n", + cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]); + + break; + case R742: + printk(KERN_INFO "Gazel: Card ISA R742 found\n"); + test_and_set_bit(HW_IPAC, &cs->HW_Flags); + printk(KERN_INFO + "Gazel: config irq:%d ipac:0x%X\n", + cs->irq, cs->hw.gazel.ipac); + break; } return (0); @@ -547,7 +547,7 @@ setup_gazelpci(struct IsdnCardState *cs) seekcard = PCI_DEVICE_ID_PLX_R685; for (nbseek = 0; nbseek < 4; nbseek++) { if ((dev_tel = hisax_find_pci_device(PCI_VENDOR_ID_PLX, - seekcard, dev_tel))) { + seekcard, dev_tel))) { if (pci_enable_device(dev_tel)) return 1; pci_irq = dev_tel->irq; @@ -559,15 +559,15 @@ setup_gazelpci(struct IsdnCardState *cs) break; else { switch (seekcard) { - case PCI_DEVICE_ID_PLX_R685: - seekcard = PCI_DEVICE_ID_PLX_R753; - break; - case PCI_DEVICE_ID_PLX_R753: - seekcard = PCI_DEVICE_ID_PLX_DJINN_ITOO; - break; - case PCI_DEVICE_ID_PLX_DJINN_ITOO: - seekcard = PCI_DEVICE_ID_PLX_OLITEC; - break; + case PCI_DEVICE_ID_PLX_R685: + seekcard = PCI_DEVICE_ID_PLX_R753; + break; + case PCI_DEVICE_ID_PLX_R753: + seekcard = PCI_DEVICE_ID_PLX_DJINN_ITOO; + break; + case PCI_DEVICE_ID_PLX_DJINN_ITOO: + seekcard = PCI_DEVICE_ID_PLX_OLITEC; + break; } } } @@ -595,27 +595,27 @@ setup_gazelpci(struct IsdnCardState *cs) cs->irq_flags |= IRQF_SHARED; switch (seekcard) { - case PCI_DEVICE_ID_PLX_R685: - printk(KERN_INFO "Gazel: Card PCI R685 found\n"); - cs->subtyp = R685; - cs->dc.isac.adf2 = 0x87; - printk(KERN_INFO - "Gazel: config irq:%d isac:0x%X cfg:0x%X\n", - cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg); - printk(KERN_INFO - "Gazel: hscx A:0x%X hscx B:0x%X\n", - cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]); - break; - case PCI_DEVICE_ID_PLX_R753: - case PCI_DEVICE_ID_PLX_DJINN_ITOO: - case PCI_DEVICE_ID_PLX_OLITEC: - printk(KERN_INFO "Gazel: Card PCI R753 found\n"); - cs->subtyp = R753; - test_and_set_bit(HW_IPAC, &cs->HW_Flags); - printk(KERN_INFO - "Gazel: config irq:%d ipac:0x%X cfg:0x%X\n", - cs->irq, cs->hw.gazel.ipac, cs->hw.gazel.cfg_reg); - break; + case PCI_DEVICE_ID_PLX_R685: + printk(KERN_INFO "Gazel: Card PCI R685 found\n"); + cs->subtyp = R685; + cs->dc.isac.adf2 = 0x87; + printk(KERN_INFO + "Gazel: config irq:%d isac:0x%X cfg:0x%X\n", + cs->irq, cs->hw.gazel.isac, cs->hw.gazel.cfg_reg); + printk(KERN_INFO + "Gazel: hscx A:0x%X hscx B:0x%X\n", + cs->hw.gazel.hscx[0], cs->hw.gazel.hscx[1]); + break; + case PCI_DEVICE_ID_PLX_R753: + case PCI_DEVICE_ID_PLX_DJINN_ITOO: + case PCI_DEVICE_ID_PLX_OLITEC: + printk(KERN_INFO "Gazel: Card PCI R753 found\n"); + cs->subtyp = R753; + test_and_set_bit(HW_IPAC, &cs->HW_Flags); + printk(KERN_INFO + "Gazel: config irq:%d ipac:0x%X cfg:0x%X\n", + cs->irq, cs->hw.gazel.ipac, cs->hw.gazel.cfg_reg); + break; } return (0); @@ -667,23 +667,23 @@ setup_gazel(struct IsdnCard *card) cs->cardmsg = &Gazel_card_msg; switch (cs->subtyp) { - case R647: - case R685: - cs->irq_func = &gazel_interrupt; - ISACVersion(cs, "Gazel:"); - if (HscxVersion(cs, "Gazel:")) { - printk(KERN_WARNING - "Gazel: wrong HSCX versions check IO address\n"); - release_io_gazel(cs); - return (0); - } - break; - case R742: - case R753: - cs->irq_func = &gazel_interrupt_ipac; - val = ReadISAC(cs, IPAC_ID - 0x80); - printk(KERN_INFO "Gazel: IPAC version %x\n", val); - break; + case R647: + case R685: + cs->irq_func = &gazel_interrupt; + ISACVersion(cs, "Gazel:"); + if (HscxVersion(cs, "Gazel:")) { + printk(KERN_WARNING + "Gazel: wrong HSCX versions check IO address\n"); + release_io_gazel(cs); + return (0); + } + break; + case R742: + case R753: + cs->irq_func = &gazel_interrupt_ipac; + val = ReadISAC(cs, IPAC_ID - 0x80); + printk(KERN_INFO "Gazel: IPAC version %x\n", val); + break; } return (1); diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c index 384d5118e325..dea04de8e7ca 100644 --- a/drivers/isdn/hisax/hfc4s8s_l1.c +++ b/drivers/isdn/hisax/hfc4s8s_l1.c @@ -93,32 +93,32 @@ static struct pci_device_id hfc4s8s_ids[] = { .subdevice = 0x08b4, .driver_data = (unsigned long) &((hfc4s8s_param) {CHIP_ID_4S, CLOCKMODE_0, 4, - "HFC-4S Evaluation Board"}), - }, + "HFC-4S Evaluation Board"}), + }, {.vendor = PCI_VENDOR_ID_CCD, .device = PCI_DEVICE_ID_8S, .subvendor = 0x1397, .subdevice = 0x16b8, .driver_data = (unsigned long) &((hfc4s8s_param) {CHIP_ID_8S, CLOCKMODE_0, 8, - "HFC-8S Evaluation Board"}), - }, + "HFC-8S Evaluation Board"}), + }, {.vendor = PCI_VENDOR_ID_CCD, .device = PCI_DEVICE_ID_4S, .subvendor = 0x1397, .subdevice = 0xb520, .driver_data = (unsigned long) &((hfc4s8s_param) {CHIP_ID_4S, CLOCKMODE_1, 4, - "IOB4ST"}), - }, + "IOB4ST"}), + }, {.vendor = PCI_VENDOR_ID_CCD, .device = PCI_DEVICE_ID_8S, .subvendor = 0x1397, .subdevice = 0xb522, .driver_data = (unsigned long) &((hfc4s8s_param) {CHIP_ID_8S, CLOCKMODE_1, 8, - "IOB8ST"}), - }, + "IOB8ST"}), + }, {} }; @@ -203,14 +203,14 @@ typedef struct _hfc4s8s_hw { #ifdef HISAX_HFC4S8S_PCIMEM /* inline functions memory mapped */ /* memory write and dummy IO read to avoid PCI byte merge problems */ -#define Write_hfc8(a,b,c) {(*((volatile u_char *)(a->membase+b)) = c); inb(a->iobase+4);} +#define Write_hfc8(a, b, c) {(*((volatile u_char *)(a->membase + b)) = c); inb(a->iobase + 4);} /* memory write without dummy IO access for fifo data access */ -#define fWrite_hfc8(a,b,c) (*((volatile u_char *)(a->membase+b)) = c) -#define Read_hfc8(a,b) (*((volatile u_char *)(a->membase+b))) -#define Write_hfc16(a,b,c) (*((volatile unsigned short *)(a->membase+b)) = c) -#define Read_hfc16(a,b) (*((volatile unsigned short *)(a->membase+b))) -#define Write_hfc32(a,b,c) (*((volatile unsigned long *)(a->membase+b)) = c) -#define Read_hfc32(a,b) (*((volatile unsigned long *)(a->membase+b))) +#define fWrite_hfc8(a, b, c) (*((volatile u_char *)(a->membase + b)) = c) +#define Read_hfc8(a, b) (*((volatile u_char *)(a->membase + b))) +#define Write_hfc16(a, b, c) (*((volatile unsigned short *)(a->membase + b)) = c) +#define Read_hfc16(a, b) (*((volatile unsigned short *)(a->membase + b))) +#define Write_hfc32(a, b, c) (*((volatile unsigned long *)(a->membase + b)) = c) +#define Read_hfc32(a, b) (*((volatile unsigned long *)(a->membase + b))) #define wait_busy(a) {while ((Read_hfc8(a, R_STATUS) & M_BUSY));} #define PCI_ENA_MEMIO 0x03 @@ -218,87 +218,87 @@ typedef struct _hfc4s8s_hw { /* inline functions io mapped */ static inline void -SetRegAddr(hfc4s8s_hw * a, u_char b) +SetRegAddr(hfc4s8s_hw *a, u_char b) { outb(b, (a->iobase) + 4); } static inline u_char -GetRegAddr(hfc4s8s_hw * a) +GetRegAddr(hfc4s8s_hw *a) { return (inb((volatile u_int) (a->iobase + 4))); } static inline void -Write_hfc8(hfc4s8s_hw * a, u_char b, u_char c) +Write_hfc8(hfc4s8s_hw *a, u_char b, u_char c) { SetRegAddr(a, b); outb(c, a->iobase); } static inline void -fWrite_hfc8(hfc4s8s_hw * a, u_char c) +fWrite_hfc8(hfc4s8s_hw *a, u_char c) { outb(c, a->iobase); } static inline void -Write_hfc16(hfc4s8s_hw * a, u_char b, u_short c) +Write_hfc16(hfc4s8s_hw *a, u_char b, u_short c) { SetRegAddr(a, b); outw(c, a->iobase); } static inline void -Write_hfc32(hfc4s8s_hw * a, u_char b, u_long c) +Write_hfc32(hfc4s8s_hw *a, u_char b, u_long c) { SetRegAddr(a, b); outl(c, a->iobase); } static inline void -fWrite_hfc32(hfc4s8s_hw * a, u_long c) +fWrite_hfc32(hfc4s8s_hw *a, u_long c) { outl(c, a->iobase); } static inline u_char -Read_hfc8(hfc4s8s_hw * a, u_char b) +Read_hfc8(hfc4s8s_hw *a, u_char b) { SetRegAddr(a, b); return (inb((volatile u_int) a->iobase)); } static inline u_char -fRead_hfc8(hfc4s8s_hw * a) +fRead_hfc8(hfc4s8s_hw *a) { return (inb((volatile u_int) a->iobase)); } static inline u_short -Read_hfc16(hfc4s8s_hw * a, u_char b) +Read_hfc16(hfc4s8s_hw *a, u_char b) { SetRegAddr(a, b); return (inw((volatile u_int) a->iobase)); } static inline u_long -Read_hfc32(hfc4s8s_hw * a, u_char b) +Read_hfc32(hfc4s8s_hw *a, u_char b) { SetRegAddr(a, b); return (inl((volatile u_int) a->iobase)); } static inline u_long -fRead_hfc32(hfc4s8s_hw * a) +fRead_hfc32(hfc4s8s_hw *a) { return (inl((volatile u_int) a->iobase)); } static inline void -wait_busy(hfc4s8s_hw * a) +wait_busy(hfc4s8s_hw *a) { SetRegAddr(a, R_STATUS); while (inb((volatile u_int) a->iobase) & M_BUSY); @@ -313,7 +313,7 @@ wait_busy(hfc4s8s_hw * a) /* may be updated by the chip during read */ /******************************************************/ static u_char -Read_hfc8_stable(hfc4s8s_hw * hw, int reg) +Read_hfc8_stable(hfc4s8s_hw *hw, int reg) { u_char ref8; u_char in8; @@ -325,7 +325,7 @@ Read_hfc8_stable(hfc4s8s_hw * hw, int reg) } static int -Read_hfc16_stable(hfc4s8s_hw * hw, int reg) +Read_hfc16_stable(hfc4s8s_hw *hw, int reg) { int ref16; int in16; @@ -349,67 +349,67 @@ dch_l2l1(struct hisax_d_if *iface, int pr, void *arg) switch (pr) { - case (PH_DATA | REQUEST): - if (!l1->enabled) { - dev_kfree_skb(skb); - break; - } - spin_lock_irqsave(&l1->lock, flags); - skb_queue_tail(&l1->d_tx_queue, skb); - if ((skb_queue_len(&l1->d_tx_queue) == 1) && - (l1->tx_cnt <= 0)) { - l1->hw->mr.r_irq_fifo_blx[l1->st_num] |= - 0x10; - spin_unlock_irqrestore(&l1->lock, flags); - schedule_work(&l1->hw->tqueue); - } else - spin_unlock_irqrestore(&l1->lock, flags); + case (PH_DATA | REQUEST): + if (!l1->enabled) { + dev_kfree_skb(skb); break; + } + spin_lock_irqsave(&l1->lock, flags); + skb_queue_tail(&l1->d_tx_queue, skb); + if ((skb_queue_len(&l1->d_tx_queue) == 1) && + (l1->tx_cnt <= 0)) { + l1->hw->mr.r_irq_fifo_blx[l1->st_num] |= + 0x10; + spin_unlock_irqrestore(&l1->lock, flags); + schedule_work(&l1->hw->tqueue); + } else + spin_unlock_irqrestore(&l1->lock, flags); + break; - case (PH_ACTIVATE | REQUEST): - if (!l1->enabled) - break; - if (!l1->nt_mode) { - if (l1->l1_state < 6) { - spin_lock_irqsave(&l1->lock, - flags); - - Write_hfc8(l1->hw, R_ST_SEL, - l1->st_num); - Write_hfc8(l1->hw, A_ST_WR_STA, - 0x60); - mod_timer(&l1->l1_timer, - jiffies + L1_TIMER_T3); - spin_unlock_irqrestore(&l1->lock, - flags); - } else if (l1->l1_state == 7) - l1->d_if.ifc.l1l2(&l1->d_if.ifc, - PH_ACTIVATE | - INDICATION, - NULL); - } else { - if (l1->l1_state != 3) { - spin_lock_irqsave(&l1->lock, - flags); - Write_hfc8(l1->hw, R_ST_SEL, - l1->st_num); - Write_hfc8(l1->hw, A_ST_WR_STA, - 0x60); - spin_unlock_irqrestore(&l1->lock, - flags); - } else if (l1->l1_state == 3) - l1->d_if.ifc.l1l2(&l1->d_if.ifc, - PH_ACTIVATE | - INDICATION, - NULL); - } + case (PH_ACTIVATE | REQUEST): + if (!l1->enabled) break; + if (!l1->nt_mode) { + if (l1->l1_state < 6) { + spin_lock_irqsave(&l1->lock, + flags); + + Write_hfc8(l1->hw, R_ST_SEL, + l1->st_num); + Write_hfc8(l1->hw, A_ST_WR_STA, + 0x60); + mod_timer(&l1->l1_timer, + jiffies + L1_TIMER_T3); + spin_unlock_irqrestore(&l1->lock, + flags); + } else if (l1->l1_state == 7) + l1->d_if.ifc.l1l2(&l1->d_if.ifc, + PH_ACTIVATE | + INDICATION, + NULL); + } else { + if (l1->l1_state != 3) { + spin_lock_irqsave(&l1->lock, + flags); + Write_hfc8(l1->hw, R_ST_SEL, + l1->st_num); + Write_hfc8(l1->hw, A_ST_WR_STA, + 0x60); + spin_unlock_irqrestore(&l1->lock, + flags); + } else if (l1->l1_state == 3) + l1->d_if.ifc.l1l2(&l1->d_if.ifc, + PH_ACTIVATE | + INDICATION, + NULL); + } + break; - default: - printk(KERN_INFO - "HFC-4S/8S: Unknown D-chan cmd 0x%x received, ignored\n", - pr); - break; + default: + printk(KERN_INFO + "HFC-4S/8S: Unknown D-chan cmd 0x%x received, ignored\n", + pr); + break; } if (!l1->enabled) l1->d_if.ifc.l1l2(&l1->d_if.ifc, @@ -430,199 +430,199 @@ bch_l2l1(struct hisax_if *ifc, int pr, void *arg) switch (pr) { - case (PH_DATA | REQUEST): - if (!l1->enabled || (bch->mode == L1_MODE_NULL)) { - dev_kfree_skb(skb); - break; - } - spin_lock_irqsave(&l1->lock, flags); - skb_queue_tail(&bch->tx_queue, skb); - if (!bch->tx_skb && (bch->tx_cnt <= 0)) { - l1->hw->mr.r_irq_fifo_blx[l1->st_num] |= - ((bch->bchan == 1) ? 1 : 4); - spin_unlock_irqrestore(&l1->lock, flags); - schedule_work(&l1->hw->tqueue); - } else - spin_unlock_irqrestore(&l1->lock, flags); + case (PH_DATA | REQUEST): + if (!l1->enabled || (bch->mode == L1_MODE_NULL)) { + dev_kfree_skb(skb); break; + } + spin_lock_irqsave(&l1->lock, flags); + skb_queue_tail(&bch->tx_queue, skb); + if (!bch->tx_skb && (bch->tx_cnt <= 0)) { + l1->hw->mr.r_irq_fifo_blx[l1->st_num] |= + ((bch->bchan == 1) ? 1 : 4); + spin_unlock_irqrestore(&l1->lock, flags); + schedule_work(&l1->hw->tqueue); + } else + spin_unlock_irqrestore(&l1->lock, flags); + break; - case (PH_ACTIVATE | REQUEST): - case (PH_DEACTIVATE | REQUEST): - if (!l1->enabled) - break; - if (pr == (PH_DEACTIVATE | REQUEST)) - mode = L1_MODE_NULL; - - switch (mode) { - case L1_MODE_HDLC: - spin_lock_irqsave(&l1->lock, - flags); - l1->hw->mr.timer_usg_cnt++; - l1->hw->mr. - fifo_slow_timer_service[l1-> - st_num] - |= - ((bch->bchan == - 1) ? 0x2 : 0x8); - Write_hfc8(l1->hw, R_FIFO, - (l1->st_num * 8 + - ((bch->bchan == - 1) ? 0 : 2))); - wait_busy(l1->hw); - Write_hfc8(l1->hw, A_CON_HDLC, 0xc); /* HDLC mode, flag fill, connect ST */ - Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ - Write_hfc8(l1->hw, A_IRQ_MSK, 1); /* enable TX interrupts for hdlc */ - Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ - wait_busy(l1->hw); - - Write_hfc8(l1->hw, R_FIFO, - (l1->st_num * 8 + - ((bch->bchan == - 1) ? 1 : 3))); - wait_busy(l1->hw); - Write_hfc8(l1->hw, A_CON_HDLC, 0xc); /* HDLC mode, flag fill, connect ST */ - Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ - Write_hfc8(l1->hw, A_IRQ_MSK, 1); /* enable RX interrupts for hdlc */ - Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ - - Write_hfc8(l1->hw, R_ST_SEL, - l1->st_num); - l1->hw->mr.r_ctrl0 |= - (bch->bchan & 3); - Write_hfc8(l1->hw, A_ST_CTRL0, - l1->hw->mr.r_ctrl0); - bch->mode = L1_MODE_HDLC; - spin_unlock_irqrestore(&l1->lock, - flags); - - bch->b_if.ifc.l1l2(&bch->b_if.ifc, - PH_ACTIVATE | - INDICATION, - NULL); - break; - - case L1_MODE_TRANS: - spin_lock_irqsave(&l1->lock, - flags); - l1->hw->mr. - fifo_rx_trans_enables[l1-> - st_num] - |= - ((bch->bchan == - 1) ? 0x2 : 0x8); - l1->hw->mr.timer_usg_cnt++; - Write_hfc8(l1->hw, R_FIFO, - (l1->st_num * 8 + - ((bch->bchan == - 1) ? 0 : 2))); - wait_busy(l1->hw); - Write_hfc8(l1->hw, A_CON_HDLC, 0xf); /* Transparent mode, 1 fill, connect ST */ - Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ - Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable TX interrupts */ - Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ - wait_busy(l1->hw); - - Write_hfc8(l1->hw, R_FIFO, - (l1->st_num * 8 + - ((bch->bchan == - 1) ? 1 : 3))); - wait_busy(l1->hw); - Write_hfc8(l1->hw, A_CON_HDLC, 0xf); /* Transparent mode, 1 fill, connect ST */ - Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ - Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable RX interrupts */ - Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ - - Write_hfc8(l1->hw, R_ST_SEL, - l1->st_num); - l1->hw->mr.r_ctrl0 |= - (bch->bchan & 3); - Write_hfc8(l1->hw, A_ST_CTRL0, - l1->hw->mr.r_ctrl0); - bch->mode = L1_MODE_TRANS; - spin_unlock_irqrestore(&l1->lock, - flags); - - bch->b_if.ifc.l1l2(&bch->b_if.ifc, - PH_ACTIVATE | - INDICATION, - NULL); - break; - - default: - if (bch->mode == L1_MODE_NULL) - break; - spin_lock_irqsave(&l1->lock, - flags); - l1->hw->mr. - fifo_slow_timer_service[l1-> - st_num] - &= - ~((bch->bchan == - 1) ? 0x3 : 0xc); - l1->hw->mr. - fifo_rx_trans_enables[l1-> - st_num] - &= - ~((bch->bchan == - 1) ? 0x3 : 0xc); - l1->hw->mr.timer_usg_cnt--; - Write_hfc8(l1->hw, R_FIFO, - (l1->st_num * 8 + - ((bch->bchan == - 1) ? 0 : 2))); - wait_busy(l1->hw); - Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable TX interrupts */ - wait_busy(l1->hw); - Write_hfc8(l1->hw, R_FIFO, - (l1->st_num * 8 + - ((bch->bchan == - 1) ? 1 : 3))); - wait_busy(l1->hw); - Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable RX interrupts */ - Write_hfc8(l1->hw, R_ST_SEL, - l1->st_num); - l1->hw->mr.r_ctrl0 &= - ~(bch->bchan & 3); - Write_hfc8(l1->hw, A_ST_CTRL0, - l1->hw->mr.r_ctrl0); - spin_unlock_irqrestore(&l1->lock, - flags); - - bch->mode = L1_MODE_NULL; - bch->b_if.ifc.l1l2(&bch->b_if.ifc, - PH_DEACTIVATE | - INDICATION, - NULL); - if (bch->tx_skb) { - dev_kfree_skb(bch->tx_skb); - bch->tx_skb = NULL; - } - if (bch->rx_skb) { - dev_kfree_skb(bch->rx_skb); - bch->rx_skb = NULL; - } - skb_queue_purge(&bch->tx_queue); - bch->tx_cnt = 0; - bch->rx_ptr = NULL; - break; - } + case (PH_ACTIVATE | REQUEST): + case (PH_DEACTIVATE | REQUEST): + if (!l1->enabled) + break; + if (pr == (PH_DEACTIVATE | REQUEST)) + mode = L1_MODE_NULL; + + switch (mode) { + case L1_MODE_HDLC: + spin_lock_irqsave(&l1->lock, + flags); + l1->hw->mr.timer_usg_cnt++; + l1->hw->mr. + fifo_slow_timer_service[l1-> + st_num] + |= + ((bch->bchan == + 1) ? 0x2 : 0x8); + Write_hfc8(l1->hw, R_FIFO, + (l1->st_num * 8 + + ((bch->bchan == + 1) ? 0 : 2))); + wait_busy(l1->hw); + Write_hfc8(l1->hw, A_CON_HDLC, 0xc); /* HDLC mode, flag fill, connect ST */ + Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ + Write_hfc8(l1->hw, A_IRQ_MSK, 1); /* enable TX interrupts for hdlc */ + Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ + wait_busy(l1->hw); - /* timer is only used when at least one b channel */ - /* is set up to transparent mode */ - if (l1->hw->mr.timer_usg_cnt) { - Write_hfc8(l1->hw, R_IRQMSK_MISC, - M_TI_IRQMSK); - } else { - Write_hfc8(l1->hw, R_IRQMSK_MISC, 0); - } + Write_hfc8(l1->hw, R_FIFO, + (l1->st_num * 8 + + ((bch->bchan == + 1) ? 1 : 3))); + wait_busy(l1->hw); + Write_hfc8(l1->hw, A_CON_HDLC, 0xc); /* HDLC mode, flag fill, connect ST */ + Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ + Write_hfc8(l1->hw, A_IRQ_MSK, 1); /* enable RX interrupts for hdlc */ + Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ + + Write_hfc8(l1->hw, R_ST_SEL, + l1->st_num); + l1->hw->mr.r_ctrl0 |= + (bch->bchan & 3); + Write_hfc8(l1->hw, A_ST_CTRL0, + l1->hw->mr.r_ctrl0); + bch->mode = L1_MODE_HDLC; + spin_unlock_irqrestore(&l1->lock, + flags); + + bch->b_if.ifc.l1l2(&bch->b_if.ifc, + PH_ACTIVATE | + INDICATION, + NULL); + break; + case L1_MODE_TRANS: + spin_lock_irqsave(&l1->lock, + flags); + l1->hw->mr. + fifo_rx_trans_enables[l1-> + st_num] + |= + ((bch->bchan == + 1) ? 0x2 : 0x8); + l1->hw->mr.timer_usg_cnt++; + Write_hfc8(l1->hw, R_FIFO, + (l1->st_num * 8 + + ((bch->bchan == + 1) ? 0 : 2))); + wait_busy(l1->hw); + Write_hfc8(l1->hw, A_CON_HDLC, 0xf); /* Transparent mode, 1 fill, connect ST */ + Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ + Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable TX interrupts */ + Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ + wait_busy(l1->hw); + + Write_hfc8(l1->hw, R_FIFO, + (l1->st_num * 8 + + ((bch->bchan == + 1) ? 1 : 3))); + wait_busy(l1->hw); + Write_hfc8(l1->hw, A_CON_HDLC, 0xf); /* Transparent mode, 1 fill, connect ST */ + Write_hfc8(l1->hw, A_SUBCH_CFG, 0); /* 8 bits */ + Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable RX interrupts */ + Write_hfc8(l1->hw, A_INC_RES_FIFO, 2); /* reset fifo */ + + Write_hfc8(l1->hw, R_ST_SEL, + l1->st_num); + l1->hw->mr.r_ctrl0 |= + (bch->bchan & 3); + Write_hfc8(l1->hw, A_ST_CTRL0, + l1->hw->mr.r_ctrl0); + bch->mode = L1_MODE_TRANS; + spin_unlock_irqrestore(&l1->lock, + flags); + + bch->b_if.ifc.l1l2(&bch->b_if.ifc, + PH_ACTIVATE | + INDICATION, + NULL); break; default: - printk(KERN_INFO - "HFC-4S/8S: Unknown B-chan cmd 0x%x received, ignored\n", - pr); + if (bch->mode == L1_MODE_NULL) + break; + spin_lock_irqsave(&l1->lock, + flags); + l1->hw->mr. + fifo_slow_timer_service[l1-> + st_num] + &= + ~((bch->bchan == + 1) ? 0x3 : 0xc); + l1->hw->mr. + fifo_rx_trans_enables[l1-> + st_num] + &= + ~((bch->bchan == + 1) ? 0x3 : 0xc); + l1->hw->mr.timer_usg_cnt--; + Write_hfc8(l1->hw, R_FIFO, + (l1->st_num * 8 + + ((bch->bchan == + 1) ? 0 : 2))); + wait_busy(l1->hw); + Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable TX interrupts */ + wait_busy(l1->hw); + Write_hfc8(l1->hw, R_FIFO, + (l1->st_num * 8 + + ((bch->bchan == + 1) ? 1 : 3))); + wait_busy(l1->hw); + Write_hfc8(l1->hw, A_IRQ_MSK, 0); /* disable RX interrupts */ + Write_hfc8(l1->hw, R_ST_SEL, + l1->st_num); + l1->hw->mr.r_ctrl0 &= + ~(bch->bchan & 3); + Write_hfc8(l1->hw, A_ST_CTRL0, + l1->hw->mr.r_ctrl0); + spin_unlock_irqrestore(&l1->lock, + flags); + + bch->mode = L1_MODE_NULL; + bch->b_if.ifc.l1l2(&bch->b_if.ifc, + PH_DEACTIVATE | + INDICATION, + NULL); + if (bch->tx_skb) { + dev_kfree_skb(bch->tx_skb); + bch->tx_skb = NULL; + } + if (bch->rx_skb) { + dev_kfree_skb(bch->rx_skb); + bch->rx_skb = NULL; + } + skb_queue_purge(&bch->tx_queue); + bch->tx_cnt = 0; + bch->rx_ptr = NULL; break; + } + + /* timer is only used when at least one b channel */ + /* is set up to transparent mode */ + if (l1->hw->mr.timer_usg_cnt) { + Write_hfc8(l1->hw, R_IRQMSK_MISC, + M_TI_IRQMSK); + } else { + Write_hfc8(l1->hw, R_IRQMSK_MISC, 0); + } + + break; + + default: + printk(KERN_INFO + "HFC-4S/8S: Unknown B-chan cmd 0x%x received, ignored\n", + pr); + break; } if (!l1->enabled) bch->b_if.ifc.l1l2(&bch->b_if.ifc, @@ -742,7 +742,7 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech) #ifdef HISAX_HFC4S8S_PCIMEM Read_hfc8(l1p->hw, A_FIFO_DATA0); #else - fRead_hfc8(l1p->hw); + fRead_hfc8(l1p->hw); #endif Write_hfc8(l1p->hw, A_INC_RES_FIFO, 1); @@ -760,7 +760,7 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech) while (z1 >= 4) { #ifdef HISAX_HFC4S8S_PCIMEM *((unsigned long *) cp) = - Read_hfc32(l1p->hw, A_FIFO_DATA0); + Read_hfc32(l1p->hw, A_FIFO_DATA0); #else *((unsigned long *) cp) = fRead_hfc32(l1p->hw); #endif @@ -772,7 +772,7 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech) #ifdef HISAX_HFC4S8S_PCIMEM *cp++ = Read_hfc8(l1p->hw, A_FIFO_DATA0); #else - *cp++ = fRead_hfc8(l1p->hw); + *cp++ = fRead_hfc8(l1p->hw); #endif Write_hfc8(l1p->hw, A_INC_RES_FIFO, 1); /* increment f counter */ @@ -866,10 +866,10 @@ rx_b_frame(struct hfc4s8s_btype *bch) while (z1 >= 4) { #ifdef HISAX_HFC4S8S_PCIMEM *((unsigned long *) bch->rx_ptr) = - Read_hfc32(l1->hw, A_FIFO_DATA0); + Read_hfc32(l1->hw, A_FIFO_DATA0); #else *((unsigned long *) bch->rx_ptr) = - fRead_hfc32(l1->hw); + fRead_hfc32(l1->hw); #endif bch->rx_ptr += 4; z1 -= 4; @@ -879,7 +879,7 @@ rx_b_frame(struct hfc4s8s_btype *bch) #ifdef HISAX_HFC4S8S_PCIMEM *(bch->rx_ptr++) = Read_hfc8(l1->hw, A_FIFO_DATA0); #else - *(bch->rx_ptr++) = fRead_hfc8(l1->hw); + *(bch->rx_ptr++) = fRead_hfc8(l1->hw); #endif if (hdlc_complete) { @@ -996,7 +996,7 @@ tx_b_frame(struct hfc4s8s_btype *bch) if (bch->mode == L1_MODE_HDLC) { hdlc_num = Read_hfc8(l1->hw, A_F1) & MAX_F_CNT; hdlc_num -= - (Read_hfc8_stable(l1->hw, A_F2) & MAX_F_CNT); + (Read_hfc8_stable(l1->hw, A_F2) & MAX_F_CNT); if (hdlc_num < 0) hdlc_num += 16; if (hdlc_num >= 15) @@ -1008,7 +1008,7 @@ tx_b_frame(struct hfc4s8s_btype *bch) if (!(skb = skb_dequeue(&bch->tx_queue))) { l1->hw->mr.fifo_slow_timer_service[l1-> st_num] - &= ~((bch->bchan == 1) ? 1 : 4); + &= ~((bch->bchan == 1) ? 1 : 4); break; /* list empty */ } bch->tx_skb = skb; @@ -1017,10 +1017,10 @@ tx_b_frame(struct hfc4s8s_btype *bch) if (!hdlc_num) l1->hw->mr.fifo_slow_timer_service[l1->st_num] |= - ((bch->bchan == 1) ? 1 : 4); + ((bch->bchan == 1) ? 1 : 4); else l1->hw->mr.fifo_slow_timer_service[l1->st_num] &= - ~((bch->bchan == 1) ? 1 : 4); + ~((bch->bchan == 1) ? 1 : 4); max = Read_hfc16_stable(l1->hw, A_Z2); max -= Read_hfc16(l1->hw, A_Z1); @@ -1055,7 +1055,7 @@ tx_b_frame(struct hfc4s8s_btype *bch) #ifdef HISAX_HFC4S8S_PCIMEM fWrite_hfc8(l1->hw, A_FIFO_DATA0, *cp++); #else - fWrite_hfc8(l1->hw, *cp++); + fWrite_hfc8(l1->hw, *cp++); #endif if (bch->tx_cnt >= skb->len) { @@ -1106,8 +1106,8 @@ hfc4s8s_bh(struct work_struct *work) Write_hfc8(l1p->hw, R_ST_SEL, l1p->st_num); l1p->l1_state = - Read_hfc8(l1p->hw, - A_ST_RD_STA) & 0xf; + Read_hfc8(l1p->hw, + A_ST_RD_STA) & 0xf; if ((oldstate == 3) && (l1p->l1_state != 3)) @@ -1123,12 +1123,12 @@ hfc4s8s_bh(struct work_struct *work) del_timer(&l1p->l1_timer); if (l1p->l1_state == 3) { l1p->d_if.ifc. - l1l2(&l1p-> - d_if.ifc, - PH_ACTIVATE - | - INDICATION, - NULL); + l1l2(&l1p-> + d_if.ifc, + PH_ACTIVATE + | + INDICATION, + NULL); } } else { /* allow transition */ @@ -1148,8 +1148,8 @@ hfc4s8s_bh(struct work_struct *work) Write_hfc8(l1p->hw, R_ST_SEL, l1p->st_num); l1p->l1_state = - Read_hfc8(l1p->hw, - A_ST_RD_STA) & 0xf; + Read_hfc8(l1p->hw, + A_ST_RD_STA) & 0xf; if (((l1p->l1_state == 3) && ((oldstate == 7) || @@ -1165,26 +1165,26 @@ hfc4s8s_bh(struct work_struct *work) del_timer(&l1p-> l1_timer); l1p->d_if.ifc. - l1l2(&l1p-> - d_if.ifc, - PH_ACTIVATE - | - INDICATION, - NULL); + l1l2(&l1p-> + d_if.ifc, + PH_ACTIVATE + | + INDICATION, + NULL); tx_d_frame(l1p); } if (l1p->l1_state == 3) { if (oldstate != 3) l1p->d_if. - ifc. - l1l2 - (&l1p-> - d_if. - ifc, - PH_DEACTIVATE - | - INDICATION, - NULL); + ifc. + l1l2 + (&l1p-> + d_if. + ifc, + PH_DEACTIVATE + | + INDICATION, + NULL); } } printk(KERN_INFO @@ -1209,8 +1209,8 @@ hfc4s8s_bh(struct work_struct *work) *fifo_stat |= hw->mr.fifo_rx_trans_enables[idx]; if (hw->fifo_sched_cnt <= 0) { *fifo_stat |= - hw->mr.fifo_slow_timer_service[l1p-> - st_num]; + hw->mr.fifo_slow_timer_service[l1p-> + st_num]; } } /* ignore fifo 6 (TX E fifo) */ @@ -1288,10 +1288,10 @@ hfc4s8s_interrupt(int intno, void *dev_id) /* Layer 1 State change */ hw->mr.r_irq_statech |= - (Read_hfc8(hw, R_SCI) & hw->mr.r_irqmsk_statchg); + (Read_hfc8(hw, R_SCI) & hw->mr.r_irqmsk_statchg); if (! (b = (Read_hfc8(hw, R_STATUS) & (M_MISC_IRQSTA | M_FR_IRQSTA))) -&& !hw->mr.r_irq_statech) { + && !hw->mr.r_irq_statech) { #ifndef HISAX_HFC4S8S_PCIMEM SetRegAddr(hw, old_ioreg); #endif @@ -1332,7 +1332,7 @@ hfc4s8s_interrupt(int intno, void *dev_id) /* reset the complete chip, don't release the chips irq but disable it */ /***********************************************************************/ static void -chipreset(hfc4s8s_hw * hw) +chipreset(hfc4s8s_hw *hw) { u_long flags; @@ -1361,7 +1361,7 @@ chipreset(hfc4s8s_hw * hw) /* disable/enable hardware in nt or te mode */ /********************************************/ static void -hfc_hardware_enable(hfc4s8s_hw * hw, int enable, int nt_mode) +hfc_hardware_enable(hfc4s8s_hw *hw, int enable, int nt_mode) { u_long flags; char if_name[40]; @@ -1468,7 +1468,7 @@ hfc_hardware_enable(hfc4s8s_hw * hw, int enable, int nt_mode) /* disable memory mapped ports / io ports */ /******************************************/ static void -release_pci_ports(hfc4s8s_hw * hw) +release_pci_ports(hfc4s8s_hw *hw) { pci_write_config_word(hw->pdev, PCI_COMMAND, 0); #ifdef HISAX_HFC4S8S_PCIMEM @@ -1484,7 +1484,7 @@ release_pci_ports(hfc4s8s_hw * hw) /* enable memory mapped ports / io ports */ /*****************************************/ static void -enable_pci_ports(hfc4s8s_hw * hw) +enable_pci_ports(hfc4s8s_hw *hw) { #ifdef HISAX_HFC4S8S_PCIMEM pci_write_config_word(hw->pdev, PCI_COMMAND, PCI_ENA_MEMIO); @@ -1498,7 +1498,7 @@ enable_pci_ports(hfc4s8s_hw * hw) /* return 0 on success. */ /*************************************/ static int __devinit -setup_instance(hfc4s8s_hw * hw) +setup_instance(hfc4s8s_hw *hw) { int err = -EIO; int i; @@ -1575,7 +1575,7 @@ setup_instance(hfc4s8s_hw * hw) return (0); - out: +out: hw->irq = 0; release_pci_ports(hw); kfree(hw); @@ -1632,7 +1632,7 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent) card_cnt++; return (err); - out: +out: kfree(hw); return (err); } @@ -1660,10 +1660,10 @@ hfc4s8s_remove(struct pci_dev *pdev) } static struct pci_driver hfc4s8s_driver = { - .name = "hfc4s8s_l1", - .probe = hfc4s8s_probe, - .remove = __devexit_p(hfc4s8s_remove), - .id_table = hfc4s8s_ids, + .name = "hfc4s8s_l1", + .probe = hfc4s8s_probe, + .remove = __devexit_p(hfc4s8s_remove), + .id_table = hfc4s8s_ids, }; /**********************/ @@ -1697,7 +1697,7 @@ hfc4s8s_module_init(void) #endif return 0; - out: +out: return (err); } /* hfc4s8s_init_hw */ diff --git a/drivers/isdn/hisax/hfc4s8s_l1.h b/drivers/isdn/hisax/hfc4s8s_l1.h index 9d5d2a56b4e9..6a8f89113d2f 100644 --- a/drivers/isdn/hisax/hfc4s8s_l1.h +++ b/drivers/isdn/hisax/hfc4s8s_l1.h @@ -15,10 +15,10 @@ /* -* include Genero generated HFC-4S/8S header file hfc48scu.h -* for complete register description. This will define _HFC48SCU_H_ -* to prevent redefinitions -*/ + * include Genero generated HFC-4S/8S header file hfc48scu.h + * for complete register description. This will define _HFC48SCU_H_ + * to prevent redefinitions + */ // #include "hfc48scu.h" diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c index a16459a1332c..a756e5cb6871 100644 --- a/drivers/isdn/hisax/hfc_2bds0.c +++ b/drivers/isdn/hisax/hfc_2bds0.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -18,15 +18,15 @@ #include "isdnl1.h" #include /* -#define KDEBUG_DEF -#include "kdebug.h" + #define KDEBUG_DEF + #include "kdebug.h" */ -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static void -dummyf(struct IsdnCardState *cs, u_char * data, int size) +dummyf(struct IsdnCardState *cs, u_char *data, int size) { printk(KERN_WARNING "HiSax: hfcd dummy fifo called\n"); } @@ -37,7 +37,7 @@ ReadReg(struct IsdnCardState *cs, int data, u_char reg) register u_char ret; if (data) { - if (cs->hw.hfcD.cip != reg) { + if (cs->hw.hfcD.cip != reg) { cs->hw.hfcD.cip = reg; byteout(cs->hw.hfcD.addr | 1, reg); } @@ -54,7 +54,7 @@ ReadReg(struct IsdnCardState *cs, int data, u_char reg) static inline void WriteReg(struct IsdnCardState *cs, int data, u_char reg, u_char value) { - if (cs->hw.hfcD.cip != reg) { + if (cs->hw.hfcD.cip != reg) { cs->hw.hfcD.cip = reg; byteout(cs->hw.hfcD.addr | 1, reg); } @@ -71,7 +71,7 @@ WriteReg(struct IsdnCardState *cs, int data, u_char reg, u_char value) static u_char readreghfcd(struct IsdnCardState *cs, u_char offset) { - return(ReadReg(cs, HFCD_DATA, offset)); + return (ReadReg(cs, HFCD_DATA, offset)); } static void @@ -103,7 +103,7 @@ WaitNoBusy(struct IsdnCardState *cs) udelay(1); to--; } - if (!to) + if (!to) printk(KERN_WARNING "HiSax: WaitNoBusy timeout\n"); return (to); } @@ -114,29 +114,29 @@ SelFiFo(struct IsdnCardState *cs, u_char FiFo) u_char cip; if (cs->hw.hfcD.fifo == FiFo) - return(1); - switch(FiFo) { - case 0: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B1; - break; - case 1: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B1; - break; - case 2: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B2; - break; - case 3: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B2; - break; - case 4: cip = HFCD_FIFO | HFCD_Z1 | HFCD_SEND; - break; - case 5: cip = HFCD_FIFO | HFCD_Z1 | HFCD_REC; - break; - default: - debugl1(cs, "SelFiFo Error"); - return(0); + return (1); + switch (FiFo) { + case 0: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B1; + break; + case 1: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B1; + break; + case 2: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B2; + break; + case 3: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B2; + break; + case 4: cip = HFCD_FIFO | HFCD_Z1 | HFCD_SEND; + break; + case 5: cip = HFCD_FIFO | HFCD_Z1 | HFCD_REC; + break; + default: + debugl1(cs, "SelFiFo Error"); + return (0); } cs->hw.hfcD.fifo = FiFo; WaitNoBusy(cs); cs->BC_Write_Reg(cs, HFCD_DATA, cip, 0); WaitForBusy(cs); - return(2); + return (2); } static int @@ -188,7 +188,7 @@ static struct sk_buff int idx; int chksum; u_char stat, cip; - + if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "hfc_empty_fifo"); idx = 0; @@ -252,7 +252,7 @@ static struct sk_buff WaitForBusy(cs); WaitNoBusy(cs); stat = ReadReg(cs, HFCD_DATA, HFCB_FIFO | HFCB_F2_INC | - HFCB_REC | HFCB_CHANNEL(bcs->channel)); + HFCB_REC | HFCB_CHANNEL(bcs->channel)); WaitForBusy(cs); return (skb); } @@ -269,7 +269,7 @@ hfc_fill_fifo(struct BCState *bcs) return; if (bcs->tx_skb->len <= 0) return; - SelFiFo(cs, HFCB_SEND | HFCB_CHANNEL(bcs->channel)); + SelFiFo(cs, HFCB_SEND | HFCB_CHANNEL(bcs->channel)); cip = HFCB_FIFO | HFCB_F1 | HFCB_SEND | HFCB_CHANNEL(bcs->channel); WaitNoBusy(cs); bcs->hw.hfc.f1 = ReadReg(cs, HFCD_DATA, cip); @@ -278,7 +278,7 @@ hfc_fill_fifo(struct BCState *bcs) WaitNoBusy(cs); bcs->hw.hfc.f2 = ReadReg(cs, HFCD_DATA, cip); bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(cs, HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_CHANNEL(bcs->channel)); - if (cs->debug & L1_DEB_HSCX) + if (cs->debug & L1_DEB_HSCX) debugl1(cs, "hfc_fill_fifo %d f1(%d) f2(%d) z1(%x)", bcs->channel, bcs->hw.hfc.f1, bcs->hw.hfc.f2, bcs->hw.hfc.send[bcs->hw.hfc.f1]); @@ -316,8 +316,8 @@ hfc_fill_fifo(struct BCState *bcs) printk(KERN_WARNING "HFC S FIFO channel %d BUSY Error\n", bcs->channel); } else { bcs->tx_cnt -= bcs->tx_skb->len; - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->tx_skb->len; @@ -339,12 +339,12 @@ static void hfc_send_data(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; - + if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { hfc_fill_fifo(bcs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else - debugl1(cs,"send_data %d blocked", bcs->channel); + debugl1(cs, "send_data %d blocked", bcs->channel); } static void @@ -356,10 +356,10 @@ main_rec_2bds0(struct BCState *bcs) int receive, count = 5; struct sk_buff *skb; - Begin: +Begin: count--; if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { - debugl1(cs,"rec_data %d blocked", bcs->channel); + debugl1(cs, "rec_data %d blocked", bcs->channel); return; } SelFiFo(cs, HFCB_REC | HFCB_CHANNEL(bcs->channel)); @@ -386,10 +386,10 @@ main_rec_2bds0(struct BCState *bcs) skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); } - rcnt = f1 -f2; - if (rcnt<0) + rcnt = f1 - f2; + if (rcnt < 0) rcnt += 32; - if (rcnt>1) + if (rcnt > 1) receive = 1; else receive = 0; @@ -397,7 +397,7 @@ main_rec_2bds0(struct BCState *bcs) receive = 0; test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); if (count && receive) - goto Begin; + goto Begin; return; } @@ -412,37 +412,37 @@ mode_2bs0(struct BCState *bcs, int mode, int bc) bcs->mode = mode; bcs->channel = bc; switch (mode) { - case (L1_MODE_NULL): - if (bc) { - cs->hw.hfcD.conn |= 0x18; - cs->hw.hfcD.sctrl &= ~SCTRL_B2_ENA; - } else { - cs->hw.hfcD.conn |= 0x3; - cs->hw.hfcD.sctrl &= ~SCTRL_B1_ENA; - } - break; - case (L1_MODE_TRANS): - if (bc) { - cs->hw.hfcD.ctmt |= 2; - cs->hw.hfcD.conn &= ~0x18; - cs->hw.hfcD.sctrl |= SCTRL_B2_ENA; - } else { - cs->hw.hfcD.ctmt |= 1; - cs->hw.hfcD.conn &= ~0x3; - cs->hw.hfcD.sctrl |= SCTRL_B1_ENA; - } - break; - case (L1_MODE_HDLC): - if (bc) { - cs->hw.hfcD.ctmt &= ~2; - cs->hw.hfcD.conn &= ~0x18; - cs->hw.hfcD.sctrl |= SCTRL_B2_ENA; - } else { - cs->hw.hfcD.ctmt &= ~1; - cs->hw.hfcD.conn &= ~0x3; - cs->hw.hfcD.sctrl |= SCTRL_B1_ENA; - } - break; + case (L1_MODE_NULL): + if (bc) { + cs->hw.hfcD.conn |= 0x18; + cs->hw.hfcD.sctrl &= ~SCTRL_B2_ENA; + } else { + cs->hw.hfcD.conn |= 0x3; + cs->hw.hfcD.sctrl &= ~SCTRL_B1_ENA; + } + break; + case (L1_MODE_TRANS): + if (bc) { + cs->hw.hfcD.ctmt |= 2; + cs->hw.hfcD.conn &= ~0x18; + cs->hw.hfcD.sctrl |= SCTRL_B2_ENA; + } else { + cs->hw.hfcD.ctmt |= 1; + cs->hw.hfcD.conn &= ~0x3; + cs->hw.hfcD.sctrl |= SCTRL_B1_ENA; + } + break; + case (L1_MODE_HDLC): + if (bc) { + cs->hw.hfcD.ctmt &= ~2; + cs->hw.hfcD.conn &= ~0x18; + cs->hw.hfcD.sctrl |= SCTRL_B2_ENA; + } else { + cs->hw.hfcD.ctmt &= ~1; + cs->hw.hfcD.conn &= ~0x3; + cs->hw.hfcD.sctrl |= SCTRL_B1_ENA; + } + break; } WriteReg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl); WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt); @@ -457,53 +457,53 @@ hfc_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; // test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); - } else { + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); + } else { // test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->tx_skb = skb; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - mode_2bs0(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - mode_2bs0(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + bcs->tx_skb = skb; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + mode_2bs0(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + mode_2bs0(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -558,23 +558,23 @@ hfcd_bh(struct work_struct *work) if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { switch (cs->dc.hfcd.ph_state) { - case (0): - l1_msg(cs, HW_RESET | INDICATION, NULL); - break; - case (3): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (8): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (6): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - case (7): - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - default: - break; + case (0): + l1_msg(cs, HW_RESET | INDICATION, NULL); + break; + case (3): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (8): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (6): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + case (7): + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + default: + break; } } if (test_and_clear_bit(D_RCVBUFREADY, &cs->event)) @@ -591,12 +591,12 @@ int receive_dmsg(struct IsdnCardState *cs) int rcnt, z1, z2; u_char stat, cip, f1, f2; int chksum; - int count=5; + int count = 5; u_char *ptr; if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { debugl1(cs, "rec_dmsg blocked"); - return(1); + return (1); } SelFiFo(cs, 4 | HFCD_REC); cip = HFCD_FIFO | HFCD_F1 | HFCD_REC; @@ -682,8 +682,8 @@ int receive_dmsg(struct IsdnCardState *cs) f2 = cs->readisac(cs, cip) & 0xf; } test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - return(1); -} + return (1); +} static void hfc_fill_dfifo(struct IsdnCardState *cs) @@ -750,23 +750,23 @@ hfc_fill_dfifo(struct IsdnCardState *cs) return; } -static +static struct BCState *Sel_BCS(struct IsdnCardState *cs, int channel) { if (cs->bcs[0].mode && (cs->bcs[0].channel == channel)) - return(&cs->bcs[0]); + return (&cs->bcs[0]); else if (cs->bcs[1].mode && (cs->bcs[1].channel == channel)) - return(&cs->bcs[1]); + return (&cs->bcs[1]); else - return(NULL); + return (NULL); } void hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val) { - u_char exval; - struct BCState *bcs; - int count=15; + u_char exval; + struct BCState *bcs; + int count = 15; if (cs->debug & L1_DEB_ISAC) debugl1(cs, "HFCD irq %x %s", val, @@ -789,25 +789,25 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val) } if (cs->hw.hfcD.int_s1 & 0x18) { exval = val; - val = cs->hw.hfcD.int_s1; + val = cs->hw.hfcD.int_s1; cs->hw.hfcD.int_s1 = exval; - } + } if (val & 0x08) { - if (!(bcs=Sel_BCS(cs, 0))) { + if (!(bcs = Sel_BCS(cs, 0))) { if (cs->debug) debugl1(cs, "hfcd spurious 0x08 IRQ"); - } else + } else main_rec_2bds0(bcs); } if (val & 0x10) { - if (!(bcs=Sel_BCS(cs, 1))) { + if (!(bcs = Sel_BCS(cs, 1))) { if (cs->debug) debugl1(cs, "hfcd spurious 0x10 IRQ"); - } else + } else main_rec_2bds0(bcs); } if (val & 0x01) { - if (!(bcs=Sel_BCS(cs, 0))) { + if (!(bcs = Sel_BCS(cs, 0))) { if (cs->debug) debugl1(cs, "hfcd spurious 0x01 IRQ"); } else { @@ -816,14 +816,14 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val) hfc_fill_fifo(bcs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else - debugl1(cs,"fill_data %d blocked", bcs->channel); + debugl1(cs, "fill_data %d blocked", bcs->channel); } else { if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { hfc_fill_fifo(bcs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else - debugl1(cs,"fill_data %d blocked", bcs->channel); + debugl1(cs, "fill_data %d blocked", bcs->channel); } else { schedule_event(bcs, B_XMTBUFREADY); } @@ -831,7 +831,7 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val) } } if (val & 0x02) { - if (!(bcs=Sel_BCS(cs, 1))) { + if (!(bcs = Sel_BCS(cs, 1))) { if (cs->debug) debugl1(cs, "hfcd spurious 0x02 IRQ"); } else { @@ -840,14 +840,14 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val) hfc_fill_fifo(bcs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else - debugl1(cs,"fill_data %d blocked", bcs->channel); + debugl1(cs, "fill_data %d blocked", bcs->channel); } else { if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { hfc_fill_fifo(bcs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else - debugl1(cs,"fill_data %d blocked", bcs->channel); + debugl1(cs, "fill_data %d blocked", bcs->channel); } else { schedule_event(bcs, B_XMTBUFREADY); } @@ -888,7 +888,7 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val) } else schedule_event(cs, D_XMTBUFREADY); } - afterXPR: + afterXPR: if (cs->hw.hfcD.int_s1 && count--) { val = cs->hw.hfcD.int_s1; cs->hw.hfcD.int_s1 = 0; @@ -905,105 +905,105 @@ HFCD_l1hw(struct PStack *st, int pr, void *arg) struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; struct sk_buff *skb = arg; u_long flags; - + switch (pr) { - case (PH_DATA | REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; -#ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { - hfc_fill_dfifo(cs); - test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - } else - debugl1(cs, "hfc_fill_dfifo blocked"); - - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - spin_unlock_irqrestore(&cs->lock, flags); - break; - } - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + Logl2Frame(cs, skb, "PH_DATA", 0); #endif if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { hfc_fill_dfifo(cs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else debugl1(cs, "hfc_fill_dfifo blocked"); + + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->writeisac(cs, HFCD_STATES, HFCD_LOAD_STATE | 3); /* HFC ST 3 */ - udelay(6); - cs->writeisac(cs, HFCD_STATES, 3); /* HFC ST 2 */ - cs->hw.hfcD.mst_m |= HFCD_MASTER; - cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); - cs->writeisac(cs, HFCD_STATES, HFCD_ACTIVATE | HFCD_DO_ACTION); - spin_unlock_irqrestore(&cs->lock, flags); - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - break; - case (HW_ENABLE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->writeisac(cs, HFCD_STATES, HFCD_ACTIVATE | HFCD_DO_ACTION); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_DEACTIVATE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcD.mst_m &= ~HFCD_MASTER; - cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO3 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcD.mst_m |= HFCD_MASTER; - cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - break; - default: - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcd_l1hw unknown pr %4x", pr); - break; + if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { + hfc_fill_dfifo(cs); + test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); + } else + debugl1(cs, "hfc_fill_dfifo blocked"); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG /* psa */ + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "-> PH_REQUEST_PULL"); +#endif + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->writeisac(cs, HFCD_STATES, HFCD_LOAD_STATE | 3); /* HFC ST 3 */ + udelay(6); + cs->writeisac(cs, HFCD_STATES, 3); /* HFC ST 2 */ + cs->hw.hfcD.mst_m |= HFCD_MASTER; + cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); + cs->writeisac(cs, HFCD_STATES, HFCD_ACTIVATE | HFCD_DO_ACTION); + spin_unlock_irqrestore(&cs->lock, flags); + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + break; + case (HW_ENABLE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->writeisac(cs, HFCD_STATES, HFCD_ACTIVATE | HFCD_DO_ACTION); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_DEACTIVATE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcD.mst_m &= ~HFCD_MASTER; + cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO3 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcD.mst_m |= HFCD_MASTER; + cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "hfcd_l1hw unknown pr %4x", pr); + break; } } @@ -1027,11 +1027,11 @@ static unsigned int if (!(send = kmalloc(cnt * sizeof(unsigned int), GFP_ATOMIC))) { printk(KERN_WARNING "HiSax: No memory for hfcd.send\n"); - return(NULL); + return (NULL); } for (i = 0; i < cnt; i++) send[i] = 0x1fff; - return(send); + return (send); } void diff --git a/drivers/isdn/hisax/hfc_2bds0.h b/drivers/isdn/hisax/hfc_2bds0.h index 30f1924db91c..8c7582a3c51e 100644 --- a/drivers/isdn/hisax/hfc_2bds0.h +++ b/drivers/isdn/hisax/hfc_2bds0.h @@ -4,26 +4,26 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ -#define HFCD_CIRM 0x18 +#define HFCD_CIRM 0x18 #define HFCD_CTMT 0x19 -#define HFCD_INT_M1 0x1A -#define HFCD_INT_M2 0x1B -#define HFCD_INT_S1 0x1E -#define HFCD_STAT 0x1C -#define HFCD_STAT_DISB 0x1D -#define HFCD_STATES 0x30 -#define HFCD_SCTRL 0x31 -#define HFCD_TEST 0x32 -#define HFCD_SQ 0x34 -#define HFCD_CLKDEL 0x37 +#define HFCD_INT_M1 0x1A +#define HFCD_INT_M2 0x1B +#define HFCD_INT_S1 0x1E +#define HFCD_STAT 0x1C +#define HFCD_STAT_DISB 0x1D +#define HFCD_STATES 0x30 +#define HFCD_SCTRL 0x31 +#define HFCD_TEST 0x32 +#define HFCD_SQ 0x34 +#define HFCD_CLKDEL 0x37 #define HFCD_MST_MODE 0x2E -#define HFCD_CONN 0x2F +#define HFCD_CONN 0x2F #define HFCD_FIFO 0x80 #define HFCD_Z1 0x10 @@ -79,7 +79,7 @@ #define HFCD_TRANSB1 0x01 /* CIRM (Write) */ -#define HFCD_RESET 0x08 +#define HFCD_RESET 0x08 #define HFCD_MEM8K 0x10 #define HFCD_INTA 0x01 #define HFCD_INTB 0x02 diff --git a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c index 626f85df302b..838531b6a60e 100644 --- a/drivers/isdn/hisax/hfc_2bs0.c +++ b/drivers/isdn/hisax/hfc_2bs0.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -181,9 +181,9 @@ hfc_empty_fifo(struct BCState *bcs, int count) return (NULL); } if (bcs->mode == L1_MODE_TRANS) - count -= 1; + count -= 1; else - count -= 3; + count -= 3; if (!(skb = dev_alloc_skb(count))) printk(KERN_WARNING "HFC: receive out of memory\n"); else { @@ -199,35 +199,35 @@ hfc_empty_fifo(struct BCState *bcs, int count) printk(KERN_WARNING "HFC FIFO channel %d BUSY Error\n", bcs->channel); dev_kfree_skb_any(skb); if (bcs->mode != L1_MODE_TRANS) { - WaitNoBusy(cs); - stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC | - HFC_CHANNEL(bcs->channel)); - WaitForBusy(cs); + WaitNoBusy(cs); + stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC | + HFC_CHANNEL(bcs->channel)); + WaitForBusy(cs); } return (NULL); } if (bcs->mode != L1_MODE_TRANS) { - WaitNoBusy(cs); - chksum = (cs->BC_Read_Reg(cs, HFC_DATA, cip) << 8); - WaitNoBusy(cs); - chksum += cs->BC_Read_Reg(cs, HFC_DATA, cip); - WaitNoBusy(cs); - stat = cs->BC_Read_Reg(cs, HFC_DATA, cip); - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "hfc_empty_fifo %d chksum %x stat %x", - bcs->channel, chksum, stat); - if (stat) { - debugl1(cs, "FIFO CRC error"); - dev_kfree_skb_any(skb); - skb = NULL; + WaitNoBusy(cs); + chksum = (cs->BC_Read_Reg(cs, HFC_DATA, cip) << 8); + WaitNoBusy(cs); + chksum += cs->BC_Read_Reg(cs, HFC_DATA, cip); + WaitNoBusy(cs); + stat = cs->BC_Read_Reg(cs, HFC_DATA, cip); + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "hfc_empty_fifo %d chksum %x stat %x", + bcs->channel, chksum, stat); + if (stat) { + debugl1(cs, "FIFO CRC error"); + dev_kfree_skb_any(skb); + skb = NULL; #ifdef ERROR_STATISTIC - bcs->err_crc++; + bcs->err_crc++; #endif - } - WaitNoBusy(cs); - stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC | - HFC_CHANNEL(bcs->channel)); - WaitForBusy(cs); + } + WaitNoBusy(cs); + stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC | + HFC_CHANNEL(bcs->channel)); + WaitForBusy(cs); } } return (skb); @@ -249,37 +249,37 @@ hfc_fill_fifo(struct BCState *bcs) cip = HFC_CIP | HFC_F1 | HFC_SEND | HFC_CHANNEL(bcs->channel); if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) { - cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip); - WaitForBusy(cs); + cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip); + WaitForBusy(cs); } WaitNoBusy(cs); if (bcs->mode != L1_MODE_TRANS) { - bcs->hw.hfc.f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip); - cip = HFC_CIP | HFC_F2 | HFC_SEND | HFC_CHANNEL(bcs->channel); - WaitNoBusy(cs); - bcs->hw.hfc.f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip); - bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(bcs, HFC_Z1 | HFC_SEND | HFC_CHANNEL(bcs->channel)); - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "hfc_fill_fifo %d f1(%d) f2(%d) z1(%x)", - bcs->channel, bcs->hw.hfc.f1, bcs->hw.hfc.f2, - bcs->hw.hfc.send[bcs->hw.hfc.f1]); - fcnt = bcs->hw.hfc.f1 - bcs->hw.hfc.f2; - if (fcnt < 0) - fcnt += 32; - if (fcnt > 30) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "hfc_fill_fifo more as 30 frames"); - return; - } - count = GetFreeFifoBytes(bcs); - } + bcs->hw.hfc.f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip); + cip = HFC_CIP | HFC_F2 | HFC_SEND | HFC_CHANNEL(bcs->channel); + WaitNoBusy(cs); + bcs->hw.hfc.f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip); + bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(bcs, HFC_Z1 | HFC_SEND | HFC_CHANNEL(bcs->channel)); + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "hfc_fill_fifo %d f1(%d) f2(%d) z1(%x)", + bcs->channel, bcs->hw.hfc.f1, bcs->hw.hfc.f2, + bcs->hw.hfc.send[bcs->hw.hfc.f1]); + fcnt = bcs->hw.hfc.f1 - bcs->hw.hfc.f2; + if (fcnt < 0) + fcnt += 32; + if (fcnt > 30) { + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "hfc_fill_fifo more as 30 frames"); + return; + } + count = GetFreeFifoBytes(bcs); + } else { - WaitForBusy(cs); - z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel)); - z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel)); - count = z1 - z2; - if (count < 0) - count += cs->hw.hfc.fifosize; + WaitForBusy(cs); + z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel)); + z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel)); + count = z1 - z2; + if (count < 0) + count += cs->hw.hfc.fifosize; } /* L1_MODE_TRANS */ if (cs->debug & L1_DEB_HSCX) debugl1(cs, "hfc_fill_fifo %d count(%u/%d)", @@ -305,12 +305,12 @@ hfc_fill_fifo(struct BCState *bcs) dev_kfree_skb_any(bcs->tx_skb); bcs->tx_skb = NULL; if (bcs->mode != L1_MODE_TRANS) { - WaitForBusy(cs); - WaitNoBusy(cs); - cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F1_INC | HFC_SEND | HFC_CHANNEL(bcs->channel)); + WaitForBusy(cs); + WaitNoBusy(cs); + cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F1_INC | HFC_SEND | HFC_CHANNEL(bcs->channel)); } - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (count >= 0)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (count >= 0)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += count; @@ -331,7 +331,7 @@ main_irq_hfc(struct BCState *bcs) int receive, transmit, count = 5; struct sk_buff *skb; - Begin: +Begin: count--; cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel); if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) { @@ -349,7 +349,7 @@ main_irq_hfc(struct BCState *bcs) if (cs->debug & L1_DEB_HSCX) debugl1(cs, "hfc rec %d f1(%d) f2(%d)", bcs->channel, f1, f2); - receive = 1; + receive = 1; } } if (receive || (bcs->mode == L1_MODE_TRANS)) { @@ -407,41 +407,41 @@ mode_hfc(struct BCState *bcs, int mode, int bc) bcs->channel = bc; switch (mode) { - case (L1_MODE_NULL): - if (bc) { - cs->hw.hfc.ctmt &= ~1; - cs->hw.hfc.isac_spcr &= ~0x03; - } - else { - cs->hw.hfc.ctmt &= ~2; - cs->hw.hfc.isac_spcr &= ~0x0c; - } - break; - case (L1_MODE_TRANS): - cs->hw.hfc.ctmt &= ~(1 << bc); /* set HDLC mode */ - cs->BC_Write_Reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt); - hfc_clear_fifo(bcs); /* complete fifo clear */ - if (bc) { - cs->hw.hfc.ctmt |= 1; - cs->hw.hfc.isac_spcr &= ~0x03; - cs->hw.hfc.isac_spcr |= 0x02; - } else { - cs->hw.hfc.ctmt |= 2; - cs->hw.hfc.isac_spcr &= ~0x0c; - cs->hw.hfc.isac_spcr |= 0x08; - } - break; - case (L1_MODE_HDLC): - if (bc) { - cs->hw.hfc.ctmt &= ~1; - cs->hw.hfc.isac_spcr &= ~0x03; - cs->hw.hfc.isac_spcr |= 0x02; - } else { - cs->hw.hfc.ctmt &= ~2; - cs->hw.hfc.isac_spcr &= ~0x0c; - cs->hw.hfc.isac_spcr |= 0x08; - } - break; + case (L1_MODE_NULL): + if (bc) { + cs->hw.hfc.ctmt &= ~1; + cs->hw.hfc.isac_spcr &= ~0x03; + } + else { + cs->hw.hfc.ctmt &= ~2; + cs->hw.hfc.isac_spcr &= ~0x0c; + } + break; + case (L1_MODE_TRANS): + cs->hw.hfc.ctmt &= ~(1 << bc); /* set HDLC mode */ + cs->BC_Write_Reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt); + hfc_clear_fifo(bcs); /* complete fifo clear */ + if (bc) { + cs->hw.hfc.ctmt |= 1; + cs->hw.hfc.isac_spcr &= ~0x03; + cs->hw.hfc.isac_spcr |= 0x02; + } else { + cs->hw.hfc.ctmt |= 2; + cs->hw.hfc.isac_spcr &= ~0x0c; + cs->hw.hfc.isac_spcr |= 0x08; + } + break; + case (L1_MODE_HDLC): + if (bc) { + cs->hw.hfc.ctmt &= ~1; + cs->hw.hfc.isac_spcr &= ~0x03; + cs->hw.hfc.isac_spcr |= 0x02; + } else { + cs->hw.hfc.ctmt &= ~2; + cs->hw.hfc.isac_spcr &= ~0x0c; + cs->hw.hfc.isac_spcr |= 0x08; + } + break; } cs->BC_Write_Reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt); cs->writeisac(cs, ISAC_SPCR, cs->hw.hfc.isac_spcr); @@ -457,53 +457,53 @@ hfc_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); - } else { - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->tx_skb = skb; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - mode_hfc(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - mode_hfc(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); + } else { + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_skb = skb; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + mode_hfc(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + mode_hfc(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } diff --git a/drivers/isdn/hisax/hfc_2bs0.h b/drivers/isdn/hisax/hfc_2bs0.h index 1a50d4a5c968..1510096363dc 100644 --- a/drivers/isdn/hisax/hfc_2bs0.h +++ b/drivers/isdn/hisax/hfc_2bs0.h @@ -4,14 +4,14 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #define HFC_CTMT 0xe0 -#define HFC_CIRM 0xc0 +#define HFC_CIRM 0xc0 #define HFC_CIP 0x80 #define HFC_Z1 0x00 #define HFC_Z2 0x08 @@ -46,7 +46,7 @@ #define HFC_TRANSB1 0x01 /* CIRM (Write) */ -#define HFC_RESET 0x08 +#define HFC_RESET 0x08 #define HFC_MEM8K 0x10 #define HFC_INTA 0x01 #define HFC_INTB 0x02 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c index 0cb0546ead88..334fa90bed8e 100644 --- a/drivers/isdn/hisax/hfc_pci.c +++ b/drivers/isdn/hisax/hfc_pci.c @@ -57,10 +57,10 @@ static const PCI_ENTRY id_list[] = {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A1T, "German telekom", "A1T"}, {PCI_VENDOR_ID_ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575, "Motorola MC145575", "MC145575"}, {PCI_VENDOR_ID_ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0, "Zoltrix", "2BD0"}, - {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E,"Digi International", "Digi DataFire Micro V IOM2 (Europe)"}, - {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E,"Digi International", "Digi DataFire Micro V (Europe)"}, - {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A,"Digi International", "Digi DataFire Micro V IOM2 (North America)"}, - {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A,"Digi International", "Digi DataFire Micro V (North America)"}, + {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, "Digi International", "Digi DataFire Micro V IOM2 (Europe)"}, + {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E, "Digi International", "Digi DataFire Micro V (Europe)"}, + {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, "Digi International", "Digi DataFire Micro V IOM2 (North America)"}, + {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A, "Digi International", "Digi DataFire Micro V (North America)"}, {PCI_VENDOR_ID_SITECOM, PCI_DEVICE_ID_SITECOM_DC105V2, "Sitecom Europe", "DC-105 ISDN PCI"}, {0, 0, NULL, NULL}, }; @@ -73,7 +73,7 @@ static void release_io_hfcpci(struct IsdnCardState *cs) { printk(KERN_INFO "HiSax: release hfcpci at %p\n", - cs->hw.hfcpci.pci_io); + cs->hw.hfcpci.pci_io); cs->hw.hfcpci.int_m2 = 0; /* interrupt output off ! */ Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); Write_hfc(cs, HFCPCI_CIRM, HFCPCI_RESET); /* Reset On */ @@ -84,7 +84,7 @@ release_io_hfcpci(struct IsdnCardState *cs) pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, 0); /* disable memory mapped ports + busmaster */ del_timer(&cs->hw.hfcpci.timer); pci_free_consistent(cs->hw.hfcpci.dev, 0x8000, - cs->hw.hfcpci.fifos, cs->hw.hfcpci.dma); + cs->hw.hfcpci.fifos, cs->hw.hfcpci.dma); cs->hw.hfcpci.fifos = NULL; iounmap((void *)cs->hw.hfcpci.pci_io); } @@ -124,7 +124,7 @@ reset_hfcpci(struct IsdnCardState *cs) Write_hfc(cs, HFCPCI_CTMT, cs->hw.hfcpci.ctmt); cs->hw.hfcpci.int_m1 = HFCPCI_INTS_DTRANS | HFCPCI_INTS_DREC | - HFCPCI_INTS_L1STATE | HFCPCI_INTS_TIMER; + HFCPCI_INTS_L1STATE | HFCPCI_INTS_TIMER; Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); /* Clear already pending ints */ @@ -170,8 +170,8 @@ hfcpci_Timer(struct IsdnCardState *cs) cs->hw.hfcpci.timer.expires = jiffies + 75; /* WD RESET */ /* WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcpci.ctmt | 0x80); - add_timer(&cs->hw.hfcpci.timer); - */ + add_timer(&cs->hw.hfcpci.timer); +*/ } @@ -215,17 +215,17 @@ Sel_BCS(struct IsdnCardState *cs, int channel) /***************************************/ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo) { u_char fifo_state; - bzfifo_type *bzr; + bzfifo_type *bzr; if (fifo) { - bzr = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxbz_b2; + bzr = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxbz_b2; fifo_state = cs->hw.hfcpci.fifo_en & HFCPCI_FIFOEN_B2RX; } else { - bzr = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxbz_b1; + bzr = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxbz_b1; fifo_state = cs->hw.hfcpci.fifo_en & HFCPCI_FIFOEN_B1RX; } if (fifo_state) - cs->hw.hfcpci.fifo_en ^= fifo_state; + cs->hw.hfcpci.fifo_en ^= fifo_state; Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); cs->hw.hfcpci.last_bfifo_cnt[fifo] = 0; bzr->za[MAX_B_FRAMES].z1 = B_FIFO_SIZE + B_SUB_VAL - 1; @@ -233,7 +233,7 @@ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo) bzr->f1 = MAX_B_FRAMES; bzr->f2 = bzr->f1; /* init F pointers to remain constant */ if (fifo_state) - cs->hw.hfcpci.fifo_en |= fifo_state; + cs->hw.hfcpci.fifo_en |= fifo_state; Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); } @@ -242,24 +242,24 @@ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo) /***************************************/ static void hfcpci_clear_fifo_tx(struct IsdnCardState *cs, int fifo) { u_char fifo_state; - bzfifo_type *bzt; + bzfifo_type *bzt; if (fifo) { - bzt = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.txbz_b2; + bzt = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.txbz_b2; fifo_state = cs->hw.hfcpci.fifo_en & HFCPCI_FIFOEN_B2TX; } else { - bzt = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.txbz_b1; + bzt = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.txbz_b1; fifo_state = cs->hw.hfcpci.fifo_en & HFCPCI_FIFOEN_B1TX; } if (fifo_state) - cs->hw.hfcpci.fifo_en ^= fifo_state; + cs->hw.hfcpci.fifo_en ^= fifo_state; Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); bzt->za[MAX_B_FRAMES].z1 = B_FIFO_SIZE + B_SUB_VAL - 1; bzt->za[MAX_B_FRAMES].z2 = bzt->za[MAX_B_FRAMES].z1; bzt->f1 = MAX_B_FRAMES; bzt->f2 = bzt->f1; /* init F pointers to remain constant */ if (fifo_state) - cs->hw.hfcpci.fifo_en |= fifo_state; + cs->hw.hfcpci.fifo_en |= fifo_state; Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); } @@ -268,7 +268,7 @@ static void hfcpci_clear_fifo_tx(struct IsdnCardState *cs, int fifo) /*********************************************/ static struct sk_buff * -hfcpci_empty_fifo(struct BCState *bcs, bzfifo_type * bz, u_char * bdata, int count) +hfcpci_empty_fifo(struct BCState *bcs, bzfifo_type *bz, u_char *bdata, int count) { u_char *ptr, *ptr1, new_f2; struct sk_buff *skb; @@ -395,7 +395,7 @@ receive_dmsg(struct IsdnCardState *cs) /* check for transparent receive data and read max one threshold size if avail */ /*******************************************************************************/ static int -hfcpci_empty_fifo_trans(struct BCState *bcs, bzfifo_type * bz, u_char * bdata) +hfcpci_empty_fifo_trans(struct BCState *bcs, bzfifo_type *bz, u_char *bdata) { unsigned short *z1r, *z2r; int new_z2, fcnt, maxlen; @@ -467,7 +467,7 @@ main_rec_hfcpci(struct BCState *bcs) bdata = ((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxdat_b1; real_fifo = 0; } - Begin: +Begin: count--; if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { debugl1(cs, "rec_data %d blocked", bcs->channel); @@ -494,7 +494,7 @@ main_rec_hfcpci(struct BCState *bcs) if (rcnt < 0) rcnt += MAX_B_FRAMES + 1; if (cs->hw.hfcpci.last_bfifo_cnt[real_fifo] > rcnt + 1) { - rcnt = 0; + rcnt = 0; hfcpci_clear_fifo_rx(cs, real_fifo); } cs->hw.hfcpci.last_bfifo_cnt[real_fifo] = rcnt; @@ -647,8 +647,8 @@ hfcpci_fill_fifo(struct BCState *bcs) debugl1(cs, "hfcpci_fill_fifo_trans %d frame length %d discarded", bcs->channel, bcs->tx_skb->len); - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->tx_skb->len; @@ -710,8 +710,8 @@ hfcpci_fill_fifo(struct BCState *bcs) memcpy(dst, src, count); } bcs->tx_cnt -= bcs->tx_skb->len; - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->tx_skb->len; @@ -736,27 +736,27 @@ dch_nt_l2l1(struct PStack *st, int pr, void *arg) struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; switch (pr) { - case (PH_DATA | REQUEST): - case (PH_PULL | REQUEST): - case (PH_PULL | INDICATION): - st->l1.l1hw(st, pr, arg); - break; - case (PH_ACTIVATE | REQUEST): - st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); - break; - case (PH_TESTLOOP | REQUEST): - if (1 & (long) arg) - debugl1(cs, "PH_TEST_LOOP B1"); - if (2 & (long) arg) - debugl1(cs, "PH_TEST_LOOP B2"); - if (!(3 & (long) arg)) - debugl1(cs, "PH_TEST_LOOP DISABLED"); - st->l1.l1hw(st, HW_TESTLOOP | REQUEST, arg); - break; - default: - if (cs->debug) - debugl1(cs, "dch_nt_l2l1 msg %04X unhandled", pr); - break; + case (PH_DATA | REQUEST): + case (PH_PULL | REQUEST): + case (PH_PULL | INDICATION): + st->l1.l1hw(st, pr, arg); + break; + case (PH_ACTIVATE | REQUEST): + st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); + break; + case (PH_TESTLOOP | REQUEST): + if (1 & (long) arg) + debugl1(cs, "PH_TEST_LOOP B1"); + if (2 & (long) arg) + debugl1(cs, "PH_TEST_LOOP B2"); + if (!(3 & (long) arg)) + debugl1(cs, "PH_TEST_LOOP DISABLED"); + st->l1.l1hw(st, HW_TESTLOOP | REQUEST, arg); + break; + default: + if (cs->debug) + debugl1(cs, "dch_nt_l2l1 msg %04X unhandled", pr); + break; } } @@ -766,14 +766,14 @@ dch_nt_l2l1(struct PStack *st, int pr, void *arg) /* set/reset echo mode */ /***********************/ static int -hfcpci_auxcmd(struct IsdnCardState *cs, isdn_ctrl * ic) +hfcpci_auxcmd(struct IsdnCardState *cs, isdn_ctrl *ic) { u_long flags; int i = *(unsigned int *) ic->parm.num; if ((ic->arg == 98) && (!(cs->hw.hfcpci.int_m1 & (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC + HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC)))) { - spin_lock_irqsave(&cs->lock, flags); + spin_lock_irqsave(&cs->lock, flags); Write_hfc(cs, HFCPCI_CLKDEL, CLKDEL_NT); /* ST-Bit delay for NT-Mode */ Write_hfc(cs, HFCPCI_STATES, HFCPCI_LOAD_STATE | 0); /* HFC ST G0 */ udelay(10); @@ -839,7 +839,7 @@ receive_emsg(struct IsdnCardState *cs) bz = &((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxbz_b2; bdata = ((fifo_area *) (cs->hw.hfcpci.fifos))->b_chans.rxdat_b2; - Begin: +Begin: count--; if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { debugl1(cs, "echo_rec_data blocked"); @@ -1078,7 +1078,7 @@ hfcpci_interrupt(int intno, void *dev_id) } else sched_event_D_pci(cs, D_XMTBUFREADY); } - afterXPR: + afterXPR: if (cs->hw.hfcpci.int_s1 && count--) { val = cs->hw.hfcpci.int_s1; cs->hw.hfcpci.int_s1 = 0; @@ -1110,130 +1110,130 @@ HFCPCI_l1hw(struct PStack *st, int pr, void *arg) struct sk_buff *skb = arg; switch (pr) { - case (PH_DATA | REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); -#ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { - hfcpci_fill_dfifo(cs); - test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - } else - debugl1(cs, "hfcpci_fill_dfifo blocked"); - - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - spin_unlock_irqrestore(&cs->lock, flags); - break; - } - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + Logl2Frame(cs, skb, "PH_DATA", 0); #endif if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { hfcpci_fill_dfifo(cs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else debugl1(cs, "hfcpci_fill_dfifo blocked"); + + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - Write_hfc(cs, HFCPCI_STATES, HFCPCI_LOAD_STATE | 3); /* HFC ST 3 */ - udelay(6); - Write_hfc(cs, HFCPCI_STATES, 3); /* HFC ST 2 */ - cs->hw.hfcpci.mst_m |= HFCPCI_MASTER; - Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); - Write_hfc(cs, HFCPCI_STATES, HFCPCI_ACTIVATE | HFCPCI_DO_ACTION); - spin_unlock_irqrestore(&cs->lock, flags); - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - break; - case (HW_ENABLE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - Write_hfc(cs, HFCPCI_STATES, HFCPCI_DO_ACTION); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_DEACTIVATE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcpci.mst_m &= ~HFCPCI_MASTER; - Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO3 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcpci.mst_m |= HFCPCI_MASTER; - Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); + if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { + hfcpci_fill_dfifo(cs); + test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); + } else + debugl1(cs, "hfcpci_fill_dfifo blocked"); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG /* psa */ + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "-> PH_REQUEST_PULL"); +#endif + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + Write_hfc(cs, HFCPCI_STATES, HFCPCI_LOAD_STATE | 3); /* HFC ST 3 */ + udelay(6); + Write_hfc(cs, HFCPCI_STATES, 3); /* HFC ST 2 */ + cs->hw.hfcpci.mst_m |= HFCPCI_MASTER; + Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); + Write_hfc(cs, HFCPCI_STATES, HFCPCI_ACTIVATE | HFCPCI_DO_ACTION); + spin_unlock_irqrestore(&cs->lock, flags); + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + break; + case (HW_ENABLE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + Write_hfc(cs, HFCPCI_STATES, HFCPCI_DO_ACTION); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_DEACTIVATE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcpci.mst_m &= ~HFCPCI_MASTER; + Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO3 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcpci.mst_m |= HFCPCI_MASTER; + Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_TESTLOOP | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + switch ((long) arg) { + case (1): + Write_hfc(cs, HFCPCI_B1_SSL, 0x80); /* tx slot */ + Write_hfc(cs, HFCPCI_B1_RSL, 0x80); /* rx slot */ + cs->hw.hfcpci.conn = (cs->hw.hfcpci.conn & ~7) | 1; + Write_hfc(cs, HFCPCI_CONNECT, cs->hw.hfcpci.conn); break; - case (HW_TESTLOOP | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - switch ((long) arg) { - case (1): - Write_hfc(cs, HFCPCI_B1_SSL, 0x80); /* tx slot */ - Write_hfc(cs, HFCPCI_B1_RSL, 0x80); /* rx slot */ - cs->hw.hfcpci.conn = (cs->hw.hfcpci.conn & ~7) | 1; - Write_hfc(cs, HFCPCI_CONNECT, cs->hw.hfcpci.conn); - break; - - case (2): - Write_hfc(cs, HFCPCI_B2_SSL, 0x81); /* tx slot */ - Write_hfc(cs, HFCPCI_B2_RSL, 0x81); /* rx slot */ - cs->hw.hfcpci.conn = (cs->hw.hfcpci.conn & ~0x38) | 0x08; - Write_hfc(cs, HFCPCI_CONNECT, cs->hw.hfcpci.conn); - break; - - default: - spin_unlock_irqrestore(&cs->lock, flags); - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcpci_l1hw loop invalid %4lx", (long) arg); - return; - } - cs->hw.hfcpci.trm |= 0x80; /* enable IOM-loop */ - Write_hfc(cs, HFCPCI_TRM, cs->hw.hfcpci.trm); - spin_unlock_irqrestore(&cs->lock, flags); + + case (2): + Write_hfc(cs, HFCPCI_B2_SSL, 0x81); /* tx slot */ + Write_hfc(cs, HFCPCI_B2_RSL, 0x81); /* rx slot */ + cs->hw.hfcpci.conn = (cs->hw.hfcpci.conn & ~0x38) | 0x08; + Write_hfc(cs, HFCPCI_CONNECT, cs->hw.hfcpci.conn); break; + default: + spin_unlock_irqrestore(&cs->lock, flags); if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcpci_l1hw unknown pr %4x", pr); - break; + debugl1(cs, "hfcpci_l1hw loop invalid %4lx", (long) arg); + return; + } + cs->hw.hfcpci.trm |= 0x80; /* enable IOM-loop */ + Write_hfc(cs, HFCPCI_TRM, cs->hw.hfcpci.trm); + spin_unlock_irqrestore(&cs->lock, flags); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "hfcpci_l1hw unknown pr %4x", pr); + break; } } @@ -1295,83 +1295,83 @@ mode_hfcpci(struct BCState *bcs, int mode, int bc) } } switch (mode) { - case (L1_MODE_NULL): - if (bc) { - cs->hw.hfcpci.sctrl &= ~SCTRL_B2_ENA; - cs->hw.hfcpci.sctrl_r &= ~SCTRL_B2_ENA; - } else { - cs->hw.hfcpci.sctrl &= ~SCTRL_B1_ENA; - cs->hw.hfcpci.sctrl_r &= ~SCTRL_B1_ENA; - } - if (fifo2) { - cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B2; - cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); - } else { - cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B1; - cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); - } - break; - case (L1_MODE_TRANS): - hfcpci_clear_fifo_rx(cs, fifo2); - hfcpci_clear_fifo_tx(cs, fifo2); - if (bc) { - cs->hw.hfcpci.sctrl |= SCTRL_B2_ENA; - cs->hw.hfcpci.sctrl_r |= SCTRL_B2_ENA; - } else { - cs->hw.hfcpci.sctrl |= SCTRL_B1_ENA; - cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; - } - if (fifo2) { - cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; - cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); - cs->hw.hfcpci.ctmt |= 2; - cs->hw.hfcpci.conn &= ~0x18; - } else { - cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; - cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); - cs->hw.hfcpci.ctmt |= 1; - cs->hw.hfcpci.conn &= ~0x03; - } - break; - case (L1_MODE_HDLC): - hfcpci_clear_fifo_rx(cs, fifo2); - hfcpci_clear_fifo_tx(cs, fifo2); - if (bc) { - cs->hw.hfcpci.sctrl |= SCTRL_B2_ENA; - cs->hw.hfcpci.sctrl_r |= SCTRL_B2_ENA; - } else { - cs->hw.hfcpci.sctrl |= SCTRL_B1_ENA; - cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; - } - if (fifo2) { - cs->hw.hfcpci.last_bfifo_cnt[1] = 0; - cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; - cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); - cs->hw.hfcpci.ctmt &= ~2; - cs->hw.hfcpci.conn &= ~0x18; - } else { - cs->hw.hfcpci.last_bfifo_cnt[0] = 0; - cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; - cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); - cs->hw.hfcpci.ctmt &= ~1; - cs->hw.hfcpci.conn &= ~0x03; - } - break; - case (L1_MODE_EXTRN): - if (bc) { - cs->hw.hfcpci.conn |= 0x10; - cs->hw.hfcpci.sctrl |= SCTRL_B2_ENA; - cs->hw.hfcpci.sctrl_r |= SCTRL_B2_ENA; - cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B2; - cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); - } else { - cs->hw.hfcpci.conn |= 0x02; - cs->hw.hfcpci.sctrl |= SCTRL_B1_ENA; - cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; - cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B1; - cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); - } - break; + case (L1_MODE_NULL): + if (bc) { + cs->hw.hfcpci.sctrl &= ~SCTRL_B2_ENA; + cs->hw.hfcpci.sctrl_r &= ~SCTRL_B2_ENA; + } else { + cs->hw.hfcpci.sctrl &= ~SCTRL_B1_ENA; + cs->hw.hfcpci.sctrl_r &= ~SCTRL_B1_ENA; + } + if (fifo2) { + cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B2; + cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); + } else { + cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B1; + cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); + } + break; + case (L1_MODE_TRANS): + hfcpci_clear_fifo_rx(cs, fifo2); + hfcpci_clear_fifo_tx(cs, fifo2); + if (bc) { + cs->hw.hfcpci.sctrl |= SCTRL_B2_ENA; + cs->hw.hfcpci.sctrl_r |= SCTRL_B2_ENA; + } else { + cs->hw.hfcpci.sctrl |= SCTRL_B1_ENA; + cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; + } + if (fifo2) { + cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; + cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); + cs->hw.hfcpci.ctmt |= 2; + cs->hw.hfcpci.conn &= ~0x18; + } else { + cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; + cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); + cs->hw.hfcpci.ctmt |= 1; + cs->hw.hfcpci.conn &= ~0x03; + } + break; + case (L1_MODE_HDLC): + hfcpci_clear_fifo_rx(cs, fifo2); + hfcpci_clear_fifo_tx(cs, fifo2); + if (bc) { + cs->hw.hfcpci.sctrl |= SCTRL_B2_ENA; + cs->hw.hfcpci.sctrl_r |= SCTRL_B2_ENA; + } else { + cs->hw.hfcpci.sctrl |= SCTRL_B1_ENA; + cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; + } + if (fifo2) { + cs->hw.hfcpci.last_bfifo_cnt[1] = 0; + cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; + cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); + cs->hw.hfcpci.ctmt &= ~2; + cs->hw.hfcpci.conn &= ~0x18; + } else { + cs->hw.hfcpci.last_bfifo_cnt[0] = 0; + cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; + cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); + cs->hw.hfcpci.ctmt &= ~1; + cs->hw.hfcpci.conn &= ~0x03; + } + break; + case (L1_MODE_EXTRN): + if (bc) { + cs->hw.hfcpci.conn |= 0x10; + cs->hw.hfcpci.sctrl |= SCTRL_B2_ENA; + cs->hw.hfcpci.sctrl_r |= SCTRL_B2_ENA; + cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B2; + cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); + } else { + cs->hw.hfcpci.conn |= 0x02; + cs->hw.hfcpci.sctrl |= SCTRL_B1_ENA; + cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; + cs->hw.hfcpci.fifo_en &= ~HFCPCI_FIFOEN_B1; + cs->hw.hfcpci.int_m1 &= ~(HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); + } + break; } Write_hfc(cs, HFCPCI_SCTRL_E, cs->hw.hfcpci.sctrl_e); Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); @@ -1393,54 +1393,54 @@ hfcpci_l2l1(struct PStack *st, int pr, void *arg) struct sk_buff *skb = arg; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; -// test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - spin_unlock_irqrestore(&bcs->cs->lock, flags); - printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); - break; - } -// test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { bcs->tx_skb = skb; +// test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { spin_unlock_irqrestore(&bcs->cs->lock, flags); + printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - mode_hfcpci(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - mode_hfcpci(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + } +// test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_skb = skb; + bcs->cs->BC_Send_Data(bcs); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + mode_hfcpci(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + mode_hfcpci(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -1510,57 +1510,57 @@ hfcpci_bh(struct work_struct *work) if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { if (!cs->hw.hfcpci.nt_mode) switch (cs->dc.hfcpci.ph_state) { - case (0): - l1_msg(cs, HW_RESET | INDICATION, NULL); - break; - case (3): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (8): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (6): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - case (7): - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - default: - break; - } else { + case (0): + l1_msg(cs, HW_RESET | INDICATION, NULL); + break; + case (3): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (8): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (6): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + case (7): + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + default: + break; + } else { spin_lock_irqsave(&cs->lock, flags); switch (cs->dc.hfcpci.ph_state) { - case (2): - if (cs->hw.hfcpci.nt_timer < 0) { - cs->hw.hfcpci.nt_timer = 0; - cs->hw.hfcpci.int_m1 &= ~HFCPCI_INTS_TIMER; - Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); - /* Clear already pending ints */ - if (Read_hfc(cs, HFCPCI_INT_S1)); - Write_hfc(cs, HFCPCI_STATES, 4 | HFCPCI_LOAD_STATE); - udelay(10); - Write_hfc(cs, HFCPCI_STATES, 4); - cs->dc.hfcpci.ph_state = 4; - } else { - cs->hw.hfcpci.int_m1 |= HFCPCI_INTS_TIMER; - Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); - cs->hw.hfcpci.ctmt &= ~HFCPCI_AUTO_TIMER; - cs->hw.hfcpci.ctmt |= HFCPCI_TIM3_125; - Write_hfc(cs, HFCPCI_CTMT, cs->hw.hfcpci.ctmt | HFCPCI_CLTIMER); - Write_hfc(cs, HFCPCI_CTMT, cs->hw.hfcpci.ctmt | HFCPCI_CLTIMER); - cs->hw.hfcpci.nt_timer = NT_T1_COUNT; - Write_hfc(cs, HFCPCI_STATES, 2 | HFCPCI_NT_G2_G3); /* allow G2 -> G3 transition */ - } - break; - case (1): - case (3): - case (4): + case (2): + if (cs->hw.hfcpci.nt_timer < 0) { cs->hw.hfcpci.nt_timer = 0; cs->hw.hfcpci.int_m1 &= ~HFCPCI_INTS_TIMER; Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); - break; - default: - break; + /* Clear already pending ints */ + if (Read_hfc(cs, HFCPCI_INT_S1)); + Write_hfc(cs, HFCPCI_STATES, 4 | HFCPCI_LOAD_STATE); + udelay(10); + Write_hfc(cs, HFCPCI_STATES, 4); + cs->dc.hfcpci.ph_state = 4; + } else { + cs->hw.hfcpci.int_m1 |= HFCPCI_INTS_TIMER; + Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); + cs->hw.hfcpci.ctmt &= ~HFCPCI_AUTO_TIMER; + cs->hw.hfcpci.ctmt |= HFCPCI_TIM3_125; + Write_hfc(cs, HFCPCI_CTMT, cs->hw.hfcpci.ctmt | HFCPCI_CLTIMER); + Write_hfc(cs, HFCPCI_CTMT, cs->hw.hfcpci.ctmt | HFCPCI_CLTIMER); + cs->hw.hfcpci.nt_timer = NT_T1_COUNT; + Write_hfc(cs, HFCPCI_STATES, 2 | HFCPCI_NT_G2_G3); /* allow G2 -> G3 transition */ + } + break; + case (1): + case (3): + case (4): + cs->hw.hfcpci.nt_timer = 0; + cs->hw.hfcpci.int_m1 &= ~HFCPCI_INTS_TIMER; + Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); + break; + default: + break; } spin_unlock_irqrestore(&cs->lock, flags); } @@ -1602,30 +1602,30 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg) if (cs->debug & L1_DEB_ISAC) debugl1(cs, "HFCPCI: card_msg %x", mt); switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_hfcpci(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_RELEASE: - release_io_hfcpci(cs); - return (0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithfcpci(cs); - reset_hfcpci(cs); - spin_unlock_irqrestore(&cs->lock, flags); - msleep(80); /* Timeout 80ms */ - /* now switch timer interrupt off */ - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcpci.int_m1 &= ~HFCPCI_INTS_TIMER; - Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); - /* reinit mode reg */ - Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_TEST: - return (0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_hfcpci(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_hfcpci(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithfcpci(cs); + reset_hfcpci(cs); + spin_unlock_irqrestore(&cs->lock, flags); + msleep(80); /* Timeout 80ms */ + /* now switch timer interrupt off */ + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcpci.int_m1 &= ~HFCPCI_INTS_TIMER; + Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); + /* reinit mode reg */ + Write_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } return (0); } @@ -1654,13 +1654,13 @@ setup_hfcpci(struct IsdnCard *card) cs->dc.hfcpci.ph_state = 0; cs->hw.hfcpci.fifo = 255; if (cs->typ != ISDN_CTYPE_HFC_PCI) - return(0); + return (0); i = 0; while (id_list[i].vendor_id) { tmp_hfcpci = hisax_find_pci_device(id_list[i].vendor_id, - id_list[i].device_id, - dev_hfcpci); + id_list[i].device_id, + dev_hfcpci); i++; if (tmp_hfcpci) { dma_addr_t dma_mask = DMA_BIT_MASK(32) & ~0x7fffUL; @@ -1668,16 +1668,16 @@ setup_hfcpci(struct IsdnCard *card) continue; if (pci_set_dma_mask(tmp_hfcpci, dma_mask)) { printk(KERN_WARNING - "HiSax hfc_pci: No suitable DMA available.\n"); + "HiSax hfc_pci: No suitable DMA available.\n"); continue; } if (pci_set_consistent_dma_mask(tmp_hfcpci, dma_mask)) { printk(KERN_WARNING - "HiSax hfc_pci: No suitable consistent DMA available.\n"); + "HiSax hfc_pci: No suitable consistent DMA available.\n"); continue; } pci_set_master(tmp_hfcpci); - if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK))) + if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[0].start & PCI_BASE_ADDRESS_IO_MASK))) continue; else break; @@ -1707,17 +1707,17 @@ setup_hfcpci(struct IsdnCard *card) /* Allocate memory for FIFOS */ cs->hw.hfcpci.fifos = pci_alloc_consistent(cs->hw.hfcpci.dev, - 0x8000, &cs->hw.hfcpci.dma); + 0x8000, &cs->hw.hfcpci.dma); if (!cs->hw.hfcpci.fifos) { printk(KERN_WARNING "HFC-PCI: Error allocating FIFO memory!\n"); return 0; } if (cs->hw.hfcpci.dma & 0x7fff) { printk(KERN_WARNING - "HFC-PCI: Error DMA memory not on 32K boundary (%lx)\n", - (u_long)cs->hw.hfcpci.dma); + "HFC-PCI: Error DMA memory not on 32K boundary (%lx)\n", + (u_long)cs->hw.hfcpci.dma); pci_free_consistent(cs->hw.hfcpci.dev, 0x8000, - cs->hw.hfcpci.fifos, cs->hw.hfcpci.dma); + cs->hw.hfcpci.fifos, cs->hw.hfcpci.dma); return 0; } pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u32)cs->hw.hfcpci.dma); diff --git a/drivers/isdn/hisax/hfc_pci.h b/drivers/isdn/hisax/hfc_pci.h index 9ef2981e404e..4e58700a3e61 100644 --- a/drivers/isdn/hisax/hfc_pci.h +++ b/drivers/isdn/hisax/hfc_pci.h @@ -4,7 +4,7 @@ * * Author Werner Cornelius * Copyright by Werner Cornelius - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -55,7 +55,7 @@ #define HFCPCI_MST_EMOD 0xB4 #define HFCPCI_MST_MODE 0xB8 -#define HFCPCI_CONNECT 0xBC +#define HFCPCI_CONNECT 0xBC /* Interrupt and status registers */ @@ -64,22 +64,22 @@ #define HFCPCI_TRM 0x48 #define HFCPCI_B_MODE 0x4C #define HFCPCI_CHIP_ID 0x58 -#define HFCPCI_CIRM 0x60 +#define HFCPCI_CIRM 0x60 #define HFCPCI_CTMT 0x64 -#define HFCPCI_INT_M1 0x68 -#define HFCPCI_INT_M2 0x6C -#define HFCPCI_INT_S1 0x78 -#define HFCPCI_INT_S2 0x7C -#define HFCPCI_STATUS 0x70 +#define HFCPCI_INT_M1 0x68 +#define HFCPCI_INT_M2 0x6C +#define HFCPCI_INT_S1 0x78 +#define HFCPCI_INT_S2 0x7C +#define HFCPCI_STATUS 0x70 /* S/T section registers */ -#define HFCPCI_STATES 0xC0 -#define HFCPCI_SCTRL 0xC4 +#define HFCPCI_STATES 0xC0 +#define HFCPCI_SCTRL 0xC4 #define HFCPCI_SCTRL_E 0xC8 #define HFCPCI_SCTRL_R 0xCC -#define HFCPCI_SQ 0xD0 -#define HFCPCI_CLKDEL 0xDC +#define HFCPCI_SQ 0xD0 +#define HFCPCI_CLKDEL 0xDC #define HFCPCI_B1_REC 0xF0 #define HFCPCI_B1_SEND 0xF0 #define HFCPCI_B2_REC 0xF4 @@ -91,7 +91,7 @@ /* bits in status register (READ) */ #define HFCPCI_PCI_PROC 0x02 -#define HFCPCI_NBUSY 0x04 +#define HFCPCI_NBUSY 0x04 #define HFCPCI_TIMER_ELAP 0x10 #define HFCPCI_STATINT 0x20 #define HFCPCI_FRAMEINT 0x40 @@ -110,7 +110,7 @@ /* bits in CIRM (Write) */ #define HFCPCI_AUX_MSK 0x07 -#define HFCPCI_RESET 0x08 +#define HFCPCI_RESET 0x08 #define HFCPCI_B1_REV 0x40 #define HFCPCI_B2_REV 0x80 @@ -183,53 +183,53 @@ #define D_FREG_MASK 0xF typedef struct { - unsigned short z1; /* Z1 pointer 16 Bit */ - unsigned short z2; /* Z2 pointer 16 Bit */ - } z_type; + unsigned short z1; /* Z1 pointer 16 Bit */ + unsigned short z2; /* Z2 pointer 16 Bit */ +} z_type; typedef struct { - u_char data[D_FIFO_SIZE]; /* FIFO data space */ - u_char fill1[0x20A0-D_FIFO_SIZE]; /* reserved, do not use */ - u_char f1,f2; /* f pointers */ - u_char fill2[0x20C0-0x20A2]; /* reserved, do not use */ - z_type za[MAX_D_FRAMES+1]; /* mask index with D_FREG_MASK for access */ - u_char fill3[0x4000-0x2100]; /* align 16K */ - } dfifo_type; + u_char data[D_FIFO_SIZE]; /* FIFO data space */ + u_char fill1[0x20A0 - D_FIFO_SIZE]; /* reserved, do not use */ + u_char f1, f2; /* f pointers */ + u_char fill2[0x20C0 - 0x20A2]; /* reserved, do not use */ + z_type za[MAX_D_FRAMES + 1]; /* mask index with D_FREG_MASK for access */ + u_char fill3[0x4000 - 0x2100]; /* align 16K */ +} dfifo_type; typedef struct { - z_type za[MAX_B_FRAMES+1]; /* only range 0x0..0x1F allowed */ - u_char f1,f2; /* f pointers */ - u_char fill[0x2100-0x2082]; /* alignment */ - } bzfifo_type; + z_type za[MAX_B_FRAMES + 1]; /* only range 0x0..0x1F allowed */ + u_char f1, f2; /* f pointers */ + u_char fill[0x2100 - 0x2082]; /* alignment */ +} bzfifo_type; typedef union { - struct { - dfifo_type d_tx; /* D-send channel */ - dfifo_type d_rx; /* D-receive channel */ - } d_chan; - struct { - u_char fill1[0x200]; - u_char txdat_b1[B_FIFO_SIZE]; - bzfifo_type txbz_b1; + struct { + dfifo_type d_tx; /* D-send channel */ + dfifo_type d_rx; /* D-receive channel */ + } d_chan; + struct { + u_char fill1[0x200]; + u_char txdat_b1[B_FIFO_SIZE]; + bzfifo_type txbz_b1; - bzfifo_type txbz_b2; - u_char txdat_b2[B_FIFO_SIZE]; + bzfifo_type txbz_b2; + u_char txdat_b2[B_FIFO_SIZE]; - u_char fill2[D_FIFO_SIZE]; + u_char fill2[D_FIFO_SIZE]; - u_char rxdat_b1[B_FIFO_SIZE]; - bzfifo_type rxbz_b1; + u_char rxdat_b1[B_FIFO_SIZE]; + bzfifo_type rxbz_b1; - bzfifo_type rxbz_b2; - u_char rxdat_b2[B_FIFO_SIZE]; - } b_chans; - u_char fill[32768]; - } fifo_area; + bzfifo_type rxbz_b2; + u_char rxdat_b2[B_FIFO_SIZE]; + } b_chans; + u_char fill[32768]; +} fifo_area; -#define Write_hfc(a,b,c) (*(((u_char *)a->hw.hfcpci.pci_io)+b) = c) -#define Read_hfc(a,b) (*(((u_char *)a->hw.hfcpci.pci_io)+b)) +#define Write_hfc(a, b, c) (*(((u_char *)a->hw.hfcpci.pci_io) + b) = c) +#define Read_hfc(a, b) (*(((u_char *)a->hw.hfcpci.pci_io) + b)) extern void main_irq_hcpci(struct BCState *bcs); extern void releasehfcpci(struct IsdnCardState *cs); diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c index 156d7c63d944..4db846be4369 100644 --- a/drivers/isdn/hisax/hfc_sx.c +++ b/drivers/isdn/hisax/hfc_sx.c @@ -5,7 +5,7 @@ * Author Werner Cornelius * based on existing driver for CCD HFC PCI cards * Copyright by Werner Cornelius - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -43,16 +43,16 @@ static const char *hfcsx_revision = "$Revision: 1.12.2.5 $"; #undef CCD_DEMO_BOARD #ifdef CCD_DEMO_BOARD static u_char ccd_sp_irqtab[16] = { - 0,0,0,0,0,2,1,0,0,0,3,4,5,0,0,6 + 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 3, 4, 5, 0, 0, 6 }; #else /* Teles 16.3c */ static u_char ccd_sp_irqtab[16] = { - 0,0,0,7,0,1,0,0,0,2,3,4,5,0,0,6 + 0, 0, 0, 7, 0, 1, 0, 0, 0, 2, 3, 4, 5, 0, 0, 6 }; #endif #define NT_T1_COUNT 20 /* number of 3.125ms interrupts for G2 timeout */ -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) /******************************/ @@ -61,19 +61,19 @@ static u_char ccd_sp_irqtab[16] = { static inline void Write_hfc(struct IsdnCardState *cs, u_char regnum, u_char val) { - byteout(cs->hw.hfcsx.base+1, regnum); + byteout(cs->hw.hfcsx.base + 1, regnum); byteout(cs->hw.hfcsx.base, val); -} +} static inline u_char Read_hfc(struct IsdnCardState *cs, u_char regnum) { - u_char ret; + u_char ret; - byteout(cs->hw.hfcsx.base+1, regnum); + byteout(cs->hw.hfcsx.base + 1, regnum); ret = bytein(cs->hw.hfcsx.base); - return(ret); -} + return (ret); +} /**************************************************/ @@ -82,15 +82,15 @@ Read_hfc(struct IsdnCardState *cs, u_char regnum) static void fifo_select(struct IsdnCardState *cs, u_char fifo) { - if (fifo == cs->hw.hfcsx.last_fifo) - return; /* still valid */ + if (fifo == cs->hw.hfcsx.last_fifo) + return; /* still valid */ - byteout(cs->hw.hfcsx.base+1, HFCSX_FIF_SEL); + byteout(cs->hw.hfcsx.base + 1, HFCSX_FIF_SEL); byteout(cs->hw.hfcsx.base, fifo); - while (bytein(cs->hw.hfcsx.base+1) & 1); /* wait for busy */ + while (bytein(cs->hw.hfcsx.base + 1) & 1); /* wait for busy */ udelay(4); byteout(cs->hw.hfcsx.base, fifo); - while (bytein(cs->hw.hfcsx.base+1) & 1); /* wait for busy */ + while (bytein(cs->hw.hfcsx.base + 1) & 1); /* wait for busy */ } /******************************************/ @@ -101,11 +101,11 @@ static void reset_fifo(struct IsdnCardState *cs, u_char fifo) { fifo_select(cs, fifo); /* first select the fifo */ - byteout(cs->hw.hfcsx.base+1, HFCSX_CIRM); + byteout(cs->hw.hfcsx.base + 1, HFCSX_CIRM); byteout(cs->hw.hfcsx.base, cs->hw.hfcsx.cirm | 0x80); /* reset cmd */ udelay(1); - while (bytein(cs->hw.hfcsx.base+1) & 1); /* wait for busy */ -} + while (bytein(cs->hw.hfcsx.base + 1) & 1); /* wait for busy */ +} /*************************************************************/ @@ -116,56 +116,56 @@ reset_fifo(struct IsdnCardState *cs, u_char fifo) static int write_fifo(struct IsdnCardState *cs, struct sk_buff *skb, u_char fifo, int trans_max) { - unsigned short *msp; - int fifo_size, count, z1, z2; + unsigned short *msp; + int fifo_size, count, z1, z2; u_char f_msk, f1, f2, *src; - if (skb->len <= 0) return(0); - if (fifo & 1) return(0); /* no write fifo */ + if (skb->len <= 0) return (0); + if (fifo & 1) return (0); /* no write fifo */ fifo_select(cs, fifo); if (fifo & 4) { - fifo_size = D_FIFO_SIZE; /* D-channel */ - f_msk = MAX_D_FRAMES; - if (trans_max) return(0); /* only HDLC */ + fifo_size = D_FIFO_SIZE; /* D-channel */ + f_msk = MAX_D_FRAMES; + if (trans_max) return (0); /* only HDLC */ } else { - fifo_size = cs->hw.hfcsx.b_fifo_size; /* B-channel */ - f_msk = MAX_B_FRAMES; + fifo_size = cs->hw.hfcsx.b_fifo_size; /* B-channel */ + f_msk = MAX_B_FRAMES; } - z1 = Read_hfc(cs, HFCSX_FIF_Z1H); + z1 = Read_hfc(cs, HFCSX_FIF_Z1H); z1 = ((z1 << 8) | Read_hfc(cs, HFCSX_FIF_Z1L)); /* Check for transparent mode */ if (trans_max) { - z2 = Read_hfc(cs, HFCSX_FIF_Z2H); - z2 = ((z2 << 8) | Read_hfc(cs, HFCSX_FIF_Z2L)); - count = z2 - z1; - if (count <= 0) - count += fifo_size; /* free bytes */ - if (count < skb->len+1) return(0); /* no room */ - count = fifo_size - count; /* bytes still not send */ - if (count > 2 * trans_max) return(0); /* delay to long */ - count = skb->len; - src = skb->data; - while (count--) - Write_hfc(cs, HFCSX_FIF_DWR, *src++); - return(1); /* success */ + z2 = Read_hfc(cs, HFCSX_FIF_Z2H); + z2 = ((z2 << 8) | Read_hfc(cs, HFCSX_FIF_Z2L)); + count = z2 - z1; + if (count <= 0) + count += fifo_size; /* free bytes */ + if (count < skb->len + 1) return (0); /* no room */ + count = fifo_size - count; /* bytes still not send */ + if (count > 2 * trans_max) return (0); /* delay to long */ + count = skb->len; + src = skb->data; + while (count--) + Write_hfc(cs, HFCSX_FIF_DWR, *src++); + return (1); /* success */ } - msp = ((struct hfcsx_extra *)(cs->hw.hfcsx.extra))->marker; - msp += (((fifo >> 1) & 3) * (MAX_B_FRAMES+1)); + msp = ((struct hfcsx_extra *)(cs->hw.hfcsx.extra))->marker; + msp += (((fifo >> 1) & 3) * (MAX_B_FRAMES + 1)); f1 = Read_hfc(cs, HFCSX_FIF_F1) & f_msk; f2 = Read_hfc(cs, HFCSX_FIF_F2) & f_msk; count = f1 - f2; /* frame count actually buffered */ if (count < 0) count += (f_msk + 1); /* if wrap around */ - if (count > f_msk-1) { - if (cs->debug & L1_DEB_ISAC_FIFO) - debugl1(cs, "hfcsx_write_fifo %d more as %d frames",fifo,f_msk-1); - return(0); + if (count > f_msk - 1) { + if (cs->debug & L1_DEB_ISAC_FIFO) + debugl1(cs, "hfcsx_write_fifo %d more as %d frames", fifo, f_msk - 1); + return (0); } *(msp + f1) = z1; /* remember marker */ @@ -176,134 +176,134 @@ write_fifo(struct IsdnCardState *cs, struct sk_buff *skb, u_char fifo, int trans /* now determine free bytes in FIFO buffer */ count = *(msp + f2) - z1; if (count <= 0) - count += fifo_size; /* count now contains available bytes */ + count += fifo_size; /* count now contains available bytes */ if (cs->debug & L1_DEB_ISAC_FIFO) - debugl1(cs, "hfcsx_write_fifo %d count(%u/%d)", - fifo, skb->len, count); + debugl1(cs, "hfcsx_write_fifo %d count(%u/%d)", + fifo, skb->len, count); if (count < skb->len) { - if (cs->debug & L1_DEB_ISAC_FIFO) - debugl1(cs, "hfcsx_write_fifo %d no fifo mem", fifo); - return(0); + if (cs->debug & L1_DEB_ISAC_FIFO) + debugl1(cs, "hfcsx_write_fifo %d no fifo mem", fifo); + return (0); } - + count = skb->len; /* get frame len */ src = skb->data; /* source pointer */ while (count--) - Write_hfc(cs, HFCSX_FIF_DWR, *src++); - + Write_hfc(cs, HFCSX_FIF_DWR, *src++); + Read_hfc(cs, HFCSX_FIF_INCF1); /* increment F1 */ udelay(1); - while (bytein(cs->hw.hfcsx.base+1) & 1); /* wait for busy */ - return(1); -} + while (bytein(cs->hw.hfcsx.base + 1) & 1); /* wait for busy */ + return (1); +} /***************************************************************/ /* read_fifo reads data to an skb from the desired fifo */ /* if no data is available or an error occurs NULL is returned */ /* the skb is not released in any way. */ /***************************************************************/ -static struct sk_buff * +static struct sk_buff * read_fifo(struct IsdnCardState *cs, u_char fifo, int trans_max) { int fifo_size, count, z1, z2; u_char f_msk, f1, f2, *dst; struct sk_buff *skb; - if (!(fifo & 1)) return(NULL); /* no read fifo */ + if (!(fifo & 1)) return (NULL); /* no read fifo */ fifo_select(cs, fifo); if (fifo & 4) { - fifo_size = D_FIFO_SIZE; /* D-channel */ - f_msk = MAX_D_FRAMES; - if (trans_max) return(NULL); /* only hdlc */ + fifo_size = D_FIFO_SIZE; /* D-channel */ + f_msk = MAX_D_FRAMES; + if (trans_max) return (NULL); /* only hdlc */ } else { - fifo_size = cs->hw.hfcsx.b_fifo_size; /* B-channel */ - f_msk = MAX_B_FRAMES; + fifo_size = cs->hw.hfcsx.b_fifo_size; /* B-channel */ + f_msk = MAX_B_FRAMES; } /* transparent mode */ if (trans_max) { - z1 = Read_hfc(cs, HFCSX_FIF_Z1H); - z1 = ((z1 << 8) | Read_hfc(cs, HFCSX_FIF_Z1L)); - z2 = Read_hfc(cs, HFCSX_FIF_Z2H); - z2 = ((z2 << 8) | Read_hfc(cs, HFCSX_FIF_Z2L)); - /* now determine bytes in actual FIFO buffer */ - count = z1 - z2; - if (count <= 0) - count += fifo_size; /* count now contains buffered bytes */ - count++; - if (count > trans_max) - count = trans_max; /* limit length */ - skb = dev_alloc_skb(count); - if (skb) { - dst = skb_put(skb, count); - while (count--) - *dst++ = Read_hfc(cs, HFCSX_FIF_DRD); - return skb; - } else - return NULL; /* no memory */ + z1 = Read_hfc(cs, HFCSX_FIF_Z1H); + z1 = ((z1 << 8) | Read_hfc(cs, HFCSX_FIF_Z1L)); + z2 = Read_hfc(cs, HFCSX_FIF_Z2H); + z2 = ((z2 << 8) | Read_hfc(cs, HFCSX_FIF_Z2L)); + /* now determine bytes in actual FIFO buffer */ + count = z1 - z2; + if (count <= 0) + count += fifo_size; /* count now contains buffered bytes */ + count++; + if (count > trans_max) + count = trans_max; /* limit length */ + skb = dev_alloc_skb(count); + if (skb) { + dst = skb_put(skb, count); + while (count--) + *dst++ = Read_hfc(cs, HFCSX_FIF_DRD); + return skb; + } else + return NULL; /* no memory */ } do { - f1 = Read_hfc(cs, HFCSX_FIF_F1) & f_msk; - f2 = Read_hfc(cs, HFCSX_FIF_F2) & f_msk; - - if (f1 == f2) return(NULL); /* no frame available */ - - z1 = Read_hfc(cs, HFCSX_FIF_Z1H); - z1 = ((z1 << 8) | Read_hfc(cs, HFCSX_FIF_Z1L)); - z2 = Read_hfc(cs, HFCSX_FIF_Z2H); - z2 = ((z2 << 8) | Read_hfc(cs, HFCSX_FIF_Z2L)); - - if (cs->debug & L1_DEB_ISAC_FIFO) - debugl1(cs, "hfcsx_read_fifo %d f1(%x) f2(%x) z1(f2)(%x) z2(f2)(%x)", - fifo, f1, f2, z1, z2); - /* now determine bytes in actual FIFO buffer */ - count = z1 - z2; - if (count <= 0) - count += fifo_size; /* count now contains buffered bytes */ - count++; - - if (cs->debug & L1_DEB_ISAC_FIFO) - debugl1(cs, "hfcsx_read_fifo %d count %u)", - fifo, count); - - if ((count > fifo_size) || (count < 4)) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcsx_read_fifo %d paket inv. len %d ", fifo , count); - while (count) { - count--; /* empty fifo */ - Read_hfc(cs, HFCSX_FIF_DRD); - } - skb = NULL; - } else - if ((skb = dev_alloc_skb(count - 3))) { - count -= 3; - dst = skb_put(skb, count); - - while (count--) - *dst++ = Read_hfc(cs, HFCSX_FIF_DRD); - - Read_hfc(cs, HFCSX_FIF_DRD); /* CRC 1 */ - Read_hfc(cs, HFCSX_FIF_DRD); /* CRC 2 */ - if (Read_hfc(cs, HFCSX_FIF_DRD)) { - dev_kfree_skb_irq(skb); + f1 = Read_hfc(cs, HFCSX_FIF_F1) & f_msk; + f2 = Read_hfc(cs, HFCSX_FIF_F2) & f_msk; + + if (f1 == f2) return (NULL); /* no frame available */ + + z1 = Read_hfc(cs, HFCSX_FIF_Z1H); + z1 = ((z1 << 8) | Read_hfc(cs, HFCSX_FIF_Z1L)); + z2 = Read_hfc(cs, HFCSX_FIF_Z2H); + z2 = ((z2 << 8) | Read_hfc(cs, HFCSX_FIF_Z2L)); + if (cs->debug & L1_DEB_ISAC_FIFO) - debugl1(cs, "hfcsx_read_fifo %d crc error", fifo); - skb = NULL; - } - } else { - printk(KERN_WARNING "HFC-SX: receive out of memory\n"); - return(NULL); - } - - Read_hfc(cs, HFCSX_FIF_INCF2); /* increment F2 */ - udelay(1); - while (bytein(cs->hw.hfcsx.base+1) & 1); /* wait for busy */ - udelay(1); + debugl1(cs, "hfcsx_read_fifo %d f1(%x) f2(%x) z1(f2)(%x) z2(f2)(%x)", + fifo, f1, f2, z1, z2); + /* now determine bytes in actual FIFO buffer */ + count = z1 - z2; + if (count <= 0) + count += fifo_size; /* count now contains buffered bytes */ + count++; + + if (cs->debug & L1_DEB_ISAC_FIFO) + debugl1(cs, "hfcsx_read_fifo %d count %u)", + fifo, count); + + if ((count > fifo_size) || (count < 4)) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "hfcsx_read_fifo %d paket inv. len %d ", fifo , count); + while (count) { + count--; /* empty fifo */ + Read_hfc(cs, HFCSX_FIF_DRD); + } + skb = NULL; + } else + if ((skb = dev_alloc_skb(count - 3))) { + count -= 3; + dst = skb_put(skb, count); + + while (count--) + *dst++ = Read_hfc(cs, HFCSX_FIF_DRD); + + Read_hfc(cs, HFCSX_FIF_DRD); /* CRC 1 */ + Read_hfc(cs, HFCSX_FIF_DRD); /* CRC 2 */ + if (Read_hfc(cs, HFCSX_FIF_DRD)) { + dev_kfree_skb_irq(skb); + if (cs->debug & L1_DEB_ISAC_FIFO) + debugl1(cs, "hfcsx_read_fifo %d crc error", fifo); + skb = NULL; + } + } else { + printk(KERN_WARNING "HFC-SX: receive out of memory\n"); + return (NULL); + } + + Read_hfc(cs, HFCSX_FIF_INCF2); /* increment F2 */ + udelay(1); + while (bytein(cs->hw.hfcsx.base + 1) & 1); /* wait for busy */ + udelay(1); } while (!skb); /* retry in case of crc error */ - return(skb); -} + return (skb); +} /******************************************/ /* free hardware resources used by driver */ @@ -328,17 +328,17 @@ release_io_hfcsx(struct IsdnCardState *cs) /**********************************************************/ static int set_fifo_size(struct IsdnCardState *cs) { - - if (cs->hw.hfcsx.b_fifo_size) return(1); /* already determined */ + + if (cs->hw.hfcsx.b_fifo_size) return (1); /* already determined */ if ((cs->hw.hfcsx.chip >> 4) == 9) { - cs->hw.hfcsx.b_fifo_size = B_FIFO_SIZE_32K; - return(1); + cs->hw.hfcsx.b_fifo_size = B_FIFO_SIZE_32K; + return (1); } - cs->hw.hfcsx.b_fifo_size = B_FIFO_SIZE_8K; - cs->hw.hfcsx.cirm |= 0x10; /* only 8K of ram */ - return(0); + cs->hw.hfcsx.b_fifo_size = B_FIFO_SIZE_8K; + cs->hw.hfcsx.cirm |= 0x10; /* only 8K of ram */ + return (0); } @@ -354,15 +354,15 @@ reset_hfcsx(struct IsdnCardState *cs) printk(KERN_INFO "HFC_SX: resetting card\n"); while (1) { - Write_hfc(cs, HFCSX_CIRM, HFCSX_RESET | cs->hw.hfcsx.cirm ); /* Reset */ - mdelay(30); - Write_hfc(cs, HFCSX_CIRM, cs->hw.hfcsx.cirm); /* Reset Off */ - mdelay(20); - if (Read_hfc(cs, HFCSX_STATUS) & 2) - printk(KERN_WARNING "HFC-SX init bit busy\n"); - cs->hw.hfcsx.last_fifo = 0xff; /* invalidate */ - if (!set_fifo_size(cs)) continue; - break; + Write_hfc(cs, HFCSX_CIRM, HFCSX_RESET | cs->hw.hfcsx.cirm); /* Reset */ + mdelay(30); + Write_hfc(cs, HFCSX_CIRM, cs->hw.hfcsx.cirm); /* Reset Off */ + mdelay(20); + if (Read_hfc(cs, HFCSX_STATUS) & 2) + printk(KERN_WARNING "HFC-SX init bit busy\n"); + cs->hw.hfcsx.last_fifo = 0xff; /* invalidate */ + if (!set_fifo_size(cs)) continue; + break; } cs->hw.hfcsx.trm = 0 + HFCSX_BTRANS_THRESMASK; /* no echo connect , threshold */ @@ -376,8 +376,8 @@ reset_hfcsx(struct IsdnCardState *cs) cs->hw.hfcsx.ctmt = HFCSX_TIM3_125 | HFCSX_AUTO_TIMER; Write_hfc(cs, HFCSX_CTMT, cs->hw.hfcsx.ctmt); - cs->hw.hfcsx.int_m1 = HFCSX_INTS_DTRANS | HFCSX_INTS_DREC | - HFCSX_INTS_L1STATE | HFCSX_INTS_TIMER; + cs->hw.hfcsx.int_m1 = HFCSX_INTS_DTRANS | HFCSX_INTS_DREC | + HFCSX_INTS_L1STATE | HFCSX_INTS_TIMER; Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); /* Clear already pending ints */ @@ -423,8 +423,8 @@ hfcsx_Timer(struct IsdnCardState *cs) cs->hw.hfcsx.timer.expires = jiffies + 75; /* WD RESET */ /* WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcsx.ctmt | 0x80); - add_timer(&cs->hw.hfcsx.timer); - */ + add_timer(&cs->hw.hfcsx.timer); +*/ } /************************************************/ @@ -458,11 +458,11 @@ receive_dmsg(struct IsdnCardState *cs) } do { - skb = read_fifo(cs, HFCSX_SEL_D_RX, 0); - if (skb) { - skb_queue_tail(&cs->rq, skb); - schedule_event(cs, D_RCVBUFREADY); - } + skb = read_fifo(cs, HFCSX_SEL_D_RX, 0); + if (skb) { + skb_queue_tail(&cs->rq, skb); + schedule_event(cs, D_RCVBUFREADY); + } } while (--count && skb); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); @@ -479,20 +479,20 @@ main_rec_hfcsx(struct BCState *bcs) int count = 5; struct sk_buff *skb; - Begin: +Begin: count--; if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { debugl1(cs, "rec_data %d blocked", bcs->channel); return; } - skb = read_fifo(cs, ((bcs->channel) && (!cs->hw.hfcsx.bswapped)) ? + skb = read_fifo(cs, ((bcs->channel) && (!cs->hw.hfcsx.bswapped)) ? HFCSX_SEL_B2_RX : HFCSX_SEL_B1_RX, - (bcs->mode == L1_MODE_TRANS) ? + (bcs->mode == L1_MODE_TRANS) ? HFCSX_BTRANS_THRESHOLD : 0); if (skb) { - skb_queue_tail(&bcs->rqueue, skb); - schedule_event(bcs, B_RCVBUFREADY); + skb_queue_tail(&bcs->rqueue, skb); + schedule_event(bcs, B_RCVBUFREADY); } test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); @@ -513,8 +513,8 @@ hfcsx_fill_dfifo(struct IsdnCardState *cs) return; if (write_fifo(cs, cs->tx_skb, HFCSX_SEL_D_TX, 0)) { - dev_kfree_skb_any(cs->tx_skb); - cs->tx_skb = NULL; + dev_kfree_skb_any(cs->tx_skb); + cs->tx_skb = NULL; } return; } @@ -532,24 +532,24 @@ hfcsx_fill_fifo(struct BCState *bcs) if (bcs->tx_skb->len <= 0) return; - if (write_fifo(cs, bcs->tx_skb, - ((bcs->channel) && (!cs->hw.hfcsx.bswapped)) ? + if (write_fifo(cs, bcs->tx_skb, + ((bcs->channel) && (!cs->hw.hfcsx.bswapped)) ? HFCSX_SEL_B2_TX : HFCSX_SEL_B1_TX, - (bcs->mode == L1_MODE_TRANS) ? + (bcs->mode == L1_MODE_TRANS) ? HFCSX_BTRANS_THRESHOLD : 0)) { - bcs->tx_cnt -= bcs->tx_skb->len; - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { - u_long flags; - spin_lock_irqsave(&bcs->aclock, flags); - bcs->ackcnt += bcs->tx_skb->len; - spin_unlock_irqrestore(&bcs->aclock, flags); - schedule_event(bcs, B_ACKPENDING); - } - dev_kfree_skb_any(bcs->tx_skb); - bcs->tx_skb = NULL; - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_cnt -= bcs->tx_skb->len; + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + u_long flags; + spin_lock_irqsave(&bcs->aclock, flags); + bcs->ackcnt += bcs->tx_skb->len; + spin_unlock_irqrestore(&bcs->aclock, flags); + schedule_event(bcs, B_ACKPENDING); + } + dev_kfree_skb_any(bcs->tx_skb); + bcs->tx_skb = NULL; + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); } } @@ -562,27 +562,27 @@ dch_nt_l2l1(struct PStack *st, int pr, void *arg) struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; switch (pr) { - case (PH_DATA | REQUEST): - case (PH_PULL | REQUEST): - case (PH_PULL | INDICATION): - st->l1.l1hw(st, pr, arg); - break; - case (PH_ACTIVATE | REQUEST): - st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); - break; - case (PH_TESTLOOP | REQUEST): - if (1 & (long) arg) - debugl1(cs, "PH_TEST_LOOP B1"); - if (2 & (long) arg) - debugl1(cs, "PH_TEST_LOOP B2"); - if (!(3 & (long) arg)) - debugl1(cs, "PH_TEST_LOOP DISABLED"); - st->l1.l1hw(st, HW_TESTLOOP | REQUEST, arg); - break; - default: - if (cs->debug) - debugl1(cs, "dch_nt_l2l1 msg %04X unhandled", pr); - break; + case (PH_DATA | REQUEST): + case (PH_PULL | REQUEST): + case (PH_PULL | INDICATION): + st->l1.l1hw(st, pr, arg); + break; + case (PH_ACTIVATE | REQUEST): + st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); + break; + case (PH_TESTLOOP | REQUEST): + if (1 & (long) arg) + debugl1(cs, "PH_TEST_LOOP B1"); + if (2 & (long) arg) + debugl1(cs, "PH_TEST_LOOP B2"); + if (!(3 & (long) arg)) + debugl1(cs, "PH_TEST_LOOP DISABLED"); + st->l1.l1hw(st, HW_TESTLOOP | REQUEST, arg); + break; + default: + if (cs->debug) + debugl1(cs, "dch_nt_l2l1 msg %04X unhandled", pr); + break; } } @@ -592,14 +592,14 @@ dch_nt_l2l1(struct PStack *st, int pr, void *arg) /* set/reset echo mode */ /***********************/ static int -hfcsx_auxcmd(struct IsdnCardState *cs, isdn_ctrl * ic) +hfcsx_auxcmd(struct IsdnCardState *cs, isdn_ctrl *ic) { unsigned long flags; int i = *(unsigned int *) ic->parm.num; if ((ic->arg == 98) && (!(cs->hw.hfcsx.int_m1 & (HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC + HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC)))) { - spin_lock_irqsave(&cs->lock, flags); + spin_lock_irqsave(&cs->lock, flags); Write_hfc(cs, HFCSX_STATES, HFCSX_LOAD_STATE | 0); /* HFC ST G0 */ udelay(10); cs->hw.hfcsx.sctrl |= SCTRL_MODE_NT; @@ -660,26 +660,26 @@ receive_emsg(struct IsdnCardState *cs) return; } do { - skb = read_fifo(cs, HFCSX_SEL_B2_RX, 0); - if (skb) { - if (cs->debug & DEB_DLOG_HEX) { - ptr = cs->dlog; - if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) { - *ptr++ = 'E'; - *ptr++ = 'C'; - *ptr++ = 'H'; - *ptr++ = 'O'; - *ptr++ = ':'; - ptr += QuickHex(ptr, skb->data, skb->len); - ptr--; - *ptr++ = '\n'; - *ptr = 0; - HiSax_putstatus(cs, NULL, cs->dlog); - } else - HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len); - } - dev_kfree_skb_any(skb); - } + skb = read_fifo(cs, HFCSX_SEL_B2_RX, 0); + if (skb) { + if (cs->debug & DEB_DLOG_HEX) { + ptr = cs->dlog; + if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) { + *ptr++ = 'E'; + *ptr++ = 'C'; + *ptr++ = 'H'; + *ptr++ = 'O'; + *ptr++ = ':'; + ptr += QuickHex(ptr, skb->data, skb->len); + ptr--; + *ptr++ = '\n'; + *ptr = 0; + HiSax_putstatus(cs, NULL, cs->dlog); + } else + HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len); + } + dev_kfree_skb_any(skb); + } } while (--count && skb); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); @@ -843,7 +843,7 @@ hfcsx_interrupt(int intno, void *dev_id) } else schedule_event(cs, D_XMTBUFREADY); } - afterXPR: + afterXPR: if (cs->hw.hfcsx.int_s1 && count--) { val = cs->hw.hfcsx.int_s1; cs->hw.hfcsx.int_s1 = 0; @@ -875,128 +875,128 @@ HFCSX_l1hw(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); -#ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { - hfcsx_fill_dfifo(cs); - test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - } else - debugl1(cs, "hfcsx_fill_dfifo blocked"); - - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - spin_unlock_irqrestore(&cs->lock, flags); - break; - } - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + Logl2Frame(cs, skb, "PH_DATA", 0); #endif if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { - hfcsx_fill_dfifo(cs); + hfcsx_fill_dfifo(cs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else debugl1(cs, "hfcsx_fill_dfifo blocked"); + + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - Write_hfc(cs, HFCSX_STATES, HFCSX_LOAD_STATE | 3); /* HFC ST 3 */ - udelay(6); - Write_hfc(cs, HFCSX_STATES, 3); /* HFC ST 2 */ - cs->hw.hfcsx.mst_m |= HFCSX_MASTER; - Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); - Write_hfc(cs, HFCSX_STATES, HFCSX_ACTIVATE | HFCSX_DO_ACTION); - spin_unlock_irqrestore(&cs->lock, flags); - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - break; - case (HW_ENABLE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - Write_hfc(cs, HFCSX_STATES, HFCSX_ACTIVATE | HFCSX_DO_ACTION); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_DEACTIVATE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcsx.mst_m &= ~HFCSX_MASTER; - Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO3 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcsx.mst_m |= HFCSX_MASTER; - Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); + if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { + hfcsx_fill_dfifo(cs); + test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); + } else + debugl1(cs, "hfcsx_fill_dfifo blocked"); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG /* psa */ + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "-> PH_REQUEST_PULL"); +#endif + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + Write_hfc(cs, HFCSX_STATES, HFCSX_LOAD_STATE | 3); /* HFC ST 3 */ + udelay(6); + Write_hfc(cs, HFCSX_STATES, 3); /* HFC ST 2 */ + cs->hw.hfcsx.mst_m |= HFCSX_MASTER; + Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); + Write_hfc(cs, HFCSX_STATES, HFCSX_ACTIVATE | HFCSX_DO_ACTION); + spin_unlock_irqrestore(&cs->lock, flags); + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + break; + case (HW_ENABLE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + Write_hfc(cs, HFCSX_STATES, HFCSX_ACTIVATE | HFCSX_DO_ACTION); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_DEACTIVATE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcsx.mst_m &= ~HFCSX_MASTER; + Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO3 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcsx.mst_m |= HFCSX_MASTER; + Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_TESTLOOP | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + switch ((long) arg) { + case (1): + Write_hfc(cs, HFCSX_B1_SSL, 0x80); /* tx slot */ + Write_hfc(cs, HFCSX_B1_RSL, 0x80); /* rx slot */ + cs->hw.hfcsx.conn = (cs->hw.hfcsx.conn & ~7) | 1; + Write_hfc(cs, HFCSX_CONNECT, cs->hw.hfcsx.conn); break; - case (HW_TESTLOOP | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - switch ((long) arg) { - case (1): - Write_hfc(cs, HFCSX_B1_SSL, 0x80); /* tx slot */ - Write_hfc(cs, HFCSX_B1_RSL, 0x80); /* rx slot */ - cs->hw.hfcsx.conn = (cs->hw.hfcsx.conn & ~7) | 1; - Write_hfc(cs, HFCSX_CONNECT, cs->hw.hfcsx.conn); - break; - case (2): - Write_hfc(cs, HFCSX_B2_SSL, 0x81); /* tx slot */ - Write_hfc(cs, HFCSX_B2_RSL, 0x81); /* rx slot */ - cs->hw.hfcsx.conn = (cs->hw.hfcsx.conn & ~0x38) | 0x08; - Write_hfc(cs, HFCSX_CONNECT, cs->hw.hfcsx.conn); - break; - default: - spin_unlock_irqrestore(&cs->lock, flags); - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcsx_l1hw loop invalid %4lx", (unsigned long)arg); - return; - } - cs->hw.hfcsx.trm |= 0x80; /* enable IOM-loop */ - Write_hfc(cs, HFCSX_TRM, cs->hw.hfcsx.trm); - spin_unlock_irqrestore(&cs->lock, flags); + case (2): + Write_hfc(cs, HFCSX_B2_SSL, 0x81); /* tx slot */ + Write_hfc(cs, HFCSX_B2_RSL, 0x81); /* rx slot */ + cs->hw.hfcsx.conn = (cs->hw.hfcsx.conn & ~0x38) | 0x08; + Write_hfc(cs, HFCSX_CONNECT, cs->hw.hfcsx.conn); break; default: + spin_unlock_irqrestore(&cs->lock, flags); if (cs->debug & L1_DEB_WARN) - debugl1(cs, "hfcsx_l1hw unknown pr %4x", pr); - break; + debugl1(cs, "hfcsx_l1hw loop invalid %4lx", (unsigned long)arg); + return; + } + cs->hw.hfcsx.trm |= 0x80; /* enable IOM-loop */ + Write_hfc(cs, HFCSX_TRM, cs->hw.hfcsx.trm); + spin_unlock_irqrestore(&cs->lock, flags); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "hfcsx_l1hw unknown pr %4x", pr); + break; } } @@ -1018,7 +1018,7 @@ hfcsx_send_data(struct BCState *bcs) struct IsdnCardState *cs = bcs->cs; if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { - hfcsx_fill_fifo(bcs); + hfcsx_fill_fifo(bcs); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); } else debugl1(cs, "send_data %d blocked", bcs->channel); @@ -1058,69 +1058,69 @@ mode_hfcsx(struct BCState *bcs, int mode, int bc) } } switch (mode) { - case (L1_MODE_NULL): - if (bc) { - cs->hw.hfcsx.sctrl &= ~SCTRL_B2_ENA; - cs->hw.hfcsx.sctrl_r &= ~SCTRL_B2_ENA; - } else { - cs->hw.hfcsx.sctrl &= ~SCTRL_B1_ENA; - cs->hw.hfcsx.sctrl_r &= ~SCTRL_B1_ENA; - } - if (fifo2) { - cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); - } else { - cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); - } - break; - case (L1_MODE_TRANS): - if (bc) { - cs->hw.hfcsx.sctrl |= SCTRL_B2_ENA; - cs->hw.hfcsx.sctrl_r |= SCTRL_B2_ENA; - } else { - cs->hw.hfcsx.sctrl |= SCTRL_B1_ENA; - cs->hw.hfcsx.sctrl_r |= SCTRL_B1_ENA; - } - if (fifo2) { - cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); - cs->hw.hfcsx.ctmt |= 2; - cs->hw.hfcsx.conn &= ~0x18; - } else { - cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); - cs->hw.hfcsx.ctmt |= 1; - cs->hw.hfcsx.conn &= ~0x03; - } - break; - case (L1_MODE_HDLC): - if (bc) { - cs->hw.hfcsx.sctrl |= SCTRL_B2_ENA; - cs->hw.hfcsx.sctrl_r |= SCTRL_B2_ENA; - } else { - cs->hw.hfcsx.sctrl |= SCTRL_B1_ENA; - cs->hw.hfcsx.sctrl_r |= SCTRL_B1_ENA; - } - if (fifo2) { - cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); - cs->hw.hfcsx.ctmt &= ~2; - cs->hw.hfcsx.conn &= ~0x18; - } else { - cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); - cs->hw.hfcsx.ctmt &= ~1; - cs->hw.hfcsx.conn &= ~0x03; - } - break; - case (L1_MODE_EXTRN): - if (bc) { - cs->hw.hfcsx.conn |= 0x10; - cs->hw.hfcsx.sctrl |= SCTRL_B2_ENA; - cs->hw.hfcsx.sctrl_r |= SCTRL_B2_ENA; - cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); - } else { - cs->hw.hfcsx.conn |= 0x02; - cs->hw.hfcsx.sctrl |= SCTRL_B1_ENA; - cs->hw.hfcsx.sctrl_r |= SCTRL_B1_ENA; - cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); - } - break; + case (L1_MODE_NULL): + if (bc) { + cs->hw.hfcsx.sctrl &= ~SCTRL_B2_ENA; + cs->hw.hfcsx.sctrl_r &= ~SCTRL_B2_ENA; + } else { + cs->hw.hfcsx.sctrl &= ~SCTRL_B1_ENA; + cs->hw.hfcsx.sctrl_r &= ~SCTRL_B1_ENA; + } + if (fifo2) { + cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); + } else { + cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); + } + break; + case (L1_MODE_TRANS): + if (bc) { + cs->hw.hfcsx.sctrl |= SCTRL_B2_ENA; + cs->hw.hfcsx.sctrl_r |= SCTRL_B2_ENA; + } else { + cs->hw.hfcsx.sctrl |= SCTRL_B1_ENA; + cs->hw.hfcsx.sctrl_r |= SCTRL_B1_ENA; + } + if (fifo2) { + cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); + cs->hw.hfcsx.ctmt |= 2; + cs->hw.hfcsx.conn &= ~0x18; + } else { + cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); + cs->hw.hfcsx.ctmt |= 1; + cs->hw.hfcsx.conn &= ~0x03; + } + break; + case (L1_MODE_HDLC): + if (bc) { + cs->hw.hfcsx.sctrl |= SCTRL_B2_ENA; + cs->hw.hfcsx.sctrl_r |= SCTRL_B2_ENA; + } else { + cs->hw.hfcsx.sctrl |= SCTRL_B1_ENA; + cs->hw.hfcsx.sctrl_r |= SCTRL_B1_ENA; + } + if (fifo2) { + cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); + cs->hw.hfcsx.ctmt &= ~2; + cs->hw.hfcsx.conn &= ~0x18; + } else { + cs->hw.hfcsx.int_m1 |= (HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); + cs->hw.hfcsx.ctmt &= ~1; + cs->hw.hfcsx.conn &= ~0x03; + } + break; + case (L1_MODE_EXTRN): + if (bc) { + cs->hw.hfcsx.conn |= 0x10; + cs->hw.hfcsx.sctrl |= SCTRL_B2_ENA; + cs->hw.hfcsx.sctrl_r |= SCTRL_B2_ENA; + cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B2TRANS + HFCSX_INTS_B2REC); + } else { + cs->hw.hfcsx.conn |= 0x02; + cs->hw.hfcsx.sctrl |= SCTRL_B1_ENA; + cs->hw.hfcsx.sctrl_r |= SCTRL_B1_ENA; + cs->hw.hfcsx.int_m1 &= ~(HFCSX_INTS_B1TRANS + HFCSX_INTS_B1REC); + } + break; } Write_hfc(cs, HFCSX_SCTRL_E, cs->hw.hfcsx.sctrl_e); Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); @@ -1129,8 +1129,8 @@ mode_hfcsx(struct BCState *bcs, int mode, int bc) Write_hfc(cs, HFCSX_CTMT, cs->hw.hfcsx.ctmt); Write_hfc(cs, HFCSX_CONNECT, cs->hw.hfcsx.conn); if (mode != L1_MODE_EXTRN) { - reset_fifo(cs, fifo2 ? HFCSX_SEL_B2_RX : HFCSX_SEL_B1_RX); - reset_fifo(cs, fifo2 ? HFCSX_SEL_B2_TX : HFCSX_SEL_B1_TX); + reset_fifo(cs, fifo2 ? HFCSX_SEL_B2_RX : HFCSX_SEL_B1_RX); + reset_fifo(cs, fifo2 ? HFCSX_SEL_B2_TX : HFCSX_SEL_B1_TX); } } @@ -1145,53 +1145,53 @@ hfcsx_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; // test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); - } else { + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n"); + } else { // test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->tx_skb = skb; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - mode_hfcsx(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - mode_hfcsx(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + bcs->tx_skb = skb; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + mode_hfcsx(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + mode_hfcsx(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -1260,61 +1260,61 @@ hfcsx_bh(struct work_struct *work) if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { if (!cs->hw.hfcsx.nt_mode) switch (cs->dc.hfcsx.ph_state) { - case (0): - l1_msg(cs, HW_RESET | INDICATION, NULL); - break; - case (3): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (8): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (6): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - case (7): - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - default: - break; - } else { + case (0): + l1_msg(cs, HW_RESET | INDICATION, NULL); + break; + case (3): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (8): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (6): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + case (7): + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + default: + break; + } else { switch (cs->dc.hfcsx.ph_state) { - case (2): - spin_lock_irqsave(&cs->lock, flags); - if (cs->hw.hfcsx.nt_timer < 0) { - cs->hw.hfcsx.nt_timer = 0; - cs->hw.hfcsx.int_m1 &= ~HFCSX_INTS_TIMER; - Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); - /* Clear already pending ints */ - if (Read_hfc(cs, HFCSX_INT_S1)); - - Write_hfc(cs, HFCSX_STATES, 4 | HFCSX_LOAD_STATE); - udelay(10); - Write_hfc(cs, HFCSX_STATES, 4); - cs->dc.hfcsx.ph_state = 4; - } else { - cs->hw.hfcsx.int_m1 |= HFCSX_INTS_TIMER; - Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); - cs->hw.hfcsx.ctmt &= ~HFCSX_AUTO_TIMER; - cs->hw.hfcsx.ctmt |= HFCSX_TIM3_125; - Write_hfc(cs, HFCSX_CTMT, cs->hw.hfcsx.ctmt | HFCSX_CLTIMER); - Write_hfc(cs, HFCSX_CTMT, cs->hw.hfcsx.ctmt | HFCSX_CLTIMER); - cs->hw.hfcsx.nt_timer = NT_T1_COUNT; - Write_hfc(cs, HFCSX_STATES, 2 | HFCSX_NT_G2_G3); /* allow G2 -> G3 transition */ - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (1): - case (3): - case (4): - spin_lock_irqsave(&cs->lock, flags); + case (2): + spin_lock_irqsave(&cs->lock, flags); + if (cs->hw.hfcsx.nt_timer < 0) { cs->hw.hfcsx.nt_timer = 0; cs->hw.hfcsx.int_m1 &= ~HFCSX_INTS_TIMER; Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); - spin_unlock_irqrestore(&cs->lock, flags); - break; - default: - break; + /* Clear already pending ints */ + if (Read_hfc(cs, HFCSX_INT_S1)); + + Write_hfc(cs, HFCSX_STATES, 4 | HFCSX_LOAD_STATE); + udelay(10); + Write_hfc(cs, HFCSX_STATES, 4); + cs->dc.hfcsx.ph_state = 4; + } else { + cs->hw.hfcsx.int_m1 |= HFCSX_INTS_TIMER; + Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); + cs->hw.hfcsx.ctmt &= ~HFCSX_AUTO_TIMER; + cs->hw.hfcsx.ctmt |= HFCSX_TIM3_125; + Write_hfc(cs, HFCSX_CTMT, cs->hw.hfcsx.ctmt | HFCSX_CLTIMER); + Write_hfc(cs, HFCSX_CTMT, cs->hw.hfcsx.ctmt | HFCSX_CLTIMER); + cs->hw.hfcsx.nt_timer = NT_T1_COUNT; + Write_hfc(cs, HFCSX_STATES, 2 | HFCSX_NT_G2_G3); /* allow G2 -> G3 transition */ + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (1): + case (3): + case (4): + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcsx.nt_timer = 0; + cs->hw.hfcsx.int_m1 &= ~HFCSX_INTS_TIMER; + Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); + spin_unlock_irqrestore(&cs->lock, flags); + break; + default: + break; } } } @@ -1353,29 +1353,29 @@ hfcsx_card_msg(struct IsdnCardState *cs, int mt, void *arg) if (cs->debug & L1_DEB_ISAC) debugl1(cs, "HFCSX: card_msg %x", mt); switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_hfcsx(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_RELEASE: - release_io_hfcsx(cs); - return (0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithfcsx(cs); - spin_unlock_irqrestore(&cs->lock, flags); - msleep(80); /* Timeout 80ms */ - /* now switch timer interrupt off */ - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcsx.int_m1 &= ~HFCSX_INTS_TIMER; - Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); - /* reinit mode reg */ - Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - return (0); - case CARD_TEST: - return (0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_hfcsx(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_hfcsx(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithfcsx(cs); + spin_unlock_irqrestore(&cs->lock, flags); + msleep(80); /* Timeout 80ms */ + /* now switch timer interrupt off */ + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcsx.int_m1 &= ~HFCSX_INTS_TIMER; + Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); + /* reinit mode reg */ + Write_hfc(cs, HFCSX_MST_MODE, cs->hw.hfcsx.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } return (0); } @@ -1383,7 +1383,7 @@ hfcsx_card_msg(struct IsdnCardState *cs, int mt, void *arg) #ifdef __ISAPNP__ static struct isapnp_device_id hfc_ids[] __devinitdata = { { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2620), - ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2620), + ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2620), (unsigned long) "Teles 16.3c2" }, { 0, } }; @@ -1403,30 +1403,30 @@ setup_hfcsx(struct IsdnCard *card) #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); + card->para[0], card->para[1]); pnp_disable_dev(pnp_d); - return(0); + return (0); } break; } else { @@ -1435,10 +1435,10 @@ setup_hfcsx(struct IsdnCard *card) } ipid++; pnp_c = NULL; - } + } if (!ipid->card_vendor) { printk(KERN_INFO "HFC PnP: no ISAPnP card found\n"); - return(0); + return (0); } } #endif @@ -1447,47 +1447,47 @@ setup_hfcsx(struct IsdnCard *card) cs->hw.hfcsx.int_s1 = 0; cs->dc.hfcsx.ph_state = 0; cs->hw.hfcsx.fifo = 255; - if ((cs->typ == ISDN_CTYPE_HFC_SX) || + if ((cs->typ == ISDN_CTYPE_HFC_SX) || (cs->typ == ISDN_CTYPE_HFC_SP_PCMCIA)) { - if ((!cs->hw.hfcsx.base) || !request_region(cs->hw.hfcsx.base, 2, "HFCSX isdn")) { - printk(KERN_WARNING - "HiSax: HFC-SX io-base %#lx already in use\n", - cs->hw.hfcsx.base); - return(0); + if ((!cs->hw.hfcsx.base) || !request_region(cs->hw.hfcsx.base, 2, "HFCSX isdn")) { + printk(KERN_WARNING + "HiSax: HFC-SX io-base %#lx already in use\n", + cs->hw.hfcsx.base); + return (0); } byteout(cs->hw.hfcsx.base, cs->hw.hfcsx.base & 0xFF); byteout(cs->hw.hfcsx.base + 1, ((cs->hw.hfcsx.base >> 8) & 3) | 0x54); udelay(10); - cs->hw.hfcsx.chip = Read_hfc(cs,HFCSX_CHIP_ID); - switch (cs->hw.hfcsx.chip >> 4) { - case 1: - tmp[0] ='+'; - break; - case 9: - tmp[0] ='P'; - break; - default: - printk(KERN_WARNING - "HFC-SX: invalid chip id 0x%x\n", - cs->hw.hfcsx.chip >> 4); - release_region(cs->hw.hfcsx.base, 2); - return(0); - } + cs->hw.hfcsx.chip = Read_hfc(cs, HFCSX_CHIP_ID); + switch (cs->hw.hfcsx.chip >> 4) { + case 1: + tmp[0] = '+'; + break; + case 9: + tmp[0] = 'P'; + break; + default: + printk(KERN_WARNING + "HFC-SX: invalid chip id 0x%x\n", + cs->hw.hfcsx.chip >> 4); + release_region(cs->hw.hfcsx.base, 2); + return (0); + } if (!ccd_sp_irqtab[cs->irq & 0xF]) { - printk(KERN_WARNING - "HFC_SX: invalid irq %d specified\n",cs->irq & 0xF); - release_region(cs->hw.hfcsx.base, 2); - return(0); - } + printk(KERN_WARNING + "HFC_SX: invalid irq %d specified\n", cs->irq & 0xF); + release_region(cs->hw.hfcsx.base, 2); + return (0); + } if (!(cs->hw.hfcsx.extra = (void *) kmalloc(sizeof(struct hfcsx_extra), GFP_ATOMIC))) { - release_region(cs->hw.hfcsx.base, 2); - printk(KERN_WARNING "HFC-SX: unable to allocate memory\n"); - return(0); + release_region(cs->hw.hfcsx.base, 2); + printk(KERN_WARNING "HFC-SX: unable to allocate memory\n"); + return (0); } printk(KERN_INFO "HFC-S%c chip detected at base 0x%x IRQ %d HZ %d\n", - tmp[0], (u_int) cs->hw.hfcsx.base, cs->irq, HZ); + tmp[0], (u_int) cs->hw.hfcsx.base, cs->irq, HZ); cs->hw.hfcsx.int_m2 = 0; /* disable alle interrupts */ cs->hw.hfcsx.int_m1 = 0; Write_hfc(cs, HFCSX_INT_M1, cs->hw.hfcsx.int_m1); diff --git a/drivers/isdn/hisax/hfc_sx.h b/drivers/isdn/hisax/hfc_sx.h index 6792f13dc220..eee85dbb0883 100644 --- a/drivers/isdn/hisax/hfc_sx.h +++ b/drivers/isdn/hisax/hfc_sx.h @@ -5,7 +5,7 @@ * Author Werner Cornelius * based on existing driver for CCD HFC PCI cards * Copyright by Werner Cornelius - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -48,7 +48,7 @@ #define HFCSX_MST_EMOD 0x2D #define HFCSX_MST_MODE 0x2E -#define HFCSX_CONNECT 0x2F +#define HFCSX_CONNECT 0x2F /* Interrupt and status registers */ @@ -56,22 +56,22 @@ #define HFCSX_TRM 0x12 #define HFCSX_B_MODE 0x13 #define HFCSX_CHIP_ID 0x16 -#define HFCSX_CIRM 0x18 +#define HFCSX_CIRM 0x18 #define HFCSX_CTMT 0x19 -#define HFCSX_INT_M1 0x1A -#define HFCSX_INT_M2 0x1B -#define HFCSX_INT_S1 0x1E -#define HFCSX_INT_S2 0x1F -#define HFCSX_STATUS 0x1C +#define HFCSX_INT_M1 0x1A +#define HFCSX_INT_M2 0x1B +#define HFCSX_INT_S1 0x1E +#define HFCSX_INT_S2 0x1F +#define HFCSX_STATUS 0x1C /* S/T section registers */ -#define HFCSX_STATES 0x30 -#define HFCSX_SCTRL 0x31 +#define HFCSX_STATES 0x30 +#define HFCSX_SCTRL 0x31 #define HFCSX_SCTRL_E 0x32 #define HFCSX_SCTRL_R 0x33 -#define HFCSX_SQ 0x34 -#define HFCSX_CLKDEL 0x37 +#define HFCSX_SQ 0x34 +#define HFCSX_CLKDEL 0x37 #define HFCSX_B1_REC 0x3C #define HFCSX_B1_SEND 0x3C #define HFCSX_B2_REC 0x3D @@ -97,7 +97,7 @@ /* bits in status register (READ) */ #define HFCSX_SX_PROC 0x02 -#define HFCSX_NBUSY 0x04 +#define HFCSX_NBUSY 0x04 #define HFCSX_TIMER_ELAP 0x10 #define HFCSX_STATINT 0x20 #define HFCSX_FRAMEINT 0x40 @@ -117,7 +117,7 @@ /* bits in CIRM (Write) */ #define HFCSX_IRQ_SELMSK 0x07 #define HFCSX_IRQ_SELDIS 0x00 -#define HFCSX_RESET 0x08 +#define HFCSX_RESET 0x08 #define HFCSX_FIFO_RESET 0x80 @@ -189,7 +189,7 @@ /* structure holding additional dynamic data -> send marker */ /************************************************************/ struct hfcsx_extra { - unsigned short marker[2*(MAX_B_FRAMES+1) + (MAX_D_FRAMES+1)]; + unsigned short marker[2 * (MAX_B_FRAMES + 1) + (MAX_D_FRAMES + 1)]; }; extern void main_irq_hfcsx(struct BCState *bcs); diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index f407de0e006d..62c65bdefd8a 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c @@ -27,7 +27,7 @@ * * See Version Histroy at the bottom of this file * -*/ + */ #include #include @@ -45,11 +45,11 @@ #include "hfc_usb.h" static const char *hfcusb_revision = - "$Revision: 2.3.2.24 $ $Date: 2007/10/14 08:40:29 $ "; + "$Revision: 2.3.2.24 $ $Date: 2007/10/14 08:40:29 $ "; /* Hisax debug support -* debug flags defined in hfc_usb.h as HFCUSB_DBG_[*] -*/ + * debug flags defined in hfc_usb.h as HFCUSB_DBG_[*] + */ #define __debug_variable hfc_debug #include "hisax_debug.h" static u_int debug; @@ -67,70 +67,70 @@ typedef struct { /* VID/PID device list */ static struct usb_device_id hfcusb_idtab[] = { { - USB_DEVICE(0x0959, 0x2bd0), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_OFF, {4, 0, 2, 1}, - "ISDN USB TA (Cologne Chip HFC-S USB based)"}), + USB_DEVICE(0x0959, 0x2bd0), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_OFF, {4, 0, 2, 1}, + "ISDN USB TA (Cologne Chip HFC-S USB based)"}), }, { - USB_DEVICE(0x0675, 0x1688), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {1, 2, 0, 0}, - "DrayTek miniVigor 128 USB ISDN TA"}), + USB_DEVICE(0x0675, 0x1688), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {1, 2, 0, 0}, + "DrayTek miniVigor 128 USB ISDN TA"}), }, { - USB_DEVICE(0x07b0, 0x0007), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Billion tiny USB ISDN TA 128"}), + USB_DEVICE(0x07b0, 0x0007), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Billion tiny USB ISDN TA 128"}), }, { - USB_DEVICE(0x0742, 0x2008), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {4, 0, 2, 1}, - "Stollmann USB TA"}), + USB_DEVICE(0x0742, 0x2008), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {4, 0, 2, 1}, + "Stollmann USB TA"}), }, { - USB_DEVICE(0x0742, 0x2009), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {4, 0, 2, 1}, - "Aceex USB ISDN TA"}), + USB_DEVICE(0x0742, 0x2009), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {4, 0, 2, 1}, + "Aceex USB ISDN TA"}), }, { - USB_DEVICE(0x0742, 0x200A), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {4, 0, 2, 1}, - "OEM USB ISDN TA"}), + USB_DEVICE(0x0742, 0x200A), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {4, 0, 2, 1}, + "OEM USB ISDN TA"}), }, { - USB_DEVICE(0x08e3, 0x0301), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {2, 0, 1, 4}, - "Olitec USB RNIS"}), + USB_DEVICE(0x08e3, 0x0301), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {2, 0, 1, 4}, + "Olitec USB RNIS"}), }, { - USB_DEVICE(0x07fa, 0x0846), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Bewan Modem RNIS USB"}), + USB_DEVICE(0x07fa, 0x0846), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Bewan Modem RNIS USB"}), }, { - USB_DEVICE(0x07fa, 0x0847), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Djinn Numeris USB"}), + USB_DEVICE(0x07fa, 0x0847), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Djinn Numeris USB"}), }, { - USB_DEVICE(0x07b0, 0x0006), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {0x80, -64, -32, -16}, - "Twister ISDN TA"}), + USB_DEVICE(0x07b0, 0x0006), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {0x80, -64, -32, -16}, + "Twister ISDN TA"}), }, { - USB_DEVICE(0x071d, 0x1005), - .driver_info = (unsigned long) &((hfcsusb_vdata) - {LED_SCHEME1, {0x02, 0, 0x01, 0x04}, - "Eicon DIVA USB 4.0"}), + USB_DEVICE(0x071d, 0x1005), + .driver_info = (unsigned long) &((hfcsusb_vdata) + {LED_SCHEME1, {0x02, 0, 0x01, 0x04}, + "Eicon DIVA USB 4.0"}), }, { } }; @@ -177,7 +177,7 @@ typedef struct hfcusb_data { int alt_used; /* used alternate config */ int ctrl_paksize; /* control pipe packet size */ int ctrl_in_pipe, /* handles for control pipe */ - ctrl_out_pipe; + ctrl_out_pipe; int cfg_used; /* configuration index used */ int vend_idx; /* vendor found */ int b_mode[2]; /* B-channel mode */ @@ -206,7 +206,7 @@ typedef struct hfcusb_data { } hfcusb_data; -static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, +static void collect_rx_frame(usb_fifo *fifo, __u8 *data, int len, int finish); static inline const char * @@ -220,24 +220,24 @@ symbolic(struct hfcusb_symbolic_list list[], const int num) } static void -ctrl_start_transfer(hfcusb_data * hfc) +ctrl_start_transfer(hfcusb_data *hfc) { if (hfc->ctrl_cnt) { hfc->ctrl_urb->pipe = hfc->ctrl_out_pipe; - hfc->ctrl_urb->setup_packet = (u_char *) & hfc->ctrl_write; + hfc->ctrl_urb->setup_packet = (u_char *)&hfc->ctrl_write; hfc->ctrl_urb->transfer_buffer = NULL; hfc->ctrl_urb->transfer_buffer_length = 0; hfc->ctrl_write.wIndex = - cpu_to_le16(hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg); + cpu_to_le16(hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg); hfc->ctrl_write.wValue = - cpu_to_le16(hfc->ctrl_buff[hfc->ctrl_out_idx].reg_val); + cpu_to_le16(hfc->ctrl_buff[hfc->ctrl_out_idx].reg_val); usb_submit_urb(hfc->ctrl_urb, GFP_ATOMIC); /* start transfer */ } } /* ctrl_start_transfer */ static int -queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action) +queue_control_request(hfcusb_data *hfc, __u8 reg, __u8 val, int action) { ctrl_buft *buf; @@ -271,7 +271,7 @@ ctrl_complete(struct urb *urb) /* write led data to auxport & invert if necessary */ static void -write_led(hfcusb_data * hfc, __u8 led_state) +write_led(hfcusb_data *hfc, __u8 led_state) { if (led_state != hfc->old_led_state) { hfc->old_led_state = led_state; @@ -280,7 +280,7 @@ write_led(hfcusb_data * hfc, __u8 led_state) } static void -set_led_bit(hfcusb_data * hfc, signed short led_bits, int on) +set_led_bit(hfcusb_data *hfc, signed short led_bits, int on) { if (on) { if (led_bits < 0) @@ -297,53 +297,53 @@ set_led_bit(hfcusb_data * hfc, signed short led_bits, int on) /* handle LED requests */ static void -handle_led(hfcusb_data * hfc, int event) +handle_led(hfcusb_data *hfc, int event) { hfcsusb_vdata *driver_info = - (hfcsusb_vdata *) hfcusb_idtab[hfc->vend_idx].driver_info; + (hfcsusb_vdata *) hfcusb_idtab[hfc->vend_idx].driver_info; /* if no scheme -> no LED action */ if (driver_info->led_scheme == LED_OFF) return; switch (event) { - case LED_POWER_ON: - set_led_bit(hfc, driver_info->led_bits[0], 1); - set_led_bit(hfc, driver_info->led_bits[1], 0); - set_led_bit(hfc, driver_info->led_bits[2], 0); - set_led_bit(hfc, driver_info->led_bits[3], 0); - break; - case LED_POWER_OFF: - set_led_bit(hfc, driver_info->led_bits[0], 0); - set_led_bit(hfc, driver_info->led_bits[1], 0); - set_led_bit(hfc, driver_info->led_bits[2], 0); - set_led_bit(hfc, driver_info->led_bits[3], 0); - break; - case LED_S0_ON: - set_led_bit(hfc, driver_info->led_bits[1], 1); - break; - case LED_S0_OFF: - set_led_bit(hfc, driver_info->led_bits[1], 0); - break; - case LED_B1_ON: - set_led_bit(hfc, driver_info->led_bits[2], 1); - break; - case LED_B1_OFF: - set_led_bit(hfc, driver_info->led_bits[2], 0); - break; - case LED_B2_ON: - set_led_bit(hfc, driver_info->led_bits[3], 1); - break; - case LED_B2_OFF: - set_led_bit(hfc, driver_info->led_bits[3], 0); - break; + case LED_POWER_ON: + set_led_bit(hfc, driver_info->led_bits[0], 1); + set_led_bit(hfc, driver_info->led_bits[1], 0); + set_led_bit(hfc, driver_info->led_bits[2], 0); + set_led_bit(hfc, driver_info->led_bits[3], 0); + break; + case LED_POWER_OFF: + set_led_bit(hfc, driver_info->led_bits[0], 0); + set_led_bit(hfc, driver_info->led_bits[1], 0); + set_led_bit(hfc, driver_info->led_bits[2], 0); + set_led_bit(hfc, driver_info->led_bits[3], 0); + break; + case LED_S0_ON: + set_led_bit(hfc, driver_info->led_bits[1], 1); + break; + case LED_S0_OFF: + set_led_bit(hfc, driver_info->led_bits[1], 0); + break; + case LED_B1_ON: + set_led_bit(hfc, driver_info->led_bits[2], 1); + break; + case LED_B1_OFF: + set_led_bit(hfc, driver_info->led_bits[2], 0); + break; + case LED_B2_ON: + set_led_bit(hfc, driver_info->led_bits[3], 1); + break; + case LED_B2_OFF: + set_led_bit(hfc, driver_info->led_bits[3], 0); + break; } write_led(hfc, hfc->led_state); } /* ISDN l1 timer T3 expires */ static void -l1_timer_expire_t3(hfcusb_data * hfc) +l1_timer_expire_t3(hfcusb_data *hfc) { hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, NULL); @@ -360,7 +360,7 @@ l1_timer_expire_t3(hfcusb_data * hfc) /* ISDN l1 timer T4 expires */ static void -l1_timer_expire_t4(hfcusb_data * hfc) +l1_timer_expire_t4(hfcusb_data *hfc) { hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, NULL); @@ -374,7 +374,7 @@ l1_timer_expire_t4(hfcusb_data * hfc) /* S0 state changed */ static void -s0_state_handler(hfcusb_data * hfc, __u8 state) +s0_state_handler(hfcusb_data *hfc, __u8 state) { __u8 old_state; @@ -402,12 +402,12 @@ s0_state_handler(hfcusb_data * hfc, __u8 state) DBG(HFCUSB_DBG_STATES, "HFC-S USB: PH_ACTIVATE | INDICATION sent"); hfc->l1_activated = 1; handle_led(hfc, LED_S0_ON); - } else if (state <= 3 /* && activated */ ) { + } else if (state <= 3 /* && activated */) { if (old_state == 7 || old_state == 8) { DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 activated"); if (!timer_pending(&hfc->t4_timer)) { hfc->t4_timer.expires = - jiffies + (HFC_TIMER_T4 * HZ) / 1000; + jiffies + (HFC_TIMER_T4 * HZ) / 1000; add_timer(&hfc->t4_timer); } } else { @@ -451,7 +451,7 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, * gaps in the transfer chain */ static int -start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, +start_isoc_chain(usb_fifo *fifo, int num_packets_per_urb, usb_complete_t complete, int packet_size) { int i, k, errcode; @@ -463,7 +463,7 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, for (i = 0; i < 2; i++) { if (!(fifo->iso[i].purb)) { fifo->iso[i].purb = - usb_alloc_urb(num_packets_per_urb, GFP_KERNEL); + usb_alloc_urb(num_packets_per_urb, GFP_KERNEL); if (!(fifo->iso[i].purb)) { printk(KERN_INFO "alloc urb for fifo %i failed!!!", @@ -487,11 +487,11 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, /* defining packet delimeters in fifo->buffer */ for (k = 0; k < num_packets_per_urb; k++) { fifo->iso[i].purb-> - iso_frame_desc[k].offset = - k * packet_size; + iso_frame_desc[k].offset = + k * packet_size; fifo->iso[i].purb-> - iso_frame_desc[k].length = - packet_size; + iso_frame_desc[k].length = + packet_size; } } else { printk(KERN_INFO @@ -511,7 +511,7 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, /* stops running iso chain and frees their pending urbs */ static void -stop_isoc_chain(usb_fifo * fifo) +stop_isoc_chain(usb_fifo *fifo) { int i; @@ -534,8 +534,8 @@ stop_isoc_chain(usb_fifo * fifo) /* defines how much ISO packets are handled in one URB */ static int iso_packets[8] = - { ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, - ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D +{ ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, + ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D }; static void @@ -545,7 +545,7 @@ tx_iso_complete(struct urb *urb) usb_fifo *fifo = context_iso_urb->owner_fifo; hfcusb_data *hfc = fifo->hfc; int k, tx_offset, num_isoc_packets, sink, len, current_len, - errcode; + errcode; int frame_complete, transp_mode, fifon, status; __u8 threshbit; @@ -565,8 +565,8 @@ tx_iso_complete(struct urb *urb) errcode = urb->iso_frame_desc[k].status; if (errcode) DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete " - "packet %i, status: %i\n", - k, errcode); + "packet %i, status: %i\n", + k, errcode); } // clear status, so go on with ISO transfers @@ -607,8 +607,8 @@ tx_iso_complete(struct urb *urb) if (current_len > 14) current_len = 14; current_len = - (len <= - current_len) ? len : current_len; + (len <= + current_len) ? len : current_len; /* how much bit do we put on the line? */ fifo->bit_line += current_len * 8; @@ -617,7 +617,7 @@ tx_iso_complete(struct urb *urb) if (!transp_mode) { /* here frame completion */ context_iso_urb-> - buffer[tx_offset] = 1; + buffer[tx_offset] = 1; /* add 2 byte flags and 16bit CRC at end of ISDN frame */ fifo->bit_line += 32; } @@ -632,12 +632,12 @@ tx_iso_complete(struct urb *urb) /* define packet delimeters within the URB buffer */ urb->iso_frame_desc[k].offset = tx_offset; urb->iso_frame_desc[k].length = - current_len + 1; + current_len + 1; tx_offset += (current_len + 1); } else { urb->iso_frame_desc[k].offset = - tx_offset++; + tx_offset++; urb->iso_frame_desc[k].length = 1; fifo->bit_line -= sink; /* we lower data margin every msec */ @@ -683,7 +683,7 @@ rx_iso_complete(struct urb *urb) usb_fifo *fifo = context_iso_urb->owner_fifo; hfcusb_data *hfc = fifo->hfc; int k, len, errcode, offset, num_isoc_packets, fifon, maxlen, - status; + status; unsigned int iso_status; __u8 *buf; static __u8 eof[8]; @@ -723,10 +723,10 @@ rx_iso_complete(struct urb *urb) if (fifon == HFCUSB_D_RX) { DBG(HFCUSB_DBG_VERBOSE_USB, - "HFC-S USB: ISO-D-RX lst_urblen:%2d " - "act_urblen:%2d max-urblen:%2d EOF:0x%0x", - fifo->last_urblen, len, maxlen, - eof[5]); + "HFC-S USB: ISO-D-RX lst_urblen:%2d " + "act_urblen:%2d max-urblen:%2d EOF:0x%0x", + fifo->last_urblen, len, maxlen, + eof[5]); DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len); } @@ -778,7 +778,7 @@ rx_iso_complete(struct urb *urb) /* collect rx data from INT- and ISO-URBs */ static void -collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) +collect_rx_frame(usb_fifo *fifo, __u8 *data, int len, int finish) { hfcusb_data *hfc = fifo->hfc; int transp_mode, fifon; @@ -802,8 +802,8 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) memcpy(skb_put(fifo->skbuff, len), data, len); } else { DBG(HFCUSB_DBG_FIFO_ERR, - "HCF-USB: got frame exceeded fifo->max_size(%d) fifo(%d)", - fifo->max_size, fifon); + "HCF-USB: got frame exceeded fifo->max_size(%d) fifo(%d)", + fifo->max_size, fifon); DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff); skb_trim(fifo->skbuff, 0); } @@ -817,7 +817,7 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) /* we have a complete hdlc packet */ if (finish) { if (fifo->skbuff->len > 3 && - !fifo->skbuff->data[fifo->skbuff->len - 1]) { + !fifo->skbuff->data[fifo->skbuff->len - 1]) { if (fifon == HFCUSB_D_RX) { DBG(HFCUSB_DBG_DCHANNEL, @@ -876,10 +876,10 @@ rx_int_complete(struct urb *urb) if (fifon == HFCUSB_D_RX) { DBG(HFCUSB_DBG_VERBOSE_USB, - "HFC-S USB: INT-D-RX lst_urblen:%2d " - "act_urblen:%2d max-urblen:%2d EOF:0x%0x", - fifo->last_urblen, len, maxlen, - eof[5]); + "HFC-S USB: INT-D-RX lst_urblen:%2d " + "act_urblen:%2d max-urblen:%2d EOF:0x%0x", + fifo->last_urblen, len, maxlen, + eof[5]); DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len); } @@ -909,7 +909,7 @@ rx_int_complete(struct urb *urb) /* start initial INT-URB for certain fifo */ static void -start_int_fifo(usb_fifo * fifo) +start_int_fifo(usb_fifo *fifo) { int errcode; @@ -936,7 +936,7 @@ start_int_fifo(usb_fifo * fifo) } static void -setup_bchannel(hfcusb_data * hfc, int channel, int mode) +setup_bchannel(hfcusb_data *hfc, int channel, int mode) { __u8 val, idx_table[2] = { 0, 2 }; @@ -999,100 +999,100 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) hfcusb_data *hfc = fifo->hfc; switch (pr) { - case PH_ACTIVATE | REQUEST: - if (fifo->fifonum == HFCUSB_D_TX) { + case PH_ACTIVATE | REQUEST: + if (fifo->fifonum == HFCUSB_D_TX) { + DBG(HFCUSB_DBG_STATES, + "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST"); + + if (hfc->l1_state != 3 + && hfc->l1_state != 7) { + hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, + PH_DEACTIVATE | + INDICATION, + NULL); DBG(HFCUSB_DBG_STATES, - "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST"); - - if (hfc->l1_state != 3 - && hfc->l1_state != 7) { - hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, - PH_DEACTIVATE | + "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)"); + } else { + if (hfc->l1_state == 7) { /* l1 already active */ + hfc->d_if.ifc.l1l2(&hfc-> + d_if. + ifc, + PH_ACTIVATE + | INDICATION, NULL); DBG(HFCUSB_DBG_STATES, - "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)"); + "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)"); } else { - if (hfc->l1_state == 7) { /* l1 already active */ - hfc->d_if.ifc.l1l2(&hfc-> - d_if. - ifc, - PH_ACTIVATE - | - INDICATION, - NULL); - DBG(HFCUSB_DBG_STATES, - "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)"); - } else { - /* force sending sending INFO1 */ - queue_control_request(hfc, - HFCUSB_STATES, - 0x14, - 1); - mdelay(1); - /* start l1 activation */ - queue_control_request(hfc, - HFCUSB_STATES, - 0x04, - 1); - if (!timer_pending - (&hfc->t3_timer)) { - hfc->t3_timer. - expires = - jiffies + - (HFC_TIMER_T3 * - HZ) / 1000; - add_timer(&hfc-> - t3_timer); - } + /* force sending sending INFO1 */ + queue_control_request(hfc, + HFCUSB_STATES, + 0x14, + 1); + mdelay(1); + /* start l1 activation */ + queue_control_request(hfc, + HFCUSB_STATES, + 0x04, + 1); + if (!timer_pending + (&hfc->t3_timer)) { + hfc->t3_timer. + expires = + jiffies + + (HFC_TIMER_T3 * + HZ) / 1000; + add_timer(&hfc-> + t3_timer); } } - } else { - DBG(HFCUSB_DBG_STATES, - "HFC_USB: hfc_usb_d_l2l1 B-chan: PH_ACTIVATE | REQUEST"); - setup_bchannel(hfc, - (fifo->fifonum == - HFCUSB_B1_TX) ? 0 : 1, - (long) arg); - fifo->hif->l1l2(fifo->hif, - PH_ACTIVATE | INDICATION, - NULL); - } - break; - case PH_DEACTIVATE | REQUEST: - if (fifo->fifonum == HFCUSB_D_TX) { - DBG(HFCUSB_DBG_STATES, - "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST"); - } else { - DBG(HFCUSB_DBG_STATES, - "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST"); - setup_bchannel(hfc, - (fifo->fifonum == - HFCUSB_B1_TX) ? 0 : 1, - (int) L1_MODE_NULL); - fifo->hif->l1l2(fifo->hif, - PH_DEACTIVATE | INDICATION, - NULL); - } - break; - case PH_DATA | REQUEST: - if (fifo->skbuff && fifo->delete_flg) { - dev_kfree_skb_any(fifo->skbuff); - fifo->skbuff = NULL; - fifo->delete_flg = 0; } - fifo->skbuff = arg; /* we have a new buffer */ - break; - default: + } else { + DBG(HFCUSB_DBG_STATES, + "HFC_USB: hfc_usb_d_l2l1 B-chan: PH_ACTIVATE | REQUEST"); + setup_bchannel(hfc, + (fifo->fifonum == + HFCUSB_B1_TX) ? 0 : 1, + (long) arg); + fifo->hif->l1l2(fifo->hif, + PH_ACTIVATE | INDICATION, + NULL); + } + break; + case PH_DEACTIVATE | REQUEST: + if (fifo->fifonum == HFCUSB_D_TX) { + DBG(HFCUSB_DBG_STATES, + "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST"); + } else { DBG(HFCUSB_DBG_STATES, - "HFC_USB: hfc_usb_d_l2l1: unknown state : %#x", pr); - break; + "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST"); + setup_bchannel(hfc, + (fifo->fifonum == + HFCUSB_B1_TX) ? 0 : 1, + (int) L1_MODE_NULL); + fifo->hif->l1l2(fifo->hif, + PH_DEACTIVATE | INDICATION, + NULL); + } + break; + case PH_DATA | REQUEST: + if (fifo->skbuff && fifo->delete_flg) { + dev_kfree_skb_any(fifo->skbuff); + fifo->skbuff = NULL; + fifo->delete_flg = 0; + } + fifo->skbuff = arg; /* we have a new buffer */ + break; + default: + DBG(HFCUSB_DBG_STATES, + "HFC_USB: hfc_usb_d_l2l1: unknown state : %#x", pr); + break; } } /* initial init HFC-S USB chip registers, HiSax interface, USB URBs */ static int -hfc_usb_init(hfcusb_data * hfc) +hfc_usb_init(hfcusb_data *hfc) { usb_fifo *fifo; int i; @@ -1138,7 +1138,7 @@ hfc_usb_init(hfcusb_data * hfc) write_usb(hfc, HFCUSB_FIFO, i); /* select the desired fifo */ fifo[i].skbuff = NULL; /* init buffer pointer */ fifo[i].max_size = - (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; + (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; fifo[i].last_urblen = 0; /* set 2 bit for D- & E-channel */ write_usb(hfc, HFCUSB_HDLC_PAR, @@ -1185,7 +1185,7 @@ hfc_usb_init(hfcusb_data * hfc) usb_fill_control_urb(hfc->ctrl_urb, hfc->dev, hfc->ctrl_out_pipe, - (u_char *) & hfc->ctrl_write, + (u_char *)&hfc->ctrl_write, NULL, 0, ctrl_complete, hfc); /* Init All Fifos */ for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { @@ -1264,9 +1264,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) struct usb_host_endpoint *ep; int ifnum = iface->desc.bInterfaceNumber; int i, idx, alt_idx, probe_alt_setting, vend_idx, cfg_used, *vcf, - attr, cfg_found, cidx, ep_addr; + attr, cfg_found, cidx, ep_addr; int cmptbl[16], small_match, iso_packet_size, packet_size, - alt_used = 0; + alt_used = 0; hfcsusb_vdata *driver_info; vend_idx = 0xffff; @@ -1309,7 +1309,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) for (i = 0; i < iface->desc.bNumEndpoints; i++) { ep_addr = - ep->desc.bEndpointAddress; + ep->desc.bEndpointAddress; /* get endpoint base */ idx = ((ep_addr & 0x7f) - 1) * 2; if (ep_addr & 0x80) @@ -1345,7 +1345,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) if (cfg_used < small_match) { small_match = cfg_used; alt_used = - probe_alt_setting; + probe_alt_setting; iface_used = iface; } } @@ -1376,95 +1376,95 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) if (vcf[idx] != EP_NOP && vcf[idx] != EP_NUL) { switch (attr) { - case USB_ENDPOINT_XFER_INT: - context-> - fifos[cidx]. - pipe = - usb_rcvintpipe - (dev, - ep->desc. - bEndpointAddress); + case USB_ENDPOINT_XFER_INT: + context-> + fifos[cidx]. + pipe = + usb_rcvintpipe + (dev, + ep->desc. + bEndpointAddress); + context-> + fifos[cidx]. + usb_transfer_mode + = USB_INT; + packet_size = + le16_to_cpu(ep->desc.wMaxPacketSize); + break; + case USB_ENDPOINT_XFER_BULK: + if (ep_addr & 0x80) context-> - fifos[cidx]. - usb_transfer_mode - = USB_INT; - packet_size = - le16_to_cpu(ep->desc.wMaxPacketSize); - break; - case USB_ENDPOINT_XFER_BULK: - if (ep_addr & 0x80) - context-> - fifos - [cidx]. - pipe = - usb_rcvbulkpipe - (dev, - ep-> - desc. - bEndpointAddress); - else - context-> - fifos - [cidx]. - pipe = - usb_sndbulkpipe - (dev, - ep-> - desc. - bEndpointAddress); + fifos + [cidx]. + pipe = + usb_rcvbulkpipe + (dev, + ep-> + desc. + bEndpointAddress); + else context-> - fifos[cidx]. - usb_transfer_mode - = USB_BULK; - packet_size = - le16_to_cpu(ep->desc.wMaxPacketSize); - break; - case USB_ENDPOINT_XFER_ISOC: - if (ep_addr & 0x80) - context-> - fifos - [cidx]. - pipe = - usb_rcvisocpipe - (dev, - ep-> - desc. - bEndpointAddress); - else - context-> - fifos - [cidx]. - pipe = - usb_sndisocpipe - (dev, - ep-> - desc. - bEndpointAddress); + fifos + [cidx]. + pipe = + usb_sndbulkpipe + (dev, + ep-> + desc. + bEndpointAddress); + context-> + fifos[cidx]. + usb_transfer_mode + = USB_BULK; + packet_size = + le16_to_cpu(ep->desc.wMaxPacketSize); + break; + case USB_ENDPOINT_XFER_ISOC: + if (ep_addr & 0x80) context-> - fifos[cidx]. - usb_transfer_mode - = USB_ISOC; - iso_packet_size = - le16_to_cpu(ep->desc.wMaxPacketSize); - break; - default: + fifos + [cidx]. + pipe = + usb_rcvisocpipe + (dev, + ep-> + desc. + bEndpointAddress); + else context-> - fifos[cidx]. - pipe = 0; + fifos + [cidx]. + pipe = + usb_sndisocpipe + (dev, + ep-> + desc. + bEndpointAddress); + context-> + fifos[cidx]. + usb_transfer_mode + = USB_ISOC; + iso_packet_size = + le16_to_cpu(ep->desc.wMaxPacketSize); + break; + default: + context-> + fifos[cidx]. + pipe = 0; } /* switch attribute */ if (context->fifos[cidx].pipe) { context->fifos[cidx]. - fifonum = cidx; + fifonum = cidx; context->fifos[cidx].hfc = - context; + context; context->fifos[cidx].usb_packet_maxlen = - le16_to_cpu(ep->desc.wMaxPacketSize); + le16_to_cpu(ep->desc.wMaxPacketSize); context->fifos[cidx]. - intervall = - ep->desc.bInterval; + intervall = + ep->desc.bInterval; context->fifos[cidx]. - skbuff = NULL; + skbuff = NULL; } } ep++; @@ -1480,14 +1480,14 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) /* create the control pipes needed for register access */ context->ctrl_in_pipe = - usb_rcvctrlpipe(context->dev, 0); + usb_rcvctrlpipe(context->dev, 0); context->ctrl_out_pipe = - usb_sndctrlpipe(context->dev, 0); + usb_sndctrlpipe(context->dev, 0); context->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL); driver_info = - (hfcsusb_vdata *) hfcusb_idtab[vend_idx]. - driver_info; + (hfcsusb_vdata *) hfcusb_idtab[vend_idx]. + driver_info; printk(KERN_INFO "HFC-S USB: detected \"%s\"\n", driver_info->vend_name); diff --git a/drivers/isdn/hisax/hfc_usb.h b/drivers/isdn/hisax/hfc_usb.h index 2f581c0b4693..f987bf89da1a 100644 --- a/drivers/isdn/hisax/hfc_usb.h +++ b/drivers/isdn/hisax/hfc_usb.h @@ -76,11 +76,11 @@ #define SINK_MIN 48 #define SINK_DMIN 12 #define SINK_DMAX 18 -#define BITLINE_INF (-64*8) +#define BITLINE_INF (-64 * 8) /* HFC-S USB register access by Control-URSs */ -#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) -#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) +#define write_usb(a, b, c) usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), NULL, 0, HFC_CTRL_TIMEOUT) +#define read_usb(a, b, c) usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), 1, HFC_CTRL_TIMEOUT) #define HFC_CTRL_BUFSIZE 32 /* entry and size of output/input control buffer */ @@ -200,8 +200,8 @@ typedef struct { #define LED_B2_OFF 9 #define LED_B2_DATA 10 -#define LED_NORMAL 0 // LEDs are normal -#define LED_INVERTED 1 // LEDs are inverted +#define LED_NORMAL 0 // LEDs are normal +#define LED_INVERTED 1 // LEDs are inverted #endif // __HFC_USB_H__ diff --git a/drivers/isdn/hisax/hfcscard.c b/drivers/isdn/hisax/hfcscard.c index 20d7688b397b..a5f048bd2bb3 100644 --- a/drivers/isdn/hisax/hfcscard.c +++ b/drivers/isdn/hisax/hfcscard.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -26,8 +26,8 @@ hfcs_interrupt(int intno, void *dev_id) u_long flags; spin_lock_irqsave(&cs->lock, flags); - if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) & - (stat = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_STAT))) { + if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) & + (stat = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_STAT))) { val = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_INT_S1); if (cs->debug & L1_DEB_ISAC) debugl1(cs, "HFCS: stat(%02x) s1(%02x)", stat, val); @@ -106,57 +106,57 @@ hfcs_card_msg(struct IsdnCardState *cs, int mt, void *arg) if (cs->debug & L1_DEB_ISAC) debugl1(cs, "HFCS: card_msg %x", mt); switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_hfcs(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_hfcs(cs); - return(0); - case CARD_INIT: - delay = (75*HZ)/100 +1; - mod_timer(&cs->hw.hfcD.timer, jiffies + delay); - spin_lock_irqsave(&cs->lock, flags); - reset_hfcs(cs); - init2bds0(cs); - spin_unlock_irqrestore(&cs->lock, flags); - delay = (80*HZ)/1000 +1; - msleep(80); - spin_lock_irqsave(&cs->lock, flags); - cs->hw.hfcD.ctmt |= HFCD_TIM800; - cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt); - cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_hfcs(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_hfcs(cs); + return (0); + case CARD_INIT: + delay = (75 * HZ) / 100 + 1; + mod_timer(&cs->hw.hfcD.timer, jiffies + delay); + spin_lock_irqsave(&cs->lock, flags); + reset_hfcs(cs); + init2bds0(cs); + spin_unlock_irqrestore(&cs->lock, flags); + delay = (80 * HZ) / 1000 + 1; + msleep(80); + spin_lock_irqsave(&cs->lock, flags); + cs->hw.hfcD.ctmt |= HFCD_TIM800; + cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt); + cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } #ifdef __ISAPNP__ static struct isapnp_device_id hfc_ids[] __devinitdata = { { ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), - ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), + ISAPNP_VENDOR('A', 'N', 'X'), ISAPNP_FUNCTION(0x1114), (unsigned long) "Acer P10" }, { ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0002), - ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0002), + ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0002), (unsigned long) "Billion 2" }, { ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0001), - ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0001), + ISAPNP_VENDOR('B', 'I', 'L'), ISAPNP_FUNCTION(0x0001), (unsigned long) "Billion 1" }, { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x7410), - ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x7410), + ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x7410), (unsigned long) "IStar PnP" }, { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2610), - ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2610), + ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2610), (unsigned long) "Teles 16.3c" }, { ISAPNP_VENDOR('S', 'F', 'M'), ISAPNP_FUNCTION(0x0001), - ISAPNP_VENDOR('S', 'F', 'M'), ISAPNP_FUNCTION(0x0001), + ISAPNP_VENDOR('S', 'F', 'M'), ISAPNP_FUNCTION(0x0001), (unsigned long) "Tornado Tipa C" }, { ISAPNP_VENDOR('K', 'Y', 'E'), ISAPNP_FUNCTION(0x0001), - ISAPNP_VENDOR('K', 'Y', 'E'), ISAPNP_FUNCTION(0x0001), + ISAPNP_VENDOR('K', 'Y', 'E'), ISAPNP_FUNCTION(0x0001), (unsigned long) "Genius Speed Surfer" }, { 0, } }; @@ -177,30 +177,30 @@ setup_hfcs(struct IsdnCard *card) #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "HFC PnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); + card->para[0], card->para[1]); pnp_disable_dev(pnp_d); - return(0); + return (0); } break; } else { @@ -209,10 +209,10 @@ setup_hfcs(struct IsdnCard *card) } ipid++; pnp_c = NULL; - } + } if (!ipid->card_vendor) { printk(KERN_INFO "HFC PnP: no ISAPnP card found\n"); - return(0); + return (0); } } #endif @@ -229,7 +229,7 @@ setup_hfcs(struct IsdnCard *card) if (cs->typ == ISDN_CTYPE_TELES3C) { cs->hw.hfcD.bfifosize = 1024 + 512; } else if (cs->typ == ISDN_CTYPE_ACERP10) { - cs->hw.hfcD.bfifosize = 7*1024 + 512; + cs->hw.hfcD.bfifosize = 7 * 1024 + 512; } else return (0); if (!request_region(cs->hw.hfcD.addr, 2, "HFCS isdn")) { diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h index aff45a11a92d..6ead6314e6d2 100644 --- a/drivers/isdn/hisax/hisax.h +++ b/drivers/isdn/hisax/hisax.h @@ -133,15 +133,15 @@ extern const char *tei_revision; /* include l3dss1 & ni1 specific process structures, but no other defines */ #ifdef CONFIG_HISAX_EURO - #define l3dss1_process - #include "l3dss1.h" - #undef l3dss1_process +#define l3dss1_process +#include "l3dss1.h" +#undef l3dss1_process #endif /* CONFIG_HISAX_EURO */ #ifdef CONFIG_HISAX_NI1 - #define l3ni1_process - #include "l3ni1.h" - #undef l3ni1_process +#define l3ni1_process +#include "l3ni1.h" +#undef l3ni1_process #endif /* CONFIG_HISAX_NI1 */ #define MAX_DFRAME_LEN 260 @@ -149,7 +149,7 @@ extern const char *tei_revision; #define HSCX_BUFMAX 4096 #define MAX_DATA_SIZE (HSCX_BUFMAX - 4) #define MAX_DATA_MEM (HSCX_BUFMAX + 64) -#define RAW_BUFMAX (((HSCX_BUFMAX*6)/5) + 5) +#define RAW_BUFMAX (((HSCX_BUFMAX * 6) / 5) + 5) #define MAX_HEADER_LEN 4 #define MAX_WINDOW 8 #define MAX_MON_FRAME 32 @@ -165,7 +165,7 @@ extern const char *tei_revision; struct FsmInst; -typedef void (* FSMFNPTR)(struct FsmInst *, int, void *); +typedef void (*FSMFNPTR)(struct FsmInst *, int, void *); struct Fsm { FSMFNPTR *jumpmatrix; @@ -272,10 +272,10 @@ struct Layer2 { struct Layer3 { void (*l3l4) (struct PStack *, int, void *); - void (*l3ml3) (struct PStack *, int, void *); + void (*l3ml3) (struct PStack *, int, void *); void (*l3l2) (struct PStack *, int, void *); struct FsmInst l3m; - struct FsmTimer l3m_timer; + struct FsmTimer l3m_timer; struct sk_buff_head squeue; struct l3_process *proc; struct l3_process *global; @@ -286,7 +286,7 @@ struct Layer3 { struct LLInterface { void (*l4l3) (struct PStack *, int, void *); - int (*l4l3_proto) (struct PStack *, isdn_ctrl *); + int (*l4l3_proto) (struct PStack *, isdn_ctrl *); void *userdata; u_long flag; }; @@ -325,16 +325,16 @@ struct PStack { struct Management ma; int protocol; /* EDSS1, 1TR6 or NI1 */ - /* protocol specific data fields */ - union - { u_char uuuu; /* only as dummy */ + /* protocol specific data fields */ + union + { u_char uuuu; /* only as dummy */ #ifdef CONFIG_HISAX_EURO - dss1_stk_priv dss1; /* private dss1 data */ -#endif /* CONFIG_HISAX_EURO */ + dss1_stk_priv dss1; /* private dss1 data */ +#endif /* CONFIG_HISAX_EURO */ #ifdef CONFIG_HISAX_NI1 - ni1_stk_priv ni1; /* private ni1 data */ -#endif /* CONFIG_HISAX_NI1 */ - } prot; + ni1_stk_priv ni1; /* private ni1 data */ +#endif /* CONFIG_HISAX_NI1 */ + } prot; }; struct l3_process { @@ -347,18 +347,18 @@ struct l3_process { struct Channel *chan; struct PStack *st; struct l3_process *next; - ulong redir_result; - - /* protocol specific data fields */ - union - { u_char uuuu; /* only when euro not defined, avoiding empty union */ -#ifdef CONFIG_HISAX_EURO - dss1_proc_priv dss1; /* private dss1 data */ -#endif /* CONFIG_HISAX_EURO */ + ulong redir_result; + + /* protocol specific data fields */ + union + { u_char uuuu; /* only when euro not defined, avoiding empty union */ +#ifdef CONFIG_HISAX_EURO + dss1_proc_priv dss1; /* private dss1 data */ +#endif /* CONFIG_HISAX_EURO */ #ifdef CONFIG_HISAX_NI1 - ni1_proc_priv ni1; /* private ni1 data */ -#endif /* CONFIG_HISAX_NI1 */ - } prot; + ni1_proc_priv ni1; /* private ni1 data */ +#endif /* CONFIG_HISAX_NI1 */ + } prot; }; struct hscx_hw { @@ -642,7 +642,7 @@ struct hfc_hw { unsigned char cip; u_char isac_spcr; struct timer_list timer; -}; +}; struct sedl_hw { unsigned int cfg_reg; @@ -693,25 +693,25 @@ struct hfcPCI_hw { unsigned char int_m2; unsigned char int_s1; unsigned char sctrl; - unsigned char sctrl_r; - unsigned char sctrl_e; - unsigned char trm; + unsigned char sctrl_r; + unsigned char sctrl_e; + unsigned char trm; unsigned char stat; unsigned char fifo; - unsigned char fifo_en; - unsigned char bswapped; - unsigned char nt_mode; - int nt_timer; - struct pci_dev *dev; - unsigned char *pci_io; /* start of PCI IO memory */ + unsigned char fifo_en; + unsigned char bswapped; + unsigned char nt_mode; + int nt_timer; + struct pci_dev *dev; + unsigned char *pci_io; /* start of PCI IO memory */ dma_addr_t dma; /* dma handle for Fifos */ - void *fifos; /* FIFO memory */ - int last_bfifo_cnt[2]; /* marker saving last b-fifo frame count */ + void *fifos; /* FIFO memory */ + int last_bfifo_cnt[2]; /* marker saving last b-fifo frame count */ struct timer_list timer; }; struct hfcSX_hw { - unsigned long base; + unsigned long base; unsigned char cirm; unsigned char ctmt; unsigned char conn; @@ -720,18 +720,18 @@ struct hfcSX_hw { unsigned char int_m2; unsigned char int_s1; unsigned char sctrl; - unsigned char sctrl_r; - unsigned char sctrl_e; - unsigned char trm; + unsigned char sctrl_r; + unsigned char sctrl_e; + unsigned char trm; unsigned char stat; unsigned char fifo; - unsigned char bswapped; - unsigned char nt_mode; - unsigned char chip; - int b_fifo_size; - unsigned char last_fifo; - void *extra; - int nt_timer; + unsigned char bswapped; + unsigned char nt_mode; + unsigned char chip; + int b_fifo_size; + unsigned char last_fifo; + void *extra; + int nt_timer; struct timer_list timer; }; @@ -784,13 +784,13 @@ struct bkm_hw { /* Scitel Quadro stuff */ unsigned long plx_adr; unsigned long data_adr; -}; +}; struct gazel_hw { struct pci_dev *dev; unsigned int cfg_reg; unsigned int pciaddr[2]; - signed int ipac; + signed int ipac; signed int isac; signed int hscx[2]; signed int isacfifo; @@ -877,8 +877,8 @@ struct icc_chip { #define HW_ARCOFI 3 #define FLG_TWO_DCHAN 4 #define FLG_L1_DBUSY 5 -#define FLG_DBUSY_TIMER 6 -#define FLG_LOCK_ATOMIC 7 +#define FLG_DBUSY_TIMER 6 +#define FLG_LOCK_ATOMIC 7 #define FLG_ARCOFI_TIMER 8 #define FLG_ARCOFI_ERROR 9 #define FLG_HW_L1_UINT 10 @@ -892,8 +892,8 @@ struct IsdnCardState { u_long irq_flags; u_long HW_Flags; int *busy_flag; - int chanlimit; /* limited number of B-chans to use */ - int logecho; /* log echo if supported by card */ + int chanlimit; /* limited number of B-chans to use */ + int logecho; /* log echo if supported by card */ union { struct elsa_hw elsa; struct teles0_hw teles0; @@ -937,8 +937,8 @@ struct IsdnCardState { void (*DC_Close) (struct IsdnCardState *); irq_handler_t irq_func; int (*auxcmd) (struct IsdnCardState *, isdn_ctrl *); - struct Channel channel[2+MAX_WAITING_CALLS]; - struct BCState bcs[2+MAX_WAITING_CALLS]; + struct Channel channel[2 + MAX_WAITING_CALLS]; + struct BCState bcs[2 + MAX_WAITING_CALLS]; struct PStack *stlist; struct sk_buff_head rq, sq; /* D-channel queues */ int cardnr; @@ -969,7 +969,7 @@ struct IsdnCardState { }; -#define schedule_event(s, ev) do {test_and_set_bit(ev, &s->event);schedule_work(&s->tqueue); } while(0) +#define schedule_event(s, ev) do { test_and_set_bit(ev, &s->event); schedule_work(&s->tqueue); } while (0) #define MON0_RX 1 #define MON1_RX 2 @@ -1053,7 +1053,7 @@ struct IsdnCardState { #define CARD_IX1MICROR2 0 #endif -#ifdef CONFIG_HISAX_DIEHLDIVA +#ifdef CONFIG_HISAX_DIEHLDIVA #define CARD_DIEHLDIVA 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1062,7 +1062,7 @@ struct IsdnCardState { #define CARD_DIEHLDIVA 0 #endif -#ifdef CONFIG_HISAX_ASUSCOM +#ifdef CONFIG_HISAX_ASUSCOM #define CARD_ASUSCOM 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1071,7 +1071,7 @@ struct IsdnCardState { #define CARD_ASUSCOM 0 #endif -#ifdef CONFIG_HISAX_TELEINT +#ifdef CONFIG_HISAX_TELEINT #define CARD_TELEINT 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1080,7 +1080,7 @@ struct IsdnCardState { #define CARD_TELEINT 0 #endif -#ifdef CONFIG_HISAX_SEDLBAUER +#ifdef CONFIG_HISAX_SEDLBAUER #define CARD_SEDLBAUER 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1089,7 +1089,7 @@ struct IsdnCardState { #define CARD_SEDLBAUER 0 #endif -#ifdef CONFIG_HISAX_SPORTSTER +#ifdef CONFIG_HISAX_SPORTSTER #define CARD_SPORTSTER 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1098,7 +1098,7 @@ struct IsdnCardState { #define CARD_SPORTSTER 0 #endif -#ifdef CONFIG_HISAX_MIC +#ifdef CONFIG_HISAX_MIC #define CARD_MIC 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1107,7 +1107,7 @@ struct IsdnCardState { #define CARD_MIC 0 #endif -#ifdef CONFIG_HISAX_NETJET +#ifdef CONFIG_HISAX_NETJET #define CARD_NETJET_S 1 #ifndef ISDN_CHIP_ISAC #define ISDN_CHIP_ISAC 1 @@ -1206,7 +1206,7 @@ struct IsdnCardState { #define CARD_W6692 0 #endif -#ifdef CONFIG_HISAX_NETJET_U +#ifdef CONFIG_HISAX_NETJET_U #define CARD_NETJET_U 1 #ifndef ISDN_CHIP_ICC #define ISDN_CHIP_ICC 1 @@ -1269,8 +1269,8 @@ void setstack_l3dc(struct PStack *st, struct Channel *chanp); void setstack_l3bc(struct PStack *st, struct Channel *chanp); void releasestack_isdnl3(struct PStack *st); -u_char *findie(u_char * p, int size, u_char ie, int wanted_set); -int getcallref(u_char * p); +u_char *findie(u_char *p, int size, u_char ie, int wanted_set); +int getcallref(u_char *p); int newcallref(void); int FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount); @@ -1279,36 +1279,36 @@ int FsmEvent(struct FsmInst *fi, int event, void *arg); void FsmChangeState(struct FsmInst *fi, int newstate); void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft); int FsmAddTimer(struct FsmTimer *ft, int millisec, int event, - void *arg, int where); + void *arg, int where); void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event, - void *arg, int where); + void *arg, int where); void FsmDelTimer(struct FsmTimer *ft, int where); int jiftime(char *s, long mark); -int HiSax_command(isdn_ctrl * ic); +int HiSax_command(isdn_ctrl *ic); int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb); __printf(3, 4) void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...); __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); -void LogFrame(struct IsdnCardState *cs, u_char * p, int size); +int QuickHex(char *txt, u_char *p, int cnt); +void LogFrame(struct IsdnCardState *cs, u_char *p, int size); void dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir); -void iecpy(u_char * dest, u_char * iestart, int ieoffset); +void iecpy(u_char *dest, u_char *iestart, int ieoffset); #endif /* __KERNEL__ */ /* * Busywait delay for `jiffs' jiffies */ -#define HZDELAY(jiffs) do { \ - int tout = jiffs; \ - \ - while (tout--) { \ - int loops = USEC_PER_SEC / HZ; \ - while (loops--) \ - udelay(1); \ - } \ +#define HZDELAY(jiffs) do { \ + int tout = jiffs; \ + \ + while (tout--) { \ + int loops = USEC_PER_SEC / HZ; \ + while (loops--) \ + udelay(1); \ + } \ } while (0) int ll_run(struct IsdnCardState *cs, int addfeatures); diff --git a/drivers/isdn/hisax/hisax_cfg.h b/drivers/isdn/hisax/hisax_cfg.h index 17a2fea64efe..487dcfe9e718 100644 --- a/drivers/isdn/hisax/hisax_cfg.h +++ b/drivers/isdn/hisax/hisax_cfg.h @@ -54,9 +54,9 @@ typedef struct IsdnCardState IsdnCardState_t; typedef struct IsdnCard IsdnCard_t; struct IsdnCard { - int typ; - int protocol; /* EDSS1, 1TR6 or NI1 */ - unsigned long para[4]; + int typ; + int protocol; /* EDSS1, 1TR6 or NI1 */ + unsigned long para[4]; IsdnCardState_t *cs; }; diff --git a/drivers/isdn/hisax/hisax_debug.h b/drivers/isdn/hisax/hisax_debug.h index 5ed3b1c44184..7b3093d0856a 100644 --- a/drivers/isdn/hisax/hisax_debug.h +++ b/drivers/isdn/hisax/hisax_debug.h @@ -4,12 +4,12 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen * 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * * How to use: - * + * * Before including this file, you need to * #define __debug_variable my_debug * where my_debug is a variable in your code which @@ -25,45 +25,45 @@ #ifdef CONFIG_HISAX_DEBUG -#define DBG(level, format, arg...) do { \ -if (level & __debug_variable) \ -printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ -} while (0) +#define DBG(level, format, arg...) do { \ + if (level & __debug_variable) \ + printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ + } while (0) -#define DBG_PACKET(level,data,count) \ - if (level & __debug_variable) dump_packet(__func__,data,count) +#define DBG_PACKET(level, data, count) \ + if (level & __debug_variable) dump_packet(__func__, data, count) -#define DBG_SKB(level,skb) \ - if ((level & __debug_variable) && skb) dump_packet(__func__,skb->data,skb->len) +#define DBG_SKB(level, skb) \ + if ((level & __debug_variable) && skb) dump_packet(__func__, skb->data, skb->len) static void __attribute__((unused)) -dump_packet(const char *name,const u_char *data,int pkt_len) +dump_packet(const char *name, const u_char *data, int pkt_len) { #define DUMP_HDR_SIZE 20 #define DUMP_TLR_SIZE 8 if (pkt_len) { - int i,len1,len2; + int i, len1, len2; - printk(KERN_DEBUG "%s: length=%d,data=",name,pkt_len); + printk(KERN_DEBUG "%s: length=%d,data=", name, pkt_len); - if (pkt_len > DUMP_HDR_SIZE+ DUMP_TLR_SIZE) { + if (pkt_len > DUMP_HDR_SIZE + DUMP_TLR_SIZE) { len1 = DUMP_HDR_SIZE; len2 = DUMP_TLR_SIZE; } else { len1 = pkt_len > DUMP_HDR_SIZE ? DUMP_HDR_SIZE : pkt_len; - len2 = 0; + len2 = 0; } for (i = 0; i < len1; ++i) { - printk ("%.2x", data[i]); + printk("%.2x", data[i]); } if (len2) { - printk (".."); + printk(".."); for (i = pkt_len-DUMP_TLR_SIZE; i < pkt_len; ++i) { - printk ("%.2x", data[i]); + printk("%.2x", data[i]); } } - printk ("\n"); + printk("\n"); } #undef DUMP_HDR_SIZE #undef DUMP_TLR_SIZE @@ -72,8 +72,8 @@ dump_packet(const char *name,const u_char *data,int pkt_len) #else #define DBG(level, format, arg...) do {} while (0) -#define DBG_PACKET(level,data,count) do {} while (0) -#define DBG_SKB(level,skb) do {} while (0) +#define DBG_PACKET(level, data, count) do {} while (0) +#define DBG_SKB(level, skb) do {} while (0) #endif diff --git a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c index 478ebab54ca4..e4f47fe3f7fd 100644 --- a/drivers/isdn/hisax/hisax_fcpcipnp.c +++ b/drivers/isdn/hisax/hisax_fcpcipnp.c @@ -4,7 +4,7 @@ * Author Kai Germaschewski * Copyright 2001 by Kai Germaschewski * 2001 by Karsten Keil - * + * * based upon Karsten Keil's original avm_pci.c driver * * This software may be used and distributed according to the terms @@ -71,7 +71,7 @@ MODULE_DEVICE_TABLE(pci, fcpci_ids); #ifdef CONFIG_PNP static struct pnp_device_id fcpnp_ids[] __devinitdata = { - { + { .id = "AVM0900", .driver_data = (unsigned long) "Fritz!Card PnP", }, @@ -153,7 +153,7 @@ MODULE_LICENSE("GPL"); static unsigned char fcpci_read_isac(struct isac *isac, unsigned char offset) { struct fritz_adapter *adapter = isac->priv; - unsigned char idx = (offset > 0x2f) ? + unsigned char idx = (offset > 0x2f) ? AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW; unsigned char val; unsigned long flags; @@ -161,7 +161,7 @@ static unsigned char fcpci_read_isac(struct isac *isac, unsigned char offset) spin_lock_irqsave(&adapter->hw_lock, flags); outb(idx, adapter->io + AVM_INDEX); val = inb(adapter->io + AVM_DATA + (offset & 0xf)); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); DBG(0x1000, " port %#x, value %#x", offset, val); return val; @@ -171,7 +171,7 @@ static void fcpci_write_isac(struct isac *isac, unsigned char offset, unsigned char value) { struct fritz_adapter *adapter = isac->priv; - unsigned char idx = (offset > 0x2f) ? + unsigned char idx = (offset > 0x2f) ? AVM_IDX_ISAC_REG_HIGH : AVM_IDX_ISAC_REG_LOW; unsigned long flags; @@ -180,10 +180,10 @@ static void fcpci_write_isac(struct isac *isac, unsigned char offset, spin_lock_irqsave(&adapter->hw_lock, flags); outb(idx, adapter->io + AVM_INDEX); outb(value, adapter->io + AVM_DATA + (offset & 0xf)); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); } -static void fcpci_read_isac_fifo(struct isac *isac, unsigned char * data, +static void fcpci_read_isac_fifo(struct isac *isac, unsigned char *data, int size) { struct fritz_adapter *adapter = isac->priv; @@ -192,10 +192,10 @@ static void fcpci_read_isac_fifo(struct isac *isac, unsigned char * data, spin_lock_irqsave(&adapter->hw_lock, flags); outb(AVM_IDX_ISAC_FIFO, adapter->io + AVM_INDEX); insb(adapter->io + AVM_DATA, data, size); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); } -static void fcpci_write_isac_fifo(struct isac *isac, unsigned char * data, +static void fcpci_write_isac_fifo(struct isac *isac, unsigned char *data, int size) { struct fritz_adapter *adapter = isac->priv; @@ -204,7 +204,7 @@ static void fcpci_write_isac_fifo(struct isac *isac, unsigned char * data, spin_lock_irqsave(&adapter->hw_lock, flags); outb(AVM_IDX_ISAC_FIFO, adapter->io + AVM_INDEX); outsb(adapter->io + AVM_DATA, data, size); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); } static u32 fcpci_read_hdlc_status(struct fritz_adapter *adapter, int nr) @@ -254,14 +254,14 @@ static unsigned char fcpci2_read_isac(struct isac *isac, unsigned char offset) spin_lock_irqsave(&adapter->hw_lock, flags); outl(offset, adapter->io + AVM_ISACSX_INDEX); val = inl(adapter->io + AVM_ISACSX_DATA); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); DBG(0x1000, " port %#x, value %#x", offset, val); return val; } -static void fcpci2_write_isac(struct isac *isac, unsigned char offset, +static void fcpci2_write_isac(struct isac *isac, unsigned char offset, unsigned char value) { struct fritz_adapter *adapter = isac->priv; @@ -272,10 +272,10 @@ static void fcpci2_write_isac(struct isac *isac, unsigned char offset, spin_lock_irqsave(&adapter->hw_lock, flags); outl(offset, adapter->io + AVM_ISACSX_INDEX); outl(value, adapter->io + AVM_ISACSX_DATA); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); } -static void fcpci2_read_isac_fifo(struct isac *isac, unsigned char * data, +static void fcpci2_read_isac_fifo(struct isac *isac, unsigned char *data, int size) { struct fritz_adapter *adapter = isac->priv; @@ -286,10 +286,10 @@ static void fcpci2_read_isac_fifo(struct isac *isac, unsigned char * data, outl(0, adapter->io + AVM_ISACSX_INDEX); for (i = 0; i < size; i++) data[i] = inl(adapter->io + AVM_ISACSX_DATA); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); } -static void fcpci2_write_isac_fifo(struct isac *isac, unsigned char * data, +static void fcpci2_write_isac_fifo(struct isac *isac, unsigned char *data, int size) { struct fritz_adapter *adapter = isac->priv; @@ -300,7 +300,7 @@ static void fcpci2_write_isac_fifo(struct isac *isac, unsigned char * data, outl(0, adapter->io + AVM_ISACSX_INDEX); for (i = 0; i < size; i++) outl(data[i], adapter->io + AVM_ISACSX_DATA); - spin_unlock_irqrestore(&adapter->hw_lock, flags); + spin_unlock_irqrestore(&adapter->hw_lock, flags); } static u32 fcpci2_read_hdlc_status(struct fritz_adapter *adapter, int nr) @@ -349,10 +349,10 @@ static void __fcpnp_write_ctrl(struct fritz_bcs *bcs, int which) outb(idx, adapter->io + AVM_INDEX); if (which & 4) - outb(bcs->ctrl.sr.mode, + outb(bcs->ctrl.sr.mode, adapter->io + AVM_DATA + HDLC_STATUS + 2); if (which & 2) - outb(bcs->ctrl.sr.xml, + outb(bcs->ctrl.sr.xml, adapter->io + AVM_DATA + HDLC_STATUS + 1); if (which & 1) outb(bcs->ctrl.sr.cmd, @@ -416,7 +416,7 @@ static void hdlc_fill_fifo(struct fritz_bcs *bcs) break; case AVM_FRITZ_PCIV2: fcpci2_write_ctrl(bcs, 3); - outsl(adapter->io + + outsl(adapter->io + (bcs->channel ? AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1), p, (count + 3) / 4); break; @@ -447,12 +447,12 @@ static inline void hdlc_empty_fifo(struct fritz_bcs *bcs, int count) case AVM_FRITZ_PCI: spin_lock(&adapter->hw_lock); outl(idx, adapter->io + AVM_INDEX); - insl(adapter->io + AVM_DATA + HDLC_FIFO, + insl(adapter->io + AVM_DATA + HDLC_FIFO, p, (count + 3) / 4); spin_unlock(&adapter->hw_lock); break; case AVM_FRITZ_PCIV2: - insl(adapter->io + + insl(adapter->io + (bcs->channel ? AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1), p, (count + 3) / 4); break; @@ -489,7 +489,7 @@ static inline void hdlc_rpr_irq(struct fritz_bcs *bcs, u32 stat) hdlc_empty_fifo(bcs, len); if ((stat & HDLC_STAT_RME) || (bcs->mode == L1_MODE_TRANS)) { - if (((stat & HDLC_STAT_CRCVFRRAB)== HDLC_STAT_CRCVFR) || + if (((stat & HDLC_STAT_CRCVFRRAB) == HDLC_STAT_CRCVFR) || (bcs->mode == L1_MODE_TRANS)) { skb = dev_alloc_skb(bcs->rcvidx); if (!skb) { @@ -512,7 +512,7 @@ static inline void hdlc_rpr_irq(struct fritz_bcs *bcs, u32 stat) static inline void hdlc_xdu_irq(struct fritz_bcs *bcs) { struct fritz_adapter *adapter = bcs->adapter; - + /* Here we lost an TX interrupt, so * restart transmitting the whole frame. @@ -587,7 +587,7 @@ static inline void hdlc_irq(struct fritz_adapter *adapter) static void modehdlc(struct fritz_bcs *bcs, int mode) { struct fritz_adapter *adapter = bcs->adapter; - + DBG(0x40, "hdlc %c mode %d --> %d", 'A' + bcs->channel, bcs->mode, mode); @@ -638,12 +638,12 @@ static void fritz_b_l2l1(struct hisax_if *ifc, int pr, void *arg) break; case PH_ACTIVATE | REQUEST: mode = (long) arg; - DBG(4,"B%d,PH_ACTIVATE_REQUEST %d", bcs->channel + 1, mode); + DBG(4, "B%d,PH_ACTIVATE_REQUEST %d", bcs->channel + 1, mode); modehdlc(bcs, mode); B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL); break; case PH_DEACTIVATE | REQUEST: - DBG(4,"B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); + DBG(4, "B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); modehdlc(bcs, L1_MODE_NULL); B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL); break; @@ -702,10 +702,10 @@ static inline void fcpci2_init(struct fritz_adapter *adapter) static inline void fcpci_init(struct fritz_adapter *adapter) { - outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER | + outb(AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER | AVM_STATUS0_ENA_IRQ, adapter->io + AVM_STATUS0); - outb(AVM_STATUS1_ENA_IOM | adapter->irq, + outb(AVM_STATUS1_ENA_IOM | adapter->irq, adapter->io + AVM_STATUS1); mdelay(10); } @@ -717,7 +717,7 @@ static int __devinit fcpcipnp_setup(struct fritz_adapter *adapter) u32 val = 0; int retval; - DBG(1,""); + DBG(1, ""); isac_init(&adapter->isac); // FIXME is this okay now @@ -737,7 +737,7 @@ static int __devinit fcpcipnp_setup(struct fritz_adapter *adapter) } DBG(1, "stat %#x Class %X Rev %d", - val, val & 0xff, (val>>8) & 0xff); + val, val & 0xff, (val >> 8) & 0xff); spin_lock_init(&adapter->hw_lock); adapter->isac.priv = adapter; @@ -819,15 +819,15 @@ static int __devinit fcpcipnp_setup(struct fritz_adapter *adapter) return 0; - err_region: +err_region: release_region(adapter->io, 32); - err: +err: return retval; } static void __devexit fcpcipnp_release(struct fritz_adapter *adapter) { - DBG(1,""); + DBG(1, ""); outb(0, adapter->io + AVM_STATUS0); free_irq(adapter->irq, adapter); @@ -836,7 +836,7 @@ static void __devexit fcpcipnp_release(struct fritz_adapter *adapter) // ---------------------------------------------------------------------- -static struct fritz_adapter * __devinit +static struct fritz_adapter * __devinit new_adapter(void) { struct fritz_adapter *adapter; @@ -850,7 +850,7 @@ new_adapter(void) adapter->isac.hisax_d_if.owner = THIS_MODULE; adapter->isac.hisax_d_if.ifc.priv = &adapter->isac; adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1; - + for (i = 0; i < 2; i++) { adapter->bcs[i].adapter = adapter; adapter->bcs[i].channel = i; @@ -862,7 +862,7 @@ new_adapter(void) b_if[i] = &adapter->bcs[i].b_if; if (hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp", - protocol) != 0) { + protocol) != 0) { kfree(adapter); adapter = NULL; } @@ -889,7 +889,7 @@ static int __devinit fcpci_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, adapter); - if (pdev->device == PCI_DEVICE_ID_AVM_A1_V2) + if (pdev->device == PCI_DEVICE_ID_AVM_A1_V2) adapter->type = AVM_FRITZ_PCIV2; else adapter->type = AVM_FRITZ_PCI; @@ -909,10 +909,10 @@ static int __devinit fcpci_probe(struct pci_dev *pdev, goto err_free; return 0; - - err_free: + +err_free: delete_adapter(adapter); - err: +err: return retval; } @@ -923,7 +923,7 @@ static int __devinit fcpnp_probe(struct pnp_dev *pdev, const struct pnp_device_i int retval; if (!pdev) - return(-ENODEV); + return (-ENODEV); retval = -ENOMEM; adapter = new_adapter(); @@ -938,7 +938,7 @@ static int __devinit fcpnp_probe(struct pnp_dev *pdev, const struct pnp_device_i retval = pnp_activate_dev(pdev); if (retval < 0) { printk(KERN_WARNING "%s: pnp_activate_dev(%s) ret(%d)\n", __func__, - (char *)dev_id->driver_data, retval); + (char *)dev_id->driver_data, retval); goto err_free; } adapter->io = pnp_port_start(pdev, 0); @@ -952,10 +952,10 @@ static int __devinit fcpnp_probe(struct pnp_dev *pdev, const struct pnp_device_i goto err_free; return 0; - - err_free: + +err_free: delete_adapter(adapter); - err: +err: return retval; } diff --git a/drivers/isdn/hisax/hisax_fcpcipnp.h b/drivers/isdn/hisax/hisax_fcpcipnp.h index 21fbcedf3a94..aedef97827fe 100644 --- a/drivers/isdn/hisax/hisax_fcpcipnp.h +++ b/drivers/isdn/hisax/hisax_fcpcipnp.h @@ -38,7 +38,7 @@ struct fritz_bcs { int rcvidx; int fifo_size; u_char rcvbuf[HSCX_BUFMAX]; /* B-Channel receive Buffer */ - + int tx_cnt; /* B-Channel transmit counter */ struct sk_buff *tx_skb; /* B-Channel transmit Buffer */ }; @@ -55,4 +55,3 @@ struct fritz_adapter { u32 (*read_hdlc_status) (struct fritz_adapter *adapter, int nr); void (*write_ctrl) (struct fritz_bcs *bcs, int which); }; - diff --git a/drivers/isdn/hisax/hisax_if.h b/drivers/isdn/hisax/hisax_if.h index aa7c94037b2b..7098d6bd5ff2 100644 --- a/drivers/isdn/hisax/hisax_if.h +++ b/drivers/isdn/hisax/hisax_if.h @@ -1,10 +1,10 @@ /* - * Interface between low level (hardware) drivers and + * Interface between low level (hardware) drivers and * HiSax protocol stack * * Author Kai Germaschewski * Copyright 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * diff --git a/drivers/isdn/hisax/hisax_isac.c b/drivers/isdn/hisax/hisax_isac.c index a8447fa2f470..5154c252a25f 100644 --- a/drivers/isdn/hisax/hisax_isac.c +++ b/drivers/isdn/hisax/hisax_isac.c @@ -1,11 +1,11 @@ /* - * Driver for ISAC-S and ISAC-SX + * Driver for ISAC-S and ISAC-SX * ISDN Subscriber Access Controller for Terminals * * Author Kai Germaschewski * Copyright 2001 by Kai Germaschewski * 2001 by Karsten Keil - * + * * based upon Karsten Keil's original isac.c driver * * This software may be used and distributed according to the terms @@ -36,10 +36,10 @@ static int debug = 1; module_param(debug, int, 0); static char *ISACVer[] = { - "2086/2186 V1.1", - "2085 B1", - "2085 B2", - "2085 V2.3" + "2086/2186 V1.1", + "2085 B1", + "2085 B2", + "2085 V2.3" }; #endif @@ -178,7 +178,7 @@ enum { ST_L1_F8, }; -#define L1_STATE_COUNT (ST_L1_F8+1) +#define L1_STATE_COUNT (ST_L1_F8 + 1) static char *strL1State[] = { @@ -382,7 +382,7 @@ static struct FsmNode L1FnList[] __initdata = {ST_L1_F3_PDOWN, EV_PH_AI8, l1_go_f7_act_ind}, {ST_L1_F3_PDOWN, EV_PH_ACTIVATE_REQ, l1_ar8}, {ST_L1_F3_PDOWN, EV_TIMER3, l1_timer3}, - + {ST_L1_F3_PEND_DEACT, EV_PH_RES, l1_di}, {ST_L1_F3_PEND_DEACT, EV_PH_EI, l1_di}, {ST_L1_F3_PEND_DEACT, EV_PH_DC, l1_go_f3pdown}, @@ -432,7 +432,7 @@ static void l1m_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; char buf[256]; - + va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); DBG(DBG_L1M, "%s", buf); @@ -522,7 +522,7 @@ static inline void isac_cisq_interrupt(struct isac *isac) } if (val & ISAC_CIR0_CIC1) { val = isac->read_isac(isac, ISAC_CIR1); - DBG(DBG_WARN, "ISAC CIR1 %#x", val ); + DBG(DBG_WARN, "ISAC CIR1 %#x", val); } } @@ -531,10 +531,10 @@ static inline void isac_rme_interrupt(struct isac *isac) unsigned char val; int count; struct sk_buff *skb; - + val = isac->read_isac(isac, ISAC_RSTA); - if ((val & (ISAC_RSTA_RDO | ISAC_RSTA_CRC | ISAC_RSTA_RAB) ) - != ISAC_RSTA_CRC) { + if ((val & (ISAC_RSTA_RDO | ISAC_RSTA_CRC | ISAC_RSTA_RAB)) + != ISAC_RSTA_CRC) { DBG(DBG_WARN, "RSTA %#x, dropped", val); isac->write_isac(isac, ISAC_CMDR, ISAC_CMDR_RMC); goto out; @@ -560,7 +560,7 @@ static inline void isac_rme_interrupt(struct isac *isac) memcpy(skb_put(skb, count), isac->rcvbuf, count); DBG_SKB(DBG_RPACKET, skb); D_L1L2(isac, PH_DATA | INDICATION, skb); - out: +out: isac->rcvidx = 0; } @@ -659,10 +659,10 @@ static inline void isacsx_rme_interrupt(struct isac *isac) unsigned char val; val = isac->read_isac(isac, ISACSX_RSTAD); - if ((val & (ISACSX_RSTAD_VFR | - ISACSX_RSTAD_RDO | - ISACSX_RSTAD_CRC | - ISACSX_RSTAD_RAB)) + if ((val & (ISACSX_RSTAD_VFR | + ISACSX_RSTAD_RDO | + ISACSX_RSTAD_CRC | + ISACSX_RSTAD_RAB)) != (ISACSX_RSTAD_VFR | ISACSX_RSTAD_CRC)) { DBG(DBG_WARN, "RSTAD %#x, dropped", val); isac->write_isac(isac, ISACSX_CMDRD, ISACSX_CMDRD_RMC); @@ -690,7 +690,7 @@ static inline void isacsx_rme_interrupt(struct isac *isac) memcpy(skb_put(skb, count), isac->rcvbuf, count); DBG_SKB(DBG_RPACKET, skb); D_L1L2(isac, PH_DATA | INDICATION, skb); - out: +out: isac->rcvidx = 0; } @@ -778,8 +778,8 @@ void isac_setup(struct isac *isac) ph_command(isac, ISAC_CMD_RES); - isac->write_isac(isac, ISAC_MASK, 0xff); - isac->mocr = 0xaa; + isac->write_isac(isac, ISAC_MASK, 0xff); + isac->mocr = 0xaa; if (test_bit(ISAC_IOM1, &isac->flags)) { /* IOM 1 Mode */ isac->write_isac(isac, ISAC_ADF2, 0x0); @@ -832,7 +832,7 @@ void isacsx_setup(struct isac *isac) // all HDLC IRQ unmasked isac->write_isac(isac, ISACSX_MASKD, 0x03); // unmask ICD, CID IRQs - isac->write_isac(isac, ISACSX_MASK, + isac->write_isac(isac, ISACSX_MASK, ~(ISACSX_ISTA_ICD | ISACSX_ISTA_CIC)); } diff --git a/drivers/isdn/hisax/hscx.c b/drivers/isdn/hisax/hscx.c index 904b9100df95..3e305fec0ed9 100644 --- a/drivers/isdn/hisax/hscx.c +++ b/drivers/isdn/hisax/hscx.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -54,7 +54,7 @@ modehscx(struct BCState *bcs, int mode, int bc) cs->BC_Write_Reg(cs, hscx, HSCX_XBCH, 0x0); cs->BC_Write_Reg(cs, hscx, HSCX_RLCR, 0x0); cs->BC_Write_Reg(cs, hscx, HSCX_CCR1, - test_bit(HW_IPAC, &cs->HW_Flags) ? 0x82 : 0x85); + test_bit(HW_IPAC, &cs->HW_Flags) ? 0x82 : 0x85); cs->BC_Write_Reg(cs, hscx, HSCX_CCR2, 0x30); cs->BC_Write_Reg(cs, hscx, HSCX_XCCR, 7); cs->BC_Write_Reg(cs, hscx, HSCX_RCCR, 7); @@ -65,27 +65,27 @@ modehscx(struct BCState *bcs, int mode, int bc) if (bc == 0) { cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, - test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : bcs->hw.hscx.tsaxr0); + test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : bcs->hw.hscx.tsaxr0); cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, - test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : bcs->hw.hscx.tsaxr0); + test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : bcs->hw.hscx.tsaxr0); } else { cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, bcs->hw.hscx.tsaxr1); cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, bcs->hw.hscx.tsaxr1); } switch (mode) { - case (L1_MODE_NULL): - cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, 0x1f); - cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, 0x1f); - cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x84); - break; - case (L1_MODE_TRANS): - cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0xe4); - break; - case (L1_MODE_HDLC): - cs->BC_Write_Reg(cs, hscx, HSCX_CCR1, - test_bit(HW_IPAC, &cs->HW_Flags) ? 0x8a : 0x8d); - cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x8c); - break; + case (L1_MODE_NULL): + cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, 0x1f); + cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, 0x1f); + cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x84); + break; + case (L1_MODE_TRANS): + cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0xe4); + break; + case (L1_MODE_HDLC): + cs->BC_Write_Reg(cs, hscx, HSCX_CCR1, + test_bit(HW_IPAC, &cs->HW_Flags) ? 0x8a : 0x8d); + cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x8c); + break; } if (mode) cs->BC_Write_Reg(cs, hscx, HSCX_CMDR, 0x41); @@ -100,55 +100,55 @@ hscx_l2l1(struct PStack *st, int pr, void *arg) struct sk_buff *skb = arg; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->hw.hscx.count = 0; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n"); - } else { - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->tx_skb = skb; - bcs->hw.hscx.count = 0; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - modehscx(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - modehscx(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->hw.hscx.count = 0; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n"); + } else { + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_skb = skb; + bcs->hw.hscx.count = 0; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + modehscx(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + modehscx(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -177,13 +177,13 @@ open_hscxstate(struct IsdnCardState *cs, struct BCState *bcs) if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { if (!(bcs->hw.hscx.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) { printk(KERN_WARNING - "HiSax: No memory for hscx.rcvbuf\n"); + "HiSax: No memory for hscx.rcvbuf\n"); test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); return (1); } if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) { printk(KERN_WARNING - "HiSax: No memory for bcs->blog\n"); + "HiSax: No memory for bcs->blog\n"); test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); kfree(bcs->hw.hscx.rcvbuf); bcs->hw.hscx.rcvbuf = NULL; diff --git a/drivers/isdn/hisax/hscx.h b/drivers/isdn/hisax/hscx.h index 268bfd3549b0..1148b4bbe711 100644 --- a/drivers/isdn/hisax/hscx.h +++ b/drivers/isdn/hisax/hscx.h @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c index 2387d76c721a..f398d4838937 100644 --- a/drivers/isdn/hisax/hscx_irq.c +++ b/drivers/isdn/hisax/hscx_irq.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -84,7 +84,7 @@ hscx_fill_fifo(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; int more, count; - int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32; + int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags) ? 64 : 32; u_char *ptr; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) @@ -125,7 +125,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) u_char r; struct BCState *bcs = cs->bcs + hscx; struct sk_buff *skb; - int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32; + int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags) ? 64 : 32; int count; if (!test_bit(BC_FLG_INIT, &bcs->Flag)) @@ -159,7 +159,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) WriteHSCXCMDR(cs, hscx, 0x80); } else { count = READHSCX(cs, hscx, HSCX_RBCL) & ( - test_bit(HW_IPAC, &cs->HW_Flags)? 0x3f: 0x1f); + test_bit(HW_IPAC, &cs->HW_Flags) ? 0x3f : 0x1f); if (count == 0) count = fifo_size; hscx_empty_fifo(bcs, count); @@ -197,8 +197,8 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) hscx_fill_fifo(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; @@ -206,7 +206,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) schedule_event(bcs, B_ACKPENDING); } dev_kfree_skb_irq(bcs->tx_skb); - bcs->hw.hscx.count = 0; + bcs->hw.hscx.count = 0; bcs->tx_skb = NULL; } } @@ -239,7 +239,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val) bcs->err_tx++; #endif /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. + * restart transmitting the whole frame. */ if (bcs->tx_skb) { skb_push(bcs->tx_skb, bcs->hw.hscx.count); @@ -266,7 +266,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val) hscx_fill_fifo(bcs); else { /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. + * restart transmitting the whole frame. */ #ifdef ERROR_STATISTIC bcs->err_tx++; diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c index 63057268cc3d..7be762b17c70 100644 --- a/drivers/isdn/hisax/icc.c +++ b/drivers/isdn/hisax/icc.c @@ -4,7 +4,7 @@ * * Author Matt Henderson & Guy Ellis * Copyright by Traverse Technologies Pty Ltd, www.travers.com.au - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -50,30 +50,30 @@ static void icc_new_ph(struct IsdnCardState *cs) { switch (cs->dc.icc.ph_state) { - case (ICC_IND_EI1): - ph_command(cs, ICC_CMD_DI); - l1_msg(cs, HW_RESET | INDICATION, NULL); - break; - case (ICC_IND_DC): - l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); - break; - case (ICC_IND_DR): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (ICC_IND_PU): - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - break; - case (ICC_IND_FJ): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (ICC_IND_AR): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - case (ICC_IND_AI): - l1_msg(cs, HW_INFO4 | INDICATION, NULL); - break; - default: - break; + case (ICC_IND_EI1): + ph_command(cs, ICC_CMD_DI); + l1_msg(cs, HW_RESET | INDICATION, NULL); + break; + case (ICC_IND_DC): + l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); + break; + case (ICC_IND_DR): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (ICC_IND_PU): + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + break; + case (ICC_IND_FJ): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (ICC_IND_AR): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + case (ICC_IND_AI): + l1_msg(cs, HW_INFO4 | INDICATION, NULL); + break; + default: + break; } } @@ -83,7 +83,7 @@ icc_bh(struct work_struct *work) struct IsdnCardState *cs = container_of(work, struct IsdnCardState, tqueue); struct PStack *stptr; - + if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { if (cs->debug) debugl1(cs, "D-Channel Busy cleared"); @@ -94,7 +94,7 @@ icc_bh(struct work_struct *work) } } if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) - icc_new_ph(cs); + icc_new_ph(cs); if (test_and_clear_bit(D_RCVBUFREADY, &cs->event)) DChannel_proc_rcv(cs); if (test_and_clear_bit(D_XMTBUFREADY, &cs->event)) @@ -254,11 +254,11 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) } else schedule_event(cs, D_XMTBUFREADY); } - afterXPR: +afterXPR: if (val & 0x04) { /* CISQ */ exval = cs->readisac(cs, ICC_CIR0); if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "ICC CIR0 %02X", exval ); + debugl1(cs, "ICC CIR0 %02X", exval); if (exval & 2) { cs->dc.icc.ph_state = (exval >> 2) & 0xf; if (cs->debug & L1_DEB_ISAC) @@ -268,7 +268,7 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) if (exval & 1) { exval = cs->readisac(cs, ICC_CIR1); if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "ICC CIR1 %02X", exval ); + debugl1(cs, "ICC CIR1 %02X", exval); } } if (val & 0x02) { /* SIN */ @@ -331,13 +331,13 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) } cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp++] = cs->readisac(cs, ICC_MOR0); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ICC MOR0 %02x", cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp -1]); + debugl1(cs, "ICC MOR0 %02x", cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp - 1]); if (cs->dc.icc.mon_rxp == 1) { cs->dc.icc.mocr |= 0x04; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); } } - afterMONR0: + afterMONR0: if (v1 & 0x80) { if (!cs->dc.icc.mon_rx) { if (!(cs->dc.icc.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { @@ -361,11 +361,11 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) } cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp++] = cs->readisac(cs, ICC_MOR1); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ICC MOR1 %02x", cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp -1]); + debugl1(cs, "ICC MOR1 %02x", cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp - 1]); cs->dc.icc.mocr |= 0x40; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); } - afterMONR1: + afterMONR1: if (v1 & 0x04) { cs->dc.icc.mocr &= 0xf0; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); @@ -381,15 +381,15 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) schedule_event(cs, D_RX_MON1); } if (v1 & 0x02) { - if ((!cs->dc.icc.mon_tx) || (cs->dc.icc.mon_txc && - (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc) && - !(v1 & 0x08))) { + if ((!cs->dc.icc.mon_tx) || (cs->dc.icc.mon_txc && + (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc) && + !(v1 & 0x08))) { cs->dc.icc.mocr &= 0xf0; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); cs->dc.icc.mocr |= 0x0a; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); if (cs->dc.icc.mon_txc && - (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc)) + (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc)) schedule_event(cs, D_TX_MON0); goto AfterMOX0; } @@ -398,21 +398,21 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) goto AfterMOX0; } cs->writeisac(cs, ICC_MOX0, - cs->dc.icc.mon_tx[cs->dc.icc.mon_txp++]); + cs->dc.icc.mon_tx[cs->dc.icc.mon_txp++]); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ICC %02x -> MOX0", cs->dc.icc.mon_tx[cs->dc.icc.mon_txp -1]); + debugl1(cs, "ICC %02x -> MOX0", cs->dc.icc.mon_tx[cs->dc.icc.mon_txp - 1]); } - AfterMOX0: + AfterMOX0: if (v1 & 0x20) { - if ((!cs->dc.icc.mon_tx) || (cs->dc.icc.mon_txc && - (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc) && - !(v1 & 0x80))) { + if ((!cs->dc.icc.mon_tx) || (cs->dc.icc.mon_txc && + (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc) && + !(v1 & 0x80))) { cs->dc.icc.mocr &= 0x0f; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); cs->dc.icc.mocr |= 0xa0; cs->writeisac(cs, ICC_MOCR, cs->dc.icc.mocr); if (cs->dc.icc.mon_txc && - (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc)) + (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc)) schedule_event(cs, D_TX_MON1); goto AfterMOX1; } @@ -421,11 +421,11 @@ icc_interrupt(struct IsdnCardState *cs, u_char val) goto AfterMOX1; } cs->writeisac(cs, ICC_MOX1, - cs->dc.icc.mon_tx[cs->dc.icc.mon_txp++]); + cs->dc.icc.mon_tx[cs->dc.icc.mon_txp++]); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ICC %02x -> MOX1", cs->dc.icc.mon_tx[cs->dc.icc.mon_txp -1]); + debugl1(cs, "ICC %02x -> MOX1", cs->dc.icc.mon_tx[cs->dc.icc.mon_txp - 1]); } - AfterMOX1: + AfterMOX1: #endif } } @@ -440,128 +440,128 @@ ICC_l1hw(struct PStack *st, int pr, void *arg) int val; switch (pr) { - case (PH_DATA |REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); -#ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - icc_fill_fifo(cs); - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL |INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - spin_unlock_irqrestore(&cs->lock, flags); - break; - } - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + Logl2Frame(cs, skb, "PH_DATA", 0); #endif icc_fill_fifo(cs); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - if ((cs->dc.icc.ph_state == ICC_IND_EI1) || - (cs->dc.icc.ph_state == ICC_IND_DR)) - ph_command(cs, ICC_CMD_DI); - else - ph_command(cs, ICC_CMD_RES); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_ENABLE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); + icc_fill_fifo(cs); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG /* psa */ + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "-> PH_REQUEST_PULL"); +#endif + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + if ((cs->dc.icc.ph_state == ICC_IND_EI1) || + (cs->dc.icc.ph_state == ICC_IND_DR)) ph_command(cs, ICC_CMD_DI); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO1 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - ph_command(cs, ICC_CMD_AR); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO3 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - ph_command(cs, ICC_CMD_AI); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_TESTLOOP | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - val = 0; - if (1 & (long) arg) - val |= 0x0c; - if (2 & (long) arg) - val |= 0x3; - if (test_bit(HW_IOM1, &cs->HW_Flags)) { - /* IOM 1 Mode */ - if (!val) { - cs->writeisac(cs, ICC_SPCR, 0xa); - cs->writeisac(cs, ICC_ADF1, 0x2); - } else { - cs->writeisac(cs, ICC_SPCR, val); - cs->writeisac(cs, ICC_ADF1, 0xa); - } + else + ph_command(cs, ICC_CMD_RES); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_ENABLE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, ICC_CMD_DI); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO1 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, ICC_CMD_AR); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO3 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, ICC_CMD_AI); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_TESTLOOP | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + val = 0; + if (1 & (long) arg) + val |= 0x0c; + if (2 & (long) arg) + val |= 0x3; + if (test_bit(HW_IOM1, &cs->HW_Flags)) { + /* IOM 1 Mode */ + if (!val) { + cs->writeisac(cs, ICC_SPCR, 0xa); + cs->writeisac(cs, ICC_ADF1, 0x2); } else { - /* IOM 2 Mode */ cs->writeisac(cs, ICC_SPCR, val); - if (val) - cs->writeisac(cs, ICC_ADF1, 0x8); - else - cs->writeisac(cs, ICC_ADF1, 0x0); - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_DEACTIVATE | RESPONSE): - skb_queue_purge(&cs->rq); - skb_queue_purge(&cs->sq); - if (cs->tx_skb) { - dev_kfree_skb_any(cs->tx_skb); - cs->tx_skb = NULL; + cs->writeisac(cs, ICC_ADF1, 0xa); } - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); - break; - default: - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "icc_l1hw unknown %04x", pr); - break; + } else { + /* IOM 2 Mode */ + cs->writeisac(cs, ICC_SPCR, val); + if (val) + cs->writeisac(cs, ICC_ADF1, 0x8); + else + cs->writeisac(cs, ICC_ADF1, 0x0); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_DEACTIVATE | RESPONSE): + skb_queue_purge(&cs->rq); + skb_queue_purge(&cs->sq); + if (cs->tx_skb) { + dev_kfree_skb_any(cs->tx_skb); + cs->tx_skb = NULL; + } + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "icc_l1hw unknown %04x", pr); + break; } } @@ -588,7 +588,7 @@ dbusy_timer_handler(struct IsdnCardState *cs) if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { rbch = cs->readisac(cs, ICC_RBCH); star = cs->readisac(cs, ICC_STAR); - if (cs->debug) + if (cs->debug) debugl1(cs, "D-Channel Busy RBCH %02x STAR %02x", rbch, star); if (rbch & ICC_RBCH_XAC) { /* D-Channel Busy */ @@ -622,8 +622,8 @@ initicc(struct IsdnCardState *cs) cs->DC_Close = DC_Close_icc; cs->dc.icc.mon_tx = NULL; cs->dc.icc.mon_rx = NULL; - cs->writeisac(cs, ICC_MASK, 0xff); - cs->dc.icc.mocr = 0xaa; + cs->writeisac(cs, ICC_MASK, 0xff); + cs->dc.icc.mocr = 0xaa; if (test_bit(HW_IOM1, &cs->HW_Flags)) { /* IOM 1 Mode */ cs->writeisac(cs, ICC_ADF2, 0x0); diff --git a/drivers/isdn/hisax/icc.h b/drivers/isdn/hisax/icc.h index e7f593967e43..f367df5d3669 100644 --- a/drivers/isdn/hisax/icc.h +++ b/drivers/isdn/hisax/icc.h @@ -4,12 +4,12 @@ * * Author Matt Henderson & Guy Ellis * Copyright by Traverse Technologies Pty Ltd, www.travers.com.au - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * - * 1999.7.14 Initial implementation of routines for Siemens ISDN - * Communication Controller PEB 2070 based on the ISAC routines + * 1999.7.14 Initial implementation of routines for Siemens ISDN + * Communication Controller PEB 2070 based on the ISAC routines * written by Karsten Keil. */ diff --git a/drivers/isdn/hisax/ipac.h b/drivers/isdn/hisax/ipac.h index f92a04a92826..4f937f02ee34 100644 --- a/drivers/isdn/hisax/ipac.h +++ b/drivers/isdn/hisax/ipac.h @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c index 690840444184..74feb5c83067 100644 --- a/drivers/isdn/hisax/ipacx.c +++ b/drivers/isdn/hisax/ipacx.c @@ -1,10 +1,10 @@ -/* +/* * * IPACX specific routines * * Author Joerg Petersohn * Derived from hisax_isac.c, isac.c, hscx.c and others - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -24,7 +24,7 @@ #define D_FIFO_SIZE 32 -// ipacx interrupt mask values +// ipacx interrupt mask values #define _MASK_IMASK 0x2E // global mask #define _MASKB_IMASK 0x0B #define _MASKD_IMASK 0x03 // all on @@ -55,33 +55,33 @@ static void clear_pending_ints(struct IsdnCardState *cs); //---------------------------------------------------------- // Issue Layer 1 command to chip //---------------------------------------------------------- -static void +static void ph_command(struct IsdnCardState *cs, unsigned int command) { - if (cs->debug &L1_DEB_ISAC) + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "ph_command (%#x) in (%#x)", command, cs->dc.isac.ph_state); -//################################### +//################################### // printk(KERN_INFO "ph_command (%#x)\n", command); -//################################### +//################################### cs->writeisac(cs, IPACX_CIX0, (command << 4) | 0x0E); } //---------------------------------------------------------- // Transceiver interrupt handler //---------------------------------------------------------- -static inline void +static inline void cic_int(struct IsdnCardState *cs) { u_char event; event = cs->readisac(cs, IPACX_CIR0) >> 4; - if (cs->debug &L1_DEB_ISAC) debugl1(cs, "cic_int(event=%#x)", event); -//######################################### + if (cs->debug & L1_DEB_ISAC) debugl1(cs, "cic_int(event=%#x)", event); +//######################################### // printk(KERN_INFO "cic_int(%x)\n", event); -//######################################### - cs->dc.isac.ph_state = event; - schedule_event(cs, D_L1STATECHANGE); +//######################################### + cs->dc.isac.ph_state = event; + schedule_event(cs, D_L1STATECHANGE); } //========================================================== @@ -99,99 +99,99 @@ dch_l2l1(struct PStack *st, int pr, void *arg) u_char cda1_cr; switch (pr) { - case (PH_DATA |REQUEST): - if (cs->debug &DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len); - if (cs->debug &DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); -#ifdef L2FRAME_DEBUG - if (cs->debug &L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG - if (cs->debug &L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - dch_fill_fifo(cs); - } - break; - - case (PH_PULL |INDICATION): - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - break; - } - if (cs->debug & DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG - if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA", 0); #endif dch_fill_fifo(cs); + } + break; + + case (PH_PULL | INDICATION): + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); break; - - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG - if (cs->debug & L1_DEB_LAPD) debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - - case (HW_RESET | REQUEST): - case (HW_ENABLE | REQUEST): - if ((cs->dc.isac.ph_state == IPACX_IND_RES) || - (cs->dc.isac.ph_state == IPACX_IND_DR) || - (cs->dc.isac.ph_state == IPACX_IND_DC)) - ph_command(cs, IPACX_CMD_TIM); - else - ph_command(cs, IPACX_CMD_RES); - break; - - case (HW_INFO3 | REQUEST): - ph_command(cs, IPACX_CMD_AR8); - break; - - case (HW_TESTLOOP | REQUEST): - cs->writeisac(cs, IPACX_CDA_TSDP10, 0x80); // Timeslot 0 is B1 - cs->writeisac(cs, IPACX_CDA_TSDP11, 0x81); // Timeslot 0 is B1 - cda1_cr = cs->readisac(cs, IPACX_CDA1_CR); - (void) cs->readisac(cs, IPACX_CDA2_CR); - if ((long)arg &1) { // loop B1 - cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr |0x0a); - } - else { // B1 off - cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr &~0x0a); - } - if ((long)arg &2) { // loop B2 - cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr |0x14); - } - else { // B2 off - cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr &~0x14); - } - break; + dch_fill_fifo(cs); + break; - case (HW_DEACTIVATE | RESPONSE): - skb_queue_purge(&cs->rq); - skb_queue_purge(&cs->sq); - if (cs->tx_skb) { - dev_kfree_skb_any(cs->tx_skb); - cs->tx_skb = NULL; - } - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG + if (cs->debug & L1_DEB_LAPD) debugl1(cs, "-> PH_REQUEST_PULL"); +#endif + if (!cs->tx_skb) { + clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + + case (HW_RESET | REQUEST): + case (HW_ENABLE | REQUEST): + if ((cs->dc.isac.ph_state == IPACX_IND_RES) || + (cs->dc.isac.ph_state == IPACX_IND_DR) || + (cs->dc.isac.ph_state == IPACX_IND_DC)) + ph_command(cs, IPACX_CMD_TIM); + else + ph_command(cs, IPACX_CMD_RES); + break; + + case (HW_INFO3 | REQUEST): + ph_command(cs, IPACX_CMD_AR8); + break; + + case (HW_TESTLOOP | REQUEST): + cs->writeisac(cs, IPACX_CDA_TSDP10, 0x80); // Timeslot 0 is B1 + cs->writeisac(cs, IPACX_CDA_TSDP11, 0x81); // Timeslot 0 is B1 + cda1_cr = cs->readisac(cs, IPACX_CDA1_CR); + (void) cs->readisac(cs, IPACX_CDA2_CR); + if ((long)arg & 1) { // loop B1 + cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr | 0x0a); + } + else { // B1 off + cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr & ~0x0a); + } + if ((long)arg & 2) { // loop B2 + cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr | 0x14); + } + else { // B2 off + cs->writeisac(cs, IPACX_CDA1_CR, cda1_cr & ~0x14); + } + break; + + case (HW_DEACTIVATE | RESPONSE): + skb_queue_purge(&cs->rq); + skb_queue_purge(&cs->sq); + if (cs->tx_skb) { + dev_kfree_skb_any(cs->tx_skb); + cs->tx_skb = NULL; + } + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + break; - default: - if (cs->debug &L1_DEB_WARN) debugl1(cs, "dch_l2l1 unknown %04x", pr); - break; + default: + if (cs->debug & L1_DEB_WARN) debugl1(cs, "dch_l2l1 unknown %04x", pr); + break; } } @@ -206,11 +206,11 @@ dbusy_timer_handler(struct IsdnCardState *cs) if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { rbchd = cs->readisac(cs, IPACX_RBCHD); stard = cs->readisac(cs, IPACX_STARD); - if (cs->debug) - debugl1(cs, "D-Channel Busy RBCHD %02x STARD %02x", rbchd, stard); - if (!(stard &0x40)) { // D-Channel Busy + if (cs->debug) + debugl1(cs, "D-Channel Busy RBCHD %02x STARD %02x", rbchd, stard); + if (!(stard & 0x40)) { // D-Channel Busy set_bit(FLG_L1_DBUSY, &cs->HW_Flags); - for (st = cs->stlist; st; st = st->next) { + for (st = cs->stlist; st; st = st->next) { st->l1.l1l2(st, PH_PAUSE | INDICATION, NULL); // flow control on } } else { @@ -232,30 +232,30 @@ dbusy_timer_handler(struct IsdnCardState *cs) //---------------------------------------------------------- // Fill buffer from receive FIFO //---------------------------------------------------------- -static void +static void dch_empty_fifo(struct IsdnCardState *cs, int count) { u_char *ptr; - if ((cs->debug &L1_DEB_ISAC) && !(cs->debug &L1_DEB_ISAC_FIFO)) + if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO)) debugl1(cs, "dch_empty_fifo()"); - // message too large, remove + // message too large, remove if ((cs->rcvidx + count) >= MAX_DFRAME_LEN_L1) { - if (cs->debug &L1_DEB_WARN) + if (cs->debug & L1_DEB_WARN) debugl1(cs, "dch_empty_fifo() incoming message too large"); - cs->writeisac(cs, IPACX_CMDRD, 0x80); // RMC + cs->writeisac(cs, IPACX_CMDRD, 0x80); // RMC cs->rcvidx = 0; return; } - + ptr = cs->rcvbuf + cs->rcvidx; cs->rcvidx += count; - + cs->readisacfifo(cs, ptr, count); cs->writeisac(cs, IPACX_CMDRD, 0x80); // RMC - - if (cs->debug &L1_DEB_ISAC_FIFO) { + + if (cs->debug & L1_DEB_ISAC_FIFO) { char *t = cs->dlog; t += sprintf(t, "dch_empty_fifo() cnt %d", count); @@ -267,15 +267,15 @@ dch_empty_fifo(struct IsdnCardState *cs, int count) //---------------------------------------------------------- // Fill transmit FIFO //---------------------------------------------------------- -static void +static void dch_fill_fifo(struct IsdnCardState *cs) { int count; u_char cmd, *ptr; - if ((cs->debug &L1_DEB_ISAC) && !(cs->debug &L1_DEB_ISAC_FIFO)) + if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO)) debugl1(cs, "dch_fill_fifo()"); - + if (!cs->tx_skb) return; count = cs->tx_skb->len; if (count <= 0) return; @@ -286,14 +286,14 @@ dch_fill_fifo(struct IsdnCardState *cs) } else { cmd = 0x0A; // XTF | XME } - + ptr = cs->tx_skb->data; skb_pull(cs->tx_skb, count); cs->tx_cnt += count; cs->writeisacfifo(cs, ptr, count); cs->writeisac(cs, IPACX_CMDRD, cmd); - - // set timeout for transmission contol + + // set timeout for transmission contol if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { debugl1(cs, "dch_fill_fifo dbusytimer running"); del_timer(&cs->dbusytimer); @@ -301,8 +301,8 @@ dch_fill_fifo(struct IsdnCardState *cs) init_timer(&cs->dbusytimer); cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ)/1000); add_timer(&cs->dbusytimer); - - if (cs->debug &L1_DEB_ISAC_FIFO) { + + if (cs->debug & L1_DEB_ISAC_FIFO) { char *t = cs->dlog; t += sprintf(t, "dch_fill_fifo() cnt %d", count); @@ -314,7 +314,7 @@ dch_fill_fifo(struct IsdnCardState *cs) //---------------------------------------------------------- // D channel interrupt handler //---------------------------------------------------------- -static inline void +static inline void dch_int(struct IsdnCardState *cs) { struct sk_buff *skb; @@ -322,31 +322,31 @@ dch_int(struct IsdnCardState *cs) int count; istad = cs->readisac(cs, IPACX_ISTAD); -//############################################## +//############################################## // printk(KERN_WARNING "dch_int(istad=%02x)\n", istad); -//############################################## - - if (istad &0x80) { // RME - rstad = cs->readisac(cs, IPACX_RSTAD); - if ((rstad &0xf0) != 0xa0) { // !(VFR && !RDO && CRC && !RAB) - if (!(rstad &0x80)) - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "dch_int(): invalid frame"); - if ((rstad &0x40)) - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "dch_int(): RDO"); - if (!(rstad &0x20)) - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "dch_int(): CRC error"); - cs->writeisac(cs, IPACX_CMDRD, 0x80); // RMC +//############################################## + + if (istad & 0x80) { // RME + rstad = cs->readisac(cs, IPACX_RSTAD); + if ((rstad & 0xf0) != 0xa0) { // !(VFR && !RDO && CRC && !RAB) + if (!(rstad & 0x80)) + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "dch_int(): invalid frame"); + if ((rstad & 0x40)) + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "dch_int(): RDO"); + if (!(rstad & 0x20)) + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "dch_int(): CRC error"); + cs->writeisac(cs, IPACX_CMDRD, 0x80); // RMC } else { // received frame ok count = cs->readisac(cs, IPACX_RBCLD); - if (count) count--; // RSTAB is last byte - count &= D_FIFO_SIZE-1; + if (count) count--; // RSTAB is last byte + count &= D_FIFO_SIZE - 1; if (count == 0) count = D_FIFO_SIZE; dch_empty_fifo(cs, count); if ((count = cs->rcvidx) > 0) { - cs->rcvidx = 0; + cs->rcvidx = 0; if (!(skb = dev_alloc_skb(count))) printk(KERN_WARNING "HiSax dch_int(): receive out of memory\n"); else { @@ -354,57 +354,57 @@ dch_int(struct IsdnCardState *cs) skb_queue_tail(&cs->rq, skb); } } - } - cs->rcvidx = 0; + } + cs->rcvidx = 0; schedule_event(cs, D_RCVBUFREADY); } - if (istad &0x40) { // RPF + if (istad & 0x40) { // RPF dch_empty_fifo(cs, D_FIFO_SIZE); } - if (istad &0x20) { // RFO - if (cs->debug &L1_DEB_WARN) debugl1(cs, "dch_int(): RFO"); - cs->writeisac(cs, IPACX_CMDRD, 0x40); //RRES + if (istad & 0x20) { // RFO + if (cs->debug & L1_DEB_WARN) debugl1(cs, "dch_int(): RFO"); + cs->writeisac(cs, IPACX_CMDRD, 0x40); //RRES } - - if (istad &0x10) { // XPR + + if (istad & 0x10) { // XPR if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) del_timer(&cs->dbusytimer); if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) schedule_event(cs, D_CLEARBUSY); - if (cs->tx_skb) { - if (cs->tx_skb->len) { - dch_fill_fifo(cs); - goto afterXPR; - } - else { - dev_kfree_skb_irq(cs->tx_skb); - cs->tx_skb = NULL; - cs->tx_cnt = 0; - } - } - if ((cs->tx_skb = skb_dequeue(&cs->sq))) { - cs->tx_cnt = 0; - dch_fill_fifo(cs); - } - else { - schedule_event(cs, D_XMTBUFREADY); - } - } - afterXPR: - - if (istad &0x0C) { // XDU or XMR - if (cs->debug &L1_DEB_WARN) debugl1(cs, "dch_int(): XDU"); - if (cs->tx_skb) { - skb_push(cs->tx_skb, cs->tx_cnt); // retransmit - cs->tx_cnt = 0; + if (cs->tx_skb) { + if (cs->tx_skb->len) { + dch_fill_fifo(cs); + goto afterXPR; + } + else { + dev_kfree_skb_irq(cs->tx_skb); + cs->tx_skb = NULL; + cs->tx_cnt = 0; + } + } + if ((cs->tx_skb = skb_dequeue(&cs->sq))) { + cs->tx_cnt = 0; + dch_fill_fifo(cs); + } + else { + schedule_event(cs, D_XMTBUFREADY); + } + } +afterXPR: + + if (istad & 0x0C) { // XDU or XMR + if (cs->debug & L1_DEB_WARN) debugl1(cs, "dch_int(): XDU"); + if (cs->tx_skb) { + skb_push(cs->tx_skb, cs->tx_cnt); // retransmit + cs->tx_cnt = 0; dch_fill_fifo(cs); } else { printk(KERN_WARNING "HiSax: ISAC XDU no skb\n"); debugl1(cs, "ISAC XDU no skb"); } - } + } } //---------------------------------------------------------- @@ -423,15 +423,15 @@ dch_init(struct IsdnCardState *cs) printk(KERN_INFO "HiSax: IPACX ISDN driver v0.1.0\n"); cs->setstack_d = dch_setstack; - + cs->dbusytimer.function = (void *) dbusy_timer_handler; cs->dbusytimer.data = (long) cs; init_timer(&cs->dbusytimer); - cs->writeisac(cs, IPACX_TR_CONF0, 0x00); // clear LDD - cs->writeisac(cs, IPACX_TR_CONF2, 0x00); // enable transmitter - cs->writeisac(cs, IPACX_MODED, 0xC9); // transparent mode 0, RAC, stop/go - cs->writeisac(cs, IPACX_MON_CR, 0x00); // disable monitor channel + cs->writeisac(cs, IPACX_TR_CONF0, 0x00); // clear LDD + cs->writeisac(cs, IPACX_TR_CONF2, 0x00); // enable transmitter + cs->writeisac(cs, IPACX_MODED, 0xC9); // transparent mode 0, RAC, stop/go + cs->writeisac(cs, IPACX_MON_CR, 0x00); // disable monitor channel } @@ -450,55 +450,55 @@ bch_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->hw.hscx.count = 0; - bch_fill_fifo(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "HiSax bch_l2l1(): this shouldn't happen\n"); - } else { - set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->tx_skb = skb; - bcs->hw.hscx.count = 0; - bch_fill_fifo(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - set_bit(BC_FLG_ACTIV, &bcs->Flag); - bch_mode(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - clear_bit(BC_FLG_ACTIV, &bcs->Flag); - clear_bit(BC_FLG_BUSY, &bcs->Flag); - bch_mode(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; + set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->hw.hscx.count = 0; + bch_fill_fifo(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "HiSax bch_l2l1(): this shouldn't happen\n"); + } else { + set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_skb = skb; + bcs->hw.hscx.count = 0; + bch_fill_fifo(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + set_bit(BC_FLG_ACTIV, &bcs->Flag); + bch_mode(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + clear_bit(BC_FLG_ACTIV, &bcs->Flag); + clear_bit(BC_FLG_BUSY, &bcs->Flag); + bch_mode(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -513,28 +513,28 @@ bch_empty_fifo(struct BCState *bcs, int count) int cnt; cs = bcs->cs; - hscx = bcs->hw.hscx.hscx; - if ((cs->debug &L1_DEB_HSCX) && !(cs->debug &L1_DEB_HSCX_FIFO)) + hscx = bcs->hw.hscx.hscx; + if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "bch_empty_fifo()"); - // message too large, remove + // message too large, remove if (bcs->hw.hscx.rcvidx + count > HSCX_BUFMAX) { - if (cs->debug &L1_DEB_WARN) + if (cs->debug & L1_DEB_WARN) debugl1(cs, "bch_empty_fifo() incoming packet too large"); - cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC + cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC bcs->hw.hscx.rcvidx = 0; return; } - + ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx; cnt = count; - while (cnt--) *ptr++ = cs->BC_Read_Reg(cs, hscx, IPACX_RFIFOB); + while (cnt--) *ptr++ = cs->BC_Read_Reg(cs, hscx, IPACX_RFIFOB); cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC - + ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx; bcs->hw.hscx.rcvidx += count; - - if (cs->debug &L1_DEB_HSCX_FIFO) { + + if (cs->debug & L1_DEB_HSCX_FIFO) { char *t = bcs->blog; t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count); @@ -554,7 +554,7 @@ bch_fill_fifo(struct BCState *bcs) u_char *ptr, *p, hscx; cs = bcs->cs; - if ((cs->debug &L1_DEB_HSCX) && !(cs->debug &L1_DEB_HSCX_FIFO)) + if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) debugl1(cs, "bch_fill_fifo()"); if (!bcs->tx_skb) return; @@ -567,17 +567,17 @@ bch_fill_fifo(struct BCState *bcs) count = B_FIFO_SIZE; } else { count = bcs->tx_skb->len; - } + } cnt = count; - + p = ptr = bcs->tx_skb->data; skb_pull(bcs->tx_skb, count); bcs->tx_cnt -= count; bcs->hw.hscx.count += count; - while (cnt--) cs->BC_Write_Reg(cs, hscx, IPACX_XFIFOB, *p++); + while (cnt--) cs->BC_Write_Reg(cs, hscx, IPACX_XFIFOB, *p++); cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, (more ? 0x08 : 0x0a)); - - if (cs->debug &L1_DEB_HSCX_FIFO) { + + if (cs->debug & L1_DEB_HSCX_FIFO) { char *t = bcs->blog; t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count); @@ -600,31 +600,31 @@ bch_int(struct IsdnCardState *cs, u_char hscx) bcs = cs->bcs + hscx; istab = cs->BC_Read_Reg(cs, hscx, IPACX_ISTAB); -//############################################## +//############################################## // printk(KERN_WARNING "bch_int(istab=%02x)\n", istab); -//############################################## +//############################################## if (!test_bit(BC_FLG_INIT, &bcs->Flag)) return; - if (istab &0x80) { // RME + if (istab & 0x80) { // RME rstab = cs->BC_Read_Reg(cs, hscx, IPACX_RSTAB); - if ((rstab &0xf0) != 0xa0) { // !(VFR && !RDO && CRC && !RAB) - if (!(rstab &0x80)) - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "bch_int() B-%d: invalid frame", hscx); - if ((rstab &0x40) && (bcs->mode != L1_MODE_NULL)) - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "bch_int() B-%d: RDO mode=%d", hscx, bcs->mode); - if (!(rstab &0x20)) - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "bch_int() B-%d: CRC error", hscx); - cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC - } - else { // received frame ok - count = cs->BC_Read_Reg(cs, hscx, IPACX_RBCLB) &(B_FIFO_SIZE-1); + if ((rstab & 0xf0) != 0xa0) { // !(VFR && !RDO && CRC && !RAB) + if (!(rstab & 0x80)) + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "bch_int() B-%d: invalid frame", hscx); + if ((rstab & 0x40) && (bcs->mode != L1_MODE_NULL)) + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "bch_int() B-%d: RDO mode=%d", hscx, bcs->mode); + if (!(rstab & 0x20)) + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "bch_int() B-%d: CRC error", hscx); + cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x80); // RMC + } + else { // received frame ok + count = cs->BC_Read_Reg(cs, hscx, IPACX_RBCLB) & (B_FIFO_SIZE - 1); if (count == 0) count = B_FIFO_SIZE; bch_empty_fifo(bcs, count); if ((count = bcs->hw.hscx.rcvidx - 1) > 0) { - if (cs->debug &L1_DEB_HSCX_FIFO) + if (cs->debug & L1_DEB_HSCX_FIFO) debugl1(cs, "bch_int Frame %d", count); if (!(skb = dev_alloc_skb(count))) printk(KERN_WARNING "HiSax bch_int(): receive frame out of memory\n"); @@ -637,8 +637,8 @@ bch_int(struct IsdnCardState *cs, u_char hscx) bcs->hw.hscx.rcvidx = 0; schedule_event(bcs, B_RCVBUFREADY); } - - if (istab &0x40) { // RPF + + if (istab & 0x40) { // RPF bch_empty_fifo(bcs, B_FIFO_SIZE); if (bcs->mode == L1_MODE_TRANS) { // queue every chunk @@ -653,21 +653,21 @@ bch_int(struct IsdnCardState *cs, u_char hscx) schedule_event(bcs, B_RCVBUFREADY); } } - - if (istab &0x20) { // RFO - if (cs->debug &L1_DEB_WARN) + + if (istab & 0x20) { // RFO + if (cs->debug & L1_DEB_WARN) debugl1(cs, "bch_int() B-%d: RFO error", hscx); cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x40); // RRES } - if (istab &0x10) { // XPR + if (istab & 0x10) { // XPR if (bcs->tx_skb) { if (bcs->tx_skb->len) { bch_fill_fifo(bcs); goto afterXPR; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; @@ -678,7 +678,7 @@ bch_int(struct IsdnCardState *cs, u_char hscx) dev_kfree_skb_irq(bcs->tx_skb); bcs->hw.hscx.count = 0; bcs->tx_skb = NULL; - } + } if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { bcs->hw.hscx.count = 0; set_bit(BC_FLG_BUSY, &bcs->Flag); @@ -688,22 +688,22 @@ bch_int(struct IsdnCardState *cs, u_char hscx) schedule_event(bcs, B_XMTBUFREADY); } } - afterXPR: +afterXPR: - if (istab &0x04) { // XDU - if (bcs->mode == L1_MODE_TRANS) { + if (istab & 0x04) { // XDU + if (bcs->mode == L1_MODE_TRANS) { bch_fill_fifo(bcs); - } - else { - if (bcs->tx_skb) { // restart transmitting the whole frame - skb_push(bcs->tx_skb, bcs->hw.hscx.count); - bcs->tx_cnt += bcs->hw.hscx.count; - bcs->hw.hscx.count = 0; - } - cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x01); // XRES - if (cs->debug &L1_DEB_WARN) - debugl1(cs, "bch_int() B-%d XDU error", hscx); - } + } + else { + if (bcs->tx_skb) { // restart transmitting the whole frame + skb_push(bcs->tx_skb, bcs->hw.hscx.count); + bcs->tx_cnt += bcs->hw.hscx.count; + bcs->hw.hscx.count = 0; + } + cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x01); // XRES + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "bch_int() B-%d XDU error", hscx); + } } } @@ -715,43 +715,43 @@ bch_mode(struct BCState *bcs, int mode, int bc) struct IsdnCardState *cs = bcs->cs; int hscx = bcs->hw.hscx.hscx; - bc = bc ? 1 : 0; // in case bc is greater than 1 + bc = bc ? 1 : 0; // in case bc is greater than 1 if (cs->debug & L1_DEB_HSCX) debugl1(cs, "mode_bch() switch B-%d mode %d chan %d", hscx, mode, bc); bcs->mode = mode; bcs->channel = bc; - - // map controller to according timeslot - if (!hscx) - { - cs->writeisac(cs, IPACX_BCHA_TSDP_BC1, 0x80 | bc); - cs->writeisac(cs, IPACX_BCHA_CR, 0x88); - } - else - { - cs->writeisac(cs, IPACX_BCHB_TSDP_BC1, 0x80 | bc); - cs->writeisac(cs, IPACX_BCHB_CR, 0x88); - } + + // map controller to according timeslot + if (!hscx) + { + cs->writeisac(cs, IPACX_BCHA_TSDP_BC1, 0x80 | bc); + cs->writeisac(cs, IPACX_BCHA_CR, 0x88); + } + else + { + cs->writeisac(cs, IPACX_BCHB_TSDP_BC1, 0x80 | bc); + cs->writeisac(cs, IPACX_BCHB_CR, 0x88); + } switch (mode) { - case (L1_MODE_NULL): - cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0xC0); // rec off - cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x30); // std adj. - cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, 0xFF); // ints off - cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments - break; - case (L1_MODE_TRANS): - cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0x88); // ext transp mode - cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x00); // xxx00000 - cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments - cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, _MASKB_IMASK); - break; - case (L1_MODE_HDLC): - cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0xC8); // transp mode 0 - cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x01); // idle=hdlc flags crc enabled - cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments - cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, _MASKB_IMASK); - break; + case (L1_MODE_NULL): + cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0xC0); // rec off + cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x30); // std adj. + cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, 0xFF); // ints off + cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments + break; + case (L1_MODE_TRANS): + cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0x88); // ext transp mode + cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x00); // xxx00000 + cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments + cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, _MASKB_IMASK); + break; + case (L1_MODE_HDLC): + cs->BC_Write_Reg(cs, hscx, IPACX_MODEB, 0xC8); // transp mode 0 + cs->BC_Write_Reg(cs, hscx, IPACX_EXMB, 0x01); // idle=hdlc flags crc enabled + cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x41); // validate adjustments + cs->BC_Write_Reg(cs, hscx, IPACX_MASKB, _MASKB_IMASK); + break; } } @@ -784,13 +784,13 @@ bch_open_state(struct IsdnCardState *cs, struct BCState *bcs) if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { if (!(bcs->hw.hscx.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) { printk(KERN_WARNING - "HiSax open_bchstate(): No memory for hscx.rcvbuf\n"); + "HiSax open_bchstate(): No memory for hscx.rcvbuf\n"); clear_bit(BC_FLG_INIT, &bcs->Flag); return (1); } if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) { printk(KERN_WARNING - "HiSax open_bchstate: No memory for bcs->blog\n"); + "HiSax open_bchstate: No memory for bcs->blog\n"); clear_bit(BC_FLG_INIT, &bcs->Flag); kfree(bcs->hw.hscx.rcvbuf); bcs->hw.hscx.rcvbuf = NULL; @@ -842,21 +842,21 @@ bch_init(struct IsdnCardState *cs, int hscx) //---------------------------------------------------------- // Main interrupt handler //---------------------------------------------------------- -void +void interrupt_ipacx(struct IsdnCardState *cs) { u_char ista; - + while ((ista = cs->readisac(cs, IPACX_ISTA))) { -//################################################# +//################################################# // printk(KERN_WARNING "interrupt_ipacx(ista=%02x)\n", ista); -//################################################# - if (ista &0x80) bch_int(cs, 0); // B channel interrupts - if (ista &0x40) bch_int(cs, 1); - - if (ista &0x01) dch_int(cs); // D channel - if (ista &0x10) cic_int(cs); // Layer 1 state - } +//################################################# + if (ista & 0x80) bch_int(cs, 0); // B channel interrupts + if (ista & 0x40) bch_int(cs, 1); + + if (ista & 0x01) dch_int(cs); // D channel + if (ista & 0x10) cic_int(cs); // Layer 1 state + } } //---------------------------------------------------------- @@ -867,17 +867,17 @@ clear_pending_ints(struct IsdnCardState *cs) { int ista; - // all interrupts off - cs->writeisac(cs, IPACX_MASK, 0xff); + // all interrupts off + cs->writeisac(cs, IPACX_MASK, 0xff); cs->writeisac(cs, IPACX_MASKD, 0xff); cs->BC_Write_Reg(cs, 0, IPACX_MASKB, 0xff); cs->BC_Write_Reg(cs, 1, IPACX_MASKB, 0xff); - - ista = cs->readisac(cs, IPACX_ISTA); - if (ista &0x80) cs->BC_Read_Reg(cs, 0, IPACX_ISTAB); - if (ista &0x40) cs->BC_Read_Reg(cs, 1, IPACX_ISTAB); - if (ista &0x10) cs->readisac(cs, IPACX_CIR0); - if (ista &0x01) cs->readisac(cs, IPACX_ISTAD); + + ista = cs->readisac(cs, IPACX_ISTA); + if (ista & 0x80) cs->BC_Read_Reg(cs, 0, IPACX_ISTAB); + if (ista & 0x40) cs->BC_Read_Reg(cs, 1, IPACX_ISTAB); + if (ista & 0x10) cs->readisac(cs, IPACX_CIR0); + if (ista & 0x01) cs->readisac(cs, IPACX_ISTAD); } //---------------------------------------------------------- @@ -887,23 +887,23 @@ clear_pending_ints(struct IsdnCardState *cs) void init_ipacx(struct IsdnCardState *cs, int part) { - if (part &1) { // initialise chip -//################################################## + if (part & 1) { // initialise chip +//################################################## // printk(KERN_INFO "init_ipacx(%x)\n", part); -//################################################## +//################################################## clear_pending_ints(cs); bch_init(cs, 0); bch_init(cs, 1); dch_init(cs); } - if (part &2) { // reenable all interrupts and start chip + if (part & 2) { // reenable all interrupts and start chip cs->BC_Write_Reg(cs, 0, IPACX_MASKB, _MASKB_IMASK); cs->BC_Write_Reg(cs, 1, IPACX_MASKB, _MASKB_IMASK); cs->writeisac(cs, IPACX_MASKD, _MASKD_IMASK); cs->writeisac(cs, IPACX_MASK, _MASK_IMASK); // global mask register // reset HDLC Transmitters/receivers - cs->writeisac(cs, IPACX_CMDRD, 0x41); + cs->writeisac(cs, IPACX_CMDRD, 0x41); cs->BC_Write_Reg(cs, 0, IPACX_CMDRB, 0x41); cs->BC_Write_Reg(cs, 1, IPACX_CMDRB, 0x41); ph_command(cs, IPACX_CMD_RES); @@ -911,4 +911,3 @@ init_ipacx(struct IsdnCardState *cs, int part) } //----------------- end of file ----------------------- - diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c index 2b66728136d5..bcd70a387307 100644 --- a/drivers/isdn/hisax/isac.c +++ b/drivers/isdn/hisax/isac.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -49,34 +49,34 @@ static void isac_new_ph(struct IsdnCardState *cs) { switch (cs->dc.isac.ph_state) { - case (ISAC_IND_RS): - case (ISAC_IND_EI): - ph_command(cs, ISAC_CMD_DUI); - l1_msg(cs, HW_RESET | INDICATION, NULL); - break; - case (ISAC_IND_DID): - l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); - break; - case (ISAC_IND_DR): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (ISAC_IND_PU): - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - break; - case (ISAC_IND_RSY): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (ISAC_IND_ARD): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - case (ISAC_IND_AI8): - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - case (ISAC_IND_AI10): - l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL); - break; - default: - break; + case (ISAC_IND_RS): + case (ISAC_IND_EI): + ph_command(cs, ISAC_CMD_DUI); + l1_msg(cs, HW_RESET | INDICATION, NULL); + break; + case (ISAC_IND_DID): + l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); + break; + case (ISAC_IND_DR): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (ISAC_IND_PU): + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + break; + case (ISAC_IND_RSY): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (ISAC_IND_ARD): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + case (ISAC_IND_AI8): + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + case (ISAC_IND_AI10): + l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL); + break; + default: + break; } } @@ -86,7 +86,7 @@ isac_bh(struct work_struct *work) struct IsdnCardState *cs = container_of(work, struct IsdnCardState, tqueue); struct PStack *stptr; - + if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) { if (cs->debug) debugl1(cs, "D-Channel Busy cleared"); @@ -97,7 +97,7 @@ isac_bh(struct work_struct *work) } } if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) - isac_new_ph(cs); + isac_new_ph(cs); if (test_and_clear_bit(D_RCVBUFREADY, &cs->event)) DChannel_proc_rcv(cs); if (test_and_clear_bit(D_XMTBUFREADY, &cs->event)) @@ -257,11 +257,11 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) } else schedule_event(cs, D_XMTBUFREADY); } - afterXPR: +afterXPR: if (val & 0x04) { /* CISQ */ exval = cs->readisac(cs, ISAC_CIR0); if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "ISAC CIR0 %02X", exval ); + debugl1(cs, "ISAC CIR0 %02X", exval); if (exval & 2) { cs->dc.isac.ph_state = (exval >> 2) & 0xf; if (cs->debug & L1_DEB_ISAC) @@ -271,7 +271,7 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) if (exval & 1) { exval = cs->readisac(cs, ISAC_CIR1); if (cs->debug & L1_DEB_ISAC) - debugl1(cs, "ISAC CIR1 %02X", exval ); + debugl1(cs, "ISAC CIR1 %02X", exval); } } if (val & 0x02) { /* SIN */ @@ -334,13 +334,13 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) } cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp++] = cs->readisac(cs, ISAC_MOR0); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ISAC MOR0 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp -1]); + debugl1(cs, "ISAC MOR0 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp - 1]); if (cs->dc.isac.mon_rxp == 1) { cs->dc.isac.mocr |= 0x04; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); } } - afterMONR0: + afterMONR0: if (v1 & 0x80) { if (!cs->dc.isac.mon_rx) { if (!(cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) { @@ -364,11 +364,11 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) } cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp++] = cs->readisac(cs, ISAC_MOR1); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ISAC MOR1 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp -1]); + debugl1(cs, "ISAC MOR1 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp - 1]); cs->dc.isac.mocr |= 0x40; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); } - afterMONR1: + afterMONR1: if (v1 & 0x04) { cs->dc.isac.mocr &= 0xf0; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); @@ -384,15 +384,15 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) schedule_event(cs, D_RX_MON1); } if (v1 & 0x02) { - if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc && - (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) && - !(v1 & 0x08))) { + if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc && + (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) && + !(v1 & 0x08))) { cs->dc.isac.mocr &= 0xf0; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); cs->dc.isac.mocr |= 0x0a; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); if (cs->dc.isac.mon_txc && - (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) + (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) schedule_event(cs, D_TX_MON0); goto AfterMOX0; } @@ -401,21 +401,21 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) goto AfterMOX0; } cs->writeisac(cs, ISAC_MOX0, - cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]); + cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ISAC %02x -> MOX0", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp -1]); + debugl1(cs, "ISAC %02x -> MOX0", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp - 1]); } - AfterMOX0: + AfterMOX0: if (v1 & 0x20) { - if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc && - (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) && - !(v1 & 0x80))) { + if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc && + (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) && + !(v1 & 0x80))) { cs->dc.isac.mocr &= 0x0f; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); cs->dc.isac.mocr |= 0xa0; cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr); if (cs->dc.isac.mon_txc && - (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) + (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) schedule_event(cs, D_TX_MON1); goto AfterMOX1; } @@ -424,11 +424,11 @@ isac_interrupt(struct IsdnCardState *cs, u_char val) goto AfterMOX1; } cs->writeisac(cs, ISAC_MOX1, - cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]); + cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]); if (cs->debug & L1_DEB_MONITOR) - debugl1(cs, "ISAC %02x -> MOX1", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp -1]); + debugl1(cs, "ISAC %02x -> MOX1", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp - 1]); } - AfterMOX1:; + AfterMOX1:; #endif } } @@ -443,123 +443,123 @@ ISAC_l1hw(struct PStack *st, int pr, void *arg) int val; switch (pr) { - case (PH_DATA |REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA Queued", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; + } else { + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA", 0); #endif - isac_fill_fifo(cs); - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL |INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - } else { - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - cs->tx_skb = skb; - cs->tx_cnt = 0; + isac_fill_fifo(cs); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); + } else { + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - isac_fill_fifo(cs); - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL | REQUEST): + isac_fill_fifo(cs); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "-> PH_REQUEST_PULL"); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - if ((cs->dc.isac.ph_state == ISAC_IND_EI) || - (cs->dc.isac.ph_state == ISAC_IND_DR) || - (cs->dc.isac.ph_state == ISAC_IND_RS)) - ph_command(cs, ISAC_CMD_TIM); - else - ph_command(cs, ISAC_CMD_RS); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_ENABLE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + if ((cs->dc.isac.ph_state == ISAC_IND_EI) || + (cs->dc.isac.ph_state == ISAC_IND_DR) || + (cs->dc.isac.ph_state == ISAC_IND_RS)) ph_command(cs, ISAC_CMD_TIM); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO3 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - ph_command(cs, ISAC_CMD_AR8); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_TESTLOOP | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - val = 0; - if (1 & (long) arg) - val |= 0x0c; - if (2 & (long) arg) - val |= 0x3; - if (test_bit(HW_IOM1, &cs->HW_Flags)) { - /* IOM 1 Mode */ - if (!val) { - cs->writeisac(cs, ISAC_SPCR, 0xa); - cs->writeisac(cs, ISAC_ADF1, 0x2); - } else { - cs->writeisac(cs, ISAC_SPCR, val); - cs->writeisac(cs, ISAC_ADF1, 0xa); - } + else + ph_command(cs, ISAC_CMD_RS); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_ENABLE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, ISAC_CMD_TIM); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO3 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, ISAC_CMD_AR8); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_TESTLOOP | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + val = 0; + if (1 & (long) arg) + val |= 0x0c; + if (2 & (long) arg) + val |= 0x3; + if (test_bit(HW_IOM1, &cs->HW_Flags)) { + /* IOM 1 Mode */ + if (!val) { + cs->writeisac(cs, ISAC_SPCR, 0xa); + cs->writeisac(cs, ISAC_ADF1, 0x2); } else { - /* IOM 2 Mode */ cs->writeisac(cs, ISAC_SPCR, val); - if (val) - cs->writeisac(cs, ISAC_ADF1, 0x8); - else - cs->writeisac(cs, ISAC_ADF1, 0x0); + cs->writeisac(cs, ISAC_ADF1, 0xa); } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_DEACTIVATE | RESPONSE): - skb_queue_purge(&cs->rq); - skb_queue_purge(&cs->sq); - if (cs->tx_skb) { - dev_kfree_skb_any(cs->tx_skb); - cs->tx_skb = NULL; - } - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); - break; - default: - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isac_l1hw unknown %04x", pr); - break; + } else { + /* IOM 2 Mode */ + cs->writeisac(cs, ISAC_SPCR, val); + if (val) + cs->writeisac(cs, ISAC_ADF1, 0x8); + else + cs->writeisac(cs, ISAC_ADF1, 0x0); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_DEACTIVATE | RESPONSE): + skb_queue_purge(&cs->rq); + skb_queue_purge(&cs->sq); + if (cs->tx_skb) { + dev_kfree_skb_any(cs->tx_skb); + cs->tx_skb = NULL; + } + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "isac_l1hw unknown %04x", pr); + break; } } @@ -587,7 +587,7 @@ dbusy_timer_handler(struct IsdnCardState *cs) if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) { rbch = cs->readisac(cs, ISAC_RBCH); star = cs->readisac(cs, ISAC_STAR); - if (cs->debug) + if (cs->debug) debugl1(cs, "D-Channel Busy RBCH %02x STAR %02x", rbch, star); if (rbch & ISAC_RBCH_XAC) { /* D-Channel Busy */ @@ -620,8 +620,8 @@ void initisac(struct IsdnCardState *cs) cs->DC_Close = DC_Close_isac; cs->dc.isac.mon_tx = NULL; cs->dc.isac.mon_rx = NULL; - cs->writeisac(cs, ISAC_MASK, 0xff); - cs->dc.isac.mocr = 0xaa; + cs->writeisac(cs, ISAC_MASK, 0xff); + cs->dc.isac.mocr = 0xaa; if (test_bit(HW_IOM1, &cs->HW_Flags)) { /* IOM 1 Mode */ cs->writeisac(cs, ISAC_ADF2, 0x0); diff --git a/drivers/isdn/hisax/isac.h b/drivers/isdn/hisax/isac.h index 8f8331e44866..04f16b91b822 100644 --- a/drivers/isdn/hisax/isac.h +++ b/drivers/isdn/hisax/isac.h @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c index d4cce337add2..ff5e139f4850 100644 --- a/drivers/isdn/hisax/isar.c +++ b/drivers/isdn/hisax/isar.c @@ -22,11 +22,11 @@ #define ETX 0x03 #define FAXMODCNT 13 -static const u_char faxmodulation[] = {3,24,48,72,73,74,96,97,98,121,122,145,146}; -static u_int modmask = 0x1fff; -static int frm_extra_delay = 2; -static int para_TOA = 6; -static const u_char *FC1_CMD[] = {"FAE", "FTS", "FRS", "FTM", "FRM", "FTH", "FRH", "CTRL" }; +static const u_char faxmodulation[] = {3, 24, 48, 72, 73, 74, 96, 97, 98, 121, 122, 145, 146}; +static u_int modmask = 0x1fff; +static int frm_extra_delay = 2; +static int para_TOA = 6; +static const u_char *FC1_CMD[] = {"FAE", "FTS", "FRS", "FTM", "FRM", "FTH", "FRH", "CTRL"}; static void isar_setup(struct IsdnCardState *cs); static void isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para); @@ -42,7 +42,7 @@ waitforHIA(struct IsdnCardState *cs, int timeout) } if (!timeout) printk(KERN_WARNING "HiSax: ISAR waitforHIA timeout\n"); - return(timeout); + return (timeout); } @@ -51,9 +51,9 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len, u_char *msg) { int i; - + if (!waitforHIA(cs, 4000)) - return(0); + return (0); #if DUMP_MBOXFRAME if (cs->debug & L1_DEB_HSCX) debugl1(cs, "sendmsg(%02x,%02x,%d)", his, creg, len); @@ -63,17 +63,17 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len, cs->BC_Write_Reg(cs, 0, ISAR_WADR, 0); if (msg && len) { cs->BC_Write_Reg(cs, 1, ISAR_MBOX, msg[0]); - for (i=1; iBC_Write_Reg(cs, 2, ISAR_MBOX, msg[i]); -#if DUMP_MBOXFRAME>1 +#if DUMP_MBOXFRAME > 1 if (cs->debug & L1_DEB_HSCX_FIFO) { char tmp[256], *t; - + i = len; - while (i>0) { + while (i > 0) { t = tmp; t += sprintf(t, "sendmbox cnt %d", len); - QuickHex(t, &msg[len-i], (i>64) ? 64:i); + QuickHex(t, &msg[len-i], (i > 64) ? 64 : i); debugl1(cs, tmp); i -= 64; } @@ -82,7 +82,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len, } cs->BC_Write_Reg(cs, 1, ISAR_HIS, his); waitforHIA(cs, 10000); - return(1); + return (1); } /* Call only with IRQ disabled !!! */ @@ -94,17 +94,17 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg) cs->BC_Write_Reg(cs, 1, ISAR_RADR, 0); if (msg && ireg->clsb) { msg[0] = cs->BC_Read_Reg(cs, 1, ISAR_MBOX); - for (i=1; i < ireg->clsb; i++) - msg[i] = cs->BC_Read_Reg(cs, 2, ISAR_MBOX); -#if DUMP_MBOXFRAME>1 + for (i = 1; i < ireg->clsb; i++) + msg[i] = cs->BC_Read_Reg(cs, 2, ISAR_MBOX); +#if DUMP_MBOXFRAME > 1 if (cs->debug & L1_DEB_HSCX_FIFO) { char tmp[256], *t; - + i = ireg->clsb; - while (i>0) { + while (i > 0) { t = tmp; t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb); - QuickHex(t, &msg[ireg->clsb-i], (i>64) ? 64:i); + QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i); debugl1(cs, tmp); i -= 64; } @@ -130,23 +130,23 @@ get_irq_infos(struct IsdnCardState *cs, struct isar_reg *ireg) static int waitrecmsg(struct IsdnCardState *cs, u_char *len, - u_char *msg, int maxdelay) + u_char *msg, int maxdelay) { int timeout = 0; struct isar_reg *ir = cs->bcs[0].hw.isar.reg; - - - while((!(cs->BC_Read_Reg(cs, 0, ISAR_IRQBIT) & ISAR_IRQSTA)) && - (timeout++ < maxdelay)) + + + while ((!(cs->BC_Read_Reg(cs, 0, ISAR_IRQBIT) & ISAR_IRQSTA)) && + (timeout++ < maxdelay)) udelay(1); if (timeout > maxdelay) { printk(KERN_WARNING"isar recmsg IRQSTA timeout\n"); - return(0); + return (0); } get_irq_infos(cs, ir); rcv_mbox(cs, ir, msg); *len = ir->clsb; - return(1); + return (1); } int @@ -167,11 +167,11 @@ ISARVersion(struct IsdnCardState *cs, char *s) cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO); if (!sendmsg(cs, ISAR_HIS_VNR, 0, 3, msg)) { spin_unlock_irqrestore(&cs->lock, flags); - return(-1); + return (-1); } if (!waitrecmsg(cs, &len, tmp, 100000)) { spin_unlock_irqrestore(&cs->lock, flags); - return(-2); + return (-2); } cs->debug = debug; if (cs->bcs[0].hw.isar.reg->iis == ISAR_IIS_VNR) { @@ -183,7 +183,7 @@ ISARVersion(struct IsdnCardState *cs, char *s) } else ver = -4; spin_unlock_irqrestore(&cs->lock, flags); - return(ver); + return (ver); } static int @@ -196,25 +196,25 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) u_char *msg, *tmpmsg, *mp, tmp[64]; u_long flags; struct isar_reg *ireg = cs->bcs[0].hw.isar.reg; - + struct {u_short sadr; u_short len; u_short d_key; } blk_head; - + #define BLK_HEAD_SIZE 6 if (1 != (ret = ISARVersion(cs, "Testing"))) { printk(KERN_ERR"isar_load_firmware wrong isar version %d\n", ret); - return(1); + return (1); } debug = cs->debug; -#if DBG_LOADFIRM<2 +#if DBG_LOADFIRM < 2 cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO); #endif - + cfu_ret = copy_from_user(&size, p, sizeof(int)); if (cfu_ret) { - printk(KERN_ERR"isar_load_firmware copy_from_user ret %d\n", cfu_ret); + printk(KERN_ERR "isar_load_firmware copy_from_user ret %d\n", cfu_ret); return -EFAULT; } p += sizeof(int); @@ -241,40 +241,40 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) goto reterror; } #ifdef __BIG_ENDIAN - sadr = (blk_head.sadr & 0xff)*256 + blk_head.sadr/256; + sadr = (blk_head.sadr & 0xff) * 256 + blk_head.sadr / 256; blk_head.sadr = sadr; - sadr = (blk_head.len & 0xff)*256 + blk_head.len/256; + sadr = (blk_head.len & 0xff) * 256 + blk_head.len / 256; blk_head.len = sadr; - sadr = (blk_head.d_key & 0xff)*256 + blk_head.d_key/256; + sadr = (blk_head.d_key & 0xff) * 256 + blk_head.d_key / 256; blk_head.d_key = sadr; #endif /* __BIG_ENDIAN */ cnt += BLK_HEAD_SIZE; p += BLK_HEAD_SIZE; printk(KERN_DEBUG"isar firmware block (%#x,%5d,%#x)\n", - blk_head.sadr, blk_head.len, blk_head.d_key & 0xff); + blk_head.sadr, blk_head.len, blk_head.d_key & 0xff); sadr = blk_head.sadr; left = blk_head.len; spin_lock_irqsave(&cs->lock, flags); if (!sendmsg(cs, ISAR_HIS_DKEY, blk_head.d_key & 0xff, 0, NULL)) { printk(KERN_ERR"isar sendmsg dkey failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } if (!waitrecmsg(cs, &len, tmp, 100000)) { printk(KERN_ERR"isar waitrecmsg dkey failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } if ((ireg->iis != ISAR_IIS_DKEY) || ireg->cmsb || len) { printk(KERN_ERR"isar wrong dkey response (%x,%x,%x)\n", - ireg->iis, ireg->cmsb, len); - ret = 1;goto reterr_unlock; + ireg->iis, ireg->cmsb, len); + ret = 1; goto reterr_unlock; } spin_unlock_irqrestore(&cs->lock, flags); - while (left>0) { + while (left > 0) { if (left > 126) noc = 126; else noc = left; - nom = 2*noc; + nom = 2 * noc; mp = msg; *mp++ = sadr / 256; *mp++ = sadr % 256; @@ -290,10 +290,10 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) sp = (u_short *)tmpmsg; #if DBG_LOADFIRM printk(KERN_DEBUG"isar: load %3d words at %04x left %d\n", - noc, sadr, left); + noc, sadr, left); #endif sadr += noc; - while(noc) { + while (noc) { #ifdef __BIG_ENDIAN *mp++ = *sp % 256; *mp++ = *sp / 256; @@ -307,21 +307,21 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) spin_lock_irqsave(&cs->lock, flags); if (!sendmsg(cs, ISAR_HIS_FIRM, 0, nom, msg)) { printk(KERN_ERR"isar sendmsg prog failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } if (!waitrecmsg(cs, &len, tmp, 100000)) { printk(KERN_ERR"isar waitrecmsg prog failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } if ((ireg->iis != ISAR_IIS_FIRM) || ireg->cmsb || len) { printk(KERN_ERR"isar wrong prog response (%x,%x,%x)\n", - ireg->iis, ireg->cmsb, len); - ret = 1;goto reterr_unlock; + ireg->iis, ireg->cmsb, len); + ret = 1; goto reterr_unlock; } spin_unlock_irqrestore(&cs->lock, flags); } printk(KERN_DEBUG"isar firmware block %5d words loaded\n", - blk_head.len); + blk_head.len); } /* 10ms delay */ cnt = 10; @@ -333,16 +333,16 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) spin_lock_irqsave(&cs->lock, flags); if (!sendmsg(cs, ISAR_HIS_STDSP, 0, 2, msg)) { printk(KERN_ERR"isar sendmsg start dsp failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } if (!waitrecmsg(cs, &len, tmp, 100000)) { printk(KERN_ERR"isar waitrecmsg start dsp failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } if ((ireg->iis != ISAR_IIS_STDSP) || ireg->cmsb || len) { printk(KERN_ERR"isar wrong start dsp response (%x,%x,%x)\n", - ireg->iis, ireg->cmsb, len); - ret = 1;goto reterr_unlock; + ireg->iis, ireg->cmsb, len); + ret = 1; goto reterr_unlock; } else printk(KERN_DEBUG"isar start dsp success\n"); /* NORMAL mode entered */ @@ -356,10 +356,10 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) } if (!cnt) { printk(KERN_ERR"isar no general status event received\n"); - ret = 1;goto reterror; + ret = 1; goto reterror; } else { printk(KERN_DEBUG"isar general status event %x\n", - ireg->bstat); + ireg->bstat); } /* 10ms delay */ cnt = 10; @@ -369,7 +369,7 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) ireg->iis = 0; if (!sendmsg(cs, ISAR_HIS_DIAG, ISAR_CTRL_STST, 0, NULL)) { printk(KERN_ERR"isar sendmsg self tst failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } cnt = 10000; /* max 100 ms */ spin_unlock_irqrestore(&cs->lock, flags); @@ -380,21 +380,21 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) udelay(1000); if (!cnt) { printk(KERN_ERR"isar no self tst response\n"); - ret = 1;goto reterror; + ret = 1; goto reterror; } if ((ireg->cmsb == ISAR_CTRL_STST) && (ireg->clsb == 1) - && (ireg->par[0] == 0)) { + && (ireg->par[0] == 0)) { printk(KERN_DEBUG"isar selftest OK\n"); } else { printk(KERN_DEBUG"isar selftest not OK %x/%x/%x\n", - ireg->cmsb, ireg->clsb, ireg->par[0]); - ret = 1;goto reterror; + ireg->cmsb, ireg->clsb, ireg->par[0]); + ret = 1; goto reterror; } spin_lock_irqsave(&cs->lock, flags); ireg->iis = 0; if (!sendmsg(cs, ISAR_HIS_DIAG, ISAR_CTRL_SWVER, 0, NULL)) { printk(KERN_ERR"isar RQST SVN failed\n"); - ret = 1;goto reterr_unlock; + ret = 1; goto reterr_unlock; } spin_unlock_irqrestore(&cs->lock, flags); cnt = 30000; /* max 300 ms */ @@ -405,15 +405,15 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) udelay(1000); if (!cnt) { printk(KERN_ERR"isar no SVN response\n"); - ret = 1;goto reterror; + ret = 1; goto reterror; } else { if ((ireg->cmsb == ISAR_CTRL_SWVER) && (ireg->clsb == 1)) printk(KERN_DEBUG"isar software version %#x\n", - ireg->par[0]); + ireg->par[0]); else { printk(KERN_ERR"isar wrong swver response (%x,%x) cnt(%d)\n", - ireg->cmsb, ireg->clsb, cnt); - ret = 1;goto reterror; + ireg->cmsb, ireg->clsb, cnt); + ret = 1; goto reterror; } } spin_lock_irqsave(&cs->lock, flags); @@ -430,7 +430,7 @@ isar_load_firmware(struct IsdnCardState *cs, u_char __user *buf) cs->BC_Write_Reg(cs, 0, ISAR_IRQBIT, 0); kfree(msg); kfree(tmpmsg); - return(ret); + return (ret); } #define B_LL_NOCARRIER 8 @@ -454,9 +454,9 @@ isar_bh(struct work_struct *work) static void send_DLE_ETX(struct BCState *bcs) { - u_char dleetx[2] = {DLE,ETX}; + u_char dleetx[2] = {DLE, ETX}; struct sk_buff *skb; - + if ((skb = dev_alloc_skb(2))) { memcpy(skb_put(skb, 2), dleetx, 2); skb_queue_tail(&bcs->rqueue, skb); @@ -486,14 +486,14 @@ insert_dle(unsigned char *dest, unsigned char *src, int count) { *dest++ = DLE; } } - + static void isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs) { u_char *ptr; struct sk_buff *skb; struct isar_reg *ireg = bcs->hw.isar.reg; - + if (!ireg->clsb) { debugl1(cs, "isar zero len frame"); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); @@ -504,7 +504,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs) debugl1(cs, "isar mode 0 spurious IIS_RDATA %x/%x/%x", ireg->iis, ireg->cmsb, ireg->clsb); printk(KERN_WARNING"isar mode 0 spurious IIS_RDATA %x/%x/%x\n", - ireg->iis, ireg->cmsb, ireg->clsb); + ireg->iis, ireg->cmsb, ireg->clsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); break; case L1_MODE_TRANS: @@ -547,11 +547,11 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs) if (cs->debug & L1_DEB_WARN) debugl1(cs, "isar frame to short %d", bcs->hw.isar.rcvidx); - } else if (!(skb = dev_alloc_skb(bcs->hw.isar.rcvidx-2))) { + } else if (!(skb = dev_alloc_skb(bcs->hw.isar.rcvidx - 2))) { printk(KERN_WARNING "ISAR: receive out of memory\n"); } else { - memcpy(skb_put(skb, bcs->hw.isar.rcvidx-2), - bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx-2); + memcpy(skb_put(skb, bcs->hw.isar.rcvidx - 2), + bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx - 2); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); } @@ -576,7 +576,7 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs) ireg->clsb, bcs->hw.isar.rcvidx); if ((skb = dev_alloc_skb(bcs->hw.isar.rcvidx))) { insert_dle((u_char *)skb_put(skb, bcs->hw.isar.rcvidx), - bcs->hw.isar.rcvbuf, ireg->clsb); + bcs->hw.isar.rcvbuf, ireg->clsb); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); if (ireg->cmsb & SART_NMD) { /* ABORT */ @@ -630,13 +630,13 @@ isar_rcv_frame(struct IsdnCardState *cs, struct BCState *bcs) debugl1(cs, "isar frame to short %d", bcs->hw.isar.rcvidx); printk(KERN_WARNING "ISAR: frame to short %d\n", - bcs->hw.isar.rcvidx); + bcs->hw.isar.rcvidx); } else if (!(skb = dev_alloc_skb(len))) { printk(KERN_WARNING "ISAR: receive out of memory\n"); } else { insert_dle((u_char *)skb_put(skb, len), - bcs->hw.isar.rcvbuf, - bcs->hw.isar.rcvidx); + bcs->hw.isar.rcvbuf, + bcs->hw.isar.rcvidx); skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); send_DLE_ETX(bcs); @@ -680,8 +680,8 @@ isar_fill_fifo(struct BCState *bcs) return; if (bcs->tx_skb->len <= 0) return; - if (!(bcs->hw.isar.reg->bstat & - (bcs->hw.isar.dpath == 1 ? BSTAT_RDM1 : BSTAT_RDM2))) + if (!(bcs->hw.isar.reg->bstat & + (bcs->hw.isar.dpath == 1 ? BSTAT_RDM1 : BSTAT_RDM2))) return; if (bcs->tx_skb->len > bcs->hw.isar.mml) { msb = 0; @@ -694,51 +694,51 @@ isar_fill_fifo(struct BCState *bcs) if (!bcs->hw.isar.txcnt) { msb |= HDLC_FST; if ((bcs->mode == L1_MODE_FAX) && - (bcs->hw.isar.cmd == PCTRL_CMD_FTH)) { + (bcs->hw.isar.cmd == PCTRL_CMD_FTH)) { if (bcs->tx_skb->len > 1) { - if ((ptr[0]== 0xff) && (ptr[1] == 0x13)) + if ((ptr[0] == 0xff) && (ptr[1] == 0x13)) /* last frame */ test_and_set_bit(BC_FLG_LASTDATA, - &bcs->Flag); - } + &bcs->Flag); + } } } skb_pull(bcs->tx_skb, count); bcs->tx_cnt -= count; bcs->hw.isar.txcnt += count; switch (bcs->mode) { - case L1_MODE_NULL: - printk(KERN_ERR"isar_fill_fifo wrong mode 0\n"); - break; - case L1_MODE_TRANS: - case L1_MODE_V32: - sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, - 0, count, ptr); - break; - case L1_MODE_HDLC: + case L1_MODE_NULL: + printk(KERN_ERR"isar_fill_fifo wrong mode 0\n"); + break; + case L1_MODE_TRANS: + case L1_MODE_V32: + sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, + 0, count, ptr); + break; + case L1_MODE_HDLC: + sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, + msb, count, ptr); + break; + case L1_MODE_FAX: + if (bcs->hw.isar.state != STFAX_ACTIV) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "isar_fill_fifo: not ACTIV"); + } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, msb, count, ptr); - break; - case L1_MODE_FAX: - if (bcs->hw.isar.state != STFAX_ACTIV) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar_fill_fifo: not ACTIV"); - } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { - sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, - msb, count, ptr); - } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTM) { - sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, - 0, count, ptr); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar_fill_fifo: not FTH/FTM"); - } - break; - default: - if (cs->debug) - debugl1(cs, "isar_fill_fifo mode(%x) error", bcs->mode); - printk(KERN_ERR"isar_fill_fifo mode(%x) error\n", bcs->mode); - break; + } else if (bcs->hw.isar.cmd == PCTRL_CMD_FTM) { + sendmsg(cs, SET_DPS(bcs->hw.isar.dpath) | ISAR_HIS_SDATA, + 0, count, ptr); + } else { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "isar_fill_fifo: not FTH/FTM"); + } + break; + default: + if (cs->debug) + debugl1(cs, "isar_fill_fifo mode(%x) error", bcs->mode); + printk(KERN_ERR"isar_fill_fifo mode(%x) error\n", bcs->mode); + break; } } @@ -746,12 +746,12 @@ static inline struct BCState *sel_bcs_isar(struct IsdnCardState *cs, u_char dpath) { if ((!dpath) || (dpath == 3)) - return(NULL); + return (NULL); if (cs->bcs[0].hw.isar.dpath == dpath) - return(&cs->bcs[0]); + return (&cs->bcs[0]); if (cs->bcs[1].hw.isar.dpath == dpath) - return(&cs->bcs[1]); - return(NULL); + return (&cs->bcs[1]); + return (NULL); } static void @@ -762,8 +762,8 @@ send_frames(struct BCState *bcs) isar_fill_fifo(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.isar.txcnt; @@ -783,7 +783,7 @@ send_frames(struct BCState *bcs) } } dev_kfree_skb_any(bcs->tx_skb); - bcs->hw.isar.txcnt = 0; + bcs->hw.isar.txcnt = 0; bcs->tx_skb = NULL; } } @@ -813,7 +813,7 @@ static inline void check_send(struct IsdnCardState *cs, u_char rdm) { struct BCState *bcs; - + if (rdm & BSTAT_RDM1) { if ((bcs = sel_bcs_isar(cs, 1))) { if (bcs->mode) { @@ -828,16 +828,16 @@ check_send(struct IsdnCardState *cs, u_char rdm) } } } - + } static const char *dmril[] = {"NO SPEED", "1200/75", "NODEF2", "75/1200", - "NODEF4", "300", "600", "1200", "2400", - "4800", "7200", "9600nt", "9600t", "12000", - "14400", "WRONG"}; + "NODEF4", "300", "600", "1200", "2400", + "4800", "7200", "9600nt", "9600t", "12000", + "14400", "WRONG"}; static const char *dmrim[] = {"NO MOD", "NO DEF", "V32/V32b", "V22", "V21", - "Bell103", "V23", "Bell202", "V17", "V29", - "V27ter"}; + "Bell103", "V23", "Bell202", "V17", "V29", + "V27ter"}; static void isar_pump_status_rsp(struct BCState *bcs, struct isar_reg *ireg) { @@ -846,48 +846,48 @@ isar_pump_status_rsp(struct BCState *bcs, struct isar_reg *ireg) { u_char rim; if (!test_and_clear_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags)) - return; + return; if (ril > 14) { if (cs->debug & L1_DEB_WARN) - debugl1(cs, "wrong pstrsp ril=%d",ril); + debugl1(cs, "wrong pstrsp ril=%d", ril); ril = 15; } - switch(ireg->par[1]) { - case 0: - rim = 0; - break; - case 0x20: - rim = 2; - break; - case 0x40: - rim = 3; - break; - case 0x41: - rim = 4; - break; - case 0x51: - rim = 5; - break; - case 0x61: - rim = 6; - break; - case 0x71: - rim = 7; - break; - case 0x82: - rim = 8; - break; - case 0x92: - rim = 9; - break; - case 0xa2: - rim = 10; - break; - default: - rim = 1; - break; + switch (ireg->par[1]) { + case 0: + rim = 0; + break; + case 0x20: + rim = 2; + break; + case 0x40: + rim = 3; + break; + case 0x41: + rim = 4; + break; + case 0x51: + rim = 5; + break; + case 0x61: + rim = 6; + break; + case 0x71: + rim = 7; + break; + case 0x82: + rim = 8; + break; + case 0x92: + rim = 9; + break; + case 0xa2: + rim = 10; + break; + default: + rim = 1; + break; } - sprintf(bcs->hw.isar.conmsg,"%s %s", dmril[ril], dmrim[rim]); + sprintf(bcs->hw.isar.conmsg, "%s %s", dmril[ril], dmrim[rim]); bcs->conmsg = bcs->hw.isar.conmsg; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "pump strsp %s", bcs->conmsg); @@ -898,77 +898,77 @@ isar_pump_statev_modem(struct BCState *bcs, u_char devt) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); - switch(devt) { - case PSEV_10MS_TIMER: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev TIMER"); - break; - case PSEV_CON_ON: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev CONNECT"); - l1_msg_b(bcs->st, PH_ACTIVATE | REQUEST, NULL); - break; - case PSEV_CON_OFF: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev NO CONNECT"); - sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); - l1_msg_b(bcs->st, PH_DEACTIVATE | REQUEST, NULL); - break; - case PSEV_V24_OFF: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev V24 OFF"); - break; - case PSEV_CTS_ON: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev CTS ON"); - break; - case PSEV_CTS_OFF: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev CTS OFF"); - break; - case PSEV_DCD_ON: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev CARRIER ON"); - test_and_set_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags); - sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); - break; - case PSEV_DCD_OFF: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev CARRIER OFF"); - break; - case PSEV_DSR_ON: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev DSR ON"); - break; - case PSEV_DSR_OFF: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev DSR_OFF"); - break; - case PSEV_REM_RET: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev REMOTE RETRAIN"); - break; - case PSEV_REM_REN: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev REMOTE RENEGOTIATE"); - break; - case PSEV_GSTN_CLR: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev GSTN CLEAR"); - break; - default: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "unknown pump stev %x", devt); - break; + switch (devt) { + case PSEV_10MS_TIMER: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev TIMER"); + break; + case PSEV_CON_ON: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev CONNECT"); + l1_msg_b(bcs->st, PH_ACTIVATE | REQUEST, NULL); + break; + case PSEV_CON_OFF: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev NO CONNECT"); + sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); + l1_msg_b(bcs->st, PH_DEACTIVATE | REQUEST, NULL); + break; + case PSEV_V24_OFF: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev V24 OFF"); + break; + case PSEV_CTS_ON: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev CTS ON"); + break; + case PSEV_CTS_OFF: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev CTS OFF"); + break; + case PSEV_DCD_ON: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev CARRIER ON"); + test_and_set_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags); + sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); + break; + case PSEV_DCD_OFF: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev CARRIER OFF"); + break; + case PSEV_DSR_ON: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev DSR ON"); + break; + case PSEV_DSR_OFF: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev DSR_OFF"); + break; + case PSEV_REM_RET: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev REMOTE RETRAIN"); + break; + case PSEV_REM_REN: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev REMOTE RENEGOTIATE"); + break; + case PSEV_GSTN_CLR: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev GSTN CLEAR"); + break; + default: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "unknown pump stev %x", devt); + break; } } static void ll_deliver_faxstat(struct BCState *bcs, u_char status) { - isdn_ctrl ic; + isdn_ctrl ic; struct Channel *chanp = (struct Channel *) bcs->st->lli.userdata; - + if (bcs->cs->debug & L1_DEB_HSCX) debugl1(bcs->cs, "HL->LL FAXIND %x", status); ic.driver = bcs->cs->myid; @@ -984,153 +984,120 @@ isar_pump_statev_fax(struct BCState *bcs, u_char devt) { u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char p1; - switch(devt) { - case PSEV_10MS_TIMER: + switch (devt) { + case PSEV_10MS_TIMER: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev TIMER"); + break; + case PSEV_RSP_READY: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_READY"); + bcs->hw.isar.state = STFAX_READY; + l1_msg_b(bcs->st, PH_ACTIVATE | REQUEST, NULL); + if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { + isar_pump_cmd(bcs, ISDN_FAX_CLASS1_FRH, 3); + } else { + isar_pump_cmd(bcs, ISDN_FAX_CLASS1_FTH, 3); + } + break; + case PSEV_LINE_TX_H: + if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev TIMER"); - break; - case PSEV_RSP_READY: + debugl1(cs, "pump stev LINE_TX_H"); + bcs->hw.isar.state = STFAX_CONT; + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); + } else { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "pump stev LINE_TX_H wrong st %x", + bcs->hw.isar.state); + } + break; + case PSEV_LINE_RX_H: + if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_READY"); - bcs->hw.isar.state = STFAX_READY; - l1_msg_b(bcs->st, PH_ACTIVATE | REQUEST, NULL); - if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { - isar_pump_cmd(bcs, ISDN_FAX_CLASS1_FRH, 3); - } else { - isar_pump_cmd(bcs, ISDN_FAX_CLASS1_FTH, 3); - } - break; - case PSEV_LINE_TX_H: - if (bcs->hw.isar.state == STFAX_LINE) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev LINE_TX_H"); - bcs->hw.isar.state = STFAX_CONT; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "pump stev LINE_TX_H wrong st %x", - bcs->hw.isar.state); - } - break; - case PSEV_LINE_RX_H: - if (bcs->hw.isar.state == STFAX_LINE) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev LINE_RX_H"); - bcs->hw.isar.state = STFAX_CONT; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "pump stev LINE_RX_H wrong st %x", - bcs->hw.isar.state); - } - break; - case PSEV_LINE_TX_B: - if (bcs->hw.isar.state == STFAX_LINE) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev LINE_TX_B"); - bcs->hw.isar.state = STFAX_CONT; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "pump stev LINE_TX_B wrong st %x", - bcs->hw.isar.state); - } - break; - case PSEV_LINE_RX_B: - if (bcs->hw.isar.state == STFAX_LINE) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev LINE_RX_B"); - bcs->hw.isar.state = STFAX_CONT; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "pump stev LINE_RX_B wrong st %x", - bcs->hw.isar.state); - } - break; - case PSEV_RSP_CONN: - if (bcs->hw.isar.state == STFAX_CONT) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_CONN"); - bcs->hw.isar.state = STFAX_ACTIV; - test_and_set_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags); - sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); - if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { - /* 1s Flags before data */ - if (test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) - del_timer(&bcs->hw.isar.ftimer); - /* 1000 ms */ - bcs->hw.isar.ftimer.expires = - jiffies + ((1000 * HZ)/1000); - test_and_set_bit(BC_FLG_LL_CONN, - &bcs->Flag); - add_timer(&bcs->hw.isar.ftimer); - } else { - schedule_event(bcs, B_LL_CONNECT); - } - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "pump stev RSP_CONN wrong st %x", - bcs->hw.isar.state); - } - break; - case PSEV_FLAGS_DET: + debugl1(cs, "pump stev LINE_RX_H"); + bcs->hw.isar.state = STFAX_CONT; + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); + } else { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "pump stev LINE_RX_H wrong st %x", + bcs->hw.isar.state); + } + break; + case PSEV_LINE_TX_B: + if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev FLAGS_DET"); - break; - case PSEV_RSP_DISC: + debugl1(cs, "pump stev LINE_TX_B"); + bcs->hw.isar.state = STFAX_CONT; + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); + } else { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "pump stev LINE_TX_B wrong st %x", + bcs->hw.isar.state); + } + break; + case PSEV_LINE_RX_B: + if (bcs->hw.isar.state == STFAX_LINE) { if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_DISC"); - if (bcs->hw.isar.state == STFAX_ESCAPE) { - p1 = 5; - switch(bcs->hw.isar.newcmd) { - case 0: - bcs->hw.isar.state = STFAX_READY; - break; - case PCTRL_CMD_FTM: - p1 = 2; - case PCTRL_CMD_FTH: - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, - PCTRL_CMD_SILON, 1, &p1); - bcs->hw.isar.state = STFAX_SILDET; - break; - case PCTRL_CMD_FRM: - if (frm_extra_delay) - mdelay(frm_extra_delay); - case PCTRL_CMD_FRH: - p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod; - bcs->hw.isar.newmod = 0; - bcs->hw.isar.cmd = bcs->hw.isar.newcmd; - bcs->hw.isar.newcmd = 0; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, - bcs->hw.isar.cmd, 1, &p1); - bcs->hw.isar.state = STFAX_LINE; - bcs->hw.isar.try_mod = 3; - break; - default: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "RSP_DISC unknown newcmd %x", bcs->hw.isar.newcmd); - break; - } - } else if (bcs->hw.isar.state == STFAX_ACTIV) { - if (test_and_clear_bit(BC_FLG_LL_OK, &bcs->Flag)) { - schedule_event(bcs, B_LL_OK); - } else if (bcs->hw.isar.cmd == PCTRL_CMD_FRM) { - send_DLE_ETX(bcs); - schedule_event(bcs, B_LL_NOCARRIER); - } else { - ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); - } - bcs->hw.isar.state = STFAX_READY; + debugl1(cs, "pump stev LINE_RX_B"); + bcs->hw.isar.state = STFAX_CONT; + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_CONT, 0, NULL); + } else { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "pump stev LINE_RX_B wrong st %x", + bcs->hw.isar.state); + } + break; + case PSEV_RSP_CONN: + if (bcs->hw.isar.state == STFAX_CONT) { + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_CONN"); + bcs->hw.isar.state = STFAX_ACTIV; + test_and_set_bit(ISAR_RATE_REQ, &bcs->hw.isar.reg->Flags); + sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); + if (bcs->hw.isar.cmd == PCTRL_CMD_FTH) { + /* 1s Flags before data */ + if (test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) + del_timer(&bcs->hw.isar.ftimer); + /* 1000 ms */ + bcs->hw.isar.ftimer.expires = + jiffies + ((1000 * HZ) / 1000); + test_and_set_bit(BC_FLG_LL_CONN, + &bcs->Flag); + add_timer(&bcs->hw.isar.ftimer); } else { - bcs->hw.isar.state = STFAX_READY; - ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); + schedule_event(bcs, B_LL_CONNECT); } - break; - case PSEV_RSP_SILDET: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_SILDET"); - if (bcs->hw.isar.state == STFAX_SILDET) { + } else { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "pump stev RSP_CONN wrong st %x", + bcs->hw.isar.state); + } + break; + case PSEV_FLAGS_DET: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev FLAGS_DET"); + break; + case PSEV_RSP_DISC: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_DISC"); + if (bcs->hw.isar.state == STFAX_ESCAPE) { + p1 = 5; + switch (bcs->hw.isar.newcmd) { + case 0: + bcs->hw.isar.state = STFAX_READY; + break; + case PCTRL_CMD_FTM: + p1 = 2; + case PCTRL_CMD_FTH: + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, + PCTRL_CMD_SILON, 1, &p1); + bcs->hw.isar.state = STFAX_SILDET; + break; + case PCTRL_CMD_FRM: + if (frm_extra_delay) + mdelay(frm_extra_delay); + case PCTRL_CMD_FRH: p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod; bcs->hw.isar.newmod = 0; bcs->hw.isar.cmd = bcs->hw.isar.newcmd; @@ -1139,32 +1106,65 @@ isar_pump_statev_fax(struct BCState *bcs, u_char devt) { bcs->hw.isar.cmd, 1, &p1); bcs->hw.isar.state = STFAX_LINE; bcs->hw.isar.try_mod = 3; - } - break; - case PSEV_RSP_SILOFF: - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_SILOFF"); - break; - case PSEV_RSP_FCERR: - if (bcs->hw.isar.state == STFAX_LINE) { + break; + default: if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_FCERR try %d", - bcs->hw.isar.try_mod); - if (bcs->hw.isar.try_mod--) { - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, - bcs->hw.isar.cmd, 1, - &bcs->hw.isar.mod); - break; - } + debugl1(cs, "RSP_DISC unknown newcmd %x", bcs->hw.isar.newcmd); + break; } - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev RSP_FCERR"); - bcs->hw.isar.state = STFAX_ESCAPE; - sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); + } else if (bcs->hw.isar.state == STFAX_ACTIV) { + if (test_and_clear_bit(BC_FLG_LL_OK, &bcs->Flag)) { + schedule_event(bcs, B_LL_OK); + } else if (bcs->hw.isar.cmd == PCTRL_CMD_FRM) { + send_DLE_ETX(bcs); + schedule_event(bcs, B_LL_NOCARRIER); + } else { + ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); + } + bcs->hw.isar.state = STFAX_READY; + } else { + bcs->hw.isar.state = STFAX_READY; ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); - break; - default: - break; + } + break; + case PSEV_RSP_SILDET: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_SILDET"); + if (bcs->hw.isar.state == STFAX_SILDET) { + p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod; + bcs->hw.isar.newmod = 0; + bcs->hw.isar.cmd = bcs->hw.isar.newcmd; + bcs->hw.isar.newcmd = 0; + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, + bcs->hw.isar.cmd, 1, &p1); + bcs->hw.isar.state = STFAX_LINE; + bcs->hw.isar.try_mod = 3; + } + break; + case PSEV_RSP_SILOFF: + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_SILOFF"); + break; + case PSEV_RSP_FCERR: + if (bcs->hw.isar.state == STFAX_LINE) { + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_FCERR try %d", + bcs->hw.isar.try_mod); + if (bcs->hw.isar.try_mod--) { + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, + bcs->hw.isar.cmd, 1, + &bcs->hw.isar.mod); + break; + } + } + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev RSP_FCERR"); + bcs->hw.isar.state = STFAX_ESCAPE; + sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, PCTRL_CMD_ESC, 0, NULL); + ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_FCERROR); + break; + default: + break; } } @@ -1178,91 +1178,91 @@ isar_int_main(struct IsdnCardState *cs) get_irq_infos(cs, ireg); switch (ireg->iis & ISAR_IIS_MSCMSD) { - case ISAR_IIS_RDATA: - if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { - isar_rcv_frame(cs, bcs); - } else { - debugl1(cs, "isar spurious IIS_RDATA %x/%x/%x", - ireg->iis, ireg->cmsb, ireg->clsb); - cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - } - break; - case ISAR_IIS_GSTEV: + case ISAR_IIS_RDATA: + if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { + isar_rcv_frame(cs, bcs); + } else { + debugl1(cs, "isar spurious IIS_RDATA %x/%x/%x", + ireg->iis, ireg->cmsb, ireg->clsb); cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - ireg->bstat |= ireg->cmsb; - check_send(cs, ireg->cmsb); - break; - case ISAR_IIS_BSTEV: + } + break; + case ISAR_IIS_GSTEV: + cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); + ireg->bstat |= ireg->cmsb; + check_send(cs, ireg->cmsb); + break; + case ISAR_IIS_BSTEV: #ifdef ERROR_STATISTIC - if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { - if (ireg->cmsb == BSTEV_TBO) - bcs->err_tx++; - if (ireg->cmsb == BSTEV_RBO) - bcs->err_rdo++; - } + if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { + if (ireg->cmsb == BSTEV_TBO) + bcs->err_tx++; + if (ireg->cmsb == BSTEV_RBO) + bcs->err_rdo++; + } #endif - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "Buffer STEV dpath%d msb(%x)", - ireg->iis>>6, ireg->cmsb); - cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - break; - case ISAR_IIS_PSTEV: - if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { - rcv_mbox(cs, ireg, (u_char *)ireg->par); - if (bcs->mode == L1_MODE_V32) { - isar_pump_statev_modem(bcs, ireg->cmsb); - } else if (bcs->mode == L1_MODE_FAX) { - isar_pump_statev_fax(bcs, ireg->cmsb); - } else if (ireg->cmsb == PSEV_10MS_TIMER) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "pump stev TIMER"); - } else { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "isar IIS_PSTEV pmode %d stat %x", - bcs->mode, ireg->cmsb); - } - } else { - debugl1(cs, "isar spurious IIS_PSTEV %x/%x/%x", - ireg->iis, ireg->cmsb, ireg->clsb); - cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); - } - break; - case ISAR_IIS_PSTRSP: - if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { - rcv_mbox(cs, ireg, (u_char *)ireg->par); - isar_pump_status_rsp(bcs, ireg); + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "Buffer STEV dpath%d msb(%x)", + ireg->iis >> 6, ireg->cmsb); + cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); + break; + case ISAR_IIS_PSTEV: + if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { + rcv_mbox(cs, ireg, (u_char *)ireg->par); + if (bcs->mode == L1_MODE_V32) { + isar_pump_statev_modem(bcs, ireg->cmsb); + } else if (bcs->mode == L1_MODE_FAX) { + isar_pump_statev_fax(bcs, ireg->cmsb); + } else if (ireg->cmsb == PSEV_10MS_TIMER) { + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "pump stev TIMER"); } else { - debugl1(cs, "isar spurious IIS_PSTRSP %x/%x/%x", - ireg->iis, ireg->cmsb, ireg->clsb); - cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "isar IIS_PSTEV pmode %d stat %x", + bcs->mode, ireg->cmsb); } - break; - case ISAR_IIS_DIAG: - case ISAR_IIS_BSTRSP: - case ISAR_IIS_IOM2RSP: + } else { + debugl1(cs, "isar spurious IIS_PSTEV %x/%x/%x", + ireg->iis, ireg->cmsb, ireg->clsb); + cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); + } + break; + case ISAR_IIS_PSTRSP: + if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) { rcv_mbox(cs, ireg, (u_char *)ireg->par); - if ((cs->debug & (L1_DEB_HSCX | L1_DEB_HSCX_FIFO)) - == L1_DEB_HSCX) { - u_char *tp=debbuf; - - tp += sprintf(debbuf, "msg iis(%x) msb(%x)", - ireg->iis, ireg->cmsb); - QuickHex(tp, (u_char *)ireg->par, ireg->clsb); - debugl1(cs, debbuf); - } - break; - case ISAR_IIS_INVMSG: - rcv_mbox(cs, ireg, debbuf); - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "invalid msg his:%x", - ireg->cmsb); - break; - default: - rcv_mbox(cs, ireg, debbuf); - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "unhandled msg iis(%x) ctrl(%x/%x)", - ireg->iis, ireg->cmsb, ireg->clsb); - break; + isar_pump_status_rsp(bcs, ireg); + } else { + debugl1(cs, "isar spurious IIS_PSTRSP %x/%x/%x", + ireg->iis, ireg->cmsb, ireg->clsb); + cs->BC_Write_Reg(cs, 1, ISAR_IIA, 0); + } + break; + case ISAR_IIS_DIAG: + case ISAR_IIS_BSTRSP: + case ISAR_IIS_IOM2RSP: + rcv_mbox(cs, ireg, (u_char *)ireg->par); + if ((cs->debug & (L1_DEB_HSCX | L1_DEB_HSCX_FIFO)) + == L1_DEB_HSCX) { + u_char *tp = debbuf; + + tp += sprintf(debbuf, "msg iis(%x) msb(%x)", + ireg->iis, ireg->cmsb); + QuickHex(tp, (u_char *)ireg->par, ireg->clsb); + debugl1(cs, debbuf); + } + break; + case ISAR_IIS_INVMSG: + rcv_mbox(cs, ireg, debbuf); + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "invalid msg his:%x", + ireg->cmsb); + break; + default: + rcv_mbox(cs, ireg, debbuf); + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "unhandled msg iis(%x) ctrl(%x/%x)", + ireg->iis, ireg->cmsb, ireg->clsb); + break; } } @@ -1287,42 +1287,42 @@ setup_pump(struct BCState *bcs) { u_char ctrl, param[6]; switch (bcs->mode) { - case L1_MODE_NULL: - case L1_MODE_TRANS: - case L1_MODE_HDLC: - sendmsg(cs, dps | ISAR_HIS_PUMPCFG, PMOD_BYPASS, 0, NULL); - break; - case L1_MODE_V32: - ctrl = PMOD_DATAMODEM; - if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { - ctrl |= PCTRL_ORIG; - param[5] = PV32P6_CTN; - } else { - param[5] = PV32P6_ATN; - } - param[0] = para_TOA; /* 6 db */ - param[1] = PV32P2_V23R | PV32P2_V22A | PV32P2_V22B | - PV32P2_V22C | PV32P2_V21 | PV32P2_BEL; - param[2] = PV32P3_AMOD | PV32P3_V32B | PV32P3_V23B; - param[3] = PV32P4_UT144; - param[4] = PV32P5_UT144; - sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 6, param); - break; - case L1_MODE_FAX: - ctrl = PMOD_FAX; - if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { - ctrl |= PCTRL_ORIG; - param[1] = PFAXP2_CTN; - } else { - param[1] = PFAXP2_ATN; - } - param[0] = para_TOA; /* 6 db */ - sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 2, param); - bcs->hw.isar.state = STFAX_NULL; - bcs->hw.isar.newcmd = 0; - bcs->hw.isar.newmod = 0; - test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag); - break; + case L1_MODE_NULL: + case L1_MODE_TRANS: + case L1_MODE_HDLC: + sendmsg(cs, dps | ISAR_HIS_PUMPCFG, PMOD_BYPASS, 0, NULL); + break; + case L1_MODE_V32: + ctrl = PMOD_DATAMODEM; + if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { + ctrl |= PCTRL_ORIG; + param[5] = PV32P6_CTN; + } else { + param[5] = PV32P6_ATN; + } + param[0] = para_TOA; /* 6 db */ + param[1] = PV32P2_V23R | PV32P2_V22A | PV32P2_V22B | + PV32P2_V22C | PV32P2_V21 | PV32P2_BEL; + param[2] = PV32P3_AMOD | PV32P3_V32B | PV32P3_V23B; + param[3] = PV32P4_UT144; + param[4] = PV32P5_UT144; + sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 6, param); + break; + case L1_MODE_FAX: + ctrl = PMOD_FAX; + if (test_bit(BC_FLG_ORIG, &bcs->Flag)) { + ctrl |= PCTRL_ORIG; + param[1] = PFAXP2_CTN; + } else { + param[1] = PFAXP2_ATN; + } + param[0] = para_TOA; /* 6 db */ + sendmsg(cs, dps | ISAR_HIS_PUMPCFG, ctrl, 2, param); + bcs->hw.isar.state = STFAX_NULL; + bcs->hw.isar.newcmd = 0; + bcs->hw.isar.newmod = 0; + test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag); + break; } udelay(1000); sendmsg(cs, dps | ISAR_HIS_PSTREQ, 0, 0, NULL); @@ -1334,31 +1334,31 @@ setup_sart(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char ctrl, param[2]; - + switch (bcs->mode) { - case L1_MODE_NULL: - sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_DISABLE, 0, - NULL); - break; - case L1_MODE_TRANS: - sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_BINARY, 2, - "\0\0"); - break; - case L1_MODE_HDLC: - param[0] = 0; - sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_HDLC, 1, - param); - break; - case L1_MODE_V32: - ctrl = SMODE_V14 | SCTRL_HDMC_BOTH; - param[0] = S_P1_CHS_8; - param[1] = S_P2_BFT_DEF; - sendmsg(cs, dps | ISAR_HIS_SARTCFG, ctrl, 2, - param); - break; - case L1_MODE_FAX: - /* SART must not configured with FAX */ - break; + case L1_MODE_NULL: + sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_DISABLE, 0, + NULL); + break; + case L1_MODE_TRANS: + sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_BINARY, 2, + "\0\0"); + break; + case L1_MODE_HDLC: + param[0] = 0; + sendmsg(cs, dps | ISAR_HIS_SARTCFG, SMODE_HDLC, 1, + param); + break; + case L1_MODE_V32: + ctrl = SMODE_V14 | SCTRL_HDMC_BOTH; + param[0] = S_P1_CHS_8; + param[1] = S_P2_BFT_DEF; + sendmsg(cs, dps | ISAR_HIS_SARTCFG, ctrl, 2, + param); + break; + case L1_MODE_FAX: + /* SART must not configured with FAX */ + break; } udelay(1000); sendmsg(cs, dps | ISAR_HIS_BSTREQ, 0, 0, NULL); @@ -1369,23 +1369,23 @@ static void setup_iom2(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); - u_char cmsb = IOM_CTRL_ENA, msg[5] = {IOM_P1_TXD,0,0,0,0}; - + u_char cmsb = IOM_CTRL_ENA, msg[5] = {IOM_P1_TXD, 0, 0, 0, 0}; + if (bcs->channel) msg[1] = msg[3] = 1; switch (bcs->mode) { - case L1_MODE_NULL: - cmsb = 0; - /* dummy slot */ - msg[1] = msg[3] = bcs->hw.isar.dpath + 2; - break; - case L1_MODE_TRANS: - case L1_MODE_HDLC: - break; - case L1_MODE_V32: - case L1_MODE_FAX: - cmsb |= IOM_CTRL_ALAW | IOM_CTRL_RCV; - break; + case L1_MODE_NULL: + cmsb = 0; + /* dummy slot */ + msg[1] = msg[3] = bcs->hw.isar.dpath + 2; + break; + case L1_MODE_TRANS: + case L1_MODE_HDLC: + break; + case L1_MODE_V32: + case L1_MODE_FAX: + cmsb |= IOM_CTRL_ALAW | IOM_CTRL_RCV; + break; } sendmsg(cs, dps | ISAR_HIS_IOM2CFG, cmsb, 5, msg); udelay(1000); @@ -1399,40 +1399,40 @@ modeisar(struct BCState *bcs, int mode, int bc) struct IsdnCardState *cs = bcs->cs; /* Here we are selecting the best datapath for requested mode */ - if(bcs->mode == L1_MODE_NULL) { /* New Setup */ + if (bcs->mode == L1_MODE_NULL) { /* New Setup */ bcs->channel = bc; switch (mode) { - case L1_MODE_NULL: /* init */ - if (!bcs->hw.isar.dpath) - /* no init for dpath 0 */ - return(0); - break; - case L1_MODE_TRANS: - case L1_MODE_HDLC: - /* best is datapath 2 */ - if (!test_and_set_bit(ISAR_DP2_USE, - &bcs->hw.isar.reg->Flags)) - bcs->hw.isar.dpath = 2; - else if (!test_and_set_bit(ISAR_DP1_USE, - &bcs->hw.isar.reg->Flags)) - bcs->hw.isar.dpath = 1; - else { - printk(KERN_WARNING"isar modeisar both pathes in use\n"); - return(1); - } - break; - case L1_MODE_V32: - case L1_MODE_FAX: - /* only datapath 1 */ - if (!test_and_set_bit(ISAR_DP1_USE, - &bcs->hw.isar.reg->Flags)) - bcs->hw.isar.dpath = 1; - else { - printk(KERN_WARNING"isar modeisar analog functions only with DP1\n"); - debugl1(cs, "isar modeisar analog functions only with DP1"); - return(1); - } - break; + case L1_MODE_NULL: /* init */ + if (!bcs->hw.isar.dpath) + /* no init for dpath 0 */ + return (0); + break; + case L1_MODE_TRANS: + case L1_MODE_HDLC: + /* best is datapath 2 */ + if (!test_and_set_bit(ISAR_DP2_USE, + &bcs->hw.isar.reg->Flags)) + bcs->hw.isar.dpath = 2; + else if (!test_and_set_bit(ISAR_DP1_USE, + &bcs->hw.isar.reg->Flags)) + bcs->hw.isar.dpath = 1; + else { + printk(KERN_WARNING"isar modeisar both pathes in use\n"); + return (1); + } + break; + case L1_MODE_V32: + case L1_MODE_FAX: + /* only datapath 1 */ + if (!test_and_set_bit(ISAR_DP1_USE, + &bcs->hw.isar.reg->Flags)) + bcs->hw.isar.dpath = 1; + else { + printk(KERN_WARNING"isar modeisar analog functions only with DP1\n"); + debugl1(cs, "isar modeisar analog functions only with DP1"); + return (1); + } + break; } } if (cs->debug & L1_DEB_HSCX) @@ -1450,118 +1450,118 @@ modeisar(struct BCState *bcs, int mode, int bc) test_and_clear_bit(ISAR_DP2_USE, &bcs->hw.isar.reg->Flags); bcs->hw.isar.dpath = 0; } - return(0); + return (0); } static void -isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para) +isar_pump_cmd(struct BCState *bcs, u_char cmd, u_char para) { struct IsdnCardState *cs = bcs->cs; u_char dps = SET_DPS(bcs->hw.isar.dpath); u_char ctrl = 0, nom = 0, p1 = 0; - switch(cmd) { - case ISDN_FAX_CLASS1_FTM: - test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FTM; - nom = 1; - bcs->hw.isar.state = STFAX_LINE; - bcs->hw.isar.cmd = ctrl; - bcs->hw.isar.mod = para; - bcs->hw.isar.newmod = 0; - bcs->hw.isar.newcmd = 0; - bcs->hw.isar.try_mod = 3; - } else if ((bcs->hw.isar.state == STFAX_ACTIV) && - (bcs->hw.isar.cmd == PCTRL_CMD_FTM) && - (bcs->hw.isar.mod == para)) { - ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); - } else { - bcs->hw.isar.newmod = para; - bcs->hw.isar.newcmd = PCTRL_CMD_FTM; - nom = 0; - ctrl = PCTRL_CMD_ESC; - bcs->hw.isar.state = STFAX_ESCAPE; - } - break; - case ISDN_FAX_CLASS1_FTH: - test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FTH; - nom = 1; - bcs->hw.isar.state = STFAX_LINE; - bcs->hw.isar.cmd = ctrl; - bcs->hw.isar.mod = para; - bcs->hw.isar.newmod = 0; - bcs->hw.isar.newcmd = 0; - bcs->hw.isar.try_mod = 3; - } else if ((bcs->hw.isar.state == STFAX_ACTIV) && - (bcs->hw.isar.cmd == PCTRL_CMD_FTH) && - (bcs->hw.isar.mod == para)) { - ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); - } else { - bcs->hw.isar.newmod = para; - bcs->hw.isar.newcmd = PCTRL_CMD_FTH; - nom = 0; - ctrl = PCTRL_CMD_ESC; - bcs->hw.isar.state = STFAX_ESCAPE; - } - break; - case ISDN_FAX_CLASS1_FRM: - test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FRM; - nom = 1; - bcs->hw.isar.state = STFAX_LINE; - bcs->hw.isar.cmd = ctrl; - bcs->hw.isar.mod = para; - bcs->hw.isar.newmod = 0; - bcs->hw.isar.newcmd = 0; - bcs->hw.isar.try_mod = 3; - } else if ((bcs->hw.isar.state == STFAX_ACTIV) && - (bcs->hw.isar.cmd == PCTRL_CMD_FRM) && - (bcs->hw.isar.mod == para)) { - ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); - } else { - bcs->hw.isar.newmod = para; - bcs->hw.isar.newcmd = PCTRL_CMD_FRM; - nom = 0; - ctrl = PCTRL_CMD_ESC; - bcs->hw.isar.state = STFAX_ESCAPE; - } - break; - case ISDN_FAX_CLASS1_FRH: - test_and_set_bit(BC_FLG_FRH_WAIT, &bcs->Flag); - if (bcs->hw.isar.state == STFAX_READY) { - p1 = para; - ctrl = PCTRL_CMD_FRH; - nom = 1; - bcs->hw.isar.state = STFAX_LINE; - bcs->hw.isar.cmd = ctrl; - bcs->hw.isar.mod = para; - bcs->hw.isar.newmod = 0; - bcs->hw.isar.newcmd = 0; - bcs->hw.isar.try_mod = 3; - } else if ((bcs->hw.isar.state == STFAX_ACTIV) && - (bcs->hw.isar.cmd == PCTRL_CMD_FRH) && - (bcs->hw.isar.mod == para)) { - ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); - } else { - bcs->hw.isar.newmod = para; - bcs->hw.isar.newcmd = PCTRL_CMD_FRH; - nom = 0; - ctrl = PCTRL_CMD_ESC; - bcs->hw.isar.state = STFAX_ESCAPE; - } - break; - case ISDN_FAXPUMP_HALT: - bcs->hw.isar.state = STFAX_NULL; + switch (cmd) { + case ISDN_FAX_CLASS1_FTM: + test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); + if (bcs->hw.isar.state == STFAX_READY) { + p1 = para; + ctrl = PCTRL_CMD_FTM; + nom = 1; + bcs->hw.isar.state = STFAX_LINE; + bcs->hw.isar.cmd = ctrl; + bcs->hw.isar.mod = para; + bcs->hw.isar.newmod = 0; + bcs->hw.isar.newcmd = 0; + bcs->hw.isar.try_mod = 3; + } else if ((bcs->hw.isar.state == STFAX_ACTIV) && + (bcs->hw.isar.cmd == PCTRL_CMD_FTM) && + (bcs->hw.isar.mod == para)) { + ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); + } else { + bcs->hw.isar.newmod = para; + bcs->hw.isar.newcmd = PCTRL_CMD_FTM; nom = 0; - ctrl = PCTRL_CMD_HALT; - break; + ctrl = PCTRL_CMD_ESC; + bcs->hw.isar.state = STFAX_ESCAPE; + } + break; + case ISDN_FAX_CLASS1_FTH: + test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); + if (bcs->hw.isar.state == STFAX_READY) { + p1 = para; + ctrl = PCTRL_CMD_FTH; + nom = 1; + bcs->hw.isar.state = STFAX_LINE; + bcs->hw.isar.cmd = ctrl; + bcs->hw.isar.mod = para; + bcs->hw.isar.newmod = 0; + bcs->hw.isar.newcmd = 0; + bcs->hw.isar.try_mod = 3; + } else if ((bcs->hw.isar.state == STFAX_ACTIV) && + (bcs->hw.isar.cmd == PCTRL_CMD_FTH) && + (bcs->hw.isar.mod == para)) { + ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); + } else { + bcs->hw.isar.newmod = para; + bcs->hw.isar.newcmd = PCTRL_CMD_FTH; + nom = 0; + ctrl = PCTRL_CMD_ESC; + bcs->hw.isar.state = STFAX_ESCAPE; + } + break; + case ISDN_FAX_CLASS1_FRM: + test_and_clear_bit(BC_FLG_FRH_WAIT, &bcs->Flag); + if (bcs->hw.isar.state == STFAX_READY) { + p1 = para; + ctrl = PCTRL_CMD_FRM; + nom = 1; + bcs->hw.isar.state = STFAX_LINE; + bcs->hw.isar.cmd = ctrl; + bcs->hw.isar.mod = para; + bcs->hw.isar.newmod = 0; + bcs->hw.isar.newcmd = 0; + bcs->hw.isar.try_mod = 3; + } else if ((bcs->hw.isar.state == STFAX_ACTIV) && + (bcs->hw.isar.cmd == PCTRL_CMD_FRM) && + (bcs->hw.isar.mod == para)) { + ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); + } else { + bcs->hw.isar.newmod = para; + bcs->hw.isar.newcmd = PCTRL_CMD_FRM; + nom = 0; + ctrl = PCTRL_CMD_ESC; + bcs->hw.isar.state = STFAX_ESCAPE; + } + break; + case ISDN_FAX_CLASS1_FRH: + test_and_set_bit(BC_FLG_FRH_WAIT, &bcs->Flag); + if (bcs->hw.isar.state == STFAX_READY) { + p1 = para; + ctrl = PCTRL_CMD_FRH; + nom = 1; + bcs->hw.isar.state = STFAX_LINE; + bcs->hw.isar.cmd = ctrl; + bcs->hw.isar.mod = para; + bcs->hw.isar.newmod = 0; + bcs->hw.isar.newcmd = 0; + bcs->hw.isar.try_mod = 3; + } else if ((bcs->hw.isar.state == STFAX_ACTIV) && + (bcs->hw.isar.cmd == PCTRL_CMD_FRH) && + (bcs->hw.isar.mod == para)) { + ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_CONNECT); + } else { + bcs->hw.isar.newmod = para; + bcs->hw.isar.newcmd = PCTRL_CMD_FRH; + nom = 0; + ctrl = PCTRL_CMD_ESC; + bcs->hw.isar.state = STFAX_ESCAPE; + } + break; + case ISDN_FAXPUMP_HALT: + bcs->hw.isar.state = STFAX_NULL; + nom = 0; + ctrl = PCTRL_CMD_HALT; + break; } if (ctrl) sendmsg(cs, dps | ISAR_HIS_PUMPCTRL, ctrl, nom, &p1); @@ -1572,10 +1572,10 @@ isar_setup(struct IsdnCardState *cs) { u_char msg; int i; - + /* Dpath 1, 2 */ msg = 61; - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { /* Buffer Config */ sendmsg(cs, (i ? ISAR_HIS_DPS2 : ISAR_HIS_DPS1) | ISAR_HIS_P12CFG, 4, 1, &msg); @@ -1596,93 +1596,93 @@ isar_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs, "DRQ set BC_FLG_BUSY"); - bcs->hw.isar.txcnt = 0; - bcs->cs->BC_Send_Data(bcs); - } + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + if (bcs->cs->debug & L1_DEB_HSCX) + debugl1(bcs->cs, "DRQ set BC_FLG_BUSY"); + bcs->hw.isar.txcnt = 0; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "isar_l2l1: this shouldn't happen\n"); + } else { + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + if (bcs->cs->debug & L1_DEB_HSCX) + debugl1(bcs->cs, "PUI set BC_FLG_BUSY"); + bcs->tx_skb = skb; + bcs->hw.isar.txcnt = 0; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + bcs->hw.isar.conmsg[0] = 0; + if (test_bit(FLG_ORIG, &st->l2.flag)) + test_and_set_bit(BC_FLG_ORIG, &bcs->Flag); + else + test_and_clear_bit(BC_FLG_ORIG, &bcs->Flag); + switch (st->l1.mode) { + case L1_MODE_TRANS: + case L1_MODE_HDLC: + ret = modeisar(bcs, st->l1.mode, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); + if (ret) + l1_msg_b(st, PH_DEACTIVATE | REQUEST, arg); + else + l1_msg_b(st, PH_ACTIVATE | REQUEST, arg); break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "isar_l2l1: this shouldn't happen\n"); - } else { - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs, "PUI set BC_FLG_BUSY"); - bcs->tx_skb = skb; - bcs->hw.isar.txcnt = 0; - bcs->cs->BC_Send_Data(bcs); - } + case L1_MODE_V32: + case L1_MODE_FAX: + ret = modeisar(bcs, st->l1.mode, st->l1.bc); spin_unlock_irqrestore(&bcs->cs->lock, flags); + if (ret) + l1_msg_b(st, PH_DEACTIVATE | REQUEST, arg); break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - bcs->hw.isar.conmsg[0] = 0; - if (test_bit(FLG_ORIG, &st->l2.flag)) - test_and_set_bit(BC_FLG_ORIG, &bcs->Flag); - else - test_and_clear_bit(BC_FLG_ORIG, &bcs->Flag); - switch(st->l1.mode) { - case L1_MODE_TRANS: - case L1_MODE_HDLC: - ret = modeisar(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - if (ret) - l1_msg_b(st, PH_DEACTIVATE | REQUEST, arg); - else - l1_msg_b(st, PH_ACTIVATE | REQUEST, arg); - break; - case L1_MODE_V32: - case L1_MODE_FAX: - ret = modeisar(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - if (ret) - l1_msg_b(st, PH_DEACTIVATE | REQUEST, arg); - break; - default: - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - } + default: + spin_unlock_irqrestore(&bcs->cs->lock, flags); break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); + } + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + switch (st->l1.mode) { + case L1_MODE_TRANS: + case L1_MODE_HDLC: + case L1_MODE_V32: break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - switch(st->l1.mode) { - case L1_MODE_TRANS: - case L1_MODE_HDLC: - case L1_MODE_V32: - break; - case L1_MODE_FAX: - isar_pump_cmd(bcs, ISDN_FAXPUMP_HALT, 0); - break; - } - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs, "PDAC clear BC_FLG_BUSY"); - modeisar(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + case L1_MODE_FAX: + isar_pump_cmd(bcs, ISDN_FAXPUMP_HALT, 0); break; + } + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + if (bcs->cs->debug & L1_DEB_HSCX) + debugl1(bcs->cs, "PDAC clear BC_FLG_BUSY"); + modeisar(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -1751,149 +1751,149 @@ isar_auxcmd(struct IsdnCardState *cs, isdn_ctrl *ic) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "isar_auxcmd cmd/ch %x/%ld", ic->command, ic->arg); switch (ic->command) { - case (ISDN_CMD_FAXCMD): - bcs = cs->channel[ic->arg].bcs; - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "isar_auxcmd cmd/subcmd %d/%d", - ic->parm.aux.cmd, ic->parm.aux.subcmd); - switch(ic->parm.aux.cmd) { - case ISDN_FAX_CLASS1_CTRL: - if (ic->parm.aux.subcmd == ETX) - test_and_set_bit(BC_FLG_DLEETX, - &bcs->Flag); - break; - case ISDN_FAX_CLASS1_FTS: - if (ic->parm.aux.subcmd == AT_QUERY) { + case (ISDN_CMD_FAXCMD): + bcs = cs->channel[ic->arg].bcs; + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "isar_auxcmd cmd/subcmd %d/%d", + ic->parm.aux.cmd, ic->parm.aux.subcmd); + switch (ic->parm.aux.cmd) { + case ISDN_FAX_CLASS1_CTRL: + if (ic->parm.aux.subcmd == ETX) + test_and_set_bit(BC_FLG_DLEETX, + &bcs->Flag); + break; + case ISDN_FAX_CLASS1_FTS: + if (ic->parm.aux.subcmd == AT_QUERY) { + ic->command = ISDN_STAT_FAXIND; + ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; + cs->iif.statcallb(ic); + return (0); + } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { + strcpy(ic->parm.aux.para, "0-255"); + ic->command = ISDN_STAT_FAXIND; + ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; + cs->iif.statcallb(ic); + return (0); + } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "isar_auxcmd %s=%d", + FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); + if (bcs->hw.isar.state == STFAX_READY) { + if (!ic->parm.aux.para[0]) { ic->command = ISDN_STAT_FAXIND; ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; cs->iif.statcallb(ic); - return(0); - } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { - strcpy(ic->parm.aux.para, "0-255"); - ic->command = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; - cs->iif.statcallb(ic); - return(0); - } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "isar_auxcmd %s=%d", - FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); - if (bcs->hw.isar.state == STFAX_READY) { - if (! ic->parm.aux.para[0]) { - ic->command = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_OK; - cs->iif.statcallb(ic); - return(0); - } - if (! test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) { - /* n*10 ms */ - bcs->hw.isar.ftimer.expires = - jiffies + ((ic->parm.aux.para[0] * 10 * HZ)/1000); - test_and_set_bit(BC_FLG_FTI_FTS, &bcs->Flag); - add_timer(&bcs->hw.isar.ftimer); - return(0); - } else { - if (cs->debug) - debugl1(cs, "isar FTS=%d and FTI busy", - ic->parm.aux.para[0]); - } - } else { - if (cs->debug) - debugl1(cs, "isar FTS=%d and isar.state not ready(%x)", - ic->parm.aux.para[0],bcs->hw.isar.state); - } - ic->command = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; - cs->iif.statcallb(ic); + return (0); } - break; - case ISDN_FAX_CLASS1_FRM: - case ISDN_FAX_CLASS1_FRH: - case ISDN_FAX_CLASS1_FTM: - case ISDN_FAX_CLASS1_FTH: - if (ic->parm.aux.subcmd == AT_QUERY) { - sprintf(ic->parm.aux.para, - "%d", bcs->hw.isar.mod); - ic->command = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; - cs->iif.statcallb(ic); - return(0); - } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { - char *p = ic->parm.aux.para; - for(i=0;icommand = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; - cs->iif.statcallb(ic); - return(0); - } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "isar_auxcmd %s=%d", - FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); - for(i=0;iparm.aux.para[0]) - break; - if ((i < FAXMODCNT) && ((1<Flag)) { - isar_pump_cmd(bcs, - ic->parm.aux.cmd, + if (!test_and_set_bit(BC_FLG_FTI_RUN, &bcs->Flag)) { + /* n*10 ms */ + bcs->hw.isar.ftimer.expires = + jiffies + ((ic->parm.aux.para[0] * 10 * HZ) / 1000); + test_and_set_bit(BC_FLG_FTI_FTS, &bcs->Flag); + add_timer(&bcs->hw.isar.ftimer); + return (0); + } else { + if (cs->debug) + debugl1(cs, "isar FTS=%d and FTI busy", ic->parm.aux.para[0]); - return(0); - } } - /* wrong modulation or not activ */ - /* fall through */ - default: - ic->command = ISDN_STAT_FAXIND; - ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; - cs->iif.statcallb(ic); + } else { + if (cs->debug) + debugl1(cs, "isar FTS=%d and isar.state not ready(%x)", + ic->parm.aux.para[0], bcs->hw.isar.state); + } + ic->command = ISDN_STAT_FAXIND; + ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; + cs->iif.statcallb(ic); } break; - case (ISDN_CMD_IOCTL): - switch (ic->arg) { - case 9: /* load firmware */ - features = ISDN_FEATURE_L2_MODEM | - ISDN_FEATURE_L2_FAX | - ISDN_FEATURE_L3_FCLASS1; - memcpy(&adr, ic->parm.num, sizeof(ulong)); - if (isar_load_firmware(cs, (u_char __user *)adr)) - return(1); - else - ll_run(cs, features); - break; - case 20: - features = *(unsigned int *) ic->parm.num; - printk(KERN_DEBUG "HiSax: max modulation old(%04x) new(%04x)\n", - modmask, features); - modmask = features; - break; - case 21: - features = *(unsigned int *) ic->parm.num; - printk(KERN_DEBUG "HiSax: FRM extra delay old(%d) new(%d) ms\n", - frm_extra_delay, features); - if (features >= 0) - frm_extra_delay = features; - break; - case 22: - features = *(unsigned int *) ic->parm.num; - printk(KERN_DEBUG "HiSax: TOA old(%d) new(%d) db\n", - para_TOA, features); - if (features >= 0 && features < 32) - para_TOA = features; - break; - default: - printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", - (int) ic->arg); - return(-EINVAL); + case ISDN_FAX_CLASS1_FRM: + case ISDN_FAX_CLASS1_FRH: + case ISDN_FAX_CLASS1_FTM: + case ISDN_FAX_CLASS1_FTH: + if (ic->parm.aux.subcmd == AT_QUERY) { + sprintf(ic->parm.aux.para, + "%d", bcs->hw.isar.mod); + ic->command = ISDN_STAT_FAXIND; + ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; + cs->iif.statcallb(ic); + return (0); + } else if (ic->parm.aux.subcmd == AT_EQ_QUERY) { + char *p = ic->parm.aux.para; + for (i = 0; i < FAXMODCNT; i++) + if ((1 << i) & modmask) + p += sprintf(p, "%d,", faxmodulation[i]); + p--; + *p = 0; + ic->command = ISDN_STAT_FAXIND; + ic->parm.aux.cmd = ISDN_FAX_CLASS1_QUERY; + cs->iif.statcallb(ic); + return (0); + } else if (ic->parm.aux.subcmd == AT_EQ_VALUE) { + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "isar_auxcmd %s=%d", + FC1_CMD[ic->parm.aux.cmd], ic->parm.aux.para[0]); + for (i = 0; i < FAXMODCNT; i++) + if (faxmodulation[i] == ic->parm.aux.para[0]) + break; + if ((i < FAXMODCNT) && ((1 << i) & modmask) && + test_bit(BC_FLG_INIT, &bcs->Flag)) { + isar_pump_cmd(bcs, + ic->parm.aux.cmd, + ic->parm.aux.para[0]); + return (0); + } } + /* wrong modulation or not activ */ + /* fall through */ + default: + ic->command = ISDN_STAT_FAXIND; + ic->parm.aux.cmd = ISDN_FAX_CLASS1_ERROR; + cs->iif.statcallb(ic); + } + break; + case (ISDN_CMD_IOCTL): + switch (ic->arg) { + case 9: /* load firmware */ + features = ISDN_FEATURE_L2_MODEM | + ISDN_FEATURE_L2_FAX | + ISDN_FEATURE_L3_FCLASS1; + memcpy(&adr, ic->parm.num, sizeof(ulong)); + if (isar_load_firmware(cs, (u_char __user *)adr)) + return (1); + else + ll_run(cs, features); + break; + case 20: + features = *(unsigned int *) ic->parm.num; + printk(KERN_DEBUG "HiSax: max modulation old(%04x) new(%04x)\n", + modmask, features); + modmask = features; + break; + case 21: + features = *(unsigned int *) ic->parm.num; + printk(KERN_DEBUG "HiSax: FRM extra delay old(%d) new(%d) ms\n", + frm_extra_delay, features); + if (features >= 0) + frm_extra_delay = features; + break; + case 22: + features = *(unsigned int *) ic->parm.num; + printk(KERN_DEBUG "HiSax: TOA old(%d) new(%d) db\n", + para_TOA, features); + if (features >= 0 && features < 32) + para_TOA = features; break; default: - return(-EINVAL); + printk(KERN_DEBUG "HiSax: invalid ioctl %d\n", + (int) ic->arg); + return (-EINVAL); + } + break; + default: + return (-EINVAL); } - return(0); + return (0); } void initisar(struct IsdnCardState *cs) diff --git a/drivers/isdn/hisax/isar.h b/drivers/isdn/hisax/isar.h index bf7676586392..0f4d101faf37 100644 --- a/drivers/isdn/hisax/isar.h +++ b/drivers/isdn/hisax/isar.h @@ -4,12 +4,12 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ - + #define ISAR_IRQMSK 0x04 #define ISAR_IRQSTA 0x04 #define ISAR_IRQBIT 0x75 @@ -21,7 +21,7 @@ #define ISAR_HIA 0x50 #define ISAR_MBOX 0x4c #define ISAR_WADR 0x4a -#define ISAR_RADR 0x48 +#define ISAR_RADR 0x48 #define ISAR_HIS_VNR 0x14 #define ISAR_HIS_DKEY 0x02 @@ -32,9 +32,9 @@ #define ISAR_HIS_TIMERIRQ 0x25 #define ISAR_HIS_P0CFG 0x3c #define ISAR_HIS_P12CFG 0x24 -#define ISAR_HIS_SARTCFG 0x25 -#define ISAR_HIS_PUMPCFG 0x26 -#define ISAR_HIS_PUMPCTRL 0x2a +#define ISAR_HIS_SARTCFG 0x25 +#define ISAR_HIS_PUMPCFG 0x26 +#define ISAR_HIS_PUMPCTRL 0x2a #define ISAR_HIS_IOM2CFG 0x27 #define ISAR_HIS_IOM2REQ 0x07 #define ISAR_HIS_IOM2CTRL 0x2b @@ -43,7 +43,7 @@ #define ISAR_HIS_SDATA 0x20 #define ISAR_HIS_DPS1 0x40 #define ISAR_HIS_DPS2 0x80 -#define SET_DPS(x) ((x<<6) & 0xc0) +#define SET_DPS(x) ((x << 6) & 0xc0) #define ISAR_CMD_TIMERIRQ_OFF 0x20 #define ISAR_CMD_TIMERIRQ_ON 0x21 diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c index d5eeacf565d6..800095781bfb 100644 --- a/drivers/isdn/hisax/isdnl1.c +++ b/drivers/isdn/hisax/isdnl1.c @@ -5,7 +5,7 @@ * Author Karsten Keil * based on the teles driver from Jan den Ouden * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -40,7 +40,7 @@ enum { ST_L1_F8, }; -#define L1S_STATE_COUNT (ST_L1_F8+1) +#define L1S_STATE_COUNT (ST_L1_F8 + 1) static char *strL1SState[] = { @@ -65,7 +65,7 @@ enum { ST_L1_TRANS, }; -#define L1U_STATE_COUNT (ST_L1_TRANS+1) +#define L1U_STATE_COUNT (ST_L1_TRANS + 1) static char *strL1UState[] = { @@ -83,7 +83,7 @@ enum { ST_L1_ACTIV, }; -#define L1B_STATE_COUNT (ST_L1_ACTIV+1) +#define L1B_STATE_COUNT (ST_L1_ACTIV + 1) static char *strL1BState[] = { @@ -100,7 +100,7 @@ enum { EV_DEACT_CNF, EV_DEACT_IND, EV_POWER_UP, - EV_RSYNC_IND, + EV_RSYNC_IND, EV_INFO2_IND, EV_INFO4_IND, EV_TIMER_DEACT, @@ -118,7 +118,7 @@ static char *strL1Event[] = "EV_DEACT_CNF", "EV_DEACT_IND", "EV_POWER_UP", - "EV_RSYNC_IND", + "EV_RSYNC_IND", "EV_INFO2_IND", "EV_INFO4_IND", "EV_TIMER_DEACT", @@ -131,7 +131,7 @@ debugl1(struct IsdnCardState *cs, char *fmt, ...) { va_list args; char tmp[8]; - + va_start(args, fmt); sprintf(tmp, "Card%d ", cs->cardnr + 1); VHiSax_putstatus(cs, tmp, fmt, args); @@ -145,7 +145,7 @@ l1m_debug(struct FsmInst *fi, char *fmt, ...) struct PStack *st = fi->userdata; struct IsdnCardState *cs = st->l1.hardware; char tmp[8]; - + va_start(args, fmt); sprintf(tmp, "Card%d ", cs->cardnr + 1); VHiSax_putstatus(cs, tmp, fmt, args); @@ -209,19 +209,19 @@ DChannel_proc_rcv(struct IsdnCardState *cs) if (stptr) if (test_bit(FLG_L1_ACTTIMER, &stptr->l1.Flags)) - FsmEvent(&stptr->l1.l1m, EV_TIMER_ACT, NULL); + FsmEvent(&stptr->l1.l1m, EV_TIMER_ACT, NULL); while ((skb = skb_dequeue(&cs->rq))) { #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA", 1); #endif stptr = cs->stlist; - if (skb->len<3) { - debugl1(cs, "D-channel frame too short(%d)",skb->len); + if (skb->len < 3) { + debugl1(cs, "D-channel frame too short(%d)", skb->len); dev_kfree_skb(skb); return; } - if ((skb->data[0] & 1) || !(skb->data[1] &1)) { + if ((skb->data[0] & 1) || !(skb->data[1] & 1)) { debugl1(cs, "D-channel frame wrong EA0/EA1"); dev_kfree_skb(skb); return; @@ -378,60 +378,60 @@ static char * l2cmd(u_char cmd) { switch (cmd & ~0x10) { - case 1: - return "RR"; - case 5: - return "RNR"; - case 9: - return "REJ"; - case 0x6f: - return "SABME"; - case 0x0f: - return "DM"; - case 3: - return "UI"; - case 0x43: - return "DISC"; - case 0x63: - return "UA"; - case 0x87: - return "FRMR"; - case 0xaf: - return "XID"; - default: - if (!(cmd & 1)) - return "I"; - else - return "invalid command"; + case 1: + return "RR"; + case 5: + return "RNR"; + case 9: + return "REJ"; + case 0x6f: + return "SABME"; + case 0x0f: + return "DM"; + case 3: + return "UI"; + case 0x43: + return "DISC"; + case 0x63: + return "UA"; + case 0x87: + return "FRMR"; + case 0xaf: + return "XID"; + default: + if (!(cmd & 1)) + return "I"; + else + return "invalid command"; } } static char tmpdeb[32]; static char * -l2frames(u_char * ptr) +l2frames(u_char *ptr) { switch (ptr[2] & ~0x10) { - case 1: - case 5: - case 9: - sprintf(tmpdeb, "%s[%d](nr %d)", l2cmd(ptr[2]), ptr[3] & 1, ptr[3] >> 1); - break; - case 0x6f: - case 0x0f: - case 3: - case 0x43: - case 0x63: - case 0x87: - case 0xaf: - sprintf(tmpdeb, "%s[%d]", l2cmd(ptr[2]), (ptr[2] & 0x10) >> 4); + case 1: + case 5: + case 9: + sprintf(tmpdeb, "%s[%d](nr %d)", l2cmd(ptr[2]), ptr[3] & 1, ptr[3] >> 1); + break; + case 0x6f: + case 0x0f: + case 3: + case 0x43: + case 0x63: + case 0x87: + case 0xaf: + sprintf(tmpdeb, "%s[%d]", l2cmd(ptr[2]), (ptr[2] & 0x10) >> 4); + break; + default: + if (!(ptr[2] & 1)) { + sprintf(tmpdeb, "I[%d](ns %d, nr %d)", ptr[3] & 1, ptr[2] >> 1, ptr[3] >> 1); break; - default: - if (!(ptr[2] & 1)) { - sprintf(tmpdeb, "I[%d](ns %d, nr %d)", ptr[3] & 1, ptr[2] >> 1, ptr[3] >> 1); - break; - } else - return "invalid command"; + } else + return "invalid command"; } @@ -547,24 +547,24 @@ l1_timer3(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - test_and_clear_bit(FLG_L1_T3RUN, &st->l1.Flags); + test_and_clear_bit(FLG_L1_T3RUN, &st->l1.Flags); if (test_and_clear_bit(FLG_L1_ACTIVATING, &st->l1.Flags)) L1deactivated(st->l1.hardware); #ifdef HISAX_UINTERFACE if (!test_bit(FLG_L1_UINT, &st->l1.Flags)) #endif - if (st->l1.l1m.state != ST_L1_F6) { - FsmChangeState(fi, ST_L1_F3); - st->l1.l1hw(st, HW_ENABLE | REQUEST, NULL); - } + if (st->l1.l1m.state != ST_L1_F6) { + FsmChangeState(fi, ST_L1_F3); + st->l1.l1hw(st, HW_ENABLE | REQUEST, NULL); + } } static void l1_timer_act(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - + test_and_clear_bit(FLG_L1_ACTTIMER, &st->l1.Flags); test_and_set_bit(FLG_L1_ACTIVATED, &st->l1.Flags); L1activated(st->l1.hardware); @@ -574,7 +574,7 @@ static void l1_timer_deact(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - + test_and_clear_bit(FLG_L1_DEACTTIMER, &st->l1.Flags); test_and_clear_bit(FLG_L1_ACTIVATED, &st->l1.Flags); L1deactivated(st->l1.hardware); @@ -585,7 +585,7 @@ static void l1_activate_s(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - + st->l1.l1hw(st, HW_RESET | REQUEST, NULL); } @@ -679,7 +679,7 @@ static void l1_activate_u(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - + st->l1.l1hw(st, HW_INFO1 | REQUEST, NULL); } @@ -751,7 +751,7 @@ static struct FsmNode L1BFnList[] __initdata = {ST_L1_WAIT_DEACT, EV_TIMER_DEACT, l1b_timer_deact}, }; -int __init +int __init Isdnl1New(void) { int retval; @@ -803,35 +803,35 @@ dch_l2l1(struct PStack *st, int pr, void *arg) struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware; switch (pr) { - case (PH_DATA | REQUEST): - case (PH_PULL | REQUEST): - case (PH_PULL |INDICATION): - st->l1.l1hw(st, pr, arg); - break; - case (PH_ACTIVATE | REQUEST): - if (cs->debug) - debugl1(cs, "PH_ACTIVATE_REQ %s", - st->l1.l1m.fsm->strState[st->l1.l1m.state]); - if (test_bit(FLG_L1_ACTIVATED, &st->l1.Flags)) - st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); - else { - test_and_set_bit(FLG_L1_ACTIVATING, &st->l1.Flags); - FsmEvent(&st->l1.l1m, EV_PH_ACTIVATE, arg); - } - break; - case (PH_TESTLOOP | REQUEST): - if (1 & (long) arg) - debugl1(cs, "PH_TEST_LOOP B1"); - if (2 & (long) arg) - debugl1(cs, "PH_TEST_LOOP B2"); - if (!(3 & (long) arg)) - debugl1(cs, "PH_TEST_LOOP DISABLED"); - st->l1.l1hw(st, HW_TESTLOOP | REQUEST, arg); - break; - default: - if (cs->debug) - debugl1(cs, "dch_l2l1 msg %04X unhandled", pr); - break; + case (PH_DATA | REQUEST): + case (PH_PULL | REQUEST): + case (PH_PULL | INDICATION): + st->l1.l1hw(st, pr, arg); + break; + case (PH_ACTIVATE | REQUEST): + if (cs->debug) + debugl1(cs, "PH_ACTIVATE_REQ %s", + st->l1.l1m.fsm->strState[st->l1.l1m.state]); + if (test_bit(FLG_L1_ACTIVATED, &st->l1.Flags)) + st->l1.l1l2(st, PH_ACTIVATE | CONFIRM, NULL); + else { + test_and_set_bit(FLG_L1_ACTIVATING, &st->l1.Flags); + FsmEvent(&st->l1.l1m, EV_PH_ACTIVATE, arg); + } + break; + case (PH_TESTLOOP | REQUEST): + if (1 & (long) arg) + debugl1(cs, "PH_TEST_LOOP B1"); + if (2 & (long) arg) + debugl1(cs, "PH_TEST_LOOP B2"); + if (!(3 & (long) arg)) + debugl1(cs, "PH_TEST_LOOP DISABLED"); + st->l1.l1hw(st, HW_TESTLOOP | REQUEST, arg); + break; + default: + if (cs->debug) + debugl1(cs, "dch_l2l1 msg %04X unhandled", pr); + break; } } @@ -840,35 +840,35 @@ l1_msg(struct IsdnCardState *cs, int pr, void *arg) { struct PStack *st; st = cs->stlist; - + while (st) { - switch(pr) { - case (HW_RESET | INDICATION): - FsmEvent(&st->l1.l1m, EV_RESET_IND, arg); - break; - case (HW_DEACTIVATE | CONFIRM): - FsmEvent(&st->l1.l1m, EV_DEACT_CNF, arg); - break; - case (HW_DEACTIVATE | INDICATION): - FsmEvent(&st->l1.l1m, EV_DEACT_IND, arg); - break; - case (HW_POWERUP | CONFIRM): - FsmEvent(&st->l1.l1m, EV_POWER_UP, arg); - break; - case (HW_RSYNC | INDICATION): - FsmEvent(&st->l1.l1m, EV_RSYNC_IND, arg); - break; - case (HW_INFO2 | INDICATION): - FsmEvent(&st->l1.l1m, EV_INFO2_IND, arg); - break; - case (HW_INFO4_P8 | INDICATION): - case (HW_INFO4_P10 | INDICATION): - FsmEvent(&st->l1.l1m, EV_INFO4_IND, arg); - break; - default: - if (cs->debug) - debugl1(cs, "l1msg %04X unhandled", pr); - break; + switch (pr) { + case (HW_RESET | INDICATION): + FsmEvent(&st->l1.l1m, EV_RESET_IND, arg); + break; + case (HW_DEACTIVATE | CONFIRM): + FsmEvent(&st->l1.l1m, EV_DEACT_CNF, arg); + break; + case (HW_DEACTIVATE | INDICATION): + FsmEvent(&st->l1.l1m, EV_DEACT_IND, arg); + break; + case (HW_POWERUP | CONFIRM): + FsmEvent(&st->l1.l1m, EV_POWER_UP, arg); + break; + case (HW_RSYNC | INDICATION): + FsmEvent(&st->l1.l1m, EV_RSYNC_IND, arg); + break; + case (HW_INFO2 | INDICATION): + FsmEvent(&st->l1.l1m, EV_INFO2_IND, arg); + break; + case (HW_INFO4_P8 | INDICATION): + case (HW_INFO4_P10 | INDICATION): + FsmEvent(&st->l1.l1m, EV_INFO4_IND, arg); + break; + default: + if (cs->debug) + debugl1(cs, "l1msg %04X unhandled", pr); + break; } st = st->next; } @@ -876,13 +876,13 @@ l1_msg(struct IsdnCardState *cs, int pr, void *arg) { void l1_msg_b(struct PStack *st, int pr, void *arg) { - switch(pr) { - case (PH_ACTIVATE | REQUEST): - FsmEvent(&st->l1.l1m, EV_PH_ACTIVATE, NULL); - break; - case (PH_DEACTIVATE | REQUEST): - FsmEvent(&st->l1.l1m, EV_PH_DEACTIVATE, NULL); - break; + switch (pr) { + case (PH_ACTIVATE | REQUEST): + FsmEvent(&st->l1.l1m, EV_PH_ACTIVATE, NULL); + break; + case (PH_DEACTIVATE | REQUEST): + FsmEvent(&st->l1.l1m, EV_PH_DEACTIVATE, NULL); + break; } } diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c index cfff0c41d298..18accb0a79cc 100644 --- a/drivers/isdn/hisax/isdnl2.c +++ b/drivers/isdn/hisax/isdnl2.c @@ -3,7 +3,7 @@ * Author Karsten Keil * based on the teles driver from Jan den Ouden * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -37,7 +37,7 @@ enum { ST_L2_8, }; -#define L2_STATE_COUNT (ST_L2_8+1) +#define L2_STATE_COUNT (ST_L2_8 + 1) static char *strL2State[] = { @@ -76,7 +76,7 @@ enum { EV_L2_FRAME_ERROR, }; -#define L2_EVENT_COUNT (EV_L2_FRAME_ERROR+1) +#define L2_EVENT_COUNT (EV_L2_FRAME_ERROR + 1) static char *strL2Event[] = { @@ -155,7 +155,7 @@ ReleaseWin(struct Layer2 *l2) { int cnt; - if((cnt = freewin1(l2))) + if ((cnt = freewin1(l2))) printk(KERN_WARNING "isdl2 freed %d skbuffs in release\n", cnt); } @@ -164,7 +164,7 @@ cansend(struct PStack *st) { unsigned int p1; - if(test_bit(FLG_MOD128, &st->l2.flag)) + if (test_bit(FLG_MOD128, &st->l2.flag)) p1 = (st->l2.vs - st->l2.va) % 128; else p1 = (st->l2.vs - st->l2.va) % 8; @@ -194,7 +194,7 @@ l2addrsize(struct Layer2 *l2) } static int -sethdraddr(struct Layer2 *l2, u_char * header, int rsp) +sethdraddr(struct Layer2 *l2, u_char *header, int rsp) { u_char *ptr = header; int crbit = rsp; @@ -226,41 +226,41 @@ enqueue_super(struct PStack *st, #define enqueue_ui(a, b) enqueue_super(a, b) static inline int -IsUI(u_char * data) +IsUI(u_char *data) { return ((data[0] & 0xef) == UI); } static inline int -IsUA(u_char * data) +IsUA(u_char *data) { return ((data[0] & 0xef) == UA); } static inline int -IsDM(u_char * data) +IsDM(u_char *data) { return ((data[0] & 0xef) == DM); } static inline int -IsDISC(u_char * data) +IsDISC(u_char *data) { return ((data[0] & 0xef) == DISC); } static inline int -IsSFrame(u_char * data, struct PStack *st) +IsSFrame(u_char *data, struct PStack *st) { register u_char d = *data; - + if (!test_bit(FLG_MOD128, &st->l2.flag)) d &= 0xf; - return(((d & 0xf3) == 1) && ((d & 0x0c) != 0x0c)); + return (((d & 0xf3) == 1) && ((d & 0x0c) != 0x0c)); } static inline int -IsSABME(u_char * data, struct PStack *st) +IsSABME(u_char *data, struct PStack *st) { u_char d = data[0] & ~0x10; @@ -268,19 +268,19 @@ IsSABME(u_char * data, struct PStack *st) } static inline int -IsREJ(u_char * data, struct PStack *st) +IsREJ(u_char *data, struct PStack *st) { return (test_bit(FLG_MOD128, &st->l2.flag) ? data[0] == REJ : (data[0] & 0xf) == REJ); } static inline int -IsFRMR(u_char * data) +IsFRMR(u_char *data) { return ((data[0] & 0xef) == FRMR); } static inline int -IsRNR(u_char * data, struct PStack *st) +IsRNR(u_char *data, struct PStack *st) { return (test_bit(FLG_MOD128, &st->l2.flag) ? data[0] == RNR : (data[0] & 0xf) == RNR); } @@ -368,14 +368,14 @@ FRMR_error(struct PStack *st, struct sk_buff *skb) return 'N'; else l2m_debug(&st->l2.l2m, "FRMR information %2x %2x %2x %2x %2x", - datap[0], datap[1], datap[2], - datap[3], datap[4]); + datap[0], datap[1], datap[2], + datap[3], datap[4]); } else { if (skb->len < headers + 3) return 'N'; else l2m_debug(&st->l2.l2m, "FRMR information %2x %2x %2x", - datap[0], datap[1], datap[2]); + datap[0], datap[1], datap[2]); } return 0; @@ -384,9 +384,9 @@ FRMR_error(struct PStack *st, struct sk_buff *skb) static unsigned int legalnr(struct PStack *st, unsigned int nr) { - struct Layer2 *l2 = &st->l2; + struct Layer2 *l2 = &st->l2; - if(test_bit(FLG_MOD128, &l2->flag)) + if (test_bit(FLG_MOD128, &l2->flag)) return ((nr - l2->va) % 128) <= ((l2->vs - l2->va) % 128); else return ((nr - l2->va) % 8) <= ((l2->vs - l2->va) % 8); @@ -402,7 +402,7 @@ setva(struct PStack *st, unsigned int nr) spin_lock_irqsave(&l2->lock, flags); while (l2->va != nr) { (l2->va)++; - if(test_bit(FLG_MOD128, &l2->flag)) + if (test_bit(FLG_MOD128, &l2->flag)) l2->va %= 128; else l2->va %= 8; @@ -413,7 +413,7 @@ setva(struct PStack *st, unsigned int nr) l2->windowar[l2->sow] = NULL; l2->sow = (l2->sow + 1) % l2->window; spin_unlock_irqrestore(&l2->lock, flags); - if (test_bit(FLG_LLI_L2WAKEUP, &st->lli.flag) && (len >=0)) + if (test_bit(FLG_LLI_L2WAKEUP, &st->lli.flag) && (len >= 0)) lli_writewakeup(st, len); spin_lock_irqsave(&l2->lock, flags); } @@ -438,7 +438,7 @@ send_uframe(struct PStack *st, u_char cmd, u_char cr) } static inline u_char -get_PollFlag(struct PStack * st, struct sk_buff * skb) +get_PollFlag(struct PStack *st, struct sk_buff *skb) { return (skb->data[l2addrsize(&(st->l2))] & 0x10); } @@ -470,29 +470,29 @@ restart_t200(struct PStack *st, int i) static inline void stop_t200(struct PStack *st, int i) { - if(test_and_clear_bit(FLG_T200_RUN, &st->l2.flag)) + if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag)) FsmDelTimer(&st->l2.t200, i); } static inline void st5_dl_release_l2l3(struct PStack *st) { - int pr; + int pr; - if(test_and_clear_bit(FLG_PEND_REL, &st->l2.flag)) - pr = DL_RELEASE | CONFIRM; - else - pr = DL_RELEASE | INDICATION; + if (test_and_clear_bit(FLG_PEND_REL, &st->l2.flag)) + pr = DL_RELEASE | CONFIRM; + else + pr = DL_RELEASE | INDICATION; - st->l2.l2l3(st, pr, NULL); + st->l2.l2l3(st, pr, NULL); } static inline void lapb_dl_release_l2l3(struct PStack *st, int f) { - if (test_bit(FLG_LAPB, &st->l2.flag)) - st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL); - st->l2.l2l3(st, DL_RELEASE | f, NULL); + if (test_bit(FLG_LAPB, &st->l2.flag)) + st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL); + st->l2.l2l3(st, DL_RELEASE | f, NULL); } static void @@ -557,7 +557,7 @@ l2_st8_mdl_error_dm(struct FsmInst *fi, int event, void *arg) static void l2_go_st3(struct FsmInst *fi, int event, void *arg) { - FsmChangeState(fi, ST_L2_3); + FsmChangeState(fi, ST_L2_3); } static void @@ -565,7 +565,7 @@ l2_mdl_assign(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - FsmChangeState(fi, ST_L2_3); + FsmChangeState(fi, ST_L2_3); st->l2.l2tei(st, MDL_ASSIGN | INDICATION, NULL); } @@ -755,7 +755,7 @@ l2_restart_multi(struct FsmInst *fi, int event, void *arg) if (est) st->l2.l2l3(st, DL_ESTABLISH | INDICATION, NULL); - if ((ST_L2_7==state) || (ST_L2_8 == state)) + if ((ST_L2_7 == state) || (ST_L2_8 == state)) if (!skb_queue_empty(&st->l2.i_queue) && cansend(st)) st->l2.l2l1(st, PH_PULL | REQUEST, NULL); } @@ -782,7 +782,7 @@ l2_connected(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; struct sk_buff *skb = arg; - int pr=-1; + int pr = -1; if (!get_PollFlag(st, skb)) { l2_mdl_error_ua(fi, event, arg); @@ -853,7 +853,7 @@ l2_st5_dm_release(struct FsmInst *fi, int event, void *arg) if (get_PollFlagFree(st, skb)) { stop_t200(st, 7); - if (!test_bit(FLG_L3_INIT, &st->l2.flag)) + if (!test_bit(FLG_L3_INIT, &st->l2.flag)) skb_queue_purge(&st->l2.i_queue); if (test_bit(FLG_LAPB, &st->l2.flag)) st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL); @@ -941,7 +941,7 @@ invoke_retransmission(struct PStack *st, unsigned int nr) if (l2->vs != nr) { while (l2->vs != nr) { (l2->vs)--; - if(test_bit(FLG_MOD128, &l2->flag)) { + if (test_bit(FLG_MOD128, &l2->flag)) { l2->vs %= 128; p1 = (l2->vs - l2->va) % 128; } else { @@ -1013,7 +1013,7 @@ l2_st7_got_super(struct FsmInst *fi, int event, void *arg) EV_L2_T203, NULL, 7); } else if ((l2->va != nr) || (typ == RNR)) { setva(st, nr); - if(typ != RR) FsmDelTimer(&st->l2.t203, 9); + if (typ != RR) FsmDelTimer(&st->l2.t203, 9); restart_t200(st, 12); } if (!skb_queue_empty(&st->l2.i_queue) && (typ == RR)) @@ -1080,10 +1080,10 @@ l2_got_iframe(struct FsmInst *fi, int event, void *arg) } if (test_bit(FLG_OWN_BUSY, &l2->flag)) { dev_kfree_skb(skb); - if(PollFlag) enquiry_response(st); + if (PollFlag) enquiry_response(st); } else if (l2->vr == ns) { (l2->vr)++; - if(test_bit(FLG_MOD128, &l2->flag)) + if (test_bit(FLG_MOD128, &l2->flag)) l2->vr %= 128; else l2->vr %= 8; @@ -1150,7 +1150,7 @@ l2_st5_tout_200(struct FsmInst *fi, int event, void *arg) struct PStack *st = fi->userdata; if (test_bit(FLG_LAPD, &st->l2.flag) && - test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { + test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9); } else if (st->l2.rc == st->l2.N200) { FsmChangeState(fi, ST_L2_4); @@ -1174,7 +1174,7 @@ l2_st6_tout_200(struct FsmInst *fi, int event, void *arg) struct PStack *st = fi->userdata; if (test_bit(FLG_LAPD, &st->l2.flag) && - test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { + test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9); } else if (st->l2.rc == st->l2.N200) { FsmChangeState(fi, ST_L2_4); @@ -1195,7 +1195,7 @@ l2_st7_tout_200(struct FsmInst *fi, int event, void *arg) struct PStack *st = fi->userdata; if (test_bit(FLG_LAPD, &st->l2.flag) && - test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { + test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9); return; } @@ -1213,7 +1213,7 @@ l2_st8_tout_200(struct FsmInst *fi, int event, void *arg) struct PStack *st = fi->userdata; if (test_bit(FLG_LAPD, &st->l2.flag) && - test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { + test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9); return; } @@ -1234,7 +1234,7 @@ l2_st7_tout_203(struct FsmInst *fi, int event, void *arg) struct PStack *st = fi->userdata; if (test_bit(FLG_LAPD, &st->l2.flag) && - test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { + test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) { FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 9); return; } @@ -1272,7 +1272,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg) } } spin_lock_irqsave(&l2->lock, flags); - if(test_bit(FLG_MOD128, &l2->flag)) + if (test_bit(FLG_MOD128, &l2->flag)) p1 = (l2->vs - l2->va) % 128; else p1 = (l2->vs - l2->va) % 8; @@ -1445,7 +1445,7 @@ static void l2_st14_persistent_da(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - + skb_queue_purge(&st->l2.i_queue); skb_queue_purge(&st->l2.ui_queue); if (test_and_clear_bit(FLG_ESTAB_PEND, &st->l2.flag)) @@ -1495,7 +1495,7 @@ l2_set_own_busy(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - if(!test_and_set_bit(FLG_OWN_BUSY, &st->l2.flag)) { + if (!test_and_set_bit(FLG_OWN_BUSY, &st->l2.flag)) { enquiry_cr(st, RNR, RSP, 0); test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag); } @@ -1506,7 +1506,7 @@ l2_clear_own_busy(struct FsmInst *fi, int event, void *arg) { struct PStack *st = fi->userdata; - if(!test_and_clear_bit(FLG_OWN_BUSY, &st->l2.flag)) { + if (!test_and_clear_bit(FLG_OWN_BUSY, &st->l2.flag)) { enquiry_cr(st, RR, RSP, 0); test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag); } @@ -1631,76 +1631,76 @@ isdnl2_l1l2(struct PStack *st, int pr, void *arg) int c = 0; switch (pr) { - case (PH_DATA | INDICATION): - datap = skb->data; - len = l2addrsize(&st->l2); - if (skb->len > len) - datap += len; - else { - FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *) 'N'); - dev_kfree_skb(skb); - return; - } - if (!(*datap & 1)) { /* I-Frame */ - if(!(c = iframe_error(st, skb))) - ret = FsmEvent(&st->l2.l2m, EV_L2_I, skb); - } else if (IsSFrame(datap, st)) { /* S-Frame */ - if(!(c = super_error(st, skb))) - ret = FsmEvent(&st->l2.l2m, EV_L2_SUPER, skb); - } else if (IsUI(datap)) { - if(!(c = UI_error(st, skb))) - ret = FsmEvent(&st->l2.l2m, EV_L2_UI, skb); - } else if (IsSABME(datap, st)) { - if(!(c = unnum_error(st, skb, CMD))) - ret = FsmEvent(&st->l2.l2m, EV_L2_SABME, skb); - } else if (IsUA(datap)) { - if(!(c = unnum_error(st, skb, RSP))) - ret = FsmEvent(&st->l2.l2m, EV_L2_UA, skb); - } else if (IsDISC(datap)) { - if(!(c = unnum_error(st, skb, CMD))) - ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, skb); - } else if (IsDM(datap)) { - if(!(c = unnum_error(st, skb, RSP))) - ret = FsmEvent(&st->l2.l2m, EV_L2_DM, skb); - } else if (IsFRMR(datap)) { - if(!(c = FRMR_error(st,skb))) - ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, skb); - } else { - FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *) 'L'); - dev_kfree_skb(skb); - ret = 0; - } - if(c) { - dev_kfree_skb(skb); - FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *)(long)c); - ret = 0; - } - if (ret) - dev_kfree_skb(skb); - break; - case (PH_PULL | CONFIRM): - FsmEvent(&st->l2.l2m, EV_L2_ACK_PULL, arg); - break; - case (PH_PAUSE | INDICATION): - test_and_set_bit(FLG_DCHAN_BUSY, &st->l2.flag); - break; - case (PH_PAUSE | CONFIRM): - test_and_clear_bit(FLG_DCHAN_BUSY, &st->l2.flag); - break; - case (PH_ACTIVATE | CONFIRM): - case (PH_ACTIVATE | INDICATION): - test_and_set_bit(FLG_L1_ACTIV, &st->l2.flag); - if (test_and_clear_bit(FLG_ESTAB_PEND, &st->l2.flag)) - FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH_REQ, arg); - break; - case (PH_DEACTIVATE | INDICATION): - case (PH_DEACTIVATE | CONFIRM): - test_and_clear_bit(FLG_L1_ACTIV, &st->l2.flag); - FsmEvent(&st->l2.l2m, EV_L1_DEACTIVATE, arg); - break; - default: - l2m_debug(&st->l2.l2m, "l2 unknown pr %04x", pr); - break; + case (PH_DATA | INDICATION): + datap = skb->data; + len = l2addrsize(&st->l2); + if (skb->len > len) + datap += len; + else { + FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *) 'N'); + dev_kfree_skb(skb); + return; + } + if (!(*datap & 1)) { /* I-Frame */ + if (!(c = iframe_error(st, skb))) + ret = FsmEvent(&st->l2.l2m, EV_L2_I, skb); + } else if (IsSFrame(datap, st)) { /* S-Frame */ + if (!(c = super_error(st, skb))) + ret = FsmEvent(&st->l2.l2m, EV_L2_SUPER, skb); + } else if (IsUI(datap)) { + if (!(c = UI_error(st, skb))) + ret = FsmEvent(&st->l2.l2m, EV_L2_UI, skb); + } else if (IsSABME(datap, st)) { + if (!(c = unnum_error(st, skb, CMD))) + ret = FsmEvent(&st->l2.l2m, EV_L2_SABME, skb); + } else if (IsUA(datap)) { + if (!(c = unnum_error(st, skb, RSP))) + ret = FsmEvent(&st->l2.l2m, EV_L2_UA, skb); + } else if (IsDISC(datap)) { + if (!(c = unnum_error(st, skb, CMD))) + ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, skb); + } else if (IsDM(datap)) { + if (!(c = unnum_error(st, skb, RSP))) + ret = FsmEvent(&st->l2.l2m, EV_L2_DM, skb); + } else if (IsFRMR(datap)) { + if (!(c = FRMR_error(st, skb))) + ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, skb); + } else { + FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *) 'L'); + dev_kfree_skb(skb); + ret = 0; + } + if (c) { + dev_kfree_skb(skb); + FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *)(long)c); + ret = 0; + } + if (ret) + dev_kfree_skb(skb); + break; + case (PH_PULL | CONFIRM): + FsmEvent(&st->l2.l2m, EV_L2_ACK_PULL, arg); + break; + case (PH_PAUSE | INDICATION): + test_and_set_bit(FLG_DCHAN_BUSY, &st->l2.flag); + break; + case (PH_PAUSE | CONFIRM): + test_and_clear_bit(FLG_DCHAN_BUSY, &st->l2.flag); + break; + case (PH_ACTIVATE | CONFIRM): + case (PH_ACTIVATE | INDICATION): + test_and_set_bit(FLG_L1_ACTIV, &st->l2.flag); + if (test_and_clear_bit(FLG_ESTAB_PEND, &st->l2.flag)) + FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH_REQ, arg); + break; + case (PH_DEACTIVATE | INDICATION): + case (PH_DEACTIVATE | CONFIRM): + test_and_clear_bit(FLG_L1_ACTIV, &st->l2.flag); + FsmEvent(&st->l2.l2m, EV_L1_DEACTIVATE, arg); + break; + default: + l2m_debug(&st->l2.l2m, "l2 unknown pr %04x", pr); + break; } } @@ -1708,45 +1708,45 @@ static void isdnl2_l3l2(struct PStack *st, int pr, void *arg) { switch (pr) { - case (DL_DATA | REQUEST): - if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg)) { - dev_kfree_skb((struct sk_buff *) arg); - } - break; - case (DL_UNIT_DATA | REQUEST): - if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg)) { - dev_kfree_skb((struct sk_buff *) arg); - } - break; - case (DL_ESTABLISH | REQUEST): - if (test_bit(FLG_L1_ACTIV, &st->l2.flag)) { - if (test_bit(FLG_LAPD, &st->l2.flag) || - test_bit(FLG_ORIG, &st->l2.flag)) { - FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH_REQ, arg); - } - } else { - if (test_bit(FLG_LAPD, &st->l2.flag) || - test_bit(FLG_ORIG, &st->l2.flag)) { - test_and_set_bit(FLG_ESTAB_PEND, &st->l2.flag); - } - st->l2.l2l1(st, PH_ACTIVATE, NULL); + case (DL_DATA | REQUEST): + if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg)) { + dev_kfree_skb((struct sk_buff *) arg); + } + break; + case (DL_UNIT_DATA | REQUEST): + if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg)) { + dev_kfree_skb((struct sk_buff *) arg); + } + break; + case (DL_ESTABLISH | REQUEST): + if (test_bit(FLG_L1_ACTIV, &st->l2.flag)) { + if (test_bit(FLG_LAPD, &st->l2.flag) || + test_bit(FLG_ORIG, &st->l2.flag)) { + FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH_REQ, arg); } - break; - case (DL_RELEASE | REQUEST): - if (test_bit(FLG_LAPB, &st->l2.flag)) { - st->l2.l2l1(st, PH_DEACTIVATE, NULL); + } else { + if (test_bit(FLG_LAPD, &st->l2.flag) || + test_bit(FLG_ORIG, &st->l2.flag)) { + test_and_set_bit(FLG_ESTAB_PEND, &st->l2.flag); } - FsmEvent(&st->l2.l2m, EV_L2_DL_RELEASE_REQ, arg); - break; - case (MDL_ASSIGN | REQUEST): - FsmEvent(&st->l2.l2m, EV_L2_MDL_ASSIGN, arg); - break; - case (MDL_REMOVE | REQUEST): - FsmEvent(&st->l2.l2m, EV_L2_MDL_REMOVE, arg); - break; - case (MDL_ERROR | RESPONSE): - FsmEvent(&st->l2.l2m, EV_L2_MDL_ERROR, arg); - break; + st->l2.l2l1(st, PH_ACTIVATE, NULL); + } + break; + case (DL_RELEASE | REQUEST): + if (test_bit(FLG_LAPB, &st->l2.flag)) { + st->l2.l2l1(st, PH_DEACTIVATE, NULL); + } + FsmEvent(&st->l2.l2m, EV_L2_DL_RELEASE_REQ, arg); + break; + case (MDL_ASSIGN | REQUEST): + FsmEvent(&st->l2.l2m, EV_L2_MDL_ASSIGN, arg); + break; + case (MDL_REMOVE | REQUEST): + FsmEvent(&st->l2.l2m, EV_L2_MDL_REMOVE, arg); + break; + case (MDL_ERROR | RESPONSE): + FsmEvent(&st->l2.l2m, EV_L2_MDL_ERROR, arg); + break; } } @@ -1787,7 +1787,7 @@ setstack_isdnl2(struct PStack *st, char *debug_id) if (test_bit(FLG_LAPB, &st->l2.flag)) st->l2.l2m.state = ST_L2_4; else - st->l2.l2m.state = ST_L2_1; + st->l2.l2m.state = ST_L2_1; st->l2.l2m.debug = 0; st->l2.l2m.userdata = st; st->l2.l2m.userint = 0; @@ -1802,16 +1802,16 @@ static void transl2_l3l2(struct PStack *st, int pr, void *arg) { switch (pr) { - case (DL_DATA | REQUEST): - case (DL_UNIT_DATA | REQUEST): - st->l2.l2l1(st, PH_DATA | REQUEST, arg); - break; - case (DL_ESTABLISH | REQUEST): - st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL); - break; - case (DL_RELEASE | REQUEST): - st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL); - break; + case (DL_DATA | REQUEST): + case (DL_UNIT_DATA | REQUEST): + st->l2.l2l1(st, PH_DATA | REQUEST, arg); + break; + case (DL_ESTABLISH | REQUEST): + st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL); + break; + case (DL_RELEASE | REQUEST): + st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL); + break; } } diff --git a/drivers/isdn/hisax/isdnl2.h b/drivers/isdn/hisax/isdnl2.h index 0cdab1b73fac..7e447fb8ed1d 100644 --- a/drivers/isdn/hisax/isdnl2.h +++ b/drivers/isdn/hisax/isdnl2.h @@ -23,4 +23,3 @@ #define RSP 1 #define LC_FLUSH_WAIT 1 - diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c index 1c24e4457b6f..45b03840f716 100644 --- a/drivers/isdn/hisax/isdnl3.c +++ b/drivers/isdn/hisax/isdnl3.c @@ -3,7 +3,7 @@ * Author Karsten Keil * based on the teles driver from Jan den Ouden * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -27,12 +27,12 @@ static struct Fsm l3fsm; enum { ST_L3_LC_REL, ST_L3_LC_ESTAB_WAIT, - ST_L3_LC_REL_DELAY, + ST_L3_LC_REL_DELAY, ST_L3_LC_REL_WAIT, ST_L3_LC_ESTAB, }; -#define L3_STATE_COUNT (ST_L3_LC_ESTAB+1) +#define L3_STATE_COUNT (ST_L3_LC_ESTAB + 1) static char *strL3State[] = { @@ -53,7 +53,7 @@ enum { EV_TIMEOUT, }; -#define L3_EVENT_COUNT (EV_TIMEOUT+1) +#define L3_EVENT_COUNT (EV_TIMEOUT + 1) static char *strL3Event[] = { @@ -67,7 +67,7 @@ static char *strL3Event[] = }; static __printf(2, 3) void -l3m_debug(struct FsmInst *fi, char *fmt, ...) + l3m_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; struct PStack *st = fi->userdata; @@ -78,7 +78,7 @@ l3m_debug(struct FsmInst *fi, char *fmt, ...) } u_char * -findie(u_char * p, int size, u_char ie, int wanted_set) +findie(u_char *p, int size, u_char ie, int wanted_set) { int l, codeset, maincodeset; u_char *pend = p + size; @@ -102,14 +102,14 @@ findie(u_char * p, int size, u_char ie, int wanted_set) else { if (codeset == wanted_set) { if (*p == ie) - { /* improved length check (Werner Cornelius) */ - if ((pend - p) < 2) - return(NULL); - if (*(p+1) > (pend - (p+2))) - return(NULL); - return (p); - } - + { /* improved length check (Werner Cornelius) */ + if ((pend - p) < 2) + return (NULL); + if (*(p + 1) > (pend - (p + 2))) + return (NULL); + return (p); + } + if (*p > ie) return (NULL); } @@ -123,16 +123,16 @@ findie(u_char * p, int size, u_char ie, int wanted_set) } int -getcallref(u_char * p) +getcallref(u_char *p) { int l, cr = 0; p++; /* prot discr */ if (*p & 0xfe) /* wrong callref BRI only 1 octet*/ - return(-2); + return (-2); l = 0xf & *p++; /* callref length */ if (!l) /* dummy CallRef */ - return(-1); + return (-1); cr = *p++; return (cr); } @@ -153,7 +153,7 @@ void newl3state(struct l3_process *pc, int state) { if (pc->debug & L3_DEB_STATE) - l3_debug(pc->st, "newstate cr %d %d --> %d", + l3_debug(pc->st, "newstate cr %d %d --> %d", pc->callref & 0x7F, pc->state, state); pc->state = state; @@ -228,8 +228,8 @@ no_l3_proto(struct PStack *st, int pr, void *arg) static int no_l3_proto_spec(struct PStack *st, isdn_ctrl *ic) { - printk(KERN_WARNING "HiSax: no specific protocol handler for proto %lu\n",ic->arg & 0xFF); - return(-1); + printk(KERN_WARNING "HiSax: no specific protocol handler for proto %lu\n", ic->arg & 0xFF); + return (-1); } struct l3_process @@ -287,7 +287,7 @@ release_l3_process(struct l3_process *p) if (pp) pp->next = np->next; else if (!(p->st->l3.proc = np->next) && - !test_bit(FLG_PTP, &p->st->l2.flag)) { + !test_bit(FLG_PTP, &p->st->l2.flag)) { if (p->debug) l3_debug(p->st, "release_l3_process: last process"); if (skb_queue_empty(&p->st->l3.squeue)) { @@ -301,7 +301,7 @@ release_l3_process(struct l3_process *p) if (p->debug) l3_debug(p->st, "release_l3_process: not release link"); } - } + } kfree(p); return; } @@ -340,42 +340,42 @@ setstack_l3dc(struct PStack *st, struct Channel *chanp) st->l3.l3m.userdata = st; st->l3.l3m.userint = 0; st->l3.l3m.printdebug = l3m_debug; - FsmInitTimer(&st->l3.l3m, &st->l3.l3m_timer); + FsmInitTimer(&st->l3.l3m, &st->l3.l3m_timer); strcpy(st->l3.debug_id, "L3DC "); st->lli.l4l3_proto = no_l3_proto_spec; -#ifdef CONFIG_HISAX_EURO +#ifdef CONFIG_HISAX_EURO if (st->protocol == ISDN_PTYPE_EURO) { setstack_dss1(st); } else #endif -#ifdef CONFIG_HISAX_NI1 - if (st->protocol == ISDN_PTYPE_NI1) { - setstack_ni1(st); - } else +#ifdef CONFIG_HISAX_NI1 + if (st->protocol == ISDN_PTYPE_NI1) { + setstack_ni1(st); + } else #endif -#ifdef CONFIG_HISAX_1TR6 - if (st->protocol == ISDN_PTYPE_1TR6) { - setstack_1tr6(st); - } else +#ifdef CONFIG_HISAX_1TR6 + if (st->protocol == ISDN_PTYPE_1TR6) { + setstack_1tr6(st); + } else #endif - if (st->protocol == ISDN_PTYPE_LEASED) { - st->lli.l4l3 = no_l3_proto; - st->l2.l2l3 = no_l3_proto; - st->l3.l3ml3 = no_l3_proto; - printk(KERN_INFO "HiSax: Leased line mode\n"); - } else { - st->lli.l4l3 = no_l3_proto; - st->l2.l2l3 = no_l3_proto; - st->l3.l3ml3 = no_l3_proto; - sprintf(tmp, "protocol %s not supported", - (st->protocol == ISDN_PTYPE_1TR6) ? "1tr6" : - (st->protocol == ISDN_PTYPE_EURO) ? "euro" : - (st->protocol == ISDN_PTYPE_NI1) ? "ni1" : - "unknown"); - printk(KERN_WARNING "HiSax: %s\n", tmp); - st->protocol = -1; - } + if (st->protocol == ISDN_PTYPE_LEASED) { + st->lli.l4l3 = no_l3_proto; + st->l2.l2l3 = no_l3_proto; + st->l3.l3ml3 = no_l3_proto; + printk(KERN_INFO "HiSax: Leased line mode\n"); + } else { + st->lli.l4l3 = no_l3_proto; + st->l2.l2l3 = no_l3_proto; + st->l3.l3ml3 = no_l3_proto; + sprintf(tmp, "protocol %s not supported", + (st->protocol == ISDN_PTYPE_1TR6) ? "1tr6" : + (st->protocol == ISDN_PTYPE_EURO) ? "euro" : + (st->protocol == ISDN_PTYPE_NI1) ? "ni1" : + "unknown"); + printk(KERN_WARNING "HiSax: %s\n", tmp); + st->protocol = -1; + } } static void @@ -469,22 +469,22 @@ lc_connected(struct FsmInst *fi, int event, void *arg) static void lc_start_delay(struct FsmInst *fi, int event, void *arg) { - struct PStack *st = fi->userdata; + struct PStack *st = fi->userdata; - FsmChangeState(fi, ST_L3_LC_REL_DELAY); - FsmAddTimer(&st->l3.l3m_timer, DREL_TIMER_VALUE, EV_TIMEOUT, NULL, 50); + FsmChangeState(fi, ST_L3_LC_REL_DELAY); + FsmAddTimer(&st->l3.l3m_timer, DREL_TIMER_VALUE, EV_TIMEOUT, NULL, 50); } static void lc_start_delay_check(struct FsmInst *fi, int event, void *arg) /* 20/09/00 - GE timer not user for NI-1 as layer 2 should stay up */ { - struct PStack *st = fi->userdata; + struct PStack *st = fi->userdata; - FsmChangeState(fi, ST_L3_LC_REL_DELAY); - /* 19/09/00 - GE timer not user for NI-1 */ - if (st->protocol != ISDN_PTYPE_NI1) - FsmAddTimer(&st->l3.l3m_timer, DREL_TIMER_VALUE, EV_TIMEOUT, NULL, 50); + FsmChangeState(fi, ST_L3_LC_REL_DELAY); + /* 19/09/00 - GE timer not user for NI-1 */ + if (st->protocol != ISDN_PTYPE_NI1) + FsmAddTimer(&st->l3.l3m_timer, DREL_TIMER_VALUE, EV_TIMEOUT, NULL, 50); } static void @@ -536,9 +536,9 @@ static struct FsmNode L3FnList[] __initdata = {ST_L3_LC_ESTAB_WAIT, EV_RELEASE_IND, lc_release_ind}, {ST_L3_LC_ESTAB, EV_RELEASE_IND, lc_release_ind}, {ST_L3_LC_ESTAB, EV_RELEASE_REQ, lc_start_delay_check}, - {ST_L3_LC_REL_DELAY, EV_RELEASE_IND, lc_release_ind}, - {ST_L3_LC_REL_DELAY, EV_ESTABLISH_REQ, lc_connected}, - {ST_L3_LC_REL_DELAY, EV_TIMEOUT, lc_release_req}, + {ST_L3_LC_REL_DELAY, EV_RELEASE_IND, lc_release_ind}, + {ST_L3_LC_REL_DELAY, EV_ESTABLISH_REQ, lc_connected}, + {ST_L3_LC_REL_DELAY, EV_TIMEOUT, lc_release_req}, {ST_L3_LC_REL_WAIT, EV_RELEASE_CNF, lc_release_cnf}, {ST_L3_LC_REL_WAIT, EV_ESTABLISH_REQ, lc_activate}, }; @@ -548,34 +548,34 @@ void l3_msg(struct PStack *st, int pr, void *arg) { switch (pr) { - case (DL_DATA | REQUEST): - if (st->l3.l3m.state == ST_L3_LC_ESTAB) { - st->l3.l3l2(st, pr, arg); - } else { - struct sk_buff *skb = arg; - - skb_queue_tail(&st->l3.squeue, skb); - FsmEvent(&st->l3.l3m, EV_ESTABLISH_REQ, NULL); - } - break; - case (DL_ESTABLISH | REQUEST): + case (DL_DATA | REQUEST): + if (st->l3.l3m.state == ST_L3_LC_ESTAB) { + st->l3.l3l2(st, pr, arg); + } else { + struct sk_buff *skb = arg; + + skb_queue_tail(&st->l3.squeue, skb); FsmEvent(&st->l3.l3m, EV_ESTABLISH_REQ, NULL); - break; - case (DL_ESTABLISH | CONFIRM): - FsmEvent(&st->l3.l3m, EV_ESTABLISH_CNF, NULL); - break; - case (DL_ESTABLISH | INDICATION): - FsmEvent(&st->l3.l3m, EV_ESTABLISH_IND, NULL); - break; - case (DL_RELEASE | INDICATION): - FsmEvent(&st->l3.l3m, EV_RELEASE_IND, NULL); - break; - case (DL_RELEASE | CONFIRM): - FsmEvent(&st->l3.l3m, EV_RELEASE_CNF, NULL); - break; - case (DL_RELEASE | REQUEST): - FsmEvent(&st->l3.l3m, EV_RELEASE_REQ, NULL); - break; + } + break; + case (DL_ESTABLISH | REQUEST): + FsmEvent(&st->l3.l3m, EV_ESTABLISH_REQ, NULL); + break; + case (DL_ESTABLISH | CONFIRM): + FsmEvent(&st->l3.l3m, EV_ESTABLISH_CNF, NULL); + break; + case (DL_ESTABLISH | INDICATION): + FsmEvent(&st->l3.l3m, EV_ESTABLISH_IND, NULL); + break; + case (DL_RELEASE | INDICATION): + FsmEvent(&st->l3.l3m, EV_RELEASE_IND, NULL); + break; + case (DL_RELEASE | CONFIRM): + FsmEvent(&st->l3.l3m, EV_RELEASE_CNF, NULL); + break; + case (DL_RELEASE | REQUEST): + FsmEvent(&st->l3.l3m, EV_RELEASE_REQ, NULL); + break; } } diff --git a/drivers/isdn/hisax/isdnl3.h b/drivers/isdn/hisax/isdnl3.h index 749498fe6c4b..0edc99d40dc2 100644 --- a/drivers/isdn/hisax/isdnl3.h +++ b/drivers/isdn/hisax/isdnl3.h @@ -5,7 +5,7 @@ * */ -#define SBIT(state) (1< - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -19,7 +19,7 @@ static const char *ISurf_revision = "$Revision: 1.12.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define ISURF_ISAR_RESET 1 @@ -46,7 +46,7 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { register int i; for (i = 0; i < size; i++) @@ -54,11 +54,11 @@ ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { register int i; - for (i = 0; i < size; i++){ - writeb(data[i], cs->hw.isurf.isac);mb(); + for (i = 0; i < size; i++) { + writeb(data[i], cs->hw.isurf.isac); mb(); } } @@ -67,17 +67,17 @@ WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) * mode = 1 access with IRQ off * mode = 2 access with IRQ off and using last offset */ - + static u_char ReadISAR(struct IsdnCardState *cs, int mode, u_char offset) -{ - return(readb(cs->hw.isurf.isar + offset)); +{ + return (readb(cs->hw.isurf.isar + offset)); } static void WriteISAR(struct IsdnCardState *cs, int mode, u_char offset, u_char value) { - writeb(value, cs->hw.isurf.isar + offset);mb(); + writeb(value, cs->hw.isurf.isar + offset); mb(); } static irqreturn_t @@ -90,11 +90,11 @@ isurf_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readb(cs->hw.isurf.isar + ISAR_IRQBIT); - Start_ISAR: +Start_ISAR: if (val & ISAR_IRQSTA) isar_int_main(cs); val = readb(cs->hw.isurf.isac + ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readb(cs->hw.isurf.isar + ISAR_IRQBIT); @@ -113,8 +113,8 @@ isurf_interrupt(int intno, void *dev_id) printk(KERN_WARNING "ISurf IRQ LOOP\n"); writeb(0, cs->hw.isurf.isar + ISAR_IRQBIT); mb(); - writeb(0xFF, cs->hw.isurf.isac + ISAC_MASK);mb(); - writeb(0, cs->hw.isurf.isac + ISAC_MASK);mb(); + writeb(0xFF, cs->hw.isurf.isac + ISAC_MASK); mb(); + writeb(0, cs->hw.isurf.isac + ISAC_MASK); mb(); writeb(ISAR_IRQMSK, cs->hw.isurf.isar + ISAR_IRQBIT); mb(); spin_unlock_irqrestore(&cs->lock, flags); return IRQ_HANDLED; @@ -145,31 +145,31 @@ ISurf_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_isurf(cs, ISURF_RESET); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_isurf(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - reset_isurf(cs, ISURF_RESET); - clear_pending_isac_ints(cs); - writeb(0, cs->hw.isurf.isar+ISAR_IRQBIT);mb(); - initisac(cs); - initisar(cs); - /* Reenable ISAC IRQ */ - cs->writeisac(cs, ISAC_MASK, 0); - /* RESET Receiver and Transmitter */ - cs->writeisac(cs, ISAC_CMDR, 0x41); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_isurf(cs, ISURF_RESET); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_isurf(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + reset_isurf(cs, ISURF_RESET); + clear_pending_isac_ints(cs); + writeb(0, cs->hw.isurf.isar + ISAR_IRQBIT); mb(); + initisac(cs); + initisar(cs); + /* Reenable ISAC IRQ */ + cs->writeisac(cs, ISAC_MASK, 0); + /* RESET Receiver and Transmitter */ + cs->writeisac(cs, ISAC_CMDR, 0x41); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } static int @@ -182,15 +182,15 @@ isurf_auxcmd(struct IsdnCardState *cs, isdn_ctrl *ic) { spin_lock_irqsave(&cs->lock, flags); if (!ret) { reset_isurf(cs, ISURF_ISAR_EA | ISURF_ISAC_RESET | - ISURF_ARCOFI_RESET); + ISURF_ARCOFI_RESET); initisac(cs); cs->writeisac(cs, ISAC_MASK, 0); cs->writeisac(cs, ISAC_CMDR, 0x41); } spin_unlock_irqrestore(&cs->lock, flags); - return(ret); + return (ret); } - return(isar_auxcmd(cs, ic)); + return (isar_auxcmd(cs, ic)); } #ifdef __ISAPNP__ @@ -206,9 +206,9 @@ setup_isurf(struct IsdnCard *card) strcpy(tmp, ISurf_revision); printk(KERN_INFO "HiSax: ISurf driver Rev. %s\n", HiSax_getrev(tmp)); - - if (cs->typ != ISDN_CTYPE_ISURF) - return(0); + + if (cs->typ != ISDN_CTYPE_ISURF) + return (0); if (card->para[1] && card->para[2]) { cs->hw.isurf.reset = card->para[1]; cs->hw.isurf.phymem = card->para[2]; @@ -221,11 +221,11 @@ setup_isurf(struct IsdnCard *card) cs->subtyp = 0; if ((pnp_c = pnp_find_card( - ISAPNP_VENDOR('S', 'I', 'E'), - ISAPNP_FUNCTION(0x0010), pnp_c))) { + ISAPNP_VENDOR('S', 'I', 'E'), + ISAPNP_FUNCTION(0x0010), pnp_c))) { if (!(pnp_d = pnp_find_dev(pnp_c, - ISAPNP_VENDOR('S', 'I', 'E'), - ISAPNP_FUNCTION(0x0010), pnp_d))) { + ISAPNP_VENDOR('S', 'I', 'E'), + ISAPNP_FUNCTION(0x0010), pnp_d))) { printk(KERN_ERR "ISurfPnP: PnP error card found, no device\n"); return (0); } @@ -236,17 +236,17 @@ setup_isurf(struct IsdnCard *card) cs->irq = pnp_irq(pnp_d, 0); if (!cs->irq || !cs->hw.isurf.reset || !cs->hw.isurf.phymem) { printk(KERN_ERR "ISurfPnP:some resources are missing %d/%x/%lx\n", - cs->irq, cs->hw.isurf.reset, cs->hw.isurf.phymem); + cs->irq, cs->hw.isurf.reset, cs->hw.isurf.phymem); pnp_disable_dev(pnp_d); - return(0); + return (0); } } else { printk(KERN_INFO "ISurfPnP: no ISAPnP card found\n"); - return(0); + return (0); } } else { printk(KERN_INFO "ISurfPnP: no ISAPnP bus found\n"); - return(0); + return (0); } #else printk(KERN_WARNING "HiSax: Siemens I-Surf port/mem not set\n"); @@ -255,15 +255,15 @@ setup_isurf(struct IsdnCard *card) } if (!request_region(cs->hw.isurf.reset, 1, "isurf isdn")) { printk(KERN_WARNING - "HiSax: Siemens I-Surf config port %x already in use\n", - cs->hw.isurf.reset); - return (0); + "HiSax: Siemens I-Surf config port %x already in use\n", + cs->hw.isurf.reset); + return (0); } if (!request_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE, "isurf iomem")) { printk(KERN_WARNING "HiSax: Siemens I-Surf memory region " - "%lx-%lx already in use\n", - cs->hw.isurf.phymem, - cs->hw.isurf.phymem + ISURF_IOMEM_SIZE); + "%lx-%lx already in use\n", + cs->hw.isurf.phymem, + cs->hw.isurf.phymem + ISURF_IOMEM_SIZE); release_region(cs->hw.isurf.reset, 1); return (0); } @@ -293,7 +293,7 @@ setup_isurf(struct IsdnCard *card) ver = ISARVersion(cs, "ISurf:"); if (ver < 0) { printk(KERN_WARNING - "ISurf: wrong ISAR version (ret = %d)\n", ver); + "ISurf: wrong ISAR version (ret = %d)\n", ver); release_io_isurf(cs); return (0); } diff --git a/drivers/isdn/hisax/ix1_micro.c b/drivers/isdn/hisax/ix1_micro.c index a92bf0d2cab2..5f299f82b801 100644 --- a/drivers/isdn/hisax/ix1_micro.c +++ b/drivers/isdn/hisax/ix1_micro.c @@ -7,7 +7,7 @@ * Copyright by Klaus-Peter Nischke, ITK AG * * by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -26,7 +26,7 @@ static const char *ix1_revision = "$Revision: 2.12.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define SPECIAL_PORT_OFFSET 3 @@ -49,7 +49,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -64,7 +64,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -85,13 +85,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, 0, data, size); } @@ -110,16 +110,16 @@ WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) cs->hw.ix1.hscx, offset + (hscx ? 0x40 : 0), value); } -#define READHSCX(cs, nr, reg) readreg(cs->hw.ix1.hscx_ale, \ - cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ix1.hscx_ale, \ - cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.ix1.hscx_ale, \ + cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ix1.hscx_ale, \ + cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ix1.hscx_ale, \ - cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ix1.hscx_ale, \ + cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ix1.hscx_ale, \ - cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ix1.hscx_ale, \ + cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -132,11 +132,11 @@ ix1micro_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_ISTA + 0x40); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_ISTA + 0x40); @@ -188,33 +188,33 @@ ix1_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - ix1_reset(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_ix1micro(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - ix1_reset(cs); - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + ix1_reset(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_ix1micro(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + ix1_reset(cs); + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } #ifdef __ISAPNP__ static struct isapnp_device_id itk_ids[] __devinitdata = { { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), - ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), + ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25), (unsigned long) "ITK micro 2" }, { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29), - ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29), + ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29), (unsigned long) "ITK micro 2." }, { 0, } }; @@ -238,30 +238,30 @@ setup_ix1micro(struct IsdnCard *card) #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "ITK PnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); + card->para[0], card->para[1]); pnp_disable_dev(pnp_d); - return(0); + return (0); } break; } else { @@ -270,10 +270,10 @@ setup_ix1micro(struct IsdnCard *card) } ipid++; pnp_c = NULL; - } + } if (!ipid->card_vendor) { printk(KERN_INFO "ITK PnP: no ISAPnP card found\n"); - return(0); + return (0); } } #endif @@ -287,15 +287,15 @@ setup_ix1micro(struct IsdnCard *card) if (cs->hw.ix1.cfg_reg) { if (!request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg")) { printk(KERN_WARNING - "HiSax: ITK ix1-micro Rev.2 config port " - "%x-%x already in use\n", + "HiSax: ITK ix1-micro Rev.2 config port " + "%x-%x already in use\n", cs->hw.ix1.cfg_reg, cs->hw.ix1.cfg_reg + 4); return (0); } } printk(KERN_INFO "HiSax: ITK ix1-micro Rev.2 config irq:%d io:0x%X\n", - cs->irq, cs->hw.ix1.cfg_reg); + cs->irq, cs->hw.ix1.cfg_reg); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; @@ -309,7 +309,7 @@ setup_ix1micro(struct IsdnCard *card) ISACVersion(cs, "ix1-Micro:"); if (HscxVersion(cs, "ix1-Micro:")) { printk(KERN_WARNING - "ix1-Micro: wrong HSCX versions check IO address\n"); + "ix1-Micro: wrong HSCX versions check IO address\n"); release_io_ix1micro(cs); return (0); } diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c index a06cea09158b..f946c58d8ab1 100644 --- a/drivers/isdn/hisax/jade.c +++ b/drivers/isdn/hisax/jade.c @@ -4,7 +4,7 @@ * * Author Roland Klabunde * Copyright by Roland Klabunde - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -23,53 +23,53 @@ int JadeVersion(struct IsdnCardState *cs, char *s) { - int ver; - int to = 50; - cs->BC_Write_Reg(cs, -1, 0x50, 0x19); - while (to) { - udelay(1); + int ver; + int to = 50; + cs->BC_Write_Reg(cs, -1, 0x50, 0x19); + while (to) { + udelay(1); + ver = cs->BC_Read_Reg(cs, -1, 0x60); + to--; + if (ver) + break; + if (!to) { + printk(KERN_INFO "%s JADE version not obtainable\n", s); + return (0); + } + } + /* Wait for the JADE */ + udelay(10); + /* Read version */ ver = cs->BC_Read_Reg(cs, -1, 0x60); - to--; - if (ver) - break; - if (!to) { - printk(KERN_INFO "%s JADE version not obtainable\n", s); - return (0); - } - } - /* Wait for the JADE */ - udelay(10); - /* Read version */ - ver = cs->BC_Read_Reg(cs, -1, 0x60); - printk(KERN_INFO "%s JADE version: %d\n", s, ver); - return (1); + printk(KERN_INFO "%s JADE version: %d\n", s, ver); + return (1); } /* Write to indirect accessible jade register set */ static void jade_write_indirect(struct IsdnCardState *cs, u_char reg, u_char value) { - int to = 50; - u_char ret; + int to = 50; + u_char ret; - /* Write the data */ - cs->BC_Write_Reg(cs, -1, COMM_JADE+1, value); - /* Say JADE we wanna write indirect reg 'reg' */ - cs->BC_Write_Reg(cs, -1, COMM_JADE, reg); - to = 50; - /* Wait for RDY goes high */ - while (to) { - udelay(1); - ret = cs->BC_Read_Reg(cs, -1, COMM_JADE); - to--; - if (ret & 1) - /* Got acknowledge */ - break; - if (!to) { - printk(KERN_INFO "Can not see ready bit from JADE DSP (reg=0x%X, value=0x%X)\n", reg, value); - return; + /* Write the data */ + cs->BC_Write_Reg(cs, -1, COMM_JADE + 1, value); + /* Say JADE we wanna write indirect reg 'reg' */ + cs->BC_Write_Reg(cs, -1, COMM_JADE, reg); + to = 50; + /* Wait for RDY goes high */ + while (to) { + udelay(1); + ret = cs->BC_Read_Reg(cs, -1, COMM_JADE); + to--; + if (ret & 1) + /* Got acknowledge */ + break; + if (!to) { + printk(KERN_INFO "Can not see ready bit from JADE DSP (reg=0x%X, value=0x%X)\n", reg, value); + return; + } } - } } @@ -77,67 +77,67 @@ jade_write_indirect(struct IsdnCardState *cs, u_char reg, u_char value) static void modejade(struct BCState *bcs, int mode, int bc) { - struct IsdnCardState *cs = bcs->cs; - int jade = bcs->hw.hscx.hscx; + struct IsdnCardState *cs = bcs->cs; + int jade = bcs->hw.hscx.hscx; - if (cs->debug & L1_DEB_HSCX) { - char tmp[40]; - sprintf(tmp, "jade %c mode %d ichan %d", - 'A' + jade, mode, bc); - debugl1(cs, tmp); - } - bcs->mode = mode; - bcs->channel = bc; - - cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (mode == L1_MODE_TRANS ? jadeMODE_TMO:0x00)); - cs->BC_Write_Reg(cs, jade, jade_HDLC_CCR0, (jadeCCR0_PU|jadeCCR0_ITF)); - cs->BC_Write_Reg(cs, jade, jade_HDLC_CCR1, 0x00); + if (cs->debug & L1_DEB_HSCX) { + char tmp[40]; + sprintf(tmp, "jade %c mode %d ichan %d", + 'A' + jade, mode, bc); + debugl1(cs, tmp); + } + bcs->mode = mode; + bcs->channel = bc; - jade_write_indirect(cs, jade_HDLC1SERRXPATH, 0x08); - jade_write_indirect(cs, jade_HDLC2SERRXPATH, 0x08); - jade_write_indirect(cs, jade_HDLC1SERTXPATH, 0x00); - jade_write_indirect(cs, jade_HDLC2SERTXPATH, 0x00); + cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (mode == L1_MODE_TRANS ? jadeMODE_TMO : 0x00)); + cs->BC_Write_Reg(cs, jade, jade_HDLC_CCR0, (jadeCCR0_PU | jadeCCR0_ITF)); + cs->BC_Write_Reg(cs, jade, jade_HDLC_CCR1, 0x00); - cs->BC_Write_Reg(cs, jade, jade_HDLC_XCCR, 0x07); - cs->BC_Write_Reg(cs, jade, jade_HDLC_RCCR, 0x07); + jade_write_indirect(cs, jade_HDLC1SERRXPATH, 0x08); + jade_write_indirect(cs, jade_HDLC2SERRXPATH, 0x08); + jade_write_indirect(cs, jade_HDLC1SERTXPATH, 0x00); + jade_write_indirect(cs, jade_HDLC2SERTXPATH, 0x00); - if (bc == 0) { - cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAX, 0x00); - cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAR, 0x00); - } else { - cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAX, 0x04); - cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAR, 0x04); - } - switch (mode) { + cs->BC_Write_Reg(cs, jade, jade_HDLC_XCCR, 0x07); + cs->BC_Write_Reg(cs, jade, jade_HDLC_RCCR, 0x07); + + if (bc == 0) { + cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAX, 0x00); + cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAR, 0x00); + } else { + cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAX, 0x04); + cs->BC_Write_Reg(cs, jade, jade_HDLC_TSAR, 0x04); + } + switch (mode) { case (L1_MODE_NULL): cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, jadeMODE_TMO); break; case (L1_MODE_TRANS): - cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (jadeMODE_TMO|jadeMODE_RAC|jadeMODE_XAC)); + cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (jadeMODE_TMO | jadeMODE_RAC | jadeMODE_XAC)); break; case (L1_MODE_HDLC): - cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (jadeMODE_RAC|jadeMODE_XAC)); + cs->BC_Write_Reg(cs, jade, jade_HDLC_MODE, (jadeMODE_RAC | jadeMODE_XAC)); break; - } - if (mode) { - cs->BC_Write_Reg(cs, jade, jade_HDLC_RCMD, (jadeRCMD_RRES|jadeRCMD_RMC)); - cs->BC_Write_Reg(cs, jade, jade_HDLC_XCMD, jadeXCMD_XRES); - /* Unmask ints */ - cs->BC_Write_Reg(cs, jade, jade_HDLC_IMR, 0xF8); - } - else - /* Mask ints */ - cs->BC_Write_Reg(cs, jade, jade_HDLC_IMR, 0x00); + } + if (mode) { + cs->BC_Write_Reg(cs, jade, jade_HDLC_RCMD, (jadeRCMD_RRES | jadeRCMD_RMC)); + cs->BC_Write_Reg(cs, jade, jade_HDLC_XCMD, jadeXCMD_XRES); + /* Unmask ints */ + cs->BC_Write_Reg(cs, jade, jade_HDLC_IMR, 0xF8); + } + else + /* Mask ints */ + cs->BC_Write_Reg(cs, jade, jade_HDLC_IMR, 0x00); } static void jade_l2l1(struct PStack *st, int pr, void *arg) { - struct BCState *bcs = st->l1.bcs; - struct sk_buff *skb = arg; - u_long flags; + struct BCState *bcs = st->l1.bcs; + struct sk_buff *skb = arg; + u_long flags; - switch (pr) { + switch (pr) { case (PH_DATA | REQUEST): spin_lock_irqsave(&bcs->cs->lock, flags); if (bcs->tx_skb) { @@ -164,10 +164,10 @@ jade_l2l1(struct PStack *st, int pr, void *arg) break; case (PH_PULL | REQUEST): if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); break; case (PH_ACTIVATE | REQUEST): spin_lock_irqsave(&bcs->cs->lock, flags); @@ -187,26 +187,26 @@ jade_l2l1(struct PStack *st, int pr, void *arg) spin_unlock_irqrestore(&bcs->cs->lock, flags); st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); break; - } + } } static void close_jadestate(struct BCState *bcs) { - modejade(bcs, 0, bcs->channel); - if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { - kfree(bcs->hw.hscx.rcvbuf); - bcs->hw.hscx.rcvbuf = NULL; - kfree(bcs->blog); - bcs->blog = NULL; - skb_queue_purge(&bcs->rqueue); - skb_queue_purge(&bcs->squeue); - if (bcs->tx_skb) { - dev_kfree_skb_any(bcs->tx_skb); - bcs->tx_skb = NULL; - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + modejade(bcs, 0, bcs->channel); + if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { + kfree(bcs->hw.hscx.rcvbuf); + bcs->hw.hscx.rcvbuf = NULL; + kfree(bcs->blog); + bcs->blog = NULL; + skb_queue_purge(&bcs->rqueue); + skb_queue_purge(&bcs->squeue); + if (bcs->tx_skb) { + dev_kfree_skb_any(bcs->tx_skb); + bcs->tx_skb = NULL; + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + } } - } } static int @@ -221,7 +221,7 @@ open_jadestate(struct IsdnCardState *cs, struct BCState *bcs) } if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) { printk(KERN_WARNING - "HiSax: No memory for bcs->blog\n"); + "HiSax: No memory for bcs->blog\n"); test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); kfree(bcs->hw.hscx.rcvbuf); bcs->hw.hscx.rcvbuf = NULL; @@ -303,12 +303,11 @@ initjade(struct IsdnCardState *cs) cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00); cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00); /* Setup host access to hdlc controller */ - jade_write_indirect(cs, jade_HDLCCNTRACCESS, (jadeINDIRECT_HAH1|jadeINDIRECT_HAH2)); + jade_write_indirect(cs, jade_HDLCCNTRACCESS, (jadeINDIRECT_HAH1 | jadeINDIRECT_HAH2)); /* Unmask HDLC int (don't forget DSP int later on)*/ - cs->BC_Write_Reg(cs, -1,jade_INT, (jadeINT_HDLC1|jadeINT_HDLC2)); + cs->BC_Write_Reg(cs, -1, jade_INT, (jadeINT_HDLC1 | jadeINT_HDLC2)); - /* once again TRANSPARENT */ + /* once again TRANSPARENT */ modejade(cs->bcs, 0, 0); modejade(cs->bcs + 1, 0, 0); } - diff --git a/drivers/isdn/hisax/jade.h b/drivers/isdn/hisax/jade.h index 29055e1ee381..4b98096a5858 100644 --- a/drivers/isdn/hisax/jade.h +++ b/drivers/isdn/hisax/jade.h @@ -4,7 +4,7 @@ * * Author Roland Klabunde * Copyright by Roland Klabunde - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -16,111 +16,111 @@ /* Special registers for access to indirect accessible JADE regs */ #define DIRECT_IO_JADE 0x0000 /* Jade direct io access area */ -#define COMM_JADE 0x0040 /* Jade communication area */ +#define COMM_JADE 0x0040 /* Jade communication area */ /********************************************************************/ -/* JADE-HDLC registers */ +/* JADE-HDLC registers */ /********************************************************************/ -#define jade_HDLC_RFIFO 0x00 /* R */ -#define jade_HDLC_XFIFO 0x00 /* W */ - -#define jade_HDLC_STAR 0x20 /* R */ - #define jadeSTAR_XDOV 0x80 - #define jadeSTAR_XFW 0x40 /* Does not work*/ - #define jadeSTAR_XCEC 0x20 - #define jadeSTAR_RCEC 0x10 - #define jadeSTAR_BSY 0x08 - #define jadeSTAR_RNA 0x04 - #define jadeSTAR_STR 0x02 - #define jadeSTAR_STX 0x01 - -#define jade_HDLC_XCMD 0x20 /* W */ - #define jadeXCMD_XF 0x80 - #define jadeXCMD_XME 0x40 - #define jadeXCMD_XRES 0x20 - #define jadeXCMD_STX 0x01 - -#define jade_HDLC_RSTA 0x21 /* R */ - #define jadeRSTA_VFR 0x80 - #define jadeRSTA_RDO 0x40 - #define jadeRSTA_CRC 0x20 - #define jadeRSTA_RAB 0x10 - #define jadeRSTA_MASK 0xF0 +#define jade_HDLC_RFIFO 0x00 /* R */ +#define jade_HDLC_XFIFO 0x00 /* W */ + +#define jade_HDLC_STAR 0x20 /* R */ +#define jadeSTAR_XDOV 0x80 +#define jadeSTAR_XFW 0x40 /* Does not work*/ +#define jadeSTAR_XCEC 0x20 +#define jadeSTAR_RCEC 0x10 +#define jadeSTAR_BSY 0x08 +#define jadeSTAR_RNA 0x04 +#define jadeSTAR_STR 0x02 +#define jadeSTAR_STX 0x01 + +#define jade_HDLC_XCMD 0x20 /* W */ +#define jadeXCMD_XF 0x80 +#define jadeXCMD_XME 0x40 +#define jadeXCMD_XRES 0x20 +#define jadeXCMD_STX 0x01 + +#define jade_HDLC_RSTA 0x21 /* R */ +#define jadeRSTA_VFR 0x80 +#define jadeRSTA_RDO 0x40 +#define jadeRSTA_CRC 0x20 +#define jadeRSTA_RAB 0x10 +#define jadeRSTA_MASK 0xF0 #define jade_HDLC_MODE 0x22 /* RW*/ - #define jadeMODE_TMO 0x80 - #define jadeMODE_RAC 0x40 - #define jadeMODE_XAC 0x20 - #define jadeMODE_TLP 0x10 - #define jadeMODE_ERFS 0x02 - #define jadeMODE_ETFS 0x01 +#define jadeMODE_TMO 0x80 +#define jadeMODE_RAC 0x40 +#define jadeMODE_XAC 0x20 +#define jadeMODE_TLP 0x10 +#define jadeMODE_ERFS 0x02 +#define jadeMODE_ETFS 0x01 #define jade_HDLC_RBCH 0x24 /* R */ -#define jade_HDLC_RBCL 0x25 /* R */ -#define jade_HDLC_RCMD 0x25 /* W */ - #define jadeRCMD_RMC 0x80 - #define jadeRCMD_RRES 0x40 - #define jadeRCMD_RMD 0x20 - #define jadeRCMD_STR 0x02 +#define jade_HDLC_RBCL 0x25 /* R */ +#define jade_HDLC_RCMD 0x25 /* W */ +#define jadeRCMD_RMC 0x80 +#define jadeRCMD_RRES 0x40 +#define jadeRCMD_RMD 0x20 +#define jadeRCMD_STR 0x02 #define jade_HDLC_CCR0 0x26 /* RW*/ - #define jadeCCR0_PU 0x80 - #define jadeCCR0_ITF 0x40 - #define jadeCCR0_C32 0x20 - #define jadeCCR0_CRL 0x10 - #define jadeCCR0_RCRC 0x08 - #define jadeCCR0_XCRC 0x04 - #define jadeCCR0_RMSB 0x02 - #define jadeCCR0_XMSB 0x01 +#define jadeCCR0_PU 0x80 +#define jadeCCR0_ITF 0x40 +#define jadeCCR0_C32 0x20 +#define jadeCCR0_CRL 0x10 +#define jadeCCR0_RCRC 0x08 +#define jadeCCR0_XCRC 0x04 +#define jadeCCR0_RMSB 0x02 +#define jadeCCR0_XMSB 0x01 #define jade_HDLC_CCR1 0x27 /* RW*/ - #define jadeCCR1_RCS0 0x80 - #define jadeCCR1_RCONT 0x40 - #define jadeCCR1_RFDIS 0x20 - #define jadeCCR1_XCS0 0x10 - #define jadeCCR1_XCONT 0x08 - #define jadeCCR1_XFDIS 0x04 +#define jadeCCR1_RCS0 0x80 +#define jadeCCR1_RCONT 0x40 +#define jadeCCR1_RFDIS 0x20 +#define jadeCCR1_XCS0 0x10 +#define jadeCCR1_XCONT 0x08 +#define jadeCCR1_XFDIS 0x04 #define jade_HDLC_TSAR 0x28 /* RW*/ #define jade_HDLC_TSAX 0x29 /* RW*/ #define jade_HDLC_RCCR 0x2A /* RW*/ #define jade_HDLC_XCCR 0x2B /* RW*/ -#define jade_HDLC_ISR 0x2C /* R */ -#define jade_HDLC_IMR 0x2C /* W */ - #define jadeISR_RME 0x80 - #define jadeISR_RPF 0x40 - #define jadeISR_RFO 0x20 - #define jadeISR_XPR 0x10 - #define jadeISR_XDU 0x08 - #define jadeISR_ALLS 0x04 - -#define jade_INT 0x75 - #define jadeINT_HDLC1 0x02 - #define jadeINT_HDLC2 0x01 - #define jadeINT_DSP 0x04 -#define jade_INTR 0x70 +#define jade_HDLC_ISR 0x2C /* R */ +#define jade_HDLC_IMR 0x2C /* W */ +#define jadeISR_RME 0x80 +#define jadeISR_RPF 0x40 +#define jadeISR_RFO 0x20 +#define jadeISR_XPR 0x10 +#define jadeISR_XDU 0x08 +#define jadeISR_ALLS 0x04 + +#define jade_INT 0x75 +#define jadeINT_HDLC1 0x02 +#define jadeINT_HDLC2 0x01 +#define jadeINT_DSP 0x04 +#define jade_INTR 0x70 /********************************************************************/ -/* Indirect accessible JADE registers of common interest */ +/* Indirect accessible JADE registers of common interest */ /********************************************************************/ #define jade_CHIPVERSIONNR 0x00 /* Does not work*/ -#define jade_HDLCCNTRACCESS 0x10 - #define jadeINDIRECT_HAH1 0x02 - #define jadeINDIRECT_HAH2 0x01 +#define jade_HDLCCNTRACCESS 0x10 +#define jadeINDIRECT_HAH1 0x02 +#define jadeINDIRECT_HAH2 0x01 #define jade_HDLC1SERRXPATH 0x1D #define jade_HDLC1SERTXPATH 0x1E #define jade_HDLC2SERRXPATH 0x1F #define jade_HDLC2SERTXPATH 0x20 - #define jadeINDIRECT_SLIN1 0x10 - #define jadeINDIRECT_SLIN0 0x08 - #define jadeINDIRECT_LMOD1 0x04 - #define jadeINDIRECT_LMOD0 0x02 - #define jadeINDIRECT_HHR 0x01 - #define jadeINDIRECT_HHX 0x01 +#define jadeINDIRECT_SLIN1 0x10 +#define jadeINDIRECT_SLIN0 0x08 +#define jadeINDIRECT_LMOD1 0x04 +#define jadeINDIRECT_LMOD0 0x02 +#define jadeINDIRECT_HHR 0x01 +#define jadeINDIRECT_HHX 0x01 #define jade_RXAUDIOCH1CFG 0x11 #define jade_RXAUDIOCH2CFG 0x14 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c index 1f201af15a0f..f521fc83dc76 100644 --- a/drivers/isdn/hisax/jade_irq.c +++ b/drivers/isdn/hisax/jade_irq.c @@ -4,7 +4,7 @@ * * Author Roland Klabunde * Copyright by Roland Klabunde - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -13,21 +13,21 @@ static inline void waitforCEC(struct IsdnCardState *cs, int jade, int reg) { - int to = 50; - int mask = (reg == jade_HDLC_XCMD ? jadeSTAR_XCEC : jadeSTAR_RCEC); - while ((READJADE(cs, jade, jade_HDLC_STAR) & mask) && to) { - udelay(1); - to--; - } - if (!to) - printk(KERN_WARNING "HiSax: waitforCEC (jade) timeout\n"); + int to = 50; + int mask = (reg == jade_HDLC_XCMD ? jadeSTAR_XCEC : jadeSTAR_RCEC); + while ((READJADE(cs, jade, jade_HDLC_STAR) & mask) && to) { + udelay(1); + to--; + } + if (!to) + printk(KERN_WARNING "HiSax: waitforCEC (jade) timeout\n"); } static inline void waitforXFW(struct IsdnCardState *cs, int jade) { - /* Does not work on older jade versions, don't care */ + /* Does not work on older jade versions, don't care */ } static inline void @@ -98,7 +98,7 @@ jade_fill_fifo(struct BCState *bcs) bcs->tx_cnt -= count; bcs->hw.hscx.count += count; WRITEJADEFIFO(cs, bcs->hw.hscx.hscx, ptr, count); - WriteJADECMDR(cs, bcs->hw.hscx.hscx, jade_HDLC_XCMD, more ? jadeXCMD_XF : (jadeXCMD_XF|jadeXCMD_XME)); + WriteJADECMDR(cs, bcs->hw.hscx.hscx, jade_HDLC_XCMD, more ? jadeXCMD_XF : (jadeXCMD_XF | jadeXCMD_XME)); if (cs->debug & L1_DEB_HSCX_FIFO) { char *t = bcs->blog; @@ -119,7 +119,7 @@ jade_interrupt(struct IsdnCardState *cs, u_char val, u_char jade) int fifo_size = 32; int count; int i_jade = (int) jade; /* To satisfy the compiler */ - + if (!test_bit(BC_FLG_INIT, &bcs->Flag)) return; @@ -128,13 +128,13 @@ jade_interrupt(struct IsdnCardState *cs, u_char val, u_char jade) if ((r & 0xf0) != 0xa0) { if (!(r & 0x80)) if (cs->debug & L1_DEB_WARN) - debugl1(cs, "JADE %s invalid frame", (jade ? "B":"A")); + debugl1(cs, "JADE %s invalid frame", (jade ? "B" : "A")); if ((r & 0x40) && bcs->mode) if (cs->debug & L1_DEB_WARN) - debugl1(cs, "JADE %c RDO mode=%d", 'A'+jade, bcs->mode); + debugl1(cs, "JADE %c RDO mode=%d", 'A' + jade, bcs->mode); if (!(r & 0x20)) if (cs->debug & L1_DEB_WARN) - debugl1(cs, "JADE %c CRC error", 'A'+jade); + debugl1(cs, "JADE %c CRC error", 'A' + jade); WriteJADECMDR(cs, jade, jade_HDLC_RCMD, jadeRCMD_RMC); } else { count = READJADE(cs, i_jade, jade_HDLC_RBCL) & 0x1F; @@ -145,7 +145,7 @@ jade_interrupt(struct IsdnCardState *cs, u_char val, u_char jade) if (cs->debug & L1_DEB_HSCX_FIFO) debugl1(cs, "HX Frame %d", count); if (!(skb = dev_alloc_skb(count))) - printk(KERN_WARNING "JADE %s receive out of memory\n", (jade ? "B":"A")); + printk(KERN_WARNING "JADE %s receive out of memory\n", (jade ? "B" : "A")); else { memcpy(skb_put(skb, count), bcs->hw.hscx.rcvbuf, count); skb_queue_tail(&bcs->rqueue, skb); @@ -175,8 +175,8 @@ jade_interrupt(struct IsdnCardState *cs, u_char val, u_char jade) jade_fill_fifo(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; @@ -204,7 +204,7 @@ jade_int_main(struct IsdnCardState *cs, u_char val, int jade) { struct BCState *bcs; bcs = cs->bcs + jade; - + if (val & jadeISR_RFO) { /* handled with RDO */ val &= ~jadeISR_RFO; @@ -216,21 +216,21 @@ jade_int_main(struct IsdnCardState *cs, u_char val, int jade) jade_fill_fifo(bcs); else { /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. + * restart transmitting the whole frame. */ if (bcs->tx_skb) { - skb_push(bcs->tx_skb, bcs->hw.hscx.count); + skb_push(bcs->tx_skb, bcs->hw.hscx.count); bcs->tx_cnt += bcs->hw.hscx.count; bcs->hw.hscx.count = 0; } WriteJADECMDR(cs, bcs->hw.hscx.hscx, jade_HDLC_XCMD, jadeXCMD_XRES); if (cs->debug & L1_DEB_WARN) - debugl1(cs, "JADE %c EXIR %x Lost TX", 'A'+jade, val); + debugl1(cs, "JADE %c EXIR %x Lost TX", 'A' + jade, val); } } - if (val & (jadeISR_RME|jadeISR_RPF|jadeISR_XPR)) { + if (val & (jadeISR_RME | jadeISR_RPF | jadeISR_XPR)) { if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "JADE %c interrupt %x", 'A'+jade, val); + debugl1(cs, "JADE %c interrupt %x", 'A' + jade, val); jade_interrupt(cs, val, jade); } } diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c index ee4dae1382e0..4c1bca5caa1d 100644 --- a/drivers/isdn/hisax/l3_1tr6.c +++ b/drivers/isdn/hisax/l3_1tr6.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -21,10 +21,10 @@ extern char *HiSax_getrev(const char *revision); static const char *l3_1tr6_revision = "$Revision: 2.15.2.3 $"; -#define MsgHead(ptr, cref, mty, dis) \ - *ptr++ = dis; \ - *ptr++ = 0x1; \ - *ptr++ = cref ^ 0x80; \ +#define MsgHead(ptr, cref, mty, dis) \ + *ptr++ = dis; \ + *ptr++ = 0x1; \ + *ptr++ = cref ^ 0x80; \ *ptr++ = mty static void @@ -83,23 +83,23 @@ l3_1tr6_setup_req(struct l3_process *pc, u_char pr, void *arg) pc->para.spv = 0; if (!isdigit(*teln)) { switch (0x5f & *teln) { - case 'S': - pc->para.spv = 1; - break; - case 'C': - channel = 0x08; - case 'P': - channel |= 0x80; - teln++; - if (*teln == '1') - channel |= 0x01; - else - channel |= 0x02; - break; - default: - if (pc->st->l3.debug & L3_DEB_WARN) - l3_debug(pc->st, "Wrong MSN Code"); - break; + case 'S': + pc->para.spv = 1; + break; + case 'C': + channel = 0x08; + case 'P': + channel |= 0x80; + teln++; + if (*teln == '1') + channel |= 0x01; + else + channel |= 0x02; + break; + default: + if (pc->st->l3.debug & L3_DEB_WARN) + l3_debug(pc->st, "Wrong MSN Code"); + break; } teln++; } @@ -176,7 +176,7 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg) return; } if ((pc->para.bchannel = p[2] & 0x3)) - bcfound++; + bcfound++; } else { l3_1tr6_error(pc, "missing setup chanID", skb); return; @@ -525,15 +525,15 @@ l3_1tr6_disconnect_req(struct l3_process *pc, u_char pr, void *arg) cause = pc->para.cause; /* Map DSS1 causes */ switch (cause & 0x7f) { - case 0x10: - clen = 0; - break; - case 0x11: - cause = CAUSE_UserBusy; - break; - case 0x15: - cause = CAUSE_CallRejected; - break; + case 0x10: + clen = 0; + break; + case 0x11: + cause = CAUSE_UserBusy; + break; + case 0x15: + cause = CAUSE_CallRejected; + break; } StopAllL3Timer(pc); MsgHead(p, pc->callref, MT_N1_DISC, PROTO_DIS_N1); @@ -588,12 +588,12 @@ l3_1tr6_t305(struct l3_process *pc, u_char pr, void *arg) cause = pc->para.cause; /* Map DSS1 causes */ switch (cause & 0x7f) { - case 0x10: - clen = 0; - break; - case 0x15: - cause = CAUSE_CallRejected; - break; + case 0x10: + clen = 0; + break; + case 0x15: + cause = CAUSE_CallRejected; + break; } MsgHead(p, pc->callref, MT_N1_REL, PROTO_DIS_N1); *p++ = WE0_cause; @@ -647,19 +647,19 @@ l3_1tr6_t308_2(struct l3_process *pc, u_char pr, void *arg) static void l3_1tr6_dl_reset(struct l3_process *pc, u_char pr, void *arg) { - pc->para.cause = CAUSE_LocalProcErr; - l3_1tr6_disconnect_req(pc, pr, NULL); - pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc); + pc->para.cause = CAUSE_LocalProcErr; + l3_1tr6_disconnect_req(pc, pr, NULL); + pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc); } static void l3_1tr6_dl_release(struct l3_process *pc, u_char pr, void *arg) { - newl3state(pc, 0); - pc->para.cause = 0x1b; /* Destination out of order */ - pc->para.loc = 0; - pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc); - release_l3_process(pc); + newl3state(pc, 0); + pc->para.cause = 0x1b; /* Destination out of order */ + pc->para.loc = 0; + pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc); + release_l3_process(pc); } /* *INDENT-OFF* */ @@ -667,9 +667,9 @@ static struct stateentry downstl[] = { {SBIT(0), CC_SETUP | REQUEST, l3_1tr6_setup_req}, - {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(6) | SBIT(7) | SBIT(8) | - SBIT(10), - CC_DISCONNECT | REQUEST, l3_1tr6_disconnect_req}, + {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(6) | SBIT(7) | SBIT(8) | + SBIT(10), + CC_DISCONNECT | REQUEST, l3_1tr6_disconnect_req}, {SBIT(12), CC_RELEASE | REQUEST, l3_1tr6_release_req}, {SBIT(6), @@ -732,12 +732,12 @@ static struct stateentry datastln1[] = static struct stateentry manstatelist[] = { - {SBIT(2), - DL_ESTABLISH | INDICATION, l3_1tr6_dl_reset}, - {ALL_STATES, - DL_RELEASE | INDICATION, l3_1tr6_dl_release}, + {SBIT(2), + DL_ESTABLISH | INDICATION, l3_1tr6_dl_reset}, + {ALL_STATES, + DL_RELEASE | INDICATION, l3_1tr6_dl_release}, }; - + /* *INDENT-ON* */ static void @@ -749,16 +749,16 @@ up1tr6(struct PStack *st, int pr, void *arg) char tmp[80]; switch (pr) { - case (DL_DATA | INDICATION): - case (DL_UNIT_DATA | INDICATION): - break; - case (DL_ESTABLISH | CONFIRM): - case (DL_ESTABLISH | INDICATION): - case (DL_RELEASE | INDICATION): - case (DL_RELEASE | CONFIRM): - l3_msg(st, pr, arg); - return; - break; + case (DL_DATA | INDICATION): + case (DL_UNIT_DATA | INDICATION): + break; + case (DL_ESTABLISH | CONFIRM): + case (DL_ESTABLISH | INDICATION): + case (DL_RELEASE | INDICATION): + case (DL_RELEASE | CONFIRM): + l3_msg(st, pr, arg); + return; + break; } if (skb->len < 4) { if (st->l3.debug & L3_DEB_PROTERR) { @@ -792,12 +792,12 @@ up1tr6(struct PStack *st, int pr, void *arg) dev_kfree_skb(skb); if (st->l3.debug & L3_DEB_STATE) { sprintf(tmp, "up1tr6%s N0 mt %x unhandled", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt); + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt); l3_debug(st, tmp); } } else if (skb->data[0] == PROTO_DIS_N1) { if (!(proc = getl3proc(st, cr))) { - if (mt == MT_N1_SETUP) { + if (mt == MT_N1_SETUP) { if (cr < 128) { if (!(proc = new_l3_process(st, cr))) { if (st->l3.debug & L3_DEB_PROTERR) { @@ -812,10 +812,10 @@ up1tr6(struct PStack *st, int pr, void *arg) return; } } else if ((mt == MT_N1_REL) || (mt == MT_N1_REL_ACK) || - (mt == MT_N1_CANC_ACK) || (mt == MT_N1_CANC_REJ) || - (mt == MT_N1_REG_ACK) || (mt == MT_N1_REG_REJ) || - (mt == MT_N1_SUSP_ACK) || (mt == MT_N1_RES_REJ) || - (mt == MT_N1_INFO)) { + (mt == MT_N1_CANC_ACK) || (mt == MT_N1_CANC_REJ) || + (mt == MT_N1_REG_ACK) || (mt == MT_N1_REG_REJ) || + (mt == MT_N1_SUSP_ACK) || (mt == MT_N1_RES_REJ) || + (mt == MT_N1_INFO)) { dev_kfree_skb(skb); return; } else { @@ -838,7 +838,7 @@ up1tr6(struct PStack *st, int pr, void *arg) dev_kfree_skb(skb); if (st->l3.debug & L3_DEB_STATE) { sprintf(tmp, "up1tr6%sstate %d mt %x unhandled", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", proc->state, mt); l3_debug(st, tmp); } @@ -846,7 +846,7 @@ up1tr6(struct PStack *st, int pr, void *arg) } else { if (st->l3.debug & L3_DEB_STATE) { sprintf(tmp, "up1tr6%sstate %d mt %x", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", proc->state, mt); l3_debug(st, tmp); } @@ -863,7 +863,7 @@ down1tr6(struct PStack *st, int pr, void *arg) struct Channel *chan; char tmp[80]; - if ((DL_ESTABLISH | REQUEST)== pr) { + if ((DL_ESTABLISH | REQUEST) == pr) { l3_msg(st, pr, NULL); return; } else if ((CC_SETUP | REQUEST) == pr) { @@ -905,31 +905,31 @@ down1tr6(struct PStack *st, int pr, void *arg) static void man1tr6(struct PStack *st, int pr, void *arg) { - int i; - struct l3_process *proc = arg; - - if (!proc) { - printk(KERN_ERR "HiSax man1tr6 without proc pr=%04x\n", pr); - return; - } - for (i = 0; i < ARRAY_SIZE(manstatelist); i++) - if ((pr == manstatelist[i].primitive) && - ((1 << proc->state) & manstatelist[i].state)) - break; - if (i == ARRAY_SIZE(manstatelist)) { - if (st->l3.debug & L3_DEB_STATE) { - l3_debug(st, "cr %d man1tr6 state %d prim %d unhandled", - proc->callref & 0x7f, proc->state, pr); - } - } else { - if (st->l3.debug & L3_DEB_STATE) { - l3_debug(st, "cr %d man1tr6 state %d prim %d", - proc->callref & 0x7f, proc->state, pr); - } - manstatelist[i].rout(proc, pr, arg); - } -} - + int i; + struct l3_process *proc = arg; + + if (!proc) { + printk(KERN_ERR "HiSax man1tr6 without proc pr=%04x\n", pr); + return; + } + for (i = 0; i < ARRAY_SIZE(manstatelist); i++) + if ((pr == manstatelist[i].primitive) && + ((1 << proc->state) & manstatelist[i].state)) + break; + if (i == ARRAY_SIZE(manstatelist)) { + if (st->l3.debug & L3_DEB_STATE) { + l3_debug(st, "cr %d man1tr6 state %d prim %d unhandled", + proc->callref & 0x7f, proc->state, pr); + } + } else { + if (st->l3.debug & L3_DEB_STATE) { + l3_debug(st, "cr %d man1tr6 state %d prim %d", + proc->callref & 0x7f, proc->state, pr); + } + manstatelist[i].rout(proc, pr, arg); + } +} + void setstack_1tr6(struct PStack *st) { diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c index 6a8acf65777d..cda700664e9c 100644 --- a/drivers/isdn/hisax/l3dss1.c +++ b/drivers/isdn/hisax/l3dss1.c @@ -7,7 +7,7 @@ * Author Karsten Keil * based on the teles driver from Jan den Ouden * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -30,14 +30,14 @@ static const char *dss1_revision = "$Revision: 2.32.2.3 $"; #define EXT_BEARER_CAPS 1 -#define MsgHead(ptr, cref, mty) \ - *ptr++ = 0x8; \ - if (cref == -1) { \ - *ptr++ = 0x0; \ - } else { \ - *ptr++ = 0x1; \ - *ptr++ = cref^0x80; \ - } \ +#define MsgHead(ptr, cref, mty) \ + *ptr++ = 0x8; \ + if (cref == -1) { \ + *ptr++ = 0x0; \ + } else { \ + *ptr++ = 0x1; \ + *ptr++ = cref^0x80; \ + } \ *ptr++ = mty @@ -49,22 +49,22 @@ static unsigned char new_invoke_id(struct PStack *p) { unsigned char retval; int i; - + i = 32; /* maximum search depth */ retval = p->prot.dss1.last_invoke_id + 1; /* try new id */ while ((i) && (p->prot.dss1.invoke_used[retval >> 3] == 0xFF)) { p->prot.dss1.last_invoke_id = (retval & 0xF8) + 8; i--; - } + } if (i) { while (p->prot.dss1.invoke_used[retval >> 3] & (1 << (retval & 7))) - retval++; + retval++; } else retval = 0; p->prot.dss1.last_invoke_id = retval; p->prot.dss1.invoke_used[retval >> 3] |= (1 << (retval & 7)); - return(retval); + return (retval); } /* new_invoke_id */ /*************************/ @@ -73,10 +73,10 @@ static unsigned char new_invoke_id(struct PStack *p) static void free_invoke_id(struct PStack *p, unsigned char id) { - if (!id) return; /* 0 = invalid value */ + if (!id) return; /* 0 = invalid value */ - p->prot.dss1.invoke_used[id >> 3] &= ~(1 << (id & 7)); -} /* free_invoke_id */ + p->prot.dss1.invoke_used[id >> 3] &= ~(1 << (id & 7)); +} /* free_invoke_id */ /**********************************************************/ @@ -86,26 +86,26 @@ static struct l3_process *dss1_new_l3_process(struct PStack *st, int cr) { struct l3_process *proc; - if (!(proc = new_l3_process(st, cr))) - return(NULL); + if (!(proc = new_l3_process(st, cr))) + return (NULL); - proc->prot.dss1.invoke_id = 0; - proc->prot.dss1.remote_operation = 0; - proc->prot.dss1.uus1_data[0] = '\0'; - - return(proc); + proc->prot.dss1.invoke_id = 0; + proc->prot.dss1.remote_operation = 0; + proc->prot.dss1.uus1_data[0] = '\0'; + + return (proc); } /* dss1_new_l3_process */ /************************************************/ /* free a l3 process and all dss1 specific data */ -/************************************************/ +/************************************************/ static void dss1_release_l3_process(struct l3_process *p) { - free_invoke_id(p->st,p->prot.dss1.invoke_id); - release_l3_process(p); + free_invoke_id(p->st, p->prot.dss1.invoke_id); + release_l3_process(p); } /* dss1_release_l3_process */ - + /********************************************************/ /* search a process with invoke id id and dummy callref */ /********************************************************/ @@ -113,120 +113,120 @@ static struct l3_process * l3dss1_search_dummy_proc(struct PStack *st, int id) { struct l3_process *pc = st->l3.proc; /* start of processes */ - if (!id) return(NULL); + if (!id) return (NULL); - while (pc) - { if ((pc->callref == -1) && (pc->prot.dss1.invoke_id == id)) - return(pc); - pc = pc->next; - } - return(NULL); + while (pc) + { if ((pc->callref == -1) && (pc->prot.dss1.invoke_id == id)) + return (pc); + pc = pc->next; + } + return (NULL); } /* l3dss1_search_dummy_proc */ /*******************************************************************/ /* called when a facility message with a dummy callref is received */ /* and a return result is delivered. id specifies the invoke id. */ -/*******************************************************************/ -static void +/*******************************************************************/ +static void l3dss1_dummy_return_result(struct PStack *st, int id, u_char *p, u_char nlen) { isdn_ctrl ic; - struct IsdnCardState *cs; - struct l3_process *pc = NULL; - - if ((pc = l3dss1_search_dummy_proc(st, id))) - { L3DelTimer(&pc->timer); /* remove timer */ - - cs = pc->st->l1.hardware; - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = DSS1_STAT_INVOKE_RES; - ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id; - ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id; - ic.parm.dss1_io.proc = pc->prot.dss1.proc; - ic.parm.dss1_io.timeout= 0; - ic.parm.dss1_io.datalen = nlen; - ic.parm.dss1_io.data = p; - free_invoke_id(pc->st, pc->prot.dss1.invoke_id); - pc->prot.dss1.invoke_id = 0; /* reset id */ - - cs->iif.statcallb(&ic); - dss1_release_l3_process(pc); - } - else - l3_debug(st, "dummy return result id=0x%x result len=%d",id,nlen); + struct IsdnCardState *cs; + struct l3_process *pc = NULL; + + if ((pc = l3dss1_search_dummy_proc(st, id))) + { L3DelTimer(&pc->timer); /* remove timer */ + + cs = pc->st->l1.hardware; + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = DSS1_STAT_INVOKE_RES; + ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id; + ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id; + ic.parm.dss1_io.proc = pc->prot.dss1.proc; + ic.parm.dss1_io.timeout = 0; + ic.parm.dss1_io.datalen = nlen; + ic.parm.dss1_io.data = p; + free_invoke_id(pc->st, pc->prot.dss1.invoke_id); + pc->prot.dss1.invoke_id = 0; /* reset id */ + + cs->iif.statcallb(&ic); + dss1_release_l3_process(pc); + } + else + l3_debug(st, "dummy return result id=0x%x result len=%d", id, nlen); } /* l3dss1_dummy_return_result */ /*******************************************************************/ /* called when a facility message with a dummy callref is received */ /* and a return error is delivered. id specifies the invoke id. */ -/*******************************************************************/ -static void +/*******************************************************************/ +static void l3dss1_dummy_error_return(struct PStack *st, int id, ulong error) { isdn_ctrl ic; - struct IsdnCardState *cs; - struct l3_process *pc = NULL; - - if ((pc = l3dss1_search_dummy_proc(st, id))) - { L3DelTimer(&pc->timer); /* remove timer */ - - cs = pc->st->l1.hardware; - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = DSS1_STAT_INVOKE_ERR; - ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id; - ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id; - ic.parm.dss1_io.proc = pc->prot.dss1.proc; - ic.parm.dss1_io.timeout= error; - ic.parm.dss1_io.datalen = 0; - ic.parm.dss1_io.data = NULL; - free_invoke_id(pc->st, pc->prot.dss1.invoke_id); - pc->prot.dss1.invoke_id = 0; /* reset id */ - - cs->iif.statcallb(&ic); - dss1_release_l3_process(pc); - } - else - l3_debug(st, "dummy return error id=0x%x error=0x%lx",id,error); + struct IsdnCardState *cs; + struct l3_process *pc = NULL; + + if ((pc = l3dss1_search_dummy_proc(st, id))) + { L3DelTimer(&pc->timer); /* remove timer */ + + cs = pc->st->l1.hardware; + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = DSS1_STAT_INVOKE_ERR; + ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id; + ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id; + ic.parm.dss1_io.proc = pc->prot.dss1.proc; + ic.parm.dss1_io.timeout = error; + ic.parm.dss1_io.datalen = 0; + ic.parm.dss1_io.data = NULL; + free_invoke_id(pc->st, pc->prot.dss1.invoke_id); + pc->prot.dss1.invoke_id = 0; /* reset id */ + + cs->iif.statcallb(&ic); + dss1_release_l3_process(pc); + } + else + l3_debug(st, "dummy return error id=0x%x error=0x%lx", id, error); } /* l3dss1_error_return */ /*******************************************************************/ /* called when a facility message with a dummy callref is received */ /* and a invoke is delivered. id specifies the invoke id. */ -/*******************************************************************/ -static void -l3dss1_dummy_invoke(struct PStack *st, int cr, int id, - int ident, u_char *p, u_char nlen) +/*******************************************************************/ +static void +l3dss1_dummy_invoke(struct PStack *st, int cr, int id, + int ident, u_char *p, u_char nlen) { isdn_ctrl ic; - struct IsdnCardState *cs; - - l3_debug(st, "dummy invoke %s id=0x%x ident=0x%x datalen=%d", - (cr == -1) ? "local" : "broadcast",id,ident,nlen); - if (cr >= -1) return; /* ignore local data */ - - cs = st->l1.hardware; - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = DSS1_STAT_INVOKE_BRD; - ic.parm.dss1_io.hl_id = id; - ic.parm.dss1_io.ll_id = 0; - ic.parm.dss1_io.proc = ident; - ic.parm.dss1_io.timeout= 0; - ic.parm.dss1_io.datalen = nlen; - ic.parm.dss1_io.data = p; - - cs->iif.statcallb(&ic); + struct IsdnCardState *cs; + + l3_debug(st, "dummy invoke %s id=0x%x ident=0x%x datalen=%d", + (cr == -1) ? "local" : "broadcast", id, ident, nlen); + if (cr >= -1) return; /* ignore local data */ + + cs = st->l1.hardware; + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = DSS1_STAT_INVOKE_BRD; + ic.parm.dss1_io.hl_id = id; + ic.parm.dss1_io.ll_id = 0; + ic.parm.dss1_io.proc = ident; + ic.parm.dss1_io.timeout = 0; + ic.parm.dss1_io.datalen = nlen; + ic.parm.dss1_io.data = p; + + cs->iif.statcallb(&ic); } /* l3dss1_dummy_invoke */ static void l3dss1_parse_facility(struct PStack *st, struct l3_process *pc, - int cr, u_char * p) + int cr, u_char *p) { int qd_len = 0; unsigned char nlen = 0, ilen, cp_tag; int ident, id; ulong err_ret; - if (pc) + if (pc) st = pc->st; /* valid Stack */ else if ((!st) || (cr >= 0)) return; /* neither pc nor st specified */ @@ -255,243 +255,243 @@ l3dss1_parse_facility(struct PStack *st, struct l3_process *pc, l3_debug(st, "class and form != 0xA0"); return; } - - cp_tag = *p & 0x1F; /* remember tag value */ - p++; + cp_tag = *p & 0x1F; /* remember tag value */ + + p++; qd_len--; - if (qd_len < 1) - { l3_debug(st, "qd_len < 1"); - return; - } - if (*p & 0x80) - { /* length format indefinite or limited */ - nlen = *p++ & 0x7F; /* number of len bytes or indefinite */ - if ((qd_len-- < ((!nlen) ? 3 : (1 + nlen))) || - (nlen > 1)) - { l3_debug(st, "length format error or not implemented"); - return; - } - if (nlen == 1) - { nlen = *p++; /* complete length */ - qd_len--; - } - else - { qd_len -= 2; /* trailing null bytes */ - if ((*(p+qd_len)) || (*(p+qd_len+1))) - { l3_debug(st,"length format indefinite error"); - return; - } - nlen = qd_len; - } - } - else - { nlen = *p++; - qd_len--; - } - if (qd_len < nlen) - { l3_debug(st, "qd_len < nlen"); - return; - } + if (qd_len < 1) + { l3_debug(st, "qd_len < 1"); + return; + } + if (*p & 0x80) + { /* length format indefinite or limited */ + nlen = *p++ & 0x7F; /* number of len bytes or indefinite */ + if ((qd_len-- < ((!nlen) ? 3 : (1 + nlen))) || + (nlen > 1)) + { l3_debug(st, "length format error or not implemented"); + return; + } + if (nlen == 1) + { nlen = *p++; /* complete length */ + qd_len--; + } + else + { qd_len -= 2; /* trailing null bytes */ + if ((*(p + qd_len)) || (*(p + qd_len + 1))) + { l3_debug(st, "length format indefinite error"); + return; + } + nlen = qd_len; + } + } + else + { nlen = *p++; + qd_len--; + } + if (qd_len < nlen) + { l3_debug(st, "qd_len < nlen"); + return; + } qd_len -= nlen; - if (nlen < 2) - { l3_debug(st, "nlen < 2"); - return; - } - if (*p != 0x02) - { /* invoke identifier tag */ - l3_debug(st, "invoke identifier tag !=0x02"); - return; - } + if (nlen < 2) + { l3_debug(st, "nlen < 2"); + return; + } + if (*p != 0x02) + { /* invoke identifier tag */ + l3_debug(st, "invoke identifier tag !=0x02"); + return; + } p++; nlen--; - if (*p & 0x80) - { /* length format */ - l3_debug(st, "invoke id length format 2"); - return; - } + if (*p & 0x80) + { /* length format */ + l3_debug(st, "invoke id length format 2"); + return; + } ilen = *p++; nlen--; - if (ilen > nlen || ilen == 0) - { l3_debug(st, "ilen > nlen || ilen == 0"); - return; - } + if (ilen > nlen || ilen == 0) + { l3_debug(st, "ilen > nlen || ilen == 0"); + return; + } nlen -= ilen; id = 0; - while (ilen > 0) - { id = (id << 8) | (*p++ & 0xFF); /* invoke identifier */ - ilen--; - } + while (ilen > 0) + { id = (id << 8) | (*p++ & 0xFF); /* invoke identifier */ + ilen--; + } switch (cp_tag) { /* component tag */ - case 1: /* invoke */ - if (nlen < 2) { - l3_debug(st, "nlen < 2 22"); - return; - } - if (*p != 0x02) { /* operation value */ - l3_debug(st, "operation value !=0x02"); - return; - } - p++; - nlen--; - ilen = *p++; - nlen--; - if (ilen > nlen || ilen == 0) { - l3_debug(st, "ilen > nlen || ilen == 0 22"); - return; - } - nlen -= ilen; - ident = 0; - while (ilen > 0) { - ident = (ident << 8) | (*p++ & 0xFF); - ilen--; - } + case 1: /* invoke */ + if (nlen < 2) { + l3_debug(st, "nlen < 2 22"); + return; + } + if (*p != 0x02) { /* operation value */ + l3_debug(st, "operation value !=0x02"); + return; + } + p++; + nlen--; + ilen = *p++; + nlen--; + if (ilen > nlen || ilen == 0) { + l3_debug(st, "ilen > nlen || ilen == 0 22"); + return; + } + nlen -= ilen; + ident = 0; + while (ilen > 0) { + ident = (ident << 8) | (*p++ & 0xFF); + ilen--; + } - if (!pc) - { l3dss1_dummy_invoke(st, cr, id, ident, p, nlen); - return; - } + if (!pc) + { l3dss1_dummy_invoke(st, cr, id, ident, p, nlen); + return; + } #ifdef CONFIG_DE_AOC - { - -#define FOO1(s,a,b) \ - while(nlen > 1) { \ - int ilen = p[1]; \ - if(nlen < ilen+2) { \ - l3_debug(st, "FOO1 nlen < ilen+2"); \ - return; \ - } \ - nlen -= ilen+2; \ - if((*p & 0xFF) == (a)) { \ - int nlen = ilen; \ - p += 2; \ - b; \ - } else { \ - p += ilen+2; \ - } \ - } - - switch (ident) { - case 0x22: /* during */ - FOO1("1A", 0x30, FOO1("1C", 0xA1, FOO1("1D", 0x30, FOO1("1E", 0x02, ( { - ident = 0; - nlen = (nlen)?nlen:0; /* Make gcc happy */ - while (ilen > 0) { - ident = (ident << 8) | *p++; - ilen--; - } - if (ident > pc->para.chargeinfo) { - pc->para.chargeinfo = ident; - st->l3.l3l4(st, CC_CHARGE | INDICATION, pc); - } - if (st->l3.debug & L3_DEB_CHARGE) { - if (*(p + 2) == 0) { - l3_debug(st, "charging info during %d", pc->para.chargeinfo); - } - else { - l3_debug(st, "charging info final %d", pc->para.chargeinfo); - } - } - } - ))))) - break; - case 0x24: /* final */ - FOO1("2A", 0x30, FOO1("2B", 0x30, FOO1("2C", 0xA1, FOO1("2D", 0x30, FOO1("2E", 0x02, ( { - ident = 0; - nlen = (nlen)?nlen:0; /* Make gcc happy */ - while (ilen > 0) { - ident = (ident << 8) | *p++; - ilen--; - } - if (ident > pc->para.chargeinfo) { - pc->para.chargeinfo = ident; - st->l3.l3l4(st, CC_CHARGE | INDICATION, pc); - } - if (st->l3.debug & L3_DEB_CHARGE) { - l3_debug(st, "charging info final %d", pc->para.chargeinfo); - } + { + +#define FOO1(s, a, b) \ + while (nlen > 1) { \ + int ilen = p[1]; \ + if (nlen < ilen + 2) { \ + l3_debug(st, "FOO1 nlen < ilen+2"); \ + return; \ + } \ + nlen -= ilen + 2; \ + if ((*p & 0xFF) == (a)) { \ + int nlen = ilen; \ + p += 2; \ + b; \ + } else { \ + p += ilen + 2; \ + } \ + } + + switch (ident) { + case 0x22: /* during */ + FOO1("1A", 0x30, FOO1("1C", 0xA1, FOO1("1D", 0x30, FOO1("1E", 0x02, ( { + ident = 0; + nlen = (nlen) ? nlen : 0; /* Make gcc happy */ + while (ilen > 0) { + ident = (ident << 8) | *p++; + ilen--; + } + if (ident > pc->para.chargeinfo) { + pc->para.chargeinfo = ident; + st->l3.l3l4(st, CC_CHARGE | INDICATION, pc); + } + if (st->l3.debug & L3_DEB_CHARGE) { + if (*(p + 2) == 0) { + l3_debug(st, "charging info during %d", pc->para.chargeinfo); + } + else { + l3_debug(st, "charging info final %d", pc->para.chargeinfo); + } + } } - )))))) - break; - default: - l3_debug(st, "invoke break invalid ident %02x",ident); - break; - } + ))))) + break; + case 0x24: /* final */ + FOO1("2A", 0x30, FOO1("2B", 0x30, FOO1("2C", 0xA1, FOO1("2D", 0x30, FOO1("2E", 0x02, ( { + ident = 0; + nlen = (nlen) ? nlen : 0; /* Make gcc happy */ + while (ilen > 0) { + ident = (ident << 8) | *p++; + ilen--; + } + if (ident > pc->para.chargeinfo) { + pc->para.chargeinfo = ident; + st->l3.l3l4(st, CC_CHARGE | INDICATION, pc); + } + if (st->l3.debug & L3_DEB_CHARGE) { + l3_debug(st, "charging info final %d", pc->para.chargeinfo); + } + } + )))))) + break; + default: + l3_debug(st, "invoke break invalid ident %02x", ident); + break; + } #undef FOO1 - } + } #else /* not CONFIG_DE_AOC */ - l3_debug(st, "invoke break"); + l3_debug(st, "invoke break"); #endif /* not CONFIG_DE_AOC */ - break; - case 2: /* return result */ - /* if no process available handle separately */ - if (!pc) - { if (cr == -1) - l3dss1_dummy_return_result(st, id, p, nlen); - return; - } - if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id)) - { /* Diversion successful */ - free_invoke_id(st,pc->prot.dss1.invoke_id); - pc->prot.dss1.remote_result = 0; /* success */ - pc->prot.dss1.invoke_id = 0; - pc->redir_result = pc->prot.dss1.remote_result; - st->l3.l3l4(st, CC_REDIR | INDICATION, pc); } /* Diversion successful */ - else - l3_debug(st,"return error unknown identifier"); - break; - case 3: /* return error */ - err_ret = 0; - if (nlen < 2) - { l3_debug(st, "return error nlen < 2"); - return; - } - if (*p != 0x02) - { /* result tag */ - l3_debug(st, "invoke error tag !=0x02"); - return; - } - p++; - nlen--; - if (*p > 4) - { /* length format */ - l3_debug(st, "invoke return errlen > 4 "); - return; - } - ilen = *p++; - nlen--; - if (ilen > nlen || ilen == 0) - { l3_debug(st, "error return ilen > nlen || ilen == 0"); - return; - } - nlen -= ilen; - while (ilen > 0) - { err_ret = (err_ret << 8) | (*p++ & 0xFF); /* error value */ - ilen--; - } - /* if no process available handle separately */ - if (!pc) - { if (cr == -1) - l3dss1_dummy_error_return(st, id, err_ret); - return; - } - if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id)) - { /* Deflection error */ - free_invoke_id(st,pc->prot.dss1.invoke_id); - pc->prot.dss1.remote_result = err_ret; /* result */ - pc->prot.dss1.invoke_id = 0; - pc->redir_result = pc->prot.dss1.remote_result; - st->l3.l3l4(st, CC_REDIR | INDICATION, pc); - } /* Deflection error */ - else - l3_debug(st,"return result unknown identifier"); - break; - default: - l3_debug(st, "facility default break tag=0x%02x",cp_tag); - break; + break; + case 2: /* return result */ + /* if no process available handle separately */ + if (!pc) + { if (cr == -1) + l3dss1_dummy_return_result(st, id, p, nlen); + return; + } + if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id)) + { /* Diversion successful */ + free_invoke_id(st, pc->prot.dss1.invoke_id); + pc->prot.dss1.remote_result = 0; /* success */ + pc->prot.dss1.invoke_id = 0; + pc->redir_result = pc->prot.dss1.remote_result; + st->l3.l3l4(st, CC_REDIR | INDICATION, pc); } /* Diversion successful */ + else + l3_debug(st, "return error unknown identifier"); + break; + case 3: /* return error */ + err_ret = 0; + if (nlen < 2) + { l3_debug(st, "return error nlen < 2"); + return; + } + if (*p != 0x02) + { /* result tag */ + l3_debug(st, "invoke error tag !=0x02"); + return; + } + p++; + nlen--; + if (*p > 4) + { /* length format */ + l3_debug(st, "invoke return errlen > 4 "); + return; + } + ilen = *p++; + nlen--; + if (ilen > nlen || ilen == 0) + { l3_debug(st, "error return ilen > nlen || ilen == 0"); + return; + } + nlen -= ilen; + while (ilen > 0) + { err_ret = (err_ret << 8) | (*p++ & 0xFF); /* error value */ + ilen--; + } + /* if no process available handle separately */ + if (!pc) + { if (cr == -1) + l3dss1_dummy_error_return(st, id, err_ret); + return; + } + if ((pc->prot.dss1.invoke_id) && (pc->prot.dss1.invoke_id == id)) + { /* Deflection error */ + free_invoke_id(st, pc->prot.dss1.invoke_id); + pc->prot.dss1.remote_result = err_ret; /* result */ + pc->prot.dss1.invoke_id = 0; + pc->redir_result = pc->prot.dss1.remote_result; + st->l3.l3l4(st, CC_REDIR | INDICATION, pc); + } /* Deflection error */ + else + l3_debug(st, "return result unknown identifier"); + break; + default: + l3_debug(st, "facility default break tag=0x%02x", cp_tag); + break; } } @@ -568,21 +568,21 @@ l3dss1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg) struct sk_buff *skb; switch (pc->para.cause) { - case 81: /* invalid callreference */ - case 88: /* incomp destination */ - case 96: /* mandory IE missing */ - case 100: /* invalid IE contents */ - case 101: /* incompatible Callstate */ - MsgHead(p, pc->callref, MT_RELEASE_COMPLETE); - *p++ = IE_CAUSE; - *p++ = 0x2; - *p++ = 0x80; - *p++ = pc->para.cause | 0x80; - break; - default: - printk(KERN_ERR "HiSax l3dss1_msg_without_setup wrong cause %d\n", - pc->para.cause); - return; + case 81: /* invalid callreference */ + case 88: /* incomp destination */ + case 96: /* mandory IE missing */ + case 100: /* invalid IE contents */ + case 101: /* incompatible Callstate */ + MsgHead(p, pc->callref, MT_RELEASE_COMPLETE); + *p++ = IE_CAUSE; + *p++ = 0x2; + *p++ = 0x80; + *p++ = pc->para.cause | 0x80; + break; + default: + printk(KERN_ERR "HiSax l3dss1_msg_without_setup wrong cause %d\n", + pc->para.cause); + return; } l = p - tmp; if (!(skb = l3_alloc_skb(l))) @@ -593,42 +593,42 @@ l3dss1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg) } static int ie_ALERTING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, - IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_HLC, - IE_USER_USER, -1}; + IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_HLC, + IE_USER_USER, -1}; static int ie_CALL_PROCEEDING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, - IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_HLC, -1}; -static int ie_CONNECT[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, - IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_DATE, IE_SIGNAL, - IE_CONNECT_PN, IE_CONNECT_SUB, IE_LLC, IE_HLC, IE_USER_USER, -1}; + IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_HLC, -1}; +static int ie_CONNECT[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, + IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_DATE, IE_SIGNAL, + IE_CONNECT_PN, IE_CONNECT_SUB, IE_LLC, IE_HLC, IE_USER_USER, -1}; static int ie_CONNECT_ACKNOWLEDGE[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_SIGNAL, -1}; static int ie_DISCONNECT[] = {IE_CAUSE | IE_MANDATORY, IE_FACILITY, - IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; + IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; static int ie_INFORMATION[] = {IE_COMPLETE, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, - IE_CALLED_PN, -1}; + IE_CALLED_PN, -1}; static int ie_NOTIFY[] = {IE_BEARER, IE_NOTIFY | IE_MANDATORY, IE_DISPLAY, -1}; static int ie_PROGRESS[] = {IE_BEARER, IE_CAUSE, IE_FACILITY, IE_PROGRESS | - IE_MANDATORY, IE_DISPLAY, IE_HLC, IE_USER_USER, -1}; + IE_MANDATORY, IE_DISPLAY, IE_HLC, IE_USER_USER, -1}; static int ie_RELEASE[] = {IE_CAUSE | IE_MANDATORY_1, IE_FACILITY, IE_DISPLAY, - IE_SIGNAL, IE_USER_USER, -1}; -/* a RELEASE_COMPLETE with errors don't require special actions -static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; + IE_SIGNAL, IE_USER_USER, -1}; +/* a RELEASE_COMPLETE with errors don't require special actions + static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; */ -static int ie_RESUME_ACKNOWLEDGE[] = {IE_CHANNEL_ID| IE_MANDATORY, IE_FACILITY, - IE_DISPLAY, -1}; +static int ie_RESUME_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, + IE_DISPLAY, -1}; static int ie_RESUME_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; static int ie_SETUP[] = {IE_COMPLETE, IE_BEARER | IE_MANDATORY, - IE_CHANNEL_ID| IE_MANDATORY, IE_FACILITY, IE_PROGRESS, - IE_NET_FAC, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, IE_CALLING_PN, - IE_CALLING_SUB, IE_CALLED_PN, IE_CALLED_SUB, IE_REDIR_NR, - IE_LLC, IE_HLC, IE_USER_USER, -1}; + IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, IE_PROGRESS, + IE_NET_FAC, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, IE_CALLING_PN, + IE_CALLING_SUB, IE_CALLED_PN, IE_CALLED_SUB, IE_REDIR_NR, + IE_LLC, IE_HLC, IE_USER_USER, -1}; static int ie_SETUP_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, - IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, -1}; + IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, -1}; static int ie_STATUS[] = {IE_CAUSE | IE_MANDATORY, IE_CALL_STATE | - IE_MANDATORY, IE_DISPLAY, -1}; + IE_MANDATORY, IE_DISPLAY, -1}; static int ie_STATUS_ENQUIRY[] = {IE_DISPLAY, -1}; static int ie_SUSPEND_ACKNOWLEDGE[] = {IE_DISPLAY, IE_FACILITY, -1}; static int ie_SUSPEND_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; -/* not used +/* not used * static int ie_CONGESTION_CONTROL[] = {IE_CONGESTION | IE_MANDATORY, * IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; * static int ie_USER_INFORMATION[] = {IE_MORE_DATA, IE_USER_USER | IE_MANDATORY, -1}; @@ -636,8 +636,8 @@ static int ie_SUSPEND_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; * IE_MANDATORY, -1}; */ static int ie_FACILITY[] = {IE_FACILITY | IE_MANDATORY, IE_DISPLAY, -1}; -static int comp_required[] = {1,2,3,5,6,7,9,10,11,14,15,-1}; -static int l3_valid_states[] = {0,1,2,3,4,6,7,8,9,10,11,12,15,17,19,25,-1}; +static int comp_required[] = {1, 2, 3, 5, 6, 7, 9, 10, 11, 14, 15, -1}; +static int l3_valid_states[] = {0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 15, 17, 19, 25, -1}; struct ie_len { int ie; @@ -678,7 +678,7 @@ struct ie_len max_ie_len[] = { {IE_LLC, 18}, {IE_HLC, 5}, {IE_USER_USER, 131}, - {-1,0}, + {-1, 0}, }; static int @@ -686,10 +686,10 @@ getmax_ie_len(u_char ie) { int i = 0; while (max_ie_len[i].ie != -1) { if (max_ie_len[i].ie == ie) - return(max_ie_len[i].len); + return (max_ie_len[i].len); i++; } - return(255); + return (255); } static int @@ -699,14 +699,14 @@ ie_in_set(struct l3_process *pc, u_char ie, int *checklist) { while (*checklist != -1) { if ((*checklist & 0xff) == ie) { if (ie & 0x80) - return(-ret); + return (-ret); else - return(ret); + return (ret); } ret++; checklist++; } - return(0); + return (0); } static int @@ -720,7 +720,7 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) u_char codeset = 0; u_char old_codeset = 0; u_char codelock = 1; - + p = skb->data; /* skip cr */ p++; @@ -738,7 +738,7 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) codelock = 1; if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check IE shift%scodeset %d->%d", - codelock ? " locking ": " ", old_codeset, codeset); + codelock ? " locking " : " ", old_codeset, codeset); p++; continue; } @@ -770,7 +770,7 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) if (!codelock) { if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check IE shift back codeset %d->%d", - codeset, old_codeset); + codeset, old_codeset); codeset = old_codeset; codelock = 1; } @@ -778,17 +778,17 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) if (err_compr | err_ureg | err_len | err_seq) { if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check IE MT(%x) %d/%d/%d/%d", - mt, err_compr, err_ureg, err_len, err_seq); + mt, err_compr, err_ureg, err_len, err_seq); if (err_compr) - return(ERR_IE_COMPREHENSION); + return (ERR_IE_COMPREHENSION); if (err_ureg) - return(ERR_IE_UNRECOGNIZED); + return (ERR_IE_UNRECOGNIZED); if (err_len) - return(ERR_IE_LENGTH); + return (ERR_IE_LENGTH); if (err_seq) - return(ERR_IE_SEQUENCE); - } - return(0); + return (ERR_IE_SEQUENCE); + } + return (0); } /* verify if a message type exists and contain no IE error */ @@ -796,42 +796,42 @@ static int l3dss1_check_messagetype_validity(struct l3_process *pc, int mt, void *arg) { switch (mt) { - case MT_ALERTING: - case MT_CALL_PROCEEDING: - case MT_CONNECT: - case MT_CONNECT_ACKNOWLEDGE: - case MT_DISCONNECT: - case MT_INFORMATION: - case MT_FACILITY: - case MT_NOTIFY: - case MT_PROGRESS: - case MT_RELEASE: - case MT_RELEASE_COMPLETE: - case MT_SETUP: - case MT_SETUP_ACKNOWLEDGE: - case MT_RESUME_ACKNOWLEDGE: - case MT_RESUME_REJECT: - case MT_SUSPEND_ACKNOWLEDGE: - case MT_SUSPEND_REJECT: - case MT_USER_INFORMATION: - case MT_RESTART: - case MT_RESTART_ACKNOWLEDGE: - case MT_CONGESTION_CONTROL: - case MT_STATUS: - case MT_STATUS_ENQUIRY: - if (pc->debug & L3_DEB_CHECK) - l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) OK", mt); - break; - case MT_RESUME: /* RESUME only in user->net */ - case MT_SUSPEND: /* SUSPEND only in user->net */ - default: - if (pc->debug & (L3_DEB_CHECK | L3_DEB_WARN)) - l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) fail", mt); - pc->para.cause = 97; - l3dss1_status_send(pc, 0, NULL); - return(1); + case MT_ALERTING: + case MT_CALL_PROCEEDING: + case MT_CONNECT: + case MT_CONNECT_ACKNOWLEDGE: + case MT_DISCONNECT: + case MT_INFORMATION: + case MT_FACILITY: + case MT_NOTIFY: + case MT_PROGRESS: + case MT_RELEASE: + case MT_RELEASE_COMPLETE: + case MT_SETUP: + case MT_SETUP_ACKNOWLEDGE: + case MT_RESUME_ACKNOWLEDGE: + case MT_RESUME_REJECT: + case MT_SUSPEND_ACKNOWLEDGE: + case MT_SUSPEND_REJECT: + case MT_USER_INFORMATION: + case MT_RESTART: + case MT_RESTART_ACKNOWLEDGE: + case MT_CONGESTION_CONTROL: + case MT_STATUS: + case MT_STATUS_ENQUIRY: + if (pc->debug & L3_DEB_CHECK) + l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) OK", mt); + break; + case MT_RESUME: /* RESUME only in user->net */ + case MT_SUSPEND: /* SUSPEND only in user->net */ + default: + if (pc->debug & (L3_DEB_CHECK | L3_DEB_WARN)) + l3_debug(pc->st, "l3dss1_check_messagetype_validity mt(%x) fail", mt); + pc->para.cause = 97; + l3dss1_status_send(pc, 0, NULL); + return (1); } - return(0); + return (0); } static void @@ -839,24 +839,24 @@ l3dss1_std_ie_err(struct l3_process *pc, int ret) { if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check_infoelements ret %d", ret); - switch(ret) { - case 0: - break; - case ERR_IE_COMPREHENSION: - pc->para.cause = 96; - l3dss1_status_send(pc, 0, NULL); - break; - case ERR_IE_UNRECOGNIZED: - pc->para.cause = 99; - l3dss1_status_send(pc, 0, NULL); - break; - case ERR_IE_LENGTH: - pc->para.cause = 100; - l3dss1_status_send(pc, 0, NULL); - break; - case ERR_IE_SEQUENCE: - default: - break; + switch (ret) { + case 0: + break; + case ERR_IE_COMPREHENSION: + pc->para.cause = 96; + l3dss1_status_send(pc, 0, NULL); + break; + case ERR_IE_UNRECOGNIZED: + pc->para.cause = 99; + l3dss1_status_send(pc, 0, NULL); + break; + case ERR_IE_LENGTH: + pc->para.cause = 100; + l3dss1_status_send(pc, 0, NULL); + break; + case ERR_IE_SEQUENCE: + default: + break; } } @@ -878,14 +878,14 @@ l3dss1_get_channel_id(struct l3_process *pc, struct sk_buff *skb) { l3_debug(pc->st, "wrong chid %x", *p); return (-3); } - return(*p & 0x3); + return (*p & 0x3); } else - return(-1); + return (-1); } static int l3dss1_get_cause(struct l3_process *pc, struct sk_buff *skb) { - u_char l, i=0; + u_char l, i = 0; u_char *p; p = skb->data; @@ -894,13 +894,13 @@ l3dss1_get_cause(struct l3_process *pc, struct sk_buff *skb) { if ((p = findie(p, skb->len, IE_CAUSE, 0))) { p++; l = *p++; - if (l>30) - return(1); + if (l > 30) + return (1); if (l) { pc->para.loc = *p++; l--; } else { - return(2); + return (2); } if (l && !(pc->para.loc & 0x80)) { l--; @@ -910,36 +910,36 @@ l3dss1_get_cause(struct l3_process *pc, struct sk_buff *skb) { pc->para.cause = *p++; l--; if (!(pc->para.cause & 0x80)) - return(3); + return (3); } else - return(4); - while (l && (i<6)) { + return (4); + while (l && (i < 6)) { pc->para.diag[i++] = *p++; l--; } } else - return(-1); - return(0); + return (-1); + return (0); } static void l3dss1_msg_with_uus(struct l3_process *pc, u_char cmd) { struct sk_buff *skb; - u_char tmp[16+40]; + u_char tmp[16 + 40]; u_char *p = tmp; int l; MsgHead(p, pc->callref, cmd); - if (pc->prot.dss1.uus1_data[0]) - { *p++ = IE_USER_USER; /* UUS info element */ - *p++ = strlen(pc->prot.dss1.uus1_data) + 1; - *p++ = 0x04; /* IA5 chars */ - strcpy(p,pc->prot.dss1.uus1_data); - p += strlen(pc->prot.dss1.uus1_data); - pc->prot.dss1.uus1_data[0] = '\0'; - } + if (pc->prot.dss1.uus1_data[0]) + { *p++ = IE_USER_USER; /* UUS info element */ + *p++ = strlen(pc->prot.dss1.uus1_data) + 1; + *p++ = 0x04; /* IA5 chars */ + strcpy(p, pc->prot.dss1.uus1_data); + p += strlen(pc->prot.dss1.uus1_data); + pc->prot.dss1.uus1_data[0] = '\0'; + } l = p - tmp; if (!(skb = l3_alloc_skb(l))) @@ -953,7 +953,7 @@ l3dss1_release_req(struct l3_process *pc, u_char pr, void *arg) { StopAllL3Timer(pc); newl3state(pc, 19); - if (!pc->prot.dss1.uus1_data[0]) + if (!pc->prot.dss1.uus1_data[0]) l3dss1_message(pc, MT_RELEASE); else l3dss1_msg_with_uus(pc, MT_RELEASE); @@ -966,9 +966,9 @@ l3dss1_release_cmpl(struct l3_process *pc, u_char pr, void *arg) struct sk_buff *skb = arg; int ret; - if ((ret = l3dss1_get_cause(pc, skb))>0) { + if ((ret = l3dss1_get_cause(pc, skb)) > 0) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "RELCMPL get_cause ret(%d)",ret); + l3_debug(pc->st, "RELCMPL get_cause ret(%d)", ret); } else if (ret < 0) pc->para.cause = NO_CAUSE; StopAllL3Timer(pc); @@ -980,7 +980,7 @@ l3dss1_release_cmpl(struct l3_process *pc, u_char pr, void *arg) #ifdef EXT_BEARER_CAPS static u_char * -EncodeASyncParams(u_char * p, u_char si2) +EncodeASyncParams(u_char *p, u_char si2) { // 7c 06 88 90 21 42 00 bb p[0] = 0; @@ -1008,38 +1008,38 @@ EncodeASyncParams(u_char * p, u_char si2) p[2] += 3; switch (si2 & 0x07) { - case 0: - p[0] = 66; // 1200 bit/s + case 0: + p[0] = 66; // 1200 bit/s - break; - case 1: - p[0] = 88; // 1200/75 bit/s + break; + case 1: + p[0] = 88; // 1200/75 bit/s - break; - case 2: - p[0] = 87; // 75/1200 bit/s + break; + case 2: + p[0] = 87; // 75/1200 bit/s - break; - case 3: - p[0] = 67; // 2400 bit/s + break; + case 3: + p[0] = 67; // 2400 bit/s - break; - case 4: - p[0] = 69; // 4800 bit/s + break; + case 4: + p[0] = 69; // 4800 bit/s - break; - case 5: - p[0] = 72; // 9600 bit/s + break; + case 5: + p[0] = 72; // 9600 bit/s - break; - case 6: - p[0] = 73; // 14400 bit/s + break; + case 6: + p[0] = 73; // 14400 bit/s - break; - case 7: - p[0] = 75; // 19200 bit/s + break; + case 7: + p[0] = 75; // 19200 bit/s - break; + break; } return p + 3; } @@ -1049,84 +1049,84 @@ EncodeSyncParams(u_char si2, u_char ai) { switch (si2) { - case 0: - return ai + 2; // 1200 bit/s + case 0: + return ai + 2; // 1200 bit/s - case 1: - return ai + 24; // 1200/75 bit/s + case 1: + return ai + 24; // 1200/75 bit/s - case 2: - return ai + 23; // 75/1200 bit/s + case 2: + return ai + 23; // 75/1200 bit/s - case 3: - return ai + 3; // 2400 bit/s + case 3: + return ai + 3; // 2400 bit/s - case 4: - return ai + 5; // 4800 bit/s + case 4: + return ai + 5; // 4800 bit/s - case 5: - return ai + 8; // 9600 bit/s + case 5: + return ai + 8; // 9600 bit/s - case 6: - return ai + 9; // 14400 bit/s + case 6: + return ai + 9; // 14400 bit/s - case 7: - return ai + 11; // 19200 bit/s + case 7: + return ai + 11; // 19200 bit/s - case 8: - return ai + 14; // 48000 bit/s + case 8: + return ai + 14; // 48000 bit/s - case 9: - return ai + 15; // 56000 bit/s + case 9: + return ai + 15; // 56000 bit/s - case 15: - return ai + 40; // negotiate bit/s + case 15: + return ai + 40; // negotiate bit/s - default: - break; + default: + break; } return ai; } static u_char -DecodeASyncParams(u_char si2, u_char * p) +DecodeASyncParams(u_char si2, u_char *p) { u_char info; switch (p[5]) { - case 66: // 1200 bit/s + case 66: // 1200 bit/s - break; // si2 don't change + break; // si2 don't change - case 88: // 1200/75 bit/s + case 88: // 1200/75 bit/s - si2 += 1; - break; - case 87: // 75/1200 bit/s + si2 += 1; + break; + case 87: // 75/1200 bit/s - si2 += 2; - break; - case 67: // 2400 bit/s + si2 += 2; + break; + case 67: // 2400 bit/s - si2 += 3; - break; - case 69: // 4800 bit/s + si2 += 3; + break; + case 69: // 4800 bit/s - si2 += 4; - break; - case 72: // 9600 bit/s + si2 += 4; + break; + case 72: // 9600 bit/s - si2 += 5; - break; - case 73: // 14400 bit/s + si2 += 5; + break; + case 73: // 14400 bit/s - si2 += 6; - break; - case 75: // 19200 bit/s + si2 += 6; + break; + case 75: // 19200 bit/s - si2 += 7; - break; + si2 += 7; + break; } info = p[7] & 0x7f; @@ -1151,39 +1151,39 @@ DecodeSyncParams(u_char si2, u_char info) { info &= 0x7f; switch (info) { - case 40: // bit/s negotiation failed ai := 165 not 175! + case 40: // bit/s negotiation failed ai := 165 not 175! - return si2 + 15; - case 15: // 56000 bit/s failed, ai := 0 not 169 ! + return si2 + 15; + case 15: // 56000 bit/s failed, ai := 0 not 169 ! - return si2 + 9; - case 14: // 48000 bit/s + return si2 + 9; + case 14: // 48000 bit/s - return si2 + 8; - case 11: // 19200 bit/s + return si2 + 8; + case 11: // 19200 bit/s - return si2 + 7; - case 9: // 14400 bit/s + return si2 + 7; + case 9: // 14400 bit/s - return si2 + 6; - case 8: // 9600 bit/s + return si2 + 6; + case 8: // 9600 bit/s - return si2 + 5; - case 5: // 4800 bit/s + return si2 + 5; + case 5: // 4800 bit/s - return si2 + 4; - case 3: // 2400 bit/s + return si2 + 4; + case 3: // 2400 bit/s - return si2 + 3; - case 23: // 75/1200 bit/s + return si2 + 3; + case 23: // 75/1200 bit/s - return si2 + 2; - case 24: // 1200/75 bit/s + return si2 + 2; + case 24: // 1200/75 bit/s - return si2 + 1; - default: // 1200 bit/s + return si2 + 1; + default: // 1200 bit/s - return si2; + return si2; } } @@ -1194,20 +1194,20 @@ DecodeSI2(struct sk_buff *skb) if ((p = findie(skb->data, skb->len, 0x7c, 0))) { switch (p[4] & 0x0f) { - case 0x01: - if (p[1] == 0x04) // sync. Bitratenadaption + case 0x01: + if (p[1] == 0x04) // sync. Bitratenadaption - return DecodeSyncParams(160, p[5]); // V.110/X.30 + return DecodeSyncParams(160, p[5]); // V.110/X.30 - else if (p[1] == 0x06) // async. Bitratenadaption + else if (p[1] == 0x06) // async. Bitratenadaption - return DecodeASyncParams(192, p); // V.110/X.30 + return DecodeASyncParams(192, p); // V.110/X.30 - break; - case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption - if (p[1] > 3) - return DecodeSyncParams(176, p[5]); // V.120 - break; + break; + case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption + if (p[1] > 3) + return DecodeSyncParams(176, p[5]); // V.120 + break; } } return 0; @@ -1225,7 +1225,7 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, u_char *p = tmp; u_char channel = 0; - u_char send_keypad; + u_char send_keypad; u_char screen = 0x80; u_char *teln; u_char *msn; @@ -1237,7 +1237,7 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, teln = pc->para.setup.phone; #ifndef CONFIG_HISAX_NO_KEYPAD - send_keypad = (strchr(teln,'*') || strchr(teln,'#')) ? 1 : 0; + send_keypad = (strchr(teln, '*') || strchr(teln, '#')) ? 1 : 0; #else send_keypad = 0; #endif @@ -1272,7 +1272,7 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, while (*teln) *p++ = (*teln++) & 0x7F; } - + /* * What about info2? Mapping to High-Layer-Compatibility? */ @@ -1280,27 +1280,27 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, /* parse number for special things */ if (!isdigit(*teln)) { switch (0x5f & *teln) { - case 'C': - channel = 0x08; - case 'P': - channel |= 0x80; - teln++; - if (*teln == '1') - channel |= 0x01; - else - channel |= 0x02; - break; - case 'R': - screen = 0xA0; - break; - case 'D': - screen = 0x80; - break; - - default: - if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "Wrong MSN Code"); - break; + case 'C': + channel = 0x08; + case 'P': + channel |= 0x80; + teln++; + if (*teln == '1') + channel |= 0x01; + else + channel |= 0x02; + break; + case 'R': + screen = 0xA0; + break; + case 'D': + screen = 0x80; + break; + + default: + if (pc->debug & L3_DEB_WARN) + l3_debug(pc->st, "Wrong MSN Code"); + break; } teln++; } @@ -1350,15 +1350,15 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, } else sp++; } - - if (!send_keypad) { + + if (!send_keypad) { *p++ = IE_CALLED_PN; *p++ = strlen(teln) + 1; /* Classify as AnyPref. */ *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */ while (*teln) *p++ = *teln++ & 0x7f; - + if (sub) { *sub++ = '.'; *p++ = IE_CALLED_SUB; @@ -1368,7 +1368,7 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, while (*sub) *p++ = *sub++ & 0x7f; } - } + } #ifdef EXT_BEARER_CAPS if ((pc->para.setup.si2 >= 160) && (pc->para.setup.si2 <= 175)) { // sync. Bitratenadaption, V.110/X.30 @@ -1397,7 +1397,7 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, p = EncodeASyncParams(p, pc->para.setup.si2 - 192); #ifndef CONFIG_HISAX_NO_LLC } else { - switch (pc->para.setup.si1) { + switch (pc->para.setup.si1) { case 1: /* Telephony */ *p++ = IE_LLC; *p++ = 0x3; /* Length */ @@ -1413,7 +1413,7 @@ l3dss1_setup_req(struct l3_process *pc, u_char pr, *p++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */ *p++ = 0x90; /* Circuit-Mode 64kbps */ break; - } + } #endif } #endif @@ -1521,7 +1521,7 @@ l3dss1_disconnect(struct l3_process *pc, u_char pr, void *arg) cause = 96; else if (ret > 0) cause = 100; - } + } if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) l3dss1_parse_facility(pc->st, pc, pc->callref, p); ret = check_infoelements(pc, skb, ie_DISCONNECT); @@ -1533,10 +1533,10 @@ l3dss1_disconnect(struct l3_process *pc, u_char pr, void *arg) newl3state(pc, 12); if (cause) newl3state(pc, 19); - if (11 != ret) + if (11 != ret) pc->st->l3.l3l4(pc->st, CC_DISCONNECT | INDICATION, pc); - else if (!cause) - l3dss1_release_req(pc, pr, NULL); + else if (!cause) + l3dss1_release_req(pc, pr, NULL); if (cause) { l3dss1_message_cause(pc, MT_RELEASE, cause); L3AddTimer(&pc->timer, T308, CC_T308_1); @@ -1602,56 +1602,56 @@ l3dss1_setup(struct l3_process *pc, u_char pr, void *arg) else { pc->para.setup.si2 = 0; switch (p[2] & 0x7f) { - case 0x00: /* Speech */ - case 0x10: /* 3.1 Khz audio */ - pc->para.setup.si1 = 1; - break; - case 0x08: /* Unrestricted digital information */ - pc->para.setup.si1 = 7; + case 0x00: /* Speech */ + case 0x10: /* 3.1 Khz audio */ + pc->para.setup.si1 = 1; + break; + case 0x08: /* Unrestricted digital information */ + pc->para.setup.si1 = 7; /* JIM, 05.11.97 I wanna set service indicator 2 */ #ifdef EXT_BEARER_CAPS - pc->para.setup.si2 = DecodeSI2(skb); + pc->para.setup.si2 = DecodeSI2(skb); #endif - break; - case 0x09: /* Restricted digital information */ - pc->para.setup.si1 = 2; - break; - case 0x11: - /* Unrestr. digital information with - * tones/announcements ( or 7 kHz audio - */ - pc->para.setup.si1 = 3; - break; - case 0x18: /* Video */ - pc->para.setup.si1 = 4; - break; - default: - err = 2; - break; + break; + case 0x09: /* Restricted digital information */ + pc->para.setup.si1 = 2; + break; + case 0x11: + /* Unrestr. digital information with + * tones/announcements ( or 7 kHz audio + */ + pc->para.setup.si1 = 3; + break; + case 0x18: /* Video */ + pc->para.setup.si1 = 4; + break; + default: + err = 2; + break; } switch (p[3] & 0x7f) { - case 0x40: /* packed mode */ - pc->para.setup.si1 = 8; - break; - case 0x10: /* 64 kbit */ - case 0x11: /* 2*64 kbit */ - case 0x13: /* 384 kbit */ - case 0x15: /* 1536 kbit */ - case 0x17: /* 1920 kbit */ - pc->para.moderate = p[3] & 0x7f; - break; - default: - err = 3; - break; + case 0x40: /* packed mode */ + pc->para.setup.si1 = 8; + break; + case 0x10: /* 64 kbit */ + case 0x11: /* 2*64 kbit */ + case 0x13: /* 384 kbit */ + case 0x15: /* 1536 kbit */ + case 0x17: /* 1920 kbit */ + pc->para.moderate = p[3] & 0x7f; + break; + default: + err = 3; + break; } } if (pc->debug & L3_DEB_SI) l3_debug(pc->st, "SI=%d, AI=%d", - pc->para.setup.si1, pc->para.setup.si2); + pc->para.setup.si1, pc->para.setup.si2); if (err) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "setup with wrong bearer(l=%d:%x,%x)", - p[1], p[2], p[3]); + p[1], p[2], p[3]); pc->para.cause = 100; l3dss1_msg_without_setup(pc, pr, NULL); return; @@ -1672,17 +1672,17 @@ l3dss1_setup(struct l3_process *pc, u_char pr, void *arg) if ((3 == id) && (0x10 == pc->para.moderate)) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "setup with wrong chid %x", - id); + id); pc->para.cause = 100; l3dss1_msg_without_setup(pc, pr, NULL); return; } bcfound++; - } else - { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "setup without bchannel, call waiting"); - bcfound++; - } + } else + { if (pc->debug & L3_DEB_WARN) + l3_debug(pc->st, "setup without bchannel, call waiting"); + bcfound++; + } } else { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "setup with wrong chid ret %d", id); @@ -1757,7 +1757,7 @@ static void l3dss1_disconnect_req(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb; - u_char tmp[16+40]; + u_char tmp[16 + 40]; u_char *p = tmp; int l; u_char cause = 16; @@ -1774,14 +1774,14 @@ l3dss1_disconnect_req(struct l3_process *pc, u_char pr, void *arg) *p++ = 0x80; *p++ = cause | 0x80; - if (pc->prot.dss1.uus1_data[0]) - { *p++ = IE_USER_USER; /* UUS info element */ - *p++ = strlen(pc->prot.dss1.uus1_data) + 1; - *p++ = 0x04; /* IA5 chars */ - strcpy(p,pc->prot.dss1.uus1_data); - p += strlen(pc->prot.dss1.uus1_data); - pc->prot.dss1.uus1_data[0] = '\0'; - } + if (pc->prot.dss1.uus1_data[0]) + { *p++ = IE_USER_USER; /* UUS info element */ + *p++ = strlen(pc->prot.dss1.uus1_data) + 1; + *p++ = 0x04; /* IA5 chars */ + strcpy(p, pc->prot.dss1.uus1_data); + p += strlen(pc->prot.dss1.uus1_data); + pc->prot.dss1.uus1_data[0] = '\0'; + } l = p - tmp; if (!(skb = l3_alloc_skb(l))) @@ -1796,12 +1796,12 @@ static void l3dss1_setup_rsp(struct l3_process *pc, u_char pr, void *arg) { - if (!pc->para.bchannel) - { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "D-chan connect for waiting call"); - l3dss1_disconnect_req(pc, pr, arg); - return; - } + if (!pc->para.bchannel) + { if (pc->debug & L3_DEB_WARN) + l3_debug(pc->st, "D-chan connect for waiting call"); + l3dss1_disconnect_req(pc, pr, arg); + return; + } newl3state(pc, 8); l3dss1_message(pc, MT_CONNECT); L3DelTimer(&pc->timer); @@ -1860,26 +1860,26 @@ l3dss1_release(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb = arg; u_char *p; - int ret, cause=0; + int ret, cause = 0; StopAllL3Timer(pc); - if ((ret = l3dss1_get_cause(pc, skb))>0) { + if ((ret = l3dss1_get_cause(pc, skb)) > 0) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "REL get_cause ret(%d)", ret); - } else if (ret<0) + } else if (ret < 0) pc->para.cause = NO_CAUSE; if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) { l3dss1_parse_facility(pc->st, pc, pc->callref, p); } - if ((ret<0) && (pc->state != 11)) + if ((ret < 0) && (pc->state != 11)) cause = 96; - else if (ret>0) + else if (ret > 0) cause = 100; ret = check_infoelements(pc, skb, ie_RELEASE); if (ERR_IE_COMPREHENSION == ret) cause = 96; else if ((ERR_IE_UNRECOGNIZED == ret) && (!cause)) - cause = 99; + cause = 99; if (cause) l3dss1_message_cause(pc, MT_RELEASE_COMPLETE, cause); else @@ -1894,10 +1894,10 @@ l3dss1_alert_req(struct l3_process *pc, u_char pr, void *arg) { newl3state(pc, 7); - if (!pc->prot.dss1.uus1_data[0]) + if (!pc->prot.dss1.uus1_data[0]) l3dss1_message(pc, MT_ALERTING); else - l3dss1_msg_with_uus(pc, MT_ALERTING); + l3dss1_msg_with_uus(pc, MT_ALERTING); } static void @@ -1906,12 +1906,12 @@ l3dss1_proceed_req(struct l3_process *pc, u_char pr, { newl3state(pc, 9); l3dss1_message(pc, MT_CALL_PROCEEDING); - pc->st->l3.l3l4(pc->st, CC_PROCEED_SEND | INDICATION, pc); + pc->st->l3.l3l4(pc->st, CC_PROCEED_SEND | INDICATION, pc); } static void l3dss1_setup_ack_req(struct l3_process *pc, u_char pr, - void *arg) + void *arg) { newl3state(pc, 25); L3DelTimer(&pc->timer); @@ -1925,22 +1925,22 @@ l3dss1_setup_ack_req(struct l3_process *pc, u_char pr, static void l3dss1_deliver_display(struct l3_process *pc, int pr, u_char *infp) { u_char len; - isdn_ctrl ic; + isdn_ctrl ic; struct IsdnCardState *cs; - char *p; + char *p; - if (*infp++ != IE_DISPLAY) return; - if ((len = *infp++) > 80) return; /* total length <= 82 */ + if (*infp++ != IE_DISPLAY) return; + if ((len = *infp++) > 80) return; /* total length <= 82 */ if (!pc->chan) return; - p = ic.parm.display; - while (len--) - *p++ = *infp++; + p = ic.parm.display; + while (len--) + *p++ = *infp++; *p = '\0'; ic.command = ISDN_STAT_DISPLAY; cs = pc->st->l1.hardware; ic.driver = cs->myid; - ic.arg = pc->chan->chan; + ic.arg = pc->chan->chan; cs->iif.statcallb(&ic); } /* l3dss1_deliver_display */ @@ -1958,37 +1958,37 @@ l3dss1_progress(struct l3_process *pc, u_char pr, void *arg) pc->para.cause = 100; } else if (!(p[2] & 0x70)) { switch (p[2]) { - case 0x80: + case 0x80: + case 0x81: + case 0x82: + case 0x84: + case 0x85: + case 0x87: + case 0x8a: + switch (p[3]) { case 0x81: case 0x82: + case 0x83: case 0x84: - case 0x85: - case 0x87: - case 0x8a: - switch (p[3]) { - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x88: - break; - default: - err = 2; - pc->para.cause = 100; - break; - } + case 0x88: break; default: - err = 3; + err = 2; pc->para.cause = 100; break; + } + break; + default: + err = 3; + pc->para.cause = 100; + break; } } } else { pc->para.cause = 96; err = 4; } - if (err) { + if (err) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "progress error %d", err); l3dss1_status_send(pc, pr, NULL); @@ -2015,21 +2015,21 @@ l3dss1_notify(struct l3_process *pc, u_char pr, void *arg) pc->para.cause = 100; } else { switch (p[2]) { - case 0x80: - case 0x81: - case 0x82: - break; - default: - pc->para.cause = 100; - err = 2; - break; + case 0x80: + case 0x81: + case 0x82: + break; + default: + pc->para.cause = 100; + err = 2; + break; } } } else { pc->para.cause = 96; err = 3; } - if (err) { + if (err) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "notify error %d", err); l3dss1_status_send(pc, pr, NULL); @@ -2052,7 +2052,7 @@ l3dss1_status_enq(struct l3_process *pc, u_char pr, void *arg) ret = check_infoelements(pc, skb, ie_STATUS_ENQUIRY); l3dss1_std_ie_err(pc, ret); pc->para.cause = 30; /* response to STATUS_ENQUIRY */ - l3dss1_status_send(pc, pr, NULL); + l3dss1_status_send(pc, pr, NULL); } static void @@ -2086,68 +2086,68 @@ static void l3dss1_redir_req(struct l3_process *pc, u_char pr, void *arg) struct sk_buff *skb; u_char tmp[128]; u_char *p = tmp; - u_char *subp; - u_char len_phone = 0; - u_char len_sub = 0; - int l; - - - strcpy(pc->prot.dss1.uus1_data,pc->chan->setup.eazmsn); /* copy uus element if available */ - if (!pc->chan->setup.phone[0]) - { pc->para.cause = -1; - l3dss1_disconnect_req(pc,pr,arg); /* disconnect immediately */ - return; - } /* only uus */ - - if (pc->prot.dss1.invoke_id) - free_invoke_id(pc->st,pc->prot.dss1.invoke_id); - - if (!(pc->prot.dss1.invoke_id = new_invoke_id(pc->st))) - return; - - MsgHead(p, pc->callref, MT_FACILITY); - - for (subp = pc->chan->setup.phone; (*subp) && (*subp != '.'); subp++) len_phone++; /* len of phone number */ - if (*subp++ == '.') len_sub = strlen(subp) + 2; /* length including info subaddress element */ + u_char *subp; + u_char len_phone = 0; + u_char len_sub = 0; + int l; + + + strcpy(pc->prot.dss1.uus1_data, pc->chan->setup.eazmsn); /* copy uus element if available */ + if (!pc->chan->setup.phone[0]) + { pc->para.cause = -1; + l3dss1_disconnect_req(pc, pr, arg); /* disconnect immediately */ + return; + } /* only uus */ + + if (pc->prot.dss1.invoke_id) + free_invoke_id(pc->st, pc->prot.dss1.invoke_id); + + if (!(pc->prot.dss1.invoke_id = new_invoke_id(pc->st))) + return; + + MsgHead(p, pc->callref, MT_FACILITY); + + for (subp = pc->chan->setup.phone; (*subp) && (*subp != '.'); subp++) len_phone++; /* len of phone number */ + if (*subp++ == '.') len_sub = strlen(subp) + 2; /* length including info subaddress element */ *p++ = 0x1c; /* Facility info element */ - *p++ = len_phone + len_sub + 2 + 2 + 8 + 3 + 3; /* length of element */ - *p++ = 0x91; /* remote operations protocol */ - *p++ = 0xa1; /* invoke component */ - - *p++ = len_phone + len_sub + 2 + 2 + 8 + 3; /* length of data */ - *p++ = 0x02; /* invoke id tag, integer */ + *p++ = len_phone + len_sub + 2 + 2 + 8 + 3 + 3; /* length of element */ + *p++ = 0x91; /* remote operations protocol */ + *p++ = 0xa1; /* invoke component */ + + *p++ = len_phone + len_sub + 2 + 2 + 8 + 3; /* length of data */ + *p++ = 0x02; /* invoke id tag, integer */ *p++ = 0x01; /* length */ - *p++ = pc->prot.dss1.invoke_id; /* invoke id */ - *p++ = 0x02; /* operation value tag, integer */ + *p++ = pc->prot.dss1.invoke_id; /* invoke id */ + *p++ = 0x02; /* operation value tag, integer */ *p++ = 0x01; /* length */ - *p++ = 0x0D; /* Call Deflect */ - - *p++ = 0x30; /* sequence phone number */ - *p++ = len_phone + 2 + 2 + 3 + len_sub; /* length */ - - *p++ = 0x30; /* Deflected to UserNumber */ - *p++ = len_phone+2+len_sub; /* length */ - *p++ = 0x80; /* NumberDigits */ + *p++ = 0x0D; /* Call Deflect */ + + *p++ = 0x30; /* sequence phone number */ + *p++ = len_phone + 2 + 2 + 3 + len_sub; /* length */ + + *p++ = 0x30; /* Deflected to UserNumber */ + *p++ = len_phone + 2 + len_sub; /* length */ + *p++ = 0x80; /* NumberDigits */ *p++ = len_phone; /* length */ - for (l = 0; l < len_phone; l++) - *p++ = pc->chan->setup.phone[l]; + for (l = 0; l < len_phone; l++) + *p++ = pc->chan->setup.phone[l]; - if (len_sub) - { *p++ = 0x04; /* called party subaddress */ - *p++ = len_sub - 2; - while (*subp) *p++ = *subp++; - } + if (len_sub) + { *p++ = 0x04; /* called party subaddress */ + *p++ = len_sub - 2; + while (*subp) *p++ = *subp++; + } - *p++ = 0x01; /* screening identifier */ - *p++ = 0x01; - *p++ = pc->chan->setup.screen; + *p++ = 0x01; /* screening identifier */ + *p++ = 0x01; + *p++ = pc->chan->setup.screen; l = p - tmp; if (!(skb = l3_alloc_skb(l))) return; memcpy(skb_put(skb, l), tmp, l); - l3_msg(pc->st, DL_DATA | REQUEST, skb); + l3_msg(pc->st, DL_DATA | REQUEST, skb); } /* l3dss1_redir_req */ /********************************************/ @@ -2155,8 +2155,8 @@ static void l3dss1_redir_req(struct l3_process *pc, u_char pr, void *arg) /********************************************/ static void l3dss1_redir_req_early(struct l3_process *pc, u_char pr, void *arg) { - l3dss1_proceed_req(pc,pr,arg); - l3dss1_redir_req(pc,pr,arg); + l3dss1_proceed_req(pc, pr, arg); + l3dss1_redir_req(pc, pr, arg); } /* l3dss1_redir_req_early */ /***********************************************/ @@ -2166,108 +2166,108 @@ static void l3dss1_redir_req_early(struct l3_process *pc, u_char pr, void *arg) /***********************************************/ static int l3dss1_cmd_global(struct PStack *st, isdn_ctrl *ic) { u_char id; - u_char temp[265]; - u_char *p = temp; - int i, l, proc_len; - struct sk_buff *skb; - struct l3_process *pc = NULL; - - switch (ic->arg) - { case DSS1_CMD_INVOKE: - if (ic->parm.dss1_io.datalen < 0) return(-2); /* invalid parameter */ - - for (proc_len = 1, i = ic->parm.dss1_io.proc >> 8; i; i++) - i = i >> 8; /* add one byte */ - l = ic->parm.dss1_io.datalen + proc_len + 8; /* length excluding ie header */ - if (l > 255) - return(-2); /* too long */ - - if (!(id = new_invoke_id(st))) - return(0); /* first get a invoke id -> return if no available */ - - i = -1; - MsgHead(p, i, MT_FACILITY); /* build message head */ - *p++ = 0x1C; /* Facility IE */ - *p++ = l; /* length of ie */ - *p++ = 0x91; /* remote operations */ - *p++ = 0xA1; /* invoke */ - *p++ = l - 3; /* length of invoke */ - *p++ = 0x02; /* invoke id tag */ - *p++ = 0x01; /* length is 1 */ - *p++ = id; /* invoke id */ - *p++ = 0x02; /* operation */ - *p++ = proc_len; /* length of operation */ - - for (i = proc_len; i; i--) - *p++ = (ic->parm.dss1_io.proc >> (i-1)) & 0xFF; - memcpy(p, ic->parm.dss1_io.data, ic->parm.dss1_io.datalen); /* copy data */ - l = (p - temp) + ic->parm.dss1_io.datalen; /* total length */ - - if (ic->parm.dss1_io.timeout > 0) - if (!(pc = dss1_new_l3_process(st, -1))) - { free_invoke_id(st, id); - return(-2); - } - pc->prot.dss1.ll_id = ic->parm.dss1_io.ll_id; /* remember id */ - pc->prot.dss1.proc = ic->parm.dss1_io.proc; /* and procedure */ - - if (!(skb = l3_alloc_skb(l))) - { free_invoke_id(st, id); - if (pc) dss1_release_l3_process(pc); - return(-2); - } - memcpy(skb_put(skb, l), temp, l); - - if (pc) - { pc->prot.dss1.invoke_id = id; /* remember id */ - L3AddTimer(&pc->timer, ic->parm.dss1_io.timeout, CC_TDSS1_IO | REQUEST); - } - - l3_msg(st, DL_DATA | REQUEST, skb); - ic->parm.dss1_io.hl_id = id; /* return id */ - return(0); - - case DSS1_CMD_INVOKE_ABORT: - if ((pc = l3dss1_search_dummy_proc(st, ic->parm.dss1_io.hl_id))) - { L3DelTimer(&pc->timer); /* remove timer */ - dss1_release_l3_process(pc); - return(0); - } - else - { l3_debug(st, "l3dss1_cmd_global abort unknown id"); - return(-2); - } - break; - - default: - l3_debug(st, "l3dss1_cmd_global unknown cmd 0x%lx", ic->arg); - return(-1); - } /* switch ic-> arg */ - return(-1); + u_char temp[265]; + u_char *p = temp; + int i, l, proc_len; + struct sk_buff *skb; + struct l3_process *pc = NULL; + + switch (ic->arg) + { case DSS1_CMD_INVOKE: + if (ic->parm.dss1_io.datalen < 0) return (-2); /* invalid parameter */ + + for (proc_len = 1, i = ic->parm.dss1_io.proc >> 8; i; i++) + i = i >> 8; /* add one byte */ + l = ic->parm.dss1_io.datalen + proc_len + 8; /* length excluding ie header */ + if (l > 255) + return (-2); /* too long */ + + if (!(id = new_invoke_id(st))) + return (0); /* first get a invoke id -> return if no available */ + + i = -1; + MsgHead(p, i, MT_FACILITY); /* build message head */ + *p++ = 0x1C; /* Facility IE */ + *p++ = l; /* length of ie */ + *p++ = 0x91; /* remote operations */ + *p++ = 0xA1; /* invoke */ + *p++ = l - 3; /* length of invoke */ + *p++ = 0x02; /* invoke id tag */ + *p++ = 0x01; /* length is 1 */ + *p++ = id; /* invoke id */ + *p++ = 0x02; /* operation */ + *p++ = proc_len; /* length of operation */ + + for (i = proc_len; i; i--) + *p++ = (ic->parm.dss1_io.proc >> (i - 1)) & 0xFF; + memcpy(p, ic->parm.dss1_io.data, ic->parm.dss1_io.datalen); /* copy data */ + l = (p - temp) + ic->parm.dss1_io.datalen; /* total length */ + + if (ic->parm.dss1_io.timeout > 0) + if (!(pc = dss1_new_l3_process(st, -1))) + { free_invoke_id(st, id); + return (-2); + } + pc->prot.dss1.ll_id = ic->parm.dss1_io.ll_id; /* remember id */ + pc->prot.dss1.proc = ic->parm.dss1_io.proc; /* and procedure */ + + if (!(skb = l3_alloc_skb(l))) + { free_invoke_id(st, id); + if (pc) dss1_release_l3_process(pc); + return (-2); + } + memcpy(skb_put(skb, l), temp, l); + + if (pc) + { pc->prot.dss1.invoke_id = id; /* remember id */ + L3AddTimer(&pc->timer, ic->parm.dss1_io.timeout, CC_TDSS1_IO | REQUEST); + } + + l3_msg(st, DL_DATA | REQUEST, skb); + ic->parm.dss1_io.hl_id = id; /* return id */ + return (0); + + case DSS1_CMD_INVOKE_ABORT: + if ((pc = l3dss1_search_dummy_proc(st, ic->parm.dss1_io.hl_id))) + { L3DelTimer(&pc->timer); /* remove timer */ + dss1_release_l3_process(pc); + return (0); + } + else + { l3_debug(st, "l3dss1_cmd_global abort unknown id"); + return (-2); + } + break; + + default: + l3_debug(st, "l3dss1_cmd_global unknown cmd 0x%lx", ic->arg); + return (-1); + } /* switch ic-> arg */ + return (-1); } /* l3dss1_cmd_global */ -static void +static void l3dss1_io_timer(struct l3_process *pc) { isdn_ctrl ic; - struct IsdnCardState *cs = pc->st->l1.hardware; + struct IsdnCardState *cs = pc->st->l1.hardware; - L3DelTimer(&pc->timer); /* remove timer */ + L3DelTimer(&pc->timer); /* remove timer */ - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = DSS1_STAT_INVOKE_ERR; - ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id; - ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id; - ic.parm.dss1_io.proc = pc->prot.dss1.proc; - ic.parm.dss1_io.timeout= -1; - ic.parm.dss1_io.datalen = 0; - ic.parm.dss1_io.data = NULL; - free_invoke_id(pc->st, pc->prot.dss1.invoke_id); - pc->prot.dss1.invoke_id = 0; /* reset id */ + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = DSS1_STAT_INVOKE_ERR; + ic.parm.dss1_io.hl_id = pc->prot.dss1.invoke_id; + ic.parm.dss1_io.ll_id = pc->prot.dss1.ll_id; + ic.parm.dss1_io.proc = pc->prot.dss1.proc; + ic.parm.dss1_io.timeout = -1; + ic.parm.dss1_io.datalen = 0; + ic.parm.dss1_io.data = NULL; + free_invoke_id(pc->st, pc->prot.dss1.invoke_id); + pc->prot.dss1.invoke_id = 0; /* reset id */ - cs->iif.statcallb(&ic); + cs->iif.statcallb(&ic); - dss1_release_l3_process(pc); + dss1_release_l3_process(pc); } /* l3dss1_io_timer */ static void @@ -2437,12 +2437,12 @@ l3dss1_status(struct l3_process *pc, u_char pr, void *arg) { u_char *p; struct sk_buff *skb = arg; - int ret; + int ret; u_char cause = 0, callState = 0; - + if ((ret = l3dss1_get_cause(pc, skb))) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "STATUS get_cause ret(%d)",ret); + l3_debug(pc->st, "STATUS get_cause ret(%d)", ret); if (ret < 0) cause = 96; else if (ret > 0) @@ -2467,9 +2467,9 @@ l3dss1_status(struct l3_process *pc, u_char pr, void *arg) } if (cause) { u_char tmp; - + if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "STATUS error(%d/%d)",ret,cause); + l3_debug(pc->st, "STATUS error(%d/%d)", ret, cause); tmp = pc->para.cause; pc->para.cause = cause; l3dss1_status_send(pc, 0, NULL); @@ -2495,10 +2495,10 @@ l3dss1_facility(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb = arg; int ret; - + ret = check_infoelements(pc, skb, ie_FACILITY); l3dss1_std_ie_err(pc, ret); - { + { u_char *p; if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) l3dss1_parse_facility(pc->st, pc, pc->callref, p); @@ -2547,7 +2547,7 @@ l3dss1_suspend_ack(struct l3_process *pc, u_char pr, void *arg) /* We don't handle suspend_ack for IE errors now */ if ((ret = check_infoelements(pc, skb, ie_SUSPEND_ACKNOWLEDGE))) if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "SUSPACK check ie(%d)",ret); + l3_debug(pc->st, "SUSPACK check ie(%d)", ret); dss1_release_l3_process(pc); } @@ -2559,8 +2559,8 @@ l3dss1_suspend_rej(struct l3_process *pc, u_char pr, void *arg) if ((ret = l3dss1_get_cause(pc, skb))) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "SUSP_REJ get_cause ret(%d)",ret); - if (ret < 0) + l3_debug(pc->st, "SUSP_REJ get_cause ret(%d)", ret); + if (ret < 0) pc->para.cause = 96; else pc->para.cause = 100; @@ -2651,8 +2651,8 @@ l3dss1_resume_rej(struct l3_process *pc, u_char pr, void *arg) if ((ret = l3dss1_get_cause(pc, skb))) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "RES_REJ get_cause ret(%d)",ret); - if (ret < 0) + l3_debug(pc->st, "RES_REJ get_cause ret(%d)", ret); + if (ret < 0) pc->para.cause = 96; else pc->para.cause = 100; @@ -2729,36 +2729,36 @@ l3dss1_global_restart(struct l3_process *pc, u_char pr, void *arg) static void l3dss1_dl_reset(struct l3_process *pc, u_char pr, void *arg) { - pc->para.cause = 0x29; /* Temporary failure */ - pc->para.loc = 0; - l3dss1_disconnect_req(pc, pr, NULL); - pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc); + pc->para.cause = 0x29; /* Temporary failure */ + pc->para.loc = 0; + l3dss1_disconnect_req(pc, pr, NULL); + pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc); } static void l3dss1_dl_release(struct l3_process *pc, u_char pr, void *arg) { - newl3state(pc, 0); - pc->para.cause = 0x1b; /* Destination out of order */ - pc->para.loc = 0; - pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc); - release_l3_process(pc); + newl3state(pc, 0); + pc->para.cause = 0x1b; /* Destination out of order */ + pc->para.loc = 0; + pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc); + release_l3_process(pc); } static void l3dss1_dl_reestablish(struct l3_process *pc, u_char pr, void *arg) { - L3DelTimer(&pc->timer); - L3AddTimer(&pc->timer, T309, CC_T309); - l3_msg(pc->st, DL_ESTABLISH | REQUEST, NULL); + L3DelTimer(&pc->timer); + L3AddTimer(&pc->timer, T309, CC_T309); + l3_msg(pc->st, DL_ESTABLISH | REQUEST, NULL); } - + static void l3dss1_dl_reest_status(struct l3_process *pc, u_char pr, void *arg) { L3DelTimer(&pc->timer); - - pc->para.cause = 0x1F; /* normal, unspecified */ + + pc->para.cause = 0x1F; /* normal, unspecified */ l3dss1_status_send(pc, 0, NULL); } @@ -2791,12 +2791,12 @@ static struct stateentry downstatelist[] = CC_SETUP | RESPONSE, l3dss1_setup_rsp}, {SBIT(10), CC_SUSPEND | REQUEST, l3dss1_suspend_req}, - {SBIT(7) | SBIT(9) | SBIT(25), - CC_REDIR | REQUEST, l3dss1_redir_req}, - {SBIT(6), - CC_REDIR | REQUEST, l3dss1_redir_req_early}, - {SBIT(9) | SBIT(25), - CC_DISCONNECT | REQUEST, l3dss1_disconnect_req}, + {SBIT(7) | SBIT(9) | SBIT(25), + CC_REDIR | REQUEST, l3dss1_redir_req}, + {SBIT(6), + CC_REDIR | REQUEST, l3dss1_redir_req_early}, + {SBIT(9) | SBIT(25), + CC_DISCONNECT | REQUEST, l3dss1_disconnect_req}, {SBIT(25), CC_T302, l3dss1_t302}, {SBIT(1), @@ -2880,20 +2880,20 @@ static struct stateentry globalmes_list[] = {SBIT(0), MT_RESTART, l3dss1_global_restart}, /* {SBIT(1), - MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack}, + MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack}, */ }; static struct stateentry manstatelist[] = { - {SBIT(2), - DL_ESTABLISH | INDICATION, l3dss1_dl_reset}, - {SBIT(10), - DL_ESTABLISH | CONFIRM, l3dss1_dl_reest_status}, - {SBIT(10), - DL_RELEASE | INDICATION, l3dss1_dl_reestablish}, - {ALL_STATES, - DL_RELEASE | INDICATION, l3dss1_dl_release}, + {SBIT(2), + DL_ESTABLISH | INDICATION, l3dss1_dl_reset}, + {SBIT(10), + DL_ESTABLISH | CONFIRM, l3dss1_dl_reest_status}, + {SBIT(10), + DL_RELEASE | INDICATION, l3dss1_dl_reestablish}, + {ALL_STATES, + DL_RELEASE | INDICATION, l3dss1_dl_release}, }; /* *INDENT-ON* */ @@ -2916,13 +2916,13 @@ global_handler(struct PStack *st, int mt, struct sk_buff *skb) if (i == ARRAY_SIZE(globalmes_list)) { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "dss1 global state %d mt %x unhandled", - proc->state, mt); + proc->state, mt); } MsgHead(p, proc->callref, MT_STATUS); *p++ = IE_CAUSE; *p++ = 0x2; *p++ = 0x80; - *p++ = 81 |0x80; /* invalid cr */ + *p++ = 81 | 0x80; /* invalid cr */ *p++ = 0x14; /* CallState */ *p++ = 0x1; *p++ = proc->state & 0x3f; @@ -2934,7 +2934,7 @@ global_handler(struct PStack *st, int mt, struct sk_buff *skb) } else { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "dss1 global %d mt %x", - proc->state, mt); + proc->state, mt); } globalmes_list[i].rout(proc, mt, skb); } @@ -2950,19 +2950,19 @@ dss1up(struct PStack *st, int pr, void *arg) struct l3_process *proc; switch (pr) { - case (DL_DATA | INDICATION): - case (DL_UNIT_DATA | INDICATION): - break; - case (DL_ESTABLISH | CONFIRM): - case (DL_ESTABLISH | INDICATION): - case (DL_RELEASE | INDICATION): - case (DL_RELEASE | CONFIRM): - l3_msg(st, pr, arg); - return; - break; - default: - printk(KERN_ERR "HiSax dss1up unknown pr=%04x\n", pr); - return; + case (DL_DATA | INDICATION): + case (DL_UNIT_DATA | INDICATION): + break; + case (DL_ESTABLISH | CONFIRM): + case (DL_ESTABLISH | INDICATION): + case (DL_RELEASE | INDICATION): + case (DL_RELEASE | CONFIRM): + l3_msg(st, pr, arg); + return; + break; + default: + printk(KERN_ERR "HiSax dss1up unknown pr=%04x\n", pr); + return; } if (skb->len < 3) { l3_debug(st, "dss1up frame too short(%d)", skb->len); @@ -2996,17 +2996,17 @@ dss1up(struct PStack *st, int pr, void *arg) } else if (cr == -1) { /* Dummy Callref */ if (mt == MT_FACILITY) if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) { - l3dss1_parse_facility(st, NULL, - (pr == (DL_DATA | INDICATION)) ? -1 : -2, p); + l3dss1_parse_facility(st, NULL, + (pr == (DL_DATA | INDICATION)) ? -1 : -2, p); dev_kfree_skb(skb); - return; + return; } if (st->l3.debug & L3_DEB_WARN) l3_debug(st, "dss1up dummy Callref (no facility msg or ie)"); dev_kfree_skb(skb); return; - } else if ((((skb->data[1] & 0x0f) == 1) && (0==(cr & 0x7f))) || - (((skb->data[1] & 0x0f) == 2) && (0==(cr & 0x7fff)))) { /* Global CallRef */ + } else if ((((skb->data[1] & 0x0f) == 1) && (0 == (cr & 0x7f))) || + (((skb->data[1] & 0x0f) == 2) && (0 == (cr & 0x7fff)))) { /* Global CallRef */ if (st->l3.debug & L3_DEB_STATE) l3_debug(st, "dss1up Global CallRef"); global_handler(st, mt, skb); @@ -3084,8 +3084,8 @@ dss1up(struct PStack *st, int pr, void *arg) dev_kfree_skb(skb); return; } - if ((p = findie(skb->data, skb->len, IE_DISPLAY, 0)) != NULL) - l3dss1_deliver_display(proc, pr, p); /* Display IE included */ + if ((p = findie(skb->data, skb->len, IE_DISPLAY, 0)) != NULL) + l3dss1_deliver_display(proc, pr, p); /* Display IE included */ for (i = 0; i < ARRAY_SIZE(datastatelist); i++) if ((mt == datastatelist[i].primitive) && ((1 << proc->state) & datastatelist[i].state)) @@ -3093,8 +3093,8 @@ dss1up(struct PStack *st, int pr, void *arg) if (i == ARRAY_SIZE(datastatelist)) { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "dss1up%sstate %d mt %#x unhandled", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", - proc->state, mt); + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", + proc->state, mt); } if ((MT_RELEASE_COMPLETE != mt) && (MT_RELEASE != mt)) { proc->para.cause = 101; @@ -3103,8 +3103,8 @@ dss1up(struct PStack *st, int pr, void *arg) } else { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "dss1up%sstate %d mt %x", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", - proc->state, mt); + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", + proc->state, mt); } datastatelist[i].rout(proc, pr, skb); } @@ -3140,10 +3140,10 @@ dss1down(struct PStack *st, int pr, void *arg) return; } - if ( pr == (CC_TDSS1_IO | REQUEST)) { - l3dss1_io_timer(proc); /* timer expires */ + if (pr == (CC_TDSS1_IO | REQUEST)) { + l3dss1_io_timer(proc); /* timer expires */ return; - } + } for (i = 0; i < ARRAY_SIZE(downstatelist); i++) if ((pr == downstatelist[i].primitive) && @@ -3152,12 +3152,12 @@ dss1down(struct PStack *st, int pr, void *arg) if (i == ARRAY_SIZE(downstatelist)) { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "dss1down state %d prim %#x unhandled", - proc->state, pr); + proc->state, pr); } } else { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "dss1down state %d prim %#x", - proc->state, pr); + proc->state, pr); } downstatelist[i].rout(proc, pr, arg); } @@ -3166,31 +3166,31 @@ dss1down(struct PStack *st, int pr, void *arg) static void dss1man(struct PStack *st, int pr, void *arg) { - int i; - struct l3_process *proc = arg; - - if (!proc) { - printk(KERN_ERR "HiSax dss1man without proc pr=%04x\n", pr); - return; - } - for (i = 0; i < ARRAY_SIZE(manstatelist); i++) - if ((pr == manstatelist[i].primitive) && - ((1 << proc->state) & manstatelist[i].state)) - break; - if (i == ARRAY_SIZE(manstatelist)) { - if (st->l3.debug & L3_DEB_STATE) { - l3_debug(st, "cr %d dss1man state %d prim %#x unhandled", - proc->callref & 0x7f, proc->state, pr); - } - } else { - if (st->l3.debug & L3_DEB_STATE) { - l3_debug(st, "cr %d dss1man state %d prim %#x", - proc->callref & 0x7f, proc->state, pr); - } - manstatelist[i].rout(proc, pr, arg); - } -} - + int i; + struct l3_process *proc = arg; + + if (!proc) { + printk(KERN_ERR "HiSax dss1man without proc pr=%04x\n", pr); + return; + } + for (i = 0; i < ARRAY_SIZE(manstatelist); i++) + if ((pr == manstatelist[i].primitive) && + ((1 << proc->state) & manstatelist[i].state)) + break; + if (i == ARRAY_SIZE(manstatelist)) { + if (st->l3.debug & L3_DEB_STATE) { + l3_debug(st, "cr %d dss1man state %d prim %#x unhandled", + proc->callref & 0x7f, proc->state, pr); + } + } else { + if (st->l3.debug & L3_DEB_STATE) { + l3_debug(st, "cr %d dss1man state %d prim %#x", + proc->callref & 0x7f, proc->state, pr); + } + manstatelist[i].rout(proc, pr, arg); + } +} + void setstack_dss1(struct PStack *st) { @@ -3205,8 +3205,8 @@ setstack_dss1(struct PStack *st) st->prot.dss1.last_invoke_id = 0; st->prot.dss1.invoke_used[0] = 1; /* Bit 0 must always be set to 1 */ i = 1; - while (i < 32) - st->prot.dss1.invoke_used[i++] = 0; + while (i < 32) + st->prot.dss1.invoke_used[i++] = 0; if (!(st->l3.global = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) { printk(KERN_ERR "HiSax can't get memory for dss1 global CR\n"); @@ -3217,7 +3217,7 @@ setstack_dss1(struct PStack *st) st->l3.global->debug = L3_DEB_WARN; st->l3.global->st = st; st->l3.global->N303 = 1; - st->l3.global->prot.dss1.invoke_id = 0; + st->l3.global->prot.dss1.invoke_id = 0; L3InitTimer(st->l3.global, &st->l3.global->timer); } diff --git a/drivers/isdn/hisax/l3dss1.h b/drivers/isdn/hisax/l3dss1.h index 6da47f05ef2a..a7807e8a94f1 100644 --- a/drivers/isdn/hisax/l3dss1.h +++ b/drivers/isdn/hisax/l3dss1.h @@ -107,18 +107,18 @@ /* l3dss1 specific data in l3 process */ typedef struct - { unsigned char invoke_id; /* used invoke id in remote ops, 0 = not active */ - ulong ll_id; /* remebered ll id */ - u8 remote_operation; /* handled remote operation, 0 = not active */ - int proc; /* rememered procedure */ - ulong remote_result; /* result of remote operation for statcallb */ - char uus1_data[35]; /* data send during alerting or disconnect */ - } dss1_proc_priv; +{ unsigned char invoke_id; /* used invoke id in remote ops, 0 = not active */ + ulong ll_id; /* remebered ll id */ + u8 remote_operation; /* handled remote operation, 0 = not active */ + int proc; /* rememered procedure */ + ulong remote_result; /* result of remote operation for statcallb */ + char uus1_data[35]; /* data send during alerting or disconnect */ +} dss1_proc_priv; /* l3dss1 specific data in protocol stack */ typedef struct - { unsigned char last_invoke_id; /* last used value for invoking */ - unsigned char invoke_used[32]; /* 256 bits for 256 values */ - } dss1_stk_priv; +{ unsigned char last_invoke_id; /* last used value for invoking */ + unsigned char invoke_used[32]; /* 256 bits for 256 values */ +} dss1_stk_priv; #endif /* only l3dss1_process */ diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c index 092dcbb39d94..0df6691d045c 100644 --- a/drivers/isdn/hisax/l3ni1.c +++ b/drivers/isdn/hisax/l3ni1.c @@ -4,14 +4,14 @@ * * Author Matt Henderson & Guy Ellis * Copyright by Traverse Technologies Pty Ltd, www.travers.com.au - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * - * 2000.6.6 Initial implementation of routines for US NI1 - * Layer 3 protocol based on the EURO/DSS1 D-channel protocol - * driver written by Karsten Keil et al. - * NI-1 Hall of Fame - Thanks to.... + * 2000.6.6 Initial implementation of routines for US NI1 + * Layer 3 protocol based on the EURO/DSS1 D-channel protocol + * driver written by Karsten Keil et al. + * NI-1 Hall of Fame - Thanks to.... * Ragnar Paulson - for some handy code fragments * Will Scales - beta tester extraordinaire * Brett Whittacre - beta tester and remote devel system in Vegas @@ -29,14 +29,14 @@ static const char *ni1_revision = "$Revision: 2.8.2.3 $"; #define EXT_BEARER_CAPS 1 -#define MsgHead(ptr, cref, mty) \ - *ptr++ = 0x8; \ - if (cref == -1) { \ - *ptr++ = 0x0; \ - } else { \ - *ptr++ = 0x1; \ - *ptr++ = cref^0x80; \ - } \ +#define MsgHead(ptr, cref, mty) \ + *ptr++ = 0x8; \ + if (cref == -1) { \ + *ptr++ = 0x0; \ + } else { \ + *ptr++ = 0x1; \ + *ptr++ = cref^0x80; \ + } \ *ptr++ = mty @@ -48,22 +48,22 @@ static unsigned char new_invoke_id(struct PStack *p) { unsigned char retval; int i; - + i = 32; /* maximum search depth */ retval = p->prot.ni1.last_invoke_id + 1; /* try new id */ while ((i) && (p->prot.ni1.invoke_used[retval >> 3] == 0xFF)) { p->prot.ni1.last_invoke_id = (retval & 0xF8) + 8; i--; - } + } if (i) { while (p->prot.ni1.invoke_used[retval >> 3] & (1 << (retval & 7))) - retval++; + retval++; } else retval = 0; p->prot.ni1.last_invoke_id = retval; p->prot.ni1.invoke_used[retval >> 3] |= (1 << (retval & 7)); - return(retval); + return (retval); } /* new_invoke_id */ /*************************/ @@ -72,10 +72,10 @@ static unsigned char new_invoke_id(struct PStack *p) static void free_invoke_id(struct PStack *p, unsigned char id) { - if (!id) return; /* 0 = invalid value */ + if (!id) return; /* 0 = invalid value */ - p->prot.ni1.invoke_used[id >> 3] &= ~(1 << (id & 7)); -} /* free_invoke_id */ + p->prot.ni1.invoke_used[id >> 3] &= ~(1 << (id & 7)); +} /* free_invoke_id */ /**********************************************************/ @@ -85,26 +85,26 @@ static struct l3_process *ni1_new_l3_process(struct PStack *st, int cr) { struct l3_process *proc; - if (!(proc = new_l3_process(st, cr))) - return(NULL); + if (!(proc = new_l3_process(st, cr))) + return (NULL); - proc->prot.ni1.invoke_id = 0; - proc->prot.ni1.remote_operation = 0; - proc->prot.ni1.uus1_data[0] = '\0'; - - return(proc); + proc->prot.ni1.invoke_id = 0; + proc->prot.ni1.remote_operation = 0; + proc->prot.ni1.uus1_data[0] = '\0'; + + return (proc); } /* ni1_new_l3_process */ /************************************************/ /* free a l3 process and all ni1 specific data */ -/************************************************/ +/************************************************/ static void ni1_release_l3_process(struct l3_process *p) { - free_invoke_id(p->st,p->prot.ni1.invoke_id); - release_l3_process(p); + free_invoke_id(p->st, p->prot.ni1.invoke_id); + release_l3_process(p); } /* ni1_release_l3_process */ - + /********************************************************/ /* search a process with invoke id id and dummy callref */ /********************************************************/ @@ -112,120 +112,120 @@ static struct l3_process * l3ni1_search_dummy_proc(struct PStack *st, int id) { struct l3_process *pc = st->l3.proc; /* start of processes */ - if (!id) return(NULL); + if (!id) return (NULL); - while (pc) - { if ((pc->callref == -1) && (pc->prot.ni1.invoke_id == id)) - return(pc); - pc = pc->next; - } - return(NULL); + while (pc) + { if ((pc->callref == -1) && (pc->prot.ni1.invoke_id == id)) + return (pc); + pc = pc->next; + } + return (NULL); } /* l3ni1_search_dummy_proc */ /*******************************************************************/ /* called when a facility message with a dummy callref is received */ /* and a return result is delivered. id specifies the invoke id. */ -/*******************************************************************/ -static void +/*******************************************************************/ +static void l3ni1_dummy_return_result(struct PStack *st, int id, u_char *p, u_char nlen) { isdn_ctrl ic; - struct IsdnCardState *cs; - struct l3_process *pc = NULL; - - if ((pc = l3ni1_search_dummy_proc(st, id))) - { L3DelTimer(&pc->timer); /* remove timer */ - - cs = pc->st->l1.hardware; - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = NI1_STAT_INVOKE_RES; - ic.parm.ni1_io.hl_id = pc->prot.ni1.invoke_id; - ic.parm.ni1_io.ll_id = pc->prot.ni1.ll_id; - ic.parm.ni1_io.proc = pc->prot.ni1.proc; - ic.parm.ni1_io.timeout= 0; - ic.parm.ni1_io.datalen = nlen; - ic.parm.ni1_io.data = p; - free_invoke_id(pc->st, pc->prot.ni1.invoke_id); - pc->prot.ni1.invoke_id = 0; /* reset id */ - - cs->iif.statcallb(&ic); - ni1_release_l3_process(pc); - } - else - l3_debug(st, "dummy return result id=0x%x result len=%d",id,nlen); + struct IsdnCardState *cs; + struct l3_process *pc = NULL; + + if ((pc = l3ni1_search_dummy_proc(st, id))) + { L3DelTimer(&pc->timer); /* remove timer */ + + cs = pc->st->l1.hardware; + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = NI1_STAT_INVOKE_RES; + ic.parm.ni1_io.hl_id = pc->prot.ni1.invoke_id; + ic.parm.ni1_io.ll_id = pc->prot.ni1.ll_id; + ic.parm.ni1_io.proc = pc->prot.ni1.proc; + ic.parm.ni1_io.timeout = 0; + ic.parm.ni1_io.datalen = nlen; + ic.parm.ni1_io.data = p; + free_invoke_id(pc->st, pc->prot.ni1.invoke_id); + pc->prot.ni1.invoke_id = 0; /* reset id */ + + cs->iif.statcallb(&ic); + ni1_release_l3_process(pc); + } + else + l3_debug(st, "dummy return result id=0x%x result len=%d", id, nlen); } /* l3ni1_dummy_return_result */ /*******************************************************************/ /* called when a facility message with a dummy callref is received */ /* and a return error is delivered. id specifies the invoke id. */ -/*******************************************************************/ -static void +/*******************************************************************/ +static void l3ni1_dummy_error_return(struct PStack *st, int id, ulong error) { isdn_ctrl ic; - struct IsdnCardState *cs; - struct l3_process *pc = NULL; - - if ((pc = l3ni1_search_dummy_proc(st, id))) - { L3DelTimer(&pc->timer); /* remove timer */ - - cs = pc->st->l1.hardware; - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = NI1_STAT_INVOKE_ERR; - ic.parm.ni1_io.hl_id = pc->prot.ni1.invoke_id; - ic.parm.ni1_io.ll_id = pc->prot.ni1.ll_id; - ic.parm.ni1_io.proc = pc->prot.ni1.proc; - ic.parm.ni1_io.timeout= error; - ic.parm.ni1_io.datalen = 0; - ic.parm.ni1_io.data = NULL; - free_invoke_id(pc->st, pc->prot.ni1.invoke_id); - pc->prot.ni1.invoke_id = 0; /* reset id */ - - cs->iif.statcallb(&ic); - ni1_release_l3_process(pc); - } - else - l3_debug(st, "dummy return error id=0x%x error=0x%lx",id,error); + struct IsdnCardState *cs; + struct l3_process *pc = NULL; + + if ((pc = l3ni1_search_dummy_proc(st, id))) + { L3DelTimer(&pc->timer); /* remove timer */ + + cs = pc->st->l1.hardware; + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = NI1_STAT_INVOKE_ERR; + ic.parm.ni1_io.hl_id = pc->prot.ni1.invoke_id; + ic.parm.ni1_io.ll_id = pc->prot.ni1.ll_id; + ic.parm.ni1_io.proc = pc->prot.ni1.proc; + ic.parm.ni1_io.timeout = error; + ic.parm.ni1_io.datalen = 0; + ic.parm.ni1_io.data = NULL; + free_invoke_id(pc->st, pc->prot.ni1.invoke_id); + pc->prot.ni1.invoke_id = 0; /* reset id */ + + cs->iif.statcallb(&ic); + ni1_release_l3_process(pc); + } + else + l3_debug(st, "dummy return error id=0x%x error=0x%lx", id, error); } /* l3ni1_error_return */ /*******************************************************************/ /* called when a facility message with a dummy callref is received */ /* and a invoke is delivered. id specifies the invoke id. */ -/*******************************************************************/ -static void -l3ni1_dummy_invoke(struct PStack *st, int cr, int id, - int ident, u_char *p, u_char nlen) +/*******************************************************************/ +static void +l3ni1_dummy_invoke(struct PStack *st, int cr, int id, + int ident, u_char *p, u_char nlen) { isdn_ctrl ic; - struct IsdnCardState *cs; - - l3_debug(st, "dummy invoke %s id=0x%x ident=0x%x datalen=%d", - (cr == -1) ? "local" : "broadcast",id,ident,nlen); - if (cr >= -1) return; /* ignore local data */ - - cs = st->l1.hardware; - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = NI1_STAT_INVOKE_BRD; - ic.parm.ni1_io.hl_id = id; - ic.parm.ni1_io.ll_id = 0; - ic.parm.ni1_io.proc = ident; - ic.parm.ni1_io.timeout= 0; - ic.parm.ni1_io.datalen = nlen; - ic.parm.ni1_io.data = p; - - cs->iif.statcallb(&ic); + struct IsdnCardState *cs; + + l3_debug(st, "dummy invoke %s id=0x%x ident=0x%x datalen=%d", + (cr == -1) ? "local" : "broadcast", id, ident, nlen); + if (cr >= -1) return; /* ignore local data */ + + cs = st->l1.hardware; + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = NI1_STAT_INVOKE_BRD; + ic.parm.ni1_io.hl_id = id; + ic.parm.ni1_io.ll_id = 0; + ic.parm.ni1_io.proc = ident; + ic.parm.ni1_io.timeout = 0; + ic.parm.ni1_io.datalen = nlen; + ic.parm.ni1_io.data = p; + + cs->iif.statcallb(&ic); } /* l3ni1_dummy_invoke */ static void l3ni1_parse_facility(struct PStack *st, struct l3_process *pc, - int cr, u_char * p) + int cr, u_char *p) { int qd_len = 0; unsigned char nlen = 0, ilen, cp_tag; int ident, id; ulong err_ret; - if (pc) + if (pc) st = pc->st; /* valid Stack */ else if ((!st) || (cr >= 0)) return; /* neither pc nor st specified */ @@ -254,173 +254,173 @@ l3ni1_parse_facility(struct PStack *st, struct l3_process *pc, l3_debug(st, "class and form != 0xA0"); return; } - - cp_tag = *p & 0x1F; /* remember tag value */ - p++; + cp_tag = *p & 0x1F; /* remember tag value */ + + p++; qd_len--; - if (qd_len < 1) - { l3_debug(st, "qd_len < 1"); - return; - } - if (*p & 0x80) - { /* length format indefinite or limited */ - nlen = *p++ & 0x7F; /* number of len bytes or indefinite */ - if ((qd_len-- < ((!nlen) ? 3 : (1 + nlen))) || - (nlen > 1)) - { l3_debug(st, "length format error or not implemented"); - return; - } - if (nlen == 1) - { nlen = *p++; /* complete length */ - qd_len--; - } - else - { qd_len -= 2; /* trailing null bytes */ - if ((*(p+qd_len)) || (*(p+qd_len+1))) - { l3_debug(st,"length format indefinite error"); - return; - } - nlen = qd_len; - } - } - else - { nlen = *p++; - qd_len--; - } - if (qd_len < nlen) - { l3_debug(st, "qd_len < nlen"); - return; - } + if (qd_len < 1) + { l3_debug(st, "qd_len < 1"); + return; + } + if (*p & 0x80) + { /* length format indefinite or limited */ + nlen = *p++ & 0x7F; /* number of len bytes or indefinite */ + if ((qd_len-- < ((!nlen) ? 3 : (1 + nlen))) || + (nlen > 1)) + { l3_debug(st, "length format error or not implemented"); + return; + } + if (nlen == 1) + { nlen = *p++; /* complete length */ + qd_len--; + } + else + { qd_len -= 2; /* trailing null bytes */ + if ((*(p + qd_len)) || (*(p + qd_len + 1))) + { l3_debug(st, "length format indefinite error"); + return; + } + nlen = qd_len; + } + } + else + { nlen = *p++; + qd_len--; + } + if (qd_len < nlen) + { l3_debug(st, "qd_len < nlen"); + return; + } qd_len -= nlen; - if (nlen < 2) - { l3_debug(st, "nlen < 2"); - return; - } - if (*p != 0x02) - { /* invoke identifier tag */ - l3_debug(st, "invoke identifier tag !=0x02"); - return; - } + if (nlen < 2) + { l3_debug(st, "nlen < 2"); + return; + } + if (*p != 0x02) + { /* invoke identifier tag */ + l3_debug(st, "invoke identifier tag !=0x02"); + return; + } p++; nlen--; - if (*p & 0x80) - { /* length format */ - l3_debug(st, "invoke id length format 2"); - return; - } + if (*p & 0x80) + { /* length format */ + l3_debug(st, "invoke id length format 2"); + return; + } ilen = *p++; nlen--; - if (ilen > nlen || ilen == 0) - { l3_debug(st, "ilen > nlen || ilen == 0"); - return; - } + if (ilen > nlen || ilen == 0) + { l3_debug(st, "ilen > nlen || ilen == 0"); + return; + } nlen -= ilen; id = 0; - while (ilen > 0) - { id = (id << 8) | (*p++ & 0xFF); /* invoke identifier */ - ilen--; - } + while (ilen > 0) + { id = (id << 8) | (*p++ & 0xFF); /* invoke identifier */ + ilen--; + } switch (cp_tag) { /* component tag */ - case 1: /* invoke */ - if (nlen < 2) { - l3_debug(st, "nlen < 2 22"); - return; - } - if (*p != 0x02) { /* operation value */ - l3_debug(st, "operation value !=0x02"); - return; - } - p++; - nlen--; - ilen = *p++; - nlen--; - if (ilen > nlen || ilen == 0) { - l3_debug(st, "ilen > nlen || ilen == 0 22"); - return; - } - nlen -= ilen; - ident = 0; - while (ilen > 0) { - ident = (ident << 8) | (*p++ & 0xFF); - ilen--; - } + case 1: /* invoke */ + if (nlen < 2) { + l3_debug(st, "nlen < 2 22"); + return; + } + if (*p != 0x02) { /* operation value */ + l3_debug(st, "operation value !=0x02"); + return; + } + p++; + nlen--; + ilen = *p++; + nlen--; + if (ilen > nlen || ilen == 0) { + l3_debug(st, "ilen > nlen || ilen == 0 22"); + return; + } + nlen -= ilen; + ident = 0; + while (ilen > 0) { + ident = (ident << 8) | (*p++ & 0xFF); + ilen--; + } - if (!pc) - { - l3ni1_dummy_invoke(st, cr, id, ident, p, nlen); - return; - } - l3_debug(st, "invoke break"); - break; - case 2: /* return result */ - /* if no process available handle separately */ - if (!pc) - { if (cr == -1) - l3ni1_dummy_return_result(st, id, p, nlen); - return; - } - if ((pc->prot.ni1.invoke_id) && (pc->prot.ni1.invoke_id == id)) - { /* Diversion successful */ - free_invoke_id(st,pc->prot.ni1.invoke_id); - pc->prot.ni1.remote_result = 0; /* success */ - pc->prot.ni1.invoke_id = 0; - pc->redir_result = pc->prot.ni1.remote_result; - st->l3.l3l4(st, CC_REDIR | INDICATION, pc); } /* Diversion successful */ - else - l3_debug(st,"return error unknown identifier"); - break; - case 3: /* return error */ - err_ret = 0; - if (nlen < 2) - { l3_debug(st, "return error nlen < 2"); - return; - } - if (*p != 0x02) - { /* result tag */ - l3_debug(st, "invoke error tag !=0x02"); - return; - } - p++; - nlen--; - if (*p > 4) - { /* length format */ - l3_debug(st, "invoke return errlen > 4 "); - return; - } - ilen = *p++; - nlen--; - if (ilen > nlen || ilen == 0) - { l3_debug(st, "error return ilen > nlen || ilen == 0"); - return; - } - nlen -= ilen; - while (ilen > 0) - { err_ret = (err_ret << 8) | (*p++ & 0xFF); /* error value */ - ilen--; - } - /* if no process available handle separately */ - if (!pc) - { if (cr == -1) - l3ni1_dummy_error_return(st, id, err_ret); - return; - } - if ((pc->prot.ni1.invoke_id) && (pc->prot.ni1.invoke_id == id)) - { /* Deflection error */ - free_invoke_id(st,pc->prot.ni1.invoke_id); - pc->prot.ni1.remote_result = err_ret; /* result */ - pc->prot.ni1.invoke_id = 0; - pc->redir_result = pc->prot.ni1.remote_result; - st->l3.l3l4(st, CC_REDIR | INDICATION, pc); - } /* Deflection error */ - else - l3_debug(st,"return result unknown identifier"); - break; - default: - l3_debug(st, "facility default break tag=0x%02x",cp_tag); - break; + if (!pc) + { + l3ni1_dummy_invoke(st, cr, id, ident, p, nlen); + return; + } + l3_debug(st, "invoke break"); + break; + case 2: /* return result */ + /* if no process available handle separately */ + if (!pc) + { if (cr == -1) + l3ni1_dummy_return_result(st, id, p, nlen); + return; + } + if ((pc->prot.ni1.invoke_id) && (pc->prot.ni1.invoke_id == id)) + { /* Diversion successful */ + free_invoke_id(st, pc->prot.ni1.invoke_id); + pc->prot.ni1.remote_result = 0; /* success */ + pc->prot.ni1.invoke_id = 0; + pc->redir_result = pc->prot.ni1.remote_result; + st->l3.l3l4(st, CC_REDIR | INDICATION, pc); } /* Diversion successful */ + else + l3_debug(st, "return error unknown identifier"); + break; + case 3: /* return error */ + err_ret = 0; + if (nlen < 2) + { l3_debug(st, "return error nlen < 2"); + return; + } + if (*p != 0x02) + { /* result tag */ + l3_debug(st, "invoke error tag !=0x02"); + return; + } + p++; + nlen--; + if (*p > 4) + { /* length format */ + l3_debug(st, "invoke return errlen > 4 "); + return; + } + ilen = *p++; + nlen--; + if (ilen > nlen || ilen == 0) + { l3_debug(st, "error return ilen > nlen || ilen == 0"); + return; + } + nlen -= ilen; + while (ilen > 0) + { err_ret = (err_ret << 8) | (*p++ & 0xFF); /* error value */ + ilen--; + } + /* if no process available handle separately */ + if (!pc) + { if (cr == -1) + l3ni1_dummy_error_return(st, id, err_ret); + return; + } + if ((pc->prot.ni1.invoke_id) && (pc->prot.ni1.invoke_id == id)) + { /* Deflection error */ + free_invoke_id(st, pc->prot.ni1.invoke_id); + pc->prot.ni1.remote_result = err_ret; /* result */ + pc->prot.ni1.invoke_id = 0; + pc->redir_result = pc->prot.ni1.remote_result; + st->l3.l3l4(st, CC_REDIR | INDICATION, pc); + } /* Deflection error */ + else + l3_debug(st, "return result unknown identifier"); + break; + default: + l3_debug(st, "facility default break tag=0x%02x", cp_tag); + break; } } @@ -518,21 +518,21 @@ l3ni1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg) struct sk_buff *skb; switch (pc->para.cause) { - case 81: /* invalid callreference */ - case 88: /* incomp destination */ - case 96: /* mandory IE missing */ - case 100: /* invalid IE contents */ - case 101: /* incompatible Callstate */ - MsgHead(p, pc->callref, MT_RELEASE_COMPLETE); - *p++ = IE_CAUSE; - *p++ = 0x2; - *p++ = 0x80; - *p++ = pc->para.cause | 0x80; - break; - default: - printk(KERN_ERR "HiSax l3ni1_msg_without_setup wrong cause %d\n", - pc->para.cause); - return; + case 81: /* invalid callreference */ + case 88: /* incomp destination */ + case 96: /* mandory IE missing */ + case 100: /* invalid IE contents */ + case 101: /* incompatible Callstate */ + MsgHead(p, pc->callref, MT_RELEASE_COMPLETE); + *p++ = IE_CAUSE; + *p++ = 0x2; + *p++ = 0x80; + *p++ = pc->para.cause | 0x80; + break; + default: + printk(KERN_ERR "HiSax l3ni1_msg_without_setup wrong cause %d\n", + pc->para.cause); + return; } l = p - tmp; if (!(skb = l3_alloc_skb(l))) @@ -543,42 +543,42 @@ l3ni1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg) } static int ie_ALERTING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, - IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_HLC, - IE_USER_USER, -1}; + IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_HLC, + IE_USER_USER, -1}; static int ie_CALL_PROCEEDING[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, - IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_HLC, -1}; -static int ie_CONNECT[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, - IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_DATE, IE_SIGNAL, - IE_CONNECT_PN, IE_CONNECT_SUB, IE_LLC, IE_HLC, IE_USER_USER, -1}; + IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_HLC, -1}; +static int ie_CONNECT[] = {IE_BEARER, IE_CHANNEL_ID | IE_MANDATORY_1, + IE_FACILITY, IE_PROGRESS, IE_DISPLAY, IE_DATE, IE_SIGNAL, + IE_CONNECT_PN, IE_CONNECT_SUB, IE_LLC, IE_HLC, IE_USER_USER, -1}; static int ie_CONNECT_ACKNOWLEDGE[] = {IE_CHANNEL_ID, IE_DISPLAY, IE_SIGNAL, -1}; static int ie_DISCONNECT[] = {IE_CAUSE | IE_MANDATORY, IE_FACILITY, - IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; + IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; static int ie_INFORMATION[] = {IE_COMPLETE, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, - IE_CALLED_PN, -1}; + IE_CALLED_PN, -1}; static int ie_NOTIFY[] = {IE_BEARER, IE_NOTIFY | IE_MANDATORY, IE_DISPLAY, -1}; static int ie_PROGRESS[] = {IE_BEARER, IE_CAUSE, IE_FACILITY, IE_PROGRESS | - IE_MANDATORY, IE_DISPLAY, IE_HLC, IE_USER_USER, -1}; + IE_MANDATORY, IE_DISPLAY, IE_HLC, IE_USER_USER, -1}; static int ie_RELEASE[] = {IE_CAUSE | IE_MANDATORY_1, IE_FACILITY, IE_DISPLAY, - IE_SIGNAL, IE_USER_USER, -1}; -/* a RELEASE_COMPLETE with errors don't require special actions -static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; + IE_SIGNAL, IE_USER_USER, -1}; +/* a RELEASE_COMPLETE with errors don't require special actions + static int ie_RELEASE_COMPLETE[] = {IE_CAUSE | IE_MANDATORY_1, IE_DISPLAY, IE_SIGNAL, IE_USER_USER, -1}; */ -static int ie_RESUME_ACKNOWLEDGE[] = {IE_CHANNEL_ID| IE_MANDATORY, IE_FACILITY, - IE_DISPLAY, -1}; +static int ie_RESUME_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, + IE_DISPLAY, -1}; static int ie_RESUME_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; static int ie_SETUP[] = {IE_COMPLETE, IE_BEARER | IE_MANDATORY, - IE_CHANNEL_ID| IE_MANDATORY, IE_FACILITY, IE_PROGRESS, - IE_NET_FAC, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, IE_CALLING_PN, - IE_CALLING_SUB, IE_CALLED_PN, IE_CALLED_SUB, IE_REDIR_NR, - IE_LLC, IE_HLC, IE_USER_USER, -1}; + IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, IE_PROGRESS, + IE_NET_FAC, IE_DISPLAY, IE_KEYPAD, IE_SIGNAL, IE_CALLING_PN, + IE_CALLING_SUB, IE_CALLED_PN, IE_CALLED_SUB, IE_REDIR_NR, + IE_LLC, IE_HLC, IE_USER_USER, -1}; static int ie_SETUP_ACKNOWLEDGE[] = {IE_CHANNEL_ID | IE_MANDATORY, IE_FACILITY, - IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, -1}; + IE_PROGRESS, IE_DISPLAY, IE_SIGNAL, -1}; static int ie_STATUS[] = {IE_CAUSE | IE_MANDATORY, IE_CALL_STATE | - IE_MANDATORY, IE_DISPLAY, -1}; + IE_MANDATORY, IE_DISPLAY, -1}; static int ie_STATUS_ENQUIRY[] = {IE_DISPLAY, -1}; static int ie_SUSPEND_ACKNOWLEDGE[] = {IE_DISPLAY, IE_FACILITY, -1}; static int ie_SUSPEND_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; -/* not used +/* not used * static int ie_CONGESTION_CONTROL[] = {IE_CONGESTION | IE_MANDATORY, * IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; * static int ie_USER_INFORMATION[] = {IE_MORE_DATA, IE_USER_USER | IE_MANDATORY, -1}; @@ -586,8 +586,8 @@ static int ie_SUSPEND_REJECT[] = {IE_CAUSE | IE_MANDATORY, IE_DISPLAY, -1}; * IE_MANDATORY, -1}; */ static int ie_FACILITY[] = {IE_FACILITY | IE_MANDATORY, IE_DISPLAY, -1}; -static int comp_required[] = {1,2,3,5,6,7,9,10,11,14,15,-1}; -static int l3_valid_states[] = {0,1,2,3,4,6,7,8,9,10,11,12,15,17,19,25,-1}; +static int comp_required[] = {1, 2, 3, 5, 6, 7, 9, 10, 11, 14, 15, -1}; +static int l3_valid_states[] = {0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 15, 17, 19, 25, -1}; struct ie_len { int ie; @@ -628,7 +628,7 @@ struct ie_len max_ie_len[] = { {IE_LLC, 18}, {IE_HLC, 5}, {IE_USER_USER, 131}, - {-1,0}, + {-1, 0}, }; static int @@ -636,10 +636,10 @@ getmax_ie_len(u_char ie) { int i = 0; while (max_ie_len[i].ie != -1) { if (max_ie_len[i].ie == ie) - return(max_ie_len[i].len); + return (max_ie_len[i].len); i++; } - return(255); + return (255); } static int @@ -649,14 +649,14 @@ ie_in_set(struct l3_process *pc, u_char ie, int *checklist) { while (*checklist != -1) { if ((*checklist & 0xff) == ie) { if (ie & 0x80) - return(-ret); + return (-ret); else - return(ret); + return (ret); } ret++; checklist++; } - return(0); + return (0); } static int @@ -670,7 +670,7 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) u_char codeset = 0; u_char old_codeset = 0; u_char codelock = 1; - + p = skb->data; /* skip cr */ p++; @@ -688,7 +688,7 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) codelock = 1; if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check IE shift%scodeset %d->%d", - codelock ? " locking ": " ", old_codeset, codeset); + codelock ? " locking " : " ", old_codeset, codeset); p++; continue; } @@ -720,7 +720,7 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) if (!codelock) { if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check IE shift back codeset %d->%d", - codeset, old_codeset); + codeset, old_codeset); codeset = old_codeset; codelock = 1; } @@ -728,17 +728,17 @@ check_infoelements(struct l3_process *pc, struct sk_buff *skb, int *checklist) if (err_compr | err_ureg | err_len | err_seq) { if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check IE MT(%x) %d/%d/%d/%d", - mt, err_compr, err_ureg, err_len, err_seq); + mt, err_compr, err_ureg, err_len, err_seq); if (err_compr) - return(ERR_IE_COMPREHENSION); + return (ERR_IE_COMPREHENSION); if (err_ureg) - return(ERR_IE_UNRECOGNIZED); + return (ERR_IE_UNRECOGNIZED); if (err_len) - return(ERR_IE_LENGTH); + return (ERR_IE_LENGTH); if (err_seq) - return(ERR_IE_SEQUENCE); - } - return(0); + return (ERR_IE_SEQUENCE); + } + return (0); } /* verify if a message type exists and contain no IE error */ @@ -746,42 +746,42 @@ static int l3ni1_check_messagetype_validity(struct l3_process *pc, int mt, void *arg) { switch (mt) { - case MT_ALERTING: - case MT_CALL_PROCEEDING: - case MT_CONNECT: - case MT_CONNECT_ACKNOWLEDGE: - case MT_DISCONNECT: - case MT_INFORMATION: - case MT_FACILITY: - case MT_NOTIFY: - case MT_PROGRESS: - case MT_RELEASE: - case MT_RELEASE_COMPLETE: - case MT_SETUP: - case MT_SETUP_ACKNOWLEDGE: - case MT_RESUME_ACKNOWLEDGE: - case MT_RESUME_REJECT: - case MT_SUSPEND_ACKNOWLEDGE: - case MT_SUSPEND_REJECT: - case MT_USER_INFORMATION: - case MT_RESTART: - case MT_RESTART_ACKNOWLEDGE: - case MT_CONGESTION_CONTROL: - case MT_STATUS: - case MT_STATUS_ENQUIRY: - if (pc->debug & L3_DEB_CHECK) - l3_debug(pc->st, "l3ni1_check_messagetype_validity mt(%x) OK", mt); - break; - case MT_RESUME: /* RESUME only in user->net */ - case MT_SUSPEND: /* SUSPEND only in user->net */ - default: - if (pc->debug & (L3_DEB_CHECK | L3_DEB_WARN)) - l3_debug(pc->st, "l3ni1_check_messagetype_validity mt(%x) fail", mt); - pc->para.cause = 97; - l3ni1_status_send(pc, 0, NULL); - return(1); + case MT_ALERTING: + case MT_CALL_PROCEEDING: + case MT_CONNECT: + case MT_CONNECT_ACKNOWLEDGE: + case MT_DISCONNECT: + case MT_INFORMATION: + case MT_FACILITY: + case MT_NOTIFY: + case MT_PROGRESS: + case MT_RELEASE: + case MT_RELEASE_COMPLETE: + case MT_SETUP: + case MT_SETUP_ACKNOWLEDGE: + case MT_RESUME_ACKNOWLEDGE: + case MT_RESUME_REJECT: + case MT_SUSPEND_ACKNOWLEDGE: + case MT_SUSPEND_REJECT: + case MT_USER_INFORMATION: + case MT_RESTART: + case MT_RESTART_ACKNOWLEDGE: + case MT_CONGESTION_CONTROL: + case MT_STATUS: + case MT_STATUS_ENQUIRY: + if (pc->debug & L3_DEB_CHECK) + l3_debug(pc->st, "l3ni1_check_messagetype_validity mt(%x) OK", mt); + break; + case MT_RESUME: /* RESUME only in user->net */ + case MT_SUSPEND: /* SUSPEND only in user->net */ + default: + if (pc->debug & (L3_DEB_CHECK | L3_DEB_WARN)) + l3_debug(pc->st, "l3ni1_check_messagetype_validity mt(%x) fail", mt); + pc->para.cause = 97; + l3ni1_status_send(pc, 0, NULL); + return (1); } - return(0); + return (0); } static void @@ -789,24 +789,24 @@ l3ni1_std_ie_err(struct l3_process *pc, int ret) { if (pc->debug & L3_DEB_CHECK) l3_debug(pc->st, "check_infoelements ret %d", ret); - switch(ret) { - case 0: - break; - case ERR_IE_COMPREHENSION: - pc->para.cause = 96; - l3ni1_status_send(pc, 0, NULL); - break; - case ERR_IE_UNRECOGNIZED: - pc->para.cause = 99; - l3ni1_status_send(pc, 0, NULL); - break; - case ERR_IE_LENGTH: - pc->para.cause = 100; - l3ni1_status_send(pc, 0, NULL); - break; - case ERR_IE_SEQUENCE: - default: - break; + switch (ret) { + case 0: + break; + case ERR_IE_COMPREHENSION: + pc->para.cause = 96; + l3ni1_status_send(pc, 0, NULL); + break; + case ERR_IE_UNRECOGNIZED: + pc->para.cause = 99; + l3ni1_status_send(pc, 0, NULL); + break; + case ERR_IE_LENGTH: + pc->para.cause = 100; + l3ni1_status_send(pc, 0, NULL); + break; + case ERR_IE_SEQUENCE: + default: + break; } } @@ -828,14 +828,14 @@ l3ni1_get_channel_id(struct l3_process *pc, struct sk_buff *skb) { l3_debug(pc->st, "wrong chid %x", *p); return (-3); } - return(*p & 0x3); + return (*p & 0x3); } else - return(-1); + return (-1); } static int l3ni1_get_cause(struct l3_process *pc, struct sk_buff *skb) { - u_char l, i=0; + u_char l, i = 0; u_char *p; p = skb->data; @@ -844,13 +844,13 @@ l3ni1_get_cause(struct l3_process *pc, struct sk_buff *skb) { if ((p = findie(p, skb->len, IE_CAUSE, 0))) { p++; l = *p++; - if (l>30) - return(1); + if (l > 30) + return (1); if (l) { pc->para.loc = *p++; l--; } else { - return(2); + return (2); } if (l && !(pc->para.loc & 0x80)) { l--; @@ -860,36 +860,36 @@ l3ni1_get_cause(struct l3_process *pc, struct sk_buff *skb) { pc->para.cause = *p++; l--; if (!(pc->para.cause & 0x80)) - return(3); + return (3); } else - return(4); - while (l && (i<6)) { + return (4); + while (l && (i < 6)) { pc->para.diag[i++] = *p++; l--; } } else - return(-1); - return(0); + return (-1); + return (0); } static void l3ni1_msg_with_uus(struct l3_process *pc, u_char cmd) { struct sk_buff *skb; - u_char tmp[16+40]; + u_char tmp[16 + 40]; u_char *p = tmp; int l; MsgHead(p, pc->callref, cmd); - if (pc->prot.ni1.uus1_data[0]) - { *p++ = IE_USER_USER; /* UUS info element */ - *p++ = strlen(pc->prot.ni1.uus1_data) + 1; - *p++ = 0x04; /* IA5 chars */ - strcpy(p,pc->prot.ni1.uus1_data); - p += strlen(pc->prot.ni1.uus1_data); - pc->prot.ni1.uus1_data[0] = '\0'; - } + if (pc->prot.ni1.uus1_data[0]) + { *p++ = IE_USER_USER; /* UUS info element */ + *p++ = strlen(pc->prot.ni1.uus1_data) + 1; + *p++ = 0x04; /* IA5 chars */ + strcpy(p, pc->prot.ni1.uus1_data); + p += strlen(pc->prot.ni1.uus1_data); + pc->prot.ni1.uus1_data[0] = '\0'; + } l = p - tmp; if (!(skb = l3_alloc_skb(l))) @@ -903,7 +903,7 @@ l3ni1_release_req(struct l3_process *pc, u_char pr, void *arg) { StopAllL3Timer(pc); newl3state(pc, 19); - if (!pc->prot.ni1.uus1_data[0]) + if (!pc->prot.ni1.uus1_data[0]) l3ni1_message(pc, MT_RELEASE); else l3ni1_msg_with_uus(pc, MT_RELEASE); @@ -916,9 +916,9 @@ l3ni1_release_cmpl(struct l3_process *pc, u_char pr, void *arg) struct sk_buff *skb = arg; int ret; - if ((ret = l3ni1_get_cause(pc, skb))>0) { + if ((ret = l3ni1_get_cause(pc, skb)) > 0) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "RELCMPL get_cause ret(%d)",ret); + l3_debug(pc->st, "RELCMPL get_cause ret(%d)", ret); } else if (ret < 0) pc->para.cause = NO_CAUSE; StopAllL3Timer(pc); @@ -930,7 +930,7 @@ l3ni1_release_cmpl(struct l3_process *pc, u_char pr, void *arg) #if EXT_BEARER_CAPS static u_char * -EncodeASyncParams(u_char * p, u_char si2) +EncodeASyncParams(u_char *p, u_char si2) { // 7c 06 88 90 21 42 00 bb p[0] = 0; @@ -958,38 +958,38 @@ EncodeASyncParams(u_char * p, u_char si2) p[2] += 3; switch (si2 & 0x07) { - case 0: - p[0] = 66; // 1200 bit/s + case 0: + p[0] = 66; // 1200 bit/s - break; - case 1: - p[0] = 88; // 1200/75 bit/s + break; + case 1: + p[0] = 88; // 1200/75 bit/s - break; - case 2: - p[0] = 87; // 75/1200 bit/s + break; + case 2: + p[0] = 87; // 75/1200 bit/s - break; - case 3: - p[0] = 67; // 2400 bit/s + break; + case 3: + p[0] = 67; // 2400 bit/s - break; - case 4: - p[0] = 69; // 4800 bit/s + break; + case 4: + p[0] = 69; // 4800 bit/s - break; - case 5: - p[0] = 72; // 9600 bit/s + break; + case 5: + p[0] = 72; // 9600 bit/s - break; - case 6: - p[0] = 73; // 14400 bit/s + break; + case 6: + p[0] = 73; // 14400 bit/s - break; - case 7: - p[0] = 75; // 19200 bit/s + break; + case 7: + p[0] = 75; // 19200 bit/s - break; + break; } return p + 3; } @@ -999,84 +999,84 @@ EncodeSyncParams(u_char si2, u_char ai) { switch (si2) { - case 0: - return ai + 2; // 1200 bit/s + case 0: + return ai + 2; // 1200 bit/s - case 1: - return ai + 24; // 1200/75 bit/s + case 1: + return ai + 24; // 1200/75 bit/s - case 2: - return ai + 23; // 75/1200 bit/s + case 2: + return ai + 23; // 75/1200 bit/s - case 3: - return ai + 3; // 2400 bit/s + case 3: + return ai + 3; // 2400 bit/s - case 4: - return ai + 5; // 4800 bit/s + case 4: + return ai + 5; // 4800 bit/s - case 5: - return ai + 8; // 9600 bit/s + case 5: + return ai + 8; // 9600 bit/s - case 6: - return ai + 9; // 14400 bit/s + case 6: + return ai + 9; // 14400 bit/s - case 7: - return ai + 11; // 19200 bit/s + case 7: + return ai + 11; // 19200 bit/s - case 8: - return ai + 14; // 48000 bit/s + case 8: + return ai + 14; // 48000 bit/s - case 9: - return ai + 15; // 56000 bit/s + case 9: + return ai + 15; // 56000 bit/s - case 15: - return ai + 40; // negotiate bit/s + case 15: + return ai + 40; // negotiate bit/s - default: - break; + default: + break; } return ai; } static u_char -DecodeASyncParams(u_char si2, u_char * p) +DecodeASyncParams(u_char si2, u_char *p) { u_char info; switch (p[5]) { - case 66: // 1200 bit/s + case 66: // 1200 bit/s - break; // si2 don't change + break; // si2 don't change - case 88: // 1200/75 bit/s + case 88: // 1200/75 bit/s - si2 += 1; - break; - case 87: // 75/1200 bit/s + si2 += 1; + break; + case 87: // 75/1200 bit/s - si2 += 2; - break; - case 67: // 2400 bit/s + si2 += 2; + break; + case 67: // 2400 bit/s - si2 += 3; - break; - case 69: // 4800 bit/s + si2 += 3; + break; + case 69: // 4800 bit/s - si2 += 4; - break; - case 72: // 9600 bit/s + si2 += 4; + break; + case 72: // 9600 bit/s - si2 += 5; - break; - case 73: // 14400 bit/s + si2 += 5; + break; + case 73: // 14400 bit/s - si2 += 6; - break; - case 75: // 19200 bit/s + si2 += 6; + break; + case 75: // 19200 bit/s - si2 += 7; - break; + si2 += 7; + break; } info = p[7] & 0x7f; @@ -1101,39 +1101,39 @@ DecodeSyncParams(u_char si2, u_char info) { info &= 0x7f; switch (info) { - case 40: // bit/s negotiation failed ai := 165 not 175! + case 40: // bit/s negotiation failed ai := 165 not 175! - return si2 + 15; - case 15: // 56000 bit/s failed, ai := 0 not 169 ! + return si2 + 15; + case 15: // 56000 bit/s failed, ai := 0 not 169 ! - return si2 + 9; - case 14: // 48000 bit/s + return si2 + 9; + case 14: // 48000 bit/s - return si2 + 8; - case 11: // 19200 bit/s + return si2 + 8; + case 11: // 19200 bit/s - return si2 + 7; - case 9: // 14400 bit/s + return si2 + 7; + case 9: // 14400 bit/s - return si2 + 6; - case 8: // 9600 bit/s + return si2 + 6; + case 8: // 9600 bit/s - return si2 + 5; - case 5: // 4800 bit/s + return si2 + 5; + case 5: // 4800 bit/s - return si2 + 4; - case 3: // 2400 bit/s + return si2 + 4; + case 3: // 2400 bit/s - return si2 + 3; - case 23: // 75/1200 bit/s + return si2 + 3; + case 23: // 75/1200 bit/s - return si2 + 2; - case 24: // 1200/75 bit/s + return si2 + 2; + case 24: // 1200/75 bit/s - return si2 + 1; - default: // 1200 bit/s + return si2 + 1; + default: // 1200 bit/s - return si2; + return si2; } } @@ -1144,20 +1144,20 @@ DecodeSI2(struct sk_buff *skb) if ((p = findie(skb->data, skb->len, 0x7c, 0))) { switch (p[4] & 0x0f) { - case 0x01: - if (p[1] == 0x04) // sync. Bitratenadaption + case 0x01: + if (p[1] == 0x04) // sync. Bitratenadaption - return DecodeSyncParams(160, p[5]); // V.110/X.30 + return DecodeSyncParams(160, p[5]); // V.110/X.30 - else if (p[1] == 0x06) // async. Bitratenadaption + else if (p[1] == 0x06) // async. Bitratenadaption - return DecodeASyncParams(192, p); // V.110/X.30 + return DecodeASyncParams(192, p); // V.110/X.30 - break; - case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption - if (p[1] > 3) - return DecodeSyncParams(176, p[5]); // V.120 - break; + break; + case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption + if (p[1] > 3) + return DecodeSyncParams(176, p[5]); // V.120 + break; } } return 0; @@ -1168,7 +1168,7 @@ DecodeSI2(struct sk_buff *skb) static void l3ni1_setup_req(struct l3_process *pc, u_char pr, - void *arg) + void *arg) { struct sk_buff *skb; u_char tmp[128]; @@ -1191,7 +1191,7 @@ l3ni1_setup_req(struct l3_process *pc, u_char pr, case 1: /* Telephony */ *p++ = IE_BEARER; *p++ = 0x3; /* Length */ - *p++ = 0x90; /* 3.1khz Audio */ + *p++ = 0x90; /* 3.1khz Audio */ *p++ = 0x90; /* Circuit-Mode 64kbps */ *p++ = 0xa2; /* u-Law Audio */ break; @@ -1214,7 +1214,7 @@ l3ni1_setup_req(struct l3_process *pc, u_char pr, } else sp++; } - + *p++ = IE_KEYPAD; *p++ = strlen(teln); while (*teln) @@ -1222,7 +1222,7 @@ l3ni1_setup_req(struct l3_process *pc, u_char pr, if (sub) *sub++ = '.'; - + #if EXT_BEARER_CAPS if ((pc->para.setup.si2 >= 160) && (pc->para.setup.si2 <= 175)) { // sync. Bitratenadaption, V.110/X.30 @@ -1250,7 +1250,7 @@ l3ni1_setup_req(struct l3_process *pc, u_char pr, *p++ = 0x21; p = EncodeASyncParams(p, pc->para.setup.si2 - 192); } else { - switch (pc->para.setup.si1) { + switch (pc->para.setup.si1) { case 1: /* Telephony */ *p++ = IE_LLC; *p++ = 0x3; /* Length */ @@ -1266,14 +1266,14 @@ l3ni1_setup_req(struct l3_process *pc, u_char pr, *p++ = 0x88; /* Coding Std. CCITT, unrestr. dig. Inform. */ *p++ = 0x90; /* Circuit-Mode 64kbps */ break; - } + } } #endif l = p - tmp; if (!(skb = l3_alloc_skb(l))) -{ + { return; -} + } memcpy(skb_put(skb, l), tmp, l); L3DelTimer(&pc->timer); L3AddTimer(&pc->timer, T303, CC_T303); @@ -1375,7 +1375,7 @@ l3ni1_disconnect(struct l3_process *pc, u_char pr, void *arg) cause = 96; else if (ret > 0) cause = 100; - } + } if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) l3ni1_parse_facility(pc->st, pc, pc->callref, p); ret = check_infoelements(pc, skb, ie_DISCONNECT); @@ -1387,10 +1387,10 @@ l3ni1_disconnect(struct l3_process *pc, u_char pr, void *arg) newl3state(pc, 12); if (cause) newl3state(pc, 19); - if (11 != ret) + if (11 != ret) pc->st->l3.l3l4(pc->st, CC_DISCONNECT | INDICATION, pc); - else if (!cause) - l3ni1_release_req(pc, pr, NULL); + else if (!cause) + l3ni1_release_req(pc, pr, NULL); if (cause) { l3ni1_message_cause(pc, MT_RELEASE, cause); L3AddTimer(&pc->timer, T308, CC_T308_1); @@ -1456,56 +1456,56 @@ l3ni1_setup(struct l3_process *pc, u_char pr, void *arg) else { pc->para.setup.si2 = 0; switch (p[2] & 0x7f) { - case 0x00: /* Speech */ - case 0x10: /* 3.1 Khz audio */ - pc->para.setup.si1 = 1; - break; - case 0x08: /* Unrestricted digital information */ - pc->para.setup.si1 = 7; + case 0x00: /* Speech */ + case 0x10: /* 3.1 Khz audio */ + pc->para.setup.si1 = 1; + break; + case 0x08: /* Unrestricted digital information */ + pc->para.setup.si1 = 7; /* JIM, 05.11.97 I wanna set service indicator 2 */ #if EXT_BEARER_CAPS - pc->para.setup.si2 = DecodeSI2(skb); + pc->para.setup.si2 = DecodeSI2(skb); #endif - break; - case 0x09: /* Restricted digital information */ - pc->para.setup.si1 = 2; - break; - case 0x11: - /* Unrestr. digital information with - * tones/announcements ( or 7 kHz audio - */ - pc->para.setup.si1 = 3; - break; - case 0x18: /* Video */ - pc->para.setup.si1 = 4; - break; - default: - err = 2; - break; + break; + case 0x09: /* Restricted digital information */ + pc->para.setup.si1 = 2; + break; + case 0x11: + /* Unrestr. digital information with + * tones/announcements ( or 7 kHz audio + */ + pc->para.setup.si1 = 3; + break; + case 0x18: /* Video */ + pc->para.setup.si1 = 4; + break; + default: + err = 2; + break; } switch (p[3] & 0x7f) { - case 0x40: /* packed mode */ - pc->para.setup.si1 = 8; - break; - case 0x10: /* 64 kbit */ - case 0x11: /* 2*64 kbit */ - case 0x13: /* 384 kbit */ - case 0x15: /* 1536 kbit */ - case 0x17: /* 1920 kbit */ - pc->para.moderate = p[3] & 0x7f; - break; - default: - err = 3; - break; + case 0x40: /* packed mode */ + pc->para.setup.si1 = 8; + break; + case 0x10: /* 64 kbit */ + case 0x11: /* 2*64 kbit */ + case 0x13: /* 384 kbit */ + case 0x15: /* 1536 kbit */ + case 0x17: /* 1920 kbit */ + pc->para.moderate = p[3] & 0x7f; + break; + default: + err = 3; + break; } } if (pc->debug & L3_DEB_SI) l3_debug(pc->st, "SI=%d, AI=%d", - pc->para.setup.si1, pc->para.setup.si2); + pc->para.setup.si1, pc->para.setup.si2); if (err) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "setup with wrong bearer(l=%d:%x,%x)", - p[1], p[2], p[3]); + p[1], p[2], p[3]); pc->para.cause = 100; l3ni1_msg_without_setup(pc, pr, NULL); return; @@ -1526,17 +1526,17 @@ l3ni1_setup(struct l3_process *pc, u_char pr, void *arg) if ((3 == id) && (0x10 == pc->para.moderate)) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "setup with wrong chid %x", - id); + id); pc->para.cause = 100; l3ni1_msg_without_setup(pc, pr, NULL); return; } bcfound++; - } else - { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "setup without bchannel, call waiting"); - bcfound++; - } + } else + { if (pc->debug & L3_DEB_WARN) + l3_debug(pc->st, "setup without bchannel, call waiting"); + bcfound++; + } } else { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "setup with wrong chid ret %d", id); @@ -1611,7 +1611,7 @@ static void l3ni1_disconnect_req(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb; - u_char tmp[16+40]; + u_char tmp[16 + 40]; u_char *p = tmp; int l; u_char cause = 16; @@ -1628,14 +1628,14 @@ l3ni1_disconnect_req(struct l3_process *pc, u_char pr, void *arg) *p++ = 0x80; *p++ = cause | 0x80; - if (pc->prot.ni1.uus1_data[0]) - { *p++ = IE_USER_USER; /* UUS info element */ - *p++ = strlen(pc->prot.ni1.uus1_data) + 1; - *p++ = 0x04; /* IA5 chars */ - strcpy(p,pc->prot.ni1.uus1_data); - p += strlen(pc->prot.ni1.uus1_data); - pc->prot.ni1.uus1_data[0] = '\0'; - } + if (pc->prot.ni1.uus1_data[0]) + { *p++ = IE_USER_USER; /* UUS info element */ + *p++ = strlen(pc->prot.ni1.uus1_data) + 1; + *p++ = 0x04; /* IA5 chars */ + strcpy(p, pc->prot.ni1.uus1_data); + p += strlen(pc->prot.ni1.uus1_data); + pc->prot.ni1.uus1_data[0] = '\0'; + } l = p - tmp; if (!(skb = l3_alloc_skb(l))) @@ -1648,18 +1648,18 @@ l3ni1_disconnect_req(struct l3_process *pc, u_char pr, void *arg) static void l3ni1_setup_rsp(struct l3_process *pc, u_char pr, - void *arg) -{ - if (!pc->para.bchannel) - { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "D-chan connect for waiting call"); - l3ni1_disconnect_req(pc, pr, arg); - return; - } + void *arg) +{ + if (!pc->para.bchannel) + { if (pc->debug & L3_DEB_WARN) + l3_debug(pc->st, "D-chan connect for waiting call"); + l3ni1_disconnect_req(pc, pr, arg); + return; + } newl3state(pc, 8); if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "D-chan connect for waiting call"); - l3ni1_message_plus_chid(pc, MT_CONNECT); /* GE 05/09/00 */ + l3ni1_message_plus_chid(pc, MT_CONNECT); /* GE 05/09/00 */ L3DelTimer(&pc->timer); L3AddTimer(&pc->timer, T313, CC_T313); } @@ -1716,26 +1716,26 @@ l3ni1_release(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb = arg; u_char *p; - int ret, cause=0; + int ret, cause = 0; StopAllL3Timer(pc); - if ((ret = l3ni1_get_cause(pc, skb))>0) { + if ((ret = l3ni1_get_cause(pc, skb)) > 0) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "REL get_cause ret(%d)", ret); - } else if (ret<0) + } else if (ret < 0) pc->para.cause = NO_CAUSE; if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) { l3ni1_parse_facility(pc->st, pc, pc->callref, p); } - if ((ret<0) && (pc->state != 11)) + if ((ret < 0) && (pc->state != 11)) cause = 96; - else if (ret>0) + else if (ret > 0) cause = 100; ret = check_infoelements(pc, skb, ie_RELEASE); if (ERR_IE_COMPREHENSION == ret) cause = 96; else if ((ERR_IE_UNRECOGNIZED == ret) && (!cause)) - cause = 99; + cause = 99; if (cause) l3ni1_message_cause(pc, MT_RELEASE_COMPLETE, cause); else @@ -1747,27 +1747,27 @@ l3ni1_release(struct l3_process *pc, u_char pr, void *arg) static void l3ni1_alert_req(struct l3_process *pc, u_char pr, - void *arg) + void *arg) { newl3state(pc, 7); - if (!pc->prot.ni1.uus1_data[0]) + if (!pc->prot.ni1.uus1_data[0]) l3ni1_message(pc, MT_ALERTING); else - l3ni1_msg_with_uus(pc, MT_ALERTING); + l3ni1_msg_with_uus(pc, MT_ALERTING); } static void l3ni1_proceed_req(struct l3_process *pc, u_char pr, - void *arg) + void *arg) { newl3state(pc, 9); l3ni1_message(pc, MT_CALL_PROCEEDING); - pc->st->l3.l3l4(pc->st, CC_PROCEED_SEND | INDICATION, pc); + pc->st->l3.l3l4(pc->st, CC_PROCEED_SEND | INDICATION, pc); } static void l3ni1_setup_ack_req(struct l3_process *pc, u_char pr, - void *arg) + void *arg) { newl3state(pc, 25); L3DelTimer(&pc->timer); @@ -1781,22 +1781,22 @@ l3ni1_setup_ack_req(struct l3_process *pc, u_char pr, static void l3ni1_deliver_display(struct l3_process *pc, int pr, u_char *infp) { u_char len; - isdn_ctrl ic; + isdn_ctrl ic; struct IsdnCardState *cs; - char *p; + char *p; - if (*infp++ != IE_DISPLAY) return; - if ((len = *infp++) > 80) return; /* total length <= 82 */ + if (*infp++ != IE_DISPLAY) return; + if ((len = *infp++) > 80) return; /* total length <= 82 */ if (!pc->chan) return; - p = ic.parm.display; - while (len--) - *p++ = *infp++; + p = ic.parm.display; + while (len--) + *p++ = *infp++; *p = '\0'; ic.command = ISDN_STAT_DISPLAY; cs = pc->st->l1.hardware; ic.driver = cs->myid; - ic.arg = pc->chan->chan; + ic.arg = pc->chan->chan; cs->iif.statcallb(&ic); } /* l3ni1_deliver_display */ @@ -1814,37 +1814,37 @@ l3ni1_progress(struct l3_process *pc, u_char pr, void *arg) pc->para.cause = 100; } else if (!(p[2] & 0x70)) { switch (p[2]) { - case 0x80: + case 0x80: + case 0x81: + case 0x82: + case 0x84: + case 0x85: + case 0x87: + case 0x8a: + switch (p[3]) { case 0x81: case 0x82: + case 0x83: case 0x84: - case 0x85: - case 0x87: - case 0x8a: - switch (p[3]) { - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x88: - break; - default: - err = 2; - pc->para.cause = 100; - break; - } + case 0x88: break; default: - err = 3; + err = 2; pc->para.cause = 100; break; + } + break; + default: + err = 3; + pc->para.cause = 100; + break; } } } else { pc->para.cause = 96; err = 4; } - if (err) { + if (err) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "progress error %d", err); l3ni1_status_send(pc, pr, NULL); @@ -1871,21 +1871,21 @@ l3ni1_notify(struct l3_process *pc, u_char pr, void *arg) pc->para.cause = 100; } else { switch (p[2]) { - case 0x80: - case 0x81: - case 0x82: - break; - default: - pc->para.cause = 100; - err = 2; - break; + case 0x80: + case 0x81: + case 0x82: + break; + default: + pc->para.cause = 100; + err = 2; + break; } } } else { pc->para.cause = 96; err = 3; } - if (err) { + if (err) { if (pc->debug & L3_DEB_WARN) l3_debug(pc->st, "notify error %d", err); l3ni1_status_send(pc, pr, NULL); @@ -1908,7 +1908,7 @@ l3ni1_status_enq(struct l3_process *pc, u_char pr, void *arg) ret = check_infoelements(pc, skb, ie_STATUS_ENQUIRY); l3ni1_std_ie_err(pc, ret); pc->para.cause = 30; /* response to STATUS_ENQUIRY */ - l3ni1_status_send(pc, pr, NULL); + l3ni1_status_send(pc, pr, NULL); } static void @@ -1942,68 +1942,68 @@ static void l3ni1_redir_req(struct l3_process *pc, u_char pr, void *arg) struct sk_buff *skb; u_char tmp[128]; u_char *p = tmp; - u_char *subp; - u_char len_phone = 0; - u_char len_sub = 0; - int l; - - - strcpy(pc->prot.ni1.uus1_data,pc->chan->setup.eazmsn); /* copy uus element if available */ - if (!pc->chan->setup.phone[0]) - { pc->para.cause = -1; - l3ni1_disconnect_req(pc,pr,arg); /* disconnect immediately */ - return; - } /* only uus */ - - if (pc->prot.ni1.invoke_id) - free_invoke_id(pc->st,pc->prot.ni1.invoke_id); - - if (!(pc->prot.ni1.invoke_id = new_invoke_id(pc->st))) - return; - - MsgHead(p, pc->callref, MT_FACILITY); - - for (subp = pc->chan->setup.phone; (*subp) && (*subp != '.'); subp++) len_phone++; /* len of phone number */ - if (*subp++ == '.') len_sub = strlen(subp) + 2; /* length including info subaddress element */ + u_char *subp; + u_char len_phone = 0; + u_char len_sub = 0; + int l; + + + strcpy(pc->prot.ni1.uus1_data, pc->chan->setup.eazmsn); /* copy uus element if available */ + if (!pc->chan->setup.phone[0]) + { pc->para.cause = -1; + l3ni1_disconnect_req(pc, pr, arg); /* disconnect immediately */ + return; + } /* only uus */ + + if (pc->prot.ni1.invoke_id) + free_invoke_id(pc->st, pc->prot.ni1.invoke_id); + + if (!(pc->prot.ni1.invoke_id = new_invoke_id(pc->st))) + return; + + MsgHead(p, pc->callref, MT_FACILITY); + + for (subp = pc->chan->setup.phone; (*subp) && (*subp != '.'); subp++) len_phone++; /* len of phone number */ + if (*subp++ == '.') len_sub = strlen(subp) + 2; /* length including info subaddress element */ *p++ = 0x1c; /* Facility info element */ - *p++ = len_phone + len_sub + 2 + 2 + 8 + 3 + 3; /* length of element */ - *p++ = 0x91; /* remote operations protocol */ - *p++ = 0xa1; /* invoke component */ - - *p++ = len_phone + len_sub + 2 + 2 + 8 + 3; /* length of data */ - *p++ = 0x02; /* invoke id tag, integer */ + *p++ = len_phone + len_sub + 2 + 2 + 8 + 3 + 3; /* length of element */ + *p++ = 0x91; /* remote operations protocol */ + *p++ = 0xa1; /* invoke component */ + + *p++ = len_phone + len_sub + 2 + 2 + 8 + 3; /* length of data */ + *p++ = 0x02; /* invoke id tag, integer */ *p++ = 0x01; /* length */ - *p++ = pc->prot.ni1.invoke_id; /* invoke id */ - *p++ = 0x02; /* operation value tag, integer */ + *p++ = pc->prot.ni1.invoke_id; /* invoke id */ + *p++ = 0x02; /* operation value tag, integer */ *p++ = 0x01; /* length */ - *p++ = 0x0D; /* Call Deflect */ - - *p++ = 0x30; /* sequence phone number */ - *p++ = len_phone + 2 + 2 + 3 + len_sub; /* length */ - - *p++ = 0x30; /* Deflected to UserNumber */ - *p++ = len_phone+2+len_sub; /* length */ - *p++ = 0x80; /* NumberDigits */ + *p++ = 0x0D; /* Call Deflect */ + + *p++ = 0x30; /* sequence phone number */ + *p++ = len_phone + 2 + 2 + 3 + len_sub; /* length */ + + *p++ = 0x30; /* Deflected to UserNumber */ + *p++ = len_phone + 2 + len_sub; /* length */ + *p++ = 0x80; /* NumberDigits */ *p++ = len_phone; /* length */ - for (l = 0; l < len_phone; l++) - *p++ = pc->chan->setup.phone[l]; + for (l = 0; l < len_phone; l++) + *p++ = pc->chan->setup.phone[l]; - if (len_sub) - { *p++ = 0x04; /* called party subaddress */ - *p++ = len_sub - 2; - while (*subp) *p++ = *subp++; - } + if (len_sub) + { *p++ = 0x04; /* called party subaddress */ + *p++ = len_sub - 2; + while (*subp) *p++ = *subp++; + } - *p++ = 0x01; /* screening identifier */ - *p++ = 0x01; - *p++ = pc->chan->setup.screen; + *p++ = 0x01; /* screening identifier */ + *p++ = 0x01; + *p++ = pc->chan->setup.screen; l = p - tmp; if (!(skb = l3_alloc_skb(l))) return; memcpy(skb_put(skb, l), tmp, l); - l3_msg(pc->st, DL_DATA | REQUEST, skb); + l3_msg(pc->st, DL_DATA | REQUEST, skb); } /* l3ni1_redir_req */ /********************************************/ @@ -2011,8 +2011,8 @@ static void l3ni1_redir_req(struct l3_process *pc, u_char pr, void *arg) /********************************************/ static void l3ni1_redir_req_early(struct l3_process *pc, u_char pr, void *arg) { - l3ni1_proceed_req(pc,pr,arg); - l3ni1_redir_req(pc,pr,arg); + l3ni1_proceed_req(pc, pr, arg); + l3ni1_redir_req(pc, pr, arg); } /* l3ni1_redir_req_early */ /***********************************************/ @@ -2022,108 +2022,108 @@ static void l3ni1_redir_req_early(struct l3_process *pc, u_char pr, void *arg) /***********************************************/ static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic) { u_char id; - u_char temp[265]; - u_char *p = temp; - int i, l, proc_len; - struct sk_buff *skb; - struct l3_process *pc = NULL; - - switch (ic->arg) - { case NI1_CMD_INVOKE: - if (ic->parm.ni1_io.datalen < 0) return(-2); /* invalid parameter */ - - for (proc_len = 1, i = ic->parm.ni1_io.proc >> 8; i; i++) - i = i >> 8; /* add one byte */ - l = ic->parm.ni1_io.datalen + proc_len + 8; /* length excluding ie header */ - if (l > 255) - return(-2); /* too long */ - - if (!(id = new_invoke_id(st))) - return(0); /* first get a invoke id -> return if no available */ - - i = -1; - MsgHead(p, i, MT_FACILITY); /* build message head */ - *p++ = 0x1C; /* Facility IE */ - *p++ = l; /* length of ie */ - *p++ = 0x91; /* remote operations */ - *p++ = 0xA1; /* invoke */ - *p++ = l - 3; /* length of invoke */ - *p++ = 0x02; /* invoke id tag */ - *p++ = 0x01; /* length is 1 */ - *p++ = id; /* invoke id */ - *p++ = 0x02; /* operation */ - *p++ = proc_len; /* length of operation */ - - for (i = proc_len; i; i--) - *p++ = (ic->parm.ni1_io.proc >> (i-1)) & 0xFF; - memcpy(p, ic->parm.ni1_io.data, ic->parm.ni1_io.datalen); /* copy data */ - l = (p - temp) + ic->parm.ni1_io.datalen; /* total length */ - - if (ic->parm.ni1_io.timeout > 0) - if (!(pc = ni1_new_l3_process(st, -1))) - { free_invoke_id(st, id); - return(-2); - } - pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */ - pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */ - - if (!(skb = l3_alloc_skb(l))) - { free_invoke_id(st, id); - if (pc) ni1_release_l3_process(pc); - return(-2); - } - memcpy(skb_put(skb, l), temp, l); - - if (pc) - { pc->prot.ni1.invoke_id = id; /* remember id */ - L3AddTimer(&pc->timer, ic->parm.ni1_io.timeout, CC_TNI1_IO | REQUEST); - } - - l3_msg(st, DL_DATA | REQUEST, skb); - ic->parm.ni1_io.hl_id = id; /* return id */ - return(0); - - case NI1_CMD_INVOKE_ABORT: - if ((pc = l3ni1_search_dummy_proc(st, ic->parm.ni1_io.hl_id))) - { L3DelTimer(&pc->timer); /* remove timer */ - ni1_release_l3_process(pc); - return(0); - } - else - { l3_debug(st, "l3ni1_cmd_global abort unknown id"); - return(-2); - } - break; - - default: - l3_debug(st, "l3ni1_cmd_global unknown cmd 0x%lx", ic->arg); - return(-1); - } /* switch ic-> arg */ - return(-1); + u_char temp[265]; + u_char *p = temp; + int i, l, proc_len; + struct sk_buff *skb; + struct l3_process *pc = NULL; + + switch (ic->arg) + { case NI1_CMD_INVOKE: + if (ic->parm.ni1_io.datalen < 0) return (-2); /* invalid parameter */ + + for (proc_len = 1, i = ic->parm.ni1_io.proc >> 8; i; i++) + i = i >> 8; /* add one byte */ + l = ic->parm.ni1_io.datalen + proc_len + 8; /* length excluding ie header */ + if (l > 255) + return (-2); /* too long */ + + if (!(id = new_invoke_id(st))) + return (0); /* first get a invoke id -> return if no available */ + + i = -1; + MsgHead(p, i, MT_FACILITY); /* build message head */ + *p++ = 0x1C; /* Facility IE */ + *p++ = l; /* length of ie */ + *p++ = 0x91; /* remote operations */ + *p++ = 0xA1; /* invoke */ + *p++ = l - 3; /* length of invoke */ + *p++ = 0x02; /* invoke id tag */ + *p++ = 0x01; /* length is 1 */ + *p++ = id; /* invoke id */ + *p++ = 0x02; /* operation */ + *p++ = proc_len; /* length of operation */ + + for (i = proc_len; i; i--) + *p++ = (ic->parm.ni1_io.proc >> (i - 1)) & 0xFF; + memcpy(p, ic->parm.ni1_io.data, ic->parm.ni1_io.datalen); /* copy data */ + l = (p - temp) + ic->parm.ni1_io.datalen; /* total length */ + + if (ic->parm.ni1_io.timeout > 0) + if (!(pc = ni1_new_l3_process(st, -1))) + { free_invoke_id(st, id); + return (-2); + } + pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */ + pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */ + + if (!(skb = l3_alloc_skb(l))) + { free_invoke_id(st, id); + if (pc) ni1_release_l3_process(pc); + return (-2); + } + memcpy(skb_put(skb, l), temp, l); + + if (pc) + { pc->prot.ni1.invoke_id = id; /* remember id */ + L3AddTimer(&pc->timer, ic->parm.ni1_io.timeout, CC_TNI1_IO | REQUEST); + } + + l3_msg(st, DL_DATA | REQUEST, skb); + ic->parm.ni1_io.hl_id = id; /* return id */ + return (0); + + case NI1_CMD_INVOKE_ABORT: + if ((pc = l3ni1_search_dummy_proc(st, ic->parm.ni1_io.hl_id))) + { L3DelTimer(&pc->timer); /* remove timer */ + ni1_release_l3_process(pc); + return (0); + } + else + { l3_debug(st, "l3ni1_cmd_global abort unknown id"); + return (-2); + } + break; + + default: + l3_debug(st, "l3ni1_cmd_global unknown cmd 0x%lx", ic->arg); + return (-1); + } /* switch ic-> arg */ + return (-1); } /* l3ni1_cmd_global */ -static void +static void l3ni1_io_timer(struct l3_process *pc) { isdn_ctrl ic; - struct IsdnCardState *cs = pc->st->l1.hardware; + struct IsdnCardState *cs = pc->st->l1.hardware; - L3DelTimer(&pc->timer); /* remove timer */ + L3DelTimer(&pc->timer); /* remove timer */ - ic.driver = cs->myid; - ic.command = ISDN_STAT_PROT; - ic.arg = NI1_STAT_INVOKE_ERR; - ic.parm.ni1_io.hl_id = pc->prot.ni1.invoke_id; - ic.parm.ni1_io.ll_id = pc->prot.ni1.ll_id; - ic.parm.ni1_io.proc = pc->prot.ni1.proc; - ic.parm.ni1_io.timeout= -1; - ic.parm.ni1_io.datalen = 0; - ic.parm.ni1_io.data = NULL; - free_invoke_id(pc->st, pc->prot.ni1.invoke_id); - pc->prot.ni1.invoke_id = 0; /* reset id */ + ic.driver = cs->myid; + ic.command = ISDN_STAT_PROT; + ic.arg = NI1_STAT_INVOKE_ERR; + ic.parm.ni1_io.hl_id = pc->prot.ni1.invoke_id; + ic.parm.ni1_io.ll_id = pc->prot.ni1.ll_id; + ic.parm.ni1_io.proc = pc->prot.ni1.proc; + ic.parm.ni1_io.timeout = -1; + ic.parm.ni1_io.datalen = 0; + ic.parm.ni1_io.data = NULL; + free_invoke_id(pc->st, pc->prot.ni1.invoke_id); + pc->prot.ni1.invoke_id = 0; /* reset id */ - cs->iif.statcallb(&ic); + cs->iif.statcallb(&ic); - ni1_release_l3_process(pc); + ni1_release_l3_process(pc); } /* l3ni1_io_timer */ static void @@ -2293,12 +2293,12 @@ l3ni1_status(struct l3_process *pc, u_char pr, void *arg) { u_char *p; struct sk_buff *skb = arg; - int ret; + int ret; u_char cause = 0, callState = 0; - + if ((ret = l3ni1_get_cause(pc, skb))) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "STATUS get_cause ret(%d)",ret); + l3_debug(pc->st, "STATUS get_cause ret(%d)", ret); if (ret < 0) cause = 96; else if (ret > 0) @@ -2323,9 +2323,9 @@ l3ni1_status(struct l3_process *pc, u_char pr, void *arg) } if (cause) { u_char tmp; - + if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "STATUS error(%d/%d)",ret,cause); + l3_debug(pc->st, "STATUS error(%d/%d)", ret, cause); tmp = pc->para.cause; pc->para.cause = cause; l3ni1_status_send(pc, 0, NULL); @@ -2351,10 +2351,10 @@ l3ni1_facility(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb = arg; int ret; - + ret = check_infoelements(pc, skb, ie_FACILITY); l3ni1_std_ie_err(pc, ret); - { + { u_char *p; if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) l3ni1_parse_facility(pc->st, pc, pc->callref, p); @@ -2403,7 +2403,7 @@ l3ni1_suspend_ack(struct l3_process *pc, u_char pr, void *arg) /* We don't handle suspend_ack for IE errors now */ if ((ret = check_infoelements(pc, skb, ie_SUSPEND_ACKNOWLEDGE))) if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "SUSPACK check ie(%d)",ret); + l3_debug(pc->st, "SUSPACK check ie(%d)", ret); ni1_release_l3_process(pc); } @@ -2415,8 +2415,8 @@ l3ni1_suspend_rej(struct l3_process *pc, u_char pr, void *arg) if ((ret = l3ni1_get_cause(pc, skb))) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "SUSP_REJ get_cause ret(%d)",ret); - if (ret < 0) + l3_debug(pc->st, "SUSP_REJ get_cause ret(%d)", ret); + if (ret < 0) pc->para.cause = 96; else pc->para.cause = 100; @@ -2507,8 +2507,8 @@ l3ni1_resume_rej(struct l3_process *pc, u_char pr, void *arg) if ((ret = l3ni1_get_cause(pc, skb))) { if (pc->debug & L3_DEB_WARN) - l3_debug(pc->st, "RES_REJ get_cause ret(%d)",ret); - if (ret < 0) + l3_debug(pc->st, "RES_REJ get_cause ret(%d)", ret); + if (ret < 0) pc->para.cause = 96; else pc->para.cause = 100; @@ -2562,7 +2562,7 @@ l3ni1_global_restart(struct l3_process *pc, u_char pr, void *arg) up->st->lli.l4l3(up->st, CC_RESTART | REQUEST, up); else if (up->para.bchannel == chan) up->st->lli.l4l3(up->st, CC_RESTART | REQUEST, up); - + up = up->next; } p = tmp; @@ -2586,112 +2586,112 @@ l3ni1_global_restart(struct l3_process *pc, u_char pr, void *arg) static void l3ni1_dl_reset(struct l3_process *pc, u_char pr, void *arg) { - pc->para.cause = 0x29; /* Temporary failure */ - pc->para.loc = 0; - l3ni1_disconnect_req(pc, pr, NULL); - pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc); + pc->para.cause = 0x29; /* Temporary failure */ + pc->para.loc = 0; + l3ni1_disconnect_req(pc, pr, NULL); + pc->st->l3.l3l4(pc->st, CC_SETUP_ERR, pc); } static void l3ni1_dl_release(struct l3_process *pc, u_char pr, void *arg) { - newl3state(pc, 0); - pc->para.cause = 0x1b; /* Destination out of order */ - pc->para.loc = 0; - pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc); - release_l3_process(pc); + newl3state(pc, 0); + pc->para.cause = 0x1b; /* Destination out of order */ + pc->para.loc = 0; + pc->st->l3.l3l4(pc->st, CC_RELEASE | INDICATION, pc); + release_l3_process(pc); } static void l3ni1_dl_reestablish(struct l3_process *pc, u_char pr, void *arg) { - L3DelTimer(&pc->timer); - L3AddTimer(&pc->timer, T309, CC_T309); - l3_msg(pc->st, DL_ESTABLISH | REQUEST, NULL); + L3DelTimer(&pc->timer); + L3AddTimer(&pc->timer, T309, CC_T309); + l3_msg(pc->st, DL_ESTABLISH | REQUEST, NULL); } - + static void l3ni1_dl_reest_status(struct l3_process *pc, u_char pr, void *arg) { L3DelTimer(&pc->timer); - - pc->para.cause = 0x1F; /* normal, unspecified */ + + pc->para.cause = 0x1F; /* normal, unspecified */ l3ni1_status_send(pc, 0, NULL); } -static void l3ni1_SendSpid( struct l3_process *pc, u_char pr, struct sk_buff *skb, int iNewState ) +static void l3ni1_SendSpid(struct l3_process *pc, u_char pr, struct sk_buff *skb, int iNewState) { - u_char * p; - char * pSPID; - struct Channel * pChan = pc->st->lli.userdata; - int l; + u_char *p; + char *pSPID; + struct Channel *pChan = pc->st->lli.userdata; + int l; - if ( skb ) - dev_kfree_skb( skb); + if (skb) + dev_kfree_skb(skb); - if ( !( pSPID = strchr( pChan->setup.eazmsn, ':' ) ) ) + if (!(pSPID = strchr(pChan->setup.eazmsn, ':'))) { - printk( KERN_ERR "SPID not supplied in EAZMSN %s\n", pChan->setup.eazmsn ); - newl3state( pc, 0 ); - pc->st->l3.l3l2( pc->st, DL_RELEASE | REQUEST, NULL ); + printk(KERN_ERR "SPID not supplied in EAZMSN %s\n", pChan->setup.eazmsn); + newl3state(pc, 0); + pc->st->l3.l3l2(pc->st, DL_RELEASE | REQUEST, NULL); return; } - l = strlen( ++pSPID ); - if ( !( skb = l3_alloc_skb( 5+l ) ) ) + l = strlen(++pSPID); + if (!(skb = l3_alloc_skb(5 + l))) { - printk( KERN_ERR "HiSax can't get memory to send SPID\n" ); + printk(KERN_ERR "HiSax can't get memory to send SPID\n"); return; } - p = skb_put( skb, 5 ); + p = skb_put(skb, 5); *p++ = PROTO_DIS_EURO; *p++ = 0; *p++ = MT_INFORMATION; *p++ = IE_SPID; *p++ = l; - memcpy( skb_put( skb, l ), pSPID, l ); + memcpy(skb_put(skb, l), pSPID, l); - newl3state( pc, iNewState ); + newl3state(pc, iNewState); - L3DelTimer( &pc->timer ); - L3AddTimer( &pc->timer, TSPID, CC_TSPID ); + L3DelTimer(&pc->timer); + L3AddTimer(&pc->timer, TSPID, CC_TSPID); - pc->st->l3.l3l2( pc->st, DL_DATA | REQUEST, skb ); + pc->st->l3.l3l2(pc->st, DL_DATA | REQUEST, skb); } -static void l3ni1_spid_send( struct l3_process *pc, u_char pr, void *arg ) +static void l3ni1_spid_send(struct l3_process *pc, u_char pr, void *arg) { - l3ni1_SendSpid( pc, pr, arg, 20 ); + l3ni1_SendSpid(pc, pr, arg, 20); } -static void l3ni1_spid_epid( struct l3_process *pc, u_char pr, void *arg ) +static void l3ni1_spid_epid(struct l3_process *pc, u_char pr, void *arg) { struct sk_buff *skb = arg; - if ( skb->data[ 1 ] == 0 ) - if ( skb->data[ 3 ] == IE_ENDPOINT_ID ) + if (skb->data[1] == 0) + if (skb->data[3] == IE_ENDPOINT_ID) { - L3DelTimer( &pc->timer ); - newl3state( pc, 0 ); - l3_msg( pc->st, DL_ESTABLISH | CONFIRM, NULL ); + L3DelTimer(&pc->timer); + newl3state(pc, 0); + l3_msg(pc->st, DL_ESTABLISH | CONFIRM, NULL); } - dev_kfree_skb( skb); + dev_kfree_skb(skb); } -static void l3ni1_spid_tout( struct l3_process *pc, u_char pr, void *arg ) +static void l3ni1_spid_tout(struct l3_process *pc, u_char pr, void *arg) { - if ( pc->state < 22 ) - l3ni1_SendSpid( pc, pr, arg, pc->state+1 ); + if (pc->state < 22) + l3ni1_SendSpid(pc, pr, arg, pc->state + 1); else { - L3DelTimer( &pc->timer ); - dev_kfree_skb( arg); + L3DelTimer(&pc->timer); + dev_kfree_skb(arg); - printk( KERN_ERR "SPID not accepted\n" ); - newl3state( pc, 0 ); - pc->st->l3.l3l2( pc->st, DL_RELEASE | REQUEST, NULL ); + printk(KERN_ERR "SPID not accepted\n"); + newl3state(pc, 0); + pc->st->l3.l3l2(pc->st, DL_RELEASE | REQUEST, NULL); } } @@ -2724,12 +2724,12 @@ static struct stateentry downstatelist[] = CC_SETUP | RESPONSE, l3ni1_setup_rsp}, {SBIT(10), CC_SUSPEND | REQUEST, l3ni1_suspend_req}, - {SBIT(7) | SBIT(9) | SBIT(25), - CC_REDIR | REQUEST, l3ni1_redir_req}, - {SBIT(6), - CC_REDIR | REQUEST, l3ni1_redir_req_early}, - {SBIT(9) | SBIT(25), - CC_DISCONNECT | REQUEST, l3ni1_disconnect_req}, + {SBIT(7) | SBIT(9) | SBIT(25), + CC_REDIR | REQUEST, l3ni1_redir_req}, + {SBIT(6), + CC_REDIR | REQUEST, l3ni1_redir_req_early}, + {SBIT(9) | SBIT(25), + CC_DISCONNECT | REQUEST, l3ni1_disconnect_req}, {SBIT(25), CC_T302, l3ni1_t302}, {SBIT(1), @@ -2752,8 +2752,8 @@ static struct stateentry downstatelist[] = CC_T308_2, l3ni1_t308_2}, {SBIT(10), CC_T309, l3ni1_dl_release}, - { SBIT( 20 ) | SBIT( 21 ) | SBIT( 22 ), - CC_TSPID, l3ni1_spid_tout }, + { SBIT(20) | SBIT(21) | SBIT(22), + CC_TSPID, l3ni1_spid_tout }, }; static struct stateentry datastatelist[] = @@ -2815,22 +2815,22 @@ static struct stateentry globalmes_list[] = {SBIT(0), MT_RESTART, l3ni1_global_restart}, /* {SBIT(1), - MT_RESTART_ACKNOWLEDGE, l3ni1_restart_ack}, + MT_RESTART_ACKNOWLEDGE, l3ni1_restart_ack}, */ - { SBIT( 0 ), MT_DL_ESTABLISHED, l3ni1_spid_send }, - { SBIT( 20 ) | SBIT( 21 ) | SBIT( 22 ), MT_INFORMATION, l3ni1_spid_epid }, + { SBIT(0), MT_DL_ESTABLISHED, l3ni1_spid_send }, + { SBIT(20) | SBIT(21) | SBIT(22), MT_INFORMATION, l3ni1_spid_epid }, }; static struct stateentry manstatelist[] = { - {SBIT(2), - DL_ESTABLISH | INDICATION, l3ni1_dl_reset}, - {SBIT(10), - DL_ESTABLISH | CONFIRM, l3ni1_dl_reest_status}, - {SBIT(10), - DL_RELEASE | INDICATION, l3ni1_dl_reestablish}, - {ALL_STATES, - DL_RELEASE | INDICATION, l3ni1_dl_release}, + {SBIT(2), + DL_ESTABLISH | INDICATION, l3ni1_dl_reset}, + {SBIT(10), + DL_ESTABLISH | CONFIRM, l3ni1_dl_reest_status}, + {SBIT(10), + DL_RELEASE | INDICATION, l3ni1_dl_reestablish}, + {ALL_STATES, + DL_RELEASE | INDICATION, l3ni1_dl_release}, }; /* *INDENT-ON* */ @@ -2845,7 +2845,7 @@ global_handler(struct PStack *st, int mt, struct sk_buff *skb) int i; struct l3_process *proc = st->l3.global; - if ( skb ) + if (skb) proc->callref = skb->data[2]; /* cr flag */ else proc->callref = 0; @@ -2856,13 +2856,13 @@ global_handler(struct PStack *st, int mt, struct sk_buff *skb) if (i == ARRAY_SIZE(globalmes_list)) { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "ni1 global state %d mt %x unhandled", - proc->state, mt); + proc->state, mt); } MsgHead(p, proc->callref, MT_STATUS); *p++ = IE_CAUSE; *p++ = 0x2; *p++ = 0x80; - *p++ = 81 |0x80; /* invalid cr */ + *p++ = 81 | 0x80; /* invalid cr */ *p++ = 0x14; /* CallState */ *p++ = 0x1; *p++ = proc->state & 0x3f; @@ -2874,7 +2874,7 @@ global_handler(struct PStack *st, int mt, struct sk_buff *skb) } else { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "ni1 global %d mt %x", - proc->state, mt); + proc->state, mt); } globalmes_list[i].rout(proc, mt, skb); } @@ -2890,23 +2890,23 @@ ni1up(struct PStack *st, int pr, void *arg) struct l3_process *proc; switch (pr) { - case (DL_DATA | INDICATION): - case (DL_UNIT_DATA | INDICATION): - break; - case (DL_ESTABLISH | INDICATION): - case (DL_RELEASE | INDICATION): - case (DL_RELEASE | CONFIRM): - l3_msg(st, pr, arg); - return; - break; + case (DL_DATA | INDICATION): + case (DL_UNIT_DATA | INDICATION): + break; + case (DL_ESTABLISH | INDICATION): + case (DL_RELEASE | INDICATION): + case (DL_RELEASE | CONFIRM): + l3_msg(st, pr, arg); + return; + break; - case (DL_ESTABLISH | CONFIRM): - global_handler( st, MT_DL_ESTABLISHED, NULL ); - return; + case (DL_ESTABLISH | CONFIRM): + global_handler(st, MT_DL_ESTABLISHED, NULL); + return; - default: - printk(KERN_ERR "HiSax ni1up unknown pr=%04x\n", pr); - return; + default: + printk(KERN_ERR "HiSax ni1up unknown pr=%04x\n", pr); + return; } if (skb->len < 3) { l3_debug(st, "ni1up frame too short(%d)", skb->len); @@ -2941,10 +2941,10 @@ ni1up(struct PStack *st, int pr, void *arg) if (mt == MT_FACILITY) { if ((p = findie(skb->data, skb->len, IE_FACILITY, 0))) { - l3ni1_parse_facility(st, NULL, - (pr == (DL_DATA | INDICATION)) ? -1 : -2, p); + l3ni1_parse_facility(st, NULL, + (pr == (DL_DATA | INDICATION)) ? -1 : -2, p); dev_kfree_skb(skb); - return; + return; } } else @@ -2952,13 +2952,13 @@ ni1up(struct PStack *st, int pr, void *arg) global_handler(st, mt, skb); return; } - + if (st->l3.debug & L3_DEB_WARN) l3_debug(st, "ni1up dummy Callref (no facility msg or ie)"); dev_kfree_skb(skb); return; - } else if ((((skb->data[1] & 0x0f) == 1) && (0==(cr & 0x7f))) || - (((skb->data[1] & 0x0f) == 2) && (0==(cr & 0x7fff)))) { /* Global CallRef */ + } else if ((((skb->data[1] & 0x0f) == 1) && (0 == (cr & 0x7f))) || + (((skb->data[1] & 0x0f) == 2) && (0 == (cr & 0x7fff)))) { /* Global CallRef */ if (st->l3.debug & L3_DEB_STATE) l3_debug(st, "ni1up Global CallRef"); global_handler(st, mt, skb); @@ -3036,8 +3036,8 @@ ni1up(struct PStack *st, int pr, void *arg) dev_kfree_skb(skb); return; } - if ((p = findie(skb->data, skb->len, IE_DISPLAY, 0)) != NULL) - l3ni1_deliver_display(proc, pr, p); /* Display IE included */ + if ((p = findie(skb->data, skb->len, IE_DISPLAY, 0)) != NULL) + l3ni1_deliver_display(proc, pr, p); /* Display IE included */ for (i = 0; i < ARRAY_SIZE(datastatelist); i++) if ((mt == datastatelist[i].primitive) && ((1 << proc->state) & datastatelist[i].state)) @@ -3045,8 +3045,8 @@ ni1up(struct PStack *st, int pr, void *arg) if (i == ARRAY_SIZE(datastatelist)) { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "ni1up%sstate %d mt %#x unhandled", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", - proc->state, mt); + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", + proc->state, mt); } if ((MT_RELEASE_COMPLETE != mt) && (MT_RELEASE != mt)) { proc->para.cause = 101; @@ -3055,8 +3055,8 @@ ni1up(struct PStack *st, int pr, void *arg) } else { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "ni1up%sstate %d mt %x", - (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", - proc->state, mt); + (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", + proc->state, mt); } datastatelist[i].rout(proc, pr, skb); } @@ -3092,10 +3092,10 @@ ni1down(struct PStack *st, int pr, void *arg) return; } - if ( pr == (CC_TNI1_IO | REQUEST)) { - l3ni1_io_timer(proc); /* timer expires */ + if (pr == (CC_TNI1_IO | REQUEST)) { + l3ni1_io_timer(proc); /* timer expires */ return; - } + } for (i = 0; i < ARRAY_SIZE(downstatelist); i++) if ((pr == downstatelist[i].primitive) && @@ -3104,12 +3104,12 @@ ni1down(struct PStack *st, int pr, void *arg) if (i == ARRAY_SIZE(downstatelist)) { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "ni1down state %d prim %#x unhandled", - proc->state, pr); + proc->state, pr); } } else { if (st->l3.debug & L3_DEB_STATE) { l3_debug(st, "ni1down state %d prim %#x", - proc->state, pr); + proc->state, pr); } downstatelist[i].rout(proc, pr, arg); } @@ -3118,31 +3118,31 @@ ni1down(struct PStack *st, int pr, void *arg) static void ni1man(struct PStack *st, int pr, void *arg) { - int i; - struct l3_process *proc = arg; - - if (!proc) { - printk(KERN_ERR "HiSax ni1man without proc pr=%04x\n", pr); - return; - } - for (i = 0; i < ARRAY_SIZE(manstatelist); i++) - if ((pr == manstatelist[i].primitive) && - ((1 << proc->state) & manstatelist[i].state)) - break; - if (i == ARRAY_SIZE(manstatelist)) { - if (st->l3.debug & L3_DEB_STATE) { - l3_debug(st, "cr %d ni1man state %d prim %#x unhandled", - proc->callref & 0x7f, proc->state, pr); - } - } else { - if (st->l3.debug & L3_DEB_STATE) { - l3_debug(st, "cr %d ni1man state %d prim %#x", - proc->callref & 0x7f, proc->state, pr); - } - manstatelist[i].rout(proc, pr, arg); - } -} - + int i; + struct l3_process *proc = arg; + + if (!proc) { + printk(KERN_ERR "HiSax ni1man without proc pr=%04x\n", pr); + return; + } + for (i = 0; i < ARRAY_SIZE(manstatelist); i++) + if ((pr == manstatelist[i].primitive) && + ((1 << proc->state) & manstatelist[i].state)) + break; + if (i == ARRAY_SIZE(manstatelist)) { + if (st->l3.debug & L3_DEB_STATE) { + l3_debug(st, "cr %d ni1man state %d prim %#x unhandled", + proc->callref & 0x7f, proc->state, pr); + } + } else { + if (st->l3.debug & L3_DEB_STATE) { + l3_debug(st, "cr %d ni1man state %d prim %#x", + proc->callref & 0x7f, proc->state, pr); + } + manstatelist[i].rout(proc, pr, arg); + } +} + void setstack_ni1(struct PStack *st) { @@ -3157,8 +3157,8 @@ setstack_ni1(struct PStack *st) st->prot.ni1.last_invoke_id = 0; st->prot.ni1.invoke_used[0] = 1; /* Bit 0 must always be set to 1 */ i = 1; - while (i < 32) - st->prot.ni1.invoke_used[i++] = 0; + while (i < 32) + st->prot.ni1.invoke_used[i++] = 0; if (!(st->l3.global = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) { printk(KERN_ERR "HiSax can't get memory for ni1 global CR\n"); @@ -3169,7 +3169,7 @@ setstack_ni1(struct PStack *st) st->l3.global->debug = L3_DEB_WARN; st->l3.global->st = st; st->l3.global->N303 = 1; - st->l3.global->prot.ni1.invoke_id = 0; + st->l3.global->prot.ni1.invoke_id = 0; L3InitTimer(st->l3.global, &st->l3.global->timer); } diff --git a/drivers/isdn/hisax/l3ni1.h b/drivers/isdn/hisax/l3ni1.h index 4066da2fe5a2..99d37d2cea4f 100644 --- a/drivers/isdn/hisax/l3ni1.h +++ b/drivers/isdn/hisax/l3ni1.h @@ -4,13 +4,13 @@ * * Author Matt Henderson & Guy Ellis * Copyright by Traverse Technologies Pty Ltd, www.travers.com.au - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * - * 2000.6.6 Initial implementation of routines for US NI1 - * Layer 3 protocol based on the EURO/DSS1 D-channel protocol - * driver written by Karsten Keil et al. Thanks also for the + * 2000.6.6 Initial implementation of routines for US NI1 + * Layer 3 protocol based on the EURO/DSS1 D-channel protocol + * driver written by Karsten Keil et al. Thanks also for the * code provided by Ragnar Paulson. * */ @@ -119,18 +119,18 @@ /* l3ni1 specific data in l3 process */ typedef struct - { unsigned char invoke_id; /* used invoke id in remote ops, 0 = not active */ - ulong ll_id; /* remebered ll id */ - u8 remote_operation; /* handled remote operation, 0 = not active */ - int proc; /* rememered procedure */ - ulong remote_result; /* result of remote operation for statcallb */ - char uus1_data[35]; /* data send during alerting or disconnect */ - } ni1_proc_priv; +{ unsigned char invoke_id; /* used invoke id in remote ops, 0 = not active */ + ulong ll_id; /* remebered ll id */ + u8 remote_operation; /* handled remote operation, 0 = not active */ + int proc; /* rememered procedure */ + ulong remote_result; /* result of remote operation for statcallb */ + char uus1_data[35]; /* data send during alerting or disconnect */ +} ni1_proc_priv; /* l3dni1 specific data in protocol stack */ typedef struct - { unsigned char last_invoke_id; /* last used value for invoking */ - unsigned char invoke_used[32]; /* 256 bits for 256 values */ - } ni1_stk_priv; +{ unsigned char last_invoke_id; /* last used value for invoking */ + unsigned char invoke_used[32]; /* 256 bits for 256 values */ +} ni1_stk_priv; #endif /* only l3dni1_process */ diff --git a/drivers/isdn/hisax/lmgr.c b/drivers/isdn/hisax/lmgr.c index d4f86d654de0..5b63eb6601aa 100644 --- a/drivers/isdn/hisax/lmgr.c +++ b/drivers/isdn/hisax/lmgr.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -16,12 +16,12 @@ static void error_handling_dchan(struct PStack *st, int Error) { switch (Error) { - case 'C': - case 'D': - case 'G': - case 'H': - st->l2.l2tei(st, MDL_ERROR | REQUEST, NULL); - break; + case 'C': + case 'D': + case 'G': + case 'H': + st->l2.l2tei(st, MDL_ERROR | REQUEST, NULL); + break; } } @@ -31,15 +31,15 @@ hisax_manager(struct PStack *st, int pr, void *arg) long Code; switch (pr) { - case (MDL_ERROR | INDICATION): - Code = (long) arg; - HiSax_putstatus(st->l1.hardware, "manager: MDL_ERROR", - " %c %s", (char)Code, + case (MDL_ERROR | INDICATION): + Code = (long) arg; + HiSax_putstatus(st->l1.hardware, "manager: MDL_ERROR", + " %c %s", (char)Code, test_bit(FLG_LAPD, &st->l2.flag) ? "D-channel" : "B-channel"); - if (test_bit(FLG_LAPD, &st->l2.flag)) - error_handling_dchan(st, Code); - break; + if (test_bit(FLG_LAPD, &st->l2.flag)) + error_handling_dchan(st, Code); + break; } } diff --git a/drivers/isdn/hisax/mic.c b/drivers/isdn/hisax/mic.c index 253943029d25..08a6b7fb17f7 100644 --- a/drivers/isdn/hisax/mic.c +++ b/drivers/isdn/hisax/mic.c @@ -4,7 +4,7 @@ * * Author Stephan von Krawczynski * Copyright by Stephan von Krawczynski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -18,7 +18,7 @@ static const char *mic_revision = "$Revision: 1.12.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define MIC_ISAC 2 @@ -39,7 +39,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -54,7 +54,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -75,13 +75,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.mic.adr, cs->hw.mic.isac, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.mic.adr, cs->hw.mic.isac, 0, data, size); } @@ -104,16 +104,16 @@ WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) * fast interrupt HSCX stuff goes here */ -#define READHSCX(cs, nr, reg) readreg(cs->hw.mic.adr, \ - cs->hw.mic.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.mic.adr, \ - cs->hw.mic.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.mic.adr, \ + cs->hw.mic.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.mic.adr, \ + cs->hw.mic.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.mic.adr, \ - cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.mic.adr, \ + cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.mic.adr, \ - cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.mic.adr, \ + cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -126,11 +126,11 @@ mic_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_ISTA + 0x40); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_ISTA + 0x40); @@ -170,21 +170,21 @@ mic_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - return(0); - case CARD_RELEASE: - release_io_mic(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscx(cs); /* /RTSA := ISAC RST */ - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + return (0); + case CARD_RELEASE: + release_io_mic(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscx(cs); /* /RTSA := ISAC RST */ + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } int __devinit @@ -214,7 +214,7 @@ setup_mic(struct IsdnCard *card) return (0); } printk(KERN_INFO "mic: defined at 0x%x IRQ %d\n", - cs->hw.mic.cfg_reg, cs->irq); + cs->hw.mic.cfg_reg, cs->irq); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; @@ -228,7 +228,7 @@ setup_mic(struct IsdnCard *card) ISACVersion(cs, "mic:"); if (HscxVersion(cs, "mic:")) { printk(KERN_WARNING - "mic: wrong HSCX versions check IO address\n"); + "mic: wrong HSCX versions check IO address\n"); release_io_mic(cs); return (0); } diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c index 644891efc26f..b646eed379df 100644 --- a/drivers/isdn/hisax/netjet.c +++ b/drivers/isdn/hisax/netjet.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -31,21 +31,21 @@ u_char NETjet_ReadIC(struct IsdnCardState *cs, u_char offset) { u_char ret; - + cs->hw.njet.auxd &= 0xfc; - cs->hw.njet.auxd |= (offset>>4) & 3; + cs->hw.njet.auxd |= (offset >> 4) & 3; byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); - ret = bytein(cs->hw.njet.isac + ((offset & 0xf)<<2)); - return(ret); + ret = bytein(cs->hw.njet.isac + ((offset & 0xf) << 2)); + return (ret); } void NETjet_WriteIC(struct IsdnCardState *cs, u_char offset, u_char value) { cs->hw.njet.auxd &= 0xfc; - cs->hw.njet.auxd |= (offset>>4) & 3; + cs->hw.njet.auxd |= (offset >> 4) & 3; byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); - byteout(cs->hw.njet.isac + ((offset & 0xf)<<2), value); + byteout(cs->hw.njet.isac + ((offset & 0xf) << 2), value); } void @@ -56,7 +56,7 @@ NETjet_ReadICfifo(struct IsdnCardState *cs, u_char *data, int size) insb(cs->hw.njet.isac, data, size); } -void +void NETjet_WriteICfifo(struct IsdnCardState *cs, u_char *data, int size) { cs->hw.njet.auxd &= 0xfc; @@ -66,17 +66,17 @@ NETjet_WriteICfifo(struct IsdnCardState *cs, u_char *data, int size) static void fill_mem(struct BCState *bcs, u_int *pos, u_int cnt, int chan, u_char fill) { - u_int mask=0x000000ff, val = 0, *p=pos; + u_int mask = 0x000000ff, val = 0, *p = pos; u_int i; - + val |= fill; if (chan) { val <<= 8; mask <<= 8; } mask ^= 0xffffffff; - for (i=0; i bcs->hw.tiger.s_end) p = bcs->hw.tiger.send; @@ -87,7 +87,7 @@ static void mode_tiger(struct BCState *bcs, int mode, int bc) { struct IsdnCardState *cs = bcs->cs; - u_char led; + u_char led; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "Tiger mode %d bchan %d/%d", @@ -95,63 +95,63 @@ mode_tiger(struct BCState *bcs, int mode, int bc) bcs->mode = mode; bcs->channel = bc; switch (mode) { - case (L1_MODE_NULL): - fill_mem(bcs, bcs->hw.tiger.send, - NETJET_DMA_TXSIZE, bc, 0xff); - if (cs->debug & L1_DEB_HSCX) - debugl1(cs, "Tiger stat rec %d/%d send %d", - bcs->hw.tiger.r_tot, bcs->hw.tiger.r_err, - bcs->hw.tiger.s_tot); - if ((cs->bcs[0].mode == L1_MODE_NULL) && - (cs->bcs[1].mode == L1_MODE_NULL)) { - cs->hw.njet.dmactrl = 0; - byteout(cs->hw.njet.base + NETJET_DMACTRL, - cs->hw.njet.dmactrl); - byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0); - } - if (cs->typ == ISDN_CTYPE_NETJET_S) - { - // led off - led = bc & 0x01; - led = 0x01 << (6 + led); // convert to mask - led = ~led; - cs->hw.njet.auxd &= led; - byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); - } - break; - case (L1_MODE_TRANS): - break; - case (L1_MODE_HDLC_56K): - case (L1_MODE_HDLC): + case (L1_MODE_NULL): + fill_mem(bcs, bcs->hw.tiger.send, + NETJET_DMA_TXSIZE, bc, 0xff); + if (cs->debug & L1_DEB_HSCX) + debugl1(cs, "Tiger stat rec %d/%d send %d", + bcs->hw.tiger.r_tot, bcs->hw.tiger.r_err, + bcs->hw.tiger.s_tot); + if ((cs->bcs[0].mode == L1_MODE_NULL) && + (cs->bcs[1].mode == L1_MODE_NULL)) { + cs->hw.njet.dmactrl = 0; + byteout(cs->hw.njet.base + NETJET_DMACTRL, + cs->hw.njet.dmactrl); + byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0); + } + if (cs->typ == ISDN_CTYPE_NETJET_S) + { + // led off + led = bc & 0x01; + led = 0x01 << (6 + led); // convert to mask + led = ~led; + cs->hw.njet.auxd &= led; + byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); + } + break; + case (L1_MODE_TRANS): + break; + case (L1_MODE_HDLC_56K): + case (L1_MODE_HDLC): + fill_mem(bcs, bcs->hw.tiger.send, + NETJET_DMA_TXSIZE, bc, 0xff); + bcs->hw.tiger.r_state = HDLC_ZERO_SEARCH; + bcs->hw.tiger.r_tot = 0; + bcs->hw.tiger.r_bitcnt = 0; + bcs->hw.tiger.r_one = 0; + bcs->hw.tiger.r_err = 0; + bcs->hw.tiger.s_tot = 0; + if (!cs->hw.njet.dmactrl) { fill_mem(bcs, bcs->hw.tiger.send, - NETJET_DMA_TXSIZE, bc, 0xff); - bcs->hw.tiger.r_state = HDLC_ZERO_SEARCH; - bcs->hw.tiger.r_tot = 0; - bcs->hw.tiger.r_bitcnt = 0; - bcs->hw.tiger.r_one = 0; - bcs->hw.tiger.r_err = 0; - bcs->hw.tiger.s_tot = 0; - if (! cs->hw.njet.dmactrl) { - fill_mem(bcs, bcs->hw.tiger.send, - NETJET_DMA_TXSIZE, !bc, 0xff); - cs->hw.njet.dmactrl = 1; - byteout(cs->hw.njet.base + NETJET_DMACTRL, - cs->hw.njet.dmactrl); - byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0x0f); + NETJET_DMA_TXSIZE, !bc, 0xff); + cs->hw.njet.dmactrl = 1; + byteout(cs->hw.njet.base + NETJET_DMACTRL, + cs->hw.njet.dmactrl); + byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0x0f); /* was 0x3f now 0x0f for TJ300 and TJ320 GE 13/07/00 */ - } - bcs->hw.tiger.sendp = bcs->hw.tiger.send; - bcs->hw.tiger.free = NETJET_DMA_TXSIZE; - test_and_set_bit(BC_FLG_EMPTY, &bcs->Flag); - if (cs->typ == ISDN_CTYPE_NETJET_S) - { - // led on - led = bc & 0x01; - led = 0x01 << (6 + led); // convert to mask - cs->hw.njet.auxd |= led; - byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); - } - break; + } + bcs->hw.tiger.sendp = bcs->hw.tiger.send; + bcs->hw.tiger.free = NETJET_DMA_TXSIZE; + test_and_set_bit(BC_FLG_EMPTY, &bcs->Flag); + if (cs->typ == ISDN_CTYPE_NETJET_S) + { + // led on + led = bc & 0x01; + led = 0x01 << (6 + led); // convert to mask + cs->hw.njet.auxd |= led; + byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); + } + break; } if (cs->debug & L1_DEB_HSCX) debugl1(cs, "tiger: set %x %x %x %x/%x pulse=%d", @@ -166,15 +166,15 @@ mode_tiger(struct BCState *bcs, int mode, int bc) static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s) { char tmp[128]; char *t = tmp; - int i=count,j; + int i = count, j; u_char *p = buf; t += sprintf(t, "tiger %s(%4d)", s, count); - while (i>0) { - if (i>16) - j=16; + while (i > 0) { + if (i > 16) + j = 16; else - j=i; + j = i; QuickHex(t, p, j); debugl1(cs, tmp); p += j; @@ -186,78 +186,78 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s // macro for 64k -#define MAKE_RAW_BYTE for (j=0; j<8; j++) { \ - bitcnt++;\ - s_val >>= 1;\ - if (val & 1) {\ - s_one++;\ - s_val |= 0x80;\ - } else {\ - s_one = 0;\ - s_val &= 0x7f;\ - }\ - if (bitcnt==8) {\ - bcs->hw.tiger.sendbuf[s_cnt++] = s_val;\ - bitcnt = 0;\ - }\ - if (s_one == 5) {\ - s_val >>= 1;\ - s_val &= 0x7f;\ - bitcnt++;\ - s_one = 0;\ - }\ - if (bitcnt==8) {\ - bcs->hw.tiger.sendbuf[s_cnt++] = s_val;\ - bitcnt = 0;\ - }\ - val >>= 1;\ - } +#define MAKE_RAW_BYTE for (j = 0; j < 8; j++) { \ + bitcnt++; \ + s_val >>= 1; \ + if (val & 1) { \ + s_one++; \ + s_val |= 0x80; \ + } else { \ + s_one = 0; \ + s_val &= 0x7f; \ + } \ + if (bitcnt == 8) { \ + bcs->hw.tiger.sendbuf[s_cnt++] = s_val; \ + bitcnt = 0; \ + } \ + if (s_one == 5) { \ + s_val >>= 1; \ + s_val &= 0x7f; \ + bitcnt++; \ + s_one = 0; \ + } \ + if (bitcnt == 8) { \ + bcs->hw.tiger.sendbuf[s_cnt++] = s_val; \ + bitcnt = 0; \ + } \ + val >>= 1; \ + } static int make_raw_data(struct BCState *bcs) { // this make_raw is for 64k - register u_int i,s_cnt=0; + register u_int i, s_cnt = 0; register u_char j; register u_char val; register u_char s_one = 0; register u_char s_val = 0; register u_char bitcnt = 0; u_int fcs; - + if (!bcs->tx_skb) { debugl1(bcs->cs, "tiger make_raw: NULL skb"); - return(1); + return (1); } bcs->hw.tiger.sendbuf[s_cnt++] = HDLC_FLAG_VALUE; fcs = PPP_INITFCS; - for (i=0; itx_skb->len; i++) { + for (i = 0; i < bcs->tx_skb->len; i++) { val = bcs->tx_skb->data[i]; - fcs = PPP_FCS (fcs, val); + fcs = PPP_FCS(fcs, val); MAKE_RAW_BYTE; } fcs ^= 0xffff; val = fcs & 0xff; MAKE_RAW_BYTE; - val = (fcs>>8) & 0xff; + val = (fcs >> 8) & 0xff; MAKE_RAW_BYTE; val = HDLC_FLAG_VALUE; - for (j=0; j<8; j++) { + for (j = 0; j < 8; j++) { bitcnt++; s_val >>= 1; if (val & 1) s_val |= 0x80; else s_val &= 0x7f; - if (bitcnt==8) { + if (bitcnt == 8) { bcs->hw.tiger.sendbuf[s_cnt++] = s_val; bitcnt = 0; } val >>= 1; } if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger make_raw: in %u out %d.%d", + debugl1(bcs->cs, "tiger make_raw: in %u out %d.%d", bcs->tx_skb->len, s_cnt, bitcnt); if (bitcnt) { - while (8>bitcnt++) { + while (8 > bitcnt++) { s_val >>= 1; s_val |= 0x80; } @@ -267,65 +267,65 @@ static int make_raw_data(struct BCState *bcs) { bcs->hw.tiger.sendcnt = s_cnt; bcs->tx_cnt -= bcs->tx_skb->len; bcs->hw.tiger.sp = bcs->hw.tiger.sendbuf; - return(0); + return (0); } // macro for 56k -#define MAKE_RAW_BYTE_56K for (j=0; j<8; j++) { \ - bitcnt++;\ - s_val >>= 1;\ - if (val & 1) {\ - s_one++;\ - s_val |= 0x80;\ - } else {\ - s_one = 0;\ - s_val &= 0x7f;\ - }\ - if (bitcnt==7) {\ - s_val >>= 1;\ - s_val |= 0x80;\ - bcs->hw.tiger.sendbuf[s_cnt++] = s_val;\ - bitcnt = 0;\ - }\ - if (s_one == 5) {\ - s_val >>= 1;\ - s_val &= 0x7f;\ - bitcnt++;\ - s_one = 0;\ - }\ - if (bitcnt==7) {\ - s_val >>= 1;\ - s_val |= 0x80;\ - bcs->hw.tiger.sendbuf[s_cnt++] = s_val;\ - bitcnt = 0;\ - }\ - val >>= 1;\ - } +#define MAKE_RAW_BYTE_56K for (j = 0; j < 8; j++) { \ + bitcnt++; \ + s_val >>= 1; \ + if (val & 1) { \ + s_one++; \ + s_val |= 0x80; \ + } else { \ + s_one = 0; \ + s_val &= 0x7f; \ + } \ + if (bitcnt == 7) { \ + s_val >>= 1; \ + s_val |= 0x80; \ + bcs->hw.tiger.sendbuf[s_cnt++] = s_val; \ + bitcnt = 0; \ + } \ + if (s_one == 5) { \ + s_val >>= 1; \ + s_val &= 0x7f; \ + bitcnt++; \ + s_one = 0; \ + } \ + if (bitcnt == 7) { \ + s_val >>= 1; \ + s_val |= 0x80; \ + bcs->hw.tiger.sendbuf[s_cnt++] = s_val; \ + bitcnt = 0; \ + } \ + val >>= 1; \ + } static int make_raw_data_56k(struct BCState *bcs) { // this make_raw is for 56k - register u_int i,s_cnt=0; + register u_int i, s_cnt = 0; register u_char j; register u_char val; register u_char s_one = 0; register u_char s_val = 0; register u_char bitcnt = 0; u_int fcs; - + if (!bcs->tx_skb) { debugl1(bcs->cs, "tiger make_raw_56k: NULL skb"); - return(1); + return (1); } val = HDLC_FLAG_VALUE; - for (j=0; j<8; j++) { + for (j = 0; j < 8; j++) { bitcnt++; s_val >>= 1; if (val & 1) s_val |= 0x80; else s_val &= 0x7f; - if (bitcnt==7) { + if (bitcnt == 7) { s_val >>= 1; s_val |= 0x80; bcs->hw.tiger.sendbuf[s_cnt++] = s_val; @@ -334,25 +334,25 @@ static int make_raw_data_56k(struct BCState *bcs) { val >>= 1; }; fcs = PPP_INITFCS; - for (i=0; itx_skb->len; i++) { + for (i = 0; i < bcs->tx_skb->len; i++) { val = bcs->tx_skb->data[i]; - fcs = PPP_FCS (fcs, val); + fcs = PPP_FCS(fcs, val); MAKE_RAW_BYTE_56K; } fcs ^= 0xffff; val = fcs & 0xff; MAKE_RAW_BYTE_56K; - val = (fcs>>8) & 0xff; + val = (fcs >> 8) & 0xff; MAKE_RAW_BYTE_56K; val = HDLC_FLAG_VALUE; - for (j=0; j<8; j++) { + for (j = 0; j < 8; j++) { bitcnt++; s_val >>= 1; if (val & 1) s_val |= 0x80; else s_val &= 0x7f; - if (bitcnt==7) { + if (bitcnt == 7) { s_val >>= 1; s_val |= 0x80; bcs->hw.tiger.sendbuf[s_cnt++] = s_val; @@ -361,10 +361,10 @@ static int make_raw_data_56k(struct BCState *bcs) { val >>= 1; } if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger make_raw_56k: in %u out %d.%d", + debugl1(bcs->cs, "tiger make_raw_56k: in %u out %d.%d", bcs->tx_skb->len, s_cnt, bitcnt); if (bitcnt) { - while (8>bitcnt++) { + while (8 > bitcnt++) { s_val >>= 1; s_val |= 0x80; } @@ -374,12 +374,12 @@ static int make_raw_data_56k(struct BCState *bcs) { bcs->hw.tiger.sendcnt = s_cnt; bcs->tx_cnt -= bcs->tx_skb->len; bcs->hw.tiger.sp = bcs->hw.tiger.sendbuf; - return(0); + return (0); } static void got_frame(struct BCState *bcs, int count) { struct sk_buff *skb; - + if (!(skb = dev_alloc_skb(count))) printk(KERN_WARNING "TIGER: receive out of memory\n"); else { @@ -388,18 +388,18 @@ static void got_frame(struct BCState *bcs, int count) { } test_and_set_bit(B_RCVBUFREADY, &bcs->event); schedule_work(&bcs->tqueue); - + if (bcs->cs->debug & L1_DEB_RECEIVE_FRAME) printframe(bcs->cs, bcs->hw.tiger.rcvbuf, count, "rec"); } -static void read_raw(struct BCState *bcs, u_int *buf, int cnt){ +static void read_raw(struct BCState *bcs, u_int *buf, int cnt) { int i; register u_char j; register u_char val; - u_int *pend = bcs->hw.tiger.rec +NETJET_DMA_RXSIZE -1; + u_int *pend = bcs->hw.tiger.rec + NETJET_DMA_RXSIZE - 1; register u_char state = bcs->hw.tiger.r_state; register u_char r_one = bcs->hw.tiger.r_one; register u_char r_val = bcs->hw.tiger.r_val; @@ -408,7 +408,7 @@ static void read_raw(struct BCState *bcs, u_int *buf, int cnt){ int bits; u_char mask; - if (bcs->mode == L1_MODE_HDLC) { // it's 64k + if (bcs->mode == L1_MODE_HDLC) { // it's 64k mask = 0xff; bits = 8; } @@ -416,8 +416,8 @@ static void read_raw(struct BCState *bcs, u_int *buf, int cnt){ mask = 0x7f; bits = 7; }; - for (i=0;ichannel ? ((*p>>8) & 0xff) : (*p & 0xff); + for (i = 0; i < cnt; i++) { + val = bcs->channel ? ((*p >> 8) & 0xff) : (*p & 0xff); p++; if (p > pend) p = bcs->hw.tiger.rec; @@ -428,137 +428,137 @@ static void read_raw(struct BCState *bcs, u_int *buf, int cnt){ r_one = 0; continue; } - for (j=0;jcs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger read_raw: zBit(%d,%d,%d) %x", - bcs->hw.tiger.r_tot,i,j,val); + debugl1(bcs->cs, "tiger read_raw: zBit(%d,%d,%d) %x", + bcs->hw.tiger.r_tot, i, j, val); } - } else if (state == HDLC_FLAG_SEARCH) { + } else if (state == HDLC_FLAG_SEARCH) { if (val & 1) { r_one++; - if (r_one>6) { - state=HDLC_ZERO_SEARCH; + if (r_one > 6) { + state = HDLC_ZERO_SEARCH; } } else { - if (r_one==6) { - bitcnt=0; - r_val=0; - state=HDLC_FLAG_FOUND; + if (r_one == 6) { + bitcnt = 0; + r_val = 0; + state = HDLC_FLAG_FOUND; if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger read_raw: flag(%d,%d,%d) %x", - bcs->hw.tiger.r_tot,i,j,val); + debugl1(bcs->cs, "tiger read_raw: flag(%d,%d,%d) %x", + bcs->hw.tiger.r_tot, i, j, val); } - r_one=0; + r_one = 0; } - } else if (state == HDLC_FLAG_FOUND) { + } else if (state == HDLC_FLAG_FOUND) { if (val & 1) { r_one++; - if (r_one>6) { - state=HDLC_ZERO_SEARCH; + if (r_one > 6) { + state = HDLC_ZERO_SEARCH; } else { r_val >>= 1; r_val |= 0x80; bitcnt++; } } else { - if (r_one==6) { - bitcnt=0; - r_val=0; - r_one=0; + if (r_one == 6) { + bitcnt = 0; + r_val = 0; + r_one = 0; val >>= 1; continue; - } else if (r_one!=5) { + } else if (r_one != 5) { r_val >>= 1; r_val &= 0x7f; bitcnt++; } - r_one=0; + r_one = 0; } if ((state != HDLC_ZERO_SEARCH) && - !(bitcnt & 7)) { - state=HDLC_FRAME_FOUND; + !(bitcnt & 7)) { + state = HDLC_FRAME_FOUND; bcs->hw.tiger.r_fcs = PPP_INITFCS; bcs->hw.tiger.rcvbuf[0] = r_val; - bcs->hw.tiger.r_fcs = PPP_FCS (bcs->hw.tiger.r_fcs, r_val); + bcs->hw.tiger.r_fcs = PPP_FCS(bcs->hw.tiger.r_fcs, r_val); if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger read_raw: byte1(%d,%d,%d) rval %x val %x i %x", - bcs->hw.tiger.r_tot,i,j,r_val,val, + debugl1(bcs->cs, "tiger read_raw: byte1(%d,%d,%d) rval %x val %x i %x", + bcs->hw.tiger.r_tot, i, j, r_val, val, bcs->cs->hw.njet.irqstat0); } } else if (state == HDLC_FRAME_FOUND) { if (val & 1) { r_one++; - if (r_one>6) { - state=HDLC_ZERO_SEARCH; - bitcnt=0; + if (r_one > 6) { + state = HDLC_ZERO_SEARCH; + bitcnt = 0; } else { r_val >>= 1; r_val |= 0x80; bitcnt++; } } else { - if (r_one==6) { - r_val=0; - r_one=0; + if (r_one == 6) { + r_val = 0; + r_one = 0; bitcnt++; if (bitcnt & 7) { debugl1(bcs->cs, "tiger: frame not byte aligned"); - state=HDLC_FLAG_SEARCH; + state = HDLC_FLAG_SEARCH; bcs->hw.tiger.r_err++; #ifdef ERROR_STATISTIC bcs->err_inv++; #endif } else { if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger frame end(%d,%d): fcs(%x) i %x", - i,j,bcs->hw.tiger.r_fcs, bcs->cs->hw.njet.irqstat0); + debugl1(bcs->cs, "tiger frame end(%d,%d): fcs(%x) i %x", + i, j, bcs->hw.tiger.r_fcs, bcs->cs->hw.njet.irqstat0); if (bcs->hw.tiger.r_fcs == PPP_GOODFCS) { - got_frame(bcs, (bitcnt>>3)-3); + got_frame(bcs, (bitcnt >> 3) - 3); } else { if (bcs->cs->debug) { debugl1(bcs->cs, "tiger FCS error"); printframe(bcs->cs, bcs->hw.tiger.rcvbuf, - (bitcnt>>3)-1, "rec"); + (bitcnt >> 3) - 1, "rec"); bcs->hw.tiger.r_err++; } #ifdef ERROR_STATISTIC - bcs->err_crc++; + bcs->err_crc++; #endif } - state=HDLC_FLAG_FOUND; + state = HDLC_FLAG_FOUND; } - bitcnt=0; - } else if (r_one==5) { + bitcnt = 0; + } else if (r_one == 5) { val >>= 1; - r_one=0; + r_one = 0; continue; } else { r_val >>= 1; r_val &= 0x7f; bitcnt++; } - r_one=0; + r_one = 0; } if ((state == HDLC_FRAME_FOUND) && - !(bitcnt & 7)) { - if ((bitcnt>>3)>=HSCX_BUFMAX) { + !(bitcnt & 7)) { + if ((bitcnt >> 3) >= HSCX_BUFMAX) { debugl1(bcs->cs, "tiger: frame too big"); - r_val=0; - state=HDLC_FLAG_SEARCH; + r_val = 0; + state = HDLC_FLAG_SEARCH; bcs->hw.tiger.r_err++; #ifdef ERROR_STATISTIC bcs->err_inv++; #endif } else { - bcs->hw.tiger.rcvbuf[(bitcnt>>3)-1] = r_val; - bcs->hw.tiger.r_fcs = - PPP_FCS (bcs->hw.tiger.r_fcs, r_val); + bcs->hw.tiger.rcvbuf[(bitcnt >> 3) - 1] = r_val; + bcs->hw.tiger.r_fcs = + PPP_FCS(bcs->hw.tiger.r_fcs, r_val); } } } @@ -574,10 +574,10 @@ static void read_raw(struct BCState *bcs, u_int *buf, int cnt){ void read_tiger(struct IsdnCardState *cs) { u_int *p; - int cnt = NETJET_DMA_RXSIZE/2; - + int cnt = NETJET_DMA_RXSIZE / 2; + if ((cs->hw.njet.irqstat0 & cs->hw.njet.last_is0) & NETJET_IRQM0_READ) { - debugl1(cs,"tiger warn read double dma %x/%x", + debugl1(cs, "tiger warn read double dma %x/%x", cs->hw.njet.irqstat0, cs->hw.njet.last_is0); #ifdef ERROR_STATISTIC if (cs->bcs[0].mode) @@ -589,7 +589,7 @@ void read_tiger(struct IsdnCardState *cs) { } else { cs->hw.njet.last_is0 &= ~NETJET_IRQM0_READ; cs->hw.njet.last_is0 |= (cs->hw.njet.irqstat0 & NETJET_IRQM0_READ); - } + } if (cs->hw.njet.irqstat0 & NETJET_IRQM0_READ_1) p = cs->bcs[0].hw.tiger.rec + NETJET_DMA_RXSIZE - 1; else @@ -612,20 +612,20 @@ void netjet_fill_dma(struct BCState *bcs) if (!bcs->tx_skb) return; if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger fill_dma1: c%d %4lx", bcs->channel, + debugl1(bcs->cs, "tiger fill_dma1: c%d %4lx", bcs->channel, bcs->Flag); if (test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) return; if (bcs->mode == L1_MODE_HDLC) { // it's 64k if (make_raw_data(bcs)) - return; + return; } else { // it's 56k if (make_raw_data_56k(bcs)) - return; + return; }; if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger fill_dma2: c%d %4lx", bcs->channel, + debugl1(bcs->cs, "tiger fill_dma2: c%d %4lx", bcs->channel, bcs->Flag); if (test_and_clear_bit(BC_FLG_NOFRAME, &bcs->Flag)) { write_raw(bcs, bcs->hw.tiger.sendp, bcs->hw.tiger.free); @@ -633,11 +633,11 @@ void netjet_fill_dma(struct BCState *bcs) p = bus_to_virt(inl(bcs->cs->hw.njet.base + NETJET_DMA_READ_ADR)); sp = bcs->hw.tiger.sendp; if (p == bcs->hw.tiger.s_end) - p = bcs->hw.tiger.send -1; + p = bcs->hw.tiger.send - 1; if (sp == bcs->hw.tiger.s_end) - sp = bcs->hw.tiger.send -1; + sp = bcs->hw.tiger.send - 1; cnt = p - sp; - if (cnt <0) { + if (cnt < 0) { write_raw(bcs, bcs->hw.tiger.sendp, bcs->hw.tiger.free); } else { p++; @@ -655,30 +655,30 @@ void netjet_fill_dma(struct BCState *bcs) cnt = bcs->hw.tiger.s_end - p; if (cnt < 2) { p = bcs->hw.tiger.send + 1; - cnt = NETJET_DMA_TXSIZE/2 - 2; + cnt = NETJET_DMA_TXSIZE / 2 - 2; } else { p++; p++; - if (cnt <= (NETJET_DMA_TXSIZE/2)) - cnt += NETJET_DMA_TXSIZE/2; + if (cnt <= (NETJET_DMA_TXSIZE / 2)) + cnt += NETJET_DMA_TXSIZE / 2; cnt--; cnt--; } write_raw(bcs, p, cnt); } if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger fill_dma3: c%d %4lx", bcs->channel, + debugl1(bcs->cs, "tiger fill_dma3: c%d %4lx", bcs->channel, bcs->Flag); } static void write_raw(struct BCState *bcs, u_int *buf, int cnt) { - u_int mask, val, *p=buf; + u_int mask, val, *p = buf; u_int i, s_cnt; - - if (cnt <= 0) - return; + + if (cnt <= 0) + return; if (test_bit(BC_FLG_BUSY, &bcs->Flag)) { - if (bcs->hw.tiger.sendcnt> cnt) { + if (bcs->hw.tiger.sendcnt > cnt) { s_cnt = cnt; bcs->hw.tiger.sendcnt -= cnt; } else { @@ -689,17 +689,17 @@ static void write_raw(struct BCState *bcs, u_int *buf, int cnt) { mask = 0xffff00ff; else mask = 0xffffff00; - for (i=0; ichannel ? ((bcs->hw.tiger.sp[i] <<8) & 0xff00) : + for (i = 0; i < s_cnt; i++) { + val = bcs->channel ? ((bcs->hw.tiger.sp[i] << 8) & 0xff00) : (bcs->hw.tiger.sp[i]); - *p &= mask; + *p &= mask; *p++ |= val; - if (p>bcs->hw.tiger.s_end) + if (p > bcs->hw.tiger.s_end) p = bcs->hw.tiger.send; } bcs->hw.tiger.s_tot += s_cnt; if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger write_raw: c%d %p-%p %d/%d %d %x", bcs->channel, + debugl1(bcs->cs, "tiger write_raw: c%d %p-%p %d/%d %d %x", bcs->channel, buf, p, s_cnt, cnt, bcs->hw.tiger.sendcnt, bcs->cs->hw.njet.irqstat0); if (bcs->cs->debug & L1_DEB_HSCX_FIFO) @@ -708,10 +708,10 @@ static void write_raw(struct BCState *bcs, u_int *buf, int cnt) { bcs->hw.tiger.sendp = p; if (!bcs->hw.tiger.sendcnt) { if (!bcs->tx_skb) { - debugl1(bcs->cs,"tiger write_raw: NULL skb s_cnt %d", s_cnt); + debugl1(bcs->cs, "tiger write_raw: NULL skb s_cnt %d", s_cnt); } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->tx_skb->len; @@ -723,7 +723,7 @@ static void write_raw(struct BCState *bcs, u_int *buf, int cnt) { } test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); bcs->hw.tiger.free = cnt - s_cnt; - if (bcs->hw.tiger.free > (NETJET_DMA_TXSIZE/2)) + if (bcs->hw.tiger.free > (NETJET_DMA_TXSIZE / 2)) test_and_set_bit(BC_FLG_HALF, &bcs->Flag); else { test_and_clear_bit(BC_FLG_HALF, &bcs->Flag); @@ -734,9 +734,9 @@ static void write_raw(struct BCState *bcs, u_int *buf, int cnt) { } else { mask ^= 0xffffffff; if (s_cnt < cnt) { - for (i=s_cnt; ibcs->hw.tiger.s_end) + if (p > bcs->hw.tiger.s_end) p = bcs->hw.tiger.send; } if (bcs->cs->debug & L1_DEB_HSCX) @@ -752,20 +752,20 @@ static void write_raw(struct BCState *bcs, u_int *buf, int cnt) { fill_mem(bcs, buf, cnt, bcs->channel, 0xff); bcs->hw.tiger.free += cnt; if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger write_raw: fill half"); + debugl1(bcs->cs, "tiger write_raw: fill half"); } else if (test_and_clear_bit(BC_FLG_HALF, &bcs->Flag)) { test_and_set_bit(BC_FLG_EMPTY, &bcs->Flag); fill_mem(bcs, buf, cnt, bcs->channel, 0xff); if (bcs->cs->debug & L1_DEB_HSCX) - debugl1(bcs->cs,"tiger write_raw: fill full"); + debugl1(bcs->cs, "tiger write_raw: fill full"); } } void write_tiger(struct IsdnCardState *cs) { - u_int *p, cnt = NETJET_DMA_TXSIZE/2; - + u_int *p, cnt = NETJET_DMA_TXSIZE / 2; + if ((cs->hw.njet.irqstat0 & cs->hw.njet.last_is0) & NETJET_IRQM0_WRITE) { - debugl1(cs,"tiger warn write double dma %x/%x", + debugl1(cs, "tiger warn write double dma %x/%x", cs->hw.njet.irqstat0, cs->hw.njet.last_is0); #ifdef ERROR_STATISTIC if (cs->bcs[0].mode) @@ -777,7 +777,7 @@ void write_tiger(struct IsdnCardState *cs) { } else { cs->hw.njet.last_is0 &= ~NETJET_IRQM0_WRITE; cs->hw.njet.last_is0 |= (cs->hw.njet.irqstat0 & NETJET_IRQM0_WRITE); - } + } if (cs->hw.njet.irqstat0 & NETJET_IRQM0_WRITE_1) p = cs->bcs[0].hw.tiger.send + NETJET_DMA_TXSIZE - 1; else @@ -797,55 +797,55 @@ tiger_l2l1(struct PStack *st, int pr, void *arg) u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - printk(KERN_WARNING "tiger_l2l1: this shouldn't happen\n"); - } else { - bcs->tx_skb = skb; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - mode_tiger(bcs, st->l1.mode, st->l1.bc); - /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG */ - spin_unlock_irqrestore(&bcs->cs->lock, flags); - bcs->cs->cardmsg(bcs->cs, MDL_BC_ASSIGN, (void *)(&st->l1.bc)); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG */ - bcs->cs->cardmsg(bcs->cs, MDL_BC_RELEASE, (void *)(&st->l1.bc)); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - mode_tiger(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); - break; + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { + bcs->tx_skb = skb; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + printk(KERN_WARNING "tiger_l2l1: this shouldn't happen\n"); + } else { + bcs->tx_skb = skb; + bcs->cs->BC_Send_Data(bcs); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + mode_tiger(bcs, st->l1.mode, st->l1.bc); + /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG */ + spin_unlock_irqrestore(&bcs->cs->lock, flags); + bcs->cs->cardmsg(bcs->cs, MDL_BC_ASSIGN, (void *)(&st->l1.bc)); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG */ + bcs->cs->cardmsg(bcs->cs, MDL_BC_RELEASE, (void *)(&st->l1.bc)); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + mode_tiger(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -908,33 +908,33 @@ setstack_tiger(struct PStack *st, struct BCState *bcs) return (0); } - + void inittiger(struct IsdnCardState *cs) { if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_TXSIZE * sizeof(unsigned int), - GFP_KERNEL | GFP_DMA))) { + GFP_KERNEL | GFP_DMA))) { printk(KERN_WARNING "HiSax: No memory for tiger.send\n"); return; } - cs->bcs[0].hw.tiger.s_irq = cs->bcs[0].hw.tiger.send + NETJET_DMA_TXSIZE/2 - 1; + cs->bcs[0].hw.tiger.s_irq = cs->bcs[0].hw.tiger.send + NETJET_DMA_TXSIZE / 2 - 1; cs->bcs[0].hw.tiger.s_end = cs->bcs[0].hw.tiger.send + NETJET_DMA_TXSIZE - 1; cs->bcs[1].hw.tiger.send = cs->bcs[0].hw.tiger.send; cs->bcs[1].hw.tiger.s_irq = cs->bcs[0].hw.tiger.s_irq; cs->bcs[1].hw.tiger.s_end = cs->bcs[0].hw.tiger.s_end; - + memset(cs->bcs[0].hw.tiger.send, 0xff, NETJET_DMA_TXSIZE * sizeof(unsigned int)); debugl1(cs, "tiger: send buf %p - %p", cs->bcs[0].hw.tiger.send, cs->bcs[0].hw.tiger.send + NETJET_DMA_TXSIZE - 1); outl(virt_to_bus(cs->bcs[0].hw.tiger.send), - cs->hw.njet.base + NETJET_DMA_READ_START); + cs->hw.njet.base + NETJET_DMA_READ_START); outl(virt_to_bus(cs->bcs[0].hw.tiger.s_irq), - cs->hw.njet.base + NETJET_DMA_READ_IRQ); + cs->hw.njet.base + NETJET_DMA_READ_IRQ); outl(virt_to_bus(cs->bcs[0].hw.tiger.s_end), - cs->hw.njet.base + NETJET_DMA_READ_END); + cs->hw.njet.base + NETJET_DMA_READ_END); if (!(cs->bcs[0].hw.tiger.rec = kmalloc(NETJET_DMA_RXSIZE * sizeof(unsigned int), - GFP_KERNEL | GFP_DMA))) { + GFP_KERNEL | GFP_DMA))) { printk(KERN_WARNING "HiSax: No memory for tiger.rec\n"); return; @@ -944,11 +944,11 @@ inittiger(struct IsdnCardState *cs) cs->bcs[1].hw.tiger.rec = cs->bcs[0].hw.tiger.rec; memset(cs->bcs[0].hw.tiger.rec, 0xff, NETJET_DMA_RXSIZE * sizeof(unsigned int)); outl(virt_to_bus(cs->bcs[0].hw.tiger.rec), - cs->hw.njet.base + NETJET_DMA_WRITE_START); - outl(virt_to_bus(cs->bcs[0].hw.tiger.rec + NETJET_DMA_RXSIZE/2 - 1), - cs->hw.njet.base + NETJET_DMA_WRITE_IRQ); + cs->hw.njet.base + NETJET_DMA_WRITE_START); + outl(virt_to_bus(cs->bcs[0].hw.tiger.rec + NETJET_DMA_RXSIZE / 2 - 1), + cs->hw.njet.base + NETJET_DMA_WRITE_IRQ); outl(virt_to_bus(cs->bcs[0].hw.tiger.rec + NETJET_DMA_RXSIZE - 1), - cs->hw.njet.base + NETJET_DMA_WRITE_END); + cs->hw.njet.base + NETJET_DMA_WRITE_END); debugl1(cs, "tiger: dmacfg %x/%x pulse=%d", inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR), inl(cs->hw.njet.base + NETJET_DMA_READ_ADR), @@ -979,4 +979,3 @@ release_io_netjet(struct IsdnCardState *cs) releasetiger(cs); release_region(cs->hw.njet.base, 256); } - diff --git a/drivers/isdn/hisax/netjet.h b/drivers/isdn/hisax/netjet.h index 68e504d4ebf9..70590d5d5e64 100644 --- a/drivers/isdn/hisax/netjet.h +++ b/drivers/isdn/hisax/netjet.h @@ -6,13 +6,13 @@ * Copyright by Karsten Keil * by Matt Henderson, * Traverse Technologies P/L www.traverse.com.au - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define NETJET_CTRL 0x00 @@ -67,4 +67,3 @@ void netjet_fill_dma(struct BCState *bcs); void netjet_interrupt(int intno, void *dev_id); void inittiger(struct IsdnCardState *cs); void release_io_netjet(struct IsdnCardState *cs); - diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c index ccaa6e13310f..6569e0315cca 100644 --- a/drivers/isdn/hisax/niccy.c +++ b/drivers/isdn/hisax/niccy.c @@ -5,10 +5,10 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * + * * Thanks to Dr. Neuhaus and SAGEM for information * */ @@ -23,7 +23,7 @@ static const char *niccy_revision = "$Revision: 1.21.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define ISAC_PCI_DATA 0 @@ -53,21 +53,21 @@ static inline u_char readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void readfifo(unsigned int ale, unsigned int adr, u_char off, - u_char *data, int size) + u_char *data, int size) { byteout(ale, off); insb(adr, data, size); } static inline void writereg(unsigned int ale, unsigned int adr, u_char off, - u_char data) + u_char data) { byteout(ale, off); byteout(adr, data); } static inline void writefifo(unsigned int ale, unsigned int adr, u_char off, - u_char *data, int size) + u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -85,12 +85,12 @@ static void WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset, value); } -static void ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +static void ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size); } -static void WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +static void WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size); } @@ -98,26 +98,26 @@ static void WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) static u_char ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) { return readreg(cs->hw.niccy.hscx_ale, - cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0)); + cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0)); } static void WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, - u_char value) + u_char value) { writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0), value); } -#define READHSCX(cs, nr, reg) readreg(cs->hw.niccy.hscx_ale, \ - cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.niccy.hscx_ale, \ - cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.niccy.hscx_ale, \ + cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.niccy.hscx_ale, \ + cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.niccy.hscx_ale, \ - cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.niccy.hscx_ale, \ + cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt) #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.niccy.hscx_ale, \ - cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt) + cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -138,7 +138,7 @@ static irqreturn_t niccy_interrupt(int intno, void *dev_id) outl(ival, cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); } val = readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, - HSCX_ISTA + 0x40); + HSCX_ISTA + 0x40); Start_HSCX: if (val) hscx_int_main(cs, val); @@ -147,7 +147,7 @@ static irqreturn_t niccy_interrupt(int intno, void *dev_id) if (val) isac_interrupt(cs, val); val = readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, - HSCX_ISTA + 0x40); + HSCX_ISTA + 0x40); if (val) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "HSCX IntStat after IntRoutine"); @@ -165,7 +165,7 @@ static irqreturn_t niccy_interrupt(int intno, void *dev_id) writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_MASK, 0xFF); writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_MASK, 0); writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK, 0); - writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK + 0x40,0); + writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK + 0x40, 0); spin_unlock_irqrestore(&cs->lock, flags); return IRQ_HANDLED; } @@ -241,32 +241,32 @@ int __devinit setup_niccy(struct IsdnCard *card) int err; pnp_c = pnp_find_card(ISAPNP_VENDOR('S', 'D', 'A'), - ISAPNP_FUNCTION(0x0150), pnp_c); + ISAPNP_FUNCTION(0x0150), pnp_c); if (pnp_c) { pnp_d = pnp_find_dev(pnp_c, - ISAPNP_VENDOR('S', 'D', 'A'), - ISAPNP_FUNCTION(0x0150), pnp_d); + ISAPNP_VENDOR('S', 'D', 'A'), + ISAPNP_FUNCTION(0x0150), pnp_d); if (!pnp_d) { printk(KERN_ERR "NiccyPnP: PnP error card " - "found, no device\n"); + "found, no device\n"); return 0; } pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev " - "ret(%d)\n", __func__, err); + "ret(%d)\n", __func__, err); return 0; } card->para[1] = pnp_port_start(pnp_d, 0); card->para[2] = pnp_port_start(pnp_d, 1); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1] || - !card->para[2]) { + !card->para[2]) { printk(KERN_ERR "NiccyPnP:some resources are " - "missing %ld/%lx/%lx\n", - card->para[0], card->para[1], - card->para[2]); + "missing %ld/%lx/%lx\n", + card->para[0], card->para[1], + card->para[2]); pnp_disable_dev(pnp_d); return 0; } @@ -284,15 +284,15 @@ int __devinit setup_niccy(struct IsdnCard *card) cs->irq = card->para[0]; if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) { printk(KERN_WARNING "HiSax: NICCY data port %x-%x " - "already in use\n", - cs->hw.niccy.isac, cs->hw.niccy.isac + 1); + "already in use\n", + cs->hw.niccy.isac, cs->hw.niccy.isac + 1); return 0; } if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) { printk(KERN_WARNING "HiSax: NICCY address port %x-%x " - "already in use\n", - cs->hw.niccy.isac_ale, - cs->hw.niccy.isac_ale + 1); + "already in use\n", + cs->hw.niccy.isac_ale, + cs->hw.niccy.isac_ale + 1); release_region(cs->hw.niccy.isac, 2); return 0; } @@ -303,8 +303,8 @@ int __devinit setup_niccy(struct IsdnCard *card) u_int pci_ioaddr; cs->subtyp = 0; if ((niccy_dev = hisax_find_pci_device(PCI_VENDOR_ID_SATSAGEM, - PCI_DEVICE_ID_SATSAGEM_NICCY, - niccy_dev))) { + PCI_DEVICE_ID_SATSAGEM_NICCY, + niccy_dev))) { if (pci_enable_device(niccy_dev)) return 0; /* get IRQ */ @@ -357,8 +357,8 @@ int __devinit setup_niccy(struct IsdnCard *card) #endif /* CONFIG_PCI */ } printk(KERN_INFO "HiSax: NICCY %s config irq:%d data:0x%X ale:0x%X\n", - (cs->subtyp == 1) ? "PnP" : "PCI", - cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale); + (cs->subtyp == 1) ? "PnP" : "PCI", + cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; @@ -372,7 +372,7 @@ int __devinit setup_niccy(struct IsdnCard *card) ISACVersion(cs, "Niccy:"); if (HscxVersion(cs, "Niccy:")) { printk(KERN_WARNING "Niccy: wrong HSCX versions check IO " - "address\n"); + "address\n"); release_io_niccy(cs); return 0; } diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c index a1b89524b505..f36ff69c07e1 100644 --- a/drivers/isdn/hisax/nj_s.c +++ b/drivers/isdn/hisax/nj_s.c @@ -18,7 +18,7 @@ static const char *NETjet_S_revision = "$Revision: 2.13.2.4 $"; static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) { - return(5); + return (5); } static void dummywr(struct IsdnCardState *cs, int chan, u_char off, u_char value) @@ -46,48 +46,48 @@ netjet_s_interrupt(int intno, void *dev_id) s1val = 1; } else s1val = 0; - /* + /* * read/write stat0 is better, because lower IRQ rate * Note the IRQ is on for 125 us if a condition match * thats long on modern CPU and so the IRQ is reentered * all the time. */ s0val = bytein(cs->hw.njet.base + NETJET_IRQSTAT0); - if ((s0val | s1val)==0) { // shared IRQ + if ((s0val | s1val) == 0) { // shared IRQ spin_unlock_irqrestore(&cs->lock, flags); return IRQ_NONE; - } + } if (s0val) byteout(cs->hw.njet.base + NETJET_IRQSTAT0, s0val); /* start new code 13/07/00 GE */ /* set bits in sval to indicate which page is free */ if (inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR) < - inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ)) + inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ)) /* the 2nd write page is free */ s0val = 0x08; else /* the 1st write page is free */ - s0val = 0x04; + s0val = 0x04; if (inl(cs->hw.njet.base + NETJET_DMA_READ_ADR) < - inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ)) + inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ)) /* the 2nd read page is free */ s0val |= 0x02; else /* the 1st read page is free */ - s0val |= 0x01; + s0val |= 0x01; if (s0val != cs->hw.njet.last_is0) /* we have a DMA interrupt */ { if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { printk(KERN_WARNING "nj LOCK_ATOMIC s0val %x->%x\n", - cs->hw.njet.last_is0, s0val); + cs->hw.njet.last_is0, s0val); spin_unlock_irqrestore(&cs->lock, flags); return IRQ_HANDLED; } cs->hw.njet.irqstat0 = s0val; - if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) != - (cs->hw.njet.last_is0 & NETJET_IRQM0_READ)) + if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) != + (cs->hw.njet.last_is0 & NETJET_IRQM0_READ)) /* we have a read dma int */ read_tiger(cs); if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_WRITE) != - (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE)) + (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE)) /* we have a write dma int */ write_tiger(cs); /* end new code 13/07/00 GE */ @@ -124,28 +124,28 @@ NETjet_S_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_netjet_s(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_netjet(cs); - return(0); - case CARD_INIT: - reset_netjet_s(cs); - inittiger(cs); - spin_lock_irqsave(&cs->lock, flags); - clear_pending_isac_ints(cs); - initisac(cs); - /* Reenable all IRQ */ - cs->writeisac(cs, ISAC_MASK, 0); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_netjet_s(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_netjet(cs); + return (0); + case CARD_INIT: + reset_netjet_s(cs); + inittiger(cs); + spin_lock_irqsave(&cs->lock, flags); + clear_pending_isac_ints(cs); + initisac(cs); + /* Reenable all IRQ */ + cs->writeisac(cs, ISAC_MASK, 0); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } static int __devinit njs_pci_probe(struct pci_dev *dev_netjet, @@ -154,17 +154,17 @@ static int __devinit njs_pci_probe(struct pci_dev *dev_netjet, u32 cfg; if (pci_enable_device(dev_netjet)) - return(0); + return (0); pci_set_master(dev_netjet); cs->irq = dev_netjet->irq; if (!cs->irq) { printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n"); - return(0); + return (0); } cs->hw.njet.base = pci_resource_start(dev_netjet, 0); if (!cs->hw.njet.base) { printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n"); - return(0); + return (0); } /* the TJ300 and TJ320 must be detected, the IRQ handling is different * unfortunately the chips use the same device ID, but the TJ320 has @@ -177,14 +177,14 @@ static int __devinit njs_pci_probe(struct pci_dev *dev_netjet, cs->subtyp = 0; /* TJ300 */ /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */ if ((dev_netjet->subsystem_vendor == 0x55) && - (dev_netjet->subsystem_device == 0x02)) { + (dev_netjet->subsystem_device == 0x02)) { printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n"); printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n"); - return(0); + return (0); } /* end new code */ - return(1); + return (1); } static int __devinit njs_cs_init(struct IsdnCard *card, @@ -209,18 +209,18 @@ static int __devinit njs_cs_init(struct IsdnCard *card, byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ); byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); - switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) ) + switch (((NETjet_ReadIC(cs, ISAC_RBCH) >> 5) & 3)) { - case 0 : - return 1; /* end loop */ + case 0: + return 1; /* end loop */ - case 3 : - printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" ); - return -1; /* continue looping */ + case 3: + printk(KERN_WARNING "NETjet-S: NETspider-U PCI card found\n"); + return -1; /* continue looping */ - default : - printk( KERN_WARNING "NETjet-S: No PCI card found\n" ); - return 0; /* end loop & function */ + default: + printk(KERN_WARNING "NETjet-S: No PCI card found\n"); + return 0; /* end loop & function */ } return 1; /* end loop */ } @@ -231,8 +231,8 @@ static int __devinit njs_cs_init_rest(struct IsdnCard *card, const int bytecnt = 256; printk(KERN_INFO - "NETjet-S: %s card configured at %#lx IRQ %d\n", - cs->subtyp ? "TJ320" : "TJ300", cs->hw.njet.base, cs->irq); + "NETjet-S: %s card configured at %#lx IRQ %d\n", + cs->subtyp ? "TJ320" : "TJ300", cs->hw.njet.base, cs->irq); if (!request_region(cs->hw.njet.base, bytecnt, "netjet-s isdn")) { printk(KERN_WARNING "HiSax: NETjet-S config port %#lx-%#lx already in use\n", @@ -271,24 +271,24 @@ setup_netjet_s(struct IsdnCard *card) strcpy(tmp, NETjet_S_revision); printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_NETJET_S) - return(0); + return (0); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - for ( ;; ) + for (;;) { if ((dev_netjet = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET, - PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { + PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { ret = njs_pci_probe(dev_netjet, cs); if (!ret) - return(0); + return (0); } else { printk(KERN_WARNING "NETjet-S: No PCI card found\n"); - return(0); + return (0); } ret = njs_cs_init(card, cs); if (!ret) - return(0); + return (0); if (ret > 0) break; /* otherwise, ret < 0, continue looping */ diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c index 095e974aed80..333484aef425 100644 --- a/drivers/isdn/hisax/nj_u.c +++ b/drivers/isdn/hisax/nj_u.c @@ -1,4 +1,4 @@ -/* $Id: nj_u.c,v 2.14.2.3 2004/01/13 14:31:26 keil Exp $ +/* $Id: nj_u.c,v 2.14.2.3 2004/01/13 14:31:26 keil Exp $ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. @@ -18,7 +18,7 @@ static const char *NETjet_U_revision = "$Revision: 2.14.2.3 $"; static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off) { - return(5); + return (5); } static void dummywr(struct IsdnCardState *cs, int chan, u_char off, u_char value) @@ -34,7 +34,7 @@ netjet_u_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); if (!((sval = bytein(cs->hw.njet.base + NETJET_IRQSTAT1)) & - NETJET_ISACIRQ)) { + NETJET_ISACIRQ)) { val = NETjet_ReadIC(cs, ICC_ISTA); if (cs->debug & L1_DEB_ISAC) debugl1(cs, "tiger: i1 %x %x", sval, val); @@ -47,17 +47,17 @@ netjet_u_interrupt(int intno, void *dev_id) /* start new code 13/07/00 GE */ /* set bits in sval to indicate which page is free */ if (inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR) < - inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ)) + inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ)) /* the 2nd write page is free */ sval = 0x08; else /* the 1st write page is free */ - sval = 0x04; + sval = 0x04; if (inl(cs->hw.njet.base + NETJET_DMA_READ_ADR) < - inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ)) + inl(cs->hw.njet.base + NETJET_DMA_READ_IRQ)) /* the 2nd read page is free */ sval = sval | 0x02; else /* the 1st read page is free */ - sval = sval | 0x01; + sval = sval | 0x01; if (sval != cs->hw.njet.last_is0) /* we have a DMA interrupt */ { if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { @@ -65,12 +65,12 @@ netjet_u_interrupt(int intno, void *dev_id) return IRQ_HANDLED; } cs->hw.njet.irqstat0 = sval; - if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) != - (cs->hw.njet.last_is0 & NETJET_IRQM0_READ)) + if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) != + (cs->hw.njet.last_is0 & NETJET_IRQM0_READ)) /* we have a read dma int */ read_tiger(cs); if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_WRITE) != - (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE)) + (cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE)) /* we have a write dma int */ write_tiger(cs); /* end new code 13/07/00 GE */ @@ -104,45 +104,45 @@ NETjet_U_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_netjet_u(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_netjet(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inittiger(cs); - reset_netjet_u(cs); - clear_pending_icc_ints(cs); - initicc(cs); - /* Reenable all IRQ */ - cs->writeisac(cs, ICC_MASK, 0); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_netjet_u(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_netjet(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inittiger(cs); + reset_netjet_u(cs); + clear_pending_icc_ints(cs); + initicc(cs); + /* Reenable all IRQ */ + cs->writeisac(cs, ICC_MASK, 0); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } static int __devinit nju_pci_probe(struct pci_dev *dev_netjet, struct IsdnCardState *cs) { if (pci_enable_device(dev_netjet)) - return(0); + return (0); pci_set_master(dev_netjet); cs->irq = dev_netjet->irq; if (!cs->irq) { printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n"); - return(0); + return (0); } cs->hw.njet.base = pci_resource_start(dev_netjet, 0); if (!cs->hw.njet.base) { printk(KERN_WARNING "NETspider-U: No IO-Adr for PCI card found\n"); - return(0); + return (0); } return (1); @@ -171,18 +171,18 @@ static int __devinit nju_cs_init(struct IsdnCard *card, byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ); byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); - switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) ) + switch (((NETjet_ReadIC(cs, ICC_RBCH) >> 5) & 3)) { - case 3 : - return 1; /* end loop */ + case 3: + return 1; /* end loop */ - case 0 : - printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" ); - return -1; /* continue looping */ + case 0: + printk(KERN_WARNING "NETspider-U: NETjet-S PCI card found\n"); + return -1; /* continue looping */ - default : - printk( KERN_WARNING "NETspider-U: No PCI card found\n" ); - return 0; /* end loop & function */ + default: + printk(KERN_WARNING "NETspider-U: No PCI card found\n"); + return 0; /* end loop & function */ } return 1; /* end loop */ } @@ -193,8 +193,8 @@ static int __devinit nju_cs_init_rest(struct IsdnCard *card, const int bytecnt = 256; printk(KERN_INFO - "NETspider-U: PCI card configured at %#lx IRQ %d\n", - cs->hw.njet.base, cs->irq); + "NETspider-U: PCI card configured at %#lx IRQ %d\n", + cs->hw.njet.base, cs->irq); if (!request_region(cs->hw.njet.base, bytecnt, "netspider-u isdn")) { printk(KERN_WARNING "HiSax: NETspider-U config port %#lx-%#lx " @@ -235,19 +235,19 @@ setup_netjet_u(struct IsdnCard *card) strcpy(tmp, NETjet_U_revision); printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp)); if (cs->typ != ISDN_CTYPE_NETJET_U) - return(0); + return (0); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); - for ( ;; ) + for (;;) { if ((dev_netjet = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET, - PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { + PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { ret = nju_pci_probe(dev_netjet, cs); if (!ret) - return(0); + return (0); } else { printk(KERN_WARNING "NETspider-U: No PCI card found\n"); - return(0); + return (0); } ret = nju_cs_init(card, cs); diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c index c0771f98fa11..041bf52d9d0a 100644 --- a/drivers/isdn/hisax/q931.c +++ b/drivers/isdn/hisax/q931.c @@ -21,7 +21,7 @@ #include "l3_1tr6.h" void -iecpy(u_char * dest, u_char * iestart, int ieoffset) +iecpy(u_char *dest, u_char *iestart, int ieoffset) { u_char *p; int l; @@ -215,7 +215,7 @@ prbits(char *dest, u_char b, int start, int len) static u_char * -skipext(u_char * p) +skipext(u_char *p) { while (!(*p++ & 0x80)); return (p); @@ -442,7 +442,7 @@ struct CauseValue { static int -prcause(char *dest, u_char * p) +prcause(char *dest, u_char *p) { u_char *end; char *dp = dest; @@ -519,7 +519,7 @@ struct MessageType cause_1tr6[] = static int cause_1tr6_len = ARRAY_SIZE(cause_1tr6); static int -prcause_1tr6(char *dest, u_char * p) +prcause_1tr6(char *dest, u_char *p) { char *dp = dest; int i, cause; @@ -554,7 +554,7 @@ prcause_1tr6(char *dest, u_char * p) } static int -prchident(char *dest, u_char * p) +prchident(char *dest, u_char *p) { char *dp = dest; @@ -566,7 +566,7 @@ prchident(char *dest, u_char * p) } static int -prcalled(char *dest, u_char * p) +prcalled(char *dest, u_char *p) { int l; char *dp = dest; @@ -583,7 +583,7 @@ prcalled(char *dest, u_char * p) return (dp - dest); } static int -prcalling(char *dest, u_char * p) +prcalling(char *dest, u_char *p) { int l; char *dp = dest; @@ -610,7 +610,7 @@ prcalling(char *dest, u_char * p) static int -prbearer(char *dest, u_char * p) +prbearer(char *dest, u_char *p) { char *dp = dest, ch; @@ -658,7 +658,7 @@ prbearer(char *dest, u_char * p) static int -prbearer_ni1(char *dest, u_char * p) +prbearer_ni1(char *dest, u_char *p) { char *dp = dest; u_char len; @@ -668,46 +668,46 @@ prbearer_ni1(char *dest, u_char * p) dp += sprintf(dp, " octet 3 "); dp += prbits(dp, *p, 8, 8); switch (*p++) { - case 0x80: - dp += sprintf(dp, " Speech"); - break; - case 0x88: - dp += sprintf(dp, " Unrestricted digital information"); - break; - case 0x90: - dp += sprintf(dp, " 3.1 kHz audio"); - break; - default: - dp += sprintf(dp, " Unknown information-transfer capability"); + case 0x80: + dp += sprintf(dp, " Speech"); + break; + case 0x88: + dp += sprintf(dp, " Unrestricted digital information"); + break; + case 0x90: + dp += sprintf(dp, " 3.1 kHz audio"); + break; + default: + dp += sprintf(dp, " Unknown information-transfer capability"); } *dp++ = '\n'; dp += sprintf(dp, " octet 4 "); dp += prbits(dp, *p, 8, 8); switch (*p++) { - case 0x90: - dp += sprintf(dp, " 64 kbps, circuit mode"); - break; - case 0xc0: - dp += sprintf(dp, " Packet mode"); - break; - default: - dp += sprintf(dp, " Unknown transfer mode"); + case 0x90: + dp += sprintf(dp, " 64 kbps, circuit mode"); + break; + case 0xc0: + dp += sprintf(dp, " Packet mode"); + break; + default: + dp += sprintf(dp, " Unknown transfer mode"); } *dp++ = '\n'; if (len > 2) { dp += sprintf(dp, " octet 5 "); dp += prbits(dp, *p, 8, 8); switch (*p++) { - case 0x21: - dp += sprintf(dp, " Rate adaption\n"); - dp += sprintf(dp, " octet 5a "); - dp += prbits(dp, *p, 8, 8); - break; - case 0xa2: - dp += sprintf(dp, " u-law"); - break; - default: - dp += sprintf(dp, " Unknown UI layer 1 protocol"); + case 0x21: + dp += sprintf(dp, " Rate adaption\n"); + dp += sprintf(dp, " octet 5a "); + dp += prbits(dp, *p, 8, 8); + break; + case 0xa2: + dp += sprintf(dp, " u-law"); + break; + default: + dp += sprintf(dp, " Unknown UI layer 1 protocol"); } *dp++ = '\n'; } @@ -715,7 +715,7 @@ prbearer_ni1(char *dest, u_char * p) } static int -general(char *dest, u_char * p) +general(char *dest, u_char *p) { char *dp = dest; char ch = ' '; @@ -742,7 +742,7 @@ general(char *dest, u_char * p) } static int -general_ni1(char *dest, u_char * p) +general_ni1(char *dest, u_char *p) { char *dp = dest; char ch = ' '; @@ -769,7 +769,7 @@ general_ni1(char *dest, u_char * p) } static int -prcharge(char *dest, u_char * p) +prcharge(char *dest, u_char *p) { char *dp = dest; int l; @@ -786,7 +786,7 @@ prcharge(char *dest, u_char * p) return (dp - dest); } static int -prtext(char *dest, u_char * p) +prtext(char *dest, u_char *p) { char *dp = dest; int l; @@ -802,7 +802,7 @@ prtext(char *dest, u_char * p) } static int -prfeatureind(char *dest, u_char * p) +prfeatureind(char *dest, u_char *p) { char *dp = dest; @@ -817,21 +817,21 @@ prfeatureind(char *dest, u_char * p) } dp += sprintf(dp, " Status: "); switch (*p) { - case 0: - dp += sprintf(dp, "Idle"); - break; - case 1: - dp += sprintf(dp, "Active"); - break; - case 2: - dp += sprintf(dp, "Prompt"); - break; - case 3: - dp += sprintf(dp, "Pending"); - break; - default: - dp += sprintf(dp, "(Reserved)"); - break; + case 0: + dp += sprintf(dp, "Idle"); + break; + case 1: + dp += sprintf(dp, "Active"); + break; + case 2: + dp += sprintf(dp, "Prompt"); + break; + case 3: + dp += sprintf(dp, "Pending"); + break; + default: + dp += sprintf(dp, "(Reserved)"); + break; } *dp++ = '\n'; return (dp - dest); @@ -868,7 +868,7 @@ struct DTag { /* Display tags */ #define DTAGSIZE ARRAY_SIZE(dtaglist) static int -disptext_ni1(char *dest, u_char * p) +disptext_ni1(char *dest, u_char *p) { char *dp = dest; int l, tag, len, i; @@ -902,12 +902,12 @@ disptext_ni1(char *dest, u_char * p) *dp++ = *p++; } dp += sprintf(dp, "\n"); - } + } } return (dp - dest); } static int -display(char *dest, u_char * p) +display(char *dest, u_char *p) { char *dp = dest; char ch = ' '; @@ -936,7 +936,7 @@ display(char *dest, u_char * p) } static int -prfacility(char *dest, u_char * p) +prfacility(char *dest, u_char *p) { char *dp = dest; int l, l2; @@ -1148,7 +1148,7 @@ static struct InformationElement we_6[] = #define WE_6_LEN ARRAY_SIZE(we_6) int -QuickHex(char *txt, u_char * p, int cnt) +QuickHex(char *txt, u_char *p, int cnt) { register int i; register char *t = txt; @@ -1163,7 +1163,7 @@ QuickHex(char *txt, u_char * p, int cnt) } void -LogFrame(struct IsdnCardState *cs, u_char * buf, int size) +LogFrame(struct IsdnCardState *cs, u_char *buf, int size) { char *dp; @@ -1206,7 +1206,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) buf = skb->data; dp += sprintf(dp, "frame %s ", dir ? "network->user" : "user->network"); size = skb->len; - + if (tei == GROUP_TEI) { if (sapi == CTRL_SAPI) { /* sapi 0 */ if (ftyp == 3) { @@ -1291,28 +1291,28 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) /* Is it a single octet information element? */ if (*buf & 0x80) { switch ((*buf >> 4) & 7) { - case 1: - dp += sprintf(dp, " Shift %x\n", *buf & 0xf); - cs_old = cset; - cset = *buf & 7; - cs_fest = *buf & 8; - break; - case 3: - dp += sprintf(dp, " Congestion level %x\n", *buf & 0xf); - break; - case 2: - if (*buf == 0xa0) { - dp += sprintf(dp, " More data\n"); - break; - } - if (*buf == 0xa1) { - dp += sprintf(dp, " Sending complete\n"); - } - break; - /* fall through */ - default: - dp += sprintf(dp, " Reserved %x\n", *buf); + case 1: + dp += sprintf(dp, " Shift %x\n", *buf & 0xf); + cs_old = cset; + cset = *buf & 7; + cs_fest = *buf & 8; + break; + case 3: + dp += sprintf(dp, " Congestion level %x\n", *buf & 0xf); + break; + case 2: + if (*buf == 0xa0) { + dp += sprintf(dp, " More data\n"); break; + } + if (*buf == 0xa1) { + dp += sprintf(dp, " Sending complete\n"); + } + break; + /* fall through */ + default: + dp += sprintf(dp, " Reserved %x\n", *buf); + break; } buf++; continue; @@ -1366,11 +1366,11 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) /* display message type if it exists */ if (i == MTSIZE) dp += sprintf(dp, "callref %d %s size %d unknown message type %x!\n", - cr & 0x7f, (cr & 0x80) ? "called" : "caller", + cr & 0x7f, (cr & 0x80) ? "called" : "caller", size, mt); else dp += sprintf(dp, "callref %d %s size %d message type %s\n", - cr & 0x7f, (cr & 0x80) ? "called" : "caller", + cr & 0x7f, (cr & 0x80) ? "called" : "caller", size, mtlist[i].descr); /* display each information element */ @@ -1378,15 +1378,15 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) /* Is it a single octet information element? */ if (*buf & 0x80) { switch ((*buf >> 4) & 7) { - case 1: - dp += sprintf(dp, " Shift %x\n", *buf & 0xf); - cs_old = cset; - cset = *buf & 7; - cs_fest = *buf & 8; - break; - default: - dp += sprintf(dp, " Unknown single-octet IE %x\n", *buf); - break; + case 1: + dp += sprintf(dp, " Shift %x\n", *buf & 0xf); + cs_old = cset; + cset = *buf & 7; + cs_fest = *buf & 8; + break; + default: + dp += sprintf(dp, " Unknown single-octet IE %x\n", *buf); + break; } buf++; continue; @@ -1452,11 +1452,11 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) /* display message type if it exists */ if (i == MTSIZE) dp += sprintf(dp, "callref %d %s size %d unknown message type %x!\n", - cr & 0x7f, (cr & 0x80) ? "called" : "caller", + cr & 0x7f, (cr & 0x80) ? "called" : "caller", size, mt); else dp += sprintf(dp, "callref %d %s size %d message type %s\n", - cr & 0x7f, (cr & 0x80) ? "called" : "caller", + cr & 0x7f, (cr & 0x80) ? "called" : "caller", size, mtlist[i].descr); /* display each information element */ @@ -1464,28 +1464,28 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) /* Is it a single octet information element? */ if (*buf & 0x80) { switch ((*buf >> 4) & 7) { - case 1: - dp += sprintf(dp, " Shift %x\n", *buf & 0xf); - break; - case 3: - dp += sprintf(dp, " Congestion level %x\n", *buf & 0xf); - break; - case 5: - dp += sprintf(dp, " Repeat indicator %x\n", *buf & 0xf); - break; - case 2: - if (*buf == 0xa0) { - dp += sprintf(dp, " More data\n"); - break; - } - if (*buf == 0xa1) { - dp += sprintf(dp, " Sending complete\n"); - } - break; - /* fall through */ - default: - dp += sprintf(dp, " Reserved %x\n", *buf); + case 1: + dp += sprintf(dp, " Shift %x\n", *buf & 0xf); + break; + case 3: + dp += sprintf(dp, " Congestion level %x\n", *buf & 0xf); + break; + case 5: + dp += sprintf(dp, " Repeat indicator %x\n", *buf & 0xf); + break; + case 2: + if (*buf == 0xa0) { + dp += sprintf(dp, " More data\n"); break; + } + if (*buf == 0xa1) { + dp += sprintf(dp, " Sending complete\n"); + } + break; + /* fall through */ + default: + dp += sprintf(dp, " Reserved %x\n", *buf); + break; } buf++; continue; diff --git a/drivers/isdn/hisax/s0box.c b/drivers/isdn/hisax/s0box.c index 16d00b555c8c..383c4e7ce50b 100644 --- a/drivers/isdn/hisax/s0box.c +++ b/drivers/isdn/hisax/s0box.c @@ -20,73 +20,73 @@ static const char *s0box_revision = "$Revision: 2.6.2.4 $"; static inline void writereg(unsigned int padr, signed int addr, u_char off, u_char val) { - outb_p(0x1c,padr+2); - outb_p(0x14,padr+2); - outb_p((addr+off)&0x7f,padr); - outb_p(0x16,padr+2); - outb_p(val,padr); - outb_p(0x17,padr+2); - outb_p(0x14,padr+2); - outb_p(0x1c,padr+2); + outb_p(0x1c, padr + 2); + outb_p(0x14, padr + 2); + outb_p((addr + off) & 0x7f, padr); + outb_p(0x16, padr + 2); + outb_p(val, padr); + outb_p(0x17, padr + 2); + outb_p(0x14, padr + 2); + outb_p(0x1c, padr + 2); } static u_char nibtab[] = { 1, 9, 5, 0xd, 3, 0xb, 7, 0xf, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8, 4, 0xc, 2, 0xa, 6, 0xe } ; + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 8, 4, 0xc, 2, 0xa, 6, 0xe }; static inline u_char readreg(unsigned int padr, signed int addr, u_char off) { register u_char n1, n2; - outb_p(0x1c,padr+2); - outb_p(0x14,padr+2); - outb_p((addr+off)|0x80,padr); - outb_p(0x16,padr+2); - outb_p(0x17,padr+2); - n1 = (inb_p(padr+1) >> 3) & 0x17; - outb_p(0x16,padr+2); - n2 = (inb_p(padr+1) >> 3) & 0x17; - outb_p(0x14,padr+2); - outb_p(0x1c,padr+2); + outb_p(0x1c, padr + 2); + outb_p(0x14, padr + 2); + outb_p((addr + off) | 0x80, padr); + outb_p(0x16, padr + 2); + outb_p(0x17, padr + 2); + n1 = (inb_p(padr + 1) >> 3) & 0x17; + outb_p(0x16, padr + 2); + n2 = (inb_p(padr + 1) >> 3) & 0x17; + outb_p(0x14, padr + 2); + outb_p(0x1c, padr + 2); return nibtab[n1] | (nibtab[n2] << 4); } static inline void -read_fifo(unsigned int padr, signed int adr, u_char * data, int size) +read_fifo(unsigned int padr, signed int adr, u_char *data, int size) { int i; register u_char n1, n2; - - outb_p(0x1c, padr+2); - outb_p(0x14, padr+2); - outb_p(adr|0x80, padr); - outb_p(0x16, padr+2); - for (i=0; i> 3) & 0x17; - outb_p(0x16,padr+2); - n2 = (inb_p(padr+1) >> 3) & 0x17; - *(data++)=nibtab[n1] | (nibtab[n2] << 4); + + outb_p(0x1c, padr + 2); + outb_p(0x14, padr + 2); + outb_p(adr | 0x80, padr); + outb_p(0x16, padr + 2); + for (i = 0; i < size; i++) { + outb_p(0x17, padr + 2); + n1 = (inb_p(padr + 1) >> 3) & 0x17; + outb_p(0x16, padr + 2); + n2 = (inb_p(padr + 1) >> 3) & 0x17; + *(data++) = nibtab[n1] | (nibtab[n2] << 4); } - outb_p(0x14,padr+2); - outb_p(0x1c,padr+2); + outb_p(0x14, padr + 2); + outb_p(0x1c, padr + 2); return; } static inline void -write_fifo(unsigned int padr, signed int adr, u_char * data, int size) +write_fifo(unsigned int padr, signed int adr, u_char *data, int size) { int i; - outb_p(0x1c, padr+2); - outb_p(0x14, padr+2); - outb_p(adr&0x7f, padr); - for (i=0; ihw.teles3.cfg_reg, cs->hw.teles3.isacfifo, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { write_fifo(cs->hw.teles3.cfg_reg, cs->hw.teles3.isacfifo, data, size); } @@ -150,11 +150,11 @@ s0box_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.teles3.cfg_reg, cs->hw.teles3.hscx[1], HSCX_ISTA); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.teles3.cfg_reg, cs->hw.teles3.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); count++; @@ -194,20 +194,20 @@ S0Box_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - break; - case CARD_RELEASE: - release_io_s0box(cs); - break; - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case CARD_TEST: - break; + case CARD_RESET: + break; + case CARD_RELEASE: + release_io_s0box(cs); + break; + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case CARD_TEST: + break; } - return(0); + return (0); } int __devinit @@ -229,17 +229,17 @@ setup_s0box(struct IsdnCard *card) cs->hw.teles3.hscxfifo[0] = cs->hw.teles3.hscx[0] + 0x3e; cs->hw.teles3.hscxfifo[1] = cs->hw.teles3.hscx[1] + 0x3e; cs->irq = card->para[0]; - if (!request_region(cs->hw.teles3.cfg_reg,8, "S0Box parallel I/O")) { + if (!request_region(cs->hw.teles3.cfg_reg, 8, "S0Box parallel I/O")) { printk(KERN_WARNING "HiSax: S0Box ports %x-%x already in use\n", - cs->hw.teles3.cfg_reg, - cs->hw.teles3.cfg_reg + 7); + cs->hw.teles3.cfg_reg, + cs->hw.teles3.cfg_reg + 7); return 0; } printk(KERN_INFO "HiSax: S0Box config irq:%d isac:0x%x cfg:0x%x\n", - cs->irq, - cs->hw.teles3.isac, cs->hw.teles3.cfg_reg); + cs->irq, + cs->hw.teles3.isac, cs->hw.teles3.cfg_reg); printk(KERN_INFO "HiSax: hscx A:0x%x hscx B:0x%x\n", - cs->hw.teles3.hscx[0], cs->hw.teles3.hscx[1]); + cs->hw.teles3.hscx[0], cs->hw.teles3.hscx[1]); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; diff --git a/drivers/isdn/hisax/saphir.c b/drivers/isdn/hisax/saphir.c index b34a81d655b8..75dcae6d36e0 100644 --- a/drivers/isdn/hisax/saphir.c +++ b/drivers/isdn/hisax/saphir.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -20,7 +20,7 @@ static char *saphir_rev = "$Revision: 1.10.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define ISAC_DATA 0 @@ -41,7 +41,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -56,7 +56,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -77,13 +77,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.saphir.ale, cs->hw.saphir.isac, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.saphir.ale, cs->hw.saphir.isac, 0, data, size); } @@ -92,26 +92,26 @@ static u_char ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) { return (readreg(cs->hw.saphir.ale, cs->hw.saphir.hscx, - offset + (hscx ? 0x40 : 0))); + offset + (hscx ? 0x40 : 0))); } static void WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) { writereg(cs->hw.saphir.ale, cs->hw.saphir.hscx, - offset + (hscx ? 0x40 : 0), value); + offset + (hscx ? 0x40 : 0), value); } -#define READHSCX(cs, nr, reg) readreg(cs->hw.saphir.ale, \ - cs->hw.saphir.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.saphir.ale, \ - cs->hw.saphir.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.saphir.ale, \ + cs->hw.saphir.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.saphir.ale, \ + cs->hw.saphir.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.saphir.ale, \ - cs->hw.saphir.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.saphir.ale, \ + cs->hw.saphir.hscx, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.saphir.ale, \ - cs->hw.saphir.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.saphir.ale, \ + cs->hw.saphir.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -124,11 +124,11 @@ saphir_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.saphir.ale, cs->hw.saphir.hscx, HSCX_ISTA + 0x40); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.saphir.ale, cs->hw.saphir.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.saphir.ale, cs->hw.saphir.hscx, HSCX_ISTA + 0x40); @@ -144,8 +144,8 @@ saphir_interrupt(int intno, void *dev_id) goto Start_ISAC; } /* Watchdog */ - if (cs->hw.saphir.timer.function) - mod_timer(&cs->hw.saphir.timer, jiffies+1*HZ); + if (cs->hw.saphir.timer.function) + mod_timer(&cs->hw.saphir.timer, jiffies + 1 * HZ); else printk(KERN_WARNING "saphir: Spurious timer!\n"); writereg(cs->hw.saphir.ale, cs->hw.saphir.hscx, HSCX_MASK, 0xFF); @@ -164,10 +164,10 @@ SaphirWatchDog(struct IsdnCardState *cs) u_long flags; spin_lock_irqsave(&cs->lock, flags); - /* 5 sec WatchDog, so read at least every 4 sec */ + /* 5 sec WatchDog, so read at least every 4 sec */ cs->readisac(cs, ISAC_RBCH); spin_unlock_irqrestore(&cs->lock, flags); - mod_timer(&cs->hw.saphir.timer, jiffies+1*HZ); + mod_timer(&cs->hw.saphir.timer, jiffies + 1 * HZ); } static void @@ -185,24 +185,24 @@ saphir_reset(struct IsdnCardState *cs) { u_char irq_val; - switch(cs->irq) { - case 5: irq_val = 0; - break; - case 3: irq_val = 1; - break; - case 11: - irq_val = 2; - break; - case 12: - irq_val = 3; - break; - case 15: - irq_val = 4; - break; - default: - printk(KERN_WARNING "HiSax: saphir wrong IRQ %d\n", - cs->irq); - return (1); + switch (cs->irq) { + case 5: irq_val = 0; + break; + case 3: irq_val = 1; + break; + case 11: + irq_val = 2; + break; + case 12: + irq_val = 3; + break; + case 15: + irq_val = 4; + break; + default: + printk(KERN_WARNING "HiSax: saphir wrong IRQ %d\n", + cs->irq); + return (1); } byteout(cs->hw.saphir.cfg_reg + IRQ_REG, irq_val); byteout(cs->hw.saphir.cfg_reg + RESET_REG, 1); @@ -220,23 +220,23 @@ saphir_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - saphir_reset(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_saphir(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + saphir_reset(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_saphir(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } @@ -259,9 +259,9 @@ setup_saphir(struct IsdnCard *card) cs->irq = card->para[0]; if (!request_region(cs->hw.saphir.cfg_reg, 6, "saphir")) { printk(KERN_WARNING - "HiSax: HST Saphir config port %x-%x already in use\n", - cs->hw.saphir.cfg_reg, - cs->hw.saphir.cfg_reg + 5); + "HiSax: HST Saphir config port %x-%x already in use\n", + cs->hw.saphir.cfg_reg, + cs->hw.saphir.cfg_reg + 5); return (0); } @@ -272,7 +272,7 @@ setup_saphir(struct IsdnCard *card) cs->hw.saphir.timer.function = (void *) SaphirWatchDog; cs->hw.saphir.timer.data = (long) cs; init_timer(&cs->hw.saphir.timer); - cs->hw.saphir.timer.expires = jiffies + 4*HZ; + cs->hw.saphir.timer.expires = jiffies + 4 * HZ; add_timer(&cs->hw.saphir.timer); if (saphir_reset(cs)) { release_io_saphir(cs); @@ -290,7 +290,7 @@ setup_saphir(struct IsdnCard *card) ISACVersion(cs, "saphir:"); if (HscxVersion(cs, "saphir:")) { printk(KERN_WARNING - "saphir: wrong HSCX versions check IO address\n"); + "saphir: wrong HSCX versions check IO address\n"); release_io_saphir(cs); return (0); } diff --git a/drivers/isdn/hisax/sedlbauer.c b/drivers/isdn/hisax/sedlbauer.c index 69dfc8d29017..1ee531b6be99 100644 --- a/drivers/isdn/hisax/sedlbauer.c +++ b/drivers/isdn/hisax/sedlbauer.c @@ -9,7 +9,7 @@ * * Author Marcus Niemann * Copyright by Marcus Niemann - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -30,13 +30,13 @@ * ISDN PC/104 IPAC DIP-SWITCH * Speed Star2 IPAC CARDMGR * Speed PCI IPAC PCI PNP - * Speed Fax+ ISAC_ISAR PCI PNP Full analog support + * Speed Fax+ ISAC_ISAR PCI PNP Full analog support * * Important: * For the sedlbauer speed fax+ to work properly you have to download * the firmware onto the card. * For example: hisaxctrl 9 ISAR.BIN -*/ + */ #include #include "hisax.h" @@ -51,9 +51,9 @@ static const char *Sedlbauer_revision = "$Revision: 1.34.2.6 $"; static const char *Sedlbauer_Types[] = - {"None", "speed card/win", "speed star", "speed fax+", - "speed win II / ISDN PC/104", "speed star II", "speed pci", - "speed fax+ pyramid", "speed fax+ pci", "HST Saphir III"}; +{"None", "speed card/win", "speed star", "speed fax+", + "speed win II / ISDN PC/104", "speed star II", "speed pci", + "speed fax+ pyramid", "speed fax+ pci", "HST Saphir III"}; #define PCI_SUBVENDOR_SPEEDFAX_PYRAMID 0x51 #define PCI_SUBVENDOR_HST_SAPHIR3 0x52 @@ -62,11 +62,11 @@ static const char *Sedlbauer_Types[] = #define PCI_SUB_ID_SEDLBAUER 0x01 #define SEDL_SPEED_CARD_WIN 1 -#define SEDL_SPEED_STAR 2 +#define SEDL_SPEED_STAR 2 #define SEDL_SPEED_FAX 3 -#define SEDL_SPEED_WIN2_PC104 4 -#define SEDL_SPEED_STAR2 5 -#define SEDL_SPEED_PCI 6 +#define SEDL_SPEED_WIN2_PC104 4 +#define SEDL_SPEED_STAR2 5 +#define SEDL_SPEED_PCI 6 #define SEDL_SPEEDFAX_PYRAMID 7 #define SEDL_SPEEDFAX_PCI 8 #define HST_SAPHIR3 9 @@ -80,7 +80,7 @@ static const char *Sedlbauer_Types[] = #define SEDL_BUS_PCI 2 #define SEDL_BUS_PCMCIA 3 -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define SEDL_HSCX_ISA_RESET_ON 0 @@ -127,7 +127,7 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); insb(adr, data, size); @@ -142,7 +142,7 @@ writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) } static inline void -writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { byteout(ale, off); outsb(adr, data, size); @@ -163,13 +163,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size); } @@ -177,23 +177,23 @@ WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) static u_char ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset) { - return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset|0x80)); + return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset | 0x80)); } static void WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value) { - writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset|0x80, value); + writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset | 0x80, value); } static void -ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size); } static void -WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) { writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size); } @@ -220,12 +220,12 @@ WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) static u_char ReadISAR(struct IsdnCardState *cs, int mode, u_char offset) -{ +{ if (mode == 0) return (readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset)); else if (mode == 1) byteout(cs->hw.sedl.adr, offset); - return(bytein(cs->hw.sedl.hscx)); + return (bytein(cs->hw.sedl.hscx)); } static void @@ -244,16 +244,16 @@ WriteISAR(struct IsdnCardState *cs, int mode, u_char offset, u_char value) * fast interrupt HSCX stuff goes here */ -#define READHSCX(cs, nr, reg) readreg(cs->hw.sedl.adr, \ - cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0)) -#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.sedl.adr, \ - cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0), data) +#define READHSCX(cs, nr, reg) readreg(cs->hw.sedl.adr, \ + cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0)) +#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.sedl.adr, \ + cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0), data) -#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.sedl.adr, \ - cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.sedl.adr, \ + cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt) -#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.sedl.adr, \ - cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt) +#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.sedl.adr, \ + cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt) #include "hscx_irq.c" @@ -274,11 +274,11 @@ sedlbauer_interrupt(int intno, void *dev_id) } val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40); @@ -360,11 +360,11 @@ sedlbauer_interrupt_isar(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT); - Start_ISAR: +Start_ISAR: if (val & ISAR_IRQSTA) isar_int_main(cs); val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT); @@ -411,7 +411,7 @@ reset_sedlbauer(struct IsdnCardState *cs) printk(KERN_INFO "Sedlbauer: resetting card\n"); if (!((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) && - (cs->hw.sedl.chip == SEDL_CHIP_ISAC_HSCX))) { + (cs->hw.sedl.chip == SEDL_CHIP_ISAC_HSCX))) { if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) { writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x20); mdelay(2); @@ -423,12 +423,12 @@ reset_sedlbauer(struct IsdnCardState *cs) writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xc0); writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_PCFG, 0x12); } else if ((cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) && - (cs->hw.sedl.bus == SEDL_BUS_PCI)) { - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on); + (cs->hw.sedl.bus == SEDL_BUS_PCI)) { + byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on); mdelay(2); - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off); + byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); mdelay(10); - } else { + } else { byteout(cs->hw.sedl.reset_on, SEDL_RESET); /* Reset On */ mdelay(2); byteout(cs->hw.sedl.reset_off, 0); /* Reset Off */ @@ -443,86 +443,86 @@ Sedl_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_sedlbauer(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - if (cs->hw.sedl.bus == SEDL_BUS_PCI) - /* disable all IRQ */ - byteout(cs->hw.sedl.cfg_reg+ 5, 0); - if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { - spin_lock_irqsave(&cs->lock, flags); - writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, - ISAR_IRQBIT, 0); - writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, - ISAC_MASK, 0xFF); - reset_sedlbauer(cs); - writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, - ISAR_IRQBIT, 0); - writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, - ISAC_MASK, 0xFF); - spin_unlock_irqrestore(&cs->lock, flags); - } - release_io_sedlbauer(cs); - return(0); - case CARD_INIT: + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_sedlbauer(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + if (cs->hw.sedl.bus == SEDL_BUS_PCI) + /* disable all IRQ */ + byteout(cs->hw.sedl.cfg_reg + 5, 0); + if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { spin_lock_irqsave(&cs->lock, flags); - if (cs->hw.sedl.bus == SEDL_BUS_PCI) - /* enable all IRQ */ - byteout(cs->hw.sedl.cfg_reg+ 5, 0x02); + writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, + ISAR_IRQBIT, 0); + writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, + ISAC_MASK, 0xFF); reset_sedlbauer(cs); - if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { - clear_pending_isac_ints(cs); - writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, - ISAR_IRQBIT, 0); - initisac(cs); - initisar(cs); - /* Reenable all IRQ */ - cs->writeisac(cs, ISAC_MASK, 0); - /* RESET Receiver and Transmitter */ - cs->writeisac(cs, ISAC_CMDR, 0x41); - } else { - inithscxisac(cs, 3); - } + writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, + ISAR_IRQBIT, 0); + writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, + ISAC_MASK, 0xFF); spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); - case MDL_INFO_CONN: - if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID) - return(0); - spin_lock_irqsave(&cs->lock, flags); - if ((long) arg) - cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED2; - else - cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED1; - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off); - spin_unlock_irqrestore(&cs->lock, flags); - break; - case MDL_INFO_REL: - if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID) - return(0); - spin_lock_irqsave(&cs->lock, flags); - if ((long) arg) - cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED2; - else - cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED1; - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off); - spin_unlock_irqrestore(&cs->lock, flags); - break; + } + release_io_sedlbauer(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + if (cs->hw.sedl.bus == SEDL_BUS_PCI) + /* enable all IRQ */ + byteout(cs->hw.sedl.cfg_reg + 5, 0x02); + reset_sedlbauer(cs); + if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { + clear_pending_isac_ints(cs); + writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, + ISAR_IRQBIT, 0); + initisac(cs); + initisar(cs); + /* Reenable all IRQ */ + cs->writeisac(cs, ISAC_MASK, 0); + /* RESET Receiver and Transmitter */ + cs->writeisac(cs, ISAC_CMDR, 0x41); + } else { + inithscxisac(cs, 3); + } + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); + case MDL_INFO_CONN: + if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID) + return (0); + spin_lock_irqsave(&cs->lock, flags); + if ((long) arg) + cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED2; + else + cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED1; + byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case MDL_INFO_REL: + if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID) + return (0); + spin_lock_irqsave(&cs->lock, flags); + if ((long) arg) + cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED2; + else + cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED1; + byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); + spin_unlock_irqrestore(&cs->lock, flags); + break; } - return(0); + return (0); } #ifdef __ISAPNP__ static struct isapnp_device_id sedl_ids[] __devinitdata = { { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), - ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), + ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), (unsigned long) "Speed win" }, { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), - ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), + ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), (unsigned long) "Speed Fax+" }, { 0, } }; @@ -539,31 +539,31 @@ setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt) if (!isapnp_present()) return -1; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[1] = pnp_port_start(pnp_d, 0); card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1]) { printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n", - card->para[0], card->para[1]); + card->para[0], card->para[1]); pnp_disable_dev(pnp_d); - return(0); + return (0); } cs->hw.sedl.cfg_reg = card->para[1]; cs->irq = card->para[0]; @@ -579,12 +579,12 @@ setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt) return (1); } else { printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n"); - return(0); + return (0); } } ipid++; pnp_c = NULL; - } + } printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n"); return -1; @@ -608,30 +608,30 @@ setup_sedlbauer_pci(struct IsdnCard *card) u16 sub_vendor_id, sub_id; if ((dev_sedl = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET, - PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) { + PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) { if (pci_enable_device(dev_sedl)) - return(0); + return (0); cs->irq = dev_sedl->irq; if (!cs->irq) { printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n"); - return(0); + return (0); } cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0); } else { printk(KERN_WARNING "Sedlbauer: No PCI card found\n"); - return(0); + return (0); } cs->irq_flags |= IRQF_SHARED; cs->hw.sedl.bus = SEDL_BUS_PCI; sub_vendor_id = dev_sedl->subsystem_vendor; sub_id = dev_sedl->subsystem_device; printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n", - sub_vendor_id, sub_id); + sub_vendor_id, sub_id); printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n", - cs->hw.sedl.cfg_reg); + cs->hw.sedl.cfg_reg); if (sub_id != PCI_SUB_ID_SEDLBAUER) { printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id); - return(0); + return (0); } if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) { cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; @@ -647,19 +647,19 @@ setup_sedlbauer_pci(struct IsdnCard *card) cs->subtyp = SEDL_SPEED_PCI; } else { printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n", - sub_vendor_id); - return(0); + sub_vendor_id); + return (0); } cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON; cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF; byteout(cs->hw.sedl.cfg_reg, 0xff); byteout(cs->hw.sedl.cfg_reg, 0x00); - byteout(cs->hw.sedl.cfg_reg+ 2, 0xdd); - byteout(cs->hw.sedl.cfg_reg+ 5, 0); /* disable all IRQ */ - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on); + byteout(cs->hw.sedl.cfg_reg + 2, 0xdd); + byteout(cs->hw.sedl.cfg_reg + 5, 0); /* disable all IRQ */ + byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on); mdelay(2); - byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off); + byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); mdelay(10); return (1); @@ -684,20 +684,20 @@ setup_sedlbauer(struct IsdnCard *card) strcpy(tmp, Sedlbauer_revision); printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp)); - - if (cs->typ == ISDN_CTYPE_SEDLBAUER) { - cs->subtyp = SEDL_SPEED_CARD_WIN; + + if (cs->typ == ISDN_CTYPE_SEDLBAUER) { + cs->subtyp = SEDL_SPEED_CARD_WIN; cs->hw.sedl.bus = SEDL_BUS_ISA; cs->hw.sedl.chip = SEDL_CHIP_TEST; - } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) { - cs->subtyp = SEDL_SPEED_STAR; + } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) { + cs->subtyp = SEDL_SPEED_STAR; cs->hw.sedl.bus = SEDL_BUS_PCMCIA; cs->hw.sedl.chip = SEDL_CHIP_TEST; - } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_FAX) { - cs->subtyp = SEDL_SPEED_FAX; + } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_FAX) { + cs->subtyp = SEDL_SPEED_FAX; cs->hw.sedl.bus = SEDL_BUS_ISA; cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; - } else + } else return (0); bytecnt = 8; @@ -720,22 +720,22 @@ setup_sedlbauer(struct IsdnCard *card) return (0); bytecnt = 256; - } + } -ready: +ready: /* In case of the sedlbauer pcmcia card, this region is in use, * reserved for us by the card manager. So we do not check it * here, it would fail. */ if (cs->hw.sedl.bus != SEDL_BUS_PCMCIA && - !request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn")) { + !request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn")) { printk(KERN_WARNING - "HiSax: %s config port %x-%x already in use\n", - CardType[card->typ], - cs->hw.sedl.cfg_reg, - cs->hw.sedl.cfg_reg + bytecnt); - return (0); + "HiSax: %s config port %x-%x already in use\n", + CardType[card->typ], + cs->hw.sedl.cfg_reg, + cs->hw.sedl.cfg_reg + bytecnt); + return (0); } printk(KERN_INFO @@ -753,12 +753,12 @@ setup_sedlbauer(struct IsdnCard *card) * testing ISA and PCMCIA Cards for IPAC, default is ISAC * do not test for PCI card, because ports are different * and PCI card uses only IPAC (for the moment) - */ + */ if (cs->hw.sedl.bus != SEDL_BUS_PCI) { val = readreg(cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR, - cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC, IPAC_ID); + cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC, IPAC_ID); printk(KERN_DEBUG "Sedlbauer: testing IPAC version %x\n", val); - if ((val == 1) || (val == 2)) { + if ((val == 1) || (val == 2)) { /* IPAC */ cs->subtyp = SEDL_SPEED_WIN2_PC104; if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) { @@ -777,16 +777,16 @@ setup_sedlbauer(struct IsdnCard *card) * hw.sedl.chip is now properly set */ printk(KERN_INFO "Sedlbauer: %s detected\n", - Sedlbauer_Types[cs->subtyp]); + Sedlbauer_Types[cs->subtyp]); setup_isac(cs); if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) { if (cs->hw.sedl.bus == SEDL_BUS_PCI) { - cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_ADR; + cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC; } else { - cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR; + cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC; } @@ -807,22 +807,22 @@ setup_sedlbauer(struct IsdnCard *card) if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { if (cs->hw.sedl.bus == SEDL_BUS_PCI) { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + - SEDL_ISAR_PCI_ADR; + SEDL_ISAR_PCI_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + - SEDL_ISAR_PCI_ISAC; + SEDL_ISAR_PCI_ISAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + - SEDL_ISAR_PCI_ISAR; + SEDL_ISAR_PCI_ISAR; } else { cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + - SEDL_ISAR_ISA_ADR; + SEDL_ISAR_ISA_ADR; cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + - SEDL_ISAR_ISA_ISAC; + SEDL_ISAR_ISA_ISAC; cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + - SEDL_ISAR_ISA_ISAR; + SEDL_ISAR_ISA_ISAR; cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + - SEDL_ISAR_ISA_ISAR_RESET_ON; + SEDL_ISAR_ISA_ISAR_RESET_ON; cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + - SEDL_ISAR_ISA_ISAR_RESET_OFF; + SEDL_ISAR_ISA_ISAR_RESET_OFF; } cs->bcs[0].hw.isar.reg = &cs->hw.sedl.isar; cs->bcs[1].hw.isar.reg = &cs->hw.sedl.isar; @@ -838,7 +838,7 @@ setup_sedlbauer(struct IsdnCard *card) ver = ISARVersion(cs, "Sedlbauer:"); if (ver < 0) printk(KERN_WARNING - "Sedlbauer: wrong ISAR version (ret = %d)\n", ver); + "Sedlbauer: wrong ISAR version (ret = %d)\n", ver); else break; reset_sedlbauer(cs); @@ -865,10 +865,10 @@ setup_sedlbauer(struct IsdnCard *card) } cs->irq_func = &sedlbauer_interrupt; ISACVersion(cs, "Sedlbauer:"); - + if (HscxVersion(cs, "Sedlbauer:")) { printk(KERN_WARNING - "Sedlbauer: wrong HSCX versions check IO address\n"); + "Sedlbauer: wrong HSCX versions check IO address\n"); release_io_sedlbauer(cs); return (0); } diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 06473f81f039..68f50495d166 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -1,39 +1,39 @@ /*====================================================================== - A Sedlbauer PCMCIA client driver - - This driver is for the Sedlbauer Speed Star and Speed Star II, - which are ISDN PCMCIA Cards. - - The contents of this file are subject to the Mozilla Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The initial developer of the original code is David A. Hinds - . Portions created by David A. Hinds - are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - - Modifications from dummy_cs.c are Copyright (C) 1999-2001 Marcus Niemann - . All Rights Reserved. - - Alternatively, the contents of this file may be used under the - terms of the GNU General Public License version 2 (the "GPL"), in - which case the provisions of the GPL are applicable instead of the - above. If you wish to allow the use of your version of this file - only under the terms of the GPL and not to allow others to use - your version of this file under the MPL, indicate your decision - by deleting the provisions above and replace them with the notice - and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this - file under either the MPL or the GPL. - -======================================================================*/ + A Sedlbauer PCMCIA client driver + + This driver is for the Sedlbauer Speed Star and Speed Star II, + which are ISDN PCMCIA Cards. + + The contents of this file are subject to the Mozilla Public + License Version 1.1 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of + the License at http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS + IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + implied. See the License for the specific language governing + rights and limitations under the License. + + The initial developer of the original code is David A. Hinds + . Portions created by David A. Hinds + are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + + Modifications from dummy_cs.c are Copyright (C) 1999-2001 Marcus Niemann + . All Rights Reserved. + + Alternatively, the contents of this file may be used under the + terms of the GNU General Public License version 2 (the "GPL"), in + which case the provisions of the GPL are applicable instead of the + above. If you wish to allow the use of your version of this file + only under the terms of the GPL and not to allow others to use + your version of this file under the MPL, indicate your decision + by deleting the provisions above and replace them with the notice + and other provisions required by the GPL. If you do not delete + the provisions above, a recipient may use your version of this + file under either the MPL or the GPL. + + ======================================================================*/ #include #include @@ -63,32 +63,32 @@ MODULE_LICENSE("Dual MPL/GPL"); static int protocol = 2; /* EURO-ISDN Default */ module_param(protocol, int, 0); -static int sedlbauer_config(struct pcmcia_device *link) __devinit ; +static int sedlbauer_config(struct pcmcia_device *link) __devinit; static void sedlbauer_release(struct pcmcia_device *link); static void sedlbauer_detach(struct pcmcia_device *p_dev) __devexit; typedef struct local_info_t { struct pcmcia_device *p_dev; - int stop; - int cardnr; + int stop; + int cardnr; } local_info_t; static int __devinit sedlbauer_probe(struct pcmcia_device *link) { - local_info_t *local; + local_info_t *local; - dev_dbg(&link->dev, "sedlbauer_attach()\n"); + dev_dbg(&link->dev, "sedlbauer_attach()\n"); - /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(local_info_t), GFP_KERNEL); - if (!local) return -ENOMEM; - local->cardnr = -1; + /* Allocate space for private device-specific data */ + local = kzalloc(sizeof(local_info_t), GFP_KERNEL); + if (!local) return -ENOMEM; + local->cardnr = -1; - local->p_dev = link; - link->priv = local; + local->p_dev = link; + link->priv = local; - return sedlbauer_config(link); + return sedlbauer_config(link); } /* sedlbauer_attach */ static void __devexit sedlbauer_detach(struct pcmcia_device *link) @@ -113,58 +113,58 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev, void *priv_data) static int __devinit sedlbauer_config(struct pcmcia_device *link) { - int ret; - IsdnCard_t icard; - - dev_dbg(&link->dev, "sedlbauer_config(0x%p)\n", link); - - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | - CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, sedlbauer_config_check, NULL); - if (ret) - goto failed; - - ret = pcmcia_enable_device(link); - if (ret) - goto failed; - - icard.para[0] = link->irq; - icard.para[1] = link->resource[0]->start; - icard.protocol = protocol; - icard.typ = ISDN_CTYPE_SEDLBAUER_PCMCIA; - - ret = hisax_init_pcmcia(link, - &(((local_info_t *)link->priv)->stop), &icard); - if (ret < 0) { - printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d with %pR\n", - ret, link->resource[0]); - sedlbauer_release(link); - return -ENODEV; - } else - ((local_info_t *)link->priv)->cardnr = ret; + int ret; + IsdnCard_t icard; + + dev_dbg(&link->dev, "sedlbauer_config(0x%p)\n", link); - return 0; + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | + CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; + + ret = pcmcia_loop_config(link, sedlbauer_config_check, NULL); + if (ret) + goto failed; + + ret = pcmcia_enable_device(link); + if (ret) + goto failed; + + icard.para[0] = link->irq; + icard.para[1] = link->resource[0]->start; + icard.protocol = protocol; + icard.typ = ISDN_CTYPE_SEDLBAUER_PCMCIA; + + ret = hisax_init_pcmcia(link, + &(((local_info_t *)link->priv)->stop), &icard); + if (ret < 0) { + printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d with %pR\n", + ret, link->resource[0]); + sedlbauer_release(link); + return -ENODEV; + } else + ((local_info_t *)link->priv)->cardnr = ret; + + return 0; failed: - sedlbauer_release(link); - return -ENODEV; + sedlbauer_release(link); + return -ENODEV; } /* sedlbauer_config */ static void sedlbauer_release(struct pcmcia_device *link) { - local_info_t *local = link->priv; - dev_dbg(&link->dev, "sedlbauer_release(0x%p)\n", link); - - if (local) { - if (local->cardnr >= 0) { - /* no unregister function with hisax */ - HiSax_closecard(local->cardnr); + local_info_t *local = link->priv; + dev_dbg(&link->dev, "sedlbauer_release(0x%p)\n", link); + + if (local) { + if (local->cardnr >= 0) { + /* no unregister function with hisax */ + HiSax_closecard(local->cardnr); + } } - } - pcmcia_disable_device(link); + pcmcia_disable_device(link); } /* sedlbauer_release */ static int sedlbauer_suspend(struct pcmcia_device *link) diff --git a/drivers/isdn/hisax/sportster.c b/drivers/isdn/hisax/sportster.c index 0a53759adfa4..1267298ef551 100644 --- a/drivers/isdn/hisax/sportster.c +++ b/drivers/isdn/hisax/sportster.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -20,7 +20,7 @@ static const char *sportster_revision = "$Revision: 1.16.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) #define SPORTSTER_ISAC 0xC000 @@ -33,17 +33,17 @@ static const char *sportster_revision = "$Revision: 1.16.2.4 $"; static inline int calc_off(unsigned int base, unsigned int off) { - return(base + ((off & 0xfc)<<8) + ((off & 3)<<1)); + return (base + ((off & 0xfc) << 8) + ((off & 3) << 1)); } static inline void -read_fifo(unsigned int adr, u_char * data, int size) +read_fifo(unsigned int adr, u_char *data, int size) { insb(adr, data, size); } static void -write_fifo(unsigned int adr, u_char * data, int size) +write_fifo(unsigned int adr, u_char *data, int size) { outsb(adr, data, size); } @@ -63,13 +63,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { read_fifo(cs->hw.spt.isac, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { write_fifo(cs->hw.spt.isac, data, size); } @@ -106,11 +106,11 @@ sportster_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = READHSCX(cs, 1, HSCX_ISTA); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = ReadISAC(cs, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = READHSCX(cs, 1, HSCX_ISTA); @@ -126,7 +126,7 @@ sportster_interrupt(int intno, void *dev_id) goto Start_ISAC; } /* get a new irq impulse if there any pending */ - bytein(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ +1); + bytein(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ + 1); spin_unlock_irqrestore(&cs->lock, flags); return IRQ_HANDLED; } @@ -137,8 +137,8 @@ release_io_sportster(struct IsdnCardState *cs) int i, adr; byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, 0); - for (i=0; i<64; i++) { - adr = cs->hw.spt.cfg_reg + i *1024; + for (i = 0; i < 64; i++) { + adr = cs->hw.spt.cfg_reg + i * 1024; release_region(adr, 8); } } @@ -160,51 +160,51 @@ Sportster_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_sportster(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_sportster(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - reset_sportster(cs); - inithscxisac(cs, 1); - cs->hw.spt.res_irq |= SPORTSTER_INTE; /* IRQ On */ - byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq); - inithscxisac(cs, 2); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_sportster(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_sportster(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + reset_sportster(cs); + inithscxisac(cs, 1); + cs->hw.spt.res_irq |= SPORTSTER_INTE; /* IRQ On */ + byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq); + inithscxisac(cs, 2); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } static int __devinit get_io_range(struct IsdnCardState *cs) { int i, j, adr; - - for (i=0;i<64;i++) { - adr = cs->hw.spt.cfg_reg + i *1024; + + for (i = 0; i < 64; i++) { + adr = cs->hw.spt.cfg_reg + i * 1024; if (!request_region(adr, 8, "sportster")) { printk(KERN_WARNING "HiSax: USR Sportster config port " - "%x-%x already in use\n", - adr, adr + 8); + "%x-%x already in use\n", + adr, adr + 8); break; - } + } } - if (i==64) - return(1); + if (i == 64) + return (1); else { - for (j=0; jhw.spt.cfg_reg + j *1024; + for (j = 0; j < i; j++) { + adr = cs->hw.spt.cfg_reg + j * 1024; release_region(adr, 8); } - return(0); + return (0); } } @@ -226,28 +226,28 @@ setup_sportster(struct IsdnCard *card) cs->hw.spt.isac = cs->hw.spt.cfg_reg + SPORTSTER_ISAC; cs->hw.spt.hscx[0] = cs->hw.spt.cfg_reg + SPORTSTER_HSCXA; cs->hw.spt.hscx[1] = cs->hw.spt.cfg_reg + SPORTSTER_HSCXB; - - switch(cs->irq) { - case 5: cs->hw.spt.res_irq = 1; - break; - case 7: cs->hw.spt.res_irq = 2; - break; - case 10:cs->hw.spt.res_irq = 3; - break; - case 11:cs->hw.spt.res_irq = 4; - break; - case 12:cs->hw.spt.res_irq = 5; - break; - case 14:cs->hw.spt.res_irq = 6; - break; - case 15:cs->hw.spt.res_irq = 7; - break; - default:release_io_sportster(cs); - printk(KERN_WARNING "Sportster: wrong IRQ\n"); - return(0); + + switch (cs->irq) { + case 5: cs->hw.spt.res_irq = 1; + break; + case 7: cs->hw.spt.res_irq = 2; + break; + case 10:cs->hw.spt.res_irq = 3; + break; + case 11:cs->hw.spt.res_irq = 4; + break; + case 12:cs->hw.spt.res_irq = 5; + break; + case 14:cs->hw.spt.res_irq = 6; + break; + case 15:cs->hw.spt.res_irq = 7; + break; + default:release_io_sportster(cs); + printk(KERN_WARNING "Sportster: wrong IRQ\n"); + return (0); } printk(KERN_INFO "HiSax: USR Sportster config irq:%d cfg:0x%X\n", - cs->irq, cs->hw.spt.cfg_reg); + cs->irq, cs->hw.spt.cfg_reg); setup_isac(cs); cs->readisac = &ReadISAC; cs->writeisac = &WriteISAC; diff --git a/drivers/isdn/hisax/st5481.h b/drivers/isdn/hisax/st5481.h index b9054cb7a0da..8cd2d8277426 100644 --- a/drivers/isdn/hisax/st5481.h +++ b/drivers/isdn/hisax/st5481.h @@ -4,7 +4,7 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen * 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -31,7 +31,7 @@ #define EP_B2_IN 0x05U /* B2 channel in */ #define EP_D_OUT 0x06U /* D channel out */ #define EP_D_IN 0x07U /* D channel in */ - + // Number of isochronous packets. With 20 packets we get // 50 interrupts/sec for each endpoint. @@ -51,7 +51,7 @@ #define B_FLOW_ADJUST 2 // Registers that are written using vendor specific device request -// on endpoint 0. +// on endpoint 0. #define LBA 0x02 /* S loopback */ #define SET_DEFAULT 0x06 /* Soft reset */ @@ -84,7 +84,7 @@ #define FFMSK_B2 0x50 /* B2 fifo interrupt MASK register */ #define GPIO_DIR 0x52 /* GPIO pins direction registers */ #define GPIO_OUT 0x53 /* GPIO pins output register */ -#define GPIO_IN 0x54 /* GPIO pins input register */ +#define GPIO_IN 0x54 /* GPIO pins input register */ #define TXCI 0x56 /* CI command to be transmitted */ @@ -124,8 +124,8 @@ #define IN_COUNTER_ZEROED 0x02 /* In down-counter reached 0 */ #define OUT_COUNTER_ZEROED 0x01 /* Out down-counter reached 0 */ -#define ANY_REC_INT (IN_OVERRUN+IN_UP+IN_DOWN+IN_COUNTER_ZEROED) -#define ANY_XMIT_INT (OUT_UNDERRUN+OUT_UP+OUT_DOWN+OUT_COUNTER_ZEROED) +#define ANY_REC_INT (IN_OVERRUN + IN_UP + IN_DOWN + IN_COUNTER_ZEROED) +#define ANY_XMIT_INT (OUT_UNDERRUN + OUT_UP + OUT_DOWN + OUT_COUNTER_ZEROED) // Level 1 commands that are sent using the TXCI device request @@ -158,7 +158,7 @@ enum { ST_DOUT_NORMAL, ST_DOUT_WAIT_FOR_UNDERRUN, - ST_DOUT_WAIT_FOR_NOT_BUSY, + ST_DOUT_WAIT_FOR_NOT_BUSY, ST_DOUT_WAIT_FOR_STOP, ST_DOUT_WAIT_FOR_RESET, }; @@ -188,9 +188,9 @@ enum { ST_L1_F8, }; -#define L1_STATE_COUNT (ST_L1_F8+1) +#define L1_STATE_COUNT (ST_L1_F8 + 1) -// The first 16 entries match the Level 1 indications that +// The first 16 entries match the Level 1 indications that // are found at offset 4 (CCIST) in the interrupt packet enum { @@ -217,14 +217,14 @@ enum { #define L1_EVENT_COUNT (EV_TIMER3 + 1) -#define ERR(format, arg...) \ -printk(KERN_ERR "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) +#define ERR(format, arg...) \ + printk(KERN_ERR "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) -#define WARNING(format, arg...) \ -printk(KERN_WARNING "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) +#define WARNING(format, arg...) \ + printk(KERN_WARNING "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) -#define INFO(format, arg...) \ -printk(KERN_INFO "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) +#define INFO(format, arg...) \ + printk(KERN_INFO "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) #include #include "fsm.h" @@ -237,7 +237,7 @@ printk(KERN_INFO "%s:%s: " format "\n" , __FILE__, __func__ , ## arg) /* Generic FIFO structure */ struct fifo { - u_char r,w,count,size; + u_char r, w, count, size; spinlock_t lock; }; @@ -269,7 +269,7 @@ static inline int fifo_add(struct fifo *fifo) index = -1; } else { // Return index where to get the next data to add to the FIFO - index = fifo->w++ & (fifo->size-1); + index = fifo->w++ & (fifo->size - 1); fifo->count++; } spin_unlock_irqrestore(&fifo->lock, flags); @@ -294,7 +294,7 @@ static inline int fifo_remove(struct fifo *fifo) index = -1; } else { // Return index where to get the next data from the FIFO - index = fifo->r++ & (fifo->size-1); + index = fifo->r++ & (fifo->size - 1); fifo->count--; } spin_unlock_irqrestore(&fifo->lock, flags); @@ -311,14 +311,14 @@ typedef struct ctrl_msg { struct usb_ctrlrequest dr; ctrl_complete_t complete; void *context; -} ctrl_msg; +} ctrl_msg; /* FIFO of ctrl messages waiting to be sent */ #define MAX_EP0_MSG 16 struct ctrl_msg_fifo { struct fifo f; struct ctrl_msg data[MAX_EP0_MSG]; -}; +}; #define MAX_DFRAME_LEN_L1 300 #define HSCX_BUFMAX 4096 @@ -330,7 +330,7 @@ struct st5481_ctrl { }; struct st5481_intr { - // struct evt_fifo evt_fifo; + // struct evt_fifo evt_fifo; struct urb *urb; }; @@ -407,21 +407,21 @@ struct st5481_adapter { * Submit an URB with error reporting. This is a macro so * the __func__ returns the caller function name. */ -#define SUBMIT_URB(urb, mem_flags) \ -({ \ - int status; \ - if ((status = usb_submit_urb(urb, mem_flags)) < 0) { \ - WARNING("usb_submit_urb failed,status=%d", status); \ - } \ - status; \ -}) +#define SUBMIT_URB(urb, mem_flags) \ + ({ \ + int status; \ + if ((status = usb_submit_urb(urb, mem_flags)) < 0) { \ + WARNING("usb_submit_urb failed,status=%d", status); \ + } \ + status; \ + }) /* * USB double buffering, return the URB index (0 or 1). */ static inline int get_buf_nr(struct urb *urbs[], struct urb *urb) { - return (urbs[0]==urb ? 0 : 1); + return (urbs[0] == urb ? 0 : 1); } /* ---------------------------------------------------------------------- */ @@ -442,17 +442,17 @@ void st5481_d_exit(void); /* USB */ void st5481_ph_command(struct st5481_adapter *adapter, unsigned int command); -int st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev, +int st5481_setup_isocpipes(struct urb *urb[2], struct usb_device *dev, unsigned int pipe, int num_packets, int packet_size, int buf_size, usb_complete_t complete, void *context); -void st5481_release_isocpipes(struct urb* urb[2]); +void st5481_release_isocpipes(struct urb *urb[2]); void st5481_usb_pipe_reset(struct st5481_adapter *adapter, - u_char pipe, ctrl_complete_t complete, void *context); + u_char pipe, ctrl_complete_t complete, void *context); void st5481_usb_device_ctrl_msg(struct st5481_adapter *adapter, - u8 request, u16 value, - ctrl_complete_t complete, void *context); + u8 request, u16 value, + ctrl_complete_t complete, void *context); int st5481_setup_usb(struct st5481_adapter *adapter); void st5481_release_usb(struct st5481_adapter *adapter); void st5481_start(struct st5481_adapter *adapter); @@ -468,18 +468,18 @@ extern int st5481_debug; #ifdef CONFIG_HISAX_DEBUG -#define DBG_ISO_PACKET(level,urb) \ - if (level & __debug_variable) dump_iso_packet(__func__,urb) +#define DBG_ISO_PACKET(level, urb) \ + if (level & __debug_variable) dump_iso_packet(__func__, urb) static void __attribute__((unused)) dump_iso_packet(const char *name, struct urb *urb) { - int i,j; - int len,ofs; + int i, j; + int len, ofs; u_char *data; printk(KERN_DEBUG "%s: packets=%d,errors=%d\n", - name,urb->number_of_packets,urb->error_count); + name, urb->number_of_packets, urb->error_count); for (i = 0; i < urb->number_of_packets; ++i) { if (urb->pipe & USB_DIR_IN) { len = urb->iso_frame_desc[i].actual_length; @@ -487,11 +487,11 @@ dump_iso_packet(const char *name, struct urb *urb) len = urb->iso_frame_desc[i].length; } ofs = urb->iso_frame_desc[i].offset; - printk(KERN_DEBUG "len=%.2d,ofs=%.3d ",len,ofs); + printk(KERN_DEBUG "len=%.2d,ofs=%.3d ", len, ofs); if (len) { - data = urb->transfer_buffer+ofs; - for (j=0; j < len; j++) { - printk ("%.2x", data[j]); + data = urb->transfer_buffer + ofs; + for (j = 0; j < len; j++) { + printk("%.2x", data[j]); } } printk("\n"); @@ -513,17 +513,17 @@ static inline const char *ST5481_CMD_string(int evt) case ST5481_CMD_ARL: return "ARL"; case ST5481_CMD_PDN: return "PDN"; }; - - sprintf(s,"0x%x",evt); + + sprintf(s, "0x%x", evt); return s; -} +} #else -#define DBG_ISO_PACKET(level,urb) do {} while (0) +#define DBG_ISO_PACKET(level, urb) do {} while (0) #endif -#endif +#endif diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c index ed4bc564dc63..409849165838 100644 --- a/drivers/isdn/hisax/st5481_b.c +++ b/drivers/isdn/hisax/st5481_b.c @@ -4,7 +4,7 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen * 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -27,33 +27,33 @@ static inline void B_L1L2(struct st5481_bcs *bcs, int pr, void *arg) /* * Encode and transmit next frame. */ -static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) +static void usb_b_out(struct st5481_bcs *bcs, int buf_nr) { struct st5481_b_out *b_out = &bcs->b_out; struct st5481_adapter *adapter = bcs->adapter; struct urb *urb; - unsigned int packet_size,offset; - int len,buf_size,bytes_sent; + unsigned int packet_size, offset; + int len, buf_size, bytes_sent; int i; struct sk_buff *skb; - + if (test_and_set_bit(buf_nr, &b_out->busy)) { - DBG(4,"ep %d urb %d busy",(bcs->channel+1)*2,buf_nr); + DBG(4, "ep %d urb %d busy", (bcs->channel + 1) * 2, buf_nr); return; } urb = b_out->urb[buf_nr]; // Adjust isoc buffer size according to flow state - if(b_out->flow_event & (OUT_DOWN | OUT_UNDERRUN)) { - buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST; + if (b_out->flow_event & (OUT_DOWN | OUT_UNDERRUN)) { + buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST; packet_size = SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST; - DBG(4,"B%d,adjust flow,add %d bytes",bcs->channel+1,B_FLOW_ADJUST); - } else if(b_out->flow_event & OUT_UP){ - buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST; + DBG(4, "B%d,adjust flow,add %d bytes", bcs->channel + 1, B_FLOW_ADJUST); + } else if (b_out->flow_event & OUT_UP) { + buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST; packet_size = SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST; - DBG(4,"B%d,adjust flow,remove %d bytes",bcs->channel+1,B_FLOW_ADJUST); + DBG(4, "B%d,adjust flow,remove %d bytes", bcs->channel + 1, B_FLOW_ADJUST); } else { - buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT; + buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT; packet_size = 8; } b_out->flow_event = 0; @@ -62,15 +62,15 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) while (len < buf_size) { if ((skb = b_out->tx_skb)) { DBG_SKB(0x100, skb); - DBG(4,"B%d,len=%d",bcs->channel+1,skb->len); - - if (bcs->mode == L1_MODE_TRANS) { + DBG(4, "B%d,len=%d", bcs->channel + 1, skb->len); + + if (bcs->mode == L1_MODE_TRANS) { bytes_sent = buf_size - len; if (skb->len < bytes_sent) bytes_sent = skb->len; { /* swap tx bytes to get hearable audio data */ register unsigned char *src = skb->data; - register unsigned char *dest = urb->transfer_buffer+len; + register unsigned char *dest = urb->transfer_buffer + len; register unsigned int count; for (count = 0; count < bytes_sent; count++) *dest++ = bitrev8(*src++); @@ -79,7 +79,7 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) } else { len += isdnhdlc_encode(&b_out->hdlc_state, skb->data, skb->len, &bytes_sent, - urb->transfer_buffer+len, buf_size-len); + urb->transfer_buffer + len, buf_size-len); } skb_pull(skb, bytes_sent); @@ -90,21 +90,21 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) B_L1L2(bcs, PH_DATA | CONFIRM, (void *)(unsigned long) skb->truesize); dev_kfree_skb_any(skb); -/* if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */ -/* st5481B_sched_event(bcs, B_XMTBUFREADY); */ -/* } */ +/* if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */ +/* st5481B_sched_event(bcs, B_XMTBUFREADY); */ +/* } */ } } else { if (bcs->mode == L1_MODE_TRANS) { - memset(urb->transfer_buffer+len, 0xff, buf_size-len); + memset(urb->transfer_buffer + len, 0xff, buf_size-len); len = buf_size; } else { // Send flags len += isdnhdlc_encode(&b_out->hdlc_state, NULL, 0, &bytes_sent, - urb->transfer_buffer+len, buf_size-len); + urb->transfer_buffer + len, buf_size-len); } - } + } } // Prepare the URB @@ -118,7 +118,7 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) urb->number_of_packets = i; urb->dev = adapter->usb_dev; - DBG_ISO_PACKET(0x200,urb); + DBG_ISO_PACKET(0x200, urb); SUBMIT_URB(urb, GFP_NOIO); } @@ -131,12 +131,12 @@ static void st5481B_start_xfer(void *context) { struct st5481_bcs *bcs = context; - DBG(4,"B%d",bcs->channel+1); + DBG(4, "B%d", bcs->channel + 1); // Start transmitting (flags or data) on B channel - usb_b_out(bcs,0); - usb_b_out(bcs,1); + usb_b_out(bcs, 0); + usb_b_out(bcs, 1); } /* @@ -158,7 +158,7 @@ static void led_blink(struct st5481_adapter *adapter) } else { leds &= ~GREEN_LED; } - + st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, leds, NULL, NULL); } @@ -168,27 +168,27 @@ static void usb_b_out_complete(struct urb *urb) struct st5481_b_out *b_out = &bcs->b_out; struct st5481_adapter *adapter = bcs->adapter; int buf_nr; - + buf_nr = get_buf_nr(b_out->urb, urb); test_and_clear_bit(buf_nr, &b_out->busy); if (unlikely(urb->status < 0)) { switch (urb->status) { - case -ENOENT: - case -ESHUTDOWN: - case -ECONNRESET: - DBG(4,"urb killed status %d", urb->status); - return; // Give up - default: - WARNING("urb status %d",urb->status); - if (b_out->busy == 0) { - st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL); - } - break; + case -ENOENT: + case -ESHUTDOWN: + case -ECONNRESET: + DBG(4, "urb killed status %d", urb->status); + return; // Give up + default: + WARNING("urb status %d", urb->status); + if (b_out->busy == 0) { + st5481_usb_pipe_reset(adapter, (bcs->channel + 1) * 2 | USB_DIR_OUT, NULL, NULL); + } + break; } } - usb_b_out(bcs,buf_nr); + usb_b_out(bcs, buf_nr); if (adapter->number_of_leds == 2) led_blink(adapter); @@ -202,7 +202,7 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) struct st5481_b_out *b_out = &bcs->b_out; struct st5481_adapter *adapter = bcs->adapter; - DBG(4,"B%d,mode=%d", bcs->channel + 1, mode); + DBG(4, "B%d,mode=%d", bcs->channel + 1, mode); if (bcs->mode == mode) return; @@ -223,14 +223,14 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) features |= HDLC_56KBIT; isdnhdlc_out_init(&b_out->hdlc_state, features); } - st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2, NULL, NULL); - + st5481_usb_pipe_reset(adapter, (bcs->channel + 1) * 2, NULL, NULL); + // Enable B channel interrupts - st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel*2), - OUT_UP+OUT_DOWN+OUT_UNDERRUN, NULL, NULL); + st5481_usb_device_ctrl_msg(adapter, FFMSK_B1 + (bcs->channel * 2), + OUT_UP + OUT_DOWN + OUT_UNDERRUN, NULL, NULL); // Enable B channel FIFOs - st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel*2), 32, st5481B_start_xfer, bcs); + st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel * 2), 32, st5481B_start_xfer, bcs); if (adapter->number_of_leds == 4) { if (bcs->channel == 0) { adapter->leds |= B1_LED; @@ -240,10 +240,10 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) } } else { // Disble B channel interrupts - st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel*2), 0, NULL, NULL); + st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel * 2), 0, NULL, NULL); // Disable B channel FIFOs - st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel*2), 0, NULL, NULL); + st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel * 2), 0, NULL, NULL); if (adapter->number_of_leds == 4) { if (bcs->channel == 0) { @@ -258,7 +258,7 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) dev_kfree_skb_any(b_out->tx_skb); b_out->tx_skb = NULL; } - + } } @@ -268,9 +268,9 @@ static int st5481_setup_b_out(struct st5481_bcs *bcs) struct usb_interface *intf; struct usb_host_interface *altsetting = NULL; struct usb_host_endpoint *endpoint; - struct st5481_b_out *b_out = &bcs->b_out; + struct st5481_b_out *b_out = &bcs->b_out; - DBG(4,""); + DBG(4, ""); intf = usb_ifnum_to_if(dev, 0); if (intf) @@ -281,11 +281,11 @@ static int st5481_setup_b_out(struct st5481_bcs *bcs) // Allocate URBs and buffers for the B channel out endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2]; - DBG(4,"endpoint address=%02x,packet size=%d", + DBG(4, "endpoint address=%02x,packet size=%d", endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize)); // Allocate memory for 8000bytes/sec + extra bytes if underrun - return st5481_setup_isocpipes(b_out->urb, dev, + return st5481_setup_isocpipes(b_out->urb, dev, usb_sndisocpipe(dev, endpoint->desc.bEndpointAddress), NUM_ISO_PACKETS_B, SIZE_ISO_PACKETS_B_OUT, NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST, @@ -296,7 +296,7 @@ static void st5481_release_b_out(struct st5481_bcs *bcs) { struct st5481_b_out *b_out = &bcs->b_out; - DBG(4,""); + DBG(4, ""); st5481_release_isocpipes(b_out->urb); } @@ -305,7 +305,7 @@ int st5481_setup_b(struct st5481_bcs *bcs) { int retval; - DBG(4,""); + DBG(4, ""); retval = st5481_setup_b_out(bcs); if (retval) @@ -324,9 +324,9 @@ int st5481_setup_b(struct st5481_bcs *bcs) return 0; - err_b_out: +err_b_out: st5481_release_b_out(bcs); - err: +err: return retval; } @@ -335,7 +335,7 @@ int st5481_setup_b(struct st5481_bcs *bcs) */ void st5481_release_b(struct st5481_bcs *bcs) { - DBG(4,""); + DBG(4, ""); st5481_release_in(&bcs->b_in); st5481_release_b_out(bcs); @@ -365,12 +365,12 @@ void st5481_b_l2l1(struct hisax_if *ifc, int pr, void *arg) break; case PH_ACTIVATE | REQUEST: mode = (long) arg; - DBG(4,"B%d,PH_ACTIVATE_REQUEST %ld", bcs->channel + 1, mode); + DBG(4, "B%d,PH_ACTIVATE_REQUEST %ld", bcs->channel + 1, mode); st5481B_mode(bcs, mode); B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL); break; case PH_DEACTIVATE | REQUEST: - DBG(4,"B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); + DBG(4, "B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); st5481B_mode(bcs, L1_MODE_NULL); B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL); break; diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c index db247b79e561..e88c5c71fca7 100644 --- a/drivers/isdn/hisax/st5481_d.c +++ b/drivers/isdn/hisax/st5481_d.c @@ -4,7 +4,7 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen * 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -32,22 +32,22 @@ static char *strL1State[] = static char *strL1Event[] = { - "EV_IND_DP", - "EV_IND_1", - "EV_IND_2", - "EV_IND_3", - "EV_IND_RSY", - "EV_IND_5", - "EV_IND_6", - "EV_IND_7", - "EV_IND_AP", - "EV_IND_9", - "EV_IND_10", - "EV_IND_11", + "EV_IND_DP", + "EV_IND_1", + "EV_IND_2", + "EV_IND_3", + "EV_IND_RSY", + "EV_IND_5", + "EV_IND_6", + "EV_IND_7", + "EV_IND_AP", + "EV_IND_9", + "EV_IND_10", + "EV_IND_11", "EV_IND_AI8", "EV_IND_AI10", "EV_IND_AIL", - "EV_IND_DI", + "EV_IND_DI", "EV_PH_ACTIVATE_REQ", "EV_PH_DEACTIVATE_REQ", "EV_TIMER3", @@ -67,7 +67,7 @@ l1_go_f3(struct FsmInst *fi, int event, void *arg) if (fi->state == ST_L1_F7) ph_disconnect(adapter); - + FsmChangeState(fi, ST_L1_F3); D_L1L2(adapter, PH_DEACTIVATE | INDICATION, NULL); } @@ -168,11 +168,11 @@ static struct FsmNode L1FnList[] __initdata = }; static __printf(2, 3) -void l1m_debug(struct FsmInst *fi, char *fmt, ...) + void l1m_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; char buf[256]; - + va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); DBG(8, "%s", buf); @@ -191,54 +191,54 @@ void l1m_debug(struct FsmInst *fi, char *fmt, ...) L1 FRAME D_OUT_STATE USB D CHANNEL -------- ----------- --- --------- - - FIXME - - -> [xx..xx] SHORT_INIT -> [7Exx..xxC1C27EFF] - SHORT_WAIT_DEN <> OUT_D_COUNTER=16 - - END_OF_SHORT <- DEN_EVENT -> 7Exx - xxxx - xxxx - xxxx - xxxx - xxxx - C1C1 - 7EFF - WAIT_FOR_RESET_IDLE <- D_UNDERRUN <- (8ms) - IDLE <> Reset pipe - - + + FIXME + + -> [xx..xx] SHORT_INIT -> [7Exx..xxC1C27EFF] + SHORT_WAIT_DEN <> OUT_D_COUNTER=16 + + END_OF_SHORT <- DEN_EVENT -> 7Exx + xxxx + xxxx + xxxx + xxxx + xxxx + C1C1 + 7EFF + WAIT_FOR_RESET_IDLE <- D_UNDERRUN <- (8ms) + IDLE <> Reset pipe + + Transmit long frame (>= 16 bytes of encoded data): L1 FRAME D_OUT_STATE USB D CHANNEL -------- ----------- --- --------- - -> [xx...xx] IDLE - WAIT_FOR_STOP <> OUT_D_COUNTER=0 - WAIT_FOR_RESET <> Reset pipe - STOP - INIT_LONG_FRAME -> [7Exx..xx] - WAIT_DEN <> OUT_D_COUNTER=16 - OUT_NORMAL <- DEN_EVENT -> 7Exx - END_OF_FRAME_BUSY -> [xxxx] xxxx - END_OF_FRAME_NOT_BUSY -> [xxxx] xxxx - -> [xxxx] xxxx - -> [C1C2] xxxx - -> [7EFF] xxxx - xxxx - xxxx - .... - xxxx - C1C2 - 7EFF - <- D_UNDERRUN <- (> 8ms) - WAIT_FOR_STOP <> OUT_D_COUNTER=0 - WAIT_FOR_RESET <> Reset pipe - STOP - -*/ + -> [xx...xx] IDLE + WAIT_FOR_STOP <> OUT_D_COUNTER=0 + WAIT_FOR_RESET <> Reset pipe + STOP + INIT_LONG_FRAME -> [7Exx..xx] + WAIT_DEN <> OUT_D_COUNTER=16 + OUT_NORMAL <- DEN_EVENT -> 7Exx + END_OF_FRAME_BUSY -> [xxxx] xxxx + END_OF_FRAME_NOT_BUSY -> [xxxx] xxxx + -> [xxxx] xxxx + -> [C1C2] xxxx + -> [7EFF] xxxx + xxxx + xxxx + .... + xxxx + C1C2 + 7EFF + <- D_UNDERRUN <- (> 8ms) + WAIT_FOR_STOP <> OUT_D_COUNTER=0 + WAIT_FOR_RESET <> Reset pipe + STOP + +*/ static struct Fsm dout_fsm; @@ -254,7 +254,7 @@ static char *strDoutState[] = "ST_DOUT_NORMAL", "ST_DOUT_WAIT_FOR_UNDERRUN", - "ST_DOUT_WAIT_FOR_NOT_BUSY", + "ST_DOUT_WAIT_FOR_NOT_BUSY", "ST_DOUT_WAIT_FOR_STOP", "ST_DOUT_WAIT_FOR_RESET", }; @@ -271,11 +271,11 @@ static char *strDoutEvent[] = }; static __printf(2, 3) -void dout_debug(struct FsmInst *fi, char *fmt, ...) + void dout_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; char buf[256]; - + va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); DBG(0x2, "%s", buf); @@ -313,19 +313,19 @@ static void usb_d_out(struct st5481_adapter *adapter, int buf_nr) skb = d_out->tx_skb; buf_size = NUM_ISO_PACKETS_D * SIZE_ISO_PACKETS_D_OUT; - + if (skb) { len = isdnhdlc_encode(&d_out->hdlc_state, skb->data, skb->len, &bytes_sent, urb->transfer_buffer, buf_size); - skb_pull(skb,bytes_sent); + skb_pull(skb, bytes_sent); } else { // Send flags or idle len = isdnhdlc_encode(&d_out->hdlc_state, NULL, 0, &bytes_sent, urb->transfer_buffer, buf_size); } - + if (len < buf_size) { FsmChangeState(&d_out->fsm, ST_DOUT_WAIT_FOR_UNDERRUN); } @@ -354,15 +354,15 @@ static void usb_d_out(struct st5481_adapter *adapter, int buf_nr) urb->dev = adapter->usb_dev; // Need to transmit the next buffer 2ms after the DEN_EVENT urb->transfer_flags = 0; - urb->start_frame = usb_get_current_frame_number(adapter->usb_dev)+2; + urb->start_frame = usb_get_current_frame_number(adapter->usb_dev) + 2; - DBG_ISO_PACKET(0x20,urb); + DBG_ISO_PACKET(0x20, urb); if (usb_submit_urb(urb, GFP_KERNEL) < 0) { // There is another URB queued up urb->transfer_flags = URB_ISO_ASAP; SUBMIT_URB(urb, GFP_KERNEL); - } + } } static void fifo_reseted(void *context) @@ -377,7 +377,7 @@ static void usb_d_out_complete(struct urb *urb) struct st5481_adapter *adapter = urb->context; struct st5481_d_out *d_out = &adapter->d_out; long buf_nr; - + DBG(2, ""); buf_nr = get_buf_nr(d_out->urb, urb); @@ -385,17 +385,17 @@ static void usb_d_out_complete(struct urb *urb) if (unlikely(urb->status < 0)) { switch (urb->status) { - case -ENOENT: - case -ESHUTDOWN: - case -ECONNRESET: - DBG(1,"urb killed status %d", urb->status); - break; - default: - WARNING("urb status %d",urb->status); - if (d_out->busy == 0) { - st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter); - } - break; + case -ENOENT: + case -ESHUTDOWN: + case -ECONNRESET: + DBG(1, "urb killed status %d", urb->status); + break; + default: + WARNING("urb status %d", urb->status); + if (d_out->busy == 0) { + st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter); + } + break; } return; // Give up } @@ -417,7 +417,7 @@ static void dout_start_xmit(struct FsmInst *fsm, int event, void *arg) skb = d_out->tx_skb; - DBG(2,"len=%d",skb->len); + DBG(2, "len=%d", skb->len); isdnhdlc_out_init(&d_out->hdlc_state, HDLC_DCHANNEL | HDLC_BITREVERSE); @@ -433,7 +433,7 @@ static void dout_start_xmit(struct FsmInst *fsm, int event, void *arg) urb->transfer_buffer, 16); skb_pull(skb, bytes_sent); - if(len < 16) + if (len < 16) FsmChangeState(&d_out->fsm, ST_DOUT_SHORT_INIT); else FsmChangeState(&d_out->fsm, ST_DOUT_LONG_INIT); @@ -455,7 +455,7 @@ static void dout_start_xmit(struct FsmInst *fsm, int event, void *arg) urb->dev = adapter->usb_dev; urb->transfer_flags = URB_ISO_ASAP; - DBG_ISO_PACKET(0x20,urb); + DBG_ISO_PACKET(0x20, urb); SUBMIT_URB(urb, GFP_KERNEL); } @@ -480,7 +480,7 @@ static void dout_long_enable_fifo(struct FsmInst *fsm, int event, void *arg) { struct st5481_adapter *adapter = fsm->userdata; struct st5481_d_out *d_out = &adapter->d_out; - + st5481_usb_device_ctrl_msg(adapter, OUT_D_COUNTER, 16, NULL, NULL); FsmChangeState(&d_out->fsm, ST_DOUT_LONG_WAIT_DEN); } @@ -619,8 +619,8 @@ static void ph_connect(struct st5481_adapter *adapter) struct st5481_d_out *d_out = &adapter->d_out; struct st5481_in *d_in = &adapter->d_in; - DBG(8,""); - + DBG(8, ""); + FsmChangeState(&d_out->fsm, ST_DOUT_NONE); // st5481_usb_device_ctrl_msg(adapter, FFMSK_D, OUT_UNDERRUN, NULL, NULL); @@ -644,7 +644,7 @@ static void ph_connect(struct st5481_adapter *adapter) */ static void ph_disconnect(struct st5481_adapter *adapter) { - DBG(8,""); + DBG(8, ""); st5481_in_mode(&adapter->d_in, L1_MODE_NULL); @@ -661,7 +661,7 @@ static int st5481_setup_d_out(struct st5481_adapter *adapter) struct usb_host_endpoint *endpoint; struct st5481_d_out *d_out = &adapter->d_out; - DBG(2,""); + DBG(2, ""); intf = usb_ifnum_to_if(dev, 0); if (intf) @@ -672,10 +672,10 @@ static int st5481_setup_d_out(struct st5481_adapter *adapter) // Allocate URBs and buffers for the D channel out endpoint = &altsetting->endpoint[EP_D_OUT-1]; - DBG(2,"endpoint address=%02x,packet size=%d", + DBG(2, "endpoint address=%02x,packet size=%d", endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize)); - return st5481_setup_isocpipes(d_out->urb, dev, + return st5481_setup_isocpipes(d_out->urb, dev, usb_sndisocpipe(dev, endpoint->desc.bEndpointAddress), NUM_ISO_PACKETS_D, SIZE_ISO_PACKETS_D_OUT, NUM_ISO_PACKETS_D * SIZE_ISO_PACKETS_D_OUT, @@ -686,7 +686,7 @@ static void st5481_release_d_out(struct st5481_adapter *adapter) { struct st5481_d_out *d_out = &adapter->d_out; - DBG(2,""); + DBG(2, ""); st5481_release_isocpipes(d_out->urb); } @@ -695,7 +695,7 @@ int st5481_setup_d(struct st5481_adapter *adapter) { int retval; - DBG(2,""); + DBG(2, ""); retval = st5481_setup_d_out(adapter); if (retval) @@ -726,15 +726,15 @@ int st5481_setup_d(struct st5481_adapter *adapter) return 0; - err_d_out: +err_d_out: st5481_release_d_out(adapter); - err: +err: return retval; } void st5481_release_d(struct st5481_adapter *adapter) { - DBG(2,""); + DBG(2, ""); st5481_release_in(&adapter->d_in); st5481_release_d_out(adapter); @@ -766,9 +766,9 @@ int __init st5481_d_init(void) return 0; - err_l1: +err_l1: FsmFree(&l1fsm); - err: +err: return retval; } diff --git a/drivers/isdn/hisax/st5481_init.c b/drivers/isdn/hisax/st5481_init.c index 9f7fd18ff773..100296e20dc0 100644 --- a/drivers/isdn/hisax/st5481_init.c +++ b/drivers/isdn/hisax/st5481_init.c @@ -4,13 +4,13 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen * 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ -/* +/* * TODO: * * b layer1 delay? @@ -63,9 +63,9 @@ static int probe_st5481(struct usb_interface *intf, int retval, i; printk(KERN_INFO "st541: found adapter VendorId %04x, ProductId %04x, LEDs %d\n", - le16_to_cpu(dev->descriptor.idVendor), - le16_to_cpu(dev->descriptor.idProduct), - number_of_leds); + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct), + number_of_leds); adapter = kzalloc(sizeof(struct st5481_adapter), GFP_KERNEL); if (!adapter) @@ -105,7 +105,7 @@ static int probe_st5481(struct usb_interface *intf, b_if[i] = &adapter->bcs[i].b_if; if (hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb", - protocol) != 0) + protocol) != 0) goto err_b1; st5481_start(adapter); @@ -113,15 +113,15 @@ static int probe_st5481(struct usb_interface *intf, usb_set_intfdata(intf, adapter); return 0; - err_b1: +err_b1: st5481_release_b(&adapter->bcs[1]); - err_b: +err_b: st5481_release_b(&adapter->bcs[0]); - err_d: +err_d: st5481_release_d(adapter); - err_usb: +err_usb: st5481_release_usb(adapter); - err: +err: kfree(adapter); return -EIO; } @@ -134,12 +134,12 @@ static void disconnect_st5481(struct usb_interface *intf) { struct st5481_adapter *adapter = usb_get_intfdata(intf); - DBG(1,""); + DBG(1, ""); usb_set_intfdata(intf, NULL); if (!adapter) return; - + st5481_stop(adapter); st5481_release_b(&adapter->bcs[1]); st5481_release_b(&adapter->bcs[0]); @@ -157,25 +157,25 @@ static void disconnect_st5481(struct usb_interface *intf) * The last 4 bits in the Product Id is set with 4 pins on the chip. */ static struct usb_device_id st5481_ids[] = { - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x0) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x1) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x2) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x3) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x4) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x5) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x6) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x7) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x8) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0x9) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xA) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xB) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xC) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xD) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xE) }, - { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID+0xF) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x0) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x1) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x2) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x3) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x4) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x5) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x6) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x7) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x8) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0x9) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0xA) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0xB) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0xC) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0xD) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0xE) }, + { USB_DEVICE(ST_VENDOR_ID, ST5481_PRODUCT_ID + 0xF) }, { } }; -MODULE_DEVICE_TABLE (usb, st5481_ids); +MODULE_DEVICE_TABLE(usb, st5481_ids); static struct usb_driver st5481_usb_driver = { .name = "st5481_usb", @@ -204,9 +204,9 @@ static int __init st5481_usb_init(void) return 0; - out_d_exit: +out_d_exit: st5481_d_exit(); - out: +out: return retval; } diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c index 159e8fa00fd6..017c67ea3f4c 100644 --- a/drivers/isdn/hisax/st5481_usb.c +++ b/drivers/isdn/hisax/st5481_usb.c @@ -4,7 +4,7 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen * 2001 by Kai Germaschewski - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -36,13 +36,13 @@ static void usb_next_ctrl_msg(struct urb *urb, } if ((r_index = fifo_remove(&ctrl->msg_fifo.f)) < 0) { - test_and_clear_bit(0,&ctrl->busy); + test_and_clear_bit(0, &ctrl->busy); return; - } - urb->setup_packet = + } + urb->setup_packet = (unsigned char *)&ctrl->msg_fifo.data[r_index]; - - DBG(1,"request=0x%02x,value=0x%04x,index=%x", + + DBG(1, "request=0x%02x,value=0x%04x,index=%x", ((struct ctrl_msg *)urb->setup_packet)->dr.bRequest, ((struct ctrl_msg *)urb->setup_packet)->dr.wValue, ((struct ctrl_msg *)urb->setup_packet)->dr.wIndex); @@ -64,13 +64,13 @@ static void usb_ctrl_msg(struct st5481_adapter *adapter, struct st5481_ctrl *ctrl = &adapter->ctrl; int w_index; struct ctrl_msg *ctrl_msg; - + if ((w_index = fifo_add(&ctrl->msg_fifo.f)) < 0) { WARNING("control msg FIFO full"); return; } - ctrl_msg = &ctrl->msg_fifo.data[w_index]; - + ctrl_msg = &ctrl->msg_fifo.data[w_index]; + ctrl_msg->dr.bRequestType = requesttype; ctrl_msg->dr.bRequest = request; ctrl_msg->dr.wValue = cpu_to_le16p(&value); @@ -86,11 +86,11 @@ static void usb_ctrl_msg(struct st5481_adapter *adapter, * Asynchronous endpoint 0 device request. */ void st5481_usb_device_ctrl_msg(struct st5481_adapter *adapter, - u8 request, u16 value, - ctrl_complete_t complete, void *context) + u8 request, u16 value, + ctrl_complete_t complete, void *context) { - usb_ctrl_msg(adapter, request, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + usb_ctrl_msg(adapter, request, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, 0, complete, context); } @@ -98,10 +98,10 @@ void st5481_usb_device_ctrl_msg(struct st5481_adapter *adapter, * Asynchronous pipe reset (async version of usb_clear_halt). */ void st5481_usb_pipe_reset(struct st5481_adapter *adapter, - u_char pipe, - ctrl_complete_t complete, void *context) + u_char pipe, + ctrl_complete_t complete, void *context) { - DBG(1,"pipe=%02x",pipe); + DBG(1, "pipe=%02x", pipe); usb_ctrl_msg(adapter, USB_REQ_CLEAR_FEATURE, USB_DIR_OUT | USB_RECIP_ENDPOINT, @@ -115,7 +115,7 @@ void st5481_usb_pipe_reset(struct st5481_adapter *adapter, void st5481_ph_command(struct st5481_adapter *adapter, unsigned int command) { - DBG(8,"command=%s", ST5481_CMD_string(command)); + DBG(8, "command=%s", ST5481_CMD_string(command)); st5481_usb_device_ctrl_msg(adapter, TXCI, command, NULL, NULL); } @@ -130,33 +130,33 @@ static void usb_ctrl_complete(struct urb *urb) struct st5481_adapter *adapter = urb->context; struct st5481_ctrl *ctrl = &adapter->ctrl; struct ctrl_msg *ctrl_msg; - + if (unlikely(urb->status < 0)) { switch (urb->status) { - case -ENOENT: - case -ESHUTDOWN: - case -ECONNRESET: - DBG(1,"urb killed status %d", urb->status); - return; // Give up - default: - WARNING("urb status %d",urb->status); - break; + case -ENOENT: + case -ESHUTDOWN: + case -ECONNRESET: + DBG(1, "urb killed status %d", urb->status); + return; // Give up + default: + WARNING("urb status %d", urb->status); + break; } } ctrl_msg = (struct ctrl_msg *)urb->setup_packet; - + if (ctrl_msg->dr.bRequest == USB_REQ_CLEAR_FEATURE) { - /* Special case handling for pipe reset */ + /* Special case handling for pipe reset */ le16_to_cpus(&ctrl_msg->dr.wIndex); usb_reset_endpoint(adapter->usb_dev, ctrl_msg->dr.wIndex); } - + if (ctrl_msg->complete) ctrl_msg->complete(ctrl_msg->context); clear_bit(0, &ctrl->busy); - + // Try to send next control message usb_next_ctrl_msg(urb, adapter); return; @@ -181,23 +181,23 @@ static void usb_int_complete(struct urb *urb) int status; switch (urb->status) { - case 0: - /* success */ - break; - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - /* this urb is terminated, clean up */ - DBG(2, "urb shutting down with status: %d", urb->status); - return; - default: - WARNING("nonzero urb status received: %d", urb->status); - goto exit; + case 0: + /* success */ + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + /* this urb is terminated, clean up */ + DBG(2, "urb shutting down with status: %d", urb->status); + return; + default: + WARNING("nonzero urb status received: %d", urb->status); + goto exit; } - + DBG_PACKET(2, data, INT_PKT_SIZE); - + if (urb->actual_length == 0) { goto exit; } @@ -214,7 +214,7 @@ static void usb_int_complete(struct urb *urb) FsmEvent(&adapter->d_out.fsm, EV_DOUT_UNDERRUN, NULL); if (irqbyte & OUT_DOWN) -;// printk("OUT_DOWN\n"); + ;// printk("OUT_DOWN\n"); irqbyte = data[MPINT]; if (irqbyte & RXCI_INT) @@ -226,7 +226,7 @@ static void usb_int_complete(struct urb *urb) urb->actual_length = 0; exit: - status = usb_submit_urb (urb, GFP_ATOMIC); + status = usb_submit_urb(urb, GFP_ATOMIC); if (status) WARNING("usb_submit_urb failed with result %d", status); } @@ -246,11 +246,11 @@ int st5481_setup_usb(struct st5481_adapter *adapter) int status; struct urb *urb; u8 *buf; - - DBG(2,""); - - if ((status = usb_reset_configuration (dev)) < 0) { - WARNING("reset_configuration failed,status=%d",status); + + DBG(2, ""); + + if ((status = usb_reset_configuration(dev)) < 0) { + WARNING("reset_configuration failed,status=%d", status); return status; } @@ -261,7 +261,7 @@ int st5481_setup_usb(struct st5481_adapter *adapter) return -ENXIO; // Check if the config is sane - if ( altsetting->desc.bNumEndpoints != 7 ) { + if (altsetting->desc.bNumEndpoints != 7) { WARNING("expecting 7 got %d endpoints!", altsetting->desc.bNumEndpoints); return -EINVAL; } @@ -271,8 +271,8 @@ int st5481_setup_usb(struct st5481_adapter *adapter) altsetting->endpoint[4].desc.wMaxPacketSize = __constant_cpu_to_le16(32); // Use alternative setting 3 on interface 0 to have 2B+D - if ((status = usb_set_interface (dev, 0, 3)) < 0) { - WARNING("usb_set_interface failed,status=%d",status); + if ((status = usb_set_interface(dev, 0, 3)) < 0) { + WARNING("usb_set_interface failed,status=%d", status); return status; } @@ -282,36 +282,36 @@ int st5481_setup_usb(struct st5481_adapter *adapter) return -ENOMEM; } ctrl->urb = urb; - + // Fill the control URB - usb_fill_control_urb (urb, dev, - usb_sndctrlpipe(dev, 0), - NULL, NULL, 0, usb_ctrl_complete, adapter); + usb_fill_control_urb(urb, dev, + usb_sndctrlpipe(dev, 0), + NULL, NULL, 0, usb_ctrl_complete, adapter); + - fifo_init(&ctrl->msg_fifo.f, ARRAY_SIZE(ctrl->msg_fifo.data)); // Allocate URBs and buffers for interrupt endpoint urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) { + if (!urb) { return -ENOMEM; } intr->urb = urb; - + buf = kmalloc(INT_PKT_SIZE, GFP_KERNEL); if (!buf) { return -ENOMEM; } endpoint = &altsetting->endpoint[EP_INT-1]; - + // Fill the interrupt URB usb_fill_int_urb(urb, dev, - usb_rcvintpipe(dev, endpoint->desc.bEndpointAddress), - buf, INT_PKT_SIZE, - usb_int_complete, adapter, - endpoint->desc.bInterval); - + usb_rcvintpipe(dev, endpoint->desc.bEndpointAddress), + buf, INT_PKT_SIZE, + usb_int_complete, adapter, + endpoint->desc.bInterval); + return 0; } @@ -324,7 +324,7 @@ void st5481_release_usb(struct st5481_adapter *adapter) struct st5481_intr *intr = &adapter->intr; struct st5481_ctrl *ctrl = &adapter->ctrl; - DBG(1,""); + DBG(1, ""); // Stop and free Control and Interrupt URBs usb_kill_urb(ctrl->urb); @@ -343,33 +343,33 @@ void st5481_release_usb(struct st5481_adapter *adapter) */ void st5481_start(struct st5481_adapter *adapter) { - static const u8 init_cmd_table[]={ - SET_DEFAULT,0, - STT,0, - SDA_MIN,0x0d, - SDA_MAX,0x29, - SDELAY_VALUE,0x14, - GPIO_DIR,0x01, - GPIO_OUT,RED_LED, + static const u8 init_cmd_table[] = { + SET_DEFAULT, 0, + STT, 0, + SDA_MIN, 0x0d, + SDA_MAX, 0x29, + SDELAY_VALUE, 0x14, + GPIO_DIR, 0x01, + GPIO_OUT, RED_LED, // FFCTRL_OUT_D,4, // FFCTRH_OUT_D,12, - FFCTRL_OUT_B1,6, - FFCTRH_OUT_B1,20, - FFCTRL_OUT_B2,6, - FFCTRH_OUT_B2,20, - MPMSK,RXCI_INT+DEN_INT+DCOLL_INT, + FFCTRL_OUT_B1, 6, + FFCTRH_OUT_B1, 20, + FFCTRL_OUT_B2, 6, + FFCTRH_OUT_B2, 20, + MPMSK, RXCI_INT + DEN_INT + DCOLL_INT, 0 - }; + }; struct st5481_intr *intr = &adapter->intr; int i = 0; - u8 request,value; + u8 request, value; - DBG(8,""); + DBG(8, ""); - adapter->leds = RED_LED; + adapter->leds = RED_LED; // Start receiving on the interrupt endpoint - SUBMIT_URB(intr->urb, GFP_KERNEL); + SUBMIT_URB(intr->urb, GFP_KERNEL); while ((request = init_cmd_table[i++])) { value = init_cmd_table[i++]; @@ -383,7 +383,7 @@ void st5481_start(struct st5481_adapter *adapter) */ void st5481_stop(struct st5481_adapter *adapter) { - DBG(8,""); + DBG(8, ""); st5481_usb_device_ctrl_msg(adapter, SET_DEFAULT, 0, NULL, NULL); } @@ -394,22 +394,22 @@ void st5481_stop(struct st5481_adapter *adapter) static void fill_isoc_urb(struct urb *urb, struct usb_device *dev, - unsigned int pipe, void *buf, int num_packets, + unsigned int pipe, void *buf, int num_packets, int packet_size, usb_complete_t complete, - void *context) + void *context) { int k; - urb->dev=dev; - urb->pipe=pipe; + urb->dev = dev; + urb->pipe = pipe; urb->interval = 1; - urb->transfer_buffer=buf; + urb->transfer_buffer = buf; urb->number_of_packets = num_packets; - urb->transfer_buffer_length=num_packets*packet_size; + urb->transfer_buffer_length = num_packets * packet_size; urb->actual_length = 0; - urb->complete=complete; - urb->context=context; - urb->transfer_flags=URB_ISO_ASAP; + urb->complete = complete; + urb->context = context; + urb->transfer_flags = URB_ISO_ASAP; for (k = 0; k < num_packets; k++) { urb->iso_frame_desc[k].offset = packet_size * k; urb->iso_frame_desc[k].length = packet_size; @@ -418,10 +418,10 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, } int -st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev, - unsigned int pipe, int num_packets, - int packet_size, int buf_size, - usb_complete_t complete, void *context) +st5481_setup_isocpipes(struct urb *urb[2], struct usb_device *dev, + unsigned int pipe, int num_packets, + int packet_size, int buf_size, + usb_complete_t complete, void *context) { int j, retval; unsigned char *buf; @@ -436,15 +436,15 @@ st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev, buf = kmalloc(buf_size, GFP_KERNEL); if (!buf) goto err; - + // Fill the isochronous URB - fill_isoc_urb(urb[j], dev, pipe, buf, + fill_isoc_urb(urb[j], dev, pipe, buf, num_packets, packet_size, complete, context); } return 0; - err: +err: for (j = 0; j < 2; j++) { if (urb[j]) { kfree(urb[j]->transfer_buffer); @@ -456,7 +456,7 @@ st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev, return retval; } -void st5481_release_isocpipes(struct urb* urb[2]) +void st5481_release_isocpipes(struct urb *urb[2]) { int j; @@ -471,8 +471,8 @@ void st5481_release_isocpipes(struct urb* urb[2]) /* * Decode frames received on the B/D channel. * Note that this function will be called continuously - * with 64Kbit/s / 16Kbit/s of data and hence it will be - * called 50 times per second with 20 ISOC descriptors. + * with 64Kbit/s / 16Kbit/s of data and hence it will be + * called 50 times per second with 20 ISOC descriptors. * Called at interrupt. */ static void usb_in_complete(struct urb *urb) @@ -484,18 +484,18 @@ static void usb_in_complete(struct urb *urb) if (unlikely(urb->status < 0)) { switch (urb->status) { - case -ENOENT: - case -ESHUTDOWN: - case -ECONNRESET: - DBG(1,"urb killed status %d", urb->status); - return; // Give up - default: - WARNING("urb status %d",urb->status); - break; + case -ENOENT: + case -ESHUTDOWN: + case -ECONNRESET: + DBG(1, "urb killed status %d", urb->status); + return; // Give up + default: + WARNING("urb status %d", urb->status); + break; } } - DBG_ISO_PACKET(0x80,urb); + DBG_ISO_PACKET(0x80, urb); len = st5481_isoc_flatten(urb); ptr = urb->transfer_buffer; @@ -506,14 +506,14 @@ static void usb_in_complete(struct urb *urb) len = 0; } else { status = isdnhdlc_decode(&in->hdlc_state, ptr, len, &count, - in->rcvbuf, in->bufsize); + in->rcvbuf, in->bufsize); ptr += count; len -= count; } - + if (status > 0) { // Good frame received - DBG(4,"count=%d",status); + DBG(4, "count=%d", status); DBG_PACKET(0x400, in->rcvbuf, status); if (!(skb = dev_alloc_skb(status))) { WARNING("receive out of memory\n"); @@ -542,14 +542,14 @@ int st5481_setup_in(struct st5481_in *in) struct usb_device *dev = in->adapter->usb_dev; int retval; - DBG(4,""); + DBG(4, ""); in->rcvbuf = kmalloc(in->bufsize, GFP_KERNEL); retval = -ENOMEM; if (!in->rcvbuf) goto err; - retval = st5481_setup_isocpipes(in->urb, dev, + retval = st5481_setup_isocpipes(in->urb, dev, usb_rcvisocpipe(dev, in->ep), in->num_packets, in->packet_size, in->num_packets * in->packet_size, @@ -558,51 +558,51 @@ int st5481_setup_in(struct st5481_in *in) goto err_free; return 0; - err_free: +err_free: kfree(in->rcvbuf); - err: +err: return retval; } void st5481_release_in(struct st5481_in *in) { - DBG(2,""); + DBG(2, ""); st5481_release_isocpipes(in->urb); } /* * Make the transfer_buffer contiguous by - * copying from the iso descriptors if necessary. + * copying from the iso descriptors if necessary. */ static int st5481_isoc_flatten(struct urb *urb) { - struct usb_iso_packet_descriptor *pipd,*pend; - unsigned char *src,*dst; + struct usb_iso_packet_descriptor *pipd, *pend; + unsigned char *src, *dst; unsigned int len; - + if (urb->status < 0) { return urb->status; } for (pipd = &urb->iso_frame_desc[0], pend = &urb->iso_frame_desc[urb->number_of_packets], - dst = urb->transfer_buffer; - pipd < pend; + dst = urb->transfer_buffer; + pipd < pend; pipd++) { - + if (pipd->status < 0) { return (pipd->status); } - + len = pipd->actual_length; pipd->actual_length = 0; - src = urb->transfer_buffer+pipd->offset; + src = urb->transfer_buffer + pipd->offset; if (src != dst) { // Need to copy since isoc buffers not full while (len--) { *dst++ = *src++; - } + } } else { // No need to copy, just update destination buffer dst += len; @@ -617,7 +617,7 @@ static void st5481_start_rcv(void *context) struct st5481_in *in = context; struct st5481_adapter *adapter = in->adapter; - DBG(4,""); + DBG(4, ""); in->urb[0]->dev = adapter->usb_dev; SUBMIT_URB(in->urb[0], GFP_KERNEL); @@ -654,4 +654,3 @@ void st5481_in_mode(struct st5481_in *in, int mode) 0, NULL, NULL); } } - diff --git a/drivers/isdn/hisax/tei.c b/drivers/isdn/hisax/tei.c index 9b6db9c92cd8..9195f9fd628f 100644 --- a/drivers/isdn/hisax/tei.c +++ b/drivers/isdn/hisax/tei.c @@ -3,7 +3,7 @@ * Author Karsten Keil * based on the teles driver from Jan den Ouden * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -43,7 +43,7 @@ enum { ST_TEI_IDVERIFY, }; -#define TEI_STATE_COUNT (ST_TEI_IDVERIFY+1) +#define TEI_STATE_COUNT (ST_TEI_IDVERIFY + 1) static char *strTeiState[] = { @@ -62,7 +62,7 @@ enum { EV_T202, }; -#define TEI_EVENT_COUNT (EV_T202+1) +#define TEI_EVENT_COUNT (EV_T202 + 1) static char *strTeiEvent[] = { @@ -130,14 +130,14 @@ tei_id_request(struct FsmInst *fi, int event, void *arg) if (st->l2.tei != -1) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "assign request for already assigned tei %d", - st->l2.tei); + "assign request for already assigned tei %d", + st->l2.tei); return; } st->ma.ri = random_ri(); if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "assign request ri %d", st->ma.ri); + "assign request ri %d", st->ma.ri); put_tei_msg(st, ID_REQUEST, st->ma.ri, 127); FsmChangeState(&st->ma.tei_m, ST_TEI_IDREQ); FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 1); @@ -156,11 +156,11 @@ tei_id_assign(struct FsmInst *fi, int event, void *arg) tei = skb->data[4] >> 1; if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "identity assign ri %d tei %d", ri, tei); + "identity assign ri %d tei %d", ri, tei); if ((ost = findtei(st, tei))) { /* same tei is in use */ if (ri != ost->ma.ri) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "possible duplicate assignment tei %d", tei); + "possible duplicate assignment tei %d", tei); ost->l2.l2tei(ost, MDL_ERROR | RESPONSE, NULL); } } else if (ri == st->ma.ri) { @@ -183,14 +183,14 @@ tei_id_test_dup(struct FsmInst *fi, int event, void *arg) tei = skb->data[4] >> 1; if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "foreign identity assign ri %d tei %d", ri, tei); + "foreign identity assign ri %d tei %d", ri, tei); if ((ost = findtei(st, tei))) { /* same tei is in use */ if (ri != ost->ma.ri) { /* and it wasn't our request */ st->ma.tei_m.printdebug(&st->ma.tei_m, - "possible duplicate assignment tei %d", tei); + "possible duplicate assignment tei %d", tei); FsmEvent(&ost->ma.tei_m, EV_VERIFY, NULL); } - } + } } static void @@ -204,7 +204,7 @@ tei_id_denied(struct FsmInst *fi, int event, void *arg) tei = skb->data[4] >> 1; if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "identity denied ri %d tei %d", ri, tei); + "identity denied ri %d tei %d", ri, tei); } static void @@ -217,7 +217,7 @@ tei_id_chk_req(struct FsmInst *fi, int event, void *arg) tei = skb->data[4] >> 1; if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "identity check req tei %d", tei); + "identity check req tei %d", tei); if ((st->l2.tei != -1) && ((tei == GROUP_TEI) || (tei == st->l2.tei))) { FsmDelTimer(&st->ma.t202, 4); FsmChangeState(&st->ma.tei_m, ST_TEI_NOP); @@ -236,7 +236,7 @@ tei_id_remove(struct FsmInst *fi, int event, void *arg) tei = skb->data[4] >> 1; if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "identity remove tei %d", tei); + "identity remove tei %d", tei); if ((st->l2.tei != -1) && ((tei == GROUP_TEI) || (tei == st->l2.tei))) { FsmDelTimer(&st->ma.t202, 5); FsmChangeState(&st->ma.tei_m, ST_TEI_NOP); @@ -253,7 +253,7 @@ tei_id_verify(struct FsmInst *fi, int event, void *arg) if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "id verify request for tei %d", st->l2.tei); + "id verify request for tei %d", st->l2.tei); put_tei_msg(st, ID_VERIFY, 0, st->l2.tei); FsmChangeState(&st->ma.tei_m, ST_TEI_IDVERIFY); FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 2); @@ -270,8 +270,8 @@ tei_id_req_tout(struct FsmInst *fi, int event, void *arg) st->ma.ri = random_ri(); if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "assign req(%d) ri %d", 4 - st->ma.N202, - st->ma.ri); + "assign req(%d) ri %d", 4 - st->ma.N202, + st->ma.ri); put_tei_msg(st, ID_REQUEST, st->ma.ri, 127); FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 3); } else { @@ -292,13 +292,13 @@ tei_id_ver_tout(struct FsmInst *fi, int event, void *arg) if (--st->ma.N202) { if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "id verify req(%d) for tei %d", - 3 - st->ma.N202, st->l2.tei); + "id verify req(%d) for tei %d", + 3 - st->ma.N202, st->l2.tei); put_tei_msg(st, ID_VERIFY, 0, st->l2.tei); FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 4); } else { st->ma.tei_m.printdebug(&st->ma.tei_m, - "verify req for tei %d failed", st->l2.tei); + "verify req for tei %d failed", st->l2.tei); st->l3.l3l2(st, MDL_REMOVE | REQUEST, NULL); cs = (struct IsdnCardState *) st->l1.hardware; cs->cardmsg(cs, MDL_REMOVE | REQUEST, NULL); @@ -320,25 +320,25 @@ tei_l1l2(struct PStack *st, int pr, void *arg) if (pr == (PH_DATA | INDICATION)) { if (skb->len < 3) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "short mgr frame %ld/3", skb->len); + "short mgr frame %ld/3", skb->len); } else if ((skb->data[0] != ((TEI_SAPI << 2) | 2)) || (skb->data[1] != ((GROUP_TEI << 1) | 1))) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "wrong mgr sapi/tei %x/%x", - skb->data[0], skb->data[1]); + "wrong mgr sapi/tei %x/%x", + skb->data[0], skb->data[1]); } else if ((skb->data[2] & 0xef) != UI) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "mgr frame is not ui %x", skb->data[2]); + "mgr frame is not ui %x", skb->data[2]); } else { skb_pull(skb, 3); if (skb->len < 5) { st->ma.tei_m.printdebug(&st->ma.tei_m, - "short mgr frame %ld/5", skb->len); + "short mgr frame %ld/5", skb->len); } else if (skb->data[0] != TEI_ENTITY_ID) { /* wrong management entity identifier, ignore */ st->ma.tei_m.printdebug(&st->ma.tei_m, - "tei handler wrong entity id %x", - skb->data[0]); + "tei handler wrong entity id %x", + skb->data[0]); } else { mt = skb->data[3]; if (mt == ID_ASSIGNED) @@ -351,13 +351,13 @@ tei_l1l2(struct PStack *st, int pr, void *arg) FsmEvent(&st->ma.tei_m, EV_REMOVE, skb); else { st->ma.tei_m.printdebug(&st->ma.tei_m, - "tei handler wrong mt %x\n", mt); + "tei handler wrong mt %x\n", mt); } } } } else { st->ma.tei_m.printdebug(&st->ma.tei_m, - "tei handler wrong pr %x\n", pr); + "tei handler wrong pr %x\n", pr); } dev_kfree_skb(skb); } @@ -371,7 +371,7 @@ tei_l2tei(struct PStack *st, int pr, void *arg) if (pr == (MDL_ASSIGN | INDICATION)) { if (st->ma.debug) st->ma.tei_m.printdebug(&st->ma.tei_m, - "fixed assign tei %d", st->l2.tei); + "fixed assign tei %d", st->l2.tei); st->l3.l3l2(st, MDL_ASSIGN | REQUEST, (void *) (long) st->l2.tei); cs = (struct IsdnCardState *) st->l1.hardware; cs->cardmsg(cs, MDL_ASSIGN | REQUEST, NULL); @@ -379,14 +379,14 @@ tei_l2tei(struct PStack *st, int pr, void *arg) return; } switch (pr) { - case (MDL_ASSIGN | INDICATION): - FsmEvent(&st->ma.tei_m, EV_IDREQ, arg); - break; - case (MDL_ERROR | REQUEST): - FsmEvent(&st->ma.tei_m, EV_VERIFY, arg); - break; - default: - break; + case (MDL_ASSIGN | INDICATION): + FsmEvent(&st->ma.tei_m, EV_IDREQ, arg); + break; + case (MDL_ERROR | REQUEST): + FsmEvent(&st->ma.tei_m, EV_VERIFY, arg); + break; + default: + break; } } diff --git a/drivers/isdn/hisax/teleint.c b/drivers/isdn/hisax/teleint.c index b0ce4ae45cbf..fa329e27cc5b 100644 --- a/drivers/isdn/hisax/teleint.c +++ b/drivers/isdn/hisax/teleint.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -18,7 +18,7 @@ static const char *TeleInt_revision = "$Revision: 1.16.2.5 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static inline u_char @@ -40,14 +40,14 @@ readreg(unsigned int ale, unsigned int adr, u_char off) } static inline void -readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size) +readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) { register u_char ret; register int max_delay = 20000; register int i; - + byteout(ale, off); - for (i = 0; ihw.hfc.cip = 0; readfifo(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, 0, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { cs->hw.hfc.cip = 0; writefifo(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, 0, data, size); @@ -163,7 +163,7 @@ TeleInt_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); val = readreg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_ISTA); @@ -183,7 +183,7 @@ TeleInt_Timer(struct IsdnCardState *cs) { int stat = 0; u_long flags; - + spin_lock_irqsave(&cs->lock, flags); if (cs->bcs[0].mode) { stat |= 1; @@ -194,7 +194,7 @@ TeleInt_Timer(struct IsdnCardState *cs) main_irq_hfc(&cs->bcs[1]); } spin_unlock_irqrestore(&cs->lock, flags); - stat = HZ/100; + stat = HZ / 100; if (!stat) stat = 1; cs->hw.hfc.timer.expires = jiffies + stat; @@ -229,34 +229,34 @@ TeleInt_card_msg(struct IsdnCardState *cs, int mt, void *arg) int delay; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_TeleInt(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_TeleInt(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - reset_TeleInt(cs); - inithfc(cs); - clear_pending_isac_ints(cs); - initisac(cs); - /* Reenable all IRQ */ - cs->writeisac(cs, ISAC_MASK, 0); - cs->writeisac(cs, ISAC_CMDR, 0x41); - spin_unlock_irqrestore(&cs->lock, flags); - delay = HZ/100; - if (!delay) - delay = 1; - cs->hw.hfc.timer.expires = jiffies + delay; - add_timer(&cs->hw.hfc.timer); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_TeleInt(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_TeleInt(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + reset_TeleInt(cs); + inithfc(cs); + clear_pending_isac_ints(cs); + initisac(cs); + /* Reenable all IRQ */ + cs->writeisac(cs, ISAC_MASK, 0); + cs->writeisac(cs, ISAC_CMDR, 0x41); + spin_unlock_irqrestore(&cs->lock, flags); + delay = HZ / 100; + if (!delay) + delay = 1; + cs->hw.hfc.timer.expires = jiffies + delay; + add_timer(&cs->hw.hfc.timer); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } int __devinit @@ -293,34 +293,34 @@ setup_TeleInt(struct IsdnCard *card) byteout(cs->hw.hfc.addr, cs->hw.hfc.addr & 0xff); byteout(cs->hw.hfc.addr | 1, ((cs->hw.hfc.addr & 0x300) >> 8) | 0x54); switch (cs->irq) { - case 3: - cs->hw.hfc.cirm |= HFC_INTA; - break; - case 4: - cs->hw.hfc.cirm |= HFC_INTB; - break; - case 5: - cs->hw.hfc.cirm |= HFC_INTC; - break; - case 7: - cs->hw.hfc.cirm |= HFC_INTD; - break; - case 10: - cs->hw.hfc.cirm |= HFC_INTE; - break; - case 11: - cs->hw.hfc.cirm |= HFC_INTF; - break; - default: - printk(KERN_WARNING "TeleInt: wrong IRQ\n"); - release_io_TeleInt(cs); - return (0); + case 3: + cs->hw.hfc.cirm |= HFC_INTA; + break; + case 4: + cs->hw.hfc.cirm |= HFC_INTB; + break; + case 5: + cs->hw.hfc.cirm |= HFC_INTC; + break; + case 7: + cs->hw.hfc.cirm |= HFC_INTD; + break; + case 10: + cs->hw.hfc.cirm |= HFC_INTE; + break; + case 11: + cs->hw.hfc.cirm |= HFC_INTF; + break; + default: + printk(KERN_WARNING "TeleInt: wrong IRQ\n"); + release_io_TeleInt(cs); + return (0); } byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.cirm); byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.ctmt); printk(KERN_INFO "TeleInt: defined at 0x%x IRQ %d\n", - cs->hw.hfc.addr, cs->irq); + cs->hw.hfc.addr, cs->irq); setup_isac(cs); cs->readisac = &ReadISAC; diff --git a/drivers/isdn/hisax/teles0.c b/drivers/isdn/hisax/teles0.c index 3ca0bed1b88c..49b4a26f91e0 100644 --- a/drivers/isdn/hisax/teles0.c +++ b/drivers/isdn/hisax/teles0.c @@ -5,7 +5,7 @@ * Author Karsten Keil * based on the teles driver from Jan den Ouden * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -24,7 +24,7 @@ static const char *teles0_revision = "$Revision: 2.15.2.4 $"; #define TELES_IOMEM_SIZE 0x400 -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static inline u_char @@ -55,7 +55,7 @@ writehscx(void __iomem *adr, int hscx, u_char off, u_char data) } static inline void -read_fifo_isac(void __iomem *adr, u_char * data, int size) +read_fifo_isac(void __iomem *adr, u_char *data, int size) { register int i; register u_char __iomem *ad = adr + 0x100; @@ -64,7 +64,7 @@ read_fifo_isac(void __iomem *adr, u_char * data, int size) } static inline void -write_fifo_isac(void __iomem *adr, u_char * data, int size) +write_fifo_isac(void __iomem *adr, u_char *data, int size) { register int i; register u_char __iomem *ad = adr + 0x100; @@ -74,7 +74,7 @@ write_fifo_isac(void __iomem *adr, u_char * data, int size) } static inline void -read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) +read_fifo_hscx(void __iomem *adr, int hscx, u_char *data, int size) { register int i; register u_char __iomem *ad = adr + (hscx ? 0x1c0 : 0x180); @@ -83,7 +83,7 @@ read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) } static inline void -write_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) +write_fifo_hscx(void __iomem *adr, int hscx, u_char *data, int size) { int i; register u_char __iomem *ad = adr + (hscx ? 0x1c0 : 0x180); @@ -107,13 +107,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { read_fifo_isac(cs->hw.teles0.membase, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { write_fifo_isac(cs->hw.teles0.membase, data, size); } @@ -151,11 +151,11 @@ teles0_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readhscx(cs->hw.teles0.membase, 1, HSCX_ISTA); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readisac(cs->hw.teles0.membase, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); count++; @@ -197,33 +197,33 @@ reset_teles0(struct IsdnCardState *cs) if (cs->hw.teles0.cfg_reg) { switch (cs->irq) { - case 2: - case 9: - cfval = 0x00; - break; - case 3: - cfval = 0x02; - break; - case 4: - cfval = 0x04; - break; - case 5: - cfval = 0x06; - break; - case 10: - cfval = 0x08; - break; - case 11: - cfval = 0x0A; - break; - case 12: - cfval = 0x0C; - break; - case 15: - cfval = 0x0E; - break; - default: - return(1); + case 2: + case 9: + cfval = 0x00; + break; + case 3: + cfval = 0x02; + break; + case 4: + cfval = 0x04; + break; + case 5: + cfval = 0x06; + break; + case 10: + cfval = 0x08; + break; + case 11: + cfval = 0x0A; + break; + case 12: + cfval = 0x0C; + break; + case 15: + cfval = 0x0E; + break; + default: + return (1); } cfval |= ((cs->hw.teles0.phymem >> 9) & 0xF0); byteout(cs->hw.teles0.cfg_reg + 4, cfval); @@ -235,7 +235,7 @@ reset_teles0(struct IsdnCardState *cs) HZDELAY(HZ / 5 + 1); writeb(1, cs->hw.teles0.membase + 0x80); mb(); HZDELAY(HZ / 5 + 1); - return(0); + return (0); } static int @@ -244,23 +244,23 @@ Teles_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_teles0(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_teles0(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_teles0(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_teles0(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } int __devinit @@ -283,14 +283,14 @@ setup_teles0(struct IsdnCard *card) if (card->para[1] < 0x10000) { card->para[1] <<= 4; printk(KERN_INFO - "Teles0: membase configured DOSish, assuming 0x%lx\n", + "Teles0: membase configured DOSish, assuming 0x%lx\n", (unsigned long) card->para[1]); } cs->irq = card->para[0]; if (cs->hw.teles0.cfg_reg) { if (!request_region(cs->hw.teles0.cfg_reg, 8, "teles cfg")) { printk(KERN_WARNING - "HiSax: %s config port %x-%x already in use\n", + "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.teles0.cfg_reg, cs->hw.teles0.cfg_reg + 8); @@ -311,8 +311,8 @@ setup_teles0(struct IsdnCard *card) return (0); } val = bytein(cs->hw.teles0.cfg_reg + 2); /* 0x1e=without AB - * 0x1f=with AB - * 0x1c 16.3 ??? + * 0x1f=with AB + * 0x1c 16.3 ??? */ if (val != 0x1e && val != 0x1f) { printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n", @@ -326,10 +326,10 @@ setup_teles0(struct IsdnCard *card) cs->hw.teles0.phymem = card->para[1]; if (!request_mem_region(cs->hw.teles0.phymem, TELES_IOMEM_SIZE, "teles iomem")) { printk(KERN_WARNING - "HiSax: %s memory region %lx-%lx already in use\n", - CardType[card->typ], - cs->hw.teles0.phymem, - cs->hw.teles0.phymem + TELES_IOMEM_SIZE); + "HiSax: %s memory region %lx-%lx already in use\n", + CardType[card->typ], + cs->hw.teles0.phymem, + cs->hw.teles0.phymem + TELES_IOMEM_SIZE); if (cs->hw.teles0.cfg_reg) release_region(cs->hw.teles0.cfg_reg, 8); return (0); @@ -357,7 +357,7 @@ setup_teles0(struct IsdnCard *card) ISACVersion(cs, "Teles0:"); if (HscxVersion(cs, "Teles0:")) { printk(KERN_WARNING - "Teles0: wrong HSCX versions check IO/MEM addresses\n"); + "Teles0: wrong HSCX versions check IO/MEM addresses\n"); release_io_teles0(cs); return (0); } diff --git a/drivers/isdn/hisax/teles3.c b/drivers/isdn/hisax/teles3.c index e9f5bb4cdffa..220b919fafc3 100644 --- a/drivers/isdn/hisax/teles3.c +++ b/drivers/isdn/hisax/teles3.c @@ -4,7 +4,7 @@ * * Author Karsten Keil * Copyright by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -22,7 +22,7 @@ static const char *teles3_revision = "$Revision: 2.19.2.4 $"; -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) static inline u_char @@ -39,13 +39,13 @@ writereg(unsigned int adr, u_char off, u_char data) static inline void -read_fifo(unsigned int adr, u_char * data, int size) +read_fifo(unsigned int adr, u_char *data, int size) { insb(adr, data, size); } static void -write_fifo(unsigned int adr, u_char * data, int size) +write_fifo(unsigned int adr, u_char *data, int size) { outsb(adr, data, size); } @@ -65,13 +65,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { read_fifo(cs->hw.teles3.isacfifo, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { write_fifo(cs->hw.teles3.isacfifo, data, size); } @@ -110,11 +110,11 @@ teles3_interrupt(int intno, void *dev_id) spin_lock_irqsave(&cs->lock, flags); val = readreg(cs->hw.teles3.hscx[1], HSCX_ISTA); - Start_HSCX: +Start_HSCX: if (val) hscx_int_main(cs, val); val = readreg(cs->hw.teles3.isac, ISAC_ISTA); - Start_ISAC: +Start_ISAC: if (val) isac_interrupt(cs, val); count++; @@ -178,33 +178,33 @@ reset_teles3(struct IsdnCardState *cs) if (cs->typ != ISDN_CTYPE_TELESPCMCIA) { if ((cs->hw.teles3.cfg_reg) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA)) { switch (cs->irq) { - case 2: - case 9: - irqcfg = 0x00; - break; - case 3: - irqcfg = 0x02; - break; - case 4: - irqcfg = 0x04; - break; - case 5: - irqcfg = 0x06; - break; - case 10: - irqcfg = 0x08; - break; - case 11: - irqcfg = 0x0A; - break; - case 12: - irqcfg = 0x0C; - break; - case 15: - irqcfg = 0x0E; - break; - default: - return(1); + case 2: + case 9: + irqcfg = 0x00; + break; + case 3: + irqcfg = 0x02; + break; + case 4: + irqcfg = 0x04; + break; + case 5: + irqcfg = 0x06; + break; + case 10: + irqcfg = 0x08; + break; + case 11: + irqcfg = 0x0A; + break; + case 12: + irqcfg = 0x0C; + break; + case 15: + irqcfg = 0x0E; + break; + default: + return (1); } byteout(cs->hw.teles3.cfg_reg + 4, irqcfg); HZDELAY(HZ / 10 + 1); @@ -223,7 +223,7 @@ reset_teles3(struct IsdnCardState *cs) HZDELAY(2); } } - return(0); + return (0); } static int @@ -232,36 +232,36 @@ Teles_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - spin_lock_irqsave(&cs->lock, flags); - reset_teles3(cs); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_RELEASE: - release_io_teles3(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + spin_lock_irqsave(&cs->lock, flags); + reset_teles3(cs); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_RELEASE: + release_io_teles3(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } #ifdef __ISAPNP__ static struct isapnp_device_id teles_ids[] __devinitdata = { { ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2110), - ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2110), + ISAPNP_VENDOR('T', 'A', 'G'), ISAPNP_FUNCTION(0x2110), (unsigned long) "Teles 16.3 PnP" }, { ISAPNP_VENDOR('C', 'T', 'X'), ISAPNP_FUNCTION(0x0), - ISAPNP_VENDOR('C', 'T', 'X'), ISAPNP_FUNCTION(0x0), + ISAPNP_VENDOR('C', 'T', 'X'), ISAPNP_FUNCTION(0x0), (unsigned long) "Creatix 16.3 PnP" }, { ISAPNP_VENDOR('C', 'P', 'Q'), ISAPNP_FUNCTION(0x1002), - ISAPNP_VENDOR('C', 'P', 'Q'), ISAPNP_FUNCTION(0x1002), + ISAPNP_VENDOR('C', 'P', 'Q'), ISAPNP_FUNCTION(0x1002), (unsigned long) "Compaq ISDN S0" }, { 0, } }; @@ -286,22 +286,22 @@ setup_teles3(struct IsdnCard *card) #ifdef __ISAPNP__ if (!card->para[1] && isapnp_present()) { struct pnp_dev *pnp_d; - while(ipid->card_vendor) { + while (ipid->card_vendor) { if ((pnp_c = pnp_find_card(ipid->card_vendor, - ipid->card_device, pnp_c))) { + ipid->card_device, pnp_c))) { pnp_d = NULL; if ((pnp_d = pnp_find_dev(pnp_c, - ipid->vendor, ipid->function, pnp_d))) { + ipid->vendor, ipid->function, pnp_d))) { int err; printk(KERN_INFO "HiSax: %s detected\n", - (char *)ipid->driver_data); + (char *)ipid->driver_data); pnp_disable_dev(pnp_d); err = pnp_activate_dev(pnp_d); - if (err<0) { + if (err < 0) { printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", - __func__, err); - return(0); + __func__, err); + return (0); } card->para[3] = pnp_port_start(pnp_d, 2); card->para[2] = pnp_port_start(pnp_d, 1); @@ -309,9 +309,9 @@ setup_teles3(struct IsdnCard *card) card->para[0] = pnp_irq(pnp_d, 0); if (!card->para[0] || !card->para[1] || !card->para[2]) { printk(KERN_ERR "Teles PnP:some resources are missing %ld/%lx/%lx\n", - card->para[0], card->para[1], card->para[2]); + card->para[0], card->para[1], card->para[2]); pnp_disable_dev(pnp_d); - return(0); + return (0); } break; } else { @@ -320,21 +320,21 @@ setup_teles3(struct IsdnCard *card) } ipid++; pnp_c = NULL; - } + } if (!ipid->card_vendor) { printk(KERN_INFO "Teles PnP: no ISAPnP card found\n"); - return(0); + return (0); } } #endif if (cs->typ == ISDN_CTYPE_16_3) { cs->hw.teles3.cfg_reg = card->para[1]; switch (cs->hw.teles3.cfg_reg) { - case 0x180: - case 0x280: - case 0x380: - cs->hw.teles3.cfg_reg |= 0xc00; - break; + case 0x180: + case 0x280: + case 0x380: + cs->hw.teles3.cfg_reg |= 0xc00; + break; } cs->hw.teles3.isac = cs->hw.teles3.cfg_reg - 0x420; cs->hw.teles3.hscx[0] = cs->hw.teles3.cfg_reg - 0xc20; @@ -374,9 +374,9 @@ setup_teles3(struct IsdnCard *card) if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) { if (!request_region(cs->hw.teles3.cfg_reg, 1, "teles3 cfg")) { printk(KERN_WARNING - "HiSax: %s config port %x already in use\n", - CardType[card->typ], - cs->hw.teles3.cfg_reg); + "HiSax: %s config port %x already in use\n", + CardType[card->typ], + cs->hw.teles3.cfg_reg); return (0); } } else { @@ -385,14 +385,14 @@ setup_teles3(struct IsdnCard *card) "HiSax: %s config port %x-%x already in use\n", CardType[card->typ], cs->hw.teles3.cfg_reg, - cs->hw.teles3.cfg_reg + 8); + cs->hw.teles3.cfg_reg + 8); return (0); } } } if (!request_region(cs->hw.teles3.isac + 32, 32, "HiSax isac")) { printk(KERN_WARNING - "HiSax: %s isac ports %x-%x already in use\n", + "HiSax: %s isac ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.isac + 32, cs->hw.teles3.isac + 64); @@ -407,7 +407,7 @@ setup_teles3(struct IsdnCard *card) } if (!request_region(cs->hw.teles3.hscx[0] + 32, 32, "HiSax hscx A")) { printk(KERN_WARNING - "HiSax: %s hscx A ports %x-%x already in use\n", + "HiSax: %s hscx A ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.hscx[0] + 32, cs->hw.teles3.hscx[0] + 64); @@ -423,7 +423,7 @@ setup_teles3(struct IsdnCard *card) } if (!request_region(cs->hw.teles3.hscx[1] + 32, 32, "HiSax hscx B")) { printk(KERN_WARNING - "HiSax: %s hscx B ports %x-%x already in use\n", + "HiSax: %s hscx B ports %x-%x already in use\n", CardType[cs->typ], cs->hw.teles3.hscx[1] + 32, cs->hw.teles3.hscx[1] + 64); diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index 161a1938552e..bfe94284b0d5 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -1,20 +1,20 @@ /* $Id: teles_cs.c,v 1.1.2.2 2004/01/25 15:07:06 keil Exp $ */ /*====================================================================== - A teles S0 PCMCIA client driver + A teles S0 PCMCIA client driver - Based on skeleton by David Hinds, dhinds@allegro.stanford.edu - Written by Christof Petig, christof.petig@wtal.de - - Also inspired by ELSA PCMCIA driver - by Klaus Lichtenwalder - - Extensions to new hisax_pcmcia by Karsten Keil + Based on skeleton by David Hinds, dhinds@allegro.stanford.edu + Written by Christof Petig, christof.petig@wtal.de - minor changes to be compatible with kernel 2.4.x - by Jan.Schubert@GMX.li + Also inspired by ELSA PCMCIA driver + by Klaus Lichtenwalder -======================================================================*/ + Extensions to new hisax_pcmcia by Karsten Keil + + minor changes to be compatible with kernel 2.4.x + by Jan.Schubert@GMX.li + + ======================================================================*/ #include #include @@ -44,33 +44,33 @@ MODULE_LICENSE("GPL"); static int protocol = 2; /* EURO-ISDN Default */ module_param(protocol, int, 0); -static int teles_cs_config(struct pcmcia_device *link) __devinit ; +static int teles_cs_config(struct pcmcia_device *link) __devinit; static void teles_cs_release(struct pcmcia_device *link); -static void teles_detach(struct pcmcia_device *p_dev) __devexit ; +static void teles_detach(struct pcmcia_device *p_dev) __devexit; typedef struct local_info_t { struct pcmcia_device *p_dev; - int busy; - int cardnr; + int busy; + int cardnr; } local_info_t; static int __devinit teles_probe(struct pcmcia_device *link) { - local_info_t *local; + local_info_t *local; - dev_dbg(&link->dev, "teles_attach()\n"); + dev_dbg(&link->dev, "teles_attach()\n"); - /* Allocate space for private device-specific data */ - local = kzalloc(sizeof(local_info_t), GFP_KERNEL); - if (!local) return -ENOMEM; - local->cardnr = -1; + /* Allocate space for private device-specific data */ + local = kzalloc(sizeof(local_info_t), GFP_KERNEL); + if (!local) return -ENOMEM; + local->cardnr = -1; - local->p_dev = link; - link->priv = local; + local->p_dev = link; + link->priv = local; - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - return teles_cs_config(link); + return teles_cs_config(link); } /* teles_attach */ static void __devexit teles_detach(struct pcmcia_device *link) @@ -111,64 +111,64 @@ static int teles_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data) static int __devinit teles_cs_config(struct pcmcia_device *link) { - int i; - IsdnCard_t icard; - - dev_dbg(&link->dev, "teles_config(0x%p)\n", link); - - i = pcmcia_loop_config(link, teles_cs_configcheck, NULL); - if (i != 0) - goto cs_failed; - - if (!link->irq) - goto cs_failed; - - i = pcmcia_enable_device(link); - if (i != 0) - goto cs_failed; - - icard.para[0] = link->irq; - icard.para[1] = link->resource[0]->start; - icard.protocol = protocol; - icard.typ = ISDN_CTYPE_TELESPCMCIA; - - i = hisax_init_pcmcia(link, &(((local_info_t*)link->priv)->busy), &icard); - if (i < 0) { - printk(KERN_ERR "teles_cs: failed to initialize Teles PCMCIA %d at i/o %#x\n", - i, (unsigned int) link->resource[0]->start); - teles_cs_release(link); - return -ENODEV; - } + int i; + IsdnCard_t icard; + + dev_dbg(&link->dev, "teles_config(0x%p)\n", link); + + i = pcmcia_loop_config(link, teles_cs_configcheck, NULL); + if (i != 0) + goto cs_failed; + + if (!link->irq) + goto cs_failed; + + i = pcmcia_enable_device(link); + if (i != 0) + goto cs_failed; - ((local_info_t*)link->priv)->cardnr = i; - return 0; + icard.para[0] = link->irq; + icard.para[1] = link->resource[0]->start; + icard.protocol = protocol; + icard.typ = ISDN_CTYPE_TELESPCMCIA; + + i = hisax_init_pcmcia(link, &(((local_info_t *)link->priv)->busy), &icard); + if (i < 0) { + printk(KERN_ERR "teles_cs: failed to initialize Teles PCMCIA %d at i/o %#x\n", + i, (unsigned int) link->resource[0]->start); + teles_cs_release(link); + return -ENODEV; + } + + ((local_info_t *)link->priv)->cardnr = i; + return 0; cs_failed: - teles_cs_release(link); - return -ENODEV; + teles_cs_release(link); + return -ENODEV; } /* teles_cs_config */ static void teles_cs_release(struct pcmcia_device *link) { - local_info_t *local = link->priv; + local_info_t *local = link->priv; - dev_dbg(&link->dev, "teles_cs_release(0x%p)\n", link); + dev_dbg(&link->dev, "teles_cs_release(0x%p)\n", link); - if (local) { - if (local->cardnr >= 0) { - /* no unregister function with hisax */ - HiSax_closecard(local->cardnr); + if (local) { + if (local->cardnr >= 0) { + /* no unregister function with hisax */ + HiSax_closecard(local->cardnr); + } } - } - pcmcia_disable_device(link); + pcmcia_disable_device(link); } /* teles_cs_release */ static int teles_suspend(struct pcmcia_device *link) { local_info_t *dev = link->priv; - dev->busy = 1; + dev->busy = 1; return 0; } @@ -177,7 +177,7 @@ static int teles_resume(struct pcmcia_device *link) { local_info_t *dev = link->priv; - dev->busy = 0; + dev->busy = 0; return 0; } diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c index b85ceb3746ce..9c002c9dc771 100644 --- a/drivers/isdn/hisax/telespci.c +++ b/drivers/isdn/hisax/telespci.c @@ -6,7 +6,7 @@ * Karsten Keil * Copyright by Ton van Rosmalen * by Karsten Keil - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -36,9 +36,9 @@ static const char *telespci_revision = "$Revision: 2.23.2.3 $"; #define READ_DATA_HSCX (ZORAN_PO_GID1 | ZORAN_PO_GREG1) #define WRITE_DATA_HSCX (ZORAN_PO_WR | ZORAN_PO_GID1 | ZORAN_PO_GREG1) -#define ZORAN_WAIT_NOBUSY do { \ - portdata = readl(adr + 0x200); \ - } while (portdata & ZORAN_PO_RQ_PEN) +#define ZORAN_WAIT_NOBUSY do { \ + portdata = readl(adr + 0x200); \ + } while (portdata & ZORAN_PO_RQ_PEN) static inline u_char readisac(void __iomem *adr, u_char off) @@ -46,15 +46,15 @@ readisac(void __iomem *adr, u_char off) register unsigned int portdata; ZORAN_WAIT_NOBUSY; - + /* set address for ISAC */ writel(WRITE_ADDR_ISAC | off, adr + 0x200); ZORAN_WAIT_NOBUSY; - + /* read data from ISAC */ writel(READ_DATA_ISAC, adr + 0x200); ZORAN_WAIT_NOBUSY; - return((u_char)(portdata & ZORAN_PO_DMASK)); + return ((u_char)(portdata & ZORAN_PO_DMASK)); } static inline void @@ -63,7 +63,7 @@ writeisac(void __iomem *adr, u_char off, u_char data) register unsigned int portdata; ZORAN_WAIT_NOBUSY; - + /* set address for ISAC */ writel(WRITE_ADDR_ISAC | off, adr + 0x200); ZORAN_WAIT_NOBUSY; @@ -80,9 +80,9 @@ readhscx(void __iomem *adr, int hscx, u_char off) ZORAN_WAIT_NOBUSY; /* set address for HSCX */ - writel(WRITE_ADDR_HSCX | ((hscx ? 0x40:0) + off), adr + 0x200); + writel(WRITE_ADDR_HSCX | ((hscx ? 0x40 : 0) + off), adr + 0x200); ZORAN_WAIT_NOBUSY; - + /* read data from HSCX */ writel(READ_DATA_HSCX, adr + 0x200); ZORAN_WAIT_NOBUSY; @@ -96,7 +96,7 @@ writehscx(void __iomem *adr, int hscx, u_char off, u_char data) ZORAN_WAIT_NOBUSY; /* set address for HSCX */ - writel(WRITE_ADDR_HSCX | ((hscx ? 0x40:0) + off), adr + 0x200); + writel(WRITE_ADDR_HSCX | ((hscx ? 0x40 : 0) + off), adr + 0x200); ZORAN_WAIT_NOBUSY; /* write data to HSCX */ @@ -105,7 +105,7 @@ writehscx(void __iomem *adr, int hscx, u_char off, u_char data) } static inline void -read_fifo_isac(void __iomem *adr, u_char * data, int size) +read_fifo_isac(void __iomem *adr, u_char *data, int size) { register unsigned int portdata; register int i; @@ -123,7 +123,7 @@ read_fifo_isac(void __iomem *adr, u_char * data, int size) } static void -write_fifo_isac(void __iomem *adr, u_char * data, int size) +write_fifo_isac(void __iomem *adr, u_char *data, int size) { register unsigned int portdata; register int i; @@ -140,7 +140,7 @@ write_fifo_isac(void __iomem *adr, u_char * data, int size) } static inline void -read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) +read_fifo_hscx(void __iomem *adr, int hscx, u_char *data, int size) { register unsigned int portdata; register int i; @@ -149,7 +149,7 @@ read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) /* read data from HSCX */ for (i = 0; i < size; i++) { /* set address for HSCX fifo */ - writel(WRITE_ADDR_HSCX |(hscx ? 0x5F:0x1F), adr + 0x200); + writel(WRITE_ADDR_HSCX | (hscx ? 0x5F : 0x1F), adr + 0x200); ZORAN_WAIT_NOBUSY; writel(READ_DATA_HSCX, adr + 0x200); ZORAN_WAIT_NOBUSY; @@ -158,7 +158,7 @@ read_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) } static inline void -write_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) +write_fifo_hscx(void __iomem *adr, int hscx, u_char *data, int size) { unsigned int portdata; register int i; @@ -167,7 +167,7 @@ write_fifo_hscx(void __iomem *adr, int hscx, u_char * data, int size) /* write data to HSCX */ for (i = 0; i < size; i++) { /* set address for HSCX fifo */ - writel(WRITE_ADDR_HSCX |(hscx ? 0x5F:0x1F), adr + 0x200); + writel(WRITE_ADDR_HSCX | (hscx ? 0x5F : 0x1F), adr + 0x200); ZORAN_WAIT_NOBUSY; writel(WRITE_DATA_HSCX | data[i], adr + 0x200); ZORAN_WAIT_NOBUSY; @@ -190,13 +190,13 @@ WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { read_fifo_isac(cs->hw.teles0.membase, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { write_fifo_isac(cs->hw.teles0.membase, data, size); } @@ -267,20 +267,20 @@ TelesPCI_card_msg(struct IsdnCardState *cs, int mt, void *arg) u_long flags; switch (mt) { - case CARD_RESET: - return(0); - case CARD_RELEASE: - release_io_telespci(cs); - return(0); - case CARD_INIT: - spin_lock_irqsave(&cs->lock, flags); - inithscxisac(cs, 3); - spin_unlock_irqrestore(&cs->lock, flags); - return(0); - case CARD_TEST: - return(0); + case CARD_RESET: + return (0); + case CARD_RELEASE: + release_io_telespci(cs); + return (0); + case CARD_INIT: + spin_lock_irqsave(&cs->lock, flags); + inithscxisac(cs, 3); + spin_unlock_irqrestore(&cs->lock, flags); + return (0); + case CARD_TEST: + return (0); } - return(0); + return (0); } static struct pci_dev *dev_tel __devinitdata = NULL; @@ -300,22 +300,22 @@ setup_telespci(struct IsdnCard *card) if (cs->typ != ISDN_CTYPE_TELESPCI) return (0); - if ((dev_tel = hisax_find_pci_device (PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_tel))) { + if ((dev_tel = hisax_find_pci_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_tel))) { if (pci_enable_device(dev_tel)) - return(0); + return (0); cs->irq = dev_tel->irq; if (!cs->irq) { printk(KERN_WARNING "Teles: No IRQ for PCI card found\n"); - return(0); + return (0); } cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0), - PAGE_SIZE); + PAGE_SIZE); printk(KERN_INFO "Found: Zoran, base-address: 0x%llx, irq: 0x%x\n", - (unsigned long long)pci_resource_start(dev_tel, 0), - dev_tel->irq); + (unsigned long long)pci_resource_start(dev_tel, 0), + dev_tel->irq); } else { printk(KERN_WARNING "TelesPCI: No PCI card found\n"); - return(0); + return (0); } /* Initialize Zoran PCI controller */ @@ -346,7 +346,7 @@ setup_telespci(struct IsdnCard *card) ISACVersion(cs, "TelesPCI:"); if (HscxVersion(cs, "TelesPCI:")) { printk(KERN_WARNING - "TelesPCI: wrong HSCX versions check IO/MEM addresses\n"); + "TelesPCI: wrong HSCX versions check IO/MEM addresses\n"); release_io_telespci(cs); return (0); } diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c index e2cfb6f5aa42..0f0d094af85b 100644 --- a/drivers/isdn/hisax/w6692.c +++ b/drivers/isdn/hisax/w6692.c @@ -4,7 +4,7 @@ * * Author Petr Novak * Copyright by Petr Novak - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -69,33 +69,33 @@ static void W6692_new_ph(struct IsdnCardState *cs) { switch (cs->dc.w6692.ph_state) { - case (W_L1CMD_RST): - ph_command(cs, W_L1CMD_DRC); - l1_msg(cs, HW_RESET | INDICATION, NULL); - /* fallthru */ - case (W_L1IND_CD): - l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); - break; - case (W_L1IND_DRD): - l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); - break; - case (W_L1IND_CE): - l1_msg(cs, HW_POWERUP | CONFIRM, NULL); - break; - case (W_L1IND_LD): - l1_msg(cs, HW_RSYNC | INDICATION, NULL); - break; - case (W_L1IND_ARD): - l1_msg(cs, HW_INFO2 | INDICATION, NULL); - break; - case (W_L1IND_AI8): - l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); - break; - case (W_L1IND_AI10): - l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL); - break; - default: - break; + case (W_L1CMD_RST): + ph_command(cs, W_L1CMD_DRC); + l1_msg(cs, HW_RESET | INDICATION, NULL); + /* fallthru */ + case (W_L1IND_CD): + l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL); + break; + case (W_L1IND_DRD): + l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL); + break; + case (W_L1IND_CE): + l1_msg(cs, HW_POWERUP | CONFIRM, NULL); + break; + case (W_L1IND_LD): + l1_msg(cs, HW_RSYNC | INDICATION, NULL); + break; + case (W_L1IND_ARD): + l1_msg(cs, HW_INFO2 | INDICATION, NULL); + break; + case (W_L1IND_AI8): + l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL); + break; + case (W_L1IND_AI10): + l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL); + break; + default: + break; } } @@ -122,11 +122,11 @@ W6692_bh(struct work_struct *work) if (test_and_clear_bit(D_XMTBUFREADY, &cs->event)) DChannel_proc_xmt(cs); /* - if (test_and_clear_bit(D_RX_MON1, &cs->event)) - arcofi_fsm(cs, ARCOFI_RX_END, NULL); - if (test_and_clear_bit(D_TX_MON1, &cs->event)) - arcofi_fsm(cs, ARCOFI_TX_END, NULL); - */ + if (test_and_clear_bit(D_RX_MON1, &cs->event)) + arcofi_fsm(cs, ARCOFI_RX_END, NULL); + if (test_and_clear_bit(D_TX_MON1, &cs->event)) + arcofi_fsm(cs, ARCOFI_TX_END, NULL); +*/ } static void @@ -250,7 +250,7 @@ W6692B_fill_fifo(struct BCState *bcs) count = bcs->tx_skb->len; if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) - debugl1(cs, "W6692B_fill_fifo%s%d", (more ? " ": " last "), count); + debugl1(cs, "W6692B_fill_fifo%s%d", (more ? " " : " last "), count); ptr = bcs->tx_skb->data; skb_pull(bcs->tx_skb, count); @@ -277,7 +277,7 @@ W6692B_interrupt(struct IsdnCardState *cs, u_char bchan) struct sk_buff *skb; int count; - bcs = (cs->bcs->channel == bchan) ? cs->bcs : (cs->bcs+1); + bcs = (cs->bcs->channel == bchan) ? cs->bcs : (cs->bcs + 1); val = cs->BC_Read_Reg(cs, bchan, W_B_EXIR); debugl1(cs, "W6692B chan %d B_EXIR 0x%02X", bchan, val); @@ -322,7 +322,7 @@ W6692B_interrupt(struct IsdnCardState *cs, u_char bchan) r = cs->BC_Read_Reg(cs, bchan, W_B_STAR); if (r & W_B_STAR_RDOV) { if (cs->debug & L1_DEB_WARN) - debugl1(cs, "W6692 B RDOV(RMR) mode=%d",bcs->mode); + debugl1(cs, "W6692 B RDOV(RMR) mode=%d", bcs->mode); cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT); if (bcs->mode != L1_MODE_TRANS) bcs->hw.w6692.rcvidx = 0; @@ -347,7 +347,7 @@ W6692B_interrupt(struct IsdnCardState *cs, u_char bchan) W6692B_fill_fifo(bcs); else { /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. + * restart transmitting the whole frame. */ if (bcs->tx_skb) { skb_push(bcs->tx_skb, bcs->hw.w6692.count); @@ -374,9 +374,9 @@ W6692B_interrupt(struct IsdnCardState *cs, u_char bchan) W6692B_fill_fifo(bcs); return; } else { - if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && - (PACKET_NOACK != bcs->tx_skb->pkt_type)) { - u_long flags; + if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && + (PACKET_NOACK != bcs->tx_skb->pkt_type)) { + u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.w6692.count; spin_unlock_irqrestore(&bcs->aclock, flags); @@ -414,7 +414,7 @@ W6692_interrupt(int intno, void *dev_id) spin_unlock_irqrestore(&cs->lock, flags); return IRQ_NONE; } - StartW6692: +StartW6692: if (cs->debug & L1_DEB_ISAC) debugl1(cs, "W6692 ISTA %x", val); @@ -473,7 +473,7 @@ W6692_interrupt(int intno, void *dev_id) } else schedule_event(cs, D_XMTBUFREADY); } - afterXFR: +afterXFR: if (val & (W_INT_XINT0 | W_INT_XINT1)) { /* XINT0/1 - never */ if (cs->debug & L1_DEB_ISAC) debugl1(cs, "W6692 spurious XINT!"); @@ -564,108 +564,108 @@ W6692_l1hw(struct PStack *st, int pr, void *arg) int val; switch (pr) { - case (PH_DATA | REQUEST): - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - skb_queue_tail(&cs->sq, skb); -#ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA Queued", 0); -#endif - } else { - cs->tx_skb = skb; - cs->tx_cnt = 0; + case (PH_DATA | REQUEST): + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + skb_queue_tail(&cs->sq, skb); #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA", 0); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA Queued", 0); #endif - W6692_fill_fifo(cs); - } - spin_unlock_irqrestore(&cs->lock, flags); - break; - case (PH_PULL | INDICATION): - spin_lock_irqsave(&cs->lock, flags); - if (cs->tx_skb) { - if (cs->debug & L1_DEB_WARN) - debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); - skb_queue_tail(&cs->sq, skb); - spin_unlock_irqrestore(&cs->lock, flags); - break; - } - if (cs->debug & DEB_DLOG_HEX) - LogFrame(cs, skb->data, skb->len); - if (cs->debug & DEB_DLOG_VERBOSE) - dlogframe(cs, skb, 0); + } else { cs->tx_skb = skb; cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ if (cs->debug & L1_DEB_LAPD) - Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); + Logl2Frame(cs, skb, "PH_DATA", 0); #endif W6692_fill_fifo(cs); + } + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | INDICATION): + spin_lock_irqsave(&cs->lock, flags); + if (cs->tx_skb) { + if (cs->debug & L1_DEB_WARN) + debugl1(cs, " l2l1 tx_skb exist this shouldn't happen"); + skb_queue_tail(&cs->sq, skb); spin_unlock_irqrestore(&cs->lock, flags); break; - case (PH_PULL | REQUEST): + } + if (cs->debug & DEB_DLOG_HEX) + LogFrame(cs, skb->data, skb->len); + if (cs->debug & DEB_DLOG_VERBOSE) + dlogframe(cs, skb, 0); + cs->tx_skb = skb; + cs->tx_cnt = 0; #ifdef L2FRAME_DEBUG /* psa */ - if (cs->debug & L1_DEB_LAPD) - debugl1(cs, "-> PH_REQUEST_PULL"); + if (cs->debug & L1_DEB_LAPD) + Logl2Frame(cs, skb, "PH_DATA_PULLED", 0); #endif - if (!cs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (HW_RESET | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) { - ph_command(cs, W_L1CMD_ECK); - spin_unlock_irqrestore(&cs->lock, flags); - } else { - ph_command(cs, W_L1CMD_RST); - cs->dc.w6692.ph_state = W_L1CMD_RST; - spin_unlock_irqrestore(&cs->lock, flags); - W6692_new_ph(cs); - } - break; - case (HW_ENABLE | REQUEST): - spin_lock_irqsave(&cs->lock, flags); + W6692_fill_fifo(cs); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (PH_PULL | REQUEST): +#ifdef L2FRAME_DEBUG /* psa */ + if (cs->debug & L1_DEB_LAPD) + debugl1(cs, "-> PH_REQUEST_PULL"); +#endif + if (!cs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (HW_RESET | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) { ph_command(cs, W_L1CMD_ECK); spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_INFO3 | REQUEST): - spin_lock_irqsave(&cs->lock, flags); - ph_command(cs, W_L1CMD_AR8); + } else { + ph_command(cs, W_L1CMD_RST); + cs->dc.w6692.ph_state = W_L1CMD_RST; spin_unlock_irqrestore(&cs->lock, flags); - break; - case (HW_TESTLOOP | REQUEST): - val = 0; - if (1 & (long) arg) - val |= 0x0c; - if (2 & (long) arg) - val |= 0x3; - /* !!! not implemented yet */ - break; - case (HW_DEACTIVATE | RESPONSE): - skb_queue_purge(&cs->rq); - skb_queue_purge(&cs->sq); - if (cs->tx_skb) { - dev_kfree_skb_any(cs->tx_skb); - cs->tx_skb = NULL; - } - if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) - del_timer(&cs->dbusytimer); - if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) - schedule_event(cs, D_CLEARBUSY); - break; - default: - if (cs->debug & L1_DEB_WARN) - debugl1(cs, "W6692_l1hw unknown %04x", pr); - break; + W6692_new_ph(cs); + } + break; + case (HW_ENABLE | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, W_L1CMD_ECK); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_INFO3 | REQUEST): + spin_lock_irqsave(&cs->lock, flags); + ph_command(cs, W_L1CMD_AR8); + spin_unlock_irqrestore(&cs->lock, flags); + break; + case (HW_TESTLOOP | REQUEST): + val = 0; + if (1 & (long) arg) + val |= 0x0c; + if (2 & (long) arg) + val |= 0x3; + /* !!! not implemented yet */ + break; + case (HW_DEACTIVATE | RESPONSE): + skb_queue_purge(&cs->rq); + skb_queue_purge(&cs->sq); + if (cs->tx_skb) { + dev_kfree_skb_any(cs->tx_skb); + cs->tx_skb = NULL; + } + if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) + del_timer(&cs->dbusytimer); + if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags)) + schedule_event(cs, D_CLEARBUSY); + break; + default: + if (cs->debug & L1_DEB_WARN) + debugl1(cs, "W6692_l1hw unknown %04x", pr); + break; } } @@ -734,17 +734,17 @@ W6692Bmode(struct BCState *bcs, int mode, int bchan) bcs->hw.w6692.bchan = bchan; switch (mode) { - case (L1_MODE_NULL): - cs->BC_Write_Reg(cs, bchan, W_B_MODE, 0); - break; - case (L1_MODE_TRANS): - cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_MMS); - break; - case (L1_MODE_HDLC): - cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_ITF); - cs->BC_Write_Reg(cs, bchan, W_B_ADM1, 0xff); - cs->BC_Write_Reg(cs, bchan, W_B_ADM2, 0xff); - break; + case (L1_MODE_NULL): + cs->BC_Write_Reg(cs, bchan, W_B_MODE, 0); + break; + case (L1_MODE_TRANS): + cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_MMS); + break; + case (L1_MODE_HDLC): + cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_ITF); + cs->BC_Write_Reg(cs, bchan, W_B_ADM1, 0xff); + cs->BC_Write_Reg(cs, bchan, W_B_ADM2, 0xff); + break; } if (mode) cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RRST | @@ -756,59 +756,59 @@ static void W6692_l2l1(struct PStack *st, int pr, void *arg) { struct sk_buff *skb = arg; - struct BCState *bcs = st->l1.bcs; + struct BCState *bcs = st->l1.bcs; u_long flags; switch (pr) { - case (PH_DATA | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - if (bcs->tx_skb) { - skb_queue_tail(&bcs->squeue, skb); - } else { - bcs->tx_skb = skb; - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); - bcs->hw.w6692.count = 0; - bcs->cs->BC_Send_Data(bcs); - } - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | INDICATION): - if (bcs->tx_skb) { - printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n"); - break; - } - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + case (PH_DATA | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + if (bcs->tx_skb) { + skb_queue_tail(&bcs->squeue, skb); + } else { bcs->tx_skb = skb; + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); bcs->hw.w6692.count = 0; bcs->cs->BC_Send_Data(bcs); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - break; - case (PH_PULL | REQUEST): - if (!bcs->tx_skb) { - test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); - } else - test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); - break; - case (PH_ACTIVATE | REQUEST): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); - W6692Bmode(bcs, st->l1.mode, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | REQUEST): - l1_msg_b(st, pr, arg); - break; - case (PH_DEACTIVATE | CONFIRM): - spin_lock_irqsave(&bcs->cs->lock, flags); - test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); - test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); - W6692Bmode(bcs, 0, st->l1.bc); - spin_unlock_irqrestore(&bcs->cs->lock, flags); - st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + } + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | INDICATION): + if (bcs->tx_skb) { + printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n"); break; + } + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); + bcs->tx_skb = skb; + bcs->hw.w6692.count = 0; + bcs->cs->BC_Send_Data(bcs); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + break; + case (PH_PULL | REQUEST): + if (!bcs->tx_skb) { + test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); + } else + test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + break; + case (PH_ACTIVATE | REQUEST): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag); + W6692Bmode(bcs, st->l1.mode, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | REQUEST): + l1_msg_b(st, pr, arg); + break; + case (PH_DEACTIVATE | CONFIRM): + spin_lock_irqsave(&bcs->cs->lock, flags); + test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag); + test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); + W6692Bmode(bcs, 0, st->l1.bc); + spin_unlock_irqrestore(&bcs->cs->lock, flags); + st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL); + break; } } @@ -943,13 +943,13 @@ WriteW6692(struct IsdnCardState *cs, u_char offset, u_char value) } static void -ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) +ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) { insb(cs->hw.w6692.iobase + W_D_RFIFO, data, size); } static void -WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) +WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) { outsb(cs->hw.w6692.iobase + W_D_XFIFO, data, size); } @@ -970,26 +970,26 @@ static int w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg) { switch (mt) { - case CARD_RESET: - resetW6692(cs); - return (0); - case CARD_RELEASE: - cs->writeW6692(cs, W_IMASK, 0xff); - release_region(cs->hw.w6692.iobase, 256); - if (cs->subtyp == W6692_USR) { - cs->writeW6692(cs, W_XDATA, 0x04); - } - return (0); - case CARD_INIT: - initW6692(cs, 3); - return (0); - case CARD_TEST: - return (0); + case CARD_RESET: + resetW6692(cs); + return (0); + case CARD_RELEASE: + cs->writeW6692(cs, W_IMASK, 0xff); + release_region(cs->hw.w6692.iobase, 256); + if (cs->subtyp == W6692_USR) { + cs->writeW6692(cs, W_XDATA, 0x04); + } + return (0); + case CARD_INIT: + initW6692(cs, 3); + return (0); + case CARD_TEST: + return (0); } return (0); } -static int id_idx ; +static int id_idx; static struct pci_dev *dev_w6692 __devinitdata = NULL; @@ -1009,8 +1009,8 @@ setup_w6692(struct IsdnCard *card) while (id_list[id_idx].vendor_id) { dev_w6692 = hisax_find_pci_device(id_list[id_idx].vendor_id, - id_list[id_idx].device_id, - dev_w6692); + id_list[id_idx].device_id, + dev_w6692); if (dev_w6692) { if (pci_enable_device(dev_w6692)) continue; diff --git a/drivers/isdn/hisax/w6692.h b/drivers/isdn/hisax/w6692.h index c79c81e0401f..024b04d33e43 100644 --- a/drivers/isdn/hisax/w6692.h +++ b/drivers/isdn/hisax/w6692.h @@ -4,7 +4,7 @@ * * Author Petr Novak * Copyright by Petr Novak - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -18,11 +18,11 @@ /* B-channel FIFO read/write routines */ -#define READW6692BFIFO(cs,bchan,ptr,count) \ - insb(cs->hw.w6692.iobase+W_B_RFIFO+(bchan?0x40:0),ptr,count) +#define READW6692BFIFO(cs, bchan, ptr, count) \ + insb(cs->hw.w6692.iobase + W_B_RFIFO + (bchan ? 0x40 : 0), ptr, count) -#define WRITEW6692BFIFO(cs,bchan,ptr,count) \ - outsb(cs->hw.w6692.iobase+W_B_XFIFO+(bchan?0x40:0),ptr,count) +#define WRITEW6692BFIFO(cs, bchan, ptr, count) \ + outsb(cs->hw.w6692.iobase + W_B_XFIFO + (bchan ? 0x40 : 0), ptr, count) /* Specifications of W6692 registers */ diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c index 3eb096f0ae1b..2aa2a0e08247 100644 --- a/drivers/isdn/hysdn/boardergo.c +++ b/drivers/isdn/hysdn/boardergo.c @@ -25,7 +25,7 @@ #include "hysdn_defs.h" #include "boardergo.h" -#define byteout(addr,val) outb(val,addr) +#define byteout(addr, val) outb(val, addr) #define bytein(addr) inb(addr) /***************************************************/ @@ -73,7 +73,7 @@ ergo_interrupt(int intno, void *dev_id) static void ergo_irq_bh(struct work_struct *ugli_api) { - hysdn_card * card = container_of(ugli_api, hysdn_card, irq_queue); + hysdn_card *card = container_of(ugli_api, hysdn_card, irq_queue); tErgDpram *dpr; int again; unsigned long flags; @@ -125,7 +125,7 @@ ergo_irq_bh(struct work_struct *ugli_api) /* stop the card (hardware reset) and disable interrupts */ /*********************************************************/ static void -ergo_stopcard(hysdn_card * card) +ergo_stopcard(hysdn_card *card) { unsigned long flags; unsigned char val; @@ -150,7 +150,7 @@ ergo_stopcard(hysdn_card * card) /* enable or disable the cards error log. The event is queued if possible */ /**************************************************************************/ static void -ergo_set_errlog_state(hysdn_card * card, int on) +ergo_set_errlog_state(hysdn_card *card, int on) { unsigned long flags; @@ -180,7 +180,7 @@ ergo_set_errlog_state(hysdn_card * card, int on) static const char TestText[36] = "This Message is filler, why read it"; static int -ergo_testram(hysdn_card * card) +ergo_testram(hysdn_card *card) { tErgDpram *dpr = card->dpram; @@ -212,12 +212,12 @@ ergo_testram(hysdn_card * card) /*****************************************************************************/ static int ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf, - unsigned long offs) + unsigned long offs) { unsigned char *dst; tErgDpram *dpram; int cnt = (BOOT_IMG_SIZE >> 2); /* number of words to move and swap (byte order!) */ - + if (card->debug_flags & LOG_POF_CARD) hysdn_addlog(card, "ERGO: write bootldr offs=0x%lx ", offs); @@ -355,7 +355,7 @@ ergo_waitpofready(struct HYSDN_CARD *card) /* enable the cards interrupt */ byteout(card->iobase + PCI9050_INTR_REG, bytein(card->iobase + PCI9050_INTR_REG) | - (PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1)); + (PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1)); card->irq_enabled = 1; /* we are ready to receive interrupts */ dpr->ToPcFlag = 0; /* reset data indicator */ @@ -363,15 +363,15 @@ ergo_waitpofready(struct HYSDN_CARD *card) dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ spin_unlock_irqrestore(&card->hysdn_lock, flags); - if ((hynet_enable & (1 << card->myid)) - && (i = hysdn_net_create(card))) + if ((hynet_enable & (1 << card->myid)) + && (i = hysdn_net_create(card))) { ergo_stopcard(card); card->state = CARD_STATE_BOOTERR; return (i); } #ifdef CONFIG_HYSDN_CAPI - if((i = hycapi_capi_create(card))) { + if ((i = hycapi_capi_create(card))) { printk(KERN_WARNING "HYSDN: failed to create capi-interface.\n"); } #endif /* CONFIG_HYSDN_CAPI */ @@ -393,7 +393,7 @@ ergo_waitpofready(struct HYSDN_CARD *card) /* Use only during module release. */ /************************************************************************************/ static void -ergo_releasehardware(hysdn_card * card) +ergo_releasehardware(hysdn_card *card) { ergo_stopcard(card); /* first stop the card if not already done */ free_irq(card->irq, card); /* release interrupt */ @@ -410,9 +410,9 @@ ergo_releasehardware(hysdn_card * card) /* Use only during module init. */ /*********************************************************************************/ int -ergo_inithardware(hysdn_card * card) +ergo_inithardware(hysdn_card *card) { - if (!request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN")) + if (!request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN")) return (-1); if (!request_region(card->iobase + PCI9050_USER_IO, 1, "HYSDN")) { release_region(card->iobase + PCI9050_INTR_REG, 1); diff --git a/drivers/isdn/hysdn/boardergo.h b/drivers/isdn/hysdn/boardergo.h index c59422aa8c3f..e99bd81c4034 100644 --- a/drivers/isdn/hysdn/boardergo.h +++ b/drivers/isdn/hysdn/boardergo.h @@ -23,8 +23,8 @@ /* following DPRAM layout copied from OS2-driver boarderg.h */ typedef struct ErgDpram_tag { -/*0000 */ unsigned char ToHyBuf[ERG_TO_HY_BUF_SIZE]; -/*0E00 */ unsigned char ToPcBuf[ERG_TO_PC_BUF_SIZE]; + /*0000 */ unsigned char ToHyBuf[ERG_TO_HY_BUF_SIZE]; + /*0E00 */ unsigned char ToPcBuf[ERG_TO_PC_BUF_SIZE]; /*1C00 */ unsigned char bSoftUart[SIZE_RSV_SOFT_UART]; /* size 0x1B0 */ @@ -37,22 +37,22 @@ typedef struct ErgDpram_tag { /*1DB9 unsigned long ucText[ERRLOG_TEXT_SIZE]; *//* ASCIIZ of len ucTextSize-1 */ /*1DF0 */ -/*1DF0 */ unsigned short volatile ToHyChannel; -/*1DF2 */ unsigned short volatile ToHySize; + /*1DF0 */ unsigned short volatile ToHyChannel; + /*1DF2 */ unsigned short volatile ToHySize; /*1DF4 */ unsigned char volatile ToHyFlag; /* !=0: msg for Hy waiting */ /*1DF5 */ unsigned char volatile ToPcFlag; /* !=0: msg for PC waiting */ -/*1DF6 */ unsigned short volatile ToPcChannel; -/*1DF8 */ unsigned short volatile ToPcSize; + /*1DF6 */ unsigned short volatile ToPcChannel; + /*1DF8 */ unsigned short volatile ToPcSize; /*1DFA */ unsigned char bRes1DBA[0x1E00 - 0x1DFA]; /* 6 bytes */ -/*1E00 */ unsigned char bRestOfEntryTbl[0x1F00 - 0x1E00]; -/*1F00 */ unsigned long TrapTable[62]; + /*1E00 */ unsigned char bRestOfEntryTbl[0x1F00 - 0x1E00]; + /*1F00 */ unsigned long TrapTable[62]; /*1FF8 */ unsigned char bRes1FF8[0x1FFB - 0x1FF8]; /* low part of reset vetor */ -/*1FFB */ unsigned char ToPcIntMetro; + /*1FFB */ unsigned char ToPcIntMetro; /* notes: * - metro has 32-bit boot ram - accessing * ToPcInt and ToHyInt would be the same; @@ -65,13 +65,13 @@ typedef struct ErgDpram_tag { * so E1 side should NOT change this byte * when writing! */ -/*1FFC */ unsigned char volatile ToHyNoDpramErrLog; + /*1FFC */ unsigned char volatile ToHyNoDpramErrLog; /* note: ToHyNoDpramErrLog is used to inform * boot loader, not to use DPRAM based * ErrLog; when DOS driver is rewritten * this becomes obsolete */ -/*1FFD */ unsigned char bRes1FFD; + /*1FFD */ unsigned char bRes1FFD; /*1FFE */ unsigned char ToPcInt; /* E1_intclear; on CHAMP2: E1_intset */ /*1FFF */ unsigned char ToHyInt; @@ -85,16 +85,16 @@ typedef struct ErgDpram_tag { #define PCI9050_INTR_REG 0x4C /* Interrupt register */ #define PCI9050_USER_IO 0x51 /* User I/O register */ - /* bitmask for PCI9050_INTR_REG: */ +/* bitmask for PCI9050_INTR_REG: */ #define PCI9050_INTR_REG_EN1 0x01 /* 1= enable (def.), 0= disable */ #define PCI9050_INTR_REG_POL1 0x02 /* 1= active high (def.), 0= active low */ #define PCI9050_INTR_REG_STAT1 0x04 /* 1= intr. active, 0= intr. not active (def.) */ #define PCI9050_INTR_REG_ENPCI 0x40 /* 1= PCI interrupts enable (def.) */ - /* bitmask for PCI9050_USER_IO: */ +/* bitmask for PCI9050_USER_IO: */ #define PCI9050_USER_IO_EN3 0x02 /* 1= disable , 0= enable (def.) */ #define PCI9050_USER_IO_DIR3 0x04 /* 1= output (def.), 0= input */ #define PCI9050_USER_IO_DAT3 0x08 /* 1= high (def.) , 0= low */ -#define PCI9050_E1_RESET ( PCI9050_USER_IO_DIR3) /* 0x04 */ -#define PCI9050_E1_RUN (PCI9050_USER_IO_DAT3|PCI9050_USER_IO_DIR3) /* 0x0C */ +#define PCI9050_E1_RESET (PCI9050_USER_IO_DIR3) /* 0x04 */ +#define PCI9050_E1_RUN (PCI9050_USER_IO_DAT3 | PCI9050_USER_IO_DIR3) /* 0x0C */ diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c index 6299b06ae009..931f916c9c23 100644 --- a/drivers/isdn/hysdn/hycapi.c +++ b/drivers/isdn/hysdn/hycapi.c @@ -31,9 +31,9 @@ #include "hysdn_defs.h" #include -static char hycapi_revision[]="$Revision: 1.8.6.4 $"; +static char hycapi_revision[] = "$Revision: 1.8.6.4 $"; -unsigned int hycapi_enable = 0xffffffff; +unsigned int hycapi_enable = 0xffffffff; module_param(hycapi_enable, uint, 0); typedef struct _hycapi_appl { @@ -48,18 +48,18 @@ static u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); static inline int _hycapi_appCheck(int app_id, int ctrl_no) { - if((ctrl_no <= 0) || (ctrl_no > CAPI_MAXCONTR) || (app_id <= 0) || + if ((ctrl_no <= 0) || (ctrl_no > CAPI_MAXCONTR) || (app_id <= 0) || (app_id > CAPI_MAXAPPL)) { printk(KERN_ERR "HYCAPI: Invalid request app_id %d for controller %d", app_id, ctrl_no); return -1; } - return ((hycapi_applications[app_id-1].ctrl_mask & (1 << (ctrl_no-1))) != 0); + return ((hycapi_applications[app_id - 1].ctrl_mask & (1 << (ctrl_no-1))) != 0); } /****************************** Kernel-Capi callback reset_ctr -******************************/ +******************************/ static void hycapi_reset_ctr(struct capi_ctr *ctrl) @@ -75,7 +75,7 @@ hycapi_reset_ctr(struct capi_ctr *ctrl) /****************************** Kernel-Capi callback remove_ctr -******************************/ +******************************/ static void hycapi_remove_ctr(struct capi_ctr *ctrl) @@ -85,25 +85,25 @@ hycapi_remove_ctr(struct capi_ctr *ctrl) hysdn_card *card = NULL; #ifdef HYCAPI_PRINTFNAMES printk(KERN_NOTICE "HYCAPI hycapi_remove_ctr\n"); -#endif +#endif cinfo = (hycapictrl_info *)(ctrl->driverdata); - if(!cinfo) { + if (!cinfo) { printk(KERN_ERR "No hycapictrl_info set!"); return; - } + } card = cinfo->card; capi_ctr_suspend_output(ctrl); - for(i=0; icnr-1]) { - kfree_skb(hycapi_applications[i].listen_req[ctrl->cnr-1]); - hycapi_applications[i].listen_req[ctrl->cnr-1] = NULL; + for (i = 0; i < CAPI_MAXAPPL; i++) { + if (hycapi_applications[i].listen_req[ctrl->cnr - 1]) { + kfree_skb(hycapi_applications[i].listen_req[ctrl->cnr - 1]); + hycapi_applications[i].listen_req[ctrl->cnr - 1] = NULL; } } detach_capi_ctr(ctrl); ctrl->driverdata = NULL; kfree(card->hyctrlinfo); - + card->hyctrlinfo = NULL; } @@ -121,7 +121,7 @@ hycapi_sendmsg_internal(struct capi_ctr *ctrl, struct sk_buff *skb) spin_lock_irq(&cinfo->lock); #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_send_message\n"); + printk(KERN_NOTICE "hycapi_send_message\n"); #endif cinfo->skbs[cinfo->in_idx++] = skb; /* add to buffer list */ if (cinfo->in_idx >= HYSDN_MAX_CAPI_SKB) @@ -130,7 +130,7 @@ hycapi_sendmsg_internal(struct capi_ctr *ctrl, struct sk_buff *skb) if (cinfo->sk_count >= HYSDN_MAX_CAPI_SKB) { /* inform upper layers we're full */ printk(KERN_ERR "HYSDN Card%d: CAPI-buffer overrun!\n", - card->myid); + card->myid); capi_ctr_suspend_output(ctrl); } cinfo->tx_skb = skb; @@ -147,7 +147,7 @@ re-register any applications in the private list. ************************************************************/ -static void +static void hycapi_register_internal(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp) { @@ -161,9 +161,9 @@ hycapi_register_internal(struct capi_ctr *ctrl, __u16 appl, __u16 MessageBufferSize = 0; int slen = strlen(ExtFeatureDefaults); #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_register_appl\n"); + printk(KERN_NOTICE "hycapi_register_appl\n"); #endif - MessageBufferSize = rp->level3cnt * rp->datablkcnt * rp->datablklen; + MessageBufferSize = rp->level3cnt * rp->datablkcnt * rp->datablklen; len = CAPI_MSG_BASELEN + 8 + slen + 1; if (!(skb = alloc_skb(len, GFP_ATOMIC))) { @@ -171,18 +171,18 @@ hycapi_register_internal(struct capi_ctr *ctrl, __u16 appl, card->myid); return; } - memcpy(skb_put(skb,sizeof(__u16)), &len, sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u16)), &appl, sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u8)), &_command, sizeof(_command)); - memcpy(skb_put(skb,sizeof(__u8)), &_subcommand, sizeof(_subcommand)); - memcpy(skb_put(skb,sizeof(__u16)), &MessageNumber, sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u16)), &MessageBufferSize, sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u16)), &(rp->level3cnt), sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u16)), &(rp->datablkcnt), sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u16)), &(rp->datablklen), sizeof(__u16)); - memcpy(skb_put(skb,slen), ExtFeatureDefaults, slen); - hycapi_applications[appl-1].ctrl_mask |= (1 << (ctrl->cnr-1)); - hycapi_send_message(ctrl, skb); + memcpy(skb_put(skb, sizeof(__u16)), &len, sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u16)), &appl, sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u8)), &_command, sizeof(_command)); + memcpy(skb_put(skb, sizeof(__u8)), &_subcommand, sizeof(_subcommand)); + memcpy(skb_put(skb, sizeof(__u16)), &MessageNumber, sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u16)), &MessageBufferSize, sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u16)), &(rp->level3cnt), sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u16)), &(rp->datablkcnt), sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u16)), &(rp->datablklen), sizeof(__u16)); + memcpy(skb_put(skb, slen), ExtFeatureDefaults, slen); + hycapi_applications[appl - 1].ctrl_mask |= (1 << (ctrl->cnr - 1)); + hycapi_send_message(ctrl, skb); } /************************************************************ @@ -200,12 +200,12 @@ static void hycapi_restart_internal(struct capi_ctr *ctrl) #ifdef HYCAPI_PRINTFNAMES printk(KERN_WARNING "HYSDN: hycapi_restart_internal"); #endif - for(i=0; icnr) == 1) { - hycapi_register_internal(ctrl, i+1, + for (i = 0; i < CAPI_MAXAPPL; i++) { + if (_hycapi_appCheck(i + 1, ctrl->cnr) == 1) { + hycapi_register_internal(ctrl, i + 1, &hycapi_applications[i].rp); - if(hycapi_applications[i].listen_req[ctrl->cnr-1]) { - skb = skb_copy(hycapi_applications[i].listen_req[ctrl->cnr-1], GFP_ATOMIC); + if (hycapi_applications[i].listen_req[ctrl->cnr - 1]) { + skb = skb_copy(hycapi_applications[i].listen_req[ctrl->cnr - 1], GFP_ATOMIC); hycapi_sendmsg_internal(ctrl, skb); } } @@ -220,35 +220,35 @@ The application is recorded in the internal list. *************************************************************/ static void -hycapi_register_appl(struct capi_ctr *ctrl, __u16 appl, +hycapi_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp) { int MaxLogicalConnections = 0, MaxBDataBlocks = 0, MaxBDataLen = 0; hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata); hysdn_card *card = cinfo->card; int chk = _hycapi_appCheck(appl, ctrl->cnr); - if(chk < 0) { + if (chk < 0) { return; } - if(chk == 1) { + if (chk == 1) { printk(KERN_INFO "HYSDN: apl %d already registered\n", appl); return; } MaxBDataBlocks = rp->datablkcnt > CAPI_MAXDATAWINDOW ? CAPI_MAXDATAWINDOW : rp->datablkcnt; rp->datablkcnt = MaxBDataBlocks; - MaxBDataLen = rp->datablklen < 1024 ? 1024 : rp->datablklen ; + MaxBDataLen = rp->datablklen < 1024 ? 1024 : rp->datablklen; rp->datablklen = MaxBDataLen; - + MaxLogicalConnections = rp->level3cnt; if (MaxLogicalConnections < 0) { - MaxLogicalConnections = card->bchans * -MaxLogicalConnections; + MaxLogicalConnections = card->bchans * -MaxLogicalConnections; } if (MaxLogicalConnections == 0) { MaxLogicalConnections = card->bchans; } - + rp->level3cnt = MaxLogicalConnections; - memcpy(&hycapi_applications[appl-1].rp, + memcpy(&hycapi_applications[appl - 1].rp, rp, sizeof(capi_register_params)); } @@ -279,19 +279,19 @@ static void hycapi_release_internal(struct capi_ctr *ctrl, __u16 appl) card->myid); return; } - memcpy(skb_put(skb,sizeof(__u16)), &len, sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u16)), &appl, sizeof(__u16)); - memcpy(skb_put(skb,sizeof(__u8)), &_command, sizeof(_command)); - memcpy(skb_put(skb,sizeof(__u8)), &_subcommand, sizeof(_subcommand)); - memcpy(skb_put(skb,sizeof(__u16)), &MessageNumber, sizeof(__u16)); - hycapi_send_message(ctrl, skb); - hycapi_applications[appl-1].ctrl_mask &= ~(1 << (ctrl->cnr-1)); + memcpy(skb_put(skb, sizeof(__u16)), &len, sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u16)), &appl, sizeof(__u16)); + memcpy(skb_put(skb, sizeof(__u8)), &_command, sizeof(_command)); + memcpy(skb_put(skb, sizeof(__u8)), &_subcommand, sizeof(_subcommand)); + memcpy(skb_put(skb, sizeof(__u16)), &MessageNumber, sizeof(__u16)); + hycapi_send_message(ctrl, skb); + hycapi_applications[appl - 1].ctrl_mask &= ~(1 << (ctrl->cnr - 1)); } /****************************************************************** hycapi_release_appl -Release the application from the internal list an remove it's +Release the application from the internal list an remove it's registration at controller-level ******************************************************************/ @@ -301,15 +301,15 @@ hycapi_release_appl(struct capi_ctr *ctrl, __u16 appl) int chk; chk = _hycapi_appCheck(appl, ctrl->cnr); - if(chk<0) { + if (chk < 0) { printk(KERN_ERR "HYCAPI: Releasing invalid appl %d on controller %d\n", appl, ctrl->cnr); return; } - if(hycapi_applications[appl-1].listen_req[ctrl->cnr-1]) { - kfree_skb(hycapi_applications[appl-1].listen_req[ctrl->cnr-1]); - hycapi_applications[appl-1].listen_req[ctrl->cnr-1] = NULL; + if (hycapi_applications[appl - 1].listen_req[ctrl->cnr - 1]) { + kfree_skb(hycapi_applications[appl - 1].listen_req[ctrl->cnr - 1]); + hycapi_applications[appl - 1].listen_req[ctrl->cnr - 1] = NULL; } - if(chk == 1) + if (chk == 1) { hycapi_release_internal(ctrl, appl); } @@ -327,7 +327,7 @@ int hycapi_capi_release(hysdn_card *card) #ifdef HYCAPI_PRINTFNAMES printk(KERN_NOTICE "hycapi_capi_release\n"); #endif - if(cinfo) { + if (cinfo) { ctrl = &cinfo->capi_ctrl; hycapi_remove_ctr(ctrl); } @@ -347,7 +347,7 @@ int hycapi_capi_stop(hysdn_card *card) #ifdef HYCAPI_PRINTFNAMES printk(KERN_NOTICE "hycapi_capi_stop\n"); #endif - if(cinfo) { + if (cinfo) { ctrl = &cinfo->capi_ctrl; /* ctrl->suspend_output(ctrl); */ capi_ctr_down(ctrl); @@ -377,59 +377,59 @@ static u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) u16 retval = CAPI_NOERROR; appl_id = CAPIMSG_APPID(skb->data); - switch(_hycapi_appCheck(appl_id, ctrl->cnr)) + switch (_hycapi_appCheck(appl_id, ctrl->cnr)) { - case 0: + case 0: /* printk(KERN_INFO "Need to register\n"); */ - hycapi_register_internal(ctrl, - appl_id, - &(hycapi_applications[appl_id-1].rp)); - break; - case 1: - break; - default: - printk(KERN_ERR "HYCAPI: Controller mixup!\n"); - retval = CAPI_ILLAPPNR; - goto out; + hycapi_register_internal(ctrl, + appl_id, + &(hycapi_applications[appl_id - 1].rp)); + break; + case 1: + break; + default: + printk(KERN_ERR "HYCAPI: Controller mixup!\n"); + retval = CAPI_ILLAPPNR; + goto out; } - switch(CAPIMSG_CMD(skb->data)) { - case CAPI_DISCONNECT_B3_RESP: - capilib_free_ncci(&cinfo->ncci_head, appl_id, - CAPIMSG_NCCI(skb->data)); - break; - case CAPI_DATA_B3_REQ: - _len = CAPIMSG_LEN(skb->data); - if (_len > 22) { - _len2 = _len - 22; - skb_copy_from_linear_data(skb, msghead, 22); - skb_copy_to_linear_data_offset(skb, _len2, - msghead, 22); - skb_pull(skb, _len2); - CAPIMSG_SETLEN(skb->data, 22); - retval = capilib_data_b3_req(&cinfo->ncci_head, - CAPIMSG_APPID(skb->data), - CAPIMSG_NCCI(skb->data), - CAPIMSG_MSGID(skb->data)); - } - break; - case CAPI_LISTEN_REQ: - if(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1]) - { - kfree_skb(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1]); - hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1] = NULL; - } - if (!(hycapi_applications[appl_id-1].listen_req[ctrl->cnr-1] = skb_copy(skb, GFP_ATOMIC))) - { - printk(KERN_ERR "HYSDN: memory squeeze in private_listen\n"); - } - break; - default: - break; + switch (CAPIMSG_CMD(skb->data)) { + case CAPI_DISCONNECT_B3_RESP: + capilib_free_ncci(&cinfo->ncci_head, appl_id, + CAPIMSG_NCCI(skb->data)); + break; + case CAPI_DATA_B3_REQ: + _len = CAPIMSG_LEN(skb->data); + if (_len > 22) { + _len2 = _len - 22; + skb_copy_from_linear_data(skb, msghead, 22); + skb_copy_to_linear_data_offset(skb, _len2, + msghead, 22); + skb_pull(skb, _len2); + CAPIMSG_SETLEN(skb->data, 22); + retval = capilib_data_b3_req(&cinfo->ncci_head, + CAPIMSG_APPID(skb->data), + CAPIMSG_NCCI(skb->data), + CAPIMSG_MSGID(skb->data)); + } + break; + case CAPI_LISTEN_REQ: + if (hycapi_applications[appl_id - 1].listen_req[ctrl->cnr - 1]) + { + kfree_skb(hycapi_applications[appl_id - 1].listen_req[ctrl->cnr - 1]); + hycapi_applications[appl_id - 1].listen_req[ctrl->cnr - 1] = NULL; + } + if (!(hycapi_applications[appl_id -1].listen_req[ctrl->cnr - 1] = skb_copy(skb, GFP_ATOMIC))) + { + printk(KERN_ERR "HYSDN: memory squeeze in private_listen\n"); + } + break; + default: + break; } - out: +out: if (retval == CAPI_NOERROR) hycapi_sendmsg_internal(ctrl, skb); - else + else dev_kfree_skb_any(skb); return retval; @@ -445,14 +445,14 @@ static int hycapi_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "name", cinfo->cardname); seq_printf(m, "%-16s 0x%x\n", "io", card->iobase); seq_printf(m, "%-16s %d\n", "irq", card->irq); - + switch (card->brdtype) { - case BD_PCCARD: s = "HYSDN Hycard"; break; - case BD_ERGO: s = "HYSDN Ergo2"; break; - case BD_METRO: s = "HYSDN Metro4"; break; - case BD_CHAMP2: s = "HYSDN Champ2"; break; - case BD_PLEXUS: s = "HYSDN Plexus30"; break; - default: s = "???"; break; + case BD_PCCARD: s = "HYSDN Hycard"; break; + case BD_ERGO: s = "HYSDN Ergo2"; break; + case BD_METRO: s = "HYSDN Metro4"; break; + case BD_CHAMP2: s = "HYSDN Champ2"; break; + case BD_PLEXUS: s = "HYSDN Plexus30"; break; + default: s = "???"; break; } seq_printf(m, "%-16s %s\n", "type", s); if ((s = cinfo->version[VER_DRIVER]) != NULL) @@ -461,9 +461,9 @@ static int hycapi_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "ver_cardtype", s); if ((s = cinfo->version[VER_SERIAL]) != NULL) seq_printf(m, "%-16s %s\n", "ver_serial", s); - + seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname); - + return 0; } @@ -491,7 +491,7 @@ on capi-interface registration. static int hycapi_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) { #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_load_firmware\n"); + printk(KERN_NOTICE "hycapi_load_firmware\n"); #endif return 0; } @@ -501,7 +501,7 @@ static char *hycapi_procinfo(struct capi_ctr *ctrl) { hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata); #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_proc_info\n"); + printk(KERN_NOTICE "hycapi_proc_info\n"); #endif if (!cinfo) return ""; @@ -525,7 +525,7 @@ New nccis are created if necessary. *******************************************************************/ void -hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len) +hycapi_rx_capipkt(hysdn_card *card, unsigned char *buf, unsigned short len) { struct sk_buff *skb; hycapictrl_info *cinfo = card->hyctrlinfo; @@ -533,24 +533,24 @@ hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len) __u16 ApplId; __u16 MsgLen, info; __u16 len2, CapiCmd; - __u32 CP64[2] = {0,0}; + __u32 CP64[2] = {0, 0}; #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_rx_capipkt\n"); + printk(KERN_NOTICE "hycapi_rx_capipkt\n"); #endif - if(!cinfo) { + if (!cinfo) { return; } ctrl = &cinfo->capi_ctrl; - if(len < CAPI_MSG_BASELEN) { + if (len < CAPI_MSG_BASELEN) { printk(KERN_ERR "HYSDN Card%d: invalid CAPI-message, length %d!\n", card->myid, len); return; - } + } MsgLen = CAPIMSG_LEN(buf); ApplId = CAPIMSG_APPID(buf); CapiCmd = CAPIMSG_CMD(buf); - - if((CapiCmd == CAPI_DATA_B3_IND) && (MsgLen < 30)) { + + if ((CapiCmd == CAPI_DATA_B3_IND) && (MsgLen < 30)) { len2 = len + (30 - MsgLen); if (!(skb = alloc_skb(len2, GFP_ATOMIC))) { printk(KERN_ERR "HYSDN Card%d: incoming packet dropped\n", @@ -558,7 +558,7 @@ hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len) return; } memcpy(skb_put(skb, MsgLen), buf, MsgLen); - memcpy(skb_put(skb, 2*sizeof(__u32)), CP64, 2* sizeof(__u32)); + memcpy(skb_put(skb, 2 * sizeof(__u32)), CP64, 2 * sizeof(__u32)); memcpy(skb_put(skb, len - MsgLen), buf + MsgLen, len - MsgLen); CAPIMSG_SETLEN(skb->data, 30); @@ -570,54 +570,54 @@ hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len) } memcpy(skb_put(skb, len), buf, len); } - switch(CAPIMSG_CMD(skb->data)) + switch (CAPIMSG_CMD(skb->data)) { - case CAPI_CONNECT_B3_CONF: + case CAPI_CONNECT_B3_CONF: /* Check info-field for error-indication: */ - info = CAPIMSG_U16(skb->data, 12); - switch(info) - { - case 0: - capilib_new_ncci(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data), - hycapi_applications[ApplId-1].rp.datablkcnt); - - break; - case 0x0001: - printk(KERN_ERR "HYSDN Card%d: NCPI not supported by current " - "protocol. NCPI ignored.\n", card->myid); - break; - case 0x2001: - printk(KERN_ERR "HYSDN Card%d: Message not supported in" - " current state\n", card->myid); - break; - case 0x2002: - printk(KERN_ERR "HYSDN Card%d: invalid PLCI\n", card->myid); - break; - case 0x2004: - printk(KERN_ERR "HYSDN Card%d: out of NCCI\n", card->myid); - break; - case 0x3008: - printk(KERN_ERR "HYSDN Card%d: NCPI not supported\n", - card->myid); - break; - default: - printk(KERN_ERR "HYSDN Card%d: Info in CONNECT_B3_CONF: %d\n", - card->myid, info); - break; - } + info = CAPIMSG_U16(skb->data, 12); + switch (info) + { + case 0: + capilib_new_ncci(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data), + hycapi_applications[ApplId - 1].rp.datablkcnt); + + break; + case 0x0001: + printk(KERN_ERR "HYSDN Card%d: NCPI not supported by current " + "protocol. NCPI ignored.\n", card->myid); break; - case CAPI_CONNECT_B3_IND: - capilib_new_ncci(&cinfo->ncci_head, ApplId, - CAPIMSG_NCCI(skb->data), - hycapi_applications[ApplId-1].rp.datablkcnt); + case 0x2001: + printk(KERN_ERR "HYSDN Card%d: Message not supported in" + " current state\n", card->myid); break; - case CAPI_DATA_B3_CONF: - capilib_data_b3_conf(&cinfo->ncci_head, ApplId, - CAPIMSG_NCCI(skb->data), - CAPIMSG_MSGID(skb->data)); + case 0x2002: + printk(KERN_ERR "HYSDN Card%d: invalid PLCI\n", card->myid); + break; + case 0x2004: + printk(KERN_ERR "HYSDN Card%d: out of NCCI\n", card->myid); + break; + case 0x3008: + printk(KERN_ERR "HYSDN Card%d: NCPI not supported\n", + card->myid); break; default: + printk(KERN_ERR "HYSDN Card%d: Info in CONNECT_B3_CONF: %d\n", + card->myid, info); break; + } + break; + case CAPI_CONNECT_B3_IND: + capilib_new_ncci(&cinfo->ncci_head, ApplId, + CAPIMSG_NCCI(skb->data), + hycapi_applications[ApplId - 1].rp.datablkcnt); + break; + case CAPI_DATA_B3_CONF: + capilib_data_b3_conf(&cinfo->ncci_head, ApplId, + CAPIMSG_NCCI(skb->data), + CAPIMSG_MSGID(skb->data)); + break; + default: + break; } capi_ctr_handle_message(ctrl, ApplId, skb); } @@ -630,13 +630,13 @@ internal queue. *******************************************************************/ -void hycapi_tx_capiack(hysdn_card * card) +void hycapi_tx_capiack(hysdn_card *card) { hycapictrl_info *cinfo = card->hyctrlinfo; #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_tx_capiack\n"); + printk(KERN_NOTICE "hycapi_tx_capiack\n"); #endif - if(!cinfo) { + if (!cinfo) { return; } spin_lock_irq(&cinfo->lock); @@ -661,7 +661,7 @@ struct sk_buff * hycapi_tx_capiget(hysdn_card *card) { hycapictrl_info *cinfo = card->hyctrlinfo; - if(!cinfo) { + if (!cinfo) { return (struct sk_buff *)NULL; } if (!cinfo->sk_count) @@ -681,10 +681,10 @@ attach the capi-driver to the kernel-capi. int hycapi_init(void) { int i; - for(i=0;ihyctrlinfo; - if(!cinfo) return; + if (!cinfo) return; ctrl = &cinfo->capi_ctrl; - strcpy(ctrl->manu, "Hypercope"); + strcpy(ctrl->manu, "Hypercope"); ctrl->version.majorversion = 2; ctrl->version.minorversion = 0; ctrl->version.majormanuversion = 3; @@ -732,18 +732,18 @@ static void hycapi_fill_profile(hysdn_card *card) (card->faxchans ? B3_PROT_T30 : 0) | (card->faxchans ? B3_PROT_T30EXT : 0) | B3_PROT_ISO8208; -} +} -int +int hycapi_capi_create(hysdn_card *card) { hycapictrl_info *cinfo = NULL; struct capi_ctr *ctrl = NULL; int retval; #ifdef HYCAPI_PRINTFNAMES - printk(KERN_NOTICE "hycapi_capi_create\n"); + printk(KERN_NOTICE "hycapi_capi_create\n"); #endif - if((hycapi_enable & (1 << card->myid)) == 0) { + if ((hycapi_enable & (1 << card->myid)) == 0) { return 1; } if (!card->hyctrlinfo) { @@ -758,12 +758,12 @@ hycapi_capi_create(hysdn_card *card) INIT_LIST_HEAD(&cinfo->ncci_head); switch (card->brdtype) { - case BD_PCCARD: strcpy(cinfo->cardname,"HYSDN Hycard"); break; - case BD_ERGO: strcpy(cinfo->cardname,"HYSDN Ergo2"); break; - case BD_METRO: strcpy(cinfo->cardname,"HYSDN Metro4"); break; - case BD_CHAMP2: strcpy(cinfo->cardname,"HYSDN Champ2"); break; - case BD_PLEXUS: strcpy(cinfo->cardname,"HYSDN Plexus30"); break; - default: strcpy(cinfo->cardname,"HYSDN ???"); break; + case BD_PCCARD: strcpy(cinfo->cardname, "HYSDN Hycard"); break; + case BD_ERGO: strcpy(cinfo->cardname, "HYSDN Ergo2"); break; + case BD_METRO: strcpy(cinfo->cardname, "HYSDN Metro4"); break; + case BD_CHAMP2: strcpy(cinfo->cardname, "HYSDN Champ2"); break; + case BD_PLEXUS: strcpy(cinfo->cardname, "HYSDN Plexus30"); break; + default: strcpy(cinfo->cardname, "HYSDN ???"); break; } ctrl = &cinfo->capi_ctrl; @@ -792,7 +792,7 @@ hycapi_capi_create(hysdn_card *card) ctrl = &card->hyctrlinfo->capi_ctrl; hycapi_fill_profile(card); capi_ctr_ready(ctrl); - hycapi_restart_internal(ctrl); + hycapi_restart_internal(ctrl); /* ctrl->resume_output(ctrl); */ } return 0; diff --git a/drivers/isdn/hysdn/hysdn_boot.c b/drivers/isdn/hysdn/hysdn_boot.c index 4f541ef14f9e..eda4741e3f2f 100644 --- a/drivers/isdn/hysdn/hysdn_boot.c +++ b/drivers/isdn/hysdn/hysdn_boot.c @@ -82,7 +82,7 @@ DecryptBuf(struct boot_data *boot, int cnt) /* id. If successful 0 is returned, a negative value shows an error. */ /********************************************************************************/ static int -pof_handle_data(hysdn_card * card, int datlen) +pof_handle_data(hysdn_card *card, int datlen) { struct boot_data *boot = card->boot; /* pointer to boot specific data */ long l; @@ -92,71 +92,71 @@ pof_handle_data(hysdn_card * card, int datlen) /* handle the different record types */ switch (boot->pof_recid) { - case TAG_TIMESTMP: - if (card->debug_flags & LOG_POF_RECORD) - hysdn_addlog(card, "POF created %s", boot->buf.PofTime.DateTimeText); - break; + case TAG_TIMESTMP: + if (card->debug_flags & LOG_POF_RECORD) + hysdn_addlog(card, "POF created %s", boot->buf.PofTime.DateTimeText); + break; + + case TAG_CBOOTDTA: + DecryptBuf(boot, datlen); /* we need to encrypt the buffer */ + case TAG_BOOTDTA: + if (card->debug_flags & LOG_POF_RECORD) + hysdn_addlog(card, "POF got %s len=%d offs=0x%lx", + (boot->pof_recid == TAG_CBOOTDTA) ? "CBOOTDATA" : "BOOTDTA", + datlen, boot->pof_recoffset); + + if (boot->pof_reclen != POF_BOOT_LOADER_TOTAL_SIZE) { + boot->last_error = EPOF_BAD_IMG_SIZE; /* invalid length */ + return (boot->last_error); + } + imgp = boot->buf.BootBuf; /* start of buffer */ + img_len = datlen; /* maximum length to transfer */ + + l = POF_BOOT_LOADER_OFF_IN_PAGE - + (boot->pof_recoffset & (POF_BOOT_LOADER_PAGE_SIZE - 1)); + if (l > 0) { + /* buffer needs to be truncated */ + imgp += l; /* advance pointer */ + img_len -= l; /* adjust len */ + } + /* at this point no special handling for data wrapping over buffer */ + /* is necessary, because the boot image always will be adjusted to */ + /* match a page boundary inside the buffer. */ + /* The buffer for the boot image on the card is filled in 2 cycles */ + /* first the 1024 hi-words are put in the buffer, then the low 1024 */ + /* word are handled in the same way with different offset. */ + + if (img_len > 0) { + /* data available for copy */ + if ((boot->last_error = + card->writebootimg(card, imgp, + (boot->pof_recoffset > POF_BOOT_LOADER_PAGE_SIZE) ? 2 : 0)) < 0) + return (boot->last_error); + } + break; /* end of case boot image hi/lo */ - case TAG_CBOOTDTA: - DecryptBuf(boot, datlen); /* we need to encrypt the buffer */ - case TAG_BOOTDTA: - if (card->debug_flags & LOG_POF_RECORD) - hysdn_addlog(card, "POF got %s len=%d offs=0x%lx", - (boot->pof_recid == TAG_CBOOTDTA) ? "CBOOTDATA" : "BOOTDTA", - datlen, boot->pof_recoffset); + case TAG_CABSDATA: + DecryptBuf(boot, datlen); /* we need to encrypt the buffer */ + case TAG_ABSDATA: + if (card->debug_flags & LOG_POF_RECORD) + hysdn_addlog(card, "POF got %s len=%d offs=0x%lx", + (boot->pof_recid == TAG_CABSDATA) ? "CABSDATA" : "ABSDATA", + datlen, boot->pof_recoffset); - if (boot->pof_reclen != POF_BOOT_LOADER_TOTAL_SIZE) { - boot->last_error = EPOF_BAD_IMG_SIZE; /* invalid length */ - return (boot->last_error); - } - imgp = boot->buf.BootBuf; /* start of buffer */ - img_len = datlen; /* maximum length to transfer */ - - l = POF_BOOT_LOADER_OFF_IN_PAGE - - (boot->pof_recoffset & (POF_BOOT_LOADER_PAGE_SIZE - 1)); - if (l > 0) { - /* buffer needs to be truncated */ - imgp += l; /* advance pointer */ - img_len -= l; /* adjust len */ - } - /* at this point no special handling for data wrapping over buffer */ - /* is necessary, because the boot image always will be adjusted to */ - /* match a page boundary inside the buffer. */ - /* The buffer for the boot image on the card is filled in 2 cycles */ - /* first the 1024 hi-words are put in the buffer, then the low 1024 */ - /* word are handled in the same way with different offset. */ - - if (img_len > 0) { - /* data available for copy */ - if ((boot->last_error = - card->writebootimg(card, imgp, - (boot->pof_recoffset > POF_BOOT_LOADER_PAGE_SIZE) ? 2 : 0)) < 0) - return (boot->last_error); - } - break; /* end of case boot image hi/lo */ - - case TAG_CABSDATA: - DecryptBuf(boot, datlen); /* we need to encrypt the buffer */ - case TAG_ABSDATA: - if (card->debug_flags & LOG_POF_RECORD) - hysdn_addlog(card, "POF got %s len=%d offs=0x%lx", - (boot->pof_recid == TAG_CABSDATA) ? "CABSDATA" : "ABSDATA", - datlen, boot->pof_recoffset); - - if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen)) < 0) - return (boot->last_error); /* error writing data */ - - if (boot->pof_recoffset + datlen >= boot->pof_reclen) - return (card->waitpofready(card)); /* data completely spooled, wait for ready */ - - break; /* end of case boot seq data */ + if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen)) < 0) + return (boot->last_error); /* error writing data */ - default: - if (card->debug_flags & LOG_POF_RECORD) - hysdn_addlog(card, "POF got data(id=0x%lx) len=%d offs=0x%lx", boot->pof_recid, - datlen, boot->pof_recoffset); + if (boot->pof_recoffset + datlen >= boot->pof_reclen) + return (card->waitpofready(card)); /* data completely spooled, wait for ready */ + + break; /* end of case boot seq data */ + + default: + if (card->debug_flags & LOG_POF_RECORD) + hysdn_addlog(card, "POF got data(id=0x%lx) len=%d offs=0x%lx", boot->pof_recid, + datlen, boot->pof_recoffset); - break; /* simply skip record */ + break; /* simply skip record */ } /* switch boot->pof_recid */ return (0); @@ -171,7 +171,7 @@ pof_handle_data(hysdn_card * card, int datlen) /* occurred and booting must be aborted. */ /******************************************************************************/ int -pof_write_buffer(hysdn_card * card, int datlen) +pof_write_buffer(hysdn_card *card, int datlen) { struct boot_data *boot = card->boot; /* pointer to boot specific data */ @@ -184,77 +184,77 @@ pof_write_buffer(hysdn_card * card, int datlen) hysdn_addlog(card, "POF write: got %d bytes ", datlen); switch (boot->pof_state) { - case POF_READ_FILE_HEAD: - if (card->debug_flags & LOG_POF_WRITE) - hysdn_addlog(card, "POF write: checking file header"); - - if (datlen != sizeof(tPofFileHdr)) { - boot->last_error = -EPOF_INTERNAL; - break; - } - if (boot->buf.PofFileHdr.Magic != TAGFILEMAGIC) { - boot->last_error = -EPOF_BAD_MAGIC; - break; - } - /* Setup the new state and vars */ - boot->Nrecs = (unsigned short)(boot->buf.PofFileHdr.N_PofRecs); /* limited to 65535 */ - boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ - boot->last_error = sizeof(tPofRecHdr); /* new length */ + case POF_READ_FILE_HEAD: + if (card->debug_flags & LOG_POF_WRITE) + hysdn_addlog(card, "POF write: checking file header"); + + if (datlen != sizeof(tPofFileHdr)) { + boot->last_error = -EPOF_INTERNAL; + break; + } + if (boot->buf.PofFileHdr.Magic != TAGFILEMAGIC) { + boot->last_error = -EPOF_BAD_MAGIC; + break; + } + /* Setup the new state and vars */ + boot->Nrecs = (unsigned short)(boot->buf.PofFileHdr.N_PofRecs); /* limited to 65535 */ + boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ + boot->last_error = sizeof(tPofRecHdr); /* new length */ + break; + + case POF_READ_TAG_HEAD: + if (card->debug_flags & LOG_POF_WRITE) + hysdn_addlog(card, "POF write: checking tag header"); + + if (datlen != sizeof(tPofRecHdr)) { + boot->last_error = -EPOF_INTERNAL; break; + } + boot->pof_recid = boot->buf.PofRecHdr.PofRecId; /* actual pof recid */ + boot->pof_reclen = boot->buf.PofRecHdr.PofRecDataLen; /* total length */ + boot->pof_recoffset = 0; /* no starting offset */ - case POF_READ_TAG_HEAD: - if (card->debug_flags & LOG_POF_WRITE) - hysdn_addlog(card, "POF write: checking tag header"); - - if (datlen != sizeof(tPofRecHdr)) { - boot->last_error = -EPOF_INTERNAL; - break; - } - boot->pof_recid = boot->buf.PofRecHdr.PofRecId; /* actual pof recid */ - boot->pof_reclen = boot->buf.PofRecHdr.PofRecDataLen; /* total length */ - boot->pof_recoffset = 0; /* no starting offset */ - - if (card->debug_flags & LOG_POF_RECORD) - hysdn_addlog(card, "POF: got record id=0x%lx length=%ld ", - boot->pof_recid, boot->pof_reclen); - - boot->pof_state = POF_READ_TAG_DATA; /* now start with tag data */ - if (boot->pof_reclen < BOOT_BUF_SIZE) - boot->last_error = boot->pof_reclen; /* limit size */ - else - boot->last_error = BOOT_BUF_SIZE; /* maximum */ + if (card->debug_flags & LOG_POF_RECORD) + hysdn_addlog(card, "POF: got record id=0x%lx length=%ld ", + boot->pof_recid, boot->pof_reclen); - if (!boot->last_error) { /* no data inside record */ - boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ - boot->last_error = sizeof(tPofRecHdr); /* new length */ - } - break; + boot->pof_state = POF_READ_TAG_DATA; /* now start with tag data */ + if (boot->pof_reclen < BOOT_BUF_SIZE) + boot->last_error = boot->pof_reclen; /* limit size */ + else + boot->last_error = BOOT_BUF_SIZE; /* maximum */ - case POF_READ_TAG_DATA: - if (card->debug_flags & LOG_POF_WRITE) - hysdn_addlog(card, "POF write: getting tag data"); - - if (datlen != boot->last_error) { - boot->last_error = -EPOF_INTERNAL; - break; - } - if ((boot->last_error = pof_handle_data(card, datlen)) < 0) - return (boot->last_error); /* an error occurred */ - boot->pof_recoffset += datlen; - if (boot->pof_recoffset >= boot->pof_reclen) { - boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ - boot->last_error = sizeof(tPofRecHdr); /* new length */ - } else { - if (boot->pof_reclen - boot->pof_recoffset < BOOT_BUF_SIZE) - boot->last_error = boot->pof_reclen - boot->pof_recoffset; /* limit size */ - else - boot->last_error = BOOT_BUF_SIZE; /* maximum */ - } - break; + if (!boot->last_error) { /* no data inside record */ + boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ + boot->last_error = sizeof(tPofRecHdr); /* new length */ + } + break; - default: - boot->last_error = -EPOF_INTERNAL; /* unknown state */ + case POF_READ_TAG_DATA: + if (card->debug_flags & LOG_POF_WRITE) + hysdn_addlog(card, "POF write: getting tag data"); + + if (datlen != boot->last_error) { + boot->last_error = -EPOF_INTERNAL; break; + } + if ((boot->last_error = pof_handle_data(card, datlen)) < 0) + return (boot->last_error); /* an error occurred */ + boot->pof_recoffset += datlen; + if (boot->pof_recoffset >= boot->pof_reclen) { + boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */ + boot->last_error = sizeof(tPofRecHdr); /* new length */ + } else { + if (boot->pof_reclen - boot->pof_recoffset < BOOT_BUF_SIZE) + boot->last_error = boot->pof_reclen - boot->pof_recoffset; /* limit size */ + else + boot->last_error = BOOT_BUF_SIZE; /* maximum */ + } + break; + + default: + boot->last_error = -EPOF_INTERNAL; /* unknown state */ + break; } /* switch (boot->pof_state) */ return (boot->last_error); @@ -268,7 +268,7 @@ pof_write_buffer(hysdn_card * card, int datlen) /* occurred. Additionally the pointer to the buffer data area is set on success */ /*******************************************************************************/ int -pof_write_open(hysdn_card * card, unsigned char **bufp) +pof_write_open(hysdn_card *card, unsigned char **bufp) { struct boot_data *boot; /* pointer to boot specific data */ @@ -310,7 +310,7 @@ pof_write_open(hysdn_card * card, unsigned char **bufp) /* The return value must be 0 if everything has happened as desired. */ /********************************************************************************/ int -pof_write_close(hysdn_card * card) +pof_write_close(hysdn_card *card) { struct boot_data *boot = card->boot; /* pointer to boot specific data */ @@ -367,27 +367,27 @@ EvalSysrTokData(hysdn_card *card, unsigned char *cp, int len) return (1); } switch (*cp) { - case SYSR_TOK_B_CHAN: /* 1 */ - if (*(cp + 1) != 1) - return (1); /* length invalid */ - card->bchans = *(cp + 2); - break; - - case SYSR_TOK_FAX_CHAN: /* 2 */ - if (*(cp + 1) != 1) - return (1); /* length invalid */ - card->faxchans = *(cp + 2); - break; - - case SYSR_TOK_MAC_ADDR: /* 3 */ - if (*(cp + 1) != 6) - return (1); /* length invalid */ - memcpy(card->mac_addr, cp + 2, 6); - break; - - default: - hysdn_addlog(card, "unknown token 0x%02x length %d", *cp, *(cp + 1)); - break; + case SYSR_TOK_B_CHAN: /* 1 */ + if (*(cp + 1) != 1) + return (1); /* length invalid */ + card->bchans = *(cp + 2); + break; + + case SYSR_TOK_FAX_CHAN: /* 2 */ + if (*(cp + 1) != 1) + return (1); /* length invalid */ + card->faxchans = *(cp + 2); + break; + + case SYSR_TOK_MAC_ADDR: /* 3 */ + if (*(cp + 1) != 6) + return (1); /* length invalid */ + memcpy(card->mac_addr, cp + 2, 6); + break; + + default: + hysdn_addlog(card, "unknown token 0x%02x length %d", *cp, *(cp + 1)); + break; } len -= (*(cp + 1) + 2); /* adjust len */ cp += (*(cp + 1) + 2); /* and pointer */ diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h index 18b801ad97a4..cdac46a21692 100644 --- a/drivers/isdn/hysdn/hysdn_defs.h +++ b/drivers/isdn/hysdn/hysdn_defs.h @@ -41,7 +41,7 @@ #define B1_PROT_64KBIT_HDLC 0x0001 #define B1_PROT_64KBIT_TRANSPARENT 0x0002 -#define B1_PROT_V110_ASYNCH 0x0004 +#define B1_PROT_V110_ASYNCH 0x0004 #define B1_PROT_V110_SYNCH 0x0008 #define B1_PROT_T30 0x0010 #define B1_PROT_64KBIT_INV_HDLC 0x0020 @@ -199,14 +199,14 @@ typedef struct HYSDN_CARD { char *version[HYSDN_MAXVERSION]; char infobuf[128]; /* for function procinfo */ - + struct HYSDN_CARD *card; struct capi_ctr capi_ctrl; struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB]; int in_idx, out_idx; /* indexes to buffer ring */ int sk_count; /* number of buffers currently in ring */ struct sk_buff *tx_skb; /* buffer for tx operation */ - + struct list_head ncci_head; } *hyctrlinfo; #endif /* CONFIG_HYSDN_CAPI */ @@ -235,11 +235,11 @@ extern void hysdn_procconf_release(void); /* deinit proc config filesys */ /* hysdn_proclog.c */ extern int hysdn_proclog_init(hysdn_card *); /* init proc log entry */ extern void hysdn_proclog_release(hysdn_card *); /* deinit proc log entry */ -extern void hysdn_addlog(hysdn_card *, char *,...); /* output data to log */ +extern void hysdn_addlog(hysdn_card *, char *, ...); /* output data to log */ extern void hysdn_card_errlog(hysdn_card *, tErrLogEntry *, int); /* output card log */ /* boardergo.c */ -extern int ergo_inithardware(hysdn_card * card); /* get hardware -> module init */ +extern int ergo_inithardware(hysdn_card *card); /* get hardware -> module init */ /* hysdn_boot.c */ extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */ @@ -249,31 +249,31 @@ extern int EvalSysrTokData(hysdn_card *, unsigned char *, int); /* Check Sysrea /* hysdn_sched.c */ extern int hysdn_sched_tx(hysdn_card *, unsigned char *, - unsigned short volatile *, unsigned short volatile *, - unsigned short); + unsigned short volatile *, unsigned short volatile *, + unsigned short); extern int hysdn_sched_rx(hysdn_card *, unsigned char *, unsigned short, - unsigned short); + unsigned short); extern int hysdn_tx_cfgline(hysdn_card *, unsigned char *, - unsigned short); /* send one cfg line */ + unsigned short); /* send one cfg line */ /* hysdn_net.c */ -extern unsigned int hynet_enable; +extern unsigned int hynet_enable; extern int hysdn_net_create(hysdn_card *); /* create a new net device */ extern int hysdn_net_release(hysdn_card *); /* delete the device */ extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */ extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */ extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */ extern void hysdn_rx_netpkt(hysdn_card *, unsigned char *, - unsigned short); /* rxed packet from network */ + unsigned short); /* rxed packet from network */ #ifdef CONFIG_HYSDN_CAPI -extern unsigned int hycapi_enable; +extern unsigned int hycapi_enable; extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */ extern int hycapi_capi_release(hysdn_card *); /* delete the device */ extern int hycapi_capi_stop(hysdn_card *card); /* suspend */ -extern void hycapi_rx_capipkt(hysdn_card * card, unsigned char * buf, - unsigned short len); -extern void hycapi_tx_capiack(hysdn_card * card); +extern void hycapi_rx_capipkt(hysdn_card *card, unsigned char *buf, + unsigned short len); +extern void hycapi_tx_capiack(hysdn_card *card); extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card); extern int hycapi_init(void); extern void hycapi_cleanup(void); diff --git a/drivers/isdn/hysdn/hysdn_init.c b/drivers/isdn/hysdn/hysdn_init.c index 0ab42ace1692..b61bbb4bb52b 100644 --- a/drivers/isdn/hysdn/hysdn_init.c +++ b/drivers/isdn/hysdn/hysdn_init.c @@ -169,8 +169,8 @@ hysdn_init(void) hysdn_have_procfs = 1; #ifdef CONFIG_HYSDN_CAPI - if(cardmax > 0) { - if(hycapi_init()) { + if (cardmax > 0) { + if (hycapi_init()) { printk(KERN_ERR "HYCAPI: init failed\n"); if (hysdn_have_procfs) diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c index 11f2cce26005..a0efb4cefa1c 100644 --- a/drivers/isdn/hysdn/hysdn_net.c +++ b/drivers/isdn/hysdn/hysdn_net.c @@ -23,7 +23,7 @@ #include "hysdn_defs.h" -unsigned int hynet_enable = 0xffffffff; +unsigned int hynet_enable = 0xffffffff; module_param(hynet_enable, uint, 0); #define MAX_SKB_BUFFERS 20 /* number of buffers for keeping TX-data */ @@ -155,7 +155,7 @@ net_send_packet(struct sk_buff *skb, struct net_device *dev) /* completion */ /***********************************************************************/ void -hysdn_tx_netack(hysdn_card * card) +hysdn_tx_netack(hysdn_card *card) { struct net_local *lp = card->netif; @@ -181,7 +181,7 @@ hysdn_tx_netack(hysdn_card * card) /* we got a packet from the network, go and queue it */ /*****************************************************/ void -hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len) +hysdn_rx_netpkt(hysdn_card *card, unsigned char *buf, unsigned short len) { struct net_local *lp = card->netif; struct net_device *dev; @@ -215,7 +215,7 @@ hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len) /* return the pointer to a network packet to be send */ /*****************************************************/ struct sk_buff * -hysdn_tx_netget(hysdn_card * card) +hysdn_tx_netget(hysdn_card *card) { struct net_local *lp = card->netif; @@ -229,11 +229,11 @@ hysdn_tx_netget(hysdn_card * card) } /* hysdn_tx_netget */ static const struct net_device_ops hysdn_netdev_ops = { - .ndo_open = net_open, + .ndo_open = net_open, .ndo_stop = net_close, .ndo_start_xmit = net_send_packet, .ndo_change_mtu = eth_change_mtu, - .ndo_set_mac_address = eth_mac_addr, + .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -244,13 +244,13 @@ static const struct net_device_ops hysdn_netdev_ops = { /* 0 announces success, else a negative error code will be returned. */ /*****************************************************************************/ int -hysdn_net_create(hysdn_card * card) +hysdn_net_create(hysdn_card *card) { struct net_device *dev; int i; struct net_local *lp; - if(!card) { + if (!card) { printk(KERN_WARNING "No card-pt in hysdn_net_create!\n"); return (-ENOMEM); } @@ -291,7 +291,7 @@ hysdn_net_create(hysdn_card * card) /* value 0 announces success, else a negative error code will be returned. */ /***************************************************************************/ int -hysdn_net_release(hysdn_card * card) +hysdn_net_release(hysdn_card *card) { struct net_device *dev = card->netif; @@ -316,7 +316,7 @@ hysdn_net_release(hysdn_card * card) /* if the interface is not existing, a "-" is returned. */ /*****************************************************************************/ char * -hysdn_net_getname(hysdn_card * card) +hysdn_net_getname(hysdn_card *card) { struct net_device *dev = card->netif; diff --git a/drivers/isdn/hysdn/hysdn_pof.h b/drivers/isdn/hysdn/hysdn_pof.h index 3a72b908900f..f63f5fa59d7e 100644 --- a/drivers/isdn/hysdn/hysdn_pof.h +++ b/drivers/isdn/hysdn/hysdn_pof.h @@ -16,9 +16,9 @@ #define BOOT_BUF_SIZE 0x1000 /* =4096, maybe moved to other h file */ #define CRYPT_FEEDTERM 0x8142 #define CRYPT_STARTTERM 0x81a5 - /* max. timeout time in seconds - * from end of booting to POF is ready - */ +/* max. timeout time in seconds + * from end of booting to POF is ready + */ #define POF_READY_TIME_OUT_SEC 10 /**********************************/ @@ -36,38 +36,38 @@ */ #define POF_BOOT_LOADER_PAGE_SIZE 0x4000 /* =16384U */ -#define POF_BOOT_LOADER_TOTAL_SIZE (2U*POF_BOOT_LOADER_PAGE_SIZE) +#define POF_BOOT_LOADER_TOTAL_SIZE (2U * POF_BOOT_LOADER_PAGE_SIZE) #define POF_BOOT_LOADER_CODE_SIZE 0x0800 /* =2KB =2048U */ - /* offset in boot page, where loader code may start */ - /* =0x3800= 14336U */ +/* offset in boot page, where loader code may start */ +/* =0x3800= 14336U */ #define POF_BOOT_LOADER_OFF_IN_PAGE (POF_BOOT_LOADER_PAGE_SIZE-POF_BOOT_LOADER_CODE_SIZE) /*--------------------------------------POF file record structs------------*/ typedef struct PofFileHdr_tag { /* Pof file header */ -/*00 */ unsigned long Magic __attribute__((packed)); -/*04 */ unsigned long N_PofRecs __attribute__((packed)); + /*00 */ unsigned long Magic __attribute__((packed)); + /*04 */ unsigned long N_PofRecs __attribute__((packed)); /*08 */ } tPofFileHdr; typedef struct PofRecHdr_tag { /* Pof record header */ -/*00 */ unsigned short PofRecId __attribute__((packed)); -/*02 */ unsigned long PofRecDataLen __attribute__((packed)); + /*00 */ unsigned short PofRecId __attribute__((packed)); + /*02 */ unsigned long PofRecDataLen __attribute__((packed)); /*06 */ } tPofRecHdr; typedef struct PofTimeStamp_tag { -/*00 */ unsigned long UnixTime __attribute__((packed)); + /*00 */ unsigned long UnixTime __attribute__((packed)); /*04 */ unsigned char DateTimeText[0x28]; /* =40 */ /*2C */ } tPofTimeStamp; - /* tPofFileHdr.Magic value: */ +/* tPofFileHdr.Magic value: */ #define TAGFILEMAGIC 0x464F501AUL - /* tPofRecHdr.PofRecId values: */ +/* tPofRecHdr.PofRecId values: */ #define TAG_ABSDATA 0x1000 /* abs. data */ #define TAG_BOOTDTA 0x1001 /* boot data */ #define TAG_COMMENT 0x0020 diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index 5fe83bd42061..8023d2510fba 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c @@ -91,7 +91,7 @@ process_line(struct conf_writedata *cnf) /* write conf file -> boot or send cfg line to card */ /****************************************************/ static ssize_t -hysdn_conf_write(struct file *file, const char __user *buf, size_t count, loff_t * off) +hysdn_conf_write(struct file *file, const char __user *buf, size_t count, loff_t *off) { struct conf_writedata *cnf; int i; @@ -366,7 +366,7 @@ static const struct file_operations conf_fops = .read = hysdn_conf_read, .write = hysdn_conf_write, .open = hysdn_conf_open, - .release = hysdn_conf_close, + .release = hysdn_conf_close, }; /*****************************/ @@ -395,9 +395,9 @@ hysdn_procconf_init(void) sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); if ((card->procconf = (void *) proc_create(conf_name, - S_IFREG | S_IRUGO | S_IWUSR, - hysdn_proc_entry, - &conf_fops)) != NULL) { + S_IFREG | S_IRUGO | S_IWUSR, + hysdn_proc_entry, + &conf_fops)) != NULL) { hysdn_proclog_init(card); /* init the log file entry */ } card = card->next; /* next entry */ diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c index 236cc7dadfd0..ba91333e3e41 100644 --- a/drivers/isdn/hysdn/hysdn_proclog.c +++ b/drivers/isdn/hysdn/hysdn_proclog.c @@ -24,7 +24,7 @@ extern struct proc_dir_entry *hysdn_proc_entry; static DEFINE_MUTEX(hysdn_log_mutex); -static void put_log_buffer(hysdn_card * card, char *cp); +static void put_log_buffer(hysdn_card *card, char *cp); /*************************************************/ /* structure keeping ascii log for device output */ @@ -54,7 +54,7 @@ struct procdata { /* log function for cards error log interface */ /**********************************************/ void -hysdn_card_errlog(hysdn_card * card, tErrLogEntry * logp, int maxsize) +hysdn_card_errlog(hysdn_card *card, tErrLogEntry *logp, int maxsize) { char buf[ERRLOG_TEXT_SIZE + 40]; @@ -66,7 +66,7 @@ hysdn_card_errlog(hysdn_card * card, tErrLogEntry * logp, int maxsize) /* Log function using format specifiers for output */ /***************************************************/ void -hysdn_addlog(hysdn_card * card, char *fmt,...) +hysdn_addlog(hysdn_card *card, char *fmt, ...) { struct procdata *pd = card->proclog; char *cp; @@ -98,7 +98,7 @@ hysdn_addlog(hysdn_card * card, char *fmt,...) /* Flushes buffers not longer in use. */ /********************************************/ static void -put_log_buffer(hysdn_card * card, char *cp) +put_log_buffer(hysdn_card *card, char *cp) { struct log_data *ib; struct procdata *pd = card->proclog; @@ -115,7 +115,7 @@ put_log_buffer(hysdn_card * card, char *cp) return; /* no open file for read */ if (!(ib = kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC))) - return; /* no memory */ + return; /* no memory */ strcpy(ib->log_start, cp); /* set output string */ ib->next = NULL; ib->proc_ctrl = pd; /* point to own control structure */ @@ -153,7 +153,7 @@ put_log_buffer(hysdn_card * card, char *cp) /* write log file -> set log level bits */ /****************************************/ static ssize_t -hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off) +hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t *off) { int rc; unsigned char valbuf[128]; @@ -177,7 +177,7 @@ hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t /* read log file */ /******************/ static ssize_t -hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t * off) +hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off) { struct log_data *inf; int len; @@ -324,7 +324,7 @@ hysdn_log_close(struct inode *ino, struct file *filep) /* select/poll routine to be able using select() */ /*************************************************/ static unsigned int -hysdn_log_poll(struct file *file, poll_table * wait) +hysdn_log_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); @@ -364,7 +364,7 @@ static const struct file_operations log_fops = .write = hysdn_log_write, .poll = hysdn_log_poll, .open = hysdn_log_open, - .release = hysdn_log_close, + .release = hysdn_log_close, }; @@ -373,7 +373,7 @@ static const struct file_operations log_fops = /* conf files. */ /***********************************************************************************/ int -hysdn_proclog_init(hysdn_card * card) +hysdn_proclog_init(hysdn_card *card) { struct procdata *pd; @@ -382,8 +382,8 @@ hysdn_proclog_init(hysdn_card * card) if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); pd->log = proc_create(pd->log_name, - S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry, - &log_fops); + S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry, + &log_fops); init_waitqueue_head(&(pd->rd_queue)); @@ -398,7 +398,7 @@ hysdn_proclog_init(hysdn_card * card) /* The module counter is assumed to be 0 ! */ /************************************************************************************/ void -hysdn_proclog_release(hysdn_card * card) +hysdn_proclog_release(hysdn_card *card) { struct procdata *pd; diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c index 3674d30d6a03..31d7c1415543 100644 --- a/drivers/isdn/hysdn/hysdn_sched.c +++ b/drivers/isdn/hysdn/hysdn_sched.c @@ -29,33 +29,33 @@ /*****************************************************************************/ int hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len, - unsigned short chan) + unsigned short chan) { switch (chan) { - case CHAN_NDIS_DATA: - if (hynet_enable & (1 << card->myid)) { - /* give packet to network handler */ - hysdn_rx_netpkt(card, buf, len); - } - break; - - case CHAN_ERRLOG: - hysdn_card_errlog(card, (tErrLogEntry *) buf, len); - if (card->err_log_state == ERRLOG_STATE_ON) - card->err_log_state = ERRLOG_STATE_START; /* start new fetch */ - break; + case CHAN_NDIS_DATA: + if (hynet_enable & (1 << card->myid)) { + /* give packet to network handler */ + hysdn_rx_netpkt(card, buf, len); + } + break; + + case CHAN_ERRLOG: + hysdn_card_errlog(card, (tErrLogEntry *) buf, len); + if (card->err_log_state == ERRLOG_STATE_ON) + card->err_log_state = ERRLOG_STATE_START; /* start new fetch */ + break; #ifdef CONFIG_HYSDN_CAPI - case CHAN_CAPI: + case CHAN_CAPI: /* give packet to CAPI handler */ - if (hycapi_enable & (1 << card->myid)) { - hycapi_rx_capipkt(card, buf, len); - } - break; + if (hycapi_enable & (1 << card->myid)) { + hycapi_rx_capipkt(card, buf, len); + } + break; #endif /* CONFIG_HYSDN_CAPI */ - default: - printk(KERN_INFO "irq message channel %d len %d unhandled \n", chan, len); - break; + default: + printk(KERN_INFO "irq message channel %d len %d unhandled \n", chan, len); + break; } /* switch rx channel */ @@ -72,8 +72,8 @@ hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len, /*****************************************************************************/ int hysdn_sched_tx(hysdn_card *card, unsigned char *buf, - unsigned short volatile *len, unsigned short volatile *chan, - unsigned short maxlen) + unsigned short volatile *len, unsigned short volatile *chan, + unsigned short maxlen) { struct sk_buff *skb; @@ -109,8 +109,8 @@ hysdn_sched_tx(hysdn_card *card, unsigned char *buf, return (1); /* tell that data should be send */ } /* error log start and able to send */ /* now handle network interface packets */ - if ((hynet_enable & (1 << card->myid)) && - (skb = hysdn_tx_netget(card)) != NULL) + if ((hynet_enable & (1 << card->myid)) && + (skb = hysdn_tx_netget(card)) != NULL) { if (skb->len <= maxlen) { /* copy the packet to the buffer */ @@ -123,8 +123,8 @@ hysdn_sched_tx(hysdn_card *card, unsigned char *buf, hysdn_tx_netack(card); /* aknowledge packet -> throw away */ } /* send a network packet if available */ #ifdef CONFIG_HYSDN_CAPI - if( ((hycapi_enable & (1 << card->myid))) && - ((skb = hycapi_tx_capiget(card)) != NULL) ) + if (((hycapi_enable & (1 << card->myid))) && + ((skb = hycapi_tx_capiget(card)) != NULL)) { if (skb->len <= maxlen) { skb_copy_from_linear_data(skb, buf, skb->len); diff --git a/drivers/isdn/hysdn/ince1pc.h b/drivers/isdn/hysdn/ince1pc.h index 7a36694df6d7..cab68361de65 100644 --- a/drivers/isdn/hysdn/ince1pc.h +++ b/drivers/isdn/hysdn/ince1pc.h @@ -17,30 +17,30 @@ /* basic scalar definitions have same meanning, * but their declaration location depends on environment - */ + */ -/*--------------------------------------channel numbers---------------------*/ +/*--------------------------------------channel numbers---------------------*/ #define CHAN_SYSTEM 0x0001 /* system channel (spooler to spooler) */ #define CHAN_ERRLOG 0x0005 /* error logger */ #define CHAN_CAPI 0x0064 /* CAPI interface */ #define CHAN_NDIS_DATA 0x1001 /* NDIS data transfer */ -/*--------------------------------------POF ready msg-----------------------*/ - /* NOTE: after booting POF sends system ready message to PC: */ +/*--------------------------------------POF ready msg-----------------------*/ +/* NOTE: after booting POF sends system ready message to PC: */ #define RDY_MAGIC 0x52535953UL /* 'SYSR' reversed */ #define RDY_MAGIC_SIZE 4 /* size in bytes */ #define MAX_N_TOK_BYTES 255 #define MIN_RDY_MSG_SIZE RDY_MAGIC_SIZE -#define MAX_RDY_MSG_SIZE (RDY_MAGIC_SIZE+MAX_N_TOK_BYTES) +#define MAX_RDY_MSG_SIZE (RDY_MAGIC_SIZE + MAX_N_TOK_BYTES) #define SYSR_TOK_END 0 #define SYSR_TOK_B_CHAN 1 /* nr. of B-Channels; DataLen=1; def: 2 */ #define SYSR_TOK_FAX_CHAN 2 /* nr. of FAX Channels; DataLen=1; def: 0 */ #define SYSR_TOK_MAC_ADDR 3 /* MAC-Address; DataLen=6; def: auto */ #define SYSR_TOK_ESC 255 /* undefined data size yet */ - /* default values, if not corrected by token: */ +/* default values, if not corrected by token: */ #define SYSR_TOK_B_CHAN_DEF 2 /* assume 2 B-Channels */ #define SYSR_TOK_FAX_CHAN_DEF 1 /* assume 1 FAX Channel */ @@ -70,31 +70,31 @@ * * note: * - for 16-bit FIFO add padding 0 byte to achieve even token data bytes! - */ + */ -/*--------------------------------------error logger------------------------*/ - /* note: pof needs final 0 ! */ +/*--------------------------------------error logger------------------------*/ +/* note: pof needs final 0 ! */ #define ERRLOG_CMD_REQ "ERRLOG ON" #define ERRLOG_CMD_REQ_SIZE 10 /* with final 0 byte ! */ #define ERRLOG_CMD_STOP "ERRLOG OFF" #define ERRLOG_CMD_STOP_SIZE 11 /* with final 0 byte ! */ #define ERRLOG_ENTRY_SIZE 64 /* sizeof(tErrLogEntry) */ - /* remaining text size = 55 */ -#define ERRLOG_TEXT_SIZE (ERRLOG_ENTRY_SIZE-2*4-1) + /* remaining text size = 55 */ +#define ERRLOG_TEXT_SIZE (ERRLOG_ENTRY_SIZE - 2 * 4 - 1) typedef struct ErrLogEntry_tag { - -/*00 */ unsigned long ulErrType; - -/*04 */ unsigned long ulErrSubtype; - -/*08 */ unsigned char ucTextSize; - + + /*00 */ unsigned long ulErrType; + + /*04 */ unsigned long ulErrSubtype; + + /*08 */ unsigned char ucTextSize; + /*09 */ unsigned char ucText[ERRLOG_TEXT_SIZE]; /* ASCIIZ of len ucTextSize-1 */ - -/*40 */ + +/*40 */ } tErrLogEntry; @@ -104,30 +104,30 @@ typedef struct ErrLogEntry_tag { #endif /* */ #endif /* */ -/*--------------------------------------DPRAM boot spooler------------------*/ - /* this is the struture used between pc and - * hyperstone to exchange boot data - */ +/*--------------------------------------DPRAM boot spooler------------------*/ +/* this is the struture used between pc and + * hyperstone to exchange boot data + */ #define DPRAM_SPOOLER_DATA_SIZE 0x20 typedef struct DpramBootSpooler_tag { - -/*00 */ unsigned char Len; - -/*01 */ volatile unsigned char RdPtr; - -/*02 */ unsigned char WrPtr; - -/*03 */ unsigned char Data[DPRAM_SPOOLER_DATA_SIZE]; - -/*23 */ + + /*00 */ unsigned char Len; + + /*01 */ volatile unsigned char RdPtr; + + /*02 */ unsigned char WrPtr; + + /*03 */ unsigned char Data[DPRAM_SPOOLER_DATA_SIZE]; + +/*23 */ } tDpramBootSpooler; #define DPRAM_SPOOLER_MIN_SIZE 5 /* Len+RdPtr+Wrptr+2*data */ #define DPRAM_SPOOLER_DEF_SIZE 0x23 /* current default size */ -/*--------------------------------------HYCARD/ERGO DPRAM SoftUart----------*/ - /* at DPRAM offset 0x1C00: */ +/*--------------------------------------HYCARD/ERGO DPRAM SoftUart----------*/ +/* at DPRAM offset 0x1C00: */ #define SIZE_RSV_SOFT_UART 0x1B0 /* 432 bytes reserved for SoftUart */ diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index d5013935ac62..78ce42214713 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c @@ -204,9 +204,9 @@ isdn_audio_tlookup(const u_char *table, u_char *buff, unsigned long n) "xlatb\n\t" "stosb\n\t" "loop 1b\n\t" - : "=&b"(d0), "=&c"(d1), "=&D"(d2), "=&S"(d3) - : "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff) - : "memory", "ax"); + : "=&b"(d0), "=&c"(d1), "=&D"(d2), "=&S"(d3) + : "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff) + : "memory", "ax"); #else while (n--) *buff = table[*(unsigned char *)buff], buff++; @@ -242,27 +242,27 @@ static unsigned char isdn_audio_linear2ulaw(int sample) { static int exp_lut[256] = - { - 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 - }; + { + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 + }; int sign, - exponent, - mantissa; + exponent, + mantissa; unsigned char ulawbyte; /* Get the sample into sign-magnitude. */ @@ -299,7 +299,7 @@ static int bitmask[9] = }; static int -isdn_audio_get_bits(adpcm_state * s, unsigned char **in, int *len) +isdn_audio_get_bits(adpcm_state *s, unsigned char **in, int *len) { while (s->nleft < s->nbits) { int d = *((*in)++); @@ -312,7 +312,7 @@ isdn_audio_get_bits(adpcm_state * s, unsigned char **in, int *len) } static void -isdn_audio_put_bits(int data, int nbits, adpcm_state * s, +isdn_audio_put_bits(int data, int nbits, adpcm_state *s, unsigned char **out, int *len) { s->word = (s->word << nbits) | (data & bitmask[nbits]); @@ -326,7 +326,7 @@ isdn_audio_put_bits(int data, int nbits, adpcm_state * s, } adpcm_state * -isdn_audio_adpcm_init(adpcm_state * s, int nbits) +isdn_audio_adpcm_init(adpcm_state *s, int nbits) { if (!s) s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC); @@ -341,7 +341,7 @@ isdn_audio_adpcm_init(adpcm_state * s, int nbits) } dtmf_state * -isdn_audio_dtmf_init(dtmf_state * s) +isdn_audio_dtmf_init(dtmf_state *s) { if (!s) s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC); @@ -358,7 +358,7 @@ isdn_audio_dtmf_init(dtmf_state * s) */ int -isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in, +isdn_audio_adpcm2xlaw(adpcm_state *s, int fmt, unsigned char *in, unsigned char *out, int len) { int a = s->a; @@ -379,7 +379,7 @@ isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in, a++; if (fmt) *out++ = isdn_audio_ulaw_to_alaw[ - isdn_audio_linear2ulaw(a << 2)]; + isdn_audio_linear2ulaw(a << 2)]; else *out++ = isdn_audio_linear2ulaw(a << 2); olen++; @@ -393,7 +393,7 @@ isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in, } int -isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in, +isdn_audio_xlaw2adpcm(adpcm_state *s, int fmt, unsigned char *in, unsigned char *out, int len) { int a = s->a; @@ -403,9 +403,9 @@ isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in, while (len--) { int e = 0, - nmax = 1 << (nbits - 1); + nmax = 1 << (nbits - 1); int sign, - delta; + delta; if (fmt) delta = (isdn_audio_alaw_to_s16[*in++] >> 2) - a; @@ -439,26 +439,26 @@ isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in, /* * Goertzel algorithm. - * See http://ptolemy.eecs.berkeley.edu/papers/96/dtmf_ict/ + * See http://ptolemy.eecs.berkeley.edu/papers/96/dtmf_ict/ * for more info. * Result is stored into an sk_buff and queued up for later * evaluation. */ static void -isdn_audio_goertzel(int *sample, modem_info * info) +isdn_audio_goertzel(int *sample, modem_info *info) { int sk, - sk1, - sk2; + sk1, + sk2; int k, - n; + n; struct sk_buff *skb; int *result; skb = dev_alloc_skb(sizeof(int) * NCOEFF); if (!skb) { printk(KERN_WARNING - "isdn_audio: Could not alloc DTMF result for ttyI%d\n", + "isdn_audio: Could not alloc DTMF result for ttyI%d\n", info->line); return; } @@ -483,16 +483,16 @@ isdn_audio_goertzel(int *sample, modem_info * info) printk(KERN_DEBUG "isdn_audio: dtmf goertzel overflow, sk2=%d\n", sk2); result[k] = - ((sk * sk) >> AMP_BITS) - - ((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) + - ((sk2 * sk2) >> AMP_BITS); + ((sk * sk) >> AMP_BITS) - + ((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) + + ((sk2 * sk2) >> AMP_BITS); } skb_queue_tail(&info->dtmf_queue, skb); isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); } void -isdn_audio_eval_dtmf(modem_info * info) +isdn_audio_eval_dtmf(modem_info *info) { struct sk_buff *skb; int *result; @@ -590,7 +590,7 @@ isdn_audio_eval_dtmf(modem_info * info) * fmt = audio data format (0 = ulaw, 1 = alaw) */ void -isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt) +isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt) { dtmf_state *s = info->dtmf_state; int i; @@ -605,10 +605,10 @@ isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt) for (i = 0; i < c; i++) { if (fmt) s->buf[s->idx++] = - isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS); + isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS); else s->buf[s->idx++] = - isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS); + isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS); } if (s->idx == DTMF_NPOINTS) { isdn_audio_goertzel(s->buf, info); @@ -619,7 +619,7 @@ isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt) } silence_state * -isdn_audio_silence_init(silence_state * s) +isdn_audio_silence_init(silence_state *s) { if (!s) s = kmalloc(sizeof(silence_state), GFP_ATOMIC); @@ -631,7 +631,7 @@ isdn_audio_silence_init(silence_state * s) } void -isdn_audio_calc_silence(modem_info * info, unsigned char *buf, int len, int fmt) +isdn_audio_calc_silence(modem_info *info, unsigned char *buf, int len, int fmt) { silence_state *s = info->silence_state; int i; @@ -641,24 +641,24 @@ isdn_audio_calc_silence(modem_info * info, unsigned char *buf, int len, int fmt) for (i = 0; i < len; i++) { if (fmt) - c = isdn_audio_alaw_to_ulaw[*buf++]; - else - c = *buf++; + c = isdn_audio_alaw_to_ulaw[*buf++]; + else + c = *buf++; if (c > 0) c -= 128; c = abs(c); - if (c > (info->emu.vpar[1] * 4)) { + if (c > (info->emu.vpar[1] * 4)) { s->idx = 0; - s->state = 1; + s->state = 1; } else { - if (s->idx < 210000) s->idx++; + if (s->idx < 210000) s->idx++; } } } void -isdn_audio_put_dle_code(modem_info * info, u_char code) +isdn_audio_put_dle_code(modem_info *info, u_char code) { struct sk_buff *skb; int di; @@ -668,7 +668,7 @@ isdn_audio_put_dle_code(modem_info * info, u_char code) skb = dev_alloc_skb(2); if (!skb) { printk(KERN_WARNING - "isdn_audio: Could not alloc skb for ttyI%d\n", + "isdn_audio: Could not alloc skb for ttyI%d\n", info->line); return; } @@ -688,24 +688,24 @@ isdn_audio_put_dle_code(modem_info * info, u_char code) } void -isdn_audio_eval_silence(modem_info * info) +isdn_audio_eval_silence(modem_info *info) { silence_state *s = info->silence_state; char what; what = ' '; - if (s->idx > (info->emu.vpar[2] * 800)) { + if (s->idx > (info->emu.vpar[2] * 800)) { s->idx = 0; - if (!s->state) { /* silence from beginning of rec */ + if (!s->state) { /* silence from beginning of rec */ what = 's'; } else { what = 'q'; } } - if ((what == 's') || (what == 'q')) { - printk(KERN_DEBUG "ttyI%d: %s\n", info->line, - (what=='s') ? "silence":"quiet"); - isdn_audio_put_dle_code(info, what); - } + if ((what == 's') || (what == 'q')) { + printk(KERN_DEBUG "ttyI%d: %s\n", info->line, + (what == 's') ? "silence" : "quiet"); + isdn_audio_put_dle_code(info, what); + } } diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c index aa0b6a6f5ef4..7f3c54d40474 100644 --- a/drivers/isdn/i4l/isdn_bsdcomp.c +++ b/drivers/isdn/i4l/isdn_bsdcomp.c @@ -7,7 +7,7 @@ */ /* - * Update: The Berkeley copyright was changed, and the change + * Update: The Berkeley copyright was changed, and the change * is retroactive to all "true" BSD software (ie everything * from UCB as opposed to other peoples code that just carried * the same license). The new copyright doesn't clash with the @@ -121,7 +121,7 @@ struct bsd_db { unsigned char maxbits; /* maximum bits/code */ unsigned char debug; /* non-zero if debug desired */ unsigned char unit; /* ppp unit number */ - u16 seqno; /* sequence # of next packet */ + u16 seqno; /* sequence # of next packet */ unsigned int mru; /* size of receive (decompress) bufr */ unsigned int maxmaxcode; /* largest valid code */ unsigned int max_ent; /* largest code in use */ @@ -157,16 +157,16 @@ struct bsd_db { #define MAXCODE(b) ((1 << (b)) - 1) #define BADCODEM1 MAXCODE(MAX_BSD_BITS) -#define BSD_HASH(prefix,suffix,hshift) ((((unsigned long)(suffix))<<(hshift)) \ - ^ (unsigned long)(prefix)) -#define BSD_KEY(prefix,suffix) ((((unsigned long)(suffix)) << 16) \ +#define BSD_HASH(prefix, suffix, hshift) ((((unsigned long)(suffix)) << (hshift)) \ + ^ (unsigned long)(prefix)) +#define BSD_KEY(prefix, suffix) ((((unsigned long)(suffix)) << 16) \ + (unsigned long)(prefix)) #define CHECK_GAP 10000 /* Ratio check interval */ #define RATIO_SCALE_LOG 8 -#define RATIO_SCALE (1<>RATIO_SCALE_LOG) +#define RATIO_SCALE (1 << RATIO_SCALE_LOG) +#define RATIO_MAX (0x7fffffff >> RATIO_SCALE_LOG) /* * clear the dictionary @@ -175,7 +175,7 @@ struct bsd_db { static void bsd_clear(struct bsd_db *db) { db->clear_count++; - db->max_ent = FIRST-1; + db->max_ent = FIRST - 1; db->n_bits = BSD_INIT_BITS; db->bytes_out = 0; db->in_count = 0; @@ -197,56 +197,56 @@ static void bsd_clear(struct bsd_db *db) * the absence of CLEAR codes (while packets are incompressible), they * must compute the same ratio. */ -static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */ +static int bsd_check(struct bsd_db *db) /* 1=output CLEAR */ { - unsigned int new_ratio; - - if (db->in_count >= db->checkpoint) - { - /* age the ratio by limiting the size of the counts */ - if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) - { - db->in_count -= (db->in_count >> 2); - db->bytes_out -= (db->bytes_out >> 2); - } - - db->checkpoint = db->in_count + CHECK_GAP; - - if (db->max_ent >= db->maxmaxcode) - { - /* Reset the dictionary only if the ratio is worse, - * or if it looks as if it has been poisoned - * by incompressible data. - * - * This does not overflow, because - * db->in_count <= RATIO_MAX. - */ - - new_ratio = db->in_count << RATIO_SCALE_LOG; - if (db->bytes_out != 0) - { - new_ratio /= db->bytes_out; - } - - if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) - { - bsd_clear (db); - return 1; - } - db->ratio = new_ratio; - } - } - return 0; + unsigned int new_ratio; + + if (db->in_count >= db->checkpoint) + { + /* age the ratio by limiting the size of the counts */ + if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) + { + db->in_count -= (db->in_count >> 2); + db->bytes_out -= (db->bytes_out >> 2); + } + + db->checkpoint = db->in_count + CHECK_GAP; + + if (db->max_ent >= db->maxmaxcode) + { + /* Reset the dictionary only if the ratio is worse, + * or if it looks as if it has been poisoned + * by incompressible data. + * + * This does not overflow, because + * db->in_count <= RATIO_MAX. + */ + + new_ratio = db->in_count << RATIO_SCALE_LOG; + if (db->bytes_out != 0) + { + new_ratio /= db->bytes_out; + } + + if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) + { + bsd_clear(db); + return 1; + } + db->ratio = new_ratio; + } + } + return 0; } /* * Return statistics. */ -static void bsd_stats (void *state, struct compstat *stats) +static void bsd_stats(void *state, struct compstat *stats) { struct bsd_db *db = (struct bsd_db *) state; - + stats->unc_bytes = db->uncomp_bytes; stats->unc_packets = db->uncomp_count; stats->comp_bytes = db->comp_bytes; @@ -260,9 +260,9 @@ static void bsd_stats (void *state, struct compstat *stats) /* * Reset state, as on a CCP ResetReq. */ -static void bsd_reset (void *state,unsigned char code, unsigned char id, - unsigned char *data, unsigned len, - struct isdn_ppp_resetparams *rsparm) +static void bsd_reset(void *state, unsigned char code, unsigned char id, + unsigned char *data, unsigned len, + struct isdn_ppp_resetparams *rsparm) { struct bsd_db *db = (struct bsd_db *) state; @@ -274,7 +274,7 @@ static void bsd_reset (void *state,unsigned char code, unsigned char id, /* * Release the compression structure */ -static void bsd_free (void *state) +static void bsd_free(void *state) { struct bsd_db *db = (struct bsd_db *) state; @@ -302,7 +302,7 @@ static void bsd_free (void *state) /* * Allocate space for a (de) compressor. */ -static void *bsd_alloc (struct isdn_ppp_comp_data *data) +static void *bsd_alloc(struct isdn_ppp_comp_data *data) { int bits; unsigned int hsize, hshift, maxmaxcode; @@ -310,27 +310,27 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) int decomp; static unsigned int htab[][2] = { - { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , - { 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 } + { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , + { 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 } }; - + if (data->optlen != 1 || data->num != CI_BSD_COMPRESS - || BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) + || BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) return NULL; bits = BSD_NBITS(data->options[0]); - if(bits < 9 || bits > 15) + if (bits < 9 || bits > 15) return NULL; - hsize = htab[bits-9][0]; - hshift = htab[bits-9][1]; - + hsize = htab[bits - 9][0]; + hshift = htab[bits - 9][1]; + /* * Allocate the main control structure for this instance. */ maxmaxcode = MAXCODE(bits); - db = kzalloc (sizeof (struct bsd_db),GFP_KERNEL); + db = kzalloc(sizeof(struct bsd_db), GFP_KERNEL); if (!db) return NULL; @@ -343,7 +343,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) */ db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); if (!db->dict) { - bsd_free (db); + bsd_free(db); return NULL; } @@ -356,7 +356,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) else { db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); if (!db->lens) { - bsd_free (db); + bsd_free(db); return (NULL); } } @@ -364,41 +364,41 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data) /* * Initialize the data information for the compression code */ - db->totlen = sizeof (struct bsd_db) + (sizeof (struct bsd_dict) * hsize); - db->hsize = hsize; - db->hshift = hshift; + db->totlen = sizeof(struct bsd_db) + (sizeof(struct bsd_dict) * hsize); + db->hsize = hsize; + db->hshift = hshift; db->maxmaxcode = maxmaxcode; - db->maxbits = bits; + db->maxbits = bits; - return (void *) db; + return (void *)db; } /* * Initialize the database. */ -static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int debug) +static int bsd_init(void *state, struct isdn_ppp_comp_data *data, int unit, int debug) { struct bsd_db *db = state; int indx; int decomp; - if(!state || !data) { - printk(KERN_ERR "isdn_bsd_init: [%d] ERR, state %lx data %lx\n",unit,(long)state,(long)data); + if (!state || !data) { + printk(KERN_ERR "isdn_bsd_init: [%d] ERR, state %lx data %lx\n", unit, (long)state, (long)data); return 0; } decomp = db->xmit ? 0 : 1; - + if (data->optlen != 1 || data->num != CI_BSD_COMPRESS - || (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) - || (BSD_NBITS(data->options[0]) != db->maxbits) - || (decomp && db->lens == NULL)) { - printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n",data->optlen,data->num,data->options[0],decomp,(unsigned long)db->lens); + || (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION) + || (BSD_NBITS(data->options[0]) != db->maxbits) + || (decomp && db->lens == NULL)) { + printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n", data->optlen, data->num, data->options[0], decomp, (unsigned long)db->lens); return 0; } if (decomp) - for(indx=LAST;indx>=0;indx--) + for (indx = LAST; indx >= 0; indx--) db->lens[indx] = 1; indx = db->hsize; @@ -411,9 +411,9 @@ static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int db->mru = 0; db->debug = 1; - - bsd_reset(db,0,0,NULL,0,NULL); - + + bsd_reset(db, 0, 0, NULL, 0, NULL); + return 1; } @@ -421,37 +421,37 @@ static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int * Obtain pointers to the various structures in the compression tables */ -#define dict_ptrx(p,idx) &(p->dict[idx]) -#define lens_ptrx(p,idx) &(p->lens[idx]) +#define dict_ptrx(p, idx) &(p->dict[idx]) +#define lens_ptrx(p, idx) &(p->lens[idx]) #ifdef DEBUG static unsigned short *lens_ptr(struct bsd_db *db, int idx) { if ((unsigned int) idx > (unsigned int) db->maxmaxcode) { - printk (KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx); + printk(KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx); idx = 0; } - return lens_ptrx (db, idx); + return lens_ptrx(db, idx); } static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx) { if ((unsigned int) idx >= (unsigned int) db->hsize) { - printk (KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx); + printk(KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx); idx = 0; } - return dict_ptrx (db, idx); + return dict_ptrx(db, idx); } #else -#define lens_ptr(db,idx) lens_ptrx(db,idx) -#define dict_ptr(db,idx) dict_ptrx(db,idx) +#define lens_ptr(db, idx) lens_ptrx(db, idx) +#define dict_ptr(db, idx) dict_ptrx(db, idx) #endif /* * compress a packet */ -static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,int proto) +static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, int proto) { struct bsd_db *db; int hshift; @@ -463,31 +463,31 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk unsigned long fcode; struct bsd_dict *dictp; unsigned char c; - int hval,disp,ilen,mxcode; + int hval, disp, ilen, mxcode; unsigned char *rptr = skb_in->data; int isize = skb_in->len; -#define OUTPUT(ent) \ - { \ - bitno -= n_bits; \ - accm |= ((ent) << bitno); \ - do { \ - if(skb_out && skb_tailroom(skb_out) > 0) \ - *(skb_put(skb_out,1)) = (unsigned char) (accm>>24); \ - accm <<= 8; \ - bitno += 8; \ - } while (bitno <= 24); \ - } +#define OUTPUT(ent) \ + { \ + bitno -= n_bits; \ + accm |= ((ent) << bitno); \ + do { \ + if (skb_out && skb_tailroom(skb_out) > 0) \ + *(skb_put(skb_out, 1)) = (unsigned char)(accm >> 24); \ + accm <<= 8; \ + bitno += 8; \ + } while (bitno <= 24); \ + } /* * If the protocol is not in the range we're interested in, * just return without compressing the packet. If it is, * the protocol becomes the first byte to compress. */ - printk(KERN_DEBUG "bsd_compress called with %x\n",proto); - + printk(KERN_DEBUG "bsd_compress called with %x\n", proto); + ent = proto; - if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1) ) + if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1)) return 0; db = (struct bsd_db *) state; @@ -496,25 +496,25 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk n_bits = db->n_bits; bitno = 32; accm = 0; - mxcode = MAXCODE (n_bits); - + mxcode = MAXCODE(n_bits); + /* This is the PPP header information */ - if(skb_out && skb_tailroom(skb_out) >= 2) { - char *v = skb_put(skb_out,2); + if (skb_out && skb_tailroom(skb_out) >= 2) { + char *v = skb_put(skb_out, 2); /* we only push our own data on the header, - AC,PC and protos is pushed by caller */ + AC,PC and protos is pushed by caller */ v[0] = db->seqno >> 8; v[1] = db->seqno; } - ilen = ++isize; /* This is off by one, but that is what is in draft! */ + ilen = ++isize; /* This is off by one, but that is what is in draft! */ while (--ilen > 0) { - c = *rptr++; - fcode = BSD_KEY (ent, c); - hval = BSD_HASH (ent, c, hshift); - dictp = dict_ptr (db, hval); - + c = *rptr++; + fcode = BSD_KEY(ent, c); + hval = BSD_HASH(ent, c, hshift); + dictp = dict_ptr(db, hval); + /* Validate and then check the entry. */ if (dictp->codem1 >= max_ent) goto nomatch; @@ -523,7 +523,7 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk ent = dictp->codem1 + 1; continue; /* found (prefix,suffix) */ } - + /* continue probing until a match or invalid entry */ disp = (hval == 0) ? 1 : hval; @@ -531,17 +531,17 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk hval += disp; if (hval >= db->hsize) hval -= db->hsize; - dictp = dict_ptr (db, hval); + dictp = dict_ptr(db, hval); if (dictp->codem1 >= max_ent) goto nomatch; } while (dictp->fcode != fcode); ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */ continue; - -nomatch: + + nomatch: OUTPUT(ent); /* output the prefix */ - + /* code -> hashtable */ if (max_ent < db->maxmaxcode) { struct bsd_dict *dictp2; @@ -551,16 +551,16 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk /* expand code size if needed */ if (max_ent >= mxcode) { db->n_bits = ++n_bits; - mxcode = MAXCODE (n_bits); + mxcode = MAXCODE(n_bits); } - - /* + + /* * Invalidate old hash table entry using * this code, and then take it over. */ - dictp2 = dict_ptr (db, max_ent + 1); + dictp2 = dict_ptr(db, max_ent + 1); indx = dictp2->cptr; - dictp3 = dict_ptr (db, indx); + dictp3 = dict_ptr(db, indx); if (dictp3->codem1 == max_ent) dictp3->codem1 = BADCODEM1; @@ -571,17 +571,17 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk db->max_ent = ++max_ent; if (db->lens) { - unsigned short *len1 = lens_ptr (db, max_ent); - unsigned short *len2 = lens_ptr (db, ent); + unsigned short *len1 = lens_ptr(db, max_ent); + unsigned short *len2 = lens_ptr(db, ent); *len1 = *len2 + 1; } } ent = c; } - + OUTPUT(ent); /* output the last code */ - if(skb_out) + if (skb_out) db->bytes_out += skb_out->len; /* Do not count bytes from here */ db->uncomp_bytes += isize; db->in_count += isize; @@ -596,15 +596,15 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk */ if (bsd_check(db)) - OUTPUT (CLEAR); + OUTPUT(CLEAR); /* * Pad dribble bits of last code with ones. * Do not emit a completely useless byte of ones. */ - if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0) - *(skb_put(skb_out,1)) = (unsigned char) ((accm | (0xff << (bitno-8))) >> 24); - + if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0) + *(skb_put(skb_out, 1)) = (unsigned char)((accm | (0xff << (bitno - 8))) >> 24); + /* * Increase code size if we would have without the packet * boundary because the decompressor will do so. @@ -613,7 +613,7 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk db->n_bits++; /* If output length is too large then this is an incompressible frame. */ - if (!skb_out || (skb_out && skb_out->len >= skb_in->len) ) { + if (!skb_out || (skb_out && skb_out->len >= skb_in->len)) { ++db->incomp_count; db->incomp_bytes += isize; return 0; @@ -631,16 +631,16 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk * Update the "BSD Compress" dictionary on the receiver for * incompressible data by pretending to compress the incoming data. */ -static void bsd_incomp (void *state, struct sk_buff *skb_in,int proto) +static void bsd_incomp(void *state, struct sk_buff *skb_in, int proto) { - bsd_compress (state, skb_in, NULL, proto); + bsd_compress(state, skb_in, NULL, proto); } /* * Decompress "BSD Compress". */ -static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, - struct isdn_ppp_resetparams *rsparm) +static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, + struct isdn_ppp_resetparams *rsparm) { struct bsd_db *db; unsigned int max_ent; @@ -653,7 +653,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * unsigned int incode; unsigned int oldcode; unsigned int finchar; - unsigned char *p,*ibuf; + unsigned char *p, *ibuf; int ilen; int codelen; int extra; @@ -667,20 +667,20 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * printk(KERN_DEBUG "bsd_decompress called\n"); - if(!skb_in || !skb_out) { + if (!skb_in || !skb_out) { printk(KERN_ERR "bsd_decompress called with NULL parameter\n"); return DECOMP_ERROR; } - + /* * Get the sequence number. */ - if( (p = skb_pull(skb_in,2)) == NULL) { + if ((p = skb_pull(skb_in, 2)) == NULL) { return DECOMP_ERROR; } - p-=2; - seq = (p[0] << 8) + p[1]; - ilen = skb_in->len; + p -= 2; + seq = (p[0] << 8) + p[1]; + ilen = skb_in->len; ibuf = skb_in->data; /* @@ -690,7 +690,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * if (seq != db->seqno) { if (db->debug) { printk(KERN_DEBUG "bsd_decomp%d: bad sequence # %d, expected %d\n", - db->unit, seq, db->seqno - 1); + db->unit, seq, db->seqno - 1); } return DECOMP_ERROR; } @@ -698,11 +698,11 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * ++db->seqno; db->bytes_out += ilen; - if(skb_tailroom(skb_out) > 0) - *(skb_put(skb_out,1)) = 0; + if (skb_tailroom(skb_out) > 0) + *(skb_put(skb_out, 1)) = 0; else return DECOMP_ERR_NOMEM; - + oldcode = CLEAR; /* @@ -734,7 +734,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * /* * The dictionary must only be cleared at the end of a packet. */ - + if (incode == CLEAR) { if (ilen > 0) { if (db->debug) @@ -746,16 +746,16 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * } if ((incode > max_ent + 2) || (incode > db->maxmaxcode) - || (incode > max_ent && oldcode == CLEAR)) { + || (incode > max_ent && oldcode == CLEAR)) { if (db->debug) { printk(KERN_DEBUG "bsd_decomp%d: bad code 0x%x oldcode=0x%x ", - db->unit, incode, oldcode); + db->unit, incode, oldcode); printk(KERN_DEBUG "max_ent=0x%x skb->Len=%d seqno=%d\n", - max_ent, skb_out->len, db->seqno); + max_ent, skb_out->len, db->seqno); } return DECOMP_FATALERROR; /* probably a bug */ } - + /* Special case for KwKwK string. */ if (incode > max_ent) { finchar = oldcode; @@ -765,13 +765,13 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * extra = 0; } - codelen = *(lens_ptr (db, finchar)); - if( skb_tailroom(skb_out) < codelen + extra) { + codelen = *(lens_ptr(db, finchar)); + if (skb_tailroom(skb_out) < codelen + extra) { if (db->debug) { printk(KERN_DEBUG "bsd_decomp%d: ran out of mru\n", db->unit); #ifdef DEBUG printk(KERN_DEBUG " len=%d, finchar=0x%x, codelen=%d,skblen=%d\n", - ilen, finchar, codelen, skb_out->len); + ilen, finchar, codelen, skb_out->len); #endif } return DECOMP_FATALERROR; @@ -781,21 +781,21 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * * Decode this code and install it in the decompressed buffer. */ - p = skb_put(skb_out,codelen); + p = skb_put(skb_out, codelen); p += codelen; while (finchar > LAST) { - struct bsd_dict *dictp2 = dict_ptr (db, finchar); - - dictp = dict_ptr (db, dictp2->cptr); + struct bsd_dict *dictp2 = dict_ptr(db, finchar); + + dictp = dict_ptr(db, dictp2->cptr); #ifdef DEBUG - if (--codelen <= 0 || dictp->codem1 != finchar-1) { + if (--codelen <= 0 || dictp->codem1 != finchar - 1) { if (codelen <= 0) { printk(KERN_ERR "bsd_decomp%d: fell off end of chain ", db->unit); printk(KERN_ERR "0x%x at 0x%x by 0x%x, max_ent=0x%x\n", incode, finchar, dictp2->cptr, max_ent); } else { - if (dictp->codem1 != finchar-1) { - printk(KERN_ERR "bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",db->unit, incode, finchar); + if (dictp->codem1 != finchar - 1) { + printk(KERN_ERR "bsd_decomp%d: bad code chain 0x%x finchar=0x%x ", db->unit, incode, finchar); printk(KERN_ERR "oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode, dictp2->cptr, dictp->codem1); } } @@ -810,15 +810,15 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * } } *--p = finchar; - + #ifdef DEBUG if (--codelen != 0) printk(KERN_ERR "bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n", db->unit, codelen, incode, max_ent); #endif - + if (extra) /* the KwKwK case again */ - *(skb_put(skb_out,1)) = finchar; - + *(skb_put(skb_out, 1)) = finchar; + /* * If not first code in a packet, and * if not out of code space, then allocate a new code. @@ -828,14 +828,14 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * */ if (oldcode != CLEAR && max_ent < db->maxmaxcode) { struct bsd_dict *dictp2, *dictp3; - u16 *lens1, *lens2; + u16 *lens1, *lens2; unsigned long fcode; int hval, disp, indx; - - fcode = BSD_KEY(oldcode,finchar); - hval = BSD_HASH(oldcode,finchar,db->hshift); - dictp = dict_ptr (db, hval); - + + fcode = BSD_KEY(oldcode, finchar); + hval = BSD_HASH(oldcode, finchar, db->hshift); + dictp = dict_ptr(db, hval); + /* look for a free hash table entry */ if (dictp->codem1 < max_ent) { disp = (hval == 0) ? 1 : hval; @@ -843,18 +843,18 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * hval += disp; if (hval >= db->hsize) hval -= db->hsize; - dictp = dict_ptr (db, hval); + dictp = dict_ptr(db, hval); } while (dictp->codem1 < max_ent); } - + /* * Invalidate previous hash table entry * assigned this code, and then take it over */ - dictp2 = dict_ptr (db, max_ent + 1); + dictp2 = dict_ptr(db, max_ent + 1); indx = dictp2->cptr; - dictp3 = dict_ptr (db, indx); + dictp3 = dict_ptr(db, indx); if (dictp3->codem1 == max_ent) dictp3->codem1 = BADCODEM1; @@ -865,10 +865,10 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * db->max_ent = ++max_ent; /* Update the length of this string. */ - lens1 = lens_ptr (db, max_ent); - lens2 = lens_ptr (db, oldcode); + lens1 = lens_ptr(db, max_ent); + lens2 = lens_ptr(db, oldcode); *lens1 = *lens2 + 1; - + /* Expand code size if needed. */ if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) { db->n_bits = ++n_bits; @@ -886,7 +886,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff * if (bsd_check(db)) { if (db->debug) printk(KERN_DEBUG "bsd_decomp%d: peer should have cleared dictionary on %d\n", - db->unit, db->seqno - 1); + db->unit, db->seqno - 1); } return skb_out->len; } @@ -914,15 +914,15 @@ static struct isdn_ppp_compressor ippp_bsd_compress = { static int __init isdn_bsdcomp_init(void) { - int answer = isdn_ppp_register_compressor (&ippp_bsd_compress); + int answer = isdn_ppp_register_compressor(&ippp_bsd_compress); if (answer == 0) - printk (KERN_INFO "PPP BSD Compression module registered\n"); + printk(KERN_INFO "PPP BSD Compression module registered\n"); return answer; } static void __exit isdn_bsdcomp_exit(void) { - isdn_ppp_unregister_compressor (&ippp_bsd_compress); + isdn_ppp_unregister_compressor(&ippp_bsd_compress); } module_init(isdn_bsdcomp_init); diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 6ddb795e31c5..d9f5524593fb 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -111,7 +111,7 @@ isdn_unlock_drivers(void) #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) void -isdn_dumppkt(char *s, u_char * p, int len, int dumplen) +isdn_dumppkt(char *s, u_char *p, int len, int dumplen) { int dumpc; @@ -163,58 +163,58 @@ isdn_wildmat(char *s, char *p) register int nostar = 1; if (!(*s) && !(*p)) - return(1); + return (1); for (; *p; s++, p++) switch (*p) { - case '\\': - /* - * Literal match with following character, - * fall through. - */ + case '\\': + /* + * Literal match with following character, + * fall through. + */ + p++; + default: + if (*s != *p) + return (*s == '\0') ? 2 : 1; + continue; + case '?': + /* Match anything. */ + if (*s == '\0') + return (2); + continue; + case '*': + nostar = 0; + /* Trailing star matches everything. */ + return (*++p ? isdn_star(s, p) : 0); + case '[': + /* [^....] means inverse character class. */ + if ((reverse = (p[1] == '^'))) p++; - default: - if (*s != *p) - return (*s == '\0')?2:1; - continue; - case '?': - /* Match anything. */ - if (*s == '\0') - return (2); - continue; - case '*': - nostar = 0; - /* Trailing star matches everything. */ - return (*++p ? isdn_star(s, p) : 0); - case '[': - /* [^....] means inverse character class. */ - if ((reverse = (p[1] == '^'))) - p++; - for (last = 0, matched = 0; *++p && (*p != ']'); last = *p) - /* This next line requires a good C compiler. */ - if (*p == '-' ? *s <= *++p && *s >= last : *s == *p) - matched = 1; - if (matched == reverse) - return (1); - continue; + for (last = 0, matched = 0; *++p && (*p != ']'); last = *p) + /* This next line requires a good C compiler. */ + if (*p == '-' ? *s <= *++p && *s >= last : *s == *p) + matched = 1; + if (matched == reverse) + return (1); + continue; } - return (*s == '\0')?0:nostar; + return (*s == '\0') ? 0 : nostar; } -int isdn_msncmp( const char * msn1, const char * msn2 ) +int isdn_msncmp(const char *msn1, const char *msn2) { - char TmpMsn1[ ISDN_MSNLEN ]; - char TmpMsn2[ ISDN_MSNLEN ]; + char TmpMsn1[ISDN_MSNLEN]; + char TmpMsn2[ISDN_MSNLEN]; char *p; - for ( p = TmpMsn1; *msn1 && *msn1 != ':'; ) // Strip off a SPID + for (p = TmpMsn1; *msn1 && *msn1 != ':';) // Strip off a SPID *p++ = *msn1++; *p = '\0'; - for ( p = TmpMsn2; *msn2 && *msn2 != ':'; ) // Strip off a SPID + for (p = TmpMsn2; *msn2 && *msn2 != ':';) // Strip off a SPID *p++ = *msn2++; *p = '\0'; - return isdn_wildmat( TmpMsn1, TmpMsn2 ); + return isdn_wildmat(TmpMsn1, TmpMsn2); } int @@ -262,8 +262,8 @@ isdn_timer_funct(ulong dummy) isdn_tty_carrier_timeout(); } } - if (tf) - mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES); + if (tf) + mod_timer(&dev->timer, jiffies + ISDN_TIMER_RES); } void @@ -284,7 +284,7 @@ isdn_timer_ctrl(int tf, int onoff) else dev->tflags &= ~tf; if (dev->tflags && !old_tflags) - mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES); + mod_timer(&dev->timer, jiffies + ISDN_TIMER_RES); spin_unlock_irqrestore(&dev->timerlock, flags); } @@ -302,7 +302,7 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) } /* Update statistics */ dev->ibytes[i] += skb->len; - + /* First, try to deliver data to network-device */ if (isdn_net_rcv_skb(i, skb)) return; @@ -339,40 +339,40 @@ isdn_command(isdn_ctrl *cmd) { if (cmd->driver == -1) { printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command); - return(1); + return (1); } if (!dev->drv[cmd->driver]) { printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d] NULL\n", - cmd->command, cmd->driver); - return(1); + cmd->command, cmd->driver); + return (1); } if (!dev->drv[cmd->driver]->interface) { printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d]->interface NULL\n", - cmd->command, cmd->driver); - return(1); + cmd->command, cmd->driver); + return (1); } if (cmd->command == ISDN_CMD_SETL2) { int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255); unsigned long l2prot = (cmd->arg >> 8) & 255; unsigned long features = (dev->drv[cmd->driver]->interface->features - >> ISDN_FEATURE_L2_SHIFT) & - ISDN_FEATURE_L2_MASK; + >> ISDN_FEATURE_L2_SHIFT) & + ISDN_FEATURE_L2_MASK; unsigned long l2_feature = (1 << l2prot); switch (l2prot) { - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: + case ISDN_PROTO_L2_V11096: + case ISDN_PROTO_L2_V11019: + case ISDN_PROTO_L2_V11038: /* If V.110 requested, but not supported by * HL-driver, set emulator-flag and change * Layer-2 to transparent */ - if (!(features & l2_feature)) { - dev->v110emu[idx] = l2prot; - cmd->arg = (cmd->arg & 255) | - (ISDN_PROTO_L2_TRANS << 8); - } else - dev->v110emu[idx] = 0; + if (!(features & l2_feature)) { + dev->v110emu[idx] = l2prot; + cmd->arg = (cmd->arg & 255) | + (ISDN_PROTO_L2_TRANS << 8); + } else + dev->v110emu[idx] = 0; } } return dev->drv[cmd->driver]->interface->command(cmd); @@ -393,7 +393,7 @@ isdn_all_eaz(int di, int ch) } /* - * Begin of a CAPI like LL<->HL interface, currently used only for + * Begin of a CAPI like LL<->HL interface, currently used only for * supplementary service (CAPI 2.0 part III) */ #include @@ -401,17 +401,17 @@ isdn_all_eaz(int di, int ch) static int isdn_capi_rec_hl_msg(capi_msg *cm) { - switch(cm->Command) { - case CAPI_FACILITY: - /* in the moment only handled in tty */ - return(isdn_tty_capi_facility(cm)); - default: - return(-1); + switch (cm->Command) { + case CAPI_FACILITY: + /* in the moment only handled in tty */ + return (isdn_tty_capi_facility(cm)); + default: + return (-1); } } static int -isdn_status_callback(isdn_ctrl * c) +isdn_status_callback(isdn_ctrl *c) { int di; u_long flags; @@ -424,314 +424,314 @@ isdn_status_callback(isdn_ctrl * c) di = c->driver; i = isdn_dc2minor(di, c->arg); switch (c->command) { - case ISDN_STAT_BSENT: - if (i < 0) - return -1; - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - if (isdn_net_stat_callback(i, c)) - return 0; - if (isdn_v110_stat_callback(i, c)) - return 0; - if (isdn_tty_stat_callback(i, c)) - return 0; - wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]); - break; - case ISDN_STAT_STAVAIL: - dev->drv[di]->stavail += c->arg; - wake_up_interruptible(&dev->drv[di]->st_waitq); - break; - case ISDN_STAT_RUN: - dev->drv[di]->flags |= DRV_FLAG_RUNNING; - for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (dev->drvmap[i] == di) - isdn_all_eaz(di, dev->chanmap[i]); - set_global_features(); - break; - case ISDN_STAT_STOP: - dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; - break; - case ISDN_STAT_ICALL: - if (i < 0) - return -1; + case ISDN_STAT_BSENT: + if (i < 0) + return -1; + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + if (isdn_net_stat_callback(i, c)) + return 0; + if (isdn_v110_stat_callback(i, c)) + return 0; + if (isdn_tty_stat_callback(i, c)) + return 0; + wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]); + break; + case ISDN_STAT_STAVAIL: + dev->drv[di]->stavail += c->arg; + wake_up_interruptible(&dev->drv[di]->st_waitq); + break; + case ISDN_STAT_RUN: + dev->drv[di]->flags |= DRV_FLAG_RUNNING; + for (i = 0; i < ISDN_MAX_CHANNELS; i++) + if (dev->drvmap[i] == di) + isdn_all_eaz(di, dev->chanmap[i]); + set_global_features(); + break; + case ISDN_STAT_STOP: + dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; + break; + case ISDN_STAT_ICALL: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "ICALL (net): %d %ld %s\n", di, c->arg, c->parm.num); + printk(KERN_DEBUG "ICALL (net): %d %ld %s\n", di, c->arg, c->parm.num); #endif - if (dev->global_flags & ISDN_GLOBAL_STOPPED) { + if (dev->global_flags & ISDN_GLOBAL_STOPPED) { + cmd.driver = di; + cmd.arg = c->arg; + cmd.command = ISDN_CMD_HANGUP; + isdn_command(&cmd); + return 0; + } + /* Try to find a network-interface which will accept incoming call */ + r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup)); + switch (r) { + case 0: + /* No network-device replies. + * Try ttyI's. + * These return 0 on no match, 1 on match and + * 3 on eventually match, if CID is longer. + */ + if (c->command == ISDN_STAT_ICALL) + if ((retval = isdn_tty_find_icall(di, c->arg, &c->parm.setup))) return (retval); +#ifdef CONFIG_ISDN_DIVERSION + if (divert_if) + if ((retval = divert_if->stat_callback(c))) + return (retval); /* processed */ +#endif /* CONFIG_ISDN_DIVERSION */ + if ((!retval) && (dev->drv[di]->flags & DRV_FLAG_REJBUS)) { + /* No tty responding */ cmd.driver = di; cmd.arg = c->arg; cmd.command = ISDN_CMD_HANGUP; isdn_command(&cmd); - return 0; + retval = 2; } - /* Try to find a network-interface which will accept incoming call */ - r = ((c->command == ISDN_STAT_ICALLW) ? 0 : isdn_net_find_icall(di, c->arg, i, &c->parm.setup)); - switch (r) { - case 0: - /* No network-device replies. - * Try ttyI's. - * These return 0 on no match, 1 on match and - * 3 on eventually match, if CID is longer. - */ - if (c->command == ISDN_STAT_ICALL) - if ((retval = isdn_tty_find_icall(di, c->arg, &c->parm.setup))) return(retval); -#ifdef CONFIG_ISDN_DIVERSION - if (divert_if) - if ((retval = divert_if->stat_callback(c))) - return(retval); /* processed */ -#endif /* CONFIG_ISDN_DIVERSION */ - if ((!retval) && (dev->drv[di]->flags & DRV_FLAG_REJBUS)) { - /* No tty responding */ - cmd.driver = di; - cmd.arg = c->arg; - cmd.command = ISDN_CMD_HANGUP; - isdn_command(&cmd); - retval = 2; - } - break; - case 1: - /* Schedule connection-setup */ - isdn_net_dial(); - cmd.driver = di; - cmd.arg = c->arg; - cmd.command = ISDN_CMD_ACCEPTD; - for ( p = dev->netdev; p; p = p->next ) - if ( p->local->isdn_channel == cmd.arg ) - { - strcpy( cmd.parm.setup.eazmsn, p->local->msn ); - isdn_command(&cmd); - retval = 1; - break; - } - break; - - case 2: /* For calling back, first reject incoming call ... */ - case 3: /* Interface found, but down, reject call actively */ - retval = 2; - printk(KERN_INFO "isdn: Rejecting Call\n"); - cmd.driver = di; - cmd.arg = c->arg; - cmd.command = ISDN_CMD_HANGUP; + break; + case 1: + /* Schedule connection-setup */ + isdn_net_dial(); + cmd.driver = di; + cmd.arg = c->arg; + cmd.command = ISDN_CMD_ACCEPTD; + for (p = dev->netdev; p; p = p->next) + if (p->local->isdn_channel == cmd.arg) + { + strcpy(cmd.parm.setup.eazmsn, p->local->msn); isdn_command(&cmd); - if (r == 3) - break; - /* Fall through */ - case 4: - /* ... then start callback. */ - isdn_net_dial(); - break; - case 5: - /* Number would eventually match, if longer */ - retval = 3; + retval = 1; break; - } + } + break; + + case 2: /* For calling back, first reject incoming call ... */ + case 3: /* Interface found, but down, reject call actively */ + retval = 2; + printk(KERN_INFO "isdn: Rejecting Call\n"); + cmd.driver = di; + cmd.arg = c->arg; + cmd.command = ISDN_CMD_HANGUP; + isdn_command(&cmd); + if (r == 3) + break; + /* Fall through */ + case 4: + /* ... then start callback. */ + isdn_net_dial(); + break; + case 5: + /* Number would eventually match, if longer */ + retval = 3; + break; + } #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "ICALL: ret=%d\n", retval); + printk(KERN_DEBUG "ICALL: ret=%d\n", retval); #endif - return retval; - break; - case ISDN_STAT_CINF: - if (i < 0) - return -1; + return retval; + break; + case ISDN_STAT_CINF: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "CINF: %ld %s\n", c->arg, c->parm.num); + printk(KERN_DEBUG "CINF: %ld %s\n", c->arg, c->parm.num); #endif - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - if (strcmp(c->parm.num, "0")) - isdn_net_stat_callback(i, c); - isdn_tty_stat_callback(i, c); - break; - case ISDN_STAT_CAUSE: + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + if (strcmp(c->parm.num, "0")) + isdn_net_stat_callback(i, c); + isdn_tty_stat_callback(i, c); + break; + case ISDN_STAT_CAUSE: #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "CAUSE: %ld %s\n", c->arg, c->parm.num); + printk(KERN_DEBUG "CAUSE: %ld %s\n", c->arg, c->parm.num); #endif - printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", - dev->drvid[di], c->arg, c->parm.num); - isdn_tty_stat_callback(i, c); + printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", + dev->drvid[di], c->arg, c->parm.num); + isdn_tty_stat_callback(i, c); #ifdef CONFIG_ISDN_DIVERSION - if (divert_if) - divert_if->stat_callback(c); + if (divert_if) + divert_if->stat_callback(c); #endif /* CONFIG_ISDN_DIVERSION */ - break; - case ISDN_STAT_DISPLAY: + break; + case ISDN_STAT_DISPLAY: #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "DISPLAY: %ld %s\n", c->arg, c->parm.display); + printk(KERN_DEBUG "DISPLAY: %ld %s\n", c->arg, c->parm.display); #endif - isdn_tty_stat_callback(i, c); + isdn_tty_stat_callback(i, c); #ifdef CONFIG_ISDN_DIVERSION - if (divert_if) - divert_if->stat_callback(c); + if (divert_if) + divert_if->stat_callback(c); #endif /* CONFIG_ISDN_DIVERSION */ - break; - case ISDN_STAT_DCONN: - if (i < 0) - return -1; + break; + case ISDN_STAT_DCONN: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "DCONN: %ld\n", c->arg); + printk(KERN_DEBUG "DCONN: %ld\n", c->arg); #endif - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - /* Find any net-device, waiting for D-channel setup */ - if (isdn_net_stat_callback(i, c)) - break; - isdn_v110_stat_callback(i, c); - /* Find any ttyI, waiting for D-channel setup */ - if (isdn_tty_stat_callback(i, c)) { - cmd.driver = di; - cmd.arg = c->arg; - cmd.command = ISDN_CMD_ACCEPTB; - isdn_command(&cmd); - break; - } + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + /* Find any net-device, waiting for D-channel setup */ + if (isdn_net_stat_callback(i, c)) break; - case ISDN_STAT_DHUP: - if (i < 0) - return -1; + isdn_v110_stat_callback(i, c); + /* Find any ttyI, waiting for D-channel setup */ + if (isdn_tty_stat_callback(i, c)) { + cmd.driver = di; + cmd.arg = c->arg; + cmd.command = ISDN_CMD_ACCEPTB; + isdn_command(&cmd); + break; + } + break; + case ISDN_STAT_DHUP: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "DHUP: %ld\n", c->arg); + printk(KERN_DEBUG "DHUP: %ld\n", c->arg); #endif - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - dev->drv[di]->online &= ~(1 << (c->arg)); - isdn_info_update(); - /* Signal hangup to network-devices */ - if (isdn_net_stat_callback(i, c)) - break; - isdn_v110_stat_callback(i, c); - if (isdn_tty_stat_callback(i, c)) - break; -#ifdef CONFIG_ISDN_DIVERSION - if (divert_if) - divert_if->stat_callback(c); -#endif /* CONFIG_ISDN_DIVERSION */ + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + dev->drv[di]->online &= ~(1 << (c->arg)); + isdn_info_update(); + /* Signal hangup to network-devices */ + if (isdn_net_stat_callback(i, c)) break; + isdn_v110_stat_callback(i, c); + if (isdn_tty_stat_callback(i, c)) break; - case ISDN_STAT_BCONN: - if (i < 0) - return -1; +#ifdef CONFIG_ISDN_DIVERSION + if (divert_if) + divert_if->stat_callback(c); +#endif /* CONFIG_ISDN_DIVERSION */ + break; + break; + case ISDN_STAT_BCONN: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "BCONN: %ld\n", c->arg); + printk(KERN_DEBUG "BCONN: %ld\n", c->arg); #endif - /* Signal B-channel-connect to network-devices */ - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - dev->drv[di]->online |= (1 << (c->arg)); - isdn_info_update(); - if (isdn_net_stat_callback(i, c)) - break; - isdn_v110_stat_callback(i, c); - if (isdn_tty_stat_callback(i, c)) - break; + /* Signal B-channel-connect to network-devices */ + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + dev->drv[di]->online |= (1 << (c->arg)); + isdn_info_update(); + if (isdn_net_stat_callback(i, c)) + break; + isdn_v110_stat_callback(i, c); + if (isdn_tty_stat_callback(i, c)) break; - case ISDN_STAT_BHUP: - if (i < 0) - return -1; + break; + case ISDN_STAT_BHUP: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "BHUP: %ld\n", c->arg); + printk(KERN_DEBUG "BHUP: %ld\n", c->arg); #endif - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - dev->drv[di]->online &= ~(1 << (c->arg)); - isdn_info_update(); + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + dev->drv[di]->online &= ~(1 << (c->arg)); + isdn_info_update(); #ifdef CONFIG_ISDN_X25 - /* Signal hangup to network-devices */ - if (isdn_net_stat_callback(i, c)) - break; + /* Signal hangup to network-devices */ + if (isdn_net_stat_callback(i, c)) + break; #endif - isdn_v110_stat_callback(i, c); - if (isdn_tty_stat_callback(i, c)) - break; + isdn_v110_stat_callback(i, c); + if (isdn_tty_stat_callback(i, c)) break; - case ISDN_STAT_NODCH: - if (i < 0) - return -1; + break; + case ISDN_STAT_NODCH: + if (i < 0) + return -1; #ifdef ISDN_DEBUG_STATCALLB - printk(KERN_DEBUG "NODCH: %ld\n", c->arg); + printk(KERN_DEBUG "NODCH: %ld\n", c->arg); #endif - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - return 0; - if (isdn_net_stat_callback(i, c)) - break; - if (isdn_tty_stat_callback(i, c)) - break; + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + return 0; + if (isdn_net_stat_callback(i, c)) break; - case ISDN_STAT_ADDCH: - spin_lock_irqsave(&dev->lock, flags); - if (isdn_add_channels(dev->drv[di], di, c->arg, 1)) { - spin_unlock_irqrestore(&dev->lock, flags); - return -1; - } - spin_unlock_irqrestore(&dev->lock, flags); - isdn_info_update(); + if (isdn_tty_stat_callback(i, c)) break; - case ISDN_STAT_DISCH: - spin_lock_irqsave(&dev->lock, flags); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if ((dev->drvmap[i] == di) && - (dev->chanmap[i] == c->arg)) { - if (c->parm.num[0]) - dev->usage[i] &= ~ISDN_USAGE_DISABLED; - else - if (USG_NONE(dev->usage[i])) { - dev->usage[i] |= ISDN_USAGE_DISABLED; - } - else - retval = -1; - break; - } + break; + case ISDN_STAT_ADDCH: + spin_lock_irqsave(&dev->lock, flags); + if (isdn_add_channels(dev->drv[di], di, c->arg, 1)) { spin_unlock_irqrestore(&dev->lock, flags); - isdn_info_update(); - break; - case ISDN_STAT_UNLOAD: - while (dev->drv[di]->locks > 0) { - isdn_unlock_driver(dev->drv[di]); - } - spin_lock_irqsave(&dev->lock, flags); - isdn_tty_stat_callback(i, c); - for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (dev->drvmap[i] == di) { - dev->drvmap[i] = -1; - dev->chanmap[i] = -1; + return -1; + } + spin_unlock_irqrestore(&dev->lock, flags); + isdn_info_update(); + break; + case ISDN_STAT_DISCH: + spin_lock_irqsave(&dev->lock, flags); + for (i = 0; i < ISDN_MAX_CHANNELS; i++) + if ((dev->drvmap[i] == di) && + (dev->chanmap[i] == c->arg)) { + if (c->parm.num[0]) dev->usage[i] &= ~ISDN_USAGE_DISABLED; - } - dev->drivers--; - dev->channels -= dev->drv[di]->channels; - kfree(dev->drv[di]->rcverr); - kfree(dev->drv[di]->rcvcount); - for (i = 0; i < dev->drv[di]->channels; i++) - skb_queue_purge(&dev->drv[di]->rpqueue[i]); - kfree(dev->drv[di]->rpqueue); - kfree(dev->drv[di]->rcv_waitq); - kfree(dev->drv[di]); - dev->drv[di] = NULL; - dev->drvid[di][0] = '\0'; - isdn_info_update(); - set_global_features(); - spin_unlock_irqrestore(&dev->lock, flags); - return 0; - case ISDN_STAT_L1ERR: - break; - case CAPI_PUT_MESSAGE: - return(isdn_capi_rec_hl_msg(&c->parm.cmsg)); + else + if (USG_NONE(dev->usage[i])) { + dev->usage[i] |= ISDN_USAGE_DISABLED; + } + else + retval = -1; + break; + } + spin_unlock_irqrestore(&dev->lock, flags); + isdn_info_update(); + break; + case ISDN_STAT_UNLOAD: + while (dev->drv[di]->locks > 0) { + isdn_unlock_driver(dev->drv[di]); + } + spin_lock_irqsave(&dev->lock, flags); + isdn_tty_stat_callback(i, c); + for (i = 0; i < ISDN_MAX_CHANNELS; i++) + if (dev->drvmap[i] == di) { + dev->drvmap[i] = -1; + dev->chanmap[i] = -1; + dev->usage[i] &= ~ISDN_USAGE_DISABLED; + } + dev->drivers--; + dev->channels -= dev->drv[di]->channels; + kfree(dev->drv[di]->rcverr); + kfree(dev->drv[di]->rcvcount); + for (i = 0; i < dev->drv[di]->channels; i++) + skb_queue_purge(&dev->drv[di]->rpqueue[i]); + kfree(dev->drv[di]->rpqueue); + kfree(dev->drv[di]->rcv_waitq); + kfree(dev->drv[di]); + dev->drv[di] = NULL; + dev->drvid[di][0] = '\0'; + isdn_info_update(); + set_global_features(); + spin_unlock_irqrestore(&dev->lock, flags); + return 0; + case ISDN_STAT_L1ERR: + break; + case CAPI_PUT_MESSAGE: + return (isdn_capi_rec_hl_msg(&c->parm.cmsg)); #ifdef CONFIG_ISDN_TTY_FAX - case ISDN_STAT_FAXIND: - isdn_tty_stat_callback(i, c); - break; + case ISDN_STAT_FAXIND: + isdn_tty_stat_callback(i, c); + break; #endif #ifdef CONFIG_ISDN_AUDIO - case ISDN_STAT_AUDIO: - isdn_tty_stat_callback(i, c); - break; + case ISDN_STAT_AUDIO: + isdn_tty_stat_callback(i, c); + break; #endif #ifdef CONFIG_ISDN_DIVERSION - case ISDN_STAT_PROT: - case ISDN_STAT_REDIR: - if (divert_if) - return(divert_if->stat_callback(c)); + case ISDN_STAT_PROT: + case ISDN_STAT_REDIR: + if (divert_if) + return (divert_if->stat_callback(c)); #endif /* CONFIG_ISDN_DIVERSION */ - default: - return -1; + default: + return -1; } return 0; } @@ -755,17 +755,17 @@ isdn_getnum(char **p) * isdn_readbchan() tries to get data from the read-queue. * It MUST be called with interrupts off. * - * Be aware that this is not an atomic operation when sleep != 0, even though + * Be aware that this is not an atomic operation when sleep != 0, even though * interrupts are turned off! Well, like that we are currently only called * on behalf of a read system call on raw device files (which are documented * to be dangerous and for debugging purpose only). The inode semaphore * takes care that this is not called for the same minor device number while * we are sleeping, but access is not serialized against simultaneous read() * from the corresponding ttyI device. Can other ugly events, like changes - * of the mapping (di,ch)<->minor, happen during the sleep? --he + * of the mapping (di,ch)<->minor, happen during the sleep? --he */ int -isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_queue_head_t *sleep) +isdn_readbchan(int di, int channel, u_char *buf, u_char *fp, int len, wait_queue_head_t *sleep) { int count; int count_pull; @@ -890,10 +890,10 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) if (!dev->drv[di]) return 0; if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) - return 0; + return 0; len = tty_buffer_request_room(tty, dev->drv[di]->rcvcount[channel]); - if(len == 0) + if (len == 0) return len; count = 0; @@ -912,7 +912,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) count_pull = count_put = 0; while ((count_pull < skb->len) && (len > 0)) { /* push every character but the last to the tty buffer directly */ - if ( count_put ) + if (count_put) tty_insert_flip_char(tty, last, TTY_NORMAL); len--; if (dev->drv[di]->DLEflag & DLEmask) { @@ -940,7 +940,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) dflag = 0; } count_put = count_pull; - if(count_put > 1) + if (count_put > 1) tty_insert_flip_string(tty, skb->data, count_put - 1); last = skb->data[count_put - 1]; len -= count_put; @@ -952,7 +952,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack) /* We got all the data in this buff. * Now we can dequeue it. */ - if(cisco_hack) + if (cisco_hack) tty_insert_flip_char(tty, last, 0xFF); else tty_insert_flip_char(tty, last, TTY_NORMAL); @@ -1057,7 +1057,7 @@ isdn_info_update(void) } static ssize_t -isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) +isdn_read(struct file *file, char __user *buf, size_t count, loff_t *off) { uint minor = iminor(file->f_path.dentry->d_inode); int len = 0; @@ -1112,7 +1112,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) len = isdn_readbchan(drvidx, chidx, p, NULL, count, &dev->drv[drvidx]->rcv_waitq[chidx]); *off += len; - if (copy_to_user(buf,p,len)) + if (copy_to_user(buf, p, len)) len = -EFAULT; kfree(p); retval = len; @@ -1135,7 +1135,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) if (count > dev->drv[drvidx]->stavail) count = dev->drv[drvidx]->stavail; len = dev->drv[drvidx]->interface->readstat(buf, count, - drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL)); + drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL)); if (len < 0) { retval = len; goto out; @@ -1158,13 +1158,13 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off) } #endif retval = -ENODEV; - out: +out: mutex_unlock(&isdn_mutex); return retval; } static ssize_t -isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off) +isdn_write(struct file *file, const char __user *buf, size_t count, loff_t *off) { uint minor = iminor(file->f_path.dentry->d_inode); int drvidx; @@ -1204,11 +1204,11 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off * if (!(dev->drv[drvidx]->flags & DRV_FLAG_RUNNING)) return -ENODEV; - */ + */ if (dev->drv[drvidx]->interface->writecmd) retval = dev->drv[drvidx]->interface-> writecmd(buf, count, drvidx, - isdn_minor2chan(minor - ISDN_MINOR_CTRL)); + isdn_minor2chan(minor - ISDN_MINOR_CTRL)); else retval = count; goto out; @@ -1220,13 +1220,13 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off } #endif retval = -ENODEV; - out: +out: mutex_unlock(&isdn_mutex); return retval; } static unsigned int -isdn_poll(struct file *file, poll_table * wait) +isdn_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; unsigned int minor = iminor(file->f_path.dentry->d_inode); @@ -1261,7 +1261,7 @@ isdn_poll(struct file *file, poll_table * wait) } #endif mask = POLLERR; - out: +out: mutex_unlock(&isdn_mutex); return mask; } @@ -1294,38 +1294,38 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg) if (minor == ISDN_MINOR_STATUS) { switch (cmd) { - case IIOCGETDVR: - return (TTY_DV + - (NET_DV << 8) + - (INF_DV << 16)); - case IIOCGETCPS: - if (arg) { - ulong __user *p = argp; - int i; - if (!access_ok(VERIFY_WRITE, p, - sizeof(ulong) * ISDN_MAX_CHANNELS * 2)) - return -EFAULT; - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - put_user(dev->ibytes[i], p++); - put_user(dev->obytes[i], p++); - } - return 0; - } else - return -EINVAL; - break; + case IIOCGETDVR: + return (TTY_DV + + (NET_DV << 8) + + (INF_DV << 16)); + case IIOCGETCPS: + if (arg) { + ulong __user *p = argp; + int i; + if (!access_ok(VERIFY_WRITE, p, + sizeof(ulong) * ISDN_MAX_CHANNELS * 2)) + return -EFAULT; + for (i = 0; i < ISDN_MAX_CHANNELS; i++) { + put_user(dev->ibytes[i], p++); + put_user(dev->obytes[i], p++); + } + return 0; + } else + return -EINVAL; + break; #ifdef CONFIG_NETDEVICES - case IIOCNETGPN: - /* Get peer phone number of a connected - * isdn network interface */ - if (arg) { - if (copy_from_user(&phone, argp, sizeof(phone))) - return -EFAULT; - return isdn_net_getpeer(&phone, argp); - } else - return -EINVAL; -#endif - default: + case IIOCNETGPN: + /* Get peer phone number of a connected + * isdn network interface */ + if (arg) { + if (copy_from_user(&phone, argp, sizeof(phone))) + return -EFAULT; + return isdn_net_getpeer(&phone, argp); + } else return -EINVAL; +#endif + default: + return -EINVAL; } } if (!dev->drivers) @@ -1347,360 +1347,360 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg) * are serialized by means of a semaphore. */ switch (cmd) { - case IIOCNETDWRSET: - printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n"); - return(-EINVAL); - case IIOCNETLCR: - printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); - return -ENODEV; + case IIOCNETDWRSET: + printk(KERN_INFO "INFO: ISDN_DW_ABC_EXTENSION not enabled\n"); + return (-EINVAL); + case IIOCNETLCR: + printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); + return -ENODEV; #ifdef CONFIG_NETDEVICES - case IIOCNETAIF: - /* Add a network-interface */ - if (arg) { - if (copy_from_user(name, argp, sizeof(name))) - return -EFAULT; - s = name; + case IIOCNETAIF: + /* Add a network-interface */ + if (arg) { + if (copy_from_user(name, argp, sizeof(name))) + return -EFAULT; + s = name; + } else { + s = NULL; + } + ret = mutex_lock_interruptible(&dev->mtx); + if (ret) return ret; + if ((s = isdn_net_new(s, NULL))) { + if (copy_to_user(argp, s, strlen(s) + 1)) { + ret = -EFAULT; + } else { + ret = 0; + } + } else + ret = -ENODEV; + mutex_unlock(&dev->mtx); + return ret; + case IIOCNETASL: + /* Add a slave to a network-interface */ + if (arg) { + if (copy_from_user(bname, argp, sizeof(bname) - 1)) + return -EFAULT; + } else + return -EINVAL; + ret = mutex_lock_interruptible(&dev->mtx); + if (ret) return ret; + if ((s = isdn_net_newslave(bname))) { + if (copy_to_user(argp, s, strlen(s) + 1)) { + ret = -EFAULT; } else { - s = NULL; + ret = 0; } + } else + ret = -ENODEV; + mutex_unlock(&dev->mtx); + return ret; + case IIOCNETDIF: + /* Delete a network-interface */ + if (arg) { + if (copy_from_user(name, argp, sizeof(name))) + return -EFAULT; ret = mutex_lock_interruptible(&dev->mtx); - if( ret ) return ret; - if ((s = isdn_net_new(s, NULL))) { - if (copy_to_user(argp, s, strlen(s) + 1)){ - ret = -EFAULT; - } else { - ret = 0; - } - } else - ret = -ENODEV; + if (ret) return ret; + ret = isdn_net_rm(name); mutex_unlock(&dev->mtx); return ret; - case IIOCNETASL: - /* Add a slave to a network-interface */ - if (arg) { - if (copy_from_user(bname, argp, sizeof(bname) - 1)) + } else + return -EINVAL; + case IIOCNETSCF: + /* Set configurable parameters of a network-interface */ + if (arg) { + if (copy_from_user(&cfg, argp, sizeof(cfg))) + return -EFAULT; + return isdn_net_setcfg(&cfg); + } else + return -EINVAL; + case IIOCNETGCF: + /* Get configurable parameters of a network-interface */ + if (arg) { + if (copy_from_user(&cfg, argp, sizeof(cfg))) + return -EFAULT; + if (!(ret = isdn_net_getcfg(&cfg))) { + if (copy_to_user(argp, &cfg, sizeof(cfg))) return -EFAULT; - } else - return -EINVAL; + } + return ret; + } else + return -EINVAL; + case IIOCNETANM: + /* Add a phone-number to a network-interface */ + if (arg) { + if (copy_from_user(&phone, argp, sizeof(phone))) + return -EFAULT; ret = mutex_lock_interruptible(&dev->mtx); - if( ret ) return ret; - if ((s = isdn_net_newslave(bname))) { - if (copy_to_user(argp, s, strlen(s) + 1)){ - ret = -EFAULT; - } else { - ret = 0; - } - } else - ret = -ENODEV; + if (ret) return ret; + ret = isdn_net_addphone(&phone); mutex_unlock(&dev->mtx); return ret; - case IIOCNETDIF: - /* Delete a network-interface */ - if (arg) { - if (copy_from_user(name, argp, sizeof(name))) - return -EFAULT; - ret = mutex_lock_interruptible(&dev->mtx); - if( ret ) return ret; - ret = isdn_net_rm(name); - mutex_unlock(&dev->mtx); - return ret; - } else - return -EINVAL; - case IIOCNETSCF: - /* Set configurable parameters of a network-interface */ - if (arg) { - if (copy_from_user(&cfg, argp, sizeof(cfg))) - return -EFAULT; - return isdn_net_setcfg(&cfg); - } else - return -EINVAL; - case IIOCNETGCF: - /* Get configurable parameters of a network-interface */ - if (arg) { - if (copy_from_user(&cfg, argp, sizeof(cfg))) - return -EFAULT; - if (!(ret = isdn_net_getcfg(&cfg))) { - if (copy_to_user(argp, &cfg, sizeof(cfg))) - return -EFAULT; - } - return ret; - } else - return -EINVAL; - case IIOCNETANM: - /* Add a phone-number to a network-interface */ - if (arg) { - if (copy_from_user(&phone, argp, sizeof(phone))) - return -EFAULT; - ret = mutex_lock_interruptible(&dev->mtx); - if( ret ) return ret; - ret = isdn_net_addphone(&phone); - mutex_unlock(&dev->mtx); - return ret; - } else - return -EINVAL; - case IIOCNETGNM: - /* Get list of phone-numbers of a network-interface */ - if (arg) { - if (copy_from_user(&phone, argp, sizeof(phone))) - return -EFAULT; - ret = mutex_lock_interruptible(&dev->mtx); - if( ret ) return ret; - ret = isdn_net_getphones(&phone, argp); - mutex_unlock(&dev->mtx); - return ret; - } else - return -EINVAL; - case IIOCNETDNM: - /* Delete a phone-number of a network-interface */ - if (arg) { - if (copy_from_user(&phone, argp, sizeof(phone))) - return -EFAULT; - ret = mutex_lock_interruptible(&dev->mtx); - if( ret ) return ret; - ret = isdn_net_delphone(&phone); - mutex_unlock(&dev->mtx); - return ret; - } else - return -EINVAL; - case IIOCNETDIL: - /* Force dialing of a network-interface */ - if (arg) { - if (copy_from_user(name, argp, sizeof(name))) - return -EFAULT; - return isdn_net_force_dial(name); - } else - return -EINVAL; -#ifdef CONFIG_ISDN_PPP - case IIOCNETALN: - if (!arg) - return -EINVAL; - if (copy_from_user(name, argp, sizeof(name))) + } else + return -EINVAL; + case IIOCNETGNM: + /* Get list of phone-numbers of a network-interface */ + if (arg) { + if (copy_from_user(&phone, argp, sizeof(phone))) return -EFAULT; - return isdn_ppp_dial_slave(name); - case IIOCNETDLN: - if (!arg) - return -EINVAL; - if (copy_from_user(name, argp, sizeof(name))) + ret = mutex_lock_interruptible(&dev->mtx); + if (ret) return ret; + ret = isdn_net_getphones(&phone, argp); + mutex_unlock(&dev->mtx); + return ret; + } else + return -EINVAL; + case IIOCNETDNM: + /* Delete a phone-number of a network-interface */ + if (arg) { + if (copy_from_user(&phone, argp, sizeof(phone))) return -EFAULT; - return isdn_ppp_hangup_slave(name); -#endif - case IIOCNETHUP: - /* Force hangup of a network-interface */ - if (!arg) - return -EINVAL; + ret = mutex_lock_interruptible(&dev->mtx); + if (ret) return ret; + ret = isdn_net_delphone(&phone); + mutex_unlock(&dev->mtx); + return ret; + } else + return -EINVAL; + case IIOCNETDIL: + /* Force dialing of a network-interface */ + if (arg) { if (copy_from_user(name, argp, sizeof(name))) return -EFAULT; - return isdn_net_force_hangup(name); - break; + return isdn_net_force_dial(name); + } else + return -EINVAL; +#ifdef CONFIG_ISDN_PPP + case IIOCNETALN: + if (!arg) + return -EINVAL; + if (copy_from_user(name, argp, sizeof(name))) + return -EFAULT; + return isdn_ppp_dial_slave(name); + case IIOCNETDLN: + if (!arg) + return -EINVAL; + if (copy_from_user(name, argp, sizeof(name))) + return -EFAULT; + return isdn_ppp_hangup_slave(name); +#endif + case IIOCNETHUP: + /* Force hangup of a network-interface */ + if (!arg) + return -EINVAL; + if (copy_from_user(name, argp, sizeof(name))) + return -EFAULT; + return isdn_net_force_hangup(name); + break; #endif /* CONFIG_NETDEVICES */ - case IIOCSETVER: - dev->net_verbose = arg; - printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose); - return 0; - case IIOCSETGST: - if (arg) - dev->global_flags |= ISDN_GLOBAL_STOPPED; - else - dev->global_flags &= ~ISDN_GLOBAL_STOPPED; - printk(KERN_INFO "isdn: Global Mode %s\n", - (dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running"); - return 0; - case IIOCSETBRJ: - drvidx = -1; - if (arg) { - int i; - char *p; - if (copy_from_user(&iocts, argp, - sizeof(isdn_ioctl_struct))) - return -EFAULT; - iocts.drvid[sizeof(iocts.drvid)-1] = 0; - if (strlen(iocts.drvid)) { - if ((p = strchr(iocts.drvid, ','))) - *p = 0; - drvidx = -1; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - if (!(strcmp(dev->drvid[i], iocts.drvid))) { - drvidx = i; - break; - } - } + case IIOCSETVER: + dev->net_verbose = arg; + printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose); + return 0; + case IIOCSETGST: + if (arg) + dev->global_flags |= ISDN_GLOBAL_STOPPED; + else + dev->global_flags &= ~ISDN_GLOBAL_STOPPED; + printk(KERN_INFO "isdn: Global Mode %s\n", + (dev->global_flags & ISDN_GLOBAL_STOPPED) ? "stopped" : "running"); + return 0; + case IIOCSETBRJ: + drvidx = -1; + if (arg) { + int i; + char *p; + if (copy_from_user(&iocts, argp, + sizeof(isdn_ioctl_struct))) + return -EFAULT; + iocts.drvid[sizeof(iocts.drvid) - 1] = 0; + if (strlen(iocts.drvid)) { + if ((p = strchr(iocts.drvid, ','))) + *p = 0; + drvidx = -1; + for (i = 0; i < ISDN_MAX_DRIVERS; i++) + if (!(strcmp(dev->drvid[i], iocts.drvid))) { + drvidx = i; + break; + } } - if (drvidx == -1) - return -ENODEV; - if (iocts.arg) - dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS; - else - dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS; - return 0; - case IIOCSIGPRF: - dev->profd = current; - return 0; - break; - case IIOCGETPRF: - /* Get all Modem-Profiles */ - if (arg) { - char __user *p = argp; - int i; - - if (!access_ok(VERIFY_WRITE, argp, - (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) - * ISDN_MAX_CHANNELS)) + } + if (drvidx == -1) + return -ENODEV; + if (iocts.arg) + dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS; + else + dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS; + return 0; + case IIOCSIGPRF: + dev->profd = current; + return 0; + break; + case IIOCGETPRF: + /* Get all Modem-Profiles */ + if (arg) { + char __user *p = argp; + int i; + + if (!access_ok(VERIFY_WRITE, argp, + (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) + * ISDN_MAX_CHANNELS)) + return -EFAULT; + + for (i = 0; i < ISDN_MAX_CHANNELS; i++) { + if (copy_to_user(p, dev->mdm.info[i].emu.profile, + ISDN_MODEM_NUMREG)) + return -EFAULT; + p += ISDN_MODEM_NUMREG; + if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN)) return -EFAULT; + p += ISDN_MSNLEN; + if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) + return -EFAULT; + p += ISDN_LMSNLEN; + } + return (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) * ISDN_MAX_CHANNELS; + } else + return -EINVAL; + break; + case IIOCSETPRF: + /* Set all Modem-Profiles */ + if (arg) { + char __user *p = argp; + int i; + + if (!access_ok(VERIFY_READ, argp, + (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) + * ISDN_MAX_CHANNELS)) + return -EFAULT; - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - if (copy_to_user(p, dev->mdm.info[i].emu.profile, - ISDN_MODEM_NUMREG)) - return -EFAULT; - p += ISDN_MODEM_NUMREG; - if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN)) - return -EFAULT; - p += ISDN_MSNLEN; - if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) - return -EFAULT; - p += ISDN_LMSNLEN; - } - return (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) * ISDN_MAX_CHANNELS; - } else - return -EINVAL; - break; - case IIOCSETPRF: - /* Set all Modem-Profiles */ - if (arg) { - char __user *p = argp; - int i; - - if (!access_ok(VERIFY_READ, argp, - (ISDN_MODEM_NUMREG + ISDN_MSNLEN + ISDN_LMSNLEN) - * ISDN_MAX_CHANNELS)) + for (i = 0; i < ISDN_MAX_CHANNELS; i++) { + if (copy_from_user(dev->mdm.info[i].emu.profile, p, + ISDN_MODEM_NUMREG)) + return -EFAULT; + p += ISDN_MODEM_NUMREG; + if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) return -EFAULT; + p += ISDN_LMSNLEN; + if (copy_from_user(dev->mdm.info[i].emu.pmsn, p, ISDN_MSNLEN)) + return -EFAULT; + p += ISDN_MSNLEN; + } + return 0; + } else + return -EINVAL; + break; + case IIOCSETMAP: + case IIOCGETMAP: + /* Set/Get MSN->EAZ-Mapping for a driver */ + if (arg) { - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - if (copy_from_user(dev->mdm.info[i].emu.profile, p, - ISDN_MODEM_NUMREG)) - return -EFAULT; - p += ISDN_MODEM_NUMREG; - if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) - return -EFAULT; - p += ISDN_LMSNLEN; - if (copy_from_user(dev->mdm.info[i].emu.pmsn, p, ISDN_MSNLEN)) - return -EFAULT; - p += ISDN_MSNLEN; - } - return 0; + if (copy_from_user(&iocts, argp, + sizeof(isdn_ioctl_struct))) + return -EFAULT; + iocts.drvid[sizeof(iocts.drvid) - 1] = 0; + if (strlen(iocts.drvid)) { + drvidx = -1; + for (i = 0; i < ISDN_MAX_DRIVERS; i++) + if (!(strcmp(dev->drvid[i], iocts.drvid))) { + drvidx = i; + break; + } } else - return -EINVAL; - break; - case IIOCSETMAP: - case IIOCGETMAP: - /* Set/Get MSN->EAZ-Mapping for a driver */ - if (arg) { + drvidx = 0; + if (drvidx == -1) + return -ENODEV; + if (cmd == IIOCSETMAP) { + int loop = 1; - if (copy_from_user(&iocts, argp, - sizeof(isdn_ioctl_struct))) - return -EFAULT; - iocts.drvid[sizeof(iocts.drvid)-1] = 0; - if (strlen(iocts.drvid)) { - drvidx = -1; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - if (!(strcmp(dev->drvid[i], iocts.drvid))) { - drvidx = i; + p = (char __user *) iocts.arg; + i = 0; + while (loop) { + int j = 0; + + while (1) { + if (!access_ok(VERIFY_READ, p, 1)) + return -EFAULT; + get_user(bname[j], p++); + switch (bname[j]) { + case '\0': + loop = 0; + /* Fall through */ + case ',': + bname[j] = '\0'; + strcpy(dev->drv[drvidx]->msn2eaz[i], bname); + j = ISDN_MSNLEN; break; + default: + j++; } - } else - drvidx = 0; - if (drvidx == -1) - return -ENODEV; - if (cmd == IIOCSETMAP) { - int loop = 1; - - p = (char __user *) iocts.arg; - i = 0; - while (loop) { - int j = 0; - - while (1) { - if (!access_ok(VERIFY_READ, p, 1)) - return -EFAULT; - get_user(bname[j], p++); - switch (bname[j]) { - case '\0': - loop = 0; - /* Fall through */ - case ',': - bname[j] = '\0'; - strcpy(dev->drv[drvidx]->msn2eaz[i], bname); - j = ISDN_MSNLEN; - break; - default: - j++; - } - if (j >= ISDN_MSNLEN) - break; - } - if (++i > 9) + if (j >= ISDN_MSNLEN) break; } - } else { - p = (char __user *) iocts.arg; - for (i = 0; i < 10; i++) { - snprintf(bname, sizeof(bname), "%s%s", - strlen(dev->drv[drvidx]->msn2eaz[i]) ? - dev->drv[drvidx]->msn2eaz[i] : "_", - (i < 9) ? "," : "\0"); - if (copy_to_user(p, bname, strlen(bname) + 1)) - return -EFAULT; - p += strlen(bname); - } + if (++i > 9) + break; } - return 0; - } else - return -EINVAL; - case IIOCDBGVAR: - if (arg) { - if (copy_to_user(argp, &dev, sizeof(ulong))) - return -EFAULT; - return 0; - } else - return -EINVAL; - break; - default: - if ((cmd & IIOCDRVCTL) == IIOCDRVCTL) - cmd = ((cmd >> _IOC_NRSHIFT) & _IOC_NRMASK) & ISDN_DRVIOCTL_MASK; - else - return -EINVAL; - if (arg) { - int i; - char *p; - if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct))) - return -EFAULT; - iocts.drvid[sizeof(iocts.drvid)-1] = 0; - if (strlen(iocts.drvid)) { - if ((p = strchr(iocts.drvid, ','))) - *p = 0; - drvidx = -1; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - if (!(strcmp(dev->drvid[i], iocts.drvid))) { - drvidx = i; - break; - } - } else - drvidx = 0; - if (drvidx == -1) - return -ENODEV; - if (!access_ok(VERIFY_WRITE, argp, - sizeof(isdn_ioctl_struct))) - return -EFAULT; - c.driver = drvidx; - c.command = ISDN_CMD_IOCTL; - c.arg = cmd; - memcpy(c.parm.num, &iocts.arg, sizeof(ulong)); - ret = isdn_command(&c); - memcpy(&iocts.arg, c.parm.num, sizeof(ulong)); - if (copy_to_user(argp, &iocts, sizeof(isdn_ioctl_struct))) - return -EFAULT; - return ret; + } else { + p = (char __user *) iocts.arg; + for (i = 0; i < 10; i++) { + snprintf(bname, sizeof(bname), "%s%s", + strlen(dev->drv[drvidx]->msn2eaz[i]) ? + dev->drv[drvidx]->msn2eaz[i] : "_", + (i < 9) ? "," : "\0"); + if (copy_to_user(p, bname, strlen(bname) + 1)) + return -EFAULT; + p += strlen(bname); + } + } + return 0; + } else + return -EINVAL; + case IIOCDBGVAR: + if (arg) { + if (copy_to_user(argp, &dev, sizeof(ulong))) + return -EFAULT; + return 0; + } else + return -EINVAL; + break; + default: + if ((cmd & IIOCDRVCTL) == IIOCDRVCTL) + cmd = ((cmd >> _IOC_NRSHIFT) & _IOC_NRMASK) & ISDN_DRVIOCTL_MASK; + else + return -EINVAL; + if (arg) { + int i; + char *p; + if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct))) + return -EFAULT; + iocts.drvid[sizeof(iocts.drvid) - 1] = 0; + if (strlen(iocts.drvid)) { + if ((p = strchr(iocts.drvid, ','))) + *p = 0; + drvidx = -1; + for (i = 0; i < ISDN_MAX_DRIVERS; i++) + if (!(strcmp(dev->drvid[i], iocts.drvid))) { + drvidx = i; + break; + } } else - return -EINVAL; + drvidx = 0; + if (drvidx == -1) + return -ENODEV; + if (!access_ok(VERIFY_WRITE, argp, + sizeof(isdn_ioctl_struct))) + return -EFAULT; + c.driver = drvidx; + c.command = ISDN_CMD_IOCTL; + c.arg = cmd; + memcpy(c.parm.num, &iocts.arg, sizeof(ulong)); + ret = isdn_command(&c); + memcpy(&iocts.arg, c.parm.num, sizeof(ulong)); + if (copy_to_user(argp, &iocts, sizeof(isdn_ioctl_struct))) + return -EFAULT; + return ret; + } else + return -EINVAL; } } #ifdef CONFIG_ISDN_PPP @@ -1788,7 +1788,7 @@ isdn_open(struct inode *ino, struct file *filep) goto out; } #endif - out: +out: nonseekable_open(ino, filep); mutex_unlock(&isdn_mutex); return retval; @@ -1832,7 +1832,7 @@ isdn_close(struct inode *ino, struct file *filep) isdn_ppp_release(minor - ISDN_MINOR_PPP, filep); #endif - out: +out: mutex_unlock(&isdn_mutex); return 0; } @@ -1868,14 +1868,14 @@ isdn_map_eaz2msn(char *msn, int di) * Find an unused ISDN-channel, whose feature-flags match the * given L2- and L3-protocols. */ -#define L2V (~(ISDN_FEATURE_L2_V11096|ISDN_FEATURE_L2_V11019|ISDN_FEATURE_L2_V11038)) +#define L2V (~(ISDN_FEATURE_L2_V11096 | ISDN_FEATURE_L2_V11019 | ISDN_FEATURE_L2_V11038)) /* * This function must be called with holding the dev->lock. */ int isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev - ,int pre_chan, char *msn) + , int pre_chan, char *msn) { int i; ulong features; @@ -1883,7 +1883,7 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev features = ((1 << l2_proto) | (0x10000 << l3_proto)); vfeatures = (((1 << l2_proto) | (0x10000 << l3_proto)) & - ~(ISDN_FEATURE_L2_V11096|ISDN_FEATURE_L2_V11019|ISDN_FEATURE_L2_V11038)); + ~(ISDN_FEATURE_L2_V11096 | ISDN_FEATURE_L2_V11019 | ISDN_FEATURE_L2_V11038)); /* If Layer-2 protocol is V.110, accept drivers with * transparent feature even if these don't support V.110 * because we can emulate this in linklevel. @@ -1893,12 +1893,12 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev (dev->drvmap[i] != -1)) { int d = dev->drvmap[i]; if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && - ((pre_dev != d) || (pre_chan != dev->chanmap[i]))) + ((pre_dev != d) || (pre_chan != dev->chanmap[i]))) continue; if (!strcmp(isdn_map_eaz2msn(msn, d), "-")) continue; if (dev->usage[i] & ISDN_USAGE_DISABLED) - continue; /* usage not allowed */ + continue; /* usage not allowed */ if (dev->drv[d]->flags & DRV_FLAG_RUNNING) { if (((dev->drv[d]->interface->features & features) == features) || (((dev->drv[d]->interface->features & vfeatures) == vfeatures) && @@ -1932,7 +1932,7 @@ isdn_free_channel(int di, int ch, int usage) if ((di < 0) || (ch < 0)) { printk(KERN_WARNING "%s: called with invalid drv(%d) or channel(%d)\n", - __func__, di, ch); + __func__, di, ch); return; } for (i = 0; i < ISDN_MAX_CHANNELS; i++) @@ -1976,7 +1976,7 @@ isdn_unexclusive_channel(int di, int ch) * writebuf replacement for SKB_ABLE drivers */ static int -isdn_writebuf_stub(int drvidx, int chan, const u_char __user * buf, int len) +isdn_writebuf_stub(int drvidx, int chan, const u_char __user *buf, int len) { int ret; int hl = dev->drv[drvidx]->interface->hl_hdrlen; @@ -2026,8 +2026,8 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb) } else { int hl = dev->drv[drvidx]->interface->hl_hdrlen; - if( skb_headroom(skb) < hl ){ - /* + if (skb_headroom(skb) < hl) { + /* * This should only occur when new HL driver with * increased hl_hdrlen was loaded after netdevice * was created and connected to the new driver. @@ -2035,13 +2035,13 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb) * The V.110 branch (re-allocates on its own) does * not need this */ - struct sk_buff * skb_tmp; + struct sk_buff *skb_tmp; skb_tmp = skb_realloc_headroom(skb, hl); printk(KERN_DEBUG "isdn_writebuf_skb_stub: reallocating headroom%s\n", skb_tmp ? "" : " failed"); if (!skb_tmp) return -ENOMEM; /* 0 better? */ ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, ack, skb_tmp); - if( ret > 0 ){ + if (ret > 0) { dev_kfree_skb(skb); } else { dev_kfree_skb(skb_tmp); @@ -2059,7 +2059,7 @@ isdn_writebuf_skb_stub(int drvidx, int chan, int ack, struct sk_buff *skb) /* For V.110 return unencoded data length */ ret = v110_ret; /* if the complete frame was send we free the skb; - if not upper function will requeue the skb */ + if not upper function will requeue the skb */ if (ret == skb->len) dev_kfree_skb(skb); } @@ -2077,7 +2077,7 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) init_waitqueue_head(&d->st_waitq); if (d->flags & DRV_FLAG_RUNNING) return -1; - if (n < 1) return 0; + if (n < 1) return 0; m = (adding) ? d->channels + n : n; @@ -2114,7 +2114,7 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) kfree(d->rcvcount); kfree(d->rcverr); } - return -1; + return -1; } for (j = 0; j < m; j++) { skb_queue_head_init(&d->rpqueue[j]); @@ -2172,45 +2172,45 @@ set_global_features(void) static char *map_drvname(int di) { - if ((di < 0) || (di >= ISDN_MAX_DRIVERS)) - return(NULL); - return(dev->drvid[di]); /* driver name */ + if ((di < 0) || (di >= ISDN_MAX_DRIVERS)) + return (NULL); + return (dev->drvid[di]); /* driver name */ } /* map_drvname */ static int map_namedrv(char *id) { int i; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - { if (!strcmp(dev->drvid[i],id)) - return(i); - } - return(-1); + for (i = 0; i < ISDN_MAX_DRIVERS; i++) + { if (!strcmp(dev->drvid[i], id)) + return (i); + } + return (-1); } /* map_namedrv */ int DIVERT_REG_NAME(isdn_divert_if *i_div) { - if (i_div->if_magic != DIVERT_IF_MAGIC) - return(DIVERT_VER_ERR); - switch (i_div->cmd) - { - case DIVERT_CMD_REL: - if (divert_if != i_div) - return(DIVERT_REL_ERR); - divert_if = NULL; /* free interface */ - return(DIVERT_NO_ERR); - - case DIVERT_CMD_REG: - if (divert_if) - return(DIVERT_REG_ERR); - i_div->ll_cmd = isdn_command; /* set command function */ - i_div->drv_to_name = map_drvname; - i_div->name_to_drv = map_namedrv; - divert_if = i_div; /* remember interface */ - return(DIVERT_NO_ERR); - - default: - return(DIVERT_CMD_ERR); - } + if (i_div->if_magic != DIVERT_IF_MAGIC) + return (DIVERT_VER_ERR); + switch (i_div->cmd) + { + case DIVERT_CMD_REL: + if (divert_if != i_div) + return (DIVERT_REL_ERR); + divert_if = NULL; /* free interface */ + return (DIVERT_NO_ERR); + + case DIVERT_CMD_REG: + if (divert_if) + return (DIVERT_REG_ERR); + i_div->ll_cmd = isdn_command; /* set command function */ + i_div->drv_to_name = map_drvname; + i_div->name_to_drv = map_namedrv; + divert_if = i_div; /* remember interface */ + return (DIVERT_NO_ERR); + + default: + return (DIVERT_CMD_ERR); + } } /* DIVERT_REG_NAME */ EXPORT_SYMBOL(DIVERT_REG_NAME); @@ -2225,7 +2225,7 @@ EXPORT_SYMBOL(isdn_ppp_unregister_compressor); #endif int -register_isdn(isdn_if * i) +register_isdn(isdn_if *i) { isdn_driver_t *d; int j; @@ -2280,10 +2280,10 @@ register_isdn(isdn_if * i) } /* - ***************************************************************************** - * And now the modules code. - ***************************************************************************** - */ +***************************************************************************** +* And now the modules code. +***************************************************************************** +*/ static char * isdn_getrev(const char *revision) diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 082735dbb412..9a471f62e1d4 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -29,19 +29,19 @@ extern void isdn_lock_drivers(void); extern void isdn_unlock_drivers(void); extern void isdn_free_channel(int di, int ch, int usage); extern void isdn_all_eaz(int di, int ch); -extern int isdn_command(isdn_ctrl *); -extern int isdn_dc2minor(int di, int ch); +extern int isdn_command(isdn_ctrl *); +extern int isdn_dc2minor(int di, int ch); extern void isdn_info_update(void); extern char *isdn_map_eaz2msn(char *msn, int di); extern void isdn_timer_ctrl(int tf, int onoff); extern void isdn_unexclusive_channel(int di, int ch); -extern int isdn_getnum(char **); -extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); -extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); -extern int isdn_get_free_channel(int, int, int, int, int, char *); -extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); -extern int register_isdn(isdn_if * i); -extern int isdn_msncmp( const char *, const char *); +extern int isdn_getnum(char **); +extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *); +extern int isdn_readbchan_tty(int, int, struct tty_struct *, int); +extern int isdn_get_free_channel(int, int, int, int, int, char *); +extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *); +extern int register_isdn(isdn_if *i); +extern int isdn_msncmp(const char *, const char *); #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) extern void isdn_dumppkt(char *, u_char *, int, int); #endif diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c index d568689669f8..91d57304d4d3 100644 --- a/drivers/isdn/i4l/isdn_concap.c +++ b/drivers/isdn/i4l/isdn_concap.c @@ -1,5 +1,5 @@ /* $Id: isdn_concap.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $ - * + * * Linux ISDN subsystem, protocol encapsulation * * This software may be used and distributed according to the terms @@ -25,57 +25,57 @@ protocols that require for reliable datalink semantics. That means: - before any data is to be submitted the connection must explicitly - be set up. + be set up. - after the successful set up of the connection is signalled the - connection is considered to be reliably up. + connection is considered to be reliably up. - Auto-dialing ist not compatible with this requirements. Thus, auto-dialing + Auto-dialing ist not compatible with this requirements. Thus, auto-dialing is completely bypassed. It might be possible to implement a (non standardized) datalink protocol that provides a reliable data link service while using some auto dialing mechanism. Such a protocol would need an auxiliary channel (i.e. user-user- signaling on the D-channel) while the B-channel is down. - */ +*/ static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb) { - struct net_device *ndev = concap -> net_dev; + struct net_device *ndev = concap->net_dev; isdn_net_dev *nd = ((isdn_net_local *) netdev_priv(ndev))->netdev; isdn_net_local *lp = isdn_net_get_locked_lp(nd); - IX25DEBUG( "isdn_concap_dl_data_req: %s \n", concap->net_dev->name); + IX25DEBUG("isdn_concap_dl_data_req: %s \n", concap->net_dev->name); if (!lp) { - IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 1); + IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 1); return 1; } lp->huptimer = 0; isdn_net_writebuf_skb(lp, skb); spin_unlock_bh(&lp->xmit_lock); - IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 0); + IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 0); return 0; } static int isdn_concap_dl_connect_req(struct concap_proto *concap) { - struct net_device *ndev = concap -> net_dev; + struct net_device *ndev = concap->net_dev; isdn_net_local *lp = netdev_priv(ndev); int ret; - IX25DEBUG( "isdn_concap_dl_connect_req: %s \n", ndev -> name); + IX25DEBUG("isdn_concap_dl_connect_req: %s \n", ndev->name); /* dial ... */ - ret = isdn_net_dial_req( lp ); - if ( ret ) IX25DEBUG("dialing failed\n"); + ret = isdn_net_dial_req(lp); + if (ret) IX25DEBUG("dialing failed\n"); return ret; } static int isdn_concap_dl_disconn_req(struct concap_proto *concap) { - IX25DEBUG( "isdn_concap_dl_disconn_req: %s \n", concap -> net_dev -> name); + IX25DEBUG("isdn_concap_dl_disconn_req: %s \n", concap->net_dev->name); - isdn_net_hangup( concap -> net_dev ); + isdn_net_hangup(concap->net_dev); return 0; } @@ -88,10 +88,10 @@ struct concap_device_ops isdn_concap_reliable_dl_dops = { /* The following should better go into a dedicated source file such that this sourcefile does not need to include any protocol specific header files. For now: - */ -struct concap_proto * isdn_concap_new( int encap ) +*/ +struct concap_proto *isdn_concap_new(int encap) { - switch ( encap ) { + switch (encap) { case ISDN_NET_ENCAP_X25IFACE: return isdn_x25iface_proto_new(); } diff --git a/drivers/isdn/i4l/isdn_concap.h b/drivers/isdn/i4l/isdn_concap.h index 6ac7e0445ea5..cd7e3ba74e25 100644 --- a/drivers/isdn/i4l/isdn_concap.h +++ b/drivers/isdn/i4l/isdn_concap.h @@ -8,6 +8,4 @@ */ extern struct concap_device_ops isdn_concap_reliable_dl_dops; -extern struct concap_proto * isdn_concap_new( int ); - - +extern struct concap_proto *isdn_concap_new(int); diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 802ab87a78b6..babc621a07fb 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -9,7 +9,7 @@ * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * - * Data Over Voice (DOV) support added - Guy Ellis 23-Mar-02 + * Data Over Voice (DOV) support added - Guy Ellis 23-Mar-02 * guy@traverse.com.au * Outgoing calls - looks for a 'V' in first char of dialed number * Incoming calls - checks first character of eaz as follows: @@ -18,7 +18,7 @@ * 'B' - accept BOTH DATA and DOV types * * Jan 2001: fix CISCO HDLC Bjoern A. Zeeb - * for info on the protocol, see + * for info on the protocol, see * http://i4l.zabbadoz.net/i4l/cisco-hdlc.txt */ @@ -40,7 +40,7 @@ /* - * Outline of new tbusy handling: + * Outline of new tbusy handling: * * Old method, roughly spoken, consisted of setting tbusy when entering * isdn_net_start_xmit() and at several other locations and clearing @@ -59,14 +59,14 @@ * Most of the changes were pretty obvious and basically done by HE already. * * One problem of the isdn net device code is that is uses struct net_device - * for masters and slaves. However, only master interface are registered to - * the network layer, and therefore, it only makes sense to call netif_* + * for masters and slaves. However, only master interface are registered to + * the network layer, and therefore, it only makes sense to call netif_* * functions on them. * * --KG */ -/* +/* * Find out if the netdevice has been ifup-ed yet. * For slaves, look at the corresponding master. */ @@ -74,8 +74,8 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n) { isdn_net_local *lp = n->local; struct net_device *dev; - - if (lp->master) + + if (lp->master) dev = lp->master; else dev = n->dev; @@ -88,7 +88,7 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n) */ static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp) { - if (lp->master) + if (lp->master) netif_wake_queue(lp->master); else netif_wake_queue(lp->netdev->dev); @@ -108,7 +108,7 @@ static __inline__ void isdn_net_device_stop_queue(isdn_net_local *lp) /* * find out if the net_device which this lp belongs to (lp can be - * master or slave) is busy. It's busy iff all (master and slave) + * master or slave) is busy. It's busy iff all (master and slave) * queues are busy */ static __inline__ int isdn_net_device_busy(isdn_net_local *lp) @@ -124,7 +124,7 @@ static __inline__ int isdn_net_device_busy(isdn_net_local *lp) nd = ISDN_MASTER_PRIV(lp)->netdev; else nd = lp->netdev; - + spin_lock_irqsave(&nd->queue_lock, flags); nlp = lp->next; while (nlp != lp) { @@ -155,7 +155,7 @@ static __inline__ void isdn_net_dec_frame_cnt(isdn_net_local *lp) } else { isdn_net_device_wake_queue(lp); } - } + } } static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) @@ -163,36 +163,36 @@ static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) atomic_set(&lp->frame_cnt, 0); } -/* For 2.2.x we leave the transmitter busy timeout at 2 secs, just +/* For 2.2.x we leave the transmitter busy timeout at 2 secs, just * to be safe. * For 2.3.x we push it up to 20 secs, because call establishment - * (in particular callback) may take such a long time, and we + * (in particular callback) may take such a long time, and we * don't want confusing messages in the log. However, there is a slight * possibility that this large timeout will break other things like MPPP, * which might rely on the tx timeout. If so, we'll find out this way... */ -#define ISDN_NET_TX_TIMEOUT (20*HZ) +#define ISDN_NET_TX_TIMEOUT (20 * HZ) /* Prototypes */ static int isdn_net_force_dial_lp(isdn_net_local *); static netdev_tx_t isdn_net_start_xmit(struct sk_buff *, - struct net_device *); + struct net_device *); static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); char *isdn_net_revision = "$Revision: 1.1.2.2 $"; - /* - * Code for raw-networking over ISDN - */ +/* + * Code for raw-networking over ISDN + */ static void isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason) { - if(skb) { + if (skb) { u_short proto = ntohs(skb->protocol); @@ -200,13 +200,13 @@ isdn_net_unreachable(struct net_device *dev, struct sk_buff *skb, char *reason) dev->name, (reason != NULL) ? reason : "unknown", (proto != ETH_P_IP) ? "Protocol != ETH_P_IP" : ""); - + dst_link_failure(skb); } else { /* dial not triggered by rawIP packet */ printk(KERN_DEBUG "isdn_net: %s: %s\n", - dev->name, - (reason != NULL) ? reason : "reason unknown"); + dev->name, + (reason != NULL) ? reason : "reason unknown"); } } @@ -214,14 +214,14 @@ static void isdn_net_reset(struct net_device *dev) { #ifdef CONFIG_ISDN_X25 - struct concap_device_ops * dops = - ((isdn_net_local *) netdev_priv(dev))->dops; - struct concap_proto * cprot = - ((isdn_net_local *) netdev_priv(dev))->netdev->cprot; + struct concap_device_ops *dops = + ((isdn_net_local *)netdev_priv(dev))->dops; + struct concap_proto *cprot = + ((isdn_net_local *)netdev_priv(dev))->netdev->cprot; #endif #ifdef CONFIG_ISDN_X25 - if( cprot && cprot -> pops && dops ) - cprot -> pops -> restart ( cprot, dev, dops ); + if (cprot && cprot->pops && dops) + cprot->pops->restart(cprot, dev, dops); #endif } @@ -248,7 +248,7 @@ isdn_net_open(struct net_device *dev) */ struct in_ifaddr *ifa = in_dev->ifa_list; if (ifa != NULL) - memcpy(dev->dev_addr+2, &ifa->ifa_local, 4); + memcpy(dev->dev_addr + 2, &ifa->ifa_local, 4); } /* If this interface has slaves, start them also */ @@ -267,7 +267,7 @@ isdn_net_open(struct net_device *dev) * Assign an ISDN-channel to a net-interface */ static void -isdn_net_bind_channel(isdn_net_local * lp, int idx) +isdn_net_bind_channel(isdn_net_local *lp, int idx) { lp->flags |= ISDN_NET_CONNECTED; lp->isdn_device = dev->drvmap[idx]; @@ -280,7 +280,7 @@ isdn_net_bind_channel(isdn_net_local * lp, int idx) * unbind a net-interface (resets interface after an error) */ static void -isdn_net_unbind_channel(isdn_net_local * lp) +isdn_net_unbind_channel(isdn_net_local *lp) { skb_queue_purge(&lp->super_tx_queue); @@ -288,7 +288,7 @@ isdn_net_unbind_channel(isdn_net_local * lp) /* Moral equivalent of dev_purge_queues(): BEWARE! This chunk of code cannot be called from hardware interrupt handler. I hope it is true. --ANK - */ + */ qdisc_reset_all_tx(lp->netdev->dev); } lp->dialstate = 0; @@ -368,7 +368,7 @@ isdn_net_autohup(void) isdn_net_hangup(p->dev); } - if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*l) == ISDN_NET_DM_OFF)) { + if (dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*l) == ISDN_NET_DM_OFF)) { isdn_net_hangup(p->dev); break; } @@ -403,143 +403,143 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) struct concap_proto_ops *pops = cprot ? cprot->pops : NULL; #endif switch (cmd) { - case ISDN_STAT_BSENT: - /* A packet has successfully been sent out */ - if ((lp->flags & ISDN_NET_CONNECTED) && - (!lp->dialstate)) { - isdn_net_dec_frame_cnt(lp); - lp->stats.tx_packets++; - lp->stats.tx_bytes += c->parm.length; - } + case ISDN_STAT_BSENT: + /* A packet has successfully been sent out */ + if ((lp->flags & ISDN_NET_CONNECTED) && + (!lp->dialstate)) { + isdn_net_dec_frame_cnt(lp); + lp->stats.tx_packets++; + lp->stats.tx_bytes += c->parm.length; + } + return 1; + case ISDN_STAT_DCONN: + /* D-Channel is up */ + switch (lp->dialstate) { + case 4: + case 7: + case 8: + lp->dialstate++; return 1; - case ISDN_STAT_DCONN: - /* D-Channel is up */ - switch (lp->dialstate) { - case 4: - case 7: - case 8: - lp->dialstate++; - return 1; - case 12: - lp->dialstate = 5; - return 1; - } - break; - case ISDN_STAT_DHUP: - /* Either D-Channel-hangup or error during dialout */ + case 12: + lp->dialstate = 5; + return 1; + } + break; + case ISDN_STAT_DHUP: + /* Either D-Channel-hangup or error during dialout */ #ifdef CONFIG_ISDN_X25 - /* If we are not connencted then dialing had - failed. If there are generic encap protocol - receiver routines signal the closure of - the link*/ - - if( !(lp->flags & ISDN_NET_CONNECTED) - && pops && pops -> disconn_ind ) - pops -> disconn_ind(cprot); + /* If we are not connencted then dialing had + failed. If there are generic encap protocol + receiver routines signal the closure of + the link*/ + + if (!(lp->flags & ISDN_NET_CONNECTED) + && pops && pops->disconn_ind) + pops->disconn_ind(cprot); #endif /* CONFIG_ISDN_X25 */ - if ((!lp->dialstate) && (lp->flags & ISDN_NET_CONNECTED)) { - if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) - isdn_net_ciscohdlck_disconnected(lp); + if ((!lp->dialstate) && (lp->flags & ISDN_NET_CONNECTED)) { + if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) + isdn_net_ciscohdlck_disconnected(lp); #ifdef CONFIG_ISDN_PPP - if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) - isdn_ppp_free(lp); + if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) + isdn_ppp_free(lp); #endif - isdn_net_lp_disconnected(lp); - isdn_all_eaz(lp->isdn_device, lp->isdn_channel); - printk(KERN_INFO "%s: remote hangup\n", p->dev->name); - printk(KERN_INFO "%s: Chargesum is %d\n", p->dev->name, - lp->charge); - isdn_net_unbind_channel(lp); - return 1; - } - break; + isdn_net_lp_disconnected(lp); + isdn_all_eaz(lp->isdn_device, lp->isdn_channel); + printk(KERN_INFO "%s: remote hangup\n", p->dev->name); + printk(KERN_INFO "%s: Chargesum is %d\n", p->dev->name, + lp->charge); + isdn_net_unbind_channel(lp); + return 1; + } + break; #ifdef CONFIG_ISDN_X25 - case ISDN_STAT_BHUP: - /* B-Channel-hangup */ - /* try if there are generic encap protocol - receiver routines and signal the closure of - the link */ - if( pops && pops -> disconn_ind ){ - pops -> disconn_ind(cprot); - return 1; - } - break; + case ISDN_STAT_BHUP: + /* B-Channel-hangup */ + /* try if there are generic encap protocol + receiver routines and signal the closure of + the link */ + if (pops && pops->disconn_ind) { + pops->disconn_ind(cprot); + return 1; + } + break; #endif /* CONFIG_ISDN_X25 */ - case ISDN_STAT_BCONN: - /* B-Channel is up */ - isdn_net_zero_frame_cnt(lp); - switch (lp->dialstate) { - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 12: - if (lp->dialstate <= 6) { - dev->usage[idx] |= ISDN_USAGE_OUTGOING; - isdn_info_update(); - } else - dev->rx_netdev[idx] = p; - lp->dialstate = 0; - isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); - if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) - isdn_net_ciscohdlck_connected(lp); - if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) { - if (lp->master) { /* is lp a slave? */ - isdn_net_dev *nd = ISDN_MASTER_PRIV(lp)->netdev; - isdn_net_add_to_bundle(nd, lp); - } - } - printk(KERN_INFO "isdn_net: %s connected\n", p->dev->name); - /* If first Chargeinfo comes before B-Channel connect, - * we correct the timestamp here. - */ - lp->chargetime = jiffies; + case ISDN_STAT_BCONN: + /* B-Channel is up */ + isdn_net_zero_frame_cnt(lp); + switch (lp->dialstate) { + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 12: + if (lp->dialstate <= 6) { + dev->usage[idx] |= ISDN_USAGE_OUTGOING; + isdn_info_update(); + } else + dev->rx_netdev[idx] = p; + lp->dialstate = 0; + isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); + if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) + isdn_net_ciscohdlck_connected(lp); + if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) { + if (lp->master) { /* is lp a slave? */ + isdn_net_dev *nd = ISDN_MASTER_PRIV(lp)->netdev; + isdn_net_add_to_bundle(nd, lp); + } + } + printk(KERN_INFO "isdn_net: %s connected\n", p->dev->name); + /* If first Chargeinfo comes before B-Channel connect, + * we correct the timestamp here. + */ + lp->chargetime = jiffies; - /* reset dial-timeout */ - lp->dialstarted = 0; - lp->dialwait_timer = 0; + /* reset dial-timeout */ + lp->dialstarted = 0; + lp->dialwait_timer = 0; #ifdef CONFIG_ISDN_PPP - if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) - isdn_ppp_wakeup_daemon(lp); + if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) + isdn_ppp_wakeup_daemon(lp); #endif #ifdef CONFIG_ISDN_X25 - /* try if there are generic concap receiver routines */ - if( pops ) - if( pops->connect_ind) - pops->connect_ind(cprot); + /* try if there are generic concap receiver routines */ + if (pops) + if (pops->connect_ind) + pops->connect_ind(cprot); #endif /* CONFIG_ISDN_X25 */ - /* ppp needs to do negotiations first */ - if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) - isdn_net_device_wake_queue(lp); - return 1; - } - break; - case ISDN_STAT_NODCH: - /* No D-Channel avail. */ - if (lp->dialstate == 4) { - lp->dialstate--; - return 1; - } - break; - case ISDN_STAT_CINF: - /* Charge-info from TelCo. Calculate interval between - * charge-infos and set timestamp for last info for - * usage by isdn_net_autohup() - */ - lp->charge++; - if (lp->hupflags & ISDN_HAVECHARGE) { - lp->hupflags &= ~ISDN_WAITCHARGE; - lp->chargeint = jiffies - lp->chargetime - (2 * HZ); - } - if (lp->hupflags & ISDN_WAITCHARGE) - lp->hupflags |= ISDN_HAVECHARGE; - lp->chargetime = jiffies; - printk(KERN_DEBUG "isdn_net: Got CINF chargetime of %s now %lu\n", - p->dev->name, lp->chargetime); + /* ppp needs to do negotiations first */ + if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) + isdn_net_device_wake_queue(lp); return 1; + } + break; + case ISDN_STAT_NODCH: + /* No D-Channel avail. */ + if (lp->dialstate == 4) { + lp->dialstate--; + return 1; + } + break; + case ISDN_STAT_CINF: + /* Charge-info from TelCo. Calculate interval between + * charge-infos and set timestamp for last info for + * usage by isdn_net_autohup() + */ + lp->charge++; + if (lp->hupflags & ISDN_HAVECHARGE) { + lp->hupflags &= ~ISDN_WAITCHARGE; + lp->chargeint = jiffies - lp->chargetime - (2 * HZ); + } + if (lp->hupflags & ISDN_WAITCHARGE) + lp->hupflags |= ISDN_HAVECHARGE; + lp->chargetime = jiffies; + printk(KERN_DEBUG "isdn_net: Got CINF chargetime of %s now %lu\n", + p->dev->name, lp->chargetime); + return 1; } } return 0; @@ -562,7 +562,7 @@ isdn_net_dial(void) int anymore = 0; int i; isdn_ctrl cmd; - u_char *phone_number; + u_char *phone_number; while (p) { isdn_net_local *lp = p->local; @@ -572,249 +572,249 @@ isdn_net_dial(void) printk(KERN_DEBUG "%s: dialstate=%d\n", p->dev->name, lp->dialstate); #endif switch (lp->dialstate) { - case 0: - /* Nothing to do for this interface */ + case 0: + /* Nothing to do for this interface */ + break; + case 1: + /* Initiate dialout. Set phone-number-pointer to first number + * of interface. + */ + lp->dial = lp->phone[1]; + if (!lp->dial) { + printk(KERN_WARNING "%s: phone number deleted?\n", + p->dev->name); + isdn_net_hangup(p->dev); break; - case 1: - /* Initiate dialout. Set phone-number-pointer to first number - * of interface. - */ - lp->dial = lp->phone[1]; - if (!lp->dial) { - printk(KERN_WARNING "%s: phone number deleted?\n", - p->dev->name); - isdn_net_hangup(p->dev); - break; + } + anymore = 1; + + if (lp->dialtimeout > 0) + if (lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) { + lp->dialstarted = jiffies; + lp->dialwait_timer = 0; } - anymore = 1; - if(lp->dialtimeout > 0) - if(lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) { - lp->dialstarted = jiffies; - lp->dialwait_timer = 0; + lp->dialstate++; + /* Fall through */ + case 2: + /* Prepare dialing. Clear EAZ, then set EAZ. */ + cmd.driver = lp->isdn_device; + cmd.arg = lp->isdn_channel; + cmd.command = ISDN_CMD_CLREAZ; + isdn_command(&cmd); + sprintf(cmd.parm.num, "%s", isdn_map_eaz2msn(lp->msn, cmd.driver)); + cmd.command = ISDN_CMD_SETEAZ; + isdn_command(&cmd); + lp->dialretry = 0; + anymore = 1; + lp->dialstate++; + /* Fall through */ + case 3: + /* Setup interface, dial current phone-number, switch to next number. + * If list of phone-numbers is exhausted, increment + * retry-counter. + */ + if (dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) { + char *s; + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + s = "dial suppressed: isdn system stopped"; + else + s = "dial suppressed: dialmode `off'"; + isdn_net_unreachable(p->dev, NULL, s); + isdn_net_hangup(p->dev); + break; + } + cmd.driver = lp->isdn_device; + cmd.command = ISDN_CMD_SETL2; + cmd.arg = lp->isdn_channel + (lp->l2_proto << 8); + isdn_command(&cmd); + cmd.driver = lp->isdn_device; + cmd.command = ISDN_CMD_SETL3; + cmd.arg = lp->isdn_channel + (lp->l3_proto << 8); + isdn_command(&cmd); + cmd.driver = lp->isdn_device; + cmd.arg = lp->isdn_channel; + if (!lp->dial) { + printk(KERN_WARNING "%s: phone number deleted?\n", + p->dev->name); + isdn_net_hangup(p->dev); + break; + } + if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) { + lp->dialstate = 4; + printk(KERN_INFO "%s: Open leased line ...\n", p->dev->name); + } else { + if (lp->dialtimeout > 0) + if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) { + lp->dialwait_timer = jiffies + lp->dialwait; + lp->dialstarted = 0; + isdn_net_unreachable(p->dev, NULL, "dial: timed out"); + isdn_net_hangup(p->dev); + break; } - lp->dialstate++; - /* Fall through */ - case 2: - /* Prepare dialing. Clear EAZ, then set EAZ. */ - cmd.driver = lp->isdn_device; - cmd.arg = lp->isdn_channel; - cmd.command = ISDN_CMD_CLREAZ; - isdn_command(&cmd); - sprintf(cmd.parm.num, "%s", isdn_map_eaz2msn(lp->msn, cmd.driver)); - cmd.command = ISDN_CMD_SETEAZ; - isdn_command(&cmd); - lp->dialretry = 0; - anymore = 1; - lp->dialstate++; - /* Fall through */ - case 3: - /* Setup interface, dial current phone-number, switch to next number. - * If list of phone-numbers is exhausted, increment - * retry-counter. - */ - if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) { - char *s; - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - s = "dial suppressed: isdn system stopped"; - else - s = "dial suppressed: dialmode `off'"; - isdn_net_unreachable(p->dev, NULL, s); - isdn_net_hangup(p->dev); - break; - } - cmd.driver = lp->isdn_device; - cmd.command = ISDN_CMD_SETL2; - cmd.arg = lp->isdn_channel + (lp->l2_proto << 8); - isdn_command(&cmd); - cmd.driver = lp->isdn_device; - cmd.command = ISDN_CMD_SETL3; - cmd.arg = lp->isdn_channel + (lp->l3_proto << 8); - isdn_command(&cmd); cmd.driver = lp->isdn_device; - cmd.arg = lp->isdn_channel; - if (!lp->dial) { - printk(KERN_WARNING "%s: phone number deleted?\n", - p->dev->name); - isdn_net_hangup(p->dev); - break; + cmd.command = ISDN_CMD_DIAL; + cmd.parm.setup.si2 = 0; + + /* check for DOV */ + phone_number = lp->dial->num; + if ((*phone_number == 'v') || + (*phone_number == 'V')) { /* DOV call */ + cmd.parm.setup.si1 = 1; + } else { /* DATA call */ + cmd.parm.setup.si1 = 7; } - if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) { - lp->dialstate = 4; - printk(KERN_INFO "%s: Open leased line ...\n", p->dev->name); - } else { - if(lp->dialtimeout > 0) - if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) { - lp->dialwait_timer = jiffies + lp->dialwait; - lp->dialstarted = 0; - isdn_net_unreachable(p->dev, NULL, "dial: timed out"); - isdn_net_hangup(p->dev); - break; - } - cmd.driver = lp->isdn_device; - cmd.command = ISDN_CMD_DIAL; - cmd.parm.setup.si2 = 0; - - /* check for DOV */ - phone_number = lp->dial->num; - if ((*phone_number == 'v') || - (*phone_number == 'V')) { /* DOV call */ - cmd.parm.setup.si1 = 1; - } else { /* DATA call */ - cmd.parm.setup.si1 = 7; - } + strcpy(cmd.parm.setup.phone, phone_number); + /* + * Switch to next number or back to start if at end of list. + */ + if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { + lp->dial = lp->phone[1]; + lp->dialretry++; - strcpy(cmd.parm.setup.phone, phone_number); - /* - * Switch to next number or back to start if at end of list. - */ - if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { - lp->dial = lp->phone[1]; - lp->dialretry++; - - if (lp->dialretry > lp->dialmax) { - if (lp->dialtimeout == 0) { - lp->dialwait_timer = jiffies + lp->dialwait; - lp->dialstarted = 0; - isdn_net_unreachable(p->dev, NULL, "dial: tried all numbers dialmax times"); - } - isdn_net_hangup(p->dev); - break; + if (lp->dialretry > lp->dialmax) { + if (lp->dialtimeout == 0) { + lp->dialwait_timer = jiffies + lp->dialwait; + lp->dialstarted = 0; + isdn_net_unreachable(p->dev, NULL, "dial: tried all numbers dialmax times"); } + isdn_net_hangup(p->dev); + break; } - sprintf(cmd.parm.setup.eazmsn, "%s", - isdn_map_eaz2msn(lp->msn, cmd.driver)); - i = isdn_dc2minor(lp->isdn_device, lp->isdn_channel); - if (i >= 0) { - strcpy(dev->num[i], cmd.parm.setup.phone); - dev->usage[i] |= ISDN_USAGE_OUTGOING; - isdn_info_update(); - } - printk(KERN_INFO "%s: dialing %d %s... %s\n", p->dev->name, - lp->dialretry, cmd.parm.setup.phone, - (cmd.parm.setup.si1 == 1) ? "DOV" : ""); - lp->dtimer = 0; -#ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dial: d=%d c=%d\n", lp->isdn_device, - lp->isdn_channel); -#endif - isdn_command(&cmd); } - lp->huptimer = 0; - lp->outgoing = 1; - if (lp->chargeint) { - lp->hupflags |= ISDN_HAVECHARGE; - lp->hupflags &= ~ISDN_WAITCHARGE; - } else { - lp->hupflags |= ISDN_WAITCHARGE; - lp->hupflags &= ~ISDN_HAVECHARGE; + sprintf(cmd.parm.setup.eazmsn, "%s", + isdn_map_eaz2msn(lp->msn, cmd.driver)); + i = isdn_dc2minor(lp->isdn_device, lp->isdn_channel); + if (i >= 0) { + strcpy(dev->num[i], cmd.parm.setup.phone); + dev->usage[i] |= ISDN_USAGE_OUTGOING; + isdn_info_update(); } - anymore = 1; - lp->dialstate = - (lp->cbdelay && - (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4; - break; - case 4: - /* Wait for D-Channel-connect. - * If timeout, switch back to state 3. - * Dialmax-handling moved to state 3. - */ - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - lp->dialstate = 3; - anymore = 1; - break; - case 5: - /* Got D-Channel-Connect, send B-Channel-request */ - cmd.driver = lp->isdn_device; - cmd.arg = lp->isdn_channel; - cmd.command = ISDN_CMD_ACCEPTB; - anymore = 1; + printk(KERN_INFO "%s: dialing %d %s... %s\n", p->dev->name, + lp->dialretry, cmd.parm.setup.phone, + (cmd.parm.setup.si1 == 1) ? "DOV" : ""); lp->dtimer = 0; - lp->dialstate++; +#ifdef ISDN_DEBUG_NET_DIAL + printk(KERN_DEBUG "dial: d=%d c=%d\n", lp->isdn_device, + lp->isdn_channel); +#endif isdn_command(&cmd); - break; - case 6: - /* Wait for B- or D-Channel-connect. If timeout, - * switch back to state 3. - */ + } + lp->huptimer = 0; + lp->outgoing = 1; + if (lp->chargeint) { + lp->hupflags |= ISDN_HAVECHARGE; + lp->hupflags &= ~ISDN_WAITCHARGE; + } else { + lp->hupflags |= ISDN_WAITCHARGE; + lp->hupflags &= ~ISDN_HAVECHARGE; + } + anymore = 1; + lp->dialstate = + (lp->cbdelay && + (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4; + break; + case 4: + /* Wait for D-Channel-connect. + * If timeout, switch back to state 3. + * Dialmax-handling moved to state 3. + */ + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) + lp->dialstate = 3; + anymore = 1; + break; + case 5: + /* Got D-Channel-Connect, send B-Channel-request */ + cmd.driver = lp->isdn_device; + cmd.arg = lp->isdn_channel; + cmd.command = ISDN_CMD_ACCEPTB; + anymore = 1; + lp->dtimer = 0; + lp->dialstate++; + isdn_command(&cmd); + break; + case 6: + /* Wait for B- or D-Channel-connect. If timeout, + * switch back to state 3. + */ #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dialtimer2: %d\n", lp->dtimer); + printk(KERN_DEBUG "dialtimer2: %d\n", lp->dtimer); #endif - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - lp->dialstate = 3; - anymore = 1; - break; - case 7: - /* Got incoming Call, setup L2 and L3 protocols, - * then wait for D-Channel-connect - */ + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) + lp->dialstate = 3; + anymore = 1; + break; + case 7: + /* Got incoming Call, setup L2 and L3 protocols, + * then wait for D-Channel-connect + */ #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); + printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); #endif - cmd.driver = lp->isdn_device; - cmd.command = ISDN_CMD_SETL2; - cmd.arg = lp->isdn_channel + (lp->l2_proto << 8); - isdn_command(&cmd); - cmd.driver = lp->isdn_device; - cmd.command = ISDN_CMD_SETL3; - cmd.arg = lp->isdn_channel + (lp->l3_proto << 8); - isdn_command(&cmd); - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) - isdn_net_hangup(p->dev); - else { - anymore = 1; - lp->dialstate++; - } - break; - case 9: - /* Got incoming D-Channel-Connect, send B-Channel-request */ - cmd.driver = lp->isdn_device; - cmd.arg = lp->isdn_channel; - cmd.command = ISDN_CMD_ACCEPTB; - isdn_command(&cmd); + cmd.driver = lp->isdn_device; + cmd.command = ISDN_CMD_SETL2; + cmd.arg = lp->isdn_channel + (lp->l2_proto << 8); + isdn_command(&cmd); + cmd.driver = lp->isdn_device; + cmd.command = ISDN_CMD_SETL3; + cmd.arg = lp->isdn_channel + (lp->l3_proto << 8); + isdn_command(&cmd); + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) + isdn_net_hangup(p->dev); + else { anymore = 1; - lp->dtimer = 0; lp->dialstate++; - break; - case 8: - case 10: - /* Wait for B- or D-channel-connect */ + } + break; + case 9: + /* Got incoming D-Channel-Connect, send B-Channel-request */ + cmd.driver = lp->isdn_device; + cmd.arg = lp->isdn_channel; + cmd.command = ISDN_CMD_ACCEPTB; + isdn_command(&cmd); + anymore = 1; + lp->dtimer = 0; + lp->dialstate++; + break; + case 8: + case 10: + /* Wait for B- or D-channel-connect */ #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); + printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); #endif - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - isdn_net_hangup(p->dev); - else - anymore = 1; - break; - case 11: - /* Callback Delay */ - if (lp->dtimer++ > lp->cbdelay) - lp->dialstate = 1; - anymore = 1; - break; - case 12: - /* Remote does callback. Hangup after cbdelay, then wait for incoming - * call (in state 4). - */ - if (lp->dtimer++ > lp->cbdelay) - { - printk(KERN_INFO "%s: hangup waiting for callback ...\n", p->dev->name); - lp->dtimer = 0; - lp->dialstate = 4; - cmd.driver = lp->isdn_device; - cmd.command = ISDN_CMD_HANGUP; - cmd.arg = lp->isdn_channel; - isdn_command(&cmd); - isdn_all_eaz(lp->isdn_device, lp->isdn_channel); - } + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) + isdn_net_hangup(p->dev); + else anymore = 1; - break; - default: - printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n", - lp->dialstate, p->dev->name); + break; + case 11: + /* Callback Delay */ + if (lp->dtimer++ > lp->cbdelay) + lp->dialstate = 1; + anymore = 1; + break; + case 12: + /* Remote does callback. Hangup after cbdelay, then wait for incoming + * call (in state 4). + */ + if (lp->dtimer++ > lp->cbdelay) + { + printk(KERN_INFO "%s: hangup waiting for callback ...\n", p->dev->name); + lp->dtimer = 0; + lp->dialstate = 4; + cmd.driver = lp->isdn_device; + cmd.command = ISDN_CMD_HANGUP; + cmd.arg = lp->isdn_channel; + isdn_command(&cmd); + isdn_all_eaz(lp->isdn_device, lp->isdn_channel); + } + anymore = 1; + break; + default: + printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n", + lp->dialstate, p->dev->name); } p = (isdn_net_dev *) p->next; } @@ -839,8 +839,8 @@ isdn_net_hangup(struct net_device *d) isdn_net_local *slp = ISDN_SLAVE_PRIV(lp); if (slp->flags & ISDN_NET_CONNECTED) { printk(KERN_INFO - "isdn_net: hang up slave %s before %s\n", - lp->slave->name, d->name); + "isdn_net: hang up slave %s before %s\n", + lp->slave->name, d->name); isdn_net_hangup(lp->slave); } } @@ -854,8 +854,8 @@ isdn_net_hangup(struct net_device *d) /* try if there are generic encap protocol receiver routines and signal the closure of the link */ - if( pops && pops -> disconn_ind ) - pops -> disconn_ind(cprot); + if (pops && pops->disconn_ind) + pops->disconn_ind(cprot); #endif /* CONFIG_ISDN_X25 */ cmd.driver = lp->isdn_device; @@ -874,7 +874,7 @@ typedef struct { } ip_ports; static void -isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp) +isdn_net_log_skb(struct sk_buff *skb, isdn_net_local *lp) { /* hopefully, this was set correctly */ const u_char *p = skb_network_header(skb); @@ -887,72 +887,72 @@ isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp) /* This check stolen from 2.1.72 dev_queue_xmit_nit() */ if (p < skb->data || skb->network_header >= skb->tail) { /* fall back to old isdn_net_log_packet method() */ - char * buf = skb->data; + char *buf = skb->data; printk(KERN_DEBUG "isdn_net: protocol %04x is buggy, dev %s\n", skb->protocol, lp->netdev->dev->name); p = buf; proto = ETH_P_IP; switch (lp->p_encap) { - case ISDN_NET_ENCAP_IPTYP: - proto = ntohs(*(__be16 *)&buf[0]); - p = &buf[2]; - break; - case ISDN_NET_ENCAP_ETHER: - proto = ntohs(*(__be16 *)&buf[12]); - p = &buf[14]; - break; - case ISDN_NET_ENCAP_CISCOHDLC: - proto = ntohs(*(__be16 *)&buf[2]); - p = &buf[4]; - break; + case ISDN_NET_ENCAP_IPTYP: + proto = ntohs(*(__be16 *)&buf[0]); + p = &buf[2]; + break; + case ISDN_NET_ENCAP_ETHER: + proto = ntohs(*(__be16 *)&buf[12]); + p = &buf[14]; + break; + case ISDN_NET_ENCAP_CISCOHDLC: + proto = ntohs(*(__be16 *)&buf[2]); + p = &buf[4]; + break; #ifdef CONFIG_ISDN_PPP - case ISDN_NET_ENCAP_SYNCPPP: - proto = ntohs(skb->protocol); - p = &buf[IPPP_MAX_HEADER]; - break; + case ISDN_NET_ENCAP_SYNCPPP: + proto = ntohs(skb->protocol); + p = &buf[IPPP_MAX_HEADER]; + break; #endif } } data_ofs = ((p[0] & 15) * 4); switch (proto) { - case ETH_P_IP: - switch (p[9]) { - case 1: - strcpy(addinfo, " ICMP"); - break; - case 2: - strcpy(addinfo, " IGMP"); - break; - case 4: - strcpy(addinfo, " IPIP"); - break; - case 6: - ipp = (ip_ports *) (&p[data_ofs]); - sprintf(addinfo, " TCP, port: %d -> %d", ntohs(ipp->source), - ntohs(ipp->dest)); - break; - case 8: - strcpy(addinfo, " EGP"); - break; - case 12: - strcpy(addinfo, " PUP"); - break; - case 17: - ipp = (ip_ports *) (&p[data_ofs]); - sprintf(addinfo, " UDP, port: %d -> %d", ntohs(ipp->source), - ntohs(ipp->dest)); - break; - case 22: - strcpy(addinfo, " IDP"); - break; - } - printk(KERN_INFO "OPEN: %pI4 -> %pI4%s\n", - p + 12, p + 16, addinfo); + case ETH_P_IP: + switch (p[9]) { + case 1: + strcpy(addinfo, " ICMP"); + break; + case 2: + strcpy(addinfo, " IGMP"); + break; + case 4: + strcpy(addinfo, " IPIP"); + break; + case 6: + ipp = (ip_ports *) (&p[data_ofs]); + sprintf(addinfo, " TCP, port: %d -> %d", ntohs(ipp->source), + ntohs(ipp->dest)); + break; + case 8: + strcpy(addinfo, " EGP"); + break; + case 12: + strcpy(addinfo, " PUP"); + break; + case 17: + ipp = (ip_ports *) (&p[data_ofs]); + sprintf(addinfo, " UDP, port: %d -> %d", ntohs(ipp->source), + ntohs(ipp->dest)); break; - case ETH_P_ARP: - printk(KERN_INFO "OPEN: ARP %pI4 -> *.*.*.* ?%pI4\n", - p + 14, p + 24); + case 22: + strcpy(addinfo, " IDP"); break; + } + printk(KERN_INFO "OPEN: %pI4 -> %pI4%s\n", + p + 12, p + 16, addinfo); + break; + case ETH_P_ARP: + printk(KERN_INFO "OPEN: ARP %pI4 -> *.*.*.* ?%pI4\n", + p + 14, p + 24); + break; } } @@ -964,7 +964,7 @@ isdn_net_log_skb(struct sk_buff * skb, isdn_net_local * lp) void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb) { if (in_irq()) { - // we can't grab the lock from irq context, + // we can't grab the lock from irq context, // so we just queue the packet skb_queue_tail(&lp->super_tx_queue, skb); schedule_work(&lp->tqueue); @@ -993,12 +993,12 @@ static void isdn_net_softint(struct work_struct *work) skb = skb_dequeue(&lp->super_tx_queue); if (!skb) break; - isdn_net_writebuf_skb(lp, skb); + isdn_net_writebuf_skb(lp, skb); } spin_unlock_bh(&lp->xmit_lock); } -/* +/* * all frames sent from the (net) LL to a HL driver should go via this function * it's serialized by the caller holding the lp->xmit_lock spinlock */ @@ -1024,12 +1024,12 @@ void isdn_net_writebuf_skb(isdn_net_local *lp, struct sk_buff *skb) printk(KERN_WARNING "%s: HL driver queue full\n", lp->netdev->dev->name); goto error; } - + lp->transcount += len; isdn_net_inc_frame_cnt(lp); return; - error: +error: dev_kfree_skb(skb); lp->stats.tx_errors++; @@ -1129,14 +1129,14 @@ isdn_net_adjust_hdr(struct sk_buff *skb, struct net_device *dev) } -static void isdn_net_tx_timeout(struct net_device * ndev) +static void isdn_net_tx_timeout(struct net_device *ndev) { isdn_net_local *lp = netdev_priv(ndev); printk(KERN_WARNING "isdn_tx_timeout dev %s dialstate %d\n", ndev->name, lp->dialstate); - if (!lp->dialstate){ + if (!lp->dialstate) { lp->stats.tx_errors++; - /* + /* * There is a certain probability that this currently * works at all because if we always wake up the interface, * then upper layer will try to send the next packet @@ -1149,7 +1149,7 @@ static void isdn_net_tx_timeout(struct net_device * ndev) * * actually, this may not matter at all, because ISDN hardware * should not see transmitter hangs at all IMO - * changed KERN_DEBUG to KERN_WARNING to find out if this is + * changed KERN_DEBUG to KERN_WARNING to find out if this is * ever called --KG */ } @@ -1167,27 +1167,27 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) { isdn_net_local *lp = netdev_priv(ndev); #ifdef CONFIG_ISDN_X25 - struct concap_proto * cprot = lp -> netdev -> cprot; + struct concap_proto *cprot = lp->netdev->cprot; /* At this point hard_start_xmit() passes control to the encapsulation protocol (if present). For X.25 auto-dialing is completly bypassed because: - It does not conform with the semantics of a reliable datalink - service as needed by X.25 PLP. + service as needed by X.25 PLP. - I don't want that the interface starts dialing when the network layer - sends a message which requests to disconnect the lapb link (or if it - sends any other message not resulting in data transmission). + sends a message which requests to disconnect the lapb link (or if it + sends any other message not resulting in data transmission). Instead, dialing will be initiated by the encapsulation protocol entity when a dl_establish request is received from the upper layer. */ - if (cprot && cprot -> pops) { - int ret = cprot -> pops -> encap_and_xmit ( cprot , skb); + if (cprot && cprot->pops) { + int ret = cprot->pops->encap_and_xmit(cprot, skb); if (ret) netif_stop_queue(ndev); return ret; } else #endif - /* auto-dialing xmit function */ + /* auto-dialing xmit function */ { #ifdef ISDN_DEBUG_NET_DUMP u_char *buf; @@ -1209,12 +1209,12 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) if (lp->phone[1]) { ulong flags; - if(lp->dialwait_timer <= 0) - if(lp->dialstarted > 0 && lp->dialtimeout > 0 && time_before(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) + if (lp->dialwait_timer <= 0) + if (lp->dialstarted > 0 && lp->dialtimeout > 0 && time_before(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) lp->dialwait_timer = lp->dialstarted + lp->dialtimeout + lp->dialwait; - if(lp->dialwait_timer > 0) { - if(time_before(jiffies, lp->dialwait_timer)) { + if (lp->dialwait_timer > 0) { + if (time_before(jiffies, lp->dialwait_timer)) { isdn_net_unreachable(ndev, skb, "dial rejected: retry-time not reached"); dev_kfree_skb(skb); return NETDEV_TX_OK; @@ -1224,26 +1224,26 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) /* Grab a free ISDN-Channel */ spin_lock_irqsave(&dev->lock, flags); if (((chi = - isdn_get_free_channel( - ISDN_USAGE_NET, - lp->l2_proto, - lp->l3_proto, - lp->pre_device, - lp->pre_channel, - lp->msn) - ) < 0) && - ((chi = - isdn_get_free_channel( - ISDN_USAGE_NET, - lp->l2_proto, - lp->l3_proto, - lp->pre_device, - lp->pre_channel^1, - lp->msn) - ) < 0)) { + isdn_get_free_channel( + ISDN_USAGE_NET, + lp->l2_proto, + lp->l3_proto, + lp->pre_device, + lp->pre_channel, + lp->msn) + ) < 0) && + ((chi = + isdn_get_free_channel( + ISDN_USAGE_NET, + lp->l2_proto, + lp->l3_proto, + lp->pre_device, + lp->pre_channel^1, + lp->msn) + ) < 0)) { spin_unlock_irqrestore(&dev->lock, flags); isdn_net_unreachable(ndev, skb, - "No channel"); + "No channel"); dev_kfree_skb(skb); return NETDEV_TX_OK; } @@ -1290,13 +1290,13 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_OK; } } else { - /* Device is connected to an ISDN channel */ + /* Device is connected to an ISDN channel */ ndev->trans_start = jiffies; if (!lp->dialstate) { /* ISDN connection is established, try sending */ int ret; ret = (isdn_net_xmit(ndev, skb)); - if(ret) netif_stop_queue(ndev); + if (ret) netif_stop_queue(ndev); return ret; } else netif_stop_queue(ndev); @@ -1313,13 +1313,13 @@ isdn_net_close(struct net_device *dev) { struct net_device *p; #ifdef CONFIG_ISDN_X25 - struct concap_proto * cprot = - ((isdn_net_local *) netdev_priv(dev))->netdev->cprot; - /* printk(KERN_DEBUG "isdn_net_close %s\n" , dev-> name ); */ + struct concap_proto *cprot = + ((isdn_net_local *)netdev_priv(dev))->netdev->cprot; + /* printk(KERN_DEBUG "isdn_net_close %s\n" , dev-> name); */ #endif #ifdef CONFIG_ISDN_X25 - if( cprot && cprot -> pops ) cprot -> pops -> close( cprot ); + if (cprot && cprot->pops) cprot->pops->close(cprot); #endif netif_stop_queue(dev); p = MASTER_TO_SLAVE(dev); @@ -1327,10 +1327,10 @@ isdn_net_close(struct net_device *dev) /* If this interface has slaves, stop them also */ while (p) { #ifdef CONFIG_ISDN_X25 - cprot = ((isdn_net_local *) netdev_priv(p)) - -> netdev -> cprot; - if( cprot && cprot -> pops ) - cprot -> pops -> close( cprot ); + cprot = ((isdn_net_local *)netdev_priv(p)) + ->netdev->cprot; + if (cprot && cprot->pops) + cprot->pops->close(cprot); #endif isdn_net_hangup(p); p = MASTER_TO_SLAVE(p); @@ -1405,7 +1405,7 @@ isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev) } -/* +/* * CISCO HDLC keepalive specific stuff */ static struct sk_buff* @@ -1417,7 +1417,7 @@ isdn_net_ciscohdlck_alloc_skb(isdn_net_local *lp, int len) skb = alloc_skb(hl + len, GFP_ATOMIC); if (skb) skb_reserve(skb, hl); - else + else printk("isdn out of mem at %s:%d!\n", __FILE__, __LINE__); return skb; } @@ -1439,52 +1439,52 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) switch (cmd) { /* get/set keepalive period */ - case SIOCGKEEPPERIOD: - len = (unsigned long)sizeof(lp->cisco_keepalive_period); - if (copy_to_user(ifr->ifr_data, - &lp->cisco_keepalive_period, len)) - rc = -EFAULT; - break; - case SIOCSKEEPPERIOD: - tmp = lp->cisco_keepalive_period; - len = (unsigned long)sizeof(lp->cisco_keepalive_period); - if (copy_from_user(&period, ifr->ifr_data, len)) - rc = -EFAULT; - if ((period > 0) && (period <= 32767)) - lp->cisco_keepalive_period = period; - else - rc = -EINVAL; - if (!rc && (tmp != lp->cisco_keepalive_period)) { - expires = (unsigned long)(jiffies + - lp->cisco_keepalive_period * HZ); - mod_timer(&lp->cisco_timer, expires); - printk(KERN_INFO "%s: Keepalive period set " - "to %d seconds.\n", - dev->name, lp->cisco_keepalive_period); - } - break; + case SIOCGKEEPPERIOD: + len = (unsigned long)sizeof(lp->cisco_keepalive_period); + if (copy_to_user(ifr->ifr_data, + &lp->cisco_keepalive_period, len)) + rc = -EFAULT; + break; + case SIOCSKEEPPERIOD: + tmp = lp->cisco_keepalive_period; + len = (unsigned long)sizeof(lp->cisco_keepalive_period); + if (copy_from_user(&period, ifr->ifr_data, len)) + rc = -EFAULT; + if ((period > 0) && (period <= 32767)) + lp->cisco_keepalive_period = period; + else + rc = -EINVAL; + if (!rc && (tmp != lp->cisco_keepalive_period)) { + expires = (unsigned long)(jiffies + + lp->cisco_keepalive_period * HZ); + mod_timer(&lp->cisco_timer, expires); + printk(KERN_INFO "%s: Keepalive period set " + "to %d seconds.\n", + dev->name, lp->cisco_keepalive_period); + } + break; /* get/set debugging */ - case SIOCGDEBSERINT: - len = (unsigned long)sizeof(lp->cisco_debserint); - if (copy_to_user(ifr->ifr_data, - &lp->cisco_debserint, len)) - rc = -EFAULT; - break; - case SIOCSDEBSERINT: - len = (unsigned long)sizeof(lp->cisco_debserint); - if (copy_from_user(&debserint, - ifr->ifr_data, len)) - rc = -EFAULT; - if ((debserint >= 0) && (debserint <= 64)) - lp->cisco_debserint = debserint; - else - rc = -EINVAL; - break; - - default: + case SIOCGDEBSERINT: + len = (unsigned long)sizeof(lp->cisco_debserint); + if (copy_to_user(ifr->ifr_data, + &lp->cisco_debserint, len)) + rc = -EFAULT; + break; + case SIOCSDEBSERINT: + len = (unsigned long)sizeof(lp->cisco_debserint); + if (copy_from_user(&debserint, + ifr->ifr_data, len)) + rc = -EFAULT; + if ((debserint >= 0) && (debserint <= 64)) + lp->cisco_debserint = debserint; + else rc = -EINVAL; - break; + break; + + default: + rc = -EINVAL; + break; } return (rc); } @@ -1524,30 +1524,30 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) lp->cisco_myseq++; myseq_diff = (lp->cisco_myseq - lp->cisco_mineseen); - if ((lp->cisco_line_state) && ((myseq_diff >= 3)||(myseq_diff <= -3))) { + if ((lp->cisco_line_state) && ((myseq_diff >= 3) || (myseq_diff <= -3))) { /* line up -> down */ lp->cisco_line_state = 0; - printk (KERN_WARNING - "UPDOWN: Line protocol on Interface %s," - " changed state to down\n", lp->netdev->dev->name); + printk(KERN_WARNING + "UPDOWN: Line protocol on Interface %s," + " changed state to down\n", lp->netdev->dev->name); /* should stop routing higher-level data across */ } else if ((!lp->cisco_line_state) && - (myseq_diff >= 0) && (myseq_diff <= 2)) { + (myseq_diff >= 0) && (myseq_diff <= 2)) { /* line down -> up */ lp->cisco_line_state = 1; - printk (KERN_WARNING - "UPDOWN: Line protocol on Interface %s," - " changed state to up\n", lp->netdev->dev->name); + printk(KERN_WARNING + "UPDOWN: Line protocol on Interface %s," + " changed state to up\n", lp->netdev->dev->name); /* restart routing higher-level data across */ } if (lp->cisco_debserint) - printk (KERN_DEBUG "%s: HDLC " - "myseq %lu, mineseen %lu%c, yourseen %lu, %s\n", - lp->netdev->dev->name, last_cisco_myseq, lp->cisco_mineseen, - ((last_cisco_myseq == lp->cisco_mineseen) ? '*' : 040), - lp->cisco_yourseq, - ((lp->cisco_line_state) ? "line up" : "line down")); + printk(KERN_DEBUG "%s: HDLC " + "myseq %lu, mineseen %lu%c, yourseen %lu, %s\n", + lp->netdev->dev->name, last_cisco_myseq, lp->cisco_mineseen, + ((last_cisco_myseq == lp->cisco_mineseen) ? '*' : 040), + lp->cisco_yourseq, + ((lp->cisco_line_state) ? "line up" : "line down")); skb = isdn_net_ciscohdlck_alloc_skb(lp, 4 + 14); if (!skb) @@ -1570,7 +1570,7 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) isdn_net_write_super(lp, skb); lp->cisco_timer.expires = jiffies + lp->cisco_keepalive_period * HZ; - + add_timer(&lp->cisco_timer); } @@ -1601,7 +1601,7 @@ isdn_net_ciscohdlck_slarp_send_request(isdn_net_local *lp) isdn_net_write_super(lp, skb); } -static void +static void isdn_net_ciscohdlck_connected(isdn_net_local *lp) { lp->cisco_myseq = 0; @@ -1622,7 +1622,7 @@ isdn_net_ciscohdlck_connected(isdn_net_local *lp) add_timer(&lp->cisco_timer); } -static void +static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp) { del_timer(&lp->cisco_timer); @@ -1703,20 +1703,20 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb) printk(KERN_INFO "%s: got slarp reply: remote ip: %pI4, local ip: %pI4 mask: %pI4\n", lp->netdev->dev->name, addr, &local, mask); break; - slarp_reply_out: + slarp_reply_out: printk(KERN_INFO "%s: got invalid slarp reply (%pI4/%pI4) - ignored\n", lp->netdev->dev->name, addr, mask); break; case CISCO_SLARP_KEEPALIVE: period = (int)((jiffies - lp->cisco_last_slarp_in - + HZ/2 - 1) / HZ); + + HZ / 2 - 1) / HZ); if (lp->cisco_debserint && - (period != lp->cisco_keepalive_period) && - lp->cisco_last_slarp_in) { + (period != lp->cisco_keepalive_period) && + lp->cisco_last_slarp_in) { printk(KERN_DEBUG "%s: Keepalive period mismatch - " - "is %d but should be %d.\n", - lp->netdev->dev->name, period, - lp->cisco_keepalive_period); + "is %d but should be %d.\n", + lp->netdev->dev->name, period, + lp->cisco_keepalive_period); } lp->cisco_last_slarp_in = jiffies; my_seq = be32_to_cpup((__be32 *)(p + 0)); @@ -1732,10 +1732,10 @@ static void isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb) { unsigned char *p; - u8 addr; - u8 ctrl; - u16 type; - + u8 addr; + u8 ctrl; + u16 type; + if (skb->len < 4) goto out_free; @@ -1745,7 +1745,7 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb) type = be16_to_cpup((__be16 *)(p + 2)); p += 4; skb_pull(skb, 4); - + if (addr != CISCO_ADDR_UNICAST && addr != CISCO_ADDR_BROADCAST) { printk(KERN_WARNING "%s: Unknown Cisco addr 0x%02x\n", lp->netdev->dev->name, addr); @@ -1764,8 +1764,8 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb) case CISCO_TYPE_CDP: if (lp->cisco_debserint) printk(KERN_DEBUG "%s: Received CDP packet. use " - "\"no cdp enable\" on cisco.\n", - lp->netdev->dev->name); + "\"no cdp enable\" on cisco.\n", + lp->netdev->dev->name); goto out_free; default: /* no special cisco protocol */ @@ -1774,7 +1774,7 @@ isdn_net_ciscohdlck_receive(isdn_net_local *lp, struct sk_buff *skb) return; } - out_free: +out_free: kfree_skb(skb); } @@ -1787,7 +1787,7 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb) isdn_net_local *lp = netdev_priv(ndev); isdn_net_local *olp = lp; /* original 'lp' */ #ifdef CONFIG_ISDN_X25 - struct concap_proto *cprot = lp -> netdev -> cprot; + struct concap_proto *cprot = lp->netdev->cprot; #endif lp->transcount += skb->len; @@ -1809,60 +1809,60 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb) isdn_dumppkt("R:", skb->data, skb->len, 40); #endif switch (lp->p_encap) { - case ISDN_NET_ENCAP_ETHER: - /* Ethernet over ISDN */ - olp->huptimer = 0; - lp->huptimer = 0; - skb->protocol = isdn_net_type_trans(skb, ndev); - break; - case ISDN_NET_ENCAP_UIHDLC: - /* HDLC with UI-frame (for ispa with -h1 option) */ - olp->huptimer = 0; - lp->huptimer = 0; - skb_pull(skb, 2); - /* Fall through */ - case ISDN_NET_ENCAP_RAWIP: - /* RAW-IP without MAC-Header */ - olp->huptimer = 0; - lp->huptimer = 0; - skb->protocol = htons(ETH_P_IP); - break; - case ISDN_NET_ENCAP_CISCOHDLCK: - isdn_net_ciscohdlck_receive(lp, skb); - return; - case ISDN_NET_ENCAP_CISCOHDLC: - /* CISCO-HDLC IP with type field and fake I-frame-header */ - skb_pull(skb, 2); - /* Fall through */ - case ISDN_NET_ENCAP_IPTYP: - /* IP with type field */ - olp->huptimer = 0; - lp->huptimer = 0; - skb->protocol = *(__be16 *)&(skb->data[0]); - skb_pull(skb, 2); - if (*(unsigned short *) skb->data == 0xFFFF) - skb->protocol = htons(ETH_P_802_3); - break; + case ISDN_NET_ENCAP_ETHER: + /* Ethernet over ISDN */ + olp->huptimer = 0; + lp->huptimer = 0; + skb->protocol = isdn_net_type_trans(skb, ndev); + break; + case ISDN_NET_ENCAP_UIHDLC: + /* HDLC with UI-frame (for ispa with -h1 option) */ + olp->huptimer = 0; + lp->huptimer = 0; + skb_pull(skb, 2); + /* Fall through */ + case ISDN_NET_ENCAP_RAWIP: + /* RAW-IP without MAC-Header */ + olp->huptimer = 0; + lp->huptimer = 0; + skb->protocol = htons(ETH_P_IP); + break; + case ISDN_NET_ENCAP_CISCOHDLCK: + isdn_net_ciscohdlck_receive(lp, skb); + return; + case ISDN_NET_ENCAP_CISCOHDLC: + /* CISCO-HDLC IP with type field and fake I-frame-header */ + skb_pull(skb, 2); + /* Fall through */ + case ISDN_NET_ENCAP_IPTYP: + /* IP with type field */ + olp->huptimer = 0; + lp->huptimer = 0; + skb->protocol = *(__be16 *)&(skb->data[0]); + skb_pull(skb, 2); + if (*(unsigned short *) skb->data == 0xFFFF) + skb->protocol = htons(ETH_P_802_3); + break; #ifdef CONFIG_ISDN_PPP - case ISDN_NET_ENCAP_SYNCPPP: - /* huptimer is done in isdn_ppp_push_higher */ - isdn_ppp_receive(lp->netdev, olp, skb); - return; + case ISDN_NET_ENCAP_SYNCPPP: + /* huptimer is done in isdn_ppp_push_higher */ + isdn_ppp_receive(lp->netdev, olp, skb); + return; #endif - default: + default: #ifdef CONFIG_ISDN_X25 - /* try if there are generic sync_device receiver routines */ - if(cprot) if(cprot -> pops) - if( cprot -> pops -> data_ind){ - cprot -> pops -> data_ind(cprot,skb); - return; - }; + /* try if there are generic sync_device receiver routines */ + if (cprot) if (cprot->pops) + if (cprot->pops->data_ind) { + cprot->pops->data_ind(cprot, skb); + return; + }; #endif /* CONFIG_ISDN_X25 */ - printk(KERN_WARNING "%s: unknown encapsulation, dropping\n", - lp->netdev->dev->name); - kfree_skb(skb); - return; + printk(KERN_WARNING "%s: unknown encapsulation, dropping\n", + lp->netdev->dev->name); + kfree_skb(skb); + return; } netif_rx(skb); @@ -1904,48 +1904,48 @@ static int isdn_net_header(struct sk_buff *skb, struct net_device *dev, int len = 0; switch (lp->p_encap) { - case ISDN_NET_ENCAP_ETHER: - len = eth_header(skb, dev, type, daddr, saddr, plen); - break; + case ISDN_NET_ENCAP_ETHER: + len = eth_header(skb, dev, type, daddr, saddr, plen); + break; #ifdef CONFIG_ISDN_PPP - case ISDN_NET_ENCAP_SYNCPPP: - /* stick on a fake header to keep fragmentation code happy. */ - len = IPPP_MAX_HEADER; - skb_push(skb,len); - break; + case ISDN_NET_ENCAP_SYNCPPP: + /* stick on a fake header to keep fragmentation code happy. */ + len = IPPP_MAX_HEADER; + skb_push(skb, len); + break; #endif - case ISDN_NET_ENCAP_RAWIP: - printk(KERN_WARNING "isdn_net_header called with RAW_IP!\n"); - len = 0; - break; - case ISDN_NET_ENCAP_IPTYP: - /* ethernet type field */ - *((__be16 *)skb_push(skb, 2)) = htons(type); - len = 2; - break; - case ISDN_NET_ENCAP_UIHDLC: - /* HDLC with UI-Frames (for ispa with -h1 option) */ - *((__be16 *)skb_push(skb, 2)) = htons(0x0103); - len = 2; - break; - case ISDN_NET_ENCAP_CISCOHDLC: - case ISDN_NET_ENCAP_CISCOHDLCK: - p = skb_push(skb, 4); - *(u8 *)(p + 0) = CISCO_ADDR_UNICAST; - *(u8 *)(p + 1) = CISCO_CTRL; - *(__be16 *)(p + 2) = cpu_to_be16(type); - p += 4; - len = 4; - break; + case ISDN_NET_ENCAP_RAWIP: + printk(KERN_WARNING "isdn_net_header called with RAW_IP!\n"); + len = 0; + break; + case ISDN_NET_ENCAP_IPTYP: + /* ethernet type field */ + *((__be16 *)skb_push(skb, 2)) = htons(type); + len = 2; + break; + case ISDN_NET_ENCAP_UIHDLC: + /* HDLC with UI-Frames (for ispa with -h1 option) */ + *((__be16 *)skb_push(skb, 2)) = htons(0x0103); + len = 2; + break; + case ISDN_NET_ENCAP_CISCOHDLC: + case ISDN_NET_ENCAP_CISCOHDLCK: + p = skb_push(skb, 4); + *(u8 *)(p + 0) = CISCO_ADDR_UNICAST; + *(u8 *)(p + 1) = CISCO_CTRL; + *(__be16 *)(p + 2) = cpu_to_be16(type); + p += 4; + len = 4; + break; #ifdef CONFIG_ISDN_X25 - default: - /* try if there are generic concap protocol routines */ - if( lp-> netdev -> cprot ){ - printk(KERN_WARNING "isdn_net_header called with concap_proto!\n"); - len = 0; - break; - } + default: + /* try if there are generic concap protocol routines */ + if (lp->netdev->cprot) { + printk(KERN_WARNING "isdn_net_header called with concap_proto!\n"); + len = 0; break; + } + break; #endif /* CONFIG_ISDN_X25 */ } return len; @@ -2045,12 +2045,12 @@ isdn_net_swapbind(int drvidx) while (p) { if (p->local->pre_device == drvidx) switch (p->local->pre_channel) { - case 0: - p->local->pre_channel = 1; - break; - case 1: - p->local->pre_channel = 0; - break; + case 0: + p->local->pre_channel = 1; + break; + case 1: + p->local->pre_channel = 0; + break; } p = (isdn_net_dev *) p->next; } @@ -2134,7 +2134,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) ematch = wret = swapped = 0; #ifdef ISDN_DEBUG_NET_ICALL printk(KERN_DEBUG "n_fi: di=%d ch=%d idx=%d usg=%d\n", di, ch, idx, - dev->usage[idx]); + dev->usage[idx]); #endif while (p) { int matchret; @@ -2142,32 +2142,32 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) /* If last check has triggered as binding-swap, revert it */ switch (swapped) { - case 2: - isdn_net_swap_usage(idx, sidx); - /* fall through */ - case 1: - isdn_net_swapbind(di); - break; + case 2: + isdn_net_swap_usage(idx, sidx); + /* fall through */ + case 1: + isdn_net_swapbind(di); + break; } swapped = 0; - /* check acceptable call types for DOV */ - my_eaz = isdn_map_eaz2msn(lp->msn, di); - if (si1 == 1) { /* it's a DOV call, check if we allow it */ - if (*my_eaz == 'v' || *my_eaz == 'V' || + /* check acceptable call types for DOV */ + my_eaz = isdn_map_eaz2msn(lp->msn, di); + if (si1 == 1) { /* it's a DOV call, check if we allow it */ + if (*my_eaz == 'v' || *my_eaz == 'V' || *my_eaz == 'b' || *my_eaz == 'B') - my_eaz++; /* skip to allow a match */ - else - my_eaz = NULL; /* force non match */ - } else { /* it's a DATA call, check if we allow it */ - if (*my_eaz == 'b' || *my_eaz == 'B') - my_eaz++; /* skip to allow a match */ - } - if (my_eaz) - matchret = isdn_msncmp(eaz, my_eaz); - else - matchret = 1; - if (!matchret) - ematch = 1; + my_eaz++; /* skip to allow a match */ + else + my_eaz = NULL; /* force non match */ + } else { /* it's a DATA call, check if we allow it */ + if (*my_eaz == 'b' || *my_eaz == 'B') + my_eaz++; /* skip to allow a match */ + } + if (my_eaz) + matchret = isdn_msncmp(eaz, my_eaz); + else + matchret = 1; + if (!matchret) + ematch = 1; /* Remember if more numbers eventually can match */ if (matchret > wret) @@ -2181,8 +2181,8 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) (USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */ (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ - ))) - { + ))) + { #ifdef ISDN_DEBUG_NET_ICALL printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n", lp->pre_device, lp->pre_channel); @@ -2312,7 +2312,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) p = (isdn_net_dev *) p->next; continue; } - } + } if (lp->flags & ISDN_NET_CALLBACK) { int chi; /* @@ -2330,18 +2330,18 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) if (lp->phone[1]) { /* Grab a free ISDN-Channel */ spin_lock_irqsave(&dev->lock, flags); - if ((chi = - isdn_get_free_channel( - ISDN_USAGE_NET, - lp->l2_proto, - lp->l3_proto, - lp->pre_device, - lp->pre_channel, - lp->msn) - ) < 0) { + if ((chi = + isdn_get_free_channel( + ISDN_USAGE_NET, + lp->l2_proto, + lp->l3_proto, + lp->pre_device, + lp->pre_channel, + lp->msn) + ) < 0) { printk(KERN_WARNING "isdn_net_find_icall: No channel for %s\n", - p->dev->name); + p->dev->name); spin_unlock_irqrestore(&dev->lock, flags); return 0; } @@ -2363,11 +2363,11 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) return (lp->flags & ISDN_NET_CBHUP) ? 2 : 4; } else printk(KERN_WARNING "isdn_net: %s: No phone number\n", - p->dev->name); + p->dev->name); return 0; } else { printk(KERN_DEBUG "%s: call from %s -> %s accepted\n", - p->dev->name, nr, eaz); + p->dev->name, nr, eaz); /* if this interface is dialing, it does it probably on a different device, so free this device */ if ((lp->dialstate == 4) || (lp->dialstate == 12)) { @@ -2377,7 +2377,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) #endif isdn_net_lp_disconnected(lp); isdn_free_channel(lp->isdn_device, lp->isdn_channel, - ISDN_USAGE_NET); + ISDN_USAGE_NET); } spin_lock_irqsave(&dev->lock, flags); dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; @@ -2414,7 +2414,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) /* If none of configured EAZ/MSN matched and not verbose, be silent */ if (!ematch || dev->net_verbose) printk(KERN_INFO "isdn_net: call from %s -> %d %s ignored\n", nr, di, eaz); - return (wret == 2)?5:0; + return (wret == 2) ? 5 : 0; } /* @@ -2439,7 +2439,7 @@ isdn_net_findif(char *name) * from isdn_net_start_xmit(). */ static int -isdn_net_force_dial_lp(isdn_net_local * lp) +isdn_net_force_dial_lp(isdn_net_local *lp) { if ((!(lp->flags & ISDN_NET_CONNECTED)) && !lp->dialstate) { int chi; @@ -2449,14 +2449,14 @@ isdn_net_force_dial_lp(isdn_net_local * lp) /* Grab a free ISDN-Channel */ spin_lock_irqsave(&dev->lock, flags); if ((chi = isdn_get_free_channel( - ISDN_USAGE_NET, - lp->l2_proto, - lp->l3_proto, - lp->pre_device, - lp->pre_channel, - lp->msn)) < 0) { + ISDN_USAGE_NET, + lp->l2_proto, + lp->l3_proto, + lp->pre_device, + lp->pre_channel, + lp->msn)) < 0) { printk(KERN_WARNING "isdn_net_force_dial: No channel for %s\n", - lp->netdev->dev->name); + lp->netdev->dev->name); spin_unlock_irqrestore(&dev->lock, flags); return -EAGAIN; } @@ -2487,7 +2487,7 @@ isdn_net_force_dial_lp(isdn_net_local * lp) * themselves. */ int -isdn_net_dial_req(isdn_net_local * lp) +isdn_net_dial_req(isdn_net_local *lp) { /* is there a better error code? */ if (!(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_AUTO)) return -EBUSY; @@ -2531,7 +2531,7 @@ static void _isdn_setup(struct net_device *dev) ether_setup(dev); /* Setup the generic properties */ - dev->flags = IFF_NOARP|IFF_POINTOPOINT; + dev->flags = IFF_NOARP | IFF_POINTOPOINT; /* isdn prepends a header in the tx path, can't share skbs */ dev->priv_flags &= ~IFF_TX_SKB_SHARING; @@ -2655,7 +2655,7 @@ isdn_net_newslave(char *parm) if (n->local->master) return NULL; /* Master must not be started yet */ - if (isdn_net_device_started(n)) + if (isdn_net_device_started(n)) return NULL; return (isdn_net_new(newname, n->dev)); } @@ -2669,7 +2669,7 @@ isdn_net_newslave(char *parm) * setup first, if only selected parameters are to be changed. */ int -isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) +isdn_net_setcfg(isdn_net_ioctl_cfg *cfg) { isdn_net_dev *p = isdn_net_findif(cfg->name); ulong features; @@ -2692,9 +2692,9 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) printk(KERN_WARNING "isdn_net: No driver with selected features\n"); return -ENODEV; } - if (lp->p_encap != cfg->p_encap){ + if (lp->p_encap != cfg->p_encap) { #ifdef CONFIG_ISDN_X25 - struct concap_proto * cprot = p -> cprot; + struct concap_proto *cprot = p->cprot; #endif if (isdn_net_device_started(p)) { printk(KERN_WARNING "%s: cannot change encap when if is up\n", @@ -2702,24 +2702,24 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) return -EBUSY; } #ifdef CONFIG_ISDN_X25 - if( cprot && cprot -> pops ) - cprot -> pops -> proto_del ( cprot ); - p -> cprot = NULL; - lp -> dops = NULL; + if (cprot && cprot->pops) + cprot->pops->proto_del(cprot); + p->cprot = NULL; + lp->dops = NULL; /* ... , prepare for configuration of new one ... */ - switch ( cfg -> p_encap ){ + switch (cfg->p_encap) { case ISDN_NET_ENCAP_X25IFACE: - lp -> dops = &isdn_concap_reliable_dl_dops; + lp->dops = &isdn_concap_reliable_dl_dops; } /* ... and allocate new one ... */ - p -> cprot = isdn_concap_new( cfg -> p_encap ); + p->cprot = isdn_concap_new(cfg->p_encap); /* p -> cprot == NULL now if p_encap is not supported by means of the concap_proto mechanism */ /* the protocol is not configured yet; this will happen later when isdn_net_reset() is called */ #endif } - switch ( cfg->p_encap ) { + switch (cfg->p_encap) { case ISDN_NET_ENCAP_SYNCPPP: #ifndef CONFIG_ISDN_PPP printk(KERN_WARNING "%s: SyncPPP support not configured\n", @@ -2743,8 +2743,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) case ISDN_NET_ENCAP_CISCOHDLCK: break; default: - if( cfg->p_encap >= 0 && - cfg->p_encap <= ISDN_NET_ENCAP_MAX_ENCAP ) + if (cfg->p_encap >= 0 && + cfg->p_encap <= ISDN_NET_ENCAP_MAX_ENCAP) break; printk(KERN_WARNING "%s: encapsulation protocol %d not supported\n", @@ -2754,10 +2754,10 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) if (strlen(cfg->drvid)) { /* A bind has been requested ... */ char *c, - *e; + *e; if (strnlen(cfg->drvid, sizeof(cfg->drvid)) == - sizeof(cfg->drvid)) + sizeof(cfg->drvid)) return -EINVAL; drvidx = -1; chidx = -1; @@ -2789,8 +2789,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) /* If binding is exclusive, try to grab the channel */ spin_lock_irqsave(&dev->lock, flags); if ((i = isdn_get_free_channel(ISDN_USAGE_NET, - lp->l2_proto, lp->l3_proto, drvidx, - chidx, lp->msn)) < 0) { + lp->l2_proto, lp->l3_proto, drvidx, + chidx, lp->msn)) < 0) { /* Grab failed, because desired channel is in use */ lp->exclusive = -1; spin_unlock_irqrestore(&dev->lock, flags); @@ -2834,23 +2834,23 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) else lp->flags &= ~ISDN_NET_CBHUP; switch (cfg->callback) { - case 0: - lp->flags &= ~(ISDN_NET_CALLBACK | ISDN_NET_CBOUT); - break; - case 1: - lp->flags |= ISDN_NET_CALLBACK; - lp->flags &= ~ISDN_NET_CBOUT; - break; - case 2: - lp->flags |= ISDN_NET_CBOUT; - lp->flags &= ~ISDN_NET_CALLBACK; - break; + case 0: + lp->flags &= ~(ISDN_NET_CALLBACK | ISDN_NET_CBOUT); + break; + case 1: + lp->flags |= ISDN_NET_CALLBACK; + lp->flags &= ~ISDN_NET_CBOUT; + break; + case 2: + lp->flags |= ISDN_NET_CBOUT; + lp->flags &= ~ISDN_NET_CALLBACK; + break; } lp->flags &= ~ISDN_NET_DIALMODE_MASK; /* first all bits off */ if (cfg->dialmode && !(cfg->dialmode & ISDN_NET_DIALMODE_MASK)) { /* old isdnctrl version, where only 0 or 1 is given */ printk(KERN_WARNING - "Old isdnctrl version detected! Please update.\n"); + "Old isdnctrl version detected! Please update.\n"); lp->flags |= ISDN_NET_DM_OFF; /* turn on `off' bit */ } else { @@ -2871,13 +2871,13 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) if (cfg->p_encap != lp->p_encap) { if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) { p->dev->header_ops = NULL; - p->dev->flags = IFF_NOARP|IFF_POINTOPOINT; + p->dev->flags = IFF_NOARP | IFF_POINTOPOINT; } else { p->dev->header_ops = &isdn_header_ops; if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) p->dev->flags = IFF_BROADCAST | IFF_MULTICAST; else - p->dev->flags = IFF_NOARP|IFF_POINTOPOINT; + p->dev->flags = IFF_NOARP | IFF_POINTOPOINT; } } lp->p_encap = cfg->p_encap; @@ -2890,7 +2890,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) * Perform get-interface-parameters.ioctl */ int -isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) +isdn_net_getcfg(isdn_net_ioctl_cfg *cfg) { isdn_net_dev *p = isdn_net_findif(cfg->name); @@ -2924,7 +2924,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) cfg->triggercps = lp->triggercps; cfg->slavedelay = lp->slavedelay / HZ; cfg->chargeint = (lp->hupflags & ISDN_CHARGEHUP) ? - (lp->chargeint / HZ) : 0; + (lp->chargeint / HZ) : 0; cfg->pppbind = lp->pppbind; cfg->dialtimeout = lp->dialtimeout >= 0 ? lp->dialtimeout / HZ : -1; cfg->dialwait = lp->dialwait / HZ; @@ -2951,7 +2951,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) * Add a phone-number to an interface. */ int -isdn_net_addphone(isdn_net_ioctl_phone * phone) +isdn_net_addphone(isdn_net_ioctl_phone *phone) { isdn_net_dev *p = isdn_net_findif(phone->name); isdn_net_phone *n; @@ -2972,7 +2972,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) * This might sleep and must be called with the isdn semaphore down. */ int -isdn_net_getphones(isdn_net_ioctl_phone * phone, char __user *phones) +isdn_net_getphones(isdn_net_ioctl_phone *phone, char __user *phones) { isdn_net_dev *p = isdn_net_findif(phone->name); int inout = phone->outgoing & 1; @@ -3015,15 +3015,15 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone __user *peer) /* * Theoretical race: while this executes, the remote number might * become invalid (hang up) or change (new connection), resulting - * in (partially) wrong number copied to user. This race + * in (partially) wrong number copied to user. This race * currently ignored. */ ch = p->local->isdn_channel; dv = p->local->isdn_device; - if(ch < 0 && dv < 0) + if (ch < 0 && dv < 0) return -ENOTCONN; idx = isdn_dc2minor(dv, ch); - if (idx <0 ) + if (idx < 0) return -ENODEV; /* for pre-bound channels, we need this extra check */ if (strncmp(dev->num[idx], "???", 3) == 0) @@ -3038,7 +3038,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone __user *peer) * Delete a phone-number from an interface. */ int -isdn_net_delphone(isdn_net_ioctl_phone * phone) +isdn_net_delphone(isdn_net_ioctl_phone *phone) { isdn_net_dev *p = isdn_net_findif(phone->name); int inout = phone->outgoing & 1; @@ -3071,7 +3071,7 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone) * Delete all phone-numbers of an interface. */ static int -isdn_net_rmallphone(isdn_net_dev * p) +isdn_net_rmallphone(isdn_net_dev *p) { isdn_net_phone *n; isdn_net_phone *m; @@ -3118,7 +3118,7 @@ isdn_net_force_hangup(char *name) * Helper-function for isdn_net_rm: Do the real work. */ static int -isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) +isdn_net_realrm(isdn_net_dev *p, isdn_net_dev *q) { u_long flags; @@ -3126,8 +3126,8 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) return -EBUSY; } #ifdef CONFIG_ISDN_X25 - if( p -> cprot && p -> cprot -> pops ) - p -> cprot -> pops -> proto_del ( p -> cprot ); + if (p->cprot && p->cprot->pops) + p->cprot->pops->proto_del(p->cprot); #endif /* Free all phone-entries */ isdn_net_rmallphone(p); diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h index 7511f08effa5..cca6d68da171 100644 --- a/drivers/isdn/i4l/isdn_net.h +++ b/drivers/isdn/i4l/isdn_net.h @@ -11,7 +11,7 @@ * */ - /* Definitions for hupflags: */ +/* Definitions for hupflags: */ #define ISDN_WAITCHARGE 1 /* did not get a charge info yet */ #define ISDN_HAVECHARGE 2 /* We know a charge info */ #define ISDN_CHARGEHUP 4 /* We want to use the charge mechanism */ @@ -58,8 +58,8 @@ extern void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb); #define ISDN_MASTER_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->master)) #define ISDN_SLAVE_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->slave)) -#define MASTER_TO_SLAVE(master) \ - (((isdn_net_local *) netdev_priv(master))->slave) +#define MASTER_TO_SLAVE(master) \ + (((isdn_net_local *) netdev_priv(master))->slave) /* * is this particular channel busy? @@ -68,7 +68,7 @@ static __inline__ int isdn_net_lp_busy(isdn_net_local *lp) { if (atomic_read(&lp->frame_cnt) < ISDN_NET_MAX_QUEUE_LENGTH) return 0; - else + else return 1; } @@ -76,7 +76,7 @@ static __inline__ int isdn_net_lp_busy(isdn_net_local *lp) * For the given net device, this will get a non-busy channel out of the * corresponding bundle. The returned channel is locked. */ -static __inline__ isdn_net_local * isdn_net_get_locked_lp(isdn_net_dev *nd) +static __inline__ isdn_net_local *isdn_net_get_locked_lp(isdn_net_dev *nd) { unsigned long flags; isdn_net_local *lp; @@ -149,4 +149,3 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp) // __func__, master_lp->netdev->queue); spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags); } - diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index e38f674a7bd3..a1e760150821 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -28,18 +28,18 @@ /* Prototypes */ static int isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot); static int isdn_ppp_closewait(int slot); -static void isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, +static void isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb, int proto); static int isdn_ppp_if_get_unit(char *namebuf); -static int isdn_ppp_set_compressor(struct ippp_struct *is,struct isdn_ppp_comp_data *); +static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_data *); static struct sk_buff *isdn_ppp_decompress(struct sk_buff *, - struct ippp_struct *,struct ippp_struct *,int *proto); -static void isdn_ppp_receive_ccp(isdn_net_dev * net_dev, isdn_net_local * lp, - struct sk_buff *skb,int proto); -static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto, - struct ippp_struct *is,struct ippp_struct *master,int type); + struct ippp_struct *, struct ippp_struct *, int *proto); +static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, + struct sk_buff *skb, int proto); +static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in, int *proto, + struct ippp_struct *is, struct ippp_struct *master, int type); static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, - struct sk_buff *skb); + struct sk_buff *skb); /* New CCP stuff */ static void isdn_ppp_ccp_kickup(struct ippp_struct *is); @@ -52,7 +52,7 @@ static void isdn_ppp_ccp_reset_free_state(struct ippp_struct *is, unsigned char id); static void isdn_ppp_ccp_timer_callback(unsigned long closure); static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, - unsigned char id); + unsigned char id); static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, struct isdn_ppp_resetparams *rp); static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, @@ -61,17 +61,17 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, #ifdef CONFIG_ISDN_MPP -static ippp_bundle * isdn_ppp_bundle_arr = NULL; - +static ippp_bundle *isdn_ppp_bundle_arr = NULL; + static int isdn_ppp_mp_bundle_array_init(void); -static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to ); -static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, - struct sk_buff *skb); -static void isdn_ppp_mp_cleanup( isdn_net_local * lp ); +static int isdn_ppp_mp_init(isdn_net_local *lp, ippp_bundle *add_to); +static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, + struct sk_buff *skb); +static void isdn_ppp_mp_cleanup(isdn_net_local *lp); static int isdn_ppp_bundle(struct ippp_struct *, int unit); #endif /* CONFIG_ISDN_MPP */ - + char *isdn_ppp_revision = "$Revision: 1.1.2.3 $"; static struct ippp_struct *ippp_table[ISDN_MAX_CHANNELS]; @@ -82,11 +82,11 @@ static struct isdn_ppp_compressor *ipc_head = NULL; * frame log (debug) */ static void -isdn_ppp_frame_log(char *info, char *data, int len, int maxlen,int unit,int slot) +isdn_ppp_frame_log(char *info, char *data, int len, int maxlen, int unit, int slot) { int cnt, - j, - i; + j, + i; char buf[80]; if (len < maxlen) @@ -94,8 +94,8 @@ isdn_ppp_frame_log(char *info, char *data, int len, int maxlen,int unit,int slot for (i = 0, cnt = 0; cnt < maxlen; i++) { for (j = 0; j < 16 && cnt < maxlen; j++, cnt++) - sprintf(buf + j * 3, "%02x ", (unsigned char) data[cnt]); - printk(KERN_DEBUG "[%d/%d].%s[%d]: %s\n",unit,slot, info, i, buf); + sprintf(buf + j * 3, "%02x ", (unsigned char)data[cnt]); + printk(KERN_DEBUG "[%d/%d].%s[%d]: %s\n", unit, slot, info, i, buf); } } @@ -105,13 +105,13 @@ isdn_ppp_frame_log(char *info, char *data, int len, int maxlen,int unit,int slot * in this case we bind another lp to the master device */ int -isdn_ppp_free(isdn_net_local * lp) +isdn_ppp_free(isdn_net_local *lp) { struct ippp_struct *is; if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", - __func__, lp->ppp_slot); + __func__, lp->ppp_slot); return 0; } @@ -128,7 +128,7 @@ isdn_ppp_free(isdn_net_local * lp) #endif /* CONFIG_ISDN_MPP */ if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: ppp_slot(%d) now invalid\n", - __func__, lp->ppp_slot); + __func__, lp->ppp_slot); return 0; } is = ippp_table[lp->ppp_slot]; @@ -153,7 +153,7 @@ isdn_ppp_free(isdn_net_local * lp) * no additional lock is needed */ int -isdn_ppp_bind(isdn_net_local * lp) +isdn_ppp_bind(isdn_net_local *lp) { int i; int unit = 0; @@ -195,11 +195,11 @@ isdn_ppp_bind(isdn_net_local * lp) unit = isdn_ppp_if_get_unit(lp->netdev->dev->name); if (unit < 0) { printk(KERN_ERR "isdn_ppp_bind: illegal interface name %s.\n", - lp->netdev->dev->name); + lp->netdev->dev->name); retval = -1; goto out; } - + lp->ppp_slot = i; is = ippp_table[i]; is->lp = lp; @@ -213,7 +213,7 @@ isdn_ppp_bind(isdn_net_local * lp) retval = lp->ppp_slot; - out: +out: return retval; } @@ -223,11 +223,11 @@ isdn_ppp_bind(isdn_net_local * lp) */ void -isdn_ppp_wakeup_daemon(isdn_net_local * lp) +isdn_ppp_wakeup_daemon(isdn_net_local *lp) { if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", - __func__, lp->ppp_slot); + __func__, lp->ppp_slot); return; } ippp_table[lp->ppp_slot]->state = IPPP_OPEN | IPPP_CONNECT | IPPP_NOBLOCK; @@ -246,7 +246,7 @@ isdn_ppp_closewait(int slot) if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: slot(%d) out of range\n", - __func__, slot); + __func__, slot); return 0; } is = ippp_table[slot]; @@ -289,7 +289,7 @@ isdn_ppp_open(int min, struct file *file) return -EBUSY; } is = file->private_data = ippp_table[slot]; - + printk(KERN_DEBUG "ippp, open, slot: %d, minor: %d, state: %04x\n", slot, min, is->state); @@ -385,21 +385,21 @@ isdn_ppp_release(int min, struct file *file) #endif /* TODO: if this was the previous master: link the stuff to the new master */ - if(is->comp_stat) + if (is->comp_stat) is->compressor->free(is->comp_stat); - if(is->link_comp_stat) + if (is->link_comp_stat) is->link_compressor->free(is->link_comp_stat); - if(is->link_decomp_stat) + if (is->link_decomp_stat) is->link_decompressor->free(is->link_decomp_stat); - if(is->decomp_stat) + if (is->decomp_stat) is->decompressor->free(is->decomp_stat); - is->compressor = is->link_compressor = NULL; - is->decompressor = is->link_decompressor = NULL; + is->compressor = is->link_compressor = NULL; + is->decompressor = is->link_decompressor = NULL; is->comp_stat = is->link_comp_stat = NULL; - is->decomp_stat = is->link_decomp_stat = NULL; + is->decomp_stat = is->link_decomp_stat = NULL; /* Clean up if necessary */ - if(is->reset) + if (is->reset) isdn_ppp_ccp_reset_free(is); /* this slot is ready for new connections */ @@ -423,9 +423,9 @@ get_arg(void __user *b, void *val, int len) * set arg .. ioctl helper */ static int -set_arg(void __user *b, void *val,int len) +set_arg(void __user *b, void *val, int len) { - if(len <= 0) + if (len <= 0) len = sizeof(void *); if (copy_to_user(b, val, len)) return -EFAULT; @@ -471,7 +471,7 @@ int isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) { unsigned long val; - int r,i,j; + int r, i, j; struct ippp_struct *is; isdn_net_local *lp; struct isdn_ppp_comp_data data; @@ -487,177 +487,177 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) return -EINVAL; switch (cmd) { - case PPPIOCBUNDLE: + case PPPIOCBUNDLE: #ifdef CONFIG_ISDN_MPP - if (!(is->state & IPPP_CONNECT)) - return -EINVAL; - if ((r = get_arg(argp, &val, sizeof(val) ))) - return r; - printk(KERN_DEBUG "iPPP-bundle: minor: %d, slave unit: %d, master unit: %d\n", - (int) min, (int) is->unit, (int) val); - return isdn_ppp_bundle(is, val); + if (!(is->state & IPPP_CONNECT)) + return -EINVAL; + if ((r = get_arg(argp, &val, sizeof(val)))) + return r; + printk(KERN_DEBUG "iPPP-bundle: minor: %d, slave unit: %d, master unit: %d\n", + (int) min, (int) is->unit, (int) val); + return isdn_ppp_bundle(is, val); #else - return -1; + return -1; #endif - break; - case PPPIOCGUNIT: /* get ppp/isdn unit number */ - if ((r = set_arg(argp, &is->unit, sizeof(is->unit) ))) - return r; - break; - case PPPIOCGIFNAME: - if(!lp) - return -EINVAL; - if ((r = set_arg(argp, lp->netdev->dev->name, - strlen(lp->netdev->dev->name)))) - return r; - break; - case PPPIOCGMPFLAGS: /* get configuration flags */ - if ((r = set_arg(argp, &is->mpppcfg, sizeof(is->mpppcfg) ))) - return r; - break; - case PPPIOCSMPFLAGS: /* set configuration flags */ - if ((r = get_arg(argp, &val, sizeof(val) ))) - return r; - is->mpppcfg = val; - break; - case PPPIOCGFLAGS: /* get configuration flags */ - if ((r = set_arg(argp, &is->pppcfg,sizeof(is->pppcfg) ))) - return r; - break; - case PPPIOCSFLAGS: /* set configuration flags */ - if ((r = get_arg(argp, &val, sizeof(val) ))) { - return r; - } - if (val & SC_ENABLE_IP && !(is->pppcfg & SC_ENABLE_IP) && (is->state & IPPP_CONNECT)) { - if (lp) { - /* OK .. we are ready to send buffers */ - is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */ - netif_wake_queue(lp->netdev->dev); - break; - } - } - is->pppcfg = val; - break; - case PPPIOCGIDLE: /* get idle time information */ + break; + case PPPIOCGUNIT: /* get ppp/isdn unit number */ + if ((r = set_arg(argp, &is->unit, sizeof(is->unit)))) + return r; + break; + case PPPIOCGIFNAME: + if (!lp) + return -EINVAL; + if ((r = set_arg(argp, lp->netdev->dev->name, + strlen(lp->netdev->dev->name)))) + return r; + break; + case PPPIOCGMPFLAGS: /* get configuration flags */ + if ((r = set_arg(argp, &is->mpppcfg, sizeof(is->mpppcfg)))) + return r; + break; + case PPPIOCSMPFLAGS: /* set configuration flags */ + if ((r = get_arg(argp, &val, sizeof(val)))) + return r; + is->mpppcfg = val; + break; + case PPPIOCGFLAGS: /* get configuration flags */ + if ((r = set_arg(argp, &is->pppcfg, sizeof(is->pppcfg)))) + return r; + break; + case PPPIOCSFLAGS: /* set configuration flags */ + if ((r = get_arg(argp, &val, sizeof(val)))) { + return r; + } + if (val & SC_ENABLE_IP && !(is->pppcfg & SC_ENABLE_IP) && (is->state & IPPP_CONNECT)) { if (lp) { - struct ppp_idle pidle; - pidle.xmit_idle = pidle.recv_idle = lp->huptimer; - if ((r = set_arg(argp, &pidle,sizeof(struct ppp_idle)))) - return r; + /* OK .. we are ready to send buffers */ + is->pppcfg = val; /* isdn_ppp_xmit test for SC_ENABLE_IP !!! */ + netif_wake_queue(lp->netdev->dev); + break; } - break; - case PPPIOCSMRU: /* set receive unit size for PPP */ - if ((r = get_arg(argp, &val, sizeof(val) ))) - return r; - is->mru = val; - break; - case PPPIOCSMPMRU: - break; - case PPPIOCSMPMTU: - break; - case PPPIOCSMAXCID: /* set the maximum compression slot id */ - if ((r = get_arg(argp, &val, sizeof(val) ))) + } + is->pppcfg = val; + break; + case PPPIOCGIDLE: /* get idle time information */ + if (lp) { + struct ppp_idle pidle; + pidle.xmit_idle = pidle.recv_idle = lp->huptimer; + if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle)))) return r; - val++; - if (is->maxcid != val) { + } + break; + case PPPIOCSMRU: /* set receive unit size for PPP */ + if ((r = get_arg(argp, &val, sizeof(val)))) + return r; + is->mru = val; + break; + case PPPIOCSMPMRU: + break; + case PPPIOCSMPMTU: + break; + case PPPIOCSMAXCID: /* set the maximum compression slot id */ + if ((r = get_arg(argp, &val, sizeof(val)))) + return r; + val++; + if (is->maxcid != val) { #ifdef CONFIG_ISDN_PPP_VJ - struct slcompress *sltmp; + struct slcompress *sltmp; #endif - if (is->debug & 0x1) - printk(KERN_DEBUG "ippp, ioctl: changed MAXCID to %ld\n", val); - is->maxcid = val; + if (is->debug & 0x1) + printk(KERN_DEBUG "ippp, ioctl: changed MAXCID to %ld\n", val); + is->maxcid = val; #ifdef CONFIG_ISDN_PPP_VJ - sltmp = slhc_init(16, val); - if (!sltmp) { - printk(KERN_ERR "ippp, can't realloc slhc struct\n"); - return -ENOMEM; - } - if (is->slcomp) - slhc_free(is->slcomp); - is->slcomp = sltmp; -#endif - } - break; - case PPPIOCGDEBUG: - if ((r = set_arg(argp, &is->debug, sizeof(is->debug) ))) - return r; - break; - case PPPIOCSDEBUG: - if ((r = get_arg(argp, &val, sizeof(val) ))) - return r; - is->debug = val; - break; - case PPPIOCGCOMPRESSORS: - { - unsigned long protos[8] = {0,}; - struct isdn_ppp_compressor *ipc = ipc_head; - while(ipc) { - j = ipc->num / (sizeof(long)*8); - i = ipc->num % (sizeof(long)*8); - if(j < 8) - protos[j] |= (0x1<next; - } - if ((r = set_arg(argp,protos,8*sizeof(long) ))) - return r; + sltmp = slhc_init(16, val); + if (!sltmp) { + printk(KERN_ERR "ippp, can't realloc slhc struct\n"); + return -ENOMEM; } - break; - case PPPIOCSCOMPRESSOR: - if ((r = get_arg(argp, &data, sizeof(struct isdn_ppp_comp_data)))) - return r; - return isdn_ppp_set_compressor(is, &data); - case PPPIOCGCALLINFO: - { - struct pppcallinfo pci; - memset((char *) &pci,0,sizeof(struct pppcallinfo)); - if(lp) - { - strncpy(pci.local_num,lp->msn,63); - if(lp->dial) { - strncpy(pci.remote_num,lp->dial->num,63); - } - pci.charge_units = lp->charge; - if(lp->outgoing) - pci.calltype = CALLTYPE_OUTGOING; - else - pci.calltype = CALLTYPE_INCOMING; - if(lp->flags & ISDN_NET_CALLBACK) - pci.calltype |= CALLTYPE_CALLBACK; - } - return set_arg(argp,&pci,sizeof(struct pppcallinfo)); + if (is->slcomp) + slhc_free(is->slcomp); + is->slcomp = sltmp; +#endif + } + break; + case PPPIOCGDEBUG: + if ((r = set_arg(argp, &is->debug, sizeof(is->debug)))) + return r; + break; + case PPPIOCSDEBUG: + if ((r = get_arg(argp, &val, sizeof(val)))) + return r; + is->debug = val; + break; + case PPPIOCGCOMPRESSORS: + { + unsigned long protos[8] = {0,}; + struct isdn_ppp_compressor *ipc = ipc_head; + while (ipc) { + j = ipc->num / (sizeof(long) * 8); + i = ipc->num % (sizeof(long) * 8); + if (j < 8) + protos[j] |= (0x1 << i); + ipc = ipc->next; + } + if ((r = set_arg(argp, protos, 8 * sizeof(long)))) + return r; + } + break; + case PPPIOCSCOMPRESSOR: + if ((r = get_arg(argp, &data, sizeof(struct isdn_ppp_comp_data)))) + return r; + return isdn_ppp_set_compressor(is, &data); + case PPPIOCGCALLINFO: + { + struct pppcallinfo pci; + memset((char *)&pci, 0, sizeof(struct pppcallinfo)); + if (lp) + { + strncpy(pci.local_num, lp->msn, 63); + if (lp->dial) { + strncpy(pci.remote_num, lp->dial->num, 63); } + pci.charge_units = lp->charge; + if (lp->outgoing) + pci.calltype = CALLTYPE_OUTGOING; + else + pci.calltype = CALLTYPE_INCOMING; + if (lp->flags & ISDN_NET_CALLBACK) + pci.calltype |= CALLTYPE_CALLBACK; + } + return set_arg(argp, &pci, sizeof(struct pppcallinfo)); + } #ifdef CONFIG_IPPP_FILTER - case PPPIOCSPASS: - { - struct sock_filter *code; - int len = get_filter(argp, &code); - if (len < 0) - return len; - kfree(is->pass_filter); - is->pass_filter = code; - is->pass_len = len; - break; - } - case PPPIOCSACTIVE: - { - struct sock_filter *code; - int len = get_filter(argp, &code); - if (len < 0) - return len; - kfree(is->active_filter); - is->active_filter = code; - is->active_len = len; - break; - } + case PPPIOCSPASS: + { + struct sock_filter *code; + int len = get_filter(argp, &code); + if (len < 0) + return len; + kfree(is->pass_filter); + is->pass_filter = code; + is->pass_len = len; + break; + } + case PPPIOCSACTIVE: + { + struct sock_filter *code; + int len = get_filter(argp, &code); + if (len < 0) + return len; + kfree(is->active_filter); + is->active_filter = code; + is->active_len = len; + break; + } #endif /* CONFIG_IPPP_FILTER */ - default: - break; + default: + break; } return 0; } unsigned int -isdn_ppp_poll(struct file *file, poll_table * wait) +isdn_ppp_poll(struct file *file, poll_table *wait) { u_int mask; struct ippp_buf_queue *bf, *bl; @@ -668,13 +668,13 @@ isdn_ppp_poll(struct file *file, poll_table * wait) if (is->debug & 0x2) printk(KERN_DEBUG "isdn_ppp_poll: minor: %d\n", - iminor(file->f_path.dentry->d_inode)); + iminor(file->f_path.dentry->d_inode)); /* just registers wait_queue hook. This doesn't really wait. */ poll_wait(file, &is->wq, wait); if (!(is->state & IPPP_OPEN)) { - if(is->state == IPPP_CLOSEWAIT) + if (is->state == IPPP_CLOSEWAIT) return POLLHUP; printk(KERN_DEBUG "isdn_ppp: device not open\n"); return POLLERR; @@ -827,7 +827,7 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count) return 0; if ((dev->drv[lp->isdn_device]->flags & DRV_FLAG_RUNNING) && - lp->dialstate == 0 && + lp->dialstate == 0 && (lp->flags & ISDN_NET_CONNECTED)) { unsigned short hl; struct sk_buff *skb; @@ -837,7 +837,7 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count) * 16 bytes, now we are looking what the driver want */ hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen; - skb = alloc_skb(hl+count, GFP_ATOMIC); + skb = alloc_skb(hl + count, GFP_ATOMIC); if (!skb) { printk(KERN_WARNING "isdn_ppp_write: out of memory!\n"); return count; @@ -850,10 +850,10 @@ isdn_ppp_write(int min, struct file *file, const char __user *buf, int count) } if (is->debug & 0x40) { printk(KERN_DEBUG "ppp xmit: len %d\n", (int) skb->len); - isdn_ppp_frame_log("xmit", skb->data, skb->len, 32,is->unit,lp->ppp_slot); + isdn_ppp_frame_log("xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); } - isdn_ppp_send_ccp(lp->netdev,lp,skb); /* keeps CCP/compression states in sync */ + isdn_ppp_send_ccp(lp->netdev, lp, skb); /* keeps CCP/compression states in sync */ isdn_net_write_super(lp, skb); } @@ -869,10 +869,10 @@ int isdn_ppp_init(void) { int i, - j; - + j; + #ifdef CONFIG_ISDN_MPP - if( isdn_ppp_mp_bundle_array_init() < 0 ) + if (isdn_ppp_mp_bundle_array_init() < 0) return -ENOMEM; #endif /* CONFIG_ISDN_MPP */ @@ -891,7 +891,7 @@ isdn_ppp_init(void) for (j = 0; j < NUM_RCV_BUFFS; j++) { ippp_table[i]->rq[j].buf = NULL; ippp_table[i]->rq[j].last = ippp_table[i]->rq + - (NUM_RCV_BUFFS + j - 1) % NUM_RCV_BUFFS; + (NUM_RCV_BUFFS + j - 1) % NUM_RCV_BUFFS; ippp_table[i]->rq[j].next = ippp_table[i]->rq + (j + 1) % NUM_RCV_BUFFS; } } @@ -916,7 +916,7 @@ isdn_ppp_cleanup(void) * check for address/control field and skip if allowed * retval != 0 -> discard packet silently */ -static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb) +static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb) { if (skb->len < 1) return -1; @@ -930,7 +930,7 @@ static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb) // skip address/control (AC) field skb_pull(skb, 2); - } else { + } else { if (is->pppcfg & SC_REJ_COMP_AC) // if AC compression was not negotiated, but used, discard packet return -1; @@ -942,10 +942,10 @@ static int isdn_ppp_skip_ac(struct ippp_struct *is, struct sk_buff *skb) * get the PPP protocol header and pull skb * retval < 0 -> discard packet silently */ -static int isdn_ppp_strip_proto(struct sk_buff *skb) +static int isdn_ppp_strip_proto(struct sk_buff *skb) { int proto; - + if (skb->len < 1) return -1; @@ -966,7 +966,7 @@ static int isdn_ppp_strip_proto(struct sk_buff *skb) /* * handler for incoming packets on a syncPPP interface */ -void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb) +void isdn_ppp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb) { struct ippp_struct *is; int slot; @@ -977,7 +977,7 @@ void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buf slot = lp->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "isdn_ppp_receive: lp->ppp_slot(%d)\n", - lp->ppp_slot); + lp->ppp_slot); kfree_skb(skb); return; } @@ -985,35 +985,35 @@ void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buf if (is->debug & 0x4) { printk(KERN_DEBUG "ippp_receive: is:%08lx lp:%08lx slot:%d unit:%d len:%d\n", - (long)is,(long)lp,lp->ppp_slot,is->unit,(int) skb->len); - isdn_ppp_frame_log("receive", skb->data, skb->len, 32,is->unit,lp->ppp_slot); - } - - if (isdn_ppp_skip_ac(is, skb) < 0) { - kfree_skb(skb); - return; - } - proto = isdn_ppp_strip_proto(skb); - if (proto < 0) { - kfree_skb(skb); - return; - } - + (long)is, (long)lp, lp->ppp_slot, is->unit, (int)skb->len); + isdn_ppp_frame_log("receive", skb->data, skb->len, 32, is->unit, lp->ppp_slot); + } + + if (isdn_ppp_skip_ac(is, skb) < 0) { + kfree_skb(skb); + return; + } + proto = isdn_ppp_strip_proto(skb); + if (proto < 0) { + kfree_skb(skb); + return; + } + #ifdef CONFIG_ISDN_MPP - if (is->compflags & SC_LINK_DECOMP_ON) { - skb = isdn_ppp_decompress(skb, is, NULL, &proto); - if (!skb) // decompression error - return; - } - - if (!(is->mpppcfg & SC_REJ_MP_PROT)) { // we agreed to receive MPPP - if (proto == PPP_MP) { - isdn_ppp_mp_receive(net_dev, lp, skb); - return; - } - } + if (is->compflags & SC_LINK_DECOMP_ON) { + skb = isdn_ppp_decompress(skb, is, NULL, &proto); + if (!skb) // decompression error + return; + } + + if (!(is->mpppcfg & SC_REJ_MP_PROT)) { // we agreed to receive MPPP + if (proto == PPP_MP) { + isdn_ppp_mp_receive(net_dev, lp, skb); + return; + } + } #endif - isdn_ppp_push_higher(net_dev, lp, skb, proto); + isdn_ppp_push_higher(net_dev, lp, skb, proto); } /* @@ -1022,116 +1022,116 @@ void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buf * note: net_dev has to be master net_dev */ static void -isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff *skb, int proto) +isdn_ppp_push_higher(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb, int proto) { struct net_device *dev = net_dev->dev; - struct ippp_struct *is, *mis; + struct ippp_struct *is, *mis; isdn_net_local *mlp = NULL; int slot; slot = lp->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "isdn_ppp_push_higher: lp->ppp_slot(%d)\n", - lp->ppp_slot); + lp->ppp_slot); goto drop_packet; } is = ippp_table[slot]; - - if (lp->master) { // FIXME? + + if (lp->master) { // FIXME? mlp = ISDN_MASTER_PRIV(lp); - slot = mlp->ppp_slot; - if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { - printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n", - lp->ppp_slot); + slot = mlp->ppp_slot; + if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { + printk(KERN_ERR "isdn_ppp_push_higher: master->ppp_slot(%d)\n", + lp->ppp_slot); goto drop_packet; - } - } - mis = ippp_table[slot]; + } + } + mis = ippp_table[slot]; if (is->debug & 0x10) { printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto); - isdn_ppp_frame_log("rpush", skb->data, skb->len, 32,is->unit,lp->ppp_slot); + isdn_ppp_frame_log("rpush", skb->data, skb->len, 32, is->unit, lp->ppp_slot); } if (mis->compflags & SC_DECOMP_ON) { skb = isdn_ppp_decompress(skb, is, mis, &proto); if (!skb) // decompression error - return; - } + return; + } switch (proto) { - case PPP_IPX: /* untested */ - if (is->debug & 0x20) - printk(KERN_DEBUG "isdn_ppp: IPX\n"); - skb->protocol = htons(ETH_P_IPX); - break; - case PPP_IP: - if (is->debug & 0x20) - printk(KERN_DEBUG "isdn_ppp: IP\n"); - skb->protocol = htons(ETH_P_IP); - break; - case PPP_COMP: - case PPP_COMPFRAG: - printk(KERN_INFO "isdn_ppp: unexpected compressed frame dropped\n"); - goto drop_packet; + case PPP_IPX: /* untested */ + if (is->debug & 0x20) + printk(KERN_DEBUG "isdn_ppp: IPX\n"); + skb->protocol = htons(ETH_P_IPX); + break; + case PPP_IP: + if (is->debug & 0x20) + printk(KERN_DEBUG "isdn_ppp: IP\n"); + skb->protocol = htons(ETH_P_IP); + break; + case PPP_COMP: + case PPP_COMPFRAG: + printk(KERN_INFO "isdn_ppp: unexpected compressed frame dropped\n"); + goto drop_packet; #ifdef CONFIG_ISDN_PPP_VJ - case PPP_VJC_UNCOMP: - if (is->debug & 0x20) - printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n"); + case PPP_VJC_UNCOMP: + if (is->debug & 0x20) + printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n"); + if (net_dev->local->ppp_slot < 0) { + printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", + __func__, net_dev->local->ppp_slot); + goto drop_packet; + } + if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) { + printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n"); + goto drop_packet; + } + skb->protocol = htons(ETH_P_IP); + break; + case PPP_VJC_COMP: + if (is->debug & 0x20) + printk(KERN_DEBUG "isdn_ppp: VJC_COMP\n"); + { + struct sk_buff *skb_old = skb; + int pkt_len; + skb = dev_alloc_skb(skb_old->len + 128); + + if (!skb) { + printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); + skb = skb_old; + goto drop_packet; + } + skb_put(skb, skb_old->len + 128); + skb_copy_from_linear_data(skb_old, skb->data, + skb_old->len); if (net_dev->local->ppp_slot < 0) { printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", - __func__, net_dev->local->ppp_slot); + __func__, net_dev->local->ppp_slot); goto drop_packet; } - if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) { - printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n"); + pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp, + skb->data, skb_old->len); + kfree_skb(skb_old); + if (pkt_len < 0) goto drop_packet; - } + + skb_trim(skb, pkt_len); skb->protocol = htons(ETH_P_IP); - break; - case PPP_VJC_COMP: - if (is->debug & 0x20) - printk(KERN_DEBUG "isdn_ppp: VJC_COMP\n"); - { - struct sk_buff *skb_old = skb; - int pkt_len; - skb = dev_alloc_skb(skb_old->len + 128); - - if (!skb) { - printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); - skb = skb_old; - goto drop_packet; - } - skb_put(skb, skb_old->len + 128); - skb_copy_from_linear_data(skb_old, skb->data, - skb_old->len); - if (net_dev->local->ppp_slot < 0) { - printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n", - __func__, net_dev->local->ppp_slot); - goto drop_packet; - } - pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp, - skb->data, skb_old->len); - kfree_skb(skb_old); - if (pkt_len < 0) - goto drop_packet; - - skb_trim(skb, pkt_len); - skb->protocol = htons(ETH_P_IP); - } - break; + } + break; #endif - case PPP_CCP: - case PPP_CCPFRAG: - isdn_ppp_receive_ccp(net_dev,lp,skb,proto); - /* Dont pop up ResetReq/Ack stuff to the daemon any - longer - the job is done already */ - if(skb->data[0] == CCP_RESETREQ || - skb->data[0] == CCP_RESETACK) - break; - /* fall through */ - default: - isdn_ppp_fill_rq(skb->data, skb->len, proto, lp->ppp_slot); /* push data to pppd device */ - kfree_skb(skb); - return; + case PPP_CCP: + case PPP_CCPFRAG: + isdn_ppp_receive_ccp(net_dev, lp, skb, proto); + /* Dont pop up ResetReq/Ack stuff to the daemon any + longer - the job is done already */ + if (skb->data[0] == CCP_RESETREQ || + skb->data[0] == CCP_RESETACK) + break; + /* fall through */ + default: + isdn_ppp_fill_rq(skb->data, skb->len, proto, lp->ppp_slot); /* push data to pppd device */ + kfree_skb(skb); + return; } #ifdef CONFIG_IPPP_FILTER @@ -1173,7 +1173,7 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff /* net_dev->local->stats.rx_packets++; done in isdn_net.c */ return; - drop_packet: +drop_packet: net_dev->local->stats.rx_dropped++; kfree_skb(skb); } @@ -1183,11 +1183,11 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff * checks whether we have enough space at the beginning of the skb * and allocs a new SKB if necessary */ -static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len) +static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p, int len) { struct sk_buff *skb = *skb_p; - if(skb_headroom(skb) < len) { + if (skb_headroom(skb) < len) { struct sk_buff *nskb = skb_realloc_headroom(skb, len); if (!nskb) { @@ -1195,12 +1195,12 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len) dev_kfree_skb(skb); return NULL; } - printk(KERN_DEBUG "isdn_ppp_skb_push:under %d %d\n",skb_headroom(skb),len); + printk(KERN_DEBUG "isdn_ppp_skb_push:under %d %d\n", skb_headroom(skb), len); dev_kfree_skb(skb); *skb_p = nskb; return skb_push(nskb, len); } - return skb_push(skb,len); + return skb_push(skb, len); } /* @@ -1214,10 +1214,10 @@ static unsigned char *isdn_ppp_skb_push(struct sk_buff **skb_p,int len) int isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) { - isdn_net_local *lp,*mlp; + isdn_net_local *lp, *mlp; isdn_net_dev *nd; unsigned int proto = PPP_IP; /* 0x21 */ - struct ippp_struct *ipt,*ipts; + struct ippp_struct *ipt, *ipts; int slot, retval = NETDEV_TX_OK; mlp = netdev_priv(netdev); @@ -1226,7 +1226,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) slot = mlp->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n", - mlp->ppp_slot); + mlp->ppp_slot); kfree_skb(skb); goto out; } @@ -1240,17 +1240,17 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) } switch (ntohs(skb->protocol)) { - case ETH_P_IP: - proto = PPP_IP; - break; - case ETH_P_IPX: - proto = PPP_IPX; /* untested */ - break; - default: - printk(KERN_ERR "isdn_ppp: skipped unsupported protocol: %#x.\n", - skb->protocol); - dev_kfree_skb(skb); - goto out; + case ETH_P_IP: + proto = PPP_IP; + break; + case ETH_P_IPX: + proto = PPP_IPX; /* untested */ + break; + default: + printk(KERN_ERR "isdn_ppp: skipped unsupported protocol: %#x.\n", + skb->protocol); + dev_kfree_skb(skb); + goto out; } lp = isdn_net_get_locked_lp(nd); @@ -1264,7 +1264,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) slot = lp->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "isdn_ppp_xmit: lp->ppp_slot(%d)\n", - lp->ppp_slot); + lp->ppp_slot); kfree_skb(skb); goto unlock; } @@ -1277,7 +1277,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) /* Pull off the fake header we stuck on earlier to keep * the fragmentation code happy. */ - skb_pull(skb,IPPP_MAX_HEADER); + skb_pull(skb, IPPP_MAX_HEADER); #ifdef CONFIG_IPPP_FILTER /* check if we should pass this packet @@ -1312,26 +1312,26 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) if (ipt->debug & 0x4) printk(KERN_DEBUG "xmit skb, len %d\n", (int) skb->len); - if (ipts->debug & 0x40) - isdn_ppp_frame_log("xmit0", skb->data, skb->len, 32,ipts->unit,lp->ppp_slot); + if (ipts->debug & 0x40) + isdn_ppp_frame_log("xmit0", skb->data, skb->len, 32, ipts->unit, lp->ppp_slot); #ifdef CONFIG_ISDN_PPP_VJ if (proto == PPP_IP && ipts->pppcfg & SC_COMP_TCP) { /* ipts here? probably yes, but check this again */ struct sk_buff *new_skb; - unsigned short hl; + unsigned short hl; /* * we need to reserve enough space in front of * sk_buff. old call to dev_alloc_skb only reserved * 16 bytes, now we are looking what the driver want. */ hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen + IPPP_MAX_HEADER; - /* + /* * Note: hl might still be insufficient because the method * above does not account for a possibible MPPP slave channel * which had larger HL header space requirements than the * master. */ - new_skb = alloc_skb(hl+skb->len, GFP_ATOMIC); + new_skb = alloc_skb(hl + skb->len, GFP_ATOMIC); if (new_skb) { u_char *buf; int pktlen; @@ -1342,9 +1342,9 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) buf = skb->data; pktlen = slhc_compress(ipts->slcomp, skb->data, skb->len, new_skb->data, - &buf, !(ipts->pppcfg & SC_NO_TCP_CCID)); + &buf, !(ipts->pppcfg & SC_NO_TCP_CCID)); - if (buf != skb->data) { + if (buf != skb->data) { if (new_skb->data != buf) printk(KERN_ERR "isdn_ppp: FATAL error after slhc_compress!!\n"); dev_kfree_skb(skb); @@ -1369,11 +1369,11 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) /* * normal (single link) or bundle compression */ - if(ipts->compflags & SC_COMP_ON) { + if (ipts->compflags & SC_COMP_ON) { /* We send compressed only if both down- und upstream compression is negotiated, that means, CCP is up */ - if(ipts->compflags & SC_DECOMP_ON) { - skb = isdn_ppp_compress(skb,&proto,ipt,ipts,0); + if (ipts->compflags & SC_DECOMP_ON) { + skb = isdn_ppp_compress(skb, &proto, ipt, ipts, 0); } else { printk(KERN_DEBUG "isdn_ppp: CCP not yet up - sending as-is\n"); } @@ -1389,7 +1389,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) ipts->mp_seqno++; if (ipt->mpppcfg & SC_OUT_SHORT_SEQ) { unsigned char *data = isdn_ppp_skb_push(&skb, 3); - if(!data) + if (!data) goto unlock; mp_seqno &= 0xfff; data[0] = MP_BEGIN_FRAG | MP_END_FRAG | ((mp_seqno >> 8) & 0xf); /* (B)egin & (E)ndbit .. */ @@ -1397,7 +1397,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) data[2] = proto; /* PID compression */ } else { unsigned char *data = isdn_ppp_skb_push(&skb, 5); - if(!data) + if (!data) goto unlock; data[0] = MP_BEGIN_FRAG | MP_END_FRAG; /* (B)egin & (E)ndbit .. */ data[1] = (mp_seqno >> 16) & 0xff; /* sequence number: 24bit */ @@ -1412,25 +1412,25 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) /* * 'link in bundle' compression ... */ - if(ipt->compflags & SC_LINK_COMP_ON) - skb = isdn_ppp_compress(skb,&proto,ipt,ipts,1); + if (ipt->compflags & SC_LINK_COMP_ON) + skb = isdn_ppp_compress(skb, &proto, ipt, ipts, 1); - if( (ipt->pppcfg & SC_COMP_PROT) && (proto <= 0xff) ) { - unsigned char *data = isdn_ppp_skb_push(&skb,1); - if(!data) + if ((ipt->pppcfg & SC_COMP_PROT) && (proto <= 0xff)) { + unsigned char *data = isdn_ppp_skb_push(&skb, 1); + if (!data) goto unlock; data[0] = proto & 0xff; } else { - unsigned char *data = isdn_ppp_skb_push(&skb,2); - if(!data) + unsigned char *data = isdn_ppp_skb_push(&skb, 2); + if (!data) goto unlock; data[0] = (proto >> 8) & 0xff; data[1] = proto & 0xff; } - if(!(ipt->pppcfg & SC_COMP_AC)) { - unsigned char *data = isdn_ppp_skb_push(&skb,2); - if(!data) + if (!(ipt->pppcfg & SC_COMP_AC)) { + unsigned char *data = isdn_ppp_skb_push(&skb, 2); + if (!data) goto unlock; data[0] = 0xff; /* All Stations */ data[1] = 0x03; /* Unnumbered information */ @@ -1440,14 +1440,14 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev) if (ipts->debug & 0x40) { printk(KERN_DEBUG "skb xmit: len: %d\n", (int) skb->len); - isdn_ppp_frame_log("xmit", skb->data, skb->len, 32,ipt->unit,lp->ppp_slot); + isdn_ppp_frame_log("xmit", skb->data, skb->len, 32, ipt->unit, lp->ppp_slot); } - + isdn_net_writebuf_skb(lp, skb); - unlock: +unlock: spin_unlock_bh(&lp->xmit_lock); - out: +out: return retval; } @@ -1488,12 +1488,12 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp) p++; *p = htons(proto); } - + drop |= is->pass_filter - && sk_run_filter(skb, is->pass_filter) == 0; + && sk_run_filter(skb, is->pass_filter) == 0; drop |= is->active_filter - && sk_run_filter(skb, is->active_filter) == 0; - + && sk_run_filter(skb, is->active_filter) == 0; + skb_push(skb, IPPP_MAX_HEADER - 4); return drop; } @@ -1502,8 +1502,8 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp) /* this is _not_ rfc1990 header, but something we convert both short and long * headers to for convinience's sake: - * byte 0 is flags as in rfc1990 - * bytes 1...4 is 24-bit seqence number converted to host byte order + * byte 0 is flags as in rfc1990 + * bytes 1...4 is 24-bit seqence number converted to host byte order */ #define MP_HEADER_LEN 5 @@ -1511,51 +1511,51 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp) #define MP_SHORTSEQ_MASK 0x00000fff #define MP_LONGSEQ_MAX MP_LONGSEQ_MASK #define MP_SHORTSEQ_MAX MP_SHORTSEQ_MASK -#define MP_LONGSEQ_MAXBIT ((MP_LONGSEQ_MASK+1)>>1) -#define MP_SHORTSEQ_MAXBIT ((MP_SHORTSEQ_MASK+1)>>1) +#define MP_LONGSEQ_MAXBIT ((MP_LONGSEQ_MASK + 1) >> 1) +#define MP_SHORTSEQ_MAXBIT ((MP_SHORTSEQ_MASK + 1) >> 1) /* sequence-wrap safe comparisons (for long sequence)*/ -#define MP_LT(a,b) ((a-b)&MP_LONGSEQ_MAXBIT) -#define MP_LE(a,b) !((b-a)&MP_LONGSEQ_MAXBIT) -#define MP_GT(a,b) ((b-a)&MP_LONGSEQ_MAXBIT) -#define MP_GE(a,b) !((a-b)&MP_LONGSEQ_MAXBIT) +#define MP_LT(a, b) ((a - b) & MP_LONGSEQ_MAXBIT) +#define MP_LE(a, b) !((b - a) & MP_LONGSEQ_MAXBIT) +#define MP_GT(a, b) ((b - a) & MP_LONGSEQ_MAXBIT) +#define MP_GE(a, b) !((a - b) & MP_LONGSEQ_MAXBIT) -#define MP_SEQ(f) ((*(u32*)(f->data+1))) +#define MP_SEQ(f) ((*(u32 *)(f->data + 1))) #define MP_FLAGS(f) (f->data[0]) static int isdn_ppp_mp_bundle_array_init(void) { int i; - int sz = ISDN_MAX_CHANNELS*sizeof(ippp_bundle); - if( (isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL ) + int sz = ISDN_MAX_CHANNELS * sizeof(ippp_bundle); + if ((isdn_ppp_bundle_arr = kzalloc(sz, GFP_KERNEL)) == NULL) return -ENOMEM; - for( i = 0; i < ISDN_MAX_CHANNELS; i++ ) + for (i = 0; i < ISDN_MAX_CHANNELS; i++) spin_lock_init(&isdn_ppp_bundle_arr[i].lock); return 0; } -static ippp_bundle * isdn_ppp_mp_bundle_alloc(void) +static ippp_bundle *isdn_ppp_mp_bundle_alloc(void) { int i; - for( i = 0; i < ISDN_MAX_CHANNELS; i++ ) + for (i = 0; i < ISDN_MAX_CHANNELS; i++) if (isdn_ppp_bundle_arr[i].ref_ct <= 0) return (isdn_ppp_bundle_arr + i); return NULL; } -static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to ) +static int isdn_ppp_mp_init(isdn_net_local *lp, ippp_bundle *add_to) { - struct ippp_struct * is; + struct ippp_struct *is; if (lp->ppp_slot < 0) { printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", - __func__, lp->ppp_slot); - return(-EINVAL); + __func__, lp->ppp_slot); + return (-EINVAL); } is = ippp_table[lp->ppp_slot]; if (add_to) { - if( lp->netdev->pb ) + if (lp->netdev->pb) lp->netdev->pb->ref_ct--; lp->netdev->pb = add_to; } else { /* first link in a bundle */ @@ -1568,76 +1568,76 @@ static int isdn_ppp_mp_init( isdn_net_local * lp, ippp_bundle * add_to ) lp->netdev->pb->seq = UINT_MAX; } lp->netdev->pb->ref_ct++; - + is->last_link_seqno = 0; return 0; } -static u32 isdn_ppp_mp_get_seq( int short_seq, - struct sk_buff * skb, u32 last_seq ); -static struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp, - struct sk_buff * from, struct sk_buff * to ); -static void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp, - struct sk_buff * from, struct sk_buff * to ); -static void isdn_ppp_mp_free_skb( ippp_bundle * mp, struct sk_buff * skb ); -static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb ); - -static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, - struct sk_buff *skb) +static u32 isdn_ppp_mp_get_seq(int short_seq, + struct sk_buff *skb, u32 last_seq); +static struct sk_buff *isdn_ppp_mp_discard(ippp_bundle *mp, + struct sk_buff *from, struct sk_buff *to); +static void isdn_ppp_mp_reassembly(isdn_net_dev *net_dev, isdn_net_local *lp, + struct sk_buff *from, struct sk_buff *to); +static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb); +static void isdn_ppp_mp_print_recv_pkt(int slot, struct sk_buff *skb); + +static void isdn_ppp_mp_receive(isdn_net_dev *net_dev, isdn_net_local *lp, + struct sk_buff *skb) { struct ippp_struct *is; - isdn_net_local * lpq; - ippp_bundle * mp; - isdn_mppp_stats * stats; - struct sk_buff * newfrag, * frag, * start, *nextf; + isdn_net_local *lpq; + ippp_bundle *mp; + isdn_mppp_stats *stats; + struct sk_buff *newfrag, *frag, *start, *nextf; u32 newseq, minseq, thisseq; unsigned long flags; int slot; spin_lock_irqsave(&net_dev->pb->lock, flags); - mp = net_dev->pb; - stats = &mp->stats; + mp = net_dev->pb; + stats = &mp->stats; slot = lp->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: lp->ppp_slot(%d)\n", - __func__, lp->ppp_slot); + __func__, lp->ppp_slot); stats->frame_drops++; dev_kfree_skb(skb); spin_unlock_irqrestore(&mp->lock, flags); return; } is = ippp_table[slot]; - if( ++mp->frames > stats->max_queue_len ) + if (++mp->frames > stats->max_queue_len) stats->max_queue_len = mp->frames; - + if (is->debug & 0x8) isdn_ppp_mp_print_recv_pkt(lp->ppp_slot, skb); - newseq = isdn_ppp_mp_get_seq(is->mpppcfg & SC_IN_SHORT_SEQ, - skb, is->last_link_seqno); + newseq = isdn_ppp_mp_get_seq(is->mpppcfg & SC_IN_SHORT_SEQ, + skb, is->last_link_seqno); /* if this packet seq # is less than last already processed one, - * toss it right away, but check for sequence start case first + * toss it right away, but check for sequence start case first */ - if( mp->seq > MP_LONGSEQ_MAX && (newseq & MP_LONGSEQ_MAXBIT) ) { + if (mp->seq > MP_LONGSEQ_MAX && (newseq & MP_LONGSEQ_MAXBIT)) { mp->seq = newseq; /* the first packet: required for * rfc1990 non-compliant clients -- * prevents constant packet toss */ - } else if( MP_LT(newseq, mp->seq) ) { + } else if (MP_LT(newseq, mp->seq)) { stats->frame_drops++; isdn_ppp_mp_free_skb(mp, skb); spin_unlock_irqrestore(&mp->lock, flags); return; } - + /* find the minimum received sequence number over all links */ is->last_link_seqno = minseq = newseq; for (lpq = net_dev->queue;;) { slot = lpq->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: lpq->ppp_slot(%d)\n", - __func__, lpq->ppp_slot); + __func__, lpq->ppp_slot); } else { u32 lls = ippp_table[slot]->last_link_seqno; if (MP_LT(lls, minseq)) @@ -1651,17 +1651,17 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, * packets */ newfrag = skb; - /* if this new fragment is before the first one, then enqueue it now. */ - if ((frag = mp->frags) == NULL || MP_LT(newseq, MP_SEQ(frag))) { + /* if this new fragment is before the first one, then enqueue it now. */ + if ((frag = mp->frags) == NULL || MP_LT(newseq, MP_SEQ(frag))) { newfrag->next = frag; - mp->frags = frag = newfrag; - newfrag = NULL; - } + mp->frags = frag = newfrag; + newfrag = NULL; + } - start = MP_FLAGS(frag) & MP_BEGIN_FRAG && - MP_SEQ(frag) == mp->seq ? frag : NULL; + start = MP_FLAGS(frag) & MP_BEGIN_FRAG && + MP_SEQ(frag) == mp->seq ? frag : NULL; - /* + /* * main fragment traversing loop * * try to accomplish several tasks: @@ -1675,71 +1675,71 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, * come to complete such sequence and it should be discarded * * loop completes when we accomplished the following tasks: - * - new fragment is inserted in the proper sequence ('newfrag' is + * - new fragment is inserted in the proper sequence ('newfrag' is * set to NULL) - * - we hit a gap in the sequence, so no reassembly/processing is + * - we hit a gap in the sequence, so no reassembly/processing is * possible ('start' would be set to NULL) * * algorithm for this code is derived from code in the book * 'PPP Design And Debugging' by James Carlson (Addison-Wesley) */ - while (start != NULL || newfrag != NULL) { - - thisseq = MP_SEQ(frag); - nextf = frag->next; - - /* drop any duplicate fragments */ - if (newfrag != NULL && thisseq == newseq) { - isdn_ppp_mp_free_skb(mp, newfrag); - newfrag = NULL; - } - - /* insert new fragment before next element if possible. */ - if (newfrag != NULL && (nextf == NULL || - MP_LT(newseq, MP_SEQ(nextf)))) { - newfrag->next = nextf; - frag->next = nextf = newfrag; - newfrag = NULL; - } - - if (start != NULL) { - /* check for misplaced start */ - if (start != frag && (MP_FLAGS(frag) & MP_BEGIN_FRAG)) { + while (start != NULL || newfrag != NULL) { + + thisseq = MP_SEQ(frag); + nextf = frag->next; + + /* drop any duplicate fragments */ + if (newfrag != NULL && thisseq == newseq) { + isdn_ppp_mp_free_skb(mp, newfrag); + newfrag = NULL; + } + + /* insert new fragment before next element if possible. */ + if (newfrag != NULL && (nextf == NULL || + MP_LT(newseq, MP_SEQ(nextf)))) { + newfrag->next = nextf; + frag->next = nextf = newfrag; + newfrag = NULL; + } + + if (start != NULL) { + /* check for misplaced start */ + if (start != frag && (MP_FLAGS(frag) & MP_BEGIN_FRAG)) { printk(KERN_WARNING"isdn_mppp(seq %d): new " - "BEGIN flag with no prior END", thisseq); + "BEGIN flag with no prior END", thisseq); stats->seqerrs++; stats->frame_drops++; - start = isdn_ppp_mp_discard(mp, start,frag); + start = isdn_ppp_mp_discard(mp, start, frag); nextf = frag->next; - } - } else if (MP_LE(thisseq, minseq)) { - if (MP_FLAGS(frag) & MP_BEGIN_FRAG) + } + } else if (MP_LE(thisseq, minseq)) { + if (MP_FLAGS(frag) & MP_BEGIN_FRAG) start = frag; - else { + else { if (MP_FLAGS(frag) & MP_END_FRAG) - stats->frame_drops++; - if( mp->frags == frag ) - mp->frags = nextf; + stats->frame_drops++; + if (mp->frags == frag) + mp->frags = nextf; isdn_ppp_mp_free_skb(mp, frag); frag = nextf; continue; - } + } } - + /* if start is non-null and we have end fragment, then - * we have full reassembly sequence -- reassemble + * we have full reassembly sequence -- reassemble * and process packet now */ - if (start != NULL && (MP_FLAGS(frag) & MP_END_FRAG)) { - minseq = mp->seq = (thisseq+1) & MP_LONGSEQ_MASK; - /* Reassemble the packet then dispatch it */ + if (start != NULL && (MP_FLAGS(frag) & MP_END_FRAG)) { + minseq = mp->seq = (thisseq + 1) & MP_LONGSEQ_MASK; + /* Reassemble the packet then dispatch it */ isdn_ppp_mp_reassembly(net_dev, lp, start, nextf); - - start = NULL; - frag = NULL; - mp->frags = nextf; - } + start = NULL; + frag = NULL; + + mp->frags = nextf; + } /* check if need to update start pointer: if we just * reassembled the packet and sequence is contiguous @@ -1749,48 +1749,48 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, * if sequence is not contiguous, either clear everything * below low watermark and set start to the next frag or * clear start ptr. - */ - if (nextf != NULL && - ((thisseq+1) & MP_LONGSEQ_MASK) == MP_SEQ(nextf)) { - /* if we just reassembled and the next one is here, + */ + if (nextf != NULL && + ((thisseq + 1) & MP_LONGSEQ_MASK) == MP_SEQ(nextf)) { + /* if we just reassembled and the next one is here, * then start another reassembly. */ - if (frag == NULL) { + if (frag == NULL) { if (MP_FLAGS(nextf) & MP_BEGIN_FRAG) - start = nextf; + start = nextf; else { - printk(KERN_WARNING"isdn_mppp(seq %d):" - " END flag with no following " - "BEGIN", thisseq); + printk(KERN_WARNING"isdn_mppp(seq %d):" + " END flag with no following " + "BEGIN", thisseq); stats->seqerrs++; } } - } else { - if ( nextf != NULL && frag != NULL && - MP_LT(thisseq, minseq)) { + } else { + if (nextf != NULL && frag != NULL && + MP_LT(thisseq, minseq)) { /* we've got a break in the sequence * and we not at the end yet * and we did not just reassembled *(if we did, there wouldn't be anything before) - * and we below the low watermark - * discard all the frames below low watermark + * and we below the low watermark + * discard all the frames below low watermark * and start over */ stats->frame_drops++; - mp->frags = isdn_ppp_mp_discard(mp,start,nextf); + mp->frags = isdn_ppp_mp_discard(mp, start, nextf); } /* break in the sequence, no reassembly */ - start = NULL; - } - - frag = nextf; - } /* while -- main loop */ - - if (mp->frags == NULL) - mp->frags = frag; - - /* rather straighforward way to deal with (not very) possible + start = NULL; + } + + frag = nextf; + } /* while -- main loop */ + + if (mp->frags == NULL) + mp->frags = frag; + + /* rather straighforward way to deal with (not very) possible * queue overflow */ if (mp->frames > MP_MAX_QUEUE_LEN) { stats->overflows++; @@ -1803,11 +1803,11 @@ static void isdn_ppp_mp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, spin_unlock_irqrestore(&mp->lock, flags); } -static void isdn_ppp_mp_cleanup( isdn_net_local * lp ) +static void isdn_ppp_mp_cleanup(isdn_net_local *lp) { - struct sk_buff * frag = lp->netdev->pb->frags; - struct sk_buff * nextfrag; - while( frag ) { + struct sk_buff *frag = lp->netdev->pb->frags; + struct sk_buff *nextfrag; + while (frag) { nextfrag = frag->next; isdn_ppp_mp_free_skb(lp->netdev->pb, frag); frag = nextfrag; @@ -1815,117 +1815,117 @@ static void isdn_ppp_mp_cleanup( isdn_net_local * lp ) lp->netdev->pb->frags = NULL; } -static u32 isdn_ppp_mp_get_seq( int short_seq, - struct sk_buff * skb, u32 last_seq ) +static u32 isdn_ppp_mp_get_seq(int short_seq, + struct sk_buff *skb, u32 last_seq) { u32 seq; int flags = skb->data[0] & (MP_BEGIN_FRAG | MP_END_FRAG); - - if( !short_seq ) + + if (!short_seq) { seq = ntohl(*(__be32 *)skb->data) & MP_LONGSEQ_MASK; - skb_push(skb,1); + skb_push(skb, 1); } else { - /* convert 12-bit short seq number to 24-bit long one - */ + /* convert 12-bit short seq number to 24-bit long one + */ seq = ntohs(*(__be16 *)skb->data) & MP_SHORTSEQ_MASK; - + /* check for seqence wrap */ - if( !(seq & MP_SHORTSEQ_MAXBIT) && - (last_seq & MP_SHORTSEQ_MAXBIT) && - (unsigned long)last_seq <= MP_LONGSEQ_MAX ) - seq |= (last_seq + MP_SHORTSEQ_MAX+1) & - (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK); + if (!(seq & MP_SHORTSEQ_MAXBIT) && + (last_seq & MP_SHORTSEQ_MAXBIT) && + (unsigned long)last_seq <= MP_LONGSEQ_MAX) + seq |= (last_seq + MP_SHORTSEQ_MAX + 1) & + (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK); else seq |= last_seq & (~MP_SHORTSEQ_MASK & MP_LONGSEQ_MASK); - + skb_push(skb, 3); /* put converted seqence back in skb */ } - *(u32*)(skb->data+1) = seq; /* put seqence back in _host_ byte + *(u32 *)(skb->data + 1) = seq; /* put seqence back in _host_ byte * order */ skb->data[0] = flags; /* restore flags */ return seq; } -struct sk_buff * isdn_ppp_mp_discard( ippp_bundle * mp, - struct sk_buff * from, struct sk_buff * to ) +struct sk_buff *isdn_ppp_mp_discard(ippp_bundle *mp, + struct sk_buff *from, struct sk_buff *to) { - if( from ) + if (from) while (from != to) { - struct sk_buff * next = from->next; + struct sk_buff *next = from->next; isdn_ppp_mp_free_skb(mp, from); - from = next; + from = next; } return from; } -void isdn_ppp_mp_reassembly( isdn_net_dev * net_dev, isdn_net_local * lp, - struct sk_buff * from, struct sk_buff * to ) +void isdn_ppp_mp_reassembly(isdn_net_dev *net_dev, isdn_net_local *lp, + struct sk_buff *from, struct sk_buff *to) { - ippp_bundle * mp = net_dev->pb; + ippp_bundle *mp = net_dev->pb; int proto; - struct sk_buff * skb; + struct sk_buff *skb; unsigned int tot_len; if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", - __func__, lp->ppp_slot); + __func__, lp->ppp_slot); return; } - if( MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG) ) { - if( ippp_table[lp->ppp_slot]->debug & 0x40 ) + if (MP_FLAGS(from) == (MP_BEGIN_FRAG | MP_END_FRAG)) { + if (ippp_table[lp->ppp_slot]->debug & 0x40) printk(KERN_DEBUG "isdn_mppp: reassembly: frame %d, " - "len %d\n", MP_SEQ(from), from->len ); + "len %d\n", MP_SEQ(from), from->len); skb = from; skb_pull(skb, MP_HEADER_LEN); - mp->frames--; + mp->frames--; } else { - struct sk_buff * frag; + struct sk_buff *frag; int n; - for(tot_len=n=0, frag=from; frag != to; frag=frag->next, n++) + for (tot_len = n = 0, frag = from; frag != to; frag = frag->next, n++) tot_len += frag->len - MP_HEADER_LEN; - if( ippp_table[lp->ppp_slot]->debug & 0x40 ) + if (ippp_table[lp->ppp_slot]->debug & 0x40) printk(KERN_DEBUG"isdn_mppp: reassembling frames %d " - "to %d, len %d\n", MP_SEQ(from), - (MP_SEQ(from)+n-1) & MP_LONGSEQ_MASK, tot_len ); - if( (skb = dev_alloc_skb(tot_len)) == NULL ) { + "to %d, len %d\n", MP_SEQ(from), + (MP_SEQ(from) + n - 1) & MP_LONGSEQ_MASK, tot_len); + if ((skb = dev_alloc_skb(tot_len)) == NULL) { printk(KERN_ERR "isdn_mppp: cannot allocate sk buff " - "of size %d\n", tot_len); + "of size %d\n", tot_len); isdn_ppp_mp_discard(mp, from, to); return; } - while( from != to ) { + while (from != to) { unsigned int len = from->len - MP_HEADER_LEN; skb_copy_from_linear_data_offset(from, MP_HEADER_LEN, - skb_put(skb,len), + skb_put(skb, len), len); frag = from->next; isdn_ppp_mp_free_skb(mp, from); - from = frag; + from = frag; } } - proto = isdn_ppp_strip_proto(skb); + proto = isdn_ppp_strip_proto(skb); isdn_ppp_push_higher(net_dev, lp, skb, proto); } -static void isdn_ppp_mp_free_skb(ippp_bundle * mp, struct sk_buff * skb) +static void isdn_ppp_mp_free_skb(ippp_bundle *mp, struct sk_buff *skb) { dev_kfree_skb(skb); mp->frames--; } -static void isdn_ppp_mp_print_recv_pkt( int slot, struct sk_buff * skb ) +static void isdn_ppp_mp_print_recv_pkt(int slot, struct sk_buff *skb) { - printk(KERN_DEBUG "mp_recv: %d/%d -> %02x %02x %02x %02x %02x %02x\n", - slot, (int) skb->len, - (int) skb->data[0], (int) skb->data[1], (int) skb->data[2], - (int) skb->data[3], (int) skb->data[4], (int) skb->data[5]); + printk(KERN_DEBUG "mp_recv: %d/%d -> %02x %02x %02x %02x %02x %02x\n", + slot, (int) skb->len, + (int) skb->data[0], (int) skb->data[1], (int) skb->data[2], + (int) skb->data[3], (int) skb->data[4], (int) skb->data[5]); } static int @@ -1944,18 +1944,18 @@ isdn_ppp_bundle(struct ippp_struct *is, int unit) return -EINVAL; } - spin_lock_irqsave(&p->pb->lock, flags); + spin_lock_irqsave(&p->pb->lock, flags); nlp = is->lp; lp = p->queue; - if( nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS || - lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS ) { + if (nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS || + lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "ippp_bundle: binding to invalid slot %d\n", - nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS ? - nlp->ppp_slot : lp->ppp_slot ); + nlp->ppp_slot < 0 || nlp->ppp_slot >= ISDN_MAX_CHANNELS ? + nlp->ppp_slot : lp->ppp_slot); rc = -EINVAL; goto out; - } + } isdn_net_add_to_bundle(p, nlp); @@ -1971,9 +1971,9 @@ isdn_ppp_bundle(struct ippp_struct *is, int unit) spin_unlock_irqrestore(&p->pb->lock, flags); return rc; } - + #endif /* CONFIG_ISDN_MPP */ - + /* * network device ioctl handlers */ @@ -2020,7 +2020,7 @@ isdn_ppp_dev_ioctl_stats(int slot, struct ifreq *ifr, struct net_device *dev) int isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { - int error=0; + int error = 0; int len; isdn_net_local *lp = netdev_priv(dev); @@ -2030,18 +2030,18 @@ isdn_ppp_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) switch (cmd) { #define PPP_VERSION "2.3.7" - case SIOCGPPPVER: - len = strlen(PPP_VERSION) + 1; - if (copy_to_user(ifr->ifr_data, PPP_VERSION, len)) - error = -EFAULT; - break; + case SIOCGPPPVER: + len = strlen(PPP_VERSION) + 1; + if (copy_to_user(ifr->ifr_data, PPP_VERSION, len)) + error = -EFAULT; + break; - case SIOCGPPPSTATS: - error = isdn_ppp_dev_ioctl_stats(lp->ppp_slot, ifr, dev); - break; - default: - error = -EINVAL; - break; + case SIOCGPPPSTATS: + error = isdn_ppp_dev_ioctl_stats(lp->ppp_slot, ifr, dev); + break; + default: + error = -EINVAL; + break; } return error; } @@ -2050,9 +2050,9 @@ static int isdn_ppp_if_get_unit(char *name) { int len, - i, - unit = 0, - deci; + i, + unit = 0, + deci; len = strlen(name); @@ -2129,7 +2129,7 @@ isdn_ppp_hangup_slave(char *name) break; } else if (mlp->flags & ISDN_NET_CONNECTED) break; - + sdev = mlp->slave; } if (!sdev) @@ -2202,8 +2202,8 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto, /* Alloc large enough skb */ hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen; - skb = alloc_skb(len + hl + 16,GFP_ATOMIC); - if(!skb) { + skb = alloc_skb(len + hl + 16, GFP_ATOMIC); + if (!skb) { printk(KERN_WARNING "ippp: CCP cannot send reset - out of memory\n"); return; @@ -2211,7 +2211,7 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto, skb_reserve(skb, hl); /* We may need to stuff an address and control field first */ - if(!(is->pppcfg & SC_COMP_AC)) { + if (!(is->pppcfg & SC_COMP_AC)) { p = skb_put(skb, 2); *p++ = 0xff; *p++ = 0x03; @@ -2228,14 +2228,14 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto, *p++ = (cnt & 0xff); /* Now stuff remaining bytes */ - if(len) { + if (len) { p = skb_put(skb, len); memcpy(p, data, len); } /* skb is now ready for xmit */ printk(KERN_DEBUG "Sending CCP Frame:\n"); - isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit,lp->ppp_slot); + isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); isdn_net_write_super(lp, skb); } @@ -2245,7 +2245,7 @@ static struct ippp_ccp_reset *isdn_ppp_ccp_reset_alloc(struct ippp_struct *is) { struct ippp_ccp_reset *r; r = kzalloc(sizeof(struct ippp_ccp_reset), GFP_KERNEL); - if(!r) { + if (!r) { printk(KERN_ERR "ippp_ccp: failed to allocate reset data" " structure - no mem\n"); return NULL; @@ -2262,8 +2262,8 @@ static void isdn_ppp_ccp_reset_free(struct ippp_struct *is) printk(KERN_DEBUG "ippp_ccp: freeing reset data structure %p\n", is->reset); - for(id = 0; id < 256; id++) { - if(is->reset->rs[id]) { + for (id = 0; id < 256; id++) { + if (is->reset->rs[id]) { isdn_ppp_ccp_reset_free_state(is, (unsigned char)id); } } @@ -2277,11 +2277,11 @@ static void isdn_ppp_ccp_reset_free_state(struct ippp_struct *is, { struct ippp_ccp_reset_state *rs; - if(is->reset->rs[id]) { + if (is->reset->rs[id]) { printk(KERN_DEBUG "ippp_ccp: freeing state for id %d\n", id); rs = is->reset->rs[id]; /* Make sure the kernel will not call back later */ - if(rs->ta) + if (rs->ta) del_timer(&rs->timer); is->reset->rs[id] = NULL; kfree(rs); @@ -2297,13 +2297,13 @@ static void isdn_ppp_ccp_timer_callback(unsigned long closure) struct ippp_ccp_reset_state *rs = (struct ippp_ccp_reset_state *)closure; - if(!rs) { + if (!rs) { printk(KERN_ERR "ippp_ccp: timer cb with zero closure.\n"); return; } - if(rs->ta && rs->state == CCPResetSentReq) { + if (rs->ta && rs->state == CCPResetSentReq) { /* We are correct here */ - if(!rs->expra) { + if (!rs->expra) { /* Hmm, there is no Ack really expected. We can clean up the state now, it will be reallocated if the decompressor insists on another reset */ @@ -2317,7 +2317,7 @@ static void isdn_ppp_ccp_timer_callback(unsigned long closure) isdn_ppp_ccp_xmit_reset(rs->is, PPP_CCP, CCP_RESETREQ, rs->id, rs->data, rs->dlen); /* Restart timer */ - rs->timer.expires = jiffies + HZ*5; + rs->timer.expires = jiffies + HZ * 5; add_timer(&rs->timer); } else { printk(KERN_WARNING "ippp_ccp: timer cb in wrong state %d\n", @@ -2327,16 +2327,16 @@ static void isdn_ppp_ccp_timer_callback(unsigned long closure) /* Allocate a new reset transaction state */ static struct ippp_ccp_reset_state *isdn_ppp_ccp_reset_alloc_state(struct ippp_struct *is, - unsigned char id) + unsigned char id) { struct ippp_ccp_reset_state *rs; - if(is->reset->rs[id]) { + if (is->reset->rs[id]) { printk(KERN_WARNING "ippp_ccp: old state exists for id %d\n", id); return NULL; } else { rs = kzalloc(sizeof(struct ippp_ccp_reset_state), GFP_KERNEL); - if(!rs) + if (!rs) return NULL; rs->state = CCPResetIdle; rs->is = is; @@ -2357,21 +2357,21 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, { struct ippp_ccp_reset_state *rs; - if(rp->valid) { + if (rp->valid) { /* The decompressor defines parameters by itself */ - if(rp->rsend) { + if (rp->rsend) { /* And he wants us to send a request */ - if(!(rp->idval)) { + if (!(rp->idval)) { printk(KERN_ERR "ippp_ccp: decompressor must" " specify reset id\n"); return; } - if(is->reset->rs[rp->id]) { + if (is->reset->rs[rp->id]) { /* There is already a transaction in existence for this id. May be still waiting for a Ack or may be wrong. */ rs = is->reset->rs[rp->id]; - if(rs->state == CCPResetSentReq && rs->ta) { + if (rs->state == CCPResetSentReq && rs->ta) { printk(KERN_DEBUG "ippp_ccp: reset" " trans still in progress" " for id %d\n", rp->id); @@ -2385,14 +2385,14 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, printk(KERN_DEBUG "ippp_ccp: new trans for id" " %d to be started\n", rp->id); rs = isdn_ppp_ccp_reset_alloc_state(is, rp->id); - if(!rs) { + if (!rs) { printk(KERN_ERR "ippp_ccp: out of mem" " allocing ccp trans\n"); return; } rs->state = CCPResetSentReq; rs->expra = rp->expra; - if(rp->dtval) { + if (rp->dtval) { rs->dlen = rp->dlen; memcpy(rs->data, rp->data, rp->dlen); } @@ -2401,7 +2401,7 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, CCP_RESETREQ, rs->id, rs->data, rs->dlen); /* Start the timer */ - rs->timer.expires = jiffies + 5*HZ; + rs->timer.expires = jiffies + 5 * HZ; add_timer(&rs->timer); rs->ta = 1; } @@ -2413,12 +2413,12 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, care about them, so we just send the minimal requests and increase ids only when an Ack is received for a given id */ - if(is->reset->rs[is->reset->lastid]) { + if (is->reset->rs[is->reset->lastid]) { /* There is already a transaction in existence for this id. May be still waiting for a Ack or may be wrong. */ rs = is->reset->rs[is->reset->lastid]; - if(rs->state == CCPResetSentReq && rs->ta) { + if (rs->state == CCPResetSentReq && rs->ta) { printk(KERN_DEBUG "ippp_ccp: reset" " trans still in progress" " for id %d\n", rp->id); @@ -2432,7 +2432,7 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, " %d to be started\n", is->reset->lastid); rs = isdn_ppp_ccp_reset_alloc_state(is, is->reset->lastid); - if(!rs) { + if (!rs) { printk(KERN_ERR "ippp_ccp: out of mem" " allocing ccp trans\n"); return; @@ -2446,7 +2446,7 @@ static void isdn_ppp_ccp_reset_trans(struct ippp_struct *is, isdn_ppp_ccp_xmit_reset(is, PPP_CCP, CCP_RESETREQ, rs->id, NULL, 0); /* Start the timer */ - rs->timer.expires = jiffies + 5*HZ; + rs->timer.expires = jiffies + 5 * HZ; add_timer(&rs->timer); rs->ta = 1; } @@ -2460,17 +2460,17 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, { struct ippp_ccp_reset_state *rs = is->reset->rs[id]; - if(rs) { - if(rs->ta && rs->state == CCPResetSentReq) { + if (rs) { + if (rs->ta && rs->state == CCPResetSentReq) { /* Great, we are correct */ - if(!rs->expra) + if (!rs->expra) printk(KERN_DEBUG "ippp_ccp: ResetAck received" " for id %d but not expected\n", id); } else { printk(KERN_INFO "ippp_ccp: ResetAck received out of" "sync for id %d\n", id); } - if(rs->ta) { + if (rs->ta) { rs->ta = 0; del_timer(&rs->timer); } @@ -2483,7 +2483,7 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, is->reset->lastid++; } -/* +/* * decompress packet * * if master = 0, we're trying to uncompress an per-link compressed packet, @@ -2495,8 +2495,8 @@ static void isdn_ppp_ccp_reset_ack_rcvd(struct ippp_struct *is, * NULL if decompression error */ -static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struct *is,struct ippp_struct *master, - int *proto) +static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb, struct ippp_struct *is, struct ippp_struct *master, + int *proto) { void *stat = NULL; struct isdn_ppp_compressor *ipc = NULL; @@ -2506,8 +2506,8 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struc struct isdn_ppp_resetparams rsparm; unsigned char rsdata[IPPP_RESET_MAXDATABYTES]; - if(!master) { - // per-link decompression + if (!master) { + // per-link decompression stat = is->link_decomp_stat; ipc = is->link_decompressor; ri = is; @@ -2524,28 +2524,28 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struc } BUG_ON(!stat); // if we have a compressor, stat has been set as well - if((master && *proto == PPP_COMP) || (!master && *proto == PPP_COMPFRAG) ) { + if ((master && *proto == PPP_COMP) || (!master && *proto == PPP_COMPFRAG)) { // compressed packets are compressed by their protocol type // Set up reset params for the decompressor - memset(&rsparm, 0, sizeof(rsparm)); - rsparm.data = rsdata; - rsparm.maxdlen = IPPP_RESET_MAXDATABYTES; - - skb_out = dev_alloc_skb(is->mru + PPP_HDRLEN); - if (!skb_out) { - kfree_skb(skb); - printk(KERN_ERR "ippp: decomp memory allocation failure\n"); + memset(&rsparm, 0, sizeof(rsparm)); + rsparm.data = rsdata; + rsparm.maxdlen = IPPP_RESET_MAXDATABYTES; + + skb_out = dev_alloc_skb(is->mru + PPP_HDRLEN); + if (!skb_out) { + kfree_skb(skb); + printk(KERN_ERR "ippp: decomp memory allocation failure\n"); return NULL; - } + } len = ipc->decompress(stat, skb, skb_out, &rsparm); kfree_skb(skb); if (len <= 0) { - switch(len) { + switch (len) { case DECOMP_ERROR: printk(KERN_INFO "ippp: decomp wants reset %s params\n", rsparm.valid ? "with" : "without"); - + isdn_ppp_ccp_reset_trans(ri, &rsparm); break; case DECOMP_FATALERROR: @@ -2563,7 +2563,7 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struc return NULL; } return skb_out; - } else { + } else { // uncompressed packets are fed through the decompressor to // update the decompressor state ipc->incomp(stat, skb, *proto); @@ -2572,31 +2572,31 @@ static struct sk_buff *isdn_ppp_decompress(struct sk_buff *skb,struct ippp_struc } /* - * compress a frame + * compress a frame * type=0: normal/bundle compression * =1: link compression * returns original skb if we haven't compressed the frame * and a new skb pointer if we've done it */ -static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto, - struct ippp_struct *is,struct ippp_struct *master,int type) +static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in, int *proto, + struct ippp_struct *is, struct ippp_struct *master, int type) { - int ret; - int new_proto; - struct isdn_ppp_compressor *compressor; - void *stat; - struct sk_buff *skb_out; + int ret; + int new_proto; + struct isdn_ppp_compressor *compressor; + void *stat; + struct sk_buff *skb_out; /* we do not compress control protocols */ - if(*proto < 0 || *proto > 0x3fff) { - return skb_in; - } + if (*proto < 0 || *proto > 0x3fff) { + return skb_in; + } - if(type) { /* type=1 => Link compression */ + if (type) { /* type=1 => Link compression */ return skb_in; } else { - if(!master) { + if (!master) { compressor = is->compressor; stat = is->comp_stat; } @@ -2607,90 +2607,90 @@ static struct sk_buff *isdn_ppp_compress(struct sk_buff *skb_in,int *proto, new_proto = PPP_COMP; } - if(!compressor) { + if (!compressor) { printk(KERN_ERR "isdn_ppp: No compressor set!\n"); return skb_in; } - if(!stat) { + if (!stat) { printk(KERN_ERR "isdn_ppp: Compressor not initialized?\n"); return skb_in; } /* Allow for at least 150 % expansion (for now) */ - skb_out = alloc_skb(skb_in->len + skb_in->len/2 + 32 + - skb_headroom(skb_in), GFP_ATOMIC); - if(!skb_out) + skb_out = alloc_skb(skb_in->len + skb_in->len / 2 + 32 + + skb_headroom(skb_in), GFP_ATOMIC); + if (!skb_out) return skb_in; skb_reserve(skb_out, skb_headroom(skb_in)); - ret = (compressor->compress)(stat,skb_in,skb_out,*proto); - if(!ret) { + ret = (compressor->compress)(stat, skb_in, skb_out, *proto); + if (!ret) { dev_kfree_skb(skb_out); return skb_in; } - + dev_kfree_skb(skb_in); *proto = new_proto; return skb_out; } /* - * we received a CCP frame .. + * we received a CCP frame .. * not a clean solution, but we MUST handle a few cases in the kernel */ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, - struct sk_buff *skb,int proto) + struct sk_buff *skb, int proto) { struct ippp_struct *is; struct ippp_struct *mis; int len; struct isdn_ppp_resetparams rsparm; - unsigned char rsdata[IPPP_RESET_MAXDATABYTES]; + unsigned char rsdata[IPPP_RESET_MAXDATABYTES]; printk(KERN_DEBUG "Received CCP frame from peer slot(%d)\n", - lp->ppp_slot); + lp->ppp_slot); if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", - __func__, lp->ppp_slot); + __func__, lp->ppp_slot); return; } is = ippp_table[lp->ppp_slot]; - isdn_ppp_frame_log("ccp-rcv", skb->data, skb->len, 32, is->unit,lp->ppp_slot); + isdn_ppp_frame_log("ccp-rcv", skb->data, skb->len, 32, is->unit, lp->ppp_slot); - if(lp->master) { + if (lp->master) { int slot = ISDN_MASTER_PRIV(lp)->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: slot(%d) out of range\n", - __func__, slot); + __func__, slot); return; - } + } mis = ippp_table[slot]; } else mis = is; - switch(skb->data[0]) { + switch (skb->data[0]) { case CCP_CONFREQ: - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Disable compression here!\n"); - if(proto == PPP_CCP) - mis->compflags &= ~SC_COMP_ON; + if (proto == PPP_CCP) + mis->compflags &= ~SC_COMP_ON; else - is->compflags &= ~SC_LINK_COMP_ON; + is->compflags &= ~SC_LINK_COMP_ON; break; case CCP_TERMREQ: case CCP_TERMACK: - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Disable (de)compression here!\n"); - if(proto == PPP_CCP) - mis->compflags &= ~(SC_DECOMP_ON|SC_COMP_ON); + if (proto == PPP_CCP) + mis->compflags &= ~(SC_DECOMP_ON | SC_COMP_ON); else - is->compflags &= ~(SC_LINK_DECOMP_ON|SC_LINK_COMP_ON); + is->compflags &= ~(SC_LINK_DECOMP_ON | SC_LINK_COMP_ON); break; case CCP_CONFACK: /* if we RECEIVE an ackowledge we enable the decompressor */ - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Enable decompression here!\n"); - if(proto == PPP_CCP) { + if (proto == PPP_CCP) { if (!mis->decompressor) break; mis->compflags |= SC_DECOMP_ON; @@ -2706,11 +2706,11 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, len = (skb->data[2] << 8) | skb->data[3]; len -= 4; - if(proto == PPP_CCP) { + if (proto == PPP_CCP) { /* If a reset Ack was outstanding for this id, then clean up the state engine */ isdn_ppp_ccp_reset_ack_rcvd(mis, skb->data[1]); - if(mis->decompressor && mis->decomp_stat) + if (mis->decompressor && mis->decomp_stat) mis->decompressor-> reset(mis->decomp_stat, skb->data[0], @@ -2722,7 +2722,7 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, } else { isdn_ppp_ccp_reset_ack_rcvd(is, skb->data[1]); - if(is->link_decompressor && is->link_decomp_stat) + if (is->link_decompressor && is->link_decomp_stat) is->link_decompressor-> reset(is->link_decomp_stat, skb->data[0], @@ -2740,12 +2740,12 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, /* Set up reset params for the reset entry */ memset(&rsparm, 0, sizeof(rsparm)); rsparm.data = rsdata; - rsparm.maxdlen = IPPP_RESET_MAXDATABYTES; + rsparm.maxdlen = IPPP_RESET_MAXDATABYTES; /* Isolate data length */ len = (skb->data[2] << 8) | skb->data[3]; len -= 4; - if(proto == PPP_CCP) { - if(mis->compressor && mis->comp_stat) + if (proto == PPP_CCP) { + if (mis->compressor && mis->comp_stat) mis->compressor-> reset(mis->comp_stat, skb->data[0], @@ -2754,7 +2754,7 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, len, &rsparm); } else { - if(is->link_compressor && is->link_comp_stat) + if (is->link_compressor && is->link_comp_stat) is->link_compressor-> reset(is->link_comp_stat, skb->data[0], @@ -2763,9 +2763,9 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, len, &rsparm); } /* Ack the Req as specified by rsparm */ - if(rsparm.valid) { + if (rsparm.valid) { /* Compressor reset handler decided how to answer */ - if(rsparm.rsend) { + if (rsparm.rsend) { /* We should send a Frame */ isdn_ppp_ccp_xmit_reset(is, proto, CCP_RESETACK, rsparm.idval ? rsparm.id @@ -2817,69 +2817,69 @@ static void isdn_ppp_receive_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb) { - struct ippp_struct *mis,*is; + struct ippp_struct *mis, *is; int proto, slot = lp->ppp_slot; unsigned char *data; - if(!skb || skb->len < 3) + if (!skb || skb->len < 3) return; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: lp->ppp_slot(%d) out of range\n", - __func__, slot); + __func__, slot); return; - } + } is = ippp_table[slot]; /* Daemon may send with or without address and control field comp */ data = skb->data; - if(!(is->pppcfg & SC_COMP_AC) && data[0] == 0xff && data[1] == 0x03) { + if (!(is->pppcfg & SC_COMP_AC) && data[0] == 0xff && data[1] == 0x03) { data += 2; - if(skb->len < 5) + if (skb->len < 5) return; } - proto = ((int)data[0]<<8)+data[1]; - if(proto != PPP_CCP && proto != PPP_CCPFRAG) + proto = ((int)data[0]<<8) + data[1]; + if (proto != PPP_CCP && proto != PPP_CCPFRAG) return; printk(KERN_DEBUG "Received CCP frame from daemon:\n"); - isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit,lp->ppp_slot); + isdn_ppp_frame_log("ccp-xmit", skb->data, skb->len, 32, is->unit, lp->ppp_slot); if (lp->master) { slot = ISDN_MASTER_PRIV(lp)->ppp_slot; if (slot < 0 || slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: slot(%d) out of range\n", - __func__, slot); + __func__, slot); return; - } + } mis = ippp_table[slot]; } else mis = is; if (mis != is) printk(KERN_DEBUG "isdn_ppp: Ouch! Master CCP sends on slave slot!\n"); - - switch(data[2]) { + + switch (data[2]) { case CCP_CONFREQ: - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Disable decompression here!\n"); - if(proto == PPP_CCP) + if (proto == PPP_CCP) is->compflags &= ~SC_DECOMP_ON; else is->compflags &= ~SC_LINK_DECOMP_ON; break; case CCP_TERMREQ: case CCP_TERMACK: - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Disable (de)compression here!\n"); - if(proto == PPP_CCP) - is->compflags &= ~(SC_DECOMP_ON|SC_COMP_ON); + if (proto == PPP_CCP) + is->compflags &= ~(SC_DECOMP_ON | SC_COMP_ON); else - is->compflags &= ~(SC_LINK_DECOMP_ON|SC_LINK_COMP_ON); + is->compflags &= ~(SC_LINK_DECOMP_ON | SC_LINK_COMP_ON); break; case CCP_CONFACK: /* if we SEND an ackowledge we can/must enable the compressor */ - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Enable compression here!\n"); - if(proto == PPP_CCP) { + if (proto == PPP_CCP) { if (!is->compressor) break; is->compflags |= SC_COMP_ON; @@ -2891,21 +2891,21 @@ static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct break; case CCP_RESETACK: /* If we send a ACK we should reset our compressor */ - if(is->debug & 0x10) + if (is->debug & 0x10) printk(KERN_DEBUG "Reset decompression state here!\n"); printk(KERN_DEBUG "ResetAck from daemon passed by\n"); - if(proto == PPP_CCP) { + if (proto == PPP_CCP) { /* link to master? */ - if(is->compressor && is->comp_stat) + if (is->compressor && is->comp_stat) is->compressor->reset(is->comp_stat, 0, 0, NULL, 0, NULL); - is->compflags &= ~SC_COMP_DISCARD; + is->compflags &= ~SC_COMP_DISCARD; } else { - if(is->link_compressor && is->link_comp_stat) + if (is->link_compressor && is->link_comp_stat) is->link_compressor->reset(is->link_comp_stat, 0, 0, NULL, 0, NULL); - is->compflags &= ~SC_LINK_COMP_DISCARD; + is->compflags &= ~SC_LINK_COMP_DISCARD; } break; case CCP_RESETREQ: @@ -2919,7 +2919,7 @@ int isdn_ppp_register_compressor(struct isdn_ppp_compressor *ipc) { ipc->next = ipc_head; ipc->prev = NULL; - if(ipc_head) { + if (ipc_head) { ipc_head->prev = ipc; } ipc_head = ipc; @@ -2928,11 +2928,11 @@ int isdn_ppp_register_compressor(struct isdn_ppp_compressor *ipc) int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc) { - if(ipc->prev) + if (ipc->prev) ipc->prev->next = ipc->next; else ipc_head = ipc->next; - if(ipc->next) + if (ipc->next) ipc->next->prev = ipc->prev; ipc->prev = ipc->next = NULL; return 0; @@ -2945,26 +2945,26 @@ static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_ void *stat; int num = data->num; - if(is->debug & 0x10) - printk(KERN_DEBUG "[%d] Set %s type %d\n",is->unit, - (data->flags&IPPP_COMP_FLAG_XMIT)?"compressor":"decompressor",num); + if (is->debug & 0x10) + printk(KERN_DEBUG "[%d] Set %s type %d\n", is->unit, + (data->flags & IPPP_COMP_FLAG_XMIT) ? "compressor" : "decompressor", num); /* If is has no valid reset state vector, we cannot allocate a decompressor. The decompressor would cause reset transactions sooner or later, and they need that vector. */ - if(!(data->flags & IPPP_COMP_FLAG_XMIT) && !is->reset) { + if (!(data->flags & IPPP_COMP_FLAG_XMIT) && !is->reset) { printk(KERN_ERR "ippp_ccp: no reset data structure - can't" " allow decompression.\n"); return -ENOMEM; } - while(ipc) { - if(ipc->num == num) { + while (ipc) { + if (ipc->num == num) { stat = ipc->alloc(data); - if(stat) { - ret = ipc->init(stat,data,is->unit,0); - if(!ret) { + if (stat) { + ret = ipc->init(stat, data, is->unit, 0); + if (!ret) { printk(KERN_ERR "Can't init (de)compression!\n"); ipc->free(stat); stat = NULL; @@ -2976,32 +2976,32 @@ static int isdn_ppp_set_compressor(struct ippp_struct *is, struct isdn_ppp_comp_ break; } - if(data->flags & IPPP_COMP_FLAG_XMIT) { - if(data->flags & IPPP_COMP_FLAG_LINK) { - if(is->link_comp_stat) + if (data->flags & IPPP_COMP_FLAG_XMIT) { + if (data->flags & IPPP_COMP_FLAG_LINK) { + if (is->link_comp_stat) is->link_compressor->free(is->link_comp_stat); is->link_comp_stat = stat; - is->link_compressor = ipc; + is->link_compressor = ipc; } else { - if(is->comp_stat) + if (is->comp_stat) is->compressor->free(is->comp_stat); is->comp_stat = stat; - is->compressor = ipc; + is->compressor = ipc; } } - else { - if(data->flags & IPPP_COMP_FLAG_LINK) { - if(is->link_decomp_stat) + else { + if (data->flags & IPPP_COMP_FLAG_LINK) { + if (is->link_decomp_stat) is->link_decompressor->free(is->link_decomp_stat); is->link_decomp_stat = stat; - is->link_decompressor = ipc; + is->link_decompressor = ipc; } else { - if(is->decomp_stat) + if (is->decomp_stat) is->decompressor->free(is->decomp_stat); is->decomp_stat = stat; - is->decompressor = ipc; + is->decompressor = ipc; } } return 0; diff --git a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h index 8cc05c7ccf78..4e9b8935a4eb 100644 --- a/drivers/isdn/i4l/isdn_ppp.h +++ b/drivers/isdn/i4l/isdn_ppp.h @@ -39,5 +39,3 @@ extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc); #define IPPP_ASSIGNED 0x10 #define IPPP_MAX_HEADER 10 - - diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 2c26b64ebbea..89a28872c636 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -61,7 +61,7 @@ char *isdn_tty_revision = "$Revision: 1.1.2.3 $"; * isdn_tty_readmodem(). */ static int -isdn_tty_try_read(modem_info * info, struct sk_buff *skb) +isdn_tty_try_read(modem_info *info, struct sk_buff *skb) { int c; int len; @@ -93,7 +93,7 @@ isdn_tty_try_read(modem_info * info, struct sk_buff *skb) last = *dp; } else { #endif - if(len > 1) + if (len > 1) tty_insert_flip_string(tty, skb->data, len - 1); last = skb->data[len - 1]; #ifdef CONFIG_ISDN_AUDIO @@ -179,7 +179,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) info = &dev->mdm.info[midx]; #ifdef CONFIG_ISDN_AUDIO ifmt = 1; - + if ((info->vonline) && (!info->emu.vpar[4])) isdn_audio_calc_dtmf(info, skb->data, skb->len, ifmt); if ((info->vonline & 1) && (info->emu.vpar[1])) @@ -213,29 +213,29 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) if (info->vonline & 1) { /* voice conversion/compression */ switch (info->emu.vpar[3]) { - case 2: - case 3: - case 4: - /* adpcm - * Since compressed data takes less - * space, we can overwrite the buffer. - */ - skb_trim(skb, isdn_audio_xlaw2adpcm(info->adpcmr, - ifmt, - skb->data, - skb->data, - skb->len)); - break; - case 5: - /* a-law */ - if (!ifmt) - isdn_audio_ulaw2alaw(skb->data, skb->len); - break; - case 6: - /* u-law */ - if (ifmt) - isdn_audio_alaw2ulaw(skb->data, skb->len); - break; + case 2: + case 3: + case 4: + /* adpcm + * Since compressed data takes less + * space, we can overwrite the buffer. + */ + skb_trim(skb, isdn_audio_xlaw2adpcm(info->adpcmr, + ifmt, + skb->data, + skb->data, + skb->len)); + break; + case 5: + /* a-law */ + if (!ifmt) + isdn_audio_ulaw2alaw(skb->data, skb->len); + break; + case 6: + /* u-law */ + if (ifmt) + isdn_audio_alaw2ulaw(skb->data, skb->len); + break; } ISDN_AUDIO_SKB_DLECOUNT(skb) = isdn_tty_countDLE(skb->data, skb->len); @@ -275,7 +275,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) } static void -isdn_tty_cleanup_xmit(modem_info * info) +isdn_tty_cleanup_xmit(modem_info *info) { skb_queue_purge(&info->xmit_queue); #ifdef CONFIG_ISDN_AUDIO @@ -284,7 +284,7 @@ isdn_tty_cleanup_xmit(modem_info * info) } static void -isdn_tty_tint(modem_info * info) +isdn_tty_tint(modem_info *info) { struct sk_buff *skb = skb_dequeue(&info->xmit_queue); int len, slen; @@ -325,7 +325,7 @@ isdn_tty_countDLE(unsigned char *buf, int len) * DLE-decoding when sending audio-data. */ static int -isdn_tty_handleDLEdown(modem_info * info, atemu * m, int len) +isdn_tty_handleDLEdown(modem_info *info, atemu *m, int len) { unsigned char *p = &info->xmit_buf[info->xmit_count]; int count = 0; @@ -334,42 +334,42 @@ isdn_tty_handleDLEdown(modem_info * info, atemu * m, int len) if (m->lastDLE) { m->lastDLE = 0; switch (*p) { - case DLE: - /* Escape code */ - if (len > 1) - memmove(p, p + 1, len - 1); - p--; - count++; - break; - case ETX: - /* End of data */ - info->vonline |= 4; - return count; - case DC4: - /* Abort RX */ - info->vonline &= ~1; + case DLE: + /* Escape code */ + if (len > 1) + memmove(p, p + 1, len - 1); + p--; + count++; + break; + case ETX: + /* End of data */ + info->vonline |= 4; + return count; + case DC4: + /* Abort RX */ + info->vonline &= ~1; #ifdef ISDN_DEBUG_MODEM_VOICE - printk(KERN_DEBUG - "DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n", - info->line); + printk(KERN_DEBUG + "DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n", + info->line); #endif - isdn_tty_at_cout("\020\003", info); - if (!info->vonline) { + isdn_tty_at_cout("\020\003", info); + if (!info->vonline) { #ifdef ISDN_DEBUG_MODEM_VOICE - printk(KERN_DEBUG - "DLEdown: send VCON on ttyI%d\n", - info->line); + printk(KERN_DEBUG + "DLEdown: send VCON on ttyI%d\n", + info->line); #endif - isdn_tty_at_cout("\r\nVCON\r\n", info); - } - /* Fall through */ - case 'q': - case 's': - /* Silence */ - if (len > 1) - memmove(p, p + 1, len - 1); - p--; - break; + isdn_tty_at_cout("\r\nVCON\r\n", info); + } + /* Fall through */ + case 'q': + case 's': + /* Silence */ + if (len > 1) + memmove(p, p + 1, len - 1); + p--; + break; } } else { if (*p == DLE) @@ -416,7 +416,7 @@ static int voice_cf[7] = * T.70 if necessary, and finally queues it up for sending via isdn_tty_tint. */ static void -isdn_tty_senddown(modem_info * info) +isdn_tty_senddown(modem_info *info) { int buflen; int skb_res; @@ -440,9 +440,9 @@ isdn_tty_senddown(modem_info * info) #endif if (!(buflen = info->xmit_count)) return; - if ((info->emu.mdmreg[REG_CTS] & BIT_CTS) != 0) + if ((info->emu.mdmreg[REG_CTS] & BIT_CTS) != 0) info->msr &= ~UART_MSR_CTS; - info->lsr &= ~UART_LSR_TEMT; + info->lsr &= ~UART_LSR_TEMT; /* info->xmit_count is modified here and in isdn_tty_write(). * So we return here if isdn_tty_write() is in the * critical section. @@ -485,32 +485,32 @@ isdn_tty_senddown(modem_info * info) /* voice conversion/decompression */ switch (info->emu.vpar[3]) { - case 2: - case 3: - case 4: - /* adpcm, compatible to ZyXel 1496 modem - * with ROM revision 6.01 - */ - audio_len = isdn_audio_adpcm2xlaw(info->adpcms, - ifmt, - skb->data, - skb_put(skb, audio_len), - buflen); - skb_pull(skb, buflen); - skb_trim(skb, audio_len); - break; - case 5: - /* a-law */ - if (!ifmt) - isdn_audio_alaw2ulaw(skb->data, - buflen); - break; - case 6: - /* u-law */ - if (ifmt) - isdn_audio_ulaw2alaw(skb->data, - buflen); - break; + case 2: + case 3: + case 4: + /* adpcm, compatible to ZyXel 1496 modem + * with ROM revision 6.01 + */ + audio_len = isdn_audio_adpcm2xlaw(info->adpcms, + ifmt, + skb->data, + skb_put(skb, audio_len), + buflen); + skb_pull(skb, buflen); + skb_trim(skb, audio_len); + break; + case 5: + /* a-law */ + if (!ifmt) + isdn_audio_alaw2ulaw(skb->data, + buflen); + break; + case 6: + /* u-law */ + if (ifmt) + isdn_audio_ulaw2alaw(skb->data, + buflen); + break; } } #endif /* CONFIG_ISDN_AUDIO */ @@ -550,7 +550,7 @@ isdn_tty_modem_do_ncarrier(unsigned long data) * low. */ static void -isdn_tty_modem_ncarrier(modem_info * info) +isdn_tty_modem_ncarrier(modem_info *info) { if (info->ncarrier) { info->nc_timer.expires = jiffies + HZ; @@ -568,30 +568,30 @@ isdn_calc_usage(int si, int l2) #ifdef CONFIG_ISDN_AUDIO if (si == 1) { - switch(l2) { - case ISDN_PROTO_L2_MODEM: - usg = ISDN_USAGE_MODEM; - break; + switch (l2) { + case ISDN_PROTO_L2_MODEM: + usg = ISDN_USAGE_MODEM; + break; #ifdef CONFIG_ISDN_TTY_FAX - case ISDN_PROTO_L2_FAX: - usg = ISDN_USAGE_FAX; - break; + case ISDN_PROTO_L2_FAX: + usg = ISDN_USAGE_FAX; + break; #endif - case ISDN_PROTO_L2_TRANS: - default: - usg = ISDN_USAGE_VOICE; - break; + case ISDN_PROTO_L2_TRANS: + default: + usg = ISDN_USAGE_VOICE; + break; } } #endif - return(usg); + return (usg); } /* isdn_tty_dial() performs dialing of a tty an the necessary * setup of the lower levels before that. */ static void -isdn_tty_dial(char *n, modem_info * info, atemu * m) +isdn_tty_dial(char *n, modem_info *info, atemu *m) { int usg = ISDN_USAGE_MODEM; int si = 7; @@ -608,10 +608,10 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) } usg = isdn_calc_usage(si, l2); #ifdef CONFIG_ISDN_AUDIO - if ((si == 1) && - (l2 != ISDN_PROTO_L2_MODEM) + if ((si == 1) && + (l2 != ISDN_PROTO_L2_MODEM) #ifdef CONFIG_ISDN_TTY_FAX - && (l2 != ISDN_PROTO_L2_FAX) + && (l2 != ISDN_PROTO_L2_FAX) #endif ) { l2 = ISDN_PROTO_L2_TRANS; @@ -679,7 +679,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) * and some cleanup is done also. */ void -isdn_tty_modem_hup(modem_info * info, int local) +isdn_tty_modem_hup(modem_info *info, int local) { isdn_ctrl cmd; int di, ch; @@ -723,7 +723,7 @@ isdn_tty_modem_hup(modem_info * info, int local) info->adpcmr = NULL; #endif if ((info->msr & UART_MSR_RI) && - (info->emu.mdmreg[REG_RUNG] & BIT_RUNG)) + (info->emu.mdmreg[REG_RUNG] & BIT_RUNG)) isdn_tty_modem_result(RESULT_RUNG, info); info->msr &= ~(UART_MSR_DCD | UART_MSR_RI); info->lsr |= UART_LSR_TEMT; @@ -746,7 +746,7 @@ isdn_tty_modem_hup(modem_info * info, int local) } /* - * Begin of a CAPI like interface, currently used only for + * Begin of a CAPI like interface, currently used only for * supplementary service (CAPI 2.0 part III) */ #include @@ -754,16 +754,16 @@ isdn_tty_modem_hup(modem_info * info, int local) int isdn_tty_capi_facility(capi_msg *cm) { - return(-1); /* dummy */ + return (-1); /* dummy */ } /* isdn_tty_suspend() tries to suspend the current tty connection */ static void -isdn_tty_suspend(char *id, modem_info * info, atemu * m) +isdn_tty_suspend(char *id, modem_info *info, atemu *m) { isdn_ctrl cmd; - + int l; if (!info) @@ -774,7 +774,7 @@ isdn_tty_suspend(char *id, modem_info * info, atemu * m) #endif l = strlen(id); if ((info->isdn_driver >= 0)) { - cmd.parm.cmsg.Length = l+18; + cmd.parm.cmsg.Length = l + 18; cmd.parm.cmsg.Command = CAPI_FACILITY; cmd.parm.cmsg.Subcommand = CAPI_REQ; cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; @@ -800,7 +800,7 @@ isdn_tty_suspend(char *id, modem_info * info, atemu * m) */ static void -isdn_tty_resume(char *id, modem_info * info, atemu * m) +isdn_tty_resume(char *id, modem_info *info, atemu *m) { int usg = ISDN_USAGE_MODEM; int si = 7; @@ -819,10 +819,10 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) } usg = isdn_calc_usage(si, l2); #ifdef CONFIG_ISDN_AUDIO - if ((si == 1) && - (l2 != ISDN_PROTO_L2_MODEM) + if ((si == 1) && + (l2 != ISDN_PROTO_L2_MODEM) #ifdef CONFIG_ISDN_TTY_FAX - && (l2 != ISDN_PROTO_L2_FAX) + && (l2 != ISDN_PROTO_L2_FAX) #endif ) { l2 = ISDN_PROTO_L2_TRANS; @@ -864,18 +864,18 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) isdn_command(&cmd); cmd.driver = info->isdn_driver; cmd.arg = info->isdn_channel; - cmd.parm.cmsg.Length = l+18; + cmd.parm.cmsg.Length = l + 18; cmd.parm.cmsg.Command = CAPI_FACILITY; cmd.parm.cmsg.Subcommand = CAPI_REQ; cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; cmd.parm.cmsg.para[0] = 3; /* 16 bit 0x0003 suplementary service */ cmd.parm.cmsg.para[1] = 0; - cmd.parm.cmsg.para[2] = l+3; + cmd.parm.cmsg.para[2] = l + 3; cmd.parm.cmsg.para[3] = 5; /* 16 bit 0x0005 Resume */ cmd.parm.cmsg.para[4] = 0; cmd.parm.cmsg.para[5] = l; strncpy(&cmd.parm.cmsg.para[6], id, l); - cmd.command =CAPI_PUT_MESSAGE; + cmd.command = CAPI_PUT_MESSAGE; info->dialing = 1; // strcpy(dev->num[i], n); isdn_info_update(); @@ -889,7 +889,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) */ static void -isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) +isdn_tty_send_msg(modem_info *info, atemu *m, char *msg) { int usg = ISDN_USAGE_MODEM; int si = 7; @@ -912,10 +912,10 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) } usg = isdn_calc_usage(si, l2); #ifdef CONFIG_ISDN_AUDIO - if ((si == 1) && - (l2 != ISDN_PROTO_L2_MODEM) + if ((si == 1) && + (l2 != ISDN_PROTO_L2_MODEM) #ifdef CONFIG_ISDN_TTY_FAX - && (l2 != ISDN_PROTO_L2_FAX) + && (l2 != ISDN_PROTO_L2_FAX) #endif ) { l2 = ISDN_PROTO_L2_TRANS; @@ -956,14 +956,14 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) isdn_command(&cmd); cmd.driver = info->isdn_driver; cmd.arg = info->isdn_channel; - cmd.parm.cmsg.Length = l+14; + cmd.parm.cmsg.Length = l + 14; cmd.parm.cmsg.Command = CAPI_MANUFACTURER; cmd.parm.cmsg.Subcommand = CAPI_REQ; cmd.parm.cmsg.adr.Controller = info->isdn_driver + 1; - cmd.parm.cmsg.para[0] = l+1; + cmd.parm.cmsg.para[0] = l + 1; strncpy(&cmd.parm.cmsg.para[1], msg, l); - cmd.parm.cmsg.para[l+1] = 0xd; - cmd.command =CAPI_PUT_MESSAGE; + cmd.parm.cmsg.para[l + 1] = 0xd; + cmd.command = CAPI_PUT_MESSAGE; /* info->dialing = 1; strcpy(dev->num[i], n); isdn_info_update(); @@ -978,7 +978,7 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine) #ifdef MODEM_PARANOIA_CHECK if (!info) { printk(KERN_WARNING "isdn_tty: null info_struct for %s in %s\n", - name, routine); + name, routine); return 1; } if (info->magic != ISDN_ASYNC_MAGIC) { @@ -995,11 +995,11 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine) * the specified baud rate for a serial port. */ static void -isdn_tty_change_speed(modem_info * info) +isdn_tty_change_speed(modem_info *info) { uint cflag, - cval, - quot; + cval, + quot; int i; if (!info->tty || !info->tty->termios) @@ -1051,7 +1051,7 @@ isdn_tty_change_speed(modem_info * info) } static int -isdn_tty_startup(modem_info * info) +isdn_tty_startup(modem_info *info) { if (info->flags & ISDN_ASYNC_INITIALIZED) return 0; @@ -1081,7 +1081,7 @@ isdn_tty_startup(modem_info * info) * DTR is dropped if the hangup on close termio flag is on. */ static void -isdn_tty_shutdown(modem_info * info) +isdn_tty_shutdown(modem_info *info) { if (!(info->flags & ISDN_ASYNC_INITIALIZED)) return; @@ -1116,7 +1116,7 @@ isdn_tty_shutdown(modem_info * info) * - If dialing, abort dial. */ static int -isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count) +isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count) { int c; int total = 0; @@ -1176,27 +1176,27 @@ isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count) } } } else - if (TTY_IS_FCLASS1(info)) { - int cc = isdn_tty_handleDLEdown(info, m, c); - - if (info->vonline & 4) { /* ETX seen */ - isdn_ctrl c; - - c.command = ISDN_CMD_FAXCMD; - c.driver = info->isdn_driver; - c.arg = info->isdn_channel; - c.parm.aux.cmd = ISDN_FAX_CLASS1_CTRL; - c.parm.aux.subcmd = ETX; - isdn_command(&c); - } - info->vonline = 0; + if (TTY_IS_FCLASS1(info)) { + int cc = isdn_tty_handleDLEdown(info, m, c); + + if (info->vonline & 4) { /* ETX seen */ + isdn_ctrl c; + + c.command = ISDN_CMD_FAXCMD; + c.driver = info->isdn_driver; + c.arg = info->isdn_channel; + c.parm.aux.cmd = ISDN_FAX_CLASS1_CTRL; + c.parm.aux.subcmd = ETX; + isdn_command(&c); + } + info->vonline = 0; #ifdef ISDN_DEBUG_MODEM_VOICE - printk(KERN_DEBUG "fax dle cc/c %d/%d\n", cc, c); + printk(KERN_DEBUG "fax dle cc/c %d/%d\n", cc, c); #endif - info->xmit_count += cc; - } else + info->xmit_count += cc; + } else #endif - info->xmit_count += c; + info->xmit_count += c; } else { info->msr |= UART_MSR_CTS; info->lsr |= UART_LSR_TEMT; @@ -1332,7 +1332,7 @@ isdn_tty_unthrottle(struct tty_struct *tty) * allows RS485 driver to be written in user space. */ static int -isdn_tty_get_lsr_info(modem_info * info, uint __user * value) +isdn_tty_get_lsr_info(modem_info *info, uint __user *value) { u_char status; uint result; @@ -1363,16 +1363,16 @@ isdn_tty_tiocmget(struct tty_struct *tty) status = info->msr; mutex_unlock(&modem_info_mutex); return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) - | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) - | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) - | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) - | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) - | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); + | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) + | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) + | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) + | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) + | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); } static int isdn_tty_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear) + unsigned int set, unsigned int clear) { modem_info *info = (modem_info *) tty->driver_data; @@ -1422,34 +1422,34 @@ isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg) if (tty->flags & (1 << TTY_IO_ERROR)) return -EIO; switch (cmd) { - case TCSBRK: /* SVID version: non-zero arg --> no break */ + case TCSBRK: /* SVID version: non-zero arg --> no break */ #ifdef ISDN_DEBUG_MODEM_IOCTL - printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line); -#endif - retval = tty_check_change(tty); - if (retval) - return retval; - tty_wait_until_sent(tty, 0); - return 0; - case TCSBRKP: /* support for POSIX tcsendbreak() */ + printk(KERN_DEBUG "ttyI%d ioctl TCSBRK\n", info->line); +#endif + retval = tty_check_change(tty); + if (retval) + return retval; + tty_wait_until_sent(tty, 0); + return 0; + case TCSBRKP: /* support for POSIX tcsendbreak() */ #ifdef ISDN_DEBUG_MODEM_IOCTL - printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line); -#endif - retval = tty_check_change(tty); - if (retval) - return retval; - tty_wait_until_sent(tty, 0); - return 0; - case TIOCSERGETLSR: /* Get line status register */ + printk(KERN_DEBUG "ttyI%d ioctl TCSBRKP\n", info->line); +#endif + retval = tty_check_change(tty); + if (retval) + return retval; + tty_wait_until_sent(tty, 0); + return 0; + case TIOCSERGETLSR: /* Get line status register */ #ifdef ISDN_DEBUG_MODEM_IOCTL - printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); + printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); #endif - return isdn_tty_get_lsr_info(info, (uint __user *) arg); - default: + return isdn_tty_get_lsr_info(info, (uint __user *) arg); + default: #ifdef ISDN_DEBUG_MODEM_IOCTL - printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line); + printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line); #endif - return -ENOIOCTLCMD; + return -ENOIOCTLCMD; } return 0; } @@ -1479,7 +1479,7 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) * ------------------------------------------------------------ */ static int -isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * info) +isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info) { DECLARE_WAITQUEUE(wait, NULL); int do_clocal = 0; @@ -1603,7 +1603,7 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp) return -ENODEV; } #ifdef ISDN_DEBUG_MODEM_OPEN - printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, + printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, info->count); #endif info->count++; @@ -1703,7 +1703,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) timeout = jiffies + HZ; while (!(info->lsr & UART_LSR_TEMT)) { schedule_timeout_interruptible(20); - if (time_after(jiffies,timeout)) + if (time_after(jiffies, timeout)) break; } } @@ -1746,7 +1746,7 @@ isdn_tty_hangup(struct tty_struct *tty) /* This routine initializes all emulator-data. */ static void -isdn_tty_reset_profile(atemu * m) +isdn_tty_reset_profile(atemu *m) { m->profile[0] = 0; m->profile[1] = 0; @@ -1776,7 +1776,7 @@ isdn_tty_reset_profile(atemu * m) #ifdef CONFIG_ISDN_AUDIO static void -isdn_tty_modem_reset_vpar(atemu * m) +isdn_tty_modem_reset_vpar(atemu *m) { m->vpar[0] = 2; /* Voice-device (2 = phone line) */ m->vpar[1] = 0; /* Silence detection level (0 = none ) */ @@ -1789,7 +1789,7 @@ isdn_tty_modem_reset_vpar(atemu * m) #ifdef CONFIG_ISDN_TTY_FAX static void -isdn_tty_modem_reset_faxpar(modem_info * info) +isdn_tty_modem_reset_faxpar(modem_info *info) { T30_s *f = info->fax; @@ -1822,7 +1822,7 @@ isdn_tty_modem_reset_faxpar(modem_info * info) #endif static void -isdn_tty_modem_reset_regs(modem_info * info, int force) +isdn_tty_modem_reset_regs(modem_info *info, int force) { atemu *m = &info->emu; if ((m->mdmreg[REG_DTRR] & BIT_DTRR) || force) { @@ -1841,7 +1841,7 @@ isdn_tty_modem_reset_regs(modem_info * info, int force) } static void -modem_write_profile(atemu * m) +modem_write_profile(atemu *m) { memcpy(m->profile, m->mdmreg, ISDN_MODEM_NUMREG); memcpy(m->pmsn, m->msn, ISDN_MSNLEN); @@ -1851,7 +1851,7 @@ modem_write_profile(atemu * m) } static const struct tty_operations modem_ops = { - .open = isdn_tty_open, + .open = isdn_tty_open, .close = isdn_tty_close, .write = isdn_tty_write, .flush_chars = isdn_tty_flush_chars, @@ -1951,7 +1951,7 @@ isdn_tty_modem_init(void) kfree(info->xmit_buf - 4); } tty_unregister_driver(m->tty_modem); - err: +err: put_tty_driver(m->tty_modem); m->tty_modem = NULL; return retval; @@ -2021,8 +2021,8 @@ isdn_tty_match_icall(char *cid, atemu *emu, int di) int tmp; tmp = isdn_msncmp(cid, isdn_map_eaz2msn(emu->msn, di)); #ifdef ISDN_DEBUG_MODEM_ICALL - printk(KERN_DEBUG "m_fi: mmsn=%s -> tmp=%d\n", - isdn_map_eaz2msn(emu->msn, di), tmp); + printk(KERN_DEBUG "m_fi: mmsn=%s -> tmp=%d\n", + isdn_map_eaz2msn(emu->msn, di), tmp); #endif return tmp; } @@ -2071,8 +2071,8 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) for (i = 0; i < ISDN_MAX_CHANNELS; i++) { modem_info *info = &dev->mdm.info[i]; - if (info->count == 0) - continue; + if (info->count == 0) + continue; if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */ (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */ idx = isdn_dc2minor(di, ch); @@ -2099,7 +2099,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) info->drv_index = idx; dev->m_idx[idx] = info->line; dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; - dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); + dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); strcpy(dev->num[idx], nr); strcpy(info->emu.cpn, eaz); info->emu.mdmreg[REG_SI1I] = si2bit[si1]; @@ -2119,11 +2119,11 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) } spin_unlock_irqrestore(&dev->lock, flags); printk(KERN_INFO "isdn_tty: call from %s -> %s %s\n", nr, eaz, - ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2))? "rejected" : "ignored"); - return (wret == 2)?3:0; + ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2)) ? "rejected" : "ignored"); + return (wret == 2) ? 3 : 0; } -#define TTY_IS_ACTIVE(info) \ +#define TTY_IS_ACTIVE(info) \ (info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE)) int @@ -2138,174 +2138,174 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) if ((mi = dev->m_idx[i]) >= 0) { info = &dev->mdm.info[mi]; switch (c->command) { - case ISDN_STAT_CINF: - printk(KERN_DEBUG "CHARGEINFO on ttyI%d: %ld %s\n", info->line, c->arg, c->parm.num); - info->emu.charge = (unsigned) simple_strtoul(c->parm.num, &e, 10); - if (e == (char *)c->parm.num) - info->emu.charge = 0; - - break; - case ISDN_STAT_BSENT: -#ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_BSENT ttyI%d\n", info->line); -#endif - if ((info->isdn_driver == c->driver) && - (info->isdn_channel == c->arg)) { - info->msr |= UART_MSR_CTS; - if (info->send_outstanding) - if (!(--info->send_outstanding)) - info->lsr |= UART_LSR_TEMT; - isdn_tty_tint(info); - return 1; - } - break; - case ISDN_STAT_CAUSE: + case ISDN_STAT_CINF: + printk(KERN_DEBUG "CHARGEINFO on ttyI%d: %ld %s\n", info->line, c->arg, c->parm.num); + info->emu.charge = (unsigned) simple_strtoul(c->parm.num, &e, 10); + if (e == (char *)c->parm.num) + info->emu.charge = 0; + + break; + case ISDN_STAT_BSENT: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_CAUSE ttyI%d\n", info->line); + printk(KERN_DEBUG "tty_STAT_BSENT ttyI%d\n", info->line); #endif - /* Signal cause to tty-device */ - strncpy(info->last_cause, c->parm.num, 5); + if ((info->isdn_driver == c->driver) && + (info->isdn_channel == c->arg)) { + info->msr |= UART_MSR_CTS; + if (info->send_outstanding) + if (!(--info->send_outstanding)) + info->lsr |= UART_LSR_TEMT; + isdn_tty_tint(info); return 1; - case ISDN_STAT_DISPLAY: + } + break; + case ISDN_STAT_CAUSE: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_DISPLAY ttyI%d\n", info->line); -#endif - /* Signal display to tty-device */ - if ((info->emu.mdmreg[REG_DISPLAY] & BIT_DISPLAY) && - !(info->emu.mdmreg[REG_RESPNUM] & BIT_RESPNUM)) { - isdn_tty_at_cout("\r\n", info); - isdn_tty_at_cout("DISPLAY: ", info); - isdn_tty_at_cout(c->parm.display, info); - isdn_tty_at_cout("\r\n", info); - } - return 1; - case ISDN_STAT_DCONN: + printk(KERN_DEBUG "tty_STAT_CAUSE ttyI%d\n", info->line); +#endif + /* Signal cause to tty-device */ + strncpy(info->last_cause, c->parm.num, 5); + return 1; + case ISDN_STAT_DISPLAY: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); + printk(KERN_DEBUG "tty_STAT_DISPLAY ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { - if (info->dialing == 1) { - info->dialing = 2; - return 1; - } + /* Signal display to tty-device */ + if ((info->emu.mdmreg[REG_DISPLAY] & BIT_DISPLAY) && + !(info->emu.mdmreg[REG_RESPNUM] & BIT_RESPNUM)) { + isdn_tty_at_cout("\r\n", info); + isdn_tty_at_cout("DISPLAY: ", info); + isdn_tty_at_cout(c->parm.display, info); + isdn_tty_at_cout("\r\n", info); + } + return 1; + case ISDN_STAT_DCONN: +#ifdef ISDN_TTY_STAT_DEBUG + printk(KERN_DEBUG "tty_STAT_DCONN ttyI%d\n", info->line); +#endif + if (TTY_IS_ACTIVE(info)) { + if (info->dialing == 1) { + info->dialing = 2; + return 1; } - break; - case ISDN_STAT_DHUP: + } + break; + case ISDN_STAT_DHUP: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line); + printk(KERN_DEBUG "tty_STAT_DHUP ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { - if (info->dialing == 1) - isdn_tty_modem_result(RESULT_BUSY, info); - if (info->dialing > 1) - isdn_tty_modem_result(RESULT_NO_CARRIER, info); - info->dialing = 0; + if (TTY_IS_ACTIVE(info)) { + if (info->dialing == 1) + isdn_tty_modem_result(RESULT_BUSY, info); + if (info->dialing > 1) + isdn_tty_modem_result(RESULT_NO_CARRIER, info); + info->dialing = 0; #ifdef ISDN_DEBUG_MODEM_HUP - printk(KERN_DEBUG "Mhup in ISDN_STAT_DHUP\n"); + printk(KERN_DEBUG "Mhup in ISDN_STAT_DHUP\n"); #endif - isdn_tty_modem_hup(info, 0); - return 1; - } - break; - case ISDN_STAT_BCONN: + isdn_tty_modem_hup(info, 0); + return 1; + } + break; + case ISDN_STAT_BCONN: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_BCONN ttyI%d\n", info->line); -#endif - /* Wake up any processes waiting - * for incoming call of this device when - * DCD follow the state of incoming carrier - */ - if (info->blocked_open && - (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { - wake_up_interruptible(&info->open_wait); - } + printk(KERN_DEBUG "tty_STAT_BCONN ttyI%d\n", info->line); +#endif + /* Wake up any processes waiting + * for incoming call of this device when + * DCD follow the state of incoming carrier + */ + if (info->blocked_open && + (info->emu.mdmreg[REG_DCD] & BIT_DCD)) { + wake_up_interruptible(&info->open_wait); + } - /* Schedule CONNECT-Message to any tty - * waiting for it and - * set DCD-bit of its modem-status. - */ - if (TTY_IS_ACTIVE(info) || - (info->blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { - info->msr |= UART_MSR_DCD; - info->emu.charge = 0; - if (info->dialing & 0xf) - info->last_dir = 1; - else - info->last_dir = 0; - info->dialing = 0; - info->rcvsched = 1; - if (USG_MODEM(dev->usage[i])) { - if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { - strcpy(info->emu.connmsg, c->parm.num); - isdn_tty_modem_result(RESULT_CONNECT, info); - } else - isdn_tty_modem_result(RESULT_CONNECT64000, info); - } - if (USG_VOICE(dev->usage[i])) - isdn_tty_modem_result(RESULT_VCON, info); - return 1; + /* Schedule CONNECT-Message to any tty + * waiting for it and + * set DCD-bit of its modem-status. + */ + if (TTY_IS_ACTIVE(info) || + (info->blocked_open && (info->emu.mdmreg[REG_DCD] & BIT_DCD))) { + info->msr |= UART_MSR_DCD; + info->emu.charge = 0; + if (info->dialing & 0xf) + info->last_dir = 1; + else + info->last_dir = 0; + info->dialing = 0; + info->rcvsched = 1; + if (USG_MODEM(dev->usage[i])) { + if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { + strcpy(info->emu.connmsg, c->parm.num); + isdn_tty_modem_result(RESULT_CONNECT, info); + } else + isdn_tty_modem_result(RESULT_CONNECT64000, info); } - break; - case ISDN_STAT_BHUP: + if (USG_VOICE(dev->usage[i])) + isdn_tty_modem_result(RESULT_VCON, info); + return 1; + } + break; + case ISDN_STAT_BHUP: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line); + printk(KERN_DEBUG "tty_STAT_BHUP ttyI%d\n", info->line); #endif - if (TTY_IS_ACTIVE(info)) { + if (TTY_IS_ACTIVE(info)) { #ifdef ISDN_DEBUG_MODEM_HUP - printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n"); + printk(KERN_DEBUG "Mhup in ISDN_STAT_BHUP\n"); #endif - isdn_tty_modem_hup(info, 0); - return 1; - } - break; - case ISDN_STAT_NODCH: + isdn_tty_modem_hup(info, 0); + return 1; + } + break; + case ISDN_STAT_NODCH: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); -#endif - if (TTY_IS_ACTIVE(info)) { - if (info->dialing) { - info->dialing = 0; - info->last_l2 = -1; - info->last_si = 0; - sprintf(info->last_cause, "0000"); - isdn_tty_modem_result(RESULT_NO_DIALTONE, info); - } - isdn_tty_modem_hup(info, 0); - return 1; + printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); +#endif + if (TTY_IS_ACTIVE(info)) { + if (info->dialing) { + info->dialing = 0; + info->last_l2 = -1; + info->last_si = 0; + sprintf(info->last_cause, "0000"); + isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } - break; - case ISDN_STAT_UNLOAD: + isdn_tty_modem_hup(info, 0); + return 1; + } + break; + case ISDN_STAT_UNLOAD: #ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); + printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); #endif - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - info = &dev->mdm.info[i]; - if (info->isdn_driver == c->driver) { - if (info->online) - isdn_tty_modem_hup(info, 1); - } + for (i = 0; i < ISDN_MAX_CHANNELS; i++) { + info = &dev->mdm.info[i]; + if (info->isdn_driver == c->driver) { + if (info->online) + isdn_tty_modem_hup(info, 1); } - return 1; + } + return 1; #ifdef CONFIG_ISDN_TTY_FAX - case ISDN_STAT_FAXIND: - if (TTY_IS_ACTIVE(info)) { - isdn_tty_fax_command(info, c); - } - break; + case ISDN_STAT_FAXIND: + if (TTY_IS_ACTIVE(info)) { + isdn_tty_fax_command(info, c); + } + break; #endif #ifdef CONFIG_ISDN_AUDIO - case ISDN_STAT_AUDIO: - if (TTY_IS_ACTIVE(info)) { - switch(c->parm.num[0]) { - case ISDN_AUDIO_DTMF: - if (info->vonline) { - isdn_audio_put_dle_code(info, + case ISDN_STAT_AUDIO: + if (TTY_IS_ACTIVE(info)) { + switch (c->parm.num[0]) { + case ISDN_AUDIO_DTMF: + if (info->vonline) { + isdn_audio_put_dle_code(info, c->parm.num[1]); - } - break; } + break; } - break; + } + break; #endif } } @@ -2314,16 +2314,16 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) /********************************************************************* Modem-Emulator-Routines - *********************************************************************/ +*********************************************************************/ -#define cmdchar(c) ((c>=' ')&&(c<=0x7f)) +#define cmdchar(c) ((c >= ' ') && (c <= 0x7f)) /* * Put a message from the AT-emulator into receive-buffer of tty, * convert CR, LF, and BS to values in modem-registers 3, 4 and 5. */ void -isdn_tty_at_cout(char *msg, modem_info * info) +isdn_tty_at_cout(char *msg, modem_info *info) { struct tty_struct *tty; atemu *m = &info->emu; @@ -2351,7 +2351,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) /* use queue instead of direct, if online and */ /* data is in queue or buffer is full */ if (info->online && ((tty_buffer_request_room(tty, l) < l) || - !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { + !skb_queue_empty(&dev->drv[info->isdn_driver]->rpqueue[info->isdn_channel]))) { skb = alloc_skb(l, GFP_ATOMIC); if (!skb) { spin_unlock_irqrestore(&info->readlock, flags); @@ -2366,22 +2366,22 @@ isdn_tty_at_cout(char *msg, modem_info * info) for (p = msg; *p; p++) { switch (*p) { - case '\r': - c = m->mdmreg[REG_CR]; - break; - case '\n': - c = m->mdmreg[REG_LF]; - break; - case '\b': - c = m->mdmreg[REG_BS]; - break; - default: - c = *p; + case '\r': + c = m->mdmreg[REG_CR]; + break; + case '\n': + c = m->mdmreg[REG_LF]; + break; + case '\b': + c = m->mdmreg[REG_BS]; + break; + default: + c = *p; } if (skb) { *sp++ = c; } else { - if(tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) + if (tty_insert_flip_char(tty, c, TTY_NORMAL) == 0) break; } } @@ -2403,7 +2403,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) * Perform ATH Hangup */ static void -isdn_tty_on_hook(modem_info * info) +isdn_tty_on_hook(modem_info *info) { if (info->isdn_channel >= 0) { #ifdef ISDN_DEBUG_MODEM_HUP @@ -2419,8 +2419,8 @@ isdn_tty_off_hook(void) printk(KERN_DEBUG "isdn_tty_off_hook\n"); } -#define PLUSWAIT1 (HZ/2) /* 0.5 sec. */ -#define PLUSWAIT2 (HZ*3/2) /* 1.5 sec */ +#define PLUSWAIT1 (HZ / 2) /* 0.5 sec. */ +#define PLUSWAIT2 (HZ * 3 / 2) /* 1.5 sec */ /* * Check Buffer for Modem-escape-sequence, activate timer-callback to @@ -2434,7 +2434,7 @@ isdn_tty_off_hook(void) * lastplus timestamp of last character */ static void -isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount, +isdn_tty_check_esc(const u_char *p, u_char plus, int count, int *pluscount, u_long *lastplus) { if (plus > 127) @@ -2474,69 +2474,69 @@ isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount, */ static void -isdn_tty_modem_result(int code, modem_info * info) +isdn_tty_modem_result(int code, modem_info *info) { atemu *m = &info->emu; static char *msg[] = - {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR", - "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER", - "RINGING", "NO MSN/EAZ", "VCON", "RUNG"}; - char s[ISDN_MSNLEN+10]; + {"OK", "CONNECT", "RING", "NO CARRIER", "ERROR", + "CONNECT 64000", "NO DIALTONE", "BUSY", "NO ANSWER", + "RINGING", "NO MSN/EAZ", "VCON", "RUNG"}; + char s[ISDN_MSNLEN + 10]; switch (code) { - case RESULT_RING: - m->mdmreg[REG_RINGCNT]++; - if (m->mdmreg[REG_RINGCNT] == m->mdmreg[REG_RINGATA]) - /* Automatically accept incoming call */ - isdn_tty_cmd_ATA(info); - break; - case RESULT_NO_CARRIER: + case RESULT_RING: + m->mdmreg[REG_RINGCNT]++; + if (m->mdmreg[REG_RINGCNT] == m->mdmreg[REG_RINGATA]) + /* Automatically accept incoming call */ + isdn_tty_cmd_ATA(info); + break; + case RESULT_NO_CARRIER: #ifdef ISDN_DEBUG_MODEM_HUP - printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", - (info->flags & ISDN_ASYNC_CLOSING), - (!info->tty)); -#endif - m->mdmreg[REG_RINGCNT] = 0; - del_timer(&info->nc_timer); - info->ncarrier = 0; - if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) { - return; - } + printk(KERN_DEBUG "modem_result: NO CARRIER %d %d\n", + (info->flags & ISDN_ASYNC_CLOSING), + (!info->tty)); +#endif + m->mdmreg[REG_RINGCNT] = 0; + del_timer(&info->nc_timer); + info->ncarrier = 0; + if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) { + return; + } #ifdef CONFIG_ISDN_AUDIO - if (info->vonline & 1) { + if (info->vonline & 1) { #ifdef ISDN_DEBUG_MODEM_VOICE - printk(KERN_DEBUG "res3: send DLE-ETX on ttyI%d\n", - info->line); + printk(KERN_DEBUG "res3: send DLE-ETX on ttyI%d\n", + info->line); #endif - /* voice-recording, add DLE-ETX */ - isdn_tty_at_cout("\020\003", info); - } - if (info->vonline & 2) { + /* voice-recording, add DLE-ETX */ + isdn_tty_at_cout("\020\003", info); + } + if (info->vonline & 2) { #ifdef ISDN_DEBUG_MODEM_VOICE - printk(KERN_DEBUG "res3: send DLE-DC4 on ttyI%d\n", - info->line); + printk(KERN_DEBUG "res3: send DLE-DC4 on ttyI%d\n", + info->line); #endif - /* voice-playing, add DLE-DC4 */ - isdn_tty_at_cout("\020\024", info); - } + /* voice-playing, add DLE-DC4 */ + isdn_tty_at_cout("\020\024", info); + } #endif - break; - case RESULT_CONNECT: - case RESULT_CONNECT64000: - sprintf(info->last_cause, "0000"); - if (!info->online) - info->online = 2; - break; - case RESULT_VCON: + break; + case RESULT_CONNECT: + case RESULT_CONNECT64000: + sprintf(info->last_cause, "0000"); + if (!info->online) + info->online = 2; + break; + case RESULT_VCON: #ifdef ISDN_DEBUG_MODEM_VOICE - printk(KERN_DEBUG "res3: send VCON on ttyI%d\n", - info->line); + printk(KERN_DEBUG "res3: send VCON on ttyI%d\n", + info->line); #endif - sprintf(info->last_cause, "0000"); - if (!info->online) - info->online = 1; - break; - } /* switch(code) */ + sprintf(info->last_cause, "0000"); + if (!info->online) + info->online = 1; + break; + } /* switch (code) */ if (m->mdmreg[REG_RESP] & BIT_RESP) { /* Show results */ @@ -2546,87 +2546,87 @@ isdn_tty_modem_result(int code, modem_info * info) isdn_tty_at_cout(s, info); } else { if (code == RESULT_RING) { - /* return if "show RUNG" and ringcounter>1 */ - if ((m->mdmreg[REG_RUNG] & BIT_RUNG) && + /* return if "show RUNG" and ringcounter>1 */ + if ((m->mdmreg[REG_RUNG] & BIT_RUNG) && (m->mdmreg[REG_RINGCNT] > 1)) - return; - /* print CID, _before_ _every_ ring */ - if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { - isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); - isdn_tty_at_cout(dev->num[info->drv_index], info); - if (m->mdmreg[REG_CDN] & BIT_CDN) { - isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); - isdn_tty_at_cout(info->emu.cpn, info); - } - } + return; + /* print CID, _before_ _every_ ring */ + if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { + isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); + isdn_tty_at_cout(dev->num[info->drv_index], info); + if (m->mdmreg[REG_CDN] & BIT_CDN) { + isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); + isdn_tty_at_cout(info->emu.cpn, info); + } + } } isdn_tty_at_cout("\r\n", info); isdn_tty_at_cout(msg[code], info); switch (code) { - case RESULT_CONNECT: - switch (m->mdmreg[REG_L2PROT]) { - case ISDN_PROTO_L2_MODEM: - isdn_tty_at_cout(" ", info); - isdn_tty_at_cout(m->connmsg, info); - break; - } + case RESULT_CONNECT: + switch (m->mdmreg[REG_L2PROT]) { + case ISDN_PROTO_L2_MODEM: + isdn_tty_at_cout(" ", info); + isdn_tty_at_cout(m->connmsg, info); break; - case RESULT_RING: - /* Append CPN, if enabled */ - if ((m->mdmreg[REG_CPN] & BIT_CPN)) { - sprintf(s, "/%s", m->cpn); - isdn_tty_at_cout(s, info); - } - /* Print CID only once, _after_ 1st RING */ - if ((m->mdmreg[REG_CIDONCE] & BIT_CIDONCE) && - (m->mdmreg[REG_RINGCNT] == 1)) { - isdn_tty_at_cout("\r\n", info); - isdn_tty_at_cout("CALLER NUMBER: ", info); - isdn_tty_at_cout(dev->num[info->drv_index], info); - if (m->mdmreg[REG_CDN] & BIT_CDN) { - isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); - isdn_tty_at_cout(info->emu.cpn, info); - } + } + break; + case RESULT_RING: + /* Append CPN, if enabled */ + if ((m->mdmreg[REG_CPN] & BIT_CPN)) { + sprintf(s, "/%s", m->cpn); + isdn_tty_at_cout(s, info); + } + /* Print CID only once, _after_ 1st RING */ + if ((m->mdmreg[REG_CIDONCE] & BIT_CIDONCE) && + (m->mdmreg[REG_RINGCNT] == 1)) { + isdn_tty_at_cout("\r\n", info); + isdn_tty_at_cout("CALLER NUMBER: ", info); + isdn_tty_at_cout(dev->num[info->drv_index], info); + if (m->mdmreg[REG_CDN] & BIT_CDN) { + isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); + isdn_tty_at_cout(info->emu.cpn, info); } + } + break; + case RESULT_NO_CARRIER: + case RESULT_NO_DIALTONE: + case RESULT_BUSY: + case RESULT_NO_ANSWER: + m->mdmreg[REG_RINGCNT] = 0; + /* Append Cause-Message if enabled */ + if (m->mdmreg[REG_RESPXT] & BIT_RESPXT) { + sprintf(s, "/%s", info->last_cause); + isdn_tty_at_cout(s, info); + } + break; + case RESULT_CONNECT64000: + /* Append Protocol to CONNECT message */ + switch (m->mdmreg[REG_L2PROT]) { + case ISDN_PROTO_L2_X75I: + case ISDN_PROTO_L2_X75UI: + case ISDN_PROTO_L2_X75BUI: + isdn_tty_at_cout("/X.75", info); break; - case RESULT_NO_CARRIER: - case RESULT_NO_DIALTONE: - case RESULT_BUSY: - case RESULT_NO_ANSWER: - m->mdmreg[REG_RINGCNT] = 0; - /* Append Cause-Message if enabled */ - if (m->mdmreg[REG_RESPXT] & BIT_RESPXT) { - sprintf(s, "/%s", info->last_cause); - isdn_tty_at_cout(s, info); - } + case ISDN_PROTO_L2_HDLC: + isdn_tty_at_cout("/HDLC", info); break; - case RESULT_CONNECT64000: - /* Append Protocol to CONNECT message */ - switch (m->mdmreg[REG_L2PROT]) { - case ISDN_PROTO_L2_X75I: - case ISDN_PROTO_L2_X75UI: - case ISDN_PROTO_L2_X75BUI: - isdn_tty_at_cout("/X.75", info); - break; - case ISDN_PROTO_L2_HDLC: - isdn_tty_at_cout("/HDLC", info); - break; - case ISDN_PROTO_L2_V11096: - isdn_tty_at_cout("/V110/9600", info); - break; - case ISDN_PROTO_L2_V11019: - isdn_tty_at_cout("/V110/19200", info); - break; - case ISDN_PROTO_L2_V11038: - isdn_tty_at_cout("/V110/38400", info); - break; - } - if (m->mdmreg[REG_T70] & BIT_T70) { - isdn_tty_at_cout("/T.70", info); - if (m->mdmreg[REG_T70] & BIT_T70_EXT) - isdn_tty_at_cout("+", info); - } + case ISDN_PROTO_L2_V11096: + isdn_tty_at_cout("/V110/9600", info); + break; + case ISDN_PROTO_L2_V11019: + isdn_tty_at_cout("/V110/19200", info); + break; + case ISDN_PROTO_L2_V11038: + isdn_tty_at_cout("/V110/38400", info); break; + } + if (m->mdmreg[REG_T70] & BIT_T70) { + isdn_tty_at_cout("/T.70", info); + if (m->mdmreg[REG_T70] & BIT_T70_EXT) + isdn_tty_at_cout("+", info); + } + break; } isdn_tty_at_cout("\r\n", info); } @@ -2648,7 +2648,7 @@ isdn_tty_modem_result(int code, modem_info * info) * Display a modem-register-value. */ static void -isdn_tty_show_profile(int ridx, modem_info * info) +isdn_tty_show_profile(int ridx, modem_info *info) { char v[6]; @@ -2667,7 +2667,7 @@ isdn_tty_get_msnstr(char *n, char **p) while (((*p[0] >= '0' && *p[0] <= '9') || /* Why a comma ??? */ (*p[0] == ',') || (*p[0] == ':')) && - (limit--)) + (limit--)) *n++ = *p[0]++; *n = '\0'; } @@ -2676,20 +2676,20 @@ isdn_tty_get_msnstr(char *n, char **p) * Get phone-number from modem-commandbuffer */ static void -isdn_tty_getdial(char *p, char *q,int cnt) +isdn_tty_getdial(char *p, char *q, int cnt) { int first = 1; int limit = ISDN_MSNLEN - 1; /* MUST match the size of interface var to avoid - buffer overflow */ + buffer overflow */ - while (strchr(" 0123456789,#.*WPTSR-", *p) && *p && --cnt>0) { + while (strchr(" 0123456789,#.*WPTSR-", *p) && *p && --cnt > 0) { if ((*p >= '0' && *p <= '9') || ((*p == 'S') && first) || ((*p == 'R') && first) || (*p == '*') || (*p == '#')) { *q++ = *p; limit--; } - if(!limit) + if (!limit) break; p++; first = 0; @@ -2701,7 +2701,7 @@ isdn_tty_getdial(char *p, char *q,int cnt) #define PARSE_ERROR1 { isdn_tty_modem_result(RESULT_ERROR, info); return 1; } static void -isdn_tty_report(modem_info * info) +isdn_tty_report(modem_info *info) { atemu *m = &info->emu; char s[80]; @@ -2713,39 +2713,39 @@ isdn_tty_report(modem_info * info) isdn_tty_at_cout(s, info); isdn_tty_at_cout(" Layer-2 Protocol: ", info); switch (info->last_l2) { - case ISDN_PROTO_L2_X75I: - isdn_tty_at_cout("X.75i", info); - break; - case ISDN_PROTO_L2_X75UI: - isdn_tty_at_cout("X.75ui", info); - break; - case ISDN_PROTO_L2_X75BUI: - isdn_tty_at_cout("X.75bui", info); - break; - case ISDN_PROTO_L2_HDLC: - isdn_tty_at_cout("HDLC", info); - break; - case ISDN_PROTO_L2_V11096: - isdn_tty_at_cout("V.110 9600 Baud", info); - break; - case ISDN_PROTO_L2_V11019: - isdn_tty_at_cout("V.110 19200 Baud", info); - break; - case ISDN_PROTO_L2_V11038: - isdn_tty_at_cout("V.110 38400 Baud", info); - break; - case ISDN_PROTO_L2_TRANS: - isdn_tty_at_cout("transparent", info); - break; - case ISDN_PROTO_L2_MODEM: - isdn_tty_at_cout("modem", info); - break; - case ISDN_PROTO_L2_FAX: - isdn_tty_at_cout("fax", info); - break; - default: - isdn_tty_at_cout("unknown", info); - break; + case ISDN_PROTO_L2_X75I: + isdn_tty_at_cout("X.75i", info); + break; + case ISDN_PROTO_L2_X75UI: + isdn_tty_at_cout("X.75ui", info); + break; + case ISDN_PROTO_L2_X75BUI: + isdn_tty_at_cout("X.75bui", info); + break; + case ISDN_PROTO_L2_HDLC: + isdn_tty_at_cout("HDLC", info); + break; + case ISDN_PROTO_L2_V11096: + isdn_tty_at_cout("V.110 9600 Baud", info); + break; + case ISDN_PROTO_L2_V11019: + isdn_tty_at_cout("V.110 19200 Baud", info); + break; + case ISDN_PROTO_L2_V11038: + isdn_tty_at_cout("V.110 38400 Baud", info); + break; + case ISDN_PROTO_L2_TRANS: + isdn_tty_at_cout("transparent", info); + break; + case ISDN_PROTO_L2_MODEM: + isdn_tty_at_cout("modem", info); + break; + case ISDN_PROTO_L2_FAX: + isdn_tty_at_cout("fax", info); + break; + default: + isdn_tty_at_cout("unknown", info); + break; } if (m->mdmreg[REG_T70] & BIT_T70) { isdn_tty_at_cout("/T.70", info); @@ -2755,19 +2755,19 @@ isdn_tty_report(modem_info * info) isdn_tty_at_cout("\r\n", info); isdn_tty_at_cout(" Service: ", info); switch (info->last_si) { - case 1: - isdn_tty_at_cout("audio\r\n", info); - break; - case 5: - isdn_tty_at_cout("btx\r\n", info); - break; - case 7: - isdn_tty_at_cout("data\r\n", info); - break; - default: - sprintf(s, "%d\r\n", info->last_si); - isdn_tty_at_cout(s, info); - break; + case 1: + isdn_tty_at_cout("audio\r\n", info); + break; + case 5: + isdn_tty_at_cout("btx\r\n", info); + break; + case 7: + isdn_tty_at_cout("data\r\n", info); + break; + default: + sprintf(s, "%d\r\n", info->last_si); + isdn_tty_at_cout(s, info); + break; } sprintf(s, " Hangup location: %s\r\n", info->last_lhup ? "local" : "remote"); isdn_tty_at_cout(s, info); @@ -2779,7 +2779,7 @@ isdn_tty_report(modem_info * info) * Parse AT&.. commands. */ static int -isdn_tty_cmd_ATand(char **p, modem_info * info) +isdn_tty_cmd_ATand(char **p, modem_info *info) { atemu *m = &info->emu; int i; @@ -2788,224 +2788,224 @@ isdn_tty_cmd_ATand(char **p, modem_info * info) #define MAXRB (sizeof(rb) - 1) switch (*p[0]) { - case 'B': - /* &B - Set Buffersize */ - p[0]++; - i = isdn_getnum(p); - if ((i < 0) || (i > ISDN_SERIAL_XMIT_MAX)) - PARSE_ERROR1; + case 'B': + /* &B - Set Buffersize */ + p[0]++; + i = isdn_getnum(p); + if ((i < 0) || (i > ISDN_SERIAL_XMIT_MAX)) + PARSE_ERROR1; #ifdef CONFIG_ISDN_AUDIO - if ((m->mdmreg[REG_SI1] & 1) && (i > VBUF)) - PARSE_ERROR1; + if ((m->mdmreg[REG_SI1] & 1) && (i > VBUF)) + PARSE_ERROR1; #endif - m->mdmreg[REG_PSIZE] = i / 16; - info->xmit_size = m->mdmreg[REG_PSIZE] * 16; - switch (m->mdmreg[REG_L2PROT]) { - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: - info->xmit_size /= 10; - } - break; - case 'C': - /* &C - DCD Status */ - p[0]++; - switch (isdn_getnum(p)) { - case 0: - m->mdmreg[REG_DCD] &= ~BIT_DCD; - break; - case 1: - m->mdmreg[REG_DCD] |= BIT_DCD; - break; - default: - PARSE_ERROR1 - } + m->mdmreg[REG_PSIZE] = i / 16; + info->xmit_size = m->mdmreg[REG_PSIZE] * 16; + switch (m->mdmreg[REG_L2PROT]) { + case ISDN_PROTO_L2_V11096: + case ISDN_PROTO_L2_V11019: + case ISDN_PROTO_L2_V11038: + info->xmit_size /= 10; + } + break; + case 'C': + /* &C - DCD Status */ + p[0]++; + switch (isdn_getnum(p)) { + case 0: + m->mdmreg[REG_DCD] &= ~BIT_DCD; break; - case 'D': - /* &D - Set DTR-Low-behavior */ - p[0]++; - switch (isdn_getnum(p)) { - case 0: - m->mdmreg[REG_DTRHUP] &= ~BIT_DTRHUP; - m->mdmreg[REG_DTRR] &= ~BIT_DTRR; - break; - case 2: - m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; - m->mdmreg[REG_DTRR] &= ~BIT_DTRR; - break; - case 3: - m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; - m->mdmreg[REG_DTRR] |= BIT_DTRR; - break; - default: - PARSE_ERROR1 - } + case 1: + m->mdmreg[REG_DCD] |= BIT_DCD; break; - case 'E': - /* &E -Set EAZ/MSN */ - p[0]++; - isdn_tty_get_msnstr(m->msn, p); + default: + PARSE_ERROR1 + } + break; + case 'D': + /* &D - Set DTR-Low-behavior */ + p[0]++; + switch (isdn_getnum(p)) { + case 0: + m->mdmreg[REG_DTRHUP] &= ~BIT_DTRHUP; + m->mdmreg[REG_DTRR] &= ~BIT_DTRR; break; - case 'F': - /* &F -Set Factory-Defaults */ - p[0]++; - if (info->msr & UART_MSR_DCD) - PARSE_ERROR1; - isdn_tty_reset_profile(m); - isdn_tty_modem_reset_regs(info, 1); + case 2: + m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; + m->mdmreg[REG_DTRR] &= ~BIT_DTRR; + break; + case 3: + m->mdmreg[REG_DTRHUP] |= BIT_DTRHUP; + m->mdmreg[REG_DTRR] |= BIT_DTRR; break; + default: + PARSE_ERROR1 + } + break; + case 'E': + /* &E -Set EAZ/MSN */ + p[0]++; + isdn_tty_get_msnstr(m->msn, p); + break; + case 'F': + /* &F -Set Factory-Defaults */ + p[0]++; + if (info->msr & UART_MSR_DCD) + PARSE_ERROR1; + isdn_tty_reset_profile(m); + isdn_tty_modem_reset_regs(info, 1); + break; #ifdef DUMMY_HAYES_AT - case 'K': - /* only for be compilant with common scripts */ - /* &K Flowcontrol - no function */ - p[0]++; - isdn_getnum(p); + case 'K': + /* only for be compilant with common scripts */ + /* &K Flowcontrol - no function */ + p[0]++; + isdn_getnum(p); + break; +#endif + case 'L': + /* &L -Set Numbers to listen on */ + p[0]++; + i = 0; + while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) && + (i < ISDN_LMSNLEN - 1)) + m->lmsn[i++] = *p[0]++; + m->lmsn[i] = '\0'; + break; + case 'R': + /* &R - Set V.110 bitrate adaption */ + p[0]++; + i = isdn_getnum(p); + switch (i) { + case 0: + /* Switch off V.110, back to X.75 */ + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; + m->mdmreg[REG_SI2] = 0; + info->xmit_size = m->mdmreg[REG_PSIZE] * 16; break; -#endif - case 'L': - /* &L -Set Numbers to listen on */ - p[0]++; - i = 0; - while (*p[0] && (strchr("0123456789,-*[]?;", *p[0])) && - (i < ISDN_LMSNLEN - 1)) - m->lmsn[i++] = *p[0]++; - m->lmsn[i] = '\0'; - break; - case 'R': - /* &R - Set V.110 bitrate adaption */ - p[0]++; - i = isdn_getnum(p); - switch (i) { - case 0: - /* Switch off V.110, back to X.75 */ - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; - m->mdmreg[REG_SI2] = 0; - info->xmit_size = m->mdmreg[REG_PSIZE] * 16; - break; - case 9600: - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11096; - m->mdmreg[REG_SI2] = 197; - info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; - break; - case 19200: - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11019; - m->mdmreg[REG_SI2] = 199; - info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; - break; - case 38400: - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11038; - m->mdmreg[REG_SI2] = 198; /* no existing standard for this */ - info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; - break; - default: - PARSE_ERROR1; - } - /* Switch off T.70 */ - m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); - /* Set Service 7 */ - m->mdmreg[REG_SI1] |= 4; + case 9600: + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11096; + m->mdmreg[REG_SI2] = 197; + info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; break; - case 'S': - /* &S - Set Windowsize */ - p[0]++; - i = isdn_getnum(p); - if ((i > 0) && (i < 9)) - m->mdmreg[REG_WSIZE] = i; - else - PARSE_ERROR1; + case 19200: + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11019; + m->mdmreg[REG_SI2] = 199; + info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; break; - case 'V': - /* &V - Show registers */ - p[0]++; - isdn_tty_at_cout("\r\n", info); - for (i = 0; i < ISDN_MODEM_NUMREG; i++) { - sprintf(rb, "S%02d=%03d%s", i, - m->mdmreg[i], ((i + 1) % 10) ? " " : "\r\n"); - isdn_tty_at_cout(rb, info); - } - sprintf(rb, "\r\nEAZ/MSN: %.50s\r\n", - strlen(m->msn) ? m->msn : "None"); - isdn_tty_at_cout(rb, info); - if (strlen(m->lmsn)) { - isdn_tty_at_cout("\r\nListen: ", info); - isdn_tty_at_cout(m->lmsn, info); - isdn_tty_at_cout("\r\n", info); - } + case 38400: + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_V11038; + m->mdmreg[REG_SI2] = 198; /* no existing standard for this */ + info->xmit_size = m->mdmreg[REG_PSIZE] * 16 / 10; break; - case 'W': - /* &W - Write Profile */ + default: + PARSE_ERROR1; + } + /* Switch off T.70 */ + m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); + /* Set Service 7 */ + m->mdmreg[REG_SI1] |= 4; + break; + case 'S': + /* &S - Set Windowsize */ + p[0]++; + i = isdn_getnum(p); + if ((i > 0) && (i < 9)) + m->mdmreg[REG_WSIZE] = i; + else + PARSE_ERROR1; + break; + case 'V': + /* &V - Show registers */ + p[0]++; + isdn_tty_at_cout("\r\n", info); + for (i = 0; i < ISDN_MODEM_NUMREG; i++) { + sprintf(rb, "S%02d=%03d%s", i, + m->mdmreg[i], ((i + 1) % 10) ? " " : "\r\n"); + isdn_tty_at_cout(rb, info); + } + sprintf(rb, "\r\nEAZ/MSN: %.50s\r\n", + strlen(m->msn) ? m->msn : "None"); + isdn_tty_at_cout(rb, info); + if (strlen(m->lmsn)) { + isdn_tty_at_cout("\r\nListen: ", info); + isdn_tty_at_cout(m->lmsn, info); + isdn_tty_at_cout("\r\n", info); + } + break; + case 'W': + /* &W - Write Profile */ + p[0]++; + switch (*p[0]) { + case '0': p[0]++; - switch (*p[0]) { - case '0': - p[0]++; - modem_write_profile(m); - break; - default: - PARSE_ERROR1; - } + modem_write_profile(m); break; - case 'X': - /* &X - Switch to BTX-Mode and T.70 */ - p[0]++; - switch (isdn_getnum(p)) { - case 0: - m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); - info->xmit_size = m->mdmreg[REG_PSIZE] * 16; - break; - case 1: - m->mdmreg[REG_T70] |= BIT_T70; - m->mdmreg[REG_T70] &= ~BIT_T70_EXT; - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; - info->xmit_size = 112; - m->mdmreg[REG_SI1] = 4; - m->mdmreg[REG_SI2] = 0; - break; - case 2: - m->mdmreg[REG_T70] |= (BIT_T70 | BIT_T70_EXT); - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; - info->xmit_size = 112; - m->mdmreg[REG_SI1] = 4; - m->mdmreg[REG_SI2] = 0; - break; - default: - PARSE_ERROR1; - } + default: + PARSE_ERROR1; + } + break; + case 'X': + /* &X - Switch to BTX-Mode and T.70 */ + p[0]++; + switch (isdn_getnum(p)) { + case 0: + m->mdmreg[REG_T70] &= ~(BIT_T70 | BIT_T70_EXT); + info->xmit_size = m->mdmreg[REG_PSIZE] * 16; + break; + case 1: + m->mdmreg[REG_T70] |= BIT_T70; + m->mdmreg[REG_T70] &= ~BIT_T70_EXT; + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; + info->xmit_size = 112; + m->mdmreg[REG_SI1] = 4; + m->mdmreg[REG_SI2] = 0; + break; + case 2: + m->mdmreg[REG_T70] |= (BIT_T70 | BIT_T70_EXT); + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; + info->xmit_size = 112; + m->mdmreg[REG_SI1] = 4; + m->mdmreg[REG_SI2] = 0; break; default: PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } static int -isdn_tty_check_ats(int mreg, int mval, modem_info * info, atemu * m) +isdn_tty_check_ats(int mreg, int mval, modem_info *info, atemu *m) { /* Some plausibility checks */ switch (mreg) { - case REG_L2PROT: - if (mval > ISDN_PROTO_L2_MAX) - return 1; - break; - case REG_PSIZE: - if ((mval * 16) > ISDN_SERIAL_XMIT_MAX) - return 1; + case REG_L2PROT: + if (mval > ISDN_PROTO_L2_MAX) + return 1; + break; + case REG_PSIZE: + if ((mval * 16) > ISDN_SERIAL_XMIT_MAX) + return 1; #ifdef CONFIG_ISDN_AUDIO - if ((m->mdmreg[REG_SI1] & 1) && (mval > VBUFX)) - return 1; -#endif - info->xmit_size = mval * 16; - switch (m->mdmreg[REG_L2PROT]) { - case ISDN_PROTO_L2_V11096: - case ISDN_PROTO_L2_V11019: - case ISDN_PROTO_L2_V11038: - info->xmit_size /= 10; - } - break; - case REG_SI1I: - case REG_PLAN: - case REG_SCREEN: - /* readonly registers */ + if ((m->mdmreg[REG_SI1] & 1) && (mval > VBUFX)) return 1; +#endif + info->xmit_size = mval * 16; + switch (m->mdmreg[REG_L2PROT]) { + case ISDN_PROTO_L2_V11096: + case ISDN_PROTO_L2_V11019: + case ISDN_PROTO_L2_V11038: + info->xmit_size /= 10; + } + break; + case REG_SI1I: + case REG_PLAN: + case REG_SCREEN: + /* readonly registers */ + return 1; } return 0; } @@ -3014,7 +3014,7 @@ isdn_tty_check_ats(int mreg, int mval, modem_info * info, atemu * m) * Perform ATS command */ static int -isdn_tty_cmd_ATS(char **p, modem_info * info) +isdn_tty_cmd_ATS(char **p, modem_info *info) { atemu *m = &info->emu; int bitpos; @@ -3026,52 +3026,52 @@ isdn_tty_cmd_ATS(char **p, modem_info * info) if (mreg < 0 || mreg >= ISDN_MODEM_NUMREG) PARSE_ERROR1; switch (*p[0]) { + case '=': + p[0]++; + mval = isdn_getnum(p); + if (mval < 0 || mval > 255) + PARSE_ERROR1; + if (isdn_tty_check_ats(mreg, mval, info, m)) + PARSE_ERROR1; + m->mdmreg[mreg] = mval; + break; + case '.': + /* Set/Clear a single bit */ + p[0]++; + bitpos = isdn_getnum(p); + if ((bitpos < 0) || (bitpos > 7)) + PARSE_ERROR1; + switch (*p[0]) { case '=': p[0]++; - mval = isdn_getnum(p); - if (mval < 0 || mval > 255) + bval = isdn_getnum(p); + if (bval < 0 || bval > 1) PARSE_ERROR1; + if (bval) + mval = m->mdmreg[mreg] | (1 << bitpos); + else + mval = m->mdmreg[mreg] & ~(1 << bitpos); if (isdn_tty_check_ats(mreg, mval, info, m)) PARSE_ERROR1; m->mdmreg[mreg] = mval; break; - case '.': - /* Set/Clear a single bit */ - p[0]++; - bitpos = isdn_getnum(p); - if ((bitpos < 0) || (bitpos > 7)) - PARSE_ERROR1; - switch (*p[0]) { - case '=': - p[0]++; - bval = isdn_getnum(p); - if (bval < 0 || bval > 1) - PARSE_ERROR1; - if (bval) - mval = m->mdmreg[mreg] | (1 << bitpos); - else - mval = m->mdmreg[mreg] & ~(1 << bitpos); - if (isdn_tty_check_ats(mreg, mval, info, m)) - PARSE_ERROR1; - m->mdmreg[mreg] = mval; - break; - case '?': - p[0]++; - isdn_tty_at_cout("\r\n", info); - isdn_tty_at_cout((m->mdmreg[mreg] & (1 << bitpos)) ? "1" : "0", - info); - break; - default: - PARSE_ERROR1; - } - break; case '?': p[0]++; - isdn_tty_show_profile(mreg, info); + isdn_tty_at_cout("\r\n", info); + isdn_tty_at_cout((m->mdmreg[mreg] & (1 << bitpos)) ? "1" : "0", + info); break; default: PARSE_ERROR1; - break; + } + break; + case '?': + p[0]++; + isdn_tty_show_profile(mreg, info); + break; + default: + PARSE_ERROR1; + break; } return 0; } @@ -3080,7 +3080,7 @@ isdn_tty_cmd_ATS(char **p, modem_info * info) * Perform ATA command */ static void -isdn_tty_cmd_ATA(modem_info * info) +isdn_tty_cmd_ATA(modem_info *info) { atemu *m = &info->emu; isdn_ctrl cmd; @@ -3134,7 +3134,7 @@ isdn_tty_cmd_ATA(modem_info * info) * Parse AT+F.. commands */ static int -isdn_tty_cmd_PLUSF(char **p, modem_info * info) +isdn_tty_cmd_PLUSF(char **p, modem_info *info) { atemu *m = &info->emu; char rs[20]; @@ -3142,81 +3142,81 @@ isdn_tty_cmd_PLUSF(char **p, modem_info * info) if (!strncmp(p[0], "CLASS", 5)) { p[0] += 5; switch (*p[0]) { - case '?': - p[0]++; - sprintf(rs, "\r\n%d", - (m->mdmreg[REG_SI1] & 1) ? 8 : 0); + case '?': + p[0]++; + sprintf(rs, "\r\n%d", + (m->mdmreg[REG_SI1] & 1) ? 8 : 0); #ifdef CONFIG_ISDN_TTY_FAX - if (TTY_IS_FCLASS2(info)) - sprintf(rs, "\r\n2"); - else if (TTY_IS_FCLASS1(info)) - sprintf(rs, "\r\n1"); + if (TTY_IS_FCLASS2(info)) + sprintf(rs, "\r\n2"); + else if (TTY_IS_FCLASS1(info)) + sprintf(rs, "\r\n1"); #endif - isdn_tty_at_cout(rs, info); - break; - case '=': + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + switch (*p[0]) { + case '0': p[0]++; - switch (*p[0]) { - case '0': - p[0]++; - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; - m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; - m->mdmreg[REG_SI1] = 4; - info->xmit_size = - m->mdmreg[REG_PSIZE] * 16; - break; + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; + m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; + m->mdmreg[REG_SI1] = 4; + info->xmit_size = + m->mdmreg[REG_PSIZE] * 16; + break; #ifdef CONFIG_ISDN_TTY_FAX - case '1': - p[0]++; - if (!(dev->global_features & - ISDN_FEATURE_L3_FCLASS1)) - PARSE_ERROR1; - m->mdmreg[REG_SI1] = 1; - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; - m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS1; - info->xmit_size = - m->mdmreg[REG_PSIZE] * 16; - break; - case '2': - p[0]++; - if (!(dev->global_features & - ISDN_FEATURE_L3_FCLASS2)) - PARSE_ERROR1; - m->mdmreg[REG_SI1] = 1; - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; - m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS2; - info->xmit_size = - m->mdmreg[REG_PSIZE] * 16; - break; + case '1': + p[0]++; + if (!(dev->global_features & + ISDN_FEATURE_L3_FCLASS1)) + PARSE_ERROR1; + m->mdmreg[REG_SI1] = 1; + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; + m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS1; + info->xmit_size = + m->mdmreg[REG_PSIZE] * 16; + break; + case '2': + p[0]++; + if (!(dev->global_features & + ISDN_FEATURE_L3_FCLASS2)) + PARSE_ERROR1; + m->mdmreg[REG_SI1] = 1; + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_FAX; + m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_FCLASS2; + info->xmit_size = + m->mdmreg[REG_PSIZE] * 16; + break; #endif - case '8': - p[0]++; - /* L2 will change on dialout with si=1 */ - m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; - m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; - m->mdmreg[REG_SI1] = 5; - info->xmit_size = VBUF; - break; - case '?': - p[0]++; - strcpy(rs, "\r\n0,"); + case '8': + p[0]++; + /* L2 will change on dialout with si=1 */ + m->mdmreg[REG_L2PROT] = ISDN_PROTO_L2_X75I; + m->mdmreg[REG_L3PROT] = ISDN_PROTO_L3_TRANS; + m->mdmreg[REG_SI1] = 5; + info->xmit_size = VBUF; + break; + case '?': + p[0]++; + strcpy(rs, "\r\n0,"); #ifdef CONFIG_ISDN_TTY_FAX - if (dev->global_features & - ISDN_FEATURE_L3_FCLASS1) - strcat(rs, "1,"); - if (dev->global_features & - ISDN_FEATURE_L3_FCLASS2) - strcat(rs, "2,"); -#endif - strcat(rs, "8"); - isdn_tty_at_cout(rs, info); - break; - default: - PARSE_ERROR1; - } + if (dev->global_features & + ISDN_FEATURE_L3_FCLASS1) + strcat(rs, "1,"); + if (dev->global_features & + ISDN_FEATURE_L3_FCLASS2) + strcat(rs, "2,"); +#endif + strcat(rs, "8"); + isdn_tty_at_cout(rs, info); break; default: PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -3231,12 +3231,12 @@ isdn_tty_cmd_PLUSF(char **p, modem_info * info) * Parse AT+V.. commands */ static int -isdn_tty_cmd_PLUSV(char **p, modem_info * info) +isdn_tty_cmd_PLUSV(char **p, modem_info *info) { atemu *m = &info->emu; isdn_ctrl cmd; static char *vcmd[] = - {"NH", "IP", "LS", "RX", "SD", "SM", "TX", "DD", NULL}; + {"NH", "IP", "LS", "RX", "SD", "SM", "TX", "DD", NULL}; int i; int par1; int par2; @@ -3251,256 +3251,256 @@ isdn_tty_cmd_PLUSV(char **p, modem_info * info) i++; } switch (i) { - case 0: - /* AT+VNH - Auto hangup feature */ + case 0: + /* AT+VNH - Auto hangup feature */ + switch (*p[0]) { + case '?': + p[0]++; + isdn_tty_at_cout("\r\n1", info); + break; + case '=': + p[0]++; switch (*p[0]) { - case '?': - p[0]++; - isdn_tty_at_cout("\r\n1", info); - break; - case '=': - p[0]++; - switch (*p[0]) { - case '1': - p[0]++; - break; - case '?': - p[0]++; - isdn_tty_at_cout("\r\n1", info); - break; - default: - PARSE_ERROR1; - } - break; - default: - PARSE_ERROR1; + case '1': + p[0]++; + break; + case '?': + p[0]++; + isdn_tty_at_cout("\r\n1", info); + break; + default: + PARSE_ERROR1; } break; - case 1: - /* AT+VIP - Reset all voice parameters */ - isdn_tty_modem_reset_vpar(m); + default: + PARSE_ERROR1; + } + break; + case 1: + /* AT+VIP - Reset all voice parameters */ + isdn_tty_modem_reset_vpar(m); + break; + case 2: + /* AT+VLS - Select device, accept incoming call */ + switch (*p[0]) { + case '?': + p[0]++; + sprintf(rs, "\r\n%d", m->vpar[0]); + isdn_tty_at_cout(rs, info); break; - case 2: - /* AT+VLS - Select device, accept incoming call */ + case '=': + p[0]++; switch (*p[0]) { - case '?': - p[0]++; - sprintf(rs, "\r\n%d", m->vpar[0]); - isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - switch (*p[0]) { - case '0': - p[0]++; - m->vpar[0] = 0; - break; - case '2': - p[0]++; - m->vpar[0] = 2; - break; - case '?': - p[0]++; - isdn_tty_at_cout("\r\n0,2", info); - break; - default: - PARSE_ERROR1; - } - break; - default: - PARSE_ERROR1; - } - break; - case 3: - /* AT+VRX - Start recording */ - if (!m->vpar[0]) - PARSE_ERROR1; - if (info->online != 1) { - isdn_tty_modem_result(RESULT_NO_ANSWER, info); - return 1; - } - info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); - if (!info->dtmf_state) { - printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); + case '0': + p[0]++; + m->vpar[0] = 0; + break; + case '2': + p[0]++; + m->vpar[0] = 2; + break; + case '?': + p[0]++; + isdn_tty_at_cout("\r\n0,2", info); + break; + default: PARSE_ERROR1; } - info->silence_state = isdn_audio_silence_init(info->silence_state); - if (!info->silence_state) { - printk(KERN_WARNING "isdn_tty: Couldn't malloc silence state\n"); + break; + default: + PARSE_ERROR1; + } + break; + case 3: + /* AT+VRX - Start recording */ + if (!m->vpar[0]) + PARSE_ERROR1; + if (info->online != 1) { + isdn_tty_modem_result(RESULT_NO_ANSWER, info); + return 1; + } + info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); + if (!info->dtmf_state) { + printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); + PARSE_ERROR1; + } + info->silence_state = isdn_audio_silence_init(info->silence_state); + if (!info->silence_state) { + printk(KERN_WARNING "isdn_tty: Couldn't malloc silence state\n"); + PARSE_ERROR1; + } + if (m->vpar[3] < 5) { + info->adpcmr = isdn_audio_adpcm_init(info->adpcmr, m->vpar[3]); + if (!info->adpcmr) { + printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); PARSE_ERROR1; } - if (m->vpar[3] < 5) { - info->adpcmr = isdn_audio_adpcm_init(info->adpcmr, m->vpar[3]); - if (!info->adpcmr) { - printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); - PARSE_ERROR1; - } - } + } #ifdef ISDN_DEBUG_AT - printk(KERN_DEBUG "AT: +VRX\n"); + printk(KERN_DEBUG "AT: +VRX\n"); #endif - info->vonline |= 1; - isdn_tty_modem_result(RESULT_CONNECT, info); - return 0; + info->vonline |= 1; + isdn_tty_modem_result(RESULT_CONNECT, info); + return 0; + break; + case 4: + /* AT+VSD - Silence detection */ + switch (*p[0]) { + case '?': + p[0]++; + sprintf(rs, "\r\n<%d>,<%d>", + m->vpar[1], + m->vpar[2]); + isdn_tty_at_cout(rs, info); break; - case 4: - /* AT+VSD - Silence detection */ - switch (*p[0]) { - case '?': - p[0]++; - sprintf(rs, "\r\n<%d>,<%d>", - m->vpar[1], - m->vpar[2]); - isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if ((*p[0]>='0') && (*p[0]<='9')) { - par1 = isdn_getnum(p); - if ((par1 < 0) || (par1 > 31)) - PARSE_ERROR1; - if (*p[0] != ',') - PARSE_ERROR1; - p[0]++; - par2 = isdn_getnum(p); - if ((par2 < 0) || (par2 > 255)) - PARSE_ERROR1; - m->vpar[1] = par1; - m->vpar[2] = par2; - break; - } else - if (*p[0] == '?') { - p[0]++; - isdn_tty_at_cout("\r\n<0-31>,<0-255>", - info); - break; - } else + case '=': + p[0]++; + if ((*p[0] >= '0') && (*p[0] <= '9')) { + par1 = isdn_getnum(p); + if ((par1 < 0) || (par1 > 31)) PARSE_ERROR1; - break; - default: + if (*p[0] != ',') PARSE_ERROR1; - } - break; - case 5: - /* AT+VSM - Select compression */ - switch (*p[0]) { - case '?': - p[0]++; - sprintf(rs, "\r\n<%d>,<%d><8000>", - m->vpar[3], - m->vpar[1]); - isdn_tty_at_cout(rs, info); - break; - case '=': + p[0]++; + par2 = isdn_getnum(p); + if ((par2 < 0) || (par2 > 255)) + PARSE_ERROR1; + m->vpar[1] = par1; + m->vpar[2] = par2; + break; + } else + if (*p[0] == '?') { p[0]++; - switch (*p[0]) { - case '2': - case '3': - case '4': - case '5': - case '6': - par1 = isdn_getnum(p); - if ((par1 < 2) || (par1 > 6)) - PARSE_ERROR1; - m->vpar[3] = par1; - break; - case '?': - p[0]++; - isdn_tty_at_cout("\r\n2;ADPCM;2;0;(8000)\r\n", - info); - isdn_tty_at_cout("3;ADPCM;3;0;(8000)\r\n", - info); - isdn_tty_at_cout("4;ADPCM;4;0;(8000)\r\n", - info); - isdn_tty_at_cout("5;ALAW;8;0;(8000)\r\n", - info); - isdn_tty_at_cout("6;ULAW;8;0;(8000)\r\n", - info); - break; - default: - PARSE_ERROR1; - } + isdn_tty_at_cout("\r\n<0-31>,<0-255>", + info); break; - default: + } else PARSE_ERROR1; - } break; - case 6: - /* AT+VTX - Start sending */ - if (!m->vpar[0]) + default: + PARSE_ERROR1; + } + break; + case 5: + /* AT+VSM - Select compression */ + switch (*p[0]) { + case '?': + p[0]++; + sprintf(rs, "\r\n<%d>,<%d><8000>", + m->vpar[3], + m->vpar[1]); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + switch (*p[0]) { + case '2': + case '3': + case '4': + case '5': + case '6': + par1 = isdn_getnum(p); + if ((par1 < 2) || (par1 > 6)) + PARSE_ERROR1; + m->vpar[3] = par1; + break; + case '?': + p[0]++; + isdn_tty_at_cout("\r\n2;ADPCM;2;0;(8000)\r\n", + info); + isdn_tty_at_cout("3;ADPCM;3;0;(8000)\r\n", + info); + isdn_tty_at_cout("4;ADPCM;4;0;(8000)\r\n", + info); + isdn_tty_at_cout("5;ALAW;8;0;(8000)\r\n", + info); + isdn_tty_at_cout("6;ULAW;8;0;(8000)\r\n", + info); + break; + default: PARSE_ERROR1; - if (info->online != 1) { - isdn_tty_modem_result(RESULT_NO_ANSWER, info); - return 1; } - info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); - if (!info->dtmf_state) { - printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); + break; + default: + PARSE_ERROR1; + } + break; + case 6: + /* AT+VTX - Start sending */ + if (!m->vpar[0]) + PARSE_ERROR1; + if (info->online != 1) { + isdn_tty_modem_result(RESULT_NO_ANSWER, info); + return 1; + } + info->dtmf_state = isdn_audio_dtmf_init(info->dtmf_state); + if (!info->dtmf_state) { + printk(KERN_WARNING "isdn_tty: Couldn't malloc dtmf state\n"); + PARSE_ERROR1; + } + if (m->vpar[3] < 5) { + info->adpcms = isdn_audio_adpcm_init(info->adpcms, m->vpar[3]); + if (!info->adpcms) { + printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); PARSE_ERROR1; } - if (m->vpar[3] < 5) { - info->adpcms = isdn_audio_adpcm_init(info->adpcms, m->vpar[3]); - if (!info->adpcms) { - printk(KERN_WARNING "isdn_tty: Couldn't malloc adpcm state\n"); - PARSE_ERROR1; - } - } + } #ifdef ISDN_DEBUG_AT - printk(KERN_DEBUG "AT: +VTX\n"); + printk(KERN_DEBUG "AT: +VTX\n"); #endif - m->lastDLE = 0; - info->vonline |= 2; - isdn_tty_modem_result(RESULT_CONNECT, info); - return 0; + m->lastDLE = 0; + info->vonline |= 2; + isdn_tty_modem_result(RESULT_CONNECT, info); + return 0; + break; + case 7: + /* AT+VDD - DTMF detection */ + switch (*p[0]) { + case '?': + p[0]++; + sprintf(rs, "\r\n<%d>,<%d>", + m->vpar[4], + m->vpar[5]); + isdn_tty_at_cout(rs, info); break; - case 7: - /* AT+VDD - DTMF detection */ - switch (*p[0]) { - case '?': - p[0]++; - sprintf(rs, "\r\n<%d>,<%d>", - m->vpar[4], - m->vpar[5]); - isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if ((*p[0]>='0') && (*p[0]<='9')) { - if (info->online != 1) - PARSE_ERROR1; - par1 = isdn_getnum(p); - if ((par1 < 0) || (par1 > 15)) - PARSE_ERROR1; - if (*p[0] != ',') - PARSE_ERROR1; - p[0]++; - par2 = isdn_getnum(p); - if ((par2 < 0) || (par2 > 255)) - PARSE_ERROR1; - m->vpar[4] = par1; - m->vpar[5] = par2; - cmd.driver = info->isdn_driver; - cmd.command = ISDN_CMD_AUDIO; - cmd.arg = info->isdn_channel + (ISDN_AUDIO_SETDD << 8); - cmd.parm.num[0] = par1; - cmd.parm.num[1] = par2; - isdn_command(&cmd); - break; - } else - if (*p[0] == '?') { - p[0]++; - isdn_tty_at_cout("\r\n<0-15>,<0-255>", - info); - break; - } else + case '=': + p[0]++; + if ((*p[0] >= '0') && (*p[0] <= '9')) { + if (info->online != 1) + PARSE_ERROR1; + par1 = isdn_getnum(p); + if ((par1 < 0) || (par1 > 15)) + PARSE_ERROR1; + if (*p[0] != ',') PARSE_ERROR1; + p[0]++; + par2 = isdn_getnum(p); + if ((par2 < 0) || (par2 > 255)) + PARSE_ERROR1; + m->vpar[4] = par1; + m->vpar[5] = par2; + cmd.driver = info->isdn_driver; + cmd.command = ISDN_CMD_AUDIO; + cmd.arg = info->isdn_channel + (ISDN_AUDIO_SETDD << 8); + cmd.parm.num[0] = par1; + cmd.parm.num[1] = par2; + isdn_command(&cmd); + break; + } else + if (*p[0] == '?') { + p[0]++; + isdn_tty_at_cout("\r\n<0-15>,<0-255>", + info); break; - default: + } else PARSE_ERROR1; - } break; default: PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -3510,7 +3510,7 @@ isdn_tty_cmd_PLUSV(char **p, modem_info * info) * Parse and perform an AT-command-line. */ static void -isdn_tty_parse_at(modem_info * info) +isdn_tty_parse_at(modem_info *info) { atemu *m = &info->emu; char *p; @@ -3521,188 +3521,188 @@ isdn_tty_parse_at(modem_info * info) #endif for (p = &m->mdmcmd[2]; *p;) { switch (*p) { - case ' ': - p++; + case ' ': + p++; + break; + case 'A': + /* A - Accept incoming call */ + p++; + isdn_tty_cmd_ATA(info); + return; + break; + case 'D': + /* D - Dial */ + if (info->msr & UART_MSR_DCD) + PARSE_ERROR; + if (info->msr & UART_MSR_RI) { + isdn_tty_modem_result(RESULT_NO_CARRIER, info); + return; + } + isdn_tty_getdial(++p, ds, sizeof ds); + p += strlen(p); + if (!strlen(m->msn)) + isdn_tty_modem_result(RESULT_NO_MSN_EAZ, info); + else if (strlen(ds)) + isdn_tty_dial(ds, info, m); + else + PARSE_ERROR; + return; + case 'E': + /* E - Turn Echo on/off */ + p++; + switch (isdn_getnum(&p)) { + case 0: + m->mdmreg[REG_ECHO] &= ~BIT_ECHO; break; - case 'A': - /* A - Accept incoming call */ + case 1: + m->mdmreg[REG_ECHO] |= BIT_ECHO; + break; + default: + PARSE_ERROR; + } + break; + case 'H': + /* H - On/Off-hook */ + p++; + switch (*p) { + case '0': p++; - isdn_tty_cmd_ATA(info); - return; + isdn_tty_on_hook(info); break; - case 'D': - /* D - Dial */ - if (info->msr & UART_MSR_DCD) - PARSE_ERROR; - if (info->msr & UART_MSR_RI) { - isdn_tty_modem_result(RESULT_NO_CARRIER, info); - return; - } - isdn_tty_getdial(++p, ds, sizeof ds); - p += strlen(p); - if (!strlen(m->msn)) - isdn_tty_modem_result(RESULT_NO_MSN_EAZ, info); - else if (strlen(ds)) - isdn_tty_dial(ds, info, m); - else - PARSE_ERROR; - return; - case 'E': - /* E - Turn Echo on/off */ + case '1': p++; - switch (isdn_getnum(&p)) { - case 0: - m->mdmreg[REG_ECHO] &= ~BIT_ECHO; - break; - case 1: - m->mdmreg[REG_ECHO] |= BIT_ECHO; - break; - default: - PARSE_ERROR; - } + isdn_tty_off_hook(); break; - case 'H': - /* H - On/Off-hook */ + default: + isdn_tty_on_hook(info); + break; + } + break; + case 'I': + /* I - Information */ + p++; + isdn_tty_at_cout("\r\nLinux ISDN", info); + switch (*p) { + case '0': + case '1': p++; - switch (*p) { - case '0': - p++; - isdn_tty_on_hook(info); - break; - case '1': - p++; - isdn_tty_off_hook(); - break; - default: - isdn_tty_on_hook(info); - break; - } break; - case 'I': - /* I - Information */ + case '2': p++; - isdn_tty_at_cout("\r\nLinux ISDN", info); - switch (*p) { - case '0': - case '1': - p++; - break; - case '2': - p++; - isdn_tty_report(info); - break; - case '3': - p++; - snprintf(ds, sizeof(ds), "\r\n%d", info->emu.charge); - isdn_tty_at_cout(ds, info); - break; - default:; - } + isdn_tty_report(info); break; -#ifdef DUMMY_HAYES_AT - case 'L': - case 'M': - /* only for be compilant with common scripts */ - /* no function */ + case '3': p++; - isdn_getnum(&p); + snprintf(ds, sizeof(ds), "\r\n%d", info->emu.charge); + isdn_tty_at_cout(ds, info); break; + default:; + } + break; +#ifdef DUMMY_HAYES_AT + case 'L': + case 'M': + /* only for be compilant with common scripts */ + /* no function */ + p++; + isdn_getnum(&p); + break; #endif - case 'O': - /* O - Go online */ - p++; - if (info->msr & UART_MSR_DCD) - /* if B-Channel is up */ - isdn_tty_modem_result((m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) ? RESULT_CONNECT:RESULT_CONNECT64000, info); - else - isdn_tty_modem_result(RESULT_NO_CARRIER, info); + case 'O': + /* O - Go online */ + p++; + if (info->msr & UART_MSR_DCD) + /* if B-Channel is up */ + isdn_tty_modem_result((m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) ? RESULT_CONNECT : RESULT_CONNECT64000, info); + else + isdn_tty_modem_result(RESULT_NO_CARRIER, info); + return; + case 'Q': + /* Q - Turn Emulator messages on/off */ + p++; + switch (isdn_getnum(&p)) { + case 0: + m->mdmreg[REG_RESP] |= BIT_RESP; + break; + case 1: + m->mdmreg[REG_RESP] &= ~BIT_RESP; + break; + default: + PARSE_ERROR; + } + break; + case 'S': + /* S - Set/Get Register */ + p++; + if (isdn_tty_cmd_ATS(&p, info)) return; - case 'Q': - /* Q - Turn Emulator messages on/off */ - p++; - switch (isdn_getnum(&p)) { - case 0: - m->mdmreg[REG_RESP] |= BIT_RESP; - break; - case 1: - m->mdmreg[REG_RESP] &= ~BIT_RESP; - break; - default: - PARSE_ERROR; - } + break; + case 'V': + /* V - Numeric or ASCII Emulator-messages */ + p++; + switch (isdn_getnum(&p)) { + case 0: + m->mdmreg[REG_RESP] |= BIT_RESPNUM; + break; + case 1: + m->mdmreg[REG_RESP] &= ~BIT_RESPNUM; break; - case 'S': - /* S - Set/Get Register */ + default: + PARSE_ERROR; + } + break; + case 'Z': + /* Z - Load Registers from Profile */ + p++; + if (info->msr & UART_MSR_DCD) { + info->online = 0; + isdn_tty_on_hook(info); + } + isdn_tty_modem_reset_regs(info, 1); + break; + case '+': + p++; + switch (*p) { +#ifdef CONFIG_ISDN_AUDIO + case 'F': p++; - if (isdn_tty_cmd_ATS(&p, info)) + if (isdn_tty_cmd_PLUSF(&p, info)) return; break; case 'V': - /* V - Numeric or ASCII Emulator-messages */ + if ((!(m->mdmreg[REG_SI1] & 1)) || + (m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM)) + PARSE_ERROR; p++; - switch (isdn_getnum(&p)) { - case 0: - m->mdmreg[REG_RESP] |= BIT_RESPNUM; - break; - case 1: - m->mdmreg[REG_RESP] &= ~BIT_RESPNUM; - break; - default: - PARSE_ERROR; - } + if (isdn_tty_cmd_PLUSV(&p, info)) + return; break; - case 'Z': - /* Z - Load Registers from Profile */ +#endif /* CONFIG_ISDN_AUDIO */ + case 'S': /* SUSPEND */ p++; - if (info->msr & UART_MSR_DCD) { - info->online = 0; - isdn_tty_on_hook(info); - } - isdn_tty_modem_reset_regs(info, 1); + isdn_tty_get_msnstr(ds, &p); + isdn_tty_suspend(ds, info, m); break; - case '+': + case 'R': /* RESUME */ p++; - switch (*p) { -#ifdef CONFIG_ISDN_AUDIO - case 'F': - p++; - if (isdn_tty_cmd_PLUSF(&p, info)) - return; - break; - case 'V': - if ((!(m->mdmreg[REG_SI1] & 1)) || - (m->mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM)) - PARSE_ERROR; - p++; - if (isdn_tty_cmd_PLUSV(&p, info)) - return; - break; -#endif /* CONFIG_ISDN_AUDIO */ - case 'S': /* SUSPEND */ - p++; - isdn_tty_get_msnstr(ds, &p); - isdn_tty_suspend(ds, info, m); - break; - case 'R': /* RESUME */ - p++; - isdn_tty_get_msnstr(ds, &p); - isdn_tty_resume(ds, info, m); - break; - case 'M': /* MESSAGE */ - p++; - isdn_tty_send_msg(info, m, p); - break; - default: - PARSE_ERROR; - } + isdn_tty_get_msnstr(ds, &p); + isdn_tty_resume(ds, info, m); break; - case '&': + case 'M': /* MESSAGE */ p++; - if (isdn_tty_cmd_ATand(&p, info)) - return; + isdn_tty_send_msg(info, m, p); break; default: PARSE_ERROR; + } + break; + case '&': + p++; + if (isdn_tty_cmd_ATand(&p, info)) + return; + break; + default: + PARSE_ERROR; } } #ifdef CONFIG_ISDN_AUDIO @@ -3714,7 +3714,7 @@ isdn_tty_parse_at(modem_info * info) /* Need own toupper() because standard-toupper is not available * within modules. */ -#define my_toupper(c) (((c>='a')&&(c<='z'))?(c&0xdf):c) +#define my_toupper(c) (((c >= 'a') && (c <= 'z')) ? (c & 0xdf) : c) /* * Perform line-editing of AT-commands @@ -3725,7 +3725,7 @@ isdn_tty_parse_at(modem_info * info) * channel index to line (minor-device) */ static int -isdn_tty_edit_at(const char *p, int count, modem_info * info) +isdn_tty_edit_at(const char *p, int count, modem_info *info) { atemu *m = &info->emu; int total = 0; @@ -3768,23 +3768,23 @@ isdn_tty_edit_at(const char *p, int count, modem_info * info) if (m->mdmcmdl < 255) { c = my_toupper(c); switch (m->mdmcmdl) { - case 1: - if (c == 'T') { - m->mdmcmd[m->mdmcmdl] = c; - m->mdmcmd[++m->mdmcmdl] = 0; - break; - } else - m->mdmcmdl = 0; - /* Fall through, check for 'A' */ - case 0: - if (c == 'A') { - m->mdmcmd[m->mdmcmdl] = c; - m->mdmcmd[++m->mdmcmdl] = 0; - } + case 1: + if (c == 'T') { + m->mdmcmd[m->mdmcmdl] = c; + m->mdmcmd[++m->mdmcmdl] = 0; break; - default: + } else + m->mdmcmdl = 0; + /* Fall through, check for 'A' */ + case 0: + if (c == 'A') { m->mdmcmd[m->mdmcmdl] = c; m->mdmcmd[++m->mdmcmdl] = 0; + } + break; + default: + m->mdmcmd[m->mdmcmdl] = c; + m->mdmcmd[++m->mdmcmdl] = 0; } } } diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 692c74d6b749..a6f801d2263b 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -93,11 +93,11 @@ #define RESULT_VCON 11 #define RESULT_RUNG 12 -#define TTY_IS_FCLASS1(info) \ - ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ +#define TTY_IS_FCLASS1(info) \ + ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS1)) -#define TTY_IS_FCLASS2(info) \ - ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ +#define TTY_IS_FCLASS2(info) \ + ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) extern void isdn_tty_modem_escape(void); @@ -110,7 +110,7 @@ extern void isdn_tty_readmodem(void); extern int isdn_tty_find_icall(int, int, setup_parm *); extern int isdn_tty_stat_callback(int, isdn_ctrl *); extern int isdn_tty_rcv_skb(int, int, int, struct sk_buff *); -extern int isdn_tty_capi_facility(capi_msg *cm); +extern int isdn_tty_capi_facility(capi_msg *cm); extern void isdn_tty_at_cout(char *, modem_info *); extern void isdn_tty_modem_hup(modem_info *, int); #ifdef CONFIG_ISDN_TTY_FAX diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c index 4c41f191d4e2..47aae4916730 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.c +++ b/drivers/isdn/i4l/isdn_ttyfax.c @@ -45,7 +45,7 @@ isdn_getrev(const char *revision) */ static void -isdn_tty_fax_modem_result(int code, modem_info * info) +isdn_tty_fax_modem_result(int code, modem_info *info) { atemu *m = &info->emu; T30_s *f = info->fax; @@ -54,9 +54,9 @@ isdn_tty_fax_modem_result(int code, modem_info * info) char *rp; int i; static char *msg[] = - {"OK", "ERROR", "+FCON", "+FCSI:", "+FDIS:", - "+FHNG:", "+FDCS:", "CONNECT", "+FTSI:", - "+FCFR", "+FPTS:", "+FET:"}; + {"OK", "ERROR", "+FCON", "+FCSI:", "+FDIS:", + "+FHNG:", "+FDCS:", "CONNECT", "+FTSI:", + "+FCFR", "+FPTS:", "+FET:"}; isdn_tty_at_cout("\r\n", info); @@ -64,95 +64,95 @@ isdn_tty_fax_modem_result(int code, modem_info * info) #ifdef ISDN_TTY_FAX_CMD_DEBUG printk(KERN_DEBUG "isdn_tty: Fax send %s on ttyI%d\n", - msg[code], info->line); + msg[code], info->line); #endif switch (code) { - case 0: /* OK */ - break; - case 1: /* ERROR */ - break; - case 2: /* +FCON */ - /* Append CPN, if enabled */ - if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) && - (!(dev->usage[info->isdn_channel] & ISDN_USAGE_OUTGOING))) { - sprintf(rs, "/%s", m->cpn); - isdn_tty_at_cout(rs, info); - } - info->online = 1; - f->fet = 0; - if (f->phase == ISDN_FAX_PHASE_A) - f->phase = ISDN_FAX_PHASE_B; - break; - case 3: /* +FCSI */ - case 8: /* +FTSI */ - sprintf(rs, "\"%s\"", f->r_id); - isdn_tty_at_cout(rs, info); - break; - case 4: /* +FDIS */ - rs[0] = 0; - rp = &f->r_resolution; - for (i = 0; i < 8; i++) { - sprintf(rss, "%c%s", rp[i] + 48, - (i < 7) ? "," : ""); - strcat(rs, rss); - } + case 0: /* OK */ + break; + case 1: /* ERROR */ + break; + case 2: /* +FCON */ + /* Append CPN, if enabled */ + if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) && + (!(dev->usage[info->isdn_channel] & ISDN_USAGE_OUTGOING))) { + sprintf(rs, "/%s", m->cpn); isdn_tty_at_cout(rs, info); + } + info->online = 1; + f->fet = 0; + if (f->phase == ISDN_FAX_PHASE_A) + f->phase = ISDN_FAX_PHASE_B; + break; + case 3: /* +FCSI */ + case 8: /* +FTSI */ + sprintf(rs, "\"%s\"", f->r_id); + isdn_tty_at_cout(rs, info); + break; + case 4: /* +FDIS */ + rs[0] = 0; + rp = &f->r_resolution; + for (i = 0; i < 8; i++) { + sprintf(rss, "%c%s", rp[i] + 48, + (i < 7) ? "," : ""); + strcat(rs, rss); + } + isdn_tty_at_cout(rs, info); #ifdef ISDN_TTY_FAX_CMD_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax DIS=%s on ttyI%d\n", - rs, info->line); + printk(KERN_DEBUG "isdn_tty: Fax DIS=%s on ttyI%d\n", + rs, info->line); #endif - break; - case 5: /* +FHNG */ - sprintf(rs, "%d", f->code); - isdn_tty_at_cout(rs, info); - info->faxonline = 0; - break; - case 6: /* +FDCS */ - rs[0] = 0; - rp = &f->r_resolution; - for (i = 0; i < 8; i++) { - sprintf(rss, "%c%s", rp[i] + 48, - (i < 7) ? "," : ""); - strcat(rs, rss); - } - isdn_tty_at_cout(rs, info); + break; + case 5: /* +FHNG */ + sprintf(rs, "%d", f->code); + isdn_tty_at_cout(rs, info); + info->faxonline = 0; + break; + case 6: /* +FDCS */ + rs[0] = 0; + rp = &f->r_resolution; + for (i = 0; i < 8; i++) { + sprintf(rss, "%c%s", rp[i] + 48, + (i < 7) ? "," : ""); + strcat(rs, rss); + } + isdn_tty_at_cout(rs, info); #ifdef ISDN_TTY_FAX_CMD_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax DCS=%s on ttyI%d\n", - rs, info->line); + printk(KERN_DEBUG "isdn_tty: Fax DCS=%s on ttyI%d\n", + rs, info->line); #endif - break; - case 7: /* CONNECT */ - info->faxonline |= 2; - break; - case 9: /* FCFR */ - break; - case 10: /* FPTS */ - isdn_tty_at_cout("1", info); - break; - case 11: /* FET */ - sprintf(rs, "%d", f->fet); - isdn_tty_at_cout(rs, info); - break; + break; + case 7: /* CONNECT */ + info->faxonline |= 2; + break; + case 9: /* FCFR */ + break; + case 10: /* FPTS */ + isdn_tty_at_cout("1", info); + break; + case 11: /* FET */ + sprintf(rs, "%d", f->fet); + isdn_tty_at_cout(rs, info); + break; } isdn_tty_at_cout("\r\n", info); switch (code) { - case 7: /* CONNECT */ - info->online = 2; - if (info->faxonline & 1) { - sprintf(rs, "%c", XON); - isdn_tty_at_cout(rs, info); - } - break; + case 7: /* CONNECT */ + info->online = 2; + if (info->faxonline & 1) { + sprintf(rs, "%c", XON); + isdn_tty_at_cout(rs, info); + } + break; } } static int -isdn_tty_fax_command1(modem_info * info, isdn_ctrl * c) +isdn_tty_fax_command1(modem_info *info, isdn_ctrl *c) { static char *msg[] = - {"OK", "CONNECT", "NO CARRIER", "ERROR", "FCERROR"}; + {"OK", "CONNECT", "NO CARRIER", "ERROR", "FCERROR"}; #ifdef ISDN_TTY_FAX_CMD_DEBUG printk(KERN_DEBUG "isdn_tty: FCLASS1 cmd(%d)\n", c->parm.aux.cmd); @@ -165,30 +165,30 @@ isdn_tty_fax_command1(modem_info * info, isdn_ctrl * c) isdn_tty_at_cout("\r\n", info); } switch (c->parm.aux.cmd) { - case ISDN_FAX_CLASS1_CONNECT: - info->online = 2; - break; - case ISDN_FAX_CLASS1_OK: - case ISDN_FAX_CLASS1_FCERROR: - case ISDN_FAX_CLASS1_ERROR: - case ISDN_FAX_CLASS1_NOCARR: - break; - case ISDN_FAX_CLASS1_QUERY: + case ISDN_FAX_CLASS1_CONNECT: + info->online = 2; + break; + case ISDN_FAX_CLASS1_OK: + case ISDN_FAX_CLASS1_FCERROR: + case ISDN_FAX_CLASS1_ERROR: + case ISDN_FAX_CLASS1_NOCARR: + break; + case ISDN_FAX_CLASS1_QUERY: + isdn_tty_at_cout("\r\n", info); + if (!c->parm.aux.para[0]) { + isdn_tty_at_cout(msg[ISDN_FAX_CLASS1_ERROR], info); isdn_tty_at_cout("\r\n", info); - if (!c->parm.aux.para[0]) { - isdn_tty_at_cout(msg[ISDN_FAX_CLASS1_ERROR], info); - isdn_tty_at_cout("\r\n", info); - } else { - isdn_tty_at_cout(c->parm.aux.para, info); - isdn_tty_at_cout("\r\nOK\r\n", info); - } - break; + } else { + isdn_tty_at_cout(c->parm.aux.para, info); + isdn_tty_at_cout("\r\nOK\r\n", info); + } + break; } return (0); } int -isdn_tty_fax_command(modem_info * info, isdn_ctrl * c) +isdn_tty_fax_command(modem_info *info, isdn_ctrl *c) { T30_s *f = info->fax; char rs[10]; @@ -201,78 +201,78 @@ isdn_tty_fax_command(modem_info * info, isdn_ctrl * c) f->r_code, info->line); #endif switch (f->r_code) { - case ISDN_TTY_FAX_FCON: - info->faxonline = 1; - isdn_tty_fax_modem_result(2, info); /* +FCON */ - return (0); - case ISDN_TTY_FAX_FCON_I: - info->faxonline = 16; - isdn_tty_fax_modem_result(2, info); /* +FCON */ - return (0); - case ISDN_TTY_FAX_RID: - if (info->faxonline & 1) - isdn_tty_fax_modem_result(3, info); /* +FCSI */ - if (info->faxonline & 16) - isdn_tty_fax_modem_result(8, info); /* +FTSI */ - return (0); - case ISDN_TTY_FAX_DIS: - isdn_tty_fax_modem_result(4, info); /* +FDIS */ - return (0); - case ISDN_TTY_FAX_HNG: - if (f->phase == ISDN_FAX_PHASE_C) { - if (f->direction == ISDN_TTY_FAX_CONN_IN) { - sprintf(rs, "%c%c", DLE, ETX); - isdn_tty_at_cout(rs, info); - } else { - sprintf(rs, "%c", 0x18); - isdn_tty_at_cout(rs, info); - } - info->faxonline &= ~2; /* leave data mode */ - info->online = 1; - } - f->phase = ISDN_FAX_PHASE_E; - isdn_tty_fax_modem_result(5, info); /* +FHNG */ - isdn_tty_fax_modem_result(0, info); /* OK */ - return (0); - case ISDN_TTY_FAX_DCS: - isdn_tty_fax_modem_result(6, info); /* +FDCS */ - isdn_tty_fax_modem_result(7, info); /* CONNECT */ - f->phase = ISDN_FAX_PHASE_C; - return (0); - case ISDN_TTY_FAX_TRAIN_OK: - isdn_tty_fax_modem_result(6, info); /* +FDCS */ - isdn_tty_fax_modem_result(0, info); /* OK */ - return (0); - case ISDN_TTY_FAX_SENT: - isdn_tty_fax_modem_result(0, info); /* OK */ - return (0); - case ISDN_TTY_FAX_CFR: - isdn_tty_fax_modem_result(9, info); /* +FCFR */ - return (0); - case ISDN_TTY_FAX_ET: - sprintf(rs, "%c%c", DLE, ETX); - isdn_tty_at_cout(rs, info); - isdn_tty_fax_modem_result(10, info); /* +FPTS */ - isdn_tty_fax_modem_result(11, info); /* +FET */ - isdn_tty_fax_modem_result(0, info); /* OK */ - info->faxonline &= ~2; /* leave data mode */ - info->online = 1; - f->phase = ISDN_FAX_PHASE_D; - return (0); - case ISDN_TTY_FAX_PTS: - isdn_tty_fax_modem_result(10, info); /* +FPTS */ - if (f->direction == ISDN_TTY_FAX_CONN_OUT) { - if (f->fet == 1) - f->phase = ISDN_FAX_PHASE_B; - if (f->fet == 0) - isdn_tty_fax_modem_result(0, info); /* OK */ + case ISDN_TTY_FAX_FCON: + info->faxonline = 1; + isdn_tty_fax_modem_result(2, info); /* +FCON */ + return (0); + case ISDN_TTY_FAX_FCON_I: + info->faxonline = 16; + isdn_tty_fax_modem_result(2, info); /* +FCON */ + return (0); + case ISDN_TTY_FAX_RID: + if (info->faxonline & 1) + isdn_tty_fax_modem_result(3, info); /* +FCSI */ + if (info->faxonline & 16) + isdn_tty_fax_modem_result(8, info); /* +FTSI */ + return (0); + case ISDN_TTY_FAX_DIS: + isdn_tty_fax_modem_result(4, info); /* +FDIS */ + return (0); + case ISDN_TTY_FAX_HNG: + if (f->phase == ISDN_FAX_PHASE_C) { + if (f->direction == ISDN_TTY_FAX_CONN_IN) { + sprintf(rs, "%c%c", DLE, ETX); + isdn_tty_at_cout(rs, info); + } else { + sprintf(rs, "%c", 0x18); + isdn_tty_at_cout(rs, info); } - return (0); - case ISDN_TTY_FAX_EOP: info->faxonline &= ~2; /* leave data mode */ info->online = 1; - f->phase = ISDN_FAX_PHASE_D; - return (0); + } + f->phase = ISDN_FAX_PHASE_E; + isdn_tty_fax_modem_result(5, info); /* +FHNG */ + isdn_tty_fax_modem_result(0, info); /* OK */ + return (0); + case ISDN_TTY_FAX_DCS: + isdn_tty_fax_modem_result(6, info); /* +FDCS */ + isdn_tty_fax_modem_result(7, info); /* CONNECT */ + f->phase = ISDN_FAX_PHASE_C; + return (0); + case ISDN_TTY_FAX_TRAIN_OK: + isdn_tty_fax_modem_result(6, info); /* +FDCS */ + isdn_tty_fax_modem_result(0, info); /* OK */ + return (0); + case ISDN_TTY_FAX_SENT: + isdn_tty_fax_modem_result(0, info); /* OK */ + return (0); + case ISDN_TTY_FAX_CFR: + isdn_tty_fax_modem_result(9, info); /* +FCFR */ + return (0); + case ISDN_TTY_FAX_ET: + sprintf(rs, "%c%c", DLE, ETX); + isdn_tty_at_cout(rs, info); + isdn_tty_fax_modem_result(10, info); /* +FPTS */ + isdn_tty_fax_modem_result(11, info); /* +FET */ + isdn_tty_fax_modem_result(0, info); /* OK */ + info->faxonline &= ~2; /* leave data mode */ + info->online = 1; + f->phase = ISDN_FAX_PHASE_D; + return (0); + case ISDN_TTY_FAX_PTS: + isdn_tty_fax_modem_result(10, info); /* +FPTS */ + if (f->direction == ISDN_TTY_FAX_CONN_OUT) { + if (f->fet == 1) + f->phase = ISDN_FAX_PHASE_B; + if (f->fet == 0) + isdn_tty_fax_modem_result(0, info); /* OK */ + } + return (0); + case ISDN_TTY_FAX_EOP: + info->faxonline &= ~2; /* leave data mode */ + info->online = 1; + f->phase = ISDN_FAX_PHASE_D; + return (0); } return (-1); @@ -280,7 +280,7 @@ isdn_tty_fax_command(modem_info * info, isdn_ctrl * c) void -isdn_tty_fax_bitorder(modem_info * info, struct sk_buff *skb) +isdn_tty_fax_bitorder(modem_info *info, struct sk_buff *skb) { __u8 LeftMask; __u8 RightMask; @@ -292,10 +292,10 @@ isdn_tty_fax_bitorder(modem_info * info, struct sk_buff *skb) for (i = 0; i < skb->len; i++) { Data = skb->data[i]; for ( - LeftMask = 0x80, RightMask = 0x01; - LeftMask > RightMask; - LeftMask >>= 1, RightMask <<= 1 - ) { + LeftMask = 0x80, RightMask = 0x01; + LeftMask > RightMask; + LeftMask >>= 1, RightMask <<= 1 + ) { fBit = (Data & LeftMask); if (Data & RightMask) Data |= LeftMask; @@ -317,10 +317,10 @@ isdn_tty_fax_bitorder(modem_info * info, struct sk_buff *skb) */ static int -isdn_tty_cmd_FCLASS1(char **p, modem_info * info) +isdn_tty_cmd_FCLASS1(char **p, modem_info *info) { static char *cmd[] = - {"AE", "TS", "RS", "TM", "RM", "TH", "RH"}; + {"AE", "TS", "RS", "TM", "RM", "TH", "RH"}; isdn_ctrl c; int par, i; u_long flags; @@ -337,28 +337,28 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) p[0] += 2; switch (*p[0]) { - case '?': - p[0]++; - c.parm.aux.subcmd = AT_QUERY; - break; - case '=': + case '?': + p[0]++; + c.parm.aux.subcmd = AT_QUERY; + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - if (*p[0] == '?') { - p[0]++; - c.parm.aux.subcmd = AT_EQ_QUERY; - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 255)) - PARSE_ERROR1; - c.parm.aux.subcmd = AT_EQ_VALUE; - c.parm.aux.para[0] = par; - } - break; - case 0: - c.parm.aux.subcmd = AT_COMMAND; - break; - default: - PARSE_ERROR1; + c.parm.aux.subcmd = AT_EQ_QUERY; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 255)) + PARSE_ERROR1; + c.parm.aux.subcmd = AT_EQ_VALUE; + c.parm.aux.para[0] = par; + } + break; + case 0: + c.parm.aux.subcmd = AT_COMMAND; + break; + default: + PARSE_ERROR1; } c.command = ISDN_CMD_FAXCMD; #ifdef ISDN_TTY_FAX_CMD_DEBUG @@ -409,7 +409,7 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) */ static int -isdn_tty_cmd_FCLASS2(char **p, modem_info * info) +isdn_tty_cmd_FCLASS2(char **p, modem_info *info) { atemu *m = &info->emu; T30_s *f = info->fax; @@ -418,25 +418,25 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) char rs[50]; char rss[50]; int maxdccval[] = - {1, 5, 2, 2, 3, 2, 0, 7}; + {1, 5, 2, 2, 3, 2, 0, 7}; /* FAA still unchanged */ if (!strncmp(p[0], "AA", 2)) { /* TODO */ p[0] += 2; switch (*p[0]) { - case '?': - p[0]++; - sprintf(rs, "\r\n%d", 0); - isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - par = isdn_getnum(p); - if ((par < 0) || (par > 255)) - PARSE_ERROR1; - break; - default: + case '?': + p[0]++; + sprintf(rs, "\r\n%d", 0); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + par = isdn_getnum(p); + if ((par < 0) || (par > 255)) PARSE_ERROR1; + break; + default: + PARSE_ERROR1; } return 0; } @@ -444,29 +444,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "BADLIN", 6)) { p[0] += 6; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->badlin); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->badlin); + sprintf(rs, "\r\n0-255"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0-255"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 255)) - PARSE_ERROR1; - f->badlin = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 255)) + PARSE_ERROR1; + f->badlin = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FBADLIN=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FBADLIN=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -474,29 +474,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "BADMUL", 6)) { p[0] += 6; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->badmul); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->badmul); + sprintf(rs, "\r\n0-255"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0-255"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 255)) - PARSE_ERROR1; - f->badmul = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 255)) + PARSE_ERROR1; + f->badmul = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FBADMUL=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FBADMUL=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -504,29 +504,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "BOR", 3)) { p[0] += 3; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->bor); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->bor); + sprintf(rs, "\r\n0,1"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0,1"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 1)) - PARSE_ERROR1; - f->bor = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 1)) + PARSE_ERROR1; + f->bor = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FBOR=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FBOR=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -534,29 +534,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "NBC", 3)) { p[0] += 3; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->nbc); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->nbc); + sprintf(rs, "\r\n0,1"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0,1"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 1)) - PARSE_ERROR1; - f->nbc = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 1)) + PARSE_ERROR1; + f->nbc = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FNBC=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FNBC=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -576,36 +576,36 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) int i, r; p[0] += 3; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n\"%s\"", f->pollid); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n\"%s\"", f->pollid); + sprintf(rs, "\r\n\"STRING\""); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { + } else { + if (*p[0] == '"') p[0]++; - sprintf(rs, "\r\n\"STRING\""); - isdn_tty_at_cout(rs, info); - } else { - if (*p[0] == '"') - p[0]++; - for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { - f->pollid[i] = *p[0]++; - } - if (*p[0] == '"') - p[0]++; - for (r = i; r < FAXIDLEN; r++) { - f->pollid[r] = 32; - } - f->pollid[FAXIDLEN - 1] = 0; + for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { + f->pollid[i] = *p[0]++; + } + if (*p[0] == '"') + p[0]++; + for (r = i; r < FAXIDLEN; r++) { + f->pollid[r] = 32; + } + f->pollid[FAXIDLEN - 1] = 0; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax local poll ID rx \"%s\"\n", f->pollid); + printk(KERN_DEBUG "isdn_tty: Fax local poll ID rx \"%s\"\n", f->pollid); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -613,29 +613,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "CQ", 2)) { p[0] += 2; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->cq); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->cq); + sprintf(rs, "\r\n0,1,2"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0,1,2"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 2)) - PARSE_ERROR1; - f->cq = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 2)) + PARSE_ERROR1; + f->cq = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FCQ=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FCQ=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -643,29 +643,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "CR", 2)) { p[0] += 2; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->cr); /* read actual value from struct and print */ + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->cr); /* read actual value from struct and print */ + sprintf(rs, "\r\n0,1"); /* display online help */ isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0,1"); /* display online help */ - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 1)) - PARSE_ERROR1; - f->cr = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 1)) + PARSE_ERROR1; + f->cr = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FCR=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FCR=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -673,29 +673,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "CTCRTY", 6)) { p[0] += 6; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->ctcrty); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->ctcrty); + sprintf(rs, "\r\n0-255"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0-255"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 255)) - PARSE_ERROR1; - f->ctcrty = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 255)) + PARSE_ERROR1; + f->ctcrty = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FCTCRTY=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FCTCRTY=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -706,42 +706,42 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) p[0] += 3; switch (*p[0]) { - case '?': - p[0]++; - strcpy(rs, "\r\n"); - for (i = 0; i < 8; i++) { - sprintf(rss, "%c%s", rp[i] + 48, - (i < 7) ? "," : ""); - strcat(rs, rss); - } - isdn_tty_at_cout(rs, info); - break; - case '=': + case '?': + p[0]++; + strcpy(rs, "\r\n"); + for (i = 0; i < 8; i++) { + sprintf(rss, "%c%s", rp[i] + 48, + (i < 7) ? "," : ""); + strcat(rs, rss); + } + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { + isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info); p[0]++; - if (*p[0] == '?') { - isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info); - p[0]++; - } else { - for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { - if (*p[0] != ',') { - if ((*p[0] - 48) > maxdccval[i]) { - PARSE_ERROR1; - } - rp[i] = *p[0] - 48; - p[0]++; - if (*p[0] == ',') - p[0]++; - } else + } else { + for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { + if (*p[0] != ',') { + if ((*p[0] - 48) > maxdccval[i]) { + PARSE_ERROR1; + } + rp[i] = *p[0] - 48; + p[0]++; + if (*p[0] == ',') p[0]++; - } + } else + p[0]++; + } #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FDCC capabilities DCE=%d,%d,%d,%d,%d,%d,%d,%d\n", - rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]); + printk(KERN_DEBUG "isdn_tty: Fax FDCC capabilities DCE=%d,%d,%d,%d,%d,%d,%d,%d\n", + rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -752,42 +752,42 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) p[0] += 3; switch (*p[0]) { - case '?': - p[0]++; - strcpy(rs, "\r\n"); - for (i = 0; i < 8; i++) { - sprintf(rss, "%c%s", rp[i] + 48, - (i < 7) ? "," : ""); - strcat(rs, rss); - } - isdn_tty_at_cout(rs, info); - break; - case '=': + case '?': + p[0]++; + strcpy(rs, "\r\n"); + for (i = 0; i < 8; i++) { + sprintf(rss, "%c%s", rp[i] + 48, + (i < 7) ? "," : ""); + strcat(rs, rss); + } + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { + isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info); p[0]++; - if (*p[0] == '?') { - isdn_tty_at_cout("\r\n(0,1),(0-5),(0-2),(0-2),(0-3),(0-2),(0),(0-7)", info); - p[0]++; - } else { - for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { - if (*p[0] != ',') { - if ((*p[0] - 48) > maxdccval[i]) { - PARSE_ERROR1; - } - rp[i] = *p[0] - 48; - p[0]++; - if (*p[0] == ',') - p[0]++; - } else + } else { + for (i = 0; (((*p[0] >= '0') && (*p[0] <= '9')) || (*p[0] == ',')) && (i < 8); i++) { + if (*p[0] != ',') { + if ((*p[0] - 48) > maxdccval[i]) { + PARSE_ERROR1; + } + rp[i] = *p[0] - 48; + p[0]++; + if (*p[0] == ',') p[0]++; - } + } else + p[0]++; + } #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FDIS session parms=%d,%d,%d,%d,%d,%d,%d,%d\n", - rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]); + printk(KERN_DEBUG "isdn_tty: Fax FDIS session parms=%d,%d,%d,%d,%d,%d,%d,%d\n", + rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7]); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -808,18 +808,18 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) f->phase = ISDN_FAX_PHASE_C; } else if (f->phase == ISDN_FAX_PHASE_D) { switch (f->fet) { - case 0: /* next page will be received */ - f->phase = ISDN_FAX_PHASE_C; - isdn_tty_fax_modem_result(7, info); /* CONNECT */ - break; - case 1: /* next doc will be received */ - f->phase = ISDN_FAX_PHASE_B; - break; - case 2: /* fax session is terminating */ - f->phase = ISDN_FAX_PHASE_E; - break; - default: - PARSE_ERROR1; + case 0: /* next page will be received */ + f->phase = ISDN_FAX_PHASE_C; + isdn_tty_fax_modem_result(7, info); /* CONNECT */ + break; + case 1: /* next doc will be received */ + f->phase = ISDN_FAX_PHASE_B; + break; + case 2: /* fax session is terminating */ + f->phase = ISDN_FAX_PHASE_E; + break; + default: + PARSE_ERROR1; } } } else { @@ -830,7 +830,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) /* DT=df,vr,wd,ln - TX phase C data command (release DCE to proceed with negotiation) */ if (!strncmp(p[0], "DT", 2)) { int i, val[] = - {4, 0, 2, 3}; + {4, 0, 2, 3}; char *rp = &f->resolution; p[0] += 2; @@ -872,29 +872,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "ECM", 3)) { p[0] += 3; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->ecm); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->ecm); + sprintf(rs, "\r\n0,2"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0,2"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par != 0) && (par != 2)) - PARSE_ERROR1; - f->ecm = par; + } else { + par = isdn_getnum(p); + if ((par != 0) && (par != 2)) + PARSE_ERROR1; + f->ecm = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FECM=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FECM=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -938,36 +938,36 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) int i, r; p[0] += 3; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n\"%s\"", f->id); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n\"%s\"", f->id); + sprintf(rs, "\r\n\"STRING\""); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { + } else { + if (*p[0] == '"') p[0]++; - sprintf(rs, "\r\n\"STRING\""); - isdn_tty_at_cout(rs, info); - } else { - if (*p[0] == '"') - p[0]++; - for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { - f->id[i] = *p[0]++; - } - if (*p[0] == '"') - p[0]++; - for (r = i; r < FAXIDLEN; r++) { - f->id[r] = 32; - } - f->id[FAXIDLEN - 1] = 0; + for (i = 0; (*p[0]) && i < (FAXIDLEN - 1) && (*p[0] != '"'); i++) { + f->id[i] = *p[0]++; + } + if (*p[0] == '"') + p[0]++; + for (r = i; r < FAXIDLEN; r++) { + f->id[r] = 32; + } + f->id[FAXIDLEN - 1] = 0; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax local ID \"%s\"\n", f->id); + printk(KERN_DEBUG "isdn_tty: Fax local ID \"%s\"\n", f->id); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -994,29 +994,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "MINSP", 5)) { p[0] += 5; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->minsp); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->minsp); + sprintf(rs, "\r\n0-5"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0-5"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 5)) - PARSE_ERROR1; - f->minsp = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 5)) + PARSE_ERROR1; + f->minsp = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FMINSP=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FMINSP=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -1024,29 +1024,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "PHCTO", 5)) { p[0] += 5; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->phcto); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->phcto); + sprintf(rs, "\r\n0-255"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0-255"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 255)) - PARSE_ERROR1; - f->phcto = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 255)) + PARSE_ERROR1; + f->phcto = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FPHCTO=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FPHCTO=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -1055,29 +1055,29 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) if (!strncmp(p[0], "REL", 3)) { p[0] += 3; switch (*p[0]) { - case '?': + case '?': + p[0]++; + sprintf(rs, "\r\n%d", f->rel); + isdn_tty_at_cout(rs, info); + break; + case '=': + p[0]++; + if (*p[0] == '?') { p[0]++; - sprintf(rs, "\r\n%d", f->rel); + sprintf(rs, "\r\n0,1"); isdn_tty_at_cout(rs, info); - break; - case '=': - p[0]++; - if (*p[0] == '?') { - p[0]++; - sprintf(rs, "\r\n0,1"); - isdn_tty_at_cout(rs, info); - } else { - par = isdn_getnum(p); - if ((par < 0) || (par > 1)) - PARSE_ERROR1; - f->rel = par; + } else { + par = isdn_getnum(p); + if ((par < 0) || (par > 1)) + PARSE_ERROR1; + f->rel = par; #ifdef ISDN_TTY_FAX_STAT_DEBUG - printk(KERN_DEBUG "isdn_tty: Fax FREL=%d\n", par); + printk(KERN_DEBUG "isdn_tty: Fax FREL=%d\n", par); #endif - } - break; - default: - PARSE_ERROR1; + } + break; + default: + PARSE_ERROR1; } return 0; } @@ -1100,11 +1100,11 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) printk(KERN_DEBUG "isdn_tty: Fax FTBC=%c\n", *p[0]); #endif switch (*p[0]) { - case '0': - p[0]++; - break; - default: - PARSE_ERROR1; + case '0': + p[0]++; + break; + default: + PARSE_ERROR1; } return 0; } @@ -1113,7 +1113,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info) } int -isdn_tty_cmd_PLUSF_FAX(char **p, modem_info * info) +isdn_tty_cmd_PLUSF_FAX(char **p, modem_info *info) { if (TTY_IS_FCLASS2(info)) return (isdn_tty_cmd_FCLASS2(p, info)); diff --git a/drivers/isdn/i4l/isdn_ttyfax.h b/drivers/isdn/i4l/isdn_ttyfax.h index 757a89010020..ccda4fcf8f7b 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.h +++ b/drivers/isdn/i4l/isdn_ttyfax.h @@ -15,4 +15,3 @@ #define XON 0x11 #define XOFF 0x13 #define DC2 0x12 - diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c index c5d02b6aafab..52827a80c51f 100644 --- a/drivers/isdn/i4l/isdn_v110.c +++ b/drivers/isdn/i4l/isdn_v110.c @@ -26,8 +26,8 @@ char *isdn_v110_revision = "$Revision: 1.1.2.2 $"; #define V110_19200 15 #define V110_9600 3 -/* - * The following data are precoded matrices, online and offline matrix +/* + * The following data are precoded matrices, online and offline matrix * for 9600, 19200 und 38400, respectively */ static unsigned char V110_OnMatrix_9600[] = @@ -56,7 +56,7 @@ static unsigned char V110_OnMatrix_38400[] = static unsigned char V110_OffMatrix_38400[] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff}; -/* +/* * FlipBits reorders sequences of keylen bits in one byte. * E.g. source order 7654321 will be converted to 45670123 when keylen = 4, * and to 67452301 when keylen = 2. This is necessary because ordering on @@ -103,18 +103,18 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize) v->decodelen = 0; switch (key) { - case V110_38400: - v->OnlineFrame = V110_OnMatrix_38400; - v->OfflineFrame = V110_OffMatrix_38400; - break; - case V110_19200: - v->OnlineFrame = V110_OnMatrix_19200; - v->OfflineFrame = V110_OffMatrix_19200; - break; - default: - v->OnlineFrame = V110_OnMatrix_9600; - v->OfflineFrame = V110_OffMatrix_9600; - break; + case V110_38400: + v->OnlineFrame = V110_OnMatrix_38400; + v->OfflineFrame = V110_OffMatrix_38400; + break; + case V110_19200: + v->OnlineFrame = V110_OnMatrix_19200; + v->OfflineFrame = V110_OffMatrix_19200; + break; + default: + v->OnlineFrame = V110_OnMatrix_9600; + v->OfflineFrame = V110_OffMatrix_9600; + break; } v->framelen = v->nbytes * 10; v->SyncInit = 5; @@ -132,7 +132,7 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize) /* isdn_v110_close frees private V.110 data structures */ void -isdn_v110_close(isdn_v110_stream * v) +isdn_v110_close(isdn_v110_stream *v) { if (v == NULL) return; @@ -144,11 +144,11 @@ isdn_v110_close(isdn_v110_stream * v) } -/* - * ValidHeaderBytes return the number of valid bytes in v->decodebuf +/* + * ValidHeaderBytes return the number of valid bytes in v->decodebuf */ static int -ValidHeaderBytes(isdn_v110_stream * v) +ValidHeaderBytes(isdn_v110_stream *v) { int i; for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++) @@ -157,11 +157,11 @@ ValidHeaderBytes(isdn_v110_stream * v) return i; } -/* - * SyncHeader moves the decodebuf ptr to the next valid header +/* + * SyncHeader moves the decodebuf ptr to the next valid header */ static void -SyncHeader(isdn_v110_stream * v) +SyncHeader(isdn_v110_stream *v) { unsigned char *rbuf = v->decodebuf; int len = v->decodelen; @@ -185,9 +185,9 @@ SyncHeader(isdn_v110_stream * v) only complete matices must be given. From these, netto data is extracted and returned in buf. The return-value is the bytecount of the decoded data. - */ +*/ static int -DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf) +DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf) { int line = 0; int buflen = 0; @@ -203,7 +203,7 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n"); /* returning now is not the right thing, though :-( */ #endif - } + } line++; /* next line of matrix */ continue; } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */ @@ -217,7 +217,7 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf continue; } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */ introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */ - next_byte: + next_byte: if (mbit > 2) { /* was it the last bit in this line ? */ mbit >>= 1; /* no -> take next */ continue; @@ -246,13 +246,13 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf return buflen; /* return number of bytes in the output buffer */ } -/* - * DecodeStream receives V.110 coded data from the input stream. It recovers the +/* + * DecodeStream receives V.110 coded data from the input stream. It recovers the * original frames. * The input stream doesn't need to be framed */ struct sk_buff * -isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb) +isdn_v110_decode(isdn_v110_stream *v, struct sk_buff *skb) { int i; int j; @@ -283,7 +283,7 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb) /* copy new data to decode-buffer */ memcpy(&(v->decodebuf[v->decodelen]), rbuf, len); v->decodelen += len; - ReSync: +ReSync: if (v->decodelen < v->nbytes) { /* got a new header ? */ dev_kfree_skb(skb); return NULL; /* no, try later */ @@ -320,7 +320,7 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb) /* EncodeMatrix takes input data in buf, len is the bytecount. Data is encoded into v110 frames in m. Return value is the number of matrix-lines generated. - */ +*/ static int EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) { @@ -333,14 +333,14 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) while ((i < len) && (line < mlen)) { /* while we still have input data */ switch (line % 10) { /* in which line of the matrix are we? */ - case 0: - m[line++] = 0x00; /* line 0 is always 0 */ - mbit = 128; /* go on with the 7th bit */ - break; - case 5: - m[line++] = 0xbf; /* line 5 is always 10111111 */ - mbit = 128; /* go on with the 7th bit */ - break; + case 0: + m[line++] = 0x00; /* line 0 is always 0 */ + mbit = 128; /* go on with the 7th bit */ + break; + case 5: + m[line++] = 0xbf; /* line 5 is always 10111111 */ + mbit = 128; /* go on with the 7th bit */ + break; } if (line >= mlen) { printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); @@ -348,16 +348,16 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) } next_bit: switch (mbit) { /* leftmost or rightmost bit ? */ - case 1: - line++; /* rightmost -> go to next line */ - if (line >= mlen) { - printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); - return line; - } - case 128: - m[line] = 128; /* leftmost -> set byte to 1000000 */ - mbit = 64; /* current bit in the matrix line */ - continue; + case 1: + line++; /* rightmost -> go to next line */ + if (line >= mlen) { + printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); + return line; + } + case 128: + m[line] = 128; /* leftmost -> set byte to 1000000 */ + mbit = 64; /* current bit in the matrix line */ + continue; } if (introducer) { /* set 110 sequence ? */ introducer--; /* set on digit less */ @@ -384,24 +384,24 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) /* if necessary, generate remaining lines of the matrix... */ if ((line) && ((line + 10) < mlen)) switch (++line % 10) { - case 1: - m[line++] = 0xfe; - case 2: - m[line++] = 0xfe; - case 3: - m[line++] = 0xfe; - case 4: - m[line++] = 0xfe; - case 5: - m[line++] = 0xbf; - case 6: - m[line++] = 0xfe; - case 7: - m[line++] = 0xfe; - case 8: - m[line++] = 0xfe; - case 9: - m[line++] = 0xfe; + case 1: + m[line++] = 0xfe; + case 2: + m[line++] = 0xfe; + case 3: + m[line++] = 0xfe; + case 4: + m[line++] = 0xfe; + case 5: + m[line++] = 0xbf; + case 6: + m[line++] = 0xfe; + case 7: + m[line++] = 0xfe; + case 8: + m[line++] = 0xfe; + case 9: + m[line++] = 0xfe; } return line; /* that's how many lines we have */ } @@ -447,7 +447,7 @@ isdn_v110_idle(isdn_v110_stream *v) } struct sk_buff * -isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb) +isdn_v110_encode(isdn_v110_stream *v, struct sk_buff *skb) { int i; int j; @@ -524,93 +524,93 @@ isdn_v110_stat_callback(int idx, isdn_ctrl *c) if (idx < 0) return 0; switch (c->command) { - case ISDN_STAT_BSENT: - /* Keep the send-queue of the driver filled - * with frames: - * If number of outstanding frames < 3, - * send down an Idle-Frame (or an Sync-Frame, if - * v->SyncInit != 0). - */ - if (!(v = dev->v110[idx])) - return 0; - atomic_inc(&dev->v110use[idx]); - for (i=0; i * v->framelen < c->parm.length; i++) { - if (v->skbidle > 0) { - v->skbidle--; - ret = 1; + case ISDN_STAT_BSENT: + /* Keep the send-queue of the driver filled + * with frames: + * If number of outstanding frames < 3, + * send down an Idle-Frame (or an Sync-Frame, if + * v->SyncInit != 0). + */ + if (!(v = dev->v110[idx])) + return 0; + atomic_inc(&dev->v110use[idx]); + for (i = 0; i * v->framelen < c->parm.length; i++) { + if (v->skbidle > 0) { + v->skbidle--; + ret = 1; + } else { + if (v->skbuser > 0) + v->skbuser--; + ret = 0; + } + } + for (i = v->skbuser + v->skbidle; i < 2; i++) { + struct sk_buff *skb; + if (v->SyncInit > 0) + skb = isdn_v110_sync(v); + else + skb = isdn_v110_idle(v); + if (skb) { + if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { + dev_kfree_skb(skb); + break; } else { - if (v->skbuser > 0) - v->skbuser--; - ret = 0; + if (v->SyncInit) + v->SyncInit--; + v->skbidle++; } + } else + break; + } + atomic_dec(&dev->v110use[idx]); + return ret; + case ISDN_STAT_DHUP: + case ISDN_STAT_BHUP: + while (1) { + atomic_inc(&dev->v110use[idx]); + if (atomic_dec_and_test(&dev->v110use[idx])) { + isdn_v110_close(dev->v110[idx]); + dev->v110[idx] = NULL; + break; + } + mdelay(1); + } + break; + case ISDN_STAT_BCONN: + if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) { + int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; + int maxsize = dev->drv[c->driver]->interface->maxbufsize; + atomic_inc(&dev->v110use[idx]); + switch (dev->v110emu[idx]) { + case ISDN_PROTO_L2_V11096: + dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize); + break; + case ISDN_PROTO_L2_V11019: + dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize); + break; + case ISDN_PROTO_L2_V11038: + dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize); + break; + default:; } - for (i = v->skbuser + v->skbidle; i < 2; i++) { - struct sk_buff *skb; - if (v->SyncInit > 0) - skb = isdn_v110_sync(v); - else - skb = isdn_v110_idle(v); - if (skb) { + if ((v = dev->v110[idx])) { + while (v->SyncInit) { + struct sk_buff *skb = isdn_v110_sync(v); if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { dev_kfree_skb(skb); + /* Unable to send, try later */ break; - } else { - if (v->SyncInit) - v->SyncInit--; - v->skbidle++; } - } else - break; - } - atomic_dec(&dev->v110use[idx]); - return ret; - case ISDN_STAT_DHUP: - case ISDN_STAT_BHUP: - while (1) { - atomic_inc(&dev->v110use[idx]); - if (atomic_dec_and_test(&dev->v110use[idx])) { - isdn_v110_close(dev->v110[idx]); - dev->v110[idx] = NULL; - break; + v->SyncInit--; + v->skbidle++; } - mdelay(1); - } - break; - case ISDN_STAT_BCONN: - if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) { - int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; - int maxsize = dev->drv[c->driver]->interface->maxbufsize; - atomic_inc(&dev->v110use[idx]); - switch (dev->v110emu[idx]) { - case ISDN_PROTO_L2_V11096: - dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize); - break; - case ISDN_PROTO_L2_V11019: - dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize); - break; - case ISDN_PROTO_L2_V11038: - dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize); - break; - default:; - } - if ((v = dev->v110[idx])) { - while (v->SyncInit) { - struct sk_buff *skb = isdn_v110_sync(v); - if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { - dev_kfree_skb(skb); - /* Unable to send, try later */ - break; - } - v->SyncInit--; - v->skbidle++; - } - } else - printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx); - atomic_dec(&dev->v110use[idx]); - } - break; - default: - return 0; + } else + printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx); + atomic_dec(&dev->v110use[idx]); + } + break; + default: + return 0; } return 0; } diff --git a/drivers/isdn/i4l/isdn_v110.h b/drivers/isdn/i4l/isdn_v110.h index 08f274bbc438..de774ab598c9 100644 --- a/drivers/isdn/i4l/isdn_v110.h +++ b/drivers/isdn/i4l/isdn_v110.h @@ -12,18 +12,18 @@ #ifndef _isdn_v110_h_ #define _isdn_v110_h_ -/* - * isdn_v110_encode will take raw data and encode it using V.110 +/* + * isdn_v110_encode will take raw data and encode it using V.110 */ extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *); -/* +/* * isdn_v110_decode receives V.110 coded data from the stream and rebuilds * frames from them. The source stream doesn't need to be framed. */ extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *); extern int isdn_v110_stat_callback(int, isdn_ctrl *); -extern void isdn_v110_close(isdn_v110_stream * v); +extern void isdn_v110_close(isdn_v110_stream *v); #endif diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c index fd10d7c785d4..e2d4e58230f5 100644 --- a/drivers/isdn/i4l/isdn_x25iface.c +++ b/drivers/isdn/i4l/isdn_x25iface.c @@ -26,7 +26,7 @@ #include "isdn_x25iface.h" /* for debugging messages not to cause an oops when device pointer is NULL*/ -#define MY_DEVNAME(dev) ( (dev) ? (dev)->name : "DEVICE UNSPECIFIED" ) +#define MY_DEVNAME(dev) ((dev) ? (dev)->name : "DEVICE UNSPECIFIED") typedef struct isdn_x25iface_proto_data { @@ -34,22 +34,22 @@ typedef struct isdn_x25iface_proto_data { enum wan_states state; /* Private stuff, not to be accessed via proto_data. We provide the other storage for the concap_proto instance here as well, - enabling us to allocate both with just one kmalloc(): */ + enabling us to allocate both with just one kmalloc(): */ struct concap_proto priv; } ix25_pdata_t; /* is now in header file (extern): struct concap_proto * isdn_x25iface_proto_new(void); */ -static void isdn_x25iface_proto_del( struct concap_proto * ); -static int isdn_x25iface_proto_close( struct concap_proto * ); -static int isdn_x25iface_proto_restart( struct concap_proto *, - struct net_device *, - struct concap_device_ops *); -static int isdn_x25iface_xmit( struct concap_proto *, struct sk_buff * ); -static int isdn_x25iface_receive( struct concap_proto *, struct sk_buff * ); -static int isdn_x25iface_connect_ind( struct concap_proto * ); -static int isdn_x25iface_disconn_ind( struct concap_proto * ); +static void isdn_x25iface_proto_del(struct concap_proto *); +static int isdn_x25iface_proto_close(struct concap_proto *); +static int isdn_x25iface_proto_restart(struct concap_proto *, + struct net_device *, + struct concap_device_ops *); +static int isdn_x25iface_xmit(struct concap_proto *, struct sk_buff *); +static int isdn_x25iface_receive(struct concap_proto *, struct sk_buff *); +static int isdn_x25iface_connect_ind(struct concap_proto *); +static int isdn_x25iface_disconn_ind(struct concap_proto *); static struct concap_proto_ops ix25_pops = { @@ -64,65 +64,65 @@ static struct concap_proto_ops ix25_pops = { }; /* error message helper function */ -static void illegal_state_warn( unsigned state, unsigned char firstbyte) +static void illegal_state_warn(unsigned state, unsigned char firstbyte) { - printk( KERN_WARNING "isdn_x25iface: firstbyte %x illegal in" - "current state %d\n",firstbyte, state ); + printk(KERN_WARNING "isdn_x25iface: firstbyte %x illegal in" + "current state %d\n", firstbyte, state); } /* check protocol data field for consistency */ -static int pdata_is_bad( ix25_pdata_t * pda ){ +static int pdata_is_bad(ix25_pdata_t *pda) { - if( pda && pda -> magic == ISDN_X25IFACE_MAGIC ) return 0; - printk( KERN_WARNING - "isdn_x25iface_xxx: illegal pointer to proto data\n" ); + if (pda && pda->magic == ISDN_X25IFACE_MAGIC) return 0; + printk(KERN_WARNING + "isdn_x25iface_xxx: illegal pointer to proto data\n"); return 1; } /* create a new x25 interface protocol instance */ -struct concap_proto * isdn_x25iface_proto_new(void) +struct concap_proto *isdn_x25iface_proto_new(void) { - ix25_pdata_t * tmp = kmalloc(sizeof(ix25_pdata_t),GFP_KERNEL); + ix25_pdata_t *tmp = kmalloc(sizeof(ix25_pdata_t), GFP_KERNEL); IX25DEBUG("isdn_x25iface_proto_new\n"); - if( tmp ){ - tmp -> magic = ISDN_X25IFACE_MAGIC; - tmp -> state = WAN_UNCONFIGURED; + if (tmp) { + tmp->magic = ISDN_X25IFACE_MAGIC; + tmp->state = WAN_UNCONFIGURED; /* private data space used to hold the concap_proto data. Only to be accessed via the returned pointer */ spin_lock_init(&tmp->priv.lock); - tmp -> priv.dops = NULL; - tmp -> priv.net_dev = NULL; - tmp -> priv.pops = &ix25_pops; - tmp -> priv.flags = 0; - tmp -> priv.proto_data = tmp; - return( &(tmp -> priv) ); + tmp->priv.dops = NULL; + tmp->priv.net_dev = NULL; + tmp->priv.pops = &ix25_pops; + tmp->priv.flags = 0; + tmp->priv.proto_data = tmp; + return (&(tmp->priv)); } return NULL; }; -/* close the x25iface encapsulation protocol +/* close the x25iface encapsulation protocol */ -static int isdn_x25iface_proto_close(struct concap_proto *cprot){ +static int isdn_x25iface_proto_close(struct concap_proto *cprot) { ix25_pdata_t *tmp; - int ret = 0; + int ret = 0; ulong flags; - if( ! cprot ){ - printk( KERN_ERR "isdn_x25iface_proto_close: " - "invalid concap_proto pointer\n" ); + if (!cprot) { + printk(KERN_ERR "isdn_x25iface_proto_close: " + "invalid concap_proto pointer\n"); return -1; } - IX25DEBUG( "isdn_x25iface_proto_close %s \n", MY_DEVNAME(cprot -> net_dev) ); + IX25DEBUG("isdn_x25iface_proto_close %s \n", MY_DEVNAME(cprot->net_dev)); spin_lock_irqsave(&cprot->lock, flags); - cprot -> dops = NULL; - cprot -> net_dev = NULL; - tmp = cprot -> proto_data; - if( pdata_is_bad( tmp ) ){ + cprot->dops = NULL; + cprot->net_dev = NULL; + tmp = cprot->proto_data; + if (pdata_is_bad(tmp)) { ret = -1; } else { - tmp -> state = WAN_UNCONFIGURED; + tmp->state = WAN_UNCONFIGURED; } spin_unlock_irqrestore(&cprot->lock, flags); return ret; @@ -130,100 +130,100 @@ static int isdn_x25iface_proto_close(struct concap_proto *cprot){ /* Delete the x25iface encapsulation protocol instance */ -static void isdn_x25iface_proto_del(struct concap_proto *cprot){ +static void isdn_x25iface_proto_del(struct concap_proto *cprot) { + + ix25_pdata_t *tmp; - ix25_pdata_t * tmp; - - IX25DEBUG( "isdn_x25iface_proto_del \n" ); - if( ! cprot ){ - printk( KERN_ERR "isdn_x25iface_proto_del: " - "concap_proto pointer is NULL\n" ); + IX25DEBUG("isdn_x25iface_proto_del \n"); + if (!cprot) { + printk(KERN_ERR "isdn_x25iface_proto_del: " + "concap_proto pointer is NULL\n"); return; } - tmp = cprot -> proto_data; - if( tmp == NULL ){ - printk( KERN_ERR "isdn_x25iface_proto_del: inconsistent " - "proto_data pointer (maybe already deleted?)\n"); + tmp = cprot->proto_data; + if (tmp == NULL) { + printk(KERN_ERR "isdn_x25iface_proto_del: inconsistent " + "proto_data pointer (maybe already deleted?)\n"); return; } /* close if the protocol is still open */ - if( cprot -> dops ) isdn_x25iface_proto_close(cprot); + if (cprot->dops) isdn_x25iface_proto_close(cprot); /* freeing the storage should be sufficient now. But some additional settings might help to catch wild pointer bugs */ - tmp -> magic = 0; - cprot -> proto_data = NULL; + tmp->magic = 0; + cprot->proto_data = NULL; - kfree( tmp ); + kfree(tmp); return; } /* (re-)initialize the data structures for x25iface encapsulation */ static int isdn_x25iface_proto_restart(struct concap_proto *cprot, - struct net_device *ndev, - struct concap_device_ops *dops) + struct net_device *ndev, + struct concap_device_ops *dops) { - ix25_pdata_t * pda = cprot -> proto_data ; + ix25_pdata_t *pda = cprot->proto_data; ulong flags; - IX25DEBUG( "isdn_x25iface_proto_restart %s \n", MY_DEVNAME(ndev) ); + IX25DEBUG("isdn_x25iface_proto_restart %s \n", MY_DEVNAME(ndev)); - if ( pdata_is_bad( pda ) ) return -1; + if (pdata_is_bad(pda)) return -1; - if( !( dops && dops -> data_req && dops -> connect_req - && dops -> disconn_req ) ){ - printk( KERN_WARNING "isdn_x25iface_restart: required dops" - " missing\n" ); + if (!(dops && dops->data_req && dops->connect_req + && dops->disconn_req)) { + printk(KERN_WARNING "isdn_x25iface_restart: required dops" + " missing\n"); isdn_x25iface_proto_close(cprot); return -1; } spin_lock_irqsave(&cprot->lock, flags); - cprot -> net_dev = ndev; - cprot -> pops = &ix25_pops; - cprot -> dops = dops; - pda -> state = WAN_DISCONNECTED; + cprot->net_dev = ndev; + cprot->pops = &ix25_pops; + cprot->dops = dops; + pda->state = WAN_DISCONNECTED; spin_unlock_irqrestore(&cprot->lock, flags); return 0; } -/* deliver a dl_data frame received from i4l HL driver to the network layer +/* deliver a dl_data frame received from i4l HL driver to the network layer */ static int isdn_x25iface_receive(struct concap_proto *cprot, struct sk_buff *skb) { - IX25DEBUG( "isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev) ); - if ( ( (ix25_pdata_t*) (cprot->proto_data) ) - -> state == WAN_CONNECTED ){ - if( skb_push(skb, 1)){ + IX25DEBUG("isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev)); + if (((ix25_pdata_t *)(cprot->proto_data)) + ->state == WAN_CONNECTED) { + if (skb_push(skb, 1)) { skb->data[0] = X25_IFACE_DATA; skb->protocol = x25_type_trans(skb, cprot->net_dev); netif_rx(skb); return 0; } } - printk(KERN_WARNING "isdn_x25iface_receive %s: not connected, skb dropped\n", MY_DEVNAME(cprot->net_dev) ); + printk(KERN_WARNING "isdn_x25iface_receive %s: not connected, skb dropped\n", MY_DEVNAME(cprot->net_dev)); dev_kfree_skb(skb); return -1; } -/* a connection set up is indicated by lower layer +/* a connection set up is indicated by lower layer */ static int isdn_x25iface_connect_ind(struct concap_proto *cprot) { - struct sk_buff * skb; - enum wan_states *state_p - = &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state); - IX25DEBUG( "isdn_x25iface_connect_ind %s \n" - , MY_DEVNAME(cprot->net_dev) ); - if( *state_p == WAN_UNCONFIGURED ){ - printk(KERN_WARNING + struct sk_buff *skb; + enum wan_states *state_p + = &(((ix25_pdata_t *)(cprot->proto_data))->state); + IX25DEBUG("isdn_x25iface_connect_ind %s \n" + , MY_DEVNAME(cprot->net_dev)); + if (*state_p == WAN_UNCONFIGURED) { + printk(KERN_WARNING "isdn_x25iface_connect_ind while unconfigured %s\n" - , MY_DEVNAME(cprot->net_dev) ); + , MY_DEVNAME(cprot->net_dev)); return -1; } *state_p = WAN_CONNECTED; skb = dev_alloc_skb(1); - if( skb ){ + if (skb) { *(skb_put(skb, 1)) = X25_IFACE_CONNECT; skb->protocol = x25_type_trans(skb, cprot->net_dev); netif_rx(skb); @@ -231,28 +231,28 @@ static int isdn_x25iface_connect_ind(struct concap_proto *cprot) } else { printk(KERN_WARNING "isdn_x25iface_connect_ind: " " out of memory -- disconnecting\n"); - cprot -> dops -> disconn_req(cprot); + cprot->dops->disconn_req(cprot); return -1; } } - -/* a disconnect is indicated by lower layer + +/* a disconnect is indicated by lower layer */ static int isdn_x25iface_disconn_ind(struct concap_proto *cprot) { struct sk_buff *skb; - enum wan_states *state_p - = &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state); - IX25DEBUG( "isdn_x25iface_disconn_ind %s \n", MY_DEVNAME(cprot -> net_dev) ); - if( *state_p == WAN_UNCONFIGURED ){ - printk(KERN_WARNING + enum wan_states *state_p + = &(((ix25_pdata_t *)(cprot->proto_data))->state); + IX25DEBUG("isdn_x25iface_disconn_ind %s \n", MY_DEVNAME(cprot->net_dev)); + if (*state_p == WAN_UNCONFIGURED) { + printk(KERN_WARNING "isdn_x25iface_disconn_ind while unconfigured\n"); return -1; } - if(! cprot -> net_dev) return -1; + if (!cprot->net_dev) return -1; *state_p = WAN_DISCONNECTED; skb = dev_alloc_skb(1); - if( skb ){ + if (skb) { *(skb_put(skb, 1)) = X25_IFACE_DISCONNECT; skb->protocol = x25_type_trans(skb, cprot->net_dev); netif_rx(skb); @@ -266,57 +266,57 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *cprot) /* process a frame handed over to us from linux network layer. First byte semantics as defined in Documentation/networking/x25-iface.txt - */ +*/ static int isdn_x25iface_xmit(struct concap_proto *cprot, struct sk_buff *skb) { unsigned char firstbyte = skb->data[0]; - enum wan_states *state = &((ix25_pdata_t*)cprot->proto_data)->state; + enum wan_states *state = &((ix25_pdata_t *)cprot->proto_data)->state; int ret = 0; IX25DEBUG("isdn_x25iface_xmit: %s first=%x state=%d\n", - MY_DEVNAME(cprot->net_dev), firstbyte, *state); - switch ( firstbyte ){ + MY_DEVNAME(cprot->net_dev), firstbyte, *state); + switch (firstbyte) { case X25_IFACE_DATA: - if( *state == WAN_CONNECTED ){ + if (*state == WAN_CONNECTED) { skb_pull(skb, 1); - cprot -> net_dev -> trans_start = jiffies; - ret = ( cprot -> dops -> data_req(cprot, skb) ); + cprot->net_dev->trans_start = jiffies; + ret = (cprot->dops->data_req(cprot, skb)); /* prepare for future retransmissions */ - if( ret ) skb_push(skb,1); + if (ret) skb_push(skb, 1); return ret; } - illegal_state_warn( *state, firstbyte ); + illegal_state_warn(*state, firstbyte); break; case X25_IFACE_CONNECT: - if( *state == WAN_DISCONNECTED ){ + if (*state == WAN_DISCONNECTED) { *state = WAN_CONNECTING; - ret = cprot -> dops -> connect_req(cprot); - if(ret){ + ret = cprot->dops->connect_req(cprot); + if (ret) { /* reset state and notify upper layer about * immidiatly failed attempts */ isdn_x25iface_disconn_ind(cprot); } } else { - illegal_state_warn( *state, firstbyte ); + illegal_state_warn(*state, firstbyte); } break; case X25_IFACE_DISCONNECT: - switch ( *state ){ - case WAN_DISCONNECTED: + switch (*state) { + case WAN_DISCONNECTED: /* Should not happen. However, give upper layer a chance to recover from inconstistency but don't trust the lower layer sending the disconn_confirm when already disconnected */ printk(KERN_WARNING "isdn_x25iface_xmit: disconnect " - " requested while disconnected\n" ); + " requested while disconnected\n"); isdn_x25iface_disconn_ind(cprot); break; /* prevent infinite loops */ case WAN_CONNECTING: case WAN_CONNECTED: *state = WAN_DISCONNECTED; - cprot -> dops -> disconn_req(cprot); + cprot->dops->disconn_req(cprot); break; default: - illegal_state_warn( *state, firstbyte ); + illegal_state_warn(*state, firstbyte); } break; case X25_IFACE_PARAMS: diff --git a/drivers/isdn/i4l/isdn_x25iface.h b/drivers/isdn/i4l/isdn_x25iface.h index 41a3d4977466..0b26e3b336e7 100644 --- a/drivers/isdn/i4l/isdn_x25iface.h +++ b/drivers/isdn/i4l/isdn_x25iface.h @@ -13,9 +13,9 @@ #define ISDN_X25IFACE_MAGIC 0x1e75a2b9 /* #define DEBUG_ISDN_X25 if you want isdn_x25 debugging messages */ #ifdef DEBUG_ISDN_X25 -# define IX25DEBUG(fmt,args...) printk(KERN_DEBUG fmt , ## args) +# define IX25DEBUG(fmt, args...) printk(KERN_DEBUG fmt, ##args) #else -# define IX25DEBUG(fmt,args...) +# define IX25DEBUG(fmt, args...) #endif #include @@ -23,17 +23,9 @@ #include #include -extern struct concap_proto_ops * isdn_x25iface_concap_proto_ops_pt; -extern struct concap_proto * isdn_x25iface_proto_new(void); +extern struct concap_proto_ops *isdn_x25iface_concap_proto_ops_pt; +extern struct concap_proto *isdn_x25iface_proto_new(void); #endif - - - - - - - - diff --git a/drivers/isdn/i4l/isdnhdlc.c b/drivers/isdn/i4l/isdnhdlc.c index c989aa35dc2f..027d1c590679 100644 --- a/drivers/isdn/i4l/isdnhdlc.c +++ b/drivers/isdn/i4l/isdnhdlc.c @@ -88,7 +88,7 @@ check_frame(struct isdnhdlc_vars *hdlc) { int status; - if (hdlc->dstpos < 2) /* too small - framing error */ + if (hdlc->dstpos < 2) /* too small - framing error */ status = -HDLC_FRAMING_ERROR; else if (hdlc->crc != 0xf0b8) /* crc error */ status = -HDLC_CRC_ERROR; @@ -127,9 +127,9 @@ check_frame(struct isdnhdlc_vars *hdlc) dsize - destination buffer size returns - number of decoded bytes in the destination buffer and status flag. - */ +*/ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen, - int *count, u8 *dst, int dsize) + int *count, u8 *dst, int dsize) { int status = 0; @@ -145,28 +145,28 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; -#define handle_fast_flag(h) \ - do {\ - if (h->cbin == fast_flag[h->bit_shift]) {\ - h->ffvalue = fast_flag_value[h->bit_shift];\ - h->state = HDLC_FAST_FLAG;\ - h->ffbit_shift = h->bit_shift;\ - h->bit_shift = 1;\ - } else {\ - h->state = HDLC_GET_DATA;\ - h->data_received = 0;\ - } \ +#define handle_fast_flag(h) \ + do { \ + if (h->cbin == fast_flag[h->bit_shift]) { \ + h->ffvalue = fast_flag_value[h->bit_shift]; \ + h->state = HDLC_FAST_FLAG; \ + h->ffbit_shift = h->bit_shift; \ + h->bit_shift = 1; \ + } else { \ + h->state = HDLC_GET_DATA; \ + h->data_received = 0; \ + } \ } while (0) -#define handle_abort(h) \ - do {\ - h->shift_reg = fast_abort[h->ffbit_shift - 1];\ - h->hdlc_bits1 = h->ffbit_shift - 2;\ - if (h->hdlc_bits1 < 0)\ - h->hdlc_bits1 = 0;\ - h->data_bits = h->ffbit_shift - 1;\ - h->state = HDLC_GET_DATA;\ - h->data_received = 0;\ +#define handle_abort(h) \ + do { \ + h->shift_reg = fast_abort[h->ffbit_shift - 1]; \ + h->hdlc_bits1 = h->ffbit_shift - 2; \ + if (h->hdlc_bits1 < 0) \ + h->hdlc_bits1 = 0; \ + h->data_bits = h->ffbit_shift - 1; \ + h->state = HDLC_GET_DATA; \ + h->data_received = 0; \ } while (0) *count = slen; @@ -204,7 +204,7 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen, if ((!hdlc->do_adapt56) && (++hdlc->hdlc_bits1 >= 8) && (hdlc->bit_shift == 1)) - hdlc->state = HDLC_FAST_IDLE; + hdlc->state = HDLC_FAST_IDLE; } hdlc->cbin <<= 1; hdlc->bit_shift--; @@ -295,7 +295,7 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen, hdlc->data_bits = 0; hdlc->data_received = 1; hdlc->crc = crc_ccitt_byte(hdlc->crc, - hdlc->shift_reg); + hdlc->shift_reg); /* good byte received */ if (hdlc->dstpos < dsize) @@ -352,7 +352,7 @@ EXPORT_SYMBOL(isdnhdlc_decode); returns - number of encoded bytes in the destination buffer */ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen, - int *count, u8 *dst, int dsize) + int *count, u8 *dst, int dsize) { static const unsigned char xfast_flag_value[] = { 0x7e, 0x3f, 0x9f, 0xcf, 0xe7, 0xf3, 0xf9, 0xfc, 0x7e @@ -478,7 +478,7 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen, } if (hdlc->bit_shift == 8) hdlc->crc = crc_ccitt_byte(hdlc->crc, - hdlc->shift_reg); + hdlc->shift_reg); if (hdlc->shift_reg & 0x01) { hdlc->hdlc_bits1++; hdlc->cbin++; diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c index 1f355bb85e54..e74df7c4658f 100644 --- a/drivers/isdn/icn/icn.c +++ b/drivers/isdn/icn/icn.c @@ -54,7 +54,7 @@ static int icn_addcard(int, char *, char *); * channel = channel number */ static void -icn_free_queue(icn_card * card, int channel) +icn_free_queue(icn_card *card, int channel) { struct sk_buff_head *queue = &card->spqueue[channel]; struct sk_buff *skb; @@ -93,7 +93,7 @@ icn_shiftout(unsigned short port, * disable a cards shared memory */ static inline void -icn_disable_ram(icn_card * card) +icn_disable_ram(icn_card *card) { OUTB_P(0, ICN_MAPRAM); } @@ -102,7 +102,7 @@ icn_disable_ram(icn_card * card) * enable a cards shared memory */ static inline void -icn_enable_ram(icn_card * card) +icn_enable_ram(icn_card *card) { OUTB_P(0xff, ICN_MAPRAM); } @@ -113,7 +113,7 @@ icn_enable_ram(icn_card * card) * must called with holding the devlock */ static inline void -icn_map_channel(icn_card * card, int channel) +icn_map_channel(icn_card *card, int channel) { #ifdef MAP_DEBUG printk(KERN_DEBUG "icn_map_channel %d %d\n", dev.channel, channel); @@ -139,7 +139,7 @@ icn_map_channel(icn_card * card, int channel) * must called with holding the devlock */ static inline int -icn_lock_channel(icn_card * card, int channel) +icn_lock_channel(icn_card *card, int channel) { register int retval; @@ -194,7 +194,7 @@ icn_release_channel(void) * Return 1 on success, 0 on failure. */ static inline int -icn_trymaplock_channel(icn_card * card, int channel) +icn_trymaplock_channel(icn_card *card, int channel) { ulong flags; @@ -225,7 +225,7 @@ icn_trymaplock_channel(icn_card * card, int channel) * then map same or other channel without locking. */ static inline void -icn_maprelease_channel(icn_card * card, int channel) +icn_maprelease_channel(icn_card *card, int channel) { ulong flags; @@ -246,7 +246,7 @@ icn_maprelease_channel(icn_card * card, int channel) */ static void -icn_pollbchan_receive(int channel, icn_card * card) +icn_pollbchan_receive(int channel, icn_card *card) { int mch = channel + ((card->secondhalf) ? 2 : 0); int eflag; @@ -297,7 +297,7 @@ icn_pollbchan_receive(int channel, icn_card * card) */ static void -icn_pollbchan_send(int channel, icn_card * card) +icn_pollbchan_send(int channel, icn_card *card) { int mch = channel + ((card->secondhalf) ? 2 : 0); int cnt; @@ -309,7 +309,7 @@ icn_pollbchan_send(int channel, icn_card * card) !skb_queue_empty(&card->spqueue[channel]))) return; if (icn_trymaplock_channel(card, mch)) { - while (sbfree && + while (sbfree && (card->sndcount[channel] || !skb_queue_empty(&card->spqueue[channel]) || card->xskb[channel])) { @@ -327,7 +327,7 @@ icn_pollbchan_send(int channel, icn_card * card) /* Pop ACK-flag off skb. * Store length to xlen. */ - if (*(skb_pull(skb,1))) + if (*(skb_pull(skb, 1))) card->xlen[channel] = skb->len; else card->xlen[channel] = 0; @@ -396,7 +396,7 @@ icn_pollbchan(unsigned long data) if (card->flags & (ICN_FLAGS_B1ACTIVE | ICN_FLAGS_B2ACTIVE)) { /* schedule b-channel polling again */ spin_lock_irqsave(&card->lock, flags); - mod_timer(&card->rb_timer, jiffies+ICN_TIMER_BCREAD); + mod_timer(&card->rb_timer, jiffies + ICN_TIMER_BCREAD); card->flags |= ICN_FLAGS_RBTIMER; spin_unlock_irqrestore(&card->lock, flags); } else @@ -428,7 +428,7 @@ static icn_stat icn_stat_table[] = {"E_L1: ACT FAIL", ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {"E_L2: DATA LIN", ISDN_STAT_BHUP, 8}, /* Layer-2 data link lost */ {"E_L1: ACTIVATION FAILED", - ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ + ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {NULL, 0, -1} }; /* *INDENT-ON* */ @@ -445,7 +445,7 @@ static icn_stat icn_stat_table[] = */ static void -icn_parse_status(u_char * status, int channel, icn_card * card) +icn_parse_status(u_char *status, int channel, icn_card *card) { icn_stat *s = icn_stat_table; int action = -1; @@ -465,128 +465,128 @@ icn_parse_status(u_char * status, int channel, icn_card * card) cmd.driver = card->myid; cmd.arg = channel; switch (action) { - case 11: - spin_lock_irqsave(&card->lock, flags); - icn_free_queue(card,channel); - card->rcvidx[channel] = 0; - - if (card->flags & - ((channel)?ICN_FLAGS_B2ACTIVE:ICN_FLAGS_B1ACTIVE)) { - - isdn_ctrl ncmd; - - card->flags &= ~((channel)? - ICN_FLAGS_B2ACTIVE:ICN_FLAGS_B1ACTIVE); - - memset(&ncmd, 0, sizeof(ncmd)); - - ncmd.driver = card->myid; - ncmd.arg = channel; - ncmd.command = ISDN_STAT_BHUP; - spin_unlock_irqrestore(&card->lock, flags); - card->interface.statcallb(&cmd); - } else - spin_unlock_irqrestore(&card->lock, flags); - break; - case 1: - spin_lock_irqsave(&card->lock, flags); - icn_free_queue(card,channel); - card->flags |= (channel) ? - ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE; - spin_unlock_irqrestore(&card->lock, flags); - break; - case 2: - spin_lock_irqsave(&card->lock, flags); + case 11: + spin_lock_irqsave(&card->lock, flags); + icn_free_queue(card, channel); + card->rcvidx[channel] = 0; + + if (card->flags & + ((channel) ? ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE)) { + + isdn_ctrl ncmd; + card->flags &= ~((channel) ? - ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE); - icn_free_queue(card, channel); - card->rcvidx[channel] = 0; - spin_unlock_irqrestore(&card->lock, flags); - break; - case 3: - { - char *t = status + 6; - char *s = strchr(t, ','); - - *s++ = '\0'; - strlcpy(cmd.parm.setup.phone, t, - sizeof(cmd.parm.setup.phone)); - s = strchr(t = s, ','); - *s++ = '\0'; - if (!strlen(t)) - cmd.parm.setup.si1 = 0; - else - cmd.parm.setup.si1 = - simple_strtoul(t, NULL, 10); - s = strchr(t = s, ','); - *s++ = '\0'; - if (!strlen(t)) - cmd.parm.setup.si2 = 0; - else - cmd.parm.setup.si2 = - simple_strtoul(t, NULL, 10); - strlcpy(cmd.parm.setup.eazmsn, s, - sizeof(cmd.parm.setup.eazmsn)); - } - cmd.parm.setup.plan = 0; - cmd.parm.setup.screen = 0; - break; - case 4: - sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); - sprintf(cmd.parm.setup.eazmsn, "%d", channel + 1); - cmd.parm.setup.si1 = 7; - cmd.parm.setup.si2 = 0; - cmd.parm.setup.plan = 0; - cmd.parm.setup.screen = 0; - break; - case 5: - strlcpy(cmd.parm.num, status + 3, sizeof(cmd.parm.num)); - break; - case 6: - snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%d", - (int) simple_strtoul(status + 7, NULL, 16)); - break; - case 7: - status += 3; - if (strlen(status) == 4) - snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%s%c%c", - status + 2, *status, *(status + 1)); - else - strlcpy(cmd.parm.num, status + 1, sizeof(cmd.parm.num)); - break; - case 8: - spin_lock_irqsave(&card->lock, flags); - card->flags &= ~ICN_FLAGS_B1ACTIVE; - icn_free_queue(card, 0); - card->rcvidx[0] = 0; + ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE); + + memset(&ncmd, 0, sizeof(ncmd)); + + ncmd.driver = card->myid; + ncmd.arg = channel; + ncmd.command = ISDN_STAT_BHUP; spin_unlock_irqrestore(&card->lock, flags); - cmd.arg = 0; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_DHUP; - cmd.arg = 0; - cmd.driver = card->myid; card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_BHUP; - spin_lock_irqsave(&card->lock, flags); - card->flags &= ~ICN_FLAGS_B2ACTIVE; - icn_free_queue(card, 1); - card->rcvidx[1] = 0; + } else spin_unlock_irqrestore(&card->lock, flags); - cmd.arg = 1; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_DHUP; - cmd.arg = 1; - cmd.driver = card->myid; - break; + break; + case 1: + spin_lock_irqsave(&card->lock, flags); + icn_free_queue(card, channel); + card->flags |= (channel) ? + ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE; + spin_unlock_irqrestore(&card->lock, flags); + break; + case 2: + spin_lock_irqsave(&card->lock, flags); + card->flags &= ~((channel) ? + ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE); + icn_free_queue(card, channel); + card->rcvidx[channel] = 0; + spin_unlock_irqrestore(&card->lock, flags); + break; + case 3: + { + char *t = status + 6; + char *s = strchr(t, ','); + + *s++ = '\0'; + strlcpy(cmd.parm.setup.phone, t, + sizeof(cmd.parm.setup.phone)); + s = strchr(t = s, ','); + *s++ = '\0'; + if (!strlen(t)) + cmd.parm.setup.si1 = 0; + else + cmd.parm.setup.si1 = + simple_strtoul(t, NULL, 10); + s = strchr(t = s, ','); + *s++ = '\0'; + if (!strlen(t)) + cmd.parm.setup.si2 = 0; + else + cmd.parm.setup.si2 = + simple_strtoul(t, NULL, 10); + strlcpy(cmd.parm.setup.eazmsn, s, + sizeof(cmd.parm.setup.eazmsn)); + } + cmd.parm.setup.plan = 0; + cmd.parm.setup.screen = 0; + break; + case 4: + sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); + sprintf(cmd.parm.setup.eazmsn, "%d", channel + 1); + cmd.parm.setup.si1 = 7; + cmd.parm.setup.si2 = 0; + cmd.parm.setup.plan = 0; + cmd.parm.setup.screen = 0; + break; + case 5: + strlcpy(cmd.parm.num, status + 3, sizeof(cmd.parm.num)); + break; + case 6: + snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%d", + (int) simple_strtoul(status + 7, NULL, 16)); + break; + case 7: + status += 3; + if (strlen(status) == 4) + snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%s%c%c", + status + 2, *status, *(status + 1)); + else + strlcpy(cmd.parm.num, status + 1, sizeof(cmd.parm.num)); + break; + case 8: + spin_lock_irqsave(&card->lock, flags); + card->flags &= ~ICN_FLAGS_B1ACTIVE; + icn_free_queue(card, 0); + card->rcvidx[0] = 0; + spin_unlock_irqrestore(&card->lock, flags); + cmd.arg = 0; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_DHUP; + cmd.arg = 0; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_BHUP; + spin_lock_irqsave(&card->lock, flags); + card->flags &= ~ICN_FLAGS_B2ACTIVE; + icn_free_queue(card, 1); + card->rcvidx[1] = 0; + spin_unlock_irqrestore(&card->lock, flags); + cmd.arg = 1; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_DHUP; + cmd.arg = 1; + cmd.driver = card->myid; + break; } card->interface.statcallb(&cmd); return; } static void -icn_putmsg(icn_card * card, unsigned char c) +icn_putmsg(icn_card *card, unsigned char c) { ulong flags; @@ -688,7 +688,7 @@ icn_polldchan(unsigned long data) add_timer(&card->rb_timer); } /* schedule again */ - mod_timer(&card->st_timer, jiffies+ICN_TIMER_DCREAD); + mod_timer(&card->st_timer, jiffies + ICN_TIMER_DCREAD); spin_unlock_irqrestore(&card->lock, flags); } @@ -702,7 +702,7 @@ icn_polldchan(unsigned long data) */ static int -icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card * card) +icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card *card) { int len = skb->len; unsigned long flags; @@ -718,13 +718,13 @@ icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card * card) return 0; if (card->sndcount[channel] > ICN_MAX_SQUEUE) return 0; - #warning TODO test headroom or use skb->nb to flag ACK +#warning TODO test headroom or use skb->nb to flag ACK nskb = skb_clone(skb, GFP_ATOMIC); if (nskb) { /* Push ACK flag as one * byte in front of data. */ - *(skb_push(nskb, 1)) = ack?1:0; + *(skb_push(nskb, 1)) = ack ? 1 : 0; skb_queue_tail(&card->spqueue[channel], nskb); dev_kfree_skb(skb); } else @@ -785,20 +785,20 @@ icn_check_loader(int cardnumber) */ #ifdef BOOT_DEBUG -#define SLEEP(sec) { \ -int slsec = sec; \ - printk(KERN_DEBUG "SLEEP(%d)\n",slsec); \ - while (slsec) { \ - msleep_interruptible(1000); \ - slsec--; \ - } \ -} +#define SLEEP(sec) { \ + int slsec = sec; \ + printk(KERN_DEBUG "SLEEP(%d)\n", slsec); \ + while (slsec) { \ + msleep_interruptible(1000); \ + slsec--; \ + } \ + } #else #define SLEEP(sec) #endif static int -icn_loadboot(u_char __user * buffer, icn_card * card) +icn_loadboot(u_char __user *buffer, icn_card *card) { int ret; u_char *codebuf; @@ -896,14 +896,14 @@ icn_loadboot(u_char __user * buffer, icn_card * card) SLEEP(1); ret = (icn_check_loader(1)); - out_kfree: +out_kfree: kfree(codebuf); - out: +out: return ret; } static int -icn_loadproto(u_char __user * buffer, icn_card * card) +icn_loadproto(u_char __user *buffer, icn_card *card) { register u_char __user *p = buffer; u_char codebuf[256]; @@ -1004,7 +1004,7 @@ icn_loadproto(u_char __user * buffer, icn_card * card) /* Read the Status-replies from the Interface */ static int -icn_readstatus(u_char __user *buf, int len, icn_card * card) +icn_readstatus(u_char __user *buf, int len, icn_card *card) { int count; u_char __user *p; @@ -1022,7 +1022,7 @@ icn_readstatus(u_char __user *buf, int len, icn_card * card) /* Put command-strings into the command-queue of the Interface */ static int -icn_writecmd(const u_char * buf, int len, int user, icn_card * card) +icn_writecmd(const u_char *buf, int len, int user, icn_card *card) { int mch = card->secondhalf ? 2 : 0; int pp; @@ -1057,9 +1057,9 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card) icn_putmsg(card, '>'); for (p = msg, pp = readb(&cmd_i), i = count; i > 0; i--, p++, pp - ++) { + ++) { writeb((*p == '\n') ? 0xff : *p, - &dev.shmem->comm_buffers.pcio_buf[pp & 0xff]); + &dev.shmem->comm_buffers.pcio_buf[pp & 0xff]); len--; xcount++; icn_putmsg(card, *p); @@ -1093,7 +1093,7 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card) * Delete card's pending timers, send STOP to linklevel */ static void -icn_stopcard(icn_card * card) +icn_stopcard(icn_card *card) { unsigned long flags; isdn_ctrl cmd; @@ -1150,7 +1150,7 @@ icn_disable_cards(void) } static int -icn_command(isdn_ctrl * c, icn_card * card) +icn_command(isdn_ctrl *c, icn_card *card) { ulong a; ulong flags; @@ -1161,275 +1161,275 @@ icn_command(isdn_ctrl * c, icn_card * card) char __user *arg; switch (c->command) { - case ISDN_CMD_IOCTL: - memcpy(&a, c->parm.num, sizeof(ulong)); - arg = (char __user *)a; - switch (c->arg) { - case ICN_IOCTL_SETMMIO: - if (dev.memaddr != (a & 0x0ffc000)) { - if (!request_mem_region(a & 0x0ffc000, 0x4000, "icn-isdn (all cards)")) { - printk(KERN_WARNING - "icn: memory at 0x%08lx in use.\n", - a & 0x0ffc000); - return -EINVAL; - } - release_mem_region(a & 0x0ffc000, 0x4000); - icn_stopallcards(); - spin_lock_irqsave(&card->lock, flags); - if (dev.mvalid) { - iounmap(dev.shmem); - release_mem_region(dev.memaddr, 0x4000); - } - dev.mvalid = 0; - dev.memaddr = a & 0x0ffc000; - spin_unlock_irqrestore(&card->lock, flags); - printk(KERN_INFO - "icn: (%s) mmio set to 0x%08lx\n", - CID, - dev.memaddr); - } - break; - case ICN_IOCTL_GETMMIO: - return (long) dev.memaddr; - case ICN_IOCTL_SETPORT: - if (a == 0x300 || a == 0x310 || a == 0x320 || a == 0x330 - || a == 0x340 || a == 0x350 || a == 0x360 || - a == 0x308 || a == 0x318 || a == 0x328 || a == 0x338 - || a == 0x348 || a == 0x358 || a == 0x368) { - if (card->port != (unsigned short) a) { - if (!request_region((unsigned short) a, ICN_PORTLEN, "icn-isdn")) { - printk(KERN_WARNING - "icn: (%s) ports 0x%03x-0x%03x in use.\n", - CID, (int) a, (int) a + ICN_PORTLEN); - return -EINVAL; - } - release_region((unsigned short) a, ICN_PORTLEN); - icn_stopcard(card); - spin_lock_irqsave(&card->lock, flags); - if (card->rvalid) - release_region(card->port, ICN_PORTLEN); - card->port = (unsigned short) a; - card->rvalid = 0; - if (card->doubleS0) { - card->other->port = (unsigned short) a; - card->other->rvalid = 0; - } - spin_unlock_irqrestore(&card->lock, flags); - printk(KERN_INFO - "icn: (%s) port set to 0x%03x\n", - CID, card->port); - } - } else + case ISDN_CMD_IOCTL: + memcpy(&a, c->parm.num, sizeof(ulong)); + arg = (char __user *)a; + switch (c->arg) { + case ICN_IOCTL_SETMMIO: + if (dev.memaddr != (a & 0x0ffc000)) { + if (!request_mem_region(a & 0x0ffc000, 0x4000, "icn-isdn (all cards)")) { + printk(KERN_WARNING + "icn: memory at 0x%08lx in use.\n", + a & 0x0ffc000); + return -EINVAL; + } + release_mem_region(a & 0x0ffc000, 0x4000); + icn_stopallcards(); + spin_lock_irqsave(&card->lock, flags); + if (dev.mvalid) { + iounmap(dev.shmem); + release_mem_region(dev.memaddr, 0x4000); + } + dev.mvalid = 0; + dev.memaddr = a & 0x0ffc000; + spin_unlock_irqrestore(&card->lock, flags); + printk(KERN_INFO + "icn: (%s) mmio set to 0x%08lx\n", + CID, + dev.memaddr); + } + break; + case ICN_IOCTL_GETMMIO: + return (long) dev.memaddr; + case ICN_IOCTL_SETPORT: + if (a == 0x300 || a == 0x310 || a == 0x320 || a == 0x330 + || a == 0x340 || a == 0x350 || a == 0x360 || + a == 0x308 || a == 0x318 || a == 0x328 || a == 0x338 + || a == 0x348 || a == 0x358 || a == 0x368) { + if (card->port != (unsigned short) a) { + if (!request_region((unsigned short) a, ICN_PORTLEN, "icn-isdn")) { + printk(KERN_WARNING + "icn: (%s) ports 0x%03x-0x%03x in use.\n", + CID, (int) a, (int) a + ICN_PORTLEN); return -EINVAL; - break; - case ICN_IOCTL_GETPORT: - return (int) card->port; - case ICN_IOCTL_GETDOUBLE: - return (int) card->doubleS0; - case ICN_IOCTL_DEBUGVAR: - if (copy_to_user(arg, - &card, - sizeof(ulong))) - return -EFAULT; - a += sizeof(ulong); - { - ulong l = (ulong) & dev; - if (copy_to_user(arg, - &l, - sizeof(ulong))) - return -EFAULT; } - return 0; - case ICN_IOCTL_LOADBOOT: - if (dev.firstload) { - icn_disable_cards(); - dev.firstload = 0; - } - icn_stopcard(card); - return (icn_loadboot(arg, card)); - case ICN_IOCTL_LOADPROTO: + release_region((unsigned short) a, ICN_PORTLEN); icn_stopcard(card); - if ((i = (icn_loadproto(arg, card)))) - return i; - if (card->doubleS0) - i = icn_loadproto(arg + ICN_CODE_STAGE2, card->other); - return i; - break; - case ICN_IOCTL_ADDCARD: - if (!dev.firstload) - return -EBUSY; - if (copy_from_user(&cdef, - arg, - sizeof(cdef))) - return -EFAULT; - return (icn_addcard(cdef.port, cdef.id1, cdef.id2)); - break; - case ICN_IOCTL_LEASEDCFG: - if (a) { - if (!card->leased) { - card->leased = 1; - while (card->ptype == ISDN_PTYPE_UNKNOWN) { - msleep_interruptible(ICN_BOOT_TIMEOUT1); - } - msleep_interruptible(ICN_BOOT_TIMEOUT1); - sprintf(cbuf, "00;FV2ON\n01;EAZ%c\n02;EAZ%c\n", - (a & 1)?'1':'C', (a & 2)?'2':'C'); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - printk(KERN_INFO - "icn: (%s) Leased-line mode enabled\n", - CID); - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } - } else { - if (card->leased) { - card->leased = 0; - sprintf(cbuf, "00;FV2OFF\n"); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - printk(KERN_INFO - "icn: (%s) Leased-line mode disabled\n", - CID); - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } + spin_lock_irqsave(&card->lock, flags); + if (card->rvalid) + release_region(card->port, ICN_PORTLEN); + card->port = (unsigned short) a; + card->rvalid = 0; + if (card->doubleS0) { + card->other->port = (unsigned short) a; + card->other->rvalid = 0; } - return 0; - default: - return -EINVAL; - } + spin_unlock_irqrestore(&card->lock, flags); + printk(KERN_INFO + "icn: (%s) port set to 0x%03x\n", + CID, card->port); + } + } else + return -EINVAL; break; - case ISDN_CMD_DIAL: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) - break; - if ((c->arg & 255) < ICN_BCH) { - char *p; - char dial[50]; - char dcode[4]; - - a = c->arg; - p = c->parm.setup.phone; - if (*p == 's' || *p == 'S') { - /* Dial for SPV */ - p++; - strcpy(dcode, "SCA"); - } else - /* Normal Dial */ - strcpy(dcode, "CAL"); - strcpy(dial, p); - sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), - dcode, dial, c->parm.setup.si1, - c->parm.setup.si2, c->parm.setup.eazmsn); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + case ICN_IOCTL_GETPORT: + return (int) card->port; + case ICN_IOCTL_GETDOUBLE: + return (int) card->doubleS0; + case ICN_IOCTL_DEBUGVAR: + if (copy_to_user(arg, + &card, + sizeof(ulong))) + return -EFAULT; + a += sizeof(ulong); + { + ulong l = (ulong)&dev; + if (copy_to_user(arg, + &l, + sizeof(ulong))) + return -EFAULT; } + return 0; + case ICN_IOCTL_LOADBOOT: + if (dev.firstload) { + icn_disable_cards(); + dev.firstload = 0; + } + icn_stopcard(card); + return (icn_loadboot(arg, card)); + case ICN_IOCTL_LOADPROTO: + icn_stopcard(card); + if ((i = (icn_loadproto(arg, card)))) + return i; + if (card->doubleS0) + i = icn_loadproto(arg + ICN_CODE_STAGE2, card->other); + return i; + break; + case ICN_IOCTL_ADDCARD: + if (!dev.firstload) + return -EBUSY; + if (copy_from_user(&cdef, + arg, + sizeof(cdef))) + return -EFAULT; + return (icn_addcard(cdef.port, cdef.id1, cdef.id2)); break; - case ISDN_CMD_ACCEPTD: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->fw_rev >= 300) { - switch (card->l2_proto[a - 1]) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BX75\n", (int) a); - break; - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BTRA\n", (int) a); - break; + case ICN_IOCTL_LEASEDCFG: + if (a) { + if (!card->leased) { + card->leased = 1; + while (card->ptype == ISDN_PTYPE_UNKNOWN) { + msleep_interruptible(ICN_BOOT_TIMEOUT1); } + msleep_interruptible(ICN_BOOT_TIMEOUT1); + sprintf(cbuf, "00;FV2ON\n01;EAZ%c\n02;EAZ%c\n", + (a & 1) ? '1' : 'C', (a & 2) ? '2' : 'C'); i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + printk(KERN_INFO + "icn: (%s) Leased-line mode enabled\n", + CID); + cmd.command = ISDN_STAT_RUN; + cmd.driver = card->myid; + cmd.arg = 0; + card->interface.statcallb(&cmd); + } + } else { + if (card->leased) { + card->leased = 0; + sprintf(cbuf, "00;FV2OFF\n"); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + printk(KERN_INFO + "icn: (%s) Leased-line mode disabled\n", + CID); + cmd.command = ISDN_STAT_RUN; + cmd.driver = card->myid; + cmd.arg = 0; + card->interface.statcallb(&cmd); } - sprintf(cbuf, "%02d;DCON_R\n", (int) a); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); } + return 0; + default: + return -EINVAL; + } + break; + case ISDN_CMD_DIAL: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_ACCEPTB: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->fw_rev >= 300) - switch (card->l2_proto[a - 1]) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BCON_R,BX75\n", (int) a); - break; - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BCON_R,BTRA\n", (int) a); - break; - } else - sprintf(cbuf, "%02d;BCON_R\n", (int) a); + if ((c->arg & 255) < ICN_BCH) { + char *p; + char dial[50]; + char dcode[4]; + + a = c->arg; + p = c->parm.setup.phone; + if (*p == 's' || *p == 'S') { + /* Dial for SPV */ + p++; + strcpy(dcode, "SCA"); + } else + /* Normal Dial */ + strcpy(dcode, "CAL"); + strcpy(dial, p); + sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), + dcode, dial, c->parm.setup.si1, + c->parm.setup.si2, c->parm.setup.eazmsn); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_ACCEPTD: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->fw_rev >= 300) { + switch (card->l2_proto[a - 1]) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BX75\n", (int) a); + break; + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BTRA\n", (int) a); + break; + } i = icn_writecmd(cbuf, strlen(cbuf), 0, card); } + sprintf(cbuf, "%02d;DCON_R\n", (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_ACCEPTB: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->fw_rev >= 300) + switch (card->l2_proto[a - 1]) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BCON_R,BX75\n", (int) a); + break; + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BCON_R,BTRA\n", (int) a); + break; + } else + sprintf(cbuf, "%02d;BCON_R\n", (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_HANGUP: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ICN_BCH) { + a = c->arg + 1; + sprintf(cbuf, "%02d;BDIS_R\n%02d;DDIS_R\n", (int) a, (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_SETEAZ: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_HANGUP: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - sprintf(cbuf, "%02d;BDIS_R\n%02d;DDIS_R\n", (int) a, (int) a); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - } + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->ptype == ISDN_PTYPE_EURO) { + sprintf(cbuf, "%02d;MS%s%s\n", (int) a, + c->parm.num[0] ? "N" : "ALL", c->parm.num); + } else + sprintf(cbuf, "%02d;EAZ%s\n", (int) a, + c->parm.num[0] ? (char *)(c->parm.num) : "0123456789"); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_CLREAZ: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_SETEAZ: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->ptype == ISDN_PTYPE_EURO) + sprintf(cbuf, "%02d;MSNC\n", (int) a); + else + sprintf(cbuf, "%02d;EAZC\n", (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_SETL2: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if ((c->arg & 255) < ICN_BCH) { + a = c->arg; + switch (a >> 8) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BX75\n", (int) (a & 255) + 1); break; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->ptype == ISDN_PTYPE_EURO) { - sprintf(cbuf, "%02d;MS%s%s\n", (int) a, - c->parm.num[0] ? "N" : "ALL", c->parm.num); - } else - sprintf(cbuf, "%02d;EAZ%s\n", (int) a, - c->parm.num[0] ? (char *)(c->parm.num) : "0123456789"); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - } - break; - case ISDN_CMD_CLREAZ: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); break; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->ptype == ISDN_PTYPE_EURO) - sprintf(cbuf, "%02d;MSNC\n", (int) a); - else - sprintf(cbuf, "%02d;EAZC\n", (int) a); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - } - break; - case ISDN_CMD_SETL2: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if ((c->arg & 255) < ICN_BCH) { - a = c->arg; - switch (a >> 8) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BX75\n", (int) (a & 255) + 1); - break; - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); - break; - default: - return -EINVAL; - } - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - card->l2_proto[a & 255] = (a >> 8); + default: + return -EINVAL; } - break; - case ISDN_CMD_SETL3: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - return 0; - default: - return -EINVAL; + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + card->l2_proto[a & 255] = (a >> 8); + } + break; + case ISDN_CMD_SETL3: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + return 0; + default: + return -EINVAL; } return 0; } @@ -1454,7 +1454,7 @@ icn_findcard(int driverid) * Wrapper functions for interface to linklevel */ static int -if_command(isdn_ctrl * c) +if_command(isdn_ctrl *c) { icn_card *card = icn_findcard(c->driver); @@ -1537,9 +1537,9 @@ icn_initcard(int port, char *id) card->interface.writecmd = if_writecmd; card->interface.readstat = if_readstatus; card->interface.features = ISDN_FEATURE_L2_X75I | - ISDN_FEATURE_L2_HDLC | - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_UNKNOWN; + ISDN_FEATURE_L2_HDLC | + ISDN_FEATURE_L3_TRANS | + ISDN_FEATURE_P_UNKNOWN; card->ptype = ISDN_PTYPE_UNKNOWN; strlcpy(card->interface.id, id, sizeof(card->interface.id)); card->msg_buf_write = card->msg_buf; @@ -1619,7 +1619,7 @@ icn_setup(char *line) icn_id2 = sid2; } } - return(1); + return (1); } __setup("icn=", icn_setup); #endif /* MODULE */ diff --git a/drivers/isdn/icn/icn.h b/drivers/isdn/icn/icn.h index 7d7245fb0b32..b713466997a0 100644 --- a/drivers/isdn/icn/icn.h +++ b/drivers/isdn/icn/icn.h @@ -54,7 +54,7 @@ typedef struct icn_cdef { /* some useful macros for debugging */ #ifdef ICN_DEBUG_PORT -#define OUTB_P(v,p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n",v,p); outb_p(v,p);} +#define OUTB_P(v, p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n", v, p); outb_p(v, p);} #else #define OUTB_P outb #endif @@ -71,8 +71,8 @@ typedef struct icn_cdef { #define ICN_BOOT_TIMEOUT1 1000 /* Delay for Boot-download (msecs) */ -#define ICN_TIMER_BCREAD (HZ/100) /* B-Channel poll-cycle */ -#define ICN_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle */ +#define ICN_TIMER_BCREAD (HZ / 100) /* B-Channel poll-cycle */ +#define ICN_TIMER_DCREAD (HZ / 2) /* D-Channel poll-cycle */ #define ICN_CODE_STAGE1 4096 /* Size of bootcode */ #define ICN_CODE_STAGE2 65536 /* Size of protocol-code */ @@ -140,7 +140,7 @@ typedef struct icn_card { int myid; /* Driver-Nr. assigned by linklevel */ int rvalid; /* IO-portregion has been requested */ int leased; /* Flag: This Adapter is connected */ - /* to a leased line */ + /* to a leased line */ unsigned short flags; /* Statusflags */ int doubleS0; /* Flag: ICN4B */ int secondhalf; /* Flag: Second half of a doubleS0 */ @@ -197,16 +197,16 @@ static icn_dev dev; /* Macros for accessing ports */ #define ICN_CFG (card->port) -#define ICN_MAPRAM (card->port+1) -#define ICN_RUN (card->port+2) -#define ICN_BANK (card->port+3) +#define ICN_MAPRAM (card->port + 1) +#define ICN_RUN (card->port + 2) +#define ICN_BANK (card->port + 3) /* Return true, if there is a free transmit-buffer */ -#define sbfree (((readb(&dev.shmem->data_control.scns)+1) & 0xf) != \ +#define sbfree (((readb(&dev.shmem->data_control.scns) + 1) & 0xf) != \ readb(&dev.shmem->data_control.scnr)) /* Switch to next transmit-buffer */ -#define sbnext (writeb((readb(&dev.shmem->data_control.scns)+1) & 0xf, \ +#define sbnext (writeb((readb(&dev.shmem->data_control.scns) + 1) & 0xf, \ &dev.shmem->data_control.scns)) /* Shortcuts for transmit-buffer-access */ @@ -220,7 +220,7 @@ static icn_dev dev; readb(&dev.shmem->data_control.ecns)) /* Switch to next receive-buffer */ -#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr)+1) & 0xf, \ +#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr) + 1) & 0xf, \ &dev.shmem->data_control.ecnr)) /* Shortcuts for receive-buffer-access */ @@ -234,18 +234,18 @@ static icn_dev dev; #define cmd_i (dev.shmem->comm_control.pcio_i) /* Return free space in command-buffer */ -#define cmd_free ((readb(&cmd_i)>=readb(&cmd_o))? \ - 0x100-readb(&cmd_i)+readb(&cmd_o): \ - readb(&cmd_o)-readb(&cmd_i)) +#define cmd_free ((readb(&cmd_i) >= readb(&cmd_o)) ? \ + 0x100 - readb(&cmd_i) + readb(&cmd_o) : \ + readb(&cmd_o) - readb(&cmd_i)) /* Shortcuts for message-buffer-access */ #define msg_o (dev.shmem->comm_control.iopc_o) #define msg_i (dev.shmem->comm_control.iopc_i) /* Return length of Message, if avail. */ -#define msg_avail ((readb(&msg_o)>readb(&msg_i))? \ - 0x100-readb(&msg_o)+readb(&msg_i): \ - readb(&msg_i)-readb(&msg_o)) +#define msg_avail ((readb(&msg_o) > readb(&msg_i)) ? \ + 0x100 - readb(&msg_o) + readb(&msg_i) : \ + readb(&msg_i) - readb(&msg_o)) #define CID (card->interface.id) diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c index d497db0a26d0..5405ec644db3 100644 --- a/drivers/isdn/isdnloop/isdnloop.c +++ b/drivers/isdn/isdnloop/isdnloop.c @@ -35,7 +35,7 @@ static int isdnloop_addcard(char *); * channel = channel number */ static void -isdnloop_free_queue(isdnloop_card * card, int channel) +isdnloop_free_queue(isdnloop_card *card, int channel) { struct sk_buff_head *queue = &card->bqueue[channel]; @@ -52,7 +52,7 @@ isdnloop_free_queue(isdnloop_card * card, int channel) * ch = channel number (0-based) */ static void -isdnloop_bchan_send(isdnloop_card * card, int ch) +isdnloop_bchan_send(isdnloop_card *card, int ch) { isdnloop_card *rcard = card->rcard[ch]; int rch = card->rch[ch], len, ack; @@ -66,7 +66,7 @@ isdnloop_bchan_send(isdnloop_card * card, int ch) ack = *(skb->head); /* used as scratch area */ cmd.driver = card->myid; cmd.arg = ch; - if (rcard){ + if (rcard) { rcard->interface.rcvcallb_skb(rcard->myid, rch, skb); } else { printk(KERN_WARNING "isdnloop: no rcard, skb dropped\n"); @@ -119,7 +119,7 @@ isdnloop_pollbchan(unsigned long data) * cmd = pointer to struct to be filled. */ static void -isdnloop_parse_setup(char *setup, isdn_ctrl * cmd) +isdnloop_parse_setup(char *setup, isdn_ctrl *cmd) { char *t = setup; char *s = strchr(t, ','); @@ -138,7 +138,7 @@ isdnloop_parse_setup(char *setup, isdn_ctrl * cmd) cmd->parm.setup.si2 = 0; else cmd->parm.setup.si2 = - simple_strtoul(t, NULL, 10); + simple_strtoul(t, NULL, 10); strlcpy(cmd->parm.setup.eazmsn, s, sizeof(cmd->parm.setup.eazmsn)); cmd->parm.setup.plan = 0; cmd->parm.setup.screen = 0; @@ -166,7 +166,7 @@ static isdnloop_stat isdnloop_stat_table[] = {"E_L1: ACT FAIL", ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {"E_L2: DATA LIN", ISDN_STAT_BHUP, 8}, /* Layer-2 data link lost */ {"E_L1: ACTIVATION FAILED", - ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ + ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {NULL, 0, -1} }; /* *INDENT-ON* */ @@ -183,7 +183,7 @@ static isdnloop_stat isdnloop_stat_table[] = * card = card where message comes from. */ static void -isdnloop_parse_status(u_char * status, int channel, isdnloop_card * card) +isdnloop_parse_status(u_char *status, int channel, isdnloop_card *card) { isdnloop_stat *s = isdnloop_stat_table; int action = -1; @@ -202,69 +202,69 @@ isdnloop_parse_status(u_char * status, int channel, isdnloop_card * card) cmd.driver = card->myid; cmd.arg = channel; switch (action) { - case 1: - /* BCON_x */ - card->flags |= (channel) ? - ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE; - break; - case 2: - /* BDIS_x */ - card->flags &= ~((channel) ? - ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE); - isdnloop_free_queue(card, channel); - break; - case 3: - /* DCAL_I and DSCA_I */ - isdnloop_parse_setup(status + 6, &cmd); - break; - case 4: - /* FCALL */ - sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); - sprintf(cmd.parm.setup.eazmsn, "%d", channel + 1); - cmd.parm.setup.si1 = 7; - cmd.parm.setup.si2 = 0; - cmd.parm.setup.plan = 0; - cmd.parm.setup.screen = 0; - break; - case 5: - /* CIF */ - strlcpy(cmd.parm.num, status + 3, sizeof(cmd.parm.num)); - break; - case 6: - /* AOC */ - snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%d", - (int) simple_strtoul(status + 7, NULL, 16)); - break; - case 7: - /* CAU */ - status += 3; - if (strlen(status) == 4) - snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%s%c%c", - status + 2, *status, *(status + 1)); - else - strlcpy(cmd.parm.num, status + 1, sizeof(cmd.parm.num)); - break; - case 8: - /* Misc Errors on L1 and L2 */ - card->flags &= ~ISDNLOOP_FLAGS_B1ACTIVE; - isdnloop_free_queue(card, 0); - cmd.arg = 0; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_DHUP; - cmd.arg = 0; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_BHUP; - card->flags &= ~ISDNLOOP_FLAGS_B2ACTIVE; - isdnloop_free_queue(card, 1); - cmd.arg = 1; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_DHUP; - cmd.arg = 1; - cmd.driver = card->myid; - break; + case 1: + /* BCON_x */ + card->flags |= (channel) ? + ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE; + break; + case 2: + /* BDIS_x */ + card->flags &= ~((channel) ? + ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE); + isdnloop_free_queue(card, channel); + break; + case 3: + /* DCAL_I and DSCA_I */ + isdnloop_parse_setup(status + 6, &cmd); + break; + case 4: + /* FCALL */ + sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); + sprintf(cmd.parm.setup.eazmsn, "%d", channel + 1); + cmd.parm.setup.si1 = 7; + cmd.parm.setup.si2 = 0; + cmd.parm.setup.plan = 0; + cmd.parm.setup.screen = 0; + break; + case 5: + /* CIF */ + strlcpy(cmd.parm.num, status + 3, sizeof(cmd.parm.num)); + break; + case 6: + /* AOC */ + snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%d", + (int) simple_strtoul(status + 7, NULL, 16)); + break; + case 7: + /* CAU */ + status += 3; + if (strlen(status) == 4) + snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%s%c%c", + status + 2, *status, *(status + 1)); + else + strlcpy(cmd.parm.num, status + 1, sizeof(cmd.parm.num)); + break; + case 8: + /* Misc Errors on L1 and L2 */ + card->flags &= ~ISDNLOOP_FLAGS_B1ACTIVE; + isdnloop_free_queue(card, 0); + cmd.arg = 0; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_DHUP; + cmd.arg = 0; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_BHUP; + card->flags &= ~ISDNLOOP_FLAGS_B2ACTIVE; + isdnloop_free_queue(card, 1); + cmd.arg = 1; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_DHUP; + cmd.arg = 1; + cmd.driver = card->myid; + break; } card->interface.statcallb(&cmd); } @@ -277,7 +277,7 @@ isdnloop_parse_status(u_char * status, int channel, isdnloop_card * card) * c = char to store. */ static void -isdnloop_putmsg(isdnloop_card * card, unsigned char c) +isdnloop_putmsg(isdnloop_card *card, unsigned char c) { ulong flags; @@ -335,7 +335,7 @@ isdnloop_polldchan(unsigned long data) card->imsg[card->iptr] = 0; card->iptr = 0; if (card->imsg[0] == '0' && card->imsg[1] >= '0' && - card->imsg[1] <= '2' && card->imsg[2] == ';') { + card->imsg[1] <= '2' && card->imsg[2] == ';') { ch = (card->imsg[1] - '0') - 1; p = &card->imsg[3]; isdnloop_parse_status(p, ch, card); @@ -397,7 +397,7 @@ isdnloop_polldchan(unsigned long data) * Number of bytes transferred, -E??? on error */ static int -isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card) +isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card *card) { int len = skb->len; unsigned long flags; @@ -440,7 +440,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card) * number of bytes actually transferred. */ static int -isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card * card) +isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card *card) { int count; u_char __user *p; @@ -468,7 +468,7 @@ isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card * card) * 0 on success, 1 on memory squeeze. */ static int -isdnloop_fake(isdnloop_card * card, char *s, int ch) +isdnloop_fake(isdnloop_card *card, char *s, int ch) { struct sk_buff *skb; int len = strlen(s) + ((ch >= 0) ? 3 : 0); @@ -517,7 +517,7 @@ static isdnloop_stat isdnloop_cmd_table[] = * card = pointer to card struct. */ static void -isdnloop_fake_err(isdnloop_card * card) +isdnloop_fake_err(isdnloop_card *card) { char buf[60]; @@ -543,19 +543,19 @@ static u_char ctable_1t[] = * Pointer to buffer containing the assembled message. */ static char * -isdnloop_unicause(isdnloop_card * card, int loc, int cau) +isdnloop_unicause(isdnloop_card *card, int loc, int cau) { static char buf[6]; switch (card->ptype) { - case ISDN_PTYPE_EURO: - sprintf(buf, "E%02X%02X", (loc) ? 4 : 2, ctable_eu[cau]); - break; - case ISDN_PTYPE_1TR6: - sprintf(buf, "%02X44", ctable_1t[cau]); - break; - default: - return ("0000"); + case ISDN_PTYPE_EURO: + sprintf(buf, "E%02X%02X", (loc) ? 4 : 2, ctable_eu[cau]); + break; + case ISDN_PTYPE_1TR6: + sprintf(buf, "%02X44", ctable_1t[cau]); + break; + default: + return ("0000"); } return (buf); } @@ -569,7 +569,7 @@ isdnloop_unicause(isdnloop_card * card, int loc, int cau) * ch = channel (0-based) */ static void -isdnloop_atimeout(isdnloop_card * card, int ch) +isdnloop_atimeout(isdnloop_card *card, int ch) { unsigned long flags; char buf[60]; @@ -615,7 +615,7 @@ isdnloop_atimeout1(unsigned long data) * ch = channel to watch for. */ static void -isdnloop_start_ctimer(isdnloop_card * card, int ch) +isdnloop_start_ctimer(isdnloop_card *card, int ch) { unsigned long flags; @@ -639,7 +639,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch) * ch = channel (0-based). */ static void -isdnloop_kill_ctimer(isdnloop_card * card, int ch) +isdnloop_kill_ctimer(isdnloop_card *card, int ch) { unsigned long flags; @@ -668,7 +668,7 @@ static u_char bit2si[] = * 3 = found matching number but SI does not match. */ static int -isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd) +isdnloop_try_call(isdnloop_card *card, char *p, int lch, isdn_ctrl *cmd) { isdnloop_card *cc = cards; unsigned long flags; @@ -686,19 +686,19 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd) continue; num_match = 0; switch (cc->ptype) { - case ISDN_PTYPE_EURO: - for (i = 0; i < 3; i++) - if (!(strcmp(cc->s0num[i], cmd->parm.setup.phone))) - num_match = 1; - break; - case ISDN_PTYPE_1TR6: - e = cc->eazlist[ch]; - while (*e) { - sprintf(nbuf, "%s%c", cc->s0num[0], *e); - if (!(strcmp(nbuf, cmd->parm.setup.phone))) - num_match = 1; - e++; - } + case ISDN_PTYPE_EURO: + for (i = 0; i < 3; i++) + if (!(strcmp(cc->s0num[i], cmd->parm.setup.phone))) + num_match = 1; + break; + case ISDN_PTYPE_1TR6: + e = cc->eazlist[ch]; + while (*e) { + sprintf(nbuf, "%s%c", cc->s0num[0], *e); + if (!(strcmp(nbuf, cmd->parm.setup.phone))) + num_match = 1; + e++; + } } if (num_match) { spin_lock_irqsave(&card->isdnloop_lock, flags); @@ -741,7 +741,7 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd) * pointer to new phone number. */ static char * -isdnloop_vstphone(isdnloop_card * card, char *phone, int caller) +isdnloop_vstphone(isdnloop_card *card, char *phone, int caller) { int i; static char nphone[30]; @@ -751,22 +751,22 @@ isdnloop_vstphone(isdnloop_card * card, char *phone, int caller) return ""; } switch (card->ptype) { - case ISDN_PTYPE_EURO: - if (caller) { - for (i = 0; i < 2; i++) - if (!(strcmp(card->s0num[i], phone))) - return (phone); - return (card->s0num[0]); - } - return (phone); - break; - case ISDN_PTYPE_1TR6: - if (caller) { - sprintf(nphone, "%s%c", card->s0num[0], phone[0]); - return (nphone); - } else - return (&phone[strlen(phone) - 1]); - break; + case ISDN_PTYPE_EURO: + if (caller) { + for (i = 0; i < 2; i++) + if (!(strcmp(card->s0num[i], phone))) + return (phone); + return (card->s0num[0]); + } + return (phone); + break; + case ISDN_PTYPE_1TR6: + if (caller) { + sprintf(nphone, "%s%c", card->s0num[0], phone[0]); + return (nphone); + } else + return (&phone[strlen(phone) - 1]); + break; } return ""; } @@ -779,7 +779,7 @@ isdnloop_vstphone(isdnloop_card * card, char *phone, int caller) * card = pointer to card struct. */ static void -isdnloop_parse_cmd(isdnloop_card * card) +isdnloop_parse_cmd(isdnloop_card *card) { char *p = card->omsg; isdn_ctrl cmd; @@ -813,141 +813,141 @@ isdnloop_parse_cmd(isdnloop_card * card) if (action == -1) return; switch (action) { - case 1: - /* 0x;BCON_R */ - if (card->rcard[ch - 1]) { - isdnloop_fake(card->rcard[ch - 1], "BCON_I", - card->rch[ch - 1] + 1); - isdnloop_fake(card, "BCON_C", ch); - } - break; - case 17: - /* 0x;BCON_I */ - if (card->rcard[ch - 1]) { - isdnloop_fake(card->rcard[ch - 1], "BCON_C", - card->rch[ch - 1] + 1); - } - break; - case 2: - /* 0x;BDIS_R */ - isdnloop_fake(card, "BDIS_C", ch); - if (card->rcard[ch - 1]) { - isdnloop_fake(card->rcard[ch - 1], "BDIS_I", - card->rch[ch - 1] + 1); - } - break; - case 16: - /* 0x;DCON_R */ - isdnloop_kill_ctimer(card, ch - 1); - if (card->rcard[ch - 1]) { - isdnloop_kill_ctimer(card->rcard[ch - 1], card->rch[ch - 1]); - isdnloop_fake(card->rcard[ch - 1], "DCON_C", - card->rch[ch - 1] + 1); - isdnloop_fake(card, "DCON_C", ch); - } - break; - case 3: - /* 0x;DDIS_R */ - isdnloop_kill_ctimer(card, ch - 1); - if (card->rcard[ch - 1]) { - isdnloop_kill_ctimer(card->rcard[ch - 1], card->rch[ch - 1]); - isdnloop_fake(card->rcard[ch - 1], "DDIS_I", - card->rch[ch - 1] + 1); - card->rcard[ch - 1] = NULL; - } - isdnloop_fake(card, "DDIS_C", ch); - break; - case 4: - /* 0x;DSCA_Rdd,yy,zz,oo */ - if (card->ptype != ISDN_PTYPE_1TR6) { - isdnloop_fake_err(card); - return; - } + case 1: + /* 0x;BCON_R */ + if (card->rcard[ch - 1]) { + isdnloop_fake(card->rcard[ch - 1], "BCON_I", + card->rch[ch - 1] + 1); + isdnloop_fake(card, "BCON_C", ch); + } + break; + case 17: + /* 0x;BCON_I */ + if (card->rcard[ch - 1]) { + isdnloop_fake(card->rcard[ch - 1], "BCON_C", + card->rch[ch - 1] + 1); + } + break; + case 2: + /* 0x;BDIS_R */ + isdnloop_fake(card, "BDIS_C", ch); + if (card->rcard[ch - 1]) { + isdnloop_fake(card->rcard[ch - 1], "BDIS_I", + card->rch[ch - 1] + 1); + } + break; + case 16: + /* 0x;DCON_R */ + isdnloop_kill_ctimer(card, ch - 1); + if (card->rcard[ch - 1]) { + isdnloop_kill_ctimer(card->rcard[ch - 1], card->rch[ch - 1]); + isdnloop_fake(card->rcard[ch - 1], "DCON_C", + card->rch[ch - 1] + 1); + isdnloop_fake(card, "DCON_C", ch); + } + break; + case 3: + /* 0x;DDIS_R */ + isdnloop_kill_ctimer(card, ch - 1); + if (card->rcard[ch - 1]) { + isdnloop_kill_ctimer(card->rcard[ch - 1], card->rch[ch - 1]); + isdnloop_fake(card->rcard[ch - 1], "DDIS_I", + card->rch[ch - 1] + 1); + card->rcard[ch - 1] = NULL; + } + isdnloop_fake(card, "DDIS_C", ch); + break; + case 4: + /* 0x;DSCA_Rdd,yy,zz,oo */ + if (card->ptype != ISDN_PTYPE_1TR6) { + isdnloop_fake_err(card); + return; + } + /* Fall through */ + case 5: + /* 0x;DCAL_Rdd,yy,zz,oo */ + p += 6; + switch (isdnloop_try_call(card, p, ch - 1, &cmd)) { + case 0: + /* Alerting */ + sprintf(buf, "D%s_I%s,%02d,%02d,%s", + (action == 4) ? "SCA" : "CAL", + isdnloop_vstphone(card, cmd.parm.setup.eazmsn, 1), + cmd.parm.setup.si1, + cmd.parm.setup.si2, + isdnloop_vstphone(card->rcard[ch - 1], + cmd.parm.setup.phone, 0)); + isdnloop_fake(card->rcard[ch - 1], buf, card->rch[ch - 1] + 1); /* Fall through */ - case 5: - /* 0x;DCAL_Rdd,yy,zz,oo */ - p += 6; - switch (isdnloop_try_call(card, p, ch - 1, &cmd)) { - case 0: - /* Alerting */ - sprintf(buf, "D%s_I%s,%02d,%02d,%s", - (action == 4) ? "SCA" : "CAL", - isdnloop_vstphone(card, cmd.parm.setup.eazmsn, 1), - cmd.parm.setup.si1, - cmd.parm.setup.si2, - isdnloop_vstphone(card->rcard[ch - 1], - cmd.parm.setup.phone, 0)); - isdnloop_fake(card->rcard[ch - 1], buf, card->rch[ch - 1] + 1); - /* Fall through */ - case 3: - /* si1 does not match, don't alert but start timer */ - isdnloop_start_ctimer(card, ch - 1); - break; - case 1: - /* Remote busy */ - isdnloop_fake(card, "DDIS_I", ch); - sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 1)); - isdnloop_fake(card, buf, ch); - break; - case 2: - /* No such user */ - isdnloop_fake(card, "DDIS_I", ch); - sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 2)); - isdnloop_fake(card, buf, ch); - break; - } - break; - case 6: - /* 0x;EAZC */ - card->eazlist[ch - 1][0] = '\0'; - break; - case 7: - /* 0x;EAZ */ - p += 3; - strcpy(card->eazlist[ch - 1], p); - break; - case 8: - /* 0x;SEEAZ */ - sprintf(buf, "EAZ-LIST: %s", card->eazlist[ch - 1]); - isdnloop_fake(card, buf, ch + 1); - break; - case 9: - /* 0x;MSN */ - break; - case 10: - /* 0x;MSNALL */ - break; - case 11: - /* 0x;SETSIL */ - p += 6; - i = 0; - while (strchr("0157", *p)) { - if (i) - card->sil[ch - 1] |= si2bit[*p - '0']; - i = (*p++ == '0'); - } - if (*p) - isdnloop_fake_err(card); - break; - case 12: - /* 0x;SEESIL */ - sprintf(buf, "SIN-LIST: "); - p = buf + 10; - for (i = 0; i < 3; i++) - if (card->sil[ch - 1] & (1 << i)) - p += sprintf(p, "%02d", bit2si[i]); - isdnloop_fake(card, buf, ch + 1); - break; - case 13: - /* 0x;SILC */ - card->sil[ch - 1] = 0; + case 3: + /* si1 does not match, don't alert but start timer */ + isdnloop_start_ctimer(card, ch - 1); break; - case 14: - /* 00;FV2ON */ + case 1: + /* Remote busy */ + isdnloop_fake(card, "DDIS_I", ch); + sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 1)); + isdnloop_fake(card, buf, ch); break; - case 15: - /* 00;FV2OFF */ + case 2: + /* No such user */ + isdnloop_fake(card, "DDIS_I", ch); + sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 2)); + isdnloop_fake(card, buf, ch); break; + } + break; + case 6: + /* 0x;EAZC */ + card->eazlist[ch - 1][0] = '\0'; + break; + case 7: + /* 0x;EAZ */ + p += 3; + strcpy(card->eazlist[ch - 1], p); + break; + case 8: + /* 0x;SEEAZ */ + sprintf(buf, "EAZ-LIST: %s", card->eazlist[ch - 1]); + isdnloop_fake(card, buf, ch + 1); + break; + case 9: + /* 0x;MSN */ + break; + case 10: + /* 0x;MSNALL */ + break; + case 11: + /* 0x;SETSIL */ + p += 6; + i = 0; + while (strchr("0157", *p)) { + if (i) + card->sil[ch - 1] |= si2bit[*p - '0']; + i = (*p++ == '0'); + } + if (*p) + isdnloop_fake_err(card); + break; + case 12: + /* 0x;SEESIL */ + sprintf(buf, "SIN-LIST: "); + p = buf + 10; + for (i = 0; i < 3; i++) + if (card->sil[ch - 1] & (1 << i)) + p += sprintf(p, "%02d", bit2si[i]); + isdnloop_fake(card, buf, ch + 1); + break; + case 13: + /* 0x;SILC */ + card->sil[ch - 1] = 0; + break; + case 14: + /* 00;FV2ON */ + break; + case 15: + /* 00;FV2OFF */ + break; } } @@ -966,7 +966,7 @@ isdnloop_parse_cmd(isdnloop_card * card) * number of bytes transferred (currently always equals len). */ static int -isdnloop_writecmd(const u_char * buf, int len, int user, isdnloop_card * card) +isdnloop_writecmd(const u_char *buf, int len, int user, isdnloop_card *card) { int xcount = 0; int ocount = 1; @@ -1016,7 +1016,7 @@ isdnloop_writecmd(const u_char * buf, int len, int user, isdnloop_card * card) * Delete card's pending timers, send STOP to linklevel */ static void -isdnloop_stopcard(isdnloop_card * card) +isdnloop_stopcard(isdnloop_card *card) { unsigned long flags; isdn_ctrl cmd; @@ -1061,7 +1061,7 @@ isdnloop_stopallcards(void) * 0 on success, -E??? otherwise. */ static int -isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) +isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp) { unsigned long flags; isdnloop_sdef sdef; @@ -1073,40 +1073,40 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) return -EFAULT; spin_lock_irqsave(&card->isdnloop_lock, flags); switch (sdef.ptype) { - case ISDN_PTYPE_EURO: - if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", - -1)) { - spin_unlock_irqrestore(&card->isdnloop_lock, flags); - return -ENOMEM; - } - card->sil[0] = card->sil[1] = 4; - if (isdnloop_fake(card, "TEI OK", 0)) { - spin_unlock_irqrestore(&card->isdnloop_lock, flags); - return -ENOMEM; - } - for (i = 0; i < 3; i++) - strcpy(card->s0num[i], sdef.num[i]); - break; - case ISDN_PTYPE_1TR6: - if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", - -1)) { - spin_unlock_irqrestore(&card->isdnloop_lock, flags); - return -ENOMEM; - } - card->sil[0] = card->sil[1] = 4; - if (isdnloop_fake(card, "TEI OK", 0)) { - spin_unlock_irqrestore(&card->isdnloop_lock, flags); - return -ENOMEM; - } - strcpy(card->s0num[0], sdef.num[0]); - card->s0num[1][0] = '\0'; - card->s0num[2][0] = '\0'; - break; - default: + case ISDN_PTYPE_EURO: + if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", + -1)) { spin_unlock_irqrestore(&card->isdnloop_lock, flags); - printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n", - sdef.ptype); - return -EINVAL; + return -ENOMEM; + } + card->sil[0] = card->sil[1] = 4; + if (isdnloop_fake(card, "TEI OK", 0)) { + spin_unlock_irqrestore(&card->isdnloop_lock, flags); + return -ENOMEM; + } + for (i = 0; i < 3; i++) + strcpy(card->s0num[i], sdef.num[i]); + break; + case ISDN_PTYPE_1TR6: + if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", + -1)) { + spin_unlock_irqrestore(&card->isdnloop_lock, flags); + return -ENOMEM; + } + card->sil[0] = card->sil[1] = 4; + if (isdnloop_fake(card, "TEI OK", 0)) { + spin_unlock_irqrestore(&card->isdnloop_lock, flags); + return -ENOMEM; + } + strcpy(card->s0num[0], sdef.num[0]); + card->s0num[1][0] = '\0'; + card->s0num[2][0] = '\0'; + break; + default: + spin_unlock_irqrestore(&card->isdnloop_lock, flags); + printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n", + sdef.ptype); + return -EINVAL; } init_timer(&card->st_timer); card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; @@ -1122,7 +1122,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) * Main handler for commands sent by linklevel. */ static int -isdnloop_command(isdn_ctrl * c, isdnloop_card * card) +isdnloop_command(isdn_ctrl *c, isdnloop_card *card) { ulong a; int i; @@ -1131,215 +1131,215 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card) isdnloop_cdef cdef; switch (c->command) { - case ISDN_CMD_IOCTL: - memcpy(&a, c->parm.num, sizeof(ulong)); - switch (c->arg) { - case ISDNLOOP_IOCTL_DEBUGVAR: - return (ulong) card; - case ISDNLOOP_IOCTL_STARTUP: - if (!access_ok(VERIFY_READ, (void *) a, sizeof(isdnloop_sdef))) - return -EFAULT; - return (isdnloop_start(card, (isdnloop_sdef *) a)); - break; - case ISDNLOOP_IOCTL_ADDCARD: - if (copy_from_user((char *)&cdef, - (char *)a, - sizeof(cdef))) - return -EFAULT; - return (isdnloop_addcard(cdef.id1)); - break; - case ISDNLOOP_IOCTL_LEASEDCFG: - if (a) { - if (!card->leased) { - card->leased = 1; - while (card->ptype == ISDN_PTYPE_UNKNOWN) - schedule_timeout_interruptible(10); - schedule_timeout_interruptible(10); - sprintf(cbuf, "00;FV2ON\n01;EAZ1\n02;EAZ2\n"); - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - printk(KERN_INFO - "isdnloop: (%s) Leased-line mode enabled\n", - CID); - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } - } else { - if (card->leased) { - card->leased = 0; - sprintf(cbuf, "00;FV2OFF\n"); - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - printk(KERN_INFO - "isdnloop: (%s) Leased-line mode disabled\n", - CID); - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } - } - return 0; - default: - return -EINVAL; + case ISDN_CMD_IOCTL: + memcpy(&a, c->parm.num, sizeof(ulong)); + switch (c->arg) { + case ISDNLOOP_IOCTL_DEBUGVAR: + return (ulong) card; + case ISDNLOOP_IOCTL_STARTUP: + if (!access_ok(VERIFY_READ, (void *) a, sizeof(isdnloop_sdef))) + return -EFAULT; + return (isdnloop_start(card, (isdnloop_sdef *) a)); + break; + case ISDNLOOP_IOCTL_ADDCARD: + if (copy_from_user((char *)&cdef, + (char *)a, + sizeof(cdef))) + return -EFAULT; + return (isdnloop_addcard(cdef.id1)); + break; + case ISDNLOOP_IOCTL_LEASEDCFG: + if (a) { + if (!card->leased) { + card->leased = 1; + while (card->ptype == ISDN_PTYPE_UNKNOWN) + schedule_timeout_interruptible(10); + schedule_timeout_interruptible(10); + sprintf(cbuf, "00;FV2ON\n01;EAZ1\n02;EAZ2\n"); + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + printk(KERN_INFO + "isdnloop: (%s) Leased-line mode enabled\n", + CID); + cmd.command = ISDN_STAT_RUN; + cmd.driver = card->myid; + cmd.arg = 0; + card->interface.statcallb(&cmd); + } + } else { + if (card->leased) { + card->leased = 0; + sprintf(cbuf, "00;FV2OFF\n"); + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + printk(KERN_INFO + "isdnloop: (%s) Leased-line mode disabled\n", + CID); + cmd.command = ISDN_STAT_RUN; + cmd.driver = card->myid; + cmd.arg = 0; + card->interface.statcallb(&cmd); + } } + return 0; + default: + return -EINVAL; + } + break; + case ISDN_CMD_DIAL: + if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_DIAL: - if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) - break; - if ((c->arg & 255) < ISDNLOOP_BCH) { - char *p; - char dial[50]; - char dcode[4]; - - a = c->arg; - p = c->parm.setup.phone; - if (*p == 's' || *p == 'S') { - /* Dial for SPV */ - p++; - strcpy(dcode, "SCA"); - } else - /* Normal Dial */ - strcpy(dcode, "CAL"); - strcpy(dial, p); - sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), - dcode, dial, c->parm.setup.si1, + if ((c->arg & 255) < ISDNLOOP_BCH) { + char *p; + char dial[50]; + char dcode[4]; + + a = c->arg; + p = c->parm.setup.phone; + if (*p == 's' || *p == 'S') { + /* Dial for SPV */ + p++; + strcpy(dcode, "SCA"); + } else + /* Normal Dial */ + strcpy(dcode, "CAL"); + strcpy(dial, p); + sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), + dcode, dial, c->parm.setup.si1, c->parm.setup.si2, c->parm.setup.eazmsn); + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_ACCEPTD: + if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ISDNLOOP_BCH) { + a = c->arg + 1; + cbuf[0] = 0; + switch (card->l2_proto[a - 1]) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BX75\n", (int) a); + break; +#ifdef CONFIG_ISDN_X25 + case ISDN_PROTO_L2_X25DTE: + sprintf(cbuf, "%02d;BX2T\n", (int) a); + break; + case ISDN_PROTO_L2_X25DCE: + sprintf(cbuf, "%02d;BX2C\n", (int) a); + break; +#endif + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BTRA\n", (int) a); + break; + } + if (strlen(cbuf)) i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + sprintf(cbuf, "%02d;DCON_R\n", (int) a); + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_ACCEPTB: + if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ISDNLOOP_BCH) { + a = c->arg + 1; + switch (card->l2_proto[a - 1]) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BCON_R,BX75\n", (int) a); + break; +#ifdef CONFIG_ISDN_X25 + case ISDN_PROTO_L2_X25DTE: + sprintf(cbuf, "%02d;BCON_R,BX2T\n", (int) a); + break; + case ISDN_PROTO_L2_X25DCE: + sprintf(cbuf, "%02d;BCON_R,BX2C\n", (int) a); + break; +#endif + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BCON_R,BTRA\n", (int) a); + break; + default: + sprintf(cbuf, "%02d;BCON_R\n", (int) a); } + printk(KERN_DEBUG "isdnloop writecmd '%s'\n", cbuf); + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); break; - case ISDN_CMD_ACCEPTD: + case ISDN_CMD_HANGUP: if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) return -ENODEV; if (c->arg < ISDNLOOP_BCH) { a = c->arg + 1; - cbuf[0] = 0; - switch (card->l2_proto[a - 1]) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BX75\n", (int) a); - break; -#ifdef CONFIG_ISDN_X25 - case ISDN_PROTO_L2_X25DTE: - sprintf(cbuf, "%02d;BX2T\n", (int) a); - break; - case ISDN_PROTO_L2_X25DCE: - sprintf(cbuf, "%02d;BX2C\n", (int) a); - break; -#endif - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BTRA\n", (int) a); - break; - } - if (strlen(cbuf)) - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - sprintf(cbuf, "%02d;DCON_R\n", (int) a); + sprintf(cbuf, "%02d;BDIS_R\n%02d;DDIS_R\n", (int) a, (int) a); i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); } break; - case ISDN_CMD_ACCEPTB: + case ISDN_CMD_SETEAZ: if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) return -ENODEV; + if (card->leased) + break; if (c->arg < ISDNLOOP_BCH) { a = c->arg + 1; - switch (card->l2_proto[a - 1]) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BCON_R,BX75\n", (int) a); - break; -#ifdef CONFIG_ISDN_X25 - case ISDN_PROTO_L2_X25DTE: - sprintf(cbuf, "%02d;BCON_R,BX2T\n", (int) a); - break; - case ISDN_PROTO_L2_X25DCE: - sprintf(cbuf, "%02d;BCON_R,BX2C\n", (int) a); - break; -#endif - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BCON_R,BTRA\n", (int) a); - break; - default: - sprintf(cbuf, "%02d;BCON_R\n", (int) a); - } - printk(KERN_DEBUG "isdnloop writecmd '%s'\n", cbuf); + if (card->ptype == ISDN_PTYPE_EURO) { + sprintf(cbuf, "%02d;MS%s%s\n", (int) a, + c->parm.num[0] ? "N" : "ALL", c->parm.num); + } else + sprintf(cbuf, "%02d;EAZ%s\n", (int) a, + c->parm.num[0] ? c->parm.num : (u_char *) "0123456789"); i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - break; - case ISDN_CMD_HANGUP: - if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ISDNLOOP_BCH) { - a = c->arg + 1; - sprintf(cbuf, "%02d;BDIS_R\n%02d;DDIS_R\n", (int) a, (int) a); - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - } - break; - case ISDN_CMD_SETEAZ: - if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) - break; - if (c->arg < ISDNLOOP_BCH) { - a = c->arg + 1; - if (card->ptype == ISDN_PTYPE_EURO) { - sprintf(cbuf, "%02d;MS%s%s\n", (int) a, - c->parm.num[0] ? "N" : "ALL", c->parm.num); - } else - sprintf(cbuf, "%02d;EAZ%s\n", (int) a, - c->parm.num[0] ? c->parm.num : (u_char *) "0123456789"); - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - } - break; + } + break; case ISDN_CMD_CLREAZ: - if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) - break; - if (c->arg < ISDNLOOP_BCH) { - a = c->arg + 1; - if (card->ptype == ISDN_PTYPE_EURO) - sprintf(cbuf, "%02d;MSNC\n", (int) a); - else - sprintf(cbuf, "%02d;EAZC\n", (int) a); - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - } + if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; + if (c->arg < ISDNLOOP_BCH) { + a = c->arg + 1; + if (card->ptype == ISDN_PTYPE_EURO) + sprintf(cbuf, "%02d;MSNC\n", (int) a); + else + sprintf(cbuf, "%02d;EAZC\n", (int) a); + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; case ISDN_CMD_SETL2: - if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) - return -ENODEV; - if ((c->arg & 255) < ISDNLOOP_BCH) { - a = c->arg; - switch (a >> 8) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BX75\n", (int) (a & 255) + 1); - break; + if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) + return -ENODEV; + if ((c->arg & 255) < ISDNLOOP_BCH) { + a = c->arg; + switch (a >> 8) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BX75\n", (int) (a & 255) + 1); + break; #ifdef CONFIG_ISDN_X25 - case ISDN_PROTO_L2_X25DTE: - sprintf(cbuf, "%02d;BX2T\n", (int) (a & 255) + 1); - break; - case ISDN_PROTO_L2_X25DCE: - sprintf(cbuf, "%02d;BX2C\n", (int) (a & 255) + 1); - break; + case ISDN_PROTO_L2_X25DTE: + sprintf(cbuf, "%02d;BX2T\n", (int) (a & 255) + 1); + break; + case ISDN_PROTO_L2_X25DCE: + sprintf(cbuf, "%02d;BX2C\n", (int) (a & 255) + 1); + break; #endif - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); - break; - case ISDN_PROTO_L2_TRANS: - sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); - break; - default: - return -EINVAL; - } - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); - card->l2_proto[a & 255] = (a >> 8); + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); + break; + case ISDN_PROTO_L2_TRANS: + sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); + break; + default: + return -EINVAL; } - break; + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); + card->l2_proto[a & 255] = (a >> 8); + } + break; case ISDN_CMD_SETL3: - if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) - return -ENODEV; - return 0; + if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) + return -ENODEV; + return 0; default: - return -EINVAL; - } + return -EINVAL; + } } return 0; } @@ -1364,7 +1364,7 @@ isdnloop_findcard(int driverid) * Wrapper functions for interface to linklevel */ static int -if_command(isdn_ctrl * c) +if_command(isdn_ctrl *c) { isdnloop_card *card = isdnloop_findcard(c->driver); @@ -1434,12 +1434,12 @@ isdnloop_initcard(char *id) if (!(card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL))) { printk(KERN_WARNING - "isdnloop: (%s) Could not allocate card-struct.\n", id); + "isdnloop: (%s) Could not allocate card-struct.\n", id); return (isdnloop_card *) 0; } card->interface.owner = THIS_MODULE; card->interface.channels = ISDNLOOP_BCH; - card->interface.hl_hdrlen = 1; /* scratch area for storing ack flag*/ + card->interface.hl_hdrlen = 1; /* scratch area for storing ack flag*/ card->interface.maxbufsize = 4000; card->interface.command = if_command; card->interface.writebuf_skb = if_sendbuf; @@ -1447,12 +1447,12 @@ isdnloop_initcard(char *id) card->interface.readstat = if_readstatus; card->interface.features = ISDN_FEATURE_L2_X75I | #ifdef CONFIG_ISDN_X25 - ISDN_FEATURE_L2_X25DTE | - ISDN_FEATURE_L2_X25DCE | + ISDN_FEATURE_L2_X25DTE | + ISDN_FEATURE_L2_X25DCE | #endif - ISDN_FEATURE_L2_HDLC | - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_UNKNOWN; + ISDN_FEATURE_L2_HDLC | + ISDN_FEATURE_L3_TRANS | + ISDN_FEATURE_P_UNKNOWN; card->ptype = ISDN_PTYPE_UNKNOWN; strlcpy(card->interface.id, id, sizeof(card->interface.id)); card->msg_buf_write = card->msg_buf; diff --git a/drivers/isdn/isdnloop/isdnloop.h b/drivers/isdn/isdnloop/isdnloop.h index 0d458a86f529..e9e035552bb4 100644 --- a/drivers/isdn/isdnloop/isdnloop.h +++ b/drivers/isdn/isdnloop/isdnloop.h @@ -55,7 +55,7 @@ typedef struct isdnloop_sdef { #define ISDNLOOP_FLAGS_RBTIMER 8 /* scheduling of B-Channel-poll */ #define ISDNLOOP_TIMER_BCREAD 1 /* B-Channel poll-cycle */ #define ISDNLOOP_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle */ -#define ISDNLOOP_TIMER_ALERTWAIT (10*HZ) /* Alert timeout */ +#define ISDNLOOP_TIMER_ALERTWAIT (10 * HZ) /* Alert timeout */ #define ISDNLOOP_MAX_SQUEUE 65536 /* Max. outstanding send-data */ #define ISDNLOOP_BCH 2 /* channels per card */ @@ -79,7 +79,7 @@ typedef struct isdnloop_card { struct timer_list st_timer; /* Timer for Status-Polls */ struct timer_list rb_timer; /* Timer for B-Channel-Polls */ struct timer_list - c_timer[ISDNLOOP_BCH]; /* Timer for Alerting */ + c_timer[ISDNLOOP_BCH]; /* Timer for Alerting */ int l2_proto[ISDNLOOP_BCH]; /* Current layer-2-protocol */ isdn_if interface; /* Interface to upper layer */ int iptr; /* Index to imsg-buffer */ @@ -92,7 +92,7 @@ typedef struct isdnloop_card { char *msg_buf_end; /* Pointer to end of statusbuffer */ int sndcount[ISDNLOOP_BCH]; /* Byte-counters for B-Ch.-send */ struct sk_buff_head - bqueue[ISDNLOOP_BCH]; /* B-Channel queues */ + bqueue[ISDNLOOP_BCH]; /* B-Channel queues */ struct sk_buff_head dqueue; /* D-Channel queue */ spinlock_t isdnloop_lock; } isdnloop_card; diff --git a/drivers/isdn/mISDN/clock.c b/drivers/isdn/mISDN/clock.c index 7418f2d811d8..693fb7c9b59a 100644 --- a/drivers/isdn/mISDN/clock.c +++ b/drivers/isdn/mISDN/clock.c @@ -13,11 +13,11 @@ * Quick API description: * * A clock source registers using mISDN_register_clock: - * name = text string to name clock source + * name = text string to name clock source * priority = value to priorize clock sources (0 = default) * ctl = callback function to enable/disable clock source * priv = private pointer of clock source - * return = pointer to clock source structure; + * return = pointer to clock source structure; * * Note: Callback 'ctl' can be called before mISDN_register_clock returns! * Also it can be called during mISDN_unregister_clock. @@ -74,14 +74,14 @@ select_iclock(void) /* last used clock source still exists but changes, disable */ if (*debug & DEBUG_CLOCK) printk(KERN_DEBUG "Old clock source '%s' disable.\n", - lastclock->name); + lastclock->name); lastclock->ctl(lastclock->priv, 0); } if (bestclock && bestclock != iclock_current) { /* new clock source selected, enable */ if (*debug & DEBUG_CLOCK) printk(KERN_DEBUG "New clock source '%s' enable.\n", - bestclock->name); + bestclock->name); bestclock->ctl(bestclock->priv, 1); } if (bestclock != iclock_current) { @@ -104,7 +104,7 @@ struct mISDNclock printk(KERN_ERR "%s: No memory for clock entry.\n", __func__); return NULL; } - strncpy(iclock->name, name, sizeof(iclock->name)-1); + strncpy(iclock->name, name, sizeof(iclock->name) - 1); iclock->pri = pri; iclock->priv = priv; iclock->ctl = ctl; @@ -123,13 +123,13 @@ mISDN_unregister_clock(struct mISDNclock *iclock) if (*debug & (DEBUG_CORE | DEBUG_CLOCK)) printk(KERN_DEBUG "%s: %s %d\n", __func__, iclock->name, - iclock->pri); + iclock->pri); write_lock_irqsave(&iclock_lock, flags); if (iclock_current == iclock) { if (*debug & DEBUG_CLOCK) printk(KERN_DEBUG - "Current clock source '%s' unregisters.\n", - iclock->name); + "Current clock source '%s' unregisters.\n", + iclock->name); iclock->ctl(iclock->priv, 0); } list_del(&iclock->list); @@ -149,9 +149,9 @@ mISDN_clock_update(struct mISDNclock *iclock, int samples, struct timeval *tv) write_lock_irqsave(&iclock_lock, flags); if (iclock_current != iclock) { printk(KERN_ERR "%s: '%s' sends us clock updates, but we do " - "listen to '%s'. This is a bug!\n", __func__, - iclock->name, - iclock_current ? iclock_current->name : "nothing"); + "listen to '%s'. This is a bug!\n", __func__, + iclock->name, + iclock_current ? iclock_current->name : "nothing"); iclock->ctl(iclock->priv, 0); write_unlock_irqrestore(&iclock_lock, flags); return; @@ -185,7 +185,7 @@ mISDN_clock_update(struct mISDNclock *iclock, int samples, struct timeval *tv) iclock_tv_valid = 1; if (*debug & DEBUG_CLOCK) printk("Received first clock from source '%s'.\n", - iclock_current ? iclock_current->name : "nothing"); + iclock_current ? iclock_current->name : "nothing"); } write_unlock_irqrestore(&iclock_lock, flags); } @@ -215,4 +215,3 @@ mISDN_clock_get(void) return count; } EXPORT_SYMBOL(mISDN_clock_get); - diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c index afeebb00fe0b..a24530f05db0 100644 --- a/drivers/isdn/mISDN/core.c +++ b/drivers/isdn/mISDN/core.c @@ -38,7 +38,7 @@ static void mISDN_dev_release(struct device *dev) } static ssize_t _show_id(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct mISDNdevice *mdev = dev_to_mISDN(dev); @@ -48,7 +48,7 @@ static ssize_t _show_id(struct device *dev, } static ssize_t _show_nrbchan(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct mISDNdevice *mdev = dev_to_mISDN(dev); @@ -58,7 +58,7 @@ static ssize_t _show_nrbchan(struct device *dev, } static ssize_t _show_d_protocols(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct mISDNdevice *mdev = dev_to_mISDN(dev); @@ -68,7 +68,7 @@ static ssize_t _show_d_protocols(struct device *dev, } static ssize_t _show_b_protocols(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct mISDNdevice *mdev = dev_to_mISDN(dev); @@ -78,7 +78,7 @@ static ssize_t _show_b_protocols(struct device *dev, } static ssize_t _show_protocol(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct mISDNdevice *mdev = dev_to_mISDN(dev); @@ -88,7 +88,7 @@ static ssize_t _show_protocol(struct device *dev, } static ssize_t _show_name(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { strcpy(buf, dev_name(dev)); return strlen(buf); @@ -96,7 +96,7 @@ static ssize_t _show_name(struct device *dev, #if 0 /* hangs */ static ssize_t _set_name(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { int err = 0; char *out = kmalloc(count + 1, GFP_KERNEL); @@ -136,7 +136,7 @@ static struct device_attribute mISDN_dev_attrs[] = { __ATTR(channelmap, S_IRUGO, _show_channelmap, NULL), __ATTR(nrbchan, S_IRUGO, _show_nrbchan, NULL), __ATTR(name, S_IRUGO, _show_name, NULL), -/* __ATTR(name, S_IRUGO|S_IWUSR, _show_name, _set_name), */ +/* __ATTR(name, S_IRUGO | S_IWUSR, _show_name, _set_name), */ {} }; @@ -187,7 +187,7 @@ struct mISDNdevice *get_mdevice(u_int id) { return dev_to_mISDN(class_find_device(&mISDN_class, NULL, &id, - _get_mdevice)); + _get_mdevice)); } static int @@ -221,7 +221,7 @@ get_free_devid(void) int mISDN_register_device(struct mISDNdevice *dev, - struct device *parent, char *name) + struct device *parent, char *name) { int err; @@ -237,7 +237,7 @@ mISDN_register_device(struct mISDNdevice *dev, dev_set_name(&dev->dev, "mISDN%d", dev->id); if (debug & DEBUG_CORE) printk(KERN_DEBUG "mISDN_register %s %d\n", - dev_name(&dev->dev), dev->id); + dev_name(&dev->dev), dev->id); err = create_stack(dev); if (err) goto error1; @@ -265,7 +265,7 @@ void mISDN_unregister_device(struct mISDNdevice *dev) { if (debug & DEBUG_CORE) printk(KERN_DEBUG "mISDN_unregister %s %d\n", - dev_name(&dev->dev), dev->id); + dev_name(&dev->dev), dev->id); /* sysfs_remove_link(&dev->dev.kobj, "device"); */ device_del(&dev->dev); dev_set_drvdata(&dev->dev, NULL); @@ -311,7 +311,7 @@ get_Bprotocol4id(u_int id) if (id < ISDN_P_B_START || id > 63) { printk(KERN_WARNING "%s id not in range %d\n", - __func__, id); + __func__, id); return NULL; } m = 1 << (id & ISDN_P_B_MASK); @@ -326,12 +326,12 @@ mISDN_register_Bprotocol(struct Bprotocol *bp) if (debug & DEBUG_CORE) printk(KERN_DEBUG "%s: %s/%x\n", __func__, - bp->name, bp->Bprotocols); + bp->name, bp->Bprotocols); old = get_Bprotocol4mask(bp->Bprotocols); if (old) { printk(KERN_WARNING - "register duplicate protocol old %s/%x new %s/%x\n", - old->name, old->Bprotocols, bp->name, bp->Bprotocols); + "register duplicate protocol old %s/%x new %s/%x\n", + old->name, old->Bprotocols, bp->name, bp->Bprotocols); return -EBUSY; } write_lock_irqsave(&bp_lock, flags); @@ -348,7 +348,7 @@ mISDN_unregister_Bprotocol(struct Bprotocol *bp) if (debug & DEBUG_CORE) printk(KERN_DEBUG "%s: %s/%x\n", __func__, bp->name, - bp->Bprotocols); + bp->Bprotocols); write_lock_irqsave(&bp_lock, flags); list_del(&bp->list); write_unlock_irqrestore(&bp_lock, flags); @@ -361,7 +361,7 @@ mISDNInit(void) int err; printk(KERN_INFO "Modular ISDN core version %d.%d.%d\n", - MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE); + MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE); mISDN_init_clock(&debug); mISDN_initstack(&debug); err = class_register(&mISDN_class); @@ -406,4 +406,3 @@ static void mISDN_cleanup(void) module_init(mISDNInit); module_exit(mISDN_cleanup); - diff --git a/drivers/isdn/mISDN/core.h b/drivers/isdn/mISDN/core.h index 7ac2f81a812b..52695bb81ee7 100644 --- a/drivers/isdn/mISDN/core.h +++ b/drivers/isdn/mISDN/core.h @@ -45,11 +45,11 @@ extern int get_mdevice_count(void); #define MGR_OPT_NETWORK 25 extern int connect_Bstack(struct mISDNdevice *, struct mISDNchannel *, - u_int, struct sockaddr_mISDN *); + u_int, struct sockaddr_mISDN *); extern int connect_layer1(struct mISDNdevice *, struct mISDNchannel *, - u_int, struct sockaddr_mISDN *); + u_int, struct sockaddr_mISDN *); extern int create_l2entity(struct mISDNdevice *, struct mISDNchannel *, - u_int, struct sockaddr_mISDN *); + u_int, struct sockaddr_mISDN *); extern int create_stack(struct mISDNdevice *); extern int create_teimanager(struct mISDNdevice *); @@ -71,7 +71,7 @@ extern void mISDN_timer_cleanup(void); extern int l1_init(u_int *); extern void l1_cleanup(void); -extern int Isdnl2_Init(u_int *); +extern int Isdnl2_Init(u_int *); extern void Isdnl2_cleanup(void); extern void mISDN_init_clock(u_int *); diff --git a/drivers/isdn/mISDN/dsp.h b/drivers/isdn/mISDN/dsp.h index 8549431430f0..afe4173ae007 100644 --- a/drivers/isdn/mISDN/dsp.h +++ b/drivers/isdn/mISDN/dsp.h @@ -24,8 +24,8 @@ * bit 1 = enable hfc hardware acceleration for all channels * */ -#define DSP_OPT_ULAW (1<<0) -#define DSP_OPT_NOHARDWARE (1<<1) +#define DSP_OPT_ULAW (1 << 0) +#define DSP_OPT_NOHARDWARE (1 << 1) #include #include @@ -97,12 +97,12 @@ struct dsp_conf_member { struct dsp_conf { struct list_head list; u32 id; - /* all cmx stacks with the same ID are - connected */ + /* all cmx stacks with the same ID are + connected */ struct list_head mlist; int software; /* conf is processed by software */ int hardware; /* conf is processed by hardware */ - /* note: if both unset, has only one member */ + /* note: if both unset, has only one member */ }; @@ -122,7 +122,7 @@ struct dsp_dtmf { int hardware; /* dtmf uses hardware decoding */ int size; /* number of bytes in buffer */ signed short buffer[DSP_DTMF_NPOINTS]; - /* buffers one full dtmf frame */ + /* buffers one full dtmf frame */ u8 lastwhat, lastdigit; int count; u8 digits[16]; /* dtmf result */ @@ -189,7 +189,7 @@ struct dsp { u32 conf_id; struct dsp_conf *conf; struct dsp_conf_member - *member; + *member; /* buffer stuff */ int rx_W; /* current write pos for data without timestamp */ @@ -203,7 +203,7 @@ struct dsp { u8 rx_buff[CMX_BUFF_SIZE]; int last_tx; /* if set, we transmitted last poll interval */ int cmx_delay; /* initial delay of buffers, - or 0 for dynamic jitter buffer */ + or 0 for dynamic jitter buffer */ int tx_dejitter; /* if set, dejitter tx buffer */ int tx_data; /* enables tx-data of CMX to upper layer */ @@ -231,7 +231,7 @@ struct dsp { int bf_sync; struct dsp_pipeline - pipeline; + pipeline; }; /* functions */ @@ -253,7 +253,7 @@ extern int dsp_cmx_del_conf(struct dsp_conf *conf); extern void dsp_dtmf_goertzel_init(struct dsp *dsp); extern void dsp_dtmf_hardware(struct dsp *dsp); extern u8 *dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len, - int fmt); + int fmt); extern int dsp_tone(struct dsp *dsp, int tone); extern void dsp_tone_copy(struct dsp *dsp, u8 *data, int len); @@ -270,7 +270,6 @@ extern int dsp_pipeline_init(struct dsp_pipeline *pipeline); extern void dsp_pipeline_destroy(struct dsp_pipeline *pipeline); extern int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg); extern void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data, - int len); + int len); extern void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, - int len, unsigned int txlen); - + int len, unsigned int txlen); diff --git a/drivers/isdn/mISDN/dsp_audio.c b/drivers/isdn/mISDN/dsp_audio.c index b8f18bd09e43..06022952a437 100644 --- a/drivers/isdn/mISDN/dsp_audio.c +++ b/drivers/isdn/mISDN/dsp_audio.c @@ -61,7 +61,7 @@ static inline unsigned char linear2alaw(short int linear) } /* Convert the scaled magnitude to segment number. */ - for (seg = 0; seg < 8; seg++) { + for (seg = 0; seg < 8; seg++) { if (pcm_val <= seg_end[seg]) break; } @@ -263,7 +263,7 @@ dsp_audio_generate_mix_table(void) sample = 32767; if (sample < -32768) sample = -32768; - dsp_audio_mix_law[(i<<8)|j] = + dsp_audio_mix_law[(i << 8) | j] = dsp_audio_s16_to_law[sample & 0xffff]; j++; } @@ -431,4 +431,3 @@ dsp_change_volume(struct sk_buff *skb, int volume) i++; } } - diff --git a/drivers/isdn/mISDN/dsp_biquad.h b/drivers/isdn/mISDN/dsp_biquad.h index 038191bc45f5..c0c933a5d197 100644 --- a/drivers/isdn/mISDN/dsp_biquad.h +++ b/drivers/isdn/mISDN/dsp_biquad.h @@ -38,7 +38,7 @@ struct biquad2_state { }; static inline void biquad2_init(struct biquad2_state *bq, - int32_t gain, int32_t a1, int32_t a2, int32_t b1, int32_t b2) + int32_t gain, int32_t a1, int32_t a2, int32_t b1, int32_t b2) { bq->gain = gain; bq->a1 = a1; @@ -55,8 +55,8 @@ static inline int16_t biquad2(struct biquad2_state *bq, int16_t sample) int32_t y; int32_t z0; - z0 = sample*bq->gain + bq->z1*bq->a1 + bq->z2*bq->a2; - y = z0 + bq->z1*bq->b1 + bq->z2*bq->b2; + z0 = sample * bq->gain + bq->z1 * bq->a1 + bq->z2 * bq->a2; + y = z0 + bq->z1 * bq->b1 + bq->z2 * bq->b2; bq->z2 = bq->z1; bq->z1 = z0 >> 15; diff --git a/drivers/isdn/mISDN/dsp_blowfish.c b/drivers/isdn/mISDN/dsp_blowfish.c index 18e411e95bba..0aa572f3858d 100644 --- a/drivers/isdn/mISDN/dsp_blowfish.c +++ b/drivers/isdn/mISDN/dsp_blowfish.c @@ -354,8 +354,8 @@ static const u32 bf_sbox[256 * 4] = { #define GET32_1(x) (((x) >> (16)) & (0xff)) #define GET32_0(x) (((x) >> (24)) & (0xff)) -#define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \ - S[512 + GET32_2(x)]) + S[768 + GET32_3(x)]) +#define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \ + S[512 + GET32_2(x)]) + S[768 + GET32_3(x)]) #define EROUND(a, b, n) do { b ^= P[n]; a ^= bf_F(b); } while (0) #define DROUND(a, b, n) do { a ^= bf_F(b); b ^= P[n]; } while (0) @@ -388,17 +388,17 @@ dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len) j = 0; /* transcode 9 samples xlaw to 8 bytes */ yl = dsp_audio_law2seven[bf_data_in[0]]; - yl = (yl<<7) | dsp_audio_law2seven[bf_data_in[1]]; - yl = (yl<<7) | dsp_audio_law2seven[bf_data_in[2]]; - yl = (yl<<7) | dsp_audio_law2seven[bf_data_in[3]]; + yl = (yl << 7) | dsp_audio_law2seven[bf_data_in[1]]; + yl = (yl << 7) | dsp_audio_law2seven[bf_data_in[2]]; + yl = (yl << 7) | dsp_audio_law2seven[bf_data_in[3]]; nibble = dsp_audio_law2seven[bf_data_in[4]]; yr = nibble; - yl = (yl<<4) | (nibble>>3); - yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[5]]; - yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[6]]; - yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[7]]; - yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[8]]; - yr = (yr<<1) | (bf_data_in[0] & 1); + yl = (yl << 4) | (nibble >> 3); + yr = (yr << 7) | dsp_audio_law2seven[bf_data_in[5]]; + yr = (yr << 7) | dsp_audio_law2seven[bf_data_in[6]]; + yr = (yr << 7) | dsp_audio_law2seven[bf_data_in[7]]; + yr = (yr << 7) | dsp_audio_law2seven[bf_data_in[8]]; + yr = (yr << 1) | (bf_data_in[0] & 1); /* fill unused bit with random noise of audio input */ /* encrypt */ @@ -423,24 +423,24 @@ dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len) yr ^= P[17]; /* calculate 3-bit checksumme */ - cs = yl ^ (yl>>3) ^ (yl>>6) ^ (yl>>9) ^ (yl>>12) ^ (yl>>15) - ^ (yl>>18) ^ (yl>>21) ^ (yl>>24) ^ (yl>>27) ^ (yl>>30) - ^ (yr<<2) ^ (yr>>1) ^ (yr>>4) ^ (yr>>7) ^ (yr>>10) - ^ (yr>>13) ^ (yr>>16) ^ (yr>>19) ^ (yr>>22) ^ (yr>>25) - ^ (yr>>28) ^ (yr>>31); + cs = yl ^ (yl >> 3) ^ (yl >> 6) ^ (yl >> 9) ^ (yl >> 12) ^ (yl >> 15) + ^ (yl >> 18) ^ (yl >> 21) ^ (yl >> 24) ^ (yl >> 27) ^ (yl >> 30) + ^ (yr << 2) ^ (yr >> 1) ^ (yr >> 4) ^ (yr >> 7) ^ (yr >> 10) + ^ (yr >> 13) ^ (yr >> 16) ^ (yr >> 19) ^ (yr >> 22) ^ (yr >> 25) + ^ (yr >> 28) ^ (yr >> 31); /* * transcode 8 crypted bytes to 9 data bytes with sync * and checksum information */ - bf_crypt_out[0] = (yl>>25) | 0x80; - bf_crypt_out[1] = (yl>>18) & 0x7f; - bf_crypt_out[2] = (yl>>11) & 0x7f; - bf_crypt_out[3] = (yl>>4) & 0x7f; - bf_crypt_out[4] = ((yl<<3) & 0x78) | ((yr>>29) & 0x07); - bf_crypt_out[5] = ((yr>>22) & 0x7f) | ((cs<<5) & 0x80); - bf_crypt_out[6] = ((yr>>15) & 0x7f) | ((cs<<6) & 0x80); - bf_crypt_out[7] = ((yr>>8) & 0x7f) | (cs<<7); + bf_crypt_out[0] = (yl >> 25) | 0x80; + bf_crypt_out[1] = (yl >> 18) & 0x7f; + bf_crypt_out[2] = (yl >> 11) & 0x7f; + bf_crypt_out[3] = (yl >> 4) & 0x7f; + bf_crypt_out[4] = ((yl << 3) & 0x78) | ((yr >> 29) & 0x07); + bf_crypt_out[5] = ((yr >> 22) & 0x7f) | ((cs << 5) & 0x80); + bf_crypt_out[6] = ((yr >> 15) & 0x7f) | ((cs << 6) & 0x80); + bf_crypt_out[7] = ((yr >> 8) & 0x7f) | (cs << 7); bf_crypt_out[8] = yr; } @@ -474,45 +474,45 @@ dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len) * shift upper bit and rotate data to buffer ring * send current decrypted data */ - sync = (sync<<1) | ((*data)>>7); + sync = (sync << 1) | ((*data) >> 7); bf_crypt_inring[j++ & 15] = *data; *data++ = bf_data_out[k++]; i++; if (k == 9) k = 0; /* repeat if no sync has been found */ /* check if not in sync */ - if ((sync&0x1f0) != 0x100) + if ((sync & 0x1f0) != 0x100) continue; j -= 9; /* transcode receive data to 64 bit block of encrypted data */ yl = bf_crypt_inring[j++ & 15]; - yl = (yl<<7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ - yl = (yl<<7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ - yl = (yl<<7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ + yl = (yl << 7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ + yl = (yl << 7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ + yl = (yl << 7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ nibble = bf_crypt_inring[j++ & 15]; /* bit7 = 0 */ yr = nibble; - yl = (yl<<4) | (nibble>>3); + yl = (yl << 4) | (nibble >> 3); cs2 = bf_crypt_inring[j++ & 15]; - yr = (yr<<7) | (cs2 & 0x7f); + yr = (yr << 7) | (cs2 & 0x7f); cs1 = bf_crypt_inring[j++ & 15]; - yr = (yr<<7) | (cs1 & 0x7f); + yr = (yr << 7) | (cs1 & 0x7f); cs0 = bf_crypt_inring[j++ & 15]; - yr = (yr<<7) | (cs0 & 0x7f); - yr = (yr<<8) | bf_crypt_inring[j++ & 15]; + yr = (yr << 7) | (cs0 & 0x7f); + yr = (yr << 8) | bf_crypt_inring[j++ & 15]; /* calculate 3-bit checksumme */ - cs = yl ^ (yl>>3) ^ (yl>>6) ^ (yl>>9) ^ (yl>>12) ^ (yl>>15) - ^ (yl>>18) ^ (yl>>21) ^ (yl>>24) ^ (yl>>27) ^ (yl>>30) - ^ (yr<<2) ^ (yr>>1) ^ (yr>>4) ^ (yr>>7) ^ (yr>>10) - ^ (yr>>13) ^ (yr>>16) ^ (yr>>19) ^ (yr>>22) ^ (yr>>25) - ^ (yr>>28) ^ (yr>>31); + cs = yl ^ (yl >> 3) ^ (yl >> 6) ^ (yl >> 9) ^ (yl >> 12) ^ (yl >> 15) + ^ (yl >> 18) ^ (yl >> 21) ^ (yl >> 24) ^ (yl >> 27) ^ (yl >> 30) + ^ (yr << 2) ^ (yr >> 1) ^ (yr >> 4) ^ (yr >> 7) ^ (yr >> 10) + ^ (yr >> 13) ^ (yr >> 16) ^ (yr >> 19) ^ (yr >> 22) ^ (yr >> 25) + ^ (yr >> 28) ^ (yr >> 31); /* check if frame is valid */ - if ((cs&0x7) != (((cs2>>5)&4) | ((cs1>>6)&2) | (cs0 >> 7))) { + if ((cs & 0x7) != (((cs2 >> 5) & 4) | ((cs1 >> 6) & 2) | (cs0 >> 7))) { if (dsp_debug & DEBUG_DSP_BLOWFISH) printk(KERN_DEBUG - "DSP BLOWFISH: received corrupt frame, " - "checksumme is not correct\n"); + "DSP BLOWFISH: received corrupt frame, " + "checksumme is not correct\n"); continue; } @@ -537,17 +537,17 @@ dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len) DROUND(yr, yl, 0); /* transcode 8 crypted bytes to 9 sample bytes */ - bf_data_out[0] = dsp_audio_seven2law[(yl>>25) & 0x7f]; - bf_data_out[1] = dsp_audio_seven2law[(yl>>18) & 0x7f]; - bf_data_out[2] = dsp_audio_seven2law[(yl>>11) & 0x7f]; - bf_data_out[3] = dsp_audio_seven2law[(yl>>4) & 0x7f]; - bf_data_out[4] = dsp_audio_seven2law[((yl<<3) & 0x78) | - ((yr>>29) & 0x07)]; - - bf_data_out[5] = dsp_audio_seven2law[(yr>>22) & 0x7f]; - bf_data_out[6] = dsp_audio_seven2law[(yr>>15) & 0x7f]; - bf_data_out[7] = dsp_audio_seven2law[(yr>>8) & 0x7f]; - bf_data_out[8] = dsp_audio_seven2law[(yr>>1) & 0x7f]; + bf_data_out[0] = dsp_audio_seven2law[(yl >> 25) & 0x7f]; + bf_data_out[1] = dsp_audio_seven2law[(yl >> 18) & 0x7f]; + bf_data_out[2] = dsp_audio_seven2law[(yl >> 11) & 0x7f]; + bf_data_out[3] = dsp_audio_seven2law[(yl >> 4) & 0x7f]; + bf_data_out[4] = dsp_audio_seven2law[((yl << 3) & 0x78) | + ((yr >> 29) & 0x07)]; + + bf_data_out[5] = dsp_audio_seven2law[(yr >> 22) & 0x7f]; + bf_data_out[6] = dsp_audio_seven2law[(yr >> 15) & 0x7f]; + bf_data_out[7] = dsp_audio_seven2law[(yr >> 8) & 0x7f]; + bf_data_out[8] = dsp_audio_seven2law[(yr >> 1) & 0x7f]; k = 0; /* start with new decoded frame */ } @@ -631,9 +631,9 @@ dsp_bf_init(struct dsp *dsp, const u8 *key, uint keylen) /* Actual subkey generation */ for (j = 0, i = 0; i < 16 + 2; i++) { temp = (((u32)key[j] << 24) | - ((u32)key[(j + 1) % keylen] << 16) | - ((u32)key[(j + 2) % keylen] << 8) | - ((u32)key[(j + 3) % keylen])); + ((u32)key[(j + 1) % keylen] << 16) | + ((u32)key[(j + 2) % keylen] << 8) | + ((u32)key[(j + 3) % keylen])); P[i] = P[i] ^ temp; j = (j + 4) % keylen; diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c index 4d395dea32f3..334feab060a1 100644 --- a/drivers/isdn/mISDN/dsp_cmx.c +++ b/drivers/isdn/mISDN/dsp_cmx.c @@ -165,8 +165,8 @@ dsp_cmx_debug(struct dsp *dsp) printk(KERN_DEBUG "-----Current DSP\n"); list_for_each_entry(odsp, &dsp_ilist, list) { printk(KERN_DEBUG "* %s hardecho=%d softecho=%d txmix=%d", - odsp->name, odsp->echo.hardware, odsp->echo.software, - odsp->tx_mix); + odsp->name, odsp->echo.hardware, odsp->echo.software, + odsp->tx_mix); if (odsp->conf) printk(" (Conf %d)", odsp->conf->id); if (dsp == odsp) @@ -178,14 +178,14 @@ dsp_cmx_debug(struct dsp *dsp) printk(KERN_DEBUG "* Conf %d (%p)\n", conf->id, conf); list_for_each_entry(member, &conf->mlist, list) { printk(KERN_DEBUG - " - member = %s (slot_tx %d, bank_tx %d, " - "slot_rx %d, bank_rx %d hfc_conf %d " - "tx_data %d rx_is_off %d)%s\n", - member->dsp->name, member->dsp->pcm_slot_tx, - member->dsp->pcm_bank_tx, member->dsp->pcm_slot_rx, - member->dsp->pcm_bank_rx, member->dsp->hfc_conf, - member->dsp->tx_data, member->dsp->rx_is_off, - (member->dsp == dsp) ? " *this*" : ""); + " - member = %s (slot_tx %d, bank_tx %d, " + "slot_rx %d, bank_rx %d hfc_conf %d " + "tx_data %d rx_is_off %d)%s\n", + member->dsp->name, member->dsp->pcm_slot_tx, + member->dsp->pcm_bank_tx, member->dsp->pcm_slot_rx, + member->dsp->pcm_bank_rx, member->dsp->hfc_conf, + member->dsp->tx_data, member->dsp->rx_is_off, + (member->dsp == dsp) ? " *this*" : ""); } } printk(KERN_DEBUG "-----end\n"); @@ -227,13 +227,13 @@ dsp_cmx_add_conf_member(struct dsp *dsp, struct dsp_conf *conf) } if (dsp->member) { printk(KERN_WARNING "%s: dsp is already member in a conf.\n", - __func__); + __func__); return -EINVAL; } if (dsp->conf) { printk(KERN_WARNING "%s: dsp is already in a conf.\n", - __func__); + __func__); return -EINVAL; } @@ -268,19 +268,19 @@ dsp_cmx_del_conf_member(struct dsp *dsp) if (!dsp) { printk(KERN_WARNING "%s: dsp is 0.\n", - __func__); + __func__); return -EINVAL; } if (!dsp->conf) { printk(KERN_WARNING "%s: dsp is not in a conf.\n", - __func__); + __func__); return -EINVAL; } if (list_empty(&dsp->conf->mlist)) { printk(KERN_WARNING "%s: dsp has linked an empty conf.\n", - __func__); + __func__); return -EINVAL; } @@ -295,8 +295,8 @@ dsp_cmx_del_conf_member(struct dsp *dsp) } } printk(KERN_WARNING - "%s: dsp is not present in its own conf_meber list.\n", - __func__); + "%s: dsp is not present in its own conf_meber list.\n", + __func__); return -EINVAL; } @@ -312,7 +312,7 @@ static struct dsp_conf if (!id) { printk(KERN_WARNING "%s: id is 0.\n", - __func__); + __func__); return NULL; } @@ -338,13 +338,13 @@ dsp_cmx_del_conf(struct dsp_conf *conf) { if (!conf) { printk(KERN_WARNING "%s: conf is null.\n", - __func__); + __func__); return -EINVAL; } if (!list_empty(&conf->mlist)) { printk(KERN_WARNING "%s: conf not empty.\n", - __func__); + __func__); return -EINVAL; } list_del(&conf->list); @@ -359,7 +359,7 @@ dsp_cmx_del_conf(struct dsp_conf *conf) */ static void dsp_cmx_hw_message(struct dsp *dsp, u32 message, u32 param1, u32 param2, - u32 param3, u32 param4) + u32 param3, u32 param4) { struct mISDN_ctrl_req cq; @@ -389,7 +389,7 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) int freeunits[8]; u_char freeslots[256]; int same_hfc = -1, same_pcm = -1, current_conf = -1, - all_conf = 1, tx_data = 0; + all_conf = 1, tx_data = 0; /* dsp gets updated (no conf) */ if (!conf) { @@ -397,17 +397,17 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) return; if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "%s checking dsp %s\n", - __func__, dsp->name); -one_member: + __func__, dsp->name); + one_member: /* remove HFC conference if enabled */ if (dsp->hfc_conf >= 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s removing %s from HFC conf %d " - "because dsp is split\n", __func__, - dsp->name, dsp->hfc_conf); + "%s removing %s from HFC conf %d " + "because dsp is split\n", __func__, + dsp->name, dsp->hfc_conf); dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_CONF_SPLIT, - 0, 0, 0, 0); + 0, 0, 0, 0); dsp->hfc_conf = -1; } /* process hw echo */ @@ -418,12 +418,12 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (dsp->pcm_slot_tx >= 0 || dsp->pcm_slot_rx >= 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "%s removing %s from" - " PCM slot %d (TX) %d (RX) because" - " dsp is split (no echo)\n", - __func__, dsp->name, - dsp->pcm_slot_tx, dsp->pcm_slot_rx); + " PCM slot %d (TX) %d (RX) because" + " dsp is split (no echo)\n", + __func__, dsp->name, + dsp->pcm_slot_tx, dsp->pcm_slot_rx); dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_DISC, - 0, 0, 0, 0); + 0, 0, 0, 0); dsp->pcm_slot_tx = -1; dsp->pcm_bank_tx = -1; dsp->pcm_slot_rx = -1; @@ -447,11 +447,11 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) dsp->pcm_bank_rx = 2; if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s refresh %s for echo using slot %d\n", - __func__, dsp->name, - dsp->pcm_slot_tx); + "%s refresh %s for echo using slot %d\n", + __func__, dsp->name, + dsp->pcm_slot_tx); dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_CONN, - dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2); + dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2); dsp->echo.hardware = 1; return; } @@ -479,8 +479,8 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (i == ii) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s no slot available for echo\n", - __func__); + "%s no slot available for echo\n", + __func__); /* no more slots available */ dsp->echo.software = 1; return; @@ -492,10 +492,10 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) dsp->pcm_bank_rx = 2; if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s assign echo for %s using slot %d\n", - __func__, dsp->name, dsp->pcm_slot_tx); + "%s assign echo for %s using slot %d\n", + __func__, dsp->name, dsp->pcm_slot_tx); dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_CONN, - dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2); + dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2); dsp->echo.hardware = 1; return; } @@ -503,11 +503,11 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) /* conf gets updated (all members) */ if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "%s checking conference %d\n", - __func__, conf->id); + __func__, conf->id); if (list_empty(&conf->mlist)) { printk(KERN_ERR "%s: conference whithout members\n", - __func__); + __func__); return; } member = list_entry(conf->mlist.next, struct dsp_conf_member, list); @@ -519,25 +519,25 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (member->dsp->tx_mix) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "tx_mix is turned on\n", __func__, - member->dsp->name); -conf_software: + "%s dsp %s cannot form a conf, because " + "tx_mix is turned on\n", __func__, + member->dsp->name); + conf_software: list_for_each_entry(member, &conf->mlist, list) { dsp = member->dsp; /* remove HFC conference if enabled */ if (dsp->hfc_conf >= 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s removing %s from HFC " - "conf %d because not " - "possible with hardware\n", - __func__, - dsp->name, - dsp->hfc_conf); + "%s removing %s from HFC " + "conf %d because not " + "possible with hardware\n", + __func__, + dsp->name, + dsp->hfc_conf); dsp_cmx_hw_message(dsp, - MISDN_CTRL_HFC_CONF_SPLIT, - 0, 0, 0, 0); + MISDN_CTRL_HFC_CONF_SPLIT, + 0, 0, 0, 0); dsp->hfc_conf = -1; } /* remove PCM slot if assigned */ @@ -545,16 +545,16 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) dsp->pcm_slot_rx >= 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "%s removing " - "%s from PCM slot %d (TX)" - " slot %d (RX) because not" - " possible with hardware\n", - __func__, - dsp->name, - dsp->pcm_slot_tx, - dsp->pcm_slot_rx); + "%s from PCM slot %d (TX)" + " slot %d (RX) because not" + " possible with hardware\n", + __func__, + dsp->name, + dsp->pcm_slot_tx, + dsp->pcm_slot_rx); dsp_cmx_hw_message(dsp, - MISDN_CTRL_HFC_PCM_DISC, - 0, 0, 0, 0); + MISDN_CTRL_HFC_PCM_DISC, + 0, 0, 0, 0); dsp->pcm_slot_tx = -1; dsp->pcm_bank_tx = -1; dsp->pcm_slot_rx = -1; @@ -569,79 +569,79 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (member->dsp->echo.hardware || member->dsp->echo.software) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "echo is turned on\n", __func__, - member->dsp->name); + "%s dsp %s cannot form a conf, because " + "echo is turned on\n", __func__, + member->dsp->name); goto conf_software; } /* check if member has tx_mix turned on */ if (member->dsp->tx_mix) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "tx_mix is turned on\n", - __func__, member->dsp->name); + "%s dsp %s cannot form a conf, because " + "tx_mix is turned on\n", + __func__, member->dsp->name); goto conf_software; } /* check if member changes volume at an not suppoted level */ if (member->dsp->tx_volume) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "tx_volume is changed\n", - __func__, member->dsp->name); + "%s dsp %s cannot form a conf, because " + "tx_volume is changed\n", + __func__, member->dsp->name); goto conf_software; } if (member->dsp->rx_volume) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "rx_volume is changed\n", - __func__, member->dsp->name); + "%s dsp %s cannot form a conf, because " + "rx_volume is changed\n", + __func__, member->dsp->name); goto conf_software; } /* check if tx-data turned on */ if (member->dsp->tx_data) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s tx_data is turned on\n", - __func__, member->dsp->name); + "%s dsp %s tx_data is turned on\n", + __func__, member->dsp->name); tx_data = 1; } /* check if pipeline exists */ if (member->dsp->pipeline.inuse) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "pipeline exists\n", __func__, - member->dsp->name); + "%s dsp %s cannot form a conf, because " + "pipeline exists\n", __func__, + member->dsp->name); goto conf_software; } /* check if encryption is enabled */ if (member->dsp->bf_enable) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "%s dsp %s cannot form a " - "conf, because encryption is enabled\n", - __func__, member->dsp->name); + "conf, because encryption is enabled\n", + __func__, member->dsp->name); goto conf_software; } /* check if member is on a card with PCM support */ if (member->dsp->features.pcm_id < 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "dsp has no PCM bus\n", - __func__, member->dsp->name); + "%s dsp %s cannot form a conf, because " + "dsp has no PCM bus\n", + __func__, member->dsp->name); goto conf_software; } /* check if relations are on the same PCM bus */ if (member->dsp->features.pcm_id != same_pcm) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s cannot form a conf, because " - "dsp is on a different PCM bus than the " - "first dsp\n", - __func__, member->dsp->name); + "%s dsp %s cannot form a conf, because " + "dsp is on a different PCM bus than the " + "first dsp\n", + __func__, member->dsp->name); goto conf_software; } /* determine if members are on the same hfc chip */ @@ -665,12 +665,12 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (memb == 1) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s conf %d cannot form a HW conference, " - "because dsp is alone\n", __func__, conf->id); + "%s conf %d cannot form a HW conference, " + "because dsp is alone\n", __func__, conf->id); conf->hardware = 0; conf->software = 0; member = list_entry(conf->mlist.next, struct dsp_conf_member, - list); + list); dsp = member->dsp; goto one_member; } @@ -684,30 +684,30 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) /* if we have only two members */ if (memb == 2) { member = list_entry(conf->mlist.next, struct dsp_conf_member, - list); + list); nextm = list_entry(member->list.next, struct dsp_conf_member, - list); + list); /* remove HFC conference if enabled */ if (member->dsp->hfc_conf >= 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s removing %s from HFC conf %d because " - "two parties require only a PCM slot\n", - __func__, member->dsp->name, - member->dsp->hfc_conf); + "%s removing %s from HFC conf %d because " + "two parties require only a PCM slot\n", + __func__, member->dsp->name, + member->dsp->hfc_conf); dsp_cmx_hw_message(member->dsp, - MISDN_CTRL_HFC_CONF_SPLIT, 0, 0, 0, 0); + MISDN_CTRL_HFC_CONF_SPLIT, 0, 0, 0, 0); member->dsp->hfc_conf = -1; } if (nextm->dsp->hfc_conf >= 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s removing %s from HFC conf %d because " - "two parties require only a PCM slot\n", - __func__, nextm->dsp->name, - nextm->dsp->hfc_conf); + "%s removing %s from HFC conf %d because " + "two parties require only a PCM slot\n", + __func__, nextm->dsp->name, + nextm->dsp->hfc_conf); dsp_cmx_hw_message(nextm->dsp, - MISDN_CTRL_HFC_CONF_SPLIT, 0, 0, 0, 0); + MISDN_CTRL_HFC_CONF_SPLIT, 0, 0, 0, 0); nextm->dsp->hfc_conf = -1; } /* if members have two banks (and not on the same chip) */ @@ -733,15 +733,15 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) /* all members have same slot */ if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s & %s stay joined on " - "PCM slot %d bank %d (TX) bank %d " - "(RX) (on different chips)\n", - __func__, - member->dsp->name, - nextm->dsp->name, - member->dsp->pcm_slot_tx, - member->dsp->pcm_bank_tx, - member->dsp->pcm_bank_rx); + "%s dsp %s & %s stay joined on " + "PCM slot %d bank %d (TX) bank %d " + "(RX) (on different chips)\n", + __func__, + member->dsp->name, + nextm->dsp->name, + member->dsp->pcm_slot_tx, + member->dsp->pcm_bank_tx, + member->dsp->pcm_bank_rx); conf->hardware = 0; conf->software = 1; return; @@ -773,10 +773,10 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (i == ii) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s no slot available for " - "%s & %s\n", __func__, - member->dsp->name, - nextm->dsp->name); + "%s no slot available for " + "%s & %s\n", __func__, + member->dsp->name, + nextm->dsp->name); /* no more slots available */ goto conf_software; } @@ -791,23 +791,23 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) nextm->dsp->pcm_bank_tx = 0; if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s adding %s & %s to new PCM slot %d " - "(TX and RX on different chips) because " - "both members have not same slots\n", - __func__, - member->dsp->name, - nextm->dsp->name, - member->dsp->pcm_slot_tx); + "%s adding %s & %s to new PCM slot %d " + "(TX and RX on different chips) because " + "both members have not same slots\n", + __func__, + member->dsp->name, + nextm->dsp->name, + member->dsp->pcm_slot_tx); dsp_cmx_hw_message(member->dsp, MISDN_CTRL_HFC_PCM_CONN, - member->dsp->pcm_slot_tx, member->dsp->pcm_bank_tx, - member->dsp->pcm_slot_rx, member->dsp->pcm_bank_rx); + member->dsp->pcm_slot_tx, member->dsp->pcm_bank_tx, + member->dsp->pcm_slot_rx, member->dsp->pcm_bank_rx); dsp_cmx_hw_message(nextm->dsp, MISDN_CTRL_HFC_PCM_CONN, - nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx, - nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx); + nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx, + nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx); conf->hardware = 1; conf->software = tx_data; return; - /* if members have one bank (or on the same chip) */ + /* if members have one bank (or on the same chip) */ } else { /* if both members have different crossed slots */ if (member->dsp->pcm_slot_tx >= 0 && @@ -827,13 +827,13 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) /* all members have same slot */ if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s dsp %s & %s stay joined on PCM " - "slot %d (TX) %d (RX) on same chip " - "or one bank PCM)\n", __func__, - member->dsp->name, - nextm->dsp->name, - member->dsp->pcm_slot_tx, - member->dsp->pcm_slot_rx); + "%s dsp %s & %s stay joined on PCM " + "slot %d (TX) %d (RX) on same chip " + "or one bank PCM)\n", __func__, + member->dsp->name, + nextm->dsp->name, + member->dsp->pcm_slot_tx, + member->dsp->pcm_slot_rx); conf->hardware = 0; conf->software = 1; return; @@ -865,14 +865,14 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (i1 == ii) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s no slot available " - "for %s & %s\n", __func__, - member->dsp->name, - nextm->dsp->name); + "%s no slot available " + "for %s & %s\n", __func__, + member->dsp->name, + nextm->dsp->name); /* no more slots available */ goto conf_software; } - i2 = i1+1; + i2 = i1 + 1; while (i2 < ii) { if (freeslots[i2]) break; @@ -881,11 +881,11 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (i2 == ii) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s no slot available " - "for %s & %s\n", - __func__, - member->dsp->name, - nextm->dsp->name); + "%s no slot available " + "for %s & %s\n", + __func__, + member->dsp->name, + nextm->dsp->name); /* no more slots available */ goto conf_software; } @@ -900,20 +900,20 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) nextm->dsp->pcm_bank_tx = 0; if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s adding %s & %s to new PCM slot %d " - "(TX) %d (RX) on same chip or one bank " - "PCM, because both members have not " - "crossed slots\n", __func__, - member->dsp->name, - nextm->dsp->name, - member->dsp->pcm_slot_tx, - member->dsp->pcm_slot_rx); + "%s adding %s & %s to new PCM slot %d " + "(TX) %d (RX) on same chip or one bank " + "PCM, because both members have not " + "crossed slots\n", __func__, + member->dsp->name, + nextm->dsp->name, + member->dsp->pcm_slot_tx, + member->dsp->pcm_slot_rx); dsp_cmx_hw_message(member->dsp, MISDN_CTRL_HFC_PCM_CONN, - member->dsp->pcm_slot_tx, member->dsp->pcm_bank_tx, - member->dsp->pcm_slot_rx, member->dsp->pcm_bank_rx); + member->dsp->pcm_slot_tx, member->dsp->pcm_bank_tx, + member->dsp->pcm_slot_rx, member->dsp->pcm_bank_rx); dsp_cmx_hw_message(nextm->dsp, MISDN_CTRL_HFC_PCM_CONN, - nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx, - nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx); + nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx, + nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx); conf->hardware = 1; conf->software = tx_data; return; @@ -929,10 +929,10 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) if (same_hfc < 0) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s conference %d cannot be formed, because " - "members are on different chips or not " - "on HFC chip\n", - __func__, conf->id); + "%s conference %d cannot be formed, because " + "members are on different chips or not " + "on HFC chip\n", + __func__, conf->id); goto conf_software; } @@ -946,7 +946,7 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) * if there is an existing conference, but not all members have joined */ if (current_conf >= 0) { -join_members: + join_members: list_for_each_entry(member, &conf->mlist, list) { /* if no conference engine on our chip, change to * software */ @@ -966,10 +966,10 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) * slot will be overwritten. */ if ( - dsp != member->dsp && - /* dsp must be on the same PCM */ - member->dsp->features.pcm_id == - dsp->features.pcm_id) { + dsp != member->dsp && + /* dsp must be on the same PCM */ + member->dsp->features.pcm_id == + dsp->features.pcm_id) { /* dsp must be on a slot */ if (dsp->pcm_slot_tx >= 0 && dsp->pcm_slot_tx < @@ -992,16 +992,16 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) /* no more slots available */ if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s conference %d cannot be formed," - " because no slot free\n", - __func__, conf->id); + "%s conference %d cannot be formed," + " because no slot free\n", + __func__, conf->id); goto conf_software; } if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s changing dsp %s to HW conference " - "%d slot %d\n", __func__, - member->dsp->name, current_conf, i); + "%s changing dsp %s to HW conference " + "%d slot %d\n", __func__, + member->dsp->name, current_conf, i); /* assign free slot & set PCM & join conf */ member->dsp->pcm_slot_tx = i; member->dsp->pcm_slot_rx = i; @@ -1009,9 +1009,9 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) member->dsp->pcm_bank_rx = 2; member->dsp->hfc_conf = current_conf; dsp_cmx_hw_message(member->dsp, MISDN_CTRL_HFC_PCM_CONN, - i, 2, i, 2); + i, 2, i, 2); dsp_cmx_hw_message(member->dsp, - MISDN_CTRL_HFC_CONF_JOIN, current_conf, 0, 0, 0); + MISDN_CTRL_HFC_CONF_JOIN, current_conf, 0, 0, 0); } return; } @@ -1040,9 +1040,9 @@ dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp) /* no more conferences available */ if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "%s conference %d cannot be formed, because " - "no conference number free\n", - __func__, conf->id); + "%s conference %d cannot be formed, because " + "no conference number free\n", + __func__, conf->id); goto conf_software; } /* join all members */ @@ -1070,7 +1070,7 @@ dsp_cmx_conf(struct dsp *dsp, u32 conf_id) if (dsp->conf_id) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "removing us from conference %d\n", - dsp->conf->id); + dsp->conf->id); /* remove us from conf */ conf = dsp->conf; err = dsp_cmx_del_conf_member(dsp); @@ -1085,7 +1085,7 @@ dsp_cmx_conf(struct dsp *dsp, u32 conf_id) if (list_empty(&conf->mlist)) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "conference is empty, so we remove it.\n"); + "conference is empty, so we remove it.\n"); err = dsp_cmx_del_conf(conf); if (err) return err; @@ -1102,29 +1102,29 @@ dsp_cmx_conf(struct dsp *dsp, u32 conf_id) /* now add us to conf */ if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG "searching conference %d\n", - conf_id); + conf_id); conf = dsp_cmx_search_conf(conf_id); if (!conf) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "conference doesn't exist yet, creating.\n"); + "conference doesn't exist yet, creating.\n"); /* the conference doesn't exist, so we create */ conf = dsp_cmx_new_conf(conf_id); if (!conf) return -EINVAL; } else if (!list_empty(&conf->mlist)) { member = list_entry(conf->mlist.next, struct dsp_conf_member, - list); + list); if (dsp->hdlc && !member->dsp->hdlc) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "cannot join transparent conference.\n"); + "cannot join transparent conference.\n"); return -EINVAL; } if (!dsp->hdlc && member->dsp->hdlc) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "cannot join hdlc conference.\n"); + "cannot join hdlc conference.\n"); return -EINVAL; } } @@ -1138,7 +1138,7 @@ dsp_cmx_conf(struct dsp *dsp, u32 conf_id) if (list_empty(&conf->mlist)) { if (dsp_debug & DEBUG_DSP_CMX) printk(KERN_DEBUG - "we are alone in this conference, so exit.\n"); + "we are alone in this conference, so exit.\n"); /* update hardware */ dsp_cmx_hardware(NULL, dsp); return 0; @@ -1166,7 +1166,7 @@ showdelay(struct dsp *dsp, int samples, int delay) sdelay = delay * 50 / (dsp_poll << 2); printk(KERN_DEBUG "DELAY (%s) %3d >%s\n", dsp->name, delay, - sdelay > 50 ? "..." : bar + 50 - sdelay); + sdelay > 50 ? "..." : bar + 50 - sdelay); } #endif @@ -1188,9 +1188,9 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb) /* half of the buffer should be larger than maximum packet size */ if (len >= CMX_BUFF_HALF) { printk(KERN_ERR - "%s line %d: packet from card is too large (%d bytes). " - "please make card send smaller packets OR increase " - "CMX_BUFF_SIZE\n", __FILE__, __LINE__, len); + "%s line %d: packet from card is too large (%d bytes). " + "please make card send smaller packets OR increase " + "CMX_BUFF_SIZE\n", __FILE__, __LINE__, len); return; } @@ -1228,9 +1228,9 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb) if (((dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK) >= CMX_BUFF_HALF) { if (dsp_debug & DEBUG_DSP_CLOCK) printk(KERN_DEBUG - "cmx_receive(dsp=%lx): UNDERRUN (or overrun the " - "maximum delay), adjusting read pointer! " - "(inst %s)\n", (u_long)dsp, dsp->name); + "cmx_receive(dsp=%lx): UNDERRUN (or overrun the " + "maximum delay), adjusting read pointer! " + "(inst %s)\n", (u_long)dsp, dsp->name); /* flush rx buffer and set delay to dsp_poll / 2 */ if (dsp->features.unordered) { dsp->rx_R = (hh->id & CMX_BUFF_MASK); @@ -1255,27 +1255,27 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb) (dsp->cmx_delay << 1)) { if (dsp_debug & DEBUG_DSP_CLOCK) printk(KERN_DEBUG - "cmx_receive(dsp=%lx): OVERRUN (because " - "twice the delay is reached), adjusting " - "read pointer! (inst %s)\n", - (u_long)dsp, dsp->name); - /* flush buffer */ - if (dsp->features.unordered) { - dsp->rx_R = (hh->id & CMX_BUFF_MASK); - dsp->rx_W = (dsp->rx_R + dsp->cmx_delay) - & CMX_BUFF_MASK; - } else { - dsp->rx_R = 0; - dsp->rx_W = dsp->cmx_delay; + "cmx_receive(dsp=%lx): OVERRUN (because " + "twice the delay is reached), adjusting " + "read pointer! (inst %s)\n", + (u_long)dsp, dsp->name); + /* flush buffer */ + if (dsp->features.unordered) { + dsp->rx_R = (hh->id & CMX_BUFF_MASK); + dsp->rx_W = (dsp->rx_R + dsp->cmx_delay) + & CMX_BUFF_MASK; + } else { + dsp->rx_R = 0; + dsp->rx_W = dsp->cmx_delay; + } + memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff)); } - memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff)); - } /* show where to write */ #ifdef CMX_DEBUG printk(KERN_DEBUG - "cmx_receive(dsp=%lx): rx_R(dsp)=%05x rx_W(dsp)=%05x len=%d %s\n", - (u_long)dsp, dsp->rx_R, dsp->rx_W, len, dsp->name); + "cmx_receive(dsp=%lx): rx_R(dsp)=%05x rx_W(dsp)=%05x len=%d %s\n", + (u_long)dsp, dsp->rx_R, dsp->rx_W, len, dsp->name); #endif /* write data into rx_buffer */ @@ -1290,7 +1290,7 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb) } /* increase write-pointer */ - dsp->rx_W = ((dsp->rx_W+len) & CMX_BUFF_MASK); + dsp->rx_W = ((dsp->rx_W + len) & CMX_BUFF_MASK); #ifdef CMX_DELAY_DEBUG showdelay(dsp, len, (dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK); #endif @@ -1319,7 +1319,7 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) return; } if (((dsp->conf && dsp->conf->hardware) || /* hardware conf */ - dsp->echo.hardware) && /* OR hardware echo */ + dsp->echo.hardware) && /* OR hardware echo */ dsp->tx_R == dsp->tx_W && /* AND no tx-data */ !(dsp->tone.tone && dsp->tone.software)) { /* AND not soft tones */ if (!dsp->tx_data) { /* no tx_data for user space required */ @@ -1334,8 +1334,8 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) #ifdef CMX_DEBUG printk(KERN_DEBUG - "SEND members=%d dsp=%s, conf=%p, rx_R=%05x rx_W=%05x\n", - members, dsp->name, conf, dsp->rx_R, dsp->rx_W); + "SEND members=%d dsp=%s, conf=%p, rx_R=%05x rx_W=%05x\n", + members, dsp->name, conf, dsp->rx_R, dsp->rx_W); #endif /* preload if we have delay set */ @@ -1349,8 +1349,8 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) nskb = mI_alloc_skb(len + preload, GFP_ATOMIC); if (!nskb) { printk(KERN_ERR - "FATAL ERROR in mISDN_dsp.o: cannot alloc %d bytes\n", - len + preload); + "FATAL ERROR in mISDN_dsp.o: cannot alloc %d bytes\n", + len + preload); return; } hh = mISDN_HEAD_P(nskb); @@ -1386,22 +1386,22 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) if (!dsp->tx_mix && t != tt) { /* -> send tx-data and continue when not enough */ #ifdef CMX_TX_DEBUG - sprintf(debugbuf, "TX sending (%04x-%04x)%p: ", t, tt, p); + sprintf(debugbuf, "TX sending (%04x-%04x)%p: ", t, tt, p); #endif while (r != rr && t != tt) { #ifdef CMX_TX_DEBUG if (strlen(debugbuf) < 48) - sprintf(debugbuf+strlen(debugbuf), " %02x", - p[t]); + sprintf(debugbuf + strlen(debugbuf), " %02x", + p[t]); #endif *d++ = p[t]; /* write tx_buff */ - t = (t+1) & CMX_BUFF_MASK; - r = (r+1) & CMX_BUFF_MASK; + t = (t + 1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; } if (r == rr) { dsp->tx_R = t; #ifdef CMX_TX_DEBUG - printk(KERN_DEBUG "%s\n", debugbuf); + printk(KERN_DEBUG "%s\n", debugbuf); #endif goto send_packet; } @@ -1417,29 +1417,29 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) /* -> send tx-data if available or use 0-volume */ while (r != rr && t != tt) { *d++ = p[t]; /* write tx_buff */ - t = (t+1) & CMX_BUFF_MASK; - r = (r+1) & CMX_BUFF_MASK; + t = (t + 1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; } if (r != rr) { if (dsp_debug & DEBUG_DSP_CLOCK) printk(KERN_DEBUG "%s: RX empty\n", - __func__); - memset(d, dsp_silence, (rr-r)&CMX_BUFF_MASK); + __func__); + memset(d, dsp_silence, (rr - r) & CMX_BUFF_MASK); } - /* -> if echo is enabled */ + /* -> if echo is enabled */ } else { /* * -> mix tx-data with echo if available, * or use echo only */ while (r != rr && t != tt) { - *d++ = dsp_audio_mix_law[(p[t]<<8)|q[r]]; - t = (t+1) & CMX_BUFF_MASK; - r = (r+1) & CMX_BUFF_MASK; + *d++ = dsp_audio_mix_law[(p[t] << 8) | q[r]]; + t = (t + 1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; } while (r != rr) { *d++ = q[r]; /* echo */ - r = (r+1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; } } dsp->tx_R = t; @@ -1449,63 +1449,63 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) #ifdef CMX_CONF_DEBUG if (0) { #else - if (members == 2) { + if (members == 2) { #endif - /* "other" becomes other party */ - other = (list_entry(conf->mlist.next, - struct dsp_conf_member, list))->dsp; - if (other == member) - other = (list_entry(conf->mlist.prev, - struct dsp_conf_member, list))->dsp; - o_q = other->rx_buff; /* received data */ - o_rr = (other->rx_R + len) & CMX_BUFF_MASK; + /* "other" becomes other party */ + other = (list_entry(conf->mlist.next, + struct dsp_conf_member, list))->dsp; + if (other == member) + other = (list_entry(conf->mlist.prev, + struct dsp_conf_member, list))->dsp; + o_q = other->rx_buff; /* received data */ + o_rr = (other->rx_R + len) & CMX_BUFF_MASK; /* end of rx-pointer */ - o_r = (o_rr - rr + r) & CMX_BUFF_MASK; + o_r = (o_rr - rr + r) & CMX_BUFF_MASK; /* start rx-pointer at current read position*/ - /* -> if echo is NOT enabled */ - if (!dsp->echo.software) { - /* - * -> copy other member's rx-data, - * if tx-data is available, mix - */ - while (o_r != o_rr && t != tt) { - *d++ = dsp_audio_mix_law[(p[t]<<8)|o_q[o_r]]; - t = (t+1) & CMX_BUFF_MASK; - o_r = (o_r+1) & CMX_BUFF_MASK; - } - while (o_r != o_rr) { - *d++ = o_q[o_r]; - o_r = (o_r+1) & CMX_BUFF_MASK; - } - /* -> if echo is enabled */ - } else { - /* - * -> mix other member's rx-data with echo, - * if tx-data is available, mix - */ - while (r != rr && t != tt) { - sample = dsp_audio_law_to_s32[p[t]] + - dsp_audio_law_to_s32[q[r]] + - dsp_audio_law_to_s32[o_q[o_r]]; - if (sample < -32768) - sample = -32768; - else if (sample > 32767) - sample = 32767; - *d++ = dsp_audio_s16_to_law[sample & 0xffff]; - /* tx-data + rx_data + echo */ - t = (t+1) & CMX_BUFF_MASK; - r = (r+1) & CMX_BUFF_MASK; - o_r = (o_r+1) & CMX_BUFF_MASK; - } - while (r != rr) { - *d++ = dsp_audio_mix_law[(q[r]<<8)|o_q[o_r]]; - r = (r+1) & CMX_BUFF_MASK; - o_r = (o_r+1) & CMX_BUFF_MASK; + /* -> if echo is NOT enabled */ + if (!dsp->echo.software) { + /* + * -> copy other member's rx-data, + * if tx-data is available, mix + */ + while (o_r != o_rr && t != tt) { + *d++ = dsp_audio_mix_law[(p[t] << 8) | o_q[o_r]]; + t = (t + 1) & CMX_BUFF_MASK; + o_r = (o_r + 1) & CMX_BUFF_MASK; + } + while (o_r != o_rr) { + *d++ = o_q[o_r]; + o_r = (o_r + 1) & CMX_BUFF_MASK; + } + /* -> if echo is enabled */ + } else { + /* + * -> mix other member's rx-data with echo, + * if tx-data is available, mix + */ + while (r != rr && t != tt) { + sample = dsp_audio_law_to_s32[p[t]] + + dsp_audio_law_to_s32[q[r]] + + dsp_audio_law_to_s32[o_q[o_r]]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + *d++ = dsp_audio_s16_to_law[sample & 0xffff]; + /* tx-data + rx_data + echo */ + t = (t + 1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; + o_r = (o_r + 1) & CMX_BUFF_MASK; + } + while (r != rr) { + *d++ = dsp_audio_mix_law[(q[r] << 8) | o_q[o_r]]; + r = (r + 1) & CMX_BUFF_MASK; + o_r = (o_r + 1) & CMX_BUFF_MASK; + } } + dsp->tx_R = t; + goto send_packet; } - dsp->tx_R = t; - goto send_packet; - } #ifdef DSP_NEVER_DEFINED } #endif @@ -1518,15 +1518,15 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) */ while (r != rr && t != tt) { sample = dsp_audio_law_to_s32[p[t]] + *c++ - - dsp_audio_law_to_s32[q[r]]; + dsp_audio_law_to_s32[q[r]]; if (sample < -32768) sample = -32768; else if (sample > 32767) sample = 32767; *d++ = dsp_audio_s16_to_law[sample & 0xffff]; - /* conf-rx+tx */ - r = (r+1) & CMX_BUFF_MASK; - t = (t+1) & CMX_BUFF_MASK; + /* conf-rx+tx */ + r = (r + 1) & CMX_BUFF_MASK; + t = (t + 1) & CMX_BUFF_MASK; } while (r != rr) { sample = *c++ - dsp_audio_law_to_s32[q[r]]; @@ -1535,10 +1535,10 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) else if (sample > 32767) sample = 32767; *d++ = dsp_audio_s16_to_law[sample & 0xffff]; - /* conf-rx */ - r = (r+1) & CMX_BUFF_MASK; + /* conf-rx */ + r = (r + 1) & CMX_BUFF_MASK; } - /* -> if echo is enabled */ + /* -> if echo is enabled */ } else { /* * -> encode conf-data, if tx-data @@ -1551,9 +1551,9 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) else if (sample > 32767) sample = 32767; *d++ = dsp_audio_s16_to_law[sample & 0xffff]; - /* conf(echo)+tx */ - t = (t+1) & CMX_BUFF_MASK; - r = (r+1) & CMX_BUFF_MASK; + /* conf(echo)+tx */ + t = (t + 1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; } while (r != rr) { sample = *c++; @@ -1562,8 +1562,8 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) else if (sample > 32767) sample = 32767; *d++ = dsp_audio_s16_to_law[sample & 0xffff]; - /* conf(echo) */ - r = (r+1) & CMX_BUFF_MASK; + /* conf(echo) */ + r = (r + 1) & CMX_BUFF_MASK; } } dsp->tx_R = t; @@ -1587,14 +1587,14 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) txskb = mI_alloc_skb(len, GFP_ATOMIC); if (!txskb) { printk(KERN_ERR - "FATAL ERROR in mISDN_dsp.o: " - "cannot alloc %d bytes\n", len); + "FATAL ERROR in mISDN_dsp.o: " + "cannot alloc %d bytes\n", len); } else { thh = mISDN_HEAD_P(txskb); thh->prim = DL_DATA_REQ; thh->id = 0; - memcpy(skb_put(txskb, len), nskb->data+preload, - len); + memcpy(skb_put(txskb, len), nskb->data + preload, + len); /* queue (trigger later) */ skb_queue_tail(&dsp->sendq, txskb); } @@ -1608,7 +1608,7 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members) /* pipeline */ if (dsp->pipeline.inuse) dsp_pipeline_process_tx(&dsp->pipeline, nskb->data, - nskb->len); + nskb->len); /* crypt */ if (dsp->bf_enable) dsp_bf_encrypt(dsp, nskb->data, nskb->len); @@ -1621,7 +1621,7 @@ static u32 jittercount; /* counter for jitter check */ struct timer_list dsp_spl_tl; u32 dsp_spl_jiffies; /* calculate the next time to fire */ static u16 dsp_count; /* last sample count */ -static int dsp_count_valid ; /* if we have last sample count */ +static int dsp_count_valid; /* if we have last sample count */ void dsp_cmx_send(void *arg) @@ -1630,7 +1630,7 @@ dsp_cmx_send(void *arg) struct dsp_conf_member *member; struct dsp *dsp; int mustmix, members; - static s32 mixbuffer[MAX_POLL+100]; + static s32 mixbuffer[MAX_POLL + 100]; s32 *c; u8 *p, *q; int r, rr; @@ -1675,9 +1675,9 @@ dsp_cmx_send(void *arg) #ifdef CMX_CONF_DEBUG if (conf->software && members > 1) #else - if (conf->software && members > 2) + if (conf->software && members > 2) #endif - mustmix = 1; + mustmix = 1; } /* transmission required */ @@ -1698,265 +1698,263 @@ dsp_cmx_send(void *arg) #ifdef CMX_CONF_DEBUG if (conf->software && members > 1) { #else - if (conf->software && members > 2) { + if (conf->software && members > 2) { #endif - /* check for hdlc conf */ - member = list_entry(conf->mlist.next, - struct dsp_conf_member, list); - if (member->dsp->hdlc) - continue; - /* mix all data */ - memset(mixbuffer, 0, length*sizeof(s32)); - list_for_each_entry(member, &conf->mlist, list) { - dsp = member->dsp; - /* get range of data to mix */ - c = mixbuffer; - q = dsp->rx_buff; - r = dsp->rx_R; - rr = (r + length) & CMX_BUFF_MASK; - /* add member's data */ - while (r != rr) { - *c++ += dsp_audio_law_to_s32[q[r]]; - r = (r+1) & CMX_BUFF_MASK; + /* check for hdlc conf */ + member = list_entry(conf->mlist.next, + struct dsp_conf_member, list); + if (member->dsp->hdlc) + continue; + /* mix all data */ + memset(mixbuffer, 0, length * sizeof(s32)); + list_for_each_entry(member, &conf->mlist, list) { + dsp = member->dsp; + /* get range of data to mix */ + c = mixbuffer; + q = dsp->rx_buff; + r = dsp->rx_R; + rr = (r + length) & CMX_BUFF_MASK; + /* add member's data */ + while (r != rr) { + *c++ += dsp_audio_law_to_s32[q[r]]; + r = (r + 1) & CMX_BUFF_MASK; + } } - } - - /* process each member */ - list_for_each_entry(member, &conf->mlist, list) { - /* transmission */ - dsp_cmx_send_member(member->dsp, length, - mixbuffer, members); - } - } - } - /* delete rx-data, increment buffers, change pointers */ - list_for_each_entry(dsp, &dsp_ilist, list) { - if (dsp->hdlc) - continue; - p = dsp->rx_buff; - q = dsp->tx_buff; - r = dsp->rx_R; - /* move receive pointer when receiving */ - if (!dsp->rx_is_off) { - rr = (r + length) & CMX_BUFF_MASK; - /* delete rx-data */ - while (r != rr) { - p[r] = dsp_silence; - r = (r+1) & CMX_BUFF_MASK; + /* process each member */ + list_for_each_entry(member, &conf->mlist, list) { + /* transmission */ + dsp_cmx_send_member(member->dsp, length, + mixbuffer, members); + } } - /* increment rx-buffer pointer */ - dsp->rx_R = r; /* write incremented read pointer */ } - /* check current rx_delay */ - delay = (dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK; - if (delay >= CMX_BUFF_HALF) - delay = 0; /* will be the delay before next write */ - /* check for lower delay */ - if (delay < dsp->rx_delay[0]) - dsp->rx_delay[0] = delay; - /* check current tx_delay */ - delay = (dsp->tx_W-dsp->tx_R) & CMX_BUFF_MASK; - if (delay >= CMX_BUFF_HALF) - delay = 0; /* will be the delay before next write */ - /* check for lower delay */ - if (delay < dsp->tx_delay[0]) - dsp->tx_delay[0] = delay; - if (jittercheck) { - /* find the lowest of all rx_delays */ - delay = dsp->rx_delay[0]; - i = 1; - while (i < MAX_SECONDS_JITTER_CHECK) { - if (delay > dsp->rx_delay[i]) - delay = dsp->rx_delay[i]; - i++; - } - /* - * remove rx_delay only if we have delay AND we - * have not preset cmx_delay AND - * the delay is greater dsp_poll - */ - if (delay > dsp_poll && !dsp->cmx_delay) { - if (dsp_debug & DEBUG_DSP_CLOCK) - printk(KERN_DEBUG - "%s lowest rx_delay of %d bytes for" - " dsp %s are now removed.\n", - __func__, delay, - dsp->name); - r = dsp->rx_R; - rr = (r + delay - (dsp_poll >> 1)) - & CMX_BUFF_MASK; + /* delete rx-data, increment buffers, change pointers */ + list_for_each_entry(dsp, &dsp_ilist, list) { + if (dsp->hdlc) + continue; + p = dsp->rx_buff; + q = dsp->tx_buff; + r = dsp->rx_R; + /* move receive pointer when receiving */ + if (!dsp->rx_is_off) { + rr = (r + length) & CMX_BUFF_MASK; /* delete rx-data */ while (r != rr) { p[r] = dsp_silence; - r = (r+1) & CMX_BUFF_MASK; + r = (r + 1) & CMX_BUFF_MASK; } /* increment rx-buffer pointer */ - dsp->rx_R = r; - /* write incremented read pointer */ - } - /* find the lowest of all tx_delays */ - delay = dsp->tx_delay[0]; - i = 1; - while (i < MAX_SECONDS_JITTER_CHECK) { - if (delay > dsp->tx_delay[i]) - delay = dsp->tx_delay[i]; - i++; + dsp->rx_R = r; /* write incremented read pointer */ } - /* - * remove delay only if we have delay AND we - * have enabled tx_dejitter - */ - if (delay > dsp_poll && dsp->tx_dejitter) { - if (dsp_debug & DEBUG_DSP_CLOCK) - printk(KERN_DEBUG - "%s lowest tx_delay of %d bytes for" - " dsp %s are now removed.\n", - __func__, delay, - dsp->name); - r = dsp->tx_R; - rr = (r + delay - (dsp_poll >> 1)) - & CMX_BUFF_MASK; - /* delete tx-data */ - while (r != rr) { - q[r] = dsp_silence; - r = (r+1) & CMX_BUFF_MASK; + + /* check current rx_delay */ + delay = (dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK; + if (delay >= CMX_BUFF_HALF) + delay = 0; /* will be the delay before next write */ + /* check for lower delay */ + if (delay < dsp->rx_delay[0]) + dsp->rx_delay[0] = delay; + /* check current tx_delay */ + delay = (dsp->tx_W-dsp->tx_R) & CMX_BUFF_MASK; + if (delay >= CMX_BUFF_HALF) + delay = 0; /* will be the delay before next write */ + /* check for lower delay */ + if (delay < dsp->tx_delay[0]) + dsp->tx_delay[0] = delay; + if (jittercheck) { + /* find the lowest of all rx_delays */ + delay = dsp->rx_delay[0]; + i = 1; + while (i < MAX_SECONDS_JITTER_CHECK) { + if (delay > dsp->rx_delay[i]) + delay = dsp->rx_delay[i]; + i++; } - /* increment rx-buffer pointer */ - dsp->tx_R = r; - /* write incremented read pointer */ - } - /* scroll up delays */ - i = MAX_SECONDS_JITTER_CHECK - 1; - while (i) { - dsp->rx_delay[i] = dsp->rx_delay[i-1]; - dsp->tx_delay[i] = dsp->tx_delay[i-1]; - i--; + /* + * remove rx_delay only if we have delay AND we + * have not preset cmx_delay AND + * the delay is greater dsp_poll + */ + if (delay > dsp_poll && !dsp->cmx_delay) { + if (dsp_debug & DEBUG_DSP_CLOCK) + printk(KERN_DEBUG + "%s lowest rx_delay of %d bytes for" + " dsp %s are now removed.\n", + __func__, delay, + dsp->name); + r = dsp->rx_R; + rr = (r + delay - (dsp_poll >> 1)) + & CMX_BUFF_MASK; + /* delete rx-data */ + while (r != rr) { + p[r] = dsp_silence; + r = (r + 1) & CMX_BUFF_MASK; + } + /* increment rx-buffer pointer */ + dsp->rx_R = r; + /* write incremented read pointer */ + } + /* find the lowest of all tx_delays */ + delay = dsp->tx_delay[0]; + i = 1; + while (i < MAX_SECONDS_JITTER_CHECK) { + if (delay > dsp->tx_delay[i]) + delay = dsp->tx_delay[i]; + i++; + } + /* + * remove delay only if we have delay AND we + * have enabled tx_dejitter + */ + if (delay > dsp_poll && dsp->tx_dejitter) { + if (dsp_debug & DEBUG_DSP_CLOCK) + printk(KERN_DEBUG + "%s lowest tx_delay of %d bytes for" + " dsp %s are now removed.\n", + __func__, delay, + dsp->name); + r = dsp->tx_R; + rr = (r + delay - (dsp_poll >> 1)) + & CMX_BUFF_MASK; + /* delete tx-data */ + while (r != rr) { + q[r] = dsp_silence; + r = (r + 1) & CMX_BUFF_MASK; + } + /* increment rx-buffer pointer */ + dsp->tx_R = r; + /* write incremented read pointer */ + } + /* scroll up delays */ + i = MAX_SECONDS_JITTER_CHECK - 1; + while (i) { + dsp->rx_delay[i] = dsp->rx_delay[i - 1]; + dsp->tx_delay[i] = dsp->tx_delay[i - 1]; + i--; + } + dsp->tx_delay[0] = CMX_BUFF_HALF; /* (infinite) delay */ + dsp->rx_delay[0] = CMX_BUFF_HALF; /* (infinite) delay */ } - dsp->tx_delay[0] = CMX_BUFF_HALF; /* (infinite) delay */ - dsp->rx_delay[0] = CMX_BUFF_HALF; /* (infinite) delay */ } - } - /* if next event would be in the past ... */ - if ((s32)(dsp_spl_jiffies+dsp_tics-jiffies) <= 0) - dsp_spl_jiffies = jiffies + 1; - else - dsp_spl_jiffies += dsp_tics; + /* if next event would be in the past ... */ + if ((s32)(dsp_spl_jiffies + dsp_tics-jiffies) <= 0) + dsp_spl_jiffies = jiffies + 1; + else + dsp_spl_jiffies += dsp_tics; - dsp_spl_tl.expires = dsp_spl_jiffies; - add_timer(&dsp_spl_tl); + dsp_spl_tl.expires = dsp_spl_jiffies; + add_timer(&dsp_spl_tl); - /* unlock */ - spin_unlock_irqrestore(&dsp_lock, flags); -} + /* unlock */ + spin_unlock_irqrestore(&dsp_lock, flags); + } /* * audio data is transmitted from upper layer to the dsp */ -void -dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb) -{ - u_int w, ww; - u8 *d, *p; - int space; /* todo: , l = skb->len; */ + void + dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb) + { + u_int w, ww; + u8 *d, *p; + int space; /* todo: , l = skb->len; */ #ifdef CMX_TX_DEBUG - char debugbuf[256] = ""; + char debugbuf[256] = ""; #endif - /* check if there is enough space, and then copy */ - w = dsp->tx_W; - ww = dsp->tx_R; - p = dsp->tx_buff; - d = skb->data; - space = (ww - w - 1) & CMX_BUFF_MASK; - /* write-pointer should not overrun nor reach read pointer */ - if (space < skb->len) { - /* write to the space we have left */ - ww = (ww - 1) & CMX_BUFF_MASK; /* end one byte prior tx_R */ - if (dsp_debug & DEBUG_DSP_CLOCK) - printk(KERN_DEBUG "%s: TX overflow space=%d skb->len=" - "%d, w=0x%04x, ww=0x%04x\n", __func__, space, - skb->len, w, ww); - } else - /* write until all byte are copied */ - ww = (w + skb->len) & CMX_BUFF_MASK; - dsp->tx_W = ww; - - /* show current buffer */ + /* check if there is enough space, and then copy */ + w = dsp->tx_W; + ww = dsp->tx_R; + p = dsp->tx_buff; + d = skb->data; + space = (ww - w - 1) & CMX_BUFF_MASK; + /* write-pointer should not overrun nor reach read pointer */ + if (space < skb->len) { + /* write to the space we have left */ + ww = (ww - 1) & CMX_BUFF_MASK; /* end one byte prior tx_R */ + if (dsp_debug & DEBUG_DSP_CLOCK) + printk(KERN_DEBUG "%s: TX overflow space=%d skb->len=" + "%d, w=0x%04x, ww=0x%04x\n", __func__, space, + skb->len, w, ww); + } else + /* write until all byte are copied */ + ww = (w + skb->len) & CMX_BUFF_MASK; + dsp->tx_W = ww; + + /* show current buffer */ #ifdef CMX_DEBUG - printk(KERN_DEBUG - "cmx_transmit(dsp=%lx) %d bytes to 0x%x-0x%x. %s\n", - (u_long)dsp, (ww-w)&CMX_BUFF_MASK, w, ww, dsp->name); + printk(KERN_DEBUG + "cmx_transmit(dsp=%lx) %d bytes to 0x%x-0x%x. %s\n", + (u_long)dsp, (ww - w) & CMX_BUFF_MASK, w, ww, dsp->name); #endif - /* copy transmit data to tx-buffer */ + /* copy transmit data to tx-buffer */ #ifdef CMX_TX_DEBUG - sprintf(debugbuf, "TX getting (%04x-%04x)%p: ", w, ww, p); + sprintf(debugbuf, "TX getting (%04x-%04x)%p: ", w, ww, p); #endif - while (w != ww) { + while (w != ww) { #ifdef CMX_TX_DEBUG - if (strlen(debugbuf) < 48) - sprintf(debugbuf+strlen(debugbuf), " %02x", *d); + if (strlen(debugbuf) < 48) + sprintf(debugbuf + strlen(debugbuf), " %02x", *d); #endif - p[w] = *d++; - w = (w+1) & CMX_BUFF_MASK; - } + p[w] = *d++; + w = (w + 1) & CMX_BUFF_MASK; + } #ifdef CMX_TX_DEBUG - printk(KERN_DEBUG "%s\n", debugbuf); + printk(KERN_DEBUG "%s\n", debugbuf); #endif -} + } /* * hdlc data is received from card and sent to all members. */ -void -dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb) -{ - struct sk_buff *nskb = NULL; - struct dsp_conf_member *member; - struct mISDNhead *hh; - - /* not if not active */ - if (!dsp->b_active) - return; + void + dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb) + { + struct sk_buff *nskb = NULL; + struct dsp_conf_member *member; + struct mISDNhead *hh; + + /* not if not active */ + if (!dsp->b_active) + return; - /* check if we have sompen */ - if (skb->len < 1) - return; + /* check if we have sompen */ + if (skb->len < 1) + return; - /* no conf */ - if (!dsp->conf) { - /* in case of software echo */ - if (dsp->echo.software) { - nskb = skb_clone(skb, GFP_ATOMIC); - if (nskb) { - hh = mISDN_HEAD_P(nskb); - hh->prim = PH_DATA_REQ; - hh->id = 0; - skb_queue_tail(&dsp->sendq, nskb); - schedule_work(&dsp->workq); + /* no conf */ + if (!dsp->conf) { + /* in case of software echo */ + if (dsp->echo.software) { + nskb = skb_clone(skb, GFP_ATOMIC); + if (nskb) { + hh = mISDN_HEAD_P(nskb); + hh->prim = PH_DATA_REQ; + hh->id = 0; + skb_queue_tail(&dsp->sendq, nskb); + schedule_work(&dsp->workq); + } } + return; } - return; - } - /* in case of hardware conference */ - if (dsp->conf->hardware) - return; - list_for_each_entry(member, &dsp->conf->mlist, list) { - if (dsp->echo.software || member->dsp != dsp) { - nskb = skb_clone(skb, GFP_ATOMIC); - if (nskb) { - hh = mISDN_HEAD_P(nskb); - hh->prim = PH_DATA_REQ; - hh->id = 0; - skb_queue_tail(&member->dsp->sendq, nskb); - schedule_work(&member->dsp->workq); + /* in case of hardware conference */ + if (dsp->conf->hardware) + return; + list_for_each_entry(member, &dsp->conf->mlist, list) { + if (dsp->echo.software || member->dsp != dsp) { + nskb = skb_clone(skb, GFP_ATOMIC); + if (nskb) { + hh = mISDN_HEAD_P(nskb); + hh->prim = PH_DATA_REQ; + hh->id = 0; + skb_queue_tail(&member->dsp->sendq, nskb); + schedule_work(&member->dsp->workq); + } } } } -} - - diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c index 742f9f49668c..2ac2d7a25a9f 100644 --- a/drivers/isdn/mISDN/dsp_core.c +++ b/drivers/isdn/mISDN/dsp_core.c @@ -218,20 +218,20 @@ dsp_rx_off_member(struct dsp *dsp) if (!dsp->ch.peer) { if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: no peer, no rx_off\n", - __func__); + __func__); return; } cq.op = MISDN_CTRL_RX_OFF; cq.p1 = rx_off; if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) { printk(KERN_DEBUG "%s: 2nd CONTROL_CHANNEL failed\n", - __func__); + __func__); return; } dsp->rx_is_off = rx_off; if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: %s set rx_off = %d\n", - __func__, dsp->name, rx_off); + __func__, dsp->name, rx_off); } static void dsp_rx_off(struct dsp *dsp) @@ -263,19 +263,19 @@ dsp_fill_empty(struct dsp *dsp) if (!dsp->ch.peer) { if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: no peer, no fill_empty\n", - __func__); + __func__); return; } cq.op = MISDN_CTRL_FILL_EMPTY; cq.p1 = 1; if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) { printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n", - __func__); + __func__); return; } if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: %s set fill_empty = 1\n", - __func__, dsp->name); + __func__, dsp->name); } static int @@ -304,7 +304,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) if (len == sizeof(int)) { if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_NOTICE "changing DTMF Threshold " - "to %d\n", *((int *)data)); + "to %d\n", *((int *)data)); dsp->dtmf.treshold = (*(int *)data) * 10000; } dsp->dtmf.enable = 1; @@ -331,19 +331,19 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) goto conf_split; if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: join conference %d\n", - __func__, *((u32 *)data)); + __func__, *((u32 *)data)); ret = dsp_cmx_conf(dsp, *((u32 *)data)); - /* dsp_cmx_hardware will also be called here */ + /* dsp_cmx_hardware will also be called here */ dsp_rx_off(dsp); if (dsp_debug & DEBUG_DSP_CMX) dsp_cmx_debug(dsp); break; case DSP_CONF_SPLIT: /* remove from conference */ -conf_split: + conf_split: if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: release conference\n", __func__); ret = dsp_cmx_conf(dsp, 0); - /* dsp_cmx_hardware will also be called here */ + /* dsp_cmx_hardware will also be called here */ if (dsp_debug & DEBUG_DSP_CMX) dsp_cmx_debug(dsp); dsp_rx_off(dsp); @@ -359,7 +359,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) } if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: turn tone 0x%x on\n", - __func__, *((int *)skb->data)); + __func__, *((int *)skb->data)); ret = dsp_tone(dsp, *((int *)data)); if (!ret) { dsp_cmx_hardware(dsp->conf, dsp); @@ -379,7 +379,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) dsp_cmx_hardware(dsp->conf, dsp); dsp_rx_off(dsp); /* reset tx buffers (user space data) */ -tone_off: + tone_off: dsp->rx_W = 0; dsp->rx_R = 0; break; @@ -395,7 +395,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) dsp->tx_volume = *((int *)data); if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: change tx vol to %d\n", - __func__, dsp->tx_volume); + __func__, dsp->tx_volume); dsp_cmx_hardware(dsp->conf, dsp); dsp_dtmf_hardware(dsp); dsp_rx_off(dsp); @@ -412,7 +412,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) dsp->rx_volume = *((int *)data); if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: change rx vol to %d\n", - __func__, dsp->tx_volume); + __func__, dsp->tx_volume); dsp_cmx_hardware(dsp->conf, dsp); dsp_dtmf_hardware(dsp); dsp_rx_off(dsp); @@ -439,14 +439,14 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) case DSP_RECEIVE_ON: /* enable receive to user space */ if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: enable receive to user " - "space\n", __func__); + "space\n", __func__); dsp->rx_disabled = 0; dsp_rx_off(dsp); break; case DSP_RECEIVE_OFF: /* disable receive to user space */ if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: disable receive to " - "user space\n", __func__); + "user space\n", __func__); dsp->rx_disabled = 1; dsp_rx_off(dsp); break; @@ -457,7 +457,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) } if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: enable mixing of " - "tx-data with conf mebers\n", __func__); + "tx-data with conf mebers\n", __func__); dsp->tx_mix = 1; dsp_cmx_hardware(dsp->conf, dsp); dsp_rx_off(dsp); @@ -471,7 +471,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) } if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: disable mixing of " - "tx-data with conf mebers\n", __func__); + "tx-data with conf mebers\n", __func__); dsp->tx_mix = 0; dsp_cmx_hardware(dsp->conf, dsp); dsp_rx_off(dsp); @@ -507,18 +507,18 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) break; } dsp->cmx_delay = (*((int *)data)) << 3; - /* milliseconds to samples */ - if (dsp->cmx_delay >= (CMX_BUFF_HALF>>1)) + /* milliseconds to samples */ + if (dsp->cmx_delay >= (CMX_BUFF_HALF >> 1)) /* clip to half of maximum usable buffer - (half of half buffer) */ - dsp->cmx_delay = (CMX_BUFF_HALF>>1) - 1; + (half of half buffer) */ + dsp->cmx_delay = (CMX_BUFF_HALF >> 1) - 1; if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: use delay algorithm to " - "compensate jitter (%d samples)\n", - __func__, dsp->cmx_delay); + "compensate jitter (%d samples)\n", + __func__, dsp->cmx_delay); break; case DSP_JITTER: /* use dynamic jitter algorithm instead of - delay algorithm */ + delay algorithm */ if (dsp->hdlc) { ret = -EINVAL; break; @@ -526,7 +526,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) dsp->cmx_delay = 0; if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: use jitter algorithm to " - "compensate jitter\n", __func__); + "compensate jitter\n", __func__); break; case DSP_TX_DEJITTER: /* use dynamic jitter algorithm for tx-buffer */ if (dsp->hdlc) { @@ -536,7 +536,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) dsp->tx_dejitter = 1; if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: use dejitter on TX " - "buffer\n", __func__); + "buffer\n", __func__); break; case DSP_TX_DEJ_OFF: /* use tx-buffer without dejittering*/ if (dsp->hdlc) { @@ -546,7 +546,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) dsp->tx_dejitter = 0; if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: use TX buffer without " - "dejittering\n", __func__); + "dejittering\n", __func__); break; case DSP_PIPELINE_CFG: if (dsp->hdlc) { @@ -555,13 +555,13 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) } if (len > 0 && ((char *)data)[len - 1]) { printk(KERN_DEBUG "%s: pipeline config string " - "is not NULL terminated!\n", __func__); + "is not NULL terminated!\n", __func__); ret = -EINVAL; } else { dsp->pipeline.inuse = 1; dsp_cmx_hardware(dsp->conf, dsp); ret = dsp_pipeline_build(&dsp->pipeline, - len > 0 ? data : NULL); + len > 0 ? data : NULL); dsp_cmx_hardware(dsp->conf, dsp); dsp_rx_off(dsp); } @@ -577,7 +577,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) } if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: turn blowfish on (key " - "not shown)\n", __func__); + "not shown)\n", __func__); ret = dsp_bf_init(dsp, (u8 *)data, len); /* set new cont */ if (!ret) @@ -586,7 +586,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) cont = DSP_BF_REJECT; /* send indication if it worked to set it */ nskb = _alloc_mISDN_skb(PH_CONTROL_IND, MISDN_ID_ANY, - sizeof(int), &cont, GFP_ATOMIC); + sizeof(int), &cont, GFP_ATOMIC); if (nskb) { if (dsp->up) { if (dsp->up->send(dsp->up, nskb)) @@ -615,7 +615,7 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) default: if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: ctrl req %x unhandled\n", - __func__, cont); + __func__, cont); ret = -EINVAL; } return ret; @@ -630,14 +630,14 @@ get_features(struct mISDNchannel *ch) if (!ch->peer) { if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: no peer, no features\n", - __func__); + __func__); return; } memset(&cq, 0, sizeof(cq)); cq.op = MISDN_CTRL_GETOP; if (ch->peer->ctrl(ch->peer, CONTROL_CHANNEL, &cq) < 0) { printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n", - __func__); + __func__); return; } if (cq.op & MISDN_CTRL_RX_OFF) @@ -651,12 +651,12 @@ get_features(struct mISDNchannel *ch) *((u_long *)&cq.p1) = (u_long)&dsp->features; if (ch->peer->ctrl(ch->peer, CONTROL_CHANNEL, &cq)) { printk(KERN_DEBUG "%s: 2nd CONTROL_CHANNEL failed\n", - __func__); + __func__); } } else if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: features not supported for %s\n", - __func__, dsp->name); + __func__, dsp->name); } static int @@ -670,7 +670,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) hh = mISDN_HEAD_P(skb); switch (hh->prim) { - /* FROM DOWN */ + /* FROM DOWN */ case (PH_DATA_CNF): dsp->data_pending = 0; /* trigger next hdlc frame, if any */ @@ -690,8 +690,8 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) if (dsp->rx_is_off) { if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: rx-data during rx_off" - " for %s\n", - __func__, dsp->name); + " for %s\n", + __func__, dsp->name); } if (dsp->hdlc) { /* hdlc */ @@ -716,14 +716,14 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) /* pipeline */ if (dsp->pipeline.inuse) dsp_pipeline_process_rx(&dsp->pipeline, skb->data, - skb->len, hh->id); + skb->len, hh->id); /* change volume if requested */ if (dsp->rx_volume) dsp_change_volume(skb, dsp->rx_volume); /* check if dtmf soft decoding is turned on */ if (dsp->dtmf.software) { digits = dsp_dtmf_goertzel_decode(dsp, skb->data, - skb->len, (dsp_options&DSP_OPT_ULAW) ? 1 : 0); + skb->len, (dsp_options & DSP_OPT_ULAW) ? 1 : 0); } /* we need to process receive data if software */ if (dsp->conf && dsp->conf->software) { @@ -740,16 +740,16 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) struct sk_buff *nskb; if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "%s: digit" - "(%c) to layer %s\n", - __func__, *digits, dsp->name); + "(%c) to layer %s\n", + __func__, *digits, dsp->name); k = *digits | DTMF_TONE_VAL; nskb = _alloc_mISDN_skb(PH_CONTROL_IND, - MISDN_ID_ANY, sizeof(int), &k, - GFP_ATOMIC); + MISDN_ID_ANY, sizeof(int), &k, + GFP_ATOMIC); if (nskb) { if (dsp->up) { if (dsp->up->send( - dsp->up, nskb)) + dsp->up, nskb)) dev_kfree_skb(nskb); } else dev_kfree_skb(nskb); @@ -768,34 +768,34 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) case (PH_CONTROL_IND): if (dsp_debug & DEBUG_DSP_DTMFCOEFF) printk(KERN_DEBUG "%s: PH_CONTROL INDICATION " - "received: %x (len %d) %s\n", __func__, - hh->id, skb->len, dsp->name); + "received: %x (len %d) %s\n", __func__, + hh->id, skb->len, dsp->name); switch (hh->id) { case (DTMF_HFC_COEF): /* getting coefficients */ if (!dsp->dtmf.hardware) { if (dsp_debug & DEBUG_DSP_DTMFCOEFF) printk(KERN_DEBUG "%s: ignoring DTMF " - "coefficients from HFC\n", - __func__); + "coefficients from HFC\n", + __func__); break; } digits = dsp_dtmf_goertzel_decode(dsp, skb->data, - skb->len, 2); + skb->len, 2); while (*digits) { int k; struct sk_buff *nskb; if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "%s: digit" - "(%c) to layer %s\n", - __func__, *digits, dsp->name); + "(%c) to layer %s\n", + __func__, *digits, dsp->name); k = *digits | DTMF_TONE_VAL; nskb = _alloc_mISDN_skb(PH_CONTROL_IND, - MISDN_ID_ANY, sizeof(int), &k, - GFP_ATOMIC); + MISDN_ID_ANY, sizeof(int), &k, + GFP_ATOMIC); if (nskb) { if (dsp->up) { if (dsp->up->send( - dsp->up, nskb)) + dsp->up, nskb)) dev_kfree_skb(nskb); } else dev_kfree_skb(nskb); @@ -812,7 +812,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) dsp->tx_volume = *((int *)skb->data); if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: change tx volume to " - "%d\n", __func__, dsp->tx_volume); + "%d\n", __func__, dsp->tx_volume); dsp_cmx_hardware(dsp->conf, dsp); dsp_dtmf_hardware(dsp); dsp_rx_off(dsp); @@ -821,7 +821,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) default: if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: ctrl ind %x unhandled " - "%s\n", __func__, hh->id, dsp->name); + "%s\n", __func__, hh->id, dsp->name); ret = -EINVAL; } break; @@ -829,13 +829,13 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) case (PH_ACTIVATE_CNF): if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: b_channel is now active %s\n", - __func__, dsp->name); + __func__, dsp->name); /* bchannel now active */ spin_lock_irqsave(&dsp_lock, flags); dsp->b_active = 1; dsp->data_pending = 0; dsp->rx_init = 1; - /* rx_W and rx_R will be adjusted on first frame */ + /* rx_W and rx_R will be adjusted on first frame */ dsp->rx_W = 0; dsp->rx_R = 0; memset(dsp->rx_buff, 0, sizeof(dsp->rx_buff)); @@ -845,8 +845,8 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) spin_unlock_irqrestore(&dsp_lock, flags); if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: done with activation, sending " - "confirm to user space. %s\n", __func__, - dsp->name); + "confirm to user space. %s\n", __func__, + dsp->name); /* send activation to upper layer */ hh->prim = DL_ESTABLISH_CNF; if (dsp->up) @@ -856,7 +856,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) case (PH_DEACTIVATE_CNF): if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: b_channel is now inactive %s\n", - __func__, dsp->name); + __func__, dsp->name); /* bchannel now inactive */ spin_lock_irqsave(&dsp_lock, flags); dsp->b_active = 0; @@ -868,7 +868,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) if (dsp->up) return dsp->up->send(dsp->up, skb); break; - /* FROM UP */ + /* FROM UP */ case (DL_DATA_REQ): case (PH_DATA_REQ): if (skb->len < 1) { @@ -904,7 +904,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) case (PH_ACTIVATE_REQ): if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: activating b_channel %s\n", - __func__, dsp->name); + __func__, dsp->name); if (dsp->dtmf.hardware || dsp->dtmf.software) dsp_dtmf_goertzel_init(dsp); get_features(ch); @@ -920,7 +920,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) case (PH_DEACTIVATE_REQ): if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: releasing b_channel %s\n", - __func__, dsp->name); + __func__, dsp->name); spin_lock_irqsave(&dsp_lock, flags); dsp->tone.tone = 0; dsp->tone.hardware = 0; @@ -939,7 +939,7 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb) default: if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: msg %x unhandled %s\n", - __func__, hh->prim, dsp->name); + __func__, hh->prim, dsp->name); ret = -EINVAL; } if (!ret) @@ -978,7 +978,7 @@ dsp_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg) skb_queue_purge(&dsp->sendq); if (dsp_debug & DEBUG_DSP_CTRL) printk(KERN_DEBUG "%s: releasing member %s\n", - __func__, dsp->name); + __func__, dsp->name); dsp->b_active = 0; dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be called here */ @@ -986,13 +986,13 @@ dsp_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (dsp_debug & DEBUG_DSP_CTRL) printk(KERN_DEBUG "%s: remove & destroy object %s\n", - __func__, dsp->name); + __func__, dsp->name); list_del(&dsp->list); spin_unlock_irqrestore(&dsp_lock, flags); if (dsp_debug & DEBUG_DSP_CTRL) printk(KERN_DEBUG "%s: dsp instance released\n", - __func__); + __func__); vfree(dsp); module_put(THIS_MODULE); break; @@ -1016,7 +1016,7 @@ dsp_send_bh(struct work_struct *work) if (dsp->data_pending) { if (dsp_debug & DEBUG_DSP_CORE) printk(KERN_DEBUG "%s: fifo full %s, this is " - "no bug!\n", __func__, dsp->name); + "no bug!\n", __func__, dsp->name); /* flush transparent data, if not acked */ dev_kfree_skb(skb); continue; @@ -1050,7 +1050,7 @@ dspcreate(struct channel_req *crq) u_long flags; if (crq->protocol != ISDN_P_B_L2DSP - && crq->protocol != ISDN_P_B_L2DSPHDLC) + && crq->protocol != ISDN_P_B_L2DSPHDLC) return -EPROTONOSUPPORT; ndsp = vzalloc(sizeof(struct dsp)); if (!ndsp) { @@ -1076,7 +1076,7 @@ dspcreate(struct channel_req *crq) } if (!try_module_get(THIS_MODULE)) printk(KERN_WARNING "%s:cannot get module\n", - __func__); + __func__); sprintf(ndsp->name, "DSP_C%x(0x%p)", ndsp->up->st->dev->id + 1, ndsp); @@ -1095,7 +1095,7 @@ dspcreate(struct channel_req *crq) if (dtmfthreshold < 20 || dtmfthreshold > 500) dtmfthreshold = 200; - ndsp->dtmf.treshold = dtmfthreshold*10000; + ndsp->dtmf.treshold = dtmfthreshold * 10000; /* init pipeline append to list */ spin_lock_irqsave(&dsp_lock, flags); @@ -1109,7 +1109,7 @@ dspcreate(struct channel_req *crq) static struct Bprotocol DSP = { .Bprotocols = (1 << (ISDN_P_B_L2DSP & ISDN_P_B_MASK)) - | (1 << (ISDN_P_B_L2DSPHDLC & ISDN_P_B_MASK)), + | (1 << (ISDN_P_B_L2DSPHDLC & ISDN_P_B_MASK)), .name = "dsp", .create = dspcreate }; @@ -1129,21 +1129,21 @@ static int __init dsp_init(void) if (dsp_poll) { if (dsp_poll > MAX_POLL) { printk(KERN_ERR "%s: Wrong poll value (%d), use %d " - "maximum.\n", __func__, poll, MAX_POLL); + "maximum.\n", __func__, poll, MAX_POLL); err = -EINVAL; return err; } if (dsp_poll < 8) { printk(KERN_ERR "%s: Wrong poll value (%d), use 8 " - "minimum.\n", __func__, dsp_poll); + "minimum.\n", __func__, dsp_poll); err = -EINVAL; return err; } dsp_tics = poll * HZ / 8000; if (dsp_tics * 8000 != poll * HZ) { printk(KERN_INFO "mISDN_dsp: Cannot clock every %d " - "samples (0,125 ms). It is not a multiple of " - "%d HZ.\n", poll, HZ); + "samples (0,125 ms). It is not a multiple of " + "%d HZ.\n", poll, HZ); err = -EINVAL; return err; } @@ -1162,14 +1162,14 @@ static int __init dsp_init(void) } if (dsp_poll == 0) { printk(KERN_INFO "mISDN_dsp: There is no multiple of kernel " - "clock that equals exactly the duration of 8-256 " - "samples. (Choose kernel clock speed like 100, 250, " - "300, 1000)\n"); + "clock that equals exactly the duration of 8-256 " + "samples. (Choose kernel clock speed like 100, 250, " + "300, 1000)\n"); err = -EINVAL; return err; } printk(KERN_INFO "mISDN_dsp: DSP clocks every %d samples. This equals " - "%d jiffies.\n", dsp_poll, dsp_tics); + "%d jiffies.\n", dsp_poll, dsp_tics); spin_lock_init(&dsp_lock); INIT_LIST_HEAD(&dsp_ilist); @@ -1177,8 +1177,8 @@ static int __init dsp_init(void) /* init conversion tables */ dsp_audio_generate_law_tables(); - dsp_silence = (dsp_options&DSP_OPT_ULAW) ? 0xff : 0x2a; - dsp_audio_law_to_s32 = (dsp_options&DSP_OPT_ULAW) ? + dsp_silence = (dsp_options & DSP_OPT_ULAW) ? 0xff : 0x2a; + dsp_audio_law_to_s32 = (dsp_options & DSP_OPT_ULAW) ? dsp_audio_ulaw_to_s32 : dsp_audio_alaw_to_s32; dsp_audio_generate_s2law_table(); dsp_audio_generate_seven(); @@ -1190,7 +1190,7 @@ static int __init dsp_init(void) err = dsp_pipeline_module_init(); if (err) { printk(KERN_ERR "mISDN_dsp: Can't initialize pipeline, " - "error(%d)\n", err); + "error(%d)\n", err); return err; } @@ -1221,11 +1221,11 @@ static void __exit dsp_cleanup(void) if (!list_empty(&dsp_ilist)) { printk(KERN_ERR "mISDN_dsp: Audio DSP object inst list not " - "empty.\n"); + "empty.\n"); } if (!list_empty(&conf_ilist)) { printk(KERN_ERR "mISDN_dsp: Conference list not empty. Not " - "all memory freed.\n"); + "all memory freed.\n"); } dsp_pipeline_module_exit(); @@ -1233,4 +1233,3 @@ static void __exit dsp_cleanup(void) module_init(dsp_init); module_exit(dsp_cleanup); - diff --git a/drivers/isdn/mISDN/dsp_dtmf.c b/drivers/isdn/mISDN/dsp_dtmf.c index 5b484c3f4af6..887860bdc63b 100644 --- a/drivers/isdn/mISDN/dsp_dtmf.c +++ b/drivers/isdn/mISDN/dsp_dtmf.c @@ -61,31 +61,31 @@ void dsp_dtmf_hardware(struct dsp *dsp) if (dsp->tx_volume) { if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, " - "because tx_volume is changed\n", - __func__, dsp->name); + "because tx_volume is changed\n", + __func__, dsp->name); hardware = 0; } if (dsp->rx_volume) { if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, " - "because rx_volume is changed\n", - __func__, dsp->name); + "because rx_volume is changed\n", + __func__, dsp->name); hardware = 0; } /* check if encryption is enabled */ if (dsp->bf_enable) { if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, " - "because encryption is enabled\n", - __func__, dsp->name); + "because encryption is enabled\n", + __func__, dsp->name); hardware = 0; } /* check if pipeline exists */ if (dsp->pipeline.inuse) { if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, " - "because pipeline exists.\n", - __func__, dsp->name); + "because pipeline exists.\n", + __func__, dsp->name); hardware = 0; } @@ -150,23 +150,23 @@ u8 if (len < 64) { if (len > 0) printk(KERN_ERR "%s: coefficients have invalid " - "size. (is=%d < must=%d)\n", - __func__, len, 64); + "size. (is=%d < must=%d)\n", + __func__, len, 64); return dsp->dtmf.digits; } hfccoeff = (s32 *)data; for (k = 0; k < NCOEFF; k++) { - sk2 = (*hfccoeff++)>>4; - sk = (*hfccoeff++)>>4; + sk2 = (*hfccoeff++) >> 4; + sk = (*hfccoeff++) >> 4; if (sk > 32767 || sk < -32767 || sk2 > 32767 || sk2 < -32767) printk(KERN_WARNING - "DTMF-Detection overflow\n"); + "DTMF-Detection overflow\n"); /* compute |X(k)|**2 */ result[k] = - (sk * sk) - - (((cos2pik[k] * sk) >> 15) * sk2) + - (sk2 * sk2); + (sk * sk) - + (((cos2pik[k] * sk) >> 15) * sk2) + + (sk2 * sk2); } data += 64; len -= 64; @@ -188,7 +188,7 @@ u8 buf = dsp->dtmf.buffer; cos2pik_ = cos2pik[k]; for (n = 0; n < DSP_DTMF_NPOINTS; n++) { - sk = ((cos2pik_*sk1)>>15) - sk2 + (*buf++); + sk = ((cos2pik_ * sk1) >> 15) - sk2 + (*buf++); sk2 = sk1; sk1 = sk; } @@ -224,14 +224,14 @@ u8 if (dsp_debug & DEBUG_DSP_DTMFCOEFF) printk(KERN_DEBUG "a %3d %3d %3d %3d %3d %3d %3d %3d" - " tr:%3d r %3d %3d %3d %3d %3d %3d %3d %3d\n", - result[0]/10000, result[1]/10000, result[2]/10000, - result[3]/10000, result[4]/10000, result[5]/10000, - result[6]/10000, result[7]/10000, tresh/10000, - result[0]/(tresh/100), result[1]/(tresh/100), - result[2]/(tresh/100), result[3]/(tresh/100), - result[4]/(tresh/100), result[5]/(tresh/100), - result[6]/(tresh/100), result[7]/(tresh/100)); + " tr:%3d r %3d %3d %3d %3d %3d %3d %3d %3d\n", + result[0] / 10000, result[1] / 10000, result[2] / 10000, + result[3] / 10000, result[4] / 10000, result[5] / 10000, + result[6] / 10000, result[7] / 10000, tresh / 10000, + result[0] / (tresh / 100), result[1] / (tresh / 100), + result[2] / (tresh / 100), result[3] / (tresh / 100), + result[4] / (tresh / 100), result[5] / (tresh / 100), + result[6] / (tresh / 100), result[7] / (tresh / 100)); /* calc digit (lowgroup/highgroup) */ lowgroup = -1; @@ -247,7 +247,7 @@ u8 break; /* noise in between */ } /* good level found. This is allowed only one time per group */ - if (i < NCOEFF/2) { + if (i < NCOEFF / 2) { /* lowgroup */ if (lowgroup >= 0) { /* Bad. Another tone found. */ @@ -262,7 +262,7 @@ u8 highgroup = -1; break; } else - highgroup = i-(NCOEFF/2); + highgroup = i - (NCOEFF / 2); } } @@ -285,13 +285,13 @@ u8 if (what) { if (dsp_debug & DEBUG_DSP_DTMF) printk(KERN_DEBUG "DTMF digit: %c\n", - what); - if ((strlen(dsp->dtmf.digits)+1) - < sizeof(dsp->dtmf.digits)) { + what); + if ((strlen(dsp->dtmf.digits) + 1) + < sizeof(dsp->dtmf.digits)) { dsp->dtmf.digits[strlen( - dsp->dtmf.digits)+1] = '\0'; + dsp->dtmf.digits) + 1] = '\0'; dsp->dtmf.digits[strlen( - dsp->dtmf.digits)] = what; + dsp->dtmf.digits)] = what; } } } @@ -302,5 +302,3 @@ u8 goto again; } - - diff --git a/drivers/isdn/mISDN/dsp_ecdis.h b/drivers/isdn/mISDN/dsp_ecdis.h index 21dbd153ee26..fed99ac7f6a4 100644 --- a/drivers/isdn/mISDN/dsp_ecdis.h +++ b/drivers/isdn/mISDN/dsp_ecdis.h @@ -46,15 +46,15 @@ struct ec_disable_detector_state { static inline void echo_can_disable_detector_init(struct ec_disable_detector_state *det) { - /* Elliptic notch */ - /* This is actually centred at 2095Hz, but gets the balance we want, due - to the asymmetric walls of the notch */ + /* Elliptic notch */ + /* This is actually centred at 2095Hz, but gets the balance we want, due + to the asymmetric walls of the notch */ biquad2_init(&det->notch, - (int32_t) (-0.7600000*32768.0), - (int32_t) (-0.1183852*32768.0), - (int32_t) (-0.5104039*32768.0), - (int32_t) (0.1567596*32768.0), - (int32_t) (1.0000000*32768.0)); + (int32_t)(-0.7600000 * 32768.0), + (int32_t)(-0.1183852 * 32768.0), + (int32_t)(-0.5104039 * 32768.0), + (int32_t)(0.1567596 * 32768.0), + (int32_t)(1.0000000 * 32768.0)); det->channel_level = 0; det->notch_level = 0; @@ -67,7 +67,7 @@ echo_can_disable_detector_init(struct ec_disable_detector_state *det) static inline int echo_can_disable_detector_update(struct ec_disable_detector_state *det, -int16_t amp) + int16_t amp) { int16_t notched; @@ -82,13 +82,13 @@ int16_t amp) det->notch_level += ((abs(notched) - det->notch_level) >> 4); if (det->channel_level > 280) { /* There is adequate energy in the channel. - Is it mostly at 2100Hz? */ - if (det->notch_level*6 < det->channel_level) { + Is it mostly at 2100Hz? */ + if (det->notch_level * 6 < det->channel_level) { /* The notch says yes, so we have the tone. */ if (!det->tone_present) { /* Do we get a kick every 450+-25ms? */ - if (det->tone_cycle_duration >= 425*8 - && det->tone_cycle_duration <= 475*8) { + if (det->tone_cycle_duration >= 425 * 8 + && det->tone_cycle_duration <= 475 * 8) { det->good_cycles++; if (det->good_cycles > 2) det->hit = TRUE; diff --git a/drivers/isdn/mISDN/dsp_hwec.c b/drivers/isdn/mISDN/dsp_hwec.c index 806a997fe7cc..a6e87076acc2 100644 --- a/drivers/isdn/mISDN/dsp_hwec.c +++ b/drivers/isdn/mISDN/dsp_hwec.c @@ -56,7 +56,7 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg) if (!dsp) { printk(KERN_ERR "%s: failed to enable hwec: dsp is NULL\n", - __func__); + __func__); return; } @@ -93,13 +93,13 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg) _do: printk(KERN_DEBUG "%s: enabling hwec with deftaps=%d\n", - __func__, deftaps); + __func__, deftaps); memset(&cq, 0, sizeof(cq)); cq.op = MISDN_CTRL_HFC_ECHOCAN_ON; cq.p1 = deftaps; if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) { printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n", - __func__); + __func__); return; } } @@ -110,7 +110,7 @@ void dsp_hwec_disable(struct dsp *dsp) if (!dsp) { printk(KERN_ERR "%s: failed to disable hwec: dsp is NULL\n", - __func__); + __func__); return; } @@ -119,7 +119,7 @@ void dsp_hwec_disable(struct dsp *dsp) cq.op = MISDN_CTRL_HFC_ECHOCAN_OFF; if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) { printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n", - __func__); + __func__); return; } } @@ -135,4 +135,3 @@ void dsp_hwec_exit(void) { mISDN_dsp_element_unregister(dsp_hwec); } - diff --git a/drivers/isdn/mISDN/dsp_hwec.h b/drivers/isdn/mISDN/dsp_hwec.h index eebe80c3f713..bbca1eb5a888 100644 --- a/drivers/isdn/mISDN/dsp_hwec.h +++ b/drivers/isdn/mISDN/dsp_hwec.h @@ -7,4 +7,3 @@ extern void dsp_hwec_enable(struct dsp *dsp, const char *arg); extern void dsp_hwec_disable(struct dsp *dsp); extern int dsp_hwec_init(void); extern void dsp_hwec_exit(void); - diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c index b6c9a5889346..88305c9cbff5 100644 --- a/drivers/isdn/mISDN/dsp_pipeline.c +++ b/drivers/isdn/mISDN/dsp_pipeline.c @@ -63,11 +63,11 @@ attr_show_args(struct device *dev, struct device_attribute *attr, char *buf) *buf = 0; for (i = 0; i < elem->num_args; i++) p += sprintf(p, "Name: %s\n%s%s%sDescription: %s\n\n", - elem->args[i].name, - elem->args[i].def ? "Default: " : "", - elem->args[i].def ? elem->args[i].def : "", - elem->args[i].def ? "\n" : "", - elem->args[i].desc); + elem->args[i].name, + elem->args[i].def ? "Default: " : "", + elem->args[i].def ? elem->args[i].def : "", + elem->args[i].def ? "\n" : "", + elem->args[i].desc); return p - buf; } @@ -106,17 +106,17 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) ret = device_register(&entry->dev); if (ret) { printk(KERN_ERR "%s: failed to register %s\n", - __func__, elem->name); + __func__, elem->name); goto err1; } list_add_tail(&entry->list, &dsp_elements); for (i = 0; i < ARRAY_SIZE(element_attributes); ++i) { ret = device_create_file(&entry->dev, - &element_attributes[i]); + &element_attributes[i]); if (ret) { printk(KERN_ERR "%s: failed to create device file\n", - __func__); + __func__); goto err2; } } @@ -148,7 +148,7 @@ void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem) device_unregister(&entry->dev); #ifdef PIPELINE_DEBUG printk(KERN_DEBUG "%s: %s unregistered\n", - __func__, elem->name); + __func__, elem->name); #endif return; } @@ -182,7 +182,7 @@ void dsp_pipeline_module_exit(void) list_for_each_entry_safe(entry, n, &dsp_elements, list) { list_del(&entry->list); printk(KERN_WARNING "%s: element was still registered: %s\n", - __func__, entry->elem->name); + __func__, entry->elem->name); kfree(entry); } @@ -213,7 +213,7 @@ static inline void _dsp_pipeline_destroy(struct dsp_pipeline *pipeline) list_del(&entry->list); if (entry->elem == dsp_hwec) dsp_hwec_disable(container_of(pipeline, struct dsp, - pipeline)); + pipeline)); else entry->elem->free(entry->p); kfree(entry); @@ -271,11 +271,11 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) elem = entry->elem; pipeline_entry = kmalloc(sizeof(struct - dsp_pipeline_entry), GFP_ATOMIC); + dsp_pipeline_entry), GFP_ATOMIC); if (!pipeline_entry) { printk(KERN_ERR "%s: failed to add " - "entry to pipeline: %s (out of " - "memory)\n", __func__, elem->name); + "entry to pipeline: %s (out of " + "memory)\n", __func__, elem->name); incomplete = 1; goto _out; } @@ -285,26 +285,26 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) /* This is a hack to make the hwec available as a pipeline module */ dsp_hwec_enable(container_of(pipeline, - struct dsp, pipeline), args); + struct dsp, pipeline), args); list_add_tail(&pipeline_entry->list, - &pipeline->list); + &pipeline->list); } else { pipeline_entry->p = elem->new(args); if (pipeline_entry->p) { list_add_tail(&pipeline_entry-> - list, &pipeline->list); + list, &pipeline->list); #ifdef PIPELINE_DEBUG printk(KERN_DEBUG "%s: created " - "instance of %s%s%s\n", - __func__, name, args ? - " with args " : "", args ? - args : ""); + "instance of %s%s%s\n", + __func__, name, args ? + " with args " : "", args ? + args : ""); #endif } else { printk(KERN_ERR "%s: failed " - "to add entry to pipeline: " - "%s (new() returned NULL)\n", - __func__, elem->name); + "to add entry to pipeline: " + "%s (new() returned NULL)\n", + __func__, elem->name); kfree(pipeline_entry); incomplete = 1; } @@ -317,7 +317,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) found = 0; else { printk(KERN_ERR "%s: element not found, skipping: " - "%s\n", __func__, name); + "%s\n", __func__, name); incomplete = 1; } } @@ -330,7 +330,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) #ifdef PIPELINE_DEBUG printk(KERN_DEBUG "%s: dsp pipeline built%s: %s\n", - __func__, incomplete ? " incomplete" : "", cfg); + __func__, incomplete ? " incomplete" : "", cfg); #endif kfree(dup); return 0; @@ -349,7 +349,7 @@ void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data, int len) } void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len, - unsigned int txlen) + unsigned int txlen) { struct dsp_pipeline_entry *entry; @@ -360,5 +360,3 @@ void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len, if (entry->elem->process_rx) entry->elem->process_rx(entry->p, data, len, txlen); } - - diff --git a/drivers/isdn/mISDN/dsp_tones.c b/drivers/isdn/mISDN/dsp_tones.c index 4e4440e8bae5..057e0d6a369b 100644 --- a/drivers/isdn/mISDN/dsp_tones.c +++ b/drivers/isdn/mISDN/dsp_tones.c @@ -239,120 +239,120 @@ static struct pattern { u32 seq[10]; } pattern[] = { {TONE_GERMAN_DIALTONE, - {DATA_GA, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GA, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {1900, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GA, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GA, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {1900, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_OLDDIALTONE, - {DATA_GO, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GO, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {1998, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GO, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GO, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {1998, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_AMERICAN_DIALTONE, - {DATA_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_DIALPBX, - {DATA_GA, DATA_S, DATA_GA, DATA_S, DATA_GA, DATA_S, NULL, NULL, NULL, - NULL}, - {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, NULL, NULL, NULL, - NULL}, - {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} }, + {DATA_GA, DATA_S, DATA_GA, DATA_S, DATA_GA, DATA_S, NULL, NULL, NULL, + NULL}, + {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, NULL, NULL, NULL, + NULL}, + {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} }, {TONE_GERMAN_OLDDIALPBX, - {DATA_GO, DATA_S, DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, - NULL}, - {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, - NULL}, - {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} }, + {DATA_GO, DATA_S, DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, + NULL}, + {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, + NULL}, + {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} }, {TONE_AMERICAN_DIALPBX, - {DATA_DT, DATA_S, DATA_DT, DATA_S, DATA_DT, DATA_S, NULL, NULL, NULL, - NULL}, - {SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, NULL, NULL, NULL, - NULL}, - {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} }, + {DATA_DT, DATA_S, DATA_DT, DATA_S, DATA_DT, DATA_S, NULL, NULL, NULL, + NULL}, + {SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, NULL, NULL, NULL, + NULL}, + {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} }, {TONE_GERMAN_RINGING, - {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {8000, 32000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {8000, 32000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_OLDRINGING, - {DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {8000, 40000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {8000, 40000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_AMERICAN_RINGING, - {DATA_RI, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_RI, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {8000, 32000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_RI, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_RI, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {8000, 32000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_RINGPBX, - {DATA_GA, DATA_S, DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} }, + {DATA_GA, DATA_S, DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_OLDRINGPBX, - {DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} }, + {DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} }, {TONE_AMERICAN_RINGPBX, - {DATA_RI, DATA_S, DATA_RI, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_RI, SIZE_S, SIZE_RI, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} }, + {DATA_RI, DATA_S, DATA_RI, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_RI, SIZE_S, SIZE_RI, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_BUSY, - {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_OLDBUSY, - {DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {1000, 5000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {1000, 5000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_AMERICAN_BUSY, - {DATA_BU, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_BU, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_BU, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_BU, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_HANGUP, - {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_OLDHANGUP, - {DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {1000, 5000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {1000, 5000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_AMERICAN_HANGUP, - {DATA_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_DT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_SPECIAL_INFO, - {DATA_S1, DATA_S2, DATA_S3, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_S1, SIZE_S2, SIZE_S3, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {2666, 2666, 2666, 8002, 0, 0, 0, 0, 0, 0} }, + {DATA_S1, DATA_S2, DATA_S3, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_S1, SIZE_S2, SIZE_S3, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {2666, 2666, 2666, 8002, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_GASSENBESETZT, - {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {2000, 2000, 0, 0, 0, 0, 0, 0, 0, 0} }, + {DATA_GA, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GA, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {2000, 2000, 0, 0, 0, 0, 0, 0, 0, 0} }, {TONE_GERMAN_AUFSCHALTTON, - {DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, - {1000, 5000, 1000, 17000, 0, 0, 0, 0, 0, 0} }, + {DATA_GO, DATA_S, DATA_GO, DATA_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, NULL, NULL, NULL, NULL, NULL, NULL}, + {1000, 5000, 1000, 17000, 0, 0, 0, 0, 0, 0} }, {0, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, }; /****************** @@ -386,7 +386,7 @@ void dsp_tone_copy(struct dsp *dsp, u8 *data, int len) /* process pattern */ pat = (struct pattern *)tone->pattern; - /* points to the current pattern */ + /* points to the current pattern */ index = tone->index; /* gives current sequence index */ count = tone->count; /* gives current sample */ @@ -404,19 +404,19 @@ void dsp_tone_copy(struct dsp *dsp, u8 *data, int len) break; if (dsp_debug & DEBUG_DSP_TONE) printk(KERN_DEBUG "%s: reaching next sequence " - "(index=%d)\n", __func__, index); + "(index=%d)\n", __func__, index); count -= pat->seq[index]; index++; } /* calculate start and number of samples */ start = count % (*(pat->siz[index])); num = len; - if (num+count > pat->seq[index]) + if (num + count > pat->seq[index]) num = pat->seq[index] - count; - if (num+start > (*(pat->siz[index]))) + if (num + start > (*(pat->siz[index]))) num = (*(pat->siz[index])) - start; /* copy memory */ - memcpy(data, pat->data[index]+start, num); + memcpy(data, pat->data[index] + start, num); /* reduce length */ data += num; count += num; @@ -441,8 +441,8 @@ dsp_tone_hw_message(struct dsp *dsp, u8 *sample, int len) /* unlocking is not required, because we don't expect a response */ nskb = _alloc_mISDN_skb(PH_CONTROL_REQ, - (len) ? HFC_SPL_LOOP_ON : HFC_SPL_LOOP_OFF, len, sample, - GFP_ATOMIC); + (len) ? HFC_SPL_LOOP_ON : HFC_SPL_LOOP_OFF, len, sample, + GFP_ATOMIC); if (nskb) { if (dsp->ch.peer) { if (dsp->ch.recv(dsp->ch.peer, nskb)) @@ -528,7 +528,7 @@ dsp_tone(struct dsp *dsp, int tone) } if (dsp_debug & DEBUG_DSP_TONE) printk(KERN_DEBUG "%s: now starting tone %d (index=%d)\n", - __func__, tone, 0); + __func__, tone, 0); tonet->tone = tone; tonet->pattern = pat; tonet->index = 0; @@ -550,8 +550,3 @@ dsp_tone(struct dsp *dsp, int tone) return 0; } - - - - - diff --git a/drivers/isdn/mISDN/fsm.c b/drivers/isdn/mISDN/fsm.c index b5d6553f2dc8..26477d48bbda 100644 --- a/drivers/isdn/mISDN/fsm.c +++ b/drivers/isdn/mISDN/fsm.c @@ -28,23 +28,23 @@ void mISDN_FsmNew(struct Fsm *fsm, - struct FsmNode *fnlist, int fncount) + struct FsmNode *fnlist, int fncount) { int i; fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count * - fsm->event_count, GFP_KERNEL); + fsm->event_count, GFP_KERNEL); for (i = 0; i < fncount; i++) if ((fnlist[i].state >= fsm->state_count) || (fnlist[i].event >= fsm->event_count)) { printk(KERN_ERR - "mISDN_FsmNew Error: %d st(%ld/%ld) ev(%ld/%ld)\n", - i, (long)fnlist[i].state, (long)fsm->state_count, - (long)fnlist[i].event, (long)fsm->event_count); + "mISDN_FsmNew Error: %d st(%ld/%ld) ev(%ld/%ld)\n", + i, (long)fnlist[i].state, (long)fsm->state_count, + (long)fnlist[i].event, (long)fsm->event_count); } else fsm->jumpmatrix[fsm->state_count * fnlist[i].event + - fnlist[i].state] = (FSMFNPTR) fnlist[i].routine; + fnlist[i].state] = (FSMFNPTR) fnlist[i].routine; } EXPORT_SYMBOL(mISDN_FsmNew); @@ -63,24 +63,24 @@ mISDN_FsmEvent(struct FsmInst *fi, int event, void *arg) if ((fi->state >= fi->fsm->state_count) || (event >= fi->fsm->event_count)) { printk(KERN_ERR - "mISDN_FsmEvent Error st(%ld/%ld) ev(%d/%ld)\n", - (long)fi->state, (long)fi->fsm->state_count, event, - (long)fi->fsm->event_count); + "mISDN_FsmEvent Error st(%ld/%ld) ev(%d/%ld)\n", + (long)fi->state, (long)fi->fsm->state_count, event, + (long)fi->fsm->event_count); return 1; } r = fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state]; if (r) { if (fi->debug) fi->printdebug(fi, "State %s Event %s", - fi->fsm->strState[fi->state], - fi->fsm->strEvent[event]); + fi->fsm->strState[fi->state], + fi->fsm->strEvent[event]); r(fi, event, arg); return 0; } else { if (fi->debug) fi->printdebug(fi, "State %s Event %s no action", - fi->fsm->strState[fi->state], - fi->fsm->strEvent[event]); + fi->fsm->strState[fi->state], + fi->fsm->strEvent[event]); return 1; } } @@ -92,7 +92,7 @@ mISDN_FsmChangeState(struct FsmInst *fi, int newstate) fi->state = newstate; if (fi->debug) fi->printdebug(fi, "ChangeState %s", - fi->fsm->strState[newstate]); + fi->fsm->strState[newstate]); } EXPORT_SYMBOL(mISDN_FsmChangeState); @@ -126,7 +126,7 @@ mISDN_FsmDelTimer(struct FsmTimer *ft, int where) #if FSM_TIMER_DEBUG if (ft->fi->debug) ft->fi->printdebug(ft->fi, "mISDN_FsmDelTimer %lx %d", - (long) ft, where); + (long) ft, where); #endif del_timer(&ft->tl); } @@ -134,21 +134,21 @@ EXPORT_SYMBOL(mISDN_FsmDelTimer); int mISDN_FsmAddTimer(struct FsmTimer *ft, - int millisec, int event, void *arg, int where) + int millisec, int event, void *arg, int where) { #if FSM_TIMER_DEBUG if (ft->fi->debug) ft->fi->printdebug(ft->fi, "mISDN_FsmAddTimer %lx %d %d", - (long) ft, millisec, where); + (long) ft, millisec, where); #endif if (timer_pending(&ft->tl)) { if (ft->fi->debug) { printk(KERN_WARNING - "mISDN_FsmAddTimer: timer already active!\n"); + "mISDN_FsmAddTimer: timer already active!\n"); ft->fi->printdebug(ft->fi, - "mISDN_FsmAddTimer already active!"); + "mISDN_FsmAddTimer already active!"); } return -1; } @@ -163,13 +163,13 @@ EXPORT_SYMBOL(mISDN_FsmAddTimer); void mISDN_FsmRestartTimer(struct FsmTimer *ft, - int millisec, int event, void *arg, int where) + int millisec, int event, void *arg, int where) { #if FSM_TIMER_DEBUG if (ft->fi->debug) ft->fi->printdebug(ft->fi, "mISDN_FsmRestartTimer %lx %d %d", - (long) ft, millisec, where); + (long) ft, millisec, where); #endif if (timer_pending(&ft->tl)) diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c index f6e108d0125f..c74c363554c4 100644 --- a/drivers/isdn/mISDN/hwchannel.c +++ b/drivers/isdn/mISDN/hwchannel.c @@ -206,7 +206,7 @@ recv_Bchannel(struct bchannel *bch, unsigned int id) hh->id = id; if (bch->rcount >= 64) { printk(KERN_WARNING "B-channel %p receive queue overflow, " - "flushing!\n", bch); + "flushing!\n", bch); skb_queue_purge(&bch->rqueue); bch->rcount = 0; return; @@ -231,7 +231,7 @@ recv_Bchannel_skb(struct bchannel *bch, struct sk_buff *skb) { if (bch->rcount >= 64) { printk(KERN_WARNING "B-channel %p receive queue overflow, " - "flushing!\n", bch); + "flushing!\n", bch); skb_queue_purge(&bch->rqueue); bch->rcount = 0; } @@ -247,10 +247,10 @@ confirm_Dsend(struct dchannel *dch) struct sk_buff *skb; skb = _alloc_mISDN_skb(PH_DATA_CNF, mISDN_HEAD_ID(dch->tx_skb), - 0, NULL, GFP_ATOMIC); + 0, NULL, GFP_ATOMIC); if (!skb) { printk(KERN_ERR "%s: no skb id %x\n", __func__, - mISDN_HEAD_ID(dch->tx_skb)); + mISDN_HEAD_ID(dch->tx_skb)); return; } skb_queue_tail(&dch->rqueue, skb); @@ -279,15 +279,15 @@ confirm_Bsend(struct bchannel *bch) if (bch->rcount >= 64) { printk(KERN_WARNING "B-channel %p receive queue overflow, " - "flushing!\n", bch); + "flushing!\n", bch); skb_queue_purge(&bch->rqueue); bch->rcount = 0; } skb = _alloc_mISDN_skb(PH_DATA_CNF, mISDN_HEAD_ID(bch->tx_skb), - 0, NULL, GFP_ATOMIC); + 0, NULL, GFP_ATOMIC); if (!skb) { printk(KERN_ERR "%s: no skb id %x\n", __func__, - mISDN_HEAD_ID(bch->tx_skb)); + mISDN_HEAD_ID(bch->tx_skb)); return; } bch->rcount++; @@ -349,7 +349,7 @@ dchannel_senddata(struct dchannel *ch, struct sk_buff *skb) } if (skb->len > ch->maxlen) { printk(KERN_WARNING "%s: skb too large(%d/%d)\n", - __func__, skb->len, ch->maxlen); + __func__, skb->len, ch->maxlen); return -EINVAL; } /* HW lock must be obtained */ @@ -376,15 +376,15 @@ bchannel_senddata(struct bchannel *ch, struct sk_buff *skb) } if (skb->len > ch->maxlen) { printk(KERN_WARNING "%s: skb too large(%d/%d)\n", - __func__, skb->len, ch->maxlen); + __func__, skb->len, ch->maxlen); return -EINVAL; } /* HW lock must be obtained */ /* check for pending next_skb */ if (ch->next_skb) { printk(KERN_WARNING - "%s: next_skb exist ERROR (skb->len=%d next_skb->len=%d)\n", - __func__, skb->len, ch->next_skb->len); + "%s: next_skb exist ERROR (skb->len=%d next_skb->len=%d)\n", + __func__, skb->len, ch->next_skb->len); return -EBUSY; } if (test_and_set_bit(FLG_TX_BUSY, &ch->Flags)) { diff --git a/drivers/isdn/mISDN/l1oip.h b/drivers/isdn/mISDN/l1oip.h index bc26c890d9a2..661c060ada49 100644 --- a/drivers/isdn/mISDN/l1oip.h +++ b/drivers/isdn/mISDN/l1oip.h @@ -10,7 +10,7 @@ /* enable to disorder received bchannels by sequence 2143658798... */ /* -#define REORDER_DEBUG + #define REORDER_DEBUG */ /* frames */ @@ -29,8 +29,8 @@ /* channel structure */ struct l1oip_chan { - struct dchannel *dch; - struct bchannel *bch; + struct dchannel *dch; + struct bchannel *bch; u32 tx_counter; /* counts xmit bytes/packets */ u32 rx_counter; /* counts recv bytes/packets */ u32 codecstate; /* used by codec to save data */ @@ -60,19 +60,19 @@ struct l1oip { int limit; /* limit number of bchannels */ /* timer */ - struct timer_list keep_tl; - struct timer_list timeout_tl; + struct timer_list keep_tl; + struct timer_list timeout_tl; int timeout_on; struct work_struct workq; /* socket */ - struct socket *socket; /* if set, socket is created */ - struct completion socket_complete;/* completion of sock thread */ + struct socket *socket; /* if set, socket is created */ + struct completion socket_complete;/* completion of sock thread */ struct task_struct *socket_thread; - spinlock_t socket_lock; /* access sock outside thread */ + spinlock_t socket_lock; /* access sock outside thread */ u32 remoteip; /* if all set, ip is assigned */ - u16 localport; /* must always be set */ - u16 remoteport; /* must always be set */ + u16 localport; /* must always be set */ + u16 remoteport; /* must always be set */ struct sockaddr_in sin_local; /* local socket name */ struct sockaddr_in sin_remote; /* remote socket name */ struct msghdr sendmsg; /* ip message to send */ @@ -88,4 +88,3 @@ extern int l1oip_alaw_to_ulaw(u8 *data, int len, u8 *result); extern int l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result); extern void l1oip_4bit_free(void); extern int l1oip_4bit_alloc(int ulaw); - diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c index 5a89972624d8..a601c8472220 100644 --- a/drivers/isdn/mISDN/l1oip_codec.c +++ b/drivers/isdn/mISDN/l1oip_codec.c @@ -27,22 +27,22 @@ /* -How the codec works: --------------------- + How the codec works: + -------------------- -The volume is increased to increase the dynamic range of the audio signal. -Each sample is converted to a-LAW with only 16 steps of level resolution. -A pair of two samples are stored in one byte. + The volume is increased to increase the dynamic range of the audio signal. + Each sample is converted to a-LAW with only 16 steps of level resolution. + A pair of two samples are stored in one byte. -The first byte is stored in the upper bits, the second byte is stored in the -lower bits. + The first byte is stored in the upper bits, the second byte is stored in the + lower bits. -To speed up compression and decompression, two lookup tables are formed: + To speed up compression and decompression, two lookup tables are formed: -- 16 bits index for two samples (law encoded) with 8 bit compressed result. -- 8 bits index for one compressed data with 16 bits decompressed result. + - 16 bits index for two samples (law encoded) with 8 bit compressed result. + - 8 bits index for one compressed data with 16 bits decompressed result. -NOTE: The bytes are handled as they are law-encoded. + NOTE: The bytes are handled as they are law-encoded. */ @@ -232,7 +232,7 @@ l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state) /* send saved byte and first input byte */ if (*state) { - *result++ = table_com[(((*state)<<8)&0xff00) | (*data++)]; + *result++ = table_com[(((*state) << 8) & 0xff00) | (*data++)]; len--; o++; } @@ -267,7 +267,7 @@ l1oip_4bit_to_law(u8 *data, int len, u8 *result) while (i < len) { r = table_dec[*data++]; - *result++ = r>>8; + *result++ = r >> 8; *result++ = r; i++; } @@ -345,8 +345,8 @@ l1oip_4bit_alloc(int ulaw) c = alaw_to_4bit[i1]; i2 = 0; while (i2 < 256) { - table_com[(i1<<8) | i2] |= (c<<4); - table_com[(i2<<8) | i1] |= c; + table_com[(i1 << 8) | i2] |= (c << 4); + table_com[(i2 << 8) | i1] |= c; i2++; } i1++; @@ -361,8 +361,8 @@ l1oip_4bit_alloc(int ulaw) sample = _4bit_to_alaw[i1]; i2 = 0; while (i2 < 16) { - table_dec[(i1<<4) | i2] |= (sample<<8); - table_dec[(i2<<4) | i1] |= sample; + table_dec[(i1 << 4) | i2] |= (sample << 8); + table_dec[(i2 << 4) | i1] |= sample; i2++; } i1++; @@ -370,5 +370,3 @@ l1oip_4bit_alloc(int ulaw) return 0; } - - diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c index 04f115a9c43e..0f88acf1185f 100644 --- a/drivers/isdn/mISDN/l1oip_core.c +++ b/drivers/isdn/mISDN/l1oip_core.c @@ -24,63 +24,63 @@ /* module parameters: * type: - Value 1 = BRI - Value 2 = PRI - Value 3 = BRI (multi channel frame, not supported yet) - Value 4 = PRI (multi channel frame, not supported yet) - A multi channel frame reduces overhead to a single frame for all - b-channels, but increases delay. - (NOTE: Multi channel frames are not implemented yet.) + Value 1 = BRI + Value 2 = PRI + Value 3 = BRI (multi channel frame, not supported yet) + Value 4 = PRI (multi channel frame, not supported yet) + A multi channel frame reduces overhead to a single frame for all + b-channels, but increases delay. + (NOTE: Multi channel frames are not implemented yet.) * codec: - Value 0 = transparent (default) - Value 1 = transfer ALAW - Value 2 = transfer ULAW - Value 3 = transfer generic 4 bit compression. + Value 0 = transparent (default) + Value 1 = transfer ALAW + Value 2 = transfer ULAW + Value 3 = transfer generic 4 bit compression. * ulaw: - 0 = we use a-Law (default) - 1 = we use u-Law + 0 = we use a-Law (default) + 1 = we use u-Law * limit: - limitation of B-channels to control bandwidth (1...126) - BRI: 1 or 2 - PRI: 1-30, 31-126 (126, because dchannel ist not counted here) - Also limited ressources are used for stack, resulting in less channels. - It is possible to have more channels than 30 in PRI mode, this must - be supported by the application. + limitation of B-channels to control bandwidth (1...126) + BRI: 1 or 2 + PRI: 1-30, 31-126 (126, because dchannel ist not counted here) + Also limited ressources are used for stack, resulting in less channels. + It is possible to have more channels than 30 in PRI mode, this must + be supported by the application. * ip: - byte representation of remote ip address (127.0.0.1 -> 127,0,0,1) - If not given or four 0, no remote address is set. - For multiple interfaces, concat ip addresses. (127,0,0,1,127,0,0,1) + byte representation of remote ip address (127.0.0.1 -> 127,0,0,1) + If not given or four 0, no remote address is set. + For multiple interfaces, concat ip addresses. (127,0,0,1,127,0,0,1) * port: - port number (local interface) - If not given or 0, port 931 is used for fist instance, 932 for next... - For multiple interfaces, different ports must be given. + port number (local interface) + If not given or 0, port 931 is used for fist instance, 932 for next... + For multiple interfaces, different ports must be given. * remoteport: - port number (remote interface) - If not given or 0, remote port equals local port - For multiple interfaces on equal sites, different ports must be given. + port number (remote interface) + If not given or 0, remote port equals local port + For multiple interfaces on equal sites, different ports must be given. * ondemand: - 0 = fixed (always transmit packets, even when remote side timed out) - 1 = on demand (only transmit packets, when remote side is detected) - the default is 0 - NOTE: ID must also be set for on demand. + 0 = fixed (always transmit packets, even when remote side timed out) + 1 = on demand (only transmit packets, when remote side is detected) + the default is 0 + NOTE: ID must also be set for on demand. * id: - optional value to identify frames. This value must be equal on both - peers and should be random. If omitted or 0, no ID is transmitted. + optional value to identify frames. This value must be equal on both + peers and should be random. If omitted or 0, no ID is transmitted. * debug: - NOTE: only one debug value must be given for all cards - enable debugging (see l1oip.h for debug options) + NOTE: only one debug value must be given for all cards + enable debugging (see l1oip.h for debug options) -Special mISDN controls: + Special mISDN controls: op = MISDN_CTRL_SETPEER* p1 = bytes 0-3 : remote IP address in network order (left element first) @@ -91,133 +91,133 @@ Special mISDN controls: op = MISDN_CTRL_UNSETPEER* * Use l1oipctrl for comfortable setting or removing ip address. - (Layer 1 Over IP CTRL) + (Layer 1 Over IP CTRL) -L1oIP-Protocol --------------- + L1oIP-Protocol + -------------- -Frame Header: + Frame Header: 7 6 5 4 3 2 1 0 -+---------------+ -|Ver|T|I|Coding | -+---------------+ -| ID byte 3 * | -+---------------+ -| ID byte 2 * | -+---------------+ -| ID byte 1 * | -+---------------+ -| ID byte 0 * | -+---------------+ -|M| Channel | -+---------------+ -| Length * | -+---------------+ -| Time Base MSB | -+---------------+ -| Time Base LSB | -+---------------+ -| Data.... | - -... - -| | -+---------------+ -|M| Channel | -+---------------+ -| Length * | -+---------------+ -| Time Base MSB | -+---------------+ -| Time Base LSB | -+---------------+ -| Data.... | - -... - - -* Only included in some cases. - -- Ver = Version -If version is missmatch, the frame must be ignored. - -- T = Type of interface -Must be 0 for S0 or 1 for E1. - -- I = Id present -If bit is set, four ID bytes are included in frame. - -- ID = Connection ID -Additional ID to prevent Denial of Service attacs. Also it prevents hijacking -connections with dynamic IP. The ID should be random and must not be 0. - -- Coding = Type of codec -Must be 0 for no transcoding. Also for D-channel and other HDLC frames. + +---------------+ + |Ver|T|I|Coding | + +---------------+ + | ID byte 3 * | + +---------------+ + | ID byte 2 * | + +---------------+ + | ID byte 1 * | + +---------------+ + | ID byte 0 * | + +---------------+ + |M| Channel | + +---------------+ + | Length * | + +---------------+ + | Time Base MSB | + +---------------+ + | Time Base LSB | + +---------------+ + | Data.... | + + ... + + | | + +---------------+ + |M| Channel | + +---------------+ + | Length * | + +---------------+ + | Time Base MSB | + +---------------+ + | Time Base LSB | + +---------------+ + | Data.... | + + ... + + + * Only included in some cases. + + - Ver = Version + If version is missmatch, the frame must be ignored. + + - T = Type of interface + Must be 0 for S0 or 1 for E1. + + - I = Id present + If bit is set, four ID bytes are included in frame. + + - ID = Connection ID + Additional ID to prevent Denial of Service attacs. Also it prevents hijacking + connections with dynamic IP. The ID should be random and must not be 0. + + - Coding = Type of codec + Must be 0 for no transcoding. Also for D-channel and other HDLC frames. 1 and 2 are reserved for explicitly use of a-LAW or u-LAW codec. 3 is used for generic table compressor. -- M = More channels to come. If this flag is 1, the following byte contains -the length of the channel data. After the data block, the next channel will -be defined. The flag for the last channel block (or if only one channel is -transmitted), must be 0 and no length is given. + - M = More channels to come. If this flag is 1, the following byte contains + the length of the channel data. After the data block, the next channel will + be defined. The flag for the last channel block (or if only one channel is + transmitted), must be 0 and no length is given. -- Channel = Channel number -0 reserved -1-3 channel data for S0 (3 is D-channel) -1-31 channel data for E1 (16 is D-channel) -32-127 channel data for extended E1 (16 is D-channel) + - Channel = Channel number + 0 reserved + 1-3 channel data for S0 (3 is D-channel) + 1-31 channel data for E1 (16 is D-channel) + 32-127 channel data for extended E1 (16 is D-channel) -- The length is used if the M-flag is 1. It is used to find the next channel -inside frame. -NOTE: A value of 0 equals 256 bytes of data. + - The length is used if the M-flag is 1. It is used to find the next channel + inside frame. + NOTE: A value of 0 equals 256 bytes of data. -> For larger data blocks, a single frame must be used. -> For larger streams, a single frame or multiple blocks with same channel ID - must be used. + must be used. -- Time Base = Timestamp of first sample in frame -The "Time Base" is used to rearange packets and to detect packet loss. -The 16 bits are sent in network order (MSB first) and count 1/8000 th of a -second. This causes a wrap around each 8,192 seconds. There is no requirement -for the initial "Time Base", but 0 should be used for the first packet. -In case of HDLC data, this timestamp counts the packet or byte number. + - Time Base = Timestamp of first sample in frame + The "Time Base" is used to rearange packets and to detect packet loss. + The 16 bits are sent in network order (MSB first) and count 1/8000 th of a + second. This causes a wrap around each 8,192 seconds. There is no requirement + for the initial "Time Base", but 0 should be used for the first packet. + In case of HDLC data, this timestamp counts the packet or byte number. -Two Timers: + Two Timers: -After initialisation, a timer of 15 seconds is started. Whenever a packet is -transmitted, the timer is reset to 15 seconds again. If the timer expires, an -empty packet is transmitted. This keep the connection alive. + After initialisation, a timer of 15 seconds is started. Whenever a packet is + transmitted, the timer is reset to 15 seconds again. If the timer expires, an + empty packet is transmitted. This keep the connection alive. -When a valid packet is received, a timer 65 seconds is started. The interface -become ACTIVE. If the timer expires, the interface becomes INACTIVE. + When a valid packet is received, a timer 65 seconds is started. The interface + become ACTIVE. If the timer expires, the interface becomes INACTIVE. -Dynamic IP handling: + Dynamic IP handling: -To allow dynamic IP, the ID must be non 0. In this case, any packet with the -correct port number and ID will be accepted. If the remote side changes its IP -the new IP is used for all transmitted packets until it changes again. + To allow dynamic IP, the ID must be non 0. In this case, any packet with the + correct port number and ID will be accepted. If the remote side changes its IP + the new IP is used for all transmitted packets until it changes again. -On Demand: + On Demand: -If the ondemand parameter is given, the remote IP is set to 0 on timeout. -This will stop keepalive traffic to remote. If the remote is online again, -traffic will continue to the remote address. This is useful for road warriors. -This feature only works with ID set, otherwhise it is highly unsecure. + If the ondemand parameter is given, the remote IP is set to 0 on timeout. + This will stop keepalive traffic to remote. If the remote is online again, + traffic will continue to the remote address. This is useful for road warriors. + This feature only works with ID set, otherwhise it is highly unsecure. -Socket and Thread ------------------ + Socket and Thread + ----------------- -The complete socket opening and closing is done by a thread. -When the thread opened a socket, the hc->socket descriptor is set. Whenever a -packet shall be sent to the socket, the hc->socket must be checked wheter not -NULL. To prevent change in socket descriptor, the hc->socket_lock must be used. -To change the socket, a recall of l1oip_socket_open() will safely kill the -socket process and create a new one. + The complete socket opening and closing is done by a thread. + When the thread opened a socket, the hc->socket descriptor is set. Whenever a + packet shall be sent to the socket, the hc->socket must be checked wheter not + NULL. To prevent change in socket descriptor, the hc->socket_lock must be used. + To change the socket, a recall of l1oip_socket_open() will safely kill the + socket process and create a new one. */ @@ -247,7 +247,7 @@ static struct list_head l1oip_ilist; #define MAX_CARDS 16 static u_int type[MAX_CARDS]; static u_int codec[MAX_CARDS]; -static u_int ip[MAX_CARDS*4]; +static u_int ip[MAX_CARDS * 4]; static u_int port[MAX_CARDS]; static u_int remoteport[MAX_CARDS]; static u_int ondemand[MAX_CARDS]; @@ -274,26 +274,26 @@ module_param(debug, uint, S_IRUGO | S_IWUSR); */ static int l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, - u16 timebase, u8 *buf, int len) + u16 timebase, u8 *buf, int len) { u8 *p; int multi = 0; - u8 frame[len+32]; + u8 frame[len + 32]; struct socket *socket = NULL; if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: sending data to socket (len = %d)\n", - __func__, len); + __func__, len); p = frame; /* restart timer */ - if ((int)(hc->keep_tl.expires-jiffies) < 5*HZ) { + if ((int)(hc->keep_tl.expires-jiffies) < 5 * HZ) { del_timer(&hc->keep_tl); - hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE*HZ; + hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ; add_timer(&hc->keep_tl); } else - hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE*HZ; + hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE * HZ; if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: resetting timer\n", __func__); @@ -302,25 +302,25 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, if (!hc->sin_remote.sin_addr.s_addr || !hc->sin_remote.sin_port) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: dropping frame, because remote " - "IP is not set.\n", __func__); + "IP is not set.\n", __func__); return len; } /* assemble frame */ - *p++ = (L1OIP_VERSION<<6) /* version and coding */ - | (hc->pri ? 0x20 : 0x00) /* type */ - | (hc->id ? 0x10 : 0x00) /* id */ - | localcodec; + *p++ = (L1OIP_VERSION << 6) /* version and coding */ + | (hc->pri ? 0x20 : 0x00) /* type */ + | (hc->id ? 0x10 : 0x00) /* id */ + | localcodec; if (hc->id) { - *p++ = hc->id>>24; /* id */ - *p++ = hc->id>>16; - *p++ = hc->id>>8; + *p++ = hc->id >> 24; /* id */ + *p++ = hc->id >> 16; + *p++ = hc->id >> 8; *p++ = hc->id; } *p++ = (multi == 1) ? 0x80 : 0x00 + channel; /* m-flag, channel */ if (multi == 1) *p++ = len; /* length */ - *p++ = timebase>>8; /* time base */ + *p++ = timebase >> 8; /* time base */ *p++ = timebase; if (buf && len) { /* add data to frame */ @@ -330,7 +330,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, l1oip_alaw_to_ulaw(buf, len, p); else if (localcodec == 3) len = l1oip_law_to_4bit(buf, len, p, - &hc->chan[channel].codecstate); + &hc->chan[channel].codecstate); else memcpy(p, buf, len); } @@ -349,7 +349,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, /* send packet */ if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: sending packet to socket (len " - "= %d)\n", __func__, len); + "= %d)\n", __func__, len); hc->sendiov.iov_base = frame; hc->sendiov.iov_len = len; len = kernel_sendmsg(socket, &hc->sendmsg, &hc->sendiov, 1, len); @@ -365,7 +365,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, */ static void l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase, - u8 *buf, int len) + u8 *buf, int len) { struct sk_buff *nskb; struct bchannel *bch; @@ -376,34 +376,34 @@ l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase, if (len == 0) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: received empty keepalive data, " - "ignoring\n", __func__); + "ignoring\n", __func__); return; } if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: received data, sending to mISDN (%d)\n", - __func__, len); + __func__, len); if (channel < 1 || channel > 127) { printk(KERN_WARNING "%s: packet error - channel %d out of " - "range\n", __func__, channel); + "range\n", __func__, channel); return; } dch = hc->chan[channel].dch; bch = hc->chan[channel].bch; if (!dch && !bch) { printk(KERN_WARNING "%s: packet error - channel %d not in " - "stack\n", __func__, channel); + "stack\n", __func__, channel); return; } /* prepare message */ - nskb = mI_alloc_skb((remotecodec == 3) ? (len<<1) : len, GFP_ATOMIC); + nskb = mI_alloc_skb((remotecodec == 3) ? (len << 1) : len, GFP_ATOMIC); if (!nskb) { printk(KERN_ERR "%s: No mem for skb.\n", __func__); return; } - p = skb_put(nskb, (remotecodec == 3) ? (len<<1) : len); + p = skb_put(nskb, (remotecodec == 3) ? (len << 1) : len); if (remotecodec == 1 && ulaw) l1oip_alaw_to_ulaw(buf, len, p); @@ -428,7 +428,7 @@ l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase, rx_counter = (rx_counter & 0xffff0000) | timebase; else - rx_counter = ((rx_counter & 0xffff0000)+0x10000) + rx_counter = ((rx_counter & 0xffff0000) + 0x10000) | timebase; } else { /* time has changed backwards */ @@ -436,7 +436,7 @@ l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase, rx_counter = (rx_counter & 0xffff0000) | timebase; else - rx_counter = ((rx_counter & 0xffff0000)-0x10000) + rx_counter = ((rx_counter & 0xffff0000) - 0x10000) | timebase; } hc->chan[channel].rx_counter = rx_counter; @@ -476,42 +476,42 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: received frame, parsing... (%d)\n", - __func__, len); + __func__, len); /* check length */ - if (len < 1+1+2) { + if (len < 1 + 1 + 2) { printk(KERN_WARNING "%s: packet error - length %d below " - "4 bytes\n", __func__, len); + "4 bytes\n", __func__, len); return; } /* check version */ - if (((*buf)>>6) != L1OIP_VERSION) { + if (((*buf) >> 6) != L1OIP_VERSION) { printk(KERN_WARNING "%s: packet error - unknown version %d\n", - __func__, buf[0]>>6); + __func__, buf[0]>>6); return; } /* check type */ - if (((*buf)&0x20) && !hc->pri) { + if (((*buf) & 0x20) && !hc->pri) { printk(KERN_WARNING "%s: packet error - received E1 packet " - "on S0 interface\n", __func__); + "on S0 interface\n", __func__); return; } - if (!((*buf)&0x20) && hc->pri) { + if (!((*buf) & 0x20) && hc->pri) { printk(KERN_WARNING "%s: packet error - received S0 packet " - "on E1 interface\n", __func__); + "on E1 interface\n", __func__); return; } /* get id flag */ - packet_id = (*buf>>4)&1; + packet_id = (*buf >> 4) & 1; /* check coding */ remotecodec = (*buf) & 0x0f; if (remotecodec > 3) { printk(KERN_WARNING "%s: packet error - remotecodec %d " - "unsupported\n", __func__, remotecodec); + "unsupported\n", __func__, remotecodec); return; } buf++; @@ -521,12 +521,12 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) if (packet_id) { if (!hc->id) { printk(KERN_WARNING "%s: packet error - packet has id " - "0x%x, but we have not\n", __func__, packet_id); + "0x%x, but we have not\n", __func__, packet_id); return; } if (len < 4) { printk(KERN_WARNING "%s: packet error - packet too " - "short for ID value\n", __func__); + "short for ID value\n", __func__); return; } packet_id = (*buf++) << 24; @@ -537,14 +537,14 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) if (packet_id != hc->id) { printk(KERN_WARNING "%s: packet error - ID mismatch, " - "got 0x%x, we 0x%x\n", - __func__, packet_id, hc->id); + "got 0x%x, we 0x%x\n", + __func__, packet_id, hc->id); return; } } else { if (hc->id) { printk(KERN_WARNING "%s: packet error - packet has no " - "ID, but we have\n", __func__); + "ID, but we have\n", __func__); return; } } @@ -552,13 +552,13 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) multiframe: if (len < 1) { printk(KERN_WARNING "%s: packet error - packet too short, " - "channel expected at position %d.\n", - __func__, len-len_start+1); + "channel expected at position %d.\n", + __func__, len-len_start + 1); return; } /* get channel and multiframe flag */ - channel = *buf&0x7f; + channel = *buf & 0x7f; m = *buf >> 7; buf++; len--; @@ -567,8 +567,8 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) if (m) { if (len < 1) { printk(KERN_WARNING "%s: packet error - packet too " - "short, length expected at position %d.\n", - __func__, len_start-len-1); + "short, length expected at position %d.\n", + __func__, len_start - len - 1); return; } @@ -576,26 +576,26 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) len--; if (mlen == 0) mlen = 256; - if (len < mlen+3) { + if (len < mlen + 3) { printk(KERN_WARNING "%s: packet error - length %d at " - "position %d exceeds total length %d.\n", - __func__, mlen, len_start-len-1, len_start); + "position %d exceeds total length %d.\n", + __func__, mlen, len_start-len - 1, len_start); return; } - if (len == mlen+3) { + if (len == mlen + 3) { printk(KERN_WARNING "%s: packet error - length %d at " - "position %d will not allow additional " - "packet.\n", - __func__, mlen, len_start-len+1); + "position %d will not allow additional " + "packet.\n", + __func__, mlen, len_start-len + 1); return; } } else - mlen = len-2; /* single frame, subtract timebase */ + mlen = len - 2; /* single frame, subtract timebase */ if (len < 2) { printk(KERN_WARNING "%s: packet error - packet too short, time " - "base expected at position %d.\n", - __func__, len-len_start+1); + "base expected at position %d.\n", + __func__, len-len_start + 1); return; } @@ -606,12 +606,12 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) /* if inactive, we send up a PH_ACTIVATE and activate */ if (!test_bit(FLG_ACTIVE, &dch->Flags)) { - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: interface become active due to " - "received packet\n", __func__); + "received packet\n", __func__); test_and_set_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_ATOMIC); + NULL, GFP_ATOMIC); } /* distribute packet */ @@ -624,24 +624,24 @@ l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len) goto multiframe; /* restart timer */ - if ((int)(hc->timeout_tl.expires-jiffies) < 5*HZ || !hc->timeout_on) { + if ((int)(hc->timeout_tl.expires-jiffies) < 5 * HZ || !hc->timeout_on) { hc->timeout_on = 1; del_timer(&hc->timeout_tl); - hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT*HZ; + hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ; add_timer(&hc->timeout_tl); } else /* only adjust timer */ - hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT*HZ; + hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT * HZ; /* if ip or source port changes */ if ((hc->sin_remote.sin_addr.s_addr != sin->sin_addr.s_addr) - || (hc->sin_remote.sin_port != sin->sin_port)) { + || (hc->sin_remote.sin_port != sin->sin_port)) { if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: remote address changes from " - "0x%08x to 0x%08x (port %d to %d)\n", __func__, - ntohl(hc->sin_remote.sin_addr.s_addr), - ntohl(sin->sin_addr.s_addr), - ntohs(hc->sin_remote.sin_port), - ntohs(sin->sin_port)); + "0x%08x to 0x%08x (port %d to %d)\n", __func__, + ntohl(hc->sin_remote.sin_addr.s_addr), + ntohl(sin->sin_addr.s_addr), + ntohs(hc->sin_remote.sin_port), + ntohs(sin->sin_port)); hc->sin_remote.sin_addr.s_addr = sin->sin_addr.s_addr; hc->sin_remote.sin_port = sin->sin_port; } @@ -694,9 +694,9 @@ l1oip_socket_thread(void *data) /* bind to incomming port */ if (socket->ops->bind(socket, (struct sockaddr *)&hc->sin_local, - sizeof(hc->sin_local))) { + sizeof(hc->sin_local))) { printk(KERN_ERR "%s: Failed to bind socket to port %d.\n", - __func__, hc->localport); + __func__, hc->localport); ret = -EINVAL; goto fail; } @@ -728,7 +728,7 @@ l1oip_socket_thread(void *data) /* read loop */ if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: socket created and open\n", - __func__); + __func__); while (!signal_pending(current)) { struct kvec iov = { .iov_base = recvbuf, @@ -741,7 +741,7 @@ l1oip_socket_thread(void *data) } else { if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_WARNING - "%s: broken pipe on socket\n", __func__); + "%s: broken pipe on socket\n", __func__); } } @@ -750,7 +750,7 @@ l1oip_socket_thread(void *data) /* if hc->socket is NULL, it is in use until it is given back */ while (!hc->socket) { spin_unlock(&hc->socket_lock); - schedule_timeout(HZ/10); + schedule_timeout(HZ / 10); spin_lock(&hc->socket_lock); } hc->socket = NULL; @@ -758,7 +758,7 @@ l1oip_socket_thread(void *data) if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: socket thread terminating\n", - __func__); + __func__); fail: /* free recvbuf */ @@ -774,7 +774,7 @@ l1oip_socket_thread(void *data) if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: socket thread terminated\n", - __func__); + __func__); return ret; } @@ -787,19 +787,19 @@ l1oip_socket_close(struct l1oip *hc) if (hc->socket_thread) { if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: socket thread exists, " - "killing...\n", __func__); + "killing...\n", __func__); send_sig(SIGTERM, hc->socket_thread, 0); wait_for_completion(&hc->socket_complete); } /* if active, we send up a PH_DEACTIVATE and deactivate */ if (test_bit(FLG_ACTIVE, &dch->Flags)) { - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: interface become deactivated " - "due to timeout\n", __func__); + "due to timeout\n", __func__); test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_ATOMIC); + NULL, GFP_ATOMIC); } } @@ -813,11 +813,11 @@ l1oip_socket_open(struct l1oip *hc) /* create receive process */ hc->socket_thread = kthread_run(l1oip_socket_thread, hc, "l1oip_%s", - hc->name); + hc->name); if (IS_ERR(hc->socket_thread)) { int err = PTR_ERR(hc->socket_thread); printk(KERN_ERR "%s: Failed (%d) to create socket process.\n", - __func__, err); + __func__, err); hc->socket_thread = NULL; sock_release(hc->socket); return err; @@ -834,9 +834,9 @@ l1oip_send_bh(struct work_struct *work) { struct l1oip *hc = container_of(work, struct l1oip, workq); - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: keepalive timer expired, sending empty " - "frame on dchannel\n", __func__); + "frame on dchannel\n", __func__); /* send an empty l1oip frame at D-channel */ l1oip_socket_send(hc, 0, hc->d_idx, 0, 0, NULL, 0); @@ -862,25 +862,25 @@ l1oip_timeout(void *data) if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: timeout timer expired, turn layer one " - "down.\n", __func__); + "down.\n", __func__); hc->timeout_on = 0; /* state that timer must be initialized next time */ /* if timeout, we send up a PH_DEACTIVATE and deactivate */ if (test_bit(FLG_ACTIVE, &dch->Flags)) { - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: interface become deactivated " - "due to timeout\n", __func__); + "due to timeout\n", __func__); test_and_clear_bit(FLG_ACTIVE, &dch->Flags); _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, - NULL, GFP_ATOMIC); + NULL, GFP_ATOMIC); } /* if we have ondemand set, we remove ip address */ if (hc->ondemand) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: on demand causes ip address to " - "be removed\n", __func__); + "be removed\n", __func__); hc->sin_remote.sin_addr.s_addr = 0; } } @@ -904,12 +904,12 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) case PH_DATA_REQ: if (skb->len < 1) { printk(KERN_WARNING "%s: skb too small\n", - __func__); + __func__); break; } if (skb->len > MAX_DFRAME_LEN_L1 || skb->len > L1OIP_MAX_LEN) { printk(KERN_WARNING "%s: skb too large\n", - __func__); + __func__); break; } /* send frame */ @@ -918,7 +918,7 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) while (l) { ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME; l1oip_socket_send(hc, 0, dch->slot, 0, - hc->chan[dch->slot].tx_counter++, p, ll); + hc->chan[dch->slot].tx_counter++, p, ll); p += ll; l -= ll; } @@ -926,9 +926,9 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); return 0; case PH_ACTIVATE_REQ: - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: PH_ACTIVATE channel %d (1..%d)\n" - , __func__, dch->slot, hc->b_num+1); + , __func__, dch->slot, hc->b_num + 1); skb_trim(skb, 0); if (test_bit(FLG_ACTIVE, &dch->Flags)) queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb); @@ -936,10 +936,10 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb); return 0; case PH_DEACTIVATE_REQ: - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: PH_DEACTIVATE channel %d " - "(1..%d)\n", __func__, dch->slot, - hc->b_num+1); + "(1..%d)\n", __func__, dch->slot, + hc->b_num + 1); skb_trim(skb, 0); if (test_bit(FLG_ACTIVE, &dch->Flags)) queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb); @@ -971,26 +971,26 @@ channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq) hc->remoteport = hc->localport; if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: got new ip address from user " - "space.\n", __func__); + "space.\n", __func__); l1oip_socket_open(hc); break; case MISDN_CTRL_UNSETPEER: if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: removing ip address.\n", - __func__); + __func__); hc->remoteip = 0; l1oip_socket_open(hc); break; case MISDN_CTRL_GETPEER: if (debug & DEBUG_L1OIP_SOCKET) printk(KERN_DEBUG "%s: getting ip address.\n", - __func__); + __func__); cq->p1 = hc->remoteip; cq->p2 = hc->remoteport | (hc->localport << 16); break; default: printk(KERN_WARNING "%s: unknown Op %x\n", - __func__, cq->op); + __func__, cq->op); ret = -EINVAL; break; } @@ -1002,21 +1002,21 @@ open_dchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) { if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: dev(%d) open from %p\n", __func__, - dch->dev.id, __builtin_return_address(0)); + dch->dev.id, __builtin_return_address(0)); if (rq->protocol == ISDN_P_NONE) return -EINVAL; if ((dch->dev.D.protocol != ISDN_P_NONE) && (dch->dev.D.protocol != rq->protocol)) { if (debug & DEBUG_HW_OPEN) printk(KERN_WARNING "%s: change protocol %x to %x\n", - __func__, dch->dev.D.protocol, rq->protocol); + __func__, dch->dev.D.protocol, rq->protocol); } if (dch->dev.D.protocol != rq->protocol) dch->dev.D.protocol = rq->protocol; if (test_bit(FLG_ACTIVE, &dch->Flags)) { _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, - 0, NULL, GFP_KERNEL); + 0, NULL, GFP_KERNEL); } rq->ch = &dch->dev.D; if (!try_module_get(THIS_MODULE)) @@ -1038,7 +1038,7 @@ open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq) bch = hc->chan[ch].bch; if (!bch) { printk(KERN_ERR "%s:internal error ch %d has no bch\n", - __func__, ch); + __func__, ch); return -EINVAL; } if (test_and_set_bit(FLG_OPEN, &bch->Flags)) @@ -1061,7 +1061,7 @@ l1oip_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: cmd:%x %p\n", - __func__, cmd, arg); + __func__, cmd, arg); switch (cmd) { case OPEN_CHANNEL: rq = arg; @@ -1089,8 +1089,8 @@ l1oip_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) case CLOSE_CHANNEL: if (debug & DEBUG_HW_OPEN) printk(KERN_DEBUG "%s: dev(%d) close from %p\n", - __func__, dch->dev.id, - __builtin_return_address(0)); + __func__, dch->dev.id, + __builtin_return_address(0)); module_put(THIS_MODULE); break; case CONTROL_CHANNEL: @@ -1099,7 +1099,7 @@ l1oip_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg) default: if (dch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: unknown command %x\n", - __func__, cmd); + __func__, cmd); err = -EINVAL; } return err; @@ -1119,12 +1119,12 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) case PH_DATA_REQ: if (skb->len <= 0) { printk(KERN_WARNING "%s: skb too small\n", - __func__); + __func__); break; } if (skb->len > MAX_DFRAME_LEN_L1 || skb->len > L1OIP_MAX_LEN) { printk(KERN_WARNING "%s: skb too large\n", - __func__); + __func__); break; } /* check for AIS / ulaw-silence */ @@ -1132,7 +1132,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) if (!memchr_inv(skb->data, 0xff, l)) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: got AIS, not sending, " - "but counting\n", __func__); + "but counting\n", __func__); hc->chan[bch->slot].tx_counter += l; skb_trim(skb, 0); queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); @@ -1143,7 +1143,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) if (!memchr_inv(skb->data, 0x2a, l)) { if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: got silence, not sending" - ", but counting\n", __func__); + ", but counting\n", __func__); hc->chan[bch->slot].tx_counter += l; skb_trim(skb, 0); queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); @@ -1156,7 +1156,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) while (l) { ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME; l1oip_socket_send(hc, hc->codec, bch->slot, 0, - hc->chan[bch->slot].tx_counter, p, ll); + hc->chan[bch->slot].tx_counter, p, ll); hc->chan[bch->slot].tx_counter += ll; p += ll; l -= ll; @@ -1165,19 +1165,19 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb); return 0; case PH_ACTIVATE_REQ: - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: PH_ACTIVATE channel %d (1..%d)\n" - , __func__, bch->slot, hc->b_num+1); + , __func__, bch->slot, hc->b_num + 1); hc->chan[bch->slot].codecstate = 0; test_and_set_bit(FLG_ACTIVE, &bch->Flags); skb_trim(skb, 0); queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb); return 0; case PH_DEACTIVATE_REQ: - if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET)) + if (debug & (DEBUG_L1OIP_MSG | DEBUG_L1OIP_SOCKET)) printk(KERN_DEBUG "%s: PH_DEACTIVATE channel %d " - "(1..%d)\n", __func__, bch->slot, - hc->b_num+1); + "(1..%d)\n", __func__, bch->slot, + hc->b_num + 1); test_and_clear_bit(FLG_ACTIVE, &bch->Flags); skb_trim(skb, 0); queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb); @@ -1202,14 +1202,14 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) case MISDN_CTRL_HW_FEATURES: /* fill features structure */ if (debug & DEBUG_L1OIP_MSG) printk(KERN_DEBUG "%s: HW_FEATURE request\n", - __func__); + __func__); /* create confirm */ features->unclocked = 1; features->unordered = 1; break; default: printk(KERN_WARNING "%s: unknown Op %x\n", - __func__, cq->op); + __func__, cq->op); ret = -EINVAL; break; } @@ -1224,7 +1224,7 @@ l1oip_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) if (bch->debug & DEBUG_HW) printk(KERN_DEBUG "%s: cmd:%x %p\n", - __func__, cmd, arg); + __func__, cmd, arg); switch (cmd) { case CLOSE_CHANNEL: test_and_clear_bit(FLG_OPEN, &bch->Flags); @@ -1239,7 +1239,7 @@ l1oip_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) break; default: printk(KERN_WARNING "%s: unknown prim(%x)\n", - __func__, cmd); + __func__, cmd); } return err; } @@ -1330,18 +1330,18 @@ init_card(struct l1oip *hc, int pri, int bundle) break; default: printk(KERN_ERR "Codec(%d) not supported.\n", - codec[l1oip_cnt]); + codec[l1oip_cnt]); return -EINVAL; } hc->codec = codec[l1oip_cnt]; if (debug & DEBUG_L1OIP_INIT) printk(KERN_DEBUG "%s: using codec %d\n", - __func__, hc->codec); + __func__, hc->codec); if (id[l1oip_cnt] == 0) { printk(KERN_WARNING "Warning: No 'id' value given or " - "0, this is highly unsecure. Please use 32 " - "bit randmom number 0x...\n"); + "0, this is highly unsecure. Please use 32 " + "bit randmom number 0x...\n"); } hc->id = id[l1oip_cnt]; if (debug & DEBUG_L1OIP_INIT) @@ -1350,7 +1350,7 @@ init_card(struct l1oip *hc, int pri, int bundle) hc->ondemand = ondemand[l1oip_cnt]; if (hc->ondemand && !hc->id) { printk(KERN_ERR "%s: ondemand option only allowed in " - "conjunction with non 0 ID\n", __func__); + "conjunction with non 0 ID\n", __func__); return -EINVAL; } @@ -1358,37 +1358,37 @@ init_card(struct l1oip *hc, int pri, int bundle) hc->b_num = limit[l1oip_cnt]; if (!pri && hc->b_num > 2) { printk(KERN_ERR "Maximum limit for BRI interface is 2 " - "channels.\n"); + "channels.\n"); return -EINVAL; } if (pri && hc->b_num > 126) { printk(KERN_ERR "Maximum limit for PRI interface is 126 " - "channels.\n"); + "channels.\n"); return -EINVAL; } if (pri && hc->b_num > 30) { printk(KERN_WARNING "Maximum limit for BRI interface is 30 " - "channels.\n"); + "channels.\n"); printk(KERN_WARNING "Your selection of %d channels must be " - "supported by application.\n", hc->limit); + "supported by application.\n", hc->limit); } - hc->remoteip = ip[l1oip_cnt<<2] << 24 - | ip[(l1oip_cnt<<2)+1] << 16 - | ip[(l1oip_cnt<<2)+2] << 8 - | ip[(l1oip_cnt<<2)+3]; - hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT+l1oip_cnt); + hc->remoteip = ip[l1oip_cnt << 2] << 24 + | ip[(l1oip_cnt << 2) + 1] << 16 + | ip[(l1oip_cnt << 2) + 2] << 8 + | ip[(l1oip_cnt << 2) + 3]; + hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT + l1oip_cnt); if (remoteport[l1oip_cnt]) hc->remoteport = remoteport[l1oip_cnt]; else hc->remoteport = hc->localport; if (debug & DEBUG_L1OIP_INIT) printk(KERN_DEBUG "%s: using local port %d remote ip " - "%d.%d.%d.%d port %d ondemand %d\n", __func__, - hc->localport, hc->remoteip >> 24, - (hc->remoteip >> 16) & 0xff, - (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff, - hc->remoteport, hc->ondemand); + "%d.%d.%d.%d port %d ondemand %d\n", __func__, + hc->localport, hc->remoteip >> 24, + (hc->remoteip >> 16) & 0xff, + (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff, + hc->remoteport, hc->ondemand); dch = kzalloc(sizeof(struct dchannel), GFP_KERNEL); if (!dch) @@ -1401,7 +1401,7 @@ init_card(struct l1oip *hc, int pri, int bundle) else dch->dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0); dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | - (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); + (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK)); dch->dev.D.send = handle_dmsg; dch->dev.D.ctrl = l1oip_dctrl; dch->dev.nrbchan = hc->b_num; @@ -1414,7 +1414,7 @@ init_card(struct l1oip *hc, int pri, int bundle) bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL); if (!bch) { printk(KERN_ERR "%s: no memory for bchannel\n", - __func__); + __func__); return -ENOMEM; } bch->nr = i + ch; @@ -1437,7 +1437,7 @@ init_card(struct l1oip *hc, int pri, int bundle) if (debug & DEBUG_L1OIP_INIT) printk(KERN_DEBUG "%s: Setting up network card(%d)\n", - __func__, l1oip_cnt + 1); + __func__, l1oip_cnt + 1); ret = l1oip_socket_open(hc); if (ret) return ret; @@ -1445,7 +1445,7 @@ init_card(struct l1oip *hc, int pri, int bundle) hc->keep_tl.function = (void *)l1oip_keepalive; hc->keep_tl.data = (ulong)hc; init_timer(&hc->keep_tl); - hc->keep_tl.expires = jiffies + 2*HZ; /* two seconds first time */ + hc->keep_tl.expires = jiffies + 2 * HZ; /* two seconds first time */ add_timer(&hc->keep_tl); hc->timeout_tl.function = (void *)l1oip_timeout; @@ -1464,7 +1464,7 @@ l1oip_init(void) int ret; printk(KERN_INFO "mISDN: Layer-1-over-IP driver Rev. %s\n", - l1oip_revision); + l1oip_revision); INIT_LIST_HEAD(&l1oip_ilist); spin_lock_init(&l1oip_lock); @@ -1493,16 +1493,16 @@ l1oip_init(void) break; default: printk(KERN_ERR "Card type(%d) not supported.\n", - type[l1oip_cnt] & 0xff); + type[l1oip_cnt] & 0xff); l1oip_cleanup(); return -EINVAL; } if (debug & DEBUG_L1OIP_INIT) printk(KERN_DEBUG "%s: interface %d is %s with %s.\n", - __func__, l1oip_cnt, pri ? "PRI" : "BRI", - bundle ? "bundled IP packet for all B-channels" : - "separate IP packets for every B-channel"); + __func__, l1oip_cnt, pri ? "PRI" : "BRI", + bundle ? "bundled IP packet for all B-channels" : + "separate IP packets for every B-channel"); hc = kzalloc(sizeof(struct l1oip), GFP_ATOMIC); if (!hc) { @@ -1530,4 +1530,3 @@ l1oip_init(void) module_init(l1oip_init); module_exit(l1oip_cleanup); - diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c index 5cc7c001c523..0fc49b375514 100644 --- a/drivers/isdn/mISDN/layer1.c +++ b/drivers/isdn/mISDN/layer1.c @@ -26,12 +26,12 @@ static u_int *debug; struct layer1 { - u_long Flags; - struct FsmInst l1m; - struct FsmTimer timer; - int delay; - struct dchannel *dch; - dchannel_l1callback *dcb; + u_long Flags; + struct FsmInst l1m; + struct FsmTimer timer; + int delay; + struct dchannel *dch; + dchannel_l1callback *dcb; }; #define TIMER3_VALUE 7000 @@ -49,7 +49,7 @@ enum { ST_L1_F8, }; -#define L1S_STATE_COUNT (ST_L1_F8+1) +#define L1S_STATE_COUNT (ST_L1_F8 + 1) static char *strL1SState[] = { @@ -358,7 +358,7 @@ l1_event(struct layer1 *l1, u_int event) default: if (*debug & DEBUG_L1) printk(KERN_DEBUG "%s %x unhandled\n", - __func__, event); + __func__, event); err = -EINVAL; } return err; diff --git a/drivers/isdn/mISDN/layer1.h b/drivers/isdn/mISDN/layer1.h index 9c8125fd89af..d1d332ced05f 100644 --- a/drivers/isdn/mISDN/layer1.h +++ b/drivers/isdn/mISDN/layer1.h @@ -23,4 +23,3 @@ #define FLG_L1_PULL_REQ 6 #define FLG_L1_UINT 7 #define FLG_L1_DBLOCKED 8 - diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c index 5bc00156315e..39d7375fa551 100644 --- a/drivers/isdn/mISDN/layer2.c +++ b/drivers/isdn/mISDN/layer2.c @@ -63,7 +63,7 @@ enum { EV_L2_FRAME_ERROR, }; -#define L2_EVENT_COUNT (EV_L2_FRAME_ERROR+1) +#define L2_EVENT_COUNT (EV_L2_FRAME_ERROR + 1) static char *strL2Event[] = { @@ -281,9 +281,9 @@ l2mgr(struct layer2 *l2, u_int prim, void *arg) { long c = (long)arg; printk(KERN_WARNING - "l2mgr: addr:%x prim %x %c\n", l2->id, prim, (char)c); + "l2mgr: addr:%x prim %x %c\n", l2->id, prim, (char)c); if (test_bit(FLG_LAPD, &l2->flag) && - !test_bit(FLG_FIXED_TEI, &l2->flag)) { + !test_bit(FLG_FIXED_TEI, &l2->flag)) { switch (c) { case 'C': case 'D': @@ -340,7 +340,7 @@ ReleaseWin(struct layer2 *l2) if (cnt) printk(KERN_WARNING - "isdnl2 freed %d skbuffs in release\n", cnt); + "isdnl2 freed %d skbuffs in release\n", cnt); } inline unsigned int @@ -471,7 +471,7 @@ inline int IsRNR(u_char *data, struct layer2 *l2) { return test_bit(FLG_MOD128, &l2->flag) ? - data[0] == RNR : (data[0] & 0xf) == RNR; + data[0] == RNR : (data[0] & 0xf) == RNR; } static int @@ -543,15 +543,15 @@ FRMR_error(struct layer2 *l2, struct sk_buff *skb) return 'N'; else if (*debug & DEBUG_L2) l2m_debug(&l2->l2m, - "FRMR information %2x %2x %2x %2x %2x", - datap[0], datap[1], datap[2], datap[3], datap[4]); + "FRMR information %2x %2x %2x %2x %2x", + datap[0], datap[1], datap[2], datap[3], datap[4]); } else { if (skb->len < headers + 3) return 'N'; else if (*debug & DEBUG_L2) l2m_debug(&l2->l2m, - "FRMR information %2x %2x %2x", - datap[0], datap[1], datap[2]); + "FRMR information %2x %2x %2x", + datap[0], datap[1], datap[2]); } return 0; } @@ -604,7 +604,7 @@ send_uframe(struct layer2 *l2, struct sk_buff *skb, u_char cmd, u_char cr) skb = mI_alloc_skb(i, GFP_ATOMIC); if (!skb) { printk(KERN_WARNING "%s: can't alloc skbuff\n", - __func__); + __func__); return; } } @@ -1051,7 +1051,7 @@ l2_st5_dm_release(struct FsmInst *fi, int event, void *arg) skb_queue_purge(&l2->i_queue); if (test_bit(FLG_LAPB, &l2->flag)) l2down_create(l2, PH_DEACTIVATE_REQ, - l2_newid(l2), 0, NULL); + l2_newid(l2), 0, NULL); st5_dl_release_l2l3(l2); mISDN_FsmChangeState(fi, ST_L2_4); if (l2->tm) @@ -1090,7 +1090,7 @@ enquiry_cr(struct layer2 *l2, u_char typ, u_char cr, u_char pf) skb = mI_alloc_skb(i, GFP_ATOMIC); if (!skb) { printk(KERN_WARNING - "isdnl2 can't alloc sbbuff for enquiry_cr\n"); + "isdnl2 can't alloc sbbuff for enquiry_cr\n"); return; } memcpy(skb_put(skb, i), tmp, i); @@ -1149,8 +1149,8 @@ invoke_retransmission(struct layer2 *l2, unsigned int nr) skb_queue_head(&l2->i_queue, l2->windowar[p1]); else printk(KERN_WARNING - "%s: windowar[%d] is NULL\n", - __func__, p1); + "%s: windowar[%d] is NULL\n", + __func__, p1); l2->windowar[p1] = NULL; } mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL); @@ -1199,13 +1199,13 @@ l2_st7_got_super(struct FsmInst *fi, int event, void *arg) invoke_retransmission(l2, nr); stop_t200(l2, 10); if (mISDN_FsmAddTimer(&l2->t203, l2->T203, - EV_L2_T203, NULL, 6)) + EV_L2_T203, NULL, 6)) l2m_debug(&l2->l2m, "Restart T203 ST7 REJ"); } else if ((nr == l2->vs) && (typ == RR)) { setva(l2, nr); stop_t200(l2, 11); mISDN_FsmRestartTimer(&l2->t203, l2->T203, - EV_L2_T203, NULL, 7); + EV_L2_T203, NULL, 7); } else if ((l2->va != nr) || (typ == RNR)) { setva(l2, nr); if (typ != RR) @@ -1303,7 +1303,7 @@ l2_got_iframe(struct FsmInst *fi, int event, void *arg) if (nr == l2->vs) { stop_t200(l2, 13); mISDN_FsmRestartTimer(&l2->t203, l2->T203, - EV_L2_T203, NULL, 7); + EV_L2_T203, NULL, 7); } else if (nr != l2->va) restart_t200(l2, 14); } @@ -1343,7 +1343,7 @@ l2_st5_tout_200(struct FsmInst *fi, int event, void *arg) struct layer2 *l2 = fi->userdata; if (test_bit(FLG_LAPD, &l2->flag) && - test_bit(FLG_DCHAN_BUSY, &l2->flag)) { + test_bit(FLG_DCHAN_BUSY, &l2->flag)) { mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); } else if (l2->rc == l2->N200) { mISDN_FsmChangeState(fi, ST_L2_4); @@ -1352,7 +1352,7 @@ l2_st5_tout_200(struct FsmInst *fi, int event, void *arg) l2mgr(l2, MDL_ERROR_IND, (void *) 'G'); if (test_bit(FLG_LAPB, &l2->flag)) l2down_create(l2, PH_DEACTIVATE_REQ, - l2_newid(l2), 0, NULL); + l2_newid(l2), 0, NULL); st5_dl_release_l2l3(l2); if (l2->tm) l2_tei(l2, MDL_STATUS_DOWN_IND, 0); @@ -1360,7 +1360,7 @@ l2_st5_tout_200(struct FsmInst *fi, int event, void *arg) l2->rc++; mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); send_uframe(l2, NULL, (test_bit(FLG_MOD128, &l2->flag) ? - SABME : SABM) | 0x10, CMD); + SABME : SABM) | 0x10, CMD); } } @@ -1370,7 +1370,7 @@ l2_st6_tout_200(struct FsmInst *fi, int event, void *arg) struct layer2 *l2 = fi->userdata; if (test_bit(FLG_LAPD, &l2->flag) && - test_bit(FLG_DCHAN_BUSY, &l2->flag)) { + test_bit(FLG_DCHAN_BUSY, &l2->flag)) { mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); } else if (l2->rc == l2->N200) { mISDN_FsmChangeState(fi, ST_L2_4); @@ -1382,7 +1382,7 @@ l2_st6_tout_200(struct FsmInst *fi, int event, void *arg) } else { l2->rc++; mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, - NULL, 9); + NULL, 9); send_uframe(l2, NULL, DISC | 0x10, CMD); } } @@ -1393,7 +1393,7 @@ l2_st7_tout_200(struct FsmInst *fi, int event, void *arg) struct layer2 *l2 = fi->userdata; if (test_bit(FLG_LAPD, &l2->flag) && - test_bit(FLG_DCHAN_BUSY, &l2->flag)) { + test_bit(FLG_DCHAN_BUSY, &l2->flag)) { mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); return; } @@ -1410,7 +1410,7 @@ l2_st8_tout_200(struct FsmInst *fi, int event, void *arg) struct layer2 *l2 = fi->userdata; if (test_bit(FLG_LAPD, &l2->flag) && - test_bit(FLG_DCHAN_BUSY, &l2->flag)) { + test_bit(FLG_DCHAN_BUSY, &l2->flag)) { mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); return; } @@ -1431,7 +1431,7 @@ l2_st7_tout_203(struct FsmInst *fi, int event, void *arg) struct layer2 *l2 = fi->userdata; if (test_bit(FLG_LAPD, &l2->flag) && - test_bit(FLG_DCHAN_BUSY, &l2->flag)) { + test_bit(FLG_DCHAN_BUSY, &l2->flag)) { mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 9); return; } @@ -1462,7 +1462,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg) p1 = (p1 + l2->sow) % l2->window; if (l2->windowar[p1]) { printk(KERN_WARNING "isdnl2 try overwrite ack queue entry %d\n", - p1); + p1); dev_kfree_skb(l2->windowar[p1]); } l2->windowar[p1] = skb; @@ -1482,7 +1482,7 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg) memcpy(skb_push(nskb, i), header, i); else { printk(KERN_WARNING - "isdnl2 pull_iqueue skb header(%d/%d) too short\n", i, p1); + "isdnl2 pull_iqueue skb header(%d/%d) too short\n", i, p1); oskb = nskb; nskb = mI_alloc_skb(oskb->len + i, GFP_ATOMIC); if (!nskb) { @@ -1537,7 +1537,7 @@ l2_st8_got_super(struct FsmInst *fi, int event, void *arg) } else { stop_t200(l2, 16); mISDN_FsmAddTimer(&l2->t203, l2->T203, - EV_L2_T203, NULL, 5); + EV_L2_T203, NULL, 5); setva(l2, nr); } invoke_retransmission(l2, nr); @@ -1858,7 +1858,7 @@ ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) ptei = *datap++; if ((psapi & 1) || !(ptei & 1)) { printk(KERN_WARNING - "l2 D-channel frame wrong EA0/EA1\n"); + "l2 D-channel frame wrong EA0/EA1\n"); return ret; } psapi >>= 2; @@ -1867,7 +1867,7 @@ ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) /* not our business */ if (*debug & DEBUG_L2) printk(KERN_DEBUG "%s: sapi %d/%d mismatch\n", - __func__, psapi, l2->sapi); + __func__, psapi, l2->sapi); dev_kfree_skb(skb); return 0; } @@ -1875,7 +1875,7 @@ ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) /* not our business */ if (*debug & DEBUG_L2) printk(KERN_DEBUG "%s: tei %d/%d mismatch\n", - __func__, ptei, l2->tei); + __func__, ptei, l2->tei); dev_kfree_skb(skb); return 0; } @@ -1927,11 +1927,11 @@ l2_send(struct mISDNchannel *ch, struct sk_buff *skb) { struct layer2 *l2 = container_of(ch, struct layer2, ch); struct mISDNhead *hh = mISDN_HEAD_P(skb); - int ret = -EINVAL; + int ret = -EINVAL; if (*debug & DEBUG_L2_RECV) printk(KERN_DEBUG "%s: prim(%x) id(%x) sapi(%d) tei(%d)\n", - __func__, hh->prim, hh->id, l2->sapi, l2->tei); + __func__, hh->prim, hh->id, l2->sapi, l2->tei); switch (hh->prim) { case PH_DATA_IND: ret = ph_data_indication(l2, hh, skb); @@ -1944,7 +1944,7 @@ l2_send(struct mISDNchannel *ch, struct sk_buff *skb) l2up_create(l2, MPH_ACTIVATE_IND, 0, NULL); if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag)) ret = mISDN_FsmEvent(&l2->l2m, - EV_L2_DL_ESTABLISH_REQ, skb); + EV_L2_DL_ESTABLISH_REQ, skb); break; case PH_DEACTIVATE_IND: test_and_clear_bit(FLG_L1_ACTIV, &l2->flag); @@ -1967,30 +1967,30 @@ l2_send(struct mISDNchannel *ch, struct sk_buff *skb) test_and_set_bit(FLG_ORIG, &l2->flag); if (test_bit(FLG_L1_ACTIV, &l2->flag)) { if (test_bit(FLG_LAPD, &l2->flag) || - test_bit(FLG_ORIG, &l2->flag)) + test_bit(FLG_ORIG, &l2->flag)) ret = mISDN_FsmEvent(&l2->l2m, - EV_L2_DL_ESTABLISH_REQ, skb); + EV_L2_DL_ESTABLISH_REQ, skb); } else { if (test_bit(FLG_LAPD, &l2->flag) || - test_bit(FLG_ORIG, &l2->flag)) { + test_bit(FLG_ORIG, &l2->flag)) { test_and_set_bit(FLG_ESTAB_PEND, - &l2->flag); + &l2->flag); } ret = l2down(l2, PH_ACTIVATE_REQ, l2_newid(l2), - skb); + skb); } break; case DL_RELEASE_REQ: if (test_bit(FLG_LAPB, &l2->flag)) l2down_create(l2, PH_DEACTIVATE_REQ, - l2_newid(l2), 0, NULL); + l2_newid(l2), 0, NULL); ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_RELEASE_REQ, - skb); + skb); break; default: if (*debug & DEBUG_L2) l2m_debug(&l2->l2m, "l2 unknown pr %04x", - hh->prim); + hh->prim); } if (ret) { dev_kfree_skb(skb); @@ -2038,7 +2038,7 @@ release_l2(struct layer2 *l2) TEIrelease(l2); if (l2->ch.st) l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, - CLOSE_CHANNEL, NULL); + CLOSE_CHANNEL, NULL); } kfree(l2); } @@ -2058,7 +2058,7 @@ l2_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg) set_channel_address(&l2->ch, l2->sapi, l2->tei); info = DL_INFO_L2_CONNECT; l2up_create(l2, DL_INFORMATION_IND, - sizeof(info), &info); + sizeof(info), &info); } break; case CLOSE_CHANNEL: @@ -2072,7 +2072,7 @@ l2_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg) struct layer2 * create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, int tei, - int sapi) + int sapi) { struct layer2 *l2; struct channel_req rq; @@ -2151,7 +2151,7 @@ create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, int tei, break; default: printk(KERN_ERR "layer2 create failed prt %x\n", - protocol); + protocol); kfree(l2); return NULL; } @@ -2162,8 +2162,8 @@ create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, int tei, InitWin(l2); l2->l2m.fsm = &l2fsm; if (test_bit(FLG_LAPB, &l2->flag) || - test_bit(FLG_PTP, &l2->flag) || - test_bit(FLG_LAPD_NET, &l2->flag)) + test_bit(FLG_PTP, &l2->flag) || + test_bit(FLG_LAPD_NET, &l2->flag)) l2->l2m.state = ST_L2_4; else l2->l2m.state = ST_L2_1; @@ -2219,4 +2219,3 @@ Isdnl2_cleanup(void) TEIFree(); mISDN_FsmFree(&l2fsm); } - diff --git a/drivers/isdn/mISDN/layer2.h b/drivers/isdn/mISDN/layer2.h index 9547fb3707a3..fe68d94c1b73 100644 --- a/drivers/isdn/mISDN/layer2.h +++ b/drivers/isdn/mISDN/layer2.h @@ -87,18 +87,18 @@ enum { ST_L2_8, }; -#define L2_STATE_COUNT (ST_L2_8+1) +#define L2_STATE_COUNT (ST_L2_8 + 1) extern struct layer2 *create_l2(struct mISDNchannel *, u_int, - u_long, int, int); + u_long, int, int); extern int tei_l2(struct layer2 *, u_int, u_long arg); /* from tei.c */ -extern int l2_tei(struct layer2 *, u_int, u_long arg); -extern void TEIrelease(struct layer2 *); -extern int TEIInit(u_int *); -extern void TEIFree(void); +extern int l2_tei(struct layer2 *, u_int, u_long arg); +extern void TEIrelease(struct layer2 *); +extern int TEIInit(u_int *); +extern void TEIFree(void); #define MAX_L2HEADER_LEN 4 diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index 738ea8dd0adf..abe2d699b6f3 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c @@ -113,7 +113,7 @@ mISDN_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) static int mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len, int flags) + struct msghdr *msg, size_t len, int flags) { struct sk_buff *skb; struct sock *sk = sock->sk; @@ -123,8 +123,8 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, if (*debug & DEBUG_SOCKET) printk(KERN_DEBUG "%s: len %d, flags %x ch.nr %d, proto %x\n", - __func__, (int)len, flags, _pms(sk)->ch.nr, - sk->sk_protocol); + __func__, (int)len, flags, _pms(sk)->ch.nr, + sk->sk_protocol); if (flags & (MSG_OOB)) return -EOPNOTSUPP; @@ -153,7 +153,7 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, } else { if (msg->msg_namelen) printk(KERN_WARNING "%s: too small namelen %d\n", - __func__, msg->msg_namelen); + __func__, msg->msg_namelen); msg->msg_namelen = 0; } @@ -166,7 +166,7 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, return -ENOSPC; } memcpy(skb_push(skb, MISDN_HEADER_LEN), mISDN_HEAD_P(skb), - MISDN_HEADER_LEN); + MISDN_HEADER_LEN); err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); @@ -179,7 +179,7 @@ mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock, static int mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len) + struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct sk_buff *skb; @@ -188,13 +188,13 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock, if (*debug & DEBUG_SOCKET) printk(KERN_DEBUG "%s: len %d flags %x ch %d proto %x\n", - __func__, (int)len, msg->msg_flags, _pms(sk)->ch.nr, - sk->sk_protocol); + __func__, (int)len, msg->msg_flags, _pms(sk)->ch.nr, + sk->sk_protocol); if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; - if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE)) + if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_NOSIGNAL | MSG_ERRQUEUE)) return -EINVAL; if (len < MISDN_HEADER_LEN) @@ -229,7 +229,7 @@ mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock, if (*debug & DEBUG_SOCKET) printk(KERN_DEBUG "%s: ID:%x\n", - __func__, mISDN_HEAD_ID(skb)); + __func__, mISDN_HEAD_ID(skb)); err = -ENODEV; if (!_pms(sk)->ch.peer) @@ -312,16 +312,16 @@ data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p) } if ((sk->sk_protocol & ~ISDN_P_B_MASK) == ISDN_P_B_START) { list_for_each_entry_safe(bchan, next, - &_pms(sk)->dev->bchannels, list) { + &_pms(sk)->dev->bchannels, list) { if (bchan->nr == cq.channel) { err = bchan->ctrl(bchan, - CONTROL_CHANNEL, &cq); + CONTROL_CHANNEL, &cq); break; } } } else err = _pms(sk)->dev->D.ctrl(&_pms(sk)->dev->D, - CONTROL_CHANNEL, &cq); + CONTROL_CHANNEL, &cq); if (err) break; if (copy_to_user(p, &cq, sizeof(cq))) @@ -338,11 +338,11 @@ data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p) break; } err = _pms(sk)->dev->teimgr->ctrl(_pms(sk)->dev->teimgr, - CONTROL_CHANNEL, val); + CONTROL_CHANNEL, val); break; case IMHOLD_L1: if (sk->sk_protocol != ISDN_P_LAPD_NT - && sk->sk_protocol != ISDN_P_LAPD_TE) { + && sk->sk_protocol != ISDN_P_LAPD_TE) { err = -EINVAL; break; } @@ -352,7 +352,7 @@ data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p) break; } err = _pms(sk)->dev->teimgr->ctrl(_pms(sk)->dev->teimgr, - CONTROL_CHANNEL, val); + CONTROL_CHANNEL, val); break; default: err = -EINVAL; @@ -366,7 +366,7 @@ data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p) static int data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { - int err = 0, id; + int err = 0, id; struct sock *sk = sock->sk; struct mISDNdevice *dev; struct mISDNversion ver; @@ -399,7 +399,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) di.Bprotocols = dev->Bprotocols | get_all_Bprotocols(); di.protocol = dev->D.protocol; memcpy(di.channelmap, dev->channelmap, - sizeof(di.channelmap)); + sizeof(di.channelmap)); di.nrbchan = dev->nrbchan; strcpy(di.name, dev_name(&dev->dev)); if (copy_to_user((void __user *)arg, &di, sizeof(di))) @@ -410,7 +410,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) default: if (sk->sk_state == MISDN_BOUND) err = data_sock_ioctl_bound(sk, cmd, - (void __user *)arg); + (void __user *)arg); else err = -ENOTCONN; } @@ -418,14 +418,14 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } static int data_sock_setsockopt(struct socket *sock, int level, int optname, - char __user *optval, unsigned int len) + char __user *optval, unsigned int len) { struct sock *sk = sock->sk; int err = 0, opt = 0; if (*debug & DEBUG_SOCKET) printk(KERN_DEBUG "%s(%p, %d, %x, %p, %d)\n", __func__, sock, - level, optname, optval, len); + level, optname, optval, len); lock_sock(sk); @@ -450,7 +450,7 @@ static int data_sock_setsockopt(struct socket *sock, int level, int optname, } static int data_sock_getsockopt(struct socket *sock, int level, int optname, - char __user *optval, int __user *optlen) + char __user *optval, int __user *optlen) { struct sock *sk = sock->sk; int len, opt; @@ -516,7 +516,7 @@ data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) if (csk->sk_protocol >= ISDN_P_B_START) continue; if (IS_ISDN_P_TE(csk->sk_protocol) - == IS_ISDN_P_TE(sk->sk_protocol)) + == IS_ISDN_P_TE(sk->sk_protocol)) continue; read_unlock_bh(&data_sockets.lock); err = -EBUSY; @@ -535,14 +535,14 @@ data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) case ISDN_P_NT_E1: mISDN_sock_unlink(&data_sockets, sk); err = connect_layer1(_pms(sk)->dev, &_pms(sk)->ch, - sk->sk_protocol, maddr); + sk->sk_protocol, maddr); if (err) mISDN_sock_link(&data_sockets, sk); break; case ISDN_P_LAPD_TE: case ISDN_P_LAPD_NT: err = create_l2entity(_pms(sk)->dev, &_pms(sk)->ch, - sk->sk_protocol, maddr); + sk->sk_protocol, maddr); break; case ISDN_P_B_RAW: case ISDN_P_B_HDLC: @@ -551,7 +551,7 @@ data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) case ISDN_P_B_L2DSP: case ISDN_P_B_L2DSPHDLC: err = connect_Bstack(_pms(sk)->dev, &_pms(sk)->ch, - sk->sk_protocol, maddr); + sk->sk_protocol, maddr); break; default: err = -EPROTONOSUPPORT; @@ -568,9 +568,9 @@ data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) static int data_sock_getname(struct socket *sock, struct sockaddr *addr, - int *addr_len, int peer) + int *addr_len, int peer) { - struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr; + struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr; struct sock *sk = sock->sk; if (!_pms(sk)->dev) @@ -651,7 +651,7 @@ base_sock_release(struct socket *sock) static int base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { - int err = 0, id; + int err = 0, id; struct mISDNdevice *dev; struct mISDNversion ver; @@ -683,7 +683,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) di.Bprotocols = dev->Bprotocols | get_all_Bprotocols(); di.protocol = dev->D.protocol; memcpy(di.channelmap, dev->channelmap, - sizeof(di.channelmap)); + sizeof(di.channelmap)); di.nrbchan = dev->nrbchan; strcpy(di.name, dev_name(&dev->dev)); if (copy_to_user((void __user *)arg, &di, sizeof(di))) @@ -692,20 +692,20 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) err = -ENODEV; break; case IMSETDEVNAME: - { - struct mISDN_devrename dn; - if (copy_from_user(&dn, (void __user *)arg, - sizeof(dn))) { - err = -EFAULT; - break; - } - dev = get_mdevice(dn.id); - if (dev) - err = device_rename(&dev->dev, dn.name); - else - err = -ENODEV; + { + struct mISDN_devrename dn; + if (copy_from_user(&dn, (void __user *)arg, + sizeof(dn))) { + err = -EFAULT; + break; } - break; + dev = get_mdevice(dn.id); + if (dev) + err = device_rename(&dev->dev, dn.name); + else + err = -ENODEV; + } + break; default: err = -EINVAL; } @@ -790,7 +790,7 @@ mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern) { int err = -EPROTONOSUPPORT; - switch (proto) { + switch (proto) { case ISDN_P_BASE: err = base_sock_create(net, sock, proto); break; @@ -838,4 +838,3 @@ misdn_sock_cleanup(void) { sock_unregister(PF_ISDN); } - diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c index a5b632e67552..1a0ae4445ff2 100644 --- a/drivers/isdn/mISDN/stack.c +++ b/drivers/isdn/mISDN/stack.c @@ -29,7 +29,7 @@ _queue_message(struct mISDNstack *st, struct sk_buff *skb) if (*debug & DEBUG_QUEUE_FUNC) printk(KERN_DEBUG "%s prim(%x) id(%x) %p\n", - __func__, hh->prim, hh->id, skb); + __func__, hh->prim, hh->id, skb); skb_queue_tail(&st->msgq, skb); if (likely(!test_bit(mISDN_STACK_STOPPED, &st->status))) { test_and_set_bit(mISDN_STACK_WORK, &st->status); @@ -109,15 +109,15 @@ send_layer2(struct mISDNstack *st, struct sk_buff *skb) if (ret) { if (*debug & DEBUG_SEND_ERR) printk(KERN_DEBUG - "%s ch%d prim(%x) addr(%x)" - " err %d\n", - __func__, ch->nr, - hh->prim, ch->addr, ret); + "%s ch%d prim(%x) addr(%x)" + " err %d\n", + __func__, ch->nr, + hh->prim, ch->addr, ret); dev_kfree_skb(cskb); } } else { printk(KERN_WARNING "%s ch%d addr %x no mem\n", - __func__, ch->nr, ch->addr); + __func__, ch->nr, ch->addr); goto out; } } @@ -135,8 +135,8 @@ send_layer2(struct mISDNstack *st, struct sk_buff *skb) skb = NULL; else if (*debug & DEBUG_SEND_ERR) printk(KERN_DEBUG - "%s ch%d mgr prim(%x) addr(%x) err %d\n", - __func__, ch->nr, hh->prim, ch->addr, ret); + "%s ch%d mgr prim(%x) addr(%x) err %d\n", + __func__, ch->nr, hh->prim, ch->addr, ret); } out: mutex_unlock(&st->lmutex); @@ -154,7 +154,7 @@ send_msg_to_layer(struct mISDNstack *st, struct sk_buff *skb) lm = hh->prim & MISDN_LAYERMASK; if (*debug & DEBUG_QUEUE_FUNC) printk(KERN_DEBUG "%s prim(%x) id(%x) %p\n", - __func__, hh->prim, hh->id, skb); + __func__, hh->prim, hh->id, skb); if (lm == 0x1) { if (!hlist_empty(&st->l1sock.head)) { __net_timestamp(skb); @@ -172,9 +172,9 @@ send_msg_to_layer(struct mISDNstack *st, struct sk_buff *skb) return ch->send(ch, skb); else printk(KERN_WARNING - "%s: dev(%s) prim(%x) id(%x) no channel\n", - __func__, dev_name(&st->dev->dev), hh->prim, - hh->id); + "%s: dev(%s) prim(%x) id(%x) no channel\n", + __func__, dev_name(&st->dev->dev), hh->prim, + hh->id); } else if (lm == 0x8) { WARN_ON(lm == 0x8); ch = get_channel4id(st, hh->id); @@ -182,13 +182,13 @@ send_msg_to_layer(struct mISDNstack *st, struct sk_buff *skb) return ch->send(ch, skb); else printk(KERN_WARNING - "%s: dev(%s) prim(%x) id(%x) no channel\n", - __func__, dev_name(&st->dev->dev), hh->prim, - hh->id); + "%s: dev(%s) prim(%x) id(%x) no channel\n", + __func__, dev_name(&st->dev->dev), hh->prim, + hh->id); } else { /* broadcast not handled yet */ printk(KERN_WARNING "%s: dev(%s) prim %x not delivered\n", - __func__, dev_name(&st->dev->dev), hh->prim); + __func__, dev_name(&st->dev->dev), hh->prim); } return -ESRCH; } @@ -207,7 +207,7 @@ mISDNStackd(void *data) sigfillset(¤t->blocked); if (*debug & DEBUG_MSG_THREAD) printk(KERN_DEBUG "mISDNStackd %s started\n", - dev_name(&st->dev->dev)); + dev_name(&st->dev->dev)); if (st->notify != NULL) { complete(st->notify); @@ -226,13 +226,13 @@ mISDNStackd(void *data) skb = skb_dequeue(&st->msgq); if (!skb) { test_and_clear_bit(mISDN_STACK_WORK, - &st->status); + &st->status); /* test if a race happens */ skb = skb_dequeue(&st->msgq); if (!skb) continue; test_and_set_bit(mISDN_STACK_WORK, - &st->status); + &st->status); } #ifdef MISDN_MSG_STATS st->msg_cnt++; @@ -241,20 +241,20 @@ mISDNStackd(void *data) if (unlikely(err)) { if (*debug & DEBUG_SEND_ERR) printk(KERN_DEBUG - "%s: %s prim(%x) id(%x) " - "send call(%d)\n", - __func__, dev_name(&st->dev->dev), - mISDN_HEAD_PRIM(skb), - mISDN_HEAD_ID(skb), err); + "%s: %s prim(%x) id(%x) " + "send call(%d)\n", + __func__, dev_name(&st->dev->dev), + mISDN_HEAD_PRIM(skb), + mISDN_HEAD_ID(skb), err); dev_kfree_skb(skb); continue; } if (unlikely(test_bit(mISDN_STACK_STOPPED, - &st->status))) { + &st->status))) { test_and_clear_bit(mISDN_STACK_WORK, - &st->status); + &st->status); test_and_clear_bit(mISDN_STACK_RUNNING, - &st->status); + &st->status); break; } } @@ -270,7 +270,7 @@ mISDNStackd(void *data) test_and_set_bit(mISDN_STACK_RUNNING, &st->status); if (!skb_queue_empty(&st->msgq)) test_and_set_bit(mISDN_STACK_WORK, - &st->status); + &st->status); } if (test_bit(mISDN_STACK_ABORT, &st->status)) break; @@ -283,10 +283,10 @@ mISDNStackd(void *data) #endif test_and_clear_bit(mISDN_STACK_ACTIVE, &st->status); wait_event_interruptible(st->workq, (st->status & - mISDN_STACK_ACTION_MASK)); + mISDN_STACK_ACTION_MASK)); if (*debug & DEBUG_MSG_THREAD) printk(KERN_DEBUG "%s: %s wake status %08lx\n", - __func__, dev_name(&st->dev->dev), st->status); + __func__, dev_name(&st->dev->dev), st->status); test_and_set_bit(mISDN_STACK_ACTIVE, &st->status); test_and_clear_bit(mISDN_STACK_WAKEUP, &st->status); @@ -300,17 +300,17 @@ mISDNStackd(void *data) } #ifdef MISDN_MSG_STATS printk(KERN_DEBUG "mISDNStackd daemon for %s proceed %d " - "msg %d sleep %d stopped\n", - dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt, - st->stopped_cnt); + "msg %d sleep %d stopped\n", + dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt, + st->stopped_cnt); printk(KERN_DEBUG - "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n", - dev_name(&st->dev->dev), st->thread->utime, st->thread->stime); + "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n", + dev_name(&st->dev->dev), st->thread->utime, st->thread->stime); printk(KERN_DEBUG - "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n", - dev_name(&st->dev->dev), st->thread->nvcsw, st->thread->nivcsw); + "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n", + dev_name(&st->dev->dev), st->thread->nvcsw, st->thread->nivcsw); printk(KERN_DEBUG "mISDNStackd daemon for %s killed now\n", - dev_name(&st->dev->dev)); + dev_name(&st->dev->dev)); #endif test_and_set_bit(mISDN_STACK_KILLED, &st->status); test_and_clear_bit(mISDN_STACK_RUNNING, &st->status); @@ -401,15 +401,15 @@ create_stack(struct mISDNdevice *dev) newst->own.recv = mISDN_queue_message; if (*debug & DEBUG_CORE_FUNC) printk(KERN_DEBUG "%s: st(%s)\n", __func__, - dev_name(&newst->dev->dev)); + dev_name(&newst->dev->dev)); newst->notify = &done; newst->thread = kthread_run(mISDNStackd, (void *)newst, "mISDN_%s", - dev_name(&newst->dev->dev)); + dev_name(&newst->dev->dev)); if (IS_ERR(newst->thread)) { err = PTR_ERR(newst->thread); printk(KERN_ERR - "mISDN:cannot create kernel thread for %s (%d)\n", - dev_name(&newst->dev->dev), err); + "mISDN:cannot create kernel thread for %s (%d)\n", + dev_name(&newst->dev->dev), err); delete_teimanager(dev->teimgr); kfree(newst); } else @@ -419,7 +419,7 @@ create_stack(struct mISDNdevice *dev) int connect_layer1(struct mISDNdevice *dev, struct mISDNchannel *ch, - u_int protocol, struct sockaddr_mISDN *adr) + u_int protocol, struct sockaddr_mISDN *adr) { struct mISDN_sock *msk = container_of(ch, struct mISDN_sock, ch); struct channel_req rq; @@ -428,8 +428,8 @@ connect_layer1(struct mISDNdevice *dev, struct mISDNchannel *ch, if (*debug & DEBUG_CORE_FUNC) printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", - __func__, dev_name(&dev->dev), protocol, adr->dev, - adr->channel, adr->sapi, adr->tei); + __func__, dev_name(&dev->dev), protocol, adr->dev, + adr->channel, adr->sapi, adr->tei); switch (protocol) { case ISDN_P_NT_S0: case ISDN_P_NT_E1: @@ -442,7 +442,7 @@ connect_layer1(struct mISDNdevice *dev, struct mISDNchannel *ch, rq.adr.channel = adr->channel; err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq); printk(KERN_DEBUG "%s: ret %d (dev %d)\n", __func__, err, - dev->id); + dev->id); if (err) return err; write_lock_bh(&dev->D.st->l1sock.lock); @@ -457,7 +457,7 @@ connect_layer1(struct mISDNdevice *dev, struct mISDNchannel *ch, int connect_Bstack(struct mISDNdevice *dev, struct mISDNchannel *ch, - u_int protocol, struct sockaddr_mISDN *adr) + u_int protocol, struct sockaddr_mISDN *adr) { struct channel_req rq, rq2; int pmask, err; @@ -465,9 +465,9 @@ connect_Bstack(struct mISDNdevice *dev, struct mISDNchannel *ch, if (*debug & DEBUG_CORE_FUNC) printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", - __func__, dev_name(&dev->dev), protocol, - adr->dev, adr->channel, adr->sapi, - adr->tei); + __func__, dev_name(&dev->dev), protocol, + adr->dev, adr->channel, adr->sapi, + adr->tei); ch->st = dev->D.st; pmask = 1 << (protocol & ISDN_P_B_MASK); if (pmask & dev->Bprotocols) { @@ -514,16 +514,16 @@ connect_Bstack(struct mISDNdevice *dev, struct mISDNchannel *ch, int create_l2entity(struct mISDNdevice *dev, struct mISDNchannel *ch, - u_int protocol, struct sockaddr_mISDN *adr) + u_int protocol, struct sockaddr_mISDN *adr) { struct channel_req rq; int err; if (*debug & DEBUG_CORE_FUNC) printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", - __func__, dev_name(&dev->dev), protocol, - adr->dev, adr->channel, adr->sapi, - adr->tei); + __func__, dev_name(&dev->dev), protocol, + adr->dev, adr->channel, adr->sapi, + adr->tei); rq.protocol = ISDN_P_TE_S0; if (dev->Dprotocols & (1 << ISDN_P_TE_E1)) rq.protocol = ISDN_P_TE_E1; @@ -573,7 +573,7 @@ delete_channel(struct mISDNchannel *ch) } if (*debug & DEBUG_CORE_FUNC) printk(KERN_DEBUG "%s: st(%s) protocol(%x)\n", __func__, - dev_name(&ch->st->dev->dev), ch->protocol); + dev_name(&ch->st->dev->dev), ch->protocol); if (ch->protocol >= ISDN_P_B_START) { if (ch->peer) { ch->peer->ctrl(ch->peer, CLOSE_CHANNEL, NULL); @@ -602,7 +602,7 @@ delete_channel(struct mISDNchannel *ch) pch->ctrl(pch, CLOSE_CHANNEL, NULL); } else printk(KERN_WARNING "%s: no l2 channel\n", - __func__); + __func__); break; case ISDN_P_LAPD_NT: pch = ch->st->dev->teimgr; @@ -610,7 +610,7 @@ delete_channel(struct mISDNchannel *ch) pch->ctrl(pch, CLOSE_CHANNEL, NULL); } else printk(KERN_WARNING "%s: no l2 channel\n", - __func__); + __func__); break; default: break; @@ -626,14 +626,14 @@ delete_stack(struct mISDNdevice *dev) if (*debug & DEBUG_CORE_FUNC) printk(KERN_DEBUG "%s: st(%s)\n", __func__, - dev_name(&st->dev->dev)); + dev_name(&st->dev->dev)); if (dev->teimgr) delete_teimanager(dev->teimgr); if (st->thread) { if (st->notify) { printk(KERN_WARNING "%s: notifier in use\n", - __func__); - complete(st->notify); + __func__); + complete(st->notify); } st->notify = &done; test_and_set_bit(mISDN_STACK_ABORT, &st->status); @@ -643,10 +643,10 @@ delete_stack(struct mISDNdevice *dev) } if (!list_empty(&st->layer2)) printk(KERN_WARNING "%s: layer2 list not empty\n", - __func__); + __func__); if (!hlist_empty(&st->l1sock.head)) printk(KERN_WARNING "%s: layer1 list not empty\n", - __func__); + __func__); kfree(st); } diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c index 687c9b6264ab..ba2bc0c776e2 100644 --- a/drivers/isdn/mISDN/tei.c +++ b/drivers/isdn/mISDN/tei.c @@ -34,7 +34,7 @@ #define DATIMER_VAL 10000 -static u_int *debug; +static u_int *debug; static struct Fsm deactfsm = {NULL, 0, 0, NULL, NULL}; static struct Fsm teifsmu = {NULL, 0, 0, NULL, NULL}; @@ -45,7 +45,7 @@ enum { ST_L1_DEACT_PENDING, ST_L1_ACTIV, }; -#define DEACT_STATE_COUNT (ST_L1_ACTIV+1) +#define DEACT_STATE_COUNT (ST_L1_ACTIV + 1) static char *strDeactState[] = { @@ -63,7 +63,7 @@ enum { EV_DATIMER, }; -#define DEACT_EVENT_COUNT (EV_DATIMER+1) +#define DEACT_EVENT_COUNT (EV_DATIMER + 1) static char *strDeactEvent[] = { @@ -130,7 +130,7 @@ da_deactivate(struct FsmInst *fi, int event, void *arg) /* All TEI are inactiv */ if (!test_bit(OPTION_L1_HOLD, &mgr->options)) { mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, - NULL, 1); + NULL, 1); mISDN_FsmChangeState(fi, ST_L1_DEACT_PENDING); } } @@ -144,7 +144,7 @@ da_ui(struct FsmInst *fi, int event, void *arg) if (!test_bit(OPTION_L1_HOLD, &mgr->options)) { mISDN_FsmDelTimer(&mgr->datimer, 2); mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, - NULL, 2); + NULL, 2); } } @@ -169,7 +169,7 @@ da_timer(struct FsmInst *fi, int event, void *arg) /* All TEI are inactiv */ mISDN_FsmChangeState(fi, ST_L1_DEACT); _queue_data(&mgr->ch, PH_DEACTIVATE_REQ, MISDN_ID_ANY, 0, NULL, - GFP_ATOMIC); + GFP_ATOMIC); } static struct FsmNode DeactFnList[] = @@ -188,7 +188,7 @@ enum { ST_TEI_IDVERIFY, }; -#define TEI_STATE_COUNT (ST_TEI_IDVERIFY+1) +#define TEI_STATE_COUNT (ST_TEI_IDVERIFY + 1) static char *strTeiState[] = { @@ -209,7 +209,7 @@ enum { EV_TIMER, }; -#define TEI_EVENT_COUNT (EV_TIMER+1) +#define TEI_EVENT_COUNT (EV_TIMER + 1) static char *strTeiEvent[] = { @@ -257,8 +257,8 @@ get_free_id(struct manager *mgr) list_for_each_entry(l2, &mgr->layer2, list) { if (l2->ch.nr > 63) { printk(KERN_WARNING - "%s: more as 63 layer2 for one device\n", - __func__); + "%s: more as 63 layer2 for one device\n", + __func__); return -EBUSY; } test_and_set_bit(l2->ch.nr, (u_long *)&ids); @@ -267,7 +267,7 @@ get_free_id(struct manager *mgr) if (!test_bit(i, (u_long *)&ids)) return i; printk(KERN_WARNING "%s: more as 63 layer2 for one device\n", - __func__); + __func__); return -EBUSY; } @@ -294,7 +294,7 @@ get_free_tei(struct manager *mgr) if (!test_bit(i, (u_long *)&ids)) return i + 64; printk(KERN_WARNING "%s: more as 63 dynamic tei for one device\n", - __func__); + __func__); return -1; } @@ -385,7 +385,7 @@ mgr_send_down(struct manager *mgr, struct sk_buff *skb) skb_queue_tail(&mgr->sendq, skb); if (!test_bit(MGR_PH_ACTIVE, &mgr->options)) { _queue_data(&mgr->ch, PH_ACTIVATE_REQ, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); } else { do_send(mgr); } @@ -398,7 +398,7 @@ dl_unit_data(struct manager *mgr, struct sk_buff *skb) return -EINVAL; if (!test_bit(MGR_PH_ACTIVE, &mgr->options)) _queue_data(&mgr->ch, PH_ACTIVATE_REQ, MISDN_ID_ANY, 0, - NULL, GFP_KERNEL); + NULL, GFP_KERNEL); skb_push(skb, 3); skb->data[0] = 0x02; /* SAPI 0 C/R = 1 */ skb->data[1] = 0xff; /* TEI 127 */ @@ -468,14 +468,14 @@ tei_id_request(struct FsmInst *fi, int event, void *arg) if (tm->l2->tei != GROUP_TEI) { tm->tei_m.printdebug(&tm->tei_m, - "assign request for already assigned tei %d", - tm->l2->tei); + "assign request for already assigned tei %d", + tm->l2->tei); return; } tm->ri = random_ri(); if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(&tm->tei_m, - "assign request ri %d", tm->ri); + "assign request ri %d", tm->ri); put_tei_msg(tm->mgr, ID_REQUEST, tm->ri, GROUP_TEI); mISDN_FsmChangeState(fi, ST_TEI_IDREQ); mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 1); @@ -496,12 +496,12 @@ tei_id_assign(struct FsmInst *fi, int event, void *arg) tei = *dp >> 1; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "identity assign ri %d tei %d", - ri, tei); + ri, tei); l2 = findtei(tm->mgr, tei); if (l2) { /* same tei is in use */ if (ri != l2->tm->ri) { tm->tei_m.printdebug(fi, - "possible duplicate assignment tei %d", tei); + "possible duplicate assignment tei %d", tei); tei_l2(l2, MDL_ERROR_RSP, 0); } } else if (ri == tm->ri) { @@ -525,12 +525,12 @@ tei_id_test_dup(struct FsmInst *fi, int event, void *arg) tei = *dp >> 1; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "foreign identity assign ri %d tei %d", - ri, tei); + ri, tei); l2 = findtei(tm->mgr, tei); if (l2) { /* same tei is in use */ if (ri != l2->tm->ri) { /* and it wasn't our request */ tm->tei_m.printdebug(fi, - "possible duplicate assignment tei %d", tei); + "possible duplicate assignment tei %d", tei); mISDN_FsmEvent(&l2->tm->tei_m, EV_VERIFY, NULL); } } @@ -549,7 +549,7 @@ tei_id_denied(struct FsmInst *fi, int event, void *arg) tei = *dp >> 1; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "identity denied ri %d tei %d", - ri, tei); + ri, tei); } static void @@ -559,11 +559,11 @@ tei_id_chk_req(struct FsmInst *fi, int event, void *arg) u_char *dp = arg; int tei; - tei = *(dp+3) >> 1; + tei = *(dp + 3) >> 1; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "identity check req tei %d", tei); if ((tm->l2->tei != GROUP_TEI) && ((tei == GROUP_TEI) || - (tei == tm->l2->tei))) { + (tei == tm->l2->tei))) { mISDN_FsmDelTimer(&tm->timer, 4); mISDN_FsmChangeState(&tm->tei_m, ST_TEI_NOP); put_tei_msg(tm->mgr, ID_CHK_RES, random_ri(), tm->l2->tei); @@ -577,7 +577,7 @@ tei_id_remove(struct FsmInst *fi, int event, void *arg) u_char *dp = arg; int tei; - tei = *(dp+3) >> 1; + tei = *(dp + 3) >> 1; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "identity remove tei %d", tei); if ((tm->l2->tei != GROUP_TEI) && @@ -595,7 +595,7 @@ tei_id_verify(struct FsmInst *fi, int event, void *arg) if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "id verify request for tei %d", - tm->l2->tei); + tm->l2->tei); put_tei_msg(tm->mgr, ID_VERIFY, 0, tm->l2->tei); mISDN_FsmChangeState(&tm->tei_m, ST_TEI_IDVERIFY); mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 2); @@ -611,7 +611,7 @@ tei_id_req_tout(struct FsmInst *fi, int event, void *arg) tm->ri = random_ri(); if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "assign req(%d) ri %d", - 4 - tm->nval, tm->ri); + 4 - tm->nval, tm->ri); put_tei_msg(tm->mgr, ID_REQUEST, tm->ri, GROUP_TEI); mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 3); } else { @@ -629,13 +629,13 @@ tei_id_ver_tout(struct FsmInst *fi, int event, void *arg) if (--tm->nval) { if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, - "id verify req(%d) for tei %d", - 3 - tm->nval, tm->l2->tei); + "id verify req(%d) for tei %d", + 3 - tm->nval, tm->l2->tei); put_tei_msg(tm->mgr, ID_VERIFY, 0, tm->l2->tei); mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 4); } else { tm->tei_m.printdebug(fi, "verify req for tei %d failed", - tm->l2->tei); + tm->l2->tei); tei_l2(tm->l2, MDL_REMOVE_REQ, 0); mISDN_FsmChangeState(fi, ST_TEI_NOP); } @@ -673,14 +673,14 @@ tei_assign_req(struct FsmInst *fi, int event, void *arg) if (tm->l2->tei == GROUP_TEI) { tm->tei_m.printdebug(&tm->tei_m, - "net tei assign request without tei"); + "net tei assign request without tei"); return; } tm->ri = ((unsigned int) *dp++ << 8); tm->ri += *dp++; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(&tm->tei_m, - "net assign request ri %d teim %d", tm->ri, *dp); + "net assign request ri %d teim %d", tm->ri, *dp); put_tei_msg(tm->mgr, ID_ASSIGNED, tm->ri, tm->l2->tei); mISDN_FsmChangeState(fi, ST_TEI_NOP); } @@ -692,7 +692,7 @@ tei_id_chk_req_net(struct FsmInst *fi, int event, void *arg) if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "id check request for tei %d", - tm->l2->tei); + tm->l2->tei); tm->rcnt = 0; put_tei_msg(tm->mgr, ID_CHK_REQ, 0, tm->l2->tei); mISDN_FsmChangeState(&tm->tei_m, ST_TEI_IDVERIFY); @@ -724,7 +724,7 @@ tei_id_verify_net(struct FsmInst *fi, int event, void *arg) tei = dp[3] >> 1; if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, "identity verify req tei %d/%d", - tei, tm->l2->tei); + tei, tm->l2->tei); if (tei == tm->l2->tei) tei_id_chk_req_net(fi, event, arg); } @@ -737,7 +737,7 @@ tei_id_ver_tout_net(struct FsmInst *fi, int event, void *arg) if (tm->rcnt == 1) { if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, - "check req for tei %d successful\n", tm->l2->tei); + "check req for tei %d successful\n", tm->l2->tei); mISDN_FsmChangeState(fi, ST_TEI_NOP); } else if (tm->rcnt > 1) { /* duplicate assignment; remove */ @@ -745,13 +745,13 @@ tei_id_ver_tout_net(struct FsmInst *fi, int event, void *arg) } else if (--tm->nval) { if (*debug & DEBUG_L2_TEI) tm->tei_m.printdebug(fi, - "id check req(%d) for tei %d", - 3 - tm->nval, tm->l2->tei); + "id check req(%d) for tei %d", + 3 - tm->nval, tm->l2->tei); put_tei_msg(tm->mgr, ID_CHK_REQ, 0, tm->l2->tei); mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 4); } else { tm->tei_m.printdebug(fi, "check req for tei %d failed", - tm->l2->tei); + tm->l2->tei); mISDN_FsmChangeState(fi, ST_TEI_NOP); tei_l2remove(tm->l2); } @@ -800,7 +800,7 @@ create_new_tei(struct manager *mgr, int tei, int sapi) if ((tei >= 0) && (tei < 64)) test_and_set_bit(OPTION_L2_FIXEDTEI, &opt); if (mgr->ch.st->dev->Dprotocols - & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1))) + & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1))) test_and_set_bit(OPTION_L2_PMX, &opt); l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, opt, tei, sapi); if (!l2) { @@ -880,7 +880,7 @@ ph_data_ind(struct manager *mgr, struct sk_buff *skb) if (skb->len < 8) { if (*debug & DEBUG_L2_TEI) printk(KERN_DEBUG "%s: short mgr frame %d/8\n", - __func__, skb->len); + __func__, skb->len); goto done; } @@ -979,15 +979,15 @@ static int create_teimgr(struct manager *mgr, struct channel_req *crq) { struct layer2 *l2; - u_long opt = 0; + u_long opt = 0; u_long flags; int id; if (*debug & DEBUG_L2_TEI) printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", - __func__, dev_name(&mgr->ch.st->dev->dev), - crq->protocol, crq->adr.dev, crq->adr.channel, - crq->adr.sapi, crq->adr.tei); + __func__, dev_name(&mgr->ch.st->dev->dev), + crq->protocol, crq->adr.dev, crq->adr.channel, + crq->adr.sapi, crq->adr.tei); if (crq->adr.tei > GROUP_TEI) return -EINVAL; if (crq->adr.tei < 64) @@ -1001,8 +1001,8 @@ create_teimgr(struct manager *mgr, struct channel_req *crq) return -EINVAL; if (mgr->up) { printk(KERN_WARNING - "%s: only one network manager is allowed\n", - __func__); + "%s: only one network manager is allowed\n", + __func__); return -EBUSY; } } else if (test_bit(MGR_OPT_USER, &mgr->options)) { @@ -1017,7 +1017,7 @@ create_teimgr(struct manager *mgr, struct channel_req *crq) test_and_set_bit(MGR_OPT_USER, &mgr->options); } if (mgr->ch.st->dev->Dprotocols - & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1))) + & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1))) test_and_set_bit(OPTION_L2_PMX, &opt); if ((crq->protocol == ISDN_P_LAPD_NT) && (crq->adr.tei == 127)) { mgr->up = crq->ch; @@ -1035,7 +1035,7 @@ create_teimgr(struct manager *mgr, struct channel_req *crq) return 0; } l2 = create_l2(crq->ch, crq->protocol, opt, - crq->adr.tei, crq->adr.sapi); + crq->adr.tei, crq->adr.sapi); if (!l2) return -ENOMEM; l2->tm = kzalloc(sizeof(struct teimgr), GFP_KERNEL); @@ -1084,7 +1084,7 @@ mgr_send(struct mISDNchannel *ch, struct sk_buff *skb) mgr = container_of(ch, struct manager, ch); if (*debug & DEBUG_L2_RECV) printk(KERN_DEBUG "%s: prim(%x) id(%x)\n", - __func__, hh->prim, hh->id); + __func__, hh->prim, hh->id); switch (hh->prim) { case PH_DATA_IND: mISDN_FsmEvent(&mgr->deact, EV_UI, NULL); @@ -1181,7 +1181,7 @@ check_data(struct manager *mgr, struct sk_buff *skb) if (*debug & DEBUG_L2_CTRL) printk(KERN_DEBUG "%s: prim(%x) id(%x)\n", - __func__, hh->prim, hh->id); + __func__, hh->prim, hh->id); if (test_bit(MGR_OPT_USER, &mgr->options)) return -ENOTCONN; if (hh->prim != PH_DATA_IND) @@ -1201,12 +1201,12 @@ check_data(struct manager *mgr, struct sk_buff *skb) /* We got a SABME for a fixed TEI */ if (*debug & DEBUG_L2_CTRL) printk(KERN_DEBUG "%s: SABME sapi(%d) tei(%d)\n", - __func__, sapi, tei); + __func__, sapi, tei); l2 = create_new_tei(mgr, tei, sapi); if (!l2) { if (*debug & DEBUG_L2_CTRL) printk(KERN_DEBUG "%s: failed to create new tei\n", - __func__); + __func__); return -ENOMEM; } ret = l2->ch.send(&l2->ch, skb); @@ -1285,15 +1285,15 @@ mgr_bcast(struct mISDNchannel *ch, struct sk_buff *skb) if (ret) { if (*debug & DEBUG_SEND_ERR) printk(KERN_DEBUG - "%s ch%d prim(%x) addr(%x)" - " err %d\n", - __func__, l2->ch.nr, - hh->prim, l2->ch.addr, ret); + "%s ch%d prim(%x) addr(%x)" + " err %d\n", + __func__, l2->ch.nr, + hh->prim, l2->ch.addr, ret); } else cskb = NULL; } else { printk(KERN_WARNING "%s ch%d addr %x no mem\n", - __func__, ch->nr, ch->addr); + __func__, ch->nr, ch->addr); goto out; } } diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index 859c81e9483b..1094667d8f31 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c @@ -98,13 +98,13 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off) if (*debug & DEBUG_TIMER) printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__, - filep, buf, (int)count, off); + filep, buf, (int)count, off); if (list_empty(&dev->expired) && (dev->work == 0)) { if (filep->f_flags & O_NONBLOCK) return -EAGAIN; wait_event_interruptible(dev->wait, (dev->work || - !list_empty(&dev->expired))); + !list_empty(&dev->expired))); if (signal_pending(current)) return -ERESTARTSYS; } @@ -141,7 +141,7 @@ mISDN_poll(struct file *filep, poll_table *wait) mask |= (POLLIN | POLLRDNORM); if (*debug & DEBUG_TIMER) printk(KERN_DEBUG "%s work(%d) empty(%d)\n", __func__, - dev->work, list_empty(&dev->expired)); + dev->work, list_empty(&dev->expired)); } return mask; } @@ -161,7 +161,7 @@ dev_expire_timer(unsigned long data) static int misdn_add_timer(struct mISDNtimerdev *dev, int timeout) { - int id; + int id; u_long flags; struct mISDNtimer *timer; @@ -224,7 +224,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) if (*debug & DEBUG_TIMER) printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__, - filep, cmd, arg); + filep, cmd, arg); mutex_lock(&mISDN_mutex); switch (cmd) { case IMADDTIMER: @@ -235,7 +235,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) id = misdn_add_timer(dev, tout); if (*debug & DEBUG_TIMER) printk(KERN_DEBUG "%s add %d id %d\n", __func__, - tout, id); + tout, id); if (id < 0) { ret = id; break; diff --git a/drivers/isdn/pcbit/callbacks.c b/drivers/isdn/pcbit/callbacks.c index 976143b2346d..efb6d6a3639a 100644 --- a/drivers/isdn/pcbit/callbacks.c +++ b/drivers/isdn/pcbit/callbacks.c @@ -2,16 +2,16 @@ * Callbacks for the FSM * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ /* * Fix: 19981230 - Carlos Morgado - * Port of Nelson Escravana's fix to CalledPN + * Port of Nelson Escravana's fix to CalledPN * NULL pointer dereference in cb_in_1 (originally fixed in 2.0) */ @@ -39,86 +39,86 @@ ushort last_ref_num = 1; * */ -void cb_out_1(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *cbdata) +void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *cbdata) { struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; #ifdef DEBUG - printk(KERN_DEBUG "Called Party Number: %s\n", - cbdata->data.setup.CalledPN); + printk(KERN_DEBUG "Called Party Number: %s\n", + cbdata->data.setup.CalledPN); #endif - /* - * hdr - kmalloc in capi_conn_req - * - kfree when msg has been sent - */ + /* + * hdr - kmalloc in capi_conn_req + * - kfree when msg has been sent + */ - if ((len = capi_conn_req(cbdata->data.setup.CalledPN, &skb, + if ((len = capi_conn_req(cbdata->data.setup.CalledPN, &skb, chan->proto)) < 0) - { - printk("capi_conn_req failed\n"); - return; - } + { + printk("capi_conn_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; + refnum = last_ref_num++ & 0x7fffU; - chan->callref = 0; - chan->layer2link = 0; - chan->snum = 0; - chan->s_refnum = refnum; + chan->callref = 0; + chan->layer2link = 0; + chan->snum = 0; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_CONN_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_REQ, refnum, skb, len); } /* * rcv CONNECT * will go into ACTIVE state * send CONN_ACTIVE_RESP - * send Select protocol request + * send Select protocol request */ -void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *data) +void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *data) { - isdn_ctrl ictl; - struct sk_buff *skb; + isdn_ctrl ictl; + struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; - if ((len=capi_conn_active_resp(chan, &skb)) < 0) - { - printk("capi_conn_active_req failed\n"); - return; - } + if ((len = capi_conn_active_resp(chan, &skb)) < 0) + { + printk("capi_conn_active_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_CONN_ACTV_RESP, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_ACTV_RESP, refnum, skb, len); - ictl.command = ISDN_STAT_DCONN; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ictl.command = ISDN_STAT_DCONN; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); - /* ACTIVE D-channel */ + /* ACTIVE D-channel */ - /* Select protocol */ + /* Select protocol */ - if ((len=capi_select_proto_req(chan, &skb, 1 /*outgoing*/)) < 0) { - printk("capi_select_proto_req failed\n"); - return; - } + if ((len = capi_select_proto_req(chan, &skb, 1 /*outgoing*/)) < 0) { + printk("capi_select_proto_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); } @@ -127,22 +127,22 @@ void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, * inform user */ -void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *cbdata) +void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *cbdata) { - isdn_ctrl ictl; - unsigned short refnum; - struct sk_buff *skb; + isdn_ctrl ictl; + unsigned short refnum; + struct sk_buff *skb; int len; - ictl.command = ISDN_STAT_ICALL; - ictl.driver=dev->id; - ictl.arg=chan->id; - - /* - * ictl.num >= strlen() + strlen() + 5 - */ + ictl.command = ISDN_STAT_ICALL; + ictl.driver = dev->id; + ictl.arg = chan->id; + + /* + * ictl.num >= strlen() + strlen() + 5 + */ if (cbdata->data.setup.CallingPN == NULL) { printk(KERN_DEBUG "NULL CallingPN to phone; using 0\n"); @@ -167,18 +167,18 @@ void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, printk(KERN_DEBUG "statstr: %s\n", ictl.num); #endif - dev->dev_if->statcallb(&ictl); + dev->dev_if->statcallb(&ictl); + - - if ((len=capi_conn_resp(chan, &skb)) < 0) { - printk(KERN_DEBUG "capi_conn_resp failed\n"); - return; + if ((len = capi_conn_resp(chan, &skb)) < 0) { + printk(KERN_DEBUG "capi_conn_resp failed\n"); + return; } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_CONN_RESP, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_RESP, refnum, skb, len); } /* @@ -187,24 +187,24 @@ void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, * send CONNECT message CONNECT_ACTIVE_REQ in CAPI */ -void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - unsigned short refnum; + unsigned short refnum; struct sk_buff *skb; - int len; - - if ((len = capi_conn_active_req(chan, &skb)) < 0) { - printk(KERN_DEBUG "capi_conn_active_req failed\n"); - return; - } + int len; + + if ((len = capi_conn_active_req(chan, &skb)) < 0) { + printk(KERN_DEBUG "capi_conn_active_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; printk(KERN_DEBUG "sending MSG_CONN_ACTV_REQ\n"); - pcbit_l2_write(dev, MSG_CONN_ACTV_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_CONN_ACTV_REQ, refnum, skb, len); } /* @@ -213,23 +213,23 @@ void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan, * */ -void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - unsigned short refnum; - struct sk_buff *skb; + unsigned short refnum; + struct sk_buff *skb; int len; - - if ((len = capi_select_proto_req(chan, &skb, 0 /*incoming*/)) < 0) - { - printk("capi_select_proto_req failed\n"); - return; - } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + if ((len = capi_select_proto_req(chan, &skb, 0 /*incoming*/)) < 0) + { + printk("capi_select_proto_req failed\n"); + return; + } + + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len); } @@ -239,52 +239,52 @@ void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, * send disconnect resp * send msg to user */ -void cb_disc_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - struct sk_buff *skb; + struct sk_buff *skb; int len; - ushort refnum; - isdn_ctrl ictl; - - if ((len = capi_disc_resp(chan, &skb)) < 0) { - printk("capi_disc_resp failed\n"); - return; - } - - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; - - pcbit_l2_write(dev, MSG_DISC_RESP, refnum, skb, len); - - ictl.command = ISDN_STAT_BHUP; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ushort refnum; + isdn_ctrl ictl; + + if ((len = capi_disc_resp(chan, &skb)) < 0) { + printk("capi_disc_resp failed\n"); + return; + } + + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; + + pcbit_l2_write(dev, MSG_DISC_RESP, refnum, skb, len); + + ictl.command = ISDN_STAT_BHUP; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); } - + /* * User HANGUP on active/call proceeding state * send disc.req */ -void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - struct sk_buff *skb; + struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; - if ((len = capi_disc_req(chan->callref, &skb, CAUSE_NORMAL)) < 0) - { - printk("capi_disc_req failed\n"); - return; - } + if ((len = capi_disc_req(chan->callref, &skb, CAUSE_NORMAL)) < 0) + { + printk("capi_disc_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb, len); } /* @@ -292,18 +292,18 @@ void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, * Problem: when the HL driver sends the disc req itself * LL receives BHUP */ -void cb_disc_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { - isdn_ctrl ictl; + isdn_ctrl ictl; - ictl.command = ISDN_STAT_BHUP; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ictl.command = ISDN_STAT_BHUP; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); } -void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, +void cb_notdone(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data) { } @@ -311,38 +311,35 @@ void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, /* * send activate b-chan protocol */ -void cb_selp_1(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *data) +void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *data) { - struct sk_buff *skb; + struct sk_buff *skb; int len; - ushort refnum; + ushort refnum; - if ((len = capi_activate_transp_req(chan, &skb)) < 0) - { - printk("capi_conn_activate_transp_req failed\n"); - return; - } + if ((len = capi_activate_transp_req(chan, &skb)) < 0) + { + printk("capi_conn_activate_transp_req failed\n"); + return; + } - refnum = last_ref_num++ & 0x7fffU; - chan->s_refnum = refnum; + refnum = last_ref_num++ & 0x7fffU; + chan->s_refnum = refnum; - pcbit_l2_write(dev, MSG_ACT_TRANSP_REQ, refnum, skb, len); + pcbit_l2_write(dev, MSG_ACT_TRANSP_REQ, refnum, skb, len); } /* * Inform User that the B-channel is available */ -void cb_open(struct pcbit_dev * dev, struct pcbit_chan* chan, - struct callb_data *data) +void cb_open(struct pcbit_dev *dev, struct pcbit_chan *chan, + struct callb_data *data) { - isdn_ctrl ictl; + isdn_ctrl ictl; - ictl.command = ISDN_STAT_BCONN; - ictl.driver=dev->id; - ictl.arg=chan->id; - dev->dev_if->statcallb(&ictl); + ictl.command = ISDN_STAT_BCONN; + ictl.driver = dev->id; + ictl.arg = chan->id; + dev->dev_if->statcallb(&ictl); } - - - diff --git a/drivers/isdn/pcbit/callbacks.h b/drivers/isdn/pcbit/callbacks.h index 17aa0f54bfc3..a036b4a7ffad 100644 --- a/drivers/isdn/pcbit/callbacks.h +++ b/drivers/isdn/pcbit/callbacks.h @@ -2,10 +2,10 @@ * Callbacks prototypes for FSM * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -13,34 +13,32 @@ #define CALLBACKS_H -extern void cb_out_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_disc_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_disc_3(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_disc_3(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_notdone(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_selp_1(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); -extern void cb_open(struct pcbit_dev * dev, struct pcbit_chan* chan, +extern void cb_open(struct pcbit_dev *dev, struct pcbit_chan *chan, struct callb_data *data); #endif - - diff --git a/drivers/isdn/pcbit/capi.c b/drivers/isdn/pcbit/capi.c index ac5a91ccde81..4e3cbf857d60 100644 --- a/drivers/isdn/pcbit/capi.c +++ b/drivers/isdn/pcbit/capi.c @@ -3,10 +3,10 @@ * Portugal Telecom CAPI 2.0 * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. * * Not compatible with the AVM Gmbh. CAPI 2.0 @@ -51,39 +51,39 @@ * */ -int capi_conn_req(const char * calledPN, struct sk_buff **skb, int proto) +int capi_conn_req(const char *calledPN, struct sk_buff **skb, int proto) { - ushort len; - - /* - * length - * AppInfoMask - 2 - * BC0 - 3 - * BC1 - 1 - * Chan - 2 - * Keypad - 1 - * CPN - 1 - * CPSA - 1 - * CalledPN - 2 + strlen - * CalledPSA - 1 - * rest... - 4 - * ---------------- - * Total 18 + strlen - */ - - len = 18 + strlen(calledPN); + ushort len; + + /* + * length + * AppInfoMask - 2 + * BC0 - 3 + * BC1 - 1 + * Chan - 2 + * Keypad - 1 + * CPN - 1 + * CPSA - 1 + * CalledPN - 2 + strlen + * CalledPSA - 1 + * rest... - 4 + * ---------------- + * Total 18 + strlen + */ + + len = 18 + strlen(calledPN); if (proto == ISDN_PROTO_L2_TRANS) len++; if ((*skb = dev_alloc_skb(len)) == NULL) { - - printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n"); + + printk(KERN_WARNING "capi_conn_req: alloc_skb failed\n"); return -1; } - /* InfoElmMask */ - *((ushort*) skb_put(*skb, 2)) = AppInfoMask; + /* InfoElmMask */ + *((ushort *)skb_put(*skb, 2)) = AppInfoMask; if (proto == ISDN_PROTO_L2_TRANS) { @@ -101,162 +101,162 @@ int capi_conn_req(const char * calledPN, struct sk_buff **skb, int proto) *(skb_put(*skb, 1)) = 0x90; /* BC0.Octect4 */ } - /* Bearer Capability - Optional*/ - *(skb_put(*skb, 1)) = 0; /* BC1.Length = 0 */ + /* Bearer Capability - Optional*/ + *(skb_put(*skb, 1)) = 0; /* BC1.Length = 0 */ - *(skb_put(*skb, 1)) = 1; /* ChannelID.Length = 1 */ - *(skb_put(*skb, 1)) = 0x83; /* Basic Interface - Any Channel */ + *(skb_put(*skb, 1)) = 1; /* ChannelID.Length = 1 */ + *(skb_put(*skb, 1)) = 0x83; /* Basic Interface - Any Channel */ - *(skb_put(*skb, 1)) = 0; /* Keypad.Length = 0 */ - + *(skb_put(*skb, 1)) = 0; /* Keypad.Length = 0 */ - *(skb_put(*skb, 1)) = 0; /* CallingPN.Length = 0 */ - *(skb_put(*skb, 1)) = 0; /* CallingPSA.Length = 0 */ - /* Called Party Number */ - *(skb_put(*skb, 1)) = strlen(calledPN) + 1; - *(skb_put(*skb, 1)) = 0x81; - memcpy(skb_put(*skb, strlen(calledPN)), calledPN, strlen(calledPN)); + *(skb_put(*skb, 1)) = 0; /* CallingPN.Length = 0 */ + *(skb_put(*skb, 1)) = 0; /* CallingPSA.Length = 0 */ - /* '#' */ + /* Called Party Number */ + *(skb_put(*skb, 1)) = strlen(calledPN) + 1; + *(skb_put(*skb, 1)) = 0x81; + memcpy(skb_put(*skb, strlen(calledPN)), calledPN, strlen(calledPN)); - *(skb_put(*skb, 1)) = 0; /* CalledPSA.Length = 0 */ + /* '#' */ - /* LLC.Length = 0; */ - /* HLC0.Length = 0; */ - /* HLC1.Length = 0; */ - /* UTUS.Length = 0; */ - memset(skb_put(*skb, 4), 0, 4); + *(skb_put(*skb, 1)) = 0; /* CalledPSA.Length = 0 */ - return len; + /* LLC.Length = 0; */ + /* HLC0.Length = 0; */ + /* HLC1.Length = 0; */ + /* UTUS.Length = 0; */ + memset(skb_put(*skb, 4), 0, 4); + + return len; } -int capi_conn_resp(struct pcbit_chan* chan, struct sk_buff **skb) +int capi_conn_resp(struct pcbit_chan *chan, struct sk_buff **skb) { - + if ((*skb = dev_alloc_skb(5)) == NULL) { - + printk(KERN_WARNING "capi_conn_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; - *(skb_put(*skb, 1)) = 0x01; /* ACCEPT_CALL */ - *(skb_put(*skb, 1)) = 0; - *(skb_put(*skb, 1)) = 0; + *((ushort *)skb_put(*skb, 2)) = chan->callref; + *(skb_put(*skb, 1)) = 0x01; /* ACCEPT_CALL */ + *(skb_put(*skb, 1)) = 0; + *(skb_put(*skb, 1)) = 0; - return 5; + return 5; } -int capi_conn_active_req(struct pcbit_chan* chan, struct sk_buff **skb) +int capi_conn_active_req(struct pcbit_chan *chan, struct sk_buff **skb) { - /* - * 8 bytes - */ - + /* + * 8 bytes + */ + if ((*skb = dev_alloc_skb(8)) == NULL) { - + printk(KERN_WARNING "capi_conn_active_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; #ifdef DEBUG - printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); + printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); #endif - *(skb_put(*skb, 1)) = 0; /* BC.Length = 0; */ - *(skb_put(*skb, 1)) = 0; /* ConnectedPN.Length = 0 */ - *(skb_put(*skb, 1)) = 0; /* PSA.Length */ - *(skb_put(*skb, 1)) = 0; /* LLC.Length = 0; */ - *(skb_put(*skb, 1)) = 0; /* HLC.Length = 0; */ - *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* BC.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* ConnectedPN.Length = 0 */ + *(skb_put(*skb, 1)) = 0; /* PSA.Length */ + *(skb_put(*skb, 1)) = 0; /* LLC.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* HLC.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ return 8; } -int capi_conn_active_resp(struct pcbit_chan* chan, struct sk_buff **skb) +int capi_conn_active_resp(struct pcbit_chan *chan, struct sk_buff **skb) { - /* - * 2 bytes - */ - + /* + * 2 bytes + */ + if ((*skb = dev_alloc_skb(2)) == NULL) { - + printk(KERN_WARNING "capi_conn_active_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - return 2; + return 2; } -int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, - int outgoing) +int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, + int outgoing) { - /* - * 18 bytes - */ + /* + * 18 bytes + */ if ((*skb = dev_alloc_skb(18)) == NULL) { - + printk(KERN_WARNING "capi_select_proto_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - /* Layer2 protocol */ + /* Layer2 protocol */ - switch (chan->proto) { - case ISDN_PROTO_L2_X75I: - *(skb_put(*skb, 1)) = 0x05; /* LAPB */ - break; - case ISDN_PROTO_L2_HDLC: - *(skb_put(*skb, 1)) = 0x02; - break; + switch (chan->proto) { + case ISDN_PROTO_L2_X75I: + *(skb_put(*skb, 1)) = 0x05; /* LAPB */ + break; + case ISDN_PROTO_L2_HDLC: + *(skb_put(*skb, 1)) = 0x02; + break; case ISDN_PROTO_L2_TRANS: - /* + /* * Voice (a-law) */ *(skb_put(*skb, 1)) = 0x06; break; - default: -#ifdef DEBUG - printk(KERN_DEBUG "Transparent\n"); + default: +#ifdef DEBUG + printk(KERN_DEBUG "Transparent\n"); #endif - *(skb_put(*skb, 1)) = 0x03; - break; - } - - *(skb_put(*skb, 1)) = (outgoing ? 0x02 : 0x42); /* Don't ask */ - *(skb_put(*skb, 1)) = 0x00; - - *((ushort *) skb_put(*skb, 2)) = MRU; - - - *(skb_put(*skb, 1)) = 0x08; /* Modulo */ - *(skb_put(*skb, 1)) = 0x07; /* Max Window */ - - *(skb_put(*skb, 1)) = 0x01; /* No Layer3 Protocol */ - - /* - * 2 - layer3 MTU [10] - * - Modulo [12] - * - Window - * - layer1 proto [14] - * - bitrate - * - sub-channel [16] - * - layer1dataformat [17] - */ - - memset(skb_put(*skb, 8), 0, 8); - - return 18; + *(skb_put(*skb, 1)) = 0x03; + break; + } + + *(skb_put(*skb, 1)) = (outgoing ? 0x02 : 0x42); /* Don't ask */ + *(skb_put(*skb, 1)) = 0x00; + + *((ushort *) skb_put(*skb, 2)) = MRU; + + + *(skb_put(*skb, 1)) = 0x08; /* Modulo */ + *(skb_put(*skb, 1)) = 0x07; /* Max Window */ + + *(skb_put(*skb, 1)) = 0x01; /* No Layer3 Protocol */ + + /* + * 2 - layer3 MTU [10] + * - Modulo [12] + * - Window + * - layer1 proto [14] + * - bitrate + * - sub-channel [16] + * - layer1dataformat [17] + */ + + memset(skb_put(*skb, 8), 0, 8); + + return 18; } @@ -264,45 +264,45 @@ int capi_activate_transp_req(struct pcbit_chan *chan, struct sk_buff **skb) { if ((*skb = dev_alloc_skb(7)) == NULL) { - + printk(KERN_WARNING "capi_activate_transp_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - - *(skb_put(*skb, 1)) = chan->layer2link; /* Layer2 id */ - *(skb_put(*skb, 1)) = 0x00; /* Transmit by default */ - *((ushort *) skb_put(*skb, 2)) = MRU; + *(skb_put(*skb, 1)) = chan->layer2link; /* Layer2 id */ + *(skb_put(*skb, 1)) = 0x00; /* Transmit by default */ - *(skb_put(*skb, 1)) = 0x01; /* Enables reception*/ + *((ushort *) skb_put(*skb, 2)) = MRU; - return 7; + *(skb_put(*skb, 1)) = 0x01; /* Enables reception*/ + + return 7; } -int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb) +int capi_tdata_req(struct pcbit_chan *chan, struct sk_buff *skb) { ushort data_len; - - /* - * callref - 2 + + /* + * callref - 2 * layer2link - 1 - * wBlockLength - 2 + * wBlockLength - 2 * data - 4 * sernum - 1 */ - + data_len = skb->len; - if(skb_headroom(skb) < 10) + if (skb_headroom(skb) < 10) { printk(KERN_CRIT "No headspace (%u) on headroom %p for capi header\n", skb_headroom(skb), skb); } else - { + { skb_push(skb, 10); } @@ -318,58 +318,58 @@ int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb) return 10; } -int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff ** skb) - +int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb) + { if ((*skb = dev_alloc_skb(4)) == NULL) { - + printk(KERN_WARNING "capi_tdata_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - *(skb_put(*skb, 1)) = chan->layer2link; - *(skb_put(*skb, 1)) = chan->r_refnum; + *(skb_put(*skb, 1)) = chan->layer2link; + *(skb_put(*skb, 1)) = chan->r_refnum; - return (*skb)->len; + return (*skb)->len; } int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause) { if ((*skb = dev_alloc_skb(6)) == NULL) { - + printk(KERN_WARNING "capi_disc_req: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2) ) = callref; + *((ushort *)skb_put(*skb, 2)) = callref; - *(skb_put(*skb, 1)) = 2; /* Cause.Length = 2; */ - *(skb_put(*skb, 1)) = 0x80; - *(skb_put(*skb, 1)) = 0x80 | cause; + *(skb_put(*skb, 1)) = 2; /* Cause.Length = 2; */ + *(skb_put(*skb, 1)) = 0x80; + *(skb_put(*skb, 1)) = 0x80 | cause; - /* - * Change it: we should send 'Sic transit gloria Mundi' here ;-) - */ + /* + * Change it: we should send 'Sic transit gloria Mundi' here ;-) + */ - *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ + *(skb_put(*skb, 1)) = 0; /* UTUS.Length = 0; */ - return 6; + return 6; } int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb) { if ((*skb = dev_alloc_skb(2)) == NULL) { - + printk(KERN_WARNING "capi_disc_resp: alloc_skb failed\n"); return -1; } - *((ushort*) skb_put(*skb, 2)) = chan->callref; + *((ushort *)skb_put(*skb, 2)) = chan->callref; - return 2; + return 2; } @@ -378,57 +378,57 @@ int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb) * */ -int capi_decode_conn_ind(struct pcbit_chan * chan, - struct sk_buff *skb, - struct callb_data *info) +int capi_decode_conn_ind(struct pcbit_chan *chan, + struct sk_buff *skb, + struct callb_data *info) { - int CIlen, len; + int CIlen, len; - /* Call Reference [CAPI] */ - chan->callref = *((ushort*) skb->data); - skb_pull(skb, 2); + /* Call Reference [CAPI] */ + chan->callref = *((ushort *)skb->data); + skb_pull(skb, 2); #ifdef DEBUG - printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); + printk(KERN_DEBUG "Call Reference: %04x\n", chan->callref); #endif - /* Channel Identification */ + /* Channel Identification */ - /* Expect - Len = 1 - Octect 3 = 0100 10CC - [ 7 Basic, 4 , 2-1 chan ] - */ + /* Expect + Len = 1 + Octect 3 = 0100 10CC - [ 7 Basic, 4 , 2-1 chan ] + */ - CIlen = skb->data[0]; + CIlen = skb->data[0]; #ifdef DEBUG - if (CIlen == 1) { + if (CIlen == 1) { - if ( ((skb->data[1]) & 0xFC) == 0x48 ) - printk(KERN_DEBUG "decode_conn_ind: chan ok\n"); - printk(KERN_DEBUG "phyChan = %d\n", skb->data[1] & 0x03); - } + if (((skb->data[1]) & 0xFC) == 0x48) + printk(KERN_DEBUG "decode_conn_ind: chan ok\n"); + printk(KERN_DEBUG "phyChan = %d\n", skb->data[1] & 0x03); + } else printk(KERN_DEBUG "conn_ind: CIlen = %d\n", CIlen); #endif - skb_pull(skb, CIlen + 1); + skb_pull(skb, CIlen + 1); - /* Calling Party Number */ - /* An "additional service" as far as Portugal Telecom is concerned */ + /* Calling Party Number */ + /* An "additional service" as far as Portugal Telecom is concerned */ - len = skb->data[0]; + len = skb->data[0]; if (len > 0) { int count = 1; - + #ifdef DEBUG printk(KERN_DEBUG "CPN: Octect 3 %02x\n", skb->data[1]); #endif if ((skb->data[1] & 0x80) == 0) count = 2; - + if (!(info->data.setup.CallingPN = kmalloc(len - count + 1, GFP_ATOMIC))) return -1; - + skb_copy_from_linear_data_offset(skb, count + 1, info->data.setup.CallingPN, len - count); @@ -442,22 +442,22 @@ int capi_decode_conn_ind(struct pcbit_chan * chan, skb_pull(skb, len + 1); - /* Calling Party Subaddress */ - skb_pull(skb, skb->data[0] + 1); + /* Calling Party Subaddress */ + skb_pull(skb, skb->data[0] + 1); - /* Called Party Number */ + /* Called Party Number */ - len = skb->data[0]; + len = skb->data[0]; if (len > 0) { int count = 1; - + if ((skb->data[1] & 0x80) == 0) count = 2; - + if (!(info->data.setup.CalledPN = kmalloc(len - count + 1, GFP_ATOMIC))) return -1; - + skb_copy_from_linear_data_offset(skb, count + 1, info->data.setup.CalledPN, len - count); @@ -471,73 +471,73 @@ int capi_decode_conn_ind(struct pcbit_chan * chan, skb_pull(skb, len + 1); - /* Called Party Subaddress */ - skb_pull(skb, skb->data[0] + 1); + /* Called Party Subaddress */ + skb_pull(skb, skb->data[0] + 1); - /* LLC */ - skb_pull(skb, skb->data[0] + 1); + /* LLC */ + skb_pull(skb, skb->data[0] + 1); - /* HLC */ - skb_pull(skb, skb->data[0] + 1); + /* HLC */ + skb_pull(skb, skb->data[0] + 1); - /* U2U */ - skb_pull(skb, skb->data[0] + 1); + /* U2U */ + skb_pull(skb, skb->data[0] + 1); - return 0; + return 0; } /* * returns errcode */ -int capi_decode_conn_conf(struct pcbit_chan * chan, struct sk_buff *skb, - int *complete) +int capi_decode_conn_conf(struct pcbit_chan *chan, struct sk_buff *skb, + int *complete) { - int errcode; - - chan->callref = *((ushort *) skb->data); /* Update CallReference */ - skb_pull(skb, 2); + int errcode; + + chan->callref = *((ushort *)skb->data); /* Update CallReference */ + skb_pull(skb, 2); + + errcode = *((ushort *) skb->data); /* read errcode */ + skb_pull(skb, 2); - errcode = *((ushort *) skb->data); /* read errcode */ - skb_pull(skb, 2); + *complete = *(skb->data); + skb_pull(skb, 1); - *complete = *(skb->data); - skb_pull(skb, 1); + /* FIX ME */ + /* This is actually a firmware bug */ + if (!*complete) + { + printk(KERN_DEBUG "complete=%02x\n", *complete); + *complete = 1; + } - /* FIX ME */ - /* This is actually a firmware bug */ - if (!*complete) - { - printk(KERN_DEBUG "complete=%02x\n", *complete); - *complete = 1; - } + /* Optional Bearer Capability */ + skb_pull(skb, *(skb->data) + 1); - /* Optional Bearer Capability */ - skb_pull(skb, *(skb->data) + 1); - - /* Channel Identification */ - skb_pull(skb, *(skb->data) + 1); + /* Channel Identification */ + skb_pull(skb, *(skb->data) + 1); - /* High Layer Compatibility follows */ - skb_pull(skb, *(skb->data) + 1); + /* High Layer Compatibility follows */ + skb_pull(skb, *(skb->data) + 1); - return errcode; + return errcode; } -int capi_decode_conn_actv_ind(struct pcbit_chan * chan, struct sk_buff *skb) +int capi_decode_conn_actv_ind(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort len; + ushort len; #ifdef DEBUG - char str[32]; + char str[32]; #endif - /* Yet Another Bearer Capability */ - skb_pull(skb, *(skb->data) + 1); - + /* Yet Another Bearer Capability */ + skb_pull(skb, *(skb->data) + 1); - /* Connected Party Number */ - len=*(skb->data); + + /* Connected Party Number */ + len = *(skb->data); #ifdef DEBUG if (len > 1 && len < 31) { @@ -549,106 +549,101 @@ int capi_decode_conn_actv_ind(struct pcbit_chan * chan, struct sk_buff *skb) printk(KERN_DEBUG "actv_ind CPN len = %d\n", len); #endif - skb_pull(skb, len + 1); + skb_pull(skb, len + 1); - /* Connected Subaddress */ - skb_pull(skb, *(skb->data) + 1); + /* Connected Subaddress */ + skb_pull(skb, *(skb->data) + 1); - /* Low Layer Capability */ - skb_pull(skb, *(skb->data) + 1); + /* Low Layer Capability */ + skb_pull(skb, *(skb->data) + 1); - /* High Layer Capability */ - skb_pull(skb, *(skb->data) + 1); + /* High Layer Capability */ + skb_pull(skb, *(skb->data) + 1); - return 0; + return 0; } -int capi_decode_conn_actv_conf(struct pcbit_chan * chan, struct sk_buff *skb) +int capi_decode_conn_actv_conf(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort errcode; - - errcode = *((ushort*) skb->data); - skb_pull(skb, 2); - - /* Channel Identification - skb_pull(skb, skb->data[0] + 1); - */ - return errcode; + ushort errcode; + + errcode = *((ushort *)skb->data); + skb_pull(skb, 2); + + /* Channel Identification + skb_pull(skb, skb->data[0] + 1); + */ + return errcode; } int capi_decode_sel_proto_conf(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort errcode; - - chan->layer2link = *(skb->data); - skb_pull(skb, 1); + ushort errcode; - errcode = *((ushort*) skb->data); - skb_pull(skb, 2); + chan->layer2link = *(skb->data); + skb_pull(skb, 1); - return errcode; + errcode = *((ushort *)skb->data); + skb_pull(skb, 2); + + return errcode; } int capi_decode_actv_trans_conf(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort errcode; + ushort errcode; - if (chan->layer2link != *(skb->data) ) - printk("capi_decode_actv_trans_conf: layer2link doesn't match\n"); + if (chan->layer2link != *(skb->data)) + printk("capi_decode_actv_trans_conf: layer2link doesn't match\n"); - skb_pull(skb, 1); + skb_pull(skb, 1); - errcode = *((ushort*) skb->data); - skb_pull(skb, 2); + errcode = *((ushort *)skb->data); + skb_pull(skb, 2); - return errcode; + return errcode; } int capi_decode_disc_ind(struct pcbit_chan *chan, struct sk_buff *skb) { - ushort len; + ushort len; #ifdef DEBUG - int i; + int i; #endif - /* Cause */ - - len = *(skb->data); - skb_pull(skb, 1); + /* Cause */ + + len = *(skb->data); + skb_pull(skb, 1); #ifdef DEBUG - for (i=0; idata + i)); + for (i = 0; i < len; i++) + printk(KERN_DEBUG "Cause Octect %d: %02x\n", i + 3, + *(skb->data + i)); #endif - skb_pull(skb, len); + skb_pull(skb, len); - return 0; + return 0; } #ifdef DEBUG int capi_decode_debug_188(u_char *hdr, ushort hdrlen) { - char str[64]; - int len; - - len = hdr[0]; - - if (len < 64 && len == hdrlen - 1) { - memcpy(str, hdr + 1, hdrlen - 1); - str[hdrlen - 1] = 0; - printk("%s\n", str); - } - else - printk("debug message incorrect\n"); - - return 0; -} -#endif - - + char str[64]; + int len; + len = hdr[0]; + if (len < 64 && len == hdrlen - 1) { + memcpy(str, hdr + 1, hdrlen - 1); + str[hdrlen - 1] = 0; + printk("%s\n", str); + } + else + printk("debug message incorrect\n"); + return 0; +} +#endif diff --git a/drivers/isdn/pcbit/capi.h b/drivers/isdn/pcbit/capi.h index df8e73c04d7f..635f63476944 100644 --- a/drivers/isdn/pcbit/capi.h +++ b/drivers/isdn/pcbit/capi.h @@ -2,10 +2,10 @@ * CAPI encode/decode prototypes and defines * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -15,42 +15,42 @@ #define REQ_CAUSE 0x01 #define REQ_DISPLAY 0x04 -#define REQ_USER_TO_USER 0x08 +#define REQ_USER_TO_USER 0x08 -#define AppInfoMask REQ_CAUSE|REQ_DISPLAY|REQ_USER_TO_USER +#define AppInfoMask REQ_CAUSE | REQ_DISPLAY | REQ_USER_TO_USER /* Connection Setup */ -extern int capi_conn_req(const char * calledPN, struct sk_buff **buf, +extern int capi_conn_req(const char *calledPN, struct sk_buff **buf, int proto); -extern int capi_decode_conn_conf(struct pcbit_chan * chan, struct sk_buff *skb, - int *complete); +extern int capi_decode_conn_conf(struct pcbit_chan *chan, struct sk_buff *skb, + int *complete); -extern int capi_decode_conn_ind(struct pcbit_chan * chan, struct sk_buff *skb, +extern int capi_decode_conn_ind(struct pcbit_chan *chan, struct sk_buff *skb, struct callb_data *info); -extern int capi_conn_resp(struct pcbit_chan* chan, struct sk_buff **skb); +extern int capi_conn_resp(struct pcbit_chan *chan, struct sk_buff **skb); -extern int capi_conn_active_req(struct pcbit_chan* chan, struct sk_buff **skb); -extern int capi_decode_conn_actv_conf(struct pcbit_chan * chan, +extern int capi_conn_active_req(struct pcbit_chan *chan, struct sk_buff **skb); +extern int capi_decode_conn_actv_conf(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_decode_conn_actv_ind(struct pcbit_chan * chan, +extern int capi_decode_conn_actv_ind(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_conn_active_resp(struct pcbit_chan* chan, +extern int capi_conn_active_resp(struct pcbit_chan *chan, struct sk_buff **skb); /* Data */ extern int capi_select_proto_req(struct pcbit_chan *chan, struct sk_buff **skb, int outgoing); -extern int capi_decode_sel_proto_conf(struct pcbit_chan *chan, +extern int capi_decode_sel_proto_conf(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_activate_transp_req(struct pcbit_chan *chan, +extern int capi_activate_transp_req(struct pcbit_chan *chan, struct sk_buff **skb); -extern int capi_decode_actv_trans_conf(struct pcbit_chan *chan, +extern int capi_decode_actv_trans_conf(struct pcbit_chan *chan, struct sk_buff *skb); -extern int capi_tdata_req(struct pcbit_chan* chan, struct sk_buff *skb); -extern int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff ** skb); +extern int capi_tdata_req(struct pcbit_chan *chan, struct sk_buff *skb); +extern int capi_tdata_resp(struct pcbit_chan *chan, struct sk_buff **skb); /* Connection Termination */ extern int capi_disc_req(ushort callref, struct sk_buff **skb, u_char cause); @@ -62,12 +62,12 @@ extern int capi_disc_resp(struct pcbit_chan *chan, struct sk_buff **skb); extern int capi_decode_debug_188(u_char *hdr, ushort hdrlen); #endif -static inline struct pcbit_chan * +static inline struct pcbit_chan * capi_channel(struct pcbit_dev *dev, struct sk_buff *skb) { ushort callref; - callref = *((ushort*) skb->data); + callref = *((ushort *)skb->data); skb_pull(skb, 2); if (dev->b1->callref == callref) @@ -79,9 +79,3 @@ capi_channel(struct pcbit_dev *dev, struct sk_buff *skb) } #endif - - - - - - diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c index 1507d2e83fbb..1eaf62273903 100644 --- a/drivers/isdn/pcbit/drv.c +++ b/drivers/isdn/pcbit/drv.c @@ -2,10 +2,10 @@ * PCBIT-D interface with isdn4linux * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -14,7 +14,7 @@ * * Nuno Grilo * fixed msn_list NULL pointer dereference. - * + * */ #include @@ -43,9 +43,9 @@ extern ushort last_ref_num; -static int pcbit_ioctl(isdn_ctrl* ctl); +static int pcbit_ioctl(isdn_ctrl *ctl); -static char* pcbit_devname[MAX_PCBIT_CARDS] = { +static char *pcbit_devname[MAX_PCBIT_CARDS] = { "pcbit0", "pcbit1", "pcbit2", @@ -56,12 +56,12 @@ static char* pcbit_devname[MAX_PCBIT_CARDS] = { * prototypes */ -static int pcbit_command(isdn_ctrl* ctl); -static int pcbit_stat(u_char __user * buf, int len, int, int); +static int pcbit_command(isdn_ctrl *ctl); +static int pcbit_stat(u_char __user *buf, int len, int, int); static int pcbit_xmit(int driver, int chan, int ack, struct sk_buff *skb); static int pcbit_writecmd(const u_char __user *, int, int, int); -static int set_protocol_running(struct pcbit_dev * dev); +static int set_protocol_running(struct pcbit_dev *dev); static void pcbit_clear_msn(struct pcbit_dev *dev); static void pcbit_set_msn(struct pcbit_dev *dev, char *list); @@ -73,7 +73,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) struct pcbit_dev *dev; isdn_if *dev_if; - if ((dev=kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) + if ((dev = kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) { printk("pcbit_init: couldn't malloc pcbit_dev struct\n"); return -ENOMEM; @@ -83,19 +83,19 @@ int pcbit_init_dev(int board, int mem_base, int irq) init_waitqueue_head(&dev->set_running_wq); spin_lock_init(&dev->lock); - if (mem_base >= 0xA0000 && mem_base <= 0xFFFFF ) { + if (mem_base >= 0xA0000 && mem_base <= 0xFFFFF) { dev->ph_mem = mem_base; if (!request_mem_region(dev->ph_mem, 4096, "PCBIT mem")) { printk(KERN_WARNING - "PCBIT: memory region %lx-%lx already in use\n", - dev->ph_mem, dev->ph_mem + 4096); + "PCBIT: memory region %lx-%lx already in use\n", + dev->ph_mem, dev->ph_mem + 4096); kfree(dev); dev_pcbit[board] = NULL; return -EACCES; } dev->sh_mem = ioremap(dev->ph_mem, 4096); } - else + else { printk("memory address invalid"); kfree(dev); @@ -111,7 +111,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) kfree(dev); return -ENOMEM; } - + dev->b2 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL); if (!dev->b2) { printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); @@ -130,7 +130,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) * interrupts */ - if (request_irq(irq, &pcbit_irq_handler, 0, pcbit_devname[board], dev) != 0) + if (request_irq(irq, &pcbit_irq_handler, 0, pcbit_devname[board], dev) != 0) { kfree(dev->b1); kfree(dev->b2); @@ -168,16 +168,16 @@ int pcbit_init_dev(int board, int mem_base, int irq) dev_if->owner = THIS_MODULE; dev_if->channels = 2; - - dev_if->features = (ISDN_FEATURE_P_EURO | ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L2_TRANS ); + + dev_if->features = (ISDN_FEATURE_P_EURO | ISDN_FEATURE_L3_TRANS | + ISDN_FEATURE_L2_HDLC | ISDN_FEATURE_L2_TRANS); dev_if->writebuf_skb = pcbit_xmit; dev_if->hl_hdrlen = 16; dev_if->maxbufsize = MAXBUFSIZE; dev_if->command = pcbit_command; - + dev_if->writecmd = pcbit_writecmd; dev_if->readstat = pcbit_stat; @@ -211,12 +211,12 @@ int pcbit_init_dev(int board, int mem_base, int irq) #ifdef MODULE void pcbit_terminate(int board) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; dev = dev_pcbit[board]; if (dev) { - /* unregister_isdn(dev->dev_if); */ + /* unregister_isdn(dev->dev_if); */ free_irq(dev->irq, dev); pcbit_clear_msn(dev); kfree(dev->dev_if); @@ -233,9 +233,9 @@ void pcbit_terminate(int board) } #endif -static int pcbit_command(isdn_ctrl* ctl) +static int pcbit_command(isdn_ctrl *ctl) { - struct pcbit_dev *dev; + struct pcbit_dev *dev; struct pcbit_chan *chan; struct callb_data info; @@ -250,7 +250,7 @@ static int pcbit_command(isdn_ctrl* ctl) chan = (ctl->arg & 0x0F) ? dev->b2 : dev->b1; - switch(ctl->command) { + switch (ctl->command) { case ISDN_CMD_IOCTL: return pcbit_ioctl(ctl); break; @@ -299,10 +299,10 @@ static int pcbit_command(isdn_ctrl* ctl) static void pcbit_block_timer(unsigned long data) { struct pcbit_chan *chan; - struct pcbit_dev * dev; + struct pcbit_dev *dev; isdn_ctrl ictl; - chan = (struct pcbit_chan *) data; + chan = (struct pcbit_chan *)data; dev = chan2dev(chan); @@ -316,12 +316,12 @@ static void pcbit_block_timer(unsigned long data) #ifdef DEBUG printk(KERN_DEBUG "pcbit_block_timer\n"); -#endif +#endif chan->queued = 0; ictl.driver = dev->id; ictl.command = ISDN_STAT_BSENT; ictl.arg = chan->id; - dev->dev_if->statcallb(&ictl); + dev->dev_if->statcallb(&ictl); } #endif @@ -329,7 +329,7 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) { ushort hdrlen; int refnum, len; - struct pcbit_chan * chan; + struct pcbit_chan *chan; struct pcbit_dev *dev; dev = finddev(driver); @@ -345,10 +345,10 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) if (chan->fsm_state != ST_ACTIVE) return -1; - if (chan->queued >= MAX_QUEUED ) + if (chan->queued >= MAX_QUEUED) { #ifdef DEBUG_QUEUE - printk(KERN_DEBUG + printk(KERN_DEBUG "pcbit: %d packets already in queue - write fails\n", chan->queued); #endif @@ -365,14 +365,14 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) chan->block_timer.expires = jiffies + 1 * HZ; add_timer(&chan->block_timer); } -#endif - return 0; +#endif + return 0; } chan->queued++; - - len = skb->len; + + len = skb->len; hdrlen = capi_tdata_req(chan, skb); @@ -386,10 +386,10 @@ static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int channel) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; int i, j; - const u_char * loadbuf; - u_char * ptr = NULL; + const u_char *loadbuf; + u_char *ptr = NULL; u_char *cbuf; int errstat; @@ -402,7 +402,7 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha return -ENODEV; } - switch(dev->l2_state) { + switch (dev->l2_state) { case L2_LWMODE: /* check (size <= rdp_size); write buf into board */ if (len < 0 || len > BANK4 + 1 || len > 1024) @@ -422,19 +422,19 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha /* this is the hard part */ /* dumb board */ /* get it into kernel space */ - if ((ptr = kmalloc(len, GFP_KERNEL))==NULL) + if ((ptr = kmalloc(len, GFP_KERNEL)) == NULL) return -ENOMEM; if (copy_from_user(ptr, buf, len)) { kfree(ptr); return -EFAULT; } loadbuf = ptr; - + errstat = 0; - for (i=0; i < len; i++) + for (i = 0; i < len; i++) { - for(j=0; j < LOAD_RETRY; j++) + for (j = 0; j < LOAD_RETRY; j++) if (!(readb(dev->sh_mem + dev->loadptr))) break; @@ -464,9 +464,9 @@ static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int cha * */ -void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, - struct sk_buff * skb, - ushort hdr_len, ushort refnum) +void pcbit_l3_receive(struct pcbit_dev *dev, ulong msg, + struct sk_buff *skb, + ushort hdr_len, ushort refnum) { struct pcbit_chan *chan; struct sk_buff *skb2; @@ -475,11 +475,11 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, int complete, err; isdn_ctrl ictl; - switch(msg) { + switch (msg) { case MSG_TDATA_IND: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -488,30 +488,30 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, dev->dev_if->rcvcallb_skb(dev->id, chan->id, skb); - if (capi_tdata_resp(chan, &skb2) > 0) - pcbit_l2_write(dev, MSG_TDATA_RESP, refnum, + if (capi_tdata_resp(chan, &skb2) > 0) + pcbit_l2_write(dev, MSG_TDATA_RESP, refnum, skb2, skb2->len); return; - break; + break; case MSG_TDATA_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } #ifdef DEBUG - if ( (*((ushort *) (skb->data + 2) )) != 0) { - printk(KERN_DEBUG "TDATA_CONF error\n"); + if ((*((ushort *)(skb->data + 2))) != 0) { + printk(KERN_DEBUG "TDATA_CONF error\n"); } #endif #ifdef BLOCK_TIMER - if (chan->queued == MAX_QUEUED) { - del_timer(&chan->block_timer); + if (chan->queued == MAX_QUEUED) { + del_timer(&chan->block_timer); chan->block_timer.function = NULL; } - -#endif + +#endif chan->queued--; ictl.driver = dev->id; @@ -523,7 +523,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_CONN_IND: /* * channel: 1st not used will do - * if both are used we're in trouble + * if both are used we're in trouble */ if (!dev->b1->fsm_state) @@ -531,12 +531,12 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, else if (!dev->b2->fsm_state) chan = dev->b2; else { - printk(KERN_INFO + printk(KERN_INFO "Incoming connection: no channels available"); - if ((len = capi_disc_req(*(ushort*)(skb->data), &skb2, CAUSE_NOCHAN)) > 0) + if ((len = capi_disc_req(*(ushort *)(skb->data), &skb2, CAUSE_NOCHAN)) > 0) pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb2, len); - break; + break; } cbdata.data.setup.CalledPN = NULL; @@ -547,7 +547,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, pcbit_fsm_event(dev, chan, EV_NET_SETUP, NULL); - if (pcbit_check_msn(dev, cbdata.data.setup.CallingPN)) + if (pcbit_check_msn(dev, cbdata.data.setup.CallingPN)) pcbit_fsm_event(dev, chan, EV_USR_PROCED_REQ, &cbdata); else pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL); @@ -555,26 +555,26 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, kfree(cbdata.data.setup.CalledPN); kfree(cbdata.data.setup.CallingPN); break; - + case MSG_CONN_CONF: - /* + /* * We should be able to find the channel by the message * reference number. The current version of the firmware * doesn't sent the ref number correctly. */ #ifdef DEBUG - printk(KERN_DEBUG "refnum=%04x b1=%04x b2=%04x\n", refnum, - dev->b1->s_refnum, + printk(KERN_DEBUG "refnum=%04x b1=%04x b2=%04x\n", refnum, + dev->b1->s_refnum, dev->b2->s_refnum); #endif /* We just try to find a channel in the right state */ if (dev->b1->fsm_state == ST_CALL_INIT) chan = dev->b1; - else { + else { if (dev->b2->s_refnum == ST_CALL_INIT) chan = dev->b2; - else { + else { chan = NULL; printk(KERN_WARNING "Connection Confirm - no channel in Call Init state\n"); break; @@ -589,18 +589,18 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, pcbit_fsm_event(dev, chan, EV_NET_CALL_PROC, NULL); else pcbit_fsm_event(dev, chan, EV_NET_SETUP_ACK, NULL); - break; + break; case MSG_CONN_ACTV_IND: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } - + if (capi_decode_conn_actv_ind(chan, skb)) { printk("error in capi_decode_conn_actv_ind\n"); - /* pcbit_fsm_event(dev, chan, EV_ERROR, NULL); */ + /* pcbit_fsm_event(dev, chan, EV_ERROR, NULL); */ break; } chan->r_refnum = refnum; @@ -609,14 +609,14 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_CONN_ACTV_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } if (capi_decode_conn_actv_conf(chan, skb) == 0) pcbit_fsm_event(dev, chan, EV_NET_CONN_ACK, NULL); - + else printk(KERN_DEBUG "decode_conn_actv_conf failed\n"); break; @@ -624,7 +624,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_SELP_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -638,7 +638,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, break; case MSG_ACT_TRANSP_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -650,7 +650,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, case MSG_DISC_IND: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -662,7 +662,7 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, break; case MSG_DISC_CONF: if (!(chan = capi_channel(dev, skb))) { - printk(KERN_WARNING + printk(KERN_WARNING "CAPI header: unknown channel id\n"); break; } @@ -711,24 +711,24 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel) stat_count = STATBUF_LEN - stat_st + stat_end; /* FIXME: should we sleep and wait for more cookies ? */ - if (len > stat_count) + if (len > stat_count) len = stat_count; if (stat_st < stat_end) { if (copy_to_user(buf, statbuf + stat_st, len)) return -EFAULT; - stat_st += len; + stat_st += len; } else { if (len > STATBUF_LEN - stat_st) { if (copy_to_user(buf, statbuf + stat_st, - STATBUF_LEN - stat_st)) + STATBUF_LEN - stat_st)) return -EFAULT; if (copy_to_user(buf, statbuf, - len - (STATBUF_LEN - stat_st))) + len - (STATBUF_LEN - stat_st))) return -EFAULT; stat_st = len - (STATBUF_LEN - stat_st); @@ -739,7 +739,7 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel) return -EFAULT; stat_st += len; - + if (stat_st == STATBUF_LEN) stat_st = 0; } @@ -756,27 +756,27 @@ static void pcbit_logstat(struct pcbit_dev *dev, char *str) int i; isdn_ctrl ictl; - for (i=stat_end; iid; - ictl.arg=strlen(str); + ictl.command = ISDN_STAT_STAVAIL; + ictl.driver = dev->id; + ictl.arg = strlen(str); dev->dev_if->statcallb(&ictl); } - -void pcbit_state_change(struct pcbit_dev * dev, struct pcbit_chan * chan, + +void pcbit_state_change(struct pcbit_dev *dev, struct pcbit_chan *chan, unsigned short i, unsigned short ev, unsigned short f) { char buf[256]; - + sprintf(buf, "change on device: %d channel:%d\n%s -> %s -> %s\n", - dev->id, chan->id, + dev->id, chan->id, isdn_state_table[i], strisdnevent(ev), isdn_state_table[f] ); @@ -789,7 +789,7 @@ void pcbit_state_change(struct pcbit_dev * dev, struct pcbit_chan * chan, static void set_running_timeout(unsigned long ptr) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; #ifdef DEBUG printk(KERN_DEBUG "set_running_timeout\n"); @@ -799,7 +799,7 @@ static void set_running_timeout(unsigned long ptr) wake_up_interruptible(&dev->set_running_wq); } -static int set_protocol_running(struct pcbit_dev * dev) +static int set_protocol_running(struct pcbit_dev *dev) { isdn_ctrl ctl; @@ -813,7 +813,7 @@ static int set_protocol_running(struct pcbit_dev * dev) dev->l2_state = L2_STARTING; - writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)), + writeb((0x80U | ((dev->rcv_seq & 0x07) << 3) | (dev->send_seq & 0x07)), dev->sh_mem + BANK4); add_timer(&dev->set_running_timer); @@ -830,8 +830,8 @@ static int set_protocol_running(struct pcbit_dev * dev) dev->writeptr = dev->sh_mem; dev->readptr = dev->sh_mem + BANK2; - - /* tell the good news to the upper layer */ + + /* tell the good news to the upper layer */ ctl.driver = dev->id; ctl.command = ISDN_STAT_RUN; @@ -845,7 +845,7 @@ static int set_protocol_running(struct pcbit_dev * dev) dev->l2_state = L2_DOWN; #ifdef DEBUG - printk(KERN_DEBUG "Bank3 = %02x\n", + printk(KERN_DEBUG "Bank3 = %02x\n", readb(dev->sh_mem + BANK3)); #endif writeb(0x40, dev->sh_mem + BANK4); @@ -862,13 +862,13 @@ static int set_protocol_running(struct pcbit_dev * dev) return 0; } -static int pcbit_ioctl(isdn_ctrl* ctl) +static int pcbit_ioctl(isdn_ctrl *ctl) { - struct pcbit_dev * dev; + struct pcbit_dev *dev; struct pcbit_ioctl *cmd; dev = finddev(ctl->driver); - + if (!dev) { printk(KERN_DEBUG "pcbit_ioctl: unknown device\n"); @@ -877,7 +877,7 @@ static int pcbit_ioctl(isdn_ctrl* ctl) cmd = (struct pcbit_ioctl *) ctl->parm.num; - switch(ctl->arg) { + switch (ctl->arg) { case PCBIT_IOCTL_GETSTAT: cmd->info.l2_status = dev->l2_state; break; @@ -890,7 +890,7 @@ static int pcbit_ioctl(isdn_ctrl* ctl) dev->writeptr = dev->sh_mem; dev->readptr = dev->sh_mem + BANK2; - + dev->l2_state = L2_LOADING; break; @@ -907,21 +907,21 @@ static int pcbit_ioctl(isdn_ctrl* ctl) dev->loadptr = LOAD_ZONE_START; dev->l2_state = L2_FWMODE; - break; + break; case PCBIT_IOCTL_ENDLOAD: if (dev->l2_state == L2_RUNNING) return -EBUSY; dev->l2_state = L2_DOWN; - break; + break; - case PCBIT_IOCTL_SETBYTE: + case PCBIT_IOCTL_SETBYTE: if (dev->l2_state == L2_RUNNING) return -EBUSY; /* check addr */ if (cmd->info.rdp_byte.addr > BANK4) return -EFAULT; - + writeb(cmd->info.rdp_byte.value, dev->sh_mem + cmd->info.rdp_byte.addr); break; case PCBIT_IOCTL_GETBYTE: @@ -935,10 +935,10 @@ static int pcbit_ioctl(isdn_ctrl* ctl) printk("getbyte: invalid addr %04x\n", cmd->info.rdp_byte.addr); return -EFAULT; } - - cmd->info.rdp_byte.value = readb(dev->sh_mem + cmd->info.rdp_byte.addr); + + cmd->info.rdp_byte.value = readb(dev->sh_mem + cmd->info.rdp_byte.addr); break; - case PCBIT_IOCTL_RUNNING: + case PCBIT_IOCTL_RUNNING: if (dev->l2_state == L2_RUNNING) return -EBUSY; return set_protocol_running(dev); @@ -972,25 +972,25 @@ static int pcbit_ioctl(isdn_ctrl* ctl) return 0; } -/* +/* * MSN list handling * * if null reject all calls - * if first entry has null MSN accept all calls + * if first entry has null MSN accept all calls */ static void pcbit_clear_msn(struct pcbit_dev *dev) { struct msn_entry *ptr, *back; - for (ptr=dev->msn_list; ptr; ) + for (ptr = dev->msn_list; ptr;) { back = ptr->next; kfree(ptr); ptr = back; } - dev->msn_list = NULL; + dev->msn_list = NULL; } static void pcbit_set_msn(struct pcbit_dev *dev, char *list) @@ -1016,12 +1016,12 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) } if (dev->msn_list) - for (back=dev->msn_list; back->next; back=back->next); - + for (back = dev->msn_list; back->next; back = back->next); + sp = list; do { - cp=strchr(sp, ','); + cp = strchr(sp, ','); if (cp) len = cp - sp; else @@ -1034,7 +1034,7 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) return; } ptr->next = NULL; - + ptr->msn = kmalloc(len, GFP_ATOMIC); if (!ptr->msn) { printk(KERN_WARNING "kmalloc failed\n"); @@ -1054,7 +1054,7 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) back->next = ptr; back = ptr; sp += len; - } while(cp); + } while (cp); } /* @@ -1063,12 +1063,12 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list) static int pcbit_check_msn(struct pcbit_dev *dev, char *msn) { struct msn_entry *ptr; - - for (ptr=dev->msn_list; ptr; ptr=ptr->next) { - if (ptr->msn == NULL) + for (ptr = dev->msn_list; ptr; ptr = ptr->next) { + + if (ptr->msn == NULL) return 1; - + if (strcmp(ptr->msn, msn) == 0) return 1; } diff --git a/drivers/isdn/pcbit/edss1.c b/drivers/isdn/pcbit/edss1.c index 80c9c16fd5ef..b2262ba6f0c9 100644 --- a/drivers/isdn/pcbit/edss1.c +++ b/drivers/isdn/pcbit/edss1.c @@ -3,10 +3,10 @@ * base: ITU-T Rec Q.931 * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -34,145 +34,145 @@ const char * const isdn_state_table[] = { - "Closed", - "Call initiated", - "Overlap sending", - "Outgoing call proceeding", - "NOT DEFINED", - "Call delivered", - "Call present", - "Call received", - "Connect request", - "Incoming call proceeding", - "Active", - "Disconnect request", - "Disconnect indication", - "NOT DEFINED", - "NOT DEFINED", - "Suspend request", - "NOT DEFINED", - "Resume request", - "NOT DEFINED", - "Release Request", - "NOT DEFINED", - "NOT DEFINED", - "NOT DEFINED", - "NOT DEFINED", - "NOT DEFINED", - "Overlap receiving", - "Select protocol on B-Channel", - "Activate B-channel protocol" + "Closed", + "Call initiated", + "Overlap sending", + "Outgoing call proceeding", + "NOT DEFINED", + "Call delivered", + "Call present", + "Call received", + "Connect request", + "Incoming call proceeding", + "Active", + "Disconnect request", + "Disconnect indication", + "NOT DEFINED", + "NOT DEFINED", + "Suspend request", + "NOT DEFINED", + "Resume request", + "NOT DEFINED", + "Release Request", + "NOT DEFINED", + "NOT DEFINED", + "NOT DEFINED", + "NOT DEFINED", + "NOT DEFINED", + "Overlap receiving", + "Select protocol on B-Channel", + "Activate B-channel protocol" }; #ifdef DEBUG_ERRS static struct CauseValue { - byte nr; - char *descr; -} cvlist[]={ - {0x01,"Unallocated (unassigned) number"}, - {0x02,"No route to specified transit network"}, - {0x03,"No route to destination"}, - {0x04,"Send special information tone"}, - {0x05,"Misdialled trunk prefix"}, - {0x06,"Channel unacceptable"}, - {0x07,"Channel awarded and being delivered in an established channel"}, - {0x08,"Preemption"}, - {0x09,"Preemption - circuit reserved for reuse"}, - {0x10,"Normal call clearing"}, - {0x11,"User busy"}, - {0x12,"No user responding"}, - {0x13,"No answer from user (user alerted)"}, - {0x14,"Subscriber absent"}, - {0x15,"Call rejected"}, - {0x16,"Number changed"}, - {0x1a,"non-selected user clearing"}, - {0x1b,"Destination out of order"}, - {0x1c,"Invalid number format (address incomplete)"}, - {0x1d,"Facility rejected"}, - {0x1e,"Response to Status enquiry"}, - {0x1f,"Normal, unspecified"}, - {0x22,"No circuit/channel available"}, - {0x26,"Network out of order"}, - {0x27,"Permanent frame mode connection out-of-service"}, - {0x28,"Permanent frame mode connection operational"}, - {0x29,"Temporary failure"}, - {0x2a,"Switching equipment congestion"}, - {0x2b,"Access information discarded"}, - {0x2c,"Requested circuit/channel not available"}, - {0x2e,"Precedence call blocked"}, - {0x2f,"Resource unavailable, unspecified"}, - {0x31,"Quality of service unavailable"}, - {0x32,"Requested facility not subscribed"}, - {0x35,"Outgoing calls barred within CUG"}, - {0x37,"Incoming calls barred within CUG"}, - {0x39,"Bearer capability not authorized"}, - {0x3a,"Bearer capability not presently available"}, - {0x3e,"Inconsistency in designated outgoing access information and subscriber class"}, - {0x3f,"Service or option not available, unspecified"}, - {0x41,"Bearer capability not implemented"}, - {0x42,"Channel type not implemented"}, - {0x43,"Requested facility not implemented"}, - {0x44,"Only restricted digital information bearer capability is available"}, - {0x4f,"Service or option not implemented"}, - {0x51,"Invalid call reference value"}, - {0x52,"Identified channel does not exist"}, - {0x53,"A suspended call exists, but this call identity does not"}, - {0x54,"Call identity in use"}, - {0x55,"No call suspended"}, - {0x56,"Call having the requested call identity has been cleared"}, - {0x57,"User not member of CUG"}, - {0x58,"Incompatible destination"}, - {0x5a,"Non-existent CUG"}, - {0x5b,"Invalid transit network selection"}, - {0x5f,"Invalid message, unspecified"}, - {0x60,"Mandatory information element is missing"}, - {0x61,"Message type non-existent or not implemented"}, - {0x62,"Message not compatible with call state or message type non-existent or not implemented"}, - {0x63,"Information element/parameter non-existent or not implemented"}, - {0x64,"Invalid information element contents"}, - {0x65,"Message not compatible with call state"}, - {0x66,"Recovery on timer expiry"}, - {0x67,"Parameter non-existent or not implemented - passed on"}, - {0x6e,"Message with unrecognized parameter discarded"}, - {0x6f,"Protocol error, unspecified"}, - {0x7f,"Interworking, unspecified"} + byte nr; + char *descr; +} cvlist[] = { + {0x01, "Unallocated (unassigned) number"}, + {0x02, "No route to specified transit network"}, + {0x03, "No route to destination"}, + {0x04, "Send special information tone"}, + {0x05, "Misdialled trunk prefix"}, + {0x06, "Channel unacceptable"}, + {0x07, "Channel awarded and being delivered in an established channel"}, + {0x08, "Preemption"}, + {0x09, "Preemption - circuit reserved for reuse"}, + {0x10, "Normal call clearing"}, + {0x11, "User busy"}, + {0x12, "No user responding"}, + {0x13, "No answer from user (user alerted)"}, + {0x14, "Subscriber absent"}, + {0x15, "Call rejected"}, + {0x16, "Number changed"}, + {0x1a, "non-selected user clearing"}, + {0x1b, "Destination out of order"}, + {0x1c, "Invalid number format (address incomplete)"}, + {0x1d, "Facility rejected"}, + {0x1e, "Response to Status enquiry"}, + {0x1f, "Normal, unspecified"}, + {0x22, "No circuit/channel available"}, + {0x26, "Network out of order"}, + {0x27, "Permanent frame mode connection out-of-service"}, + {0x28, "Permanent frame mode connection operational"}, + {0x29, "Temporary failure"}, + {0x2a, "Switching equipment congestion"}, + {0x2b, "Access information discarded"}, + {0x2c, "Requested circuit/channel not available"}, + {0x2e, "Precedence call blocked"}, + {0x2f, "Resource unavailable, unspecified"}, + {0x31, "Quality of service unavailable"}, + {0x32, "Requested facility not subscribed"}, + {0x35, "Outgoing calls barred within CUG"}, + {0x37, "Incoming calls barred within CUG"}, + {0x39, "Bearer capability not authorized"}, + {0x3a, "Bearer capability not presently available"}, + {0x3e, "Inconsistency in designated outgoing access information and subscriber class"}, + {0x3f, "Service or option not available, unspecified"}, + {0x41, "Bearer capability not implemented"}, + {0x42, "Channel type not implemented"}, + {0x43, "Requested facility not implemented"}, + {0x44, "Only restricted digital information bearer capability is available"}, + {0x4f, "Service or option not implemented"}, + {0x51, "Invalid call reference value"}, + {0x52, "Identified channel does not exist"}, + {0x53, "A suspended call exists, but this call identity does not"}, + {0x54, "Call identity in use"}, + {0x55, "No call suspended"}, + {0x56, "Call having the requested call identity has been cleared"}, + {0x57, "User not member of CUG"}, + {0x58, "Incompatible destination"}, + {0x5a, "Non-existent CUG"}, + {0x5b, "Invalid transit network selection"}, + {0x5f, "Invalid message, unspecified"}, + {0x60, "Mandatory information element is missing"}, + {0x61, "Message type non-existent or not implemented"}, + {0x62, "Message not compatible with call state or message type non-existent or not implemented"}, + {0x63, "Information element/parameter non-existent or not implemented"}, + {0x64, "Invalid information element contents"}, + {0x65, "Message not compatible with call state"}, + {0x66, "Recovery on timer expiry"}, + {0x67, "Parameter non-existent or not implemented - passed on"}, + {0x6e, "Message with unrecognized parameter discarded"}, + {0x6f, "Protocol error, unspecified"}, + {0x7f, "Interworking, unspecified"} }; #endif static struct isdn_event_desc { - unsigned short ev; - char * desc; -} isdn_event_table [] = { - {EV_USR_SETUP_REQ, "CC->L3: Setup Request"}, - {EV_USR_SETUP_RESP, "CC->L3: Setup Response"}, - {EV_USR_PROCED_REQ, "CC->L3: Proceeding Request"}, - {EV_USR_RELEASE_REQ, "CC->L3: Release Request"}, - - {EV_NET_SETUP, "NET->TE: setup "}, - {EV_NET_CALL_PROC, "NET->TE: call proceeding"}, - {EV_NET_SETUP_ACK, "NET->TE: setup acknowledge (more info needed)"}, - {EV_NET_CONN, "NET->TE: connect"}, - {EV_NET_CONN_ACK, "NET->TE: connect acknowledge"}, - {EV_NET_DISC, "NET->TE: disconnect indication"}, - {EV_NET_RELEASE, "NET->TE: release"}, - {EV_NET_RELEASE_COMP, "NET->TE: release complete"}, - {EV_NET_SELP_RESP, "Board: Select B-channel protocol ack"}, - {EV_NET_ACTV_RESP, "Board: Activate B-channel protocol ack"}, - {EV_TIMER, "Timeout"}, - {0, "NULL"} + unsigned short ev; + char *desc; +} isdn_event_table[] = { + {EV_USR_SETUP_REQ, "CC->L3: Setup Request"}, + {EV_USR_SETUP_RESP, "CC->L3: Setup Response"}, + {EV_USR_PROCED_REQ, "CC->L3: Proceeding Request"}, + {EV_USR_RELEASE_REQ, "CC->L3: Release Request"}, + + {EV_NET_SETUP, "NET->TE: setup "}, + {EV_NET_CALL_PROC, "NET->TE: call proceeding"}, + {EV_NET_SETUP_ACK, "NET->TE: setup acknowledge (more info needed)"}, + {EV_NET_CONN, "NET->TE: connect"}, + {EV_NET_CONN_ACK, "NET->TE: connect acknowledge"}, + {EV_NET_DISC, "NET->TE: disconnect indication"}, + {EV_NET_RELEASE, "NET->TE: release"}, + {EV_NET_RELEASE_COMP, "NET->TE: release complete"}, + {EV_NET_SELP_RESP, "Board: Select B-channel protocol ack"}, + {EV_NET_ACTV_RESP, "Board: Activate B-channel protocol ack"}, + {EV_TIMER, "Timeout"}, + {0, "NULL"} }; -char * strisdnevent(ushort ev) +char *strisdnevent(ushort ev) { - struct isdn_event_desc * entry; - - for (entry = isdn_event_table; entry->ev; entry++) - if (entry->ev == ev) - break; + struct isdn_event_desc *entry; + + for (entry = isdn_event_table; entry->ev; entry++) + if (entry->ev == ev) + break; - return entry->desc; + return entry->desc; } /* @@ -180,130 +180,130 @@ char * strisdnevent(ushort ev) */ static struct fsm_timer_entry fsm_timers[] = { - {ST_CALL_PROC, 10}, - {ST_DISC_REQ, 2}, - {ST_ACTIVE_SELP, 5}, - {ST_ACTIVE_ACTV, 5}, - {ST_INCM_PROC, 10}, - {ST_CONN_REQ, 2}, - {0xff, 0} + {ST_CALL_PROC, 10}, + {ST_DISC_REQ, 2}, + {ST_ACTIVE_SELP, 5}, + {ST_ACTIVE_ACTV, 5}, + {ST_INCM_PROC, 10}, + {ST_CONN_REQ, 2}, + {0xff, 0} }; static struct fsm_entry fsm_table[] = { /* Connect Phase */ - /* Outgoing */ - {ST_NULL, ST_CALL_INIT, EV_USR_SETUP_REQ, cb_out_1}, + /* Outgoing */ + {ST_NULL, ST_CALL_INIT, EV_USR_SETUP_REQ, cb_out_1}, - {ST_CALL_INIT, ST_OVER_SEND, EV_NET_SETUP_ACK, cb_notdone}, - {ST_CALL_INIT, ST_CALL_PROC, EV_NET_CALL_PROC, NULL}, - {ST_CALL_INIT, ST_NULL, EV_NET_DISC, cb_out_2}, + {ST_CALL_INIT, ST_OVER_SEND, EV_NET_SETUP_ACK, cb_notdone}, + {ST_CALL_INIT, ST_CALL_PROC, EV_NET_CALL_PROC, NULL}, + {ST_CALL_INIT, ST_NULL, EV_NET_DISC, cb_out_2}, - {ST_CALL_PROC, ST_ACTIVE_SELP, EV_NET_CONN, cb_out_2}, - {ST_CALL_PROC, ST_NULL, EV_NET_DISC, cb_disc_1}, - {ST_CALL_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_CALL_PROC, ST_ACTIVE_SELP, EV_NET_CONN, cb_out_2}, + {ST_CALL_PROC, ST_NULL, EV_NET_DISC, cb_disc_1}, + {ST_CALL_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - /* Incoming */ - {ST_NULL, ST_CALL_PRES, EV_NET_SETUP, NULL}, + /* Incoming */ + {ST_NULL, ST_CALL_PRES, EV_NET_SETUP, NULL}, - {ST_CALL_PRES, ST_INCM_PROC, EV_USR_PROCED_REQ, cb_in_1}, - {ST_CALL_PRES, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_CALL_PRES, ST_INCM_PROC, EV_USR_PROCED_REQ, cb_in_1}, + {ST_CALL_PRES, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_INCM_PROC, ST_CONN_REQ, EV_USR_SETUP_RESP, cb_in_2}, - {ST_INCM_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_INCM_PROC, ST_CONN_REQ, EV_USR_SETUP_RESP, cb_in_2}, + {ST_INCM_PROC, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_CONN_REQ, ST_ACTIVE_SELP, EV_NET_CONN_ACK, cb_in_3}, + {ST_CONN_REQ, ST_ACTIVE_SELP, EV_NET_CONN_ACK, cb_in_3}, - /* Active */ - {ST_ACTIVE, ST_NULL, EV_NET_DISC, cb_disc_1}, - {ST_ACTIVE, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_ACTIVE, ST_NULL, EV_NET_RELEASE, cb_disc_3}, + /* Active */ + {ST_ACTIVE, ST_NULL, EV_NET_DISC, cb_disc_1}, + {ST_ACTIVE, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_ACTIVE, ST_NULL, EV_NET_RELEASE, cb_disc_3}, - /* Disconnect */ + /* Disconnect */ - {ST_DISC_REQ, ST_NULL, EV_NET_DISC, cb_disc_1}, - {ST_DISC_REQ, ST_NULL, EV_NET_RELEASE, cb_disc_3}, + {ST_DISC_REQ, ST_NULL, EV_NET_DISC, cb_disc_1}, + {ST_DISC_REQ, ST_NULL, EV_NET_RELEASE, cb_disc_3}, - /* protocol selection */ - {ST_ACTIVE_SELP, ST_ACTIVE_ACTV, EV_NET_SELP_RESP, cb_selp_1}, - {ST_ACTIVE_SELP, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + /* protocol selection */ + {ST_ACTIVE_SELP, ST_ACTIVE_ACTV, EV_NET_SELP_RESP, cb_selp_1}, + {ST_ACTIVE_SELP, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - {ST_ACTIVE_ACTV, ST_ACTIVE, EV_NET_ACTV_RESP, cb_open}, - {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, + {ST_ACTIVE_ACTV, ST_ACTIVE, EV_NET_ACTV_RESP, cb_open}, + {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_USR_RELEASE_REQ, cb_disc_2}, - /* Timers */ - {ST_CALL_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_DISC_REQ, ST_NULL, EV_TIMER, cb_disc_3}, - {ST_ACTIVE_SELP, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_INCM_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, - {ST_CONN_REQ, ST_CONN_REQ, EV_TIMER, cb_in_2}, - - {0xff, 0, 0, NULL} + /* Timers */ + {ST_CALL_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_DISC_REQ, ST_NULL, EV_TIMER, cb_disc_3}, + {ST_ACTIVE_SELP, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_ACTIVE_ACTV, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_INCM_PROC, ST_DISC_REQ, EV_TIMER, cb_disc_2}, + {ST_CONN_REQ, ST_CONN_REQ, EV_TIMER, cb_in_2}, + + {0xff, 0, 0, NULL} }; static void pcbit_fsm_timer(unsigned long data) { - struct pcbit_dev *dev; - struct pcbit_chan *chan; + struct pcbit_dev *dev; + struct pcbit_chan *chan; - chan = (struct pcbit_chan *) data; + chan = (struct pcbit_chan *) data; - del_timer(&chan->fsm_timer); - chan->fsm_timer.function = NULL; + del_timer(&chan->fsm_timer); + chan->fsm_timer.function = NULL; - dev = chan2dev(chan); + dev = chan2dev(chan); - if (dev == NULL) { - printk(KERN_WARNING "pcbit: timer for unknown device\n"); - return; - } + if (dev == NULL) { + printk(KERN_WARNING "pcbit: timer for unknown device\n"); + return; + } - pcbit_fsm_event(dev, chan, EV_TIMER, NULL); + pcbit_fsm_event(dev, chan, EV_TIMER, NULL); } void pcbit_fsm_event(struct pcbit_dev *dev, struct pcbit_chan *chan, - unsigned short event, struct callb_data *data) + unsigned short event, struct callb_data *data) { - struct fsm_entry * action; + struct fsm_entry *action; struct fsm_timer_entry *tentry; unsigned long flags; spin_lock_irqsave(&dev->lock, flags); - for (action = fsm_table; action->init != 0xff; action++) - if (action->init == chan->fsm_state && action->event == event) - break; - + for (action = fsm_table; action->init != 0xff; action++) + if (action->init == chan->fsm_state && action->event == event) + break; + if (action->init == 0xff) { - + spin_unlock_irqrestore(&dev->lock, flags); - printk(KERN_DEBUG "fsm error: event %x on state %x\n", - event, chan->fsm_state); + printk(KERN_DEBUG "fsm error: event %x on state %x\n", + event, chan->fsm_state); return; } - if (chan->fsm_timer.function) { - del_timer(&chan->fsm_timer); - chan->fsm_timer.function = NULL; - } + if (chan->fsm_timer.function) { + del_timer(&chan->fsm_timer); + chan->fsm_timer.function = NULL; + } chan->fsm_state = action->final; - + pcbit_state_change(dev, chan, action->init, event, action->final); - for (tentry = fsm_timers; tentry->init != 0xff; tentry++) - if (tentry->init == chan->fsm_state) - break; + for (tentry = fsm_timers; tentry->init != 0xff; tentry++) + if (tentry->init == chan->fsm_state) + break; - if (tentry->init != 0xff) { - init_timer(&chan->fsm_timer); - chan->fsm_timer.function = &pcbit_fsm_timer; - chan->fsm_timer.data = (ulong) chan; - chan->fsm_timer.expires = jiffies + tentry->timeout * HZ; - add_timer(&chan->fsm_timer); - } + if (tentry->init != 0xff) { + init_timer(&chan->fsm_timer); + chan->fsm_timer.function = &pcbit_fsm_timer; + chan->fsm_timer.data = (ulong) chan; + chan->fsm_timer.expires = jiffies + tentry->timeout * HZ; + add_timer(&chan->fsm_timer); + } spin_unlock_irqrestore(&dev->lock, flags); @@ -311,7 +311,3 @@ void pcbit_fsm_event(struct pcbit_dev *dev, struct pcbit_chan *chan, action->callb(dev, chan, data); } - - - - diff --git a/drivers/isdn/pcbit/edss1.h b/drivers/isdn/pcbit/edss1.h index 39f8346e28c5..2f6b3a8edfba 100644 --- a/drivers/isdn/pcbit/edss1.h +++ b/drivers/isdn/pcbit/edss1.h @@ -2,10 +2,10 @@ * DSS.1 module definitions * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -62,9 +62,9 @@ /* * Cause values * only the ones we use - */ + */ -#define CAUSE_NORMAL 0x10U +#define CAUSE_NORMAL 0x10U #define CAUSE_NOCHAN 0x22U struct callb_data { @@ -94,9 +94,6 @@ extern const char * const isdn_state_table[]; void pcbit_fsm_event(struct pcbit_dev *, struct pcbit_chan *, unsigned short event, struct callb_data *); -char * strisdnevent(ushort ev); +char *strisdnevent(ushort ev); #endif - - - diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c index 30f0f45e3139..682911f81138 100644 --- a/drivers/isdn/pcbit/layer2.c +++ b/drivers/isdn/pcbit/layer2.c @@ -12,7 +12,7 @@ /* * 19991203 - Fernando Carvalho - takion@superbofh.org * Hacked to compile with egcs and run with current version of isdn modules -*/ + */ /* * Based on documentation provided by Inesc: @@ -77,7 +77,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, struct sk_buff *skb, unsigned short hdr_len) { struct frame_buf *frame, - *ptr; + *ptr; unsigned long flags; if (dev->l2_state != L2_RUNNING && dev->l2_state != L2_LOADING) { @@ -85,7 +85,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, return -1; } if ((frame = kmalloc(sizeof(struct frame_buf), - GFP_ATOMIC)) == NULL) { + GFP_ATOMIC)) == NULL) { printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n"); dev_kfree_skb(skb); return -1; @@ -147,7 +147,7 @@ pcbit_transmit(struct pcbit_dev *dev) int flen; /* fragment frame length including all headers */ int free; int count, - cp_len; + cp_len; unsigned long flags; unsigned short tt; @@ -177,7 +177,7 @@ pcbit_transmit(struct pcbit_dev *dev) /* Type 0 frame */ - ulong msg; + ulong msg; if (frame->skb) flen = FRAME_HDR_LEN + PREHDR_LEN + frame->skb->len; @@ -270,7 +270,7 @@ pcbit_transmit(struct pcbit_dev *dev) spin_unlock_irqrestore(&dev->lock, flags); #ifdef DEBUG printk(KERN_DEBUG "unacked %d free %d write_queue %s\n", - unacked, dev->free, dev->write_queue ? "not empty" : + unacked, dev->free, dev->write_queue ? "not empty" : "empty"); #endif } @@ -301,8 +301,8 @@ pcbit_deliver(struct work_struct *work) SET_MSG_CMD(msg, frame->skb->data[2]); SET_MSG_SCMD(msg, frame->skb->data[3]); - frame->refnum = *((ushort *) frame->skb->data + 4); - frame->msg = *((ulong *) & msg); + frame->refnum = *((ushort *)frame->skb->data + 4); + frame->msg = *((ulong *)&msg); skb_pull(frame->skb, 6); @@ -326,7 +326,7 @@ pcbit_receive(struct pcbit_dev *dev) { unsigned short tt; u_char cpu, - proc; + proc; struct frame_buf *frame = NULL; unsigned long flags; u_char type1; @@ -378,10 +378,10 @@ pcbit_receive(struct pcbit_dev *dev) frame->dt_len = pcbit_readw(dev); /* - * 0 sized packet - * I don't know if they are an error or not... - * But they are very frequent - * Not documented + * 0 sized packet + * I don't know if they are an error or not... + * But they are very frequent + * Not documented */ if (frame->hdr_len == 0) { @@ -499,8 +499,8 @@ pcbit_irq_handler(int interrupt, void *devptr) { struct pcbit_dev *dev; u_char info, - ack_seq, - read_seq; + ack_seq, + read_seq; dev = (struct pcbit_dev *) devptr; @@ -666,7 +666,7 @@ static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack) { int i, - count; + count; int unacked; unacked = (dev->send_seq + (8 - dev->unack_seq)) & 0x07; @@ -678,13 +678,13 @@ pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack) if (dev->send_seq > dev->unack_seq) { if (ack <= dev->unack_seq || ack > dev->send_seq) { printk(KERN_DEBUG - "layer 2 ack unacceptable - dev %d", + "layer 2 ack unacceptable - dev %d", dev->id); pcbit_l2_error(dev); } else if (ack > dev->send_seq && ack <= dev->unack_seq) { printk(KERN_DEBUG - "layer 2 ack unacceptable - dev %d", + "layer 2 ack unacceptable - dev %d", dev->id); pcbit_l2_error(dev); } diff --git a/drivers/isdn/pcbit/layer2.h b/drivers/isdn/pcbit/layer2.h index 2ac295e1a6e5..be1327bc162a 100644 --- a/drivers/isdn/pcbit/layer2.h +++ b/drivers/isdn/pcbit/layer2.h @@ -2,17 +2,17 @@ * PCBIT-D low-layer interface definitions * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ /* * 19991203 - Fernando Carvalho - takion@superbofh.org * Hacked to compile with egcs and run with current version of isdn modules -*/ + */ #ifndef LAYER2_H #define LAYER2_H @@ -37,8 +37,8 @@ /* TAM - XX - C - S - NUM */ #define PREHDR_LEN 8 -/* TT - M - I - TH - TD */ -#define FRAME_HDR_LEN 8 +/* TT - M - I - TH - TD */ +#define FRAME_HDR_LEN 8 #define MSG_CONN_REQ 0x08000100 #define MSG_CONN_CONF 0x00000101 @@ -84,21 +84,21 @@ #define MSG_DEBUG_188 0x0000ff00 /* - - long 4 3 2 1 - Intel 1 2 3 4 + + long 4 3 2 1 + Intel 1 2 3 4 */ #ifdef __LITTLE_ENDIAN -#define SET_MSG_SCMD(msg, ch) (msg = (msg & 0xffffff00) | (((ch) & 0xff))) -#define SET_MSG_CMD(msg, ch) (msg = (msg & 0xffff00ff) | (((ch) & 0xff) << 8)) -#define SET_MSG_PROC(msg, ch) (msg = (msg & 0xff00ffff) | (((ch) & 0xff) << 16)) -#define SET_MSG_CPU(msg, ch) (msg = (msg & 0x00ffffff) | (((ch) & 0xff) << 24)) +#define SET_MSG_SCMD(msg, ch) (msg = (msg & 0xffffff00) | (((ch) & 0xff))) +#define SET_MSG_CMD(msg, ch) (msg = (msg & 0xffff00ff) | (((ch) & 0xff) << 8)) +#define SET_MSG_PROC(msg, ch) (msg = (msg & 0xff00ffff) | (((ch) & 0xff) << 16)) +#define SET_MSG_CPU(msg, ch) (msg = (msg & 0x00ffffff) | (((ch) & 0xff) << 24)) -#define GET_MSG_SCMD(msg) ((msg) & 0xFF) -#define GET_MSG_CMD(msg) ((msg) >> 8 & 0xFF) -#define GET_MSG_PROC(msg) ((msg) >> 16 & 0xFF) -#define GET_MSG_CPU(msg) ((msg) >> 24) +#define GET_MSG_SCMD(msg) ((msg) & 0xFF) +#define GET_MSG_CMD(msg) ((msg) >> 8 & 0xFF) +#define GET_MSG_PROC(msg) ((msg) >> 16 & 0xFF) +#define GET_MSG_CPU(msg) ((msg) >> 24) #else #error "Non-Intel CPU" @@ -109,60 +109,60 @@ #define SCHED_READ 0x01 #define SCHED_WRITE 0x02 -#define SET_RUN_TIMEOUT 2*HZ /* 2 seconds */ - +#define SET_RUN_TIMEOUT 2 * HZ /* 2 seconds */ + struct frame_buf { - ulong msg; - unsigned int refnum; - unsigned int dt_len; - unsigned int hdr_len; - struct sk_buff *skb; + ulong msg; + unsigned int refnum; + unsigned int dt_len; + unsigned int hdr_len; + struct sk_buff *skb; unsigned int copied; - struct frame_buf * next; + struct frame_buf *next; }; -extern int pcbit_l2_write(struct pcbit_dev * dev, ulong msg, ushort refnum, - struct sk_buff *skb, unsigned short hdr_len); +extern int pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, + struct sk_buff *skb, unsigned short hdr_len); extern irqreturn_t pcbit_irq_handler(int interrupt, void *); -extern struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS]; +extern struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS]; #ifdef DEBUG static __inline__ void log_state(struct pcbit_dev *dev) { - printk(KERN_DEBUG "writeptr = %ld\n", + printk(KERN_DEBUG "writeptr = %ld\n", (ulong) (dev->writeptr - dev->sh_mem)); - printk(KERN_DEBUG "readptr = %ld\n", + printk(KERN_DEBUG "readptr = %ld\n", (ulong) (dev->readptr - (dev->sh_mem + BANK2))); - printk(KERN_DEBUG "{rcv_seq=%01x, send_seq=%01x, unack_seq=%01x}\n", + printk(KERN_DEBUG "{rcv_seq=%01x, send_seq=%01x, unack_seq=%01x}\n", dev->rcv_seq, dev->send_seq, dev->unack_seq); } #endif -static __inline__ struct pcbit_dev * chan2dev(struct pcbit_chan * chan) +static __inline__ struct pcbit_dev *chan2dev(struct pcbit_chan *chan) { - struct pcbit_dev * dev; - int i; + struct pcbit_dev *dev; + int i; - for (i=0; ib1 == chan || dev->b2 == chan) - return dev; - return NULL; + for (i = 0; i < MAX_PCBIT_CARDS; i++) + if ((dev = dev_pcbit[i])) + if (dev->b1 == chan || dev->b2 == chan) + return dev; + return NULL; } -static __inline__ struct pcbit_dev * finddev(int id) +static __inline__ struct pcbit_dev *finddev(int id) { - struct pcbit_dev * dev; - int i; - - for (i=0; iid == id) - return dev; - return NULL; + struct pcbit_dev *dev; + int i; + + for (i = 0; i < MAX_PCBIT_CARDS; i++) + if ((dev = dev_pcbit[i])) + if (dev->id == id) + return dev; + return NULL; } @@ -172,117 +172,110 @@ static __inline__ struct pcbit_dev * finddev(int id) static __inline__ void pcbit_writeb(struct pcbit_dev *dev, unsigned char dt) { - writeb(dt, dev->writeptr++); - if (dev->writeptr == dev->sh_mem + BANKLEN) - dev->writeptr = dev->sh_mem; + writeb(dt, dev->writeptr++); + if (dev->writeptr == dev->sh_mem + BANKLEN) + dev->writeptr = dev->sh_mem; } static __inline__ void pcbit_writew(struct pcbit_dev *dev, unsigned short dt) { - int dist; - - dist = BANKLEN - (dev->writeptr - dev->sh_mem); - switch (dist) { - case 2: - writew(dt, dev->writeptr); - dev->writeptr = dev->sh_mem; - break; - case 1: - writeb((u_char) (dt & 0x00ffU), dev->writeptr); - dev->writeptr = dev->sh_mem; - writeb((u_char) (dt >> 8), dev->writeptr++); - break; - default: - writew(dt, dev->writeptr); - dev->writeptr += 2; - break; - }; + int dist; + + dist = BANKLEN - (dev->writeptr - dev->sh_mem); + switch (dist) { + case 2: + writew(dt, dev->writeptr); + dev->writeptr = dev->sh_mem; + break; + case 1: + writeb((u_char) (dt & 0x00ffU), dev->writeptr); + dev->writeptr = dev->sh_mem; + writeb((u_char) (dt >> 8), dev->writeptr++); + break; + default: + writew(dt, dev->writeptr); + dev->writeptr += 2; + break; + }; } -static __inline__ void memcpy_topcbit(struct pcbit_dev * dev, u_char * data, +static __inline__ void memcpy_topcbit(struct pcbit_dev *dev, u_char *data, int len) { - int diff; - - diff = len - (BANKLEN - (dev->writeptr - dev->sh_mem) ); - - if (diff > 0) - { - memcpy_toio(dev->writeptr, data, len - diff); - memcpy_toio(dev->sh_mem, data + (len - diff), diff); - dev->writeptr = dev->sh_mem + diff; - } - else - { - memcpy_toio(dev->writeptr, data, len); - - dev->writeptr += len; - if (diff == 0) - dev->writeptr = dev->sh_mem; - } + int diff; + + diff = len - (BANKLEN - (dev->writeptr - dev->sh_mem)); + + if (diff > 0) + { + memcpy_toio(dev->writeptr, data, len - diff); + memcpy_toio(dev->sh_mem, data + (len - diff), diff); + dev->writeptr = dev->sh_mem + diff; + } + else + { + memcpy_toio(dev->writeptr, data, len); + + dev->writeptr += len; + if (diff == 0) + dev->writeptr = dev->sh_mem; + } } static __inline__ unsigned char pcbit_readb(struct pcbit_dev *dev) { - unsigned char val; + unsigned char val; - val = readb(dev->readptr++); - if (dev->readptr == dev->sh_mem + BANK2 + BANKLEN) - dev->readptr = dev->sh_mem + BANK2; + val = readb(dev->readptr++); + if (dev->readptr == dev->sh_mem + BANK2 + BANKLEN) + dev->readptr = dev->sh_mem + BANK2; - return val; + return val; } static __inline__ unsigned short pcbit_readw(struct pcbit_dev *dev) { - int dist; - unsigned short val; - - dist = BANKLEN - ( dev->readptr - (dev->sh_mem + BANK2 ) ); - switch (dist) { - case 2: - val = readw(dev->readptr); - dev->readptr = dev->sh_mem + BANK2; - break; - case 1: - val = readb(dev->readptr); - dev->readptr = dev->sh_mem + BANK2; - val = (readb(dev->readptr++) << 8) | val; - break; - default: - val = readw(dev->readptr); - dev->readptr += 2; - break; - }; - return val; + int dist; + unsigned short val; + + dist = BANKLEN - (dev->readptr - (dev->sh_mem + BANK2)); + switch (dist) { + case 2: + val = readw(dev->readptr); + dev->readptr = dev->sh_mem + BANK2; + break; + case 1: + val = readb(dev->readptr); + dev->readptr = dev->sh_mem + BANK2; + val = (readb(dev->readptr++) << 8) | val; + break; + default: + val = readw(dev->readptr); + dev->readptr += 2; + break; + }; + return val; } -static __inline__ void memcpy_frompcbit(struct pcbit_dev * dev, u_char * data, int len) +static __inline__ void memcpy_frompcbit(struct pcbit_dev *dev, u_char *data, int len) { - int diff; - - diff = len - (BANKLEN - (dev->readptr - (dev->sh_mem + BANK2) ) ); - if (diff > 0) - { - memcpy_fromio(data, dev->readptr, len - diff); - memcpy_fromio(data + (len - diff), dev->sh_mem + BANK2 , diff); - dev->readptr = dev->sh_mem + BANK2 + diff; - } - else - { - memcpy_fromio(data, dev->readptr, len); - dev->readptr += len; - if (diff == 0) - dev->readptr = dev->sh_mem + BANK2; - } + int diff; + + diff = len - (BANKLEN - (dev->readptr - (dev->sh_mem + BANK2))); + if (diff > 0) + { + memcpy_fromio(data, dev->readptr, len - diff); + memcpy_fromio(data + (len - diff), dev->sh_mem + BANK2 , diff); + dev->readptr = dev->sh_mem + BANK2 + diff; + } + else + { + memcpy_fromio(data, dev->readptr, len); + dev->readptr += len; + if (diff == 0) + dev->readptr = dev->sh_mem + BANK2; + } } #endif - - - - - - - diff --git a/drivers/isdn/pcbit/module.c b/drivers/isdn/pcbit/module.c index 04ea241ff176..0a59bd0b8210 100644 --- a/drivers/isdn/pcbit/module.c +++ b/drivers/isdn/pcbit/module.c @@ -2,10 +2,10 @@ * PCBIT-D module support * * Copyright (C) 1996 Universidade de Lisboa - * + * * Written by Pedro Roque Marques (roque@di.fc.ul.pt) * - * This software may be used and distributed according to the terms of + * This software may be used and distributed according to the terms of * the GNU General Public License, incorporated herein by reference. */ @@ -29,7 +29,7 @@ module_param_array(mem, int, NULL, 0); module_param_array(irq, int, NULL, 0); static int num_boards; -struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS]; +struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS]; static int __init pcbit_init(void) { @@ -37,26 +37,26 @@ static int __init pcbit_init(void) num_boards = 0; - printk(KERN_NOTICE + printk(KERN_NOTICE "PCBIT-D device driver v 0.5-fjpc0 19991204 - " "Copyright (C) 1996 Universidade de Lisboa\n"); - if (mem[0] || irq[0]) + if (mem[0] || irq[0]) { - for (board=0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++) + for (board = 0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++) { if (!mem[board]) mem[board] = 0xD0000; if (!irq[board]) irq[board] = 5; - + if (pcbit_init_dev(board, mem[board], irq[board]) == 0) num_boards++; - - else + + else { - printk(KERN_WARNING - "pcbit_init failed for dev %d", + printk(KERN_WARNING + "pcbit_init failed for dev %d", board + 1); return -EIO; } @@ -67,7 +67,7 @@ static int __init pcbit_init(void) if (!num_boards) { - printk(KERN_INFO + printk(KERN_INFO "Trying to detect board using default settings\n"); if (pcbit_init_dev(0, 0xD0000, 5) == 0) num_boards++; @@ -84,7 +84,7 @@ static void __exit pcbit_exit(void) for (board = 0; board < num_boards; board++) pcbit_terminate(board); - printk(KERN_NOTICE + printk(KERN_NOTICE "PCBIT-D module unloaded\n"); #endif } @@ -95,20 +95,20 @@ static int __init pcbit_setup(char *line) { int i, j, argc; char *str; - int ints[MAX_PARA+1]; + int ints[MAX_PARA + 1]; str = get_options(line, MAX_PARA, ints); argc = ints[0]; i = 0; j = 1; - while (argc && (icommand) { + switch (cmd->command) { case ISDN_CMD_IOCTL: { - unsigned long cmdptr; + unsigned long cmdptr; scs_ioctl ioc; memcpy(&cmdptr, cmd->parm.num, sizeof(unsigned long)); if (copy_from_user(&ioc, (scs_ioctl __user *)cmdptr, sizeof(scs_ioctl))) { pr_debug("%s: Failed to verify user space 0x%lx\n", - sc_adapter[card]->devicename, cmdptr); + sc_adapter[card]->devicename, cmdptr); return -EFAULT; } return sc_ioctl(card, &ioc); @@ -133,76 +133,76 @@ int command(isdn_ctrl *cmd) /* * start the onboard firmware */ -int startproc(int card) +int startproc(int card) { int status; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } /* - * send start msg + * send start msg */ - status = sendmessage(card, CMPID,cmReqType2, - cmReqClass0, - cmReqStartProc, - 0,0,NULL); + status = sendmessage(card, CMPID, cmReqType2, + cmReqClass0, + cmReqStartProc, + 0, 0, NULL); pr_debug("%s: Sent startProc\n", sc_adapter[card]->devicename); - + return status; } /* - * Dials the number passed in + * Dials the number passed in */ static int dial(int card, unsigned long channel, setup_parm setup) { int status; char Phone[48]; - - if(!IS_VALID_CARD(card)) { + + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } - /*extract ISDN number to dial from eaz/msn string*/ - strcpy(Phone,setup.phone); + /*extract ISDN number to dial from eaz/msn string*/ + strcpy(Phone, setup.phone); /*send the connection message*/ - status = sendmessage(card, CEPID,ceReqTypePhy, - ceReqClass1, - ceReqPhyConnect, - (unsigned char) channel+1, - strlen(Phone), - (unsigned int *) Phone); + status = sendmessage(card, CEPID, ceReqTypePhy, + ceReqClass1, + ceReqPhyConnect, + (unsigned char)channel + 1, + strlen(Phone), + (unsigned int *)Phone); pr_debug("%s: Dialing %s on channel %lu\n", - sc_adapter[card]->devicename, Phone, channel+1); - + sc_adapter[card]->devicename, Phone, channel + 1); + return status; } /* - * Answer an incoming call + * Answer an incoming call */ static int answer(int card, unsigned long channel) { - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } - if(setup_buffers(card, channel+1)) { - hangup(card, channel+1); + if (setup_buffers(card, channel + 1)) { + hangup(card, channel + 1); return -ENOBUFS; } - indicate_status(card, ISDN_STAT_BCONN,channel,NULL); + indicate_status(card, ISDN_STAT_BCONN, channel, NULL); pr_debug("%s: Answered incoming call on channel %lu\n", - sc_adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel + 1); return 0; } @@ -213,19 +213,19 @@ static int hangup(int card, unsigned long channel) { int status; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } status = sendmessage(card, CEPID, ceReqTypePhy, - ceReqClass1, - ceReqPhyDisconnect, - (unsigned char) channel+1, - 0, - NULL); + ceReqClass1, + ceReqPhyDisconnect, + (unsigned char)channel + 1, + 0, + NULL); pr_debug("%s: Sent HANGUP message to channel %lu\n", - sc_adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel + 1); return status; } @@ -234,10 +234,10 @@ static int hangup(int card, unsigned long channel) */ static int setl2(int card, unsigned long arg) { - int status =0; - int protocol,channel; + int status = 0; + int protocol, channel; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } @@ -249,14 +249,14 @@ static int setl2(int card, unsigned long arg) * check that the adapter is also set to the correct protocol */ pr_debug("%s: Sending GetFrameFormat for channel %d\n", - sc_adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel + 1); status = sendmessage(card, CEPID, ceReqTypeCall, - ceReqClass0, - ceReqCallGetFrameFormat, - (unsigned char)channel+1, - 1, - (unsigned int *) protocol); - if(status) + ceReqClass0, + ceReqCallGetFrameFormat, + (unsigned char)channel + 1, + 1, + (unsigned int *)protocol); + if (status) return status; return 0; } @@ -268,7 +268,7 @@ static int setl3(int card, unsigned long channel) { int protocol = channel >> 8; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } @@ -279,26 +279,26 @@ static int setl3(int card, unsigned long channel) static int acceptb(int card, unsigned long channel) { - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } - if(setup_buffers(card, channel+1)) + if (setup_buffers(card, channel + 1)) { - hangup(card, channel+1); + hangup(card, channel + 1); return -ENOBUFS; } pr_debug("%s: B-Channel connection accepted on channel %lu\n", - sc_adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel + 1); indicate_status(card, ISDN_STAT_BCONN, channel, NULL); return 0; } static int clreaz(int card, unsigned long arg) { - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } @@ -306,13 +306,13 @@ static int clreaz(int card, unsigned long arg) strcpy(sc_adapter[card]->channel[arg].eazlist, ""); sc_adapter[card]->channel[arg].eazclear = 1; pr_debug("%s: EAZ List cleared for channel %lu\n", - sc_adapter[card]->devicename, arg+1); + sc_adapter[card]->devicename, arg + 1); return 0; } static int seteaz(int card, unsigned long arg, char *num) { - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } @@ -320,8 +320,8 @@ static int seteaz(int card, unsigned long arg, char *num) strcpy(sc_adapter[card]->channel[arg].eazlist, num); sc_adapter[card]->channel[arg].eazclear = 0; pr_debug("%s: EAZ list for channel %lu set to: %s\n", - sc_adapter[card]->devicename, arg+1, - sc_adapter[card]->channel[arg].eazlist); + sc_adapter[card]->devicename, arg + 1, + sc_adapter[card]->channel[arg].eazlist); return 0; } @@ -329,14 +329,14 @@ int reset(int card) { unsigned long flags; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return -ENODEV; } indicate_status(card, ISDN_STAT_STOP, 0, NULL); - if(sc_adapter[card]->EngineUp) { + if (sc_adapter[card]->EngineUp) { del_timer(&sc_adapter[card]->stat_timer); } @@ -350,14 +350,14 @@ int reset(int card) add_timer(&sc_adapter[card]->reset_timer); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); - outb(0x1,sc_adapter[card]->ioport[SFT_RESET]); + outb(0x1, sc_adapter[card]->ioport[SFT_RESET]); pr_debug("%s: Adapter Reset\n", sc_adapter[card]->devicename); return 0; } -void flushreadfifo (int card) +void flushreadfifo(int card) { - while(inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) + while (inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) inb(sc_adapter[card]->ioport[FIFO_READ]); } diff --git a/drivers/isdn/sc/event.c b/drivers/isdn/sc/event.c index 498f4039ece2..717003a3bdf4 100644 --- a/drivers/isdn/sc/event.c +++ b/drivers/isdn/sc/event.c @@ -38,26 +38,26 @@ static char *events[] = { "ISDN_STAT_STAVAIL", "ISDN_STAT_CAUSE" }; #endif -int indicate_status(int card, int event,ulong Channel,char *Data) +int indicate_status(int card, int event, ulong Channel, char *Data) { isdn_ctrl cmd; #ifdef DEBUG pr_debug("%s: Indicating event %s on Channel %d\n", - sc_adapter[card]->devicename, events[event-256], Channel); + sc_adapter[card]->devicename, events[event - 256], Channel); #endif - if (Data != NULL){ + if (Data != NULL) { pr_debug("%s: Event data: %s\n", sc_adapter[card]->devicename, - Data); + Data); switch (event) { - case ISDN_STAT_BSENT: - memcpy(&cmd.parm.length, Data, sizeof(cmd.parm.length)); - break; - case ISDN_STAT_ICALL: - memcpy(&cmd.parm.setup, Data, sizeof(cmd.parm.setup)); - break; - default: - strcpy(cmd.parm.num, Data); + case ISDN_STAT_BSENT: + memcpy(&cmd.parm.length, Data, sizeof(cmd.parm.length)); + break; + case ISDN_STAT_ICALL: + memcpy(&cmd.parm.setup, Data, sizeof(cmd.parm.setup)); + break; + default: + strcpy(cmd.parm.num, Data); } } diff --git a/drivers/isdn/sc/hardware.h b/drivers/isdn/sc/hardware.h index 627324856ead..81fbe78701f0 100644 --- a/drivers/isdn/sc/hardware.h +++ b/drivers/isdn/sc/hardware.h @@ -105,6 +105,6 @@ */ /* Determine if a channel number is valid for the adapter */ -#define IS_VALID_CHANNEL(y,x) ((x>0) && (x <= sc_adapter[y]->channels)) +#define IS_VALID_CHANNEL(y, x) ((x > 0) && (x <= sc_adapter[y]->channels)) #endif diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c index 023de789f250..6b580b2c717f 100644 --- a/drivers/isdn/sc/init.c +++ b/drivers/isdn/sc/init.c @@ -27,9 +27,9 @@ static const char version[] = "2.0b1"; static const char *boardname[] = { "DataCommute/BRI", "DataCommute/PRI", "TeleCommute/BRI" }; /* insmod set parameters */ -static unsigned int io[] = {0,0,0,0}; -static unsigned char irq[] = {0,0,0,0}; -static unsigned long ram[] = {0,0,0,0}; +static unsigned int io[] = {0, 0, 0, 0}; +static unsigned char irq[] = {0, 0, 0, 0}; +static unsigned long ram[] = {0, 0, 0, 0}; static bool do_reset = 0; module_param_array(io, int, NULL, 0); @@ -62,7 +62,7 @@ static int __init sc_init(void) #endif pr_info("Copyright (C) 1996 SpellCaster Telecommunications Inc.\n"); - while(b++ < MAX_CARDS - 1) { + while (b++ < MAX_CARDS - 1) { pr_debug("Probing for adapter #%d\n", b); /* * Initialize reusable variables @@ -72,17 +72,17 @@ static int __init sc_init(void) channels = 0; pgport = 0; - /* - * See if we should probe for IO base + /* + * See if we should probe for IO base */ pr_debug("I/O Base for board %d is 0x%x, %s probe\n", b, io[b], - io[b] == 0 ? "will" : "won't"); - if(io[b]) { + io[b] == 0 ? "will" : "won't"); + if (io[b]) { /* * No, I/O Base has been provided */ - for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) { - if(!request_region(io[b] + i * 0x400, 1, "sc test")) { + for (i = 0; i < MAX_IO_REGS - 1; i++) { + if (!request_region(io[b] + i * 0x400, 1, "sc test")) { pr_debug("request_region for 0x%x failed\n", io[b] + i * 0x400); io[b] = 0; break; @@ -93,13 +93,13 @@ static int __init sc_init(void) /* * Confirm the I/O Address with a test */ - if(io[b] == 0) { + if (io[b] == 0) { pr_debug("I/O Address invalid.\n"); continue; } outb(0x18, io[b] + 0x400 * EXP_PAGE0); - if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { + if (inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { pr_debug("I/O Base 0x%x fails test\n", io[b] + 0x400 * EXP_PAGE0); continue; @@ -109,12 +109,12 @@ static int __init sc_init(void) /* * Yes, probe for I/O Base */ - if(probe_exhasted) { + if (probe_exhasted) { pr_debug("All probe addresses exhasted, skipping\n"); continue; } pr_debug("Probing for I/O...\n"); - for (i = last_base ; i <= IOBASE_MAX ; i += IOBASE_OFFSET) { + for (i = last_base; i <= IOBASE_MAX; i += IOBASE_OFFSET) { int found_io = 1; if (i == IOBASE_MAX) { probe_exhasted = 1; /* No more addresses to probe */ @@ -122,19 +122,19 @@ static int __init sc_init(void) } last_base = i + IOBASE_OFFSET; pr_debug(" checking 0x%x...", i); - for ( j = 0 ; j < MAX_IO_REGS - 1 ; j++) { - if(!request_region(i + j * 0x400, 1, "sc test")) { + for (j = 0; j < MAX_IO_REGS - 1; j++) { + if (!request_region(i + j * 0x400, 1, "sc test")) { pr_debug("Failed\n"); found_io = 0; break; } else release_region(i + j * 0x400, 1); - } + } - if(found_io) { + if (found_io) { io[b] = i; outb(0x18, io[b] + 0x400 * EXP_PAGE0); - if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { + if (inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { pr_debug("Failed by test\n"); continue; } @@ -142,7 +142,7 @@ static int __init sc_init(void) break; } } - if(probe_exhasted) { + if (probe_exhasted) { continue; } } @@ -150,23 +150,23 @@ static int __init sc_init(void) /* * See if we should probe for shared RAM */ - if(do_reset) { + if (do_reset) { pr_debug("Doing a SAFE probe reset\n"); outb(0xFF, io[b] + RESET_OFFSET); msleep_interruptible(10000); } pr_debug("RAM Base for board %d is 0x%lx, %s probe\n", b, - ram[b], ram[b] == 0 ? "will" : "won't"); + ram[b], ram[b] == 0 ? "will" : "won't"); - if(ram[b]) { + if (ram[b]) { /* * No, the RAM base has been provided * Just look for a signature and ID the * board model */ - if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) { + if (request_region(ram[b], SRAM_PAGESIZE, "sc test")) { pr_debug("request_region for RAM base 0x%lx succeeded\n", ram[b]); - model = identify_board(ram[b], io[b]); + model = identify_board(ram[b], io[b]); release_region(ram[b], SRAM_PAGESIZE); } } @@ -175,15 +175,15 @@ static int __init sc_init(void) * Yes, probe for free RAM and look for * a signature and id the board model */ - for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) { + for (i = SRAM_MIN; i < SRAM_MAX; i += SRAM_PAGESIZE) { pr_debug("Checking RAM address 0x%x...\n", i); - if(request_region(i, SRAM_PAGESIZE, "sc test")) { + if (request_region(i, SRAM_PAGESIZE, "sc test")) { pr_debug(" request_region succeeded\n"); model = identify_board(i, io[b]); release_region(i, SRAM_PAGESIZE); if (model >= 0) { pr_debug(" Identified a %s\n", - boardname[model]); + boardname[model]); ram[b] = i; break; } @@ -196,19 +196,19 @@ static int __init sc_init(void) /* * See if we found free RAM and the board model */ - if(!ram[b] || model < 0) { + if (!ram[b] || model < 0) { /* * Nope, there was no place in RAM for the * board, or it couldn't be identified */ - pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]); - continue; + pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]); + continue; } /* * Set the board's magic number, memory size and page register */ - switch(model) { + switch (model) { case PRI_BOARD: channels = 23; magic = 0x20000; @@ -224,7 +224,7 @@ static int __init sc_init(void) features = BRI_FEATURES; break; } - switch(ram[b] >> 12 & 0x0F) { + switch (ram[b] >> 12 & 0x0F) { case 0x0: pr_debug("RAM Page register set to EXP_PAGE0\n"); pgport = EXP_PAGE0; @@ -250,12 +250,12 @@ static int __init sc_init(void) continue; } - pr_debug("current IRQ: %d b: %d\n",irq[b],b); + pr_debug("current IRQ: %d b: %d\n", irq[b], b); /* * Make sure we got an IRQ */ - if(!irq[b]) { + if (!irq[b]) { /* * No interrupt could be used */ @@ -299,7 +299,7 @@ static int __init sc_init(void) } spin_lock_init(&sc_adapter[cinst]->lock); - if(!register_isdn(interface)) { + if (!register_isdn(interface)) { /* * Oops, couldn't register for some reason */ @@ -344,30 +344,30 @@ static int __init sc_init(void) kfree(interface); kfree(sc_adapter[cinst]); continue; - + } sc_adapter[cinst]->iobase = io[b]; - for(i = 0 ; i < MAX_IO_REGS - 1 ; i++) { + for (i = 0; i < MAX_IO_REGS - 1; i++) { sc_adapter[cinst]->ioport[i] = io[b] + i * 0x400; request_region(sc_adapter[cinst]->ioport[i], 1, - interface->id); + interface->id); pr_debug("Requesting I/O Port %#x\n", - sc_adapter[cinst]->ioport[i]); + sc_adapter[cinst]->ioport[i]); } sc_adapter[cinst]->ioport[IRQ_SELECT] = io[b] + 0x2; request_region(sc_adapter[cinst]->ioport[IRQ_SELECT], 1, - interface->id); + interface->id); pr_debug("Requesting I/O Port %#x\n", - sc_adapter[cinst]->ioport[IRQ_SELECT]); + sc_adapter[cinst]->ioport[IRQ_SELECT]); sc_adapter[cinst]->rambase = ram[b]; request_region(sc_adapter[cinst]->rambase, SRAM_PAGESIZE, - interface->id); + interface->id); - pr_info(" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n", + pr_info(" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n", sc_adapter[cinst]->devicename, sc_adapter[cinst]->driverId, boardname[model], channels, irq[b], io[b], ram[b]); - + /* * reset the adapter to put things in motion */ @@ -376,7 +376,7 @@ static int __init sc_init(void) cinst++; status = 0; } - if (status) + if (status) pr_info("Failed to find any adapters, driver unloaded\n"); return status; } @@ -385,7 +385,7 @@ static void __exit sc_exit(void) { int i, j; - for(i = 0 ; i < cinst ; i++) { + for (i = 0; i < cinst; i++) { pr_debug("Cleaning up after adapter %d\n", i); /* * kill the timers @@ -417,14 +417,14 @@ static void __exit sc_exit(void) /* * Release the I/O Port regions */ - for(j = 0 ; j < MAX_IO_REGS - 1; j++) { + for (j = 0; j < MAX_IO_REGS - 1; j++) { release_region(sc_adapter[i]->ioport[j], 1); pr_debug("Releasing I/O Port %#x\n", - sc_adapter[i]->ioport[j]); + sc_adapter[i]->ioport[j]); } release_region(sc_adapter[i]->ioport[IRQ_SELECT], 1); pr_debug("Releasing I/O Port %#x\n", - sc_adapter[i]->ioport[IRQ_SELECT]); + sc_adapter[i]->ioport[IRQ_SELECT]); /* * Release any memory we alloced @@ -447,19 +447,19 @@ static int identify_board(unsigned long rambase, unsigned int iobase) int x; pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n", - rambase, iobase); + rambase, iobase); /* * Enable the base pointer */ outb(rambase >> 12, iobase + 0x2c00); - switch(rambase >> 12 & 0x0F) { + switch (rambase >> 12 & 0x0F) { case 0x0: pgport = iobase + PG0_OFFSET; pr_debug("Page Register offset is 0x%x\n", PG0_OFFSET); break; - + case 0x4: pgport = iobase + PG1_OFFSET; pr_debug("Page Register offset is 0x%x\n", PG1_OFFSET); @@ -486,7 +486,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) msleep_interruptible(1000); sig = readl(rambase + SIG_OFFSET); pr_debug("Looking for a signature, got 0x%lx\n", sig); - if(sig == SIGNATURE) + if (sig == SIGNATURE) return PRI_BOARD; /* @@ -496,7 +496,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) msleep_interruptible(1000); sig = readl(rambase + SIG_OFFSET); pr_debug("Looking for a signature, got 0x%lx\n", sig); - if(sig == SIGNATURE) + if (sig == SIGNATURE) return BRI_BOARD; return -1; @@ -506,7 +506,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase) */ sig = readl(rambase + SIG_OFFSET); pr_debug("Looking for a signature, got 0x%lx\n", sig); - if(sig != SIGNATURE) + if (sig != SIGNATURE) return -1; dpm = (DualPortMemory *) rambase; @@ -523,11 +523,11 @@ static int identify_board(unsigned long rambase, unsigned int iobase) * Wait for the response */ x = 0; - while((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) { + while ((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) { schedule_timeout_interruptible(1); x++; } - if(x == 100) { + if (x == 100) { pr_debug("Timeout waiting for response\n"); return -1; } @@ -540,11 +540,11 @@ static int identify_board(unsigned long rambase, unsigned int iobase) hwci.st_u_sense ? "S/T" : "U", hwci.ram_size, hwci.serial_no, hwci.part_no, hwci.rev_no); - if(!strncmp(PRI_PARTNO, hwci.part_no, 6)) + if (!strncmp(PRI_PARTNO, hwci.part_no, 6)) return PRI_BOARD; - if(!strncmp(BRI_PARTNO, hwci.part_no, 6)) + if (!strncmp(BRI_PARTNO, hwci.part_no, 6)) return BRI_BOARD; - + return -1; } diff --git a/drivers/isdn/sc/interrupt.c b/drivers/isdn/sc/interrupt.c index f0225bc0f267..e80cc76bc314 100644 --- a/drivers/isdn/sc/interrupt.c +++ b/drivers/isdn/sc/interrupt.c @@ -22,7 +22,7 @@ #include /* - * + * */ irqreturn_t interrupt_handler(int dummy, void *card_inst) { @@ -31,15 +31,15 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) int channel; int card = (int)(unsigned long) card_inst; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return IRQ_NONE; } pr_debug("%s: Entered Interrupt handler\n", - sc_adapter[card]->devicename); - - /* + sc_adapter[card]->devicename); + + /* * Pull all of the waiting messages off the response queue */ while (!receivemessage(card, &rcvmsg)) { @@ -47,31 +47,31 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) * Push the message to the adapter structure for * send_and_receive to snoop */ - if(sc_adapter[card]->want_async_messages) + if (sc_adapter[card]->want_async_messages) memcpy(&(sc_adapter[card]->async_msg), - &rcvmsg, sizeof(RspMessage)); + &rcvmsg, sizeof(RspMessage)); channel = (unsigned int) rcvmsg.phy_link_no; - + /* * Trap Invalid request messages */ - if(IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) { - pr_debug("%s: Invalid request Message, rsp_status = %d\n", - sc_adapter[card]->devicename, - rcvmsg.rsp_status); - break; + if (IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) { + pr_debug("%s: Invalid request Message, rsp_status = %d\n", + sc_adapter[card]->devicename, + rcvmsg.rsp_status); + break; } - + /* * Check for a linkRead message */ if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Read)) { pr_debug("%s: Received packet 0x%x bytes long at 0x%lx\n", - sc_adapter[card]->devicename, - rcvmsg.msg_data.response.msg_len, - rcvmsg.msg_data.response.buff_offset); + sc_adapter[card]->devicename, + rcvmsg.msg_data.response.msg_len, + rcvmsg.msg_data.response.buff_offset); rcvpkt(card, &rcvmsg); continue; @@ -80,49 +80,49 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) /* * Handle a write acknoledgement */ - if(IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) { + if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) { pr_debug("%s: Packet Send ACK on channel %d\n", - sc_adapter[card]->devicename, - rcvmsg.phy_link_no); - sc_adapter[card]->channel[rcvmsg.phy_link_no-1].free_sendbufs++; + sc_adapter[card]->devicename, + rcvmsg.phy_link_no); + sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].free_sendbufs++; continue; } /* * Handle a connection message */ - if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Connect)) + if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Connect)) { unsigned int callid; - setup_parm setup; + setup_parm setup; pr_debug("%s: Connect message: line %d: status %d: cause 0x%x\n", - sc_adapter[card]->devicename, - rcvmsg.phy_link_no, - rcvmsg.rsp_status, - rcvmsg.msg_data.byte_array[2]); - - memcpy(&callid,rcvmsg.msg_data.byte_array,sizeof(int)); - if(callid>=0x8000 && callid<=0xFFFF) - { + sc_adapter[card]->devicename, + rcvmsg.phy_link_no, + rcvmsg.rsp_status, + rcvmsg.msg_data.byte_array[2]); + + memcpy(&callid, rcvmsg.msg_data.byte_array, sizeof(int)); + if (callid >= 0x8000 && callid <= 0xFFFF) + { pr_debug("%s: Got Dial-Out Rsp\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); indicate_status(card, ISDN_STAT_DCONN, - (unsigned long)rcvmsg.phy_link_no-1,NULL); - + (unsigned long)rcvmsg.phy_link_no - 1, NULL); + } - else if(callid>=0x0000 && callid<=0x7FFF) + else if (callid >= 0x0000 && callid <= 0x7FFF) { int len; pr_debug("%s: Got Incoming Call\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); len = strlcpy(setup.phone, &(rcvmsg.msg_data.byte_array[4]), - sizeof(setup.phone)); + sizeof(setup.phone)); if (len >= sizeof(setup.phone)) continue; len = strlcpy(setup.eazmsn, - sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, - sizeof(setup.eazmsn)); + sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, + sizeof(setup.eazmsn)); if (len >= sizeof(setup.eazmsn)) continue; setup.si1 = 7; @@ -130,8 +130,8 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) setup.plan = 0; setup.screen = 0; - indicate_status(card, ISDN_STAT_ICALL,(unsigned long)rcvmsg.phy_link_no-1,(char *)&setup); - indicate_status(card, ISDN_STAT_DCONN,(unsigned long)rcvmsg.phy_link_no-1,NULL); + indicate_status(card, ISDN_STAT_ICALL, (unsigned long)rcvmsg.phy_link_no - 1, (char *)&setup); + indicate_status(card, ISDN_STAT_DCONN, (unsigned long)rcvmsg.phy_link_no - 1, NULL); } continue; } @@ -139,16 +139,16 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) /* * Handle a disconnection message */ - if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect)) + if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect)) { pr_debug("%s: disconnect message: line %d: status %d: cause 0x%x\n", - sc_adapter[card]->devicename, - rcvmsg.phy_link_no, - rcvmsg.rsp_status, - rcvmsg.msg_data.byte_array[2]); + sc_adapter[card]->devicename, + rcvmsg.phy_link_no, + rcvmsg.rsp_status, + rcvmsg.msg_data.byte_array[2]); - indicate_status(card, ISDN_STAT_BHUP,(unsigned long)rcvmsg.phy_link_no-1,NULL); - indicate_status(card, ISDN_STAT_DHUP,(unsigned long)rcvmsg.phy_link_no-1,NULL); + indicate_status(card, ISDN_STAT_BHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL); + indicate_status(card, ISDN_STAT_DHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL); continue; } @@ -158,10 +158,10 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) */ if (IS_CM_MESSAGE(rcvmsg, 5, 0, MiscEngineUp)) { pr_debug("%s: Received EngineUp message\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); sc_adapter[card]->EngineUp = 1; - sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,1,0,NULL); - sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,2,0,NULL); + sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 1, 0, NULL); + sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 2, 0, NULL); init_timer(&sc_adapter[card]->stat_timer); sc_adapter[card]->stat_timer.function = check_phystat; sc_adapter[card]->stat_timer.data = card; @@ -175,25 +175,25 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) */ if (IS_CM_MESSAGE(rcvmsg, 2, 0, StartProc)) { pr_debug("%s: StartProc Response Status %d\n", - sc_adapter[card]->devicename, - rcvmsg.rsp_status); + sc_adapter[card]->devicename, + rcvmsg.rsp_status); continue; } /* * Handle a GetMyNumber Rsp */ - if (IS_CE_MESSAGE(rcvmsg,Call,0,GetMyNumber)){ + if (IS_CE_MESSAGE(rcvmsg, Call, 0, GetMyNumber)) { strlcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, rcvmsg.msg_data.byte_array, sizeof(rcvmsg.msg_data.byte_array)); continue; } - + /* * PhyStatus response */ - if(IS_CE_MESSAGE(rcvmsg, Phy, 2, Status)) { + if (IS_CE_MESSAGE(rcvmsg, Phy, 2, Status)) { unsigned int b1stat, b2stat; /* @@ -204,30 +204,30 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) sc_adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */ pr_debug("%s: PhyStat is 0x%2x\n", - sc_adapter[card]->devicename, - sc_adapter[card]->nphystat); + sc_adapter[card]->devicename, + sc_adapter[card]->nphystat); continue; } - /* + /* * Handle a GetFramFormat */ - if(IS_CE_MESSAGE(rcvmsg, Call, 0, GetFrameFormat)) { - if(rcvmsg.msg_data.byte_array[0] != HDLC_PROTO) { + if (IS_CE_MESSAGE(rcvmsg, Call, 0, GetFrameFormat)) { + if (rcvmsg.msg_data.byte_array[0] != HDLC_PROTO) { unsigned int proto = HDLC_PROTO; /* * Set board format to HDLC if it wasn't already */ pr_debug("%s: current frame format: 0x%x, will change to HDLC\n", - sc_adapter[card]->devicename, - rcvmsg.msg_data.byte_array[0]); + sc_adapter[card]->devicename, + rcvmsg.msg_data.byte_array[0]); sendmessage(card, CEPID, ceReqTypeCall, - ceReqClass0, - ceReqCallSetFrameFormat, - (unsigned char) channel +1, - 1,&proto); - } + ceReqClass0, + ceReqCallSetFrameFormat, + (unsigned char)channel + 1, + 1, &proto); + } continue; } @@ -235,13 +235,13 @@ irqreturn_t interrupt_handler(int dummy, void *card_inst) * Hmm... */ pr_debug("%s: Received unhandled message (%d,%d,%d) link %d\n", - sc_adapter[card]->devicename, - rcvmsg.type, rcvmsg.class, rcvmsg.code, - rcvmsg.phy_link_no); + sc_adapter[card]->devicename, + rcvmsg.type, rcvmsg.class, rcvmsg.code, + rcvmsg.phy_link_no); } /* while */ pr_debug("%s: Exiting Interrupt Handler\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return IRQ_HANDLED; } diff --git a/drivers/isdn/sc/ioctl.c b/drivers/isdn/sc/ioctl.c index 4cfdbe08ffd1..e63983aa1d27 100644 --- a/drivers/isdn/sc/ioctl.c +++ b/drivers/isdn/sc/ioctl.c @@ -30,11 +30,11 @@ int sc_ioctl(int card, scs_ioctl *data) if (!rcvmsg) return -ENOMEM; - switch(data->command) { + switch (data->command) { case SCIOCRESET: /* Perform a hard reset of the adapter */ { pr_debug("%s: SCIOCRESET: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); sc_adapter[card]->StartOnReset = 0; kfree(rcvmsg); return reset(card); @@ -50,10 +50,10 @@ int sc_ioctl(int card, scs_ioctl *data) return -ENOMEM; } pr_debug("%s: SCIOLOAD: ioctl received\n", - sc_adapter[card]->devicename); - if(sc_adapter[card]->EngineUp) { + sc_adapter[card]->devicename); + if (sc_adapter[card]->EngineUp) { pr_debug("%s: SCIOCLOAD: command failed, LoadProc while engine running.\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); kfree(rcvmsg); kfree(srec); return -1; @@ -69,18 +69,18 @@ int sc_ioctl(int card, scs_ioctl *data) } status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc, - 0, SCIOC_SRECSIZE, srec, rcvmsg, SAR_TIMEOUT); + 0, SCIOC_SRECSIZE, srec, rcvmsg, SAR_TIMEOUT); kfree(rcvmsg); kfree(srec); - if(status) { - pr_debug("%s: SCIOCLOAD: command failed, status = %d\n", - sc_adapter[card]->devicename, status); + if (status) { + pr_debug("%s: SCIOCLOAD: command failed, status = %d\n", + sc_adapter[card]->devicename, status); return -1; } else { pr_debug("%s: SCIOCLOAD: command successful\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return 0; } } @@ -89,10 +89,10 @@ int sc_ioctl(int card, scs_ioctl *data) { kfree(rcvmsg); pr_debug("%s: SCIOSTART: ioctl received\n", - sc_adapter[card]->devicename); - if(sc_adapter[card]->EngineUp) { + sc_adapter[card]->devicename); + if (sc_adapter[card]->EngineUp) { pr_debug("%s: SCIOCSTART: command failed, engine already running.\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return -1; } @@ -104,7 +104,7 @@ int sc_ioctl(int card, scs_ioctl *data) case SCIOCSETSWITCH: { pr_debug("%s: SCIOSETSWITCH: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * Get the switch type from user space @@ -115,41 +115,41 @@ int sc_ioctl(int card, scs_ioctl *data) } pr_debug("%s: SCIOCSETSWITCH: setting switch type to %d\n", - sc_adapter[card]->devicename, - switchtype); + sc_adapter[card]->devicename, + switchtype); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSwitchType, - 0, sizeof(char),&switchtype, rcvmsg, SAR_TIMEOUT); - if(!status && !(rcvmsg->rsp_status)) { + 0, sizeof(char), &switchtype, rcvmsg, SAR_TIMEOUT); + if (!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCSETSWITCH: command successful\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); kfree(rcvmsg); return 0; } else { pr_debug("%s: SCIOCSETSWITCH: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } } - + case SCIOCGETSWITCH: { pr_debug("%s: SCIOGETSWITCH: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * Get the switch type from the board */ - status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, - ceReqCallGetSwitchType, 0, 0, NULL, rcvmsg, SAR_TIMEOUT); + status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, + ceReqCallGetSwitchType, 0, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCGETSWITCH: command successful\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSWITCH: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } @@ -172,7 +172,7 @@ int sc_ioctl(int card, scs_ioctl *data) case SCIOCGETSPID: { pr_debug("%s: SCIOGETSPID: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); spid = kzalloc(SCIOC_SPIDSIZE, GFP_KERNEL); if (!spid) { @@ -183,13 +183,13 @@ int sc_ioctl(int card, scs_ioctl *data) * Get the spid from the board */ status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSPID, - data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); + data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status) { pr_debug("%s: SCIOCGETSPID: command successful\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSPID: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(spid); kfree(rcvmsg); return status; @@ -208,12 +208,12 @@ int sc_ioctl(int card, scs_ioctl *data) kfree(spid); kfree(rcvmsg); return 0; - } + } case SCIOCSETSPID: { pr_debug("%s: DCBIOSETSPID: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * Get the spid from user space @@ -224,21 +224,21 @@ int sc_ioctl(int card, scs_ioctl *data) return PTR_ERR(spid); } - pr_debug("%s: SCIOCSETSPID: setting channel %d spid to %s\n", - sc_adapter[card]->devicename, data->channel, spid); - status = send_and_receive(card, CEPID, ceReqTypeCall, - ceReqClass0, ceReqCallSetSPID, data->channel, - strlen(spid), spid, rcvmsg, SAR_TIMEOUT); - if(!status && !(rcvmsg->rsp_status)) { - pr_debug("%s: SCIOCSETSPID: command successful\n", - sc_adapter[card]->devicename); + pr_debug("%s: SCIOCSETSPID: setting channel %d spid to %s\n", + sc_adapter[card]->devicename, data->channel, spid); + status = send_and_receive(card, CEPID, ceReqTypeCall, + ceReqClass0, ceReqCallSetSPID, data->channel, + strlen(spid), spid, rcvmsg, SAR_TIMEOUT); + if (!status && !(rcvmsg->rsp_status)) { + pr_debug("%s: SCIOCSETSPID: command successful\n", + sc_adapter[card]->devicename); kfree(rcvmsg); kfree(spid); return 0; } else { pr_debug("%s: SCIOCSETSPID: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(rcvmsg); kfree(spid); return status; @@ -248,20 +248,20 @@ int sc_ioctl(int card, scs_ioctl *data) case SCIOCGETDN: { pr_debug("%s: SCIOGETDN: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * Get the dn from the board */ status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, - data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); + data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status) { pr_debug("%s: SCIOCGETDN: command successful\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETDN: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } @@ -283,12 +283,12 @@ int sc_ioctl(int card, scs_ioctl *data) } kfree(dn); return 0; - } + } case SCIOCSETDN: { pr_debug("%s: SCIOSETDN: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * Get the spid from user space @@ -299,21 +299,21 @@ int sc_ioctl(int card, scs_ioctl *data) return PTR_ERR(dn); } - pr_debug("%s: SCIOCSETDN: setting channel %d dn to %s\n", - sc_adapter[card]->devicename, data->channel, dn); - status = send_and_receive(card, CEPID, ceReqTypeCall, - ceReqClass0, ceReqCallSetMyNumber, data->channel, - strlen(dn),dn,rcvmsg, SAR_TIMEOUT); - if(!status && !(rcvmsg->rsp_status)) { - pr_debug("%s: SCIOCSETDN: command successful\n", - sc_adapter[card]->devicename); + pr_debug("%s: SCIOCSETDN: setting channel %d dn to %s\n", + sc_adapter[card]->devicename, data->channel, dn); + status = send_and_receive(card, CEPID, ceReqTypeCall, + ceReqClass0, ceReqCallSetMyNumber, data->channel, + strlen(dn), dn, rcvmsg, SAR_TIMEOUT); + if (!status && !(rcvmsg->rsp_status)) { + pr_debug("%s: SCIOCSETDN: command successful\n", + sc_adapter[card]->devicename); kfree(rcvmsg); kfree(dn); return 0; } else { pr_debug("%s: SCIOCSETDN: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(rcvmsg); kfree(dn); return status; @@ -323,11 +323,11 @@ int sc_ioctl(int card, scs_ioctl *data) case SCIOCTRACE: pr_debug("%s: SCIOTRACE: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* sc_adapter[card]->trace = !sc_adapter[card]->trace; pr_debug("%s: SCIOCTRACE: tracing turned %s\n", - sc_adapter[card]->devicename, - sc_adapter[card]->trace ? "ON" : "OFF"); */ + sc_adapter[card]->devicename, + sc_adapter[card]->trace ? "ON" : "OFF"); */ break; case SCIOCSTAT: @@ -335,7 +335,7 @@ int sc_ioctl(int card, scs_ioctl *data) boardInfo *bi; pr_debug("%s: SCIOSTAT: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); bi = kzalloc(sizeof(boardInfo), GFP_KERNEL); if (!bi) { @@ -358,20 +358,20 @@ int sc_ioctl(int card, scs_ioctl *data) case SCIOCGETSPEED: { pr_debug("%s: SCIOGETSPEED: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * Get the speed from the board */ - status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, - ceReqCallGetCallType, data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); + status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, + ceReqCallGetCallType, data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); if (!status && !(rcvmsg->rsp_status)) { pr_debug("%s: SCIOCGETSPEED: command successful\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSPEED: command failed (status = %d)\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); kfree(rcvmsg); return status; } @@ -392,12 +392,12 @@ int sc_ioctl(int card, scs_ioctl *data) case SCIOCSETSPEED: pr_debug("%s: SCIOCSETSPEED: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); break; case SCIOCLOOPTST: pr_debug("%s: SCIOCLOOPTST: ioctl received\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); break; default: @@ -432,32 +432,32 @@ static int GetStatus(int card, boardInfo *bi) * Get the current PhyStats and LnkStats */ status = send_and_receive(card, CEPID, ceReqTypePhy, ceReqClass2, - ceReqPhyStatus, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); - if(!status) { - if(sc_adapter[card]->model < PRI_BOARD) { + ceReqPhyStatus, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); + if (!status) { + if (sc_adapter[card]->model < PRI_BOARD) { bi->l1_status = rcvmsg.msg_data.byte_array[2]; - for(i = 0 ; i < BRI_CHANNELS ; i++) + for (i = 0; i < BRI_CHANNELS; i++) bi->status.bristats[i].phy_stat = rcvmsg.msg_data.byte_array[i]; } else { bi->l1_status = rcvmsg.msg_data.byte_array[0]; bi->l2_status = rcvmsg.msg_data.byte_array[1]; - for(i = 0 ; i < PRI_CHANNELS ; i++) - bi->status.pristats[i].phy_stat = - rcvmsg.msg_data.byte_array[i+2]; + for (i = 0; i < PRI_CHANNELS; i++) + bi->status.pristats[i].phy_stat = + rcvmsg.msg_data.byte_array[i + 2]; } } - + /* * Get the call types for each channel */ - for (i = 0 ; i < sc_adapter[card]->nChannels ; i++) { + for (i = 0; i < sc_adapter[card]->nChannels; i++) { status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, - ceReqCallGetCallType, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); - if(!status) { + ceReqCallGetCallType, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); + if (!status) { if (sc_adapter[card]->model == PRI_BOARD) { - bi->status.pristats[i].call_type = + bi->status.pristats[i].call_type = rcvmsg.msg_data.byte_array[0]; } else { @@ -466,7 +466,7 @@ static int GetStatus(int card, boardInfo *bi) } } } - + /* * If PRI, get the call states and service states for each channel */ @@ -475,10 +475,10 @@ static int GetStatus(int card, boardInfo *bi) * Get the call states */ status = send_and_receive(card, CEPID, ceReqTypeStat, ceReqClass2, - ceReqPhyChCallState, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); - if(!status) { - for( i = 0 ; i < PRI_CHANNELS ; i++ ) - bi->status.pristats[i].call_state = + ceReqPhyChCallState, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); + if (!status) { + for (i = 0; i < PRI_CHANNELS; i++) + bi->status.pristats[i].call_state = rcvmsg.msg_data.byte_array[i]; } @@ -486,27 +486,27 @@ static int GetStatus(int card, boardInfo *bi) * Get the service states */ status = send_and_receive(card, CEPID, ceReqTypeStat, ceReqClass2, - ceReqPhyChServState, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); - if(!status) { - for( i = 0 ; i < PRI_CHANNELS ; i++ ) - bi->status.pristats[i].serv_state = + ceReqPhyChServState, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); + if (!status) { + for (i = 0; i < PRI_CHANNELS; i++) + bi->status.pristats[i].serv_state = rcvmsg.msg_data.byte_array[i]; } /* * Get the link stats for the channels */ - for (i = 1 ; i <= PRI_CHANNELS ; i++) { + for (i = 1; i <= PRI_CHANNELS; i++) { status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, - ceReqLnkGetStats, i, 0, NULL, &rcvmsg, SAR_TIMEOUT); + ceReqLnkGetStats, i, 0, NULL, &rcvmsg, SAR_TIMEOUT); if (!status) { - bi->status.pristats[i-1].link_stats.tx_good = + bi->status.pristats[i - 1].link_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[0]; - bi->status.pristats[i-1].link_stats.tx_bad = + bi->status.pristats[i - 1].link_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[4]; - bi->status.pristats[i-1].link_stats.rx_good = + bi->status.pristats[i - 1].link_stats.rx_good = (unsigned long)rcvmsg.msg_data.byte_array[8]; - bi->status.pristats[i-1].link_stats.rx_bad = + bi->status.pristats[i - 1].link_stats.rx_bad = (unsigned long)rcvmsg.msg_data.byte_array[12]; } } @@ -515,7 +515,7 @@ static int GetStatus(int card, boardInfo *bi) * Link stats for the D channel */ status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, - ceReqLnkGetStats, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); + ceReqLnkGetStats, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); if (!status) { bi->dch_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[0]; bi->dch_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[4]; @@ -534,49 +534,49 @@ static int GetStatus(int card, boardInfo *bi) * Get the link stats for the channels */ status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, - ceReqLnkGetStats, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); + ceReqLnkGetStats, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); if (!status) { bi->dch_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[0]; bi->dch_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[4]; bi->dch_stats.rx_good = (unsigned long)rcvmsg.msg_data.byte_array[8]; bi->dch_stats.rx_bad = (unsigned long)rcvmsg.msg_data.byte_array[12]; - bi->status.bristats[0].link_stats.tx_good = + bi->status.bristats[0].link_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[16]; - bi->status.bristats[0].link_stats.tx_bad = + bi->status.bristats[0].link_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[20]; - bi->status.bristats[0].link_stats.rx_good = + bi->status.bristats[0].link_stats.rx_good = (unsigned long)rcvmsg.msg_data.byte_array[24]; - bi->status.bristats[0].link_stats.rx_bad = + bi->status.bristats[0].link_stats.rx_bad = (unsigned long)rcvmsg.msg_data.byte_array[28]; - bi->status.bristats[1].link_stats.tx_good = + bi->status.bristats[1].link_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[32]; - bi->status.bristats[1].link_stats.tx_bad = + bi->status.bristats[1].link_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[36]; - bi->status.bristats[1].link_stats.rx_good = + bi->status.bristats[1].link_stats.rx_good = (unsigned long)rcvmsg.msg_data.byte_array[40]; - bi->status.bristats[1].link_stats.rx_bad = + bi->status.bristats[1].link_stats.rx_bad = (unsigned long)rcvmsg.msg_data.byte_array[44]; } /* * Get the SPIDs */ - for (i = 0 ; i < BRI_CHANNELS ; i++) { + for (i = 0; i < BRI_CHANNELS; i++) { status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, - ceReqCallGetSPID, i+1, 0, NULL, &rcvmsg, SAR_TIMEOUT); + ceReqCallGetSPID, i + 1, 0, NULL, &rcvmsg, SAR_TIMEOUT); if (!status) strcpy(bi->status.bristats[i].spid, rcvmsg.msg_data.byte_array); } - + /* * Get the DNs */ - for (i = 0 ; i < BRI_CHANNELS ; i++) { + for (i = 0; i < BRI_CHANNELS; i++) { status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, - ceReqCallGetMyNumber, i+1, 0, NULL, &rcvmsg, SAR_TIMEOUT); + ceReqCallGetMyNumber, i + 1, 0, NULL, &rcvmsg, SAR_TIMEOUT); if (!status) strcpy(bi->status.bristats[i].dn, rcvmsg.msg_data.byte_array); } - + return 0; } diff --git a/drivers/isdn/sc/message.c b/drivers/isdn/sc/message.c index 0b4c4f15abdd..9679a1902b32 100644 --- a/drivers/isdn/sc/message.c +++ b/drivers/isdn/sc/message.c @@ -25,7 +25,7 @@ /* * receive a message from the board */ -int receivemessage(int card, RspMessage *rspmsg) +int receivemessage(int card, RspMessage *rspmsg) { DualPortMemory *dpm; unsigned long flags; @@ -34,9 +34,9 @@ int receivemessage(int card, RspMessage *rspmsg) pr_debug("Invalid param: %d is not a valid card id\n", card); return -EINVAL; } - + pr_debug("%s: Entered receivemessage\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* * See if there are messages waiting @@ -47,47 +47,47 @@ int receivemessage(int card, RspMessage *rspmsg) */ spin_lock_irqsave(&sc_adapter[card]->lock, flags); outb((sc_adapter[card]->shmem_magic >> 14) | 0x80, - sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); dpm = (DualPortMemory *) sc_adapter[card]->rambase; - memcpy_fromio(rspmsg, &(dpm->rsp_queue[dpm->rsp_tail]), - MSG_LEN); - dpm->rsp_tail = (dpm->rsp_tail+1) % MAX_MESSAGES; + memcpy_fromio(rspmsg, &(dpm->rsp_queue[dpm->rsp_tail]), + MSG_LEN); + dpm->rsp_tail = (dpm->rsp_tail + 1) % MAX_MESSAGES; inb(sc_adapter[card]->ioport[FIFO_READ]); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); /* * Tell the board that the message is received */ pr_debug("%s: Received Message seq:%d pid:%d time:%d cmd:%d " - "cnt:%d (type,class,code):(%d,%d,%d) " - "link:%d stat:0x%x\n", - sc_adapter[card]->devicename, - rspmsg->sequence_no, - rspmsg->process_id, - rspmsg->time_stamp, - rspmsg->cmd_sequence_no, - rspmsg->msg_byte_cnt, - rspmsg->type, - rspmsg->class, - rspmsg->code, - rspmsg->phy_link_no, - rspmsg->rsp_status); + "cnt:%d (type,class,code):(%d,%d,%d) " + "link:%d stat:0x%x\n", + sc_adapter[card]->devicename, + rspmsg->sequence_no, + rspmsg->process_id, + rspmsg->time_stamp, + rspmsg->cmd_sequence_no, + rspmsg->msg_byte_cnt, + rspmsg->type, + rspmsg->class, + rspmsg->code, + rspmsg->phy_link_no, + rspmsg->rsp_status); return 0; } return -ENOMSG; } - + /* * send a message to the board */ int sendmessage(int card, unsigned int procid, - unsigned int type, - unsigned int class, + unsigned int type, + unsigned int class, unsigned int code, - unsigned int link, - unsigned int data_len, - unsigned int *data) + unsigned int link, + unsigned int data_len, + unsigned int *data) { DualPortMemory *dpm; ReqMessage sndmsg; @@ -102,15 +102,15 @@ int sendmessage(int card, * Make sure we only send CEPID messages when the engine is up * and CMPID messages when it is down */ - if(sc_adapter[card]->EngineUp && procid == CMPID) { + if (sc_adapter[card]->EngineUp && procid == CMPID) { pr_debug("%s: Attempt to send CM message with engine up\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return -ESRCH; } - if(!sc_adapter[card]->EngineUp && procid == CEPID) { + if (!sc_adapter[card]->EngineUp && procid == CEPID) { pr_debug("%s: Attempt to send CE message with engine down\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return -ESRCH; } @@ -142,39 +142,39 @@ int sendmessage(int card, */ spin_lock_irqsave(&sc_adapter[card]->lock, flags); outb((sc_adapter[card]->shmem_magic >> 14) | 0x80, - sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); dpm = (DualPortMemory *) sc_adapter[card]->rambase; /* Fix me */ - memcpy_toio(&(dpm->req_queue[dpm->req_head]),&sndmsg,MSG_LEN); - dpm->req_head = (dpm->req_head+1) % MAX_MESSAGES; + memcpy_toio(&(dpm->req_queue[dpm->req_head]), &sndmsg, MSG_LEN); + dpm->req_head = (dpm->req_head + 1) % MAX_MESSAGES; outb(sndmsg.sequence_no, sc_adapter[card]->ioport[FIFO_WRITE]); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); - + pr_debug("%s: Sent Message seq:%d pid:%d time:%d " - "cnt:%d (type,class,code):(%d,%d,%d) " - "link:%d\n ", - sc_adapter[card]->devicename, - sndmsg.sequence_no, - sndmsg.process_id, - sndmsg.time_stamp, - sndmsg.msg_byte_cnt, - sndmsg.type, - sndmsg.class, - sndmsg.code, - sndmsg.phy_link_no); - + "cnt:%d (type,class,code):(%d,%d,%d) " + "link:%d\n ", + sc_adapter[card]->devicename, + sndmsg.sequence_no, + sndmsg.process_id, + sndmsg.time_stamp, + sndmsg.msg_byte_cnt, + sndmsg.type, + sndmsg.class, + sndmsg.code, + sndmsg.phy_link_no); + return 0; } int send_and_receive(int card, - unsigned int procid, - unsigned char type, - unsigned char class, - unsigned char code, - unsigned char link, - unsigned char data_len, - unsigned char *data, - RspMessage *mesgdata, - int timeout) + unsigned int procid, + unsigned char type, + unsigned char class, + unsigned char code, + unsigned char link, + unsigned char data_len, + unsigned char *data, + RspMessage *mesgdata, + int timeout) { int retval; int tries; @@ -185,12 +185,12 @@ int send_and_receive(int card, } sc_adapter[card]->want_async_messages = 1; - retval = sendmessage(card, procid, type, class, code, link, - data_len, (unsigned int *) data); - + retval = sendmessage(card, procid, type, class, code, link, + data_len, (unsigned int *) data); + if (retval) { pr_debug("%s: SendMessage failed in SAR\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); sc_adapter[card]->want_async_messages = 0; return -EIO; } @@ -199,7 +199,7 @@ int send_and_receive(int card, /* wait for the response */ while (tries < timeout) { schedule_timeout_interruptible(1); - + pr_debug("SAR waiting..\n"); /* @@ -214,14 +214,14 @@ int send_and_receive(int card, * Got it! */ pr_debug("%s: Got ASYNC message\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); memcpy(mesgdata, &(sc_adapter[card]->async_msg), - sizeof(RspMessage)); + sizeof(RspMessage)); sc_adapter[card]->want_async_messages = 0; return 0; } - tries++; + tries++; } pr_debug("%s: SAR message timeout\n", sc_adapter[card]->devicename); diff --git a/drivers/isdn/sc/message.h b/drivers/isdn/sc/message.h index 8eb15e7306b2..5e6f4a5c15f8 100644 --- a/drivers/isdn/sc/message.h +++ b/drivers/isdn/sc/message.h @@ -21,7 +21,7 @@ /* * Board message macros, defines and structures */ - + #ifndef MESSAGE_H #define MESSAGE_H @@ -36,19 +36,19 @@ * Macro to determine if a message is a loader message */ #define IS_CM_MESSAGE(mesg, tx, cx, dx) \ - ((mesg.type == cmRspType##tx) \ - &&(mesg.class == cmRspClass##cx) \ - &&(mesg.code == cmRsp##dx)) + ((mesg.type == cmRspType##tx) \ + && (mesg.class == cmRspClass##cx) \ + && (mesg.code == cmRsp##dx)) /* * Macro to determine if a message is a firmware message */ #define IS_CE_MESSAGE(mesg, tx, cx, dx) \ - ((mesg.type == ceRspType##tx) \ - &&(mesg.class == ceRspClass##cx) \ - &&(mesg.code == ceRsp##tx##dx)) + ((mesg.type == ceRspType##tx) \ + && (mesg.class == ceRspClass##cx) \ + && (mesg.code == ceRsp##tx##dx)) -/* +/* * Loader Request and Response Messages */ @@ -186,7 +186,7 @@ typedef struct { } LLData; -/* +/* * Message payload template for an HWConfig message */ typedef struct { diff --git a/drivers/isdn/sc/packet.c b/drivers/isdn/sc/packet.c index 5ff6ae868440..2446957085e0 100644 --- a/drivers/isdn/sc/packet.c +++ b/drivers/isdn/sc/packet.c @@ -29,27 +29,27 @@ int sndpkt(int devId, int channel, int ack, struct sk_buff *data) card = get_card_from_id(devId); - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("invalid param: %d is not a valid card id\n", card); return -ENODEV; } pr_debug("%s: sndpkt: frst = 0x%lx nxt = %d f = %d n = %d\n", - sc_adapter[card]->devicename, - sc_adapter[card]->channel[channel].first_sendbuf, - sc_adapter[card]->channel[channel].next_sendbuf, - sc_adapter[card]->channel[channel].free_sendbufs, - sc_adapter[card]->channel[channel].num_sendbufs); + sc_adapter[card]->devicename, + sc_adapter[card]->channel[channel].first_sendbuf, + sc_adapter[card]->channel[channel].next_sendbuf, + sc_adapter[card]->channel[channel].free_sendbufs, + sc_adapter[card]->channel[channel].num_sendbufs); - if(!sc_adapter[card]->channel[channel].free_sendbufs) { + if (!sc_adapter[card]->channel[channel].free_sendbufs) { pr_debug("%s: out of TX buffers\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return -EINVAL; } - if(data->len > BUFFER_SIZE) { + if (data->len > BUFFER_SIZE) { pr_debug("%s: data overflows buffer size (data > buffer)\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return -EINVAL; } @@ -57,24 +57,24 @@ int sndpkt(int devId, int channel, int ack, struct sk_buff *data) BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf; ReqLnkWrite.msg_len = data->len; /* sk_buff size */ pr_debug("%s: writing %d bytes to buffer offset 0x%lx\n", - sc_adapter[card]->devicename, - ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset); + sc_adapter[card]->devicename, + ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset); memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len); /* * sendmessage */ pr_debug("%s: sndpkt size=%d, buf_offset=0x%lx buf_indx=%d\n", - sc_adapter[card]->devicename, - ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset, - sc_adapter[card]->channel[channel].next_sendbuf); + sc_adapter[card]->devicename, + ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset, + sc_adapter[card]->channel[channel].next_sendbuf); status = sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkWrite, - channel+1, sizeof(LLData), (unsigned int*)&ReqLnkWrite); + channel + 1, sizeof(LLData), (unsigned int *)&ReqLnkWrite); len = data->len; - if(status) { + if (status) { pr_debug("%s: failed to send packet, status = %d\n", - sc_adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return -1; } else { @@ -83,9 +83,9 @@ int sndpkt(int devId, int channel, int ack, struct sk_buff *data) ++sc_adapter[card]->channel[channel].next_sendbuf == sc_adapter[card]->channel[channel].num_sendbufs ? 0 : sc_adapter[card]->channel[channel].next_sendbuf; - pr_debug("%s: packet sent successfully\n", sc_adapter[card]->devicename); + pr_debug("%s: packet sent successfully\n", sc_adapter[card]->devicename); dev_kfree_skb(data); - indicate_status(card,ISDN_STAT_BSENT,channel, (char *)&len); + indicate_status(card, ISDN_STAT_BSENT, channel, (char *)&len); } return len; } @@ -95,49 +95,49 @@ void rcvpkt(int card, RspMessage *rcvmsg) LLData newll; struct sk_buff *skb; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("invalid param: %d is not a valid card id\n", card); return; } - switch(rcvmsg->rsp_status){ + switch (rcvmsg->rsp_status) { case 0x01: case 0x02: case 0x70: pr_debug("%s: error status code: 0x%x\n", - sc_adapter[card]->devicename, rcvmsg->rsp_status); + sc_adapter[card]->devicename, rcvmsg->rsp_status); return; - case 0x00: - if (!(skb = dev_alloc_skb(rcvmsg->msg_data.response.msg_len))) { + case 0x00: + if (!(skb = dev_alloc_skb(rcvmsg->msg_data.response.msg_len))) { printk(KERN_WARNING "%s: rcvpkt out of memory, dropping packet\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return; } skb_put(skb, rcvmsg->msg_data.response.msg_len); pr_debug("%s: getting data from offset: 0x%lx\n", - sc_adapter[card]->devicename, - rcvmsg->msg_data.response.buff_offset); + sc_adapter[card]->devicename, + rcvmsg->msg_data.response.buff_offset); memcpy_fromshmem(card, - skb_put(skb, rcvmsg->msg_data.response.msg_len), - (char *)rcvmsg->msg_data.response.buff_offset, - rcvmsg->msg_data.response.msg_len); + skb_put(skb, rcvmsg->msg_data.response.msg_len), + (char *)rcvmsg->msg_data.response.buff_offset, + rcvmsg->msg_data.response.msg_len); sc_adapter[card]->card->rcvcallb_skb(sc_adapter[card]->driverId, - rcvmsg->phy_link_no-1, skb); + rcvmsg->phy_link_no - 1, skb); case 0x03: /* - * Recycle the buffer - */ + * Recycle the buffer + */ pr_debug("%s: buffer size : %d\n", - sc_adapter[card]->devicename, BUFFER_SIZE); + sc_adapter[card]->devicename, BUFFER_SIZE); /* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */ newll.buff_offset = rcvmsg->msg_data.response.buff_offset; newll.msg_len = BUFFER_SIZE; pr_debug("%s: recycled buffer at offset 0x%lx size %d\n", - sc_adapter[card]->devicename, - newll.buff_offset, newll.msg_len); + sc_adapter[card]->devicename, + newll.buff_offset, newll.msg_len); sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, - rcvmsg->phy_link_no, sizeof(LLData), (unsigned int *)&newll); + rcvmsg->phy_link_no, sizeof(LLData), (unsigned int *)&newll); } } @@ -148,7 +148,7 @@ int setup_buffers(int card, int c) unsigned int buffer_size; LLData RcvBuffOffset; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("invalid param: %d is not a valid card id\n", card); return -ENODEV; } @@ -157,49 +157,48 @@ int setup_buffers(int card, int c) * Calculate the buffer offsets (send/recv/send/recv) */ pr_debug("%s: setting up channel buffer space in shared RAM\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); buffer_size = BUFFER_SIZE; nBuffers = ((sc_adapter[card]->ramsize - BUFFER_BASE) / buffer_size) / 2; nBuffers = nBuffers > BUFFERS_MAX ? BUFFERS_MAX : nBuffers; pr_debug("%s: calculating buffer space: %d buffers, %d big\n", - sc_adapter[card]->devicename, - nBuffers, buffer_size); - if(nBuffers < 2) { + sc_adapter[card]->devicename, + nBuffers, buffer_size); + if (nBuffers < 2) { pr_debug("%s: not enough buffer space\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); return -1; } cBase = (nBuffers * buffer_size) * (c - 1); pr_debug("%s: channel buffer offset from shared RAM: 0x%x\n", - sc_adapter[card]->devicename, cBase); - sc_adapter[card]->channel[c-1].first_sendbuf = BUFFER_BASE + cBase; - sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2; - sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2; - sc_adapter[card]->channel[c-1].next_sendbuf = 0; + sc_adapter[card]->devicename, cBase); + sc_adapter[card]->channel[c - 1].first_sendbuf = BUFFER_BASE + cBase; + sc_adapter[card]->channel[c - 1].num_sendbufs = nBuffers / 2; + sc_adapter[card]->channel[c - 1].free_sendbufs = nBuffers / 2; + sc_adapter[card]->channel[c - 1].next_sendbuf = 0; pr_debug("%s: send buffer setup complete: first=0x%lx n=%d f=%d, nxt=%d\n", - sc_adapter[card]->devicename, - sc_adapter[card]->channel[c-1].first_sendbuf, - sc_adapter[card]->channel[c-1].num_sendbufs, - sc_adapter[card]->channel[c-1].free_sendbufs, - sc_adapter[card]->channel[c-1].next_sendbuf); + sc_adapter[card]->devicename, + sc_adapter[card]->channel[c - 1].first_sendbuf, + sc_adapter[card]->channel[c - 1].num_sendbufs, + sc_adapter[card]->channel[c - 1].free_sendbufs, + sc_adapter[card]->channel[c - 1].next_sendbuf); /* * Prep the receive buffers */ pr_debug("%s: adding %d RecvBuffers:\n", - sc_adapter[card]->devicename, nBuffers /2); - for (i = 0 ; i < nBuffers / 2; i++) { - RcvBuffOffset.buff_offset = - ((sc_adapter[card]->channel[c-1].first_sendbuf + - (nBuffers / 2) * buffer_size) + (buffer_size * i)); + sc_adapter[card]->devicename, nBuffers / 2); + for (i = 0; i < nBuffers / 2; i++) { + RcvBuffOffset.buff_offset = + ((sc_adapter[card]->channel[c - 1].first_sendbuf + + (nBuffers / 2) * buffer_size) + (buffer_size * i)); RcvBuffOffset.msg_len = buffer_size; pr_debug("%s: adding RcvBuffer #%d offset=0x%lx sz=%d bufsz:%d\n", - sc_adapter[card]->devicename, - i + 1, RcvBuffOffset.buff_offset, - RcvBuffOffset.msg_len,buffer_size); + sc_adapter[card]->devicename, + i + 1, RcvBuffOffset.buff_offset, + RcvBuffOffset.msg_len, buffer_size); sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, - c, sizeof(LLData), (unsigned int *)&RcvBuffOffset); - } + c, sizeof(LLData), (unsigned int *)&RcvBuffOffset); + } return 0; } - diff --git a/drivers/isdn/sc/scioc.h b/drivers/isdn/sc/scioc.h index dfb107a6de44..a50e143779e7 100644 --- a/drivers/isdn/sc/scioc.h +++ b/drivers/isdn/sc/scioc.h @@ -17,9 +17,9 @@ #define SCIOCGETSWITCH 0x06 /* Get switch type */ #define SCIOCSETSWITCH 0x07 /* Set switch type */ #define SCIOCGETSPID 0x08 /* Get channel SPID */ -#define SCIOCSETSPID 0x09 /* Set channel SPID */ +#define SCIOCSETSPID 0x09 /* Set channel SPID */ #define SCIOCGETDN 0x0A /* Get channel DN */ -#define SCIOCSETDN 0x0B /* Set channel DN */ +#define SCIOCSETDN 0x0B /* Set channel DN */ #define SCIOCTRACE 0x0C /* Toggle trace mode */ #define SCIOCSTAT 0x0D /* Get line status */ #define SCIOCGETSPEED 0x0E /* Set channel speed */ @@ -108,4 +108,3 @@ typedef struct { } boardInfo; #endif /* __ISDN_SC_SCIOC_H__ */ - diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c index 7f16d75d2d89..d24506ceb6e8 100644 --- a/drivers/isdn/sc/shmem.c +++ b/drivers/isdn/sc/shmem.c @@ -42,22 +42,22 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) * determine the page to load from the address */ ch = (unsigned long) dest / SRAM_PAGESIZE; - pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch); + pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch); /* * Block interrupts and load the page */ spin_lock_irqsave(&sc_adapter[card]->lock, flags); outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, - sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); memcpy_toio((void __iomem *)(sc_adapter[card]->rambase + dest_rem), src, n); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); - pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, - ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); + pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename, + ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80); pr_debug("%s: copying %zu bytes from %#lx to %#lx\n", - sc_adapter[card]->devicename, n, - (unsigned long) src, - sc_adapter[card]->rambase + ((unsigned long) dest %0x4000)); + sc_adapter[card]->devicename, n, + (unsigned long) src, + sc_adapter[card]->rambase + ((unsigned long) dest % 0x4000)); } /* @@ -68,12 +68,12 @@ void memcpy_fromshmem(int card, void *dest, const void *src, size_t n) unsigned long flags; unsigned char ch; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return; } - if(n > SRAM_PAGESIZE) { + if (n > SRAM_PAGESIZE) { return; } @@ -81,24 +81,24 @@ void memcpy_fromshmem(int card, void *dest, const void *src, size_t n) * determine the page to load from the address */ ch = (unsigned long) src / SRAM_PAGESIZE; - pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch); - - + pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch); + + /* * Block interrupts and load the page */ spin_lock_irqsave(&sc_adapter[card]->lock, flags); outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, - sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); - memcpy_fromio(dest,(void *)(sc_adapter[card]->rambase + - ((unsigned long) src % 0x4000)), n); + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + memcpy_fromio(dest, (void *)(sc_adapter[card]->rambase + + ((unsigned long) src % 0x4000)), n); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); - pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, - ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); + pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename, + ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80); /* pr_debug("%s: copying %d bytes from %#x to %#x\n", - sc_adapter[card]->devicename, n, - sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */ + sc_adapter[card]->devicename, n, + sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */ } #if 0 @@ -107,12 +107,12 @@ void memset_shmem(int card, void *dest, int c, size_t n) unsigned long flags; unsigned char ch; - if(!IS_VALID_CARD(card)) { + if (!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return; } - if(n > SRAM_PAGESIZE) { + if (n > SRAM_PAGESIZE) { return; } @@ -120,7 +120,7 @@ void memset_shmem(int card, void *dest, int c, size_t n) * determine the page to load from the address */ ch = (unsigned long) dest / SRAM_PAGESIZE; - pr_debug("%s: loaded page %d\n",sc_adapter[card]->devicename,ch); + pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch); /* * Block interrupts and load the page @@ -128,11 +128,11 @@ void memset_shmem(int card, void *dest, int c, size_t n) spin_lock_irqsave(&sc_adapter[card]->lock, flags); outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, - sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); memset_io(sc_adapter[card]->rambase + - ((unsigned long) dest % 0x4000), c, n); - pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, - ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); + ((unsigned long) dest % 0x4000), c, n); + pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename, + ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); } #endif /* 0 */ diff --git a/drivers/isdn/sc/timer.c b/drivers/isdn/sc/timer.c index 91fbe0dc28ec..6fbac2230d7e 100644 --- a/drivers/isdn/sc/timer.c +++ b/drivers/isdn/sc/timer.c @@ -31,7 +31,7 @@ static void setup_ports(int card) /* And the IRQ */ outb((sc_adapter[card]->interrupt | 0x80), - sc_adapter[card]->ioport[IRQ_SELECT]); + sc_adapter[card]->ioport[IRQ_SELECT]); } /* @@ -50,18 +50,18 @@ void sc_check_reset(unsigned long data) int card = (unsigned int) data; pr_debug("%s: check_timer timer called\n", - sc_adapter[card]->devicename); + sc_adapter[card]->devicename); /* Setup the io ports */ setup_ports(card); spin_lock_irqsave(&sc_adapter[card]->lock, flags); outb(sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport], - (sc_adapter[card]->shmem_magic>>14) | 0x80); + (sc_adapter[card]->shmem_magic >> 14) | 0x80); sig = (unsigned long) *((unsigned long *)(sc_adapter[card]->rambase + SIG_OFFSET)); /* check the signature */ - if(sig == SIGNATURE) { + if (sig == SIGNATURE) { flushreadfifo(card); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); /* See if we need to do a startproc */ @@ -69,8 +69,8 @@ void sc_check_reset(unsigned long data) startproc(card); } else { pr_debug("%s: No signature yet, waiting another %lu jiffies.\n", - sc_adapter[card]->devicename, CHECKRESET_TIME); - mod_timer(&sc_adapter[card]->reset_timer, jiffies+CHECKRESET_TIME); + sc_adapter[card]->devicename, CHECKRESET_TIME); + mod_timer(&sc_adapter[card]->reset_timer, jiffies + CHECKRESET_TIME); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); } } @@ -91,19 +91,19 @@ void check_phystat(unsigned long data) int card = (unsigned int) data; pr_debug("%s: Checking status...\n", sc_adapter[card]->devicename); - /* + /* * check the results of the last PhyStat and change only if * has changed drastically */ if (sc_adapter[card]->nphystat && !sc_adapter[card]->phystat) { /* All is well */ pr_debug("PhyStat transition to RUN\n"); - pr_info("%s: Switch contacted, transmitter enabled\n", + pr_info("%s: Switch contacted, transmitter enabled\n", sc_adapter[card]->devicename); indicate_status(card, ISDN_STAT_RUN, 0, NULL); } else if (!sc_adapter[card]->nphystat && sc_adapter[card]->phystat) { /* All is not well */ pr_debug("PhyStat transition to STOP\n"); - pr_info("%s: Switch connection lost, transmitter disabled\n", + pr_info("%s: Switch connection lost, transmitter disabled\n", sc_adapter[card]->devicename); indicate_status(card, ISDN_STAT_STOP, 0, NULL); @@ -113,11 +113,10 @@ void check_phystat(unsigned long data) /* Reinitialize the timer */ spin_lock_irqsave(&sc_adapter[card]->lock, flags); - mod_timer(&sc_adapter[card]->stat_timer, jiffies+CHECKSTAT_TIME); + mod_timer(&sc_adapter[card]->stat_timer, jiffies + CHECKSTAT_TIME); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); /* Send a new cePhyStatus message */ - sendmessage(card, CEPID,ceReqTypePhy,ceReqClass2, - ceReqPhyStatus,0,0,NULL); + sendmessage(card, CEPID, ceReqTypePhy, ceReqClass2, + ceReqPhyStatus, 0, 0, NULL); } - -- GitLab From 5e5282bbfde9ca6157dba913d90cbab859a837e2 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 16:01:30 +0200 Subject: [PATCH 0924/1846] Bluetooth: mgmt: Allow connectable/discoverable changes in off state This patch makes it possible to toggle the connectable & discoverable settings when powered off. Two new hdev->dev_flags flags are added to track what the scan mode should be when the device is finally powered on. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 2 + net/bluetooth/hci_core.c | 1 + net/bluetooth/mgmt.c | 91 +++++++++++++++++++++++++++++-------- 3 files changed, 76 insertions(+), 18 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index ec370494e568..169d2f8cc4ee 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -96,6 +96,8 @@ enum { HCI_LE_SCAN, HCI_SSP_ENABLED, HCI_HS_ENABLED, + HCI_CONNECTABLE, + HCI_DISCOVERABLE, }; /* HCI ioctl defines */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index a787c9c9d4cd..9d199494bd65 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -737,6 +737,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) if (hdev->discov_timeout > 0) { cancel_delayed_work(&hdev->discov_off); hdev->discov_timeout = 0; + clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); } if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0f87030f9c30..6311be775ff2 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -398,10 +398,10 @@ static u32 get_current_settings(struct hci_dev *hdev) if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) settings |= MGMT_SETTING_POWERED; - if (test_bit(HCI_PSCAN, &hdev->flags)) + if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) settings |= MGMT_SETTING_CONNECTABLE; - if (test_bit(HCI_ISCAN, &hdev->flags)) + if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) settings |= MGMT_SETTING_DISCOVERABLE; if (test_bit(HCI_PAIRABLE, &hdev->dev_flags)) @@ -804,6 +804,7 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) struct mgmt_cp_set_discoverable *cp = data; struct hci_dev *hdev; struct pending_cmd *cmd; + u16 timeout; u8 scan; int err; @@ -818,9 +819,11 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_INVALID_PARAMS); + timeout = get_unaligned_le16(&cp->timeout); + hci_dev_lock(hdev); - if (!hdev_is_powered(hdev)) { + if (!hdev_is_powered(hdev) && timeout > 0) { err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_NOT_POWERED); goto failed; @@ -833,8 +836,22 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - if (cp->val == test_bit(HCI_ISCAN, &hdev->flags) && - test_bit(HCI_PSCAN, &hdev->flags)) { + if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) { + err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + MGMT_STATUS_REJECTED); + goto failed; + } + + if (!hdev_is_powered(hdev)) { + if (cp->val) + set_bit(HCI_DISCOVERABLE, &hdev->dev_flags); + else + clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); + err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); + goto failed; + } + + if (!!cp->val == test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) { err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); goto failed; } @@ -857,7 +874,7 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) mgmt_pending_remove(cmd); if (cp->val) - hdev->discov_timeout = get_unaligned_le16(&cp->timeout); + hdev->discov_timeout = timeout; failed: hci_dev_unlock(hdev); @@ -888,8 +905,13 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, - MGMT_STATUS_NOT_POWERED); + if (cp->val) + set_bit(HCI_CONNECTABLE, &hdev->dev_flags); + else { + clear_bit(HCI_CONNECTABLE, &hdev->dev_flags); + clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); + } + err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev); goto failed; } @@ -900,7 +922,7 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - if (cp->val == test_bit(HCI_PSCAN, &hdev->flags)) { + if (!!cp->val == test_bit(HCI_PSCAN, &hdev->flags)) { err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev); goto failed; } @@ -2881,9 +2903,22 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) __le32 ev; int err; + if (!test_bit(HCI_MGMT, &hdev->dev_flags)) + return 0; + mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); - if (!powered) { + if (powered) { + u8 scan = 0; + + if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) + scan |= SCAN_PAGE; + if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) + scan |= SCAN_INQUIRY; + + if (scan) + hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); + } else { u8 status = ENETDOWN; mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); } @@ -2902,15 +2937,25 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) { struct cmd_lookup match = { NULL, hdev }; - __le32 ev; - int err; + bool changed = false; + int err = 0; mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, settings_rsp, &match); - ev = cpu_to_le32(get_current_settings(hdev)); + if (discoverable) { + if (!test_and_set_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) + changed = true; + } else { + if (test_and_clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) + changed = true; + } - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), + if (changed) { + __le32 ev = cpu_to_le32(get_current_settings(hdev)); + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + } + if (match.sk) sock_put(match.sk); @@ -2919,16 +2964,26 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) int mgmt_connectable(struct hci_dev *hdev, u8 connectable) { - __le32 ev; struct cmd_lookup match = { NULL, hdev }; - int err; + bool changed = false; + int err = 0; mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, settings_rsp, &match); - ev = cpu_to_le32(get_current_settings(hdev)); + if (connectable) { + if (!test_and_set_bit(HCI_CONNECTABLE, &hdev->dev_flags)) + changed = true; + } else { + if (test_and_clear_bit(HCI_CONNECTABLE, &hdev->dev_flags)) + changed = true; + } - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + if (changed) { + __le32 ev = cpu_to_le32(get_current_settings(hdev)); + err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), + match.sk); + } if (match.sk) sock_put(match.sk); -- GitLab From df2c6c5ed5c0bc13b78e855d3e5d9aa3472567ba Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 19:15:49 +0200 Subject: [PATCH 0925/1846] Bluetooth: mgmt: Fix Removing discoverable timeout in set_connectable When switching connectable mode off any pending discoverable timeout must also be disabled to avoid duplicate write_scan_enable commands. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 6311be775ff2..eec70a4ba36c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -935,9 +935,14 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) if (cp->val) scan = SCAN_PAGE; - else + else { scan = 0; + if (test_bit(HCI_ISCAN, &hdev->flags) && + hdev->discov_timeout > 0) + cancel_delayed_work(&hdev->discov_off); + } + err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); if (err < 0) mgmt_pending_remove(cmd); -- GitLab From f1f0eb02213a3003ecb10b9c61694e588267b824 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 17:15:41 +0200 Subject: [PATCH 0926/1846] Bluetooth: mgmt: Fix current settings values when powered off We should not stop iterating through the various settings if powered off since most may still be set even then. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index eec70a4ba36c..86e63a707f5a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -392,10 +392,7 @@ static u32 get_current_settings(struct hci_dev *hdev) { u32 settings = 0; - if (!test_bit(HCI_UP, &hdev->flags)) - return settings; - - if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) + if (hdev_is_powered(hdev)) settings |= MGMT_SETTING_POWERED; if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) -- GitLab From beadb2bddce5810dc668da156b4c2ca457940250 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 16:55:31 +0200 Subject: [PATCH 0927/1846] Bluetooth: mgmt: Add convenience function for sending New Settings The New Settings event needs to be sent from quite many places so it makes sense to have a convenience function for it to simplify the code. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 96 ++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 86e63a707f5a..439ec786ff8c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -796,6 +796,42 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len) return err; } +static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, + u16 data_len, struct sock *skip_sk) +{ + struct sk_buff *skb; + struct mgmt_hdr *hdr; + + skb = alloc_skb(sizeof(*hdr) + data_len, GFP_ATOMIC); + if (!skb) + return -ENOMEM; + + hdr = (void *) skb_put(skb, sizeof(*hdr)); + hdr->opcode = cpu_to_le16(event); + if (hdev) + hdr->index = cpu_to_le16(hdev->id); + else + hdr->index = cpu_to_le16(MGMT_INDEX_NONE); + hdr->len = cpu_to_le16(data_len); + + if (data) + memcpy(skb_put(skb, data_len), data, data_len); + + hci_send_to_control(skb, skip_sk); + kfree_skb(skb); + + return 0; +} + +static int new_settings(struct hci_dev *hdev, struct sock *skip) +{ + __le32 ev; + + ev = cpu_to_le32(get_current_settings(hdev)); + + return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip); +} + static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_set_discoverable *cp = data; @@ -951,38 +987,10 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) return err; } -static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, - u16 data_len, struct sock *skip_sk) -{ - struct sk_buff *skb; - struct mgmt_hdr *hdr; - - skb = alloc_skb(sizeof(*hdr) + data_len, GFP_ATOMIC); - if (!skb) - return -ENOMEM; - - hdr = (void *) skb_put(skb, sizeof(*hdr)); - hdr->opcode = cpu_to_le16(event); - if (hdev) - hdr->index = cpu_to_le16(hdev->id); - else - hdr->index = cpu_to_le16(MGMT_INDEX_NONE); - hdr->len = cpu_to_le16(data_len); - - if (data) - memcpy(skb_put(skb, data_len), data, data_len); - - hci_send_to_control(skb, skip_sk); - kfree_skb(skb); - - return 0; -} - static int set_pairable(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_mode *cp = data; struct hci_dev *hdev; - __le32 ev; int err; BT_DBG("request for hci%u", index); @@ -1007,9 +1015,7 @@ static int set_pairable(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto failed; - ev = cpu_to_le32(get_current_settings(hdev)); - - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), sk); + err = new_settings(hdev, sk); failed: hci_dev_unlock(hdev); @@ -2902,7 +2908,6 @@ static void settings_rsp(struct pending_cmd *cmd, void *data) int mgmt_powered(struct hci_dev *hdev, u8 powered) { struct cmd_lookup match = { NULL, hdev }; - __le32 ev; int err; if (!test_bit(HCI_MGMT, &hdev->dev_flags)) @@ -2925,10 +2930,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); } - ev = cpu_to_le32(get_current_settings(hdev)); - - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), - match.sk); + err = new_settings(hdev, match.sk); if (match.sk) sock_put(match.sk); @@ -2952,11 +2954,8 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) changed = true; } - if (changed) { - __le32 ev = cpu_to_le32(get_current_settings(hdev)); - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), - match.sk); - } + if (changed) + err = new_settings(hdev, match.sk); if (match.sk) sock_put(match.sk); @@ -2981,11 +2980,8 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable) changed = true; } - if (changed) { - __le32 ev = cpu_to_le32(get_current_settings(hdev)); - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), - match.sk); - } + if (changed) + err = new_settings(hdev, match.sk); if (match.sk) sock_put(match.sk); @@ -3320,7 +3316,6 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) { struct cmd_lookup match = { NULL, hdev }; - __le32 ev; int err; if (status) { @@ -3333,8 +3328,7 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, settings_rsp, &match); - ev = cpu_to_le32(get_current_settings(hdev)); - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + err = new_settings(hdev, match.sk); if (match.sk) sock_put(match.sk); @@ -3357,7 +3351,6 @@ static int clear_eir(struct hci_dev *hdev) int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status) { struct cmd_lookup match = { NULL, hdev }; - __le32 ev; int err; if (status) { @@ -3369,8 +3362,7 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status) mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, settings_rsp, &match); - ev = cpu_to_le32(get_current_settings(hdev)); - err = mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), match.sk); + err = new_settings(hdev, match.sk); if (match.sk) { sock_put(match.sk); -- GitLab From 0224d2fafbbed4ac0cb05d08d3adab506a398451 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 19:40:05 +0200 Subject: [PATCH 0928/1846] Bluetooth: mgmt: Fix New Settings event for connectable/discoverable When powered off and doing changes to the Connectable or Discoverable setting we should also send an appropriate New Settings event in addition to the command response. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 439ec786ff8c..08b867a4d0e6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -876,11 +876,20 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) } if (!hdev_is_powered(hdev)) { - if (cp->val) - set_bit(HCI_DISCOVERABLE, &hdev->dev_flags); - else - clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); + bool changed = false; + + if (!!cp->val != test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) { + change_bit(HCI_DISCOVERABLE, &hdev->dev_flags); + changed = true; + } + err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); + if (err < 0) + goto failed; + + if (changed) + err = new_settings(hdev, sk); + goto failed; } @@ -938,13 +947,25 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { + bool changed = false; + + if (!!cp->val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) + changed = true; + if (cp->val) set_bit(HCI_CONNECTABLE, &hdev->dev_flags); else { clear_bit(HCI_CONNECTABLE, &hdev->dev_flags); clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); } + err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev); + if (err < 0) + goto failed; + + if (changed) + err = new_settings(hdev, sk); + goto failed; } -- GitLab From a297e97cf7228467a8c5c76216945ccf029ae2a4 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 17:55:47 +0200 Subject: [PATCH 0929/1846] Bluetooth: Fix clearing of persistent dev_flags Now that most flags are persistent, only the LE_SCAN flag should be cleared after a reset. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 5d0f92a948c2..2a5d05c05e35 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -192,9 +192,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_RESET, status); - /* Reset all flags, except persistent ones */ - hdev->dev_flags &= BIT(HCI_MGMT) | BIT(HCI_SETUP) | BIT(HCI_AUTO_OFF) | - BIT(HCI_LINK_KEYS) | BIT(HCI_DEBUG_KEYS); + /* Reset all non-persistent flags */ + hdev->dev_flags &= ~(BIT(HCI_LE_SCAN)); } static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From ed9b5f2fa053adce8dac88a385d2225a8ac5f0b5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 21 Feb 2012 20:47:06 +0200 Subject: [PATCH 0930/1846] Bluetooth: mgmt: Fix connectable/discoverable response values The connectable/discoverable flags need to be changed before sending the response since otherwise the settings value will be incorrect. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 08b867a4d0e6..e8f890d7256a 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2965,8 +2965,6 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) bool changed = false; int err = 0; - mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, settings_rsp, &match); - if (discoverable) { if (!test_and_set_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) changed = true; @@ -2975,6 +2973,9 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) changed = true; } + mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, settings_rsp, + &match); + if (changed) err = new_settings(hdev, match.sk); @@ -2990,9 +2991,6 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable) bool changed = false; int err = 0; - mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, settings_rsp, - &match); - if (connectable) { if (!test_and_set_bit(HCI_CONNECTABLE, &hdev->dev_flags)) changed = true; @@ -3001,6 +2999,9 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable) changed = true; } + mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, settings_rsp, + &match); + if (changed) err = new_settings(hdev, match.sk); -- GitLab From 4934b0329f7150dcb5f90506860e2db32274c755 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Feb 2012 07:30:33 +0000 Subject: [PATCH 0931/1846] datagram: Factor out sk queue referencing This makes lines shorter and simplifies further patching. Signed-off-by: Pavel Emelyanov Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- net/core/datagram.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/core/datagram.c b/net/core/datagram.c index 68bbf9f65cb0..6f54d0a17f8e 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -180,18 +180,19 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, * However, this function was correct in any case. 8) */ unsigned long cpu_flags; + struct sk_buff_head *queue = &sk->sk_receive_queue; - spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); - skb = skb_peek(&sk->sk_receive_queue); + spin_lock_irqsave(&queue->lock, cpu_flags); + skb = skb_peek(queue); if (skb) { *peeked = skb->peeked; if (flags & MSG_PEEK) { skb->peeked = 1; atomic_inc(&skb->users); } else - __skb_unlink(skb, &sk->sk_receive_queue); + __skb_unlink(skb, queue); } - spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); + spin_unlock_irqrestore(&queue->lock, cpu_flags); if (skb) return skb; -- GitLab From 3f518bf745cbd6007d8069100fb9cb09e960c872 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Feb 2012 07:30:58 +0000 Subject: [PATCH 0932/1846] datagram: Add offset argument to __skb_recv_datagram This one is only considered for MSG_PEEK flag and the value pointed by it specifies where to start peeking bytes from. If the offset happens to point into the middle of the returned skb, the offset within this skb is put back to this very argument. Signed-off-by: Pavel Emelyanov Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/skbuff.h | 2 +- net/core/datagram.c | 21 +++++++++++++-------- net/ipv4/udp.c | 4 ++-- net/ipv6/udp.c | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 2b7317ff297f..f3cf43de3c2a 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2046,7 +2046,7 @@ static inline void skb_frag_add_head(struct sk_buff *skb, struct sk_buff *frag) for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next) extern struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, - int *peeked, int *err); + int *peeked, int *off, int *err); extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock, int *err); extern unsigned int datagram_poll(struct file *file, struct socket *sock, diff --git a/net/core/datagram.c b/net/core/datagram.c index 6f54d0a17f8e..d3cf12f62c8f 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -132,6 +132,8 @@ static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) * __skb_recv_datagram - Receive a datagram skbuff * @sk: socket * @flags: MSG_ flags + * @off: an offset in bytes to peek skb from. Returns an offset + * within an skb where data actually starts * @peeked: returns non-zero if this packet has been seen before * @err: error code returned * @@ -158,7 +160,7 @@ static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) * the standard around please. */ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, - int *peeked, int *err) + int *peeked, int *off, int *err) { struct sk_buff *skb; long timeo; @@ -183,19 +185,22 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, struct sk_buff_head *queue = &sk->sk_receive_queue; spin_lock_irqsave(&queue->lock, cpu_flags); - skb = skb_peek(queue); - if (skb) { + skb_queue_walk(queue, skb) { *peeked = skb->peeked; if (flags & MSG_PEEK) { + if (*off >= skb->len) { + *off -= skb->len; + continue; + } skb->peeked = 1; atomic_inc(&skb->users); } else __skb_unlink(skb, queue); - } - spin_unlock_irqrestore(&queue->lock, cpu_flags); - if (skb) + spin_unlock_irqrestore(&queue->lock, cpu_flags); return skb; + } + spin_unlock_irqrestore(&queue->lock, cpu_flags); /* User doesn't want to wait */ error = -EAGAIN; @@ -215,10 +220,10 @@ EXPORT_SYMBOL(__skb_recv_datagram); struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock, int *err) { - int peeked; + int peeked, off = 0; return __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), - &peeked, err); + &peeked, &off, err); } EXPORT_SYMBOL(skb_recv_datagram); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index cd99f1a0f59f..7c41ab84e72e 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1167,7 +1167,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; struct sk_buff *skb; unsigned int ulen, copied; - int peeked; + int peeked, off = 0; int err; int is_udplite = IS_UDPLITE(sk); bool slow; @@ -1183,7 +1183,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, try_again: skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), - &peeked, &err); + &peeked, &off, &err); if (!skb) goto out; diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 8aebf8f90436..37b0699e95e5 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -342,7 +342,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct inet_sock *inet = inet_sk(sk); struct sk_buff *skb; unsigned int ulen, copied; - int peeked; + int peeked, off = 0; int err; int is_udplite = IS_UDPLITE(sk); int is_udp4; @@ -359,7 +359,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, try_again: skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), - &peeked, &err); + &peeked, &off, &err); if (!skb) goto out; -- GitLab From da5ef6e51b327b41180b5d1000c06e8d3595a936 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Feb 2012 07:31:18 +0000 Subject: [PATCH 0933/1846] skb: Add skb_peek_next helper Signed-off-by: Pavel Emelyanov Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/skbuff.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f3cf43de3c2a..c11a44ea1bf4 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -876,6 +876,24 @@ static inline struct sk_buff *skb_peek(const struct sk_buff_head *list_) return list; } +/** + * skb_peek_next - peek skb following the given one from a queue + * @skb: skb to start from + * @list_: list to peek at + * + * Returns %NULL when the end of the list is met or a pointer to the + * next element. The reference count is not incremented and the + * reference is therefore volatile. Use with caution. + */ +static inline struct sk_buff *skb_peek_next(struct sk_buff *skb, + const struct sk_buff_head *list_) +{ + struct sk_buff *next = skb->next; + if (next == (struct sk_buff *)list_) + next = NULL; + return next; +} + /** * skb_peek_tail - peek at the tail of an &sk_buff_head * @list_: list to peek at -- GitLab From ef64a54f6e558155b4f149bb10666b9e914b6c54 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Feb 2012 07:31:34 +0000 Subject: [PATCH 0934/1846] sock: Introduce the SO_PEEK_OFF sock option This one specifies where to start MSG_PEEK-ing queue data from. When set to negative value means that MSG_PEEK works as ususally -- peeks from the head of the queue always. When some bytes are peeked from queue and the peeking offset is non negative it is moved forward so that the next peek will return next portion of data. When non-peeking recvmsg occurs and the peeking offset is non negative is is moved backward so that the next peek will still peek the proper data (i.e. the one that would have been picked if there were no non peeking recv in between). The offset is set using per-proto opteration to let the protocol handle the locking issues and to check whether the peeking offset feature is supported by the protocol the socket belongs to. Signed-off-by: Pavel Emelyanov Signed-off-by: David S. Miller --- arch/alpha/include/asm/socket.h | 1 + arch/arm/include/asm/socket.h | 1 + arch/avr32/include/asm/socket.h | 1 + arch/cris/include/asm/socket.h | 1 + arch/frv/include/asm/socket.h | 1 + arch/h8300/include/asm/socket.h | 1 + arch/ia64/include/asm/socket.h | 1 + arch/m32r/include/asm/socket.h | 1 + arch/m68k/include/asm/socket.h | 1 + arch/mips/include/asm/socket.h | 1 + arch/mn10300/include/asm/socket.h | 1 + arch/parisc/include/asm/socket.h | 1 + arch/powerpc/include/asm/socket.h | 1 + arch/s390/include/asm/socket.h | 1 + arch/sparc/include/asm/socket.h | 1 + arch/xtensa/include/asm/socket.h | 1 + include/asm-generic/socket.h | 1 + include/linux/net.h | 1 + include/net/sock.h | 25 +++++++++++++++++++++++++ net/core/sock.c | 13 +++++++++++++ 20 files changed, 56 insertions(+) diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h index 082355f159e6..16449d330dae 100644 --- a/arch/alpha/include/asm/socket.h +++ b/arch/alpha/include/asm/socket.h @@ -71,6 +71,7 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. diff --git a/arch/arm/include/asm/socket.h b/arch/arm/include/asm/socket.h index dec6f9afb3cf..d958c74e5260 100644 --- a/arch/arm/include/asm/socket.h +++ b/arch/arm/include/asm/socket.h @@ -64,5 +64,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/avr32/include/asm/socket.h b/arch/avr32/include/asm/socket.h index 247b88c760be..30078f98b3ab 100644 --- a/arch/avr32/include/asm/socket.h +++ b/arch/avr32/include/asm/socket.h @@ -64,5 +64,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* __ASM_AVR32_SOCKET_H */ diff --git a/arch/cris/include/asm/socket.h b/arch/cris/include/asm/socket.h index e269264df7c4..048aba64600c 100644 --- a/arch/cris/include/asm/socket.h +++ b/arch/cris/include/asm/socket.h @@ -66,6 +66,7 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/frv/include/asm/socket.h b/arch/frv/include/asm/socket.h index ce80fdadcce5..7a361810f3cc 100644 --- a/arch/frv/include/asm/socket.h +++ b/arch/frv/include/asm/socket.h @@ -64,6 +64,7 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/h8300/include/asm/socket.h b/arch/h8300/include/asm/socket.h index cf1daab6f27e..e7bbfcee5b99 100644 --- a/arch/h8300/include/asm/socket.h +++ b/arch/h8300/include/asm/socket.h @@ -64,5 +64,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/ia64/include/asm/socket.h b/arch/ia64/include/asm/socket.h index 4b03664e3fb5..ced62de9d5a9 100644 --- a/arch/ia64/include/asm/socket.h +++ b/arch/ia64/include/asm/socket.h @@ -73,5 +73,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_IA64_SOCKET_H */ diff --git a/arch/m32r/include/asm/socket.h b/arch/m32r/include/asm/socket.h index e8b8c5bb053c..696cb4c7ca4e 100644 --- a/arch/m32r/include/asm/socket.h +++ b/arch/m32r/include/asm/socket.h @@ -64,5 +64,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_M32R_SOCKET_H */ diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/asm/socket.h index d4708ce466e0..e8b41a6775f9 100644 --- a/arch/m68k/include/asm/socket.h +++ b/arch/m68k/include/asm/socket.h @@ -64,5 +64,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/mips/include/asm/socket.h b/arch/mips/include/asm/socket.h index ad5c0a7a02a7..52104872e9e3 100644 --- a/arch/mips/include/asm/socket.h +++ b/arch/mips/include/asm/socket.h @@ -84,6 +84,7 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #ifdef __KERNEL__ diff --git a/arch/mn10300/include/asm/socket.h b/arch/mn10300/include/asm/socket.h index 876356d78522..013fcc51698f 100644 --- a/arch/mn10300/include/asm/socket.h +++ b/arch/mn10300/include/asm/socket.h @@ -64,5 +64,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h index d28c51b61067..f717c9bec16f 100644 --- a/arch/parisc/include/asm/socket.h +++ b/arch/parisc/include/asm/socket.h @@ -63,6 +63,7 @@ #define SO_WIFI_STATUS 0x4022 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 0x4023 /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. diff --git a/arch/powerpc/include/asm/socket.h b/arch/powerpc/include/asm/socket.h index 2fc2af8fbf59..fe1c0b478fd7 100644 --- a/arch/powerpc/include/asm/socket.h +++ b/arch/powerpc/include/asm/socket.h @@ -71,5 +71,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_POWERPC_SOCKET_H */ diff --git a/arch/s390/include/asm/socket.h b/arch/s390/include/asm/socket.h index 67b5c1b14b51..581702fa1b0c 100644 --- a/arch/s390/include/asm/socket.h +++ b/arch/s390/include/asm/socket.h @@ -72,5 +72,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _ASM_SOCKET_H */ diff --git a/arch/sparc/include/asm/socket.h b/arch/sparc/include/asm/socket.h index 8af1b64168b3..68e2e2746f6f 100644 --- a/arch/sparc/include/asm/socket.h +++ b/arch/sparc/include/asm/socket.h @@ -60,6 +60,7 @@ #define SO_WIFI_STATUS 0x0025 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 0x0026 /* Security levels - as per NRL IPv6 - don't actually do anything */ #define SO_SECURITY_AUTHENTICATION 0x5001 diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/asm/socket.h index bb06968be227..74818b161362 100644 --- a/arch/xtensa/include/asm/socket.h +++ b/arch/xtensa/include/asm/socket.h @@ -75,5 +75,6 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* _XTENSA_SOCKET_H */ diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h index 49c1704173e7..d9aaac0c36d4 100644 --- a/include/asm-generic/socket.h +++ b/include/asm-generic/socket.h @@ -67,4 +67,5 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 #endif /* __ASM_GENERIC_SOCKET_H */ diff --git a/include/linux/net.h b/include/linux/net.h index b29923006b11..be60c7f5e145 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -206,6 +206,7 @@ struct proto_ops { int offset, size_t size, int flags); ssize_t (*splice_read)(struct socket *sock, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); + void (*set_peek_off)(struct sock *sk, int val); }; #define DECLARE_SOCKADDR(type, dst, src) \ diff --git a/include/net/sock.h b/include/net/sock.h index 91c1c8baf020..9c0553b9e451 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -357,6 +357,7 @@ struct sock { struct page *sk_sndmsg_page; struct sk_buff *sk_send_head; __u32 sk_sndmsg_off; + __s32 sk_peek_off; int sk_write_pending; #ifdef CONFIG_SECURITY void *sk_security; @@ -373,6 +374,30 @@ struct sock { void (*sk_destruct)(struct sock *sk); }; +static inline int sk_peek_offset(struct sock *sk, int flags) +{ + if ((flags & MSG_PEEK) && (sk->sk_peek_off >= 0)) + return sk->sk_peek_off; + else + return 0; +} + +static inline void sk_peek_offset_bwd(struct sock *sk, int val) +{ + if (sk->sk_peek_off >= 0) { + if (sk->sk_peek_off >= val) + sk->sk_peek_off -= val; + else + sk->sk_peek_off = 0; + } +} + +static inline void sk_peek_offset_fwd(struct sock *sk, int val) +{ + if (sk->sk_peek_off >= 0) + sk->sk_peek_off += val; +} + /* * Hashed lists helper routines */ diff --git a/net/core/sock.c b/net/core/sock.c index 02f8dfe320b7..19942d4bb6e6 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -793,6 +793,12 @@ int sock_setsockopt(struct socket *sock, int level, int optname, sock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool); break; + case SO_PEEK_OFF: + if (sock->ops->set_peek_off) + sock->ops->set_peek_off(sk, val); + else + ret = -EOPNOTSUPP; + break; default: ret = -ENOPROTOOPT; break; @@ -1018,6 +1024,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname, v.val = !!sock_flag(sk, SOCK_WIFI_STATUS); break; + case SO_PEEK_OFF: + if (!sock->ops->set_peek_off) + return -EOPNOTSUPP; + + v.val = sk->sk_peek_off; + break; default: return -ENOPROTOOPT; } @@ -2092,6 +2104,7 @@ void sock_init_data(struct socket *sock, struct sock *sk) sk->sk_sndmsg_page = NULL; sk->sk_sndmsg_off = 0; + sk->sk_peek_off = -1; sk->sk_peer_pid = NULL; sk->sk_peer_cred = NULL; -- GitLab From f55bb7f9cb82dec2f2e803d7bd0fc5929248e4d8 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Feb 2012 07:31:51 +0000 Subject: [PATCH 0935/1846] unix: Support peeking offset for datagram and seqpacket sockets The sk_peek_off manipulations are protected with the unix_sk->readlock mutex. This mutex is enough since all we need is to syncronize setting the offset vs reading the queue head. The latter is fully covered with the mentioned lock. The recently added __skb_recv_datagram's offset is used to pick the skb to read the data from. Signed-off-by: Pavel Emelyanov Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- net/unix/af_unix.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 85d3bb7490aa..3d9481de031f 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -530,6 +530,16 @@ static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *, static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, struct msghdr *, size_t, int); +static void unix_set_peek_off(struct sock *sk, int val) +{ + struct unix_sock *u = unix_sk(sk); + + mutex_lock(&u->readlock); + sk->sk_peek_off = val; + mutex_unlock(&u->readlock); +} + + static const struct proto_ops unix_stream_ops = { .family = PF_UNIX, .owner = THIS_MODULE, @@ -570,6 +580,7 @@ static const struct proto_ops unix_dgram_ops = { .recvmsg = unix_dgram_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, + .set_peek_off = unix_set_peek_off, }; static const struct proto_ops unix_seqpacket_ops = { @@ -591,6 +602,7 @@ static const struct proto_ops unix_seqpacket_ops = { .recvmsg = unix_seqpacket_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, + .set_peek_off = unix_set_peek_off, }; static struct proto unix_proto = { @@ -1756,6 +1768,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, int noblock = flags & MSG_DONTWAIT; struct sk_buff *skb; int err; + int peeked, skip; err = -EOPNOTSUPP; if (flags&MSG_OOB) @@ -1769,7 +1782,9 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, goto out; } - skb = skb_recv_datagram(sk, flags, noblock, &err); + skip = sk_peek_offset(sk, flags); + + skb = __skb_recv_datagram(sk, flags, &peeked, &skip, &err); if (!skb) { unix_state_lock(sk); /* Signal EOF on disconnected non-blocking SEQPACKET socket. */ @@ -1786,12 +1801,12 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, if (msg->msg_name) unix_copy_addr(msg, skb->sk); - if (size > skb->len) - size = skb->len; - else if (size < skb->len) + if (size > skb->len - skip) + size = skb->len - skip; + else if (size < skb->len - skip) msg->msg_flags |= MSG_TRUNC; - err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, size); + err = skb_copy_datagram_iovec(skb, skip, msg->msg_iov, size); if (err) goto out_free; @@ -1808,6 +1823,8 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, if (!(flags & MSG_PEEK)) { if (UNIXCB(skb).fp) unix_detach_fds(siocb->scm, skb); + + sk_peek_offset_bwd(sk, skb->len); } else { /* It is questionable: on PEEK we could: - do not return fds - good, but too simple 8) @@ -1821,6 +1838,9 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, clearly however! */ + + sk_peek_offset_fwd(sk, size); + if (UNIXCB(skb).fp) siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp); } -- GitLab From fc0d753641f7b919c7273d9bd21ae6ab45e757f3 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 21 Feb 2012 07:32:06 +0000 Subject: [PATCH 0936/1846] unix: Support peeking offset for stream sockets The same here -- we can protect the sk_peek_off manipulations with the unix_sk->readlock mutex. The peeking of data from a stream socket is done in the datagram style, i.e. even if there's enough room for more data in the user buffer, only the head skb's data is copied in there. This feature is preserved when peeking data from a given offset -- the data is read till the nearest skb's boundary. Signed-off-by: Pavel Emelyanov Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- net/unix/af_unix.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 3d9481de031f..0be4d24f6ae8 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -559,6 +559,7 @@ static const struct proto_ops unix_stream_ops = { .recvmsg = unix_stream_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, + .set_peek_off = unix_set_peek_off, }; static const struct proto_ops unix_dgram_ops = { @@ -1904,6 +1905,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, int target; int err = 0; long timeo; + int skip; err = -EINVAL; if (sk->sk_state != TCP_ESTABLISHED) @@ -1933,12 +1935,15 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, goto out; } + skip = sk_peek_offset(sk, flags); + do { int chunk; struct sk_buff *skb; unix_state_lock(sk); skb = skb_peek(&sk->sk_receive_queue); +again: if (skb == NULL) { unix_sk(sk)->recursion_level = 0; if (copied >= target) @@ -1973,6 +1978,13 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, unix_state_unlock(sk); break; } + + if (skip >= skb->len) { + skip -= skb->len; + skb = skb_peek_next(skb, &sk->sk_receive_queue); + goto again; + } + unix_state_unlock(sk); if (check_creds) { @@ -1992,8 +2004,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, sunaddr = NULL; } - chunk = min_t(unsigned int, skb->len, size); - if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) { + chunk = min_t(unsigned int, skb->len - skip, size); + if (memcpy_toiovec(msg->msg_iov, skb->data + skip, chunk)) { if (copied == 0) copied = -EFAULT; break; @@ -2005,6 +2017,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, if (!(flags & MSG_PEEK)) { skb_pull(skb, chunk); + sk_peek_offset_bwd(sk, chunk); + if (UNIXCB(skb).fp) unix_detach_fds(siocb->scm, skb); @@ -2022,6 +2036,8 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, if (UNIXCB(skb).fp) siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp); + sk_peek_offset_fwd(sk, chunk); + break; } } while (size); -- GitLab From f274fd9a0384c448335dcc51b04c4c41caa7f432 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Wed, 22 Feb 2012 03:06:54 +0000 Subject: [PATCH 0937/1846] tg3: remove IRQF_SAMPLE_RANDOM flag This driver is the last user of the IRQF_SAMPLE_RANDOM flag for net drivers, and since add_*_randomness interfaces have now deprecated the flag as a source of external noise, we can remove it. Signed-off-by: Davidlohr Bueso Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index d604664fdb42..27dafd928279 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -9682,7 +9682,7 @@ static int tg3_test_interrupt(struct tg3 *tp) } err = request_irq(tnapi->irq_vec, tg3_test_isr, - IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, tnapi); + IRQF_SHARED, dev->name, tnapi); if (err) return err; -- GitLab From b049aadca3f2535bea245cb0bba1393d9a60c7a4 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 22 Feb 2012 02:36:38 +0000 Subject: [PATCH 0938/1846] 3com/typhoon: reuse eth_mac_addr() Use eth_mac_addr() for .ndo_set_mac_address, remove typhoon_set_mac_address() since it do currently the same as eth_mac_addr(). Additional advantage: eth_mac_addr() already checks if the given address is valid. Signed-off-by: Danny Kukawka Acked-by: Dave Dillow Signed-off-by: David S. Miller --- drivers/net/ethernet/3com/typhoon.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c index f7d622eed203..1234a14b2b73 100644 --- a/drivers/net/ethernet/3com/typhoon.c +++ b/drivers/net/ethernet/3com/typhoon.c @@ -966,18 +966,6 @@ typhoon_get_stats(struct net_device *dev) return stats; } -static int -typhoon_set_mac_address(struct net_device *dev, void *addr) -{ - struct sockaddr *saddr = (struct sockaddr *) addr; - - if(netif_running(dev)) - return -EBUSY; - - memcpy(dev->dev_addr, saddr->sa_data, dev->addr_len); - return 0; -} - static void typhoon_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { @@ -2266,7 +2254,7 @@ static const struct net_device_ops typhoon_netdev_ops = { .ndo_tx_timeout = typhoon_tx_timeout, .ndo_get_stats = typhoon_get_stats, .ndo_validate_addr = eth_validate_addr, - .ndo_set_mac_address = typhoon_set_mac_address, + .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = eth_change_mtu, }; -- GitLab From cdf49c283e2e105da86ca575ad35b453f5ff24ea Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 22 Feb 2012 02:36:39 +0000 Subject: [PATCH 0939/1846] net/ieee802154/6lowpan.c: reuse eth_mac_addr() Use eth_mac_addr() for .ndo_set_mac_address, remove lowpan_set_address since it do currently the same as eth_mac_addr(). Additional advantage: eth_mac_addr() already checks if the given address is valid Signed-off-by: Danny Kukawka Acked-by: Dmitry Eremin-Solenikov Signed-off-by: David S. Miller --- net/ieee802154/6lowpan.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index e4ecc1eef98c..368515885368 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -924,19 +925,6 @@ lowpan_process_data(struct sk_buff *skb) return -EINVAL; } -static int lowpan_set_address(struct net_device *dev, void *p) -{ - struct sockaddr *sa = p; - - if (netif_running(dev)) - return -EBUSY; - - /* TODO: validate addr */ - memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); - - return 0; -} - static int lowpan_get_mac_header_length(struct sk_buff *skb) { /* @@ -1062,7 +1050,7 @@ static struct header_ops lowpan_header_ops = { static const struct net_device_ops lowpan_netdev_ops = { .ndo_start_xmit = lowpan_xmit, - .ndo_set_mac_address = lowpan_set_address, + .ndo_set_mac_address = eth_mac_addr, }; static void lowpan_setup(struct net_device *dev) -- GitLab From 9f6f9af7694ede6314bed281eec74d588ba9474f Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 21 Feb 2012 23:24:55 +0000 Subject: [PATCH 0940/1846] af_unix: MSG_TRUNC support for dgram sockets Piergiorgio Beruto expressed the need to fetch size of first datagram in queue for AF_UNIX sockets and suggested a patch against SIOCINQ ioctl. I suggested instead to implement MSG_TRUNC support as a recv() input flag, as already done for RAW, UDP & NETLINK sockets. len = recv(fd, &byte, 1, MSG_PEEK | MSG_TRUNC); MSG_TRUNC asks recv() to return the real length of the packet, even when is was longer than the passed buffer. There is risk that a userland application used MSG_TRUNC by accident (since it had no effect on af_unix sockets) and this might break after this patch. Signed-off-by: Eric Dumazet Tested-by: Piergiorgio Beruto CC: Michael Kerrisk Signed-off-by: David S. Miller --- net/unix/af_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 0be4d24f6ae8..8ee85aa79fa7 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1845,7 +1845,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, if (UNIXCB(skb).fp) siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp); } - err = size; + err = (flags & MSG_TRUNC) ? skb->len - skip : size; scm_recv(sock, msg, siocb->scm, flags); -- GitLab From 2bd02d9aace88ea6aaf7361ad1cd2c4f9ea8a269 Mon Sep 17 00:00:00 2001 From: "Devendra.Naga" Date: Tue, 31 Jan 2012 02:11:03 -0500 Subject: [PATCH 0941/1846] rtlwifi/rtl8192c: in _rtl92c_phy_calculate_bit_shift remove comparing bitmask against 1 in _rtl92c_phy_calculate_bit_shift everytime the right shifted bitmask is AND with 1 and compared against 1. i.e. if ((bitmask >> i) & 0x1 == 1) break; which in the if condition is anyway becomes a 1 or 0. Signed-off-by: Devendra.Naga Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index 22e998dd2f32..a76b22387e3d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -177,7 +177,7 @@ u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask) u32 i; for (i = 0; i <= 31; i++) { - if (((bitmask >> i) & 0x1) == 1) + if ((bitmask >> i) & 0x1) break; } return i; -- GitLab From 6adaea3062b66852e951c65139feb47d1953bd7e Mon Sep 17 00:00:00 2001 From: John Li Date: Wed, 8 Feb 2012 21:19:01 +0800 Subject: [PATCH 0942/1846] rt2x00:Fix typo Signed-off-by: John Li Acked-by: Helmut Schaa Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig index a0a7854facc0..299c3879582d 100644 --- a/drivers/net/wireless/rt2x00/Kconfig +++ b/drivers/net/wireless/rt2x00/Kconfig @@ -163,7 +163,7 @@ config RT2800USB_RT53XX depends on EXPERIMENTAL ---help--- This adds support for rt53xx wireless chipset family to the - rt2800pci driver. + rt2800usb driver. Supported chips: RT5370 config RT2800USB_UNKNOWN -- GitLab From b6df7f1d3b0513529c496b7ef70f0f14b5177407 Mon Sep 17 00:00:00 2001 From: John Li Date: Wed, 8 Feb 2012 21:25:24 +0800 Subject: [PATCH 0943/1846] rt2x00:Add debug message for new chipset Signed-off-by: John Li Acked-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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 772d4aec303a..f1df929e97a7 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -4053,7 +4053,7 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) case RT5390: break; default: - ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); + ERROR(rt2x00dev, "Invalid RT chipset 0x%04x detected.\n", rt2x00dev->chip.rt); return -ENODEV; } @@ -4072,7 +4072,7 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) case RF5390: break; default: - ERROR(rt2x00dev, "Invalid RF chipset 0x%x detected.\n", + ERROR(rt2x00dev, "Invalid RF chipset 0x%04x detected.\n", rt2x00dev->chip.rf); return -ENODEV; } -- GitLab From 02b6ab0ab936b058632cf0cfdf226778a1005882 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 8 Feb 2012 20:56:52 -0600 Subject: [PATCH 0944/1846] rtlwifi: rtl8192c-common: rtl8192se: rtl8192de: Simplify if statements Devendra Naga submitted a patch for rtl8192c_common to change the tests in _rtl92c_store_pwrIndex_diffrate_offset(). This patch improves on those changes and applies similar modifications to drivers rtl8192se and rtl8192de. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- .../wireless/rtlwifi/rtl8192c/phy_common.c | 154 ++++----------- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 187 ++++-------------- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 40 ++-- 3 files changed, 104 insertions(+), 277 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index a76b22387e3d..cdd71f5e77ac 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -253,121 +253,51 @@ void _rtl92c_store_pwrIndex_diffrate_offset(struct ieee80211_hw *hw, { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &(rtlpriv->phy); + int index; + + if (regaddr == RTXAGC_A_RATE18_06) + index = 0; + else if (regaddr == RTXAGC_A_RATE54_24) + index = 1; + else if (regaddr == RTXAGC_A_CCK1_MCS32) + index = 6; + else if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) + index = 7; + else if (regaddr == RTXAGC_A_MCS03_MCS00) + index = 2; + else if (regaddr == RTXAGC_A_MCS07_MCS04) + index = 3; + else if (regaddr == RTXAGC_A_MCS11_MCS08) + index = 4; + else if (regaddr == RTXAGC_A_MCS15_MCS12) + index = 5; + else if (regaddr == RTXAGC_B_RATE18_06) + index = 8; + else if (regaddr == RTXAGC_B_RATE54_24) + index = 9; + else if (regaddr == RTXAGC_B_CCK1_55_MCS32) + index = 14; + else if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) + index = 15; + else if (regaddr == RTXAGC_B_MCS03_MCS00) + index = 10; + else if (regaddr == RTXAGC_B_MCS07_MCS04) + index = 11; + else if (regaddr == RTXAGC_B_MCS11_MCS08) + index = 12; + else if (regaddr == RTXAGC_B_MCS15_MCS12) + index = 13; + else + return; - if (regaddr == RTXAGC_A_RATE18_06) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0]); - } - if (regaddr == RTXAGC_A_RATE54_24) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][1] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1]); - } - if (regaddr == RTXAGC_A_CCK1_MCS32) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][6] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6]); - } - if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][7] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7]); - } - if (regaddr == RTXAGC_A_MCS03_MCS00) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][2] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2]); - } - if (regaddr == RTXAGC_A_MCS07_MCS04) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][3] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3]); - } - if (regaddr == RTXAGC_A_MCS11_MCS08) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][4] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4]); - } - if (regaddr == RTXAGC_A_MCS15_MCS12) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][5] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5]); - } - if (regaddr == RTXAGC_B_RATE18_06) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][8] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8]); - } - if (regaddr == RTXAGC_B_RATE54_24) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][9] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9]); - } - if (regaddr == RTXAGC_B_CCK1_55_MCS32) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][14] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14]); - } - if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][15] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15]); - } - if (regaddr == RTXAGC_B_MCS03_MCS00) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][10] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10]); - } - if (regaddr == RTXAGC_B_MCS07_MCS04) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][11] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11]); - } - if (regaddr == RTXAGC_B_MCS11_MCS08) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][12] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12]); - } - if (regaddr == RTXAGC_B_MCS15_MCS12) { - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13] = data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][13] = 0x%x\n", - rtlphy->pwrgroup_cnt, - rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13]); + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][index] = data; + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, + "MCSTxPowerLevelOriginalOffset[%d][%d] = 0x%x\n", + rtlphy->pwrgroup_cnt, index, + rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][index]); + if (index == 13) rtlphy->pwrgroup_cnt++; - } } EXPORT_SYMBOL(_rtl92c_store_pwrIndex_diffrate_offset); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index 9581a19c2548..96dc71746eaa 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -665,152 +665,51 @@ static void _rtl92d_store_pwrindex_diffrate_offset(struct ieee80211_hw *hw, { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &(rtlpriv->phy); + int index; + + if (regaddr == RTXAGC_A_RATE18_06) + index = 0; + else if (regaddr == RTXAGC_A_RATE54_24) + index = 1; + else if (regaddr == RTXAGC_A_CCK1_MCS32) + index = 6; + else if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) + index = 7; + else if (regaddr == RTXAGC_A_MCS03_MCS00) + index = 2; + else if (regaddr == RTXAGC_A_MCS07_MCS04) + index = 3; + else if (regaddr == RTXAGC_A_MCS11_MCS08) + index = 4; + else if (regaddr == RTXAGC_A_MCS15_MCS12) + index = 5; + else if (regaddr == RTXAGC_B_RATE18_06) + index = 8; + else if (regaddr == RTXAGC_B_RATE54_24) + index = 9; + else if (regaddr == RTXAGC_B_CCK1_55_MCS32) + index = 14; + else if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) + index = 15; + else if (regaddr == RTXAGC_B_MCS03_MCS00) + index = 10; + else if (regaddr == RTXAGC_B_MCS07_MCS04) + index = 11; + else if (regaddr == RTXAGC_B_MCS11_MCS08) + index = 12; + else if (regaddr == RTXAGC_B_MCS15_MCS12) + index = 13; + else + return; - if (regaddr == RTXAGC_A_RATE18_06) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][0] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][0]); - } - if (regaddr == RTXAGC_A_RATE54_24) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][1] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][1]); - } - if (regaddr == RTXAGC_A_CCK1_MCS32) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][6] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][6]); - } - if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][7] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][7] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][7]); - } - if (regaddr == RTXAGC_A_MCS03_MCS00) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][2] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][2]); - } - if (regaddr == RTXAGC_A_MCS07_MCS04) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][3] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][3]); - } - if (regaddr == RTXAGC_A_MCS11_MCS08) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][4] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][4]); - } - if (regaddr == RTXAGC_A_MCS15_MCS12) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][5] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][5]); - } - if (regaddr == RTXAGC_B_RATE18_06) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][8] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][8] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][8]); - } - if (regaddr == RTXAGC_B_RATE54_24) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][9] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][9] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][9]); - } - if (regaddr == RTXAGC_B_CCK1_55_MCS32) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][14] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][14] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][14]); - } - if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][15] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][15] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][15]); - } - if (regaddr == RTXAGC_B_MCS03_MCS00) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][10] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][10] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][10]); - } - if (regaddr == RTXAGC_B_MCS07_MCS04) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][11] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][11] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][11]); - } - if (regaddr == RTXAGC_B_MCS11_MCS08) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][12] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][12] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][12]); - } - if (regaddr == RTXAGC_B_MCS15_MCS12) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][13] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "MCSTxPowerLevelOriginalOffset[%d][13] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][13]); + rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][index] = data; + RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, + "MCSTxPowerLevelOriginalOffset[%d][%d] = 0x%ulx\n", + rtlphy->pwrgroup_cnt, index, + rtlphy->mcs_txpwrlevel_origoffset + [rtlphy->pwrgroup_cnt][index]); + if (index == 13) rtlphy->pwrgroup_cnt++; - } } static bool _rtl92d_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index 05b4e2790e99..6d5bbd0e4d38 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -678,30 +678,28 @@ static void _rtl92s_store_pwrindex_diffrate_offset(struct ieee80211_hw *hw, { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &(rtlpriv->phy); + int index; if (reg_addr == RTXAGC_RATE18_06) - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] = - data; - if (reg_addr == RTXAGC_RATE54_24) - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] = - data; - if (reg_addr == RTXAGC_CCK_MCS32) - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] = - data; - if (reg_addr == RTXAGC_MCS03_MCS00) - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] = - data; - if (reg_addr == RTXAGC_MCS07_MCS04) - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] = - data; - if (reg_addr == RTXAGC_MCS11_MCS08) - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] = - data; - if (reg_addr == RTXAGC_MCS15_MCS12) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] = - data; + index = 0; + else if (reg_addr == RTXAGC_RATE54_24) + index = 1; + else if (reg_addr == RTXAGC_CCK_MCS32) + index = 6; + else if (reg_addr == RTXAGC_MCS03_MCS00) + index = 2; + else if (reg_addr == RTXAGC_MCS07_MCS04) + index = 3; + else if (reg_addr == RTXAGC_MCS11_MCS08) + index = 4; + else if (reg_addr == RTXAGC_MCS15_MCS12) + index = 5; + else + return; + + rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][index] = data; + if (index == 5) rtlphy->pwrgroup_cnt++; - } } static void _rtl92s_phy_init_register_definition(struct ieee80211_hw *hw) -- GitLab From e1fa746029252c85b18b3d6ee5b0e066ce14383f Mon Sep 17 00:00:00 2001 From: Tristan Pourcelot Date: Thu, 9 Feb 2012 14:48:09 +0100 Subject: [PATCH 0945/1846] Correcting typos in rtlwifi/base.c This patch correct some typos in a comment. Signed-off-by: Tristan Pourcelot Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index df5655cc55c0..510023554e5f 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -39,10 +39,10 @@ #include /* - *NOTICE!!!: This file will be very big, we hsould - *keep it clear under follwing roles: + *NOTICE!!!: This file will be very big, we should + *keep it clear under following roles: * - *This file include follwing part, so, if you add new + *This file include following parts, so, if you add new *functions into this file, please check which part it *should includes. or check if you should add new part *for this file: -- GitLab From 14433f4df21b2ab8287084d8348bede6bf813a90 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:08:55 +0100 Subject: [PATCH 0946/1846] brcm80211: update the maintainers listed for brcm80211 drivers Henry Ptasinski is not working on the brcm80211 driver so taking his name/email out of the MAINTAINERS file. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 48418c8475f0..0b92435d9f51 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1575,7 +1575,6 @@ F: drivers/net/ethernet/broadcom/tg3.* BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER M: Brett Rudley -M: Henry Ptasinski M: Roland Vossen M: Arend van Spriel M: Franky (Zhenhui) Lin -- GitLab From 1570e53c14ff21ec5e23c1a7fe814c09aa950dbc Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:08:56 +0100 Subject: [PATCH 0947/1846] brcm80211: smac: fix unintended fallthru in wlc_phy_radio_init_2057() The radio initialization for 2057 rev 5 was using the incorrect register table for the initialization. This patch fixes that. Reported-by: Larry Finger Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index ec7450d2fbd6..c27ec7a9af21 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -19989,12 +19989,11 @@ static void wlc_phy_radio_init_2057(struct brcms_phy *pi) switch (pi->pubpi.radiorev) { case 5: - if (pi->pubpi.radiover == 0x0) + if (NREV_IS(pi->pubpi.phy_rev, 8)) regs_2057_ptr = regs_2057_rev5; - else if (pi->pubpi.radiover == 0x1) + else if (NREV_IS(pi->pubpi.phy_rev, 9)) regs_2057_ptr = regs_2057_rev5v1; - else - break; + break; case 7: -- GitLab From 01343537e6da3398ecea205ff1d579e4dc226b93 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:08:57 +0100 Subject: [PATCH 0948/1846] brcm80211: smac: remove redundant assignments from txpwrctrl_pwr_setup_nphy The function wlc_phy_txpwrctrl_pwr_setup_nphy() does assign a local variable target_pwr_qtrdbm in several code paths, but in the end all code paths are coming to an assignment of that variable which does override all previous. So those early and redundant assignments have been removed. Reported-by: Larry Finger Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../wireless/brcm80211/brcmsmac/phy/phy_n.c | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index c27ec7a9af21..9595ecd38c1f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -17824,8 +17824,6 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) if (pi->sh->sromrev < 4) { idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = 13 * 4; - target_pwr_qtrdbm[1] = 13 * 4; a1[0] = -424; a1[1] = -424; b0[0] = 5612; @@ -17839,10 +17837,6 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) case WL_CHAN_FREQ_RANGE_2G: idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_2g; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_2g; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_2g_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_2g_b0; @@ -17853,10 +17847,6 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) case WL_CHAN_FREQ_RANGE_5GL: idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gl; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gl; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0; @@ -17867,10 +17857,6 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) case WL_CHAN_FREQ_RANGE_5GM: idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gm; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gm; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gm_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gm_b0; @@ -17881,10 +17867,6 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) case WL_CHAN_FREQ_RANGE_5GH: idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_5g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_5g; - target_pwr_qtrdbm[0] = - pi->nphy_pwrctrl_info[0].max_pwr_5gh; - target_pwr_qtrdbm[1] = - pi->nphy_pwrctrl_info[1].max_pwr_5gh; a1[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1; a1[1] = pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1; b0[0] = pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0; @@ -17895,8 +17877,6 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) default: idle_tssi[0] = pi->nphy_pwrctrl_info[0].idle_tssi_2g; idle_tssi[1] = pi->nphy_pwrctrl_info[1].idle_tssi_2g; - target_pwr_qtrdbm[0] = 13 * 4; - target_pwr_qtrdbm[1] = 13 * 4; a1[0] = -424; a1[1] = -424; b0[0] = 5612; @@ -17907,6 +17887,7 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) } } + /* use the provided transmit power */ target_pwr_qtrdbm[0] = (s8) pi->tx_power_max; target_pwr_qtrdbm[1] = (s8) pi->tx_power_max; -- GitLab From 5e379203c7788b7af01150bfadbc74d2797a2ef4 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:08:58 +0100 Subject: [PATCH 0949/1846] brcm80211: smac: fix endless retry of A-MPDU transmissions The A-MPDU code checked against a retry limit, but it was using the wrong variable to do so. This patch fixes this to assure proper retry mechanism. This problem had a side-effect causing the mac80211 flush callback to remain waiting forever as well. That side effect has been fixed by commit by Stanislaw Gruszka: commit f96b08a7e6f69c0f0a576554df3df5b1b519c479 Date: Tue Jan 17 12:38:50 2012 +0100 brcmsmac: fix tx queue flush infinite loop Reference: https://bugzilla.kernel.org/show_bug.cgi?id=42576 Cc: Stanislaw Gruszka Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/ampdu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index d89dcb14cb6d..c1ce831b9bf4 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c @@ -1051,17 +1051,13 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, } /* either retransmit or send bar if ack not recd */ if (!ack_recd) { - struct ieee80211_tx_rate *txrate = - tx_info->status.rates; - if (retry && (txrate[0].count < (int)retry_limit)) { + if (retry && (ini->txretry[index] < (int)retry_limit)) { ini->txretry[index]++; ini->tx_in_transit--; /* * Use high prededence for retransmit to * give some punch */ - /* brcms_c_txq_enq(wlc, scb, p, - * BRCMS_PRIO_TO_PREC(tid)); */ brcms_c_txq_enq(wlc, scb, p, BRCMS_PRIO_TO_HI_PREC(tid)); } else { -- GitLab From 137dabed34a13f90e068327b98329331367c9b46 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:08:59 +0100 Subject: [PATCH 0950/1846] brcm80211: smac: remove smatch warnings from brcmsmac code The patch fixes following smatch warnings: main.c +2902 brcms_b_read_objmem(11) info: ignoring unreachable code. mac80211_if.c +1146 brcms_suspend(8) error: we previously assumed 'wl' could be null (see line 1145) srom.c +641 _initvars_srom_pci(16) error: potential null dereference 'entry'. (kzalloc returns null) Reported-by: Dan Carpenter Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 ++-- drivers/net/wireless/brcm80211/brcmsmac/main.c | 1 - drivers/net/wireless/brcm80211/brcmsmac/srom.c | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index c8427978d09e..fec0f10773e5 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1136,8 +1136,8 @@ static int brcms_suspend(struct bcma_device *pdev) hw = bcma_get_drvdata(pdev); wl = hw->priv; if (!wl) { - wiphy_err(wl->wiphy, - "brcms_suspend: bcma_get_drvdata failed\n"); + pr_err("%s: %s: no driver private struct!\n", KBUILD_MODNAME, + __func__); return -ENODEV; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index fb712cac9157..86186fa82946 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -2901,7 +2901,6 @@ brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) objoff += 2; return bcma_read16(core, objoff); -; } static void diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 563743643038..b96f4b9d74bd 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -621,7 +621,7 @@ static inline void cpu_to_le16_buf(u16 *buf, uint nwords) /* * convert binary srom data into linked list of srom variable items. */ -static void +static int _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) { struct brcms_srom_list_head *entry; @@ -638,6 +638,9 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) /* first store the srom revision */ entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); + if (!entry) + return -ENOMEM; + entry->varid = BRCMS_SROM_REV; entry->var_type = BRCMS_SROM_UNUMBER; entry->uval = sromrev; @@ -715,6 +718,8 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) entry = kzalloc(sizeof(struct brcms_srom_list_head) + extra_space, GFP_KERNEL); + if (!entry) + return -ENOMEM; entry->varid = id; entry->var_type = type; if (flags & SRFL_ETHADDR) { @@ -754,6 +759,8 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); + if (!entry) + return -ENOMEM; entry->varid = srv->varid+p; entry->var_type = BRCMS_SROM_UNUMBER; entry->uval = val; @@ -761,6 +768,7 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) } pb += psz; } + return 0; } /* @@ -906,7 +914,9 @@ int srom_var_init(struct si_pub *sih) INIT_LIST_HEAD(&sii->var_list); /* parse SROM into name=value pairs. */ - _initvars_srom_pci(sromrev, srom, &sii->var_list); + err = _initvars_srom_pci(sromrev, srom, &sii->var_list); + if (err) + srom_free_vars(sih); } errout: -- GitLab From 2315992c2a6f395dd3dfd4ba50a164d5f3ded84d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:00 +0100 Subject: [PATCH 0951/1846] brcm80211: fmac: resolve smatch issues in brcmfmac code This patch resolves the following smatch issues: wl_cfg80211.c +1377 brcmf_cfg80211_connect(65) warn: min_t truncates here '(sme->ssid_len)' (4294967295 vs 9223372036854775807) dhd_sdio.c +1275 brcmf_sdbrcm_rxglom(156) warn: min_t truncates here '(pfirst->len)' (2147483647 vs 4294967295) dhd_sdio.c +1457 brcmf_sdbrcm_rxglom(338) warn: min_t truncates here '(pfirst->len)' (2147483647 vs 4294967295) bcmsdh_sdmmc.c +300 brcmf_sdioh_request_buffer(10) warn: variable dereferenced before check 'pkt' (see line 295) Reported-by: Dan Carpenter Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 3 ++- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index ac71adeece51..b698a76f8550 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -294,13 +294,14 @@ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, struct sk_buff *pkt) { int status; - uint pkt_len = pkt->len; + uint pkt_len; bool fifo = (fix_inc == SDIOH_DATA_FIX); brcmf_dbg(TRACE, "Enter\n"); if (pkt == NULL) return -EINVAL; + pkt_len = pkt->len; brcmf_pm_resume_wait(sdiodev, &sdiodev->request_buffer_wait); if (brcmf_pm_resume_error(sdiodev)) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 74c95a597950..e95a883c77da 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -1376,7 +1376,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, memset(&join_params, 0, sizeof(join_params)); join_params_size = sizeof(join_params.ssid_le); - ssid.SSID_len = min_t(u32, sizeof(ssid.SSID), sme->ssid_len); + ssid.SSID_len = min_t(u32, sizeof(ssid.SSID), (u32)sme->ssid_len); memcpy(&join_params.ssid_le.SSID, sme->ssid, ssid.SSID_len); memcpy(&ssid.SSID, sme->ssid, ssid.SSID_len); join_params.ssid_le.SSID_len = cpu_to_le32(ssid.SSID_len); -- GitLab From 89fdb468e201c16b31d3337b68993bc9f763a5a0 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 9 Feb 2012 21:09:01 +0100 Subject: [PATCH 0952/1846] brcm80211: fmac: make sure cancel_work_sync only called after INIT_WORK INIT_WORK only gets called after brcmf_proto_attach returns success. This dependency should be annotated in brcmf_detach to avoid any error. Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index db2df1f1e6b2..eff0073879c7 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1109,13 +1109,13 @@ void brcmf_detach(struct device *dev) if (drvr->iflist[i]) brcmf_del_if(drvr, i); - cancel_work_sync(&drvr->setmacaddr_work); - cancel_work_sync(&drvr->multicast_work); - brcmf_bus_detach(drvr); - if (drvr->prot) + if (drvr->prot) { + cancel_work_sync(&drvr->setmacaddr_work); + cancel_work_sync(&drvr->multicast_work); brcmf_proto_detach(drvr); + } bus_if->drvr = NULL; kfree(drvr); -- GitLab From 0a332e4678e4e4f0030f10827980c72d32300274 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:02 +0100 Subject: [PATCH 0953/1846] brcm80211: fmac: use specific types in struct brcmf_bus The fields bus_priv and drvr are defined as void pointer. It is preferred to have specific types for compiler type checking. To prepare for other bus types the bus_priv field is defined as a union containing the sdio bus private structure reference. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 4 ++-- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 7 +++++-- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index b698a76f8550..1d2b74d3fa21 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -489,7 +489,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, sdiodev->func[0] = func->card->sdio_func[0]; sdiodev->func[1] = func; sdiodev->bus_if = bus_if; - bus_if->bus_priv = sdiodev; + bus_if->bus_priv.sdio = sdiodev; bus_if->type = SDIO_BUS; bus_if->align = BRCMF_SDALIGN; dev_set_drvdata(&func->card->dev, sdiodev); @@ -530,7 +530,7 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) if (func->num == 2) { bus_if = dev_get_drvdata(&func->dev); - sdiodev = bus_if->bus_priv; + sdiodev = bus_if->bus_priv.sdio; brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n"); brcmf_sdio_remove(sdiodev); dev_set_drvdata(&func->card->dev, NULL); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index ad9be2410b59..567a966f7634 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -39,8 +39,11 @@ struct dngl_stats { /* interface structure between common and bus layer */ struct brcmf_bus { u8 type; /* bus type */ - void *bus_priv; /* pointer to bus private structure */ - void *drvr; /* pointer to driver pub structure brcmf_pub */ + union { + /* pointer to sdio private structure */ + struct brcmf_sdio_dev *sdio; + } bus_priv; + struct brcmf_pub *drvr; /* pointer to driver pub structure brcmf_pub */ enum brcmf_bus_state state; uint maxctl; /* Max size rxctl request from proto to bus */ bool drvr_up; /* Status flag of driver up/down */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 6e4b5e85a099..b20029e9984c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2277,7 +2277,7 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev) 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_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); @@ -2627,7 +2627,7 @@ static 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_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); @@ -2869,7 +2869,7 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) 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_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); @@ -2978,7 +2978,7 @@ brcmf_sdbrcm_bus_rxctl(struct device *dev, unsigned char *msg, uint msglen) 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_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); @@ -3389,7 +3389,7 @@ brcmf_sdbrcm_download_firmware(struct brcmf_sdio *bus) static int brcmf_sdbrcm_bus_init(struct device *dev) { struct brcmf_bus *bus_if = dev_get_drvdata(dev); - struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_sdio *bus = sdiodev->bus; unsigned long timeout; uint retries = 0; -- GitLab From f3d7cdc3b41804096a9df9c5d7a9439ef192f36a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:03 +0100 Subject: [PATCH 0954/1846] brcm80211: fmac: move module entry points to dhd_linux.c The module_init/exit functions are moved to dhd_linux.c to prepare for supporting multiple host interface types. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../brcm80211/brcmfmac/bcmsdh_sdmmc.c | 7 ++---- .../net/wireless/brcm80211/brcmfmac/dhd_bus.h | 6 +++++ .../wireless/brcm80211/brcmfmac/dhd_linux.c | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 1d2b74d3fa21..83ca3cc2cccb 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -597,14 +597,14 @@ static struct sdio_driver brcmf_sdmmc_driver = { #endif /* CONFIG_PM_SLEEP */ }; -static void __exit brcmf_sdio_exit(void) +void brcmf_sdio_exit(void) { brcmf_dbg(TRACE, "Enter\n"); sdio_unregister_driver(&brcmf_sdmmc_driver); } -static int __init brcmf_sdio_init(void) +int brcmf_sdio_init(void) { int ret; @@ -617,6 +617,3 @@ static int __init brcmf_sdio_init(void) 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 567a966f7634..bc575b4f158e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -105,4 +105,10 @@ extern int brcmf_bus_start(struct device *dev); extern int brcmf_add_if(struct device *dev, int ifidx, char *name, u8 *mac_addr); + +#ifdef CONFIG_BRCMFMAC_SDIO +extern void brcmf_sdio_exit(void); +extern int brcmf_sdio_init(void); +#endif + #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 eff0073879c7..ff7fc0e9f807 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1183,3 +1183,27 @@ int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size) return ret; } #endif /* DEBUG */ + +static int __init brcmfmac_init(void) +{ + int ret = 0; + +#ifdef CONFIG_BRCMFMAC_SDIO + ret = brcmf_sdio_init(); + if (ret) + goto fail; +#endif + +fail: + return ret; +} + +static void __exit brcmfmac_exit(void) +{ +#ifdef CONFIG_BRCMFMAC_SDIO + brcmf_sdio_exit(); +#endif +} + +module_init(brcmfmac_init); +module_exit(brcmfmac_exit); -- GitLab From c0e89f084b5089acdfdda1cb45c88896fa0f5139 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:04 +0100 Subject: [PATCH 0955/1846] brcm80211: fmac: only return success in brcmf_sdbrcm_bus_init() when true The function brcmf_sdbrcm_bus_init() always returned success except for firmware download failure. However, also when enabling SDIO function 2 is failing the function should return failure. This patch fixes that. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index b20029e9984c..47a192db36ff 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3467,13 +3467,12 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) /* Set bus state according to enable result */ bus_if->state = BRCMF_BUS_DATA; - } - - else { + } else { /* Disable F2 again */ enable = SDIO_FUNC_ENABLE_1; brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, enable, NULL); + ret = -ENODEV; } /* Restore previous clock setting */ @@ -3481,7 +3480,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); /* If we didn't come up, turn off backplane clock */ - if (bus_if->state != BRCMF_BUS_DATA) + if (!ret) brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); exit: -- GitLab From 1bb1f38462bcf58cf98d8f7bedf2bfefd394f940 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:05 +0100 Subject: [PATCH 0956/1846] brcm80211: fmac: update bus state in common driver part The bus state is updated in the sdio bus init function, but it is better to do it when the brcmf_bus_start() function is completed successfully. The brcmf_netdev_open() function will return -EAGAIN until the state is updated instead of calling brcmf_bus_start() to avoid reentering that function. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../wireless/brcm80211/brcmfmac/dhd_linux.c | 19 ++++++++----------- .../wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 --- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index ff7fc0e9f807..68da7568ad10 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -796,18 +796,19 @@ static int brcmf_netdev_open(struct net_device *ndev) { struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_pub *drvr = ifp->drvr; + struct brcmf_bus *bus_if = drvr->bus_if; u32 toe_ol; s32 ret = 0; brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx); if (ifp->idx == 0) { /* do it only for primary eth0 */ - /* try to bring up bus */ - ret = brcmf_bus_start(drvr->dev); - if (ret != 0) { - brcmf_dbg(ERROR, "failed with code %d\n", ret); - return -1; + /* If bus is not ready, can't continue */ + if (bus_if->state != BRCMF_BUS_DATA) { + brcmf_dbg(ERROR, "failed bus is not ready\n"); + return -EAGAIN; } + atomic_set(&drvr->pend_8021x_cnt, 0); memcpy(ndev->dev_addr, drvr->mac, ETH_ALEN); @@ -979,12 +980,6 @@ int brcmf_bus_start(struct device *dev) return ret; } - /* If bus is not ready, can't come up */ - if (bus_if->state != BRCMF_BUS_DATA) { - brcmf_dbg(ERROR, "failed bus is not ready\n"); - return -ENODEV; - } - brcmf_c_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, iovbuf, @@ -1021,6 +1016,8 @@ int brcmf_bus_start(struct device *dev) if (ret < 0) return ret; + /* signal bus ready */ + bus_if->state = BRCMF_BUS_DATA; return 0; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 47a192db36ff..253fc20adf88 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3464,9 +3464,6 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_WATERMARK, 8, &err); - - /* Set bus state according to enable result */ - bus_if->state = BRCMF_BUS_DATA; } else { /* Disable F2 again */ enable = SDIO_FUNC_ENABLE_1; -- GitLab From bcbec9e777cc66fbbeb386c42d8af680fc941da7 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:06 +0100 Subject: [PATCH 0957/1846] brcm80211: fmac: change allocation flag in brcmf_enq_event() function As the function is called from atomic context it should not do the kzalloc call with GFP_KERNEL. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Kan Yan Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index e95a883c77da..285fa19e881d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -3297,7 +3297,9 @@ static struct brcmf_cfg80211_event_q *brcmf_deq_event( } /* -** push event to tail of the queue +* push event to tail of the queue +* +* remark: this function may not sleep as it is called in atomic context. */ static s32 @@ -3307,7 +3309,7 @@ brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, struct brcmf_cfg80211_event_q *e; s32 err = 0; - e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_KERNEL); + e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_ATOMIC); if (!e) return -ENOMEM; -- GitLab From cf44066a3836847a74f6a0817c680726b796239f Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:07 +0100 Subject: [PATCH 0958/1846] brcm80211: fmac: use spinlock calls saving irq flags in brcmf_enq_event() This function is executed within irq context. The call spin_unlock_irq does enable interrupts which is not desired in the irq context. This patch replaces them using the spin_loc_irqsave and spin_unlock_irqrestore functions. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Kan Yan Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 285fa19e881d..15d7f00513be 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -3308,6 +3308,7 @@ brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, { struct brcmf_cfg80211_event_q *e; s32 err = 0; + ulong flags; e = kzalloc(sizeof(struct brcmf_cfg80211_event_q), GFP_ATOMIC); if (!e) @@ -3316,9 +3317,9 @@ brcmf_enq_event(struct brcmf_cfg80211_priv *cfg_priv, u32 event, e->etype = event; memcpy(&e->emsg, msg, sizeof(struct brcmf_event_msg)); - spin_lock_irq(&cfg_priv->evt_q_lock); + spin_lock_irqsave(&cfg_priv->evt_q_lock, flags); list_add_tail(&e->evt_q_list, &cfg_priv->evt_q_list); - spin_unlock_irq(&cfg_priv->evt_q_lock); + spin_unlock_irqrestore(&cfg_priv->evt_q_lock, flags); return err; } -- GitLab From 71bb244ba2fd5390eefe4ee9054abdb3f8b05922 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:08 +0100 Subject: [PATCH 0959/1846] brcm80211: fmac: add USB support for bcm43235/6/8 chipsets This patch extends the use of the brcmfmac driver with support for chipsets with a USB host interface. The first chipsets supported are the bcm43235, bcm43236, and bcm43238 for which firmware has been submitted. This driver change has been successfully built for x86, x86_64, ppc64, arm_le, and mips_be. It has been tested successfully on x86 and x86_64. Cc: M. Lambert Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Kan Yan Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/Kconfig | 17 +- .../net/wireless/brcm80211/brcmfmac/Makefile | 6 +- .../net/wireless/brcm80211/brcmfmac/dhd_bus.h | 6 +- .../wireless/brcm80211/brcmfmac/dhd_linux.c | 8 + drivers/net/wireless/brcm80211/brcmfmac/usb.c | 1623 +++++++++++++++++ drivers/net/wireless/brcm80211/brcmfmac/usb.h | 84 + .../net/wireless/brcm80211/brcmfmac/usb_rdl.h | 75 + 7 files changed, 1812 insertions(+), 7 deletions(-) create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/usb.c create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/usb.h create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/usb_rdl.h diff --git a/drivers/net/wireless/brcm80211/Kconfig b/drivers/net/wireless/brcm80211/Kconfig index cd6375de2a60..c5104533e24e 100644 --- a/drivers/net/wireless/brcm80211/Kconfig +++ b/drivers/net/wireless/brcm80211/Kconfig @@ -26,16 +26,25 @@ config BRCMFMAC it'll be called brcmfmac.ko. config BRCMFMAC_SDIO - bool "SDIO bus interface support for FullMAC" + bool "SDIO bus interface support for FullMAC driver" depends on MMC depends on BRCMFMAC select FW_LOADER default y ---help--- This option enables the SDIO bus interface support for Broadcom - FullMAC WLAN driver. - Say Y if you want to use brcmfmac for a compatible SDIO interface - wireless card. + IEEE802.11n embedded FullMAC WLAN driver. Say Y if you want to + use the driver for a SDIO wireless card. + +config BRCMFMAC_USB + bool "USB bus interface support for FullMAC driver" + depends on USB + depends on BRCMFMAC + select FW_LOADER + ---help--- + This option enables the USB bus interface support for Broadcom + IEEE802.11n embedded FullMAC WLAN driver. Say Y if you want to + use the driver for an USB wireless card. config BRCMDBG bool "Broadcom driver debug functions" diff --git a/drivers/net/wireless/brcm80211/brcmfmac/Makefile b/drivers/net/wireless/brcm80211/brcmfmac/Makefile index 9ca9ea1135ea..abb48032753b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/Makefile +++ b/drivers/net/wireless/brcm80211/brcmfmac/Makefile @@ -19,6 +19,8 @@ ccflags-y += \ -Idrivers/net/wireless/brcm80211/brcmfmac \ -Idrivers/net/wireless/brcm80211/include +ccflags-y += -D__CHECK_ENDIAN__ + obj-$(CONFIG_BRCMFMAC) += brcmfmac.o brcmfmac-objs += \ wl_cfg80211.o \ @@ -30,5 +32,5 @@ brcmfmac-$(CONFIG_BRCMFMAC_SDIO) += \ bcmsdh.o \ bcmsdh_sdmmc.o \ sdio_chip.o - -ccflags-y += -D__CHECK_ENDIAN__ +brcmfmac-$(CONFIG_BRCMFMAC_USB) += \ + usb.o diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index bc575b4f158e..b7671b30692f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -40,8 +40,8 @@ struct dngl_stats { struct brcmf_bus { u8 type; /* bus type */ union { - /* pointer to sdio private structure */ struct brcmf_sdio_dev *sdio; + struct brcmf_usbdev *usb; } bus_priv; struct brcmf_pub *drvr; /* pointer to driver pub structure brcmf_pub */ enum brcmf_bus_state state; @@ -110,5 +110,9 @@ extern int brcmf_add_if(struct device *dev, int ifidx, extern void brcmf_sdio_exit(void); extern int brcmf_sdio_init(void); #endif +#ifdef CONFIG_BRCMFMAC_USB +extern void brcmf_usb_exit(void); +extern int brcmf_usb_init(void); +#endif #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 68da7568ad10..c4da05817443 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1190,6 +1190,11 @@ static int __init brcmfmac_init(void) if (ret) goto fail; #endif +#ifdef CONFIG_BRCMFMAC_USB + ret = brcmf_usb_init(); + if (ret) + goto fail; +#endif fail: return ret; @@ -1200,6 +1205,9 @@ static void __exit brcmfmac_exit(void) #ifdef CONFIG_BRCMFMAC_SDIO brcmf_sdio_exit(); #endif +#ifdef CONFIG_BRCMFMAC_USB + brcmf_usb_exit(); +#endif } module_init(brcmfmac_init); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c new file mode 100644 index 000000000000..934ed782620c --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -0,0 +1,1623 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "usb_rdl.h" +#include "usb.h" + +#define IOCTL_RESP_TIMEOUT 2000 + +#define BRCMF_USB_SYNC_TIMEOUT 300 /* ms */ +#define BRCMF_USB_DLIMAGE_SPINWAIT 100 /* in unit of ms */ +#define BRCMF_USB_DLIMAGE_LIMIT 500 /* spinwait limit (ms) */ + +#define BRCMF_POSTBOOT_ID 0xA123 /* ID to detect if dongle + has boot up */ +#define BRCMF_USB_RESETCFG_SPINWAIT 1 /* wait after resetcfg (ms) */ + +#define BRCMF_USB_NRXQ 50 +#define BRCMF_USB_NTXQ 50 + +#define CONFIGDESC(usb) (&((usb)->actconfig)->desc) +#define IFPTR(usb, idx) ((usb)->actconfig->interface[(idx)]) +#define IFALTS(usb, idx) (IFPTR((usb), (idx))->altsetting[0]) +#define IFDESC(usb, idx) IFALTS((usb), (idx)).desc +#define IFEPDESC(usb, idx, ep) (IFALTS((usb), (idx)).endpoint[(ep)]).desc + +#define CONTROL_IF 0 +#define BULK_IF 0 + +#define BRCMF_USB_CBCTL_WRITE 0 +#define BRCMF_USB_CBCTL_READ 1 +#define BRCMF_USB_MAX_PKT_SIZE 1600 + +#define BRCMF_USB_FW_NAME "brcm/brcmfmac-usb.bin" + +enum usbdev_suspend_state { + USBOS_SUSPEND_STATE_DEVICE_ACTIVE = 0, /* Device is busy, won't allow + suspend */ + USBOS_SUSPEND_STATE_SUSPEND_PENDING, /* Device is idle, can be + * suspended. Wating PM to + * suspend the device + */ + USBOS_SUSPEND_STATE_SUSPENDED /* Device suspended */ +}; + +struct brcmf_usb_probe_info { + void *usbdev_info; + struct usb_device *usb; /* USB device pointer from OS */ + uint rx_pipe, tx_pipe, intr_pipe, rx_pipe2; + int intr_size; /* Size of interrupt message */ + int interval; /* Interrupt polling interval */ + int vid; + int pid; + enum usb_device_speed device_speed; + enum usbdev_suspend_state suspend_state; + struct usb_interface *intf; +}; +static struct brcmf_usb_probe_info usbdev_probe_info; + +struct brcmf_usb_image { + void *data; + u32 len; +}; +static struct brcmf_usb_image g_image = { NULL, 0 }; + +struct intr_transfer_buf { + u32 notification; + u32 reserved; +}; + +struct brcmf_usbdev_info { + struct brcmf_usbdev bus_pub; /* MUST BE FIRST */ + spinlock_t qlock; + struct list_head rx_freeq; + struct list_head rx_postq; + struct list_head tx_freeq; + struct list_head tx_postq; + enum usbdev_suspend_state suspend_state; + uint rx_pipe, tx_pipe, intr_pipe, rx_pipe2; + + bool activity; + int rx_low_watermark; + int tx_low_watermark; + int tx_high_watermark; + bool txoff; + bool rxoff; + bool txoverride; + + struct brcmf_usbreq *tx_reqs; + struct brcmf_usbreq *rx_reqs; + + u8 *image; /* buffer for combine fw and nvram */ + int image_len; + + wait_queue_head_t wait; + bool waitdone; + int sync_urb_status; + + struct usb_device *usbdev; + struct device *dev; + enum usb_device_speed device_speed; + + int ctl_in_pipe, ctl_out_pipe; + struct urb *ctl_urb; /* URB for control endpoint */ + struct usb_ctrlrequest ctl_write; + struct usb_ctrlrequest ctl_read; + u32 ctl_urb_actual_length; + int ctl_urb_status; + int ctl_completed; + wait_queue_head_t ioctl_resp_wait; + wait_queue_head_t ctrl_wait; + ulong ctl_op; + + bool rxctl_deferrespok; + + struct urb *bulk_urb; /* used for FW download */ + struct urb *intr_urb; /* URB for interrupt endpoint */ + int intr_size; /* Size of interrupt message */ + int interval; /* Interrupt polling interval */ + struct intr_transfer_buf intr; /* Data buffer for interrupt endpoint */ + + struct brcmf_usb_probe_info probe_info; + +}; + +static void brcmf_usb_rx_refill(struct brcmf_usbdev_info *devinfo, + struct brcmf_usbreq *req); + +MODULE_AUTHOR("Broadcom Corporation"); +MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac usb driver."); +MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac usb cards"); +MODULE_LICENSE("Dual BSD/GPL"); + +static struct brcmf_usbdev *brcmf_usb_get_buspub(struct device *dev) +{ + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + return bus_if->bus_priv.usb; +} + +static struct brcmf_usbdev_info *brcmf_usb_get_businfo(struct device *dev) +{ + return brcmf_usb_get_buspub(dev)->devinfo; +} + +#if 0 +static void +brcmf_usb_txflowcontrol(struct brcmf_usbdev_info *devinfo, bool onoff) +{ + dhd_txflowcontrol(devinfo->bus_pub.netdev, 0, onoff); +} +#endif + +static int brcmf_usb_ioctl_resp_wait(struct brcmf_usbdev_info *devinfo, + uint *condition, bool *pending) +{ + DECLARE_WAITQUEUE(wait, current); + int timeout = IOCTL_RESP_TIMEOUT; + + /* Convert timeout in millsecond to jiffies */ + timeout = msecs_to_jiffies(timeout); + /* Wait until control frame is available */ + add_wait_queue(&devinfo->ioctl_resp_wait, &wait); + set_current_state(TASK_INTERRUPTIBLE); + + smp_mb(); + while (!(*condition) && (!signal_pending(current) && timeout)) { + timeout = schedule_timeout(timeout); + /* Wait until control frame is available */ + smp_mb(); + } + + if (signal_pending(current)) + *pending = true; + + set_current_state(TASK_RUNNING); + remove_wait_queue(&devinfo->ioctl_resp_wait, &wait); + + return timeout; +} + +static int brcmf_usb_ioctl_resp_wake(struct brcmf_usbdev_info *devinfo) +{ + if (waitqueue_active(&devinfo->ioctl_resp_wait)) + wake_up_interruptible(&devinfo->ioctl_resp_wait); + + return 0; +} + +static void +brcmf_usb_ctl_complete(struct brcmf_usbdev_info *devinfo, int type, int status) +{ + + if (unlikely(devinfo == NULL)) + return; + + if (type == BRCMF_USB_CBCTL_READ) { + if (status == 0) + devinfo->bus_pub.stats.rx_ctlpkts++; + else + devinfo->bus_pub.stats.rx_ctlerrs++; + } else if (type == BRCMF_USB_CBCTL_WRITE) { + if (status == 0) + devinfo->bus_pub.stats.tx_ctlpkts++; + else + devinfo->bus_pub.stats.tx_ctlerrs++; + } + + devinfo->ctl_urb_status = status; + devinfo->ctl_completed = true; + brcmf_usb_ioctl_resp_wake(devinfo); +} + +static void +brcmf_usb_ctlread_complete(struct urb *urb) +{ + struct brcmf_usbdev_info *devinfo = + (struct brcmf_usbdev_info *)urb->context; + + devinfo->ctl_urb_actual_length = urb->actual_length; + brcmf_usb_ctl_complete(devinfo, BRCMF_USB_CBCTL_READ, + urb->status); +} + +static void +brcmf_usb_ctlwrite_complete(struct urb *urb) +{ + struct brcmf_usbdev_info *devinfo = + (struct brcmf_usbdev_info *)urb->context; + + brcmf_usb_ctl_complete(devinfo, BRCMF_USB_CBCTL_WRITE, + urb->status); +} + +static int brcmf_usb_pnp(struct brcmf_usbdev_info *devinfo, uint state) +{ + return 0; +} + +static int +brcmf_usb_send_ctl(struct brcmf_usbdev_info *devinfo, u8 *buf, int len) +{ + int ret; + u16 size; + + if (devinfo == NULL || buf == NULL || + len == 0 || devinfo->ctl_urb == NULL) + return -EINVAL; + + /* If the USB/HSIC bus in sleep state, wake it up */ + if (devinfo->suspend_state == USBOS_SUSPEND_STATE_SUSPENDED) + if (brcmf_usb_pnp(devinfo, BCMFMAC_USB_PNP_RESUME) != 0) { + brcmf_dbg(ERROR, "Could not Resume the bus!\n"); + return -EIO; + } + + devinfo->activity = true; + size = len; + devinfo->ctl_write.wLength = cpu_to_le16p(&size); + devinfo->ctl_urb->transfer_buffer_length = size; + devinfo->ctl_urb_status = 0; + devinfo->ctl_urb_actual_length = 0; + + usb_fill_control_urb(devinfo->ctl_urb, + devinfo->usbdev, + devinfo->ctl_out_pipe, + (unsigned char *) &devinfo->ctl_write, + buf, size, + (usb_complete_t)brcmf_usb_ctlwrite_complete, + devinfo); + + ret = usb_submit_urb(devinfo->ctl_urb, GFP_ATOMIC); + if (ret < 0) + brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); + + return ret; +} + +static int +brcmf_usb_recv_ctl(struct brcmf_usbdev_info *devinfo, u8 *buf, int len) +{ + int ret; + u16 size; + + if ((devinfo == NULL) || (buf == NULL) || (len == 0) + || (devinfo->ctl_urb == NULL)) + return -EINVAL; + + size = len; + devinfo->ctl_read.wLength = cpu_to_le16p(&size); + devinfo->ctl_urb->transfer_buffer_length = size; + + if (devinfo->rxctl_deferrespok) { + /* BMAC model */ + devinfo->ctl_read.bRequestType = USB_DIR_IN + | USB_TYPE_VENDOR | USB_RECIP_INTERFACE; + devinfo->ctl_read.bRequest = DL_DEFER_RESP_OK; + } else { + /* full dongle model */ + devinfo->ctl_read.bRequestType = USB_DIR_IN + | USB_TYPE_CLASS | USB_RECIP_INTERFACE; + devinfo->ctl_read.bRequest = 1; + } + + usb_fill_control_urb(devinfo->ctl_urb, + devinfo->usbdev, + devinfo->ctl_in_pipe, + (unsigned char *) &devinfo->ctl_read, + buf, size, + (usb_complete_t)brcmf_usb_ctlread_complete, + devinfo); + + ret = usb_submit_urb(devinfo->ctl_urb, GFP_ATOMIC); + if (ret < 0) + brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); + + return ret; +} + +static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len) +{ + int err = 0; + int timeout = 0; + bool pending; + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + + if (devinfo->bus_pub.state != BCMFMAC_USB_STATE_UP) { + /* TODO: handle suspend/resume */ + return -EIO; + } + + if (test_and_set_bit(0, &devinfo->ctl_op)) + return -EIO; + + err = brcmf_usb_send_ctl(devinfo, buf, len); + if (err) { + brcmf_dbg(ERROR, "fail %d bytes: %d\n", err, len); + return err; + } + + devinfo->ctl_completed = false; + timeout = brcmf_usb_ioctl_resp_wait(devinfo, &devinfo->ctl_completed, + &pending); + clear_bit(0, &devinfo->ctl_op); + if (!timeout) { + brcmf_dbg(ERROR, "Txctl wait timed out\n"); + err = -EIO; + } + return err; +} + +static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len) +{ + int err = 0; + int timeout = 0; + bool pending; + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + + if (devinfo->bus_pub.state != BCMFMAC_USB_STATE_UP) { + /* TODO: handle suspend/resume */ + return -EIO; + } + if (test_and_set_bit(0, &devinfo->ctl_op)) + return -EIO; + + err = brcmf_usb_recv_ctl(devinfo, buf, len); + if (err) { + brcmf_dbg(ERROR, "fail %d bytes: %d\n", err, len); + return err; + } + devinfo->ctl_completed = false; + timeout = brcmf_usb_ioctl_resp_wait(devinfo, &devinfo->ctl_completed, + &pending); + err = devinfo->ctl_urb_status; + clear_bit(0, &devinfo->ctl_op); + if (!timeout) { + brcmf_dbg(ERROR, "rxctl wait timed out\n"); + err = -EIO; + } + if (!err) + return devinfo->ctl_urb_actual_length; + else + return err; +} + +static struct brcmf_usbreq *brcmf_usb_deq(struct brcmf_usbdev_info *devinfo, + struct list_head *q) +{ + unsigned long flags; + struct brcmf_usbreq *req; + spin_lock_irqsave(&devinfo->qlock, flags); + if (list_empty(q)) { + spin_unlock_irqrestore(&devinfo->qlock, flags); + return NULL; + } + req = list_entry(q->next, struct brcmf_usbreq, list); + list_del_init(q->next); + spin_unlock_irqrestore(&devinfo->qlock, flags); + return req; + +} + +static void brcmf_usb_enq(struct brcmf_usbdev_info *devinfo, + struct list_head *q, struct brcmf_usbreq *req) +{ + unsigned long flags; + spin_lock_irqsave(&devinfo->qlock, flags); + list_add_tail(&req->list, q); + spin_unlock_irqrestore(&devinfo->qlock, flags); +} + +static struct brcmf_usbreq * +brcmf_usbdev_qinit(struct list_head *q, int qsize) +{ + int i; + struct brcmf_usbreq *req, *reqs; + + reqs = kzalloc(sizeof(struct brcmf_usbreq) * qsize, GFP_ATOMIC); + if (reqs == NULL) { + brcmf_dbg(ERROR, "fail to allocate memory!\n"); + return NULL; + } + req = reqs; + + for (i = 0; i < qsize; i++) { + req->urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!req->urb) + goto fail; + + INIT_LIST_HEAD(&req->list); + list_add_tail(&req->list, q); + req++; + } + return reqs; +fail: + brcmf_dbg(ERROR, "fail!\n"); + while (!list_empty(q)) { + req = list_entry(q->next, struct brcmf_usbreq, list); + if (req && req->urb) + usb_free_urb(req->urb); + list_del(q->next); + } + return NULL; + +} + +static void brcmf_usb_free_q(struct list_head *q, bool pending) +{ + struct brcmf_usbreq *req, *next; + int i = 0; + list_for_each_entry_safe(req, next, q, list) { + if (!req || !req->urb) { + brcmf_dbg(ERROR, "bad req\n"); + break; + } + i++; + if (pending) { + usb_kill_urb(req->urb); + } else { + usb_free_urb(req->urb); + list_del_init(&req->list); + } + } +} + +static void brcmf_usb_del_fromq(struct brcmf_usbdev_info *devinfo, + struct brcmf_usbreq *req) +{ + unsigned long flags; + + spin_lock_irqsave(&devinfo->qlock, flags); + list_del_init(&req->list); + spin_unlock_irqrestore(&devinfo->qlock, flags); +} + + +static void brcmf_usb_tx_complete(struct urb *urb) +{ + struct brcmf_usbreq *req = (struct brcmf_usbreq *)urb->context; + struct brcmf_usbdev_info *devinfo = req->devinfo; + + brcmf_usb_del_fromq(devinfo, req); + if (urb->status == 0) + devinfo->bus_pub.stats.tx_packets++; + else + devinfo->bus_pub.stats.tx_errors++; + + dev_kfree_skb(req->skb); + req->skb = NULL; + brcmf_usb_enq(devinfo, &devinfo->tx_freeq, req); + +} + +static void brcmf_usb_rx_complete(struct urb *urb) +{ + struct brcmf_usbreq *req = (struct brcmf_usbreq *)urb->context; + struct brcmf_usbdev_info *devinfo = req->devinfo; + struct sk_buff *skb; + int ifidx = 0; + + brcmf_usb_del_fromq(devinfo, req); + skb = req->skb; + req->skb = NULL; + + if (urb->status == 0) { + devinfo->bus_pub.stats.rx_packets++; + } else { + devinfo->bus_pub.stats.rx_errors++; + dev_kfree_skb(skb); + brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req); + return; + } + + if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP) { + skb_put(skb, urb->actual_length); + if (brcmf_proto_hdrpull(devinfo->dev, &ifidx, skb) != 0) { + brcmf_dbg(ERROR, "rx protocol error\n"); + brcmu_pkt_buf_free_skb(skb); + devinfo->bus_pub.bus->dstats.rx_errors++; + } else { + brcmf_rx_packet(devinfo->dev, ifidx, skb); + brcmf_usb_rx_refill(devinfo, req); + } + } else { + dev_kfree_skb(skb); + } + return; + +} + +static void brcmf_usb_rx_refill(struct brcmf_usbdev_info *devinfo, + struct brcmf_usbreq *req) +{ + struct sk_buff *skb; + int ret; + + if (!req || !devinfo) + return; + + skb = dev_alloc_skb(devinfo->bus_pub.bus_mtu); + if (!skb) { + brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req); + return; + } + req->skb = skb; + + usb_fill_bulk_urb(req->urb, devinfo->usbdev, devinfo->rx_pipe, + skb->data, skb_tailroom(skb), brcmf_usb_rx_complete, + req); + req->urb->transfer_flags |= URB_ZERO_PACKET; + req->devinfo = devinfo; + + ret = usb_submit_urb(req->urb, GFP_ATOMIC); + if (ret == 0) { + brcmf_usb_enq(devinfo, &devinfo->rx_postq, req); + } else { + dev_kfree_skb(req->skb); + req->skb = NULL; + brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req); + } + return; +} + +static void brcmf_usb_rx_fill_all(struct brcmf_usbdev_info *devinfo) +{ + struct brcmf_usbreq *req; + + if (devinfo->bus_pub.state != BCMFMAC_USB_STATE_UP) { + brcmf_dbg(ERROR, "bus is not up\n"); + return; + } + while ((req = brcmf_usb_deq(devinfo, &devinfo->rx_freeq)) != NULL) + brcmf_usb_rx_refill(devinfo, req); +} + +static void +brcmf_usb_state_change(struct brcmf_usbdev_info *devinfo, int state) +{ + struct brcmf_bus *bcmf_bus = devinfo->bus_pub.bus; + int old_state; + + + if (devinfo->bus_pub.state == state) + return; + + old_state = devinfo->bus_pub.state; + brcmf_dbg(TRACE, "dbus state change from %d to to %d\n", + old_state, state); + + /* Don't update state if it's PnP firmware re-download */ + if (state != BCMFMAC_USB_STATE_PNP_FWDL) /* TODO */ + devinfo->bus_pub.state = state; + + if ((old_state == BCMFMAC_USB_STATE_SLEEP) + && (state == BCMFMAC_USB_STATE_UP)) { + brcmf_usb_rx_fill_all(devinfo); + } + + /* update state of upper layer */ + if (state == BCMFMAC_USB_STATE_DOWN) { + brcmf_dbg(INFO, "DBUS is down\n"); + bcmf_bus->state = BRCMF_BUS_DOWN; + } else { + brcmf_dbg(INFO, "DBUS current state=%d\n", state); + } +} + +static void +brcmf_usb_intr_complete(struct urb *urb) +{ + struct brcmf_usbdev_info *devinfo = + (struct brcmf_usbdev_info *)urb->context; + bool killed; + + if (devinfo == NULL) + return; + + if (unlikely(urb->status)) { + if (devinfo->suspend_state == + USBOS_SUSPEND_STATE_SUSPEND_PENDING) + killed = true; + + if ((urb->status == -ENOENT && (!killed)) + || urb->status == -ESHUTDOWN || + urb->status == -ENODEV) { + brcmf_usb_state_change(devinfo, BCMFMAC_USB_STATE_DOWN); + } + } + + if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_DOWN) { + brcmf_dbg(ERROR, "intr cb when DBUS down, ignoring\n"); + return; + } + + if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP) + usb_submit_urb(devinfo->intr_urb, GFP_ATOMIC); +} + +static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb) +{ + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + struct brcmf_usbreq *req; + int ret; + + if (devinfo->bus_pub.state != BCMFMAC_USB_STATE_UP) { + /* TODO: handle suspend/resume */ + return -EIO; + } + + req = brcmf_usb_deq(devinfo, &devinfo->tx_freeq); + if (!req) { + brcmf_dbg(ERROR, "no req to send\n"); + return -ENOMEM; + } + if (!req->urb) { + brcmf_dbg(ERROR, "no urb for req %p\n", req); + return -ENOBUFS; + } + + req->skb = skb; + req->devinfo = devinfo; + usb_fill_bulk_urb(req->urb, devinfo->usbdev, devinfo->tx_pipe, + skb->data, skb->len, brcmf_usb_tx_complete, req); + req->urb->transfer_flags |= URB_ZERO_PACKET; + ret = usb_submit_urb(req->urb, GFP_ATOMIC); + if (!ret) { + brcmf_usb_enq(devinfo, &devinfo->tx_postq, req); + } else { + req->skb = NULL; + brcmf_usb_enq(devinfo, &devinfo->tx_freeq, req); + } + + return ret; +} + + +static int brcmf_usb_up(struct device *dev) +{ + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + u16 ifnum; + + if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP) + return 0; + + if (devinfo == NULL) + return -EINVAL; + + /* If the USB/HSIC bus in sleep state, wake it up */ + if (devinfo->suspend_state == USBOS_SUSPEND_STATE_SUSPENDED) { + if (brcmf_usb_pnp(devinfo, BCMFMAC_USB_PNP_RESUME) != 0) { + brcmf_dbg(ERROR, "Could not Resume the bus!\n"); + return -EIO; + } + } + devinfo->activity = true; + + /* Success, indicate devinfo is fully up */ + brcmf_usb_state_change(devinfo, BCMFMAC_USB_STATE_UP); + + if (devinfo->intr_urb) { + int ret; + + usb_fill_int_urb(devinfo->intr_urb, devinfo->usbdev, + devinfo->intr_pipe, + &devinfo->intr, + devinfo->intr_size, + (usb_complete_t)brcmf_usb_intr_complete, + devinfo, + devinfo->interval); + + ret = usb_submit_urb(devinfo->intr_urb, GFP_ATOMIC); + if (ret) { + brcmf_dbg(ERROR, "USB_SUBMIT_URB failed with status %d\n", + ret); + return -EINVAL; + } + } + + if (devinfo->ctl_urb) { + devinfo->ctl_in_pipe = usb_rcvctrlpipe(devinfo->usbdev, 0); + devinfo->ctl_out_pipe = usb_sndctrlpipe(devinfo->usbdev, 0); + + ifnum = IFDESC(devinfo->usbdev, CONTROL_IF).bInterfaceNumber; + + /* CTL Write */ + devinfo->ctl_write.bRequestType = + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE; + devinfo->ctl_write.bRequest = 0; + devinfo->ctl_write.wValue = cpu_to_le16(0); + devinfo->ctl_write.wIndex = cpu_to_le16p(&ifnum); + + /* CTL Read */ + devinfo->ctl_read.bRequestType = + USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; + devinfo->ctl_read.bRequest = 1; + devinfo->ctl_read.wValue = cpu_to_le16(0); + devinfo->ctl_read.wIndex = cpu_to_le16p(&ifnum); + } + brcmf_usb_rx_fill_all(devinfo); + return 0; +} + +static void brcmf_usb_down(struct device *dev) +{ + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); + + if (devinfo == NULL) + return; + + brcmf_dbg(TRACE, "enter\n"); + if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_DOWN) + return; + + brcmf_usb_state_change(devinfo, BCMFMAC_USB_STATE_DOWN); + if (devinfo->intr_urb) + usb_kill_urb(devinfo->intr_urb); + + if (devinfo->ctl_urb) + usb_kill_urb(devinfo->ctl_urb); + + if (devinfo->bulk_urb) + usb_kill_urb(devinfo->bulk_urb); + brcmf_usb_free_q(&devinfo->tx_postq, true); + + brcmf_usb_free_q(&devinfo->rx_postq, true); +} + +static int +brcmf_usb_sync_wait(struct brcmf_usbdev_info *devinfo, u16 time) +{ + int ret; + int err = 0; + int ms = time; + + ret = wait_event_interruptible_timeout(devinfo->wait, + devinfo->waitdone == true, (ms * HZ / 1000)); + + if ((devinfo->waitdone == false) || (devinfo->sync_urb_status)) { + brcmf_dbg(ERROR, "timeout(%d) or urb err=%d\n", + ret, devinfo->sync_urb_status); + err = -EINVAL; + } + devinfo->waitdone = false; + return err; +} + +static void +brcmf_usb_sync_complete(struct urb *urb) +{ + struct brcmf_usbdev_info *devinfo = + (struct brcmf_usbdev_info *)urb->context; + + devinfo->waitdone = true; + wake_up_interruptible(&devinfo->wait); + devinfo->sync_urb_status = urb->status; +} + +static bool brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd, + void *buffer, int buflen) +{ + int ret = 0; + char *tmpbuf; + u16 size; + + if ((!devinfo) || (devinfo->ctl_urb == NULL)) + return false; + + tmpbuf = kmalloc(buflen, GFP_ATOMIC); + if (!tmpbuf) + return false; + + size = buflen; + devinfo->ctl_urb->transfer_buffer_length = size; + + devinfo->ctl_read.wLength = cpu_to_le16p(&size); + devinfo->ctl_read.bRequestType = USB_DIR_IN | USB_TYPE_VENDOR | + USB_RECIP_INTERFACE; + devinfo->ctl_read.bRequest = cmd; + + usb_fill_control_urb(devinfo->ctl_urb, + devinfo->usbdev, + usb_rcvctrlpipe(devinfo->usbdev, 0), + (unsigned char *) &devinfo->ctl_read, + (void *) tmpbuf, size, + (usb_complete_t)brcmf_usb_sync_complete, devinfo); + + ret = usb_submit_urb(devinfo->ctl_urb, GFP_ATOMIC); + if (ret < 0) { + brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); + kfree(tmpbuf); + return false; + } + + ret = brcmf_usb_sync_wait(devinfo, BRCMF_USB_SYNC_TIMEOUT); + memcpy(buffer, tmpbuf, buflen); + kfree(tmpbuf); + + return (ret == 0); +} + +static bool +brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) +{ + struct bootrom_id_le id; + u32 chipid, chiprev; + + brcmf_dbg(TRACE, "enter\n"); + + if (devinfo == NULL) + return false; + + /* Check if firmware downloaded already by querying runtime ID */ + id.chip = cpu_to_le32(0xDEAD); + brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, + sizeof(struct bootrom_id_le)); + + chipid = le32_to_cpu(id.chip); + chiprev = le32_to_cpu(id.chiprev); + + if ((chipid & 0x4300) == 0x4300) + brcmf_dbg(INFO, "chip %x rev 0x%x\n", chipid, chiprev); + else + brcmf_dbg(INFO, "chip %d rev 0x%x\n", chipid, chiprev); + if (chipid == BRCMF_POSTBOOT_ID) { + brcmf_dbg(INFO, "firmware already downloaded\n"); + brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, + sizeof(struct bootrom_id_le)); + return false; + } else { + devinfo->bus_pub.attrib.devid = chipid; + devinfo->bus_pub.attrib.chiprev = chiprev; + } + return true; +} + +static int +brcmf_usb_resetcfg(struct brcmf_usbdev_info *devinfo) +{ + struct bootrom_id_le id; + u16 wait = 0, wait_time; + + brcmf_dbg(TRACE, "enter\n"); + + if (devinfo == NULL) + return -EINVAL; + + /* Give dongle chance to boot */ + wait_time = BRCMF_USB_DLIMAGE_SPINWAIT; + while (wait < BRCMF_USB_DLIMAGE_LIMIT) { + mdelay(wait_time); + wait += wait_time; + id.chip = cpu_to_le32(0xDEAD); /* Get the ID */ + brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, + sizeof(struct bootrom_id_le)); + if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) + break; + } + + if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) { + brcmf_dbg(INFO, "download done %d ms postboot chip 0x%x/rev 0x%x\n", + wait, le32_to_cpu(id.chip), le32_to_cpu(id.chiprev)); + + brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, + sizeof(struct bootrom_id_le)); + + /* XXX this wait may not be necessary */ + mdelay(BRCMF_USB_RESETCFG_SPINWAIT); + return 0; + } else { + brcmf_dbg(ERROR, "Cannot talk to Dongle. Firmware is not UP, %d ms\n", + wait); + return -EINVAL; + } +} + + +static int +brcmf_usb_dl_send_bulk(struct brcmf_usbdev_info *devinfo, void *buffer, int len) +{ + int ret; + + if ((devinfo == NULL) || (devinfo->bulk_urb == NULL)) + return -EINVAL; + + /* Prepare the URB */ + usb_fill_bulk_urb(devinfo->bulk_urb, devinfo->usbdev, + devinfo->tx_pipe, buffer, len, + (usb_complete_t)brcmf_usb_sync_complete, devinfo); + + devinfo->bulk_urb->transfer_flags |= URB_ZERO_PACKET; + + ret = usb_submit_urb(devinfo->bulk_urb, GFP_ATOMIC); + if (ret) { + brcmf_dbg(ERROR, "usb_submit_urb failed %d\n", ret); + return ret; + } + ret = brcmf_usb_sync_wait(devinfo, BRCMF_USB_SYNC_TIMEOUT); + return ret; +} + +static int +brcmf_usb_dl_writeimage(struct brcmf_usbdev_info *devinfo, u8 *fw, int fwlen) +{ + unsigned int sendlen, sent, dllen; + char *bulkchunk = NULL, *dlpos; + struct rdl_state_le state; + u32 rdlstate, rdlbytes; + int err = 0; + brcmf_dbg(TRACE, "fw %p, len %d\n", fw, fwlen); + + bulkchunk = kmalloc(RDL_CHUNK, GFP_ATOMIC); + if (bulkchunk == NULL) { + err = -ENOMEM; + goto fail; + } + + /* 1) Prepare USB boot loader for runtime image */ + brcmf_usb_dl_cmd(devinfo, DL_START, &state, + sizeof(struct rdl_state_le)); + + rdlstate = le32_to_cpu(state.state); + rdlbytes = le32_to_cpu(state.bytes); + + /* 2) Check we are in the Waiting state */ + if (rdlstate != DL_WAITING) { + brcmf_dbg(ERROR, "Failed to DL_START\n"); + err = -EINVAL; + goto fail; + } + sent = 0; + dlpos = fw; + dllen = fwlen; + + /* Get chip id and rev */ + while (rdlbytes != dllen) { + /* Wait until the usb device reports it received all + * the bytes we sent */ + if ((rdlbytes == sent) && (rdlbytes != dllen)) { + if ((dllen-sent) < RDL_CHUNK) + sendlen = dllen-sent; + else + sendlen = RDL_CHUNK; + + /* simply avoid having to send a ZLP by ensuring we + * never have an even + * multiple of 64 + */ + if (!(sendlen % 64)) + sendlen -= 4; + + /* send data */ + memcpy(bulkchunk, dlpos, sendlen); + if (brcmf_usb_dl_send_bulk(devinfo, bulkchunk, + sendlen)) { + brcmf_dbg(ERROR, "send_bulk failed\n"); + err = -EINVAL; + goto fail; + } + + dlpos += sendlen; + sent += sendlen; + } + if (!brcmf_usb_dl_cmd(devinfo, DL_GETSTATE, &state, + sizeof(struct rdl_state_le))) { + brcmf_dbg(ERROR, "DL_GETSTATE Failed xxxx\n"); + err = -EINVAL; + goto fail; + } + + rdlstate = le32_to_cpu(state.state); + rdlbytes = le32_to_cpu(state.bytes); + + /* restart if an error is reported */ + if (rdlstate == DL_BAD_HDR || rdlstate == DL_BAD_CRC) { + brcmf_dbg(ERROR, "Bad Hdr or Bad CRC state %d\n", + rdlstate); + err = -EINVAL; + goto fail; + } + } + +fail: + kfree(bulkchunk); + brcmf_dbg(TRACE, "err=%d\n", err); + return err; +} + +static int brcmf_usb_dlstart(struct brcmf_usbdev_info *devinfo, u8 *fw, int len) +{ + int err; + + brcmf_dbg(TRACE, "enter\n"); + + if (devinfo == NULL) + return -EINVAL; + + if (devinfo->bus_pub.attrib.devid == 0xDEAD) + return -EINVAL; + + err = brcmf_usb_dl_writeimage(devinfo, fw, len); + if (err == 0) + devinfo->bus_pub.state = BCMFMAC_USB_STATE_DL_DONE; + else + devinfo->bus_pub.state = BCMFMAC_USB_STATE_DL_PENDING; + brcmf_dbg(TRACE, "exit: err=%d\n", err); + + return err; +} + +static int brcmf_usb_dlrun(struct brcmf_usbdev_info *devinfo) +{ + struct rdl_state_le state; + + brcmf_dbg(TRACE, "enter\n"); + if (!devinfo) + return -EINVAL; + + if (devinfo->bus_pub.attrib.devid == 0xDEAD) + return -EINVAL; + + /* Check we are runnable */ + brcmf_usb_dl_cmd(devinfo, DL_GETSTATE, &state, + sizeof(struct rdl_state_le)); + + /* Start the image */ + if (state.state == cpu_to_le32(DL_RUNNABLE)) { + if (!brcmf_usb_dl_cmd(devinfo, DL_GO, &state, + sizeof(struct rdl_state_le))) + return -ENODEV; + if (brcmf_usb_resetcfg(devinfo)) + return -ENODEV; + /* The Dongle may go for re-enumeration. */ + } else { + brcmf_dbg(ERROR, "Dongle not runnable\n"); + return -EINVAL; + } + brcmf_dbg(TRACE, "exit\n"); + return 0; +} + +static bool brcmf_usb_chip_support(int chipid, int chiprev) +{ + switch(chipid) { + case 43235: + case 43236: + case 43238: + return (chiprev == 3); + default: + break; + } + return false; +} + +static int +brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo) +{ + struct brcmf_usb_attrib *attr; + int err; + + brcmf_dbg(TRACE, "enter\n"); + if (devinfo == NULL) + return -ENODEV; + + attr = &devinfo->bus_pub.attrib; + + if (!brcmf_usb_chip_support(attr->devid, attr->chiprev)) { + brcmf_dbg(ERROR, "unsupported chip %d rev %d\n", + attr->devid, attr->chiprev); + return -EINVAL; + } + + if (!devinfo->image) { + brcmf_dbg(ERROR, "No firmware!\n"); + return -ENOENT; + } + + err = brcmf_usb_dlstart(devinfo, + devinfo->image, devinfo->image_len); + if (err == 0) + err = brcmf_usb_dlrun(devinfo); + return err; +} + + +static void brcmf_usb_detach(const struct brcmf_usbdev *bus_pub) +{ + struct brcmf_usbdev_info *devinfo = + (struct brcmf_usbdev_info *)bus_pub; + + brcmf_dbg(TRACE, "devinfo %p\n", devinfo); + + /* store the image globally */ + g_image.data = devinfo->image; + g_image.len = devinfo->image_len; + + /* free the URBS */ + brcmf_usb_free_q(&devinfo->rx_freeq, false); + brcmf_usb_free_q(&devinfo->tx_freeq, false); + + usb_free_urb(devinfo->intr_urb); + usb_free_urb(devinfo->ctl_urb); + usb_free_urb(devinfo->bulk_urb); + + kfree(devinfo->tx_reqs); + kfree(devinfo->rx_reqs); + kfree(devinfo); +} + +#define TRX_MAGIC 0x30524448 /* "HDR0" */ +#define TRX_VERSION 1 /* Version 1 */ +#define TRX_MAX_LEN 0x3B0000 /* Max length */ +#define TRX_NO_HEADER 1 /* Do not write TRX header */ +#define TRX_MAX_OFFSET 3 /* Max number of individual files */ +#define TRX_UNCOMP_IMAGE 0x20 /* Trx contains uncompressed image */ + +struct trx_header_le { + __le32 magic; /* "HDR0" */ + __le32 len; /* Length of file including header */ + __le32 crc32; /* CRC from flag_version to end of file */ + __le32 flag_version; /* 0:15 flags, 16:31 version */ + __le32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of + * header */ +}; + +static int check_file(const u8 *headers) +{ + struct trx_header_le *trx; + int actual_len = -1; + + /* Extract trx header */ + trx = (struct trx_header_le *) headers; + if (trx->magic != cpu_to_le32(TRX_MAGIC)) + return -1; + + headers += sizeof(struct trx_header_le); + + if (le32_to_cpu(trx->flag_version) & TRX_UNCOMP_IMAGE) { + actual_len = le32_to_cpu(trx->offsets[TRX_OFFSETS_DLFWLEN_IDX]); + return actual_len + sizeof(struct trx_header_le); + } + return -1; +} + +static int brcmf_usb_get_fw(struct brcmf_usbdev_info *devinfo) +{ + s8 *fwname; + const struct firmware *fw; + int err; + + devinfo->image = g_image.data; + devinfo->image_len = g_image.len; + + /* + * if we have an image we can leave here. + */ + if (devinfo->image) + return 0; + + fwname = BRCMF_USB_FW_NAME; + + err = request_firmware(&fw, fwname, devinfo->dev); + if (!fw) { + brcmf_dbg(ERROR, "fail to request firmware %s\n", fwname); + return err; + } + if (check_file(fw->data) < 0) { + brcmf_dbg(ERROR, "invalid firmware %s\n", fwname); + return -EINVAL; + } + + devinfo->image = kmalloc(fw->size, GFP_ATOMIC); /* plus nvram */ + if (!devinfo->image) + return -ENOMEM; + + memcpy(devinfo->image, fw->data, fw->size); + devinfo->image_len = fw->size; + + release_firmware(fw); + return 0; +} + + +static +struct brcmf_usbdev *brcmf_usb_attach(int nrxq, int ntxq, struct device *dev) +{ + struct brcmf_usbdev_info *devinfo; + + devinfo = kzalloc(sizeof(struct brcmf_usbdev_info), GFP_ATOMIC); + if (devinfo == NULL) + return NULL; + + devinfo->bus_pub.nrxq = nrxq; + devinfo->rx_low_watermark = nrxq / 2; + devinfo->bus_pub.devinfo = devinfo; + devinfo->bus_pub.ntxq = ntxq; + + /* flow control when too many tx urbs posted */ + devinfo->tx_low_watermark = ntxq / 4; + devinfo->tx_high_watermark = devinfo->tx_low_watermark * 3; + devinfo->dev = dev; + devinfo->usbdev = usbdev_probe_info.usb; + devinfo->tx_pipe = usbdev_probe_info.tx_pipe; + devinfo->rx_pipe = usbdev_probe_info.rx_pipe; + devinfo->rx_pipe2 = usbdev_probe_info.rx_pipe2; + devinfo->intr_pipe = usbdev_probe_info.intr_pipe; + + devinfo->interval = usbdev_probe_info.interval; + devinfo->intr_size = usbdev_probe_info.intr_size; + + memcpy(&devinfo->probe_info, &usbdev_probe_info, + sizeof(struct brcmf_usb_probe_info)); + devinfo->bus_pub.bus_mtu = BRCMF_USB_MAX_PKT_SIZE; + + /* Initialize other structure content */ + init_waitqueue_head(&devinfo->ioctl_resp_wait); + + /* Initialize the spinlocks */ + spin_lock_init(&devinfo->qlock); + + INIT_LIST_HEAD(&devinfo->rx_freeq); + INIT_LIST_HEAD(&devinfo->rx_postq); + + INIT_LIST_HEAD(&devinfo->tx_freeq); + INIT_LIST_HEAD(&devinfo->tx_postq); + + devinfo->rx_reqs = brcmf_usbdev_qinit(&devinfo->rx_freeq, nrxq); + if (!devinfo->rx_reqs) + goto error; + + devinfo->tx_reqs = brcmf_usbdev_qinit(&devinfo->tx_freeq, ntxq); + if (!devinfo->tx_reqs) + goto error; + + devinfo->intr_urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!devinfo->intr_urb) { + brcmf_dbg(ERROR, "usb_alloc_urb (intr) failed\n"); + goto error; + } + devinfo->ctl_urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!devinfo->ctl_urb) { + brcmf_dbg(ERROR, "usb_alloc_urb (ctl) failed\n"); + goto error; + } + devinfo->rxctl_deferrespok = 0; + + devinfo->bulk_urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!devinfo->bulk_urb) { + brcmf_dbg(ERROR, "usb_alloc_urb (bulk) failed\n"); + goto error; + } + + init_waitqueue_head(&devinfo->wait); + if (!brcmf_usb_dlneeded(devinfo)) + return &devinfo->bus_pub; + + brcmf_dbg(TRACE, "start fw downloading\n"); + if (brcmf_usb_get_fw(devinfo)) + goto error; + + if (brcmf_usb_fw_download(devinfo)) + goto error; + + return &devinfo->bus_pub; + +error: + brcmf_dbg(ERROR, "failed!\n"); + brcmf_usb_detach(&devinfo->bus_pub); + return NULL; +} + +static int brcmf_usb_probe_cb(struct device *dev, const char *desc, + u32 bustype, u32 hdrlen) +{ + struct brcmf_bus *bus = NULL; + struct brcmf_usbdev *bus_pub = NULL; + int ret; + + + bus_pub = brcmf_usb_attach(BRCMF_USB_NRXQ, BRCMF_USB_NTXQ, dev); + if (!bus_pub) { + ret = -ENODEV; + goto fail; + } + + bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); + if (!bus) { + ret = -ENOMEM; + goto fail; + } + + bus_pub->bus = bus; + bus->brcmf_bus_txdata = brcmf_usb_tx; + bus->brcmf_bus_init = brcmf_usb_up; + bus->brcmf_bus_stop = brcmf_usb_down; + bus->brcmf_bus_txctl = brcmf_usb_tx_ctlpkt; + bus->brcmf_bus_rxctl = brcmf_usb_rx_ctlpkt; + bus->type = bustype; + bus->bus_priv.usb = bus_pub; + dev_set_drvdata(dev, bus); + + /* Attach to the common driver interface */ + ret = brcmf_attach(hdrlen, dev); + if (ret) { + brcmf_dbg(ERROR, "dhd_attach failed\n"); + goto fail; + } + + ret = brcmf_bus_start(dev); + if (ret == -ENOLINK) { + brcmf_dbg(ERROR, "dongle is not responding\n"); + brcmf_detach(dev); + goto fail; + } + + /* add interface and open for business */ + ret = brcmf_add_if(dev, 0, "wlan%d", NULL); + if (ret) { + brcmf_dbg(ERROR, "Add primary net device interface failed!!\n"); + brcmf_detach(dev); + goto fail; + } + + return 0; +fail: + /* Release resources in reverse order */ + if (bus_pub) + brcmf_usb_detach(bus_pub); + kfree(bus); + return ret; +} + +static void +brcmf_usb_disconnect_cb(struct brcmf_usbdev *bus_pub) +{ + if (!bus_pub) + return; + brcmf_dbg(TRACE, "enter: bus_pub %p\n", bus_pub); + + brcmf_detach(bus_pub->devinfo->dev); + kfree(bus_pub->bus); + brcmf_usb_detach(bus_pub); + +} + +static int +brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + int ep; + struct usb_endpoint_descriptor *endpoint; + int ret = 0; + struct usb_device *usb = interface_to_usbdev(intf); + int num_of_eps; + u8 endpoint_num; + + brcmf_dbg(TRACE, "enter\n"); + + usbdev_probe_info.usb = usb; + usbdev_probe_info.intf = intf; + + if (id != NULL) { + usbdev_probe_info.vid = id->idVendor; + usbdev_probe_info.pid = id->idProduct; + } + + usb_set_intfdata(intf, &usbdev_probe_info); + + /* Check that the device supports only one configuration */ + if (usb->descriptor.bNumConfigurations != 1) { + ret = -1; + goto fail; + } + + if (usb->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { + ret = -1; + goto fail; + } + + /* + * Only the BDC interface configuration is supported: + * Device class: USB_CLASS_VENDOR_SPEC + * if0 class: USB_CLASS_VENDOR_SPEC + * if0/ep0: control + * if0/ep1: bulk in + * if0/ep2: bulk out (ok if swapped with bulk in) + */ + if (CONFIGDESC(usb)->bNumInterfaces != 1) { + ret = -1; + goto fail; + } + + /* Check interface */ + if (IFDESC(usb, CONTROL_IF).bInterfaceClass != USB_CLASS_VENDOR_SPEC || + IFDESC(usb, CONTROL_IF).bInterfaceSubClass != 2 || + IFDESC(usb, CONTROL_IF).bInterfaceProtocol != 0xff) { + brcmf_dbg(ERROR, "invalid control interface: class %d, subclass %d, proto %d\n", + IFDESC(usb, CONTROL_IF).bInterfaceClass, + IFDESC(usb, CONTROL_IF).bInterfaceSubClass, + IFDESC(usb, CONTROL_IF).bInterfaceProtocol); + ret = -1; + goto fail; + } + + /* Check control endpoint */ + endpoint = &IFEPDESC(usb, CONTROL_IF, 0); + if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + != USB_ENDPOINT_XFER_INT) { + brcmf_dbg(ERROR, "invalid control endpoint %d\n", + endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); + ret = -1; + goto fail; + } + + endpoint_num = endpoint->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; + usbdev_probe_info.intr_pipe = usb_rcvintpipe(usb, endpoint_num); + + usbdev_probe_info.rx_pipe = 0; + usbdev_probe_info.rx_pipe2 = 0; + usbdev_probe_info.tx_pipe = 0; + num_of_eps = IFDESC(usb, BULK_IF).bNumEndpoints - 1; + + /* Check data endpoints and get pipes */ + for (ep = 1; ep <= num_of_eps; ep++) { + endpoint = &IFEPDESC(usb, BULK_IF, ep); + if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != + USB_ENDPOINT_XFER_BULK) { + brcmf_dbg(ERROR, "invalid data endpoint %d\n", ep); + ret = -1; + goto fail; + } + + endpoint_num = endpoint->bEndpointAddress & + USB_ENDPOINT_NUMBER_MASK; + if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) + == USB_DIR_IN) { + if (!usbdev_probe_info.rx_pipe) { + usbdev_probe_info.rx_pipe = + usb_rcvbulkpipe(usb, endpoint_num); + } else { + usbdev_probe_info.rx_pipe2 = + usb_rcvbulkpipe(usb, endpoint_num); + } + } else { + usbdev_probe_info.tx_pipe = + usb_sndbulkpipe(usb, endpoint_num); + } + } + + /* Allocate interrupt URB and data buffer */ + /* RNDIS says 8-byte intr, our old drivers used 4-byte */ + if (IFEPDESC(usb, CONTROL_IF, 0).wMaxPacketSize == cpu_to_le16(16)) + usbdev_probe_info.intr_size = 8; + else + usbdev_probe_info.intr_size = 4; + + usbdev_probe_info.interval = IFEPDESC(usb, CONTROL_IF, 0).bInterval; + + usbdev_probe_info.device_speed = usb->speed; + if (usb->speed == USB_SPEED_HIGH) + brcmf_dbg(INFO, "Broadcom high speed USB wireless device detected\n"); + else + brcmf_dbg(INFO, "Broadcom full speed USB wireless device detected\n"); + + ret = brcmf_usb_probe_cb(&usb->dev, "", USB_BUS, 0); + if (ret) + goto fail; + + /* Success */ + return 0; + +fail: + brcmf_dbg(ERROR, "failed with errno %d\n", ret); + usb_set_intfdata(intf, NULL); + return ret; + +} + +static void +brcmf_usb_disconnect(struct usb_interface *intf) +{ + struct usb_device *usb = interface_to_usbdev(intf); + + brcmf_dbg(TRACE, "enter\n"); + brcmf_usb_disconnect_cb(brcmf_usb_get_buspub(&usb->dev)); + usb_set_intfdata(intf, NULL); +} + +/* + * only need to signal the bus being down and update the suspend state. + */ +static int brcmf_usb_suspend(struct usb_interface *intf, pm_message_t state) +{ + struct usb_device *usb = interface_to_usbdev(intf); + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(&usb->dev); + + brcmf_dbg(TRACE, "enter\n"); + devinfo->bus_pub.state = BCMFMAC_USB_STATE_DOWN; + devinfo->suspend_state = USBOS_SUSPEND_STATE_SUSPENDED; + return 0; +} + +/* + * mark suspend state active and crank up the bus. + */ +static int brcmf_usb_resume(struct usb_interface *intf) +{ + struct usb_device *usb = interface_to_usbdev(intf); + struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(&usb->dev); + + brcmf_dbg(TRACE, "enter\n"); + devinfo->suspend_state = USBOS_SUSPEND_STATE_DEVICE_ACTIVE; + brcmf_bus_start(&usb->dev); + return 0; +} + +#define BRCMF_USB_VENDOR_ID_BROADCOM 0x0a5c +#define BRCMF_USB_DEVICE_ID_43236 0xbd17 +#define BRCMF_USB_DEVICE_ID_BCMFW 0x0bdc + +static struct usb_device_id brcmf_usb_devid_table[] = { + { USB_DEVICE(BRCMF_USB_VENDOR_ID_BROADCOM, BRCMF_USB_DEVICE_ID_43236) }, + /* special entry for device with firmware loaded and running */ + { USB_DEVICE(BRCMF_USB_VENDOR_ID_BROADCOM, BRCMF_USB_DEVICE_ID_BCMFW) }, + { } +}; +MODULE_DEVICE_TABLE(usb, brcmf_usb_devid_table); +MODULE_FIRMWARE(BRCMF_USB_FW_NAME); + +/* TODO: suspend and resume entries */ +static struct usb_driver brcmf_usbdrvr = { + .name = KBUILD_MODNAME, + .probe = brcmf_usb_probe, + .disconnect = brcmf_usb_disconnect, + .id_table = brcmf_usb_devid_table, + .suspend = brcmf_usb_suspend, + .resume = brcmf_usb_resume, + .supports_autosuspend = 1 +}; + +void brcmf_usb_exit(void) +{ + usb_deregister(&brcmf_usbdrvr); + kfree(g_image.data); + g_image.data = NULL; + g_image.len = 0; +} + +int brcmf_usb_init(void) +{ + return usb_register(&brcmf_usbdrvr); +} diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.h b/drivers/net/wireless/brcm80211/brcmfmac/usb.h new file mode 100644 index 000000000000..b31da7b83ff7 --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.h @@ -0,0 +1,84 @@ +/* + * 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 BRCMFMAC_USB_H +#define BRCMFMAC_USB_H + +enum brcmf_usb_state { + BCMFMAC_USB_STATE_DL_PENDING, + BCMFMAC_USB_STATE_DL_DONE, + BCMFMAC_USB_STATE_UP, + BCMFMAC_USB_STATE_DOWN, + BCMFMAC_USB_STATE_PNP_FWDL, + BCMFMAC_USB_STATE_DISCONNECT, + BCMFMAC_USB_STATE_SLEEP +}; + +enum brcmf_usb_pnp_state { + BCMFMAC_USB_PNP_DISCONNECT, + BCMFMAC_USB_PNP_SLEEP, + BCMFMAC_USB_PNP_RESUME, +}; + +struct brcmf_stats { + u32 tx_errors; + u32 tx_packets; + u32 tx_multicast; + u32 tx_ctlpkts; + u32 tx_ctlerrs; + u32 tx_dropped; + u32 tx_flushed; + u32 rx_errors; + u32 rx_packets; + u32 rx_multicast; + u32 rx_ctlpkts; + u32 rx_ctlerrs; + u32 rx_dropped; + u32 rx_flushed; + +}; + +struct brcmf_usb_attrib { + int bustype; + int vid; + int pid; + int devid; + int chiprev; /* chip revsion number */ + int mtu; + int nchan; /* Data Channels */ + int has_2nd_bulk_in_ep; +}; + +struct brcmf_usbdev_info; + +struct brcmf_usbdev { + struct brcmf_bus *bus; + struct brcmf_usbdev_info *devinfo; + enum brcmf_usb_state state; + struct brcmf_stats stats; + int ntxq, nrxq, rxsize; + u32 bus_mtu; + struct brcmf_usb_attrib attrib; +}; + +/* IO Request Block (IRB) */ +struct brcmf_usbreq { + struct list_head list; + struct brcmf_usbdev_info *devinfo; + struct urb *urb; + struct sk_buff *skb; +}; + +#endif /* BRCMFMAC_USB_H */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb_rdl.h b/drivers/net/wireless/brcm80211/brcmfmac/usb_rdl.h new file mode 100644 index 000000000000..0a35c51c3da2 --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb_rdl.h @@ -0,0 +1,75 @@ +/* + * 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 _USB_RDL_H +#define _USB_RDL_H + +/* Control messages: bRequest values */ +#define DL_GETSTATE 0 /* returns the rdl_state_t struct */ +#define DL_CHECK_CRC 1 /* currently unused */ +#define DL_GO 2 /* execute downloaded image */ +#define DL_START 3 /* initialize dl state */ +#define DL_REBOOT 4 /* reboot the device in 2 seconds */ +#define DL_GETVER 5 /* returns the bootrom_id_t struct */ +#define DL_GO_PROTECTED 6 /* execute the downloaded code and set reset + * event to occur in 2 seconds. It is the + * responsibility of the downloaded code to + * clear this event + */ +#define DL_EXEC 7 /* jump to a supplied address */ +#define DL_RESETCFG 8 /* To support single enum on dongle + * - Not used by bootloader + */ +#define DL_DEFER_RESP_OK 9 /* Potentially defer the response to setup + * if resp unavailable + */ + +/* states */ +#define DL_WAITING 0 /* waiting to rx first pkt */ +#define DL_READY 1 /* hdr was good, waiting for more of the + * compressed image */ +#define DL_BAD_HDR 2 /* hdr was corrupted */ +#define DL_BAD_CRC 3 /* compressed image was corrupted */ +#define DL_RUNNABLE 4 /* download was successful,waiting for go cmd */ +#define DL_START_FAIL 5 /* failed to initialize correctly */ +#define DL_NVRAM_TOOBIG 6 /* host specified nvram data exceeds DL_NVRAM + * value */ +#define DL_IMAGE_TOOBIG 7 /* download image too big (exceeds DATA_START + * for rdl) */ + +struct rdl_state_le { + __le32 state; + __le32 bytes; +}; + +struct bootrom_id_le { + __le32 chip; /* Chip id */ + __le32 chiprev; /* Chip rev */ + __le32 ramsize; /* Size of RAM */ + __le32 remapbase; /* Current remap base address */ + __le32 boardtype; /* Type of board */ + __le32 boardrev; /* Board revision */ +}; + +#define RDL_CHUNK 1500 /* size of each dl transfer */ + +#define TRX_OFFSETS_DLFWLEN_IDX 0 +#define TRX_OFFSETS_JUMPTO_IDX 1 +#define TRX_OFFSETS_NVM_LEN_IDX 2 + +#define TRX_OFFSETS_DLBASE_IDX 0 + +#endif /* _USB_RDL_H */ -- GitLab From 52e1409f72d629644b496db80c119e04ebabad90 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:09 +0100 Subject: [PATCH 0960/1846] brcm80211: fmac: make sdio firmware filename specific The sdio driver part uses firmware name brcmfmac.bin. With addition of usb this name is too generic. This patch renames the filename to brcmfmac-sdio.bin. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 253fc20adf88..0b467b08604d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -309,10 +309,10 @@ 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); +#define BRCMF_SDIO_FW_NAME "brcm/brcmfmac-sdio.bin" +#define BRCMF_SDIO_NV_NAME "brcm/brcmfmac-sdio.txt" +MODULE_FIRMWARE(BRCMF_SDIO_FW_NAME); +MODULE_FIRMWARE(BRCMF_SDIO_NV_NAME); #define BRCMF_IDLE_IMMEDIATE (-1) /* Enter idle immediately */ #define BRCMF_IDLE_ACTIVE 0 /* Do not request any SD clock change @@ -3202,7 +3202,7 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_sdio *bus) brcmf_dbg(INFO, "Enter\n"); - ret = request_firmware(&bus->firmware, BRCMFMAC_FW_NAME, + ret = request_firmware(&bus->firmware, BRCMF_SDIO_FW_NAME, &bus->sdiodev->func[2]->dev); if (ret) { brcmf_dbg(ERROR, "Fail to request firmware %d\n", ret); @@ -3299,7 +3299,7 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_sdio *bus) char *bufp; int ret; - ret = request_firmware(&bus->firmware, BRCMFMAC_NV_NAME, + ret = request_firmware(&bus->firmware, BRCMF_SDIO_NV_NAME, &bus->sdiodev->func[2]->dev); if (ret) { brcmf_dbg(ERROR, "Fail to request nvram %d\n", ret); -- GitLab From 3fccdcf5091eaaa0d7582bedbc035163b40714b9 Mon Sep 17 00:00:00 2001 From: Tim Gardner Date: Thu, 9 Feb 2012 18:19:52 -0600 Subject: [PATCH 0961/1846] rtlwifi: rtl8192se firmware load can overflow target buffer Define RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE which represents the maximimum possible firmware file size. Use it in the definition of the buffer which receives the firmware file data. Set RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE closer to the actual size of the firmware file, e.g., 90000 (down from hard coded 164000). The current size of rtlwifi/rtl8192sefw.bin is 88856. Set max_fw_size to RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE for the size limit check. Fix the error case where max_fw_size is not cleared if the size limit check fails. Cc: Chaoming Li Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Tim Gardner Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192se/fw.h | 3 ++- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.h b/drivers/net/wireless/rtlwifi/rtl8192se/fw.h index babe85d4b694..b4afff626437 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.h +++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.h @@ -30,6 +30,7 @@ #define __REALTEK_FIRMWARE92S_H__ #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 +#define RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE 90000 #define RTL8190_CPU_START_OFFSET 0x80 /* Firmware Local buffer size. 64k */ #define MAX_FIRMWARE_CODE_SIZE 0xFF00 @@ -217,7 +218,7 @@ struct rt_firmware { u8 fw_emem[RTL8190_MAX_FIRMWARE_CODE_SIZE]; u32 fw_imem_len; u32 fw_emem_len; - u8 sz_fw_tmpbuffer[164000]; + u8 sz_fw_tmpbuffer[RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE]; u32 sz_fw_tmpbufferlen; u16 cmdpacket_fragthresold; }; diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index ca38dd9f3564..345d752137fa 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -108,6 +108,7 @@ static void rtl92se_fw_cb(const struct firmware *firmware, void *context) if (firmware->size > rtlpriv->max_fw_size) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Firmware is too big!\n"); + rtlpriv->max_fw_size = 0; release_firmware(firmware); return; } @@ -232,7 +233,7 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) return 1; } - rtlpriv->max_fw_size = sizeof(struct rt_firmware); + rtlpriv->max_fw_size = RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE; pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" "Loading firmware %s\n", rtlpriv->cfg->fw_name); -- GitLab From b6603036ad87244bd39ed7bc0612009df7694f5e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:08 +0100 Subject: [PATCH 0962/1846] iwlegacy: dump stack when fail to gain access to the device Print dump stack when the device is not responding. This should give some more clue about the reason of failure. Also change the message we print, since "MAC in deep sleep" is kinda confusing. On the way add unlikely(), as fail to gain NIC access is hmm ... unlikely. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 04ec38e5eaaf..3900967a79f6 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -111,9 +111,10 @@ _il_grab_nic_access(struct il_priv *il) _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) { + if (unlikely(ret < 0)) { val = _il_rd(il, CSR_GP_CNTRL); - IL_ERR("MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); + WARN_ONCE(1, "Timeout waiting for ucode processor access " + "(CSR_GP_CNTRL 0x%08x)\n", val); _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } -- GitLab From 1e0f32a43ae652eaa5b23dc06852938555cb8da1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:09 +0100 Subject: [PATCH 0963/1846] iwlegacy: always check if got h/w access before write Before we write to the device register always check if _il_grap_nic_access() was successful. Change type return type _il_grap_nic_access() to bool, and add likely()/unlikely() statements. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/iwlegacy/common.c | 10 ++++----- drivers/net/wireless/iwlegacy/common.h | 27 +++++++++++++----------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 235812ac6a0d..90c9bfb089f4 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -3778,7 +3778,7 @@ 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)) + if (likely(_il_grab_nic_access(il))) _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 3900967a79f6..6dbd11f76f84 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -81,7 +81,7 @@ il_clear_bit(struct il_priv *p, u32 r, u32 m) } EXPORT_SYMBOL(il_clear_bit); -int +bool _il_grab_nic_access(struct il_priv *il) { int ret; @@ -116,10 +116,10 @@ _il_grab_nic_access(struct il_priv *il) WARN_ONCE(1, "Timeout waiting for ucode processor access " "(CSR_GP_CNTRL 0x%08x)\n", val); _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); - return -EIO; + return false; } - return 0; + return true; } EXPORT_SYMBOL_GPL(_il_grab_nic_access); @@ -161,7 +161,7 @@ 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)) { + if (likely(_il_grab_nic_access(il))) { _il_wr_prph(il, addr, val); _il_release_nic_access(il); } @@ -194,7 +194,7 @@ 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 (likely(_il_grab_nic_access(il))) { _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); _il_wr(il, HBUS_TARG_MEM_WDAT, val); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 708095644f17..1dfaa58acc45 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -2103,7 +2103,7 @@ irqreturn_t il_isr(int irq, void *data); extern void il_set_bit(struct il_priv *p, u32 r, u32 m); extern void il_clear_bit(struct il_priv *p, u32 r, u32 m); -extern int _il_grab_nic_access(struct il_priv *il); +extern bool _il_grab_nic_access(struct il_priv *il); extern int _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout); extern int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout); extern u32 il_rd_prph(struct il_priv *il, u32 reg); @@ -2168,7 +2168,7 @@ 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)) { + if (likely(_il_grab_nic_access(il))) { _il_wr(il, reg, value); _il_release_nic_access(il); } @@ -2197,9 +2197,10 @@ 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_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)); - _il_release_nic_access(il); + if (likely(_il_grab_nic_access(il))) { + _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)); + _il_release_nic_access(il); + } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -2209,9 +2210,10 @@ 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_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits)); - _il_release_nic_access(il); + if (likely(_il_grab_nic_access(il))) { + _il_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits)); + _il_release_nic_access(il); + } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -2222,10 +2224,11 @@ il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask) 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); + if (likely(_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); } -- GitLab From 4e5ea2088b699ae86ffd96b53b916a3966535fcb Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:10 +0100 Subject: [PATCH 0964/1846] iwlegacy: cleanup/fix memory barriers wmb(), rmb() are not needed when writel(), readl() are used as accessors for MMIO. We use them indirectly via iowrite32(), ioread32(). What is needed mmiowb(), for synchronizing writes coming from different CPUs on PCIe bridge (see in patch comments). This fortunately is not needed on x86, where mmiowb() is just defined as compiler barrier. As iwlegacy devices are most likely not used on anything other than x86, this is not so important fix. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 2 -- drivers/net/wireless/iwlegacy/common.h | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 6dbd11f76f84..50308da8aee3 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -179,7 +179,6 @@ il_read_targ_mem(struct il_priv *il, u32 addr) _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); @@ -196,7 +195,6 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) spin_lock_irqsave(&il->reg_lock, reg_flags); if (likely(_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); } diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 1dfaa58acc45..df9b5b462839 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -2146,6 +2146,13 @@ 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); + /* + * In above we are reading CSR_GP_CNTRL register, what will flush any + * previous writes, but still want write, which clear MAC_ACCESS_REQ + * bit, be performed on PCI bus before any other writes scheduled on + * different CPUs (after we drop reg_lock). + */ + mmiowb(); } static inline u32 @@ -2179,7 +2186,6 @@ 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); } @@ -2187,7 +2193,6 @@ 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); } -- GitLab From a5f16137ab8aff1208d3ea013033d0d38f15a61f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:11 +0100 Subject: [PATCH 0965/1846] iwlegacy: use writeb,writel,readl directly That change will save us some CPU cycles at run time. Having port-based I/O seems to be not possible for PCIe devices. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 6 +++--- drivers/net/wireless/iwlegacy/4965-mac.c | 6 +++--- drivers/net/wireless/iwlegacy/common.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index aa8f5c0bd642..63ec05b15ba3 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3655,7 +3655,7 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /*********************** * 3. Read REV Register * ********************/ - il->hw_base = pci_iomap(pdev, 0, 0); + il->hw_base = pci_ioremap_bar(pdev, 0); if (!il->hw_base) { err = -ENODEV; goto out_pci_release_regions; @@ -3780,7 +3780,7 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_eeprom_free: il_eeprom_free(il); out_iounmap: - pci_iounmap(pdev, il->hw_base); + iounmap(il->hw_base); out_pci_release_regions: pci_release_regions(pdev); out_pci_disable_device: @@ -3860,7 +3860,7 @@ il3945_pci_remove(struct pci_dev *pdev) free_irq(pdev->irq, il); pci_disable_msi(pdev); - pci_iounmap(pdev, il->hw_base); + iounmap(il->hw_base); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 90c9bfb089f4..7bf78bf866ca 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6224,7 +6224,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /*********************** * 3. Read REV register ***********************/ - il->hw_base = pci_iomap(pdev, 0, 0); + il->hw_base = pci_ioremap_bar(pdev, 0); if (!il->hw_base) { err = -ENODEV; goto out_pci_release_regions; @@ -6356,7 +6356,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_free_eeprom: il_eeprom_free(il); out_iounmap: - pci_iounmap(pdev, il->hw_base); + iounmap(il->hw_base); out_pci_release_regions: pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); @@ -6438,7 +6438,7 @@ il4965_pci_remove(struct pci_dev *pdev) free_irq(il->pci_dev->irq, il); pci_disable_msi(il->pci_dev); - pci_iounmap(pdev, il->hw_base); + iounmap(il->hw_base); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index df9b5b462839..fd2a4eea85e4 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -2114,20 +2114,20 @@ extern void il_write_targ_mem(struct il_priv *il, u32 addr, u32 val); static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) { - iowrite8(val, il->hw_base + ofs); + writeb(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); + writel(val, il->hw_base + ofs); } static inline u32 _il_rd(struct il_priv *il, u32 ofs) { - return ioread32(il->hw_base + ofs); + return readl(il->hw_base + ofs); } static inline void -- GitLab From 93a984a4eec83f45abddb80724da7dcb85b4db6b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:12 +0100 Subject: [PATCH 0966/1846] iwlegacy: regulatory_bands is not an ops Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945.c | 39 +++++++++++++++++--------- drivers/net/wireless/iwlegacy/4965.c | 19 +++++++------ drivers/net/wireless/iwlegacy/common.c | 10 +++---- drivers/net/wireless/iwlegacy/common.h | 3 +- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 6c1ae5fab899..66a5dc072eb2 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2646,18 +2646,9 @@ static struct il_lib_ops il3945_lib = { .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, - }, + .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, @@ -2707,7 +2698,17 @@ static struct il_cfg il3945_bg_cfg = { .set_l0s = false, .use_bsm = true, .led_compensation = 64, - .wd_timeout = IL_DEF_WD_TIMEOUT + .wd_timeout = IL_DEF_WD_TIMEOUT, + + .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, + }, }; static struct il_cfg il3945_abg_cfg = { @@ -2726,7 +2727,17 @@ static struct il_cfg il3945_abg_cfg = { .set_l0s = false, .use_bsm = true, .led_compensation = 64, - .wd_timeout = IL_DEF_WD_TIMEOUT + .wd_timeout = IL_DEF_WD_TIMEOUT, + + .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, + }, }; DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 79e4e7971338..aea84bf4e935 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2217,14 +2217,6 @@ static struct il_lib_ops il4965_lib = { .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, }, @@ -2288,6 +2280,17 @@ struct il_cfg il4965_cfg = { .ucode_tracing = true, .sensitivity_calib_by_driver = true, .chain_noise_calib_by_driver = true, + + .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 + }, + }; /* Module firmware */ diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 50308da8aee3..5a7ad52db1d9 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -798,8 +798,8 @@ il_init_band_reference(const struct il_priv *il, int eep_band, const struct il_eeprom_channel **eeprom_ch_info, const u8 **eeprom_ch_idx) { - u32 offset = - il->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; + u32 offset = il->cfg->regulatory_bands[eep_band - 1]; + switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); @@ -1000,10 +1000,8 @@ il_init_channel_map(struct il_priv *il) } /* Check if we do have HT40 channels */ - if (il->ops->lib->eeprom_ops.regulatory_bands[5] == - EEPROM_REGULATORY_BAND_NO_HT40 && - il->ops->lib->eeprom_ops.regulatory_bands[6] == - EEPROM_REGULATORY_BAND_NO_HT40) + if (il->cfg->regulatory_bands[5] == EEPROM_REGULATORY_BAND_NO_HT40 && + il->cfg->regulatory_bands[6] == EEPROM_REGULATORY_BAND_NO_HT40) return 0; /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */ diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index fd2a4eea85e4..37bc40636c1e 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -426,7 +426,6 @@ struct il_eeprom_calib_info { #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); }; @@ -1769,6 +1768,8 @@ struct il_cfg { const bool ucode_tracing; const bool sensitivity_calib_by_driver; const bool chain_noise_calib_by_driver; + + const u32 regulatory_bands[7]; }; /*************************** -- GitLab From 3dfea27d103e9913698cf1a2c86745a74c7c556b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:13 +0100 Subject: [PATCH 0967/1846] iwlegacy: gather all 4965 handlers in one place Handers belongs logically into 4965-mac.c file. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 307 +++++++++++++++++++++- drivers/net/wireless/iwlegacy/4965.c | 312 ----------------------- drivers/net/wireless/iwlegacy/4965.h | 9 - drivers/net/wireless/iwlegacy/common.h | 2 - 4 files changed, 305 insertions(+), 325 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 7bf78bf866ca..4560021bb96d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2548,6 +2548,308 @@ il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, 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); +} + +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->hw_params.bcast_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); + } +} + +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; + } +} + +/** + * 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].skbs[idx]); + 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; + struct sk_buff *skb; + + /* 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); + + skb = il->txq[txq_id].skbs[idx]; + if (WARN_ON_ONCE(skb == NULL)) + return -1; + hdr = (struct ieee80211_hdr *) skb->data; + + 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; +} + +/** + * il4965_hdl_tx - Handle standard (non-aggregation) Tx response + */ +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); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + struct il_tx_queue *txq = &il->txq[txq_id]; + struct sk_buff *skb; + 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; + + skb = txq->skbs[txq->q.read_ptr]; + info = IEEE80211_SKB_CB(skb); + memset(&info->status, 0, sizeof(info->status)); + + hdr = (struct ieee80211_hdr *) skb->data; + 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); +} + /** * translate ucode response to mac80211 tx status control values */ @@ -3868,10 +4170,11 @@ il4965_setup_handlers(struct il_priv *il) /* Rx handlers */ il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; il->handlers[N_RX_MPDU] = il4965_hdl_rx; + il->handlers[N_RX] = il4965_hdl_rx; /* block ack */ il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; - /* Set up hardware specific Rx handlers */ - il->ops->lib->handler_setup(il); + /* Tx response */ + il->handlers[C_TX] = il4965_hdl_tx; } /** diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index aea84bf4e935..cf49a7af6c6e 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1737,317 +1737,6 @@ il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) 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; -} - -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 - */ -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].skbs[idx]); - 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; - struct sk_buff *skb; - - /* 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); - - skb = il->txq[txq_id].skbs[idx]; - if (WARN_ON_ONCE(skb == NULL)) - return -1; - hdr = (struct ieee80211_hdr *) skb->data; - - 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->hw_params.bcast_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_hdl_tx - Handle standard (non-aggregation) Tx response - */ -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); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - struct il_tx_queue *txq = &il->txq[txq_id]; - struct sk_buff *skb; - 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; - - skb = txq->skbs[txq->q.read_ptr]; - info = IEEE80211_SKB_CB(skb); - memset(&info->status, 0, sizeof(info->status)); - - hdr = (struct ieee80211_hdr *) skb->data; - 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); -} - -/* Set up 4965-specific Rx frame reply handlers */ -static void -il4965_handler_setup(struct il_priv *il) -{ - /* Legacy Rx frames */ - il->handlers[N_RX] = il4965_hdl_rx; - /* Tx response */ - il->handlers[C_TX] = il4965_hdl_tx; -} - static struct il_hcmd_ops il4965_hcmd = { .rxon_assoc = il4965_send_rxon_assoc, .commit_rxon = il4965_commit_rxon, @@ -2205,7 +1894,6 @@ 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, - .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/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 83ab60496388..befa7e60e956 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -67,8 +67,6 @@ 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_rx_handle(struct il_priv *il); /* tx */ @@ -84,7 +82,6 @@ int il4965_tx_agg_start(struct il_priv *il, 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 *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); @@ -106,12 +103,6 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, int tx_fifo_id, int scd_retry); -/* 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); - /* scan */ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 37bc40636c1e..1c0d969e9cf7 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1600,8 +1600,6 @@ struct il_lib_ops { 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 */ -- GitLab From 93b7654ec563a929a62da70324e834eeb18a2778 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:14 +0100 Subject: [PATCH 0968/1846] iwlegacy: move debugfs_ops to il_priv Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-debug.c | 6 ++++++ drivers/net/wireless/iwlegacy/3945-mac.c | 3 +++ drivers/net/wireless/iwlegacy/3945.c | 8 -------- drivers/net/wireless/iwlegacy/3945.h | 8 +------- drivers/net/wireless/iwlegacy/4965-debug.c | 6 ++++++ drivers/net/wireless/iwlegacy/4965-mac.c | 3 +++ drivers/net/wireless/iwlegacy/4965.c | 7 ------- drivers/net/wireless/iwlegacy/4965.h | 8 +------- drivers/net/wireless/iwlegacy/common.h | 10 ++++------ drivers/net/wireless/iwlegacy/debug.c | 9 ++++++--- 10 files changed, 30 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 5e1a19fd354d..f767dd106b09 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -503,3 +503,9 @@ il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, kfree(buf); return ret; } + +const struct il_debugfs_ops il3945_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, +}; diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 63ec05b15ba3..b7d5ebc512d3 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3619,6 +3619,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; il->ops = &il3945_ops; +#ifdef CONFIG_IWLEGACY_DEBUGFS + il->debugfs_ops = &il3945_debugfs_ops; +#endif il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 66a5dc072eb2..4e63e7d48a7b 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2651,14 +2651,6 @@ 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 c00a8d30b6fe..1d45075e0d5b 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -595,13 +595,7 @@ 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_general_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos); +extern const struct il_debugfs_ops il3945_debugfs_ops; #endif #endif diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 98ec39f56ba3..c8153fc64f74 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -744,3 +744,9 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, kfree(buf); return ret; } + +const struct il_debugfs_ops il4965_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, +}; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 4560021bb96d..36f85f289a25 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6483,6 +6483,9 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; il->ops = &il4965_ops; +#ifdef CONFIG_IWLEGACY_DEBUGFS + il->debugfs_ops = &il4965_debugfs_ops; +#endif il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index cf49a7af6c6e..34fa3db82292 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1913,13 +1913,6 @@ 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 befa7e60e956..b3fcb8f30fe9 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -928,13 +928,7 @@ 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); +extern const struct il_debugfs_ops il4965_debugfs_ops; #endif /****************************/ diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 1c0d969e9cf7..cd8f27d18b1c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1155,13 +1155,15 @@ struct il_power_mgr { }; 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; const struct il_ops *ops; +#ifdef CONFIG_IWLEGACY_DEBUGFS + const struct il_debugfs_ops *debugfs_ops; +#endif /* temporary frame storage list */ struct list_head free_frames; @@ -1624,10 +1626,6 @@ struct il_lib_ops { /* temperature */ struct il_temp_ops temp_ops; -#ifdef CONFIG_IWLEGACY_DEBUGFS - struct il_debugfs_ops debugfs_ops; -#endif - }; struct il_led_ops { diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index bb7c95607a69..5091db813d66 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -901,7 +901,8 @@ 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->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos); + + return il->debugfs_ops->rx_stats_read(file, user_buf, count, ppos); } static ssize_t @@ -909,7 +910,8 @@ 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->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos); + + return il->debugfs_ops->tx_stats_read(file, user_buf, count, ppos); } static ssize_t @@ -917,7 +919,8 @@ 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->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos); + + return il->debugfs_ops->general_stats_read(file, user_buf, count, ppos); } static ssize_t -- GitLab From 527901d0aeb233a479123b7e5f542fbc911ccf6d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:15 +0100 Subject: [PATCH 0969/1846] iwlegacy: remove temp_ops Remove unneeded structure and cleanup temperature calibration routines a bit. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 26 ++++++++++++------------ drivers/net/wireless/iwlegacy/4965.c | 5 +---- drivers/net/wireless/iwlegacy/4965.h | 1 + drivers/net/wireless/iwlegacy/common.h | 8 -------- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 36f85f289a25..e113dc5b1c2e 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1343,12 +1343,11 @@ il4965_accumulative_stats(struct il_priv *il, __le32 * stats) } #endif -#define REG_RECALIB_PERIOD (60) - void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { - int change; + const int recalib_seconds = 60; + bool change; struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", @@ -1369,20 +1368,21 @@ il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) set_bit(S_STATS, &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 */ + /* + * Reschedule the stats timer to occur in recalib_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)); + jiffies + msecs_to_jiffies(recalib_seconds * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && (pkt->hdr.cmd == N_STATS)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); } - if (il->ops->lib->temp_ops.temperature && change) - il->ops->lib->temp_ops.temperature(il); + + if (change) + il4965_temperature_calib(il); } void @@ -4028,9 +4028,9 @@ il4965_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) * 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 N_STATS - * was received. We need to ensure we receive the stats in order - * to update the temperature used for calibrating the TXPOWER. + * 60 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. */ static void il4965_bg_stats_periodic(unsigned long data) diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 34fa3db82292..3a30aacf5d0c 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1678,7 +1678,7 @@ il4965_is_temp_calib_needed(struct il_priv *il) return 1; } -static void +void il4965_temperature_calib(struct il_priv *il) { s32 temp; @@ -1910,9 +1910,6 @@ static struct il_lib_ops il4965_lib = { }, .send_tx_power = il4965_send_tx_power, .update_chain_flags = il4965_update_chain_flags, - .temp_ops = { - .temperature = il4965_temperature_calib, - }, }; 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 b3fcb8f30fe9..7c6b9b925c94 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -266,6 +266,7 @@ il4965_hw_valid_rtc_data_addr(u32 addr) ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ (t) > IL_TX_POWER_TEMPERATURE_MAX) +extern void il4965_temperature_calib(struct il_priv *il); /********************* END TEMPERATURE ***************************************/ /********************* START TXPOWER *****************************************/ diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index cd8f27d18b1c..6f42f56388e7 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1588,10 +1588,6 @@ struct il_debugfs_ops { }; #endif -struct il_temp_ops { - void (*temperature) (struct il_priv *il); -}; - struct il_lib_ops { /* Handling TX */ void (*txq_update_byte_cnt_tbl) (struct il_priv *il, @@ -1622,10 +1618,6 @@ struct il_lib_ops { /* eeprom operations */ struct il_eeprom_ops eeprom_ops; - - /* temperature */ - struct il_temp_ops temp_ops; - }; struct il_led_ops { -- GitLab From a89268e8cdcd52680bda21ada05f2716c6466377 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:16 +0100 Subject: [PATCH 0970/1846] iwlegacy: merge eeprom_ops into lib_ops Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945.c | 6 ++---- drivers/net/wireless/iwlegacy/4965.c | 6 ++---- drivers/net/wireless/iwlegacy/common.c | 4 ++-- drivers/net/wireless/iwlegacy/common.h | 8 ++------ 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 4e63e7d48a7b..95d88b4f3106 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2645,12 +2645,10 @@ static struct il_lib_ops il3945_lib = { .init = il3945_apm_init, .config = il3945_nic_config, }, - .eeprom_ops = { - .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, + .eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore, + .eeprom_release_semaphore = il3945_eeprom_release_semaphore, }; static const struct il_legacy_ops il3945_legacy_ops = { diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 3a30aacf5d0c..3ddc31f0f9e7 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1904,12 +1904,10 @@ static struct il_lib_ops il4965_lib = { .init = il_apm_init, .config = il4965_nic_config, }, - .eeprom_ops = { - .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, + .eeprom_acquire_semaphore = il4965_eeprom_acquire_semaphore, + .eeprom_release_semaphore = il4965_eeprom_release_semaphore, }; static const struct il_legacy_ops il4965_legacy_ops = { diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 5a7ad52db1d9..5de2340d08c4 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -740,7 +740,7 @@ il_eeprom_init(struct il_priv *il) } /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = il->ops->lib->eeprom_ops.acquire_semaphore(il); + ret = il->ops->lib->eeprom_acquire_semaphore(il); if (ret < 0) { IL_ERR("Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; @@ -772,7 +772,7 @@ il_eeprom_init(struct il_priv *il) ret = 0; done: - il->ops->lib->eeprom_ops.release_semaphore(il); + il->ops->lib->eeprom_release_semaphore(il); err: if (ret) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 6f42f56388e7..b588a5f4da03 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -425,11 +425,6 @@ struct il_eeprom_calib_info { #define EEPROM_REGULATORY_BAND_NO_HT40 (0) -struct il_eeprom_ops { - 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); @@ -1617,7 +1612,8 @@ struct il_lib_ops { void (*update_chain_flags) (struct il_priv *il); /* eeprom operations */ - struct il_eeprom_ops eeprom_ops; + int (*eeprom_acquire_semaphore) (struct il_priv *il); + void (*eeprom_release_semaphore) (struct il_priv *il); }; struct il_led_ops { -- GitLab From f03ee2a87e21f76928c10d822639ec437113d312 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:17 +0100 Subject: [PATCH 0971/1846] iwlegacy: remove il_apm_ops Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 2 +- drivers/net/wireless/iwlegacy/3945.c | 10 +++------- drivers/net/wireless/iwlegacy/4965-mac.c | 8 ++------ drivers/net/wireless/iwlegacy/4965.c | 7 ++----- drivers/net/wireless/iwlegacy/4965.h | 2 ++ drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 9 ++------- 7 files changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index b7d5ebc512d3..ba01d2d2ff97 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -3672,7 +3672,7 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 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 + /* these spin locks will be used in apm_init and EEPROM access * we should init now */ spin_lock_init(&il->reg_lock); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 95d88b4f3106..a21ec25ec9d1 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -958,12 +958,11 @@ il3945_hw_nic_init(struct il_priv *il) struct il_rx_queue *rxq = &il->rxq; spin_lock_irqsave(&il->lock, flags); - il->ops->lib->apm_ops.init(il); + il3945_apm_init(il); spin_unlock_irqrestore(&il->lock, flags); il3945_set_pwr_vmain(il); - - il->ops->lib->apm_ops.config(il); + il3945_nic_config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { @@ -2641,10 +2640,7 @@ static struct il_lib_ops il3945_lib = { .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, - }, + .apm_init = il3945_apm_init, .send_tx_power = il3945_send_tx_power, .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, .eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore, diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index e113dc5b1c2e..ebfcfc8a9ae6 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -199,18 +199,14 @@ il4965_hw_nic_init(struct il_priv *il) struct il_rx_queue *rxq = &il->rxq; int ret; - /* nic_init */ spin_lock_irqsave(&il->lock, flags); - il->ops->lib->apm_ops.init(il); - + il_apm_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->ops->lib->apm_ops.config(il); + il4965_nic_config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 3ddc31f0f9e7..e5e5ab24d171 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -508,7 +508,7 @@ iw4965_is_ht40_channel(__le32 rxon_flags) chan_mod == CHANNEL_MODE_MIXED); } -static void +void il4965_nic_config(struct il_priv *il) { unsigned long flags; @@ -1900,10 +1900,7 @@ static struct il_lib_ops il4965_lib = { .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, - }, + .apm_init = il_apm_init, .send_tx_power = il4965_send_tx_power, .update_chain_flags = il4965_update_chain_flags, .eeprom_acquire_semaphore = il4965_eeprom_acquire_semaphore, diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 7c6b9b925c94..208a4564d063 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -60,6 +60,8 @@ 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); +void il4965_nic_config(struct il_priv *il); + /* rx */ void il4965_rx_queue_restock(struct il_priv *il); void il4965_rx_replenish(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 5de2340d08c4..6e63d9fee565 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -730,7 +730,7 @@ il_eeprom_init(struct il_priv *il) } e = (__le16 *) il->eeprom; - il->ops->lib->apm_ops.init(il); + il->ops->lib->apm_init(il); ret = il_eeprom_verify_signature(il); if (ret < 0) { diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index b588a5f4da03..ca68b58674c6 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1566,11 +1566,6 @@ struct il_hcmd_utils_ops { void (*post_scan) (struct il_priv *il); }; -struct il_apm_ops { - int (*init) (struct il_priv *il); - 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, @@ -1605,9 +1600,9 @@ struct il_lib_ops { int (*set_channel_switch) (struct il_priv *il, struct ieee80211_channel_switch *ch_switch); /* power management */ - struct il_apm_ops apm_ops; + int (*apm_init) (struct il_priv *il); - /* power */ + /* tx power */ int (*send_tx_power) (struct il_priv *il); void (*update_chain_flags) (struct il_priv *il); -- GitLab From 1600b87542ce93e3dc094f6b108d8c2953e2ca0e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:18 +0100 Subject: [PATCH 0972/1846] iwlegacy: merge il_lib_ops into il_ops Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 8 ++--- drivers/net/wireless/iwlegacy/3945.c | 29 +++++++++--------- drivers/net/wireless/iwlegacy/4965-calib.c | 4 +-- drivers/net/wireless/iwlegacy/4965-mac.c | 23 +++++++-------- drivers/net/wireless/iwlegacy/4965.c | 19 +++++------- drivers/net/wireless/iwlegacy/common.c | 34 +++++++++++----------- drivers/net/wireless/iwlegacy/common.h | 31 +++++++++----------- drivers/net/wireless/iwlegacy/debug.c | 4 +-- 8 files changed, 71 insertions(+), 81 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index ba01d2d2ff97..19a4d56dd0ab 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -616,7 +616,7 @@ 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->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 0); + il->ops->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). */ @@ -625,8 +625,8 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, len, PCI_DMA_TODEVICE); - il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, len, 0, - U32_PAD(len)); + il->ops->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 */ @@ -2413,7 +2413,7 @@ __il3945_up(struct il_priv *il) /* load bootstrap state machine, * load bootstrap program into processor's memory, * prepare to load the "initialize" uCode */ - rc = il->ops->lib->load_ucode(il); + rc = il->ops->load_ucode(il); if (rc) { IL_ERR("Unable to set up bootstrap uCode: %d\n", rc); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index a21ec25ec9d1..f5833d049654 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -303,7 +303,7 @@ il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) skb = txq->skbs[txq->q.read_ptr]; ieee80211_tx_status_irqsafe(il->hw, skb); txq->skbs[txq->q.read_ptr] = NULL; - il->ops->lib->txq_free_tfd(il, txq); + il->ops->txq_free_tfd(il, txq); } if (il_queue_space(q) > q->low_mark && txq_id >= 0 && @@ -1612,7 +1612,7 @@ il3945_hw_reg_comp_txpower_temp(struct il_priv *il) } /* send Txpower command for current channel to ucode */ - return il->ops->lib->send_tx_power(il); + return il->ops->send_tx_power(il); } int @@ -2634,19 +2634,6 @@ static struct il_hcmd_ops il3945_hcmd = { .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_init = il3945_apm_init, - .send_tx_power = il3945_send_tx_power, - .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, - .eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore, - .eeprom_release_semaphore = il3945_eeprom_release_semaphore, -}; - static const struct il_legacy_ops il3945_legacy_ops = { .post_associate = il3945_post_associate, .config_ap = il3945_config_ap, @@ -2661,7 +2648,17 @@ static struct il_hcmd_utils_ops il3945_hcmd_utils = { }; const struct il_ops il3945_ops = { - .lib = &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_init = il3945_apm_init, + .send_tx_power = il3945_send_tx_power, + .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, + .eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore, + .eeprom_release_semaphore = il3945_eeprom_release_semaphore, + .hcmd = &il3945_hcmd, .utils = &il3945_hcmd_utils, .led = &il3945_led_ops, diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index fe9171506a91..47c20e3d5605 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -923,8 +923,8 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* Some power changes may have been made during the calibration. * Update and commit the RXON */ - if (il->ops->lib->update_chain_flags) - il->ops->lib->update_chain_flags(il); + if (il->ops->update_chain_flags) + il->ops->update_chain_flags(il); data->state = IL_CHAIN_NOISE_DONE; il_power_update_mode(il, false); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ebfcfc8a9ae6..cc2963be001e 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1811,7 +1811,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) dma_unmap_len_set(out_meta, len, firstlen); /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - il->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0); + il->ops->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0); if (!ieee80211_has_morefrags(hdr->frame_control)) { txq->need_update = 1; @@ -1827,8 +1827,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen, PCI_DMA_TODEVICE); - il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, - secondlen, 0, 0); + il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen, + 0, 0); } scratch_phys = @@ -1848,8 +1848,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) - il->ops->lib->txq_update_byte_cnt_tbl(il, txq, - le16_to_cpu(tx_cmd->len)); + il->ops->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); @@ -2470,7 +2469,7 @@ il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) il4965_tx_status(il, skb, txq_id >= IL4965_FIRST_AMPDU_QUEUE); txq->skbs[txq->q.read_ptr] = NULL; - il->ops->lib->txq_free_tfd(il, txq); + il->ops->txq_free_tfd(il, txq); } return nfreed; } @@ -5072,7 +5071,7 @@ il4965_dump_nic_error_log(struct il_priv *il) else base = le32_to_cpu(il->card_alive.error_event_table_ptr); - if (!il->ops->lib->is_valid_rtc_data_addr(base)) { + if (!il->ops->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; @@ -5574,7 +5573,7 @@ __il4965_up(struct il_priv *il) /* load bootstrap state machine, * load bootstrap program into processor's memory, * prepare to load the "initialize" uCode */ - ret = il->ops->lib->load_ucode(il); + ret = il->ops->load_ucode(il); if (ret) { IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); @@ -5615,7 +5614,7 @@ il4965_bg_init_alive_start(struct work_struct *data) if (test_bit(S_EXIT_PENDING, &il->status)) goto out; - il->ops->lib->init_alive_start(il); + il->ops->init_alive_start(il); out: mutex_unlock(&il->mutex); } @@ -6047,7 +6046,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, if (!il_is_associated(il)) goto out; - if (!il->ops->lib->set_channel_switch) + if (!il->ops->set_channel_switch) goto out; ch = channel->hw_value; @@ -6099,7 +6098,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, */ set_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = cpu_to_le16(ch); - if (il->ops->lib->set_channel_switch(il, ch_switch)) { + if (il->ops->set_channel_switch(il, ch_switch)) { clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = 0; ieee80211_chswitch_done(il->vif, false); @@ -6182,7 +6181,7 @@ il4965_bg_txpower_work(struct work_struct *work) /* 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->ops->lib->send_tx_power(il); + il->ops->send_tx_power(il); /* Update last_temperature to keep is_calib_needed from running * when it isn't needed... */ diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index e5e5ab24d171..805a4ea8351a 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1889,7 +1889,14 @@ static struct il_hcmd_utils_ops il4965_hcmd_utils = { .post_scan = il4965_post_scan, }; -static struct il_lib_ops il4965_lib = { +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, +}; + +const struct il_ops il4965_ops = { .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, @@ -1905,17 +1912,7 @@ static struct il_lib_ops il4965_lib = { .update_chain_flags = il4965_update_chain_flags, .eeprom_acquire_semaphore = il4965_eeprom_acquire_semaphore, .eeprom_release_semaphore = il4965_eeprom_release_semaphore, -}; -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, -}; - -const struct il_ops il4965_ops = { - .lib = &il4965_lib, .hcmd = &il4965_hcmd, .utils = &il4965_hcmd_utils, .led = &il4965_led_ops, diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 6e63d9fee565..d522a4324a11 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -730,7 +730,7 @@ il_eeprom_init(struct il_priv *il) } e = (__le16 *) il->eeprom; - il->ops->lib->apm_init(il); + il->ops->apm_init(il); ret = il_eeprom_verify_signature(il); if (ret < 0) { @@ -740,7 +740,7 @@ il_eeprom_init(struct il_priv *il) } /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = il->ops->lib->eeprom_acquire_semaphore(il); + ret = il->ops->eeprom_acquire_semaphore(il); if (ret < 0) { IL_ERR("Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; @@ -772,7 +772,7 @@ il_eeprom_init(struct il_priv *il) ret = 0; done: - il->ops->lib->eeprom_release_semaphore(il); + il->ops->eeprom_release_semaphore(il); err: if (ret) @@ -1155,9 +1155,9 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force) if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) clear_bit(S_POWER_PMI, &il->status); - if (il->ops->lib->update_chain_flags && update_chains) - il->ops->lib->update_chain_flags(il); - else if (il->ops->lib->update_chain_flags) + if (il->ops->update_chain_flags && update_chains) + il->ops->update_chain_flags(il); + else if (il->ops->update_chain_flags) D_POWER("Cannot update the power, chain noise " "calibration running: %d\n", il->chain_noise_data.state); @@ -2719,7 +2719,7 @@ il_tx_queue_unmap(struct il_priv *il, int txq_id) return; while (q->write_ptr != q->read_ptr) { - il->ops->lib->txq_free_tfd(il, txq); + il->ops->txq_free_tfd(il, txq); q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } @@ -3019,7 +3019,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ - il->ops->lib->txq_init(il, txq); + il->ops->txq_init(il, txq); return 0; err: @@ -3050,7 +3050,7 @@ il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ - il->ops->lib->txq_init(il, txq); + il->ops->txq_init(il, txq); } EXPORT_SYMBOL(il_tx_queue_reset); @@ -3157,9 +3157,9 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) #endif txq->need_update = 1; - if (il->ops->lib->txq_update_byte_cnt_tbl) + if (il->ops->txq_update_byte_cnt_tbl) /* Set up entry in queue's byte count circular buffer */ - il->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); + il->ops->txq_update_byte_cnt_tbl(il, txq, 0); phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, @@ -3167,7 +3167,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1, + il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1, U32_PAD(cmd->len)); /* Increment and update queue's write idx */ @@ -4101,9 +4101,9 @@ il_irq_handle_error(struct il_priv *il) IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); - il->ops->lib->dump_nic_error_log(il); - if (il->ops->lib->dump_fh) - il->ops->lib->dump_fh(il, NULL, false); + il->ops->dump_nic_error_log(il); + if (il->ops->dump_fh) + il->ops->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); @@ -4290,7 +4290,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) if (il->tx_power_user_lmt == tx_power && !force) return 0; - if (!il->ops->lib->send_tx_power) + if (!il->ops->send_tx_power) return -EOPNOTSUPP; /* 0 dBm mean 1 milliwatt */ @@ -4323,7 +4323,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) prev_tx_power = il->tx_power_user_lmt; il->tx_power_user_lmt = tx_power; - ret = il->ops->lib->send_tx_power(il); + ret = il->ops->send_tx_power(il); /* if fail to set tx_power, restore the orig. tx power */ if (ret) { diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index ca68b58674c6..91624ee57fed 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1578,7 +1578,20 @@ struct il_debugfs_ops { }; #endif -struct il_lib_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 { /* Handling TX */ void (*txq_update_byte_cnt_tbl) (struct il_priv *il, struct il_tx_queue *txq, @@ -1609,23 +1622,7 @@ struct il_lib_ops { /* eeprom operations */ int (*eeprom_acquire_semaphore) (struct il_priv *il); void (*eeprom_release_semaphore) (struct il_priv *il); -}; -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; diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 5091db813d66..be6005da785d 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -1178,8 +1178,8 @@ il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, int pos = 0; ssize_t ret = -EFAULT; - if (il->ops->lib->dump_fh) { - ret = pos = il->ops->lib->dump_fh(il, &buf, true); + if (il->ops->dump_fh) { + ret = pos = il->ops->dump_fh(il, &buf, true); if (buf) { ret = simple_read_from_buffer(user_buf, count, ppos, buf, -- GitLab From c936355172a7e4aeadbbdcaae48f10e31f604899 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:19 +0100 Subject: [PATCH 0973/1846] iwlegacy: merge all ops structures into one Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945.c | 39 ++++++------------ drivers/net/wireless/iwlegacy/4965-mac.c | 17 ++++---- drivers/net/wireless/iwlegacy/4965.c | 51 +++++++++-------------- drivers/net/wireless/iwlegacy/common.c | 50 +++++++++-------------- drivers/net/wireless/iwlegacy/common.h | 52 +++++++++--------------- 5 files changed, 78 insertions(+), 131 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index f5833d049654..fde6979d080a 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -57,10 +57,6 @@ il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) 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, \ @@ -2629,24 +2625,6 @@ il3945_load_bsm(struct il_priv *il) return 0; } -static struct il_hcmd_ops il3945_hcmd = { - .rxon_assoc = il3945_send_rxon_assoc, - .commit_rxon = il3945_commit_rxon, -}; - -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, -}; - const struct il_ops il3945_ops = { .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, .txq_free_tfd = il3945_hw_txq_free_tfd, @@ -2659,10 +2637,19 @@ const struct il_ops il3945_ops = { .eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore, .eeprom_release_semaphore = il3945_eeprom_release_semaphore, - .hcmd = &il3945_hcmd, - .utils = &il3945_hcmd_utils, - .led = &il3945_led_ops, - .legacy = &il3945_legacy_ops, + .rxon_assoc = il3945_send_rxon_assoc, + .commit_rxon = il3945_commit_rxon, + + .get_hcmd_size = il3945_get_hcmd_size, + .build_addsta_hcmd = il3945_build_addsta_hcmd, + .request_scan = il3945_request_scan, + .post_scan = il3945_post_scan, + + .post_associate = il3945_post_associate, + .config_ap = il3945_config_ap, + .manage_ibss_station = il3945_manage_ibss_station, + + .send_led_cmd = il3945_send_led_cmd, }; static struct il_cfg il3945_bg_cfg = { diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index cc2963be001e..89275bfe559f 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -3649,8 +3649,8 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) void il4965_update_chain_flags(struct il_priv *il) { - if (il->ops->hcmd->set_rxon_chain) { - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) { + il->ops->set_rxon_chain(il); if (il->active.rx_chain != il->staging.rx_chain) il_commit_rxon(il); } @@ -4399,9 +4399,8 @@ 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", @@ -5300,8 +5299,8 @@ il4965_alive_start(struct il_priv *il) /* Initialize our rx_config data */ il_connection_init_rx_config(il); - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); } /* Configure bluetooth coexistence if enabled */ @@ -6333,8 +6332,8 @@ il4965_init_drv(struct il_priv *il) il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; /* Choose which receivers/antennas to use */ - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); il_init_scan_params(il); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 805a4ea8351a..5db11714e047 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -264,10 +264,6 @@ 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); @@ -1737,12 +1733,6 @@ il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) return (u16) sizeof(struct il4965_addsta_cmd); } -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) { @@ -1782,8 +1772,8 @@ il4965_post_associate(struct il_priv *il) il_set_rxon_ht(il, &il->current_ht_config); - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); @@ -1857,8 +1847,8 @@ il4965_config_ap(struct il_priv *il) /* 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->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); il->staging.assoc_id = 0; @@ -1882,20 +1872,6 @@ il4965_config_ap(struct il_priv *il) 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 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, -}; - const struct il_ops il4965_ops = { .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, @@ -1913,10 +1889,21 @@ const struct il_ops il4965_ops = { .eeprom_acquire_semaphore = il4965_eeprom_acquire_semaphore, .eeprom_release_semaphore = il4965_eeprom_release_semaphore, - .hcmd = &il4965_hcmd, - .utils = &il4965_hcmd_utils, - .led = &il4965_led_ops, - .legacy = &il4965_legacy_ops, + .rxon_assoc = il4965_send_rxon_assoc, + .commit_rxon = il4965_commit_rxon, + .set_rxon_chain = il4965_set_rxon_chain, + + .get_hcmd_size = il4965_get_hcmd_size, + .build_addsta_hcmd = il4965_build_addsta_hcmd, + .request_scan = il4965_request_scan, + .post_scan = il4965_post_scan, + + .post_associate = il4965_post_associate, + .config_ap = il4965_config_ap, + .manage_ibss_station = il4965_manage_ibss_station, + .update_bcast_stations = il4965_update_bcast_stations, + + .send_led_cmd = il4965_send_led_cmd, }; struct il_cfg il4965_cfg = { diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index d522a4324a11..1bf861626c86 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -519,7 +519,7 @@ il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) il_blink_compensation(il, off, il->cfg->led_compensation); - ret = il->ops->led->cmd(il, &led_cmd); + ret = il->ops->send_led_cmd(il, &led_cmd); if (!ret) { il->blink_on = on; il->blink_off = off; @@ -1482,9 +1482,6 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); - if (WARN_ON(!il->ops->utils->request_scan)) - return -EOPNOTSUPP; - cancel_delayed_work(&il->scan_check); if (!il_is_ready_rf(il)) { @@ -1507,7 +1504,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) set_bit(S_SCANNING, &il->status); il->scan_start = jiffies; - ret = il->ops->utils->request_scan(il, vif); + ret = il->ops->request_scan(il, vif); if (ret) { clear_bit(S_SCANNING, &il->status); return ret; @@ -1669,7 +1666,7 @@ il_bg_scan_completed(struct work_struct *work) il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); il_set_tx_power(il, il->tx_power_next, false); - il->ops->utils->post_scan(il); + il->ops->post_scan(il); out: mutex_unlock(&il->mutex); @@ -1811,7 +1808,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) might_sleep(); } - cmd.len = il->ops->utils->build_addsta_hcmd(sta, data); + cmd.len = il->ops->build_addsta_hcmd(sta, data); ret = il_send_cmd(il, &cmd); if (ret || (flags & CMD_ASYNC)) @@ -3078,7 +3075,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) u32 idx; u16 fix_size; - cmd->len = il->ops->utils->get_hcmd_size(cmd->id, cmd->len); + cmd->len = il->ops->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 @@ -3842,8 +3839,8 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; } - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); D_ASSOC("rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), @@ -4472,8 +4469,8 @@ il_set_mode(struct il_priv *il) { il_connection_init_rx_config(il); - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); return il_commit_rxon(il); } @@ -5171,9 +5168,6 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) int scan_active = 0; bool ht_changed = false; - if (WARN_ON(!il->ops->legacy)) - return -EOPNOTSUPP; - mutex_lock(&il->mutex); D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, @@ -5196,8 +5190,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) * set up the SM PS mode to OFF if an HT channel is * configured. */ - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); } /* during scanning mac80211 will delay channel setting until @@ -5266,8 +5260,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) spin_unlock_irqrestore(&il->lock, flags); - if (il->ops->legacy->update_bcast_stations) - ret = il->ops->legacy->update_bcast_stations(il); + if (il->ops->update_bcast_stations) + ret = il->ops->update_bcast_stations(il); set_ch_out: /* The list of supported rates and rate mask can be different @@ -5317,9 +5311,6 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct il_priv *il = hw->priv; unsigned long flags; - if (WARN_ON(!il->ops->legacy)) - return; - mutex_lock(&il->mutex); D_MAC80211("enter\n"); @@ -5472,7 +5463,7 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) return; } - il->ops->legacy->post_associate(il); + il->ops->post_associate(il); } void @@ -5482,9 +5473,6 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct il_priv *il = hw->priv; int ret; - if (WARN_ON(!il->ops->legacy)) - return; - D_MAC80211("changes = 0x%X\n", changes); mutex_lock(&il->mutex); @@ -5587,8 +5575,8 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (changes & BSS_CHANGED_HT) { il_ht_conf(il, vif); - if (il->ops->hcmd->set_rxon_chain) - il->ops->hcmd->set_rxon_chain(il); + if (il->ops->set_rxon_chain) + il->ops->set_rxon_chain(il); } if (changes & BSS_CHANGED_ASSOC) { @@ -5597,7 +5585,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, il->timestamp = bss_conf->timestamp; if (!il_is_rfkill(il)) - il->ops->legacy->post_associate(il); + il->ops->post_associate(il); } else il_set_no_assoc(il, vif); } @@ -5617,14 +5605,14 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, memcpy(il->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - il->ops->legacy->config_ap(il); + il->ops->config_ap(il); } else il_set_no_assoc(il, vif); } if (changes & BSS_CHANGED_IBSS) { ret = - il->ops->legacy->manage_ibss_station(il, vif, + il->ops->manage_ibss_station(il, vif, bss_conf->ibss_joined); if (ret) IL_ERR("failed to %s IBSS station %pM\n", diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 91624ee57fed..873182ec3fbf 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1553,19 +1553,6 @@ il_free_pages(struct il_priv *il, unsigned long page) #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); - int (*commit_rxon) (struct il_priv *il); - void (*set_rxon_chain) (struct il_priv *il); -}; - -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); -}; - #ifdef CONFIG_IWLEGACY_DEBUGFS struct il_debugfs_ops { ssize_t(*rx_stats_read) (struct file *file, char __user *user_buf, @@ -1578,19 +1565,6 @@ struct il_debugfs_ops { }; #endif -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 { /* Handling TX */ void (*txq_update_byte_cnt_tbl) (struct il_priv *il, @@ -1623,11 +1597,23 @@ struct il_ops { int (*eeprom_acquire_semaphore) (struct il_priv *il); void (*eeprom_release_semaphore) (struct il_priv *il); - 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; + int (*rxon_assoc) (struct il_priv *il); + int (*commit_rxon) (struct il_priv *il); + void (*set_rxon_chain) (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); + 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 (*send_led_cmd) (struct il_priv *il, struct il_led_cmd *led_cmd); }; struct il_mod_params { @@ -2053,13 +2039,13 @@ int il_send_rxon_timing(struct il_priv *il); static inline int il_send_rxon_assoc(struct il_priv *il) { - return il->ops->hcmd->rxon_assoc(il); + return il->ops->rxon_assoc(il); } static inline int il_commit_rxon(struct il_priv *il) { - return il->ops->hcmd->commit_rxon(il); + return il->ops->commit_rxon(il); } static inline const struct ieee80211_supported_band * -- GitLab From 288f9954132cd64f60fbb8051e31d62d8c35875f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:20 +0100 Subject: [PATCH 0974/1846] iwlegacy: get rid of tx/rx traffic log The same data can be gathered using monitor mode. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 12 +- drivers/net/wireless/iwlegacy/3945.c | 2 - drivers/net/wireless/iwlegacy/4965-mac.c | 13 +- drivers/net/wireless/iwlegacy/common.c | 247 ----------------------- drivers/net/wireless/iwlegacy/common.h | 51 +---- drivers/net/wireless/iwlegacy/debug.c | 243 ++++++++++++---------- 6 files changed, 145 insertions(+), 423 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 19a4d56dd0ab..1743accc1271 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -573,7 +573,6 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) 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; @@ -3098,11 +3097,9 @@ il3945_store_debug_level(struct device *d, struct device_attribute *attr, ret = strict_strtoul(buf, 0, &val); if (ret) IL_INFO("%s is not in hex or decimal form.\n", buf); - else { + 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); } @@ -3625,9 +3622,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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 * *************************/ @@ -3790,7 +3784,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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; @@ -3858,7 +3851,6 @@ il3945_pci_remove(struct pci_dev *pdev) * until now... */ destroy_workqueue(il->workqueue); il->workqueue = NULL; - il_free_traffic_mem(il); free_irq(pdev->irq, il); pci_disable_msi(pdev); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index fde6979d080a..95ebd43ae537 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -573,8 +573,6 @@ il3945_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) 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); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 89275bfe559f..b251d34f0790 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -688,7 +688,6 @@ il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) /* 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); @@ -1781,7 +1780,6 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* 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); @@ -4541,11 +4539,9 @@ il4965_store_debug_level(struct device *d, struct device_attribute *attr, ret = strict_strtoul(buf, 0, &val); if (ret) IL_ERR("%s is not in hex or decimal form.\n", buf); - else { + 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); } @@ -6483,9 +6479,6 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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 **************************/ @@ -6663,7 +6656,6 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 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; @@ -6734,7 +6726,6 @@ il4965_pci_remove(struct pci_dev *pdev) * 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); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 1bf861626c86..21b355a9171f 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4574,253 +4574,6 @@ il_txq_mem(struct il_priv *il) } 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) { diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 873182ec3fbf..b2a6e52f8233 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1766,57 +1766,21 @@ 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); +extern 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. - * **************************************************/ + * 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_csa(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** * RX @@ -1827,13 +1791,10 @@ 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 diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index be6005da785d..236dc90b035b 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -31,6 +31,101 @@ #include "common.h" +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)); +} + +/* + * il_update_stats function record all the MGMT, CTRL and DATA pkt for + * both TX and Rx . Use debugfs to display the rx/rx_stats + */ +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); + /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ if (!debugfs_create_file(#name, mode, parent, il, \ @@ -98,6 +193,46 @@ static const struct file_operations il_dbgfs_##name##_ops = { \ .llseek = generic_file_llseek, \ }; +static 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"; + + } +} + +static 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"; + + } +} + static ssize_t il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) @@ -714,112 +849,6 @@ 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->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) @@ -1303,7 +1332,6 @@ il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, 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); @@ -1357,7 +1385,6 @@ il_dbgfs_register(struct il_priv *il, const char *name) 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); -- GitLab From 9ce7b73c76ca872cb5b42e835f8e683a4051fbd9 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:21 +0100 Subject: [PATCH 0975/1846] iwlegacy: improve mac operation debuggability a bit Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 16 +++-- drivers/net/wireless/iwlegacy/common.c | 89 ++++++++++++------------ 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 1743accc1271..99d7c729d8ce 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -2781,10 +2781,9 @@ 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); + D_MAC80211("enter\n"); /* fetch ucode file from disk, alloc and copy to bus-master buffers ... * ucode filename and max sizes are card-specific. */ @@ -2940,15 +2939,19 @@ il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, * hardware will then not attempt to decrypt the frames. */ if (vif->type == NL80211_IFTYPE_ADHOC && - !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { + D_MAC80211("leave - IBSS RSN\n"); return -EOPNOTSUPP; + } static_key = !il_is_associated(il); if (!static_key) { sta_id = il_sta_id_or_broadcast(il, sta); - if (sta_id == IL_INVALID_STATION) + if (sta_id == IL_INVALID_STATION) { + D_MAC80211("leave - station not found\n"); return -EINVAL; + } } mutex_lock(&il->mutex); @@ -2973,8 +2976,8 @@ il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = -EINVAL; } + D_MAC80211("leave ret %d\n", ret); mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); return ret; } @@ -2989,9 +2992,8 @@ il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 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); + D_INFO("station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; ret = il_add_station_common(il, sta->addr, is_ap, sta, &sta_id); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 21b355a9171f..0d1a643d8b91 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -1523,12 +1523,13 @@ il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct il_priv *il = hw->priv; int ret; - D_MAC80211("enter\n"); - - if (req->n_channels == 0) + if (req->n_channels == 0) { + IL_ERR("Can not scan on no channels.\n"); return -EINVAL; + } mutex_lock(&il->mutex); + D_MAC80211("enter\n"); if (test_bit(S_SCANNING, &il->status)) { D_SCAN("Scan already in progress.\n"); @@ -1543,9 +1544,8 @@ il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, ret = il_scan_initiate(il, vif); - D_MAC80211("leave\n"); - out_unlock: + D_MAC80211("leave ret %d\n", ret); mutex_unlock(&il->mutex); return ret; @@ -2413,13 +2413,16 @@ il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 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); + D_MAC80211("enter 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); + + D_MAC80211("leave ret %d\n", ret); mutex_unlock(&il->mutex); + return ret; } EXPORT_SYMBOL(il_mac_sta_remove); @@ -4459,8 +4462,14 @@ int il_mac_tx_last_beacon(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; + int ret; - return il->ibss_manager == IL_IBSS_MANAGER; + D_MAC80211("enter\n"); + + ret = (il->ibss_manager == IL_IBSS_MANAGER); + + D_MAC80211("leave ret %d\n", ret); + return ret; } EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); @@ -4481,9 +4490,8 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct il_priv *il = hw->priv; int err; - D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); - mutex_lock(&il->mutex); + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); if (!il_is_ready_rf(il)) { IL_WARN("Try to add interface when device not ready\n"); @@ -4506,9 +4514,9 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) } out: + D_MAC80211("leave err %d\n", err); mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); return err; } EXPORT_SYMBOL(il_mac_add_interface); @@ -4534,20 +4542,17 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; - D_MAC80211("enter\n"); - mutex_lock(&il->mutex); + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); WARN_ON(il->vif != vif); il->vif = NULL; il_teardown_interface(il, vif, false); - memset(il->bssid, 0, ETH_ALEN); - mutex_unlock(&il->mutex); D_MAC80211("leave\n"); - + mutex_unlock(&il->mutex); } EXPORT_SYMBOL(il_mac_remove_interface); @@ -4633,10 +4638,14 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct il_priv *il = hw->priv; int err; - if (newp2p) - return -EOPNOTSUPP; - mutex_lock(&il->mutex); + D_MAC80211("enter: type %d, addr %pM newtype %d newp2p %d\n", + vif->type, vif->addr, newtype, newp2p); + + if (newp2p) { + err = -EOPNOTSUPP; + goto out; + } if (!il->vif || !il_is_ready_rf(il)) { /* @@ -4663,7 +4672,9 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, err = 0; out: + D_MAC80211("leave err %d\n", err); mutex_unlock(&il->mutex); + return err; } EXPORT_SYMBOL(il_mac_change_interface); @@ -4922,8 +4933,7 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) bool ht_changed = false; mutex_lock(&il->mutex); - - D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, + D_MAC80211("enter: channel %d changed 0x%X\n", channel->hw_value, changed); if (unlikely(test_bit(S_SCANNING, &il->status))) { @@ -5052,8 +5062,9 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed) il_update_qos(il); out: - D_MAC80211("leave\n"); + D_MAC80211("leave ret %d\n", ret); mutex_unlock(&il->mutex); + return ret; } EXPORT_SYMBOL(il_mac_config); @@ -5065,20 +5076,16 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) unsigned long flags; mutex_lock(&il->mutex); - D_MAC80211("enter\n"); + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); 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); + memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); /* 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); @@ -5090,17 +5097,14 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) return; } - /* we are restarting association process - * clear RXON_FILTER_ASSOC_MSK bit - */ + /* we are restarting association process */ il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il_commit_rxon(il); il_set_rate(il); - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); + mutex_unlock(&il->mutex); } EXPORT_SYMBOL(il_mac_reset_tsf); @@ -5226,11 +5230,11 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct il_priv *il = hw->priv; int ret; - D_MAC80211("changes = 0x%X\n", changes); - mutex_lock(&il->mutex); + D_MAC80211("enter: changes 0x%x\n", changes); if (!il_is_alive(il)) { + D_MAC80211("leave - not alive\n"); mutex_unlock(&il->mutex); return; } @@ -5261,8 +5265,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, * 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"); + D_MAC80211("leave - scan abort failed\n"); mutex_unlock(&il->mutex); return; } @@ -5274,10 +5277,8 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, /* currently needed in a few places */ memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - } else { + } else il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - } - } /* @@ -5364,18 +5365,16 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, } if (changes & BSS_CHANGED_IBSS) { - ret = - il->ops->manage_ibss_station(il, vif, - bss_conf->ibss_joined); + ret = il->ops->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"); + mutex_unlock(&il->mutex); } EXPORT_SYMBOL(il_mac_bss_info_changed); -- GitLab From 774212b3f3fd590f4da03dc898aff3d9980f1ae0 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:22 +0100 Subject: [PATCH 0976/1846] iwleagcy: remove old comments Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index b2a6e52f8233..a7794459d747 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1626,22 +1626,6 @@ struct il_mod_params { 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 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 - * @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 { -}; - #define IL_LED_SOLID 11 #define IL_DEF_LED_INTRVL cpu_to_le32(1000) -- GitLab From c37281a076604937ec2403f3cfec71362f93c7d8 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:23 +0100 Subject: [PATCH 0977/1846] iwleagcy: fix ident code damage Using ident is not always good. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 18 +++++------------- drivers/net/wireless/iwlegacy/4965-mac.c | 18 +++++------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 99d7c729d8ce..002cf4fd5a55 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -2272,12 +2272,8 @@ __il3945_down(struct il_priv *il) * 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_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; } @@ -2285,13 +2281,9 @@ __il3945_down(struct il_priv *il) /* ...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_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); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index b251d34f0790..8930e7aa13a7 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -5384,12 +5384,8 @@ __il4965_down(struct il_priv *il) * 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_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; } @@ -5397,13 +5393,9 @@ __il4965_down(struct il_priv *il) /* ...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_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); -- GitLab From 775ed8abde9420afc955ca7540aacdce721be6c1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:24 +0100 Subject: [PATCH 0978/1846] iwlegacy: do not grab nic access if rfkill If rfkill is on il_grab_nic_access() fail and we can not write to the various registers during stop procedure. Write to those registers unconditionally instead. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 17 +++-- drivers/net/wireless/iwlegacy/3945.c | 27 ++++---- drivers/net/wireless/iwlegacy/4965-mac.c | 81 ++++++++++++++---------- drivers/net/wireless/iwlegacy/common.c | 25 ++++++-- drivers/net/wireless/iwlegacy/common.h | 4 +- 5 files changed, 97 insertions(+), 57 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 002cf4fd5a55..ee91ab2e3858 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -2286,16 +2286,25 @@ __il3945_down(struct il_priv *il) test_bit(S_FW_ERROR, &il->status) << S_FW_ERROR | test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; + /* + * We disabled and synchronized interrupt, and priv->mutex is taken, so + * here is the only thread which will program device registers, but + * still have lockdep assertions, so we are taking reg_lock. + */ + spin_lock_irq(&il->reg_lock); + /* FIXME: il_grab_nic_access if rfkill is off ? */ + 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); + _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); + _il_apm_stop(il); + spin_unlock_irq(&il->reg_lock); + + il3945_hw_txq_ctx_free(il); exit: memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 95ebd43ae537..103251dba459 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -1016,18 +1016,17 @@ 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); + _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); + _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), + FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), + 1000); } - - il3945_hw_txq_ctx_free(il); } /** @@ -2176,12 +2175,14 @@ il3945_txpower_set_from_eeprom(struct il_priv *il) int il3945_hw_rxq_stop(struct il_priv *il) { - int rc; + int ret; - 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_wr(il, FH39_RCSR_CONFIG(0), 0); + ret = _il_poll_bit(il, FH39_RSSR_STATUS, + FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, + FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, + 1000); + if (ret < 0) IL_ERR("Can't stop Rx DMA.\n"); return 0; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 8930e7aa13a7..5ebf7615808d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -441,11 +441,15 @@ il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) int il4965_rxq_stop(struct il_priv *il) { + int ret; - /* 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); + _il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); + ret = _il_poll_bit(il, FH49_MEM_RSSR_RX_STATUS_REG, + FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, + FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, + 1000); + if (ret < 0) + IL_ERR("Can't stop Rx DMA.\n"); return 0; } @@ -2031,31 +2035,10 @@ il4965_txq_ctx_reset(struct il_priv *il) } } -/** - * il4965_txq_ctx_stop - Stop all Tx DMA channels - */ void -il4965_txq_ctx_stop(struct il_priv *il) +il4965_txq_ctx_unmap(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, 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)); - } - spin_unlock_irqrestore(&il->lock, flags); + int txq_id; if (!il->txq) return; @@ -2068,6 +2051,30 @@ il4965_txq_ctx_stop(struct il_priv *il) il_tx_queue_unmap(il, txq_id); } +/** + * il4965_txq_ctx_stop - Stop all Tx DMA channels + */ +void +il4965_txq_ctx_stop(struct il_priv *il) +{ + int ch, ret; + + _il_wr_prph(il, IL49_SCD_TXFACT, 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, FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + ret = + _il_poll_bit(il, FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), + FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), + 1000); + if (ret < 0) + IL_ERR("Timeout stopping DMA channel %d [0x%08x]", + ch, _il_rd(il, FH49_TSSR_TX_STATUS_REG)); + } +} + /* * Find first available (lowest unused) Tx Queue, mark it "active". * Called only when finding queue for aggregation. @@ -5398,19 +5405,27 @@ __il4965_down(struct il_priv *il) test_bit(S_FW_ERROR, &il->status) << S_FW_ERROR | test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; + /* + * We disabled and synchronized interrupt, and priv->mutex is taken, so + * here is the only thread which will program device registers, but + * still have lockdep assertions, so we are taking reg_lock. + */ + spin_lock_irq(&il->reg_lock); + /* FIXME: il_grab_nic_access if rfkill is off ? */ + 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); + _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); - + _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); + _il_apm_stop(il); + + spin_unlock_irq(&il->reg_lock); + il4965_txq_ctx_unmap(il); exit: memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 0d1a643d8b91..f343f27e50af 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4126,12 +4126,12 @@ il_irq_handle_error(struct il_priv *il) EXPORT_SYMBOL(il_irq_handle_error); static int -il_apm_stop_master(struct il_priv *il) +_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); + _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, @@ -4145,15 +4145,17 @@ il_apm_stop_master(struct il_priv *il) } void -il_apm_stop(struct il_priv *il) +_il_apm_stop(struct il_priv *il) { + lockdep_assert_held(&il->reg_lock); + D_INFO("Stop card, put in low power state\n"); /* Stop device's DMA activity */ - il_apm_stop_master(il); + _il_apm_stop_master(il); /* Reset the entire device */ - il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + _il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); udelay(10); @@ -4161,7 +4163,18 @@ 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); + +void +il_apm_stop(struct il_priv *il) +{ + unsigned long flags; + + spin_lock_irqsave(&il->reg_lock, flags); + _il_apm_stop(il); + spin_unlock_irqrestore(&il->reg_lock, flags); } EXPORT_SYMBOL(il_apm_stop); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index a7794459d747..13bfd4394f91 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1976,7 +1976,9 @@ 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); -void il_apm_stop(struct il_priv *il); +extern void il_apm_stop(struct il_priv *il); +extern 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); -- GitLab From 586e45e31e50a9d0dda16349640b433eef002477 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:25 +0100 Subject: [PATCH 0979/1846] iwlegacy: check correct il_poll_bit error value Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index f343f27e50af..d0d408e1b367 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4136,7 +4136,7 @@ _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) + if (ret < 0) IL_WARN("Master Disable Timed Out, 100 usec\n"); D_INFO("stop master\n"); -- GitLab From 71e0c6c267595f406cf0e0699bacf10098e0f387 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:26 +0100 Subject: [PATCH 0980/1846] iwlegacy: small il4965_set_hw_ready cleanup Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 35 ++++++++++-------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 5ebf7615808d..24a3bbc23eb8 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -5446,40 +5446,36 @@ il4965_down(struct il_priv *il) il4965_cancel_deferred_work(il); } -#define HW_READY_TIMEOUT (50) -static int +static void il4965_set_hw_ready(struct il_priv *il) { - int ret = 0; + int ret; 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) + 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, + 100); + if (ret >= 0) il->hw_ready = true; - else - il->hw_ready = false; - D_INFO("hardware %s\n", (il->hw_ready == 1) ? "ready" : "not ready"); - return ret; + D_INFO("hardware %s ready\n", (il->hw_ready) ? "" : "not"); } -static int +static void il4965_prepare_card_hw(struct il_priv *il) { - int ret = 0; + int ret; - D_INFO("il4965_prepare_card_hw enter\n"); + il->hw_ready = false; - ret = il4965_set_hw_ready(il); + il4965_set_hw_ready(il); if (il->hw_ready) - return ret; + return; /* 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); @@ -5492,8 +5488,6 @@ il4965_prepare_card_hw(struct il_priv *il) /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) il4965_set_hw_ready(il); - - return ret; } #define MAX_HW_RESTARTS 5 @@ -5521,9 +5515,8 @@ __il4965_up(struct il_priv *il) } il4965_prepare_card_hw(il); - if (!il->hw_ready) { - IL_WARN("Exit HW not ready\n"); + IL_ERR("HW not ready\n"); return -EIO; } -- GitLab From 3976b4519458b27753196e63c89b2a774129e19a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 14 Feb 2012 08:50:42 +0100 Subject: [PATCH 0981/1846] iwlegacy: enable only rfkill interrupt when rfkill switch is on during IFF_UP Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 24a3bbc23eb8..cf1486132eea 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -5523,13 +5523,11 @@ __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(S_RF_KILL_HW, &il->status); - else + else { set_bit(S_RF_KILL_HW, &il->status); - - if (il_is_rfkill(il)) { wiphy_rfkill_set_hw_state(il->hw->wiphy, true); - il_enable_interrupts(il); + il_enable_rfkill_int(il); IL_WARN("Radio disabled by HW RF Kill switch\n"); return 0; } -- GitLab From d87c771f47460f7ca943942d508f2b9bd223a7e0 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:28 +0100 Subject: [PATCH 0982/1846] iwlegacy: small queue initializations cleanup Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945.c | 9 +--- drivers/net/wireless/iwlegacy/4965-mac.c | 18 ++----- drivers/net/wireless/iwlegacy/common.c | 66 +++++++++++++----------- drivers/net/wireless/iwlegacy/common.h | 20 ++++--- 4 files changed, 52 insertions(+), 61 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 103251dba459..8900e3c42b02 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -790,7 +790,6 @@ il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) static int il3945_tx_reset(struct il_priv *il) { - /* bypass mode */ il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); @@ -827,8 +826,7 @@ il3945_tx_reset(struct il_priv *il) static int il3945_txq_ctx_reset(struct il_priv *il) { - int rc; - int txq_id, slots_num; + int rc, txq_id; il3945_hw_txq_ctx_free(il); @@ -844,10 +842,7 @@ 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); + rc = il_tx_queue_init(il, txq_id); if (rc) { IL_ERR("Tx %d queue init failed\n", txq_id); goto error; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index cf1486132eea..a0158e3efd01 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1952,8 +1952,7 @@ il4965_hw_txq_ctx_free(struct il_priv *il) int il4965_txq_ctx_alloc(struct il_priv *il) { - int ret; - int txq_id, slots_num; + int ret, txq_id; unsigned long flags; /* Free all tx/cmd queues and keep-warm buffer */ @@ -1990,10 +1989,7 @@ 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); + ret = il_tx_queue_init(il, txq_id); if (ret) { IL_ERR("Tx %d queue init failed\n", txq_id); goto error; @@ -2014,25 +2010,21 @@ il4965_txq_ctx_alloc(struct il_priv *il) void il4965_txq_ctx_reset(struct il_priv *il) { - int txq_id, slots_num; + int txq_id; 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, FH49_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); - } + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + il_tx_queue_reset(il, txq_id); } void diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index d0d408e1b367..872302a3f869 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -2887,20 +2887,22 @@ 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) +il_queue_init(struct il_priv *il, struct il_queue *q, int slots, u32 id) { - q->n_bd = count; - q->n_win = slots_num; - q->id = 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)); + /* FIXME: remove q->n_bd */ + q->n_bd = TFD_QUEUE_SIZE_MAX; - /* 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)); + q->n_win = slots; + q->id = id; - /* slots_num must be power-of-two size, otherwise + /* slots_must be power-of-two size, otherwise * il_get_cmd_idx is broken. */ - BUG_ON(!is_power_of_2(slots_num)); + BUG_ON(!is_power_of_2(slots)); q->low_mark = q->n_win / 4; if (q->low_mark < 4) @@ -2959,12 +2961,11 @@ il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) * 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) +il_tx_queue_init(struct il_priv *il, u32 txq_id) { - int i, len; - int ret; - int actual_slots = slots_num; + int i, len, ret; + int slots, actual_slots; + struct il_tx_queue *txq = &il->txq[txq_id]; /* * Alloc buffer array for commands (Tx or other types of commands). @@ -2974,8 +2975,13 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, * For normal Tx queues (all other queues), no super-size command * space is needed. */ - if (txq_id == il->cmd_queue) - actual_slots++; + if (txq_id == il->cmd_queue) { + slots = TFD_CMD_SLOTS; + actual_slots = slots + 1; + } else { + slots = TFD_TX_CMD_SLOTS; + actual_slots = slots; + } txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); @@ -2988,7 +2994,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, len = sizeof(struct il_device_cmd); for (i = 0; i < actual_slots; i++) { /* only happens for cmd queue */ - if (i == slots_num) + if (i == slots) len = IL_MAX_CMD_SIZE; txq->cmd[i] = kmalloc(len, GFP_KERNEL); @@ -3011,12 +3017,8 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, 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); + il_queue_init(il, &txq->q, slots, txq_id); /* Tell device where to find queue */ il->ops->txq_init(il, txq); @@ -3034,20 +3036,24 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, 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) +il_tx_queue_reset(struct il_priv *il, u32 txq_id) { - int actual_slots = slots_num; + int slots, actual_slots; + struct il_tx_queue *txq = &il->txq[txq_id]; - if (txq_id == il->cmd_queue) - actual_slots++; + if (txq_id == il->cmd_queue) { + slots = TFD_CMD_SLOTS; + actual_slots = TFD_CMD_SLOTS + 1; + } else { + slots = TFD_TX_CMD_SLOTS; + actual_slots = TFD_TX_CMD_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); + il_queue_init(il, &txq->q, slots, txq_id); /* Tell device where to find queue */ il->ops->txq_init(il, txq); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 13bfd4394f91..e2f55dc86936 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1783,14 +1783,12 @@ void il_chswitch_done(struct il_priv *il, bool is_success); /***************************************************** * 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); +extern void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); +extern int il_tx_queue_init(struct il_priv *il, u32 txq_id); +extern void il_tx_queue_reset(struct il_priv *il, u32 txq_id); +extern void il_tx_queue_unmap(struct il_priv *il, int txq_id); +extern void il_tx_queue_free(struct il_priv *il, int txq_id); +extern void il_setup_watchdog(struct il_priv *il); /***************************************************** * TX power ****************************************************/ @@ -2405,10 +2403,10 @@ struct il_rb_status { __le32 __unused; /* 3945 only */ } __packed; -#define TFD_QUEUE_SIZE_MAX (256) -#define TFD_QUEUE_SIZE_BC_DUP (64) +#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_TX_DMA_MASK DMA_BIT_MASK(36) #define IL_NUM_OF_TBS 20 static inline u8 -- GitLab From bc269a8e2701aaa6c53553eaef9f0866ef03e703 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:29 +0100 Subject: [PATCH 0983/1846] iwlegacy: s/S_RF_KILL_HW/S_RFKILL/g Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945-mac.c | 30 ++++++++++++------------ drivers/net/wireless/iwlegacy/4965-mac.c | 28 +++++++++++----------- drivers/net/wireless/iwlegacy/common.c | 6 ++--- drivers/net/wireless/iwlegacy/common.h | 4 ++-- drivers/net/wireless/iwlegacy/debug.c | 4 ++-- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index ee91ab2e3858..0ccc934a35bb 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -809,16 +809,16 @@ il3945_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) _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); + set_bit(S_RFKILL, &il->status); else - clear_bit(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); il_scan_cancel(il); - if ((test_bit(S_RF_KILL_HW, &status) != - test_bit(S_RF_KILL_HW, &il->status))) + if ((test_bit(S_RFKILL, &status) != + test_bit(S_RFKILL, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RFKILL, &il->status)); else wake_up(&il->wait_command_queue); } @@ -2166,7 +2166,7 @@ il3945_alive_start(struct il_priv *il) D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { - clear_bit(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ while (il3945_hw_get_temperature(il) == 0) { @@ -2178,7 +2178,7 @@ il3945_alive_start(struct il_priv *il) D_INFO("Thermal calibration took %dus\n", thermal_spin * 10); } else - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); /* After the ALIVE response, we can send commands to 3945 uCode */ set_bit(S_ALIVE, &il->status); @@ -2272,7 +2272,7 @@ __il3945_down(struct il_priv *il) * 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_RFKILL, &il->status) << S_RFKILL | test_bit(S_GEO_CONFIGURED, &il->status) << S_GEO_CONFIGURED | test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; goto exit; @@ -2281,7 +2281,7 @@ __il3945_down(struct il_priv *il) /* ...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_RFKILL, &il->status) << S_RFKILL | 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; @@ -2371,9 +2371,9 @@ __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(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); else { - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); IL_WARN("Radio disabled by HW RF Kill switch\n"); return -ENODEV; } @@ -2405,7 +2405,7 @@ __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(S_RF_KILL_HW, &il->status)) + if (test_bit(S_RFKILL, &il->status)) return 0; for (i = 0; i < MAX_HW_RESTARTS; i++) { @@ -2485,15 +2485,15 @@ 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 old_rfkill = test_bit(S_RFKILL, &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(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); else - clear_bit(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index a0158e3efd01..3aa0ee5458f9 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -4110,17 +4110,17 @@ il4965_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) il4965_perform_ct_kill_task(il); if (flags & HW_CARD_DISABLED) - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); else - clear_bit(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); if (!(flags & RXON_CARD_DISABLED)) il_scan_cancel(il); - if ((test_bit(S_RF_KILL_HW, &status) != - test_bit(S_RF_KILL_HW, &il->status))) + if ((test_bit(S_RFKILL, &status) != + test_bit(S_RFKILL, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RFKILL, &il->status)); else wake_up(&il->wait_command_queue); } @@ -4412,9 +4412,9 @@ il4965_irq_tasklet(struct il_priv *il) */ if (!test_bit(S_ALIVE, &il->status)) { if (hw_rf_kill) - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); else - clear_bit(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); } @@ -5383,7 +5383,7 @@ __il4965_down(struct il_priv *il) * 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_RFKILL, &il->status) << S_RFKILL | test_bit(S_GEO_CONFIGURED, &il->status) << S_GEO_CONFIGURED | test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; goto exit; @@ -5392,7 +5392,7 @@ __il4965_down(struct il_priv *il) /* ...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_RFKILL, &il->status) << S_RFKILL | 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; @@ -5514,9 +5514,9 @@ __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(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); else { - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, true); il_enable_rfkill_int(il); @@ -6612,12 +6612,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(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); else - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RFKILL, &il->status)); il_power_initialize(il); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 872302a3f869..defe8d9a4f59 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -350,7 +350,7 @@ il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } } - if (test_bit(S_RF_KILL_HW, &il->status)) { + if (test_bit(S_RFKILL, &il->status)) { IL_ERR("Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; @@ -4890,9 +4890,9 @@ il_pci_resume(struct device *device) hw_rfkill = true; if (hw_rfkill) - set_bit(S_RF_KILL_HW, &il->status); + set_bit(S_RFKILL, &il->status); else - clear_bit(S_RF_KILL_HW, &il->status); + clear_bit(S_RFKILL, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index e2f55dc86936..42820183dbe1 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1906,7 +1906,7 @@ void il_free_geos(struct il_priv *il); #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_RFKILL 3 #define S_CT_KILL 4 #define S_INIT 5 #define S_ALIVE 6 @@ -1947,7 +1947,7 @@ il_is_init(struct il_priv *il) static inline int il_is_rfkill_hw(struct il_priv *il) { - return test_bit(S_RF_KILL_HW, &il->status); + return test_bit(S_RFKILL, &il->status); } static inline int diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 236dc90b035b..229849150aac 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -630,8 +630,8 @@ il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, 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)); + scnprintf(buf + pos, bufsz - pos, "S_RFKILL:\t %d\n", + test_bit(S_RFKILL, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", test_bit(S_CT_KILL, &il->status)); -- GitLab From 6668e4eb5030af96d2bde366b8f6614b34b8c96c Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:30 +0100 Subject: [PATCH 0984/1846] iwlegacy: s/il_txq_mem/il_free_txq_mem/g Previous name was confusing. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/3945.c | 2 +- drivers/net/wireless/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/iwlegacy/common.c | 4 ++-- drivers/net/wireless/iwlegacy/common.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 8900e3c42b02..456f32da6b26 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -1002,7 +1002,7 @@ il3945_hw_txq_ctx_free(struct il_priv *il) il_tx_queue_free(il, txq_id); /* free tx queue structure */ - il_txq_mem(il); + il_free_txq_mem(il); } void diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 3aa0ee5458f9..2d01db0f08e0 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1939,7 +1939,7 @@ il4965_hw_txq_ctx_free(struct il_priv *il) il4965_free_dma_ptr(il, &il->scd_bc_tbls); /* free tx queue structure */ - il_txq_mem(il); + il_free_txq_mem(il); } /** diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index defe8d9a4f59..b42052b47d8e 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -4591,12 +4591,12 @@ il_alloc_txq_mem(struct il_priv *il) EXPORT_SYMBOL(il_alloc_txq_mem); void -il_txq_mem(struct il_priv *il) +il_free_txq_mem(struct il_priv *il) { kfree(il->txq); il->txq = NULL; } -EXPORT_SYMBOL(il_txq_mem); +EXPORT_SYMBOL(il_free_txq_mem); int il_force_reset(struct il_priv *il, bool external) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 42820183dbe1..cee72f1523f7 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1747,7 +1747,7 @@ 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 *il); -void il_txq_mem(struct il_priv *il); +void il_free_txq_mem(struct il_priv *il); #ifdef CONFIG_IWLEGACY_DEBUGFS extern void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len); -- GitLab From 4e3bc141d480661634d0fadad7dbb1ddde70b4d4 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 13 Feb 2012 11:23:31 +0100 Subject: [PATCH 0985/1846] iwlegacy: remove il_is_rfkill_hw Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index cee72f1523f7..6ed9871f1c4b 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1944,16 +1944,10 @@ 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_RFKILL, &il->status); -} - static inline int il_is_rfkill(struct il_priv *il) { - return il_is_rfkill_hw(il); + return test_bit(S_RFKILL, &il->status); } static inline int -- GitLab From 8860020e0be1f03d83dc9e9e93e18a4ddbe01038 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 13 Feb 2012 15:17:18 +0100 Subject: [PATCH 0986/1846] cfg80211: restructure AP/GO mode API The AP/GO mode API isn't very clearly defined, it has "set beacon" and "new beacon" etc. Modify the API to the following: * start AP -- all settings * change beacon -- new beacon data * stop AP -- stop AP mode operation This also reflects in the nl80211 API, rename the commands there correspondingly (but keep the old names for compatibility.) Overall, this makes it much clearer what's going on in the API. Kalle developed the ath6kl changes, I created the rest of the patch. Signed-off-by: Kalle Valo Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 82 ++++--- include/linux/nl80211.h | 34 +-- include/net/cfg80211.h | 70 +++--- net/mac80211/cfg.c | 146 +++++------- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/tx.c | 13 +- net/wireless/nl80211.c | 255 ++++++++++++--------- 7 files changed, 316 insertions(+), 286 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d1922d8eb3bb..5370333883e4 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2269,25 +2269,11 @@ static int ath6kl_set_ap_probe_resp_ies(struct ath6kl_vif *vif, return ret; } -static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info, bool add) +static int ath6kl_set_ies(struct ath6kl_vif *vif, + struct cfg80211_beacon_data *info) { - struct ath6kl *ar = ath6kl_priv(dev); - struct ath6kl_vif *vif = netdev_priv(dev); - struct ieee80211_mgmt *mgmt; - u8 *ies; - int ies_len; - struct wmi_connect_cmd p; + struct ath6kl *ar = vif->ar; int res; - int i, ret; - - ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: add=%d\n", __func__, add); - - if (!ath6kl_cfg80211_ready(vif)) - return -EIO; - - if (vif->next_mode != AP_NETWORK) - return -EOPNOTSUPP; if (info->beacon_ies) { res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, @@ -2297,12 +2283,14 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, if (res) return res; } + if (info->proberesp_ies) { res = ath6kl_set_ap_probe_resp_ies(vif, info->proberesp_ies, info->proberesp_ies_len); if (res) return res; } + if (info->assocresp_ies) { res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, WMI_FRAME_ASSOC_RESP, @@ -2312,8 +2300,30 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, return res; } - if (!add) - return 0; + return 0; +} + +static int ath6kl_start_ap(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ap_settings *info) +{ + struct ath6kl *ar = ath6kl_priv(dev); + struct ath6kl_vif *vif = netdev_priv(dev); + struct ieee80211_mgmt *mgmt; + u8 *ies; + int ies_len; + struct wmi_connect_cmd p; + int res; + int i, ret; + + ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s:\n", __func__); + + if (!ath6kl_cfg80211_ready(vif)) + return -EIO; + + if (vif->next_mode != AP_NETWORK) + return -EOPNOTSUPP; + + res = ath6kl_set_ies(vif, &info->beacon); ar->ap_mode_bkey.valid = false; @@ -2322,13 +2332,13 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, * info->dtim_period */ - if (info->head == NULL) + if (info->beacon.head == NULL) return -EINVAL; - mgmt = (struct ieee80211_mgmt *) info->head; + mgmt = (struct ieee80211_mgmt *) info->beacon.head; ies = mgmt->u.beacon.variable; - if (ies > info->head + info->head_len) + if (ies > info->beacon.head + info->beacon.head_len) return -EINVAL; - ies_len = info->head + info->head_len - ies; + ies_len = info->beacon.head + info->beacon.head_len - ies; if (info->ssid == NULL) return -EINVAL; @@ -2436,19 +2446,21 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, return 0; } -static int ath6kl_add_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info) +static int ath6kl_change_beacon(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_beacon_data *beacon) { - return ath6kl_ap_beacon(wiphy, dev, info, true); -} + struct ath6kl_vif *vif = netdev_priv(dev); -static int ath6kl_set_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info) -{ - return ath6kl_ap_beacon(wiphy, dev, info, false); + if (!ath6kl_cfg80211_ready(vif)) + return -EIO; + + if (vif->next_mode != AP_NETWORK) + return -EOPNOTSUPP; + + return ath6kl_set_ies(vif, beacon); } -static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev) +static int ath6kl_stop_ap(struct wiphy *wiphy, struct net_device *dev) { struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); @@ -2783,9 +2795,9 @@ static struct cfg80211_ops ath6kl_cfg80211_ops = { .resume = __ath6kl_cfg80211_resume, #endif .set_channel = ath6kl_set_channel, - .add_beacon = ath6kl_add_beacon, - .set_beacon = ath6kl_set_beacon, - .del_beacon = ath6kl_del_beacon, + .start_ap = ath6kl_start_ap, + .change_beacon = ath6kl_change_beacon, + .stop_ap = ath6kl_stop_ap, .del_station = ath6kl_del_station, .change_station = ath6kl_change_station, .remain_on_channel = ath6kl_remain_on_channel, diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index ad56e21a9f10..be35a68746a7 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -156,21 +156,23 @@ * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX * or %NL80211_ATTR_MAC. * - * @NL80211_CMD_GET_BEACON: retrieve beacon information (returned in a - * %NL80222_CMD_NEW_BEACON message) - * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface - * using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD, - * %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL attributes. - * Following attributes are provided for drivers that generate full Beacon - * and Probe Response frames internally: %NL80211_ATTR_SSID, + * @NL80211_CMD_GET_BEACON: (not used) + * @NL80211_CMD_SET_BEACON: change the beacon on an access point interface + * using the %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL + * attributes. For drivers that generate the beacon and probe responses + * internally, the following attributes must be provided: %NL80211_ATTR_IE, + * %NL80211_ATTR_IE_PROBE_RESP and %NL80211_ATTR_IE_ASSOC_RESP. + * @NL80211_CMD_START_AP: Start AP operation on an AP interface, parameters + * are like for %NL80211_CMD_SET_BEACON, and additionally parameters that + * do not change are used, these include %NL80211_ATTR_BEACON_INTERVAL, + * %NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID, * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE, * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS, - * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY, - * %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_IE, %NL80211_ATTR_IE_PROBE_RESP, - * %NL80211_ATTR_IE_ASSOC_RESP. - * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface, - * parameters are like for %NL80211_CMD_SET_BEACON. - * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it + * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY and + * %NL80211_ATTR_AUTH_TYPE. + * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP + * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface + * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP * * @NL80211_CMD_GET_STATION: Get station attributes for station identified by * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX. @@ -565,8 +567,10 @@ enum nl80211_commands { NL80211_CMD_GET_BEACON, NL80211_CMD_SET_BEACON, - NL80211_CMD_NEW_BEACON, - NL80211_CMD_DEL_BEACON, + NL80211_CMD_START_AP, + NL80211_CMD_NEW_BEACON = NL80211_CMD_START_AP, + NL80211_CMD_STOP_AP, + NL80211_CMD_DEL_BEACON = NL80211_CMD_STOP_AP, NL80211_CMD_GET_STATION, NL80211_CMD_SET_STATION, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index e0c9ff3a1977..755a7707a7c5 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -366,25 +366,13 @@ struct cfg80211_crypto_settings { }; /** - * struct beacon_parameters - beacon parameters - * - * Used to configure the beacon for an interface. - * + * struct cfg80211_beacon_data - beacon data * @head: head portion of beacon (before TIM IE) * or %NULL if not changed * @tail: tail portion of beacon (after TIM IE) * or %NULL if not changed - * @interval: beacon interval or zero if not changed - * @dtim_period: DTIM period or zero if not changed * @head_len: length of @head * @tail_len: length of @tail - * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from - * user space) - * @ssid_len: length of @ssid - * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames - * @crypto: crypto settings - * @privacy: the BSS uses privacy - * @auth_type: Authentication type (algorithm) * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL * @beacon_ies_len: length of beacon_ies in octets * @proberesp_ies: extra information element(s) to add into Probe Response @@ -396,24 +384,46 @@ struct cfg80211_crypto_settings { * @probe_resp_len: length of probe response template (@probe_resp) * @probe_resp: probe response template (AP mode only) */ -struct beacon_parameters { - u8 *head, *tail; - int interval, dtim_period; - int head_len, tail_len; +struct cfg80211_beacon_data { + const u8 *head, *tail; + const u8 *beacon_ies; + const u8 *proberesp_ies; + const u8 *assocresp_ies; + const u8 *probe_resp; + + size_t head_len, tail_len; + size_t beacon_ies_len; + size_t proberesp_ies_len; + size_t assocresp_ies_len; + size_t probe_resp_len; +}; + +/** + * struct cfg80211_ap_settings - AP configuration + * + * Used to configure an AP interface. + * + * @beacon: beacon data + * @beacon_interval: beacon interval + * @dtim_period: DTIM period + * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from + * user space) + * @ssid_len: length of @ssid + * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames + * @crypto: crypto settings + * @privacy: the BSS uses privacy + * @auth_type: Authentication type (algorithm) + */ +struct cfg80211_ap_settings { + struct cfg80211_beacon_data beacon; + + int beacon_interval, dtim_period; const u8 *ssid; size_t ssid_len; enum nl80211_hidden_ssid hidden_ssid; struct cfg80211_crypto_settings crypto; bool privacy; enum nl80211_auth_type auth_type; - const u8 *beacon_ies; - size_t beacon_ies_len; - const u8 *proberesp_ies; - size_t proberesp_ies_len; - const u8 *assocresp_ies; - size_t assocresp_ies_len; - int probe_resp_len; - u8 *probe_resp; }; /** @@ -1518,11 +1528,11 @@ struct cfg80211_ops { struct net_device *netdev, u8 key_index); - int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info); - int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info); - int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev); + int (*start_ap)(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ap_settings *settings); + int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_beacon_data *info); + int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev); int (*add_station)(struct wiphy *wiphy, struct net_device *dev, diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index c3de921c8cfd..f7eb25aabf8f 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -489,27 +489,13 @@ static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, return ret; } -static void ieee80211_config_ap_ssid(struct ieee80211_sub_if_data *sdata, - struct beacon_parameters *params) -{ - struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; - - bss_conf->ssid_len = params->ssid_len; - - if (params->ssid_len) - memcpy(bss_conf->ssid, params->ssid, params->ssid_len); - - bss_conf->hidden_ssid = - (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); -} - static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, - u8 *resp, size_t resp_len) + const u8 *resp, size_t resp_len) { struct sk_buff *new, *old; if (!resp || !resp_len) - return -EINVAL; + return 1; old = rtnl_dereference(sdata->u.ap.probe_resp); @@ -520,50 +506,28 @@ static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, memcpy(skb_put(new, resp_len), resp, resp_len); rcu_assign_pointer(sdata->u.ap.probe_resp, new); - synchronize_rcu(); - - if (old) + if (old) { + /* TODO: use call_rcu() */ + synchronize_rcu(); dev_kfree_skb(old); + } return 0; } -/* - * This handles both adding a beacon and setting new beacon info - */ -static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, - struct beacon_parameters *params) +static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, + struct cfg80211_beacon_data *params) { struct beacon_data *new, *old; int new_head_len, new_tail_len; - int size; - int err = -EINVAL; - u32 changed = 0; + int size, err; + u32 changed = BSS_CHANGED_BEACON; old = rtnl_dereference(sdata->u.ap.beacon); - /* head must not be zero-length */ - if (params->head && !params->head_len) - return -EINVAL; - - /* - * This is a kludge. beacon interval should really be part - * of the beacon information. - */ - if (params->interval && - (sdata->vif.bss_conf.beacon_int != params->interval)) { - sdata->vif.bss_conf.beacon_int = params->interval; - ieee80211_bss_info_change_notify(sdata, - BSS_CHANGED_BEACON_INT); - } - /* Need to have a beacon head if we don't have one yet */ if (!params->head && !old) - return err; - - /* sorry, no way to start beaconing without dtim period */ - if (!params->dtim_period && !old) - return err; + return -EINVAL; /* new or old head? */ if (params->head) @@ -586,12 +550,6 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, /* start filling the new info now */ - /* new or old dtim period? */ - if (params->dtim_period) - new->dtim_period = params->dtim_period; - else - new->dtim_period = old->dtim_period; - /* * pointers go into the block we allocated, * memory is | beacon_data | head | tail | @@ -614,46 +572,37 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, if (old) memcpy(new->tail, old->tail, new_tail_len); - sdata->vif.bss_conf.dtim_period = new->dtim_period; - - rcu_assign_pointer(sdata->u.ap.beacon, new); - - synchronize_rcu(); - - kfree(old); - err = ieee80211_set_probe_resp(sdata, params->probe_resp, params->probe_resp_len); - if (!err) + if (err < 0) + return err; + if (err == 0) changed |= BSS_CHANGED_AP_PROBE_RESP; - ieee80211_config_ap_ssid(sdata, params); - changed |= BSS_CHANGED_BEACON_ENABLED | - BSS_CHANGED_BEACON | - BSS_CHANGED_SSID; + rcu_assign_pointer(sdata->u.ap.beacon, new); + + if (old) + kfree_rcu(old, rcu_head); - ieee80211_bss_info_change_notify(sdata, changed); - return 0; + return changed; } -static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *params) +static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ap_settings *params) { - struct ieee80211_sub_if_data *sdata; + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); struct beacon_data *old; struct ieee80211_sub_if_data *vlan; - int ret; - - sdata = IEEE80211_DEV_TO_SUB_IF(dev); + u32 changed = BSS_CHANGED_BEACON_INT | + BSS_CHANGED_BEACON_ENABLED | + BSS_CHANGED_BEACON | + BSS_CHANGED_SSID; + int err; old = rtnl_dereference(sdata->u.ap.beacon); if (old) return -EALREADY; - ret = ieee80211_config_beacon(sdata, params); - if (ret) - return ret; - /* * Apply control port protocol, this allows us to * not encrypt dynamic WEP control frames. @@ -667,14 +616,32 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, params->crypto.control_port_no_encrypt; } + sdata->vif.bss_conf.beacon_int = params->beacon_interval; + sdata->vif.bss_conf.dtim_period = params->dtim_period; + + sdata->vif.bss_conf.ssid_len = params->ssid_len; + if (params->ssid_len) + memcpy(sdata->vif.bss_conf.ssid, params->ssid, + params->ssid_len); + sdata->vif.bss_conf.hidden_ssid = + (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); + + err = ieee80211_assign_beacon(sdata, ¶ms->beacon); + if (err < 0) + return err; + changed |= err; + + ieee80211_bss_info_change_notify(sdata, changed); + return 0; } -static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *params) +static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_beacon_data *params) { struct ieee80211_sub_if_data *sdata; struct beacon_data *old; + int err; sdata = IEEE80211_DEV_TO_SUB_IF(dev); @@ -682,10 +649,14 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, if (!old) return -ENOENT; - return ieee80211_config_beacon(sdata, params); + err = ieee80211_assign_beacon(sdata, params); + if (err < 0) + return err; + ieee80211_bss_info_change_notify(sdata, err); + return 0; } -static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) +static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) { struct ieee80211_sub_if_data *sdata; struct beacon_data *old; @@ -697,10 +668,11 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) return -ENOENT; RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); - synchronize_rcu(); - kfree(old); + + kfree_rcu(old, rcu_head); ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); + return 0; } @@ -2699,9 +2671,9 @@ struct cfg80211_ops mac80211_config_ops = { .get_key = ieee80211_get_key, .set_default_key = ieee80211_config_default_key, .set_default_mgmt_key = ieee80211_config_default_mgmt_key, - .add_beacon = ieee80211_add_beacon, - .set_beacon = ieee80211_set_beacon, - .del_beacon = ieee80211_del_beacon, + .start_ap = ieee80211_start_ap, + .change_beacon = ieee80211_change_beacon, + .stop_ap = ieee80211_stop_ap, .add_station = ieee80211_add_station, .del_station = ieee80211_del_station, .change_station = ieee80211_change_station, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 74594f012cd3..67aed1eff135 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -228,7 +228,7 @@ struct ieee80211_rx_data { struct beacon_data { u8 *head, *tail; int head_len, tail_len; - int dtim_period; + struct rcu_head rcu_head; }; struct ieee80211_if_ap { diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 1be0ca2b5936..c6eadac9ca4e 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2206,7 +2206,8 @@ void ieee80211_tx_pending(unsigned long data) /* functions for drivers to get certain frames */ -static void ieee80211_beacon_add_tim(struct ieee80211_if_ap *bss, +static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, + struct ieee80211_if_ap *bss, struct sk_buff *skb, struct beacon_data *beacon) { @@ -2223,7 +2224,7 @@ static void ieee80211_beacon_add_tim(struct ieee80211_if_ap *bss, IEEE80211_MAX_AID+1); if (bss->dtim_count == 0) - bss->dtim_count = beacon->dtim_period - 1; + bss->dtim_count = sdata->vif.bss_conf.dtim_period - 1; else bss->dtim_count--; @@ -2231,7 +2232,7 @@ static void ieee80211_beacon_add_tim(struct ieee80211_if_ap *bss, *pos++ = WLAN_EID_TIM; *pos++ = 4; *pos++ = bss->dtim_count; - *pos++ = beacon->dtim_period; + *pos++ = sdata->vif.bss_conf.dtim_period; if (bss->dtim_count == 0 && !skb_queue_empty(&bss->ps_bc_buf)) aid0 = 1; @@ -2324,12 +2325,14 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, * of the tim bitmap in mac80211 and the driver. */ if (local->tim_in_locked_section) { - ieee80211_beacon_add_tim(ap, skb, beacon); + ieee80211_beacon_add_tim(sdata, ap, skb, + beacon); } else { unsigned long flags; spin_lock_irqsave(&local->tim_lock, flags); - ieee80211_beacon_add_tim(ap, skb, beacon); + ieee80211_beacon_add_tim(sdata, ap, skb, + beacon); spin_unlock_irqrestore(&local->tim_lock, flags); } diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index fe2747653564..1998c3682774 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -871,7 +871,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, CMD(add_virtual_intf, NEW_INTERFACE); CMD(change_virtual_intf, SET_INTERFACE); CMD(add_key, NEW_KEY); - CMD(add_beacon, NEW_BEACON); + CMD(start_ap, START_AP); CMD(add_station, NEW_STATION); CMD(add_mpath, NEW_MPATH); CMD(update_mesh_config, SET_MESH_CONFIG); @@ -2075,15 +2075,10 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) return err; } -static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info) +static int nl80211_parse_beacon(struct genl_info *info, + struct cfg80211_beacon_data *bcn) { - int (*call)(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info); - struct cfg80211_registered_device *rdev = info->user_ptr[0]; - struct net_device *dev = info->user_ptr[1]; - struct wireless_dev *wdev = dev->ieee80211_ptr; - struct beacon_parameters params; - int haveinfo = 0, err; + bool haveinfo = false; if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_BEACON_TAIL]) || !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]) || @@ -2091,149 +2086,183 @@ static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info) !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_ASSOC_RESP])) return -EINVAL; - if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && - dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) - return -EOPNOTSUPP; - - memset(¶ms, 0, sizeof(params)); - - switch (info->genlhdr->cmd) { - case NL80211_CMD_NEW_BEACON: - /* these are required for NEW_BEACON */ - if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] || - !info->attrs[NL80211_ATTR_DTIM_PERIOD] || - !info->attrs[NL80211_ATTR_BEACON_HEAD]) - return -EINVAL; - - params.interval = - nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); - params.dtim_period = - nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); - - err = cfg80211_validate_beacon_int(rdev, params.interval); - if (err) - return err; - - /* - * In theory, some of these attributes could be required for - * NEW_BEACON, but since they were not used when the command was - * originally added, keep them optional for old user space - * programs to work with drivers that do not need the additional - * information. - */ - if (info->attrs[NL80211_ATTR_SSID]) { - params.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); - params.ssid_len = - nla_len(info->attrs[NL80211_ATTR_SSID]); - if (params.ssid_len == 0 || - params.ssid_len > IEEE80211_MAX_SSID_LEN) - return -EINVAL; - } - - if (info->attrs[NL80211_ATTR_HIDDEN_SSID]) { - params.hidden_ssid = nla_get_u32( - info->attrs[NL80211_ATTR_HIDDEN_SSID]); - if (params.hidden_ssid != - NL80211_HIDDEN_SSID_NOT_IN_USE && - params.hidden_ssid != - NL80211_HIDDEN_SSID_ZERO_LEN && - params.hidden_ssid != - NL80211_HIDDEN_SSID_ZERO_CONTENTS) - return -EINVAL; - } - - params.privacy = !!info->attrs[NL80211_ATTR_PRIVACY]; - - if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { - params.auth_type = nla_get_u32( - info->attrs[NL80211_ATTR_AUTH_TYPE]); - if (!nl80211_valid_auth_type(params.auth_type)) - return -EINVAL; - } else - params.auth_type = NL80211_AUTHTYPE_AUTOMATIC; - - err = nl80211_crypto_settings(rdev, info, ¶ms.crypto, - NL80211_MAX_NR_CIPHER_SUITES); - if (err) - return err; - - call = rdev->ops->add_beacon; - break; - case NL80211_CMD_SET_BEACON: - call = rdev->ops->set_beacon; - break; - default: - WARN_ON(1); - return -EOPNOTSUPP; - } - - if (!call) - return -EOPNOTSUPP; + memset(bcn, 0, sizeof(*bcn)); if (info->attrs[NL80211_ATTR_BEACON_HEAD]) { - params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]); - params.head_len = - nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]); - haveinfo = 1; + bcn->head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]); + bcn->head_len = nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]); + if (!bcn->head_len) + return -EINVAL; + haveinfo = true; } if (info->attrs[NL80211_ATTR_BEACON_TAIL]) { - params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]); - params.tail_len = + bcn->tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]); + bcn->tail_len = nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]); - haveinfo = 1; + haveinfo = true; } if (!haveinfo) return -EINVAL; if (info->attrs[NL80211_ATTR_IE]) { - params.beacon_ies = nla_data(info->attrs[NL80211_ATTR_IE]); - params.beacon_ies_len = nla_len(info->attrs[NL80211_ATTR_IE]); + bcn->beacon_ies = nla_data(info->attrs[NL80211_ATTR_IE]); + bcn->beacon_ies_len = nla_len(info->attrs[NL80211_ATTR_IE]); } if (info->attrs[NL80211_ATTR_IE_PROBE_RESP]) { - params.proberesp_ies = + bcn->proberesp_ies = nla_data(info->attrs[NL80211_ATTR_IE_PROBE_RESP]); - params.proberesp_ies_len = + bcn->proberesp_ies_len = nla_len(info->attrs[NL80211_ATTR_IE_PROBE_RESP]); } if (info->attrs[NL80211_ATTR_IE_ASSOC_RESP]) { - params.assocresp_ies = + bcn->assocresp_ies = nla_data(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); - params.assocresp_ies_len = + bcn->assocresp_ies_len = nla_len(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); } if (info->attrs[NL80211_ATTR_PROBE_RESP]) { - params.probe_resp = + bcn->probe_resp = nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]); - params.probe_resp_len = + bcn->probe_resp_len = nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]); } - err = call(&rdev->wiphy, dev, ¶ms); - if (!err && params.interval) - wdev->beacon_interval = params.interval; + return 0; +} + +static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_ap_settings params; + int err; + + if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && + dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) + return -EOPNOTSUPP; + + if (!rdev->ops->start_ap) + return -EOPNOTSUPP; + + if (wdev->beacon_interval) + return -EALREADY; + + memset(¶ms, 0, sizeof(params)); + + /* these are required for START_AP */ + if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] || + !info->attrs[NL80211_ATTR_DTIM_PERIOD] || + !info->attrs[NL80211_ATTR_BEACON_HEAD]) + return -EINVAL; + + err = nl80211_parse_beacon(info, ¶ms.beacon); + if (err) + return err; + + params.beacon_interval = + nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]); + params.dtim_period = + nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]); + + err = cfg80211_validate_beacon_int(rdev, params.beacon_interval); + if (err) + return err; + + /* + * In theory, some of these attributes should be required here + * but since they were not used when the command was originally + * added, keep them optional for old user space programs to let + * them continue to work with drivers that do not need the + * additional information -- drivers must check! + */ + if (info->attrs[NL80211_ATTR_SSID]) { + params.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); + params.ssid_len = + nla_len(info->attrs[NL80211_ATTR_SSID]); + if (params.ssid_len == 0 || + params.ssid_len > IEEE80211_MAX_SSID_LEN) + return -EINVAL; + } + + if (info->attrs[NL80211_ATTR_HIDDEN_SSID]) { + params.hidden_ssid = nla_get_u32( + info->attrs[NL80211_ATTR_HIDDEN_SSID]); + if (params.hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE && + params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_LEN && + params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_CONTENTS) + return -EINVAL; + } + + params.privacy = !!info->attrs[NL80211_ATTR_PRIVACY]; + + if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { + params.auth_type = nla_get_u32( + info->attrs[NL80211_ATTR_AUTH_TYPE]); + if (!nl80211_valid_auth_type(params.auth_type)) + return -EINVAL; + } else + params.auth_type = NL80211_AUTHTYPE_AUTOMATIC; + + err = nl80211_crypto_settings(rdev, info, ¶ms.crypto, + NL80211_MAX_NR_CIPHER_SUITES); + if (err) + return err; + + err = rdev->ops->start_ap(&rdev->wiphy, dev, ¶ms); + if (!err) + wdev->beacon_interval = params.beacon_interval; return err; } -static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info) +static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_beacon_data params; + int err; + + if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && + dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) + return -EOPNOTSUPP; + + if (!rdev->ops->change_beacon) + return -EOPNOTSUPP; + + if (!wdev->beacon_interval) + return -EINVAL; + + err = nl80211_parse_beacon(info, ¶ms); + if (err) + return err; + + return rdev->ops->change_beacon(&rdev->wiphy, dev, ¶ms); +} + +static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info) { struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct net_device *dev = info->user_ptr[1]; struct wireless_dev *wdev = dev->ieee80211_ptr; int err; - if (!rdev->ops->del_beacon) + if (!rdev->ops->stop_ap) return -EOPNOTSUPP; if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) return -EOPNOTSUPP; - err = rdev->ops->del_beacon(&rdev->wiphy, dev); + if (!wdev->beacon_interval) + return -ENOENT; + + err = rdev->ops->stop_ap(&rdev->wiphy, dev); if (!err) wdev->beacon_interval = 0; return err; @@ -6357,23 +6386,23 @@ static struct genl_ops nl80211_ops[] = { .cmd = NL80211_CMD_SET_BEACON, .policy = nl80211_policy, .flags = GENL_ADMIN_PERM, - .doit = nl80211_addset_beacon, + .doit = nl80211_set_beacon, .internal_flags = NL80211_FLAG_NEED_NETDEV | NL80211_FLAG_NEED_RTNL, }, { - .cmd = NL80211_CMD_NEW_BEACON, + .cmd = NL80211_CMD_START_AP, .policy = nl80211_policy, .flags = GENL_ADMIN_PERM, - .doit = nl80211_addset_beacon, + .doit = nl80211_start_ap, .internal_flags = NL80211_FLAG_NEED_NETDEV | NL80211_FLAG_NEED_RTNL, }, { - .cmd = NL80211_CMD_DEL_BEACON, + .cmd = NL80211_CMD_STOP_AP, .policy = nl80211_policy, .flags = GENL_ADMIN_PERM, - .doit = nl80211_del_beacon, + .doit = nl80211_stop_ap, .internal_flags = NL80211_FLAG_NEED_NETDEV | NL80211_FLAG_NEED_RTNL, }, -- GitLab From cede8b64808f543fb5ed4991af330a0ae6026805 Mon Sep 17 00:00:00 2001 From: Jonathan Bither Date: Mon, 13 Feb 2012 21:47:45 -0500 Subject: [PATCH 0987/1846] ath5k:Remove __raw_read and __raw_write By swithing from our __raw_read and __raw_write functions to ioread32 and iowrite32, benchmarks on my desk with iperf went from 11MBps to 18.1MBps using the AHB bus on an EnGenius ECB3500 running OpenWRT. Signed-off-by: Jonathan Bither Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ahb.c | 20 ++++++++++---------- drivers/net/wireless/ath/ath5k/ath5k.h | 4 ++-- drivers/net/wireless/ath/ath5k/reset.c | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath5k/ahb.c b/drivers/net/wireless/ath/ath5k/ahb.c index ee7ea572b065..8faa129da5a0 100644 --- a/drivers/net/wireless/ath/ath5k/ahb.c +++ b/drivers/net/wireless/ath/ath5k/ahb.c @@ -140,23 +140,23 @@ static int ath_ahb_probe(struct platform_device *pdev) if (bcfg->devid >= AR5K_SREV_AR2315_R6) { /* Enable WMAC AHB arbitration */ - reg = __raw_readl((void __iomem *) AR5K_AR2315_AHB_ARB_CTL); + reg = ioread32((void __iomem *) AR5K_AR2315_AHB_ARB_CTL); reg |= AR5K_AR2315_AHB_ARB_CTL_WLAN; - __raw_writel(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL); + iowrite32(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL); /* Enable global WMAC swapping */ - reg = __raw_readl((void __iomem *) AR5K_AR2315_BYTESWAP); + reg = ioread32((void __iomem *) AR5K_AR2315_BYTESWAP); reg |= AR5K_AR2315_BYTESWAP_WMAC; - __raw_writel(reg, (void __iomem *) AR5K_AR2315_BYTESWAP); + iowrite32(reg, (void __iomem *) AR5K_AR2315_BYTESWAP); } else { /* Enable WMAC DMA access (assuming 5312 or 231x*/ /* TODO: check other platforms */ - reg = __raw_readl((void __iomem *) AR5K_AR5312_ENABLE); + reg = ioread32((void __iomem *) AR5K_AR5312_ENABLE); if (to_platform_device(ah->dev)->id == 0) reg |= AR5K_AR5312_ENABLE_WLAN0; else reg |= AR5K_AR5312_ENABLE_WLAN1; - __raw_writel(reg, (void __iomem *) AR5K_AR5312_ENABLE); + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE); /* * On a dual-band AR5312, the multiband radio is only @@ -203,17 +203,17 @@ static int ath_ahb_remove(struct platform_device *pdev) if (bcfg->devid >= AR5K_SREV_AR2315_R6) { /* Disable WMAC AHB arbitration */ - reg = __raw_readl((void __iomem *) AR5K_AR2315_AHB_ARB_CTL); + reg = ioread32((void __iomem *) AR5K_AR2315_AHB_ARB_CTL); reg &= ~AR5K_AR2315_AHB_ARB_CTL_WLAN; - __raw_writel(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL); + iowrite32(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL); } else { /*Stop DMA access */ - reg = __raw_readl((void __iomem *) AR5K_AR5312_ENABLE); + reg = ioread32((void __iomem *) AR5K_AR5312_ENABLE); if (to_platform_device(ah->dev)->id == 0) reg &= ~AR5K_AR5312_ENABLE_WLAN0; else reg &= ~AR5K_AR5312_ENABLE_WLAN1; - __raw_writel(reg, (void __iomem *) AR5K_AR5312_ENABLE); + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE); } ath5k_deinit_ah(ah); diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index c2b2518c2ecd..6640326f7005 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -1656,12 +1656,12 @@ static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg) static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) { - return __raw_readl(ath5k_ahb_reg(ah, reg)); + return ioread32(ath5k_ahb_reg(ah, reg)); } static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) { - __raw_writel(val, ath5k_ahb_reg(ah, reg)); + iowrite32(val, ath5k_ahb_reg(ah, reg)); } #else diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c index 250db40b751d..200f165c0c6d 100644 --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c @@ -473,14 +473,14 @@ ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) } /* Put BB/MAC into reset */ - regval = __raw_readl(reg); - __raw_writel(regval | val, reg); - regval = __raw_readl(reg); + regval = ioread32(reg); + iowrite32(regval | val, reg); + regval = ioread32(reg); usleep_range(100, 150); /* Bring BB/MAC out of reset */ - __raw_writel(regval & ~val, reg); - regval = __raw_readl(reg); + iowrite32(regval & ~val, reg); + regval = ioread32(reg); /* * Reset configuration register (for hw byte-swap). Note that this -- GitLab From 5ce3df64a4a2849a6fc616e5957b5188daaea631 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 14 Feb 2012 18:39:18 +0530 Subject: [PATCH 0988/1846] ath9k: remove obsolete comments the corresponding code/logic was removed in "ath9k: rework power state handling" Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index ec82e926badc..22785c77d007 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1587,12 +1587,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ath9k_ps_wakeup(sc); mutex_lock(&sc->mutex); - /* - * Leave this as the first check because we need to turn on the - * radio if it was disabled before prior to processing the rest - * of the changes. Likewise we must only disable the radio towards - * the end. - */ if (changed & IEEE80211_CONF_CHANGE_IDLE) { sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); if (sc->ps_idle) -- GitLab From 0a8a721de97dce7477bfb89e7b4ca1eba425db34 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 14 Feb 2012 18:39:19 +0530 Subject: [PATCH 0989/1846] ath9k: remove unnecessary PS wrappers ath_set_channel is called from ath9k_config which already has proper PS wrappers Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 22785c77d007..c81304d3ef14 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -371,12 +371,8 @@ static int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, if (sc->sc_flags & SC_OP_INVALID) return -EIO; - ath9k_ps_wakeup(sc); - r = ath_reset_internal(sc, hchan, false); - ath9k_ps_restore(sc); - return r; } -- GitLab From c3cb2a874122889c036934294dbbb8ad82f53060 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 20 Feb 2012 23:22:02 +0000 Subject: [PATCH 0990/1846] sfc: Specify that the VFDI status page has page alignment and size This requirement was meant to be implied in the name 'status page'. One out-of-tree VF driver allocates a buffer using the structure size and not a full page - hence the current odd specification - but in practice that allocation will be padded and aligned to at least 4KB. Therefore, we can specify this and have the option to extend the structure up to 4KB without worrying about VF drivers using odd-shaped buffers. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/vfdi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/vfdi.h b/drivers/net/ethernet/sfc/vfdi.h index 656fa70f9993..225557caaf5a 100644 --- a/drivers/net/ethernet/sfc/vfdi.h +++ b/drivers/net/ethernet/sfc/vfdi.h @@ -152,7 +152,8 @@ enum vfdi_op { * all traffic at this receive queue. * @u.mac_filter.flags: MAC filter flags. * @u.set_status_page.dma_addr: Base address for the &struct vfdi_status. - * This address must be such that the structure fits within a page. + * This address must be page-aligned and the PF may write up to a + * whole page (allowing for extension of the structure). * @u.set_status_page.peer_page_count: Number of additional pages the VF * has provided into which peer addresses may be DMAd. * @u.set_status_page.peer_page_addr: Array of DMA addresses of pages. -- GitLab From 01cb543db8a2d2dbcea5f357365ce1327ac46193 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 21 Feb 2012 02:57:33 +0000 Subject: [PATCH 0991/1846] sfc: Correct validation of peer_page_count in efx_vfdi_set_status_page() efx_vfdi_set_status_page() validates the peer page count by calculating the size of a request containing that many addresses and comparing that with the maximum valid request size (4KB). The calculation involves a multiplication that may overflow on a 32-bit system. We use kcalloc() to allocate memory to store the addresses; that also does a multiplication and it does check for integer overflow, so any values larger than 0x1fffffff will be rejected. However, values in the range [0x1fffffffc, 0x1fffffff] pass boh tests and result in an attempt to allocate nearly 4GB on the heap. This should be rejected rather quickly as it's obviously impossible on a 32-bit system, and indeed the maximum possible heap allocation is 32MB. Still, let's make absolutely sure by fixing the initial validation. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/siena_sriov.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c index 5c6839ec3a83..80976e84eee6 100644 --- a/drivers/net/ethernet/sfc/siena_sriov.c +++ b/drivers/net/ethernet/sfc/siena_sriov.c @@ -796,12 +796,13 @@ static int efx_vfdi_set_status_page(struct efx_vf *vf) { struct efx_nic *efx = vf->efx; struct vfdi_req *req = vf->buf.addr; - unsigned int page_count; + u64 page_count = req->u.set_status_page.peer_page_count; + u64 max_page_count = + (EFX_PAGE_SIZE - + offsetof(struct vfdi_req, u.set_status_page.peer_page_addr[0])) + / sizeof(req->u.set_status_page.peer_page_addr[0]); - page_count = req->u.set_status_page.peer_page_count; - if (!req->u.set_status_page.dma_addr || EFX_PAGE_SIZE < - offsetof(struct vfdi_req, - u.set_status_page.peer_page_addr[page_count])) { + if (!req->u.set_status_page.dma_addr || page_count > max_page_count) { if (net_ratelimit()) netif_err(efx, hw, efx->net_dev, "ERROR: Invalid SET_STATUS_PAGE from %s\n", -- GitLab From c92aaff18e0a48f693678105343160e0bd032dfa Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 21 Feb 2012 23:22:00 +0000 Subject: [PATCH 0992/1846] sfc: Reverse initial buffer table allocation to allow for later resizing We have a very simple way of allocating buffer table entries to queues, which is just to take the next one available. The extra channels are the highest numbered channels but they need to be allocated the lowest entries so that the traffic channels can be allocated new entries without any collisions. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index ac571cf14485..c7004dcb5838 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -585,7 +585,12 @@ static int efx_probe_channels(struct efx_nic *efx) /* Restart special buffer allocation */ efx->next_buffer_table = 0; - efx_for_each_channel(channel, efx) { + /* Probe channels in reverse, so that any 'extra' channels + * use the start of the buffer table. This allows the traffic + * channels to be resized without moving them or wasting the + * entries before them. + */ + efx_for_each_channel_rev(channel, efx) { rc = efx_probe_channel(channel); if (rc) { netif_err(efx, probe, efx->net_dev, -- GitLab From 2d0cc56da39d62e141d4a60e3ac96522c52de4b1 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 17 Feb 2012 00:10:45 +0000 Subject: [PATCH 0993/1846] sfc: Minor formatting cleanup Fix some indentation and line continuations. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/bitfield.h | 4 ++-- drivers/net/ethernet/sfc/mcdi_mon.c | 2 +- drivers/net/ethernet/sfc/tx.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/sfc/bitfield.h b/drivers/net/ethernet/sfc/bitfield.h index a2a9f40b90cf..b26a954c27fc 100644 --- a/drivers/net/ethernet/sfc/bitfield.h +++ b/drivers/net/ethernet/sfc/bitfield.h @@ -531,8 +531,8 @@ typedef union efx_oword { /* Static initialiser */ -#define EFX_OWORD32(a, b, c, d) \ - { .u32 = { cpu_to_le32(a), cpu_to_le32(b), \ +#define EFX_OWORD32(a, b, c, d) \ + { .u32 = { cpu_to_le32(a), cpu_to_le32(b), \ cpu_to_le32(c), cpu_to_le32(d) } } #endif /* EFX_BITFIELD_H */ diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c index 8a72c10b9a6c..fb7f65b59eb8 100644 --- a/drivers/net/ethernet/sfc/mcdi_mon.c +++ b/drivers/net/ethernet/sfc/mcdi_mon.c @@ -37,7 +37,7 @@ static const struct { SENSOR(PHY0_TEMP, "PHY temp.", EFX_HWMON_TEMP, 0), SENSOR(PHY0_COOLING, "PHY cooling", EFX_HWMON_COOL, 0), SENSOR(PHY1_TEMP, "PHY temp.", EFX_HWMON_TEMP, 1), - SENSOR(PHY1_COOLING, "PHY cooling", EFX_HWMON_COOL, 1), + SENSOR(PHY1_COOLING, "PHY cooling", EFX_HWMON_COOL, 1), SENSOR(IN_1V0, "1.0V supply", EFX_HWMON_IN, -1), SENSOR(IN_1V2, "1.2V supply", EFX_HWMON_IN, -1), SENSOR(IN_1V8, "1.8V supply", EFX_HWMON_IN, -1), diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c index a096e287e95f..94d0365b31cd 100644 --- a/drivers/net/ethernet/sfc/tx.c +++ b/drivers/net/ethernet/sfc/tx.c @@ -339,7 +339,7 @@ static void efx_dequeue_buffers(struct efx_tx_queue *tx_queue, * OS to free the skb. */ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb, - struct net_device *net_dev) + struct net_device *net_dev) { struct efx_nic *efx = netdev_priv(net_dev); struct efx_tx_queue *tx_queue; -- GitLab From 73e0026fb2bee4f2ca85c702040e143ec504eaa6 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 23 Feb 2012 00:45:50 +0000 Subject: [PATCH 0994/1846] sfc: Correct efx_for_each_possible_channel_tx_queue() to skip non-TX channels efx_for_each_possible_channel_tx_queue() should do nothing for RX-only or extra channels. The current definition results in allocating additional unused hardware TX queues when using the mqprio qdisc and either separate_tx_channels or SR-IOV. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/net_driver.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 3fbec458c323..0b95505e8968 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -1030,9 +1030,12 @@ static inline bool efx_tx_queue_used(struct efx_tx_queue *tx_queue) /* Iterate over all possible TX queues belonging to a channel */ #define efx_for_each_possible_channel_tx_queue(_tx_queue, _channel) \ - for (_tx_queue = (_channel)->tx_queue; \ - _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \ - _tx_queue++) + if (!efx_channel_has_tx_queues(_channel)) \ + ; \ + else \ + for (_tx_queue = (_channel)->tx_queue; \ + _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \ + _tx_queue++) static inline bool efx_channel_has_rx_queue(struct efx_channel *channel) { -- GitLab From 34655ad63893d3dd64f3fbaaaa0791550e554fa9 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Wed, 22 Feb 2012 12:35:18 +0000 Subject: [PATCH 0995/1846] tg3: Fix link check in tg3_adjust_link The tg3 driver tried to detect link changes by comparing the tg3 local active_speed member with SPEED_UNKNOWN (or formerly SPEED_INVALID). This check is not correct, since phylib will never set its speed member to either of these two values. The code only appeared to work because tg3 initializes active_speed to SPEED_INVALID during tg3_init_one. This patch introduces a new "old_link" tg3 member and then compares the phy_device's link member against it to detect link state changes. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 6 ++++-- drivers/net/ethernet/broadcom/tg3.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 27dafd928279..0caf565fafe4 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -1819,13 +1819,13 @@ static void tg3_adjust_link(struct net_device *dev) (6 << TX_LENGTHS_IPG_SHIFT) | (32 << TX_LENGTHS_SLOT_TIME_SHIFT))); - if ((phydev->link && tp->link_config.active_speed == SPEED_UNKNOWN) || - (!phydev->link && tp->link_config.active_speed != SPEED_UNKNOWN) || + if (phydev->link != tp->old_link || phydev->speed != tp->link_config.active_speed || phydev->duplex != tp->link_config.active_duplex || oldflowctrl != tp->link_config.active_flowctrl) linkmesg = 1; + tp->old_link = phydev->link; tp->link_config.active_speed = phydev->speed; tp->link_config.active_duplex = phydev->duplex; @@ -13352,6 +13352,8 @@ static void __devinit tg3_phy_init_link_config(struct tg3 *tp) tp->link_config.autoneg = AUTONEG_ENABLE; tp->link_config.active_speed = SPEED_UNKNOWN; tp->link_config.active_duplex = DUPLEX_UNKNOWN; + + tp->old_link = -1; } static int __devinit tg3_phy_probe(struct tg3 *tp) diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h index 22cbe74b3d11..66bcfca55261 100644 --- a/drivers/net/ethernet/broadcom/tg3.h +++ b/drivers/net/ethernet/broadcom/tg3.h @@ -3064,6 +3064,7 @@ struct tg3 { struct mii_bus *mdio_bus; int mdio_irq[PHY_MAX_ADDR]; + int old_link; u8 phy_addr; -- GitLab From d13ba512cbba7de5d55d7a3b2aae7d83c8921457 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Wed, 22 Feb 2012 12:35:19 +0000 Subject: [PATCH 0996/1846] tg3: Remove SPEED_UNKNOWN checks tg3_phy_copper_begin() has code that configures the link advertisements through the use of the link_config.speed and link_config.duplex members. The driver does not internally use these members in this way, nor is it (currently) permitted via the ethtool interface. This patch removes the dead code. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 67 ++++++++++------------------- 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 0caf565fafe4..f921484d2086 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -3894,51 +3894,33 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl) static void tg3_phy_copper_begin(struct tg3 *tp) { - u32 new_adv; - int i; - - if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { - new_adv = ADVERTISED_10baseT_Half | - ADVERTISED_10baseT_Full; - if (tg3_flag(tp, WOL_SPEED_100MB)) - new_adv |= ADVERTISED_100baseT_Half | - ADVERTISED_100baseT_Full; - - tg3_phy_autoneg_cfg(tp, new_adv, - FLOW_CTRL_TX | FLOW_CTRL_RX); - } else if (tp->link_config.speed == SPEED_UNKNOWN) { - if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) - tp->link_config.advertising &= - ~(ADVERTISED_1000baseT_Half | - ADVERTISED_1000baseT_Full); - - tg3_phy_autoneg_cfg(tp, tp->link_config.advertising, - tp->link_config.flowctrl); - } else { - /* Asking for a specific link mode. */ - if (tp->link_config.speed == SPEED_1000) { - if (tp->link_config.duplex == DUPLEX_FULL) - new_adv = ADVERTISED_1000baseT_Full; - else - new_adv = ADVERTISED_1000baseT_Half; - } else if (tp->link_config.speed == SPEED_100) { - if (tp->link_config.duplex == DUPLEX_FULL) - new_adv = ADVERTISED_100baseT_Full; - else - new_adv = ADVERTISED_100baseT_Half; + if (tp->link_config.autoneg == AUTONEG_ENABLE || + (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) { + u32 adv, fc; + + if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) { + adv = ADVERTISED_10baseT_Half | + ADVERTISED_10baseT_Full; + if (tg3_flag(tp, WOL_SPEED_100MB)) + adv |= ADVERTISED_100baseT_Half | + ADVERTISED_100baseT_Full; + + fc = FLOW_CTRL_TX | FLOW_CTRL_RX; } else { - if (tp->link_config.duplex == DUPLEX_FULL) - new_adv = ADVERTISED_10baseT_Full; - else - new_adv = ADVERTISED_10baseT_Half; + adv = tp->link_config.advertising; + if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY) + adv &= ~(ADVERTISED_1000baseT_Half | + ADVERTISED_1000baseT_Full); + + fc = tp->link_config.flowctrl; } - tg3_phy_autoneg_cfg(tp, new_adv, - tp->link_config.flowctrl); - } + tg3_phy_autoneg_cfg(tp, adv, fc); - if (tp->link_config.autoneg == AUTONEG_DISABLE && - tp->link_config.speed != SPEED_UNKNOWN) { + tg3_writephy(tp, MII_BMCR, + BMCR_ANENABLE | BMCR_ANRESTART); + } else { + int i; u32 bmcr, orig_bmcr; tp->link_config.active_speed = tp->link_config.speed; @@ -3980,9 +3962,6 @@ static void tg3_phy_copper_begin(struct tg3 *tp) tg3_writephy(tp, MII_BMCR, bmcr); udelay(40); } - } else { - tg3_writephy(tp, MII_BMCR, - BMCR_ANENABLE | BMCR_ANRESTART); } } -- GitLab From c71013597d49c7ca8bb5049f0c7873df2643fad5 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Wed, 22 Feb 2012 12:35:20 +0000 Subject: [PATCH 0997/1846] tg3: Clear RECOVERY_PENDING with reset_task_cancel If an error happens in the tx completion thread, tg3_reset_task will be scheduled and TX_RECOVERY_PENDING will be set. The TX_RECOVERY_PENDING flag causes tg3_poll[_msix] to return early before doing much of its work. Tg3_reset_task() gets canceled when the configuration of the device is changing, which always results in a chip reset. When this happens, the TX_RECOVERY_PENDING flag may be left set, which would unnecessarily hinder tg3_poll from doing work. This patch fixes the problem. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index f921484d2086..21b39c5ffb4b 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -6163,6 +6163,7 @@ static inline void tg3_reset_task_cancel(struct tg3 *tp) { cancel_work_sync(&tp->reset_task); tg3_flag_clear(tp, RESET_TASK_PENDING); + tg3_flag_clear(tp, TX_RECOVERY_PENDING); } static int tg3_poll_msix(struct napi_struct *napi, int budget) @@ -15937,7 +15938,6 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev, /* Want to make sure that the reset task doesn't run */ tg3_reset_task_cancel(tp); - tg3_flag_clear(tp, TX_RECOVERY_PENDING); netif_device_detach(netdev); -- GitLab From 21f7638e6f05c36b35a36cd4311e08be5dc00bb1 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Wed, 22 Feb 2012 12:35:21 +0000 Subject: [PATCH 0998/1846] tg3: Create timer helper functions This patch seeks to clean up the timer related code. It begins by moving one-time timer setup code from tg3_open() to tg3_init_one(). It then creates a function that encapsulates the code needed to start the timer. A tg3_timer_stop() function was added for parity. Finally, this patch moves all the timer functions to a more suitable location. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 208 +++++++++++++++------------- 1 file changed, 112 insertions(+), 96 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 21b39c5ffb4b..ec5bc3d04333 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -204,6 +204,7 @@ static inline void _tg3_flag_clear(enum TG3_FLAGS flag, unsigned long *bits) #define TG3_RAW_IP_ALIGN 2 #define TG3_FW_UPDATE_TIMEOUT_SEC 5 +#define TG3_FW_UPDATE_FREQ_SEC (TG3_FW_UPDATE_TIMEOUT_SEC / 2) #define FIRMWARE_TG3 "tigon/tg3.bin" #define FIRMWARE_TG3TSO "tigon/tg3_tso.bin" @@ -9328,74 +9329,6 @@ static int tg3_init_hw(struct tg3 *tp, int reset_phy) return tg3_reset_hw(tp, reset_phy); } -/* Restart hardware after configuration changes, self-test, etc. - * Invoked with tp->lock held. - */ -static int tg3_restart_hw(struct tg3 *tp, int reset_phy) - __releases(tp->lock) - __acquires(tp->lock) -{ - int err; - - err = tg3_init_hw(tp, reset_phy); - if (err) { - netdev_err(tp->dev, - "Failed to re-initialize device, aborting\n"); - tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); - tg3_full_unlock(tp); - del_timer_sync(&tp->timer); - tp->irq_sync = 0; - tg3_napi_enable(tp); - dev_close(tp->dev); - tg3_full_lock(tp, 0); - } - return err; -} - -static void tg3_reset_task(struct work_struct *work) -{ - struct tg3 *tp = container_of(work, struct tg3, reset_task); - int err; - - tg3_full_lock(tp, 0); - - if (!netif_running(tp->dev)) { - tg3_flag_clear(tp, RESET_TASK_PENDING); - tg3_full_unlock(tp); - return; - } - - tg3_full_unlock(tp); - - tg3_phy_stop(tp); - - tg3_netif_stop(tp); - - tg3_full_lock(tp, 1); - - if (tg3_flag(tp, TX_RECOVERY_PENDING)) { - tp->write32_tx_mbox = tg3_write32_tx_mbox; - tp->write32_rx_mbox = tg3_write_flush_reg32; - tg3_flag_set(tp, MBOX_WRITE_REORDER); - tg3_flag_clear(tp, TX_RECOVERY_PENDING); - } - - tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); - err = tg3_init_hw(tp, 1); - if (err) - goto out; - - tg3_netif_start(tp); - -out: - tg3_full_unlock(tp); - - if (!err) - tg3_phy_start(tp); - - tg3_flag_clear(tp, RESET_TASK_PENDING); -} - #define TG3_STAT_ADD32(PSTAT, REG) \ do { u32 __val = tr32(REG); \ (PSTAT)->low += __val; \ @@ -9608,6 +9541,108 @@ static void tg3_timer(unsigned long __opaque) add_timer(&tp->timer); } +static void __devinit tg3_timer_init(struct tg3 *tp) +{ + if (tg3_flag(tp, TAGGED_STATUS) && + GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5717 && + !tg3_flag(tp, 57765_CLASS)) + tp->timer_offset = HZ; + else + tp->timer_offset = HZ / 10; + + BUG_ON(tp->timer_offset > HZ); + + tp->timer_multiplier = (HZ / tp->timer_offset); + tp->asf_multiplier = (HZ / tp->timer_offset) * + TG3_FW_UPDATE_FREQ_SEC; + + init_timer(&tp->timer); + tp->timer.data = (unsigned long) tp; + tp->timer.function = tg3_timer; +} + +static void tg3_timer_start(struct tg3 *tp) +{ + tp->asf_counter = tp->asf_multiplier; + tp->timer_counter = tp->timer_multiplier; + + tp->timer.expires = jiffies + tp->timer_offset; + add_timer(&tp->timer); +} + +static void tg3_timer_stop(struct tg3 *tp) +{ + del_timer_sync(&tp->timer); +} + +/* Restart hardware after configuration changes, self-test, etc. + * Invoked with tp->lock held. + */ +static int tg3_restart_hw(struct tg3 *tp, int reset_phy) + __releases(tp->lock) + __acquires(tp->lock) +{ + int err; + + err = tg3_init_hw(tp, reset_phy); + if (err) { + netdev_err(tp->dev, + "Failed to re-initialize device, aborting\n"); + tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); + tg3_full_unlock(tp); + tg3_timer_stop(tp); + tp->irq_sync = 0; + tg3_napi_enable(tp); + dev_close(tp->dev); + tg3_full_lock(tp, 0); + } + return err; +} + +static void tg3_reset_task(struct work_struct *work) +{ + struct tg3 *tp = container_of(work, struct tg3, reset_task); + int err; + + tg3_full_lock(tp, 0); + + if (!netif_running(tp->dev)) { + tg3_flag_clear(tp, RESET_TASK_PENDING); + tg3_full_unlock(tp); + return; + } + + tg3_full_unlock(tp); + + tg3_phy_stop(tp); + + tg3_netif_stop(tp); + + tg3_full_lock(tp, 1); + + if (tg3_flag(tp, TX_RECOVERY_PENDING)) { + tp->write32_tx_mbox = tg3_write32_tx_mbox; + tp->write32_rx_mbox = tg3_write_flush_reg32; + tg3_flag_set(tp, MBOX_WRITE_REORDER); + tg3_flag_clear(tp, TX_RECOVERY_PENDING); + } + + tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); + err = tg3_init_hw(tp, 1); + if (err) + goto out; + + tg3_netif_start(tp); + +out: + tg3_full_unlock(tp); + + if (!err) + tg3_phy_start(tp); + + tg3_flag_clear(tp, RESET_TASK_PENDING); +} + static int tg3_request_irq(struct tg3 *tp, int irq_num) { irq_handler_t fn; @@ -9973,24 +10008,6 @@ static int tg3_open(struct net_device *dev) if (err) { tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); tg3_free_rings(tp); - } else { - if (tg3_flag(tp, TAGGED_STATUS) && - GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5717 && - !tg3_flag(tp, 57765_CLASS)) - tp->timer_offset = HZ; - else - tp->timer_offset = HZ / 10; - - BUG_ON(tp->timer_offset > HZ); - tp->timer_counter = tp->timer_multiplier = - (HZ / tp->timer_offset); - tp->asf_counter = tp->asf_multiplier = - ((HZ / tp->timer_offset) * 2); - - init_timer(&tp->timer); - tp->timer.expires = jiffies + tp->timer_offset; - tp->timer.data = (unsigned long) tp; - tp->timer.function = tg3_timer; } tg3_full_unlock(tp); @@ -10022,7 +10039,7 @@ static int tg3_open(struct net_device *dev) tg3_full_lock(tp, 0); - add_timer(&tp->timer); + tg3_timer_start(tp); tg3_flag_set(tp, INIT_COMPLETE); tg3_enable_ints(tp); @@ -10067,7 +10084,7 @@ static int tg3_close(struct net_device *dev) netif_tx_stop_all_queues(dev); - del_timer_sync(&tp->timer); + tg3_timer_stop(tp); tg3_phy_stop(tp); @@ -15701,6 +15718,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, tg3_frob_aux_power(tp, false); } + tg3_timer_init(tp); + err = register_netdev(dev); if (err) { dev_err(&pdev->dev, "Cannot register net device, aborting\n"); @@ -15826,7 +15845,7 @@ static int tg3_suspend(struct device *device) tg3_phy_stop(tp); tg3_netif_stop(tp); - del_timer_sync(&tp->timer); + tg3_timer_stop(tp); tg3_full_lock(tp, 1); tg3_disable_ints(tp); @@ -15850,8 +15869,7 @@ static int tg3_suspend(struct device *device) if (err2) goto out; - tp->timer.expires = jiffies + tp->timer_offset; - add_timer(&tp->timer); + tg3_timer_start(tp); netif_device_attach(dev); tg3_netif_start(tp); @@ -15885,8 +15903,7 @@ static int tg3_resume(struct device *device) if (err) goto out; - tp->timer.expires = jiffies + tp->timer_offset; - add_timer(&tp->timer); + tg3_timer_start(tp); tg3_netif_start(tp); @@ -15934,7 +15951,7 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev, tg3_netif_stop(tp); - del_timer_sync(&tp->timer); + tg3_timer_stop(tp); /* Want to make sure that the reset task doesn't run */ tg3_reset_task_cancel(tp); @@ -16030,8 +16047,7 @@ static void tg3_io_resume(struct pci_dev *pdev) netif_device_attach(netdev); - tp->timer.expires = jiffies + tp->timer_offset; - add_timer(&tp->timer); + tg3_timer_start(tp); tg3_netif_start(tp); -- GitLab From 6b6ba88b5bb8779156b21bb957520a448c3642e2 Mon Sep 17 00:00:00 2001 From: Keng-Yu Lin Date: Wed, 30 Nov 2011 18:32:37 +0800 Subject: [PATCH 0999/1846] Bluetooth: Add AR30XX device ID on Asus laptops The ID is found on Asus K54HR and K53U. Blacklist the AR3011-based device ID [0489:e03d] and add to ath3k.c for firmware loading. Below is the output of usb-devices script: Before the fiwmware loading: T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e03d Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb After the fiwmware loading: T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=3005 Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb Signed-off-by: Keng-Yu Lin Signed-off-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- drivers/bluetooth/ath3k.c | 1 + drivers/bluetooth/btusb.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 07f14d10ea49..4eca6e5cbf22 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -65,6 +65,7 @@ static struct usb_device_id ath3k_table[] = { { USB_DEVICE(0x0CF3, 0x3002) }, { USB_DEVICE(0x13d3, 0x3304) }, { USB_DEVICE(0x0930, 0x0215) }, + { USB_DEVICE(0x0489, 0xE03D) }, /* Atheros AR9285 Malbec with sflash firmware */ { USB_DEVICE(0x03F0, 0x311D) }, diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index e61a195969bf..c5606ef91761 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -121,6 +121,7 @@ static struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE }, { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE }, { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE }, + { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE }, /* Atheros AR9285 Malbec with sflash firmware */ { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, -- GitLab From 1b009c982482ee0e4cbabcd9bdae690a29119ede Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 21 Feb 2012 12:54:54 +0200 Subject: [PATCH 1000/1846] Bluetooth: trivial: Fix long line Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 37736c6603fc..63539f940572 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -2720,7 +2720,8 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd result = __le16_to_cpu(rsp->result); status = __le16_to_cpu(rsp->status); - BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status); + BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", + dcid, scid, result, status); if (scid) { chan = l2cap_get_chan_by_scid(conn, scid); -- GitLab From 3df91ea20e744344100b10ae69a17211fcf5b207 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 21 Feb 2012 12:54:55 +0200 Subject: [PATCH 1001/1846] Bluetooth: Revert to mutexes from RCU list Usage of RCU list looks not reasonalbe for a number of reasons: our code sleep and we had to use socket spinlocks. Most parts of code are updaters thus there is little sense to use RCU. Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 166 ++++++++++++++++++++++--------------- net/bluetooth/l2cap_sock.c | 10 +++ 2 files changed, 109 insertions(+), 67 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 63539f940572..8e8e9e93fb34 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -77,36 +77,24 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) { - struct l2cap_chan *c, *r = NULL; - - rcu_read_lock(); + struct l2cap_chan *c; - list_for_each_entry_rcu(c, &conn->chan_l, list) { - if (c->dcid == cid) { - r = c; - break; - } + list_for_each_entry(c, &conn->chan_l, list) { + if (c->dcid == cid) + return c; } - - rcu_read_unlock(); - return r; + return NULL; } static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) { - struct l2cap_chan *c, *r = NULL; - - rcu_read_lock(); + struct l2cap_chan *c; - list_for_each_entry_rcu(c, &conn->chan_l, list) { - if (c->scid == cid) { - r = c; - break; - } + list_for_each_entry(c, &conn->chan_l, list) { + if (c->scid == cid) + return c; } - - rcu_read_unlock(); - return r; + return NULL; } /* Find channel with given SCID. @@ -115,36 +103,32 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci { struct l2cap_chan *c; + mutex_lock(&conn->chan_lock); c = __l2cap_get_chan_by_scid(conn, cid); - if (c) - lock_sock(c->sk); + mutex_unlock(&conn->chan_lock); + return c; } static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident) { - struct l2cap_chan *c, *r = NULL; - - rcu_read_lock(); + struct l2cap_chan *c; - list_for_each_entry_rcu(c, &conn->chan_l, list) { - if (c->ident == ident) { - r = c; - break; - } + list_for_each_entry(c, &conn->chan_l, list) { + if (c->ident == ident) + return c; } - - rcu_read_unlock(); - return r; + return NULL; } static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident) { struct l2cap_chan *c; + mutex_lock(&conn->chan_lock); c = __l2cap_get_chan_by_ident(conn, ident); - if (c) - lock_sock(c->sk); + mutex_unlock(&conn->chan_lock); + return c; } @@ -228,11 +212,13 @@ static void l2cap_chan_timeout(struct work_struct *work) { struct l2cap_chan *chan = container_of(work, struct l2cap_chan, chan_timer.work); + struct l2cap_conn *conn = chan->conn; struct sock *sk = chan->sk; int reason; BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); + mutex_lock(&conn->chan_lock); lock_sock(sk); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) @@ -248,6 +234,8 @@ static void l2cap_chan_timeout(struct work_struct *work) release_sock(sk); chan->ops->close(chan->data); + mutex_unlock(&conn->chan_lock); + l2cap_chan_put(chan); } @@ -331,7 +319,9 @@ static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) l2cap_chan_hold(chan); - list_add_rcu(&chan->list, &conn->chan_l); + mutex_lock(&conn->chan_lock); + list_add(&chan->list, &conn->chan_l); + mutex_unlock(&conn->chan_lock); } /* Delete channel. @@ -348,8 +338,7 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) if (conn) { /* Delete from channel list */ - list_del_rcu(&chan->list); - synchronize_rcu(); + list_del(&chan->list); l2cap_chan_put(chan); @@ -400,10 +389,12 @@ static void l2cap_chan_cleanup_listen(struct sock *parent) /* Close not yet accepted channels */ while ((sk = bt_accept_dequeue(parent, NULL))) { struct l2cap_chan *chan = l2cap_pi(sk)->chan; + __clear_chan_timer(chan); lock_sock(sk); l2cap_chan_close(chan, ECONNRESET); release_sock(sk); + chan->ops->close(chan->data); } } @@ -718,13 +709,13 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c /* ---- L2CAP connections ---- */ static void l2cap_conn_start(struct l2cap_conn *conn) { - struct l2cap_chan *chan; + struct l2cap_chan *chan, *tmp; BT_DBG("conn %p", conn); - rcu_read_lock(); + mutex_lock(&conn->chan_lock); - list_for_each_entry_rcu(chan, &conn->chan_l, list) { + list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) { struct sock *sk = chan->sk; bh_lock_sock(sk); @@ -804,7 +795,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) bh_unlock_sock(sk); } - rcu_read_unlock(); + mutex_unlock(&conn->chan_lock); } /* Find socket with cid and source bdaddr. @@ -916,9 +907,9 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) if (conn->hcon->out && conn->hcon->type == LE_LINK) smp_conn_security(conn, conn->hcon->pending_sec_level); - rcu_read_lock(); + mutex_lock(&conn->chan_lock); - list_for_each_entry_rcu(chan, &conn->chan_l, list) { + list_for_each_entry(chan, &conn->chan_l, list) { struct sock *sk = chan->sk; bh_lock_sock(sk); @@ -938,7 +929,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) bh_unlock_sock(sk); } - rcu_read_unlock(); + mutex_unlock(&conn->chan_lock); } /* Notify sockets that we cannot guaranty reliability anymore */ @@ -948,16 +939,16 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) BT_DBG("conn %p", conn); - rcu_read_lock(); + mutex_lock(&conn->chan_lock); - list_for_each_entry_rcu(chan, &conn->chan_l, list) { + list_for_each_entry(chan, &conn->chan_l, list) { struct sock *sk = chan->sk; if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) sk->sk_err = err; } - rcu_read_unlock(); + mutex_unlock(&conn->chan_lock); } static void l2cap_info_timeout(struct work_struct *work) @@ -984,6 +975,8 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) kfree_skb(conn->rx_skb); + mutex_lock(&conn->chan_lock); + /* Kill channels */ list_for_each_entry_safe(chan, l, &conn->chan_l, list) { sk = chan->sk; @@ -993,6 +986,8 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) chan->ops->close(chan->data); } + mutex_unlock(&conn->chan_lock); + hci_chan_del(conn->hchan); if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) @@ -1050,6 +1045,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) conn->feat_mask = 0; spin_lock_init(&conn->lock); + mutex_init(&conn->chan_lock); INIT_LIST_HEAD(&conn->chan_l); @@ -1792,9 +1788,9 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) BT_DBG("conn %p", conn); - rcu_read_lock(); + mutex_lock(&conn->chan_lock); - list_for_each_entry_rcu(chan, &conn->chan_l, list) { + list_for_each_entry(chan, &conn->chan_l, list) { struct sock *sk = chan->sk; if (chan->chan_type != L2CAP_CHAN_RAW) continue; @@ -1810,7 +1806,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) kfree_skb(nskb); } - rcu_read_unlock(); + mutex_unlock(&conn->chan_lock); } /* ---- L2CAP signalling commands ---- */ @@ -2600,6 +2596,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd parent = pchan->sk; + mutex_lock(&conn->chan_lock); lock_sock(parent); /* Check if the ACL is secure enough (if not SDP) */ @@ -2673,6 +2670,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd response: release_sock(parent); + mutex_unlock(&conn->chan_lock); sendresp: rsp.scid = cpu_to_le16(scid); @@ -2714,6 +2712,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd struct l2cap_chan *chan; struct sock *sk; u8 req[128]; + int err; scid = __le16_to_cpu(rsp->scid); dcid = __le16_to_cpu(rsp->dcid); @@ -2723,17 +2722,26 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status); + mutex_lock(&conn->chan_lock); + if (scid) { - chan = l2cap_get_chan_by_scid(conn, scid); - if (!chan) - return -EFAULT; + chan = __l2cap_get_chan_by_scid(conn, scid); + if (!chan) { + err = -EFAULT; + goto unlock; + } } else { - chan = l2cap_get_chan_by_ident(conn, cmd->ident); - if (!chan) - return -EFAULT; + chan = __l2cap_get_chan_by_ident(conn, cmd->ident); + if (!chan) { + err = -EFAULT; + goto unlock; + } } + err = 0; + sk = chan->sk; + lock_sock(sk); switch (result) { case L2CAP_CR_SUCCESS: @@ -2760,7 +2768,11 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd } release_sock(sk); - return 0; + +unlock: + mutex_unlock(&conn->chan_lock); + + return err; } static inline void set_default_fcs(struct l2cap_chan *chan) @@ -2793,6 +2805,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr return -ENOENT; sk = chan->sk; + lock_sock(sk); if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { struct l2cap_cmd_rej_cid rej; @@ -2905,6 +2918,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr return 0; sk = chan->sk; + lock_sock(sk); switch (result) { case L2CAP_CONF_SUCCESS: @@ -3006,11 +3020,16 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid); - chan = l2cap_get_chan_by_scid(conn, dcid); - if (!chan) + mutex_lock(&conn->chan_lock); + + chan = __l2cap_get_chan_by_scid(conn, dcid); + if (!chan) { + mutex_unlock(&conn->chan_lock); return 0; + } sk = chan->sk; + lock_sock(sk); rsp.dcid = cpu_to_le16(chan->scid); rsp.scid = cpu_to_le16(chan->dcid); @@ -3022,6 +3041,9 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd release_sock(sk); chan->ops->close(chan->data); + + mutex_unlock(&conn->chan_lock); + return 0; } @@ -3037,16 +3059,24 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid); - chan = l2cap_get_chan_by_scid(conn, scid); - if (!chan) + mutex_lock(&conn->chan_lock); + + chan = __l2cap_get_chan_by_scid(conn, scid); + if (!chan) { + mutex_unlock(&conn->chan_lock); return 0; + } sk = chan->sk; + lock_sock(sk); l2cap_chan_del(chan, 0); release_sock(sk); chan->ops->close(chan->data); + + mutex_unlock(&conn->chan_lock); + return 0; } @@ -4205,6 +4235,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk } sk = chan->sk; + lock_sock(sk); BT_DBG("chan %p, len %d", chan, skb->len); @@ -4492,9 +4523,9 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) cancel_delayed_work(&conn->security_timer); } - rcu_read_lock(); + mutex_lock(&conn->chan_lock); - list_for_each_entry_rcu(chan, &conn->chan_l, list) { + list_for_each_entry(chan, &conn->chan_l, list) { struct sock *sk = chan->sk; bh_lock_sock(sk); @@ -4574,7 +4605,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) bh_unlock_sock(sk); } - rcu_read_unlock(); + mutex_unlock(&conn->chan_lock); return 0; } @@ -4635,6 +4666,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) if (chan && chan->sk) { struct sock *sk = chan->sk; + lock_sock(sk); if (chan->imtu < len - L2CAP_HDR_SIZE) { BT_ERR("Frame exceeding recv MTU (len %d, " diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index b48d6c1b9db6..1273fcbeec28 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -796,6 +796,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) { struct sock *sk = sock->sk; struct l2cap_chan *chan; + struct l2cap_conn *conn; int err = 0; BT_DBG("sock %p, sk %p", sock, sk); @@ -804,6 +805,10 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) return 0; chan = l2cap_pi(sk)->chan; + conn = chan->conn; + + if (conn) + mutex_lock(&conn->chan_lock); lock_sock(sk); if (!sk->sk_shutdown) { @@ -811,6 +816,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) err = __l2cap_wait_ack(sk); sk->sk_shutdown = SHUTDOWN_MASK; + l2cap_chan_close(chan, 0); if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) @@ -822,6 +828,10 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) err = -sk->sk_err; release_sock(sk); + + if (conn) + mutex_unlock(&conn->chan_lock); + return err; } -- GitLab From c03b355ea2938495bbdf25a4645be545be8890f4 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 21 Feb 2012 12:54:56 +0200 Subject: [PATCH 1002/1846] Bluetooth: Add l2cap_chan_lock Channel lock will be used to lock L2CAP channels which are locked currently by socket locks. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 11 +++++++++++ net/bluetooth/l2cap_core.c | 2 ++ 2 files changed, 13 insertions(+) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index bbb0e214e51d..d6d8ec8eb8cf 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -497,6 +497,7 @@ struct l2cap_chan { void *data; struct l2cap_ops *ops; + struct mutex lock; }; struct l2cap_ops { @@ -609,6 +610,16 @@ static inline void l2cap_chan_put(struct l2cap_chan *c) kfree(c); } +static inline void l2cap_chan_lock(struct l2cap_chan *chan) +{ + mutex_lock(&chan->lock); +} + +static inline void l2cap_chan_unlock(struct l2cap_chan *chan) +{ + mutex_unlock(&chan->lock); +} + static inline void l2cap_set_timer(struct l2cap_chan *chan, struct delayed_work *work, long timeout) { diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8e8e9e93fb34..e39eba1ac4da 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -247,6 +247,8 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk) if (!chan) return NULL; + mutex_init(&chan->lock); + chan->sk = sk; write_lock(&chan_list_lock); -- GitLab From 0e587be728a522fd8e522ad905b02f2892b61712 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 21 Feb 2012 12:54:57 +0200 Subject: [PATCH 1003/1846] Bluetooth: Add locked and unlocked state_change Split to locked and unlocked versions of l2cap_state_change helping to remove socket locks from l2cap code. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 41 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index e39eba1ac4da..4638dbbaa4b2 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -199,7 +199,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) return 0; } -static void l2cap_state_change(struct l2cap_chan *chan, int state) +static void __l2cap_state_change(struct l2cap_chan *chan, int state) { BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state), state_to_string(state)); @@ -208,6 +208,15 @@ static void l2cap_state_change(struct l2cap_chan *chan, int state) chan->ops->state_change(chan->data, state); } +static void l2cap_state_change(struct l2cap_chan *chan, int state) +{ + struct sock *sk = chan->sk; + + lock_sock(sk); + __l2cap_state_change(chan, state); + release_sock(sk); +} + static void l2cap_chan_timeout(struct work_struct *work) { struct l2cap_chan *chan = container_of(work, struct l2cap_chan, @@ -348,7 +357,7 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) hci_conn_put(conn->hcon); } - l2cap_state_change(chan, BT_CLOSED); + __l2cap_state_change(chan, BT_CLOSED); sock_set_flag(sk, SOCK_ZAPPED); if (err) @@ -413,7 +422,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) case BT_LISTEN: l2cap_chan_cleanup_listen(sk); - l2cap_state_change(chan, BT_CLOSED); + __l2cap_state_change(chan, BT_CLOSED); sock_set_flag(sk, SOCK_ZAPPED); break; @@ -704,7 +713,7 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ, sizeof(req), &req); - l2cap_state_change(chan, BT_DISCONN); + __l2cap_state_change(chan, BT_DISCONN); sk->sk_err = err; } @@ -770,7 +779,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) parent->sk_data_ready(parent, 0); } else { - l2cap_state_change(chan, BT_CONFIG); + __l2cap_state_change(chan, BT_CONFIG); rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); } @@ -873,7 +882,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) __set_chan_timer(chan, sk->sk_sndtimeo); - l2cap_state_change(chan, BT_CONNECTED); + __l2cap_state_change(chan, BT_CONNECTED); parent->sk_data_ready(parent, 0); clean: @@ -890,7 +899,7 @@ static void l2cap_chan_ready(struct l2cap_chan *chan) chan->conf_state = 0; __clear_chan_timer(chan); - l2cap_state_change(chan, BT_CONNECTED); + __l2cap_state_change(chan, BT_CONNECTED); sk->sk_state_change(sk); if (parent) @@ -922,7 +931,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) } else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { __clear_chan_timer(chan); - l2cap_state_change(chan, BT_CONNECTED); + __l2cap_state_change(chan, BT_CONNECTED); sk->sk_state_change(sk); } else if (chan->state == BT_CONNECT) @@ -1196,14 +1205,14 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d l2cap_chan_add(conn, chan); - l2cap_state_change(chan, BT_CONNECT); + __l2cap_state_change(chan, BT_CONNECT); __set_chan_timer(chan, sk->sk_sndtimeo); if (hcon->state == BT_CONNECTED) { if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { __clear_chan_timer(chan); if (l2cap_chan_check_security(chan)) - l2cap_state_change(chan, BT_CONNECTED); + __l2cap_state_change(chan, BT_CONNECTED); } else l2cap_do_start(chan); } @@ -2650,22 +2659,22 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) { if (l2cap_chan_check_security(chan)) { if (bt_sk(sk)->defer_setup) { - l2cap_state_change(chan, BT_CONNECT2); + __l2cap_state_change(chan, BT_CONNECT2); result = L2CAP_CR_PEND; status = L2CAP_CS_AUTHOR_PEND; parent->sk_data_ready(parent, 0); } else { - l2cap_state_change(chan, BT_CONFIG); + __l2cap_state_change(chan, BT_CONFIG); result = L2CAP_CR_SUCCESS; status = L2CAP_CS_NO_INFO; } } else { - l2cap_state_change(chan, BT_CONNECT2); + __l2cap_state_change(chan, BT_CONNECT2); result = L2CAP_CR_PEND; status = L2CAP_CS_AUTHEN_PEND; } } else { - l2cap_state_change(chan, BT_CONNECT2); + __l2cap_state_change(chan, BT_CONNECT2); result = L2CAP_CR_PEND; status = L2CAP_CS_NO_INFO; } @@ -4584,12 +4593,12 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) if (parent) parent->sk_data_ready(parent, 0); } else { - l2cap_state_change(chan, BT_CONFIG); + __l2cap_state_change(chan, BT_CONFIG); res = L2CAP_CR_SUCCESS; stat = L2CAP_CS_NO_INFO; } } else { - l2cap_state_change(chan, BT_DISCONN); + __l2cap_state_change(chan, BT_DISCONN); __set_chan_timer(chan, msecs_to_jiffies(L2CAP_DISC_TIMEOUT)); res = L2CAP_CR_SEC_BLOCK; -- GitLab From 2e0052e4cf78e3e205e92d82ee572ed726e315d6 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Tue, 21 Feb 2012 12:54:58 +0200 Subject: [PATCH 1004/1846] Bluetooth: Add socket error function Use locked and unlocked versions to help removing socket locks from l2cap core functions. Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 4638dbbaa4b2..c0640b73c628 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -217,6 +217,22 @@ static void l2cap_state_change(struct l2cap_chan *chan, int state) release_sock(sk); } +static inline void __l2cap_chan_set_err(struct l2cap_chan *chan, int err) +{ + struct sock *sk = chan->sk; + + sk->sk_err = err; +} + +static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err) +{ + struct sock *sk = chan->sk; + + lock_sock(sk); + __l2cap_chan_set_err(chan, err); + release_sock(sk); +} + static void l2cap_chan_timeout(struct work_struct *work) { struct l2cap_chan *chan = container_of(work, struct l2cap_chan, @@ -361,7 +377,7 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) sock_set_flag(sk, SOCK_ZAPPED); if (err) - sk->sk_err = err; + __l2cap_chan_set_err(chan, err); if (parent) { bt_accept_unlink(sk); @@ -694,14 +710,11 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) { - struct sock *sk; struct l2cap_disconn_req req; if (!conn) return; - sk = chan->sk; - if (chan->mode == L2CAP_MODE_ERTM) { __clear_retrans_timer(chan); __clear_monitor_timer(chan); @@ -714,7 +727,7 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c L2CAP_DISCONN_REQ, sizeof(req), &req); __l2cap_state_change(chan, BT_DISCONN); - sk->sk_err = err; + __l2cap_chan_set_err(chan, err); } /* ---- L2CAP connections ---- */ @@ -953,10 +966,8 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) mutex_lock(&conn->chan_lock); list_for_each_entry(chan, &conn->chan_l, list) { - struct sock *sk = chan->sk; - if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) - sk->sk_err = err; + __l2cap_chan_set_err(chan, err); } mutex_unlock(&conn->chan_lock); @@ -2988,7 +2999,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr } default: - sk->sk_err = ECONNRESET; + __l2cap_chan_set_err(chan, ECONNRESET); + __set_chan_timer(chan, msecs_to_jiffies(L2CAP_DISC_REJ_TIMEOUT)); l2cap_send_disconn_req(conn, chan, ECONNRESET); -- GitLab From 47990ea09d393da8fb6cf284f4dba704c3661973 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 11:58:37 +0200 Subject: [PATCH 1005/1846] Bluetooth: mgmt: Make Set Link Security callable while powered off This patch makes it possible to change the Link Security setting while powered off and have it automatically enabled when powering on a device. To track the desired state once powered on a new HCI_LINK_SECURITY flag is added. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 6 ++++++ net/bluetooth/mgmt.c | 33 ++++++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 169d2f8cc4ee..806eb4120797 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -98,6 +98,7 @@ enum { HCI_HS_ENABLED, HCI_CONNECTABLE, HCI_DISCOVERABLE, + HCI_LINK_SECURITY, }; /* HCI ioctl defines */ diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2a5d05c05e35..5fb1ee516d3a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -594,6 +594,12 @@ static void hci_setup(struct hci_dev *hdev) sizeof(cp), &cp); } + if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) { + u8 enable = 1; + hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, + sizeof(enable), &enable); + } + if (hdev->features[4] & LMP_LE) hci_set_le_support(hdev); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index e8f890d7256a..69d4e1a699a3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -410,7 +410,7 @@ static u32 get_current_settings(struct hci_dev *hdev) if (hdev->host_features[0] & LMP_HOST_LE) settings |= MGMT_SETTING_LE; - if (test_bit(HCI_AUTH, &hdev->flags)) + if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) settings |= MGMT_SETTING_LINK_SECURITY; if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) @@ -1067,8 +1067,21 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, - MGMT_STATUS_NOT_POWERED); + bool changed = false; + + if (!!cp->val != test_bit(HCI_LINK_SECURITY, + &hdev->dev_flags)) { + change_bit(HCI_LINK_SECURITY, &hdev->dev_flags); + changed = true; + } + + err = send_settings_rsp(sk, MGMT_OP_SET_LINK_SECURITY, hdev); + if (err < 0) + goto failed; + + if (changed) + err = new_settings(hdev, sk); + goto failed; } @@ -3338,7 +3351,8 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) { struct cmd_lookup match = { NULL, hdev }; - int err; + bool changed = false; + int err = 0; if (status) { u8 mgmt_err = mgmt_status(status); @@ -3347,10 +3361,19 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) return 0; } + if (test_bit(HCI_AUTH, &hdev->flags)) { + if (!test_and_set_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) + changed = true; + } else { + if (test_and_clear_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) + changed = true; + } + mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, settings_rsp, &match); - err = new_settings(hdev, match.sk); + if (changed) + err = new_settings(hdev, match.sk); if (match.sk) sock_put(match.sk); -- GitLab From 2e99b0afc7445769bb886dc14a31aaa0dc17c4b5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 12:28:39 +0200 Subject: [PATCH 1006/1846] Bluetooth: Remove unneeded hci_cc_read_ssp_mode function The kernel has no need to track the hci_read_ssp_mode command since it has the hci_sent_cmd_data function to check what value was set when hci_write_ssp_mode completes. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 5fb1ee516d3a..1b1c3480a24d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -420,21 +420,6 @@ static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_HOST_BUFFER_SIZE, status); } -static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) -{ - struct hci_rp_read_ssp_mode *rp = (void *) skb->data; - - BT_DBG("%s status 0x%x", hdev->name, rp->status); - - if (rp->status) - return; - - if (rp->mode) - set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); - else - clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); -} - static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) { __u8 status = *((__u8 *) skb->data); @@ -2201,10 +2186,6 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk hci_cc_host_buffer_size(hdev, skb); break; - case HCI_OP_READ_SSP_MODE: - hci_cc_read_ssp_mode(hdev, skb); - break; - case HCI_OP_WRITE_SSP_MODE: hci_cc_write_ssp_mode(hdev, skb); break; -- GitLab From c0ecddc2507da980af307aae40d6bcdea4c195dc Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 12:38:31 +0200 Subject: [PATCH 1007/1846] Bluetooth: mgmt: Make Set SSP command callable while powered off This patch makes it possible to enable SSP through mgmt even when powered off. The setting will then get automatically actiated when powering on. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_event.c | 20 +++++++-------- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 094b5dbdb130..6ba3a4b1078e 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1006,7 +1006,7 @@ int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); -int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status); +int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 1b1c3480a24d..240dc1640c04 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -427,21 +427,18 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, status); - if (status) - goto done; - sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SSP_MODE); if (!sent) return; - if (*((u8 *) sent)) - set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); - else - clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); - -done: if (test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_ssp_enable_complete(hdev, status); + mgmt_ssp_enable_complete(hdev, *((u8 *) sent), status); + else if (!status) { + if (*((u8 *) sent)) + set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); + else + clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); + } } static u8 hci_get_inquiry_mode(struct hci_dev *hdev) @@ -560,7 +557,8 @@ static void hci_setup(struct hci_dev *hdev) if (hdev->hci_ver > BLUETOOTH_VER_1_1) hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); - if (hdev->features[6] & LMP_SIMPLE_PAIR) { + if (hdev->features[6] & LMP_SIMPLE_PAIR && + test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { u8 mode = 0x01; hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, sizeof(mode), &mode); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 69d4e1a699a3..eefd08468002 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1138,9 +1138,23 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + val = !!cp->val; + if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_SSP, - MGMT_STATUS_NOT_POWERED); + bool changed = false; + + if (val != test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { + change_bit(HCI_SSP_ENABLED, &hdev->dev_flags); + changed = true; + } + + err = send_settings_rsp(sk, MGMT_OP_SET_SSP, hdev); + if (err < 0) + goto failed; + + if (changed) + err = new_settings(hdev, sk); + goto failed; } @@ -1155,8 +1169,6 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - val = !!cp->val; - if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) == val) { err = send_settings_rsp(sk, MGMT_OP_SET_SSP, hdev); goto failed; @@ -3393,21 +3405,37 @@ static int clear_eir(struct hci_dev *hdev) return hci_send_cmd(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 status) +int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) { struct cmd_lookup match = { NULL, hdev }; - int err; + bool changed = false; + int err = 0; if (status) { u8 mgmt_err = mgmt_status(status); + + if (enable && test_and_clear_bit(HCI_SSP_ENABLED, + &hdev->dev_flags)) + err = new_settings(hdev, NULL); + mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, cmd_status_rsp, &mgmt_err); - return 0; + + return err; + } + + if (enable) { + if (!test_and_set_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) + changed = true; + } else { + if (test_and_clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) + changed = true; } mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, settings_rsp, &match); - err = new_settings(hdev, match.sk); + if (changed) + err = new_settings(hdev, match.sk); if (match.sk) { sock_put(match.sk); -- GitLab From e5f0e151426bd83e4852a7a150fc6ad8ee349e69 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 11:59:01 +0100 Subject: [PATCH 1008/1846] Bluetooth: Fix two minor style issues in management code WARNING: Statements terminations use 1 semicolon + return err;; WARNING: space prohibited between function name and open parenthesis '(' + err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME, Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index eefd08468002..3f4c50eebbea 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -264,7 +264,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, if (err < 0) kfree_skb(skb); - return err;; + return err; } static int read_version(struct sock *sk) @@ -2532,7 +2532,7 @@ static int confirm_name(struct sock *sk, u16 index, void *data, u16 len) e = hci_inquiry_cache_lookup_unknown(hdev, &cp->addr.bdaddr); if (!e) { - err = cmd_status (sk, index, MGMT_OP_CONFIRM_NAME, + err = cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, MGMT_STATUS_INVALID_PARAMS); goto failed; } -- GitLab From 70c1f20b00495fd25b81be14b263d32648a3d629 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 12:06:43 +0100 Subject: [PATCH 1009/1846] Bluetooth: Fix two minor style issues in HCI code WARNING: min() should probably be min_t(__u16, scb->expect, count) + len = min(scb->expect, (__u16)count); WARNING: Statements terminations use 1 semicolon + INIT_LIST_HEAD(&conn->chan_list);; Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 3c68e606d5e5..947172bf1621 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -402,7 +402,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) skb_queue_head_init(&conn->data_q); - INIT_LIST_HEAD(&conn->chan_list);; + INIT_LIST_HEAD(&conn->chan_list); INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout); setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9d199494bd65..e1dadeea4c2f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1957,7 +1957,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data, while (count) { scb = (void *) skb->cb; - len = min(scb->expect, (__u16)count); + len = min_t(__u16, scb->expect, count); memcpy(skb_put(skb, len), data, len); -- GitLab From 6bf0e4699d1dd56f7f8c12cf332ebffaf1c5e83e Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 22 Feb 2012 13:21:16 +0200 Subject: [PATCH 1010/1846] Bluetooth: Fix coding style issues in mgmt code In this case we need to use braces in both branches. Signed-off-by: Andrei Emeltchenko Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3f4c50eebbea..9fb44900f7d6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -952,9 +952,9 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) if (!!cp->val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) changed = true; - if (cp->val) + if (cp->val) { set_bit(HCI_CONNECTABLE, &hdev->dev_flags); - else { + } else { clear_bit(HCI_CONNECTABLE, &hdev->dev_flags); clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); } @@ -987,9 +987,9 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - if (cp->val) + if (cp->val) { scan = SCAN_PAGE; - else { + } else { scan = 0; if (test_bit(HCI_ISCAN, &hdev->flags) && -- GitLab From 5fc6ebb102fdf6f589242ebfe3a07d112d60c7d5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 15:10:59 +0200 Subject: [PATCH 1011/1846] Bluetooth: mgmt: Fix EIR toggling with SSP This patch fixes setting the EIR properly when the SSP flag has been set when powered off (in such a case there is no pending Set_SSP command). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9fb44900f7d6..bdaadb278ce7 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3437,14 +3437,13 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) if (changed) err = new_settings(hdev, match.sk); - if (match.sk) { + if (match.sk) sock_put(match.sk); - if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) - update_eir(hdev); - else - clear_eir(hdev); - } + if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) + update_eir(hdev); + else + clear_eir(hdev); return err; } -- GitLab From c80da27e868f6ffbe1c6588937aa4e7aeab21dec Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 15:38:48 +0200 Subject: [PATCH 1012/1846] Bluetooth: mgmt: Fix clearing of hdev->eir The hdev->eir buffer needs to be cleared when clearing the EIR data. Otherwise subsequent attempts at setting the EIR to something valid again may fail because the code thinks that the EIR hasn't changed. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index bdaadb278ce7..08c657df7f8c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3400,6 +3400,8 @@ static int clear_eir(struct hci_dev *hdev) if (!(hdev->features[6] & LMP_EXT_INQ)) return 0; + memset(hdev->eir, 0, sizeof(hdev->eir)); + memset(&cp, 0, sizeof(cp)); return hci_send_cmd(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp); -- GitLab From 54d04dbbb933e8a49429d602b847e367782267e9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 15:47:48 +0200 Subject: [PATCH 1013/1846] Bluetooth: Explicitly clear EIR data upon hci_dev setup Some controllers preserve their EIR data even after a reset so we need to explicitly clear this during the device setup procedure. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 240dc1640c04..3476d5c7b02d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -557,10 +557,19 @@ static void hci_setup(struct hci_dev *hdev) if (hdev->hci_ver > BLUETOOTH_VER_1_1) hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); - if (hdev->features[6] & LMP_SIMPLE_PAIR && - test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { - u8 mode = 0x01; - hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, sizeof(mode), &mode); + if (hdev->features[6] & LMP_SIMPLE_PAIR) { + if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { + u8 mode = 0x01; + hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, + sizeof(mode), &mode); + } else { + struct hci_cp_write_eir cp; + + memset(hdev->eir, 0, sizeof(hdev->eir)); + memset(&cp, 0, sizeof(cp)); + + hci_send_cmd(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp); + } } if (hdev->features[3] & LMP_RSSI_INQ) -- GitLab From 97e0bdeb93cc9bd014c21d5400af4fa7f2fe2f91 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 13:49:28 +0100 Subject: [PATCH 1014/1846] Bluetooth: Enable timestamps for control channel The control channel can be also monitored, so include timestamps here as well. And make sure management events get their timestamp when they are created. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_sock.c | 1 + net/bluetooth/mgmt.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index dd5635064145..8a814bca00d7 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -782,6 +782,7 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, case HCI_CHANNEL_RAW: hci_sock_cmsg(sk, msg, skb); break; + case HCI_CHANNEL_CONTROL: case HCI_CHANNEL_MONITOR: sock_recv_timestamp(msg, sk, skb); break; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 08c657df7f8c..8b4df0473ec3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -817,6 +817,9 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, if (data) memcpy(skb_put(skb, data_len), data, data_len); + /* Time stamp */ + __net_timestamp(skb); + hci_send_to_control(skb, skip_sk); kfree_skb(skb); -- GitLab From 6c8f12c143fe83485afa530320e6f70dfc1aad54 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 16:35:26 +0200 Subject: [PATCH 1015/1846] Bluetooth: mgmt: Fix Set SSP supported check The test for SSP support needs to be earlier in the set_ssp function so that we return an error when SSP is not supported even when the device is powered off. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8b4df0473ec3..ac8ba839a78b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1141,6 +1141,12 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { + err = cmd_status(sk, index, MGMT_OP_SET_SSP, + MGMT_STATUS_NOT_SUPPORTED); + goto failed; + } + val = !!cp->val; if (!hdev_is_powered(hdev)) { @@ -1161,12 +1167,6 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { - err = cmd_status(sk, index, MGMT_OP_SET_SSP, - MGMT_STATUS_NOT_SUPPORTED); - goto failed; - } - if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_BUSY); goto failed; -- GitLab From 06199cf86a84206cfdc96b8dc02d5c27efa8c60f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 16:37:11 +0200 Subject: [PATCH 1016/1846] Bluetooth: mgmt: Implement Set LE command This patch implements support for the Set LE mgmt command. Now, in addition to the enable_le module parameter user space needs to send an explicit Enable LE command to enable LE support. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_event.c | 7 +- net/bluetooth/mgmt.c | 119 ++++++++++++++++++++++++++++++- 4 files changed, 126 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 806eb4120797..c97cf0872ac9 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -96,6 +96,7 @@ enum { HCI_LE_SCAN, HCI_SSP_ENABLED, HCI_HS_ENABLED, + HCI_LE_ENABLED, HCI_CONNECTABLE, HCI_DISCOVERABLE, HCI_LINK_SECURITY, diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 6ba3a4b1078e..abdaa7900edb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1010,6 +1010,7 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); +int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8 *eir, u16 eir_len); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 3476d5c7b02d..498b71a0579a 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -539,7 +539,7 @@ static void hci_set_le_support(struct hci_dev *hdev) memset(&cp, 0, sizeof(cp)); - if (enable_le) { + if (enable_le && test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { cp.le = 1; cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); } @@ -1130,10 +1130,15 @@ static inline void hci_cc_write_le_host_supported(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_cp_read_local_ext_features cp; + struct hci_cp_write_le_host_supported *sent; __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%x", hdev->name, status); + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); + if (sent && test_bit(HCI_MGMT, &hdev->dev_flags)) + mgmt_le_enable_complete(hdev, sent->le, status); + if (status) return; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ac8ba839a78b..8bc6a7a48732 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -407,7 +407,7 @@ static u32 get_current_settings(struct hci_dev *hdev) if (!(hdev->features[4] & LMP_NO_BREDR)) settings |= MGMT_SETTING_BREDR; - if (hdev->host_features[0] & LMP_HOST_LE) + if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) settings |= MGMT_SETTING_LE; if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) @@ -1231,6 +1231,82 @@ static int set_hs(struct sock *sk, u16 index, void *data, u16 len) return err; } +static int set_le(struct sock *sk, u16 index, void *data, u16 len) +{ + struct mgmt_mode *cp = data; + struct hci_cp_write_le_host_supported hci_cp; + struct pending_cmd *cmd; + struct hci_dev *hdev; + int err; + u8 val; + + BT_DBG("request for hci%u", index); + + if (len != sizeof(*cp)) + return cmd_status(sk, index, MGMT_OP_SET_LE, + MGMT_STATUS_INVALID_PARAMS); + + hdev = hci_dev_get(index); + if (!hdev) + return cmd_status(sk, index, MGMT_OP_SET_LE, + MGMT_STATUS_INVALID_PARAMS); + + if (!enable_le || !(hdev->features[4] & LMP_LE)) { + err = cmd_status(sk, index, MGMT_OP_SET_LE, + MGMT_STATUS_NOT_SUPPORTED); + goto failed; + } + + val = !!cp->val; + + if (!hdev_is_powered(hdev)) { + bool changed = false; + + if (val != test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { + change_bit(HCI_LE_ENABLED, &hdev->dev_flags); + changed = true; + } + + err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); + if (err < 0) + goto failed; + + if (changed) + err = new_settings(hdev, sk); + + goto failed; + } + + if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { + err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY); + goto failed; + } + + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LE, hdev, data, len); + if (!cmd) { + err = -ENOMEM; + goto failed; + } + + memset(&hci_cp, 0, sizeof(hci_cp)); + + if (val) { + hci_cp.le = val; + hci_cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); + } + + err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, + sizeof(hci_cp), &hci_cp); + if (err < 0) { + mgmt_pending_remove(cmd); + goto failed; + } + +failed: + hci_dev_put(hdev); + return err; +} + static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_add_uuid *cp = data; @@ -2816,6 +2892,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_SET_HS: err = set_hs(sk, index, cp, len); break; + case MGMT_OP_SET_LE: + err = set_le(sk, index, cp, len); + break; case MGMT_OP_ADD_UUID: err = add_uuid(sk, index, cp, len); break; @@ -3521,6 +3600,44 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, return err; } +int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) +{ + struct cmd_lookup match = { NULL, hdev }; + bool changed = false; + int err = 0; + + if (status) { + u8 mgmt_err = mgmt_status(status); + + if (enable && test_and_clear_bit(HCI_LE_ENABLED, + &hdev->dev_flags)) + err = new_settings(hdev, NULL); + + mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, + cmd_status_rsp, &mgmt_err); + + return err; + } + + if (enable) { + if (!test_and_set_bit(HCI_LE_ENABLED, &hdev->dev_flags)) + changed = true; + } else { + if (test_and_clear_bit(HCI_LE_ENABLED, &hdev->dev_flags)) + changed = true; + } + + mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match); + + if (changed) + err = new_settings(hdev, match.sk); + + if (match.sk) + sock_put(match.sk); + + return err; +} + int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8 *eir, u16 eir_len) -- GitLab From e59fda8dc14c173b74b5e9d5c8d72849d2ff6b5f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 18:11:53 +0200 Subject: [PATCH 1017/1846] Bluetooth: Fix EIR data clearing when powering off When powering off we should assume that the EIR data isn't valid anymore. This patch makes sure it gets cleared in hci_dev_do_close and thereby ensures that a correct new EIR is recreated when powering on again. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e1dadeea4c2f..2d75ffb42f7d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -794,6 +794,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) /* Clear flags */ hdev->flags = 0; + memset(hdev->eir, 0, sizeof(hdev->eir)); + hci_req_unlock(hdev); hci_dev_put(hdev); -- GitLab From f51d5b248981d05269e4f83ab8f8ed7ed494fe33 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 18:17:32 +0200 Subject: [PATCH 1018/1846] Bluetooth: mgmt: Fix updating EIR when updating the name Whenever we update the local device name the EIR data also needs to be updated to reflect this. The update_eir() function in mgmt.c depends on hdev->dev_name to be up to date so the patch also makes sure that the mgmt function is called from hci_event.c after the update has happened. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 6 +++--- net/bluetooth/mgmt.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 498b71a0579a..e44e3fd68628 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -209,12 +209,12 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_set_local_name_complete(hdev, sent, status); - if (status == 0) memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); + if (test_bit(HCI_MGMT, &hdev->dev_flags)) + mgmt_set_local_name_complete(hdev, sent, status); + hci_dev_unlock(hdev); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 8bc6a7a48732..d756644163bc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3561,6 +3561,7 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) send_event: err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, sizeof(ev), cmd ? cmd->sk : NULL); + update_eir(hdev); failed: if (cmd) -- GitLab From 24c54a90527ca5b85e7feedde2c779dc056ffddb Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 18:06:34 +0100 Subject: [PATCH 1019/1846] Bluetooth: Disabling discoverable with timeout is invalid Add one extra sanity check to ensure that the supplied timeout value is actually valid in this context. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d756644163bc..6df4af6e99cc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -850,13 +850,16 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_INVALID_PARAMS); + timeout = get_unaligned_le16(&cp->timeout); + if (!cp->val && timeout > 0) + return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + MGMT_STATUS_INVALID_PARAMS); + hdev = hci_dev_get(index); if (!hdev) return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_INVALID_PARAMS); - timeout = get_unaligned_le16(&cp->timeout); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev) && timeout > 0) { -- GitLab From 955638ecec9431788e291fc99f34c42124071abe Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 18:21:00 +0100 Subject: [PATCH 1020/1846] Bluetooth: Fix handling of discoverable setting with timeout The current handling of the discoverable timeout was missing the proper handling of the timeout when the mode was already set. Now the command can be used to expire or retrigger the timeout. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 6df4af6e99cc..f7e111f30434 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -900,6 +900,17 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) } if (!!cp->val == test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) { + if (hdev->discov_timeout > 0) { + cancel_delayed_work(&hdev->discov_off); + hdev->discov_timeout = 0; + } + + if (cp->val && timeout > 0) { + hdev->discov_timeout = timeout; + queue_delayed_work(hdev->workqueue, &hdev->discov_off, + msecs_to_jiffies(hdev->discov_timeout * 1000)); + } + err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); goto failed; } -- GitLab From 7f9a903c57bb42b9f7ad8fb7867859d3252229ab Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 18:38:01 +0100 Subject: [PATCH 1021/1846] Bluetooth: Send management event for class of device changes Currently there are no events to other management sockets if the class of device got changed. So make sure they are sent. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_event.c | 13 +++++++++---- net/bluetooth/mgmt.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index abdaa7900edb..24dd770d442b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1007,6 +1007,8 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 status); int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); +int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, + u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, u8 *randomizer, u8 status); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e44e3fd68628..c79ffb955554 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -350,14 +350,19 @@ static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, status); - if (status) - return; - sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); if (!sent) return; - memcpy(hdev->dev_class, sent, 3); + hci_dev_lock(hdev); + + if (status == 0) + memcpy(hdev->dev_class, sent, 3); + + if (test_bit(HCI_MGMT, &hdev->dev_flags)) + mgmt_set_class_of_dev_complete(hdev, sent, status); + + hci_dev_unlock(hdev); } static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f7e111f30434..16bddd22713f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3546,6 +3546,16 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) return err; } +int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, + u8 status) +{ + int err; + + err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class, 3, NULL); + + return err; +} + int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) { struct pending_cmd *cmd; -- GitLab From 490c5baba7a5ad80782d5eb778638d1cfc8d70ce Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 19:19:09 +0200 Subject: [PATCH 1022/1846] Bluetooth: Add hdev->short_name for EIR generation It's possible to provide a short name through the mgmt interface and this name can be used for EIR generation when the full name doesn't fit there. This patch adds the preliminary tracking of the provided short name. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 3 +++ include/net/bluetooth/mgmt.h | 2 +- net/bluetooth/mgmt.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 24dd770d442b..3fcc7f0d08c3 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -129,6 +129,8 @@ struct le_scan_params { int timeout; }; +#define HCI_MAX_SHORT_NAME_LENGTH 10 + #define NUM_REASSEMBLY 4 struct hci_dev { struct list_head list; @@ -141,6 +143,7 @@ struct hci_dev { __u8 dev_type; bdaddr_t bdaddr; __u8 dev_name[HCI_MAX_NAME_LENGTH]; + __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; __u8 eir[HCI_MAX_EIR_LENGTH]; __u8 dev_class[3]; __u8 major_class; diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index ac59cdd0fa1b..495668c77fb6 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -75,7 +75,7 @@ struct mgmt_rp_read_index_list { /* Reserve one extra byte for names in management messages so that they * are always guaranteed to be nul-terminated */ #define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) -#define MGMT_MAX_SHORT_NAME_LENGTH (10 + 1) +#define MGMT_MAX_SHORT_NAME_LENGTH (HCI_MAX_SHORT_NAME_LENGTH + 1) #define MGMT_SETTING_POWERED 0x00000001 #define MGMT_SETTING_CONNECTABLE 0x00000002 diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 16bddd22713f..3f6a2df9d150 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2273,6 +2273,9 @@ static int set_local_name(struct sock *sk, u16 index, void *data, goto failed; } + memcpy(hdev->short_name, mgmt_cp->short_name, + sizeof(hdev->short_name)); + memcpy(hci_cp.name, mgmt_cp->name, sizeof(hci_cp.name)); err = hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(hci_cp), &hci_cp); -- GitLab From db99b5fc77e6cec47d80703b471f1efe04527d2f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 20:14:22 +0200 Subject: [PATCH 1023/1846] Bluetooth: Fix read_name updating when HCI_SETUP is not set The local name should only be updated as a consequence of a hci_read_local_name if we are in the HCI_SETUP state. In all other scenarios it should only be updated through hci_write_local_name. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index c79ffb955554..9917fe3d1d18 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -227,7 +227,8 @@ static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) if (rp->status) return; - memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); + if (test_bit(HCI_SETUP, &hdev->dev_flags)) + memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); } static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From 28cc7bde5978cbc58c9026123fa5f33b62ad66b3 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 21:06:55 +0200 Subject: [PATCH 1024/1846] Bluetooth: mgmt: Allow local name changes while powered off This patch makes it possible to set the local name before powering on the device. The name will be applied using the hci_write_local_name command once the device gets powered on. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 13 ++++++++++--- net/bluetooth/mgmt.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9917fe3d1d18..9b30587c0de6 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -209,11 +209,10 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); - if (status == 0) - memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); - if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_set_local_name_complete(hdev, sent, status); + else if (!status) + memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); hci_dev_unlock(hdev); } @@ -563,6 +562,14 @@ static void hci_setup(struct hci_dev *hdev) if (hdev->hci_ver > BLUETOOTH_VER_1_1) hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); + if (!test_bit(HCI_SETUP, &hdev->dev_flags) && + test_bit(HCI_MGMT, &hdev->dev_flags)) { + struct hci_cp_write_local_name cp; + + memcpy(cp.name, hdev->dev_name, sizeof(cp.name)); + hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp); + } + if (hdev->features[6] & LMP_SIMPLE_PAIR) { if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { u8 mode = 0x01; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3f6a2df9d150..9c1f7714794d 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2260,22 +2260,29 @@ static int set_local_name(struct sock *sk, u16 index, void *data, hci_dev_lock(hdev); + memcpy(hdev->short_name, mgmt_cp->short_name, + sizeof(hdev->short_name)); + if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, - MGMT_STATUS_NOT_POWERED); + memcpy(hdev->dev_name, mgmt_cp->name, sizeof(hdev->dev_name)); + + err = cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, + data, len); + if (err < 0) + goto failed; + + err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, data, len, + sk); + goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, - len); + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; } - memcpy(hdev->short_name, mgmt_cp->short_name, - sizeof(hdev->short_name)); - memcpy(hci_cp.name, mgmt_cp->name, sizeof(hci_cp.name)); err = hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(hci_cp), &hci_cp); @@ -3563,10 +3570,17 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) { struct pending_cmd *cmd; struct mgmt_cp_set_local_name ev; - int err; + bool changed = false; + int err = 0; + + if (memcmp(name, hdev->dev_name, sizeof(hdev->dev_name)) != 0) { + memcpy(hdev->dev_name, name, sizeof(hdev->dev_name)); + changed = true; + } memset(&ev, 0, sizeof(ev)); memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); + memcpy(ev.short_name, hdev->short_name, HCI_MAX_SHORT_NAME_LENGTH); cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, hdev); if (!cmd) @@ -3578,16 +3592,16 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) goto failed; } - update_eir(hdev); - err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, &ev, sizeof(ev)); if (err < 0) goto failed; send_event: - err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, sizeof(ev), - cmd ? cmd->sk : NULL); + if (changed) + err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, + sizeof(ev), cmd ? cmd->sk : NULL); + update_eir(hdev); failed: -- GitLab From 7bdaae4a4bc075cf73ab9c3a531b7229caa1f49e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 21:39:58 +0200 Subject: [PATCH 1025/1846] Bluetooth: mgmt: Fix name_changed event for short name changes Since we can't reliably track the short name changes just assume that we had a change whenever there's a pending mgmt command. In the worst case we just get one unnecessary name_changed signal. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9c1f7714794d..ee57edbb13ec 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3586,6 +3586,10 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) if (!cmd) goto send_event; + /* Always assume that either the short or the complete name has + * changed if there was a pending mgmt command */ + changed = true; + if (status) { err = cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, mgmt_status(status)); -- GitLab From 27fcc362297b8e838a929c947b82eabb3f4b7591 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 21:46:22 +0200 Subject: [PATCH 1026/1846] Bluetooth: mgmt: Fix missing short_name in read_info The short name is part of the Read Controller Info response and should be appropriately filled in based on the value of hdev->short_name. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ee57edbb13ec..6850a8b46c62 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -648,6 +648,7 @@ static int read_controller_info(struct sock *sk, u16 index) memcpy(rp.dev_class, hdev->dev_class, 3); memcpy(rp.name, hdev->dev_name, sizeof(hdev->dev_name)); + memcpy(rp.short_name, hdev->short_name, sizeof(hdev->short_name)); hci_dev_unlock(hdev); hci_dev_put(hdev); -- GitLab From 09b3c3fbbee9aef8ac5d9148ae61aae35766b2a6 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 22:01:41 +0200 Subject: [PATCH 1027/1846] Bluetooth: Fix clearing of dev_class when powering down We should assume a value of 0 for the device class when powered off. The appropriate place to do this is in hci_dev_do_close(). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2d75ffb42f7d..2ab78bfc108e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -795,6 +795,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) hdev->flags = 0; memset(hdev->eir, 0, sizeof(hdev->eir)); + memset(hdev->dev_class, 0, sizeof(hdev->dev_class)); hci_req_unlock(hdev); -- GitLab From 8ec37034ef36b89cfb060bd9273db24e6acb1b3a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 22:02:50 +0200 Subject: [PATCH 1028/1846] Bluetooth: mgmt: Fix return value for set_class The return parameters for Set Device Class should consist of the new class value. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 6850a8b46c62..23421f05abf2 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1470,7 +1470,7 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) if (err == 0) err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, - NULL, 0); + hdev->dev_class, 3); unlock: hci_dev_unlock(hdev); -- GitLab From 7770c4aacaf34fb69cb2acfb7469e9b4e34f1674 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 22:06:38 +0200 Subject: [PATCH 1029/1846] Bluetooth: mgmt: Check for HCI_UP in update_eir() and update_class() These functions should just silently fail when we're not powered on instead of trying to send HCI commands. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 23421f05abf2..3a2066504ffe 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -532,6 +532,9 @@ static int update_eir(struct hci_dev *hdev) { struct hci_cp_write_eir cp; + if (!test_bit(HCI_UP, &hdev->flags)) + return 0; + if (!(hdev->features[6] & LMP_EXT_INQ)) return 0; @@ -570,6 +573,9 @@ static int update_class(struct hci_dev *hdev) BT_DBG("%s", hdev->name); + if (!test_bit(HCI_UP, &hdev->flags)) + return 0; + if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) return 0; -- GitLab From 932f5ff5e32bf520eb9287b050c926faa6e76bcf Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 22:11:32 +0200 Subject: [PATCH 1030/1846] Bluetooth: mgmt: Allow class of device changes while powered off This patch makes it possible to set the class when powered off. When powering on the right class of device value will be automatically writen to the controller. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3a2066504ffe..a45c2b70dfdb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1456,15 +1456,15 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + hdev->major_class = cp->major; + hdev->minor_class = cp->minor; + if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, - MGMT_STATUS_NOT_POWERED); + err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, + hdev->dev_class, 3); goto unlock; } - hdev->major_class = cp->major; - hdev->minor_class = cp->minor; - if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) { hci_dev_unlock(hdev); cancel_delayed_work_sync(&hdev->service_cache); -- GitLab From 5f97c1df5563349795f26ed249e2a8840237c569 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 22:41:18 +0200 Subject: [PATCH 1031/1846] Bluetooth: mgmt: Add missing powered checks to commands This patch adds missing powered checks to pair_device, cancel_pair_device, add_remote_oob_data and remove_remote_oob_data. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a45c2b70dfdb..7c7bc2a21393 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1735,6 +1735,12 @@ static int get_connections(struct sock *sk, u16 index) hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_status(sk, index, MGMT_OP_GET_CONNECTIONS, + MGMT_STATUS_NOT_POWERED); + goto unlock; + } + count = 0; list_for_each_entry(c, &hdev->conn_hash.list, list) { if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) @@ -1766,8 +1772,9 @@ static int get_connections(struct sock *sk, u16 index) err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, 0, rp, rp_len); -unlock: kfree(rp); + +unlock: hci_dev_unlock(hdev); hci_dev_put(hdev); return err; @@ -2002,6 +2009,12 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, + MGMT_STATUS_NOT_POWERED); + goto unlock; + } + sec_level = BT_SECURITY_MEDIUM; if (cp->io_cap == 0x03) auth_type = HCI_AT_DEDICATED_BONDING; @@ -2084,6 +2097,12 @@ static int cancel_pair_device(struct sock *sk, u16 index, hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + MGMT_STATUS_NOT_POWERED); + goto unlock; + } + cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev); if (!cmd) { err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, @@ -2375,6 +2394,13 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, + MGMT_STATUS_NOT_POWERED, + &cp->addr, sizeof(cp->addr)); + goto unlock; + } + err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, cp->randomizer); if (err < 0) @@ -2385,6 +2411,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, status, &cp->addr, sizeof(cp->addr)); +unlock: hci_dev_unlock(hdev); hci_dev_put(hdev); @@ -2413,6 +2440,13 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, hci_dev_lock(hdev); + if (!hdev_is_powered(hdev)) { + err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, + MGMT_STATUS_NOT_POWERED, + &cp->addr, sizeof(cp->addr)); + goto unlock; + } + err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr); if (err < 0) status = MGMT_STATUS_INVALID_PARAMS; @@ -2422,6 +2456,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, status, &cp->addr, sizeof(cp->addr)); +unlock: hci_dev_unlock(hdev); hci_dev_put(hdev); -- GitLab From 86a8cfc6d0428f32d702ec59c1b3ef38541a6821 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 22 Feb 2012 22:53:34 +0200 Subject: [PATCH 1032/1846] Bluetooth: mgmt: Fix unpair_device responses This patch adds an error return when not powered and cleans up/simpifies the function logic in the same go. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 7c7bc2a21393..36bebfb2d840 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1561,7 +1561,6 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) struct hci_cp_disconnect dc; struct pending_cmd *cmd; struct hci_conn *conn; - u8 status = 0; int err; if (len != sizeof(*cp)) @@ -1579,32 +1578,38 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); rp.addr.type = cp->addr.type; + if (!hdev_is_powered(hdev)) { + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, + MGMT_STATUS_NOT_POWERED, + &rp, sizeof(rp)); + goto unlock; + } + if (cp->addr.type == MGMT_ADDR_BREDR) err = hci_remove_link_key(hdev, &cp->addr.bdaddr); else err = hci_remove_ltk(hdev, &cp->addr.bdaddr); if (err < 0) { - status = MGMT_STATUS_NOT_PAIRED; - goto unlock; - } - - if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, status, - &rp, sizeof(rp)); - device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, + MGMT_STATUS_NOT_PAIRED, + &rp, sizeof(rp)); goto unlock; } - if (cp->addr.type == MGMT_ADDR_BREDR) - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, + if (cp->disconnect) { + if (cp->addr.type == MGMT_ADDR_BREDR) + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); - else - conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, + else + conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr); + } else { + conn = NULL; + } if (!conn) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, status, + err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, 0, &rp, sizeof(rp)); device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; @@ -1624,9 +1629,6 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) mgmt_pending_remove(cmd); unlock: - if (err < 0) - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, status, - &rp, sizeof(rp)); hci_dev_unlock(hdev); hci_dev_put(hdev); -- GitLab From 9a395a80dc6a2004787539dcc0c7d167ba87e89a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 00:00:32 +0200 Subject: [PATCH 1033/1846] Bluetooth: mgmt: Fix device_found parameters According to the latest mgmt API there's a flags field instead of a separate confirm_name paramter. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 5 ++++- net/bluetooth/mgmt.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 495668c77fb6..09646f5ef36a 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -393,11 +393,14 @@ struct mgmt_ev_auth_failed { __u8 status; } __packed; +#define MGMT_DEV_FOUND_CONFIRM_NAME 0x01 +#define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02 + #define MGMT_EV_DEVICE_FOUND 0x0012 struct mgmt_ev_device_found { struct mgmt_addr_info addr; __s8 rssi; - __u8 confirm_name; + __u8 flags[4]; __le16 eir_len; __u8 eir[0]; } __packed; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 36bebfb2d840..b7b10ca297d5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3745,7 +3745,8 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, bacpy(&ev->addr.bdaddr, bdaddr); ev->addr.type = link_to_mgmt(link_type, addr_type); ev->rssi = rssi; - ev->confirm_name = cfm_name; + if (cfm_name) + ev->flags[0] |= MGMT_DEV_FOUND_CONFIRM_NAME; if (eir_len > 0) memcpy(ev->eir, eir, eir_len); -- GitLab From 388fc8faf200f80159353eb86cde4ab75d0a0bbd Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 00:38:59 +0200 Subject: [PATCH 1034/1846] Bluetooth: mgmt: Add legacy pairing info to dev_found events This patch makes sure that legacy pairing vs SSP infomation gets properly propageted to the device_found events in the form of the legacy pairing flag. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 5 +++-- net/bluetooth/hci_core.c | 8 +++++++- net/bluetooth/hci_event.c | 26 ++++++++++++++------------ net/bluetooth/mgmt.c | 4 +++- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 3fcc7f0d08c3..720bdc26b7e9 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -407,7 +407,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, struct inquiry_entry *ie); bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, - bool name_known); + bool name_known, bool *ssp); /* ----- HCI Connections ----- */ enum { @@ -1018,7 +1018,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 *eir, u16 eir_len); + u8 cfm_name, u8 ssp, u8 *eir, + u16 eir_len); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, s8 rssi, u8 *name, u8 name_len); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2ab78bfc108e..e6cbb8a1f47d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -466,15 +466,21 @@ void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, } bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, - bool name_known) + bool name_known, bool *ssp) { struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *ie; BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr)); + if (ssp) + *ssp = data->ssp_mode; + ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr); if (ie) { + if (ie->data.ssp_mode && ssp) + *ssp = true; + if (ie->name_state == NAME_NEEDED && data->rssi != ie->data.rssi) { ie->data.rssi = data->rssi; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9b30587c0de6..276f3ac06089 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1696,7 +1696,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * hci_dev_lock(hdev); for (; num_rsp; num_rsp--, info++) { - bool name_known; + bool name_known, ssp; bacpy(&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; @@ -1707,9 +1707,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * data.rssi = 0x00; data.ssp_mode = 0x00; - name_known = hci_inquiry_cache_update(hdev, &data, false); + name_known = hci_inquiry_cache_update(hdev, &data, false, &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, 0, !name_known, + info->dev_class, 0, !name_known, ssp, NULL, 0); } @@ -2783,7 +2783,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct { struct inquiry_data data; int num_rsp = *((__u8 *) skb->data); - bool name_known; + bool name_known, ssp; BT_DBG("%s num_rsp %d", hdev->name, num_rsp); @@ -2807,10 +2807,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.ssp_mode = 0x00; name_known = hci_inquiry_cache_update(hdev, &data, - false); + false, &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - !name_known, NULL, 0); + !name_known, ssp, NULL, 0); } } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); @@ -2825,10 +2825,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; name_known = hci_inquiry_cache_update(hdev, &data, - false); + false, &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - !name_known, NULL, 0); + !name_known, ssp, NULL, 0); } } @@ -2964,7 +2964,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct hci_dev_lock(hdev); for (; num_rsp; num_rsp--, info++) { - bool name_known; + bool name_known, ssp; bacpy(&data.bdaddr, &info->bdaddr); data.pscan_rep_mode = info->pscan_rep_mode; @@ -2982,10 +2982,11 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct else name_known = true; - name_known = hci_inquiry_cache_update(hdev, &data, name_known); + name_known = hci_inquiry_cache_update(hdev, &data, name_known, + &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, info->dev_class, info->rssi, - !name_known, info->data, + !name_known, ssp, info->data, sizeof(info->data)); } @@ -3310,7 +3311,8 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev, rssi = ev->data[ev->length]; mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type, - NULL, rssi, 0, ev->data, ev->length); + NULL, rssi, 0, 1, ev->data, + ev->length); ptr += sizeof(*ev) + ev->length + 1; } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index b7b10ca297d5..42d665bdc01f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3730,7 +3730,7 @@ int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 *eir, u16 eir_len) + u8 cfm_name, u8 ssp, u8 *eir, u16 eir_len) { char buf[512]; struct mgmt_ev_device_found *ev = (void *) buf; @@ -3747,6 +3747,8 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, ev->rssi = rssi; if (cfm_name) ev->flags[0] |= MGMT_DEV_FOUND_CONFIRM_NAME; + if (!ssp) + ev->flags[0] |= MGMT_DEV_FOUND_LEGACY_PAIRING; if (eir_len > 0) memcpy(ev->eir, eir, eir_len); -- GitLab From 643162a8e2c15a1c1983a0063d9941240b3bde30 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 22 Feb 2012 17:11:55 +0200 Subject: [PATCH 1035/1846] Bluetooth: Add unlocked __l2cap_chan_add function Add unlocked L2CAP channel add function. Unlocked version will be used in later patches. Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index c0640b73c628..0e4f4cb2acbb 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -300,7 +300,7 @@ void l2cap_chan_destroy(struct l2cap_chan *chan) l2cap_chan_put(chan); } -static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) +void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) { BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, chan->psm, chan->dcid); @@ -346,8 +346,13 @@ static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) l2cap_chan_hold(chan); - mutex_lock(&conn->chan_lock); list_add(&chan->list, &conn->chan_l); +} + +void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) +{ + mutex_lock(&conn->chan_lock); + __l2cap_chan_add(conn, chan); mutex_unlock(&conn->chan_lock); } -- GitLab From 6be3655552ee49aa2b5fd20fa1b08f28d0feac86 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 22 Feb 2012 17:11:56 +0200 Subject: [PATCH 1036/1846] Bluetooth: Change sk lock to chan lock in L2CAP core Change sk lock to chan lock in l2cap core and move sk locks to l2cap sock code. bh_locks were used because of being RCU critical section. When needed use explicit socket locks. Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 166 ++++++++++++++++++++++--------------- net/bluetooth/l2cap_sock.c | 18 +++- 2 files changed, 114 insertions(+), 70 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0e4f4cb2acbb..5f4cfea33915 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -238,13 +238,12 @@ static void l2cap_chan_timeout(struct work_struct *work) struct l2cap_chan *chan = container_of(work, struct l2cap_chan, chan_timer.work); struct l2cap_conn *conn = chan->conn; - struct sock *sk = chan->sk; int reason; BT_DBG("chan %p state %s", chan, state_to_string(chan->state)); mutex_lock(&conn->chan_lock); - lock_sock(sk); + l2cap_chan_lock(chan); if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) reason = ECONNREFUSED; @@ -256,7 +255,7 @@ static void l2cap_chan_timeout(struct work_struct *work) l2cap_chan_close(chan, reason); - release_sock(sk); + l2cap_chan_unlock(chan); chan->ops->close(chan->data); mutex_unlock(&conn->chan_lock); @@ -356,8 +355,6 @@ void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) mutex_unlock(&conn->chan_lock); } -/* Delete channel. - * Must be called on the locked socket. */ static void l2cap_chan_del(struct l2cap_chan *chan, int err) { struct sock *sk = chan->sk; @@ -378,6 +375,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) hci_conn_put(conn->hcon); } + lock_sock(sk); + __l2cap_state_change(chan, BT_CLOSED); sock_set_flag(sk, SOCK_ZAPPED); @@ -390,6 +389,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) } else sk->sk_state_change(sk); + release_sock(sk); + if (!(test_bit(CONF_OUTPUT_DONE, &chan->conf_state) && test_bit(CONF_INPUT_DONE, &chan->conf_state))) return; @@ -422,10 +423,10 @@ static void l2cap_chan_cleanup_listen(struct sock *parent) while ((sk = bt_accept_dequeue(parent, NULL))) { struct l2cap_chan *chan = l2cap_pi(sk)->chan; + l2cap_chan_lock(chan); __clear_chan_timer(chan); - lock_sock(sk); l2cap_chan_close(chan, ECONNRESET); - release_sock(sk); + l2cap_chan_unlock(chan); chan->ops->close(chan->data); } @@ -441,10 +442,12 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) switch (chan->state) { case BT_LISTEN: + lock_sock(sk); l2cap_chan_cleanup_listen(sk); __l2cap_state_change(chan, BT_CLOSED); sock_set_flag(sk, SOCK_ZAPPED); + release_sock(sk); break; case BT_CONNECTED: @@ -487,7 +490,9 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) break; default: + lock_sock(sk); sock_set_flag(sk, SOCK_ZAPPED); + release_sock(sk); break; } } @@ -715,6 +720,7 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) { + struct sock *sk = chan->sk; struct l2cap_disconn_req req; if (!conn) @@ -731,8 +737,10 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ, sizeof(req), &req); + lock_sock(sk); __l2cap_state_change(chan, BT_DISCONN); __l2cap_chan_set_err(chan, err); + release_sock(sk); } /* ---- L2CAP connections ---- */ @@ -747,10 +755,10 @@ static void l2cap_conn_start(struct l2cap_conn *conn) list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) { struct sock *sk = chan->sk; - bh_lock_sock(sk); + l2cap_chan_lock(chan); if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } @@ -759,17 +767,15 @@ static void l2cap_conn_start(struct l2cap_conn *conn) if (!l2cap_chan_check_security(chan) || !__l2cap_no_conn_pending(chan)) { - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } if (!l2cap_mode_supported(chan->mode, conn->feat_mask) && test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { - /* l2cap_chan_close() calls list_del(chan) - * so release the lock */ l2cap_chan_close(chan, ECONNRESET); - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } @@ -789,6 +795,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) rsp.dcid = cpu_to_le16(chan->scid); if (l2cap_chan_check_security(chan)) { + lock_sock(sk); if (bt_sk(sk)->defer_setup) { struct sock *parent = bt_sk(sk)->parent; rsp.result = cpu_to_le16(L2CAP_CR_PEND); @@ -801,6 +808,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); } + release_sock(sk); } else { rsp.result = cpu_to_le16(L2CAP_CR_PEND); rsp.status = cpu_to_le16(L2CAP_CS_AUTHEN_PEND); @@ -811,7 +819,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) if (test_bit(CONF_REQ_SENT, &chan->conf_state) || rsp.result != L2CAP_CR_SUCCESS) { - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } @@ -821,7 +829,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) chan->num_conf_req++; } - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); } mutex_unlock(&conn->chan_lock); @@ -910,7 +918,11 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) static void l2cap_chan_ready(struct l2cap_chan *chan) { struct sock *sk = chan->sk; - struct sock *parent = bt_sk(sk)->parent; + struct sock *parent; + + lock_sock(sk); + + parent = bt_sk(sk)->parent; BT_DBG("sk %p, parent %p", sk, parent); @@ -922,6 +934,8 @@ static void l2cap_chan_ready(struct l2cap_chan *chan) if (parent) parent->sk_data_ready(parent, 0); + + release_sock(sk); } static void l2cap_conn_ready(struct l2cap_conn *conn) @@ -939,23 +953,25 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) mutex_lock(&conn->chan_lock); list_for_each_entry(chan, &conn->chan_l, list) { - struct sock *sk = chan->sk; - bh_lock_sock(sk); + l2cap_chan_lock(chan); if (conn->hcon->type == LE_LINK) { if (smp_conn_security(conn, chan->sec_level)) l2cap_chan_ready(chan); } else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { + struct sock *sk = chan->sk; __clear_chan_timer(chan); + lock_sock(sk); __l2cap_state_change(chan, BT_CONNECTED); sk->sk_state_change(sk); + release_sock(sk); } else if (chan->state == BT_CONNECT) l2cap_do_start(chan); - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); } mutex_unlock(&conn->chan_lock); @@ -993,7 +1009,6 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) { struct l2cap_conn *conn = hcon->l2cap_data; struct l2cap_chan *chan, *l; - struct sock *sk; if (!conn) return; @@ -1006,10 +1021,12 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) /* Kill channels */ list_for_each_entry_safe(chan, l, &conn->chan_l, list) { - sk = chan->sk; - lock_sock(sk); + l2cap_chan_lock(chan); + l2cap_chan_del(chan, err); - release_sock(sk); + + l2cap_chan_unlock(chan); + chan->ops->close(chan->data); } @@ -1140,7 +1157,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d hci_dev_lock(hdev); - lock_sock(sk); + l2cap_chan_lock(chan); /* PSM must be odd and lsb of upper byte must be 0 */ if ((__le16_to_cpu(psm) & 0x0101) != 0x0001 && !cid && @@ -1167,17 +1184,21 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d goto done; } + lock_sock(sk); + switch (sk->sk_state) { case BT_CONNECT: case BT_CONNECT2: case BT_CONFIG: /* Already connecting */ err = 0; + release_sock(sk); goto done; case BT_CONNECTED: /* Already connected */ err = -EISCONN; + release_sock(sk); goto done; case BT_OPEN: @@ -1187,11 +1208,15 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d default: err = -EBADFD; + release_sock(sk); goto done; } /* Set destination address and psm */ bacpy(&bt_sk(sk)->dst, dst); + + release_sock(sk); + chan->psm = psm; chan->dcid = cid; @@ -1219,16 +1244,18 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d /* Update source addr of the socket */ bacpy(src, conn->src); + l2cap_chan_unlock(chan); l2cap_chan_add(conn, chan); + l2cap_chan_lock(chan); - __l2cap_state_change(chan, BT_CONNECT); + l2cap_state_change(chan, BT_CONNECT); __set_chan_timer(chan, sk->sk_sndtimeo); if (hcon->state == BT_CONNECTED) { if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { __clear_chan_timer(chan); if (l2cap_chan_check_security(chan)) - __l2cap_state_change(chan, BT_CONNECTED); + l2cap_state_change(chan, BT_CONNECTED); } else l2cap_do_start(chan); } @@ -1236,6 +1263,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d err = 0; done: + l2cap_chan_unlock(chan); hci_dev_unlock(hdev); hci_dev_put(hdev); return err; @@ -1277,14 +1305,14 @@ static void l2cap_monitor_timeout(struct work_struct *work) { struct l2cap_chan *chan = container_of(work, struct l2cap_chan, monitor_timer.work); - struct sock *sk = chan->sk; BT_DBG("chan %p", chan); - lock_sock(sk); + l2cap_chan_lock(chan); + if (chan->retry_count >= chan->remote_max_tx) { l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED); - release_sock(sk); + l2cap_chan_unlock(chan); return; } @@ -1292,25 +1320,26 @@ static void l2cap_monitor_timeout(struct work_struct *work) __set_monitor_timer(chan); l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); - release_sock(sk); + l2cap_chan_unlock(chan); } static void l2cap_retrans_timeout(struct work_struct *work) { struct l2cap_chan *chan = container_of(work, struct l2cap_chan, retrans_timer.work); - struct sock *sk = chan->sk; BT_DBG("chan %p", chan); - lock_sock(sk); + l2cap_chan_lock(chan); + chan->retry_count = 1; __set_monitor_timer(chan); set_bit(CONN_WAIT_F, &chan->conn_state); l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); - release_sock(sk); + + l2cap_chan_unlock(chan); } static void l2cap_drop_acked_frames(struct l2cap_chan *chan) @@ -2001,9 +2030,11 @@ static void l2cap_ack_timeout(struct work_struct *work) BT_DBG("chan %p", chan); - lock_sock(chan->sk); + l2cap_chan_lock(chan); + __l2cap_send_ack(chan); - release_sock(chan->sk); + + l2cap_chan_unlock(chan); l2cap_chan_put(chan); } @@ -2664,7 +2695,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd bt_accept_enqueue(parent, sk); - l2cap_chan_add(conn, chan); + __l2cap_chan_add(conn, chan); dcid = chan->scid; @@ -2737,7 +2768,6 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; u16 scid, dcid, result, status; struct l2cap_chan *chan; - struct sock *sk; u8 req[128]; int err; @@ -2767,8 +2797,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd err = 0; - sk = chan->sk; - lock_sock(sk); + l2cap_chan_lock(chan); switch (result) { case L2CAP_CR_SUCCESS: @@ -2794,7 +2823,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd break; } - release_sock(sk); + l2cap_chan_unlock(chan); unlock: mutex_unlock(&conn->chan_lock); @@ -2819,7 +2848,6 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr u16 dcid, flags; u8 rsp[64]; struct l2cap_chan *chan; - struct sock *sk; int len; dcid = __le16_to_cpu(req->dcid); @@ -2831,8 +2859,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr if (!chan) return -ENOENT; - sk = chan->sk; - lock_sock(sk); + l2cap_chan_lock(chan); if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) { struct l2cap_cmd_rej_cid rej; @@ -2921,7 +2948,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr } unlock: - release_sock(sk); + l2cap_chan_unlock(chan); return 0; } @@ -2930,7 +2957,6 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; u16 scid, flags, result; struct l2cap_chan *chan; - struct sock *sk; int len = cmd->len - sizeof(*rsp); scid = __le16_to_cpu(rsp->scid); @@ -2944,8 +2970,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr if (!chan) return 0; - sk = chan->sk; - lock_sock(sk); + l2cap_chan_lock(chan); switch (result) { case L2CAP_CONF_SUCCESS: @@ -3004,7 +3029,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr } default: - __l2cap_chan_set_err(chan, ECONNRESET); + l2cap_chan_set_err(chan, ECONNRESET); __set_chan_timer(chan, msecs_to_jiffies(L2CAP_DISC_REJ_TIMEOUT)); @@ -3031,7 +3056,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr } done: - release_sock(sk); + l2cap_chan_unlock(chan); return 0; } @@ -3056,17 +3081,21 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd return 0; } + l2cap_chan_lock(chan); + sk = chan->sk; - lock_sock(sk); rsp.dcid = cpu_to_le16(chan->scid); rsp.scid = cpu_to_le16(chan->dcid); l2cap_send_cmd(conn, cmd->ident, L2CAP_DISCONN_RSP, sizeof(rsp), &rsp); + lock_sock(sk); sk->sk_shutdown = SHUTDOWN_MASK; + release_sock(sk); l2cap_chan_del(chan, ECONNRESET); - release_sock(sk); + + l2cap_chan_unlock(chan); chan->ops->close(chan->data); @@ -3080,7 +3109,6 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; u16 dcid, scid; struct l2cap_chan *chan; - struct sock *sk; scid = __le16_to_cpu(rsp->scid); dcid = __le16_to_cpu(rsp->dcid); @@ -3095,11 +3123,11 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd return 0; } - sk = chan->sk; - lock_sock(sk); + l2cap_chan_lock(chan); l2cap_chan_del(chan, 0); - release_sock(sk); + + l2cap_chan_unlock(chan); chan->ops->close(chan->data); @@ -4251,7 +4279,6 @@ static int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk_buff *skb) { struct l2cap_chan *chan; - struct sock *sk = NULL; u32 control; u16 tx_seq; int len; @@ -4259,11 +4286,12 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk chan = l2cap_get_chan_by_scid(conn, cid); if (!chan) { BT_DBG("unknown cid 0x%4.4x", cid); - goto drop; + /* Drop packet and return */ + kfree(skb); + return 0; } - sk = chan->sk; - lock_sock(sk); + l2cap_chan_lock(chan); BT_DBG("chan %p, len %d", chan, skb->len); @@ -4334,8 +4362,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk kfree_skb(skb); done: - if (sk) - release_sock(sk); + l2cap_chan_unlock(chan); return 0; } @@ -4554,9 +4581,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) mutex_lock(&conn->chan_lock); list_for_each_entry(chan, &conn->chan_l, list) { - struct sock *sk = chan->sk; - - bh_lock_sock(sk); + l2cap_chan_lock(chan); BT_DBG("chan->scid %d", chan->scid); @@ -4566,19 +4591,19 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) l2cap_chan_ready(chan); } - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } if (test_bit(CONF_CONNECT_PEND, &chan->conf_state)) { - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } if (!status && (chan->state == BT_CONNECTED || chan->state == BT_CONFIG)) { l2cap_check_encryption(chan, encrypt); - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); continue; } @@ -4599,9 +4624,12 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) msecs_to_jiffies(L2CAP_DISC_TIMEOUT)); } } else if (chan->state == BT_CONNECT2) { + struct sock *sk = chan->sk; struct l2cap_conn_rsp rsp; __u16 res, stat; + lock_sock(sk); + if (!status) { if (bt_sk(sk)->defer_setup) { struct sock *parent = bt_sk(sk)->parent; @@ -4622,6 +4650,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) stat = L2CAP_CS_NO_INFO; } + release_sock(sk); + rsp.scid = cpu_to_le16(chan->dcid); rsp.dcid = cpu_to_le16(chan->scid); rsp.result = cpu_to_le16(res); @@ -4630,7 +4660,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) sizeof(rsp), &rsp); } - bh_unlock_sock(sk); + l2cap_chan_unlock(chan); } mutex_unlock(&conn->chan_lock); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 1273fcbeec28..73a06c1b0cd7 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -127,6 +127,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al if (err) goto done; + lock_sock(sk); + err = bt_sock_wait_state(sk, BT_CONNECTED, sock_sndtimeo(sk, flags & O_NONBLOCK)); done: @@ -810,14 +812,18 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) if (conn) mutex_lock(&conn->chan_lock); + l2cap_chan_lock(chan); lock_sock(sk); + if (!sk->sk_shutdown) { if (chan->mode == L2CAP_MODE_ERTM) err = __l2cap_wait_ack(sk); sk->sk_shutdown = SHUTDOWN_MASK; + release_sock(sk); l2cap_chan_close(chan, 0); + lock_sock(sk); if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) err = bt_sock_wait_state(sk, BT_CLOSED, @@ -828,6 +834,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) err = -sk->sk_err; release_sock(sk); + l2cap_chan_unlock(chan); if (conn) mutex_unlock(&conn->chan_lock); @@ -874,8 +881,12 @@ static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb) struct sock *sk = data; struct l2cap_pinfo *pi = l2cap_pi(sk); - if (pi->rx_busy_skb) - return -ENOMEM; + lock_sock(sk); + + if (pi->rx_busy_skb) { + err = -ENOMEM; + goto done; + } err = sock_queue_rcv_skb(sk, skb); @@ -894,6 +905,9 @@ static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb) err = 0; } +done: + release_sock(sk); + return err; } -- GitLab From b3fb611ec7b76048cb14600e9a5a9b57e5d913da Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 22 Feb 2012 17:11:57 +0200 Subject: [PATCH 1037/1846] Bluetooth: Remove socket lock check Simplify code so that we do not need to check whether socket is locked. Signed-off-by: Andrei Emeltchenko Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_sock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 73a06c1b0cd7..52c94c765779 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -125,15 +125,15 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al err = l2cap_chan_connect(chan, la.l2_psm, la.l2_cid, &la.l2_bdaddr); if (err) - goto done; + return err; lock_sock(sk); err = bt_sock_wait_state(sk, BT_CONNECTED, sock_sndtimeo(sk, flags & O_NONBLOCK)); -done: - if (sock_owned_by_user(sk)) - release_sock(sk); + + release_sock(sk); + return err; } -- GitLab From 60fc5fb66efa0bcbe028637206ed59df8cd4ac19 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 09:52:28 +0200 Subject: [PATCH 1038/1846] Bluetooth: mgmt: Fix count parameter in get_connections reply This patch fixes the count parameter in the Get Connections reply message. We cannot know the right number until iterating through all connections so set the parameter value only after the loop. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 42d665bdc01f..7fdba8fb9808 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1725,8 +1725,8 @@ static int get_connections(struct sock *sk, u16 index) struct hci_dev *hdev; struct hci_conn *c; size_t rp_len; - u16 count; - int i, err; + int err; + u16 i; BT_DBG(""); @@ -1743,21 +1743,19 @@ static int get_connections(struct sock *sk, u16 index) goto unlock; } - count = 0; + i = 0; list_for_each_entry(c, &hdev->conn_hash.list, list) { if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) - count++; + i++; } - rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info)); + rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); rp = kmalloc(rp_len, GFP_ATOMIC); if (!rp) { err = -ENOMEM; goto unlock; } - put_unaligned_le16(count, &rp->conn_count); - i = 0; list_for_each_entry(c, &hdev->conn_hash.list, list) { if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) @@ -1769,6 +1767,8 @@ static int get_connections(struct sock *sk, u16 index) i++; } + put_unaligned_le16(i, &rp->conn_count); + /* Recalculate length in case of filtered SCO connections, etc */ rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); -- GitLab From 69775ff6d101ccf435bd26ae822c24bbb20e11cf Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Thu, 23 Feb 2012 16:50:05 +0200 Subject: [PATCH 1039/1846] Bluetooth: Set DISCOVERY_STOPPED if controller resets If controller is reset during the discovery procedure, Start Discovery command stops working. This can be easily reproduced by running "hciconfig hci0 reset" while discovering devices, for instance. We should force discovery state to DISCOVERY_STOPPED in case we receive a reset command complete event. Otherwise we may stuck in one of the active discovery states (DISCOVERY_INQUIRY, DISCOVERY_LE_SCAN and DISCOVERY_RESOLVING) and subsequent Start Discovery commands will simply fail. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 276f3ac06089..3d1eef0df2a3 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -194,6 +194,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) /* Reset all non-persistent flags */ hdev->dev_flags &= ~(BIT(HCI_LE_SCAN)); + + hdev->discovery.state = DISCOVERY_STOPPED; } static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From 504c8dcd6b0ec3cd36ab221695c5516e88cf3d79 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 13:30:41 +0200 Subject: [PATCH 1040/1846] Bluetooth: mgmt: Fix update_eir/class with HCI_AUTO_OFF flag set If we're powered but still have the HCI_AUTO_OFF flag set the update_eir and update_class functions should not do anything. Additionally these functions need to be called when the flag is finally cleared through set_powered or when powering on for real. Signed-off-by: Johan Hedberg Acked-by: Gustavo F. Padovan Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 7fdba8fb9808..4e4889490635 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -532,7 +532,7 @@ static int update_eir(struct hci_dev *hdev) { struct hci_cp_write_eir cp; - if (!test_bit(HCI_UP, &hdev->flags)) + if (!hdev_is_powered(hdev)) return 0; if (!(hdev->features[6] & LMP_EXT_INQ)) @@ -573,7 +573,7 @@ static int update_class(struct hci_dev *hdev) BT_DBG("%s", hdev->name); - if (!test_bit(HCI_UP, &hdev->flags)) + if (!hdev_is_powered(hdev)) return 0; if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) @@ -3121,6 +3121,9 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) if (scan) hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); + + update_class(hdev); + update_eir(hdev); } else { u8 status = ENETDOWN; mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); -- GitLab From 9997a5332320dbaaee64b5c0581ccaa6589a15c9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 15:57:46 +0200 Subject: [PATCH 1041/1846] Bluetooth: mgmt: Fix return value of add/remove_uuid The Add/Remove UUID commands should return the device class instead of an empty parameter list. Signed-off-by: Johan Hedberg Acked-by: Gustavo F. Padovan Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4e4889490635..000abc07bc1e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1367,7 +1367,7 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto failed; - err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, 0, NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, 0, hdev->dev_class, 3); failed: hci_dev_unlock(hdev); @@ -1428,7 +1428,8 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto unlock; - err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, NULL, 0); + err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, + hdev->dev_class, 3); unlock: hci_dev_unlock(hdev); -- GitLab From 4004b6d96a14edbd157a62ae25bf61022d7caccc Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 21:30:12 +0200 Subject: [PATCH 1042/1846] Bluetooth: mgmt: Move service cache setting to a more sensible place Since we can now add UUIDs when powered off we don't really need to always use the service cache to avoid large bursts of HCI commands. Instead, the only important use case is when we're already powered and user space starts to initialize itself. This can be easiest detected by a "clear UUIDs" operation which is where this patch moves the service cache setting. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 000abc07bc1e..30a30b7b301c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -617,10 +617,6 @@ static void mgmt_init_hdev(struct hci_dev *hdev) */ clear_bit(HCI_PAIRABLE, &hdev->dev_flags); } - - if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) - schedule_delayed_work(&hdev->service_cache, - msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); } static int read_controller_info(struct sock *sk, u16 index) @@ -1399,6 +1395,12 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) { err = hci_uuids_clear(hdev); + + if (hdev_is_powered(hdev) && + !test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) + schedule_delayed_work(&hdev->service_cache, + msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); + goto unlock; } -- GitLab From 9246a8693e74b3480913cf6e0c2d472267169990 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 21:33:16 +0200 Subject: [PATCH 1043/1846] Bluetooth: mgmt: Fix clear UUIDs response We also need to send a proper response when clearing UUIDs. This patch adds fixes the missing response for this use case. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 30a30b7b301c..93f2c1348add 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1401,7 +1401,7 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) schedule_delayed_work(&hdev->service_cache, msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); - goto unlock; + goto update_class; } found = 0; @@ -1422,6 +1422,7 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) goto unlock; } +update_class: err = update_class(hdev); if (err < 0) goto unlock; -- GitLab From 08c79b6133b70a6e3d462d11a89c80259ac66ec7 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 22:31:51 +0200 Subject: [PATCH 1044/1846] Bluetooth: mgmt: Add flags parameter to device_connected This patch updates the Device Connected events to match the latest API by adding a flags parameter to them. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 4 ++-- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/hci_event.c | 8 ++++---- net/bluetooth/mgmt.c | 6 ++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 720bdc26b7e9..facd7ed32b74 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -980,8 +980,8 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent); int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 *name, u8 name_len, - u8 *dev_class); + u8 addr_type, u32 flags, u8 *name, + u8 name_len, u8 *dev_class); int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, u8 addr_type); int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 09646f5ef36a..7aab53e6b813 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -357,6 +357,7 @@ struct mgmt_ev_new_long_term_key { #define MGMT_EV_DEVICE_CONNECTED 0x000B struct mgmt_ev_device_connected { struct mgmt_addr_info addr; + __le32 flags; __le16 eir_len; __u8 eir[0]; } __packed; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 3d1eef0df2a3..fb6543b60dec 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1368,7 +1368,7 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, struct inquiry_entry *e; if (conn && !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) - mgmt_device_connected(hdev, bdaddr, ACL_LINK, 0x00, + mgmt_device_connected(hdev, bdaddr, ACL_LINK, 0x00, 0, name, name_len, conn->dev_class); if (discov->state == DISCOVERY_STOPPED) @@ -2104,7 +2104,7 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &conn->dst, conn->type, - conn->dst_type, NULL, 0, + conn->dst_type, 0, NULL, 0, conn->dev_class); if (!hci_outgoing_auth_needed(hdev, conn)) { @@ -2872,7 +2872,7 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &conn->dst, conn->type, - conn->dst_type, NULL, 0, + conn->dst_type, 0, NULL, 0, conn->dev_class); if (!hci_outgoing_auth_needed(hdev, conn)) { @@ -3282,7 +3282,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &ev->bdaddr, conn->type, - conn->dst_type, NULL, 0, 0); + conn->dst_type, 0, NULL, 0, 0); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 93f2c1348add..79fe57573463 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3249,8 +3249,8 @@ int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent) } int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 *name, u8 name_len, - u8 *dev_class) + u8 addr_type, u32 flags, u8 *name, + u8 name_len, u8 *dev_class) { char buf[512]; struct mgmt_ev_device_connected *ev = (void *) buf; @@ -3259,6 +3259,8 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, bacpy(&ev->addr.bdaddr, bdaddr); ev->addr.type = link_to_mgmt(link_type, addr_type); + put_unaligned_le32(flags, &ev->flags); + if (name_len > 0) eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name, name_len); -- GitLab From 504f9b5a6bb5336ad434438d0cdd61a16db80129 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Tue, 21 Feb 2012 02:07:49 +0000 Subject: [PATCH 1045/1846] ethernet: unify return value of .ndo_set_mac_address if address is invalid Unify return value of .ndo_set_mac_address if the given address isn't valid. Return -EADDRNOTAVAIL as eth_mac_addr() already does if is_valid_ether_addr() fails. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/aeroflex/greth.c | 2 +- drivers/net/ethernet/broadcom/bnx2.c | 2 +- drivers/net/ethernet/broadcom/tg3.c | 2 +- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 2 +- drivers/net/ethernet/dlink/sundance.c | 2 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- drivers/net/ethernet/marvell/pxa168_eth.c | 2 +- drivers/net/ethernet/neterion/s2io.c | 2 +- drivers/net/ethernet/pasemi/pasemi_mac.c | 2 +- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- drivers/net/ethernet/sfc/efx.c | 2 +- drivers/net/ethernet/sun/niu.c | 2 +- drivers/net/ethernet/ti/davinci_emac.c | 2 +- drivers/net/ethernet/tile/tilepro.c | 2 +- drivers/net/ethernet/tundra/tsi108_eth.c | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c index cfa13481e5f2..348501178089 100644 --- a/drivers/net/ethernet/aeroflex/greth.c +++ b/drivers/net/ethernet/aeroflex/greth.c @@ -1017,7 +1017,7 @@ static int greth_set_mac_add(struct net_device *dev, void *p) regs = (struct greth_regs *) greth->regs; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); GRETH_REGSAVE(regs->esa_msb, dev->dev_addr[0] << 8 | dev->dev_addr[1]); diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 7105989ba658..8297e2868736 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -7773,7 +7773,7 @@ bnx2_change_mac_addr(struct net_device *dev, void *p) struct bnx2 *bp = netdev_priv(dev); if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); if (netif_running(dev)) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index ec5bc3d04333..97dcccdb9eb2 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -8045,7 +8045,7 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p) int err = 0, skip_mac_1 = 0; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c index 857cc254cab8..63bfdd10bd6d 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c @@ -2499,7 +2499,7 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p) struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); t3_mac_set_address(&pi->mac, LAN_MAC_IDX, dev->dev_addr); diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index e83d12c7bf20..1d889427073f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -2809,7 +2809,7 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p) struct port_info *pi = netdev_priv(dev); if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; ret = t4_change_mac(pi->adapter, pi->adapter->fn, pi->viid, pi->xact_addr_filt, addr->sa_data, true, true); diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index 9045a451d4a9..3f580c0c28a6 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -1130,7 +1130,7 @@ static int cxgb4vf_set_mac_addr(struct net_device *dev, void *_addr) struct port_info *pi = netdev_priv(dev); if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; ret = t4vf_change_mac(pi->adapter, pi->viid, pi->xact_addr_filt, addr->sa_data, true); diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c index 7227f29ee2ee..d783f4f96ec0 100644 --- a/drivers/net/ethernet/dlink/sundance.c +++ b/drivers/net/ethernet/dlink/sundance.c @@ -1601,7 +1601,7 @@ static int sundance_set_mac_addr(struct net_device *dev, void *data) const struct sockaddr *addr = data; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); __set_mac_addr(dev); diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index f702d0dc18c7..75af1afe46c8 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -1832,7 +1832,7 @@ static int mv643xx_eth_set_mac_address(struct net_device *dev, void *addr) struct sockaddr *sa = addr; if (!is_valid_ether_addr(sa->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 83e37ad113e0..3a7df0593c68 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -627,7 +627,7 @@ static int pxa168_eth_set_mac_address(struct net_device *dev, void *addr) unsigned char oldMac[ETH_ALEN]; if (!is_valid_ether_addr(sa->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(oldMac, dev->dev_addr, ETH_ALEN); dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, sa->sa_data, ETH_ALEN); diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c index 44a6065794c3..22a8de00bf02 100644 --- a/drivers/net/ethernet/neterion/s2io.c +++ b/drivers/net/ethernet/neterion/s2io.c @@ -5248,7 +5248,7 @@ static int s2io_set_mac_addr(struct net_device *dev, void *p) struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 667498ea4603..ddc95b0ac78d 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c @@ -238,7 +238,7 @@ static int pasemi_mac_set_mac_addr(struct net_device *dev, void *p) unsigned int adr0, adr1; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 8dc4a134dece..7648995ea720 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -518,7 +518,7 @@ static int netxen_nic_set_mac(struct net_device *netdev, void *p) struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; if (netif_running(netdev)) { netif_device_detach(netdev); diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index dba95311a462..81bb1a69e69f 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -301,7 +301,7 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p) return -EOPNOTSUPP; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) { netif_device_detach(netdev); diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index c7004dcb5838..1908ba7ca7e6 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1935,7 +1935,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) netif_err(efx, drv, efx->net_dev, "invalid ethernet MAC address requested: %pM\n", new_addr); - return -EINVAL; + return -EADDRNOTAVAIL; } memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len); diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index d83c50816714..c99b3b0e2eae 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -6412,7 +6412,7 @@ static int niu_set_mac_addr(struct net_device *dev, void *p) unsigned long flags; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index f053aebbaa06..6d74cb7aaae8 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1254,7 +1254,7 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr) struct sockaddr *sa = addr; if (!is_valid_ether_addr(sa->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; /* Store mac addr in priv and rx channel and set it in EMAC hw */ memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len); diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c index 948c4f2a2d67..261356c2dc99 100644 --- a/drivers/net/ethernet/tile/tilepro.c +++ b/drivers/net/ethernet/tile/tilepro.c @@ -2186,7 +2186,7 @@ static int tile_net_set_mac_address(struct net_device *dev, void *p) struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; /* ISSUE: Note that "dev_addr" is now a pointer. */ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c index fc5521c9c089..840e0e9031f5 100644 --- a/drivers/net/ethernet/tundra/tsi108_eth.c +++ b/drivers/net/ethernet/tundra/tsi108_eth.c @@ -1148,7 +1148,7 @@ static int tsi108_set_mac(struct net_device *dev, void *addr) int i; if (!is_valid_ether_addr(addr)) - return -EINVAL; + return -EADDRNOTAVAIL; for (i = 0; i < 6; i++) /* +2 is for the offset of the HW addr type */ -- GitLab From 15b8f4cf8ea6654c5642358c70b6e84909d99038 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Tue, 21 Feb 2012 02:07:50 +0000 Subject: [PATCH 1046/1846] mcs7830: unify return value of .ndo_set_mac_address if address is invalid Unify return value of .ndo_set_mac_address if the given address isn't valid. Return -EADDRNOTAVAIL as eth_mac_addr() already does if is_valid_ether_addr() fails. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/usb/mcs7830.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c index a29aa9cf9f6e..c434b6ba0337 100644 --- a/drivers/net/usb/mcs7830.c +++ b/drivers/net/usb/mcs7830.c @@ -239,7 +239,7 @@ static int mcs7830_set_mac_address(struct net_device *netdev, void *p) return -EBUSY; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; ret = mcs7830_hif_set_mac_address(dev, addr->sa_data); -- GitLab From 7ca1e11ab7d83ec76f3a8ef8704adca8c7518f41 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Tue, 21 Feb 2012 02:07:52 +0000 Subject: [PATCH 1047/1846] br_device: unify return value of .ndo_set_mac_address if address is invalid Unify return value of .ndo_set_mac_address if the given address isn't valid. Return -EADDRNOTAVAIL as eth_mac_addr() already does if is_valid_ether_addr() fails. Signed-off-by: Danny Kukawka Acked-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index a157bf827d87..ba829de84423 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -167,7 +167,7 @@ static int br_set_mac_address(struct net_device *dev, void *p) struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; spin_lock_bh(&br->lock); if (compare_ether_addr(dev->dev_addr, addr->sa_data)) { -- GitLab From 8abe6fb51ebd1d16c93d4435a808e056113f3510 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Thu, 23 Feb 2012 17:11:39 -0500 Subject: [PATCH 1048/1846] Staging: et131x: unify return value of .ndo_set_mac_address if address is invalid Unify return value of .ndo_set_mac_address if the given address isn't valid. Return -EADDRNOTAVAIL as eth_mac_addr() already does if is_valid_ether_addr() fails. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/staging/et131x/et131x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 2c4069fcd981..b055731f8d88 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -5177,7 +5177,7 @@ static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) /* Make sure the requested MAC is valid */ if (!is_valid_ether_addr(address->sa_data)) - return -EINVAL; + return -EADDRNOTAVAIL; et131x_disable_txrx(netdev); et131x_handle_send_interrupt(adapter); -- GitLab From c95f0ba76f902bc8b540468b695bcfe8948e8e46 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 22:54:38 +0200 Subject: [PATCH 1049/1846] Bluetooth: mgmt: Track pending class changes This patch adds a flag to track pending changes to the class of device. This is needed since we cannot cleanly handle multiple simultaneous commands and need to return a "busy" error status in the mgmt commands that might trigger a class change. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 1 + net/bluetooth/mgmt.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c97cf0872ac9..05bd9aca4054 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -100,6 +100,7 @@ enum { HCI_CONNECTABLE, HCI_DISCOVERABLE, HCI_LINK_SECURITY, + HCI_PENDING_CLASS, }; /* HCI ioctl defines */ diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 79fe57573463..9f912dc71bae 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -570,6 +570,7 @@ static u8 get_service_classes(struct hci_dev *hdev) static int update_class(struct hci_dev *hdev) { u8 cod[3]; + int err; BT_DBG("%s", hdev->name); @@ -586,7 +587,11 @@ static int update_class(struct hci_dev *hdev) if (memcmp(cod, hdev->dev_class, 3) == 0) return 0; - return hci_send_cmd(hdev, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod); + err = hci_send_cmd(hdev, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod); + if (err == 0) + set_bit(HCI_PENDING_CLASS, &hdev->dev_flags); + + return err; } static void service_cache_off(struct work_struct *work) @@ -1344,6 +1349,12 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { + err = cmd_status(sk, index, MGMT_OP_ADD_UUID, + MGMT_STATUS_BUSY); + goto failed; + } + uuid = kmalloc(sizeof(*uuid), GFP_ATOMIC); if (!uuid) { err = -ENOMEM; @@ -1393,6 +1404,12 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { + err = cmd_status(sk, index, MGMT_OP_REMOVE_UUID, + MGMT_STATUS_BUSY); + goto unlock; + } + if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) { err = hci_uuids_clear(hdev); @@ -1460,6 +1477,12 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) hci_dev_lock(hdev); + if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { + err = cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, + MGMT_STATUS_BUSY); + goto unlock; + } + hdev->major_class = cp->major; hdev->minor_class = cp->minor; @@ -3259,7 +3282,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, bacpy(&ev->addr.bdaddr, bdaddr); ev->addr.type = link_to_mgmt(link_type, addr_type); - put_unaligned_le32(flags, &ev->flags); + ev->flags = __cpu_to_le32(flags); if (name_len > 0) eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, @@ -3614,6 +3637,8 @@ int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, { int err; + clear_bit(HCI_PENDING_CLASS, &hdev->dev_flags); + err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class, 3, NULL); return err; -- GitLab From 90e704543d6702971ecfe3fe2325829d89b76f6b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 23:09:40 +0200 Subject: [PATCH 1050/1846] Bluetooth: mgmt: Fix dev_class related command response timing All mgmt commands that may fire off a hci_write_class_of_device command should wait for the completion of the HCI command before sending a response to user space. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 70 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9f912dc71bae..7a906d6e0236 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1332,6 +1332,7 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_add_uuid *cp = data; + struct pending_cmd *cmd; struct hci_dev *hdev; struct bt_uuid *uuid; int err; @@ -1374,7 +1375,17 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto failed; - err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, 0, hdev->dev_class, 3); + if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { + err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, 0, + hdev->dev_class, 3); + goto failed; + } + + cmd = mgmt_pending_add(sk, MGMT_OP_ADD_UUID, hdev, data, len); + if (!cmd) { + err = -ENOMEM; + goto failed; + } failed: hci_dev_unlock(hdev); @@ -1386,6 +1397,7 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_remove_uuid *cp = data; + struct pending_cmd *cmd; struct list_head *p, *n; struct hci_dev *hdev; u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1448,8 +1460,17 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) if (err < 0) goto unlock; - err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, + if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { + err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, hdev->dev_class, 3); + goto unlock; + } + + cmd = mgmt_pending_add(sk, MGMT_OP_REMOVE_UUID, hdev, data, len); + if (!cmd) { + err = -ENOMEM; + goto unlock; + } unlock: hci_dev_unlock(hdev); @@ -1462,6 +1483,7 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) { struct hci_dev *hdev; struct mgmt_cp_set_dev_class *cp = data; + struct pending_cmd *cmd; int err; BT_DBG("request for hci%u", index); @@ -1500,10 +1522,20 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) } err = update_class(hdev); + if (err < 0) + goto unlock; - if (err == 0) + if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, hdev->dev_class, 3); + goto unlock; + } + + cmd = mgmt_pending_add(sk, MGMT_OP_SET_DEV_CLASS, hdev, data, len); + if (!cmd) { + err = -ENOMEM; + goto unlock; + } unlock: hci_dev_unlock(hdev); @@ -3110,6 +3142,7 @@ int mgmt_index_removed(struct hci_dev *hdev) struct cmd_lookup { struct sock *sk; struct hci_dev *hdev; + u8 mgmt_status; }; static void settings_rsp(struct pending_cmd *cmd, void *data) @@ -3632,14 +3665,41 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) return err; } +static void class_rsp(struct pending_cmd *cmd, void *data) +{ + struct cmd_lookup *match = data; + + cmd_complete(cmd->sk, cmd->index, cmd->opcode, match->mgmt_status, + match->hdev->dev_class, 3); + + list_del(&cmd->list); + + if (match->sk == NULL) { + match->sk = cmd->sk; + sock_hold(match->sk); + } + + mgmt_pending_free(cmd); +} + int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, u8 status) { - int err; + struct cmd_lookup match = { NULL, hdev, mgmt_status(status) }; + int err = 0; clear_bit(HCI_PENDING_CLASS, &hdev->dev_flags); - err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class, 3, NULL); + mgmt_pending_foreach(MGMT_OP_SET_DEV_CLASS, hdev, class_rsp, &match); + mgmt_pending_foreach(MGMT_OP_ADD_UUID, hdev, class_rsp, &match); + mgmt_pending_foreach(MGMT_OP_REMOVE_UUID, hdev, class_rsp, &match); + + if (!status) + err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, + dev_class, 3, NULL); + + if (match.sk) + sock_put(match.sk); return err; } -- GitLab From 24b78d0f49b94f658e8bae707c158962535053dd Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 23 Feb 2012 23:24:30 +0200 Subject: [PATCH 1051/1846] Bluetooth: mgmt: Fix clear_uuids response Since the clear_uuids operation doesn't send an immediate HCI command but just sets off a timer to wait for subsequent add_uuid calls it doesn't make sense to wait until the timer fires off to send the response. Instead send the response immediately. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 7a906d6e0236..07e31f73f703 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1394,6 +1394,20 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) return err; } +static bool enable_service_cache(struct hci_dev *hdev) +{ + if (!hdev_is_powered(hdev)) + return false; + + if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) { + schedule_delayed_work(&hdev->service_cache, + msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); + return true; + } + + return false; +} + static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) { struct mgmt_cp_remove_uuid *cp = data; @@ -1425,10 +1439,11 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) { err = hci_uuids_clear(hdev); - if (hdev_is_powered(hdev) && - !test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) - schedule_delayed_work(&hdev->service_cache, - msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); + if (enable_service_cache(hdev)) { + err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, + hdev->dev_class, 3); + goto unlock; + } goto update_class; } -- GitLab From 191eb7563164529bc7d6a693742fe5bed33cf004 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 23 Feb 2012 18:50:13 +0000 Subject: [PATCH 1052/1846] be2net: cancel be_worker during EEH recovery EEH recovery involves ring cleanup and re-creation. The worker thread must not run during EEH cleanup/resume. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 1 + drivers/net/ethernet/emulex/benet/be_main.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 86f51dea0c39..4b1994dcf3c7 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -304,6 +304,7 @@ struct be_vf_cfg { }; #define BE_FLAGS_LINK_STATUS_INIT 1 +#define BE_FLAGS_WORKER_SCHEDULED (1 << 3) struct be_adapter { struct pci_dev *pdev; diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 28f2b254d227..68408d5bb0d7 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -2447,6 +2447,11 @@ static void be_vf_clear(struct be_adapter *adapter) static int be_clear(struct be_adapter *adapter) { + if (adapter->flags & BE_FLAGS_WORKER_SCHEDULED) { + cancel_delayed_work_sync(&adapter->work); + adapter->flags &= ~BE_FLAGS_WORKER_SCHEDULED; + } + if (sriov_enabled(adapter)) be_vf_clear(adapter); @@ -2648,6 +2653,9 @@ static int be_setup(struct be_adapter *adapter) goto err; } + schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); + adapter->flags |= BE_FLAGS_WORKER_SCHEDULED; + return 0; err: be_clear(adapter); @@ -3208,8 +3216,6 @@ static void __devexit be_remove(struct pci_dev *pdev) if (!adapter) return; - cancel_delayed_work_sync(&adapter->work); - unregister_netdev(adapter->netdev); be_clear(adapter); @@ -3533,7 +3539,6 @@ static int __devinit be_probe(struct pci_dev *pdev, dev_info(&pdev->dev, "%s: %s port %d\n", netdev->name, nic_name(pdev), adapter->port_num); - schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); return 0; unsetup: @@ -3563,7 +3568,6 @@ static int be_suspend(struct pci_dev *pdev, pm_message_t state) struct be_adapter *adapter = pci_get_drvdata(pdev); struct net_device *netdev = adapter->netdev; - cancel_delayed_work_sync(&adapter->work); if (adapter->wol) be_setup_wol(adapter, true); @@ -3612,7 +3616,6 @@ static int be_resume(struct pci_dev *pdev) if (adapter->wol) be_setup_wol(adapter, false); - schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); return 0; } -- GitLab From 0ae57bb3df562e57ac89ad7bc524b6f2e83235f9 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 23 Feb 2012 18:50:14 +0000 Subject: [PATCH 1053/1846] be2net: fix tx completion cleanup As a part of be_close(), instead of waiting for a max of 200ms for each TXQ, wait for a total of 200ms for completions from all TXQs to arrive. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_main.c | 75 ++++++++++++--------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 68408d5bb0d7..36ad9a7ef4ba 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -1563,51 +1563,62 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo) rxq->tail = rxq->head = 0; } -static void be_tx_compl_clean(struct be_adapter *adapter, - struct be_tx_obj *txo) +static void be_tx_compl_clean(struct be_adapter *adapter) { - struct be_queue_info *tx_cq = &txo->cq; - struct be_queue_info *txq = &txo->q; + struct be_tx_obj *txo; + struct be_queue_info *txq; struct be_eth_tx_compl *txcp; u16 end_idx, cmpl = 0, timeo = 0, num_wrbs = 0; - struct sk_buff **sent_skbs = txo->sent_skb_list; struct sk_buff *sent_skb; bool dummy_wrb; + int i, pending_txqs; /* Wait for a max of 200ms for all the tx-completions to arrive. */ do { - while ((txcp = be_tx_compl_get(tx_cq))) { - end_idx = AMAP_GET_BITS(struct amap_eth_tx_compl, - wrb_index, txcp); - num_wrbs += be_tx_compl_process(adapter, txo, end_idx); - cmpl++; - } - if (cmpl) { - be_cq_notify(adapter, tx_cq->id, false, cmpl); - atomic_sub(num_wrbs, &txq->used); - cmpl = 0; - num_wrbs = 0; + pending_txqs = adapter->num_tx_qs; + + for_all_tx_queues(adapter, txo, i) { + txq = &txo->q; + while ((txcp = be_tx_compl_get(&txo->cq))) { + end_idx = + AMAP_GET_BITS(struct amap_eth_tx_compl, + wrb_index, txcp); + num_wrbs += be_tx_compl_process(adapter, txo, + end_idx); + cmpl++; + } + if (cmpl) { + be_cq_notify(adapter, txo->cq.id, false, cmpl); + atomic_sub(num_wrbs, &txq->used); + cmpl = 0; + num_wrbs = 0; + } + if (atomic_read(&txq->used) == 0) + pending_txqs--; } - if (atomic_read(&txq->used) == 0 || ++timeo > 200) + if (pending_txqs == 0 || ++timeo > 200) break; mdelay(1); } while (true); - if (atomic_read(&txq->used)) - dev_err(&adapter->pdev->dev, "%d pending tx-completions\n", - atomic_read(&txq->used)); - - /* free posted tx for which compls will never arrive */ - while (atomic_read(&txq->used)) { - sent_skb = sent_skbs[txq->tail]; - end_idx = txq->tail; - index_adv(&end_idx, - wrb_cnt_for_skb(adapter, sent_skb, &dummy_wrb) - 1, - txq->len); - num_wrbs = be_tx_compl_process(adapter, txo, end_idx); - atomic_sub(num_wrbs, &txq->used); + for_all_tx_queues(adapter, txo, i) { + txq = &txo->q; + if (atomic_read(&txq->used)) + dev_err(&adapter->pdev->dev, "%d pending tx-compls\n", + atomic_read(&txq->used)); + + /* free posted tx for which compls will never arrive */ + while (atomic_read(&txq->used)) { + sent_skb = txo->sent_skb_list[txq->tail]; + end_idx = txq->tail; + num_wrbs = wrb_cnt_for_skb(adapter, sent_skb, + &dummy_wrb); + index_adv(&end_idx, num_wrbs - 1, txq->len); + num_wrbs = be_tx_compl_process(adapter, txo, end_idx); + atomic_sub(num_wrbs, &txq->used); + } } } @@ -2236,7 +2247,6 @@ static void be_rx_qs_destroy(struct be_adapter *adapter) static int be_close(struct net_device *netdev) { struct be_adapter *adapter = netdev_priv(netdev); - struct be_tx_obj *txo; struct be_eq_obj *eqo; int i; @@ -2259,8 +2269,7 @@ static int be_close(struct net_device *netdev) /* Wait for all pending tx completions to arrive so that * all tx skbs are freed. */ - for_all_tx_queues(adapter, txo, i) - be_tx_compl_clean(adapter, txo); + be_tx_compl_clean(adapter); be_rx_qs_destroy(adapter); return 0; -- GitLab From 1cfafab965198bc0d9cb794af5065d0797969727 Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 23 Feb 2012 18:50:15 +0000 Subject: [PATCH 1054/1846] be2net: reset queue address after freeing This will prevent double free in some cases where be_clear() is called for cleanup when be_setup() fails half-way. Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 36ad9a7ef4ba..e3822788f532 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -127,9 +127,11 @@ static inline bool be_is_mc(struct be_adapter *adapter) { static void be_queue_free(struct be_adapter *adapter, struct be_queue_info *q) { struct be_dma_mem *mem = &q->dma_mem; - if (mem->va) + if (mem->va) { dma_free_coherent(&adapter->pdev->dev, mem->size, mem->va, mem->dma); + mem->va = NULL; + } } static int be_queue_alloc(struct be_adapter *adapter, struct be_queue_info *q, @@ -1660,7 +1662,7 @@ static int be_evt_queues_create(struct be_adapter *adapter) if (rc) return rc; } - return rc; + return 0; } static void be_mcc_queues_destroy(struct be_adapter *adapter) -- GitLab From 1ca7ba921e8af04266881bc485be08d4fac5f1bc Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 23 Feb 2012 18:50:16 +0000 Subject: [PATCH 1055/1846] be2net: enable RSS for ipv6 pkts Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_cmds.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 6432efa7b9cb..398fb5ca0fe2 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -1694,7 +1694,8 @@ int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, u16 table_size) OPCODE_ETH_RSS_CONFIG, sizeof(*req), wrb, NULL); req->if_id = cpu_to_le32(adapter->if_handle); - req->enable_rss = cpu_to_le16(RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4); + req->enable_rss = cpu_to_le16(RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4 | + RSS_ENABLE_TCP_IPV6 | RSS_ENABLE_IPV6); req->cpu_table_size_log2 = cpu_to_le16(fls(table_size) - 1); memcpy(req->cpu_table, rsstable, table_size); memcpy(req->hash, myhash, sizeof(myhash)); -- GitLab From d708f6039b21ca8f0508ba1da1aaf3d00a36446f Mon Sep 17 00:00:00 2001 From: Sathya Perla Date: Thu, 23 Feb 2012 18:50:17 +0000 Subject: [PATCH 1056/1846] be2net: update driver version Signed-off-by: Sathya Perla Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 4b1994dcf3c7..c357172d0543 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -33,7 +33,7 @@ #include "be_hw.h" -#define DRV_VER "4.0.100u" +#define DRV_VER "4.2.116u" #define DRV_NAME "be2net" #define BE_NAME "ServerEngines BladeEngine2 10Gbps NIC" #define BE3_NAME "ServerEngines BladeEngine3 10Gbps NIC" -- GitLab From b4ad0428139491355ea8742294c77942c312c5bb Mon Sep 17 00:00:00 2001 From: Christian Riesch Date: Wed, 22 Feb 2012 21:58:00 +0000 Subject: [PATCH 1057/1846] davinci_cpdma: Fix channel number written to teardown registers chan->chan_num is 0..CPDMA_MAX_CHANNELS-1 for tx channels and CPDMA_MAX_CHANNELS..2*CPDMA_MAX_CHANNELS-1 for rx channels. However, the rx and tx teardown registers expect zero based channel numbering. Since the upper bits of the registers are reserved, the teardown also worked before, this patch is cleanup only. Signed-off-by: Christian Riesch Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/davinci_cpdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index c97d2f590855..34558766cbf0 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -822,7 +822,7 @@ int cpdma_chan_stop(struct cpdma_chan *chan) dma_reg_write(ctlr, chan->int_clear, chan->mask); /* trigger teardown */ - dma_reg_write(ctlr, chan->td, chan->chan_num); + dma_reg_write(ctlr, chan->td, chan_linear(chan)); /* wait for teardown complete */ timeout = jiffies + HZ/10; /* 100 msec */ -- GitLab From 7c3a95a15ad2a5278498a72df0463131048926a3 Mon Sep 17 00:00:00 2001 From: Christian Riesch Date: Wed, 22 Feb 2012 22:07:58 +0000 Subject: [PATCH 1058/1846] davinci_mdio: Correct bitmask for clock divider value The CLKDIV bitfield in the MDIO Control Register is a 16 bit field, therefore the CLKDIV value may range from 0 to 0xffff. Signed-off-by: Christian Riesch Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/davinci_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index af8b8fc39eb2..2757c7d6e633 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -53,7 +53,7 @@ struct davinci_mdio_regs { u32 control; #define CONTROL_IDLE BIT(31) #define CONTROL_ENABLE BIT(30) -#define CONTROL_MAX_DIV (0xff) +#define CONTROL_MAX_DIV (0xffff) u32 alive; u32 link; -- GitLab From 36eabda3d094dae30a74350c6289c163349b744d Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:14 +0000 Subject: [PATCH 1059/1846] net: Support RXFCS feature flag. When set on hardware that supports the feature, this causes the Ethernet FCS to be appended to the end of the skb. Useful for sniffing packets. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- Documentation/networking/netdev-features.txt | 6 ++++++ include/linux/netdev_features.h | 2 ++ net/core/ethtool.c | 1 + 3 files changed, 9 insertions(+) diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt index 4b1c0dcef84c..7d2781230d30 100644 --- a/Documentation/networking/netdev-features.txt +++ b/Documentation/networking/netdev-features.txt @@ -152,3 +152,9 @@ NETIF_F_VLAN_CHALLENGED should be set for devices which can't cope with VLAN headers. Some drivers set this because the cards can't handle the bigger MTU. [FIXME: Those cases could be fixed in VLAN code by allowing only reduced-MTU VLANs. This may be not useful, though.] + +* rx-fcs + +This requests that the NIC append the Ethernet Frame Checksum (FCS) +to the end of the skb data. This allows sniffers and other tools to +read the CRC recorded by the NIC on receipt of the packet. diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index 77f5202977ce..d1331865f830 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h @@ -54,6 +54,7 @@ enum { NETIF_F_RXCSUM_BIT, /* Receive checksumming offload */ NETIF_F_NOCACHE_COPY_BIT, /* Use no-cache copyfromuser */ NETIF_F_LOOPBACK_BIT, /* Enable loopback */ + NETIF_F_RXFCS_BIT, /* Append FCS to skb pkt data */ /* * Add your fresh new feature above and remember to update @@ -98,6 +99,7 @@ enum { #define NETIF_F_TSO __NETIF_F(TSO) #define NETIF_F_UFO __NETIF_F(UFO) #define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED) +#define NETIF_F_RXFCS __NETIF_F(RXFCS) /* Features valid for ethtool to change */ /* = all defined minus driver/device-class-related */ diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 3f79db1b612a..080161924a0d 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -73,6 +73,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] [NETIF_F_RXCSUM_BIT] = "rx-checksum", [NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy", [NETIF_F_LOOPBACK_BIT] = "loopback", + [NETIF_F_RXFCS_BIT] = "rx-fcs", }; static int ethtool_get_features(struct net_device *dev, void __user *useraddr) -- GitLab From 0184039a4b6727d6efd545919c773ef141090ae7 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:25 +0000 Subject: [PATCH 1060/1846] e1000e: Support RXFCS feature flag. This enables enabling/disabling reception of the Ethernet FCS. This can be useful when sniffing packets. For e1000e, enabling RXFCS can change the default behaviour for how the NIC handles CRC. Disabling RXFCS will take the NIC back to defaults, which can be configured as part of the module options. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/e1000.h | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 41 ++++++++++++++++++---- drivers/net/ethernet/intel/e1000e/param.c | 5 ++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 45e5ae8a9fb7..04a21fcb827e 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -461,6 +461,7 @@ struct e1000_info { #define FLAG2_CHECK_PHY_HANG (1 << 9) #define FLAG2_NO_DISABLE_RX (1 << 10) #define FLAG2_PCIM2PCI_ARBITER_WA (1 << 11) +#define FLAG2_DFLT_CRC_STRIPPING (1 << 12) #define E1000_RX_DESC_PS(R, i) \ (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index c079b9b0810d..30c8c15d0396 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -933,8 +933,16 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done, } /* adjust length to remove Ethernet CRC */ - if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) - length -= 4; + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) { + /* If configured to store CRC, don't subtract FCS, + * but keep the FCS bytes out of the total_rx_bytes + * counter + */ + if (netdev->features & NETIF_F_RXFCS) + total_rx_bytes -= 4; + else + length -= 4; + } total_rx_bytes += length; total_rx_packets++; @@ -1301,8 +1309,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done, DMA_FROM_DEVICE); /* remove the CRC */ - if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) - l1 -= 4; + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) { + if (!(netdev->features & NETIF_F_RXFCS)) + l1 -= 4; + } skb_put(skb, l1); goto copydone; @@ -1328,8 +1338,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done, /* strip the ethernet crc, problem is we're using pages now so * this whole operation can get a little cpu intensive */ - if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) - pskb_trim(skb, skb->len - 4); + if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) { + if (!(netdev->features & NETIF_F_RXFCS)) + pskb_trim(skb, skb->len - 4); + } copydone: total_rx_bytes += skb->len; @@ -5982,7 +5994,7 @@ static int e1000_set_features(struct net_device *netdev, adapter->flags |= FLAG_TSO_FORCE; if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | - NETIF_F_RXCSUM | NETIF_F_RXHASH))) + NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS))) return 0; /* @@ -5996,6 +6008,20 @@ static int e1000_set_features(struct net_device *netdev, return -EINVAL; } + if (changed & NETIF_F_RXFCS) { + if (features & NETIF_F_RXFCS) { + adapter->flags2 &= ~FLAG2_CRC_STRIPPING; + } else { + /* We need to take it back to defaults, which might mean + * stripping is still disabled at the adapter level. + */ + if (adapter->flags2 & FLAG2_DFLT_CRC_STRIPPING) + adapter->flags2 |= FLAG2_CRC_STRIPPING; + else + adapter->flags2 &= ~FLAG2_CRC_STRIPPING; + } + } + netdev->features = features; if (netif_running(netdev)) @@ -6194,6 +6220,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, /* Set user-changeable features (subset of all device features) */ netdev->hw_features = netdev->features; + netdev->hw_features |= NETIF_F_RXFCS; if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) netdev->features |= NETIF_F_HW_VLAN_FILTER; diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c index 9c6a56d804a4..ff796e42c3eb 100644 --- a/drivers/net/ethernet/intel/e1000e/param.c +++ b/drivers/net/ethernet/intel/e1000e/param.c @@ -463,10 +463,13 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) if (num_CrcStripping > bd) { unsigned int crc_stripping = CrcStripping[bd]; e1000_validate_option(&crc_stripping, &opt, adapter); - if (crc_stripping == OPTION_ENABLED) + if (crc_stripping == OPTION_ENABLED) { adapter->flags2 |= FLAG2_CRC_STRIPPING; + adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING; + } } else { adapter->flags2 |= FLAG2_CRC_STRIPPING; + adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING; } } { /* Kumeran Lock Loss Workaround */ -- GitLab From 3bdc0eba0b8b47797f4a76e377dd8360f317450f Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:30 +0000 Subject: [PATCH 1061/1846] net: Add framework to allow sending packets with customized CRC. This is useful for testing RX handling of frames with bad CRCs. Requires driver support to actually put the packet on the wire properly. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- arch/alpha/include/asm/socket.h | 3 +++ arch/arm/include/asm/socket.h | 3 +++ arch/avr32/include/asm/socket.h | 3 +++ arch/cris/include/asm/socket.h | 3 +++ arch/frv/include/asm/socket.h | 3 +++ arch/h8300/include/asm/socket.h | 3 +++ arch/ia64/include/asm/socket.h | 3 +++ arch/m32r/include/asm/socket.h | 3 +++ arch/m68k/include/asm/socket.h | 3 +++ arch/mips/include/asm/socket.h | 3 +++ arch/mn10300/include/asm/socket.h | 3 +++ arch/parisc/include/asm/socket.h | 4 ++++ arch/powerpc/include/asm/socket.h | 3 +++ arch/s390/include/asm/socket.h | 3 +++ arch/sparc/include/asm/socket.h | 4 ++++ arch/xtensa/include/asm/socket.h | 3 +++ include/asm-generic/socket.h | 4 ++++ include/linux/if.h | 2 ++ include/linux/netdevice.h | 8 +++++++- include/linux/skbuff.h | 4 +++- include/net/sock.h | 4 ++++ net/core/skbuff.c | 1 + net/core/sock.c | 5 +++++ net/packet/af_packet.c | 32 +++++++++++++++++++++++++++---- 24 files changed, 104 insertions(+), 6 deletions(-) diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h index 16449d330dae..dcb221a4b5be 100644 --- a/arch/alpha/include/asm/socket.h +++ b/arch/alpha/include/asm/socket.h @@ -73,6 +73,9 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. */ diff --git a/arch/arm/include/asm/socket.h b/arch/arm/include/asm/socket.h index d958c74e5260..6433cadb6ed4 100644 --- a/arch/arm/include/asm/socket.h +++ b/arch/arm/include/asm/socket.h @@ -66,4 +66,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/avr32/include/asm/socket.h b/arch/avr32/include/asm/socket.h index 30078f98b3ab..a473f8c6a9aa 100644 --- a/arch/avr32/include/asm/socket.h +++ b/arch/avr32/include/asm/socket.h @@ -66,4 +66,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* __ASM_AVR32_SOCKET_H */ diff --git a/arch/cris/include/asm/socket.h b/arch/cris/include/asm/socket.h index 048aba64600c..ae52825021af 100644 --- a/arch/cris/include/asm/socket.h +++ b/arch/cris/include/asm/socket.h @@ -68,6 +68,9 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/frv/include/asm/socket.h b/arch/frv/include/asm/socket.h index 7a361810f3cc..a5b1d7dbb205 100644 --- a/arch/frv/include/asm/socket.h +++ b/arch/frv/include/asm/socket.h @@ -66,5 +66,8 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/h8300/include/asm/socket.h b/arch/h8300/include/asm/socket.h index e7bbfcee5b99..ec4554e7b04b 100644 --- a/arch/h8300/include/asm/socket.h +++ b/arch/h8300/include/asm/socket.h @@ -66,4 +66,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/ia64/include/asm/socket.h b/arch/ia64/include/asm/socket.h index ced62de9d5a9..41fc28a4a18a 100644 --- a/arch/ia64/include/asm/socket.h +++ b/arch/ia64/include/asm/socket.h @@ -75,4 +75,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_IA64_SOCKET_H */ diff --git a/arch/m32r/include/asm/socket.h b/arch/m32r/include/asm/socket.h index 696cb4c7ca4e..a15f40b52783 100644 --- a/arch/m32r/include/asm/socket.h +++ b/arch/m32r/include/asm/socket.h @@ -66,4 +66,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_M32R_SOCKET_H */ diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/asm/socket.h index e8b41a6775f9..d1be684edf97 100644 --- a/arch/m68k/include/asm/socket.h +++ b/arch/m68k/include/asm/socket.h @@ -66,4 +66,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/mips/include/asm/socket.h b/arch/mips/include/asm/socket.h index 52104872e9e3..a2ed6fdad4e0 100644 --- a/arch/mips/include/asm/socket.h +++ b/arch/mips/include/asm/socket.h @@ -86,6 +86,9 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #ifdef __KERNEL__ /** sock_type - Socket types diff --git a/arch/mn10300/include/asm/socket.h b/arch/mn10300/include/asm/socket.h index 013fcc51698f..820463a484b8 100644 --- a/arch/mn10300/include/asm/socket.h +++ b/arch/mn10300/include/asm/socket.h @@ -66,4 +66,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h index f717c9bec16f..1b52c2c31a7a 100644 --- a/arch/parisc/include/asm/socket.h +++ b/arch/parisc/include/asm/socket.h @@ -65,6 +65,10 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 0x4023 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 0x4024 + + /* O_NONBLOCK clashes with the bits used for socket types. Therefore we * have to define SOCK_NONBLOCK to a different value here. */ diff --git a/arch/powerpc/include/asm/socket.h b/arch/powerpc/include/asm/socket.h index fe1c0b478fd7..3d5179bb122f 100644 --- a/arch/powerpc/include/asm/socket.h +++ b/arch/powerpc/include/asm/socket.h @@ -73,4 +73,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_POWERPC_SOCKET_H */ diff --git a/arch/s390/include/asm/socket.h b/arch/s390/include/asm/socket.h index 581702fa1b0c..c91b720965c0 100644 --- a/arch/s390/include/asm/socket.h +++ b/arch/s390/include/asm/socket.h @@ -74,4 +74,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/sparc/include/asm/socket.h b/arch/sparc/include/asm/socket.h index 68e2e2746f6f..bea1568ae4af 100644 --- a/arch/sparc/include/asm/socket.h +++ b/arch/sparc/include/asm/socket.h @@ -62,6 +62,10 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 0x0026 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 0x0027 + + /* Security levels - as per NRL IPv6 - don't actually do anything */ #define SO_SECURITY_AUTHENTICATION 0x5001 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/asm/socket.h index 74818b161362..e36c68184920 100644 --- a/arch/xtensa/include/asm/socket.h +++ b/arch/xtensa/include/asm/socket.h @@ -77,4 +77,7 @@ #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* _XTENSA_SOCKET_H */ diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h index d9aaac0c36d4..b1bea03274d5 100644 --- a/include/asm-generic/socket.h +++ b/include/asm-generic/socket.h @@ -68,4 +68,8 @@ #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 + +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + #endif /* __ASM_GENERIC_SOCKET_H */ diff --git a/include/linux/if.h b/include/linux/if.h index 06b6ef60c821..f995c663c493 100644 --- a/include/linux/if.h +++ b/include/linux/if.h @@ -80,6 +80,8 @@ * skbs on transmit */ #define IFF_UNICAST_FLT 0x20000 /* Supports unicast filtering */ #define IFF_TEAM_PORT 0x40000 /* device used as team port */ +#define IFF_SUPP_NOFCS 0x80000 /* device supports sending custom FCS */ + #define IF_GET_IFACE 0x0001 /* for querying only */ #define IF_GET_PROTO 0x0002 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 0eac07c95255..f1b7d037c2c5 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1082,7 +1082,8 @@ struct net_device { const struct header_ops *header_ops; unsigned int flags; /* interface flags (a la BSD) */ - unsigned int priv_flags; /* Like 'flags' but invisible to userspace. */ + unsigned int priv_flags; /* Like 'flags' but invisible to userspace. + * See if.h for definitions. */ unsigned short gflags; unsigned short padded; /* How much padding added by alloc_netdev() */ @@ -2650,6 +2651,11 @@ static inline int netif_is_bond_slave(struct net_device *dev) return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING; } +static inline bool netif_supports_nofcs(struct net_device *dev) +{ + return dev->priv_flags & IFF_SUPP_NOFCS; +} + extern struct pernet_operations __net_initdata loopback_net_ops; /* Logging, debugging and troubleshooting/diagnostic helpers. */ diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index c11a44ea1bf4..06a4c0fd7bef 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -361,6 +361,7 @@ typedef unsigned char *sk_buff_data_t; * ports. * @wifi_acked_valid: wifi_acked was set * @wifi_acked: whether frame was acked on wifi or not + * @no_fcs: Request NIC to treat last 4 bytes as Ethernet FCS * @dma_cookie: a cookie to one of several possible DMA operations * done by skb DMA functions * @secmark: security marking @@ -459,7 +460,8 @@ struct sk_buff { __u8 l4_rxhash:1; __u8 wifi_acked_valid:1; __u8 wifi_acked:1; - /* 10/12 bit hole (depending on ndisc_nodetype presence) */ + __u8 no_fcs:1; + /* 9/11 bit hole (depending on ndisc_nodetype presence) */ kmemcheck_bitfield_end(flags2); #ifdef CONFIG_NET_DMA diff --git a/include/net/sock.h b/include/net/sock.h index 9c0553b9e451..ba761e7de252 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -615,6 +615,10 @@ enum sock_flags { SOCK_RXQ_OVFL, SOCK_ZEROCOPY, /* buffers from userspace */ SOCK_WIFI_STATUS, /* push wifi status to userspace */ + SOCK_NOFCS, /* Tell NIC not to do the Ethernet FCS. + * Will use last 4 bytes of packet sent from + * user-space instead. + */ }; static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index f3a530780753..6eb656acdfe5 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -592,6 +592,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) new->rxhash = old->rxhash; new->ooo_okay = old->ooo_okay; new->l4_rxhash = old->l4_rxhash; + new->no_fcs = old->no_fcs; #ifdef CONFIG_XFRM new->sp = secpath_get(old->sp); #endif diff --git a/net/core/sock.c b/net/core/sock.c index 19942d4bb6e6..55011cb691ad 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -799,6 +799,11 @@ int sock_setsockopt(struct socket *sock, int level, int optname, else ret = -EOPNOTSUPP; break; + + case SO_NOFCS: + sock_valbool_flag(sk, SOCK_NOFCS, valbool); + break; + default: ret = -ENOPROTOOPT; break; diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 2dbb32b988c4..ae2d484416dd 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1459,6 +1459,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, struct net_device *dev; __be16 proto = 0; int err; + int extra_len = 0; /* * Get and verify the address. @@ -1493,8 +1494,16 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, * raw protocol and you must do your own fragmentation at this level. */ + if (unlikely(sock_flag(sk, SOCK_NOFCS))) { + if (!netif_supports_nofcs(dev)) { + err = -EPROTONOSUPPORT; + goto out_unlock; + } + extra_len = 4; /* We're doing our own CRC */ + } + err = -EMSGSIZE; - if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN) + if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN + extra_len) goto out_unlock; if (!skb) { @@ -1526,7 +1535,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, goto retry; } - if (len > (dev->mtu + dev->hard_header_len)) { + if (len > (dev->mtu + dev->hard_header_len + extra_len)) { /* Earlier code assumed this would be a VLAN pkt, * double-check this now that we have the actual * packet in hand. @@ -1548,6 +1557,9 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, if (err < 0) goto out_unlock; + if (unlikely(extra_len == 4)) + skb->no_fcs = 1; + dev_queue_xmit(skb); rcu_read_unlock(); return len; @@ -2209,6 +2221,7 @@ static int packet_snd(struct socket *sock, struct packet_sock *po = pkt_sk(sk); unsigned short gso_type = 0; int hlen, tlen; + int extra_len = 0; /* * Get and verify the address. @@ -2288,8 +2301,16 @@ static int packet_snd(struct socket *sock, } } + if (unlikely(sock_flag(sk, SOCK_NOFCS))) { + if (!netif_supports_nofcs(dev)) { + err = -EPROTONOSUPPORT; + goto out_unlock; + } + extra_len = 4; /* We're doing our own CRC */ + } + err = -EMSGSIZE; - if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN)) + if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN + extra_len)) goto out_unlock; err = -ENOBUFS; @@ -2315,7 +2336,7 @@ static int packet_snd(struct socket *sock, if (err < 0) goto out_free; - if (!gso_type && (len > dev->mtu + reserve)) { + if (!gso_type && (len > dev->mtu + reserve + extra_len)) { /* Earlier code assumed this would be a VLAN pkt, * double-check this now that we have the actual * packet in hand. @@ -2353,6 +2374,9 @@ static int packet_snd(struct socket *sock, len += vnet_hdr_len; } + if (unlikely(extra_len == 4)) + skb->no_fcs = 1; + /* * Now send it */ -- GitLab From 943146de22d3658de26d94512beae7223282ed1c Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:40 +0000 Subject: [PATCH 1062/1846] e1000e: Support sending custom Ethernet CRC. This can aid with testing the RX logic for bad CRCs. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 30c8c15d0396..340442c4f381 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -4613,6 +4613,7 @@ static void e1000_watchdog_task(struct work_struct *work) #define E1000_TX_FLAGS_VLAN 0x00000002 #define E1000_TX_FLAGS_TSO 0x00000004 #define E1000_TX_FLAGS_IPV4 0x00000008 +#define E1000_TX_FLAGS_NO_FCS 0x00000010 #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 #define E1000_TX_FLAGS_VLAN_SHIFT 16 @@ -4872,6 +4873,9 @@ static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count) txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK); } + if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) + txd_lower &= ~(E1000_TXD_CMD_IFCS); + i = tx_ring->next_to_use; do { @@ -4889,6 +4893,10 @@ static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count) tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd); + /* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */ + if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) + tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS)); + /* * Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only @@ -5094,6 +5102,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, if (skb->protocol == htons(ETH_P_IP)) tx_flags |= E1000_TX_FLAGS_IPV4; + if (unlikely(skb->no_fcs)) + tx_flags |= E1000_TX_FLAGS_NO_FCS; + /* if count is 0 then mapping error has occurred */ count = e1000_tx_map(tx_ring, skb, first, max_per_txd, nr_frags, mss); if (count) { @@ -6221,6 +6232,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, /* Set user-changeable features (subset of all device features) */ netdev->hw_features = netdev->features; netdev->hw_features |= NETIF_F_RXFCS; + netdev->priv_flags |= IFF_SUPP_NOFCS; if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) netdev->features |= NETIF_F_HW_VLAN_FILTER; -- GitLab From 5e0c03c8cd40e5c3b7ba624b8ba9a343de79ade1 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:45 +0000 Subject: [PATCH 1063/1846] net: Support RX-ALL feature flag. This flag requests that network devices pass all received frames up the stack, even ones with errors such as invalid FCS (frame check sum). This will allow sniffers to see bad packets and perhaps give the user some idea how to fix the problem. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- Documentation/networking/netdev-features.txt | 7 +++++++ include/linux/netdev_features.h | 2 ++ net/core/ethtool.c | 1 + 3 files changed, 10 insertions(+) diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt index 7d2781230d30..4164f5c02e4b 100644 --- a/Documentation/networking/netdev-features.txt +++ b/Documentation/networking/netdev-features.txt @@ -158,3 +158,10 @@ VLANs. This may be not useful, though.] This requests that the NIC append the Ethernet Frame Checksum (FCS) to the end of the skb data. This allows sniffers and other tools to read the CRC recorded by the NIC on receipt of the packet. + +* rx-all + +This requests that the NIC receive all possible frames, including errored +frames (such as bad FCS, etc). This can be helpful when sniffing a link with +bad packets on it. Some NICs may receive more packets if also put into normal +PROMISC mdoe. diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index d1331865f830..5ac32123035a 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h @@ -55,6 +55,7 @@ enum { NETIF_F_NOCACHE_COPY_BIT, /* Use no-cache copyfromuser */ NETIF_F_LOOPBACK_BIT, /* Enable loopback */ NETIF_F_RXFCS_BIT, /* Append FCS to skb pkt data */ + NETIF_F_RXALL_BIT, /* Receive errored frames too */ /* * Add your fresh new feature above and remember to update @@ -100,6 +101,7 @@ enum { #define NETIF_F_UFO __NETIF_F(UFO) #define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED) #define NETIF_F_RXFCS __NETIF_F(RXFCS) +#define NETIF_F_RXALL __NETIF_F(RXALL) /* Features valid for ethtool to change */ /* = all defined minus driver/device-class-related */ diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 080161924a0d..6d6d7d25caaa 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -74,6 +74,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] [NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy", [NETIF_F_LOOPBACK_BIT] = "loopback", [NETIF_F_RXFCS_BIT] = "rx-fcs", + [NETIF_F_RXALL_BIT] = "rx-all", }; static int ethtool_get_features(struct net_device *dev, void __user *useraddr) -- GitLab From cf955e6c96cb9af2dce7093a8e3a5e808555c8a4 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:51 +0000 Subject: [PATCH 1064/1846] e1000e: Support RXALL feature flag. This allows the NIC to receive all frames available, including those with bad FCS, un-matched vlans, ethernet control frames, and more. Tested by sending frames with bad FCS. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/defines.h | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 29 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h index 1af30b967a4f..3a5025917163 100644 --- a/drivers/net/ethernet/intel/e1000e/defines.h +++ b/drivers/net/ethernet/intel/e1000e/defines.h @@ -177,6 +177,7 @@ #define E1000_RCTL_VFE 0x00040000 /* vlan filter enable */ #define E1000_RCTL_CFIEN 0x00080000 /* canonical form enable */ #define E1000_RCTL_CFI 0x00100000 /* canonical form indicator */ +#define E1000_RCTL_DPF 0x00400000 /* Discard Pause Frames */ #define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */ #define E1000_RCTL_BSEX 0x02000000 /* Buffer size extension */ #define E1000_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */ diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 340442c4f381..c30e99ee66c6 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -926,7 +926,8 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done, goto next_desc; } - if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) { + if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) && + !(netdev->features & NETIF_F_RXALL))) { /* recycle */ buffer_info->skb = skb; goto next_desc; @@ -1255,7 +1256,8 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done, goto next_desc; } - if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) { + if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) && + !(netdev->features & NETIF_F_RXALL))) { dev_kfree_skb_irq(skb); goto next_desc; } @@ -1454,7 +1456,8 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done, /* errors is only valid for DD + EOP descriptors */ if (unlikely((staterr & E1000_RXD_STAT_EOP) && - (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK))) { + ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) && + !(netdev->features & NETIF_F_RXALL)))) { /* recycle both page and skb */ buffer_info->skb = skb; /* an error means any chain goes out the window too */ @@ -2997,6 +3000,22 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) ew32(PSRCTL, psrctl); } + /* This is useful for sniffing bad packets. */ + if (adapter->netdev->features & NETIF_F_RXALL) { + /* UPE and MPE will be handled by normal PROMISC logic + * in e1000e_set_rx_mode */ + rctl |= (E1000_RCTL_SBP | /* Receive bad packets */ + E1000_RCTL_BAM | /* RX All Bcast Pkts */ + E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */ + + rctl &= ~(E1000_RCTL_VFE | /* Disable VLAN filter */ + E1000_RCTL_DPF | /* Allow filtered pause */ + E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */ + /* Do not mess with E1000_CTRL_VME, it affects transmit as well, + * and that breaks VLANs. + */ + } + ew32(RFCTL, rfctl); ew32(RCTL, rctl); /* just started the receive unit, no need to restart */ @@ -6005,7 +6024,8 @@ static int e1000_set_features(struct net_device *netdev, adapter->flags |= FLAG_TSO_FORCE; if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | - NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS))) + NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS | + NETIF_F_RXALL))) return 0; /* @@ -6233,6 +6253,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, netdev->hw_features = netdev->features; netdev->hw_features |= NETIF_F_RXFCS; netdev->priv_flags |= IFF_SUPP_NOFCS; + netdev->hw_features |= NETIF_F_RXALL; if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) netdev->features |= NETIF_F_HW_VLAN_FILTER; -- GitLab From 11a78dcf35fc20bd6ae57fee11ca0447a62d33a8 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:40:01 +0000 Subject: [PATCH 1065/1846] e1000: Support sending custom Ethernet CRC. Good for testing the RX logic for bad CRC handling. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000/e1000_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index e72dc8175955..bd1d28f4cc9a 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -1067,6 +1067,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev, (hw->mac_type != e1000_82547)) netdev->hw_features |= NETIF_F_TSO; + netdev->priv_flags |= IFF_SUPP_NOFCS; + netdev->features |= netdev->hw_features; netdev->hw_features |= NETIF_F_RXCSUM; @@ -2692,6 +2694,7 @@ static void e1000_set_itr(struct e1000_adapter *adapter) #define E1000_TX_FLAGS_VLAN 0x00000002 #define E1000_TX_FLAGS_TSO 0x00000004 #define E1000_TX_FLAGS_IPV4 0x00000008 +#define E1000_TX_FLAGS_NO_FCS 0x00000010 #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 #define E1000_TX_FLAGS_VLAN_SHIFT 16 @@ -2993,6 +2996,9 @@ static void e1000_tx_queue(struct e1000_adapter *adapter, txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK); } + if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) + txd_lower &= ~(E1000_TXD_CMD_IFCS); + i = tx_ring->next_to_use; while (count--) { @@ -3007,6 +3013,10 @@ static void e1000_tx_queue(struct e1000_adapter *adapter, tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd); + /* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */ + if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) + tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS)); + /* Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only * applicable for weak-ordered memory model archs, @@ -3222,6 +3232,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, if (likely(skb->protocol == htons(ETH_P_IP))) tx_flags |= E1000_TX_FLAGS_IPV4; + if (unlikely(skb->no_fcs)) + tx_flags |= E1000_TX_FLAGS_NO_FCS; + count = e1000_tx_map(adapter, tx_ring, skb, first, max_per_txd, nr_frags, mss); -- GitLab From b0d1562c820ae0f9ffe4d21f43676f1466ccaec2 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:40:11 +0000 Subject: [PATCH 1066/1846] e1000: Support RX-FCS flag. This allows the NIC to pass the Ethernet Frame Checksum (FCS) up the stack. Useful when sniffing packets. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000/e1000_main.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index bd1d28f4cc9a..8aa8097558f9 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -1071,6 +1071,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, netdev->features |= netdev->hw_features; netdev->hw_features |= NETIF_F_RXCSUM; + netdev->hw_features |= NETIF_F_RXFCS; if (pci_using_dac) { netdev->features |= NETIF_F_HIGHDMA; @@ -4137,10 +4138,9 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, ((u32)(rx_desc->errors) << 24), le16_to_cpu(rx_desc->csum), skb); - pskb_trim(skb, skb->len - 4); - - /* probably a little skewed due to removing CRC */ - total_rx_bytes += skb->len; + total_rx_bytes += (skb->len - 4); /* don't count FCS */ + if (likely(!(netdev->features & NETIF_F_RXFCS))) + pskb_trim(skb, skb->len - 4); total_rx_packets++; /* eth type trans needs skb->data to point to something */ @@ -4294,14 +4294,15 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, } } - /* adjust length to remove Ethernet CRC, this must be - * done after the TBI_ACCEPT workaround above */ - length -= 4; - - /* probably a little skewed due to removing CRC */ - total_rx_bytes += length; + total_rx_bytes += (length - 4); /* don't count FCS */ total_rx_packets++; + if (likely(!(netdev->features & NETIF_F_RXFCS))) + /* adjust length to remove Ethernet CRC, this must be + * done after the TBI_ACCEPT workaround above + */ + length -= 4; + e1000_check_copybreak(netdev, buffer_info, length, &skb); skb_put(skb, length); -- GitLab From d95089dc54ad07a8d10292fd06963b29b059ed5b Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 10 Feb 2012 15:04:31 +0000 Subject: [PATCH 1067/1846] 8139too: Support RX-ALL logic. This allows the NIC to receive Runts and frames with bad Ethernet Frame Checksums (FCS). Useful to sniffing & diagnosing bad networks. Signed-off-by: Ben Greear --- drivers/net/ethernet/realtek/8139too.c | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index 1c3feb0116b5..1b9a090d4865 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c @@ -907,6 +907,33 @@ static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev) return ERR_PTR(rc); } +static int rtl8139_set_features(struct net_device *dev, netdev_features_t features) +{ + struct rtl8139_private *tp = netdev_priv(dev); + unsigned long flags; + netdev_features_t changed = features ^ dev->features; + void __iomem *ioaddr = tp->mmio_addr; + + if (!(changed & (NETIF_F_RXALL))) + return 0; + + spin_lock_irqsave(&tp->lock, flags); + + if (changed & NETIF_F_RXALL) { + int rx_mode = tp->rx_config; + if (features & NETIF_F_RXALL) + rx_mode |= (AcceptErr | AcceptRunt); + else + rx_mode &= ~(AcceptErr | AcceptRunt); + tp->rx_config = rtl8139_rx_config | rx_mode; + RTL_W32_F(RxConfig, tp->rx_config); + } + + spin_unlock_irqrestore(&tp->lock, flags); + + return 0; +} + static const struct net_device_ops rtl8139_netdev_ops = { .ndo_open = rtl8139_open, .ndo_stop = rtl8139_close, @@ -921,6 +948,7 @@ static const struct net_device_ops rtl8139_netdev_ops = { #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = rtl8139_poll_controller, #endif + .ndo_set_features = rtl8139_set_features, }; static int __devinit rtl8139_init_one (struct pci_dev *pdev, @@ -994,6 +1022,8 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev, dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA; dev->vlan_features = dev->features; + dev->hw_features |= NETIF_F_RXALL; + dev->irq = pdev->irq; /* tp zeroed and aligned in alloc_etherdev */ @@ -1978,11 +2008,30 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp, if (unlikely((rx_size > (MAX_ETH_FRAME_SIZE+4)) || (rx_size < 8) || (!(rx_status & RxStatusOK)))) { + if ((dev->features & NETIF_F_RXALL) && + (rx_size <= (MAX_ETH_FRAME_SIZE + 4)) && + (rx_size >= 8) && + (!(rx_status & RxStatusOK))) { + /* Length is at least mostly OK, but pkt has + * error. I'm hoping we can handle some of these + * errors without resetting the chip. --Ben + */ + dev->stats.rx_errors++; + if (rx_status & RxCRCErr) { + dev->stats.rx_crc_errors++; + goto keep_pkt; + } + if (rx_status & RxRunt) { + dev->stats.rx_length_errors++; + goto keep_pkt; + } + } rtl8139_rx_err (rx_status, dev, tp, ioaddr); received = -1; goto out; } +keep_pkt: /* Malloc up new buffer, compatible with net-2e. */ /* Omit the four octet CRC from the length. */ @@ -2515,6 +2564,9 @@ static void __set_rx_mode (struct net_device *dev) } } + if (dev->features & NETIF_F_RXALL) + rx_mode |= (AcceptErr | AcceptRunt); + /* We can safely update without stopping the chip. */ tmp = rtl8139_rx_config | rx_mode; if (tp->rx_config != tmp) { -- GitLab From eeb69aa443e8cdc945405c48f21ce03f5a3b1f86 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 10 Feb 2012 15:04:32 +0000 Subject: [PATCH 1068/1846] 8139too: Support RX-FCS flag. This allows the NIC to pass the Ethernet FCS on up the stack, and is useful when sniffing networks. Signed-off-by: Ben Greear --- drivers/net/ethernet/realtek/8139too.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index 1b9a090d4865..abd6aca70e9b 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c @@ -1023,6 +1023,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev, dev->vlan_features = dev->features; dev->hw_features |= NETIF_F_RXALL; + dev->hw_features |= NETIF_F_RXFCS; dev->irq = pdev->irq; @@ -1970,7 +1971,10 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp, /* read size+status of next frame from DMA ring buffer */ rx_status = le32_to_cpu (*(__le32 *) (rx_ring + ring_offset)); rx_size = rx_status >> 16; - pkt_size = rx_size - 4; + if (likely(!(dev->features & NETIF_F_RXFCS))) + pkt_size = rx_size - 4; + else + pkt_size = rx_size; netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n", __func__, rx_status, rx_size, cur_rx); -- GitLab From 6bbe021d405fff46b64a08dca51b06897b897a67 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 10 Feb 2012 15:04:33 +0000 Subject: [PATCH 1069/1846] r8169: Support RX-ALL flag. This allows the NIC to receive packets with bad FCS and Runts, which can help when sniffing. NOTE: r8169, at least on my NIC, silently drops packets with bad FCS instead of counting them. It seems they are only received in any fashion if the RxCRC flag is set (which this patch allows). Signed-off-by: Ben Greear --- drivers/net/ethernet/realtek/r8169.c | 51 +++++++++++++++++++++------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 5eb6858ed0a7..0517a6a252f1 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -1626,21 +1626,32 @@ static void __rtl8169_set_features(struct net_device *dev, netdev_features_t features) { struct rtl8169_private *tp = netdev_priv(dev); - + netdev_features_t changed = features ^ dev->features; void __iomem *ioaddr = tp->mmio_addr; - if (features & NETIF_F_RXCSUM) - tp->cp_cmd |= RxChkSum; - else - tp->cp_cmd &= ~RxChkSum; + if (!(changed & (NETIF_F_RXALL | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_RX))) + return; - if (dev->features & NETIF_F_HW_VLAN_RX) - tp->cp_cmd |= RxVlan; - else - tp->cp_cmd &= ~RxVlan; + if (changed & (NETIF_F_RXCSUM | NETIF_F_HW_VLAN_RX)) { + if (features & NETIF_F_RXCSUM) + tp->cp_cmd |= RxChkSum; + else + tp->cp_cmd &= ~RxChkSum; - RTL_W16(CPlusCmd, tp->cp_cmd); - RTL_R16(CPlusCmd); + if (dev->features & NETIF_F_HW_VLAN_RX) + tp->cp_cmd |= RxVlan; + else + tp->cp_cmd &= ~RxVlan; + + RTL_W16(CPlusCmd, tp->cp_cmd); + RTL_R16(CPlusCmd); + } + if (changed & NETIF_F_RXALL) { + int tmp = (RTL_R32(RxConfig) & ~(AcceptErr | AcceptRunt)); + if (features & NETIF_F_RXALL) + tmp |= (AcceptErr | AcceptRunt); + RTL_W32(RxConfig, tmp); + } } static int rtl8169_set_features(struct net_device *dev, @@ -4174,6 +4185,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) /* 8110SCd requires hardware Rx VLAN - disallow toggling */ dev->hw_features &= ~NETIF_F_HW_VLAN_RX; + dev->hw_features |= NETIF_F_RXALL; + tp->hw_start = cfg->hw_start; tp->event_slow = cfg->event_slow; @@ -5747,11 +5760,20 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); dev->stats.rx_fifo_errors++; } + if ((status & (RxRUNT | RxCRC)) && + !(status & (RxRWT | RxFOVF)) && + (dev->features & NETIF_F_RXALL)) + goto process_pkt; + rtl8169_mark_to_asic(desc, rx_buf_sz); } else { struct sk_buff *skb; - dma_addr_t addr = le64_to_cpu(desc->addr); - int pkt_size = (status & 0x00003fff) - 4; + dma_addr_t addr; + int pkt_size; + +process_pkt: + addr = le64_to_cpu(desc->addr); + pkt_size = (status & 0x00003fff) - 4; /* * The driver does not support incoming fragmented @@ -6025,6 +6047,9 @@ static void rtl_set_rx_mode(struct net_device *dev) } } + if (dev->features & NETIF_F_RXALL) + rx_mode |= (AcceptErr | AcceptRunt); + tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode; if (tp->mac_version > RTL_GIGA_MAC_VER_06) { -- GitLab From 79d0c1d26e1eac0dc5b201e66b65cc5e4e706743 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 10 Feb 2012 15:04:34 +0000 Subject: [PATCH 1070/1846] r8169: Support RX-FCS flag. This allows the NIC to receive the Ethernet FCS and pass it up the stack, allowing sniffers and other interested programs to inspect the FCS. Signed-off-by: Ben Greear --- drivers/net/ethernet/realtek/r8169.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 0517a6a252f1..fbd855bcd9f0 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -4186,6 +4186,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->hw_features &= ~NETIF_F_HW_VLAN_RX; dev->hw_features |= NETIF_F_RXALL; + dev->hw_features |= NETIF_F_RXFCS; tp->hw_start = cfg->hw_start; tp->event_slow = cfg->event_slow; @@ -5773,7 +5774,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget process_pkt: addr = le64_to_cpu(desc->addr); - pkt_size = (status & 0x00003fff) - 4; + if (likely(!(dev->features & NETIF_F_RXFCS))) + pkt_size = (status & 0x00003fff) - 4; + else + pkt_size = status & 0x00003fff; /* * The driver does not support incoming fragmented -- GitLab From b4d8e21dd83c7ed8b885929b3f742721cf2624a9 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 17 Feb 2012 03:17:55 +0000 Subject: [PATCH 1071/1846] e1000e: cosmetic change to boolean comparisons Recent discussions on LKML, kernel-janitors, linux-wireless and netdev have suggested boolean comparisons should use logical operators instead of equality comparisons with true/false. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index bc960fed8bf6..3c2daa7afc84 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -458,7 +458,7 @@ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, return ret_val; } - if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) { + if (hw->dev_spec.e80003es2lan.mdic_wa_enable) { /* * The "ready" bit in the MDIC register may be incorrectly set * before the device has completed the "Page Select" MDI @@ -529,7 +529,7 @@ static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, return ret_val; } - if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) { + if (hw->dev_spec.e80003es2lan.mdic_wa_enable) { /* * The "ready" bit in the MDIC register may be incorrectly set * before the device has completed the "Page Select" MDI -- GitLab From dffcdde7697e5bf71e40fb453d2fa69055700be4 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 17 Feb 2012 09:35:33 +0000 Subject: [PATCH 1072/1846] e1000e: cosmetic comment changes to make lines less than 80 characters Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 3c2daa7afc84..1f8f8524d863 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -289,7 +289,7 @@ static void e1000_release_phy_80003es2lan(struct e1000_hw *hw) } /** - * e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register + * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register * @hw: pointer to the HW structure * * Acquire the semaphore to access the Kumeran interface. @@ -305,7 +305,7 @@ static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw) } /** - * e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register + * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register * @hw: pointer to the HW structure * * Release the semaphore used to access the Kumeran interface -- GitLab From 542c3f4ea90fb6de47cce13df1da9ed9b1563981 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 10 Feb 2012 12:07:36 +0000 Subject: [PATCH 1073/1846] e1000: Neaten e1000_config_dsp_after_link_change Separate a complicated bit of e1000_config_dsp_after_link_change into a new static function e1000_1000Mb_check_cable_length. Reduces indentation and adds a bit of clarity. Signed-off-by: Joe Perches Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000/e1000_hw.c | 156 +++++++++----------- 1 file changed, 73 insertions(+), 83 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.c b/drivers/net/ethernet/intel/e1000/e1000_hw.c index 36ee76bf4cba..c526279e4927 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_hw.c +++ b/drivers/net/ethernet/intel/e1000/e1000_hw.c @@ -5253,6 +5253,78 @@ static s32 e1000_check_downshift(struct e1000_hw *hw) return E1000_SUCCESS; } +static const u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = { + IGP01E1000_PHY_AGC_PARAM_A, + IGP01E1000_PHY_AGC_PARAM_B, + IGP01E1000_PHY_AGC_PARAM_C, + IGP01E1000_PHY_AGC_PARAM_D +}; + +static s32 e1000_1000Mb_check_cable_length(struct e1000_hw *hw) +{ + u16 min_length, max_length; + u16 phy_data, i; + s32 ret_val; + + ret_val = e1000_get_cable_length(hw, &min_length, &max_length); + if (ret_val) + return ret_val; + + if (hw->dsp_config_state != e1000_dsp_config_enabled) + return 0; + + if (min_length >= e1000_igp_cable_length_50) { + for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) { + ret_val = e1000_read_phy_reg(hw, dsp_reg_array[i], + &phy_data); + if (ret_val) + return ret_val; + + phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX; + + ret_val = e1000_write_phy_reg(hw, dsp_reg_array[i], + phy_data); + if (ret_val) + return ret_val; + } + hw->dsp_config_state = e1000_dsp_config_activated; + } else { + u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20; + u32 idle_errs = 0; + + /* clear previous idle error counts */ + ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data); + if (ret_val) + return ret_val; + + for (i = 0; i < ffe_idle_err_timeout; i++) { + udelay(1000); + ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, + &phy_data); + if (ret_val) + return ret_val; + + idle_errs += (phy_data & SR_1000T_IDLE_ERROR_CNT); + if (idle_errs > SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) { + hw->ffe_config_state = e1000_ffe_config_active; + + ret_val = e1000_write_phy_reg(hw, + IGP01E1000_PHY_DSP_FFE, + IGP01E1000_PHY_DSP_FFE_CM_CP); + if (ret_val) + return ret_val; + break; + } + + if (idle_errs) + ffe_idle_err_timeout = + FFE_IDLE_ERR_COUNT_TIMEOUT_100; + } + } + + return 0; +} + /** * e1000_config_dsp_after_link_change * @hw: Struct containing variables accessed by shared code @@ -5269,13 +5341,6 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up) { s32 ret_val; u16 phy_data, phy_saved_data, speed, duplex, i; - static const u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = { - IGP01E1000_PHY_AGC_PARAM_A, - IGP01E1000_PHY_AGC_PARAM_B, - IGP01E1000_PHY_AGC_PARAM_C, - IGP01E1000_PHY_AGC_PARAM_D - }; - u16 min_length, max_length; e_dbg("e1000_config_dsp_after_link_change"); @@ -5290,84 +5355,9 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up) } if (speed == SPEED_1000) { - - ret_val = - e1000_get_cable_length(hw, &min_length, - &max_length); + ret_val = e1000_1000Mb_check_cable_length(hw); if (ret_val) return ret_val; - - if ((hw->dsp_config_state == e1000_dsp_config_enabled) - && min_length >= e1000_igp_cable_length_50) { - - for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) { - ret_val = - e1000_read_phy_reg(hw, - dsp_reg_array[i], - &phy_data); - if (ret_val) - return ret_val; - - phy_data &= - ~IGP01E1000_PHY_EDAC_MU_INDEX; - - ret_val = - e1000_write_phy_reg(hw, - dsp_reg_array - [i], phy_data); - if (ret_val) - return ret_val; - } - hw->dsp_config_state = - e1000_dsp_config_activated; - } - - if ((hw->ffe_config_state == e1000_ffe_config_enabled) - && (min_length < e1000_igp_cable_length_50)) { - - u16 ffe_idle_err_timeout = - FFE_IDLE_ERR_COUNT_TIMEOUT_20; - u32 idle_errs = 0; - - /* clear previous idle error counts */ - ret_val = - e1000_read_phy_reg(hw, PHY_1000T_STATUS, - &phy_data); - if (ret_val) - return ret_val; - - for (i = 0; i < ffe_idle_err_timeout; i++) { - udelay(1000); - ret_val = - e1000_read_phy_reg(hw, - PHY_1000T_STATUS, - &phy_data); - if (ret_val) - return ret_val; - - idle_errs += - (phy_data & - SR_1000T_IDLE_ERROR_CNT); - if (idle_errs > - SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) - { - hw->ffe_config_state = - e1000_ffe_config_active; - - ret_val = - e1000_write_phy_reg(hw, - IGP01E1000_PHY_DSP_FFE, - IGP01E1000_PHY_DSP_FFE_CM_CP); - if (ret_val) - return ret_val; - break; - } - - if (idle_errs) - ffe_idle_err_timeout = - FFE_IDLE_ERR_COUNT_TIMEOUT_100; - } - } } } else { if (hw->dsp_config_state == e1000_dsp_config_activated) { -- GitLab From e29b5d8f0896bfe908c0036f2614a89e71bdf42c Mon Sep 17 00:00:00 2001 From: Tushar Dave Date: Fri, 10 Feb 2012 08:06:36 +0000 Subject: [PATCH 1074/1846] v2 e1000: Neaten e1000_dump function Use pr_ for printk Use temporary instead of multiple pr_conts Coalesce formats. Save a few bytes of object code too: $ size drivers/net/ethernet/intel/e1000/e1000_main.o* text data bss dec hex filename 60507 369 14120 74996 124f4 drivers/net/ethernet/intel/e1000/e1000_main.o.new 60717 369 14176 75262 125fe drivers/net/ethernet/intel/e1000/e1000_main.o.old Removed printing of pktdata. Signed-off-by: Joe Perches Signed-off-by: Tushar Dave Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000/e1000_main.c | 113 ++++++++---------- 1 file changed, 50 insertions(+), 63 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 8aa8097558f9..6419a88a69e6 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -3261,16 +3261,16 @@ static void e1000_regdump(struct e1000_adapter *adapter) u32 *regs_buff = regs; int i = 0; - char *reg_name[] = { - "CTRL", "STATUS", - "RCTL", "RDLEN", "RDH", "RDT", "RDTR", - "TCTL", "TDBAL", "TDBAH", "TDLEN", "TDH", "TDT", - "TIDV", "TXDCTL", "TADV", "TARC0", - "TDBAL1", "TDBAH1", "TDLEN1", "TDH1", "TDT1", - "TXDCTL1", "TARC1", - "CTRL_EXT", "ERT", "RDBAL", "RDBAH", - "TDFH", "TDFT", "TDFHS", "TDFTS", "TDFPC", - "RDFH", "RDFT", "RDFHS", "RDFTS", "RDFPC" + static const char * const reg_name[] = { + "CTRL", "STATUS", + "RCTL", "RDLEN", "RDH", "RDT", "RDTR", + "TCTL", "TDBAL", "TDBAH", "TDLEN", "TDH", "TDT", + "TIDV", "TXDCTL", "TADV", "TARC0", + "TDBAL1", "TDBAH1", "TDLEN1", "TDH1", "TDT1", + "TXDCTL1", "TARC1", + "CTRL_EXT", "ERT", "RDBAL", "RDBAH", + "TDFH", "TDFT", "TDFHS", "TDFTS", "TDFPC", + "RDFH", "RDFT", "RDFHS", "RDFTS", "RDFPC" }; regs_buff[0] = er32(CTRL); @@ -3316,10 +3316,8 @@ static void e1000_regdump(struct e1000_adapter *adapter) regs_buff[37] = er32(RDFPC); pr_info("Register dump\n"); - for (i = 0; i < NUM_REGS; i++) { - printk(KERN_INFO "%-15s %08x\n", - reg_name[i], regs_buff[i]); - } + for (i = 0; i < NUM_REGS; i++) + pr_info("%-15s %08x\n", reg_name[i], regs_buff[i]); } /* @@ -3370,10 +3368,8 @@ static void e1000_dump(struct e1000_adapter *adapter) * +----------------------------------------------------------------+ * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 */ - printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma ]" - " leng ntw timestmp bi->skb\n"); - printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen] [bi->dma ]" - " leng ntw timestmp bi->skb\n"); + pr_info("Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma ] leng ntw timestmp bi->skb\n"); + pr_info("Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen] [bi->dma ] leng ntw timestmp bi->skb\n"); if (!netif_msg_tx_done(adapter)) goto rx_ring_summary; @@ -3383,27 +3379,23 @@ static void e1000_dump(struct e1000_adapter *adapter) struct e1000_buffer *buffer_info = &tx_ring->buffer_info[i]; struct my_u { u64 a; u64 b; }; struct my_u *u = (struct my_u *)tx_desc; - printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX %04X %3X " - "%016llX %p", - ((le64_to_cpu(u->b) & (1<<20)) ? 'd' : 'c'), i, - le64_to_cpu(u->a), le64_to_cpu(u->b), - (u64)buffer_info->dma, buffer_info->length, - buffer_info->next_to_watch, (u64)buffer_info->time_stamp, - buffer_info->skb); + const char *type; + if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean) - printk(KERN_CONT" NTC/U\n"); + type = "NTC/U"; else if (i == tx_ring->next_to_use) - printk(KERN_CONT " NTU\n"); + type = "NTU"; else if (i == tx_ring->next_to_clean) - printk(KERN_CONT " NTC\n"); + type = "NTC"; else - printk(KERN_CONT "\n"); - - - if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) - print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, - 16, 1, phys_to_virt(buffer_info->dma), - buffer_info->length, true); + type = ""; + + pr_info("T%c[0x%03X] %016llX %016llX %016llX %04X %3X %016llX %p %s\n", + ((le64_to_cpu(u->b) & (1<<20)) ? 'd' : 'c'), i, + le64_to_cpu(u->a), le64_to_cpu(u->b), + (u64)buffer_info->dma, buffer_info->length, + buffer_info->next_to_watch, + (u64)buffer_info->time_stamp, buffer_info->skb, type); } rx_ring_summary: @@ -3421,8 +3413,7 @@ static void e1000_dump(struct e1000_adapter *adapter) * +-----------------------------------------------------+ * 63 48 47 40 39 32 31 16 15 0 */ - printk(KERN_INFO "R[desc] [address 63:0 ] [vl er S cks ln] " - "[bi->dma ] [bi->skb]\n"); + pr_info("R[desc] [address 63:0 ] [vl er S cks ln] [bi->dma ] [bi->skb]\n"); if (!netif_msg_rx_status(adapter)) goto exit; @@ -3432,44 +3423,40 @@ static void e1000_dump(struct e1000_adapter *adapter) struct e1000_buffer *buffer_info = &rx_ring->buffer_info[i]; struct my_u { u64 a; u64 b; }; struct my_u *u = (struct my_u *)rx_desc; - printk(KERN_INFO "R[0x%03X] %016llX %016llX %016llX %p", - i, le64_to_cpu(u->a), le64_to_cpu(u->b), - (u64)buffer_info->dma, buffer_info->skb); + const char *type; + if (i == rx_ring->next_to_use) - printk(KERN_CONT " NTU\n"); + type = "NTU"; else if (i == rx_ring->next_to_clean) - printk(KERN_CONT " NTC\n"); + type = "NTC"; else - printk(KERN_CONT "\n"); - - if (netif_msg_pktdata(adapter)) - print_hex_dump(KERN_INFO, "", - DUMP_PREFIX_ADDRESS, 16, 1, - phys_to_virt(buffer_info->dma), - buffer_info->length, true); + type = ""; + pr_info("R[0x%03X] %016llX %016llX %016llX %p %s\n", + i, le64_to_cpu(u->a), le64_to_cpu(u->b), + (u64)buffer_info->dma, buffer_info->skb, type); } /* for */ /* dump the descriptor caches */ /* rx */ - printk(KERN_INFO "e1000: Rx descriptor cache in 64bit format\n"); + pr_info("Rx descriptor cache in 64bit format\n"); for (i = 0x6000; i <= 0x63FF ; i += 0x10) { - printk(KERN_INFO "R%04X: %08X|%08X %08X|%08X\n", - i, - readl(adapter->hw.hw_addr + i+4), - readl(adapter->hw.hw_addr + i), - readl(adapter->hw.hw_addr + i+12), - readl(adapter->hw.hw_addr + i+8)); + pr_info("R%04X: %08X|%08X %08X|%08X\n", + i, + readl(adapter->hw.hw_addr + i+4), + readl(adapter->hw.hw_addr + i), + readl(adapter->hw.hw_addr + i+12), + readl(adapter->hw.hw_addr + i+8)); } /* tx */ - printk(KERN_INFO "e1000: Tx descriptor cache in 64bit format\n"); + pr_info("Tx descriptor cache in 64bit format\n"); for (i = 0x7000; i <= 0x73FF ; i += 0x10) { - printk(KERN_INFO "T%04X: %08X|%08X %08X|%08X\n", - i, - readl(adapter->hw.hw_addr + i+4), - readl(adapter->hw.hw_addr + i), - readl(adapter->hw.hw_addr + i+12), - readl(adapter->hw.hw_addr + i+8)); + pr_info("T%04X: %08X|%08X %08X|%08X\n", + i, + readl(adapter->hw.hw_addr + i+4), + readl(adapter->hw.hw_addr + i), + readl(adapter->hw.hw_addr + i+12), + readl(adapter->hw.hw_addr + i+8)); } exit: return; -- GitLab From 3159d3843aa628b0ee9e8ef4b4fe8c935500c03f Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 24 Feb 2012 13:47:56 +0200 Subject: [PATCH 1075/1846] Bluetooth: Fix init request completion with old controllers With Bluetooth 1.1 controllers the last command in the HCI init sequence will be a write_local_name, however there was no callback to indicate init request completion in this case. This patch fixes the issue by adding the necessary callback to the write_local_name_complete handler. Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index fb6543b60dec..3e817fed7706 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -217,6 +217,8 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); hci_dev_unlock(hdev); + + hci_req_complete(hdev, HCI_OP_WRITE_LOCAL_NAME, status); } static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) -- GitLab From 28b8df77449faa03b573638e089a855f8d25e0ed Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 24 Feb 2012 12:45:44 +0200 Subject: [PATCH 1076/1846] Bluetooth: Fix init request completion with AMP controllers Mark request status as done for Read Local Version HCI command. In AMP initialization this HCI command is the last and needs to be completed. Signed-off-by: Andrei Emeltchenko Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 3e817fed7706..e920cd520a82 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -620,7 +620,7 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s status 0x%x", hdev->name, rp->status); if (rp->status) - return; + goto done; hdev->hci_ver = rp->hci_ver; hdev->hci_rev = __le16_to_cpu(rp->hci_rev); @@ -634,6 +634,9 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) if (test_bit(HCI_INIT, &hdev->flags)) hci_setup(hdev); + +done: + hci_req_complete(hdev, HCI_OP_READ_LOCAL_VERSION, rp->status); } static void hci_setup_link_policy(struct hci_dev *hdev) -- GitLab From a55e1f388767116836d32457a50eda7da3e925e5 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 24 Feb 2012 17:12:24 +0100 Subject: [PATCH 1077/1846] Bluetooth: Allow HCI UART reset parameter via flags ioctl The flags ioctl for HCI UART drivers already allows setting of certain Bluetooth core quirks. The reset parameter fits right in here. So allow this as well. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_ldisc.c | 11 +++-------- drivers/bluetooth/hci_uart.h | 1 + 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index c2d637adb3ca..cdc3594f9901 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -48,8 +48,6 @@ #define VERSION "2.2" -static bool reset = 0; - static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO]; int hci_uart_register_proto(struct hci_uart_proto *p) @@ -392,12 +390,12 @@ static int hci_uart_register_dev(struct hci_uart *hu) hdev->send = hci_uart_send_frame; hdev->parent = hu->tty->dev; - if (!reset) - set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); - if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); + if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) + set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); + if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); @@ -584,9 +582,6 @@ static void __exit hci_uart_exit(void) module_init(hci_uart_init); module_exit(hci_uart_exit); -module_param(reset, bool, 0644); -MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); - MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Bluetooth HCI UART driver ver " VERSION); MODULE_VERSION(VERSION); diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 99fb35239d1f..54c8983b183e 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -45,6 +45,7 @@ #define HCI_UART_ATH3K 5 #define HCI_UART_RAW_DEVICE 0 +#define HCI_UART_RESET_ON_INIT 1 struct hci_uart; -- GitLab From 8a7a3fd680f3ea9f22fc504caf5e8e056a800401 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 24 Feb 2012 17:09:38 +0100 Subject: [PATCH 1078/1846] Bluetooth: Add support for creating HCI UART based AMP controllers In reality this might never be used for real hardware, but it is a nice feature for emulating AMP controllers within a virtual machine. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- drivers/bluetooth/hci_ldisc.c | 5 +++++ drivers/bluetooth/hci_uart.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index cdc3594f9901..fd5adb408f44 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -396,6 +396,11 @@ static int hci_uart_register_dev(struct hci_uart *hu) if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); + if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) + hdev->dev_type = HCI_AMP; + else + hdev->dev_type = HCI_BREDR; + if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 54c8983b183e..6cf6ab22ad21 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -46,6 +46,7 @@ #define HCI_UART_RAW_DEVICE 0 #define HCI_UART_RESET_ON_INIT 1 +#define HCI_UART_CREATE_AMP 2 struct hci_uart; -- GitLab From 5b4cedaa14bd1fe3ca1d59c684203a6ae7747faa Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 24 Feb 2012 16:35:32 +0200 Subject: [PATCH 1079/1846] Bluetooth: Fix double locking in LE and conless chan Remove socket lock since chan->ops->recv locks socket itself. Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 5f4cfea33915..db04c9e4e1d9 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4369,18 +4369,13 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, struct sk_buff *skb) { - struct sock *sk = NULL; struct l2cap_chan *chan; chan = l2cap_global_chan_by_psm(0, psm, conn->src); if (!chan) goto drop; - sk = chan->sk; - - lock_sock(sk); - - BT_DBG("sk %p, len %d", sk, skb->len); + BT_DBG("chan %p, len %d", chan, skb->len); if (chan->state != BT_BOUND && chan->state != BT_CONNECTED) goto drop; @@ -4389,31 +4384,23 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str goto drop; if (!chan->ops->recv(chan->data, skb)) - goto done; + return 0; drop: kfree_skb(skb); -done: - if (sk) - release_sock(sk); return 0; } static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct sk_buff *skb) { - struct sock *sk = NULL; struct l2cap_chan *chan; chan = l2cap_global_chan_by_scid(0, cid, conn->src); if (!chan) goto drop; - sk = chan->sk; - - lock_sock(sk); - - BT_DBG("sk %p, len %d", sk, skb->len); + BT_DBG("chan %p, len %d", chan, skb->len); if (chan->state != BT_BOUND && chan->state != BT_CONNECTED) goto drop; @@ -4422,14 +4409,11 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct goto drop; if (!chan->ops->recv(chan->data, skb)) - goto done; + return 0; drop: kfree_skb(skb); -done: - if (sk) - release_sock(sk); return 0; } -- GitLab From 9b27f350688c9399da10c2b888c4044c2c1bd923 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 24 Feb 2012 16:00:00 +0200 Subject: [PATCH 1080/1846] Bluetooth: Remove duplicated code in l2cap conn req The same sequence sending L2CAP Connection Request was used in several places. Using subroutine makes those places easy to read. Signed-off-by: Andrei Emeltchenko Reviewed-by: Ulisses Furquim Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 49 +++++++++++++++----------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index db04c9e4e1d9..bdcfbf0f631e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -667,6 +667,21 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan) return !test_bit(CONF_CONNECT_PEND, &chan->conf_state); } +static void l2cap_send_conn_req(struct l2cap_chan *chan) +{ + struct l2cap_conn *conn = chan->conn; + struct l2cap_conn_req req; + + req.scid = cpu_to_le16(chan->scid); + req.psm = chan->psm; + + chan->ident = l2cap_get_ident(conn); + + set_bit(CONF_CONNECT_PEND, &chan->conf_state); + + l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req); +} + static void l2cap_do_start(struct l2cap_chan *chan) { struct l2cap_conn *conn = chan->conn; @@ -676,17 +691,8 @@ static void l2cap_do_start(struct l2cap_chan *chan) return; if (l2cap_chan_check_security(chan) && - __l2cap_no_conn_pending(chan)) { - struct l2cap_conn_req req; - req.scid = cpu_to_le16(chan->scid); - req.psm = chan->psm; - - chan->ident = l2cap_get_ident(conn); - set_bit(CONF_CONNECT_PEND, &chan->conf_state); - - l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, - sizeof(req), &req); - } + __l2cap_no_conn_pending(chan)) + l2cap_send_conn_req(chan); } else { struct l2cap_info_req req; req.type = cpu_to_le16(L2CAP_IT_FEAT_MASK); @@ -763,8 +769,6 @@ static void l2cap_conn_start(struct l2cap_conn *conn) } if (chan->state == BT_CONNECT) { - struct l2cap_conn_req req; - if (!l2cap_chan_check_security(chan) || !__l2cap_no_conn_pending(chan)) { l2cap_chan_unlock(chan); @@ -779,14 +783,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) continue; } - req.scid = cpu_to_le16(chan->scid); - req.psm = chan->psm; - - chan->ident = l2cap_get_ident(conn); - set_bit(CONF_CONNECT_PEND, &chan->conf_state); - - l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, - sizeof(req), &req); + l2cap_send_conn_req(chan); } else if (chan->state == BT_CONNECT2) { struct l2cap_conn_rsp rsp; @@ -4593,15 +4590,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) if (chan->state == BT_CONNECT) { if (!status) { - struct l2cap_conn_req req; - req.scid = cpu_to_le16(chan->scid); - req.psm = chan->psm; - - chan->ident = l2cap_get_ident(conn); - set_bit(CONF_CONNECT_PEND, &chan->conf_state); - - l2cap_send_cmd(conn, chan->ident, - L2CAP_CONN_REQ, sizeof(req), &req); + l2cap_send_conn_req(chan); } else { __clear_chan_timer(chan); __set_chan_timer(chan, -- GitLab From bc2f7996858db66f2d5b154aac10971655f72cad Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 24 Feb 2012 14:48:34 -0500 Subject: [PATCH 1081/1846] net: Add missing getsockopt for SO_NOFCS. Signed-off-by: David S. Miller --- net/core/sock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/sock.c b/net/core/sock.c index 55011cb691ad..216719cb5c7f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1035,6 +1035,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname, v.val = sk->sk_peek_off; break; + case SO_NOFCS: + v.val = !!sock_flag(sk, SOCK_NOFCS); + break; default: return -ENOPROTOOPT; } -- GitLab From f27fd49962dc0f608e5547fc7ae98a8243570610 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:53 +0000 Subject: [PATCH 1082/1846] amd/hplance.c: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/amd/hplance.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/amd/hplance.c b/drivers/net/ethernet/amd/hplance.c index 86aa0d546a5b..4e2d68a4de8a 100644 --- a/drivers/net/ethernet/amd/hplance.c +++ b/drivers/net/ethernet/amd/hplance.c @@ -89,7 +89,6 @@ static int __devinit hplance_init_one(struct dio_dev *d, { struct net_device *dev; int err = -ENOMEM; - int i; dev = alloc_etherdev(sizeof(struct hplance_private)); if (!dev) @@ -107,13 +106,8 @@ static int __devinit hplance_init_one(struct dio_dev *d, dio_set_drvdata(d, dev); - printk(KERN_INFO "%s: %s; select code %d, addr %2.2x", dev->name, d->name, d->scode, dev->dev_addr[0]); - - for (i=1; i<6; i++) { - printk(":%2.2x", dev->dev_addr[i]); - } - - printk(", irq %d\n", d->ipl); + printk(KERN_INFO "%s: %s; select code %d, addr %pM, irq %d\n", + dev->name, d->name, d->scode, dev->dev_addr, d->ipl); return 0; -- GitLab From 66dc92eddf610d6f4572367f42902e62e19db7cb Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:54 +0000 Subject: [PATCH 1083/1846] cirrus/mac89x0: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Use memcpy to set the address to dev->dev_addr in set_mac_address, instead of mxing it up in a for loop with printing a debug msg. Check also if the given address is valid. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/cirrus/mac89x0.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cirrus/mac89x0.c b/drivers/net/ethernet/cirrus/mac89x0.c index 83781f316d1f..419825ceab3b 100644 --- a/drivers/net/ethernet/cirrus/mac89x0.c +++ b/drivers/net/ethernet/cirrus/mac89x0.c @@ -592,10 +592,14 @@ static void set_multicast_list(struct net_device *dev) static int set_mac_address(struct net_device *dev, void *addr) { int i; - printk("%s: Setting MAC address to ", dev->name); - for (i = 0; i < 6; i++) - printk(" %2.2x", dev->dev_addr[i] = ((unsigned char *)addr)[i]); - printk(".\n"); + struct sockaddr *saddr = addr; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + printk("%s: Setting MAC address to %pM\n", dev->name, dev->dev_addr); + /* set the Ethernet address */ for (i=0; i < ETH_ALEN/2; i++) writereg(dev, PP_IA+i*2, dev->dev_addr[i*2] | (dev->dev_addr[i*2+1] << 8)); -- GitLab From bbf7bd2f04b5a24d0f371bd77ad1cf82471225e4 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:55 +0000 Subject: [PATCH 1084/1846] dec/tulip/de4x5: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/dec/tulip/de4x5.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c index 93583408a325..18b106cc6d2b 100644 --- a/drivers/net/ethernet/dec/tulip/de4x5.c +++ b/drivers/net/ethernet/dec/tulip/de4x5.c @@ -5234,11 +5234,7 @@ de4x5_dbg_open(struct net_device *dev) if (de4x5_debug & DEBUG_OPEN) { printk("%s: de4x5 opening with irq %d\n",dev->name,dev->irq); - printk("\tphysical address: "); - for (i=0;i<6;i++) { - printk("%2.2x:",(short)dev->dev_addr[i]); - } - printk("\n"); + printk("\tphysical address: %pM\n", dev->dev_addr); printk("Descriptor head addresses:\n"); printk("\t0x%8.8lx 0x%8.8lx\n",(u_long)lp->rx_ring,(u_long)lp->tx_ring); printk("Descriptor addresses:\nRX: "); -- GitLab From f794e7efe40147ed0c34f889b75298fec10e66b8 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:56 +0000 Subject: [PATCH 1085/1846] ixgbevf: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index e10221dcebb1..581c65976bb4 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -3462,13 +3462,7 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev, ixgbevf_init_last_counter_stats(adapter); /* print the MAC address */ - hw_dbg(hw, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", - netdev->dev_addr[0], - netdev->dev_addr[1], - netdev->dev_addr[2], - netdev->dev_addr[3], - netdev->dev_addr[4], - netdev->dev_addr[5]); + hw_dbg(hw, "%pM\n", netdev->dev_addr); hw_dbg(hw, "MAC: %d\n", hw->mac.type); -- GitLab From d558950efcfb005771151cb843ac906355ad5ef4 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:57 +0000 Subject: [PATCH 1086/1846] sun/sunqe: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/ethernet/sun/sunqe.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/sun/sunqe.c b/drivers/net/ethernet/sun/sunqe.c index b42d1c5a6ca1..139d6b410d68 100644 --- a/drivers/net/ethernet/sun/sunqe.c +++ b/drivers/net/ethernet/sun/sunqe.c @@ -907,14 +907,8 @@ static int __devinit qec_ether_init(struct platform_device *op) dev_set_drvdata(&op->dev, qe); - printk(KERN_INFO "%s: qe channel[%d] ", dev->name, qe->channel); - for (i = 0; i < 6; i++) - printk ("%2.2x%c", - dev->dev_addr[i], - i == 5 ? ' ': ':'); - printk("\n"); - - + printk(KERN_INFO "%s: qe channel[%d] %pM\n", dev->name, qe->channel, + dev->dev_addr); return 0; fail: -- GitLab From 2d5ba835514c75dd06b9be8118977573dff4b5b8 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:58 +0000 Subject: [PATCH 1087/1846] xscale/ixp2000/ixpdev: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Acked-by: Lennert Buytenhek Signed-off-by: David S. Miller --- drivers/net/ethernet/xscale/ixp2000/ixpdev.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/xscale/ixp2000/ixpdev.c b/drivers/net/ethernet/xscale/ixp2000/ixpdev.c index e122493ab70e..45008377c8bf 100644 --- a/drivers/net/ethernet/xscale/ixp2000/ixpdev.c +++ b/drivers/net/ethernet/xscale/ixp2000/ixpdev.c @@ -398,11 +398,8 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, } for (i = 0; i < nds_count; i++) { - printk(KERN_INFO "%s: IXP2000 MSF ethernet (port %d), " - "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x.\n", nds[i]->name, i, - nds[i]->dev_addr[0], nds[i]->dev_addr[1], - nds[i]->dev_addr[2], nds[i]->dev_addr[3], - nds[i]->dev_addr[4], nds[i]->dev_addr[5]); + printk(KERN_INFO "%s: IXP2000 MSF ethernet (port %d), %pM.\n", + nds[i]->name, i, nds[i]->dev_addr); } return 0; -- GitLab From 517cd81c0a5b5d8fa4887490ba5cd7c64e7b5e00 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:45:59 +0000 Subject: [PATCH 1088/1846] usb/cdc_ncm: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Signed-off-by: David S. Miller --- drivers/net/usb/cdc_ncm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 3a539a9cac54..81f86b8ea551 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -579,11 +579,7 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf) if (temp) goto error2; - dev_info(&dev->udev->dev, "MAC-Address: " - "0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - dev->net->dev_addr[0], dev->net->dev_addr[1], - dev->net->dev_addr[2], dev->net->dev_addr[3], - dev->net->dev_addr[4], dev->net->dev_addr[5]); + dev_info(&dev->udev->dev, "MAC-Address: %pM\n", dev->net->dev_addr); dev->in = usb_rcvbulkpipe(dev->udev, ctx->in_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); -- GitLab From 6ac8f069776c4e678448dabdd9bb2dd25dea3186 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 03:46:00 +0000 Subject: [PATCH 1089/1846] usb/kaweth: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka Acked-by: Oliver Neukum Signed-off-by: David S. Miller --- drivers/net/usb/kaweth.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index d034d9c42548..df2a2cf35a99 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -1098,13 +1098,7 @@ static int kaweth_probe( dev_info(&intf->dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); dev_info(&intf->dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); dev_info(&intf->dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); - dev_info(&intf->dev, "Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", - (int)kaweth->configuration.hw_addr[0], - (int)kaweth->configuration.hw_addr[1], - (int)kaweth->configuration.hw_addr[2], - (int)kaweth->configuration.hw_addr[3], - (int)kaweth->configuration.hw_addr[4], - (int)kaweth->configuration.hw_addr[5]); + dev_info(&intf->dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); if(!memcmp(&kaweth->configuration.hw_addr, &bcast_addr, -- GitLab From ff40a675bba27c990c7b32c2fcc50d3db758b226 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 14:45:52 +0100 Subject: [PATCH 1090/1846] arch/ia64/hp/sim/simeth.c: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pm instead of custom code. Signed-off-by: Danny Kukawka --- arch/ia64/hp/sim/simeth.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/ia64/hp/sim/simeth.c b/arch/ia64/hp/sim/simeth.c index 47afcc61f6e5..440001e5714e 100644 --- a/arch/ia64/hp/sim/simeth.c +++ b/arch/ia64/hp/sim/simeth.c @@ -193,7 +193,7 @@ simeth_probe1(void) unsigned char mac_addr[ETH_ALEN]; struct simeth_local *local; struct net_device *dev; - int fd, i, err, rc; + int fd, err, rc; /* * XXX Fix me @@ -236,12 +236,8 @@ simeth_probe1(void) */ netdev_connect(dev->irq); - printk(KERN_INFO "%s: hosteth=%s simfd=%d, HwAddr", - dev->name, simeth_device, local->simfd); - for(i = 0; i < ETH_ALEN; i++) { - printk(" %2.2x", dev->dev_addr[i]); - } - printk(", IRQ %d\n", dev->irq); + printk(KERN_INFO "%s: hosteth=%s simfd=%d, HwAddr=%pm, IRQ %d\n", + dev->name, simeth_device, local->simfd, dev->dev_addr, dev->irq); return 0; } -- GitLab From 3274ce71fede837176e59b1579ac9679dc990117 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 14:46:01 +0100 Subject: [PATCH 1091/1846] Staging: ft1000-pcmcia: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c index 917bbb082a6e..7569aa0f24d1 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c @@ -2211,11 +2211,8 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link, ft1000InitProc(dev); ft1000_card_present = 1; SET_ETHTOOL_OPS(dev, &ops); - printk(KERN_INFO - "ft1000: %s: addr 0x%04lx irq %d, MAC addr %02x:%02x:%02x:%02x:%02x:%02x\n", - dev->name, dev->base_addr, dev->irq, dev->dev_addr[0], - dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5]); + printk(KERN_INFO "ft1000: %s: addr 0x%04lx irq %d, MAC addr %pM\n", + dev->name, dev->base_addr, dev->irq, dev->dev_addr); return dev; err_unreg: -- GitLab From 5d74f1757001f5b9a7739c2a9053435e16ce516b Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Fri, 24 Feb 2012 14:46:02 +0100 Subject: [PATCH 1092/1846] Staging: wlags49_h2: print MAC via printk format specifier Print MAC/dev_addr via printk extended format specifier %pM instead of custom code. Signed-off-by: Danny Kukawka --- drivers/staging/wlags49_h2/wl_cs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c index 2faee2dd4bb1..a2cbb29c3f59 100644 --- a/drivers/staging/wlags49_h2/wl_cs.c +++ b/drivers/staging/wlags49_h2/wl_cs.c @@ -229,7 +229,6 @@ static int wl_adapter_resume(struct pcmcia_device *link) void wl_adapter_insert(struct pcmcia_device *link) { struct net_device *dev; - int i; int ret; /*--------------------------------------------------------------------*/ @@ -266,10 +265,8 @@ void wl_adapter_insert(struct pcmcia_device *link) register_wlags_sysfs(dev); - printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, ""mac_address ", - dev->name, dev->base_addr, dev->irq); - for (i = 0; i < ETH_ALEN; i++) - printk("%02X%c", dev->dev_addr[i], ((i < (ETH_ALEN-1)) ? ':' : '\n')); + printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, mac_address" + " %pM\n", dev->name, dev->base_addr, dev->irq, dev->dev_addr); DBG_LEAVE(DbgInfo); return; -- GitLab From fc0eea691a06ba8516795fb7a198239fb9db1cfc Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 28 Oct 2011 16:26:41 -0400 Subject: [PATCH 1093/1846] tipc: Introduce node signature field in neighbor discovery message Adds support for the new "node signature" in neighbor discovery messages, which is a 16 bit identifier chosen randomly when TIPC is initialized. This field makes it possible for nodes receiving a neighbor discovery message to detect if multiple neighboring nodes are using the same network address (i.e. ), even when the messages are arriving on different interfaces. This first phase of node signature support creates the signature, incorporates it into outgoing neighbor discovery messages, and tracks the signature used by valid neighbors. An upcoming patch builds on this foundation to implement the improved duplicate neighbor detection checking. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/discover.c | 3 +++ net/tipc/msg.h | 10 ++++++++++ net/tipc/node.c | 1 + net/tipc/node.h | 7 +++++++ 4 files changed, 21 insertions(+) diff --git a/net/tipc/discover.c b/net/tipc/discover.c index a00e5f811569..7ae1b4c33aeb 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c @@ -82,6 +82,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type, msg = buf_msg(buf); tipc_msg_init(msg, LINK_CONFIG, type, INT_H_SIZE, dest_domain); msg_set_non_seq(msg, 1); + msg_set_node_sig(msg, tipc_random); msg_set_dest_domain(msg, dest_domain); msg_set_bc_netid(msg, tipc_net_id); b_ptr->media->addr2msg(&b_ptr->addr, msg_media_addr(msg)); @@ -128,6 +129,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) u32 orig = msg_prevnode(msg); u32 net_id = msg_bc_netid(msg); u32 type = msg_type(msg); + u32 signature = msg_node_sig(msg); int link_fully_up; media_addr.broadcast = 1; @@ -197,6 +199,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) } /* Accept discovery message & send response, if necessary */ + n_ptr->signature = signature; link_fully_up = link_working_working(link); if ((type == DSC_REQ_MSG) && !link_fully_up && !b_ptr->blocked) { diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 7b0cda167107..2ec13b731811 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h @@ -517,6 +517,16 @@ static inline void msg_set_seq_gap(struct tipc_msg *m, u32 n) msg_set_bits(m, 1, 16, 0x1fff, n); } +static inline u32 msg_node_sig(struct tipc_msg *m) +{ + return msg_bits(m, 1, 0, 0xffff); +} + +static inline void msg_set_node_sig(struct tipc_msg *m, u32 n) +{ + msg_set_bits(m, 1, 0, 0xffff, n); +} + /* * Word 2 diff --git a/net/tipc/node.c b/net/tipc/node.c index 7bc45e135fb4..153425997cce 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -112,6 +112,7 @@ struct tipc_node *tipc_node_create(u32 addr) } list_add_tail(&n_ptr->list, &temp_node->list); n_ptr->block_setup = WAIT_PEER_DOWN; + n_ptr->signature = INVALID_NODE_SIG; tipc_num_nodes++; diff --git a/net/tipc/node.h b/net/tipc/node.h index e1b78a2199c2..7bf526af1dfb 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h @@ -42,6 +42,11 @@ #include "net.h" #include "bearer.h" +/* + * Out-of-range value for node signature + */ +#define INVALID_NODE_SIG 0x10000 + /* Flags used to block (re)establishment of contact with a neighboring node */ #define WAIT_PEER_DOWN 0x0001 /* wait to see that peer's links are down */ @@ -61,6 +66,7 @@ * @block_setup: bit mask of conditions preventing link establishment to node * @link_cnt: number of links to node * @permit_changeover: non-zero if node has redundant links to this system + * @signature: node instance identifier * @bclink: broadcast-related info * @supportable: non-zero if node supports TIPC b'cast link capability * @supported: non-zero if node supports TIPC b'cast capability @@ -86,6 +92,7 @@ struct tipc_node { int working_links; int block_setup; int permit_changeover; + u32 signature; struct { u8 supportable; u8 supported; -- GitLab From 97878a405c0ffe0f6433e1fb51834d4619ece025 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 28 Oct 2011 17:30:08 -0400 Subject: [PATCH 1094/1846] tipc: Detect duplicate nodes using different network interfaces Utilizes the new "node signature" field in neighbor discovery messages to ensure that all links TIPC associates with a given network address belong to the same neighboring node. (Previously, TIPC could not tell if link setup requests arriving on different interfaces were from the same node or from two different nodes that has mistakenly been assigned the same network address.) The revised algorithm for detecting a duplicate node considers both the node signature and the network interface adddress specified in a request message when deciding how to respond to a link setup request. This prevents false alarms that might otherwise arise during normal network operation under the following scenarios: a) A neighboring node reboots. (The node's signature changes, but the network interface address remains unchanged.) b) A neighboring node's network interface is replaced. (The node's signature remains unchanged, but the network interface address changes.) c) A neighboring node is completely replaced. (The node's signature and network interface address both change.) The algorithm also handles cases in which a node reboots and re-establishes its links to TIPC (or begins re-establishing those links) before TIPC detects that it is using a new node signature. In such cases of "delayed rediscovery" TIPC simply accepts the new signature without disrupting communication that is already underway over the links. Thanks to Laser [gotolaser@gmail.com] for his contributions to the development of this enhancement. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/discover.c | 72 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 7ae1b4c33aeb..f5f9bf7a0436 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c @@ -122,7 +122,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) { struct tipc_node *n_ptr; struct tipc_link *link; - struct tipc_media_addr media_addr, *addr; + struct tipc_media_addr media_addr; struct sk_buff *rbuf; struct tipc_msg *msg = buf_msg(buf); u32 dest = msg_dest_domain(msg); @@ -130,13 +130,14 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) u32 net_id = msg_bc_netid(msg); u32 type = msg_type(msg); u32 signature = msg_node_sig(msg); + int addr_mismatch; int link_fully_up; media_addr.broadcast = 1; b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg)); buf_discard(buf); - /* Validate discovery message from requesting node */ + /* Ensure message from node is valid and communication is permitted */ if (net_id != tipc_net_id) return; if (media_addr.broadcast) @@ -164,15 +165,50 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) } tipc_node_lock(n_ptr); + /* Prepare to validate requesting node's signature and media address */ link = n_ptr->links[b_ptr->identity]; + addr_mismatch = (link != NULL) && + memcmp(&link->media_addr, &media_addr, sizeof(media_addr)); - /* Create a link endpoint for this bearer, if necessary */ - if (!link) { - link = tipc_link_create(n_ptr, b_ptr, &media_addr); - if (!link) { + /* + * Ensure discovery message's signature is correct + * + * If signature is incorrect and there is no working link to the node, + * accept the new signature but invalidate all existing links to the + * node so they won't re-activate without a new discovery message. + * + * If signature is incorrect and the requested link to the node is + * working, accept the new signature. (This is an instance of delayed + * rediscovery, where a link endpoint was able to re-establish contact + * with its peer endpoint on a node that rebooted before receiving a + * discovery message from that node.) + * + * If signature is incorrect and there is a working link to the node + * that is not the requested link, reject the request (must be from + * a duplicate node). + */ + if (signature != n_ptr->signature) { + if (n_ptr->working_links == 0) { + struct tipc_link *curr_link; + int i; + + for (i = 0; i < MAX_BEARERS; i++) { + curr_link = n_ptr->links[i]; + if (curr_link) { + memset(&curr_link->media_addr, 0, + sizeof(media_addr)); + tipc_link_reset(curr_link); + } + } + addr_mismatch = (link != NULL); + } else if (tipc_link_is_up(link) && !addr_mismatch) { + /* delayed rediscovery */ + } else { + disc_dupl_alert(b_ptr, orig, &media_addr); tipc_node_unlock(n_ptr); return; } + n_ptr->signature = signature; } /* @@ -185,21 +221,29 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) * the new media address and reset the link to ensure it starts up * cleanly. */ - addr = &link->media_addr; - if (memcmp(addr, &media_addr, sizeof(*addr))) { - if (tipc_link_is_up(link) || (!link->started)) { + + if (addr_mismatch) { + if (tipc_link_is_up(link)) { disc_dupl_alert(b_ptr, orig, &media_addr); tipc_node_unlock(n_ptr); return; + } else { + memcpy(&link->media_addr, &media_addr, + sizeof(media_addr)); + tipc_link_reset(link); + } + } + + /* Create a link endpoint for this bearer, if necessary */ + if (!link) { + link = tipc_link_create(n_ptr, b_ptr, &media_addr); + if (!link) { + tipc_node_unlock(n_ptr); + return; } - warn("Resetting link <%s>, peer interface address changed\n", - link->name); - memcpy(addr, &media_addr, sizeof(*addr)); - tipc_link_reset(link); } /* Accept discovery message & send response, if necessary */ - n_ptr->signature = signature; link_fully_up = link_working_working(link); if ((type == DSC_REQ_MSG) && !link_fully_up && !b_ptr->blocked) { -- GitLab From c74a46110fd5f97bf9299e68e9ed0453bdacb181 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 2 Nov 2011 15:08:44 -0400 Subject: [PATCH 1095/1846] tipc: Remove duplicate check of message destination node Eliminates a check in the processing of TIPC messages arriving from off node that ensures the message is destined for this node, since this check duplicates an earlier check. (The check would be necessary if TIPC needed to be able to route incoming messages to another node, but the elimination of multi-cluster support means that this never happens and all incoming messages are consumed by the receiving node.) Note: This change involves the elimination of a single "if" statement with a large "then" clause; consequently, a significant number of lines end up getting re-indented. In addition, a simple message header access routine that is no longer referenced is eliminated. However, the only functional change is the elimination of the single check described above. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 93 ++++++++++++++++++++++++------------------------- net/tipc/msg.h | 5 --- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index d8b0a22367b6..6cc78a970126 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -1773,57 +1773,56 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) if (unlikely(l_ptr->oldest_deferred_in)) head = link_insert_deferred_queue(l_ptr, head); - if (likely(msg_is_dest(msg, tipc_own_addr))) { - int ret; deliver: - if (likely(msg_isdata(msg))) { - tipc_node_unlock(n_ptr); - tipc_port_recv_msg(buf); - continue; + if (likely(msg_isdata(msg))) { + tipc_node_unlock(n_ptr); + tipc_port_recv_msg(buf); + continue; + } + switch (msg_user(msg)) { + int ret; + case MSG_BUNDLER: + l_ptr->stats.recv_bundles++; + l_ptr->stats.recv_bundled += + msg_msgcnt(msg); + tipc_node_unlock(n_ptr); + tipc_link_recv_bundle(buf); + continue; + case NAME_DISTRIBUTOR: + tipc_node_unlock(n_ptr); + tipc_named_recv(buf); + continue; + case CONN_MANAGER: + tipc_node_unlock(n_ptr); + tipc_port_recv_proto_msg(buf); + continue; + case MSG_FRAGMENTER: + l_ptr->stats.recv_fragments++; + ret = tipc_link_recv_fragment( + &l_ptr->defragm_buf, + &buf, &msg); + if (ret == 1) { + l_ptr->stats.recv_fragmented++; + goto deliver; } - switch (msg_user(msg)) { - case MSG_BUNDLER: - l_ptr->stats.recv_bundles++; - l_ptr->stats.recv_bundled += - msg_msgcnt(msg); - tipc_node_unlock(n_ptr); - tipc_link_recv_bundle(buf); - continue; - case NAME_DISTRIBUTOR: - tipc_node_unlock(n_ptr); - tipc_named_recv(buf); - continue; - case CONN_MANAGER: - tipc_node_unlock(n_ptr); - tipc_port_recv_proto_msg(buf); - continue; - case MSG_FRAGMENTER: - l_ptr->stats.recv_fragments++; - ret = tipc_link_recv_fragment( - &l_ptr->defragm_buf, - &buf, &msg); - if (ret == 1) { - l_ptr->stats.recv_fragmented++; + if (ret == -1) + l_ptr->next_in_no--; + break; + case CHANGEOVER_PROTOCOL: + type = msg_type(msg); + if (link_recv_changeover_msg(&l_ptr, + &buf)) { + msg = buf_msg(buf); + seq_no = msg_seqno(msg); + if (type == ORIGINAL_MSG) goto deliver; - } - if (ret == -1) - l_ptr->next_in_no--; - break; - case CHANGEOVER_PROTOCOL: - type = msg_type(msg); - if (link_recv_changeover_msg(&l_ptr, &buf)) { - msg = buf_msg(buf); - seq_no = msg_seqno(msg); - if (type == ORIGINAL_MSG) - goto deliver; - goto protocol_check; - } - break; - default: - buf_discard(buf); - buf = NULL; - break; + goto protocol_check; } + break; + default: + buf_discard(buf); + buf = NULL; + break; } tipc_node_unlock(n_ptr); tipc_net_route_msg(buf); diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 2ec13b731811..eba524e34a6b 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h @@ -384,11 +384,6 @@ static inline void msg_set_destnode(struct tipc_msg *m, u32 a) msg_set_word(m, 7, a); } -static inline int msg_is_dest(struct tipc_msg *m, u32 d) -{ - return msg_short(m) || (msg_destnode(m) == d); -} - static inline u32 msg_nametype(struct tipc_msg *m) { return msg_word(m, 8); -- GitLab From c422f1bdc3d3f9f637b3d288a6601668e26111d6 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 2 Nov 2011 15:49:40 -0400 Subject: [PATCH 1096/1846] tipc: Simplify enforcement of reserved name type prohibition Streamlines the logic that prevents an application from binding a reserved TIPC name type to a port by moving the check to the code that handles a socket bind() operation. This allows internal TIPC subsystems to bind a reserved name without having to set an atomic flag to gain permission to use such a name. (This simplification is now possible due to the elimination of support for TIPC's native API.) Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/config.c | 2 +- net/tipc/name_table.c | 24 +----------------------- net/tipc/name_table.h | 2 -- net/tipc/socket.c | 3 +++ net/tipc/subscr.c | 2 +- 5 files changed, 6 insertions(+), 27 deletions(-) diff --git a/net/tipc/config.c b/net/tipc/config.c index 4785bf26cdf4..9fefd32e9b2e 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c @@ -481,7 +481,7 @@ int tipc_cfg_init(void) seq.type = TIPC_CFG_SRV; seq.lower = seq.upper = tipc_own_addr; - res = tipc_nametbl_publish_rsv(config_port_ref, TIPC_ZONE_SCOPE, &seq); + res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); if (res) goto failed; diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 89eb5621ebba..1196f050e334 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -114,10 +114,8 @@ struct name_table { }; static struct name_table table; -static atomic_t rsv_publ_ok = ATOMIC_INIT(0); DEFINE_RWLOCK(tipc_nametbl_lock); - static int hash(int x) { return x & (tipc_nametbl_size - 1); @@ -665,22 +663,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, return res; } -/** - * tipc_nametbl_publish_rsv - publish port name using a reserved name type - */ - -int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, - struct tipc_name_seq const *seq) -{ - int res; - - atomic_inc(&rsv_publ_ok); - res = tipc_publish(ref, scope, seq); - atomic_dec(&rsv_publ_ok); - return res; -} - -/** +/* * tipc_nametbl_publish - add name publication to network name tables */ @@ -694,11 +677,6 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, tipc_max_publications); return NULL; } - if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) { - warn("Publication failed, reserved name {%u,%u,%u}\n", - type, lower, upper); - return NULL; - } write_lock_bh(&tipc_nametbl_lock); table.local_publ_count++; diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index 8086b42f92ad..207d59ebf849 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h @@ -91,8 +91,6 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, struct tipc_port_list *dports); -int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, - struct tipc_name_seq const *seq); struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, u32 scope, u32 port_ref, u32 key); int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e2f7c5d370ba..d3227f2a216e 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -355,6 +355,9 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) else if (addr->addrtype != TIPC_ADDR_NAMESEQ) return -EAFNOSUPPORT; + if (addr->addr.nameseq.type < TIPC_RESERVED_TYPES) + return -EACCES; + return (addr->scope > 0) ? tipc_publish(portref, addr->scope, &addr->addr.nameseq) : tipc_withdraw(portref, -addr->scope, &addr->addr.nameseq); diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 8c49566da8f3..b2964e9895d3 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c @@ -552,7 +552,7 @@ int tipc_subscr_start(void) if (res) goto failed; - res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq); + res = tipc_publish(topsrv.setup_port, TIPC_NODE_SCOPE, &seq); if (res) { tipc_deleteport(topsrv.setup_port); topsrv.setup_port = 0; -- GitLab From f80c24d9964c8a15c55d1afc2dea327c5eff7d6b Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Thu, 3 Nov 2011 11:12:01 -0400 Subject: [PATCH 1097/1846] tipc: Add check to prevent insertion of duplicate name table entries Adds a new check to TIPC's name table logic to reject any attempt to create a new name publication that is identical to an existing one. (Such an attempt will never happen under normal circumstances, but could arise if another network node malfunctions and issues a duplicate name publication message.) Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/name_table.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 1196f050e334..c2224f98e64f 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -268,6 +268,13 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, } info = sseq->info; + + /* Check if an identical publication already exists */ + list_for_each_entry(publ, &info->zone_list, zone_list) { + if ((publ->ref == port) && (publ->key == key) && + (!publ->node || (publ->node == node))) + return NULL; + } } else { u32 inspos; struct sub_seq *freesseq; -- GitLab From 732efba4d77e1b0857984c401a7b18784f51b075 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 23 Feb 2012 15:44:08 -0500 Subject: [PATCH 1098/1846] tipc: nuke the delimit static inline function. This "shortform" is actually longer than typing out what it is really trying to do, and just makes reading the code more difficult, so lets simply shoot it in the head. In the case of log.c - the comparison is on a u32, so we can drop the check for < 0 at the same time. Signed-off-by: Paul Gortmaker --- net/tipc/config.c | 8 ++++---- net/tipc/core.h | 10 ---------- net/tipc/log.c | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/net/tipc/config.c b/net/tipc/config.c index 9fefd32e9b2e..69cca4f67e8e 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c @@ -218,7 +218,7 @@ static struct sk_buff *cfg_set_max_publications(void) return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); - if (value != delimit(value, 1, 65535)) + if (value < 1 || value > 65535) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (max publications must be 1-65535)"); tipc_max_publications = value; @@ -233,7 +233,7 @@ static struct sk_buff *cfg_set_max_subscriptions(void) return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); - if (value != delimit(value, 1, 65535)) + if (value < 1 || value > 65535) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (max subscriptions must be 1-65535"); tipc_max_subscriptions = value; @@ -249,7 +249,7 @@ static struct sk_buff *cfg_set_max_ports(void) value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); if (value == tipc_max_ports) return tipc_cfg_reply_none(); - if (value != delimit(value, 127, 65535)) + if (value < 127 || value > 65535) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (max ports must be 127-65535)"); if (tipc_mode != TIPC_NOT_RUNNING) @@ -268,7 +268,7 @@ static struct sk_buff *cfg_set_netid(void) value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); if (value == tipc_net_id) return tipc_cfg_reply_none(); - if (value != delimit(value, 1, 9999)) + if (value < 1 || value > 9999) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (network id must be 1-9999)"); if (tipc_mode == TIPC_NET_MODE) diff --git a/net/tipc/core.h b/net/tipc/core.h index 2761af36d141..1260b053bf25 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h @@ -168,16 +168,6 @@ extern void tipc_netlink_stop(void); extern int tipc_socket_init(void); extern void tipc_socket_stop(void); -static inline int delimit(int val, int min, int max) -{ - if (val > max) - return max; - if (val < min) - return min; - return val; -} - - /* * TIPC timer and signal code */ diff --git a/net/tipc/log.c b/net/tipc/log.c index 952c39f643e6..895c6e530b0b 100644 --- a/net/tipc/log.c +++ b/net/tipc/log.c @@ -304,7 +304,7 @@ struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space) return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); - if (value != delimit(value, 0, 32768)) + if (value > 32768) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (log size must be 0-32768)"); if (tipc_log_resize(value)) -- GitLab From 9efde4a0bd2f21dec0c7b40da2bf2c3e189e98e2 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Thu, 3 Nov 2011 13:15:10 -0400 Subject: [PATCH 1099/1846] tipc: Eliminate a test for negative unsigned quantities Simplifies a comparison operation to eliminate a useless test that checks if an unsigned value is less than zero. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bearer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 329fb659fae4..5f5e89e12fcf 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -456,8 +456,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) warn("Bearer <%s> rejected, illegal discovery domain\n", name); return -EINVAL; } - if ((priority < TIPC_MIN_LINK_PRI || - priority > TIPC_MAX_LINK_PRI) && + if ((priority > TIPC_MAX_LINK_PRI) && (priority != TIPC_MEDIA_LINK_PRI)) { warn("Bearer <%s> rejected, illegal priority\n", name); return -EINVAL; -- GitLab From a635b46bd884efc1fc98819cb5a200da255d575c Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 4 Nov 2011 11:54:43 -0400 Subject: [PATCH 1100/1846] tipc: Hide internal details of node table implementation Relocates information about the size of TIPC's node table index and its associated hash function, since only node subsystem routines need to have access to this information. Note that these changes are essentially cosmetic in nature, and have no impact on the actual operation of TIPC. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/node.c | 13 +++++++++++++ net/tipc/node.h | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 153425997cce..1790f503f57b 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -39,6 +39,8 @@ #include "node.h" #include "name_distr.h" +#define NODE_HTABLE_SIZE 512 + static void node_lost_contact(struct tipc_node *n_ptr); static void node_established_contact(struct tipc_node *n_ptr); @@ -50,6 +52,17 @@ static u32 tipc_num_nodes; static atomic_t tipc_num_links = ATOMIC_INIT(0); +/* + * A trivial power-of-two bitmask technique is used for speed, since this + * operation is done for every incoming TIPC packet. The number of hash table + * entries has been chosen so that no hash chain exceeds 8 nodes and will + * usually be much smaller (typically only a single node). + */ +static inline unsigned int tipc_hashfn(u32 addr) +{ + return addr & (NODE_HTABLE_SIZE - 1); +} + /* * tipc_node_find - locate specified node object, if it exists */ diff --git a/net/tipc/node.h b/net/tipc/node.h index 7bf526af1dfb..72561c971d67 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h @@ -107,20 +107,8 @@ struct tipc_node { } bclink; }; -#define NODE_HTABLE_SIZE 512 extern struct list_head tipc_node_list; -/* - * A trivial power-of-two bitmask technique is used for speed, since this - * operation is done for every incoming TIPC packet. The number of hash table - * entries has been chosen so that no hash chain exceeds 8 nodes and will - * usually be much smaller (typically only a single node). - */ -static inline unsigned int tipc_hashfn(u32 addr) -{ - return addr & (NODE_HTABLE_SIZE - 1); -} - struct tipc_node *tipc_node_find(u32 addr); struct tipc_node *tipc_node_create(u32 addr); void tipc_node_delete(struct tipc_node *n_ptr); -- GitLab From 5f6d9123f1c7ef7297b0da1620988fe16c738e75 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 4 Nov 2011 13:24:29 -0400 Subject: [PATCH 1101/1846] tipc: Eliminate trivial buffer manipulation helper routines Gets rid of two inlined routines that simply call existing sk_buff manipulation routines, since there is no longer any extra processing done by the helper routines. Note that these changes are essentially cosmetic in nature, and have no impact on the actual operation of TIPC. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bcast.c | 12 +++---- net/tipc/core.h | 24 ------------- net/tipc/discover.c | 6 ++-- net/tipc/link.c | 80 +++++++++++++++++++++---------------------- net/tipc/msg.c | 2 +- net/tipc/name_distr.c | 4 +-- net/tipc/net.c | 4 +-- net/tipc/node.c | 4 +-- net/tipc/port.c | 14 ++++---- net/tipc/socket.c | 8 ++--- 10 files changed, 67 insertions(+), 91 deletions(-) diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 41ecf313073c..e00441a2092f 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -256,7 +256,7 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) if (bcbuf_acks(crs) == 0) { bcl->first_out = next; bcl->out_queue_size--; - buf_discard(crs); + kfree_skb(crs); released = 1; } crs = next; @@ -330,7 +330,7 @@ void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent) tipc_bearer_send(&bcbearer->bearer, buf, NULL); bcl->stats.sent_nacks++; spin_unlock_bh(&bc_lock); - buf_discard(buf); + kfree_skb(buf); n_ptr->bclink.oos_state++; } @@ -374,7 +374,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf) if (!bclink->bcast_nodes.count) { res = msg_data_sz(buf_msg(buf)); - buf_discard(buf); + kfree_skb(buf); goto exit; } @@ -480,7 +480,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) if (likely(msg_mcast(msg))) tipc_port_recv_mcast(buf, NULL); else - buf_discard(buf); + kfree_skb(buf); } else if (msg_user(msg) == MSG_BUNDLER) { spin_lock_bh(&bc_lock); bclink_accept_pkt(node, seqno); @@ -513,7 +513,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) bclink_accept_pkt(node, seqno); spin_unlock_bh(&bc_lock); tipc_node_unlock(node); - buf_discard(buf); + kfree_skb(buf); } buf = NULL; @@ -569,7 +569,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) unlock: tipc_node_unlock(node); exit: - buf_discard(buf); + kfree_skb(buf); } u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr) diff --git a/net/tipc/core.h b/net/tipc/core.h index 1260b053bf25..aefe1869572e 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h @@ -269,28 +269,4 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb) extern struct sk_buff *tipc_buf_acquire(u32 size); -/** - * buf_discard - frees a TIPC message buffer - * @skb: message buffer - * - * Frees a message buffer. If passed NULL, just returns. - */ - -static inline void buf_discard(struct sk_buff *skb) -{ - kfree_skb(skb); -} - -/** - * buf_linearize - convert a TIPC message buffer into a single contiguous piece - * @skb: message buffer - * - * Returns 0 on success. - */ - -static inline int buf_linearize(struct sk_buff *skb) -{ - return skb_linearize(skb); -} - #endif diff --git a/net/tipc/discover.c b/net/tipc/discover.c index f5f9bf7a0436..c630a21b2bed 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c @@ -135,7 +135,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) media_addr.broadcast = 1; b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg)); - buf_discard(buf); + kfree_skb(buf); /* Ensure message from node is valid and communication is permitted */ if (net_id != tipc_net_id) @@ -250,7 +250,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr) rbuf = tipc_disc_init_msg(DSC_RESP_MSG, orig, b_ptr); if (rbuf) { b_ptr->media->send_msg(rbuf, b_ptr, &media_addr); - buf_discard(rbuf); + kfree_skb(rbuf); } } @@ -396,7 +396,7 @@ void tipc_disc_delete(struct tipc_link_req *req) { k_cancel_timer(&req->timer); k_term_timer(&req->timer); - buf_discard(req->buf); + kfree_skb(req->buf); kfree(req); } diff --git a/net/tipc/link.c b/net/tipc/link.c index 6cc78a970126..f16e65dd50c0 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -484,7 +484,7 @@ static void link_release_outqueue(struct tipc_link *l_ptr) while (buf) { next = buf->next; - buf_discard(buf); + kfree_skb(buf); buf = next; } l_ptr->first_out = NULL; @@ -503,7 +503,7 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr) while (buf) { next = buf->next; - buf_discard(buf); + kfree_skb(buf); buf = next; } l_ptr->defragm_buf = NULL; @@ -522,20 +522,20 @@ void tipc_link_stop(struct tipc_link *l_ptr) buf = l_ptr->oldest_deferred_in; while (buf) { next = buf->next; - buf_discard(buf); + kfree_skb(buf); buf = next; } buf = l_ptr->first_out; while (buf) { next = buf->next; - buf_discard(buf); + kfree_skb(buf); buf = next; } tipc_link_reset_fragments(l_ptr); - buf_discard(l_ptr->proto_msg_queue); + kfree_skb(l_ptr->proto_msg_queue); l_ptr->proto_msg_queue = NULL; } @@ -571,12 +571,12 @@ void tipc_link_reset(struct tipc_link *l_ptr) /* Clean up all queues: */ link_release_outqueue(l_ptr); - buf_discard(l_ptr->proto_msg_queue); + kfree_skb(l_ptr->proto_msg_queue); l_ptr->proto_msg_queue = NULL; buf = l_ptr->oldest_deferred_in; while (buf) { struct sk_buff *next = buf->next; - buf_discard(buf); + kfree_skb(buf); buf = next; } if (!list_empty(&l_ptr->waiting_ports)) @@ -810,7 +810,7 @@ static int link_bundle_buf(struct tipc_link *l_ptr, skb_copy_to_linear_data_offset(bundler, to_pos, buf->data, size); msg_set_size(bundler_msg, to_pos + size); msg_set_msgcnt(bundler_msg, msg_msgcnt(bundler_msg) + 1); - buf_discard(buf); + kfree_skb(buf); l_ptr->stats.sent_bundled++; return 1; } @@ -878,10 +878,10 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) if (unlikely(queue_size >= queue_limit)) { if (imp <= TIPC_CRITICAL_IMPORTANCE) { link_schedule_port(l_ptr, msg_origport(msg), size); - buf_discard(buf); + kfree_skb(buf); return -ELINKCONG; } - buf_discard(buf); + kfree_skb(buf); if (imp > CONN_MANAGER) { warn("Resetting link <%s>, send queue full", l_ptr->name); tipc_link_reset(l_ptr); @@ -968,10 +968,10 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) if (l_ptr) res = tipc_link_send_buf(l_ptr, buf); else - buf_discard(buf); + kfree_skb(buf); tipc_node_unlock(n_ptr); } else { - buf_discard(buf); + kfree_skb(buf); } read_unlock_bh(&tipc_net_lock); return res; @@ -1018,7 +1018,7 @@ void tipc_link_send_names(struct list_head *message_list, u32 dest) list_for_each_safe(buf, temp_buf, ((struct sk_buff *)message_list)) { list_del((struct list_head *)buf); - buf_discard(buf); + kfree_skb(buf); } } @@ -1262,7 +1262,7 @@ static int link_send_sections_long(struct tipc_port *sender, error: for (; buf_chain; buf_chain = buf) { buf = buf_chain->next; - buf_discard(buf_chain); + kfree_skb(buf_chain); } return -EFAULT; } @@ -1316,7 +1316,7 @@ static int link_send_sections_long(struct tipc_port *sender, tipc_node_unlock(node); for (; buf_chain; buf_chain = buf) { buf = buf_chain->next; - buf_discard(buf_chain); + kfree_skb(buf_chain); } goto again; } @@ -1324,7 +1324,7 @@ static int link_send_sections_long(struct tipc_port *sender, reject: for (; buf_chain; buf_chain = buf) { buf = buf_chain->next; - buf_discard(buf_chain); + kfree_skb(buf_chain); } return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect, total_len, TIPC_ERR_NO_NODE); @@ -1390,7 +1390,7 @@ u32 tipc_link_push_packet(struct tipc_link *l_ptr) msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { l_ptr->unacked_window = 0; - buf_discard(buf); + kfree_skb(buf); l_ptr->proto_msg_queue = NULL; return 0; } else { @@ -1679,7 +1679,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) /* Ensure message data is a single contiguous unit */ - if (unlikely(buf_linearize(buf))) + if (unlikely(skb_linearize(buf))) goto cont; /* Handle arrival of a non-unicast link message */ @@ -1744,7 +1744,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) less_eq(buf_seqno(crs), ackd)) { struct sk_buff *next = crs->next; - buf_discard(crs); + kfree_skb(crs); crs = next; released++; } @@ -1820,7 +1820,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) } break; default: - buf_discard(buf); + kfree_skb(buf); buf = NULL; break; } @@ -1851,7 +1851,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) } tipc_node_unlock(n_ptr); cont: - buf_discard(buf); + kfree_skb(buf); } read_unlock_bh(&tipc_net_lock); } @@ -1891,7 +1891,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, u32 curr_seqno = buf_seqno(queue_buf); if (seq_no == curr_seqno) { - buf_discard(buf); + kfree_skb(buf); return 0; } @@ -1932,7 +1932,7 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, if (less(seq_no, mod(l_ptr->next_in_no))) { l_ptr->stats.duplicates++; - buf_discard(buf); + kfree_skb(buf); return; } @@ -1961,7 +1961,7 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, /* Discard any previous message that was deferred due to congestion */ if (l_ptr->proto_msg_queue) { - buf_discard(l_ptr->proto_msg_queue); + kfree_skb(l_ptr->proto_msg_queue); l_ptr->proto_msg_queue = NULL; } @@ -2060,7 +2060,7 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, /* Discard message if it was sent successfully */ l_ptr->unacked_window = 0; - buf_discard(buf); + kfree_skb(buf); } /* @@ -2204,7 +2204,7 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) break; } exit: - buf_discard(buf); + kfree_skb(buf); } @@ -2402,7 +2402,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr, warn("Link changeover error, duplicate msg dropped\n"); goto exit; } - buf_discard(tunnel_buf); + kfree_skb(tunnel_buf); return 1; } @@ -2434,7 +2434,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr, } else { *buf = buf_extract(tunnel_buf, INT_H_SIZE); if (*buf != NULL) { - buf_discard(tunnel_buf); + kfree_skb(tunnel_buf); return 1; } else { warn("Link changeover error, original msg dropped\n"); @@ -2442,7 +2442,7 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr, } exit: *buf = NULL; - buf_discard(tunnel_buf); + kfree_skb(tunnel_buf); return 0; } @@ -2464,7 +2464,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf) pos += align(msg_size(buf_msg(obuf))); tipc_net_route_msg(obuf); } - buf_discard(buf); + kfree_skb(buf); } /* @@ -2513,11 +2513,11 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) } fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); if (fragm == NULL) { - buf_discard(buf); + kfree_skb(buf); while (buf_chain) { buf = buf_chain; buf_chain = buf_chain->next; - buf_discard(buf); + kfree_skb(buf); } return -ENOMEM; } @@ -2534,7 +2534,7 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) crs += fragm_sz; msg_set_type(&fragm_hdr, FRAGMENT); } - buf_discard(buf); + kfree_skb(buf); /* Append chain of fragments to send queue & send them */ @@ -2621,7 +2621,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, if (msg_type(imsg) == TIPC_MCAST_MSG) max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE; if (msg_size(imsg) > max) { - buf_discard(fbuf); + kfree_skb(fbuf); return 0; } pbuf = tipc_buf_acquire(msg_size(imsg)); @@ -2637,10 +2637,10 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, set_expected_frags(pbuf, exp_fragm_cnt - 1); } else { dbg("Link unable to reassemble fragmented message\n"); - buf_discard(fbuf); + kfree_skb(fbuf); return -1; } - buf_discard(fbuf); + kfree_skb(fbuf); return 0; } else if (pbuf && (msg_type(fragm) != FIRST_FRAGMENT)) { u32 dsz = msg_data_sz(fragm); @@ -2649,7 +2649,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, u32 exp_frags = get_expected_frags(pbuf) - 1; skb_copy_to_linear_data_offset(pbuf, crs, msg_data(fragm), dsz); - buf_discard(fbuf); + kfree_skb(fbuf); /* Is message complete? */ @@ -2666,7 +2666,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, set_expected_frags(pbuf, exp_frags); return 0; } - buf_discard(fbuf); + kfree_skb(fbuf); return 0; } @@ -2697,7 +2697,7 @@ static void link_check_defragm_bufs(struct tipc_link *l_ptr) prev->next = buf->next; else l_ptr->defragm_buf = buf->next; - buf_discard(buf); + kfree_skb(buf); } buf = next; } @@ -3072,7 +3072,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s str_len = tipc_link_stats((char *)TLV_DATA(req_tlv_area), (char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO); if (!str_len) { - buf_discard(buf); + kfree_skb(buf); return tipc_cfg_reply_error_string("link not found"); } diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 3e4d3e29be61..e3afe162c0ac 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -106,7 +106,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, if (likely(res)) return dsz; - buf_discard(*buf); + kfree_skb(*buf); *buf = NULL; return -EFAULT; } diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index acecfda82f37..d57da6159616 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -120,7 +120,7 @@ static void named_cluster_distribute(struct sk_buff *buf) } } - buf_discard(buf); + kfree_skb(buf); } /** @@ -312,7 +312,7 @@ void tipc_named_recv(struct sk_buff *buf) item++; } write_unlock_bh(&tipc_nametbl_lock); - buf_discard(buf); + kfree_skb(buf); } /** diff --git a/net/tipc/net.c b/net/tipc/net.c index 61afee7e8291..2abd4be4933e 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -117,7 +117,7 @@ static void net_route_named_msg(struct sk_buff *buf) u32 dport; if (!msg_named(msg)) { - buf_discard(buf); + kfree_skb(buf); return; } @@ -161,7 +161,7 @@ void tipc_net_route_msg(struct sk_buff *buf) tipc_port_recv_proto_msg(buf); break; default: - buf_discard(buf); + kfree_skb(buf); } return; } diff --git a/net/tipc/node.c b/net/tipc/node.c index 1790f503f57b..24c42f7568ac 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -353,12 +353,12 @@ static void node_lost_contact(struct tipc_node *n_ptr) while (n_ptr->bclink.deferred_head) { struct sk_buff *buf = n_ptr->bclink.deferred_head; n_ptr->bclink.deferred_head = buf->next; - buf_discard(buf); + kfree_skb(buf); } n_ptr->bclink.deferred_size = 0; if (n_ptr->bclink.defragm) { - buf_discard(n_ptr->bclink.defragm); + kfree_skb(n_ptr->bclink.defragm); n_ptr->bclink.defragm = NULL; } diff --git a/net/tipc/port.c b/net/tipc/port.c index ba3268b8da42..c4b5a347037a 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -116,13 +116,13 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, ibuf = skb_copy(buf, GFP_ATOMIC); if (ibuf == NULL) { tipc_port_list_free(&dports); - buf_discard(buf); + kfree_skb(buf); return -ENOMEM; } } res = tipc_bclink_send_msg(buf); if ((res < 0) && (dports.count != 0)) - buf_discard(ibuf); + kfree_skb(ibuf); } else { ibuf = buf; } @@ -187,7 +187,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) } } exit: - buf_discard(buf); + kfree_skb(buf); tipc_port_list_free(dp); } @@ -420,7 +420,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) else tipc_link_send(rbuf, src_node, msg_link_selector(rmsg)); exit: - buf_discard(buf); + kfree_skb(buf); return data_sz; } @@ -568,7 +568,7 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) tipc_port_unlock(p_ptr); exit: tipc_net_route_msg(r_buf); - buf_discard(buf); + kfree_skb(buf); } static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id) @@ -759,7 +759,7 @@ static void port_dispatcher_sigh(void *dummy) } } if (buf) - buf_discard(buf); + kfree_skb(buf); buf = next; continue; err: @@ -813,7 +813,7 @@ static void port_dispatcher_sigh(void *dummy) } } if (buf) - buf_discard(buf); + kfree_skb(buf); buf = next; continue; reject: diff --git a/net/tipc/socket.c b/net/tipc/socket.c index d3227f2a216e..29e957f64458 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -126,7 +126,7 @@ static atomic_t tipc_queue_size = ATOMIC_INIT(0); static void advance_rx_queue(struct sock *sk) { - buf_discard(__skb_dequeue(&sk->sk_receive_queue)); + kfree_skb(__skb_dequeue(&sk->sk_receive_queue)); atomic_dec(&tipc_queue_size); } @@ -142,7 +142,7 @@ static void discard_rx_queue(struct sock *sk) while ((buf = __skb_dequeue(&sk->sk_receive_queue))) { atomic_dec(&tipc_queue_size); - buf_discard(buf); + kfree_skb(buf); } } @@ -288,7 +288,7 @@ static int release(struct socket *sock) break; atomic_dec(&tipc_queue_size); if (TIPC_SKB_CB(buf)->handle != 0) - buf_discard(buf); + kfree_skb(buf); else { if ((sock->state == SS_CONNECTING) || (sock->state == SS_CONNECTED)) { @@ -1615,7 +1615,7 @@ static int shutdown(struct socket *sock, int how) if (buf) { atomic_dec(&tipc_queue_size); if (TIPC_SKB_CB(buf)->handle != 0) { - buf_discard(buf); + kfree_skb(buf); goto restart; } tipc_disconnect(tport->ref); -- GitLab From 1cc35df847f7dba4ba06cb65bc41713df5d41404 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 4 Nov 2011 14:54:06 -0400 Subject: [PATCH 1102/1846] tipc: Remove obsolete comments about routing table updates Eliminates a block of comments that describe how routing table updates are to be handled. These comments no longer apply following the removal of TIPC's prototype multi-cluster support. Note that these changes are essentially cosmetic in nature, and have no impact on the actual operation of TIPC. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/node.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 24c42f7568ac..d7f8b7be3d8f 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -266,52 +266,6 @@ void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) n_ptr->link_cnt--; } -/* - * Routing table management - five cases to handle: - * - * 1: A link towards a zone/cluster external node comes up. - * => Send a multicast message updating routing tables of all - * system nodes within own cluster that the new destination - * can be reached via this node. - * (node.establishedContact()=>cluster.multicastNewRoute()) - * - * 2: A link towards a slave node comes up. - * => Send a multicast message updating routing tables of all - * system nodes within own cluster that the new destination - * can be reached via this node. - * (node.establishedContact()=>cluster.multicastNewRoute()) - * => Send a message to the slave node about existence - * of all system nodes within cluster: - * (node.establishedContact()=>cluster.sendLocalRoutes()) - * - * 3: A new cluster local system node becomes available. - * => Send message(s) to this particular node containing - * information about all cluster external and slave - * nodes which can be reached via this node. - * (node.establishedContact()==>network.sendExternalRoutes()) - * (node.establishedContact()==>network.sendSlaveRoutes()) - * => Send messages to all directly connected slave nodes - * containing information about the existence of the new node - * (node.establishedContact()=>cluster.multicastNewRoute()) - * - * 4: The link towards a zone/cluster external node or slave - * node goes down. - * => Send a multcast message updating routing tables of all - * nodes within cluster that the new destination can not any - * longer be reached via this node. - * (node.lostAllLinks()=>cluster.bcastLostRoute()) - * - * 5: A cluster local system node becomes unavailable. - * => Remove all references to this node from the local - * routing tables. Note: This is a completely node - * local operation. - * (node.lostAllLinks()=>network.removeAsRouter()) - * => Send messages to all directly connected slave nodes - * containing information about loss of the node - * (node.establishedContact()=>cluster.multicastLostRoute()) - * - */ - static void node_established_contact(struct tipc_node *n_ptr) { tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr); -- GitLab From 75aba9af2410ae8fc70600d9dcda0651f20e091e Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Fri, 4 Nov 2011 15:00:02 -0400 Subject: [PATCH 1103/1846] tipc: Minor optimization to broadcast link synchronization logic Optimizes processing done when contact with a neighboring node is established to avoid recording the current state of outgoing broadcast messages if the neighboring node isn't a valid broadcast link destination, since this state information isn't needed for such nodes. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/node.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index d7f8b7be3d8f..12ddc6581572 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -270,10 +270,8 @@ static void node_established_contact(struct tipc_node *n_ptr) { tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr); - /* Syncronize broadcast acks */ - n_ptr->bclink.acked = tipc_bclink_get_last_sent(); - if (n_ptr->bclink.supportable) { + n_ptr->bclink.acked = tipc_bclink_get_last_sent(); tipc_bclink_add_node(n_ptr->addr); n_ptr->bclink.supported = 1; } -- GitLab From bc9f8143ecf96c17a56635d2ef4c3c6b6ec27947 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Mon, 7 Nov 2011 17:00:54 -0500 Subject: [PATCH 1104/1846] tipc: Revert name table translation optimization Restores name table translation using a non-zero domain that is "out of scope", which was broken by an earlier commit (5d9c54c1e9ececcf7e99c4f014f9bec7ee3a7def). Comments have now been added to the name table translation routine to make it clear that there are actually three possible outcomes to a translation request (found/not found/deferred), rather than just two (found/not found). Note that a straightforward revert of the earlier commit is not possible, as other changes to the name table translation logic have occurred since the incorrect optimization was made. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/name_table.c | 17 +++++++++++++---- net/tipc/port.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index c2224f98e64f..c6a1ae36952e 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -539,10 +539,17 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, } /* - * tipc_nametbl_translate - translate name to port id + * tipc_nametbl_translate - perform name translation * - * Note: on entry 'destnode' is the search domain used during translation; - * on exit it passes back the node address of the matching port (if any) + * On entry, 'destnode' is the search domain used during translation. + * + * On exit: + * - if name translation is deferred to another node/cluster/zone, + * leaves 'destnode' unchanged (will be non-zero) and returns 0 + * - if name translation is attempted and succeeds, sets 'destnode' + * to publishing node and returns port reference (will be non-zero) + * - if name translation is attempted and fails, sets 'destnode' to 0 + * and returns 0 */ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) @@ -552,6 +559,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) struct publication *publ; struct name_seq *seq; u32 ref = 0; + u32 node = 0; if (!tipc_in_scope(*destnode, tipc_own_addr)) return 0; @@ -609,11 +617,12 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) } ref = publ->ref; - *destnode = publ->node; + node = publ->node; no_match: spin_unlock_bh(&seq->lock); not_found: read_unlock_bh(&tipc_nametbl_lock); + *destnode = node; return ref; } diff --git a/net/tipc/port.c b/net/tipc/port.c index c4b5a347037a..b103d7630c82 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -1221,7 +1221,7 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, msg_set_destnode(msg, destnode); msg_set_destport(msg, destport); - if (likely(destport)) { + if (likely(destport || destnode)) { if (likely(destnode == tipc_own_addr)) res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, total_len); -- GitLab From 077a26f029e76a5918edf9c1d44d5566eec719fc Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 8 Nov 2011 13:18:59 -0500 Subject: [PATCH 1105/1846] tipc: Eliminate obsolete support for "not running" mode Removes all references to TIPC's "not running" mode, since the removal of support for the native API means that there is no longer any way to interact with TIPC if it has not been initialized. The changes made consist of removing mode-based checks that are no longer needed, along with any associated code lying on non-executable control paths. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/config.c | 7 ++----- net/tipc/core.c | 10 +--------- net/tipc/core.h | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/net/tipc/config.c b/net/tipc/config.c index 69cca4f67e8e..7ca3854a2ac8 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c @@ -252,11 +252,8 @@ static struct sk_buff *cfg_set_max_ports(void) if (value < 127 || value > 65535) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (max ports must be 127-65535)"); - if (tipc_mode != TIPC_NOT_RUNNING) - return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED - " (cannot change max ports while TIPC is active)"); - tipc_max_ports = value; - return tipc_cfg_reply_none(); + return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED + " (cannot change max ports while TIPC is active)"); } static struct sk_buff *cfg_set_netid(void) diff --git a/net/tipc/core.c b/net/tipc/core.c index 2691cd57b8a8..ec381d444bc3 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c @@ -53,7 +53,7 @@ /* global variables used by multiple sub-systems within TIPC */ -int tipc_mode = TIPC_NOT_RUNNING; +int tipc_mode; int tipc_random; const char tipc_alphabet[] = @@ -125,11 +125,6 @@ int tipc_core_start_net(unsigned long addr) static void tipc_core_stop(void) { - if (tipc_mode != TIPC_NODE_MODE) - return; - - tipc_mode = TIPC_NOT_RUNNING; - tipc_netlink_stop(); tipc_handler_stop(); tipc_cfg_stop(); @@ -148,9 +143,6 @@ static int tipc_core_start(void) { int res; - if (tipc_mode != TIPC_NOT_RUNNING) - return -ENOPROTOOPT; - get_random_bytes(&tipc_random, sizeof(tipc_random)); tipc_mode = TIPC_NODE_MODE; diff --git a/net/tipc/core.h b/net/tipc/core.h index aefe1869572e..9842ec08dd5c 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h @@ -132,7 +132,7 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); /* * TIPC operating mode routines */ -#define TIPC_NOT_RUNNING 0 + #define TIPC_NODE_MODE 1 #define TIPC_NET_MODE 2 -- GitLab From b58343f9ea75f02ef48b984767511c6b3ba76eaf Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Tue, 8 Nov 2011 13:48:28 -0500 Subject: [PATCH 1106/1846] tipc: Eliminate support for tipc_mode global variable Removes all references to the global variable that records whether TIPC is running in "single node" mode or "network" mode, since this information can be easily deduced from the global variable that records TIPC's network address. (i.e. a non-zero network address means that TIPC is running in network mode.) The changes made update most existing mode-based checks to use the network address global variable. A few checks that are no longer needed are removed entirely, along with any associated code lying on non-executable control paths. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/bearer.c | 2 +- net/tipc/config.c | 4 ++-- net/tipc/core.c | 2 -- net/tipc/core.h | 8 -------- net/tipc/net.c | 7 +------ net/tipc/node.c | 2 +- 6 files changed, 5 insertions(+), 20 deletions(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 5f5e89e12fcf..5dfd89c40429 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -435,7 +435,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) u32 i; int res = -EINVAL; - if (tipc_mode != TIPC_NET_MODE) { + if (!tipc_own_addr) { warn("Bearer <%s> rejected, not supported in standalone mode\n", name); return -ENOPROTOOPT; diff --git a/net/tipc/config.c b/net/tipc/config.c index 7ca3854a2ac8..f76d3b15e4e2 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c @@ -179,7 +179,7 @@ static struct sk_buff *cfg_set_own_addr(void) if (!tipc_addr_node_valid(addr)) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (node address)"); - if (tipc_mode == TIPC_NET_MODE) + if (tipc_own_addr) return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED " (cannot change node address once assigned)"); @@ -268,7 +268,7 @@ static struct sk_buff *cfg_set_netid(void) if (value < 1 || value > 9999) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (network id must be 1-9999)"); - if (tipc_mode == TIPC_NET_MODE) + if (tipc_own_addr) return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED " (cannot change network id once TIPC has joined a network)"); tipc_net_id = value; diff --git a/net/tipc/core.c b/net/tipc/core.c index ec381d444bc3..68eba03e7955 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c @@ -53,7 +53,6 @@ /* global variables used by multiple sub-systems within TIPC */ -int tipc_mode; int tipc_random; const char tipc_alphabet[] = @@ -144,7 +143,6 @@ static int tipc_core_start(void) int res; get_random_bytes(&tipc_random, sizeof(tipc_random)); - tipc_mode = TIPC_NODE_MODE; res = tipc_handler_start(); if (!res) diff --git a/net/tipc/core.h b/net/tipc/core.h index 9842ec08dd5c..13837e0e56b1 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h @@ -129,13 +129,6 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ -/* - * TIPC operating mode routines - */ - -#define TIPC_NODE_MODE 1 -#define TIPC_NET_MODE 2 - /* * Global configuration variables */ @@ -151,7 +144,6 @@ extern int tipc_remote_management; * Other global variables */ -extern int tipc_mode; extern int tipc_random; extern const char tipc_alphabet[]; diff --git a/net/tipc/net.c b/net/tipc/net.c index 2abd4be4933e..d4531b07076c 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -175,14 +175,10 @@ int tipc_net_start(u32 addr) { char addr_string[16]; - if (tipc_mode != TIPC_NODE_MODE) - return -ENOPROTOOPT; - tipc_subscr_stop(); tipc_cfg_stop(); tipc_own_addr = addr; - tipc_mode = TIPC_NET_MODE; tipc_named_reinit(); tipc_port_reinit(); @@ -201,10 +197,9 @@ void tipc_net_stop(void) { struct tipc_node *node, *t_node; - if (tipc_mode != TIPC_NET_MODE) + if (!tipc_own_addr) return; write_lock_bh(&tipc_net_lock); - tipc_mode = TIPC_NODE_MODE; tipc_bearer_stop(); tipc_bclink_stop(); list_for_each_entry_safe(node, t_node, &tipc_node_list, list) diff --git a/net/tipc/node.c b/net/tipc/node.c index 12ddc6581572..a34cabc2c43a 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -406,7 +406,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE " (network address)"); - if (tipc_mode != TIPC_NET_MODE) + if (!tipc_own_addr) return tipc_cfg_reply_none(); read_lock_bh(&tipc_net_lock); -- GitLab From d1964eb138901286a170de8ed422efd227dd4daf Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:21 +0000 Subject: [PATCH 1107/1846] e1000e: cleanup: rename e1000e_id_led_init() and call as function pointer Rename e1000e_id_led_init() to e1000e_id_led_init_generic() to signify the function is used for more than one MAC-family type. For the ich8lan MAC family, some MACs use the generic function and others use the function e1000_id_led_init_pchlan(). In all cases where e1000e_id_led_init() was called directly, change to call the function pointer to be consistent with the driver design. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 4 ++-- drivers/net/ethernet/intel/e1000e/82571.c | 4 ++-- drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 5 ++--- drivers/net/ethernet/intel/e1000e/mac.c | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 1f8f8524d863..c1464845439d 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -820,7 +820,7 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) e1000_initialize_hw_bits_80003es2lan(hw); /* Initialize identification LED */ - ret_val = e1000e_id_led_init(hw); + ret_val = mac->ops.id_led_init(hw); if (ret_val) e_dbg("Error initializing identification LED\n"); /* This is not fatal and we should not stop init due to this */ @@ -1413,7 +1413,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw) static const struct e1000_mac_operations es2_mac_ops = { .read_mac_addr = e1000_read_mac_addr_80003es2lan, - .id_led_init = e1000e_id_led_init, + .id_led_init = e1000e_id_led_init_generic, .blink_led = e1000e_blink_led_generic, .check_mng_mode = e1000e_check_mng_mode_generic, /* check_for_link dependent on media type */ diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index b6b7bc4c33aa..2ca6377bd015 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1118,7 +1118,7 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw) e1000_initialize_hw_bits_82571(hw); /* Initialize identification LED */ - ret_val = e1000e_id_led_init(hw); + ret_val = mac->ops.id_led_init(hw); if (ret_val) e_dbg("Error initializing identification LED\n"); /* This is not fatal and we should not stop init due to this */ @@ -1911,7 +1911,7 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) static const struct e1000_mac_operations e82571_mac_ops = { /* .check_mng_mode: mac type dependent */ /* .check_for_link: media type dependent */ - .id_led_init = e1000e_id_led_init, + .id_led_init = e1000e_id_led_init_generic, .cleanup_led = e1000e_cleanup_led_generic, .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, .get_bus_info = e1000e_get_bus_info_pcie, diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 04a21fcb827e..2a0d658b596c 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -559,7 +559,7 @@ extern s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u extern s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex); extern s32 e1000e_disable_pcie_master(struct e1000_hw *hw); extern s32 e1000e_get_auto_rd_done(struct e1000_hw *hw); -extern s32 e1000e_id_led_init(struct e1000_hw *hw); +extern s32 e1000e_id_led_init_generic(struct e1000_hw *hw); extern void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw); extern s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw); extern s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw); diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index f3282dc5588e..7d3a7fb11dd3 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -580,7 +580,7 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw) /* check management mode */ mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan; /* ID LED init */ - mac->ops.id_led_init = e1000e_id_led_init; + mac->ops.id_led_init = e1000e_id_led_init_generic; /* blink LED */ mac->ops.blink_led = e1000e_blink_led_generic; /* setup LED */ @@ -2962,7 +2962,7 @@ static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data) * * PCH also does not have an "always on" or "always off" mode which * complicates the ID feature. Instead of using the "on" mode to indicate - * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()), + * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()), * use "link_up" mode. The LEDs will still ID on request if there is no * link based on logic in e1000_led_[on|off]_pchlan(). **/ @@ -4006,7 +4006,6 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) } static const struct e1000_mac_operations ich8_mac_ops = { - .id_led_init = e1000e_id_led_init, /* check_mng_mode dependent on mac type */ .check_for_link = e1000_check_for_copper_link_ich8lan, /* cleanup_led dependent on mac type */ diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 17991e63083d..aaf4a4d731b6 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -1399,11 +1399,11 @@ s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data) } /** - * e1000e_id_led_init - + * e1000e_id_led_init_generic - * @hw: pointer to the HW structure * **/ -s32 e1000e_id_led_init(struct e1000_hw *hw) +s32 e1000e_id_led_init_generic(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; s32 ret_val; -- GitLab From 1a46b40fbb1dfd698efbc7a9575aa64aed04d568 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:26 +0000 Subject: [PATCH 1108/1846] e1000e: cleanup: rename e1000e_setup_link() and call as function pointer Rename e1000e_setup_link() to e1000e_setup_link_generic() to signify the function is used for more than one MAC-family type. The 82571-family has a custom setup_link function which also calls the generic function. The ich8lan-family has a custom function which should just be called via the function pointer. The 80003es2lan-family just uses the generic function. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 4 ++-- drivers/net/ethernet/intel/e1000e/82571.c | 4 ++-- drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- drivers/net/ethernet/intel/e1000e/mac.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index c1464845439d..e1cbead69409 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -838,7 +838,7 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); /* Setup link and flow control */ - ret_val = e1000e_setup_link(hw); + ret_val = mac->ops.setup_link(hw); /* Disable IBIST slave mode (far-end loopback) */ e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM, @@ -1429,7 +1429,7 @@ static const struct e1000_mac_operations es2_mac_ops = { .clear_vfta = e1000_clear_vfta_generic, .reset_hw = e1000_reset_hw_80003es2lan, .init_hw = e1000_init_hw_80003es2lan, - .setup_link = e1000e_setup_link, + .setup_link = e1000e_setup_link_generic, /* setup_physical_interface dependent on media type */ .setup_led = e1000e_setup_led_generic, }; diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 2ca6377bd015..721c2030ebe3 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1143,7 +1143,7 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw) E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); /* Setup link and flow control */ - ret_val = e1000_setup_link_82571(hw); + ret_val = mac->ops.setup_link(hw); /* Set the transmit descriptor write-back policy */ reg_data = er32(TXDCTL(0)); @@ -1455,7 +1455,7 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw) break; } - return e1000e_setup_link(hw); + return e1000e_setup_link_generic(hw); } /** diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 2a0d658b596c..22e03e567fed 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -564,7 +564,7 @@ extern void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw); extern s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw); extern s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw); extern s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw); -extern s32 e1000e_setup_link(struct e1000_hw *hw); +extern s32 e1000e_setup_link_generic(struct e1000_hw *hw); extern void e1000_clear_vfta_generic(struct e1000_hw *hw); extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 7d3a7fb11dd3..8b9bf94f9887 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -3212,7 +3212,7 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) } /* Setup link and flow control */ - ret_val = e1000_setup_link_ich8lan(hw); + ret_val = mac->ops.setup_link(hw); /* Set the transmit descriptor write-back policy for both queues */ txdctl = er32(TXDCTL(0)); diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index aaf4a4d731b6..6e48895aa2ef 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -693,7 +693,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) } /** - * e1000e_setup_link - Setup flow control and link settings + * e1000e_setup_link_generic - Setup flow control and link settings * @hw: pointer to the HW structure * * Determines which flow control settings to use, then configures flow @@ -702,7 +702,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) * should be established. Assumes the hardware has previously been reset * and the transmitter and receiver are not enabled. **/ -s32 e1000e_setup_link(struct e1000_hw *hw) +s32 e1000e_setup_link_generic(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; s32 ret_val; -- GitLab From 48768329efcf5e3970f54f6d15046f3e549101d8 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:32 +0000 Subject: [PATCH 1109/1846] e1000e: cleanup use of check_mng_mode function pointer Replace e1000_check_mng_mode() inline function with calls to the MAC ops check_mng_mode function pointer. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 2 +- drivers/net/ethernet/intel/e1000e/e1000.h | 5 ----- drivers/net/ethernet/intel/e1000e/manage.c | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index e1cbead69409..0ea3e7e404e6 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1056,7 +1056,7 @@ static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw) * firmware will have already initialized them. We only initialize * them if the HW is not in IAMT mode. */ - if (!e1000e_check_mng_mode(hw)) { + if (!hw->mac.ops.check_mng_mode(hw)) { /* Enable Electrical Idle on the PHY */ data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE; ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data); diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 22e03e567fed..bae094b6cdd9 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -725,11 +725,6 @@ static inline s32 e1000_get_phy_info(struct e1000_hw *hw) return hw->phy.ops.get_info(hw); } -static inline s32 e1000e_check_mng_mode(struct e1000_hw *hw) -{ - return hw->mac.ops.check_mng_mode(hw); -} - extern bool e1000e_check_mng_mode_generic(struct e1000_hw *hw); extern bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw); extern s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length); diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c index 0d24b13ce763..473f8e711510 100644 --- a/drivers/net/ethernet/intel/e1000e/manage.c +++ b/drivers/net/ethernet/intel/e1000e/manage.c @@ -106,7 +106,7 @@ static s32 e1000_mng_enable_host_if(struct e1000_hw *hw) } /** - * e1000e_check_mng_mode_generic - check management mode + * e1000e_check_mng_mode_generic - Generic check management mode * @hw: pointer to the HW structure * * Reads the firmware semaphore register and returns true (>0) if @@ -138,7 +138,7 @@ bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) hw->mac.tx_pkt_filtering = true; /* No manageability, no filtering */ - if (!e1000e_check_mng_mode(hw)) { + if (!hw->mac.ops.check_mng_mode(hw)) { hw->mac.tx_pkt_filtering = false; return hw->mac.tx_pkt_filtering; } -- GitLab From 44abd5c12767a8c567dc4e45fd9aec3b13ca85e0 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:37 +0000 Subject: [PATCH 1110/1846] e1000e: cleanup use of check_reset_block function pointer Replace e1000_check_reset_block() inline function with calls to the PHY ops check_reset_block function pointer. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/e1000.h | 5 ----- drivers/net/ethernet/intel/e1000e/ethtool.c | 6 ++++-- drivers/net/ethernet/intel/e1000e/ich8lan.c | 15 ++++++++------- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- drivers/net/ethernet/intel/e1000e/phy.c | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index bae094b6cdd9..f93d7a40e6ad 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -662,11 +662,6 @@ static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw) return hw->phy.ops.reset(hw); } -static inline s32 e1000_check_reset_block(struct e1000_hw *hw) -{ - return hw->phy.ops.check_reset_block(hw); -} - static inline s32 e1e_rphy(struct e1000_hw *hw, u32 offset, u16 *data) { return hw->phy.ops.read_reg(hw, offset, data); diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index b1f5d7491b57..db35dd5d96de 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -258,7 +258,7 @@ static int e1000_set_settings(struct net_device *netdev, * When SoL/IDER sessions are active, autoneg/speed/duplex * cannot be changed */ - if (e1000_check_reset_block(hw)) { + if (hw->phy.ops.check_reset_block(hw)) { e_err("Cannot change link characteristics when SoL/IDER is " "active.\n"); return -EINVAL; @@ -1598,11 +1598,13 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter) static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) { + struct e1000_hw *hw = &adapter->hw; + /* * PHY loopback cannot be performed if SoL/IDER * sessions are active */ - if (e1000_check_reset_block(&adapter->hw)) { + if (hw->phy.ops.check_reset_block(hw)) { e_err("Cannot do PHY loopback test when SoL/IDER is active.\n"); *data = 0; goto out; diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 8b9bf94f9887..da89e2b73b40 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -324,7 +324,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; - if (!e1000_check_reset_block(hw)) { + if (!hw->phy.ops.check_reset_block(hw)) { u32 fwsm = er32(FWSM); /* @@ -1314,7 +1314,7 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state) oem_reg |= HV_OEM_BITS_LPLU; /* Set Restart auto-neg to activate the bits */ - if (!e1000_check_reset_block(hw)) + if (!hw->phy.ops.check_reset_block(hw)) oem_reg |= HV_OEM_BITS_RESTART_AN; } else { if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE | @@ -1788,7 +1788,7 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) s32 ret_val = 0; u16 reg; - if (e1000_check_reset_block(hw)) + if (hw->phy.ops.check_reset_block(hw)) return 0; /* Allow time for h/w to get to quiescent state after reset */ @@ -1897,7 +1897,7 @@ static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) else oem_reg &= ~HV_OEM_BITS_LPLU; - if (!e1000_check_reset_block(hw)) + if (!hw->phy.ops.check_reset_block(hw)) oem_reg |= HV_OEM_BITS_RESTART_AN; return e1e_wphy(hw, HV_OEM_BITS, oem_reg); @@ -3109,7 +3109,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) ctrl = er32(CTRL); - if (!e1000_check_reset_block(hw)) { + if (!hw->phy.ops.check_reset_block(hw)) { /* * Full-chip reset requires MAC and PHY reset at the same * time to make sure the interface between MAC and the @@ -3327,7 +3327,7 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) { s32 ret_val; - if (e1000_check_reset_block(hw)) + if (hw->phy.ops.check_reset_block(hw)) return 0; /* @@ -3707,7 +3707,8 @@ void e1000_resume_workarounds_pchlan(struct e1000_hw *hw) u16 phy_id1, phy_id2; s32 ret_val; - if ((hw->mac.type != e1000_pch2lan) || e1000_check_reset_block(hw)) + if ((hw->mac.type != e1000_pch2lan) || + hw->phy.ops.check_reset_block(hw)) return; ret_val = hw->phy.ops.acquire(hw); diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 6e48895aa2ef..011d83ddad1e 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -711,7 +711,7 @@ s32 e1000e_setup_link_generic(struct e1000_hw *hw) * In the case of the phy reset being blocked, we already have a link. * We do not need to set it up again. */ - if (e1000_check_reset_block(hw)) + if (hw->phy.ops.check_reset_block(hw)) return 0; /* diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index c30e99ee66c6..3975ed1fb279 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6236,7 +6236,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, adapter->hw.phy.ms_type = e1000_ms_hw_default; } - if (e1000_check_reset_block(&adapter->hw)) + if (hw->phy.ops.check_reset_block(hw)) e_info("PHY reset is blocked due to SOL/IDER session.\n"); /* Set initial default active device features */ @@ -6403,7 +6403,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, if (!(adapter->flags & FLAG_HAS_AMT)) e1000e_release_hw_control(adapter); err_eeprom: - if (!e1000_check_reset_block(&adapter->hw)) + if (!hw->phy.ops.check_reset_block(hw)) e1000_phy_hw_reset(&adapter->hw); err_hw_init: kfree(adapter->tx_ring); diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index d4dbbe741246..d10b27fee201 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -2133,7 +2133,7 @@ s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw) s32 ret_val; u32 ctrl; - ret_val = e1000_check_reset_block(hw); + ret_val = phy->ops.check_reset_block(hw); if (ret_val) return 0; -- GitLab From 944ce011cfc0b261b74c36e2c1c2e725c72c72ac Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:42 +0000 Subject: [PATCH 1111/1846] e1000e: cleanup calls to setup_physical_interface function pointer Call the MAC ops setup_physical_interface function pointer instead of the MAC-family-specific function to conform to the rest of the driver design. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index da89e2b73b40..fdc3be9834ac 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -3353,7 +3353,7 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) hw->fc.current_mode); /* Continue to configure the copper link. */ - ret_val = e1000_setup_copper_link_ich8lan(hw); + ret_val = hw->mac.ops.setup_physical_interface(hw); if (ret_val) return ret_val; -- GitLab From 6e3c807504a573aba1ff5aad99e235d04ac72269 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:47 +0000 Subject: [PATCH 1112/1846] e1000e: comment correction in e1000e_set_kmrn_lock_loss_workaround_ich8lan Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index fdc3be9834ac..14366829f848 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -3555,7 +3555,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) } /** - * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state + * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state * @hw: pointer to the HW structure * @state: boolean value used to set the current Kumeran workaround state * -- GitLab From 57cde7630c1911ea7e8e1561cccfde8096e8bcc7 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:58 +0000 Subject: [PATCH 1113/1846] e1000e: rename e1000e_config_collision_dist() and call as function pointer Rename e1000e_config_collision_dist() to e1000e_config_collision_dist_generic() to signify the function is used for more than one MAC-family type, and set and use it as a MAC ops function pointer to be consistent with the driver design. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 1 + drivers/net/ethernet/intel/e1000e/82571.c | 1 + drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/hw.h | 1 + drivers/net/ethernet/intel/e1000e/ich8lan.c | 3 ++- drivers/net/ethernet/intel/e1000e/mac.c | 11 +++++------ drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- drivers/net/ethernet/intel/e1000e/phy.c | 4 ++-- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 0ea3e7e404e6..6e58e94ff46b 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1432,6 +1432,7 @@ static const struct e1000_mac_operations es2_mac_ops = { .setup_link = e1000e_setup_link_generic, /* setup_physical_interface dependent on media type */ .setup_led = e1000e_setup_led_generic, + .config_collision_dist = e1000e_config_collision_dist_generic, }; static const struct e1000_phy_operations es2_phy_ops = { diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 721c2030ebe3..7f44ab76a200 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1927,6 +1927,7 @@ static const struct e1000_mac_operations e82571_mac_ops = { .setup_link = e1000_setup_link_82571, /* .setup_physical_interface: media type dependent */ .setup_led = e1000e_setup_led_generic, + .config_collision_dist = e1000e_config_collision_dist_generic, .read_mac_addr = e1000_read_mac_addr_82571, }; diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index f93d7a40e6ad..9f3a26859d6d 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -575,7 +575,7 @@ extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); extern s32 e1000e_get_hw_semaphore(struct e1000_hw *hw); extern s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data); -extern void e1000e_config_collision_dist(struct e1000_hw *hw); +extern void e1000e_config_collision_dist_generic(struct e1000_hw *hw); extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw); extern s32 e1000e_force_mac_fc(struct e1000_hw *hw); extern s32 e1000e_blink_led_generic(struct e1000_hw *hw); diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h index 197059bb9abf..50e114b68e39 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -781,6 +781,7 @@ struct e1000_mac_operations { s32 (*setup_physical_interface)(struct e1000_hw *); s32 (*setup_led)(struct e1000_hw *); void (*write_vfta)(struct e1000_hw *, u32, u32); + void (*config_collision_dist)(struct e1000_hw *); s32 (*read_mac_addr)(struct e1000_hw *); }; diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 14366829f848..df91c426a098 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -746,7 +746,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) * of MAC speed/duplex configuration. So we only need to * configure Collision Distance in the MAC. */ - e1000e_config_collision_dist(hw); + mac->ops.config_collision_dist(hw); /* * Configure Flow Control now that Auto-Neg has completed. @@ -4022,6 +4022,7 @@ static const struct e1000_mac_operations ich8_mac_ops = { .setup_link = e1000_setup_link_ich8lan, .setup_physical_interface= e1000_setup_copper_link_ich8lan, /* id_led_init dependent on mac type */ + .config_collision_dist = e1000e_config_collision_dist_generic, }; static const struct e1000_phy_operations ich8_phy_ops = { diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 011d83ddad1e..f16a611e2ded 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -465,7 +465,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) * of MAC speed/duplex configuration. So we only need to * configure Collision Distance in the MAC. */ - e1000e_config_collision_dist(hw); + mac->ops.config_collision_dist(hw); /* * Configure Flow Control now that Auto-Neg has completed. @@ -890,7 +890,7 @@ s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw) /* Take the link out of reset */ ctrl &= ~E1000_CTRL_LRST; - e1000e_config_collision_dist(hw); + hw->mac.ops.config_collision_dist(hw); ret_val = e1000_commit_fc_settings_generic(hw); if (ret_val) @@ -925,14 +925,13 @@ s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw) } /** - * e1000e_config_collision_dist - Configure collision distance + * e1000e_config_collision_dist_generic - Configure collision distance * @hw: pointer to the HW structure * * Configures the collision distance to the default value and is used - * during link setup. Currently no func pointer exists and all - * implementations are handled in the generic version of this function. + * during link setup. **/ -void e1000e_config_collision_dist(struct e1000_hw *hw) +void e1000e_config_collision_dist_generic(struct e1000_hw *hw) { u32 tctl; diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 3975ed1fb279..56c1aec65186 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -2855,7 +2855,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) /* enable Report Status bit */ adapter->txd_cmd |= E1000_TXD_CMD_RS; - e1000e_config_collision_dist(hw); + hw->mac.ops.config_collision_dist(hw); } /** diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index d10b27fee201..683abac4a049 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1181,7 +1181,7 @@ s32 e1000e_setup_copper_link(struct e1000_hw *hw) if (link) { e_dbg("Valid link established!!!\n"); - e1000e_config_collision_dist(hw); + hw->mac.ops.config_collision_dist(hw); ret_val = e1000e_config_fc_after_link_up(hw); } else { e_dbg("Unable to establish link!!!\n"); @@ -1489,7 +1489,7 @@ void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) e_dbg("Forcing 10mb\n"); } - e1000e_config_collision_dist(hw); + hw->mac.ops.config_collision_dist(hw); ew32(CTRL, ctrl); } -- GitLab From b2a50e1a1d16d8e377a0c540de36803197bde3fb Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:02:53 +0000 Subject: [PATCH 1114/1846] e1000e: cleanup comment in e1000_hash_mc_addr() Remove reference to non-existant function. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index f16a611e2ded..4130134b0d32 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -263,8 +263,7 @@ void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) * @mc_addr: pointer to a multicast address * * Generates a multicast address hash value which is used to determine - * the multicast filter table array address and new table value. See - * e1000_mta_set_generic() + * the multicast filter table array address and new table value. **/ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) { -- GitLab From b20caa80e8c9b0180defb42678209dc0d6c229d2 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:03:03 +0000 Subject: [PATCH 1115/1846] e1000e: use true/false for boolean send_xon, do not assume always true Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/mac.c | 4 +++- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 4130134b0d32..d55f5887b07a 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -969,7 +969,9 @@ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) * XON frames. */ fcrtl = hw->fc.low_water; - fcrtl |= E1000_FCRTL_XONE; + if (hw->fc.send_xon) + fcrtl |= E1000_FCRTL_XONE; + fcrth = hw->fc.high_water; } ew32(FCRTL, fcrtl); diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 56c1aec65186..8b62870e2c25 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -3464,7 +3464,7 @@ void e1000e_reset(struct e1000_adapter *adapter) fc->pause_time = 0xFFFF; else fc->pause_time = E1000_FC_PAUSE_TIME; - fc->send_xon = 1; + fc->send_xon = true; fc->current_mode = fc->requested_mode; switch (hw->mac.type) { -- GitLab From 0d37678e16fd4db3cf74fa840e7f98a0b7d40742 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:03:09 +0000 Subject: [PATCH 1116/1846] e1000e: cleanup - remove unnecessary variable Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index d55f5887b07a..59ac9f6353de 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -703,7 +703,6 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) **/ s32 e1000e_setup_link_generic(struct e1000_hw *hw) { - struct e1000_mac_info *mac = &hw->mac; s32 ret_val; /* @@ -732,7 +731,7 @@ s32 e1000e_setup_link_generic(struct e1000_hw *hw) e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode); /* Call the necessary media_type subroutine to configure the link. */ - ret_val = mac->ops.setup_physical_interface(hw); + ret_val = hw->mac.ops.setup_physical_interface(hw); if (ret_val) return ret_val; -- GitLab From e85e36390c55230975f842ed5b14aad6ab490059 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Wed, 22 Feb 2012 09:03:14 +0000 Subject: [PATCH 1117/1846] e1000e: rename e1000e_reload_nvm() and call as function pointer Rename e1000e_reload_nvm() to e1000e_reload_nvm_generic() to signify the function is used for more than one MAC-family type, and set and use it as a MAC ops function pointer to be consistent with the driver design. Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/80003es2lan.c | 1 + drivers/net/ethernet/intel/e1000e/82571.c | 1 + drivers/net/ethernet/intel/e1000e/e1000.h | 2 +- drivers/net/ethernet/intel/e1000e/hw.h | 1 + drivers/net/ethernet/intel/e1000e/ich8lan.c | 3 ++- drivers/net/ethernet/intel/e1000e/nvm.c | 4 ++-- 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index 6e58e94ff46b..bac9dda31b6c 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1457,6 +1457,7 @@ static const struct e1000_nvm_operations es2_nvm_ops = { .acquire = e1000_acquire_nvm_80003es2lan, .read = e1000e_read_nvm_eerd, .release = e1000_release_nvm_80003es2lan, + .reload = e1000e_reload_nvm_generic, .update = e1000e_update_nvm_checksum_generic, .valid_led_default = e1000e_valid_led_default, .validate = e1000e_validate_nvm_checksum_generic, diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 7f44ab76a200..086dad709179 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1989,6 +1989,7 @@ static const struct e1000_nvm_operations e82571_nvm_ops = { .acquire = e1000_acquire_nvm_82571, .read = e1000e_read_nvm_eerd, .release = e1000_release_nvm_82571, + .reload = e1000e_reload_nvm_generic, .update = e1000_update_nvm_checksum_82571, .valid_led_default = e1000_valid_led_default_82571, .validate = e1000_validate_nvm_checksum_82571, diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 9f3a26859d6d..86cdd4793992 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -684,7 +684,7 @@ extern s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg); extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw); extern void e1000e_release_nvm(struct e1000_hw *hw); -extern void e1000e_reload_nvm(struct e1000_hw *hw); +extern void e1000e_reload_nvm_generic(struct e1000_hw *hw); extern s32 e1000_read_mac_addr_generic(struct e1000_hw *hw); static inline s32 e1000e_read_mac_addr(struct e1000_hw *hw) diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h index 50e114b68e39..f82ecf536c8b 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -830,6 +830,7 @@ struct e1000_nvm_operations { s32 (*acquire)(struct e1000_hw *); s32 (*read)(struct e1000_hw *, u16, u16, u16 *); void (*release)(struct e1000_hw *); + void (*reload)(struct e1000_hw *); s32 (*update)(struct e1000_hw *); s32 (*valid_led_default)(struct e1000_hw *, u16 *); s32 (*validate)(struct e1000_hw *); diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index df91c426a098..8e9af624d54a 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -2609,7 +2609,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) * until after the next adapter reset. */ if (!ret_val) { - e1000e_reload_nvm(hw); + nvm->ops.reload(hw); usleep_range(10000, 20000); } @@ -4043,6 +4043,7 @@ static const struct e1000_nvm_operations ich8_nvm_ops = { .acquire = e1000_acquire_nvm_ich8lan, .read = e1000_read_nvm_ich8lan, .release = e1000_release_nvm_ich8lan, + .reload = e1000e_reload_nvm_generic, .update = e1000_update_nvm_checksum_ich8lan, .valid_led_default = e1000_valid_led_default_ich8lan, .validate = e1000_validate_nvm_checksum_ich8lan, diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c index 24b7930b7500..a969f1af1b4e 100644 --- a/drivers/net/ethernet/intel/e1000e/nvm.c +++ b/drivers/net/ethernet/intel/e1000e/nvm.c @@ -625,13 +625,13 @@ s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw) } /** - * e1000e_reload_nvm - Reloads EEPROM + * e1000e_reload_nvm_generic - Reloads EEPROM * @hw: pointer to the HW structure * * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the * extended control register. **/ -void e1000e_reload_nvm(struct e1000_hw *hw) +void e1000e_reload_nvm_generic(struct e1000_hw *hw) { u32 ctrl_ext; -- GitLab From 946a720c814ff63a9e5c7755395bff080b931eae Mon Sep 17 00:00:00 2001 From: Rami Rosen Date: Sat, 25 Feb 2012 02:09:46 +0000 Subject: [PATCH 1118/1846] xfrm: remove unneeded method typedef declaration in net/xfrm.h. The patch removes unneeded method typedef declaration (icv_update_fn_t ) and the two struct declarations which appear in its prototype (struct hash_desc and struct scatterlist) in net/xfrm.h. Signed-off-by: Rami Rosen Signed-off-by: David S. Miller --- include/net/xfrm.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 89174e29dca9..96239e78e621 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1566,11 +1566,6 @@ extern struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe); extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, int probe); -struct hash_desc; -struct scatterlist; -typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *, - unsigned int); - static inline int xfrm_addr_cmp(const xfrm_address_t *a, const xfrm_address_t *b, int family) -- GitLab From 80d326fab534a5380e8f6e509a0b9076655a9670 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 24 Feb 2012 14:30:15 +0000 Subject: [PATCH 1119/1846] netlink: add netlink_dump_control structure for netlink_dump_start() Davem considers that the argument list of this interface is getting out of control. This patch tries to address this issue following his proposal: struct netlink_dump_control c = { .dump = dump, .done = done, ... }; netlink_dump_start(..., &c); Suggested by David S. Miller. Signed-off-by: Pablo Neira Ayuso Signed-off-by: David S. Miller --- crypto/crypto_user.c | 10 +++++++--- drivers/infiniband/core/netlink.c | 10 +++++++--- include/linux/netlink.h | 10 +++++++--- net/core/rtnetlink.c | 9 +++++++-- net/ipv4/inet_diag.c | 18 ++++++++++++------ net/netfilter/ipset/ip_set_core.c | 10 +++++++--- net/netfilter/nf_conntrack_netlink.c | 18 ++++++++++++------ net/netfilter/nfnetlink_acct.c | 6 ++++-- net/netlink/af_netlink.c | 11 ++++------- net/netlink/genetlink.c | 9 +++++++-- net/unix/diag.c | 10 ++++++---- net/xfrm/xfrm_user.c | 9 +++++++-- 12 files changed, 87 insertions(+), 43 deletions(-) diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c index 16f8693cc147..b6ac1387770c 100644 --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c @@ -389,9 +389,13 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) (nlh->nlmsg_flags & NLM_F_DUMP))) { if (link->dump == NULL) return -EINVAL; - - return netlink_dump_start(crypto_nlsk, skb, nlh, - link->dump, link->done, 0); + { + struct netlink_dump_control c = { + .dump = link->dump, + .done = link->done, + }; + return netlink_dump_start(crypto_nlsk, skb, nlh, &c); + } } err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX, diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c index d1c8196d15d7..396e29370304 100644 --- a/drivers/infiniband/core/netlink.c +++ b/drivers/infiniband/core/netlink.c @@ -147,9 +147,13 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (op < 0 || op >= client->nops || !client->cb_table[RDMA_NL_GET_OP(op)].dump) return -EINVAL; - return netlink_dump_start(nls, skb, nlh, - client->cb_table[op].dump, - NULL, 0); + + { + struct netlink_dump_control c = { + .dump = client->cb_table[op].dump, + }; + return netlink_dump_start(nls, skb, nlh, &c); + } } } diff --git a/include/linux/netlink.h b/include/linux/netlink.h index a390e9d54827..1f8c1a95f57c 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -248,11 +248,15 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) #define NLMSG_PUT(skb, pid, seq, type, len) \ NLMSG_NEW(skb, pid, seq, type, len, 0) +struct netlink_dump_control { + int (*dump)(struct sk_buff *skb, struct netlink_callback *); + int (*done)(struct netlink_callback*); + u16 min_dump_alloc; +}; + extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, const struct nlmsghdr *nlh, - int (*dump)(struct sk_buff *skb, struct netlink_callback*), - int (*done)(struct netlink_callback*), - u16 min_dump_alloc); + struct netlink_dump_control *control); #define NL_NONROOT_RECV 0x1 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 65aebd450027..7aef62e53113 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1981,8 +1981,13 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) __rtnl_unlock(); rtnl = net->rtnl; - err = netlink_dump_start(rtnl, skb, nlh, dumpit, - NULL, min_dump_alloc); + { + struct netlink_dump_control c = { + .dump = dumpit, + .min_dump_alloc = min_dump_alloc, + }; + err = netlink_dump_start(rtnl, skb, nlh, &c); + } rtnl_lock(); return err; } diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index fcf281819cd4..8d25a1c557eb 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -960,9 +960,12 @@ static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh) inet_diag_bc_audit(nla_data(attr), nla_len(attr))) return -EINVAL; } - - return netlink_dump_start(sock_diag_nlsk, skb, nlh, - inet_diag_dump_compat, NULL, 0); + { + struct netlink_dump_control c = { + .dump = inet_diag_dump_compat, + }; + return netlink_dump_start(sock_diag_nlsk, skb, nlh, &c); + } } return inet_diag_get_exact_compat(skb, nlh); @@ -985,9 +988,12 @@ static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) inet_diag_bc_audit(nla_data(attr), nla_len(attr))) return -EINVAL; } - - return netlink_dump_start(sock_diag_nlsk, skb, h, - inet_diag_dump, NULL, 0); + { + struct netlink_dump_control c = { + .dump = inet_diag_dump, + }; + return netlink_dump_start(sock_diag_nlsk, skb, h, &c); + } } return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h)); diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index 32dbf0fa89db..e7f90e7082b4 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -1162,9 +1162,13 @@ ip_set_dump(struct sock *ctnl, struct sk_buff *skb, if (unlikely(protocol_failed(attr))) return -IPSET_ERR_PROTOCOL; - return netlink_dump_start(ctnl, skb, nlh, - ip_set_dump_start, - ip_set_dump_done, 0); + { + struct netlink_dump_control c = { + .dump = ip_set_dump_start, + .done = ip_set_dump_done, + }; + return netlink_dump_start(ctnl, skb, nlh, &c); + } } /* Add, del and test */ diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 9307b033c0c9..61f7feb7932b 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -977,9 +977,13 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, u16 zone; int err; - if (nlh->nlmsg_flags & NLM_F_DUMP) - return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table, - ctnetlink_done, 0); + if (nlh->nlmsg_flags & NLM_F_DUMP) { + struct netlink_dump_control c = { + .dump = ctnetlink_dump_table, + .done = ctnetlink_done, + }; + return netlink_dump_start(ctnl, skb, nlh, &c); + } err = ctnetlink_parse_zone(cda[CTA_ZONE], &zone); if (err < 0) @@ -1850,9 +1854,11 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, int err; if (nlh->nlmsg_flags & NLM_F_DUMP) { - return netlink_dump_start(ctnl, skb, nlh, - ctnetlink_exp_dump_table, - ctnetlink_exp_done, 0); + struct netlink_dump_control c = { + .dump = ctnetlink_exp_dump_table, + .done = ctnetlink_exp_done, + }; + return netlink_dump_start(ctnl, skb, nlh, &c); } err = ctnetlink_parse_zone(cda[CTA_EXPECT_ZONE], &zone); diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c index 11ba013e47f6..3eb348bfc4fb 100644 --- a/net/netfilter/nfnetlink_acct.c +++ b/net/netfilter/nfnetlink_acct.c @@ -171,8 +171,10 @@ nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb, char *acct_name; if (nlh->nlmsg_flags & NLM_F_DUMP) { - return netlink_dump_start(nfnl, skb, nlh, nfnl_acct_dump, - NULL, 0); + struct netlink_dump_control c = { + .dump = nfnl_acct_dump, + }; + return netlink_dump_start(nfnl, skb, nlh, &c); } if (!tb[NFACCT_NAME]) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 4d751e3d4b4b..ab74845876d2 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1736,10 +1736,7 @@ static int netlink_dump(struct sock *sk) int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, const struct nlmsghdr *nlh, - int (*dump)(struct sk_buff *skb, - struct netlink_callback *), - int (*done)(struct netlink_callback *), - u16 min_dump_alloc) + struct netlink_dump_control *control) { struct netlink_callback *cb; struct sock *sk; @@ -1750,10 +1747,10 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, if (cb == NULL) return -ENOBUFS; - cb->dump = dump; - cb->done = done; + cb->dump = control->dump; + cb->done = control->done; cb->nlh = nlh; - cb->min_dump_alloc = min_dump_alloc; + cb->min_dump_alloc = control->min_dump_alloc; atomic_inc(&skb->users); cb->skb = skb; diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index a1154717219e..9f40441d7a7d 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -563,8 +563,13 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) return -EOPNOTSUPP; genl_unlock(); - err = netlink_dump_start(net->genl_sock, skb, nlh, - ops->dumpit, ops->done, 0); + { + struct netlink_dump_control c = { + .dump = ops->dumpit, + .done = ops->done, + }; + err = netlink_dump_start(net->genl_sock, skb, nlh, &c); + } genl_lock(); return err; } diff --git a/net/unix/diag.c b/net/unix/diag.c index 6b7697fd911b..4195555aea65 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -301,10 +301,12 @@ static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) if (nlmsg_len(h) < hdrlen) return -EINVAL; - if (h->nlmsg_flags & NLM_F_DUMP) - return netlink_dump_start(sock_diag_nlsk, skb, h, - unix_diag_dump, NULL, 0); - else + if (h->nlmsg_flags & NLM_F_DUMP) { + struct netlink_dump_control c = { + .dump = unix_diag_dump, + }; + return netlink_dump_start(sock_diag_nlsk, skb, h, &c); + } else return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h)); } diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 66b84fbf2746..7128dde0fe1a 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -2299,8 +2299,13 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (link->dump == NULL) return -EINVAL; - return netlink_dump_start(net->xfrm.nlsk, skb, nlh, - link->dump, link->done, 0); + { + struct netlink_dump_control c = { + .dump = link->dump, + .done = link->done, + }; + return netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c); + } } err = nlmsg_parse(nlh, xfrm_msg_min[type], attrs, XFRMA_MAX, -- GitLab From 7175c883071515f0d4c1cece2646203b8a5a7415 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 24 Feb 2012 14:30:16 +0000 Subject: [PATCH 1120/1846] netlink: allow to pass data pointer to netlink_dump_start() callback This patch allows you to pass a data pointer that can be accessed from the dump callback. Netfilter is going to use this patch to provide filtered dumps to user-space. This is specifically interesting in ctnetlink that may handle lots of conntrack entries. We can save precious cycles by skipping the conversion to TLV format of conntrack entries that are not interesting for user-space. More specifically, ctnetlink will include one operation to allow to filter the dumping of conntrack entries by ctmark values. Signed-off-by: Pablo Neira Ayuso Signed-off-by: David S. Miller --- include/linux/netlink.h | 2 ++ net/netlink/af_netlink.c | 1 + 2 files changed, 3 insertions(+) diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 1f8c1a95f57c..a2092f582a78 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -225,6 +225,7 @@ struct netlink_callback { int (*dump)(struct sk_buff * skb, struct netlink_callback *cb); int (*done)(struct netlink_callback *cb); + void *data; u16 family; u16 min_dump_alloc; unsigned int prev_seq, seq; @@ -251,6 +252,7 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) struct netlink_dump_control { int (*dump)(struct sk_buff *skb, struct netlink_callback *); int (*done)(struct netlink_callback*); + void *data; u16 min_dump_alloc; }; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index ab74845876d2..32bb75324e76 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1750,6 +1750,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, cb->dump = control->dump; cb->done = control->done; cb->nlh = nlh; + cb->data = control->data; cb->min_dump_alloc = control->min_dump_alloc; atomic_inc(&skb->users); cb->skb = skb; -- GitLab From 0f298a285f2e365cb34f69d1f79bb9fc996f683d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 24 Feb 2012 14:41:50 +0000 Subject: [PATCH 1121/1846] netfilter: ctnetlink: support kernel-space dump filtering by ctmark This patch adds CTA_MARK_MASK which, together with CTA_MARK, allows you to selectively send conntrack entries to user-space by returning those that match mark & mask. With this, we can save cycles in the building and the parsing of the entries that may be later on filtered out in user-space by using the ctmark & mask. Signed-off-by: Pablo Neira Ayuso Signed-off-by: David S. Miller --- include/linux/netfilter/nfnetlink_conntrack.h | 1 + net/netfilter/nf_conntrack_netlink.c | 35 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index debf1aefd753..d498a4426ebf 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -43,6 +43,7 @@ enum ctattr_type { CTA_ZONE, CTA_SECCTX, CTA_TIMESTAMP, + CTA_MARK_MASK, __CTA_MAX }; #define CTA_MAX (__CTA_MAX - 1) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 61f7feb7932b..28d0312d890a 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -691,9 +691,18 @@ static int ctnetlink_done(struct netlink_callback *cb) { if (cb->args[1]) nf_ct_put((struct nf_conn *)cb->args[1]); + if (cb->data) + kfree(cb->data); return 0; } +struct ctnetlink_dump_filter { + struct { + u_int32_t val; + u_int32_t mask; + } mark; +}; + static int ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) { @@ -703,7 +712,9 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) struct hlist_nulls_node *n; struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh); u_int8_t l3proto = nfmsg->nfgen_family; - +#ifdef CONFIG_NF_CONNTRACK_MARK + const struct ctnetlink_dump_filter *filter = cb->data; +#endif spin_lock_bh(&nf_conntrack_lock); last = (struct nf_conn *)cb->args[1]; for (; cb->args[0] < net->ct.htable_size; cb->args[0]++) { @@ -723,6 +734,12 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) continue; cb->args[1] = 0; } +#ifdef CONFIG_NF_CONNTRACK_MARK + if (filter && !((ct->mark & filter->mark.mask) == + filter->mark.val)) { + continue; + } +#endif if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, NFNL_MSG_TYPE( @@ -894,6 +911,7 @@ static const struct nla_policy ct_nla_policy[CTA_MAX+1] = { [CTA_NAT_DST] = { .type = NLA_NESTED }, [CTA_TUPLE_MASTER] = { .type = NLA_NESTED }, [CTA_ZONE] = { .type = NLA_U16 }, + [CTA_MARK_MASK] = { .type = NLA_U32 }, }; static int @@ -982,6 +1000,21 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, .dump = ctnetlink_dump_table, .done = ctnetlink_done, }; +#ifdef CONFIG_NF_CONNTRACK_MARK + if (cda[CTA_MARK] && cda[CTA_MARK_MASK]) { + struct ctnetlink_dump_filter *filter; + + filter = kzalloc(sizeof(struct ctnetlink_dump_filter), + GFP_ATOMIC); + if (filter == NULL) + return -ENOMEM; + + filter->mark.val = ntohl(nla_get_be32(cda[CTA_MARK])); + filter->mark.mask = + ntohl(nla_get_be32(cda[CTA_MARK_MASK])); + c.data = filter; + } +#endif return netlink_dump_start(ctnl, skb, nlh, &c); } -- GitLab From 622121719934f60378279eb440d3cec2fc3176d2 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Sat, 25 Feb 2012 00:51:05 +0000 Subject: [PATCH 1122/1846] mlx4_en: dont change mac_header on xmit A driver xmit function is not allowed to change skb without special care. mlx4_en_xmit() should not call skb_reset_mac_header() and instead should use skb->data to access ethernet header. This removes a dumb test : if (ethh && ethh->h_dest) Also remove this slow mlx4_en_mac_to_u64() call, we can use get_unaligned() to get faster code. Signed-off-by: Eric Dumazet Cc: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 15 +++------------ include/linux/mlx4/qp.h | 5 ++++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index ff3250586584..2fd51405a509 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -601,8 +601,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) struct skb_frag_struct *frag; struct mlx4_en_tx_info *tx_info; struct ethhdr *ethh; - u64 mac; - u32 mac_l, mac_h; int tx_ind = 0; int nr_txbb; int desc_size; @@ -687,16 +685,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) } /* Copy dst mac address to wqe */ - skb_reset_mac_header(skb); - ethh = eth_hdr(skb); - if (ethh && ethh->h_dest) { - mac = mlx4_en_mac_to_u64(ethh->h_dest); - mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16); - mac_l = (u32) (mac & 0xffffffff); - tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h); - tx_desc->ctrl.imm = cpu_to_be32(mac_l); - } - + ethh = (struct ethhdr *)skb->data; + tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((u16 *)ethh->h_dest); + tx_desc->ctrl.imm = get_unaligned((u32 *)(ethh->h_dest + 2)); /* Handle LSO (TSO) packets */ if (lso_header_size) { /* Mark opcode as LSO */ diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h index bee8fa231276..091f9e7dc8b9 100644 --- a/include/linux/mlx4/qp.h +++ b/include/linux/mlx4/qp.h @@ -212,7 +212,10 @@ struct mlx4_wqe_ctrl_seg { * [1] SE (solicited event) * [0] FL (force loopback) */ - __be32 srcrb_flags; + union { + __be32 srcrb_flags; + __be16 srcrb_flags16[2]; + }; /* * imm is immediate data for send/RDMA write w/ immediate; * also invalidation key for send with invalidate; input -- GitLab From 816a11d5ced501d368fabe09172f3d62744e8b53 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sun, 26 Feb 2012 13:04:52 +0200 Subject: [PATCH 1123/1846] Bluetooth: Use kernel int types instead of ones from stdint.h u8/__u8/u32/etc should be used in the kernel instead of stdint.h types. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 4 ++-- net/bluetooth/bnep/sock.c | 6 +++--- net/bluetooth/cmtp/sock.c | 6 +++--- net/bluetooth/hidp/sock.c | 6 +++--- net/bluetooth/mgmt.c | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 05bd9aca4054..0c54fcfe7e0f 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -691,8 +691,8 @@ struct hci_cp_host_buffer_size { #define HCI_OP_WRITE_EIR 0x0c52 struct hci_cp_write_eir { - uint8_t fec; - uint8_t data[HCI_MAX_EIR_LENGTH]; + __u8 fec; + __u8 data[HCI_MAX_EIR_LENGTH]; } __packed; #define HCI_OP_READ_SSP_MODE 0x0c55 diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index 17800b1d28ea..9f9c8dcd8af0 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c @@ -143,10 +143,10 @@ static int bnep_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne { if (cmd == BNEPGETCONNLIST) { struct bnep_connlist_req cl; - uint32_t uci; + u32 uci; int err; - if (get_user(cl.cnum, (uint32_t __user *) arg) || + if (get_user(cl.cnum, (u32 __user *) arg) || get_user(uci, (u32 __user *) (arg + 4))) return -EFAULT; @@ -157,7 +157,7 @@ static int bnep_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne err = bnep_get_connlist(&cl); - if (!err && put_user(cl.cnum, (uint32_t __user *) arg)) + if (!err && put_user(cl.cnum, (u32 __user *) arg)) err = -EFAULT; return err; diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index 3f2dd5c25ae5..1230faaac29b 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c @@ -137,10 +137,10 @@ static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne { if (cmd == CMTPGETCONNLIST) { struct cmtp_connlist_req cl; - uint32_t uci; + u32 uci; int err; - if (get_user(cl.cnum, (uint32_t __user *) arg) || + if (get_user(cl.cnum, (u32 __user *) arg) || get_user(uci, (u32 __user *) (arg + 4))) return -EFAULT; @@ -151,7 +151,7 @@ static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne err = cmtp_get_connlist(&cl); - if (!err && put_user(cl.cnum, (uint32_t __user *) arg)) + if (!err && put_user(cl.cnum, (u32 __user *) arg)) err = -EFAULT; return err; diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 178ac7f127ad..73a32d705c1f 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -160,10 +160,10 @@ static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne { if (cmd == HIDPGETCONNLIST) { struct hidp_connlist_req cl; - uint32_t uci; + u32 uci; int err; - if (get_user(cl.cnum, (uint32_t __user *) arg) || + if (get_user(cl.cnum, (u32 __user *) arg) || get_user(uci, (u32 __user *) (arg + 4))) return -EFAULT; @@ -174,7 +174,7 @@ static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne err = hidp_get_connlist(&cl); - if (!err && put_user(cl.cnum, (uint32_t __user *) arg)) + if (!err && put_user(cl.cnum, (u32 __user *) arg)) err = -EFAULT; return err; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 07e31f73f703..27830f401698 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1075,7 +1075,7 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) struct mgmt_mode *cp = data; struct pending_cmd *cmd; struct hci_dev *hdev; - uint8_t val; + u8 val; int err; BT_DBG("request for hci%u", index); @@ -1147,7 +1147,7 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) struct mgmt_mode *cp = data; struct pending_cmd *cmd; struct hci_dev *hdev; - uint8_t val; + u8 val; int err; BT_DBG("request for hci%u", index); -- GitLab From d0ff7383a3164adff7072719717d574436ec1677 Mon Sep 17 00:00:00 2001 From: Naveen Gangadharan Date: Wed, 8 Feb 2012 17:51:36 -0800 Subject: [PATCH 1124/1846] ath6kl: Add unicast mgmt frame buffering PS buffering of unicast Action frames that are sent in a context of a BSS. In AP mode when the recepient station goes to powersave and PS_POLL flag is not set, we would buffer the frames. Send out unicast mgmt bufferred frame when PS_POLL is received. This fixes a bug in P2P GO behavior when sending a GO Discoverability Request to a client that is in sleep mode. kvalo: indentation fixes Signed-off-by: Thirumalai Pachamuthu Signed-off-by: Naveen Gangadharan Signed-off-by: Aarthi Thiruvengadam Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 98 ++++++++++++++++++---- drivers/net/wireless/ath/ath6kl/core.c | 2 + drivers/net/wireless/ath/ath6kl/core.h | 12 +++ drivers/net/wireless/ath/ath6kl/main.c | 41 +++++++-- drivers/net/wireless/ath/ath6kl/txrx.c | 25 ++++++ drivers/net/wireless/ath/ath6kl/wmi.c | 37 ++++++-- drivers/net/wireless/ath/ath6kl/wmi.h | 3 - 7 files changed, 188 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index a91f521c5227..86879896b1ab 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2573,6 +2573,76 @@ static int ath6kl_send_go_probe_resp(struct ath6kl_vif *vif, return ret; } +static bool ath6kl_mgmt_powersave_ap(struct ath6kl_vif *vif, + u32 id, + u32 freq, + u32 wait, + const u8 *buf, + size_t len, + bool *more_data, + bool no_cck) +{ + struct ieee80211_mgmt *mgmt; + struct ath6kl_sta *conn; + bool is_psq_empty = false; + struct ath6kl_mgmt_buff *mgmt_buf; + size_t mgmt_buf_size; + struct ath6kl *ar = vif->ar; + + mgmt = (struct ieee80211_mgmt *) buf; + if (is_multicast_ether_addr(mgmt->da)) + return false; + + conn = ath6kl_find_sta(vif, mgmt->da); + if (!conn) + return false; + + if (conn->sta_flags & STA_PS_SLEEP) { + if (!(conn->sta_flags & STA_PS_POLLED)) { + /* Queue the frames if the STA is sleeping */ + mgmt_buf_size = len + sizeof(struct ath6kl_mgmt_buff); + mgmt_buf = kmalloc(mgmt_buf_size, GFP_KERNEL); + if (!mgmt_buf) + return false; + + INIT_LIST_HEAD(&mgmt_buf->list); + mgmt_buf->id = id; + mgmt_buf->freq = freq; + mgmt_buf->wait = wait; + mgmt_buf->len = len; + mgmt_buf->no_cck = no_cck; + memcpy(mgmt_buf->buf, buf, len); + spin_lock_bh(&conn->psq_lock); + is_psq_empty = skb_queue_empty(&conn->psq) && + (conn->mgmt_psq_len == 0); + list_add_tail(&mgmt_buf->list, &conn->mgmt_psq); + conn->mgmt_psq_len++; + spin_unlock_bh(&conn->psq_lock); + + /* + * If this is the first pkt getting queued + * for this STA, update the PVB for this + * STA. + */ + if (is_psq_empty) + ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx, + conn->aid, 1); + return true; + } + + /* + * This tx is because of a PsPoll. + * Determine if MoreData bit has to be set. + */ + spin_lock_bh(&conn->psq_lock); + if (!skb_queue_empty(&conn->psq) || (conn->mgmt_psq_len != 0)) + *more_data = true; + spin_unlock_bh(&conn->psq_lock); + } + + return false; +} + static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, struct ieee80211_channel *chan, bool offchan, enum nl80211_channel_type channel_type, @@ -2584,6 +2654,7 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, struct ath6kl_vif *vif = netdev_priv(dev); u32 id; const struct ieee80211_mgmt *mgmt; + bool more_data, queued; mgmt = (const struct ieee80211_mgmt *) buf; if (buf + len >= mgmt->u.probe_resp.variable && @@ -2609,22 +2680,19 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev, *cookie = id; - if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, - ar->fw_capabilities)) { - /* - * If capable of doing P2P mgmt operations using - * station interface, send additional information like - * supported rates to advertise and xmit rates for - * probe requests - */ - return ath6kl_wmi_send_mgmt_cmd(ar->wmi, vif->fw_vif_idx, id, - chan->center_freq, wait, - buf, len, no_cck); - } else { - return ath6kl_wmi_send_action_cmd(ar->wmi, vif->fw_vif_idx, id, - chan->center_freq, wait, - buf, len); + /* AP mode Power saving processing */ + if (vif->nw_type == AP_NETWORK) { + queued = ath6kl_mgmt_powersave_ap(vif, + id, chan->center_freq, + wait, buf, + len, &more_data, no_cck); + if (queued) + return 0; } + + return ath6kl_wmi_send_mgmt_cmd(ar->wmi, vif->fw_vif_idx, id, + chan->center_freq, wait, + buf, len, no_cck); } static void ath6kl_mgmt_frame_register(struct wiphy *wiphy, diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index c4926cf11213..6dec186d9ac7 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -262,6 +262,8 @@ struct ath6kl *ath6kl_core_create(struct device *dev) spin_lock_init(&ar->sta_list[ctr].psq_lock); skb_queue_head_init(&ar->sta_list[ctr].psq); skb_queue_head_init(&ar->sta_list[ctr].apsdq); + ar->sta_list[ctr].mgmt_psq_len = 0; + INIT_LIST_HEAD(&ar->sta_list[ctr].mgmt_psq); ar->sta_list[ctr].aggr_conn = kzalloc(sizeof(struct aggr_info_conn), GFP_KERNEL); if (!ar->sta_list[ctr].aggr_conn) { diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index ec7d6b67b7ff..09efafa5fef1 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -286,6 +286,16 @@ struct ath6kl_cookie { struct ath6kl_cookie *arc_list_next; }; +struct ath6kl_mgmt_buff { + struct list_head list; + u32 freq; + u32 wait; + u32 id; + bool no_cck; + size_t len; + u8 buf[0]; +}; + struct ath6kl_sta { u16 sta_flags; u8 mac[ETH_ALEN]; @@ -296,6 +306,8 @@ struct ath6kl_sta { u8 wpa_ie[ATH6KL_MAX_IE]; struct sk_buff_head psq; spinlock_t psq_lock; + struct list_head mgmt_psq; + size_t mgmt_psq_len; u8 apsd_info; struct sk_buff_head apsdq; struct aggr_info_conn *aggr_conn; diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index d463a18332dc..0d6e352bfb17 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -81,11 +81,21 @@ static void ath6kl_add_new_sta(struct ath6kl_vif *vif, u8 *mac, u16 aid, static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i) { struct ath6kl_sta *sta = &ar->sta_list[i]; + struct ath6kl_mgmt_buff *entry, *tmp; /* empty the queued pkts in the PS queue if any */ spin_lock_bh(&sta->psq_lock); skb_queue_purge(&sta->psq); skb_queue_purge(&sta->apsdq); + + if (sta->mgmt_psq_len != 0) { + list_for_each_entry_safe(entry, tmp, &sta->mgmt_psq, list) { + kfree(entry); + } + INIT_LIST_HEAD(&sta->mgmt_psq); + sta->mgmt_psq_len = 0; + } + spin_unlock_bh(&sta->psq_lock); memset(&ar->ap_stats.sta[sta->aid - 1], 0, @@ -811,6 +821,7 @@ void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid) struct sk_buff *skb; bool psq_empty = false; struct ath6kl *ar = vif->ar; + struct ath6kl_mgmt_buff *mgmt_buf; conn = ath6kl_find_sta_by_aid(ar, aid); @@ -821,7 +832,7 @@ void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid) * becomes empty update the PVB for this station. */ spin_lock_bh(&conn->psq_lock); - psq_empty = skb_queue_empty(&conn->psq); + psq_empty = skb_queue_empty(&conn->psq) && (conn->mgmt_psq_len == 0); spin_unlock_bh(&conn->psq_lock); if (psq_empty) @@ -829,15 +840,31 @@ void ath6kl_pspoll_event(struct ath6kl_vif *vif, u8 aid) return; spin_lock_bh(&conn->psq_lock); - skb = skb_dequeue(&conn->psq); - spin_unlock_bh(&conn->psq_lock); + if (conn->mgmt_psq_len > 0) { + mgmt_buf = list_first_entry(&conn->mgmt_psq, + struct ath6kl_mgmt_buff, list); + list_del(&mgmt_buf->list); + conn->mgmt_psq_len--; + spin_unlock_bh(&conn->psq_lock); + + conn->sta_flags |= STA_PS_POLLED; + ath6kl_wmi_send_mgmt_cmd(ar->wmi, vif->fw_vif_idx, + mgmt_buf->id, mgmt_buf->freq, + mgmt_buf->wait, mgmt_buf->buf, + mgmt_buf->len, mgmt_buf->no_cck); + conn->sta_flags &= ~STA_PS_POLLED; + kfree(mgmt_buf); + } else { + skb = skb_dequeue(&conn->psq); + spin_unlock_bh(&conn->psq_lock); - conn->sta_flags |= STA_PS_POLLED; - ath6kl_data_tx(skb, vif->ndev); - conn->sta_flags &= ~STA_PS_POLLED; + conn->sta_flags |= STA_PS_POLLED; + ath6kl_data_tx(skb, vif->ndev); + conn->sta_flags &= ~STA_PS_POLLED; + } spin_lock_bh(&conn->psq_lock); - psq_empty = skb_queue_empty(&conn->psq); + psq_empty = skb_queue_empty(&conn->psq) && (conn->mgmt_psq_len == 0); spin_unlock_bh(&conn->psq_lock); if (psq_empty) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 87d46460a524..633637ace661 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1417,8 +1417,33 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) if (!(conn->sta_flags & STA_PS_SLEEP)) { struct sk_buff *skbuff = NULL; bool is_apsdq_empty; + struct ath6kl_mgmt_buff *mgmt; + u8 idx; spin_lock_bh(&conn->psq_lock); + while (conn->mgmt_psq_len > 0) { + mgmt = list_first_entry( + &conn->mgmt_psq, + struct ath6kl_mgmt_buff, + list); + list_del(&mgmt->list); + conn->mgmt_psq_len--; + spin_unlock_bh(&conn->psq_lock); + idx = vif->fw_vif_idx; + + ath6kl_wmi_send_mgmt_cmd(ar->wmi, + idx, + mgmt->id, + mgmt->freq, + mgmt->wait, + mgmt->buf, + mgmt->len, + mgmt->no_cck); + + kfree(mgmt); + spin_lock_bh(&conn->psq_lock); + } + conn->mgmt_psq_len = 0; while ((skbuff = skb_dequeue(&conn->psq))) { spin_unlock_bh(&conn->psq_lock); ath6kl_data_tx(skbuff, vif->ndev); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index bbbe0a74d3c3..fce29f7f2e5c 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -3182,8 +3182,9 @@ int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur) * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P * mgmt operations using station interface. */ -int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, - u32 wait, const u8 *data, u16 data_len) +static int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, + u32 freq, u32 wait, const u8 *data, + u16 data_len) { struct sk_buff *skb; struct wmi_send_action_cmd *p; @@ -3219,9 +3220,9 @@ int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, NO_SYNC_WMIFLAG); } -int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, - u32 wait, const u8 *data, u16 data_len, - u32 no_cck) +static int __ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, + u32 freq, u32 wait, const u8 *data, + u16 data_len, u32 no_cck) { struct sk_buff *skb; struct wmi_send_mgmt_cmd *p; @@ -3258,6 +3259,32 @@ int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, NO_SYNC_WMIFLAG); } +int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, + u32 wait, const u8 *data, u16 data_len, + u32 no_cck) +{ + int status; + struct ath6kl *ar = wmi->parent_dev; + + if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, + ar->fw_capabilities)) { + /* + * If capable of doing P2P mgmt operations using + * station interface, send additional information like + * supported rates to advertise and xmit rates for + * probe requests + */ + status = __ath6kl_wmi_send_mgmt_cmd(ar->wmi, if_idx, id, freq, + wait, data, data_len, + no_cck); + } else { + status = ath6kl_wmi_send_action_cmd(ar->wmi, if_idx, id, freq, + wait, data, data_len); + } + + return status; +} + int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, const u8 *dst, const u8 *data, u16 data_len) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index e7d031b8451d..38907f411225 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2506,9 +2506,6 @@ int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable); int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur); -int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, - u32 wait, const u8 *data, u16 data_len); - int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, u32 wait, const u8 *data, u16 data_len, u32 no_cck); -- GitLab From 0ea10f2b469ee51ed9948dd24cdd9582a98b885e Mon Sep 17 00:00:00 2001 From: Chilam Ng Date: Thu, 9 Feb 2012 02:17:01 -0800 Subject: [PATCH 1125/1846] ath6kl: assign Tx packet drop threshold per endpoint based on AC priority Tx packets will begin to drop when there are multiple traffic priorities and the current traffic is not the highest priority and the remaining cookies drop below a certain number, which is fixed for all AC. It is possilbe that lower priority AC have more traffic which will consume more cookies and lock out higher priority AC from having any. Assign each endpoint (AC) with a different Tx-packet-drop threshold so lower priority AC is more likely to drop packets and the cookies become more available to higher priority AC. Signed-off-by: Chilam Ng Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/htc.c | 9 +++++++++ drivers/net/wireless/ath/ath6kl/htc.h | 1 + drivers/net/wireless/ath/ath6kl/txrx.c | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index c703ef9c5313..920e7c07fd4f 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2483,6 +2483,15 @@ int ath6kl_htc_conn_service(struct htc_target *target, endpoint->cred_dist.endpoint = assigned_ep; endpoint->cred_dist.cred_sz = target->tgt_cred_sz; + switch (endpoint->svc_id) { + case WMI_DATA_BK_SVC: + endpoint->tx_drop_packet_threshold = MAX_DEF_COOKIE_NUM / 3; + break; + default: + endpoint->tx_drop_packet_threshold = MAX_HI_COOKIE_NUM; + break; + } + if (conn_req->max_rxmsg_sz) { /* * Override cred_per_msg calculation, this optimizes diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 519766571334..2de4d6fc1e32 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -501,6 +501,7 @@ struct htc_endpoint { u8 seqno; u32 conn_flags; struct htc_endpoint_stats ep_st; + u16 tx_drop_packet_threshold; }; struct htc_control_buffer { diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 633637ace661..802291346d30 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -594,7 +594,8 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, */ if (ar->ac_stream_pri_map[ar->ep2ac_map[endpoint]] < ar->hiac_stream_active_pri && - ar->cookie_count <= MAX_HI_COOKIE_NUM) + ar->cookie_count <= + target->endpoint[endpoint].tx_drop_packet_threshold) /* * Give preference to the highest priority stream by * dropping the packets which overflowed. -- GitLab From e8ad9a0638cb50dad48201f461f4739740f036b3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 14 Feb 2012 20:32:59 +0530 Subject: [PATCH 1126/1846] ath6kl: Fix missing release of semaphore in ath6kl_stop_txrx() This fixes smatch warning "inconsistent returns sem:&ar->sem". Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 72f1b4f52b2e..6fed6280174f 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1733,5 +1733,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar) ath6kl_reset_device(ar, ar->target_type, true, true); clear_bit(WLAN_ENABLED, &ar->flag); + + up(&ar->sem); } EXPORT_SYMBOL(ath6kl_stop_txrx); -- GitLab From cc4d623de46616825d9330467e0a7375835171be Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 14 Feb 2012 20:33:00 +0530 Subject: [PATCH 1127/1846] ath6kl: Remove bogus non-NULL pointer check In ath6kl_cfg80211_add_key(), params is checked for non-NULL but this pointer has been deferenced many times before this check. This gives the following smatch warning. add_key() can never carry NULL as params, remove this bogus check. ath6kl_cfg80211_add_key(86) warn: variable dereferenced before check 'params' Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 86879896b1ab..a47688054ce9 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1059,7 +1059,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, if (vif->nw_type == AP_NETWORK && !pairwise && (key_type == TKIP_CRYPT || key_type == AES_CRYPT || - key_type == WAPI_CRYPT) && params) { + key_type == WAPI_CRYPT)) { ar->ap_mode_bkey.valid = true; ar->ap_mode_bkey.key_index = key_index; ar->ap_mode_bkey.key_type = key_type; -- GitLab From d42a179b941a9e4cc6cf41d0f3cbadd75fc48a89 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Sat, 11 Feb 2012 21:58:09 +0100 Subject: [PATCH 1128/1846] rt2x00: Add support for D-Link DWA-127 to rt2800usb. This is an RT3070 based device. Cc: Reported-by: Mikhail Kryshen 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(+) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index d009b6b794bb..0074c4e18d29 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -921,6 +921,7 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x07d1, 0x3c13) }, { USB_DEVICE(0x07d1, 0x3c15) }, { USB_DEVICE(0x07d1, 0x3c16) }, + { USB_DEVICE(0x2001, 0x3c1b) }, /* Draytek */ { USB_DEVICE(0x07fa, 0x7712) }, /* DVICO */ -- GitLab From 14fec8d9baffc026beaffa2ee9e911df9d1d4ad2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 15 Feb 2012 21:53:16 +0100 Subject: [PATCH 1129/1846] ath9k_hw: remove duplicate initvals Comparing SHA1 checksums of the initval tables has shown that there are many tables that are 100% identical. iniBank{0,1,2,3,7} and iniBB_RfGain are shared by AR5416, AR913x, AR9160 iniBank6 is shared between AR5416 and AR9160 iniBank6TPC is shared between AR913x and AR9160 iniPcieSerdes is the same for all AR9002 based devices The CCK FIR coefficients are shared between AR9271 and AR9287 Getting rid of those duplicates saves about 7.5k uncompressed (on MIPS). For AR9003 and later there are some duplicates as well, but I've decided to leave them in for now, as the initvals for those chips are still actively maintained by QCA. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- .../net/wireless/ath/ath9k/ar9001_initvals.h | 270 ------------------ drivers/net/wireless/ath/ath9k/ar9002_hw.c | 107 +++---- .../net/wireless/ath/ath9k/ar9002_initvals.h | 98 ------- 3 files changed, 34 insertions(+), 441 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9001_initvals.h b/drivers/net/wireless/ath/ath9k/ar9001_initvals.h index e8bdc75405f1..ea4a230997ac 100644 --- a/drivers/net/wireless/ath/ath9k/ar9001_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9001_initvals.h @@ -459,97 +459,6 @@ static const u32 ar5416Common_9100[][2] = { {0x0000a3e0, 0x000001ce}, }; -static const u32 ar5416Bank0_9100[][2] = { - /* Addr allmodes */ - {0x000098b0, 0x1e5795e5}, - {0x000098e0, 0x02008020}, -}; - -static const u32 ar5416BB_RfGain_9100[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x00009a00, 0x00000000, 0x00000000}, - {0x00009a04, 0x00000040, 0x00000040}, - {0x00009a08, 0x00000080, 0x00000080}, - {0x00009a0c, 0x000001a1, 0x00000141}, - {0x00009a10, 0x000001e1, 0x00000181}, - {0x00009a14, 0x00000021, 0x000001c1}, - {0x00009a18, 0x00000061, 0x00000001}, - {0x00009a1c, 0x00000168, 0x00000041}, - {0x00009a20, 0x000001a8, 0x000001a8}, - {0x00009a24, 0x000001e8, 0x000001e8}, - {0x00009a28, 0x00000028, 0x00000028}, - {0x00009a2c, 0x00000068, 0x00000068}, - {0x00009a30, 0x00000189, 0x000000a8}, - {0x00009a34, 0x000001c9, 0x00000169}, - {0x00009a38, 0x00000009, 0x000001a9}, - {0x00009a3c, 0x00000049, 0x000001e9}, - {0x00009a40, 0x00000089, 0x00000029}, - {0x00009a44, 0x00000170, 0x00000069}, - {0x00009a48, 0x000001b0, 0x00000190}, - {0x00009a4c, 0x000001f0, 0x000001d0}, - {0x00009a50, 0x00000030, 0x00000010}, - {0x00009a54, 0x00000070, 0x00000050}, - {0x00009a58, 0x00000191, 0x00000090}, - {0x00009a5c, 0x000001d1, 0x00000151}, - {0x00009a60, 0x00000011, 0x00000191}, - {0x00009a64, 0x00000051, 0x000001d1}, - {0x00009a68, 0x00000091, 0x00000011}, - {0x00009a6c, 0x000001b8, 0x00000051}, - {0x00009a70, 0x000001f8, 0x00000198}, - {0x00009a74, 0x00000038, 0x000001d8}, - {0x00009a78, 0x00000078, 0x00000018}, - {0x00009a7c, 0x00000199, 0x00000058}, - {0x00009a80, 0x000001d9, 0x00000098}, - {0x00009a84, 0x00000019, 0x00000159}, - {0x00009a88, 0x00000059, 0x00000199}, - {0x00009a8c, 0x00000099, 0x000001d9}, - {0x00009a90, 0x000000d9, 0x00000019}, - {0x00009a94, 0x000000f9, 0x00000059}, - {0x00009a98, 0x000000f9, 0x00000099}, - {0x00009a9c, 0x000000f9, 0x000000d9}, - {0x00009aa0, 0x000000f9, 0x000000f9}, - {0x00009aa4, 0x000000f9, 0x000000f9}, - {0x00009aa8, 0x000000f9, 0x000000f9}, - {0x00009aac, 0x000000f9, 0x000000f9}, - {0x00009ab0, 0x000000f9, 0x000000f9}, - {0x00009ab4, 0x000000f9, 0x000000f9}, - {0x00009ab8, 0x000000f9, 0x000000f9}, - {0x00009abc, 0x000000f9, 0x000000f9}, - {0x00009ac0, 0x000000f9, 0x000000f9}, - {0x00009ac4, 0x000000f9, 0x000000f9}, - {0x00009ac8, 0x000000f9, 0x000000f9}, - {0x00009acc, 0x000000f9, 0x000000f9}, - {0x00009ad0, 0x000000f9, 0x000000f9}, - {0x00009ad4, 0x000000f9, 0x000000f9}, - {0x00009ad8, 0x000000f9, 0x000000f9}, - {0x00009adc, 0x000000f9, 0x000000f9}, - {0x00009ae0, 0x000000f9, 0x000000f9}, - {0x00009ae4, 0x000000f9, 0x000000f9}, - {0x00009ae8, 0x000000f9, 0x000000f9}, - {0x00009aec, 0x000000f9, 0x000000f9}, - {0x00009af0, 0x000000f9, 0x000000f9}, - {0x00009af4, 0x000000f9, 0x000000f9}, - {0x00009af8, 0x000000f9, 0x000000f9}, - {0x00009afc, 0x000000f9, 0x000000f9}, -}; - -static const u32 ar5416Bank1_9100[][2] = { - /* Addr allmodes */ - {0x000098b0, 0x02108421}, - {0x000098ec, 0x00000008}, -}; - -static const u32 ar5416Bank2_9100[][2] = { - /* Addr allmodes */ - {0x000098b0, 0x0e73ff17}, - {0x000098e0, 0x00000420}, -}; - -static const u32 ar5416Bank3_9100[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x000098f0, 0x01400018, 0x01c00018}, -}; - static const u32 ar5416Bank6_9100[][3] = { /* Addr 5G_HT20 5G_HT40 */ {0x0000989c, 0x00000000, 0x00000000}, @@ -624,13 +533,6 @@ static const u32 ar5416Bank6TPC_9100[][3] = { {0x000098d0, 0x0000000f, 0x0010000f}, }; -static const u32 ar5416Bank7_9100[][2] = { - /* Addr allmodes */ - {0x0000989c, 0x00000500}, - {0x0000989c, 0x00000800}, - {0x000098cc, 0x0000000e}, -}; - static const u32 ar5416Addac_9100[][2] = { /* Addr allmodes */ {0x0000989c, 0x00000000}, @@ -1113,178 +1015,6 @@ static const u32 ar5416Common_9160[][2] = { {0x0000a3e0, 0x000001ce}, }; -static const u32 ar5416Bank0_9160[][2] = { - /* Addr allmodes */ - {0x000098b0, 0x1e5795e5}, - {0x000098e0, 0x02008020}, -}; - -static const u32 ar5416BB_RfGain_9160[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x00009a00, 0x00000000, 0x00000000}, - {0x00009a04, 0x00000040, 0x00000040}, - {0x00009a08, 0x00000080, 0x00000080}, - {0x00009a0c, 0x000001a1, 0x00000141}, - {0x00009a10, 0x000001e1, 0x00000181}, - {0x00009a14, 0x00000021, 0x000001c1}, - {0x00009a18, 0x00000061, 0x00000001}, - {0x00009a1c, 0x00000168, 0x00000041}, - {0x00009a20, 0x000001a8, 0x000001a8}, - {0x00009a24, 0x000001e8, 0x000001e8}, - {0x00009a28, 0x00000028, 0x00000028}, - {0x00009a2c, 0x00000068, 0x00000068}, - {0x00009a30, 0x00000189, 0x000000a8}, - {0x00009a34, 0x000001c9, 0x00000169}, - {0x00009a38, 0x00000009, 0x000001a9}, - {0x00009a3c, 0x00000049, 0x000001e9}, - {0x00009a40, 0x00000089, 0x00000029}, - {0x00009a44, 0x00000170, 0x00000069}, - {0x00009a48, 0x000001b0, 0x00000190}, - {0x00009a4c, 0x000001f0, 0x000001d0}, - {0x00009a50, 0x00000030, 0x00000010}, - {0x00009a54, 0x00000070, 0x00000050}, - {0x00009a58, 0x00000191, 0x00000090}, - {0x00009a5c, 0x000001d1, 0x00000151}, - {0x00009a60, 0x00000011, 0x00000191}, - {0x00009a64, 0x00000051, 0x000001d1}, - {0x00009a68, 0x00000091, 0x00000011}, - {0x00009a6c, 0x000001b8, 0x00000051}, - {0x00009a70, 0x000001f8, 0x00000198}, - {0x00009a74, 0x00000038, 0x000001d8}, - {0x00009a78, 0x00000078, 0x00000018}, - {0x00009a7c, 0x00000199, 0x00000058}, - {0x00009a80, 0x000001d9, 0x00000098}, - {0x00009a84, 0x00000019, 0x00000159}, - {0x00009a88, 0x00000059, 0x00000199}, - {0x00009a8c, 0x00000099, 0x000001d9}, - {0x00009a90, 0x000000d9, 0x00000019}, - {0x00009a94, 0x000000f9, 0x00000059}, - {0x00009a98, 0x000000f9, 0x00000099}, - {0x00009a9c, 0x000000f9, 0x000000d9}, - {0x00009aa0, 0x000000f9, 0x000000f9}, - {0x00009aa4, 0x000000f9, 0x000000f9}, - {0x00009aa8, 0x000000f9, 0x000000f9}, - {0x00009aac, 0x000000f9, 0x000000f9}, - {0x00009ab0, 0x000000f9, 0x000000f9}, - {0x00009ab4, 0x000000f9, 0x000000f9}, - {0x00009ab8, 0x000000f9, 0x000000f9}, - {0x00009abc, 0x000000f9, 0x000000f9}, - {0x00009ac0, 0x000000f9, 0x000000f9}, - {0x00009ac4, 0x000000f9, 0x000000f9}, - {0x00009ac8, 0x000000f9, 0x000000f9}, - {0x00009acc, 0x000000f9, 0x000000f9}, - {0x00009ad0, 0x000000f9, 0x000000f9}, - {0x00009ad4, 0x000000f9, 0x000000f9}, - {0x00009ad8, 0x000000f9, 0x000000f9}, - {0x00009adc, 0x000000f9, 0x000000f9}, - {0x00009ae0, 0x000000f9, 0x000000f9}, - {0x00009ae4, 0x000000f9, 0x000000f9}, - {0x00009ae8, 0x000000f9, 0x000000f9}, - {0x00009aec, 0x000000f9, 0x000000f9}, - {0x00009af0, 0x000000f9, 0x000000f9}, - {0x00009af4, 0x000000f9, 0x000000f9}, - {0x00009af8, 0x000000f9, 0x000000f9}, - {0x00009afc, 0x000000f9, 0x000000f9}, -}; - -static const u32 ar5416Bank1_9160[][2] = { - /* Addr allmodes */ - {0x000098b0, 0x02108421}, - {0x000098ec, 0x00000008}, -}; - -static const u32 ar5416Bank2_9160[][2] = { - /* Addr allmodes */ - {0x000098b0, 0x0e73ff17}, - {0x000098e0, 0x00000420}, -}; - -static const u32 ar5416Bank3_9160[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x000098f0, 0x01400018, 0x01c00018}, -}; - -static const u32 ar5416Bank6_9160[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x0000989c, 0x00000000, 0x00000000}, - {0x0000989c, 0x00000000, 0x00000000}, - {0x0000989c, 0x00000000, 0x00000000}, - {0x0000989c, 0x00e00000, 0x00e00000}, - {0x0000989c, 0x005e0000, 0x005e0000}, - {0x0000989c, 0x00120000, 0x00120000}, - {0x0000989c, 0x00620000, 0x00620000}, - {0x0000989c, 0x00020000, 0x00020000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x40ff0000, 0x40ff0000}, - {0x0000989c, 0x005f0000, 0x005f0000}, - {0x0000989c, 0x00870000, 0x00870000}, - {0x0000989c, 0x00f90000, 0x00f90000}, - {0x0000989c, 0x007b0000, 0x007b0000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x00f50000, 0x00f50000}, - {0x0000989c, 0x00dc0000, 0x00dc0000}, - {0x0000989c, 0x00110000, 0x00110000}, - {0x0000989c, 0x006100a8, 0x006100a8}, - {0x0000989c, 0x004210a2, 0x004210a2}, - {0x0000989c, 0x0014008f, 0x0014008f}, - {0x0000989c, 0x00c40003, 0x00c40003}, - {0x0000989c, 0x003000f2, 0x003000f2}, - {0x0000989c, 0x00440016, 0x00440016}, - {0x0000989c, 0x00410040, 0x00410040}, - {0x0000989c, 0x0001805e, 0x0001805e}, - {0x0000989c, 0x0000c0ab, 0x0000c0ab}, - {0x0000989c, 0x000000f1, 0x000000f1}, - {0x0000989c, 0x00002081, 0x00002081}, - {0x0000989c, 0x000000d4, 0x000000d4}, - {0x000098d0, 0x0000000f, 0x0010000f}, -}; - -static const u32 ar5416Bank6TPC_9160[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x0000989c, 0x00000000, 0x00000000}, - {0x0000989c, 0x00000000, 0x00000000}, - {0x0000989c, 0x00000000, 0x00000000}, - {0x0000989c, 0x00e00000, 0x00e00000}, - {0x0000989c, 0x005e0000, 0x005e0000}, - {0x0000989c, 0x00120000, 0x00120000}, - {0x0000989c, 0x00620000, 0x00620000}, - {0x0000989c, 0x00020000, 0x00020000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x40ff0000, 0x40ff0000}, - {0x0000989c, 0x005f0000, 0x005f0000}, - {0x0000989c, 0x00870000, 0x00870000}, - {0x0000989c, 0x00f90000, 0x00f90000}, - {0x0000989c, 0x007b0000, 0x007b0000}, - {0x0000989c, 0x00ff0000, 0x00ff0000}, - {0x0000989c, 0x00f50000, 0x00f50000}, - {0x0000989c, 0x00dc0000, 0x00dc0000}, - {0x0000989c, 0x00110000, 0x00110000}, - {0x0000989c, 0x006100a8, 0x006100a8}, - {0x0000989c, 0x00423022, 0x00423022}, - {0x0000989c, 0x2014008f, 0x2014008f}, - {0x0000989c, 0x00c40002, 0x00c40002}, - {0x0000989c, 0x003000f2, 0x003000f2}, - {0x0000989c, 0x00440016, 0x00440016}, - {0x0000989c, 0x00410040, 0x00410040}, - {0x0000989c, 0x0001805e, 0x0001805e}, - {0x0000989c, 0x0000c0ab, 0x0000c0ab}, - {0x0000989c, 0x000000e1, 0x000000e1}, - {0x0000989c, 0x00007080, 0x00007080}, - {0x0000989c, 0x000000d4, 0x000000d4}, - {0x000098d0, 0x0000000f, 0x0010000f}, -}; - -static const u32 ar5416Bank7_9160[][2] = { - /* Addr allmodes */ - {0x0000989c, 0x00000500}, - {0x0000989c, 0x00000800}, - {0x000098cc, 0x0000000e}, -}; - static const u32 ar5416Addac_9160[][2] = { /* Addr allmodes */ {0x0000989c, 0x00000000}, diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 11f192a1ceb7..d48f5fe8af7f 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -35,11 +35,11 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, ARRAY_SIZE(ar9271Common_9271), 2); INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271, - ar9271Common_normal_cck_fir_coeff_9271, - ARRAY_SIZE(ar9271Common_normal_cck_fir_coeff_9271), 2); + ar9287Common_normal_cck_fir_coeff_9287_1_1, + ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_9287_1_1), 2); INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271, - ar9271Common_japan_2484_cck_fir_coeff_9271, - ARRAY_SIZE(ar9271Common_japan_2484_cck_fir_coeff_9271), 2); + ar9287Common_japan_2484_cck_fir_coeff_9287_1_1, + ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_9287_1_1), 2); INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, ar9271Modes_9271_1_0_only, ARRAY_SIZE(ar9271Modes_9271_1_0_only), 5); @@ -54,53 +54,31 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) return; } + if (ah->config.pcie_clock_req) + INIT_INI_ARRAY(&ah->iniPcieSerdes, + ar9280PciePhy_clkreq_off_L1_9280, + ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280), 2); + else + INIT_INI_ARRAY(&ah->iniPcieSerdes, + ar9280PciePhy_clkreq_always_on_L1_9280, + ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2); + if (AR_SREV_9287_11_OR_LATER(ah)) { INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1, ARRAY_SIZE(ar9287Modes_9287_1_1), 5); INIT_INI_ARRAY(&ah->iniCommon, ar9287Common_9287_1_1, ARRAY_SIZE(ar9287Common_9287_1_1), 2); - if (ah->config.pcie_clock_req) - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9287PciePhy_clkreq_off_L1_9287_1_1, - ARRAY_SIZE(ar9287PciePhy_clkreq_off_L1_9287_1_1), 2); - else - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9287PciePhy_clkreq_always_on_L1_9287_1_1, - ARRAY_SIZE(ar9287PciePhy_clkreq_always_on_L1_9287_1_1), - 2); } else if (AR_SREV_9285_12_OR_LATER(ah)) { - - INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285_1_2, ARRAY_SIZE(ar9285Modes_9285_1_2), 5); INIT_INI_ARRAY(&ah->iniCommon, ar9285Common_9285_1_2, ARRAY_SIZE(ar9285Common_9285_1_2), 2); - - if (ah->config.pcie_clock_req) { - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9285PciePhy_clkreq_off_L1_9285_1_2, - ARRAY_SIZE(ar9285PciePhy_clkreq_off_L1_9285_1_2), 2); - } else { - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9285PciePhy_clkreq_always_on_L1_9285_1_2, - ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285_1_2), - 2); - } } else if (AR_SREV_9280_20_OR_LATER(ah)) { INIT_INI_ARRAY(&ah->iniModes, ar9280Modes_9280_2, ARRAY_SIZE(ar9280Modes_9280_2), 5); INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2, ARRAY_SIZE(ar9280Common_9280_2), 2); - if (ah->config.pcie_clock_req) { - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9280PciePhy_clkreq_off_L1_9280, - ARRAY_SIZE(ar9280PciePhy_clkreq_off_L1_9280), 2); - } else { - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9280PciePhy_clkreq_always_on_L1_9280, - ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2); - } INIT_INI_ARRAY(&ah->iniModesAdditional, ar9280Modes_fast_clock_9280_2, ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3); @@ -109,22 +87,6 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar5416Modes_9160), 5); INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9160, ARRAY_SIZE(ar5416Common_9160), 2); - INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9160, - ARRAY_SIZE(ar5416Bank0_9160), 2); - INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9160, - ARRAY_SIZE(ar5416BB_RfGain_9160), 3); - INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9160, - ARRAY_SIZE(ar5416Bank1_9160), 2); - INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9160, - ARRAY_SIZE(ar5416Bank2_9160), 2); - INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9160, - ARRAY_SIZE(ar5416Bank3_9160), 3); - INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9160, - ARRAY_SIZE(ar5416Bank6_9160), 3); - INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9160, - ARRAY_SIZE(ar5416Bank6TPC_9160), 3); - INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9160, - ARRAY_SIZE(ar5416Bank7_9160), 2); if (AR_SREV_9160_11(ah)) { INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9160_1_1, @@ -138,22 +100,8 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar5416Modes_9100), 5); INIT_INI_ARRAY(&ah->iniCommon, ar5416Common_9100, ARRAY_SIZE(ar5416Common_9100), 2); - INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0_9100, - ARRAY_SIZE(ar5416Bank0_9100), 2); - INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain_9100, - ARRAY_SIZE(ar5416BB_RfGain_9100), 3); - INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1_9100, - ARRAY_SIZE(ar5416Bank1_9100), 2); - INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2_9100, - ARRAY_SIZE(ar5416Bank2_9100), 2); - INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3_9100, - ARRAY_SIZE(ar5416Bank3_9100), 3); INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6_9100, ARRAY_SIZE(ar5416Bank6_9100), 3); - INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100, - ARRAY_SIZE(ar5416Bank6TPC_9100), 3); - INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7_9100, - ARRAY_SIZE(ar5416Bank7_9100), 2); INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac_9100, ARRAY_SIZE(ar5416Addac_9100), 2); } else { @@ -161,24 +109,37 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar5416Modes), 5); INIT_INI_ARRAY(&ah->iniCommon, ar5416Common, ARRAY_SIZE(ar5416Common), 2); - INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0, - ARRAY_SIZE(ar5416Bank0), 2); + INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC, + ARRAY_SIZE(ar5416Bank6TPC), 3); + INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, + ARRAY_SIZE(ar5416Addac), 2); + } + + if (!AR_SREV_9280_20_OR_LATER(ah)) { + /* Common for AR5416, AR913x, AR9160 */ INIT_INI_ARRAY(&ah->iniBB_RfGain, ar5416BB_RfGain, ARRAY_SIZE(ar5416BB_RfGain), 3); + + INIT_INI_ARRAY(&ah->iniBank0, ar5416Bank0, + ARRAY_SIZE(ar5416Bank0), 2); INIT_INI_ARRAY(&ah->iniBank1, ar5416Bank1, ARRAY_SIZE(ar5416Bank1), 2); INIT_INI_ARRAY(&ah->iniBank2, ar5416Bank2, ARRAY_SIZE(ar5416Bank2), 2); INIT_INI_ARRAY(&ah->iniBank3, ar5416Bank3, ARRAY_SIZE(ar5416Bank3), 3); - INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6, - ARRAY_SIZE(ar5416Bank6), 3); - INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC, - ARRAY_SIZE(ar5416Bank6TPC), 3); INIT_INI_ARRAY(&ah->iniBank7, ar5416Bank7, ARRAY_SIZE(ar5416Bank7), 2); - INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, - ARRAY_SIZE(ar5416Addac), 2); + + /* Common for AR5416, AR9160 */ + if (!AR_SREV_9100(ah)) + INIT_INI_ARRAY(&ah->iniBank6, ar5416Bank6, + ARRAY_SIZE(ar5416Bank6), 3); + + /* Common for AR913x, AR9160 */ + if (!AR_SREV_5416(ah)) + INIT_INI_ARRAY(&ah->iniBank6TPC, ar5416Bank6TPC_9100, + ARRAY_SIZE(ar5416Bank6TPC_9100), 3); } } diff --git a/drivers/net/wireless/ath/ath9k/ar9002_initvals.h b/drivers/net/wireless/ath/ath9k/ar9002_initvals.h index 863db321070d..d571c329ee59 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9002_initvals.h @@ -925,34 +925,6 @@ static const u32 ar9280PciePhy_clkreq_always_on_L1_9280[][2] = { {0x00004044, 0x00000000}, }; -static const u32 ar9285PciePhy_clkreq_always_on_L1_9285[][2] = { - /* Addr allmodes */ - {0x00004040, 0x9248fd00}, - {0x00004040, 0x24924924}, - {0x00004040, 0xa8000019}, - {0x00004040, 0x13160820}, - {0x00004040, 0xe5980560}, - {0x00004040, 0xc01dcffd}, - {0x00004040, 0x1aaabe41}, - {0x00004040, 0xbe105554}, - {0x00004040, 0x00043007}, - {0x00004044, 0x00000000}, -}; - -static const u32 ar9285PciePhy_clkreq_off_L1_9285[][2] = { - /* Addr allmodes */ - {0x00004040, 0x9248fd00}, - {0x00004040, 0x24924924}, - {0x00004040, 0xa8000019}, - {0x00004040, 0x13160820}, - {0x00004040, 0xe5980560}, - {0x00004040, 0xc01dcffc}, - {0x00004040, 0x1aaabe41}, - {0x00004040, 0xbe105554}, - {0x00004040, 0x00043007}, - {0x00004044, 0x00000000}, -}; - static const u32 ar9285Modes_9285_1_2[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160}, @@ -1743,34 +1715,6 @@ static const u32 ar9285Modes_XE2_0_high_power[][5] = { {0x0000a3e0, 0x000000e7, 0x000000e7, 0x000000e7, 0x000000e7}, }; -static const u32 ar9285PciePhy_clkreq_always_on_L1_9285_1_2[][2] = { - /* Addr allmodes */ - {0x00004040, 0x9248fd00}, - {0x00004040, 0x24924924}, - {0x00004040, 0xa8000019}, - {0x00004040, 0x13160820}, - {0x00004040, 0xe5980560}, - {0x00004040, 0xc01dcffd}, - {0x00004040, 0x1aaabe41}, - {0x00004040, 0xbe105554}, - {0x00004040, 0x00043007}, - {0x00004044, 0x00000000}, -}; - -static const u32 ar9285PciePhy_clkreq_off_L1_9285_1_2[][2] = { - /* Addr allmodes */ - {0x00004040, 0x9248fd00}, - {0x00004040, 0x24924924}, - {0x00004040, 0xa8000019}, - {0x00004040, 0x13160820}, - {0x00004040, 0xe5980560}, - {0x00004040, 0xc01dcffc}, - {0x00004040, 0x1aaabe41}, - {0x00004040, 0xbe105554}, - {0x00004040, 0x00043007}, - {0x00004044, 0x00000000}, -}; - static const u32 ar9287Modes_9287_1_1[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00001030, 0x00000000, 0x00000000, 0x000002c0, 0x00000160}, @@ -2512,34 +2456,6 @@ static const u32 ar9287Modes_rx_gain_9287_1_1[][5] = { {0x0000a848, 0x00000000, 0x00000000, 0x00001067, 0x00001067}, }; -static const u32 ar9287PciePhy_clkreq_always_on_L1_9287_1_1[][2] = { - /* Addr allmodes */ - {0x00004040, 0x9248fd00}, - {0x00004040, 0x24924924}, - {0x00004040, 0xa8000019}, - {0x00004040, 0x13160820}, - {0x00004040, 0xe5980560}, - {0x00004040, 0xc01dcffd}, - {0x00004040, 0x1aaabe41}, - {0x00004040, 0xbe105554}, - {0x00004040, 0x00043007}, - {0x00004044, 0x00000000}, -}; - -static const u32 ar9287PciePhy_clkreq_off_L1_9287_1_1[][2] = { - /* Addr allmodes */ - {0x00004040, 0x9248fd00}, - {0x00004040, 0x24924924}, - {0x00004040, 0xa8000019}, - {0x00004040, 0x13160820}, - {0x00004040, 0xe5980560}, - {0x00004040, 0xc01dcffc}, - {0x00004040, 0x1aaabe41}, - {0x00004040, 0xbe105554}, - {0x00004040, 0x00043007}, - {0x00004044, 0x00000000}, -}; - static const u32 ar9271Modes_9271[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160}, @@ -3176,20 +3092,6 @@ static const u32 ar9271Common_9271[][2] = { {0x0000d384, 0xf3307ff0}, }; -static const u32 ar9271Common_normal_cck_fir_coeff_9271[][2] = { - /* Addr allmodes */ - {0x0000a1f4, 0x00fffeff}, - {0x0000a1f8, 0x00f5f9ff}, - {0x0000a1fc, 0xb79f6427}, -}; - -static const u32 ar9271Common_japan_2484_cck_fir_coeff_9271[][2] = { - /* Addr allmodes */ - {0x0000a1f4, 0x00000000}, - {0x0000a1f8, 0xefff0301}, - {0x0000a1fc, 0xca9228ee}, -}; - static const u32 ar9271Modes_9271_1_0_only[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00009910, 0x30002311, 0x30002311, 0x30002311, 0x30002311}, -- GitLab From 25d78d305ff7187837d3535cdda997ad91352fde Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:50:55 +0530 Subject: [PATCH 1130/1846] ath9k: Remove unnecessary variable initialization Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/debug.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 68d972bf232d..dc45cf91aba2 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -1677,10 +1677,5 @@ int ath9k_init_debug(struct ath_hw *ah) debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); - sc->debug.regidx = 0; - memset(&sc->debug.bb_mac_samp, 0, sizeof(sc->debug.bb_mac_samp)); - sc->debug.sampidx = 0; - sc->debug.tsidx = 0; - sc->debug.rsidx = 0; return 0; } -- GitLab From 6bcf6f647b456dc037238137c0db2917e5d8c525 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:51:02 +0530 Subject: [PATCH 1131/1846] ath9k: Merge wiphy and misc debugfs files This patch merges the 'wiphy' and 'misc' debugfs files and consolidates the information. Information about the current channel and other HT parameters can be obtained from both mac80211 and iw. Remove such redundant data. The reset statistics have been removed, they will be re-added in a subsequent patch (in a new debugfs file). Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/debug.c | 224 +++++++------------------ 1 file changed, 64 insertions(+), 160 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index dc45cf91aba2..b2c60690255a 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -451,109 +451,6 @@ static const struct file_operations fops_interrupt = { .llseek = default_llseek, }; -static const char *channel_type_str(enum nl80211_channel_type t) -{ - switch (t) { - case NL80211_CHAN_NO_HT: - return "no ht"; - case NL80211_CHAN_HT20: - return "ht20"; - case NL80211_CHAN_HT40MINUS: - return "ht40-"; - case NL80211_CHAN_HT40PLUS: - return "ht40+"; - default: - return "???"; - } -} - -static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct ath_softc *sc = file->private_data; - struct ieee80211_channel *chan = sc->hw->conf.channel; - struct ieee80211_conf *conf = &(sc->hw->conf); - char buf[512]; - unsigned int len = 0; - u8 addr[ETH_ALEN]; - u32 tmp; - - len += snprintf(buf + len, sizeof(buf) - len, - "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n", - wiphy_name(sc->hw->wiphy), - ieee80211_frequency_to_channel(chan->center_freq), - chan->center_freq, - conf->channel_type, - channel_type_str(conf->channel_type)); - - ath9k_ps_wakeup(sc); - put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); - put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4); - len += snprintf(buf + len, sizeof(buf) - len, - "addr: %pM\n", addr); - put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); - put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4); - len += snprintf(buf + len, sizeof(buf) - len, - "addrmask: %pM\n", addr); - tmp = ath9k_hw_getrxfilter(sc->sc_ah); - ath9k_ps_restore(sc); - len += snprintf(buf + len, sizeof(buf) - len, - "rfilt: 0x%x", tmp); - if (tmp & ATH9K_RX_FILTER_UCAST) - len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); - if (tmp & ATH9K_RX_FILTER_MCAST) - len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); - if (tmp & ATH9K_RX_FILTER_BCAST) - len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); - if (tmp & ATH9K_RX_FILTER_CONTROL) - len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); - if (tmp & ATH9K_RX_FILTER_BEACON) - len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); - if (tmp & ATH9K_RX_FILTER_PROM) - len += snprintf(buf + len, sizeof(buf) - len, " PROM"); - if (tmp & ATH9K_RX_FILTER_PROBEREQ) - len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); - if (tmp & ATH9K_RX_FILTER_PHYERR) - len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); - if (tmp & ATH9K_RX_FILTER_MYBEACON) - len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); - if (tmp & ATH9K_RX_FILTER_COMP_BAR) - len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); - if (tmp & ATH9K_RX_FILTER_PSPOLL) - len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); - if (tmp & ATH9K_RX_FILTER_PHYRADAR) - len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); - if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) - len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); - - len += snprintf(buf + len, sizeof(buf) - len, - "\n\nReset causes:\n" - " baseband hang: %d\n" - " baseband watchdog: %d\n" - " fatal hardware error interrupt: %d\n" - " tx hardware error: %d\n" - " tx path hang: %d\n" - " pll rx hang: %d\n", - sc->debug.stats.reset[RESET_TYPE_BB_HANG], - sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG], - sc->debug.stats.reset[RESET_TYPE_FATAL_INT], - sc->debug.stats.reset[RESET_TYPE_TX_ERROR], - sc->debug.stats.reset[RESET_TYPE_TX_HANG], - sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); - - if (len > sizeof(buf)) - len = sizeof(buf); - - return simple_read_from_buffer(user_buf, count, ppos, buf, len); -} - -static const struct file_operations fops_wiphy = { - .read = read_file_wiphy, - .open = ath9k_debugfs_open, - .owner = THIS_MODULE, - .llseek = default_llseek, -}; - #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum #define PR(str, elem) \ do { \ @@ -763,84 +660,93 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf, { struct ath_softc *sc = file->private_data; struct ath_common *common = ath9k_hw_common(sc->sc_ah); - struct ath_hw *ah = sc->sc_ah; struct ieee80211_hw *hw = sc->hw; - char *buf; - unsigned int len = 0, size = 8000; + struct ath9k_vif_iter_data iter_data; + char buf[512]; + unsigned int len = 0; ssize_t retval = 0; unsigned int reg; - struct ath9k_vif_iter_data iter_data; + u32 rxfilter; - ath9k_calculate_iter_data(hw, NULL, &iter_data); - - buf = kzalloc(size, GFP_KERNEL); - if (buf == NULL) - return -ENOMEM; + len += snprintf(buf + len, sizeof(buf) - len, + "BSSID: %pM\n", common->curbssid); + len += snprintf(buf + len, sizeof(buf) - len, + "BSSID-MASK: %pM\n", common->bssidmask); + len += snprintf(buf + len, sizeof(buf) - len, + "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); ath9k_ps_wakeup(sc); - len += snprintf(buf + len, size - len, - "curbssid: %pM\n" - "OP-Mode: %s(%i)\n" - "Beacon-Timer-Register: 0x%x\n", - common->curbssid, - ath_opmode_to_string(sc->sc_ah->opmode), - (int)(sc->sc_ah->opmode), - REG_READ(ah, AR_BEACON_PERIOD)); - - reg = REG_READ(ah, AR_TIMER_MODE); + rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); ath9k_ps_restore(sc); - len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (", - reg); - if (reg & AR_TBTT_TIMER_EN) - len += snprintf(buf + len, size - len, "TBTT "); - if (reg & AR_DBA_TIMER_EN) - len += snprintf(buf + len, size - len, "DBA "); - if (reg & AR_SWBA_TIMER_EN) - len += snprintf(buf + len, size - len, "SWBA "); - if (reg & AR_HCF_TIMER_EN) - len += snprintf(buf + len, size - len, "HCF "); - if (reg & AR_TIM_TIMER_EN) - len += snprintf(buf + len, size - len, "TIM "); - if (reg & AR_DTIM_TIMER_EN) - len += snprintf(buf + len, size - len, "DTIM "); - len += snprintf(buf + len, size - len, ")\n"); + + len += snprintf(buf + len, sizeof(buf) - len, + "RXFILTER: 0x%x", rxfilter); + + if (rxfilter & ATH9K_RX_FILTER_UCAST) + len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); + if (rxfilter & ATH9K_RX_FILTER_MCAST) + len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); + if (rxfilter & ATH9K_RX_FILTER_BCAST) + len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); + if (rxfilter & ATH9K_RX_FILTER_CONTROL) + len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); + if (rxfilter & ATH9K_RX_FILTER_BEACON) + len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); + if (rxfilter & ATH9K_RX_FILTER_PROM) + len += snprintf(buf + len, sizeof(buf) - len, " PROM"); + if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) + len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); + if (rxfilter & ATH9K_RX_FILTER_PHYERR) + len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); + if (rxfilter & ATH9K_RX_FILTER_MYBEACON) + len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); + if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) + len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); + if (rxfilter & ATH9K_RX_FILTER_PSPOLL) + len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); + if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) + len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); + if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) + len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); + if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) + len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); + + len += snprintf(buf + len, sizeof(buf) - len, "\n"); reg = sc->sc_ah->imask; - len += snprintf(buf + len, size - len, "imask: 0x%x (", reg); + + len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); + if (reg & ATH9K_INT_SWBA) - len += snprintf(buf + len, size - len, "SWBA "); + len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); if (reg & ATH9K_INT_BMISS) - len += snprintf(buf + len, size - len, "BMISS "); + len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); if (reg & ATH9K_INT_CST) - len += snprintf(buf + len, size - len, "CST "); + len += snprintf(buf + len, sizeof(buf) - len, " CST"); if (reg & ATH9K_INT_RX) - len += snprintf(buf + len, size - len, "RX "); + len += snprintf(buf + len, sizeof(buf) - len, " RX"); if (reg & ATH9K_INT_RXHP) - len += snprintf(buf + len, size - len, "RXHP "); + len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); if (reg & ATH9K_INT_RXLP) - len += snprintf(buf + len, size - len, "RXLP "); + len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); if (reg & ATH9K_INT_BB_WATCHDOG) - len += snprintf(buf + len, size - len, "BB_WATCHDOG "); - /* there are other IRQs if one wanted to add them. */ - len += snprintf(buf + len, size - len, ")\n"); + len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); - len += snprintf(buf + len, size - len, - "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i" - " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n", + len += snprintf(buf + len, sizeof(buf) - len, "\n"); + + ath9k_calculate_iter_data(hw, NULL, &iter_data); + + len += snprintf(buf + len, sizeof(buf) - len, + "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" + " ADHOC: %i OTHER: %i TOTAL: %hi BEACON-VIF: %hi\n", iter_data.naps, iter_data.nstations, iter_data.nmeshes, iter_data.nwds, iter_data.nadhocs, iter_data.nothers, sc->nvifs, sc->nbcnvifs); - len += snprintf(buf + len, size - len, - "Calculated-BSSID-Mask: %pM\n", - iter_data.mask); - - if (len > size) - len = size; + if (len > sizeof(buf)) + len = sizeof(buf); retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); - kfree(buf); - return retval; } @@ -1637,8 +1543,6 @@ int ath9k_init_debug(struct ath_hw *ah) &fops_dma); debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_interrupt); - debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, - sc, &fops_wiphy); debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_xmit); debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, -- GitLab From f8b815dc0e0942c45919d814e319c14c1221fa81 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:51:11 +0530 Subject: [PATCH 1132/1846] ath9k: Add a debugfs file to display reset statistics Location: /ieee80211/phy#/ath9k/reset Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/debug.c | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index b2c60690255a..fe1f55f7c292 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -750,6 +750,38 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf, return retval; } +static ssize_t read_file_reset(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath_softc *sc = file->private_data; + char buf[512]; + unsigned int len = 0; + + len += snprintf(buf + len, sizeof(buf) - len, + "%17s: %2d\n", "Baseband Hang", + sc->debug.stats.reset[RESET_TYPE_BB_HANG]); + len += snprintf(buf + len, sizeof(buf) - len, + "%17s: %2d\n", "Baseband Watchdog", + sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); + len += snprintf(buf + len, sizeof(buf) - len, + "%17s: %2d\n", "Fatal HW Error", + sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); + len += snprintf(buf + len, sizeof(buf) - len, + "%17s: %2d\n", "TX HW error", + sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); + len += snprintf(buf + len, sizeof(buf) - len, + "%17s: %2d\n", "TX Path Hang", + sc->debug.stats.reset[RESET_TYPE_TX_HANG]); + len += snprintf(buf + len, sizeof(buf) - len, + "%17s: %2d\n", "PLL RX Hang", + sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); + + if (len > sizeof(buf)) + len = sizeof(buf); + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, struct ath_tx_status *ts, struct ath_txq *txq, unsigned int flags) @@ -837,6 +869,13 @@ static const struct file_operations fops_misc = { .llseek = default_llseek, }; +static const struct file_operations fops_reset = { + .read = read_file_reset, + .open = ath9k_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + static ssize_t read_file_recv(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1549,6 +1588,8 @@ int ath9k_init_debug(struct ath_hw *ah) &fops_stations); debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_misc); + debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, + &fops_reset); debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_recv); debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, -- GitLab From 4203214ee28d285c580263e2ea80848fd5e676f3 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:51:23 +0530 Subject: [PATCH 1133/1846] ath9k: Prettify recv debugfs file output Dumping the RSSI information in the middle of error statistics is a bit misleading. Move them to the end. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/debug.c | 97 ++++++++++++-------------- 1 file changed, 45 insertions(+), 52 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index fe1f55f7c292..5a838fc28b61 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -880,12 +880,12 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { #define PHY_ERR(s, p) \ - len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ + len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ sc->debug.stats.rxstats.phy_err_stats[p]); struct ath_softc *sc = file->private_data; char *buf; - unsigned int len = 0, size = 1400; + unsigned int len = 0, size = 1600; ssize_t retval = 0; buf = kzalloc(size, GFP_KERNEL); @@ -893,87 +893,80 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, return -ENOMEM; len += snprintf(buf + len, size - len, - "%18s : %10u\n", "CRC ERR", + "%22s : %10u\n", "CRC ERR", sc->debug.stats.rxstats.crc_err); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "DECRYPT CRC ERR", + "%22s : %10u\n", "DECRYPT CRC ERR", sc->debug.stats.rxstats.decrypt_crc_err); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "PHY ERR", + "%22s : %10u\n", "PHY ERR", sc->debug.stats.rxstats.phy_err); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "MIC ERR", + "%22s : %10u\n", "MIC ERR", sc->debug.stats.rxstats.mic_err); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "PRE-DELIM CRC ERR", + "%22s : %10u\n", "PRE-DELIM CRC ERR", sc->debug.stats.rxstats.pre_delim_crc_err); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "POST-DELIM CRC ERR", + "%22s : %10u\n", "POST-DELIM CRC ERR", sc->debug.stats.rxstats.post_delim_crc_err); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "DECRYPT BUSY ERR", + "%22s : %10u\n", "DECRYPT BUSY ERR", sc->debug.stats.rxstats.decrypt_busy_err); + PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); + PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); + PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); + PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); + PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); + PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); + PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); + PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); + PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); + PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); + PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); + PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); + PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); + PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); + PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); + PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); + PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); + PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); + PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); + PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); + PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); + PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); + PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); + PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); + PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); + PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); + len += snprintf(buf + len, size - len, - "%18s : %10d\n", "RSSI-CTL0", + "%22s : %10d\n", "RSSI-CTL0", sc->debug.stats.rxstats.rs_rssi_ctl0); - len += snprintf(buf + len, size - len, - "%18s : %10d\n", "RSSI-CTL1", + "%22s : %10d\n", "RSSI-CTL1", sc->debug.stats.rxstats.rs_rssi_ctl1); - len += snprintf(buf + len, size - len, - "%18s : %10d\n", "RSSI-CTL2", + "%22s : %10d\n", "RSSI-CTL2", sc->debug.stats.rxstats.rs_rssi_ctl2); - len += snprintf(buf + len, size - len, - "%18s : %10d\n", "RSSI-EXT0", + "%22s : %10d\n", "RSSI-EXT0", sc->debug.stats.rxstats.rs_rssi_ext0); - len += snprintf(buf + len, size - len, - "%18s : %10d\n", "RSSI-EXT1", + "%22s : %10d\n", "RSSI-EXT1", sc->debug.stats.rxstats.rs_rssi_ext1); - len += snprintf(buf + len, size - len, - "%18s : %10d\n", "RSSI-EXT2", + "%22s : %10d\n", "RSSI-EXT2", sc->debug.stats.rxstats.rs_rssi_ext2); - len += snprintf(buf + len, size - len, - "%18s : %10d\n", "Rx Antenna", + "%22s : %10d\n", "Rx Antenna", sc->debug.stats.rxstats.rs_antenna); - - PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); - PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); - PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); - PHY_ERR("RATE", ATH9K_PHYERR_RATE); - PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); - PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); - PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); - PHY_ERR("TOR", ATH9K_PHYERR_TOR); - PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); - PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); - PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); - PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); - PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); - PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); - PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); - PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); - PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); - PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); - PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); - PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); - PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); - PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); - PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); - PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); - PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); - PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); - len += snprintf(buf + len, size - len, - "%18s : %10u\n", "RX-Pkts-All", + "%22s : %10u\n", "RX-Pkts-All", sc->debug.stats.rxstats.rx_pkts_all); len += snprintf(buf + len, size - len, - "%18s : %10u\n", "RX-Bytes-All", + "%22s : %10u\n", "RX-Bytes-All", sc->debug.stats.rxstats.rx_bytes_all); if (len > size) -- GitLab From dbb07f00446f3c7557dbfefb6e16f15b96225da8 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:52:25 +0530 Subject: [PATCH 1134/1846] ath9k: Fix phyerr debug statistics Validate the phyerr value against the max. size of the statistics array properly. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 5a838fc28b61..228c18189a3a 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -987,8 +987,6 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ [sc->debug.rsidx].c) - u32 phyerr; - RX_STAT_INC(rx_pkts_all); sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; @@ -1007,8 +1005,8 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) if (rs->rs_status & ATH9K_RXERR_PHY) { RX_STAT_INC(phy_err); - phyerr = rs->rs_phyerr & 0x24; - RX_PHY_ERR_INC(phyerr); + if (rs->rs_phyerr < ATH9K_PHYERR_MAX) + RX_PHY_ERR_INC(rs->rs_phyerr); } sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0; -- GitLab From 4bc7cda884731e90961a1269b51690152428b77b Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:52:35 +0530 Subject: [PATCH 1135/1846] ath9k: Remove unused initvals Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- .../wireless/ath/ath9k/ar9462_1p0_initvals.h | 394 --------------- .../wireless/ath/ath9k/ar9462_2p0_initvals.h | 465 ------------------ 2 files changed, 859 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h index 5c55ae389adb..5510216a4886 100644 --- a/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h @@ -190,12 +190,6 @@ static const u32 ar9462_1p0_baseband_core_txfir_coeff_japan_2484[][2] = { {0x0000a3a0, 0xca9228ee}, }; -static const u32 ar9462_1p0_sys3ant[][2] = { - /* Addr allmodes */ - {0x00063280, 0x00040807}, - {0x00063284, 0x104ccccc}, -}; - static const u32 ar9462_pcie_phy_clkreq_enable_L1_1p0[][2] = { /* Addr allmodes */ {0x00018c00, 0x10053e5e}, @@ -203,338 +197,6 @@ static const u32 ar9462_pcie_phy_clkreq_enable_L1_1p0[][2] = { {0x00018c08, 0x0000580c}, }; -static const u32 ar9462_1p0_mac_core_emulation[][2] = { - /* Addr allmodes */ - {0x00000030, 0x00060085}, - {0x00000044, 0x00000008}, - {0x0000805c, 0xffffc7ff}, - {0x00008344, 0xaa4a105b}, -}; - -static const u32 ar9462_common_rx_gain_table_ar9280_2p0_1p0[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x02000101}, - {0x0000a004, 0x02000102}, - {0x0000a008, 0x02000103}, - {0x0000a00c, 0x02000104}, - {0x0000a010, 0x02000200}, - {0x0000a014, 0x02000201}, - {0x0000a018, 0x02000202}, - {0x0000a01c, 0x02000203}, - {0x0000a020, 0x02000204}, - {0x0000a024, 0x02000205}, - {0x0000a028, 0x02000208}, - {0x0000a02c, 0x02000302}, - {0x0000a030, 0x02000303}, - {0x0000a034, 0x02000304}, - {0x0000a038, 0x02000400}, - {0x0000a03c, 0x02010300}, - {0x0000a040, 0x02010301}, - {0x0000a044, 0x02010302}, - {0x0000a048, 0x02000500}, - {0x0000a04c, 0x02010400}, - {0x0000a050, 0x02020300}, - {0x0000a054, 0x02020301}, - {0x0000a058, 0x02020302}, - {0x0000a05c, 0x02020303}, - {0x0000a060, 0x02020400}, - {0x0000a064, 0x02030300}, - {0x0000a068, 0x02030301}, - {0x0000a06c, 0x02030302}, - {0x0000a070, 0x02030303}, - {0x0000a074, 0x02030400}, - {0x0000a078, 0x02040300}, - {0x0000a07c, 0x02040301}, - {0x0000a080, 0x02040302}, - {0x0000a084, 0x02040303}, - {0x0000a088, 0x02030500}, - {0x0000a08c, 0x02040400}, - {0x0000a090, 0x02050203}, - {0x0000a094, 0x02050204}, - {0x0000a098, 0x02050205}, - {0x0000a09c, 0x02040500}, - {0x0000a0a0, 0x02050301}, - {0x0000a0a4, 0x02050302}, - {0x0000a0a8, 0x02050303}, - {0x0000a0ac, 0x02050400}, - {0x0000a0b0, 0x02050401}, - {0x0000a0b4, 0x02050402}, - {0x0000a0b8, 0x02050403}, - {0x0000a0bc, 0x02050500}, - {0x0000a0c0, 0x02050501}, - {0x0000a0c4, 0x02050502}, - {0x0000a0c8, 0x02050503}, - {0x0000a0cc, 0x02050504}, - {0x0000a0d0, 0x02050600}, - {0x0000a0d4, 0x02050601}, - {0x0000a0d8, 0x02050602}, - {0x0000a0dc, 0x02050603}, - {0x0000a0e0, 0x02050604}, - {0x0000a0e4, 0x02050700}, - {0x0000a0e8, 0x02050701}, - {0x0000a0ec, 0x02050702}, - {0x0000a0f0, 0x02050703}, - {0x0000a0f4, 0x02050704}, - {0x0000a0f8, 0x02050705}, - {0x0000a0fc, 0x02050708}, - {0x0000a100, 0x02050709}, - {0x0000a104, 0x0205070a}, - {0x0000a108, 0x0205070b}, - {0x0000a10c, 0x0205070c}, - {0x0000a110, 0x0205070d}, - {0x0000a114, 0x02050710}, - {0x0000a118, 0x02050711}, - {0x0000a11c, 0x02050712}, - {0x0000a120, 0x02050713}, - {0x0000a124, 0x02050714}, - {0x0000a128, 0x02050715}, - {0x0000a12c, 0x02050730}, - {0x0000a130, 0x02050731}, - {0x0000a134, 0x02050732}, - {0x0000a138, 0x02050733}, - {0x0000a13c, 0x02050734}, - {0x0000a140, 0x02050735}, - {0x0000a144, 0x02050750}, - {0x0000a148, 0x02050751}, - {0x0000a14c, 0x02050752}, - {0x0000a150, 0x02050753}, - {0x0000a154, 0x02050754}, - {0x0000a158, 0x02050755}, - {0x0000a15c, 0x02050770}, - {0x0000a160, 0x02050771}, - {0x0000a164, 0x02050772}, - {0x0000a168, 0x02050773}, - {0x0000a16c, 0x02050774}, - {0x0000a170, 0x02050775}, - {0x0000a174, 0x00000776}, - {0x0000a178, 0x00000776}, - {0x0000a17c, 0x00000776}, - {0x0000a180, 0x00000776}, - {0x0000a184, 0x00000776}, - {0x0000a188, 0x00000776}, - {0x0000a18c, 0x00000776}, - {0x0000a190, 0x00000776}, - {0x0000a194, 0x00000776}, - {0x0000a198, 0x00000776}, - {0x0000a19c, 0x00000776}, - {0x0000a1a0, 0x00000776}, - {0x0000a1a4, 0x00000776}, - {0x0000a1a8, 0x00000776}, - {0x0000a1ac, 0x00000776}, - {0x0000a1b0, 0x00000776}, - {0x0000a1b4, 0x00000776}, - {0x0000a1b8, 0x00000776}, - {0x0000a1bc, 0x00000776}, - {0x0000a1c0, 0x00000776}, - {0x0000a1c4, 0x00000776}, - {0x0000a1c8, 0x00000776}, - {0x0000a1cc, 0x00000776}, - {0x0000a1d0, 0x00000776}, - {0x0000a1d4, 0x00000776}, - {0x0000a1d8, 0x00000776}, - {0x0000a1dc, 0x00000776}, - {0x0000a1e0, 0x00000776}, - {0x0000a1e4, 0x00000776}, - {0x0000a1e8, 0x00000776}, - {0x0000a1ec, 0x00000776}, - {0x0000a1f0, 0x00000776}, - {0x0000a1f4, 0x00000776}, - {0x0000a1f8, 0x00000776}, - {0x0000a1fc, 0x00000776}, - {0x0000b000, 0x02000101}, - {0x0000b004, 0x02000102}, - {0x0000b008, 0x02000103}, - {0x0000b00c, 0x02000104}, - {0x0000b010, 0x02000200}, - {0x0000b014, 0x02000201}, - {0x0000b018, 0x02000202}, - {0x0000b01c, 0x02000203}, - {0x0000b020, 0x02000204}, - {0x0000b024, 0x02000205}, - {0x0000b028, 0x02000208}, - {0x0000b02c, 0x02000302}, - {0x0000b030, 0x02000303}, - {0x0000b034, 0x02000304}, - {0x0000b038, 0x02000400}, - {0x0000b03c, 0x02010300}, - {0x0000b040, 0x02010301}, - {0x0000b044, 0x02010302}, - {0x0000b048, 0x02000500}, - {0x0000b04c, 0x02010400}, - {0x0000b050, 0x02020300}, - {0x0000b054, 0x02020301}, - {0x0000b058, 0x02020302}, - {0x0000b05c, 0x02020303}, - {0x0000b060, 0x02020400}, - {0x0000b064, 0x02030300}, - {0x0000b068, 0x02030301}, - {0x0000b06c, 0x02030302}, - {0x0000b070, 0x02030303}, - {0x0000b074, 0x02030400}, - {0x0000b078, 0x02040300}, - {0x0000b07c, 0x02040301}, - {0x0000b080, 0x02040302}, - {0x0000b084, 0x02040303}, - {0x0000b088, 0x02030500}, - {0x0000b08c, 0x02040400}, - {0x0000b090, 0x02050203}, - {0x0000b094, 0x02050204}, - {0x0000b098, 0x02050205}, - {0x0000b09c, 0x02040500}, - {0x0000b0a0, 0x02050301}, - {0x0000b0a4, 0x02050302}, - {0x0000b0a8, 0x02050303}, - {0x0000b0ac, 0x02050400}, - {0x0000b0b0, 0x02050401}, - {0x0000b0b4, 0x02050402}, - {0x0000b0b8, 0x02050403}, - {0x0000b0bc, 0x02050500}, - {0x0000b0c0, 0x02050501}, - {0x0000b0c4, 0x02050502}, - {0x0000b0c8, 0x02050503}, - {0x0000b0cc, 0x02050504}, - {0x0000b0d0, 0x02050600}, - {0x0000b0d4, 0x02050601}, - {0x0000b0d8, 0x02050602}, - {0x0000b0dc, 0x02050603}, - {0x0000b0e0, 0x02050604}, - {0x0000b0e4, 0x02050700}, - {0x0000b0e8, 0x02050701}, - {0x0000b0ec, 0x02050702}, - {0x0000b0f0, 0x02050703}, - {0x0000b0f4, 0x02050704}, - {0x0000b0f8, 0x02050705}, - {0x0000b0fc, 0x02050708}, - {0x0000b100, 0x02050709}, - {0x0000b104, 0x0205070a}, - {0x0000b108, 0x0205070b}, - {0x0000b10c, 0x0205070c}, - {0x0000b110, 0x0205070d}, - {0x0000b114, 0x02050710}, - {0x0000b118, 0x02050711}, - {0x0000b11c, 0x02050712}, - {0x0000b120, 0x02050713}, - {0x0000b124, 0x02050714}, - {0x0000b128, 0x02050715}, - {0x0000b12c, 0x02050730}, - {0x0000b130, 0x02050731}, - {0x0000b134, 0x02050732}, - {0x0000b138, 0x02050733}, - {0x0000b13c, 0x02050734}, - {0x0000b140, 0x02050735}, - {0x0000b144, 0x02050750}, - {0x0000b148, 0x02050751}, - {0x0000b14c, 0x02050752}, - {0x0000b150, 0x02050753}, - {0x0000b154, 0x02050754}, - {0x0000b158, 0x02050755}, - {0x0000b15c, 0x02050770}, - {0x0000b160, 0x02050771}, - {0x0000b164, 0x02050772}, - {0x0000b168, 0x02050773}, - {0x0000b16c, 0x02050774}, - {0x0000b170, 0x02050775}, - {0x0000b174, 0x00000776}, - {0x0000b178, 0x00000776}, - {0x0000b17c, 0x00000776}, - {0x0000b180, 0x00000776}, - {0x0000b184, 0x00000776}, - {0x0000b188, 0x00000776}, - {0x0000b18c, 0x00000776}, - {0x0000b190, 0x00000776}, - {0x0000b194, 0x00000776}, - {0x0000b198, 0x00000776}, - {0x0000b19c, 0x00000776}, - {0x0000b1a0, 0x00000776}, - {0x0000b1a4, 0x00000776}, - {0x0000b1a8, 0x00000776}, - {0x0000b1ac, 0x00000776}, - {0x0000b1b0, 0x00000776}, - {0x0000b1b4, 0x00000776}, - {0x0000b1b8, 0x00000776}, - {0x0000b1bc, 0x00000776}, - {0x0000b1c0, 0x00000776}, - {0x0000b1c4, 0x00000776}, - {0x0000b1c8, 0x00000776}, - {0x0000b1cc, 0x00000776}, - {0x0000b1d0, 0x00000776}, - {0x0000b1d4, 0x00000776}, - {0x0000b1d8, 0x00000776}, - {0x0000b1dc, 0x00000776}, - {0x0000b1e0, 0x00000776}, - {0x0000b1e4, 0x00000776}, - {0x0000b1e8, 0x00000776}, - {0x0000b1ec, 0x00000776}, - {0x0000b1f0, 0x00000776}, - {0x0000b1f4, 0x00000776}, - {0x0000b1f8, 0x00000776}, - {0x0000b1fc, 0x00000776}, -}; - -static const u32 ar9200_ar9280_2p0_radio_core_1p0[][2] = { - /* Addr allmodes */ - {0x00007800, 0x00040000}, - {0x00007804, 0xdb005012}, - {0x00007808, 0x04924914}, - {0x0000780c, 0x21084210}, - {0x00007810, 0x6d801300}, - {0x00007814, 0x0019beff}, - {0x00007818, 0x07e41000}, - {0x0000781c, 0x00392000}, - {0x00007820, 0x92592480}, - {0x00007824, 0x00040000}, - {0x00007828, 0xdb005012}, - {0x0000782c, 0x04924914}, - {0x00007830, 0x21084210}, - {0x00007834, 0x6d801300}, - {0x00007838, 0x0019beff}, - {0x0000783c, 0x07e40000}, - {0x00007840, 0x00392000}, - {0x00007844, 0x92592480}, - {0x00007848, 0x00100000}, - {0x0000784c, 0x773f0567}, - {0x00007850, 0x54214514}, - {0x00007854, 0x12035828}, - {0x00007858, 0x92592692}, - {0x0000785c, 0x00000000}, - {0x00007860, 0x56400000}, - {0x00007864, 0x0a8e370e}, - {0x00007868, 0xc0102850}, - {0x0000786c, 0x812d4000}, - {0x00007870, 0x807ec400}, - {0x00007874, 0x001b6db0}, - {0x00007878, 0x00376b63}, - {0x0000787c, 0x06db6db6}, - {0x00007880, 0x006d8000}, - {0x00007884, 0xffeffffe}, - {0x00007888, 0xffeffffe}, - {0x0000788c, 0x00010000}, - {0x00007890, 0x02060aeb}, - {0x00007894, 0x5a108000}, -}; - -static const u32 ar9462_1p0_baseband_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00009e3c, 0xcf946221, 0xcf946221, 0xcf946221, 0xcf946221}, - {0x00009e44, 0x005c0000, 0x005c0000, 0x005c0000, 0x005c0000}, - {0x0000a258, 0x02020200, 0x02020200, 0x02020200, 0x02020200}, - {0x0000a25c, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e}, - {0x0000a28c, 0x00011111, 0x00011111, 0x00011111, 0x00011111}, - {0x0000a2c4, 0x00148d18, 0x00148d18, 0x00148d20, 0x00148d20}, - {0x0000a2d8, 0xf999a800, 0xf999a800, 0xf999a80c, 0xf999a80c}, - {0x0000a50c, 0x0000c00a, 0x0000c00a, 0x0000c00a, 0x0000c00a}, - {0x0000a538, 0x00038e8c, 0x00038e8c, 0x00038e8c, 0x00038e8c}, - {0x0000a53c, 0x0003cecc, 0x0003cecc, 0x0003cecc, 0x0003cecc}, - {0x0000a540, 0x00040ed4, 0x00040ed4, 0x00040ed4, 0x00040ed4}, - {0x0000a544, 0x00044edc, 0x00044edc, 0x00044edc, 0x00044edc}, - {0x0000a548, 0x00048ede, 0x00048ede, 0x00048ede, 0x00048ede}, - {0x0000a54c, 0x0004cf1e, 0x0004cf1e, 0x0004cf1e, 0x0004cf1e}, - {0x0000a550, 0x00050f5e, 0x00050f5e, 0x00050f5e, 0x00050f5e}, - {0x0000a554, 0x00054f9e, 0x00054f9e, 0x00054f9e, 0x00054f9e}, - {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, -}; - static const u32 ar9462_pcie_phy_pll_on_clkreq_disable_L1_1p0[][2] = { /* Addr allmodes */ {0x00018c00, 0x10012e5e}, @@ -1139,30 +801,6 @@ static const u32 ar9462_1p0_mac_postamble[][5] = { {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440}, }; -static const u32 ar9462_1p0_mac_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00008014, 0x10f810f8, 0x10f810f8, 0x10f810f8, 0x10f810f8}, - {0x0000801c, 0x0e8d8017, 0x0e8d8017, 0x0e8d8017, 0x0e8d8017}, -}; - -static const u32 ar9462_1p0_tx_gain_table_baseband_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a410, 0x000000d5, 0x000000d5, 0x000000d5, 0x000000d5}, - {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a504, 0x00004002, 0x00004002, 0x00004002, 0x00004002}, - {0x0000a508, 0x00008004, 0x00008004, 0x00008004, 0x00008004}, - {0x0000a510, 0x0001000c, 0x0001000c, 0x0001000c, 0x0001000c}, - {0x0000a514, 0x0001420b, 0x0001420b, 0x0001420b, 0x0001420b}, - {0x0000a518, 0x0001824a, 0x0001824a, 0x0001824a, 0x0001824a}, - {0x0000a51c, 0x0001c44a, 0x0001c44a, 0x0001c44a, 0x0001c44a}, - {0x0000a520, 0x0002064a, 0x0002064a, 0x0002064a, 0x0002064a}, - {0x0000a524, 0x0002484a, 0x0002484a, 0x0002484a, 0x0002484a}, - {0x0000a528, 0x00028a4a, 0x00028a4a, 0x00028a4a, 0x00028a4a}, - {0x0000a52c, 0x0002cc4a, 0x0002cc4a, 0x0002cc4a, 0x0002cc4a}, - {0x0000a530, 0x00030e4a, 0x00030e4a, 0x00030e4a, 0x00030e4a}, - {0x0000a534, 0x00034e8a, 0x00034e8a, 0x00034e8a, 0x00034e8a}, -}; - static const u32 ar9462_1p0_radio_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x0001609c, 0x0b8ee524, 0x0b8ee524, 0x0b8ee524, 0x0b8ee524}, @@ -1174,11 +812,6 @@ static const u32 ar9462_1p0_radio_postamble[][5] = { {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, }; -static const u32 ar9462_1p0_soc_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00007010, 0x00001133, 0x00001133, 0x00001133, 0x00001133}, -}; - static const u32 ar9462_1p0_baseband_core[][2] = { /* Addr allmodes */ {0x00009800, 0xafe68e30}, @@ -1736,28 +1369,6 @@ static const u32 ar9462_pcie_phy_clkreq_disable_L1_1p0[][2] = { {0x00018c08, 0x0000580c}, }; -static const u32 ar9462_1p0_baseband_core_emulation[][2] = { - /* Addr allmodes */ - {0x00009800, 0xafa68e30}, - {0x00009884, 0x00002842}, - {0x00009c04, 0xff55ff55}, - {0x00009c08, 0x0320ff55}, - {0x00009e50, 0x00000000}, - {0x00009fcc, 0x00000014}, - {0x0000a344, 0x00000010}, - {0x0000a398, 0x00000000}, - {0x0000a39c, 0x71733d01}, - {0x0000a3a0, 0xd0ad5c12}, - {0x0000a3c0, 0x22222220}, - {0x0000a3c4, 0x22222222}, - {0x0000a404, 0x00418a11}, - {0x0000a418, 0x050001ce}, - {0x0000a438, 0x00001800}, - {0x0000a458, 0x01444452}, - {0x0000a644, 0x3fad9d74}, - {0x0000a690, 0x00000038}, -}; - static const u32 ar9462_1p0_radio_core[][2] = { /* Addr allmodes */ {0x00016000, 0x36db6db6}, @@ -1825,9 +1436,4 @@ static const u32 ar9462_1p0_soc_preamble[][2] = { {0x00007038, 0x000004c2}, }; -static const u32 ar9462_1p0_sys2ant[][2] = { - /* Addr allmodes */ - {0x00063120, 0x00801980}, -}; - #endif /* INITVALS_9462_1P0_H */ diff --git a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h index dc2054f0378e..b6ba1e8149be 100644 --- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h @@ -98,14 +98,6 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = { {0x0000b284, 0x00000000, 0x00000000, 0x00000550, 0x00000550}, }; -static const u32 ar9462_2p0_mac_core_emulation[][2] = { - /* Addr allmodes */ - {0x00000030, 0x000e0085}, - {0x00000044, 0x00000008}, - {0x0000805c, 0xffffc7ff}, - {0x00008344, 0xaa4a105b}, -}; - static const u32 ar9462_common_rx_gain_table_2p0[][2] = { /* Addr allmodes */ {0x0000a000, 0x00010000}, @@ -380,349 +372,6 @@ static const u32 ar9462_pciephy_pll_on_clkreq_disable_L1_2p0[][2] = { {0x00018c08, 0x0003580c}, }; -static const u32 ar9462_2p0_sys3ant[][2] = { - /* Addr allmodes */ - {0x00063280, 0x00040807}, - {0x00063284, 0x104ccccc}, -}; - -static const u32 ar9462_common_rx_gain_table_ar9280_2p0[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x02000101}, - {0x0000a004, 0x02000102}, - {0x0000a008, 0x02000103}, - {0x0000a00c, 0x02000104}, - {0x0000a010, 0x02000200}, - {0x0000a014, 0x02000201}, - {0x0000a018, 0x02000202}, - {0x0000a01c, 0x02000203}, - {0x0000a020, 0x02000204}, - {0x0000a024, 0x02000205}, - {0x0000a028, 0x02000208}, - {0x0000a02c, 0x02000302}, - {0x0000a030, 0x02000303}, - {0x0000a034, 0x02000304}, - {0x0000a038, 0x02000400}, - {0x0000a03c, 0x02010300}, - {0x0000a040, 0x02010301}, - {0x0000a044, 0x02010302}, - {0x0000a048, 0x02000500}, - {0x0000a04c, 0x02010400}, - {0x0000a050, 0x02020300}, - {0x0000a054, 0x02020301}, - {0x0000a058, 0x02020302}, - {0x0000a05c, 0x02020303}, - {0x0000a060, 0x02020400}, - {0x0000a064, 0x02030300}, - {0x0000a068, 0x02030301}, - {0x0000a06c, 0x02030302}, - {0x0000a070, 0x02030303}, - {0x0000a074, 0x02030400}, - {0x0000a078, 0x02040300}, - {0x0000a07c, 0x02040301}, - {0x0000a080, 0x02040302}, - {0x0000a084, 0x02040303}, - {0x0000a088, 0x02030500}, - {0x0000a08c, 0x02040400}, - {0x0000a090, 0x02050203}, - {0x0000a094, 0x02050204}, - {0x0000a098, 0x02050205}, - {0x0000a09c, 0x02040500}, - {0x0000a0a0, 0x02050301}, - {0x0000a0a4, 0x02050302}, - {0x0000a0a8, 0x02050303}, - {0x0000a0ac, 0x02050400}, - {0x0000a0b0, 0x02050401}, - {0x0000a0b4, 0x02050402}, - {0x0000a0b8, 0x02050403}, - {0x0000a0bc, 0x02050500}, - {0x0000a0c0, 0x02050501}, - {0x0000a0c4, 0x02050502}, - {0x0000a0c8, 0x02050503}, - {0x0000a0cc, 0x02050504}, - {0x0000a0d0, 0x02050600}, - {0x0000a0d4, 0x02050601}, - {0x0000a0d8, 0x02050602}, - {0x0000a0dc, 0x02050603}, - {0x0000a0e0, 0x02050604}, - {0x0000a0e4, 0x02050700}, - {0x0000a0e8, 0x02050701}, - {0x0000a0ec, 0x02050702}, - {0x0000a0f0, 0x02050703}, - {0x0000a0f4, 0x02050704}, - {0x0000a0f8, 0x02050705}, - {0x0000a0fc, 0x02050708}, - {0x0000a100, 0x02050709}, - {0x0000a104, 0x0205070a}, - {0x0000a108, 0x0205070b}, - {0x0000a10c, 0x0205070c}, - {0x0000a110, 0x0205070d}, - {0x0000a114, 0x02050710}, - {0x0000a118, 0x02050711}, - {0x0000a11c, 0x02050712}, - {0x0000a120, 0x02050713}, - {0x0000a124, 0x02050714}, - {0x0000a128, 0x02050715}, - {0x0000a12c, 0x02050730}, - {0x0000a130, 0x02050731}, - {0x0000a134, 0x02050732}, - {0x0000a138, 0x02050733}, - {0x0000a13c, 0x02050734}, - {0x0000a140, 0x02050735}, - {0x0000a144, 0x02050750}, - {0x0000a148, 0x02050751}, - {0x0000a14c, 0x02050752}, - {0x0000a150, 0x02050753}, - {0x0000a154, 0x02050754}, - {0x0000a158, 0x02050755}, - {0x0000a15c, 0x02050770}, - {0x0000a160, 0x02050771}, - {0x0000a164, 0x02050772}, - {0x0000a168, 0x02050773}, - {0x0000a16c, 0x02050774}, - {0x0000a170, 0x02050775}, - {0x0000a174, 0x00000776}, - {0x0000a178, 0x00000776}, - {0x0000a17c, 0x00000776}, - {0x0000a180, 0x00000776}, - {0x0000a184, 0x00000776}, - {0x0000a188, 0x00000776}, - {0x0000a18c, 0x00000776}, - {0x0000a190, 0x00000776}, - {0x0000a194, 0x00000776}, - {0x0000a198, 0x00000776}, - {0x0000a19c, 0x00000776}, - {0x0000a1a0, 0x00000776}, - {0x0000a1a4, 0x00000776}, - {0x0000a1a8, 0x00000776}, - {0x0000a1ac, 0x00000776}, - {0x0000a1b0, 0x00000776}, - {0x0000a1b4, 0x00000776}, - {0x0000a1b8, 0x00000776}, - {0x0000a1bc, 0x00000776}, - {0x0000a1c0, 0x00000776}, - {0x0000a1c4, 0x00000776}, - {0x0000a1c8, 0x00000776}, - {0x0000a1cc, 0x00000776}, - {0x0000a1d0, 0x00000776}, - {0x0000a1d4, 0x00000776}, - {0x0000a1d8, 0x00000776}, - {0x0000a1dc, 0x00000776}, - {0x0000a1e0, 0x00000776}, - {0x0000a1e4, 0x00000776}, - {0x0000a1e8, 0x00000776}, - {0x0000a1ec, 0x00000776}, - {0x0000a1f0, 0x00000776}, - {0x0000a1f4, 0x00000776}, - {0x0000a1f8, 0x00000776}, - {0x0000a1fc, 0x00000776}, - {0x0000b000, 0x02000101}, - {0x0000b004, 0x02000102}, - {0x0000b008, 0x02000103}, - {0x0000b00c, 0x02000104}, - {0x0000b010, 0x02000200}, - {0x0000b014, 0x02000201}, - {0x0000b018, 0x02000202}, - {0x0000b01c, 0x02000203}, - {0x0000b020, 0x02000204}, - {0x0000b024, 0x02000205}, - {0x0000b028, 0x02000208}, - {0x0000b02c, 0x02000302}, - {0x0000b030, 0x02000303}, - {0x0000b034, 0x02000304}, - {0x0000b038, 0x02000400}, - {0x0000b03c, 0x02010300}, - {0x0000b040, 0x02010301}, - {0x0000b044, 0x02010302}, - {0x0000b048, 0x02000500}, - {0x0000b04c, 0x02010400}, - {0x0000b050, 0x02020300}, - {0x0000b054, 0x02020301}, - {0x0000b058, 0x02020302}, - {0x0000b05c, 0x02020303}, - {0x0000b060, 0x02020400}, - {0x0000b064, 0x02030300}, - {0x0000b068, 0x02030301}, - {0x0000b06c, 0x02030302}, - {0x0000b070, 0x02030303}, - {0x0000b074, 0x02030400}, - {0x0000b078, 0x02040300}, - {0x0000b07c, 0x02040301}, - {0x0000b080, 0x02040302}, - {0x0000b084, 0x02040303}, - {0x0000b088, 0x02030500}, - {0x0000b08c, 0x02040400}, - {0x0000b090, 0x02050203}, - {0x0000b094, 0x02050204}, - {0x0000b098, 0x02050205}, - {0x0000b09c, 0x02040500}, - {0x0000b0a0, 0x02050301}, - {0x0000b0a4, 0x02050302}, - {0x0000b0a8, 0x02050303}, - {0x0000b0ac, 0x02050400}, - {0x0000b0b0, 0x02050401}, - {0x0000b0b4, 0x02050402}, - {0x0000b0b8, 0x02050403}, - {0x0000b0bc, 0x02050500}, - {0x0000b0c0, 0x02050501}, - {0x0000b0c4, 0x02050502}, - {0x0000b0c8, 0x02050503}, - {0x0000b0cc, 0x02050504}, - {0x0000b0d0, 0x02050600}, - {0x0000b0d4, 0x02050601}, - {0x0000b0d8, 0x02050602}, - {0x0000b0dc, 0x02050603}, - {0x0000b0e0, 0x02050604}, - {0x0000b0e4, 0x02050700}, - {0x0000b0e8, 0x02050701}, - {0x0000b0ec, 0x02050702}, - {0x0000b0f0, 0x02050703}, - {0x0000b0f4, 0x02050704}, - {0x0000b0f8, 0x02050705}, - {0x0000b0fc, 0x02050708}, - {0x0000b100, 0x02050709}, - {0x0000b104, 0x0205070a}, - {0x0000b108, 0x0205070b}, - {0x0000b10c, 0x0205070c}, - {0x0000b110, 0x0205070d}, - {0x0000b114, 0x02050710}, - {0x0000b118, 0x02050711}, - {0x0000b11c, 0x02050712}, - {0x0000b120, 0x02050713}, - {0x0000b124, 0x02050714}, - {0x0000b128, 0x02050715}, - {0x0000b12c, 0x02050730}, - {0x0000b130, 0x02050731}, - {0x0000b134, 0x02050732}, - {0x0000b138, 0x02050733}, - {0x0000b13c, 0x02050734}, - {0x0000b140, 0x02050735}, - {0x0000b144, 0x02050750}, - {0x0000b148, 0x02050751}, - {0x0000b14c, 0x02050752}, - {0x0000b150, 0x02050753}, - {0x0000b154, 0x02050754}, - {0x0000b158, 0x02050755}, - {0x0000b15c, 0x02050770}, - {0x0000b160, 0x02050771}, - {0x0000b164, 0x02050772}, - {0x0000b168, 0x02050773}, - {0x0000b16c, 0x02050774}, - {0x0000b170, 0x02050775}, - {0x0000b174, 0x00000776}, - {0x0000b178, 0x00000776}, - {0x0000b17c, 0x00000776}, - {0x0000b180, 0x00000776}, - {0x0000b184, 0x00000776}, - {0x0000b188, 0x00000776}, - {0x0000b18c, 0x00000776}, - {0x0000b190, 0x00000776}, - {0x0000b194, 0x00000776}, - {0x0000b198, 0x00000776}, - {0x0000b19c, 0x00000776}, - {0x0000b1a0, 0x00000776}, - {0x0000b1a4, 0x00000776}, - {0x0000b1a8, 0x00000776}, - {0x0000b1ac, 0x00000776}, - {0x0000b1b0, 0x00000776}, - {0x0000b1b4, 0x00000776}, - {0x0000b1b8, 0x00000776}, - {0x0000b1bc, 0x00000776}, - {0x0000b1c0, 0x00000776}, - {0x0000b1c4, 0x00000776}, - {0x0000b1c8, 0x00000776}, - {0x0000b1cc, 0x00000776}, - {0x0000b1d0, 0x00000776}, - {0x0000b1d4, 0x00000776}, - {0x0000b1d8, 0x00000776}, - {0x0000b1dc, 0x00000776}, - {0x0000b1e0, 0x00000776}, - {0x0000b1e4, 0x00000776}, - {0x0000b1e8, 0x00000776}, - {0x0000b1ec, 0x00000776}, - {0x0000b1f0, 0x00000776}, - {0x0000b1f4, 0x00000776}, - {0x0000b1f8, 0x00000776}, - {0x0000b1fc, 0x00000776}, -}; - -static const u32 ar9200_ar9280_2p0_radio_core[][2] = { - /* Addr allmodes */ - {0x00007800, 0x00040000}, - {0x00007804, 0xdb005012}, - {0x00007808, 0x04924914}, - {0x0000780c, 0x21084210}, - {0x00007810, 0x6d801300}, - {0x00007814, 0x0019beff}, - {0x00007818, 0x07e41000}, - {0x0000781c, 0x00392000}, - {0x00007820, 0x92592480}, - {0x00007824, 0x00040000}, - {0x00007828, 0xdb005012}, - {0x0000782c, 0x04924914}, - {0x00007830, 0x21084210}, - {0x00007834, 0x6d801300}, - {0x00007838, 0x0019beff}, - {0x0000783c, 0x07e40000}, - {0x00007840, 0x00392000}, - {0x00007844, 0x92592480}, - {0x00007848, 0x00100000}, - {0x0000784c, 0x773f0567}, - {0x00007850, 0x54214514}, - {0x00007854, 0x12035828}, - {0x00007858, 0x92592692}, - {0x0000785c, 0x00000000}, - {0x00007860, 0x56400000}, - {0x00007864, 0x0a8e370e}, - {0x00007868, 0xc0102850}, - {0x0000786c, 0x812d4000}, - {0x00007870, 0x807ec400}, - {0x00007874, 0x001b6db0}, - {0x00007878, 0x00376b63}, - {0x0000787c, 0x06db6db6}, - {0x00007880, 0x006d8000}, - {0x00007884, 0xffeffffe}, - {0x00007888, 0xffeffffe}, - {0x0000788c, 0x00010000}, - {0x00007890, 0x02060aeb}, - {0x00007894, 0x5a108000}, -}; - -static const u32 ar9462_2p0_mac_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00008014, 0x10f810f8, 0x10f810f8, 0x10f810f8, 0x10f810f8}, - {0x0000801c, 0x0e8d8017, 0x0e8d8017, 0x0e8d8017, 0x0e8d8017}, -}; - -static const u32 ar9462_2p0_radio_postamble_sys3ant[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, - {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, - {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, -}; - -static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00009e3c, 0xcf946221, 0xcf946221, 0xcf946221, 0xcf946221}, - {0x00009e44, 0xfc5c0000, 0xfc5c0000, 0xfc5c0000, 0xfc5c0000}, - {0x0000a258, 0x02020200, 0x02020200, 0x02020200, 0x02020200}, - {0x0000a25c, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e}, - {0x0000a28c, 0x00011111, 0x00011111, 0x00011111, 0x00011111}, - {0x0000a2c4, 0x00148d18, 0x00148d18, 0x00148d20, 0x00148d20}, - {0x0000a2d8, 0xf999a800, 0xf999a800, 0xf999a80c, 0xf999a80c}, - {0x0000a50c, 0x0000c00a, 0x0000c00a, 0x0000c00a, 0x0000c00a}, - {0x0000a538, 0x00038e8c, 0x00038e8c, 0x00038e8c, 0x00038e8c}, - {0x0000a53c, 0x0003cecc, 0x0003cecc, 0x0003cecc, 0x0003cecc}, - {0x0000a540, 0x00040ed4, 0x00040ed4, 0x00040ed4, 0x00040ed4}, - {0x0000a544, 0x00044edc, 0x00044edc, 0x00044edc, 0x00044edc}, - {0x0000a548, 0x00048ede, 0x00048ede, 0x00048ede, 0x00048ede}, - {0x0000a54c, 0x0004cf1e, 0x0004cf1e, 0x0004cf1e, 0x0004cf1e}, - {0x0000a550, 0x00050f5e, 0x00050f5e, 0x00050f5e, 0x00050f5e}, - {0x0000a554, 0x00054f9e, 0x00054f9e, 0x00054f9e, 0x00054f9e}, - {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, -}; - static const u32 ar9462_2p0_radio_postamble_sys2ant[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, @@ -1356,24 +1005,6 @@ static const u32 ar9462_2p0_radio_core[][2] = { {0x00016548, 0x000080c0}, }; -static const u32 ar9462_2p0_tx_gain_table_baseband_postamble_emulation[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a410, 0x000000d5, 0x000000d5, 0x000000d5, 0x000000d5}, - {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a504, 0x00004002, 0x00004002, 0x00004002, 0x00004002}, - {0x0000a508, 0x00008004, 0x00008004, 0x00008004, 0x00008004}, - {0x0000a510, 0x0001000c, 0x0001000c, 0x0001000c, 0x0001000c}, - {0x0000a514, 0x0001420b, 0x0001420b, 0x0001420b, 0x0001420b}, - {0x0000a518, 0x0001824a, 0x0001824a, 0x0001824a, 0x0001824a}, - {0x0000a51c, 0x0001c44a, 0x0001c44a, 0x0001c44a, 0x0001c44a}, - {0x0000a520, 0x0002064a, 0x0002064a, 0x0002064a, 0x0002064a}, - {0x0000a524, 0x0002484a, 0x0002484a, 0x0002484a, 0x0002484a}, - {0x0000a528, 0x00028a4a, 0x00028a4a, 0x00028a4a, 0x00028a4a}, - {0x0000a52c, 0x0002cc4a, 0x0002cc4a, 0x0002cc4a, 0x0002cc4a}, - {0x0000a530, 0x00030e4a, 0x00030e4a, 0x00030e4a, 0x00030e4a}, - {0x0000a534, 0x00034e8a, 0x00034e8a, 0x00034e8a, 0x00034e8a}, -}; - static const u32 ar9462_2p0_soc_preamble[][2] = { /* Addr allmodes */ {0x00007020, 0x00000000}, @@ -1381,11 +1012,6 @@ static const u32 ar9462_2p0_soc_preamble[][2] = { {0x00007038, 0x000004c2}, }; -static const u32 ar9462_2p0_sys2ant[][2] = { - /* Addr allmodes */ - {0x00063120, 0x00801980}, -}; - static const u32 ar9462_2p0_mac_core[][2] = { /* Addr allmodes */ {0x00000008, 0x00000000}, @@ -1822,75 +1448,6 @@ static const u32 ar9462_common_mixed_rx_gain_table_2p0[][2] = { {0x0000b1fc, 0x00000196}, }; -static const u32 ar9462_modes_green_ob_db_tx_gain_table_2p0[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x000098bc, 0x00000003, 0x00000003, 0x00000003, 0x00000003}, - {0x0000a2dc, 0x01feee00, 0x01feee00, 0x03aaa352, 0x03aaa352}, - {0x0000a2e0, 0x0000f000, 0x0000f000, 0x03ccc584, 0x03ccc584}, - {0x0000a2e4, 0x01ff0000, 0x01ff0000, 0x03f0f800, 0x03f0f800}, - {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, - {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, - {0x0000a458, 0x80000000, 0x80000000, 0x80000000, 0x80000000}, - {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, - {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002}, - {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004}, - {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200}, - {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202}, - {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400}, - {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402}, - {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404}, - {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603}, - {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02}, - {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04}, - {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20}, - {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20}, - {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22}, - {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24}, - {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640}, - {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, - {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, - {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, - {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, - {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, - {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, - {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, - {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, - {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb}, - {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00804000, 0x00804000, 0x00000000, 0x00000000}, - {0x0000a614, 0x00804201, 0x00804201, 0x01404000, 0x01404000}, - {0x0000a618, 0x0280c802, 0x0280c802, 0x01404501, 0x01404501}, - {0x0000a61c, 0x0280ca03, 0x0280ca03, 0x02008501, 0x02008501}, - {0x0000a620, 0x04c15104, 0x04c15104, 0x0280ca03, 0x0280ca03}, - {0x0000a624, 0x04c15305, 0x04c15305, 0x03010c04, 0x03010c04}, - {0x0000a628, 0x04c15305, 0x04c15305, 0x04014c04, 0x04014c04}, - {0x0000a62c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a630, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a634, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a638, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a63c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000b2dc, 0x01feee00, 0x01feee00, 0x03aaa352, 0x03aaa352}, - {0x0000b2e0, 0x0000f000, 0x0000f000, 0x03ccc584, 0x03ccc584}, - {0x0000b2e4, 0x01ff0000, 0x01ff0000, 0x03f0f800, 0x03f0f800}, - {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, - {0x00016044, 0x056d82e4, 0x056d82e4, 0x056d82e4, 0x056d82e4}, - {0x00016048, 0x8db49060, 0x8db49060, 0x8db49060, 0x8db49060}, - {0x00016054, 0x6db60180, 0x6db60180, 0x6db60180, 0x6db60180}, - {0x00016444, 0x056d82e4, 0x056d82e4, 0x056d82e4, 0x056d82e4}, - {0x00016448, 0x8db49000, 0x8db49000, 0x8db49000, 0x8db49000}, - {0x00016454, 0x6db60180, 0x6db60180, 0x6db60180, 0x6db60180}, -}; - static const u32 ar9462_2p0_BTCOEX_MAX_TXPWR_table[][2] = { /* Addr allmodes */ {0x000018c0, 0x10101010}, @@ -1903,26 +1460,4 @@ static const u32 ar9462_2p0_BTCOEX_MAX_TXPWR_table[][2] = { {0x000018dc, 0x10101010}, }; -static const u32 ar9462_2p0_baseband_core_emulation[][2] = { - /* Addr allmodes */ - {0x00009800, 0xafa68e30}, - {0x00009884, 0x00002842}, - {0x00009c04, 0xff55ff55}, - {0x00009c08, 0x0320ff55}, - {0x00009e50, 0x00000000}, - {0x00009fcc, 0x00000014}, - {0x0000a344, 0x00000010}, - {0x0000a398, 0x00000000}, - {0x0000a39c, 0x71733d01}, - {0x0000a3a0, 0xd0ad5c12}, - {0x0000a3c0, 0x22222220}, - {0x0000a3c4, 0x22222222}, - {0x0000a404, 0x00418a11}, - {0x0000a418, 0x050001ce}, - {0x0000a438, 0x00001800}, - {0x0000a458, 0x01444452}, - {0x0000a644, 0x3fad9d74}, - {0x0000a690, 0x00000038}, -}; - #endif /* INITVALS_9462_2P0_H */ -- GitLab From ae245cde14b2386fe77023af3934db96409d1807 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:52:44 +0530 Subject: [PATCH 1136/1846] ath9k: Initialize NF values properly Using AR_SREV_* macros for setting up the chip-specific NF values will make adding support for new chips hard. Use separate macros for each chip. Currently, AR9462 has the same value for all NF limits. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 15 +++++++++++---- drivers/net/wireless/ath/ath9k/ar9003_phy.h | 13 +++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index 2b0bfb8cca02..70e27d2a5e43 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c @@ -1099,13 +1099,20 @@ static void ar9003_hw_set_nf_limits(struct ath_hw *ah) { ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ; ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9300_2GHZ; - if (AR_SREV_9330(ah)) - ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9330_2GHZ; - else - ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9300_2GHZ; + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9300_2GHZ; ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_5GHZ; ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9300_5GHZ; ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9300_5GHZ; + + if (AR_SREV_9330(ah)) + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9330_2GHZ; + + if (AR_SREV_9462(ah)) { + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9462_2GHZ; + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9462_2GHZ; + ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9462_5GHZ; + ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9462_5GHZ; + } } /* diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index ed64114571fc..aca24bfdc6c3 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h @@ -325,13 +325,18 @@ #define AR_PHY_RX_OCGAIN (AR_AGC_BASE + 0x200) -#define AR_PHY_CCA_NOM_VAL_9300_2GHZ (AR_SREV_9462(ah) ? -127 : -110) -#define AR_PHY_CCA_NOM_VAL_9300_5GHZ (AR_SREV_9462(ah) ? -127 : -115) -#define AR_PHY_CCA_MIN_GOOD_VAL_9300_2GHZ (AR_SREV_9462(ah) ? -127 : -125) -#define AR_PHY_CCA_MIN_GOOD_VAL_9300_5GHZ (AR_SREV_9462(ah) ? -127 : -125) +#define AR_PHY_CCA_NOM_VAL_9300_2GHZ -110 +#define AR_PHY_CCA_NOM_VAL_9300_5GHZ -115 +#define AR_PHY_CCA_MIN_GOOD_VAL_9300_2GHZ -125 +#define AR_PHY_CCA_MIN_GOOD_VAL_9300_5GHZ -125 #define AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ -95 #define AR_PHY_CCA_MAX_GOOD_VAL_9300_5GHZ -100 +#define AR_PHY_CCA_NOM_VAL_9462_2GHZ -127 +#define AR_PHY_CCA_MIN_GOOD_VAL_9462_2GHZ -127 +#define AR_PHY_CCA_NOM_VAL_9462_5GHZ -127 +#define AR_PHY_CCA_MIN_GOOD_VAL_9462_5GHZ -127 + #define AR_PHY_CCA_NOM_VAL_9330_2GHZ -118 /* -- GitLab From f4c6ac27d6f4fc775cf6532f298dc1fc346083a7 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:52:50 +0530 Subject: [PATCH 1137/1846] ath9k: Fix programming SYNTH4 for AR9462 The LONG_SHIFT_SELECT offset is different for AR9462 from the other chip families. Fix this. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_phy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index aca24bfdc6c3..81f3e857ff28 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h @@ -625,8 +625,8 @@ #define AR_PHY_AIC_STAT_2_B0 (AR_SM_BASE + 0x4cc) #define AR_PHY_65NM_CH0_SYNTH4 0x1608c -#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT 0x00000002 -#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT_S 1 +#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT (AR_SREV_9462(ah) ? 0x00000001 : 0x00000002) +#define AR_PHY_SYNTH4_LONG_SHIFT_SELECT_S (AR_SREV_9462(ah) ? 0 : 1) #define AR_PHY_65NM_CH0_SYNTH7 0x16098 #define AR_PHY_65NM_CH0_BIAS1 0x160c0 #define AR_PHY_65NM_CH0_BIAS2 0x160c4 -- GitLab From 9da27232060411e98c27a8407610c794acb08c8b Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Thu, 16 Feb 2012 11:53:00 +0530 Subject: [PATCH 1138/1846] ath9k: Fix descriptor length for AR9462 Change the descriptor length to 24 and explicitly set the control field 23 to zero. Not doing so would result in dropping of frames. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 6 +++++- drivers/net/wireless/ath/ath9k/ar9003_mac.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 09b8c9dbf78f..39cb4829f292 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -28,11 +28,14 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i) struct ar9003_txc *ads = ds; int checksum = 0; u32 val, ctl12, ctl17; + u8 desc_len; + + desc_len = (AR_SREV_9462(ah) ? 0x18 : 0x17); val = (ATHEROS_VENDOR_ID << AR_DescId_S) | (1 << AR_TxRxDesc_S) | (1 << AR_CtrlStat_S) | - (i->qcu << AR_TxQcuNum_S) | 0x17; + (i->qcu << AR_TxQcuNum_S) | desc_len; checksum += val; ACCESS_ONCE(ads->info) = val; @@ -81,6 +84,7 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i) ads->ctl20 = 0; ads->ctl21 = 0; ads->ctl22 = 0; + ads->ctl23 = 0; ctl17 = SM(i->keytype, AR_EncrType); if (!i->is_first) { diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.h b/drivers/net/wireless/ath/ath9k/ar9003_mac.h index e203b51e968b..cbf60b090bd9 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.h @@ -92,7 +92,8 @@ struct ar9003_txc { u32 ctl20; /* DMA control 20 */ u32 ctl21; /* DMA control 21 */ u32 ctl22; /* DMA control 22 */ - u32 pad[9]; /* pad to cache line (128 bytes/32 dwords) */ + u32 ctl23; /* DMA control 23 */ + u32 pad[8]; /* pad to cache line (128 bytes/32 dwords) */ } __packed __aligned(4); struct ar9003_txs { -- GitLab From 2e9c43dd45ced5bd77c94d4216f96b4a49448d73 Mon Sep 17 00:00:00 2001 From: John Li Date: Thu, 16 Feb 2012 21:40:57 +0800 Subject: [PATCH 1139/1846] rt2x00:Add VCO recalibration Signed-off-by: John Li Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 9 +++ drivers/net/wireless/rt2x00/rt2800lib.c | 88 ++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2800lib.h | 1 + drivers/net/wireless/rt2x00/rt2800pci.c | 1 + drivers/net/wireless/rt2x00/rt2800usb.c | 1 + drivers/net/wireless/rt2x00/rt2x00.h | 12 +++ drivers/net/wireless/rt2x00/rt2x00config.c | 3 + drivers/net/wireless/rt2x00/rt2x00dev.c | 4 + drivers/net/wireless/rt2x00/rt2x00lib.h | 13 ++++ drivers/net/wireless/rt2x00/rt2x00link.c | 39 ++++++++++ 10 files changed, 171 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index 06acabd02984..62e697ffc6d1 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -965,6 +965,7 @@ * TX_PIN_CFG: */ #define TX_PIN_CFG 0x1328 +#define TX_PIN_CFG_PA_PE_DISABLE 0xfcfffff0 #define TX_PIN_CFG_PA_PE_A0_EN FIELD32(0x00000001) #define TX_PIN_CFG_PA_PE_G0_EN FIELD32(0x00000002) #define TX_PIN_CFG_PA_PE_A1_EN FIELD32(0x00000004) @@ -985,6 +986,14 @@ #define TX_PIN_CFG_RFTR_POL FIELD32(0x00020000) #define TX_PIN_CFG_TRSW_EN FIELD32(0x00040000) #define TX_PIN_CFG_TRSW_POL FIELD32(0x00080000) +#define TX_PIN_CFG_PA_PE_A2_EN FIELD32(0x01000000) +#define TX_PIN_CFG_PA_PE_G2_EN FIELD32(0x02000000) +#define TX_PIN_CFG_PA_PE_A2_POL FIELD32(0x04000000) +#define TX_PIN_CFG_PA_PE_G2_POL FIELD32(0x08000000) +#define TX_PIN_CFG_LNA_PE_A2_EN FIELD32(0x10000000) +#define TX_PIN_CFG_LNA_PE_G2_EN FIELD32(0x20000000) +#define TX_PIN_CFG_LNA_PE_A2_POL FIELD32(0x40000000) +#define TX_PIN_CFG_LNA_PE_G2_POL FIELD32(0x80000000) /* * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index f1df929e97a7..6104a14e4fff 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -2497,6 +2497,80 @@ void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev) } EXPORT_SYMBOL_GPL(rt2800_gain_calibration); +void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev) +{ + u32 tx_pin; + u8 rfcsr; + + /* + * A voltage-controlled oscillator(VCO) is an electronic oscillator + * designed to be controlled in oscillation frequency by a voltage + * input. Maybe the temperature will affect the frequency of + * oscillation to be shifted. The VCO calibration will be called + * periodically to adjust the frequency to be precision. + */ + + rt2800_register_read(rt2x00dev, TX_PIN_CFG, &tx_pin); + tx_pin &= TX_PIN_CFG_PA_PE_DISABLE; + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); + + switch (rt2x00dev->chip.rf) { + case RF2020: + case RF3020: + case RF3021: + case RF3022: + case RF3320: + case RF3052: + rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); + rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); + break; + case RF5370: + case RF5372: + case RF5390: + rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1); + rt2800_rfcsr_write(rt2x00dev, 3, rfcsr); + break; + default: + return; + } + + mdelay(1); + + rt2800_register_read(rt2x00dev, TX_PIN_CFG, &tx_pin); + if (rt2x00dev->rf_channel <= 14) { + switch (rt2x00dev->default_ant.tx_chain_num) { + case 3: + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G2_EN, 1); + /* fall through */ + case 2: + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1); + /* fall through */ + case 1: + default: + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1); + break; + } + } else { + switch (rt2x00dev->default_ant.tx_chain_num) { + case 3: + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A2_EN, 1); + /* fall through */ + case 2: + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1); + /* fall through */ + case 1: + default: + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, 1); + break; + } + } + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); + +} +EXPORT_SYMBOL_GPL(rt2800_vco_calibration); + static void rt2800_config_retry_limit(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_conf *libconf) { @@ -4451,6 +4525,20 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) } } + switch (rt2x00dev->chip.rf) { + case RF2020: + case RF3020: + case RF3021: + case RF3022: + case RF3320: + case RF3052: + case RF5370: + case RF5372: + case RF5390: + __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags); + break; + } + return 0; } EXPORT_SYMBOL_GPL(rt2800_probe_hw_mode); diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h index 8c3c281904fe..419e36cb06be 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/rt2x00/rt2800lib.h @@ -184,6 +184,7 @@ void rt2800_reset_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual); void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, const u32 count); void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev); +void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev); int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev); void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev); diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 6ad692914ee9..fc9acc299b10 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -1050,6 +1050,7 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { .reset_tuner = rt2800_reset_tuner, .link_tuner = rt2800_link_tuner, .gain_calibration = rt2800_gain_calibration, + .vco_calibration = rt2800_vco_calibration, .start_queue = rt2800pci_start_queue, .kick_queue = rt2800pci_kick_queue, .stop_queue = rt2800pci_stop_queue, diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 0074c4e18d29..f997f0056d7f 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -781,6 +781,7 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = { .reset_tuner = rt2800_reset_tuner, .link_tuner = rt2800_link_tuner, .gain_calibration = rt2800_gain_calibration, + .vco_calibration = rt2800_vco_calibration, .watchdog = rt2800usb_watchdog, .start_queue = rt2800usb_start_queue, .kick_queue = rt2x00usb_kick_queue, diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index ed2ae6efcaa3..1906a94e448f 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -355,6 +355,11 @@ struct link { * Work structure for scheduling periodic AGC adjustments. */ struct delayed_work agc_work; + + /* + * Work structure for scheduling periodic VCO calibration. + */ + struct delayed_work vco_work; }; enum rt2x00_delayed_flags { @@ -579,6 +584,7 @@ struct rt2x00lib_ops { void (*link_tuner) (struct rt2x00_dev *rt2x00dev, struct link_qual *qual, const u32 count); void (*gain_calibration) (struct rt2x00_dev *rt2x00dev); + void (*vco_calibration) (struct rt2x00_dev *rt2x00dev); /* * Data queue handlers. @@ -722,6 +728,7 @@ enum rt2x00_capability_flags { CAPABILITY_EXTERNAL_LNA_BG, CAPABILITY_DOUBLE_ANTENNA, CAPABILITY_BT_COEXIST, + CAPABILITY_VCO_RECALIBRATION, }; /* @@ -977,6 +984,11 @@ struct rt2x00_dev { struct tasklet_struct rxdone_tasklet; struct tasklet_struct autowake_tasklet; + /* + * Used for VCO periodic calibration. + */ + int rf_channel; + /* * Protect the interrupt mask register. */ diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c index b704e5b183d0..d7c0f86c9e43 100644 --- a/drivers/net/wireless/rt2x00/rt2x00config.c +++ b/drivers/net/wireless/rt2x00/rt2x00config.c @@ -232,6 +232,9 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, memcpy(&libconf.channel, &rt2x00dev->spec.channels_info[hw_value], sizeof(libconf.channel)); + + /* Used for VCO periodic calibration */ + rt2x00dev->rf_channel = libconf.rf.channel; } if (test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) && diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index bae5b01299ea..dfe485a872f6 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -88,6 +88,8 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev) rt2x00queue_start_queues(rt2x00dev); rt2x00link_start_tuner(rt2x00dev); rt2x00link_start_agc(rt2x00dev); + if (test_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags)) + rt2x00link_start_vcocal(rt2x00dev); /* * Start watchdog monitoring. @@ -111,6 +113,8 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev) * Stop all queues */ rt2x00link_stop_agc(rt2x00dev); + if (test_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags)) + rt2x00link_stop_vcocal(rt2x00dev); rt2x00link_stop_tuner(rt2x00dev); rt2x00queue_stop_queues(rt2x00dev); rt2x00queue_flush_queues(rt2x00dev, true); diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h index 4cdf247a870d..78bd43b8961f 100644 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h @@ -33,6 +33,7 @@ #define WATCHDOG_INTERVAL round_jiffies_relative(HZ) #define LINK_TUNE_INTERVAL round_jiffies_relative(HZ) #define AGC_INTERVAL round_jiffies_relative(4 * HZ) +#define VCO_INTERVAL round_jiffies_relative(10 * HZ) /* 10 sec */ /* * rt2x00_rate: Per rate device information @@ -277,12 +278,24 @@ void rt2x00link_stop_watchdog(struct rt2x00_dev *rt2x00dev); */ void rt2x00link_start_agc(struct rt2x00_dev *rt2x00dev); +/** + * rt2x00link_start_vcocal - Start periodic VCO calibration + * @rt2x00dev: Pointer to &struct rt2x00_dev. + */ +void rt2x00link_start_vcocal(struct rt2x00_dev *rt2x00dev); + /** * rt2x00link_stop_agc - Stop periodic gain calibration * @rt2x00dev: Pointer to &struct rt2x00_dev. */ void rt2x00link_stop_agc(struct rt2x00_dev *rt2x00dev); +/** + * rt2x00link_stop_vcocal - Stop periodic VCO calibration + * @rt2x00dev: Pointer to &struct rt2x00_dev. + */ +void rt2x00link_stop_vcocal(struct rt2x00_dev *rt2x00dev); + /** * rt2x00link_register - Initialize link tuning & watchdog functionality * @rt2x00dev: Pointer to &struct rt2x00_dev. diff --git a/drivers/net/wireless/rt2x00/rt2x00link.c b/drivers/net/wireless/rt2x00/rt2x00link.c index ea10b0068f82..8368aab86f28 100644 --- a/drivers/net/wireless/rt2x00/rt2x00link.c +++ b/drivers/net/wireless/rt2x00/rt2x00link.c @@ -447,11 +447,27 @@ void rt2x00link_start_agc(struct rt2x00_dev *rt2x00dev) AGC_INTERVAL); } +void rt2x00link_start_vcocal(struct rt2x00_dev *rt2x00dev) +{ + struct link *link = &rt2x00dev->link; + + if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) && + rt2x00dev->ops->lib->vco_calibration) + ieee80211_queue_delayed_work(rt2x00dev->hw, + &link->vco_work, + VCO_INTERVAL); +} + void rt2x00link_stop_agc(struct rt2x00_dev *rt2x00dev) { cancel_delayed_work_sync(&rt2x00dev->link.agc_work); } +void rt2x00link_stop_vcocal(struct rt2x00_dev *rt2x00dev) +{ + cancel_delayed_work_sync(&rt2x00dev->link.vco_work); +} + static void rt2x00link_agc(struct work_struct *work) { struct rt2x00_dev *rt2x00dev = @@ -473,9 +489,32 @@ static void rt2x00link_agc(struct work_struct *work) AGC_INTERVAL); } +static void rt2x00link_vcocal(struct work_struct *work) +{ + struct rt2x00_dev *rt2x00dev = + container_of(work, struct rt2x00_dev, link.vco_work.work); + struct link *link = &rt2x00dev->link; + + /* + * When the radio is shutting down we should + * immediately cease the VCO calibration. + */ + if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) + return; + + rt2x00dev->ops->lib->vco_calibration(rt2x00dev); + + if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) + ieee80211_queue_delayed_work(rt2x00dev->hw, + &link->vco_work, + VCO_INTERVAL); +} + void rt2x00link_register(struct rt2x00_dev *rt2x00dev) { INIT_DELAYED_WORK(&rt2x00dev->link.agc_work, rt2x00link_agc); + if (test_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags)) + INIT_DELAYED_WORK(&rt2x00dev->link.vco_work, rt2x00link_vcocal); INIT_DELAYED_WORK(&rt2x00dev->link.watchdog_work, rt2x00link_watchdog); INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00link_tuner); } -- GitLab From 4e3c3b88a9c743cb9ddd65eb1cdd15ade25abfb4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 16 Feb 2012 12:14:36 -0600 Subject: [PATCH 1140/1846] rtlwifi: Fix breakage in debug functions when built as a module Since commit 481b9606, it has not been possible to invoke debugging with any rtlwifi driver built as a module. Reported-by: Johannes Berg Signed-off-by: Larry Finger Cc: Joe Perches Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig index 44b9c0a57702..cefac6a43601 100644 --- a/drivers/net/wireless/rtlwifi/Kconfig +++ b/drivers/net/wireless/rtlwifi/Kconfig @@ -50,7 +50,7 @@ config RTLWIFI default m config RTLWIFI_DEBUG - tristate "Additional debugging output" + bool "Additional debugging output" depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE default y -- GitLab From a39fb224b49c5aebb40c4d5c9d6ccf3a951053ee Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 16 Feb 2012 22:14:45 -0500 Subject: [PATCH 1141/1846] ath9k: avoid useless cast from (struct ath_rateset *) to (u8 *) and back Signed-off-by: Pavel Roskin Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/rc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index a427a16bb739..b8c6c38cbb98 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -567,10 +567,8 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv, static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv, const struct ath_rate_table *rate_table, - u8 *mcs_set, u32 capflag) + struct ath_rateset *rateset, u32 capflag) { - struct ath_rateset *rateset = (struct ath_rateset *)mcs_set; - u8 i, j, hi = 0; /* Use intersection of working rates and valid rates */ @@ -1212,7 +1210,7 @@ static void ath_rc_init(struct ath_softc *sc, { struct ath_rateset *rateset = &ath_rc_priv->neg_rates; struct ath_common *common = ath9k_hw_common(sc->sc_ah); - u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; + struct ath_rateset *ht_mcs = &ath_rc_priv->neg_ht_rates; u8 i, j, k, hi = 0, hthi = 0; /* Initial rate table size. Will change depending -- GitLab From 2ed7188447fd48336f296ce2dfbd35785768d28c Mon Sep 17 00:00:00 2001 From: John Li Date: Fri, 17 Feb 2012 17:33:06 +0800 Subject: [PATCH 1142/1846] rt2x00:Add RT5372 chipset support Signed-off-by: John Li Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 1 + drivers/net/wireless/rt2x00/rt2800lib.c | 153 ++++++++++++++++++++---- drivers/net/wireless/rt2x00/rt2800pci.c | 3 +- drivers/net/wireless/rt2x00/rt2800usb.c | 14 +++ drivers/net/wireless/rt2x00/rt2x00.h | 1 + 5 files changed, 147 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index 62e697ffc6d1..3b32f847c834 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -68,6 +68,7 @@ #define RF3322 0x000c #define RF3053 0x000d #define RF5370 0x5370 +#define RF5372 0x5372 #define RF5390 0x5390 /* diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 6104a14e4fff..474b5b9e6238 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -402,7 +402,8 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev, if (rt2x00_is_pci(rt2x00dev)) { if (rt2x00_rt(rt2x00dev, RT3572) || - rt2x00_rt(rt2x00dev, RT5390)) { + rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_register_read(rt2x00dev, AUX_CTRL, ®); rt2x00_set_field32(®, AUX_CTRL_FORCE_PCIE_CLK, 1); rt2x00_set_field32(®, AUX_CTRL_WAKE_PCIE_EN, 1); @@ -1989,7 +1990,8 @@ static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev, r55_nonbt_rev[idx]); rt2800_rfcsr_write(rt2x00dev, 59, r59_nonbt_rev[idx]); - } else if (rt2x00_rt(rt2x00dev, RT5390)) { + } else if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { static const char r59_non_bt[] = {0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8d, 0x8a, 0x88, 0x88, 0x87, 0x87, 0x86}; @@ -2039,6 +2041,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, rt2800_config_channel_rf3052(rt2x00dev, conf, rf, info); break; case RF5370: + case RF5372: case RF5390: rt2800_config_channel_rf53xx(rt2x00dev, conf, rf, info); break; @@ -2055,7 +2058,8 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, rt2800_bbp_write(rt2x00dev, 86, 0); if (rf->channel <= 14) { - if (!rt2x00_rt(rt2x00dev, RT5390)) { + if (!rt2x00_rt(rt2x00dev, RT5390) && + !rt2x00_rt(rt2x00dev, RT5392)) { if (test_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags)) { rt2800_bbp_write(rt2x00dev, 82, 0x62); @@ -2659,7 +2663,8 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev) rt2x00_rt(rt2x00dev, RT3071) || rt2x00_rt(rt2x00dev, RT3090) || rt2x00_rt(rt2x00dev, RT3390) || - rt2x00_rt(rt2x00dev, RT5390)) + rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) return 0x1c + (2 * rt2x00dev->lna_gain); else return 0x2e + rt2x00dev->lna_gain; @@ -2794,7 +2799,8 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) } else if (rt2x00_rt(rt2x00dev, RT3572)) { rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); - } else if (rt2x00_rt(rt2x00dev, RT5390)) { + } else if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404); rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); @@ -3170,7 +3176,8 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) rt2800_wait_bbp_ready(rt2x00dev))) return -EACCES; - if (rt2x00_rt(rt2x00dev, RT5390)) { + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_bbp_read(rt2x00dev, 4, &value); rt2x00_set_field8(&value, BBP4_MAC_IF_CTRL, 1); rt2800_bbp_write(rt2x00dev, 4, value); @@ -3178,19 +3185,22 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) if (rt2800_is_305x_soc(rt2x00dev) || rt2x00_rt(rt2x00dev, RT3572) || - rt2x00_rt(rt2x00dev, RT5390)) + rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 31, 0x08); rt2800_bbp_write(rt2x00dev, 65, 0x2c); rt2800_bbp_write(rt2x00dev, 66, 0x38); - if (rt2x00_rt(rt2x00dev, RT5390)) + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 68, 0x0b); if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) { rt2800_bbp_write(rt2x00dev, 69, 0x16); rt2800_bbp_write(rt2x00dev, 73, 0x12); - } else if (rt2x00_rt(rt2x00dev, RT5390)) { + } else if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_bbp_write(rt2x00dev, 69, 0x12); rt2800_bbp_write(rt2x00dev, 73, 0x13); rt2800_bbp_write(rt2x00dev, 75, 0x46); @@ -3208,7 +3218,8 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) rt2x00_rt(rt2x00dev, RT3090) || rt2x00_rt(rt2x00dev, RT3390) || rt2x00_rt(rt2x00dev, RT3572) || - rt2x00_rt(rt2x00dev, RT5390)) { + rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_bbp_write(rt2x00dev, 79, 0x13); rt2800_bbp_write(rt2x00dev, 80, 0x05); rt2800_bbp_write(rt2x00dev, 81, 0x33); @@ -3220,64 +3231,88 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) } rt2800_bbp_write(rt2x00dev, 82, 0x62); - if (rt2x00_rt(rt2x00dev, RT5390)) + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 83, 0x7a); else rt2800_bbp_write(rt2x00dev, 83, 0x6a); if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860D)) rt2800_bbp_write(rt2x00dev, 84, 0x19); - else if (rt2x00_rt(rt2x00dev, RT5390)) + else if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 84, 0x9a); else rt2800_bbp_write(rt2x00dev, 84, 0x99); - if (rt2x00_rt(rt2x00dev, RT5390)) + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 86, 0x38); else rt2800_bbp_write(rt2x00dev, 86, 0x00); + if (rt2x00_rt(rt2x00dev, RT5392)) + rt2800_bbp_write(rt2x00dev, 88, 0x90); + rt2800_bbp_write(rt2x00dev, 91, 0x04); - if (rt2x00_rt(rt2x00dev, RT5390)) + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 92, 0x02); else rt2800_bbp_write(rt2x00dev, 92, 0x00); + if (rt2x00_rt(rt2x00dev, RT5392)) { + rt2800_bbp_write(rt2x00dev, 95, 0x9a); + rt2800_bbp_write(rt2x00dev, 98, 0x12); + } + if (rt2x00_rt_rev_gte(rt2x00dev, RT3070, REV_RT3070F) || rt2x00_rt_rev_gte(rt2x00dev, RT3071, REV_RT3071E) || rt2x00_rt_rev_gte(rt2x00dev, RT3090, REV_RT3090E) || rt2x00_rt_rev_gte(rt2x00dev, RT3390, REV_RT3390E) || rt2x00_rt(rt2x00dev, RT3572) || rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392) || rt2800_is_305x_soc(rt2x00dev)) rt2800_bbp_write(rt2x00dev, 103, 0xc0); else rt2800_bbp_write(rt2x00dev, 103, 0x00); - if (rt2x00_rt(rt2x00dev, RT5390)) + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 104, 0x92); if (rt2800_is_305x_soc(rt2x00dev)) rt2800_bbp_write(rt2x00dev, 105, 0x01); - else if (rt2x00_rt(rt2x00dev, RT5390)) + else if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 105, 0x3c); else rt2800_bbp_write(rt2x00dev, 105, 0x05); if (rt2x00_rt(rt2x00dev, RT5390)) rt2800_bbp_write(rt2x00dev, 106, 0x03); + else if (rt2x00_rt(rt2x00dev, RT5392)) + rt2800_bbp_write(rt2x00dev, 106, 0x12); else rt2800_bbp_write(rt2x00dev, 106, 0x35); - if (rt2x00_rt(rt2x00dev, RT5390)) + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) rt2800_bbp_write(rt2x00dev, 128, 0x12); + if (rt2x00_rt(rt2x00dev, RT5392)) { + rt2800_bbp_write(rt2x00dev, 134, 0xd0); + rt2800_bbp_write(rt2x00dev, 135, 0xf6); + } + if (rt2x00_rt(rt2x00dev, RT3071) || rt2x00_rt(rt2x00dev, RT3090) || rt2x00_rt(rt2x00dev, RT3390) || rt2x00_rt(rt2x00dev, RT3572) || - rt2x00_rt(rt2x00dev, RT5390)) { + rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_bbp_read(rt2x00dev, 138, &value); rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom); @@ -3289,7 +3324,8 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) rt2800_bbp_write(rt2x00dev, 138, value); } - if (rt2x00_rt(rt2x00dev, RT5390)) { + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { int ant, div_mode; rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); @@ -3416,13 +3452,15 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) !rt2x00_rt(rt2x00dev, RT3390) && !rt2x00_rt(rt2x00dev, RT3572) && !rt2x00_rt(rt2x00dev, RT5390) && + !rt2x00_rt(rt2x00dev, RT5392) && !rt2800_is_305x_soc(rt2x00dev)) return 0; /* * Init RF calibration. */ - if (rt2x00_rt(rt2x00dev, RT5390)) { + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 1); rt2800_rfcsr_write(rt2x00dev, 2, rfcsr); @@ -3640,6 +3678,66 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) rt2800_rfcsr_write(rt2x00dev, 61, 0xdd); rt2800_rfcsr_write(rt2x00dev, 62, 0x00); rt2800_rfcsr_write(rt2x00dev, 63, 0x00); + } else if (rt2x00_rt(rt2x00dev, RT5392)) { + rt2800_rfcsr_write(rt2x00dev, 1, 0x17); + rt2800_rfcsr_write(rt2x00dev, 2, 0x80); + rt2800_rfcsr_write(rt2x00dev, 3, 0x88); + rt2800_rfcsr_write(rt2x00dev, 5, 0x10); + rt2800_rfcsr_write(rt2x00dev, 6, 0xe0); + rt2800_rfcsr_write(rt2x00dev, 7, 0x00); + rt2800_rfcsr_write(rt2x00dev, 10, 0x53); + rt2800_rfcsr_write(rt2x00dev, 11, 0x4a); + rt2800_rfcsr_write(rt2x00dev, 12, 0x46); + rt2800_rfcsr_write(rt2x00dev, 13, 0x9f); + rt2800_rfcsr_write(rt2x00dev, 14, 0x00); + rt2800_rfcsr_write(rt2x00dev, 15, 0x00); + rt2800_rfcsr_write(rt2x00dev, 16, 0x00); + rt2800_rfcsr_write(rt2x00dev, 18, 0x03); + rt2800_rfcsr_write(rt2x00dev, 19, 0x4d); + rt2800_rfcsr_write(rt2x00dev, 20, 0x00); + rt2800_rfcsr_write(rt2x00dev, 21, 0x8d); + rt2800_rfcsr_write(rt2x00dev, 22, 0x20); + rt2800_rfcsr_write(rt2x00dev, 23, 0x0b); + rt2800_rfcsr_write(rt2x00dev, 24, 0x44); + rt2800_rfcsr_write(rt2x00dev, 25, 0x80); + rt2800_rfcsr_write(rt2x00dev, 26, 0x82); + rt2800_rfcsr_write(rt2x00dev, 27, 0x09); + rt2800_rfcsr_write(rt2x00dev, 28, 0x00); + rt2800_rfcsr_write(rt2x00dev, 29, 0x10); + rt2800_rfcsr_write(rt2x00dev, 30, 0x10); + rt2800_rfcsr_write(rt2x00dev, 31, 0x80); + rt2800_rfcsr_write(rt2x00dev, 32, 0x20); + rt2800_rfcsr_write(rt2x00dev, 33, 0xC0); + rt2800_rfcsr_write(rt2x00dev, 34, 0x07); + rt2800_rfcsr_write(rt2x00dev, 35, 0x12); + rt2800_rfcsr_write(rt2x00dev, 36, 0x00); + rt2800_rfcsr_write(rt2x00dev, 37, 0x08); + rt2800_rfcsr_write(rt2x00dev, 38, 0x89); + rt2800_rfcsr_write(rt2x00dev, 39, 0x1b); + rt2800_rfcsr_write(rt2x00dev, 40, 0x0f); + rt2800_rfcsr_write(rt2x00dev, 41, 0xbb); + rt2800_rfcsr_write(rt2x00dev, 42, 0xd5); + rt2800_rfcsr_write(rt2x00dev, 43, 0x9b); + rt2800_rfcsr_write(rt2x00dev, 44, 0x0e); + rt2800_rfcsr_write(rt2x00dev, 45, 0xa2); + rt2800_rfcsr_write(rt2x00dev, 46, 0x73); + rt2800_rfcsr_write(rt2x00dev, 47, 0x0c); + rt2800_rfcsr_write(rt2x00dev, 48, 0x10); + rt2800_rfcsr_write(rt2x00dev, 49, 0x94); + rt2800_rfcsr_write(rt2x00dev, 50, 0x94); + rt2800_rfcsr_write(rt2x00dev, 51, 0x3a); + rt2800_rfcsr_write(rt2x00dev, 52, 0x48); + rt2800_rfcsr_write(rt2x00dev, 53, 0x44); + rt2800_rfcsr_write(rt2x00dev, 54, 0x38); + rt2800_rfcsr_write(rt2x00dev, 55, 0x43); + rt2800_rfcsr_write(rt2x00dev, 56, 0xa1); + rt2800_rfcsr_write(rt2x00dev, 57, 0x00); + rt2800_rfcsr_write(rt2x00dev, 58, 0x39); + rt2800_rfcsr_write(rt2x00dev, 59, 0x07); + rt2800_rfcsr_write(rt2x00dev, 60, 0x45); + rt2800_rfcsr_write(rt2x00dev, 61, 0x91); + rt2800_rfcsr_write(rt2x00dev, 62, 0x39); + rt2800_rfcsr_write(rt2x00dev, 63, 0x07); } if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) { @@ -3713,7 +3811,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) rt2800_bbp_read(rt2x00dev, 25, &drv_data->bbp25); rt2800_bbp_read(rt2x00dev, 26, &drv_data->bbp26); - if (!rt2x00_rt(rt2x00dev, RT5390)) { + if (!rt2x00_rt(rt2x00dev, RT5390) && + !rt2x00_rt(rt2x00dev, RT5392)) { /* * Set back to initial state */ @@ -3741,7 +3840,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) rt2x00_set_field32(®, OPT_14_CSR_BIT0, 1); rt2800_register_write(rt2x00dev, OPT_14_CSR, reg); - if (!rt2x00_rt(rt2x00dev, RT5390)) { + if (!rt2x00_rt(rt2x00dev, RT5390) && + !rt2x00_rt(rt2x00dev, RT5392)) { rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0); if (rt2x00_rt(rt2x00dev, RT3070) || @@ -3806,7 +3906,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) rt2800_rfcsr_write(rt2x00dev, 27, rfcsr); } - if (rt2x00_rt(rt2x00dev, RT5390)) { + if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392)) { rt2800_rfcsr_read(rt2x00dev, 38, &rfcsr); rt2x00_set_field8(&rfcsr, RFCSR38_RX_LO1_EN, 0); rt2800_rfcsr_write(rt2x00dev, 38, rfcsr); @@ -4107,7 +4208,8 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) * RT53xx: defined in "EEPROM_CHIP_ID" field */ rt2800_register_read(rt2x00dev, MAC_CSR0, ®); - if (rt2x00_get_field32(reg, MAC_CSR0_CHIPSET) == RT5390) + if (rt2x00_get_field32(reg, MAC_CSR0_CHIPSET) == RT5390 || + rt2x00_get_field32(reg, MAC_CSR0_CHIPSET) == RT5392) rt2x00_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &value); else value = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE); @@ -4125,6 +4227,7 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) case RT3390: case RT3572: case RT5390: + case RT5392: break; default: ERROR(rt2x00dev, "Invalid RT chipset 0x%04x detected.\n", rt2x00dev->chip.rt); @@ -4143,6 +4246,7 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) case RF3052: case RF3320: case RF5370: + case RF5372: case RF5390: break; default: @@ -4449,6 +4553,7 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) rt2x00_rf(rt2x00dev, RF3022) || rt2x00_rf(rt2x00dev, RF3320) || rt2x00_rf(rt2x00dev, RF5370) || + rt2x00_rf(rt2x00dev, RF5372) || rt2x00_rf(rt2x00dev, RF5390)) { spec->num_channels = 14; spec->channels = rf_vals_3x; diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index fc9acc299b10..b45ce7605667 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -480,7 +480,8 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev) if (rt2x00_is_pcie(rt2x00dev) && (rt2x00_rt(rt2x00dev, RT3572) || - rt2x00_rt(rt2x00dev, RT5390))) { + rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392))) { rt2x00pci_register_read(rt2x00dev, AUX_CTRL, ®); rt2x00_set_field32(®, AUX_CTRL_FORCE_PCIE_CLK, 1); rt2x00_set_field32(®, AUX_CTRL_WAKE_PCIE_EN, 1); diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index f997f0056d7f..2c11137c1eb0 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -1102,12 +1102,26 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x5a57, 0x0284) }, #endif #ifdef CONFIG_RT2800USB_RT53XX + /* Alpha */ + { USB_DEVICE(0x2001, 0x3c15) }, + { USB_DEVICE(0x2001, 0x3c19) }, + /* Arcadyan */ + { USB_DEVICE(0x043e, 0x7a12) }, /* Azurewave */ { USB_DEVICE(0x13d3, 0x3329) }, { USB_DEVICE(0x13d3, 0x3365) }, + /* LG innotek */ + { USB_DEVICE(0x043e, 0x7a22) }, + /* Panasonic */ + { USB_DEVICE(0x04da, 0x1801) }, + { USB_DEVICE(0x04da, 0x1800) }, + /* Philips */ + { USB_DEVICE(0x0471, 0x2104) }, /* Ralink */ { USB_DEVICE(0x148f, 0x5370) }, { USB_DEVICE(0x148f, 0x5372) }, + /* Unknown */ + { USB_DEVICE(0x04da, 0x23f6) }, #endif #ifdef CONFIG_RT2800USB_UNKNOWN /* diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 1906a94e448f..65275efcf279 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -192,6 +192,7 @@ struct rt2x00_chip { #define RT3593 0x3593 #define RT3883 0x3883 /* WSOC */ #define RT5390 0x5390 /* 2.4GHz */ +#define RT5392 0x5392 /* 2.4GHz */ u16 rf; u16 rev; -- GitLab From c393862faad6aa200ce3fbf03735eb54361e6a4c Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 17 Feb 2012 23:04:10 +0900 Subject: [PATCH 1143/1846] wireless: Fix typo in mac80211_hwsim.c Correct spelling "occured" to "occurred" in drivers/net/wireless/mac80211_hwsim.c Signed-off-by: Masanari Iida Signed-off-by: John W. Linville --- drivers/net/wireless/mac80211_hwsim.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 4b9e730d2c8a..29e930a669ae 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -592,7 +592,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, return; nla_put_failure: - printk(KERN_DEBUG "mac80211_hwsim: error occured in %s\n", __func__); + printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); } static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, @@ -1564,7 +1564,7 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, return 0; err: - printk(KERN_DEBUG "mac80211_hwsim: error occured in %s\n", __func__); + printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); goto out; out: dev_kfree_skb(skb); @@ -1584,7 +1584,7 @@ static int hwsim_register_received_nl(struct sk_buff *skb_2, return 0; out: - printk(KERN_DEBUG "mac80211_hwsim: error occured in %s\n", __func__); + printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); return -EINVAL; } @@ -1647,7 +1647,7 @@ static int hwsim_init_netlink(void) return 0; failure: - printk(KERN_DEBUG "mac80211_hwsim: error occured in %s\n", __func__); + printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); return -EINVAL; } -- GitLab From 494f1fe559748a54bb30c066057dfae02d29676e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 19 Feb 2012 15:26:09 +0200 Subject: [PATCH 1144/1846] mac80211: don't queue monitor work for HW_CONNECTION_MONITOR Devices that monitor the connection in the hw don't need the monitor work in the driver. Signed-off-by: Eliad Peller Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 52133dab9297..7ece99a59805 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2974,13 +2974,17 @@ static void ieee80211_sta_monitor_work(struct work_struct *work) static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata) { + u32 flags; + if (sdata->vif.type == NL80211_IFTYPE_STATION) { sdata->u.mgd.flags &= ~(IEEE80211_STA_BEACON_POLL | IEEE80211_STA_CONNECTION_POLL); /* let's probe the connection once */ - ieee80211_queue_work(&sdata->local->hw, - &sdata->u.mgd.monitor_work); + flags = sdata->local->hw.flags; + if (!(flags & IEEE80211_HW_CONNECTION_MONITOR)) + ieee80211_queue_work(&sdata->local->hw, + &sdata->u.mgd.monitor_work); /* and do all the other regular work too */ ieee80211_queue_work(&sdata->local->hw, &sdata->work); } -- GitLab From 6b5773ebd5c9719aec30e58429db2d3b3f343d2c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 19 Feb 2012 15:26:10 +0200 Subject: [PATCH 1145/1846] mac80211: remove redundant monitor_work enqueueing ieee80211_restart_sta_timer() takes care for enqueueing monitor_work if needed, so no need to do it again. Signed-off-by: Eliad Peller Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 7ece99a59805..586d4fb8e130 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3048,7 +3048,6 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) add_timer(&ifmgd->chswitch_timer); ieee80211_sta_reset_beacon_monitor(sdata); ieee80211_restart_sta_timer(sdata); - ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.monitor_work); } #endif -- GitLab From d26ad3771fe7405bf80d736cae9ba4c706a7b1d8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 20 Feb 2012 11:38:41 +0100 Subject: [PATCH 1146/1846] mac80211: clean up asm/unaligned.h inclusion Some files implicitly get this via mesh.h which itself doesn't need it, so move the inclusion into the right files. Some other files don't need it at all but include it, so remove it from there. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 1 - net/mac80211/key.c | 1 + net/mac80211/mesh.h | 1 - net/mac80211/mesh_hwmp.c | 1 + net/mac80211/rx.c | 1 + net/mac80211/status.c | 1 + 6 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 8361da4b36ab..7f9ac577600a 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "ieee80211_i.h" #include "driver-ops.h" diff --git a/net/mac80211/key.c b/net/mac80211/key.c index e8616b3ff636..5bb600d93d77 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "ieee80211_i.h" #include "driver-ops.h" #include "debugfs_key.h" diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index bd14bd26a2b6..c7e5c49471e5 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -13,7 +13,6 @@ #include #include -#include #include "ieee80211_i.h" diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index c27dec904963..31bc762f209d 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -8,6 +8,7 @@ */ #include +#include #include "wme.h" #include "mesh.h" diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 3ab85c02ef04..7a4ff02af261 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "ieee80211_i.h" #include "driver-ops.h" diff --git a/net/mac80211/status.c b/net/mac80211/status.c index d67f0b967f8a..c928e4a4effd 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -11,6 +11,7 @@ #include #include +#include #include "ieee80211_i.h" #include "rate.h" #include "mesh.h" -- GitLab From 79ebfb85d4ad3495d70124a249a1096ab6396c05 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 20 Feb 2012 14:19:58 +0100 Subject: [PATCH 1147/1846] mac80211: fix associated vs. idle race Eliad reports that if a scan finishes in the middle of processing associated (however it happens), the interface can go idle. This is because we set assoc_data to NULL before we set associated. Change the order so any idle check will find either one of them. Doing this requires duplicating the TX sync processing, but I already have a patch to delete that completely and will submit that as soon as my driver changes to no longer require it are submitted. Reported-by: Eliad Peller Tested-by: Eliad Peller Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 586d4fb8e130..1495fb99b379 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2238,14 +2238,28 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, } else { printk(KERN_DEBUG "%s: associated\n", sdata->name); - ieee80211_destroy_assoc_data(sdata, true); + /* tell driver about sync done first */ + if (assoc_data->synced) { + drv_finish_tx_sync(sdata->local, sdata, + assoc_data->bss->bssid, + IEEE80211_TX_SYNC_ASSOC); + assoc_data->synced = false; + } if (!ieee80211_assoc_success(sdata, *bss, mgmt, len)) { /* oops -- internal error -- send timeout for now */ + ieee80211_destroy_assoc_data(sdata, true); sta_info_destroy_addr(sdata, mgmt->bssid); cfg80211_put_bss(*bss); return RX_MGMT_CFG80211_ASSOC_TIMEOUT; } + + /* + * destroy assoc_data afterwards, as otherwise an idle + * recalc after assoc_data is NULL but before associated + * is set can cause the interface to go idle + */ + ieee80211_destroy_assoc_data(sdata, true); } return RX_MGMT_CFG80211_RX_ASSOC; -- GitLab From c91ec465cab4a831671e01d65113330239faee61 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:03 +0530 Subject: [PATCH 1148/1846] ath9k: Remove AR9462 v1.0 support v1.0 chips are not available in the market. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- .../net/wireless/ath/ath9k/ar9003_eeprom.c | 4 - drivers/net/wireless/ath/ath9k/ar9003_hw.c | 88 +- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 38 +- drivers/net/wireless/ath/ath9k/ar9003_phy.h | 6 +- .../wireless/ath/ath9k/ar9462_1p0_initvals.h | 1439 ----------------- drivers/net/wireless/ath/ath9k/hw.c | 3 +- drivers/net/wireless/ath/ath9k/reg.h | 5 - 7 files changed, 10 insertions(+), 1573 deletions(-) delete mode 100644 drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index 9fbcbddea165..6bb4db052bb0 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -3603,10 +3603,6 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) u32 value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz); if (AR_SREV_9462(ah)) { - if (AR_SREV_9462_10(ah)) { - value &= ~AR_SWITCH_TABLE_COM_SPDT; - value |= 0x00100000; - } REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM, AR_SWITCH_TABLE_COM_AR9462_ALL, value); } else diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c index fb937ba93e0c..7b4aa000cc2e 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c @@ -22,7 +22,6 @@ #include "ar9330_1p1_initvals.h" #include "ar9330_1p2_initvals.h" #include "ar9580_1p0_initvals.h" -#include "ar9462_1p0_initvals.h" #include "ar9462_2p0_initvals.h" /* General hardware code for the AR9003 hadware family */ @@ -264,63 +263,6 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) ar9485_1_1_pcie_phy_clkreq_disable_L1, ARRAY_SIZE(ar9485_1_1_pcie_phy_clkreq_disable_L1), 2); - } else if (AR_SREV_9462_10(ah)) { - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_1p0_mac_core, - ARRAY_SIZE(ar9462_1p0_mac_core), 2); - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], - ar9462_1p0_mac_postamble, - ARRAY_SIZE(ar9462_1p0_mac_postamble), - 5); - - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], - ar9462_1p0_baseband_core, - ARRAY_SIZE(ar9462_1p0_baseband_core), - 2); - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], - ar9462_1p0_baseband_postamble, - ARRAY_SIZE(ar9462_1p0_baseband_postamble), 5); - - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], - ar9462_1p0_radio_core, - ARRAY_SIZE(ar9462_1p0_radio_core), 2); - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], - ar9462_1p0_radio_postamble, - ARRAY_SIZE(ar9462_1p0_radio_postamble), 5); - - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], - ar9462_1p0_soc_preamble, - ARRAY_SIZE(ar9462_1p0_soc_preamble), 2); - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], - ar9462_1p0_soc_postamble, - ARRAY_SIZE(ar9462_1p0_soc_postamble), 5); - - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9462_common_rx_gain_table_1p0, - ARRAY_SIZE(ar9462_common_rx_gain_table_1p0), 2); - - /* Awake -> Sleep Setting */ - INIT_INI_ARRAY(&ah->iniPcieSerdes, - ar9462_pcie_phy_clkreq_disable_L1_1p0, - ARRAY_SIZE(ar9462_pcie_phy_clkreq_disable_L1_1p0), - 2); - - /* Sleep -> Awake Setting */ - INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower, - ar9462_pcie_phy_clkreq_disable_L1_1p0, - ARRAY_SIZE(ar9462_pcie_phy_clkreq_disable_L1_1p0), - 2); - - INIT_INI_ARRAY(&ah->iniModesAdditional, - ar9462_modes_fast_clock_1p0, - ARRAY_SIZE(ar9462_modes_fast_clock_1p0), 3); - INIT_INI_ARRAY(&ah->iniCckfirJapan2484, - AR9462_BB_CTX_COEFJ(1p0), - ARRAY_SIZE(AR9462_BB_CTX_COEFJ(1p0)), 2); - } else if (AR_SREV_9462_20(ah)) { INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); @@ -537,11 +479,6 @@ static void ar9003_tx_gain_table_mode0(struct ath_hw *ah) ar9580_1p0_lowest_ob_db_tx_gain_table, ARRAY_SIZE(ar9580_1p0_lowest_ob_db_tx_gain_table), 5); - else if (AR_SREV_9462_10(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9462_modes_low_ob_db_tx_gain_table_1p0, - ARRAY_SIZE(ar9462_modes_low_ob_db_tx_gain_table_1p0), - 5); else if (AR_SREV_9462_20(ah)) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9462_modes_low_ob_db_tx_gain_table_2p0, @@ -581,11 +518,6 @@ static void ar9003_tx_gain_table_mode1(struct ath_hw *ah) ar9580_1p0_high_ob_db_tx_gain_table, ARRAY_SIZE(ar9580_1p0_high_ob_db_tx_gain_table), 5); - else if (AR_SREV_9462_10(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9462_modes_high_ob_db_tx_gain_table_1p0, - ARRAY_SIZE(ar9462_modes_high_ob_db_tx_gain_table_1p0), - 5); else if (AR_SREV_9462_20(ah)) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9462_modes_high_ob_db_tx_gain_table_2p0, @@ -712,11 +644,6 @@ static void ar9003_rx_gain_table_mode0(struct ath_hw *ah) ar9580_1p0_rx_gain_table, ARRAY_SIZE(ar9580_1p0_rx_gain_table), 2); - else if (AR_SREV_9462_10(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9462_common_rx_gain_table_1p0, - ARRAY_SIZE(ar9462_common_rx_gain_table_1p0), - 2); else if (AR_SREV_9462_20(ah)) INIT_INI_ARRAY(&ah->iniModesRxGain, ar9462_common_rx_gain_table_2p0, @@ -751,11 +678,6 @@ static void ar9003_rx_gain_table_mode1(struct ath_hw *ah) ar9485Common_wo_xlna_rx_gain_1_1, ARRAY_SIZE(ar9485Common_wo_xlna_rx_gain_1_1), 2); - else if (AR_SREV_9462_10(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9462_common_wo_xlna_rx_gain_table_1p0, - ARRAY_SIZE(ar9462_common_wo_xlna_rx_gain_table_1p0), - 2); else if (AR_SREV_9462_20(ah)) INIT_INI_ARRAY(&ah->iniModesRxGain, ar9462_common_wo_xlna_rx_gain_table_2p0, @@ -775,14 +697,10 @@ static void ar9003_rx_gain_table_mode1(struct ath_hw *ah) static void ar9003_rx_gain_table_mode2(struct ath_hw *ah) { - if (AR_SREV_9462_10(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9462_common_mixed_rx_gain_table_1p0, - ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_1p0), 2); - else if (AR_SREV_9462_20(ah)) + if (AR_SREV_9462_20(ah)) INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9462_common_mixed_rx_gain_table_2p0, - ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_2p0), 2); + ar9462_common_mixed_rx_gain_table_2p0, + ARRAY_SIZE(ar9462_common_mixed_rx_gain_table_2p0), 2); } static void ar9003_rx_gain_table_apply(struct ath_hw *ah) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 709520c6835b..8439656a0913 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -274,14 +274,6 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) ath_dbg(common, 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, MCI, "MCI Send REQ_WAKE to remoter(BT)\n"); ar9003_mci_send_req_wake(ah, true); @@ -291,8 +283,6 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) ath_dbg(common, 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 @@ -339,15 +329,14 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, AR_MCI_INTERRUPT_BT_PRI); - if (AR_SREV_9462_10(ah) || mci->is_2g) { + if (mci->is_2g) { /* Send LNA_TRANS */ ath_dbg(common, 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 ((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, @@ -358,14 +347,6 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) ath_dbg(common, 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, 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 */ @@ -618,9 +599,6 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, } else ath_dbg(common, 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)) { @@ -771,9 +749,6 @@ static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done) 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, @@ -810,11 +785,8 @@ static void ar9003_mci_queue_unsent_gpm(struct ath_hw *ah, u8 header, 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) + MCI_GPM_COEX_BT_FLAGS_READ) break; mci->update_2g5g = queue; @@ -1438,9 +1410,7 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) 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; + query_type = MCI_GPM_COEX_QUERY_BT_TOPOLOGY; ar9003_mci_send_coex_bt_status_query(ah, true, query_type); break; diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index 81f3e857ff28..d834d97fe727 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h @@ -617,10 +617,8 @@ #define AR_PHY_AIC_CTRL_1_B0 (AR_SM_BASE + 0x4b4) #define AR_PHY_AIC_CTRL_2_B0 (AR_SM_BASE + 0x4b8) #define AR_PHY_AIC_CTRL_3_B0 (AR_SM_BASE + 0x4bc) -#define AR_PHY_AIC_STAT_0_B0 (AR_SM_BASE + (AR_SREV_9462_10(ah) ? \ - 0x4c0 : 0x4c4)) -#define AR_PHY_AIC_STAT_1_B0 (AR_SM_BASE + (AR_SREV_9462_10(ah) ? \ - 0x4c4 : 0x4c8)) +#define AR_PHY_AIC_STAT_0_B0 (AR_SM_BASE + 0x4c4)) +#define AR_PHY_AIC_STAT_1_B0 (AR_SM_BASE + 0x4c8)) #define AR_PHY_AIC_CTRL_4_B0 (AR_SM_BASE + 0x4c0) #define AR_PHY_AIC_STAT_2_B0 (AR_SM_BASE + 0x4cc) diff --git a/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h deleted file mode 100644 index 5510216a4886..000000000000 --- a/drivers/net/wireless/ath/ath9k/ar9462_1p0_initvals.h +++ /dev/null @@ -1,1439 +0,0 @@ -/* - * Copyright (c) 2010 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 INITVALS_9462_1P0_H -#define INITVALS_9462_1P0_H - -/* AR9462 1.0 */ - -static const u32 ar9462_1p0_mac_core[][2] = { - /* Addr allmodes */ - {0x00000008, 0x00000000}, - {0x00000030, 0x00060085}, - {0x00000034, 0x00000005}, - {0x00000040, 0x00000000}, - {0x00000044, 0x00000000}, - {0x00000048, 0x00000008}, - {0x0000004c, 0x00000010}, - {0x00000050, 0x00000000}, - {0x00001040, 0x002ffc0f}, - {0x00001044, 0x002ffc0f}, - {0x00001048, 0x002ffc0f}, - {0x0000104c, 0x002ffc0f}, - {0x00001050, 0x002ffc0f}, - {0x00001054, 0x002ffc0f}, - {0x00001058, 0x002ffc0f}, - {0x0000105c, 0x002ffc0f}, - {0x00001060, 0x002ffc0f}, - {0x00001064, 0x002ffc0f}, - {0x000010f0, 0x00000100}, - {0x00001270, 0x00000000}, - {0x000012b0, 0x00000000}, - {0x000012f0, 0x00000000}, - {0x0000143c, 0x00000000}, - {0x0000147c, 0x00000000}, - {0x00001810, 0x0f000003}, - {0x00008000, 0x00000000}, - {0x00008004, 0x00000000}, - {0x00008008, 0x00000000}, - {0x0000800c, 0x00000000}, - {0x00008018, 0x00000000}, - {0x00008020, 0x00000000}, - {0x00008038, 0x00000000}, - {0x0000803c, 0x00080000}, - {0x00008040, 0x00000000}, - {0x00008044, 0x00000000}, - {0x00008048, 0x00000000}, - {0x0000804c, 0xffffffff}, - {0x00008050, 0xffffffff}, - {0x00008054, 0x00000000}, - {0x00008058, 0x00000000}, - {0x0000805c, 0x000fc78f}, - {0x00008060, 0x0000000f}, - {0x00008064, 0x00000000}, - {0x00008070, 0x00000310}, - {0x00008074, 0x00000020}, - {0x00008078, 0x00000000}, - {0x0000809c, 0x0000000f}, - {0x000080a0, 0x00000000}, - {0x000080a4, 0x02ff0000}, - {0x000080a8, 0x0e070605}, - {0x000080ac, 0x0000000d}, - {0x000080b0, 0x00000000}, - {0x000080b4, 0x00000000}, - {0x000080b8, 0x00000000}, - {0x000080bc, 0x00000000}, - {0x000080c0, 0x2a800000}, - {0x000080c4, 0x06900168}, - {0x000080c8, 0x13881c20}, - {0x000080cc, 0x01f40000}, - {0x000080d0, 0x00252500}, - {0x000080d4, 0x00a00005}, - {0x000080d8, 0x00400002}, - {0x000080dc, 0x00000000}, - {0x000080e0, 0xffffffff}, - {0x000080e4, 0x0000ffff}, - {0x000080e8, 0x3f3f3f3f}, - {0x000080ec, 0x00000000}, - {0x000080f0, 0x00000000}, - {0x000080f4, 0x00000000}, - {0x000080fc, 0x00020000}, - {0x00008100, 0x00000000}, - {0x00008108, 0x00000052}, - {0x0000810c, 0x00000000}, - {0x00008110, 0x00000000}, - {0x00008114, 0x000007ff}, - {0x00008118, 0x000000aa}, - {0x0000811c, 0x00003210}, - {0x00008124, 0x00000000}, - {0x00008128, 0x00000000}, - {0x0000812c, 0x00000000}, - {0x00008130, 0x00000000}, - {0x00008134, 0x00000000}, - {0x00008138, 0x00000000}, - {0x0000813c, 0x0000ffff}, - {0x00008144, 0xffffffff}, - {0x00008168, 0x00000000}, - {0x0000816c, 0x00000000}, - {0x00008170, 0x18486e00}, - {0x00008174, 0x33332210}, - {0x00008178, 0x00000000}, - {0x0000817c, 0x00020000}, - {0x000081c4, 0x33332210}, - {0x000081c8, 0x00000000}, - {0x000081cc, 0x00000000}, - {0x000081d4, 0x00000000}, - {0x000081ec, 0x00000000}, - {0x000081f0, 0x00000000}, - {0x000081f4, 0x00000000}, - {0x000081f8, 0x00000000}, - {0x000081fc, 0x00000000}, - {0x00008240, 0x00100000}, - {0x00008244, 0x0010f400}, - {0x00008248, 0x00000800}, - {0x0000824c, 0x0001e800}, - {0x00008250, 0x00000000}, - {0x00008254, 0x00000000}, - {0x00008258, 0x00000000}, - {0x0000825c, 0x40000000}, - {0x00008260, 0x00080922}, - {0x00008264, 0x99c00010}, - {0x00008268, 0xffffffff}, - {0x0000826c, 0x0000ffff}, - {0x00008270, 0x00000000}, - {0x00008274, 0x40000000}, - {0x00008278, 0x003e4180}, - {0x0000827c, 0x00000004}, - {0x00008284, 0x0000002c}, - {0x00008288, 0x0000002c}, - {0x0000828c, 0x000000ff}, - {0x00008294, 0x00000000}, - {0x00008298, 0x00000000}, - {0x0000829c, 0x00000000}, - {0x00008300, 0x00000140}, - {0x00008314, 0x00000000}, - {0x0000831c, 0x0000010d}, - {0x00008328, 0x00000000}, - {0x0000832c, 0x0000001f}, - {0x00008330, 0x00000302}, - {0x00008334, 0x00000700}, - {0x00008338, 0xffff0000}, - {0x0000833c, 0x02400000}, - {0x00008340, 0x000107ff}, - {0x00008344, 0xaa48105b}, - {0x00008348, 0x008f0000}, - {0x0000835c, 0x00000000}, - {0x00008360, 0xffffffff}, - {0x00008364, 0xffffffff}, - {0x00008368, 0x00000000}, - {0x00008370, 0x00000000}, - {0x00008374, 0x000000ff}, - {0x00008378, 0x00000000}, - {0x0000837c, 0x00000000}, - {0x00008380, 0xffffffff}, - {0x00008384, 0xffffffff}, - {0x00008390, 0xffffffff}, - {0x00008394, 0xffffffff}, - {0x00008398, 0x00000000}, - {0x0000839c, 0x00000000}, - {0x000083a4, 0x0000fa14}, - {0x000083a8, 0x000f0c00}, - {0x000083ac, 0x33332210}, - {0x000083b0, 0x33332210}, - {0x000083b4, 0x33332210}, - {0x000083b8, 0x33332210}, - {0x000083bc, 0x00000000}, - {0x000083c0, 0x00000000}, - {0x000083c4, 0x00000000}, - {0x000083c8, 0x00000000}, - {0x000083cc, 0x00000200}, - {0x000083d0, 0x000301ff}, -}; - -static const u32 ar9462_1p0_baseband_core_txfir_coeff_japan_2484[][2] = { - /* Addr allmodes */ - {0x0000a398, 0x00000000}, - {0x0000a39c, 0x6f7f0301}, - {0x0000a3a0, 0xca9228ee}, -}; - -static const u32 ar9462_pcie_phy_clkreq_enable_L1_1p0[][2] = { - /* Addr allmodes */ - {0x00018c00, 0x10053e5e}, - {0x00018c04, 0x000801d8}, - {0x00018c08, 0x0000580c}, -}; - -static const u32 ar9462_pcie_phy_pll_on_clkreq_disable_L1_1p0[][2] = { - /* Addr allmodes */ - {0x00018c00, 0x10012e5e}, - {0x00018c04, 0x000801d8}, - {0x00018c08, 0x0000580c}, -}; - -static const u32 ar9462_common_rx_gain_table_1p0[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00010000}, - {0x0000a004, 0x00030002}, - {0x0000a008, 0x00050004}, - {0x0000a00c, 0x00810080}, - {0x0000a010, 0x00830082}, - {0x0000a014, 0x01810180}, - {0x0000a018, 0x01830182}, - {0x0000a01c, 0x01850184}, - {0x0000a020, 0x01890188}, - {0x0000a024, 0x018b018a}, - {0x0000a028, 0x018d018c}, - {0x0000a02c, 0x01910190}, - {0x0000a030, 0x01930192}, - {0x0000a034, 0x01950194}, - {0x0000a038, 0x038a0196}, - {0x0000a03c, 0x038c038b}, - {0x0000a040, 0x0390038d}, - {0x0000a044, 0x03920391}, - {0x0000a048, 0x03940393}, - {0x0000a04c, 0x03960395}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x22222229}, - {0x0000a084, 0x1d1d1d1d}, - {0x0000a088, 0x1d1d1d1d}, - {0x0000a08c, 0x1d1d1d1d}, - {0x0000a090, 0x171d1d1d}, - {0x0000a094, 0x11111717}, - {0x0000a098, 0x00030311}, - {0x0000a09c, 0x00000000}, - {0x0000a0a0, 0x00000000}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x001f0000}, - {0x0000a0c4, 0x01000101}, - {0x0000a0c8, 0x011e011f}, - {0x0000a0cc, 0x011c011d}, - {0x0000a0d0, 0x02030204}, - {0x0000a0d4, 0x02010202}, - {0x0000a0d8, 0x021f0200}, - {0x0000a0dc, 0x0302021e}, - {0x0000a0e0, 0x03000301}, - {0x0000a0e4, 0x031e031f}, - {0x0000a0e8, 0x0402031d}, - {0x0000a0ec, 0x04000401}, - {0x0000a0f0, 0x041e041f}, - {0x0000a0f4, 0x0502041d}, - {0x0000a0f8, 0x05000501}, - {0x0000a0fc, 0x051e051f}, - {0x0000a100, 0x06010602}, - {0x0000a104, 0x061f0600}, - {0x0000a108, 0x061d061e}, - {0x0000a10c, 0x07020703}, - {0x0000a110, 0x07000701}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x01000101}, - {0x0000a148, 0x011e011f}, - {0x0000a14c, 0x011c011d}, - {0x0000a150, 0x02030204}, - {0x0000a154, 0x02010202}, - {0x0000a158, 0x021f0200}, - {0x0000a15c, 0x0302021e}, - {0x0000a160, 0x03000301}, - {0x0000a164, 0x031e031f}, - {0x0000a168, 0x0402031d}, - {0x0000a16c, 0x04000401}, - {0x0000a170, 0x041e041f}, - {0x0000a174, 0x0502041d}, - {0x0000a178, 0x05000501}, - {0x0000a17c, 0x051e051f}, - {0x0000a180, 0x06010602}, - {0x0000a184, 0x061f0600}, - {0x0000a188, 0x061d061e}, - {0x0000a18c, 0x07020703}, - {0x0000a190, 0x07000701}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000196}, - {0x0000b000, 0x00010000}, - {0x0000b004, 0x00030002}, - {0x0000b008, 0x00050004}, - {0x0000b00c, 0x00810080}, - {0x0000b010, 0x00830082}, - {0x0000b014, 0x01810180}, - {0x0000b018, 0x01830182}, - {0x0000b01c, 0x01850184}, - {0x0000b020, 0x02810280}, - {0x0000b024, 0x02830282}, - {0x0000b028, 0x02850284}, - {0x0000b02c, 0x02890288}, - {0x0000b030, 0x028b028a}, - {0x0000b034, 0x0388028c}, - {0x0000b038, 0x038a0389}, - {0x0000b03c, 0x038c038b}, - {0x0000b040, 0x0390038d}, - {0x0000b044, 0x03920391}, - {0x0000b048, 0x03940393}, - {0x0000b04c, 0x03960395}, - {0x0000b050, 0x00000000}, - {0x0000b054, 0x00000000}, - {0x0000b058, 0x00000000}, - {0x0000b05c, 0x00000000}, - {0x0000b060, 0x00000000}, - {0x0000b064, 0x00000000}, - {0x0000b068, 0x00000000}, - {0x0000b06c, 0x00000000}, - {0x0000b070, 0x00000000}, - {0x0000b074, 0x00000000}, - {0x0000b078, 0x00000000}, - {0x0000b07c, 0x00000000}, - {0x0000b080, 0x2a2d2f32}, - {0x0000b084, 0x21232328}, - {0x0000b088, 0x19191c1e}, - {0x0000b08c, 0x12141417}, - {0x0000b090, 0x07070e0e}, - {0x0000b094, 0x03030305}, - {0x0000b098, 0x00000003}, - {0x0000b09c, 0x00000000}, - {0x0000b0a0, 0x00000000}, - {0x0000b0a4, 0x00000000}, - {0x0000b0a8, 0x00000000}, - {0x0000b0ac, 0x00000000}, - {0x0000b0b0, 0x00000000}, - {0x0000b0b4, 0x00000000}, - {0x0000b0b8, 0x00000000}, - {0x0000b0bc, 0x00000000}, - {0x0000b0c0, 0x003f0020}, - {0x0000b0c4, 0x00400041}, - {0x0000b0c8, 0x0140005f}, - {0x0000b0cc, 0x0160015f}, - {0x0000b0d0, 0x017e017f}, - {0x0000b0d4, 0x02410242}, - {0x0000b0d8, 0x025f0240}, - {0x0000b0dc, 0x027f0260}, - {0x0000b0e0, 0x0341027e}, - {0x0000b0e4, 0x035f0340}, - {0x0000b0e8, 0x037f0360}, - {0x0000b0ec, 0x04400441}, - {0x0000b0f0, 0x0460045f}, - {0x0000b0f4, 0x0541047f}, - {0x0000b0f8, 0x055f0540}, - {0x0000b0fc, 0x057f0560}, - {0x0000b100, 0x06400641}, - {0x0000b104, 0x0660065f}, - {0x0000b108, 0x067e067f}, - {0x0000b10c, 0x07410742}, - {0x0000b110, 0x075f0740}, - {0x0000b114, 0x077f0760}, - {0x0000b118, 0x07800781}, - {0x0000b11c, 0x07a0079f}, - {0x0000b120, 0x07c107bf}, - {0x0000b124, 0x000007c0}, - {0x0000b128, 0x00000000}, - {0x0000b12c, 0x00000000}, - {0x0000b130, 0x00000000}, - {0x0000b134, 0x00000000}, - {0x0000b138, 0x00000000}, - {0x0000b13c, 0x00000000}, - {0x0000b140, 0x003f0020}, - {0x0000b144, 0x00400041}, - {0x0000b148, 0x0140005f}, - {0x0000b14c, 0x0160015f}, - {0x0000b150, 0x017e017f}, - {0x0000b154, 0x02410242}, - {0x0000b158, 0x025f0240}, - {0x0000b15c, 0x027f0260}, - {0x0000b160, 0x0341027e}, - {0x0000b164, 0x035f0340}, - {0x0000b168, 0x037f0360}, - {0x0000b16c, 0x04400441}, - {0x0000b170, 0x0460045f}, - {0x0000b174, 0x0541047f}, - {0x0000b178, 0x055f0540}, - {0x0000b17c, 0x057f0560}, - {0x0000b180, 0x06400641}, - {0x0000b184, 0x0660065f}, - {0x0000b188, 0x067e067f}, - {0x0000b18c, 0x07410742}, - {0x0000b190, 0x075f0740}, - {0x0000b194, 0x077f0760}, - {0x0000b198, 0x07800781}, - {0x0000b19c, 0x07a0079f}, - {0x0000b1a0, 0x07c107bf}, - {0x0000b1a4, 0x000007c0}, - {0x0000b1a8, 0x00000000}, - {0x0000b1ac, 0x00000000}, - {0x0000b1b0, 0x00000000}, - {0x0000b1b4, 0x00000000}, - {0x0000b1b8, 0x00000000}, - {0x0000b1bc, 0x00000000}, - {0x0000b1c0, 0x00000000}, - {0x0000b1c4, 0x00000000}, - {0x0000b1c8, 0x00000000}, - {0x0000b1cc, 0x00000000}, - {0x0000b1d0, 0x00000000}, - {0x0000b1d4, 0x00000000}, - {0x0000b1d8, 0x00000000}, - {0x0000b1dc, 0x00000000}, - {0x0000b1e0, 0x00000000}, - {0x0000b1e4, 0x00000000}, - {0x0000b1e8, 0x00000000}, - {0x0000b1ec, 0x00000000}, - {0x0000b1f0, 0x00000396}, - {0x0000b1f4, 0x00000396}, - {0x0000b1f8, 0x00000396}, - {0x0000b1fc, 0x00000196}, -}; - -static const u32 ar9462_modes_high_ob_db_tx_gain_table_1p0[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a2dc, 0x01feee00, 0x01feee00, 0x03aaa352, 0x03aaa352}, - {0x0000a2e0, 0x0000f000, 0x0000f000, 0x03ccc584, 0x03ccc584}, - {0x0000a2e4, 0x01ff0000, 0x01ff0000, 0x03f0f800, 0x03f0f800}, - {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, - {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, - {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, - {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002}, - {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004}, - {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200}, - {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202}, - {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400}, - {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402}, - {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404}, - {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603}, - {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02}, - {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04}, - {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20}, - {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20}, - {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22}, - {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24}, - {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640}, - {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, - {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, - {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, - {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, - {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, - {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, - {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, - {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, - {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb}, - {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00804000, 0x00804000, 0x00000000, 0x00000000}, - {0x0000a614, 0x00804201, 0x00804201, 0x01404000, 0x01404000}, - {0x0000a618, 0x0280c802, 0x0280c802, 0x01404501, 0x01404501}, - {0x0000a61c, 0x0280ca03, 0x0280ca03, 0x02008501, 0x02008501}, - {0x0000a620, 0x04c15104, 0x04c15104, 0x0280ca03, 0x0280ca03}, - {0x0000a624, 0x04c15305, 0x04c15305, 0x03010c04, 0x03010c04}, - {0x0000a628, 0x04c15305, 0x04c15305, 0x04014c04, 0x04014c04}, - {0x0000a62c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a630, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a634, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a638, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000a63c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005}, - {0x0000b2dc, 0x01feee00, 0x01feee00, 0x03aaa352, 0x03aaa352}, - {0x0000b2e0, 0x0000f000, 0x0000f000, 0x03ccc584, 0x03ccc584}, - {0x0000b2e4, 0x01ff0000, 0x01ff0000, 0x03f0f800, 0x03f0f800}, - {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, - {0x00016044, 0x056d82e4, 0x056d82e4, 0x056d82e4, 0x056d82e4}, - {0x00016048, 0x8db49060, 0x8db49060, 0x8db49060, 0x8db49060}, - {0x00016444, 0x056d82e4, 0x056d82e4, 0x056d82e4, 0x056d82e4}, - {0x00016448, 0x8db49000, 0x8db49000, 0x8db49000, 0x8db49000}, -}; - -static const u32 ar9462_common_wo_xlna_rx_gain_table_1p0[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00010000}, - {0x0000a004, 0x00030002}, - {0x0000a008, 0x00050004}, - {0x0000a00c, 0x00810080}, - {0x0000a010, 0x00830082}, - {0x0000a014, 0x01810180}, - {0x0000a018, 0x01830182}, - {0x0000a01c, 0x01850184}, - {0x0000a020, 0x01890188}, - {0x0000a024, 0x018b018a}, - {0x0000a028, 0x018d018c}, - {0x0000a02c, 0x03820190}, - {0x0000a030, 0x03840383}, - {0x0000a034, 0x03880385}, - {0x0000a038, 0x038a0389}, - {0x0000a03c, 0x038c038b}, - {0x0000a040, 0x0390038d}, - {0x0000a044, 0x03920391}, - {0x0000a048, 0x03940393}, - {0x0000a04c, 0x03960395}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x29292929}, - {0x0000a084, 0x29292929}, - {0x0000a088, 0x29292929}, - {0x0000a08c, 0x29292929}, - {0x0000a090, 0x22292929}, - {0x0000a094, 0x1d1d2222}, - {0x0000a098, 0x0c111117}, - {0x0000a09c, 0x00030303}, - {0x0000a0a0, 0x00000000}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x001f0000}, - {0x0000a0c4, 0x01000101}, - {0x0000a0c8, 0x011e011f}, - {0x0000a0cc, 0x011c011d}, - {0x0000a0d0, 0x02030204}, - {0x0000a0d4, 0x02010202}, - {0x0000a0d8, 0x021f0200}, - {0x0000a0dc, 0x0302021e}, - {0x0000a0e0, 0x03000301}, - {0x0000a0e4, 0x031e031f}, - {0x0000a0e8, 0x0402031d}, - {0x0000a0ec, 0x04000401}, - {0x0000a0f0, 0x041e041f}, - {0x0000a0f4, 0x0502041d}, - {0x0000a0f8, 0x05000501}, - {0x0000a0fc, 0x051e051f}, - {0x0000a100, 0x06010602}, - {0x0000a104, 0x061f0600}, - {0x0000a108, 0x061d061e}, - {0x0000a10c, 0x07020703}, - {0x0000a110, 0x07000701}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x01000101}, - {0x0000a148, 0x011e011f}, - {0x0000a14c, 0x011c011d}, - {0x0000a150, 0x02030204}, - {0x0000a154, 0x02010202}, - {0x0000a158, 0x021f0200}, - {0x0000a15c, 0x0302021e}, - {0x0000a160, 0x03000301}, - {0x0000a164, 0x031e031f}, - {0x0000a168, 0x0402031d}, - {0x0000a16c, 0x04000401}, - {0x0000a170, 0x041e041f}, - {0x0000a174, 0x0502041d}, - {0x0000a178, 0x05000501}, - {0x0000a17c, 0x051e051f}, - {0x0000a180, 0x06010602}, - {0x0000a184, 0x061f0600}, - {0x0000a188, 0x061d061e}, - {0x0000a18c, 0x07020703}, - {0x0000a190, 0x07000701}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000196}, - {0x0000b000, 0x00010000}, - {0x0000b004, 0x00030002}, - {0x0000b008, 0x00050004}, - {0x0000b00c, 0x00810080}, - {0x0000b010, 0x00830082}, - {0x0000b014, 0x01810180}, - {0x0000b018, 0x01830182}, - {0x0000b01c, 0x01850184}, - {0x0000b020, 0x02810280}, - {0x0000b024, 0x02830282}, - {0x0000b028, 0x02850284}, - {0x0000b02c, 0x02890288}, - {0x0000b030, 0x028b028a}, - {0x0000b034, 0x0388028c}, - {0x0000b038, 0x038a0389}, - {0x0000b03c, 0x038c038b}, - {0x0000b040, 0x0390038d}, - {0x0000b044, 0x03920391}, - {0x0000b048, 0x03940393}, - {0x0000b04c, 0x03960395}, - {0x0000b050, 0x00000000}, - {0x0000b054, 0x00000000}, - {0x0000b058, 0x00000000}, - {0x0000b05c, 0x00000000}, - {0x0000b060, 0x00000000}, - {0x0000b064, 0x00000000}, - {0x0000b068, 0x00000000}, - {0x0000b06c, 0x00000000}, - {0x0000b070, 0x00000000}, - {0x0000b074, 0x00000000}, - {0x0000b078, 0x00000000}, - {0x0000b07c, 0x00000000}, - {0x0000b080, 0x32323232}, - {0x0000b084, 0x2f2f3232}, - {0x0000b088, 0x23282a2d}, - {0x0000b08c, 0x1c1e2123}, - {0x0000b090, 0x14171919}, - {0x0000b094, 0x0e0e1214}, - {0x0000b098, 0x03050707}, - {0x0000b09c, 0x00030303}, - {0x0000b0a0, 0x00000000}, - {0x0000b0a4, 0x00000000}, - {0x0000b0a8, 0x00000000}, - {0x0000b0ac, 0x00000000}, - {0x0000b0b0, 0x00000000}, - {0x0000b0b4, 0x00000000}, - {0x0000b0b8, 0x00000000}, - {0x0000b0bc, 0x00000000}, - {0x0000b0c0, 0x003f0020}, - {0x0000b0c4, 0x00400041}, - {0x0000b0c8, 0x0140005f}, - {0x0000b0cc, 0x0160015f}, - {0x0000b0d0, 0x017e017f}, - {0x0000b0d4, 0x02410242}, - {0x0000b0d8, 0x025f0240}, - {0x0000b0dc, 0x027f0260}, - {0x0000b0e0, 0x0341027e}, - {0x0000b0e4, 0x035f0340}, - {0x0000b0e8, 0x037f0360}, - {0x0000b0ec, 0x04400441}, - {0x0000b0f0, 0x0460045f}, - {0x0000b0f4, 0x0541047f}, - {0x0000b0f8, 0x055f0540}, - {0x0000b0fc, 0x057f0560}, - {0x0000b100, 0x06400641}, - {0x0000b104, 0x0660065f}, - {0x0000b108, 0x067e067f}, - {0x0000b10c, 0x07410742}, - {0x0000b110, 0x075f0740}, - {0x0000b114, 0x077f0760}, - {0x0000b118, 0x07800781}, - {0x0000b11c, 0x07a0079f}, - {0x0000b120, 0x07c107bf}, - {0x0000b124, 0x000007c0}, - {0x0000b128, 0x00000000}, - {0x0000b12c, 0x00000000}, - {0x0000b130, 0x00000000}, - {0x0000b134, 0x00000000}, - {0x0000b138, 0x00000000}, - {0x0000b13c, 0x00000000}, - {0x0000b140, 0x003f0020}, - {0x0000b144, 0x00400041}, - {0x0000b148, 0x0140005f}, - {0x0000b14c, 0x0160015f}, - {0x0000b150, 0x017e017f}, - {0x0000b154, 0x02410242}, - {0x0000b158, 0x025f0240}, - {0x0000b15c, 0x027f0260}, - {0x0000b160, 0x0341027e}, - {0x0000b164, 0x035f0340}, - {0x0000b168, 0x037f0360}, - {0x0000b16c, 0x04400441}, - {0x0000b170, 0x0460045f}, - {0x0000b174, 0x0541047f}, - {0x0000b178, 0x055f0540}, - {0x0000b17c, 0x057f0560}, - {0x0000b180, 0x06400641}, - {0x0000b184, 0x0660065f}, - {0x0000b188, 0x067e067f}, - {0x0000b18c, 0x07410742}, - {0x0000b190, 0x075f0740}, - {0x0000b194, 0x077f0760}, - {0x0000b198, 0x07800781}, - {0x0000b19c, 0x07a0079f}, - {0x0000b1a0, 0x07c107bf}, - {0x0000b1a4, 0x000007c0}, - {0x0000b1a8, 0x00000000}, - {0x0000b1ac, 0x00000000}, - {0x0000b1b0, 0x00000000}, - {0x0000b1b4, 0x00000000}, - {0x0000b1b8, 0x00000000}, - {0x0000b1bc, 0x00000000}, - {0x0000b1c0, 0x00000000}, - {0x0000b1c4, 0x00000000}, - {0x0000b1c8, 0x00000000}, - {0x0000b1cc, 0x00000000}, - {0x0000b1d0, 0x00000000}, - {0x0000b1d4, 0x00000000}, - {0x0000b1d8, 0x00000000}, - {0x0000b1dc, 0x00000000}, - {0x0000b1e0, 0x00000000}, - {0x0000b1e4, 0x00000000}, - {0x0000b1e8, 0x00000000}, - {0x0000b1ec, 0x00000000}, - {0x0000b1f0, 0x00000396}, - {0x0000b1f4, 0x00000396}, - {0x0000b1f8, 0x00000396}, - {0x0000b1fc, 0x00000196}, -}; - -static const u32 ar9462_1p0_mac_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160}, - {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c}, - {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38}, - {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00}, - {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b}, - {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810}, - {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a}, - {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440}, -}; - -static const u32 ar9462_1p0_radio_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0001609c, 0x0b8ee524, 0x0b8ee524, 0x0b8ee524, 0x0b8ee524}, - {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24646c08, 0x24646c08}, - {0x000160b0, 0x01d67f70, 0x01d67f70, 0x01d67f70, 0x01d67f70}, - {0x0001610c, 0x48000000, 0x40000000, 0x40000000, 0x40000000}, - {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, - {0x0001650c, 0x48000000, 0x40000000, 0x40000000, 0x40000000}, - {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, -}; - -static const u32 ar9462_1p0_baseband_core[][2] = { - /* Addr allmodes */ - {0x00009800, 0xafe68e30}, - {0x00009804, 0xfd14e000}, - {0x00009808, 0x9c0a9f6b}, - {0x0000980c, 0x04900000}, - {0x00009814, 0x9280c00a}, - {0x00009818, 0x00000000}, - {0x0000981c, 0x00020028}, - {0x00009834, 0x6400a290}, - {0x00009838, 0x0108ecff}, - {0x0000983c, 0x0d000600}, - {0x00009880, 0x201fff00}, - {0x00009884, 0x00001042}, - {0x000098a4, 0x00200400}, - {0x000098b0, 0x32840bbe}, - {0x000098d0, 0x004b6a8e}, - {0x000098d4, 0x00000820}, - {0x000098dc, 0x00000000}, - {0x000098e4, 0x01ffffff}, - {0x000098e8, 0x01ffffff}, - {0x000098ec, 0x01ffffff}, - {0x000098f0, 0x00000000}, - {0x000098f4, 0x00000000}, - {0x00009c04, 0xff55ff55}, - {0x00009c08, 0x0320ff55}, - {0x00009c0c, 0x00000000}, - {0x00009c10, 0x00000000}, - {0x00009c14, 0x00046384}, - {0x00009c18, 0x05b6b440}, - {0x00009c1c, 0x00b6b440}, - {0x00009d00, 0xc080a333}, - {0x00009d04, 0x40206c10}, - {0x00009d08, 0x009c4060}, - {0x00009d0c, 0x9883800a}, - {0x00009d10, 0x01834061}, - {0x00009d14, 0x00c0040b}, - {0x00009d18, 0x00000000}, - {0x00009e08, 0x0038230c}, - {0x00009e24, 0x990bb514}, - {0x00009e28, 0x0c6f0000}, - {0x00009e30, 0x06336f77}, - {0x00009e34, 0x6af6532f}, - {0x00009e38, 0x0cc80c00}, - {0x00009e40, 0x0d261820}, - {0x00009e4c, 0x00001004}, - {0x00009e50, 0x00ff03f1}, - {0x00009e54, 0x64c355c7}, - {0x00009e58, 0xfd897735}, - {0x00009e5c, 0xe9198724}, - {0x00009fc0, 0x803e4788}, - {0x00009fc4, 0x0001efb5}, - {0x00009fcc, 0x40000014}, - {0x00009fd0, 0x01193b93}, - {0x0000a20c, 0x00000000}, - {0x0000a220, 0x00000000}, - {0x0000a224, 0x00000000}, - {0x0000a228, 0x10002310}, - {0x0000a23c, 0x00000000}, - {0x0000a244, 0x0c000000}, - {0x0000a2a0, 0x00000001}, - {0x0000a2c0, 0x00000001}, - {0x0000a2c8, 0x00000000}, - {0x0000a2cc, 0x18c43433}, - {0x0000a2d4, 0x00000000}, - {0x0000a2ec, 0x00000000}, - {0x0000a2f0, 0x00000000}, - {0x0000a2f4, 0x00000000}, - {0x0000a2f8, 0x00000000}, - {0x0000a344, 0x00000000}, - {0x0000a34c, 0x00000000}, - {0x0000a350, 0x0000a000}, - {0x0000a364, 0x00000000}, - {0x0000a370, 0x00000000}, - {0x0000a390, 0x00000001}, - {0x0000a394, 0x00000444}, - {0x0000a398, 0x001f0e0f}, - {0x0000a39c, 0x0075393f}, - {0x0000a3a0, 0xb79f6427}, - {0x0000a3a4, 0x00000000}, - {0x0000a3a8, 0xaaaaaaaa}, - {0x0000a3ac, 0x3c466478}, - {0x0000a3c0, 0x20202020}, - {0x0000a3c4, 0x22222220}, - {0x0000a3c8, 0x20200020}, - {0x0000a3cc, 0x20202020}, - {0x0000a3d0, 0x20202020}, - {0x0000a3d4, 0x20202020}, - {0x0000a3d8, 0x20202020}, - {0x0000a3dc, 0x20202020}, - {0x0000a3e0, 0x20202020}, - {0x0000a3e4, 0x20202020}, - {0x0000a3e8, 0x20202020}, - {0x0000a3ec, 0x20202020}, - {0x0000a3f0, 0x00000000}, - {0x0000a3f4, 0x00000006}, - {0x0000a3f8, 0x0c9bd380}, - {0x0000a3fc, 0x000f0f01}, - {0x0000a400, 0x8fa91f01}, - {0x0000a404, 0x00000000}, - {0x0000a408, 0x0e79e5c6}, - {0x0000a40c, 0x00820820}, - {0x0000a414, 0x1ce739ce}, - {0x0000a418, 0x2d001dce}, - {0x0000a41c, 0x1ce739ce}, - {0x0000a420, 0x000001ce}, - {0x0000a424, 0x1ce739ce}, - {0x0000a428, 0x000001ce}, - {0x0000a42c, 0x1ce739ce}, - {0x0000a430, 0x1ce739ce}, - {0x0000a434, 0x00000000}, - {0x0000a438, 0x00001801}, - {0x0000a43c, 0x00100000}, - {0x0000a440, 0x00000000}, - {0x0000a444, 0x00000000}, - {0x0000a448, 0x05000080}, - {0x0000a44c, 0x00000001}, - {0x0000a450, 0x00010000}, - {0x0000a458, 0x00000000}, - {0x0000a644, 0xbfad9d74}, - {0x0000a648, 0x0048060a}, - {0x0000a64c, 0x00003c37}, - {0x0000a670, 0x03020100}, - {0x0000a674, 0x09080504}, - {0x0000a678, 0x0d0c0b0a}, - {0x0000a67c, 0x13121110}, - {0x0000a680, 0x31301514}, - {0x0000a684, 0x35343332}, - {0x0000a688, 0x00000036}, - {0x0000a690, 0x00000838}, - {0x0000a6b0, 0x0000000a}, - {0x0000a6b4, 0x28f12c01}, - {0x0000a7c0, 0x00000000}, - {0x0000a7c4, 0xfffffffc}, - {0x0000a7c8, 0x00000000}, - {0x0000a7cc, 0x00000000}, - {0x0000a7d0, 0x00000000}, - {0x0000a7d4, 0x00000004}, - {0x0000a7dc, 0x00000001}, - {0x0000a8d0, 0x004b6a8e}, - {0x0000a8d4, 0x00000820}, - {0x0000a8dc, 0x00000000}, - {0x0000a8f0, 0x00000000}, - {0x0000a8f4, 0x00000000}, - {0x0000b2d0, 0x00000080}, - {0x0000b2d4, 0x00000000}, - {0x0000b2ec, 0x00000000}, - {0x0000b2f0, 0x00000000}, - {0x0000b2f4, 0x00000000}, - {0x0000b2f8, 0x00000000}, - {0x0000b408, 0x0e79e5c0}, - {0x0000b40c, 0x00820820}, - {0x0000b420, 0x00000000}, - {0x0000b6b0, 0x0000000a}, - {0x0000b6b4, 0x00c00001}, -}; - -static const u32 ar9462_1p0_baseband_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, - {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, - {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, - {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, - {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, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e}, - {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 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, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27}, - {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012}, - {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, - {0x0000a204, 0x0131b7c0, 0x0131b7c4, 0x0131b7c4, 0x0131b7c0}, - {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004}, - {0x0000a22c, 0x01026a2f, 0x01026a27, 0x01026a2f, 0x01026a2f}, - {0x0000a230, 0x0000400a, 0x00004014, 0x00004016, 0x0000400b}, - {0x0000a234, 0x00000fff, 0x10000fff, 0x10000fff, 0x00000fff}, - {0x0000a238, 0xffb81018, 0xffb81018, 0xffb81018, 0xffb81018}, - {0x0000a250, 0x00000000, 0x00000000, 0x00000210, 0x00000108}, - {0x0000a254, 0x000007d0, 0x00000fa0, 0x00001130, 0x00000898}, - {0x0000a258, 0x02020002, 0x02020002, 0x02020002, 0x02020002}, - {0x0000a25c, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e}, - {0x0000a260, 0x0a021501, 0x0a021501, 0x3a021501, 0x3a021501}, - {0x0000a264, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e}, - {0x0000a280, 0x00000007, 0x00000007, 0x0000000b, 0x0000000b}, - {0x0000a284, 0x00000000, 0x00000000, 0x00000150, 0x00000150}, - {0x0000a288, 0x00000110, 0x00000110, 0x00100110, 0x00100110}, - {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222}, - {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18}, - {0x0000a2d0, 0x00041981, 0x00041981, 0x00041981, 0x00041982}, - {0x0000a2d8, 0x7999a83b, 0x7999a83b, 0x7999a83b, 0x7999a83b}, - {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, - {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x00100000}, - {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, - {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce}, - {0x0000b284, 0x00000000, 0x00000000, 0x00000550, 0x00000550}, -}; - -static const u32 ar9462_modes_fast_clock_1p0[][3] = { - /* Addr 5G_HT20 5G_HT40 */ - {0x00001030, 0x00000268, 0x000004d0}, - {0x00001070, 0x0000018c, 0x00000318}, - {0x000010b0, 0x00000fd0, 0x00001fa0}, - {0x00008014, 0x044c044c, 0x08980898}, - {0x0000801c, 0x148ec02b, 0x148ec057}, - {0x00008318, 0x000044c0, 0x00008980}, - {0x00009e00, 0x0372131c, 0x0372131c}, - {0x0000a230, 0x0000400b, 0x00004016}, - {0x0000a254, 0x00000898, 0x00001130}, -}; - -static const u32 ar9462_modes_low_ob_db_tx_gain_table_1p0[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352}, - {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584}, - {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800}, - {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, - {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, - {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002}, - {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004}, - {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200}, - {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202}, - {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400}, - {0x0000a518, 0x21020220, 0x21020220, 0x16000402, 0x16000402}, - {0x0000a51c, 0x27020223, 0x27020223, 0x19000404, 0x19000404}, - {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603}, - {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02}, - {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04}, - {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20}, - {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20}, - {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22}, - {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24}, - {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640}, - {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660}, - {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861}, - {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81}, - {0x0000a54c, 0x5c04286b, 0x5c04286b, 0x47001a83, 0x47001a83}, - {0x0000a550, 0x61042a6c, 0x61042a6c, 0x4a001c84, 0x4a001c84}, - {0x0000a554, 0x66062a6c, 0x66062a6c, 0x4e001ce3, 0x4e001ce3}, - {0x0000a558, 0x6b062e6c, 0x6b062e6c, 0x52001ce5, 0x52001ce5}, - {0x0000a55c, 0x7006308c, 0x7006308c, 0x56001ce9, 0x56001ce9}, - {0x0000a560, 0x730a308a, 0x730a308a, 0x5a001ceb, 0x5a001ceb}, - {0x0000a564, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a568, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a56c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a570, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a574, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a578, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a57c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008501, 0x02008501}, - {0x0000a620, 0x0300cc03, 0x0300cc03, 0x0280ca03, 0x0280ca03}, - {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04}, - {0x0000a628, 0x0300cc03, 0x0300cc03, 0x04014c04, 0x04014c04}, - {0x0000a62c, 0x03810c03, 0x03810c03, 0x04015005, 0x04015005}, - {0x0000a630, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005}, - {0x0000a634, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005}, - {0x0000a638, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005}, - {0x0000a63c, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005}, - {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352}, - {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584}, - {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800}, - {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, - {0x00016044, 0x012482d4, 0x012482d4, 0x012482d4, 0x012482d4}, - {0x00016048, 0x64992060, 0x64992060, 0x64992060, 0x64992060}, - {0x00016444, 0x012482d4, 0x012482d4, 0x012482d4, 0x012482d4}, - {0x00016448, 0x64992000, 0x64992000, 0x64992000, 0x64992000}, -}; - -static const u32 ar9462_1p0_soc_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00007010, 0x00002233, 0x00002233, 0x00002233, 0x00002233}, -}; - -static const u32 ar9462_common_mixed_rx_gain_table_1p0[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00010000}, - {0x0000a004, 0x00030002}, - {0x0000a008, 0x00050004}, - {0x0000a00c, 0x00810080}, - {0x0000a010, 0x00830082}, - {0x0000a014, 0x01810180}, - {0x0000a018, 0x01830182}, - {0x0000a01c, 0x01850184}, - {0x0000a020, 0x01890188}, - {0x0000a024, 0x018b018a}, - {0x0000a028, 0x018d018c}, - {0x0000a02c, 0x03820190}, - {0x0000a030, 0x03840383}, - {0x0000a034, 0x03880385}, - {0x0000a038, 0x038a0389}, - {0x0000a03c, 0x038c038b}, - {0x0000a040, 0x0390038d}, - {0x0000a044, 0x03920391}, - {0x0000a048, 0x03940393}, - {0x0000a04c, 0x03960395}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x29292929}, - {0x0000a084, 0x29292929}, - {0x0000a088, 0x29292929}, - {0x0000a08c, 0x29292929}, - {0x0000a090, 0x22292929}, - {0x0000a094, 0x1d1d2222}, - {0x0000a098, 0x0c111117}, - {0x0000a09c, 0x00030303}, - {0x0000a0a0, 0x00000000}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x001f0000}, - {0x0000a0c4, 0x01000101}, - {0x0000a0c8, 0x011e011f}, - {0x0000a0cc, 0x011c011d}, - {0x0000a0d0, 0x02030204}, - {0x0000a0d4, 0x02010202}, - {0x0000a0d8, 0x021f0200}, - {0x0000a0dc, 0x0302021e}, - {0x0000a0e0, 0x03000301}, - {0x0000a0e4, 0x031e031f}, - {0x0000a0e8, 0x0402031d}, - {0x0000a0ec, 0x04000401}, - {0x0000a0f0, 0x041e041f}, - {0x0000a0f4, 0x0502041d}, - {0x0000a0f8, 0x05000501}, - {0x0000a0fc, 0x051e051f}, - {0x0000a100, 0x06010602}, - {0x0000a104, 0x061f0600}, - {0x0000a108, 0x061d061e}, - {0x0000a10c, 0x07020703}, - {0x0000a110, 0x07000701}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x01000101}, - {0x0000a148, 0x011e011f}, - {0x0000a14c, 0x011c011d}, - {0x0000a150, 0x02030204}, - {0x0000a154, 0x02010202}, - {0x0000a158, 0x021f0200}, - {0x0000a15c, 0x0302021e}, - {0x0000a160, 0x03000301}, - {0x0000a164, 0x031e031f}, - {0x0000a168, 0x0402031d}, - {0x0000a16c, 0x04000401}, - {0x0000a170, 0x041e041f}, - {0x0000a174, 0x0502041d}, - {0x0000a178, 0x05000501}, - {0x0000a17c, 0x051e051f}, - {0x0000a180, 0x06010602}, - {0x0000a184, 0x061f0600}, - {0x0000a188, 0x061d061e}, - {0x0000a18c, 0x07020703}, - {0x0000a190, 0x07000701}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000196}, - {0x0000b000, 0x00010000}, - {0x0000b004, 0x00030002}, - {0x0000b008, 0x00050004}, - {0x0000b00c, 0x00810080}, - {0x0000b010, 0x00830082}, - {0x0000b014, 0x01810180}, - {0x0000b018, 0x01830182}, - {0x0000b01c, 0x01850184}, - {0x0000b020, 0x02810280}, - {0x0000b024, 0x02830282}, - {0x0000b028, 0x02850284}, - {0x0000b02c, 0x02890288}, - {0x0000b030, 0x028b028a}, - {0x0000b034, 0x0388028c}, - {0x0000b038, 0x038a0389}, - {0x0000b03c, 0x038c038b}, - {0x0000b040, 0x0390038d}, - {0x0000b044, 0x03920391}, - {0x0000b048, 0x03940393}, - {0x0000b04c, 0x03960395}, - {0x0000b050, 0x00000000}, - {0x0000b054, 0x00000000}, - {0x0000b058, 0x00000000}, - {0x0000b05c, 0x00000000}, - {0x0000b060, 0x00000000}, - {0x0000b064, 0x00000000}, - {0x0000b068, 0x00000000}, - {0x0000b06c, 0x00000000}, - {0x0000b070, 0x00000000}, - {0x0000b074, 0x00000000}, - {0x0000b078, 0x00000000}, - {0x0000b07c, 0x00000000}, - {0x0000b080, 0x2a2d2f32}, - {0x0000b084, 0x21232328}, - {0x0000b088, 0x19191c1e}, - {0x0000b08c, 0x12141417}, - {0x0000b090, 0x07070e0e}, - {0x0000b094, 0x03030305}, - {0x0000b098, 0x00000003}, - {0x0000b09c, 0x00000000}, - {0x0000b0a0, 0x00000000}, - {0x0000b0a4, 0x00000000}, - {0x0000b0a8, 0x00000000}, - {0x0000b0ac, 0x00000000}, - {0x0000b0b0, 0x00000000}, - {0x0000b0b4, 0x00000000}, - {0x0000b0b8, 0x00000000}, - {0x0000b0bc, 0x00000000}, - {0x0000b0c0, 0x003f0020}, - {0x0000b0c4, 0x00400041}, - {0x0000b0c8, 0x0140005f}, - {0x0000b0cc, 0x0160015f}, - {0x0000b0d0, 0x017e017f}, - {0x0000b0d4, 0x02410242}, - {0x0000b0d8, 0x025f0240}, - {0x0000b0dc, 0x027f0260}, - {0x0000b0e0, 0x0341027e}, - {0x0000b0e4, 0x035f0340}, - {0x0000b0e8, 0x037f0360}, - {0x0000b0ec, 0x04400441}, - {0x0000b0f0, 0x0460045f}, - {0x0000b0f4, 0x0541047f}, - {0x0000b0f8, 0x055f0540}, - {0x0000b0fc, 0x057f0560}, - {0x0000b100, 0x06400641}, - {0x0000b104, 0x0660065f}, - {0x0000b108, 0x067e067f}, - {0x0000b10c, 0x07410742}, - {0x0000b110, 0x075f0740}, - {0x0000b114, 0x077f0760}, - {0x0000b118, 0x07800781}, - {0x0000b11c, 0x07a0079f}, - {0x0000b120, 0x07c107bf}, - {0x0000b124, 0x000007c0}, - {0x0000b128, 0x00000000}, - {0x0000b12c, 0x00000000}, - {0x0000b130, 0x00000000}, - {0x0000b134, 0x00000000}, - {0x0000b138, 0x00000000}, - {0x0000b13c, 0x00000000}, - {0x0000b140, 0x003f0020}, - {0x0000b144, 0x00400041}, - {0x0000b148, 0x0140005f}, - {0x0000b14c, 0x0160015f}, - {0x0000b150, 0x017e017f}, - {0x0000b154, 0x02410242}, - {0x0000b158, 0x025f0240}, - {0x0000b15c, 0x027f0260}, - {0x0000b160, 0x0341027e}, - {0x0000b164, 0x035f0340}, - {0x0000b168, 0x037f0360}, - {0x0000b16c, 0x04400441}, - {0x0000b170, 0x0460045f}, - {0x0000b174, 0x0541047f}, - {0x0000b178, 0x055f0540}, - {0x0000b17c, 0x057f0560}, - {0x0000b180, 0x06400641}, - {0x0000b184, 0x0660065f}, - {0x0000b188, 0x067e067f}, - {0x0000b18c, 0x07410742}, - {0x0000b190, 0x075f0740}, - {0x0000b194, 0x077f0760}, - {0x0000b198, 0x07800781}, - {0x0000b19c, 0x07a0079f}, - {0x0000b1a0, 0x07c107bf}, - {0x0000b1a4, 0x000007c0}, - {0x0000b1a8, 0x00000000}, - {0x0000b1ac, 0x00000000}, - {0x0000b1b0, 0x00000000}, - {0x0000b1b4, 0x00000000}, - {0x0000b1b8, 0x00000000}, - {0x0000b1bc, 0x00000000}, - {0x0000b1c0, 0x00000000}, - {0x0000b1c4, 0x00000000}, - {0x0000b1c8, 0x00000000}, - {0x0000b1cc, 0x00000000}, - {0x0000b1d0, 0x00000000}, - {0x0000b1d4, 0x00000000}, - {0x0000b1d8, 0x00000000}, - {0x0000b1dc, 0x00000000}, - {0x0000b1e0, 0x00000000}, - {0x0000b1e4, 0x00000000}, - {0x0000b1e8, 0x00000000}, - {0x0000b1ec, 0x00000000}, - {0x0000b1f0, 0x00000396}, - {0x0000b1f4, 0x00000396}, - {0x0000b1f8, 0x00000396}, - {0x0000b1fc, 0x00000196}, -}; - -static const u32 ar9462_pcie_phy_clkreq_disable_L1_1p0[][2] = { - /* Addr allmodes */ - {0x00018c00, 0x10013e5e}, - {0x00018c04, 0x000801d8}, - {0x00018c08, 0x0000580c}, -}; - -static const u32 ar9462_1p0_radio_core[][2] = { - /* Addr allmodes */ - {0x00016000, 0x36db6db6}, - {0x00016004, 0x6db6db40}, - {0x00016008, 0x73f00000}, - {0x0001600c, 0x00000000}, - {0x00016010, 0x6d820001}, - {0x00016040, 0x7f80fff8}, - {0x0001604c, 0x2699e04f}, - {0x00016050, 0x6db6db6c}, - {0x00016054, 0x6db60000}, - {0x00016058, 0x6c200000}, - {0x00016080, 0x00040000}, - {0x00016084, 0x9a68048c}, - {0x00016088, 0x54214514}, - {0x0001608c, 0x12030409}, - {0x00016090, 0x24926490}, - {0x00016098, 0xd2888888}, - {0x000160a0, 0x0a108ffe}, - {0x000160a4, 0x812fc490}, - {0x000160a8, 0x423c8000}, - {0x000160b4, 0x92000000}, - {0x000160b8, 0x0285dddc}, - {0x000160bc, 0x02908888}, - {0x000160c0, 0x00adb6d0}, - {0x000160c4, 0x6db6db60}, - {0x000160c8, 0x6db6db6c}, - {0x000160cc, 0x0de6c1b0}, - {0x00016100, 0x3fffbe04}, - {0x00016104, 0xfff80000}, - {0x00016108, 0x00200400}, - {0x00016110, 0x00000000}, - {0x00016144, 0x02084080}, - {0x00016148, 0x000080c0}, - {0x00016280, 0x050a0001}, - {0x00016284, 0x3d841400}, - {0x00016288, 0x00000000}, - {0x0001628c, 0xe3000000}, - {0x00016290, 0xa1005080}, - {0x00016294, 0x00000020}, - {0x00016298, 0x50a02900}, - {0x00016340, 0x121e4276}, - {0x00016344, 0x00300000}, - {0x00016400, 0x36db6db6}, - {0x00016404, 0x6db6db40}, - {0x00016408, 0x73f00000}, - {0x0001640c, 0x00000000}, - {0x00016410, 0x6c800001}, - {0x00016440, 0x7f80fff8}, - {0x0001644c, 0x4699e04f}, - {0x00016450, 0x6db6db6c}, - {0x00016454, 0x6db60000}, - {0x00016500, 0x3fffbe04}, - {0x00016504, 0xfff80000}, - {0x00016508, 0x00200400}, - {0x00016510, 0x00000000}, - {0x00016544, 0x02084080}, - {0x00016548, 0x000080c0}, -}; - -static const u32 ar9462_1p0_soc_preamble[][2] = { - /* Addr allmodes */ - {0x00007020, 0x00000000}, - {0x00007034, 0x00000002}, - {0x00007038, 0x000004c2}, -}; - -#endif /* INITVALS_9462_1P0_H */ diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 87db1ee1c298..cb46d41f2288 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1962,8 +1962,7 @@ static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip) REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); /* Shutdown chip. Active low */ - if (!AR_SREV_5416(ah) && - !AR_SREV_9271(ah) && !AR_SREV_9462_10(ah)) { + if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah)) { REG_CLR_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN); udelay(2); } diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h index 6e2f18861f5d..80b1856f817d 100644 --- a/drivers/net/wireless/ath/ath9k/reg.h +++ b/drivers/net/wireless/ath/ath9k/reg.h @@ -797,7 +797,6 @@ #define AR_SREV_VERSION_9580 0x1C0 #define AR_SREV_REVISION_9580_10 4 /* AR9580 1.0 */ #define AR_SREV_VERSION_9462 0x280 -#define AR_SREV_REVISION_9462_10 0 #define AR_SREV_REVISION_9462_20 2 #define AR_SREV_5416(_ah) \ @@ -898,10 +897,6 @@ #define AR_SREV_9462(_ah) \ (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462)) -#define AR_SREV_9462_10(_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \ - ((_ah)->hw_version.macRev == AR_SREV_REVISION_9462_10)) - #define AR_SREV_9462_20(_ah) \ (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \ ((_ah)->hw_version.macRev == AR_SREV_REVISION_9462_20)) -- GitLab From ea510e4bdd672b72d0350198538e697e471fafd4 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:09 +0530 Subject: [PATCH 1149/1846] ath9k: Cleanup MCI init/deinit routines This patch simplifies the buffer allocation functions for MCI and removes unneeded memset calls. Also, a couple of unused variables are removed and a memory leak in DMA allocation is fixed. [ 1263.788267] WARNING: at /home/sujith/dev/wireless-testing/lib/dma-debug.c:875 check_unmap+0x173/0x7e0() [ 1263.788273] ath9k 0000:06:00.0: DMA-API: device driver frees DMA memory with different size [device address=0x0000000071908000] [map size=512 bytes] [unmap size=256 bytes] [ 1263.788345] Pid: 774, comm: rmmod Tainted: G W O 3.3.0-rc3-wl #18 [ 1263.788348] Call Trace: [ 1263.788355] [] warn_slowpath_common+0x7f/0xc0 [ 1263.788359] [] warn_slowpath_fmt+0x46/0x50 [ 1263.788363] [] check_unmap+0x173/0x7e0 [ 1263.788368] [] ? prio_tree_left+0x32/0xc0 [ 1263.788373] [] debug_dma_free_coherent+0x6d/0x80 [ 1263.788381] [] ath_mci_cleanup+0x7c/0x110 [ath9k] [ 1263.788387] [] ath9k_deinit_softc+0x113/0x120 [ath9k] [ 1263.788392] [] ath9k_deinit_device+0x5c/0x70 [ath9k] [ 1263.788397] [] ath_pci_remove+0x54/0xa0 [ath9k] [ 1263.788401] [] pci_device_remove+0x46/0x110 [ 1263.788406] [] __device_release_driver+0x7c/0xe0 [ 1263.788410] [] driver_detach+0xd0/0xe0 [ 1263.788414] [] bus_remove_driver+0x88/0xe0 [ 1263.788418] [] driver_unregister+0x62/0xa0 [ 1263.788421] [] pci_unregister_driver+0x44/0xc0 [ 1263.788427] [] ath_pci_exit+0x15/0x20 [ath9k] [ 1263.788432] [] ath9k_exit+0x15/0x31 [ath9k] [ 1263.788436] [] sys_delete_module+0x18c/0x270 [ 1263.788441] [] ? retint_swapgs+0x13/0x1b [ 1263.788446] [] ? trace_hardirqs_on_thunk+0x3a/0x3f [ 1263.788450] [] system_call_fastpath+0x16/0x1b [ 1263.788453] ---[ end trace 3ab4d030ffde40d4 ]--- Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 5 -- drivers/net/wireless/ath/ath9k/btcoex.h | 1 - drivers/net/wireless/ath/ath9k/mci.c | 70 +++++++-------------- drivers/net/wireless/ath/ath9k/mci.h | 3 - 4 files changed, 23 insertions(+), 56 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 8439656a0913..2cd607f9705e 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -973,7 +973,6 @@ 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)); if (!ATH9K_HW_CAP_MCI) return; @@ -982,7 +981,6 @@ void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf, 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); } @@ -990,14 +988,11 @@ EXPORT_SYMBOL(ar9003_mci_setup); void ar9003_mci_cleanup(struct ath_hw *ah) { - struct ath_common *common = ath9k_hw_common(ah); - if (!ATH9K_HW_CAP_MCI) return; /* Turn off MCI and Jupiter mode. */ REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00); - ath_dbg(common, MCI, "MCI ar9003_mci_cleanup\n"); ar9003_mci_disable_interrupt(ah); } EXPORT_SYMBOL(ar9003_mci_cleanup); diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h index 278361c867ca..0cb7ce98394b 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.h +++ b/drivers/net/wireless/ath/ath9k/btcoex.h @@ -67,7 +67,6 @@ struct ath9k_hw_mci { u32 wlan_cal_done; u32 config; u8 *gpm_buf; - u8 *sched_buf; bool ready; bool update_2g5g; bool is_2g; diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index 05c23ea4c633..85a957ab89be 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -383,84 +383,60 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) } } -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; + struct ath_mci_buf *buf = &mci->sched_buf; if (!ATH9K_HW_CAP_MCI) return 0; - mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE; + buf->bf_addr = dma_alloc_coherent(sc->dev, + ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, + &buf->bf_paddr, GFP_KERNEL); - if (ath_mci_buf_alloc(sc, &mci->sched_buf)) { + if (buf->bf_addr == NULL) { ath_dbg(common, FATAL, "MCI buffer alloc failed\n"); - error = -ENOMEM; - goto fail; + return -ENOMEM; } - mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE; + memset(buf->bf_addr, MCI_GPM_RSVD_PATTERN, + ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE); - memset(mci->sched_buf.bf_addr, MCI_GPM_RSVD_PATTERN, - mci->sched_buf.bf_len); + mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE; 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_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; + + ath_dbg(common, MCI, "MCI Initialized\n"); + + return 0; } void ath_mci_cleanup(struct ath_softc *sc) { + struct ath_common *common = ath9k_hw_common(sc->sc_ah); struct ath_hw *ah = sc->sc_ah; struct ath_mci_coex *mci = &sc->mci_coex; + struct ath_mci_buf *buf = &mci->sched_buf; if (!ATH9K_HW_CAP_MCI) return; - /* - * both schedule and gpm buffers will be released - */ - ath_mci_buf_free(sc, &mci->sched_buf); + if (buf->bf_addr) + dma_free_coherent(sc->dev, + ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, + buf->bf_addr, buf->bf_paddr); + ar9003_mci_cleanup(ah); + + ath_dbg(common, MCI, "MCI De-Initialized\n"); } void ath_mci_intr(struct ath_softc *sc) diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index 29e3e51d078f..b805bf24ea4c 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -113,7 +113,6 @@ 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 */ @@ -121,10 +120,8 @@ struct ath_mci_buf { }; 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); -- GitLab From d3c83ac12338509f37e95bffb19097a361a089a2 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:15 +0530 Subject: [PATCH 1150/1846] ath9k: Initialize MCI params using a helper Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/btcoex.c | 24 ++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/btcoex.h | 1 + drivers/net/wireless/ath/ath9k/init.c | 23 ++--------------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c index a6712a95d76a..6566952b08cc 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.c +++ b/drivers/net/wireless/ath/ath9k/btcoex.c @@ -152,6 +152,30 @@ void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah) } EXPORT_SYMBOL(ath9k_hw_btcoex_init_3wire); +void ath9k_hw_btcoex_init_mci(struct ath_hw *ah) +{ + 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; +} +EXPORT_SYMBOL(ath9k_hw_btcoex_init_mci); + static void ath9k_hw_btcoex_enable_2wire(struct ath_hw *ah) { struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h index 0cb7ce98394b..0cb15cd85e92 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.h +++ b/drivers/net/wireless/ath/ath9k/btcoex.h @@ -99,6 +99,7 @@ struct ath_btcoex_hw { void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah); void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah); +void ath9k_hw_btcoex_init_mci(struct ath_hw *ah); void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum); void ath9k_hw_btcoex_set_weight(struct ath_hw *ah, u32 bt_weight, diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 53a005d288aa..a944fc95f69f 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -449,27 +449,8 @@ static int ath9k_init_btcoex(struct ath_softc *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; - 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; - } + ath9k_hw_btcoex_init_mci(ah); + break; default: WARN_ON(1); -- GitLab From 5908120fdc2aac0cb1be4059b40ec256d55934bc Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:21 +0530 Subject: [PATCH 1151/1846] ath9k: Move BTCOEX init/deinit functions to gpio.c Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 2 + drivers/net/wireless/ath/ath9k/gpio.c | 51 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/init.c | 48 +----------------------- 3 files changed, 54 insertions(+), 47 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 171ccf7c972f..aa609832e06f 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -454,6 +454,8 @@ struct ath_btcoex { struct ath_mci_profile mci; }; +int ath9k_init_btcoex(struct ath_softc *sc); +void ath9k_deinit_btcoex(struct ath_softc *sc); int ath_init_btcoex_timer(struct ath_softc *sc); void ath9k_btcoex_timer_resume(struct ath_softc *sc); void ath9k_btcoex_timer_pause(struct ath_softc *sc); diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 597c84e31adb..ef23624518b5 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -317,3 +317,54 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc) btcoex->hw_timer_enabled = false; } + +void ath9k_deinit_btcoex(struct ath_softc *sc) +{ + if ((sc->btcoex.no_stomp_timer) && + ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE) + ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer); + + if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_MCI) + ath_mci_cleanup(sc); +} + +int ath9k_init_btcoex(struct ath_softc *sc) +{ + struct ath_txq *txq; + struct ath_hw *ah = sc->sc_ah; + int r; + + switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) { + case ATH_BTCOEX_CFG_NONE: + break; + case ATH_BTCOEX_CFG_2WIRE: + ath9k_hw_btcoex_init_2wire(sc->sc_ah); + break; + case ATH_BTCOEX_CFG_3WIRE: + ath9k_hw_btcoex_init_3wire(sc->sc_ah); + r = ath_init_btcoex_timer(sc); + if (r) + 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; + + ath9k_hw_btcoex_init_mci(ah); + + break; + default: + WARN_ON(1); + break; + } + + return 0; +} diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index a944fc95f69f..d8b05961f7e3 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -419,47 +419,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, return error; } -static int ath9k_init_btcoex(struct ath_softc *sc) -{ - struct ath_txq *txq; - struct ath_hw *ah = sc->sc_ah; - int r; - - switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) { - case ATH_BTCOEX_CFG_NONE: - break; - case ATH_BTCOEX_CFG_2WIRE: - ath9k_hw_btcoex_init_2wire(sc->sc_ah); - break; - case ATH_BTCOEX_CFG_3WIRE: - ath9k_hw_btcoex_init_3wire(sc->sc_ah); - r = ath_init_btcoex_timer(sc); - if (r) - 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; - - ath9k_hw_btcoex_init_mci(ah); - - break; - default: - WARN_ON(1); - break; - } - - return 0; -} - static int ath9k_init_queues(struct ath_softc *sc) { int i = 0; @@ -861,12 +820,7 @@ static void ath9k_deinit_softc(struct ath_softc *sc) if (sc->sbands[IEEE80211_BAND_5GHZ].channels) kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels); - if ((sc->btcoex.no_stomp_timer) && - ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE) - ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer); - - if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_MCI) - ath_mci_cleanup(sc); + ath9k_deinit_btcoex(sc); for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) if (ATH_TXQ_SETUP(sc, i)) -- GitLab From df198b172f7a14ecf7aefaadb3761c273600333e Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:27 +0530 Subject: [PATCH 1152/1846] ath9k: Use proper start/stop routines for BTCOEX Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 3 ++- drivers/net/wireless/ath/ath9k/gpio.c | 31 +++++++++++++++++++++++++- drivers/net/wireless/ath/ath9k/main.c | 19 ++-------------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index aa609832e06f..2ede8977406d 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -456,7 +456,8 @@ struct ath_btcoex { int ath9k_init_btcoex(struct ath_softc *sc); void ath9k_deinit_btcoex(struct ath_softc *sc); -int ath_init_btcoex_timer(struct ath_softc *sc); +void ath9k_start_btcoex(struct ath_softc *sc); +void ath9k_stop_btcoex(struct ath_softc *sc); void ath9k_btcoex_timer_resume(struct ath_softc *sc); void ath9k_btcoex_timer_pause(struct ath_softc *sc); diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index ef23624518b5..1ca2ca54f0e1 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -245,7 +245,7 @@ static void ath_btcoex_no_stomp_timer(void *arg) ath9k_ps_restore(sc); } -int ath_init_btcoex_timer(struct ath_softc *sc) +static int ath_init_btcoex_timer(struct ath_softc *sc) { struct ath_btcoex *btcoex = &sc->btcoex; @@ -318,6 +318,35 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc) btcoex->hw_timer_enabled = false; } +void ath9k_start_btcoex(struct ath_softc *sc) +{ + struct ath_hw *ah = sc->sc_ah; + + if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) && + !ah->btcoex_hw.enabled) { + if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) + ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, + AR_STOMP_LOW_WLAN_WGHT); + ath9k_hw_btcoex_enable(ah); + + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) + ath9k_btcoex_timer_resume(sc); + } +} + +void ath9k_stop_btcoex(struct ath_softc *sc) +{ + struct ath_hw *ah = sc->sc_ah; + + if (ah->btcoex_hw.enabled && + ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) { + ath9k_hw_btcoex_disable(ah); + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) + ath9k_btcoex_timer_pause(sc); + ath_mci_flush_profile(&sc->btcoex.mci); + } +} + void ath9k_deinit_btcoex(struct ath_softc *sc) { if ((sc->btcoex.no_stomp_timer) && diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index c81304d3ef14..82c36a918946 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1075,16 +1075,7 @@ static int ath9k_start(struct ieee80211_hw *hw) spin_unlock_bh(&sc->sc_pcu_lock); - if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) && - !ah->btcoex_hw.enabled) { - if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) - ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, - AR_STOMP_LOW_WLAN_WGHT); - ath9k_hw_btcoex_enable(ah); - - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) - ath9k_btcoex_timer_resume(sc); - } + ath9k_start_btcoex(sc); if (ah->caps.pcie_lcr_extsync_en && common->bus_ops->extn_synch_en) common->bus_ops->extn_synch_en(common); @@ -1185,13 +1176,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) /* Ensure HW is awake when we try to shut it down. */ ath9k_ps_wakeup(sc); - if (ah->btcoex_hw.enabled && - ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) { - ath9k_hw_btcoex_disable(ah); - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) - ath9k_btcoex_timer_pause(sc); - ath_mci_flush_profile(&sc->btcoex.mci); - } + ath9k_stop_btcoex(sc); spin_lock_bh(&sc->sc_pcu_lock); -- GitLab From 56ca0dba9d5fbc2948ed0c3a4fffc51cd875abb9 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:32 +0530 Subject: [PATCH 1153/1846] ath9k: Process BTCOEX interrupts using a helper Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/gpio.c | 12 ++++++++++++ drivers/net/wireless/ath/ath9k/main.c | 7 +------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 2ede8977406d..acf537288946 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -460,6 +460,7 @@ void ath9k_start_btcoex(struct ath_softc *sc); void ath9k_stop_btcoex(struct ath_softc *sc); void ath9k_btcoex_timer_resume(struct ath_softc *sc); void ath9k_btcoex_timer_pause(struct ath_softc *sc); +void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status); /********************/ /* LED Control */ diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 1ca2ca54f0e1..a24aa679c699 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -318,6 +318,18 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc) btcoex->hw_timer_enabled = false; } +void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status) +{ + struct ath_hw *ah = sc->sc_ah; + + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) + if (status & ATH9K_INT_GENTIMER) + ath_gen_timer_isr(sc->sc_ah); + + if ((status & ATH9K_INT_MCI) && ATH9K_HW_CAP_MCI) + ath_mci_intr(sc); +} + void ath9k_start_btcoex(struct ath_softc *sc) { struct ath_hw *ah = sc->sc_ah; diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 82c36a918946..02e95c8e7465 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -735,12 +735,7 @@ void ath9k_tasklet(unsigned long data) ath_tx_tasklet(sc); } - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) - if (status & ATH9K_INT_GENTIMER) - ath_gen_timer_isr(sc->sc_ah); - - if ((status & ATH9K_INT_MCI) && ATH9K_HW_CAP_MCI) - ath_mci_intr(sc); + ath9k_btcoex_handle_interrupt(sc, status); out: /* re-enable hardware interrupt */ -- GitLab From c0ac53fa5725aa9e571386d3e7249c1be50eca10 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:38 +0530 Subject: [PATCH 1154/1846] ath9k: Calculate ampdu limit using a helper Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/gpio.c | 14 ++++++++++++++ drivers/net/wireless/ath/ath9k/xmit.c | 19 +++++++++---------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index acf537288946..23145ce9ea3f 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -461,6 +461,7 @@ void ath9k_stop_btcoex(struct ath_softc *sc); void ath9k_btcoex_timer_resume(struct ath_softc *sc); void ath9k_btcoex_timer_pause(struct ath_softc *sc); void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status); +u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen); /********************/ /* LED Control */ diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index a24aa679c699..e870251cdd1b 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -318,6 +318,20 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc) btcoex->hw_timer_enabled = false; } +u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen) +{ + struct ath_mci_profile *mci = &sc->btcoex.mci; + u16 aggr_limit = 0; + + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) + aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; + else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) + aggr_limit = min((max_4ms_framelen * 3) / 8, + (u32)ATH_AMPDU_LIMIT_MAX); + + return aggr_limit; +} + void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status) { struct ath_hw *ah = sc->sc_ah; diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 3182408ffe35..5dd27d2712fc 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -647,9 +647,8 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, struct sk_buff *skb; struct ieee80211_tx_info *tx_info; struct ieee80211_tx_rate *rates; - struct ath_mci_profile *mci = &sc->btcoex.mci; u32 max_4ms_framelen, frmlen; - u16 aggr_limit, legacy = 0; + u16 aggr_limit, bt_aggr_limit, legacy = 0; int i; skb = bf->bf_mpdu; @@ -694,14 +693,14 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) return 0; - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) - aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; - else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) - aggr_limit = min((max_4ms_framelen * 3) / 8, - (u32)ATH_AMPDU_LIMIT_MAX); - else - aggr_limit = min(max_4ms_framelen, - (u32)ATH_AMPDU_LIMIT_MAX); + aggr_limit = min(max_4ms_framelen, (u32)ATH_AMPDU_LIMIT_MAX); + + /* + * Override the default aggregation limit for BTCOEX. + */ + bt_aggr_limit = ath9k_btcoex_aggr_limit(sc, max_4ms_framelen); + if (bt_aggr_limit) + aggr_limit = bt_aggr_limit; /* * h/w can accept aggregates up to 16 bit lengths (65535). -- GitLab From 4daa7760e2da9324e740f7d872970fa91c8ea6f0 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:44 +0530 Subject: [PATCH 1155/1846] ath9k: Use CONFIG_ATH9K_BTCOEX_SUPPORT This patch uses CONFIG_ATH9K_BTCOEX_SUPPORT to conditionally compile btcoex-related code in the driver core. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/Makefile | 4 ++-- drivers/net/wireless/ath/ath9k/ath9k.h | 28 +++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/gpio.c | 4 ++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile index da02242499af..b3c7b12a3e2c 100644 --- a/drivers/net/wireless/ath/ath9k/Makefile +++ b/drivers/net/wireless/ath/ath9k/Makefile @@ -3,9 +3,9 @@ ath9k-y += beacon.o \ init.o \ main.o \ recv.o \ - xmit.o \ - mci.o \ + xmit.o +ath9k-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += mci.o ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o ath9k-$(CONFIG_ATH9K_PCI) += pci.o ath9k-$(CONFIG_ATH9K_AHB) += ahb.o diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 23145ce9ea3f..c2ccba676eca 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -454,6 +454,7 @@ struct ath_btcoex { struct ath_mci_profile mci; }; +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT int ath9k_init_btcoex(struct ath_softc *sc); void ath9k_deinit_btcoex(struct ath_softc *sc); void ath9k_start_btcoex(struct ath_softc *sc); @@ -462,6 +463,30 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc); void ath9k_btcoex_timer_pause(struct ath_softc *sc); void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status); u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen); +#else +static inline int ath9k_init_btcoex(struct ath_softc *sc) +{ + return 0; +} +static inline void ath9k_deinit_btcoex(struct ath_softc *sc) +{ +} +static inline void ath9k_start_btcoex(struct ath_softc *sc) +{ +} +static inline void ath9k_stop_btcoex(struct ath_softc *sc) +{ +} +static inline void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, + u32 status) +{ +} +static inline u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, + u32 max_4ms_framelen) +{ + return 0; +} +#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ /********************/ /* LED Control */ @@ -655,8 +680,11 @@ struct ath_softc { struct ath_beacon_config cur_beacon_conf; struct delayed_work tx_complete_work; struct delayed_work hw_pll_work; + +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT struct ath_btcoex btcoex; struct ath_mci_coex mci_coex; +#endif struct ath_descdma txsdma; diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index e870251cdd1b..77b3eb7b7a33 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -110,6 +110,8 @@ void ath_start_rfkill_poll(struct ath_softc *sc) wiphy_rfkill_start_polling(sc->hw->wiphy); } +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT + /******************/ /* BTCOEX */ /******************/ @@ -423,3 +425,5 @@ int ath9k_init_btcoex(struct ath_softc *sc) return 0; } + +#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ -- GitLab From d68475de9637a476ad8e5870060ccc69a80f2299 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:49 +0530 Subject: [PATCH 1156/1846] ath9k: Initialize BTCOEX scheme using a helper Setting up the required scheme can be done as part of the BTCOEX initialization path and it doesn't belong in ath9k_hw_fill_cap_info() anyway. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/btcoex.c | 34 +++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/btcoex.h | 1 + drivers/net/wireless/ath/ath9k/gpio.c | 2 ++ drivers/net/wireless/ath/ath9k/hw.c | 25 ------------------ 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c index 6566952b08cc..536595952cd2 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.c +++ b/drivers/net/wireless/ath/ath9k/btcoex.c @@ -98,6 +98,40 @@ void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum) } EXPORT_SYMBOL(ath9k_hw_init_btcoex_hw); +void ath9k_hw_btcoex_init_scheme(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; + + /* + * Check if BTCOEX is globally disabled. + */ + if (!common->btcoex_enabled) { + btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE; + return; + } + + 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; + btcoex_hw->btpriority_gpio = ATH_BTPRIORITY_GPIO_9300; + } else if (AR_SREV_9280_20_OR_LATER(ah)) { + btcoex_hw->btactive_gpio = ATH_BTACTIVE_GPIO_9280; + btcoex_hw->wlanactive_gpio = ATH_WLANACTIVE_GPIO_9280; + + if (AR_SREV_9285(ah)) { + btcoex_hw->scheme = ATH_BTCOEX_CFG_3WIRE; + btcoex_hw->btpriority_gpio = ATH_BTPRIORITY_GPIO_9285; + } else { + btcoex_hw->scheme = ATH_BTCOEX_CFG_2WIRE; + } + } +} +EXPORT_SYMBOL(ath9k_hw_btcoex_init_scheme); + void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah) { struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h index 0cb15cd85e92..10627b46ec34 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.h +++ b/drivers/net/wireless/ath/ath9k/btcoex.h @@ -97,6 +97,7 @@ struct ath_btcoex_hw { u32 wlan_weight[AR9300_NUM_WLAN_WEIGHTS]; }; +void ath9k_hw_btcoex_init_scheme(struct ath_hw *ah); void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah); void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah); void ath9k_hw_btcoex_init_mci(struct ath_hw *ah); diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 77b3eb7b7a33..4da486bccfa4 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -391,6 +391,8 @@ int ath9k_init_btcoex(struct ath_softc *sc) struct ath_hw *ah = sc->sc_ah; int r; + ath9k_hw_btcoex_init_scheme(ah); + switch (ath9k_hw_get_btcoex_scheme(sc->sc_ah)) { case ATH_BTCOEX_CFG_NONE: break; diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index cb46d41f2288..f4b121f33132 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2303,7 +2303,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) struct ath9k_hw_capabilities *pCap = &ah->caps; struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); struct ath_common *common = ath9k_hw_common(ah); - struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; unsigned int chip_chainmask; u16 eeval; @@ -2422,30 +2421,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) else pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS; - if (common->btcoex_enabled) { - 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; - btcoex_hw->btpriority_gpio = ATH_BTPRIORITY_GPIO_9300; - } else if (AR_SREV_9280_20_OR_LATER(ah)) { - btcoex_hw->btactive_gpio = ATH_BTACTIVE_GPIO_9280; - btcoex_hw->wlanactive_gpio = ATH_WLANACTIVE_GPIO_9280; - - if (AR_SREV_9285(ah)) { - btcoex_hw->scheme = ATH_BTCOEX_CFG_3WIRE; - btcoex_hw->btpriority_gpio = - ATH_BTPRIORITY_GPIO_9285; - } else { - btcoex_hw->scheme = ATH_BTCOEX_CFG_2WIRE; - } - } - } else { - btcoex_hw->scheme = ATH_BTCOEX_CFG_NONE; - } - if (AR_SREV_9300_20_OR_LATER(ah)) { pCap->hw_caps |= ATH9K_HW_CAP_EDMA | ATH9K_HW_CAP_FASTCLOCK; if (!AR_SREV_9330(ah) && !AR_SREV_9485(ah)) -- GitLab From 5a1e273573d5e4a32aaa82a98a89b3fd711c74f0 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:40:55 +0530 Subject: [PATCH 1157/1846] ath9k_hw: Use a helper function to get MCI ISR Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 29 ++------------------- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 25 ++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 1 + 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 39cb4829f292..575f36a296f4 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -180,7 +180,6 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) u32 mask2 = 0; struct ath9k_hw_capabilities *pCap = &ah->caps; struct ath_common *common = ath9k_hw_common(ah); - struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; u32 sync_cause = 0, async_cause; async_cause = REG_READ(ah, AR_INTR_ASYNC_CAUSE); @@ -302,32 +301,8 @@ 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, 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, MCI, "AR_INTR_SYNC_MCI\n"); - - } - } + if (async_cause & AR_INTR_ASYNC_MASK_MCI) + ar9003_mci_get_isr(ah, masked); if (sync_cause) { if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) { diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 2cd607f9705e..1a01788ec103 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -412,6 +412,31 @@ void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, } EXPORT_SYMBOL(ar9003_mci_get_interrupt); +void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.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, MCI, + "MCI gets 0xdeadbeef during int processing\n"); + } 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); + } +} + void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g) { struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 6a29004a71b0..ebc32d00fecc 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1231,6 +1231,7 @@ 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); +void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT static inline enum ath_btcoex_scheme -- GitLab From d1ca8b8ecd18d99cf3ae0c2a9b81d3a22b4141c1 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:01 +0530 Subject: [PATCH 1158/1846] ath9k_hw: Handle MCI power state using a helper Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 17 +++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.c | 17 ++--------------- drivers/net/wireless/ath/ath9k/hw.h | 1 + 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 1a01788ec103..a87d4ca1b547 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -365,6 +365,23 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) REG_WRITE(ah, AR_MCI_INTERRUPT_EN, saved_mci_int_en); } +void ar9003_mci_set_full_sleep(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + + if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) && + (mci->bt_state != MCI_BT_SLEEP) && + !mci->halted_bt_gpm) { + ath_dbg(common, MCI, + "MCI halt BT GPM (full_sleep)\n"); + ar9003_mci_send_coex_halt_bt_gpm(ah, true, true); + } + + mci->ready = false; + REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); +} + void ar9003_mci_disable_interrupt(struct ath_hw *ah) { if (!ATH9K_HW_CAP_MCI) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index f4b121f33132..406ffd06b6db 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2076,7 +2076,6 @@ 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", @@ -2100,20 +2099,8 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode) 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, MCI, - "MCI halt BT GPM (full_sleep)\n"); - ar9003_mci_send_coex_halt_bt_gpm(ah, - true, true); - } - - mci->ready = false; - REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); - } + if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) + ar9003_mci_set_full_sleep(ah); ath9k_set_power_sleep(ah, setChip); ah->chip_fullsleep = true; diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index ebc32d00fecc..07dd53e059fb 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1219,6 +1219,7 @@ void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, 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_set_full_sleep(struct ath_hw *ah); 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); -- GitLab From f2f408eff7eb10a834859457b2ced5d3255d0cd3 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:06 +0530 Subject: [PATCH 1159/1846] ath9k_hw: Setup MCI calibration using a helper Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 42 ++-------------- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 48 +++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 2 + 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c index 8e70f0bc073e..63089cc1fafd 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c @@ -925,7 +925,6 @@ 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; @@ -998,30 +997,8 @@ 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, 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, MCI, "MCI wait for BT_CAL_GRANT\n"); - - if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_GRANT, 0, 50000)) - ath_dbg(common, MCI, "MCI got BT_CAL_GRANT\n"); - else { - is_reusable = false; - ath_dbg(common, MCI, "\nMCI BT is not responding\n"); - } - } + if (mci && IS_CHAN_2GHZ(chan) && run_agc_cal) + ar9003_mci_init_cal_req(ah, &is_reusable); txiqcal_done = ar9003_hw_tx_iq_cal_run(ah); REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS); @@ -1041,19 +1018,8 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah, 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, 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 (mci && IS_CHAN_2GHZ(chan) && run_agc_cal) + ar9003_mci_init_cal_done(ah); if (rtt && !run_rtt_cal) { agc_ctrl |= agc_supp_cals; diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index a87d4ca1b547..65db2cd44c9a 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -1011,6 +1011,54 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, } EXPORT_SYMBOL(ar9003_mci_send_message); +void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; + u32 pld[4] = {0, 0, 0, 0}; + + if ((mci_hw->bt_state != MCI_BT_AWAKE) || + (mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL)) + return; + + /* send CAL_REQ only when BT is AWAKE. */ + ath_dbg(common, 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, MCI, "MCI wait for BT_CAL_GRANT\n"); + + if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_GRANT, 0, 50000)) { + ath_dbg(common, MCI, "MCI got BT_CAL_GRANT\n"); + } else { + is_reusable = false; + ath_dbg(common, MCI, "MCI BT is not responding\n"); + } +} + +void ar9003_mci_init_cal_done(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; + u32 pld[4] = {0, 0, 0, 0}; + + if ((mci_hw->bt_state != MCI_BT_AWAKE) || + (mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL)) + return; + + ath_dbg(common, 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); +} + void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf, u16 len, u32 sched_addr) { diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 07dd53e059fb..ff752546354f 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1211,6 +1211,8 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, 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_init_cal_req(struct ath_hw *ah, bool *is_reusable); +void ar9003_mci_init_cal_done(struct ath_hw *ah); 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); -- GitLab From 528e5d3605a589632bb6660aa1ea90729f8ca776 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:12 +0530 Subject: [PATCH 1160/1846] ath9k_hw: Cleanup MCI bits from ath9k_hw_reset() This patch moves all the MCI-specific code in the main reset function to helper functions. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 142 ++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.c | 129 ++---------------- drivers/net/wireless/ath/ath9k/hw.h | 10 ++ 3 files changed, 163 insertions(+), 118 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 65db2cd44c9a..597e707a0c73 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -16,6 +16,7 @@ #include #include "hw.h" +#include "hw-ops.h" #include "ar9003_phy.h" #include "ar9003_mci.h" @@ -567,6 +568,131 @@ static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done, wait_done, true); } +void ar9003_mci_check_bt(struct ath_hw *ah) +{ + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; + + if (!mci_hw->ready) + return; + + /* + * 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; + } +} + +bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; + u32 payload[4] = {0, 0, 0, 0}; + + ar9003_mci_2g5g_changed(ah, IS_CHAN_2GHZ(chan)); + + if (mci_hw->bt_state != MCI_BT_CAL_START) + return false; + + ath_dbg(common, MCI, "MCI stop rx for BT CAL\n"); + + 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, MCI, "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, true, false); + + ath_dbg(common, MCI, "\nMCI BT is calibrating\n"); + + /* 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, MCI, + "MCI got BT_CAL_DONE\n"); + else + ath_dbg(common, 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; +} + +int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, + struct ath9k_hw_cal_data *caldata) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; + + if (!mci_hw->ready) + return 0; + + if (!IS_CHAN_2GHZ(chan) || (mci_hw->bt_state != MCI_BT_SLEEP)) + goto exit; + + 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, 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, 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, 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; + + } +exit: + ar9003_mci_enable_interrupt(ah); + return 0; +} + void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, bool is_full_sleep) { @@ -696,6 +822,22 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, ar9003_mci_enable_interrupt(ah); } +void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep) +{ + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.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; +} + void ar9003_mci_mute_bt(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 406ffd06b6db..475e4caee776 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1518,61 +1518,22 @@ 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; u32 macStaId1; u64 tsf = 0; int i, r; - bool allow_fbs = false; + bool allow_fbs = false, start_mci_reset = 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, MCI, "MCI stop rx for BT CAL\n"); - - 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, MCI, "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, true, false); - - ath_dbg(common, MCI, "\nMCI BT is calibrating\n"); - - /* 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, MCI, - "MCI got BT_CAL_DONE\n"); - else - ath_dbg(common, 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; - } + start_mci_reset = ar9003_mci_start_reset(ah, chan); + if (start_mci_reset) + return 0; } - if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) return -EIO; @@ -1609,7 +1570,7 @@ 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) + if (mci && ar9003_mci_is_ready(ah)) ar9003_mci_2g5g_switch(ah, true); if (AR_SREV_9271(ah)) @@ -1618,19 +1579,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, } } - 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; - } - + if (mci) + ar9003_mci_stop_bt(ah, save_fullsleep); saveDefAntenna = REG_READ(ah, AR_DEF_ANTENNA); if (saveDefAntenna == 0) @@ -1807,53 +1757,8 @@ 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, 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, 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, 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); - } + if (mci && ar9003_mci_end_reset(ah, chan, caldata)) + return -EIO; ENABLE_REGWRITE_BUFFER(ah); @@ -1898,20 +1803,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) 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 (mci) + ar9003_mci_check_bt(ah); if (AR_SREV_9300_20_OR_LATER(ah)) { ar9003_hw_bb_watchdog_config(ah); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index ff752546354f..0d108dc25c57 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1209,6 +1209,7 @@ 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_stop_bt(struct ath_hw *ah, bool sava_fullsleep); 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_init_cal_req(struct ath_hw *ah, bool *is_reusable); @@ -1225,6 +1226,10 @@ void ar9003_mci_set_full_sleep(struct ath_hw *ah); 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_check_bt(struct ath_hw *ah); +bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan); +int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, + struct ath9k_hw_cal_data *caldata); 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); @@ -1236,6 +1241,11 @@ void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, u32 *rx_msg_intr); void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); +static inline bool ar9003_mci_is_ready(struct ath_hw *ah) +{ + return ah->btcoex_hw.mci.ready; +} + #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT static inline enum ath_btcoex_scheme ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) -- GitLab From f4701b5a0dc3e047d4a9e11cd70d8839893bad17 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:18 +0530 Subject: [PATCH 1161/1846] ath9k_hw: Cleanup MCI bits from hw.h This patch moves all the MCI-specific declarations that have been dumped unceremoniously in hw.h to ar9003_mci.h Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 1 + drivers/net/wireless/ath/ath9k/ar9003_mci.h | 195 ++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.c | 1 + drivers/net/wireless/ath/ath9k/hw.h | 195 -------------------- drivers/net/wireless/ath/ath9k/mci.h | 2 + 5 files changed, 199 insertions(+), 195 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 575f36a296f4..51687e3f63d8 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -16,6 +16,7 @@ #include #include "hw.h" #include "ar9003_mac.h" +#include "ar9003_mci.h" static void ar9003_hw_rx_enable(struct ath_hw *hw) { diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.h b/drivers/net/wireless/ath/ath9k/ar9003_mci.h index 798da116a44c..39bbf67078db 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.h @@ -99,4 +99,199 @@ enum mci_gpm_coex_bt_update_flags_op { ATH_MCI_CONFIG_MCI_OBS_BT) #define ATH_MCI_CONFIG_MCI_OBS_GPIO 0x0000002F +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, + MCI_GPM_COEX_PROFILE_A2DP, + MCI_GPM_COEX_PROFILE_HID, + MCI_GPM_COEX_PROFILE_BNEP, + MCI_GPM_COEX_PROFILE_VOICE, + 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) + +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_stop_bt(struct ath_hw *ah, bool sava_fullsleep); +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_init_cal_req(struct ath_hw *ah, bool *is_reusable); +void ar9003_mci_init_cal_done(struct ath_hw *ah); +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_set_full_sleep(struct ath_hw *ah); +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_check_bt(struct ath_hw *ah); +bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan); +int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, + struct ath9k_hw_cal_data *caldata); +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); +void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); + +static inline bool ar9003_mci_is_ready(struct ath_hw *ah) +{ + return ah->btcoex_hw.mci.ready; +} + #endif diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 475e4caee776..5f2e30ca8eff 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -23,6 +23,7 @@ #include "hw-ops.h" #include "rc.h" #include "ar9003_mac.h" +#include "ar9003_mci.h" static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 0d108dc25c57..96494a612650 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -432,161 +432,6 @@ 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, - MCI_GPM_COEX_PROFILE_A2DP, - MCI_GPM_COEX_PROFILE_HID, - MCI_GPM_COEX_PROFILE_BNEP, - MCI_GPM_COEX_PROFILE_VOICE, - 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; @@ -1206,46 +1051,6 @@ 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_stop_bt(struct ath_hw *ah, bool sava_fullsleep); -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_init_cal_req(struct ath_hw *ah, bool *is_reusable); -void ar9003_mci_init_cal_done(struct ath_hw *ah); -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_set_full_sleep(struct ath_hw *ah); -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_check_bt(struct ath_hw *ah); -bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan); -int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, - struct ath9k_hw_cal_data *caldata); -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); -void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); - -static inline bool ar9003_mci_is_ready(struct ath_hw *ah) -{ - return ah->btcoex_hw.mci.ready; -} - #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT static inline enum ath_btcoex_scheme ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index b805bf24ea4c..c841444f53c2 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -17,6 +17,8 @@ #ifndef MCI_H #define MCI_H +#include "ar9003_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) -- GitLab From a3f846f12ce75c62bde4b6a1332416520c4fc00a Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:24 +0530 Subject: [PATCH 1162/1846] ath9k_hw: Cleanup MCI function declarations This patch converts a few functions to static variants and removes extraneous declarations. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 508 ++++++++++---------- drivers/net/wireless/ath/ath9k/ar9003_mci.h | 13 - 2 files changed, 254 insertions(+), 267 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 597e707a0c73..b9652f6e5a4f 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -82,7 +82,7 @@ static int ar9003_mci_wait_for_interrupt(struct ath_hw *ah, u32 address, return time_out; } -void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done) +static void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done) { u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00}; @@ -94,7 +94,7 @@ void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done) udelay(5); } -void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done) +static void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done) { u32 payload = 0x00000000; @@ -112,7 +112,7 @@ static void ar9003_mci_send_req_wake(struct ath_hw *ah, bool wait_done) udelay(5); } -void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done) +static void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done) { if (!ATH9K_HW_CAP_MCI) return; @@ -223,8 +223,8 @@ static void ar9003_mci_send_coex_bt_status_query(struct ath_hw *ah, } } -void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, - bool wait_done) +static 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; @@ -383,7 +383,7 @@ void ar9003_mci_set_full_sleep(struct ath_hw *ah) REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); } -void ar9003_mci_disable_interrupt(struct ath_hw *ah) +static void ar9003_mci_disable_interrupt(struct ath_hw *ah) { if (!ATH9K_HW_CAP_MCI) return; @@ -392,7 +392,7 @@ void ar9003_mci_disable_interrupt(struct ath_hw *ah) REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0); } -void ar9003_mci_enable_interrupt(struct ath_hw *ah) +static void ar9003_mci_enable_interrupt(struct ath_hw *ah) { if (!ATH9K_HW_CAP_MCI) return; @@ -402,7 +402,7 @@ void ar9003_mci_enable_interrupt(struct ath_hw *ah) AR_MCI_INTERRUPT_RX_MSG_DEFAULT); } -bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints) +static bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints) { u32 intr; @@ -455,7 +455,7 @@ void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked) } } -void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g) +static void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g) { struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; @@ -568,6 +568,36 @@ static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done, wait_done, true); } +static 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; + + if (!ATH9K_HW_CAP_MCI) + return; + + cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL); + + if (mci->bt_state != cur_bt_state) { + ath_dbg(common, 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, MCI, "MCI unhalt BT GPM\n"); + ar9003_mci_send_coex_halt_bt_gpm(ah, false, true); + } + } +} + void ar9003_mci_check_bt(struct ath_hw *ah) { struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; @@ -588,6 +618,188 @@ void ar9003_mci_check_bt(struct ath_hw *ah) } } +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, 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, 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, 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, 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, MCI, "MCI Recv GPM COEX BT_Profile_Info\n"); + break; + case MCI_GPM_COEX_BT_STATUS_UPDATE: + mci->query_bt = true; + ath_dbg(common, MCI, + "MCI Recv GPM COEX BT_Status_Update SEQ=%d (drop&query)\n", + *(p_gpm + 3)); + break; + default: + break; + } +} + +static 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); + + if (!ATH9K_HW_CAP_MCI) + return 0; + + 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, 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, 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, MCI, "MCI now wait for BT_CAL_DONE\n"); + + continue; + } else { + ath_dbg(common, 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, MCI, + "MCI GPM received timeout, mismatch = %d\n", mismatch); + } else + ath_dbg(common, MCI, "MCI Receive GPM type=0x%x, code=0x%x\n", + gpm_type, gpm_opcode); + + while (more_data == MCI_GPM_MORE) { + + ath_dbg(common, 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; +} + bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) { struct ath_common *common = ath9k_hw_common(ah); @@ -693,6 +905,39 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, return 0; } +static void ar9003_mci_mute_bt(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + + if (!ATH9K_HW_CAP_MCI) + return; + + /* 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, MCI, "MCI Send LNA take\n"); + ar9003_mci_send_lna_take(ah, true); + + udelay(5); + + ath_dbg(common, MCI, "MCI Send sys sleeping\n"); + ar9003_mci_send_sys_sleeping(ah, true); +} + void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, bool is_full_sleep) { @@ -838,69 +1083,6 @@ void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep) mci_hw->ready = false; } -void ar9003_mci_mute_bt(struct ath_hw *ah) -{ - struct ath_common *common = ath9k_hw_common(ah); - - if (!ATH9K_HW_CAP_MCI) - return; - - /* 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, MCI, "MCI Send LNA take\n"); - ar9003_mci_send_lna_take(ah, true); - - udelay(5); - - ath_dbg(common, 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; - - if (!ATH9K_HW_CAP_MCI) - return; - - cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL); - - if (mci->bt_state != cur_bt_state) { - ath_dbg(common, 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, MCI, "MCI unhalt BT GPM\n"); - 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); @@ -1229,188 +1411,6 @@ void ar9003_mci_cleanup(struct ath_hw *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, 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, 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, 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, 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, MCI, "MCI Recv GPM COEX BT_Profile_Info\n"); - break; - case MCI_GPM_COEX_BT_STATUS_UPDATE: - mci->query_bt = true; - ath_dbg(common, 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); - - if (!ATH9K_HW_CAP_MCI) - return 0; - - 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, 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, 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, MCI, "MCI now wait for BT_CAL_DONE\n"); - - continue; - } else { - ath_dbg(common, 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, MCI, - "MCI GPM received timeout, mismatch = %d\n", mismatch); - } else - ath_dbg(common, MCI, "MCI Receive GPM type=0x%x, code=0x%x\n", - gpm_type, gpm_opcode); - - while (more_data == MCI_GPM_MORE) { - - ath_dbg(common, 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); diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.h b/drivers/net/wireless/ath/ath9k/ar9003_mci.h index 39bbf67078db..507527b9f5ab 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.h @@ -258,21 +258,13 @@ 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_stop_bt(struct ath_hw *ah, bool sava_fullsleep); -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_init_cal_req(struct ath_hw *ah, bool *is_reusable); void ar9003_mci_init_cal_done(struct ath_hw *ah); 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_set_full_sleep(struct ath_hw *ah); -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_check_bt(struct ath_hw *ah); bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan); @@ -280,11 +272,6 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata); 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); void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); -- GitLab From dbccdd1d320e8454e25750ba6adec3b0d0688fe8 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 17:55:47 +0530 Subject: [PATCH 1163/1846] ath9k_hw: Use CONFIG_ATH9K_BTCOEX_SUPPORT Make use of CONFIG_ATH9K_BTCOEX_SUPPORT in ath9k_hw to provide a clean way of compilation without BTCOEX support. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/Makefile | 6 +- drivers/net/wireless/ath/ath9k/ar9003_mci.h | 63 +++++++++++++++++++-- drivers/net/wireless/ath/ath9k/btcoex.h | 1 - drivers/net/wireless/ath/ath9k/hw.c | 3 +- drivers/net/wireless/ath/ath9k/hw.h | 21 ++++++- 5 files changed, 80 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile index b3c7b12a3e2c..27d95fe5ade0 100644 --- a/drivers/net/wireless/ath/ath9k/Makefile +++ b/drivers/net/wireless/ath/ath9k/Makefile @@ -31,14 +31,14 @@ ath9k_hw-y:= \ eeprom_4k.o \ eeprom_9287.o \ ani.o \ - btcoex.o \ mac.o \ ar9002_mac.o \ ar9003_mac.o \ ar9003_eeprom.o \ - ar9003_paprd.o \ - ar9003_mci.o + ar9003_paprd.o +ath9k_hw-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \ + ar9003_mci.o obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.h b/drivers/net/wireless/ath/ath9k/ar9003_mci.h index 507527b9f5ab..4842f6c06b8c 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.h @@ -254,16 +254,32 @@ enum mci_gpm_coex_opcode { #define MCI_GPM_IS_CAL_TYPE(_type) ((_type) <= MCI_GPM_WLAN_CAL_DONE) +/* + * Functions that are available to the MCI driver core. + */ 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_stop_bt(struct ath_hw *ah, bool sava_fullsleep); u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data); -void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable); -void ar9003_mci_init_cal_done(struct ath_hw *ah); 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_get_interrupt(struct ath_hw *ah, u32 *raw_intr, + u32 *rx_msg_intr); + +/* + * These functions are used by ath9k_hw. + */ + +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT + +static inline bool ar9003_mci_is_ready(struct ath_hw *ah) +{ + return ah->btcoex_hw.mci.ready; +} +void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep); +void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable); +void ar9003_mci_init_cal_done(struct ath_hw *ah); void ar9003_mci_set_full_sleep(struct ath_hw *ah); void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done); void ar9003_mci_check_bt(struct ath_hw *ah); @@ -272,13 +288,48 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata); void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, bool is_full_sleep); -void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, - u32 *rx_msg_intr); void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); +#else + static inline bool ar9003_mci_is_ready(struct ath_hw *ah) { - return ah->btcoex_hw.mci.ready; + return false; +} +static inline void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep) +{ +} +static inline void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable) +{ +} +static inline void ar9003_mci_init_cal_done(struct ath_hw *ah) +{ +} +static inline void ar9003_mci_set_full_sleep(struct ath_hw *ah) +{ +} +static inline void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done) +{ +} +static inline void ar9003_mci_check_bt(struct ath_hw *ah) +{ +} +static inline bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) +{ + return false; +} +static inline int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, + struct ath9k_hw_cal_data *caldata) +{ + return 0; +} +static inline void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, + bool is_full_sleep) +{ +} +static inline void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked) +{ } +#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ #endif diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h index 10627b46ec34..8f93aef4414f 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.h +++ b/drivers/net/wireless/ath/ath9k/btcoex.h @@ -105,7 +105,6 @@ void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum); void ath9k_hw_btcoex_set_weight(struct ath_hw *ah, u32 bt_weight, u32 wlan_weight); -void ath9k_hw_btcoex_enable(struct ath_hw *ah); void ath9k_hw_btcoex_disable(struct ath_hw *ah); void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah, enum ath_stomp_type stomp_type); diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 5f2e30ca8eff..8c840cad3ac2 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1800,8 +1800,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, #endif } - if (ah->btcoex_hw.enabled && - ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) + if (ath9k_hw_btcoex_is_enabled(ah)) ath9k_hw_btcoex_enable(ah); if (mci) diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 96494a612650..29b65adade60 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -802,8 +802,9 @@ struct ath_hw { int firpwr[5]; enum ath9k_ani_cmd ani_function; - /* Bluetooth coexistance */ +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT struct ath_btcoex_hw btcoex_hw; +#endif u32 intr_txqs; u8 txchainmask; @@ -1052,13 +1053,29 @@ void ath9k_hw_proc_mib_event(struct ath_hw *ah); void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan); #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT +static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah) +{ + return ah->btcoex_hw.enabled; +} +void ath9k_hw_btcoex_enable(struct ath_hw *ah); static inline enum ath_btcoex_scheme ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) { return ah->btcoex_hw.scheme; } #else -#define ath9k_hw_get_btcoex_scheme(...) ATH_BTCOEX_CFG_NONE +static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah) +{ + return false; +} +static inline void ath9k_hw_btcoex_enable(struct ath_hw *ah) +{ +} +static inline enum ath_btcoex_scheme +ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) +{ + return ATH_BTCOEX_CFG_NONE; +} #endif #define ATH9K_CLOCK_RATE_CCK 22 -- GitLab From bf047fcdaca3481fd6ce7d54011d2a774b8b7900 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:36 +0530 Subject: [PATCH 1164/1846] ath9k_htc: Start/stop btcoex using a helper Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/htc.h | 2 ++ drivers/net/wireless/ath/ath9k/htc_drv_gpio.c | 24 +++++++++++++++++++ drivers/net/wireless/ath/ath9k/htc_drv_main.c | 15 +++--------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h index da5596766d82..71e877eb6ddf 100644 --- a/drivers/net/wireless/ath/ath9k/htc.h +++ b/drivers/net/wireless/ath/ath9k/htc.h @@ -400,6 +400,8 @@ struct ath_btcoex { u32 btscan_no_stomp; }; +void ath9k_htc_start_btcoex(struct ath9k_htc_priv *priv); +void ath9k_htc_stop_btcoex(struct ath9k_htc_priv *priv); void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv); void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv); void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv); diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c index 6506e1fd5036..82f02f769b51 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c @@ -160,6 +160,30 @@ void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv) cancel_delayed_work_sync(&priv->duty_cycle_work); } +void ath9k_htc_start_btcoex(struct ath9k_htc_priv *priv) +{ + struct ath_hw *ah = priv->ah; + + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) { + ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, + AR_STOMP_LOW_WLAN_WGHT); + ath9k_hw_btcoex_enable(ah); + ath_htc_resume_btcoex_work(priv); + } +} + +void ath9k_htc_stop_btcoex(struct ath9k_htc_priv *priv) +{ + struct ath_hw *ah = priv->ah; + + if (ah->btcoex_hw.enabled && + ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) { + ath9k_hw_btcoex_disable(ah); + if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) + ath_htc_cancel_btcoex_work(priv); + } +} + /*******/ /* LED */ /*******/ diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c index 06101b6bdeac..2a29a7cdef18 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c @@ -957,12 +957,8 @@ static int ath9k_htc_start(struct ieee80211_hw *hw) mod_timer(&priv->tx.cleanup_timer, jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL)); - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) { - ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, - AR_STOMP_LOW_WLAN_WGHT); - ath9k_hw_btcoex_enable(ah); - ath_htc_resume_btcoex_work(priv); - } + ath9k_htc_start_btcoex(priv); + mutex_unlock(&priv->mutex); return ret; @@ -1009,12 +1005,7 @@ static void ath9k_htc_stop(struct ieee80211_hw *hw) mutex_lock(&priv->mutex); - if (ah->btcoex_hw.enabled && - ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) { - ath9k_hw_btcoex_disable(ah); - if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) - ath_htc_cancel_btcoex_work(priv); - } + ath9k_htc_stop_btcoex(priv); /* Remove a monitor interface if it's present. */ if (priv->ah->is_monitoring) -- GitLab From cee5341d47fcd1cb79bbb71e430f502285fef8db Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:41 +0530 Subject: [PATCH 1165/1846] ath9k_htc: Init BTCOEX inside htc_drv_gpio.c Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/htc.h | 1 + drivers/net/wireless/ath/ath9k/htc_drv_gpio.c | 32 +++++++++++++++++++ drivers/net/wireless/ath/ath9k/htc_drv_init.c | 32 +------------------ 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h index 71e877eb6ddf..8046be66fa87 100644 --- a/drivers/net/wireless/ath/ath9k/htc.h +++ b/drivers/net/wireless/ath/ath9k/htc.h @@ -400,6 +400,7 @@ struct ath_btcoex { u32 btscan_no_stomp; }; +void ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product); void ath9k_htc_start_btcoex(struct ath9k_htc_priv *priv); void ath9k_htc_stop_btcoex(struct ath9k_htc_priv *priv); void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv); diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c index 82f02f769b51..2c61d363b001 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c @@ -20,6 +20,8 @@ /* BTCOEX */ /******************/ +#define ATH_HTC_BTCOEX_PRODUCT_ID "wb193" + /* * Detects if there is any priority bt traffic */ @@ -184,6 +186,36 @@ void ath9k_htc_stop_btcoex(struct ath9k_htc_priv *priv) } } +void ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product) +{ + struct ath_hw *ah = priv->ah; + int qnum; + + if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) { + ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE; + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) + return; + } + + switch (ath9k_hw_get_btcoex_scheme(priv->ah)) { + case ATH_BTCOEX_CFG_NONE: + break; + case ATH_BTCOEX_CFG_3WIRE: + priv->ah->btcoex_hw.btactive_gpio = 7; + priv->ah->btcoex_hw.btpriority_gpio = 6; + priv->ah->btcoex_hw.wlanactive_gpio = 8; + priv->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; + ath9k_hw_btcoex_init_3wire(priv->ah); + ath_htc_init_btcoex_work(priv); + qnum = priv->hwq_map[WME_AC_BE]; + ath9k_hw_init_btcoex_hw(priv->ah, qnum); + break; + default: + WARN_ON(1); + break; + } +} + /*******/ /* LED */ /*******/ diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index fc7519c93390..de5ee15ee639 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -41,8 +41,6 @@ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); .max_power = 20, \ } -#define ATH_HTC_BTCOEX_PRODUCT_ID "wb193" - static struct ieee80211_channel ath9k_2ghz_channels[] = { CHAN2G(2412, 0), /* Channel 1 */ CHAN2G(2417, 1), /* Channel 2 */ @@ -603,29 +601,6 @@ static void ath9k_init_misc(struct ath9k_htc_priv *priv) priv->ah->opmode = NL80211_IFTYPE_STATION; } -static void ath9k_init_btcoex(struct ath9k_htc_priv *priv) -{ - int qnum; - - switch (ath9k_hw_get_btcoex_scheme(priv->ah)) { - case ATH_BTCOEX_CFG_NONE: - break; - case ATH_BTCOEX_CFG_3WIRE: - priv->ah->btcoex_hw.btactive_gpio = 7; - priv->ah->btcoex_hw.btpriority_gpio = 6; - priv->ah->btcoex_hw.wlanactive_gpio = 8; - priv->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; - ath9k_hw_btcoex_init_3wire(priv->ah); - ath_htc_init_btcoex_work(priv); - qnum = priv->hwq_map[WME_AC_BE]; - ath9k_hw_init_btcoex_hw(priv->ah, qnum); - break; - default: - WARN_ON(1); - break; - } -} - static int ath9k_init_priv(struct ath9k_htc_priv *priv, u16 devid, char *product, u32 drv_info) @@ -698,12 +673,7 @@ static int ath9k_init_priv(struct ath9k_htc_priv *priv, ath9k_cmn_init_crypto(ah); ath9k_init_channels_rates(priv); ath9k_init_misc(priv); - - if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) { - ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE; - if (ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) - ath9k_init_btcoex(priv); - } + ath9k_htc_init_btcoex(priv, product); return 0; -- GitLab From 9d5b80fd36dd524d01a7819586b1d95312c0922f Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:47 +0530 Subject: [PATCH 1166/1846] ath9k_htc: Use CONFIG_ATH9K_BTCOEX_SUPPORT ath9k_htc can also make use of CONFIG_ATH9K_BTCOEX_SUPPORT to be compiled without BTCOEX support. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/htc.h | 18 +++++++++++++++--- drivers/net/wireless/ath/ath9k/htc_drv_gpio.c | 10 +++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h index 8046be66fa87..135795257d95 100644 --- a/drivers/net/wireless/ath/ath9k/htc.h +++ b/drivers/net/wireless/ath/ath9k/htc.h @@ -400,12 +400,21 @@ struct ath_btcoex { u32 btscan_no_stomp; }; +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT void ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product); void ath9k_htc_start_btcoex(struct ath9k_htc_priv *priv); void ath9k_htc_stop_btcoex(struct ath9k_htc_priv *priv); -void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv); -void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv); -void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv); +#else +static inline void ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product) +{ +} +static inline void ath9k_htc_start_btcoex(struct ath9k_htc_priv *priv) +{ +} +static inline void ath9k_htc_stop_btcoex(struct ath9k_htc_priv *priv) +{ +} +#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ #define OP_INVALID BIT(0) #define OP_SCANNING BIT(1) @@ -486,7 +495,10 @@ struct ath9k_htc_priv { int cabq; int hwq_map[WME_NUM_AC]; +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT struct ath_btcoex btcoex; +#endif + struct delayed_work coex_period_work; struct delayed_work duty_cycle_work; #ifdef CONFIG_ATH9K_HTC_DEBUGFS diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c index 2c61d363b001..6aa76745e020 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c @@ -22,6 +22,8 @@ #define ATH_HTC_BTCOEX_PRODUCT_ID "wb193" +#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT + /* * Detects if there is any priority bt traffic */ @@ -113,7 +115,7 @@ static void ath_btcoex_duty_cycle_work(struct work_struct *work) ath9k_hw_btcoex_enable(priv->ah); } -void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv) +static void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv) { struct ath_btcoex *btcoex = &priv->btcoex; @@ -133,7 +135,7 @@ void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv) * (Re)start btcoex work */ -void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv) +static void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv) { struct ath_btcoex *btcoex = &priv->btcoex; struct ath_hw *ah = priv->ah; @@ -153,7 +155,7 @@ void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv) /* * Cancel btcoex and bt duty cycle work. */ -void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv) +static void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv) { if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE) return; @@ -216,6 +218,8 @@ void ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product) } } +#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ + /*******/ /* LED */ /*******/ -- GitLab From 64ab38df6e8ac8e56f38c49d26578fae2fb808f8 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:52 +0530 Subject: [PATCH 1167/1846] ath9k: Remove ATH_BTCOEX_CFG_NONE checks Since BTCOEX code can be compiled out cleanly now, remove these checks. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/btcoex.c | 21 ------------------- drivers/net/wireless/ath/ath9k/gpio.c | 9 -------- drivers/net/wireless/ath/ath9k/htc_drv_gpio.c | 11 ---------- drivers/net/wireless/ath/ath9k/hw.h | 2 +- 4 files changed, 1 insertion(+), 42 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c index 536595952cd2..ec3271993411 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.c +++ b/drivers/net/wireless/ath/ath9k/btcoex.c @@ -68,9 +68,6 @@ void ath9k_hw_init_btcoex_hw(struct ath_hw *ah, int qnum) u32 i, idx; bool rxclear_polarity = ath_bt_config.bt_rxclear_polarity; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - if (AR_SREV_9300_20_OR_LATER(ah)) rxclear_polarity = !ath_bt_config.bt_rxclear_polarity; @@ -136,9 +133,6 @@ void ath9k_hw_btcoex_init_2wire(struct ath_hw *ah) { struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - /* connect bt_active to baseband */ REG_CLR_BIT(ah, AR_GPIO_INPUT_EN_VAL, (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_DEF | @@ -161,9 +155,6 @@ void ath9k_hw_btcoex_init_3wire(struct ath_hw *ah) { struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - /* btcoex 3-wire */ REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, (AR_GPIO_INPUT_EN_VAL_BT_PRIORITY_BB | @@ -214,9 +205,6 @@ static void ath9k_hw_btcoex_enable_2wire(struct ath_hw *ah) { struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - /* Configure the desired GPIO port for TX_FRAME output */ ath9k_hw_cfg_output(ah, btcoex_hw->wlanactive_gpio, AR_GPIO_OUTPUT_MUX_AS_TX_FRAME); @@ -228,9 +216,6 @@ void ath9k_hw_btcoex_set_weight(struct ath_hw *ah, { struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - btcoex_hw->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) | SM(wlan_weight, AR_BTCOEX_WL_WGHT); } @@ -319,9 +304,6 @@ void ath9k_hw_btcoex_disable(struct ath_hw *ah) struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw; int i; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - btcoex_hw->enabled = false; if (btcoex_hw->scheme == ATH_BTCOEX_CFG_MCI) { ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE); @@ -370,9 +352,6 @@ static void ar9003_btcoex_bt_stomp(struct ath_hw *ah, void ath9k_hw_btcoex_bt_stomp(struct ath_hw *ah, enum ath_stomp_type stomp_type) { - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - if (AR_SREV_9300_20_OR_LATER(ah)) { ar9003_btcoex_bt_stomp(ah, stomp_type); return; diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 4da486bccfa4..1f1a5c632152 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -251,9 +251,6 @@ static int ath_init_btcoex_timer(struct ath_softc *sc) { struct ath_btcoex *btcoex = &sc->btcoex; - if (ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_NONE) - return 0; - btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000; btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * btcoex->btcoex_period / 100; @@ -286,9 +283,6 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc) ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n"); - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - /* make sure duty cycle timer is also stopped when resuming */ if (btcoex->hw_timer_enabled) ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer); @@ -309,9 +303,6 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc) struct ath_btcoex *btcoex = &sc->btcoex; struct ath_hw *ah = sc->sc_ah; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - del_timer_sync(&btcoex->period_timer); if (btcoex->hw_timer_enabled) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c index 6aa76745e020..1c10e2e5c237 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c @@ -119,9 +119,6 @@ static void ath_htc_init_btcoex_work(struct ath9k_htc_priv *priv) { struct ath_btcoex *btcoex = &priv->btcoex; - if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE) - return; - btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD; btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * btcoex->btcoex_period / 100; @@ -140,9 +137,6 @@ static void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv) struct ath_btcoex *btcoex = &priv->btcoex; struct ath_hw *ah = priv->ah; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; - ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex work\n"); btcoex->bt_priority_cnt = 0; @@ -157,9 +151,6 @@ static void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv) */ static void ath_htc_cancel_btcoex_work(struct ath9k_htc_priv *priv) { - if (ath9k_hw_get_btcoex_scheme(priv->ah) == ATH_BTCOEX_CFG_NONE) - return; - cancel_delayed_work_sync(&priv->coex_period_work); cancel_delayed_work_sync(&priv->duty_cycle_work); } @@ -195,8 +186,6 @@ void ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product) if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) { ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE; - if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_NONE) - return; } switch (ath9k_hw_get_btcoex_scheme(priv->ah)) { diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 29b65adade60..5f5f57421249 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1076,7 +1076,7 @@ ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) { return ATH_BTCOEX_CFG_NONE; } -#endif +#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ #define ATH9K_CLOCK_RATE_CCK 22 #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 -- GitLab From 9a15858f0cb9432e29db08dd936c39d20019a484 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:41:59 +0530 Subject: [PATCH 1168/1846] ath9k: Remove ATH9K_HW_CAP_MCI checks With the ability to remove BTCOEX support at compile time, these checks are no longer needed. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 54 --------------------- drivers/net/wireless/ath/ath9k/gpio.c | 2 +- drivers/net/wireless/ath/ath9k/hw.h | 4 -- drivers/net/wireless/ath/ath9k/mci.c | 9 ---- 4 files changed, 1 insertion(+), 68 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index b9652f6e5a4f..4079676fe692 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -86,9 +86,6 @@ static void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done) { u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00}; - if (!ATH9K_HW_CAP_MCI) - return; - ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16, wait_done, false); udelay(5); @@ -98,9 +95,6 @@ static void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done) { u32 payload = 0x00000000; - if (!ATH9K_HW_CAP_MCI) - return; - ar9003_mci_send_message(ah, MCI_LNA_TRANS, 0, &payload, 1, wait_done, false); } @@ -114,9 +108,6 @@ static void ar9003_mci_send_req_wake(struct ath_hw *ah, bool wait_done) static void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done) { - if (!ATH9K_HW_CAP_MCI) - return; - ar9003_mci_send_message(ah, MCI_SYS_WAKING, MCI_FLAG_DISABLE_TIMESTAMP, NULL, 0, wait_done, false); } @@ -230,9 +221,6 @@ static void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; u32 payload[4] = {0, 0, 0, 0}; - if (!ATH9K_HW_CAP_MCI) - return; - ath_dbg(common, MCI, "MCI Send Coex %s BT GPM\n", (halt) ? "halt" : "unhalt"); @@ -385,18 +373,12 @@ void ar9003_mci_set_full_sleep(struct ath_hw *ah) static void ar9003_mci_disable_interrupt(struct ath_hw *ah) { - if (!ATH9K_HW_CAP_MCI) - return; - REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0); REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0); } static void ar9003_mci_enable_interrupt(struct ath_hw *ah) { - if (!ATH9K_HW_CAP_MCI) - return; - 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); @@ -406,9 +388,6 @@ static bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints) { u32 intr; - if (!ATH9K_HW_CAP_MCI) - return false; - intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW); return ((intr & ints) == ints); } @@ -418,9 +397,6 @@ void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, { struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; - if (!ATH9K_HW_CAP_MCI) - return; - *raw_intr = mci->raw_intr; *rx_msg_intr = mci->rx_msg_intr; @@ -459,9 +435,6 @@ static void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g) { struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; - if (!ATH9K_HW_CAP_MCI) - return; - if (!mci->update_2g5g && (mci->is_2g != is_2g)) mci->update_2g5g = true; @@ -574,9 +547,6 @@ static void ar9003_mci_sync_bt_state(struct ath_hw *ah) struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; u32 cur_bt_state; - if (!ATH9K_HW_CAP_MCI) - return; - cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL); if (mci->bt_state != cur_bt_state) { @@ -675,9 +645,6 @@ static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type, u8 recv_type = 0, recv_opcode = 0; bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE); - if (!ATH9K_HW_CAP_MCI) - return 0; - more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE; while (time_out > 0) { @@ -909,9 +876,6 @@ static void ar9003_mci_mute_bt(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); - if (!ATH9K_HW_CAP_MCI) - return; - /* disable all MCI messages */ REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000); REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff); @@ -945,9 +909,6 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; u32 regval, thresh; - if (!ATH9K_HW_CAP_MCI) - return; - ath_dbg(common, MCI, "MCI full_sleep = %d, is_2g = %d\n", is_full_sleep, is_2g); @@ -1218,9 +1179,6 @@ 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 (!ATH9K_HW_CAP_MCI) - return; - if (mci->update_2g5g) { if (mci->is_2g) { @@ -1272,9 +1230,6 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, u32 saved_mci_int_en; int i; - if (!ATH9K_HW_CAP_MCI) - return false; - saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN); regval = REG_READ(ah, AR_BTCOEX_CTRL); @@ -1388,9 +1343,6 @@ void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf, { struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; - if (!ATH9K_HW_CAP_MCI) - return; - mci->gpm_addr = gpm_addr; mci->gpm_buf = gpm_buf; mci->gpm_len = len; @@ -1402,9 +1354,6 @@ EXPORT_SYMBOL(ar9003_mci_setup); void ar9003_mci_cleanup(struct ath_hw *ah) { - if (!ATH9K_HW_CAP_MCI) - return; - /* Turn off MCI and Jupiter mode. */ REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00); ar9003_mci_disable_interrupt(ah); @@ -1418,9 +1367,6 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) u32 value = 0, more_gpm = 0, gpm_ptr; u8 query_type; - if (!ATH9K_HW_CAP_MCI) - return 0; - switch (state_type) { case MCI_STATE_ENABLE: if (mci->ready) { diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 1f1a5c632152..63e4c4b1cb3d 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -333,7 +333,7 @@ void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status) if (status & ATH9K_INT_GENTIMER) ath_gen_timer_isr(sc->sc_ah); - if ((status & ATH9K_INT_MCI) && ATH9K_HW_CAP_MCI) + if (status & ATH9K_INT_MCI) ath_mci_intr(sc); } diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 5f5f57421249..c785303eb3ad 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -209,11 +209,7 @@ enum ath9k_hw_caps { ATH9K_HW_CAP_5GHZ = BIT(12), ATH9K_HW_CAP_APM = BIT(13), ATH9K_HW_CAP_RTT = BIT(14), -#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT ATH9K_HW_CAP_MCI = BIT(15), -#else - ATH9K_HW_CAP_MCI = 0, -#endif ATH9K_HW_CAP_DFS = BIT(16), }; diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index 85a957ab89be..f818faa3b612 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -389,9 +389,6 @@ int ath_mci_setup(struct ath_softc *sc) struct ath_mci_coex *mci = &sc->mci_coex; struct ath_mci_buf *buf = &mci->sched_buf; - if (!ATH9K_HW_CAP_MCI) - return 0; - buf->bf_addr = dma_alloc_coherent(sc->dev, ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, &buf->bf_paddr, GFP_KERNEL); @@ -426,9 +423,6 @@ void ath_mci_cleanup(struct ath_softc *sc) struct ath_mci_coex *mci = &sc->mci_coex; struct ath_mci_buf *buf = &mci->sched_buf; - if (!ATH9K_HW_CAP_MCI) - return; - if (buf->bf_addr) dma_free_coherent(sc->dev, ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, @@ -450,9 +444,6 @@ void ath_mci_intr(struct ath_softc *sc) u32 more_data = MCI_GPM_MORE; bool skip_gpm = false; - if (!ATH9K_HW_CAP_MCI) - return; - ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg); if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) { -- GitLab From 70982b720f6910d094861916973ad51f2afa0e18 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:42:04 +0530 Subject: [PATCH 1169/1846] ath9k: Modify ATH9K_BTCOEX_SUPPORT ATH9K_BTCOEX_SUPPORT is now used by both ath9k and ath9k_htc to enable BT coexistence. Fix Kbuild to allow this. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/Kconfig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index dc6be4afe8eb..595a272aa96e 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig @@ -6,6 +6,14 @@ config ATH9K_DFS_DEBUGFS def_bool y depends on ATH9K_DEBUGFS && ATH9K_DFS_CERTIFIED +config ATH9K_BTCOEX_SUPPORT + bool "Atheros bluetooth coexistence support" + depends on (ATH9K || ATH9K_HTC) + default y + ---help--- + Say Y, if you want to use the ath9k/ath9k_htc radios together with + Bluetooth modules in the same system. + config ATH9K tristate "Atheros 802.11n wireless cards support" depends on MAC80211 @@ -81,14 +89,6 @@ config ATH9K_RATE_CONTROL Say Y, if you want to use the ath9k specific rate control module instead of minstrel_ht. -config ATH9K_BTCOEX_SUPPORT - bool "Atheros ath9k bluetooth coexistence support" - depends on ATH9K - default y - ---help--- - Say Y, if you want to use the ath9k radios together with - Bluetooth modules in the same system. - config ATH9K_HTC tristate "Atheros HTC based wireless cards support" depends on USB && MAC80211 -- GitLab From 4f851df78a96947807c14a7c616d1d096314e460 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:42:10 +0530 Subject: [PATCH 1170/1846] ath9k_hw: Cleanup MCI reset routine * Use a separate function to enable/disable OneStepLookAhead. * Remove unnecessary hardware SREV checks. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 91 +++++++++++---------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 4079676fe692..8d3659cc11f0 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -902,20 +902,46 @@ static void ar9003_mci_mute_bt(struct ath_hw *ah) ar9003_mci_send_sys_sleeping(ah, true); } +static void ar9003_mci_osla_setup(struct ath_hw *ah, bool enable) +{ + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 thresh; + + if (enable) { + 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); + + if (!(mci->config & ATH_MCI_CONFIG_DISABLE_AGGR_THRESH)) { + thresh = MS(mci->config, ATH_MCI_CONFIG_AGGR_THRESH); + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_AGGR_THRESH, thresh); + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN, 1); + } else { + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN, 0); + } + + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN, 1); + } else { + REG_CLR_BIT(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN); + } +} + 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; + u32 regval; - ath_dbg(common, MCI, "MCI full_sleep = %d, is_2g = %d\n", + ath_dbg(common, MCI, "MCI Reset (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, MCI, "MCI GPM and schedule buffers are not allocated\n"); @@ -923,7 +949,7 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, } if (REG_READ(ah, AR_BTCOEX_CTRL) == 0xdeadbeef) { - ath_dbg(common, MCI, "MCI it's deadbeef, quit mci_reset\n"); + ath_dbg(common, MCI, "BTCOEX control register is dead\n"); return; } @@ -947,46 +973,23 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, 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, 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, MCI, "MCI sched aggr thresh: off\n"); - } else - ath_dbg(common, MCI, "MCI SCHED one step look ahead off\n"); - 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); - } + if (is_2g && !(mci->config & ATH_MCI_CONFIG_DISABLE_OSLA)) + ar9003_mci_osla_setup(ah, true); + else + ar9003_mci_osla_setup(ah, false); + + 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); + regval = MS(mci->config, ATH_MCI_CONFIG_CLK_DIV); + REG_RMW_FIELD(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_CLK_DIV, regval); REG_SET_BIT(ah, AR_BTCOEX_CTRL, AR_BTCOEX_CTRL_MCI_MODE_EN); /* Resetting the Rx and Tx paths of MCI */ @@ -1011,15 +1014,15 @@ void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, 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); + AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE); - if (AR_SREV_9462_20_OR_LATER(ah)) - ar9003_mci_observation_set_up(ah); + ar9003_mci_observation_set_up(ah); mci->ready = true; ar9003_mci_prep_interface(ah); -- GitLab From 0cc4cdebb789c5ca8c2b263c846fe7e9b0a199bd Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:42:15 +0530 Subject: [PATCH 1171/1846] ath9k_hw: Remove HW revision checks They are not needed since MCI will be enabled only for AR9462 v2.0 Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 34 ++++++--------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 8d3659cc11f0..591ca35b3983 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -22,9 +22,6 @@ 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); @@ -496,14 +493,9 @@ static void ar9003_mci_observation_set_up(struct ath_hw *ah) 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_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); @@ -1053,9 +1045,7 @@ static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done) 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->update_2g5g && (mci->bt_state != MCI_BT_SLEEP)) { if (mci->is_2g) { new_flags = MCI_2G_FLAGS; @@ -1193,14 +1183,13 @@ void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done) 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, MCI, "MCI Send LNA take\n"); @@ -1210,12 +1199,10 @@ void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done) 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); - } + 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); } @@ -1532,8 +1519,7 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) 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)) { + if (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) != -- GitLab From 37cd9d78d100ecfdb480228a3229bc8b0b1af88e Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 12:42:21 +0530 Subject: [PATCH 1172/1846] ath9k_hw: MCI whitespace/debug cleanup This patch fixes indentation and the general coding style in ar9003_mci.c. Also, minimize the amount of debug log output generated by MCI. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 362 ++++---------------- 1 file changed, 68 insertions(+), 294 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c index 591ca35b3983..3cac293a2849 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -35,13 +35,10 @@ static int ar9003_mci_wait_for_interrupt(struct ath_hw *ah, u32 address, 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); @@ -127,30 +124,27 @@ static void ar9003_mci_send_sys_sleeping(struct ath_hw *ah, bool wait_done) 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, MCI, "MCI Send Coex version query\n"); + (mci->bt_state != MCI_BT_SLEEP)) { MCI_GPM_SET_TYPE_OPCODE(payload, - MCI_GPM_COEX_AGENT, MCI_GPM_COEX_VERSION_QUERY); + MCI_GPM_COEX_AGENT, + MCI_GPM_COEX_VERSION_QUERY); ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, - wait_done, true); + wait_done, true); } } static void ar9003_mci_send_coex_version_response(struct ath_hw *ah, - bool wait_done) + 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, MCI, "MCI Send Coex version response\n"); MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT, - MCI_GPM_COEX_VERSION_RESPONSE); + 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) = @@ -159,15 +153,16 @@ static void ar9003_mci_send_coex_version_response(struct ath_hw *ah, } static void ar9003_mci_send_coex_wlan_channels(struct ath_hw *ah, - bool wait_done) + 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->bt_state != MCI_BT_SLEEP)) { MCI_GPM_SET_TYPE_OPCODE(payload, - MCI_GPM_COEX_AGENT, MCI_GPM_COEX_WLAN_CHANNELS); + 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); @@ -177,7 +172,6 @@ static void ar9003_mci_send_coex_wlan_channels(struct ath_hw *ah, 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 | @@ -185,25 +179,19 @@ static void ar9003_mci_send_coex_bt_status_query(struct ath_hw *ah, if (mci->bt_state != MCI_BT_SLEEP) { - ath_dbg(common, 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); + 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) { + if (query_btinfo) mci->need_flush_btinfo = true; - - ath_dbg(common, MCI, - "MCI send bt_status_query fail, set flush flag again\n"); - } } if (query_btinfo) @@ -214,15 +202,11 @@ static void ar9003_mci_send_coex_bt_status_query(struct ath_hw *ah, static 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, 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); + MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT, + MCI_GPM_COEX_HALT_BT_GPM); if (halt) { mci->query_bt = true; @@ -238,7 +222,6 @@ static void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, 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); @@ -255,18 +238,12 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, REG_READ(ah, AR_MCI_INTERRUPT_RAW)); - /* Remote Reset */ - ath_dbg(common, MCI, "MCI Reset sequence start\n"); - ath_dbg(common, MCI, "MCI send REMOTE_RESET\n"); ar9003_mci_remote_reset(ah, true); - - ath_dbg(common, 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)) { + AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING, 500)) { - ath_dbg(common, MCI, "MCI SYS_WAKING from remote(BT)\n"); mci->bt_state = MCI_BT_AWAKE; /* @@ -285,11 +262,6 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) * 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, MCI, "MCI send SW SYS_WAKING to remote BT\n"); - ar9003_mci_send_sys_waking(ah, true); udelay(10); @@ -297,7 +269,6 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) * 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); @@ -316,17 +287,15 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) AR_MCI_INTERRUPT_BT_PRI); if (mci->is_2g) { - /* Send LNA_TRANS */ - ath_dbg(common, MCI, "MCI send LNA_TRANS to BT\n"); ar9003_mci_send_lna_transfer(ah, true); udelay(5); } if ((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)) + AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_LNA_INFO, + mci_timeout)) ath_dbg(common, MCI, "MCI WLAN has control over the LNA & BT obeys it\n"); else @@ -339,13 +308,12 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) 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_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); @@ -353,14 +321,11 @@ static void ar9003_mci_prep_interface(struct ath_hw *ah) void ar9003_mci_set_full_sleep(struct ath_hw *ah) { - struct ath_common *common = ath9k_hw_common(ah); struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) && (mci->bt_state != MCI_BT_SLEEP) && !mci->halted_bt_gpm) { - ath_dbg(common, MCI, - "MCI halt BT GPM (full_sleep)\n"); ar9003_mci_send_coex_halt_bt_gpm(ah, true, true); } @@ -441,7 +406,6 @@ static void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool 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; @@ -454,10 +418,8 @@ static bool ar9003_mci_is_gpm_valid(struct ath_hw *ah, u32 msg_index) payload = (u32 *)(mci->gpm_buf + offset); recv_type = MCI_GPM_TYPE(payload); - if (recv_type == MCI_GPM_RSVD_PATTERN) { - ath_dbg(common, MCI, "MCI Skip RSVD GPM\n"); + if (recv_type == MCI_GPM_RSVD_PATTERN) return false; - } return true; } @@ -465,29 +427,23 @@ static bool ar9003_mci_is_gpm_valid(struct ath_hw *ah, u32 msg_index) 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); + 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; @@ -509,13 +465,12 @@ static void ar9003_mci_observation_set_up(struct ath_hw *ah) } static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done, - u8 opcode, u32 bt_flags) + 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); + 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; @@ -523,40 +478,27 @@ static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done, *(((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, 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); + wait_done, true); } static 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, MCI, - "MCI BT state mismatches. old: %d, new: %d\n", - mci->bt_state, cur_bt_state); + if (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, MCI, "MCI unhalt BT GPM\n"); + if (mci->unhalt_bt_gpm == true) ar9003_mci_send_coex_halt_bt_gpm(ah, false, true); - } } } @@ -654,8 +596,8 @@ static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type, if (!time_out) break; - offset = ar9003_mci_state(ah, - MCI_STATE_NEXT_GPM_OFFSET, &more_data); + offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET, + &more_data); if (offset == MCI_GPM_INVALID) continue; @@ -665,24 +607,17 @@ static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type, 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, MCI, - "MCI Recv BT_CAL_DONE wait BT_CAL_GRANT\n"); continue; } - break; } - } else if ((recv_type == gpm_type) && - (recv_opcode == gpm_opcode)) + } else if ((recv_type == gpm_type) && (recv_opcode == gpm_opcode)) { break; - - /* not expected message */ + } /* * check if it's cal_grant @@ -703,45 +638,31 @@ static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type, u32 payload[4] = {0, 0, 0, 0}; gpm_type = MCI_GPM_BT_CAL_DONE; - ath_dbg(common, MCI, - "MCI Rcv BT_CAL_REQ, send WLAN_CAL_GRANT\n"); - MCI_GPM_SET_CAL_TYPE(payload, - MCI_GPM_WLAN_CAL_GRANT); - + MCI_GPM_WLAN_CAL_GRANT); ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, false, false); - - ath_dbg(common, MCI, "MCI now wait for BT_CAL_DONE\n"); - continue; } else { ath_dbg(common, 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); + recv_opcode, p_gpm); } } + if (p_gpm) { MCI_GPM_RECYCLE(p_gpm); p_gpm = NULL; } - if (time_out <= 0) { + if (time_out <= 0) time_out = 0; - ath_dbg(common, MCI, - "MCI GPM received timeout, mismatch = %d\n", mismatch); - } else - ath_dbg(common, MCI, "MCI Receive GPM type=0x%x, code=0x%x\n", - gpm_type, gpm_opcode); while (more_data == MCI_GPM_MORE) { - - ath_dbg(common, MCI, "MCI discard remaining GPM\n"); offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET, &more_data); - if (offset == MCI_GPM_INVALID) break; @@ -770,8 +691,6 @@ bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) if (mci_hw->bt_state != MCI_BT_CAL_START) return false; - ath_dbg(common, MCI, "MCI stop rx for BT CAL\n"); - mci_hw->bt_state = MCI_BT_CAL; /* @@ -779,26 +698,20 @@ bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) * 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, MCI, "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, true, false); - ath_dbg(common, MCI, "\nMCI BT is calibrating\n"); - /* 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, MCI, - "MCI got BT_CAL_DONE\n"); + ath_dbg(common, MCI, "MCI BT_CAL_DONE received\n"); else ath_dbg(common, MCI, - "MCI ### BT cal takes to long, force bt_state to be bt_awake\n"); + "MCI BT_CAL_DONE not received\n"); mci_hw->bt_state = MCI_BT_AWAKE; /* MCI FIX: enable mci interrupt here */ @@ -810,7 +723,6 @@ bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata) { - struct ath_common *common = ath9k_hw_common(ah); struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; if (!mci_hw->ready) @@ -828,16 +740,10 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, * WLAN calibration, need to go through all * message exchanges again and recal. */ - - ath_dbg(common, 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, MCI, "MCI send REMOTE_RESET\n"); - ar9003_mci_remote_reset(ah, true); ar9003_mci_send_sys_waking(ah, true); udelay(1); @@ -847,8 +753,6 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, mci_hw->bt_state = MCI_BT_AWAKE; - ath_dbg(common, MCI, "MCI re-cal\n"); - if (caldata) { caldata->done_txiqcal_once = false; caldata->done_txclcal_once = false; @@ -866,8 +770,6 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, static 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); @@ -884,13 +786,10 @@ static void ar9003_mci_mute_bt(struct ath_hw *ah) * 1. reset not after resuming from full sleep * 2. before reset MCI RX, to quiet BT and avoid MCI RX misalignment */ - - ath_dbg(common, MCI, "MCI Send LNA take\n"); ar9003_mci_send_lna_take(ah, true); udelay(5); - ath_dbg(common, MCI, "MCI Send sys sleeping\n"); ar9003_mci_send_sys_sleeping(ah, true); } @@ -1041,12 +940,10 @@ void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep) 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 (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; @@ -1057,41 +954,23 @@ static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done) to_set = MCI_5G_FLAGS_SET_MASK; } - ath_dbg(common, 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); - + 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); + MCI_GPM_COEX_BT_FLAGS_SET, + to_set); } } 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, MCI, - "MCI ERROR: Send fail: %02x: %02x %02x %02x\n", - header, - *(((u8 *)payload) + 4), - *(((u8 *)payload) + 5), - *(((u8 *)payload) + 6)); - else - ath_dbg(common, MCI, "MCI ERROR: Send fail: %02x\n", - header); - } - /* check if the message is to be queued */ if (header != MCI_GPM) return; @@ -1104,61 +983,29 @@ static void ar9003_mci_queue_unsent_gpm(struct ath_hw *ah, u8 header, switch (opcode) { case MCI_GPM_COEX_BT_UPDATE_FLAGS: - 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, MCI, - "MCI BT_MCI_FLAGS: 2G5G status %s\n", - mci->is_2g ? "2G" : "5G"); - else - ath_dbg(common, 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, MCI, "MCI WLAN channel map \n"); - else - ath_dbg(common, 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_GPM_COEX_BT_GPM_UNHALT) { mci->unhalt_bt_gpm = queue; - if (queue) - ath_dbg(common, MCI, - "MCI UNHALT BT GPM \n"); - else { + if (!queue) mci->halted_bt_gpm = false; - ath_dbg(common, 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, MCI, - "MCI HALT BT GPM \n"); - else - ath_dbg(common, MCI, - "MCI UNHALT BT GPM \n"); } break; @@ -1169,36 +1016,29 @@ static void ar9003_mci_queue_unsent_gpm(struct ath_hw *ah, u8 header, 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, 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); + REG_CLR_BIT(ah, AR_PHY_GLB_CONTROL, + AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL); - 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); + 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, 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); - REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL); REG_CLR_BIT(ah, AR_BTCOEX_CTRL, @@ -1224,21 +1064,15 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, regval = REG_READ(ah, AR_BTCOEX_CTRL); if ((regval == 0xdeadbeef) || !(regval & AR_BTCOEX_CTRL_MCI_MODE_EN)) { - ath_dbg(common, MCI, "MCI Not sending 0x%x. MCI is not enabled. full_sleep = %d\n", - header, - (ah->power_mode == ATH9K_PM_FULL_SLEEP) ? 1 : 0); - + 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, 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; } @@ -1266,7 +1100,7 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, if (wait_done && !(ar9003_mci_wait_for_interrupt(ah, AR_MCI_INTERRUPT_RAW, - AR_MCI_INTERRUPT_SW_MSG_DONE, 500))) + 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); @@ -1290,29 +1124,21 @@ void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable) (mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL)) return; - /* send CAL_REQ only when BT is AWAKE. */ - ath_dbg(common, 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, MCI, "MCI wait for BT_CAL_GRANT\n"); - if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_GRANT, 0, 50000)) { - ath_dbg(common, MCI, "MCI got BT_CAL_GRANT\n"); + ath_dbg(common, MCI, "MCI BT_CAL_GRANT received\n"); } else { is_reusable = false; - ath_dbg(common, MCI, "MCI BT is not responding\n"); + ath_dbg(common, MCI, "MCI BT_CAL_GRANT not received\n"); } } void ar9003_mci_init_cal_done(struct ath_hw *ah) { - struct ath_common *common = ath9k_hw_common(ah); struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; u32 pld[4] = {0, 0, 0, 0}; @@ -1320,9 +1146,6 @@ void ar9003_mci_init_cal_done(struct ath_hw *ah) (mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL)) return; - ath_dbg(common, 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); @@ -1360,7 +1183,6 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) switch (state_type) { case MCI_STATE_ENABLE: if (mci->ready) { - value = REG_READ(ah, AR_BTCOEX_CTRL); if ((value == 0xdeadbeef) || (value == 0xffffffff)) @@ -1370,7 +1192,6 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) break; case MCI_STATE_INIT_GPM_OFFSET: value = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR); - ath_dbg(common, MCI, "MCI GPM initial WRITE_PTR=%d\n", value); mci->gpm_idx = value; break; case MCI_STATE_NEXT_GPM_OFFSET: @@ -1393,32 +1214,21 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) if (value == 0) value = mci->gpm_len - 1; else if (value >= mci->gpm_len) { - if (value != 0xFFFF) { + if (value != 0xFFFF) value = 0; - ath_dbg(common, MCI, - "MCI GPM offset out of range\n"); - } - } else + } else { value--; + } if (value == 0xFFFF) { value = MCI_GPM_INVALID; more_gpm = MCI_GPM_NOMORE; - ath_dbg(common, 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, 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 */ @@ -1435,13 +1245,8 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) mci->gpm_len) mci->gpm_idx = 0; - ath_dbg(common, 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)) { + temp_index)) { value = temp_index; break; } @@ -1466,55 +1271,42 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) /* 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; - + 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, MCI, "MCI unhalt BT GPM\n"); + if (mci->unhalt_bt_gpm) 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; @@ -1522,22 +1314,16 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) if (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, MCI, - "MCI reconfigure observation\n"); + ATH_MCI_CONFIG_MCI_OBS_GPIO) != + ATH_MCI_CONFIG_MCI_OBS_GPIO) { 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, MCI, "MCI Set BT Coex version with NULL data!!\n"); @@ -1549,7 +1335,6 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) mci->bt_ver_major, mci->bt_ver_minor); } break; - case MCI_STATE_SEND_WLAN_CHANNELS: if (p_data) { if (((mci->wlan_channels[1] & 0xffff0000) == @@ -1566,17 +1351,13 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *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 = 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 @@ -1596,28 +1377,21 @@ u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) mci->need_flush_btinfo = (*p_data != 0) ? true : false; break; - case MCI_STATE_RECOVER_RX: - - ath_dbg(common, 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; -- GitLab From 682dd04b37bc6b36356adda31e5435da8a246499 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 22 Feb 2012 14:43:52 +0530 Subject: [PATCH 1173/1846] ath9k: Cleanup mci.c Cleanup whitespace, fix indentation and coding style. Also remove debug messages that were flooding the log. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mci.c | 213 ++++++++------------------- 1 file changed, 59 insertions(+), 154 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index f818faa3b612..29fe52d69973 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -42,24 +42,18 @@ static bool ath_mci_add_profile(struct ath_common *common, struct ath_mci_profile_info *entry; if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) && - (info->type == MCI_GPM_COEX_PROFILE_VOICE)) { - ath_dbg(common, MCI, - "Too many SCO profile, failed to add new profile\n"); + (info->type == MCI_GPM_COEX_PROFILE_VOICE)) return false; - } if (((NUM_PROF(mci) - mci->num_sco) == ATH_MCI_MAX_ACL_PROFILE) && - (info->type != MCI_GPM_COEX_PROFILE_VOICE)) { - ath_dbg(common, MCI, - "Too many ACL profile, failed to add new profile\n"); + (info->type != MCI_GPM_COEX_PROFILE_VOICE)) return false; - } entry = ath_mci_find_profile(mci, info); - if (entry) + if (entry) { memcpy(entry, info, 10); - else { + } else { entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (!entry) return false; @@ -68,6 +62,7 @@ static bool ath_mci_add_profile(struct ath_common *common, INC_PROF(mci, info); list_add_tail(&info->list, &mci->info); } + return true; } @@ -79,10 +74,9 @@ static void ath_mci_del_profile(struct ath_common *common, entry = ath_mci_find_profile(mci, info); - if (!entry) { - ath_dbg(common, MCI, "Profile to be deleted not found\n"); + if (!entry) return; - } + DEC_PROF(mci, entry); list_del(&entry->list); kfree(entry); @@ -177,13 +171,12 @@ static void ath_mci_update_scheme(struct ath_softc *sc) btcoex->btcoex_period *= 1000; btcoex->btcoex_no_stomp = btcoex->btcoex_period * - (100 - btcoex->duty_cycle) / 100; + (100 - btcoex->duty_cycle) / 100; ath9k_hw_btcoex_enable(sc->sc_ah); 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; @@ -192,42 +185,24 @@ static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) switch (opcode) { case MCI_GPM_BT_CAL_REQ: - - ath_dbg(common, 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, MCI, "MCI State mismatches: %d\n", + } else { + ath_dbg(common, MCI, "MCI State mismatch: %d\n", ar9003_mci_state(ah, MCI_STATE_BT, NULL)); - + } break; - case MCI_GPM_BT_CAL_DONE: - - ath_dbg(common, MCI, "MCI received BT_CAL_DONE\n"); - - if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_CAL) - ath_dbg(common, MCI, "MCI error illegal!\n"); - else - ath_dbg(common, MCI, "MCI BT not in CAL state\n"); - + ar9003_mci_state(ah, MCI_STATE_BT, NULL); break; - case MCI_GPM_BT_CAL_GRANT: - - ath_dbg(common, MCI, "MCI received BT_CAL_GRANT\n"); - - /* Send WLAN_CAL_DONE for now */ - ath_dbg(common, 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, MCI, "MCI Unknown GPM CAL message\n"); + ath_dbg(common, MCI, "Unknown GPM CAL message\n"); break; } } @@ -247,6 +222,7 @@ static void ath_mci_process_profile(struct ath_softc *sc, btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD; mci->aggr_limit = mci->num_sco ? 6 : 0; + if (NUM_PROF(mci)) { btcoex->bt_stomp_type = ATH_BTCOEX_STOMP_LOW; btcoex->duty_cycle = ath_mci_duty_cycle[NUM_PROF(mci)]; @@ -262,31 +238,24 @@ static void ath_mci_process_profile(struct ath_softc *sc, 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; struct ath_mci_profile *mci = &btcoex->mci; struct ath_mci_profile_info info; int i = 0, old_num_mgmt = mci->num_mgmt; /* Link status type are not handled */ - if (status->is_link) { - ath_dbg(common, MCI, "Skip link type status update\n"); + if (status->is_link) return; - } memset(&info, 0, sizeof(struct ath_mci_profile_info)); info.conn_handle = status->conn_handle; - if (ath_mci_find_profile(mci, &info)) { - ath_dbg(common, MCI, - "Skip non link state update for existing profile %d\n", - status->conn_handle); + if (ath_mci_find_profile(mci, &info)) return; - } - if (status->conn_handle >= ATH_MCI_MAX_PROFILE) { - ath_dbg(common, MCI, "Ignore too many non-link update\n"); + + if (status->conn_handle >= ATH_MCI_MAX_PROFILE) return; - } + if (status->is_critical) __set_bit(status->conn_handle, mci->status); else @@ -314,43 +283,28 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) u32 seq_num; switch (opcode) { - case MCI_GPM_COEX_VERSION_QUERY: - ath_dbg(common, MCI, "MCI Recv GPM COEX Version Query\n"); - version = ar9003_mci_state(ah, - MCI_STATE_SEND_WLAN_COEX_VERSION, NULL); + version = ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_COEX_VERSION, + NULL); break; - case MCI_GPM_COEX_VERSION_RESPONSE: - ath_dbg(common, 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, 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); + version = ar9003_mci_state(ah, MCI_STATE_SET_BT_COEX_VERSION, + &version); break; - case MCI_GPM_COEX_STATUS_QUERY: - ath_dbg(common, 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); + ar9003_mci_state(ah, MCI_STATE_SEND_WLAN_CHANNELS, NULL); break; - case MCI_GPM_COEX_BT_PROFILE_INFO: - ath_dbg(common, 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)) { - + if ((profile_info.type == MCI_GPM_COEX_PROFILE_UNKNOWN) || + (profile_info.type >= MCI_GPM_COEX_PROFILE_MAX)) { ath_dbg(common, MCI, - "illegal profile type = %d, state = %d\n", + "Illegal profile type = %d, state = %d\n", profile_info.type, profile_info.start); break; @@ -358,7 +312,6 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) 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); @@ -369,16 +322,14 @@ static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) seq_num = *((u32 *)(rx_payload + 12)); ath_dbg(common, MCI, - "MCI Recv GPM COEX BT_Status_Update: is_link=%d, linkId=%d, state=%d, SEQ=%d\n", + "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, MCI, "MCI Unknown GPM COEX message = 0x%02x\n", - opcode); + ath_dbg(common, MCI, "Unknown GPM COEX message = 0x%02x\n", opcode); break; } } @@ -447,13 +398,7 @@ void ath_mci_intr(struct ath_softc *sc) 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, MCI, "MCI interrupt but MCI disabled\n"); - - ath_dbg(common, MCI, - "MCI interrupt: intr = 0x%x, intr_rxmsg = 0x%x\n", - mci_int, mci_int_rxmsg); + ar9003_mci_state(ah, MCI_STATE_INIT_GPM_OFFSET, NULL); return; } @@ -466,11 +411,8 @@ void ath_mci_intr(struct ath_softc *sc) * only when BT wake up. Now they are always sent, as a * recovery method to reset BT MCI's RX alignment. */ - ath_dbg(common, MCI, "MCI interrupt send REMOTE_RESET\n"); - ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16, true, false); - ath_dbg(common, MCI, "MCI interrupt send SYS_WAKING\n"); ar9003_mci_send_message(ah, MCI_SYS_WAKING, 0, NULL, 0, true, false); @@ -480,74 +422,51 @@ void ath_mci_intr(struct ath_softc *sc) /* * always do this for recovery and 2G/5G toggling and LNA_TRANS */ - ath_dbg(common, 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, MCI, - "MCI BT stays in sleep mode\n"); - else { - ath_dbg(common, MCI, - "MCI Set BT state to AWAKE\n"); - ar9003_mci_state(ah, - MCI_STATE_SET_BT_AWAKE, NULL); - } - } else - ath_dbg(common, MCI, "MCI BT stays in AWAKE mode\n"); + if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) != + MCI_BT_SLEEP) + ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE, + NULL); + } } 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, MCI, - "MCI BT stays in AWAKE mode\n"); - else { - ath_dbg(common, MCI, - "MCI SetBT state to SLEEP\n"); + if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) != + MCI_BT_AWAKE) ar9003_mci_state(ah, MCI_STATE_SET_BT_SLEEP, NULL); - } - } else - ath_dbg(common, 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, 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); + offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET, + &more_data); if (offset == MCI_GPM_INVALID) break; @@ -558,44 +477,38 @@ void ath_mci_intr(struct ath_softc *sc) * 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; - } + if (skip_gpm) + goto recycle; + + 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; } } + recycle: 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) { + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_INFO) mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_INFO; - ath_dbg(common, 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_STATE_CONT_RSSI_POWER, NULL); mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_INFO; @@ -603,33 +516,25 @@ void ath_mci_intr(struct ath_softc *sc) ath_dbg(common, MCI, "MCI CONT_INFO: (tx) pri = %d, pwr = %d dBm\n", ar9003_mci_state(ah, - MCI_STATE_CONT_PRIORITY, NULL), + MCI_STATE_CONT_PRIORITY, NULL), value_dbm); else ath_dbg(common, MCI, "MCI CONT_INFO: (rx) pri = %d,pwr = %d dBm\n", ar9003_mci_state(ah, - MCI_STATE_CONT_PRIORITY, NULL), + MCI_STATE_CONT_PRIORITY, NULL), value_dbm); } - if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_NACK) { + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_NACK) mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_NACK; - ath_dbg(common, MCI, "MCI CONT_NACK\n"); - } - if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_RST) { + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_RST) mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_RST; - ath_dbg(common, 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, MCI, "MCI not processed mci_int_rxmsg = 0x%x\n", - mci_int_rxmsg); } -- GitLab From 9d88c7f6709aab0e4342d80fad6fb7d3f7efc7ff Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Thu, 23 Feb 2012 02:17:48 +0100 Subject: [PATCH 1174/1846] mac80211: use proper sub_if_data on suspend path Use interface data from sta instead of invalid pointer to list head in calls to drv_sta_state. Signed-off-by: Jakub Kicinski Reviewed-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 2b53a5348ace..ef8eba1d736d 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -102,7 +102,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) state = sta->sta_state; for (; state > IEEE80211_STA_NOTEXIST; state--) - WARN_ON(drv_sta_state(local, sdata, sta, + WARN_ON(drv_sta_state(local, sta->sdata, sta, state, state - 1)); } -- GitLab From 06d9b6ac75379297c6a47ee8b8d0fe8b5cedcd39 Mon Sep 17 00:00:00 2001 From: Stanislav Yakovlev Date: Thu, 23 Feb 2012 17:31:24 -0500 Subject: [PATCH 1175/1846] net/wireless: ipw2x00: Use IW_HANDLER macro from linux/wireless.h Use IW_HANDLER macro in ipw2100.c to declare wireless handlers. Note: ipw2200.c already uses it. Signed-off-by: Stanislav Yakovlev Signed-off-by: John W. Linville --- drivers/net/wireless/ipw2x00/ipw2100.c | 90 ++++++++++---------------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index a0e5c21d3657..da41b8cf8700 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c @@ -8108,61 +8108,41 @@ static int ipw2100_wx_get_crc_check(struct net_device *dev, #endif /* CONFIG_IPW2100_MONITOR */ static iw_handler ipw2100_wx_handlers[] = { - NULL, /* SIOCSIWCOMMIT */ - ipw2100_wx_get_name, /* SIOCGIWNAME */ - NULL, /* SIOCSIWNWID */ - NULL, /* SIOCGIWNWID */ - ipw2100_wx_set_freq, /* SIOCSIWFREQ */ - ipw2100_wx_get_freq, /* SIOCGIWFREQ */ - ipw2100_wx_set_mode, /* SIOCSIWMODE */ - ipw2100_wx_get_mode, /* SIOCGIWMODE */ - NULL, /* SIOCSIWSENS */ - NULL, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - ipw2100_wx_get_range, /* SIOCGIWRANGE */ - NULL, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - NULL, /* SIOCSIWSPY */ - NULL, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - ipw2100_wx_set_wap, /* SIOCSIWAP */ - ipw2100_wx_get_wap, /* SIOCGIWAP */ - ipw2100_wx_set_mlme, /* SIOCSIWMLME */ - NULL, /* SIOCGIWAPLIST -- deprecated */ - ipw2100_wx_set_scan, /* SIOCSIWSCAN */ - ipw2100_wx_get_scan, /* SIOCGIWSCAN */ - ipw2100_wx_set_essid, /* SIOCSIWESSID */ - ipw2100_wx_get_essid, /* SIOCGIWESSID */ - ipw2100_wx_set_nick, /* SIOCSIWNICKN */ - ipw2100_wx_get_nick, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - ipw2100_wx_set_rate, /* SIOCSIWRATE */ - ipw2100_wx_get_rate, /* SIOCGIWRATE */ - ipw2100_wx_set_rts, /* SIOCSIWRTS */ - ipw2100_wx_get_rts, /* SIOCGIWRTS */ - ipw2100_wx_set_frag, /* SIOCSIWFRAG */ - ipw2100_wx_get_frag, /* SIOCGIWFRAG */ - ipw2100_wx_set_txpow, /* SIOCSIWTXPOW */ - ipw2100_wx_get_txpow, /* SIOCGIWTXPOW */ - ipw2100_wx_set_retry, /* SIOCSIWRETRY */ - ipw2100_wx_get_retry, /* SIOCGIWRETRY */ - ipw2100_wx_set_encode, /* SIOCSIWENCODE */ - ipw2100_wx_get_encode, /* SIOCGIWENCODE */ - ipw2100_wx_set_power, /* SIOCSIWPOWER */ - ipw2100_wx_get_power, /* SIOCGIWPOWER */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - ipw2100_wx_set_genie, /* SIOCSIWGENIE */ - ipw2100_wx_get_genie, /* SIOCGIWGENIE */ - ipw2100_wx_set_auth, /* SIOCSIWAUTH */ - ipw2100_wx_get_auth, /* SIOCGIWAUTH */ - ipw2100_wx_set_encodeext, /* SIOCSIWENCODEEXT */ - ipw2100_wx_get_encodeext, /* SIOCGIWENCODEEXT */ - NULL, /* SIOCSIWPMKSA */ + IW_HANDLER(SIOCGIWNAME, ipw2100_wx_get_name), + IW_HANDLER(SIOCSIWFREQ, ipw2100_wx_set_freq), + IW_HANDLER(SIOCGIWFREQ, ipw2100_wx_get_freq), + IW_HANDLER(SIOCSIWMODE, ipw2100_wx_set_mode), + IW_HANDLER(SIOCGIWMODE, ipw2100_wx_get_mode), + IW_HANDLER(SIOCGIWRANGE, ipw2100_wx_get_range), + IW_HANDLER(SIOCSIWAP, ipw2100_wx_set_wap), + IW_HANDLER(SIOCGIWAP, ipw2100_wx_get_wap), + IW_HANDLER(SIOCSIWMLME, ipw2100_wx_set_mlme), + IW_HANDLER(SIOCSIWSCAN, ipw2100_wx_set_scan), + IW_HANDLER(SIOCGIWSCAN, ipw2100_wx_get_scan), + IW_HANDLER(SIOCSIWESSID, ipw2100_wx_set_essid), + IW_HANDLER(SIOCGIWESSID, ipw2100_wx_get_essid), + IW_HANDLER(SIOCSIWNICKN, ipw2100_wx_set_nick), + IW_HANDLER(SIOCGIWNICKN, ipw2100_wx_get_nick), + IW_HANDLER(SIOCSIWRATE, ipw2100_wx_set_rate), + IW_HANDLER(SIOCGIWRATE, ipw2100_wx_get_rate), + IW_HANDLER(SIOCSIWRTS, ipw2100_wx_set_rts), + IW_HANDLER(SIOCGIWRTS, ipw2100_wx_get_rts), + IW_HANDLER(SIOCSIWFRAG, ipw2100_wx_set_frag), + IW_HANDLER(SIOCGIWFRAG, ipw2100_wx_get_frag), + IW_HANDLER(SIOCSIWTXPOW, ipw2100_wx_set_txpow), + IW_HANDLER(SIOCGIWTXPOW, ipw2100_wx_get_txpow), + IW_HANDLER(SIOCSIWRETRY, ipw2100_wx_set_retry), + IW_HANDLER(SIOCGIWRETRY, ipw2100_wx_get_retry), + IW_HANDLER(SIOCSIWENCODE, ipw2100_wx_set_encode), + IW_HANDLER(SIOCGIWENCODE, ipw2100_wx_get_encode), + IW_HANDLER(SIOCSIWPOWER, ipw2100_wx_set_power), + IW_HANDLER(SIOCGIWPOWER, ipw2100_wx_get_power), + IW_HANDLER(SIOCSIWGENIE, ipw2100_wx_set_genie), + IW_HANDLER(SIOCGIWGENIE, ipw2100_wx_get_genie), + IW_HANDLER(SIOCSIWAUTH, ipw2100_wx_set_auth), + IW_HANDLER(SIOCGIWAUTH, ipw2100_wx_get_auth), + IW_HANDLER(SIOCSIWENCODEEXT, ipw2100_wx_set_encodeext), + IW_HANDLER(SIOCGIWENCODEEXT, ipw2100_wx_get_encodeext), }; #define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV -- GitLab From d4ca00992ce0809e8cfdc452aa3f972e3be72654 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 24 Feb 2012 09:22:27 +0300 Subject: [PATCH 1176/1846] brcm80211: fmac: fix a couple checking after dereference bugs There were two dereferencing before checking for NULL static checker complaints in this new file. The list cursor is never NULL so that check can be removed. I moved the other dereference after the check. Signed-off-by: Dan Carpenter Acked-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 934ed782620c..7c54d1db4a44 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -482,7 +482,7 @@ static void brcmf_usb_free_q(struct list_head *q, bool pending) struct brcmf_usbreq *req, *next; int i = 0; list_for_each_entry_safe(req, next, q, list) { - if (!req || !req->urb) { + if (!req->urb) { brcmf_dbg(ERROR, "bad req\n"); break; } @@ -712,12 +712,12 @@ static int brcmf_usb_up(struct device *dev) struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); u16 ifnum; - if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP) - return 0; - if (devinfo == NULL) return -EINVAL; + if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP) + return 0; + /* If the USB/HSIC bus in sleep state, wake it up */ if (devinfo->suspend_state == USBOS_SUSPEND_STATE_SUSPENDED) { if (brcmf_usb_pnp(devinfo, BCMFMAC_USB_PNP_RESUME) != 0) { -- GitLab From fda82417884eecd9f2c8b4e6bb2039def0da7ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 24 Feb 2012 07:22:51 +0100 Subject: [PATCH 1177/1846] brcm80211: fmac: use correct firmware filename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also don't use so generic BRCMF_USB_FW_NAME as we may need different firmwares in the future. Signed-off-by: Rafał Miłecki Acked-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 7c54d1db4a44..d4a9e8e7deb3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -65,7 +65,7 @@ #define BRCMF_USB_CBCTL_READ 1 #define BRCMF_USB_MAX_PKT_SIZE 1600 -#define BRCMF_USB_FW_NAME "brcm/brcmfmac-usb.bin" +#define BRCMF_USB_43236_FW_NAME "brcm/brcmfmac43236b.bin" enum usbdev_suspend_state { USBOS_SUSPEND_STATE_DEVICE_ACTIVE = 0, /* Device is busy, won't allow @@ -1229,7 +1229,7 @@ static int brcmf_usb_get_fw(struct brcmf_usbdev_info *devinfo) if (devinfo->image) return 0; - fwname = BRCMF_USB_FW_NAME; + fwname = BRCMF_USB_43236_FW_NAME; err = request_firmware(&fw, fwname, devinfo->dev); if (!fw) { @@ -1596,7 +1596,7 @@ static struct usb_device_id brcmf_usb_devid_table[] = { { } }; MODULE_DEVICE_TABLE(usb, brcmf_usb_devid_table); -MODULE_FIRMWARE(BRCMF_USB_FW_NAME); +MODULE_FIRMWARE(BRCMF_USB_43236_FW_NAME); /* TODO: suspend and resume entries */ static struct usb_driver brcmf_usbdrvr = { -- GitLab From 54e4ffb2abb3c086637cbc75a2bfe55a8ce987c8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 25 Feb 2012 21:48:08 +0100 Subject: [PATCH 1178/1846] mac80211: fix auth/assoc data & timer leak When removing an interface while it is in the process of authenticating or associating, we leak the auth_data or assoc_data, and leave the timer pending. The timer then crashes the system when it fires as its data is gone. Fix this by explicitly deleting all the data when the interface is removed. This uncovered another bug -- this problem should have been detected by the sta_info_flush() warning but that function doesn't ever return non-zero, I'll fix that in a separate patch. Reported-by: Hieu Nguyen Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/iface.c | 2 ++ net/mac80211/mlme.c | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 67aed1eff135..4a722b10b4dd 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1178,6 +1178,7 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata); void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata); +void ieee80211_mgd_teardown(struct ieee80211_sub_if_data *sdata); /* IBSS code */ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local); diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 6b3cd65d1e07..60b240ce709e 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -644,6 +644,8 @@ static void ieee80211_teardown_sdata(struct net_device *dev) if (ieee80211_vif_is_mesh(&sdata->vif)) mesh_rmc_free(sdata); + else if (sdata->vif.type == NL80211_IFTYPE_STATION) + ieee80211_mgd_teardown(sdata); flushed = sta_info_flush(local, sdata); WARN_ON(flushed); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 1495fb99b379..0c220e1b6c9c 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3513,6 +3513,19 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, return 0; } +void ieee80211_mgd_teardown(struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + + mutex_lock(&ifmgd->mtx); + if (ifmgd->assoc_data) + ieee80211_destroy_assoc_data(sdata, false); + if (ifmgd->auth_data) + ieee80211_destroy_auth_data(sdata, false); + del_timer_sync(&ifmgd->timer); + mutex_unlock(&ifmgd->mtx); +} + void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, enum nl80211_cqm_rssi_threshold_event rssi_event, gfp_t gfp) -- GitLab From 3431683759596409427b6726e582f3ee66082728 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 25 Feb 2012 21:40:46 +0100 Subject: [PATCH 1179/1846] mac80211: fix sta_info_flush() return value The comment for sta_info_flush() states "Returns the number of removed STA entries" but that isn't actually true. Consequently, the warning when a station is still around on interface removal can never trigger and this delayed finding the timer issue the previous patch fixed. Fix the return value here to make that warning useful again. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/sta_info.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 4034ee616022..98613c8f08cf 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -865,8 +865,10 @@ int sta_info_flush(struct ieee80211_local *local, mutex_lock(&local->sta_mtx); list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { - if (!sdata || sdata == sta->sdata) + if (!sdata || sdata == sta->sdata) { WARN_ON(__sta_info_destroy(sta)); + ret++; + } } mutex_unlock(&local->sta_mtx); -- GitLab From 005e472b45131250fe09c194f8b872b86fd266c1 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 26 Feb 2012 11:24:35 +0100 Subject: [PATCH 1180/1846] mac80211: remove local_to_hw That's a lot longer than open-coding it and doesn't really add value, so just remove it. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ieee80211_i.h | 6 ------ net/mac80211/main.c | 6 +++--- net/mac80211/tx.c | 2 +- net/mac80211/util.c | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4a722b10b4dd..4d1682950a60 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1128,12 +1128,6 @@ static inline struct ieee80211_local *hw_to_local( return container_of(hw, struct ieee80211_local, hw); } -static inline struct ieee80211_hw *local_to_hw( - struct ieee80211_local *local) -{ - return &local->hw; -} - static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr) { diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 2306d7514fff..36fa8051296c 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -286,11 +286,11 @@ static void ieee80211_tasklet_handler(unsigned long data) /* Clear skb->pkt_type in order to not confuse kernel * netstack. */ skb->pkt_type = 0; - ieee80211_rx(local_to_hw(local), skb); + ieee80211_rx(&local->hw, skb); break; case IEEE80211_TX_STATUS_MSG: skb->pkt_type = 0; - ieee80211_tx_status(local_to_hw(local), skb); + ieee80211_tx_status(&local->hw, skb); break; case IEEE80211_EOSP_MSG: eosp_data = (void *)skb->cb; @@ -668,7 +668,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, ieee80211_hw_roc_setup(local); - return local_to_hw(local); + return &local->hw; } EXPORT_SYMBOL(ieee80211_alloc_hw); diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index c6eadac9ca4e..7c021f255716 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -625,7 +625,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx) tx->local->hw.wiphy->frag_threshold); /* set up the tx rate control struct we give the RC algo */ - txrc.hw = local_to_hw(tx->local); + txrc.hw = &tx->local->hw; txrc.sband = sband; txrc.bss_conf = &tx->sdata->vif.bss_conf; txrc.skb = tx->skb; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 264397aee811..f6e4cef92021 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -753,7 +753,7 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata) use_11b = (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) && !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); - for (queue = 0; queue < local_to_hw(local)->queues; queue++) { + for (queue = 0; queue < local->hw.queues; queue++) { /* Set defaults according to 802.11-2007 Table 7-37 */ aCWmax = 1023; if (use_11b) -- GitLab From c143189ada745eb3f6c1a38fd8c5af4b4cbcdff1 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Sun, 26 Feb 2012 18:40:04 +0100 Subject: [PATCH 1181/1846] mac80211_hwsim: correctly line up a multiline printk The second line of a printk statement must line up to the opening bracket. Signed-off-by: Antonio Quartulli Signed-off-by: John W. Linville --- drivers/net/wireless/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 29e930a669ae..ba16f05df0fc 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -1580,7 +1580,7 @@ static int hwsim_register_received_nl(struct sk_buff *skb_2, wmediumd_pid = info->snd_pid; printk(KERN_DEBUG "mac80211_hwsim: received a REGISTER, " - "switching to wmediumd mode with pid %d\n", info->snd_pid); + "switching to wmediumd mode with pid %d\n", info->snd_pid); return 0; out: -- GitLab From 2530c55ea9a397c4e5f41c0820084dfc27441d14 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 15 Feb 2012 18:55:16 +0100 Subject: [PATCH 1182/1846] iwlwifi: iwl-agn.h included twice drivers/net/wireless/iwlwifi/iwl-core.c included 'iwl-agn.h' twice, remove the duplicate. Signed-off-by: Danny Kukawka Acked-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f3b72bc84d25..f52d5458a3af 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -38,7 +38,6 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-power.h" -#include "iwl-agn.h" #include "iwl-shared.h" #include "iwl-agn.h" #include "iwl-trans.h" -- GitLab From 09a3311c1a061bda809ff78c512855f3b71dcd6b Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Wed, 22 Feb 2012 21:58:57 +0100 Subject: [PATCH 1183/1846] rt2800: Add documentation on MCU requests Add documentation on MCU communication, some of known commands and their arguments. Supplement command ids. Signed-off-by: Jakub Kicinski Acked-by: Ivo van Doorn Acked-by: Gertjan van Wingerde Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 15 ++++++++++++++- drivers/net/wireless/rt2x00/rt2800pci.c | 8 +++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index 3b32f847c834..e5c05d8c7448 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -1637,6 +1637,7 @@ struct mac_iveiv_entry { /* * H2M_MAILBOX_CSR: Host-to-MCU Mailbox. + * CMD_TOKEN: Command id, 0xff disable status reporting. */ #define H2M_MAILBOX_CSR 0x7010 #define H2M_MAILBOX_CSR_ARG0 FIELD32(0x000000ff) @@ -1646,6 +1647,8 @@ struct mac_iveiv_entry { /* * H2M_MAILBOX_CID: + * Free slots contain 0xff. MCU will store command's token to lowest free slot. + * If all slots are occupied status will be dropped. */ #define H2M_MAILBOX_CID 0x7014 #define H2M_MAILBOX_CID_CMD0 FIELD32(0x000000ff) @@ -1655,6 +1658,7 @@ struct mac_iveiv_entry { /* * H2M_MAILBOX_STATUS: + * Command status will be saved to same slot as command id. */ #define H2M_MAILBOX_STATUS 0x701c @@ -2298,6 +2302,12 @@ struct mac_iveiv_entry { /* * MCU mailbox commands. + * MCU_SLEEP - go to power-save mode. + * arg1: 1: save as much power as possible, 0: save less power. + * status: 1: success, 2: already asleep, + * 3: maybe MAC is busy so can't finish this task. + * MCU_RADIO_OFF + * arg0: 0: do power-saving, NOT turn off radio. */ #define MCU_SLEEP 0x30 #define MCU_WAKEUP 0x31 @@ -2318,7 +2328,10 @@ struct mac_iveiv_entry { /* * MCU mailbox tokens */ -#define TOKEN_WAKUP 3 +#define TOKEN_SLEEP 1 +#define TOKEN_RADIO_OFF 2 +#define TOKEN_WAKEUP 3 + /* * DMA descriptor defines. diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index b45ce7605667..627fc2214cd3 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -522,14 +522,16 @@ static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state) { if (state == STATE_AWAKE) { - rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKUP, 0, 0x02); - rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKUP); + rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP, + 0, 0x02); + rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP); } else if (state == STATE_SLEEP) { rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, 0xffffffff); rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, 0xffffffff); - rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0x01, 0xff, 0x01); + rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_SLEEP, + 0xff, 0x01); } return 0; -- GitLab From e8b461c37717d6b5c071c4924845884a86c20752 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Wed, 22 Feb 2012 21:58:58 +0100 Subject: [PATCH 1184/1846] rt2800pci: Fix 'Error - MCU request failed' during initialization Bring MCU operations during device initialization to sync with legacy driver. This should fix following error: phy0 -> rt2800pci_mcu_status: Error - MCU request failed, no response from hardware Signed-off-by: Jakub Kicinski Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800pci.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 627fc2214cd3..9375db455456 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -502,11 +502,27 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev) static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev) { + int retval; + if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) || rt2800pci_init_queues(rt2x00dev))) return -EIO; - return rt2800_enable_radio(rt2x00dev); + retval = rt2800_enable_radio(rt2x00dev); + if (retval) + return retval; + + /* After resume MCU_BOOT_SIGNAL will trash these. */ + rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0); + rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0); + + rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_RADIO_OFF, 0xff, 0x02); + rt2800pci_mcu_status(rt2x00dev, TOKEN_RADIO_OFF); + + rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP, 0, 0); + rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP); + + return retval; } static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev) @@ -544,13 +560,6 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev, switch (state) { case STATE_RADIO_ON: - /* - * Before the radio can be enabled, the device first has - * to be woken up. After that it needs a bit of time - * to be fully awake and then the radio can be enabled. - */ - rt2800pci_set_state(rt2x00dev, STATE_AWAKE); - msleep(1); retval = rt2800pci_enable_radio(rt2x00dev); break; case STATE_RADIO_OFF: -- GitLab From 5bd49735db39c1c1360cb91b1f1e1c999d90eb94 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 27 Feb 2012 14:12:07 -0500 Subject: [PATCH 1185/1846] gigaset: Use semicolons to terminate statements Commas are not generally used at locations where statement termination semicolons are used. Realign each field set at appropriate indentation. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/isdn/gigaset/interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index da2486e59102..b826dac7c845 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -679,10 +679,10 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, if (tty == NULL) goto enomem; - tty->magic = TTY_DRIVER_MAGIC, - tty->type = TTY_DRIVER_TYPE_SERIAL, - tty->subtype = SERIAL_TYPE_NORMAL, - tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + tty->magic = TTY_DRIVER_MAGIC; + tty->type = TTY_DRIVER_TYPE_SERIAL; + tty->subtype = SERIAL_TYPE_NORMAL; + tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; tty->driver_name = procname; tty->name = devname; -- GitLab From e9daccd732971b5d0268a0b858b5d14f6b6a9d86 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 08:42:43 +0200 Subject: [PATCH 1186/1846] iwlwifi: parse_tlv functions set the fw_version string struct iwl_fw contains a string that describe the fw. This string is now set by the iwl_parse_*_firmware. This string is later used to update the cfg80211 data. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-ucode.c | 70 ++++++++++++++---------- drivers/net/wireless/iwlwifi/iwl-ucode.h | 5 +- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 61c6c0568c11..ea757098654d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -731,8 +731,6 @@ struct iwlagn_firmware_pieces { size_t inst_size, data_size, init_size, init_data_size, wowlan_inst_size, wowlan_data_size; - u32 build; - u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; }; @@ -742,7 +740,8 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, struct iwlagn_firmware_pieces *pieces) { struct iwl_ucode_header *ucode = (void *)ucode_raw->data; - u32 api_ver, hdr_size; + u32 api_ver, hdr_size, build; + char buildstr[25]; const u8 *src; nic->fw.ucode_ver = le32_to_cpu(ucode->ver); @@ -755,7 +754,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, IWL_ERR(nic, "File size too small!\n"); return -EINVAL; } - pieces->build = le32_to_cpu(ucode->u.v2.build); + build = le32_to_cpu(ucode->u.v2.build); pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); @@ -770,7 +769,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, IWL_ERR(nic, "File size too small!\n"); return -EINVAL; } - pieces->build = 0; + build = 0; pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); @@ -779,6 +778,22 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, break; } + if (build) + sprintf(buildstr, " build %u%s", build, + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? " (EXP)" : ""); + else + buildstr[0] = '\0'; + + snprintf(nic->fw.fw_version, + sizeof(nic->fw.fw_version), + "%u.%u.%u.%u%s", + IWL_UCODE_MAJOR(nic->fw.ucode_ver), + IWL_UCODE_MINOR(nic->fw.ucode_ver), + IWL_UCODE_API(nic->fw.ucode_ver), + IWL_UCODE_SERIAL(nic->fw.ucode_ver), + buildstr); + /* 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 + @@ -817,6 +832,8 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, u32 tlv_len; enum iwl_ucode_tlv_type tlv_type; const u8 *tlv_data; + char buildstr[25]; + u32 build; if (len < sizeof(*ucode)) { IWL_ERR(nic, "uCode has invalid length: %zd\n", len); @@ -847,7 +864,24 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, tmp, wanted_alternative); nic->fw.ucode_ver = le32_to_cpu(ucode->ver); - pieces->build = le32_to_cpu(ucode->build); + build = le32_to_cpu(ucode->build); + + if (build) + sprintf(buildstr, " build %u%s", build, + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? " (EXP)" : ""); + else + buildstr[0] = '\0'; + + snprintf(nic->fw.fw_version, + sizeof(nic->fw.fw_version), + "%u.%u.%u.%u%s", + IWL_UCODE_MAJOR(nic->fw.ucode_ver), + IWL_UCODE_MINOR(nic->fw.ucode_ver), + IWL_UCODE_API(nic->fw.ucode_ver), + IWL_UCODE_SERIAL(nic->fw.ucode_ver), + buildstr); + data = ucode->data; len -= sizeof(*ucode); @@ -1021,8 +1055,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) unsigned int api_ok = cfg->ucode_api_ok; const unsigned int api_min = cfg->ucode_api_min; u32 api_ver; - char buildstr[25]; - u32 build; fw->ucode_capa.max_probe_length = 200; fw->ucode_capa.standard_phy_calibration_size = @@ -1063,7 +1095,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) goto try_again; api_ver = IWL_UCODE_API(nic->fw.ucode_ver); - build = pieces.build; /* * api_ver should match the api version forming part of the @@ -1094,28 +1125,11 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) } } - if (build) - sprintf(buildstr, " build %u%s", build, - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) - ? " (EXP)" : ""); - else - buildstr[0] = '\0'; - - IWL_INFO(nic, "loaded firmware version %u.%u.%u.%u%s\n", - IWL_UCODE_MAJOR(nic->fw.ucode_ver), - IWL_UCODE_MINOR(nic->fw.ucode_ver), - IWL_UCODE_API(nic->fw.ucode_ver), - IWL_UCODE_SERIAL(nic->fw.ucode_ver), - buildstr); + IWL_INFO(nic, "loaded firmware version %s", nic->fw.fw_version); snprintf(priv->hw->wiphy->fw_version, sizeof(priv->hw->wiphy->fw_version), - "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(nic->fw.ucode_ver), - IWL_UCODE_MINOR(nic->fw.ucode_ver), - IWL_UCODE_API(nic->fw.ucode_ver), - IWL_UCODE_SERIAL(nic->fw.ucode_ver), - buildstr); + "%s", nic->fw.fw_version); /* * For any of the failures below (before allocating pci memory) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-ucode.h index d13e6241f126..8bebeb003bef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.h +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.h @@ -204,9 +204,8 @@ struct fw_img { */ struct iwl_fw { - /* ucode image and variables */ - u32 ucode_ver; /* version of ucode, copy of - iwl_ucode.ver */ + u32 ucode_ver; + char fw_version[ETHTOOL_BUSINFO_LEN]; /* ucode images */ -- GitLab From e211b2427a61e92e5a6bdd629bc2c2e6114c2dc1 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 7 Feb 2012 10:35:18 +0200 Subject: [PATCH 1187/1846] iwlwifi: move content of iwl_probe to post fetch_fw This will allow to have different behavior depending on the fw. Different fw APIs require completely different implementation of the mac80211 APIs. Each of these implementations is called an op_mode. The current op_mode is called DVM which states for dual virtual MAC. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 53 +++++++++++++++++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 3 ++ drivers/net/wireless/iwlwifi/iwl-ucode.c | 64 +++++------------------ drivers/net/wireless/iwlwifi/iwl-wifi.h | 2 + 4 files changed, 67 insertions(+), 55 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index e8fed167f97e..5e476a80bd8c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1142,9 +1142,11 @@ static void iwl_debug_config(struct iwl_priv *priv) #endif } -int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, - struct iwl_cfg *cfg) +int iwl_op_mode_dvm_start(struct iwl_bus *bus, + const struct iwl_trans_ops *trans_ops, + struct iwl_cfg *cfg) { + struct iwl_fw *fw = &nic(bus)->fw; int err = 0; struct iwl_priv *priv; struct ieee80211_hw *hw; @@ -1172,7 +1174,6 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_debug_config(priv); IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); - cfg(priv) = cfg; /* is antenna coupling more than 35dB ? */ priv->bt_ant_couple_ok = @@ -1260,12 +1261,44 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, iwl_power_initialize(priv); iwl_tt_initialize(priv); - init_completion(&nic(priv)->request_firmware_complete); + snprintf(priv->hw->wiphy->fw_version, + sizeof(priv->hw->wiphy->fw_version), + "%s", fw->fw_version); + + priv->new_scan_threshold_behaviour = + !!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); - err = iwl_request_firmware(nic(priv), true); + if (fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { + priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; + priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; + } else { + priv->sta_key_max_num = STA_KEY_MAX_NUM; + priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; + } + + priv->phy_calib_chain_noise_reset_cmd = + fw->ucode_capa.standard_phy_calibration_size; + priv->phy_calib_chain_noise_gain_cmd = + fw->ucode_capa.standard_phy_calibration_size + 1; + + /* initialize all valid contexts */ + iwl_init_context(priv, fw->ucode_capa.flags); + + /************************************************** + * This is still part of probe() in a sense... + * + * 9. Setup and register with mac80211 and debugfs + **************************************************/ + err = iwlagn_mac_setup_register(priv, &fw->ucode_capa); if (err) goto out_destroy_workqueue; + err = iwl_dbgfs_register(priv, DRV_NAME); + if (err) + IWL_ERR(priv, + "failed to create debugfs files. Ignoring error: %d\n", + err); + return 0; out_destroy_workqueue: @@ -1281,6 +1314,16 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, return err; } +int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, + struct iwl_cfg *cfg) +{ + bus->shrd->cfg = cfg; + + init_completion(&nic(bus)->request_firmware_complete); + + return iwl_request_firmware(nic(bus), true); +} + void __devexit iwl_remove(struct iwl_priv * priv) { wait_for_completion(&nic(priv)->request_firmware_complete); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index f810b41db9df..cf593b086149 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -532,6 +532,9 @@ enum iwl_rxon_context_id { NUM_IWL_RXON_CTX }; +int iwl_op_mode_dvm_start(struct iwl_bus *bus, + const struct iwl_trans_ops *trans_ops, + struct iwl_cfg *cfg); int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, struct iwl_cfg *cfg); void __devexit iwl_remove(struct iwl_priv * priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index ea757098654d..99f89b27f42c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -687,7 +687,6 @@ int iwl_run_init_ucode(struct iwl_trans *trans) static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); -#define UCODE_EXPERIMENTAL_INDEX 100 #define UCODE_EXPERIMENTAL_TAG "exp" int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first) @@ -1047,7 +1046,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) struct iwl_nic *nic = context; struct iwl_cfg *cfg = cfg(nic); struct iwl_fw *fw = &nic->fw; - struct iwl_priv *priv = priv(nic); /* temporary */ struct iwl_ucode_header *ucode; int err; struct iwlagn_firmware_pieces pieces; @@ -1127,10 +1125,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) IWL_INFO(nic, "loaded firmware version %s", nic->fw.fw_version); - snprintf(priv->hw->wiphy->fw_version, - sizeof(priv->hw->wiphy->fw_version), - "%s", nic->fw.fw_version); - /* * For any of the failures below (before allocating pci memory) * we will try to load a version with a smaller API -- maybe the @@ -1235,27 +1229,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) #ifndef CONFIG_IWLWIFI_P2P fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; #endif - - priv->new_scan_threshold_behaviour = - !!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); - - if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) - fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; - - /* - * if not PAN, then don't support P2P -- might be a uCode - * packaging bug or due to the eeprom check above - */ - if (!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) - fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; - - if (fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { - priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; - nic->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; - } else { - priv->sta_key_max_num = STA_KEY_MAX_NUM; - nic->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 @@ -1265,47 +1238,38 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) fw->ucode_capa.standard_phy_calibration_size = IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; - priv->phy_calib_chain_noise_reset_cmd = - fw->ucode_capa.standard_phy_calibration_size; - priv->phy_calib_chain_noise_gain_cmd = - fw->ucode_capa.standard_phy_calibration_size + 1; - - /* initialize all valid contexts */ - iwl_init_context(priv, fw->ucode_capa.flags); - - /************************************************** - * This is still part of probe() in a sense... - * - * 9. Setup and register with mac80211 and debugfs - **************************************************/ - err = iwlagn_mac_setup_register(priv, &fw->ucode_capa); - if (err) - goto out_unbind; + if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) + fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; - err = iwl_dbgfs_register(priv, DRV_NAME); - if (err) - IWL_ERR(nic, - "failed to create debugfs files. Ignoring error: %d\n", - err); + /* + * if not PAN, then don't support P2P -- might be a uCode + * packaging bug or due to the eeprom check above + */ + if (!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) + fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); complete(&nic->request_firmware_complete); + + if (iwl_op_mode_dvm_start(bus(nic), trans(nic)->ops, cfg)) + goto out_unbind; + return; try_again: /* try next, if any */ + release_firmware(ucode_raw); if (iwl_request_firmware(nic, false)) goto out_unbind; - release_firmware(ucode_raw); return; err_pci_alloc: IWL_ERR(nic, "failed to allocate pci memory\n"); iwl_dealloc_ucode(nic); + release_firmware(ucode_raw); out_unbind: complete(&nic->request_firmware_complete); device_release_driver(trans(nic)->dev); - release_firmware(ucode_raw); } diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index 84172f6de4bb..a78120e89fe1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -66,6 +66,8 @@ #include "iwl-shared.h" #include "iwl-ucode.h" +#define UCODE_EXPERIMENTAL_INDEX 100 + /** * struct iwl_nic - nic common data * @fw: the iwl_fw structure -- GitLab From a78be210d53b24cc3437d4362912c510b895a8eb Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 21 Feb 2012 18:31:06 +0200 Subject: [PATCH 1188/1846] iwlwifi: move uCode flags handling to op_mode The uCode flags modification is op_mode dependent since the P2P config is an op-mode config. This also fixes P2P enabling: due to the uCode loading code shuffle moving the SKU check before the EEPROM was read it was always false and would always disable PAN/P2P. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 23 ++++++++++++++++++++--- drivers/net/wireless/iwlwifi/iwl-ucode.c | 14 +------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 5e476a80bd8c..d70dd6fff4f5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1151,6 +1151,7 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, struct iwl_priv *priv; struct ieee80211_hw *hw; u16 num_mac; + u32 ucode_flags; /************************ * 1. Allocating HW data @@ -1242,6 +1243,22 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, ************************/ iwl_set_hw_params(priv); + ucode_flags = fw->ucode_capa.flags; + +#ifndef CONFIG_IWLWIFI_P2P + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; +#endif + if (!(hw_params(priv).sku & EEPROM_SKU_CAP_IPAN_ENABLE)) + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; + + /* + * if not PAN, then don't support P2P -- might be a uCode + * packaging bug or due to the eeprom check above + */ + if (!(ucode_flags & IWL_UCODE_TLV_FLAGS_PAN)) + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; + + /******************* * 6. Setup priv *******************/ @@ -1266,9 +1283,9 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, "%s", fw->fw_version); priv->new_scan_threshold_behaviour = - !!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); + !!(ucode_flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); - if (fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { + if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) { priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; } else { @@ -1282,7 +1299,7 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, fw->ucode_capa.standard_phy_calibration_size + 1; /* initialize all valid contexts */ - iwl_init_context(priv, fw->ucode_capa.flags); + iwl_init_context(priv, ucode_flags); /************************************************** * This is still part of probe() in a sense... diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 99f89b27f42c..3645bf3d61c6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -1226,9 +1226,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) nic->inst_evtlog_size = cfg->base_params->max_event_log_size; nic->inst_errlog_ptr = pieces.inst_errlog_ptr; -#ifndef CONFIG_IWLWIFI_P2P - fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; -#endif + /* * figure out the offset of chain noise reset and gain commands * base on the size of standard phy calibration commands table size @@ -1238,16 +1236,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) fw->ucode_capa.standard_phy_calibration_size = IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; - if (!(cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) - fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; - - /* - * if not PAN, then don't support P2P -- might be a uCode - * packaging bug or due to the eeprom check above - */ - if (!(fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) - fw->ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_P2P; - /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); complete(&nic->request_firmware_complete); -- GitLab From 5c58edc63edd6cd8097e2bee90e2d341e33bcd60 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 7 Feb 2012 14:18:40 +0200 Subject: [PATCH 1189/1846] iwlwifi: introducing the drv object's flows Fetch the fw and spawn the op_mode. The op_mode that we need to fetch is determined from the fw file. Since the fw is fetched very early in the init flow, we can determine what op_mode to spawn. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/Makefile | 1 + drivers/net/wireless/iwlwifi/iwl-agn.c | 10 -- drivers/net/wireless/iwlwifi/iwl-drv.c | 94 ++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-drv.h | 110 ++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-pci.c | 22 +---- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 - 6 files changed, 210 insertions(+), 29 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-drv.c create mode 100644 drivers/net/wireless/iwlwifi/iwl-drv.h diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index 46622a0f017b..afa0bb8f3245 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -13,6 +13,7 @@ iwlwifi-objs += iwl-6000.o iwlwifi-objs += iwl-1000.o iwlwifi-objs += iwl-2000.o iwlwifi-objs += iwl-pci.o +iwlwifi-objs += iwl-drv.o iwlwifi-objs += iwl-trans.o iwlwifi-objs += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index d70dd6fff4f5..8bb97c91b102 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1331,16 +1331,6 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, return err; } -int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, - struct iwl_cfg *cfg) -{ - bus->shrd->cfg = cfg; - - init_completion(&nic(bus)->request_firmware_complete); - - return iwl_request_firmware(nic(bus), true); -} - void __devexit iwl_remove(struct iwl_priv * priv) { wait_for_completion(&nic(priv)->request_firmware_complete); diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c new file mode 100644 index 000000000000..49f7e70bc362 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -0,0 +1,94 @@ +/****************************************************************************** + * + * 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) 2007 - 2012 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 - 2012 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 "iwl-drv.h" +#include "iwl-trans.h" +#include "iwl-wifi.h" + +int iwl_drv_start(struct iwl_shared *shrd, + struct iwl_trans *trans, struct iwl_cfg *cfg) +{ + int ret; + + shrd->cfg = cfg; + + shrd->nic = kzalloc(sizeof(*shrd->nic), GFP_KERNEL); + if (!shrd->nic) { + dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_nic"); + return -ENOMEM; + } + shrd->nic->shrd = shrd; + + init_completion(&shrd->nic->request_firmware_complete); + + ret = iwl_request_firmware(shrd->nic, true); + + if (ret) { + dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw"); + kfree(shrd->nic); + } + + return ret; +} + diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.h b/drivers/net/wireless/iwlwifi/iwl-drv.h new file mode 100644 index 000000000000..c40545199224 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-drv.h @@ -0,0 +1,110 @@ +/****************************************************************************** + * + * 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 - 2012 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 - 2012 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 __iwl_drv_h__ +#define __iwl_drv_h__ + +#include "iwl-shared.h" + +/** + * DOC: Driver system flows - drv component + * + * This component implements the system flows such as bus enumeration, bus + * removal. Bus dependent parts of system flows (such as iwl_pci_probe) are in + * bus specific files (transport files). This is the code that is common among + * different buses. + * + * This component is also in charge of managing the several implementations of + * the wifi flows: it will allow to have several fw API implementation. These + * different implementations will differ in the way they implement mac80211's + * handlers too. + + * The init flow wrt to the drv component looks like this: + * 1) The bus specific component is called from module_init + * 2) The bus specific component registers the bus driver + * 3) The bus driver calls the probe function + * 4) The bus specific component configures the bus + * 5) The bus specific component calls to the drv bus agnostic part + * (iwl_drv_start) + * 6) iwl_drv_start fetches the fw ASYNC, iwl_ucode_callback + * 7) iwl_ucode_callback parses the fw file + * 8) iwl_ucode_callback starts the wifi implementation to matches the fw + */ + +/** + * iwl_drv_start - start the drv + * + * @shrd: the shrd area + * @trans_ops: the ops of the transport + * @cfg: device specific constants / virtual functions + * + * TODO: review the parameters given to this function + * + * starts the driver: fetches the firmware. This should be called by bus + * specific system flows implementations. For example, the bus specific probe + * function should do bus related operations only, and then call to this + * function. + */ +int iwl_drv_start(struct iwl_shared *shrd, + struct iwl_trans *trans, struct iwl_cfg *cfg); + +#endif /* __iwl_drv_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 519067020534..e2695445dfac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -70,7 +70,7 @@ #include "iwl-trans.h" #include "iwl-csr.h" #include "iwl-cfg.h" -#include "iwl-wifi.h" +#include "iwl-drv.h" #define IWL_PCI_DEVICE(dev, subdev, cfg) \ .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ @@ -283,34 +283,24 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) bus->shrd->bus = bus; - /* temporarily create this here */ - bus->shrd->nic = kzalloc(sizeof(*bus->shrd->nic), GFP_KERNEL); - if (!bus->shrd->nic) { - dev_printk(KERN_ERR, &pdev->dev, - "Couldn't allocate iwl_nic"); - err = -ENOMEM; - goto out_free_bus; - } - /* and initialize it as well, temporarily */ - bus->shrd->nic->shrd = bus->shrd; pci_set_drvdata(pdev, bus); #ifdef CONFIG_IWLWIFI_IDI trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { err = -ENOMEM; - goto out_free_nic; + goto out_free_bus; } - err = iwl_probe(bus, &trans_ops_idi, cfg); + err = iwl_drv_start(bus->shrd, trans(bus), cfg); #else trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent); if (trans(bus) == NULL) { err = -ENOMEM; - goto out_free_nic; + goto out_free_bus; } - err = iwl_probe(bus, &trans_ops_pcie, cfg); + err = iwl_drv_start(bus->shrd, trans(bus), cfg); #endif if (err) goto out_free_trans; @@ -320,8 +310,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_free_trans: iwl_trans_free(trans(bus)); pci_set_drvdata(pdev, NULL); -out_free_nic: - kfree(bus->shrd->nic); out_free_bus: kfree(bus->shrd); kfree(bus); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index cf593b086149..d84beef10bdd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -535,8 +535,6 @@ enum iwl_rxon_context_id { int iwl_op_mode_dvm_start(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, struct iwl_cfg *cfg); -int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, - struct iwl_cfg *cfg); void __devexit iwl_remove(struct iwl_priv * priv); struct iwl_device_cmd; int __must_check iwl_rx_dispatch(struct iwl_priv *priv, -- GitLab From 07590f080d5f29e33158b22f7ad6079b85d87609 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Tue, 7 Feb 2012 14:27:31 +0200 Subject: [PATCH 1190/1846] iwlwifi: drv object can release its own memory Move that code to the iwl-drv.c Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-drv.c | 7 +++++++ drivers/net/wireless/iwlwifi/iwl-drv.h | 13 +++++++++++++ drivers/net/wireless/iwlwifi/iwl-pci.c | 3 +-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 49f7e70bc362..b3876dec52af 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -92,3 +92,10 @@ int iwl_drv_start(struct iwl_shared *shrd, return ret; } +void iwl_drv_stop(struct iwl_shared *shrd) +{ + iwl_remove(shrd->priv); + + kfree(shrd->nic); +} + diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.h b/drivers/net/wireless/iwlwifi/iwl-drv.h index c40545199224..90534a23ddc8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.h +++ b/drivers/net/wireless/iwlwifi/iwl-drv.h @@ -107,4 +107,17 @@ int iwl_drv_start(struct iwl_shared *shrd, struct iwl_trans *trans, struct iwl_cfg *cfg); +/** + * iwl_drv_stop - stop the drv + * + * @shrd: the shrd area + * + * TODO: review the parameters given to this function + * + * Stop the driver. This should be called by bus specific system flows + * implementations. For example, the bus specific remove function should first + * call this function and then do the bus related operations only. + */ +void iwl_drv_stop(struct iwl_shared *shrd); + #endif /* __iwl_drv_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index e2695445dfac..b9cdd1ac1744 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -321,12 +321,11 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) struct iwl_bus *bus = pci_get_drvdata(pdev); struct iwl_shared *shrd = bus->shrd; - iwl_remove(shrd->priv); + iwl_drv_stop(shrd); iwl_trans_free(shrd->trans); pci_set_drvdata(pdev, NULL); - kfree(bus->shrd->nic); kfree(bus->shrd); kfree(bus); } -- GitLab From 6459f9871a1218f7a2e6385d1ae6c91e91f9d251 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 11:46:06 +0200 Subject: [PATCH 1191/1846] iwlwifi: rename iwl_remove to iwl_op_mode_dvm_stop iwl_remove stops the wifi flows, so rename. Moreover, we can possibly stop the wifi flows even if the driver is statically compiled in the kernel, so remove the __devexit pragma. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-drv.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8bb97c91b102..09f343cd405e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1331,7 +1331,7 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, return err; } -void __devexit iwl_remove(struct iwl_priv * priv) +void iwl_op_mode_dvm_stop(struct iwl_priv *priv) { wait_for_completion(&nic(priv)->request_firmware_complete); diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index b3876dec52af..db430c7d27d7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -94,7 +94,7 @@ int iwl_drv_start(struct iwl_shared *shrd, void iwl_drv_stop(struct iwl_shared *shrd) { - iwl_remove(shrd->priv); + iwl_op_mode_dvm_stop(shrd->priv); kfree(shrd->nic); } diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index d84beef10bdd..392b33a59410 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -535,7 +535,7 @@ enum iwl_rxon_context_id { int iwl_op_mode_dvm_start(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, struct iwl_cfg *cfg); -void __devexit iwl_remove(struct iwl_priv * priv); +void iwl_op_mode_dvm_stop(struct iwl_priv *priv); struct iwl_device_cmd; int __must_check iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, -- GitLab From d0f76d6869adad1f3757d102af47508be0642949 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 16:08:15 +0200 Subject: [PATCH 1192/1846] iwlwifi: virtualize the op_mode Define the op_mode as an interface with its ops. All the functions of the op_mode are "private", but its ops is made public in iwl-op-mode.h. The drv object starts the op_mode by using the start function in the public ops. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 16 ++- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 4 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 32 ++++-- drivers/net/wireless/iwlwifi/iwl-dev.h | 8 ++ drivers/net/wireless/iwlwifi/iwl-drv.c | 6 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 62 +++++------ drivers/net/wireless/iwlwifi/iwl-op-mode.h | 108 ++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 4 - drivers/net/wireless/iwlwifi/iwl-testmode.c | 20 ++-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 5 +- drivers/net/wireless/iwlwifi/iwl-wifi.h | 2 + 12 files changed, 204 insertions(+), 65 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-op-mode.h diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index c368433f8bc8..5be0d3695d03 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -959,7 +959,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, struct ieee80211_key_conf *key, void *_data) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct wowlan_key_data *data = _data; struct iwl_rxon_context *ctx = data->ctx; struct aes_sc *aes_sc, *aes_tx_sc = NULL; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index f88e2e33e2e8..a7d67135e3dc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -38,6 +38,7 @@ #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-agn.h" +#include "iwl-op-mode.h" #define RS_NAME "iwl-agn-rs" @@ -909,7 +910,8 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, struct iwl_lq_sta *lq_sta = priv_sta; struct iwl_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct iwl_priv *priv = (struct iwl_priv *)priv_r; + struct iwl_op_mode *op_mode = (struct iwl_op_mode *)priv_r; + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); enum mac80211_rate_control_flags mac_flags; u32 tx_rate; @@ -2737,7 +2739,9 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, 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 iwl_op_mode *op_mode __maybe_unused = + (struct iwl_op_mode *)priv_r; + struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct iwl_lq_sta *lq_sta = priv_sta; int rate_idx; @@ -2805,9 +2809,10 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, gfp_t gfp) { struct iwl_station_priv *sta_priv = (struct iwl_station_priv *) sta->drv_priv; - struct iwl_priv *priv; + struct iwl_op_mode *op_mode __maybe_unused = + (struct iwl_op_mode *)priv_rate; + struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode); - priv = (struct iwl_priv *)priv_rate; IWL_DEBUG_RATE(priv, "create station rate scale window\n"); return &sta_priv->lq_sta; @@ -3074,7 +3079,8 @@ static void rs_free(void *priv_rate) static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta, void *priv_sta) { - struct iwl_priv *priv __maybe_unused = priv_r; + struct iwl_op_mode *op_mode __maybe_unused = priv_r; + struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode); IWL_DEBUG_RATE(priv, "enter\n"); IWL_DEBUG_RATE(priv, "leave\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 35dd7e364b46..73653a6cf32d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -549,7 +549,7 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf, int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; @@ -805,7 +805,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_bss_conf *bss_conf, u32 changes) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); int ret; bool force = false; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 09f343cd405e..dbef0f48c3ef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -52,6 +52,7 @@ #include "iwl-shared.h" #include "iwl-bus.h" #include "iwl-trans.h" +#include "iwl-op-mode.h" /****************************************************************************** * @@ -1142,14 +1143,13 @@ static void iwl_debug_config(struct iwl_priv *priv) #endif } -int iwl_op_mode_dvm_start(struct iwl_bus *bus, - const struct iwl_trans_ops *trans_ops, - struct iwl_cfg *cfg) +static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) { - struct iwl_fw *fw = &nic(bus)->fw; + struct iwl_fw *fw = &nic(trans)->fw; int err = 0; struct iwl_priv *priv; struct ieee80211_hw *hw; + struct iwl_op_mode *op_mode; u16 num_mac; u32 ucode_flags; @@ -1158,18 +1158,21 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, ************************/ hw = iwl_alloc_all(); if (!hw) { - pr_err("%s: Cannot allocate network device\n", cfg->name); + pr_err("%s: Cannot allocate network device\n", + cfg(trans)->name); err = -ENOMEM; goto out; } - priv = hw->priv; - priv->shrd = bus->shrd; + op_mode = hw->priv; + op_mode->ops = &iwl_dvm_ops; + priv = IWL_OP_MODE_GET_DVM(op_mode); + priv->shrd = trans->shrd; priv->shrd->priv = priv; /* At this point both hw and priv are allocated. */ - SET_IEEE80211_DEV(hw, trans(priv)->dev); + SET_IEEE80211_DEV(priv->hw, trans(priv)->dev); /* show what debugging capabilities we have */ iwl_debug_config(priv); @@ -1316,7 +1319,7 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, "failed to create debugfs files. Ignoring error: %d\n", err); - return 0; + return op_mode; out_destroy_workqueue: destroy_workqueue(priv->workqueue); @@ -1328,11 +1331,14 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus, iwl_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); out: - return err; + op_mode = NULL; + return op_mode; } -void iwl_op_mode_dvm_stop(struct iwl_priv *priv) +static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) { + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + wait_for_completion(&nic(priv)->request_firmware_complete); IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); @@ -1374,6 +1380,10 @@ void iwl_op_mode_dvm_stop(struct iwl_priv *priv) ieee80211_free_hw(priv->hw); } +const struct iwl_op_mode_ops iwl_dvm_ops = { + .start = iwl_op_mode_dvm_start, + .stop = iwl_op_mode_dvm_stop, +}; /***************************************************************************** * diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 494c696dc177..479d3281a972 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -50,6 +50,7 @@ #include "iwl-bus.h" #include "iwl-trans.h" #include "iwl-shared.h" +#include "iwl-op-mode.h" struct iwl_tx_queue; @@ -710,6 +711,13 @@ struct iwl_wipan_noa_data { u8 data[]; }; +#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \ + ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific)) + +#define IWL_MAC80211_GET_DVM(_hw) \ + ((struct iwl_priv *) ((struct iwl_op_mode *) \ + (_hw)->priv)->op_mode_specific) + struct iwl_priv { /*data shared among all the driver's layers */ diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index db430c7d27d7..8ff52568cf6e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -65,6 +65,7 @@ #include "iwl-drv.h" #include "iwl-trans.h" #include "iwl-wifi.h" +#include "iwl-op-mode.h" int iwl_drv_start(struct iwl_shared *shrd, struct iwl_trans *trans, struct iwl_cfg *cfg) @@ -94,8 +95,9 @@ int iwl_drv_start(struct iwl_shared *shrd, void iwl_drv_stop(struct iwl_shared *shrd) { - iwl_op_mode_dvm_stop(shrd->priv); + /* op_mode can be NULL if its start failed */ + if (shrd->nic->op_mode) + iwl_op_mode_stop(shrd->nic->op_mode); kfree(shrd->nic); } - diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 9c29234221fd..3ca89ab67029 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -53,6 +53,7 @@ #include "iwl-shared.h" #include "iwl-bus.h" #include "iwl-trans.h" +#include "iwl-op-mode.h" /***************************************************************************** * @@ -305,7 +306,7 @@ static int __iwl_up(struct iwl_priv *priv) static int iwlagn_mac_start(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int ret; IWL_DEBUG_MAC80211(priv, "enter\n"); @@ -332,7 +333,7 @@ static int iwlagn_mac_start(struct ieee80211_hw *hw) static void iwlagn_mac_stop(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); IWL_DEBUG_MAC80211(priv, "enter\n"); @@ -362,7 +363,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_gtk_rekey_data *data) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); if (iwlagn_mod_params.sw_crypto) return; @@ -389,7 +390,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, static int iwlagn_mac_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; int ret; @@ -431,7 +432,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, static int iwlagn_mac_resume(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; struct ieee80211_vif *vif; unsigned long flags; @@ -497,7 +498,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 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); @@ -512,7 +513,7 @@ static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); } @@ -522,7 +523,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *ctx = vif_priv->ctx; int ret; @@ -626,7 +627,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int ret = -EINVAL; struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; @@ -692,7 +693,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; bool is_ap = vif->type == NL80211_IFTYPE_STATION; @@ -735,7 +736,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); const struct iwl_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = ch_switch->channel; @@ -822,7 +823,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw, unsigned int *total_flags, u64 multicast) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); __le32 filter_or = 0, filter_nand = 0; struct iwl_rxon_context *ctx; @@ -869,7 +870,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw, static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); mutex_lock(&priv->shrd->mutex); IWL_DEBUG_MAC80211(priv, "enter\n"); @@ -906,7 +907,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, enum nl80211_channel_type channel_type, int duration) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; int err = 0; @@ -996,7 +997,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) return -EOPNOTSUPP; @@ -1016,7 +1017,7 @@ static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, const u8 *bssid, enum ieee80211_tx_sync_type type) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *ctx = vif_priv->ctx; int ret; @@ -1070,7 +1071,7 @@ static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, const u8 *bssid, enum ieee80211_tx_sync_type type) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *ctx = vif_priv->ctx; @@ -1094,7 +1095,7 @@ static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, enum ieee80211_rssi_event rssi_event) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); IWL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->shrd->mutex); @@ -1119,7 +1120,7 @@ static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); queue_work(priv->workqueue, &priv->beacon_update); @@ -1130,7 +1131,7 @@ static int iwlagn_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_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *ctx = vif_priv->ctx; unsigned long flags; @@ -1173,7 +1174,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, static int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); return priv->ibss_manager == IWL_IBSS_MANAGER; } @@ -1227,7 +1228,7 @@ static int iwl_setup_interface(struct iwl_priv *priv, static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *tmp, *ctx = NULL; int err; @@ -1324,7 +1325,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv, static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); IWL_DEBUG_MAC80211(priv, "enter\n"); @@ -1352,7 +1353,7 @@ static int iwlagn_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_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; struct iwl_rxon_context *tmp; @@ -1438,7 +1439,7 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int ret; IWL_DEBUG_MAC80211(priv, "enter\n"); @@ -1484,7 +1485,7 @@ static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; int ret; @@ -1523,7 +1524,7 @@ static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, enum sta_notify_cmd cmd, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; int sta_id; @@ -1591,15 +1592,18 @@ struct ieee80211_ops iwlagn_hw_ops = { struct ieee80211_hw *iwl_alloc_all(void) { struct iwl_priv *priv; + struct iwl_op_mode *op_mode; /* 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), &iwlagn_hw_ops); + hw = ieee80211_alloc_hw(sizeof(struct iwl_priv) + + sizeof(struct iwl_op_mode), &iwlagn_hw_ops); if (!hw) goto out; - priv = hw->priv; + op_mode = hw->priv; + priv = IWL_OP_MODE_GET_DVM(op_mode); priv->hw = hw; out: diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h new file mode 100644 index 000000000000..c85c8dcabb49 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -0,0 +1,108 @@ +/****************************************************************************** + * + * 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) 2007 - 2012 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 - 2012 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 __iwl_op_mode_h__ +#define __iwl_op_mode_h__ + +struct iwl_op_mode; +struct iwl_trans; + +/** + * struct iwl_op_mode_ops - op_mode specific operations + * + * All the handlers MUST be implemented + * + * @start: start the op_mode + * May sleep + * @stop: stop the op_mode + * May sleep + */ +struct iwl_op_mode_ops { + struct iwl_op_mode *(*start)(struct iwl_trans *trans); + void (*stop)(struct iwl_op_mode *op_mode); +}; + +/** + * struct iwl_op_mode - operational mode + * + * This holds an implementation of the mac80211 / fw API. + * + * @ops - pointer to its own ops + */ +struct iwl_op_mode { + const struct iwl_op_mode_ops *ops; + const struct iwl_trans *trans; + + char op_mode_specific[0] __aligned(sizeof(void *)); +}; + +static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode) +{ + op_mode->ops->stop(op_mode); +} + +/***************************************************** +* Op mode layers implementations +******************************************************/ +extern const struct iwl_op_mode_ops iwl_dvm_ops; + +#endif /* __iwl_op_mode_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 392b33a59410..635e3eb4f86d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -532,10 +532,6 @@ enum iwl_rxon_context_id { NUM_IWL_RXON_CTX }; -int iwl_op_mode_dvm_start(struct iwl_bus *bus, - const struct iwl_trans_ops *trans_ops, - struct iwl_cfg *cfg); -void iwl_op_mode_dvm_stop(struct iwl_priv *priv); struct iwl_device_cmd; int __must_check iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 80955ed06e82..e3cca664c19f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -255,7 +255,7 @@ void iwl_testmode_cleanup(struct iwl_priv *priv) */ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_host_cmd cmd; struct iwl_rx_packet *pkt; struct sk_buff *skb; @@ -341,7 +341,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) */ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); u32 ofs, val32, cmd; u8 val8; struct sk_buff *skb; @@ -458,7 +458,7 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) */ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_trans *trans = trans(priv); struct sk_buff *skb; unsigned char *rsp_data_ptr = NULL; @@ -643,7 +643,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) */ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct sk_buff *skb; int status = 0; struct device *dev = trans(priv)->dev; @@ -718,7 +718,7 @@ 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; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int idx, length; if (priv->testmode_trace.trace_enabled && @@ -762,7 +762,7 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, */ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); u8 owner; if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { @@ -876,7 +876,7 @@ static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr, static int iwl_testmode_indirect_mem(struct ieee80211_hw *hw, struct nlattr **tb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); u32 addr, size, cmd; unsigned char *buf; @@ -910,7 +910,7 @@ static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, struct nlattr **tb, struct sk_buff *skb, struct netlink_callback *cb) { - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int idx, length; if (priv->testmode_mem.read_in_progress) { @@ -961,7 +961,7 @@ static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, struct nlattr **tb, 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; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int result; result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, @@ -1038,7 +1038,7 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, void *data, int len) { struct nlattr *tb[IWL_TM_ATTR_MAX]; - struct iwl_priv *priv = hw->priv; + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int result; u32 cmd; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 3645bf3d61c6..b16efc00ba6e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -44,6 +44,7 @@ #include "iwl-agn-calib.h" #include "iwl-trans.h" #include "iwl-fh.h" +#include "iwl-op-mode.h" static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, @@ -1240,7 +1241,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) release_firmware(ucode_raw); complete(&nic->request_firmware_complete); - if (iwl_op_mode_dvm_start(bus(nic), trans(nic)->ops, cfg)) + nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans); + + if (!nic->op_mode) goto out_unbind; return; diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index a78120e89fe1..d5cba07a24c8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -72,6 +72,7 @@ * struct iwl_nic - nic common data * @fw: the iwl_fw structure * @shrd: pointer to common shared structure + * @op_mode: the running op_mode * @fw_index: firmware revision to try loading * @firmware_name: composite filename of ucode file to load * @init_evtlog_ptr: event log offset for init ucode. @@ -86,6 +87,7 @@ struct iwl_nic { struct iwl_fw fw; struct iwl_shared *shrd; + struct iwl_op_mode *op_mode; int fw_index; /* firmware we're trying to load */ char firmware_name[25]; /* name of firmware file to load */ -- GitLab From cbe6ab4e11603e426e01c6349cd5643f3a287ba4 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 15 Feb 2012 09:25:06 +0200 Subject: [PATCH 1193/1846] iwlwifi: use sparse compliant __aligned__ attribute Sparse prefers __aligned(sizeof(void *)); Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-bus.h | 2 +- drivers/net/wireless/iwlwifi/iwl-trans.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h index 30965e0e8ab4..7d56cbc4a0b8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ b/drivers/net/wireless/iwlwifi/iwl-bus.h @@ -133,7 +133,7 @@ struct iwl_bus { /* pointer to bus specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ - char bus_specific[0] __attribute__((__aligned__(sizeof(void *)))); + char bus_specific[0] __aligned(sizeof(void *)); }; /***************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index cc7a3cfb5f24..f42328605356 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -347,7 +347,7 @@ struct iwl_trans { /* pointer to trans specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ - char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); + char trans_specific[0] __aligned(sizeof(void *)); }; static inline int iwl_trans_start_hw(struct iwl_trans *trans) -- GitLab From ed277c9361e423df2bc19312c60b9d06cac31ee6 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 16:08:15 +0200 Subject: [PATCH 1194/1846] iwlwifi: virtualize op_mode's free skb This handler allows the transport layer to free an skb from the op_mode. This can happen when the driver is stopped while Tx packets are pending in the transport layer. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 3 +++ drivers/net/wireless/iwlwifi/iwl-agn.h | 1 + drivers/net/wireless/iwlwifi/iwl-core.c | 4 +++- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 12 ++++++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 3 ++- drivers/net/wireless/iwlwifi/iwl-trans.h | 13 +++++++++++++ 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index dbef0f48c3ef..ac62010408a0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1170,6 +1170,8 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) priv->shrd = trans->shrd; priv->shrd->priv = priv; + iwl_trans_configure(trans(priv), op_mode); + /* At this point both hw and priv are allocated. */ SET_IEEE80211_DEV(priv->hw, trans(priv)->dev); @@ -1383,6 +1385,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) const struct iwl_op_mode_ops iwl_dvm_ops = { .start = iwl_op_mode_dvm_start, .stop = iwl_op_mode_dvm_stop, + .free_skb = iwl_free_skb, }; /***************************************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 79894aca9644..00253f3d987f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -80,6 +80,7 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) void iwl_down(struct iwl_priv *priv); void iwl_cancel_deferred_work(struct iwl_priv *priv); void iwlagn_prepare_restart(struct iwl_priv *priv); +void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb); /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f52d5458a3af..675464a0218e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -41,6 +41,7 @@ #include "iwl-shared.h" #include "iwl-agn.h" #include "iwl-trans.h" +#include "iwl-wifi.h" const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; @@ -1464,8 +1465,9 @@ void iwl_nic_config(struct iwl_priv *priv) cfg(priv)->lib->nic_config(priv); } -void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb) +void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) { + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); struct ieee80211_tx_info *info; info = IEEE80211_SKB_CB(skb); diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index c85c8dcabb49..59dd3074bf73 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -65,6 +65,7 @@ struct iwl_op_mode; struct iwl_trans; +struct sk_buff; /** * struct iwl_op_mode_ops - op_mode specific operations @@ -75,10 +76,15 @@ struct iwl_trans; * May sleep * @stop: stop the op_mode * May sleep + * @free_skb: allows the transport layer to free skbs that haven't been + * reclaimed by the op_mode. This can happen when the driver is freed and + * there are Tx packets pending in the transport layer. + * Must be atomic */ struct iwl_op_mode_ops { struct iwl_op_mode *(*start)(struct iwl_trans *trans); void (*stop)(struct iwl_op_mode *op_mode); + void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); }; /** @@ -100,6 +106,12 @@ static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode) op_mode->ops->stop(op_mode); } +static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode, + struct sk_buff *skb) +{ + op_mode->ops->free_skb(op_mode, skb); +} + /***************************************************** * Op mode layers implementations ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 635e3eb4f86d..eff9360a0c7f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -540,7 +540,6 @@ int __must_check iwl_rx_dispatch(struct iwl_priv *priv, int iwlagn_hw_valid_rtc_data_addr(u32 addr); void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state); void iwl_nic_config(struct iwl_priv *priv); -void iwl_free_skb(struct iwl_priv *priv, struct sk_buff *skb); void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand); const char *get_cmd_string(u8 cmd); bool iwl_check_for_ct_kill(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index a3cebd76dc0c..bca0f4fa2ffa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -35,6 +35,7 @@ #include "iwl-prph.h" #include "iwl-io.h" #include "iwl-agn-hw.h" +#include "iwl-op-mode.h" #include "iwl-trans-pcie-int.h" #define IWL_TX_CRC_SIZE 4 @@ -229,7 +230,7 @@ void iwlagn_txq_free_tfd(struct iwl_trans *trans, struct iwl_tx_queue *txq, * freed and that the queue is not empty - free the skb */ if (skb) { - iwl_free_skb(priv(trans), skb); + iwl_op_mode_free_skb(trans->op_mode, skb); txq->skbs[index] = NULL; } } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index f42328605356..fbb09f684670 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -114,6 +114,7 @@ struct iwl_priv; struct iwl_shared; +struct iwl_op_mode; /** * DOC: Host command section @@ -312,6 +313,7 @@ enum iwl_trans_state { * struct iwl_trans - transport common data * * @ops - pointer to iwl_trans_ops + * @op_mode - pointer to the op_mode * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @hcmd_lock: protects HCMD * @reg_lock - protect hw register access @@ -327,6 +329,7 @@ enum iwl_trans_state { */ struct iwl_trans { const struct iwl_trans_ops *ops; + struct iwl_op_mode *op_mode; struct iwl_shared *shrd; enum iwl_trans_state state; spinlock_t hcmd_lock; @@ -350,6 +353,16 @@ struct iwl_trans { char trans_specific[0] __aligned(sizeof(void *)); }; +static inline void iwl_trans_configure(struct iwl_trans *trans, + struct iwl_op_mode *op_mode) +{ + /* + * only set the op_mode for the moment. Later on, this function will do + * more + */ + trans->op_mode = op_mode; +} + static inline int iwl_trans_start_hw(struct iwl_trans *trans) { might_sleep(); -- GitLab From db70f290e1a88f11815e50acd8ac1c36f89b0da2 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 16:08:15 +0200 Subject: [PATCH 1195/1846] iwlwifi: virtualize op_mode's rx This is the op_mode's Rx handler. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 3 ++- drivers/net/wireless/iwlwifi/iwl-agn.c | 1 + drivers/net/wireless/iwlwifi/iwl-agn.h | 3 +++ drivers/net/wireless/iwlwifi/iwl-op-mode.h | 13 +++++++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 5 ----- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 3 ++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index aee7d060d317..30bb5bbb0cd7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1141,10 +1141,11 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) } -int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, +int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); int err = 0; /* diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ac62010408a0..bafa546939ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1385,6 +1385,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) const struct iwl_op_mode_ops iwl_dvm_ops = { .start = iwl_op_mode_dvm_start, .stop = iwl_op_mode_dvm_stop, + .rx = iwl_rx_dispatch, .free_skb = iwl_free_skb, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 00253f3d987f..337e0984702b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -81,6 +81,9 @@ void iwl_down(struct iwl_priv *priv); void iwl_cancel_deferred_work(struct iwl_priv *priv); void iwlagn_prepare_restart(struct iwl_priv *priv); void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb); +int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode, + struct iwl_rx_mem_buffer *rxb, + struct iwl_device_cmd *cmd); /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index 59dd3074bf73..b0272fd9b537 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -66,6 +66,8 @@ struct iwl_op_mode; struct iwl_trans; struct sk_buff; +struct iwl_device_cmd; +struct iwl_rx_mem_buffer; /** * struct iwl_op_mode_ops - op_mode specific operations @@ -76,6 +78,8 @@ struct sk_buff; * May sleep * @stop: stop the op_mode * May sleep + * @rx: Rx notification to the op_mode. rxb is the Rx buffer itself. Cmd is the + * HCMD the this Rx responds to. * @free_skb: allows the transport layer to free skbs that haven't been * reclaimed by the op_mode. This can happen when the driver is freed and * there are Tx packets pending in the transport layer. @@ -84,6 +88,8 @@ struct sk_buff; struct iwl_op_mode_ops { struct iwl_op_mode *(*start)(struct iwl_trans *trans); void (*stop)(struct iwl_op_mode *op_mode); + int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_mem_buffer *rxb, + struct iwl_device_cmd *cmd); void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); }; @@ -106,6 +112,13 @@ static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode) op_mode->ops->stop(op_mode); } +static inline int iwl_op_mode_rx(struct iwl_op_mode *op_mode, + struct iwl_rx_mem_buffer *rxb, + struct iwl_device_cmd *cmd) +{ + return op_mode->ops->rx(op_mode, rxb, cmd); +} + static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) { diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index eff9360a0c7f..b63423f6d2b4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -532,11 +532,6 @@ enum iwl_rxon_context_id { NUM_IWL_RXON_CTX }; -struct iwl_device_cmd; -int __must_check iwl_rx_dispatch(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, - struct iwl_device_cmd *cmd); - int iwlagn_hw_valid_rtc_data_addr(u32 addr); void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state); void iwl_nic_config(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 6715d04b72f4..579131142163 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -35,6 +35,7 @@ #include "iwl-io.h" #include "iwl-trans-pcie-int.h" #include "iwl-wifi.h" +#include "iwl-op-mode.h" #ifdef CONFIG_IWLWIFI_IDI #include "iwl-amfh.h" @@ -460,7 +461,7 @@ static void iwl_rx_handle(struct iwl_trans *trans) "reclaim is false, SEQ_RX_FRAME unset: %s\n", get_cmd_string(pkt->hdr.cmd)); - err = iwl_rx_dispatch(priv(trans), rxb, cmd); + err = iwl_op_mode_rx(trans->op_mode, rxb, cmd); /* * XXX: After here, we should always check rxb->page -- GitLab From 02e3835884f352ac707dcf14d8bf455c0c0acbc5 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 16:08:15 +0200 Subject: [PATCH 1196/1846] iwlwifi: virtualize op_mode's stop/start queue Export them as "queue_full" and "queue_not_full" notification. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 ++ drivers/net/wireless/iwlwifi/iwl-agn.h | 3 +++ drivers/net/wireless/iwlwifi/iwl-core.c | 8 ++++++-- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 17 +++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 5 +++-- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index bafa546939ba..91aa83fbb432 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1386,6 +1386,8 @@ const struct iwl_op_mode_ops iwl_dvm_ops = { .start = iwl_op_mode_dvm_start, .stop = iwl_op_mode_dvm_stop, .rx = iwl_rx_dispatch, + .queue_full = iwl_stop_sw_queue, + .queue_not_full = iwl_wake_sw_queue, .free_skb = iwl_free_skb, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 337e0984702b..db0e2ae2f5bf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -84,6 +84,9 @@ void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb); int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd); +void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); +void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac); + /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 675464a0218e..2aa69e07e687 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1475,12 +1475,16 @@ void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) dev_kfree_skb_any(skb); } -void iwl_stop_sw_queue(struct iwl_priv *priv, u8 ac) +void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac) { + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + ieee80211_stop_queue(priv->hw, ac); } -void iwl_wake_sw_queue(struct iwl_priv *priv, u8 ac) +void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac) { + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + ieee80211_wake_queue(priv->hw, ac); } diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index b0272fd9b537..c1664e1fd26a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -80,6 +80,10 @@ struct iwl_rx_mem_buffer; * May sleep * @rx: Rx notification to the op_mode. rxb is the Rx buffer itself. Cmd is the * HCMD the this Rx responds to. + * @queue_full: notifies that a HW queue is full. Ac is the ac of the queue + * Must be atomic + * @queue_not_full: notifies that a HW queue is not full any more. + * Ac is the ac of the queue. Must be atomic * @free_skb: allows the transport layer to free skbs that haven't been * reclaimed by the op_mode. This can happen when the driver is freed and * there are Tx packets pending in the transport layer. @@ -90,6 +94,8 @@ struct iwl_op_mode_ops { void (*stop)(struct iwl_op_mode *op_mode); int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd); + void (*queue_full)(struct iwl_op_mode *op_mode, u8 ac); + void (*queue_not_full)(struct iwl_op_mode *op_mode, u8 ac); void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); }; @@ -119,6 +125,17 @@ static inline int iwl_op_mode_rx(struct iwl_op_mode *op_mode, return op_mode->ops->rx(op_mode, rxb, cmd); } +static inline void iwl_op_mode_queue_full(struct iwl_op_mode *op_mode, u8 ac) +{ + op_mode->ops->queue_full(op_mode, ac); +} + +static inline void iwl_op_mode_queue_not_full(struct iwl_op_mode *op_mode, + u8 ac) +{ + op_mode->ops->queue_not_full(op_mode, ac); +} + static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) { diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index b63423f6d2b4..0a3f6fd6da60 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -539,8 +539,6 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand); const char *get_cmd_string(u8 cmd); 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); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 8c30fea8c2b3..5b26b71ae3d5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -40,6 +40,7 @@ #include "iwl-trans.h" #include "iwl-debug.h" #include "iwl-io.h" +#include "iwl-op-mode.h" struct iwl_tx_queue; struct iwl_queue; @@ -374,7 +375,7 @@ static inline void iwl_wake_queue(struct iwl_trans *trans, if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) { if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) { - iwl_wake_sw_queue(priv(trans), ac); + iwl_op_mode_queue_not_full(trans->op_mode, ac); IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d. %s", hwq, ac, msg); } else { @@ -397,7 +398,7 @@ static inline void iwl_stop_queue(struct iwl_trans *trans, if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) { if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) { - iwl_stop_sw_queue(priv(trans), ac); + iwl_op_mode_queue_full(trans->op_mode, ac); IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d ac %d" " stop count %d. %s", hwq, ac, atomic_read(&trans_pcie-> -- GitLab From 7120d9894c363ee31fd529e5dd962452b639ab8e Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 16:08:15 +0200 Subject: [PATCH 1197/1846] iwlwifi: virtualize op_mode's set_hw_rf_kill Export it as "hw_rf_kill" notification. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 1 + drivers/net/wireless/iwlwifi/iwl-agn.h | 2 +- drivers/net/wireless/iwlwifi/iwl-core.c | 4 +++- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 9 +++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 6 +++--- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 91aa83fbb432..28fda18df2b5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1388,6 +1388,7 @@ const struct iwl_op_mode_ops iwl_dvm_ops = { .rx = iwl_rx_dispatch, .queue_full = iwl_stop_sw_queue, .queue_not_full = iwl_wake_sw_queue, + .hw_rf_kill = iwl_set_hw_rfkill_state, .free_skb = iwl_free_skb, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index db0e2ae2f5bf..39d1e7960908 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -86,7 +86,7 @@ int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_device_cmd *cmd); void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac); - +void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state); /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 2aa69e07e687..3b91b6b811aa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1455,8 +1455,10 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, return cpu_to_le32(res); } -void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state) +void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) { + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + wiphy_rfkill_set_hw_state(priv->hw->wiphy, state); } diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index c1664e1fd26a..8ce4aac29b0a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -84,6 +84,8 @@ struct iwl_rx_mem_buffer; * Must be atomic * @queue_not_full: notifies that a HW queue is not full any more. * Ac is the ac of the queue. Must be atomic + * @hw_rf_kill:notifies of a change in the HW rf kill switch. True means that + * the radio is killed. Must be atomic. * @free_skb: allows the transport layer to free skbs that haven't been * reclaimed by the op_mode. This can happen when the driver is freed and * there are Tx packets pending in the transport layer. @@ -96,6 +98,7 @@ struct iwl_op_mode_ops { struct iwl_device_cmd *cmd); void (*queue_full)(struct iwl_op_mode *op_mode, u8 ac); void (*queue_not_full)(struct iwl_op_mode *op_mode, u8 ac); + void (*hw_rf_kill)(struct iwl_op_mode *op_mode, bool state); void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); }; @@ -136,6 +139,12 @@ static inline void iwl_op_mode_queue_not_full(struct iwl_op_mode *op_mode, op_mode->ops->queue_not_full(op_mode, ac); } +static inline void iwl_op_mode_hw_rf_kill(struct iwl_op_mode *op_mode, + bool state) +{ + op_mode->ops->hw_rf_kill(op_mode, state); +} + static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) { diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 0a3f6fd6da60..5cbc637e63b6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -533,7 +533,6 @@ enum iwl_rxon_context_id { }; int iwlagn_hw_valid_rtc_data_addr(u32 addr); -void iwl_set_hw_rfkill_state(struct iwl_priv *priv, bool state); void iwl_nic_config(struct iwl_priv *priv); void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand); const char *get_cmd_string(u8 cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 579131142163..abb5277f98e7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1036,7 +1036,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) else clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - iwl_set_hw_rfkill_state(priv(trans), hw_rf_kill); + iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rf_kill); } handled |= CSR_INT_BIT_RF_KILL; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 176063c4f781..ca0fa9c8e89c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1045,7 +1045,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw) set_bit(STATUS_RF_KILL_HW, &trans->shrd->status); if (iwl_is_rfkill(trans->shrd)) { - iwl_set_hw_rfkill_state(priv(trans), true); + iwl_op_mode_hw_rf_kill(trans->op_mode, true); iwl_enable_interrupts(trans); return -ERFKILL; } @@ -1524,7 +1524,7 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) else set_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - iwl_set_hw_rfkill_state(priv(trans), + iwl_op_mode_hw_rf_kill(trans->op_mode, test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)); @@ -1669,7 +1669,7 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans) else clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - iwl_set_hw_rfkill_state(priv(trans), hw_rfkill); + iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); return 0; } -- GitLab From bcb9321c8db86150004d615e03551911be84685e Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 9 Feb 2012 16:08:15 +0200 Subject: [PATCH 1198/1846] iwlwifi: virtualize op_mode's fw_error Export it as "nic_error" notification, the error handling will be in the op_mode. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 1 + drivers/net/wireless/iwlwifi/iwl-agn.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-core.c | 9 ++++++++- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 7 +++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 4 ++-- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 28fda18df2b5..a0346edbf012 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1390,6 +1390,7 @@ const struct iwl_op_mode_ops iwl_dvm_ops = { .queue_not_full = iwl_wake_sw_queue, .hw_rf_kill = iwl_set_hw_rfkill_state, .free_skb = iwl_free_skb, + .nic_error = iwl_nic_error, }; /***************************************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 39d1e7960908..3c7f0c1190d8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -87,6 +87,8 @@ int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode, void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state); +void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); +void iwl_nic_error(struct iwl_op_mode *op_mode); /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 3b91b6b811aa..88a8c74ea21e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -830,7 +830,7 @@ void iwl_print_rx_config_cmd(struct iwl_priv *priv, } #endif -void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) +static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) { unsigned int reload_msec; unsigned long reload_jiffies; @@ -1455,6 +1455,13 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, return cpu_to_le32(res); } +void iwl_nic_error(struct iwl_op_mode *op_mode) +{ + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + + iwlagn_fw_error(priv, false); +} + void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) { struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index 8ce4aac29b0a..e2a780d12467 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -90,6 +90,7 @@ struct iwl_rx_mem_buffer; * reclaimed by the op_mode. This can happen when the driver is freed and * there are Tx packets pending in the transport layer. * Must be atomic + * @nic_error: error notification. Must be atomic */ struct iwl_op_mode_ops { struct iwl_op_mode *(*start)(struct iwl_trans *trans); @@ -100,6 +101,7 @@ struct iwl_op_mode_ops { void (*queue_not_full)(struct iwl_op_mode *op_mode, u8 ac); void (*hw_rf_kill)(struct iwl_op_mode *op_mode, bool state); void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); + void (*nic_error)(struct iwl_op_mode *op_mode); }; /** @@ -151,6 +153,11 @@ static inline void iwl_op_mode_free_skb(struct iwl_op_mode *op_mode, op_mode->ops->free_skb(op_mode, skb); } +static inline void iwl_op_mode_nic_error(struct iwl_op_mode *op_mode) +{ + op_mode->ops->nic_error(op_mode); +} + /***************************************************** * Op mode layers implementations ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 5cbc637e63b6..f3b6fd7ae4dd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -534,7 +534,6 @@ enum iwl_rxon_context_id { int iwlagn_hw_valid_rtc_data_addr(u32 addr); void iwl_nic_config(struct iwl_priv *priv); -void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand); const char *get_cmd_string(u8 cmd); bool iwl_check_for_ct_kill(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index abb5277f98e7..2072bc20f2e2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -701,7 +701,7 @@ static void iwl_irq_handle_error(struct iwl_trans *trans) iwl_print_rx_config_cmd(priv(trans), IWL_RXON_CTX_BSS); #endif - iwlagn_fw_error(priv, false); + iwl_op_mode_nic_error(trans->op_mode); } #define EVENT_START_OFFSET (4 * sizeof(u32)) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index bca0f4fa2ffa..82e34484fa5e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -689,7 +689,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) is_ct_kill = iwl_check_for_ct_kill(priv(trans)); if (!is_ct_kill) { IWL_ERR(trans, "Restarting adapter queue is full\n"); - iwlagn_fw_error(priv(trans), false); + iwl_op_mode_nic_error(trans->op_mode); } return -ENOSPC; } @@ -822,7 +822,7 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id, if (nfreed++ > 0) { IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); - iwlagn_fw_error(priv(trans), false); + iwl_op_mode_nic_error(trans->op_mode); } } -- GitLab From ff6e75cb20b6423c8947077a377ba318dd1a7554 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Sun, 12 Feb 2012 15:21:08 +0200 Subject: [PATCH 1199/1846] iwlwifi: remove a few dereferences to iwl_priv from the tansport The transport should not dereference the iwl_priv pointer. Remove a few of those. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 2072bc20f2e2..60e70b78d7d1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -671,9 +671,8 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) */ static void iwl_irq_handle_error(struct iwl_trans *trans) { - struct iwl_priv *priv = priv(trans); /* W/A for WiFi/WiMAX coex and WiMAX own the RF */ - if (cfg(priv)->internal_wimax_coex && + if (cfg(trans)->internal_wimax_coex && (!(iwl_read_prph(trans, APMG_CLK_CTRL_REG) & APMS_CLK_VAL_MRB_FUNC_MODE) || (iwl_read_prph(trans, APMG_PS_CTRL_REG) & @@ -684,13 +683,13 @@ static void iwl_irq_handle_error(struct iwl_trans *trans) */ clear_bit(STATUS_READY, &trans->shrd->status); clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); - wake_up(&priv->shrd->wait_command_queue); + wake_up(&trans->shrd->wait_command_queue); IWL_ERR(trans, "RF is used by WiMAX\n"); return; } IWL_ERR(trans, "Loaded firmware version: %s\n", - priv->hw->wiphy->fw_version); + nic(trans)->fw.fw_version); iwl_dump_nic_error_log(trans); iwl_dump_csr(trans); -- GitLab From 90304749c366c0eb5b8d01d415ee95e9215e0dbf Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 13 Feb 2012 11:17:57 +0200 Subject: [PATCH 1200/1846] iwlwifi: move eeprom defines to iwl-eeprom.c They don't need to be in iwl-dev.h Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 3 --- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 479d3281a972..a670c82e82fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -443,9 +443,6 @@ struct iwl_chain_noise_data { u8 state; }; -#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ -#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ - enum { MEASUREMENT_READY = (1 << 0), MEASUREMENT_ACTIVE = (1 << 1), diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index d1fd1cdb29c2..5936833ff759 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -149,6 +149,10 @@ static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */ * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ + +#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ +#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ + static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) { u16 count; -- GitLab From ca77d534840b2b30c72bc0e668bd131bf786e6c3 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 13 Feb 2012 11:24:47 +0200 Subject: [PATCH 1201/1846] iwlwifi: eeprom gets transport and not bus This is temporary, but at least we can now throw the bus away and move the iwl_pci_{probe,remove} functions. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 152 +++++++++++----------- drivers/net/wireless/iwlwifi/iwl-eeprom.h | 3 +- 3 files changed, 80 insertions(+), 77 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index a0346edbf012..7e3e00d6423e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1215,7 +1215,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) * 4. Read EEPROM *****************/ /* Read the EEPROM */ - err = iwl_eeprom_init(priv, trans(priv)->hw_rev); + err = iwl_eeprom_init(trans(priv), trans(priv)->hw_rev); /* Reset chip to save power until we load uCode during "up". */ iwl_trans_stop_hw(trans(priv)); if (err) { diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 5936833ff759..07e93787bce8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -153,23 +153,23 @@ static const u8 iwl_eeprom_band_7[] = { /* 5.2 ht40 channel */ #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ -static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) +static int iwl_eeprom_acquire_semaphore(struct iwl_trans *trans) { u16 count; int ret; for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - iwl_set_bit(trans(bus), CSR_HW_IF_CONFIG_REG, + iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = iwl_poll_bit(trans(bus), CSR_HW_IF_CONFIG_REG, + ret = iwl_poll_bit(trans, 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_EEPROM(trans(bus), + IWL_DEBUG_EEPROM(trans, "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -179,9 +179,9 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) return ret; } -static void iwl_eeprom_release_semaphore(struct iwl_bus *bus) +static void iwl_eeprom_release_semaphore(struct iwl_trans *trans) { - iwl_clear_bit(trans(bus), CSR_HW_IF_CONFIG_REG, + iwl_clear_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } @@ -308,19 +308,20 @@ void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac) * ******************************************************************************/ -static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode) +static void iwl_set_otp_access(struct iwl_trans *trans, + enum iwl_access_mode mode) { - iwl_read32(trans(bus), CSR_OTP_GP_REG); + iwl_read32(trans, CSR_OTP_GP_REG); if (mode == IWL_OTP_ACCESS_ABSOLUTE) - iwl_clear_bit(trans(bus), CSR_OTP_GP_REG, + iwl_clear_bit(trans, CSR_OTP_GP_REG, CSR_OTP_GP_REG_OTP_ACCESS_MODE); else - iwl_set_bit(trans(bus), CSR_OTP_GP_REG, + iwl_set_bit(trans, CSR_OTP_GP_REG, CSR_OTP_GP_REG_OTP_ACCESS_MODE); } -static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) +static int iwl_get_nvm_type(struct iwl_trans *trans, u32 hw_rev) { u32 otpgp; int nvm_type; @@ -328,7 +329,7 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) /* OTP only valid for CP/PP and after */ switch (hw_rev & CSR_HW_REV_TYPE_MSK) { case CSR_HW_REV_TYPE_NONE: - IWL_ERR(bus, "Unknown hardware type\n"); + IWL_ERR(trans, "Unknown hardware type\n"); return -ENOENT; case CSR_HW_REV_TYPE_5300: case CSR_HW_REV_TYPE_5350: @@ -337,7 +338,7 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) nvm_type = NVM_DEVICE_TYPE_EEPROM; break; default: - otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG); + otpgp = iwl_read32(trans, CSR_OTP_GP_REG); if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) nvm_type = NVM_DEVICE_TYPE_OTP; else @@ -347,73 +348,74 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) return nvm_type; } -static int iwl_init_otp_access(struct iwl_bus *bus) +static int iwl_init_otp_access(struct iwl_trans *trans) { int ret; /* Enable 40MHz radio clock */ - iwl_write32(trans(bus), CSR_GP_CNTRL, - iwl_read32(trans(bus), CSR_GP_CNTRL) | + iwl_write32(trans, CSR_GP_CNTRL, + iwl_read32(trans, CSR_GP_CNTRL) | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* wait for clock to be ready */ - ret = iwl_poll_bit(trans(bus), CSR_GP_CNTRL, + ret = iwl_poll_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) - IWL_ERR(bus, "Time out access OTP\n"); + IWL_ERR(trans, "Time out access OTP\n"); else { - iwl_set_bits_prph(trans(bus), APMG_PS_CTRL_REG, + iwl_set_bits_prph(trans, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - iwl_clear_bits_prph(trans(bus), APMG_PS_CTRL_REG, + iwl_clear_bits_prph(trans, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); /* * CSR auto clock gate disable bit - * this is only applicable for HW with OTP shadow RAM */ - if (cfg(bus)->base_params->shadow_ram_support) - iwl_set_bit(trans(bus), CSR_DBG_LINK_PWR_MGMT_REG, + if (cfg(trans)->base_params->shadow_ram_support) + iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, CSR_RESET_LINK_PWR_MGMT_DISABLED); } return ret; } -static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) +static int iwl_read_otp_word(struct iwl_trans *trans, u16 addr, + __le16 *eeprom_data) { int ret = 0; u32 r; u32 otpgp; - iwl_write32(trans(bus), CSR_EEPROM_REG, + iwl_write32(trans, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(trans(bus), CSR_EEPROM_REG, + ret = iwl_poll_bit(trans, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IWL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IWL_ERR(bus, "Time out reading OTP[%d]\n", addr); + IWL_ERR(trans, "Time out reading OTP[%d]\n", addr); return ret; } - r = iwl_read32(trans(bus), CSR_EEPROM_REG); + r = iwl_read32(trans, CSR_EEPROM_REG); /* check for ECC errors: */ - otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG); + otpgp = iwl_read32(trans, CSR_OTP_GP_REG); if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { /* stop in this case */ /* set the uncorrectable OTP ECC bit for acknowledgement */ - iwl_set_bit(trans(bus), CSR_OTP_GP_REG, + iwl_set_bit(trans, CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); - IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n"); + IWL_ERR(trans, "Uncorrectable OTP ECC error, abort OTP read\n"); return -EINVAL; } if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { /* continue in this case */ /* set the correctable OTP ECC bit for acknowledgement */ - iwl_set_bit(trans(bus), CSR_OTP_GP_REG, + iwl_set_bit(trans, CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); - IWL_ERR(bus, "Correctable OTP ECC error, continue read\n"); + IWL_ERR(trans, "Correctable OTP ECC error, continue read\n"); } *eeprom_data = cpu_to_le16(r >> 16); return 0; @@ -422,20 +424,20 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) /* * iwl_is_otp_empty: check for empty OTP */ -static bool iwl_is_otp_empty(struct iwl_bus *bus) +static bool iwl_is_otp_empty(struct iwl_trans *trans) { u16 next_link_addr = 0; __le16 link_value; bool is_empty = false; /* locate the beginning of OTP link list */ - if (!iwl_read_otp_word(bus, next_link_addr, &link_value)) { + if (!iwl_read_otp_word(trans, next_link_addr, &link_value)) { if (!link_value) { - IWL_ERR(bus, "OTP is empty\n"); + IWL_ERR(trans, "OTP is empty\n"); is_empty = true; } } else { - IWL_ERR(bus, "Unable to read first block of OTP list.\n"); + IWL_ERR(trans, "Unable to read first block of OTP list.\n"); is_empty = true; } @@ -452,7 +454,7 @@ static bool iwl_is_otp_empty(struct iwl_bus *bus) * we should read and used to configure the device. * only perform this operation if shadow RAM is disabled */ -static int iwl_find_otp_image(struct iwl_bus *bus, +static int iwl_find_otp_image(struct iwl_trans *trans, u16 *validblockaddr) { u16 next_link_addr = 0, valid_addr; @@ -460,10 +462,10 @@ static int iwl_find_otp_image(struct iwl_bus *bus, int usedblocks = 0; /* set addressing mode to absolute to traverse the link list */ - iwl_set_otp_access(bus, IWL_OTP_ACCESS_ABSOLUTE); + iwl_set_otp_access(trans, IWL_OTP_ACCESS_ABSOLUTE); /* checking for empty OTP or error */ - if (iwl_is_otp_empty(bus)) + if (iwl_is_otp_empty(trans)) return -EINVAL; /* @@ -477,9 +479,9 @@ static int iwl_find_otp_image(struct iwl_bus *bus, */ valid_addr = next_link_addr; next_link_addr = le16_to_cpu(link_value) * sizeof(u16); - IWL_DEBUG_EEPROM(bus, "OTP blocks %d addr 0x%x\n", + IWL_DEBUG_EEPROM(trans, "OTP blocks %d addr 0x%x\n", usedblocks, next_link_addr); - if (iwl_read_otp_word(bus, next_link_addr, &link_value)) + if (iwl_read_otp_word(trans, next_link_addr, &link_value)) return -EINVAL; if (!link_value) { /* @@ -494,10 +496,10 @@ static int iwl_find_otp_image(struct iwl_bus *bus, } /* more in the link list, continue */ usedblocks++; - } while (usedblocks <= cfg(bus)->base_params->max_ll_items); + } while (usedblocks <= cfg(trans)->base_params->max_ll_items); /* OTP has no valid blocks */ - IWL_DEBUG_EEPROM(bus, "OTP has no valid blocks\n"); + IWL_DEBUG_EEPROM(trans, "OTP has no valid blocks\n"); return -EINVAL; } @@ -657,63 +659,62 @@ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) * * NOTE: This routine uses the non-debug IO access functions. */ -int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) +int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev) { - struct iwl_shared *shrd = priv->shrd; __le16 *e; - u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP); + u32 gp = iwl_read32(trans, CSR_EEPROM_GP); int sz; int ret; u16 addr; u16 validblockaddr = 0; u16 cache_addr = 0; - trans(priv)->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev); - if (trans(priv)->nvm_device_type == -ENOENT) + trans->nvm_device_type = iwl_get_nvm_type(trans, hw_rev); + if (trans->nvm_device_type == -ENOENT) return -ENOENT; /* allocate eeprom */ - sz = cfg(priv)->base_params->eeprom_size; - IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); - shrd->eeprom = kzalloc(sz, GFP_KERNEL); - if (!shrd->eeprom) { + sz = cfg(trans)->base_params->eeprom_size; + IWL_DEBUG_EEPROM(trans, "NVM size = %d\n", sz); + trans->shrd->eeprom = kzalloc(sz, GFP_KERNEL); + if (!trans->shrd->eeprom) { ret = -ENOMEM; goto alloc_err; } - e = (__le16 *)shrd->eeprom; + e = (__le16 *)trans->shrd->eeprom; - ret = iwl_eeprom_verify_signature(trans(priv)); + ret = iwl_eeprom_verify_signature(trans); if (ret < 0) { - IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IWL_ERR(trans, "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 = iwl_eeprom_acquire_semaphore(bus(priv)); + ret = iwl_eeprom_acquire_semaphore(trans); if (ret < 0) { - IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); + IWL_ERR(trans, "Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } - if (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) { + if (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) { - ret = iwl_init_otp_access(bus(priv)); + ret = iwl_init_otp_access(trans); if (ret) { - IWL_ERR(priv, "Failed to initialize OTP access.\n"); + IWL_ERR(trans, "Failed to initialize OTP access.\n"); ret = -ENOENT; goto done; } - iwl_write32(trans(priv), CSR_EEPROM_GP, - iwl_read32(trans(priv), CSR_EEPROM_GP) & + iwl_write32(trans, CSR_EEPROM_GP, + iwl_read32(trans, CSR_EEPROM_GP) & ~CSR_EEPROM_GP_IF_OWNER_MSK); - iwl_set_bit(trans(priv), CSR_OTP_GP_REG, + iwl_set_bit(trans, CSR_OTP_GP_REG, CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); /* traversing the linked list if no shadow ram supported */ - if (!cfg(priv)->base_params->shadow_ram_support) { - if (iwl_find_otp_image(bus(priv), &validblockaddr)) { + if (!cfg(trans)->base_params->shadow_ram_support) { + if (iwl_find_otp_image(trans, &validblockaddr)) { ret = -ENOENT; goto done; } @@ -722,7 +723,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) addr += sizeof(u16)) { __le16 eeprom_data; - ret = iwl_read_otp_word(bus(priv), addr, &eeprom_data); + ret = iwl_read_otp_word(trans, addr, &eeprom_data); if (ret) goto done; e[cache_addr / 2] = eeprom_data; @@ -733,34 +734,35 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - iwl_write32(trans(priv), CSR_EEPROM_REG, + iwl_write32(trans, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(trans(priv), CSR_EEPROM_REG, + ret = iwl_poll_bit(trans, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IWL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr); + IWL_ERR(trans, + "Time out reading EEPROM[%d]\n", addr); goto done; } - r = iwl_read32(trans(priv), CSR_EEPROM_REG); + r = iwl_read32(trans, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } } - IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", - (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) + IWL_DEBUG_EEPROM(trans, "NVM Type: %s, version: 0x%x\n", + (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) ? "OTP" : "EEPROM", - iwl_eeprom_query16(shrd, EEPROM_VERSION)); + iwl_eeprom_query16(trans->shrd, EEPROM_VERSION)); ret = 0; done: - iwl_eeprom_release_semaphore(bus(priv)); + iwl_eeprom_release_semaphore(trans); err: if (ret) - iwl_eeprom_free(priv->shrd); + iwl_eeprom_free(trans->shrd); alloc_err: return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 13f2d3928ef8..cbb86116917b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -67,6 +67,7 @@ struct iwl_priv; struct iwl_shared; +struct iwl_trans; /* * EEPROM access time values: @@ -305,7 +306,7 @@ struct iwl_eeprom_ops { }; -int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev); +int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev); 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); -- GitLab From 36a79223c4b998efefda7a8c52c6923228f9c0ea Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Mon, 27 Feb 2012 13:53:32 -0800 Subject: [PATCH 1202/1846] iwlwifi: kill iwl_bus.h No one needs it any more Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 1 - drivers/net/wireless/iwlwifi/iwl-bus.h | 145 -------------------- drivers/net/wireless/iwlwifi/iwl-debug.h | 1 - drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - drivers/net/wireless/iwlwifi/iwl-mac80211.c | 1 - drivers/net/wireless/iwlwifi/iwl-pci.c | 60 ++++---- drivers/net/wireless/iwlwifi/iwl-shared.h | 5 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 1 - drivers/net/wireless/iwlwifi/iwl-trans.h | 2 + 9 files changed, 29 insertions(+), 188 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-bus.h diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 7e3e00d6423e..e0fef9f257c2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -50,7 +50,6 @@ #include "iwl-agn-calib.h" #include "iwl-agn.h" #include "iwl-shared.h" -#include "iwl-bus.h" #include "iwl-trans.h" #include "iwl-op-mode.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h deleted file mode 100644 index 7d56cbc4a0b8..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-bus.h +++ /dev/null @@ -1,145 +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) 2007 - 2012 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 - 2012 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 __iwl_bus_h__ -#define __iwl_bus_h__ - -#include -#include - -/** - * DOC: Bus layer - role and goal - * - * iwl-bus.h defines the API to the bus layer of the iwlwifi driver. - * The bus layer is responsible for doing very basic bus operations that are - * listed in the iwl_bus_ops structure. - * The bus layer registers to the bus driver, advertises the supported HW and - * gets notifications about enumeration, suspend, resume. - * For the moment, the bus layer is not a linux kernel module as itself, and - * the module_init function of the driver must call the bus specific - * registration functions. These functions are listed at the end of this file. - * For the moment, there is only one implementation of this interface: PCI-e. - * This implementation is iwl-pci.c - */ - -/** - * DOC: encapsulation and type safety - * - * The iwl_bus describes the data that is shared amongst all the bus layer - * implementations. This data is visible to other layers. Data in the bus - * specific area is not visible outside the bus specific implementation. - * iwl_bus holds a pointer to iwl_shared which holds pointer to all the other - * layers of the driver (iwl_priv, iwl_trans). In fact, this is the way to go - * when the transport layer needs to call a function of another layer. - * - * In order to achieve encapsulation, iwl_priv cannot be dereferenced from the - * bus layer. Type safety is still kept since functions that gets iwl_priv gets - * a typed pointer (as opposed to void *). - */ - -/** - * DOC: probe flow - * - * The module_init calls the bus specific registration function. The - * registration to the bus layer will trigger an enumeration of the bus which - * will call the bus specific probe function. - * The first thing this function must do is to allocate the memory needed by - * iwl_bus + the bus_specific data. - * Once the bus specific probe function has configured the hardware, it - * chooses the appropriate transport layer and calls iwl_probe that will run - * the bus independent probe flow. - * - * Note: The bus specific code must set the following data in iwl_bus before it - * calls iwl_probe: - * * bus->dev - * * bus->irq - * * bus->ops - */ - -struct iwl_shared; -struct iwl_bus; - -/** - * struct iwl_bus - bus common data - * - * This data is common to all bus layer implementations. - * - * @ops - pointer to iwl_bus_ops - * @shrd - pointer to iwl_shared which holds shared data from the upper layer - * NB: for the time being this needs to be set by the upper layer since - * it allocates the shared data - */ -struct iwl_bus { - struct iwl_shared *shrd; - - /* pointer to bus specific struct */ - /*Ensure that this pointer will always be aligned to sizeof pointer */ - char bus_specific[0] __aligned(sizeof(void *)); -}; - -/***************************************************** -* Bus layer registration functions -******************************************************/ -int __must_check iwl_pci_register_driver(void); -void iwl_pci_unregister_driver(void); - -#endif /* __iwl_bus_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index bfc08494ed22..01b23303d736 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -29,7 +29,6 @@ #ifndef __iwl_debug_h__ #define __iwl_debug_h__ -#include "iwl-bus.h" #include "iwl-shared.h" #include "iwl-devtrace.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index a670c82e82fd..6e5bf0a14609 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -47,7 +47,6 @@ #include "iwl-power.h" #include "iwl-agn-rs.h" #include "iwl-agn-tt.h" -#include "iwl-bus.h" #include "iwl-trans.h" #include "iwl-shared.h" #include "iwl-op-mode.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 3ca89ab67029..03f770543d8e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -51,7 +51,6 @@ #include "iwl-agn-calib.h" #include "iwl-agn.h" #include "iwl-shared.h" -#include "iwl-bus.h" #include "iwl-trans.h" #include "iwl-op-mode.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index b9cdd1ac1744..527f13b50055 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -64,13 +64,13 @@ #include #include -#include "iwl-bus.h" #include "iwl-io.h" #include "iwl-shared.h" #include "iwl-trans.h" #include "iwl-csr.h" #include "iwl-cfg.h" #include "iwl-drv.h" +#include "iwl-trans.h" #define IWL_PCI_DEVICE(dev, subdev, cfg) \ .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ @@ -263,44 +263,40 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); - struct iwl_bus *bus; + struct iwl_shared *shrd; + struct iwl_trans *iwl_trans; int err; - bus = kzalloc(sizeof(*bus), GFP_KERNEL); - if (!bus) { - dev_printk(KERN_ERR, &pdev->dev, - "Couldn't allocate iwl_pci_bus"); - return -ENOMEM; - } - - bus->shrd = kzalloc(sizeof(*bus->shrd), GFP_KERNEL); - if (!bus->shrd) { + shrd = kzalloc(sizeof(*iwl_trans->shrd), GFP_KERNEL); + if (!shrd) { dev_printk(KERN_ERR, &pdev->dev, "Couldn't allocate iwl_shared"); err = -ENOMEM; goto out_free_bus; } - bus->shrd->bus = bus; - - pci_set_drvdata(pdev, bus); - #ifdef CONFIG_IWLWIFI_IDI - trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent); - if (trans(bus) == NULL) { + iwl_trans = iwl_trans_idi_alloc(shrd, pdev, ent); + if (trans == NULL) { err = -ENOMEM; goto out_free_bus; } - err = iwl_drv_start(bus->shrd, trans(bus), cfg); + shrd->trans = iwl_trans; + pci_set_drvdata(pdev, iwl_trans); + + err = iwl_drv_start(shrd, iwl_trans, cfg); #else - trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent); - if (trans(bus) == NULL) { + iwl_trans = iwl_trans_pcie_alloc(shrd, pdev, ent); + if (iwl_trans == NULL) { err = -ENOMEM; goto out_free_bus; } - err = iwl_drv_start(bus->shrd, trans(bus), cfg); + shrd->trans = iwl_trans; + pci_set_drvdata(pdev, iwl_trans); + + err = iwl_drv_start(shrd, iwl_trans, cfg); #endif if (err) goto out_free_trans; @@ -308,26 +304,24 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; out_free_trans: - iwl_trans_free(trans(bus)); + iwl_trans_free(iwl_trans); pci_set_drvdata(pdev, NULL); out_free_bus: - kfree(bus->shrd); - kfree(bus); + kfree(shrd); return err; } static void __devexit iwl_pci_remove(struct pci_dev *pdev) { - struct iwl_bus *bus = pci_get_drvdata(pdev); - struct iwl_shared *shrd = bus->shrd; + struct iwl_trans *iwl_trans = pci_get_drvdata(pdev); + struct iwl_shared *shrd = iwl_trans->shrd; iwl_drv_stop(shrd); iwl_trans_free(shrd->trans); pci_set_drvdata(pdev, NULL); - kfree(bus->shrd); - kfree(bus); + kfree(shrd); } #ifdef CONFIG_PM_SLEEP @@ -335,22 +329,20 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) static int iwl_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct iwl_bus *bus = pci_get_drvdata(pdev); - struct iwl_shared *shrd = bus->shrd; + struct iwl_trans *iwl_trans = pci_get_drvdata(pdev); /* Before you put code here, think about WoWLAN. You cannot check here * whether WoWLAN is enabled or not, and your code will run even if * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx. */ - return iwl_trans_suspend(shrd->trans); + return iwl_trans_suspend(iwl_trans); } static int iwl_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct iwl_bus *bus = pci_get_drvdata(pdev); - struct iwl_shared *shrd = bus->shrd; + struct iwl_trans *iwl_trans = pci_get_drvdata(pdev); /* Before you put code here, think about WoWLAN. You cannot check here * whether WoWLAN is enabled or not, and your code will run even if @@ -363,7 +355,7 @@ static int iwl_pci_resume(struct device *device) */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - return iwl_trans_resume(shrd->trans); + return iwl_trans_resume(iwl_trans); } static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index f3b6fd7ae4dd..e7b075eebb72 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -94,7 +94,6 @@ * This implementation is iwl-pci.c */ -struct iwl_bus; struct iwl_priv; struct iwl_trans; struct iwl_sensitivity_ranges; @@ -385,7 +384,6 @@ struct iwl_shared { bool wowlan; u8 valid_contexts; - struct iwl_bus *bus; struct iwl_cfg *cfg; struct iwl_priv *priv; struct iwl_trans *trans; @@ -416,10 +414,9 @@ struct iwl_shared { }; -/*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */ +/*Whatever _m is (iwl_trans, iwl_priv, these macros will work */ #define priv(_m) ((_m)->shrd->priv) #define cfg(_m) ((_m)->shrd->cfg) -#define bus(_m) ((_m)->shrd->bus) #define nic(_m) ((_m)->shrd->nic) #define trans(_m) ((_m)->shrd->trans) #define hw_params(_m) ((_m)->shrd->hw_params) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index e3cca664c19f..23eea06a74ad 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -78,7 +78,6 @@ #include "iwl-agn.h" #include "iwl-testmode.h" #include "iwl-trans.h" -#include "iwl-bus.h" #include "iwl-fh.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index fbb09f684670..52a1c2eda8e8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -563,6 +563,8 @@ extern const struct iwl_trans_ops trans_ops_pcie; struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, struct pci_dev *pdev, const struct pci_device_id *ent); +int __must_check iwl_pci_register_driver(void); +void iwl_pci_unregister_driver(void); extern const struct iwl_trans_ops trans_ops_idi; struct iwl_trans *iwl_trans_idi_alloc(struct iwl_shared *shrd, -- GitLab From 3e6895c50af9a9574a8bb97268d99be049fe46f0 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 15 Feb 2012 12:48:04 +0200 Subject: [PATCH 1203/1846] iwlwifi: remove iwl_print_rx_config_cmd from shared It is op_mode related Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.h | 10 ++++++++++ drivers/net/wireless/iwlwifi/iwl-core.c | 5 +++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 10 ---------- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 4 ---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 3c7f0c1190d8..cb484e273b93 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -392,4 +392,14 @@ void iwl_testmode_cleanup(struct iwl_priv *priv) } #endif +#ifdef CONFIG_IWLWIFI_DEBUG +void iwl_print_rx_config_cmd(struct iwl_priv *priv, + enum iwl_rxon_context_id ctxid); +#else +static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv, + enum iwl_rxon_context_id ctxid) +{ +} +#endif + #endif /* __iwl_agn_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 88a8c74ea21e..275e08966059 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -835,6 +835,11 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) unsigned int reload_msec; unsigned long reload_jiffies; +#ifdef CONFIG_IWLWIFI_DEBUG + if (iwl_get_debug_level(priv->shrd) & IWL_DL_FW_ERRORS) + iwl_print_rx_config_cmd(priv, IWL_RXON_CTX_BSS); +#endif + /* Set the FW error flag -- cleared on iwl_down */ set_bit(STATUS_FW_ERROR, &priv->shrd->status); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index e7b075eebb72..5140c7829662 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -557,16 +557,6 @@ iwl_remove_notification(struct iwl_shared *shrd, void iwl_reset_traffic_log(struct iwl_priv *priv); #endif /* CONFIG_IWLWIFI_DEBUGFS */ -#ifdef CONFIG_IWLWIFI_DEBUG -void iwl_print_rx_config_cmd(struct iwl_priv *priv, - enum iwl_rxon_context_id ctxid); -#else -static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv, - enum iwl_rxon_context_id ctxid) -{ -} -#endif - #define IWL_CMD(x) case x: return #x #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 60e70b78d7d1..2c910fddaaf6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -695,10 +695,6 @@ static void iwl_irq_handle_error(struct iwl_trans *trans) iwl_dump_csr(trans); iwl_dump_fh(trans, NULL, false); iwl_dump_nic_event_log(trans, false, NULL, false); -#ifdef CONFIG_IWLWIFI_DEBUG - if (iwl_get_debug_level(trans->shrd) & IWL_DL_FW_ERRORS) - iwl_print_rx_config_cmd(priv(trans), IWL_RXON_CTX_BSS); -#endif iwl_op_mode_nic_error(trans->op_mode); } -- GitLab From 4d660ce52e27957f7181ef662889eec67686c7b5 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 15 Feb 2012 12:48:04 +0200 Subject: [PATCH 1204/1846] iwlwifi: remove iwl_reset_traffic_log from shared It is op_mode related Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-core.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-shared.h | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 930e247bbae6..42630f5e8de7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -197,6 +197,8 @@ const char *get_ctrl_string(int cmd); void iwl_clear_traffic_stats(struct iwl_priv *priv); void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len); +void iwl_reset_traffic_log(struct iwl_priv *priv); + #else static inline int iwl_alloc_traffic_mem(struct iwl_priv *priv) { diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 5140c7829662..a6441623e6b1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -553,10 +553,6 @@ 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 */ - #define IWL_CMD(x) case x: return #x #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -- GitLab From 53476fe11f730e37a6e8f0eabb25d59485e9854b Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 16 Feb 2012 09:35:19 +0200 Subject: [PATCH 1205/1846] iwlwifi: document the operational mode Also add a might_sleep to enforce the context requirements. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 36 ++++++++++++++++++++-- drivers/net/wireless/iwlwifi/iwl-trans.h | 6 ---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index e2a780d12467..d4fc9be2d2f3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -69,17 +69,47 @@ struct sk_buff; struct iwl_device_cmd; struct iwl_rx_mem_buffer; +/** + * DOC: Operational mode - what is it ? + * + * The operational mode (a.k.a. op_mode) is the layer that implements + * mac80211's handlers. It knows two APIs: mac80211's and the fw's. It uses + * the transport API to access the HW. The op_mode doesn't need to know how the + * underlying HW works, since the transport layer takes care of that. + * + * There can be several op_mode: i.e. different fw APIs will require two + * different op_modes. This is why the op_mode is virtualized. + */ + +/** + * DOC: Life cycle of the Operational mode + * + * The operational mode has a very simple life cycle. + * + * 1) The driver layer (iwl-drv.c) chooses the op_mode based on the + * capabilities advertized by the fw file (in TLV format). + * 2) The driver layer starts the op_mode (ops->start) + * 3) The op_mode registers registers mac80211 + * 4) The op_mode is governed by mac80211 + * 5) The driver layer stops the op_mode + */ + /** * struct iwl_op_mode_ops - op_mode specific operations * + * The op_mode exports its ops so that external components can start it and + * interact with it. The driver layer typically calls the start and stop + * handlers, the transport layer calls the others. + * * All the handlers MUST be implemented * - * @start: start the op_mode + * @start: start the op_mode. The transport layer is already allocated. * May sleep - * @stop: stop the op_mode + * @stop: stop the op_mode. Must free all the memory allocated. * May sleep * @rx: Rx notification to the op_mode. rxb is the Rx buffer itself. Cmd is the * HCMD the this Rx responds to. + * Must be atomic. * @queue_full: notifies that a HW queue is full. Ac is the ac of the queue * Must be atomic * @queue_not_full: notifies that a HW queue is not full any more. @@ -120,6 +150,8 @@ struct iwl_op_mode { static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode) { + might_sleep(); + op_mode->ops->stop(op_mode); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 52a1c2eda8e8..08d93b9c94e9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -106,12 +106,6 @@ * 6) Eventually, the free function will be called. */ -/** - * DOC: API needed by the transport layer from the op_mode - * - * TODO - */ - struct iwl_priv; struct iwl_shared; struct iwl_op_mode; -- GitLab From e679378dc684ed1ed7b7f6e56cb7a6b0f6461f9c Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 16 Feb 2012 09:47:01 +0200 Subject: [PATCH 1206/1846] iwlwifi: iwl-trans.h doesn't need all these includes We can use forward declaration for the relevant struct since they aren't dereferenced in the header file. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 + drivers/net/wireless/iwlwifi/iwl-trans.h | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ca0fa9c8e89c..9f8b23909404 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -76,6 +76,7 @@ #include "iwl-eeprom.h" #include "iwl-agn-hw.h" #include "iwl-core.h" +#include "iwl-ucode.h" static int iwl_trans_rx_alloc(struct iwl_trans *trans) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 08d93b9c94e9..4e7e6c0eede9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -63,12 +63,9 @@ #ifndef __iwl_trans_h__ #define __iwl_trans_h__ -#include -#include +#include #include "iwl-shared.h" -#include "iwl-commands.h" -#include "iwl-ucode.h" #include "iwl-debug.h" /** @@ -109,6 +106,9 @@ struct iwl_priv; struct iwl_shared; struct iwl_op_mode; +struct fw_img; +struct sk_buff; +struct dentry; /** * DOC: Host command section -- GitLab From 259653d86b80ed01c70d47b7307140ae0ba19420 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 22 Feb 2012 08:18:55 -0800 Subject: [PATCH 1207/1846] iwlwifi: one more sku added to 6x35 series Add new sku to 6x35 series Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 527f13b50055..93bd9f621f86 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -241,6 +241,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, + {IWL_PCI_DEVICE(0x088E, 0x4860, iwl6035_2agn_cfg)}, /* 105 Series */ {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, -- GitLab From 378911233f424d7a1bf4a579587ae71c7d887166 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 22 Feb 2012 10:21:09 -0800 Subject: [PATCH 1208/1846] iwlwifi: update pci subsystem id Update the pci subsystem id and product name for 6005 series devices Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-6000.c | 11 +++++++++++ drivers/net/wireless/iwlwifi/iwl-cfg.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-pci.c | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 1e6fbf4fcb46..223e60a1b79d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -383,6 +383,17 @@ struct iwl_cfg iwl6005_2agn_d_cfg = { .ht_params = &iwl6000_ht_params, }; +struct iwl_cfg iwl6005_2agn_mow1_cfg = { + .name = "Intel(R) Centrino(R) Advanced-N 6206 AGN", + IWL_DEVICE_6005, + .ht_params = &iwl6000_ht_params, +}; +struct iwl_cfg iwl6005_2agn_mow2_cfg = { + .name = "Intel(R) Centrino(R) Advanced-N 6207 AGN", + IWL_DEVICE_6005, + .ht_params = &iwl6000_ht_params, +}; + #define IWL_DEVICE_6030 \ .fw_name_pre = IWL6030_FW_PRE, \ .ucode_api_max = IWL6000G2_UCODE_API_MAX, \ diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h index 957bc00cdaf0..1ad14bbccc99 100644 --- a/drivers/net/wireless/iwlwifi/iwl-cfg.h +++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h @@ -80,6 +80,8 @@ extern struct iwl_cfg iwl6005_2abg_cfg; extern struct iwl_cfg iwl6005_2bg_cfg; extern struct iwl_cfg iwl6005_2agn_sff_cfg; extern struct iwl_cfg iwl6005_2agn_d_cfg; +extern struct iwl_cfg iwl6005_2agn_mow1_cfg; +extern struct iwl_cfg iwl6005_2agn_mow2_cfg; extern struct iwl_cfg iwl1030_bgn_cfg; extern struct iwl_cfg iwl1030_bg_cfg; extern struct iwl_cfg iwl6030_2agn_cfg; diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 93bd9f621f86..0ce704715ce9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -158,9 +158,9 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { {IWL_PCI_DEVICE(0x0085, 0x1316, iwl6005_2abg_cfg)}, {IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)}, {IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)}, - {IWL_PCI_DEVICE(0x0082, 0x1341, iwl6005_2agn_d_cfg)}, - {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_cfg)},/* low 5GHz active */ - {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_cfg)},/* high 5GHz active */ + {IWL_PCI_DEVICE(0x0082, 0x4820, iwl6005_2agn_d_cfg)}, + {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_mow1_cfg)},/* low 5GHz active */ + {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_mow2_cfg)},/* high 5GHz active */ /* 6x30 Series */ {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, -- GitLab From 659373d5152705b83283860364bfd4e2b1422f7a Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 23 Feb 2012 10:18:00 +0200 Subject: [PATCH 1209/1846] iwlwifi: fix IDI compilation This is a fixup for my: iwlwifi: kill iwl_bus.h Please fold them into one patch for upstream Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 0ce704715ce9..06e004157dcc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -278,7 +278,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) #ifdef CONFIG_IWLWIFI_IDI iwl_trans = iwl_trans_idi_alloc(shrd, pdev, ent); - if (trans == NULL) { + if (iwl_trans == NULL) { err = -ENOMEM; goto out_free_bus; } -- GitLab From 0b60eba1b29740a606e6b7694d2dc98b6085a1bf Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 00:57:24 +0200 Subject: [PATCH 1210/1846] Bluetooth: Don't send unnecessary write_le_enable command If the local host features indicate that LE is already in the state that is desired there's no point in sending the HCI command to try to change the setting. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 27830f401698..c4d3bc9c86b5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1260,7 +1260,7 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) struct pending_cmd *cmd; struct hci_dev *hdev; int err; - u8 val; + u8 val, enabled; BT_DBG("request for hci%u", index); @@ -1280,8 +1280,9 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) } val = !!cp->val; + enabled = !!(hdev->host_features[0] & LMP_HOST_LE); - if (!hdev_is_powered(hdev)) { + if (!hdev_is_powered(hdev) || val == enabled) { bool changed = false; if (val != test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { -- GitLab From 8f984dfaf0bfa1355548cfba00473c8fa8e22d6e Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 01:07:22 +0200 Subject: [PATCH 1211/1846] Bluetooth: Remove redundant read_host_features commands Previously the write_le_enable would trigger a read_host_features command but since we have access to the value LE support was set to we can simply just clear or set the bit in hdev->host_features. This also removes a second unnecessary read_host_features command from the device initialization procedure since LE is only enabled after the first read_host_features command completes. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 59 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e920cd520a82..488fdbcfe762 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -542,20 +542,6 @@ static void hci_setup_event_mask(struct hci_dev *hdev) hci_send_cmd(hdev, HCI_OP_SET_EVENT_MASK, sizeof(events), events); } -static void hci_set_le_support(struct hci_dev *hdev) -{ - struct hci_cp_write_le_host_supported cp; - - memset(&cp, 0, sizeof(cp)); - - if (enable_le && test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { - cp.le = 1; - cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); - } - - hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp), &cp); -} - static void hci_setup(struct hci_dev *hdev) { if (hdev->dev_type != HCI_BREDR) @@ -608,9 +594,6 @@ static void hci_setup(struct hci_dev *hdev) hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, sizeof(enable), &enable); } - - if (hdev->features[4] & LMP_LE) - hci_set_le_support(hdev); } static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) @@ -730,6 +713,22 @@ static void hci_cc_read_local_features(struct hci_dev *hdev, struct sk_buff *skb hdev->features[6], hdev->features[7]); } +static void hci_set_le_support(struct hci_dev *hdev) +{ + struct hci_cp_write_le_host_supported cp; + + memset(&cp, 0, sizeof(cp)); + + if (enable_le && test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { + cp.le = 1; + cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); + } + + if (cp.le != !!(hdev->host_features[0] & LMP_HOST_LE)) + hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, + sizeof(cp), &cp); +} + static void hci_cc_read_local_ext_features(struct hci_dev *hdev, struct sk_buff *skb) { @@ -738,7 +737,7 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev, BT_DBG("%s status 0x%x", hdev->name, rp->status); if (rp->status) - return; + goto done; switch (rp->page) { case 0: @@ -749,6 +748,10 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev, break; } + if (test_bit(HCI_INIT, &hdev->flags) && hdev->features[4] & LMP_LE) + hci_set_le_support(hdev); + +done: hci_req_complete(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, rp->status); } @@ -1149,21 +1152,27 @@ static void hci_cc_le_ltk_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_cc_write_le_host_supported(struct hci_dev *hdev, struct sk_buff *skb) { - struct hci_cp_read_local_ext_features cp; struct hci_cp_write_le_host_supported *sent; __u8 status = *((__u8 *) skb->data); BT_DBG("%s status 0x%x", hdev->name, status); sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); - if (sent && test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_le_enable_complete(hdev, sent->le, status); - - if (status) + if (!sent) return; - cp.page = 0x01; - hci_send_cmd(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, sizeof(cp), &cp); + if (!status) { + if (sent->le) + hdev->host_features[0] |= LMP_HOST_LE; + else + hdev->host_features[0] &= ~LMP_HOST_LE; + } + + if (test_bit(HCI_MGMT, &hdev->dev_flags) && + !test_bit(HCI_INIT, &hdev->flags)) + mgmt_le_enable_complete(hdev, sent->le, status); + + hci_req_complete(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, status); } static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) -- GitLab From cc2c04ec1ea8bd5137c99dc88bc04b4a07a11443 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 02:03:24 +0200 Subject: [PATCH 1212/1846] Bluetooth: Add missing host features definitions This patch adds missing SSP and "Simultaneous LE & BR/EDR" feature bit definitions to hci.h. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 0c54fcfe7e0f..3acbebfb22b9 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -237,7 +237,9 @@ enum { #define LMP_EXTFEATURES 0x80 /* Extended LMP features */ -#define LMP_HOST_LE 0x02 +#define LMP_HOST_SSP 0x01 +#define LMP_HOST_LE 0x02 +#define LMP_HOST_LE_BREDR 0x04 /* Connection modes */ #define HCI_CM_ACTIVE 0x0000 -- GitLab From 02b7cc62b6176748dc5b55e0ca9c965f73a5c300 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 02:28:43 +0200 Subject: [PATCH 1213/1846] Bluetooth: Use LMP_HOST_SSP define instead of magic values This patch fixes the code to use the proper LMP_HOST_SSP define instead of magic values and thereby makes the code more readable. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 488fdbcfe762..8c3261db7611 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2869,9 +2869,9 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b ie = hci_inquiry_cache_lookup(hdev, &conn->dst); if (ie) - ie->data.ssp_mode = (ev->features[0] & 0x01); + ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); - if (ev->features[0] & 0x01) + if (ev->features[0] & LMP_HOST_SSP) set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); } @@ -3224,7 +3224,7 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_ ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); if (ie) - ie->data.ssp_mode = (ev->features[0] & 0x01); + ie->data.ssp_mode = (ev->features[0] & LMP_HOST_SSP); hci_dev_unlock(hdev); } -- GitLab From bd5b5ac2873da5a153fa32ff58d2fc4e25f7bc8a Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 10 Feb 2012 20:40:32 +0530 Subject: [PATCH 1214/1846] ath6kl: Make sure to allocate rx buffers after the endpoint connection Rx buffers should be allocated for control and best effort endpoints only after the enpoints connection is esablished. But this is done before the endpoint connection is complete, we don't even the control and BE endpoints that time. Move the buffer allocation after endpoint connection is over, after ath6kl_init_hw_start(). Found in review, never seen any real issue with this. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 6dec186d9ac7..39684650e843 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -136,10 +136,6 @@ int ath6kl_core_init(struct ath6kl *ar) ar->ac_stream_pri_map[WMM_AC_VI] = 2; ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */ - /* give our connected endpoints some buffers */ - ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep); - ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]); - /* allocate some buffers that handle larger AMSDU frames */ ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS); @@ -182,6 +178,10 @@ int ath6kl_core_init(struct ath6kl *ar) goto err_rxbuf_cleanup; } + /* give our connected endpoints some buffers */ + ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep); + ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]); + /* * Set mac address which is received in ready event * FIXME: Move to ath6kl_interface_add() -- GitLab From 5378f244b677f6696ca8a9a467cef16cd399b0e2 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 10 Feb 2012 20:40:33 +0530 Subject: [PATCH 1215/1846] ath6kl: Fix memory leak of rx packets in endpoint 0 htc_packet and htc_packet->buf_start are separately allocated for endpoint 0. This is different for other endpoints where packets are allocated as skb where htc_packet is skb->head and they are freed properly. Free htc_packet and htc_packet->buf_start separatly for endpoint 0. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/htc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 920e7c07fd4f..c6f45a744d52 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -2372,7 +2372,21 @@ void ath6kl_htc_flush_rx_buf(struct htc_target *target) "htc rx flush pkt 0x%p len %d ep %d\n", packet, packet->buf_len, packet->endpoint); - dev_kfree_skb(packet->pkt_cntxt); + /* + * packets in rx_bufq of endpoint 0 have originally + * been queued from target->free_ctrl_rxbuf where + * packet and packet->buf_start are allocated + * separately using kmalloc(). For other endpoint + * rx_bufq, it is allocated as skb where packet is + * skb->head. Take care of this difference while freeing + * the memory. + */ + if (packet->endpoint == ENDPOINT_0) { + kfree(packet->buf_start); + kfree(packet); + } else { + dev_kfree_skb(packet->pkt_cntxt); + } spin_lock_bh(&target->rx_lock); } spin_unlock_bh(&target->rx_lock); -- GitLab From 13423c31195efb1a1ac319294f5a0148a13433e6 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 21 Feb 2012 15:30:42 +0530 Subject: [PATCH 1216/1846] ath6kl: Make foreground scan a deterministic one This makes the device get into scan state as soon as a scan request is received, instead of blocking the scan request till the traffic comes down. It is necessary for the deterministic foreground scan particularly when having multiple vif operating where, if the scan is non- deterministic, scan on one interface will not start as long as there are traffic on the other interface. This change passes 50 msec as foreground scan interval to fix this. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 11 +++++++---- drivers/net/wireless/ath/ath6kl/core.h | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index a47688054ce9..d8d483798530 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -927,14 +927,17 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, */ ret = ath6kl_wmi_beginscan_cmd(ar->wmi, vif->fw_vif_idx, WMI_LONG_SCAN, force_fg_scan, - false, 0, 0, n_channels, - channels, request->no_cck, + false, 0, + ATH6KL_FG_SCAN_INTERVAL, + n_channels, channels, + request->no_cck, request->rates); } else { ret = ath6kl_wmi_startscan_cmd(ar->wmi, vif->fw_vif_idx, WMI_LONG_SCAN, force_fg_scan, - false, 0, 0, n_channels, - channels); + false, 0, + ATH6KL_FG_SCAN_INTERVAL, + n_channels, channels); } if (ret) ath6kl_err("wmi_startscan_cmd failed\n"); diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 09efafa5fef1..5bbc595f23d1 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -63,6 +63,9 @@ #define A_DEFAULT_LISTEN_INTERVAL 1 /* beacon intervals */ #define A_MAX_WOW_LISTEN_INTERVAL 1000 +/* Channel dwell time in fg scan */ +#define ATH6KL_FG_SCAN_INTERVAL 50 /* in ms */ + /* includes also the null byte */ #define ATH6KL_FIRMWARE_MAGIC "QCA-ATH6KL" -- GitLab From 4480bb59361b317d9a0a7b8cc6daafae14570f49 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Wed, 22 Feb 2012 12:03:51 +0530 Subject: [PATCH 1217/1846] ath6kl: Lower SDIO pad drive strength for hw2.1.1 board Without this change, SDIO shuts down due to CRC error during data communication to the firmware in some of the platform. for example, scan request issued to the firmware doesn't return scan completed events and cause the socket interface to always return -16 (device busy). SDIO pad drive strength should be reduced for hw2.1.1 board to avoid such errors. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 6fed6280174f..f3b5502362d8 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1406,7 +1406,8 @@ static int ath6kl_init_upload(struct ath6kl *ar) return status; /* WAR to avoid SDIO CRC err */ - if (ar->version.target_ver == AR6003_HW_2_0_VERSION) { + if (ar->version.target_ver == AR6003_HW_2_0_VERSION || + ar->version.target_ver == AR6003_HW_2_1_1_VERSION) { ath6kl_err("temporary war to avoid sdio crc error\n"); param = 0x20; -- GitLab From faaf192908b163eaeddc69940e08f2f42d72ea5d Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Mon, 27 Feb 2012 11:44:19 +0530 Subject: [PATCH 1218/1846] ath6kl: Register driver ht capabilities in wiphy Register driver's ht capabilities in wiphy to avoid failures in setting ht channels from hostapd. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d8d483798530..5da0f292ec79 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -69,6 +69,10 @@ static struct ieee80211_rate ath6kl_rates[] = { #define ath6kl_g_rates (ath6kl_rates + 0) #define ath6kl_g_rates_size 12 +#define ath6kl_g_htcap (IEEE80211_HT_CAP_SUP_WIDTH_20_40 | \ + IEEE80211_HT_CAP_SGI_20 | \ + IEEE80211_HT_CAP_SGI_40) + static struct ieee80211_channel ath6kl_2ghz_channels[] = { CHAN2G(1, 2412, 0), CHAN2G(2, 2417, 0), @@ -113,6 +117,8 @@ static struct ieee80211_supported_band ath6kl_band_2ghz = { .channels = ath6kl_2ghz_channels, .n_bitrates = ath6kl_g_rates_size, .bitrates = ath6kl_g_rates, + .ht_cap.cap = ath6kl_g_htcap, + .ht_cap.ht_supported = true, }; static struct ieee80211_supported_band ath6kl_band_5ghz = { @@ -120,6 +126,8 @@ static struct ieee80211_supported_band ath6kl_band_5ghz = { .channels = ath6kl_5ghz_a_channels, .n_bitrates = ath6kl_a_rates_size, .bitrates = ath6kl_a_rates, + .ht_cap.cap = ath6kl_g_htcap, + .ht_cap.ht_supported = true, }; #define CCKM_KRK_CIPHER_SUITE 0x004096ff /* use for KRK */ -- GitLab From 7c64fd98ce512de6c6dae0452dc026446bd368d5 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 28 Feb 2012 10:55:36 +0100 Subject: [PATCH 1219/1846] batman-adv: Fix indentation of multiline statements Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/bat_sysfs.c | 4 ++-- net/batman-adv/bitarray.c | 8 ++++---- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/gateway_common.c | 4 ++-- net/batman-adv/hard-interface.c | 30 +++++++++++++++--------------- net/batman-adv/originator.c | 5 ++--- net/batman-adv/routing.c | 8 ++++---- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/translation-table.c | 26 +++++++++++++------------- 9 files changed, 44 insertions(+), 45 deletions(-) diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c index 7317729a00f7..b00101db5cc6 100644 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c @@ -321,11 +321,11 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr, gw_mode_tmp = GW_MODE_OFF; if (strncmp(buff, GW_MODE_CLIENT_NAME, - strlen(GW_MODE_CLIENT_NAME)) == 0) + strlen(GW_MODE_CLIENT_NAME)) == 0) gw_mode_tmp = GW_MODE_CLIENT; if (strncmp(buff, GW_MODE_SERVER_NAME, - strlen(GW_MODE_SERVER_NAME)) == 0) + strlen(GW_MODE_SERVER_NAME)) == 0) gw_mode_tmp = GW_MODE_SERVER; if (gw_mode_tmp < 0) { diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c index e63069d61dbb..6d0aa216b232 100644 --- a/net/batman-adv/bitarray.c +++ b/net/batman-adv/bitarray.c @@ -154,8 +154,8 @@ int bit_get_packet(void *priv, unsigned long *seq_bits, /* sequence number is much newer, probably missed a lot of packets */ - if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) - && (seq_num_diff < EXPECTED_SEQNO_RANGE)) { + if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) && + (seq_num_diff < EXPECTED_SEQNO_RANGE)) { bat_dbg(DBG_BATMAN, bat_priv, "We missed a lot of packets (%i) !\n", seq_num_diff - 1); @@ -170,8 +170,8 @@ int bit_get_packet(void *priv, unsigned long *seq_bits, * packet should be dropped without calling this function if the * seqno window is protected. */ - if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) - || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { + if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || + (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { bat_dbg(DBG_BATMAN, bat_priv, "Other host probably restarted!\n"); diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 65a77a10f17d..0fa8e2d7c46e 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -629,7 +629,7 @@ bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) /* check for bootp port */ if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && - (ntohs(udphdr->dest) != 67)) + (ntohs(udphdr->dest) != 67)) return false; if ((ntohs(ethhdr->h_proto) == ETH_P_IPV6) && diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 7f79e156e64d..3ccb9c87fd19 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -93,7 +93,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, multi = 1024; if ((strnicmp(tmp_ptr, "kbit", 4) == 0) || - (multi > 1)) + (multi > 1)) *tmp_ptr = '\0'; } @@ -118,7 +118,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, multi = 1024; if ((strnicmp(tmp_ptr, "kbit", 4) == 0) || - (multi > 1)) + (multi > 1)) *tmp_ptr = '\0'; } diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 41826b96d9f1..409d0273c9d1 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -341,23 +341,23 @@ int hardif_enable_interface(struct hard_iface *hard_iface, if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < ETH_DATA_LEN + BAT_HEADER_LEN) bat_info(hard_iface->soft_iface, - "The MTU of interface %s is too small (%i) to handle " - "the transport of batman-adv packets. Packets going " - "over this interface will be fragmented on layer2 " - "which could impact the performance. Setting the MTU " - "to %zi would solve the problem.\n", - hard_iface->net_dev->name, hard_iface->net_dev->mtu, - ETH_DATA_LEN + BAT_HEADER_LEN); + "The MTU of interface %s is too small (%i) to handle " + "the transport of batman-adv packets. Packets going " + "over this interface will be fragmented on layer2 " + "which could impact the performance. Setting the MTU " + "to %zi would solve the problem.\n", + hard_iface->net_dev->name, hard_iface->net_dev->mtu, + ETH_DATA_LEN + BAT_HEADER_LEN); if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < ETH_DATA_LEN + BAT_HEADER_LEN) bat_info(hard_iface->soft_iface, - "The MTU of interface %s is too small (%i) to handle " - "the transport of batman-adv packets. If you experience" - " problems getting traffic through try increasing the " - "MTU to %zi.\n", - hard_iface->net_dev->name, hard_iface->net_dev->mtu, - ETH_DATA_LEN + BAT_HEADER_LEN); + "The MTU of interface %s is too small (%i) to handle " + "the transport of batman-adv packets. If you " + "experience problems getting traffic through try " + "increasing the MTU to %zi.\n", + hard_iface->net_dev->name, hard_iface->net_dev->mtu, + ETH_DATA_LEN + BAT_HEADER_LEN); if (hardif_is_iface_up(hard_iface)) hardif_activate_interface(hard_iface); @@ -580,8 +580,8 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, goto err_free; /* expect a valid ethernet header here. */ - if (unlikely(skb->mac_len != sizeof(struct ethhdr) - || !skb_mac_header(skb))) + if (unlikely(skb->mac_len != sizeof(struct ethhdr) || + !skb_mac_header(skb))) goto err_free; if (!hard_iface->soft_iface) diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index c2e46b551624..371cc93d8e17 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -143,7 +143,7 @@ static void orig_node_free_rcu(struct rcu_head *rcu) frag_list_free(&orig_node->frag_list); tt_global_del_orig(orig_node->bat_priv, orig_node, - "originator timed out"); + "originator timed out"); kfree(orig_node->tt_buff); kfree(orig_node->bcast_own); @@ -333,9 +333,8 @@ static bool purge_orig_node(struct bat_priv *bat_priv, return true; } else { if (purge_orig_neighbors(bat_priv, orig_node, - &best_neigh_node)) { + &best_neigh_node)) update_route(bat_priv, orig_node, best_neigh_node); - } } return false; diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index cf9a2f62de6a..f53515562a4f 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -72,7 +72,7 @@ static void _update_route(struct bat_priv *bat_priv, bat_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", orig_node->orig); tt_global_del_orig(bat_priv, orig_node, - "Deleted route towards originator"); + "Deleted route towards originator"); /* route added */ } else if ((!curr_router) && (neigh_node)) { @@ -229,8 +229,8 @@ void bonding_save_primary(const struct orig_node *orig_node, int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, unsigned long *last_reset) { - if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) - || (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { + if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || + (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { if (has_timed_out(*last_reset, RESET_PROTECTION_MS)) { *last_reset = jiffies; @@ -429,7 +429,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) if ((hdr_size == sizeof(struct icmp_packet_rr)) && (icmp_packet->rr_cur < BAT_RR_LEN)) { memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), - ethhdr->h_dest, ETH_ALEN); + ethhdr->h_dest, ETH_ALEN); icmp_packet->rr_cur++; } diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 2ffdc74ac40e..c39c120e1171 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -397,7 +397,7 @@ void softif_neigh_purge(struct bat_priv *bat_priv) &softif_neigh_vid->softif_neigh_list, list) { if ((!has_timed_out(softif_neigh->last_seen, - SOFTIF_NEIGH_TIMEOUT)) && + SOFTIF_NEIGH_TIMEOUT)) && (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE)) continue; diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 9a6f315b7d44..c9507057c98e 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -261,7 +261,7 @@ int tt_changes_fill_buffer(struct bat_priv *bat_priv, atomic_set(&bat_priv->tt_local_changes, 0); list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, - list) { + list) { if (count < tot_changes) { memcpy(buff + tt_len(count), &entry->change, sizeof(struct tt_change)); @@ -333,17 +333,17 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) hlist_for_each_entry_rcu(tt_common_entry, node, head, hash_entry) { seq_printf(seq, " * %pM [%c%c%c%c%c]\n", - tt_common_entry->addr, - (tt_common_entry->flags & - TT_CLIENT_ROAM ? 'R' : '.'), - (tt_common_entry->flags & - TT_CLIENT_NOPURGE ? 'P' : '.'), - (tt_common_entry->flags & - TT_CLIENT_NEW ? 'N' : '.'), - (tt_common_entry->flags & - TT_CLIENT_PENDING ? 'X' : '.'), - (tt_common_entry->flags & - TT_CLIENT_WIFI ? 'W' : '.')); + tt_common_entry->addr, + (tt_common_entry->flags & + TT_CLIENT_ROAM ? 'R' : '.'), + (tt_common_entry->flags & + TT_CLIENT_NOPURGE ? 'P' : '.'), + (tt_common_entry->flags & + TT_CLIENT_NEW ? 'N' : '.'), + (tt_common_entry->flags & + TT_CLIENT_PENDING ? 'X' : '.'), + (tt_common_entry->flags & + TT_CLIENT_WIFI ? 'W' : '.')); } rcu_read_unlock(); } @@ -704,7 +704,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, spin_lock_bh(list_lock); hlist_for_each_entry_safe(tt_common_entry, node, safe, - head, hash_entry) { + head, hash_entry) { tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, common); -- GitLab From 5af70c864a1539bd1d3f3fcb04ab9558491c9103 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:28 +0200 Subject: [PATCH 1220/1846] wl12xx: set the ELP entry delay to the FW dyn-ps timeout With PSM handled in FW, the checks in wl1271_elp_work() are always true. Thus during active traffic we constantly enter and exit ELP (many times per second). As each ELP exit takes ~10ms, this can have an adverse effect on throughput and interactivity. Set the ELP timeout to the dyn-ps timeout. This period is longer and avoids the above problem. It also makes sense to stay out of ELP while we are awake on the network, to minimize delays in Tx/Rx. The same thing was done by the mac80211 dynamic-ps mechanism before the FW DPS changes. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/ps.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 23d67501c50a..78f598b4f97b 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -69,8 +69,6 @@ void wl1271_elp_work(struct work_struct *work) mutex_unlock(&wl->mutex); } -#define ELP_ENTRY_DELAY 5 - /* Routines to toggle sleep mode while in ELP */ void wl1271_ps_elp_sleep(struct wl1271 *wl) { @@ -90,7 +88,7 @@ void wl1271_ps_elp_sleep(struct wl1271 *wl) } ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, - msecs_to_jiffies(ELP_ENTRY_DELAY)); + msecs_to_jiffies(wl->conf.conn.dynamic_ps_timeout)); } int wl1271_ps_elp_wakeup(struct wl1271 *wl) -- GitLab From 0b0e32b792b4077c113ae70d6de12b5f301e0882 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:29 +0200 Subject: [PATCH 1221/1846] wl12xx: change bits in the link_map under spin lock These bits are used in op_tx to determine if a packet should be dropped. As such we should use the spin lock to sync the state. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index b776d9d5efe8..ef994dacf8d2 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -459,23 +459,32 @@ int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id) int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) { + unsigned long flags; u8 link = find_first_zero_bit(wl->links_map, WL12XX_MAX_LINKS); if (link >= WL12XX_MAX_LINKS) return -EBUSY; + /* these bits are used by op_tx */ + spin_lock_irqsave(&wl->wl_lock, flags); __set_bit(link, wl->links_map); __set_bit(link, wlvif->links_map); + spin_unlock_irqrestore(&wl->wl_lock, flags); *hlid = link; return 0; } void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) { + unsigned long flags; + if (*hlid == WL12XX_INVALID_LINK_ID) return; + /* these bits are used by op_tx */ + spin_lock_irqsave(&wl->wl_lock, flags); __clear_bit(*hlid, wl->links_map); __clear_bit(*hlid, wlvif->links_map); + spin_unlock_irqrestore(&wl->wl_lock, flags); *hlid = WL12XX_INVALID_LINK_ID; } -- GitLab From 6246ca003f2560e30b9696757efc271284b809f6 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:30 +0200 Subject: [PATCH 1222/1846] wl12xx: reset link Tx queues when freeing it Before, the link was first freed (invalidating it in the map), and later on vif removal, all valid wlvif-related links were reset. Since these links were already invalid, we failed to reset them. The bug was made worse by op_stop, which set the tx_queue_count to 0 arbitrarily. This resulted in a negative tx_queue_count in some scenarios. Fix this by resetting the Tx-queues of a link when freeing it. Add a WARN_ON and reset all link Tx-queues in op_stop, to avoid a negative tx_queue_count. [changed WARN_ON to WARN_ON_ONCE -- Luca] Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 7 +++++++ drivers/net/wireless/wl12xx/main.c | 1 - drivers/net/wireless/wl12xx/tx.c | 13 ++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index ef994dacf8d2..ae1f3d7f34d2 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -485,6 +485,13 @@ void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) __clear_bit(*hlid, wl->links_map); __clear_bit(*hlid, wlvif->links_map); spin_unlock_irqrestore(&wl->wl_lock, flags); + + /* + * At this point op_tx() will not add more packets to the queues. We + * can purge them. + */ + wl1271_tx_reset_link_queues(wl, *hlid); + *hlid = WL12XX_INVALID_LINK_ID; } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index adf9bbcf88fd..712e38530153 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4228,7 +4228,6 @@ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) 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); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 6446e4d3e8f9..8f5ab047aec8 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -527,6 +527,7 @@ static struct sk_buff *wl12xx_lnk_skb_dequeue(struct wl1271 *wl, if (skb) { int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); spin_lock_irqsave(&wl->wl_lock, flags); + WARN_ON_ONCE(wl->tx_queue_count[q] <= 0); wl->tx_queue_count[q]--; spin_unlock_irqrestore(&wl->wl_lock, flags); } @@ -602,6 +603,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) skb = wl->dummy_packet; q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); spin_lock_irqsave(&wl->wl_lock, flags); + WARN_ON_ONCE(wl->tx_queue_count[q] <= 0); wl->tx_queue_count[q]--; spin_unlock_irqrestore(&wl->wl_lock, flags); } @@ -959,7 +961,6 @@ void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif) else 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; } @@ -973,8 +974,14 @@ void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues) struct sk_buff *skb; struct ieee80211_tx_info *info; - for (i = 0; i < NUM_TX_QUEUES; i++) - wl->tx_queue_count[i] = 0; + /* only reset the queues if something bad happened */ + if (WARN_ON_ONCE(wl1271_tx_total_queue_count(wl) != 0)) { + for (i = 0; i < WL12XX_MAX_LINKS; i++) + wl1271_tx_reset_link_queues(wl, i); + + for (i = 0; i < NUM_TX_QUEUES; i++) + wl->tx_queue_count[i] = 0; + } wl->stopped_queues_map = 0; -- GitLab From 49c9cd26445aa8bc8348c384c943b758c57c47a9 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:31 +0200 Subject: [PATCH 1223/1846] wl12xx: avoid starving the system hlid Re-factor the Tx scheduler so that the system_hlid is taken into account before restarting an iteration over the wlvifs. Previously this hlid had a lower priority and would starve if some wlvif had many packets. In addition avoid iterating over wlvifs past last_wlvif when performing the a second pass. If we had packets in those wlvifs they would have been found earlier. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8f5ab047aec8..6640c3975cfb 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -572,6 +572,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) struct wl12xx_vif *wlvif = wl->last_wlvif; struct sk_buff *skb = NULL; + /* continue from last wlvif (round robin) */ if (wlvif) { wl12xx_for_each_wlvif_continue(wl, wlvif) { skb = wl12xx_vif_skb_dequeue(wl, wlvif); @@ -582,7 +583,11 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) } } - /* do another pass */ + /* dequeue from the system HLID before the restarting wlvif list */ + if (!skb) + skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[wl->system_hlid]); + + /* do a new pass over the wlvif list */ if (!skb) { wl12xx_for_each_wlvif(wl, wlvif) { skb = wl12xx_vif_skb_dequeue(wl, wlvif); @@ -590,12 +595,16 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) wl->last_wlvif = wlvif; break; } + + /* + * No need to continue after last_wlvif. The previous + * pass should have found it. + */ + if (wlvif == wl->last_wlvif) + break; } } - 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; -- GitLab From 18aa755b84715f36e2811734f95cb822bcacfd89 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:32 +0200 Subject: [PATCH 1224/1846] wl12xx: flush all Tx queues on tx_flush timeout Ensure our queues are empty at the end of a tx_flush(), in case we timeout on passively waiting for them. This makes sure no left-overs are transmitted when we are on the wrong channel. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 6640c3975cfb..8f78fddcb723 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -1040,6 +1040,7 @@ void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues) void wl1271_tx_flush(struct wl1271 *wl) { unsigned long timeout; + int i; timeout = jiffies + usecs_to_jiffies(WL1271_TX_FLUSH_TIMEOUT); while (!time_after(jiffies, timeout)) { @@ -1057,6 +1058,12 @@ void wl1271_tx_flush(struct wl1271 *wl) } wl1271_warning("Unable to flush all TX buffers, timed out."); + + /* forcibly flush all Tx buffers on our queues */ + mutex_lock(&wl->mutex); + for (i = 0; i < WL12XX_MAX_LINKS; i++) + wl1271_tx_reset_link_queues(wl, i); + mutex_unlock(&wl->mutex); } u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set) -- GitLab From b9239b665889582835fbd54730902eee08aa42d7 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:33 +0200 Subject: [PATCH 1225/1846] wl12xx: flush Tx during suspend and 802.11h chan switch Flush our Tx queues before suspending or changing the channel due to a channel_switch element in the AP beacon. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 712e38530153..ad1a4addaab5 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1737,6 +1737,8 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); WARN_ON(!wow || !wow->any); + wl1271_tx_flush(wl); + wl->wow_enabled = true; wl12xx_for_each_wlvif(wl, wlvif) { ret = wl1271_configure_suspend(wl, wlvif); @@ -4496,6 +4498,8 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 channel switch"); + wl1271_tx_flush(wl); + mutex_lock(&wl->mutex); if (unlikely(wl->state == WL1271_STATE_OFF)) { -- GitLab From d7b63b9fc7ee73e75a4c7fdb899a7c43ded7d25f Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 28 Feb 2012 00:41:34 +0200 Subject: [PATCH 1226/1846] wl12xx: increase dynamic PS timeout to 200ms This ensures the user won't encounter lag associated with getting in and out of PSM when the card is in use. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index ad1a4addaab5..418b2b82c185 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -246,7 +246,7 @@ static struct conf_drv_settings default_conf = { .psm_entry_retries = 8, .psm_exit_retries = 16, .psm_entry_nullfunc_retries = 3, - .dynamic_ps_timeout = 100, + .dynamic_ps_timeout = 200, .forced_ps = false, .keep_alive_interval = 55000, .max_listen_interval = 20, -- GitLab From 9100eb012a31dcc3f6eff1f09eb9e118b1e5b6c4 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 28 Feb 2012 15:48:42 -0500 Subject: [PATCH 1227/1846] mac89x0: Fix build error. Need to use the new 'saddr' variable not the void 'addr' in set_mac_address(). Reported-by: Geert Uytterhoeven Signed-off-by: David S. Miller --- drivers/net/ethernet/cirrus/mac89x0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/cirrus/mac89x0.c b/drivers/net/ethernet/cirrus/mac89x0.c index 419825ceab3b..932fdccc339a 100644 --- a/drivers/net/ethernet/cirrus/mac89x0.c +++ b/drivers/net/ethernet/cirrus/mac89x0.c @@ -591,13 +591,13 @@ static void set_multicast_list(struct net_device *dev) static int set_mac_address(struct net_device *dev, void *addr) { - int i; struct sockaddr *saddr = addr; + int i; - if (!is_valid_ether_addr(addr->sa_data)) + if (!is_valid_ether_addr(saddr->sa_data)) return -EADDRNOTAVAIL; - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + memcpy(dev->dev_addr, saddr->sa_data, ETH_ALEN); printk("%s: Setting MAC address to %pM\n", dev->name, dev->dev_addr); /* set the Ethernet address */ -- GitLab From 3379013bcfceb3c0365a3cf03543d6c67b84fc34 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 28 Feb 2012 09:52:46 +0300 Subject: [PATCH 1228/1846] Bluetooth: use kfree_skb() instead of kfree() sk_buffs should be freed using kfree_skb(). Signed-off-by: Dan Carpenter Acked-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/l2cap_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index bdcfbf0f631e..df3be692f2cf 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -4284,7 +4284,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk if (!chan) { BT_DBG("unknown cid 0x%4.4x", cid); /* Drop packet and return */ - kfree(skb); + kfree_skb(skb); return 0; } -- GitLab From 89bb46d02046b59c1de3d2e92680f3a1062750d0 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 28 Feb 2012 09:57:59 +0300 Subject: [PATCH 1229/1846] Bluetooth: change min_t() cast in hci_reassembly() "count" is type int so the cast to __u16 truncates the high bits away and triggers a Smatch static checker warning. It looks like a high value of count could cause a forever loop, but I didn't follow it through to see if count is capped somewhere. Signed-off-by: Dan Carpenter Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e6cbb8a1f47d..db484a8e7364 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1966,7 +1966,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data, while (count) { scb = (void *) skb->cb; - len = min_t(__u16, scb->expect, count); + len = min_t(uint, scb->expect, count); memcpy(skb_put(skb, len), data, len); -- GitLab From 978c93b90fc4768e295b20492b5db76d5e026e5e Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 29 Feb 2012 10:41:41 +0200 Subject: [PATCH 1230/1846] Bluetooth: Save remote L2CAP fixed channel mask Fixed channel mask needs to be stored to decide whether to use A2MP for example. So far save only one relevant byte which keeps all information we need. Signed-off-by: Andrei Emeltchenko Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index d6d8ec8eb8cf..3732a4849f2e 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -522,6 +522,7 @@ struct l2cap_conn { unsigned int mtu; __u32 feat_mask; + __u8 fixed_chan_mask; __u8 info_state; __u8 info_ident; diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index df3be692f2cf..bc8d558b01f6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -3209,7 +3209,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm return 0; } - if (type == L2CAP_IT_FEAT_MASK) { + switch (type) { + case L2CAP_IT_FEAT_MASK: conn->feat_mask = get_unaligned_le32(rsp->data); if (conn->feat_mask & L2CAP_FEAT_FIXED_CHAN) { @@ -3226,11 +3227,15 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm l2cap_conn_start(conn); } - } else if (type == L2CAP_IT_FIXED_CHAN) { + break; + + case L2CAP_IT_FIXED_CHAN: + conn->fixed_chan_mask = rsp->data[0]; conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; conn->info_ident = 0; l2cap_conn_start(conn); + break; } return 0; -- GitLab From 426c189a1b34c0d36d5eddbe1c35bc961b1a1b68 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 24 Feb 2012 11:41:04 -0300 Subject: [PATCH 1231/1846] Bluetooth: Change interleaved discovery behavior According to last discussion on IRC, if an interleaved discovery is issued, but the device is not dual mode, we should return error instead of performing a regular BR/EDR or LE-only discovery. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c4d3bc9c86b5..b0c43fe43563 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2540,29 +2540,6 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, return err; } -static int discovery(struct hci_dev *hdev) -{ - int err; - - if (lmp_host_le_capable(hdev)) { - if (lmp_bredr_capable(hdev)) { - err = hci_le_scan(hdev, LE_SCAN_TYPE, - LE_SCAN_INT, LE_SCAN_WIN, - LE_SCAN_TIMEOUT_BREDR_LE); - } else { - hdev->discovery.type = DISCOV_TYPE_LE; - err = hci_le_scan(hdev, LE_SCAN_TYPE, - LE_SCAN_INT, LE_SCAN_WIN, - LE_SCAN_TIMEOUT_LE_ONLY); - } - } else { - hdev->discovery.type = DISCOV_TYPE_BREDR; - err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); - } - - return err; -} - int mgmt_interleaved_discovery(struct hci_dev *hdev) { int err; @@ -2632,7 +2609,11 @@ static int start_discovery(struct sock *sk, u16 index, break; case DISCOV_TYPE_INTERLEAVED: - err = discovery(hdev); + if (lmp_host_le_capable(hdev) && lmp_bredr_capable(hdev)) + err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, + LE_SCAN_WIN, LE_SCAN_TIMEOUT_BREDR_LE); + else + err = -ENOTSUPP; break; default: -- GitLab From 95b23582d796305c66952188de2f5159b28be766 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Sun, 12 Feb 2012 13:55:35 +0100 Subject: [PATCH 1232/1846] Bluetooth: Use NULL instead of integer for mgmt_device_connected param Last param of mgmt_device_connected is of pointer type, so use NULL instead of 0 for it. This fix following sparse warning: CHECK net/bluetooth/hci_event.c net/bluetooth/hci_event.c:3262:74: warning: Using plain integer as NULL pointer Signed-off-by: Szymon Janc Signed-off-by: Johan Hedberg --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8c3261db7611..746f7d372258 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3296,7 +3296,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &ev->bdaddr, conn->type, - conn->dst_type, 0, NULL, 0, 0); + conn->dst_type, 0, NULL, 0, NULL); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); -- GitLab From 9b641251aee1a804169a17fe4236a50188894994 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 9 Nov 2011 13:29:18 -0500 Subject: [PATCH 1233/1846] tipc: Un-inline port routine for processing incoming messages Converts a non-trivial routine from inline to non-inline form to avoid bloating the TIPC code base with 6 copies of its body. This change is essentially cosmetic, and doesn't change existing TIPC behavior. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/port.c | 43 +++++++++++++++++++++++++++++++++++++++++++ net/tipc/port.h | 42 +----------------------------------------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/net/tipc/port.c b/net/tipc/port.c index b103d7630c82..6adcdf99123b 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -1133,6 +1133,49 @@ int tipc_shutdown(u32 ref) return tipc_disconnect(ref); } +/** + * tipc_port_recv_msg - receive message from lower layer and deliver to port user + */ + +int tipc_port_recv_msg(struct sk_buff *buf) +{ + struct tipc_port *p_ptr; + struct tipc_msg *msg = buf_msg(buf); + u32 destport = msg_destport(msg); + u32 dsz = msg_data_sz(msg); + u32 err; + + /* forward unresolved named message */ + if (unlikely(!destport)) { + tipc_net_route_msg(buf); + return dsz; + } + + /* validate destination & pass to port, otherwise reject message */ + p_ptr = tipc_port_lock(destport); + if (likely(p_ptr)) { + if (likely(p_ptr->connected)) { + if ((unlikely(msg_origport(msg) != + tipc_peer_port(p_ptr))) || + (unlikely(msg_orignode(msg) != + tipc_peer_node(p_ptr))) || + (unlikely(!msg_connected(msg)))) { + err = TIPC_ERR_NO_PORT; + tipc_port_unlock(p_ptr); + goto reject; + } + } + err = p_ptr->dispatcher(p_ptr, buf); + tipc_port_unlock(p_ptr); + if (likely(!err)) + return dsz; + } else { + err = TIPC_ERR_NO_PORT; + } +reject: + return tipc_reject_msg(buf, err); +} + /* * tipc_port_recv_sections(): Concatenate and deliver sectioned * message for this node. diff --git a/net/tipc/port.h b/net/tipc/port.h index f751807e2a91..9b88531e5a61 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h @@ -205,6 +205,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr); /* * TIPC messaging routines */ +int tipc_port_recv_msg(struct sk_buff *buf); int tipc_send(u32 portref, unsigned int num_sect, struct iovec const *msg_sect, unsigned int total_len); @@ -271,45 +272,4 @@ static inline int tipc_port_congested(struct tipc_port *p_ptr) return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); } -/** - * tipc_port_recv_msg - receive message from lower layer and deliver to port user - */ - -static inline int tipc_port_recv_msg(struct sk_buff *buf) -{ - struct tipc_port *p_ptr; - struct tipc_msg *msg = buf_msg(buf); - u32 destport = msg_destport(msg); - u32 dsz = msg_data_sz(msg); - u32 err; - - /* forward unresolved named message */ - if (unlikely(!destport)) { - tipc_net_route_msg(buf); - return dsz; - } - - /* validate destination & pass to port, otherwise reject message */ - p_ptr = tipc_port_lock(destport); - if (likely(p_ptr)) { - if (likely(p_ptr->connected)) { - if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) || - (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) || - (unlikely(!msg_connected(msg)))) { - err = TIPC_ERR_NO_PORT; - tipc_port_unlock(p_ptr); - goto reject; - } - } - err = p_ptr->dispatcher(p_ptr, buf); - tipc_port_unlock(p_ptr); - if (likely(!err)) - return dsz; - } else { - err = TIPC_ERR_NO_PORT; - } -reject: - return tipc_reject_msg(buf, err); -} - #endif -- GitLab From e8ec1ae756de320644c69194898c53d247925586 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 9 Nov 2011 17:38:20 -0500 Subject: [PATCH 1234/1846] tipc: Eliminate obsolete code for re-sending a message Removes code that updated the "previous node" field of an out-going message over TIPC's links. Such updating is unnecessary since the removal of the prototype multi-cluster capability means that all outgoing messages are generated locally and already have this field populated correctly. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/link.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index f16e65dd50c0..b4b9b30167a3 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -871,8 +871,6 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) u32 queue_limit = l_ptr->queue_limit[imp]; u32 max_packet = l_ptr->max_pkt; - msg_set_prevnode(msg, tipc_own_addr); /* If routed message */ - /* Match msg importance against queue limits: */ if (unlikely(queue_size >= queue_limit)) { -- GitLab From 9bbbc59dbd4e69da078b65a7f708c4250984dd29 Mon Sep 17 00:00:00 2001 From: Allan Stephens Date: Wed, 9 Nov 2011 16:30:55 -0500 Subject: [PATCH 1235/1846] tipc: Optimize setting of immutable payload message header fields Optimizes routines that send payload messages so that they no longer update the "originating node" and "originating port" fields of the outgoing message header template, since these fields are initialized when the sending port is created and never change thereafter. Also optimizes the routine which updates the message header template when a connection to a port is established, for the same reason. Signed-off-by: Allan Stephens Signed-off-by: Paul Gortmaker --- net/tipc/port.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/net/tipc/port.c b/net/tipc/port.c index 6adcdf99123b..94d2904cce66 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -1054,8 +1054,6 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer) msg = &p_ptr->phdr; msg_set_destnode(msg, peer->node); msg_set_destport(msg, peer->ref); - msg_set_orignode(msg, tipc_own_addr); - msg_set_origport(msg, p_ptr->ref); msg_set_type(msg, TIPC_CONN_MSG); msg_set_lookup_scope(msg, 0); msg_set_hdr_sz(msg, SHORT_H_SIZE); @@ -1254,8 +1252,6 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, msg = &p_ptr->phdr; msg_set_type(msg, TIPC_NAMED_MSG); - msg_set_orignode(msg, tipc_own_addr); - msg_set_origport(msg, ref); msg_set_hdr_sz(msg, NAMED_H_SIZE); msg_set_nametype(msg, name->type); msg_set_nameinst(msg, name->instance); @@ -1305,8 +1301,6 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, msg = &p_ptr->phdr; msg_set_type(msg, TIPC_DIRECT_MSG); msg_set_lookup_scope(msg, 0); - msg_set_orignode(msg, tipc_own_addr); - msg_set_origport(msg, ref); msg_set_destnode(msg, dest->node); msg_set_destport(msg, dest->ref); msg_set_hdr_sz(msg, BASIC_H_SIZE); @@ -1345,8 +1339,6 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, msg = &p_ptr->phdr; msg_set_type(msg, TIPC_DIRECT_MSG); - msg_set_orignode(msg, tipc_own_addr); - msg_set_origport(msg, ref); msg_set_destnode(msg, dest->node); msg_set_destport(msg, dest->ref); msg_set_hdr_sz(msg, BASIC_H_SIZE); -- GitLab From 53bf2426b4122d933213bba78bf736e88f7dc929 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Wed, 29 Feb 2012 16:38:13 -0300 Subject: [PATCH 1236/1846] Bluetooth: Fix Kconfig help description SMP is not a kernel module, it is part of Bluetooth Core (as already described in lines above). Signed-off-by: Andre Guedes Acked-by: Gustavo F. Padovan Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 9ec85eb8853d..3537d385035e 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -29,7 +29,6 @@ menuconfig BT BNEP Module (Bluetooth Network Encapsulation Protocol) CMTP Module (CAPI Message Transport Protocol) HIDP Module (Human Interface Device Protocol) - SMP Module (Security Manager Protocol) Say Y here to compile Bluetooth support into the kernel or say M to compile it as module (bluetooth). -- GitLab From 02f1434d4ed8197cefde6f6c4a8b2f502144cbb5 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 29 Feb 2012 14:00:13 +0100 Subject: [PATCH 1237/1846] zd1211rw: wait between setting hash table and powering radio on I am running Debian testing kernel 3.1.0-1-amd64, using a 079b:0062 Sagem XG-76NA 802.11bg stick. Upon zd1211rw interface bringup (ifconfig wlan0 up) I get the following timeout: [ 950.330573] zd1211rw 1-3:1.0: phy2 [ 955.108510] zd1211rw 1-3:1.0: firmware version 4725 [ 955.148532] zd1211rw 1-3:1.0: zd1211b chip 079b:0062 v4810 high 00-19-70 AL2230_RF pa0 g--NS [snip] [ 955.204072] zd1211rw 1-3:1.0: error ioread32(CR_REG1): -110 A second ifconfig wlan0 up brings the interface up without problems. After a bit more debugging, the call trace is the following: [10241.028130] zd1211rw 1-3:1.0: zd_chip_lock_phy_regs: error ioread32(CR_REG1): -110 [10241.028140] zd1211rw 1-3:1.0: zd_switch_radio_on: failed to lock PHY regs [10241.028148] zd1211rw 1-3:1.0: zd_op_start: failed to set radio on Adding a 10 milliseconds delay between the call to set_mc_hash() and zd_chip_switch_radio_on() allows successful interface bringups in all cases and matches what the vendor driver did. Acked-by: Jussi Kivilinna Signed-off-by: Florian Fainelli Signed-off-by: John W. Linville --- drivers/net/wireless/zd1211rw/zd_mac.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 98a574a4a465..9fcde36d5013 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c @@ -306,9 +306,19 @@ int zd_op_start(struct ieee80211_hw *hw) r = set_mc_hash(mac); if (r) goto disable_int; + + /* Wait after setting the multicast hash table and powering on + * the radio otherwise interface bring up will fail. This matches + * what the vendor driver did. + */ + msleep(10); + r = zd_chip_switch_radio_on(chip); - if (r < 0) + if (r < 0) { + dev_err(zd_chip_dev(chip), + "%s: failed to set radio on\n", __func__); goto disable_int; + } r = zd_chip_enable_rxtx(chip); if (r < 0) goto disable_radio; -- GitLab From 4d94c157f87eebdcd84e9e5e27ad65978f776c2e Mon Sep 17 00:00:00 2001 From: Stanislav Yakovlev Date: Thu, 9 Feb 2012 20:23:52 -0500 Subject: [PATCH 1238/1846] ipw2x00: remove ipw2100_rates_11b[] It's just a duplicate of ipw2100_bg_rates[]. Signed-off-by: Stanislav Yakovlev Reviewed-by: Julian Calaby Signed-off-by: John W. Linville --- drivers/net/wireless/ipw2x00/ipw2100.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index da41b8cf8700..5d7e97e63def 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c @@ -309,13 +309,6 @@ static const long ipw2100_frequencies[] = { #define FREQ_COUNT ARRAY_SIZE(ipw2100_frequencies) -static const long ipw2100_rates_11b[] = { - 1000000, - 2000000, - 5500000, - 11000000 -}; - static struct ieee80211_rate ipw2100_bg_rates[] = { { .bitrate = 10 }, { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, @@ -323,7 +316,7 @@ static struct ieee80211_rate ipw2100_bg_rates[] = { { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, }; -#define RATE_COUNT ARRAY_SIZE(ipw2100_rates_11b) +#define RATE_COUNT ARRAY_SIZE(ipw2100_bg_rates) /* Pre-decl until we get the code solid and then we can clean it up */ static void ipw2100_tx_send_commands(struct ipw2100_priv *priv); @@ -6896,7 +6889,7 @@ static int ipw2100_wx_get_range(struct net_device *dev, range->num_bitrates = RATE_COUNT; for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { - range->bitrate[i] = ipw2100_rates_11b[i]; + range->bitrate[i] = ipw2100_bg_rates[i].bitrate * 100 * 1000; } range->min_rts = MIN_RTS_THRESHOLD; -- GitLab From 63c9c5e77c36f8793dddf0e905a4bc43a0972735 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 24 Feb 2012 13:50:51 +0100 Subject: [PATCH 1239/1846] cfg80211: remove cookies from callbacks In "cfg80211: no cookies in cfg80211_send_XXX()" Holger Schurig removed the cookies in the calls from mac80211 to cfg80211, but the ones in the other direction were left in. Remove them now. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/cfg80211.h | 6 ++---- net/mac80211/cfg.c | 12 ++++-------- net/mac80211/ieee80211_i.h | 6 ++---- net/mac80211/mlme.c | 28 ++++++++++++++-------------- net/wireless/mlme.c | 6 +++--- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 755a7707a7c5..0178c7489373 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1587,11 +1587,9 @@ struct cfg80211_ops { int (*assoc)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_assoc_request *req); int (*deauth)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_deauth_request *req, - void *cookie); + struct cfg80211_deauth_request *req); int (*disassoc)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_disassoc_request *req, - void *cookie); + struct cfg80211_disassoc_request *req); int (*connect)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme); diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index f7eb25aabf8f..6a77d4c910f9 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1595,19 +1595,15 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, } static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_deauth_request *req, - void *cookie) + struct cfg80211_deauth_request *req) { - return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), - req, cookie); + return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req); } static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_disassoc_request *req, - void *cookie) + struct cfg80211_disassoc_request *req) { - return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), - req, cookie); + return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req); } static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 4d1682950a60..cee0c7493fd0 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1150,11 +1150,9 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, struct cfg80211_assoc_request *req); int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, - struct cfg80211_deauth_request *req, - void *cookie); + struct cfg80211_deauth_request *req); int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, - struct cfg80211_disassoc_request *req, - void *cookie); + struct cfg80211_disassoc_request *req); void ieee80211_send_pspoll(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata); void ieee80211_recalc_ps(struct ieee80211_local *local, s32 latency); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 0c220e1b6c9c..edba1d8158fc 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -612,8 +612,9 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) } static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, - const u8 *bssid, u16 stype, u16 reason, - void *cookie, bool send_frame) + const u8 *bssid, u16 stype, + u16 reason, bool cfg80211_locked, + bool send_frame) { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; @@ -637,12 +638,12 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, mgmt->u.deauth.reason_code = cpu_to_le16(reason); if (stype == IEEE80211_STYPE_DEAUTH) - if (cookie) + if (cfg80211_locked) __cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); else cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); else - if (cookie) + if (cfg80211_locked) __cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); else cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); @@ -1696,7 +1697,7 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata) ieee80211_send_deauth_disassoc(sdata, bssid, IEEE80211_STYPE_DEAUTH, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, - NULL, true); + false, true); mutex_lock(&local->mtx); ieee80211_recalc_idle(local); @@ -2706,8 +2707,8 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, * but that's not a problem. */ ieee80211_send_deauth_disassoc(sdata, bssid, - IEEE80211_STYPE_DEAUTH, reason, - NULL, true); + IEEE80211_STYPE_DEAUTH, + reason, false, true); mutex_lock(&local->mtx); ieee80211_recalc_idle(local); @@ -3439,8 +3440,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, } int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, - struct cfg80211_deauth_request *req, - void *cookie) + struct cfg80211_deauth_request *req) { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; bool assoc_bss = false; @@ -3461,8 +3461,9 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n", sdata->name, req->bssid, req->reason_code); - ieee80211_send_deauth_disassoc(sdata, req->bssid, IEEE80211_STYPE_DEAUTH, - req->reason_code, cookie, true); + ieee80211_send_deauth_disassoc(sdata, req->bssid, + IEEE80211_STYPE_DEAUTH, + req->reason_code, true, true); if (assoc_bss) sta_info_flush(sdata->local, sdata); @@ -3474,8 +3475,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, } int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, - struct cfg80211_disassoc_request *req, - void *cookie) + struct cfg80211_disassoc_request *req) { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; u8 bssid[ETH_ALEN]; @@ -3503,7 +3503,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, IEEE80211_STYPE_DISASSOC, req->reason_code, - cookie, !req->local_state_change); + true, !req->local_state_change); sta_info_flush(sdata->local, sdata); mutex_lock(&sdata->local->mtx); diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index d553d365e751..fb1e72179117 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -455,7 +455,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, return 0; } - return rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); + return rdev->ops->deauth(&rdev->wiphy, dev, &req); } int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, @@ -500,7 +500,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, else return -ENOTCONN; - return rdev->ops->disassoc(&rdev->wiphy, dev, &req, wdev); + return rdev->ops->disassoc(&rdev->wiphy, dev, &req); } int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, @@ -541,7 +541,7 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); req.bssid = bssid; - rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev); + rdev->ops->deauth(&rdev->wiphy, dev, &req); if (wdev->current_bss) { cfg80211_unhold_bss(wdev->current_bss); -- GitLab From 5fef7dbcadbb85079d3bf56625dd12e6d2816e3d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 24 Feb 2012 13:50:52 +0100 Subject: [PATCH 1240/1846] mac80211: dont call cfg80211 from ieee80211_send_deauth_disassoc Instead of calling cfg80211 in ieee80211_send_deauth_disassoc() pass out the frame and call it from the caller. That saves the SKB allocation if we don't actually want to send the frame and enables us to make the ordering smarter in the future. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 71 ++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index edba1d8158fc..82d49341eaa0 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -88,6 +88,8 @@ MODULE_PARM_DESC(probe_wait_ms, #define TMR_RUNNING_TIMER 0 #define TMR_RUNNING_CHANSW 1 +#define DEAUTH_DISASSOC_LEN (24 /* hdr */ + 2 /* reason */) + /* * All cfg80211 functions have to be called outside a locked * section so that they can acquire a lock themselves... This @@ -613,47 +615,41 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, const u8 *bssid, u16 stype, - u16 reason, bool cfg80211_locked, - bool send_frame) + u16 reason, bool send_frame, + u8 *frame_buf) { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct sk_buff *skb; - struct ieee80211_mgmt *mgmt; - - skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); - if (!skb) - return; + struct ieee80211_mgmt *mgmt = (void *)frame_buf; - skb_reserve(skb, local->hw.extra_tx_headroom); - - mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); - memset(mgmt, 0, 24); + /* build frame */ + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); + mgmt->duration = 0; /* initialize only */ + mgmt->seq_ctrl = 0; /* initialize only */ memcpy(mgmt->da, bssid, ETH_ALEN); memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); memcpy(mgmt->bssid, bssid, ETH_ALEN); - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); - skb_put(skb, 2); /* u.deauth.reason_code == u.disassoc.reason_code */ mgmt->u.deauth.reason_code = cpu_to_le16(reason); - if (stype == IEEE80211_STYPE_DEAUTH) - if (cfg80211_locked) - __cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); - else - cfg80211_send_deauth(sdata->dev, (u8 *)mgmt, skb->len); - else - if (cfg80211_locked) - __cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); - else - cfg80211_send_disassoc(sdata->dev, (u8 *)mgmt, skb->len); - if (!(ifmgd->flags & IEEE80211_STA_MFP_ENABLED)) - IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; + if (send_frame) { + skb = dev_alloc_skb(local->hw.extra_tx_headroom + + DEAUTH_DISASSOC_LEN); + if (!skb) + return; - if (send_frame) + skb_reserve(skb, local->hw.extra_tx_headroom); + + /* copy in frame */ + memcpy(skb_put(skb, DEAUTH_DISASSOC_LEN), + mgmt, DEAUTH_DISASSOC_LEN); + + if (!(ifmgd->flags & IEEE80211_STA_MFP_ENABLED)) + IEEE80211_SKB_CB(skb)->flags |= + IEEE80211_TX_INTFL_DONT_ENCRYPT; ieee80211_tx_skb(sdata, skb); - else - kfree_skb(skb); + } } void ieee80211_send_pspoll(struct ieee80211_local *local, @@ -1675,6 +1671,7 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata) struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_local *local = sdata->local; u8 bssid[ETH_ALEN]; + u8 frame_buf[DEAUTH_DISASSOC_LEN]; mutex_lock(&ifmgd->mtx); if (!ifmgd->associated) { @@ -1697,7 +1694,8 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata) ieee80211_send_deauth_disassoc(sdata, bssid, IEEE80211_STYPE_DEAUTH, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, - false, true); + false, frame_buf); + cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); mutex_lock(&local->mtx); ieee80211_recalc_idle(local); @@ -2696,6 +2694,7 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + u8 frame_buf[DEAUTH_DISASSOC_LEN]; ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | IEEE80211_STA_BEACON_POLL); @@ -2708,7 +2707,8 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, */ ieee80211_send_deauth_disassoc(sdata, bssid, IEEE80211_STYPE_DEAUTH, - reason, false, true); + reason, false, frame_buf); + cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); mutex_lock(&local->mtx); ieee80211_recalc_idle(local); @@ -3444,6 +3444,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; bool assoc_bss = false; + u8 frame_buf[DEAUTH_DISASSOC_LEN]; mutex_lock(&ifmgd->mtx); @@ -3463,7 +3464,8 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, ieee80211_send_deauth_disassoc(sdata, req->bssid, IEEE80211_STYPE_DEAUTH, - req->reason_code, true, true); + req->reason_code, true, frame_buf); + __cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); if (assoc_bss) sta_info_flush(sdata->local, sdata); @@ -3479,6 +3481,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; u8 bssid[ETH_ALEN]; + u8 frame_buf[DEAUTH_DISASSOC_LEN]; mutex_lock(&ifmgd->mtx); @@ -3502,8 +3505,10 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, mutex_unlock(&ifmgd->mtx); ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, - IEEE80211_STYPE_DISASSOC, req->reason_code, - true, !req->local_state_change); + IEEE80211_STYPE_DISASSOC, + req->reason_code, + !req->local_state_change, frame_buf); + __cfg80211_send_disassoc(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); sta_info_flush(sdata->local, sdata); mutex_lock(&sdata->local->mtx); -- GitLab From 02d83e60b9864e7920d87b49e1fbedffd32470f8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 24 Feb 2012 13:50:53 +0100 Subject: [PATCH 1241/1846] mac80211: fix ieee80211_set_disassoc() sending DelBA When ieee80211_set_disassoc() is called with the tx argument set to true, it will send DelBA out to the peer. This isn't useful or necessary in a few cases where we do it today, those being when we lost the connection or when the supplicant explicitly asked us to not tell the AP. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 82d49341eaa0..379a1d140161 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1684,7 +1684,7 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata) printk(KERN_DEBUG "%s: Connection to AP %pM lost.\n", sdata->name, bssid); - ieee80211_set_disassoc(sdata, true, true); + ieee80211_set_disassoc(sdata, true, false); mutex_unlock(&ifmgd->mtx); /* @@ -2699,7 +2699,7 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | IEEE80211_STA_BEACON_POLL); - ieee80211_set_disassoc(sdata, true, true); + ieee80211_set_disassoc(sdata, true, false); mutex_unlock(&ifmgd->mtx); /* * must be outside lock due to cfg80211, @@ -3500,7 +3500,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, sdata->name, req->bss->bssid, req->reason_code); memcpy(bssid, req->bss->bssid, ETH_ALEN); - ieee80211_set_disassoc(sdata, false, true); + ieee80211_set_disassoc(sdata, false, !req->local_state_change); mutex_unlock(&ifmgd->mtx); -- GitLab From 37ad38887d9ca5ed66c6f2b14a8921794bf3d4c3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 24 Feb 2012 13:50:54 +0100 Subject: [PATCH 1242/1846] mac80211: make deauth/disassoc sequence more natural The association sequence looks (roughly) like this now: * set BSSID * set station to EXIST state * send auth * set station to AUTH state * send assoc * set station to ASSOC state * set BSS info to associated In contrast, the deauth/disassoc sequence is the other way around: * clear BSSID/BSS info state * remove station * send deauth/disassoc (in some cases the last two steps are reversed.) This patch encodes the entire sequence in the ieee80211_set_disassoc() function and changes it to be like this, for good measure with an explicit flush: * send deauth/disassoc * flush * remove station * clear BSSID/BSS info state At least iwlwifi gets confused with the other sequence in P2P mode and complains that it wasn't able to flush the queues. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 84 +++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 379a1d140161..caf97f5a2937 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1389,7 +1389,8 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, } static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, - bool remove_sta, bool tx) + u16 stype, u16 reason, bool tx, + u8 *frame_buf) { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_local *local = sdata->local; @@ -1399,6 +1400,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, ASSERT_MGD_MTX(ifmgd); + if (WARN_ON_ONCE(tx && !frame_buf)) + return; + if (WARN_ON(!ifmgd->associated)) return; @@ -1432,6 +1436,19 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, } mutex_unlock(&local->sta_mtx); + /* deauthenticate/disassociate now */ + if (tx || frame_buf) + ieee80211_send_deauth_disassoc(sdata, bssid, stype, reason, + tx, frame_buf); + + /* flush out frame */ + if (tx) + drv_flush(local, false); + + /* remove AP and TDLS peers */ + sta_info_flush(local, sdata); + + /* finally reset all BSS / config parameters */ changed |= ieee80211_reset_erp_info(sdata); ieee80211_led_assoc(local, 0); @@ -1471,10 +1488,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; ieee80211_bss_info_change_notify(sdata, changed); - /* remove AP and TDLS peers */ - if (remove_sta) - sta_info_flush(local, sdata); - del_timer_sync(&sdata->u.mgd.conn_mon_timer); del_timer_sync(&sdata->u.mgd.bcn_mon_timer); del_timer_sync(&sdata->u.mgd.timer); @@ -1684,17 +1697,15 @@ static void __ieee80211_connection_loss(struct ieee80211_sub_if_data *sdata) printk(KERN_DEBUG "%s: Connection to AP %pM lost.\n", sdata->name, bssid); - ieee80211_set_disassoc(sdata, true, false); + ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, + false, frame_buf); mutex_unlock(&ifmgd->mtx); /* * must be outside lock due to cfg80211, * but that's not a problem. */ - ieee80211_send_deauth_disassoc(sdata, bssid, - IEEE80211_STYPE_DEAUTH, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, - false, frame_buf); cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); mutex_lock(&local->mtx); @@ -1902,7 +1913,8 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, printk(KERN_DEBUG "%s: deauthenticated from %pM (Reason: %u)\n", sdata->name, bssid, reason_code); - ieee80211_set_disassoc(sdata, true, false); + ieee80211_set_disassoc(sdata, 0, 0, false, NULL); + mutex_lock(&sdata->local->mtx); ieee80211_recalc_idle(sdata->local); mutex_unlock(&sdata->local->mtx); @@ -1932,10 +1944,12 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, printk(KERN_DEBUG "%s: disassociated from %pM (Reason: %u)\n", sdata->name, mgmt->sa, reason_code); - ieee80211_set_disassoc(sdata, true, false); + ieee80211_set_disassoc(sdata, 0, 0, false, NULL); + mutex_lock(&sdata->local->mtx); ieee80211_recalc_idle(sdata->local); mutex_unlock(&sdata->local->mtx); + return RX_MGMT_CFG80211_DISASSOC; } @@ -2699,15 +2713,14 @@ static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, ifmgd->flags &= ~(IEEE80211_STA_CONNECTION_POLL | IEEE80211_STA_BEACON_POLL); - ieee80211_set_disassoc(sdata, true, false); + ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, reason, + false, frame_buf); mutex_unlock(&ifmgd->mtx); + /* * must be outside lock due to cfg80211, * but that's not a problem. */ - ieee80211_send_deauth_disassoc(sdata, bssid, - IEEE80211_STYPE_DEAUTH, - reason, false, frame_buf); cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); mutex_lock(&local->mtx); @@ -3192,7 +3205,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, ifmgd->auth_data = auth_data; if (ifmgd->associated) - ieee80211_set_disassoc(sdata, true, false); + ieee80211_set_disassoc(sdata, 0, 0, false, NULL); printk(KERN_DEBUG "%s: authenticate with %pM\n", sdata->name, req->bss->bssid); @@ -3270,7 +3283,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, mutex_lock(&ifmgd->mtx); if (ifmgd->associated) - ieee80211_set_disassoc(sdata, true, false); + ieee80211_set_disassoc(sdata, 0, 0, false, NULL); if (ifmgd->auth_data && !ifmgd->auth_data->done) { err = -EBUSY; @@ -3443,31 +3456,32 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, struct cfg80211_deauth_request *req) { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - bool assoc_bss = false; u8 frame_buf[DEAUTH_DISASSOC_LEN]; mutex_lock(&ifmgd->mtx); - if (ifmgd->associated && - memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) { - ieee80211_set_disassoc(sdata, false, true); - assoc_bss = true; - } else if (ifmgd->auth_data) { + if (ifmgd->auth_data) { ieee80211_destroy_auth_data(sdata, false); mutex_unlock(&ifmgd->mtx); return 0; } - mutex_unlock(&ifmgd->mtx); - printk(KERN_DEBUG "%s: deauthenticating from %pM by local choice (reason=%d)\n", + printk(KERN_DEBUG + "%s: deauthenticating from %pM by local choice (reason=%d)\n", sdata->name, req->bssid, req->reason_code); - ieee80211_send_deauth_disassoc(sdata, req->bssid, - IEEE80211_STYPE_DEAUTH, + if (ifmgd->associated && + memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) + ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, req->reason_code, true, frame_buf); + else + ieee80211_send_deauth_disassoc(sdata, req->bssid, + IEEE80211_STYPE_DEAUTH, + req->reason_code, true, + frame_buf); + mutex_unlock(&ifmgd->mtx); + __cfg80211_send_deauth(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); - if (assoc_bss) - sta_info_flush(sdata->local, sdata); mutex_lock(&sdata->local->mtx); ieee80211_recalc_idle(sdata->local); @@ -3500,16 +3514,12 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, sdata->name, req->bss->bssid, req->reason_code); memcpy(bssid, req->bss->bssid, ETH_ALEN); - ieee80211_set_disassoc(sdata, false, !req->local_state_change); - + ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DISASSOC, + req->reason_code, !req->local_state_change, + frame_buf); mutex_unlock(&ifmgd->mtx); - ieee80211_send_deauth_disassoc(sdata, req->bss->bssid, - IEEE80211_STYPE_DISASSOC, - req->reason_code, - !req->local_state_change, frame_buf); __cfg80211_send_disassoc(sdata->dev, frame_buf, DEAUTH_DISASSOC_LEN); - sta_info_flush(sdata->local, sdata); mutex_lock(&sdata->local->mtx); ieee80211_recalc_idle(sdata->local); -- GitLab From 1a907b749c0ae235ab46e3ba7834e6c143f5503e Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Fri, 24 Feb 2012 21:35:36 -0800 Subject: [PATCH 1243/1846] mwifiex: remove redundant scan operation It should have been removed by commit "mwifiex: use cfg80211 dynamic scan..." (7c6fa2a843..) after adding code to avoid an extra scan during association because scan entries are valid for 15 seconds in cfg80211 stack. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 8d8ee639fe56..a08037e85101 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -923,12 +923,6 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, } } done: - /* Do specific SSID scanning */ - if (mwifiex_request_scan(priv, &req_ssid)) { - dev_err(priv->adapter->dev, "scan error\n"); - return -EFAULT; - } - /* * Scan entries are valid for some time (15 sec). So we can save one * active scan time if we just try cfg80211_get_bss first. If it fails -- GitLab From 5eb02e44adc92a71bae3ff60acb1eea5ada14e93 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Fri, 24 Feb 2012 21:36:04 -0800 Subject: [PATCH 1244/1846] mwifiex: remove unnecessary enum MWIFIEX_802_11_WEP_STATUS Instead of defining an 'enum', we can simply use 'u8' flag for WEP status. Rename 'wep_status' to 'wep_enabled' to match with 'wpa_enabled' and 'wpa2_enabled'. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 2 +- drivers/net/wireless/mwifiex/fw.h | 5 --- drivers/net/wireless/mwifiex/init.c | 2 +- drivers/net/wireless/mwifiex/join.c | 5 +-- drivers/net/wireless/mwifiex/main.h | 2 +- drivers/net/wireless/mwifiex/scan.c | 47 ++++++++++-------------- drivers/net/wireless/mwifiex/sta_ioctl.c | 10 ++--- 7 files changed, 29 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index a08037e85101..503717c59358 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -146,7 +146,7 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev, struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); /* Return if WEP key not configured */ - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED) + if (!priv->sec_info.wep_enabled) return 0; if (mwifiex_set_encode(priv, NULL, 0, key_index, 0)) { diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index 51c5417c569c..c82620094a53 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h @@ -86,11 +86,6 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { MWIFIEX_802_11_PRIV_FILTER_8021X_WEP }; -enum MWIFIEX_802_11_WEP_STATUS { - MWIFIEX_802_11_WEP_ENABLED, - MWIFIEX_802_11_WEP_DISABLED, -}; - #define CAL_SNR(RSSI, NF) ((s16)((s16)(RSSI)-(s16)(NF))) #define PROPRIETARY_TLV_BASE_ID 0x0100 diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index ca59cc0d013e..e81bf6ef1666 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c @@ -82,7 +82,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv) priv->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR; priv->data_avg_factor = DEFAULT_DATA_AVG_FACTOR; - priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED; + priv->sec_info.wep_enabled = 0; priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM; priv->sec_info.encryption_mode = 0; for (i = 0; i < ARRAY_SIZE(priv->wep_key); i++) diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 0b0eb5efba9d..ee439fc2f4f3 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -417,7 +417,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, auth_tlv = (struct mwifiex_ie_types_auth_type *) pos; auth_tlv->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE); auth_tlv->header.len = cpu_to_le16(sizeof(auth_tlv->auth_type)); - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED) + if (priv->sec_info.wep_enabled) auth_tlv->auth_type = cpu_to_le16( (u16) priv->sec_info.authentication_mode); else @@ -1069,8 +1069,7 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, priv->curr_bss_params.bss_descriptor.channel = bss_desc->channel; priv->curr_bss_params.band = (u8) bss_desc->bss_band; - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED - || priv->sec_info.wpa_enabled) + if (priv->sec_info.wep_enabled || priv->sec_info.wpa_enabled) tmp_cap |= WLAN_CAPABILITY_PRIVACY; if (IS_SUPPORT_MULTI_BANDS(priv->adapter)) { diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 52810b1497ea..4c8621706278 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -217,7 +217,7 @@ struct mwifiex_802_11_security { u8 wpa2_enabled; u8 wapi_enabled; u8 wapi_key_on; - enum MWIFIEX_802_11_WEP_STATUS wep_status; + u8 wep_enabled; u32 authentication_mode; u32 encryption_mode; }; diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 98f1ca9cd6d8..8f10038d1b45 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -196,9 +196,8 @@ static bool mwifiex_is_network_compatible_for_no_sec(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED - && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled - && ((!bss_desc->bcn_wpa_ie) || + if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && + !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) && ((!bss_desc->bcn_rsn_ie) || @@ -219,9 +218,8 @@ static bool mwifiex_is_network_compatible_for_static_wep(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED - && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled - && bss_desc->privacy) { + if (priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && + !priv->sec_info.wpa2_enabled && bss_desc->privacy) { return true; } return false; @@ -235,10 +233,9 @@ static bool mwifiex_is_network_compatible_for_wpa(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED - && priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled - && ((bss_desc->bcn_wpa_ie) && ((*(bss_desc->bcn_wpa_ie)).vend_hdr. - element_id == WLAN_EID_WPA)) + if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled && + !priv->sec_info.wpa2_enabled && ((bss_desc->bcn_wpa_ie) && + ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id == WLAN_EID_WPA)) /* * Privacy bit may NOT be set in some APs like * LinkSys WRT54G && bss_desc->privacy @@ -253,8 +250,7 @@ mwifiex_is_network_compatible_for_wpa(struct mwifiex_private *priv, (bss_desc->bcn_rsn_ie) ? (*(bss_desc->bcn_rsn_ie)). ieee_hdr.element_id : 0, - (priv->sec_info.wep_status == - MWIFIEX_802_11_WEP_ENABLED) ? "e" : "d", + (priv->sec_info.wep_enabled) ? "e" : "d", (priv->sec_info.wpa_enabled) ? "e" : "d", (priv->sec_info.wpa2_enabled) ? "e" : "d", priv->sec_info.encryption_mode, @@ -272,10 +268,9 @@ static bool mwifiex_is_network_compatible_for_wpa2(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED - && !priv->sec_info.wpa_enabled && priv->sec_info.wpa2_enabled - && ((bss_desc->bcn_rsn_ie) && ((*(bss_desc->bcn_rsn_ie)).ieee_hdr. - element_id == WLAN_EID_RSN)) + if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && + priv->sec_info.wpa2_enabled && ((bss_desc->bcn_rsn_ie) && + ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id == WLAN_EID_RSN)) /* * Privacy bit may NOT be set in some APs like * LinkSys WRT54G && bss_desc->privacy @@ -290,8 +285,7 @@ mwifiex_is_network_compatible_for_wpa2(struct mwifiex_private *priv, (bss_desc->bcn_rsn_ie) ? (*(bss_desc->bcn_rsn_ie)). ieee_hdr.element_id : 0, - (priv->sec_info.wep_status == - MWIFIEX_802_11_WEP_ENABLED) ? "e" : "d", + (priv->sec_info.wep_enabled) ? "e" : "d", (priv->sec_info.wpa_enabled) ? "e" : "d", (priv->sec_info.wpa2_enabled) ? "e" : "d", priv->sec_info.encryption_mode, @@ -309,10 +303,9 @@ static bool mwifiex_is_network_compatible_for_adhoc_aes(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED - && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled - && ((!bss_desc->bcn_wpa_ie) || ((*(bss_desc->bcn_wpa_ie)).vend_hdr. - element_id != WLAN_EID_WPA)) + if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && + !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || + ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) && ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr. element_id != WLAN_EID_RSN)) && !priv->sec_info.encryption_mode @@ -330,10 +323,9 @@ static bool mwifiex_is_network_compatible_for_dynamic_wep(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED - && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled - && ((!bss_desc->bcn_wpa_ie) || ((*(bss_desc->bcn_wpa_ie)).vend_hdr. - element_id != WLAN_EID_WPA)) + if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && + !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || + ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) && ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr. element_id != WLAN_EID_RSN)) && priv->sec_info.encryption_mode @@ -468,8 +460,7 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, (bss_desc->bcn_rsn_ie) ? (*(bss_desc->bcn_rsn_ie)).ieee_hdr. element_id : 0, - (priv->sec_info.wep_status == - MWIFIEX_802_11_WEP_ENABLED) ? "e" : "d", + (priv->sec_info.wep_enabled) ? "e" : "d", (priv->sec_info.wpa_enabled) ? "e" : "d", (priv->sec_info.wpa2_enabled) ? "e" : "d", priv->sec_info.encryption_mode, bss_desc->privacy); diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index b0fbf5d4fea0..866026ecca44 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -471,7 +471,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv, info->bcn_nf_last = priv->bcn_nf_last; - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED) + if (priv->sec_info.wep_enabled) info->wep_status = true; else info->wep_status = false; @@ -1020,7 +1020,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv, wep_key = &priv->wep_key[priv->wep_key_curr_index]; index = encrypt_key->key_index; if (encrypt_key->key_disable) { - priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED; + priv->sec_info.wep_enabled = 0; } else if (!encrypt_key->key_len) { /* Copy the required key as the current key */ wep_key = &priv->wep_key[index]; @@ -1030,7 +1030,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv, return -1; } priv->wep_key_curr_index = (u16) index; - priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED; + priv->sec_info.wep_enabled = 1; } else { wep_key = &priv->wep_key[index]; memset(wep_key, 0, sizeof(struct mwifiex_wep_key)); @@ -1040,7 +1040,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv, encrypt_key->key_len); wep_key->key_index = index; wep_key->key_length = encrypt_key->key_len; - priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED; + priv->sec_info.wep_enabled = 1; } if (wep_key->key_length) { /* Send request to firmware */ @@ -1050,7 +1050,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv, if (ret) return ret; } - if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED) + if (priv->sec_info.wep_enabled) priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE; else priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE; -- GitLab From 02f2f1a951f87644166926862ec32fb13511e2f3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 27 Feb 2012 12:18:30 +0100 Subject: [PATCH 1245/1846] mac80211: handle non-bufferable MMPDUs correctly This renames the IEEE80211_TX_CTL_POLL_RESPONSE TX flag to IEEE80211_TX_CTL_NO_PS_BUFFER and also uses it for non-bufferable MMPDUs (all MMPDUs but deauth, disassoc and action frames.) Previously, mac80211 would let the MMPDU through but not set the flag so drivers supporting some hardware aids for avoiding the PS races would then reject the frame. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 6 +++++- drivers/net/wireless/p54/txrx.c | 2 +- include/net/mac80211.h | 17 ++++++++++------- net/mac80211/sta_info.c | 4 ++-- net/mac80211/tx.c | 17 +++++++++++------ 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2d01db0f08e0..2329033e23d7 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1693,7 +1693,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) sta_priv = (void *)sta->drv_priv; if (sta_priv && sta_priv->asleep && - (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) { + (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) { /* * This sends an asynchronous command to the device, * but we can rely on it being processed before the diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index da18a8fc9af7..5f78567f4180 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -322,7 +322,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) sta_priv = (void *)info->control.sta->drv_priv; if (sta_priv && sta_priv->asleep && - (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) { + (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)) { /* * This sends an asynchronous command to the device, * but we can rely on it being processed before the @@ -331,6 +331,10 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * counter. * For now set the counter to just 1 since we do not * support uAPSD yet. + * + * FIXME: If we get two non-bufferable frames one + * after the other, we might only send out one of + * them because this is racy. */ iwl_sta_modify_sleep_tx_count(priv, sta_id, 1); } diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c index 42b97bc38477..a08a6f0e4dd1 100644 --- a/drivers/net/wireless/p54/txrx.c +++ b/drivers/net/wireless/p54/txrx.c @@ -690,7 +690,7 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb, if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) *flags |= P54_HDR_FLAG_DATA_OUT_SEQNR; - if (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE) + if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL; if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index cbff4f94a200..7477f020ee7a 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -341,9 +341,9 @@ struct ieee80211_bss_conf { * used to indicate that a frame was already retried due to PS * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211, * used to indicate frame should not be encrypted - * @IEEE80211_TX_CTL_POLL_RESPONSE: This frame is a response to a poll - * frame (PS-Poll or uAPSD) and should be sent although the station - * is in powersave mode. + * @IEEE80211_TX_CTL_NO_PS_BUFFER: This frame is a response to a poll + * frame (PS-Poll or uAPSD) or a non-bufferable MMPDU and must + * be sent although the station is in powersave mode. * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the * transmit function after the current frame, this can be used * by drivers to kick the DMA queue only if unset or when the @@ -399,7 +399,7 @@ enum mac80211_tx_control_flags { IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14), IEEE80211_TX_INTFL_RETRIED = BIT(15), IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16), - IEEE80211_TX_CTL_POLL_RESPONSE = BIT(17), + IEEE80211_TX_CTL_NO_PS_BUFFER = BIT(17), IEEE80211_TX_CTL_MORE_FRAMES = BIT(18), IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19), /* hole at 20, use later */ @@ -425,7 +425,7 @@ enum mac80211_tx_control_flags { IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \ IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \ IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \ - IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_POLL_RESPONSE | \ + IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_NO_PS_BUFFER | \ IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \ IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP) @@ -1634,7 +1634,7 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); * the station sends a PS-Poll or a uAPSD trigger frame, mac80211 * will inform the driver of this with the @allow_buffered_frames * callback; this callback is optional. mac80211 will then transmit - * the frames as usual and set the %IEEE80211_TX_CTL_POLL_RESPONSE + * the frames as usual and set the %IEEE80211_TX_CTL_NO_PS_BUFFER * on each frame. The last frame in the service period (or the only * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to * indicate that it ends the service period; as this frame must have @@ -1642,6 +1642,9 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); * When TX status is reported for this frame, the service period is * marked has having ended and a new one can be started by the peer. * + * Additionally, non-bufferable MMPDUs can also be transmitted by + * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them. + * * Another race condition can happen on some devices like iwlwifi * when there are frames queued for the station and it wakes up * or polls; the frames that are already queued could end up being @@ -2140,7 +2143,7 @@ enum ieee80211_frame_release_type { * @allow_buffered_frames: Prepare device to allow the given number of frames * to go out to the given station. The frames will be sent by mac80211 * via the usual TX path after this call. The TX information for frames - * released will also have the %IEEE80211_TX_CTL_POLL_RESPONSE flag set + * released will also have the %IEEE80211_TX_CTL_NO_PS_BUFFER flag set * and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case * frames from multiple TIDs are released and the driver might reorder * them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 98613c8f08cf..cd0f265f42e5 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -1050,7 +1050,7 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, * exchange. Also set EOSP to indicate this packet * ends the poll/service period. */ - info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE | + info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | IEEE80211_TX_STATUS_EOSP | IEEE80211_TX_CTL_REQ_TX_STATUS; @@ -1177,7 +1177,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, * STA may still remain is PS mode after this frame * exchange. */ - info->flags |= IEEE80211_TX_CTL_POLL_RESPONSE; + info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; /* * Use MoreData flag to indicate whether there are diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 7c021f255716..570737df2d22 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -448,18 +448,23 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; struct ieee80211_local *local = tx->local; - if (unlikely(!sta || - ieee80211_is_probe_resp(hdr->frame_control) || - ieee80211_is_auth(hdr->frame_control) || - ieee80211_is_assoc_resp(hdr->frame_control) || - ieee80211_is_reassoc_resp(hdr->frame_control))) + if (unlikely(!sta)) return TX_CONTINUE; if (unlikely((test_sta_flag(sta, WLAN_STA_PS_STA) || test_sta_flag(sta, WLAN_STA_PS_DRIVER)) && - !(info->flags & IEEE80211_TX_CTL_POLL_RESPONSE))) { + !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { int ac = skb_get_queue_mapping(tx->skb); + /* only deauth, disassoc and action are bufferable MMPDUs */ + if (ieee80211_is_mgmt(hdr->frame_control) && + !ieee80211_is_deauth(hdr->frame_control) && + !ieee80211_is_disassoc(hdr->frame_control) && + !ieee80211_is_action(hdr->frame_control)) { + info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; + return TX_CONTINUE; + } + #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG printk(KERN_DEBUG "STA %pM aid %d: PS buffer for AC %d\n", sta->sta.addr, sta->sta.aid, ac); -- GitLab From 649921499c7116d5283b02ec432ff42229aefccd Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Mon, 27 Feb 2012 12:25:30 -0600 Subject: [PATCH 1246/1846] iwlegacy: Kconfig: Move Debugging Options Move the debug options so they appear below the 3945 / 4965 options. Signed-off-by: Greg Dietsche Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/Kconfig | 78 +++++++++++++-------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index 05bd375cb845..4d81b80b16e6 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -6,45 +6,6 @@ config IWLEGACY select LEDS_TRIGGERS select MAC80211_LEDS -menu "Debugging Options" - depends on IWLEGACY - -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 iwlegacy - drivers. - - This will result in the kernel module being ~100k larger. You can - control which debug output is sent to the kernel log by setting the - value in - - /sys/class/net/wlan0/device/debug_level - - This entry will only exist if this option is enabled. - - To set a value, simply echo an 8-byte hex value to the same file: - - % echo 0x43fff > /sys/class/net/wlan0/device/debug_level - - You can find the list of debug mask values in: - 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 - any problems you may encounter. - -config IWLEGACY_DEBUGFS - bool "iwlegacy (iwl 3945/4965) debugfs support" - depends on IWLEGACY && MAC80211_DEBUGFS - ---help--- - 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. - -endmenu - config IWL4965 tristate "Intel Wireless WiFi 4965AGN (iwl4965)" depends on PCI && MAC80211 @@ -98,3 +59,42 @@ config IWL3945 inserted in and removed from the running kernel whenever you want), say M here and read . The module will be called iwl3945. + +menu "Debugging Options" + depends on IWLEGACY + +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 iwlegacy + drivers. + + This will result in the kernel module being ~100k larger. You can + control which debug output is sent to the kernel log by setting the + value in + + /sys/class/net/wlan0/device/debug_level + + This entry will only exist if this option is enabled. + + To set a value, simply echo an 8-byte hex value to the same file: + + % echo 0x43fff > /sys/class/net/wlan0/device/debug_level + + You can find the list of debug mask values in: + 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 + any problems you may encounter. + +config IWLEGACY_DEBUGFS + bool "iwlegacy (iwl 3945/4965) debugfs support" + depends on IWLEGACY && MAC80211_DEBUGFS + ---help--- + 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. + +endmenu -- GitLab From 08db1ab7fa4cab08c1e24f373439d472d054a921 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Mon, 27 Feb 2012 12:25:31 -0600 Subject: [PATCH 1247/1846] iwlegacy: Kconfig: Change Debug Option to be more clear Since the menuconfig system doesn't indent the debug options for the 3945 /4965, add some text to make it clear which debug options are being configured. Signed-off-by: Greg Dietsche Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index 4d81b80b16e6..fb919727b8bb 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -60,7 +60,7 @@ config IWL3945 say M here and read . The module will be called iwl3945. -menu "Debugging Options" +menu "iwl3945 / iwl4965 Debugging Options" depends on IWLEGACY config IWLEGACY_DEBUG -- GitLab From d7b6b6a64301d6b0c632c8b9563a27aeeb09e967 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Mon, 27 Feb 2012 12:25:32 -0600 Subject: [PATCH 1248/1846] iwlegacy: remove enum iw_calib and related code Remove the enum il_calib. It defined one identifier: IL_CALIB_MAX. Remove the function il4965_calib_free_results. It was doing nothing because IL_CALIB_MAX is zero. Next, remove calib_results from the il_priv structure and also remove the associated return type/struct il_calib_result. Signed-off-by: Greg Dietsche Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/4965-calib.c | 12 ------------ drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/4965.h | 1 - drivers/net/wireless/iwlegacy/common.h | 18 ------------------ 4 files changed, 32 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 47c20e3d5605..e78bdefb8952 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -79,18 +79,6 @@ struct stats_general_data { 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 *****************************************************************************/ diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2329033e23d7..7b54dbb338be 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -6347,7 +6347,6 @@ il4965_init_drv(struct il_priv *il) 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); diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 208a4564d063..1db677689cfe 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -927,7 +927,6 @@ 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 diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 6ed9871f1c4b..d0de922cb937 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -961,21 +961,6 @@ enum il4965_calib_enabled_state { 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, @@ -1195,9 +1180,6 @@ struct il_priv { 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; -- GitLab From aef6a62d8b517f7472105971d5e221ef55a320be Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Mon, 27 Feb 2012 12:25:33 -0600 Subject: [PATCH 1249/1846] iwlegacy: remove unused enum il4965_calib_enabled_state Remove the enum il4965_calib_enabled_state because it is not used. Signed-off-by: Greg Dietsche Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index d0de922cb937..5f5017767b99 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -956,11 +956,6 @@ enum il4965_chain_noise_state { IL_CHAIN_NOISE_DONE, }; -enum il4965_calib_enabled_state { - IL_CALIB_DISABLED = 0, /* must be 0 */ - IL_CALIB_ENABLED = 1, -}; - enum ucode_type { UCODE_NONE = 0, UCODE_INIT, -- GitLab From f4fb4b212d2668f831918023bc3ca451997faee6 Mon Sep 17 00:00:00 2001 From: Zefir Kurtisi Date: Mon, 27 Feb 2012 12:52:06 +0100 Subject: [PATCH 1250/1846] ath9k: decouple RX error checking for DFS Previous RX error checking was done exclusive-or for different error types and caused DFS pulse events to be dropped when other error flags (e.g. CRC) were set simultaneously. This patch decouples PHY error processing from other types and ensures that all pulses detected by HW are accounted by the pattern detector. Signed-off-by: Zefir Kurtisi Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 51687e3f63d8..8d1bca03bc0e 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -510,7 +510,11 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, */ if (rxsp->status11 & AR_CRCErr) rxs->rs_status |= ATH9K_RXERR_CRC; - else if (rxsp->status11 & AR_PHYErr) { + else if (rxsp->status11 & AR_DecryptCRCErr) + rxs->rs_status |= ATH9K_RXERR_DECRYPT; + else if (rxsp->status11 & AR_MichaelErr) + rxs->rs_status |= ATH9K_RXERR_MIC; + if (rxsp->status11 & AR_PHYErr) { phyerr = MS(rxsp->status11, AR_PHYErrCode); /* * If we reach a point here where AR_PostDelimCRCErr is @@ -532,11 +536,7 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, rxs->rs_status |= ATH9K_RXERR_PHY; rxs->rs_phyerr = phyerr; } - - } else if (rxsp->status11 & AR_DecryptCRCErr) - rxs->rs_status |= ATH9K_RXERR_DECRYPT; - else if (rxsp->status11 & AR_MichaelErr) - rxs->rs_status |= ATH9K_RXERR_MIC; + }; } if (rxsp->status11 & AR_KeyMiss) -- GitLab From c288ec614e264b46853c65d3db9ccf91d53c9484 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Wed, 29 Feb 2012 15:08:33 -0500 Subject: [PATCH 1251/1846] carl9170: fix breakage from "mac80211: handle non-bufferable MMPDUs correctly" That commit intended for 3.4 renamed IEEE80211_TX_CTL_POLL_RESPONSE as IEEE80211_TX_CTL_NO_PS_BUFFER. Meanwhile, "carl9170: fix frame delivery if sta is in powersave mode" added a reference to IEEE80211_TX_CTL_POLL_RESPONSE in the fixes stream for 3.3. This simple patch fixes that merge boo-boo. Signed-off-by: John W. Linville --- drivers/net/wireless/ath/carl9170/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c index 0f00721995ef..aed305177af6 100644 --- a/drivers/net/wireless/ath/carl9170/tx.c +++ b/drivers/net/wireless/ath/carl9170/tx.c @@ -1247,7 +1247,7 @@ static bool carl9170_tx_ps_drop(struct ar9170 *ar, struct sk_buff *skb) tx_info = IEEE80211_SKB_CB(skb); if (unlikely(sta_info->sleeping) && - !(tx_info->flags & (IEEE80211_TX_CTL_POLL_RESPONSE | + !(tx_info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER | IEEE80211_TX_CTL_CLEAR_PS_FILT))) { rcu_read_unlock(); -- GitLab From 00abfe4442864144a77f70b6b411d691bcb796bf Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 1 Mar 2012 00:37:10 -0300 Subject: [PATCH 1252/1846] Bluetooth: Fix coding style with breaking lines Our limit is 80 and broken lines should as right as possible. Signed-off-by: Gustavo F. Padovan --- drivers/bluetooth/btmrvl_debugfs.c | 19 +++++++++---------- net/bluetooth/hci_event.c | 3 ++- net/bluetooth/mgmt.c | 3 +-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c index 60fe333cfd40..3497347e6dbb 100644 --- a/drivers/bluetooth/btmrvl_debugfs.c +++ b/drivers/bluetooth/btmrvl_debugfs.c @@ -401,28 +401,27 @@ void btmrvl_debugfs_init(struct hci_dev *hdev) dbg->config_dir = debugfs_create_dir("config", hdev->debugfs); dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, - priv, &btmrvl_psmode_fops); + priv, &btmrvl_psmode_fops); dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, - priv, &btmrvl_pscmd_fops); + priv, &btmrvl_pscmd_fops); dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, - priv, &btmrvl_gpiogap_fops); + priv, &btmrvl_gpiogap_fops); dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, - priv, &btmrvl_hsmode_fops); + priv, &btmrvl_hsmode_fops); dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, - priv, &btmrvl_hscmd_fops); + priv, &btmrvl_hscmd_fops); dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, - priv, &btmrvl_hscfgcmd_fops); + priv, &btmrvl_hscfgcmd_fops); dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); dbg->curpsmode = debugfs_create_file("curpsmode", 0444, dbg->status_dir, priv, &btmrvl_curpsmode_fops); dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, - priv, &btmrvl_psstate_fops); + priv, &btmrvl_psstate_fops); dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, - priv, &btmrvl_hsstate_fops); + priv, &btmrvl_hsstate_fops); dbg->txdnldready = debugfs_create_file("txdnldready", 0444, - dbg->status_dir, - priv, + dbg->status_dir, priv, &btmrvl_txdnldready_fops); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 746f7d372258..aee9556e1039 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1344,7 +1344,8 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev, return 1; } -static inline int hci_resolve_name(struct hci_dev *hdev, struct inquiry_entry *e) +static inline int hci_resolve_name(struct hci_dev *hdev, + struct inquiry_entry *e) { struct hci_cp_remote_name_req cp; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index b0c43fe43563..373b46a9eb17 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1926,8 +1926,7 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) goto failed; } - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, - len); + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; -- GitLab From 1de028ceb54ccd28cc96f1530a195ae1b6a6d5b5 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 29 Feb 2012 19:55:35 -0800 Subject: [PATCH 1253/1846] Bluetooth: mgmt: Add missing hci_dev locking to set_le() The set_le() function was missing hci_dev locking which is e.g. critical for the mgmt pending command adding/removing. Acked-by: Gustavo F. Padovan Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 373b46a9eb17..abf1adb8bc16 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1273,10 +1273,12 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) return cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_INVALID_PARAMS); + hci_dev_lock(hdev); + if (!enable_le || !(hdev->features[4] & LMP_LE)) { err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_NOT_SUPPORTED); - goto failed; + goto unlock; } val = !!cp->val; @@ -1292,23 +1294,23 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); if (err < 0) - goto failed; + goto unlock; if (changed) err = new_settings(hdev, sk); - goto failed; + goto unlock; } if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY); - goto failed; + goto unlock; } cmd = mgmt_pending_add(sk, MGMT_OP_SET_LE, hdev, data, len); if (!cmd) { err = -ENOMEM; - goto failed; + goto unlock; } memset(&hci_cp, 0, sizeof(hci_cp)); @@ -1322,10 +1324,11 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) sizeof(hci_cp), &hci_cp); if (err < 0) { mgmt_pending_remove(cmd); - goto failed; + goto unlock; } -failed: +unlock: + hci_dev_unlock(hdev); hci_dev_put(hdev); return err; } -- GitLab From f2afdac709546f03cbdb11dc58f2c8250678bc66 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 28 Feb 2012 20:20:19 +0530 Subject: [PATCH 1254/1846] ath6kl: Group wiphy initialization into ath6kl_cfg80211_init() There are some code which initializes various wiphy members left outside ath6kl_cfg80211_init(), in ath6kl_core_init(). Move them into a single palce. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 14 ++++++++++++++ drivers/net/wireless/ath/ath6kl/core.c | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 5da0f292ec79..bad92441b78a 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -3077,6 +3077,20 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) wiphy->max_sched_scan_ssids = 10; + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | + WIPHY_FLAG_HAVE_AP_SME | + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; + + if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN, ar->fw_capabilities)) + ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; + + ar->wiphy->probe_resp_offload = + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U; + ret = wiphy_register(wiphy); if (ret < 0) { ath6kl_err("couldn't register wiphy device\n"); diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 39684650e843..d078aedfbf77 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -154,20 +154,6 @@ int ath6kl_core_init(struct ath6kl *ar) if (uart_debug) ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; - ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | - WIPHY_FLAG_HAVE_AP_SME | - WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | - WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; - - if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN, ar->fw_capabilities)) - ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; - - ar->wiphy->probe_resp_offload = - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P | - NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U; - set_bit(FIRST_BOOT, &ar->flag); ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; -- GitLab From 4705b7036c2fec73856ae57b0a1f452fca705cd5 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 28 Feb 2012 20:20:20 +0530 Subject: [PATCH 1255/1846] ath6kl: Initialize netdev hw_features for every interface Move netdev->hw_features setting from ath6kl_core_init() to init_netdev() so that it is done for every interface. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.c | 2 -- drivers/net/wireless/ath/ath6kl/main.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index d078aedfbf77..d5c06c0dddab 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -156,8 +156,6 @@ int ath6kl_core_init(struct ath6kl *ar) set_bit(FIRST_BOOT, &ar->flag); - ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; - ret = ath6kl_init_hw_start(ar); if (ret) { ath6kl_err("Failed to start hardware: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 0d6e352bfb17..f804cf135a60 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -1212,5 +1212,7 @@ void init_netdev(struct net_device *dev) sizeof(struct wmi_data_hdr) + HTC_HDR_LENGTH + WMI_MAX_TX_META_SZ + ATH6KL_HTC_ALIGN_BYTES; + dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; + return; } -- GitLab From 5dbc811f42d030405df765a1f12047b16bb0caa3 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 28 Feb 2012 20:20:21 +0530 Subject: [PATCH 1256/1846] ath6kl: Refactor ath6kl_wmi_control_rx() Split the wmi event processing into the one which needs to be vif specific and the reset. This is a step towards avoiding the need for wiphy and a netdev registration before getting any message from firmware. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/wmi.c | 200 +++++++++++++------------- 1 file changed, 99 insertions(+), 101 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index fce29f7f2e5c..c0393b344a1f 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -3396,32 +3396,101 @@ static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); } -/* Control Path */ -int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) +/* Process interface specific wmi events, caller would free the datap */ +static int ath6kl_wmi_proc_events_vif(struct wmi *wmi, u16 if_idx, u16 cmd_id, + u8 *datap, u32 len) { - struct wmi_cmd_hdr *cmd; struct ath6kl_vif *vif; - u32 len; - u16 id; - u8 if_idx; - u8 *datap; - int ret = 0; - if (WARN_ON(skb == NULL)) + vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); + if (!vif) { + ath6kl_dbg(ATH6KL_DBG_WMI, + "Wmi event for unavailable vif, vif_index:%d\n", + if_idx); return -EINVAL; + } - if (skb->len < sizeof(struct wmi_cmd_hdr)) { - ath6kl_err("bad packet 1\n"); - dev_kfree_skb(skb); + switch (cmd_id) { + case WMI_CONNECT_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); + return ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); + case WMI_DISCONNECT_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); + return ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); + case WMI_TKIP_MICERR_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); + return ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); + case WMI_BSSINFO_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); + return ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); + case WMI_NEIGHBOR_REPORT_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); + return ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, + vif); + case WMI_SCAN_COMPLETE_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); + return ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); + case WMI_REPORT_STATISTICS_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); + return ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); + case WMI_CAC_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); + return ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); + case WMI_PSPOLL_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); + return ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); + case WMI_DTIMEXPIRY_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); + return ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); + case WMI_ADDBA_REQ_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); + return ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); + case WMI_DELBA_REQ_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); + return ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); + case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, + "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID"); + return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif); + case WMI_REMAIN_ON_CHNL_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); + return ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); + case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, + "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); + return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, + len, vif); + case WMI_TX_STATUS_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); + return ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); + case WMI_RX_PROBE_REQ_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); + return ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); + case WMI_RX_ACTION_EVENTID: + ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); + return ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); + default: + ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", cmd_id); return -EINVAL; } + return 0; +} + +static int ath6kl_wmi_proc_events(struct wmi *wmi, struct sk_buff *skb) +{ + struct wmi_cmd_hdr *cmd; + int ret = 0; + u32 len; + u16 id; + u8 if_idx; + u8 *datap; + cmd = (struct wmi_cmd_hdr *) skb->data; id = le16_to_cpu(cmd->cmd_id); if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK; skb_pull(skb, sizeof(struct wmi_cmd_hdr)); - datap = skb->data; len = skb->len; @@ -3429,15 +3498,6 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", datap, len); - vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); - if (!vif) { - ath6kl_dbg(ATH6KL_DBG_WMI, - "Wmi event for unavailable vif, vif_index:%d\n", - if_idx); - dev_kfree_skb(skb); - return -EINVAL; - } - switch (id) { case WMI_GET_BITRATE_CMDID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); @@ -3455,26 +3515,10 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); break; - case WMI_CONNECT_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); - ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); - break; - case WMI_DISCONNECT_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); - ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); - break; case WMI_PEER_NODE_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); break; - case WMI_TKIP_MICERR_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); - ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); - break; - case WMI_BSSINFO_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); - ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); - break; case WMI_REGDOMAIN_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); ath6kl_wmi_regdomain_event(wmi, datap, len); @@ -3483,23 +3527,10 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); break; - case WMI_NEIGHBOR_REPORT_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); - ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, - vif); - break; - case WMI_SCAN_COMPLETE_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); - ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); - break; case WMI_CMDERROR_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); ret = ath6kl_wmi_error_event_rx(wmi, datap, len); break; - case WMI_REPORT_STATISTICS_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); - ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); - break; case WMI_RSSI_THRESHOLD_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); @@ -3519,10 +3550,6 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); break; - case WMI_CAC_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); - ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); - break; case WMI_CHANNEL_CHANGE_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); break; @@ -3562,28 +3589,12 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); break; - case WMI_PSPOLL_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); - ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); - break; - case WMI_DTIMEXPIRY_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); - ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); - break; case WMI_SET_PARAMS_REPLY_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); break; - case WMI_ADDBA_REQ_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); - ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); - break; case WMI_ADDBA_RESP_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); break; - case WMI_DELBA_REQ_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); - ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); - break; case WMI_REPORT_BTCOEX_CONFIG_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); @@ -3596,52 +3607,39 @@ int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); ret = ath6kl_wmi_tx_complete_event_rx(datap, len); break; - case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, - "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID"); - ret = ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif); - break; - case WMI_REMAIN_ON_CHNL_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); - ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); - break; - case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, - "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); - ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, - len, vif); - break; - case WMI_TX_STATUS_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); - ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); - break; - case WMI_RX_PROBE_REQ_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); - ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); - break; case WMI_P2P_CAPABILITIES_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); break; - case WMI_RX_ACTION_EVENTID: - ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); - ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); - break; case WMI_P2P_INFO_EVENTID: ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); ret = ath6kl_wmi_p2p_info_event_rx(datap, len); break; default: - ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); - ret = -EINVAL; + /* may be the event is interface specific */ + ret = ath6kl_wmi_proc_events_vif(wmi, if_idx, id, datap, len); break; } dev_kfree_skb(skb); - return ret; } +/* Control Path */ +int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) +{ + if (WARN_ON(skb == NULL)) + return -EINVAL; + + if (skb->len < sizeof(struct wmi_cmd_hdr)) { + ath6kl_err("bad packet 1\n"); + dev_kfree_skb(skb); + return -EINVAL; + } + + return ath6kl_wmi_proc_events(wmi, skb); +} + void ath6kl_wmi_reset(struct wmi *wmi) { spin_lock_bh(&wmi->lock); -- GitLab From 81db48dc295e16aced8ece912098fda078b1ba8c Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 28 Feb 2012 20:20:22 +0530 Subject: [PATCH 1257/1846] ath6kl: Skip vif index validation in ath6kl_rx() for wmi events When the wmi event is vif specific, the validation of vif index is taken care in ath6kl_wmi_proc_events_iface(). This also avoids the need for a netdev to be registered while receiving initial events like "target_ready" and "regulatory domain". Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/txrx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 802291346d30..6754441105ef 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -1298,7 +1298,15 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) skb_put(skb, packet->act_len + HTC_HDR_LENGTH); skb_pull(skb, HTC_HDR_LENGTH); + ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "rx ", + skb->data, skb->len); + if (ept == ar->ctrl_ep) { + if (test_bit(WMI_ENABLED, &ar->flag)) { + ath6kl_check_wow_status(ar); + ath6kl_wmi_control_rx(ar->wmi, skb); + return; + } if_idx = wmi_cmd_hdr_get_if_idx((struct wmi_cmd_hdr *) skb->data); } else { @@ -1323,10 +1331,6 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) spin_unlock_bh(&vif->if_lock); - - ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, __func__, "rx ", - skb->data, skb->len); - skb->dev = vif->ndev; if (!test_bit(WMI_ENABLED, &ar->flag)) { @@ -1338,11 +1342,6 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) ath6kl_check_wow_status(ar); - if (ept == ar->ctrl_ep) { - ath6kl_wmi_control_rx(ar->wmi, skb); - return; - } - min_hdr_len = sizeof(struct ethhdr) + sizeof(struct wmi_data_hdr) + sizeof(struct ath6kl_llc_snap_hdr); -- GitLab From b796f0934ae07fdd26d265ac9bf87e18921d7fef Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 28 Feb 2012 20:20:23 +0530 Subject: [PATCH 1258/1846] ath6kl: Defer wiphy and netdev registration till the end of ath6kl_core_init() This makes the wiphy and initial netdev registration the last step in dev initialization. Apart from the fact that this looks right, it can also be used to setup wiphy with the regulatory information received from firmware after uploading the firmware. Also it fixes a FIXME in ath6kl_core_init() where mac address is copied into netdev->dev_addr, ath6kl_interface_add() takes care of this as well. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.c | 76 +++++++++++--------------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index d5c06c0dddab..e66cf4399b61 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -98,38 +98,6 @@ int ath6kl_core_init(struct ath6kl *ar) ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi); - ret = ath6kl_cfg80211_init(ar); - if (ret) - goto err_node_cleanup; - - ret = ath6kl_debug_init(ar); - if (ret) { - wiphy_unregister(ar->wiphy); - goto err_node_cleanup; - } - - for (i = 0; i < ar->vif_max; i++) - ar->avail_idx_map |= BIT(i); - - rtnl_lock(); - - /* Add an initial station interface */ - ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, - INFRA_NETWORK); - - rtnl_unlock(); - - if (!ndev) { - ath6kl_err("Failed to instantiate a network device\n"); - ret = -ENOMEM; - wiphy_unregister(ar->wiphy); - goto err_debug_init; - } - - - ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", - __func__, ndev->name, ndev, ar); - /* setup access class priority mappings */ ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */ ar->ac_stream_pri_map[WMM_AC_BE] = 1; @@ -166,24 +134,44 @@ int ath6kl_core_init(struct ath6kl *ar) ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep); ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]); - /* - * Set mac address which is received in ready event - * FIXME: Move to ath6kl_interface_add() - */ - memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); + ret = ath6kl_cfg80211_init(ar); + if (ret) + goto err_rxbuf_cleanup; - return ret; + ret = ath6kl_debug_init(ar); + if (ret) { + wiphy_unregister(ar->wiphy); + goto err_rxbuf_cleanup; + } + + for (i = 0; i < ar->vif_max; i++) + ar->avail_idx_map |= BIT(i); -err_rxbuf_cleanup: - ath6kl_htc_flush_rx_buf(ar->htc_target); - ath6kl_cleanup_amsdu_rxbufs(ar); rtnl_lock(); - ath6kl_cfg80211_vif_cleanup(netdev_priv(ndev)); + + /* Add an initial station interface */ + ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0, + INFRA_NETWORK); + rtnl_unlock(); - wiphy_unregister(ar->wiphy); + + if (!ndev) { + ath6kl_err("Failed to instantiate a network device\n"); + ret = -ENOMEM; + wiphy_unregister(ar->wiphy); + goto err_debug_init; + } + + ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", + __func__, ndev->name, ndev, ar); + + return ret; + err_debug_init: ath6kl_debug_cleanup(ar); -err_node_cleanup: +err_rxbuf_cleanup: + ath6kl_htc_flush_rx_buf(ar->htc_target); + ath6kl_cleanup_amsdu_rxbufs(ar); ath6kl_wmi_shutdown(ar->wmi); clear_bit(WMI_ENABLED, &ar->flag); ar->wmi = NULL; -- GitLab From e5348a1e3341dca3e53a6db568c2d4d48929dd95 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Sat, 25 Feb 2012 14:43:17 +0530 Subject: [PATCH 1259/1846] ath6kl: Make sure wiphy is registered before calling regulatory_hint() As regulatory events are processed even before the wiphy is registered, calling regulatory_hint() at early stage should be fixed. Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 ++++ drivers/net/wireless/ath/ath6kl/core.h | 2 ++ drivers/net/wireless/ath/ath6kl/wmi.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index bad92441b78a..50b76d0a4c6a 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -3097,12 +3097,16 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) return ret; } + ar->wiphy_registered = true; + return 0; } void ath6kl_cfg80211_cleanup(struct ath6kl *ar) { wiphy_unregister(ar->wiphy); + + ar->wiphy_registered = false; } struct ath6kl *ath6kl_cfg80211_create(void) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 5bbc595f23d1..b6bdece63361 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -666,6 +666,8 @@ struct ath6kl { bool p2p; + bool wiphy_registered; + #ifdef CONFIG_ATH6KL_DEBUG struct { struct sk_buff_head fwlog_queue; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index c0393b344a1f..dc6230dea86c 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -914,7 +914,7 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) regpair->regDmnEnum); } - if (country) { + if (country && wmi->parent_dev->wiphy_registered) { alpha2[0] = country->isoName[0]; alpha2[1] = country->isoName[1]; -- GitLab From 719cdac54e0237837251a32a3d690bfe9c1e9bed Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 17 Feb 2012 13:43:05 +0000 Subject: [PATCH 1260/1846] e100: Support RXFCS feature flag. This allows e100 to be configured to append the Ethernet FCS to the skb. Useful for sniffing networks. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e100.c | 35 ++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 485ab8cdac48..3ecbdedf6135 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -1075,7 +1075,7 @@ static void e100_get_defaults(struct nic *nic) /* Template for a freshly allocated RFD */ nic->blank_rfd.command = 0; nic->blank_rfd.rbd = cpu_to_le32(0xFFFFFFFF); - nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN); + nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN + ETH_FCS_LEN); /* MII setup */ nic->mii.phy_id_mask = 0x1F; @@ -1089,6 +1089,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) { struct config *config = &cb->u.config; u8 *c = (u8 *)config; + struct net_device *netdev = nic->netdev; cb->command = cpu_to_le16(cb_config); @@ -1132,6 +1133,9 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) config->promiscuous_mode = 0x1; /* 1=on, 0=off */ } + if (unlikely(netdev->features & NETIF_F_RXFCS)) + config->rx_crc_transfer = 0x1; /* 1=save, 0=discard */ + if (nic->flags & multicast_all) config->multicast_all = 0x1; /* 1=accept, 0=no */ @@ -1881,7 +1885,7 @@ static inline void e100_start_receiver(struct nic *nic, struct rx *rx) } } -#define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN) +#define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN + ETH_FCS_LEN) static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) { if (!(rx->skb = netdev_alloc_skb_ip_align(nic->netdev, RFD_BUF_LEN))) @@ -1919,6 +1923,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, struct sk_buff *skb = rx->skb; struct rfd *rfd = (struct rfd *)skb->data; u16 rfd_status, actual_size; + u16 fcs_pad = 0; if (unlikely(work_done && *work_done >= work_to_do)) return -EAGAIN; @@ -1951,6 +1956,8 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, } /* Get actual data size */ + if (unlikely(dev->features & NETIF_F_RXFCS)) + fcs_pad = 4; actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF; if (unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd))) actual_size = RFD_BUF_LEN - sizeof(struct rfd); @@ -1980,13 +1987,13 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, if (unlikely(!(rfd_status & cb_ok))) { /* Don't indicate if hardware indicates errors */ dev_kfree_skb_any(skb); - } else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) { + } else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN + fcs_pad) { /* Don't indicate oversized frames */ nic->rx_over_length_errors++; dev_kfree_skb_any(skb); } else { dev->stats.rx_packets++; - dev->stats.rx_bytes += actual_size; + dev->stats.rx_bytes += (actual_size - fcs_pad); netif_receive_skb(skb); if (work_done) (*work_done)++; @@ -2058,7 +2065,8 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done, pci_dma_sync_single_for_device(nic->pdev, old_before_last_rx->dma_addr, sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); - old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); + old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN + + ETH_FCS_LEN); pci_dma_sync_single_for_device(nic->pdev, old_before_last_rx->dma_addr, sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); @@ -2729,6 +2737,20 @@ static int e100_close(struct net_device *netdev) return 0; } +static int e100_set_features(struct net_device *netdev, + netdev_features_t features) +{ + struct nic *nic = netdev_priv(netdev); + netdev_features_t changed = features ^ netdev->features; + + if (!(changed & (NETIF_F_RXFCS))) + return 0; + + netdev->features = features; + e100_exec_cb(nic, NULL, e100_configure); + return 0; +} + static const struct net_device_ops e100_netdev_ops = { .ndo_open = e100_open, .ndo_stop = e100_close, @@ -2742,6 +2764,7 @@ static const struct net_device_ops e100_netdev_ops = { #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = e100_netpoll, #endif + .ndo_set_features = e100_set_features, }; static int __devinit e100_probe(struct pci_dev *pdev, @@ -2754,6 +2777,8 @@ static int __devinit e100_probe(struct pci_dev *pdev, if (!(netdev = alloc_etherdev(sizeof(struct nic)))) return -ENOMEM; + netdev->hw_features |= NETIF_F_RXFCS; + netdev->netdev_ops = &e100_netdev_ops; SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops); netdev->watchdog_timeo = E100_WATCHDOG_PERIOD; -- GitLab From 080eec4fb478f10c6f171875634fc3174da1a1c3 Mon Sep 17 00:00:00 2001 From: Aarthi Thiruvengadam Date: Tue, 28 Feb 2012 09:17:04 -0800 Subject: [PATCH 1261/1846] ath6kl: Clear the IE in firmware if not set Remove check so that IE in firmware is cleared if not set. Without this fix, any previously set IE will be used incorrectly in the next frame. For example, consider the scenario where a P2P device scan is followed by a regular station scan. The P2P IE set by the P2P scan needs to be cleared, otherwise the station scan will contain the P2P IE. kvalo: indentation fixes Signed-off-by: Aarthi Thiruvengadam Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 64 ++++++++++------------ 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 50b76d0a4c6a..0becddd8b585 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -885,19 +885,14 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, request->ssids[i].ssid); } - /* - * FIXME: we should clear the IE in fw if it's not set so just - * remove the check altogether - */ - if (request->ie) { - ret = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, - WMI_FRAME_PROBE_REQ, - request->ie, request->ie_len); - if (ret) { - ath6kl_err("failed to set Probe Request appie for " - "scan"); - return ret; - } + /* this also clears IE in fw if it's not set */ + ret = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_PROBE_REQ, + request->ie, request->ie_len); + if (ret) { + ath6kl_err("failed to set Probe Request appie for " + "scan"); + return ret; } /* @@ -2301,28 +2296,27 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, if (vif->next_mode != AP_NETWORK) return -EOPNOTSUPP; - if (info->beacon_ies) { - res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, - WMI_FRAME_BEACON, - info->beacon_ies, - info->beacon_ies_len); - if (res) - return res; - } - if (info->proberesp_ies) { - res = ath6kl_set_ap_probe_resp_ies(vif, info->proberesp_ies, - info->proberesp_ies_len); - if (res) - return res; - } - if (info->assocresp_ies) { - res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, - WMI_FRAME_ASSOC_RESP, - info->assocresp_ies, - info->assocresp_ies_len); - if (res) - return res; - } + /* this also clears IE in fw if it's not set */ + res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_BEACON, + info->beacon_ies, + info->beacon_ies_len); + if (res) + return res; + + /* this also clears IE in fw if it's not set */ + res = ath6kl_set_ap_probe_resp_ies(vif, info->proberesp_ies, + info->proberesp_ies_len); + if (res) + return res; + + /* this also clears IE in fw if it's not set */ + res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_ASSOC_RESP, + info->assocresp_ies, + info->assocresp_ies_len); + if (res) + return res; if (!add) return 0; -- GitLab From 67cd22e48d4acd3ac8c0032b628537bb27e92a24 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Tue, 28 Feb 2012 15:08:46 -0800 Subject: [PATCH 1262/1846] ath6kl: implement hidden ssid The ath6kl FW does not distinguish between different types of hidden SSIDs (empty or null), so treat all cfg80211 requests for hidden ssid the same. Signed-off-by: Thomas Pedersen Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 7 ++++++- drivers/net/wireless/ath/ath6kl/wmi.c | 16 ++++++++++++++++ drivers/net/wireless/ath/ath6kl/wmi.h | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 0becddd8b585..ff916ca7a23c 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2282,6 +2282,7 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, struct ath6kl *ar = ath6kl_priv(dev); struct ath6kl_vif *vif = netdev_priv(dev); struct ieee80211_mgmt *mgmt; + bool hidden = false; u8 *ies; int ies_len; struct wmi_connect_cmd p; @@ -2341,7 +2342,11 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev, memcpy(vif->ssid, info->ssid, info->ssid_len); vif->ssid_len = info->ssid_len; if (info->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) - return -EOPNOTSUPP; /* TODO */ + hidden = true; + + res = ath6kl_wmi_ap_hidden_ssid(ar->wmi, vif->fw_vif_idx, hidden); + if (res) + return res; ret = ath6kl_set_auth_type(vif, info->auth_type); if (ret) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index dc6230dea86c..0a57dcc6041a 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -3013,6 +3013,22 @@ int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, NO_SYNC_WMIFLAG); } +int ath6kl_wmi_ap_hidden_ssid(struct wmi *wmi, u8 if_idx, bool enable) +{ + struct sk_buff *skb; + struct wmi_ap_hidden_ssid_cmd *cmd; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_ap_hidden_ssid_cmd *) skb->data; + cmd->hidden_ssid = enable ? 1 : 0; + + return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_HIDDEN_SSID_CMDID, + NO_SYNC_WMIFLAG); +} + /* This command will be used to enable/disable AP uAPSD feature */ int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable) { diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 38907f411225..cea7429a8a0b 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -2129,6 +2129,10 @@ struct wmi_rx_frame_format_cmd { u8 reserved[1]; } __packed; +struct wmi_ap_hidden_ssid_cmd { + u8 hidden_ssid; +} __packed; + /* AP mode events */ struct wmi_ap_set_apsd_cmd { u8 enable; @@ -2485,6 +2489,7 @@ u8 ath6kl_wmi_get_traffic_class(u8 user_priority); u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri); /* AP mode */ +int ath6kl_wmi_ap_hidden_ssid(struct wmi *wmi, u8 if_idx, bool enable); int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, struct wmi_connect_cmd *p); -- GitLab From 7504a3e1f552cf7447835e7a893bea4bb2d6541d Mon Sep 17 00:00:00 2001 From: Etay Luz Date: Tue, 28 Feb 2012 17:17:15 -0800 Subject: [PATCH 1263/1846] ath6kl: add padding to firmware log records firmware debug utility expects firmware log record size to be 1500 bytes. This patch ensures that the firmware record will be exactly 1500 bytes. kvalo: remove trailing space Signed-off-by: Etay Luz Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 drivers/net/wireless/ath/ath6kl/debug.c diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c old mode 100644 new mode 100755 index 3d0713dfe3b9..28b516ff3d59 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -277,7 +277,7 @@ void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len) if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE)) return; - slot_len = sizeof(*slot) + len; + slot_len = sizeof(*slot) + ATH6KL_FWLOG_PAYLOAD_SIZE; skb = alloc_skb(slot_len, GFP_KERNEL); if (!skb) @@ -288,6 +288,9 @@ void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len) slot->length = cpu_to_le32(len); memcpy(slot->payload, buf, len); + /* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */ + memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len); + spin_lock(&ar->debug.fwlog_queue.lock); __skb_queue_tail(&ar->debug.fwlog_queue, skb); -- GitLab From af840ba7e2886ee69e252e752ebd0cb34e78f6f4 Mon Sep 17 00:00:00 2001 From: Etay Luz Date: Tue, 28 Feb 2012 17:18:04 -0800 Subject: [PATCH 1264/1846] ath6kl: Collect residue firmware logs Collect residue firmware logs following firmware assert. Firmware sends logs to host once the 1500 byte log buffer has been filled. At time of assert, there could be residue logs lying in the firmware. This patch pulls those residue logs. This would give the full picture of the firmware. Signed-off-by: Etay Luz Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/hif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index ef650b61740a..3e569b265332 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -135,6 +135,7 @@ static int ath6kl_hif_proc_dbg_intr(struct ath6kl_device *dev) ath6kl_warn("Failed to clear debug interrupt: %d\n", ret); ath6kl_hif_dump_fw_crash(dev->ar); + ath6kl_read_fwlogs(dev->ar); return ret; } -- GitLab From 75f58a537674cdff2122789cfd3cc7a76956ece5 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Sat, 11 Feb 2012 15:39:35 +0000 Subject: [PATCH 1265/1846] e100: Support sending custom Ethernet CRC This can aid with testing the RX logic for bad CRCs. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e100.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 3ecbdedf6135..6f9f70a04474 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -412,6 +412,10 @@ enum cb_status { cb_ok = 0x2000, }; +/** + * cb_command - Command Block flags + * @cb_tx_nc: 0: controler does CRC (normal), 1: CRC from skb memory + */ enum cb_command { cb_nop = 0x0000, cb_iaaddr = 0x0001, @@ -421,6 +425,7 @@ enum cb_command { cb_ucode = 0x0005, cb_dump = 0x0006, cb_tx_sf = 0x0008, + cb_tx_nc = 0x0010, cb_cid = 0x1f00, cb_i = 0x2000, cb_s = 0x4000, @@ -1724,6 +1729,16 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb, struct sk_buff *skb) { cb->command = nic->tx_command; + + /* + * Use the last 4 bytes of the SKB payload packet as the CRC, used for + * testing, ie sending frames with bad CRC. + */ + if (unlikely(skb->no_fcs)) + cb->command |= __constant_cpu_to_le16(cb_tx_nc); + else + cb->command &= ~__constant_cpu_to_le16(cb_tx_nc); + /* interrupt every 16 packets regardless of delay */ if ((nic->cbs_avail & ~15) == nic->cbs_avail) cb->command |= cpu_to_le16(cb_i); @@ -2778,6 +2793,7 @@ static int __devinit e100_probe(struct pci_dev *pdev, return -ENOMEM; netdev->hw_features |= NETIF_F_RXFCS; + netdev->priv_flags |= IFF_SUPP_NOFCS; netdev->netdev_ops = &e100_netdev_ops; SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops); -- GitLab From 0bf61e66a09793aba617e8918fbf739cd5db8e78 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 17 Feb 2012 13:43:44 +0000 Subject: [PATCH 1266/1846] e100: Support RXALL feature flag. This allows the NIC to receive packets with bad FCS and other errors. Good for sniffing packets on flakey networks. v4: Only flax rx-over-length errors if pkt is beyond maximum expected packet size, not just beyond the MTU. This matches the existing logic for this counter. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e100.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 6f9f70a04474..4d8a616fe9cd 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -462,7 +462,7 @@ struct config { /*5*/ u8 X(tx_dma_max_count:7, dma_max_count_enable:1); /*6*/ u8 X(X(X(X(X(X(X(late_scb_update:1, direct_rx_dma:1), tno_intr:1), cna_intr:1), standard_tcb:1), standard_stat_counter:1), - rx_discard_overruns:1), rx_save_bad_frames:1); + rx_save_overruns : 1), rx_save_bad_frames : 1); /*7*/ u8 X(X(X(X(X(rx_discard_short_frames:1, tx_underrun_retry:2), pad7:2), rx_extended_rfd:1), tx_two_frames_in_fifo:1), tx_dynamic_tbd:1); @@ -1165,6 +1165,12 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb) } } + if (netdev->features & NETIF_F_RXALL) { + config->rx_save_overruns = 0x1; /* 1=save, 0=discard */ + config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */ + config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */ + } + netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); @@ -1999,6 +2005,16 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, skb_put(skb, actual_size); skb->protocol = eth_type_trans(skb, nic->netdev); + /* If we are receiving all frames, then don't bother + * checking for errors. + */ + if (unlikely(dev->features & NETIF_F_RXALL)) { + if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN + fcs_pad) + /* Received oversized frame, but keep it. */ + nic->rx_over_length_errors++; + goto process_skb; + } + if (unlikely(!(rfd_status & cb_ok))) { /* Don't indicate if hardware indicates errors */ dev_kfree_skb_any(skb); @@ -2007,6 +2023,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, nic->rx_over_length_errors++; dev_kfree_skb_any(skb); } else { +process_skb: dev->stats.rx_packets++; dev->stats.rx_bytes += (actual_size - fcs_pad); netif_receive_skb(skb); @@ -2758,7 +2775,7 @@ static int e100_set_features(struct net_device *netdev, struct nic *nic = netdev_priv(netdev); netdev_features_t changed = features ^ netdev->features; - if (!(changed & (NETIF_F_RXFCS))) + if (!(changed & (NETIF_F_RXFCS | NETIF_F_RXALL))) return 0; netdev->features = features; @@ -2794,6 +2811,7 @@ static int __devinit e100_probe(struct pci_dev *pdev, netdev->hw_features |= NETIF_F_RXFCS; netdev->priv_flags |= IFF_SUPP_NOFCS; + netdev->hw_features |= NETIF_F_RXALL; netdev->netdev_ops = &e100_netdev_ops; SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops); -- GitLab From 06c24b915cad962b4dce6760fb130677123bc6c3 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Thu, 23 Feb 2012 03:13:13 +0000 Subject: [PATCH 1267/1846] e1000e: cleanup incorrect filename in comment Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 8b62870e2c25..efb37290262d 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -6628,4 +6628,4 @@ MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_VERSION); -/* e1000_main.c */ +/* netdev.c */ -- GitLab From 3d3a1676561cfb0dcef0cf5e146ddefbb16f5598 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Thu, 23 Feb 2012 03:13:18 +0000 Subject: [PATCH 1268/1846] e1000e: cleanup whitespace and indentation Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/82571.c | 14 +++-- drivers/net/ethernet/intel/e1000e/ich8lan.c | 10 ++-- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- drivers/net/ethernet/intel/e1000e/netdev.c | 10 ++-- drivers/net/ethernet/intel/e1000e/phy.c | 59 ++++++++------------- 5 files changed, 38 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index 086dad709179..b3fdc6977f2e 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1269,18 +1269,16 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) reg |= E1000_PBA_ECC_CORR_EN; ew32(PBA_ECC, reg); } + /* * Workaround for hardware errata. * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572 */ - - if ((hw->mac.type == e1000_82571) || - (hw->mac.type == e1000_82572)) { - reg = er32(CTRL_EXT); - reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN; - ew32(CTRL_EXT, reg); - } - + if ((hw->mac.type == e1000_82571) || (hw->mac.type == e1000_82572)) { + reg = er32(CTRL_EXT); + reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN; + ew32(CTRL_EXT, reg); + } /* PCI-Ex Control Registers */ switch (hw->mac.type) { diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 8e9af624d54a..64c76443a7aa 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1230,9 +1230,8 @@ s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) u32 reg = 0; u16 kmrn_reg = 0; - ret_val = e1000e_read_kmrn_reg_locked(hw, - E1000_KMRNCTRLSTA_K1_CONFIG, - &kmrn_reg); + ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, + &kmrn_reg); if (ret_val) return ret_val; @@ -1241,9 +1240,8 @@ s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) else kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE; - ret_val = e1000e_write_kmrn_reg_locked(hw, - E1000_KMRNCTRLSTA_K1_CONFIG, - kmrn_reg); + ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, + kmrn_reg); if (ret_val) return ret_val; diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 59ac9f6353de..decad98c1059 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -629,7 +629,7 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) if (E1000_TXCW_ANE & er32(TXCW)) { status = er32(STATUS); if (status & E1000_STATUS_LU) { - /* SYNCH bit and IV bit are sticky, so reread rxcw. */ + /* SYNCH bit and IV bit are sticky, so reread rxcw. */ udelay(10); rxcw = er32(RXCW); if (rxcw & E1000_RXCW_SYNCH) { diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index efb37290262d..a9a4ea2c616e 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -3262,6 +3262,7 @@ static void e1000e_set_rx_mode(struct net_device *netdev) e1000e_vlan_filter_disable(adapter); } else { int count; + if (netdev->flags & IFF_ALLMULTI) { rctl |= E1000_RCTL_MPE; } else { @@ -6103,7 +6104,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev, const struct e1000_info *ei = e1000_info_tbl[ent->driver_data]; resource_size_t mmio_start, mmio_len; resource_size_t flash_start, flash_len; - static int cards_found; u16 aspm_disable_flag = 0; int i, err, pci_using_dac; @@ -6347,11 +6347,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev, } else if (adapter->flags & FLAG_APME_IN_CTRL3) { if (adapter->flags & FLAG_APME_CHECK_PORT_B && (adapter->hw.bus.func == 1)) - e1000_read_nvm(&adapter->hw, - NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); + e1000_read_nvm(&adapter->hw, NVM_INIT_CONTROL3_PORT_B, + 1, &eeprom_data); else - e1000_read_nvm(&adapter->hw, - NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); + e1000_read_nvm(&adapter->hw, NVM_INIT_CONTROL3_PORT_A, + 1, &eeprom_data); } /* fetch WoL from EEPROM */ diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 683abac4a049..6e768b11380e 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1007,12 +1007,12 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw) * The possible values of the "fc" parameter are: * 0: Flow control is completely disabled * 1: Rx flow control is enabled (we can receive pause frames - * but not send pause frames). + * but not send pause frames). * 2: Tx flow control is enabled (we can send pause frames - * but we do not support receiving pause frames). + * but we do not support receiving pause frames). * 3: Both Rx and Tx flow control (symmetric) are enabled. * other: No software override. The flow control configuration - * in the EEPROM is used. + * in the EEPROM is used. */ switch (hw->fc.current_mode) { case e1000_fc_none: @@ -1172,10 +1172,8 @@ s32 e1000e_setup_copper_link(struct e1000_hw *hw) * Check link status. Wait up to 100 microseconds for link to become * valid. */ - ret_val = e1000e_phy_has_link_generic(hw, - COPPER_LINK_UP_LIMIT, - 10, - &link); + ret_val = e1000e_phy_has_link_generic(hw, COPPER_LINK_UP_LIMIT, 10, + &link); if (ret_val) return ret_val; @@ -1237,10 +1235,8 @@ s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw) if (phy->autoneg_wait_to_complete) { e_dbg("Waiting for forced speed/duplex link on IGP phy.\n"); - ret_val = e1000e_phy_has_link_generic(hw, - PHY_FORCE_LIMIT, - 100000, - &link); + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + 100000, &link); if (ret_val) return ret_val; @@ -1248,10 +1244,8 @@ s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw) e_dbg("Link taking longer than expected.\n"); /* Try once more */ - ret_val = e1000e_phy_has_link_generic(hw, - PHY_FORCE_LIMIT, - 100000, - &link); + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + 100000, &link); } return ret_val; @@ -1412,10 +1406,8 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw) if (phy->autoneg_wait_to_complete) { e_dbg("Waiting for forced speed/duplex link on IFE phy.\n"); - ret_val = e1000e_phy_has_link_generic(hw, - PHY_FORCE_LIMIT, - 100000, - &link); + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + 100000, &link); if (ret_val) return ret_val; @@ -1423,10 +1415,8 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw) e_dbg("Link taking longer than expected.\n"); /* Try once more */ - ret_val = e1000e_phy_has_link_generic(hw, - PHY_FORCE_LIMIT, - 100000, - &link); + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + 100000, &link); if (ret_val) return ret_val; } @@ -2167,6 +2157,7 @@ s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw) s32 e1000e_get_cfg_done(struct e1000_hw *hw) { mdelay(10); + return 0; } @@ -3155,13 +3146,11 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) if (ret_val) return ret_val; - data &= BM_CS_STATUS_LINK_UP | - BM_CS_STATUS_RESOLVED | - BM_CS_STATUS_SPEED_MASK; + data &= BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | + BM_CS_STATUS_SPEED_MASK; - if (data != (BM_CS_STATUS_LINK_UP | - BM_CS_STATUS_RESOLVED | - BM_CS_STATUS_SPEED_1000)) + if (data != (BM_CS_STATUS_LINK_UP | BM_CS_STATUS_RESOLVED | + BM_CS_STATUS_SPEED_1000)) return 0; mdelay(200); @@ -3227,10 +3216,8 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw) if (phy->autoneg_wait_to_complete) { e_dbg("Waiting for forced speed/duplex link on 82577 phy\n"); - ret_val = e1000e_phy_has_link_generic(hw, - PHY_FORCE_LIMIT, - 100000, - &link); + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + 100000, &link); if (ret_val) return ret_val; @@ -3238,10 +3225,8 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw) e_dbg("Link taking longer than expected.\n"); /* Try once more */ - ret_val = e1000e_phy_has_link_generic(hw, - PHY_FORCE_LIMIT, - 100000, - &link); + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + 100000, &link); } return ret_val; -- GitLab From bb9c5ee15b560f944a8877f60e7d3d77ad542286 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Thu, 23 Feb 2012 03:31:29 +0000 Subject: [PATCH 1269/1846] e1000e: use msleep instead of mdelay The e1000_link_stall_workaround_lv() function is always called in non- atomic context so it should use msleep instead of mdelay. Also, remove unnecessary #include . Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/phy.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 6e768b11380e..35b45578c604 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -26,8 +26,6 @@ *******************************************************************************/ -#include - #include "e1000.h" static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw); @@ -3153,7 +3151,7 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw) BM_CS_STATUS_SPEED_1000)) return 0; - mdelay(200); + msleep(200); /* flush the packets in the fifo buffer */ ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC | -- GitLab From 9e0c5648d973cfe6bb037df3fdd08903c81bdc3e Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:33 +0000 Subject: [PATCH 1270/1846] ixgbe: Minor formatting and comment corrections for ixgbe_xmit_frame_ring This patch is meant to address several minor issues in ixgbe_xmit_frame_ring. Specifically it adds a comment explaining the TXSW flag, and correctly wraps a line over 80 characters. Signed-off-by: Alexander Duyck Tested-by: Phil Schmitt Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 4e55860fdcd4..1cf676bf12ec 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -7012,11 +7012,6 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, return NETDEV_TX_BUSY; } -#ifdef CONFIG_PCI_IOV - if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) - tx_flags |= IXGBE_TX_FLAGS_TXSW; - -#endif /* if we have a HW VLAN tag being added default to the HW one */ if (vlan_tx_tag_present(skb)) { tx_flags |= vlan_tx_tag_get(skb) << IXGBE_TX_FLAGS_VLAN_SHIFT; @@ -7029,10 +7024,20 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, goto out_drop; protocol = vhdr->h_vlan_encapsulated_proto; - tx_flags |= ntohs(vhdr->h_vlan_TCI) << IXGBE_TX_FLAGS_VLAN_SHIFT; + tx_flags |= ntohs(vhdr->h_vlan_TCI) << + IXGBE_TX_FLAGS_VLAN_SHIFT; tx_flags |= IXGBE_TX_FLAGS_SW_VLAN; } +#ifdef CONFIG_PCI_IOV + /* + * Use the l2switch_enable flag - would be false if the DMA + * Tx switch had been disabled. + */ + if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) + tx_flags |= IXGBE_TX_FLAGS_TXSW; + +#endif /* DCB maps skb priorities 0-7 onto 3 bit PCP of VLAN tag. */ if ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && ((tx_flags & (IXGBE_TX_FLAGS_HW_VLAN | IXGBE_TX_FLAGS_SW_VLAN)) || -- GitLab From c466d7a73360ed02167598a94984ab7b4dadfa68 Mon Sep 17 00:00:00 2001 From: Don Skidmore Date: Tue, 28 Feb 2012 06:35:54 +0000 Subject: [PATCH 1271/1846] ixgbe: fix spelling errors Correct spelling error caught with codespell.py. Signed-off-by: Don Skidmore Tested-by: Phil Schmitt Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 383b9413292e..87f6b4f8abbd 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -3336,7 +3336,7 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length) * @hw: pointer to the HW structure * @buffer: contains the command to write and where the return status will * be placed - * @lenght: lenght of buffer, must be multiple of 4 bytes + * @length: length of buffer, must be multiple of 4 bytes * * Communicates with the manageability block. On success return 0 * else return IXGBE_ERR_HOST_INTERFACE_COMMAND. -- GitLab From 24ddd967806a5f0a7915721b7d60cac6f2cf5db9 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Fri, 10 Feb 2012 02:08:32 +0000 Subject: [PATCH 1272/1846] ixgbe: Fix comments that are out of date or formatted incorrectly This patch corrects several comments that are either incorrect or formatted incorrectly for multiline comments. Signed-off-by: Alexander Duyck Tested-by: Phil Schmitt Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 1cf676bf12ec..23a466530a04 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2359,7 +2359,7 @@ static irqreturn_t ixgbe_intr(int irq, void *data) u32 eicr; /* - * Workaround for silicon errata on 82598. Mask the interrupts + * Workaround for silicon errata #26 on 82598. Mask the interrupt * before the read of EICR. */ IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK); @@ -4381,7 +4381,11 @@ static inline bool ixgbe_set_fdir_queues(struct ixgbe_adapter *adapter) f_fdir->indices = min((int)num_online_cpus(), f_fdir->indices); f_fdir->mask = 0; - /* Flow Director must have RSS enabled */ + /* + * Use RSS in addition to Flow Director to ensure the best + * distribution of flows across cores, even when an FDIR flow + * isn't matched. + */ if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) { adapter->num_tx_queues = f_fdir->indices; @@ -4558,7 +4562,8 @@ static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, */ vector_threshold = MIN_MSIX_COUNT; - /* The more we get, the more we will assign to Tx/Rx Cleanup + /* + * The more we get, the more we will assign to Tx/Rx Cleanup * for the separate queues...where Rx Cleanup >= Tx Cleanup. * Right now, we simply care about how many we'll get; we'll * set them up later while requesting irq's. @@ -6996,7 +7001,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, /* * need: 1 descriptor per page * PAGE_SIZE/IXGBE_MAX_DATA_PER_TXD, - * + 1 desc for skb_head_len/IXGBE_MAX_DATA_PER_TXD, + * + 1 desc for skb_headlen/IXGBE_MAX_DATA_PER_TXD, * + 2 desc gap to keep tail from touching head, * + 1 desc for context descriptor, * otherwise try next time -- GitLab From 48752f6513012a1b078da08b145d5c40a644f058 Mon Sep 17 00:00:00 2001 From: Greg Rose Date: Wed, 8 Feb 2012 00:45:00 +0000 Subject: [PATCH 1273/1846] rtnetlink: Fix VF IFLA policy Add VF spoof check to IFLA policy. The original patch I submitted to add the spoof checking feature to rtnl failed to add the proper policy rule that identifies the data type and len. This patch corrects that oversight. No bugs have been reported against this but it may cause some problem for the netlink message parsing that uses the policy table. CC: stable@vger.kernel.org Signed-off-by: Greg Rose Tested-by: Sibai Li Signed-off-by: Jeff Kirsher --- net/core/rtnetlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 5cf39cd7da85..2be10181d583 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1132,6 +1132,8 @@ static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { .len = sizeof(struct ifla_vf_vlan) }, [IFLA_VF_TX_RATE] = { .type = NLA_BINARY, .len = sizeof(struct ifla_vf_tx_rate) }, + [IFLA_VF_SPOOFCHK] = { .type = NLA_BINARY, + .len = sizeof(struct ifla_vf_spoofchk) }, }; static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = { -- GitLab From d1f4159723450252b643bcddff064153f32918bc Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Thu, 9 Feb 2012 12:57:12 +0530 Subject: [PATCH 1274/1846] ath6kl: Fix random system lockup The commit "ath6kl: Use a mutex_lock to avoid race in diabling and handling irq" introduces a state where ath6kl_sdio_irq_handler() would be waiting to claim the sdio function for receive indefinitely when things happen in the following order. ath6kl_sdio_irq_handler() - aquires mtx_irq - sdio_release_host() ath6kl_sdio_irq_disable() - sdio_claim_host() - sleep on mtx_irq ath6kl_hif_intr_bh_handler() - (indefinitely) wait for the sdio function to be released to exclusively claim it again for receive operation. Fix this by replacing the mtx_irq with an atomic variable and a wait_queue. kvalo: add ath6kl_sdio_is_on_irq() due to open parenthesis alignment Signed-off-by: Raja Mani Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 34 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index cae446bf2129..346f5dd3a954 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -50,8 +50,8 @@ struct ath6kl_sdio { /* scatter request list head */ struct list_head scat_req; - /* Avoids disabling irq while the interrupts being handled */ - struct mutex mtx_irq; + atomic_t irq_handling; + wait_queue_head_t irq_wq; spinlock_t scat_lock; bool scatter_enabled; @@ -463,7 +463,7 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func) ath6kl_dbg(ATH6KL_DBG_SDIO, "irq\n"); ar_sdio = sdio_get_drvdata(func); - mutex_lock(&ar_sdio->mtx_irq); + atomic_set(&ar_sdio->irq_handling, 1); /* * Release the host during interrups so we can pick it back up when * we process commands. @@ -472,7 +472,10 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func) status = ath6kl_hif_intr_bh_handler(ar_sdio->ar); sdio_claim_host(ar_sdio->func); - mutex_unlock(&ar_sdio->mtx_irq); + + atomic_set(&ar_sdio->irq_handling, 0); + wake_up(&ar_sdio->irq_wq); + WARN_ON(status && status != -ECANCELED); } @@ -573,6 +576,13 @@ static void ath6kl_sdio_irq_enable(struct ath6kl *ar) sdio_release_host(ar_sdio->func); } +static bool ath6kl_sdio_is_on_irq(struct ath6kl *ar) +{ + struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); + + return !atomic_read(&ar_sdio->irq_handling); +} + static void ath6kl_sdio_irq_disable(struct ath6kl *ar) { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); @@ -580,14 +590,21 @@ static void ath6kl_sdio_irq_disable(struct ath6kl *ar) sdio_claim_host(ar_sdio->func); - mutex_lock(&ar_sdio->mtx_irq); + if (atomic_read(&ar_sdio->irq_handling)) { + sdio_release_host(ar_sdio->func); + + ret = wait_event_interruptible(ar_sdio->irq_wq, + ath6kl_sdio_is_on_irq(ar)); + if (ret) + return; + + sdio_claim_host(ar_sdio->func); + } ret = sdio_release_irq(ar_sdio->func); if (ret) ath6kl_err("Failed to release sdio irq: %d\n", ret); - mutex_unlock(&ar_sdio->mtx_irq); - sdio_release_host(ar_sdio->func); } @@ -1288,7 +1305,6 @@ static int ath6kl_sdio_probe(struct sdio_func *func, spin_lock_init(&ar_sdio->scat_lock); spin_lock_init(&ar_sdio->wr_async_lock); mutex_init(&ar_sdio->dma_buffer_mutex); - mutex_init(&ar_sdio->mtx_irq); INIT_LIST_HEAD(&ar_sdio->scat_req); INIT_LIST_HEAD(&ar_sdio->bus_req_freeq); @@ -1296,6 +1312,8 @@ static int ath6kl_sdio_probe(struct sdio_func *func, INIT_WORK(&ar_sdio->wr_async_work, ath6kl_sdio_write_async_work); + init_waitqueue_head(&ar_sdio->irq_wq); + for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]); -- GitLab From 8b90129cc5789a4c65547c91c9a7b1fd3a4d56a4 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Thu, 23 Feb 2012 18:09:27 -0300 Subject: [PATCH 1275/1846] Bluetooth: Check capabilities in BR/EDR and LE-Only discovery This patch add an extra check for BR/EDR and LE-Only discovery. This way, we are able to return error immediately if the discovery type requested is not supported by the device. Signed-off-by: Andre Guedes Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index abf1adb8bc16..3fcccad75453 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2602,12 +2602,18 @@ static int start_discovery(struct sock *sk, u16 index, switch (hdev->discovery.type) { case DISCOV_TYPE_BREDR: - err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); + if (lmp_bredr_capable(hdev)) + err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); + else + err = -ENOTSUPP; break; case DISCOV_TYPE_LE: - err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, + if (lmp_host_le_capable(hdev)) + err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); + else + err = -ENOTSUPP; break; case DISCOV_TYPE_INTERLEAVED: -- GitLab From 75fb0e324daa48ec458fb5c2960eb07b80cfad9d Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 1 Mar 2012 21:35:55 +0200 Subject: [PATCH 1276/1846] Bluetooth: Fix init sequence for some CSR based controllers Some CSR controllers will generate a spontaneous reset during init and just eat up any pending command without sending a command complete for it. This patch solves the issue by just resending whatever was the last sent command. hci_send_cmd is not used since we need to bypass all other commands in the send queue. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_core.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index db484a8e7364..d3ddc0ba9cd4 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -82,8 +82,28 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result) /* If this is the init phase check if the completed command matches * the last init command, and if not just return. */ - if (test_bit(HCI_INIT, &hdev->flags) && hdev->init_last_cmd != cmd) + if (test_bit(HCI_INIT, &hdev->flags) && hdev->init_last_cmd != cmd) { + struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; + struct sk_buff *skb; + + /* Some CSR based controllers generate a spontaneous + * reset complete event during init and any pending + * command will never be completed. In such a case we + * need to resend whatever was the last sent + * command. + */ + + if (cmd != HCI_OP_RESET || sent->opcode == HCI_OP_RESET) + return; + + skb = skb_clone(hdev->sent_cmd, GFP_ATOMIC); + if (skb) { + skb_queue_head(&hdev->cmd_q, skb); + queue_work(hdev->workqueue, &hdev->cmd_work); + } + return; + } if (hdev->req_status == HCI_REQ_PEND) { hdev->req_result = result; -- GitLab From 9c717758c9289331e22c88ef69d8c248def9cd29 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 29 Feb 2012 14:23:27 +0000 Subject: [PATCH 1277/1846] mdio: Export mdio.h to userland The ID packing definitions are needed by userland and the register definitions may also be useful there. Do not export mdio_phy_id_{is_c45,prtad,devad}() as the use of bool is problematic and it's not that useful to export only a subset of these. Do not export MDIO_SUPPORTS_{C22,C45} directly; these flags are only exposed to userland through struct ethtool_cmd so they should be defined alongside that with appropriate names. Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- include/linux/Kbuild | 1 + include/linux/mdio.h | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/Kbuild b/include/linux/Kbuild index c94e71781b79..4b0b7ed4a999 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -238,6 +238,7 @@ header-y += magic.h header-y += major.h header-y += map_to_7segment.h header-y += matroxfb.h +header-y += mdio.h header-y += media.h header-y += mempolicy.h header-y += meye.h diff --git a/include/linux/mdio.h b/include/linux/mdio.h index b1494aced217..ec90da7232cc 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -273,6 +273,8 @@ static inline __u16 mdio_phy_id_c45(int prtad, int devad) return MDIO_PHY_ID_C45 | (prtad << 5) | devad; } +#ifdef __KERNEL__ + static inline bool mdio_phy_id_is_c45(int phy_id) { return (phy_id & MDIO_PHY_ID_C45) && !(phy_id & ~MDIO_PHY_ID_C45_MASK); @@ -288,11 +290,6 @@ static inline __u16 mdio_phy_id_devad(int phy_id) return phy_id & MDIO_PHY_ID_DEVAD; } -#define MDIO_SUPPORTS_C22 1 -#define MDIO_SUPPORTS_C45 2 - -#ifdef __KERNEL__ - /** * struct mdio_if_info - Ethernet controller MDIO interface * @prtad: PRTAD of the PHY (%MDIO_PRTAD_NONE if not present/unknown) @@ -321,6 +318,8 @@ struct mdio_if_info { #define MDIO_PRTAD_NONE (-1) #define MDIO_DEVAD_NONE (-1) +#define MDIO_SUPPORTS_C22 1 +#define MDIO_SUPPORTS_C45 2 #define MDIO_EMULATE_C22 4 struct ethtool_cmd; -- GitLab From 9c4df53bc3f9c72d7f1f1226927f456d46412381 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 29 Feb 2012 14:26:22 +0000 Subject: [PATCH 1278/1846] ethtool, mdio, mii: Specify MDIO information fields in struct ethtool_cmd Add comments for ethtool_cmd::phy_address and ethtool_cmd::mdio_support, and definitions of the flags currently used in mdio_support. In the mdio library, assert that its own flags continue to match those in the ethtool interface. In the mii library, use the ethtool flag definition and stop including . Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller --- drivers/net/mdio.c | 3 +++ drivers/net/mii.c | 4 ++-- include/linux/ethtool.h | 23 +++++++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/net/mdio.c b/drivers/net/mdio.c index 16fbb11d92ac..8403316eb02b 100644 --- a/drivers/net/mdio.c +++ b/drivers/net/mdio.c @@ -190,6 +190,9 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio, int reg; u32 speed; + BUILD_BUG_ON(MDIO_SUPPORTS_C22 != ETH_MDIO_SUPPORTS_C22); + BUILD_BUG_ON(MDIO_SUPPORTS_C45 != ETH_MDIO_SUPPORTS_C45); + ecmd->transceiver = XCVR_INTERNAL; ecmd->phy_address = mdio->prtad; ecmd->mdio_support = diff --git a/drivers/net/mii.c b/drivers/net/mii.c index c70c2332d15e..4a99c3919037 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include static u32 mii_get_an(struct mii_if_info *mii, u16 addr) { @@ -74,7 +74,7 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) /* this isn't fully supported at higher layers */ ecmd->phy_address = mii->phy_id; - ecmd->mdio_support = MDIO_SUPPORTS_C22; + ecmd->mdio_support = ETH_MDIO_SUPPORTS_C22; ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII; diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index da5b2de99ae4..e1d9e0ede309 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -30,10 +30,15 @@ struct ethtool_cmd { * access it */ __u8 duplex; /* Duplex, half or full */ __u8 port; /* Which connector port */ - __u8 phy_address; + __u8 phy_address; /* MDIO PHY address (PRTAD for clause 45). + * May be read-only or read-write + * depending on the driver. + */ __u8 transceiver; /* Which transceiver to use */ __u8 autoneg; /* Enable or disable autonegotiation */ - __u8 mdio_support; + __u8 mdio_support; /* MDIO protocols supported. Read-only. + * Not set by all drivers. + */ __u32 maxtxpkt; /* Tx pkts before generating tx int */ __u32 maxrxpkt; /* Rx pkts before generating rx int */ __u16 speed_hi; /* The forced speed (upper @@ -59,6 +64,20 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) return (ep->speed_hi << 16) | ep->speed; } +/* Device supports clause 22 register access to PHY or peripherals + * using the interface defined in . This should not be + * set if there are known to be no such peripherals present or if + * the driver only emulates clause 22 registers for compatibility. + */ +#define ETH_MDIO_SUPPORTS_C22 1 + +/* Device supports clause 45 register access to PHY or peripherals + * using the interface defined in and . + * This should not be set if there are known to be no such peripherals + * present. + */ +#define ETH_MDIO_SUPPORTS_C45 2 + #define ETHTOOL_FWVERS_LEN 32 #define ETHTOOL_BUSINFO_LEN 32 /* these strings are set to whatever the driver author decides... */ -- GitLab From bdb6d97154b7b7e98867e9b71bae0f47ec70b1d7 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 06:13:32 +0200 Subject: [PATCH 1279/1846] Bluetooth: mgmt: Refactor hci_dev lookup for commands Almost all mgmt commands need to lookup a struct hci_dev based on the index received within the mgmt headers. It makese therefore sense to look this up in a single place and then just pass the hdev pointer to each command handler function. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 764 ++++++++++++++++--------------------------- 1 file changed, 274 insertions(+), 490 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 3fcccad75453..cc9fb64def90 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -624,17 +624,11 @@ static void mgmt_init_hdev(struct hci_dev *hdev) } } -static int read_controller_info(struct sock *sk, u16 index) +static int read_controller_info(struct sock *sk, struct hci_dev *hdev) { struct mgmt_rp_read_info rp; - struct hci_dev *hdev; - - BT_DBG("sock %p hci%u", sk, index); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_READ_INFO, - MGMT_STATUS_INVALID_PARAMS); + BT_DBG("sock %p %s", sk, hdev->name); hci_dev_lock(hdev); @@ -658,9 +652,9 @@ static int read_controller_info(struct sock *sk, u16 index) memcpy(rp.short_name, hdev->short_name, sizeof(hdev->short_name)); hci_dev_unlock(hdev); - hci_dev_put(hdev); - return cmd_complete(sk, index, MGMT_OP_READ_INFO, 0, &rp, sizeof(rp)); + return cmd_complete(sk, hdev->id, MGMT_OP_READ_INFO, 0, &rp, + sizeof(rp)); } static void mgmt_pending_free(struct pending_cmd *cmd) @@ -744,22 +738,17 @@ static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev) sizeof(settings)); } -static int set_powered(struct sock *sk, u16 index, void *data, u16 len) +static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_mode *cp = data; - struct hci_dev *hdev; struct pending_cmd *cmd; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_POWERED, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_POWERED, + return cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -780,7 +769,7 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len) } if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_POWERED, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, MGMT_STATUS_BUSY); goto failed; } @@ -800,7 +789,6 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); return err; } @@ -843,48 +831,43 @@ static int new_settings(struct hci_dev *hdev, struct sock *skip) return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip); } -static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) +static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_set_discoverable *cp = data; - struct hci_dev *hdev; struct pending_cmd *cmd; u16 timeout; u8 scan; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_INVALID_PARAMS); timeout = get_unaligned_le16(&cp->timeout); if (!cp->val && timeout > 0) - return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev) && timeout > 0) { - err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_NOT_POWERED); goto failed; } if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_BUSY); goto failed; } if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) { - err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, MGMT_STATUS_REJECTED); goto failed; } @@ -945,28 +928,21 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) +static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_mode *cp = data; - struct hci_dev *hdev; struct pending_cmd *cmd; u8 scan; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -996,7 +972,7 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, MGMT_STATUS_BUSY); goto failed; } @@ -1028,26 +1004,19 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_pairable(struct sock *sk, u16 index, void *data, u16 len) +static int set_pairable(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_mode *cp = data; - struct hci_dev *hdev; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_PAIRABLE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_PAIRABLE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_PAIRABLE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -1065,28 +1034,21 @@ static int set_pairable(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) +static int set_link_security(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { struct mgmt_mode *cp = data; struct pending_cmd *cmd; - struct hci_dev *hdev; u8 val; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, + return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -1111,7 +1073,7 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) } if (mgmt_pending_find(MGMT_OP_SET_LINK_SECURITY, hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_LINK_SECURITY, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, MGMT_STATUS_BUSY); goto failed; } @@ -1137,34 +1099,26 @@ static int set_link_security(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) +static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_mode *cp = data; struct pending_cmd *cmd; - struct hci_dev *hdev; u8 val; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_SSP, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_SSP, + return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { - err = cmd_status(sk, index, MGMT_OP_SET_SSP, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, MGMT_STATUS_NOT_SUPPORTED); goto failed; } @@ -1190,7 +1144,8 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) } if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_BUSY); + err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, + MGMT_STATUS_BUSY); goto failed; } @@ -1213,70 +1168,49 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_hs(struct sock *sk, u16 index, void *data, u16 len) +static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_mode *cp = data; - struct hci_dev *hdev; - int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_HS, + return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, MGMT_STATUS_INVALID_PARAMS); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_HS, - MGMT_STATUS_INVALID_PARAMS); - - if (!enable_hs) { - err = cmd_status(sk, index, MGMT_OP_SET_HS, - MGMT_STATUS_NOT_SUPPORTED); - goto failed; - } + if (!enable_hs) + return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, + MGMT_STATUS_NOT_SUPPORTED); if (cp->val) set_bit(HCI_HS_ENABLED, &hdev->dev_flags); else clear_bit(HCI_HS_ENABLED, &hdev->dev_flags); - err = send_settings_rsp(sk, MGMT_OP_SET_HS, hdev); - -failed: - hci_dev_put(hdev); - return err; + return send_settings_rsp(sk, MGMT_OP_SET_HS, hdev); } -static int set_le(struct sock *sk, u16 index, void *data, u16 len) +static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_mode *cp = data; struct hci_cp_write_le_host_supported hci_cp; struct pending_cmd *cmd; - struct hci_dev *hdev; int err; u8 val, enabled; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_LE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_LE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_LE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!enable_le || !(hdev->features[4] & LMP_LE)) { - err = cmd_status(sk, index, MGMT_OP_SET_LE, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, MGMT_STATUS_NOT_SUPPORTED); goto unlock; } @@ -1303,7 +1237,8 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) } if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { - err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY); + err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, + MGMT_STATUS_BUSY); goto unlock; } @@ -1329,33 +1264,26 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); return err; } -static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) +static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_cp_add_uuid *cp = data; struct pending_cmd *cmd; - struct hci_dev *hdev; struct bt_uuid *uuid; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_ADD_UUID, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_ADD_UUID, + return cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { - err = cmd_status(sk, index, MGMT_OP_ADD_UUID, + err = cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID, MGMT_STATUS_BUSY); goto failed; } @@ -1380,7 +1308,7 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) goto failed; if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { - err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_UUID, 0, hdev->dev_class, 3); goto failed; } @@ -1393,8 +1321,6 @@ static int add_uuid(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } @@ -1412,30 +1338,25 @@ static bool enable_service_cache(struct hci_dev *hdev) return false; } -static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) +static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_remove_uuid *cp = data; struct pending_cmd *cmd; struct list_head *p, *n; - struct hci_dev *hdev; u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int err, found; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_REMOVE_UUID, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_REMOVE_UUID, + return cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { - err = cmd_status(sk, index, MGMT_OP_REMOVE_UUID, + err = cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, MGMT_STATUS_BUSY); goto unlock; } @@ -1444,8 +1365,8 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) err = hci_uuids_clear(hdev); if (enable_service_cache(hdev)) { - err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, - hdev->dev_class, 3); + err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_UUID, + 0, hdev->dev_class, 3); goto unlock; } @@ -1465,7 +1386,7 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) } if (found == 0) { - err = cmd_status(sk, index, MGMT_OP_REMOVE_UUID, + err = cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, MGMT_STATUS_INVALID_PARAMS); goto unlock; } @@ -1480,7 +1401,7 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) goto unlock; if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { - err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_UUID, 0, hdev->dev_class, 3); goto unlock; } @@ -1493,33 +1414,26 @@ static int remove_uuid(struct sock *sk, u16 index, void *data, u16 len) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) +static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_set_dev_class *cp = data; struct pending_cmd *cmd; int err; - BT_DBG("request for hci%u", index); + BT_DBG("request for %s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, + return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { - err = cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, + err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, MGMT_STATUS_BUSY); goto unlock; } @@ -1528,7 +1442,7 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) hdev->minor_class = cp->minor; if (!hdev_is_powered(hdev)) { - err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 0, hdev->dev_class, 3); goto unlock; } @@ -1545,7 +1459,7 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) goto unlock; if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { - err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 0, hdev->dev_class, 3); goto unlock; } @@ -1558,20 +1472,18 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) +static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_load_link_keys *cp = data; u16 key_count, expected_len; int i; if (len < sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, + return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, MGMT_STATUS_INVALID_PARAMS); key_count = get_unaligned_le16(&cp->key_count); @@ -1581,16 +1493,11 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) if (expected_len != len) { BT_ERR("load_link_keys: expected %u bytes, got %u bytes", len, expected_len); - return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, + return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, MGMT_STATUS_INVALID_PARAMS); } - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, - MGMT_STATUS_INVALID_PARAMS); - - BT_DBG("hci%u debug_keys %u key_count %u", index, cp->debug_keys, + BT_DBG("%s debug_keys %u key_count %u", hdev->name, cp->debug_keys, key_count); hci_dev_lock(hdev); @@ -1611,10 +1518,9 @@ static int load_link_keys(struct sock *sk, u16 index, void *data, u16 len) key->type, key->pin_len); } - cmd_complete(sk, index, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0); + cmd_complete(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0); hci_dev_unlock(hdev); - hci_dev_put(hdev); return 0; } @@ -1631,9 +1537,9 @@ static int device_unpaired(struct hci_dev *hdev, bdaddr_t *bdaddr, skip_sk); } -static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) +static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_unpair_device *cp = data; struct mgmt_rp_unpair_device rp; struct hci_cp_disconnect dc; @@ -1642,12 +1548,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) int err; if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_UNPAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_UNPAIR_DEVICE, + return cmd_status(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -1657,7 +1558,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) rp.addr.type = cp->addr.type; if (!hdev_is_powered(hdev)) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, + err = cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, MGMT_STATUS_NOT_POWERED, &rp, sizeof(rp)); goto unlock; @@ -1669,7 +1570,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) err = hci_remove_ltk(hdev, &cp->addr.bdaddr); if (err < 0) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, + err = cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, MGMT_STATUS_NOT_PAIRED, &rp, sizeof(rp)); goto unlock; @@ -1687,7 +1588,7 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) } if (!conn) { - err = cmd_complete(sk, index, MGMT_OP_UNPAIR_DEVICE, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, 0, &rp, sizeof(rp)); device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; @@ -1708,14 +1609,12 @@ static int unpair_device(struct sock *sk, u16 index, void *data, u16 len) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int disconnect(struct sock *sk, u16 index, void *data, u16 len) +static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_disconnect *cp = data; struct hci_cp_disconnect dc; struct pending_cmd *cmd; @@ -1725,24 +1624,19 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len) BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_DISCONNECT, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_DISCONNECT, + return cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!test_bit(HCI_UP, &hdev->flags)) { - err = cmd_status(sk, index, MGMT_OP_DISCONNECT, + err = cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, MGMT_STATUS_NOT_POWERED); goto failed; } if (mgmt_pending_find(MGMT_OP_DISCONNECT, hdev)) { - err = cmd_status(sk, index, MGMT_OP_DISCONNECT, + err = cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, MGMT_STATUS_BUSY); goto failed; } @@ -1753,7 +1647,7 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len) conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr); if (!conn) { - err = cmd_status(sk, index, MGMT_OP_DISCONNECT, + err = cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, MGMT_STATUS_NOT_CONNECTED); goto failed; } @@ -1773,8 +1667,6 @@ static int disconnect(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } @@ -1797,10 +1689,9 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type) } } -static int get_connections(struct sock *sk, u16 index) +static int get_connections(struct sock *sk, struct hci_dev *hdev) { struct mgmt_rp_get_connections *rp; - struct hci_dev *hdev; struct hci_conn *c; size_t rp_len; int err; @@ -1808,15 +1699,10 @@ static int get_connections(struct sock *sk, u16 index) BT_DBG(""); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_GET_CONNECTIONS, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_GET_CONNECTIONS, + err = cmd_status(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, MGMT_STATUS_NOT_POWERED); goto unlock; } @@ -1850,18 +1736,18 @@ static int get_connections(struct sock *sk, u16 index) /* Recalculate length in case of filtered SCO connections, etc */ rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); - err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, 0, rp, rp_len); + err = cmd_complete(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, 0, rp, + rp_len); kfree(rp); unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); return err; } -static int send_pin_code_neg_reply(struct sock *sk, u16 index, - struct hci_dev *hdev, struct mgmt_cp_pin_code_neg_reply *cp) +static int send_pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, + struct mgmt_cp_pin_code_neg_reply *cp) { struct pending_cmd *cmd; int err; @@ -1879,9 +1765,9 @@ static int send_pin_code_neg_reply(struct sock *sk, u16 index, return err; } -static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) +static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct hci_conn *conn; struct mgmt_cp_pin_code_reply *cp = data; struct hci_cp_pin_code_reply reply; @@ -1891,25 +1777,20 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, + return cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, + err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_NOT_POWERED); goto failed; } conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); if (!conn) { - err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, + err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_NOT_CONNECTED); goto failed; } @@ -1921,9 +1802,9 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) BT_ERR("PIN code is not 16 bytes long"); - err = send_pin_code_neg_reply(sk, index, hdev, &ncp); + err = send_pin_code_neg_reply(sk, hdev, &ncp); if (err >= 0) - err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, + err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, MGMT_STATUS_INVALID_PARAMS); goto failed; @@ -1945,59 +1826,45 @@ static int pin_code_reply(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int pin_code_neg_reply(struct sock *sk, u16 index, void *data, u16 len) +static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { - struct hci_dev *hdev; struct mgmt_cp_pin_code_neg_reply *cp = data; int err; BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, + return cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, + err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, MGMT_STATUS_NOT_POWERED); goto failed; } - err = send_pin_code_neg_reply(sk, index, hdev, cp); + err = send_pin_code_neg_reply(sk, hdev, cp); failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int set_io_capability(struct sock *sk, u16 index, void *data, u16 len) +static int set_io_capability(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { - struct hci_dev *hdev; struct mgmt_cp_set_io_capability *cp = data; BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_IO_CAPABILITY, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_IO_CAPABILITY, + return cmd_status(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -2008,9 +1875,9 @@ static int set_io_capability(struct sock *sk, u16 index, void *data, u16 len) hdev->io_capability); hci_dev_unlock(hdev); - hci_dev_put(hdev); - return cmd_complete(sk, index, MGMT_OP_SET_IO_CAPABILITY, 0, NULL, 0); + return cmd_complete(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, 0, + NULL, 0); } static inline struct pending_cmd *find_pairing(struct hci_conn *conn) @@ -2065,9 +1932,9 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status) pairing_complete(cmd, mgmt_status(status)); } -static int pair_device(struct sock *sk, u16 index, void *data, u16 len) +static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_pair_device *cp = data; struct mgmt_rp_pair_device rp; struct pending_cmd *cmd; @@ -2078,18 +1945,13 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, + return cmd_status(sk, hdev->id, MGMT_OP_PAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, + err = cmd_status(sk, hdev->id, MGMT_OP_PAIR_DEVICE, MGMT_STATUS_NOT_POWERED); goto unlock; } @@ -2112,7 +1974,7 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) rp.addr.type = cp->addr.type; if (IS_ERR(conn)) { - err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, + err = cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, MGMT_STATUS_CONNECT_FAILED, &rp, sizeof(rp)); goto unlock; @@ -2120,7 +1982,7 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) if (conn->connect_cfm_cb) { hci_conn_put(conn); - err = cmd_complete(sk, index, MGMT_OP_PAIR_DEVICE, + err = cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, MGMT_STATUS_BUSY, &rp, sizeof(rp)); goto unlock; } @@ -2149,16 +2011,13 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int cancel_pair_device(struct sock *sk, u16 index, +static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, unsigned char *data, u16 len) { struct mgmt_addr_info *addr = (void *) data; - struct hci_dev *hdev; struct pending_cmd *cmd; struct hci_conn *conn; int err; @@ -2166,25 +2025,20 @@ static int cancel_pair_device(struct sock *sk, u16 index, BT_DBG(""); if (len != sizeof(*addr)) - return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + return cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, MGMT_STATUS_NOT_POWERED); goto unlock; } cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev); if (!cmd) { - err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); goto unlock; } @@ -2192,40 +2046,33 @@ static int cancel_pair_device(struct sock *sk, u16 index, conn = cmd->user_data; if (bacmp(&addr->bdaddr, &conn->dst) != 0) { - err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, + err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, MGMT_STATUS_INVALID_PARAMS); goto unlock; } pairing_complete(cmd, MGMT_STATUS_CANCELLED); - err = cmd_complete(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, 0, addr, - sizeof(*addr)); + err = cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, + addr, sizeof(*addr)); unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, - u8 type, u16 mgmt_op, u16 hci_op, - __le32 passkey) +static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, + bdaddr_t *bdaddr, u8 type, u16 mgmt_op, + u16 hci_op, __le32 passkey) { struct pending_cmd *cmd; - struct hci_dev *hdev; struct hci_conn *conn; int err; - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, mgmt_op, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, mgmt_op, MGMT_STATUS_NOT_POWERED); + err = cmd_status(sk, hdev->id, mgmt_op, + MGMT_STATUS_NOT_POWERED); goto done; } @@ -2235,7 +2082,7 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); if (!conn) { - err = cmd_status(sk, index, mgmt_op, + err = cmd_status(sk, hdev->id, mgmt_op, MGMT_STATUS_NOT_CONNECTED); goto done; } @@ -2245,10 +2092,10 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, err = smp_user_confirm_reply(conn, mgmt_op, passkey); if (!err) - err = cmd_status(sk, index, mgmt_op, + err = cmd_status(sk, hdev->id, mgmt_op, MGMT_STATUS_SUCCESS); else - err = cmd_status(sk, index, mgmt_op, + err = cmd_status(sk, hdev->id, mgmt_op, MGMT_STATUS_FAILED); goto done; @@ -2275,92 +2122,86 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, done: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len) +static int user_confirm_reply(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { struct mgmt_cp_user_confirm_reply *cp = data; BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_REPLY, + return cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_REPLY, MGMT_STATUS_INVALID_PARAMS); - return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_CONFIRM_REPLY, HCI_OP_USER_CONFIRM_REPLY, 0); } -static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data, - u16 len) +static int user_confirm_neg_reply(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { struct mgmt_cp_user_confirm_neg_reply *cp = data; BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_NEG_REPLY, + return cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_NEG_REPLY, MGMT_STATUS_INVALID_PARAMS); - return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_CONFIRM_NEG_REPLY, HCI_OP_USER_CONFIRM_NEG_REPLY, 0); } -static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) +static int user_passkey_reply(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { struct mgmt_cp_user_passkey_reply *cp = data; BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_REPLY, + return cmd_status(sk, hdev->id, MGMT_OP_USER_PASSKEY_REPLY, EINVAL); - return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_PASSKEY_REPLY, HCI_OP_USER_PASSKEY_REPLY, cp->passkey); } -static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, - u16 len) +static int user_passkey_neg_reply(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { struct mgmt_cp_user_passkey_neg_reply *cp = data; BT_DBG(""); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_NEG_REPLY, - EINVAL); + return cmd_status(sk, hdev->id, MGMT_OP_USER_PASSKEY_NEG_REPLY, + EINVAL); - return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type, + return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_PASSKEY_NEG_REPLY, HCI_OP_USER_PASSKEY_NEG_REPLY, 0); } -static int set_local_name(struct sock *sk, u16 index, void *data, +static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_cp_set_local_name *mgmt_cp = data; struct hci_cp_write_local_name hci_cp; - struct hci_dev *hdev; struct pending_cmd *cmd; int err; BT_DBG(""); if (len != sizeof(*mgmt_cp)) - return cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, + return cmd_status(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); @@ -2396,40 +2237,32 @@ static int set_local_name(struct sock *sk, u16 index, void *data, failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int read_local_oob_data(struct sock *sk, u16 index) +static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev) { - struct hci_dev *hdev; struct pending_cmd *cmd; int err; - BT_DBG("hci%u", index); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS); + BT_DBG("%s", hdev->name); hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, + err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, MGMT_STATUS_NOT_POWERED); goto unlock; } if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { - err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, + err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, MGMT_STATUS_NOT_SUPPORTED); goto unlock; } if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev)) { - err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, + err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, MGMT_STATUS_BUSY); goto unlock; } @@ -2446,35 +2279,26 @@ static int read_local_oob_data(struct sock *sk, u16 index) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int add_remote_oob_data(struct sock *sk, u16 index, void *data, - u16 len) +static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { - struct hci_dev *hdev; struct mgmt_cp_add_remote_oob_data *cp = data; u8 status; int err; - BT_DBG("hci%u ", index); + BT_DBG("%s ", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, + return cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, MGMT_STATUS_INVALID_PARAMS); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS, - &cp->addr, sizeof(cp->addr)); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, + err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, MGMT_STATUS_NOT_POWERED, &cp->addr, sizeof(cp->addr)); goto unlock; @@ -2487,42 +2311,34 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, else status = 0; - err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, status, + err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, status, &cp->addr, sizeof(cp->addr)); unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int remove_remote_oob_data(struct sock *sk, u16 index, +static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { - struct hci_dev *hdev; struct mgmt_cp_remove_remote_oob_data *cp = data; u8 status; int err; - BT_DBG("hci%u ", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, + return cmd_status(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA, MGMT_STATUS_INVALID_PARAMS); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS, - &cp->addr, sizeof(cp->addr)); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - MGMT_STATUS_NOT_POWERED, - &cp->addr, sizeof(cp->addr)); + err = cmd_complete(sk, hdev->id, + MGMT_OP_REMOVE_REMOTE_OOB_DATA, + MGMT_STATUS_NOT_POWERED, + &cp->addr, sizeof(cp->addr)); goto unlock; } @@ -2532,13 +2348,11 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, else status = 0; - err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, status, - &cp->addr, sizeof(cp->addr)); + err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA, + status, &cp->addr, sizeof(cp->addr)); unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } @@ -2559,36 +2373,30 @@ int mgmt_interleaved_discovery(struct hci_dev *hdev) return err; } -static int start_discovery(struct sock *sk, u16 index, +static int start_discovery(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_cp_start_discovery *cp = data; struct pending_cmd *cmd; - struct hci_dev *hdev; int err; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_START_DISCOVERY, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_START_DISCOVERY, + return cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { - err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, + err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, MGMT_STATUS_NOT_POWERED); goto failed; } if (hdev->discovery.state != DISCOVERY_STOPPED) { - err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, - MGMT_STATUS_BUSY); + err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, + MGMT_STATUS_BUSY); goto failed; } @@ -2635,42 +2443,35 @@ static int start_discovery(struct sock *sk, u16 index, failed: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int stop_discovery(struct sock *sk, u16 index, void *data, u16 len) +static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_stop_discovery *mgmt_cp = data; - struct hci_dev *hdev; struct pending_cmd *cmd; struct hci_cp_remote_name_req_cancel cp; struct inquiry_entry *e; int err; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*mgmt_cp)) - return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, + return cmd_status(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hci_discovery_active(hdev)) { - err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, + err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, MGMT_STATUS_REJECTED, &mgmt_cp->type, sizeof(mgmt_cp->type)); goto unlock; } if (hdev->discovery.type != mgmt_cp->type) { - err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, + err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, MGMT_STATUS_INVALID_PARAMS, &mgmt_cp->type, sizeof(mgmt_cp->type)); goto unlock; @@ -2694,7 +2495,7 @@ static int stop_discovery(struct sock *sk, u16 index, void *data, u16 len) e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_PENDING); if (!e) { mgmt_pending_remove(cmd); - err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, 0, &mgmt_cp->type, sizeof(mgmt_cp->type)); hci_discovery_set_state(hdev, DISCOVERY_STOPPED); goto unlock; @@ -2710,41 +2511,34 @@ static int stop_discovery(struct sock *sk, u16 index, void *data, u16 len) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int confirm_name(struct sock *sk, u16 index, void *data, u16 len) +static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_confirm_name *cp = data; struct inquiry_entry *e; - struct hci_dev *hdev; int err; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, - MGMT_STATUS_INVALID_PARAMS); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, - MGMT_STATUS_INVALID_PARAMS); + return cmd_status(sk, hdev->id, MGMT_OP_CONFIRM_NAME, + MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hci_discovery_active(hdev)) { - err = cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, + err = cmd_status(sk, hdev->id, MGMT_OP_CONFIRM_NAME, MGMT_STATUS_FAILED); goto failed; } e = hci_inquiry_cache_lookup_unknown(hdev, &cp->addr.bdaddr); if (!e) { - err = cmd_status(sk, index, MGMT_OP_CONFIRM_NAME, - MGMT_STATUS_INVALID_PARAMS); + err = cmd_status(sk, hdev->id, MGMT_OP_CONFIRM_NAME, + MGMT_STATUS_INVALID_PARAMS); goto failed; } @@ -2760,29 +2554,22 @@ static int confirm_name(struct sock *sk, u16 index, void *data, u16 len) failed: hci_dev_unlock(hdev); - return err; } -static int block_device(struct sock *sk, u16 index, void *data, u16 len) +static int block_device(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_block_device *cp = data; u8 status; int err; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, + return cmd_status(sk, hdev->id, MGMT_OP_BLOCK_DEVICE, MGMT_STATUS_INVALID_PARAMS); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS, - &cp->addr, sizeof(cp->addr)); - hci_dev_lock(hdev); err = hci_blacklist_add(hdev, &cp->addr.bdaddr, cp->addr.type); @@ -2791,34 +2578,27 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) else status = 0; - err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, status, + err = cmd_complete(sk, hdev->id, MGMT_OP_BLOCK_DEVICE, status, &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); - hci_dev_put(hdev); return err; } -static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) +static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { - struct hci_dev *hdev; struct mgmt_cp_unblock_device *cp = data; u8 status; int err; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, + return cmd_status(sk, hdev->id, MGMT_OP_UNBLOCK_DEVICE, MGMT_STATUS_INVALID_PARAMS); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS, - &cp->addr, sizeof(cp->addr)); - hci_dev_lock(hdev); err = hci_blacklist_del(hdev, &cp->addr.bdaddr, cp->addr.type); @@ -2827,41 +2607,35 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) else status = 0; - err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, status, + err = cmd_complete(sk, hdev->id, MGMT_OP_UNBLOCK_DEVICE, status, &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); - hci_dev_put(hdev); return err; } -static int set_fast_connectable(struct sock *sk, u16 index, - void *data, u16 len) +static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, + void *data, u16 len) { - struct hci_dev *hdev; struct mgmt_mode *cp = data; struct hci_cp_write_page_scan_activity acp; u8 type; int err; - BT_DBG("hci%u", index); + BT_DBG("%s", hdev->name); if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, MGMT_STATUS_INVALID_PARAMS); - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_INVALID_PARAMS); if (!hdev_is_powered(hdev)) - return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, + return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, MGMT_STATUS_NOT_POWERED); if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) - return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_REJECTED); + return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, + MGMT_STATUS_REJECTED); hci_dev_lock(hdev); @@ -2878,37 +2652,34 @@ static int set_fast_connectable(struct sock *sk, u16 index, err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp), &acp); if (err < 0) { - err = cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_FAILED); + err = cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, + MGMT_STATUS_FAILED); goto done; } err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); if (err < 0) { - err = cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_FAILED); + err = cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, + MGMT_STATUS_FAILED); goto done; } - err = cmd_complete(sk, index, MGMT_OP_SET_FAST_CONNECTABLE, 0, + err = cmd_complete(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, 0, NULL, 0); done: hci_dev_unlock(hdev); - hci_dev_put(hdev); - return err; } -static int load_long_term_keys(struct sock *sk, u16 index, +static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, void *cp_data, u16 len) { - struct hci_dev *hdev; struct mgmt_cp_load_long_term_keys *cp = cp_data; u16 key_count, expected_len; int i; if (len < sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_LOAD_LONG_TERM_KEYS, + return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, EINVAL); key_count = get_unaligned_le16(&cp->key_count); @@ -2918,16 +2689,11 @@ static int load_long_term_keys(struct sock *sk, u16 index, if (expected_len != len) { BT_ERR("load_keys: expected %u bytes, got %u bytes", len, expected_len); - return cmd_status(sk, index, MGMT_OP_LOAD_LONG_TERM_KEYS, + return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, EINVAL); } - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_LOAD_LONG_TERM_KEYS, - ENODEV); - - BT_DBG("hci%u key_count %u", index, key_count); + BT_DBG("%s key_count %u", hdev->name, key_count); hci_dev_lock(hdev); @@ -2948,7 +2714,6 @@ static int load_long_term_keys(struct sock *sk, u16 index, } hci_dev_unlock(hdev); - hci_dev_put(hdev); return 0; } @@ -2959,6 +2724,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) u8 *cp; struct mgmt_hdr *hdr; u16 opcode, index, len; + struct hci_dev *hdev = NULL; int err; BT_DBG("got %zu bytes", msglen); @@ -2985,6 +2751,21 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) goto done; } + if (opcode < MGMT_OP_READ_INFO) { + if (index != MGMT_INDEX_NONE) { + err = cmd_status(sk, index, opcode, + MGMT_STATUS_INVALID_PARAMS); + goto done; + } + } else { + hdev = hci_dev_get(index); + if (!hdev) { + err = cmd_status(sk, index, opcode, + MGMT_STATUS_INVALID_PARAMS); + goto done; + } + } + cp = buf + sizeof(*hdr); switch (opcode) { @@ -2998,112 +2779,112 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) err = read_index_list(sk); break; case MGMT_OP_READ_INFO: - err = read_controller_info(sk, index); + err = read_controller_info(sk, hdev); break; case MGMT_OP_SET_POWERED: - err = set_powered(sk, index, cp, len); + err = set_powered(sk, hdev, cp, len); break; case MGMT_OP_SET_DISCOVERABLE: - err = set_discoverable(sk, index, cp, len); + err = set_discoverable(sk, hdev, cp, len); break; case MGMT_OP_SET_CONNECTABLE: - err = set_connectable(sk, index, cp, len); + err = set_connectable(sk, hdev, cp, len); break; case MGMT_OP_SET_FAST_CONNECTABLE: - err = set_fast_connectable(sk, index, cp, len); + err = set_fast_connectable(sk, hdev, cp, len); break; case MGMT_OP_SET_PAIRABLE: - err = set_pairable(sk, index, cp, len); + err = set_pairable(sk, hdev, cp, len); break; case MGMT_OP_SET_LINK_SECURITY: - err = set_link_security(sk, index, cp, len); + err = set_link_security(sk, hdev, cp, len); break; case MGMT_OP_SET_SSP: - err = set_ssp(sk, index, cp, len); + err = set_ssp(sk, hdev, cp, len); break; case MGMT_OP_SET_HS: - err = set_hs(sk, index, cp, len); + err = set_hs(sk, hdev, cp, len); break; case MGMT_OP_SET_LE: - err = set_le(sk, index, cp, len); + err = set_le(sk, hdev, cp, len); break; case MGMT_OP_ADD_UUID: - err = add_uuid(sk, index, cp, len); + err = add_uuid(sk, hdev, cp, len); break; case MGMT_OP_REMOVE_UUID: - err = remove_uuid(sk, index, cp, len); + err = remove_uuid(sk, hdev, cp, len); break; case MGMT_OP_SET_DEV_CLASS: - err = set_dev_class(sk, index, cp, len); + err = set_dev_class(sk, hdev, cp, len); break; case MGMT_OP_LOAD_LINK_KEYS: - err = load_link_keys(sk, index, cp, len); + err = load_link_keys(sk, hdev, cp, len); break; case MGMT_OP_DISCONNECT: - err = disconnect(sk, index, cp, len); + err = disconnect(sk, hdev, cp, len); break; case MGMT_OP_GET_CONNECTIONS: - err = get_connections(sk, index); + err = get_connections(sk, hdev); break; case MGMT_OP_PIN_CODE_REPLY: - err = pin_code_reply(sk, index, cp, len); + err = pin_code_reply(sk, hdev, cp, len); break; case MGMT_OP_PIN_CODE_NEG_REPLY: - err = pin_code_neg_reply(sk, index, cp, len); + err = pin_code_neg_reply(sk, hdev, cp, len); break; case MGMT_OP_SET_IO_CAPABILITY: - err = set_io_capability(sk, index, cp, len); + err = set_io_capability(sk, hdev, cp, len); break; case MGMT_OP_PAIR_DEVICE: - err = pair_device(sk, index, cp, len); + err = pair_device(sk, hdev, cp, len); break; case MGMT_OP_CANCEL_PAIR_DEVICE: - err = cancel_pair_device(sk, index, buf + sizeof(*hdr), len); + err = cancel_pair_device(sk, hdev, buf + sizeof(*hdr), len); break; case MGMT_OP_UNPAIR_DEVICE: - err = unpair_device(sk, index, cp, len); + err = unpair_device(sk, hdev, cp, len); break; case MGMT_OP_USER_CONFIRM_REPLY: - err = user_confirm_reply(sk, index, cp, len); + err = user_confirm_reply(sk, hdev, cp, len); break; case MGMT_OP_USER_CONFIRM_NEG_REPLY: - err = user_confirm_neg_reply(sk, index, cp, len); + err = user_confirm_neg_reply(sk, hdev, cp, len); break; case MGMT_OP_USER_PASSKEY_REPLY: - err = user_passkey_reply(sk, index, cp, len); + err = user_passkey_reply(sk, hdev, cp, len); break; case MGMT_OP_USER_PASSKEY_NEG_REPLY: - err = user_passkey_neg_reply(sk, index, cp, len); + err = user_passkey_neg_reply(sk, hdev, cp, len); break; case MGMT_OP_SET_LOCAL_NAME: - err = set_local_name(sk, index, cp, len); + err = set_local_name(sk, hdev, cp, len); break; case MGMT_OP_READ_LOCAL_OOB_DATA: - err = read_local_oob_data(sk, index); + err = read_local_oob_data(sk, hdev); break; case MGMT_OP_ADD_REMOTE_OOB_DATA: - err = add_remote_oob_data(sk, index, cp, len); + err = add_remote_oob_data(sk, hdev, cp, len); break; case MGMT_OP_REMOVE_REMOTE_OOB_DATA: - err = remove_remote_oob_data(sk, index, cp, len); + err = remove_remote_oob_data(sk, hdev, cp, len); break; case MGMT_OP_START_DISCOVERY: - err = start_discovery(sk, index, cp, len); + err = start_discovery(sk, hdev, cp, len); break; case MGMT_OP_STOP_DISCOVERY: - err = stop_discovery(sk, index, cp, len); + err = stop_discovery(sk, hdev, cp, len); break; case MGMT_OP_CONFIRM_NAME: - err = confirm_name(sk, index, cp, len); + err = confirm_name(sk, hdev, cp, len); break; case MGMT_OP_BLOCK_DEVICE: - err = block_device(sk, index, cp, len); + err = block_device(sk, hdev, cp, len); break; case MGMT_OP_UNBLOCK_DEVICE: - err = unblock_device(sk, index, cp, len); + err = unblock_device(sk, hdev, cp, len); break; case MGMT_OP_LOAD_LONG_TERM_KEYS: - err = load_long_term_keys(sk, index, cp, len); + err = load_long_term_keys(sk, hdev, cp, len); break; default: BT_DBG("Unknown op %u", opcode); @@ -3118,6 +2899,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) err = msglen; done: + if (hdev) + hci_dev_put(hdev); + kfree(buf); return err; } -- GitLab From 6a919082e9b82a0de20f1248a33f3b3f005cebaf Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 06:17:26 +0200 Subject: [PATCH 1280/1846] Bluetooth: mgmt: Initialize HCI_MGMT flag for any command The read_controller_info is typically the first command that user space sends when taking a controller into use. This is also the reason why this command has been used as the trigger to set the HCI_MGMT flag. However, when not running the user-space daemon and using command line tools it is possible that read_controller_info is not the first controller specific command. This patch moves the HCI_MGMT initialization to a generic place where it will be set for whatever happens to be the first mgmt command targetting a specific controller. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cc9fb64def90..cf8c8403571e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -610,8 +610,11 @@ static void service_cache_off(struct work_struct *work) hci_dev_unlock(hdev); } -static void mgmt_init_hdev(struct hci_dev *hdev) +static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) { + if (!test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) + return; + if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) { INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); @@ -632,9 +635,6 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev) hci_dev_lock(hdev); - if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) - mgmt_init_hdev(hdev); - memset(&rp, 0, sizeof(rp)); bacpy(&rp.bdaddr, &hdev->bdaddr); @@ -2764,6 +2764,8 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) MGMT_STATUS_INVALID_PARAMS); goto done; } + + mgmt_init_hdev(sk, hdev); } cp = buf + sizeof(*hdr); -- GitLab From 0f4e68cf6e70fc219f219799c799a8a3e3c13100 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Feb 2012 17:18:30 +0200 Subject: [PATCH 1281/1846] Bluetooth: mgmt: Move command handlers into a table By moving the command handlers into a table (the index being equal to the opcode) the lookup is made a bit more efficient. Having a struct to describe each handler also paves the way to add more meta-data for each handler, e.g. the minimum message size for the command and allow handling of common tasks like this in a centralized place. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 219 ++++++++++++++++--------------------------- 1 file changed, 79 insertions(+), 140 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cf8c8403571e..88a342a12593 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -267,7 +267,8 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, return err; } -static int read_version(struct sock *sk) +static int read_version(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) { struct mgmt_rp_read_version rp; @@ -280,7 +281,8 @@ static int read_version(struct sock *sk) sizeof(rp)); } -static int read_commands(struct sock *sk) +static int read_commands(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) { struct mgmt_rp_read_commands *rp; u16 num_commands = ARRAY_SIZE(mgmt_commands); @@ -313,7 +315,8 @@ static int read_commands(struct sock *sk) return err; } -static int read_index_list(struct sock *sk) +static int read_index_list(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) { struct mgmt_rp_read_index_list *rp; struct list_head *p; @@ -627,7 +630,8 @@ static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) } } -static int read_controller_info(struct sock *sk, struct hci_dev *hdev) +static int read_controller_info(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) { struct mgmt_rp_read_info rp; @@ -1689,7 +1693,8 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type) } } -static int get_connections(struct sock *sk, struct hci_dev *hdev) +static int get_connections(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) { struct mgmt_rp_get_connections *rp; struct hci_conn *c; @@ -2015,9 +2020,9 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, } static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, - unsigned char *data, u16 len) + void *data, u16 len) { - struct mgmt_addr_info *addr = (void *) data; + struct mgmt_addr_info *addr = data; struct pending_cmd *cmd; struct hci_conn *conn; int err; @@ -2240,7 +2245,8 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, return err; } -static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev) +static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len) { struct pending_cmd *cmd; int err; @@ -2718,6 +2724,53 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, return 0; } +struct mgmt_handler { + int (*func) (struct sock *sk, struct hci_dev *hdev, + void *data, u16 data_len); +} mgmt_handlers[] = { + { NULL }, /* 0x0000 (no command) */ + { read_version, }, + { read_commands, }, + { read_index_list, }, + { read_controller_info, }, + { set_powered, }, + { set_discoverable, }, + { set_connectable, }, + { set_fast_connectable, }, + { set_pairable, }, + { set_link_security, }, + { set_ssp, }, + { set_hs, }, + { set_le, }, + { set_dev_class, }, + { set_local_name, }, + { add_uuid, }, + { remove_uuid, }, + { load_link_keys, }, + { load_long_term_keys, }, + { disconnect, }, + { get_connections, }, + { pin_code_reply, }, + { pin_code_neg_reply, }, + { set_io_capability, }, + { pair_device, }, + { cancel_pair_device, }, + { unpair_device, }, + { user_confirm_reply, }, + { user_confirm_neg_reply, }, + { user_passkey_reply, }, + { user_passkey_neg_reply, }, + { read_local_oob_data, }, + { add_remote_oob_data, }, + { remove_remote_oob_data, }, + { start_discovery, }, + { stop_discovery, }, + { confirm_name, }, + { block_device, }, + { unblock_device, }, +}; + + int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) { void *buf; @@ -2751,150 +2804,36 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) goto done; } - if (opcode < MGMT_OP_READ_INFO) { - if (index != MGMT_INDEX_NONE) { - err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_PARAMS); - goto done; - } - } else { + if (index != MGMT_INDEX_NONE) { hdev = hci_dev_get(index); if (!hdev) { err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto done; } - - mgmt_init_hdev(sk, hdev); } - cp = buf + sizeof(*hdr); - - switch (opcode) { - case MGMT_OP_READ_VERSION: - err = read_version(sk); - break; - case MGMT_OP_READ_COMMANDS: - err = read_commands(sk); - break; - case MGMT_OP_READ_INDEX_LIST: - err = read_index_list(sk); - break; - case MGMT_OP_READ_INFO: - err = read_controller_info(sk, hdev); - break; - case MGMT_OP_SET_POWERED: - err = set_powered(sk, hdev, cp, len); - break; - case MGMT_OP_SET_DISCOVERABLE: - err = set_discoverable(sk, hdev, cp, len); - break; - case MGMT_OP_SET_CONNECTABLE: - err = set_connectable(sk, hdev, cp, len); - break; - case MGMT_OP_SET_FAST_CONNECTABLE: - err = set_fast_connectable(sk, hdev, cp, len); - break; - case MGMT_OP_SET_PAIRABLE: - err = set_pairable(sk, hdev, cp, len); - break; - case MGMT_OP_SET_LINK_SECURITY: - err = set_link_security(sk, hdev, cp, len); - break; - case MGMT_OP_SET_SSP: - err = set_ssp(sk, hdev, cp, len); - break; - case MGMT_OP_SET_HS: - err = set_hs(sk, hdev, cp, len); - break; - case MGMT_OP_SET_LE: - err = set_le(sk, hdev, cp, len); - break; - case MGMT_OP_ADD_UUID: - err = add_uuid(sk, hdev, cp, len); - break; - case MGMT_OP_REMOVE_UUID: - err = remove_uuid(sk, hdev, cp, len); - break; - case MGMT_OP_SET_DEV_CLASS: - err = set_dev_class(sk, hdev, cp, len); - break; - case MGMT_OP_LOAD_LINK_KEYS: - err = load_link_keys(sk, hdev, cp, len); - break; - case MGMT_OP_DISCONNECT: - err = disconnect(sk, hdev, cp, len); - break; - case MGMT_OP_GET_CONNECTIONS: - err = get_connections(sk, hdev); - break; - case MGMT_OP_PIN_CODE_REPLY: - err = pin_code_reply(sk, hdev, cp, len); - break; - case MGMT_OP_PIN_CODE_NEG_REPLY: - err = pin_code_neg_reply(sk, hdev, cp, len); - break; - case MGMT_OP_SET_IO_CAPABILITY: - err = set_io_capability(sk, hdev, cp, len); - break; - case MGMT_OP_PAIR_DEVICE: - err = pair_device(sk, hdev, cp, len); - break; - case MGMT_OP_CANCEL_PAIR_DEVICE: - err = cancel_pair_device(sk, hdev, buf + sizeof(*hdr), len); - break; - case MGMT_OP_UNPAIR_DEVICE: - err = unpair_device(sk, hdev, cp, len); - break; - case MGMT_OP_USER_CONFIRM_REPLY: - err = user_confirm_reply(sk, hdev, cp, len); - break; - case MGMT_OP_USER_CONFIRM_NEG_REPLY: - err = user_confirm_neg_reply(sk, hdev, cp, len); - break; - case MGMT_OP_USER_PASSKEY_REPLY: - err = user_passkey_reply(sk, hdev, cp, len); - break; - case MGMT_OP_USER_PASSKEY_NEG_REPLY: - err = user_passkey_neg_reply(sk, hdev, cp, len); - break; - case MGMT_OP_SET_LOCAL_NAME: - err = set_local_name(sk, hdev, cp, len); - break; - case MGMT_OP_READ_LOCAL_OOB_DATA: - err = read_local_oob_data(sk, hdev); - break; - case MGMT_OP_ADD_REMOTE_OOB_DATA: - err = add_remote_oob_data(sk, hdev, cp, len); - break; - case MGMT_OP_REMOVE_REMOTE_OOB_DATA: - err = remove_remote_oob_data(sk, hdev, cp, len); - break; - case MGMT_OP_START_DISCOVERY: - err = start_discovery(sk, hdev, cp, len); - break; - case MGMT_OP_STOP_DISCOVERY: - err = stop_discovery(sk, hdev, cp, len); - break; - case MGMT_OP_CONFIRM_NAME: - err = confirm_name(sk, hdev, cp, len); - break; - case MGMT_OP_BLOCK_DEVICE: - err = block_device(sk, hdev, cp, len); - break; - case MGMT_OP_UNBLOCK_DEVICE: - err = unblock_device(sk, hdev, cp, len); - break; - case MGMT_OP_LOAD_LONG_TERM_KEYS: - err = load_long_term_keys(sk, hdev, cp, len); - break; - default: + if (opcode >= ARRAY_SIZE(mgmt_handlers) || + mgmt_handlers[opcode].func == NULL) { BT_DBG("Unknown op %u", opcode); err = cmd_status(sk, index, opcode, MGMT_STATUS_UNKNOWN_COMMAND); - break; + goto done; + } + + if ((hdev && opcode < MGMT_OP_READ_INFO) || + (!hdev && opcode >= MGMT_OP_READ_INFO)) { + err = cmd_status(sk, index, opcode, + MGMT_STATUS_INVALID_PARAMS); + goto done; } + if (hdev) + mgmt_init_hdev(sk, hdev); + + cp = buf + sizeof(*hdr); + + err = mgmt_handlers[opcode].func(sk, hdev, cp, len); if (err < 0) goto done; -- GitLab From 9d1acbfb774fa5e043a44adedfcc36c9837a5e61 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 1 Mar 2012 22:23:42 +0200 Subject: [PATCH 1282/1846] Bluetooth: mgmt: Add defines for command sizes These defines are shorter than "sizeof(struct mgmt_cp_foo_bar...)" and will be helpful when extending the command lookup table to contain the expected command size information. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 7aab53e6b813..d33457d657c3 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -52,14 +52,17 @@ struct mgmt_addr_info { bdaddr_t bdaddr; __u8 type; } __packed; +#define MGMT_ADDR_INFO_SIZE 7 #define MGMT_OP_READ_VERSION 0x0001 +#define MGMT_READ_VERSION_SIZE 0 struct mgmt_rp_read_version { __u8 version; __le16 revision; } __packed; #define MGMT_OP_READ_COMMANDS 0x0002 +#define MGMT_READ_COMMANDS_SIZE 0 struct mgmt_rp_read_commands { __le16 num_commands; __le16 num_events; @@ -67,6 +70,7 @@ struct mgmt_rp_read_commands { } __packed; #define MGMT_OP_READ_INDEX_LIST 0x0003 +#define MGMT_READ_INDEX_LIST_SIZE 0 struct mgmt_rp_read_index_list { __le16 num_controllers; __le16 index[0]; @@ -89,6 +93,7 @@ struct mgmt_rp_read_index_list { #define MGMT_SETTING_LE 0x00000200 #define MGMT_OP_READ_INFO 0x0004 +#define MGMT_READ_INFO_SIZE 0 struct mgmt_rp_read_info { bdaddr_t bdaddr; __u8 version; @@ -104,6 +109,8 @@ struct mgmt_mode { __u8 val; } __packed; +#define MGMT_SETTING_SIZE 1 + #define MGMT_OP_SET_POWERED 0x0005 #define MGMT_OP_SET_DISCOVERABLE 0x0006 @@ -111,6 +118,7 @@ struct mgmt_cp_set_discoverable { __u8 val; __u16 timeout; } __packed; +#define MGMT_SET_DISCOVERABLE_SIZE 3 #define MGMT_OP_SET_CONNECTABLE 0x0007 @@ -131,23 +139,27 @@ struct mgmt_cp_set_dev_class { __u8 major; __u8 minor; } __packed; +#define MGMT_SET_DEV_CLASS_SIZE 2 #define MGMT_OP_SET_LOCAL_NAME 0x000F struct mgmt_cp_set_local_name { __u8 name[MGMT_MAX_NAME_LENGTH]; __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; } __packed; +#define MGMT_SET_LOCAL_NAME_SIZE 260 #define MGMT_OP_ADD_UUID 0x0010 struct mgmt_cp_add_uuid { __u8 uuid[16]; __u8 svc_hint; } __packed; +#define MGMT_ADD_UUID_SIZE 17 #define MGMT_OP_REMOVE_UUID 0x0011 struct mgmt_cp_remove_uuid { __u8 uuid[16]; } __packed; +#define MGMT_REMOVE_UUID_SIZE 16 struct mgmt_link_key_info { struct mgmt_addr_info addr; @@ -162,6 +174,7 @@ struct mgmt_cp_load_link_keys { __le16 key_count; struct mgmt_link_key_info keys[0]; } __packed; +#define MGMT_LOAD_LINK_KEYS_SIZE 3 struct mgmt_ltk_info { struct mgmt_addr_info addr; @@ -178,16 +191,19 @@ struct mgmt_cp_load_long_term_keys { __le16 key_count; struct mgmt_ltk_info keys[0]; } __packed; +#define MGMT_LOAD_LONG_TERM_KEYS_SIZE 2 #define MGMT_OP_DISCONNECT 0x0014 struct mgmt_cp_disconnect { struct mgmt_addr_info addr; } __packed; +#define MGMT_DISCONNECT_SIZE MGMT_ADDR_INFO_SIZE struct mgmt_rp_disconnect { struct mgmt_addr_info addr; } __packed; #define MGMT_OP_GET_CONNECTIONS 0x0015 +#define MGMT_GET_CONNECTIONS_SIZE 0 struct mgmt_rp_get_connections { __le16 conn_count; struct mgmt_addr_info addr[0]; @@ -199,6 +215,7 @@ struct mgmt_cp_pin_code_reply { __u8 pin_len; __u8 pin_code[16]; } __packed; +#define MGMT_PIN_CODE_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 17) struct mgmt_rp_pin_code_reply { struct mgmt_addr_info addr; } __packed; @@ -207,28 +224,33 @@ struct mgmt_rp_pin_code_reply { struct mgmt_cp_pin_code_neg_reply { struct mgmt_addr_info addr; } __packed; +#define MGMT_PIN_CODE_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_OP_SET_IO_CAPABILITY 0x0018 struct mgmt_cp_set_io_capability { __u8 io_capability; } __packed; +#define MGMT_SET_IO_CAPABILITY_SIZE 1 #define MGMT_OP_PAIR_DEVICE 0x0019 struct mgmt_cp_pair_device { struct mgmt_addr_info addr; __u8 io_cap; } __packed; +#define MGMT_PAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) struct mgmt_rp_pair_device { struct mgmt_addr_info addr; } __packed; #define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A +#define MGMT_CANCEL_PAIR_DEVICE_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_OP_UNPAIR_DEVICE 0x001B struct mgmt_cp_unpair_device { struct mgmt_addr_info addr; __u8 disconnect; } __packed; +#define MGMT_UNPAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) struct mgmt_rp_unpair_device { struct mgmt_addr_info addr; }; @@ -237,6 +259,7 @@ struct mgmt_rp_unpair_device { struct mgmt_cp_user_confirm_reply { struct mgmt_addr_info addr; } __packed; +#define MGMT_USER_CONFIRM_REPLY_SIZE MGMT_ADDR_INFO_SIZE struct mgmt_rp_user_confirm_reply { struct mgmt_addr_info addr; } __packed; @@ -245,12 +268,14 @@ struct mgmt_rp_user_confirm_reply { struct mgmt_cp_user_confirm_neg_reply { struct mgmt_addr_info addr; } __packed; +#define MGMT_USER_CONFIRM_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_OP_USER_PASSKEY_REPLY 0x001E struct mgmt_cp_user_passkey_reply { struct mgmt_addr_info addr; __le32 passkey; } __packed; +#define MGMT_USER_PASSKEY_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 4) struct mgmt_rp_user_passkey_reply { struct mgmt_addr_info addr; } __packed; @@ -259,8 +284,10 @@ struct mgmt_rp_user_passkey_reply { struct mgmt_cp_user_passkey_neg_reply { struct mgmt_addr_info addr; } __packed; +#define MGMT_USER_PASSKEY_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 +#define MGMT_READ_LOCAL_OOB_DATA_SIZE 0 struct mgmt_rp_read_local_oob_data { __u8 hash[16]; __u8 randomizer[16]; @@ -272,27 +299,32 @@ struct mgmt_cp_add_remote_oob_data { __u8 hash[16]; __u8 randomizer[16]; } __packed; +#define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 struct mgmt_cp_remove_remote_oob_data { struct mgmt_addr_info addr; } __packed; +#define MGMT_REMOVE_REMOTE_OOB_DATA_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_OP_START_DISCOVERY 0x0023 struct mgmt_cp_start_discovery { __u8 type; } __packed; +#define MGMT_START_DISCOVERY_SIZE 1 #define MGMT_OP_STOP_DISCOVERY 0x0024 struct mgmt_cp_stop_discovery { __u8 type; } __packed; +#define MGMT_STOP_DISCOVERY_SIZE 1 #define MGMT_OP_CONFIRM_NAME 0x0025 struct mgmt_cp_confirm_name { struct mgmt_addr_info addr; __u8 name_known; } __packed; +#define MGMT_CONFIRM_NAME_SIZE (MGMT_ADDR_INFO_SIZE + 1) struct mgmt_rp_confirm_name { struct mgmt_addr_info addr; } __packed; @@ -301,11 +333,13 @@ struct mgmt_rp_confirm_name { struct mgmt_cp_block_device { struct mgmt_addr_info addr; } __packed; +#define MGMT_BLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_OP_UNBLOCK_DEVICE 0x0027 struct mgmt_cp_unblock_device { struct mgmt_addr_info addr; } __packed; +#define MGMT_UNBLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { -- GitLab From be22b54e8711734f4cb93ac31723b955fe9dbbe0 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 1 Mar 2012 22:24:41 +0200 Subject: [PATCH 1283/1846] Bluetooth: mgmt: Centralize message length checks This patch moves the command length information into the command handler table allowing the removal of length checks from the handler functions and doing the check in a single place before calling the handler function. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 220 ++++++++++--------------------------------- 1 file changed, 52 insertions(+), 168 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 88a342a12593..7bd7d57a8775 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -751,10 +751,6 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { @@ -846,10 +842,6 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, - MGMT_STATUS_INVALID_PARAMS); - timeout = get_unaligned_le16(&cp->timeout); if (!cp->val && timeout > 0) return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, @@ -945,10 +937,6 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -1019,10 +1007,6 @@ static int set_pairable(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_PAIRABLE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (cp->val) @@ -1051,10 +1035,6 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -1115,10 +1095,6 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { @@ -1181,10 +1157,6 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, - MGMT_STATUS_INVALID_PARAMS); - if (!enable_hs) return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, MGMT_STATUS_NOT_SUPPORTED); @@ -1207,10 +1179,6 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_LE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!enable_le || !(hdev->features[4] & LMP_LE)) { @@ -1280,10 +1248,6 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { @@ -1353,10 +1317,6 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { @@ -1430,10 +1390,6 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("request for %s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { @@ -1486,10 +1442,6 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, u16 key_count, expected_len; int i; - if (len < sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, - MGMT_STATUS_INVALID_PARAMS); - key_count = get_unaligned_le16(&cp->key_count); expected_len = sizeof(*cp) + key_count * @@ -1551,10 +1503,6 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, struct hci_conn *conn; int err; - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); memset(&rp, 0, sizeof(rp)); @@ -1627,10 +1575,6 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!test_bit(HCI_UP, &hdev->flags)) { @@ -1781,10 +1725,6 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -1842,10 +1782,6 @@ static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -1868,10 +1804,6 @@ static int set_io_capability(struct sock *sk, struct hci_dev *hdev, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); hdev->io_capability = cp->io_capability; @@ -1949,10 +1881,6 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_PAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -2029,10 +1957,6 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, BT_DBG(""); - if (len != sizeof(*addr)) - return cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -2153,10 +2077,6 @@ static int user_confirm_neg_reply(struct sock *sk, struct hci_dev *hdev, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_NEG_REPLY, - MGMT_STATUS_INVALID_PARAMS); - return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_CONFIRM_NEG_REPLY, HCI_OP_USER_CONFIRM_NEG_REPLY, 0); @@ -2169,10 +2089,6 @@ static int user_passkey_reply(struct sock *sk, struct hci_dev *hdev, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_USER_PASSKEY_REPLY, - EINVAL); - return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_PASSKEY_REPLY, HCI_OP_USER_PASSKEY_REPLY, @@ -2186,10 +2102,6 @@ static int user_passkey_neg_reply(struct sock *sk, struct hci_dev *hdev, BT_DBG(""); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_USER_PASSKEY_NEG_REPLY, - EINVAL); - return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, MGMT_OP_USER_PASSKEY_NEG_REPLY, HCI_OP_USER_PASSKEY_NEG_REPLY, 0); @@ -2205,10 +2117,6 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG(""); - if (len != sizeof(*mgmt_cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); memcpy(hdev->short_name, mgmt_cp->short_name, @@ -2297,10 +2205,6 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, BT_DBG("%s ", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -2334,10 +2238,6 @@ static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev, BT_DBG("%s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -2388,10 +2288,6 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, BT_DBG("%s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hdev_is_powered(hdev)) { @@ -2463,10 +2359,6 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("%s", hdev->name); - if (len != sizeof(*mgmt_cp)) - return cmd_status(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hci_discovery_active(hdev)) { @@ -2529,10 +2421,6 @@ static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("%s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_CONFIRM_NAME, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); if (!hci_discovery_active(hdev)) { @@ -2572,10 +2460,6 @@ static int block_device(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("%s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_BLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); err = hci_blacklist_add(hdev, &cp->addr.bdaddr, cp->addr.type); @@ -2601,10 +2485,6 @@ static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data, BT_DBG("%s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_UNBLOCK_DEVICE, - MGMT_STATUS_INVALID_PARAMS); - hci_dev_lock(hdev); err = hci_blacklist_del(hdev, &cp->addr.bdaddr, cp->addr.type); @@ -2631,10 +2511,6 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, BT_DBG("%s", hdev->name); - if (len != sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_INVALID_PARAMS); - if (!hdev_is_powered(hdev)) return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, MGMT_STATUS_NOT_POWERED); @@ -2684,10 +2560,6 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, u16 key_count, expected_len; int i; - if (len < sizeof(*cp)) - return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, - EINVAL); - key_count = get_unaligned_le16(&cp->key_count); expected_len = sizeof(*cp) + key_count * @@ -2727,47 +2599,49 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, struct mgmt_handler { int (*func) (struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len); + bool var_len; + size_t data_len; } mgmt_handlers[] = { { NULL }, /* 0x0000 (no command) */ - { read_version, }, - { read_commands, }, - { read_index_list, }, - { read_controller_info, }, - { set_powered, }, - { set_discoverable, }, - { set_connectable, }, - { set_fast_connectable, }, - { set_pairable, }, - { set_link_security, }, - { set_ssp, }, - { set_hs, }, - { set_le, }, - { set_dev_class, }, - { set_local_name, }, - { add_uuid, }, - { remove_uuid, }, - { load_link_keys, }, - { load_long_term_keys, }, - { disconnect, }, - { get_connections, }, - { pin_code_reply, }, - { pin_code_neg_reply, }, - { set_io_capability, }, - { pair_device, }, - { cancel_pair_device, }, - { unpair_device, }, - { user_confirm_reply, }, - { user_confirm_neg_reply, }, - { user_passkey_reply, }, - { user_passkey_neg_reply, }, - { read_local_oob_data, }, - { add_remote_oob_data, }, - { remove_remote_oob_data, }, - { start_discovery, }, - { stop_discovery, }, - { confirm_name, }, - { block_device, }, - { unblock_device, }, + { read_version, false, MGMT_READ_VERSION_SIZE }, + { read_commands, false, MGMT_READ_COMMANDS_SIZE }, + { read_index_list, false, MGMT_READ_INDEX_LIST_SIZE }, + { read_controller_info, false, MGMT_READ_INFO_SIZE }, + { set_powered, false, MGMT_SETTING_SIZE }, + { set_discoverable, false, MGMT_SET_DISCOVERABLE_SIZE }, + { set_connectable, false, MGMT_SETTING_SIZE }, + { set_fast_connectable, false, MGMT_SETTING_SIZE }, + { set_pairable, false, MGMT_SETTING_SIZE }, + { set_link_security, false, MGMT_SETTING_SIZE }, + { set_ssp, false, MGMT_SETTING_SIZE }, + { set_hs, false, MGMT_SETTING_SIZE }, + { set_le, false, MGMT_SETTING_SIZE }, + { set_dev_class, false, MGMT_SET_DEV_CLASS_SIZE }, + { set_local_name, false, MGMT_SET_LOCAL_NAME_SIZE }, + { add_uuid, false, MGMT_ADD_UUID_SIZE }, + { remove_uuid, false, MGMT_REMOVE_UUID_SIZE }, + { load_link_keys, true, MGMT_LOAD_LINK_KEYS_SIZE }, + { load_long_term_keys, true, MGMT_LOAD_LONG_TERM_KEYS_SIZE }, + { disconnect, false, MGMT_DISCONNECT_SIZE }, + { get_connections, false, MGMT_GET_CONNECTIONS_SIZE }, + { pin_code_reply, false, MGMT_PIN_CODE_REPLY_SIZE }, + { pin_code_neg_reply, false, MGMT_PIN_CODE_NEG_REPLY_SIZE }, + { set_io_capability, false, MGMT_SET_IO_CAPABILITY_SIZE }, + { pair_device, false, MGMT_PAIR_DEVICE_SIZE }, + { cancel_pair_device, false, MGMT_CANCEL_PAIR_DEVICE_SIZE }, + { unpair_device, false, MGMT_UNPAIR_DEVICE_SIZE }, + { user_confirm_reply, false, MGMT_USER_CONFIRM_REPLY_SIZE }, + { user_confirm_neg_reply, false, MGMT_USER_CONFIRM_NEG_REPLY_SIZE }, + { user_passkey_reply, false, MGMT_USER_PASSKEY_REPLY_SIZE }, + { user_passkey_neg_reply, false, MGMT_USER_PASSKEY_NEG_REPLY_SIZE }, + { read_local_oob_data, false, MGMT_READ_LOCAL_OOB_DATA_SIZE }, + { add_remote_oob_data, false, MGMT_ADD_REMOTE_OOB_DATA_SIZE }, + { remove_remote_oob_data, false, MGMT_REMOVE_REMOTE_OOB_DATA_SIZE }, + { start_discovery, false, MGMT_START_DISCOVERY_SIZE }, + { stop_discovery, false, MGMT_STOP_DISCOVERY_SIZE }, + { confirm_name, false, MGMT_CONFIRM_NAME_SIZE }, + { block_device, false, MGMT_BLOCK_DEVICE_SIZE }, + { unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE }, }; @@ -2778,6 +2652,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) struct mgmt_hdr *hdr; u16 opcode, index, len; struct hci_dev *hdev = NULL; + struct mgmt_handler *handler; int err; BT_DBG("got %zu bytes", msglen); @@ -2828,12 +2703,21 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) goto done; } + handler = &mgmt_handlers[opcode]; + + if ((handler->var_len && len < handler->data_len) || + (!handler->var_len && len != handler->data_len)) { + err = cmd_status(sk, index, opcode, + MGMT_STATUS_INVALID_PARAMS); + goto done; + } + if (hdev) mgmt_init_hdev(sk, hdev); cp = buf + sizeof(*hdr); - err = mgmt_handlers[opcode].func(sk, hdev, cp, len); + err = handler->func(sk, hdev, cp, len); if (err < 0) goto done; -- GitLab From 97767a87f3be8834192dc3fc9412aaccf708d87f Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 29 Feb 2012 20:40:46 +0000 Subject: [PATCH 1284/1846] be2net: Remove unused OFFSET_IN_PAGE() macro Signed-off-by: Roland Dreier Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index c357172d0543..ab24e4600695 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -442,10 +442,6 @@ extern const struct ethtool_ops be_ethtool_ops; ((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) + \ (size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K)) -/* Byte offset into the page corresponding to given address */ -#define OFFSET_IN_PAGE(addr) \ - ((size_t)(addr) & (PAGE_SIZE_4K-1)) - /* Returns bit offset within a DWORD of a bitfield */ #define AMAP_BIT_OFFSET(_struct, field) \ (((size_t)&(((_struct *)0)->field))%32) -- GitLab From ba13ccd9b911e043c0f11e60cbb72bd4de194205 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 1 Mar 2012 14:25:33 -0800 Subject: [PATCH 1285/1846] Bluetooth: Update L2CAP timeout constants to use msecs_to_jiffies The L2CAP timeout constants are always used in form of jiffies. So just include the conversion from msecs in the define itself. This has the advantage of making the code where the timeout is used more readable. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- include/net/bluetooth/l2cap.h | 10 +++++----- net/bluetooth/l2cap_core.c | 18 ++++++------------ net/bluetooth/l2cap_sock.c | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 3732a4849f2e..e4669d0230c5 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -45,11 +45,11 @@ #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF -#define L2CAP_DISC_TIMEOUT (100) -#define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ -#define L2CAP_ENC_TIMEOUT (5000) /* 5 seconds */ -#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ -#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ +#define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) +#define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) +#define L2CAP_ENC_TIMEOUT msecs_to_jiffies(5000) +#define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) +#define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) /* L2CAP socket address */ struct sockaddr_l2 { diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index bc8d558b01f6..0b1aabff8649 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -700,8 +700,7 @@ static void l2cap_do_start(struct l2cap_chan *chan) conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_SENT; conn->info_ident = l2cap_get_ident(conn); - schedule_delayed_work(&conn->info_timer, - msecs_to_jiffies(L2CAP_INFO_TIMEOUT)); + schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ, sizeof(req), &req); @@ -2741,8 +2740,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_SENT; conn->info_ident = l2cap_get_ident(conn); - schedule_delayed_work(&conn->info_timer, - msecs_to_jiffies(L2CAP_INFO_TIMEOUT)); + schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ, sizeof(info), &info); @@ -3028,8 +3026,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr default: l2cap_chan_set_err(chan, ECONNRESET); - __set_chan_timer(chan, - msecs_to_jiffies(L2CAP_DISC_REJ_TIMEOUT)); + __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT); l2cap_send_disconn_req(conn, chan, ECONNRESET); goto done; } @@ -4539,8 +4536,7 @@ static inline void l2cap_check_encryption(struct l2cap_chan *chan, u8 encrypt) if (encrypt == 0x00) { if (chan->sec_level == BT_SECURITY_MEDIUM) { __clear_chan_timer(chan); - __set_chan_timer(chan, - msecs_to_jiffies(L2CAP_ENC_TIMEOUT)); + __set_chan_timer(chan, L2CAP_ENC_TIMEOUT); } else if (chan->sec_level == BT_SECURITY_HIGH) l2cap_chan_close(chan, ECONNREFUSED); } else { @@ -4598,8 +4594,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) l2cap_send_conn_req(chan); } else { __clear_chan_timer(chan); - __set_chan_timer(chan, - msecs_to_jiffies(L2CAP_DISC_TIMEOUT)); + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); } } else if (chan->state == BT_CONNECT2) { struct sock *sk = chan->sk; @@ -4622,8 +4617,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) } } else { __l2cap_state_change(chan, BT_DISCONN); - __set_chan_timer(chan, - msecs_to_jiffies(L2CAP_DISC_TIMEOUT)); + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); res = L2CAP_CR_SEC_BLOCK; stat = L2CAP_CS_NO_INFO; } diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 52c94c765779..3da56c5c1fc9 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -1039,7 +1039,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p INIT_LIST_HEAD(&bt_sk(sk)->accept_q); sk->sk_destruct = l2cap_sock_destruct; - sk->sk_sndtimeo = msecs_to_jiffies(L2CAP_CONN_TIMEOUT); + sk->sk_sndtimeo = L2CAP_CONN_TIMEOUT; sock_reset_flag(sk, SOCK_ZAPPED); -- GitLab From 17b02e625662906f370a3eb5e7495cf06ed7d4a4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 1 Mar 2012 14:32:37 -0800 Subject: [PATCH 1286/1846] Bluetooth: Update MGMT and SMP timeout constants to use msecs_to_jiffies The MGMT and SMP timeout constants are always used in form of jiffies. So just include the conversion from msecs in the define itself. This has the advantage of making the code where the timeout is used more readable. Signed-off-by: Marcel Holtmann Signed-off-by: Johan Hedberg --- net/bluetooth/mgmt.c | 5 ++--- net/bluetooth/smp.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 7bd7d57a8775..40b3da3d5e62 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -116,7 +116,7 @@ static const u16 mgmt_events[] = { #define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ #define INQUIRY_LEN_BREDR_LE 0x04 /* TGAP(100)/2 */ -#define SERVICE_CACHE_TIMEOUT (5 * 1000) +#define CACHE_TIMEOUT msecs_to_jiffies(2 * 1000) #define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \ !test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) @@ -1298,8 +1298,7 @@ static bool enable_service_cache(struct hci_dev *hdev) return false; if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) { - schedule_delayed_work(&hdev->service_cache, - msecs_to_jiffies(SERVICE_CACHE_TIMEOUT)); + schedule_delayed_work(&hdev->service_cache, CACHE_TIMEOUT); return true; } diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index f6a6d8be3051..75937d73d8ae 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -29,7 +29,7 @@ #include #include -#define SMP_TIMEOUT 30000 /* 30 seconds */ +#define SMP_TIMEOUT msecs_to_jiffies(30000) static inline void swap128(u8 src[16], u8 dst[16]) { @@ -186,8 +186,7 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) hci_send_acl(conn->hchan, skb, 0); cancel_delayed_work_sync(&conn->security_timer); - schedule_delayed_work(&conn->security_timer, - msecs_to_jiffies(SMP_TIMEOUT)); + schedule_delayed_work(&conn->security_timer, SMP_TIMEOUT); } static __u8 authreq_to_seclevel(__u8 authreq) -- GitLab From 9f8ce967caed427f78d00bb6b07d79cb040a88bd Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 2 Mar 2012 03:06:04 +0200 Subject: [PATCH 1287/1846] Bluetooth: Fix clearing of HCI_PENDING_CLASS flag When doing reset HCI_PENDING_CLASS is one of the flags that should be cleared (since it's used for a pending HCI command and a reset clear all pending commands). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index aee9556e1039..d6c41bbfe759 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -193,7 +193,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) hci_req_complete(hdev, HCI_OP_RESET, status); /* Reset all non-persistent flags */ - hdev->dev_flags &= ~(BIT(HCI_LE_SCAN)); + hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS)); hdev->discovery.state = DISCOVERY_STOPPED; } -- GitLab From d4f68526e438dbb7d194b08499a96c733131ad72 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 2 Mar 2012 03:07:07 +0200 Subject: [PATCH 1288/1846] Bluetooth: mgmt: Fix command status error code values Error codes in the command status should always be from the set of values defined for mgmt and never e.g. POSIX error codes. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 40b3da3d5e62..bd01e4a4784e 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2745,7 +2745,7 @@ int mgmt_index_added(struct hci_dev *hdev) int mgmt_index_removed(struct hci_dev *hdev) { - u8 status = ENODEV; + u8 status = MGMT_STATUS_INVALID_PARAMS; mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); @@ -2798,7 +2798,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) update_class(hdev); update_eir(hdev); } else { - u8 status = ENETDOWN; + u8 status = MGMT_STATUS_NOT_POWERED; mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); } -- GitLab From 5f15903279143eb640f9ba1c0e72b52fe9e9e2a6 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 2 Mar 2012 03:13:19 +0200 Subject: [PATCH 1289/1846] Bluetooth: mgmt: Add new error code for invalid index The index is part of the command header and not its parameters so it makes sense to distinguish this from the invalid parameters error. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/mgmt.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index d33457d657c3..0ca3519e08bd 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -41,6 +41,7 @@ #define MGMT_STATUS_DISCONNECTED 0x0e #define MGMT_STATUS_NOT_POWERED 0x0f #define MGMT_STATUS_CANCELLED 0x10 +#define MGMT_STATUS_INVALID_INDEX 0x11 struct mgmt_hdr { __le16 opcode; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index bd01e4a4784e..fa9a58964278 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2682,7 +2682,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) hdev = hci_dev_get(index); if (!hdev) { err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_INDEX); goto done; } } @@ -2698,7 +2698,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) if ((hdev && opcode < MGMT_OP_READ_INFO) || (!hdev && opcode >= MGMT_OP_READ_INFO)) { err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_INDEX); goto done; } @@ -2745,7 +2745,7 @@ int mgmt_index_added(struct hci_dev *hdev) int mgmt_index_removed(struct hci_dev *hdev) { - u8 status = MGMT_STATUS_INVALID_PARAMS; + u8 status = MGMT_STATUS_INVALID_INDEX; mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); -- GitLab From 4f87da80a5210e66fb47b0e839f4d05016986f78 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 2 Mar 2012 19:55:56 +0200 Subject: [PATCH 1290/1846] Bluetooth: Remove HCI_PI_MGMT_INIT flag for sockets This flag is of no use right now and is in fact harmful in that it prevents the HCI_MGMT flag to be set for any controllers that may need it after the first one that bluetoothd takes into use (the flag is cleared for the first controller so any subsequent ones through the same bluetoothd mgmt socket never get the HCI_MGMT flag set). Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- include/net/bluetooth/hci_core.h | 4 ---- net/bluetooth/hci_sock.c | 1 - net/bluetooth/mgmt.c | 18 ++++++++---------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index facd7ed32b74..25cb0a15b579 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1034,16 +1034,12 @@ int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); /* HCI info for socket */ #define hci_pi(sk) ((struct hci_pinfo *) sk) -/* HCI socket flags */ -#define HCI_PI_MGMT_INIT 0 - struct hci_pinfo { struct bt_sock bt; struct hci_dev *hdev; struct hci_filter filter; __u32 cmsg_mask; unsigned short channel; - unsigned long flags; }; /* HCI security filter */ diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 8a814bca00d7..63afd234283e 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -659,7 +659,6 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le goto done; } - set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags); break; case HCI_CHANNEL_MONITOR: diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index fa9a58964278..4b1efedc18c5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -615,19 +615,17 @@ static void service_cache_off(struct work_struct *work) static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) { - if (!test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) + if (test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) return; - if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) { - INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); + INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); - /* Non-mgmt controlled devices get this bit set - * implicitly so that pairing works for them, however - * for mgmt we require user-space to explicitly enable - * it - */ - clear_bit(HCI_PAIRABLE, &hdev->dev_flags); - } + /* Non-mgmt controlled devices get this bit set + * implicitly so that pairing works for them, however + * for mgmt we require user-space to explicitly enable + * it + */ + clear_bit(HCI_PAIRABLE, &hdev->dev_flags); } static int read_controller_info(struct sock *sk, struct hci_dev *hdev, -- GitLab From 2b4bf3974249da74f4aef1e9180d4beaf6332515 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 3 Mar 2012 00:19:06 +0200 Subject: [PATCH 1291/1846] Bluetooth: mgmt: Fix updating local name when powering on When powering on we need to apply whatever name has been set through mgmt_set_local_name. The appropriate place for this is mgmt_powered() and not hci_setup() since this needs to be applied also if the HCI init sequence was already completed but the adapter was still "powered off" from a mgmt perspective due the the HCI_AUTO_OFF still being set. Signed-off-by: Johan Hedberg Acked-by: Marcel Holtmann --- net/bluetooth/hci_event.c | 8 -------- net/bluetooth/mgmt.c | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d6c41bbfe759..6a817daf095b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -552,14 +552,6 @@ static void hci_setup(struct hci_dev *hdev) if (hdev->hci_ver > BLUETOOTH_VER_1_1) hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); - if (!test_bit(HCI_SETUP, &hdev->dev_flags) && - test_bit(HCI_MGMT, &hdev->dev_flags)) { - struct hci_cp_write_local_name cp; - - memcpy(cp.name, hdev->dev_name, sizeof(cp.name)); - hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp); - } - if (hdev->features[6] & LMP_SIMPLE_PAIR) { if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { u8 mode = 0x01; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4b1efedc18c5..4ca009268afb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2104,11 +2104,19 @@ static int user_passkey_neg_reply(struct sock *sk, struct hci_dev *hdev, HCI_OP_USER_PASSKEY_NEG_REPLY, 0); } +static int update_name(struct hci_dev *hdev, const char *name) +{ + struct hci_cp_write_local_name cp; + + memcpy(cp.name, name, sizeof(cp.name)); + + return hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp); +} + static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { - struct mgmt_cp_set_local_name *mgmt_cp = data; - struct hci_cp_write_local_name hci_cp; + struct mgmt_cp_set_local_name *cp = data; struct pending_cmd *cmd; int err; @@ -2116,11 +2124,10 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, hci_dev_lock(hdev); - memcpy(hdev->short_name, mgmt_cp->short_name, - sizeof(hdev->short_name)); + memcpy(hdev->short_name, cp->short_name, sizeof(hdev->short_name)); if (!hdev_is_powered(hdev)) { - memcpy(hdev->dev_name, mgmt_cp->name, sizeof(hdev->dev_name)); + memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name)); err = cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, data, len); @@ -2139,9 +2146,7 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, goto failed; } - memcpy(hci_cp.name, mgmt_cp->name, sizeof(hci_cp.name)); - err = hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(hci_cp), - &hci_cp); + err = update_name(hdev, cp->name); if (err < 0) mgmt_pending_remove(cmd); @@ -2794,6 +2799,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); update_class(hdev); + update_name(hdev, hdev->dev_name); update_eir(hdev); } else { u8 status = MGMT_STATUS_NOT_POWERED; -- GitLab From 74fe619ef96466d562a1a13e7cbab783624ec2f3 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Thu, 1 Mar 2012 18:19:57 -0300 Subject: [PATCH 1292/1846] Bluetooth: Don't force DISCOVERY_STOPPED state in inquiry_cache_flush We are not supposed to force DISCOVERY_STOPPED in inquiry_cache_flush because we may break the discovery state machine. For instance, during interleaved discovery, when we are about to start inquiry, the state machine forcibly goes to DISCOVERY_STOPPED while it should stay in DISCOVERY_FINDING state. This problem results in unexpected behaviors such as sending two mgmt_discovering events to userspace (when only one event is expected) and Stop Discovery failures. Signed-off-by: Andre Guedes Signed-off-by: Johan Hedberg --- net/bluetooth/hci_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index d3ddc0ba9cd4..661d65fc487b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -413,7 +413,6 @@ static void inquiry_cache_flush(struct hci_dev *hdev) INIT_LIST_HEAD(&cache->unknown); INIT_LIST_HEAD(&cache->resolve); - cache->state = DISCOVERY_STOPPED; } struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) -- GitLab From d24d65eda97fe51f2996538148e85d309e2460e4 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 17 Feb 2012 13:44:23 +0000 Subject: [PATCH 1293/1846] e100: Fix rx-over-length statistics. The old code would += the total errors every time stats were gathered. Instead, keep a count of short-pkt and long-pkt counters and then simply add them together for the rx-over-length stat. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e100.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 4d8a616fe9cd..d2b78722fc32 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -622,6 +622,7 @@ struct nic { u32 rx_fc_pause; u32 rx_fc_unsupported; u32 rx_tco_frames; + u32 rx_short_frame_errors; u32 rx_over_length_errors; u16 eeprom_wc; @@ -1622,7 +1623,9 @@ static void e100_update_stats(struct nic *nic) ns->collisions += nic->tx_collisions; ns->tx_errors += le32_to_cpu(s->tx_max_collisions) + le32_to_cpu(s->tx_lost_crs); - ns->rx_length_errors += le32_to_cpu(s->rx_short_frame_errors) + + nic->rx_short_frame_errors += + le32_to_cpu(s->rx_short_frame_errors); + ns->rx_length_errors = nic->rx_short_frame_errors + nic->rx_over_length_errors; ns->rx_crc_errors += le32_to_cpu(s->rx_crc_errors); ns->rx_frame_errors += le32_to_cpu(s->rx_alignment_errors); -- GitLab From 6f66342c1ecd59467d4579176dd81a4e837a06ef Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 17 Feb 2012 13:44:28 +0000 Subject: [PATCH 1294/1846] e100: Show short v/s long rx length errors in ethtool stats. Signed-off-by: Ben Greear Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e100.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index d2b78722fc32..e498effb85d9 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -2661,6 +2661,7 @@ static const char e100_gstrings_stats[][ETH_GSTRING_LEN] = { "tx_deferred", "tx_single_collisions", "tx_multi_collisions", "tx_flow_control_pause", "rx_flow_control_pause", "rx_flow_control_unsupported", "tx_tco_packets", "rx_tco_packets", + "rx_short_frame_errors", "rx_over_length_errors", }; #define E100_NET_STATS_LEN 21 #define E100_STATS_LEN ARRAY_SIZE(e100_gstrings_stats) @@ -2694,6 +2695,8 @@ static void e100_get_ethtool_stats(struct net_device *netdev, data[i++] = nic->rx_fc_unsupported; data[i++] = nic->tx_tco_frames; data[i++] = nic->rx_tco_frames; + data[i++] = nic->rx_short_frame_errors; + data[i++] = nic->rx_over_length_errors; } static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data) -- GitLab From 89d27a3c0ad7d5f2ce9ece055b3c7c619dc42f6c Mon Sep 17 00:00:00 2001 From: John Fastabend Date: Fri, 10 Feb 2012 03:19:35 +0000 Subject: [PATCH 1295/1846] ixgbe: dcb: check setup_tc return codes dcb netlink code calls setup_tc to init hardware traffic classes to use for DCB. At some call sites the return values are not checked for errors and in one case may return -EINVAL back to the net/dcbnl.c caller which is expecting a u8. This fixes some smatch hits and although failures are never seen in practive its best to check return codes. Reported-by: Dan Carenter Signed-off-by: John Fastabend Tested-by: Ross Brattain Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c index 79a92fe987b9..95e5d11bb555 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c @@ -111,7 +111,7 @@ static u8 ixgbe_dcbnl_get_state(struct net_device *netdev) static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) { - u8 err = 0; + int err = 0; u8 prio_tc[MAX_USER_PRIORITY] = {0}; int i; struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -122,7 +122,7 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) /* verify there is something to do, if not then exit */ if (!!state != !(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) - return err; + goto out; if (state > 0) { err = ixgbe_setup_tc(netdev, adapter->dcb_cfg.num_tcs.pg_tcs); @@ -131,10 +131,14 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state) err = ixgbe_setup_tc(netdev, 0); } + if (err) + goto out; + for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(netdev, i, prio_tc[i]); - return err; +out: + return err ? 1 : 0; } static void ixgbe_dcbnl_get_perm_hw_addr(struct net_device *netdev, @@ -581,7 +585,7 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev, { struct ixgbe_adapter *adapter = netdev_priv(dev); int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN; - int i; + int i, err = 0; __u8 max_tc = 0; if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) @@ -608,12 +612,17 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev, return -EINVAL; if (max_tc != netdev_get_num_tc(dev)) - ixgbe_setup_tc(dev, max_tc); + err = ixgbe_setup_tc(dev, max_tc); + + if (err) + goto err_out; for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) netdev_set_prio_tc_map(dev, i, ets->prio_tc[i]); - return ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame); + err = ixgbe_dcb_hw_ets(&adapter->hw, ets, max_frame); +err_out: + return err; } static int ixgbe_dcbnl_ieee_getpfc(struct net_device *dev, @@ -726,6 +735,7 @@ static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode) struct ixgbe_adapter *adapter = netdev_priv(dev); struct ieee_ets ets = {0}; struct ieee_pfc pfc = {0}; + int err = 0; /* no support for LLD_MANAGED modes or CEE+IEEE */ if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || @@ -756,10 +766,10 @@ static u8 ixgbe_dcbnl_setdcbx(struct net_device *dev, u8 mode) */ ixgbe_dcbnl_ieee_setets(dev, &ets); ixgbe_dcbnl_ieee_setpfc(dev, &pfc); - ixgbe_setup_tc(dev, 0); + err = ixgbe_setup_tc(dev, 0); } - return 0; + return err ? 1 : 0; } const struct dcbnl_rtnl_ops dcbnl_ops = { -- GitLab From 2b88f2de30510c0f4e623d3cd5fcd85cdb70b51f Mon Sep 17 00:00:00 2001 From: John Fastabend Date: Fri, 10 Feb 2012 03:19:41 +0000 Subject: [PATCH 1296/1846] net: dcb: getnumtcs()/setnumtcs() should return an int {g|s}etnumtcs() today returns a u8 that is only used by the DCB code to verify no error occurred. Today the driver implementations return negative error codes which end up being non-zero so the logic works out but triggers some sparse warnings. To fix the sparse warnings convert the return value to an int. CC: Eilon Greenstein Reported-by: Dan Carpenter Signed-off-by: John Fastabend Tested-by: Ross Brattain Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 4 ++-- drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 4 ++-- include/net/dcbnl.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 9a9bd3ab4793..9a4ed05bb30a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -2142,7 +2142,7 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap) return rval; } -static u8 bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num) +static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num) { struct bnx2x *bp = netdev_priv(netdev); u8 rval = 0; @@ -2169,7 +2169,7 @@ static u8 bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num) return rval; } -static u8 bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num) +static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num) { struct bnx2x *bp = netdev_priv(netdev); DP(NETIF_MSG_LINK, "num tcs = %d; Not supported\n", num); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c index 95e5d11bb555..dde65f951400 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c @@ -490,7 +490,7 @@ static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap) return 0; } -static u8 ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) +static int ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) { struct ixgbe_adapter *adapter = netdev_priv(netdev); u8 rval = 0; @@ -514,7 +514,7 @@ static u8 ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) return rval; } -static u8 ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num) +static int ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num) { return -EINVAL; } diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h index 2cd66d0be348..f55c980d8e23 100644 --- a/include/net/dcbnl.h +++ b/include/net/dcbnl.h @@ -72,8 +72,8 @@ struct dcbnl_rtnl_ops { void (*getpfccfg)(struct net_device *, int, u8 *); u8 (*setall)(struct net_device *); u8 (*getcap)(struct net_device *, int, u8 *); - u8 (*getnumtcs)(struct net_device *, int, u8 *); - u8 (*setnumtcs)(struct net_device *, int, u8); + int (*getnumtcs)(struct net_device *, int, u8 *); + int (*setnumtcs)(struct net_device *, int, u8); u8 (*getpfcstate)(struct net_device *); void (*setpfcstate)(struct net_device *, u8); void (*getbcncfg)(struct net_device *, int, u32 *); -- GitLab From 793734b587a670e47a8d65f9e5211ba2188bb904 Mon Sep 17 00:00:00 2001 From: Gerrit Renker Date: Mon, 27 Feb 2012 12:29:44 -0700 Subject: [PATCH 1297/1846] dccp ccid-3: replace incorrect BUG_ON This replaces an unjustified BUG_ON(), which could get triggered under normal conditions: X_calc can be 0 when p > 0. X would in this case be set to the minimum, s/t_mbi. Its replacement avoids t_ipi = 0 (unbounded sending rate). Thanks to Jordi, Victor and Xavier who reported this. Signed-off-by: Gerrit Renker Acked-by: Ian McDonald --- net/dccp/ccids/ccid3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 560627307200..70bfaf2d1965 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c @@ -98,6 +98,7 @@ static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hc) { hc->tx_t_ipi = scaled_div32(((u64)hc->tx_s) << 6, hc->tx_x); + DCCP_BUG_ON(hc->tx_t_ipi == 0); ccid3_pr_debug("t_ipi=%u, s=%u, X=%u\n", hc->tx_t_ipi, hc->tx_s, (unsigned)(hc->tx_x >> 6)); } @@ -236,8 +237,6 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) * * Note that X_recv is scaled by 2^6 while X_calc is not */ - BUG_ON(hc->tx_p && !hc->tx_x_calc); - if (hc->tx_x_calc > (hc->tx_x_recv >> 5)) hc->tx_x_recv = max(hc->tx_x_recv / 2, -- GitLab From f541fb7e20c848f947ca65fbf169efe69400c942 Mon Sep 17 00:00:00 2001 From: Samuel Jero Date: Sun, 26 Feb 2012 18:22:02 -0700 Subject: [PATCH 1298/1846] dccp: fix bug in sequence number validation during connection setup This fixes a bug in the sequence number validation during the initial handshake. The code did not treat the initial sequence numbers ISS and ISR as read-only and did not keep state for GSR and GSS as required by the specification. This causes problems with retransmissions during the initial handshake, causing the budding connection to be reset. This patch now treats ISS/ISR as read-only and tracks GSS/GSR as required. Signed-off-by: Samuel Jero Signed-off-by: Gerrit Renker --- include/linux/dccp.h | 8 ++++++-- net/dccp/ipv4.c | 8 +++++--- net/dccp/ipv6.c | 8 +++++--- net/dccp/minisocks.c | 18 +++++++++++------- net/dccp/output.c | 10 +++++----- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 710c04302a15..eaf95a023af4 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -376,8 +376,10 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb) /** * struct dccp_request_sock - represent DCCP-specific connection request * @dreq_inet_rsk: structure inherited from - * @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1) - * @dreq_isr: initial sequence number received on the Request + * @dreq_iss: initial sequence number, sent on the first Response (RFC 4340, 7.1) + * @dreq_gss: greatest sequence number sent (for retransmitted Responses) + * @dreq_isr: initial sequence number received in the first Request + * @dreq_gsr: greatest sequence number received (for retransmitted Request(s)) * @dreq_service: service code present on the Request (there is just one) * @dreq_featneg: feature negotiation options for this connection * The following two fields are analogous to the ones in dccp_sock: @@ -387,7 +389,9 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb) struct dccp_request_sock { struct inet_request_sock dreq_inet_rsk; __u64 dreq_iss; + __u64 dreq_gss; __u64 dreq_isr; + __u64 dreq_gsr; __be32 dreq_service; struct list_head dreq_featneg; __u32 dreq_timestamp_echo; diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 1c67fe8ff90d..caf6e1734b62 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -300,7 +300,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) */ WARN_ON(req->sk); - if (seq != dccp_rsk(req)->dreq_iss) { + if (!between48(seq, dccp_rsk(req)->dreq_iss, + dccp_rsk(req)->dreq_gss)) { NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); goto out; } @@ -639,11 +640,12 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) * * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie * - * In fact we defer setting S.GSR, S.SWL, S.SWH to - * dccp_create_openreq_child. + * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child(). */ dreq->dreq_isr = dcb->dccpd_seq; + dreq->dreq_gsr = dreq->dreq_isr; dreq->dreq_iss = dccp_v4_init_sequence(skb); + dreq->dreq_gss = dreq->dreq_iss; dreq->dreq_service = service; if (dccp_v4_send_response(sk, req, NULL)) diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index ce903f747e64..4dc588f520e0 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -193,7 +193,8 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, */ WARN_ON(req->sk != NULL); - if (seq != dccp_rsk(req)->dreq_iss) { + if (!between48(seq, dccp_rsk(req)->dreq_iss, + dccp_rsk(req)->dreq_gss)) { NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); goto out; } @@ -440,11 +441,12 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) * * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie * - * In fact we defer setting S.GSR, S.SWL, S.SWH to - * dccp_create_openreq_child. + * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child(). */ dreq->dreq_isr = dcb->dccpd_seq; + dreq->dreq_gsr = dreq->dreq_isr; dreq->dreq_iss = dccp_v6_init_sequence(skb); + dreq->dreq_gss = dreq->dreq_iss; dreq->dreq_service = service; if (dccp_v6_send_response(sk, req, NULL)) diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 5a7f90bbffac..ea850ce35d4a 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -127,9 +127,11 @@ struct sock *dccp_create_openreq_child(struct sock *sk, * activation below, as these windows all depend on the local * and remote Sequence Window feature values (7.5.2). */ - newdp->dccps_gss = newdp->dccps_iss = dreq->dreq_iss; + newdp->dccps_iss = dreq->dreq_iss; + newdp->dccps_gss = dreq->dreq_gss; newdp->dccps_gar = newdp->dccps_iss; - newdp->dccps_gsr = newdp->dccps_isr = dreq->dreq_isr; + newdp->dccps_isr = dreq->dreq_isr; + newdp->dccps_gsr = dreq->dreq_gsr; /* * Activate features: initialise CCIDs, sequence windows etc. @@ -164,9 +166,9 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb, /* Check for retransmitted REQUEST */ if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) { - if (after48(DCCP_SKB_CB(skb)->dccpd_seq, dreq->dreq_isr)) { + if (after48(DCCP_SKB_CB(skb)->dccpd_seq, dreq->dreq_gsr)) { dccp_pr_debug("Retransmitted REQUEST\n"); - dreq->dreq_isr = DCCP_SKB_CB(skb)->dccpd_seq; + dreq->dreq_gsr = DCCP_SKB_CB(skb)->dccpd_seq; /* * Send another RESPONSE packet * To protect against Request floods, increment retrans @@ -186,12 +188,14 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb, goto drop; /* Invalid ACK */ - if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dreq->dreq_iss) { + if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, + dreq->dreq_iss, dreq->dreq_gss)) { dccp_pr_debug("Invalid ACK number: ack_seq=%llu, " - "dreq_iss=%llu\n", + "dreq_iss=%llu, dreq_gss=%llu\n", (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq, - (unsigned long long) dreq->dreq_iss); + (unsigned long long) dreq->dreq_iss, + (unsigned long long) dreq->dreq_gss); goto drop; } diff --git a/net/dccp/output.c b/net/dccp/output.c index dede3edb8849..787367308797 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c @@ -408,10 +408,10 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, skb_dst_set(skb, dst_clone(dst)); dreq = dccp_rsk(req); - if (inet_rsk(req)->acked) /* increase ISS upon retransmission */ - dccp_inc_seqno(&dreq->dreq_iss); + if (inet_rsk(req)->acked) /* increase GSS upon retransmission */ + dccp_inc_seqno(&dreq->dreq_gss); DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE; - DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss; + DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_gss; /* Resolve feature dependencies resulting from choice of CCID */ if (dccp_feat_server_ccid_dependencies(dreq)) @@ -429,8 +429,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; dh->dccph_type = DCCP_PKT_RESPONSE; dh->dccph_x = 1; - dccp_hdr_set_seq(dh, dreq->dreq_iss); - dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr); + dccp_hdr_set_seq(dh, dreq->dreq_gss); + dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_gsr); dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service; dccp_csum_outgoing(skb); -- GitLab From 224223aaf9a44cd484019d2b765b6ca2beee6dd4 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 15 Feb 2012 18:55:01 +0100 Subject: [PATCH 1299/1846] can: cc770: linux/can/dev.h included twice drivers/net/can/cc770/cc770.c included 'linux/can/dev.h' twice, remove the duplicate. Signed-off-by: Danny Kukawka Signed-off-by: Marc Kleine-Budde --- drivers/net/can/cc770/cc770.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/can/cc770/cc770.c b/drivers/net/can/cc770/cc770.c index c30f0e6f1048..d42a6a7396f2 100644 --- a/drivers/net/can/cc770/cc770.c +++ b/drivers/net/can/cc770/cc770.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "cc770.h" -- GitLab From e6d9c80b7ca1504411ad6d7acdb8683e4ae1c9cd Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Fri, 2 Mar 2012 16:21:19 +0100 Subject: [PATCH 1300/1846] can: peak_pci: add support of some new PEAK-System PCI cards This patch adds the support of some new PEAK-System PCI cards in the CAN network sub-system. These are: PCAN-PCIeC (PCI-ExpressCard) PCAN-mminiPCI (mini-PCI) PCAN-PCI (PCI next-gen) This patch also adds the control of the blinking leds of the PCAN-PCIeC. Tested-by: Oliver Hartkopp Acked-by: Wolfgang Grandegger Signed-off-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- drivers/net/can/sja1000/Kconfig | 18 +- drivers/net/can/sja1000/peak_pci.c | 505 ++++++++++++++++++++++++++++- 2 files changed, 506 insertions(+), 17 deletions(-) diff --git a/drivers/net/can/sja1000/Kconfig b/drivers/net/can/sja1000/Kconfig index b21523ddff3c..fdc39261d464 100644 --- a/drivers/net/can/sja1000/Kconfig +++ b/drivers/net/can/sja1000/Kconfig @@ -44,11 +44,23 @@ config CAN_EMS_PCI (http://www.ems-wuensche.de). config CAN_PEAK_PCI - tristate "PEAK PCAN PCI/PCIe Cards" + tristate "PEAK PCAN-PCI/PCIe/miniPCI Cards" depends on PCI ---help--- - This driver is for the PCAN PCI/PCIe cards (1, 2, 3 or 4 channels) - from PEAK Systems (http://www.peak-system.com). + This driver is for the PCAN-PCI/PCIe/miniPCI cards + (1, 2, 3 or 4 channels) from PEAK-System Technik + (http://www.peak-system.com). + +config CAN_PEAK_PCIEC + bool "PEAK PCAN-ExpressCard Cards" + depends on CAN_PEAK_PCI + select I2C + select I2C_ALGOBIT + default y + ---help--- + Say Y here if you want to use a PCAN-ExpressCard from PEAK-System + Technik. This will also automatically select I2C and I2C_ALGO + configuration options. config CAN_KVASER_PCI tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards" diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c index 214795945bc4..5f92b865f64b 100644 --- a/drivers/net/can/sja1000/peak_pci.c +++ b/drivers/net/can/sja1000/peak_pci.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2007, 2011 Wolfgang Grandegger + * Copyright (C) 2012 Stephane Grosjean * * Derived from the PCAN project file driver/src/pcan_pci.c: * @@ -13,10 +14,6 @@ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include @@ -26,22 +23,26 @@ #include #include #include +#include +#include #include #include #include "sja1000.h" MODULE_AUTHOR("Wolfgang Grandegger "); -MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCI/PCIe cards"); -MODULE_SUPPORTED_DEVICE("PEAK PCAN PCI/PCIe CAN card"); +MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCI family cards"); +MODULE_SUPPORTED_DEVICE("PEAK PCAN PCI/PCIe/PCIeC miniPCI CAN cards"); MODULE_LICENSE("GPL v2"); #define DRV_NAME "peak_pci" +struct peak_pciec_card; struct peak_pci_chan { void __iomem *cfg_base; /* Common for all channels */ struct net_device *prev_dev; /* Chain of network devices */ u16 icr_mask; /* Interrupt mask for fast ack */ + struct peak_pciec_card *pciec_card; /* only for PCIeC LEDs */ }; #define PEAK_PCI_CAN_CLOCK (16000000 / 2) @@ -61,16 +62,464 @@ struct peak_pci_chan { #define PEAK_PCI_VENDOR_ID 0x001C /* The PCI device and vendor IDs */ #define PEAK_PCI_DEVICE_ID 0x0001 /* for PCI/PCIe slot cards */ +#define PEAK_PCIEC_DEVICE_ID 0x0002 /* for ExpressCard slot cards */ +#define PEAK_PCIE_DEVICE_ID 0x0003 /* for nextgen PCIe slot cards */ +#define PEAK_MPCI_DEVICE_ID 0x0008 /* The miniPCI slot cards */ + +#define PEAK_PCI_CHAN_MAX 4 -static const u16 peak_pci_icr_masks[] = {0x02, 0x01, 0x40, 0x80}; +static const u16 peak_pci_icr_masks[PEAK_PCI_CHAN_MAX] = { + 0x02, 0x01, 0x40, 0x80 +}; static DEFINE_PCI_DEVICE_TABLE(peak_pci_tbl) = { {PEAK_PCI_VENDOR_ID, PEAK_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, + {PEAK_PCI_VENDOR_ID, PEAK_PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, + {PEAK_PCI_VENDOR_ID, PEAK_MPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, +#ifdef CONFIG_CAN_PEAK_PCIEC + {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, +#endif {0,} }; MODULE_DEVICE_TABLE(pci, peak_pci_tbl); +#ifdef CONFIG_CAN_PEAK_PCIEC +/* + * PCAN-ExpressCard needs I2C bit-banging configuration option. + */ + +/* GPIOICR byte access offsets */ +#define PITA_GPOUT 0x18 /* GPx output value */ +#define PITA_GPIN 0x19 /* GPx input value */ +#define PITA_GPOEN 0x1A /* configure GPx as ouput pin */ + +/* I2C GP bits */ +#define PITA_GPIN_SCL 0x01 /* Serial Clock Line */ +#define PITA_GPIN_SDA 0x04 /* Serial DAta line */ + +#define PCA9553_1_SLAVEADDR (0xC4 >> 1) + +/* PCA9553 LS0 fields values */ +enum { + PCA9553_LOW, + PCA9553_HIGHZ, + PCA9553_PWM0, + PCA9553_PWM1 +}; + +/* LEDs control */ +#define PCA9553_ON PCA9553_LOW +#define PCA9553_OFF PCA9553_HIGHZ +#define PCA9553_SLOW PCA9553_PWM0 +#define PCA9553_FAST PCA9553_PWM1 + +#define PCA9553_LED(c) (1 << (c)) +#define PCA9553_LED_STATE(s, c) ((s) << ((c) << 1)) + +#define PCA9553_LED_ON(c) PCA9553_LED_STATE(PCA9553_ON, c) +#define PCA9553_LED_OFF(c) PCA9553_LED_STATE(PCA9553_OFF, c) +#define PCA9553_LED_SLOW(c) PCA9553_LED_STATE(PCA9553_SLOW, c) +#define PCA9553_LED_FAST(c) PCA9553_LED_STATE(PCA9553_FAST, c) +#define PCA9553_LED_MASK(c) PCA9553_LED_STATE(0x03, c) + +#define PCA9553_LED_OFF_ALL (PCA9553_LED_OFF(0) | PCA9553_LED_OFF(1)) + +#define PCA9553_LS0_INIT 0x40 /* initial value (!= from 0x00) */ + +struct peak_pciec_chan { + struct net_device *netdev; + unsigned long prev_rx_bytes; + unsigned long prev_tx_bytes; +}; + +struct peak_pciec_card { + void __iomem *cfg_base; /* Common for all channels */ + void __iomem *reg_base; /* first channel base address */ + u8 led_cache; /* leds state cache */ + + /* PCIExpressCard i2c data */ + struct i2c_algo_bit_data i2c_bit; + struct i2c_adapter led_chip; + struct delayed_work led_work; /* led delayed work */ + int chan_count; + struct peak_pciec_chan channel[PEAK_PCI_CHAN_MAX]; +}; + +/* "normal" pci register write callback is overloaded for leds control */ +static void peak_pci_write_reg(const struct sja1000_priv *priv, + int port, u8 val); + +static inline void pita_set_scl_highz(struct peak_pciec_card *card) +{ + u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SCL; + writeb(gp_outen, card->cfg_base + PITA_GPOEN); +} + +static inline void pita_set_sda_highz(struct peak_pciec_card *card) +{ + u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SDA; + writeb(gp_outen, card->cfg_base + PITA_GPOEN); +} + +static void peak_pciec_init_pita_gpio(struct peak_pciec_card *card) +{ + /* raise SCL & SDA GPIOs to high-Z */ + pita_set_scl_highz(card); + pita_set_sda_highz(card); +} + +static void pita_setsda(void *data, int state) +{ + struct peak_pciec_card *card = (struct peak_pciec_card *)data; + u8 gp_out, gp_outen; + + /* set output sda always to 0 */ + gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SDA; + writeb(gp_out, card->cfg_base + PITA_GPOUT); + + /* control output sda with GPOEN */ + gp_outen = readb(card->cfg_base + PITA_GPOEN); + if (state) + gp_outen &= ~PITA_GPIN_SDA; + else + gp_outen |= PITA_GPIN_SDA; + + writeb(gp_outen, card->cfg_base + PITA_GPOEN); +} + +static void pita_setscl(void *data, int state) +{ + struct peak_pciec_card *card = (struct peak_pciec_card *)data; + u8 gp_out, gp_outen; + + /* set output scl always to 0 */ + gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SCL; + writeb(gp_out, card->cfg_base + PITA_GPOUT); + + /* control output scl with GPOEN */ + gp_outen = readb(card->cfg_base + PITA_GPOEN); + if (state) + gp_outen &= ~PITA_GPIN_SCL; + else + gp_outen |= PITA_GPIN_SCL; + + writeb(gp_outen, card->cfg_base + PITA_GPOEN); +} + +static int pita_getsda(void *data) +{ + struct peak_pciec_card *card = (struct peak_pciec_card *)data; + + /* set tristate */ + pita_set_sda_highz(card); + + return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SDA) ? 1 : 0; +} + +static int pita_getscl(void *data) +{ + struct peak_pciec_card *card = (struct peak_pciec_card *)data; + + /* set tristate */ + pita_set_scl_highz(card); + + return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SCL) ? 1 : 0; +} + +/* + * write commands to the LED chip though the I2C-bus of the PCAN-PCIeC + */ +static int peak_pciec_write_pca9553(struct peak_pciec_card *card, + u8 offset, u8 data) +{ + u8 buffer[2] = { + offset, + data + }; + struct i2c_msg msg = { + .addr = PCA9553_1_SLAVEADDR, + .len = 2, + .buf = buffer, + }; + int ret; + + /* cache led mask */ + if ((offset == 5) && (data == card->led_cache)) + return 0; + + ret = i2c_transfer(&card->led_chip, &msg, 1); + if (ret < 0) + return ret; + + if (offset == 5) + card->led_cache = data; + + return 0; +} + +/* + * delayed work callback used to control the LEDs + */ +static void peak_pciec_led_work(struct work_struct *work) +{ + struct peak_pciec_card *card = + container_of(work, struct peak_pciec_card, led_work.work); + struct net_device *netdev; + u8 new_led = card->led_cache; + int i, up_count = 0; + + /* first check what is to do */ + for (i = 0; i < card->chan_count; i++) { + /* default is: not configured */ + new_led &= ~PCA9553_LED_MASK(i); + new_led |= PCA9553_LED_ON(i); + + netdev = card->channel[i].netdev; + if (!netdev || !(netdev->flags & IFF_UP)) + continue; + + up_count++; + + /* no activity (but configured) */ + new_led &= ~PCA9553_LED_MASK(i); + new_led |= PCA9553_LED_SLOW(i); + + /* if bytes counters changed, set fast blinking led */ + if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { + card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; + new_led &= ~PCA9553_LED_MASK(i); + new_led |= PCA9553_LED_FAST(i); + } + if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { + card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; + new_led &= ~PCA9553_LED_MASK(i); + new_led |= PCA9553_LED_FAST(i); + } + } + + /* check if LS0 settings changed, only update i2c if so */ + peak_pciec_write_pca9553(card, 5, new_led); + + /* restart timer (except if no more configured channels) */ + if (up_count) + schedule_delayed_work(&card->led_work, HZ); +} + +/* + * set LEDs blinking state + */ +static void peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s) +{ + u8 new_led = card->led_cache; + int i; + + /* first check what is to do */ + for (i = 0; i < card->chan_count; i++) + if (led_mask & PCA9553_LED(i)) { + new_led &= ~PCA9553_LED_MASK(i); + new_led |= PCA9553_LED_STATE(s, i); + } + + /* check if LS0 settings changed, only update i2c if so */ + peak_pciec_write_pca9553(card, 5, new_led); +} + +/* + * start one second delayed work to control LEDs + */ +static void peak_pciec_start_led_work(struct peak_pciec_card *card) +{ + if (!delayed_work_pending(&card->led_work)) + schedule_delayed_work(&card->led_work, HZ); +} + +/* + * stop LEDs delayed work + */ +static void peak_pciec_stop_led_work(struct peak_pciec_card *card) +{ + cancel_delayed_work_sync(&card->led_work); +} + +/* + * initialize the PCA9553 4-bit I2C-bus LED chip + */ +static int peak_pciec_init_leds(struct peak_pciec_card *card) +{ + int err; + + /* prescaler for frequency 0: "SLOW" = 1 Hz = "44" */ + err = peak_pciec_write_pca9553(card, 1, 44 / 1); + if (err) + return err; + + /* duty cycle 0: 50% */ + err = peak_pciec_write_pca9553(card, 2, 0x80); + if (err) + return err; + + /* prescaler for frequency 1: "FAST" = 5 Hz */ + err = peak_pciec_write_pca9553(card, 3, 44 / 5); + if (err) + return err; + + /* duty cycle 1: 50% */ + err = peak_pciec_write_pca9553(card, 4, 0x80); + if (err) + return err; + + /* switch LEDs to initial state */ + return peak_pciec_write_pca9553(card, 5, PCA9553_LS0_INIT); +} + +/* + * restore LEDs state to off peak_pciec_leds_exit + */ +static void peak_pciec_leds_exit(struct peak_pciec_card *card) +{ + /* switch LEDs to off */ + peak_pciec_write_pca9553(card, 5, PCA9553_LED_OFF_ALL); +} + +/* + * normal write sja1000 register method overloaded to catch when controller + * is started or stopped, to control leds + */ +static void peak_pciec_write_reg(const struct sja1000_priv *priv, + int port, u8 val) +{ + struct peak_pci_chan *chan = priv->priv; + struct peak_pciec_card *card = chan->pciec_card; + int c = (priv->reg_base - card->reg_base) / PEAK_PCI_CHAN_SIZE; + + /* sja1000 register changes control the leds state */ + if (port == REG_MOD) + switch (val) { + case MOD_RM: + /* Reset Mode: set led on */ + peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_ON); + break; + case 0x00: + /* Normal Mode: led slow blinking and start led timer */ + peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_SLOW); + peak_pciec_start_led_work(card); + break; + default: + break; + } + + /* call base function */ + peak_pci_write_reg(priv, port, val); +} + +static struct i2c_algo_bit_data peak_pciec_i2c_bit_ops = { + .setsda = pita_setsda, + .setscl = pita_setscl, + .getsda = pita_getsda, + .getscl = pita_getscl, + .udelay = 10, + .timeout = HZ, +}; + +static int peak_pciec_probe(struct pci_dev *pdev, struct net_device *dev) +{ + struct sja1000_priv *priv = netdev_priv(dev); + struct peak_pci_chan *chan = priv->priv; + struct peak_pciec_card *card; + int err; + + /* copy i2c object address from 1st channel */ + if (chan->prev_dev) { + struct sja1000_priv *prev_priv = netdev_priv(chan->prev_dev); + struct peak_pci_chan *prev_chan = prev_priv->priv; + + card = prev_chan->pciec_card; + if (!card) + return -ENODEV; + + /* channel is the first one: do the init part */ + } else { + /* create the bit banging I2C adapter structure */ + card = kzalloc(sizeof(struct peak_pciec_card), GFP_KERNEL); + if (!card) { + dev_err(&pdev->dev, + "failed allocating memory for i2c chip\n"); + return -ENOMEM; + } + + card->cfg_base = chan->cfg_base; + card->reg_base = priv->reg_base; + + card->led_chip.owner = THIS_MODULE; + card->led_chip.dev.parent = &pdev->dev; + card->led_chip.algo_data = &card->i2c_bit; + strncpy(card->led_chip.name, "peak_i2c", + sizeof(card->led_chip.name)); + + card->i2c_bit = peak_pciec_i2c_bit_ops; + card->i2c_bit.udelay = 10; + card->i2c_bit.timeout = HZ; + card->i2c_bit.data = card; + + peak_pciec_init_pita_gpio(card); + + err = i2c_bit_add_bus(&card->led_chip); + if (err) { + dev_err(&pdev->dev, "i2c init failed\n"); + goto pciec_init_err_1; + } + + err = peak_pciec_init_leds(card); + if (err) { + dev_err(&pdev->dev, "leds hardware init failed\n"); + goto pciec_init_err_2; + } + + INIT_DELAYED_WORK(&card->led_work, peak_pciec_led_work); + /* PCAN-ExpressCard needs its own callback for leds */ + priv->write_reg = peak_pciec_write_reg; + } + + chan->pciec_card = card; + card->channel[card->chan_count++].netdev = dev; + + return 0; + +pciec_init_err_2: + i2c_del_adapter(&card->led_chip); + +pciec_init_err_1: + peak_pciec_init_pita_gpio(card); + kfree(card); + + return err; +} + +static void peak_pciec_remove(struct peak_pciec_card *card) +{ + peak_pciec_stop_led_work(card); + peak_pciec_leds_exit(card); + i2c_del_adapter(&card->led_chip); + peak_pciec_init_pita_gpio(card); + kfree(card); +} + +#else /* CONFIG_CAN_PEAK_PCIEC */ + +/* + * Placebo functions when PCAN-ExpressCard support is not selected + */ +static inline int peak_pciec_probe(struct pci_dev *pdev, struct net_device *dev) +{ + return -ENODEV; +} + +static inline void peak_pciec_remove(struct peak_pciec_card *card) +{ +} +#endif /* CONFIG_CAN_PEAK_PCIEC */ + static u8 peak_pci_read_reg(const struct sja1000_priv *priv, int port) { return readb(priv->reg_base + (port << 2)); @@ -188,17 +637,31 @@ static int __devinit peak_pci_probe(struct pci_dev *pdev, SET_NETDEV_DEV(dev, &pdev->dev); + /* Create chain of SJA1000 devices */ + chan->prev_dev = pci_get_drvdata(pdev); + pci_set_drvdata(pdev, dev); + + /* + * PCAN-ExpressCard needs some additional i2c init. + * This must be done *before* register_sja1000dev() but + * *after* devices linkage + */ + if (pdev->device == PEAK_PCIEC_DEVICE_ID) { + err = peak_pciec_probe(pdev, dev); + if (err) { + dev_err(&pdev->dev, + "failed to probe device (err %d)\n", + err); + goto failure_free_dev; + } + } + err = register_sja1000dev(dev); if (err) { dev_err(&pdev->dev, "failed to register device\n"); - free_sja1000dev(dev); - goto failure_remove_channels; + goto failure_free_dev; } - /* Create chain of SJA1000 devices */ - chan->prev_dev = pci_get_drvdata(pdev); - pci_set_drvdata(pdev, dev); - dev_info(&pdev->dev, "%s at reg_base=0x%p cfg_base=0x%p irq=%d\n", dev->name, priv->reg_base, chan->cfg_base, dev->irq); @@ -209,10 +672,15 @@ static int __devinit peak_pci_probe(struct pci_dev *pdev, return 0; +failure_free_dev: + pci_set_drvdata(pdev, chan->prev_dev); + free_sja1000dev(dev); + failure_remove_channels: /* Disable interrupts */ writew(0x0, cfg_base + PITA_ICR + 2); + chan = NULL; for (dev = pci_get_drvdata(pdev); dev; dev = chan->prev_dev) { unregister_sja1000dev(dev); free_sja1000dev(dev); @@ -220,6 +688,10 @@ static int __devinit peak_pci_probe(struct pci_dev *pdev, chan = priv->priv; } + /* free any PCIeC resources too */ + if (chan && chan->pciec_card) + peak_pciec_remove(chan->pciec_card); + pci_iounmap(pdev, reg_base); failure_unmap_cfg_base: @@ -251,8 +723,13 @@ static void __devexit peak_pci_remove(struct pci_dev *pdev) unregister_sja1000dev(dev); free_sja1000dev(dev); dev = chan->prev_dev; - if (!dev) + + if (!dev) { + /* do that only for first channel */ + if (chan->pciec_card) + peak_pciec_remove(chan->pciec_card); break; + } priv = netdev_priv(dev); chan = priv->priv; } -- GitLab From 2b61972b74219d21ef1e91178349bdb840357688 Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Fri, 2 Mar 2012 16:21:20 +0100 Subject: [PATCH 1301/1846] can: sja1000: add support for PEAK-System PCMCIA card This patch adds support to the PCAN-PC Card PCMCIA card from PEAK-System Technik (www.peak-system.com). This card is a CAN interface for the PC Card slot. It is available as a single or dual-channel version. Tested-by: Oliver Hartkopp Acked-by: Dominik Brodowski Signed-off-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- drivers/net/can/sja1000/Kconfig | 9 + drivers/net/can/sja1000/Makefile | 1 + drivers/net/can/sja1000/peak_pcmcia.c | 753 ++++++++++++++++++++++++++ 3 files changed, 763 insertions(+) create mode 100644 drivers/net/can/sja1000/peak_pcmcia.c diff --git a/drivers/net/can/sja1000/Kconfig b/drivers/net/can/sja1000/Kconfig index fdc39261d464..b60d6c5f29a0 100644 --- a/drivers/net/can/sja1000/Kconfig +++ b/drivers/net/can/sja1000/Kconfig @@ -43,6 +43,15 @@ config CAN_EMS_PCI CPC-PCIe and CPC-104P cards from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de). +config CAN_PEAK_PCMCIA + tristate "PEAK PCAN-PC Card" + depends on PCMCIA + ---help--- + This driver is for the PCAN-PC Card PCMCIA adapter (1 or 2 channels) + from PEAK-System (http://www.peak-system.com). To compile this + driver as a module, choose M here: the module will be called + peak_pcmcia. + config CAN_PEAK_PCI tristate "PEAK PCAN-PCI/PCIe/miniPCI Cards" depends on PCI diff --git a/drivers/net/can/sja1000/Makefile b/drivers/net/can/sja1000/Makefile index 0604f240c8b1..b3d05cbfec36 100644 --- a/drivers/net/can/sja1000/Makefile +++ b/drivers/net/can/sja1000/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_CAN_SJA1000_OF_PLATFORM) += sja1000_of_platform.o obj-$(CONFIG_CAN_EMS_PCMCIA) += ems_pcmcia.o obj-$(CONFIG_CAN_EMS_PCI) += ems_pci.o obj-$(CONFIG_CAN_KVASER_PCI) += kvaser_pci.o +obj-$(CONFIG_CAN_PEAK_PCMCIA) += peak_pcmcia.o obj-$(CONFIG_CAN_PEAK_PCI) += peak_pci.o obj-$(CONFIG_CAN_PLX_PCI) += plx_pci.o obj-$(CONFIG_CAN_TSCAN1) += tscan1.o diff --git a/drivers/net/can/sja1000/peak_pcmcia.c b/drivers/net/can/sja1000/peak_pcmcia.c new file mode 100644 index 000000000000..ec6bd9d1b2af --- /dev/null +++ b/drivers/net/can/sja1000/peak_pcmcia.c @@ -0,0 +1,753 @@ +/* + * Copyright (C) 2010-2012 Stephane Grosjean + * + * CAN driver for PEAK-System PCAN-PC Card + * Derived from the PCAN project file driver/src/pcan_pccard.c + * Copyright (C) 2006-2010 PEAK System-Technik GmbH + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the 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. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sja1000.h" + +MODULE_AUTHOR("Stephane Grosjean "); +MODULE_DESCRIPTION("CAN driver for PEAK-System PCAN-PC Cards"); +MODULE_LICENSE("GPL v2"); +MODULE_SUPPORTED_DEVICE("PEAK PCAN-PC Card"); + +/* PEAK-System PCMCIA driver name */ +#define PCC_NAME "peak_pcmcia" + +#define PCC_CHAN_MAX 2 + +#define PCC_CAN_CLOCK (16000000 / 2) + +#define PCC_MANF_ID 0x0377 +#define PCC_CARD_ID 0x0001 + +#define PCC_CHAN_SIZE 0x20 +#define PCC_CHAN_OFF(c) ((c) * PCC_CHAN_SIZE) +#define PCC_COMN_OFF (PCC_CHAN_OFF(PCC_CHAN_MAX)) +#define PCC_COMN_SIZE 0x40 + +/* common area registers */ +#define PCC_CCR 0x00 +#define PCC_CSR 0x02 +#define PCC_CPR 0x04 +#define PCC_SPI_DIR 0x06 +#define PCC_SPI_DOR 0x08 +#define PCC_SPI_ADR 0x0a +#define PCC_SPI_IR 0x0c +#define PCC_FW_MAJOR 0x10 +#define PCC_FW_MINOR 0x12 + +/* CCR bits */ +#define PCC_CCR_CLK_16 0x00 +#define PCC_CCR_CLK_10 0x01 +#define PCC_CCR_CLK_21 0x02 +#define PCC_CCR_CLK_8 0x03 +#define PCC_CCR_CLK_MASK PCC_CCR_CLK_8 + +#define PCC_CCR_RST_CHAN(c) (0x01 << ((c) + 2)) +#define PCC_CCR_RST_ALL (PCC_CCR_RST_CHAN(0) | PCC_CCR_RST_CHAN(1)) +#define PCC_CCR_RST_MASK PCC_CCR_RST_ALL + +/* led selection bits */ +#define PCC_LED(c) (1 << (c)) +#define PCC_LED_ALL (PCC_LED(0) | PCC_LED(1)) + +/* led state value */ +#define PCC_LED_ON 0x00 +#define PCC_LED_FAST 0x01 +#define PCC_LED_SLOW 0x02 +#define PCC_LED_OFF 0x03 + +#define PCC_CCR_LED_CHAN(s, c) ((s) << (((c) + 2) << 1)) + +#define PCC_CCR_LED_ON_CHAN(c) PCC_CCR_LED_CHAN(PCC_LED_ON, c) +#define PCC_CCR_LED_FAST_CHAN(c) PCC_CCR_LED_CHAN(PCC_LED_FAST, c) +#define PCC_CCR_LED_SLOW_CHAN(c) PCC_CCR_LED_CHAN(PCC_LED_SLOW, c) +#define PCC_CCR_LED_OFF_CHAN(c) PCC_CCR_LED_CHAN(PCC_LED_OFF, c) +#define PCC_CCR_LED_MASK_CHAN(c) PCC_CCR_LED_OFF_CHAN(c) +#define PCC_CCR_LED_OFF_ALL (PCC_CCR_LED_OFF_CHAN(0) | \ + PCC_CCR_LED_OFF_CHAN(1)) +#define PCC_CCR_LED_MASK PCC_CCR_LED_OFF_ALL + +#define PCC_CCR_INIT (PCC_CCR_CLK_16 | PCC_CCR_RST_ALL | PCC_CCR_LED_OFF_ALL) + +/* CSR bits */ +#define PCC_CSR_SPI_BUSY 0x04 + +/* time waiting for SPI busy (prevent from infinite loop) */ +#define PCC_SPI_MAX_BUSY_WAIT_MS 3 + +/* max count of reading the SPI status register waiting for a change */ +/* (prevent from infinite loop) */ +#define PCC_WRITE_MAX_LOOP 1000 + +/* max nb of int handled by that isr in one shot (prevent from infinite loop) */ +#define PCC_ISR_MAX_LOOP 10 + +/* EEPROM chip instruction set */ +/* note: EEPROM Read/Write instructions include A8 bit */ +#define PCC_EEP_WRITE(a) (0x02 | (((a) & 0x100) >> 5)) +#define PCC_EEP_READ(a) (0x03 | (((a) & 0x100) >> 5)) +#define PCC_EEP_WRDI 0x04 /* EEPROM Write Disable */ +#define PCC_EEP_RDSR 0x05 /* EEPROM Read Status Register */ +#define PCC_EEP_WREN 0x06 /* EEPROM Write Enable */ + +/* EEPROM Status Register bits */ +#define PCC_EEP_SR_WEN 0x02 /* EEPROM SR Write Enable bit */ +#define PCC_EEP_SR_WIP 0x01 /* EEPROM SR Write In Progress bit */ + +/* + * The board configuration is probably following: + * RX1 is connected to ground. + * TX1 is not connected. + * CLKO is not connected. + * Setting the OCR register to 0xDA is a good idea. + * This means normal output mode, push-pull and the correct polarity. + */ +#define PCC_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL) + +/* + * In the CDR register, you should set CBP to 1. + * You will probably also want to set the clock divider value to 7 + * (meaning direct oscillator output) because the second SJA1000 chip + * is driven by the first one CLKOUT output. + */ +#define PCC_CDR (CDR_CBP | CDR_CLKOUT_MASK) + +struct pcan_channel { + struct net_device *netdev; + unsigned long prev_rx_bytes; + unsigned long prev_tx_bytes; +}; + +/* PCAN-PC Card private structure */ +struct pcan_pccard { + struct pcmcia_device *pdev; + int chan_count; + struct pcan_channel channel[PCC_CHAN_MAX]; + u8 ccr; + u8 fw_major; + u8 fw_minor; + void __iomem *ioport_addr; + struct timer_list led_timer; +}; + +static struct pcmcia_device_id pcan_table[] = { + PCMCIA_DEVICE_MANF_CARD(PCC_MANF_ID, PCC_CARD_ID), + PCMCIA_DEVICE_NULL, +}; + +MODULE_DEVICE_TABLE(pcmcia, pcan_table); + +static void pcan_set_leds(struct pcan_pccard *card, u8 mask, u8 state); + +/* + * start timer which controls leds state + */ +static void pcan_start_led_timer(struct pcan_pccard *card) +{ + if (!timer_pending(&card->led_timer)) + mod_timer(&card->led_timer, jiffies + HZ); +} + +/* + * stop the timer which controls leds state + */ +static void pcan_stop_led_timer(struct pcan_pccard *card) +{ + del_timer_sync(&card->led_timer); +} + +/* + * read a sja1000 register + */ +static u8 pcan_read_canreg(const struct sja1000_priv *priv, int port) +{ + return ioread8(priv->reg_base + port); +} + +/* + * write a sja1000 register + */ +static void pcan_write_canreg(const struct sja1000_priv *priv, int port, u8 v) +{ + struct pcan_pccard *card = priv->priv; + int c = (priv->reg_base - card->ioport_addr) / PCC_CHAN_SIZE; + + /* sja1000 register changes control the leds state */ + if (port == REG_MOD) + switch (v) { + case MOD_RM: + /* Reset Mode: set led on */ + pcan_set_leds(card, PCC_LED(c), PCC_LED_ON); + break; + case 0x00: + /* Normal Mode: led slow blinking and start led timer */ + pcan_set_leds(card, PCC_LED(c), PCC_LED_SLOW); + pcan_start_led_timer(card); + break; + default: + break; + } + + iowrite8(v, priv->reg_base + port); +} + +/* + * read a register from the common area + */ +static u8 pcan_read_reg(struct pcan_pccard *card, int port) +{ + return ioread8(card->ioport_addr + PCC_COMN_OFF + port); +} + +/* + * write a register into the common area + */ +static void pcan_write_reg(struct pcan_pccard *card, int port, u8 v) +{ + /* cache ccr value */ + if (port == PCC_CCR) { + if (card->ccr == v) + return; + card->ccr = v; + } + + iowrite8(v, card->ioport_addr + PCC_COMN_OFF + port); +} + +/* + * check whether the card is present by checking its fw version numbers + * against values read at probing time. + */ +static inline int pcan_pccard_present(struct pcan_pccard *card) +{ + return ((pcan_read_reg(card, PCC_FW_MAJOR) == card->fw_major) && + (pcan_read_reg(card, PCC_FW_MINOR) == card->fw_minor)); +} + +/* + * wait for SPI engine while it is busy + */ +static int pcan_wait_spi_busy(struct pcan_pccard *card) +{ + unsigned long timeout = jiffies + + msecs_to_jiffies(PCC_SPI_MAX_BUSY_WAIT_MS) + 1; + + /* be sure to read status at least once after sleeping */ + while (pcan_read_reg(card, PCC_CSR) & PCC_CSR_SPI_BUSY) { + if (time_after(jiffies, timeout)) + return -EBUSY; + schedule(); + } + + return 0; +} + +/* + * write data in device eeprom + */ +static int pcan_write_eeprom(struct pcan_pccard *card, u16 addr, u8 v) +{ + u8 status; + int err, i; + + /* write instruction enabling write */ + pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_WREN); + err = pcan_wait_spi_busy(card); + if (err) + goto we_spi_err; + + /* wait until write enabled */ + for (i = 0; i < PCC_WRITE_MAX_LOOP; i++) { + /* write instruction reading the status register */ + pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_RDSR); + err = pcan_wait_spi_busy(card); + if (err) + goto we_spi_err; + + /* get status register value and check write enable bit */ + status = pcan_read_reg(card, PCC_SPI_DIR); + if (status & PCC_EEP_SR_WEN) + break; + } + + if (i >= PCC_WRITE_MAX_LOOP) { + dev_err(&card->pdev->dev, + "stop waiting to be allowed to write in eeprom\n"); + return -EIO; + } + + /* set address and data */ + pcan_write_reg(card, PCC_SPI_ADR, addr & 0xff); + pcan_write_reg(card, PCC_SPI_DOR, v); + + /* + * write instruction with bit[3] set according to address value: + * if addr refers to upper half of the memory array: bit[3] = 1 + */ + pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_WRITE(addr)); + err = pcan_wait_spi_busy(card); + if (err) + goto we_spi_err; + + /* wait while write in progress */ + for (i = 0; i < PCC_WRITE_MAX_LOOP; i++) { + /* write instruction reading the status register */ + pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_RDSR); + err = pcan_wait_spi_busy(card); + if (err) + goto we_spi_err; + + /* get status register value and check write in progress bit */ + status = pcan_read_reg(card, PCC_SPI_DIR); + if (!(status & PCC_EEP_SR_WIP)) + break; + } + + if (i >= PCC_WRITE_MAX_LOOP) { + dev_err(&card->pdev->dev, + "stop waiting for write in eeprom to complete\n"); + return -EIO; + } + + /* write instruction disabling write */ + pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_WRDI); + err = pcan_wait_spi_busy(card); + if (err) + goto we_spi_err; + + return 0; + +we_spi_err: + dev_err(&card->pdev->dev, + "stop waiting (spi engine always busy) err %d\n", err); + + return err; +} + +static void pcan_set_leds(struct pcan_pccard *card, u8 led_mask, u8 state) +{ + u8 ccr = card->ccr; + int i; + + for (i = 0; i < card->chan_count; i++) + if (led_mask & PCC_LED(i)) { + /* clear corresponding led bits in ccr */ + ccr &= ~PCC_CCR_LED_MASK_CHAN(i); + /* then set new bits */ + ccr |= PCC_CCR_LED_CHAN(state, i); + } + + /* real write only if something has changed in ccr */ + pcan_write_reg(card, PCC_CCR, ccr); +} + +/* + * enable/disable CAN connectors power + */ +static inline void pcan_set_can_power(struct pcan_pccard *card, int onoff) +{ + int err; + + err = pcan_write_eeprom(card, 0, !!onoff); + if (err) + dev_err(&card->pdev->dev, + "failed setting power %s to can connectors (err %d)\n", + (onoff) ? "on" : "off", err); +} + +/* + * set leds state according to channel activity + */ +static void pcan_led_timer(unsigned long arg) +{ + struct pcan_pccard *card = (struct pcan_pccard *)arg; + struct net_device *netdev; + int i, up_count = 0; + u8 ccr; + + ccr = card->ccr; + for (i = 0; i < card->chan_count; i++) { + /* default is: not configured */ + ccr &= ~PCC_CCR_LED_MASK_CHAN(i); + ccr |= PCC_CCR_LED_ON_CHAN(i); + + netdev = card->channel[i].netdev; + if (!netdev || !(netdev->flags & IFF_UP)) + continue; + + up_count++; + + /* no activity (but configured) */ + ccr &= ~PCC_CCR_LED_MASK_CHAN(i); + ccr |= PCC_CCR_LED_SLOW_CHAN(i); + + /* if bytes counters changed, set fast blinking led */ + if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { + card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; + ccr &= ~PCC_CCR_LED_MASK_CHAN(i); + ccr |= PCC_CCR_LED_FAST_CHAN(i); + } + if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { + card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; + ccr &= ~PCC_CCR_LED_MASK_CHAN(i); + ccr |= PCC_CCR_LED_FAST_CHAN(i); + } + } + + /* write the new leds state */ + pcan_write_reg(card, PCC_CCR, ccr); + + /* restart timer (except if no more configured channels) */ + if (up_count) + mod_timer(&card->led_timer, jiffies + HZ); +} + +/* + * interrupt service routine + */ +static irqreturn_t pcan_isr(int irq, void *dev_id) +{ + struct pcan_pccard *card = dev_id; + int irq_handled; + + /* prevent from infinite loop */ + for (irq_handled = 0; irq_handled < PCC_ISR_MAX_LOOP; irq_handled++) { + /* handle shared interrupt and next loop */ + int nothing_to_handle = 1; + int i; + + /* check interrupt for each channel */ + for (i = 0; i < card->chan_count; i++) { + struct net_device *netdev; + + /* + * check whether the card is present before calling + * sja1000_interrupt() to speed up hotplug detection + */ + if (!pcan_pccard_present(card)) { + /* card unplugged during isr */ + return IRQ_NONE; + } + + /* + * should check whether all or SJA1000_MAX_IRQ + * interrupts have been handled: loop again to be sure. + */ + netdev = card->channel[i].netdev; + if (netdev && + sja1000_interrupt(irq, netdev) == IRQ_HANDLED) + nothing_to_handle = 0; + } + + if (nothing_to_handle) + break; + } + + return (irq_handled) ? IRQ_HANDLED : IRQ_NONE; +} + +/* + * free all resources used by the channels and switch off leds and can power + */ +static void pcan_free_channels(struct pcan_pccard *card) +{ + int i; + u8 led_mask = 0; + + for (i = 0; i < card->chan_count; i++) { + struct net_device *netdev; + char name[IFNAMSIZ]; + + led_mask |= PCC_LED(i); + + netdev = card->channel[i].netdev; + if (!netdev) + continue; + + strncpy(name, netdev->name, IFNAMSIZ); + + unregister_sja1000dev(netdev); + + free_sja1000dev(netdev); + + dev_info(&card->pdev->dev, "%s removed\n", name); + } + + /* do it only if device not removed */ + if (pcan_pccard_present(card)) { + pcan_set_leds(card, led_mask, PCC_LED_OFF); + pcan_set_can_power(card, 0); + } +} + +/* + * check if a CAN controller is present at the specified location + */ +static inline int pcan_channel_present(struct sja1000_priv *priv) +{ + /* make sure SJA1000 is in reset mode */ + pcan_write_canreg(priv, REG_MOD, 1); + pcan_write_canreg(priv, REG_CDR, CDR_PELICAN); + + /* read reset-values */ + if (pcan_read_canreg(priv, REG_CDR) == CDR_PELICAN) + return 1; + + return 0; +} + +static int pcan_add_channels(struct pcan_pccard *card) +{ + struct pcmcia_device *pdev = card->pdev; + int i, err = 0; + u8 ccr = PCC_CCR_INIT; + + /* init common registers (reset channels and leds off) */ + card->ccr = ~ccr; + pcan_write_reg(card, PCC_CCR, ccr); + + /* wait 2ms before unresetting channels */ + mdelay(2); + + ccr &= ~PCC_CCR_RST_ALL; + pcan_write_reg(card, PCC_CCR, ccr); + + /* create one network device per channel detected */ + for (i = 0; i < ARRAY_SIZE(card->channel); i++) { + struct net_device *netdev; + struct sja1000_priv *priv; + + netdev = alloc_sja1000dev(0); + if (!netdev) { + err = -ENOMEM; + break; + } + + /* update linkages */ + priv = netdev_priv(netdev); + priv->priv = card; + SET_NETDEV_DEV(netdev, &pdev->dev); + + priv->irq_flags = IRQF_SHARED; + netdev->irq = pdev->irq; + priv->reg_base = card->ioport_addr + PCC_CHAN_OFF(i); + + /* check if channel is present */ + if (!pcan_channel_present(priv)) { + dev_err(&pdev->dev, "channel %d not present\n", i); + free_sja1000dev(netdev); + continue; + } + + priv->read_reg = pcan_read_canreg; + priv->write_reg = pcan_write_canreg; + priv->can.clock.freq = PCC_CAN_CLOCK; + priv->ocr = PCC_OCR; + priv->cdr = PCC_CDR; + + /* Neither a slave device distributes the clock */ + if (i > 0) + priv->cdr |= CDR_CLK_OFF; + + priv->flags |= SJA1000_CUSTOM_IRQ_HANDLER; + + /* register SJA1000 device */ + err = register_sja1000dev(netdev); + if (err) { + free_sja1000dev(netdev); + continue; + } + + card->channel[i].netdev = netdev; + card->chan_count++; + + /* set corresponding led on in the new ccr */ + ccr &= ~PCC_CCR_LED_OFF_CHAN(i); + + dev_info(&pdev->dev, + "%s on channel %d at 0x%p irq %d\n", + netdev->name, i, priv->reg_base, pdev->irq); + } + + /* write new ccr (change leds state) */ + pcan_write_reg(card, PCC_CCR, ccr); + + return err; +} + +static int pcan_conf_check(struct pcmcia_device *pdev, void *priv_data) +{ + pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; + pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; /* only */ + pdev->io_lines = 10; + + /* This reserves IO space but doesn't actually enable it */ + return pcmcia_request_io(pdev); +} + +/* + * free all resources used by the device + */ +static void pcan_free(struct pcmcia_device *pdev) +{ + struct pcan_pccard *card = pdev->priv; + + if (!card) + return; + + free_irq(pdev->irq, card); + pcan_stop_led_timer(card); + + pcan_free_channels(card); + + ioport_unmap(card->ioport_addr); + + kfree(card); + pdev->priv = NULL; +} + +/* + * setup PCMCIA socket and probe for PEAK-System PC-CARD + */ +static int __devinit pcan_probe(struct pcmcia_device *pdev) +{ + struct pcan_pccard *card; + int err; + + pdev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; + + err = pcmcia_loop_config(pdev, pcan_conf_check, NULL); + if (err) { + dev_err(&pdev->dev, "pcmcia_loop_config() error %d\n", err); + goto probe_err_1; + } + + if (!pdev->irq) { + dev_err(&pdev->dev, "no irq assigned\n"); + err = -ENODEV; + goto probe_err_1; + } + + err = pcmcia_enable_device(pdev); + if (err) { + dev_err(&pdev->dev, "pcmcia_enable_device failed err=%d\n", + err); + goto probe_err_1; + } + + card = kzalloc(sizeof(struct pcan_pccard), GFP_KERNEL); + if (!card) { + dev_err(&pdev->dev, "couldn't allocate card memory\n"); + err = -ENOMEM; + goto probe_err_2; + } + + card->pdev = pdev; + pdev->priv = card; + + /* sja1000 api uses iomem */ + card->ioport_addr = ioport_map(pdev->resource[0]->start, + resource_size(pdev->resource[0])); + if (!card->ioport_addr) { + dev_err(&pdev->dev, "couldn't map io port into io memory\n"); + err = -ENOMEM; + goto probe_err_3; + } + card->fw_major = pcan_read_reg(card, PCC_FW_MAJOR); + card->fw_minor = pcan_read_reg(card, PCC_FW_MINOR); + + /* display board name and firware version */ + dev_info(&pdev->dev, "PEAK-System pcmcia card %s fw %d.%d\n", + pdev->prod_id[1] ? pdev->prod_id[1] : "PCAN-PC Card", + card->fw_major, card->fw_minor); + + /* detect available channels */ + pcan_add_channels(card); + if (!card->chan_count) + goto probe_err_4; + + /* init the timer which controls the leds */ + init_timer(&card->led_timer); + card->led_timer.function = pcan_led_timer; + card->led_timer.data = (unsigned long)card; + + /* request the given irq */ + err = request_irq(pdev->irq, &pcan_isr, IRQF_SHARED, PCC_NAME, card); + if (err) { + dev_err(&pdev->dev, "couldn't request irq%d\n", pdev->irq); + goto probe_err_5; + } + + /* power on the connectors */ + pcan_set_can_power(card, 1); + + return 0; + +probe_err_5: + /* unregister can devices from network */ + pcan_free_channels(card); + +probe_err_4: + ioport_unmap(card->ioport_addr); + +probe_err_3: + kfree(card); + pdev->priv = NULL; + +probe_err_2: + pcmcia_disable_device(pdev); + +probe_err_1: + return err; +} + +/* + * release claimed resources + */ +static void pcan_remove(struct pcmcia_device *pdev) +{ + pcan_free(pdev); + pcmcia_disable_device(pdev); +} + +static struct pcmcia_driver pcan_driver = { + .name = PCC_NAME, + .probe = pcan_probe, + .remove = pcan_remove, + .id_table = pcan_table, +}; + +static int __init pcan_init(void) +{ + return pcmcia_register_driver(&pcan_driver); +} +module_init(pcan_init); + +static void __exit pcan_exit(void) +{ + pcmcia_unregister_driver(&pcan_driver); +} +module_exit(pcan_exit); -- GitLab From bb4785551f64e18b2c8bb15a3bd2b22f5ebf624d Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Fri, 2 Mar 2012 16:13:04 +0100 Subject: [PATCH 1302/1846] can: usb: PEAK-System Technik USB adapters driver core This patch adds the core of the peak_usb driver which handles PEAK-System Technik PCAN USB adapters. It defines the parts which are common to the PCAN-USB adapters: can network interfaces management, network-to/from-usb data path interface, timestamps management... Tested-by: Oliver Hartkopp Acked-by: Wolfgang Grandegger Signed-off-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/Kconfig | 6 + drivers/net/can/usb/Makefile | 1 + drivers/net/can/usb/peak_usb/Makefile | 2 + drivers/net/can/usb/peak_usb/pcan_usb_core.c | 951 +++++++++++++++++++ drivers/net/can/usb/peak_usb/pcan_usb_core.h | 146 +++ 5 files changed, 1106 insertions(+) create mode 100644 drivers/net/can/usb/peak_usb/Makefile create mode 100644 drivers/net/can/usb/peak_usb/pcan_usb_core.c create mode 100644 drivers/net/can/usb/peak_usb/pcan_usb_core.h diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig index 04525495b15b..0a6876841c20 100644 --- a/drivers/net/can/usb/Kconfig +++ b/drivers/net/can/usb/Kconfig @@ -13,4 +13,10 @@ config CAN_ESD_USB2 This driver supports the CAN-USB/2 interface from esd electronic system design gmbh (http://www.esd.eu). +config CAN_PEAK_USB + tristate "PEAK PCAN-USB/USB Pro interfaces" + ---help--- + This driver supports the PCAN-USB and PCAN-USB Pro adapters + from PEAK-System Technik (http://www.peak-system.com). + endmenu diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile index fce3cf11719f..da6d1d3b2969 100644 --- a/drivers/net/can/usb/Makefile +++ b/drivers/net/can/usb/Makefile @@ -4,5 +4,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o +obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/ ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG diff --git a/drivers/net/can/usb/peak_usb/Makefile b/drivers/net/can/usb/peak_usb/Makefile new file mode 100644 index 000000000000..bbb23ceb65f6 --- /dev/null +++ b/drivers/net/can/usb/peak_usb/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_CAN_PEAK_USB) += peak_usb.o +peak_usb-y = pcan_usb_core.o diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c new file mode 100644 index 000000000000..d2f91f737871 --- /dev/null +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -0,0 +1,951 @@ +/* + * CAN driver for PEAK System USB adapters + * Derived from the PCAN project file driver/src/pcan_usb_core.c + * + * Copyright (C) 2003-2010 PEAK System-Technik GmbH + * Copyright (C) 2010-2012 Stephane Grosjean + * + * Many thanks to Klaus Hitschler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * 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. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "pcan_usb_core.h" + +MODULE_AUTHOR("Stephane Grosjean "); +MODULE_DESCRIPTION("CAN driver for PEAK-System USB adapters"); +MODULE_LICENSE("GPL v2"); + +/* Table of devices that work with this driver */ +static struct usb_device_id peak_usb_table[] = { + {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USB_PRODUCT_ID)}, + {USB_DEVICE(PCAN_USB_VENDOR_ID, PCAN_USBPRO_PRODUCT_ID)}, + {} /* Terminating entry */ +}; + +MODULE_DEVICE_TABLE(usb, peak_usb_table); + +/* List of supported PCAN-USB adapters (NULL terminated list) */ +static struct peak_usb_adapter *peak_usb_adapters_list[] = { + &pcan_usb, + &pcan_usb_pro, + NULL, +}; + +/* + * dump memory + */ +#define DUMP_WIDTH 16 +void dump_mem(char *prompt, void *p, int l) +{ + pr_info("%s dumping %s (%d bytes):\n", + PCAN_USB_DRIVER_NAME, prompt ? prompt : "memory", l); + print_hex_dump(KERN_INFO, PCAN_USB_DRIVER_NAME " ", DUMP_PREFIX_NONE, + DUMP_WIDTH, 1, p, l, false); +} + +/* + * initialize a time_ref object with usb adapter own settings + */ +void peak_usb_init_time_ref(struct peak_time_ref *time_ref, + struct peak_usb_adapter *adapter) +{ + if (time_ref) { + memset(time_ref, 0, sizeof(struct peak_time_ref)); + time_ref->adapter = adapter; + } +} + +static void peak_usb_add_us(struct timeval *tv, u32 delta_us) +{ + /* number of s. to add to final time */ + u32 delta_s = delta_us / 1000000; + + delta_us -= delta_s * 1000000; + + tv->tv_usec += delta_us; + if (tv->tv_usec >= 1000000) { + tv->tv_usec -= 1000000; + delta_s++; + } + tv->tv_sec += delta_s; +} + +/* + * sometimes, another now may be more recent than current one... + */ +void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now) +{ + time_ref->ts_dev_2 = ts_now; + + /* should wait at least two passes before computing */ + if (time_ref->tv_host.tv_sec > 0) { + u32 delta_ts = time_ref->ts_dev_2 - time_ref->ts_dev_1; + + if (time_ref->ts_dev_2 < time_ref->ts_dev_1) + delta_ts &= (1 << time_ref->adapter->ts_used_bits) - 1; + + time_ref->ts_total += delta_ts; + } +} + +/* + * register device timestamp as now + */ +void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now) +{ + if (time_ref->tv_host_0.tv_sec == 0) { + /* use monotonic clock to correctly compute further deltas */ + time_ref->tv_host_0 = ktime_to_timeval(ktime_get()); + time_ref->tv_host.tv_sec = 0; + } else { + /* + * delta_us should not be >= 2^32 => delta_s should be < 4294 + * handle 32-bits wrapping here: if count of s. reaches 4200, + * reset counters and change time base + */ + if (time_ref->tv_host.tv_sec != 0) { + u32 delta_s = time_ref->tv_host.tv_sec + - time_ref->tv_host_0.tv_sec; + if (delta_s > 4200) { + time_ref->tv_host_0 = time_ref->tv_host; + time_ref->ts_total = 0; + } + } + + time_ref->tv_host = ktime_to_timeval(ktime_get()); + time_ref->tick_count++; + } + + time_ref->ts_dev_1 = time_ref->ts_dev_2; + peak_usb_update_ts_now(time_ref, ts_now); +} + +/* + * compute timeval according to current ts and time_ref data + */ +void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts, + struct timeval *tv) +{ + /* protect from getting timeval before setting now */ + if (time_ref->tv_host.tv_sec > 0) { + u64 delta_us; + + delta_us = ts - time_ref->ts_dev_2; + if (ts < time_ref->ts_dev_2) + delta_us &= (1 << time_ref->adapter->ts_used_bits) - 1; + + delta_us += time_ref->ts_total; + + delta_us *= time_ref->adapter->us_per_ts_scale; + delta_us >>= time_ref->adapter->us_per_ts_shift; + + *tv = time_ref->tv_host_0; + peak_usb_add_us(tv, (u32)delta_us); + } else { + *tv = ktime_to_timeval(ktime_get()); + } +} + +/* + * callback for bulk Rx urb + */ +static void peak_usb_read_bulk_callback(struct urb *urb) +{ + struct peak_usb_device *dev = urb->context; + struct net_device *netdev; + int err; + + netdev = dev->netdev; + + if (!netif_device_present(netdev)) + return; + + /* check reception status */ + switch (urb->status) { + case 0: + /* success */ + break; + + case -EILSEQ: + case -ENOENT: + case -ECONNRESET: + case -ESHUTDOWN: + return; + + default: + if (net_ratelimit()) + netdev_err(netdev, + "Rx urb aborted (%d)\n", urb->status); + goto resubmit_urb; + } + + /* protect from any incoming empty msgs */ + if ((urb->actual_length > 0) && (dev->adapter->dev_decode_buf)) { + /* handle these kinds of msgs only if _start callback called */ + if (dev->state & PCAN_USB_STATE_STARTED) { + err = dev->adapter->dev_decode_buf(dev, urb); + if (err) + dump_mem("received usb message", + urb->transfer_buffer, + urb->transfer_buffer_length); + } + } + +resubmit_urb: + usb_fill_bulk_urb(urb, dev->udev, + usb_rcvbulkpipe(dev->udev, dev->ep_msg_in), + urb->transfer_buffer, dev->adapter->rx_buffer_size, + peak_usb_read_bulk_callback, dev); + + usb_anchor_urb(urb, &dev->rx_submitted); + err = usb_submit_urb(urb, GFP_ATOMIC); + if (!err) + return; + + usb_unanchor_urb(urb); + + if (err == -ENODEV) + netif_device_detach(netdev); + else + netdev_err(netdev, "failed resubmitting read bulk urb: %d\n", + err); +} + +/* + * callback for bulk Tx urb + */ +static void peak_usb_write_bulk_callback(struct urb *urb) +{ + struct peak_tx_urb_context *context = urb->context; + struct peak_usb_device *dev; + struct net_device *netdev; + + BUG_ON(!context); + + dev = context->dev; + netdev = dev->netdev; + + atomic_dec(&dev->active_tx_urbs); + + if (!netif_device_present(netdev)) + return; + + /* check tx status */ + switch (urb->status) { + case 0: + /* transmission complete */ + netdev->stats.tx_packets++; + netdev->stats.tx_bytes += context->dlc; + + /* prevent tx timeout */ + netdev->trans_start = jiffies; + break; + + default: + if (net_ratelimit()) + netdev_err(netdev, "Tx urb aborted (%d)\n", + urb->status); + case -EPROTO: + case -ENOENT: + case -ECONNRESET: + case -ESHUTDOWN: + + break; + } + + /* should always release echo skb and corresponding context */ + can_get_echo_skb(netdev, context->echo_index); + context->echo_index = PCAN_USB_MAX_TX_URBS; + + /* do wakeup tx queue in case of success only */ + if (!urb->status) + netif_wake_queue(netdev); +} + +/* + * called by netdev to send one skb on the CAN interface. + */ +static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb, + struct net_device *netdev) +{ + struct peak_usb_device *dev = netdev_priv(netdev); + struct peak_tx_urb_context *context = NULL; + struct net_device_stats *stats = &netdev->stats; + struct can_frame *cf = (struct can_frame *)skb->data; + struct urb *urb; + u8 *obuf; + int i, err; + size_t size = dev->adapter->tx_buffer_size; + + if (can_dropped_invalid_skb(netdev, skb)) + return NETDEV_TX_OK; + + for (i = 0; i < PCAN_USB_MAX_TX_URBS; i++) + if (dev->tx_contexts[i].echo_index == PCAN_USB_MAX_TX_URBS) { + context = dev->tx_contexts + i; + break; + } + + if (!context) { + /* should not occur except during restart */ + return NETDEV_TX_BUSY; + } + + urb = context->urb; + obuf = urb->transfer_buffer; + + err = dev->adapter->dev_encode_msg(dev, skb, obuf, &size); + if (err) { + if (net_ratelimit()) + netdev_err(netdev, "packet dropped\n"); + dev_kfree_skb(skb); + stats->tx_dropped++; + return NETDEV_TX_OK; + } + + context->echo_index = i; + context->dlc = cf->can_dlc; + + usb_anchor_urb(urb, &dev->tx_submitted); + + can_put_echo_skb(skb, netdev, context->echo_index); + + atomic_inc(&dev->active_tx_urbs); + + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err) { + can_free_echo_skb(netdev, context->echo_index); + + usb_unanchor_urb(urb); + + /* this context is not used in fact */ + context->echo_index = PCAN_USB_MAX_TX_URBS; + + atomic_dec(&dev->active_tx_urbs); + + switch (err) { + case -ENODEV: + netif_device_detach(netdev); + break; + default: + netdev_warn(netdev, "tx urb submitting failed err=%d\n", + err); + case -ENOENT: + /* cable unplugged */ + stats->tx_dropped++; + } + } else { + netdev->trans_start = jiffies; + + /* slow down tx path */ + if (atomic_read(&dev->active_tx_urbs) >= PCAN_USB_MAX_TX_URBS) + netif_stop_queue(netdev); + } + + return NETDEV_TX_OK; +} + +/* + * start the CAN interface. + * Rx and Tx urbs are allocated here. Rx urbs are submitted here. + */ +static int peak_usb_start(struct peak_usb_device *dev) +{ + struct net_device *netdev = dev->netdev; + int err, i; + + for (i = 0; i < PCAN_USB_MAX_RX_URBS; i++) { + struct urb *urb; + u8 *buf; + + /* create a URB, and a buffer for it, to receive usb messages */ + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) { + netdev_err(netdev, "No memory left for URBs\n"); + err = -ENOMEM; + break; + } + + buf = kmalloc(dev->adapter->rx_buffer_size, GFP_KERNEL); + if (!buf) { + netdev_err(netdev, "No memory left for USB buffer\n"); + usb_free_urb(urb); + err = -ENOMEM; + break; + } + + usb_fill_bulk_urb(urb, dev->udev, + usb_rcvbulkpipe(dev->udev, dev->ep_msg_in), + buf, dev->adapter->rx_buffer_size, + peak_usb_read_bulk_callback, dev); + + /* ask last usb_free_urb() to also kfree() transfer_buffer */ + urb->transfer_flags |= URB_FREE_BUFFER; + usb_anchor_urb(urb, &dev->rx_submitted); + + err = usb_submit_urb(urb, GFP_KERNEL); + if (err) { + if (err == -ENODEV) + netif_device_detach(dev->netdev); + + usb_unanchor_urb(urb); + kfree(buf); + usb_free_urb(urb); + break; + } + + /* drop reference, USB core will take care of freeing it */ + usb_free_urb(urb); + } + + /* did we submit any URBs? Warn if we was not able to submit all urbs */ + if (i < PCAN_USB_MAX_RX_URBS) { + if (i == 0) { + netdev_err(netdev, "couldn't setup any rx URB\n"); + return err; + } + + netdev_warn(netdev, "rx performance may be slow\n"); + } + + /* pre-alloc tx buffers and corresponding urbs */ + for (i = 0; i < PCAN_USB_MAX_TX_URBS; i++) { + struct peak_tx_urb_context *context; + struct urb *urb; + u8 *buf; + + /* create a URB and a buffer for it, to transmit usb messages */ + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) { + netdev_err(netdev, "No memory left for URBs\n"); + err = -ENOMEM; + break; + } + + buf = kmalloc(dev->adapter->tx_buffer_size, GFP_KERNEL); + if (!buf) { + netdev_err(netdev, "No memory left for USB buffer\n"); + usb_free_urb(urb); + err = -ENOMEM; + break; + } + + context = dev->tx_contexts + i; + context->dev = dev; + context->urb = urb; + + usb_fill_bulk_urb(urb, dev->udev, + usb_sndbulkpipe(dev->udev, dev->ep_msg_out), + buf, dev->adapter->tx_buffer_size, + peak_usb_write_bulk_callback, context); + + /* ask last usb_free_urb() to also kfree() transfer_buffer */ + urb->transfer_flags |= URB_FREE_BUFFER; + } + + /* warn if we were not able to allocate enough tx contexts */ + if (i < PCAN_USB_MAX_TX_URBS) { + if (i == 0) { + netdev_err(netdev, "couldn't setup any tx URB\n"); + return err; + } + + netdev_warn(netdev, "tx performance may be slow\n"); + } + + if (dev->adapter->dev_start) { + err = dev->adapter->dev_start(dev); + if (err) + goto failed; + } + + dev->state |= PCAN_USB_STATE_STARTED; + + /* can set bus on now */ + if (dev->adapter->dev_set_bus) { + err = dev->adapter->dev_set_bus(dev, 1); + if (err) + goto failed; + } + + dev->can.state = CAN_STATE_ERROR_ACTIVE; + + return 0; + +failed: + if (err == -ENODEV) + netif_device_detach(dev->netdev); + + netdev_warn(netdev, "couldn't submit control: %d\n", err); + + return err; +} + +/* + * called by netdev to open the corresponding CAN interface. + */ +static int peak_usb_ndo_open(struct net_device *netdev) +{ + struct peak_usb_device *dev = netdev_priv(netdev); + int err; + + /* common open */ + err = open_candev(netdev); + if (err) + return err; + + /* finally start device */ + err = peak_usb_start(dev); + if (err) { + netdev_err(netdev, "couldn't start device: %d\n", err); + close_candev(netdev); + return err; + } + + dev->open_time = jiffies; + netif_start_queue(netdev); + + return 0; +} + +/* + * unlink in-flight Rx and Tx urbs and free their memory. + */ +static void peak_usb_unlink_all_urbs(struct peak_usb_device *dev) +{ + int i; + + /* free all Rx (submitted) urbs */ + usb_kill_anchored_urbs(&dev->rx_submitted); + + /* free unsubmitted Tx urbs first */ + for (i = 0; i < PCAN_USB_MAX_TX_URBS; i++) { + struct urb *urb = dev->tx_contexts[i].urb; + + if (!urb || + dev->tx_contexts[i].echo_index != PCAN_USB_MAX_TX_URBS) { + /* + * this urb is already released or always submitted, + * let usb core free by itself + */ + continue; + } + + usb_free_urb(urb); + dev->tx_contexts[i].urb = NULL; + } + + /* then free all submitted Tx urbs */ + usb_kill_anchored_urbs(&dev->tx_submitted); + atomic_set(&dev->active_tx_urbs, 0); +} + +/* + * called by netdev to close the corresponding CAN interface. + */ +static int peak_usb_ndo_stop(struct net_device *netdev) +{ + struct peak_usb_device *dev = netdev_priv(netdev); + + dev->state &= ~PCAN_USB_STATE_STARTED; + netif_stop_queue(netdev); + + /* unlink all pending urbs and free used memory */ + peak_usb_unlink_all_urbs(dev); + + if (dev->adapter->dev_stop) + dev->adapter->dev_stop(dev); + + close_candev(netdev); + + dev->open_time = 0; + dev->can.state = CAN_STATE_STOPPED; + + /* can set bus off now */ + if (dev->adapter->dev_set_bus) { + int err = dev->adapter->dev_set_bus(dev, 0); + if (err) + return err; + } + + return 0; +} + +/* + * handle end of waiting for the device to reset + */ +void peak_usb_restart_complete(struct peak_usb_device *dev) +{ + /* finally MUST update can state */ + dev->can.state = CAN_STATE_ERROR_ACTIVE; + + /* netdev queue can be awaken now */ + netif_wake_queue(dev->netdev); +} + +void peak_usb_async_complete(struct urb *urb) +{ + kfree(urb->transfer_buffer); + usb_free_urb(urb); +} + +/* + * device (auto-)restart mechanism runs in a timer context => + * MUST handle restart with asynchronous usb transfers + */ +static int peak_usb_restart(struct peak_usb_device *dev) +{ + struct urb *urb; + int err; + u8 *buf; + + /* + * if device doesn't define any asynchronous restart handler, simply + * wake the netdev queue up + */ + if (!dev->adapter->dev_restart_async) { + peak_usb_restart_complete(dev); + return 0; + } + + /* first allocate a urb to handle the asynchronous steps */ + urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!urb) { + netdev_err(dev->netdev, "no memory left for urb\n"); + return -ENOMEM; + } + + /* also allocate enough space for the commands to send */ + buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC); + if (!buf) { + netdev_err(dev->netdev, "no memory left for async cmd\n"); + usb_free_urb(urb); + return -ENOMEM; + } + + /* call the device specific handler for the restart */ + err = dev->adapter->dev_restart_async(dev, urb, buf); + if (!err) + return 0; + + kfree(buf); + usb_free_urb(urb); + + return err; +} + +/* + * candev callback used to change CAN mode. + * Warning: this is called from a timer context! + */ +static int peak_usb_set_mode(struct net_device *netdev, enum can_mode mode) +{ + struct peak_usb_device *dev = netdev_priv(netdev); + int err = 0; + + if (!dev->open_time) + return -EINVAL; + + switch (mode) { + case CAN_MODE_START: + err = peak_usb_restart(dev); + if (err) + netdev_err(netdev, "couldn't start device (err %d)\n", + err); + break; + + default: + return -EOPNOTSUPP; + } + + return err; +} + +/* + * candev callback used to set device bitrate. + */ +static int peak_usb_set_bittiming(struct net_device *netdev) +{ + struct peak_usb_device *dev = netdev_priv(netdev); + struct can_bittiming *bt = &dev->can.bittiming; + + if (dev->adapter->dev_set_bittiming) { + int err = dev->adapter->dev_set_bittiming(dev, bt); + + if (err) + netdev_info(netdev, "couldn't set bitrate (err %d)\n", + err); + return err; + } + + return 0; +} + +static const struct net_device_ops peak_usb_netdev_ops = { + .ndo_open = peak_usb_ndo_open, + .ndo_stop = peak_usb_ndo_stop, + .ndo_start_xmit = peak_usb_ndo_start_xmit, +}; + +/* + * create one device which is attached to CAN controller #ctrl_idx of the + * usb adapter. + */ +static int peak_usb_create_dev(struct peak_usb_adapter *peak_usb_adapter, + struct usb_interface *intf, int ctrl_idx) +{ + struct usb_device *usb_dev = interface_to_usbdev(intf); + int sizeof_candev = peak_usb_adapter->sizeof_dev_private; + struct peak_usb_device *dev; + struct net_device *netdev; + int i, err; + u16 tmp16; + + if (sizeof_candev < sizeof(struct peak_usb_device)) + sizeof_candev = sizeof(struct peak_usb_device); + + netdev = alloc_candev(sizeof_candev, PCAN_USB_MAX_TX_URBS); + if (!netdev) { + dev_err(&intf->dev, "%s: couldn't alloc candev\n", + PCAN_USB_DRIVER_NAME); + return -ENOMEM; + } + + dev = netdev_priv(netdev); + + /* allocate a buffer large enough to send commands */ + dev->cmd_buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_KERNEL); + if (!dev->cmd_buf) { + dev_err(&intf->dev, "%s: couldn't alloc cmd buffer\n", + PCAN_USB_DRIVER_NAME); + err = -ENOMEM; + goto lbl_set_intf_data; + } + + dev->udev = usb_dev; + dev->netdev = netdev; + dev->adapter = peak_usb_adapter; + dev->ctrl_idx = ctrl_idx; + dev->state = PCAN_USB_STATE_CONNECTED; + + dev->ep_msg_in = peak_usb_adapter->ep_msg_in; + dev->ep_msg_out = peak_usb_adapter->ep_msg_out[ctrl_idx]; + + dev->can.clock = peak_usb_adapter->clock; + dev->can.bittiming_const = &peak_usb_adapter->bittiming_const; + dev->can.do_set_bittiming = peak_usb_set_bittiming; + dev->can.do_set_mode = peak_usb_set_mode; + dev->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | + CAN_CTRLMODE_LISTENONLY; + + netdev->netdev_ops = &peak_usb_netdev_ops; + + netdev->flags |= IFF_ECHO; /* we support local echo */ + + init_usb_anchor(&dev->rx_submitted); + + init_usb_anchor(&dev->tx_submitted); + atomic_set(&dev->active_tx_urbs, 0); + + for (i = 0; i < PCAN_USB_MAX_TX_URBS; i++) + dev->tx_contexts[i].echo_index = PCAN_USB_MAX_TX_URBS; + + dev->prev_siblings = usb_get_intfdata(intf); + usb_set_intfdata(intf, dev); + + SET_NETDEV_DEV(netdev, &intf->dev); + + err = register_candev(netdev); + if (err) { + dev_err(&intf->dev, "couldn't register CAN device: %d\n", err); + goto lbl_free_cmd_buf; + } + + if (dev->prev_siblings) + (dev->prev_siblings)->next_siblings = dev; + + /* keep hw revision into the netdevice */ + tmp16 = le16_to_cpu(usb_dev->descriptor.bcdDevice); + dev->device_rev = tmp16 >> 8; + + if (dev->adapter->dev_init) { + err = dev->adapter->dev_init(dev); + if (err) + goto lbl_free_cmd_buf; + } + + /* set bus off */ + if (dev->adapter->dev_set_bus) { + err = dev->adapter->dev_set_bus(dev, 0); + if (err) + goto lbl_free_cmd_buf; + } + + /* get device number early */ + if (dev->adapter->dev_get_device_id) + dev->adapter->dev_get_device_id(dev, &dev->device_number); + + netdev_info(netdev, "attached to %s channel %u (device %u)\n", + peak_usb_adapter->name, ctrl_idx, dev->device_number); + + return 0; + +lbl_free_cmd_buf: + kfree(dev->cmd_buf); + +lbl_set_intf_data: + usb_set_intfdata(intf, dev->prev_siblings); + free_candev(netdev); + + return err; +} + +/* + * called by the usb core when the device is unplugged from the system + */ +static void peak_usb_disconnect(struct usb_interface *intf) +{ + struct peak_usb_device *dev; + + /* unregister as many netdev devices as siblings */ + for (dev = usb_get_intfdata(intf); dev; dev = dev->prev_siblings) { + struct net_device *netdev = dev->netdev; + char name[IFNAMSIZ]; + + dev->state &= ~PCAN_USB_STATE_CONNECTED; + strncpy(name, netdev->name, IFNAMSIZ); + + unregister_netdev(netdev); + free_candev(netdev); + + kfree(dev->cmd_buf); + dev->next_siblings = NULL; + if (dev->adapter->dev_free) + dev->adapter->dev_free(dev); + + dev_info(&intf->dev, "%s removed\n", name); + } + + usb_set_intfdata(intf, NULL); +} + +/* + * probe function for new PEAK-System devices + */ +static int peak_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + struct usb_device *usb_dev = interface_to_usbdev(intf); + struct peak_usb_adapter *peak_usb_adapter, **pp; + int i, err = -ENOMEM; + + usb_dev = interface_to_usbdev(intf); + + /* get corresponding PCAN-USB adapter */ + for (pp = peak_usb_adapters_list; *pp; pp++) + if ((*pp)->device_id == usb_dev->descriptor.idProduct) + break; + + peak_usb_adapter = *pp; + if (!peak_usb_adapter) { + /* should never come except device_id bad usage in this file */ + pr_err("%s: didn't find device id. 0x%x in devices list\n", + PCAN_USB_DRIVER_NAME, usb_dev->descriptor.idProduct); + return -ENODEV; + } + + /* got corresponding adapter: check if it handles current interface */ + if (peak_usb_adapter->intf_probe) { + err = peak_usb_adapter->intf_probe(intf); + if (err) + return err; + } + + for (i = 0; i < peak_usb_adapter->ctrl_count; i++) { + err = peak_usb_create_dev(peak_usb_adapter, intf, i); + if (err) { + /* deregister already created devices */ + peak_usb_disconnect(intf); + break; + } + } + + return err; +} + +/* usb specific object needed to register this driver with the usb subsystem */ +static struct usb_driver peak_usb_driver = { + .name = PCAN_USB_DRIVER_NAME, + .disconnect = peak_usb_disconnect, + .probe = peak_usb_probe, + .id_table = peak_usb_table, +}; + +static int __init peak_usb_init(void) +{ + int err; + + /* register this driver with the USB subsystem */ + err = usb_register(&peak_usb_driver); + if (err) + pr_err("%s: usb_register failed (err %d)\n", + PCAN_USB_DRIVER_NAME, err); + + return err; +} + +static int peak_usb_do_device_exit(struct device *d, void *arg) +{ + struct usb_interface *intf = to_usb_interface(d); + struct peak_usb_device *dev; + + /* stop as many netdev devices as siblings */ + for (dev = usb_get_intfdata(intf); dev; dev = dev->prev_siblings) { + struct net_device *netdev = dev->netdev; + + if (netif_device_present(netdev)) + if (dev->adapter->dev_exit) + dev->adapter->dev_exit(dev); + } + + return 0; +} + +static void __exit peak_usb_exit(void) +{ + int err; + + /* last chance do send any synchronous commands here */ + err = driver_for_each_device(&peak_usb_driver.drvwrap.driver, NULL, + NULL, peak_usb_do_device_exit); + if (err) + pr_err("%s: failed to stop all can devices (err %d)\n", + PCAN_USB_DRIVER_NAME, err); + + /* deregister this driver with the USB subsystem */ + usb_deregister(&peak_usb_driver); + + pr_info("%s: PCAN-USB interfaces driver unloaded\n", + PCAN_USB_DRIVER_NAME); +} + +module_init(peak_usb_init); +module_exit(peak_usb_exit); diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.h b/drivers/net/can/usb/peak_usb/pcan_usb_core.h new file mode 100644 index 000000000000..a948c5a89401 --- /dev/null +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.h @@ -0,0 +1,146 @@ +/* + * CAN driver for PEAK System USB adapters + * Derived from the PCAN project file driver/src/pcan_usb_core.c + * + * Copyright (C) 2003-2010 PEAK System-Technik GmbH + * Copyright (C) 2010-2012 Stephane Grosjean + * + * Many thanks to Klaus Hitschler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * 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. + */ +#ifndef PCAN_USB_CORE_H +#define PCAN_USB_CORE_H + +/* PEAK-System vendor id. */ +#define PCAN_USB_VENDOR_ID 0x0c72 + +/* supported device ids. */ +#define PCAN_USB_PRODUCT_ID 0x000c +#define PCAN_USBPRO_PRODUCT_ID 0x000d + +#define PCAN_USB_DRIVER_NAME "peak_usb" + +/* number of urbs that are submitted for rx/tx per channel */ +#define PCAN_USB_MAX_RX_URBS 4 +#define PCAN_USB_MAX_TX_URBS 10 + +/* usb adapters maximum channels per usb interface */ +#define PCAN_USB_MAX_CHANNEL 2 + +/* maximum length of the usb commands sent to/received from the devices */ +#define PCAN_USB_MAX_CMD_LEN 32 + +struct peak_usb_device; + +/* PEAK-System USB adapter descriptor */ +struct peak_usb_adapter { + char *name; + u32 device_id; + struct can_clock clock; + struct can_bittiming_const bittiming_const; + unsigned int ctrl_count; + + int (*intf_probe)(struct usb_interface *intf); + + int (*dev_init)(struct peak_usb_device *dev); + void (*dev_exit)(struct peak_usb_device *dev); + void (*dev_free)(struct peak_usb_device *dev); + int (*dev_open)(struct peak_usb_device *dev); + int (*dev_close)(struct peak_usb_device *dev); + int (*dev_set_bittiming)(struct peak_usb_device *dev, + struct can_bittiming *bt); + int (*dev_set_bus)(struct peak_usb_device *dev, u8 onoff); + int (*dev_get_device_id)(struct peak_usb_device *dev, u32 *device_id); + int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb); + int (*dev_encode_msg)(struct peak_usb_device *dev, struct sk_buff *skb, + u8 *obuf, size_t *size); + int (*dev_start)(struct peak_usb_device *dev); + int (*dev_stop)(struct peak_usb_device *dev); + int (*dev_restart_async)(struct peak_usb_device *dev, struct urb *urb, + u8 *buf); + u8 ep_msg_in; + u8 ep_msg_out[PCAN_USB_MAX_CHANNEL]; + u8 ts_used_bits; + u32 ts_period; + u8 us_per_ts_shift; + u32 us_per_ts_scale; + + int rx_buffer_size; + int tx_buffer_size; + int sizeof_dev_private; +}; + +extern struct peak_usb_adapter pcan_usb; +extern struct peak_usb_adapter pcan_usb_pro; + +struct peak_time_ref { + struct timeval tv_host_0, tv_host; + u32 ts_dev_1, ts_dev_2; + u64 ts_total; + u32 tick_count; + struct peak_usb_adapter *adapter; +}; + +struct peak_tx_urb_context { + struct peak_usb_device *dev; + u32 echo_index; + u8 dlc; + struct urb *urb; +}; + +#define PCAN_USB_STATE_CONNECTED 0x00000001 +#define PCAN_USB_STATE_STARTED 0x00000002 + +/* PEAK-System USB device */ +struct peak_usb_device { + struct can_priv can; + struct peak_usb_adapter *adapter; + unsigned int ctrl_idx; + int open_time; + u32 state; + + struct sk_buff *echo_skb[PCAN_USB_MAX_TX_URBS]; + + struct usb_device *udev; + struct net_device *netdev; + + atomic_t active_tx_urbs; + struct usb_anchor tx_submitted; + struct peak_tx_urb_context tx_contexts[PCAN_USB_MAX_TX_URBS]; + + u8 *cmd_buf; + struct usb_anchor rx_submitted; + + u32 device_number; + u8 device_rev; + + u8 ep_msg_in; + u8 ep_msg_out; + + u16 bus_load; + + struct peak_usb_device *prev_siblings; + struct peak_usb_device *next_siblings; +}; + +void dump_mem(char *prompt, void *p, int l); + +/* common timestamp management */ +void peak_usb_init_time_ref(struct peak_time_ref *time_ref, + struct peak_usb_adapter *adapter); +void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now); +void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now); +void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts, + struct timeval *tv); + +void peak_usb_async_complete(struct urb *urb); +void peak_usb_restart_complete(struct peak_usb_device *dev); +#endif -- GitLab From 46be265d3388339d8168c863791f0c7bbf3f2fed Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Fri, 2 Mar 2012 16:13:05 +0100 Subject: [PATCH 1303/1846] can: usb: PEAK-System Technik PCAN-USB specific part This patch adds the specific part which handles the PCAN-USB adapter from PEAK-System Technik (http://www.peak-system.com). The PCAN-USB adapter is a sja1000 based, mono-channel USB 1.1 adapter compliant with CAN specifications 2.0A (11-bit ID) and 2.0B (29-bit ID). Tested-by: Oliver Hartkopp Acked-by: Wolfgang Grandegger Signed-off-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/peak_usb/Makefile | 2 +- drivers/net/can/usb/peak_usb/pcan_usb.c | 901 ++++++++++++++++++++++++ 2 files changed, 902 insertions(+), 1 deletion(-) create mode 100644 drivers/net/can/usb/peak_usb/pcan_usb.c diff --git a/drivers/net/can/usb/peak_usb/Makefile b/drivers/net/can/usb/peak_usb/Makefile index bbb23ceb65f6..4450466fa57f 100644 --- a/drivers/net/can/usb/peak_usb/Makefile +++ b/drivers/net/can/usb/peak_usb/Makefile @@ -1,2 +1,2 @@ obj-$(CONFIG_CAN_PEAK_USB) += peak_usb.o -peak_usb-y = pcan_usb_core.o +peak_usb-y = pcan_usb_core.o pcan_usb.o diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c new file mode 100644 index 000000000000..8a7982e18e4e --- /dev/null +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c @@ -0,0 +1,901 @@ +/* + * CAN driver for PEAK System PCAN-USB adapter + * Derived from the PCAN project file driver/src/pcan_usb.c + * + * Copyright (C) 2003-2010 PEAK System-Technik GmbH + * Copyright (C) 2011-2012 Stephane Grosjean + * + * Many thanks to Klaus Hitschler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * 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. + */ +#include +#include +#include + +#include +#include +#include + +#include "pcan_usb_core.h" + +MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter"); + +/* PCAN-USB Endpoints */ +#define PCAN_USB_EP_CMDOUT 1 +#define PCAN_USB_EP_CMDIN (PCAN_USB_EP_CMDOUT | USB_DIR_IN) +#define PCAN_USB_EP_MSGOUT 2 +#define PCAN_USB_EP_MSGIN (PCAN_USB_EP_MSGOUT | USB_DIR_IN) + +/* PCAN-USB command struct */ +#define PCAN_USB_CMD_FUNC 0 +#define PCAN_USB_CMD_NUM 1 +#define PCAN_USB_CMD_ARGS 2 +#define PCAN_USB_CMD_ARGS_LEN 14 +#define PCAN_USB_CMD_LEN (PCAN_USB_CMD_ARGS + \ + PCAN_USB_CMD_ARGS_LEN) + +/* PCAN-USB command timeout (ms.) */ +#define PCAN_USB_COMMAND_TIMEOUT 1000 + +/* PCAN-USB startup timeout (ms.) */ +#define PCAN_USB_STARTUP_TIMEOUT 10 + +/* PCAN-USB rx/tx buffers size */ +#define PCAN_USB_RX_BUFFER_SIZE 64 +#define PCAN_USB_TX_BUFFER_SIZE 64 + +#define PCAN_USB_MSG_HEADER_LEN 2 + +/* PCAN-USB adapter internal clock (MHz) */ +#define PCAN_USB_CRYSTAL_HZ 16000000 + +/* PCAN-USB USB message record status/len field */ +#define PCAN_USB_STATUSLEN_TIMESTAMP (1 << 7) +#define PCAN_USB_STATUSLEN_INTERNAL (1 << 6) +#define PCAN_USB_STATUSLEN_EXT_ID (1 << 5) +#define PCAN_USB_STATUSLEN_RTR (1 << 4) +#define PCAN_USB_STATUSLEN_DLC (0xf) + +/* PCAN-USB error flags */ +#define PCAN_USB_ERROR_TXFULL 0x01 +#define PCAN_USB_ERROR_RXQOVR 0x02 +#define PCAN_USB_ERROR_BUS_LIGHT 0x04 +#define PCAN_USB_ERROR_BUS_HEAVY 0x08 +#define PCAN_USB_ERROR_BUS_OFF 0x10 +#define PCAN_USB_ERROR_RXQEMPTY 0x20 +#define PCAN_USB_ERROR_QOVR 0x40 +#define PCAN_USB_ERROR_TXQFULL 0x80 + +/* SJA1000 modes */ +#define SJA1000_MODE_NORMAL 0x00 +#define SJA1000_MODE_INIT 0x01 + +/* + * tick duration = 42.666 us => + * (tick_number * 44739243) >> 20 ~ (tick_number * 42666) / 1000 + * accuracy = 10^-7 + */ +#define PCAN_USB_TS_DIV_SHIFTER 20 +#define PCAN_USB_TS_US_PER_TICK 44739243 + +/* PCAN-USB messages record types */ +#define PCAN_USB_REC_ERROR 1 +#define PCAN_USB_REC_ANALOG 2 +#define PCAN_USB_REC_BUSLOAD 3 +#define PCAN_USB_REC_TS 4 +#define PCAN_USB_REC_BUSEVT 5 + +/* private to PCAN-USB adapter */ +struct pcan_usb { + struct peak_usb_device dev; + struct peak_time_ref time_ref; + struct timer_list restart_timer; +}; + +/* incoming message context for decoding */ +struct pcan_usb_msg_context { + u16 ts16; + u8 prev_ts8; + u8 *ptr; + u8 *end; + u8 rec_cnt; + u8 rec_idx; + u8 rec_data_idx; + struct net_device *netdev; + struct pcan_usb *pdev; +}; + +/* + * send a command + */ +static int pcan_usb_send_cmd(struct peak_usb_device *dev, u8 f, u8 n, u8 *p) +{ + int err; + int actual_length; + + /* usb device unregistered? */ + if (!(dev->state & PCAN_USB_STATE_CONNECTED)) + return 0; + + dev->cmd_buf[PCAN_USB_CMD_FUNC] = f; + dev->cmd_buf[PCAN_USB_CMD_NUM] = n; + + if (p) + memcpy(dev->cmd_buf + PCAN_USB_CMD_ARGS, + p, PCAN_USB_CMD_ARGS_LEN); + + err = usb_bulk_msg(dev->udev, + usb_sndbulkpipe(dev->udev, PCAN_USB_EP_CMDOUT), + dev->cmd_buf, PCAN_USB_CMD_LEN, &actual_length, + PCAN_USB_COMMAND_TIMEOUT); + if (err) + netdev_err(dev->netdev, + "sending cmd f=0x%x n=0x%x failure: %d\n", + f, n, err); + return err; +} + +/* + * send a command then wait for its response + */ +static int pcan_usb_wait_rsp(struct peak_usb_device *dev, u8 f, u8 n, u8 *p) +{ + int err; + int actual_length; + + /* usb device unregistered? */ + if (!(dev->state & PCAN_USB_STATE_CONNECTED)) + return 0; + + /* first, send command */ + err = pcan_usb_send_cmd(dev, f, n, NULL); + if (err) + return err; + + err = usb_bulk_msg(dev->udev, + usb_rcvbulkpipe(dev->udev, PCAN_USB_EP_CMDIN), + dev->cmd_buf, PCAN_USB_CMD_LEN, &actual_length, + PCAN_USB_COMMAND_TIMEOUT); + if (err) + netdev_err(dev->netdev, + "waiting rsp f=0x%x n=0x%x failure: %d\n", f, n, err); + else if (p) + memcpy(p, dev->cmd_buf + PCAN_USB_CMD_ARGS, + PCAN_USB_CMD_ARGS_LEN); + + return err; +} + +static int pcan_usb_set_sja1000(struct peak_usb_device *dev, u8 mode) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN] = { + [1] = mode, + }; + + return pcan_usb_send_cmd(dev, 9, 2, args); +} + +static int pcan_usb_set_bus(struct peak_usb_device *dev, u8 onoff) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN] = { + [0] = !!onoff, + }; + + return pcan_usb_send_cmd(dev, 3, 2, args); +} + +static int pcan_usb_set_silent(struct peak_usb_device *dev, u8 onoff) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN] = { + [0] = !!onoff, + }; + + return pcan_usb_send_cmd(dev, 3, 3, args); +} + +static int pcan_usb_set_ext_vcc(struct peak_usb_device *dev, u8 onoff) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN] = { + [0] = !!onoff, + }; + + return pcan_usb_send_cmd(dev, 10, 2, args); +} + +/* + * set bittiming value to can + */ +static int pcan_usb_set_bittiming(struct peak_usb_device *dev, + struct can_bittiming *bt) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN]; + u8 btr0, btr1; + + btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6); + btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) | + (((bt->phase_seg2 - 1) & 0x7) << 4); + if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) + btr1 |= 0x80; + + netdev_info(dev->netdev, "setting BTR0=0x%02x BTR1=0x%02x\n", + btr0, btr1); + + args[0] = btr1; + args[1] = btr0; + + return pcan_usb_send_cmd(dev, 1, 2, args); +} + +/* + * init/reset can + */ +static int pcan_usb_write_mode(struct peak_usb_device *dev, u8 onoff) +{ + int err; + + err = pcan_usb_set_bus(dev, onoff); + if (err) + return err; + + if (!onoff) { + err = pcan_usb_set_sja1000(dev, SJA1000_MODE_INIT); + } else { + /* the PCAN-USB needs time to init */ + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(msecs_to_jiffies(PCAN_USB_STARTUP_TIMEOUT)); + } + + return err; +} + +/* + * handle end of waiting for the device to reset + */ +static void pcan_usb_restart(unsigned long arg) +{ + /* notify candev and netdev */ + peak_usb_restart_complete((struct peak_usb_device *)arg); +} + +/* + * handle the submission of the restart urb + */ +static void pcan_usb_restart_pending(struct urb *urb) +{ + struct pcan_usb *pdev = urb->context; + + /* the PCAN-USB needs time to restart */ + mod_timer(&pdev->restart_timer, + jiffies + msecs_to_jiffies(PCAN_USB_STARTUP_TIMEOUT)); + + /* can delete usb resources */ + peak_usb_async_complete(urb); +} + +/* + * handle asynchronous restart + */ +static int pcan_usb_restart_async(struct peak_usb_device *dev, struct urb *urb, + u8 *buf) +{ + struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev); + + if (timer_pending(&pdev->restart_timer)) + return -EBUSY; + + /* set bus on */ + buf[PCAN_USB_CMD_FUNC] = 3; + buf[PCAN_USB_CMD_NUM] = 2; + buf[PCAN_USB_CMD_ARGS] = 1; + + usb_fill_bulk_urb(urb, dev->udev, + usb_sndbulkpipe(dev->udev, PCAN_USB_EP_CMDOUT), + buf, PCAN_USB_CMD_LEN, + pcan_usb_restart_pending, pdev); + + return usb_submit_urb(urb, GFP_ATOMIC); +} + +/* + * read serial number from device + */ +static int pcan_usb_get_serial(struct peak_usb_device *dev, u32 *serial_number) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN]; + int err; + + err = pcan_usb_wait_rsp(dev, 6, 1, args); + if (err) { + netdev_err(dev->netdev, "getting serial failure: %d\n", err); + } else if (serial_number) { + u32 tmp32; + + memcpy(&tmp32, args, 4); + *serial_number = le32_to_cpu(tmp32); + } + + return err; +} + +/* + * read device id from device + */ +static int pcan_usb_get_device_id(struct peak_usb_device *dev, u32 *device_id) +{ + u8 args[PCAN_USB_CMD_ARGS_LEN]; + int err; + + err = pcan_usb_wait_rsp(dev, 4, 1, args); + if (err) + netdev_err(dev->netdev, "getting device id failure: %d\n", err); + else if (device_id) + *device_id = args[0]; + + return err; +} + +/* + * update current time ref with received timestamp + */ +static int pcan_usb_update_ts(struct pcan_usb_msg_context *mc) +{ + u16 tmp16; + + if ((mc->ptr+2) > mc->end) + return -EINVAL; + + memcpy(&tmp16, mc->ptr, 2); + + mc->ts16 = le16_to_cpu(tmp16); + + if (mc->rec_idx > 0) + peak_usb_update_ts_now(&mc->pdev->time_ref, mc->ts16); + else + peak_usb_set_ts_now(&mc->pdev->time_ref, mc->ts16); + + return 0; +} + +/* + * decode received timestamp + */ +static int pcan_usb_decode_ts(struct pcan_usb_msg_context *mc, u8 first_packet) +{ + /* only 1st packet supplies a word timestamp */ + if (first_packet) { + u16 tmp16; + + if ((mc->ptr + 2) > mc->end) + return -EINVAL; + + memcpy(&tmp16, mc->ptr, 2); + mc->ptr += 2; + + mc->ts16 = le16_to_cpu(tmp16); + mc->prev_ts8 = mc->ts16 & 0x00ff; + } else { + u8 ts8; + + if ((mc->ptr + 1) > mc->end) + return -EINVAL; + + ts8 = *mc->ptr++; + + if (ts8 < mc->prev_ts8) + mc->ts16 += 0x100; + + mc->ts16 &= 0xff00; + mc->ts16 |= ts8; + mc->prev_ts8 = ts8; + } + + return 0; +} + +static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, + u8 status_len) +{ + struct sk_buff *skb; + struct can_frame *cf; + struct timeval tv; + enum can_state new_state; + + /* ignore this error until 1st ts received */ + if (n == PCAN_USB_ERROR_QOVR) + if (!mc->pdev->time_ref.tick_count) + return 0; + + new_state = mc->pdev->dev.can.state; + + switch (mc->pdev->dev.can.state) { + case CAN_STATE_ERROR_ACTIVE: + if (n & PCAN_USB_ERROR_BUS_LIGHT) { + new_state = CAN_STATE_ERROR_WARNING; + break; + } + + case CAN_STATE_ERROR_WARNING: + if (n & PCAN_USB_ERROR_BUS_HEAVY) { + new_state = CAN_STATE_ERROR_PASSIVE; + break; + } + if (n & PCAN_USB_ERROR_BUS_OFF) { + new_state = CAN_STATE_BUS_OFF; + break; + } + if (n & (PCAN_USB_ERROR_RXQOVR | PCAN_USB_ERROR_QOVR)) { + /* + * trick to bypass next comparison and process other + * errors + */ + new_state = CAN_STATE_MAX; + break; + } + if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) { + /* no error (back to active state) */ + mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE; + return 0; + } + break; + + case CAN_STATE_ERROR_PASSIVE: + if (n & PCAN_USB_ERROR_BUS_OFF) { + new_state = CAN_STATE_BUS_OFF; + break; + } + if (n & PCAN_USB_ERROR_BUS_LIGHT) { + new_state = CAN_STATE_ERROR_WARNING; + break; + } + if (n & (PCAN_USB_ERROR_RXQOVR | PCAN_USB_ERROR_QOVR)) { + /* + * trick to bypass next comparison and process other + * errors + */ + new_state = CAN_STATE_MAX; + break; + } + + if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) { + /* no error (back to active state) */ + mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE; + return 0; + } + break; + + default: + /* do nothing waiting for restart */ + return 0; + } + + /* donot post any error if current state didn't change */ + if (mc->pdev->dev.can.state == new_state) + return 0; + + /* allocate an skb to store the error frame */ + skb = alloc_can_err_skb(mc->netdev, &cf); + if (!skb) + return -ENOMEM; + + switch (new_state) { + case CAN_STATE_BUS_OFF: + cf->can_id |= CAN_ERR_BUSOFF; + can_bus_off(mc->netdev); + break; + + case CAN_STATE_ERROR_PASSIVE: + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE | + CAN_ERR_CRTL_RX_PASSIVE; + mc->pdev->dev.can.can_stats.error_passive++; + break; + + case CAN_STATE_ERROR_WARNING: + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] |= CAN_ERR_CRTL_TX_WARNING | + CAN_ERR_CRTL_RX_WARNING; + mc->pdev->dev.can.can_stats.error_warning++; + break; + + default: + /* CAN_STATE_MAX (trick to handle other errors) */ + cf->can_id |= CAN_ERR_CRTL; + cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW; + mc->netdev->stats.rx_over_errors++; + mc->netdev->stats.rx_errors++; + + new_state = mc->pdev->dev.can.state; + break; + } + + mc->pdev->dev.can.state = new_state; + + if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { + peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); + skb->tstamp = timeval_to_ktime(tv); + } + + netif_rx(skb); + mc->netdev->stats.rx_packets++; + mc->netdev->stats.rx_bytes += cf->can_dlc; + + return 0; +} + +/* + * decode non-data usb message + */ +static int pcan_usb_decode_status(struct pcan_usb_msg_context *mc, + u8 status_len) +{ + u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC; + u8 f, n; + int err; + + /* check whether function and number can be read */ + if ((mc->ptr + 2) > mc->end) + return -EINVAL; + + f = mc->ptr[PCAN_USB_CMD_FUNC]; + n = mc->ptr[PCAN_USB_CMD_NUM]; + mc->ptr += PCAN_USB_CMD_ARGS; + + if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { + int err = pcan_usb_decode_ts(mc, !mc->rec_idx); + + if (err) + return err; + } + + switch (f) { + case PCAN_USB_REC_ERROR: + err = pcan_usb_decode_error(mc, n, status_len); + if (err) + return err; + break; + + case PCAN_USB_REC_ANALOG: + /* analog values (ignored) */ + rec_len = 2; + break; + + case PCAN_USB_REC_BUSLOAD: + /* bus load (ignored) */ + rec_len = 1; + break; + + case PCAN_USB_REC_TS: + /* only timestamp */ + if (pcan_usb_update_ts(mc)) + return -EINVAL; + break; + + case PCAN_USB_REC_BUSEVT: + /* error frame/bus event */ + if (n & PCAN_USB_ERROR_TXQFULL) + netdev_dbg(mc->netdev, "device Tx queue full)\n"); + break; + default: + netdev_err(mc->netdev, "unexpected function %u\n", f); + break; + } + + if ((mc->ptr + rec_len) > mc->end) + return -EINVAL; + + mc->ptr += rec_len; + + return 0; +} + +/* + * decode data usb message + */ +static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) +{ + u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC; + struct sk_buff *skb; + struct can_frame *cf; + struct timeval tv; + + skb = alloc_can_skb(mc->netdev, &cf); + if (!skb) + return -ENOMEM; + + if (status_len & PCAN_USB_STATUSLEN_EXT_ID) { + u32 tmp32; + + if ((mc->ptr + 4) > mc->end) + goto decode_failed; + + memcpy(&tmp32, mc->ptr, 4); + mc->ptr += 4; + + cf->can_id = le32_to_cpu(tmp32 >> 3) | CAN_EFF_FLAG; + } else { + u16 tmp16; + + if ((mc->ptr + 2) > mc->end) + goto decode_failed; + + memcpy(&tmp16, mc->ptr, 2); + mc->ptr += 2; + + cf->can_id = le16_to_cpu(tmp16 >> 5); + } + + cf->can_dlc = get_can_dlc(rec_len); + + /* first data packet timestamp is a word */ + if (pcan_usb_decode_ts(mc, !mc->rec_data_idx)) + goto decode_failed; + + /* read data */ + memset(cf->data, 0x0, sizeof(cf->data)); + if (status_len & PCAN_USB_STATUSLEN_RTR) { + cf->can_id |= CAN_RTR_FLAG; + } else { + if ((mc->ptr + rec_len) > mc->end) + goto decode_failed; + + memcpy(cf->data, mc->ptr, rec_len); + mc->ptr += rec_len; + } + + /* convert timestamp into kernel time */ + peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); + skb->tstamp = timeval_to_ktime(tv); + + /* push the skb */ + netif_rx(skb); + + /* update statistics */ + mc->netdev->stats.rx_packets++; + mc->netdev->stats.rx_bytes += cf->can_dlc; + + return 0; + +decode_failed: + dev_kfree_skb(skb); + return -EINVAL; +} + +/* + * process incoming message + */ +static int pcan_usb_decode_msg(struct peak_usb_device *dev, u8 *ibuf, u32 lbuf) +{ + struct pcan_usb_msg_context mc = { + .rec_cnt = ibuf[1], + .ptr = ibuf + PCAN_USB_MSG_HEADER_LEN, + .end = ibuf + lbuf, + .netdev = dev->netdev, + .pdev = container_of(dev, struct pcan_usb, dev), + }; + int err; + + for (err = 0; mc.rec_idx < mc.rec_cnt && !err; mc.rec_idx++) { + u8 sl = *mc.ptr++; + + /* handle status and error frames here */ + if (sl & PCAN_USB_STATUSLEN_INTERNAL) { + err = pcan_usb_decode_status(&mc, sl); + /* handle normal can frames here */ + } else { + err = pcan_usb_decode_data(&mc, sl); + mc.rec_data_idx++; + } + } + + return err; +} + +/* + * process any incoming buffer + */ +static int pcan_usb_decode_buf(struct peak_usb_device *dev, struct urb *urb) +{ + int err = 0; + + if (urb->actual_length > PCAN_USB_MSG_HEADER_LEN) { + err = pcan_usb_decode_msg(dev, urb->transfer_buffer, + urb->actual_length); + + } else if (urb->actual_length > 0) { + netdev_err(dev->netdev, "usb message length error (%u)\n", + urb->actual_length); + err = -EINVAL; + } + + return err; +} + +/* + * process outgoing packet + */ +static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb, + u8 *obuf, size_t *size) +{ + struct net_device *netdev = dev->netdev; + struct net_device_stats *stats = &netdev->stats; + struct can_frame *cf = (struct can_frame *)skb->data; + u8 *pc; + + obuf[0] = 2; + obuf[1] = 1; + + pc = obuf + PCAN_USB_MSG_HEADER_LEN; + + /* status/len byte */ + *pc = cf->can_dlc; + if (cf->can_id & CAN_RTR_FLAG) + *pc |= PCAN_USB_STATUSLEN_RTR; + + /* can id */ + if (cf->can_id & CAN_EFF_FLAG) { + __le32 tmp32 = cpu_to_le32(cf->can_id & CAN_ERR_MASK); + + tmp32 <<= 3; + *pc |= PCAN_USB_STATUSLEN_EXT_ID; + memcpy(++pc, &tmp32, 4); + pc += 4; + } else { + __le16 tmp16 = cpu_to_le32(cf->can_id & CAN_ERR_MASK); + + tmp16 <<= 5; + memcpy(++pc, &tmp16, 2); + pc += 2; + } + + /* can data */ + if (!(cf->can_id & CAN_RTR_FLAG)) { + memcpy(pc, cf->data, cf->can_dlc); + pc += cf->can_dlc; + } + + obuf[(*size)-1] = (u8)(stats->tx_packets & 0xff); + + return 0; +} + +/* + * start interface + */ +static int pcan_usb_start(struct peak_usb_device *dev) +{ + struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev); + + /* number of bits used in timestamps read from adapter struct */ + peak_usb_init_time_ref(&pdev->time_ref, &pcan_usb); + + /* if revision greater than 3, can put silent mode on/off */ + if (dev->device_rev > 3) { + int err; + + err = pcan_usb_set_silent(dev, + dev->can.ctrlmode & CAN_CTRLMODE_LISTENONLY); + if (err) + return err; + } + + return pcan_usb_set_ext_vcc(dev, 0); +} + +static int pcan_usb_init(struct peak_usb_device *dev) +{ + struct pcan_usb *pdev = container_of(dev, struct pcan_usb, dev); + u32 serial_number; + int err; + + /* initialize a timer needed to wait for hardware restart */ + init_timer(&pdev->restart_timer); + pdev->restart_timer.function = pcan_usb_restart; + pdev->restart_timer.data = (unsigned long)dev; + + /* + * explicit use of dev_xxx() instead of netdev_xxx() here: + * information displayed are related to the device itself, not + * to the canx netdevice. + */ + err = pcan_usb_get_serial(dev, &serial_number); + if (err) { + dev_err(dev->netdev->dev.parent, + "unable to read %s serial number (err %d)\n", + pcan_usb.name, err); + return err; + } + + dev_info(dev->netdev->dev.parent, + "PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n", + pcan_usb.name, dev->device_rev, serial_number, + pcan_usb.ctrl_count); + + return 0; +} + +/* + * probe function for new PCAN-USB usb interface + */ +static int pcan_usb_probe(struct usb_interface *intf) +{ + struct usb_host_interface *if_desc; + int i; + + if_desc = intf->altsetting; + + /* check interface endpoint addresses */ + for (i = 0; i < if_desc->desc.bNumEndpoints; i++) { + struct usb_endpoint_descriptor *ep = &if_desc->endpoint[i].desc; + + switch (ep->bEndpointAddress) { + case PCAN_USB_EP_CMDOUT: + case PCAN_USB_EP_CMDIN: + case PCAN_USB_EP_MSGOUT: + case PCAN_USB_EP_MSGIN: + break; + default: + return -ENODEV; + } + } + + return 0; +} + +/* + * describe the PCAN-USB adapter + */ +struct peak_usb_adapter pcan_usb = { + .name = "PCAN-USB", + .device_id = PCAN_USB_PRODUCT_ID, + .ctrl_count = 1, + .clock = { + .freq = PCAN_USB_CRYSTAL_HZ / 2 , + }, + .bittiming_const = { + .name = "pcan_usb", + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_max = 4, + .brp_min = 1, + .brp_max = 64, + .brp_inc = 1, + }, + + /* size of device private data */ + .sizeof_dev_private = sizeof(struct pcan_usb), + + /* timestamps usage */ + .ts_used_bits = 16, + .ts_period = 24575, /* calibration period in ts. */ + .us_per_ts_scale = PCAN_USB_TS_US_PER_TICK, /* us=(ts*scale) */ + .us_per_ts_shift = PCAN_USB_TS_DIV_SHIFTER, /* >> shift */ + + /* give here messages in/out endpoints */ + .ep_msg_in = PCAN_USB_EP_MSGIN, + .ep_msg_out = {PCAN_USB_EP_MSGOUT}, + + /* size of rx/tx usb buffers */ + .rx_buffer_size = PCAN_USB_RX_BUFFER_SIZE, + .tx_buffer_size = PCAN_USB_TX_BUFFER_SIZE, + + /* device callbacks */ + .intf_probe = pcan_usb_probe, + .dev_init = pcan_usb_init, + .dev_set_bus = pcan_usb_write_mode, + .dev_set_bittiming = pcan_usb_set_bittiming, + .dev_get_device_id = pcan_usb_get_device_id, + .dev_decode_buf = pcan_usb_decode_buf, + .dev_encode_msg = pcan_usb_encode_msg, + .dev_start = pcan_usb_start, + .dev_restart_async = pcan_usb_restart_async, +}; -- GitLab From d8a199355f8f8a0797c00d98788d7282c9ea38bd Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Fri, 2 Mar 2012 16:13:06 +0100 Subject: [PATCH 1304/1846] can: usb: PEAK-System Technik PCAN-USB Pro specific part This patch adds the specific part which handles the PCAN-USB Pro adapter from PEAK-System Technik (http://www.peak-system.com). The PCAN-USB Pro adapter is a dual-channel USB 2.0 adapter compliant with CAN specifications Tested-by: Oliver Hartkopp Acked-by: Wolfgang Grandegger Signed-off-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/peak_usb/Makefile | 2 +- drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 1036 +++++++++++++++++++ drivers/net/can/usb/peak_usb/pcan_usb_pro.h | 178 ++++ 3 files changed, 1215 insertions(+), 1 deletion(-) create mode 100644 drivers/net/can/usb/peak_usb/pcan_usb_pro.c create mode 100644 drivers/net/can/usb/peak_usb/pcan_usb_pro.h diff --git a/drivers/net/can/usb/peak_usb/Makefile b/drivers/net/can/usb/peak_usb/Makefile index 4450466fa57f..1aefbc88d643 100644 --- a/drivers/net/can/usb/peak_usb/Makefile +++ b/drivers/net/can/usb/peak_usb/Makefile @@ -1,2 +1,2 @@ obj-$(CONFIG_CAN_PEAK_USB) += peak_usb.o -peak_usb-y = pcan_usb_core.o pcan_usb.o +peak_usb-y = pcan_usb_core.o pcan_usb.o pcan_usb_pro.o diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c new file mode 100644 index 000000000000..5234586dff15 --- /dev/null +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c @@ -0,0 +1,1036 @@ +/* + * CAN driver for PEAK System PCAN-USB Pro adapter + * Derived from the PCAN project file driver/src/pcan_usbpro.c + * + * Copyright (C) 2003-2011 PEAK System-Technik GmbH + * Copyright (C) 2011-2012 Stephane Grosjean + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * 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. + */ +#include +#include +#include + +#include +#include +#include + +#include "pcan_usb_core.h" +#include "pcan_usb_pro.h" + +MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB Pro adapter"); + +/* PCAN-USB Pro Endpoints */ +#define PCAN_USBPRO_EP_CMDOUT 1 +#define PCAN_USBPRO_EP_CMDIN (PCAN_USBPRO_EP_CMDOUT | USB_DIR_IN) +#define PCAN_USBPRO_EP_MSGOUT_0 2 +#define PCAN_USBPRO_EP_MSGIN (PCAN_USBPRO_EP_MSGOUT_0 | USB_DIR_IN) +#define PCAN_USBPRO_EP_MSGOUT_1 3 +#define PCAN_USBPRO_EP_UNUSED (PCAN_USBPRO_EP_MSGOUT_1 | USB_DIR_IN) + +#define PCAN_USBPRO_CHANNEL_COUNT 2 + +/* PCAN-USB Pro adapter internal clock (MHz) */ +#define PCAN_USBPRO_CRYSTAL_HZ 56000000 + +/* PCAN-USB Pro command timeout (ms.) */ +#define PCAN_USBPRO_COMMAND_TIMEOUT 1000 + +/* PCAN-USB Pro rx/tx buffers size */ +#define PCAN_USBPRO_RX_BUFFER_SIZE 1024 +#define PCAN_USBPRO_TX_BUFFER_SIZE 64 + +#define PCAN_USBPRO_MSG_HEADER_LEN 4 + +/* some commands responses need to be re-submitted */ +#define PCAN_USBPRO_RSP_SUBMIT_MAX 2 + +#define PCAN_USBPRO_RTR 0x01 +#define PCAN_USBPRO_EXT 0x02 + +#define PCAN_USBPRO_CMD_BUFFER_SIZE 512 + +/* handle device specific info used by the netdevices */ +struct pcan_usb_pro_interface { + struct peak_usb_device *dev[PCAN_USBPRO_CHANNEL_COUNT]; + struct peak_time_ref time_ref; + int cm_ignore_count; + int dev_opened_count; +}; + +/* device information */ +struct pcan_usb_pro_device { + struct peak_usb_device dev; + struct pcan_usb_pro_interface *usb_if; + u32 cached_ccbt; +}; + +/* internal structure used to handle messages sent to bulk urb */ +struct pcan_usb_pro_msg { + u8 *rec_ptr; + int rec_buffer_size; + int rec_buffer_len; + union { + u16 *rec_cnt_rd; + u32 *rec_cnt; + u8 *rec_buffer; + } u; +}; + +/* records sizes table indexed on message id. (8-bits value) */ +static u16 pcan_usb_pro_sizeof_rec[256] = { + [PCAN_USBPRO_SETBTR] = sizeof(struct pcan_usb_pro_btr), + [PCAN_USBPRO_SETBUSACT] = sizeof(struct pcan_usb_pro_busact), + [PCAN_USBPRO_SETSILENT] = sizeof(struct pcan_usb_pro_silent), + [PCAN_USBPRO_SETFILTR] = sizeof(struct pcan_usb_pro_filter), + [PCAN_USBPRO_SETTS] = sizeof(struct pcan_usb_pro_setts), + [PCAN_USBPRO_GETDEVID] = sizeof(struct pcan_usb_pro_devid), + [PCAN_USBPRO_SETLED] = sizeof(struct pcan_usb_pro_setled), + [PCAN_USBPRO_RXMSG8] = sizeof(struct pcan_usb_pro_rxmsg), + [PCAN_USBPRO_RXMSG4] = sizeof(struct pcan_usb_pro_rxmsg) - 4, + [PCAN_USBPRO_RXMSG0] = sizeof(struct pcan_usb_pro_rxmsg) - 8, + [PCAN_USBPRO_RXRTR] = sizeof(struct pcan_usb_pro_rxmsg) - 8, + [PCAN_USBPRO_RXSTATUS] = sizeof(struct pcan_usb_pro_rxstatus), + [PCAN_USBPRO_RXTS] = sizeof(struct pcan_usb_pro_rxts), + [PCAN_USBPRO_TXMSG8] = sizeof(struct pcan_usb_pro_txmsg), + [PCAN_USBPRO_TXMSG4] = sizeof(struct pcan_usb_pro_txmsg) - 4, + [PCAN_USBPRO_TXMSG0] = sizeof(struct pcan_usb_pro_txmsg) - 8, +}; + +/* + * initialize PCAN-USB Pro message data structure + */ +static u8 *pcan_msg_init(struct pcan_usb_pro_msg *pm, void *buffer_addr, + int buffer_size) +{ + if (buffer_size < PCAN_USBPRO_MSG_HEADER_LEN) + return NULL; + + pm->u.rec_buffer = (u8 *)buffer_addr; + pm->rec_buffer_size = pm->rec_buffer_len = buffer_size; + pm->rec_ptr = pm->u.rec_buffer + PCAN_USBPRO_MSG_HEADER_LEN; + + return pm->rec_ptr; +} + +static u8 *pcan_msg_init_empty(struct pcan_usb_pro_msg *pm, + void *buffer_addr, int buffer_size) +{ + u8 *pr = pcan_msg_init(pm, buffer_addr, buffer_size); + + if (pr) { + pm->rec_buffer_len = PCAN_USBPRO_MSG_HEADER_LEN; + *pm->u.rec_cnt = 0; + } + return pr; +} + +/* + * add one record to a message being built + */ +static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, u8 id, ...) +{ + int len, i; + u8 *pc; + va_list ap; + + va_start(ap, id); + + pc = pm->rec_ptr + 1; + + i = 0; + switch (id) { + case PCAN_USBPRO_TXMSG8: + i += 4; + case PCAN_USBPRO_TXMSG4: + i += 4; + case PCAN_USBPRO_TXMSG0: + *pc++ = va_arg(ap, int); + *pc++ = va_arg(ap, int); + *pc++ = va_arg(ap, int); + *(u32 *)pc = cpu_to_le32(va_arg(ap, u32)); + pc += 4; + memcpy(pc, va_arg(ap, int *), i); + pc += i; + break; + + case PCAN_USBPRO_SETBTR: + case PCAN_USBPRO_GETDEVID: + *pc++ = va_arg(ap, int); + pc += 2; + *(u32 *)pc = cpu_to_le32(va_arg(ap, u32)); + pc += 4; + break; + + case PCAN_USBPRO_SETFILTR: + case PCAN_USBPRO_SETBUSACT: + case PCAN_USBPRO_SETSILENT: + *pc++ = va_arg(ap, int); + *(u16 *)pc = cpu_to_le16(va_arg(ap, int)); + pc += 2; + break; + + case PCAN_USBPRO_SETLED: + *pc++ = va_arg(ap, int); + *(u16 *)pc = cpu_to_le16(va_arg(ap, int)); + pc += 2; + *(u32 *)pc = cpu_to_le32(va_arg(ap, u32)); + pc += 4; + break; + + case PCAN_USBPRO_SETTS: + pc++; + *(u16 *)pc = cpu_to_le16(va_arg(ap, int)); + pc += 2; + break; + + default: + pr_err("%s: %s(): unknown data type %02Xh (%d)\n", + PCAN_USB_DRIVER_NAME, __func__, id, id); + pc--; + break; + } + + len = pc - pm->rec_ptr; + if (len > 0) { + *pm->u.rec_cnt = cpu_to_le32(*pm->u.rec_cnt+1); + *pm->rec_ptr = id; + + pm->rec_ptr = pc; + pm->rec_buffer_len += len; + } + + va_end(ap); + + return len; +} + +/* + * send PCAN-USB Pro command synchronously + */ +static int pcan_usb_pro_send_cmd(struct peak_usb_device *dev, + struct pcan_usb_pro_msg *pum) +{ + int actual_length; + int err; + + /* usb device unregistered? */ + if (!(dev->state & PCAN_USB_STATE_CONNECTED)) + return 0; + + err = usb_bulk_msg(dev->udev, + usb_sndbulkpipe(dev->udev, PCAN_USBPRO_EP_CMDOUT), + pum->u.rec_buffer, pum->rec_buffer_len, + &actual_length, PCAN_USBPRO_COMMAND_TIMEOUT); + if (err) + netdev_err(dev->netdev, "sending command failure: %d\n", err); + + return err; +} + +/* + * wait for PCAN-USB Pro command response + */ +static int pcan_usb_pro_wait_rsp(struct peak_usb_device *dev, + struct pcan_usb_pro_msg *pum) +{ + u8 req_data_type, req_channel; + int actual_length; + int i, err = 0; + + /* usb device unregistered? */ + if (!(dev->state & PCAN_USB_STATE_CONNECTED)) + return 0; + + req_data_type = pum->u.rec_buffer[4]; + req_channel = pum->u.rec_buffer[5]; + + *pum->u.rec_cnt = 0; + for (i = 0; !err && i < PCAN_USBPRO_RSP_SUBMIT_MAX; i++) { + struct pcan_usb_pro_msg rsp; + union pcan_usb_pro_rec *pr; + u32 r, rec_cnt; + u16 rec_len; + u8 *pc; + + err = usb_bulk_msg(dev->udev, + usb_rcvbulkpipe(dev->udev, PCAN_USBPRO_EP_CMDIN), + pum->u.rec_buffer, pum->rec_buffer_len, + &actual_length, PCAN_USBPRO_COMMAND_TIMEOUT); + if (err) { + netdev_err(dev->netdev, "waiting rsp error %d\n", err); + break; + } + + if (actual_length == 0) + continue; + + err = -EBADMSG; + if (actual_length < PCAN_USBPRO_MSG_HEADER_LEN) { + netdev_err(dev->netdev, + "got abnormal too small rsp (len=%d)\n", + actual_length); + break; + } + + pc = pcan_msg_init(&rsp, pum->u.rec_buffer, + actual_length); + + rec_cnt = le32_to_cpu(*rsp.u.rec_cnt); + + /* loop on records stored into message */ + for (r = 0; r < rec_cnt; r++) { + pr = (union pcan_usb_pro_rec *)pc; + rec_len = pcan_usb_pro_sizeof_rec[pr->data_type]; + if (!rec_len) { + netdev_err(dev->netdev, + "got unprocessed record in msg\n"); + dump_mem("rcvd rsp msg", pum->u.rec_buffer, + actual_length); + break; + } + + /* check if response corresponds to request */ + if (pr->data_type != req_data_type) + netdev_err(dev->netdev, + "got unwanted rsp %xh: ignored\n", + pr->data_type); + + /* check if channel in response corresponds too */ + else if ((req_channel != 0xff) && \ + (pr->bus_act.channel != req_channel)) + netdev_err(dev->netdev, + "got rsp %xh but on chan%u: ignored\n", + req_data_type, pr->bus_act.channel); + + /* got the response */ + else + return 0; + + /* otherwise, go on with next record in message */ + pc += rec_len; + } + } + + return (i >= PCAN_USBPRO_RSP_SUBMIT_MAX) ? -ERANGE : err; +} + +static int pcan_usb_pro_send_req(struct peak_usb_device *dev, int req_id, + int req_value, void *req_addr, int req_size) +{ + int err; + u8 req_type; + unsigned int p; + + /* usb device unregistered? */ + if (!(dev->state & PCAN_USB_STATE_CONNECTED)) + return 0; + + memset(req_addr, '\0', req_size); + + req_type = USB_TYPE_VENDOR | USB_RECIP_OTHER; + + switch (req_id) { + case PCAN_USBPRO_REQ_FCT: + p = usb_sndctrlpipe(dev->udev, 0); + break; + + default: + p = usb_rcvctrlpipe(dev->udev, 0); + req_type |= USB_DIR_IN; + break; + } + + err = usb_control_msg(dev->udev, p, req_id, req_type, req_value, 0, + req_addr, req_size, 2 * USB_CTRL_GET_TIMEOUT); + if (err < 0) { + netdev_info(dev->netdev, + "unable to request usb[type=%d value=%d] err=%d\n", + req_id, req_value, err); + return err; + } + + return 0; +} + +static int pcan_usb_pro_set_ts(struct peak_usb_device *dev, u16 onoff) +{ + struct pcan_usb_pro_msg um; + + pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETTS, onoff); + + return pcan_usb_pro_send_cmd(dev, &um); +} + +static int pcan_usb_pro_set_bitrate(struct peak_usb_device *dev, u32 ccbt) +{ + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + struct pcan_usb_pro_msg um; + + pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETBTR, dev->ctrl_idx, ccbt); + + /* cache the CCBT value to reuse it before next buson */ + pdev->cached_ccbt = ccbt; + + return pcan_usb_pro_send_cmd(dev, &um); +} + +static int pcan_usb_pro_set_bus(struct peak_usb_device *dev, u8 onoff) +{ + struct pcan_usb_pro_msg um; + + /* if bus=on, be sure the bitrate being set before! */ + if (onoff) { + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + + pcan_usb_pro_set_bitrate(dev, pdev->cached_ccbt); + } + + pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETBUSACT, dev->ctrl_idx, onoff); + + return pcan_usb_pro_send_cmd(dev, &um); +} + +static int pcan_usb_pro_set_silent(struct peak_usb_device *dev, u8 onoff) +{ + struct pcan_usb_pro_msg um; + + pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETSILENT, dev->ctrl_idx, onoff); + + return pcan_usb_pro_send_cmd(dev, &um); +} + +static int pcan_usb_pro_set_filter(struct peak_usb_device *dev, u16 filter_mode) +{ + struct pcan_usb_pro_msg um; + + pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETFILTR, dev->ctrl_idx, filter_mode); + + return pcan_usb_pro_send_cmd(dev, &um); +} + +static int pcan_usb_pro_set_led(struct peak_usb_device *dev, u8 mode, + u32 timeout) +{ + struct pcan_usb_pro_msg um; + + pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETLED, dev->ctrl_idx, mode, timeout); + + return pcan_usb_pro_send_cmd(dev, &um); +} + +static int pcan_usb_pro_get_device_id(struct peak_usb_device *dev, + u32 *device_id) +{ + struct pcan_usb_pro_devid *pdn; + struct pcan_usb_pro_msg um; + int err; + u8 *pc; + + pc = pcan_msg_init_empty(&um, dev->cmd_buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_GETDEVID, dev->ctrl_idx); + + err = pcan_usb_pro_send_cmd(dev, &um); + if (err) + return err; + + err = pcan_usb_pro_wait_rsp(dev, &um); + if (err) + return err; + + pdn = (struct pcan_usb_pro_devid *)pc; + if (device_id) + *device_id = le32_to_cpu(pdn->serial_num); + + return err; +} + +static int pcan_usb_pro_set_bittiming(struct peak_usb_device *dev, + struct can_bittiming *bt) +{ + u32 ccbt; + + ccbt = (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 0x00800000 : 0; + ccbt |= (bt->sjw - 1) << 24; + ccbt |= (bt->phase_seg2 - 1) << 20; + ccbt |= (bt->prop_seg + bt->phase_seg1 - 1) << 16; /* = tseg1 */ + ccbt |= bt->brp - 1; + + netdev_info(dev->netdev, "setting ccbt=0x%08x\n", ccbt); + + return pcan_usb_pro_set_bitrate(dev, ccbt); +} + +static void pcan_usb_pro_restart_complete(struct urb *urb) +{ + /* can delete usb resources */ + peak_usb_async_complete(urb); + + /* notify candev and netdev */ + peak_usb_restart_complete(urb->context); +} + +/* + * handle restart but in asynchronously way + */ +static int pcan_usb_pro_restart_async(struct peak_usb_device *dev, + struct urb *urb, u8 *buf) +{ + struct pcan_usb_pro_msg um; + + pcan_msg_init_empty(&um, buf, PCAN_USB_MAX_CMD_LEN); + pcan_msg_add_rec(&um, PCAN_USBPRO_SETBUSACT, dev->ctrl_idx, 1); + + usb_fill_bulk_urb(urb, dev->udev, + usb_sndbulkpipe(dev->udev, PCAN_USBPRO_EP_CMDOUT), + buf, PCAN_USB_MAX_CMD_LEN, + pcan_usb_pro_restart_complete, dev); + + return usb_submit_urb(urb, GFP_ATOMIC); +} + +static void pcan_usb_pro_drv_loaded(struct peak_usb_device *dev, int loaded) +{ + u8 buffer[16]; + + buffer[0] = 0; + buffer[1] = !!loaded; + + pcan_usb_pro_send_req(dev, PCAN_USBPRO_REQ_FCT, + PCAN_USBPRO_FCT_DRVLD, buffer, sizeof(buffer)); +} + +static inline +struct pcan_usb_pro_interface *pcan_usb_pro_dev_if(struct peak_usb_device *dev) +{ + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + return pdev->usb_if; +} + +static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if, + struct pcan_usb_pro_rxmsg *rx) +{ + const unsigned int ctrl_idx = (rx->len >> 4) & 0x0f; + struct peak_usb_device *dev = usb_if->dev[ctrl_idx]; + struct net_device *netdev = dev->netdev; + struct can_frame *can_frame; + struct sk_buff *skb; + struct timeval tv; + + skb = alloc_can_skb(netdev, &can_frame); + if (!skb) + return -ENOMEM; + + can_frame->can_id = le32_to_cpu(rx->id); + can_frame->can_dlc = rx->len & 0x0f; + + if (rx->flags & PCAN_USBPRO_EXT) + can_frame->can_id |= CAN_EFF_FLAG; + + if (rx->flags & PCAN_USBPRO_RTR) + can_frame->can_id |= CAN_RTR_FLAG; + else + memcpy(can_frame->data, rx->data, can_frame->can_dlc); + + peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv); + skb->tstamp = timeval_to_ktime(tv); + + netif_rx(skb); + netdev->stats.rx_packets++; + netdev->stats.rx_bytes += can_frame->can_dlc; + + return 0; +} + +static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if, + struct pcan_usb_pro_rxstatus *er) +{ + const u32 raw_status = le32_to_cpu(er->status); + const unsigned int ctrl_idx = (er->channel >> 4) & 0x0f; + struct peak_usb_device *dev = usb_if->dev[ctrl_idx]; + struct net_device *netdev = dev->netdev; + struct can_frame *can_frame; + enum can_state new_state = CAN_STATE_ERROR_ACTIVE; + u8 err_mask = 0; + struct sk_buff *skb; + struct timeval tv; + + /* nothing should be sent while in BUS_OFF state */ + if (dev->can.state == CAN_STATE_BUS_OFF) + return 0; + + if (!raw_status) { + /* no error bit (back to active state) */ + dev->can.state = CAN_STATE_ERROR_ACTIVE; + return 0; + } + + if (raw_status & (PCAN_USBPRO_STATUS_OVERRUN | + PCAN_USBPRO_STATUS_QOVERRUN)) { + /* trick to bypass next comparison and process other errors */ + new_state = CAN_STATE_MAX; + } + + if (raw_status & PCAN_USBPRO_STATUS_BUS) { + new_state = CAN_STATE_BUS_OFF; + } else if (raw_status & PCAN_USBPRO_STATUS_ERROR) { + u32 rx_err_cnt = (le32_to_cpu(er->err_frm) & 0x00ff0000) >> 16; + u32 tx_err_cnt = (le32_to_cpu(er->err_frm) & 0xff000000) >> 24; + + if (rx_err_cnt > 127) + err_mask |= CAN_ERR_CRTL_RX_PASSIVE; + else if (rx_err_cnt > 96) + err_mask |= CAN_ERR_CRTL_RX_WARNING; + + if (tx_err_cnt > 127) + err_mask |= CAN_ERR_CRTL_TX_PASSIVE; + else if (tx_err_cnt > 96) + err_mask |= CAN_ERR_CRTL_TX_WARNING; + + if (err_mask & (CAN_ERR_CRTL_RX_WARNING | + CAN_ERR_CRTL_TX_WARNING)) + new_state = CAN_STATE_ERROR_WARNING; + else if (err_mask & (CAN_ERR_CRTL_RX_PASSIVE | + CAN_ERR_CRTL_TX_PASSIVE)) + new_state = CAN_STATE_ERROR_PASSIVE; + } + + /* donot post any error if current state didn't change */ + if (dev->can.state == new_state) + return 0; + + /* allocate an skb to store the error frame */ + skb = alloc_can_err_skb(netdev, &can_frame); + if (!skb) + return -ENOMEM; + + switch (new_state) { + case CAN_STATE_BUS_OFF: + can_frame->can_id |= CAN_ERR_BUSOFF; + can_bus_off(netdev); + break; + + case CAN_STATE_ERROR_PASSIVE: + can_frame->can_id |= CAN_ERR_CRTL; + can_frame->data[1] |= err_mask; + dev->can.can_stats.error_passive++; + break; + + case CAN_STATE_ERROR_WARNING: + can_frame->can_id |= CAN_ERR_CRTL; + can_frame->data[1] |= err_mask; + dev->can.can_stats.error_warning++; + break; + + case CAN_STATE_ERROR_ACTIVE: + break; + + default: + /* CAN_STATE_MAX (trick to handle other errors) */ + if (raw_status & PCAN_USBPRO_STATUS_OVERRUN) { + can_frame->can_id |= CAN_ERR_PROT; + can_frame->data[2] |= CAN_ERR_PROT_OVERLOAD; + netdev->stats.rx_over_errors++; + netdev->stats.rx_errors++; + } + + if (raw_status & PCAN_USBPRO_STATUS_QOVERRUN) { + can_frame->can_id |= CAN_ERR_CRTL; + can_frame->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW; + netdev->stats.rx_over_errors++; + netdev->stats.rx_errors++; + } + + new_state = CAN_STATE_ERROR_ACTIVE; + break; + } + + dev->can.state = new_state; + + peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv); + skb->tstamp = timeval_to_ktime(tv); + netif_rx(skb); + netdev->stats.rx_packets++; + netdev->stats.rx_bytes += can_frame->can_dlc; + + return 0; +} + +static void pcan_usb_pro_handle_ts(struct pcan_usb_pro_interface *usb_if, + struct pcan_usb_pro_rxts *ts) +{ + /* should wait until clock is stabilized */ + if (usb_if->cm_ignore_count > 0) + usb_if->cm_ignore_count--; + else + peak_usb_set_ts_now(&usb_if->time_ref, + le32_to_cpu(ts->ts64[1])); +} + +/* + * callback for bulk IN urb + */ +static int pcan_usb_pro_decode_buf(struct peak_usb_device *dev, struct urb *urb) +{ + struct pcan_usb_pro_interface *usb_if = pcan_usb_pro_dev_if(dev); + struct net_device *netdev = dev->netdev; + struct pcan_usb_pro_msg usb_msg; + u8 *rec_ptr, *msg_end; + u16 rec_cnt; + int err = 0; + + rec_ptr = pcan_msg_init(&usb_msg, urb->transfer_buffer, + urb->actual_length); + if (!rec_ptr) { + netdev_err(netdev, "bad msg hdr len %d\n", urb->actual_length); + return -EINVAL; + } + + /* loop reading all the records from the incoming message */ + msg_end = urb->transfer_buffer + urb->actual_length; + rec_cnt = le16_to_cpu(*usb_msg.u.rec_cnt_rd); + for (; rec_cnt > 0; rec_cnt--) { + union pcan_usb_pro_rec *pr = (union pcan_usb_pro_rec *)rec_ptr; + u16 sizeof_rec = pcan_usb_pro_sizeof_rec[pr->data_type]; + + if (!sizeof_rec) { + netdev_err(netdev, + "got unsupported rec in usb msg:\n"); + err = -ENOTSUPP; + break; + } + + /* check if the record goes out of current packet */ + if (rec_ptr + sizeof_rec > msg_end) { + netdev_err(netdev, + "got frag rec: should inc usb rx buf size\n"); + err = -EBADMSG; + break; + } + + switch (pr->data_type) { + case PCAN_USBPRO_RXMSG8: + case PCAN_USBPRO_RXMSG4: + case PCAN_USBPRO_RXMSG0: + case PCAN_USBPRO_RXRTR: + err = pcan_usb_pro_handle_canmsg(usb_if, &pr->rx_msg); + if (err < 0) + goto fail; + break; + + case PCAN_USBPRO_RXSTATUS: + err = pcan_usb_pro_handle_error(usb_if, &pr->rx_status); + if (err < 0) + goto fail; + break; + + case PCAN_USBPRO_RXTS: + pcan_usb_pro_handle_ts(usb_if, &pr->rx_ts); + break; + + default: + netdev_err(netdev, + "unhandled rec type 0x%02x (%d): ignored\n", + pr->data_type, pr->data_type); + break; + } + + rec_ptr += sizeof_rec; + } + +fail: + if (err) + dump_mem("received msg", + urb->transfer_buffer, urb->actual_length); + + return err; +} + +static int pcan_usb_pro_encode_msg(struct peak_usb_device *dev, + struct sk_buff *skb, u8 *obuf, size_t *size) +{ + struct can_frame *cf = (struct can_frame *)skb->data; + u8 data_type, len, flags; + struct pcan_usb_pro_msg usb_msg; + + pcan_msg_init_empty(&usb_msg, obuf, *size); + + if ((cf->can_id & CAN_RTR_FLAG) || (cf->can_dlc == 0)) + data_type = PCAN_USBPRO_TXMSG0; + else if (cf->can_dlc <= 4) + data_type = PCAN_USBPRO_TXMSG4; + else + data_type = PCAN_USBPRO_TXMSG8; + + len = (dev->ctrl_idx << 4) | (cf->can_dlc & 0x0f); + + flags = 0; + if (cf->can_id & CAN_EFF_FLAG) + flags |= 0x02; + if (cf->can_id & CAN_RTR_FLAG) + flags |= 0x01; + + pcan_msg_add_rec(&usb_msg, data_type, 0, flags, len, cf->can_id, + cf->data); + + *size = usb_msg.rec_buffer_len; + + return 0; +} + +static int pcan_usb_pro_start(struct peak_usb_device *dev) +{ + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + int err; + + err = pcan_usb_pro_set_silent(dev, + dev->can.ctrlmode & CAN_CTRLMODE_LISTENONLY); + if (err) + return err; + + /* filter mode: 0-> All OFF; 1->bypass */ + err = pcan_usb_pro_set_filter(dev, 1); + if (err) + return err; + + /* opening first device: */ + if (pdev->usb_if->dev_opened_count == 0) { + /* reset time_ref */ + peak_usb_init_time_ref(&pdev->usb_if->time_ref, &pcan_usb_pro); + + /* ask device to send ts messages */ + err = pcan_usb_pro_set_ts(dev, 1); + } + + pdev->usb_if->dev_opened_count++; + + return err; +} + +/* + * stop interface + * (last chance before set bus off) + */ +static int pcan_usb_pro_stop(struct peak_usb_device *dev) +{ + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + + /* turn off ts msgs for that interface if no other dev opened */ + if (pdev->usb_if->dev_opened_count == 1) + pcan_usb_pro_set_ts(dev, 0); + + pdev->usb_if->dev_opened_count--; + + return 0; +} + +/* + * called when probing to initialize a device object. + */ +static int pcan_usb_pro_init(struct peak_usb_device *dev) +{ + struct pcan_usb_pro_interface *usb_if; + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + + /* do this for 1st channel only */ + if (!dev->prev_siblings) { + struct pcan_usb_pro_fwinfo fi; + struct pcan_usb_pro_blinfo bi; + int err; + + /* allocate netdevices common structure attached to first one */ + usb_if = kzalloc(sizeof(struct pcan_usb_pro_interface), + GFP_KERNEL); + if (!usb_if) + return -ENOMEM; + + /* number of ts msgs to ignore before taking one into account */ + usb_if->cm_ignore_count = 5; + + /* + * explicit use of dev_xxx() instead of netdev_xxx() here: + * information displayed are related to the device itself, not + * to the canx netdevices. + */ + err = pcan_usb_pro_send_req(dev, PCAN_USBPRO_REQ_INFO, + PCAN_USBPRO_INFO_FW, + &fi, sizeof(fi)); + if (err) { + dev_err(dev->netdev->dev.parent, + "unable to read %s firmware info (err %d)\n", + pcan_usb_pro.name, err); + return err; + } + + err = pcan_usb_pro_send_req(dev, PCAN_USBPRO_REQ_INFO, + PCAN_USBPRO_INFO_BL, + &bi, sizeof(bi)); + if (err) { + dev_err(dev->netdev->dev.parent, + "unable to read %s bootloader info (err %d)\n", + pcan_usb_pro.name, err); + return err; + } + + dev_info(dev->netdev->dev.parent, + "PEAK-System %s hwrev %u serial %08X.%08X (%u channels)\n", + pcan_usb_pro.name, + bi.hw_rev, bi.serial_num_hi, bi.serial_num_lo, + pcan_usb_pro.ctrl_count); + + /* tell the device the can driver is running */ + pcan_usb_pro_drv_loaded(dev, 1); + } else { + usb_if = pcan_usb_pro_dev_if(dev->prev_siblings); + } + + pdev->usb_if = usb_if; + usb_if->dev[dev->ctrl_idx] = dev; + + /* set LED in default state (end of init phase) */ + pcan_usb_pro_set_led(dev, 0, 1); + + return 0; +} + +static void pcan_usb_pro_exit(struct peak_usb_device *dev) +{ + struct pcan_usb_pro_device *pdev = + container_of(dev, struct pcan_usb_pro_device, dev); + + /* + * when rmmod called before unplug and if down, should reset things + * before leaving + */ + if (dev->can.state != CAN_STATE_STOPPED) { + /* set bus off on the corresponding channel */ + pcan_usb_pro_set_bus(dev, 0); + } + + /* if channel #0 (only) */ + if (dev->ctrl_idx == 0) { + /* turn off calibration message if any device were opened */ + if (pdev->usb_if->dev_opened_count > 0) + pcan_usb_pro_set_ts(dev, 0); + + /* tell the PCAN-USB Pro device the driver is being unloaded */ + pcan_usb_pro_drv_loaded(dev, 0); + } +} + +/* + * called when PCAN-USB Pro adapter is unplugged + */ +static void pcan_usb_pro_free(struct peak_usb_device *dev) +{ + /* last device: can free pcan_usb_pro_interface object now */ + if (!dev->prev_siblings && !dev->next_siblings) + kfree(pcan_usb_pro_dev_if(dev)); +} + +/* + * probe function for new PCAN-USB Pro usb interface + */ +static int pcan_usb_pro_probe(struct usb_interface *intf) +{ + struct usb_host_interface *if_desc; + int i; + + if_desc = intf->altsetting; + + /* check interface endpoint addresses */ + for (i = 0; i < if_desc->desc.bNumEndpoints; i++) { + struct usb_endpoint_descriptor *ep = &if_desc->endpoint[i].desc; + + /* + * below is the list of valid ep addreses. Any other ep address + * is considered as not-CAN interface address => no dev created + */ + switch (ep->bEndpointAddress) { + case PCAN_USBPRO_EP_CMDOUT: + case PCAN_USBPRO_EP_CMDIN: + case PCAN_USBPRO_EP_MSGOUT_0: + case PCAN_USBPRO_EP_MSGOUT_1: + case PCAN_USBPRO_EP_MSGIN: + case PCAN_USBPRO_EP_UNUSED: + break; + default: + return -ENODEV; + } + } + + return 0; +} + +/* + * describe the PCAN-USB Pro adapter + */ +struct peak_usb_adapter pcan_usb_pro = { + .name = "PCAN-USB Pro", + .device_id = PCAN_USBPRO_PRODUCT_ID, + .ctrl_count = PCAN_USBPRO_CHANNEL_COUNT, + .clock = { + .freq = PCAN_USBPRO_CRYSTAL_HZ, + }, + .bittiming_const = { + .name = "pcan_usb_pro", + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_max = 4, + .brp_min = 1, + .brp_max = 1024, + .brp_inc = 1, + }, + + /* size of device private data */ + .sizeof_dev_private = sizeof(struct pcan_usb_pro_device), + + /* timestamps usage */ + .ts_used_bits = 32, + .ts_period = 1000000, /* calibration period in ts. */ + .us_per_ts_scale = 1, /* us = (ts * scale) >> shift */ + .us_per_ts_shift = 0, + + /* give here messages in/out endpoints */ + .ep_msg_in = PCAN_USBPRO_EP_MSGIN, + .ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1}, + + /* size of rx/tx usb buffers */ + .rx_buffer_size = PCAN_USBPRO_RX_BUFFER_SIZE, + .tx_buffer_size = PCAN_USBPRO_TX_BUFFER_SIZE, + + /* device callbacks */ + .intf_probe = pcan_usb_pro_probe, + .dev_init = pcan_usb_pro_init, + .dev_exit = pcan_usb_pro_exit, + .dev_free = pcan_usb_pro_free, + .dev_set_bus = pcan_usb_pro_set_bus, + .dev_set_bittiming = pcan_usb_pro_set_bittiming, + .dev_get_device_id = pcan_usb_pro_get_device_id, + .dev_decode_buf = pcan_usb_pro_decode_buf, + .dev_encode_msg = pcan_usb_pro_encode_msg, + .dev_start = pcan_usb_pro_start, + .dev_stop = pcan_usb_pro_stop, + .dev_restart_async = pcan_usb_pro_restart_async, +}; diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.h b/drivers/net/can/usb/peak_usb/pcan_usb_pro.h new file mode 100644 index 000000000000..a869918c5620 --- /dev/null +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.h @@ -0,0 +1,178 @@ +/* + * CAN driver for PEAK System PCAN-USB Pro adapter + * Derived from the PCAN project file driver/src/pcan_usbpro_fw.h + * + * Copyright (C) 2003-2011 PEAK System-Technik GmbH + * Copyright (C) 2011-2012 Stephane Grosjean + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * 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. + */ +#ifndef PCAN_USB_PRO_H +#define PCAN_USB_PRO_H + +/* + * USB Vendor request data types + */ +#define PCAN_USBPRO_REQ_INFO 0 +#define PCAN_USBPRO_REQ_FCT 2 + +/* Vendor Request value for XXX_INFO */ +#define PCAN_USBPRO_INFO_BL 0 +#define PCAN_USBPRO_INFO_FW 1 + +/* Vendor Request value for XXX_FCT */ +#define PCAN_USBPRO_FCT_DRVLD 5 /* tell device driver is loaded */ + +/* PCAN_USBPRO_INFO_BL vendor request record type */ +struct __packed pcan_usb_pro_blinfo { + u32 ctrl_type; + u8 version[4]; + u8 day; + u8 month; + u8 year; + u8 dummy; + u32 serial_num_hi; + u32 serial_num_lo; + u32 hw_type; + u32 hw_rev; +}; + +/* PCAN_USBPRO_INFO_FW vendor request record type */ +struct __packed pcan_usb_pro_fwinfo { + u32 ctrl_type; + u8 version[4]; + u8 day; + u8 month; + u8 year; + u8 dummy; + u32 fw_type; +}; + +/* + * USB Command record types + */ +#define PCAN_USBPRO_SETBTR 0x02 +#define PCAN_USBPRO_SETBUSACT 0x04 +#define PCAN_USBPRO_SETSILENT 0x05 +#define PCAN_USBPRO_SETFILTR 0x0a +#define PCAN_USBPRO_SETTS 0x10 +#define PCAN_USBPRO_GETDEVID 0x12 +#define PCAN_USBPRO_SETLED 0x1C +#define PCAN_USBPRO_RXMSG8 0x80 +#define PCAN_USBPRO_RXMSG4 0x81 +#define PCAN_USBPRO_RXMSG0 0x82 +#define PCAN_USBPRO_RXRTR 0x83 +#define PCAN_USBPRO_RXSTATUS 0x84 +#define PCAN_USBPRO_RXTS 0x85 +#define PCAN_USBPRO_TXMSG8 0x41 +#define PCAN_USBPRO_TXMSG4 0x42 +#define PCAN_USBPRO_TXMSG0 0x43 + +/* record structures */ +struct __packed pcan_usb_pro_btr { + u8 data_type; + u8 channel; + u16 dummy; + u32 CCBT; +}; + +struct __packed pcan_usb_pro_busact { + u8 data_type; + u8 channel; + u16 onoff; +}; + +struct __packed pcan_usb_pro_silent { + u8 data_type; + u8 channel; + u16 onoff; +}; + +struct __packed pcan_usb_pro_filter { + u8 data_type; + u8 dummy; + u16 filter_mode; +}; + +struct __packed pcan_usb_pro_setts { + u8 data_type; + u8 dummy; + u16 mode; +}; + +struct __packed pcan_usb_pro_devid { + u8 data_type; + u8 channel; + u16 dummy; + u32 serial_num; +}; + +struct __packed pcan_usb_pro_setled { + u8 data_type; + u8 channel; + u16 mode; + u32 timeout; +}; + +struct __packed pcan_usb_pro_rxmsg { + u8 data_type; + u8 client; + u8 flags; + u8 len; + u32 ts32; + u32 id; + + u8 data[8]; +}; + +#define PCAN_USBPRO_STATUS_ERROR 0x0001 +#define PCAN_USBPRO_STATUS_BUS 0x0002 +#define PCAN_USBPRO_STATUS_OVERRUN 0x0004 +#define PCAN_USBPRO_STATUS_QOVERRUN 0x0008 + +struct __packed pcan_usb_pro_rxstatus { + u8 data_type; + u8 channel; + u16 status; + u32 ts32; + u32 err_frm; +}; + +struct __packed pcan_usb_pro_rxts { + u8 data_type; + u8 dummy[3]; + u32 ts64[2]; +}; + +struct __packed pcan_usb_pro_txmsg { + u8 data_type; + u8 client; + u8 flags; + u8 len; + u32 id; + u8 data[8]; +}; + +union pcan_usb_pro_rec { + u8 data_type; + struct pcan_usb_pro_btr btr; + struct pcan_usb_pro_busact bus_act; + struct pcan_usb_pro_silent silent_mode; + struct pcan_usb_pro_filter filter_mode; + struct pcan_usb_pro_setts ts; + struct pcan_usb_pro_devid dev_id; + struct pcan_usb_pro_setled set_led; + struct pcan_usb_pro_rxmsg rx_msg; + struct pcan_usb_pro_rxstatus rx_status; + struct pcan_usb_pro_rxts rx_ts; + struct pcan_usb_pro_txmsg tx_msg; +}; + +#endif -- GitLab From 2556cd8603cd1f39205aaf61f054a76133359ae6 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Sat, 3 Mar 2012 15:04:45 -0500 Subject: [PATCH 1305/1846] mdio.h: Include linux/types.h Fixes: /home/davem/src/GIT/net-next/usr/include/linux/mdio.h:271: found __[us]{8,16,32,64} type without #include Signed-off-by: David S. Miller --- include/linux/mdio.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index ec90da7232cc..dfb947959ec9 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -10,6 +10,7 @@ #ifndef __LINUX_MDIO_H__ #define __LINUX_MDIO_H__ +#include #include /* MDIO Manageable Devices (MMDs). */ -- GitLab From c441b456767357322dbc14b55bdc7da0051d0d98 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Sun, 4 Mar 2012 14:48:13 +0000 Subject: [PATCH 1306/1846] tg3: Fix jumbo loopback test on 5719 Loopback on 9K packet fails because the chip has a DMA limit of 4K. The loopback test logic uses a single BD for simplicity. Fix it by reducing the jumbo packet size to the DMA limit. Signed-off-by: Michael Chan Reviewed-by: Benjamin Li Reviewed-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 76f33d5c7272..4b3243b2bdf1 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -11727,6 +11727,10 @@ static int tg3_run_loopback(struct tg3 *tp, u32 pktsz, bool tso_loopback) } else { num_pkts = 1; data_off = ETH_HLEN; + + if (tg3_flag(tp, USE_JUMBO_BDFLAG) && + tx_len > VLAN_ETH_FRAME_LEN) + base_flags |= TXD_FLAG_JMB_PKT; } for (i = data_off; i < tx_len; i++) @@ -11857,6 +11861,10 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) { int err = -EIO; u32 eee_cap; + u32 jmb_pkt_sz = 9000; + + if (tp->dma_limit) + jmb_pkt_sz = tp->dma_limit - ETH_HLEN; eee_cap = tp->phy_flags & TG3_PHYFLG_EEE_CAP; tp->phy_flags &= ~TG3_PHYFLG_EEE_CAP; @@ -11900,7 +11908,7 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) data[0] |= TG3_STD_LOOPBACK_FAILED; if (tg3_flag(tp, JUMBO_RING_ENABLE) && - tg3_run_loopback(tp, 9000 + ETH_HLEN, false)) + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) data[0] |= TG3_JMB_LOOPBACK_FAILED; tg3_mac_loopback(tp, false); @@ -11925,7 +11933,7 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) tg3_run_loopback(tp, ETH_FRAME_LEN, true)) data[1] |= TG3_TSO_LOOPBACK_FAILED; if (tg3_flag(tp, JUMBO_RING_ENABLE) && - tg3_run_loopback(tp, 9000 + ETH_HLEN, false)) + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) data[1] |= TG3_JMB_LOOPBACK_FAILED; if (do_extlpbk) { @@ -11943,7 +11951,7 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) tg3_run_loopback(tp, ETH_FRAME_LEN, true)) data[2] |= TG3_TSO_LOOPBACK_FAILED; if (tg3_flag(tp, JUMBO_RING_ENABLE) && - tg3_run_loopback(tp, 9000 + ETH_HLEN, false)) + tg3_run_loopback(tp, jmb_pkt_sz + ETH_HLEN, false)) data[2] |= TG3_JMB_LOOPBACK_FAILED; } -- GitLab From 6541b806b5f267eda8f127bb7f5fec4e7e4db995 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Sun, 4 Mar 2012 14:48:14 +0000 Subject: [PATCH 1307/1846] tg3: Add memory barriers to sync BD data for weak memory model architectures to ensure that the chip will DMA valid BD data. Signed-off-by: Michael Chan Reviewed-by: Benjamin Li Reviewed-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 4b3243b2bdf1..0da93dbbd0c8 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -5928,6 +5928,9 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) /* Refill RX ring(s). */ if (!tg3_flag(tp, ENABLE_RSS)) { + /* Sync BD data before updating mailbox */ + wmb(); + if (work_mask & RXD_OPAQUE_RING_STD) { tpr->rx_std_prod_idx = std_prod_idx & tp->rx_std_ring_mask; @@ -6970,6 +6973,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) skb_tx_timestamp(skb); netdev_sent_queue(tp->dev, skb->len); + /* Sync BD data before updating mailbox */ + wmb(); + /* Packets are ready, update Tx producer idx local and on card. */ tw32_tx_mbox(tnapi->prodmbox, entry); @@ -11763,6 +11769,9 @@ static int tg3_run_loopback(struct tg3 *tp, u32 pktsz, bool tso_loopback) tnapi->tx_prod++; + /* Sync BD data before updating mailbox */ + wmb(); + tw32_tx_mbox(tnapi->prodmbox, tnapi->tx_prod); tr32_mailbox(tnapi->prodmbox); -- GitLab From 2fae5e3670a666039e6f2fd63e1a5d320c71b913 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Sun, 4 Mar 2012 14:48:15 +0000 Subject: [PATCH 1308/1846] tg3: Fix poor tx performance on 57766 after MTU change GRC reset causes the read DMA engine to go into a mode that breaks up requests into 256 bytes. A PHY reset is required to bring it back to the normal mode. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 0da93dbbd0c8..a8490a473a1c 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -12267,7 +12267,7 @@ static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp, static int tg3_change_mtu(struct net_device *dev, int new_mtu) { struct tg3 *tp = netdev_priv(dev); - int err; + int err, reset_phy = 0; if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU(tp)) return -EINVAL; @@ -12290,7 +12290,13 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) tg3_set_mtu(dev, tp, new_mtu); - err = tg3_restart_hw(tp, 0); + /* Reset PHY, otherwise the read DMA engine will be in a mode that + * breaks all requests to 256 bytes. + */ + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57766) + reset_phy = 1; + + err = tg3_restart_hw(tp, reset_phy); if (!err) tg3_netif_start(tp); -- GitLab From 784db3f06228da81627d23052a6d2ecc38db001a Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 4 Mar 2012 12:54:54 +0000 Subject: [PATCH 1309/1846] ppp: Change copyright notices from ANU to me This changes the copyright notices on the PPP code that I developed in the late 1990s from being copyright The Australian National University to copyright Paul Mackerras. I can do this as I have an acknowledgement in writing from the Head of the Computer Science Department at ANU (where I worked then) that ANU does not claim any intellectual property in this code. While I'm at it, change the copyright notice from BSD-style to GNU GPL like the rest of the kernel. Signed-off-by: Paul Mackerras Signed-off-by: David S. Miller --- drivers/net/ppp/ppp_deflate.c | 30 ++++----------------------- include/linux/ppp-comp.h | 38 ++++------------------------------- include/linux/ppp_defs.h | 38 ++++------------------------------- 3 files changed, 12 insertions(+), 94 deletions(-) diff --git a/drivers/net/ppp/ppp_deflate.c b/drivers/net/ppp/ppp_deflate.c index 1dbdf82a6dfd..602c625d95d5 100644 --- a/drivers/net/ppp/ppp_deflate.c +++ b/drivers/net/ppp/ppp_deflate.c @@ -1,34 +1,12 @@ /* - * ==FILEVERSION 980319== - * * ppp_deflate.c - interface the zlib procedures for Deflate compression * and decompression (as used by gzip) to the PPP code. - * This version is for use with Linux kernel 1.3.X. - * - * Copyright (c) 1994 The Australian National University. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation is hereby granted, provided that the above copyright - * notice appears in all copies. This software is provided without any - * warranty, express or implied. The Australian National University - * makes no representations about the suitability of this software for - * any purpose. - * - * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. * - * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, - * OR MODIFICATIONS. + * Copyright 1994-1998 Paul Mackerras. * - * From: deflate.c,v 1.1 1996/01/18 03:17:48 paulus Exp + * 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. */ #include diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h index b8d4ddd22736..e53ff65935dd 100644 --- a/include/linux/ppp-comp.h +++ b/include/linux/ppp-comp.h @@ -1,42 +1,12 @@ /* * ppp-comp.h - Definitions for doing PPP packet compression. * - * Copyright (c) 1994 The Australian National University. - * All rights reserved. + * Copyright 1994-1998 Paul Mackerras. * - * Permission to use, copy, modify, and distribute this software and its - * documentation is hereby granted, provided that the above copyright - * notice appears in all copies. This software is provided without any - * warranty, express or implied. The Australian National University - * makes no representations about the suitability of this software for - * any purpose. - * - * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, - * OR MODIFICATIONS. + * 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. */ - -/* - * ==FILEVERSION 980319== - * - * NOTE TO MAINTAINERS: - * If you modify this file at all, please set the above date. - * ppp-comp.h is shipped with a PPP distribution as well as with the kernel; - * if everyone increases the FILEVERSION number above, then scripts - * can do the right thing when deciding whether to install a new ppp-comp.h - * file. Don't change the format of that line otherwise, so the - * installation script can recognize it. - */ - #ifndef _NET_PPP_COMP_H #define _NET_PPP_COMP_H diff --git a/include/linux/ppp_defs.h b/include/linux/ppp_defs.h index 0f93ed6b4a88..ba416f67eb62 100644 --- a/include/linux/ppp_defs.h +++ b/include/linux/ppp_defs.h @@ -1,44 +1,14 @@ /* * ppp_defs.h - PPP definitions. * - * Copyright (c) 1994 The Australian National University. - * All rights reserved. + * Copyright 1994-2000 Paul Mackerras. * - * Permission to use, copy, modify, and distribute this software and its - * documentation is hereby granted, provided that the above copyright - * notice appears in all copies. This software is provided without any - * warranty, express or implied. The Australian National University - * makes no representations about the suitability of this software for - * any purpose. - * - * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO - * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, - * OR MODIFICATIONS. + * 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. */ - #include -/* - * ==FILEVERSION 20000114== - * - * NOTE TO MAINTAINERS: - * If you modify this file at all, please set the above date. - * ppp_defs.h is shipped with a PPP distribution as well as with the kernel; - * if everyone increases the FILEVERSION number above, then scripts - * can do the right thing when deciding whether to install a new ppp_defs.h - * file. Don't change the format of that line otherwise, so the - * installation script can recognize it. - */ - #ifndef _PPP_DEFS_H_ #define _PPP_DEFS_H_ -- GitLab From bf7daebb9fba540cb8864f435f153678b3e5c171 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 4 Mar 2012 12:56:04 +0000 Subject: [PATCH 1310/1846] ppp: Move ioctl definitions from if_ppp.h to new ppp-ioctl.h This moves the definitions of the ioctls, constants and structures relating to the ppp_generic interface to userspace out from if_ppp.h to a new file, ppp-ioctl.h. The new file has my copyright since I designed and implemented the ppp_generic interface in the late 1990s. None of the contents of this file comes from the original if_ppp.h published by Carnegie Mellon University. Of the remainder of if_ppp.h, only the PPP_MTU definition was being used, and this replaces the uses of it with PPP_MRU (which is identical). Therefore, this replaces the entire file with the single line #include which clearly doesn't contain any CMU code. Thus I have removed the CMU copyright notice with its problematic advertising clause, and in fact since it's only one trivial line I have not added any other copyright notice. Signed-off-by: Paul Mackerras Signed-off-by: David S. Miller --- Documentation/ioctl/ioctl-number.txt | 2 +- Documentation/networking/ppp_generic.txt | 6 +- drivers/net/ppp/ppp_generic.c | 4 +- drivers/net/ppp/pptp.c | 4 +- include/linux/Kbuild | 1 + include/linux/if_ppp.h | 174 +---------------------- include/linux/ppp-ioctl.h | 119 ++++++++++++++++ 7 files changed, 129 insertions(+), 181 deletions(-) create mode 100644 include/linux/ppp-ioctl.h diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 4840334ea97b..85af5482f0ab 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt @@ -255,7 +255,7 @@ Code Seq#(hex) Include File Comments linux/ixjuser.h 'r' 00-1F linux/msdos_fs.h and fs/fat/dir.c 's' all linux/cdk.h -'t' 00-7F linux/if_ppp.h +'t' 00-7F linux/ppp-ioctl.h 't' 80-8F linux/isdn_ppp.h 't' 90 linux/toshiba.h 'u' 00-1F linux/smb_fs.h gone diff --git a/Documentation/networking/ppp_generic.txt b/Documentation/networking/ppp_generic.txt index 15b5172fbb98..091d20273dcb 100644 --- a/Documentation/networking/ppp_generic.txt +++ b/Documentation/networking/ppp_generic.txt @@ -342,7 +342,7 @@ an interface unit are: numbers on received multilink fragments SC_MP_XSHORTSEQ transmit short multilink sequence nos. - The values of these flags are defined in . Note + The values of these flags are defined in . Note that the values of the SC_MULTILINK, SC_MP_SHORTSEQ and SC_MP_XSHORTSEQ bits are ignored if the CONFIG_PPP_MULTILINK option is not selected. @@ -358,7 +358,7 @@ an interface unit are: * PPPIOCSCOMPRESS sets the parameters for packet compression or decompression. The argument should point to a ppp_option_data - structure (defined in ), which contains a + structure (defined in ), which contains a pointer/length pair which should describe a block of memory containing a CCP option specifying a compression method and its parameters. The ppp_option_data struct also contains a `transmit' @@ -395,7 +395,7 @@ an interface unit are: * PPPIOCSNPMODE sets the network-protocol mode for a given network protocol. The argument should point to an npioctl struct (defined - in ). The `protocol' field gives the PPP protocol + in ). The `protocol' field gives the PPP protocol number for the protocol to be affected, and the `mode' field specifies what to do with packets for that protocol: diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 6d4d2ebb0a8a..159da2905fe9 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -1031,7 +1031,7 @@ static void ppp_setup(struct net_device *dev) { dev->netdev_ops = &ppp_netdev_ops; dev->hard_header_len = PPP_HDRLEN; - dev->mtu = PPP_MTU; + dev->mtu = PPP_MRU; dev->addr_len = 0; dev->tx_queue_len = 3; dev->type = ARPHRD_PPP; diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index 234cd9d87ed9..885dbdd9c39e 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -481,7 +481,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.mtu = dst_mtu(&rt->dst); if (!po->chan.mtu) - po->chan.mtu = PPP_MTU; + po->chan.mtu = PPP_MRU; ip_rt_put(rt); po->chan.mtu -= PPTP_HEADER_OVERHEAD; diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 4b0b7ed4a999..a25555381097 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -305,6 +305,7 @@ header-y += poll.h header-y += posix_types.h header-y += ppdev.h header-y += ppp-comp.h +header-y += ppp-ioctl.h header-y += ppp_defs.h header-y += pps.h header-y += prctl.h diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h index c9ad38322576..9048fabb7a4e 100644 --- a/include/linux/if_ppp.h +++ b/include/linux/if_ppp.h @@ -1,173 +1 @@ -/* - * if_ppp.h - Point-to-Point Protocol definitions. - * - * Copyright (c) 1989 Carnegie Mellon University. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Carnegie Mellon University. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -/* - * ==FILEVERSION 20050812== - * - * NOTE TO MAINTAINERS: - * If you modify this file at all, please set the above date. - * if_ppp.h is shipped with a PPP distribution as well as with the kernel; - * if everyone increases the FILEVERSION number above, then scripts - * can do the right thing when deciding whether to install a new if_ppp.h - * file. Don't change the format of that line otherwise, so the - * installation script can recognize it. - */ - -#ifndef _IF_PPP_H_ -#define _IF_PPP_H_ - -#include -#include - -/* - * Packet sizes - */ - -#define PPP_MTU 1500 /* Default MTU (size of Info field) */ -#define PPP_MAXMRU 65000 /* Largest MRU we allow */ -#define PROTO_IPX 0x002b /* protocol numbers */ -#define PROTO_DNA_RT 0x0027 /* DNA Routing */ - - -/* - * Bit definitions for flags. - */ - -#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ -#define SC_COMP_AC 0x00000002 /* header compression (output) */ -#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ -#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ -#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ -#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ -#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */ -#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */ -#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */ -#define SC_LOOP_TRAFFIC 0x00000200 /* send traffic to pppd */ -#define SC_MULTILINK 0x00000400 /* do multilink encapsulation */ -#define SC_MP_SHORTSEQ 0x00000800 /* use short MP sequence numbers */ -#define SC_COMP_RUN 0x00001000 /* compressor has been inited */ -#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */ -#define SC_MP_XSHORTSEQ 0x00004000 /* transmit short MP seq numbers */ -#define SC_DEBUG 0x00010000 /* enable debug messages */ -#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */ -#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */ -#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ -#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ -#define SC_SYNC 0x00200000 /* synchronous serial mode */ -#define SC_MUST_COMP 0x00400000 /* no uncompressed packets may be sent or received */ -#define SC_MASK 0x0f600fff /* bits that user can change */ - -/* state bits */ -#define SC_XMIT_BUSY 0x10000000 /* (used by isdn_ppp?) */ -#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ -#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ -#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ -#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ -#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */ -#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */ - -/* - * Ioctl definitions. - */ - -struct npioctl { - int protocol; /* PPP protocol, e.g. PPP_IP */ - enum NPmode mode; -}; - -/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */ -struct ppp_option_data { - __u8 __user *ptr; - __u32 length; - int transmit; -}; - -struct ifpppstatsreq { - struct ifreq b; - struct ppp_stats stats; /* statistic information */ -}; - -struct ifpppcstatsreq { - struct ifreq b; - struct ppp_comp_stats stats; -}; - -/* For PPPIOCGL2TPSTATS */ -struct pppol2tp_ioc_stats { - __u16 tunnel_id; /* redundant */ - __u16 session_id; /* if zero, get tunnel stats */ - __u32 using_ipsec:1; /* valid only for session_id == 0 */ - __aligned_u64 tx_packets; - __aligned_u64 tx_bytes; - __aligned_u64 tx_errors; - __aligned_u64 rx_packets; - __aligned_u64 rx_bytes; - __aligned_u64 rx_seq_discards; - __aligned_u64 rx_oos_packets; - __aligned_u64 rx_errors; -}; - -#define ifr__name b.ifr_ifrn.ifrn_name -#define stats_ptr b.ifr_ifru.ifru_data - -/* - * Ioctl definitions. - */ - -#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ -#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ -#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */ -#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */ -#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */ -#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */ -#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */ -#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */ -#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */ -#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */ -#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */ -#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */ -#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */ -#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data) -#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */ -#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */ -#define PPPIOCSPASS _IOW('t', 71, struct sock_fprog) /* set pass filter */ -#define PPPIOCSACTIVE _IOW('t', 70, struct sock_fprog) /* set active filt */ -#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */ -#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */ -#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ -#define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */ -#define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */ -#define PPPIOCDETACH _IOW('t', 60, int) /* detach from ppp unit/chan */ -#define PPPIOCSMRRU _IOW('t', 59, int) /* set multilink MRU */ -#define PPPIOCCONNECT _IOW('t', 58, int) /* connect channel to unit */ -#define PPPIOCDISCONN _IO('t', 57) /* disconnect channel */ -#define PPPIOCATTCHAN _IOW('t', 56, int) /* attach to ppp channel */ -#define PPPIOCGCHAN _IOR('t', 55, int) /* get ppp channel number */ -#define PPPIOCGL2TPSTATS _IOR('t', 54, struct pppol2tp_ioc_stats) - -#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0) -#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */ -#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2) - -#if !defined(ifr_mtu) -#define ifr_mtu ifr_ifru.ifru_metric -#endif - -#endif /* _IF_PPP_H_ */ +#include diff --git a/include/linux/ppp-ioctl.h b/include/linux/ppp-ioctl.h new file mode 100644 index 000000000000..2d9a8859550a --- /dev/null +++ b/include/linux/ppp-ioctl.h @@ -0,0 +1,119 @@ +/* + * ppp-ioctl.h - PPP ioctl definitions. + * + * Copyright 1999-2002 Paul Mackerras. + * + * 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. + */ +#ifndef _PPP_IOCTL_H +#define _PPP_IOCTL_H + +#include +#include + +/* + * Bit definitions for flags argument to PPPIOCGFLAGS/PPPIOCSFLAGS. + */ +#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ +#define SC_COMP_AC 0x00000002 /* header compression (output) */ +#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ +#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ +#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ +#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ +#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */ +#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */ +#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */ +#define SC_LOOP_TRAFFIC 0x00000200 /* send traffic to pppd */ +#define SC_MULTILINK 0x00000400 /* do multilink encapsulation */ +#define SC_MP_SHORTSEQ 0x00000800 /* use short MP sequence numbers */ +#define SC_COMP_RUN 0x00001000 /* compressor has been inited */ +#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */ +#define SC_MP_XSHORTSEQ 0x00004000 /* transmit short MP seq numbers */ +#define SC_DEBUG 0x00010000 /* enable debug messages */ +#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */ +#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */ +#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ +#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ +#define SC_SYNC 0x00200000 /* synchronous serial mode */ +#define SC_MUST_COMP 0x00400000 /* no uncompressed packets may be sent or received */ +#define SC_MASK 0x0f600fff /* bits that user can change */ + +/* state bits */ +#define SC_XMIT_BUSY 0x10000000 /* (used by isdn_ppp?) */ +#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ +#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ +#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ +#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ +#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */ +#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */ + +/* Used with PPPIOCGNPMODE/PPPIOCSNPMODE */ +struct npioctl { + int protocol; /* PPP protocol, e.g. PPP_IP */ + enum NPmode mode; +}; + +/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */ +struct ppp_option_data { + __u8 __user *ptr; + __u32 length; + int transmit; +}; + +/* For PPPIOCGL2TPSTATS */ +struct pppol2tp_ioc_stats { + __u16 tunnel_id; /* redundant */ + __u16 session_id; /* if zero, get tunnel stats */ + __u32 using_ipsec:1; /* valid only for session_id == 0 */ + __aligned_u64 tx_packets; + __aligned_u64 tx_bytes; + __aligned_u64 tx_errors; + __aligned_u64 rx_packets; + __aligned_u64 rx_bytes; + __aligned_u64 rx_seq_discards; + __aligned_u64 rx_oos_packets; + __aligned_u64 rx_errors; +}; + +/* + * Ioctl definitions. + */ + +#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ +#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ +#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */ +#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */ +#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */ +#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */ +#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */ +#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */ +#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */ +#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */ +#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */ +#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */ +#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */ +#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data) +#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */ +#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */ +#define PPPIOCSPASS _IOW('t', 71, struct sock_fprog) /* set pass filter */ +#define PPPIOCSACTIVE _IOW('t', 70, struct sock_fprog) /* set active filt */ +#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */ +#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */ +#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ +#define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */ +#define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */ +#define PPPIOCDETACH _IOW('t', 60, int) /* detach from ppp unit/chan */ +#define PPPIOCSMRRU _IOW('t', 59, int) /* set multilink MRU */ +#define PPPIOCCONNECT _IOW('t', 58, int) /* connect channel to unit */ +#define PPPIOCDISCONN _IO('t', 57) /* disconnect channel */ +#define PPPIOCATTCHAN _IOW('t', 56, int) /* attach to ppp channel */ +#define PPPIOCGCHAN _IOR('t', 55, int) /* get ppp channel number */ +#define PPPIOCGL2TPSTATS _IOR('t', 54, struct pppol2tp_ioc_stats) + +#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0) +#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */ +#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2) + +#endif /* _PPP_IOCTL_H */ -- GitLab From 4b32da2bcf1de2b7a196a0e48389d231b4472c36 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 4 Mar 2012 12:56:55 +0000 Subject: [PATCH 1311/1846] ppp: Replace uses of with Since all that include/linux/if_ppp.h does is #include , this replaces the occurrences of #include with #include . It also corrects an error in Documentation/networking/l2tp.txt, where it referenced include/linux/if_ppp.h as the source of some definitions that are actually now defined in include/linux/if_pppol2tp.h. Signed-off-by: Paul Mackerras Signed-off-by: David S. Miller --- Documentation/networking/l2tp.txt | 2 +- drivers/isdn/capi/capi.c | 2 +- drivers/net/ppp/ppp_async.c | 2 +- drivers/net/ppp/ppp_synctty.c | 2 +- drivers/net/ppp/pppoe.c | 2 +- drivers/net/ppp/pppox.c | 2 +- drivers/tty/ipwireless/network.c | 2 +- drivers/tty/ipwireless/tty.c | 2 +- fs/compat_ioctl.c | 2 +- include/linux/isdn.h | 2 +- net/atm/pppoatm.c | 2 +- net/irda/irnet/irnet.h | 2 +- net/l2tp/l2tp_ppp.c | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Documentation/networking/l2tp.txt b/Documentation/networking/l2tp.txt index e7bf3979facb..e63fc1f7bf87 100644 --- a/Documentation/networking/l2tp.txt +++ b/Documentation/networking/l2tp.txt @@ -111,7 +111,7 @@ When creating PPPoL2TP sockets, the application provides information to the driver about the socket in a socket connect() call. Source and destination tunnel and session ids are provided, as well as the file descriptor of a UDP socket. See struct pppol2tp_addr in -include/linux/if_ppp.h. Note that zero tunnel / session ids are +include/linux/if_pppol2tp.h. Note that zero tunnel / session ids are treated specially. When creating the per-tunnel PPPoL2TP management socket in Step 2 above, zero source and destination session ids are specified, which tells the driver to prepare the supplied UDP file diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index d33a70c49180..0cf05464bfb7 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index c6ba64380829..af95a98fd86f 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index 736a39ee05bb..55e466c511d5 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index bc9a4bb31980..2fa1a9b6f498 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c @@ -72,7 +72,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/net/ppp/pppox.c b/drivers/net/ppp/pppox.c index 8c0d170dabcd..2940e9fe351b 100644 --- a/drivers/net/ppp/pppox.c +++ b/drivers/net/ppp/pppox.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c index f7daeea598e4..57c8b481113f 100644 --- a/drivers/tty/ipwireless/network.c +++ b/drivers/tty/ipwireless/network.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include "network.h" diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index ef92869502a7..2ffa0b77770a 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index a26bea10e81b..10d8cd90ca6f 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 4ccf95d681b4..292f27a793d4 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -187,7 +187,7 @@ typedef struct { #endif #include -#include +#include #include #endif diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c index df35d9a3b5fe..614d3fc47ede 100644 --- a/net/atm/pppoatm.c +++ b/net/atm/pppoatm.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h index 979ecb2435a7..564eb0b8afa3 100644 --- a/net/irda/irnet/irnet.h +++ b/net/irda/irnet/irnet.h @@ -254,7 +254,7 @@ #include #include -#include +#include #include #include diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 8a90d756c904..96bc7a67585a 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -82,7 +82,7 @@ #include #include #include -#include +#include #include #include #include -- GitLab From e19a82c18f0e6360ee9fd431721794eb0036c0cd Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 27 Feb 2012 02:36:29 +0000 Subject: [PATCH 1312/1846] ucc_geth: separate out rx/tx ring alloc and free operations Factor out the the existing allocation and free operations so that they can be used individually. This is to improve code readability, and also to prepare for possible future changes like better error recovery and more dynamic configuration (e.g on-the-fly resizing of the rings). This change represents a straight up relocation of the existing code into separate routines without changing any of the contained code itself. Local variables are relocated as necessary. Signed-off-by: Paul Gortmaker Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/ucc_geth.c | 453 ++++++++++++---------- 1 file changed, 257 insertions(+), 196 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index ec0905461312..4e3cd2f8debb 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -1856,11 +1856,93 @@ static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *uge return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */ } -static void ucc_geth_memclean(struct ucc_geth_private *ugeth) +static void ucc_geth_free_rx(struct ucc_geth_private *ugeth) +{ + struct ucc_geth_info *ug_info; + struct ucc_fast_info *uf_info; + u16 i, j; + u8 __iomem *bd; + + + ug_info = ugeth->ug_info; + uf_info = &ug_info->uf_info; + + for (i = 0; i < ugeth->ug_info->numQueuesRx; i++) { + if (ugeth->p_rx_bd_ring[i]) { + /* Return existing data buffers in ring */ + bd = ugeth->p_rx_bd_ring[i]; + for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) { + if (ugeth->rx_skbuff[i][j]) { + dma_unmap_single(ugeth->dev, + in_be32(&((struct qe_bd __iomem *)bd)->buf), + ugeth->ug_info-> + uf_info.max_rx_buf_length + + UCC_GETH_RX_DATA_BUF_ALIGNMENT, + DMA_FROM_DEVICE); + dev_kfree_skb_any( + ugeth->rx_skbuff[i][j]); + ugeth->rx_skbuff[i][j] = NULL; + } + bd += sizeof(struct qe_bd); + } + + kfree(ugeth->rx_skbuff[i]); + + if (ugeth->ug_info->uf_info.bd_mem_part == + MEM_PART_SYSTEM) + kfree((void *)ugeth->rx_bd_ring_offset[i]); + else if (ugeth->ug_info->uf_info.bd_mem_part == + MEM_PART_MURAM) + qe_muram_free(ugeth->rx_bd_ring_offset[i]); + ugeth->p_rx_bd_ring[i] = NULL; + } + } + +} + +static void ucc_geth_free_tx(struct ucc_geth_private *ugeth) { + struct ucc_geth_info *ug_info; + struct ucc_fast_info *uf_info; u16 i, j; u8 __iomem *bd; + ug_info = ugeth->ug_info; + uf_info = &ug_info->uf_info; + + for (i = 0; i < ugeth->ug_info->numQueuesTx; i++) { + bd = ugeth->p_tx_bd_ring[i]; + if (!bd) + continue; + for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { + if (ugeth->tx_skbuff[i][j]) { + dma_unmap_single(ugeth->dev, + in_be32(&((struct qe_bd __iomem *)bd)->buf), + (in_be32((u32 __iomem *)bd) & + BD_LENGTH_MASK), + DMA_TO_DEVICE); + dev_kfree_skb_any(ugeth->tx_skbuff[i][j]); + ugeth->tx_skbuff[i][j] = NULL; + } + } + + kfree(ugeth->tx_skbuff[i]); + + if (ugeth->p_tx_bd_ring[i]) { + if (ugeth->ug_info->uf_info.bd_mem_part == + MEM_PART_SYSTEM) + kfree((void *)ugeth->tx_bd_ring_offset[i]); + else if (ugeth->ug_info->uf_info.bd_mem_part == + MEM_PART_MURAM) + qe_muram_free(ugeth->tx_bd_ring_offset[i]); + ugeth->p_tx_bd_ring[i] = NULL; + } + } + +} + +static void ucc_geth_memclean(struct ucc_geth_private *ugeth) +{ if (!ugeth) return; @@ -1927,64 +2009,8 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth) kfree(ugeth->p_init_enet_param_shadow); ugeth->p_init_enet_param_shadow = NULL; } - for (i = 0; i < ugeth->ug_info->numQueuesTx; i++) { - bd = ugeth->p_tx_bd_ring[i]; - if (!bd) - continue; - for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { - if (ugeth->tx_skbuff[i][j]) { - dma_unmap_single(ugeth->dev, - in_be32(&((struct qe_bd __iomem *)bd)->buf), - (in_be32((u32 __iomem *)bd) & - BD_LENGTH_MASK), - DMA_TO_DEVICE); - dev_kfree_skb_any(ugeth->tx_skbuff[i][j]); - ugeth->tx_skbuff[i][j] = NULL; - } - } - - kfree(ugeth->tx_skbuff[i]); - - if (ugeth->p_tx_bd_ring[i]) { - if (ugeth->ug_info->uf_info.bd_mem_part == - MEM_PART_SYSTEM) - kfree((void *)ugeth->tx_bd_ring_offset[i]); - else if (ugeth->ug_info->uf_info.bd_mem_part == - MEM_PART_MURAM) - qe_muram_free(ugeth->tx_bd_ring_offset[i]); - ugeth->p_tx_bd_ring[i] = NULL; - } - } - for (i = 0; i < ugeth->ug_info->numQueuesRx; i++) { - if (ugeth->p_rx_bd_ring[i]) { - /* Return existing data buffers in ring */ - bd = ugeth->p_rx_bd_ring[i]; - for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) { - if (ugeth->rx_skbuff[i][j]) { - dma_unmap_single(ugeth->dev, - in_be32(&((struct qe_bd __iomem *)bd)->buf), - ugeth->ug_info-> - uf_info.max_rx_buf_length + - UCC_GETH_RX_DATA_BUF_ALIGNMENT, - DMA_FROM_DEVICE); - dev_kfree_skb_any( - ugeth->rx_skbuff[i][j]); - ugeth->rx_skbuff[i][j] = NULL; - } - bd += sizeof(struct qe_bd); - } - - kfree(ugeth->rx_skbuff[i]); - - if (ugeth->ug_info->uf_info.bd_mem_part == - MEM_PART_SYSTEM) - kfree((void *)ugeth->rx_bd_ring_offset[i]); - else if (ugeth->ug_info->uf_info.bd_mem_part == - MEM_PART_MURAM) - qe_muram_free(ugeth->rx_bd_ring_offset[i]); - ugeth->p_rx_bd_ring[i] = NULL; - } - } + ucc_geth_free_tx(ugeth); + ucc_geth_free_rx(ugeth); while (!list_empty(&ugeth->group_hash_q)) put_enet_addr_container(ENET_ADDR_CONT_ENTRY (dequeue(&ugeth->group_hash_q))); @@ -2210,6 +2236,171 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth) return 0; } +static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth) +{ + struct ucc_geth_info *ug_info; + struct ucc_fast_info *uf_info; + int length; + u16 i, j; + u8 __iomem *bd; + + ug_info = ugeth->ug_info; + uf_info = &ug_info->uf_info; + + /* Allocate Tx bds */ + for (j = 0; j < ug_info->numQueuesTx; j++) { + /* Allocate in multiple of + UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT, + according to spec */ + length = ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) + / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) + * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; + if ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) % + UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) + length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; + if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { + u32 align = 4; + if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4) + align = UCC_GETH_TX_BD_RING_ALIGNMENT; + ugeth->tx_bd_ring_offset[j] = + (u32) kmalloc((u32) (length + align), GFP_KERNEL); + + if (ugeth->tx_bd_ring_offset[j] != 0) + ugeth->p_tx_bd_ring[j] = + (u8 __iomem *)((ugeth->tx_bd_ring_offset[j] + + align) & ~(align - 1)); + } else if (uf_info->bd_mem_part == MEM_PART_MURAM) { + ugeth->tx_bd_ring_offset[j] = + qe_muram_alloc(length, + UCC_GETH_TX_BD_RING_ALIGNMENT); + if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j])) + ugeth->p_tx_bd_ring[j] = + (u8 __iomem *) qe_muram_addr(ugeth-> + tx_bd_ring_offset[j]); + } + if (!ugeth->p_tx_bd_ring[j]) { + if (netif_msg_ifup(ugeth)) + ugeth_err + ("%s: Can not allocate memory for Tx bd rings.", + __func__); + return -ENOMEM; + } + /* Zero unused end of bd ring, according to spec */ + memset_io((void __iomem *)(ugeth->p_tx_bd_ring[j] + + ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)), 0, + length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)); + } + + /* Init Tx bds */ + for (j = 0; j < ug_info->numQueuesTx; j++) { + /* Setup the skbuff rings */ + ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * + ugeth->ug_info->bdRingLenTx[j], + GFP_KERNEL); + + if (ugeth->tx_skbuff[j] == NULL) { + if (netif_msg_ifup(ugeth)) + ugeth_err("%s: Could not allocate tx_skbuff", + __func__); + return -ENOMEM; + } + + for (i = 0; i < ugeth->ug_info->bdRingLenTx[j]; i++) + ugeth->tx_skbuff[j][i] = NULL; + + ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0; + bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j]; + for (i = 0; i < ug_info->bdRingLenTx[j]; i++) { + /* clear bd buffer */ + out_be32(&((struct qe_bd __iomem *)bd)->buf, 0); + /* set bd status and length */ + out_be32((u32 __iomem *)bd, 0); + bd += sizeof(struct qe_bd); + } + bd -= sizeof(struct qe_bd); + /* set bd status and length */ + out_be32((u32 __iomem *)bd, T_W); /* for last BD set Wrap bit */ + } + + return 0; +} + +static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth) +{ + struct ucc_geth_info *ug_info; + struct ucc_fast_info *uf_info; + int length; + u16 i, j; + u8 __iomem *bd; + + ug_info = ugeth->ug_info; + uf_info = &ug_info->uf_info; + + /* Allocate Rx bds */ + for (j = 0; j < ug_info->numQueuesRx; j++) { + length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd); + if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { + u32 align = 4; + if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4) + align = UCC_GETH_RX_BD_RING_ALIGNMENT; + ugeth->rx_bd_ring_offset[j] = + (u32) kmalloc((u32) (length + align), GFP_KERNEL); + if (ugeth->rx_bd_ring_offset[j] != 0) + ugeth->p_rx_bd_ring[j] = + (u8 __iomem *)((ugeth->rx_bd_ring_offset[j] + + align) & ~(align - 1)); + } else if (uf_info->bd_mem_part == MEM_PART_MURAM) { + ugeth->rx_bd_ring_offset[j] = + qe_muram_alloc(length, + UCC_GETH_RX_BD_RING_ALIGNMENT); + if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j])) + ugeth->p_rx_bd_ring[j] = + (u8 __iomem *) qe_muram_addr(ugeth-> + rx_bd_ring_offset[j]); + } + if (!ugeth->p_rx_bd_ring[j]) { + if (netif_msg_ifup(ugeth)) + ugeth_err + ("%s: Can not allocate memory for Rx bd rings.", + __func__); + return -ENOMEM; + } + } + + /* Init Rx bds */ + for (j = 0; j < ug_info->numQueuesRx; j++) { + /* Setup the skbuff rings */ + ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * + ugeth->ug_info->bdRingLenRx[j], + GFP_KERNEL); + + if (ugeth->rx_skbuff[j] == NULL) { + if (netif_msg_ifup(ugeth)) + ugeth_err("%s: Could not allocate rx_skbuff", + __func__); + return -ENOMEM; + } + + for (i = 0; i < ugeth->ug_info->bdRingLenRx[j]; i++) + ugeth->rx_skbuff[j][i] = NULL; + + ugeth->skb_currx[j] = 0; + bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j]; + for (i = 0; i < ug_info->bdRingLenRx[j]; i++) { + /* set bd status and length */ + out_be32((u32 __iomem *)bd, R_I); + /* clear bd buffer */ + out_be32(&((struct qe_bd __iomem *)bd)->buf, 0); + bd += sizeof(struct qe_bd); + } + bd -= sizeof(struct qe_bd); + /* set bd status and length */ + out_be32((u32 __iomem *)bd, R_W); /* for last BD set Wrap bit */ + } + + return 0; +} + static int ucc_geth_startup(struct ucc_geth_private *ugeth) { struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt; @@ -2222,11 +2413,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) int ret_val = -EINVAL; u32 remoder = UCC_GETH_REMODER_INIT; u32 init_enet_pram_offset, cecr_subblock, command; - u32 ifstat, i, j, size, l2qt, l3qt, length; + u32 ifstat, i, j, size, l2qt, l3qt; u16 temoder = UCC_GETH_TEMODER_INIT; u16 test; u8 function_code = 0; - u8 __iomem *bd; u8 __iomem *endOfRing; u8 numThreadsRxNumerical, numThreadsTxNumerical; @@ -2366,142 +2556,13 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE), 0, &uf_regs->upsmr, &ug_regs->uescr); - /* Allocate Tx bds */ - for (j = 0; j < ug_info->numQueuesTx; j++) { - /* Allocate in multiple of - UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT, - according to spec */ - length = ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) - / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) - * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; - if ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) % - UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) - length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; - if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { - u32 align = 4; - if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4) - align = UCC_GETH_TX_BD_RING_ALIGNMENT; - ugeth->tx_bd_ring_offset[j] = - (u32) kmalloc((u32) (length + align), GFP_KERNEL); - - if (ugeth->tx_bd_ring_offset[j] != 0) - ugeth->p_tx_bd_ring[j] = - (u8 __iomem *)((ugeth->tx_bd_ring_offset[j] + - align) & ~(align - 1)); - } else if (uf_info->bd_mem_part == MEM_PART_MURAM) { - ugeth->tx_bd_ring_offset[j] = - qe_muram_alloc(length, - UCC_GETH_TX_BD_RING_ALIGNMENT); - if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j])) - ugeth->p_tx_bd_ring[j] = - (u8 __iomem *) qe_muram_addr(ugeth-> - tx_bd_ring_offset[j]); - } - if (!ugeth->p_tx_bd_ring[j]) { - if (netif_msg_ifup(ugeth)) - ugeth_err - ("%s: Can not allocate memory for Tx bd rings.", - __func__); - return -ENOMEM; - } - /* Zero unused end of bd ring, according to spec */ - memset_io((void __iomem *)(ugeth->p_tx_bd_ring[j] + - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)), 0, - length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)); - } - - /* Allocate Rx bds */ - for (j = 0; j < ug_info->numQueuesRx; j++) { - length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd); - if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { - u32 align = 4; - if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4) - align = UCC_GETH_RX_BD_RING_ALIGNMENT; - ugeth->rx_bd_ring_offset[j] = - (u32) kmalloc((u32) (length + align), GFP_KERNEL); - if (ugeth->rx_bd_ring_offset[j] != 0) - ugeth->p_rx_bd_ring[j] = - (u8 __iomem *)((ugeth->rx_bd_ring_offset[j] + - align) & ~(align - 1)); - } else if (uf_info->bd_mem_part == MEM_PART_MURAM) { - ugeth->rx_bd_ring_offset[j] = - qe_muram_alloc(length, - UCC_GETH_RX_BD_RING_ALIGNMENT); - if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j])) - ugeth->p_rx_bd_ring[j] = - (u8 __iomem *) qe_muram_addr(ugeth-> - rx_bd_ring_offset[j]); - } - if (!ugeth->p_rx_bd_ring[j]) { - if (netif_msg_ifup(ugeth)) - ugeth_err - ("%s: Can not allocate memory for Rx bd rings.", - __func__); - return -ENOMEM; - } - } - - /* Init Tx bds */ - for (j = 0; j < ug_info->numQueuesTx; j++) { - /* Setup the skbuff rings */ - ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * - ugeth->ug_info->bdRingLenTx[j], - GFP_KERNEL); - - if (ugeth->tx_skbuff[j] == NULL) { - if (netif_msg_ifup(ugeth)) - ugeth_err("%s: Could not allocate tx_skbuff", - __func__); - return -ENOMEM; - } - - for (i = 0; i < ugeth->ug_info->bdRingLenTx[j]; i++) - ugeth->tx_skbuff[j][i] = NULL; - - ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0; - bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j]; - for (i = 0; i < ug_info->bdRingLenTx[j]; i++) { - /* clear bd buffer */ - out_be32(&((struct qe_bd __iomem *)bd)->buf, 0); - /* set bd status and length */ - out_be32((u32 __iomem *)bd, 0); - bd += sizeof(struct qe_bd); - } - bd -= sizeof(struct qe_bd); - /* set bd status and length */ - out_be32((u32 __iomem *)bd, T_W); /* for last BD set Wrap bit */ - } - - /* Init Rx bds */ - for (j = 0; j < ug_info->numQueuesRx; j++) { - /* Setup the skbuff rings */ - ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * - ugeth->ug_info->bdRingLenRx[j], - GFP_KERNEL); - - if (ugeth->rx_skbuff[j] == NULL) { - if (netif_msg_ifup(ugeth)) - ugeth_err("%s: Could not allocate rx_skbuff", - __func__); - return -ENOMEM; - } - - for (i = 0; i < ugeth->ug_info->bdRingLenRx[j]; i++) - ugeth->rx_skbuff[j][i] = NULL; + ret_val = ucc_geth_alloc_tx(ugeth); + if (ret_val != 0) + return ret_val; - ugeth->skb_currx[j] = 0; - bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j]; - for (i = 0; i < ug_info->bdRingLenRx[j]; i++) { - /* set bd status and length */ - out_be32((u32 __iomem *)bd, R_I); - /* clear bd buffer */ - out_be32(&((struct qe_bd __iomem *)bd)->buf, 0); - bd += sizeof(struct qe_bd); - } - bd -= sizeof(struct qe_bd); - /* set bd status and length */ - out_be32((u32 __iomem *)bd, R_W); /* for last BD set Wrap bit */ - } + ret_val = ucc_geth_alloc_rx(ugeth); + if (ret_val != 0) + return ret_val; /* * Global PRAM -- GitLab From 0b471506712dd734964b3270d2aa88160712c262 Mon Sep 17 00:00:00 2001 From: Matt Carlson Date: Mon, 27 Feb 2012 09:44:48 +0000 Subject: [PATCH 1313/1846] tg3: Recode PCI MRRS adjustment as a PCI quirk This patch recodes the MRRS cap for 5719 A0 devices as a PCI quirk. Signed-off-by: Matt Carlson Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 6 ------ drivers/pci/quirks.c | 18 ++++++++++++++++++ include/linux/pci_ids.h | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index a8490a473a1c..bc236b6a7a91 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -14242,12 +14242,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) tg3_flag_set(tp, PCI_EXPRESS); - if (tp->pci_chip_rev_id == CHIPREV_ID_5719_A0) { - int readrq = pcie_get_readrq(tp->pdev); - if (readrq > 2048) - pcie_set_readrq(tp->pdev, 2048); - } - pci_read_config_word(tp->pdev, pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, &lnkctl); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 64765474676f..f722c5f6951a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -2161,6 +2161,24 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709S, quirk_brcm_570x_limit_vpd); +static void __devinit quirk_brcm_5719_limit_mrrs(struct pci_dev *dev) +{ + u32 rev; + + pci_read_config_dword(dev, 0xf4, &rev); + + /* Only CAP the MRRS if the device is a 5719 A0 */ + if (rev == 0x05719000) { + int readrq = pcie_get_readrq(dev); + if (readrq > 2048) + pcie_set_readrq(dev, 2048); + } +} + +DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_BROADCOM, + PCI_DEVICE_ID_TIGON3_5719, + quirk_brcm_5719_limit_mrrs); + /* Originally in EDAC sources for i82875P: * Intel tells BIOS developers to hide device 6 which * configures the overflow device access containing diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 31d77af2ef42..3329965ed63f 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2105,6 +2105,7 @@ #define PCI_DEVICE_ID_NX2_57711E 0x1650 #define PCI_DEVICE_ID_TIGON3_5705 0x1653 #define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 +#define PCI_DEVICE_ID_TIGON3_5719 0x1657 #define PCI_DEVICE_ID_TIGON3_5721 0x1659 #define PCI_DEVICE_ID_TIGON3_5722 0x165a #define PCI_DEVICE_ID_TIGON3_5723 0x165b -- GitLab From 4c1dc80a74384829e467ba078260094d1ffdd963 Mon Sep 17 00:00:00 2001 From: Shreyas Bhatewara Date: Tue, 28 Feb 2012 22:08:39 +0000 Subject: [PATCH 1314/1846] vmxnet3: Fix log messages and corrects some typos Fix log messages and corrects some typos Change logging of failure to enable MSI/MSI-X to display device's PCI address instead of eth%d. Rectify a typo. Signed-off-by: Shreyas N Bhatewara Reviewed-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/vmxnet3/vmxnet3_drv.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index adf527e27583..a9684a53af19 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -2704,8 +2704,8 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter, adapter->intr.num_intrs = vectors; return 0; } else if (err < 0) { - printk(KERN_ERR "Failed to enable MSI-X for %s, error" - " %d\n", adapter->netdev->name, err); + netdev_err(adapter->netdev, + "Failed to enable MSI-X, error: %d\n", err); vectors = 0; } else if (err < vector_threshold) { break; @@ -2713,15 +2713,15 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter, /* If fails to enable required number of MSI-x vectors * try enabling minimum number of vectors required. */ + netdev_err(adapter->netdev, + "Failed to enable %d MSI-X, trying %d instead\n", + vectors, vector_threshold); vectors = vector_threshold; - printk(KERN_ERR "Failed to enable %d MSI-X for %s, try" - " %d instead\n", vectors, adapter->netdev->name, - vector_threshold); } } - printk(KERN_INFO "Number of MSI-X interrupts which can be allocatedi" - " are lower than min threshold required.\n"); + netdev_info(adapter->netdev, + "Number of MSI-X interrupts which can be allocated are lower than min threshold required.\n"); return err; } @@ -2787,8 +2787,9 @@ vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter) return; /* If we cannot allocate MSIx vectors use only one rx queue */ - printk(KERN_INFO "Failed to enable MSI-X for %s, error %d." - "#rx queues : 1, try MSI\n", adapter->netdev->name, err); + netdev_info(adapter->netdev, + "Failed to enable MSI-X, error %d . Limiting #rx queues to 1, try MSI.\n", + err); adapter->intr.type = VMXNET3_IT_MSI; } -- GitLab From 349345a4ec631cd98767b58b065535dd2278697c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:45 +0200 Subject: [PATCH 1315/1846] wl12xx: don't start dev role on ibss vifs device role is used for scanning and sending packets before connection. however, since we don't need to send packets before ibss creation, there is no need to start the device on idle-off. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 418b2b82c185..93636ea84dae 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3746,10 +3746,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, ibss_joined = true; } else { if (test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, - &wlvif->flags)) { + &wlvif->flags)) wl1271_unjoin(wl, wlvif); - wl12xx_start_dev(wl, wlvif); - } } } @@ -3767,7 +3765,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, do_join = true; } - if (changed & BSS_CHANGED_IDLE) { + if (changed & BSS_CHANGED_IDLE && !is_ibss) { ret = wl1271_sta_handle_idle(wl, wlvif, bss_conf->idle); if (ret < 0) wl1271_warning("idle mode change failed %d", ret); -- GitLab From 8a6a84a471f7de1845174d1dd66b35074d9d9398 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:46 +0200 Subject: [PATCH 1316/1846] wl12xx: consider bss_conf->idle instead of hw->conf.flags On disassociation, check only whether the current vif is idle, instead of checking whether the device is idle. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 93636ea84dae..b771106c0a1e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3901,7 +3901,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, /* restore the bssid filter and go to dummy bssid */ if (was_assoc) { - u32 conf_flags = wl->hw->conf.flags; /* * we might have to disable roc, if there was * no IF_OPER_UP notification. @@ -3924,7 +3923,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, } wl1271_unjoin(wl, wlvif); - if (!(conf_flags & IEEE80211_CONF_IDLE)) + if (!bss_conf->idle) wl12xx_start_dev(wl, wlvif); } } -- GitLab From 2d6cf2b51fa3492c479c6d1f86496e120b51e1d8 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:47 +0200 Subject: [PATCH 1317/1846] wl12xx: implement sta_state callback Implement sta_state callback instead of the sta_add/remove callbacks. Update the fw regarding peer state and ht caps only after the station was authorized. Otherwise, the fw might try establishing BA session before the sta is authorized. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 137 +++++++++++++++++------------ 1 file changed, 82 insertions(+), 55 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b771106c0a1e..8569ac3760df 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4233,100 +4233,128 @@ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) wl->active_sta_count--; } -static int wl1271_op_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +static int wl12xx_sta_add(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + 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; u8 hlid; - mutex_lock(&wl->mutex); - - if (unlikely(wl->state == WL1271_STATE_OFF)) - goto out; - - if (wlvif->bss_type != BSS_TYPE_AP_BSS) - goto out; - wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); ret = wl1271_allocate_sta(wl, wlvif, sta); if (ret < 0) - goto out; + return ret; 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; - ret = wl12xx_cmd_add_peer(wl, wlvif, sta, hlid); if (ret < 0) - goto out_sleep; + wl1271_free_sta(wl, wlvif, hlid); - ret = wl12xx_cmd_set_peer_state(wl, hlid); - if (ret < 0) - goto out_sleep; + return ret; +} - ret = wl1271_acx_set_ht_capabilities(wl, &sta->ht_cap, true, hlid); - if (ret < 0) - goto out_sleep; +static int wl12xx_sta_remove(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta) +{ + struct wl1271_station *wl_sta; + int ret = 0, id; -out_sleep: - wl1271_ps_elp_sleep(wl); + wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); + + wl_sta = (struct wl1271_station *)sta->drv_priv; + id = wl_sta->hlid; + if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map))) + return -EINVAL; -out_free_sta: + ret = wl12xx_cmd_remove_peer(wl, wl_sta->hlid); if (ret < 0) - wl1271_free_sta(wl, wlvif, hlid); + return ret; -out: - mutex_unlock(&wl->mutex); + wl1271_free_sta(wl, wlvif, wl_sta->hlid); return ret; } -static int wl1271_op_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +static int wl12xx_update_sta_state(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta, + enum ieee80211_sta_state old_state, + enum ieee80211_sta_state new_state) { - struct wl1271 *wl = hw->priv; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_station *wl_sta; - int ret = 0, id; + u8 hlid; + bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS; + bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; + int ret; - mutex_lock(&wl->mutex); + wl_sta = (struct wl1271_station *)sta->drv_priv; + hlid = wl_sta->hlid; - if (unlikely(wl->state == WL1271_STATE_OFF)) - goto out; + /* Add station (AP mode) */ + if (is_ap && + old_state == IEEE80211_STA_NOTEXIST && + new_state == IEEE80211_STA_NONE) + return wl12xx_sta_add(wl, wlvif, sta); + + /* Remove station (AP mode) */ + if (is_ap && + old_state == IEEE80211_STA_NONE && + new_state == IEEE80211_STA_NOTEXIST) { + /* must not fail */ + wl12xx_sta_remove(wl, wlvif, sta); + return 0; + } - if (wlvif->bss_type != BSS_TYPE_AP_BSS) - goto out; + /* Authorize station (AP mode) */ + if (is_ap && + new_state == IEEE80211_STA_AUTHORIZED) { + ret = wl12xx_cmd_set_peer_state(wl, hlid); + if (ret < 0) + return ret; - wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); + ret = wl1271_acx_set_ht_capabilities(wl, &sta->ht_cap, true, + hlid); + return ret; + } - wl_sta = (struct wl1271_station *)sta->drv_priv; - id = wl_sta->hlid; - if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map))) + return 0; +} + +static int wl12xx_op_sta_state(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + enum ieee80211_sta_state old_state, + enum ieee80211_sta_state new_state) +{ + struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret; + + wl1271_debug(DEBUG_MAC80211, "mac80211 sta %d state=%d->%d", + sta->aid, old_state, new_state); + + mutex_lock(&wl->mutex); + + if (unlikely(wl->state == WL1271_STATE_OFF)) { + ret = -EBUSY; goto out; + } ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; - ret = wl12xx_cmd_remove_peer(wl, wl_sta->hlid); - if (ret < 0) - goto out_sleep; + ret = wl12xx_update_sta_state(wl, wlvif, sta, old_state, new_state); - wl1271_free_sta(wl, wlvif, wl_sta->hlid); - -out_sleep: wl1271_ps_elp_sleep(wl); - out: mutex_unlock(&wl->mutex); + if (new_state < old_state) + return 0; return ret; } @@ -4795,8 +4823,7 @@ static const struct ieee80211_ops wl1271_ops = { .conf_tx = wl1271_op_conf_tx, .get_tsf = wl1271_op_get_tsf, .get_survey = wl1271_op_get_survey, - .sta_add = wl1271_op_sta_add, - .sta_remove = wl1271_op_sta_remove, + .sta_state = wl12xx_op_sta_state, .ampdu_action = wl1271_op_ampdu_action, .tx_frames_pending = wl1271_tx_frames_pending, .set_bitrate_mask = wl12xx_set_bitrate_mask, -- GitLab From 9fd6f21ba295810e36299981411f62719364d9e9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:48 +0200 Subject: [PATCH 1318/1846] wl12xx: set authorized AP on sta_state notification wl12xx currently looks for AP authorization by registering a netdev notifier and waiting for the IF_OPER_UP notification, which is quite cumbersome. Use the newly introduced sta_state callback (waiting for assoc -> auth notification) instead, in order to simplify it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 117 +++++---------------------- drivers/net/wireless/wl12xx/wl12xx.h | 3 +- 2 files changed, 23 insertions(+), 97 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8569ac3760df..a330b0c0ae61 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -392,15 +392,15 @@ 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 DEFINE_MUTEX(wl_list_mutex); -static LIST_HEAD(wl_list); - -static int wl1271_check_operstate(struct wl1271 *wl, struct wl12xx_vif *wlvif, - unsigned char operstate) +static int wl12xx_set_authorized(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - if (operstate != IF_OPER_UP) + if (WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS)) + return -EINVAL; + + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) return 0; if (test_and_set_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags)) @@ -415,76 +415,6 @@ static int wl1271_check_operstate(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_info("Association completed."); return 0; } -static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, - void *arg) -{ - struct net_device *dev = arg; - struct wireless_dev *wdev; - struct wiphy *wiphy; - 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. */ - if (what != NETDEV_CHANGE) - return NOTIFY_DONE; - - wdev = dev->ieee80211_ptr; - if (wdev == NULL) - return NOTIFY_DONE; - - wiphy = wdev->wiphy; - if (wiphy == NULL) - return NOTIFY_DONE; - - hw = wiphy_priv(wiphy); - if (hw == NULL) - return NOTIFY_DONE; - - wl_temp = hw->priv; - mutex_lock(&wl_list_mutex); - list_for_each_entry(wl, &wl_list, list) { - if (wl == wl_temp) - break; - } - mutex_unlock(&wl_list_mutex); - if (wl != wl_temp) - return NOTIFY_DONE; - - mutex_lock(&wl->mutex); - - if (wl->state == WL1271_STATE_OFF) - goto out; - - if (dev->operstate != IF_OPER_UP) - goto out; - /* - * The correct behavior should be just getting the appropriate wlvif - * from the given dev, but currently we don't have a mac80211 - * interface for it. - */ - wl12xx_for_each_wlvif_sta(wl, wlvif) { - struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); - - if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) - continue; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - - wl1271_check_operstate(wl, wlvif, - ieee80211_get_operstate(vif)); - - wl1271_ps_elp_sleep(wl); - } -out: - mutex_unlock(&wl->mutex); - - return NOTIFY_OK; -} static int wl1271_reg_notify(struct wiphy *wiphy, struct regulatory_request *request) @@ -1626,10 +1556,6 @@ static struct sk_buff *wl12xx_alloc_dummy_packet(struct wl1271 *wl) } -static struct notifier_block wl1271_dev_notifier = { - .notifier_call = wl1271_dev_notify, -}; - #ifdef CONFIG_PM static int wl1271_configure_suspend_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -1856,10 +1782,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl->state = WL1271_STATE_OFF; mutex_unlock(&wl->mutex); - mutex_lock(&wl_list_mutex); - list_del(&wl->list); - mutex_unlock(&wl_list_mutex); - wl1271_flush_deferred_work(wl); cancel_delayed_work_sync(&wl->scan_complete_work); cancel_work_sync(&wl->netstack_work); @@ -2270,11 +2192,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, out_unlock: mutex_unlock(&wl->mutex); - mutex_lock(&wl_list_mutex); - if (!ret) - list_add(&wl->list, &wl_list); - mutex_unlock(&wl_list_mutex); - return ret; } @@ -3967,8 +3884,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (ret < 0) goto out; - wl1271_check_operstate(wl, wlvif, - ieee80211_get_operstate(vif)); + if (test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags)) + wl12xx_set_authorized(wl, wlvif); } /* * stop device role if started (we might already be in @@ -4321,6 +4238,20 @@ static int wl12xx_update_sta_state(struct wl1271 *wl, return ret; } + /* Authorize station */ + if (is_sta && + new_state == IEEE80211_STA_AUTHORIZED) { + set_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags); + return wl12xx_set_authorized(wl, wlvif); + } + + if (is_sta && + old_state == IEEE80211_STA_AUTHORIZED && + new_state == IEEE80211_STA_ASSOC) { + clear_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags); + return 0; + } + return 0; } @@ -5144,8 +5075,6 @@ static int wl1271_register_hw(struct wl1271 *wl) wl1271_debugfs_init(wl); - register_netdevice_notifier(&wl1271_dev_notifier); - wl1271_notice("loaded"); out: @@ -5157,7 +5086,6 @@ static void wl1271_unregister_hw(struct wl1271 *wl) if (wl->plt) wl1271_plt_stop(wl); - unregister_netdevice_notifier(&wl1271_dev_notifier); ieee80211_unregister_hw(wl->hw); wl->mac80211_registered = false; @@ -5278,7 +5206,6 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) wl = hw->priv; memset(wl, 0, sizeof(*wl)); - INIT_LIST_HEAD(&wl->list); INIT_LIST_HEAD(&wl->wlvif_list); wl->hw = hw; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 90352415e2aa..b26b1be9a98b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -265,6 +265,7 @@ enum wl12xx_flags { enum wl12xx_vif_flags { WLVIF_FLAG_INITIALIZED, WLVIF_FLAG_STA_ASSOCIATED, + WLVIF_FLAG_STA_AUTHORIZED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, WLVIF_FLAG_IN_PS, @@ -452,8 +453,6 @@ struct wl1271 { bool enable_11a; - struct list_head list; - /* Most recently reported noise in dBm */ s8 noise; -- GitLab From b32b2b0f8ea82cb51d70b88815c25e0f1c0cf7a5 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:49 +0200 Subject: [PATCH 1319/1846] wl12xx: increment session_counter for device role as well The sesssion_counter has to be incremented each time the dev is started (similar to sta role). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index ae1f3d7f34d2..1ef212f6440f 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -531,7 +531,7 @@ static int wl12xx_cmd_role_start_dev(struct wl1271 *wl, goto out_free; } cmd->device.hlid = wlvif->dev_hlid; - cmd->device.session = wlvif->session_counter; + cmd->device.session = wl12xx_get_new_session_id(wl, wlvif); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d", cmd->role_id, cmd->device.hlid, cmd->device.session); -- GitLab From 249e9698899643a799951a6e772facae346f0941 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:50 +0200 Subject: [PATCH 1320/1846] wl12xx: set correct vif type in change_interface callback In some cases, the wrong vif type was set in the change_interface callback (P2P_CLIENT/P2P_GO instead of STA/AP) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a330b0c0ae61..65f91d7bad31 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2336,7 +2336,7 @@ static int wl12xx_op_change_interface(struct ieee80211_hw *hw, set_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags); wl1271_op_remove_interface(hw, vif); - vif->type = ieee80211_iftype_p2p(new_type, p2p); + vif->type = new_type; vif->p2p = p2p; ret = wl1271_op_add_interface(hw, vif); -- GitLab From 121af04995d29e3287b849a768789c668d39dce3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:51 +0200 Subject: [PATCH 1321/1846] wl12xx: don't handle change_channel while associated Currently, CHANGE_CHANNEL indication while associated is considered as roaming attempt. However, with the new auth/assoc redesign, we no longer have to handle this case, so remove it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 41 ++++++++++-------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 65f91d7bad31..85bbe7f4f517 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2515,35 +2515,22 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_warning("rate policy for channel " "failed %d", ret); - if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, - &wlvif->flags)) { - if (wl12xx_dev_role_started(wlvif)) { - /* roaming */ - ret = wl12xx_croc(wl, - wlvif->dev_role_id); - if (ret < 0) - return ret; - } - ret = wl1271_join(wl, wlvif, false); + /* + * change the ROC channel. do it only if we are + * not idle. otherwise, CROC will be called + * anyway. + */ + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, + &wlvif->flags) && + wl12xx_dev_role_started(wlvif) && + !(conf->flags & IEEE80211_CONF_IDLE)) { + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) - wl1271_warning("cmd join on channel " - "failed %d", ret); - } else { - /* - * change the ROC channel. do it only if we are - * not idle. otherwise, CROC will be called - * anyway. - */ - if (wl12xx_dev_role_started(wlvif) && - !(conf->flags & IEEE80211_CONF_IDLE)) { - ret = wl12xx_stop_dev(wl, wlvif); - if (ret < 0) - return ret; + return ret; - ret = wl12xx_start_dev(wl, wlvif); - if (ret < 0) - return ret; - } + ret = wl12xx_start_dev(wl, wlvif); + if (ret < 0) + return ret; } } } -- GitLab From 97fd311a2615d8f35e796b11a14b6cf3d335d423 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:52 +0200 Subject: [PATCH 1322/1846] wl12xx: don't allow scanning while device is in ROC return EBUSY on scan when there is any role in ROC (not necessarily the one we are going to use) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 85bbe7f4f517..1d5f2d5614fb 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3057,8 +3057,6 @@ 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; @@ -3086,8 +3084,8 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, if (ret < 0) goto out; - if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && - test_bit(wlvif->role_id, wl->roc_map)) { + /* fail if there is any role in ROC */ + if (find_first_bit(wl->roc_map, WL12XX_MAX_ROLES) < WL12XX_MAX_ROLES) { /* don't allow scanning right now */ ret = -EBUSY; goto out_sleep; -- GitLab From 6667776d3cf32dd3809a18917c2b7adb8ef12aa2 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:53 +0200 Subject: [PATCH 1323/1846] wl12xx: configure the correct beacon_interval We didn't update the beacon interval on association (or on a change notification when working as sta), so the default interval (100ms) was always used. Update the beacon interval according to the bss_conf before starting the sta role (on association). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 1d5f2d5614fb..89bf9eadc840 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3723,6 +3723,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, u32 rates; int ieoffset; wlvif->aid = bss_conf->aid; + wlvif->beacon_int = bss_conf->beacon_int; set_assoc = true; /* -- GitLab From e9ba7152c1f5babd6ad9ad45619e0a10b4c08554 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:54 +0200 Subject: [PATCH 1324/1846] wl12xx: avoid bug_on_recovery during fw switch Add a flag to indicate we initiated a recovery work on purpose, in order to avoid triggering BUG() (when the bug_on_recovery module param was set). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 5 ++++- drivers/net/wireless/wl12xx/wl12xx.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 89bf9eadc840..3c966f2e00d0 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1154,7 +1154,8 @@ static void wl1271_recovery_work(struct work_struct *work) wl1271_info("Hardware recovery in progress. FW ver: %s pc: 0x%x", wl->chip.fw_ver_str, wl1271_read32(wl, SCR_PAD4)); - BUG_ON(bug_on_recovery); + BUG_ON(bug_on_recovery && + !test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags)); /* * Advance security sequence number to overcome potential progress @@ -2133,6 +2134,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (wl12xx_need_fw_change(wl, vif_count, true)) { wl12xx_force_active_psm(wl); + set_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags); mutex_unlock(&wl->mutex); wl1271_recovery_work(&wl->recovery_work); return 0; @@ -2317,6 +2319,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, WARN_ON(iter != wlvif); if (wl12xx_need_fw_change(wl, vif_count, false)) { wl12xx_force_active_psm(wl); + set_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags); wl12xx_queue_recovery_work(wl); cancel_recovery = false; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b26b1be9a98b..6e13a3073e9f 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -260,6 +260,7 @@ enum wl12xx_flags { WL1271_FLAG_SOFT_GEMINI, WL1271_FLAG_RECOVERY_IN_PROGRESS, WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, + WL1271_FLAG_INTENDED_FW_RECOVERY, }; enum wl12xx_vif_flags { -- GitLab From 8ccd16e6cb17a1e961617cc67798bbb222e4cd13 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 4 Mar 2012 10:55:55 +0200 Subject: [PATCH 1325/1846] wl12xx: print the tx packet len Add the packet length to the tx debug print. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3c966f2e00d0..95a76a5f9eeb 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1459,7 +1459,8 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) goto out; } - wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q); + wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d len %d", + hlid, q, skb->len); skb_queue_tail(&wl->links[hlid].tx_queue[q], skb); wl->tx_queue_count[q]++; -- GitLab From daa16bc52ad8e9513506fca29a038a1460e63638 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Fri, 2 Mar 2012 18:02:08 +0530 Subject: [PATCH 1326/1846] ath6kl: Restrict memcpy to bounce buffer only for write request No need to copy received local buffer content to bounce buffer (DMA buffer) while performing sync READ operation from the chip. It's applicable for only WRITE operation. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 346f5dd3a954..e2f42a133952 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -405,7 +405,10 @@ static int ath6kl_sdio_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf, return -ENOMEM; mutex_lock(&ar_sdio->dma_buffer_mutex); tbuf = ar_sdio->dma_buffer; - memcpy(tbuf, buf, len); + + if (request & HIF_WRITE) + memcpy(tbuf, buf, len); + bounced = true; } else tbuf = buf; -- GitLab From a0f6d6caef4033aa9c3e2ea2ceae256c4347a419 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Fri, 24 Feb 2012 21:36:05 -0800 Subject: [PATCH 1327/1846] mwifiex: handle auto authentication mode correctly When authentication type is configured to NL80211_AUTHTYPE_AUTOMATIC, driver tries to connect using open mode. The association is failed if AP is configured in shared mode. This patch adds code to try association using shared mode as well if open mode association fails. Now since we returned exact error code in association response handler (instead of -1), corresponding changes are done in mwifiex_process_cmdresp(). Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 10 ++++++---- drivers/net/wireless/mwifiex/cmdevt.c | 8 +++----- drivers/net/wireless/mwifiex/join.c | 2 +- drivers/net/wireless/mwifiex/main.h | 1 + drivers/net/wireless/mwifiex/sta_ioctl.c | 11 +++++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index a460fb0cc503..6a81101bab44 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -873,6 +873,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, priv->sec_info.wpa2_enabled = false; priv->wep_key_curr_index = 0; priv->sec_info.encryption_mode = 0; + priv->sec_info.is_authtype_auto = 0; ret = mwifiex_set_encode(priv, NULL, 0, 0, 1); if (mode == NL80211_IFTYPE_ADHOC) { @@ -894,11 +895,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, } /* Now handle infra mode. "sme" is valid for infra mode only */ - if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC - || sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) + if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) { auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; - else if (sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) - auth_type = NL80211_AUTHTYPE_SHARED_KEY; + priv->sec_info.is_authtype_auto = 1; + } else { + auth_type = sme->auth_type; + } if (sme->crypto.n_ciphers_pairwise) { priv->sec_info.encryption_mode = diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c index 6623db69e157..c82eb7ff2fa2 100644 --- a/drivers/net/wireless/mwifiex/cmdevt.c +++ b/drivers/net/wireless/mwifiex/cmdevt.c @@ -771,7 +771,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) /* Check init command response */ if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) { - if (ret == -1) { + if (ret) { dev_err(adapter->dev, "%s: cmd %#x failed during " "initialization\n", __func__, cmdresp_no); mwifiex_init_fw_complete(adapter); @@ -781,10 +781,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) } if (adapter->curr_cmd) { - if (adapter->curr_cmd->wait_q_enabled && (!ret)) - adapter->cmd_wait_q.status = 0; - else if (adapter->curr_cmd->wait_q_enabled && (ret == -1)) - adapter->cmd_wait_q.status = -1; + if (adapter->curr_cmd->wait_q_enabled) + adapter->cmd_wait_q.status = ret; /* Clean up and put current command back to cmd_free_q */ mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index ee439fc2f4f3..5c95e4839004 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -585,7 +585,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, le16_to_cpu(assoc_rsp->cap_info_bitmap), le16_to_cpu(assoc_rsp->a_id)); - ret = -1; + ret = le16_to_cpu(assoc_rsp->status_code); goto done; } diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 4c8621706278..dddb5563398a 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -219,6 +219,7 @@ struct mwifiex_802_11_security { u8 wapi_key_on; u8 wep_enabled; u32 authentication_mode; + u8 is_authtype_auto; u32 encryption_mode; }; diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 866026ecca44..e10161f5894c 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -249,6 +249,17 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, * application retrieval */ priv->assoc_rsp_size = 0; ret = mwifiex_associate(priv, bss_desc); + + /* If auth type is auto and association fails using open mode, + * try to connect using shared mode */ + if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG && + priv->sec_info.is_authtype_auto && + priv->sec_info.wep_enabled) { + priv->sec_info.authentication_mode = + NL80211_AUTHTYPE_SHARED_KEY; + ret = mwifiex_associate(priv, bss_desc); + } + if (bss) cfg80211_put_bss(bss); } else { -- GitLab From d6157bf78015e53371e806e0f8fd44ef6a1bfc5d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 27 Feb 2012 19:58:39 +0100 Subject: [PATCH 1328/1846] Revert "ath9k_hw: Fix false tx hung detection in AR9003 chips" The approach of this change is flawed, as it triggers tx status processing from more callsites, yet the chips only have one global tx status queue. Subsequent patches will properly fix the issue that this one tried to address. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 8 ++------ drivers/net/wireless/ath/ath9k/beacon.c | 6 ------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 8d1bca03bc0e..01d5c1a4d746 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -326,7 +326,6 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_status *ts) { - struct ar9003_txc *txc = (struct ar9003_txc *) ds; struct ar9003_txs *ads; u32 status; @@ -336,11 +335,7 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds, if ((status & AR_TxDone) == 0) return -EINPROGRESS; - ts->qid = MS(ads->ds_info, AR_TxQcuNum); - if (!txc || (MS(txc->info, AR_TxQcuNum) == ts->qid)) - ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size; - else - return -ENOENT; + ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size; if ((MS(ads->ds_info, AR_DescId) != ATHEROS_VENDOR_ID) || (MS(ads->ds_info, AR_TxRxDesc) != 1)) { @@ -354,6 +349,7 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds, ts->ts_seqnum = MS(status, AR_SeqNum); ts->tid = MS(status, AR_TxTid); + ts->qid = MS(ads->ds_info, AR_TxQcuNum); ts->desc_id = MS(ads->status1, AR_TxDescId); ts->ts_tstamp = ads->status4; ts->ts_status = 0; diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index b8967e482e6e..6d1e46577db0 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c @@ -355,7 +355,6 @@ void ath_beacon_tasklet(unsigned long data) struct ath_common *common = ath9k_hw_common(ah); struct ath_buf *bf = NULL; struct ieee80211_vif *vif; - struct ath_tx_status ts; bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); int slot; u32 bfaddr, bc = 0; @@ -462,11 +461,6 @@ void ath_beacon_tasklet(unsigned long data) ath9k_hw_txstart(ah, sc->beacon.beaconq); sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */ - if (edma) { - spin_lock_bh(&sc->sc_pcu_lock); - ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts); - spin_unlock_bh(&sc->sc_pcu_lock); - } } } -- GitLab From 4286df60edfe19d3407fa112bf4bdfeeadda897c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 27 Feb 2012 19:58:40 +0100 Subject: [PATCH 1329/1846] ath9k: do not call ath9k_hw_txprocdesc on AR9003 outside of the tx tasklet Since AR9003 uses a global tx status queue, processing tx status outside of the regular tx tasklet is dangerous and messes up hardware/software synchronization of tx status events. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 02e95c8e7465..cc2535c38bed 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -2300,6 +2300,7 @@ static int ath9k_tx_last_beacon(struct ieee80211_hw *hw) struct ath_vif *avp; struct ath_buf *bf; struct ath_tx_status ts; + bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); int status; vif = sc->beacon.bslot[0]; @@ -2310,7 +2311,7 @@ static int ath9k_tx_last_beacon(struct ieee80211_hw *hw) if (!avp->is_bslot_active) return 0; - if (!sc->beacon.tx_processed) { + if (!sc->beacon.tx_processed && !edma) { tasklet_disable(&sc->bcon_tasklet); bf = avp->av_bcbuf; -- GitLab From 627e67a656bbb1d616c1ca2d056138a164111a52 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 27 Feb 2012 19:58:41 +0100 Subject: [PATCH 1330/1846] ath9k_hw: enable interrupts for beacon tx completion events Not doing so could cause the tx status queue to overflow during longer periods of time without non-beacon tx. These events are also required for proper drv_tx_last_beacon handling. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index e196aba77acf..5f4ae6c9a93c 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -745,7 +745,11 @@ int ath9k_hw_beaconq_setup(struct ath_hw *ah) qi.tqi_aifs = 1; qi.tqi_cwmin = 0; qi.tqi_cwmax = 0; - /* NB: don't enable any interrupts */ + + if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) + qi.tqi_qflags = TXQ_FLAG_TXOKINT_ENABLE | + TXQ_FLAG_TXERRINT_ENABLE; + return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi); } EXPORT_SYMBOL(ath9k_hw_beaconq_setup); -- GitLab From 4e0ad2591adde7bec878a4b37a073427aec3e19c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 27 Feb 2012 19:58:42 +0100 Subject: [PATCH 1331/1846] ath9k: fix drv_tx_last_beacon on AR9003 by processing beacon tx status Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/beacon.c | 2 +- drivers/net/wireless/ath/ath9k/xmit.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 6d1e46577db0..43882f9e25c4 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c @@ -91,7 +91,7 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp, info.txpower = MAX_RATE_POWER; info.keyix = ATH9K_TXKEYIX_INVALID; info.keytype = ATH9K_KEY_TYPE_CLEAR; - info.flags = ATH9K_TXDESC_NOACK; + info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_INTREQ; info.buf_addr[0] = bf->bf_buf_addr; info.buf_len[0] = roundup(skb->len, 4); diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 5dd27d2712fc..9f785015a7dc 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -2296,9 +2296,12 @@ void ath_tx_edma_tasklet(struct ath_softc *sc) break; } - /* Skip beacon completions */ - if (ts.qid == sc->beacon.beaconq) + /* Process beacon completions separately */ + if (ts.qid == sc->beacon.beaconq) { + sc->beacon.tx_processed = true; + sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK); continue; + } txq = &sc->tx.txq[ts.qid]; -- GitLab From edd8d90b624e97105d26615d1655da22a3605fff Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:04 +0100 Subject: [PATCH 1332/1846] ssb: sprom fix some sizes / signedness Some parts of the sprom struct are bigger than needed. The leddc and maxpwr values are just 8 bit long and not 16. rxpo2g and rxpo5g are signed I got these information for the open source part of the Broadcom SDK covering sprom version 1 to 9. rxpo2g contained a negative number on my bcm5354 based device, this cased an error and Broadcom SDK says this is signed. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- include/linux/ssb/ssb.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h index bbc2612cb64a..f1696213e3b5 100644 --- a/include/linux/ssb/ssb.h +++ b/include/linux/ssb/ssb.h @@ -33,8 +33,8 @@ struct ssb_sprom { u8 et1mdcport; /* MDIO for enet1 */ u16 board_rev; /* Board revision number from SPROM. */ u8 country_code; /* Country Code */ - u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */ - u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */ + u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */ + u8 leddc_off_time; /* LED Powersave Duty Cycle Off Count */ u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */ u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */ u16 pa0b0; @@ -53,10 +53,10 @@ struct ssb_sprom { u8 gpio1; /* GPIO pin 1 */ u8 gpio2; /* GPIO pin 2 */ u8 gpio3; /* GPIO pin 3 */ - u16 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */ - u16 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */ - u16 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */ - u16 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */ + u8 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */ + u8 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */ + u8 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */ + u8 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */ u8 itssi_a; /* Idle TSSI Target for A-PHY */ u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */ u8 tri2g; /* 2.4GHz TX isolation */ @@ -67,8 +67,8 @@ struct ssb_sprom { u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */ u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */ u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */ - u8 rxpo2g; /* 2GHz RX power offset */ - u8 rxpo5g; /* 5GHz RX power offset */ + s8 rxpo2g; /* 2GHz RX power offset */ + s8 rxpo5g; /* 5GHz RX power offset */ u8 rssisav2g; /* 2GHz RSSI params */ u8 rssismc2g; u8 rssismf2g; -- GitLab From f8f8a660ba501ad14617ccd0d91a1ed8ce54d6d0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:05 +0100 Subject: [PATCH 1333/1846] ssb: remove 5GHz antenna gain from sprom There is no 2.4 GHz or 5GHz antenna gain stored in sprom. The sprom just stores the gain values for antenna 1 and 2 or 1 to 4 for more recent sprom versions. On old devices antenna 2 was used for 5 GHz wifi. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/net/wireless/b43legacy/phy.c | 2 +- drivers/ssb/pci.c | 41 ++++++++++------------------ drivers/ssb/pcmcia.c | 12 +++----- drivers/ssb/sdio.c | 12 +++----- include/linux/ssb/ssb.h | 7 +---- 5 files changed, 24 insertions(+), 50 deletions(-) diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c index 96faaef3661b..950334197f40 100644 --- a/drivers/net/wireless/b43legacy/phy.c +++ b/drivers/net/wireless/b43legacy/phy.c @@ -1860,7 +1860,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) * which accounts for the factor of 4 */ #define REG_MAX_PWR 20 max_pwr = min(REG_MAX_PWR * 4 - - dev->dev->bus->sprom.antenna_gain.ghz24.a0 + - dev->dev->bus->sprom.antenna_gain.a0 - 0x6, max_pwr); /* find the desired power in Q5.2 - power_level is in dBm diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c index befa89eac6f3..ed4124469a3a 100644 --- a/drivers/ssb/pci.c +++ b/drivers/ssb/pci.c @@ -331,7 +331,6 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) { int i; u16 v; - s8 gain; u16 loc[3]; if (out->revision == 3) /* rev 3 moved MAC */ @@ -390,20 +389,12 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0); /* Extract the antenna gain values. */ - gain = r123_extract_antgain(out->revision, in, - SSB_SPROM1_AGAIN_BG, - SSB_SPROM1_AGAIN_BG_SHIFT); - out->antenna_gain.ghz24.a0 = gain; - out->antenna_gain.ghz24.a1 = gain; - out->antenna_gain.ghz24.a2 = gain; - out->antenna_gain.ghz24.a3 = gain; - gain = r123_extract_antgain(out->revision, in, - SSB_SPROM1_AGAIN_A, - SSB_SPROM1_AGAIN_A_SHIFT); - out->antenna_gain.ghz5.a0 = gain; - out->antenna_gain.ghz5.a1 = gain; - out->antenna_gain.ghz5.a2 = gain; - out->antenna_gain.ghz5.a3 = gain; + out->antenna_gain.a0 = r123_extract_antgain(out->revision, in, + SSB_SPROM1_AGAIN_BG, + SSB_SPROM1_AGAIN_BG_SHIFT); + out->antenna_gain.a1 = r123_extract_antgain(out->revision, in, + SSB_SPROM1_AGAIN_A, + SSB_SPROM1_AGAIN_A_SHIFT); } /* Revs 4 5 and 8 have partially shared layout */ @@ -504,16 +495,14 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in) } /* Extract the antenna gain values. */ - SPEX(antenna_gain.ghz24.a0, SSB_SPROM4_AGAIN01, + SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01, SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT); - SPEX(antenna_gain.ghz24.a1, SSB_SPROM4_AGAIN01, + SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01, SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT); - SPEX(antenna_gain.ghz24.a2, SSB_SPROM4_AGAIN23, + SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23, SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT); - SPEX(antenna_gain.ghz24.a3, SSB_SPROM4_AGAIN23, + SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23, SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT); - memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24, - sizeof(out->antenna_gain.ghz5)); sprom_extract_r458(out, in); @@ -602,16 +591,14 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0); /* Extract the antenna gain values. */ - SPEX(antenna_gain.ghz24.a0, SSB_SPROM8_AGAIN01, + SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01, SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT); - SPEX(antenna_gain.ghz24.a1, SSB_SPROM8_AGAIN01, + SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01, SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT); - SPEX(antenna_gain.ghz24.a2, SSB_SPROM8_AGAIN23, + SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23, SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT); - SPEX(antenna_gain.ghz24.a3, SSB_SPROM8_AGAIN23, + SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23, SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT); - memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24, - sizeof(out->antenna_gain.ghz5)); /* Extract cores power info info */ for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) { diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c index c821c6b2a6a0..fbafed5b729b 100644 --- a/drivers/ssb/pcmcia.c +++ b/drivers/ssb/pcmcia.c @@ -676,14 +676,10 @@ static int ssb_pcmcia_do_get_invariants(struct pcmcia_device *p_dev, case SSB_PCMCIA_CIS_ANTGAIN: GOTO_ERROR_ON(tuple->TupleDataLen != 2, "antg tpl size"); - sprom->antenna_gain.ghz24.a0 = tuple->TupleData[1]; - sprom->antenna_gain.ghz24.a1 = tuple->TupleData[1]; - sprom->antenna_gain.ghz24.a2 = tuple->TupleData[1]; - sprom->antenna_gain.ghz24.a3 = tuple->TupleData[1]; - sprom->antenna_gain.ghz5.a0 = tuple->TupleData[1]; - sprom->antenna_gain.ghz5.a1 = tuple->TupleData[1]; - sprom->antenna_gain.ghz5.a2 = tuple->TupleData[1]; - sprom->antenna_gain.ghz5.a3 = tuple->TupleData[1]; + sprom->antenna_gain.a0 = tuple->TupleData[1]; + sprom->antenna_gain.a1 = tuple->TupleData[1]; + sprom->antenna_gain.a2 = tuple->TupleData[1]; + sprom->antenna_gain.a3 = tuple->TupleData[1]; break; case SSB_PCMCIA_CIS_BFLAGS: GOTO_ERROR_ON((tuple->TupleDataLen != 3) && diff --git a/drivers/ssb/sdio.c b/drivers/ssb/sdio.c index 63fd709038ca..b2d36f7736c5 100644 --- a/drivers/ssb/sdio.c +++ b/drivers/ssb/sdio.c @@ -551,14 +551,10 @@ int ssb_sdio_get_invariants(struct ssb_bus *bus, case SSB_SDIO_CIS_ANTGAIN: GOTO_ERROR_ON(tuple->size != 2, "antg tpl size"); - sprom->antenna_gain.ghz24.a0 = tuple->data[1]; - sprom->antenna_gain.ghz24.a1 = tuple->data[1]; - sprom->antenna_gain.ghz24.a2 = tuple->data[1]; - sprom->antenna_gain.ghz24.a3 = tuple->data[1]; - sprom->antenna_gain.ghz5.a0 = tuple->data[1]; - sprom->antenna_gain.ghz5.a1 = tuple->data[1]; - sprom->antenna_gain.ghz5.a2 = tuple->data[1]; - sprom->antenna_gain.ghz5.a3 = tuple->data[1]; + sprom->antenna_gain.a0 = tuple->data[1]; + sprom->antenna_gain.a1 = tuple->data[1]; + sprom->antenna_gain.a2 = tuple->data[1]; + sprom->antenna_gain.a3 = tuple->data[1]; break; case SSB_SDIO_CIS_BFLAGS: GOTO_ERROR_ON((tuple->size != 3) && diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h index f1696213e3b5..1de56757e949 100644 --- a/include/linux/ssb/ssb.h +++ b/include/linux/ssb/ssb.h @@ -94,12 +94,7 @@ struct ssb_sprom { * on each band. Values in dBm/4 (Q5.2). Negative gain means the * loss in the connectors is bigger than the gain. */ struct { - struct { - s8 a0, a1, a2, a3; - } ghz24; /* 2.4GHz band */ - struct { - s8 a0, a1, a2, a3; - } ghz5; /* 5GHz band */ + s8 a0, a1, a2, a3; } antenna_gain; struct { -- GitLab From 3b64e6f9050ff87a746c8e07dc04d97c7f26c5e2 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:06 +0100 Subject: [PATCH 1334/1846] ssb: fix per path sprom vars On sprom version 4 and 5 there are 4 values for pa_2g, pa_5gl, pa_5g and pa_5gh, for sprom version 8 and 9 there are only 3. Make the per path sprom store also work for older sprom versions. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- include/linux/ssb/ssb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h index 1de56757e949..49284192521b 100644 --- a/include/linux/ssb/ssb.h +++ b/include/linux/ssb/ssb.h @@ -19,7 +19,7 @@ struct ssb_driver; struct ssb_sprom_core_pwr_info { u8 itssi_2g, itssi_5g; u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh; - u16 pa_2g[3], pa_5gl[3], pa_5g[3], pa_5gh[3]; + u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4]; }; struct ssb_sprom { -- GitLab From 03a5642b6a578d8de355b77efff49bbc45b8be6d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:07 +0100 Subject: [PATCH 1335/1846] ssb: add alpha2 This member contains the country code encoded with two chars Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- include/linux/ssb/ssb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h index 49284192521b..d658de45ffb9 100644 --- a/include/linux/ssb/ssb.h +++ b/include/linux/ssb/ssb.h @@ -33,6 +33,7 @@ struct ssb_sprom { u8 et1mdcport; /* MDIO for enet1 */ u16 board_rev; /* Board revision number from SPROM. */ u8 country_code; /* Country Code */ + char alpha2[2]; /* Country Code as two chars like EU or US */ u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */ u8 leddc_off_time; /* LED Powersave Duty Cycle Off Count */ u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */ -- GitLab From 52aa63f5322aab23e07a52ff8ddd246d34799eb5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:08 +0100 Subject: [PATCH 1336/1846] ssb: add some missing sprom attributes This patch extends the sprom struct to contain all sprom attributes found in sprom version 1 to 9. This was done accordingly to the open source part of the Broadcom SDK. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- include/linux/ssb/ssb.h | 76 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h index d658de45ffb9..d27683180025 100644 --- a/include/linux/ssb/ssb.h +++ b/include/linux/ssb/ssb.h @@ -32,6 +32,8 @@ struct ssb_sprom { u8 et0mdcport; /* MDIO for enet0 */ u8 et1mdcport; /* MDIO for enet1 */ u16 board_rev; /* Board revision number from SPROM. */ + u16 board_num; /* Board number from SPROM. */ + u16 board_type; /* Board type from SPROM. */ u8 country_code; /* Country Code */ char alpha2[2]; /* Country Code as two chars like EU or US */ u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */ @@ -107,7 +109,79 @@ struct ssb_sprom { } ghz5; } fem; - /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */ + u16 mcs2gpo[8]; + u16 mcs5gpo[8]; + u16 mcs5glpo[8]; + u16 mcs5ghpo[8]; + u8 opo; + + u8 rxgainerr2ga[3]; + u8 rxgainerr5gla[3]; + u8 rxgainerr5gma[3]; + u8 rxgainerr5gha[3]; + u8 rxgainerr5gua[3]; + + u8 noiselvl2ga[3]; + u8 noiselvl5gla[3]; + u8 noiselvl5gma[3]; + u8 noiselvl5gha[3]; + u8 noiselvl5gua[3]; + + u8 regrev; + u8 txchain; + u8 rxchain; + u8 antswitch; + u16 cddpo; + u16 stbcpo; + u16 bw40po; + u16 bwduppo; + + u8 tempthresh; + u8 tempoffset; + u16 rawtempsense; + u8 measpower; + u8 tempsense_slope; + u8 tempcorrx; + u8 tempsense_option; + u8 freqoffset_corr; + u8 iqcal_swp_dis; + u8 hw_iqcal_en; + u8 elna2g; + u8 elna5g; + u8 phycal_tempdelta; + u8 temps_period; + u8 temps_hysteresis; + u8 measpower1; + u8 measpower2; + u8 pcieingress_war; + + /* power per rate from sromrev 9 */ + u16 cckbw202gpo; + u16 cckbw20ul2gpo; + u32 legofdmbw202gpo; + u32 legofdmbw20ul2gpo; + u32 legofdmbw205glpo; + u32 legofdmbw20ul5glpo; + u32 legofdmbw205gmpo; + u32 legofdmbw20ul5gmpo; + u32 legofdmbw205ghpo; + u32 legofdmbw20ul5ghpo; + u32 mcsbw202gpo; + u32 mcsbw20ul2gpo; + u32 mcsbw402gpo; + u32 mcsbw205glpo; + u32 mcsbw20ul5glpo; + u32 mcsbw405glpo; + u32 mcsbw205gmpo; + u32 mcsbw20ul5gmpo; + u32 mcsbw405gmpo; + u32 mcsbw205ghpo; + u32 mcsbw20ul5ghpo; + u32 mcsbw405ghpo; + u16 mcs32po; + u16 legofdm40duppo; + u8 sar2g; + u8 sar5g; }; /* Information about the PCB the circuitry is soldered on. */ -- GitLab From 1c9351cf2180924c91bb85e5ba607f24a3d875b1 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:09 +0100 Subject: [PATCH 1337/1846] bcma: export bcma_find_core This function is needed by the bcm47xx arch code to get the number of the ieee80211 core. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/main.c | 3 ++- include/linux/bcma/bcma.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index b8379b90d045..7e138ec21357 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -61,7 +61,7 @@ static struct bus_type bcma_bus_type = { .dev_attrs = bcma_device_attrs, }; -static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid) +struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid) { struct bcma_device *core; @@ -71,6 +71,7 @@ static struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid) } return NULL; } +EXPORT_SYMBOL_GPL(bcma_find_core); static void bcma_release_core_dev(struct device *dev) { diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h index b9f65fbee42f..46bbd088c4ad 100644 --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h @@ -284,6 +284,7 @@ static inline void bcma_maskset16(struct bcma_device *cc, bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set); } +extern struct bcma_device *bcma_find_core(struct bcma_bus *bus, u16 coreid); extern bool bcma_core_is_enabled(struct bcma_device *core); extern void bcma_core_disable(struct bcma_device *core, u32 flags); extern int bcma_core_enable(struct bcma_device *core, u32 flags); -- GitLab From a027237a56f7d519eee5749cfb720e568d0bb0b6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:10 +0100 Subject: [PATCH 1338/1846] bcma: add support for sprom not found on the device On SoCs the sprom is stored in the nvram in a special partition on the flash chip. The nvram contains the sprom for the main bus, but sometimes also for a pci devices using bcma. This patch makes it possible for the arch code to register a function to fetch the needed sprom from the nvram and provide it to the bcma code. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/bcma/sprom.c | 77 +++++++++++++++++++++++++++++++++++---- include/linux/bcma/bcma.h | 6 +++ 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index ca7752510d5b..916ae255ff64 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -2,6 +2,8 @@ * Broadcom specific AMBA * SPROM reading * + * Copyright 2011, 2012, Hauke Mehrtens + * * Licensed under the GNU/GPL. See COPYING for details. */ @@ -14,6 +16,45 @@ #include #include +static int(*get_fallback_sprom)(struct bcma_bus *dev, struct ssb_sprom *out); + +/** + * bcma_arch_register_fallback_sprom - Registers a method providing a + * fallback SPROM if no SPROM is found. + * + * @sprom_callback: The callback function. + * + * With this function the architecture implementation may register a + * callback handler which fills the SPROM data structure. The fallback is + * used for PCI based BCMA devices, where no valid SPROM can be found + * in the shadow registers and to provide the SPROM for SoCs where BCMA is + * to controll the system bus. + * + * This function is useful for weird architectures that have a half-assed + * BCMA device hardwired to their PCI bus. + * + * This function is available for architecture code, only. So it is not + * exported. + */ +int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus, + struct ssb_sprom *out)) +{ + if (get_fallback_sprom) + return -EEXIST; + get_fallback_sprom = sprom_callback; + + return 0; +} + +static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus, + struct ssb_sprom *out) +{ + if (!get_fallback_sprom) + return -ENOENT; + + return get_fallback_sprom(bus, out); +} + /************************************************** * R/W ops. **************************************************/ @@ -246,23 +287,43 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) SSB_SROM8_FEM_ANTSWLUT_SHIFT); } +static bool bcma_is_sprom_available(struct bcma_bus *bus) +{ + u32 sromctrl; + + if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM)) + return false; + + if (bus->drv_cc.core->id.rev >= 32) { + sromctrl = bcma_read32(bus->drv_cc.core, BCMA_CC_SROM_CONTROL); + return sromctrl & BCMA_CC_SROM_CONTROL_PRESENT; + } + return true; +} + int bcma_sprom_get(struct bcma_bus *bus) { u16 offset; u16 *sprom; - u32 sromctrl; int err = 0; if (!bus->drv_cc.core) return -EOPNOTSUPP; - if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM)) - return -ENOENT; - - if (bus->drv_cc.core->id.rev >= 32) { - sromctrl = bcma_read32(bus->drv_cc.core, BCMA_CC_SROM_CONTROL); - if (!(sromctrl & BCMA_CC_SROM_CONTROL_PRESENT)) - return -ENOENT; + if (!bcma_is_sprom_available(bus)) { + /* + * Maybe there is no SPROM on the device? + * Now we ask the arch code if there is some sprom + * available for this device in some other storage. + */ + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); + if (err) { + pr_warn("Using fallback SPROM failed (err %d)\n", err); + } else { + pr_debug("Using SPROM revision %d provided by" + " platform.\n", bus->sprom.revision); + return 0; + } } sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h index 46bbd088c4ad..5af9a075498f 100644 --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h @@ -176,6 +176,12 @@ int __bcma_driver_register(struct bcma_driver *drv, struct module *owner); extern void bcma_driver_unregister(struct bcma_driver *drv); +/* Set a fallback SPROM. + * See kdoc at the function definition for complete documentation. */ +extern int bcma_arch_register_fallback_sprom( + int (*sprom_callback)(struct bcma_bus *bus, + struct ssb_sprom *out)); + struct bcma_bus { /* The MMIO area. */ void __iomem *mmio; -- GitLab From 44d4b2ae94b19080d6d033a1f5cf2cc47443be3b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:11 +0100 Subject: [PATCH 1339/1846] MIPS: BCM47XX: return number of written bytes in nvram_getenv Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- arch/mips/bcm47xx/nvram.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c index a84e3bb7387f..d43ceff5be47 100644 --- a/arch/mips/bcm47xx/nvram.c +++ b/arch/mips/bcm47xx/nvram.c @@ -107,8 +107,7 @@ int nvram_getenv(char *name, char *val, size_t val_len) value = eq + 1; if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0) { - snprintf(val, val_len, "%s", value); - return 0; + return snprintf(val, val_len, "%s", value); } } return NVRAM_ERR_ENVNOTFOUND; -- GitLab From ac78838b65f6e843bc04cd7772ce7c85b607a404 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:12 +0100 Subject: [PATCH 1340/1846] MIPS: BCM47XX: fix signature of nvram_parse_macaddr Explicitly enforce an char array of 6 bytes for the mac address. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- arch/mips/include/asm/mach-bcm47xx/nvram.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h b/arch/mips/include/asm/mach-bcm47xx/nvram.h index 184d5ecb5f51..69ef3efe06e7 100644 --- a/arch/mips/include/asm/mach-bcm47xx/nvram.h +++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h @@ -37,7 +37,7 @@ struct nvram_header { extern int nvram_getenv(char *name, char *val, size_t val_len); -static inline void nvram_parse_macaddr(char *buf, u8 *macaddr) +static inline void nvram_parse_macaddr(char *buf, u8 macaddr[6]) { if (strchr(buf, ':')) sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], -- GitLab From 019eee2e34e2d1db715dc4fe5be2079800636fa8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:13 +0100 Subject: [PATCH 1341/1846] MIPS: BCM47XX: move and extend sprom parsing Move the sprom parsing from nvram into sprom.c. There are all values needed for sprom version 1 to 9 read from nvram and there are more sanity checks added. This is based on the sprom parsing in the open source part of the Broadcom SDK. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- arch/mips/bcm47xx/Makefile | 2 +- arch/mips/bcm47xx/setup.c | 151 +---- arch/mips/bcm47xx/sprom.c | 620 +++++++++++++++++++ arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 3 + 4 files changed, 625 insertions(+), 151 deletions(-) create mode 100644 arch/mips/bcm47xx/sprom.c diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile index 4add17349ff9..4389de182eb4 100644 --- a/arch/mips/bcm47xx/Makefile +++ b/arch/mips/bcm47xx/Makefile @@ -3,5 +3,5 @@ # under Linux. # -obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o +obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o sprom.o obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index aab6b0c40a75..6b0dacde98d4 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c @@ -85,156 +85,7 @@ static void bcm47xx_machine_halt(void) } #ifdef CONFIG_BCM47XX_SSB -#define READ_FROM_NVRAM(_outvar, name, buf) \ - if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\ - sprom->_outvar = simple_strtoul(buf, NULL, 0); - -#define READ_FROM_NVRAM2(_outvar, name1, name2, buf) \ - if (nvram_getprefix(prefix, name1, buf, sizeof(buf)) >= 0 || \ - nvram_getprefix(prefix, name2, buf, sizeof(buf)) >= 0)\ - sprom->_outvar = simple_strtoul(buf, NULL, 0); - -static inline int nvram_getprefix(const char *prefix, char *name, - char *buf, int len) -{ - if (prefix) { - char key[100]; - - snprintf(key, sizeof(key), "%s%s", prefix, name); - return nvram_getenv(key, buf, len); - } - - return nvram_getenv(name, buf, len); -} - -static u32 nvram_getu32(const char *name, char *buf, int len) -{ - int rv; - char key[100]; - u16 var0, var1; - - snprintf(key, sizeof(key), "%s0", name); - rv = nvram_getenv(key, buf, len); - /* return 0 here so this looks like unset */ - if (rv < 0) - return 0; - var0 = simple_strtoul(buf, NULL, 0); - - snprintf(key, sizeof(key), "%s1", name); - rv = nvram_getenv(key, buf, len); - if (rv < 0) - return 0; - var1 = simple_strtoul(buf, NULL, 0); - return var1 << 16 | var0; -} - -static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) -{ - char buf[100]; - u32 boardflags; - - memset(sprom, 0, sizeof(struct ssb_sprom)); - - sprom->revision = 1; /* Fallback: Old hardware does not define this. */ - READ_FROM_NVRAM(revision, "sromrev", buf); - if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0 || - nvram_getprefix(prefix, "macaddr", buf, sizeof(buf)) >= 0) - nvram_parse_macaddr(buf, sprom->il0mac); - if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0) - nvram_parse_macaddr(buf, sprom->et0mac); - if (nvram_getprefix(prefix, "et1macaddr", buf, sizeof(buf)) >= 0) - nvram_parse_macaddr(buf, sprom->et1mac); - READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf); - READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf); - READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf); - READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf); - READ_FROM_NVRAM(board_rev, "boardrev", buf); - READ_FROM_NVRAM(country_code, "ccode", buf); - READ_FROM_NVRAM(ant_available_a, "aa5g", buf); - READ_FROM_NVRAM(ant_available_bg, "aa2g", buf); - READ_FROM_NVRAM(pa0b0, "pa0b0", buf); - READ_FROM_NVRAM(pa0b1, "pa0b1", buf); - READ_FROM_NVRAM(pa0b2, "pa0b2", buf); - READ_FROM_NVRAM(pa1b0, "pa1b0", buf); - READ_FROM_NVRAM(pa1b1, "pa1b1", buf); - READ_FROM_NVRAM(pa1b2, "pa1b2", buf); - READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf); - READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf); - READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf); - READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf); - READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf); - READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf); - READ_FROM_NVRAM2(gpio0, "ledbh0", "wl0gpio0", buf); - READ_FROM_NVRAM2(gpio1, "ledbh1", "wl0gpio1", buf); - READ_FROM_NVRAM2(gpio2, "ledbh2", "wl0gpio2", buf); - READ_FROM_NVRAM2(gpio3, "ledbh3", "wl0gpio3", buf); - READ_FROM_NVRAM2(maxpwr_bg, "maxp2ga0", "pa0maxpwr", buf); - READ_FROM_NVRAM2(maxpwr_al, "maxp5gla0", "pa1lomaxpwr", buf); - READ_FROM_NVRAM2(maxpwr_a, "maxp5ga0", "pa1maxpwr", buf); - READ_FROM_NVRAM2(maxpwr_ah, "maxp5gha0", "pa1himaxpwr", buf); - READ_FROM_NVRAM2(itssi_bg, "itt5ga0", "pa0itssit", buf); - READ_FROM_NVRAM2(itssi_a, "itt2ga0", "pa1itssit", buf); - READ_FROM_NVRAM(tri2g, "tri2g", buf); - READ_FROM_NVRAM(tri5gl, "tri5gl", buf); - READ_FROM_NVRAM(tri5g, "tri5g", buf); - READ_FROM_NVRAM(tri5gh, "tri5gh", buf); - READ_FROM_NVRAM(txpid2g[0], "txpid2ga0", buf); - READ_FROM_NVRAM(txpid2g[1], "txpid2ga1", buf); - READ_FROM_NVRAM(txpid2g[2], "txpid2ga2", buf); - READ_FROM_NVRAM(txpid2g[3], "txpid2ga3", buf); - READ_FROM_NVRAM(txpid5g[0], "txpid5ga0", buf); - READ_FROM_NVRAM(txpid5g[1], "txpid5ga1", buf); - READ_FROM_NVRAM(txpid5g[2], "txpid5ga2", buf); - READ_FROM_NVRAM(txpid5g[3], "txpid5ga3", buf); - READ_FROM_NVRAM(txpid5gl[0], "txpid5gla0", buf); - READ_FROM_NVRAM(txpid5gl[1], "txpid5gla1", buf); - READ_FROM_NVRAM(txpid5gl[2], "txpid5gla2", buf); - READ_FROM_NVRAM(txpid5gl[3], "txpid5gla3", buf); - READ_FROM_NVRAM(txpid5gh[0], "txpid5gha0", buf); - READ_FROM_NVRAM(txpid5gh[1], "txpid5gha1", buf); - READ_FROM_NVRAM(txpid5gh[2], "txpid5gha2", buf); - READ_FROM_NVRAM(txpid5gh[3], "txpid5gha3", buf); - READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf); - READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf); - READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf); - READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf); - READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf); - READ_FROM_NVRAM(bxa2g, "bxa2g", buf); - READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf); - READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf); - READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf); - READ_FROM_NVRAM(bxa5g, "bxa5g", buf); - READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf); - - sprom->ofdm2gpo = nvram_getu32("ofdm2gpo", buf, sizeof(buf)); - sprom->ofdm5glpo = nvram_getu32("ofdm5glpo", buf, sizeof(buf)); - sprom->ofdm5gpo = nvram_getu32("ofdm5gpo", buf, sizeof(buf)); - sprom->ofdm5ghpo = nvram_getu32("ofdm5ghpo", buf, sizeof(buf)); - - READ_FROM_NVRAM(antenna_gain.ghz24.a0, "ag0", buf); - READ_FROM_NVRAM(antenna_gain.ghz24.a1, "ag1", buf); - READ_FROM_NVRAM(antenna_gain.ghz24.a2, "ag2", buf); - READ_FROM_NVRAM(antenna_gain.ghz24.a3, "ag3", buf); - memcpy(&sprom->antenna_gain.ghz5, &sprom->antenna_gain.ghz24, - sizeof(sprom->antenna_gain.ghz5)); - - if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) { - boardflags = simple_strtoul(buf, NULL, 0); - if (boardflags) { - sprom->boardflags_lo = (boardflags & 0x0000FFFFU); - sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16; - } - } - if (nvram_getprefix(prefix, "boardflags2", buf, sizeof(buf)) >= 0) { - boardflags = simple_strtoul(buf, NULL, 0); - if (boardflags) { - sprom->boardflags2_lo = (boardflags & 0x0000FFFFU); - sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16; - } - } -} - -int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out) +static int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out) { char prefix[10]; diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c new file mode 100644 index 000000000000..5c8dcd2a8a93 --- /dev/null +++ b/arch/mips/bcm47xx/sprom.c @@ -0,0 +1,620 @@ +/* + * Copyright (C) 2004 Florian Schirmer + * Copyright (C) 2006 Felix Fietkau + * Copyright (C) 2006 Michael Buesch + * Copyright (C) 2010 Waldemar Brodkorb + * Copyright (C) 2010-2012 Hauke Mehrtens + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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. + * + * 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., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +static void create_key(const char *prefix, const char *postfix, + const char *name, char *buf, int len) +{ + if (prefix && postfix) + snprintf(buf, len, "%s%s%s", prefix, name, postfix); + else if (prefix) + snprintf(buf, len, "%s%s", prefix, name); + else if (postfix) + snprintf(buf, len, "%s%s", name, postfix); + else + snprintf(buf, len, "%s", name); +} + +#define NVRAM_READ_VAL(type) \ +static void nvram_read_ ## type (const char *prefix, \ + const char *postfix, const char *name, \ + type *val, type allset) \ +{ \ + char buf[100]; \ + char key[40]; \ + int err; \ + type var; \ + \ + create_key(prefix, postfix, name, key, sizeof(key)); \ + \ + err = nvram_getenv(key, buf, sizeof(buf)); \ + if (err < 0) \ + return; \ + err = kstrto ## type (buf, 0, &var); \ + if (err) { \ + pr_warn("can not parse nvram name %s with value %s" \ + " got %i", key, buf, err); \ + return; \ + } \ + if (allset && var == allset) \ + return; \ + *val = var; \ +} + +NVRAM_READ_VAL(u8) +NVRAM_READ_VAL(s8) +NVRAM_READ_VAL(u16) +NVRAM_READ_VAL(u32) + +#undef NVRAM_READ_VAL + +static void nvram_read_u32_2(const char *prefix, const char *name, + u16 *val_lo, u16 *val_hi) +{ + char buf[100]; + char key[40]; + int err; + u32 val; + + create_key(prefix, NULL, name, key, sizeof(key)); + + err = nvram_getenv(key, buf, sizeof(buf)); + if (err < 0) + return; + err = kstrtou32(buf, 0, &val); + if (err) { + pr_warn("can not parse nvram name %s with value %s got %i", + key, buf, err); + return; + } + *val_lo = (val & 0x0000FFFFU); + *val_hi = (val & 0xFFFF0000U) >> 16; +} + +static void nvram_read_leddc(const char *prefix, const char *name, + u8 *leddc_on_time, u8 *leddc_off_time) +{ + char buf[100]; + char key[40]; + int err; + u32 val; + + create_key(prefix, NULL, name, key, sizeof(key)); + + err = nvram_getenv(key, buf, sizeof(buf)); + if (err < 0) + return; + err = kstrtou32(buf, 0, &val); + if (err) { + pr_warn("can not parse nvram name %s with value %s got %i", + key, buf, err); + return; + } + + if (val == 0xffff || val == 0xffffffff) + return; + + *leddc_on_time = val & 0xff; + *leddc_off_time = (val >> 16) & 0xff; +} + +static void nvram_read_macaddr(const char *prefix, const char *name, + u8 (*val)[6]) +{ + char buf[100]; + char key[40]; + int err; + + create_key(prefix, NULL, name, key, sizeof(key)); + + err = nvram_getenv(key, buf, sizeof(buf)); + if (err < 0) + return; + nvram_parse_macaddr(buf, *val); +} + +static void nvram_read_alpha2(const char *prefix, const char *name, + char (*val)[2]) +{ + char buf[10]; + char key[40]; + int err; + + create_key(prefix, NULL, name, key, sizeof(key)); + + err = nvram_getenv(key, buf, sizeof(buf)); + if (err < 0) + return; + if (buf[0] == '0') + return; + if (strlen(buf) > 2) { + pr_warn("alpha2 is too long %s", buf); + return; + } + memcpy(val, buf, sizeof(val)); +} + +static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, + const char *prefix) +{ + nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0); + nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0); + nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff); + nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff); + nvram_read_u8(prefix, NULL, "ledbh2", &sprom->gpio2, 0xff); + nvram_read_u8(prefix, NULL, "ledbh3", &sprom->gpio3, 0xff); + nvram_read_u8(prefix, NULL, "aa2g", &sprom->ant_available_bg, 0); + nvram_read_u8(prefix, NULL, "aa5g", &sprom->ant_available_a, 0); + nvram_read_s8(prefix, NULL, "ag0", &sprom->antenna_gain.a0, 0); + nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0); + nvram_read_alpha2(prefix, "ccode", &sprom->alpha2); +} + +static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom, + const char *prefix) +{ + nvram_read_u16(prefix, NULL, "pa0b0", &sprom->pa0b0, 0); + nvram_read_u16(prefix, NULL, "pa0b1", &sprom->pa0b1, 0); + nvram_read_u16(prefix, NULL, "pa0b2", &sprom->pa0b2, 0); + nvram_read_u8(prefix, NULL, "pa0itssit", &sprom->itssi_bg, 0); + nvram_read_u8(prefix, NULL, "pa0maxpwr", &sprom->maxpwr_bg, 0); + nvram_read_u16(prefix, NULL, "pa1b0", &sprom->pa1b0, 0); + nvram_read_u16(prefix, NULL, "pa1b1", &sprom->pa1b1, 0); + nvram_read_u16(prefix, NULL, "pa1b2", &sprom->pa1b2, 0); + nvram_read_u8(prefix, NULL, "pa1itssit", &sprom->itssi_a, 0); + nvram_read_u8(prefix, NULL, "pa1maxpwr", &sprom->maxpwr_a, 0); +} + +static void bcm47xx_fill_sprom_r1(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u16(prefix, NULL, "boardflags", &sprom->boardflags_lo, 0); + nvram_read_u8(prefix, NULL, "cc", &sprom->country_code, 0); +} + +static void bcm47xx_fill_sprom_r2389(struct ssb_sprom *sprom, + const char *prefix) +{ + nvram_read_u8(prefix, NULL, "opo", &sprom->opo, 0); + nvram_read_u16(prefix, NULL, "pa1lob0", &sprom->pa1lob0, 0); + nvram_read_u16(prefix, NULL, "pa1lob1", &sprom->pa1lob1, 0); + nvram_read_u16(prefix, NULL, "pa1lob2", &sprom->pa1lob2, 0); + nvram_read_u16(prefix, NULL, "pa1hib0", &sprom->pa1hib0, 0); + nvram_read_u16(prefix, NULL, "pa1hib1", &sprom->pa1hib1, 0); + nvram_read_u16(prefix, NULL, "pa1hib2", &sprom->pa1hib2, 0); + nvram_read_u8(prefix, NULL, "pa1lomaxpwr", &sprom->maxpwr_al, 0); + nvram_read_u8(prefix, NULL, "pa1himaxpwr", &sprom->maxpwr_ah, 0); +} + +static void bcm47xx_fill_sprom_r2(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo, + &sprom->boardflags_hi); + nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0); +} + +static void bcm47xx_fill_sprom_r389(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u8(prefix, NULL, "bxa2g", &sprom->bxa2g, 0); + nvram_read_u8(prefix, NULL, "rssisav2g", &sprom->rssisav2g, 0); + nvram_read_u8(prefix, NULL, "rssismc2g", &sprom->rssismc2g, 0); + nvram_read_u8(prefix, NULL, "rssismf2g", &sprom->rssismf2g, 0); + nvram_read_u8(prefix, NULL, "bxa5g", &sprom->bxa5g, 0); + nvram_read_u8(prefix, NULL, "rssisav5g", &sprom->rssisav5g, 0); + nvram_read_u8(prefix, NULL, "rssismc5g", &sprom->rssismc5g, 0); + nvram_read_u8(prefix, NULL, "rssismf5g", &sprom->rssismf5g, 0); + nvram_read_u8(prefix, NULL, "tri2g", &sprom->tri2g, 0); + nvram_read_u8(prefix, NULL, "tri5g", &sprom->tri5g, 0); + nvram_read_u8(prefix, NULL, "tri5gl", &sprom->tri5gl, 0); + nvram_read_u8(prefix, NULL, "tri5gh", &sprom->tri5gh, 0); + nvram_read_s8(prefix, NULL, "rxpo2g", &sprom->rxpo2g, 0); + nvram_read_s8(prefix, NULL, "rxpo5g", &sprom->rxpo5g, 0); +} + +static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo, + &sprom->boardflags_hi); + nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0); + nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0); + nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time, + &sprom->leddc_off_time); +} + +static void bcm47xx_fill_sprom_r4589(struct ssb_sprom *sprom, + const char *prefix) +{ + nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo, + &sprom->boardflags_hi); + nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo, + &sprom->boardflags2_hi); + nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0); + nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0); + nvram_read_s8(prefix, NULL, "ag2", &sprom->antenna_gain.a2, 0); + nvram_read_s8(prefix, NULL, "ag3", &sprom->antenna_gain.a3, 0); + nvram_read_u8(prefix, NULL, "txchain", &sprom->txchain, 0xf); + nvram_read_u8(prefix, NULL, "rxchain", &sprom->rxchain, 0xf); + nvram_read_u8(prefix, NULL, "antswitch", &sprom->antswitch, 0xff); + nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time, + &sprom->leddc_off_time); +} + +static void bcm47xx_fill_sprom_r458(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u16(prefix, NULL, "cck2gpo", &sprom->cck2gpo, 0); + nvram_read_u32(prefix, NULL, "ofdm2gpo", &sprom->ofdm2gpo, 0); + nvram_read_u32(prefix, NULL, "ofdm5gpo", &sprom->ofdm5gpo, 0); + nvram_read_u32(prefix, NULL, "ofdm5glpo", &sprom->ofdm5glpo, 0); + nvram_read_u32(prefix, NULL, "ofdm5ghpo", &sprom->ofdm5ghpo, 0); + nvram_read_u16(prefix, NULL, "cddpo", &sprom->cddpo, 0); + nvram_read_u16(prefix, NULL, "stbcpo", &sprom->stbcpo, 0); + nvram_read_u16(prefix, NULL, "bw40po", &sprom->bw40po, 0); + nvram_read_u16(prefix, NULL, "bwduppo", &sprom->bwduppo, 0); + nvram_read_u16(prefix, NULL, "mcs2gpo0", &sprom->mcs2gpo[0], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo1", &sprom->mcs2gpo[1], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo2", &sprom->mcs2gpo[2], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo3", &sprom->mcs2gpo[3], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo4", &sprom->mcs2gpo[4], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo5", &sprom->mcs2gpo[5], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo6", &sprom->mcs2gpo[6], 0); + nvram_read_u16(prefix, NULL, "mcs2gpo7", &sprom->mcs2gpo[7], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo0", &sprom->mcs5gpo[0], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo1", &sprom->mcs5gpo[1], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo2", &sprom->mcs5gpo[2], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo3", &sprom->mcs5gpo[3], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo4", &sprom->mcs5gpo[4], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo5", &sprom->mcs5gpo[5], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo6", &sprom->mcs5gpo[6], 0); + nvram_read_u16(prefix, NULL, "mcs5gpo7", &sprom->mcs5gpo[7], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo0", &sprom->mcs5glpo[0], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo1", &sprom->mcs5glpo[1], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo2", &sprom->mcs5glpo[2], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo3", &sprom->mcs5glpo[3], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo4", &sprom->mcs5glpo[4], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo5", &sprom->mcs5glpo[5], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo6", &sprom->mcs5glpo[6], 0); + nvram_read_u16(prefix, NULL, "mcs5glpo7", &sprom->mcs5glpo[7], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo0", &sprom->mcs5ghpo[0], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo1", &sprom->mcs5ghpo[1], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo2", &sprom->mcs5ghpo[2], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo3", &sprom->mcs5ghpo[3], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo4", &sprom->mcs5ghpo[4], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo5", &sprom->mcs5ghpo[5], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo6", &sprom->mcs5ghpo[6], 0); + nvram_read_u16(prefix, NULL, "mcs5ghpo7", &sprom->mcs5ghpo[7], 0); +} + +static void bcm47xx_fill_sprom_r45(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u8(prefix, NULL, "txpid2ga0", &sprom->txpid2g[0], 0); + nvram_read_u8(prefix, NULL, "txpid2ga1", &sprom->txpid2g[1], 0); + nvram_read_u8(prefix, NULL, "txpid2ga2", &sprom->txpid2g[2], 0); + nvram_read_u8(prefix, NULL, "txpid2ga3", &sprom->txpid2g[3], 0); + nvram_read_u8(prefix, NULL, "txpid5ga0", &sprom->txpid5g[0], 0); + nvram_read_u8(prefix, NULL, "txpid5ga1", &sprom->txpid5g[1], 0); + nvram_read_u8(prefix, NULL, "txpid5ga2", &sprom->txpid5g[2], 0); + nvram_read_u8(prefix, NULL, "txpid5ga3", &sprom->txpid5g[3], 0); + nvram_read_u8(prefix, NULL, "txpid5gla0", &sprom->txpid5gl[0], 0); + nvram_read_u8(prefix, NULL, "txpid5gla1", &sprom->txpid5gl[1], 0); + nvram_read_u8(prefix, NULL, "txpid5gla2", &sprom->txpid5gl[2], 0); + nvram_read_u8(prefix, NULL, "txpid5gla3", &sprom->txpid5gl[3], 0); + nvram_read_u8(prefix, NULL, "txpid5gha0", &sprom->txpid5gh[0], 0); + nvram_read_u8(prefix, NULL, "txpid5gha1", &sprom->txpid5gh[1], 0); + nvram_read_u8(prefix, NULL, "txpid5gha2", &sprom->txpid5gh[2], 0); + nvram_read_u8(prefix, NULL, "txpid5gha3", &sprom->txpid5gh[3], 0); +} + +static void bcm47xx_fill_sprom_r89(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u8(prefix, NULL, "tssipos2g", &sprom->fem.ghz2.tssipos, 0); + nvram_read_u8(prefix, NULL, "extpagain2g", + &sprom->fem.ghz2.extpa_gain, 0); + nvram_read_u8(prefix, NULL, "pdetrange2g", + &sprom->fem.ghz2.pdet_range, 0); + nvram_read_u8(prefix, NULL, "triso2g", &sprom->fem.ghz2.tr_iso, 0); + nvram_read_u8(prefix, NULL, "antswctl2g", &sprom->fem.ghz2.antswlut, 0); + nvram_read_u8(prefix, NULL, "tssipos5g", &sprom->fem.ghz5.tssipos, 0); + nvram_read_u8(prefix, NULL, "extpagain5g", + &sprom->fem.ghz5.extpa_gain, 0); + nvram_read_u8(prefix, NULL, "pdetrange5g", + &sprom->fem.ghz5.pdet_range, 0); + nvram_read_u8(prefix, NULL, "triso5g", &sprom->fem.ghz5.tr_iso, 0); + nvram_read_u8(prefix, NULL, "antswctl5g", &sprom->fem.ghz5.antswlut, 0); + nvram_read_u8(prefix, NULL, "tempthresh", &sprom->tempthresh, 0); + nvram_read_u8(prefix, NULL, "tempoffset", &sprom->tempoffset, 0); + nvram_read_u16(prefix, NULL, "rawtempsense", &sprom->rawtempsense, 0); + nvram_read_u8(prefix, NULL, "measpower", &sprom->measpower, 0); + nvram_read_u8(prefix, NULL, "tempsense_slope", + &sprom->tempsense_slope, 0); + nvram_read_u8(prefix, NULL, "tempcorrx", &sprom->tempcorrx, 0); + nvram_read_u8(prefix, NULL, "tempsense_option", + &sprom->tempsense_option, 0); + nvram_read_u8(prefix, NULL, "freqoffset_corr", + &sprom->freqoffset_corr, 0); + nvram_read_u8(prefix, NULL, "iqcal_swp_dis", &sprom->iqcal_swp_dis, 0); + nvram_read_u8(prefix, NULL, "hw_iqcal_en", &sprom->hw_iqcal_en, 0); + nvram_read_u8(prefix, NULL, "elna2g", &sprom->elna2g, 0); + nvram_read_u8(prefix, NULL, "elna5g", &sprom->elna5g, 0); + nvram_read_u8(prefix, NULL, "phycal_tempdelta", + &sprom->phycal_tempdelta, 0); + nvram_read_u8(prefix, NULL, "temps_period", &sprom->temps_period, 0); + nvram_read_u8(prefix, NULL, "temps_hysteresis", + &sprom->temps_hysteresis, 0); + nvram_read_u8(prefix, NULL, "measpower1", &sprom->measpower1, 0); + nvram_read_u8(prefix, NULL, "measpower2", &sprom->measpower2, 0); + nvram_read_u8(prefix, NULL, "rxgainerr2ga0", + &sprom->rxgainerr2ga[0], 0); + nvram_read_u8(prefix, NULL, "rxgainerr2ga1", + &sprom->rxgainerr2ga[1], 0); + nvram_read_u8(prefix, NULL, "rxgainerr2ga2", + &sprom->rxgainerr2ga[2], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gla0", + &sprom->rxgainerr5gla[0], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gla1", + &sprom->rxgainerr5gla[1], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gla2", + &sprom->rxgainerr5gla[2], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gma0", + &sprom->rxgainerr5gma[0], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gma1", + &sprom->rxgainerr5gma[1], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gma2", + &sprom->rxgainerr5gma[2], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gha0", + &sprom->rxgainerr5gha[0], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gha1", + &sprom->rxgainerr5gha[1], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gha2", + &sprom->rxgainerr5gha[2], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gua0", + &sprom->rxgainerr5gua[0], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gua1", + &sprom->rxgainerr5gua[1], 0); + nvram_read_u8(prefix, NULL, "rxgainerr5gua2", + &sprom->rxgainerr5gua[2], 0); + nvram_read_u8(prefix, NULL, "noiselvl2ga0", &sprom->noiselvl2ga[0], 0); + nvram_read_u8(prefix, NULL, "noiselvl2ga1", &sprom->noiselvl2ga[1], 0); + nvram_read_u8(prefix, NULL, "noiselvl2ga2", &sprom->noiselvl2ga[2], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gla0", + &sprom->noiselvl5gla[0], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gla1", + &sprom->noiselvl5gla[1], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gla2", + &sprom->noiselvl5gla[2], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gma0", + &sprom->noiselvl5gma[0], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gma1", + &sprom->noiselvl5gma[1], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gma2", + &sprom->noiselvl5gma[2], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gha0", + &sprom->noiselvl5gha[0], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gha1", + &sprom->noiselvl5gha[1], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gha2", + &sprom->noiselvl5gha[2], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gua0", + &sprom->noiselvl5gua[0], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gua1", + &sprom->noiselvl5gua[1], 0); + nvram_read_u8(prefix, NULL, "noiselvl5gua2", + &sprom->noiselvl5gua[2], 0); + nvram_read_u8(prefix, NULL, "pcieingress_war", + &sprom->pcieingress_war, 0); +} + +static void bcm47xx_fill_sprom_r9(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_u16(prefix, NULL, "cckbw202gpo", &sprom->cckbw202gpo, 0); + nvram_read_u16(prefix, NULL, "cckbw20ul2gpo", &sprom->cckbw20ul2gpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw202gpo", + &sprom->legofdmbw202gpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw20ul2gpo", + &sprom->legofdmbw20ul2gpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw205glpo", + &sprom->legofdmbw205glpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw20ul5glpo", + &sprom->legofdmbw20ul5glpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw205gmpo", + &sprom->legofdmbw205gmpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw20ul5gmpo", + &sprom->legofdmbw20ul5gmpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw205ghpo", + &sprom->legofdmbw205ghpo, 0); + nvram_read_u32(prefix, NULL, "legofdmbw20ul5ghpo", + &sprom->legofdmbw20ul5ghpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw202gpo", &sprom->mcsbw202gpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw20ul2gpo", &sprom->mcsbw20ul2gpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw402gpo", &sprom->mcsbw402gpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw205glpo", &sprom->mcsbw205glpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw20ul5glpo", + &sprom->mcsbw20ul5glpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw405glpo", &sprom->mcsbw405glpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw205gmpo", &sprom->mcsbw205gmpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw20ul5gmpo", + &sprom->mcsbw20ul5gmpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw405gmpo", &sprom->mcsbw405gmpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw205ghpo", &sprom->mcsbw205ghpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw20ul5ghpo", + &sprom->mcsbw20ul5ghpo, 0); + nvram_read_u32(prefix, NULL, "mcsbw405ghpo", &sprom->mcsbw405ghpo, 0); + nvram_read_u16(prefix, NULL, "mcs32po", &sprom->mcs32po, 0); + nvram_read_u16(prefix, NULL, "legofdm40duppo", + &sprom->legofdm40duppo, 0); + nvram_read_u8(prefix, NULL, "sar2g", &sprom->sar2g, 0); + nvram_read_u8(prefix, NULL, "sar5g", &sprom->sar5g, 0); +} + +static void bcm47xx_fill_sprom_path_r4589(struct ssb_sprom *sprom, + const char *prefix) +{ + char postfix[2]; + int i; + + for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { + struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; + snprintf(postfix, sizeof(postfix), "%i", i); + nvram_read_u8(prefix, postfix, "maxp2ga", + &pwr_info->maxpwr_2g, 0); + nvram_read_u8(prefix, postfix, "itt2ga", + &pwr_info->itssi_2g, 0); + nvram_read_u8(prefix, postfix, "itt5ga", + &pwr_info->itssi_5g, 0); + nvram_read_u16(prefix, postfix, "pa2gw0a", + &pwr_info->pa_2g[0], 0); + nvram_read_u16(prefix, postfix, "pa2gw1a", + &pwr_info->pa_2g[1], 0); + nvram_read_u16(prefix, postfix, "pa2gw2a", + &pwr_info->pa_2g[2], 0); + nvram_read_u8(prefix, postfix, "maxp5ga", + &pwr_info->maxpwr_5g, 0); + nvram_read_u8(prefix, postfix, "maxp5gha", + &pwr_info->maxpwr_5gh, 0); + nvram_read_u8(prefix, postfix, "maxp5gla", + &pwr_info->maxpwr_5gl, 0); + nvram_read_u16(prefix, postfix, "pa5gw0a", + &pwr_info->pa_5g[0], 0); + nvram_read_u16(prefix, postfix, "pa5gw1a", + &pwr_info->pa_5g[1], 0); + nvram_read_u16(prefix, postfix, "pa5gw2a", + &pwr_info->pa_5g[2], 0); + nvram_read_u16(prefix, postfix, "pa5glw0a", + &pwr_info->pa_5gl[0], 0); + nvram_read_u16(prefix, postfix, "pa5glw1a", + &pwr_info->pa_5gl[1], 0); + nvram_read_u16(prefix, postfix, "pa5glw2a", + &pwr_info->pa_5gl[2], 0); + nvram_read_u16(prefix, postfix, "pa5ghw0a", + &pwr_info->pa_5gh[0], 0); + nvram_read_u16(prefix, postfix, "pa5ghw1a", + &pwr_info->pa_5gh[1], 0); + nvram_read_u16(prefix, postfix, "pa5ghw2a", + &pwr_info->pa_5gh[2], 0); + } +} + +static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom, + const char *prefix) +{ + char postfix[2]; + int i; + + for (i = 0; i < ARRAY_SIZE(sprom->core_pwr_info); i++) { + struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i]; + snprintf(postfix, sizeof(postfix), "%i", i); + nvram_read_u16(prefix, postfix, "pa2gw3a", + &pwr_info->pa_2g[3], 0); + nvram_read_u16(prefix, postfix, "pa5gw3a", + &pwr_info->pa_5g[3], 0); + nvram_read_u16(prefix, postfix, "pa5glw3a", + &pwr_info->pa_5gl[3], 0); + nvram_read_u16(prefix, postfix, "pa5ghw3a", + &pwr_info->pa_5gh[3], 0); + } +} + +void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix) +{ + nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac); + nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0); + nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0); + + nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac); + nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0); + nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0); + + nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac); + nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac); +} + +void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) +{ + memset(sprom, 0, sizeof(struct ssb_sprom)); + + bcm47xx_fill_sprom_ethernet(sprom, prefix); + + nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0); + + switch (sprom->revision) { + case 1: + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r12389(sprom, prefix); + bcm47xx_fill_sprom_r1(sprom, prefix); + break; + case 2: + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r12389(sprom, prefix); + bcm47xx_fill_sprom_r2389(sprom, prefix); + bcm47xx_fill_sprom_r2(sprom, prefix); + break; + case 3: + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r12389(sprom, prefix); + bcm47xx_fill_sprom_r2389(sprom, prefix); + bcm47xx_fill_sprom_r389(sprom, prefix); + bcm47xx_fill_sprom_r3(sprom, prefix); + break; + case 4: + case 5: + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r4589(sprom, prefix); + bcm47xx_fill_sprom_r458(sprom, prefix); + bcm47xx_fill_sprom_r45(sprom, prefix); + bcm47xx_fill_sprom_path_r4589(sprom, prefix); + bcm47xx_fill_sprom_path_r45(sprom, prefix); + break; + case 8: + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r12389(sprom, prefix); + bcm47xx_fill_sprom_r2389(sprom, prefix); + bcm47xx_fill_sprom_r389(sprom, prefix); + bcm47xx_fill_sprom_r4589(sprom, prefix); + bcm47xx_fill_sprom_r458(sprom, prefix); + bcm47xx_fill_sprom_r89(sprom, prefix); + bcm47xx_fill_sprom_path_r4589(sprom, prefix); + break; + case 9: + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r12389(sprom, prefix); + bcm47xx_fill_sprom_r2389(sprom, prefix); + bcm47xx_fill_sprom_r389(sprom, prefix); + bcm47xx_fill_sprom_r4589(sprom, prefix); + bcm47xx_fill_sprom_r89(sprom, prefix); + bcm47xx_fill_sprom_r9(sprom, prefix); + bcm47xx_fill_sprom_path_r4589(sprom, prefix); + break; + default: + pr_warn("Unsupported SPROM revision %d detected. Will extract" + " v1\n", sprom->revision); + sprom->revision = 1; + bcm47xx_fill_sprom_r1234589(sprom, prefix); + bcm47xx_fill_sprom_r12389(sprom, prefix); + bcm47xx_fill_sprom_r1(sprom, prefix); + } +} diff --git a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h index de95e0723e2b..5ecaf47b34d2 100644 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h @@ -44,4 +44,7 @@ union bcm47xx_bus { extern union bcm47xx_bus bcm47xx_bus; extern enum bcm47xx_bus_type bcm47xx_bus_type; +void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix); +void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix); + #endif /* __ASM_BCM47XX_H */ -- GitLab From f384b3dddc727b1cbd77e493c24d7fefa883396a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 00:56:14 +0100 Subject: [PATCH 1342/1846] MIPS: BCM47XX: provide sprom to bcma bus On SoCs the sprom is often stored in nvram in the flashchip. This patch registers a sprom fallback callback handler in bcma and provides the sprom needed for this device. Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- arch/mips/bcm47xx/setup.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index 6b0dacde98d4..19780aa91708 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c @@ -3,7 +3,7 @@ * Copyright (C) 2006 Felix Fietkau * Copyright (C) 2006 Michael Buesch * Copyright (C) 2010 Waldemar Brodkorb - * Copyright (C) 2010-2011 Hauke Mehrtens + * Copyright (C) 2010-2012 Hauke Mehrtens * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -85,7 +85,7 @@ static void bcm47xx_machine_halt(void) } #ifdef CONFIG_BCM47XX_SSB -static int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out) +static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) { char prefix[10]; @@ -102,7 +102,7 @@ static int bcm47xx_get_sprom(struct ssb_bus *bus, struct ssb_sprom *out) } static int bcm47xx_get_invariants(struct ssb_bus *bus, - struct ssb_init_invariants *iv) + struct ssb_init_invariants *iv) { char buf[20]; @@ -132,7 +132,7 @@ static void __init bcm47xx_register_ssb(void) char buf[100]; struct ssb_mipscore *mcore; - err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom); + err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb); if (err) printk(KERN_WARNING "bcm47xx: someone else already registered" " a ssb SPROM callback handler (err %d)\n", err); @@ -159,10 +159,41 @@ static void __init bcm47xx_register_ssb(void) #endif #ifdef CONFIG_BCM47XX_BCMA +static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out) +{ + char prefix[10]; + struct bcma_device *core; + + switch (bus->hosttype) { + case BCMA_HOSTTYPE_PCI: + snprintf(prefix, sizeof(prefix), "pci/%u/%u/", + bus->host_pci->bus->number + 1, + PCI_SLOT(bus->host_pci->devfn)); + bcm47xx_fill_sprom(out, prefix); + return 0; + case BCMA_HOSTTYPE_SOC: + bcm47xx_fill_sprom_ethernet(out, NULL); + core = bcma_find_core(bus, BCMA_CORE_80211); + if (core) { + snprintf(prefix, sizeof(prefix), "sb/%u/", + core->core_index); + bcm47xx_fill_sprom(out, prefix); + } + return 0; + default: + pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n"); + return -EINVAL; + } +} + static void __init bcm47xx_register_bcma(void) { int err; + err = bcma_arch_register_fallback_sprom(&bcm47xx_get_sprom_bcma); + if (err) + pr_warn("bcm47xx: someone else already registered a bcma SPROM callback handler (err %d)\n", err); + err = bcma_host_soc_register(&bcm47xx_bus.bcma); if (err) panic("Failed to initialize BCMA bus (err %d)", err); -- GitLab From eb416ad37db897efe9b2a5b79bd671f5966fa443 Mon Sep 17 00:00:00 2001 From: Avinash Patil Date: Mon, 27 Feb 2012 22:04:11 -0800 Subject: [PATCH 1343/1846] mwifiex: correct bitrates advertised to cfg80211 1. Driver and firmware do not support 22Mbps and 72Mbps bitrates. Remove them from the rate table advertised to cfg80211. 2. First 4 rates from mwifiex_rates table are not valid for 5GHz/A band. Set correct bitrate array's index and no of rates for ieee80211_supported_band for 5GHz band. Signed-off-by: Avinash Patil Signed-off-by: Nishant Sarmukadam Signed-off-by: Amitkumar Karwar Signed-off-by: Yogesh Ashok Powar Signed-off-by: Kiran Divekar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 6a81101bab44..55293a3ac317 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -613,7 +613,6 @@ static struct ieee80211_rate mwifiex_rates[] = { {.bitrate = 20, .hw_value = 4, }, {.bitrate = 55, .hw_value = 11, }, {.bitrate = 110, .hw_value = 22, }, - {.bitrate = 220, .hw_value = 44, }, {.bitrate = 60, .hw_value = 12, }, {.bitrate = 90, .hw_value = 18, }, {.bitrate = 120, .hw_value = 24, }, @@ -622,7 +621,6 @@ static struct ieee80211_rate mwifiex_rates[] = { {.bitrate = 360, .hw_value = 72, }, {.bitrate = 480, .hw_value = 96, }, {.bitrate = 540, .hw_value = 108, }, - {.bitrate = 720, .hw_value = 144, }, }; /* Channel definitions to be advertised to cfg80211 */ @@ -688,8 +686,8 @@ static struct ieee80211_channel mwifiex_channels_5ghz[] = { static struct ieee80211_supported_band mwifiex_band_5ghz = { .channels = mwifiex_channels_5ghz, .n_channels = ARRAY_SIZE(mwifiex_channels_5ghz), - .bitrates = mwifiex_rates - 4, - .n_bitrates = ARRAY_SIZE(mwifiex_rates) + 4, + .bitrates = mwifiex_rates + 4, + .n_bitrates = ARRAY_SIZE(mwifiex_rates) - 4, }; -- GitLab From b9be5f39bdabb25708a9de294c2cae7bdd8dfb17 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Mon, 27 Feb 2012 22:04:14 -0800 Subject: [PATCH 1344/1846] mwifiex: remove unnecessary struct mwifiex_802_11_ssid Use struct cfg80211_ssid available in include/net/cfg80211.h instead of having similar definition in driver. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 4 ++-- drivers/net/wireless/mwifiex/decl.h | 5 ----- drivers/net/wireless/mwifiex/ioctl.h | 4 ++-- drivers/net/wireless/mwifiex/join.c | 4 ++-- drivers/net/wireless/mwifiex/main.h | 15 +++++++-------- drivers/net/wireless/mwifiex/scan.c | 7 +++---- drivers/net/wireless/mwifiex/sta_event.c | 2 +- drivers/net/wireless/mwifiex/sta_ioctl.c | 5 ++--- 8 files changed, 19 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 55293a3ac317..6a91c2fa89fe 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -839,12 +839,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, u8 *bssid, int mode, struct ieee80211_channel *channel, struct cfg80211_connect_params *sme, bool privacy) { - struct mwifiex_802_11_ssid req_ssid; + struct cfg80211_ssid req_ssid; int ret, auth_type = 0; struct cfg80211_bss *bss = NULL; u8 is_scanning_required = 0; - memset(&req_ssid, 0, sizeof(struct mwifiex_802_11_ssid)); + memset(&req_ssid, 0, sizeof(struct cfg80211_ssid)); req_ssid.ssid_len = ssid_len; if (ssid_len > IEEE80211_MAX_SSID_LEN) { diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h index 3735c775495c..be5fd1652e53 100644 --- a/drivers/net/wireless/mwifiex/decl.h +++ b/drivers/net/wireless/mwifiex/decl.h @@ -91,11 +91,6 @@ struct mwifiex_fw_image { u32 fw_len; }; -struct mwifiex_802_11_ssid { - u32 ssid_len; - u8 ssid[IEEE80211_MAX_SSID_LEN]; -}; - struct mwifiex_wait_queue { wait_queue_head_t wait; int status; diff --git a/drivers/net/wireless/mwifiex/ioctl.h b/drivers/net/wireless/mwifiex/ioctl.h index d5d81f1fe41c..7ca4e8234f3e 100644 --- a/drivers/net/wireless/mwifiex/ioctl.h +++ b/drivers/net/wireless/mwifiex/ioctl.h @@ -50,7 +50,7 @@ struct mwifiex_chan_freq { }; struct mwifiex_ssid_bssid { - struct mwifiex_802_11_ssid ssid; + struct cfg80211_ssid ssid; u8 bssid[ETH_ALEN]; }; @@ -122,7 +122,7 @@ struct mwifiex_ver_ext { struct mwifiex_bss_info { u32 bss_mode; - struct mwifiex_802_11_ssid ssid; + struct cfg80211_ssid ssid; u32 bss_chan; u32 region_code; u32 media_connected; diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 5c95e4839004..bce9991612c8 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -714,7 +714,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - struct mwifiex_802_11_ssid *req_ssid) + struct cfg80211_ssid *req_ssid) { int rsn_ie_len = 0; struct mwifiex_adapter *adapter = priv->adapter; @@ -1245,7 +1245,7 @@ int mwifiex_associate(struct mwifiex_private *priv, */ int mwifiex_adhoc_start(struct mwifiex_private *priv, - struct mwifiex_802_11_ssid *adhoc_ssid) + struct cfg80211_ssid *adhoc_ssid) { dev_dbg(priv->adapter->dev, "info: Adhoc Channel = %d\n", priv->adhoc_channel); diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index dddb5563398a..a0bd4ebd262a 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -244,7 +244,7 @@ struct ieee_types_generic { struct mwifiex_bssdescriptor { u8 mac_address[ETH_ALEN]; - struct mwifiex_802_11_ssid ssid; + struct cfg80211_ssid ssid; u32 privacy; s32 rssi; u32 channel; @@ -388,7 +388,7 @@ struct mwifiex_private { s16 bcn_rssi_avg; s16 bcn_nf_avg; struct mwifiex_bssdescriptor *attempted_bss_desc; - struct mwifiex_802_11_ssid prev_ssid; + struct cfg80211_ssid prev_ssid; u8 prev_bssid[ETH_ALEN]; struct mwifiex_current_bss_params curr_bss_params; u16 beacon_period; @@ -747,8 +747,7 @@ void mwifiex_queue_scan_cmd(struct mwifiex_private *priv, struct cmd_ctrl_node *cmd_node); int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, struct host_cmd_ds_command *resp); -s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1, - struct mwifiex_802_11_ssid *ssid2); +s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2); int mwifiex_associate(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc); int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, @@ -760,12 +759,12 @@ void mwifiex_reset_connect_state(struct mwifiex_private *priv); u8 mwifiex_band_to_radio_type(u8 band); int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac); int mwifiex_adhoc_start(struct mwifiex_private *priv, - struct mwifiex_802_11_ssid *adhoc_ssid); + struct cfg80211_ssid *adhoc_ssid); int mwifiex_adhoc_join(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc); int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - struct mwifiex_802_11_ssid *req_ssid); + struct cfg80211_ssid *req_ssid); int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, struct mwifiex_bssdescriptor *bss_desc); @@ -898,7 +897,7 @@ int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist, struct net_device *dev); int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter); int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, - struct mwifiex_802_11_ssid *req_ssid); + struct cfg80211_ssid *req_ssid); int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type); int mwifiex_enable_hs(struct mwifiex_adapter *adapter); int mwifiex_disable_auto_ds(struct mwifiex_private *priv); @@ -907,7 +906,7 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv, int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, struct mwifiex_rate_cfg *rate); int mwifiex_request_scan(struct mwifiex_private *priv, - struct mwifiex_802_11_ssid *req_ssid); + struct cfg80211_ssid *req_ssid); int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, struct mwifiex_user_scan_cfg *scan_req); int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel); diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 8f10038d1b45..67422f64f9fe 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -163,8 +163,7 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) * This function compares two SSIDs and checks if they match. */ s32 -mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1, - struct mwifiex_802_11_ssid *ssid2) +mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2) { if (!ssid1 || !ssid2 || (ssid1->ssid_len != ssid2->ssid_len)) return -1; @@ -1851,7 +1850,7 @@ mwifiex_queue_scan_cmd(struct mwifiex_private *priv, * firmware, filtered on a specific SSID. */ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv, - struct mwifiex_802_11_ssid *req_ssid) + struct cfg80211_ssid *req_ssid) { struct mwifiex_adapter *adapter = priv->adapter; int ret = 0; @@ -1896,7 +1895,7 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv, * scan, depending upon whether an SSID is provided or not. */ int mwifiex_request_scan(struct mwifiex_private *priv, - struct mwifiex_802_11_ssid *req_ssid) + struct cfg80211_ssid *req_ssid) { int ret; diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c index d7aa21da84d0..b9b59db60454 100644 --- a/drivers/net/wireless/mwifiex/sta_event.c +++ b/drivers/net/wireless/mwifiex/sta_event.c @@ -101,7 +101,7 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) memcpy(&priv->prev_ssid, &priv->curr_bss_params.bss_descriptor.ssid, - sizeof(struct mwifiex_802_11_ssid)); + sizeof(struct cfg80211_ssid)); memcpy(priv->prev_bssid, priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN); diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index e10161f5894c..593d285111d2 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -192,7 +192,7 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, * first. */ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, - struct mwifiex_802_11_ssid *req_ssid) + struct cfg80211_ssid *req_ssid) { int ret; struct mwifiex_adapter *adapter = priv->adapter; @@ -464,8 +464,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv, info->bss_mode = priv->bss_mode; - memcpy(&info->ssid, &bss_desc->ssid, - sizeof(struct mwifiex_802_11_ssid)); + memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid)); memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN); -- GitLab From be0b281e8f7afd56d2250a568b85dafc850bc9ae Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Mon, 27 Feb 2012 22:04:15 -0800 Subject: [PATCH 1345/1846] mwifiex: fix bug in wildcard scan handling Currently if valid SSID list is provided in scan request, driver performs specific SSID scan otherwise wildcard scan is chosen. When wpa_supplicant provides valid SSID list followed by zero-length SSID for wildcard scan, only specific SSID scan is performed by driver. Actually driver is expected to do both type of scanning in this case. The patch fixes this issue. Also, use SSID list pointer provided by stack directly, instead of copying SSID's to local structure. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 10 +++---- drivers/net/wireless/mwifiex/fw.h | 10 ++----- drivers/net/wireless/mwifiex/scan.c | 40 ++++++++++++------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 6a91c2fa89fe..b4890a01ba92 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -1106,12 +1106,10 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, 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; - } + + priv->user_scan_cfg->num_ssids = request->n_ssids; + priv->user_scan_cfg->ssid_list = request->ssids; + for (i = 0; i < request->n_channels; i++) { chan = request->channels[i]; priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value; diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index c82620094a53..fc4ffee6c6b9 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h @@ -852,11 +852,6 @@ struct mwifiex_user_scan_chan { u32 scan_time; } __packed; -struct mwifiex_user_scan_ssid { - u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; - u8 max_len; -} __packed; - struct mwifiex_user_scan_cfg { /* * BSS mode to be sent in the firmware command @@ -867,8 +862,9 @@ struct mwifiex_user_scan_cfg { u8 reserved; /* BSSID filter sent in the firmware command to limit the results */ u8 specific_bssid[ETH_ALEN]; - /* SSID filter list used in the to limit the scan results */ - struct mwifiex_user_scan_ssid ssid_list[MWIFIEX_MAX_SSID_LIST_LENGTH]; + /* SSID filter list used in the firmware to limit the scan results */ + struct cfg80211_ssid *ssid_list; + u8 num_ssids; /* Variable number (fixed maximum) of channels to scan up */ struct mwifiex_user_scan_chan chan_list[MWIFIEX_USER_SCAN_CHAN_MAX]; } __packed; diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 67422f64f9fe..fd0302fe5bd8 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -737,7 +737,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, u16 scan_dur; u8 channel; u8 radio_type; - u32 ssid_idx; + int i; u8 ssid_filter; u8 rates[MWIFIEX_SUPPORTED_RATES]; u32 rates_size; @@ -792,14 +792,8 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, user_scan_in->specific_bssid, sizeof(scan_cfg_out->specific_bssid)); - for (ssid_idx = 0; - ((ssid_idx < ARRAY_SIZE(user_scan_in->ssid_list)) - && (*user_scan_in->ssid_list[ssid_idx].ssid - || user_scan_in->ssid_list[ssid_idx].max_len)); - ssid_idx++) { - - ssid_len = strlen(user_scan_in->ssid_list[ssid_idx]. - ssid) + 1; + for (i = 0; i < user_scan_in->num_ssids; i++) { + ssid_len = user_scan_in->ssid_list[i].ssid_len; wildcard_ssid_tlv = (struct mwifiex_ie_types_wildcard_ssid_params *) @@ -810,19 +804,26 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, (u16) (ssid_len + sizeof(wildcard_ssid_tlv-> max_ssid_length))); - /* max_ssid_length = 0 tells firmware to perform - specific scan for the SSID filled */ - wildcard_ssid_tlv->max_ssid_length = 0; + /* + * max_ssid_length = 0 tells firmware to perform + * specific scan for the SSID filled, whereas + * max_ssid_length = IEEE80211_MAX_SSID_LEN is for + * wildcard scan. + */ + if (ssid_len) + wildcard_ssid_tlv->max_ssid_length = 0; + else + wildcard_ssid_tlv->max_ssid_length = + IEEE80211_MAX_SSID_LEN; memcpy(wildcard_ssid_tlv->ssid, - user_scan_in->ssid_list[ssid_idx].ssid, - ssid_len); + user_scan_in->ssid_list[i].ssid, ssid_len); tlv_pos += (sizeof(wildcard_ssid_tlv->header) + le16_to_cpu(wildcard_ssid_tlv->header.len)); - dev_dbg(adapter->dev, "info: scan: ssid_list[%d]: %s, %d\n", - ssid_idx, wildcard_ssid_tlv->ssid, + dev_dbg(adapter->dev, "info: scan: ssid[%d]: %s, %d\n", + i, wildcard_ssid_tlv->ssid, wildcard_ssid_tlv->max_ssid_length); /* Empty wildcard ssid with a maxlen will match many or @@ -831,7 +832,6 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, filtered. */ if (!ssid_len && wildcard_ssid_tlv->max_ssid_length) ssid_filter = false; - } /* @@ -840,7 +840,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, * truncate scan results. That is not an issue with an SSID * or BSSID filter applied to the scan results in the firmware. */ - if ((ssid_idx && ssid_filter) + if ((i && ssid_filter) || memcmp(scan_cfg_out->specific_bssid, &zero_mac, sizeof(zero_mac))) *filtered_scan = true; @@ -1876,8 +1876,8 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv, return -ENOMEM; } - memcpy(scan_cfg->ssid_list[0].ssid, req_ssid->ssid, - req_ssid->ssid_len); + scan_cfg->ssid_list = req_ssid; + scan_cfg->num_ssids = 1; ret = mwifiex_scan_networks(priv, scan_cfg); -- GitLab From 3d045a54488b69b0024309b18da5024c036c3152 Mon Sep 17 00:00:00 2001 From: Chun-Yeow Yeoh Date: Tue, 28 Feb 2012 22:00:06 +0800 Subject: [PATCH 1346/1846] mac80211: Fix the generation of PREQs in proactive RANN mechanism of HWMP According to Section Y.7.4 Actions on receipt of proactive RANN, an individually addressed PREQ should be generated towards the neighbor peer mesh STA indicated in the RANN Sender Address field in the forwarding information. Signed-off-by: Chun-Yeow Yeoh Signed-off-by: Javier Cardona Signed-off-by: Thomas Pedersen Signed-off-by: John W. Linville --- net/mac80211/mesh.h | 4 ++++ net/mac80211/mesh_hwmp.c | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index c7e5c49471e5..8d53b71378e3 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -85,6 +85,8 @@ enum mesh_deferred_task_flags { * @state_lock: mesh path state lock used to protect changes to the * mpath itself. No need to take this lock when adding or removing * an mpath to a hash bucket on a path table. + * @rann_snd_addr: the RANN sender address + * @is_root: the destination station of this path is a root node * @is_gate: the destination station of this path is a mesh gate * * @@ -109,6 +111,8 @@ struct mesh_path { u8 discovery_retries; enum mesh_path_flags flags; spinlock_t state_lock; + u8 rann_snd_addr[ETH_ALEN]; + bool is_root; bool is_gate; }; diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 31bc762f209d..639db14f43d2 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -513,8 +513,9 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, u8 *preq_elem, u32 metric) { struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; - struct mesh_path *mpath; + struct mesh_path *mpath = NULL; u8 *target_addr, *orig_addr; + const u8 *da; u8 target_flags, ttl; u32 orig_sn, target_sn, lifetime; bool reply = false; @@ -591,9 +592,11 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, flags = PREQ_IE_FLAGS(preq_elem); preq_id = PREQ_IE_PREQ_ID(preq_elem); hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; + da = (mpath && mpath->is_root) ? + mpath->rann_snd_addr : broadcast_addr; mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, cpu_to_le32(orig_sn), target_flags, target_addr, - cpu_to_le32(target_sn), broadcast_addr, + cpu_to_le32(target_sn), da, hopcount, ttl, cpu_to_le32(lifetime), cpu_to_le32(metric), cpu_to_le32(preq_id), sdata); @@ -742,8 +745,8 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) return; - mhwmp_dbg("received RANN from %pM (is_gate=%d)", orig_addr, - root_is_gate); + mhwmp_dbg("received RANN from %pM via neighbour %pM (is_gate=%d)", + orig_addr, mgmt->sa, root_is_gate); rcu_read_lock(); mpath = mesh_path_lookup(orig_addr, sdata); @@ -774,6 +777,11 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, 0, sdata); mpath->sn = orig_sn; } + + /* Using individually addressed PREQ for root node */ + memcpy(mpath->rann_snd_addr, mgmt->sa, ETH_ALEN); + mpath->is_root = true; + if (root_is_gate) mesh_path_add_gate(mpath); @@ -909,6 +917,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) struct mesh_preq_queue *preq_node; struct mesh_path *mpath; u8 ttl, target_flags; + const u8 *da; u32 lifetime; spin_lock_bh(&ifmsh->mesh_preq_queue_lock); @@ -971,9 +980,10 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) target_flags = MP_F_RF; spin_unlock_bh(&mpath->state_lock); + da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, - cpu_to_le32(mpath->sn), broadcast_addr, 0, + cpu_to_le32(mpath->sn), da, 0, ttl, cpu_to_le32(lifetime), 0, cpu_to_le32(ifmsh->preq_id++), sdata); mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); -- GitLab From d53c74e5a124b0aaed7e9b5c462d1806aad54757 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 28 Feb 2012 20:54:43 +0530 Subject: [PATCH 1347/1846] ath9k: completely zero intialize valid_phy_rate_idx its better to zero initialize the 'valid_phy_rate_idx' array completely Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/rc.c | 2 +- drivers/net/wireless/ath/ath9k/rc.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index b8c6c38cbb98..6407af22f7b9 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -1226,7 +1226,7 @@ static void ath_rc_init(struct ath_softc *sc, ath_rc_init_valid_rate_idx(ath_rc_priv); for (i = 0; i < WLAN_RC_PHY_MAX; i++) { - for (j = 0; j < MAX_TX_RATE_PHY; j++) + for (j = 0; j < RATE_TABLE_SIZE; j++) ath_rc_priv->valid_phy_rateidx[i][j] = 0; ath_rc_priv->valid_phy_ratecnt[i] = 0; } diff --git a/drivers/net/wireless/ath/ath9k/rc.h b/drivers/net/wireless/ath/ath9k/rc.h index b7a4bcd3eec7..75f8e9b06b28 100644 --- a/drivers/net/wireless/ath/ath9k/rc.h +++ b/drivers/net/wireless/ath/ath9k/rc.h @@ -25,8 +25,6 @@ struct ath_softc; #define ATH_RATE_MAX 30 #define RATE_TABLE_SIZE 72 -#define MAX_TX_RATE_PHY 48 - #define RC_INVALID 0x0000 #define RC_LEGACY 0x0001 -- GitLab From 6a01f0c08d20a2b1356c1cb90ef97a0dc412b64c Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 28 Feb 2012 20:54:44 +0530 Subject: [PATCH 1348/1846] ath9k: make use of list_for_each_entry_safe this does the same thing as the previous code Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 7e1a91af1497..4633f513a80b 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -169,22 +169,17 @@ static void ath_rx_addbuffer_edma(struct ath_softc *sc, enum ath9k_rx_qtype qtype, int size) { struct ath_common *common = ath9k_hw_common(sc->sc_ah); - u32 nbuf = 0; + struct ath_buf *bf, *tbf; if (list_empty(&sc->rx.rxbuf)) { ath_dbg(common, QUEUE, "No free rx buf available\n"); return; } - while (!list_empty(&sc->rx.rxbuf)) { - nbuf++; - + list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) if (!ath_rx_edma_buf_link(sc, qtype)) break; - if (nbuf >= size) - break; - } } static void ath_rx_remove_buffer(struct ath_softc *sc, -- GitLab From 5809802180b2b638762465cbad3f51a9ac8ff0b3 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Feb 2012 20:45:06 +0100 Subject: [PATCH 1349/1846] b43: prevent firmware on bcm5354 from taking over wrong GPIO pins When using the bcm5354 (Soc with integrated LP-PHY Wifi) with a recent firmware >= 478.104 it runs out of memory after a very short time in OpenWrt after doing an active scan or any thing else where packages are send. This was cased by a gpio misconfiguration, the firmware triggered the GPIO pins used for buttons on some devices and that caused an other driver (OpenWrt diag) listening for these buttons irqs to send many messages to the user space. This patch fixes the bug for my devices (Asus WL-520GU) and makes it work with firmware 666.2. Now the firmware just uses LED GPIO pin number 1 and not the button pins any more. This is the GPIO Pin layout used on my device, see [0]. GPIO pin layout: pin# name type 0 power led 1 wlan led 2 reset button 3 ses buttom This is the nvram configuration output of "nvram show |grep gpio" related nvram configuration: wl0gpio2=11 wl0gpio3=11 wl0gpio0=11 wl0gpio1=0x02 reset_gpio=2 [0]: https://dev.openwrt.org/browser/trunk/package/broadcom-diag/src/diag.c Signed-off-by: Hauke Mehrtens Signed-off-by: John W. Linville --- drivers/net/wireless/b43/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 5189cf38123a..1d633f3b3274 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -2706,6 +2706,8 @@ static int b43_gpio_init(struct b43_wldev *dev) mask |= 0x0060; set |= 0x0060; } + if (dev->dev->chip_id == 0x5354) + set &= 0xff02; if (0 /* FIXME: conditional unknown */ ) { b43_write16(dev, B43_MMIO_GPIO_MASK, b43_read16(dev, B43_MMIO_GPIO_MASK) -- GitLab From 5533513784a88049e19dd2ab380a452b61e5171e Mon Sep 17 00:00:00 2001 From: Ashok Nagarajan Date: Tue, 28 Feb 2012 17:04:08 -0800 Subject: [PATCH 1350/1846] {nl,cfg,mac}80211: Implement RSSI threshold for mesh peering Mesh peer links are established only if average rssi of the peer candidate satisfies the threshold. This is not in 802.11s specification but was requested by David Fulgham, an open80211s user. This is a way to avoid marginal peer links with stations that are barely within range. This patch adds a new mesh configuration parameter, mesh_rssi_threshold. This feature is supported only for hardwares that report signal in dBm. Signed-off-by: Ashok Nagarajan Signed-off-by: Javier Cardona Signed-off-by: John W. Linville --- include/linux/nl80211.h | 5 +++++ include/net/cfg80211.h | 1 + net/mac80211/cfg.c | 8 ++++++++ net/mac80211/debugfs_netdev.c | 2 ++ net/mac80211/mesh_plink.c | 16 +++++++++++++++- net/wireless/mesh.c | 3 +++ net/wireless/nl80211.c | 5 +++++ 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index be35a68746a7..38fda5ee57f5 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -2112,6 +2112,10 @@ enum nl80211_mntr_flags { * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding * or forwarding entity (default is TRUE - forwarding entity) * + * @NL80211_MESHCONF_RSSI_THRESHOLD: RSSI threshold in dBm. This specifies the + * threshold for average signal strength of candidate station to establish + * a peer link. + * * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute * * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use @@ -2137,6 +2141,7 @@ enum nl80211_meshconf_params { NL80211_MESHCONF_GATE_ANNOUNCEMENTS, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, NL80211_MESHCONF_FORWARDING, + NL80211_MESHCONF_RSSI_THRESHOLD, /* keep last */ __NL80211_MESHCONF_ATTR_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 0178c7489373..b4e015c90885 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -809,6 +809,7 @@ struct mesh_config { * Still keeping the same nomenclature to be in sync with the spec. */ bool dot11MeshGateAnnouncementProtocol; bool dot11MeshForwarding; + s32 rssi_threshold; }; /** diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 6a77d4c910f9..ab31cc56a2fb 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1314,6 +1314,14 @@ static int ieee80211_update_mesh_config(struct wiphy *wiphy, } if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) conf->dot11MeshForwarding = nconf->dot11MeshForwarding; + if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) { + /* our RSSI threshold implementation is supported only for + * devices that report signal in dBm. + */ + if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)) + return -ENOTSUPP; + conf->rssi_threshold = nconf->rssi_threshold; + } return 0; } diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 510ed1dab3c7..9f484d8905fd 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -443,6 +443,7 @@ IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol, IEEE80211_IF_FILE(dot11MeshHWMPRannInterval, u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC); IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC); +IEEE80211_IF_FILE(rssi_threshold, u.mesh.mshcfg.rssi_threshold, DEC); #endif @@ -581,6 +582,7 @@ static void add_mesh_config(struct ieee80211_sub_if_data *sdata) MESHPARAMS_ADD(dot11MeshHWMPRootMode); MESHPARAMS_ADD(dot11MeshHWMPRannInterval); MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol); + MESHPARAMS_ADD(rssi_threshold); #undef MESHPARAMS_ADD } #endif diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 8806e5ef8ffe..80ce52772538 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -31,6 +31,11 @@ #define dot11MeshHoldingTimeout(s) (s->u.mesh.mshcfg.dot11MeshHoldingTimeout) #define dot11MeshMaxPeerLinks(s) (s->u.mesh.mshcfg.dot11MeshMaxPeerLinks) +#define sta_meets_rssi_threshold(sta, sdata) \ + (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\ + (s8) -ewma_read(&sta->avg_signal) > \ + sdata->u.mesh.mshcfg.rssi_threshold) + enum plink_event { PLINK_UNDEFINED, OPN_ACPT, @@ -301,7 +306,8 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, if (mesh_peer_accepts_plinks(elems) && sta->plink_state == NL80211_PLINK_LISTEN && sdata->u.mesh.accepting_plinks && - sdata->u.mesh.mshcfg.auto_open_plinks) + sdata->u.mesh.mshcfg.auto_open_plinks && + sta_meets_rssi_threshold(sta, sdata)) mesh_plink_open(sta); rcu_read_unlock(); @@ -531,6 +537,14 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m return; } + if (ftype == WLAN_SP_MESH_PEERING_OPEN && + !sta_meets_rssi_threshold(sta, sdata)) { + mpl_dbg("Mesh plink: %pM does not meet rssi threshold\n", + sta->sta.addr); + rcu_read_unlock(); + return; + } + if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) { mpl_dbg("Mesh plink: Action frame from non-authed peer\n"); rcu_read_unlock(); diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index 9d3e3b6bfcf4..ba21ab22187b 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c @@ -23,6 +23,8 @@ #define MESH_PERR_MIN_INT 100 #define MESH_DIAM_TRAVERSAL_TIME 50 +#define MESH_RSSI_THRESHOLD 0 + /* * A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds * before timing out. This way it will remain ACTIVE and no data frames @@ -56,6 +58,7 @@ const struct mesh_config default_mesh_config = { .dot11MeshHWMPRannInterval = MESH_RANN_INTERVAL, .dot11MeshGateAnnouncementProtocol = false, .dot11MeshForwarding = true, + .rssi_threshold = MESH_RSSI_THRESHOLD, }; const struct mesh_setup default_mesh_setup = { diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 1998c3682774..25a470abd21d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3290,6 +3290,8 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, cur_params.dot11MeshGateAnnouncementProtocol); NLA_PUT_U8(msg, NL80211_MESHCONF_FORWARDING, cur_params.dot11MeshForwarding); + NLA_PUT_U32(msg, NL80211_MESHCONF_RSSI_THRESHOLD, + cur_params.rssi_threshold); nla_nest_end(msg, pinfoattr); genlmsg_end(msg, hdr); return genlmsg_reply(msg, info); @@ -3322,6 +3324,7 @@ static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_A [NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 }, [NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 }, [NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 }, + [NL80211_MESHCONF_RSSI_THRESHOLD] = { .type = NLA_U32}, }; static const struct nla_policy @@ -3413,6 +3416,8 @@ do {\ nla_get_u8); FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, mask, NL80211_MESHCONF_FORWARDING, nla_get_u8); + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, + mask, NL80211_MESHCONF_RSSI_THRESHOLD, nla_get_u32); if (mask_out) *mask_out = mask; -- GitLab From 41eedf39dfb145fb8fa04cd5b799f7bdc7679696 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 1 Mar 2012 10:02:08 +0300 Subject: [PATCH 1351/1846] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work() If "offset" is negative then we can get past this check: if (offset > CONTROL_BUFFER_SIZE) Or if we pick a very high "req_ie_len" then we can get around the check: if (offset + req_ie_len > CONTROL_BUFFER_SIZE) I made "resp_ie_len" and "req_ie_len" unsigned. I don't know if it was intentional that they were signed in the original. Signed-off-by: Dan Carpenter Acked-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index a330c69583d6..dde45effef14 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev) struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct ndis_80211_assoc_info *info = NULL; u8 bssid[ETH_ALEN]; - int resp_ie_len, req_ie_len; + unsigned int resp_ie_len, req_ie_len; + unsigned int offset; u8 *req_ie, *resp_ie; - int ret, offset; + int ret; bool roamed = false; bool match_bss; @@ -2785,7 +2786,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev) ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE); if (!ret) { req_ie_len = le32_to_cpu(info->req_ie_length); - if (req_ie_len > 0) { + if (req_ie_len > CONTROL_BUFFER_SIZE) + req_ie_len = CONTROL_BUFFER_SIZE; + if (req_ie_len != 0) { offset = le32_to_cpu(info->offset_req_ies); if (offset > CONTROL_BUFFER_SIZE) @@ -2799,7 +2802,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev) } resp_ie_len = le32_to_cpu(info->resp_ie_length); - if (resp_ie_len > 0) { + if (resp_ie_len > CONTROL_BUFFER_SIZE) + resp_ie_len = CONTROL_BUFFER_SIZE; + if (resp_ie_len != 0) { offset = le32_to_cpu(info->offset_resp_ies); if (offset > CONTROL_BUFFER_SIZE) -- GitLab From b26e395038a219685c7f78f3be8aeb578c4a5b60 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 29 Feb 2012 09:36:28 +0300 Subject: [PATCH 1352/1846] rndis_wlan: remove unneeded variables We never use the "len" variable. Signed-off-by: Dan Carpenter Acked-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index dde45effef14..1bde2eb54255 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1790,9 +1790,8 @@ static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev, struct cfg80211_pmksa *pmksa, int max_pmkids) { - int i, len, count, newlen, err; + int i, count, newlen, err; - len = le32_to_cpu(pmkids->length); count = le32_to_cpu(pmkids->bssid_info_count); if (count > max_pmkids) @@ -1831,9 +1830,8 @@ static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev, struct cfg80211_pmksa *pmksa, int max_pmkids) { - int i, err, len, count, newlen; + int i, err, count, newlen; - len = le32_to_cpu(pmkids->length); count = le32_to_cpu(pmkids->bssid_info_count); if (count > max_pmkids) -- GitLab From 551d6fe6cb67ea6f7ca4425a5085b05d34f39730 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 29 Feb 2012 09:36:57 +0300 Subject: [PATCH 1353/1846] rndis_wlan: make some variables unsigned These variables can never be less than zero because we cap them in get_device_pmkids(). Let's make them unsigned here because it's simpler to not have to worry about negative numbers when we read the code. Signed-off-by: Dan Carpenter Acked-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 1bde2eb54255..454f2f182342 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1790,7 +1790,8 @@ static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev, struct cfg80211_pmksa *pmksa, int max_pmkids) { - int i, count, newlen, err; + int i, newlen, err; + unsigned int count; count = le32_to_cpu(pmkids->bssid_info_count); @@ -1830,7 +1831,8 @@ static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev, struct cfg80211_pmksa *pmksa, int max_pmkids) { - int i, err, count, newlen; + int i, err, newlen; + unsigned int count; count = le32_to_cpu(pmkids->bssid_info_count); -- GitLab From e4e02da2ef01deb36aa80fce6ee0bc3e9725ffe8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 29 Feb 2012 09:37:53 +0300 Subject: [PATCH 1354/1846] rndis_wlan: prevent integer overflow in indication() If we pick a high value for "offset" then it could lead to an integer overflow and we would get past the check for: if (offset + len > buflen) { ... Signed-off-by: Dan Carpenter Acked-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 454f2f182342..ce138d846193 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -3043,7 +3043,7 @@ static void rndis_wlan_media_specific_indication(struct usbnet *usbdev, struct rndis_indicate *msg, int buflen) { struct ndis_80211_status_indication *indication; - int len, offset; + unsigned int len, offset; offset = offsetof(struct rndis_indicate, status) + le32_to_cpu(msg->offset); @@ -3055,7 +3055,7 @@ static void rndis_wlan_media_specific_indication(struct usbnet *usbdev, return; } - if (offset + len > buflen) { + if (len > buflen || offset > buflen || offset + len > buflen) { netdev_info(usbdev->net, "media specific indication, too large to fit to buffer (%i > %i)\n", offset + len, buflen); return; -- GitLab From f808e4ad05704d4ba0082fbb27640294c6fa4eae Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Wed, 29 Feb 2012 16:24:54 +0200 Subject: [PATCH 1355/1846] rndis_wlan: fix le16/le32_to_cpu mix up with config.beacon_period 'beacon_period' in 'struct ndis_80211_conf' is __le32 instead of __le16 so le32_to_cpu must be used instead of le16_to_cpu. Also correct 'beacon_interval' variables used for passing this value forward from u16 to u32 and rename those variables 'beacon_period' This is to avoid confusion because 'beacon_interval' is defined as __le16 at other structure, 'struct ndis_80211_fixed_ies'. Reported-by: Dan Carpenter Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index ce138d846193..c831c1f2bd07 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1350,7 +1350,7 @@ static int set_channel(struct usbnet *usbdev, int channel) } static struct ieee80211_channel *get_current_channel(struct usbnet *usbdev, - u16 *beacon_interval) + u32 *beacon_period) { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct ieee80211_channel *channel; @@ -1370,8 +1370,8 @@ static struct ieee80211_channel *get_current_channel(struct usbnet *usbdev, if (!channel) return NULL; - if (beacon_interval) - *beacon_interval = le16_to_cpu(config.beacon_period); + if (beacon_period) + *beacon_period = le32_to_cpu(config.beacon_period); return channel; } @@ -2683,7 +2683,7 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, s32 signal; u64 timestamp; u16 capability; - u16 beacon_interval = 0; + u32 beacon_period = 0; __le32 rssi; u8 ie_buf[34]; int len, ret, ie_len; @@ -2708,7 +2708,7 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, } /* Get channel and beacon interval */ - channel = get_current_channel(usbdev, &beacon_interval); + channel = get_current_channel(usbdev, &beacon_period); if (!channel) { netdev_warn(usbdev->net, "%s(): could not get channel.\n", __func__); @@ -2738,11 +2738,11 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, netdev_dbg(usbdev->net, "%s(): channel:%d(freq), bssid:[%pM], tsf:%d, " "capa:%x, beacon int:%d, resp_ie(len:%d, essid:'%.32s'), " "signal:%d\n", __func__, (channel ? channel->center_freq : -1), - bssid, (u32)timestamp, capability, beacon_interval, ie_len, + bssid, (u32)timestamp, capability, beacon_period, ie_len, ssid.essid, signal); bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, - timestamp, capability, beacon_interval, ie_buf, ie_len, + timestamp, capability, beacon_period, ie_buf, ie_len, signal, GFP_KERNEL); cfg80211_put_bss(bss); } -- GitLab From f096ce6d244a380a78e19a7d7a25d9a4a6a6c9b7 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Wed, 29 Feb 2012 16:25:00 +0200 Subject: [PATCH 1356/1846] rndis_wlan: use RNDIS_WLAN_NUM_KEYS for all key index checks Use new RNDIS_WLAN_NUM_KEYS for checks in add_wep_key() and add_wpa_key(). Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index c831c1f2bd07..0e238400b046 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1387,13 +1387,15 @@ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len, netdev_dbg(usbdev->net, "%s(idx: %d, len: %d)\n", __func__, index, key_len); - if ((key_len != 5 && key_len != 13) || index < 0 || index > 3) + if (index < 0 || index >= RNDIS_WLAN_NUM_KEYS) return -EINVAL; if (key_len == 5) cipher = WLAN_CIPHER_SUITE_WEP40; - else + else if (key_len == 13) cipher = WLAN_CIPHER_SUITE_WEP104; + else + return -EINVAL; memset(&ndis_key, 0, sizeof(ndis_key)); @@ -1436,7 +1438,7 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len, bool is_addr_ok; int ret; - if (index < 0 || index >= 4) { + if (index < 0 || index >= RNDIS_WLAN_NUM_KEYS) { netdev_dbg(usbdev->net, "%s(): index out of range (%i)\n", __func__, index); return -EINVAL; -- GitLab From 461bc26c93f27d306a0e74cf642b33eb9d2d4112 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Wed, 29 Feb 2012 16:25:05 +0200 Subject: [PATCH 1357/1846] rndis_wlan: use u8 for key indexes cfg80211 uses u8 for key indexes and so should rndis_wlan. Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 0e238400b046..d66e2980bc27 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -518,7 +518,7 @@ struct rndis_wlan_private { __le32 current_command_oid; /* encryption stuff */ - int encr_tx_key_index; + u8 encr_tx_key_index; struct rndis_wlan_encr_key encr_keys[RNDIS_WLAN_NUM_KEYS]; int wpa_version; @@ -634,7 +634,7 @@ static u32 get_bcm4320_power_dbm(struct rndis_wlan_private *priv) } } -static bool is_wpa_key(struct rndis_wlan_private *priv, int idx) +static bool is_wpa_key(struct rndis_wlan_private *priv, u8 idx) { int cipher = priv->encr_keys[idx].cipher; @@ -1377,7 +1377,7 @@ static struct ieee80211_channel *get_current_channel(struct usbnet *usbdev, /* index must be 0 - N, as per NDIS */ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len, - int index) + u8 index) { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct ndis_80211_wep_key ndis_key; @@ -1387,7 +1387,7 @@ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len, netdev_dbg(usbdev->net, "%s(idx: %d, len: %d)\n", __func__, index, key_len); - if (index < 0 || index >= RNDIS_WLAN_NUM_KEYS) + if (index >= RNDIS_WLAN_NUM_KEYS) return -EINVAL; if (key_len == 5) @@ -1430,7 +1430,7 @@ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len, } static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len, - int index, const u8 *addr, const u8 *rx_seq, + u8 index, const u8 *addr, const u8 *rx_seq, int seq_len, u32 cipher, __le32 flags) { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); @@ -1438,7 +1438,7 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len, bool is_addr_ok; int ret; - if (index < 0 || index >= RNDIS_WLAN_NUM_KEYS) { + if (index >= RNDIS_WLAN_NUM_KEYS) { netdev_dbg(usbdev->net, "%s(): index out of range (%i)\n", __func__, index); return -EINVAL; @@ -1526,7 +1526,7 @@ static int add_wpa_key(struct usbnet *usbdev, const u8 *key, int key_len, return 0; } -static int restore_key(struct usbnet *usbdev, int key_idx) +static int restore_key(struct usbnet *usbdev, u8 key_idx) { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct rndis_wlan_encr_key key; @@ -1552,13 +1552,13 @@ static void restore_keys(struct usbnet *usbdev) restore_key(usbdev, i); } -static void clear_key(struct rndis_wlan_private *priv, int idx) +static void clear_key(struct rndis_wlan_private *priv, u8 idx) { memset(&priv->encr_keys[idx], 0, sizeof(priv->encr_keys[idx])); } /* remove_key is for both wep and wpa */ -static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid) +static int remove_key(struct usbnet *usbdev, u8 index, const u8 *bssid) { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct ndis_80211_remove_key remove_key; -- GitLab From 62ebeed8d00aef75eac4fd6c161cae75a41965ca Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Thu, 1 Mar 2012 00:40:08 +0400 Subject: [PATCH 1358/1846] p54spi: Release GPIO lines and IRQ on error in p54spi_probe This makes it possible to reload driver if insmod has failed due to missing firmware. Signed-off-by: Max Filippov Cc: stable Acked-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/p54/p54spi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c index 7faed62c6378..f7929906d437 100644 --- a/drivers/net/wireless/p54/p54spi.c +++ b/drivers/net/wireless/p54/p54spi.c @@ -618,19 +618,19 @@ static int __devinit p54spi_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { dev_err(&priv->spi->dev, "spi_setup failed"); - goto err_free_common; + goto err_free; } ret = gpio_request(p54spi_gpio_power, "p54spi power"); if (ret < 0) { dev_err(&priv->spi->dev, "power GPIO request failed: %d", ret); - goto err_free_common; + goto err_free; } ret = gpio_request(p54spi_gpio_irq, "p54spi irq"); if (ret < 0) { dev_err(&priv->spi->dev, "irq GPIO request failed: %d", ret); - goto err_free_common; + goto err_free_gpio_power; } gpio_direction_output(p54spi_gpio_power, 0); @@ -641,7 +641,7 @@ static int __devinit p54spi_probe(struct spi_device *spi) priv->spi); if (ret < 0) { dev_err(&priv->spi->dev, "request_irq() failed"); - goto err_free_common; + goto err_free_gpio_irq; } irq_set_irq_type(gpio_to_irq(p54spi_gpio_irq), IRQ_TYPE_EDGE_RISING); @@ -673,6 +673,12 @@ static int __devinit p54spi_probe(struct spi_device *spi) return 0; err_free_common: + free_irq(gpio_to_irq(p54spi_gpio_irq), spi); +err_free_gpio_irq: + gpio_free(p54spi_gpio_irq); +err_free_gpio_power: + gpio_free(p54spi_gpio_power); +err_free: p54_free_common(priv->hw); return ret; } -- GitLab From 380aeef8941c6b8a3e8de86b5ca000ca986e3b17 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 1 Mar 2012 10:22:30 +0300 Subject: [PATCH 1359/1846] mwifiex: endian bug in mwifiex_drv_change_adhoc_chan() In mwifiex_drv_change_adhoc_chan() we pass channel to mwifiex_bss_ioctl_ibss_channel() which sets the high 16 bits. This works on little endian systems but not on big endian ones. I've changed mwifiex_drv_change_adhoc_chan() to use a 16 bit variable. This matches the other functions in the file. I considered changing mwifiex_change_adhoc_chan() as well but it turns out that the function isn't implemented so I just removed the definition. Signed-off-by: Dan Carpenter Acked-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/main.h | 3 +-- drivers/net/wireless/mwifiex/sta_ioctl.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index a0bd4ebd262a..6dc116647411 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -909,10 +909,9 @@ int mwifiex_request_scan(struct mwifiex_private *priv, struct cfg80211_ssid *req_ssid); int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, struct mwifiex_user_scan_cfg *scan_req); -int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel); int mwifiex_set_radio(struct mwifiex_private *priv, u8 option); -int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel); +int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel); int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key, int key_len, u8 key_index, int disable); diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 593d285111d2..0ae1209646c1 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -609,7 +609,7 @@ static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv, * - Start/Join the IBSS */ int -mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel) +mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel) { int ret; struct mwifiex_bss_info bss_info; @@ -646,7 +646,7 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel) ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid); ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET, - (u16 *) &channel); + &channel); /* Do specific SSID scanning */ if (mwifiex_request_scan(priv, &bss_info.ssid)) { -- GitLab From 4d196e4b2ffd734393b54f351507462f19d737b5 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 1 Mar 2012 11:23:37 +0100 Subject: [PATCH 1360/1846] mac80211: use 16 bit alignment for the if_ibss bssid field Several MAC address comparison functions assume 16 bit alignment for pointers passed to them. Since the addition of the control_port field, alignment for the IBSS bssid was off by one, causing a severe performance hit on architectures without efficient unaligned access (e.g. MIPS). Signed-off-by: Felix Fietkau Acked-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ieee80211_i.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index cee0c7493fd0..c4130588b035 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -480,7 +480,7 @@ struct ieee80211_if_ibss { bool control_port; - u8 bssid[ETH_ALEN]; + u8 bssid[ETH_ALEN] __aligned(2); u8 ssid[IEEE80211_MAX_SSID_LEN]; u8 ssid_len, ie_len; u8 *ie; -- GitLab From 888d04dfbe7e09f930fdaafb257cce2c54c9c3f3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 1 Mar 2012 15:22:09 +0100 Subject: [PATCH 1361/1846] mac80211: use compare_ether_addr on MAC addresses instead of memcmp Because of the constant size and guaranteed 16 bit alignment, the inline compare_ether_addr function is much cheaper than calling memcmp. Signed-off-by: Felix Fietkau Acked-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ibss.c | 10 +++++----- net/mac80211/mesh.c | 2 +- net/mac80211/mesh_hwmp.c | 19 +++++++++++-------- net/mac80211/mesh_pathtbl.c | 14 ++++++++------ net/mac80211/mlme.c | 30 ++++++++++++++++-------------- net/mac80211/rx.c | 6 +++--- net/mac80211/scan.c | 3 ++- net/mac80211/sta_info.c | 5 +++-- net/mac80211/sta_info.h | 3 ++- net/mac80211/status.c | 3 ++- 10 files changed, 53 insertions(+), 42 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 7f9ac577600a..33fd8d9f714e 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -66,7 +66,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, skb_reset_tail_pointer(skb); skb_reserve(skb, sdata->local->hw.extra_tx_headroom); - if (memcmp(ifibss->bssid, bssid, ETH_ALEN)) + if (compare_ether_addr(ifibss->bssid, bssid)) sta_info_flush(sdata->local, sdata); /* if merging, indicate to driver that we leave the old IBSS */ @@ -403,7 +403,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, return; if (sdata->vif.type == NL80211_IFTYPE_ADHOC && - memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) { + compare_ether_addr(mgmt->bssid, sdata->u.ibss.bssid) == 0) { rcu_read_lock(); sta = sta_info_get(sdata, mgmt->sa); @@ -508,7 +508,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, goto put_bss; /* same BSSID */ - if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) + if (compare_ether_addr(cbss->bssid, sdata->u.ibss.bssid) == 0) goto put_bss; if (rx_status->flag & RX_FLAG_MACTIME_MPDU) { @@ -831,8 +831,8 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da)) return; - if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 && - memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) + if (compare_ether_addr(mgmt->bssid, ifibss->bssid) != 0 && + !is_broadcast_ether_addr(mgmt->bssid)) return; end = ((u8 *) mgmt) + len; diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index c707c8bf6d2c..e5fbb7cf3562 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -204,7 +204,7 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr, kmem_cache_free(rm_cache, p); --entries; } else if ((seqnum == p->seqnum) && - (memcmp(sa, p->sa, ETH_ALEN) == 0)) + (compare_ether_addr(sa, p->sa) == 0)) return -1; } diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 639db14f43d2..ae82ea75bc74 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "wme.h" #include "mesh.h" @@ -419,7 +420,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, new_metric = MAX_METRIC; exp_time = TU_TO_EXP_TIME(orig_lifetime); - if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) { + if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) { /* This MP is the originator, we are not interested in this * frame, except for updating transmitter's path info. */ @@ -469,7 +470,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, /* Update and check transmitter routing info */ ta = mgmt->sa; - if (memcmp(orig_addr, ta, ETH_ALEN) == 0) + if (compare_ether_addr(orig_addr, ta) == 0) fresh_info = false; else { fresh_info = true; @@ -530,7 +531,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, mhwmp_dbg("received PREQ from %pM", orig_addr); - if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) { + if (compare_ether_addr(target_addr, sdata->vif.addr) == 0) { mhwmp_dbg("PREQ is for us"); forward = false; reply = true; @@ -627,7 +628,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem)); orig_addr = PREP_IE_ORIG_ADDR(prep_elem); - if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) + if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) /* destination, no forwarding required */ return; @@ -697,10 +698,12 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, rcu_read_lock(); mpath = mesh_path_lookup(target_addr, sdata); if (mpath) { + struct sta_info *sta; + spin_lock_bh(&mpath->state_lock); + sta = next_hop_deref_protected(mpath); if (mpath->flags & MESH_PATH_ACTIVE && - memcmp(ta, next_hop_deref_protected(mpath)->sta.addr, - ETH_ALEN) == 0 && + compare_ether_addr(ta, sta->sta.addr) == 0 && (!(mpath->flags & MESH_PATH_SN_VALID) || SN_GT(target_sn, mpath->sn))) { mpath->flags &= ~MESH_PATH_ACTIVE; @@ -742,7 +745,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, metric = rann->rann_metric; /* Ignore our own RANNs */ - if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) + if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) return; mhwmp_dbg("received RANN from %pM via neighbour %pM (is_gate=%d)", @@ -1074,7 +1077,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, if (time_after(jiffies, mpath->exp_time - msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && - !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) && + !compare_ether_addr(sdata->vif.addr, hdr->addr4) && !(mpath->flags & MESH_PATH_RESOLVING) && !(mpath->flags & MESH_PATH_FIXED)) mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index dc51669e67d8..157642f780b9 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -348,7 +348,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, u8 *dst, hlist_for_each_entry_rcu(node, n, bucket, list) { mpath = node->mpath; if (mpath->sdata == sdata && - memcmp(dst, mpath->dst, ETH_ALEN) == 0) { + compare_ether_addr(dst, mpath->dst) == 0) { if (MPATH_EXPIRED(mpath)) { spin_lock_bh(&mpath->state_lock); mpath->flags &= ~MESH_PATH_ACTIVE; @@ -523,7 +523,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) int err = 0; u32 hash_idx; - if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0) + if (compare_ether_addr(dst, sdata->vif.addr) == 0) /* never add ourselves as neighbours */ return -ENOTSUPP; @@ -564,7 +564,8 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) err = -EEXIST; hlist_for_each_entry(node, n, bucket, list) { mpath = node->mpath; - if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0) + if (mpath->sdata == sdata && + compare_ether_addr(dst, mpath->dst) == 0) goto err_exists; } @@ -655,7 +656,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) int err = 0; u32 hash_idx; - if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0) + if (compare_ether_addr(dst, sdata->vif.addr) == 0) /* never add ourselves as neighbours */ return -ENOTSUPP; @@ -692,7 +693,8 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) err = -EEXIST; hlist_for_each_entry(node, n, bucket, list) { mpath = node->mpath; - if (mpath->sdata == sdata && memcmp(dst, mpath->dst, ETH_ALEN) == 0) + if (mpath->sdata == sdata && + compare_ether_addr(dst, mpath->dst) == 0) goto err_exists; } @@ -886,7 +888,7 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) hlist_for_each_entry(node, n, bucket, list) { mpath = node->mpath; if (mpath->sdata == sdata && - memcmp(addr, mpath->dst, ETH_ALEN) == 0) { + compare_ether_addr(addr, mpath->dst) == 0) { __mesh_path_del(tbl, node); goto enddel; } diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index caf97f5a2937..7190da4f2138 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1822,7 +1822,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); - if (memcmp(bssid, mgmt->bssid, ETH_ALEN)) + if (compare_ether_addr(bssid, mgmt->bssid)) return RX_MGMT_NONE; auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); @@ -1903,7 +1903,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, return RX_MGMT_NONE; if (!ifmgd->associated || - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid)) return RX_MGMT_NONE; bssid = ifmgd->associated->bssid; @@ -1936,7 +1936,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, return RX_MGMT_NONE; if (!ifmgd->associated || - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid)) return RX_MGMT_NONE; reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); @@ -2203,7 +2203,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, if (!assoc_data) return RX_MGMT_NONE; - if (memcmp(assoc_data->bss->bssid, mgmt->bssid, ETH_ALEN)) + if (compare_ether_addr(assoc_data->bss->bssid, mgmt->bssid)) return RX_MGMT_NONE; /* @@ -2291,8 +2291,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, bool need_ps = false; if (sdata->u.mgd.associated && - memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, - ETH_ALEN) == 0) { + compare_ether_addr(mgmt->bssid, sdata->u.mgd.associated->bssid) + == 0) { bss = (void *)sdata->u.mgd.associated->priv; /* not previously set so we may need to recalc */ need_ps = !bss->dtim_period; @@ -2347,7 +2347,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, ASSERT_MGD_MTX(ifmgd); - if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) + if (compare_ether_addr(mgmt->da, sdata->vif.addr)) return; /* ignore ProbeResp to foreign address */ baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; @@ -2360,11 +2360,12 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); if (ifmgd->associated && - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0) + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid) == 0) ieee80211_reset_ap_probe(sdata); if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies && - memcmp(mgmt->bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN) == 0) { + compare_ether_addr(mgmt->bssid, ifmgd->auth_data->bss->bssid) + == 0) { /* got probe response, continue with auth */ printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); ifmgd->auth_data->tries = 0; @@ -2421,7 +2422,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, return; if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && - memcmp(mgmt->bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN) == 0) { + compare_ether_addr(mgmt->bssid, ifmgd->assoc_data->bss->bssid) + == 0) { ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); @@ -2436,7 +2438,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, } if (!ifmgd->associated || - memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) + compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid)) return; bssid = ifmgd->associated->bssid; @@ -3299,7 +3301,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, bool match; /* keep sta info, bssid if matching */ - match = memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN) == 0; + match = compare_ether_addr(ifmgd->bssid, req->bss->bssid) == 0; ieee80211_destroy_auth_data(sdata, match); } @@ -3421,7 +3423,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, goto err_clear; } } else - WARN_ON_ONCE(memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN)); + WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, req->bss->bssid)); if (!bss->dtim_period && sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) { @@ -3471,7 +3473,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, sdata->name, req->bssid, req->reason_code); if (ifmgd->associated && - memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) + compare_ether_addr(ifmgd->associated->bssid, req->bssid) == 0) ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, req->reason_code, true, frame_buf); else diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 7a4ff02af261..3cf011fc97f4 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -489,12 +489,12 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) if (ieee80211_has_tods(hdr->frame_control) || !ieee80211_has_fromds(hdr->frame_control)) return RX_DROP_MONITOR; - if (memcmp(hdr->addr3, dev_addr, ETH_ALEN) == 0) + if (compare_ether_addr(hdr->addr3, dev_addr) == 0) return RX_DROP_MONITOR; } else { if (!ieee80211_has_a4(hdr->frame_control)) return RX_DROP_MONITOR; - if (memcmp(hdr->addr4, dev_addr, ETH_ALEN) == 0) + if (compare_ether_addr(hdr->addr4, dev_addr) == 0) return RX_DROP_MONITOR; } } @@ -2336,7 +2336,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) if (sdata->vif.type != NL80211_IFTYPE_STATION) break; - if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) + if (compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid)) break; goto queue; diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 9270771702fe..a9d7235df7c3 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -176,7 +177,7 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) presp = ieee80211_is_probe_resp(fc); if (presp) { /* ignore ProbeResp to foreign address */ - if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) + if (compare_ether_addr(mgmt->da, sdata->vif.addr)) return RX_DROP_MONITOR; presp = true; diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index cd0f265f42e5..38137cb5f6f0 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -101,7 +102,7 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, lockdep_is_held(&local->sta_mtx)); while (sta) { if (sta->sdata == sdata && - memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) + compare_ether_addr(sta->sta.addr, addr) == 0) break; sta = rcu_dereference_check(sta->hnext, lockdep_is_held(&local->sta_mtx)); @@ -124,7 +125,7 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, while (sta) { if ((sta->sdata == sdata || (sta->sdata->bss && sta->sdata->bss == sdata->bss)) && - memcmp(sta->sta.addr, addr, ETH_ALEN) == 0) + compare_ether_addr(sta->sta.addr, addr) == 0) break; sta = rcu_dereference_check(sta->hnext, lockdep_is_held(&local->sta_mtx)); diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 23a97c9dc042..3336d54e5558 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "key.h" /** @@ -489,7 +490,7 @@ void for_each_sta_info_type_check(struct ieee80211_local *local, nxt = _sta ? rcu_dereference(_sta->hnext) : NULL \ ) \ /* compare address and run code only if it matches */ \ - if (memcmp(_sta->sta.addr, (_addr), ETH_ALEN) == 0) + if (compare_ether_addr(_sta->sta.addr, (_addr)) == 0) /* * Get STA info by index, BROKEN! diff --git a/net/mac80211/status.c b/net/mac80211/status.c index c928e4a4effd..5f8f89e89d6b 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include "ieee80211_i.h" @@ -377,7 +378,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) for_each_sta_info(local, hdr->addr1, sta, tmp) { /* skip wrong virtual interface */ - if (memcmp(hdr->addr2, sta->sdata->vif.addr, ETH_ALEN)) + if (compare_ether_addr(hdr->addr2, sta->sdata->vif.addr)) continue; if (info->flags & IEEE80211_TX_STATUS_EOSP) -- GitLab From c04a4ff71b6a59cb5c8deec961b9196226e89573 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 1 Mar 2012 15:28:19 +0100 Subject: [PATCH 1362/1846] cfg80211: fix kernel-doc I forgot to update the kernel-doc in my patch to redesign AP mode APIs, fix that now. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/cfg80211.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b4e015c90885..d640a39d9513 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1357,12 +1357,10 @@ struct cfg80211_gtk_rekey_data { * * @set_rekey_data: give the data necessary for GTK rekeying to the driver * - * @add_beacon: Add a beacon with given parameters, @head, @interval - * and @dtim_period will be valid, @tail is optional. - * @set_beacon: Change the beacon parameters for an access point mode - * interface. This should reject the call when no beacon has been - * configured. - * @del_beacon: Remove beacon configuration and stop sending the beacon. + * @start_ap: Start acting in AP mode defined by the parameters. + * @change_beacon: Change the beacon parameters for an access point mode + * interface. This should reject the call when AP mode wasn't started. + * @stop_ap: Stop being an AP, including stopping beaconing. * * @add_station: Add a new station. * @del_station: Remove a station; @mac may be NULL to remove all stations. -- GitLab From fe8431f89e25de722610ee5beb2892bd019d1fed Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 1 Mar 2012 18:00:07 +0100 Subject: [PATCH 1363/1846] mac80211: add an rx flag for ignoring a packet's signal strength For A-MPDU rx it makes sense to only process the signal strength once per aggregate instead of once per subframe. Additonally, some hardware (e.g. Atheros) only provides valid signal strength information for the last subframe. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- include/net/mac80211.h | 3 +++ net/mac80211/rx.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 7477f020ee7a..c06974accfa6 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -659,6 +659,8 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index * @RX_FLAG_40MHZ: HT40 (40 MHz) was used * @RX_FLAG_SHORT_GI: Short guard interval was used + * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present. + * Valid only for data frames (mainly A-MPDU) */ enum mac80211_rx_flags { RX_FLAG_MMIC_ERROR = 1<<0, @@ -672,6 +674,7 @@ enum mac80211_rx_flags { RX_FLAG_HT = 1<<9, RX_FLAG_40MHZ = 1<<10, RX_FLAG_SHORT_GI = 1<<11, + RX_FLAG_NO_SIGNAL_VAL = 1<<12, }; /** diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 3cf011fc97f4..f3b515d16f24 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -177,7 +177,8 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, pos += 2; /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ - if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { + if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM && + !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { *pos = status->signal; rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL); @@ -1309,8 +1310,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) sta->rx_fragments++; sta->rx_bytes += rx->skb->len; - sta->last_signal = status->signal; - ewma_add(&sta->avg_signal, -status->signal); + if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { + sta->last_signal = status->signal; + ewma_add(&sta->avg_signal, -status->signal); + } /* * Change STA power saving mode only at the end of a frame -- GitLab From 77a1abf54f4b003ad6e59c535045b2ad89fedfeb Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 5 Mar 2012 04:50:09 +0000 Subject: [PATCH 1364/1846] net: export netdev_stats_to_stats64 Some drivers use internal netdev stats member to store part of their stats, yet advertize ndo_get_stats64() to implement some 64bit fields. Allow them to use netdev_stats_to_stats64() helper to make the copy of netdev stats before they compute their 64bit counters. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/netdevice.h | 2 ++ net/core/dev.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f1b7d037c2c5..4d279c5287f8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2557,6 +2557,8 @@ extern void dev_load(struct net *net, const char *name); extern void dev_mcast_init(void); extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, struct rtnl_link_stats64 *storage); +extern void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, + const struct net_device_stats *netdev_stats); extern int netdev_max_backlog; extern int netdev_tstamp_prequeue; diff --git a/net/core/dev.c b/net/core/dev.c index 763a0eda7158..5ef3b65c3687 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5834,12 +5834,12 @@ void netdev_run_todo(void) /* Convert net_device_stats to rtnl_link_stats64. They have the same * fields in the same order, with only the type differing. */ -static void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, - const struct net_device_stats *netdev_stats) +void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, + const struct net_device_stats *netdev_stats) { #if BITS_PER_LONG == 64 - BUILD_BUG_ON(sizeof(*stats64) != sizeof(*netdev_stats)); - memcpy(stats64, netdev_stats, sizeof(*stats64)); + BUILD_BUG_ON(sizeof(*stats64) != sizeof(*netdev_stats)); + memcpy(stats64, netdev_stats, sizeof(*stats64)); #else size_t i, n = sizeof(*stats64) / sizeof(u64); const unsigned long *src = (const unsigned long *)netdev_stats; @@ -5851,6 +5851,7 @@ static void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, dst[i] = src[i]; #endif } +EXPORT_SYMBOL(netdev_stats_to_stats64); /** * dev_get_stats - get network device statistics -- GitLab From d665508b98d3cdbeb476e7d6848a513184a81ed0 Mon Sep 17 00:00:00 2001 From: Chun-Yeow Yeoh Date: Fri, 2 Mar 2012 02:03:19 +0800 Subject: [PATCH 1365/1846] mac80211: fix the support of setting non-forwarding entity in Mesh RANN, PREP and PERR propagation should happen only if the dot11MeshForwarding is true. Besides, data frame should not be forwarded if dot11MeshForwarding is false. This redundant checking is necessary to avoid the broadcasted ARP breaking the non-forwarding rule. Signed-off-by: Chun-Yeow Yeoh Signed-off-by: John W. Linville --- net/mac80211/mesh_hwmp.c | 9 ++++++++- net/mac80211/rx.c | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index ae82ea75bc74..4a993f2d1ae1 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -619,6 +619,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, u8 *prep_elem, u32 metric) { + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; struct mesh_path *mpath; u8 *target_addr, *orig_addr; u8 ttl, hopcount, flags; @@ -632,6 +633,9 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, /* destination, no forwarding required */ return; + if (!ifmsh->mshcfg.dot11MeshForwarding) + return; + ttl = PREP_IE_TTL(prep_elem); if (ttl <= 1) { sdata->u.mesh.mshstats.dropped_frames_ttl++; @@ -709,12 +713,15 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, mpath->flags &= ~MESH_PATH_ACTIVE; mpath->sn = target_sn; spin_unlock_bh(&mpath->state_lock); + if (!ifmsh->mshcfg.dot11MeshForwarding) + goto endperr; mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), cpu_to_le16(target_rcode), broadcast_addr, sdata); } else spin_unlock_bh(&mpath->state_lock); } +endperr: rcu_read_unlock(); } @@ -771,7 +778,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); } - if (mpath->sn < orig_sn) { + if (mpath->sn < orig_sn && ifmsh->mshcfg.dot11MeshForwarding) { mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, cpu_to_le32(orig_sn), 0, NULL, 0, broadcast_addr, diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index f3b515d16f24..c8166adcd600 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1960,6 +1960,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) return RX_DROP_MONITOR; } + if (!ifmsh->mshcfg.dot11MeshForwarding) + goto out; + fwd_skb = skb_copy(skb, GFP_ATOMIC); if (!fwd_skb) { if (net_ratelimit()) -- GitLab From 1b658f118b11de3c4052ed8cbdd5803cd1fa5670 Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Fri, 2 Mar 2012 15:50:02 +0530 Subject: [PATCH 1366/1846] cfg80211: Add an attribute to set inactivity timeout in AP mode This patch adds an attribute, NL80211_ATTR_INACTIVITY_TIMEOUT, to set the inactivity timeout which can be used to remove the station in AP mode. This can be passed in NL80211_CMD_START_AP and used by the drivers which have AP MLME in firmware but don't support get_station() properly. To disable inactivity timer in userspace, wpa_s for example, there is a new flag, NL80211_FEATURE_INACTIVITY_TIMER, in nl80211_feature_flags through which drivers can register their capability to use the inactivity timeout to free the stations. Signed-off-by: Vasanthakumar Thiagarajan Acked-by: Johannes Berg Signed-off-by: John W. Linville --- include/linux/nl80211.h | 15 +++++++++++++-- include/net/cfg80211.h | 2 ++ net/wireless/nl80211.c | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 38fda5ee57f5..9f46c62b1eee 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -168,8 +168,8 @@ * %NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID, * %NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE, * %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS, - * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY and - * %NL80211_ATTR_AUTH_TYPE. + * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY, + * %NL80211_ATTR_AUTH_TYPE and %NL80211_ATTR_INACTIVITY_TIMEOUT. * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP @@ -1197,6 +1197,12 @@ enum nl80211_commands { * @NL80211_ATTR_NOACK_MAP: This u16 bitmap contains the No Ack Policy of * up to 16 TIDs. * + * @NL80211_ATTR_INACTIVITY_TIMEOUT: timeout value in seconds, this can be + * used by the drivers which has MLME in firmware and does not have support + * to report per station tx/rx activity to free up the staion entry from + * the list. This needs to be used when the driver advertises the + * capability to timeout the stations. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1442,6 +1448,8 @@ enum nl80211_attrs { NL80211_ATTR_NOACK_MAP, + NL80211_ATTR_INACTIVITY_TIMEOUT, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -2809,10 +2817,13 @@ enum nl80211_ap_sme_features { * TX status to the socket error queue when requested with the * socket option. * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates. + * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up + * the connected inactive stations in AP mode. */ enum nl80211_feature_flags { NL80211_FEATURE_SK_TX_STATUS = 1 << 0, NL80211_FEATURE_HT_IBSS = 1 << 1, + NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2, }; /** diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index d640a39d9513..804805827736 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -413,6 +413,7 @@ struct cfg80211_beacon_data { * @crypto: crypto settings * @privacy: the BSS uses privacy * @auth_type: Authentication type (algorithm) + * @inactivity_timeout: time in seconds to determine station's inactivity. */ struct cfg80211_ap_settings { struct cfg80211_beacon_data beacon; @@ -424,6 +425,7 @@ struct cfg80211_ap_settings { struct cfg80211_crypto_settings crypto; bool privacy; enum nl80211_auth_type auth_type; + int inactivity_timeout; }; /** diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 25a470abd21d..4b6afc338aac 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -204,6 +204,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { .len = NL80211_HT_CAPABILITY_LEN }, [NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 }, + [NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 }, }; /* policy for the key attributes */ @@ -2214,6 +2215,13 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) if (err) return err; + if (info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]) { + if (!(rdev->wiphy.features & NL80211_FEATURE_INACTIVITY_TIMER)) + return -EOPNOTSUPP; + params.inactivity_timeout = nla_get_u16( + info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]); + } + err = rdev->ops->start_ap(&rdev->wiphy, dev, ¶ms); if (!err) wdev->beacon_interval = params.beacon_interval; -- GitLab From 293702a3fb75832613e2af097bdc3ac8ef775b33 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Mar 2012 13:18:19 +0100 Subject: [PATCH 1367/1846] mac80211: use common radiotap code for cooked monitors There's no need to hardcode a subset of the radiotap header for cooked monitor receive, we can just reuse the normal monitor mode radiotap code. This simplifies the code and extends the information available on cooked monitor interfaces. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/rx.c | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index c8166adcd600..10bbbd33b314 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -228,7 +228,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, { struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(origskb); struct ieee80211_sub_if_data *sdata; - int needed_headroom = 0; + int needed_headroom; struct sk_buff *skb, *skb2; struct net_device *prev_dev = NULL; int present_fcs_len = 0; @@ -2544,16 +2544,10 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, { struct ieee80211_sub_if_data *sdata; struct ieee80211_local *local = rx->local; - struct ieee80211_rtap_hdr { - struct ieee80211_radiotap_header hdr; - u8 flags; - u8 rate_or_pad; - __le16 chan_freq; - __le16 chan_flags; - } __packed *rthdr; struct sk_buff *skb = rx->skb, *skb2; struct net_device *prev_dev = NULL; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); + int needed_headroom; /* * If cooked monitor has been processed already, then @@ -2567,30 +2561,15 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, if (!local->cooked_mntrs) goto out_free_skb; - if (skb_headroom(skb) < sizeof(*rthdr) && - pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) - goto out_free_skb; - - rthdr = (void *)skb_push(skb, sizeof(*rthdr)); - memset(rthdr, 0, sizeof(*rthdr)); - rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); - rthdr->hdr.it_present = - cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | - (1 << IEEE80211_RADIOTAP_CHANNEL)); + /* room for the radiotap header based on driver features */ + needed_headroom = ieee80211_rx_radiotap_len(local, status); - if (rate) { - rthdr->rate_or_pad = rate->bitrate / 5; - rthdr->hdr.it_present |= - cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE); - } - rthdr->chan_freq = cpu_to_le16(status->freq); + if (skb_headroom(skb) < needed_headroom && + pskb_expand_head(skb, needed_headroom, 0, GFP_ATOMIC)) + goto out_free_skb; - if (status->band == IEEE80211_BAND_5GHZ) - rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_OFDM | - IEEE80211_CHAN_5GHZ); - else - rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_DYN | - IEEE80211_CHAN_2GHZ); + /* prepend radiotap information */ + ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom); skb_set_mac_header(skb, 0); skb->ip_summed = CHECKSUM_UNNECESSARY; -- GitLab From 3abead59fcdeb56df8b83288a2f5edbe6423b0bb Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Mar 2012 15:56:59 +0100 Subject: [PATCH 1368/1846] mac80211: combine QoS with other BSS changes When associating and particularly when disassociating there's no need to notify the driver about changes with multiple calls to bss_info_changed, we should combine the QoS enabling/disabling into the same call as otherwise the driver could get confused about QoS suddenly getting disabled while connected. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/iface.c | 2 +- net/mac80211/mlme.c | 12 ++++++++---- net/mac80211/util.c | 9 ++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index c4130588b035..24cb1080e238 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1348,7 +1348,8 @@ int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int keyidx, struct ieee80211_hdr *hdr, const u8 *tsc, gfp_t gfp); -void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata); +void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, + bool bss_notify); void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 620ca8d2ad42..401c01f0731e 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -304,7 +304,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up) * need to initialise the hardware if the hardware * doesn't start up with sane defaults */ - ieee80211_set_wmm_default(sdata); + ieee80211_set_wmm_default(sdata, true); } set_bit(SDATA_STATE_RUNNING, &sdata->state); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 7190da4f2138..92c5eb124d6f 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1277,7 +1277,6 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, /* enable WMM or activate new settings */ sdata->vif.bss_conf.qos = true; - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS); } static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, @@ -1455,8 +1454,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, changed |= BSS_CHANGED_ASSOC; sdata->vif.bss_conf.assoc = false; - ieee80211_set_wmm_default(sdata); - /* channel(_type) changes are handled by ieee80211_hw_config */ WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT)); @@ -1484,10 +1481,16 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, changed |= BSS_CHANGED_ARP_FILTER; } + sdata->vif.bss_conf.qos = false; + changed |= BSS_CHANGED_QOS; + /* The BSSID (not really interesting) and HT changed */ changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; ieee80211_bss_info_change_notify(sdata, changed); + /* disassociated - set to defaults now */ + ieee80211_set_wmm_default(sdata, false); + del_timer_sync(&sdata->u.mgd.conn_mon_timer); del_timer_sync(&sdata->u.mgd.bcn_mon_timer); del_timer_sync(&sdata->u.mgd.timer); @@ -2155,7 +2158,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, elems.wmm_param_len); else - ieee80211_set_wmm_default(sdata); + ieee80211_set_wmm_default(sdata, false); + changed |= BSS_CHANGED_QOS; if (elems.ht_info_elem && elems.wmm_param && (sdata->local->hw.queues >= 4) && diff --git a/net/mac80211/util.c b/net/mac80211/util.c index f6e4cef92021..0a5ad95ac8b0 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -737,7 +737,8 @@ void ieee802_11_parse_elems(u8 *start, size_t len, ieee802_11_parse_elems_crc(start, len, elems, 0, 0); } -void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata) +void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, + bool bss_notify) { struct ieee80211_local *local = sdata->local; struct ieee80211_tx_queue_params qparam; @@ -807,7 +808,9 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata) if (sdata->vif.type != NL80211_IFTYPE_MONITOR) { sdata->vif.bss_conf.qos = sdata->vif.type != NL80211_IFTYPE_STATION; - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS); + if (bss_notify) + ieee80211_bss_info_change_notify(sdata, + BSS_CHANGED_QOS); } } @@ -829,7 +832,7 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, else sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; - ieee80211_set_wmm_default(sdata); + ieee80211_set_wmm_default(sdata, true); } u32 ieee80211_mandatory_rates(struct ieee80211_local *local, -- GitLab From 48de1a17fc41613b7e9d61037fa989256d04234f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 2 Mar 2012 13:21:22 -0600 Subject: [PATCH 1369/1846] rtlwifi: Detect misread of end-point count In the unlikely event of a misread of the USB end point count, the driver generates a divide fault. To prevent this, add a check of the value returned by _rtl_usb_init(). In addition, add some logging to indicate why the condition occurred. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/usb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index ffcf89fe45e4..b0eee0eb5679 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -346,9 +346,14 @@ static int _rtl_usb_init(struct ieee80211_hw *hw) pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize, pep_desc->bInterval); } - if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num) - return -EINVAL ; - + if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num) { + pr_err("Too few input end points found\n"); + return -EINVAL; + } + if (rtlusb->out_ep_nums == 0) { + pr_err("No output end points found\n"); + return -EINVAL; + } /* usb endpoint mapping */ err = rtlpriv->cfg->usb_interface_cfg->usb_endpoint_mapping(hw); rtlusb->usb_mq_to_hwq = rtlpriv->cfg->usb_interface_cfg->usb_mq_to_hwq; @@ -976,6 +981,8 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, } rtlpriv->cfg->ops->init_sw_leds(hw); err = _rtl_usb_init(hw); + if (err) + goto error_out; err = _rtl_usb_init_sw(hw); /* Init mac80211 sw */ err = rtl_init_core(hw); -- GitLab From 8f526ab4aa1b145bda2baf56e223050c7ef3e1b0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 2 Mar 2012 13:22:46 -0600 Subject: [PATCH 1370/1846] rtlwifi: Remove extraneous value return In usb.c, routine _rtl_usb_init_sw() always returns 0, and rtl_usb_probe() never checks the returned value. Thus we can change _rtl_usb_init_sw() to a void routine. In addition, remove the underscore at the beginning of the name of the routine. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/usb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index b0eee0eb5679..2e1e352864bb 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -362,7 +362,7 @@ static int _rtl_usb_init(struct ieee80211_hw *hw) return err; } -static int _rtl_usb_init_sw(struct ieee80211_hw *hw) +static void rtl_usb_init_sw(struct ieee80211_hw *hw) { struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); @@ -397,7 +397,6 @@ static int _rtl_usb_init_sw(struct ieee80211_hw *hw) /* HIMR_EX - turn all on */ rtlusb->irq_mask[1] = 0xFFFFFFFF; rtlusb->disableHWSM = true; - return 0; } #define __RADIO_TAP_SIZE_RSV 32 @@ -983,7 +982,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf, err = _rtl_usb_init(hw); if (err) goto error_out; - err = _rtl_usb_init_sw(hw); + rtl_usb_init_sw(hw); /* Init mac80211 sw */ err = rtl_init_core(hw); if (err) { -- GitLab From ebecdcc12fed5d3c81853dea61a0a78a5aefab52 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 2 Mar 2012 15:23:36 -0600 Subject: [PATCH 1371/1846] rtlwifi: rtl8192c: Prevent sleeping from invalid context in rtl8192cu When driver rtl8192cu is used with the debug level set to 3 or greater, the result is "sleeping function called from invalid context" due to an rcu_read_lock() call in the DM refresh routine in driver rtl8192c. This lock is not necessary as the USB driver does not use the struct being protected, thus the lock is set only when a PCI interface is active. This bug is reported in https://bugzilla.kernel.org/show_bug.cgi?id=42775. Reported-by: Ronald Wahl Tested-by: Ronald Wahl Signed-off-by: Larry Finger Cc: Stable Cc: Ronald Wahl Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index cb5535cf3ae2..8646ff2a55ce 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -1201,13 +1201,18 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw) "PreState = %d, CurState = %d\n", p_ra->pre_ratr_state, p_ra->ratr_state); - rcu_read_lock(); - sta = ieee80211_find_sta(mac->vif, mac->bssid); + /* Only the PCI card uses sta in the update rate table + * callback routine */ + if (rtlhal->interface == INTF_PCI) { + rcu_read_lock(); + sta = ieee80211_find_sta(mac->vif, mac->bssid); + } rtlpriv->cfg->ops->update_rate_tbl(hw, sta, p_ra->ratr_state); p_ra->pre_ratr_state = p_ra->ratr_state; - rcu_read_unlock(); + if (rtlhal->interface == INTF_PCI) + rcu_read_unlock(); } } } -- GitLab From 3bc7e29c984ffda0b6133c2b34233023ff36f370 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:45 +0100 Subject: [PATCH 1372/1846] brcm80211: fmac: remove unnecessary NULL pointer check In brcmf_usb_up() the variable devinfo was checked for being a NULL pointer, but this can not happen. Also the check was done after dereferencing the pointer. This patch removes the check. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Kan Yan Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index d4a9e8e7deb3..8616961a066e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -712,9 +712,6 @@ static int brcmf_usb_up(struct device *dev) struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); u16 ifnum; - if (devinfo == NULL) - return -EINVAL; - if (devinfo->bus_pub.state == BCMFMAC_USB_STATE_UP) return 0; -- GitLab From ac94f196a5fed4915b82d71b9b111867d78df992 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:46 +0100 Subject: [PATCH 1373/1846] brcm80211: fmac: remove brcmf_usb_attrib structure Several fields in this structure are only written once or not used at all. Remaining two fields have been moved and brcmf_usb_attrib definition has been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Kan Yan Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 17 +++++++++-------- drivers/net/wireless/brcm80211/brcmfmac/usb.h | 16 ++-------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 8616961a066e..0418a40fce8d 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -897,8 +897,8 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) sizeof(struct bootrom_id_le)); return false; } else { - devinfo->bus_pub.attrib.devid = chipid; - devinfo->bus_pub.attrib.chiprev = chiprev; + devinfo->bus_pub.devid = chipid; + devinfo->bus_pub.chiprev = chiprev; } return true; } @@ -1064,7 +1064,7 @@ static int brcmf_usb_dlstart(struct brcmf_usbdev_info *devinfo, u8 *fw, int len) if (devinfo == NULL) return -EINVAL; - if (devinfo->bus_pub.attrib.devid == 0xDEAD) + if (devinfo->bus_pub.devid == 0xDEAD) return -EINVAL; err = brcmf_usb_dl_writeimage(devinfo, fw, len); @@ -1085,7 +1085,7 @@ static int brcmf_usb_dlrun(struct brcmf_usbdev_info *devinfo) if (!devinfo) return -EINVAL; - if (devinfo->bus_pub.attrib.devid == 0xDEAD) + if (devinfo->bus_pub.devid == 0xDEAD) return -EINVAL; /* Check we are runnable */ @@ -1124,18 +1124,19 @@ static bool brcmf_usb_chip_support(int chipid, int chiprev) static int brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo) { - struct brcmf_usb_attrib *attr; + int devid, chiprev; int err; brcmf_dbg(TRACE, "enter\n"); if (devinfo == NULL) return -ENODEV; - attr = &devinfo->bus_pub.attrib; + devid = devinfo->bus_pub.devid; + chiprev = devinfo->bus_pub.chiprev; - if (!brcmf_usb_chip_support(attr->devid, attr->chiprev)) { + if (!brcmf_usb_chip_support(devid, chiprev)) { brcmf_dbg(ERROR, "unsupported chip %d rev %d\n", - attr->devid, attr->chiprev); + devid, chiprev); return -EINVAL; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.h b/drivers/net/wireless/brcm80211/brcmfmac/usb.h index b31da7b83ff7..3377d63e6c8b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.h @@ -50,19 +50,6 @@ struct brcmf_stats { }; -struct brcmf_usb_attrib { - int bustype; - int vid; - int pid; - int devid; - int chiprev; /* chip revsion number */ - int mtu; - int nchan; /* Data Channels */ - int has_2nd_bulk_in_ep; -}; - -struct brcmf_usbdev_info; - struct brcmf_usbdev { struct brcmf_bus *bus; struct brcmf_usbdev_info *devinfo; @@ -70,7 +57,8 @@ struct brcmf_usbdev { struct brcmf_stats stats; int ntxq, nrxq, rxsize; u32 bus_mtu; - struct brcmf_usb_attrib attrib; + int devid; + int chiprev; /* chip revsion number */ }; /* IO Request Block (IRB) */ -- GitLab From 1d9c1796bc448d76429e0937ef69e4f29cd1adad Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:47 +0100 Subject: [PATCH 1374/1846] brcm80211: fmac: use counters in brcmf_bus structure The usb code defines a structure for counting statistics. However, it should use the statistics entry provided in brcmf_bus as that is exposed to the net_device. The usb private statistics counter only remains with counters for control packets between driver and usb device. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 8 ++++---- drivers/net/wireless/brcm80211/brcmfmac/usb.h | 11 ----------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 0418a40fce8d..a2a0c45201ac 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -514,9 +514,9 @@ static void brcmf_usb_tx_complete(struct urb *urb) brcmf_usb_del_fromq(devinfo, req); if (urb->status == 0) - devinfo->bus_pub.stats.tx_packets++; + devinfo->bus_pub.bus->dstats.tx_packets++; else - devinfo->bus_pub.stats.tx_errors++; + devinfo->bus_pub.bus->dstats.tx_errors++; dev_kfree_skb(req->skb); req->skb = NULL; @@ -536,9 +536,9 @@ static void brcmf_usb_rx_complete(struct urb *urb) req->skb = NULL; if (urb->status == 0) { - devinfo->bus_pub.stats.rx_packets++; + devinfo->bus_pub.bus->dstats.rx_packets++; } else { - devinfo->bus_pub.stats.rx_errors++; + devinfo->bus_pub.bus->dstats.rx_errors++; dev_kfree_skb(skb); brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req); return; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.h b/drivers/net/wireless/brcm80211/brcmfmac/usb.h index 3377d63e6c8b..acfa5e89872f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.h @@ -33,21 +33,10 @@ enum brcmf_usb_pnp_state { }; struct brcmf_stats { - u32 tx_errors; - u32 tx_packets; - u32 tx_multicast; u32 tx_ctlpkts; u32 tx_ctlerrs; - u32 tx_dropped; - u32 tx_flushed; - u32 rx_errors; - u32 rx_packets; - u32 rx_multicast; u32 rx_ctlpkts; u32 rx_ctlerrs; - u32 rx_dropped; - u32 rx_flushed; - }; struct brcmf_usbdev { -- GitLab From 549040abbc03e87bdee2964fea5e4c827471d4df Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:48 +0100 Subject: [PATCH 1375/1846] brcm80211: fmac: initialize host interface drivers regardless result The module init function of brcmfmac calls init functions for SDIO and USB doing driver registration. This patch removes terminating the module init when a driver registration for one host interface fails. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 4 +--- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 4 ++-- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 14 +++----------- drivers/net/wireless/brcm80211/brcmfmac/usb.c | 4 ++-- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 83ca3cc2cccb..4688904908ec 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -604,7 +604,7 @@ void brcmf_sdio_exit(void) sdio_unregister_driver(&brcmf_sdmmc_driver); } -int brcmf_sdio_init(void) +void brcmf_sdio_init(void) { int ret; @@ -614,6 +614,4 @@ int brcmf_sdio_init(void) if (ret) brcmf_dbg(ERROR, "sdio_register_driver failed: %d\n", ret); - - return ret; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index b7671b30692f..366916494be4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -108,11 +108,11 @@ extern int brcmf_add_if(struct device *dev, int ifidx, #ifdef CONFIG_BRCMFMAC_SDIO extern void brcmf_sdio_exit(void); -extern int brcmf_sdio_init(void); +extern void brcmf_sdio_init(void); #endif #ifdef CONFIG_BRCMFMAC_USB extern void brcmf_usb_exit(void); -extern int brcmf_usb_init(void); +extern void brcmf_usb_init(void); #endif #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 c4da05817443..e7345569e9de 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1183,21 +1183,13 @@ int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size) static int __init brcmfmac_init(void) { - int ret = 0; - #ifdef CONFIG_BRCMFMAC_SDIO - ret = brcmf_sdio_init(); - if (ret) - goto fail; + brcmf_sdio_init(); #endif #ifdef CONFIG_BRCMFMAC_USB - ret = brcmf_usb_init(); - if (ret) - goto fail; + brcmf_usb_init(); #endif - -fail: - return ret; + return 0; } static void __exit brcmfmac_exit(void) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index a2a0c45201ac..82364223e817 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c @@ -1615,7 +1615,7 @@ void brcmf_usb_exit(void) g_image.len = 0; } -int brcmf_usb_init(void) +void brcmf_usb_init(void) { - return usb_register(&brcmf_usbdrvr); + usb_register(&brcmf_usbdrvr); } -- GitLab From e64a4b708fd5b719b54f7f969895b66bcba71486 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:49 +0100 Subject: [PATCH 1376/1846] brcm80211: fmac: remove firmware requests from init_module syscall As indicated in [1] on netdev mailing list drivers should not block on the init_module() syscall. This patch defers the actual driver registration to a workqueue so the init_module() syscall can complete without delay. [1] http://article.gmane.org/gmane.linux.network/217729/ Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../wireless/brcm80211/brcmfmac/dhd_linux.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index e7345569e9de..2a1e5ae0c402 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1181,7 +1181,7 @@ int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size) } #endif /* DEBUG */ -static int __init brcmfmac_init(void) +static void brcmf_driver_init(struct work_struct *work) { #ifdef CONFIG_BRCMFMAC_SDIO brcmf_sdio_init(); @@ -1189,11 +1189,21 @@ static int __init brcmfmac_init(void) #ifdef CONFIG_BRCMFMAC_USB brcmf_usb_init(); #endif +} +static DECLARE_WORK(brcmf_driver_work, brcmf_driver_init); + +static int __init brcmfmac_module_init(void) +{ + if (!schedule_work(&brcmf_driver_work)) + return -EBUSY; + return 0; } -static void __exit brcmfmac_exit(void) +static void __exit brcmfmac_module_exit(void) { + cancel_work_sync(&brcmf_driver_work); + #ifdef CONFIG_BRCMFMAC_SDIO brcmf_sdio_exit(); #endif @@ -1202,5 +1212,5 @@ static void __exit brcmfmac_exit(void) #endif } -module_init(brcmfmac_init); -module_exit(brcmfmac_exit); +module_init(brcmfmac_module_init); +module_exit(brcmfmac_module_exit); -- GitLab From b0c359b2f68e982ac9334a5f2c04c3a67dee4d50 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:50 +0100 Subject: [PATCH 1377/1846] brcm80211: smac: remove firmware requests from init_module syscall As indicated in [1] on netdev mailing list drivers should not block on the init_module() syscall. This patch defers the actual driver registration to a workqueue so the init_module() syscall can complete without delay. [1] http://article.gmane.org/gmane.linux.network/217729/ Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../wireless/brcm80211/brcmsmac/mac80211_if.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index fec0f10773e5..569ab8abd2a1 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1169,25 +1169,31 @@ static struct bcma_driver brcms_bcma_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. - * + * This function is scheduled upon module initialization and + * does the driver registration, which result in brcms_bcma_probe() + * call resulting in the driver bringup. */ -static int __init brcms_module_init(void) +static void brcms_driver_init(struct work_struct *work) { - int error = -ENODEV; + int error; + error = bcma_driver_register(&brcms_bcma_driver); + if (error) + pr_err("%s: register returned %d\n", __func__, error); +} + +static DECLARE_WORK(brcms_driver_work, brcms_driver_init); + +static int __init brcms_module_init(void) +{ #ifdef DEBUG if (msglevel != 0xdeadbeef) brcm_msg_level = msglevel; -#endif /* DEBUG */ - - error = bcma_driver_register(&brcms_bcma_driver); - pr_err("%s: register returned %d\n", __func__, error); - if (!error) - return 0; +#endif + if (!schedule_work(&brcms_driver_work)) + return -EBUSY; - return error; + return 0; } /** @@ -1199,6 +1205,7 @@ static int __init brcms_module_init(void) */ static void __exit brcms_module_exit(void) { + cancel_work_sync(&brcms_driver_work); bcma_driver_unregister(&brcms_bcma_driver); } -- GitLab From 769009b89d8c29c410a99eee3cd63764b1fff869 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Fri, 2 Mar 2012 22:55:51 +0100 Subject: [PATCH 1378/1846] brcm80211: smac: cleanup couple of debug output statements Tidying up some debug statements in brcms_c_ampdu_dotxstatus_complete() that got broken strings to satisfy checkpatch, but the rules changed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmsmac/ampdu.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index dbee69620a90..95b5902bc4b3 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c @@ -959,14 +959,13 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, if (supr_status) { update_rate = false; if (supr_status == TX_STATUS_SUPR_BADCH) { - wiphy_err(wiphy, "%s: Pkt tx suppressed, " - "illegal channel possibly %d\n", + wiphy_err(wiphy, + "%s: Pkt tx suppressed, illegal channel possibly %d\n", __func__, CHSPEC_CHANNEL( wlc->default_bss->chanspec)); } else { if (supr_status != TX_STATUS_SUPR_FRAG) - wiphy_err(wiphy, "%s:" - "supr_status 0x%x\n", + wiphy_err(wiphy, "%s: supr_status 0x%x\n", __func__, supr_status); } /* no need to retry for badch; will fail again */ @@ -988,9 +987,8 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, } } else if (txs->phyerr) { update_rate = false; - wiphy_err(wiphy, "wl%d: ampdu tx phy " - "error (0x%x)\n", wlc->pub->unit, - txs->phyerr); + wiphy_err(wiphy, "%s: ampdu tx phy error (0x%x)\n", + __func__, txs->phyerr); if (brcm_msg_level & LOG_ERROR_VAL) { brcmu_prpkt("txpkt (AMPDU)", p); @@ -1018,10 +1016,10 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, ack_recd = false; if (ba_recd) { bindex = MODSUB_POW2(seq, start_seq, SEQNUM_MAX); - BCMMSG(wlc->wiphy, "tid %d seq %d," - " start_seq %d, bindex %d set %d, index %d\n", - tid, seq, start_seq, bindex, - isset(bitmap, bindex), index); + BCMMSG(wiphy, + "tid %d seq %d, start_seq %d, bindex %d set %d, index %d\n", + tid, seq, start_seq, bindex, + isset(bitmap, bindex), index); /* if acked then clear bit and free packet */ if ((bindex < AMPDU_TX_BA_MAX_WSIZE) && isset(bitmap, bindex)) { -- GitLab From 18f973af3e7028620186d1c1ace044506bb6229e Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 5 Mar 2012 05:01:14 +0000 Subject: [PATCH 1379/1846] mlx4_en: remove sparse errors Fix new sparse errors introduced in commit 6221217199 (mlx4_en: dont change mac_header on xmit) Reported-by: Or Gerlitz Signed-off-by: Eric Dumazet Cc: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 2fd51405a509..50b3fa5212ed 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -686,8 +686,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) /* Copy dst mac address to wqe */ ethh = (struct ethhdr *)skb->data; - tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((u16 *)ethh->h_dest); - tx_desc->ctrl.imm = get_unaligned((u32 *)(ethh->h_dest + 2)); + tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest); + tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2)); /* Handle LSO (TSO) packets */ if (lso_header_size) { /* Mark opcode as LSO */ -- GitLab From 8027aa245bbd125350f6a78c5a78771d143aba55 Mon Sep 17 00:00:00 2001 From: Junchang Wang Date: Sun, 4 Mar 2012 23:30:32 +0100 Subject: [PATCH 1380/1846] r8169: add 64bit statistics. Switch to use ndo_get_stats64 to get 64bit statistics. Two sync entries are used (one for Rx and one for Tx). Signed-off-by: Junchang Wang Reviewed-by: Eric Dumazet Signed-off-by: Francois Romieu --- drivers/net/ethernet/realtek/r8169.c | 59 +++++++++++++++++++++------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index fbd855bcd9f0..a4d7674886a2 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -675,6 +675,12 @@ enum rtl_flag { RTL_FLAG_MAX }; +struct rtl8169_stats { + u64 packets; + u64 bytes; + struct u64_stats_sync syncp; +}; + struct rtl8169_private { void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; @@ -687,6 +693,8 @@ struct rtl8169_private { u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */ u32 dirty_rx; u32 dirty_tx; + struct rtl8169_stats rx_stats; + struct rtl8169_stats tx_stats; struct TxDesc *TxDescArray; /* 256-aligned Tx descriptor ring */ struct RxDesc *RxDescArray; /* 256-aligned Rx descriptor ring */ dma_addr_t TxPhyAddr; @@ -775,7 +783,9 @@ static void rtl_hw_start(struct net_device *dev); static int rtl8169_close(struct net_device *dev); static void rtl_set_rx_mode(struct net_device *dev); static void rtl8169_tx_timeout(struct net_device *dev); -static struct net_device_stats *rtl8169_get_stats(struct net_device *dev); +static struct rtnl_link_stats64 *rtl8169_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 + *stats); static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); static void rtl8169_rx_clear(struct rtl8169_private *tp); static int rtl8169_poll(struct napi_struct *napi, int budget); @@ -3521,7 +3531,7 @@ static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp) static const struct net_device_ops rtl8169_netdev_ops = { .ndo_open = rtl8169_open, .ndo_stop = rtl8169_close, - .ndo_get_stats = rtl8169_get_stats, + .ndo_get_stats64 = rtl8169_get_stats64, .ndo_start_xmit = rtl8169_start_xmit, .ndo_tx_timeout = rtl8169_tx_timeout, .ndo_validate_addr = eth_validate_addr, @@ -5658,8 +5668,10 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb, tp->TxDescArray + entry); if (status & LastFrag) { - dev->stats.tx_packets++; - dev->stats.tx_bytes += tx_skb->skb->len; + u64_stats_update_begin(&tp->tx_stats.syncp); + tp->tx_stats.packets++; + tp->tx_stats.bytes += tx_skb->skb->len; + u64_stats_update_end(&tp->tx_stats.syncp); dev_kfree_skb(tx_skb->skb); tx_skb->skb = NULL; } @@ -5807,8 +5819,10 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget napi_gro_receive(&tp->napi, skb); - dev->stats.rx_bytes += pkt_size; - dev->stats.rx_packets++; + u64_stats_update_begin(&tp->rx_stats.syncp); + tp->rx_stats.packets++; + tp->rx_stats.bytes += pkt_size; + u64_stats_update_end(&tp->rx_stats.syncp); } /* Work around for AMD plateform. */ @@ -6069,21 +6083,38 @@ static void rtl_set_rx_mode(struct net_device *dev) RTL_W32(RxConfig, tmp); } -/** - * rtl8169_get_stats - Get rtl8169 read/write statistics - * @dev: The Ethernet Device to get statistics for - * - * Get TX/RX statistics for rtl8169 - */ -static struct net_device_stats *rtl8169_get_stats(struct net_device *dev) +static struct rtnl_link_stats64 * +rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { struct rtl8169_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; + unsigned int start; if (netif_running(dev)) rtl8169_rx_missed(dev, ioaddr); - return &dev->stats; + do { + start = u64_stats_fetch_begin_bh(&tp->rx_stats.syncp); + stats->rx_packets = tp->rx_stats.packets; + stats->rx_bytes = tp->rx_stats.bytes; + } while (u64_stats_fetch_retry_bh(&tp->rx_stats.syncp, start)); + + + do { + start = u64_stats_fetch_begin_bh(&tp->tx_stats.syncp); + stats->tx_packets = tp->tx_stats.packets; + stats->tx_bytes = tp->tx_stats.bytes; + } while (u64_stats_fetch_retry_bh(&tp->tx_stats.syncp, start)); + + stats->rx_dropped = dev->stats.rx_dropped; + stats->tx_dropped = dev->stats.tx_dropped; + stats->rx_length_errors = dev->stats.rx_length_errors; + stats->rx_errors = dev->stats.rx_errors; + stats->rx_crc_errors = dev->stats.rx_crc_errors; + stats->rx_fifo_errors = dev->stats.rx_fifo_errors; + stats->rx_missed_errors = dev->stats.rx_missed_errors; + + return stats; } static void rtl8169_net_suspend(struct net_device *dev) -- GitLab From 036dafa28da1e2565a8529de2ae663c37b7a0060 Mon Sep 17 00:00:00 2001 From: Igor Maravic Date: Mon, 5 Mar 2012 00:01:25 +0100 Subject: [PATCH 1381/1846] r8169: add byte queue limit support. Nothing fancy: - sent bytes count is notified in the start_xmit path right before updating the owner bit in the hardware Tx descriptor (E. Dumazet) - avoid useless tp->dev dereferencing in start_xmit (E. Dumazet) Use of netdev_reset_queue is favored over proper accounting in rtl8169_tx_clear_range since the latter would need more work for the same result (nb: said accounting degenerates to nothing in xmit_frags). Signed-off-by: Igor Maravic Signed-off-by: Francois Romieu Acked-by: Eric Dumazet --- drivers/net/ethernet/realtek/r8169.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index a4d7674886a2..515a7edb605c 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5399,6 +5399,7 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp) { rtl8169_tx_clear_range(tp, tp->dirty_tx, NUM_TX_DESC); tp->cur_tx = tp->dirty_tx = 0; + netdev_reset_queue(tp->dev); } static void rtl_reset_work(struct rtl8169_private *tp) @@ -5553,6 +5554,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, txd->opts2 = cpu_to_le32(opts[1]); + netdev_sent_queue(dev, skb->len); + wmb(); /* Anti gcc 2.95.3 bugware (sic) */ @@ -5647,9 +5650,16 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); } +struct rtl_txc { + int packets; + int bytes; +}; + static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) { + struct rtl8169_stats *tx_stats = &tp->tx_stats; unsigned int dirty_tx, tx_left; + struct rtl_txc txc = { 0, 0 }; dirty_tx = tp->dirty_tx; smp_rmb(); @@ -5668,17 +5678,24 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp) rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb, tp->TxDescArray + entry); if (status & LastFrag) { - u64_stats_update_begin(&tp->tx_stats.syncp); - tp->tx_stats.packets++; - tp->tx_stats.bytes += tx_skb->skb->len; - u64_stats_update_end(&tp->tx_stats.syncp); - dev_kfree_skb(tx_skb->skb); + struct sk_buff *skb = tx_skb->skb; + + txc.packets++; + txc.bytes += skb->len; + dev_kfree_skb(skb); tx_skb->skb = NULL; } dirty_tx++; tx_left--; } + u64_stats_update_begin(&tx_stats->syncp); + tx_stats->packets += txc.packets; + tx_stats->bytes += txc.bytes; + u64_stats_update_end(&tx_stats->syncp); + + netdev_completed_queue(dev, txc.packets, txc.bytes); + if (tp->dirty_tx != dirty_tx) { tp->dirty_tx = dirty_tx; /* Sync with rtl8169_start_xmit: -- GitLab From 0a4eaeeb993658a4d6cff054a863241f32d3d2fb Mon Sep 17 00:00:00 2001 From: "James M. Leddy" Date: Tue, 6 Mar 2012 02:41:33 +0200 Subject: [PATCH 1382/1846] Bluetooth: btusb: add support for BCM20702A0 [0a5c:21e6] Add another vendor specific ID for BCM20702A0. This has been tested and works on hardware with this device. output of usb-devices: T: Bus=01 Lev=02 Prnt=02 Port=03 Cnt=04 Dev#= 6 Spd=12 MxCh= 0 D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0a5c ProdID=21e6 Rev=01.12 S: Manufacturer=Broadcom Corp S: Product=BCM20702A0 S: SerialNumber=D0DF9AFB227B C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none) I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none) I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none) Signed-off-by: James M. Leddy Acked-by: Marcel Holtmann Signed-off-by: Andrew Morton Signed-off-by: Johan Hedberg --- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index c5606ef91761..22f695e2b730 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -102,6 +102,7 @@ static struct usb_device_id btusb_table[] = { /* Broadcom BCM20702A0 */ { USB_DEVICE(0x0a5c, 0x21e3) }, + { USB_DEVICE(0x0a5c, 0x21e6) }, { USB_DEVICE(0x0a5c, 0x21f3) }, { USB_DEVICE(0x413c, 0x8197) }, -- GitLab From 9184a22701ed257974e7950be11da4cbd3116c63 Mon Sep 17 00:00:00 2001 From: Junchang Wang Date: Mon, 5 Mar 2012 17:13:05 +0000 Subject: [PATCH 1383/1846] 8139too: Add 64bit statistics Switch to use ndo_get_stats64 to get 64bit statistics. Two sync entries are used (one for Rx and one for Tx). Signed-off-by: Junchang Wang Signed-off-by: David S. Miller --- drivers/net/ethernet/realtek/8139too.c | 46 +++++++++++++++++++++----- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index abd6aca70e9b..df7fd8d083dc 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c @@ -565,6 +565,12 @@ struct rtl_extra_stats { unsigned long rx_lost_in_ring; }; +struct rtl8139_stats { + u64 packets; + u64 bytes; + struct u64_stats_sync syncp; +}; + struct rtl8139_private { void __iomem *mmio_addr; int drv_flags; @@ -575,11 +581,13 @@ struct rtl8139_private { unsigned char *rx_ring; unsigned int cur_rx; /* RX buf index of next pkt */ + struct rtl8139_stats rx_stats; dma_addr_t rx_ring_dma; unsigned int tx_flag; unsigned long cur_tx; unsigned long dirty_tx; + struct rtl8139_stats tx_stats; unsigned char *tx_buf[NUM_TX_DESC]; /* Tx bounce buffers */ unsigned char *tx_bufs; /* Tx bounce buffer region. */ dma_addr_t tx_bufs_dma; @@ -641,7 +649,9 @@ static int rtl8139_poll(struct napi_struct *napi, int budget); static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance); static int rtl8139_close (struct net_device *dev); static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); -static struct net_device_stats *rtl8139_get_stats (struct net_device *dev); +static struct rtnl_link_stats64 *rtl8139_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 + *stats); static void rtl8139_set_rx_mode (struct net_device *dev); static void __set_rx_mode (struct net_device *dev); static void rtl8139_hw_start (struct net_device *dev); @@ -937,7 +947,7 @@ static int rtl8139_set_features(struct net_device *dev, netdev_features_t featur static const struct net_device_ops rtl8139_netdev_ops = { .ndo_open = rtl8139_open, .ndo_stop = rtl8139_close, - .ndo_get_stats = rtl8139_get_stats, + .ndo_get_stats64 = rtl8139_get_stats64, .ndo_change_mtu = eth_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = rtl8139_set_mac_address, @@ -1807,8 +1817,10 @@ static void rtl8139_tx_interrupt (struct net_device *dev, dev->stats.tx_fifo_errors++; } dev->stats.collisions += (txstatus >> 24) & 15; - dev->stats.tx_bytes += txstatus & 0x7ff; - dev->stats.tx_packets++; + u64_stats_update_begin(&tp->tx_stats.syncp); + tp->tx_stats.packets++; + tp->tx_stats.bytes += txstatus & 0x7ff; + u64_stats_update_end(&tp->tx_stats.syncp); } dirty_tx++; @@ -2050,8 +2062,10 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp, skb->protocol = eth_type_trans (skb, dev); - dev->stats.rx_bytes += pkt_size; - dev->stats.rx_packets++; + u64_stats_update_begin(&tp->rx_stats.syncp); + tp->rx_stats.packets++; + tp->rx_stats.bytes += pkt_size; + u64_stats_update_end(&tp->rx_stats.syncp); netif_receive_skb (skb); } else { @@ -2515,11 +2529,13 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } -static struct net_device_stats *rtl8139_get_stats (struct net_device *dev) +static struct rtnl_link_stats64 * +rtl8139_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { struct rtl8139_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; unsigned long flags; + unsigned int start; if (netif_running(dev)) { spin_lock_irqsave (&tp->lock, flags); @@ -2528,7 +2544,21 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev) spin_unlock_irqrestore (&tp->lock, flags); } - return &dev->stats; + netdev_stats_to_stats64(stats, &dev->stats); + + do { + start = u64_stats_fetch_begin_bh(&tp->rx_stats.syncp); + stats->rx_packets = tp->rx_stats.packets; + stats->rx_bytes = tp->rx_stats.bytes; + } while (u64_stats_fetch_retry_bh(&tp->rx_stats.syncp, start)); + + do { + start = u64_stats_fetch_begin_bh(&tp->tx_stats.syncp); + stats->tx_packets = tp->tx_stats.packets; + stats->tx_bytes = tp->tx_stats.bytes; + } while (u64_stats_fetch_retry_bh(&tp->tx_stats.syncp, start)); + + return stats; } /* Set or clear the multicast filter for this adaptor. -- GitLab From 068a4633bf42501db3ec934beff07cd50c1b7e9d Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Tue, 6 Mar 2012 14:39:40 +0530 Subject: [PATCH 1384/1846] ath6kl: Fix kernel panic while receiving fwlog during boot "ath6kl: Defer wiphy and netdev registration till the end of ath6kl_core_init()" causes kernel panic by accessing the unallocated debug resources during boot time. To fix this, split the debug initialization funtion into two, one initializes the debug resource and the other takes care of debugfs initialization. When this issue shows up the kernel crash dump would look like ath6kl_debug_fwlog_event+0x9c/0x10a [] register_lock_class+0x57/0x288 [] ? trace_hardirqs_on+0xb/0xd [] ? ath6kl_debug_fwlog_event+0x9c/0x10a [] __lock_acquire+0x96/0xbe5 [] ? alarmtimer_suspend+0x80/0x127 [] ? vprintk+0x394/0x3b1 [] ? ath6kl_debug_fwlog_event+0x9c/0x10a [] lock_acquire+0xda/0xf9 [] ? ath6kl_debug_fwlog_event+0x9c/0x10a [] _raw_spin_lock+0x28/0x58 [] ? ath6kl_debug_fwlog_event+0x9c/0x10a [] ath6kl_debug_fwlog_event+0x9c/0x10a [] ath6kl_wmi_control_rx+0x69d/0xb50 [ath6kl_core] [] ? ath6kl_rx+0x3c/0x839 [ath6kl_core] [] ath6kl_rx+0xb8/0x839 [ath6kl_core] [] ? local_clock+0x2d/0x4e [] ? _local_bh_enable_ip+0x94/0x98 [] ? ath6kl_alloc_amsdu_rxbuf+0xb7/0xb7 [] ath6kl_htc_rxmsg_pending_handler+0x891/0x988 [ath6kl_core] [] ? ath6kl_refill_amsdu_rxbufs+0x89/0x92 [] ? aggr_timeout+0xed/0xed [ath6kl_core] [] ? ath6kl_alloc_amsdu_rxbuf+0xb7/0xb7 [] ? ath6kl_tx_complete+0x376/0x376 [ath6kl_core] [] ath6kl_hif_intr_bh_handler+0xf7/0x33e [] ? mmc_host_disable+0x15/0x3a [] ath6kl_sdio_irq_handler+0x3c/0x90 [ath6kl_sdio] [] sdio_irq_thread+0xb6/0x29c [] ? sdio_claim_irq+0x1cb/0x1cb [] kthread+0x67/0x6c [] ? __init_kthread_worker+0x42/0x42 [] kernel_thread_helper+0x6/0xd BUG: unable to handle kernel NULL pointer dereference at EIP: [] ath6kl_debug_fwlog_event+0xa7/0x10a kvalo: rename new function to ath6kl_debug_init_fs() and add a comment why it's needed Reported-by: Kalle Valo Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.c | 9 +++++---- drivers/net/wireless/ath/ath6kl/debug.c | 10 +++++++++- drivers/net/wireless/ath/ath6kl/debug.h | 9 +++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index e66cf4399b61..84dd9786622f 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -124,6 +124,8 @@ int ath6kl_core_init(struct ath6kl *ar) set_bit(FIRST_BOOT, &ar->flag); + ath6kl_debug_init(ar); + ret = ath6kl_init_hw_start(ar); if (ret) { ath6kl_err("Failed to start hardware: %d\n", ret); @@ -138,7 +140,7 @@ int ath6kl_core_init(struct ath6kl *ar) if (ret) goto err_rxbuf_cleanup; - ret = ath6kl_debug_init(ar); + ret = ath6kl_debug_init_fs(ar); if (ret) { wiphy_unregister(ar->wiphy); goto err_rxbuf_cleanup; @@ -159,7 +161,7 @@ int ath6kl_core_init(struct ath6kl *ar) ath6kl_err("Failed to instantiate a network device\n"); ret = -ENOMEM; wiphy_unregister(ar->wiphy); - goto err_debug_init; + goto err_rxbuf_cleanup; } ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", @@ -167,9 +169,8 @@ int ath6kl_core_init(struct ath6kl *ar) return ret; -err_debug_init: - ath6kl_debug_cleanup(ar); err_rxbuf_cleanup: + ath6kl_debug_cleanup(ar); ath6kl_htc_flush_rx_buf(ar->htc_target); ath6kl_cleanup_amsdu_rxbufs(ar); ath6kl_wmi_shutdown(ar->wmi); diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 28b516ff3d59..645f923f79b5 100755 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1722,7 +1722,7 @@ static const struct file_operations fops_power_params = { .llseek = default_llseek, }; -int ath6kl_debug_init(struct ath6kl *ar) +void ath6kl_debug_init(struct ath6kl *ar) { skb_queue_head_init(&ar->debug.fwlog_queue); init_completion(&ar->debug.fwlog_completion); @@ -1732,7 +1732,15 @@ int ath6kl_debug_init(struct ath6kl *ar) * value from the firmware. */ ar->debug.fwlog_mask = 0; +} +/* + * Initialisation needs to happen in two stages as fwlog events can come + * before cfg80211 is initialised, and debugfs depends on cfg80211 + * initialisation. + */ +int ath6kl_debug_init_fs(struct ath6kl *ar) +{ ar->debugfs_phy = debugfs_create_dir("ath6kl", ar->wiphy->debugfsdir); if (!ar->debugfs_phy) diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index c5d5e6c8259e..1803a0baae82 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -78,7 +78,8 @@ int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf, size_t len); void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive); void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout); -int ath6kl_debug_init(struct ath6kl *ar); +void ath6kl_debug_init(struct ath6kl *ar); +int ath6kl_debug_init_fs(struct ath6kl *ar); void ath6kl_debug_cleanup(struct ath6kl *ar); #else @@ -128,7 +129,11 @@ static inline void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, { } -static inline int ath6kl_debug_init(struct ath6kl *ar) +static inline void ath6kl_debug_init(struct ath6kl *ar) +{ +} + +static inline int ath6kl_debug_init_fs(struct ath6kl *ar) { return 0; } -- GitLab From 2c61c8a787fc3382edefd8c7ad3e0f74c81e5302 Mon Sep 17 00:00:00 2001 From: Robert Stonehouse Date: Fri, 2 Mar 2012 17:20:00 +0000 Subject: [PATCH 1385/1846] sfc: Fix calculation of vf_i in map_vi_index() This was broken during refactoring to use efx_vf_size(). [bwh: Keep using efx_vf_size()] Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/siena_sriov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c index 80976e84eee6..9cb3b84ecae9 100644 --- a/drivers/net/ethernet/sfc/siena_sriov.c +++ b/drivers/net/ethernet/sfc/siena_sriov.c @@ -514,7 +514,7 @@ static bool map_vi_index(struct efx_nic *efx, unsigned abs_index, if (abs_index < EFX_VI_BASE) return true; - vf_i = (abs_index - EFX_VI_BASE) * efx_vf_size(efx); + vf_i = (abs_index - EFX_VI_BASE) / efx_vf_size(efx); if (vf_i >= efx->vf_init_count) return true; -- GitLab From bdca71ede7356e4a5838724a0a40be63ac549641 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 24 Feb 2012 21:29:40 +0000 Subject: [PATCH 1386/1846] sfc: Remove redundant function efx_nic_has_mc() This function is now used in only one place, where it always returns true. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/nic.h | 4 ---- drivers/net/ethernet/sfc/siena.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 246c4140453c..ac12f7f7f35b 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -35,10 +35,6 @@ static inline int efx_nic_rev(struct efx_nic *efx) extern u32 efx_nic_fpga_ver(struct efx_nic *efx); -static inline bool efx_nic_has_mc(struct efx_nic *efx) -{ - return efx_nic_rev(efx) >= EFX_REV_SIENA_A0; -} /* NIC has two interlinked PCI functions for the same port. */ static inline bool efx_nic_is_dual_func(struct efx_nic *efx) { diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index 7bea79017a05..9f8d7cea3967 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c @@ -409,8 +409,7 @@ static void siena_remove_nic(struct efx_nic *efx) siena_reset_hw(efx, RESET_TYPE_ALL); /* Relinquish the device back to the BMC */ - if (efx_nic_has_mc(efx)) - efx_mcdi_drv_attach(efx, false, NULL); + efx_mcdi_drv_attach(efx, false, NULL); /* Tear down the private nic state */ kfree(efx->nic_data); -- GitLab From 61321d92fc3d89fea0a4deb83db4acb0a3dcda07 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sat, 25 Feb 2012 01:58:35 +0000 Subject: [PATCH 1387/1846] sfc: Update comments on efx_rx_packet_gro() The in-tree driver has never supported Driverlink. The rest of the comments are rather redundant, but we can usefully state what the requirements are on the buffer state. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/rx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index 1ba290d0c21c..763fa2fe1a38 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -449,10 +449,8 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, efx_rx_queue_channel(rx_queue)->n_rx_overlength++; } -/* Pass a received packet up through the generic GRO stack - * - * Handles driverlink veto, and passes the fragment up via - * the appropriate GRO method +/* Pass a received packet up through GRO. GRO can handle pages + * regardless of checksum state and skbs with a good checksum. */ static void efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf, @@ -461,7 +459,6 @@ static void efx_rx_packet_gro(struct efx_channel *channel, struct napi_struct *napi = &channel->napi_str; gro_result_t gro_result; - /* Pass the skb/page into the GRO engine */ if (rx_buf->flags & EFX_RX_BUF_PAGE) { struct efx_nic *efx = channel->efx; struct page *page = rx_buf->u.page; -- GitLab From e7bed9c8838c09518c02ea1a2ee74569836065ea Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 28 Feb 2012 18:44:13 +0000 Subject: [PATCH 1388/1846] sfc: Remove TX completions from adaptive IRQ scoring RX and TX completions on the same event queue are generally not associated with the same flows. The inclusion of TX completions in the adaptive IRQ score is more of a source of noise rather than useful feedback. Therefore, do not include them in the score, and adjust the default threshold scores down. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 4 ++-- drivers/net/ethernet/sfc/nic.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 1908ba7ca7e6..00e13ab080e6 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -163,12 +163,12 @@ static int phy_flash_cfg; module_param(phy_flash_cfg, int, 0644); MODULE_PARM_DESC(phy_flash_cfg, "Set PHYs into reflash mode initially"); -static unsigned irq_adapt_low_thresh = 10000; +static unsigned irq_adapt_low_thresh = 8000; module_param(irq_adapt_low_thresh, uint, 0644); MODULE_PARM_DESC(irq_adapt_low_thresh, "Threshold score for reducing IRQ moderation"); -static unsigned irq_adapt_high_thresh = 20000; +static unsigned irq_adapt_high_thresh = 16000; module_param(irq_adapt_high_thresh, uint, 0644); MODULE_PARM_DESC(irq_adapt_high_thresh, "Threshold score for increasing IRQ moderation"); diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 2bf4283f05fe..5da8af5e7501 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -822,7 +822,6 @@ efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event) channel, tx_ev_q_label % EFX_TXQ_TYPES); tx_packets = ((tx_ev_desc_ptr - tx_queue->read_count) & tx_queue->ptr_mask); - channel->irq_mod_score += tx_packets; efx_xmit_done(tx_queue, tx_ev_desc_ptr); } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) { /* Rewrite the FIFO write pointer */ -- GitLab From 93e5dfa59b0e26a145a8adce5c9edf50bdaef4c7 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 28 Feb 2012 20:40:53 +0000 Subject: [PATCH 1389/1846] sfc: Raise self-test timeouts IRQ latency can be ridiculously high for various reasons, so our current timeouts of 100 ms or 10 ms are too short. Change the IRQ and event tests to use polling loops starting with a delay of 1 tick and doubling that if necessary up to a maximum total delay of approximately 1 second. Raise the loopback packet RX timeout to 1 second. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/selftest.c | 65 ++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index febe2a9e6211..dc330b9d9168 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -25,6 +25,16 @@ #include "selftest.h" #include "workarounds.h" +/* IRQ latency can be enormous because: + * - All IRQs may be disabled on a CPU for a *long* time by e.g. a + * slow serial console or an old IDE driver doing error recovery + * - The PREEMPT_RT patches mostly deal with this, but also allow a + * tasklet or normal task to be given higher priority than our IRQ + * threads + * Try to avoid blaming the hardware for this. + */ +#define IRQ_TIMEOUT HZ + /* * Loopback test packet structure * @@ -77,6 +87,9 @@ struct efx_loopback_state { struct efx_loopback_payload payload; }; +/* How long to wait for all the packets to arrive (in ms) */ +#define LOOPBACK_TIMEOUT_MS 1000 + /************************************************************************** * * MII, NVRAM and register tests @@ -130,6 +143,7 @@ static int efx_test_chip(struct efx_nic *efx, struct efx_self_tests *tests) static int efx_test_interrupts(struct efx_nic *efx, struct efx_self_tests *tests) { + unsigned long timeout, wait; int cpu; netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n"); @@ -140,13 +154,18 @@ static int efx_test_interrupts(struct efx_nic *efx, smp_wmb(); efx_nic_generate_interrupt(efx); + timeout = jiffies + IRQ_TIMEOUT; + wait = 1; /* Wait for arrival of test interrupt. */ netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n"); - schedule_timeout_uninterruptible(HZ / 10); - cpu = ACCESS_ONCE(efx->last_irq_cpu); - if (cpu >= 0) - goto success; + do { + schedule_timeout_uninterruptible(wait); + cpu = ACCESS_ONCE(efx->last_irq_cpu); + if (cpu >= 0) + goto success; + wait *= 2; + } while (time_before(jiffies, timeout)); netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n"); return -ETIMEDOUT; @@ -165,29 +184,37 @@ static int efx_test_eventq_irq(struct efx_channel *channel, struct efx_nic *efx = channel->efx; unsigned int read_ptr; bool napi_ran, dma_seen, int_seen; + unsigned long timeout, wait; read_ptr = channel->eventq_read_ptr; channel->last_irq_cpu = -1; smp_wmb(); efx_nic_generate_test_event(channel); + timeout = jiffies + IRQ_TIMEOUT; + wait = 1; /* Wait for arrival of interrupt. NAPI processing may or may * not complete in time, but we can cope in any case. */ - msleep(10); - napi_disable(&channel->napi_str); - if (channel->eventq_read_ptr != read_ptr) { - napi_ran = true; - dma_seen = true; - int_seen = true; - } else { - napi_ran = false; - dma_seen = efx_nic_event_present(channel); - int_seen = ACCESS_ONCE(channel->last_irq_cpu) >= 0; - } - napi_enable(&channel->napi_str); - efx_nic_eventq_read_ack(channel); + do { + schedule_timeout_uninterruptible(wait); + + napi_disable(&channel->napi_str); + if (channel->eventq_read_ptr != read_ptr) { + napi_ran = true; + dma_seen = true; + int_seen = true; + } else { + napi_ran = false; + dma_seen = efx_nic_event_present(channel); + int_seen = ACCESS_ONCE(channel->last_irq_cpu) >= 0; + } + napi_enable(&channel->napi_str); + efx_nic_eventq_read_ack(channel); + + wait *= 2; + } while (!(dma_seen && int_seen) && time_before(jiffies, timeout)); tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1; tests->eventq_int[channel->channel] = int_seen ? 1 : -1; @@ -516,10 +543,10 @@ efx_test_loopback(struct efx_tx_queue *tx_queue, begin_rc = efx_begin_loopback(tx_queue); /* This will normally complete very quickly, but be - * prepared to wait up to 100 ms. */ + * prepared to wait much longer. */ msleep(1); if (!efx_poll_loopback(efx)) { - msleep(100); + msleep(LOOPBACK_TIMEOUT_MS); efx_poll_loopback(efx); } -- GitLab From ed74f48087d1b1cf7cf534dad03bf1584eee783d Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 28 Feb 2012 20:40:54 +0000 Subject: [PATCH 1390/1846] sfc: Test all event queues in parallel In case all event queues are broken for some reason, this means it will only take about a second to check them all, rather than up to 32 seconds. This may also speed up testing in the successful case. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/selftest.c | 114 ++++++++++++++++------------ 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index dc330b9d9168..e4b4c8a3abc6 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -178,69 +178,88 @@ static int efx_test_interrupts(struct efx_nic *efx, } /* Test generation and receipt of interrupting events */ -static int efx_test_eventq_irq(struct efx_channel *channel, +static int efx_test_eventq_irq(struct efx_nic *efx, struct efx_self_tests *tests) { - struct efx_nic *efx = channel->efx; - unsigned int read_ptr; - bool napi_ran, dma_seen, int_seen; + struct efx_channel *channel; + unsigned int read_ptr[EFX_MAX_CHANNELS]; + unsigned long napi_ran = 0, dma_pend = 0, int_pend = 0; unsigned long timeout, wait; - read_ptr = channel->eventq_read_ptr; - channel->last_irq_cpu = -1; - smp_wmb(); + BUILD_BUG_ON(EFX_MAX_CHANNELS > BITS_PER_LONG); + + efx_for_each_channel(channel, efx) { + read_ptr[channel->channel] = channel->eventq_read_ptr; + set_bit(channel->channel, &dma_pend); + set_bit(channel->channel, &int_pend); + channel->last_irq_cpu = -1; + smp_wmb(); + efx_nic_generate_test_event(channel); + } - efx_nic_generate_test_event(channel); timeout = jiffies + IRQ_TIMEOUT; wait = 1; - /* Wait for arrival of interrupt. NAPI processing may or may + /* Wait for arrival of interrupts. NAPI processing may or may * not complete in time, but we can cope in any case. */ do { schedule_timeout_uninterruptible(wait); - napi_disable(&channel->napi_str); - if (channel->eventq_read_ptr != read_ptr) { - napi_ran = true; - dma_seen = true; - int_seen = true; - } else { - napi_ran = false; - dma_seen = efx_nic_event_present(channel); - int_seen = ACCESS_ONCE(channel->last_irq_cpu) >= 0; + efx_for_each_channel(channel, efx) { + napi_disable(&channel->napi_str); + if (channel->eventq_read_ptr != + read_ptr[channel->channel]) { + set_bit(channel->channel, &napi_ran); + clear_bit(channel->channel, &dma_pend); + clear_bit(channel->channel, &int_pend); + } else { + if (efx_nic_event_present(channel)) + clear_bit(channel->channel, &dma_pend); + if (ACCESS_ONCE(channel->last_irq_cpu) >= 0) + clear_bit(channel->channel, &int_pend); + } + napi_enable(&channel->napi_str); + efx_nic_eventq_read_ack(channel); } - napi_enable(&channel->napi_str); - efx_nic_eventq_read_ack(channel); wait *= 2; - } while (!(dma_seen && int_seen) && time_before(jiffies, timeout)); - - tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1; - tests->eventq_int[channel->channel] = int_seen ? 1 : -1; + } while ((dma_pend || int_pend) && time_before(jiffies, timeout)); - if (dma_seen && int_seen) { - netif_dbg(efx, drv, efx->net_dev, - "channel %d event queue passed (with%s NAPI)\n", - channel->channel, napi_ran ? "" : "out"); - return 0; - } else { - /* Report failure and whether either interrupt or DMA worked */ - netif_err(efx, drv, efx->net_dev, - "channel %d timed out waiting for event queue\n", - channel->channel); - if (int_seen) - netif_err(efx, drv, efx->net_dev, - "channel %d saw interrupt " - "during event queue test\n", - channel->channel); - if (dma_seen) + efx_for_each_channel(channel, efx) { + bool dma_seen = !test_bit(channel->channel, &dma_pend); + bool int_seen = !test_bit(channel->channel, &int_pend); + + tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1; + tests->eventq_int[channel->channel] = int_seen ? 1 : -1; + + if (dma_seen && int_seen) { + netif_dbg(efx, drv, efx->net_dev, + "channel %d event queue passed (with%s NAPI)\n", + channel->channel, + test_bit(channel->channel, &napi_ran) ? + "" : "out"); + } else { + /* Report failure and whether either interrupt or DMA + * worked + */ netif_err(efx, drv, efx->net_dev, - "channel %d event was generated, but " - "failed to trigger an interrupt\n", + "channel %d timed out waiting for event queue\n", channel->channel); - return -ETIMEDOUT; + if (int_seen) + netif_err(efx, drv, efx->net_dev, + "channel %d saw interrupt " + "during event queue test\n", + channel->channel); + if (dma_seen) + netif_err(efx, drv, efx->net_dev, + "channel %d event was generated, but " + "failed to trigger an interrupt\n", + channel->channel); + } } + + return (dma_pend || int_pend) ? -ETIMEDOUT : 0; } static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests, @@ -687,7 +706,6 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, enum efx_loopback_mode loopback_mode = efx->loopback_mode; int phy_mode = efx->phy_mode; enum reset_type reset_method = RESET_TYPE_INVISIBLE; - struct efx_channel *channel; int rc_test = 0, rc_reset = 0, rc; /* Online (i.e. non-disruptive) testing @@ -705,11 +723,9 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, if (rc && !rc_test) rc_test = rc; - efx_for_each_channel(channel, efx) { - rc = efx_test_eventq_irq(channel, tests); - if (rc && !rc_test) - rc_test = rc; - } + rc = efx_test_eventq_irq(efx, tests); + if (rc && !rc_test) + rc_test = rc; if (rc_test) return rc_test; -- GitLab From eee6f6a9e0c83811de77a137989d4a3289e297cc Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 28 Feb 2012 23:37:35 +0000 Subject: [PATCH 1391/1846] sfc: Encapsulate access to efx_{channel,nic}::last_irq_cpu in self-test Cleanup in preparation for doing an event test on ifup. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/nic.c | 8 ++++++-- drivers/net/ethernet/sfc/nic.h | 13 +++++++++++-- drivers/net/ethernet/sfc/selftest.c | 14 ++++---------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 5da8af5e7501..4c47b7569145 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -1332,8 +1332,10 @@ void efx_nic_remove_eventq(struct efx_channel *channel) } -void efx_nic_generate_test_event(struct efx_channel *channel) +void efx_nic_event_test_start(struct efx_channel *channel) { + channel->last_irq_cpu = -1; + smp_wmb(); efx_magic_event(channel, EFX_CHANNEL_MAGIC_TEST(channel)); } @@ -1382,8 +1384,10 @@ void efx_nic_disable_interrupts(struct efx_nic *efx) * Interrupt must already have been enabled, otherwise nasty things * may happen. */ -void efx_nic_generate_interrupt(struct efx_nic *efx) +void efx_nic_irq_test_start(struct efx_nic *efx) { + efx->last_irq_cpu = -1; + smp_wmb(); efx_nic_interrupts(efx, true, true); } diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index ac12f7f7f35b..e0e8596f4d10 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -301,14 +301,23 @@ extern void falcon_update_stats_xmac(struct efx_nic *efx); /* Interrupts and test events */ extern int efx_nic_init_interrupt(struct efx_nic *efx); extern void efx_nic_enable_interrupts(struct efx_nic *efx); -extern void efx_nic_generate_test_event(struct efx_channel *channel); -extern void efx_nic_generate_interrupt(struct efx_nic *efx); +extern void efx_nic_event_test_start(struct efx_channel *channel); +extern void efx_nic_irq_test_start(struct efx_nic *efx); extern void efx_nic_disable_interrupts(struct efx_nic *efx); extern void efx_nic_fini_interrupt(struct efx_nic *efx); extern irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx); extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id); extern void falcon_irq_ack_a1(struct efx_nic *efx); +static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel) +{ + return ACCESS_ONCE(channel->last_irq_cpu); +} +static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx) +{ + return ACCESS_ONCE(efx->last_irq_cpu); +} + /* Global Resources */ extern int efx_nic_flush_queues(struct efx_nic *efx); extern void falcon_start_nic_stats(struct efx_nic *efx); diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index e4b4c8a3abc6..aa4ab53cac57 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -149,11 +149,7 @@ static int efx_test_interrupts(struct efx_nic *efx, netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n"); tests->interrupt = -1; - /* Reset interrupt flag */ - efx->last_irq_cpu = -1; - smp_wmb(); - - efx_nic_generate_interrupt(efx); + efx_nic_irq_test_start(efx); timeout = jiffies + IRQ_TIMEOUT; wait = 1; @@ -161,7 +157,7 @@ static int efx_test_interrupts(struct efx_nic *efx, netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n"); do { schedule_timeout_uninterruptible(wait); - cpu = ACCESS_ONCE(efx->last_irq_cpu); + cpu = efx_nic_irq_test_irq_cpu(efx); if (cpu >= 0) goto success; wait *= 2; @@ -192,9 +188,7 @@ static int efx_test_eventq_irq(struct efx_nic *efx, read_ptr[channel->channel] = channel->eventq_read_ptr; set_bit(channel->channel, &dma_pend); set_bit(channel->channel, &int_pend); - channel->last_irq_cpu = -1; - smp_wmb(); - efx_nic_generate_test_event(channel); + efx_nic_event_test_start(channel); } timeout = jiffies + IRQ_TIMEOUT; @@ -216,7 +210,7 @@ static int efx_test_eventq_irq(struct efx_nic *efx, } else { if (efx_nic_event_present(channel)) clear_bit(channel->channel, &dma_pend); - if (ACCESS_ONCE(channel->last_irq_cpu) >= 0) + if (efx_nic_event_test_irq_cpu(channel) >= 0) clear_bit(channel->channel, &int_pend); } napi_enable(&channel->napi_str); -- GitLab From dd40781e3a4e9d3177a548c389232ee9496dae8e Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 28 Feb 2012 23:40:21 +0000 Subject: [PATCH 1392/1846] sfc: Run event/IRQ self-test asynchronously when interface is brought up Generate a test event on each event queue whenever the interface is brought up, then after 1 second check that we have either handled a test event or handled another IRQ for each event queue. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 6 ++++- drivers/net/ethernet/sfc/efx.h | 2 +- drivers/net/ethernet/sfc/net_driver.h | 6 +++-- drivers/net/ethernet/sfc/nic.c | 4 +-- drivers/net/ethernet/sfc/nic.h | 2 +- drivers/net/ethernet/sfc/selftest.c | 35 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/selftest.h | 3 +++ 7 files changed, 51 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 00e13ab080e6..7683e53fda1d 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -25,6 +25,7 @@ #include "net_driver.h" #include "efx.h" #include "nic.h" +#include "selftest.h" #include "mcdi.h" #include "workarounds.h" @@ -1564,8 +1565,9 @@ static void efx_start_all(struct efx_nic *efx) * since we're holding the rtnl_lock at this point. */ static void efx_flush_all(struct efx_nic *efx) { - /* Make sure the hardware monitor is stopped */ + /* Make sure the hardware monitor and event self-test are stopped */ cancel_delayed_work_sync(&efx->monitor_work); + efx_selftest_async_cancel(efx); /* Stop scheduled port reconfigurations */ cancel_work_sync(&efx->mac_work); } @@ -1825,6 +1827,7 @@ static int efx_net_open(struct net_device *net_dev) efx_link_status_changed(efx); efx_start_all(efx); + efx_selftest_async_start(efx); return 0; } @@ -2375,6 +2378,7 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type, #endif INIT_WORK(&efx->reset_work, efx_reset_work); INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor); + INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work); efx->pci_dev = pci_dev; efx->msg_enable = debug; efx->state = STATE_INIT; diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h index 4debfe07fb88..be8f9158a714 100644 --- a/drivers/net/ethernet/sfc/efx.h +++ b/drivers/net/ethernet/sfc/efx.h @@ -148,7 +148,7 @@ static inline void efx_schedule_channel(struct efx_channel *channel) static inline void efx_schedule_channel_irq(struct efx_channel *channel) { - channel->last_irq_cpu = raw_smp_processor_id(); + channel->event_test_cpu = raw_smp_processor_id(); efx_schedule_channel(channel); } diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 0b95505e8968..27fe85fd4ba3 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -325,7 +325,7 @@ enum efx_rx_alloc_method { * @eventq_mask: Event queue pointer mask * @eventq_read_ptr: Event queue read pointer * @last_eventq_read_ptr: Last event queue read pointer value. - * @last_irq_cpu: Last CPU to handle interrupt for this channel + * @event_test_cpu: Last CPU to handle interrupt or test event for this channel * @irq_count: Number of IRQs since last adaptive moderation decision * @irq_mod_score: IRQ moderation score * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors @@ -356,8 +356,8 @@ struct efx_channel { unsigned int eventq_mask; unsigned int eventq_read_ptr; unsigned int last_eventq_read_ptr; + int event_test_cpu; - int last_irq_cpu; unsigned int irq_count; unsigned int irq_mod_score; #ifdef CONFIG_RFS_ACCEL @@ -678,6 +678,7 @@ struct vfdi_status; * @irq_status: Interrupt status buffer * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0 * @irq_level: IRQ level/index for IRQs not triggered by an event queue + * @selftest_work: Work item for asynchronous self-test * @mtd_list: List of MTDs attached to the NIC * @nic_data: Hardware dependent state * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode, @@ -791,6 +792,7 @@ struct efx_nic { struct efx_buffer irq_status; unsigned irq_zero_count; unsigned irq_level; + struct delayed_work selftest_work; #ifdef CONFIG_SFC_MTD struct list_head mtd_list; diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index 4c47b7569145..4a9a5beec8fc 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c @@ -1083,7 +1083,7 @@ efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event) code = _EFX_CHANNEL_MAGIC_CODE(magic); if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) { - /* ignore */ + channel->event_test_cpu = raw_smp_processor_id(); } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_FILL(rx_queue)) { /* The queue must be empty, so we won't receive any rx * events, so efx_process_channel() won't refill the @@ -1334,7 +1334,7 @@ void efx_nic_remove_eventq(struct efx_channel *channel) void efx_nic_event_test_start(struct efx_channel *channel) { - channel->last_irq_cpu = -1; + channel->event_test_cpu = -1; smp_wmb(); efx_magic_event(channel, EFX_CHANNEL_MAGIC_TEST(channel)); } diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index e0e8596f4d10..f46e2cea8ca9 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -311,7 +311,7 @@ extern void falcon_irq_ack_a1(struct efx_nic *efx); static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel) { - return ACCESS_ONCE(channel->last_irq_cpu); + return ACCESS_ONCE(channel->event_test_cpu); } static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx) { diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c index aa4ab53cac57..de4c0069f5b2 100644 --- a/drivers/net/ethernet/sfc/selftest.c +++ b/drivers/net/ethernet/sfc/selftest.c @@ -702,6 +702,8 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, enum reset_type reset_method = RESET_TYPE_INVISIBLE; int rc_test = 0, rc_reset = 0, rc; + efx_selftest_async_cancel(efx); + /* Online (i.e. non-disruptive) testing * This checks interrupt generation, event delivery and PHY presence. */ @@ -794,3 +796,36 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, return rc_test; } +void efx_selftest_async_start(struct efx_nic *efx) +{ + struct efx_channel *channel; + + efx_for_each_channel(channel, efx) + efx_nic_event_test_start(channel); + schedule_delayed_work(&efx->selftest_work, IRQ_TIMEOUT); +} + +void efx_selftest_async_cancel(struct efx_nic *efx) +{ + cancel_delayed_work_sync(&efx->selftest_work); +} + +void efx_selftest_async_work(struct work_struct *data) +{ + struct efx_nic *efx = container_of(data, struct efx_nic, + selftest_work.work); + struct efx_channel *channel; + int cpu; + + efx_for_each_channel(channel, efx) { + cpu = efx_nic_event_test_irq_cpu(channel); + if (cpu < 0) + netif_err(efx, ifup, efx->net_dev, + "channel %d failed to trigger an interrupt\n", + channel->channel); + else + netif_dbg(efx, ifup, efx->net_dev, + "channel %d triggered interrupt on CPU %d\n", + channel->channel, cpu); + } +} diff --git a/drivers/net/ethernet/sfc/selftest.h b/drivers/net/ethernet/sfc/selftest.h index 87abe2a53846..aed24b736059 100644 --- a/drivers/net/ethernet/sfc/selftest.h +++ b/drivers/net/ethernet/sfc/selftest.h @@ -48,5 +48,8 @@ extern void efx_loopback_rx_packet(struct efx_nic *efx, extern int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, unsigned flags); +extern void efx_selftest_async_start(struct efx_nic *efx); +extern void efx_selftest_async_cancel(struct efx_nic *efx); +extern void efx_selftest_async_work(struct work_struct *data); #endif /* EFX_SELFTEST_H */ -- GitLab From 58f7e57d11b99575ddb0a3ee9baf7551f10bc3dd Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 29 Feb 2012 00:24:10 +0000 Subject: [PATCH 1393/1846] sfc: Remove efx_channel::last_eventq_read_ptr This member has never been used in a production version of the driver. Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/net_driver.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 27fe85fd4ba3..f0385e1fb2d8 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -324,7 +324,6 @@ enum efx_rx_alloc_method { * @eventq: Event queue buffer * @eventq_mask: Event queue pointer mask * @eventq_read_ptr: Event queue read pointer - * @last_eventq_read_ptr: Last event queue read pointer value. * @event_test_cpu: Last CPU to handle interrupt or test event for this channel * @irq_count: Number of IRQs since last adaptive moderation decision * @irq_mod_score: IRQ moderation score @@ -355,7 +354,6 @@ struct efx_channel { struct efx_special_buffer eventq; unsigned int eventq_mask; unsigned int eventq_read_ptr; - unsigned int last_eventq_read_ptr; int event_test_cpu; unsigned int irq_count; -- GitLab From 460eeaa03c5c0af32a388337a6e1f0f1acd043ce Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 5 Mar 2012 15:35:39 +0000 Subject: [PATCH 1394/1846] sfc: Log the part number on probe During probe of each port, read and log the part number from VPD. Remove the Falcon-specific board name lookup. Initial version by Stuart Hodgson . Signed-off-by: Ben Hutchings --- drivers/net/ethernet/sfc/efx.c | 53 ++++++++++++++++++++++++ drivers/net/ethernet/sfc/falcon_boards.c | 13 ------ drivers/net/ethernet/sfc/nic.h | 4 -- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 7683e53fda1d..3cbfbffe3f00 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -2497,6 +2497,57 @@ static void efx_pci_remove(struct pci_dev *pci_dev) free_netdev(efx->net_dev); }; +/* NIC VPD information + * Called during probe to display the part number of the + * installed NIC. VPD is potentially very large but this should + * always appear within the first 512 bytes. + */ +#define SFC_VPD_LEN 512 +static void efx_print_product_vpd(struct efx_nic *efx) +{ + struct pci_dev *dev = efx->pci_dev; + char vpd_data[SFC_VPD_LEN]; + ssize_t vpd_size; + int i, j; + + /* Get the vpd data from the device */ + vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data); + if (vpd_size <= 0) { + netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n"); + return; + } + + /* Get the Read only section */ + i = pci_vpd_find_tag(vpd_data, 0, vpd_size, PCI_VPD_LRDT_RO_DATA); + if (i < 0) { + netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); + return; + } + + j = pci_vpd_lrdt_size(&vpd_data[i]); + i += PCI_VPD_LRDT_TAG_SIZE; + if (i + j > vpd_size) + j = vpd_size - i; + + /* Get the Part number */ + i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN"); + if (i < 0) { + netif_err(efx, drv, efx->net_dev, "Part number not found\n"); + return; + } + + j = pci_vpd_info_field_size(&vpd_data[i]); + i += PCI_VPD_INFO_FLD_HDR_SIZE; + if (i + j > vpd_size) { + netif_err(efx, drv, efx->net_dev, "Incomplete part number\n"); + return; + } + + netif_info(efx, drv, efx->net_dev, + "Part Number : %.*s\n", j, &vpd_data[i]); +} + + /* Main body of NIC initialisation * This is called at module load (or hotplug insertion, theoretically). */ @@ -2586,6 +2637,8 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, netif_info(efx, probe, efx->net_dev, "Solarflare NIC detected\n"); + efx_print_product_vpd(efx); + /* Set up basic I/O (BAR mappings etc) */ rc = efx_init_io(efx); if (rc) diff --git a/drivers/net/ethernet/sfc/falcon_boards.c b/drivers/net/ethernet/sfc/falcon_boards.c index 2084cc6ede52..8687a6c3db0d 100644 --- a/drivers/net/ethernet/sfc/falcon_boards.c +++ b/drivers/net/ethernet/sfc/falcon_boards.c @@ -709,8 +709,6 @@ static int sfe4003_init(struct efx_nic *efx) static const struct falcon_board_type board_types[] = { { .id = FALCON_BOARD_SFE4001, - .ref_model = "SFE4001", - .gen_type = "10GBASE-T adapter", .init = sfe4001_init, .init_phy = efx_port_dummy_op_void, .fini = sfe4001_fini, @@ -719,8 +717,6 @@ static const struct falcon_board_type board_types[] = { }, { .id = FALCON_BOARD_SFE4002, - .ref_model = "SFE4002", - .gen_type = "XFP adapter", .init = sfe4002_init, .init_phy = sfe4002_init_phy, .fini = efx_fini_lm87, @@ -729,8 +725,6 @@ static const struct falcon_board_type board_types[] = { }, { .id = FALCON_BOARD_SFE4003, - .ref_model = "SFE4003", - .gen_type = "10GBASE-CX4 adapter", .init = sfe4003_init, .init_phy = sfe4003_init_phy, .fini = efx_fini_lm87, @@ -739,8 +733,6 @@ static const struct falcon_board_type board_types[] = { }, { .id = FALCON_BOARD_SFN4112F, - .ref_model = "SFN4112F", - .gen_type = "SFP+ adapter", .init = sfn4112f_init, .init_phy = sfn4112f_init_phy, .fini = efx_fini_lm87, @@ -763,11 +755,6 @@ int falcon_probe_board(struct efx_nic *efx, u16 revision_info) board->type = &board_types[i]; if (board->type) { - netif_info(efx, probe, efx->net_dev, "board is %s rev %c%d\n", - (efx->pci_dev->subsystem_vendor == - PCI_VENDOR_ID_SOLARFLARE) - ? board->type->ref_model : board->type->gen_type, - 'A' + board->major, board->minor); return 0; } else { netif_err(efx, probe, efx->net_dev, "unknown board type %d\n", diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index f46e2cea8ca9..f48ccf6bb3b9 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h @@ -69,8 +69,6 @@ enum { /** * struct falcon_board_type - board operations and type information * @id: Board type id, as found in NVRAM - * @ref_model: Model number of Solarflare reference design - * @gen_type: Generic board type description * @init: Allocate resources and initialise peripheral hardware * @init_phy: Do board-specific PHY initialisation * @fini: Shut down hardware and free resources @@ -79,8 +77,6 @@ enum { */ struct falcon_board_type { u8 id; - const char *ref_model; - const char *gen_type; int (*init) (struct efx_nic *nic); void (*init_phy) (struct efx_nic *efx); void (*fini) (struct efx_nic *nic); -- GitLab From 804483e90794256f9ed53e795ffbf1e94de237c8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 22:18:41 +0100 Subject: [PATCH 1395/1846] cfg80211/mac80211: report signal strength for mgmt frames Add the signal strength (in dBm only for now) to frames that are received via nl80211's various frame APIs. Signed-off-by: Johannes Berg Acked-by: Kalle Valo Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath6kl/wmi.c | 6 ++++-- include/linux/nl80211.h | 6 ++++++ include/net/cfg80211.h | 8 +++++--- net/mac80211/rx.c | 13 +++++++++++-- net/wireless/mlme.c | 7 ++++--- net/wireless/nl80211.c | 9 +++++++-- net/wireless/nl80211.h | 3 ++- 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 18fa9aa8af92..97abf4699b41 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -556,7 +556,8 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, dlen, freq, vif->probe_req_report); if (vif->probe_req_report || vif->nw_type == AP_NETWORK) - cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); + cfg80211_rx_mgmt(vif->ndev, freq, 0, + ev->data, dlen, GFP_ATOMIC); return 0; } @@ -595,7 +596,8 @@ static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, return -EINVAL; } ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); - cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); + cfg80211_rx_mgmt(vif->ndev, freq, 0, + ev->data, dlen, GFP_ATOMIC); return 0; } diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 9f46c62b1eee..c37d67add090 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -1203,6 +1203,10 @@ enum nl80211_commands { * the list. This needs to be used when the driver advertises the * capability to timeout the stations. * + * @NL80211_ATTR_RX_SIGNAL_DBM: signal strength in dBm (as a 32-bit int); + * this attribute is (depending on the driver capabilities) added to + * received frames indicated with %NL80211_CMD_FRAME. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1450,6 +1454,8 @@ enum nl80211_attrs { NL80211_ATTR_INACTIVITY_TIMEOUT, + NL80211_ATTR_RX_SIGNAL_DBM, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 804805827736..4682c35a92c4 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -3189,6 +3189,7 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); * cfg80211_rx_mgmt - notification of received, unprocessed management frame * @dev: network device * @freq: Frequency on which the frame was received in MHz + * @sig_dbm: signal strength in mBm, or 0 if unknown * @buf: Management frame (header + body) * @len: length of the frame data * @gfp: context flags @@ -3201,8 +3202,8 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); * This function is called whenever an Action frame is received for a station * mode interface, but is not processed in kernel. */ -bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, - size_t len, gfp_t gfp); +bool cfg80211_rx_mgmt(struct net_device *dev, int freq, int sig_dbm, + const u8 *buf, size_t len, gfp_t gfp); /** * cfg80211_mgmt_tx_status - notification of TX status for management frame @@ -3315,6 +3316,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, * @frame: the frame * @len: length of the frame * @freq: frequency the frame was received on + * @sig_dbm: signal strength in mBm, or 0 if unknown * @gfp: allocation flags * * Use this function to report to userspace when a beacon was @@ -3323,7 +3325,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, */ void cfg80211_report_obss_beacon(struct wiphy *wiphy, const u8 *frame, size_t len, - int freq, gfp_t gfp); + int freq, int sig_dbm, gfp_t gfp); /* * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 10bbbd33b314..5f6e32ca0858 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2188,9 +2188,14 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx) if (rx->sdata->vif.type == NL80211_IFTYPE_AP && ieee80211_is_beacon(mgmt->frame_control) && !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { + int sig = 0; + + if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) + sig = status->signal; + cfg80211_report_obss_beacon(rx->local->hw.wiphy, rx->skb->data, rx->skb->len, - status->freq, GFP_ATOMIC); + status->freq, sig, GFP_ATOMIC); rx->flags |= IEEE80211_RX_BEACON_REPORTED; } @@ -2414,6 +2419,7 @@ static ieee80211_rx_result debug_noinline ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx) { struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); + int sig = 0; /* skip known-bad action frames and return them in the next handler */ if (status->rx_flags & IEEE80211_RX_MALFORMED_ACTION_FRM) @@ -2426,7 +2432,10 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx) * it transmitted were processed or returned. */ - if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, + if (rx->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) + sig = status->signal; + + if (cfg80211_rx_mgmt(rx->sdata->dev, status->freq, sig, rx->skb->data, rx->skb->len, GFP_ATOMIC)) { if (rx->sta) diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index fb1e72179117..f5a7ac3a0939 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -814,8 +814,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, cookie); } -bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, - size_t len, gfp_t gfp) +bool cfg80211_rx_mgmt(struct net_device *dev, int freq, int sig_mbm, + const u8 *buf, size_t len, gfp_t gfp) { struct wireless_dev *wdev = dev->ieee80211_ptr; struct wiphy *wiphy = wdev->wiphy; @@ -854,7 +854,8 @@ bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, /* found match! */ /* Indicate the received Action frame to user space */ - if (nl80211_send_mgmt(rdev, dev, reg->nlpid, freq, + if (nl80211_send_mgmt(rdev, dev, reg->nlpid, + freq, sig_mbm, buf, len, gfp)) continue; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 4b6afc338aac..39dbdf2adb12 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -7686,7 +7686,8 @@ bool nl80211_unexpected_4addr_frame(struct net_device *dev, int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, struct net_device *netdev, u32 nlpid, - int freq, const u8 *buf, size_t len, gfp_t gfp) + int freq, int sig_dbm, + const u8 *buf, size_t len, gfp_t gfp) { struct sk_buff *msg; void *hdr; @@ -7704,6 +7705,8 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); + if (sig_dbm) + NLA_PUT_U32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm); NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); genlmsg_end(msg, hdr); @@ -7965,7 +7968,7 @@ EXPORT_SYMBOL(cfg80211_probe_status); void cfg80211_report_obss_beacon(struct wiphy *wiphy, const u8 *frame, size_t len, - int freq, gfp_t gfp) + int freq, int sig_dbm, gfp_t gfp) { struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); struct sk_buff *msg; @@ -7988,6 +7991,8 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy, NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); if (freq) NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); + if (sig_dbm) + NLA_PUT_U32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm); NLA_PUT(msg, NL80211_ATTR_FRAME, len, frame); genlmsg_end(msg, hdr); diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index 12bf4d185abe..4ffe50df9f31 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h @@ -92,7 +92,8 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, gfp_t gfp); int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, - struct net_device *netdev, u32 nlpid, int freq, + struct net_device *netdev, u32 nlpid, + int freq, int sig_dbm, const u8 *buf, size_t len, gfp_t gfp); void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, struct net_device *netdev, u64 cookie, -- GitLab From da473b61ad9e25e2ac3efb58d95c5b573260c6a8 Mon Sep 17 00:00:00 2001 From: Chun-Yeow Yeoh Date: Sat, 3 Mar 2012 09:48:56 +0800 Subject: [PATCH 1396/1846] ath5k: allow AP and mesh mode to operate simultaneously This patch allows the possibility of having the mesh point and AP to be operated simultaneously in one single radio. Previously, mesh point fails to generate the mesh beacon if virtual AP is created for the same radio. Signed-off-by: Chun-Yeow Yeoh Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ath5k.h | 1 + drivers/net/wireless/ath/ath5k/base.c | 6 ++++-- drivers/net/wireless/ath/ath5k/mac80211-ops.c | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index 6640326f7005..8d434b8f5855 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -1320,6 +1320,7 @@ struct ath5k_hw { struct ieee80211_vif *bslot[ATH_BCBUF]; u16 num_ap_vifs; u16 num_adhoc_vifs; + u16 num_mesh_vifs; unsigned int bhalq, /* SW q for outgoing beacons */ bmisscount, /* missed beacon transmits */ bintval, /* beacon interval in TU */ diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index a339693fbe26..b51d58c414d2 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -1867,7 +1867,8 @@ ath5k_beacon_send(struct ath5k_hw *ah) ah->bmisscount = 0; } - if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs > 1) || + if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs + + ah->num_mesh_vifs > 1) || ah->opmode == NL80211_IFTYPE_MESH_POINT) { u64 tsf = ath5k_hw_get_tsf64(ah); u32 tsftu = TSF_TO_TU(tsf); @@ -1952,7 +1953,8 @@ ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf) u64 hw_tsf; intval = ah->bintval & AR5K_BEACON_PERIOD; - if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs > 1) { + if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs + + ah->num_mesh_vifs > 1) { intval /= ATH_BCBUF; /* staggered multi-bss beacons */ if (intval < 15) ATH5K_WARN(ah, "intval %u is too low, min 15\n", diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c index af4c7ecb4b30..5c5329955414 100644 --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c @@ -134,6 +134,8 @@ ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ah->num_ap_vifs++; else if (avf->opmode == NL80211_IFTYPE_ADHOC) ah->num_adhoc_vifs++; + else if (avf->opmode == NL80211_IFTYPE_MESH_POINT) + ah->num_mesh_vifs++; } /* Any MAC address is fine, all others are included through the @@ -175,6 +177,8 @@ ath5k_remove_interface(struct ieee80211_hw *hw, ah->num_ap_vifs--; else if (avf->opmode == NL80211_IFTYPE_ADHOC) ah->num_adhoc_vifs--; + else if (avf->opmode == NL80211_IFTYPE_MESH_POINT) + ah->num_mesh_vifs--; ath5k_update_bssid_mask_and_opmode(ah, NULL); mutex_unlock(&ah->lock); -- GitLab From a9b89e2567c743483e6354f64d7a7e3a8c101e9e Mon Sep 17 00:00:00 2001 From: Jingjun Wu Date: Fri, 2 Mar 2012 20:52:14 -0600 Subject: [PATCH 1397/1846] rtlwifi: rtl8192ce: Fix loss of receive performance Driver rtl8192ce when used with the RTL8188CE device would start at about 20 Mbps on a 54 Mbps connection, but quickly drop to 1 Mbps. One of the symptoms is that the AP would need to retransmit each packet 4 of 5 times before the driver would acknowledge it. Recovery is possible only by unloading and reloading the driver. This problem was reported at https://bugzilla.redhat.com/show_bug.cgi?id=770207. The problem is due to a missing update of the gain setting. Signed-off-by: Jingjun Wu Signed-off-by: Larry Finger Cc: Stable Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index 8646ff2a55ce..d8d73dbb5780 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -520,6 +520,10 @@ void rtl92c_dm_write_dig(struct ieee80211_hw *hw) dm_digtable.cur_igvalue, dm_digtable.pre_igvalue, dm_digtable.backoff_val); + dm_digtable.cur_igvalue += 2; + if (dm_digtable.cur_igvalue > 0x3f) + dm_digtable.cur_igvalue = 0x3f; + if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) { rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, dm_digtable.cur_igvalue); -- GitLab From 972a31367f94967716b000fd8fac33d259ebcfed Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 3 Mar 2012 21:24:43 +0100 Subject: [PATCH 1398/1846] p54: pass interface setup errors back to mac80211 Signed-off-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/p54/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c index 40f4eb7da7b2..ee8af1f047c8 100644 --- a/drivers/net/wireless/p54/main.c +++ b/drivers/net/wireless/p54/main.c @@ -227,6 +227,7 @@ static int p54_add_interface(struct ieee80211_hw *dev, struct ieee80211_vif *vif) { struct p54_common *priv = dev->priv; + int err; vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; @@ -251,9 +252,9 @@ static int p54_add_interface(struct ieee80211_hw *dev, } memcpy(priv->mac_addr, vif->addr, ETH_ALEN); - p54_setup_mac(priv); + err = p54_setup_mac(priv); mutex_unlock(&priv->conf_mutex); - return 0; + return err; } static void p54_remove_interface(struct ieee80211_hw *dev, -- GitLab From 26627687e881e79c8c8f9076f79181c2beefcae7 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 3 Mar 2012 21:25:19 +0100 Subject: [PATCH 1399/1846] p54pci: use new driver.pm interface for suspend/resume Signed-off-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/p54/p54pci.c | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c index b1f51a215792..45df728183fd 100644 --- a/drivers/net/wireless/p54/p54pci.c +++ b/drivers/net/wireless/p54/p54pci.c @@ -624,36 +624,39 @@ static void __devexit p54p_remove(struct pci_dev *pdev) } #ifdef CONFIG_PM -static int p54p_suspend(struct pci_dev *pdev, pm_message_t state) +static int p54p_suspend(struct device *device) { - struct ieee80211_hw *dev = pci_get_drvdata(pdev); - struct p54p_priv *priv = dev->priv; - - if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) { - ieee80211_stop_queues(dev); - p54p_stop(dev); - } + struct pci_dev *pdev = to_pci_dev(device); pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + pci_set_power_state(pdev, PCI_D3hot); + pci_disable_device(pdev); return 0; } -static int p54p_resume(struct pci_dev *pdev) +static int p54p_resume(struct device *device) { - struct ieee80211_hw *dev = pci_get_drvdata(pdev); - struct p54p_priv *priv = dev->priv; + struct pci_dev *pdev = to_pci_dev(device); + int err; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); + err = pci_reenable_device(pdev); + if (err) + return err; + return pci_set_power_state(pdev, PCI_D0); +} - if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) { - p54p_open(dev); - ieee80211_wake_queues(dev); - } +static const struct dev_pm_ops p54pci_pm_ops = { + .suspend = p54p_suspend, + .resume = p54p_resume, + .freeze = p54p_suspend, + .thaw = p54p_resume, + .poweroff = p54p_suspend, + .restore = p54p_resume, +}; - return 0; -} +#define P54P_PM_OPS (&p54pci_pm_ops) +#else +#define P54P_PM_OPS (NULL) #endif /* CONFIG_PM */ static struct pci_driver p54p_driver = { @@ -661,10 +664,7 @@ static struct pci_driver p54p_driver = { .id_table = p54p_table, .probe = p54p_probe, .remove = __devexit_p(p54p_remove), -#ifdef CONFIG_PM - .suspend = p54p_suspend, - .resume = p54p_resume, -#endif /* CONFIG_PM */ + .driver.pm = P54P_PM_OPS, }; static int __init p54p_init(void) -- GitLab From 342bbf3fee2fa9a18147e74b2e3c4229a4564912 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 4 Mar 2012 08:50:46 -0800 Subject: [PATCH 1400/1846] iwlwifi: always monitor for stuck queues If we only monitor while associated, the following can happen: - we're associated, and the queue stuck check runs, setting the queue "touch" time to X - we disassociate, stopping the monitoring, which leaves the time set to X - almost 2s later, we associate, and enqueue a frame - before the frame is transmitted, we monitor for stuck queues, and find the time set to X, although it is now later than X + 2000ms, so we decide that the queue is stuck and erroneously restart the device It happens more with P2P because there we can go between associated/unassociated frequently. Cc: stable@vger.kernel.org Reported-by: Ben Cahill Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 275e08966059..8551c95e7437 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1345,20 +1345,10 @@ void iwl_bg_watchdog(unsigned long data) if (timeout == 0) return; - /* monitor and check for stuck cmd queue */ - if (iwl_check_stuck_queue(priv, priv->shrd->cmd_queue)) - return; - - /* monitor and check for other stuck queues */ - if (iwl_is_any_associated(priv)) { - for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) { - /* skip as we already checked the command queue */ - if (cnt == priv->shrd->cmd_queue) - continue; - if (iwl_check_stuck_queue(priv, cnt)) - return; - } - } + /* monitor and check for stuck queues */ + for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) + if (iwl_check_stuck_queue(priv, cnt)) + return; mod_timer(&priv->watchdog, jiffies + msecs_to_jiffies(IWL_WD_TICK(timeout))); -- GitLab From e9a8e8ec1e487536568adc4b3efa8f56e4391a7b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 5 Mar 2012 21:10:07 +0300 Subject: [PATCH 1401/1846] airo: fix test for FLAG_RADIO_DOWN We should be doing a shift (1 << FLAG_RADIO_DOWN) here before testing the flag. As luck would have it, this test works almost correctly. The current code tests for FLAG_RADIO_OFF instead of FLAG_RADIO_DOWN. #define FLAG_RADIO_OFF 0 /* User disabling of MAC */ #define FLAG_RADIO_DOWN 1 /* ifup/ifdown disabling of MAC */ Signed-off-by: Dan Carpenter Signed-off-by: John W. Linville --- drivers/net/wireless/airo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 1c008c61b95c..ddc061dd150c 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -1869,7 +1869,7 @@ static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock) static void try_auto_wep(struct airo_info *ai) { - if (auto_wep && !(ai->flags & FLAG_RADIO_DOWN)) { + if (auto_wep && !test_bit(FLAG_RADIO_DOWN, &ai->flags)) { ai->expires = RUN_AT(3*HZ); wake_up_interruptible(&ai->thr_wait); } -- GitLab From d316383dfdb51d46fb9681a68b395a5735f3f4b3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:19 -0800 Subject: [PATCH 1402/1846] iwlwifi: move iwl_clear_driver_stations to user There's only one place using this function, so move it where it's needed. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 35 ++++++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-agn.h | 35 -------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index e0fef9f257c2..a7f3a7023d88 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -738,6 +738,41 @@ int iwl_alive_start(struct iwl_priv *priv) return iwl_power_update_mode(priv, true); } +/** + * iwl_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 + * 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 void iwl_clear_driver_stations(struct iwl_priv *priv) +{ + unsigned long flags; + struct iwl_rxon_context *ctx; + + spin_lock_irqsave(&priv->shrd->sta_lock, flags); + memset(priv->stations, 0, sizeof(priv->stations)); + priv->num_stations = 0; + + priv->ucode_key_table = 0; + + for_each_context(priv, 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; + } + + spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); +} + void iwl_down(struct iwl_priv *priv) { int exit_pending; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index cb484e273b93..ef0cdf5b32fa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -232,41 +232,6 @@ int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd); -/** - * iwl_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 - * 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_clear_driver_stations(struct iwl_priv *priv) -{ - unsigned long flags; - struct iwl_rxon_context *ctx; - - spin_lock_irqsave(&priv->shrd->sta_lock, flags); - memset(priv->stations, 0, sizeof(priv->stations)); - priv->num_stations = 0; - - priv->ucode_key_table = 0; - - for_each_context(priv, 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; - } - - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); -} - static inline int iwl_sta_id(struct ieee80211_sta *sta) { if (WARN_ON(!sta)) -- GitLab From f2b69ef022aba3fe436bb03664cf12b261cb64d1 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:20 -0800 Subject: [PATCH 1403/1846] iwlwifi: remove an unused argument The station ID argument to the function iwlagn_tx_cmd_build_hwcrypto isn't used 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-agn-tx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 5f78567f4180..81a3b0e3a8e0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -208,10 +208,9 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv, } static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv, - struct ieee80211_tx_info *info, - struct iwl_tx_cmd *tx_cmd, - struct sk_buff *skb_frag, - int sta_id) + struct ieee80211_tx_info *info, + struct iwl_tx_cmd *tx_cmd, + struct sk_buff *skb_frag) { struct ieee80211_key_conf *keyconf = info->control.hw_key; @@ -358,7 +357,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) - iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); + iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb); /* TODO need this for burst mode later on */ iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); -- GitLab From 71cb99241d63b26a41c9cce6ed441bc30f90224a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:21 -0800 Subject: [PATCH 1404/1846] iwlwifi: reduce sta_lock hold time in TX When we TX, we hold the sta_lock for a long time, a lot of which isn't needed. Reduce the time we hold the lock. Note that this doesn't really change anything as the code is already under the other spinlock, but it makes the code easier to read. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 81a3b0e3a8e0..59509d80f73f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -341,13 +341,10 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (info->flags & IEEE80211_TX_CTL_AMPDU) is_agg = true; - /* irqs already disabled/saved above when locking priv->shrd->lock */ - spin_lock(&priv->shrd->sta_lock); - dev_cmd = kmem_cache_alloc(priv->tx_cmd_pool, GFP_ATOMIC); if (unlikely(!dev_cmd)) - goto drop_unlock_sta; + goto drop_unlock_priv; memset(dev_cmd, 0, sizeof(*dev_cmd)); tx_cmd = (struct iwl_tx_cmd *) dev_cmd->payload; @@ -372,6 +369,9 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) info->driver_data[0] = ctx; info->driver_data[1] = dev_cmd; + /* irqs already disabled/saved above when locking priv->shrd->lock */ + spin_lock(&priv->shrd->sta_lock); + if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc)) { u8 *qc = NULL; struct iwl_tid_data *tid_data; -- GitLab From 40e4e6868c532b439754154d69a2837dbf9bd91e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:22 -0800 Subject: [PATCH 1405/1846] iwlwifi: simplify code in iwlagn_key_sta_id Simplify the code by returning directly in the error case and replacing the switch/if with a single if statement. 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 | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index f1298cd6a19a..3eb8fd4771b6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -1080,32 +1080,19 @@ static u8 iwlagn_key_sta_id(struct iwl_priv *priv, struct ieee80211_sta *sta) { struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - u8 sta_id = IWL_INVALID_STATION; if (sta) - sta_id = iwl_sta_id(sta); + return iwl_sta_id(sta); /* * The device expects GTKs for station interfaces to be * installed as GTKs for the AP station. If we have no * station ID, then use the ap_sta_id in that case. */ - if (!sta && vif && vif_priv->ctx) { - switch (vif->type) { - case NL80211_IFTYPE_STATION: - sta_id = vif_priv->ctx->ap_sta_id; - break; - default: - /* - * In all other cases, the key will be - * used either for TX only or is bound - * to a station already. - */ - break; - } - } + if (vif->type == NL80211_IFTYPE_STATION && vif_priv->ctx) + return vif_priv->ctx->ap_sta_id; - return sta_id; + return IWL_INVALID_STATION; } static int iwlagn_send_sta_key(struct iwl_priv *priv, -- GitLab From 9451ca1a31be44f8235c3f8f998ff27fc7a8395e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:23 -0800 Subject: [PATCH 1406/1846] iwlwifi: build some station commands directly In the powersave related functions we only need to set a few parameters for the station command and can otherwise leave it blank -- there's no need to copy it from the database. This allows us to not use the sta lock here. 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 | 20 +++++++++----------- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 16 ++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 3eb8fd4771b6..6b9af994cfa4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -1437,16 +1437,14 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) { - unsigned long flags; - - spin_lock_irqsave(&priv->shrd->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 = - 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_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + struct iwl_addsta_cmd cmd = { + .mode = STA_CONTROL_MODIFY_MSK, + .station_flags = STA_FLG_PWR_SAVE_MSK, + .station_flags_msk = STA_FLG_PWR_SAVE_MSK, + .sta.sta_id = sta_id, + .sta.modify_mask = STA_MODIFY_SLEEP_TX_COUNT_MSK, + .sleep_tx_count = cpu_to_le16(cnt), + }; + iwl_send_add_sta(priv, &cmd, CMD_ASYNC); } diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 03f770543d8e..9fba532d35cd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -1505,17 +1505,13 @@ static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) { - unsigned long flags; - - spin_lock_irqsave(&priv->shrd->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 = 0; - priv->stations[sta_id].sta.sleep_tx_count = 0; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + struct iwl_addsta_cmd cmd = { + .mode = STA_CONTROL_MODIFY_MSK, + .station_flags_msk = STA_FLG_PWR_SAVE_MSK, + .sta.sta_id = sta_id, + }; + iwl_send_add_sta(priv, &cmd, CMD_ASYNC); } static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, -- GitLab From 015c15e1067c988fc87fb550b222f075c8d3f47c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:24 -0800 Subject: [PATCH 1407/1846] iwlwifi: introduce per-queue locks Instead of (ab)using the sta_lock, make the transport layer lock its own TX queue data structures with a lock per queue. This also unifies with the cmd queue lock. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 ++ .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 20 +++++++----- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 31 ++++++++++++------- drivers/net/wireless/iwlwifi/iwl-trans.h | 2 -- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 5b26b71ae3d5..b1029468ccbd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -169,6 +169,7 @@ struct iwl_queue { * @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 + * lock: queue lock * @time_stamp: time (in jiffies) of last read_ptr change * @need_update: indicates need to update read/write index * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled @@ -187,6 +188,7 @@ struct iwl_tx_queue { struct iwl_device_cmd **cmd; struct iwl_cmd_meta *meta; struct sk_buff **skbs; + spinlock_t lock; unsigned long time_stamp; u8 need_update; u8 sched_retry; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 82e34484fa5e..1cb1dd29b3fe 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -217,6 +217,8 @@ void iwlagn_txq_free_tfd(struct iwl_trans *trans, struct iwl_tx_queue *txq, { struct iwl_tfd *tfd_tmp = txq->tfds; + lockdep_assert_held(&txq->lock); + iwlagn_unmap_tfd(trans, &txq->meta[index], &tfd_tmp[index], dma_dir); /* free SKB */ @@ -621,7 +623,6 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) struct iwl_device_cmd *out_cmd; struct iwl_cmd_meta *out_meta; dma_addr_t phys_addr; - unsigned long flags; u32 idx; u16 copy_size, cmd_size; bool is_ct_kill = false; @@ -680,10 +681,10 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) return -EIO; } - spin_lock_irqsave(&trans->hcmd_lock, flags); + spin_lock_bh(&txq->lock); if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { - spin_unlock_irqrestore(&trans->hcmd_lock, flags); + spin_unlock_bh(&txq->lock); IWL_ERR(trans, "No space in command queue\n"); is_ct_kill = iwl_check_for_ct_kill(priv(trans)); @@ -790,7 +791,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) iwl_txq_update_write_ptr(trans, txq); out: - spin_unlock_irqrestore(&trans->hcmd_lock, flags); + spin_unlock_bh(&txq->lock); return idx; } @@ -809,6 +810,8 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id, struct iwl_queue *q = &txq->q; int nfreed = 0; + lockdep_assert_held(&txq->lock); + if ((idx >= q->n_bd) || (iwl_queue_used(q, idx) == 0)) { IWL_ERR(trans, "%s: Read index for DMA queue txq id (%d), " "index %d is out of range [0-%d] %d %d.\n", __func__, @@ -850,7 +853,6 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, struct iwl_cmd_meta *meta; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->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 @@ -864,6 +866,8 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, return; } + spin_lock(&txq->lock); + cmd_index = get_cmd_index(&txq->q, index); cmd = txq->cmd[cmd_index]; meta = &txq->meta[cmd_index]; @@ -880,8 +884,6 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, rxb->page = NULL; } - spin_lock_irqsave(&trans->hcmd_lock, flags); - iwl_hcmd_queue_reclaim(trans, txq_id, index); if (!(meta->flags & CMD_ASYNC)) { @@ -898,7 +900,7 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, meta->flags = 0; - spin_unlock_irqrestore(&trans->hcmd_lock, flags); + spin_unlock(&txq->lock); } #define HOST_COMPLETE_TIMEOUT (2 * HZ) @@ -1041,6 +1043,8 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index, if (WARN_ON(txq_id == trans->shrd->cmd_queue)) return 0; + lockdep_assert_held(&txq->lock); + /*Since we free until index _not_ inclusive, the one before index is * the last we will free. This one must be used */ last_to_free = iwl_queue_dec_wrap(index, q->n_bd); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 9f8b23909404..f47426a5ef4d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -390,6 +390,8 @@ static int iwl_trans_txq_init(struct iwl_trans *trans, struct iwl_tx_queue *txq, if (ret) return ret; + spin_lock_init(&txq->lock); + /* * Tell nic where to find circular buffer of Tx Frame Descriptors for * given Tx queue, and enable the DMA channel used for that queue. @@ -409,8 +411,6 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id) struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id]; struct iwl_queue *q = &txq->q; enum dma_data_direction dma_dir; - unsigned long flags; - spinlock_t *lock; if (!q->n_bd) return; @@ -418,22 +418,19 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id) /* In the command queue, all the TBs are mapped as BIDI * so unmap them as such. */ - if (txq_id == trans->shrd->cmd_queue) { + if (txq_id == trans->shrd->cmd_queue) dma_dir = DMA_BIDIRECTIONAL; - lock = &trans->hcmd_lock; - } else { + else dma_dir = DMA_TO_DEVICE; - lock = &trans->shrd->sta_lock; - } - spin_lock_irqsave(lock, flags); + spin_lock_bh(&txq->lock); while (q->write_ptr != q->read_ptr) { /* The read_ptr needs to bound by q->n_window */ iwlagn_txq_free_tfd(trans, txq, get_cmd_index(q, q->read_ptr), dma_dir); q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd); } - spin_unlock_irqrestore(lock, flags); + spin_unlock_bh(&txq->lock); } /** @@ -1358,6 +1355,8 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, txq = &trans_pcie->txq[txq_id]; q = &txq->q; + spin_lock(&txq->lock); + /* In AGG mode, the index in the ring must correspond to the WiFi * sequence number. This is a HW requirements to help the SCD to parse * the BA. @@ -1404,7 +1403,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, &dev_cmd->hdr, firstlen, DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(trans->dev, txcmd_phys))) - return -1; + goto out_err; dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); @@ -1426,7 +1425,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, dma_unmap_addr(out_meta, mapping), dma_unmap_len(out_meta, len), DMA_BIDIRECTIONAL); - return -1; + goto out_err; } } @@ -1481,7 +1480,11 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, iwl_stop_queue(trans, txq, "Queue is full"); } } + spin_unlock(&txq->lock); return 0; + out_err: + spin_unlock(&txq->lock); + return -1; } static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) @@ -1560,6 +1563,8 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, int tfd_num = ssn & (txq->q.n_bd - 1); int freed = 0; + spin_lock(&txq->lock); + txq->time_stamp = jiffies; if (unlikely(txq_id >= IWLAGN_FIRST_AMPDU_QUEUE && @@ -1574,6 +1579,7 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, IWL_DEBUG_TX_QUEUES(trans, "Bad queue mapping txq_id %d, " "agg_txq[sta_id[tid] %d", txq_id, trans_pcie->agg_txq[sta_id][tid]); + spin_unlock(&txq->lock); return 1; } @@ -1587,6 +1593,8 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, status != TX_STATUS_FAIL_PASSIVE_NO_RX)) iwl_wake_queue(trans, txq, "Packets reclaimed"); } + + spin_unlock(&txq->lock); return 0; } @@ -2267,7 +2275,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, trans->ops = &trans_ops_pcie; trans->shrd = shrd; trans_pcie->trans = trans; - spin_lock_init(&trans->hcmd_lock); spin_lock_init(&trans_pcie->irq_lock); /* W/A - seems to solve weird behavior. We need to remove this if we diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 4e7e6c0eede9..e2f21cfc2cd4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -309,7 +309,6 @@ enum iwl_trans_state { * @ops - pointer to iwl_trans_ops * @op_mode - pointer to the op_mode * @shrd - pointer to iwl_shared which holds shared data from the upper layer - * @hcmd_lock: protects HCMD * @reg_lock - protect hw register access * @dev - pointer to struct device * that represents the device * @irq - the irq number for the device @@ -326,7 +325,6 @@ struct iwl_trans { struct iwl_op_mode *op_mode; struct iwl_shared *shrd; enum iwl_trans_state state; - spinlock_t hcmd_lock; spinlock_t reg_lock; struct device *dev; -- GitLab From fa23cb04b38a9950b21ee756e4419a737d496371 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:25 -0800 Subject: [PATCH 1408/1846] iwlwifi: make sta lock private & BH lock Now that the transport has its own locking, there's no need to have the sta_lock in the shared data. Also, it can be a BH lock as it's not used from IRQ handlers. 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 | 141 +++++++++------------ drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 46 +++---- drivers/net/wireless/iwlwifi/iwl-agn.c | 7 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 6 + drivers/net/wireless/iwlwifi/iwl-shared.h | 3 - 5 files changed, 88 insertions(+), 115 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 6b9af994cfa4..4bd50daeac1a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -34,9 +34,10 @@ #include "iwl-agn.h" #include "iwl-trans.h" -/* priv->shrd->sta_lock must be held */ static int iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) { + lockdep_assert_held(&priv->sta_lock); + if (sta_id >= IWLAGN_STATION_COUNT) { IWL_ERR(priv, "invalid sta_id %u", sta_id); return -EINVAL; @@ -64,7 +65,6 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, struct iwl_rx_packet *pkt) { u8 sta_id = addsta->sta.sta_id; - unsigned long flags; int ret = -EIO; if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { @@ -76,7 +76,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n", sta_id); - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock(&priv->sta_lock); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: @@ -118,7 +118,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, priv->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock(&priv->sta_lock); return ret; } @@ -317,18 +317,17 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_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_addsta_cmd sta_cmd; *sta_id_r = 0; - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); sta_id = iwl_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", addr); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); return -EINVAL; } @@ -340,7 +339,7 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { IWL_DEBUG_INFO(priv, "STA %d already in process of being " "added.\n", sta_id); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); return -EEXIST; } @@ -348,24 +347,24 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not " "adding again.\n", sta_id, addr); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); return -EEXIST; } priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS; memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd)); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); /* Add station to device's station table */ ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) { - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); IWL_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; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); } *sta_id_r = sta_id; return ret; @@ -373,11 +372,11 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, /** * iwl_sta_ucode_deactivate - deactivate ucode status for a station - * - * priv->shrd->sta_lock must be held */ static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id) { + lockdep_assert_held(&priv->sta_lock); + /* Ucode must be active and driver must be non active */ if ((priv->stations[sta_id].used & (IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) != @@ -396,8 +395,6 @@ static int iwl_send_remove_station(struct iwl_priv *priv, { struct iwl_rx_packet *pkt; int ret; - - unsigned long flags_spin; struct iwl_rem_sta_cmd rm_sta_cmd; struct iwl_host_cmd cmd = { @@ -429,11 +426,9 @@ static int iwl_send_remove_station(struct iwl_priv *priv, switch (pkt->u.rem_sta.status) { case REM_STA_SUCCESS_MSK: if (!temporary) { - spin_lock_irqsave(&priv->shrd->sta_lock, - flags_spin); + spin_lock_bh(&priv->sta_lock); iwl_sta_ucode_deactivate(priv, sta_id); - spin_unlock_irqrestore(&priv->shrd->sta_lock, - flags_spin); + spin_unlock_bh(&priv->sta_lock); } IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); break; @@ -454,7 +449,6 @@ static int iwl_send_remove_station(struct iwl_priv *priv, int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, const u8 *addr) { - unsigned long flags; u8 tid; if (!iwl_is_ready(priv->shrd)) { @@ -475,7 +469,7 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, if (WARN_ON(sta_id == IWL_INVALID_STATION)) return -EINVAL; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", @@ -505,11 +499,11 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, if (WARN_ON(priv->num_stations < 0)) priv->num_stations = 0; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return iwl_send_remove_station(priv, addr, sta_id, false); out_err: - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return -EINVAL; } @@ -525,12 +519,11 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { int i; - unsigned long flags_spin; bool cleared = false; IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); for (i = 0; i < IWLAGN_STATION_COUNT; i++) { if (ctx && ctx->ctxid != priv->stations[i].ctxid) continue; @@ -542,7 +535,7 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv, cleared = true; } } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); if (!cleared) IWL_DEBUG_INFO(priv, @@ -561,7 +554,6 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { struct iwl_addsta_cmd sta_cmd; struct iwl_link_quality_cmd lq; - unsigned long flags_spin; int i; bool found = false; int ret; @@ -574,7 +566,7 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) } IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); for (i = 0; i < IWLAGN_STATION_COUNT; i++) { if (ctx->ctxid != priv->stations[i].ctxid) continue; @@ -601,20 +593,17 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) sizeof(struct iwl_link_quality_cmd)); send_lq = true; } - spin_unlock_irqrestore(&priv->shrd->sta_lock, - flags_spin); + spin_unlock_bh(&priv->sta_lock); ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) { - spin_lock_irqsave(&priv->shrd->sta_lock, - flags_spin); + spin_lock_bh(&priv->sta_lock); IWL_ERR(priv, "Adding station %pM failed.\n", priv->stations[i].sta.sta.addr); priv->stations[i].used &= ~IWL_STA_DRIVER_ACTIVE; priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->shrd->sta_lock, - flags_spin); + spin_unlock_bh(&priv->sta_lock); } /* * Rate scaling has already been initialized, send @@ -623,12 +612,12 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) if (send_lq) iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; } } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); if (!found) IWL_DEBUG_INFO(priv, "Restoring all known stations .... " "no stations to be restored.\n"); @@ -639,16 +628,15 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { - unsigned long flags; int sta_id = ctx->ap_sta_id; int ret; struct iwl_addsta_cmd sta_cmd; struct iwl_link_quality_cmd lq; bool active, have_lq = false; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return; } @@ -661,7 +649,7 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE; priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); if (active) { ret = iwl_send_remove_station( @@ -671,9 +659,9 @@ void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) IWL_ERR(priv, "failed to remove STA %pM (%d)\n", priv->stations[sta_id].sta.sta.addr, ret); } - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) @@ -696,10 +684,9 @@ int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) void iwl_dealloc_bcast_stations(struct iwl_priv *priv) { - unsigned long flags; int i; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); for (i = 0; i < IWLAGN_STATION_COUNT; i++) { if (!(priv->stations[i].used & IWL_STA_BCAST)) continue; @@ -711,7 +698,7 @@ void iwl_dealloc_bcast_stations(struct iwl_priv *priv) kfree(priv->stations[i].lq); priv->stations[i].lq = NULL; } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); } #ifdef CONFIG_IWLWIFI_DEBUG @@ -783,8 +770,6 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, struct iwl_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; - unsigned long flags_spin; - struct iwl_host_cmd cmd = { .id = REPLY_TX_LINK_QUALITY_CMD, .len = { sizeof(struct iwl_link_quality_cmd), }, @@ -796,12 +781,12 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return -EINVAL; - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); if (!(priv->stations[lq->sta_id].used & IWL_STA_DRIVER_ACTIVE)) { - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); return -EINVAL; } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); iwl_dump_lq_cmd(priv, lq); if (WARN_ON(init && (cmd.flags & CMD_ASYNC))) @@ -819,9 +804,9 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, IWL_DEBUG_INFO(priv, "init LQ command complete, " "clearing sta addition status for sta %d\n", lq->sta_id); - spin_lock_irqsave(&priv->shrd->sta_lock, flags_spin); + spin_lock_bh(&priv->sta_lock); priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags_spin); + spin_unlock_bh(&priv->sta_lock); } return ret; } @@ -906,7 +891,6 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv, int ret; u8 sta_id; struct iwl_link_quality_cmd *link_cmd; - unsigned long flags; if (sta_id_r) *sta_id_r = IWL_INVALID_STATION; @@ -920,9 +904,9 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv, if (sta_id_r) *sta_id_r = sta_id; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); priv->stations[sta_id].used |= IWL_STA_LOCAL; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); /* Set up default rate scaling table in device's station table */ link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id); @@ -937,9 +921,9 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv, if (ret) IWL_ERR(priv, "Link quality command failed (%d)\n", ret); - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return 0; } @@ -1100,14 +1084,13 @@ static int iwlagn_send_sta_key(struct iwl_priv *priv, u8 sta_id, u32 tkip_iv32, u16 *tkip_p1k, u32 cmd_flags) { - unsigned long flags; __le16 key_flags; struct iwl_addsta_cmd sta_cmd; int i; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); key_flags = cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); key_flags |= STA_KEY_FLG_MAP_KEY_MSK; @@ -1174,7 +1157,6 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta) { - unsigned long flags; struct iwl_addsta_cmd sta_cmd; u8 sta_id = iwlagn_key_sta_id(priv, ctx->vif, sta); __le16 key_flags; @@ -1183,11 +1165,11 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, if (sta_id == IWL_INVALID_STATION) return -ENOENT; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) sta_id = IWL_INVALID_STATION; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); if (sta_id == IWL_INVALID_STATION) return 0; @@ -1287,21 +1269,20 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { struct iwl_link_quality_cmd *link_cmd; - unsigned long flags; u8 sta_id; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); sta_id = iwl_prep_station(priv, ctx, iwl_bcast_addr, false, NULL); if (sta_id == IWL_INVALID_STATION) { IWL_ERR(priv, "Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return -EINVAL; } priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; priv->stations[sta_id].used |= IWL_STA_BCAST; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id); if (!link_cmd) { @@ -1310,9 +1291,9 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv, return -ENOMEM; } - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return 0; } @@ -1326,7 +1307,6 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv, int iwl_update_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { - unsigned long flags; struct iwl_link_quality_cmd *link_cmd; u8 sta_id = ctx->bcast_sta_id; @@ -1336,13 +1316,13 @@ int iwl_update_bcast_station(struct iwl_priv *priv, return -ENOMEM; } - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); if (priv->stations[sta_id].lq) kfree(priv->stations[sta_id].lq); else IWL_DEBUG_INFO(priv, "Bcast station rate scaling has not been initialized yet.\n"); priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return 0; } @@ -1366,18 +1346,17 @@ int iwl_update_bcast_stations(struct iwl_priv *priv) */ int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) { - unsigned long flags; struct iwl_addsta_cmd sta_cmd; lockdep_assert_held(&priv->shrd->mutex); /* Remove "disable" flag, to enable Tx for this TID */ - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); 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, sizeof(struct iwl_addsta_cmd)); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); } @@ -1385,7 +1364,6 @@ int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, int tid, u16 ssn) { - unsigned long flags; int sta_id; struct iwl_addsta_cmd sta_cmd; @@ -1395,14 +1373,14 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, if (sta_id == IWL_INVALID_STATION) return -ENXIO; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); 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, sizeof(struct iwl_addsta_cmd)); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); } @@ -1410,7 +1388,6 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, int tid) { - unsigned long flags; int sta_id; struct iwl_addsta_cmd sta_cmd; @@ -1422,13 +1399,13 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, return -ENXIO; } - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); 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, sizeof(struct iwl_addsta_cmd)); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 59509d80f73f..4e69189a631d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -370,7 +370,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) info->driver_data[1] = dev_cmd; /* irqs already disabled/saved above when locking priv->shrd->lock */ - spin_lock(&priv->shrd->sta_lock); + spin_lock(&priv->sta_lock); if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc)) { u8 *qc = NULL; @@ -417,7 +417,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) !ieee80211_has_morefrags(fc)) priv->tid_data[sta_id][tid].seq_number = seq_number; - spin_unlock(&priv->shrd->sta_lock); + spin_unlock(&priv->sta_lock); spin_unlock_irqrestore(&priv->shrd->lock, flags); /* @@ -435,7 +435,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) drop_unlock_sta: if (dev_cmd) kmem_cache_free(priv->tx_cmd_pool, dev_cmd); - spin_unlock(&priv->shrd->sta_lock); + spin_unlock(&priv->sta_lock); drop_unlock_priv: spin_unlock_irqrestore(&priv->shrd->lock, flags); return -1; @@ -455,7 +455,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, return -ENXIO; } - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); tid_data = &priv->tid_data[sta_id][tid]; @@ -475,7 +475,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, IWL_WARN(priv, "Stopping AGG while state not ON " "or starting for %d on %d (%d)\n", sta_id, tid, priv->tid_data[sta_id][tid].agg.state); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return 0; } @@ -489,7 +489,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, tid_data->next_reclaimed); priv->tid_data[sta_id][tid].agg.state = IWL_EMPTYING_HW_QUEUE_DELBA; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return 0; } @@ -498,12 +498,10 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, turn_off: priv->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF; - /* do not restore/save irqs */ - spin_unlock(&priv->shrd->sta_lock); - spin_lock(&priv->shrd->lock); + spin_unlock_bh(&priv->sta_lock); + spin_lock_irqsave(&priv->shrd->lock, flags); iwl_trans_tx_agg_disable(trans(priv), sta_id, tid); - spin_unlock_irqrestore(&priv->shrd->lock, flags); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); @@ -515,7 +513,6 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn) { struct iwl_tid_data *tid_data; - unsigned long flags; int sta_id; int ret; @@ -539,7 +536,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, if (ret) return ret; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); tid_data = &priv->tid_data[sta_id][tid]; tid_data->agg.ssn = SEQ_TO_SN(tid_data->seq_number); @@ -548,7 +545,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, ret = iwl_trans_tx_agg_alloc(trans(priv), sta_id, tid); if (ret) { - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return ret; } @@ -565,7 +562,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); return ret; } @@ -575,14 +572,13 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif, { struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); - unsigned long flags; u16 ssn; buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); ssn = priv->tid_data[sta_priv->sta_id][tid].agg.ssn; - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, sta_priv->sta_id, tid, buf_size, ssn); @@ -638,7 +634,7 @@ static void iwlagn_check_ratid_empty(struct iwl_priv *priv, int sta_id, u8 tid) struct ieee80211_vif *vif; u8 *addr; - lockdep_assert_held(&priv->shrd->sta_lock); + lockdep_assert_held(&priv->sta_lock); addr = priv->stations[sta_id].sta.sta.addr; ctx = priv->stations[sta_id].ctxid; @@ -1005,7 +1001,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, int sta_id; int freed; struct ieee80211_tx_info *info; - unsigned long flags; struct sk_buff_head skbs; struct sk_buff *skb; struct iwl_rxon_context *ctx; @@ -1016,7 +1011,7 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, sta_id = (tx_resp->ra_tid & IWLAGN_TX_RES_RA_MSK) >> IWLAGN_TX_RES_RA_POS; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock(&priv->sta_lock); if (is_agg) iwl_rx_reply_tx_agg(priv, tx_resp); @@ -1106,7 +1101,7 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, } iwl_check_abort_status(priv, tx_resp->frame_count, status); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock(&priv->sta_lock); return 0; } @@ -1127,7 +1122,6 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, struct ieee80211_tx_info *info; struct ieee80211_hdr *hdr; struct sk_buff *skb; - unsigned long flags; int sta_id; int tid; int freed; @@ -1149,12 +1143,12 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, tid = ba_resp->tid; agg = &priv->tid_data[sta_id][tid].agg; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock(&priv->sta_lock); if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) IWL_ERR(priv, "Received BA when not expected\n"); - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock(&priv->sta_lock); return 0; } @@ -1165,7 +1159,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, * transmitted ... if not, it's too late anyway). */ if (iwl_trans_reclaim(trans(priv), sta_id, tid, scd_flow, ba_resp_scd_ssn, 0, &reclaimed_skbs)) { - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock(&priv->sta_lock); return 0; } @@ -1230,6 +1224,6 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, ieee80211_tx_status_irqsafe(priv->hw, skb); } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock(&priv->sta_lock); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index a7f3a7023d88..0090fab3aacb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -749,10 +749,9 @@ int iwl_alive_start(struct iwl_priv *priv) */ static void iwl_clear_driver_stations(struct iwl_priv *priv) { - unsigned long flags; struct iwl_rxon_context *ctx; - spin_lock_irqsave(&priv->shrd->sta_lock, flags); + spin_lock_bh(&priv->sta_lock); memset(priv->stations, 0, sizeof(priv->stations)); priv->num_stations = 0; @@ -770,7 +769,7 @@ static void iwl_clear_driver_stations(struct iwl_priv *priv) ctx->key_mapping_keys = 0; } - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); + spin_unlock_bh(&priv->sta_lock); } void iwl_down(struct iwl_priv *priv) @@ -1039,7 +1038,7 @@ static int iwl_init_drv(struct iwl_priv *priv) { int ret; - spin_lock_init(&priv->shrd->sta_lock); + spin_lock_init(&priv->sta_lock); mutex_init(&priv->shrd->mutex); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 6e5bf0a14609..dc57522594a6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -719,6 +719,12 @@ struct iwl_priv { /*data shared among all the driver's layers */ struct iwl_shared *shrd; + /* + * protects the station table, if shrd->lock and sta_lock are + * needed, shrd->lock must be acquired first + */ + spinlock_t sta_lock; + /* ieee device used by generic ieee processing code */ struct ieee80211_hw *hw; struct ieee80211_channel *ieee_channels; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index a6441623e6b1..3a0f0a4c58d3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -360,8 +360,6 @@ struct iwl_cfg { * @nic: pointer to the nic data * @hw_params: see struct iwl_hw_params * @lock: protect general shared data - * @sta_lock: protects the station table. - * If lock and sta_lock are needed, lock must be acquired first. * @mutex: * @wait_command_queue: the wait_queue for SYNC host command nad uCode load * @eeprom: pointer to the eeprom/OTP image @@ -391,7 +389,6 @@ struct iwl_shared { struct iwl_hw_params hw_params; spinlock_t lock; - spinlock_t sta_lock; struct mutex mutex; wait_queue_head_t wait_command_queue; -- GitLab From 4ff70fcdf3c424c3fdca253e7b7556f77eaf39be Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:26 -0800 Subject: [PATCH 1409/1846] iwlwifi: introduce statistics lock The statistics are currently only half-heartedly locked against concurrent reading & modification so introduce a lock to really protect them. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 16 +++++++-------- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 ++ drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 8 ++++++++ drivers/net/wireless/iwlwifi/iwl-agn.c | 1 + drivers/net/wireless/iwlwifi/iwl-debugfs.c | 21 ++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-dev.h | 1 + 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 988ee454a944..12acc81ed419 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -655,7 +655,6 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv) struct iwl_sensitivity_data *data = NULL; struct statistics_rx_non_phy *rx_info; struct statistics_rx_phy *ofdm, *cck; - unsigned long flags; struct statistics_general_data statis; if (priv->disable_sens_cal) @@ -668,13 +667,13 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv) return; } - spin_lock_irqsave(&priv->shrd->lock, flags); + spin_lock_bh(&priv->statistics.lock); rx_info = &priv->statistics.rx_non_phy; ofdm = &priv->statistics.rx_ofdm; cck = &priv->statistics.rx_cck; if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { IWL_DEBUG_CALIB(priv, "<< invalid data.\n"); - spin_unlock_irqrestore(&priv->shrd->lock, flags); + spin_unlock_bh(&priv->statistics.lock); return; } @@ -698,7 +697,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv) statis.beacon_energy_c = le32_to_cpu(rx_info->beacon_energy_c); - spin_unlock_irqrestore(&priv->shrd->lock, flags); + spin_unlock_bh(&priv->statistics.lock); IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); @@ -958,7 +957,6 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) u16 stat_chnum = INITIALIZATION_VALUE; u8 rxon_band24; u8 stat_band24; - unsigned long flags; struct statistics_rx_non_phy *rx_info; /* @@ -983,13 +981,13 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) return; } - spin_lock_irqsave(&priv->shrd->lock, flags); + spin_lock_bh(&priv->statistics.lock); rx_info = &priv->statistics.rx_non_phy; if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); - spin_unlock_irqrestore(&priv->shrd->lock, flags); + spin_unlock_bh(&priv->statistics.lock); return; } @@ -1004,7 +1002,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); - spin_unlock_irqrestore(&priv->shrd->lock, flags); + spin_unlock_bh(&priv->statistics.lock); return; } @@ -1023,7 +1021,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) 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->shrd->lock, flags); + spin_unlock_bh(&priv->statistics.lock); data->beacon_count++; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 5be0d3695d03..0f8dd0f96fa6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -88,6 +88,8 @@ int iwlagn_send_tx_power(struct iwl_priv *priv) void iwlagn_temperature(struct iwl_priv *priv) { + lockdep_assert_held(&priv->statistics.lock); + /* store temperature from correct statistics (in Celsius) */ priv->temperature = le32_to_cpu(priv->statistics.common.temperature); iwl_tt_handler(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 30bb5bbb0cd7..bc21586aed63 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -266,6 +266,8 @@ static bool iwlagn_good_ack_health(struct iwl_priv *priv, if (priv->agg_tids_count) return true; + lockdep_assert_held(&priv->statistics.lock); + old = &priv->statistics.tx; actual_delta = le32_to_cpu(cur->actual_ack_cnt) - @@ -509,6 +511,8 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n", len); + spin_lock(&priv->statistics.lock); + if (len == sizeof(struct iwl_bt_notif_statistics)) { struct iwl_bt_notif_statistics *stats; stats = &pkt->u.stats_bt; @@ -542,6 +546,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, WARN_ONCE(1, "len %d doesn't match BT (%zu) or normal (%zu)\n", len, sizeof(struct iwl_bt_notif_statistics), sizeof(struct iwl_notif_statistics)); + spin_unlock(&priv->statistics.lock); return 0; } @@ -585,6 +590,9 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, } if (cfg(priv)->lib->temperature && change) cfg(priv)->lib->temperature(priv); + + spin_unlock(&priv->statistics.lock); + return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 0090fab3aacb..47c788607024 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1233,6 +1233,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) */ spin_lock_init(&trans(priv)->reg_lock); spin_lock_init(&priv->shrd->lock); + spin_lock_init(&priv->statistics.lock); /*********************** * 3. Read REV register diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index ad74138e1c70..628af563e4e1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -920,6 +920,8 @@ static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) int p = 0; u32 flag; + lockdep_assert_held(&priv->statistics.lock); + flag = le32_to_cpu(priv->statistics.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); @@ -967,6 +969,7 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ + spin_lock_bh(&priv->statistics.lock); ofdm = &priv->statistics.rx_ofdm; cck = &priv->statistics.rx_cck; general = &priv->statistics.rx_non_phy; @@ -1363,6 +1366,8 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, accum_ht->unsupport_mcs, delta_ht->unsupport_mcs, max_ht->unsupport_mcs); + spin_unlock_bh(&priv->statistics.lock); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -1392,6 +1397,8 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ + spin_lock_bh(&priv->statistics.lock); + tx = &priv->statistics.tx; accum_tx = &priv->accum_stats.tx; delta_tx = &priv->delta_stats.tx; @@ -1554,6 +1561,9 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, fmt_hex, "antenna C:", tx->tx_power.ant_c); } + + spin_unlock_bh(&priv->statistics.lock); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -1586,6 +1596,9 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ + + spin_lock_bh(&priv->statistics.lock); + general = &priv->statistics.common; dbg = &priv->statistics.common.dbg; div = &priv->statistics.common.div; @@ -1670,6 +1683,9 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, accum_general->num_of_sos_states, delta_general->num_of_sos_states, max_general->num_of_sos_states); + + spin_unlock_bh(&priv->statistics.lock); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -1713,6 +1729,9 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ + + spin_lock_bh(&priv->statistics.lock); + bt = &priv->statistics.bt_activity; accum_bt = &priv->accum_stats.bt_activity; @@ -1758,6 +1777,8 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, le32_to_cpu(priv->statistics.num_bt_kills), priv->statistics.accum_num_bt_kills); + spin_unlock_bh(&priv->statistics.lock); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index dc57522594a6..daf233026b5e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -851,6 +851,7 @@ struct iwl_priv { struct statistics_bt_activity bt_activity; __le32 num_bt_kills, accum_num_bt_kills; #endif + spinlock_t lock; } statistics; #ifdef CONFIG_IWLWIFI_DEBUGFS struct { -- GitLab From 08ae86ac3f9d9c9a60d2883c82cd72a5c66b94db Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:27 -0800 Subject: [PATCH 1410/1846] iwlwifi: remove shared lock Some data doesn't need protection, some of the lock places are simply useless, and some data can be protected with the mutex instead. Thus the shared lock can be removed by making those changes. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-5000.c | 7 ------- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 3 --- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 3 --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 6 ------ drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 9 --------- drivers/net/wireless/iwlwifi/iwl-agn.c | 5 +---- drivers/net/wireless/iwlwifi/iwl-dev.h | 4 ---- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 9 ++------- drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - 9 files changed, 3 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 1527dec7a267..ccaeead29c2f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -63,12 +63,8 @@ /* NIC configuration for 5000 series */ static void iwl5000_nic_config(struct iwl_priv *priv) { - unsigned long flags; - iwl_rf_config(priv); - spin_lock_irqsave(&priv->shrd->lock, flags); - /* W/A : NIC is stuck in a reset state after Early PCIe power off * (PCIe power is lost before PERST# is asserted), * causing ME FW to lose ownership and not being able to obtain it back. @@ -76,9 +72,6 @@ static void iwl5000_nic_config(struct iwl_priv *priv) iwl_set_bits_mask_prph(trans(priv), APMG_PS_CTRL_REG, APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS, ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); - - - spin_unlock_irqrestore(&priv->shrd->lock, flags); } static struct iwl_sensitivity_ranges iwl5000_sensitivity = { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 0f8dd0f96fa6..2470ca767589 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -710,7 +710,6 @@ int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd) { - unsigned long flags; struct iwl_rx_packet *pkt = rxb_addr(rxb); struct iwl_bt_coex_profile_notif *coex = &pkt->u.bt_coex_profile_notif; struct iwl_bt_uart_msg *uart_msg = &coex->last_bt_uart_msg; @@ -756,9 +755,7 @@ int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, /* FIXME: based on notification, adjust the prio_boost */ - spin_lock_irqsave(&priv->shrd->lock, flags); priv->bt_ci_compliance = coex->bt_ci_compliance; - spin_unlock_irqrestore(&priv->shrd->lock, flags); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index a7d67135e3dc..9895b807246b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -870,19 +870,16 @@ static void rs_bt_update_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, { struct iwl_scale_tbl_info *tbl; bool full_concurrent = priv->bt_full_concurrent; - unsigned long flags; if (priv->bt_ant_couple_ok) { /* * Is there a need to switch between * full concurrency and 3-wire? */ - spin_lock_irqsave(&priv->shrd->lock, flags); if (priv->bt_ci_compliance && priv->bt_ant_couple_ok) full_concurrent = true; else full_concurrent = false; - spin_unlock_irqrestore(&priv->shrd->lock, flags); } if ((priv->bt_traffic_load != priv->last_bt_traffic_load) || (priv->bt_full_concurrent != full_concurrent)) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 73653a6cf32d..a8c790028d53 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -590,8 +590,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) } if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { - unsigned long flags; - ch_info = iwl_get_channel_info(priv, channel->band, channel->hw_value); if (!is_channel_valid(ch_info)) { @@ -600,8 +598,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) goto out; } - spin_lock_irqsave(&priv->shrd->lock, flags); - for_each_context(priv, ctx) { /* Configure HT40 channels */ if (ctx->ht.enabled != conf_is_ht(conf)) @@ -636,8 +632,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) ctx->vif); } - spin_unlock_irqrestore(&priv->shrd->lock, flags); - iwl_update_bcast_stations(priv); /* diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 4e69189a631d..2b722ccb730a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -259,18 +259,15 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; struct iwl_device_cmd *dev_cmd = NULL; struct iwl_tx_cmd *tx_cmd; - __le16 fc; u8 hdr_len; u16 len, seq_number = 0; u8 sta_id, tid = IWL_MAX_TID_COUNT; - unsigned long flags; bool is_agg = false; if (info->control.vif) ctx = iwl_rxon_ctx_from_vif(info->control.vif); - spin_lock_irqsave(&priv->shrd->lock, flags); if (iwl_is_rfkill(priv->shrd)) { IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); goto drop_unlock_priv; @@ -369,7 +366,6 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) info->driver_data[0] = ctx; info->driver_data[1] = dev_cmd; - /* irqs already disabled/saved above when locking priv->shrd->lock */ spin_lock(&priv->sta_lock); if (ieee80211_is_data_qos(fc) && !ieee80211_is_qos_nullfunc(fc)) { @@ -418,7 +414,6 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) priv->tid_data[sta_id][tid].seq_number = seq_number; spin_unlock(&priv->sta_lock); - spin_unlock_irqrestore(&priv->shrd->lock, flags); /* * Avoid atomic ops if it isn't an associated client. @@ -437,7 +432,6 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) kmem_cache_free(priv->tx_cmd_pool, dev_cmd); spin_unlock(&priv->sta_lock); drop_unlock_priv: - spin_unlock_irqrestore(&priv->shrd->lock, flags); return -1; } @@ -445,7 +439,6 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid) { struct iwl_tid_data *tid_data; - unsigned long flags; int sta_id; sta_id = iwl_sta_id(sta); @@ -500,9 +493,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, spin_unlock_bh(&priv->sta_lock); - spin_lock_irqsave(&priv->shrd->lock, flags); iwl_trans_tx_agg_disable(trans(priv), sta_id, tid); - spin_unlock_irqrestore(&priv->shrd->lock, flags); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 47c788607024..ada9d9e4402b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -552,13 +552,11 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv) { struct iwl_ct_kill_config cmd; struct iwl_ct_kill_throttling_config adv_cmd; - unsigned long flags; int ret = 0; - spin_lock_irqsave(&priv->shrd->lock, flags); iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - spin_unlock_irqrestore(&priv->shrd->lock, flags); + priv->thermal_throttle.ct_kill_toggle = false; if (cfg(priv)->base_params->support_ct_kill_exit) { @@ -1232,7 +1230,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) * we should init now */ spin_lock_init(&trans(priv)->reg_lock); - spin_lock_init(&priv->shrd->lock); spin_lock_init(&priv->statistics.lock); /*********************** diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index daf233026b5e..5b537dbe0af4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -719,10 +719,6 @@ struct iwl_priv { /*data shared among all the driver's layers */ struct iwl_shared *shrd; - /* - * protects the station table, if shrd->lock and sta_lock are - * needed, shrd->lock must be acquired first - */ spinlock_t sta_lock; /* ieee device used by generic ieee processing code */ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 9fba532d35cd..dcee30f0d629 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -779,8 +779,6 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, goto out; } - spin_lock_irq(&priv->shrd->lock); - priv->current_ht_config.smps = conf->smps_mode; /* Configure HT40 channels */ @@ -797,8 +795,6 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, iwl_set_rxon_ht(priv, ht_conf); iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); - spin_unlock_irq(&priv->shrd->lock); - iwl_set_rate(priv); /* * at this point, staging_rxon has the @@ -1133,7 +1129,6 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *ctx = vif_priv->ctx; - unsigned long flags; int q; if (WARN_ON(!ctx)) @@ -1153,7 +1148,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, q = AC_NUM - 1 - queue; - spin_lock_irqsave(&priv->shrd->lock, flags); + mutex_lock(&priv->shrd->mutex); ctx->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); @@ -1165,7 +1160,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; - spin_unlock_irqrestore(&priv->shrd->lock, flags); + mutex_unlock(&priv->shrd->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 3a0f0a4c58d3..7720fc34c278 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -388,7 +388,6 @@ struct iwl_shared { struct iwl_nic *nic; struct iwl_hw_params hw_params; - spinlock_t lock; struct mutex mutex; wait_queue_head_t wait_command_queue; -- GitLab From 5c40d8603d8ed03aa851d20ad8a9155fc79a1b07 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:28 -0800 Subject: [PATCH 1411/1846] iwlwifi: make EXIT_PENDING depend on mac80211 There's no reason to set EXIT_PENDING when we start removing the module, as mac80211 will cleanly shut down the device in this case. Additionally, there's no point in rejecting commands to the device when we're cleaning up as that only leads to unwanted errors from mac80211 being printed, such as failed to remove key (...) from hardware (-16) Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 6 ------ drivers/net/wireless/iwlwifi/iwl-agn.c | 6 ------ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ---- drivers/net/wireless/iwlwifi/iwl-scan.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 7 ------- 5 files changed, 1 insertion(+), 25 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index a8c790028d53..7a86a359e573 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -422,9 +422,6 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) lockdep_assert_held(&priv->shrd->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - return -EINVAL; - if (!iwl_is_alive(priv->shrd)) return -EBUSY; @@ -560,9 +557,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&priv->shrd->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - goto out; - if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); goto out; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ada9d9e4402b..c14eda048948 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1378,12 +1378,6 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) iwl_dbgfs_unregister(priv); - /* ieee80211_unregister_hw call wil cause iwlagn_mac_stop to - * to be called and iwl_down since we are removing the device - * we need to set STATUS_EXIT_PENDING bit. - */ - set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); - iwl_testmode_cleanup(priv); iwlagn_mac_unregister(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index dcee30f0d629..7f63ba93ba5d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -649,8 +649,6 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_RX_STOP: IWL_DEBUG_HT(priv, "stop Rx\n"); ret = iwl_sta_rx_agg_stop(priv, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - ret = 0; break; case IEEE80211_AMPDU_TX_START: if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) @@ -666,8 +664,6 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", priv->agg_tids_count); } - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) - ret = 0; if (!priv->agg_tids_count && cfg(priv)->ht_params && cfg(priv)->ht_params->use_rts_for_aggregation) { /* diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 42ee1c410efd..766572b9ac89 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -69,8 +69,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) if (!test_bit(STATUS_READY, &priv->shrd->status) || !test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status) || !test_bit(STATUS_SCAN_HW, &priv->shrd->status) || - test_bit(STATUS_FW_ERROR, &priv->shrd->status) || - test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + test_bit(STATUS_FW_ERROR, &priv->shrd->status)) return -EIO; ret = iwl_trans_send_cmd(trans(priv), &cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 1cb1dd29b3fe..de2a0d91d658 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -914,9 +914,6 @@ static int iwl_send_cmd_async(struct iwl_trans *trans, struct iwl_host_cmd *cmd) return -EINVAL; - if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status)) - return -EBUSY; - ret = iwl_enqueue_hcmd(trans, cmd); if (ret < 0) { IWL_DEBUG_QUIET_RFKILL(trans, @@ -938,10 +935,6 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", get_cmd_string(cmd->id)); - if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status)) - return -EBUSY; - - if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", get_cmd_string(cmd->id)); -- GitLab From fb5fe5b9da167f25fd44818327338eeec20c2a5a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:29 -0800 Subject: [PATCH 1412/1846] iwlwifi: simplify auth/assoc flow With mac80211 now giving us station information (via the sta_state callback) before auth/assoc we can get rid of tx_sync by adding the station early for the case of managed interfaces. Keep AP mode actions the same for now. As we now get the BSSID early, we can also get rid of iwl_reprogram_ap_sta(). We can still optimise the number of RXONs we send to the device, but that can be done later. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 7 - drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 45 ----- drivers/net/wireless/iwlwifi/iwl-agn.h | 1 - drivers/net/wireless/iwlwifi/iwl-dev.h | 3 - drivers/net/wireless/iwlwifi/iwl-mac80211.c | 207 +++++++++----------- 5 files changed, 90 insertions(+), 173 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 7a86a359e573..e806ad82e7e3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -274,8 +274,6 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv, } memcpy(active, &ctx->staging, sizeof(*active)); - iwl_reprogram_ap_sta(priv, ctx); - /* IBSS beacon needs to be sent after setting assoc */ if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC)) if (iwlagn_update_beacon(priv, ctx->vif)) @@ -431,10 +429,6 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) if (!ctx->is_active) return 0; - /* override BSSID if necessary due to preauth */ - if (ctx->preauth_bssid) - memcpy(ctx->staging.bssid_addr, ctx->bssid, ETH_ALEN); - /* always get timestamp with Rx frame */ ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; @@ -920,7 +914,6 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, if (!priv->disable_chain_noise_cal) iwlagn_chain_noise_reset(priv); priv->start_calib = 1; - WARN_ON(ctx->preauth_bssid); } if (changes & BSS_CHANGED_IBSS) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 4bd50daeac1a..222a8f46365f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -626,51 +626,6 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) "complete.\n"); } -void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx) -{ - int sta_id = ctx->ap_sta_id; - int ret; - struct iwl_addsta_cmd sta_cmd; - struct iwl_link_quality_cmd lq; - bool active, have_lq = false; - - spin_lock_bh(&priv->sta_lock); - if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { - spin_unlock_bh(&priv->sta_lock); - return; - } - - memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); - sta_cmd.mode = 0; - if (priv->stations[sta_id].lq) { - memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); - have_lq = true; - } - - active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE; - priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; - spin_unlock_bh(&priv->sta_lock); - - if (active) { - ret = iwl_send_remove_station( - priv, priv->stations[sta_id].sta.sta.addr, - sta_id, true); - if (ret) - IWL_ERR(priv, "failed to remove STA %pM (%d)\n", - priv->stations[sta_id].sta.sta.addr, ret); - } - spin_lock_bh(&priv->sta_lock); - priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; - spin_unlock_bh(&priv->sta_lock); - - ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); - if (ret) - IWL_ERR(priv, "failed to re-add STA %pM (%d)\n", - priv->stations[sta_id].sta.sta.addr, ret); - if (have_lq) - iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); -} - int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) { int i; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index ef0cdf5b32fa..a142a197b2e4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -227,7 +227,6 @@ void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id, struct iwl_link_quality_cmd *link_cmd); int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, struct iwl_link_quality_cmd *lq, u8 flags, bool init); -void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx); int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 5b537dbe0af4..9ea9002cc839 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -671,9 +671,6 @@ struct iwl_rxon_context { u8 extension_chan_offset; } ht; - u8 bssid[ETH_ALEN]; - bool preauth_bssid; - bool last_tx_rejected; }; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 7f63ba93ba5d..005763fa38ab 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -692,12 +692,9 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; bool is_ap = vif->type == NL80211_IFTYPE_STATION; - int ret = 0; + int ret; u8 sta_id; - IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", - sta->addr); - mutex_lock(&priv->shrd->mutex); IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", sta->addr); sta_priv->sta_id = IWL_INVALID_STATION; @@ -712,16 +709,98 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, IWL_ERR(priv, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ - goto out; + return ret; } sta_priv->sta_id = sta_id; - /* Initialize rate scaling */ - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", - sta->addr); - iwl_rs_rate_init(priv, sta, sta_id); - out: + return 0; +} + +static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; + int ret; + + IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", + sta->addr); + ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); + if (ret) + IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", + sta->addr); + return ret; +} + +static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + enum ieee80211_sta_state old_state, + enum ieee80211_sta_state new_state) +{ + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); + enum { + NONE, ADD, REMOVE, RATE_INIT, ADD_RATE_INIT, + } op = NONE; + int ret; + + IWL_DEBUG_MAC80211(priv, "station %pM state change %d->%d\n", + sta->addr, old_state, new_state); + + mutex_lock(&priv->shrd->mutex); + if (vif->type == NL80211_IFTYPE_STATION) { + if (old_state == IEEE80211_STA_NOTEXIST && + new_state == IEEE80211_STA_NONE) + op = ADD; + else if (old_state == IEEE80211_STA_NONE && + new_state == IEEE80211_STA_NOTEXIST) + op = REMOVE; + else if (old_state == IEEE80211_STA_AUTH && + new_state == IEEE80211_STA_ASSOC) + op = RATE_INIT; + } else { + if (old_state == IEEE80211_STA_AUTH && + new_state == IEEE80211_STA_ASSOC) + op = ADD_RATE_INIT; + else if (old_state == IEEE80211_STA_ASSOC && + new_state == IEEE80211_STA_AUTH) + op = REMOVE; + } + + switch (op) { + case ADD: + ret = iwlagn_mac_sta_add(hw, vif, sta); + break; + case REMOVE: + ret = iwlagn_mac_sta_remove(hw, vif, sta); + break; + case ADD_RATE_INIT: + ret = iwlagn_mac_sta_add(hw, vif, sta); + if (ret) + break; + /* fall through */ + case RATE_INIT: + /* Initialize rate scaling */ + IWL_DEBUG_INFO(priv, + "Initializing rate scaling for station %pM\n", + sta->addr); + iwl_rs_rate_init(priv, sta, iwl_sta_id(sta)); + ret = 0; + break; + default: + ret = 0; + break; + } + + /* + * mac80211 might WARN if we fail, but due the way we + * (badly) handle hard rfkill, we might fail here + */ + if (iwl_is_rfkill(priv->shrd)) + ret = 0; + mutex_unlock(&priv->shrd->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); @@ -1003,86 +1082,6 @@ static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) return 0; } -static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *bssid, - enum ieee80211_tx_sync_type type) -{ - struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; - 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); - - if (iwl_is_associated_ctx(ctx)) { - ret = 0; - goto out; - } - - if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, - &priv->shrd->status)) { - ret = -EBUSY; - goto out; - } - - ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); - if (ret) - goto out; - - if (WARN_ON(sta_id != ctx->ap_sta_id)) { - ret = -EIO; - goto out_remove_sta; - } - - memcpy(ctx->bssid, bssid, ETH_ALEN); - ctx->preauth_bssid = true; - - ret = iwlagn_commit_rxon(priv, ctx); - - if (ret == 0) - goto out; - - out_remove_sta: - iwl_remove_station(priv, sta_id, bssid); - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} - -static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *bssid, - enum ieee80211_tx_sync_type type) -{ - struct iwl_priv *priv = IWL_MAC80211_GET_DVM(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); - - if (iwl_is_associated_ctx(ctx)) - goto out; - - iwl_remove_station(priv, ctx->ap_sta_id, bssid); - ctx->preauth_bssid = false; - /* no need to commit */ - out: - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); -} - static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, enum ieee80211_rssi_event rssi_event) { @@ -1471,29 +1470,6 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, return ret; } -static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - int ret; - - IWL_DEBUG_MAC80211(priv, "enter: received request to remove " - "station %pM\n", sta->addr); - mutex_lock(&priv->shrd->mutex); - IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", - sta->addr); - ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); - if (ret) - IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", - sta->addr); - mutex_unlock(&priv->shrd->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); - - return ret; -} - static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) { struct iwl_addsta_cmd cmd = { @@ -1559,8 +1535,7 @@ struct ieee80211_ops iwlagn_hw_ops = { .ampdu_action = iwlagn_mac_ampdu_action, .hw_scan = iwlagn_mac_hw_scan, .sta_notify = iwlagn_mac_sta_notify, - .sta_add = iwlagn_mac_sta_add, - .sta_remove = iwlagn_mac_sta_remove, + .sta_state = iwlagn_mac_sta_state, .channel_switch = iwlagn_mac_channel_switch, .flush = iwlagn_mac_flush, .tx_last_beacon = iwlagn_mac_tx_last_beacon, @@ -1569,8 +1544,6 @@ struct ieee80211_ops iwlagn_hw_ops = { .rssi_callback = iwlagn_mac_rssi_callback, CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) - .tx_sync = iwlagn_mac_tx_sync, - .finish_tx_sync = iwlagn_mac_finish_tx_sync, .set_tim = iwlagn_mac_set_tim, }; -- GitLab From a8bceb392a739321ec20d03a91a86ebdde9c07bb Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:30 -0800 Subject: [PATCH 1413/1846] iwlwifi: remove per-device debug level There's no need for the per-device debug level that we expose in debugfs since the module parameter is writable in sysfs. At the same time, simplify code by changing iwl_get_debug_level(shrd) & IWL_DL_ISR) to iwl_have_debug_level(IWL_DL_ISR) Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.c | 10 ++-- drivers/net/wireless/iwlwifi/iwl-debug.c | 4 +- drivers/net/wireless/iwlwifi/iwl-debug.h | 12 ++-- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 55 +------------------ drivers/net/wireless/iwlwifi/iwl-shared.h | 27 +-------- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 10 ++-- 6 files changed, 22 insertions(+), 96 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 8551c95e7437..8d25fd6be645 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -836,7 +836,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) unsigned long reload_jiffies; #ifdef CONFIG_IWLWIFI_DEBUG - if (iwl_get_debug_level(priv->shrd) & IWL_DL_FW_ERRORS) + if (iwl_have_debug_level(IWL_DL_FW_ERRORS)) iwl_print_rx_config_cmd(priv, IWL_RXON_CTX_BSS); #endif @@ -1004,7 +1004,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv) { u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE; - if (iwl_get_debug_level(priv->shrd) & IWL_DL_TX) { + if (iwl_have_debug_level(IWL_DL_TX)) { if (!priv->tx_traffic) { priv->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1012,7 +1012,7 @@ int iwl_alloc_traffic_mem(struct iwl_priv *priv) return -ENOMEM; } } - if (iwl_get_debug_level(priv->shrd) & IWL_DL_RX) { + if (iwl_have_debug_level(IWL_DL_RX)) { if (!priv->rx_traffic) { priv->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1039,7 +1039,7 @@ void iwl_dbg_log_tx_data_frame(struct iwl_priv *priv, __le16 fc; u16 len; - if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_TX))) + if (likely(!iwl_have_debug_level(IWL_DL_TX))) return; if (!priv->tx_traffic) @@ -1063,7 +1063,7 @@ void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv, __le16 fc; u16 len; - if (likely(!(iwl_get_debug_level(priv->shrd) & IWL_DL_RX))) + if (likely(!iwl_have_debug_level(IWL_DL_RX))) return; if (!priv->rx_traffic) diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.c b/drivers/net/wireless/iwlwifi/iwl-debug.c index 4bc2e70051d6..059efabda184 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.c +++ b/drivers/net/wireless/iwlwifi/iwl-debug.c @@ -104,7 +104,7 @@ void __iwl_err(struct device *dev, bool rfkill_prefix, bool trace_only, } #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING) -void __iwl_dbg(struct iwl_shared *shared, struct device *dev, +void __iwl_dbg(struct device *dev, u32 level, bool limit, const char *function, const char *fmt, ...) { @@ -116,7 +116,7 @@ void __iwl_dbg(struct iwl_shared *shared, struct device *dev, va_start(args, fmt); vaf.va = &args; #ifdef CONFIG_IWLWIFI_DEBUG - if (iwl_get_debug_level(shared) & level && + if (iwl_have_debug_level(level) && (!limit || net_ratelimit())) dev_err(dev, "%c %s %pV", in_interrupt() ? 'I' : 'U', function, &vaf); diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 01b23303d736..163d259198be 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -47,12 +47,12 @@ void __iwl_crit(struct device *dev, const char *fmt, ...); #define IWL_CRIT(m, f, a...) __iwl_crit(trans(m)->dev, f, ## a) #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING) -void __iwl_dbg(struct iwl_shared *shared, struct device *dev, +void __iwl_dbg(struct device *dev, u32 level, bool limit, const char *function, const char *fmt, ...); #else static inline void -__iwl_dbg(struct iwl_shared *shared, struct device *dev, +__iwl_dbg(struct device *dev, u32 level, bool limit, const char *function, const char *fmt, ...) {} @@ -65,14 +65,14 @@ do { \ } while (0) #define IWL_DEBUG(m, level, fmt, args...) \ - __iwl_dbg((m)->shrd, trans(m)->dev, level, false, __func__, fmt, ##args) + __iwl_dbg(trans(m)->dev, level, false, __func__, fmt, ##args) #define IWL_DEBUG_LIMIT(m, level, fmt, args...) \ - __iwl_dbg((m)->shrd, trans(m)->dev, level, true, __func__, fmt, ##args) + __iwl_dbg(trans(m)->dev, level, true, __func__, fmt, ##args) #ifdef CONFIG_IWLWIFI_DEBUG #define iwl_print_hex_dump(m, level, p, len) \ do { \ - if (iwl_get_debug_level((m)->shrd) & level) \ + if (iwl_have_debug_level(level)) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) @@ -82,7 +82,7 @@ do { \ IWL_ERR(m, fmt, ##args); \ else \ __iwl_err(trans(m)->dev, true, \ - !(iwl_get_debug_level((m)->shrd) & IWL_DL_RADIO),\ + !iwl_have_debug_level(IWL_DL_RADIO), \ fmt, ##args); \ } while (0) #else diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 628af563e4e1..dd502e82e410 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -845,8 +845,7 @@ static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, IWL_ERR(priv, "Can not allocate buffer\n"); return -ENOMEM; } - if (priv->tx_traffic && - (iwl_get_debug_level(priv->shrd) & IWL_DL_TX)) { + if (priv->tx_traffic && iwl_have_debug_level(IWL_DL_TX)) { ptr = priv->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", priv->tx_traffic_idx); @@ -864,8 +863,7 @@ static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, } } - if (priv->rx_traffic && - (iwl_get_debug_level(priv->shrd) & IWL_DL_RX)) { + if (priv->rx_traffic && iwl_have_debug_level(IWL_DL_RX)) { ptr = priv->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", priv->rx_traffic_idx); @@ -2507,52 +2505,6 @@ DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); DEBUGFS_READ_FILE_OPS(reply_tx_error); DEBUGFS_WRITE_FILE_OPS(echo_test); -#ifdef CONFIG_IWLWIFI_DEBUG -static ssize_t iwl_dbgfs_debug_level_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct iwl_priv *priv = file->private_data; - struct iwl_shared *shrd = priv->shrd; - char buf[11]; - int len; - - len = scnprintf(buf, sizeof(buf), "0x%.8x", - iwl_get_debug_level(shrd)); - - return simple_read_from_buffer(user_buf, count, ppos, buf, len); -} - -static ssize_t iwl_dbgfs_debug_level_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct iwl_priv *priv = file->private_data; - struct iwl_shared *shrd = priv->shrd; - char buf[11]; - unsigned long val; - int ret; - - if (count > sizeof(buf)) - return -EINVAL; - - memset(buf, 0, sizeof(buf)); - if (copy_from_user(buf, user_buf, count)) - return -EFAULT; - - ret = strict_strtoul(buf, 0, &val); - if (ret) - return ret; - - shrd->dbg_level_dev = val; - if (iwl_alloc_traffic_mem(priv)) - IWL_ERR(priv, "Not enough memory to generate traffic log\n"); - - return count; -} -DEBUGFS_READ_WRITE_FILE_OPS(debug_level); -#endif /* CONFIG_IWLWIFI_DEBUG */ - /* * Create the debugfs files and directories * @@ -2617,9 +2569,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR); if (iwl_advanced_bt_coexist(priv)) DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); -#ifdef CONFIG_IWLWIFI_DEBUG - DEBUGFS_ADD_FILE(debug_level, dir_debug, S_IRUSR | S_IWUSR); -#endif DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 7720fc34c278..239dfbc57bee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -346,8 +346,6 @@ struct iwl_cfg { /** * struct iwl_shared - shared fields for all the layers of the driver * - * @dbg_level_dev: dbg level set per device. Prevails on - * iwlagn_mod_params.debug_level if set (!= 0) * @ucode_owner: IWL_OWNERSHIP_* * @cmd_queue: command queue number * @status: STATUS_* @@ -370,10 +368,6 @@ struct iwl_cfg { * @device_pointers: pointers to ucode event tables */ struct iwl_shared { -#ifdef CONFIG_IWLWIFI_DEBUG - u32 dbg_level_dev; -#endif /* CONFIG_IWLWIFI_DEBUG */ - #define IWL_OWNERSHIP_DRIVER 0 #define IWL_OWNERSHIP_TM 1 u8 ucode_owner; @@ -417,27 +411,10 @@ struct iwl_shared { #define trans(_m) ((_m)->shrd->trans) #define hw_params(_m) ((_m)->shrd->hw_params) -#ifdef CONFIG_IWLWIFI_DEBUG -/* - * iwl_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_get_debug_level(struct iwl_shared *shrd) -{ - if (shrd->dbg_level_dev) - return shrd->dbg_level_dev; - else - return iwlagn_mod_params.debug_level; -} -#else -static inline u32 iwl_get_debug_level(struct iwl_shared *shrd) +static inline bool iwl_have_debug_level(u32 level) { - return iwlagn_mod_params.debug_level; + return iwlagn_mod_params.debug_level & level; } -#endif static inline void iwl_free_pages(struct iwl_shared *shrd, unsigned long page) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 2c910fddaaf6..6495945637b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -881,7 +881,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, } #ifdef CONFIG_IWLWIFI_DEBUG - if (!(iwl_get_debug_level(trans->shrd) & IWL_DL_FW_ERRORS) && !full_log) + if (!(iwl_have_debug_level(IWL_DL_FW_ERRORS)) && !full_log) size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size; #else @@ -901,7 +901,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, if (!*buf) return -ENOMEM; } - if ((iwl_get_debug_level(trans->shrd) & IWL_DL_FW_ERRORS) || full_log) { + if (iwl_have_debug_level(IWL_DL_FW_ERRORS) || full_log) { /* * if uCode has wrapped back to top of log, * start at the oldest entry, @@ -960,7 +960,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) inta = trans_pcie->inta; #ifdef CONFIG_IWLWIFI_DEBUG - if (iwl_get_debug_level(trans->shrd) & IWL_DL_ISR) { + if (iwl_have_debug_level(IWL_DL_ISR)) { /* just for debug */ inta_mask = iwl_read32(trans, CSR_INT_MASK); IWL_DEBUG_ISR(trans, "inta 0x%08x, enabled 0x%08x\n ", @@ -989,7 +989,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) } #ifdef CONFIG_IWLWIFI_DEBUG - if (iwl_get_debug_level(trans->shrd) & (IWL_DL_ISR)) { + if (iwl_have_debug_level(IWL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { IWL_DEBUG_ISR(trans, "Scheduler finished to transmit " @@ -1301,7 +1301,7 @@ static irqreturn_t iwl_isr(int irq, void *data) } #ifdef CONFIG_IWLWIFI_DEBUG - if (iwl_get_debug_level(trans->shrd) & (IWL_DL_ISR)) { + if (iwl_have_debug_level(IWL_DL_ISR)) { inta_fh = iwl_read32(trans, CSR_FH_INT_STATUS); IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled 0x%08x, " "fh 0x%08x\n", inta, inta_mask, inta_fh); -- GitLab From 54708d8df355b7ecf1d25d4049336840e6107d96 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:31 -0800 Subject: [PATCH 1414/1846] iwlwifi: remove SKU from config There's no SKU override, we always just use it from EEPROM. As such, we can remove it from the config and use it in hw_param only. Since iwl_eeprom_check_sku() really needs to fill it in also rename that to iwl_eeprom_init_hw_params(). Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 5 ++--- drivers/net/wireless/iwlwifi/iwl-core.c | 8 ++++---- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 20 +++++++++----------- drivers/net/wireless/iwlwifi/iwl-eeprom.h | 2 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 2470ca767589..79ac7cb1701b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -235,7 +235,7 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control) IWL_PAN_SCD_BK_MSK | IWL_PAN_SCD_MGMT_MSK | IWL_PAN_SCD_MULTICAST_MSK; - if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE) flush_cmd.fifo_control |= IWL_AGG_TX_QUEUE_MSK; IWL_DEBUG_INFO(priv, "fifo queue control: 0X%x\n", diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index c14eda048948..e1bf12578f87 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1124,13 +1124,12 @@ static void iwl_set_hw_params(struct iwl_priv *priv) get_order(IWL_RX_BUF_SIZE_4K); if (iwlagn_mod_params.disable_11n & IWL_DISABLE_HT_ALL) - cfg(priv)->sku &= ~EEPROM_SKU_CAP_11N_ENABLE; + hw_params(priv).sku &= ~EEPROM_SKU_CAP_11N_ENABLE; hw_params(priv).num_ampdu_queues = cfg(priv)->base_params->num_of_ampdu_queues; hw_params(priv).shadow_reg_enable = cfg(priv)->base_params->shadow_reg_enable; - hw_params(priv).sku = cfg(priv)->sku; hw_params(priv).wd_timeout = cfg(priv)->base_params->wd_timeout; /* Device-specific setup */ @@ -1257,7 +1256,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) if (err) goto out_free_eeprom; - err = iwl_eeprom_check_sku(priv); + err = iwl_eeprom_init_hw_params(priv); if (err) goto out_free_eeprom; diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 8d25fd6be645..c5df3e3d975b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -137,7 +137,7 @@ int iwl_init_geos(struct iwl_priv *priv) sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; - if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE) iwl_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_5GHZ); @@ -147,7 +147,7 @@ int iwl_init_geos(struct iwl_priv *priv) sband->bitrates = rates; sband->n_bitrates = IWL_RATE_COUNT_LEGACY; - if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE) iwl_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_2GHZ); @@ -202,11 +202,11 @@ int iwl_init_geos(struct iwl_priv *priv) priv->tx_power_next = max_tx_power; if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - cfg(priv)->sku & EEPROM_SKU_CAP_BAND_52GHZ) { + hw_params(priv).sku & EEPROM_SKU_CAP_BAND_52GHZ) { IWL_INFO(priv, "Incorrectly detected BG card as ABG. " "Please send your %s to maintainer.\n", trans(priv)->hw_id_str); - cfg(priv)->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; + hw_params(priv).sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; } IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 07e93787bce8..d8668bccc083 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -252,26 +252,24 @@ int iwl_eeprom_check_version(struct iwl_priv *priv) } -int iwl_eeprom_check_sku(struct iwl_priv *priv) +int iwl_eeprom_init_hw_params(struct iwl_priv *priv) { struct iwl_shared *shrd = priv->shrd; u16 radio_cfg; - if (!cfg(priv)->sku) { - /* not using sku overwrite */ - cfg(priv)->sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP); - if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE && - !cfg(priv)->ht_params) { - IWL_ERR(priv, "Invalid 11n configuration\n"); - return -EINVAL; - } + hw_params(priv).sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP); + if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE && + !cfg(priv)->ht_params) { + IWL_ERR(priv, "Invalid 11n configuration\n"); + return -EINVAL; } - if (!cfg(priv)->sku) { + + if (!hw_params(priv).sku) { IWL_ERR(priv, "Invalid device sku\n"); return -EINVAL; } - IWL_INFO(priv, "Device SKU: 0x%X\n", cfg(priv)->sku); + IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku); if (!cfg(priv)->valid_tx_ant && !cfg(priv)->valid_rx_ant) { /* not using .cfg overwrite */ diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index cbb86116917b..3b17056d5675 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -309,7 +309,7 @@ struct iwl_eeprom_ops { int iwl_eeprom_init(struct iwl_trans *trans, u32 hw_rev); 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); +int iwl_eeprom_init_hw_params(struct iwl_priv *priv); 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); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 005763fa38ab..8b26f3217823 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -161,7 +161,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, hw->flags |= IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_SUPPORTS_DYNAMIC_PS; - if (cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE) hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; @@ -633,7 +633,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", sta->addr, tid); - if (!(cfg(priv)->sku & EEPROM_SKU_CAP_11N_ENABLE)) + if (!(hw_params(priv).sku & EEPROM_SKU_CAP_11N_ENABLE)) return -EACCES; IWL_DEBUG_MAC80211(priv, "enter\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 239dfbc57bee..11184f1c4365 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -282,7 +282,6 @@ enum iwl_led_mode { * @max_data_size: The maximal length of the fw data section * @valid_tx_ant: valid transmit antenna * @valid_rx_ant: valid receive antenna - * @sku: sku information from EEPROM * @eeprom_ver: EEPROM version * @eeprom_calib_ver: EEPROM calibration version * @lib: pointer to the lib ops @@ -321,7 +320,6 @@ struct iwl_cfg { const u32 max_inst_size; u8 valid_tx_ant; u8 valid_rx_ant; - u16 sku; u16 eeprom_ver; u16 eeprom_calib_ver; const struct iwl_lib_ops *lib; -- GitLab From 7e79a3937a44b1dc5f457e6dbb8c50e93719286a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:32 -0800 Subject: [PATCH 1415/1846] iwlwifi: use valid TX/RX antenna from hw_params It's not really a good idea to write to the global static configuration. Use the valid TX/RX antenna information only from the HW params struct except in the case where the values from the config are used to override the values from the EEPROM. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 7 ++-- drivers/net/wireless/iwlwifi/iwl-2000.c | 7 ++-- drivers/net/wireless/iwlwifi/iwl-5000.c | 16 ++++----- drivers/net/wireless/iwlwifi/iwl-6000.c | 7 ++-- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 4 +-- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 9 +++-- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 38 ++++++++++---------- 8 files changed, 46 insertions(+), 44 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 605ee3df1d82..22eb0622ac21 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -131,14 +131,13 @@ static void iwl1000_hw_set_hw_params(struct iwl_priv *priv) hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); - hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); + hw_params(priv).tx_chains_num = + num_of_ant(hw_params(priv).valid_tx_ant); if (cfg(priv)->rx_with_siso_diversity) hw_params(priv).rx_chains_num = 1; else hw_params(priv).rx_chains_num = - num_of_ant(cfg(priv)->valid_rx_ant); - hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; - hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; + num_of_ant(hw_params(priv).valid_rx_ant); iwl1000_set_ct_threshold(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index e6e8c79a80d8..43d17a4564e3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -127,14 +127,13 @@ static void iwl2000_hw_set_hw_params(struct iwl_priv *priv) hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); - hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); + hw_params(priv).tx_chains_num = + num_of_ant(hw_params(priv).valid_tx_ant); if (cfg(priv)->rx_with_siso_diversity) hw_params(priv).rx_chains_num = 1; else hw_params(priv).rx_chains_num = - num_of_ant(cfg(priv)->valid_rx_ant); - hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; - hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; + num_of_ant(hw_params(priv).valid_rx_ant); iwl2000_set_ct_threshold(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index ccaeead29c2f..8cdc4a35a973 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -167,10 +167,10 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); - hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); - hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant); - hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; - hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; + hw_params(priv).tx_chains_num = + num_of_ant(hw_params(priv).valid_tx_ant); + hw_params(priv).rx_chains_num = + num_of_ant(hw_params(priv).valid_rx_ant); iwl5000_set_ct_threshold(priv); @@ -190,10 +190,10 @@ static void iwl5150_hw_set_hw_params(struct iwl_priv *priv) hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); - hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); - hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant); - hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; - hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; + hw_params(priv).tx_chains_num = + num_of_ant(hw_params(priv).valid_tx_ant); + hw_params(priv).rx_chains_num = + num_of_ant(hw_params(priv).valid_rx_ant); iwl5150_set_ct_threshold(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 223e60a1b79d..720e8e6e62ae 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -149,14 +149,13 @@ static void iwl6000_hw_set_hw_params(struct iwl_priv *priv) hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); - hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); + hw_params(priv).tx_chains_num = + num_of_ant(hw_params(priv).valid_tx_ant); if (cfg(priv)->rx_with_siso_diversity) hw_params(priv).rx_chains_num = 1; else hw_params(priv).rx_chains_num = - num_of_ant(cfg(priv)->valid_rx_ant); - hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; - hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; + num_of_ant(hw_params(priv).valid_rx_ant); iwl6000_set_ct_threshold(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 12acc81ed419..84fc5ce91b35 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -848,7 +848,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, * connect the first valid tx chain */ first_chain = - find_first_chain(cfg(priv)->valid_tx_ant); + find_first_chain(hw_params(priv).valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); IWL_DEBUG_CALIB(priv, @@ -1082,7 +1082,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) iwlagn_gain_computation(priv, average_noise, min_average_noise_antenna_i, min_average_noise, - find_first_chain(cfg(priv)->valid_rx_ant)); + find_first_chain(hw_params(priv).valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index e1bf12578f87..6cec7e63c171 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -699,7 +699,7 @@ int iwl_alive_start(struct iwl_priv *priv) priv->active_rate = IWL_RATES_MASK; /* Configure Tx antenna selection based on H/W config */ - iwlagn_send_tx_ant_config(priv, cfg(priv)->valid_tx_ant); + iwlagn_send_tx_ant_config(priv, hw_params(priv).valid_tx_ant); if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) { struct iwl_rxon_cmd *active_rxon = diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index dd502e82e410..b6740c33b519 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -1546,15 +1546,18 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) { pos += scnprintf(buf + pos, bufsz - pos, "tx power: (1/2 dB step)\n"); - if ((cfg(priv)->valid_tx_ant & ANT_A) && tx->tx_power.ant_a) + if ((hw_params(priv).valid_tx_ant & ANT_A) && + tx->tx_power.ant_a) pos += scnprintf(buf + pos, bufsz - pos, fmt_hex, "antenna A:", tx->tx_power.ant_a); - if ((cfg(priv)->valid_tx_ant & ANT_B) && tx->tx_power.ant_b) + if ((hw_params(priv).valid_tx_ant & ANT_B) && + tx->tx_power.ant_b) pos += scnprintf(buf + pos, bufsz - pos, fmt_hex, "antenna B:", tx->tx_power.ant_b); - if ((cfg(priv)->valid_tx_ant & ANT_C) && tx->tx_power.ant_c) + if ((hw_params(priv).valid_tx_ant & ANT_C) && + tx->tx_power.ant_c) pos += scnprintf(buf + pos, bufsz - pos, fmt_hex, "antenna C:", tx->tx_power.ant_c); diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index d8668bccc083..6915b33add36 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -271,25 +271,27 @@ int iwl_eeprom_init_hw_params(struct iwl_priv *priv) IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku); - if (!cfg(priv)->valid_tx_ant && !cfg(priv)->valid_rx_ant) { - /* not using .cfg overwrite */ - radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG); - cfg(priv)->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); - cfg(priv)->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg); - if (!cfg(priv)->valid_tx_ant || !cfg(priv)->valid_rx_ant) { - IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n", - cfg(priv)->valid_tx_ant, - cfg(priv)->valid_rx_ant); - return -EINVAL; - } - IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n", - cfg(priv)->valid_tx_ant, cfg(priv)->valid_rx_ant); + radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG); + + hw_params(priv).valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); + hw_params(priv).valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg); + + /* check overrides (some devices have wrong EEPROM) */ + if (cfg(priv)->valid_tx_ant) + hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; + if (cfg(priv)->valid_rx_ant) + hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; + + if (!hw_params(priv).valid_tx_ant || !hw_params(priv).valid_rx_ant) { + IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n", + hw_params(priv).valid_tx_ant, + hw_params(priv).valid_rx_ant); + return -EINVAL; } - /* - * for some special cases, - * EEPROM did not reflect the correct antenna setting - * so overwrite the valid tx/rx antenna from .cfg - */ + + IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n", + hw_params(priv).valid_tx_ant, hw_params(priv).valid_rx_ant); + return 0; } -- GitLab From 706c4ff67cb86134a3a93413a595a7c5559b7cc2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:33 -0800 Subject: [PATCH 1416/1846] iwlwifi: make config const Writing to the global config structures is always wrong. To protect against such mistakes in the future, mark them const. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 8 +-- drivers/net/wireless/iwlwifi/iwl-2000.c | 12 ++-- drivers/net/wireless/iwlwifi/iwl-5000.c | 14 ++-- drivers/net/wireless/iwlwifi/iwl-6000.c | 49 +++++++------- drivers/net/wireless/iwlwifi/iwl-cfg.h | 82 +++++++++++------------ drivers/net/wireless/iwlwifi/iwl-drv.c | 2 +- drivers/net/wireless/iwlwifi/iwl-drv.h | 2 +- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 2 +- drivers/net/wireless/iwlwifi/iwl-pci.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 4 +- 11 files changed, 90 insertions(+), 89 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 22eb0622ac21..2199a0e5c4f0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -196,13 +196,13 @@ static struct iwl_ht_params iwl1000_ht_params = { .base_params = &iwl1000_base_params, \ .led_mode = IWL_LED_BLINK -struct iwl_cfg iwl1000_bgn_cfg = { +const struct iwl_cfg iwl1000_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN", IWL_DEVICE_1000, .ht_params = &iwl1000_ht_params, }; -struct iwl_cfg iwl1000_bg_cfg = { +const struct iwl_cfg iwl1000_bg_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 1000 BG", IWL_DEVICE_1000, }; @@ -221,13 +221,13 @@ struct iwl_cfg iwl1000_bg_cfg = { .led_mode = IWL_LED_RF_STATE, \ .rx_with_siso_diversity = true -struct iwl_cfg iwl100_bgn_cfg = { +const struct iwl_cfg iwl100_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 100 BGN", IWL_DEVICE_100, .ht_params = &iwl1000_ht_params, }; -struct iwl_cfg iwl100_bg_cfg = { +const struct iwl_cfg iwl100_bg_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 100 BG", IWL_DEVICE_100, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 43d17a4564e3..1ba020723537 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -248,13 +248,13 @@ static struct iwl_bt_params iwl2030_bt_params = { .led_mode = IWL_LED_RF_STATE, \ .iq_invert = true \ -struct iwl_cfg iwl2000_2bgn_cfg = { +const struct iwl_cfg iwl2000_2bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 2200 BGN", IWL_DEVICE_2000, .ht_params = &iwl2000_ht_params, }; -struct iwl_cfg iwl2000_2bgn_d_cfg = { +const struct iwl_cfg iwl2000_2bgn_d_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 2200D BGN", IWL_DEVICE_2000, .ht_params = &iwl2000_ht_params, @@ -278,7 +278,7 @@ struct iwl_cfg iwl2000_2bgn_d_cfg = { .adv_pm = true, \ .iq_invert = true \ -struct iwl_cfg iwl2030_2bgn_cfg = { +const struct iwl_cfg iwl2030_2bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 2230 BGN", IWL_DEVICE_2030, .ht_params = &iwl2000_ht_params, @@ -302,13 +302,13 @@ struct iwl_cfg iwl2030_2bgn_cfg = { .rx_with_siso_diversity = true, \ .iq_invert = true \ -struct iwl_cfg iwl105_bgn_cfg = { +const struct iwl_cfg iwl105_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 105 BGN", IWL_DEVICE_105, .ht_params = &iwl2000_ht_params, }; -struct iwl_cfg iwl105_bgn_d_cfg = { +const struct iwl_cfg iwl105_bgn_d_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 105D BGN", IWL_DEVICE_105, .ht_params = &iwl2000_ht_params, @@ -333,7 +333,7 @@ struct iwl_cfg iwl105_bgn_d_cfg = { .rx_with_siso_diversity = true, \ .iq_invert = true \ -struct iwl_cfg iwl135_bgn_cfg = { +const struct iwl_cfg iwl135_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 135 BGN", IWL_DEVICE_135, .ht_params = &iwl2000_ht_params, diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 8cdc4a35a973..dff75a09eb48 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -349,7 +349,7 @@ static struct iwl_ht_params iwl5000_ht_params = { .base_params = &iwl5000_base_params, \ .led_mode = IWL_LED_BLINK -struct iwl_cfg iwl5300_agn_cfg = { +const struct iwl_cfg iwl5300_agn_cfg = { .name = "Intel(R) Ultimate N WiFi Link 5300 AGN", IWL_DEVICE_5000, /* at least EEPROM 0x11A has wrong info */ @@ -358,7 +358,7 @@ struct iwl_cfg iwl5300_agn_cfg = { .ht_params = &iwl5000_ht_params, }; -struct iwl_cfg iwl5100_bgn_cfg = { +const struct iwl_cfg iwl5100_bgn_cfg = { .name = "Intel(R) WiFi Link 5100 BGN", IWL_DEVICE_5000, .valid_tx_ant = ANT_B, /* .cfg overwrite */ @@ -366,14 +366,14 @@ struct iwl_cfg iwl5100_bgn_cfg = { .ht_params = &iwl5000_ht_params, }; -struct iwl_cfg iwl5100_abg_cfg = { +const struct iwl_cfg iwl5100_abg_cfg = { .name = "Intel(R) WiFi Link 5100 ABG", IWL_DEVICE_5000, .valid_tx_ant = ANT_B, /* .cfg overwrite */ .valid_rx_ant = ANT_AB, /* .cfg overwrite */ }; -struct iwl_cfg iwl5100_agn_cfg = { +const struct iwl_cfg iwl5100_agn_cfg = { .name = "Intel(R) WiFi Link 5100 AGN", IWL_DEVICE_5000, .valid_tx_ant = ANT_B, /* .cfg overwrite */ @@ -381,7 +381,7 @@ struct iwl_cfg iwl5100_agn_cfg = { .ht_params = &iwl5000_ht_params, }; -struct iwl_cfg iwl5350_agn_cfg = { +const struct iwl_cfg iwl5350_agn_cfg = { .name = "Intel(R) WiMAX/WiFi Link 5350 AGN", .fw_name_pre = IWL5000_FW_PRE, .ucode_api_max = IWL5000_UCODE_API_MAX, @@ -411,14 +411,14 @@ struct iwl_cfg iwl5350_agn_cfg = { .led_mode = IWL_LED_BLINK, \ .internal_wimax_coex = true -struct iwl_cfg iwl5150_agn_cfg = { +const struct iwl_cfg iwl5150_agn_cfg = { .name = "Intel(R) WiMAX/WiFi Link 5150 AGN", IWL_DEVICE_5150, .ht_params = &iwl5000_ht_params, }; -struct iwl_cfg iwl5150_abg_cfg = { +const struct iwl_cfg iwl5150_abg_cfg = { .name = "Intel(R) WiMAX/WiFi Link 5150 ABG", IWL_DEVICE_5150, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 720e8e6e62ae..ef896630625d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -354,40 +354,41 @@ static struct iwl_bt_params iwl6000_bt_params = { .need_temp_offset_calib = true, \ .led_mode = IWL_LED_RF_STATE -struct iwl_cfg iwl6005_2agn_cfg = { +const struct iwl_cfg iwl6005_2agn_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6205 AGN", IWL_DEVICE_6005, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6005_2abg_cfg = { +const struct iwl_cfg iwl6005_2abg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6205 ABG", IWL_DEVICE_6005, }; -struct iwl_cfg iwl6005_2bg_cfg = { +const struct iwl_cfg iwl6005_2bg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6205 BG", IWL_DEVICE_6005, }; -struct iwl_cfg iwl6005_2agn_sff_cfg = { +const struct iwl_cfg iwl6005_2agn_sff_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6205S AGN", IWL_DEVICE_6005, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6005_2agn_d_cfg = { +const struct iwl_cfg iwl6005_2agn_d_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6205D AGN", IWL_DEVICE_6005, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6005_2agn_mow1_cfg = { +const struct iwl_cfg iwl6005_2agn_mow1_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6206 AGN", IWL_DEVICE_6005, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6005_2agn_mow2_cfg = { + +const struct iwl_cfg iwl6005_2agn_mow2_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6207 AGN", IWL_DEVICE_6005, .ht_params = &iwl6000_ht_params, @@ -409,53 +410,53 @@ struct iwl_cfg iwl6005_2agn_mow2_cfg = { .led_mode = IWL_LED_RF_STATE, \ .adv_pm = true \ -struct iwl_cfg iwl6030_2agn_cfg = { +const struct iwl_cfg iwl6030_2agn_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6230 AGN", IWL_DEVICE_6030, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6030_2abg_cfg = { +const struct iwl_cfg iwl6030_2abg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6230 ABG", IWL_DEVICE_6030, }; -struct iwl_cfg iwl6030_2bgn_cfg = { +const struct iwl_cfg iwl6030_2bgn_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6230 BGN", IWL_DEVICE_6030, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6030_2bg_cfg = { +const struct iwl_cfg iwl6030_2bg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6230 BG", IWL_DEVICE_6030, }; -struct iwl_cfg iwl6035_2agn_cfg = { +const struct iwl_cfg iwl6035_2agn_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6235 AGN", IWL_DEVICE_6030, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl1030_bgn_cfg = { +const struct iwl_cfg iwl1030_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN", IWL_DEVICE_6030, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl1030_bg_cfg = { +const struct iwl_cfg iwl1030_bg_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 1030 BG", IWL_DEVICE_6030, }; -struct iwl_cfg iwl130_bgn_cfg = { +const struct iwl_cfg iwl130_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 130 BGN", IWL_DEVICE_6030, .ht_params = &iwl6000_ht_params, .rx_with_siso_diversity = true, }; -struct iwl_cfg iwl130_bg_cfg = { +const struct iwl_cfg iwl130_bg_cfg = { .name = "Intel(R) Centrino(R) Wireless-N 130 BG", IWL_DEVICE_6030, .rx_with_siso_diversity = true, @@ -480,18 +481,18 @@ struct iwl_cfg iwl130_bg_cfg = { .pa_type = IWL_PA_INTERNAL, \ .led_mode = IWL_LED_BLINK -struct iwl_cfg iwl6000i_2agn_cfg = { +const struct iwl_cfg iwl6000i_2agn_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN", IWL_DEVICE_6000i, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6000i_2abg_cfg = { +const struct iwl_cfg iwl6000i_2abg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6200 ABG", IWL_DEVICE_6000i, }; -struct iwl_cfg iwl6000i_2bg_cfg = { +const struct iwl_cfg iwl6000i_2bg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N 6200 BG", IWL_DEVICE_6000i, }; @@ -512,13 +513,13 @@ struct iwl_cfg iwl6000i_2bg_cfg = { .led_mode = IWL_LED_BLINK, \ .internal_wimax_coex = true -struct iwl_cfg iwl6050_2agn_cfg = { +const struct iwl_cfg iwl6050_2agn_cfg = { .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN", IWL_DEVICE_6050, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6050_2abg_cfg = { +const struct iwl_cfg iwl6050_2abg_cfg = { .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 ABG", IWL_DEVICE_6050, }; @@ -537,18 +538,18 @@ struct iwl_cfg iwl6050_2abg_cfg = { .led_mode = IWL_LED_BLINK, \ .internal_wimax_coex = true -struct iwl_cfg iwl6150_bgn_cfg = { +const struct iwl_cfg iwl6150_bgn_cfg = { .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN", IWL_DEVICE_6150, .ht_params = &iwl6000_ht_params, }; -struct iwl_cfg iwl6150_bg_cfg = { +const struct iwl_cfg iwl6150_bg_cfg = { .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG", IWL_DEVICE_6150, }; -struct iwl_cfg iwl6000_3agn_cfg = { +const 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, diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h index 1ad14bbccc99..82152311d73b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-cfg.h +++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h @@ -68,46 +68,46 @@ * This file declares the config structures for all devices. */ -extern struct iwl_cfg iwl5300_agn_cfg; -extern struct iwl_cfg iwl5100_agn_cfg; -extern struct iwl_cfg iwl5350_agn_cfg; -extern struct iwl_cfg iwl5100_bgn_cfg; -extern struct iwl_cfg iwl5100_abg_cfg; -extern struct iwl_cfg iwl5150_agn_cfg; -extern struct iwl_cfg iwl5150_abg_cfg; -extern struct iwl_cfg iwl6005_2agn_cfg; -extern struct iwl_cfg iwl6005_2abg_cfg; -extern struct iwl_cfg iwl6005_2bg_cfg; -extern struct iwl_cfg iwl6005_2agn_sff_cfg; -extern struct iwl_cfg iwl6005_2agn_d_cfg; -extern struct iwl_cfg iwl6005_2agn_mow1_cfg; -extern struct iwl_cfg iwl6005_2agn_mow2_cfg; -extern struct iwl_cfg iwl1030_bgn_cfg; -extern struct iwl_cfg iwl1030_bg_cfg; -extern struct iwl_cfg iwl6030_2agn_cfg; -extern struct iwl_cfg iwl6030_2abg_cfg; -extern struct iwl_cfg iwl6030_2bgn_cfg; -extern struct iwl_cfg iwl6030_2bg_cfg; -extern struct iwl_cfg iwl6000i_2agn_cfg; -extern struct iwl_cfg iwl6000i_2abg_cfg; -extern struct iwl_cfg iwl6000i_2bg_cfg; -extern struct iwl_cfg iwl6000_3agn_cfg; -extern struct iwl_cfg iwl6050_2agn_cfg; -extern struct iwl_cfg iwl6050_2abg_cfg; -extern struct iwl_cfg iwl6150_bgn_cfg; -extern struct iwl_cfg iwl6150_bg_cfg; -extern struct iwl_cfg iwl1000_bgn_cfg; -extern struct iwl_cfg iwl1000_bg_cfg; -extern struct iwl_cfg iwl100_bgn_cfg; -extern struct iwl_cfg iwl100_bg_cfg; -extern struct iwl_cfg iwl130_bgn_cfg; -extern struct iwl_cfg iwl130_bg_cfg; -extern struct iwl_cfg iwl2000_2bgn_cfg; -extern struct iwl_cfg iwl2000_2bgn_d_cfg; -extern struct iwl_cfg iwl2030_2bgn_cfg; -extern struct iwl_cfg iwl6035_2agn_cfg; -extern struct iwl_cfg iwl105_bgn_cfg; -extern struct iwl_cfg iwl105_bgn_d_cfg; -extern struct iwl_cfg iwl135_bgn_cfg; +extern const struct iwl_cfg iwl5300_agn_cfg; +extern const struct iwl_cfg iwl5100_agn_cfg; +extern const struct iwl_cfg iwl5350_agn_cfg; +extern const struct iwl_cfg iwl5100_bgn_cfg; +extern const struct iwl_cfg iwl5100_abg_cfg; +extern const struct iwl_cfg iwl5150_agn_cfg; +extern const struct iwl_cfg iwl5150_abg_cfg; +extern const struct iwl_cfg iwl6005_2agn_cfg; +extern const struct iwl_cfg iwl6005_2abg_cfg; +extern const struct iwl_cfg iwl6005_2bg_cfg; +extern const struct iwl_cfg iwl6005_2agn_sff_cfg; +extern const struct iwl_cfg iwl6005_2agn_d_cfg; +extern const struct iwl_cfg iwl6005_2agn_mow1_cfg; +extern const struct iwl_cfg iwl6005_2agn_mow2_cfg; +extern const struct iwl_cfg iwl1030_bgn_cfg; +extern const struct iwl_cfg iwl1030_bg_cfg; +extern const struct iwl_cfg iwl6030_2agn_cfg; +extern const struct iwl_cfg iwl6030_2abg_cfg; +extern const struct iwl_cfg iwl6030_2bgn_cfg; +extern const struct iwl_cfg iwl6030_2bg_cfg; +extern const struct iwl_cfg iwl6000i_2agn_cfg; +extern const struct iwl_cfg iwl6000i_2abg_cfg; +extern const struct iwl_cfg iwl6000i_2bg_cfg; +extern const struct iwl_cfg iwl6000_3agn_cfg; +extern const struct iwl_cfg iwl6050_2agn_cfg; +extern const struct iwl_cfg iwl6050_2abg_cfg; +extern const struct iwl_cfg iwl6150_bgn_cfg; +extern const struct iwl_cfg iwl6150_bg_cfg; +extern const struct iwl_cfg iwl1000_bgn_cfg; +extern const struct iwl_cfg iwl1000_bg_cfg; +extern const struct iwl_cfg iwl100_bgn_cfg; +extern const struct iwl_cfg iwl100_bg_cfg; +extern const struct iwl_cfg iwl130_bgn_cfg; +extern const struct iwl_cfg iwl130_bg_cfg; +extern const struct iwl_cfg iwl2000_2bgn_cfg; +extern const struct iwl_cfg iwl2000_2bgn_d_cfg; +extern const struct iwl_cfg iwl2030_2bgn_cfg; +extern const struct iwl_cfg iwl6035_2agn_cfg; +extern const struct iwl_cfg iwl105_bgn_cfg; +extern const struct iwl_cfg iwl105_bgn_d_cfg; +extern const struct iwl_cfg iwl135_bgn_cfg; #endif /* __iwl_pci_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 8ff52568cf6e..76fc4407b19e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -68,7 +68,7 @@ #include "iwl-op-mode.h" int iwl_drv_start(struct iwl_shared *shrd, - struct iwl_trans *trans, struct iwl_cfg *cfg) + struct iwl_trans *trans, const struct iwl_cfg *cfg) { int ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.h b/drivers/net/wireless/iwlwifi/iwl-drv.h index 90534a23ddc8..3b771c1d9096 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.h +++ b/drivers/net/wireless/iwlwifi/iwl-drv.h @@ -105,7 +105,7 @@ * function. */ int iwl_drv_start(struct iwl_shared *shrd, - struct iwl_trans *trans, struct iwl_cfg *cfg); + struct iwl_trans *trans, const struct iwl_cfg *cfg); /** * iwl_drv_stop - stop the drv diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 6915b33add36..f965ee333920 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -512,7 +512,7 @@ static int iwl_find_otp_image(struct iwl_trans *trans, * iwl_get_max_txpower_avg - get the highest tx power from all chains. * find the highest tx power from all chains for the channel */ -static s8 iwl_get_max_txpower_avg(struct iwl_cfg *cfg, +static s8 iwl_get_max_txpower_avg(const struct iwl_cfg *cfg, struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, int element, s8 *max_txpower_in_half_dbm) { diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 06e004157dcc..d109b0f32e33 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -263,7 +263,7 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); + const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); struct iwl_shared *shrd; struct iwl_trans *iwl_trans; int err; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 11184f1c4365..4efc9e13f9ec 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -374,7 +374,7 @@ struct iwl_shared { bool wowlan; u8 valid_contexts; - struct iwl_cfg *cfg; + const struct iwl_cfg *cfg; struct iwl_priv *priv; struct iwl_trans *trans; struct iwl_nic *nic; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index b16efc00ba6e..206a61c991dd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -692,7 +692,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first) { - struct iwl_cfg *cfg = cfg(nic); + const struct iwl_cfg *cfg = cfg(nic); const char *name_pre = cfg->fw_name_pre; char tag[8]; @@ -1045,7 +1045,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) { struct iwl_nic *nic = context; - struct iwl_cfg *cfg = cfg(nic); + const struct iwl_cfg *cfg = cfg(nic); struct iwl_fw *fw = &nic->fw; struct iwl_ucode_header *ucode; int err; -- GitLab From ce9e80af4f2c5dffb0df470538573d473c91d540 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:34 -0800 Subject: [PATCH 1417/1846] iwlwifi: reduce IDI code ifdef The code in the two branches of the #ifdef is almost the same so move the common code outside the #ifdef. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-pci.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index d109b0f32e33..c5e339ee918b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -278,17 +278,9 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) #ifdef CONFIG_IWLWIFI_IDI iwl_trans = iwl_trans_idi_alloc(shrd, pdev, ent); - if (iwl_trans == NULL) { - err = -ENOMEM; - goto out_free_bus; - } - - shrd->trans = iwl_trans; - pci_set_drvdata(pdev, iwl_trans); - - err = iwl_drv_start(shrd, iwl_trans, cfg); #else iwl_trans = iwl_trans_pcie_alloc(shrd, pdev, ent); +#endif if (iwl_trans == NULL) { err = -ENOMEM; goto out_free_bus; @@ -298,7 +290,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, iwl_trans); err = iwl_drv_start(shrd, iwl_trans, cfg); -#endif if (err) goto out_free_trans; -- GitLab From 2dd4f9f731f593a52a3fdca20bb32a78d917baf7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:35 -0800 Subject: [PATCH 1418/1846] iwlwifi: clean up (wowlan) suspend flow In the WoWLAN suspend flow, instead of accessing registers directly, ask the transport to do the required setup at the end of suspend. If the transport doesn't implement this, don't tell the stack we support WoWLAN. When the device suspends w/o WoWLAN, mac80211 will have stopped it already, which has already called iwl_apm_stop() via stop_hw(). Thus, it isn't necessary to call it again in pcie_suspend and we can simply do nothing there. This unifies the regular and WoWLAN suspend. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 5 ++- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 32 ++++++++----------- drivers/net/wireless/iwlwifi/iwl-trans.h | 11 +++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 8b26f3217823..8c7ca7318c00 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -196,6 +196,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_IBSS_RSN; if (nic(priv)->fw.ucode_wowlan.code.len && + trans(priv)->ops->wowlan_suspend && device_can_wakeup(trans(priv)->dev)) { hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT | @@ -412,9 +413,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, device_set_wakeup_enable(trans(priv)->dev, true); - /* Now let the ucode operate on its own */ - iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); + iwl_trans_wowlan_suspend(trans(priv)); goto out; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index f47426a5ef4d..bb8f2fdf1281 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1303,6 +1303,17 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); } +static void iwl_trans_pcie_wowlan_suspend(struct iwl_trans *trans) +{ + /* let the ucode operate on its own */ + iwl_write32(trans, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); + + iwl_disable_interrupts(trans); + iwl_clear_bit(trans, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); +} + static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, struct iwl_device_cmd *dev_cmd, enum iwl_rxon_context_id ctx, u8 sta_id, u8 tid) @@ -1641,25 +1652,6 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans) #ifdef CONFIG_PM_SLEEP static int iwl_trans_pcie_suspend(struct iwl_trans *trans) { - /* - * This function is called when system goes into suspend state - * mac80211 will call iwlagn_mac_stop() from the mac80211 suspend - * function first but since iwlagn_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. - * - * But of course ... if we have configured WoWLAN then we did other - * things already :-) - */ - if (!trans->shrd->wowlan) { - iwl_apm_stop(trans); - } else { - iwl_disable_interrupts(trans); - iwl_clear_bit(trans, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - } - return 0; } @@ -2227,6 +2219,8 @@ const struct iwl_trans_ops trans_ops_pcie = { .start_fw = iwl_trans_pcie_start_fw, .stop_device = iwl_trans_pcie_stop_device, + .wowlan_suspend = iwl_trans_pcie_wowlan_suspend, + .wake_any_queue = iwl_trans_pcie_wake_any_queue, .send_cmd = iwl_trans_pcie_send_cmd, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index e2f21cfc2cd4..83f04c9d77e5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -210,6 +210,9 @@ struct iwl_host_cmd { * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_* * @stop_device:stops the whole device (embedded CPU put to reset) * May sleep + * @wowlan_suspend: put the device into the correct mode for WoWLAN during + * suspend. This is optional, if not implemented WoWLAN will not be + * supported. This callback may sleep. * @send_cmd:send a host command * May sleep only if CMD_SYNC is set * @tx: send an skb @@ -247,6 +250,8 @@ struct iwl_trans_ops { void (*fw_alive)(struct iwl_trans *trans); void (*stop_device)(struct iwl_trans *trans); + void (*wowlan_suspend)(struct iwl_trans *trans); + void (*wake_any_queue)(struct iwl_trans *trans, enum iwl_rxon_context_id ctx, const char *msg); @@ -396,6 +401,12 @@ static inline void iwl_trans_stop_device(struct iwl_trans *trans) trans->state = IWL_TRANS_NO_FW; } +static inline void iwl_trans_wowlan_suspend(struct iwl_trans *trans) +{ + might_sleep(); + trans->ops->wowlan_suspend(trans); +} + static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, enum iwl_rxon_context_id ctx, const char *msg) -- GitLab From 15b86bff995525a38126eb44a951765a57ea2f4c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:36 -0800 Subject: [PATCH 1419/1846] iwlwifi: move wowlan bool into priv With the new WoWLAN flow into the transport there no longer is a need for this to be shared, so move it into priv. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-power.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 79ac7cb1701b..626b0d184729 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1193,7 +1193,7 @@ int iwlagn_suspend(struct iwl_priv *priv, iwl_trans_stop_device(trans(priv)); - priv->shrd->wowlan = true; + priv->wowlan = true; ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_WOWLAN); if (ret) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 222a8f46365f..7a713ba9bdee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -586,7 +586,7 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) sizeof(struct iwl_addsta_cmd)); send_lq = false; if (priv->stations[i].lq) { - if (priv->shrd->wowlan) + if (priv->wowlan) iwl_sta_fill_lq(priv, ctx, i, &lq); else memcpy(&lq, priv->stations[i].lq, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 2b722ccb730a..e5ebc36a14c8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -126,7 +126,7 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv, u8 data_retry_limit; u8 rate_plcp; - if (priv->shrd->wowlan) { + if (priv->wowlan) { rts_retry_limit = IWLAGN_LOW_RETRY_LIMIT; data_retry_limit = IWLAGN_LOW_RETRY_LIMIT; } else { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6cec7e63c171..6dd4faead7cd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -701,7 +701,7 @@ int iwl_alive_start(struct iwl_priv *priv) /* Configure Tx antenna selection based on H/W config */ iwlagn_send_tx_ant_config(priv, hw_params(priv).valid_tx_ant); - if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) { + if (iwl_is_associated_ctx(ctx) && !priv->wowlan) { struct iwl_rxon_cmd *active_rxon = (struct iwl_rxon_cmd *)&ctx->active; /* apply any changes in staging */ @@ -716,7 +716,7 @@ int iwl_alive_start(struct iwl_priv *priv) iwlagn_set_rxon_chain(priv, ctx); } - if (!priv->shrd->wowlan) { + if (!priv->wowlan) { /* WoWLAN ucode will not reply in the same way, skip it */ iwl_reset_run_time_calib(priv); } diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 9ea9002cc839..ef71463e84ea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -787,6 +787,8 @@ struct iwl_priv { bool new_scan_threshold_behaviour; + bool wowlan; + /* EEPROM MAC addresses */ struct mac_address addresses[2]; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 8c7ca7318c00..8160f615f71a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -418,7 +418,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, goto out; error: - priv->shrd->wowlan = false; + priv->wowlan = false; iwlagn_prepare_restart(priv); ieee80211_restart_hw(priv->hw); out: @@ -474,7 +474,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) /* we'll clear ctx->vif during iwlagn_prepare_restart() */ vif = ctx->vif; - priv->shrd->wowlan = false; + priv->wowlan = false; device_set_wakeup_enable(trans(priv)->dev, false); diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index fd008c4e41fd..1ef3c4da1605 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -348,7 +348,7 @@ static void iwl_power_build_cmd(struct iwl_priv *priv, dtimper = priv->hw->conf.ps_dtim_period ?: 1; - if (priv->shrd->wowlan) + if (priv->wowlan) iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper); else if (!cfg(priv)->base_params->no_idle_support && priv->hw->conf.flags & IEEE80211_CONF_IDLE) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 4efc9e13f9ec..a7dbcabafc96 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -371,7 +371,6 @@ struct iwl_shared { u8 ucode_owner; u8 cmd_queue; unsigned long status; - bool wowlan; u8 valid_contexts; const struct iwl_cfg *cfg; -- GitLab From 2c6ab7ff8fa9af22a2a616656da6e5a0567da285 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:37 -0800 Subject: [PATCH 1420/1846] iwlwifi: use ieee80211_tx_status We currently use the _irqsafe version, but that isn't recommended together with ieee80211_rx() as it can cause races. If the device reports a TX-status and RX in that order then with the current combination mac80211 might process them in the other order, which can cause issues with powersaving clients. Use ieee80211_tx_status() to avoid this race. Since we don't want to call it with locks held, process the frame queues later -- this is fine as they are on the stack. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 28 +++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index e5ebc36a14c8..1914bee1891e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -1007,6 +1007,8 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, if (is_agg) iwl_rx_reply_tx_agg(priv, tx_resp); + __skb_queue_head_init(&skbs); + if (tx_resp->frame_count == 1) { u16 next_reclaimed = le16_to_cpu(tx_resp->seq_ctl); next_reclaimed = SEQ_TO_SN(next_reclaimed + 0x10); @@ -1026,8 +1028,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, next_reclaimed = ssn; } - __skb_queue_head_init(&skbs); - if (tid != IWL_TID_NON_QOS) { priv->tid_data[sta_id][tid].next_reclaimed = next_reclaimed; @@ -1040,8 +1040,9 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, ssn, status, &skbs)); iwlagn_check_ratid_empty(priv, sta_id, tid); freed = 0; - while (!skb_queue_empty(&skbs)) { - skb = __skb_dequeue(&skbs); + + /* process frames */ + skb_queue_walk(&skbs, skb) { hdr = (struct ieee80211_hdr *)skb->data; if (!ieee80211_is_data_qos(hdr->frame_control)) @@ -1083,8 +1084,6 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, if (!is_agg) iwlagn_non_agg_tx_status(priv, ctx, hdr->addr1); - ieee80211_tx_status_irqsafe(priv->hw, skb); - freed++; } @@ -1093,6 +1092,12 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, iwl_check_abort_status(priv, tx_resp->frame_count, status); spin_unlock(&priv->sta_lock); + + while (!skb_queue_empty(&skbs)) { + skb = __skb_dequeue(&skbs); + ieee80211_tx_status(priv->hw, skb); + } + return 0; } @@ -1186,9 +1191,8 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, iwlagn_check_ratid_empty(priv, sta_id, tid); freed = 0; - while (!skb_queue_empty(&reclaimed_skbs)) { - skb = __skb_dequeue(&reclaimed_skbs); + skb_queue_walk(&reclaimed_skbs, skb) { hdr = (struct ieee80211_hdr *)skb->data; if (ieee80211_is_data_qos(hdr->frame_control)) @@ -1211,10 +1215,14 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, iwlagn_hwrate_to_tx_control(priv, agg->rate_n_flags, info); } - - ieee80211_tx_status_irqsafe(priv->hw, skb); } spin_unlock(&priv->sta_lock); + + while (!skb_queue_empty(&reclaimed_skbs)) { + skb = __skb_dequeue(&reclaimed_skbs); + ieee80211_tx_status(priv->hw, skb); + } + return 0; } -- GitLab From 65b94a4abfd55b3304be25ffed9832455d41e1dd Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:38 -0800 Subject: [PATCH 1421/1846] iwlwifi: pass response packet directly When CMD_WANT_SKB is set for a (synchronous) command, the response is passed back to the caller which is then responsible for freeing it. Make this more abstract with real API, passing directly the response packet in the new cmd.resp_pkt member and also introduce iwl_free_resp() to free the pages -- this way the upper layers don't have to directly touch the page implementation. NOTE: This breaks IDI -- the new code isn't reflected there yet! 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 | 6 +++--- drivers/net/wireless/iwlwifi/iwl-scan.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 5 ----- drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 16 ++++++++++------ drivers/net/wireless/iwlwifi/iwl-trans.h | 13 +++++++++++-- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 7a713ba9bdee..9ef8da47ad04 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -160,7 +160,7 @@ int iwl_send_add_sta(struct iwl_priv *priv, /*else the command was successfully sent in SYNC mode, need to free * the reply page */ - iwl_free_pages(priv->shrd, cmd.reply_page); + iwl_free_resp(&cmd); if (cmd.handler_status) IWL_ERR(priv, "%s - error in the CMD response %d", __func__, @@ -415,7 +415,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, if (ret) return ret; - pkt = (struct iwl_rx_packet *)cmd.reply_page; + pkt = cmd.resp_pkt; if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); @@ -438,7 +438,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, break; } } - iwl_free_pages(priv->shrd, cmd.reply_page); + iwl_free_resp(&cmd); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 766572b9ac89..c0fc3687a2fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -76,7 +76,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) if (ret) return ret; - pkt = (struct iwl_rx_packet *)cmd.reply_page; + pkt = cmd.resp_pkt; if (pkt->u.status != CAN_ABORT_STATUS) { /* The scan abort will return 1 for success or * 2 for "failure". A failure condition can be @@ -88,7 +88,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) ret = -EIO; } - iwl_free_pages(priv->shrd, cmd.reply_page); + iwl_free_resp(&cmd); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index a7dbcabafc96..53244d88f1ab 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -413,11 +413,6 @@ static inline bool iwl_have_debug_level(u32 level) return iwlagn_mod_params.debug_level & level; } -static inline void iwl_free_pages(struct iwl_shared *shrd, unsigned long page) -{ - free_pages(page, shrd->hw_params.rx_page_order); -} - /** * iwl_queue_inc_wrap - increment queue index, wrap back to beginning * @index -- current index diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 23eea06a74ad..cc1f3e990ad6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -292,7 +292,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) return ret; /* Handling return of SKB to the user */ - pkt = (struct iwl_rx_packet *)cmd.reply_page; + pkt = cmd.resp_pkt; if (!pkt) { IWL_ERR(priv, "HCMD received a null response packet\n"); return ret; @@ -309,7 +309,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) /* The reply is in a page, that we cannot send to user space. */ memcpy(reply_buf, &(pkt->hdr), reply_len); - iwl_free_pages(priv->shrd, cmd.reply_page); + iwl_free_resp(&cmd); NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index de2a0d91d658..771fae2f9fd8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -879,9 +879,13 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, /* 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); - meta->source->handler_status = handler_status; + struct page *p = rxb->page; + rxb->page = NULL; + meta->source->resp_pkt = pkt; + meta->source->_rx_page_addr = (unsigned long)page_address(p); + meta->source->_rx_page_order = hw_params(trans).rx_page_order; + meta->source->handler_status = handler_status; } iwl_hcmd_queue_reclaim(trans, txq_id, index); @@ -985,7 +989,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) } } - if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { + if ((cmd->flags & CMD_WANT_SKB) && !cmd->resp_pkt) { IWL_ERR(trans, "Error: Response NULL in '%s'\n", get_cmd_string(cmd->id)); ret = -EIO; @@ -1006,9 +1010,9 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ~CMD_WANT_SKB; } - if (cmd->reply_page) { - iwl_free_pages(trans->shrd, cmd->reply_page); - cmd->reply_page = 0; + if (cmd->resp_pkt) { + iwl_free_resp(cmd); + cmd->resp_pkt = NULL; } return ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 83f04c9d77e5..e8ab8d8ca484 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -173,7 +173,9 @@ enum iwl_hcmd_dataflag { * struct iwl_host_cmd - Host command to the uCode * * @data: array of chunks that composes the data of the host command - * @reply_page: pointer to the page that holds the response to the host command + * @resp_pkt: response packet, if %CMD_WANT_SKB was set + * @_rx_page_order: (internally used to free response packet) + * @_rx_page_addr: (internally used to free response packet) * @handler_status: return value of the handler of the command * (put in setup_rx_handlers) - valid for SYNC mode only * @flags: can be CMD_* @@ -183,7 +185,9 @@ enum iwl_hcmd_dataflag { */ struct iwl_host_cmd { const void *data[IWL_MAX_CMD_TFDS]; - unsigned long reply_page; + struct iwl_rx_packet *resp_pkt; + unsigned long _rx_page_addr; + u32 _rx_page_order; int handler_status; u32 flags; @@ -192,6 +196,11 @@ struct iwl_host_cmd { u8 id; }; +static inline void iwl_free_resp(struct iwl_host_cmd *cmd) +{ + free_pages(cmd->_rx_page_addr, cmd->_rx_page_order); +} + /** * struct iwl_trans_ops - transport specific operations * -- GitLab From 48a2d66f58d2bf1818acf5ff7ed9897a9977a96e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:39 -0800 Subject: [PATCH 1422/1846] iwlwifi: don't pass iwl_rx_mem_buffer to upper layers struct iwl_rx_mem_buffer implementation details (DMA address, list pointers) that the upper layers don't need. Introduce iwl_rx_cmd_buffer that is passed upstream and only contains the needed data (the page). Additionally, access this data only via accessor functions, allowing us to change the implementation in the future. These accessors are rxb_addr() (as before) and rxb_steal_page() to take ownership of the data. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 41 ++++++++++--------- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 4 +- drivers/net/wireless/iwlwifi/iwl-agn.h | 12 +++--- drivers/net/wireless/iwlwifi/iwl-dev.h | 4 +- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 6 +-- drivers/net/wireless/iwlwifi/iwl-scan.c | 8 ++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 18 +++++--- drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 +- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 8 +++- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 21 ++++++---- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 5 +-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 2 +- 14 files changed, 80 insertions(+), 57 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 626b0d184729..e96af5133e06 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -707,7 +707,7 @@ static void iwlagn_set_kill_msk(struct iwl_priv *priv, } int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index bc21586aed63..8e025e0df50d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -131,7 +131,7 @@ const char *get_cmd_string(u8 cmd) ******************************************************************************/ static int iwlagn_rx_reply_error(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -146,7 +146,7 @@ static int iwlagn_rx_reply_error(struct iwl_priv *priv, return 0; } -static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, +static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -177,7 +177,7 @@ static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, static int iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -195,7 +195,7 @@ static int iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv, } static int iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { #ifdef CONFIG_IWLWIFI_DEBUG @@ -208,7 +208,7 @@ static int iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv, } static int iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -222,7 +222,7 @@ static int iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv, } static int iwlagn_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -489,7 +489,7 @@ iwlagn_accumulative_statistics(struct iwl_priv *priv, #endif static int iwlagn_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { unsigned long stamp = jiffies; @@ -597,7 +597,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, } static int iwlagn_rx_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -620,7 +620,7 @@ static int iwlagn_rx_reply_statistics(struct iwl_priv *priv, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -673,7 +673,7 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, } static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { @@ -698,7 +698,7 @@ static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv, /* 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. */ static int iwlagn_rx_reply_rx_phy(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -765,12 +765,14 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct ieee80211_rx_status *stats) { struct sk_buff *skb; __le16 fc = hdr->frame_control; struct iwl_rxon_context *ctx; + struct page *p; + int offset; /* We only process data packets if the interface is open */ if (unlikely(!priv->is_open)) { @@ -790,7 +792,9 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv, return; } - skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); + offset = (void *)hdr - rxb_addr(rxb); + p = rxb_steal_page(rxb); + skb_add_rx_frag(skb, 0, p, offset, len); iwl_update_stats(priv, false, fc, len); @@ -817,7 +821,6 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv, memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); ieee80211_rx(priv->hw, skb); - rxb->page = NULL; } static u32 iwlagn_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in) @@ -923,7 +926,7 @@ static int iwlagn_calc_rssi(struct iwl_priv *priv, /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ static int iwlagn_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct ieee80211_hdr *header; @@ -1043,7 +1046,7 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv, } static int iwlagn_rx_noa_notification(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_wipan_noa_data *new_data, *old_data; @@ -1094,7 +1097,7 @@ static int iwlagn_rx_noa_notification(struct iwl_priv *priv, */ void iwl_setup_rx_handlers(struct iwl_priv *priv) { - int (**handlers)(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, + int (**handlers)(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); handlers = priv->rx_handlers; @@ -1149,8 +1152,8 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) } -int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_mem_buffer *rxb, - struct iwl_device_cmd *cmd) +int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, + struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 9ef8da47ad04..736f8dc404df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -123,7 +123,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, return ret; } -int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, +int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 1914bee1891e..dd28785e1a5c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -977,7 +977,7 @@ static void iwl_check_abort_status(struct iwl_priv *priv, } } -int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, +int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -1108,7 +1108,7 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, * of frames sent via aggregation. */ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index a142a197b2e4..a9c018a7b8ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -82,7 +82,7 @@ void iwl_cancel_deferred_work(struct iwl_priv *priv); void iwlagn_prepare_restart(struct iwl_priv *priv); void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb); int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac); @@ -110,7 +110,7 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf, /* uCode */ int iwlagn_rx_calib_result(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags); @@ -142,9 +142,9 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif, int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); -int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, +int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); static inline u32 iwl_tx_status_to_mac80211(u32 status) @@ -179,7 +179,7 @@ void iwlagn_disable_roc(struct iwl_priv *priv); /* bt coex */ void iwlagn_send_advance_bt_config(struct iwl_priv *priv); int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv); void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv); @@ -227,7 +227,7 @@ void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id, struct iwl_link_quality_cmd *link_cmd); int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, struct iwl_link_quality_cmd *lq, u8 flags, bool init); -int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, +int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index ef71463e84ea..5957209b2f37 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -729,9 +729,9 @@ struct iwl_priv { enum ieee80211_band band; void (*pre_rx_handler)(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); + struct iwl_rx_cmd_buffer *rxb); int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index d4fc9be2d2f3..41e58a136715 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -67,7 +67,7 @@ struct iwl_op_mode; struct iwl_trans; struct sk_buff; struct iwl_device_cmd; -struct iwl_rx_mem_buffer; +struct iwl_rx_cmd_buffer; /** * DOC: Operational mode - what is it ? @@ -125,7 +125,7 @@ struct iwl_rx_mem_buffer; struct iwl_op_mode_ops { struct iwl_op_mode *(*start)(struct iwl_trans *trans); void (*stop)(struct iwl_op_mode *op_mode); - int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_mem_buffer *rxb, + int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); void (*queue_full)(struct iwl_op_mode *op_mode, u8 ac); void (*queue_not_full)(struct iwl_op_mode *op_mode, u8 ac); @@ -156,7 +156,7 @@ static inline void iwl_op_mode_stop(struct iwl_op_mode *op_mode) } static inline int iwl_op_mode_rx(struct iwl_op_mode *op_mode, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { return op_mode->ops->rx(op_mode, rxb, cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index c0fc3687a2fd..28899dabe6fb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -260,7 +260,7 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) /* Service response to REPLY_SCAN_CMD (0x80) */ static int iwl_rx_reply_scan(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { #ifdef CONFIG_IWLWIFI_DEBUG @@ -275,7 +275,7 @@ static int iwl_rx_reply_scan(struct iwl_priv *priv, /* Service SCAN_START_NOTIFICATION (0x82) */ static int iwl_rx_scan_start_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -302,7 +302,7 @@ static int iwl_rx_scan_start_notif(struct iwl_priv *priv, /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ static int iwl_rx_scan_results_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { #ifdef CONFIG_IWLWIFI_DEBUG @@ -328,7 +328,7 @@ static int iwl_rx_scan_results_notif(struct iwl_priv *priv, /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ static int iwl_rx_scan_complete_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 53244d88f1ab..ed1811d43550 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -433,13 +433,21 @@ static inline int iwl_queue_dec_wrap(int index, int n_bd) return --index & (n_bd - 1); } -struct iwl_rx_mem_buffer { - dma_addr_t page_dma; - struct page *page; - struct list_head list; +struct iwl_rx_cmd_buffer { + struct page *_page; }; -#define rxb_addr(r) page_address(r->page) +static inline void *rxb_addr(struct iwl_rx_cmd_buffer *r) +{ + return page_address(r->_page); +} + +static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) +{ + struct page *p = r->_page; + r->_page = NULL; + return p; +} /* * mac80211 queues, ACs, hardware queues, FIFOs. diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index cc1f3e990ad6..b24b166a9482 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -131,7 +131,7 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { * 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) +static inline int get_event_length(struct iwl_rx_cmd_buffer *rxb) { struct iwl_rx_packet *pkt = rxb_addr(rxb); if (pkt) @@ -162,7 +162,7 @@ static inline int get_event_length(struct iwl_rx_mem_buffer *rxb) */ static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) + struct iwl_rx_cmd_buffer *rxb) { struct ieee80211_hw *hw = priv->hw; struct sk_buff *skb; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index b1029468ccbd..632d4099900e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -49,6 +49,12 @@ struct iwl_host_cmd; /*This file includes the declaration that are internal to the * trans_pcie layer */ +struct iwl_rx_mem_buffer { + dma_addr_t page_dma; + struct page *page; + struct list_head list; +}; + /** * struct isr_statistics - interrupt statistics * @@ -287,7 +293,7 @@ int iwlagn_txq_attach_buf_to_tfd(struct iwl_trans *trans, int iwl_queue_init(struct iwl_queue *q, int count, int slots_num, u32 id); int iwl_trans_pcie_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd); void iwl_tx_cmd_complete(struct iwl_trans *trans, - struct iwl_rx_mem_buffer *rxb, int handler_status); + struct iwl_rx_cmd_buffer *rxb, int handler_status); void iwl_trans_txq_update_byte_cnt_tbl(struct iwl_trans *trans, struct iwl_tx_queue *txq, u16 byte_cnt); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 6495945637b9..68e89be60bef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -367,8 +367,6 @@ void iwl_bg_rx_replenish(struct work_struct *data) */ static void iwl_rx_handle(struct iwl_trans *trans) { - struct iwl_rx_mem_buffer *rxb; - struct iwl_rx_packet *pkt; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_rx_queue *rxq = &trans_pcie->rxq; @@ -402,6 +400,9 @@ static void iwl_rx_handle(struct iwl_trans *trans) while (i != r) { int len, err; u16 sequence; + struct iwl_rx_mem_buffer *rxb; + struct iwl_rx_cmd_buffer rxcb; + struct iwl_rx_packet *pkt; rxb = rxq->queue[i]; @@ -418,7 +419,9 @@ static void iwl_rx_handle(struct iwl_trans *trans) dma_unmap_page(trans->dev, rxb->page_dma, PAGE_SIZE << hw_params(trans).rx_page_order, DMA_FROM_DEVICE); - pkt = rxb_addr(rxb); + + rxcb._page = rxb->page; + pkt = rxb_addr(&rxcb); IWL_DEBUG_RX(trans, "r = %d, i = %d, %s, 0x%02x\n", r, i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -461,10 +464,10 @@ static void iwl_rx_handle(struct iwl_trans *trans) "reclaim is false, SEQ_RX_FRAME unset: %s\n", get_cmd_string(pkt->hdr.cmd)); - err = iwl_op_mode_rx(trans->op_mode, rxb, cmd); + err = iwl_op_mode_rx(trans->op_mode, &rxcb, cmd); /* - * XXX: After here, we should always check rxb->page + * XXX: After here, we should always check rxcb._page * against NULL before touching it or its virtual * memory (pkt). Because some rx_handler might have * already taken or freed the pages. @@ -475,12 +478,16 @@ static void iwl_rx_handle(struct iwl_trans *trans) * and fire off the (possibly) blocking * iwl_trans_send_cmd() * as we reclaim the driver command queue */ - if (rxb->page) - iwl_tx_cmd_complete(trans, rxb, err); + if (rxcb._page) + iwl_tx_cmd_complete(trans, &rxcb, err); else IWL_WARN(trans, "Claim null rxb?\n"); } + /* page was stolen from us */ + if (rxcb._page == NULL) + rxb->page = NULL; + /* 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. */ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 771fae2f9fd8..0513b90da040 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -841,7 +841,7 @@ static void iwl_hcmd_queue_reclaim(struct iwl_trans *trans, int txq_id, * will be executed. The attached skb (if present) will only be freed * if the callback returns 1 */ -void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, +void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb, int handler_status) { struct iwl_rx_packet *pkt = rxb_addr(rxb); @@ -879,9 +879,8 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, /* Input error checking is done when commands are added to queue. */ if (meta->flags & CMD_WANT_SKB) { - struct page *p = rxb->page; + struct page *p = rxb_steal_page(rxb); - rxb->page = NULL; meta->source->resp_pkt = pkt; meta->source->_rx_page_addr = (unsigned long)page_address(p); meta->source->_rx_page_order = hw_params(trans).rx_page_order; diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 206a61c991dd..12e79d04374f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -228,7 +228,7 @@ static int iwl_send_calib_cfg(struct iwl_trans *trans) } int iwlagn_rx_calib_result(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, + struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); -- GitLab From df2f3216ccde52bb43df78e0b869a0dd1637cf15 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:40 -0800 Subject: [PATCH 1423/1846] iwlwifi: refactor PCI-E RX path Just make the code easier to read with less indentation. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 216 +++++++++--------- 1 file changed, 110 insertions(+), 106 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 68e89be60bef..bf560e9f87b7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -358,6 +358,113 @@ void iwl_bg_rx_replenish(struct work_struct *data) iwlagn_rx_replenish(trans_pcie->trans); } +static void iwl_rx_handle_rxbuf(struct iwl_trans *trans, + struct iwl_rx_mem_buffer *rxb) +{ + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_rx_queue *rxq = &trans_pcie->rxq; + struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue]; + struct iwl_device_cmd *cmd; + unsigned long flags; + int len, err; + u16 sequence; + struct iwl_rx_cmd_buffer rxcb; + struct iwl_rx_packet *pkt; + bool reclaim; + int index, cmd_index; + + if (WARN_ON(!rxb)) + return; + + dma_unmap_page(trans->dev, rxb->page_dma, + PAGE_SIZE << hw_params(trans).rx_page_order, + DMA_FROM_DEVICE); + + rxcb._page = rxb->page; + pkt = rxb_addr(&rxcb); + + IWL_DEBUG_RX(trans, "%s, 0x%02x\n", + get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + + + len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len += sizeof(u32); /* account for status word */ + trace_iwlwifi_dev_rx(priv(trans), pkt, len); + + /* 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); + + sequence = le16_to_cpu(pkt->hdr.sequence); + index = SEQ_TO_INDEX(sequence); + cmd_index = get_cmd_index(&txq->q, index); + + if (reclaim) + cmd = txq->cmd[cmd_index]; + else + cmd = NULL; + + /* warn if this is cmd response / notification and the uCode + * didn't set the SEQ_RX_FRAME for a frame that is + * uCode-originated + * If you saw this code after the second half of 2012, then + * please remove it + */ + WARN(pkt->hdr.cmd != REPLY_TX && reclaim == false && + (!(pkt->hdr.sequence & SEQ_RX_FRAME)), + "reclaim is false, SEQ_RX_FRAME unset: %s\n", + get_cmd_string(pkt->hdr.cmd)); + + err = iwl_op_mode_rx(trans->op_mode, &rxcb, cmd); + + /* + * XXX: After here, we should always check rxcb._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 + * iwl_trans_send_cmd() + * as we reclaim the driver command queue */ + if (rxcb._page) + iwl_tx_cmd_complete(trans, &rxcb, err); + else + IWL_WARN(trans, "Claim null rxb?\n"); + } + + /* page was stolen from us */ + if (rxcb._page == NULL) + rxb->page = NULL; + + /* 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 = + dma_map_page(trans->dev, rxb->page, 0, + PAGE_SIZE << hw_params(trans).rx_page_order, + DMA_FROM_DEVICE); + 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); +} + /** * iwl_rx_handle - Main entry function for receiving responses from uCode * @@ -367,18 +474,12 @@ void iwl_bg_rx_replenish(struct work_struct *data) */ static void iwl_rx_handle(struct iwl_trans *trans) { - struct iwl_trans_pcie *trans_pcie = - IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_rx_queue *rxq = &trans_pcie->rxq; - struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue]; - struct iwl_device_cmd *cmd; u32 r, i; - int reclaim; - unsigned long flags; u8 fill_rx = 0; u32 count = 8; int total_empty; - int index, cmd_index; /* uCode's read index (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ @@ -398,111 +499,14 @@ static void iwl_rx_handle(struct iwl_trans *trans) fill_rx = 1; while (i != r) { - int len, err; - u16 sequence; struct iwl_rx_mem_buffer *rxb; - struct iwl_rx_cmd_buffer rxcb; - struct iwl_rx_packet *pkt; 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 */ - if (WARN_ON(rxb == NULL)) { - i = (i + 1) & RX_QUEUE_MASK; - continue; - } - rxq->queue[i] = NULL; - dma_unmap_page(trans->dev, rxb->page_dma, - PAGE_SIZE << hw_params(trans).rx_page_order, - DMA_FROM_DEVICE); - - rxcb._page = rxb->page; - pkt = rxb_addr(&rxcb); - - IWL_DEBUG_RX(trans, "r = %d, i = %d, %s, 0x%02x\n", r, - i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ - trace_iwlwifi_dev_rx(priv(trans), pkt, len); - - /* 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); - - sequence = le16_to_cpu(pkt->hdr.sequence); - index = SEQ_TO_INDEX(sequence); - cmd_index = get_cmd_index(&txq->q, index); - - if (reclaim) - cmd = txq->cmd[cmd_index]; - else - cmd = NULL; - - /* warn if this is cmd response / notification and the uCode - * didn't set the SEQ_RX_FRAME for a frame that is - * uCode-originated - * If you saw this code after the second half of 2012, then - * please remove it - */ - WARN(pkt->hdr.cmd != REPLY_TX && reclaim == false && - (!(pkt->hdr.sequence & SEQ_RX_FRAME)), - "reclaim is false, SEQ_RX_FRAME unset: %s\n", - get_cmd_string(pkt->hdr.cmd)); - - err = iwl_op_mode_rx(trans->op_mode, &rxcb, cmd); - - /* - * XXX: After here, we should always check rxcb._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 - * iwl_trans_send_cmd() - * as we reclaim the driver command queue */ - if (rxcb._page) - iwl_tx_cmd_complete(trans, &rxcb, err); - else - IWL_WARN(trans, "Claim null rxb?\n"); - } - - /* page was stolen from us */ - if (rxcb._page == NULL) - rxb->page = NULL; + IWL_DEBUG_RX(trans, "rxbuf: r = %d, i = %d (%p)\n", rxb); - /* 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 = dma_map_page(trans->dev, rxb->page, - 0, PAGE_SIZE << - hw_params(trans).rx_page_order, - DMA_FROM_DEVICE); - 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); + iwl_rx_handle_rxbuf(trans, rxb); i = (i + 1) & RX_QUEUE_MASK; /* If there are a lot of unused frames, -- GitLab From c977a33d84fb3d706faa0b62f9671f49b16dde34 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:41 -0800 Subject: [PATCH 1424/1846] iwlwifi: transport's tx_agg_alloc must not sleep The annotation/documentation is wrong, we call it in a context that can't sleep. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index e8ab8d8ca484..0197f31f3bec 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -229,7 +229,7 @@ static inline void iwl_free_resp(struct iwl_host_cmd *cmd) * @reclaim: free packet until ssn. Returns a list of freed packets. * Must be atomic * @tx_agg_alloc: allocate resources for a TX BA session - * May sleep + * Must be atomic * @tx_agg_setup: setup a tx queue for AMPDU - will be called once the HW is * ready and a successful ADDBA response has been received. * May sleep @@ -474,8 +474,6 @@ static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, static inline int iwl_trans_tx_agg_alloc(struct iwl_trans *trans, int sta_id, int tid) { - might_sleep(); - if (trans->state != IWL_TRANS_FW_ALIVE) IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); -- GitLab From bffc66ce2210b149fd171eccad2aef9802c0b35d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:42 -0800 Subject: [PATCH 1425/1846] iwlwifi: move queue functions to PCI-E iwl_queue_inc_wrap/iwl_queue_dec_wrap aren't shared functions, they are PCI-E specific, so move them into the appropriate header. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-shared.h | 20 ------------------- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index ed1811d43550..787d726efbc8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -413,26 +413,6 @@ static inline bool iwl_have_debug_level(u32 level) return iwlagn_mod_params.debug_level & level; } -/** - * iwl_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_queue_inc_wrap(int index, int n_bd) -{ - return ++index & (n_bd - 1); -} - -/** - * iwl_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_queue_dec_wrap(int index, int n_bd) -{ - return --index & (n_bd - 1); -} - struct iwl_rx_cmd_buffer { struct page *_page; }; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 632d4099900e..44952c371d33 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -115,6 +115,26 @@ struct iwl_dma_ptr { size_t size; }; +/** + * iwl_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_queue_inc_wrap(int index, int n_bd) +{ + return ++index & (n_bd - 1); +} + +/** + * iwl_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_queue_dec_wrap(int index, int n_bd) +{ + return --index & (n_bd - 1); +} + /* * This queue number is required for proper operation * because the ucode will stop/start the scheduler as -- GitLab From 930dfd5f20eba2cef41cdb2db04108b359b97594 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:43 -0800 Subject: [PATCH 1426/1846] iwlwifi: iwl_rx_cmd_buffer belongs to transport API This is how the transport passes things up into higher layers, so it belongs to the transport API. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-shared.h | 17 ----------------- drivers/net/wireless/iwlwifi/iwl-trans.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 787d726efbc8..2b9d21a7207d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -67,7 +67,6 @@ #include #include #include -#include /* for page_address */ #include #include "iwl-commands.h" @@ -413,22 +412,6 @@ static inline bool iwl_have_debug_level(u32 level) return iwlagn_mod_params.debug_level & level; } -struct iwl_rx_cmd_buffer { - struct page *_page; -}; - -static inline void *rxb_addr(struct iwl_rx_cmd_buffer *r) -{ - return page_address(r->_page); -} - -static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) -{ - struct page *p = r->_page; - r->_page = NULL; - return p; -} - /* * mac80211 queues, ACs, hardware queues, FIFOs. * diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 0197f31f3bec..b09192a028de 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -64,6 +64,7 @@ #define __iwl_trans_h__ #include +#include /* for page_address */ #include "iwl-shared.h" #include "iwl-debug.h" @@ -201,6 +202,22 @@ static inline void iwl_free_resp(struct iwl_host_cmd *cmd) free_pages(cmd->_rx_page_addr, cmd->_rx_page_order); } +struct iwl_rx_cmd_buffer { + struct page *_page; +}; + +static inline void *rxb_addr(struct iwl_rx_cmd_buffer *r) +{ + return page_address(r->_page); +} + +static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) +{ + struct page *p = r->_page; + r->_page = NULL; + return p; +} + /** * struct iwl_trans_ops - transport specific operations * -- GitLab From 70a18c5d57998433d9f4de058a5286fbd16ed839 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:44 -0800 Subject: [PATCH 1427/1846] iwlwifi: move tid_to_ac to PCI-E Currently, queue mapping is handled in the transport. This may change, but until then the code for it can be close to where it's used rather than in iwl-shared.h. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-shared.h | 46 ------------------- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 2b9d21a7207d..740a058b22ee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -412,52 +412,6 @@ static inline bool iwl_have_debug_level(u32 level) return iwlagn_mod_params.debug_level & level; } -/* - * 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, iwl-5000.c etc.), 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 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; -} - enum iwl_rxon_context_id { IWL_RXON_CTX_BSS, IWL_RXON_CTX_PAN, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 0513b90da040..0164154f9c97 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -41,6 +41,43 @@ #define IWL_TX_CRC_SIZE 4 #define IWL_TX_DELIMITER_SIZE 4 +/* + * 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 code), 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 +}; + + /** * iwl_trans_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ @@ -442,6 +479,15 @@ void iwl_trans_tx_queue_set_status(struct iwl_trans *trans, scd_retry ? "BA" : "AC/CMD", txq_id); } +static inline int 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 get_fifo_from_tid(struct iwl_trans_pcie *trans_pcie, u8 ctx, u16 tid) { -- GitLab From 0439bb6200153406abb81b469b82d2336be0d175 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:45 -0800 Subject: [PATCH 1428/1846] iwlwifi: move IWL_MASK into file using it Only used in two places in the same file, no need to be in iwl-shared.h. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 740a058b22ee..976e6c584ac7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -444,7 +444,6 @@ iwl_remove_notification(struct iwl_shared *shrd, struct iwl_notification_wait *wait_entry); #define IWL_CMD(x) case x: return #x -#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) #define IWL_TRAFFIC_ENTRIES (256) #define IWL_TRAFFIC_ENTRY_SIZE (64) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index bb8f2fdf1281..3ae2fd720ed8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -78,6 +78,8 @@ #include "iwl-core.h" #include "iwl-ucode.h" +#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) + static int iwl_trans_rx_alloc(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = -- GitLab From 61f0439277abb4f65d99b362b62cbabbde7032a0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:46 -0800 Subject: [PATCH 1429/1846] iwlwifi: move traffic log definitions These are DVM specific, and shouldn't be in iwl-shared.h. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.h | 4 ++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 42630f5e8de7..db44115a6775 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -265,6 +265,10 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, #define IWL_SCAN_CHECK_WATCHDOG (HZ * 7) +/* traffic log definitions */ +#define IWL_TRAFFIC_ENTRIES (256) +#define IWL_TRAFFIC_ENTRY_SIZE (64) + /***************************************************** * S e n d i n g H o s t C o m m a n d s * *****************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 976e6c584ac7..b816e70d1445 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -445,9 +445,6 @@ iwl_remove_notification(struct iwl_shared *shrd, #define IWL_CMD(x) case x: return #x -#define IWL_TRAFFIC_ENTRIES (256) -#define IWL_TRAFFIC_ENTRY_SIZE (64) - /***************************************************** * DRIVER STATUS FUNCTIONS ******************************************************/ -- GitLab From ab0bd5b32a9c7ea2e7cc69d56c82a96be340c269 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:47 -0800 Subject: [PATCH 1430/1846] iwlwifi: fix station HT parameters My patch "iwlwifi: simplify auth/assoc flow" caused a serious throughput degradation due to me forgetting that there are HT settings in the station table. To restore throughput, set these parameters correctly when the sta moves to assoc state. This patch should probably be merged with the auth/assoc redesign patch for upstream. In that case, this paragraph should be added to the commit log as the third paragraph (before talking about RXON): However, as we only get the station HT data when the station moves into assoc state, we also need to program this into the device (and copy it into our database) then. 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 | 81 +++++++++++++++------ drivers/net/wireless/iwlwifi/iwl-agn.h | 2 + drivers/net/wireless/iwlwifi/iwl-mac80211.c | 18 ++++- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 736f8dc404df..ca080265a829 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -169,34 +169,38 @@ int iwl_send_add_sta(struct iwl_priv *priv, return cmd.handler_status; } -static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, - struct ieee80211_sta *sta, - struct iwl_rxon_context *ctx) +static void iwl_sta_calc_ht_flags(struct iwl_priv *priv, + struct ieee80211_sta *sta, + struct iwl_rxon_context *ctx, + __le32 *flags, __le32 *mask) { struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; - __le32 sta_flags; u8 mimo_ps_mode; + *mask = STA_FLG_RTS_MIMO_PROT_MSK | + STA_FLG_MIMO_DIS_MSK | + STA_FLG_HT40_EN_MSK | + STA_FLG_MAX_AGG_SIZE_MSK | + STA_FLG_AGG_MPDU_DENSITY_MSK; + *flags = 0; + if (!sta || !sta_ht_inf->ht_supported) - goto done; + return; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", + + IWL_DEBUG_INFO(priv, "STA %pM SM PS 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 &= ~(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; + *flags |= STA_FLG_MIMO_DIS_MSK; break; case WLAN_HT_CAP_SM_PS_DYNAMIC: - sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; + *flags |= STA_FLG_RTS_MIMO_PROT_MSK; break; case WLAN_HT_CAP_SM_PS_DISABLED: break; @@ -205,20 +209,53 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, break; } - sta_flags |= cpu_to_le32( - (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); + *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); + *flags |= cpu_to_le32( + (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) - sta_flags |= STA_FLG_HT40_EN_MSK; - else - sta_flags &= ~STA_FLG_HT40_EN_MSK; + *flags |= STA_FLG_HT40_EN_MSK; +} + +int iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx, + struct ieee80211_sta *sta) +{ + u8 sta_id = iwl_sta_id(sta); + __le32 flags, mask; + struct iwl_addsta_cmd cmd; + + if (WARN_ON_ONCE(sta_id == IWL_INVALID_STATION)) + return -EINVAL; - priv->stations[index].sta.station_flags = sta_flags; - done: - return; + iwl_sta_calc_ht_flags(priv, sta, ctx, &flags, &mask); + + spin_lock_bh(&priv->sta_lock); + priv->stations[sta_id].sta.station_flags &= ~mask; + priv->stations[sta_id].sta.station_flags |= flags; + spin_unlock_bh(&priv->sta_lock); + + memset(&cmd, 0, sizeof(cmd)); + cmd.mode = STA_CONTROL_MODIFY_MSK; + cmd.station_flags_msk = mask; + cmd.station_flags = flags; + cmd.sta.sta_id = sta_id; + + return iwl_send_add_sta(priv, &cmd, CMD_SYNC); +} + +static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, + struct ieee80211_sta *sta, + struct iwl_rxon_context *ctx) +{ + __le32 flags, mask; + + iwl_sta_calc_ht_flags(priv, sta, ctx, &flags, &mask); + + lockdep_assert_held(&priv->sta_lock); + priv->stations[index].sta.station_flags &= ~mask; + priv->stations[index].sta.station_flags |= flags; } /** diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index a9c018a7b8ba..70100f9a2e5c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -229,6 +229,8 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, struct iwl_link_quality_cmd *lq, u8 flags, bool init); int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); +int iwl_sta_update_ht(struct iwl_priv *priv, struct iwl_rxon_context *ctx, + struct ieee80211_sta *sta); static inline int iwl_sta_id(struct ieee80211_sta *sta) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 8160f615f71a..7f937151a8af 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -740,8 +740,9 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, enum ieee80211_sta_state new_state) { struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; enum { - NONE, ADD, REMOVE, RATE_INIT, ADD_RATE_INIT, + NONE, ADD, REMOVE, HT_RATE_INIT, ADD_RATE_INIT, } op = NONE; int ret; @@ -758,7 +759,7 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, op = REMOVE; else if (old_state == IEEE80211_STA_AUTH && new_state == IEEE80211_STA_ASSOC) - op = RATE_INIT; + op = HT_RATE_INIT; } else { if (old_state == IEEE80211_STA_AUTH && new_state == IEEE80211_STA_ASSOC) @@ -779,8 +780,6 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, ret = iwlagn_mac_sta_add(hw, vif, sta); if (ret) break; - /* fall through */ - case RATE_INIT: /* Initialize rate scaling */ IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", @@ -788,6 +787,17 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, iwl_rs_rate_init(priv, sta, iwl_sta_id(sta)); ret = 0; break; + case HT_RATE_INIT: + /* Initialize rate scaling */ + ret = iwl_sta_update_ht(priv, vif_priv->ctx, sta); + if (ret) + break; + IWL_DEBUG_INFO(priv, + "Initializing rate scaling for station %pM\n", + sta->addr); + iwl_rs_rate_init(priv, sta, iwl_sta_id(sta)); + ret = 0; + break; default: ret = 0; break; -- GitLab From 7db5b989a0e28a40ce61ef0b26da1af18289d711 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:48 -0800 Subject: [PATCH 1431/1846] iwlwifi: move uCode deallocation to drv This shouldn't be in the op_mode, as it will later be switchable at runtime. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 -- drivers/net/wireless/iwlwifi/iwl-drv.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6dd4faead7cd..c3b594647def 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1385,8 +1385,6 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) /*This will stop the queues, move the device to low power state */ iwl_trans_stop_device(trans(priv)); - iwl_dealloc_ucode(nic(priv)); - iwl_eeprom_free(priv->shrd); /*netif_stop_queue(dev); */ diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 76fc4407b19e..590f57662754 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -99,5 +99,7 @@ void iwl_drv_stop(struct iwl_shared *shrd) if (shrd->nic->op_mode) iwl_op_mode_stop(shrd->nic->op_mode); + iwl_dealloc_ucode(shrd->nic); + kfree(shrd->nic); } -- GitLab From 702e0630ee50c5f72e84da59daf5b23729140b62 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:49 -0800 Subject: [PATCH 1432/1846] iwlwifi: move iwl_base_params to shared header This is used from there, so should be in it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.h | 42 ---------------------- drivers/net/wireless/iwlwifi/iwl-shared.h | 43 +++++++++++++++++++++++ 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index db44115a6775..7259cbf77da4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -95,48 +95,6 @@ struct iwl_lib_ops { void (*temperature)(struct iwl_priv *priv); }; -/* - * @max_ll_items: max number of OTP blocks - * @shadow_ram_support: shadow support for OTP memory - * @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 - * @adv_thermal_throttle: support advance thermal throttle - * @support_ct_kill_exit: support ct kill exit condition - * @support_wimax_coexist: support wimax/wifi co-exist - * @plcp_delta_threshold: plcp error rate threshold used to trigger - * radio tuning when there is a high receiving plcp error rate - * @chain_noise_scale: default chain noise scale used for gain computation - * @wd_timeout: TX queues watchdog timeout - * @max_event_log_size: size of event log buffer size for ucode event logging - * @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; - int num_of_queues; /* def: HW dependent */ - int num_of_ampdu_queues;/* def: HW dependent */ - /* for iwl_apm_init() */ - u32 pll_cfg_val; - - const u16 max_ll_items; - const bool shadow_ram_support; - u16 led_compensation; - bool adv_thermal_throttle; - bool support_ct_kill_exit; - const bool support_wimax_coexist; - u8 plcp_delta_threshold; - s32 chain_noise_scale; - unsigned int wd_timeout; - u32 max_event_log_size; - 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 * @bt_init_traffic_load: specify initial bt traffic load diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index b816e70d1445..ef80e0386c30 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -267,6 +267,49 @@ enum iwl_led_mode { IWL_LED_DISABLE, }; +/* + * @max_ll_items: max number of OTP blocks + * @shadow_ram_support: shadow support for OTP memory + * @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 + * @adv_thermal_throttle: support advance thermal throttle + * @support_ct_kill_exit: support ct kill exit condition + * @support_wimax_coexist: support wimax/wifi co-exist + * @plcp_delta_threshold: plcp error rate threshold used to trigger + * radio tuning when there is a high receiving plcp error rate + * @chain_noise_scale: default chain noise scale used for gain computation + * @wd_timeout: TX queues watchdog timeout + * @max_event_log_size: size of event log buffer size for ucode event logging + * @shadow_reg_enable: HW shadhow register bit + * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up + * @no_idle_support: do not support idle mode + * wd_disable: disable watchdog timer + */ +struct iwl_base_params { + int eeprom_size; + int num_of_queues; /* def: HW dependent */ + int num_of_ampdu_queues;/* def: HW dependent */ + /* for iwl_apm_init() */ + u32 pll_cfg_val; + + const u16 max_ll_items; + const bool shadow_ram_support; + u16 led_compensation; + bool adv_thermal_throttle; + bool support_ct_kill_exit; + const bool support_wimax_coexist; + u8 plcp_delta_threshold; + s32 chain_noise_scale; + unsigned int wd_timeout; + u32 max_event_log_size; + const bool shadow_reg_enable; + const bool hd_v2; + const bool no_idle_support; + const bool wd_disable; +}; + /** * struct iwl_cfg * @name: Offical name of the device -- GitLab From 15854ef94f54ae8fa8b95eb66a2cfa5dcff481e9 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:50 -0800 Subject: [PATCH 1433/1846] iwlwifi: move firmware request into drv Firmware request is a base driver flow, it isn't related to any specific mode. Move the code related to it into the base driver file iwl-drv.c. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-drv.c | 625 +++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-ucode.c | 622 ---------------------- drivers/net/wireless/iwlwifi/iwl-wifi.h | 5 - 3 files changed, 625 insertions(+), 627 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 590f57662754..343f41eb4e4f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -61,12 +61,637 @@ * *****************************************************************************/ #include +#include +#include +#include #include "iwl-drv.h" #include "iwl-trans.h" #include "iwl-wifi.h" +#include "iwl-shared.h" #include "iwl-op-mode.h" +static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc) +{ + if (desc->v_addr) + dma_free_coherent(trans(nic)->dev, desc->len, + desc->v_addr, desc->p_addr); + desc->v_addr = NULL; + desc->len = 0; +} + +static void iwl_free_fw_img(struct iwl_nic *nic, struct fw_img *img) +{ + iwl_free_fw_desc(nic, &img->code); + iwl_free_fw_desc(nic, &img->data); +} + +static void iwl_dealloc_ucode(struct iwl_nic *nic) +{ + iwl_free_fw_img(nic, &nic->fw.ucode_rt); + iwl_free_fw_img(nic, &nic->fw.ucode_init); + iwl_free_fw_img(nic, &nic->fw.ucode_wowlan); +} + +static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc, + const void *data, size_t len) +{ + if (!len) { + desc->v_addr = NULL; + return -EINVAL; + } + + desc->v_addr = dma_alloc_coherent(trans(nic)->dev, len, + &desc->p_addr, GFP_KERNEL); + if (!desc->v_addr) + return -ENOMEM; + + desc->len = len; + memcpy(desc->v_addr, data, len); + return 0; +} + +static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); + +#define UCODE_EXPERIMENTAL_INDEX 100 +#define UCODE_EXPERIMENTAL_TAG "exp" + +static int iwl_request_firmware(struct iwl_nic *nic, bool first) +{ + const struct iwl_cfg *cfg = cfg(nic); + const char *name_pre = cfg->fw_name_pre; + char tag[8]; + + if (first) { +#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE + nic->fw_index = UCODE_EXPERIMENTAL_INDEX; + strcpy(tag, UCODE_EXPERIMENTAL_TAG); + } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { +#endif + nic->fw_index = cfg->ucode_api_max; + sprintf(tag, "%d", nic->fw_index); + } else { + nic->fw_index--; + sprintf(tag, "%d", nic->fw_index); + } + + if (nic->fw_index < cfg->ucode_api_min) { + IWL_ERR(nic, "no suitable firmware found!\n"); + return -ENOENT; + } + + sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + + IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n", + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? "EXPERIMENTAL " : "", + nic->firmware_name); + + return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, + trans(nic)->dev, + GFP_KERNEL, nic, iwl_ucode_callback); +} + +struct iwlagn_firmware_pieces { + const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data; + size_t inst_size, data_size, init_size, init_data_size, + wowlan_inst_size, wowlan_data_size; + + u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; + u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; +}; + +static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, + const struct firmware *ucode_raw, + struct iwlagn_firmware_pieces *pieces) +{ + struct iwl_ucode_header *ucode = (void *)ucode_raw->data; + u32 api_ver, hdr_size, build; + char buildstr[25]; + const u8 *src; + + nic->fw.ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IWL_UCODE_API(nic->fw.ucode_ver); + + switch (api_ver) { + default: + hdr_size = 28; + if (ucode_raw->size < hdr_size) { + IWL_ERR(nic, "File size too small!\n"); + return -EINVAL; + } + build = le32_to_cpu(ucode->u.v2.build); + pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); + pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); + pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); + pieces->init_data_size = + le32_to_cpu(ucode->u.v2.init_data_size); + src = ucode->u.v2.data; + break; + case 0: + case 1: + case 2: + hdr_size = 24; + if (ucode_raw->size < hdr_size) { + IWL_ERR(nic, "File size too small!\n"); + return -EINVAL; + } + build = 0; + pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); + pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); + pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); + pieces->init_data_size = + le32_to_cpu(ucode->u.v1.init_data_size); + src = ucode->u.v1.data; + break; + } + + if (build) + sprintf(buildstr, " build %u%s", build, + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? " (EXP)" : ""); + else + buildstr[0] = '\0'; + + snprintf(nic->fw.fw_version, + sizeof(nic->fw.fw_version), + "%u.%u.%u.%u%s", + IWL_UCODE_MAJOR(nic->fw.ucode_ver), + IWL_UCODE_MINOR(nic->fw.ucode_ver), + IWL_UCODE_API(nic->fw.ucode_ver), + IWL_UCODE_SERIAL(nic->fw.ucode_ver), + buildstr); + + /* 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) { + + IWL_ERR(nic, + "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; + + return 0; +} + +static int iwl_parse_tlv_firmware(struct iwl_nic *nic, + const struct firmware *ucode_raw, + struct iwlagn_firmware_pieces *pieces, + struct iwl_ucode_capabilities *capa) +{ + struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; + struct iwl_ucode_tlv *tlv; + size_t len = ucode_raw->size; + const u8 *data; + int wanted_alternative = iwlagn_mod_params.wanted_ucode_alternative; + int tmp; + u64 alternatives; + u32 tlv_len; + enum iwl_ucode_tlv_type tlv_type; + const u8 *tlv_data; + char buildstr[25]; + u32 build; + + if (len < sizeof(*ucode)) { + IWL_ERR(nic, "uCode has invalid length: %zd\n", len); + return -EINVAL; + } + + if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { + IWL_ERR(nic, "invalid uCode magic: 0X%x\n", + le32_to_cpu(ucode->magic)); + return -EINVAL; + } + + /* + * Check which alternatives are present, and "downgrade" + * when the chosen alternative is not present, warning + * the user when that happens. Some files may not have + * any alternatives, so don't warn in that case. + */ + alternatives = le64_to_cpu(ucode->alternatives); + tmp = wanted_alternative; + if (wanted_alternative > 63) + wanted_alternative = 63; + while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) + wanted_alternative--; + if (wanted_alternative && wanted_alternative != tmp) + IWL_WARN(nic, + "uCode alternative %d not available, choosing %d\n", + tmp, wanted_alternative); + + nic->fw.ucode_ver = le32_to_cpu(ucode->ver); + build = le32_to_cpu(ucode->build); + + if (build) + sprintf(buildstr, " build %u%s", build, + (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + ? " (EXP)" : ""); + else + buildstr[0] = '\0'; + + snprintf(nic->fw.fw_version, + sizeof(nic->fw.fw_version), + "%u.%u.%u.%u%s", + IWL_UCODE_MAJOR(nic->fw.ucode_ver), + IWL_UCODE_MINOR(nic->fw.ucode_ver), + IWL_UCODE_API(nic->fw.ucode_ver), + IWL_UCODE_SERIAL(nic->fw.ucode_ver), + buildstr); + + data = ucode->data; + + len -= sizeof(*ucode); + + while (len >= sizeof(*tlv)) { + u16 tlv_alt; + + len -= sizeof(*tlv); + tlv = (void *)data; + + tlv_len = le32_to_cpu(tlv->length); + tlv_type = le16_to_cpu(tlv->type); + tlv_alt = le16_to_cpu(tlv->alternative); + tlv_data = tlv->data; + + if (len < tlv_len) { + IWL_ERR(nic, "invalid TLV len: %zd/%u\n", + len, tlv_len); + return -EINVAL; + } + len -= ALIGN(tlv_len, 4); + data += sizeof(*tlv) + ALIGN(tlv_len, 4); + + /* + * Alternative 0 is always valid. + * + * Skip alternative TLVs that are not selected. + */ + if (tlv_alt != 0 && tlv_alt != wanted_alternative) + continue; + + switch (tlv_type) { + case IWL_UCODE_TLV_INST: + pieces->inst = tlv_data; + pieces->inst_size = tlv_len; + break; + case IWL_UCODE_TLV_DATA: + pieces->data = tlv_data; + pieces->data_size = tlv_len; + break; + case IWL_UCODE_TLV_INIT: + pieces->init = tlv_data; + pieces->init_size = tlv_len; + break; + case IWL_UCODE_TLV_INIT_DATA: + pieces->init_data = tlv_data; + pieces->init_data_size = tlv_len; + break; + case IWL_UCODE_TLV_BOOT: + IWL_ERR(nic, "Found unexpected BOOT ucode\n"); + break; + case IWL_UCODE_TLV_PROBE_MAX_LEN: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + capa->max_probe_length = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_PAN: + if (tlv_len) + goto invalid_tlv_len; + capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; + break; + case IWL_UCODE_TLV_FLAGS: + /* must be at least one u32 */ + if (tlv_len < sizeof(u32)) + goto invalid_tlv_len; + /* and a proper number of u32s */ + if (tlv_len % sizeof(u32)) + goto invalid_tlv_len; + /* + * This driver only reads the first u32 as + * right now no more features are defined, + * if that changes then either the driver + * will not work with the new firmware, or + * it'll not take advantage of new features. + */ + capa->flags = le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_INIT_EVTLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->init_evtlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->init_evtlog_size = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_INIT_ERRLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->init_errlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->inst_evtlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->inst_evtlog_size = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + pieces->inst_errlog_ptr = + le32_to_cpup((__le32 *)tlv_data); + break; + case IWL_UCODE_TLV_ENHANCE_SENS_TBL: + if (tlv_len) + goto invalid_tlv_len; + nic->fw.enhance_sensitivity_table = true; + break; + case IWL_UCODE_TLV_WOWLAN_INST: + pieces->wowlan_inst = tlv_data; + pieces->wowlan_inst_size = tlv_len; + break; + case IWL_UCODE_TLV_WOWLAN_DATA: + pieces->wowlan_data = tlv_data; + pieces->wowlan_data_size = tlv_len; + break; + case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + capa->standard_phy_calibration_size = + le32_to_cpup((__le32 *)tlv_data); + break; + default: + IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type); + break; + } + } + + if (len) { + IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len); + iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len); + return -EINVAL; + } + + return 0; + + invalid_tlv_len: + IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); + iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len); + + return -EINVAL; +} + +/** + * iwl_ucode_callback - callback when firmware was loaded + * + * If loaded successfully, copies the firmware into buffers + * for the card to fetch (via DMA). + */ +static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) +{ + struct iwl_nic *nic = context; + const struct iwl_cfg *cfg = cfg(nic); + struct iwl_fw *fw = &nic->fw; + struct iwl_ucode_header *ucode; + int err; + struct iwlagn_firmware_pieces pieces; + const unsigned int api_max = cfg->ucode_api_max; + unsigned int api_ok = cfg->ucode_api_ok; + const unsigned int api_min = cfg->ucode_api_min; + u32 api_ver; + + fw->ucode_capa.max_probe_length = 200; + fw->ucode_capa.standard_phy_calibration_size = + IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + + if (!api_ok) + api_ok = api_max; + + memset(&pieces, 0, sizeof(pieces)); + + if (!ucode_raw) { + if (nic->fw_index <= api_ok) + IWL_ERR(nic, + "request for firmware file '%s' failed.\n", + nic->firmware_name); + goto try_again; + } + + IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n", + nic->firmware_name, ucode_raw->size); + + /* Make sure that we got at least the API version number */ + if (ucode_raw->size < 4) { + IWL_ERR(nic, "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; + + if (ucode->ver) + err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); + else + err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, + &fw->ucode_capa); + + if (err) + goto try_again; + + api_ver = IWL_UCODE_API(nic->fw.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 + */ + /* no api version check required for experimental uCode */ + if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { + if (api_ver < api_min || api_ver > api_max) { + IWL_ERR(nic, + "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_ok) { + if (api_ok != api_max) + IWL_ERR(nic, "Firmware has old API version, " + "expected v%u through v%u, got v%u.\n", + api_ok, api_max, api_ver); + else + IWL_ERR(nic, "Firmware has old API version, " + "expected v%u, got v%u.\n", + api_max, api_ver); + IWL_ERR(nic, "New firmware can be obtained from " + "http://www.intellinuxwireless.org/.\n"); + } + } + + IWL_INFO(nic, "loaded firmware version %s", nic->fw.fw_version); + + /* + * 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. + */ + + IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n", + nic->fw.ucode_ver); + IWL_DEBUG_INFO(nic, "f/w package hdr runtime inst size = %Zd\n", + pieces.inst_size); + IWL_DEBUG_INFO(nic, "f/w package hdr runtime data size = %Zd\n", + pieces.data_size); + IWL_DEBUG_INFO(nic, "f/w package hdr init inst size = %Zd\n", + pieces.init_size); + IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n", + pieces.init_data_size); + + /* Verify that uCode images will fit in card's SRAM */ + if (pieces.inst_size > cfg->max_inst_size) { + IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", + pieces.inst_size); + goto try_again; + } + + if (pieces.data_size > cfg->max_data_size) { + IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", + pieces.data_size); + goto try_again; + } + + if (pieces.init_size > cfg->max_inst_size) { + IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", + pieces.init_size); + goto try_again; + } + + if (pieces.init_data_size > cfg->max_data_size) { + IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", + pieces.init_data_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 */ + if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code, + pieces.inst, pieces.inst_size)) + goto err_pci_alloc; + if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data, + pieces.data, pieces.data_size)) + goto err_pci_alloc; + + /* Initialization instructions and data */ + if (pieces.init_size && pieces.init_data_size) { + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_init.code, + pieces.init, pieces.init_size)) + goto err_pci_alloc; + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_init.data, + pieces.init_data, pieces.init_data_size)) + goto err_pci_alloc; + } + + /* WoWLAN instructions and data */ + if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_wowlan.code, + pieces.wowlan_inst, + pieces.wowlan_inst_size)) + goto err_pci_alloc; + if (iwl_alloc_fw_desc(nic, + &nic->fw.ucode_wowlan.data, + pieces.wowlan_data, + pieces.wowlan_data_size)) + goto err_pci_alloc; + } + + /* Now that we can no longer fail, copy information */ + + /* + * The (size - 16) / 12 formula is based on the information recorded + * for each event, which is of mode 1 (including timestamp) for all + * new microcodes that include this information. + */ + nic->init_evtlog_ptr = pieces.init_evtlog_ptr; + if (pieces.init_evtlog_size) + nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; + else + nic->init_evtlog_size = + cfg->base_params->max_event_log_size; + nic->init_errlog_ptr = pieces.init_errlog_ptr; + nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; + if (pieces.inst_evtlog_size) + nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; + else + nic->inst_evtlog_size = + cfg->base_params->max_event_log_size; + nic->inst_errlog_ptr = pieces.inst_errlog_ptr; + + /* + * figure out the offset of chain noise reset and gain commands + * base on the size of standard phy calibration commands table size + */ + if (fw->ucode_capa.standard_phy_calibration_size > + IWL_MAX_PHY_CALIBRATE_TBL_SIZE) + fw->ucode_capa.standard_phy_calibration_size = + IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; + + /* We have our copies now, allow OS release its copies */ + release_firmware(ucode_raw); + complete(&nic->request_firmware_complete); + + nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans); + + if (!nic->op_mode) + goto out_unbind; + + return; + + try_again: + /* try next, if any */ + release_firmware(ucode_raw); + if (iwl_request_firmware(nic, false)) + goto out_unbind; + return; + + err_pci_alloc: + IWL_ERR(nic, "failed to allocate pci memory\n"); + iwl_dealloc_ucode(nic); + release_firmware(ucode_raw); + out_unbind: + complete(&nic->request_firmware_complete); + device_release_driver(trans(nic)->dev); +} + int iwl_drv_start(struct iwl_shared *shrd, struct iwl_trans *trans, const struct iwl_cfg *cfg) { diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 12e79d04374f..64a9c5ce5f89 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -28,11 +28,8 @@ *****************************************************************************/ #include -#include #include #include -#include -#include #include "iwl-ucode.h" #include "iwl-wifi.h" @@ -83,46 +80,6 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { * ******************************************************************************/ -static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc) -{ - if (desc->v_addr) - dma_free_coherent(trans(nic)->dev, desc->len, - desc->v_addr, desc->p_addr); - desc->v_addr = NULL; - desc->len = 0; -} - -static void iwl_free_fw_img(struct iwl_nic *nic, struct fw_img *img) -{ - iwl_free_fw_desc(nic, &img->code); - iwl_free_fw_desc(nic, &img->data); -} - -void iwl_dealloc_ucode(struct iwl_nic *nic) -{ - iwl_free_fw_img(nic, &nic->fw.ucode_rt); - iwl_free_fw_img(nic, &nic->fw.ucode_init); - iwl_free_fw_img(nic, &nic->fw.ucode_wowlan); -} - -static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc, - const void *data, size_t len) -{ - if (!len) { - desc->v_addr = NULL; - return -EINVAL; - } - - desc->v_addr = dma_alloc_coherent(trans(nic)->dev, len, - &desc->p_addr, GFP_KERNEL); - if (!desc->v_addr) - return -ENOMEM; - - desc->len = len; - memcpy(desc->v_addr, data, len); - return 0; -} - static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic, enum iwl_ucode_type ucode_type) { @@ -685,582 +642,3 @@ int iwl_run_init_ucode(struct iwl_trans *trans) iwl_trans_stop_device(trans); return ret; } - -static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); - -#define UCODE_EXPERIMENTAL_TAG "exp" - -int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first) -{ - const struct iwl_cfg *cfg = cfg(nic); - const char *name_pre = cfg->fw_name_pre; - char tag[8]; - - if (first) { -#ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE - nic->fw_index = UCODE_EXPERIMENTAL_INDEX; - strcpy(tag, UCODE_EXPERIMENTAL_TAG); - } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { -#endif - nic->fw_index = cfg->ucode_api_max; - sprintf(tag, "%d", nic->fw_index); - } else { - nic->fw_index--; - sprintf(tag, "%d", nic->fw_index); - } - - if (nic->fw_index < cfg->ucode_api_min) { - IWL_ERR(nic, "no suitable firmware found!\n"); - return -ENOENT; - } - - sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - - IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n", - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) - ? "EXPERIMENTAL " : "", - nic->firmware_name); - - return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, - trans(nic)->dev, - GFP_KERNEL, nic, iwl_ucode_callback); -} - -struct iwlagn_firmware_pieces { - const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data; - size_t inst_size, data_size, init_size, init_data_size, - wowlan_inst_size, wowlan_data_size; - - u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; - u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; -}; - -static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, - const struct firmware *ucode_raw, - struct iwlagn_firmware_pieces *pieces) -{ - struct iwl_ucode_header *ucode = (void *)ucode_raw->data; - u32 api_ver, hdr_size, build; - char buildstr[25]; - const u8 *src; - - nic->fw.ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IWL_UCODE_API(nic->fw.ucode_ver); - - switch (api_ver) { - default: - hdr_size = 28; - if (ucode_raw->size < hdr_size) { - IWL_ERR(nic, "File size too small!\n"); - return -EINVAL; - } - build = le32_to_cpu(ucode->u.v2.build); - pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); - pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); - pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); - pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size); - src = ucode->u.v2.data; - break; - case 0: - case 1: - case 2: - hdr_size = 24; - if (ucode_raw->size < hdr_size) { - IWL_ERR(nic, "File size too small!\n"); - return -EINVAL; - } - build = 0; - pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); - pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); - pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); - pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size); - src = ucode->u.v1.data; - break; - } - - if (build) - sprintf(buildstr, " build %u%s", build, - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) - ? " (EXP)" : ""); - else - buildstr[0] = '\0'; - - snprintf(nic->fw.fw_version, - sizeof(nic->fw.fw_version), - "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(nic->fw.ucode_ver), - IWL_UCODE_MINOR(nic->fw.ucode_ver), - IWL_UCODE_API(nic->fw.ucode_ver), - IWL_UCODE_SERIAL(nic->fw.ucode_ver), - buildstr); - - /* 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) { - - IWL_ERR(nic, - "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; - - return 0; -} - -static int iwl_parse_tlv_firmware(struct iwl_nic *nic, - const struct firmware *ucode_raw, - struct iwlagn_firmware_pieces *pieces, - struct iwl_ucode_capabilities *capa) -{ - struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; - struct iwl_ucode_tlv *tlv; - size_t len = ucode_raw->size; - const u8 *data; - int wanted_alternative = iwlagn_mod_params.wanted_ucode_alternative; - int tmp; - u64 alternatives; - u32 tlv_len; - enum iwl_ucode_tlv_type tlv_type; - const u8 *tlv_data; - char buildstr[25]; - u32 build; - - if (len < sizeof(*ucode)) { - IWL_ERR(nic, "uCode has invalid length: %zd\n", len); - return -EINVAL; - } - - if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { - IWL_ERR(nic, "invalid uCode magic: 0X%x\n", - le32_to_cpu(ucode->magic)); - return -EINVAL; - } - - /* - * Check which alternatives are present, and "downgrade" - * when the chosen alternative is not present, warning - * the user when that happens. Some files may not have - * any alternatives, so don't warn in that case. - */ - alternatives = le64_to_cpu(ucode->alternatives); - tmp = wanted_alternative; - if (wanted_alternative > 63) - wanted_alternative = 63; - while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) - wanted_alternative--; - if (wanted_alternative && wanted_alternative != tmp) - IWL_WARN(nic, - "uCode alternative %d not available, choosing %d\n", - tmp, wanted_alternative); - - nic->fw.ucode_ver = le32_to_cpu(ucode->ver); - build = le32_to_cpu(ucode->build); - - if (build) - sprintf(buildstr, " build %u%s", build, - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) - ? " (EXP)" : ""); - else - buildstr[0] = '\0'; - - snprintf(nic->fw.fw_version, - sizeof(nic->fw.fw_version), - "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(nic->fw.ucode_ver), - IWL_UCODE_MINOR(nic->fw.ucode_ver), - IWL_UCODE_API(nic->fw.ucode_ver), - IWL_UCODE_SERIAL(nic->fw.ucode_ver), - buildstr); - - data = ucode->data; - - len -= sizeof(*ucode); - - while (len >= sizeof(*tlv)) { - u16 tlv_alt; - - len -= sizeof(*tlv); - tlv = (void *)data; - - tlv_len = le32_to_cpu(tlv->length); - tlv_type = le16_to_cpu(tlv->type); - tlv_alt = le16_to_cpu(tlv->alternative); - tlv_data = tlv->data; - - if (len < tlv_len) { - IWL_ERR(nic, "invalid TLV len: %zd/%u\n", - len, tlv_len); - return -EINVAL; - } - len -= ALIGN(tlv_len, 4); - data += sizeof(*tlv) + ALIGN(tlv_len, 4); - - /* - * Alternative 0 is always valid. - * - * Skip alternative TLVs that are not selected. - */ - if (tlv_alt != 0 && tlv_alt != wanted_alternative) - continue; - - switch (tlv_type) { - case IWL_UCODE_TLV_INST: - pieces->inst = tlv_data; - pieces->inst_size = tlv_len; - break; - case IWL_UCODE_TLV_DATA: - pieces->data = tlv_data; - pieces->data_size = tlv_len; - break; - case IWL_UCODE_TLV_INIT: - pieces->init = tlv_data; - pieces->init_size = tlv_len; - break; - case IWL_UCODE_TLV_INIT_DATA: - pieces->init_data = tlv_data; - pieces->init_data_size = tlv_len; - break; - case IWL_UCODE_TLV_BOOT: - IWL_ERR(nic, "Found unexpected BOOT ucode\n"); - break; - case IWL_UCODE_TLV_PROBE_MAX_LEN: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - capa->max_probe_length = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_PAN: - if (tlv_len) - goto invalid_tlv_len; - capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; - break; - case IWL_UCODE_TLV_FLAGS: - /* must be at least one u32 */ - if (tlv_len < sizeof(u32)) - goto invalid_tlv_len; - /* and a proper number of u32s */ - if (tlv_len % sizeof(u32)) - goto invalid_tlv_len; - /* - * This driver only reads the first u32 as - * right now no more features are defined, - * if that changes then either the driver - * will not work with the new firmware, or - * it'll not take advantage of new features. - */ - capa->flags = le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_INIT_EVTLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->init_evtlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->init_evtlog_size = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_INIT_ERRLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->init_errlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->inst_evtlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->inst_evtlog_size = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - pieces->inst_errlog_ptr = - le32_to_cpup((__le32 *)tlv_data); - break; - case IWL_UCODE_TLV_ENHANCE_SENS_TBL: - if (tlv_len) - goto invalid_tlv_len; - nic->fw.enhance_sensitivity_table = true; - break; - case IWL_UCODE_TLV_WOWLAN_INST: - pieces->wowlan_inst = tlv_data; - pieces->wowlan_inst_size = tlv_len; - break; - case IWL_UCODE_TLV_WOWLAN_DATA: - pieces->wowlan_data = tlv_data; - pieces->wowlan_data_size = tlv_len; - break; - case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: - if (tlv_len != sizeof(u32)) - goto invalid_tlv_len; - capa->standard_phy_calibration_size = - le32_to_cpup((__le32 *)tlv_data); - break; - default: - IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type); - break; - } - } - - if (len) { - IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len); - iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len); - return -EINVAL; - } - - return 0; - - invalid_tlv_len: - IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); - iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len); - - return -EINVAL; -} - -/** - * iwl_ucode_callback - callback when firmware was loaded - * - * If loaded successfully, copies the firmware into buffers - * for the card to fetch (via DMA). - */ -static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) -{ - struct iwl_nic *nic = context; - const struct iwl_cfg *cfg = cfg(nic); - struct iwl_fw *fw = &nic->fw; - struct iwl_ucode_header *ucode; - int err; - struct iwlagn_firmware_pieces pieces; - const unsigned int api_max = cfg->ucode_api_max; - unsigned int api_ok = cfg->ucode_api_ok; - const unsigned int api_min = cfg->ucode_api_min; - u32 api_ver; - - fw->ucode_capa.max_probe_length = 200; - fw->ucode_capa.standard_phy_calibration_size = - IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; - - if (!api_ok) - api_ok = api_max; - - memset(&pieces, 0, sizeof(pieces)); - - if (!ucode_raw) { - if (nic->fw_index <= api_ok) - IWL_ERR(nic, - "request for firmware file '%s' failed.\n", - nic->firmware_name); - goto try_again; - } - - IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n", - nic->firmware_name, ucode_raw->size); - - /* Make sure that we got at least the API version number */ - if (ucode_raw->size < 4) { - IWL_ERR(nic, "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; - - if (ucode->ver) - err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); - else - err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, - &fw->ucode_capa); - - if (err) - goto try_again; - - api_ver = IWL_UCODE_API(nic->fw.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 - */ - /* no api version check required for experimental uCode */ - if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { - if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(nic, - "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_ok) { - if (api_ok != api_max) - IWL_ERR(nic, "Firmware has old API version, " - "expected v%u through v%u, got v%u.\n", - api_ok, api_max, api_ver); - else - IWL_ERR(nic, "Firmware has old API version, " - "expected v%u, got v%u.\n", - api_max, api_ver); - IWL_ERR(nic, "New firmware can be obtained from " - "http://www.intellinuxwireless.org/.\n"); - } - } - - IWL_INFO(nic, "loaded firmware version %s", nic->fw.fw_version); - - /* - * 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. - */ - - IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n", - nic->fw.ucode_ver); - IWL_DEBUG_INFO(nic, "f/w package hdr runtime inst size = %Zd\n", - pieces.inst_size); - IWL_DEBUG_INFO(nic, "f/w package hdr runtime data size = %Zd\n", - pieces.data_size); - IWL_DEBUG_INFO(nic, "f/w package hdr init inst size = %Zd\n", - pieces.init_size); - IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n", - pieces.init_data_size); - - /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > cfg->max_inst_size) { - IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", - pieces.inst_size); - goto try_again; - } - - if (pieces.data_size > cfg->max_data_size) { - IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", - pieces.data_size); - goto try_again; - } - - if (pieces.init_size > cfg->max_inst_size) { - IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", - pieces.init_size); - goto try_again; - } - - if (pieces.init_data_size > cfg->max_data_size) { - IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", - pieces.init_data_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 */ - if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code, - pieces.inst, pieces.inst_size)) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data, - pieces.data, pieces.data_size)) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_init.code, - pieces.init, pieces.init_size)) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_init.data, - pieces.init_data, pieces.init_data_size)) - goto err_pci_alloc; - } - - /* WoWLAN instructions and data */ - if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_wowlan.code, - pieces.wowlan_inst, - pieces.wowlan_inst_size)) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_wowlan.data, - pieces.wowlan_data, - pieces.wowlan_data_size)) - goto err_pci_alloc; - } - - /* Now that we can no longer fail, copy information */ - - /* - * The (size - 16) / 12 formula is based on the information recorded - * for each event, which is of mode 1 (including timestamp) for all - * new microcodes that include this information. - */ - nic->init_evtlog_ptr = pieces.init_evtlog_ptr; - if (pieces.init_evtlog_size) - nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; - else - nic->init_evtlog_size = - cfg->base_params->max_event_log_size; - nic->init_errlog_ptr = pieces.init_errlog_ptr; - nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; - if (pieces.inst_evtlog_size) - nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; - else - nic->inst_evtlog_size = - cfg->base_params->max_event_log_size; - nic->inst_errlog_ptr = pieces.inst_errlog_ptr; - - /* - * figure out the offset of chain noise reset and gain commands - * base on the size of standard phy calibration commands table size - */ - if (fw->ucode_capa.standard_phy_calibration_size > - IWL_MAX_PHY_CALIBRATE_TBL_SIZE) - fw->ucode_capa.standard_phy_calibration_size = - IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; - - /* We have our copies now, allow OS release its copies */ - release_firmware(ucode_raw); - complete(&nic->request_firmware_complete); - - nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans); - - if (!nic->op_mode) - goto out_unbind; - - return; - - try_again: - /* try next, if any */ - release_firmware(ucode_raw); - if (iwl_request_firmware(nic, false)) - goto out_unbind; - return; - - err_pci_alloc: - IWL_ERR(nic, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(nic); - release_firmware(ucode_raw); - out_unbind: - complete(&nic->request_firmware_complete); - device_release_driver(trans(nic)->dev); -} - diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index d5cba07a24c8..d157931e1e95 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -66,8 +66,6 @@ #include "iwl-shared.h" #include "iwl-ucode.h" -#define UCODE_EXPERIMENTAL_INDEX 100 - /** * struct iwl_nic - nic common data * @fw: the iwl_fw structure @@ -99,9 +97,6 @@ struct iwl_nic { }; -int __must_check iwl_request_firmware(struct iwl_nic *nic, bool first); -void iwl_dealloc_ucode(struct iwl_nic *nic); - int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); void iwl_send_prio_tbl(struct iwl_trans *trans); int iwl_init_alive_start(struct iwl_trans *trans); -- GitLab From 2e7eb117586198386e5a06d0bc4279a9d7cbaeb6 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 5 Mar 2012 11:24:51 -0800 Subject: [PATCH 1434/1846] iwlwifi: move firmware completion wait This doesn't belong into the op_mode, it has to be in the drv stop flow instead. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 -- drivers/net/wireless/iwlwifi/iwl-drv.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index c3b594647def..8bb3f173bfa0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1371,8 +1371,6 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) { struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); - wait_for_completion(&nic(priv)->request_firmware_complete); - IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); iwl_dbgfs_unregister(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 343f41eb4e4f..1a588f36b591 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -720,6 +720,8 @@ int iwl_drv_start(struct iwl_shared *shrd, void iwl_drv_stop(struct iwl_shared *shrd) { + wait_for_completion(&shrd->nic->request_firmware_complete); + /* op_mode can be NULL if its start failed */ if (shrd->nic->op_mode) iwl_op_mode_stop(shrd->nic->op_mode); -- GitLab From 8097e1494459a4f9cdbaba7440334d9bd11a39f0 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Mon, 5 Mar 2012 15:31:47 -0800 Subject: [PATCH 1435/1846] cfg80211: expose cfg80211_calculate_bitrate() Signed-off-by: Thomas Pedersen Reviewed-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/cfg80211.h | 8 ++++++++ net/wireless/util.c | 1 + 2 files changed, 9 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 4682c35a92c4..57c9fddc2acf 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -3337,6 +3337,14 @@ int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, struct ieee80211_channel *chan, enum nl80211_channel_type channel_type); +/* + * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units) + * @rate: given rate_info to calculate bitrate from + * + * return 0 if MCS index >= 32 + */ +u16 cfg80211_calculate_bitrate(struct rate_info *rate); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/net/wireless/util.c b/net/wireless/util.c index 9aa9db6c8141..1b7a08df933c 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -904,6 +904,7 @@ u16 cfg80211_calculate_bitrate(struct rate_info *rate) /* do NOT round down here */ return (bitrate + 50000) / 100000; } +EXPORT_SYMBOL(cfg80211_calculate_bitrate); int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, u32 beacon_int) -- GitLab From 6b62bf326393deede630731a933713de9d574128 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Mon, 5 Mar 2012 15:31:48 -0800 Subject: [PATCH 1436/1846] mac80211: fix mesh airtime link metric estimating Airtime link metric estimation was broken in HT mesh, use cfg80211_calculate_bitrate to get the right rate value. Also factor out tx rate copying from sta_set_sinfo(). Signed-off-by: Thomas Pedersen Reviewed-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/cfg.c | 23 +++++++++++++++-------- net/mac80211/mesh_hwmp.c | 6 ++++-- net/mac80211/sta_info.h | 3 +++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index ab31cc56a2fb..677d65929780 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -336,6 +336,20 @@ static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, in rate->mcs = idx; } +void sta_set_rate_info_tx(struct sta_info *sta, + const struct ieee80211_tx_rate *rate, + struct rate_info *rinfo) +{ + rinfo->flags = 0; + if (rate->flags & IEEE80211_TX_RC_MCS) + rinfo->flags |= RATE_INFO_FLAGS_MCS; + if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; + if (rate->flags & IEEE80211_TX_RC_SHORT_GI) + rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; + rate_idx_to_bitrate(rinfo, sta, rate->idx); +} + static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) { struct ieee80211_sub_if_data *sdata = sta->sdata; @@ -378,14 +392,7 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); } - sinfo->txrate.flags = 0; - if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS) - sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; - if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH) - sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; - if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) - sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; - rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx); + sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); sinfo->rxrate.flags = 0; if (sta->last_rx_rate_flag & RX_FLAG_HT) diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 4a993f2d1ae1..1c6f3d02aebf 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -324,6 +324,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local, struct sta_info *sta) { struct ieee80211_supported_band *sband; + struct rate_info rinfo; /* This should be adjusted for each device */ int device_constant = 1 << ARITH_SHIFT; int test_frame_len = TEST_FRAME_LEN << ARITH_SHIFT; @@ -337,7 +338,9 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local, if (sta->fail_avg >= 100) return MAX_METRIC; - if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS) + sta_set_rate_info_tx(sta, &sta->last_tx_rate, &rinfo); + rate = cfg80211_calculate_bitrate(&rinfo); + if (WARN_ON(!rate)) return MAX_METRIC; err = (sta->fail_avg << ARITH_SHIFT) / 100; @@ -345,7 +348,6 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local, /* bitrate is in units of 100 Kbps, while we need rate in units of * 1Mbps. This will be corrected on tx_time computation. */ - rate = sband->bitrates[sta->last_tx_rate.idx].bitrate; tx_time = (device_constant + 10 * test_frame_len / rate); estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ; diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 3336d54e5558..ab0576827baf 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -529,6 +529,9 @@ void sta_info_init(struct ieee80211_local *local); void sta_info_stop(struct ieee80211_local *local); int sta_info_flush(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata); +void sta_set_rate_info_tx(struct sta_info *sta, + const struct ieee80211_tx_rate *rate, + struct rate_info *rinfo); void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, unsigned long exp_time); -- GitLab From 2f40b9404903dba89d70d706ee71263f9babd109 Mon Sep 17 00:00:00 2001 From: Javier Cardona Date: Mon, 5 Mar 2012 17:20:37 -0800 Subject: [PATCH 1437/1846] mac80211_hwsim: Add tsf to beacons, probe responses and radiotap header. Generate a tsf from internal kernel clock. Prepare the path for having different tsf offsets on each phy. This will be useful for testing mesh synchronization algorithms. Signed-off-by: Javier Cardona Reviewed-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/mac80211_hwsim.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index ba16f05df0fc..14a3cac19a30 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "mac80211_hwsim.h" @@ -321,11 +322,15 @@ struct mac80211_hwsim_data { struct dentry *debugfs_group; int power_level; + + /* difference between this hw's clock and the real clock, in usecs */ + u64 tsf_offset; }; struct hwsim_radiotap_hdr { struct ieee80211_radiotap_header hdr; + __le64 rt_tsft; u8 rt_flags; u8 rt_rate; __le16 rt_channel; @@ -367,6 +372,12 @@ static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb, return NETDEV_TX_OK; } +static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data) +{ + struct timeval tv = ktime_to_timeval(ktime_get_real()); + u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec; + return cpu_to_le64(now + data->tsf_offset); +} static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, struct sk_buff *tx_skb) @@ -391,7 +402,9 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_TSFT) | (1 << IEEE80211_RADIOTAP_CHANNEL)); + hdr->rt_tsft = __mac80211_hwsim_get_tsf(data); hdr->rt_flags = 0; hdr->rt_rate = txrate->bitrate / 5; hdr->rt_channel = cpu_to_le16(data->channel->center_freq); @@ -610,7 +623,8 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, } memset(&rx_status, 0, sizeof(rx_status)); - /* TODO: set mactime */ + rx_status.mactime = le64_to_cpu(__mac80211_hwsim_get_tsf(data)); + rx_status.flag |= RX_FLAG_MACTIME_MPDU; rx_status.freq = data->channel->center_freq; rx_status.band = data->channel->band; rx_status.rate_idx = info->control.rates[0].idx; @@ -667,6 +681,12 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) bool ack; struct ieee80211_tx_info *txi; u32 _pid; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + struct mac80211_hwsim_data *data = hw->priv; + + if (ieee80211_is_beacon(mgmt->frame_control) || + ieee80211_is_probe_resp(mgmt->frame_control)) + mgmt->u.beacon.timestamp = __mac80211_hwsim_get_tsf(data); mac80211_hwsim_monitor_rx(hw, skb); @@ -763,9 +783,11 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, struct ieee80211_vif *vif) { struct ieee80211_hw *hw = arg; + struct mac80211_hwsim_data *data = hw->priv; struct sk_buff *skb; struct ieee80211_tx_info *info; u32 _pid; + struct ieee80211_mgmt *mgmt; hwsim_check_magic(vif); @@ -779,6 +801,9 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, return; info = IEEE80211_SKB_CB(skb); + mgmt = (struct ieee80211_mgmt *) skb->data; + mgmt->u.beacon.timestamp = __mac80211_hwsim_get_tsf(data); + mac80211_hwsim_monitor_rx(hw, skb); /* wmediumd mode check */ -- GitLab From 12ce8ba3eb09bb83509a459835917a3100ad8db1 Mon Sep 17 00:00:00 2001 From: Javier Cardona Date: Mon, 5 Mar 2012 17:20:38 -0800 Subject: [PATCH 1438/1846] mac80211: Modify tsf via debugfs in mesh interfaces Signed-off-by: Javier Cardona Reviewed-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/mac80211_hwsim.c | 18 ++++++++++++++++++ net/mac80211/debugfs_netdev.c | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 14a3cac19a30..b4f6cb3298a4 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -379,6 +379,22 @@ static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data) return cpu_to_le64(now + data->tsf_offset); } +static u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct mac80211_hwsim_data *data = hw->priv; + return le64_to_cpu(__mac80211_hwsim_get_tsf(data)); +} + +static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u64 tsf) +{ + struct mac80211_hwsim_data *data = hw->priv; + struct timeval tv = ktime_to_timeval(ktime_get_real()); + u64 now = tv.tv_sec * USEC_PER_SEC + tv.tv_usec; + data->tsf_offset = tsf - now; +} + static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, struct sk_buff *tx_skb) { @@ -1224,6 +1240,8 @@ static struct ieee80211_ops mac80211_hwsim_ops = .sw_scan_start = mac80211_hwsim_sw_scan, .sw_scan_complete = mac80211_hwsim_sw_scan_complete, .flush = mac80211_hwsim_flush, + .get_tsf = mac80211_hwsim_get_tsf, + .set_tsf = mac80211_hwsim_set_tsf, }; diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 9f484d8905fd..f6de8a65f402 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -538,11 +538,15 @@ static void add_monitor_files(struct ieee80211_sub_if_data *sdata) #ifdef CONFIG_MAC80211_MESH +static void add_mesh_files(struct ieee80211_sub_if_data *sdata) +{ + DEBUGFS_ADD_MODE(tsf, 0600); +} + static void add_mesh_stats(struct ieee80211_sub_if_data *sdata) { struct dentry *dir = debugfs_create_dir("mesh_stats", sdata->debugfs.dir); - #define MESHSTATS_ADD(name)\ debugfs_create_file(#name, 0400, dir, sdata, &name##_ops); @@ -595,6 +599,7 @@ static void add_files(struct ieee80211_sub_if_data *sdata) switch (sdata->vif.type) { case NL80211_IFTYPE_MESH_POINT: #ifdef CONFIG_MAC80211_MESH + add_mesh_files(sdata); add_mesh_stats(sdata); add_mesh_config(sdata); #endif -- GitLab From 62e2c102cc1d2600381410c089ca9a37359577d2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 6 Mar 2012 11:06:37 +0100 Subject: [PATCH 1439/1846] ath5k: do not stop queues for full calibration Some calibration types interfere with tx activity, but the queue stop does not prevent that. In fact, some calibration types need tx activity to properly function, so stopping the queues for them is counterproductive. In some tests this patch has been shown to improve stability, especially in AP or ad-hoc mode. Signed-off-by: Felix Fietkau Acked-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/base.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index b51d58c414d2..0e643b016b32 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -2332,15 +2332,6 @@ ath5k_calibrate_work(struct work_struct *work) "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; @@ -2355,10 +2346,9 @@ ath5k_calibrate_work(struct work_struct *work) ah->curchan->center_freq)); /* Clear calibration flags */ - if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) { - ieee80211_wake_queues(ah->hw); + if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL; - } else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT) + else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT) ah->ah_cal_mask &= ~AR5K_CALIBRATION_SHORT; } -- GitLab From 5c17ddc4a047c59638c7eb8537aa887a1ddb9b0b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 6 Mar 2012 11:06:38 +0100 Subject: [PATCH 1440/1846] ath5k: do not re-run AGC calibration periodically All other Atheros drivers run the AGC gain calibration and DC offset calibration only after reset. Running them periodically has caused stability issues on some (primarily AR2315/2413/5413/5414 based) devices, leading to messages such as: ath5k phy0: gain calibration timeout (2462MHz) ath5k phy0: calibration of channel 11 failed Related bug reports: https://dev.openwrt.org/ticket/10574 https://bugzilla.redhat.com/show_bug.cgi?id=795141 Signed-off-by: Felix Fietkau Acked-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/phy.c | 34 ++++++++-------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index e1f8613426a9..3a2845489a1b 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c @@ -1871,31 +1871,15 @@ ath5k_hw_phy_calibrate(struct ath5k_hw *ah, 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); - } - - /* Update noise floor - * XXX: Only do this after AGC calibration */ + /* On full calibration request a PAPD probe for + * gainf calibration if needed */ + if ((ah->ah_cal_mask & AR5K_CALIBRATION_FULL) && + (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 */ if (!(ah->ah_cal_mask & AR5K_CALIBRATION_NF)) ath5k_hw_update_noise_floor(ah); -- GitLab From 4ac887cfdad909f16ee1886fe4fa19b452fc7fd3 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 6 Mar 2012 15:50:47 +0100 Subject: [PATCH 1441/1846] bcma: return error in bcma_sprom_get() when fallback fails When not SPROM is available a fallback mechanism is used. However, when that fails the code currently continues. This patch assures that the bcma_sprom_get() function aborts when that happens. Cc: Rafal Milecki Cc: Hauke Mehrtens Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/bcma/sprom.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index 916ae255ff64..fba8066857d2 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -49,10 +49,23 @@ int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus, struct ssb_sprom *out) { - if (!get_fallback_sprom) - return -ENOENT; + int err; - return get_fallback_sprom(bus, out); + if (!get_fallback_sprom) { + err = -ENOENT; + goto fail; + } + + err = get_fallback_sprom(bus, out); + if (err) + goto fail; + + pr_debug("Using SPROM revision %d provided by" + " platform.\n", bus->sprom.revision); + return 0; +fail: + pr_warn("Using fallback SPROM failed (err %d)\n", err); + return err; } /************************************************** @@ -317,13 +330,7 @@ int bcma_sprom_get(struct bcma_bus *bus) * available for this device in some other storage. */ err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); - if (err) { - pr_warn("Using fallback SPROM failed (err %d)\n", err); - } else { - pr_debug("Using SPROM revision %d provided by" - " platform.\n", bus->sprom.revision); - return 0; - } + return err; } sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), -- GitLab From 10d8493cd9efd38b1947b7a74276dbdc8311aa1a Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 6 Mar 2012 15:50:48 +0100 Subject: [PATCH 1442/1846] bcma: add support for on-chip OTP memory used for SPROM storage Wireless Broadcom chips can have either their SPROM data stored on either external SPROM or on-chip OTP memory. Both are accessed through the same register space. This patch adds support for the on-chip OTP memory. Tested with: BCM43224 OTP and SPROM BCM4331 SPROM BCM4313 OTP This patch is in response to linux-wireless thread [1]. [1] http://article.gmane.org/gmane.linux.kernel.wireless.general/85426 Tested-by: Saul St. John Tested-by: Rafal Milecki Tested-by: Hauke Mehrtens Cc: Larry Finger Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/bcma/sprom.c | 126 ++++++++++++++++---- include/linux/bcma/bcma_driver_chipcommon.h | 10 +- 2 files changed, 115 insertions(+), 21 deletions(-) diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c index fba8066857d2..cdcf75c0954f 100644 --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c @@ -300,37 +300,128 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) SSB_SROM8_FEM_ANTSWLUT_SHIFT); } -static bool bcma_is_sprom_available(struct bcma_bus *bus) +/* + * Indicates the presence of external SPROM. + */ +static bool bcma_sprom_ext_available(struct bcma_bus *bus) { - u32 sromctrl; + u32 chip_status; + u32 srom_control; + u32 present_mask; - if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM)) - return false; + if (bus->drv_cc.core->id.rev >= 31) { + if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM)) + return false; - if (bus->drv_cc.core->id.rev >= 32) { - sromctrl = bcma_read32(bus->drv_cc.core, BCMA_CC_SROM_CONTROL); - return sromctrl & BCMA_CC_SROM_CONTROL_PRESENT; + srom_control = bcma_read32(bus->drv_cc.core, + BCMA_CC_SROM_CONTROL); + return srom_control & BCMA_CC_SROM_CONTROL_PRESENT; } - return true; + + /* older chipcommon revisions use chip status register */ + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT); + switch (bus->chipinfo.id) { + case 0x4313: + present_mask = BCMA_CC_CHIPST_4313_SPROM_PRESENT; + break; + + case 0x4331: + present_mask = BCMA_CC_CHIPST_4331_SPROM_PRESENT; + break; + + default: + return true; + } + + return chip_status & present_mask; +} + +/* + * Indicates that on-chip OTP memory is present and enabled. + */ +static bool bcma_sprom_onchip_available(struct bcma_bus *bus) +{ + u32 chip_status; + u32 otpsize = 0; + bool present; + + chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT); + switch (bus->chipinfo.id) { + case 0x4313: + present = chip_status & BCMA_CC_CHIPST_4313_OTP_PRESENT; + break; + + case 0x4331: + present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT; + break; + + case 43224: + case 43225: + /* for these chips OTP is always available */ + present = true; + break; + + default: + present = false; + break; + } + + if (present) { + otpsize = bus->drv_cc.capabilities & BCMA_CC_CAP_OTPS; + otpsize >>= BCMA_CC_CAP_OTPS_SHIFT; + } + + return otpsize != 0; +} + +/* + * Verify OTP is filled and determine the byte + * offset where SPROM data is located. + * + * On error, returns 0; byte offset otherwise. + */ +static int bcma_sprom_onchip_offset(struct bcma_bus *bus) +{ + struct bcma_device *cc = bus->drv_cc.core; + u32 offset; + + /* verify OTP status */ + if ((bcma_read32(cc, BCMA_CC_OTPS) & BCMA_CC_OTPS_GU_PROG_HW) == 0) + return 0; + + /* obtain bit offset from otplayout register */ + offset = (bcma_read32(cc, BCMA_CC_OTPL) & BCMA_CC_OTPL_GURGN_OFFSET); + return BCMA_CC_SPROM + (offset >> 3); } int bcma_sprom_get(struct bcma_bus *bus) { - u16 offset; + u16 offset = BCMA_CC_SPROM; u16 *sprom; int err = 0; if (!bus->drv_cc.core) return -EOPNOTSUPP; - if (!bcma_is_sprom_available(bus)) { + if (!bcma_sprom_ext_available(bus)) { /* - * Maybe there is no SPROM on the device? - * Now we ask the arch code if there is some sprom - * available for this device in some other storage. + * External SPROM takes precedence so check + * on-chip OTP only when no external SPROM + * is present. */ - err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); - return err; + if (bcma_sprom_onchip_available(bus)) { + /* determine offset */ + offset = bcma_sprom_onchip_offset(bus); + } + if (!offset) { + /* + * Maybe there is no SPROM on the device? + * Now we ask the arch code if there is some sprom + * available for this device in some other storage. + */ + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); + return err; + } } sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16), @@ -341,11 +432,6 @@ int bcma_sprom_get(struct bcma_bus *bus) if (bus->chipinfo.id == 0x4331) bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false); - /* Most cards have SPROM moved by additional offset 0x30 (48 dwords). - * According to brcm80211 this applies to cards with PCIe rev >= 6 - * TODO: understand this condition and use it */ - offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM : - BCMA_CC_SPROM_PCIE6; pr_debug("SPROM offset 0x%x\n", offset); bcma_sprom_read(bus, offset, sprom); diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h index e72938b10714..8bbfe31fbac8 100644 --- a/include/linux/bcma/bcma_driver_chipcommon.h +++ b/include/linux/bcma/bcma_driver_chipcommon.h @@ -56,6 +56,9 @@ #define BCMA_CC_OTPS_HW_PROTECT 0x00000001 #define BCMA_CC_OTPS_SW_PROTECT 0x00000002 #define BCMA_CC_OTPS_CID_PROTECT 0x00000004 +#define BCMA_CC_OTPS_GU_PROG_IND 0x00000F00 /* General Use programmed indication */ +#define BCMA_CC_OTPS_GU_PROG_IND_SHIFT 8 +#define BCMA_CC_OTPS_GU_PROG_HW 0x00000100 /* HW region programmed */ #define BCMA_CC_OTPC 0x0014 /* OTP control */ #define BCMA_CC_OTPC_RECWAIT 0xFF000000 #define BCMA_CC_OTPC_PROGWAIT 0x00FFFF00 @@ -72,6 +75,8 @@ #define BCMA_CC_OTPP_READ 0x40000000 #define BCMA_CC_OTPP_START 0x80000000 #define BCMA_CC_OTPP_BUSY 0x80000000 +#define BCMA_CC_OTPL 0x001C /* OTP layout */ +#define BCMA_CC_OTPL_GURGN_OFFSET 0x00000FFF /* offset of general use region */ #define BCMA_CC_IRQSTAT 0x0020 #define BCMA_CC_IRQMASK 0x0024 #define BCMA_CC_IRQ_GPIO 0x00000001 /* gpio intr */ @@ -79,6 +84,10 @@ #define BCMA_CC_IRQ_WDRESET 0x80000000 /* watchdog reset occurred */ #define BCMA_CC_CHIPCTL 0x0028 /* Rev >= 11 only */ #define BCMA_CC_CHIPSTAT 0x002C /* Rev >= 11 only */ +#define BCMA_CC_CHIPST_4313_SPROM_PRESENT 1 +#define BCMA_CC_CHIPST_4313_OTP_PRESENT 2 +#define BCMA_CC_CHIPST_4331_SPROM_PRESENT 2 +#define BCMA_CC_CHIPST_4331_OTP_PRESENT 4 #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */ #define BCMA_CC_JCMD_START 0x80000000 #define BCMA_CC_JCMD_BUSY 0x80000000 @@ -256,7 +265,6 @@ #define BCMA_CC_PLLCTL_ADDR 0x0660 #define BCMA_CC_PLLCTL_DATA 0x0664 #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */ -#define BCMA_CC_SPROM_PCIE6 0x0830 /* SPROM beginning on PCIe rev >= 6 */ /* Divider allocation in 4716/47162/5356 */ #define BCMA_CC_PMU5_MAINPLL_CPU 1 -- GitLab From c3b1e1e8a76fdaa507daaa95ba7bd1d8d0c74b6b Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:33 +0100 Subject: [PATCH 1443/1846] NFC: Export NFCID1 from pn533 Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/pn533.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 1a1500bc8452..8be0ae626d73 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -736,6 +736,8 @@ static int pn533_target_found_type_a(struct nfc_target *nfc_tgt, u8 *tgt_data, nfc_tgt->sens_res = be16_to_cpu(tgt_type_a->sens_res); nfc_tgt->sel_res = tgt_type_a->sel_res; + nfc_tgt->nfcid1_len = tgt_type_a->nfcid_len; + memcpy(nfc_tgt->nfcid1, tgt_type_a->nfcid_data, nfc_tgt->nfcid1_len); return 0; } -- GitLab From c970a1ac4e75a5d31c7b6e8e9f0bb192b0a511e7 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:34 +0100 Subject: [PATCH 1444/1846] NFC: Add device powered netlink attribute For user space to know if a device is up or down. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- include/linux/nfc.h | 1 + net/nfc/netlink.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/nfc.h b/include/linux/nfc.h index b4999abcb2a2..39c1fcf089c0 100644 --- a/include/linux/nfc.h +++ b/include/linux/nfc.h @@ -107,6 +107,7 @@ enum nfc_attrs { NFC_ATTR_TARGET_SENSF_RES, NFC_ATTR_COMM_MODE, NFC_ATTR_RF_MODE, + NFC_ATTR_DEVICE_POWERED, /* private: internal use only */ __NFC_ATTR_AFTER_LAST }; diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 07f0348aabf5..a1388e4efd6f 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -48,6 +48,7 @@ static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = { [NFC_ATTR_PROTOCOLS] = { .type = NLA_U32 }, [NFC_ATTR_COMM_MODE] = { .type = NLA_U8 }, [NFC_ATTR_RF_MODE] = { .type = NLA_U8 }, + [NFC_ATTR_DEVICE_POWERED] = { .type = NLA_U8 }, }; static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target, @@ -200,6 +201,7 @@ int nfc_genl_device_added(struct nfc_dev *dev) NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)); NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols); + NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up); genlmsg_end(msg, hdr); @@ -261,6 +263,7 @@ static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)); NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols); + NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up); return genlmsg_end(msg, hdr); -- GitLab From 4722d2b70b80098e1e429e093a7e04aad360260a Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:35 +0100 Subject: [PATCH 1445/1846] NFC: Factorize the I frame queueing routine This one will be called from the I frame command sending. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/llcp.c | 45 ++++++++++++++++++++++++++++----------------- net/nfc/llcp/llcp.h | 1 + 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 1d32680807d6..8510a2fb3da8 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -616,6 +616,33 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, } +void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) +{ + struct nfc_llcp_local *local = sock->local; + + pr_debug("Remote ready %d tx queue len %d remote rw %d", + sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), + local->remote_rw); + + /* Try to queue some I frames for transmission */ + while (sock->remote_ready && + skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) { + struct sk_buff *pdu, *pending_pdu; + + pdu = skb_dequeue(&sock->tx_queue); + if (pdu == NULL) + break; + + /* Update N(S)/N(R) */ + nfc_llcp_set_nrns(sock, pdu); + + pending_pdu = skb_clone(pdu, GFP_KERNEL); + + skb_queue_tail(&local->tx_queue, pdu); + skb_queue_tail(&sock->tx_pending_queue, pending_pdu); + } +} + static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, struct sk_buff *skb) { @@ -673,23 +700,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, } } - /* Queue some I frames for transmission */ - while (llcp_sock->remote_ready && - skb_queue_len(&llcp_sock->tx_pending_queue) <= local->remote_rw) { - struct sk_buff *pdu, *pending_pdu; - - pdu = skb_dequeue(&llcp_sock->tx_queue); - if (pdu == NULL) - break; - - /* Update N(S)/N(R) */ - nfc_llcp_set_nrns(llcp_sock, pdu); - - pending_pdu = skb_clone(pdu, GFP_KERNEL); - - skb_queue_tail(&local->tx_queue, pdu); - skb_queue_tail(&llcp_sock->tx_pending_queue, pending_pdu); - } + nfc_llcp_queue_i_frames(llcp_sock); release_sock(sk); nfc_llcp_sock_put(llcp_sock); diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 0ad2e3361584..0a72ee627641 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h @@ -165,6 +165,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, struct nfc_llcp_sock *sock); u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); +void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); /* Sock API */ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp); -- GitLab From 53aef92054e7fbffe66d3e2f95d122f39a33c211 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:36 +0100 Subject: [PATCH 1446/1846] NFC: Handle Receiver Not Ready LLCP frame Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/llcp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 8510a2fb3da8..bbfaa2750ea8 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -671,15 +671,15 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, nfc_llcp_sock_put(llcp_sock); } - if (ns == llcp_sock->recv_n) - llcp_sock->recv_n = (llcp_sock->recv_n + 1) % 16; - else - pr_err("Received out of sequence I PDU\n"); - /* Pass the payload upstream */ if (ptype == LLCP_PDU_I) { pr_debug("I frame, queueing on %p\n", &llcp_sock->sk); + if (ns == llcp_sock->recv_n) + llcp_sock->recv_n = (llcp_sock->recv_n + 1) % 16; + else + pr_err("Received out of sequence I PDU\n"); + skb_pull(skb, LLCP_HEADER_SIZE + LLCP_SEQUENCE_SIZE); if (sock_queue_rcv_skb(&llcp_sock->sk, skb)) { pr_err("receive queue is full\n"); @@ -700,6 +700,11 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, } } + if (ptype == LLCP_PDU_RR) + llcp_sock->remote_ready = true; + else if (ptype == LLCP_PDU_RNR) + llcp_sock->remote_ready = false; + nfc_llcp_queue_i_frames(llcp_sock); release_sock(sk); @@ -813,6 +818,7 @@ static void nfc_llcp_rx_work(struct work_struct *work) case LLCP_PDU_I: case LLCP_PDU_RR: + case LLCP_PDU_RNR: pr_debug("I frame\n"); nfc_llcp_recv_hdlc(local, skb); break; -- GitLab From 53a0ac2ee810cf82ec374b686a1dc3c32399265a Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:37 +0100 Subject: [PATCH 1447/1846] NFC: LLCP socket sendmsg implemetation Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/commands.c | 31 +++++++++++++++++++++++++++++++ net/nfc/llcp/llcp.h | 2 ++ net/nfc/llcp/sock.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index 151f2ef429c4..f6c2257c11aa 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c @@ -397,3 +397,34 @@ int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock) return 0; } + +int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, + struct msghdr *msg, size_t len) +{ + struct sk_buff *pdu; + struct sock *sk; + + pr_debug("Send I frame\n"); + + pdu = llcp_allocate_pdu(sock, LLCP_PDU_I, len + LLCP_SEQUENCE_SIZE); + if (pdu == NULL) + return -ENOMEM; + + skb_put(pdu, LLCP_SEQUENCE_SIZE); + + if (memcpy_fromiovec(skb_put(pdu, len), msg->msg_iov, len)) { + kfree_skb(pdu); + return -EFAULT; + } + + skb_queue_head(&sock->tx_queue, pdu); + + sk = &sock->sk; + lock_sock(sk); + + nfc_llcp_queue_i_frames(sock); + + release_sock(sk); + + return 0; +} diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 0a72ee627641..36d8572c8beb 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h @@ -188,6 +188,8 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock); int nfc_llcp_send_cc(struct nfc_llcp_sock *sock); int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); +int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, + struct msghdr *msg, size_t len); /* Socket API */ int __init nfc_llcp_sock_init(void); diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index f738ccd535f1..b8bef367ee49 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c @@ -482,6 +482,34 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, return ret; } +static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, + struct msghdr *msg, size_t len) +{ + struct sock *sk = sock->sk; + struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); + int ret; + + pr_debug("sock %p sk %p", sock, sk); + + ret = sock_error(sk); + if (ret) + return ret; + + if (msg->msg_flags & MSG_OOB) + return -EOPNOTSUPP; + + lock_sock(sk); + + if (sk->sk_state != LLCP_CONNECTED) { + release_sock(sk); + return -ENOTCONN; + } + + release_sock(sk); + + return nfc_llcp_send_i_frame(llcp_sock, msg, len); +} + static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) { @@ -567,7 +595,7 @@ static const struct proto_ops llcp_sock_ops = { .shutdown = sock_no_shutdown, .setsockopt = sock_no_setsockopt, .getsockopt = sock_no_getsockopt, - .sendmsg = sock_no_sendmsg, + .sendmsg = llcp_sock_sendmsg, .recvmsg = llcp_sock_recvmsg, .mmap = sock_no_mmap, }; -- GitLab From 1762c17c9c38ed21090bee8cd02e2b470c5c2308 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:38 +0100 Subject: [PATCH 1448/1846] NFC: Fix bitops usage in LLCP Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/llcp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index bbfaa2750ea8..443407e964ca 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -176,7 +176,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, return LLCP_SAP_MAX; } - set_bit(BIT(ssap), &local->local_wks); + set_bit(ssap, &local->local_wks); mutex_unlock(&local->sdp_lock); return ssap; @@ -195,25 +195,25 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, pr_debug("SDP ssap %d\n", LLCP_WKS_NUM_SAP + ssap); - set_bit(BIT(ssap), &local->local_sdp); + set_bit(ssap, &local->local_sdp); mutex_unlock(&local->sdp_lock); return LLCP_WKS_NUM_SAP + ssap; } else if (sock->ssap != 0) { if (sock->ssap < LLCP_WKS_NUM_SAP) { - if (!(local->local_wks & BIT(sock->ssap))) { - set_bit(BIT(sock->ssap), &local->local_wks); + if (!test_bit(sock->ssap, &local->local_wks)) { + set_bit(sock->ssap, &local->local_wks); mutex_unlock(&local->sdp_lock); return sock->ssap; } } else if (sock->ssap < LLCP_SDP_NUM_SAP) { - if (!(local->local_sdp & - BIT(sock->ssap - LLCP_WKS_NUM_SAP))) { - set_bit(BIT(sock->ssap - LLCP_WKS_NUM_SAP), - &local->local_sdp); + if (!test_bit(sock->ssap - LLCP_WKS_NUM_SAP, + &local->local_sdp)) { + set_bit(sock->ssap - LLCP_WKS_NUM_SAP, + &local->local_sdp); mutex_unlock(&local->sdp_lock); return sock->ssap; @@ -238,7 +238,7 @@ u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local) return LLCP_SAP_MAX; } - set_bit(BIT(local_ssap), &local->local_sap); + set_bit(local_ssap, &local->local_sap); mutex_unlock(&local->sdp_lock); @@ -265,7 +265,7 @@ void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap) mutex_lock(&local->sdp_lock); - clear_bit(1 << local_ssap, sdp); + clear_bit(local_ssap, sdp); mutex_unlock(&local->sdp_lock); } -- GitLab From 98b3ac1b980b0c0ffff24fda8d13ab8c216df4d1 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:39 +0100 Subject: [PATCH 1449/1846] NFC: Clear pn533 target structure The polled target structure should be memset to 0 in order to avoid sel_res and sens_res garbage. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/pn533.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 8be0ae626d73..a5766042f0ee 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -904,6 +904,8 @@ static int pn533_target_found(struct pn533 *dev, if (resp->tg != 1) return -EPROTO; + memset(&nfc_tgt, 0, sizeof(struct nfc_target)); + target_data_len = resp_len - sizeof(struct pn533_poll_response); switch (dev->poll_mod_curr) { -- GitLab From b9a76f1d3c6da47b2fa115ff1c0de229e8d06f8f Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:40 +0100 Subject: [PATCH 1450/1846] NFC: Clear LLCP SDPs whan MAC goes down Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/llcp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 443407e964ca..577bcb92ea9b 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -97,6 +97,17 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) mutex_unlock(&local->socket_lock); } +static void nfc_llcp_clear_sdp(struct nfc_llcp_local *local) +{ + mutex_lock(&local->sdp_lock); + + local->local_wks = 0; + local->local_sdp = 0; + local->local_sap = 0; + + mutex_unlock(&local->sdp_lock); +} + static void nfc_llcp_timeout_work(struct work_struct *work) { struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, @@ -857,6 +868,8 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev) if (local == NULL) return; + nfc_llcp_clear_sdp(local); + /* Close and purge all existing sockets */ nfc_llcp_socket_release(local); } -- GitLab From 0767a7fa87ff18f6a11e3de954c5386a45b9d96e Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:41 +0100 Subject: [PATCH 1451/1846] NFC: Set the right LLCP N(R) value for I frames Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/llcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 577bcb92ea9b..2506810cd780 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -419,7 +419,7 @@ static u8 nfc_llcp_nr(struct sk_buff *pdu) static void nfc_llcp_set_nrns(struct nfc_llcp_sock *sock, struct sk_buff *pdu) { - pdu->data[2] = (sock->send_n << 4) | ((sock->recv_n - 1) % 16); + pdu->data[2] = (sock->send_n << 4) | (sock->recv_n % 16); sock->send_n = (sock->send_n + 1) % 16; sock->recv_ack_n = (sock->recv_n - 1) % 16; } -- GitLab From d094afa155273e03b82981ea818d39c7a2dfba86 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:42 +0100 Subject: [PATCH 1452/1846] NFC: Send LLCP RR frames to acknowledge received I frames In order to acknowledge an I frame, we have to either queue pending local I frames or queue a receiver ready frame. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/commands.c | 24 ++++++++++++++++++++++++ net/nfc/llcp/llcp.c | 9 +++++++-- net/nfc/llcp/llcp.h | 3 ++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index f6c2257c11aa..8ebd322b11eb 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c @@ -428,3 +428,27 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, return 0; } + +int nfc_llcp_send_rr(struct nfc_llcp_sock *sock) +{ + struct sk_buff *skb; + struct nfc_llcp_local *local; + + pr_debug("Send rr nr %d\n", sock->recv_n); + + local = sock->local; + if (local == NULL) + return -ENODEV; + + skb = llcp_allocate_pdu(sock, LLCP_PDU_RR, LLCP_SEQUENCE_SIZE); + if (skb == NULL) + return -ENOMEM; + + skb_put(skb, LLCP_SEQUENCE_SIZE); + + skb->data[2] = sock->recv_n % 16; + + skb_queue_head(&local->tx_queue, skb); + + return 0; +} diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 2506810cd780..a0cb133c610a 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -627,8 +627,9 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, } -void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) +int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) { + int nr_frames = 0; struct nfc_llcp_local *local = sock->local; pr_debug("Remote ready %d tx queue len %d remote rw %d", @@ -651,7 +652,10 @@ void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) skb_queue_tail(&local->tx_queue, pdu); skb_queue_tail(&sock->tx_pending_queue, pending_pdu); + nr_frames++; } + + return nr_frames; } static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, @@ -716,7 +720,8 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, else if (ptype == LLCP_PDU_RNR) llcp_sock->remote_ready = false; - nfc_llcp_queue_i_frames(llcp_sock); + if (nfc_llcp_queue_i_frames(llcp_sock) == 0) + nfc_llcp_send_rr(llcp_sock); release_sock(sk); nfc_llcp_sock_put(llcp_sock); diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 36d8572c8beb..054c64ffdaa7 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h @@ -165,7 +165,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, struct nfc_llcp_sock *sock); u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); -void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); +int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); /* Sock API */ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp); @@ -190,6 +190,7 @@ int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, struct msghdr *msg, size_t len); +int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); /* Socket API */ int __init nfc_llcp_sock_init(void); -- GitLab From eda21f16a5ed2476c1740e83a7dfaae34d893d9b Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:43 +0100 Subject: [PATCH 1453/1846] NFC: Set MIU and RW values from CONNECT and CC LLCP frames We use the maximum values for the LLCP Maximum Information Unit and Receive Window Size. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/commands.c | 48 ++++++++++++++++++++++++++++++++++++++--- net/nfc/llcp/llcp.h | 4 ++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index 8ebd322b11eb..a02292ba25c7 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c @@ -284,6 +284,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) struct nfc_llcp_local *local; struct sk_buff *skb; u8 *service_name_tlv = NULL, service_name_tlv_length; + u8 *miux_tlv = NULL, miux_tlv_length; + u8 *rw_tlv = NULL, rw_tlv_length, rw; + __be16 miux; int err; u16 size = 0; @@ -301,6 +304,14 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) size += service_name_tlv_length; } + miux = cpu_to_be16(LLCP_MAX_MIUX); + miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length); + size += miux_tlv_length; + + rw = LLCP_MAX_RW; + rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length); + size += rw_tlv_length; + pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len); skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size); @@ -313,6 +324,9 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) skb = llcp_add_tlv(skb, service_name_tlv, service_name_tlv_length); + skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length); + skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length); + skb_queue_tail(&local->tx_queue, skb); return 0; @@ -321,6 +335,8 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) pr_err("error %d\n", err); kfree(service_name_tlv); + kfree(miux_tlv); + kfree(rw_tlv); return err; } @@ -329,6 +345,11 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) { struct nfc_llcp_local *local; struct sk_buff *skb; + u8 *miux_tlv = NULL, miux_tlv_length; + u8 *rw_tlv = NULL, rw_tlv_length, rw; + __be16 miux; + int err; + u16 size = 0; pr_debug("Sending CC\n"); @@ -336,13 +357,34 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) if (local == NULL) return -ENODEV; - skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, 0); - if (skb == NULL) - return -ENOMEM; + miux = cpu_to_be16(LLCP_MAX_MIUX); + miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length); + size += miux_tlv_length; + + rw = LLCP_MAX_RW; + rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length); + size += rw_tlv_length; + + skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size); + if (skb == NULL) { + err = -ENOMEM; + goto error_tlv; + } + + skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length); + skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length); skb_queue_tail(&local->tx_queue, skb); return 0; + +error_tlv: + pr_err("error %d\n", err); + + kfree(miux_tlv); + kfree(rw_tlv); + + return err; } int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason) diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 054c64ffdaa7..70e1762d6e8d 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h @@ -28,6 +28,10 @@ enum llcp_state { #define LLCP_DEFAULT_RW 1 #define LLCP_DEFAULT_MIU 128 +#define LLCP_MAX_LTO 0xff +#define LLCP_MAX_RW 15 +#define LLCP_MAX_MIUX 0x7ff + #define LLCP_WKS_NUM_SAP 16 #define LLCP_SDP_NUM_SAP 16 #define LLCP_LOCAL_NUM_SAP 32 -- GitLab From e65b0f46edfda746ba8c66ada28ccb97c682b7c0 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:44 +0100 Subject: [PATCH 1454/1846] NFC: Fragment LLCP I frames Based on the receiver MIU, we have to fragment the frame to be transmitted. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/commands.c | 57 +++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index a02292ba25c7..bfe35b8f225e 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c @@ -444,29 +444,58 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, struct msghdr *msg, size_t len) { struct sk_buff *pdu; - struct sock *sk; + struct sock *sk = &sock->sk; + struct nfc_llcp_local *local; + size_t frag_len = 0, remaining_len; + u8 *msg_data, *msg_ptr; - pr_debug("Send I frame\n"); + pr_debug("Send I frame len %zd\n", len); - pdu = llcp_allocate_pdu(sock, LLCP_PDU_I, len + LLCP_SEQUENCE_SIZE); - if (pdu == NULL) - return -ENOMEM; + local = sock->local; + if (local == NULL) + return -ENODEV; - skb_put(pdu, LLCP_SEQUENCE_SIZE); + msg_data = kzalloc(len, GFP_KERNEL); + if (msg_data == NULL) + return -ENOMEM; - if (memcpy_fromiovec(skb_put(pdu, len), msg->msg_iov, len)) { - kfree_skb(pdu); - return -EFAULT; + if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) { + kfree(msg_data); + return -EFAULT; } - skb_queue_head(&sock->tx_queue, pdu); + remaining_len = len; + msg_ptr = msg_data; + + while (remaining_len > 0) { + + frag_len = min_t(u16, local->remote_miu, remaining_len); - sk = &sock->sk; - lock_sock(sk); + pr_debug("Fragment %zd bytes remaining %zd", + frag_len, remaining_len); - nfc_llcp_queue_i_frames(sock); + pdu = llcp_allocate_pdu(sock, LLCP_PDU_I, + frag_len + LLCP_SEQUENCE_SIZE); + if (pdu == NULL) + return -ENOMEM; + + skb_put(pdu, LLCP_SEQUENCE_SIZE); + + memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); + + skb_queue_head(&sock->tx_queue, pdu); + + lock_sock(sk); + + nfc_llcp_queue_i_frames(sock); + + release_sock(sk); + + remaining_len -= frag_len; + msg_ptr += len; + } - release_sock(sk); + kfree(msg_data); return 0; } -- GitLab From 7975754f61b8e87ad0b34509a94c54c8d19ea15d Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:45 +0100 Subject: [PATCH 1455/1846] NFC: Export sensf from pn533 sensf is the detection response for Felica NFC tags. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/pn533.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index a5766042f0ee..353bab775d7d 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -783,6 +783,9 @@ static int pn533_target_found_felica(struct nfc_target *nfc_tgt, u8 *tgt_data, else nfc_tgt->supported_protocols = NFC_PROTO_FELICA_MASK; + memcpy(nfc_tgt->sensf_res, &tgt_felica->opcode, 9); + nfc_tgt->sensf_res_len = 9; + return 0; } -- GitLab From d8dc107248d336695ca6a964c5ffdc2f4d160a04 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:46 +0100 Subject: [PATCH 1456/1846] NFC: Export Jewel/Topaz ID from pn533 The jewel ID is the NFCID1 for Topaz NFC tags. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/pn533.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 353bab775d7d..f5da5ae67ec1 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -828,6 +828,8 @@ static int pn533_target_found_jewel(struct nfc_target *nfc_tgt, u8 *tgt_data, nfc_tgt->supported_protocols = NFC_PROTO_JEWEL_MASK; nfc_tgt->sens_res = be16_to_cpu(tgt_jewel->sens_res); + nfc_tgt->nfcid1_len = 4; + memcpy(nfc_tgt->nfcid1, tgt_jewel->jewelid, nfc_tgt->nfcid1_len); return 0; } -- GitLab From 2fbabfa467ce945deb92bf04c745b4d101fc21ee Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:47 +0100 Subject: [PATCH 1457/1846] NFC: Export NFCID when detecting a p2p target with pn533 Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/pn533.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index f5da5ae67ec1..ef33f64143b5 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -1316,6 +1316,8 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, nfc_dev_dbg(&dev->interface->dev, "Creating new target"); nfc_target.supported_protocols = NFC_PROTO_NFC_DEP_MASK; + nfc_target.nfcid1_len = 10; + memcpy(nfc_target.nfcid1, resp->nfcid3t, nfc_target.nfcid1_len); rc = nfc_targets_found(dev->nfc_dev, &nfc_target, 1); if (rc) return 0; -- GitLab From 0c31835993e622fa9d407807e384c0f9b971d53b Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:48 +0100 Subject: [PATCH 1458/1846] NFC: Unlink LLCP child sockets from llcp_sock_release The parent socket (the bound one) could be freed before its children, so we should unlink the children without trying to reach it through the parent. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/sock.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index b8bef367ee49..d3861773fab0 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c @@ -327,20 +327,10 @@ static int llcp_sock_release(struct socket *sock) mutex_lock(&local->socket_lock); - if (llcp_sock == local->sockets[llcp_sock->ssap]) { + if (llcp_sock == local->sockets[llcp_sock->ssap]) local->sockets[llcp_sock->ssap] = NULL; - } else { - struct nfc_llcp_sock *parent, *s, *n; - - parent = local->sockets[llcp_sock->ssap]; - - list_for_each_entry_safe(s, n, &parent->list, list) - if (llcp_sock == s) { - list_del(&s->list); - break; - } - - } + else + list_del(&llcp_sock->list); mutex_unlock(&local->socket_lock); -- GitLab From 9dda50f4c98f84e32a5f6dc4d9dd7af6085add43 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:49 +0100 Subject: [PATCH 1459/1846] NFC: SN is not an invalid GT value We just don't do anything with it when parsing the general bytes. We handle it from the CONNECT reception code. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/commands.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index bfe35b8f225e..7c74b82f2161 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c @@ -152,6 +152,8 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, case LLCP_TLV_RW: local->remote_rw = llcp_tlv_rw(tlv); break; + case LLCP_TLV_SN: + break; default: pr_err("Invalid gt tlv value 0x%x\n", type); break; -- GitLab From 47807d3dbb62e93850cbcb797db1a9ee1806f986 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:50 +0100 Subject: [PATCH 1460/1846] NFC: Remove the rf mode parameter from the DEP link up routine When calling nfc_dep_link_up, we implicitely are in initiator mode. Which means we also can provide the general bytes as a function argument, as all drivers will eventually request them. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- drivers/nfc/pn533.c | 20 +++++--------------- include/net/nfc/nfc.h | 6 ++---- net/nfc/core.c | 22 +++++++++++----------- net/nfc/llcp/llcp.c | 2 +- net/nfc/netlink.c | 11 +++-------- net/nfc/nfc.h | 5 ++--- 6 files changed, 24 insertions(+), 42 deletions(-) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index ef33f64143b5..cb6204f78300 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -1340,21 +1340,15 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, } static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, - u8 comm_mode, u8 rf_mode) + u8 comm_mode, u8* gb, size_t gb_len) { struct pn533 *dev = nfc_get_drvdata(nfc_dev); struct pn533_cmd_jump_dep *cmd; - u8 cmd_len, local_gt_len, *local_gt; + u8 cmd_len; int rc; nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - if (rf_mode == NFC_RF_TARGET) { - nfc_dev_err(&dev->interface->dev, "Target mode not supported"); - return -EOPNOTSUPP; - } - - if (dev->poll_mod_count) { nfc_dev_err(&dev->interface->dev, "Cannot bring the DEP link up while polling"); @@ -1367,11 +1361,7 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, return -EBUSY; } - local_gt = nfc_get_local_general_bytes(dev->nfc_dev, &local_gt_len); - if (local_gt_len > NFC_MAX_GT_LEN) - return -EINVAL; - - cmd_len = sizeof(struct pn533_cmd_jump_dep) + local_gt_len; + cmd_len = sizeof(struct pn533_cmd_jump_dep) + gb_len; cmd = kzalloc(cmd_len, GFP_KERNEL); if (cmd == NULL) return -ENOMEM; @@ -1380,9 +1370,9 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, cmd->active = !comm_mode; cmd->baud = 0; - if (local_gt != NULL) { + if (gb != NULL && gb_len > 0) { cmd->next = 4; /* We have some Gi */ - memcpy(cmd->gt, local_gt, local_gt_len); + memcpy(cmd->gt, gb, gb_len); } else { cmd->next = 0; } diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index d253278e5a96..d608e4eac66f 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -53,8 +53,8 @@ struct nfc_ops { int (*dev_down)(struct nfc_dev *dev); int (*start_poll)(struct nfc_dev *dev, u32 protocols); void (*stop_poll)(struct nfc_dev *dev); - int (*dep_link_up)(struct nfc_dev *dev, int target_idx, - u8 comm_mode, u8 rf_mode); + int (*dep_link_up)(struct nfc_dev *dev, int target_idx, u8 comm_mode, + u8 *gb, size_t gb_len); int (*dep_link_down)(struct nfc_dev *dev); int (*activate_target)(struct nfc_dev *dev, u32 target_idx, u32 protocol); @@ -179,8 +179,6 @@ struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp); int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gt, u8 gt_len); -u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len); - int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, int ntargets); diff --git a/net/nfc/core.c b/net/nfc/core.c index 6089aca67b14..f4f526f73217 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -181,13 +181,13 @@ int nfc_stop_poll(struct nfc_dev *dev) return rc; } -int nfc_dep_link_up(struct nfc_dev *dev, int target_index, - u8 comm_mode, u8 rf_mode) +int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode) { int rc = 0; + u8 *gb; + size_t gb_len; - pr_debug("dev_name=%s comm:%d rf:%d\n", - dev_name(&dev->dev), comm_mode, rf_mode); + pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode); if (!dev->ops->dep_link_up) return -EOPNOTSUPP; @@ -204,7 +204,13 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, goto error; } - rc = dev->ops->dep_link_up(dev, target_index, comm_mode, rf_mode); + gb = nfc_llcp_general_bytes(dev, &gb_len); + if (gb_len > NFC_MAX_GT_LEN) { + rc = -EINVAL; + goto error; + } + + rc = dev->ops->dep_link_up(dev, target_index, comm_mode, gb, gb_len); error: device_unlock(&dev->dev); @@ -367,12 +373,6 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) } EXPORT_SYMBOL(nfc_set_remote_general_bytes); -u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len) -{ - return nfc_llcp_general_bytes(dev, gt_len); -} -EXPORT_SYMBOL(nfc_get_local_general_bytes); - /** * nfc_alloc_send_skb - allocate a skb for data exchange responses * diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index a0cb133c610a..3ce646e35f6b 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -281,7 +281,7 @@ void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap) mutex_unlock(&local->sdp_lock); } -u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *general_bytes_len) +u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len) { struct nfc_llcp_local *local; diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index a1388e4efd6f..fa620d03799e 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -542,13 +542,12 @@ static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info) struct nfc_dev *dev; int rc, tgt_idx; u32 idx; - u8 comm, rf; + u8 comm; pr_debug("DEP link up\n"); if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || - !info->attrs[NFC_ATTR_COMM_MODE] || - !info->attrs[NFC_ATTR_RF_MODE]) + !info->attrs[NFC_ATTR_COMM_MODE]) return -EINVAL; idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); @@ -558,19 +557,15 @@ static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info) tgt_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]); comm = nla_get_u8(info->attrs[NFC_ATTR_COMM_MODE]); - rf = nla_get_u8(info->attrs[NFC_ATTR_RF_MODE]); if (comm != NFC_COMM_ACTIVE && comm != NFC_COMM_PASSIVE) return -EINVAL; - if (rf != NFC_RF_INITIATOR && comm != NFC_RF_TARGET) - return -EINVAL; - dev = nfc_get_device(idx); if (!dev) return -ENODEV; - rc = nfc_dep_link_up(dev, tgt_idx, comm, rf); + rc = nfc_dep_link_up(dev, tgt_idx, comm); nfc_put_device(dev); diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 6d28d75995b0..2fd83b16df68 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h @@ -54,7 +54,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, int nfc_llcp_register_device(struct nfc_dev *dev); void nfc_llcp_unregister_device(struct nfc_dev *dev); int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); -u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *general_bytes_len); +u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len); int __init nfc_llcp_init(void); void nfc_llcp_exit(void); @@ -160,8 +160,7 @@ int nfc_start_poll(struct nfc_dev *dev, u32 protocols); int nfc_stop_poll(struct nfc_dev *dev); -int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, - u8 comm_mode, u8 rf_mode); +int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, u8 comm_mode); int nfc_dep_link_down(struct nfc_dev *dev); -- GitLab From 40c75f81d6852bb4fd08491074889187f77b8d1f Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:51 +0100 Subject: [PATCH 1461/1846] NFC: Fix LLCP sockets releasing path The socket local pointer needs to be set to NULL when the adapter is removed or the MAC goes down. If the socket release code is called after such an event, the socket reference count still needs to be decreased in order for the socket to eventually be freed. Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/llcp.c | 15 +++++++++++---- net/nfc/llcp/sock.c | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 3ce646e35f6b..8af896dc759e 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -47,7 +47,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) /* Release all child sockets */ list_for_each_entry_safe(s, n, &parent->list, list) { - list_del(&s->list); + list_del_init(&s->list); sk = &s->sk; lock_sock(sk); @@ -56,9 +56,12 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) nfc_put_device(s->dev); sk->sk_state = LLCP_CLOSED; - sock_set_flag(sk, SOCK_DEAD); release_sock(sk); + + sock_orphan(sk); + + s->local = NULL; } parent_sk = &parent->sk; @@ -77,11 +80,12 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) nfc_llcp_accept_unlink(accept_sk); accept_sk->sk_state = LLCP_CLOSED; - sock_set_flag(accept_sk, SOCK_DEAD); release_sock(accept_sk); sock_orphan(accept_sk); + + lsk->local = NULL; } } @@ -89,9 +93,12 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) nfc_put_device(parent->dev); parent_sk->sk_state = LLCP_CLOSED; - sock_set_flag(parent_sk, SOCK_DEAD); release_sock(parent_sk); + + sock_orphan(parent_sk); + + parent->local = NULL; } mutex_unlock(&local->socket_lock); diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index d3861773fab0..35825e20163a 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c @@ -315,6 +315,7 @@ static int llcp_sock_release(struct socket *sock) struct sock *sk = sock->sk; struct nfc_llcp_local *local; struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); + int err = 0; if (!sk) return 0; @@ -322,15 +323,17 @@ static int llcp_sock_release(struct socket *sock) pr_debug("%p\n", sk); local = llcp_sock->local; - if (local == NULL) - return -ENODEV; + if (local == NULL) { + err = -ENODEV; + goto out; + } mutex_lock(&local->socket_lock); if (llcp_sock == local->sockets[llcp_sock->ssap]) local->sockets[llcp_sock->ssap] = NULL; else - list_del(&llcp_sock->list); + list_del_init(&llcp_sock->list); mutex_unlock(&local->socket_lock); @@ -354,9 +357,7 @@ static int llcp_sock_release(struct socket *sock) release_sock(accept_sk); - sock_set_flag(sk, SOCK_DEAD); sock_orphan(accept_sk); - sock_put(accept_sk); } } @@ -367,14 +368,13 @@ static int llcp_sock_release(struct socket *sock) sk->sk_state == LLCP_LISTEN) nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap); - sock_set_flag(sk, SOCK_DEAD); - release_sock(sk); +out: sock_orphan(sk); sock_put(sk); - return 0; + return err; } static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, @@ -645,6 +645,8 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp) void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) { + struct nfc_llcp_local *local = sock->local; + kfree(sock->service_name); skb_queue_purge(&sock->tx_queue); @@ -653,6 +655,11 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) list_del_init(&sock->accept_queue); + if (local != NULL && sock == local->sockets[sock->ssap]) + local->sockets[sock->ssap] = NULL; + else + list_del_init(&sock->list); + sock->parent = NULL; } -- GitLab From 427a2eb1f568c9c5934a36105232c94553db9b69 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:52 +0100 Subject: [PATCH 1462/1846] NFC: LLCP code identation fixes Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- net/nfc/llcp/commands.c | 39 +++++++++-------- net/nfc/llcp/llcp.c | 93 +++++++++++++++++++++-------------------- net/nfc/llcp/llcp.h | 6 +-- net/nfc/llcp/sock.c | 55 ++++++++++++------------ 4 files changed, 100 insertions(+), 93 deletions(-) diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index 7c74b82f2161..7b76eb7192f3 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c @@ -118,7 +118,7 @@ u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length) } int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, - u8 *tlv_array, u16 tlv_array_len) + u8 *tlv_array, u16 tlv_array_len) { u8 *tlv = tlv_array, type, length, offset = 0; @@ -164,15 +164,15 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, } pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x rw %d\n", - local->remote_version, local->remote_miu, - local->remote_lto, local->remote_opt, - local->remote_wks, local->remote_rw); + local->remote_version, local->remote_miu, + local->remote_lto, local->remote_opt, + local->remote_wks, local->remote_rw); return 0; } static struct sk_buff *llcp_add_header(struct sk_buff *pdu, - u8 dsap, u8 ssap, u8 ptype) + u8 dsap, u8 ssap, u8 ptype) { u8 header[2]; @@ -188,7 +188,8 @@ static struct sk_buff *llcp_add_header(struct sk_buff *pdu, return pdu; } -static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length) +static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, + u8 tlv_length) { /* XXX Add an skb length check */ @@ -201,7 +202,7 @@ static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length) } static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock, - u8 cmd, u16 size) + u8 cmd, u16 size) { struct sk_buff *skb; int err; @@ -210,7 +211,7 @@ static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock, return NULL; skb = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT, - size + LLCP_HEADER_SIZE, &err); + size + LLCP_HEADER_SIZE, &err); if (skb == NULL) { pr_err("Could not allocate PDU\n"); return NULL; @@ -278,7 +279,7 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) skb = llcp_add_header(skb, 0, 0, LLCP_PDU_SYMM); return nfc_data_exchange(dev, local->target_idx, skb, - nfc_llcp_recv, local); + nfc_llcp_recv, local); } int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) @@ -300,14 +301,15 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) if (sock->service_name != NULL) { service_name_tlv = nfc_llcp_build_tlv(LLCP_TLV_SN, - sock->service_name, - sock->service_name_len, - &service_name_tlv_length); + sock->service_name, + sock->service_name_len, + &service_name_tlv_length); size += service_name_tlv_length; } miux = cpu_to_be16(LLCP_MAX_MIUX); - miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length); + miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, + &miux_tlv_length); size += miux_tlv_length; rw = LLCP_MAX_RW; @@ -324,7 +326,7 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) if (service_name_tlv != NULL) skb = llcp_add_tlv(skb, service_name_tlv, - service_name_tlv_length); + service_name_tlv_length); skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length); skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length); @@ -360,7 +362,8 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) return -ENODEV; miux = cpu_to_be16(LLCP_MAX_MIUX); - miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length); + miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, + &miux_tlv_length); size += miux_tlv_length; rw = LLCP_MAX_RW; @@ -443,7 +446,7 @@ int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock) } int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, - struct msghdr *msg, size_t len) + struct msghdr *msg, size_t len) { struct sk_buff *pdu; struct sock *sk = &sock->sk; @@ -462,8 +465,8 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, return -ENOMEM; if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) { - kfree(msg_data); - return -EFAULT; + kfree(msg_data); + return -EFAULT; } remaining_len = len; diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 8af896dc759e..17a578f641f1 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -37,7 +37,6 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) struct sock *sk, *parent_sk; int i; - mutex_lock(&local->socket_lock); for (i = 0; i < LLCP_MAX_SAP; i++) { @@ -73,7 +72,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) struct sock *accept_sk; list_for_each_entry_safe(lsk, n, &parent->accept_queue, - accept_queue) { + accept_queue) { accept_sk = &lsk->sk; lock_sock(accept_sk); @@ -118,7 +117,7 @@ static void nfc_llcp_clear_sdp(struct nfc_llcp_local *local) static void nfc_llcp_timeout_work(struct work_struct *work) { struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, - timeout_work); + timeout_work); nfc_dep_link_down(local->dev); } @@ -164,7 +163,7 @@ static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len) num_wks = ARRAY_SIZE(wks); - for (sap = 0 ; sap < num_wks; sap++) { + for (sap = 0; sap < num_wks; sap++) { if (wks[sap] == NULL) continue; @@ -176,13 +175,13 @@ static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len) } u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, - struct nfc_llcp_sock *sock) + struct nfc_llcp_sock *sock) { mutex_lock(&local->sdp_lock); if (sock->service_name != NULL && sock->service_name_len > 0) { int ssap = nfc_llcp_wks_sap(sock->service_name, - sock->service_name_len); + sock->service_name_len); if (ssap > 0) { pr_debug("WKS %d\n", ssap); @@ -312,7 +311,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) version = LLCP_VERSION_11; version_tlv = nfc_llcp_build_tlv(LLCP_TLV_VERSION, &version, - 1, &version_length); + 1, &version_length); gb_len += version_length; /* 1500 ms */ @@ -322,7 +321,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) pr_debug("Local wks 0x%lx\n", local->local_wks); wks_tlv = nfc_llcp_build_tlv(LLCP_TLV_WKS, (u8 *)&local->local_wks, 2, - &wks_length); + &wks_length); gb_len += wks_length; gb_len += ARRAY_SIZE(llcp_magic); @@ -367,8 +366,7 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) memcpy(local->remote_gb, gb, gb_len); local->remote_gb_len = gb_len; - if (local->remote_gb == NULL || - local->remote_gb_len == 0) + if (local->remote_gb == NULL || local->remote_gb_len == 0) return -ENODEV; if (memcmp(local->remote_gb, llcp_magic, 3)) { @@ -377,26 +375,27 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) } return nfc_llcp_parse_tlv(local, - &local->remote_gb[3], local->remote_gb_len - 3); + &local->remote_gb[3], + local->remote_gb_len - 3); } static void nfc_llcp_tx_work(struct work_struct *work) { struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, - tx_work); + tx_work); struct sk_buff *skb; skb = skb_dequeue(&local->tx_queue); if (skb != NULL) { pr_debug("Sending pending skb\n"); nfc_data_exchange(local->dev, local->target_idx, - skb, nfc_llcp_recv, local); + skb, nfc_llcp_recv, local); } else { nfc_llcp_send_symm(local->dev); } mod_timer(&local->link_timer, - jiffies + msecs_to_jiffies(local->remote_lto)); + jiffies + msecs_to_jiffies(local->remote_lto)); } static u8 nfc_llcp_dsap(struct sk_buff *pdu) @@ -432,7 +431,7 @@ static void nfc_llcp_set_nrns(struct nfc_llcp_sock *sock, struct sk_buff *pdu) } static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, - u8 ssap, u8 dsap) + u8 ssap, u8 dsap) { struct nfc_llcp_sock *sock, *llcp_sock, *n; @@ -456,7 +455,7 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, list_for_each_entry_safe(llcp_sock, n, &sock->list, list) { pr_debug("llcp_sock %p sk %p dsap %d\n", llcp_sock, - &llcp_sock->sk, llcp_sock->dsap); + &llcp_sock->sk, llcp_sock->dsap); if (llcp_sock->dsap == dsap) { sock_hold(&llcp_sock->sk); mutex_unlock(&local->socket_lock); @@ -500,7 +499,7 @@ static u8 *nfc_llcp_connect_sn(struct sk_buff *skb, size_t *sn_len) } static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, - struct sk_buff *skb) + struct sk_buff *skb) { struct sock *new_sk, *parent; struct nfc_llcp_sock *sock, *new_sock; @@ -512,7 +511,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, pr_debug("%d %d\n", dsap, ssap); nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], - skb->len - LLCP_HEADER_SIZE); + skb->len - LLCP_HEADER_SIZE); if (dsap != LLCP_SAP_SDP) { bound_sap = dsap; @@ -531,7 +530,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, lock_sock(&sock->sk); if (sock->dsap == LLCP_SAP_SDP && - sock->sk.sk_state == LLCP_LISTEN) + sock->sk.sk_state == LLCP_LISTEN) goto enqueue; } else { u8 *sn; @@ -547,23 +546,23 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, mutex_lock(&local->socket_lock); for (bound_sap = 0; bound_sap < LLCP_LOCAL_SAP_OFFSET; - bound_sap++) { + bound_sap++) { sock = local->sockets[bound_sap]; if (sock == NULL) continue; if (sock->service_name == NULL || - sock->service_name_len == 0) + sock->service_name_len == 0) continue; if (sock->service_name_len != sn_len) continue; if (sock->dsap == LLCP_SAP_SDP && - sock->sk.sk_state == LLCP_LISTEN && - !memcmp(sn, sock->service_name, sn_len)) { + sock->sk.sk_state == LLCP_LISTEN && + !memcmp(sn, sock->service_name, sn_len)) { pr_debug("Found service name at SAP %d\n", - bound_sap); + bound_sap); sock_hold(&sock->sk); mutex_unlock(&local->socket_lock); @@ -588,8 +587,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, goto fail; } - new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, - GFP_ATOMIC); + new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, GFP_ATOMIC); if (new_sk == NULL) { reason = LLCP_DM_REJ; release_sock(&sock->sk); @@ -640,12 +638,12 @@ int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) struct nfc_llcp_local *local = sock->local; pr_debug("Remote ready %d tx queue len %d remote rw %d", - sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), - local->remote_rw); + sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), + local->remote_rw); /* Try to queue some I frames for transmission */ while (sock->remote_ready && - skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) { + skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) { struct sk_buff *pdu, *pending_pdu; pdu = skb_dequeue(&sock->tx_queue); @@ -666,7 +664,7 @@ int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) } static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, - struct sk_buff *skb) + struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; struct sock *sk; @@ -724,7 +722,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, if (ptype == LLCP_PDU_RR) llcp_sock->remote_ready = true; - else if (ptype == LLCP_PDU_RNR) + else if (ptype == LLCP_PDU_RNR) llcp_sock->remote_ready = false; if (nfc_llcp_queue_i_frames(llcp_sock) == 0) @@ -735,7 +733,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, } static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, - struct sk_buff *skb) + struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; struct sock *sk; @@ -757,7 +755,6 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, nfc_llcp_sock_put(llcp_sock); } - if (sk->sk_state == LLCP_CONNECTED) { nfc_put_device(local->dev); sk->sk_state = LLCP_CLOSED; @@ -770,13 +767,11 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, nfc_llcp_sock_put(llcp_sock); } -static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, - struct sk_buff *skb) +static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; u8 dsap, ssap; - dsap = nfc_llcp_dsap(skb); ssap = nfc_llcp_ssap(skb); @@ -795,7 +790,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, llcp_sock->dsap = ssap; nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], - skb->len - LLCP_HEADER_SIZE); + skb->len - LLCP_HEADER_SIZE); nfc_llcp_sock_put(llcp_sock); } @@ -803,7 +798,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, static void nfc_llcp_rx_work(struct work_struct *work) { struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, - rx_work); + rx_work); u8 dsap, ssap, ptype; struct sk_buff *skb; @@ -861,7 +856,7 @@ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err) pr_debug("Received an LLCP PDU\n"); if (err < 0) { - pr_err("err %d", err); + pr_err("err %d\n", err); return; } @@ -907,7 +902,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, queue_work(local->tx_wq, &local->tx_work); } else { mod_timer(&local->link_timer, - jiffies + msecs_to_jiffies(local->remote_lto)); + jiffies + msecs_to_jiffies(local->remote_lto)); } } @@ -933,8 +928,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) skb_queue_head_init(&local->tx_queue); INIT_WORK(&local->tx_work, nfc_llcp_tx_work); snprintf(name, sizeof(name), "%s_llcp_tx_wq", dev_name(dev)); - local->tx_wq = alloc_workqueue(name, - WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); + local->tx_wq = + alloc_workqueue(name, + WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, + 1); if (local->tx_wq == NULL) { err = -ENOMEM; goto err_local; @@ -943,8 +940,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) local->rx_pending = NULL; INIT_WORK(&local->rx_work, nfc_llcp_rx_work); snprintf(name, sizeof(name), "%s_llcp_rx_wq", dev_name(dev)); - local->rx_wq = alloc_workqueue(name, - WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); + local->rx_wq = + alloc_workqueue(name, + WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, + 1); if (local->rx_wq == NULL) { err = -ENOMEM; goto err_tx_wq; @@ -952,8 +951,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) INIT_WORK(&local->timeout_work, nfc_llcp_timeout_work); snprintf(name, sizeof(name), "%s_llcp_timeout_wq", dev_name(dev)); - local->timeout_wq = alloc_workqueue(name, - WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); + local->timeout_wq = + alloc_workqueue(name, + WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, + 1); if (local->timeout_wq == NULL) { err = -ENOMEM; goto err_rx_wq; diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 70e1762d6e8d..50680ce5ae43 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h @@ -166,7 +166,7 @@ struct nfc_llcp_sock { struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, - struct nfc_llcp_sock *sock); + struct nfc_llcp_sock *sock); u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); @@ -180,7 +180,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); /* TLV API */ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, - u8 *tlv_array, u16 tlv_array_len); + u8 *tlv_array, u16 tlv_array_len); /* Commands API */ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); @@ -193,7 +193,7 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock); int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, - struct msghdr *msg, size_t len); + struct msghdr *msg, size_t len); int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); /* Socket API */ diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index 35825e20163a..c13e02ebdef9 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c @@ -78,9 +78,11 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) llcp_sock->local = local; llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; llcp_sock->service_name_len = min_t(unsigned int, - llcp_addr.service_name_len, NFC_LLCP_MAX_SERVICE_NAME); + llcp_addr.service_name_len, + NFC_LLCP_MAX_SERVICE_NAME); llcp_sock->service_name = kmemdup(llcp_addr.service_name, - llcp_sock->service_name_len, GFP_KERNEL); + llcp_sock->service_name_len, + GFP_KERNEL); llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); if (llcp_sock->ssap == LLCP_MAX_SAP) @@ -110,7 +112,7 @@ static int llcp_sock_listen(struct socket *sock, int backlog) lock_sock(sk); if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM) - || sk->sk_state != LLCP_BOUND) { + || sk->sk_state != LLCP_BOUND) { ret = -EBADFD; goto error; } @@ -149,13 +151,13 @@ void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk) sock_hold(sk); list_add_tail(&llcp_sock->accept_queue, - &llcp_sock_parent->accept_queue); + &llcp_sock_parent->accept_queue); llcp_sock->parent = parent; sk_acceptq_added(parent); } struct sock *nfc_llcp_accept_dequeue(struct sock *parent, - struct socket *newsock) + struct socket *newsock) { struct nfc_llcp_sock *lsk, *n, *llcp_parent; struct sock *sk; @@ -163,7 +165,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent, llcp_parent = nfc_llcp_sock(parent); list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue, - accept_queue) { + accept_queue) { sk = &lsk->sk; lock_sock(sk); @@ -192,7 +194,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent, } static int llcp_sock_accept(struct socket *sock, struct socket *newsock, - int flags) + int flags) { DECLARE_WAITQUEUE(wait, current); struct sock *sk = sock->sk, *new_sk; @@ -248,7 +250,7 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock, static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) { - struct sockaddr_nfc_llcp *llcp_addr = (struct sockaddr_nfc_llcp *) addr; + struct sockaddr_nfc_llcp *llcp_addr = (struct sockaddr_nfc_llcp *)addr; struct sock *sk = sock->sk; struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); @@ -262,7 +264,7 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr, llcp_addr->ssap = llcp_sock->ssap; llcp_addr->service_name_len = llcp_sock->service_name_len; memcpy(llcp_addr->service_name, llcp_sock->service_name, - llcp_addr->service_name_len); + llcp_addr->service_name_len); return 0; } @@ -275,7 +277,7 @@ static inline unsigned int llcp_accept_poll(struct sock *parent) parent_sock = nfc_llcp_sock(parent); list_for_each_entry_safe(llcp_sock, n, &parent_sock->accept_queue, - accept_queue) { + accept_queue) { sk = &llcp_sock->sk; if (sk->sk_state == LLCP_CONNECTED) @@ -286,7 +288,7 @@ static inline unsigned int llcp_accept_poll(struct sock *parent) } static unsigned int llcp_sock_poll(struct file *file, struct socket *sock, - poll_table *wait) + poll_table *wait) { struct sock *sk = sock->sk; unsigned int mask = 0; @@ -348,7 +350,7 @@ static int llcp_sock_release(struct socket *sock) struct sock *accept_sk; list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue, - accept_queue) { + accept_queue) { accept_sk = &lsk->sk; lock_sock(accept_sk); @@ -363,9 +365,8 @@ static int llcp_sock_release(struct socket *sock) /* Freeing the SAP */ if ((sk->sk_state == LLCP_CONNECTED - && llcp_sock->ssap > LLCP_LOCAL_SAP_OFFSET) || - sk->sk_state == LLCP_BOUND || - sk->sk_state == LLCP_LISTEN) + && llcp_sock->ssap > LLCP_LOCAL_SAP_OFFSET) || + sk->sk_state == LLCP_BOUND || sk->sk_state == LLCP_LISTEN) nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap); release_sock(sk); @@ -378,7 +379,7 @@ static int llcp_sock_release(struct socket *sock) } static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, - int len, int flags) + int len, int flags) { struct sock *sk = sock->sk; struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); @@ -390,7 +391,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, pr_debug("sock %p sk %p flags 0x%x\n", sock, sk, flags); if (!addr || len < sizeof(struct sockaddr_nfc) || - addr->sa_family != AF_NFC) { + addr->sa_family != AF_NFC) { pr_err("Invalid socket\n"); return -EINVAL; } @@ -401,7 +402,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, } pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n", addr->dev_idx, - addr->target_idx, addr->nfc_protocol); + addr->target_idx, addr->nfc_protocol); lock_sock(sk); @@ -431,7 +432,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, device_unlock(&dev->dev); if (local->rf_mode == NFC_RF_INITIATOR && - addr->target_idx != local->target_idx) { + addr->target_idx != local->target_idx) { ret = -ENOLINK; goto put_dev; } @@ -449,9 +450,11 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, llcp_sock->dsap = LLCP_SAP_SDP; llcp_sock->nfc_protocol = addr->nfc_protocol; llcp_sock->service_name_len = min_t(unsigned int, - addr->service_name_len, NFC_LLCP_MAX_SERVICE_NAME); + addr->service_name_len, + NFC_LLCP_MAX_SERVICE_NAME); llcp_sock->service_name = kmemdup(addr->service_name, - llcp_sock->service_name_len, GFP_KERNEL); + llcp_sock->service_name_len, + GFP_KERNEL); local->sockets[llcp_sock->ssap] = llcp_sock; @@ -473,7 +476,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, } static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len) + struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); @@ -514,7 +517,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, lock_sock(sk); if (sk->sk_state == LLCP_CLOSED && - skb_queue_empty(&sk->sk_receive_queue)) { + skb_queue_empty(&sk->sk_receive_queue)) { release_sock(sk); return 0; } @@ -527,7 +530,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, skb = skb_recv_datagram(sk, flags, noblock, &err); if (!skb) { pr_err("Recv datagram failed state %d %d %d", - sk->sk_state, err, sock_error(sk)); + sk->sk_state, err, sock_error(sk)); if (sk->sk_shutdown & RCV_SHUTDOWN) return 0; @@ -535,7 +538,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, return err; } - rlen = skb->len; /* real length of skb */ + rlen = skb->len; /* real length of skb */ copied = min_t(unsigned int, rlen, len); cskb = skb; @@ -664,7 +667,7 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) } static int llcp_sock_create(struct net *net, struct socket *sock, - const struct nfc_protocol *nfc_proto) + const struct nfc_protocol *nfc_proto) { struct sock *sk; -- GitLab From 0a40acb24602783fcf6881f915659148aa9807d7 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:53 +0100 Subject: [PATCH 1463/1846] NFC: Core code identation fixes Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- include/net/nfc/nfc.h | 24 +++++++++--------- net/nfc/af_nfc.c | 2 +- net/nfc/core.c | 28 +++++++++------------ net/nfc/netlink.c | 57 ++++++++++++++++++++----------------------- net/nfc/nfc.h | 13 +++++----- net/nfc/rawsock.c | 16 ++++++------ 6 files changed, 66 insertions(+), 74 deletions(-) diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index d608e4eac66f..bac070bf3514 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -57,11 +57,11 @@ struct nfc_ops { u8 *gb, size_t gb_len); int (*dep_link_down)(struct nfc_dev *dev); int (*activate_target)(struct nfc_dev *dev, u32 target_idx, - u32 protocol); + u32 protocol); void (*deactivate_target)(struct nfc_dev *dev, u32 target_idx); int (*data_exchange)(struct nfc_dev *dev, u32 target_idx, - struct sk_buff *skb, data_exchange_cb_t cb, - void *cb_context); + struct sk_buff *skb, data_exchange_cb_t cb, + void *cb_context); }; #define NFC_TARGET_IDX_ANY -1 @@ -110,9 +110,9 @@ struct nfc_dev { extern struct class nfc_class; struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, - u32 supported_protocols, - int tx_headroom, - int tx_tailroom); + u32 supported_protocols, + int tx_headroom, + int tx_tailroom); /** * nfc_free_device - free nfc device @@ -135,7 +135,7 @@ void nfc_unregister_device(struct nfc_dev *dev); * @dev: The parent device */ static inline void nfc_set_parent_dev(struct nfc_dev *nfc_dev, - struct device *dev) + struct device *dev) { nfc_dev->dev.parent = dev; } @@ -172,15 +172,15 @@ static inline const char *nfc_device_name(struct nfc_dev *dev) } struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk, - unsigned int flags, unsigned int size, - unsigned int *err); + unsigned int flags, unsigned int size, + unsigned int *err); struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp); int nfc_set_remote_general_bytes(struct nfc_dev *dev, - u8 *gt, u8 gt_len); + u8 *gt, u8 gt_len); -int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, - int ntargets); +int nfc_targets_found(struct nfc_dev *dev, + struct nfc_target *targets, int ntargets); int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, u8 comm_mode, u8 rf_mode); diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c index da67756425ce..9d68441e2a5a 100644 --- a/net/nfc/af_nfc.c +++ b/net/nfc/af_nfc.c @@ -30,7 +30,7 @@ static DEFINE_RWLOCK(proto_tab_lock); static const struct nfc_protocol *proto_tab[NFC_SOCKPROTO_MAX]; static int nfc_sock_create(struct net *net, struct socket *sock, int proto, - int kern) + int kern) { int rc = -EPROTONOSUPPORT; diff --git a/net/nfc/core.c b/net/nfc/core.c index f4f526f73217..295d129864d2 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -256,7 +256,7 @@ int nfc_dep_link_down(struct nfc_dev *dev) } int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, - u8 comm_mode, u8 rf_mode) + u8 comm_mode, u8 rf_mode) { dev->dep_link_up = true; dev->dep_rf_mode = rf_mode; @@ -336,10 +336,8 @@ int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx) * * The user must wait for the callback before calling this function again. */ -int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, - struct sk_buff *skb, - data_exchange_cb_t cb, - void *cb_context) +int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, + data_exchange_cb_t cb, void *cb_context) { int rc; @@ -363,8 +361,7 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) { - pr_debug("dev_name=%s gb_len=%d\n", - dev_name(&dev->dev), gb_len); + pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len); if (gb_len > NFC_MAX_GT_LEN) return -EINVAL; @@ -380,8 +377,8 @@ EXPORT_SYMBOL(nfc_set_remote_general_bytes); * @gfp: gfp flags */ struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk, - unsigned int flags, unsigned int size, - unsigned int *err) + unsigned int flags, unsigned int size, + unsigned int *err) { struct sk_buff *skb; unsigned int total_size; @@ -428,8 +425,8 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb); * are found. After calling this function, the device driver must stop * polling for targets. */ -int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, - int n_targets) +int nfc_targets_found(struct nfc_dev *dev, + struct nfc_target *targets, int n_targets) { pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets); @@ -441,7 +438,7 @@ int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, kfree(dev->targets); dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target), - GFP_ATOMIC); + GFP_ATOMIC); if (!dev->targets) { dev->n_targets = 0; @@ -501,15 +498,14 @@ struct nfc_dev *nfc_get_device(unsigned idx) * @supported_protocols: NFC protocols supported by the device */ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, - u32 supported_protocols, - int tx_headroom, - int tx_tailroom) + u32 supported_protocols, + int tx_headroom, int tx_tailroom) { static atomic_t dev_no = ATOMIC_INIT(0); struct nfc_dev *dev; if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || - !ops->deactivate_target || !ops->data_exchange) + !ops->deactivate_target || !ops->data_exchange) return NULL; if (!supported_protocols) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index fa620d03799e..6404052d6c07 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -52,31 +52,30 @@ static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = { }; static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target, - struct netlink_callback *cb, int flags) + struct netlink_callback *cb, int flags) { void *hdr; hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, - &nfc_genl_family, flags, NFC_CMD_GET_TARGET); + &nfc_genl_family, flags, NFC_CMD_GET_TARGET); if (!hdr) return -EMSGSIZE; genl_dump_check_consistent(cb, hdr, &nfc_genl_family); NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target->idx); - NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, - target->supported_protocols); + NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, target->supported_protocols); NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res); NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res); if (target->nfcid1_len > 0) NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len, - target->nfcid1); + target->nfcid1); if (target->sensb_res_len > 0) NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len, - target->sensb_res); + target->sensb_res); if (target->sensf_res_len > 0) NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len, - target->sensf_res); + target->sensf_res); return genlmsg_end(msg, hdr); @@ -92,9 +91,9 @@ static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb) u32 idx; rc = nlmsg_parse(cb->nlh, GENL_HDRLEN + nfc_genl_family.hdrsize, - nfc_genl_family.attrbuf, - nfc_genl_family.maxattr, - nfc_genl_policy); + nfc_genl_family.attrbuf, + nfc_genl_family.maxattr, + nfc_genl_policy); if (rc < 0) return ERR_PTR(rc); @@ -111,7 +110,7 @@ static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb) } static int nfc_genl_dump_targets(struct sk_buff *skb, - struct netlink_callback *cb) + struct netlink_callback *cb) { int i = cb->args[0]; struct nfc_dev *dev = (struct nfc_dev *) cb->args[1]; @@ -131,7 +130,7 @@ static int nfc_genl_dump_targets(struct sk_buff *skb, while (i < dev->n_targets) { rc = nfc_genl_send_target(skb, &dev->targets[i], cb, - NLM_F_MULTI); + NLM_F_MULTI); if (rc < 0) break; @@ -167,7 +166,7 @@ int nfc_genl_targets_found(struct nfc_dev *dev) return -ENOMEM; hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_EVENT_TARGETS_FOUND); + NFC_EVENT_TARGETS_FOUND); if (!hdr) goto free_msg; @@ -194,7 +193,7 @@ int nfc_genl_device_added(struct nfc_dev *dev) return -ENOMEM; hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_EVENT_DEVICE_ADDED); + NFC_EVENT_DEVICE_ADDED); if (!hdr) goto free_msg; @@ -226,7 +225,7 @@ int nfc_genl_device_removed(struct nfc_dev *dev) return -ENOMEM; hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_EVENT_DEVICE_REMOVED); + NFC_EVENT_DEVICE_REMOVED); if (!hdr) goto free_msg; @@ -246,14 +245,14 @@ int nfc_genl_device_removed(struct nfc_dev *dev) } static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, - u32 pid, u32 seq, - struct netlink_callback *cb, - int flags) + u32 pid, u32 seq, + struct netlink_callback *cb, + int flags) { void *hdr; hdr = genlmsg_put(msg, pid, seq, &nfc_genl_family, flags, - NFC_CMD_GET_DEVICE); + NFC_CMD_GET_DEVICE); if (!hdr) return -EMSGSIZE; @@ -273,7 +272,7 @@ static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, } static int nfc_genl_dump_devices(struct sk_buff *skb, - struct netlink_callback *cb) + struct netlink_callback *cb) { struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0]; struct nfc_dev *dev = (struct nfc_dev *) cb->args[1]; @@ -300,8 +299,7 @@ static int nfc_genl_dump_devices(struct sk_buff *skb, int rc; rc = nfc_genl_send_device(skb, dev, NETLINK_CB(cb->skb).pid, - cb->nlh->nlmsg_seq, - cb, NLM_F_MULTI); + cb->nlh->nlmsg_seq, cb, NLM_F_MULTI); if (rc < 0) break; @@ -326,7 +324,7 @@ static int nfc_genl_dump_devices_done(struct netlink_callback *cb) } int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx, - u8 comm_mode, u8 rf_mode) + u8 comm_mode, u8 rf_mode) { struct sk_buff *msg; void *hdr; @@ -337,8 +335,7 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx, if (!msg) return -ENOMEM; - hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_CMD_DEP_LINK_UP); + hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, NFC_CMD_DEP_LINK_UP); if (!hdr) goto free_msg; @@ -375,7 +372,7 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev) return -ENOMEM; hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_CMD_DEP_LINK_DOWN); + NFC_CMD_DEP_LINK_DOWN); if (!hdr) goto free_msg; @@ -417,7 +414,7 @@ static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info) } rc = nfc_genl_send_device(msg, dev, info->snd_pid, info->snd_seq, - NULL, 0); + NULL, 0); if (rc < 0) goto out_free; @@ -484,7 +481,7 @@ static int nfc_genl_start_poll(struct sk_buff *skb, struct genl_info *info) pr_debug("Poll start\n"); if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || - !info->attrs[NFC_ATTR_PROTOCOLS]) + !info->attrs[NFC_ATTR_PROTOCOLS]) return -EINVAL; idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); @@ -640,7 +637,7 @@ static struct genl_ops nfc_genl_ops[] = { }; static int nfc_genl_rcv_nl_event(struct notifier_block *this, - unsigned long event, void *ptr) + unsigned long event, void *ptr) { struct netlink_notify *n = ptr; struct class_dev_iter iter; @@ -693,7 +690,7 @@ int __init nfc_genl_init(void) int rc; rc = genl_register_family_with_ops(&nfc_genl_family, nfc_genl_ops, - ARRAY_SIZE(nfc_genl_ops)); + ARRAY_SIZE(nfc_genl_ops)); if (rc) return rc; diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 2fd83b16df68..ec8794c1099c 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h @@ -32,7 +32,7 @@ struct nfc_protocol { struct proto *proto; struct module *owner; int (*create)(struct net *net, struct socket *sock, - const struct nfc_protocol *nfc_proto); + const struct nfc_protocol *nfc_proto); }; struct nfc_rawsock { @@ -65,7 +65,7 @@ static inline void nfc_llcp_mac_is_down(struct nfc_dev *dev) } static inline void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, - u8 comm_mode, u8 rf_mode) + u8 comm_mode, u8 rf_mode) { } @@ -78,7 +78,8 @@ static inline void nfc_llcp_unregister_device(struct nfc_dev *dev) { } -static inline int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) +static inline int nfc_llcp_set_remote_gb(struct nfc_dev *dev, + u8 *gb, u8 gb_len) { return 0; } @@ -168,9 +169,7 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol); int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx); -int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, - struct sk_buff *skb, - data_exchange_cb_t cb, - void *cb_context); +int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, + data_exchange_cb_t cb, void *cb_context); #endif /* __LOCAL_NFC_H */ diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index 5325439b0c60..5a839ceb2e82 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -63,7 +63,7 @@ static int rawsock_release(struct socket *sock) } static int rawsock_connect(struct socket *sock, struct sockaddr *_addr, - int len, int flags) + int len, int flags) { struct sock *sk = sock->sk; struct sockaddr_nfc *addr = (struct sockaddr_nfc *)_addr; @@ -73,7 +73,7 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr, pr_debug("sock=%p sk=%p flags=%d\n", sock, sk, flags); if (!addr || len < sizeof(struct sockaddr_nfc) || - addr->sa_family != AF_NFC) + addr->sa_family != AF_NFC) return -EINVAL; pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n", @@ -120,7 +120,7 @@ static int rawsock_add_header(struct sk_buff *skb) } static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb, - int err) + int err) { struct sock *sk = (struct sock *) context; @@ -173,7 +173,7 @@ static void rawsock_tx_work(struct work_struct *work) sock_hold(sk); rc = nfc_data_exchange(dev, target_idx, skb, - rawsock_data_exchange_complete, sk); + rawsock_data_exchange_complete, sk); if (rc) { rawsock_report_error(sk, rc); sock_put(sk); @@ -181,7 +181,7 @@ static void rawsock_tx_work(struct work_struct *work) } static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len) + struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct nfc_dev *dev = nfc_rawsock(sk)->dev; @@ -218,7 +218,7 @@ static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock, } static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len, int flags) + struct msghdr *msg, size_t len, int flags) { int noblock = flags & MSG_DONTWAIT; struct sock *sk = sock->sk; @@ -274,7 +274,7 @@ static void rawsock_destruct(struct sock *sk) if (sk->sk_state == TCP_ESTABLISHED) { nfc_deactivate_target(nfc_rawsock(sk)->dev, - nfc_rawsock(sk)->target_idx); + nfc_rawsock(sk)->target_idx); nfc_put_device(nfc_rawsock(sk)->dev); } @@ -287,7 +287,7 @@ static void rawsock_destruct(struct sock *sk) } static int rawsock_create(struct net *net, struct socket *sock, - const struct nfc_protocol *nfc_proto) + const struct nfc_protocol *nfc_proto) { struct sock *sk; -- GitLab From eb9bc6e9a0ac668d2283b8fea1534f8ba31d1692 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 5 Mar 2012 01:03:54 +0100 Subject: [PATCH 1464/1846] NFC: NCI code identation fixes Signed-off-by: Samuel Ortiz Signed-off-by: John W. Linville --- include/net/nfc/nci_core.h | 10 ++-- net/nfc/nci/core.c | 113 ++++++++++++++++++------------------- net/nfc/nci/data.c | 28 ++++----- net/nfc/nci/ntf.c | 75 ++++++++++++------------ net/nfc/nci/rsp.c | 17 +++--- 5 files changed, 116 insertions(+), 127 deletions(-) diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 86fee8b5c65c..feba74027ff8 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h @@ -141,17 +141,17 @@ struct nci_dev { /* ----- NCI Devices ----- */ struct nci_dev *nci_allocate_device(struct nci_ops *ops, - __u32 supported_protocols, - int tx_headroom, - int tx_tailroom); + __u32 supported_protocols, + int tx_headroom, + int tx_tailroom); void nci_free_device(struct nci_dev *ndev); int nci_register_device(struct nci_dev *ndev); void nci_unregister_device(struct nci_dev *ndev); int nci_recv_frame(struct sk_buff *skb); static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev, - unsigned int len, - gfp_t how) + unsigned int len, + gfp_t how) { struct sk_buff *skb; diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index a47e90c7d9d1..9ec065bb9ee1 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c @@ -66,9 +66,8 @@ static void nci_req_cancel(struct nci_dev *ndev, int err) /* Execute request and wait for completion. */ static int __nci_request(struct nci_dev *ndev, - void (*req)(struct nci_dev *ndev, unsigned long opt), - unsigned long opt, - __u32 timeout) + void (*req)(struct nci_dev *ndev, unsigned long opt), + unsigned long opt, __u32 timeout) { int rc = 0; long completion_rc; @@ -77,9 +76,9 @@ static int __nci_request(struct nci_dev *ndev, init_completion(&ndev->req_completion); req(ndev, opt); - completion_rc = wait_for_completion_interruptible_timeout( - &ndev->req_completion, - timeout); + completion_rc = + wait_for_completion_interruptible_timeout(&ndev->req_completion, + timeout); pr_debug("wait_for_completion return %ld\n", completion_rc); @@ -110,8 +109,9 @@ static int __nci_request(struct nci_dev *ndev, } static inline int nci_request(struct nci_dev *ndev, - void (*req)(struct nci_dev *ndev, unsigned long opt), - unsigned long opt, __u32 timeout) + void (*req)(struct nci_dev *ndev, + unsigned long opt), + unsigned long opt, __u32 timeout) { int rc; @@ -152,14 +152,14 @@ static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt) /* by default mapping is set to NCI_RF_INTERFACE_FRAME */ for (i = 0; i < ndev->num_supported_rf_interfaces; i++) { if (ndev->supported_rf_interfaces[i] == - NCI_RF_INTERFACE_ISO_DEP) { + NCI_RF_INTERFACE_ISO_DEP) { cfg[*num].rf_protocol = NCI_RF_PROTOCOL_ISO_DEP; cfg[*num].mode = NCI_DISC_MAP_MODE_POLL | NCI_DISC_MAP_MODE_LISTEN; cfg[*num].rf_interface = NCI_RF_INTERFACE_ISO_DEP; (*num)++; } else if (ndev->supported_rf_interfaces[i] == - NCI_RF_INTERFACE_NFC_DEP) { + NCI_RF_INTERFACE_NFC_DEP) { cfg[*num].rf_protocol = NCI_RF_PROTOCOL_NFC_DEP; cfg[*num].mode = NCI_DISC_MAP_MODE_POLL | NCI_DISC_MAP_MODE_LISTEN; @@ -172,8 +172,7 @@ static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt) } nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_MAP_CMD, - (1 + ((*num)*sizeof(struct disc_map_config))), - &cmd); + (1 + ((*num) * sizeof(struct disc_map_config))), &cmd); } static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) @@ -184,36 +183,36 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) cmd.num_disc_configs = 0; if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && - (protocols & NFC_PROTO_JEWEL_MASK - || protocols & NFC_PROTO_MIFARE_MASK - || protocols & NFC_PROTO_ISO14443_MASK - || protocols & NFC_PROTO_NFC_DEP_MASK)) { + (protocols & NFC_PROTO_JEWEL_MASK + || protocols & NFC_PROTO_MIFARE_MASK + || protocols & NFC_PROTO_ISO14443_MASK + || protocols & NFC_PROTO_NFC_DEP_MASK)) { cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = - NCI_NFC_A_PASSIVE_POLL_MODE; + NCI_NFC_A_PASSIVE_POLL_MODE; cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.num_disc_configs++; } if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && - (protocols & NFC_PROTO_ISO14443_MASK)) { + (protocols & NFC_PROTO_ISO14443_MASK)) { cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = - NCI_NFC_B_PASSIVE_POLL_MODE; + NCI_NFC_B_PASSIVE_POLL_MODE; cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.num_disc_configs++; } if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && - (protocols & NFC_PROTO_FELICA_MASK - || protocols & NFC_PROTO_NFC_DEP_MASK)) { + (protocols & NFC_PROTO_FELICA_MASK + || protocols & NFC_PROTO_NFC_DEP_MASK)) { cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = - NCI_NFC_F_PASSIVE_POLL_MODE; + NCI_NFC_F_PASSIVE_POLL_MODE; cmd.disc_configs[cmd.num_disc_configs].frequency = 1; cmd.num_disc_configs++; } nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, - (1 + (cmd.num_disc_configs*sizeof(struct disc_config))), - &cmd); + (1 + (cmd.num_disc_configs * sizeof(struct disc_config))), + &cmd); } struct nci_rf_discover_select_param { @@ -224,7 +223,7 @@ struct nci_rf_discover_select_param { static void nci_rf_discover_select_req(struct nci_dev *ndev, unsigned long opt) { struct nci_rf_discover_select_param *param = - (struct nci_rf_discover_select_param *)opt; + (struct nci_rf_discover_select_param *)opt; struct nci_rf_discover_select_cmd cmd; cmd.rf_discovery_id = param->rf_discovery_id; @@ -245,8 +244,7 @@ static void nci_rf_discover_select_req(struct nci_dev *ndev, unsigned long opt) } nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_SELECT_CMD, - sizeof(struct nci_rf_discover_select_cmd), - &cmd); + sizeof(struct nci_rf_discover_select_cmd), &cmd); } static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt) @@ -256,8 +254,7 @@ static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt) cmd.type = NCI_DEACTIVATE_TYPE_IDLE_MODE; nci_send_cmd(ndev, NCI_OP_RF_DEACTIVATE_CMD, - sizeof(struct nci_rf_deactivate_cmd), - &cmd); + sizeof(struct nci_rf_deactivate_cmd), &cmd); } static int nci_open_device(struct nci_dev *ndev) @@ -281,16 +278,16 @@ static int nci_open_device(struct nci_dev *ndev) set_bit(NCI_INIT, &ndev->flags); rc = __nci_request(ndev, nci_reset_req, 0, - msecs_to_jiffies(NCI_RESET_TIMEOUT)); + msecs_to_jiffies(NCI_RESET_TIMEOUT)); if (!rc) { rc = __nci_request(ndev, nci_init_req, 0, - msecs_to_jiffies(NCI_INIT_TIMEOUT)); + msecs_to_jiffies(NCI_INIT_TIMEOUT)); } if (!rc) { rc = __nci_request(ndev, nci_init_complete_req, 0, - msecs_to_jiffies(NCI_INIT_TIMEOUT)); + msecs_to_jiffies(NCI_INIT_TIMEOUT)); } clear_bit(NCI_INIT, &ndev->flags); @@ -340,7 +337,7 @@ static int nci_close_device(struct nci_dev *ndev) set_bit(NCI_INIT, &ndev->flags); __nci_request(ndev, nci_reset_req, 0, - msecs_to_jiffies(NCI_RESET_TIMEOUT)); + msecs_to_jiffies(NCI_RESET_TIMEOUT)); clear_bit(NCI_INIT, &ndev->flags); /* Flush cmd wq */ @@ -396,7 +393,7 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) int rc; if ((atomic_read(&ndev->state) == NCI_DISCOVERY) || - (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) { + (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) { pr_err("unable to start poll, since poll is already active\n"); return -EBUSY; } @@ -407,17 +404,17 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols) } if ((atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) || - (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) { + (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) { pr_debug("target active or w4 select, implicitly deactivate\n"); rc = nci_request(ndev, nci_rf_deactivate_req, 0, - msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); + msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); if (rc) return -EBUSY; } rc = nci_request(ndev, nci_rf_discover_req, protocols, - msecs_to_jiffies(NCI_RF_DISC_TIMEOUT)); + msecs_to_jiffies(NCI_RF_DISC_TIMEOUT)); if (!rc) ndev->poll_prots = protocols; @@ -430,17 +427,17 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev) struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); if ((atomic_read(&ndev->state) != NCI_DISCOVERY) && - (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) { + (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) { pr_err("unable to stop poll, since poll is not active\n"); return; } nci_request(ndev, nci_rf_deactivate_req, 0, - msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); + msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); } static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, - __u32 protocol) + __u32 protocol) { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); struct nci_rf_discover_select_param param; @@ -451,7 +448,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) && - (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { + (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { pr_err("there is no available target to activate\n"); return -EINVAL; } @@ -494,8 +491,8 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP; rc = nci_request(ndev, nci_rf_discover_select_req, - (unsigned long)¶m, - msecs_to_jiffies(NCI_RF_DISC_SELECT_TIMEOUT)); + (unsigned long)¶m, + msecs_to_jiffies(NCI_RF_DISC_SELECT_TIMEOUT)); } if (!rc) @@ -519,14 +516,13 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { nci_request(ndev, nci_rf_deactivate_req, 0, - msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); + msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); } } static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx, - struct sk_buff *skb, - data_exchange_cb_t cb, - void *cb_context) + struct sk_buff *skb, + data_exchange_cb_t cb, void *cb_context) { struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); int rc; @@ -571,9 +567,8 @@ static struct nfc_ops nci_nfc_ops = { * @supported_protocols: NFC protocols supported by the device */ struct nci_dev *nci_allocate_device(struct nci_ops *ops, - __u32 supported_protocols, - int tx_headroom, - int tx_tailroom) + __u32 supported_protocols, + int tx_headroom, int tx_tailroom) { struct nci_dev *ndev; @@ -594,9 +589,9 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops, ndev->tx_tailroom = tx_tailroom; ndev->nfc_dev = nfc_allocate_device(&nci_nfc_ops, - supported_protocols, - tx_headroom + NCI_DATA_HDR_SIZE, - tx_tailroom); + supported_protocols, + tx_headroom + NCI_DATA_HDR_SIZE, + tx_tailroom); if (!ndev->nfc_dev) goto free_exit; @@ -668,9 +663,9 @@ int nci_register_device(struct nci_dev *ndev) skb_queue_head_init(&ndev->tx_q); setup_timer(&ndev->cmd_timer, nci_cmd_timer, - (unsigned long) ndev); + (unsigned long) ndev); setup_timer(&ndev->data_timer, nci_data_timer, - (unsigned long) ndev); + (unsigned long) ndev); mutex_init(&ndev->req_lock); @@ -719,7 +714,7 @@ int nci_recv_frame(struct sk_buff *skb) pr_debug("len %d\n", skb->len); if (!ndev || (!test_bit(NCI_UP, &ndev->flags) - && !test_bit(NCI_INIT, &ndev->flags))) { + && !test_bit(NCI_INIT, &ndev->flags))) { kfree_skb(skb); return -ENXIO; } @@ -799,7 +794,7 @@ static void nci_tx_work(struct work_struct *work) /* Check if data flow control is used */ if (atomic_read(&ndev->credits_cnt) != - NCI_DATA_FLOW_CONTROL_NOT_USED) + NCI_DATA_FLOW_CONTROL_NOT_USED) atomic_dec(&ndev->credits_cnt); pr_debug("NCI TX: MT=data, PBF=%d, conn_id=%d, plen=%d\n", @@ -810,7 +805,7 @@ static void nci_tx_work(struct work_struct *work) nci_send_frame(skb); mod_timer(&ndev->data_timer, - jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT)); + jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT)); } } @@ -879,6 +874,6 @@ static void nci_cmd_work(struct work_struct *work) nci_send_frame(skb); mod_timer(&ndev->cmd_timer, - jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT)); + jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT)); } } diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index 7880ae924d5e..a0bc326308a5 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c @@ -35,8 +35,7 @@ #include /* Complete data exchange transaction and forward skb to nfc core */ -void nci_data_exchange_complete(struct nci_dev *ndev, - struct sk_buff *skb, +void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, int err) { data_exchange_cb_t cb = ndev->data_exchange_cb; @@ -67,9 +66,9 @@ void nci_data_exchange_complete(struct nci_dev *ndev, /* ----------------- NCI TX Data ----------------- */ static inline void nci_push_data_hdr(struct nci_dev *ndev, - __u8 conn_id, - struct sk_buff *skb, - __u8 pbf) + __u8 conn_id, + struct sk_buff *skb, + __u8 pbf) { struct nci_data_hdr *hdr; int plen = skb->len; @@ -86,8 +85,8 @@ static inline void nci_push_data_hdr(struct nci_dev *ndev, } static int nci_queue_tx_data_frags(struct nci_dev *ndev, - __u8 conn_id, - struct sk_buff *skb) { + __u8 conn_id, + struct sk_buff *skb) { int total_len = skb->len; unsigned char *data = skb->data; unsigned long flags; @@ -105,8 +104,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev, min_t(int, total_len, ndev->max_data_pkt_payload_size); skb_frag = nci_skb_alloc(ndev, - (NCI_DATA_HDR_SIZE + frag_len), - GFP_KERNEL); + (NCI_DATA_HDR_SIZE + frag_len), + GFP_KERNEL); if (skb_frag == NULL) { rc = -ENOMEM; goto free_exit; @@ -118,7 +117,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev, /* second, set the header */ nci_push_data_hdr(ndev, conn_id, skb_frag, - ((total_len == frag_len) ? (NCI_PBF_LAST) : (NCI_PBF_CONT))); + ((total_len == frag_len) ? + (NCI_PBF_LAST) : (NCI_PBF_CONT))); __skb_queue_tail(&frags_q, skb_frag); @@ -186,8 +186,8 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb) /* ----------------- NCI RX Data ----------------- */ static void nci_add_rx_data_frag(struct nci_dev *ndev, - struct sk_buff *skb, - __u8 pbf) + struct sk_buff *skb, + __u8 pbf) { int reassembly_len; int err = 0; @@ -211,8 +211,8 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, /* second, combine the two fragments */ memcpy(skb_push(skb, reassembly_len), - ndev->rx_data_reassembly->data, - reassembly_len); + ndev->rx_data_reassembly->data, + reassembly_len); /* third, free old reassembly */ kfree_skb(ndev->rx_data_reassembly); diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 03e7b4626a3e..2e3dee42196d 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c @@ -40,7 +40,7 @@ /* Handle NCI Notification packets */ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { struct nci_core_conn_credit_ntf *ntf = (void *) skb->data; int i; @@ -62,7 +62,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) { /* found static rf connection */ atomic_add(ntf->conn_entries[i].credits, - &ndev->credits_cnt); + &ndev->credits_cnt); } } @@ -72,7 +72,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, } static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { __u8 status = skb->data[0]; @@ -80,7 +80,7 @@ static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev, if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { /* Activation failed, so complete the request - (the state remains the same) */ + (the state remains the same) */ nci_req_complete(ndev, status); } } @@ -101,7 +101,7 @@ static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev, static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, struct rf_tech_specific_params_nfca_poll *nfca_poll, - __u8 *data) + __u8 *data) { nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); data += 2; @@ -128,7 +128,7 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, struct rf_tech_specific_params_nfcb_poll *nfcb_poll, - __u8 *data) + __u8 *data) { nfcb_poll->sensb_res_len = *data++; @@ -142,13 +142,13 @@ static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, struct rf_tech_specific_params_nfcf_poll *nfcf_poll, - __u8 *data) + __u8 *data) { nfcf_poll->bit_rate = *data++; nfcf_poll->sensf_res_len = *data++; pr_debug("bit_rate %d, sensf_res_len %d\n", - nfcf_poll->bit_rate, nfcf_poll->sensf_res_len); + nfcf_poll->bit_rate, nfcf_poll->sensf_res_len); memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len); data += nfcf_poll->sensf_res_len; @@ -189,7 +189,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, target->nfcid1_len = nfca_poll->nfcid1_len; if (target->nfcid1_len > 0) { memcpy(target->nfcid1, nfca_poll->nfcid1, - target->nfcid1_len); + target->nfcid1_len); } } else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) { nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params; @@ -197,7 +197,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, target->sensb_res_len = nfcb_poll->sensb_res_len; if (target->sensb_res_len > 0) { memcpy(target->sensb_res, nfcb_poll->sensb_res, - target->sensb_res_len); + target->sensb_res_len); } } else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) { nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params; @@ -205,7 +205,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, target->sensf_res_len = nfcf_poll->sensf_res_len; if (target->sensf_res_len > 0) { memcpy(target->sensf_res, nfcf_poll->sensf_res, - target->sensf_res_len); + target->sensf_res_len); } } else { pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); @@ -220,7 +220,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, } static void nci_add_new_target(struct nci_dev *ndev, - struct nci_rf_discover_ntf *ntf) + struct nci_rf_discover_ntf *ntf) { struct nfc_target *target; int i, rc; @@ -230,8 +230,8 @@ static void nci_add_new_target(struct nci_dev *ndev, if (target->idx == ntf->rf_discovery_id) { /* This target already exists, add the new protocol */ nci_add_new_protocol(ndev, target, ntf->rf_protocol, - ntf->rf_tech_and_mode, - &ntf->rf_tech_specific_params); + ntf->rf_tech_and_mode, + &ntf->rf_tech_specific_params); return; } } @@ -245,27 +245,27 @@ static void nci_add_new_target(struct nci_dev *ndev, target = &ndev->targets[ndev->n_targets]; rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, - ntf->rf_tech_and_mode, - &ntf->rf_tech_specific_params); + ntf->rf_tech_and_mode, + &ntf->rf_tech_specific_params); if (!rc) { target->idx = ntf->rf_discovery_id; ndev->n_targets++; pr_debug("target_idx %d, n_targets %d\n", target->idx, - ndev->n_targets); + ndev->n_targets); } } void nci_clear_target_list(struct nci_dev *ndev) { memset(ndev->targets, 0, - (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS)); + (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS)); ndev->n_targets = 0; } static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { struct nci_rf_discover_ntf ntf; __u8 *data = skb->data; @@ -280,7 +280,7 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol); pr_debug("rf_tech_and_mode 0x%x\n", ntf.rf_tech_and_mode); pr_debug("rf_tech_specific_params_len %d\n", - ntf.rf_tech_specific_params_len); + ntf.rf_tech_specific_params_len); if (ntf.rf_tech_specific_params_len > 0) { switch (ntf.rf_tech_and_mode) { @@ -318,7 +318,7 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, } else { atomic_set(&ndev->state, NCI_W4_HOST_SELECT); nfc_targets_found(ndev->nfc_dev, ndev->targets, - ndev->n_targets); + ndev->n_targets); } } @@ -335,20 +335,17 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len); if (nfca_poll->rats_res_len > 0) { memcpy(nfca_poll->rats_res, - data, - nfca_poll->rats_res_len); + data, nfca_poll->rats_res_len); } break; case NCI_NFC_B_PASSIVE_POLL_MODE: nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep; nfcb_poll->attrib_res_len = *data++; - pr_debug("attrib_res_len %d\n", - nfcb_poll->attrib_res_len); + pr_debug("attrib_res_len %d\n", nfcb_poll->attrib_res_len); if (nfcb_poll->attrib_res_len > 0) { memcpy(nfcb_poll->attrib_res, - data, - nfcb_poll->attrib_res_len); + data, nfcb_poll->attrib_res_len); } break; @@ -362,7 +359,7 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, } static void nci_target_auto_activated(struct nci_dev *ndev, - struct nci_rf_intf_activated_ntf *ntf) + struct nci_rf_intf_activated_ntf *ntf) { struct nfc_target *target; int rc; @@ -370,8 +367,8 @@ static void nci_target_auto_activated(struct nci_dev *ndev, target = &ndev->targets[ndev->n_targets]; rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, - ntf->activation_rf_tech_and_mode, - &ntf->rf_tech_specific_params); + ntf->activation_rf_tech_and_mode, + &ntf->rf_tech_specific_params); if (rc) return; @@ -384,7 +381,7 @@ static void nci_target_auto_activated(struct nci_dev *ndev, } static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { struct nci_rf_intf_activated_ntf ntf; __u8 *data = skb->data; @@ -405,7 +402,8 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, ntf.activation_rf_tech_and_mode); pr_debug("max_data_pkt_payload_size 0x%x\n", ntf.max_data_pkt_payload_size); - pr_debug("initial_num_credits 0x%x\n", ntf.initial_num_credits); + pr_debug("initial_num_credits 0x%x\n", + ntf.initial_num_credits); pr_debug("rf_tech_specific_params_len %d\n", ntf.rf_tech_specific_params_len); @@ -441,18 +439,15 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, pr_debug("data_exch_rf_tech_and_mode 0x%x\n", ntf.data_exch_rf_tech_and_mode); - pr_debug("data_exch_tx_bit_rate 0x%x\n", - ntf.data_exch_tx_bit_rate); - pr_debug("data_exch_rx_bit_rate 0x%x\n", - ntf.data_exch_rx_bit_rate); - pr_debug("activation_params_len %d\n", - ntf.activation_params_len); + pr_debug("data_exch_tx_bit_rate 0x%x\n", ntf.data_exch_tx_bit_rate); + pr_debug("data_exch_rx_bit_rate 0x%x\n", ntf.data_exch_rx_bit_rate); + pr_debug("activation_params_len %d\n", ntf.activation_params_len); if (ntf.activation_params_len > 0) { switch (ntf.rf_interface) { case NCI_RF_INTERFACE_ISO_DEP: err = nci_extract_activation_params_iso_dep(ndev, - &ntf, data); + &ntf, data); break; case NCI_RF_INTERFACE_FRAME: @@ -489,7 +484,7 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, } static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { struct nci_rf_deactivate_ntf *ntf = (void *) skb->data; diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c index aa63b1e99188..3003c3390e49 100644 --- a/net/nfc/nci/rsp.c +++ b/net/nfc/nci/rsp.c @@ -67,19 +67,18 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces; if (ndev->num_supported_rf_interfaces > - NCI_MAX_SUPPORTED_RF_INTERFACES) { + NCI_MAX_SUPPORTED_RF_INTERFACES) { ndev->num_supported_rf_interfaces = NCI_MAX_SUPPORTED_RF_INTERFACES; } memcpy(ndev->supported_rf_interfaces, - rsp_1->supported_rf_interfaces, - ndev->num_supported_rf_interfaces); + rsp_1->supported_rf_interfaces, + ndev->num_supported_rf_interfaces); rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces); - ndev->max_logical_connections = - rsp_2->max_logical_connections; + ndev->max_logical_connections = rsp_2->max_logical_connections; ndev->max_routing_table_size = __le16_to_cpu(rsp_2->max_routing_table_size); ndev->max_ctrl_pkt_payload_len = @@ -121,7 +120,7 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) } static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { __u8 status = skb->data[0]; @@ -143,7 +142,7 @@ static void nci_rf_disc_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) } static void nci_rf_disc_select_rsp_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { __u8 status = skb->data[0]; @@ -155,7 +154,7 @@ static void nci_rf_disc_select_rsp_packet(struct nci_dev *ndev, } static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, - struct sk_buff *skb) + struct sk_buff *skb) { __u8 status = skb->data[0]; @@ -163,7 +162,7 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, /* If target was active, complete the request only in deactivate_ntf */ if ((status != NCI_STATUS_OK) || - (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { + (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { nci_clear_target_list(ndev); atomic_set(&ndev->state, NCI_IDLE); nci_req_complete(ndev, status); -- GitLab From 6975f4ce5a44e337514283e84761adaf2849aa26 Mon Sep 17 00:00:00 2001 From: Santosh Nayak Date: Fri, 2 Mar 2012 05:09:39 +0000 Subject: [PATCH 1465/1846] qla3xxx: ethernet: Silence static checker warning. Silence the following warning: "warn: returning -1 instead of -ENOMEM is sloppy". Signed-off-by: Santosh Nayak Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qla3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index 8da3e41058ca..df09b1cb742f 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c @@ -2836,7 +2836,7 @@ static int ql_create_send_free_list(struct ql3_adapter *qdev) req_q_curr++; tx_cb->oal = kmalloc(512, GFP_KERNEL); if (tx_cb->oal == NULL) - return -1; + return -ENOMEM; } return 0; } -- GitLab From ebf8c9aa032f03343b91c91951b0705021b02eb0 Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Tue, 6 Mar 2012 04:03:34 +0000 Subject: [PATCH 1466/1846] net/mlx4_en: Saving mem access on data path Localized the pdev->dev, and using dma_map instead of pci_map There are multiple map/unmap operations on data path, optimizing those by saving redundant pointer access. Those places were identified as hot-spots when running kernel profiling during some benchmarks. The fixes had most impact when testing packet rate with small packets, reducing several % from CPU load, and in some case being the difference between reaching wire speed or being CPU bound. Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 + drivers/net/ethernet/mellanox/mlx4/en_rx.c | 14 +++++--------- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 13 ++++++------- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 + 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 9fe4f94c6da7..31b455a49273 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -1062,6 +1062,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, memset(priv, 0, sizeof(struct mlx4_en_priv)); priv->dev = dev; priv->mdev = mdev; + priv->ddev = &mdev->pdev->dev; priv->prof = prof; priv->port = port; priv->port_up = false; diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index d703ef2c9c91..c881712b7492 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -48,7 +48,6 @@ static int mlx4_en_alloc_frag(struct mlx4_en_priv *priv, struct mlx4_en_rx_alloc *ring_alloc, int i) { - struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_frag_info *frag_info = &priv->frag_info[i]; struct mlx4_en_rx_alloc *page_alloc = &ring_alloc[i]; struct page *page; @@ -72,7 +71,7 @@ static int mlx4_en_alloc_frag(struct mlx4_en_priv *priv, skb_frags[i].offset = page_alloc->offset; page_alloc->offset += frag_info->frag_stride; } - dma = pci_map_single(mdev->pdev, page_address(skb_frags[i].page) + + dma = dma_map_single(priv->ddev, page_address(skb_frags[i].page) + skb_frags[i].offset, frag_info->frag_size, PCI_DMA_FROMDEVICE); rx_desc->data[i].addr = cpu_to_be64(dma); @@ -186,7 +185,6 @@ static void mlx4_en_free_rx_desc(struct mlx4_en_priv *priv, struct mlx4_en_rx_ring *ring, int index) { - struct mlx4_en_dev *mdev = priv->mdev; struct page_frag *skb_frags; struct mlx4_en_rx_desc *rx_desc = ring->buf + (index << ring->log_stride); dma_addr_t dma; @@ -198,7 +196,7 @@ static void mlx4_en_free_rx_desc(struct mlx4_en_priv *priv, dma = be64_to_cpu(rx_desc->data[nr].addr); en_dbg(DRV, priv, "Unmapping buffer at dma:0x%llx\n", (u64) dma); - pci_unmap_single(mdev->pdev, dma, skb_frags[nr].size, + dma_unmap_single(priv->ddev, dma, skb_frags[nr].size, PCI_DMA_FROMDEVICE); put_page(skb_frags[nr].page); } @@ -412,7 +410,6 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv, int length) { struct skb_frag_struct *skb_frags_rx = skb_shinfo(skb)->frags; - struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_frag_info *frag_info; int nr; dma_addr_t dma; @@ -435,7 +432,7 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv, goto fail; /* Unmap buffer */ - pci_unmap_single(mdev->pdev, dma, skb_frag_size(&skb_frags_rx[nr]), + dma_unmap_single(priv->ddev, dma, skb_frag_size(&skb_frags_rx[nr]), PCI_DMA_FROMDEVICE); } /* Adjust size of last fragment to match actual length */ @@ -461,7 +458,6 @@ static struct sk_buff *mlx4_en_rx_skb(struct mlx4_en_priv *priv, struct mlx4_en_rx_alloc *page_alloc, unsigned int length) { - struct mlx4_en_dev *mdev = priv->mdev; struct sk_buff *skb; void *va; int used_frags; @@ -483,10 +479,10 @@ static struct sk_buff *mlx4_en_rx_skb(struct mlx4_en_priv *priv, /* We are copying all relevant data to the skb - temporarily * synch buffers for the copy */ dma = be64_to_cpu(rx_desc->data[0].addr); - dma_sync_single_for_cpu(&mdev->pdev->dev, dma, length, + dma_sync_single_for_cpu(priv->ddev, dma, length, DMA_FROM_DEVICE); skb_copy_to_linear_data(skb, va, length); - dma_sync_single_for_device(&mdev->pdev->dev, dma, length, + dma_sync_single_for_device(priv->ddev, dma, length, DMA_FROM_DEVICE); skb->tail += length; } else { diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 50b3fa5212ed..008f0af5cc8b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -198,7 +198,6 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, struct mlx4_en_tx_ring *ring, int index, u8 owner) { - struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_tx_info *tx_info = &ring->tx_info[index]; struct mlx4_en_tx_desc *tx_desc = ring->buf + index * TXBB_SIZE; struct mlx4_wqe_data_seg *data = (void *) tx_desc + tx_info->data_offset; @@ -214,7 +213,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, if (likely((void *) tx_desc + tx_info->nr_txbb * TXBB_SIZE <= end)) { if (!tx_info->inl) { if (tx_info->linear) { - pci_unmap_single(mdev->pdev, + dma_unmap_single(priv->ddev, (dma_addr_t) be64_to_cpu(data->addr), be32_to_cpu(data->byte_count), PCI_DMA_TODEVICE); @@ -223,7 +222,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, for (i = 0; i < frags; i++) { frag = &skb_shinfo(skb)->frags[i]; - pci_unmap_page(mdev->pdev, + dma_unmap_page(priv->ddev, (dma_addr_t) be64_to_cpu(data[i].addr), skb_frag_size(frag), PCI_DMA_TODEVICE); } @@ -241,7 +240,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, } if (tx_info->linear) { - pci_unmap_single(mdev->pdev, + dma_unmap_single(priv->ddev, (dma_addr_t) be64_to_cpu(data->addr), be32_to_cpu(data->byte_count), PCI_DMA_TODEVICE); @@ -253,7 +252,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv, if ((void *) data >= end) data = ring->buf; frag = &skb_shinfo(skb)->frags[i]; - pci_unmap_page(mdev->pdev, + dma_unmap_page(priv->ddev, (dma_addr_t) be64_to_cpu(data->addr), skb_frag_size(frag), PCI_DMA_TODEVICE); ++data; @@ -733,7 +732,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) /* Map fragments */ for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) { frag = &skb_shinfo(skb)->frags[i]; - dma = skb_frag_dma_map(&mdev->dev->pdev->dev, frag, + dma = skb_frag_dma_map(priv->ddev, frag, 0, skb_frag_size(frag), DMA_TO_DEVICE); data->addr = cpu_to_be64(dma); @@ -745,7 +744,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) /* Map linear part */ if (tx_info->linear) { - dma = pci_map_single(mdev->dev->pdev, skb->data + lso_header_size, + dma = dma_map_single(priv->ddev, skb->data + lso_header_size, skb_headlen(skb) - lso_header_size, PCI_DMA_TODEVICE); data->addr = cpu_to_be64(dma); data->lkey = cpu_to_be32(mdev->mr.key); diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index d60335f3c473..a5bb0b7d339a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -482,6 +482,7 @@ struct mlx4_en_priv { struct mlx4_en_stat_out_mbox hw_stats; int vids[128]; bool wol; + struct device *ddev; }; enum mlx4_en_wol { -- GitLab From 4ef2a435bea24330781cbfe910a05810f17079d2 Mon Sep 17 00:00:00 2001 From: Or Gerlitz Date: Tue, 6 Mar 2012 04:03:41 +0000 Subject: [PATCH 1467/1846] net/mlx4: fix sparse warnings on TX control flags, endianess Fix sparse warnings on incompatibility between the endianess of the ctrl_flags field of struct mlx4_en_priv to the srcrb_flags field of struct mlx4_wqe_ctrl_seg by changing the former to be __be32 instead of u32. Signed-off-by: Or Gerlitz Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index a5bb0b7d339a..8f4e655bd57b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -453,7 +453,7 @@ struct mlx4_en_priv { int base_qpn; struct mlx4_en_rss_map rss_map; - u32 ctrl_flags; + __be32 ctrl_flags; u32 flags; #define MLX4_EN_FLAG_PROMISC 0x1 #define MLX4_EN_FLAG_MC_PROMISC 0x2 -- GitLab From 966684d581c9c04202e6612a792e36ae7bc5fd59 Mon Sep 17 00:00:00 2001 From: Or Gerlitz Date: Tue, 6 Mar 2012 04:04:02 +0000 Subject: [PATCH 1468/1846] net/mlx4: fix sparse warnings on TX blue flame buffer The blue flame buffer is defined to be of type void __iomem * but was passed to mlx4_bf_copy which gets unsigned long * . This triggered sparse warning on different address spaces, fix that by changing mlx4_bf_copy first param to be of type void __iomem * . Signed-off-by: Or Gerlitz Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 008f0af5cc8b..17968244c399 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -584,7 +584,7 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb) return skb_tx_hash(dev, skb); } -static void mlx4_bf_copy(unsigned long *dst, unsigned long *src, unsigned bytecnt) +static void mlx4_bf_copy(void __iomem *dst, unsigned long *src, unsigned bytecnt) { __iowrite64_copy(dst, src, bytecnt / 8); } -- GitLab From 39b2c4ebb433acf751c28a59dde110767af24d23 Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Tue, 6 Mar 2012 04:04:07 +0000 Subject: [PATCH 1469/1846] net/mlx4: fix sparse warnings on wrong type for RSS keys The keys used for the hardware RSS topelitz hash are of type __be32 where the values provided by the driver are from array of u32, this triggered sparse warning on incorrect type in assignment as of different base types. Since these values are picked randomly, the fix is to transform the key to __be32 by executing cpu_to_be_32() Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index c881712b7492..9adbd53da525 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -910,7 +910,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) rss_context->flags = rss_mask; rss_context->hash_fn = MLX4_RSS_HASH_TOP; for (i = 0; i < 10; i++) - rss_context->rss_key[i] = rsskey[i]; + rss_context->rss_key[i] = cpu_to_be32(rsskey[i]); err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, &context, &rss_map->indir_qp, &rss_map->indir_state); -- GitLab From 2ab573c586446ebab9d7a3e340bd4ff8fc2c70d4 Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Tue, 6 Mar 2012 04:04:26 +0000 Subject: [PATCH 1470/1846] net/mlx4: fixing sparse warnings when copying mac, address to gid entry The mac should be written as __be64 the gid. The warning was because we changed the mac parameter, which is u64, by writing result of cpu_to_be64 into it. Fixing by using new variable of type __be64. Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/port.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 575839dba8a2..98e776261ead 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -79,13 +79,14 @@ static int mlx4_uc_steer_add(struct mlx4_dev *dev, u8 port, u64 mac, int *qpn) { struct mlx4_qp qp; u8 gid[16] = {0}; + __be64 be_mac; int err; qp.qpn = *qpn; mac &= 0xffffffffffffULL; - mac = cpu_to_be64(mac << 16); - memcpy(&gid[10], &mac, ETH_ALEN); + be_mac = cpu_to_be64(mac << 16); + memcpy(&gid[10], &be_mac, ETH_ALEN); gid[5] = port; err = mlx4_unicast_attach(dev, &qp, gid, 0, MLX4_PROT_ETH); @@ -100,11 +101,12 @@ static void mlx4_uc_steer_release(struct mlx4_dev *dev, u8 port, { struct mlx4_qp qp; u8 gid[16] = {0}; + __be64 be_mac; qp.qpn = qpn; mac &= 0xffffffffffffULL; - mac = cpu_to_be64(mac << 16); - memcpy(&gid[10], &mac, ETH_ALEN); + be_mac = cpu_to_be64(mac << 16); + memcpy(&gid[10], &be_mac, ETH_ALEN); gid[5] = port; mlx4_unicast_detach(dev, &qp, gid, MLX4_PROT_ETH); -- GitLab From 9a9a232a9295deb3b6b5f4ce4290a7d05ff061fa Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Tue, 6 Mar 2012 04:04:47 +0000 Subject: [PATCH 1471/1846] net/mlx4: fixing sparse warnings for not declared, functions The SET_PORT functions are implemented in port.c, which is part of mlx4_core, these functions are exported. The functions are in use by the mlx4_en module (were originally part of mlx4_en). Their declaration remained in mlx4_en module, moving the declaration to the right location. Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 4 ---- include/linux/mlx4/device.h | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index 8f4e655bd57b..9e2b911a1230 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -553,10 +553,6 @@ void mlx4_en_rx_irq(struct mlx4_cq *mcq); int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode); int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv); -int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, - u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); -int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, - u8 promisc); int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset); int mlx4_en_QUERY_PORT(struct mlx4_en_dev *mdev, u8 port); diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index aea61905499b..44d8144e9ae8 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h @@ -622,7 +622,10 @@ int mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac); int mlx4_get_eth_qp(struct mlx4_dev *dev, u8 port, u64 mac, int *qpn); void mlx4_put_eth_qp(struct mlx4_dev *dev, u8 port, u64 mac, int qpn); void mlx4_set_stats_bitmap(struct mlx4_dev *dev, u64 *stats_bitmap); - +int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, + u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); +int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, + u8 promisc); int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index); -- GitLab From be6736ba1fb67b6b8b56c5c912fc269309ca86fc Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Tue, 6 Mar 2012 04:04:54 +0000 Subject: [PATCH 1472/1846] net/mlx4: remove unused functions Removing functions that are no longer in use, but still exist Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/fw.c | 10 ---- drivers/net/ethernet/mellanox/mlx4/mr.c | 75 ------------------------- 2 files changed, 85 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c index 9ea7cabcaf3c..2a02ba522e60 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c @@ -685,16 +685,6 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, return err; } -int mlx4_QUERY_PORT(struct mlx4_dev *dev, void *ptr, u8 port) -{ - struct mlx4_cmd_mailbox *outbox = ptr; - - return mlx4_cmd_box(dev, 0, outbox->dma, port, 0, - MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B, - MLX4_CMD_WRAPPED); -} -EXPORT_SYMBOL_GPL(mlx4_QUERY_PORT); - int mlx4_map_cmd(struct mlx4_dev *dev, u16 op, struct mlx4_icm *icm, u64 virt) { struct mlx4_cmd_mailbox *mailbox; diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c index 25a80d71fb2a..9f693e120025 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -304,29 +304,6 @@ static int mlx4_HW2SW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); } -int mlx4_mr_reserve_range(struct mlx4_dev *dev, int cnt, int align, - u32 *base_mridx) -{ - struct mlx4_priv *priv = mlx4_priv(dev); - u32 mridx; - - mridx = mlx4_bitmap_alloc_range(&priv->mr_table.mpt_bitmap, cnt, align); - if (mridx == -1) - return -ENOMEM; - - *base_mridx = mridx; - return 0; - -} -EXPORT_SYMBOL_GPL(mlx4_mr_reserve_range); - -void mlx4_mr_release_range(struct mlx4_dev *dev, u32 base_mridx, int cnt) -{ - struct mlx4_priv *priv = mlx4_priv(dev); - mlx4_bitmap_free_range(&priv->mr_table.mpt_bitmap, base_mridx, cnt); -} -EXPORT_SYMBOL_GPL(mlx4_mr_release_range); - int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, u64 iova, u64 size, u32 access, int npages, int page_shift, struct mlx4_mr *mr) @@ -852,46 +829,6 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, } EXPORT_SYMBOL_GPL(mlx4_fmr_alloc); -int mlx4_fmr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, - u32 pd, u32 access, int max_pages, - int max_maps, u8 page_shift, struct mlx4_fmr *fmr) -{ - struct mlx4_priv *priv = mlx4_priv(dev); - int err = -ENOMEM; - - if (page_shift < (ffs(dev->caps.page_size_cap) - 1) || page_shift >= 32) - return -EINVAL; - - /* All MTTs must fit in the same page */ - if (max_pages * sizeof *fmr->mtts > PAGE_SIZE) - return -EINVAL; - - fmr->page_shift = page_shift; - fmr->max_pages = max_pages; - fmr->max_maps = max_maps; - fmr->maps = 0; - - err = mlx4_mr_alloc_reserved(dev, mridx, pd, 0, 0, access, max_pages, - page_shift, &fmr->mr); - if (err) - return err; - - fmr->mtts = mlx4_table_find(&priv->mr_table.mtt_table, - fmr->mr.mtt.offset, - &fmr->dma_handle); - if (!fmr->mtts) { - err = -ENOMEM; - goto err_free; - } - - return 0; - -err_free: - mlx4_mr_free_reserved(dev, &fmr->mr); - return err; -} -EXPORT_SYMBOL_GPL(mlx4_fmr_alloc_reserved); - int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr) { struct mlx4_priv *priv = mlx4_priv(dev); @@ -954,18 +891,6 @@ int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr) } EXPORT_SYMBOL_GPL(mlx4_fmr_free); -int mlx4_fmr_free_reserved(struct mlx4_dev *dev, struct mlx4_fmr *fmr) -{ - if (fmr->maps) - return -EBUSY; - - mlx4_mr_free_reserved(dev, &fmr->mr); - fmr->mr.enabled = MLX4_MR_DISABLED; - - return 0; -} -EXPORT_SYMBOL_GPL(mlx4_fmr_free_reserved); - int mlx4_SYNC_TPT(struct mlx4_dev *dev) { return mlx4_cmd(dev, 0, 0, 0, MLX4_CMD_SYNC_TPT, 1000, -- GitLab From 66431a7d4570dbafb5e25c85607779ffa9c4a4bc Mon Sep 17 00:00:00 2001 From: Yevgeny Petrilin Date: Tue, 6 Mar 2012 04:05:02 +0000 Subject: [PATCH 1473/1846] net/mlx4: defining functions as static Fixing sparse warnings, the 2 functions are only used in same file. Defining them as static and not exporting them. Signed-off-by: Yevgeny Petrilin Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/mr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c index 9f693e120025..32e2b6616f3d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -304,7 +304,7 @@ static int mlx4_HW2SW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); } -int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, +static int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, u64 iova, u64 size, u32 access, int npages, int page_shift, struct mlx4_mr *mr) { @@ -317,7 +317,6 @@ int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, return mlx4_mtt_init(dev, npages, page_shift, &mr->mtt); } -EXPORT_SYMBOL_GPL(mlx4_mr_alloc_reserved); static int mlx4_WRITE_MTT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, @@ -434,7 +433,7 @@ int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access, } EXPORT_SYMBOL_GPL(mlx4_mr_alloc); -void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) +static void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) { int err; @@ -449,7 +448,6 @@ void mlx4_mr_free_reserved(struct mlx4_dev *dev, struct mlx4_mr *mr) } mlx4_mtt_cleanup(dev, &mr->mtt); } -EXPORT_SYMBOL_GPL(mlx4_mr_free_reserved); void mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr) { -- GitLab From 95f050bf7f64be5168ae2e2c715bb0b0ded141d1 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 6 Mar 2012 16:12:15 -0500 Subject: [PATCH 1474/1846] net: Use bool for return value of dev_valid_name(). Signed-off-by: David S. Miller --- include/linux/netdevice.h | 2 +- net/core/dev.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 4d279c5287f8..a89933bc4f2f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2122,7 +2122,7 @@ extern int netdev_rx_handler_register(struct net_device *dev, void *rx_handler_data); extern void netdev_rx_handler_unregister(struct net_device *dev); -extern int dev_valid_name(const char *name); +extern bool dev_valid_name(const char *name); extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); extern int dev_ethtool(struct net *net, struct ifreq *); extern unsigned dev_get_flags(const struct net_device *); diff --git a/net/core/dev.c b/net/core/dev.c index 5ef3b65c3687..0090809af7bd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -848,21 +848,21 @@ EXPORT_SYMBOL(dev_get_by_flags_rcu); * to allow sysfs to work. We also disallow any kind of * whitespace. */ -int dev_valid_name(const char *name) +bool dev_valid_name(const char *name) { if (*name == '\0') - return 0; + return false; if (strlen(name) >= IFNAMSIZ) - return 0; + return false; if (!strcmp(name, ".") || !strcmp(name, "..")) - return 0; + return false; while (*name) { if (*name == '/' || isspace(*name)) - return 0; + return false; name++; } - return 1; + return true; } EXPORT_SYMBOL(dev_valid_name); -- GitLab From 8dfc2b45ffc722c4291f24f1f40c64e448b9b5b4 Mon Sep 17 00:00:00 2001 From: Duc Dang Date: Mon, 5 Mar 2012 00:57:42 +0000 Subject: [PATCH 1475/1846] powerpc/44x: Add new compatible value for EMAC node of APM821XX dts file. This compatible value will be used to distinguish some special features of APM821XX EMAC: no half duplex mode support, configuring jumbo frame. Signed-off-by: Duc Dang Signed-off-by: David S. Miller --- arch/powerpc/boot/dts/bluestone.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/boot/dts/bluestone.dts b/arch/powerpc/boot/dts/bluestone.dts index 2a56a0dbd1f7..74876f737407 100644 --- a/arch/powerpc/boot/dts/bluestone.dts +++ b/arch/powerpc/boot/dts/bluestone.dts @@ -222,7 +222,7 @@ EMAC0: ethernet@ef600c00 { device_type = "network"; - compatible = "ibm,emac4sync"; + compatible = "ibm,emac-apm821xx", "ibm,emac4sync"; interrupt-parent = <&EMAC0>; interrupts = <0x0 0x1>; #interrupt-cells = <1>; -- GitLab From ae5d33723e325392c48bc0ff481d9ec8d646a0ed Mon Sep 17 00:00:00 2001 From: Duc Dang Date: Mon, 5 Mar 2012 00:58:22 +0000 Subject: [PATCH 1476/1846] powerpc/44x: Add more changes for APM821XX EMAC driver This patch includes: Configure EMAC PHY clock source (clock from PHY or internal clock). Do not advertise PHY half duplex capability as APM821XX EMAC does not support half duplex mode. Add changes to support configuring jumbo frame for APM821XX EMAC. [ Fix coding style -DaveM ] Signed-off-by: Duc Dang Signed-off-by: David S. Miller --- drivers/net/ethernet/ibm/emac/core.c | 29 +++++++++++++++++++++++++++- drivers/net/ethernet/ibm/emac/core.h | 13 +++++++++++-- drivers/net/ethernet/ibm/emac/emac.h | 2 ++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index dac7ffb4eaf1..a0fe6e3fce61 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device *ndev) else if (!netdev_mc_empty(ndev)) r |= EMAC_RMR_MAE; + if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) { + r &= ~EMAC4_RMR_MJS_MASK; + r |= EMAC4_RMR_MJS(ndev->mtu); + } + return r; } @@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu) int rx_sync_size = emac_rx_sync_size(new_mtu); int rx_skb_size = emac_rx_skb_size(new_mtu); int i, ret = 0; + int mr1_jumbo_bit_change = 0; mutex_lock(&dev->link_lock); emac_netif_stop(dev); @@ -1013,7 +1019,15 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu) } skip: /* Check if we need to change "Jumbo" bit in MR1 */ - if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) { + if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) { + mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) || + (dev->ndev->mtu > ETH_DATA_LEN); + } else { + mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^ + (dev->ndev->mtu > ETH_DATA_LEN); + } + + if (mr1_jumbo_bit_change) { /* This is to prevent starting RX channel in emac_rx_enable() */ set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags); @@ -2471,6 +2485,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev) /* Disable any PHY features not supported by the platform */ dev->phy.def->features &= ~dev->phy_feat_exc; + dev->phy.features &= ~dev->phy_feat_exc; /* Setup initial link parameters */ if (dev->phy.features & SUPPORTED_Autoneg) { @@ -2568,6 +2583,11 @@ static int __devinit emac_init_config(struct emac_instance *dev) if (of_device_is_compatible(np, "ibm,emac-405ex") || of_device_is_compatible(np, "ibm,emac-405exr")) dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX; + if (of_device_is_compatible(np, "ibm,emac-apm821xx")) { + dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE | + EMAC_FTR_APM821XX_NO_HALF_DUPLEX | + EMAC_FTR_460EX_PHY_CLK_FIX); + } } else if (of_device_is_compatible(np, "ibm,emac4")) { dev->features |= EMAC_FTR_EMAC4; if (of_device_is_compatible(np, "ibm,emac-440gx")) @@ -2816,6 +2836,13 @@ static int __devinit emac_probe(struct platform_device *ofdev) dev->stop_timeout = STOP_TIMEOUT_100; INIT_DELAYED_WORK(&dev->link_work, emac_link_timer); + /* Some SoCs like APM821xx does not support Half Duplex mode. */ + if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX)) { + dev->phy_feat_exc = (SUPPORTED_1000baseT_Half | + SUPPORTED_100baseT_Half | + SUPPORTED_10baseT_Half); + } + /* Find PHY if any */ err = emac_init_phy(dev); if (err != 0) diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h index bade29690c71..70074792bdef 100644 --- a/drivers/net/ethernet/ibm/emac/core.h +++ b/drivers/net/ethernet/ibm/emac/core.h @@ -325,7 +325,14 @@ struct emac_instance { * Set if we need phy clock workaround for 460ex or 460gt */ #define EMAC_FTR_460EX_PHY_CLK_FIX 0x00000400 - +/* + * APM821xx requires Jumbo frame size set explicitly + */ +#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE 0x00000800 +/* + * APM821xx does not support Half Duplex mode + */ +#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX 0x00001000 /* Right now, we don't quite handle the always/possible masks on the * most optimal way as we don't have a way to say something like @@ -353,7 +360,9 @@ enum { EMAC_FTR_NO_FLOW_CONTROL_40x | #endif EMAC_FTR_460EX_PHY_CLK_FIX | - EMAC_FTR_440EP_PHY_CLK_FIX, + EMAC_FTR_440EP_PHY_CLK_FIX | + EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE | + EMAC_FTR_APM821XX_NO_HALF_DUPLEX, }; static inline int emac_has_feature(struct emac_instance *dev, diff --git a/drivers/net/ethernet/ibm/emac/emac.h b/drivers/net/ethernet/ibm/emac/emac.h index b44bd243fb58..5afcc27ceebb 100644 --- a/drivers/net/ethernet/ibm/emac/emac.h +++ b/drivers/net/ethernet/ibm/emac/emac.h @@ -212,6 +212,8 @@ struct emac_regs { #define EMAC4_RMR_RFAF_64_1024 0x00000006 #define EMAC4_RMR_RFAF_128_2048 0x00000007 #define EMAC4_RMR_BASE EMAC4_RMR_RFAF_128_2048 +#define EMAC4_RMR_MJS_MASK 0x0001fff8 +#define EMAC4_RMR_MJS(s) (((s) << 3) & EMAC4_RMR_MJS_MASK) /* EMACx_ISR & EMACx_ISER */ #define EMAC4_ISR_TXPE 0x20000000 -- GitLab From c4762507342dabbe6896ef288df0851ac7dd63d6 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Tue, 6 Mar 2012 23:39:50 -0300 Subject: [PATCH 1477/1846] Bluetooth: Fix coding style in mgmt.h Align struct definition in a proper way. Signed-off-by: Gustavo F. Padovan --- include/net/bluetooth/mgmt.h | 157 +++++++++++++++++------------------ 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 0ca3519e08bd..61953dc848a6 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -44,37 +44,37 @@ #define MGMT_STATUS_INVALID_INDEX 0x11 struct mgmt_hdr { - __le16 opcode; - __le16 index; - __le16 len; + __le16 opcode; + __le16 index; + __le16 len; } __packed; struct mgmt_addr_info { - bdaddr_t bdaddr; - __u8 type; + bdaddr_t bdaddr; + __u8 type; } __packed; #define MGMT_ADDR_INFO_SIZE 7 #define MGMT_OP_READ_VERSION 0x0001 #define MGMT_READ_VERSION_SIZE 0 struct mgmt_rp_read_version { - __u8 version; - __le16 revision; + __u8 version; + __le16 revision; } __packed; #define MGMT_OP_READ_COMMANDS 0x0002 #define MGMT_READ_COMMANDS_SIZE 0 struct mgmt_rp_read_commands { - __le16 num_commands; - __le16 num_events; - __le16 opcodes[0]; + __le16 num_commands; + __le16 num_events; + __le16 opcodes[0]; } __packed; #define MGMT_OP_READ_INDEX_LIST 0x0003 #define MGMT_READ_INDEX_LIST_SIZE 0 struct mgmt_rp_read_index_list { - __le16 num_controllers; - __le16 index[0]; + __le16 num_controllers; + __le16 index[0]; } __packed; /* Reserve one extra byte for names in management messages so that they @@ -96,14 +96,14 @@ struct mgmt_rp_read_index_list { #define MGMT_OP_READ_INFO 0x0004 #define MGMT_READ_INFO_SIZE 0 struct mgmt_rp_read_info { - bdaddr_t bdaddr; - __u8 version; - __le16 manufacturer; - __le32 supported_settings; - __le32 current_settings; - __u8 dev_class[3]; - __u8 name[MGMT_MAX_NAME_LENGTH]; - __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; + bdaddr_t bdaddr; + __u8 version; + __le16 manufacturer; + __le32 supported_settings; + __le32 current_settings; + __u8 dev_class[3]; + __u8 name[MGMT_MAX_NAME_LENGTH]; + __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; } __packed; struct mgmt_mode { @@ -116,8 +116,8 @@ struct mgmt_mode { #define MGMT_OP_SET_DISCOVERABLE 0x0006 struct mgmt_cp_set_discoverable { - __u8 val; - __u16 timeout; + __u8 val; + __u16 timeout; } __packed; #define MGMT_SET_DISCOVERABLE_SIZE 3 @@ -134,63 +134,62 @@ struct mgmt_cp_set_discoverable { #define MGMT_OP_SET_HS 0x000C #define MGMT_OP_SET_LE 0x000D - #define MGMT_OP_SET_DEV_CLASS 0x000E struct mgmt_cp_set_dev_class { - __u8 major; - __u8 minor; + __u8 major; + __u8 minor; } __packed; #define MGMT_SET_DEV_CLASS_SIZE 2 #define MGMT_OP_SET_LOCAL_NAME 0x000F struct mgmt_cp_set_local_name { - __u8 name[MGMT_MAX_NAME_LENGTH]; - __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; + __u8 name[MGMT_MAX_NAME_LENGTH]; + __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; } __packed; #define MGMT_SET_LOCAL_NAME_SIZE 260 #define MGMT_OP_ADD_UUID 0x0010 struct mgmt_cp_add_uuid { - __u8 uuid[16]; - __u8 svc_hint; + __u8 uuid[16]; + __u8 svc_hint; } __packed; #define MGMT_ADD_UUID_SIZE 17 #define MGMT_OP_REMOVE_UUID 0x0011 struct mgmt_cp_remove_uuid { - __u8 uuid[16]; + __u8 uuid[16]; } __packed; #define MGMT_REMOVE_UUID_SIZE 16 struct mgmt_link_key_info { struct mgmt_addr_info addr; - u8 type; - u8 val[16]; - u8 pin_len; + u8 type; + u8 val[16]; + u8 pin_len; } __packed; #define MGMT_OP_LOAD_LINK_KEYS 0x0012 struct mgmt_cp_load_link_keys { - __u8 debug_keys; - __le16 key_count; - struct mgmt_link_key_info keys[0]; + __u8 debug_keys; + __le16 key_count; + struct mgmt_link_key_info keys[0]; } __packed; #define MGMT_LOAD_LINK_KEYS_SIZE 3 struct mgmt_ltk_info { struct mgmt_addr_info addr; - __u8 authenticated; - __u8 master; - __u8 enc_size; - __le16 ediv; - __u8 rand[8]; - __u8 val[16]; + __u8 authenticated; + __u8 master; + __u8 enc_size; + __le16 ediv; + __u8 rand[8]; + __u8 val[16]; } __packed; #define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013 struct mgmt_cp_load_long_term_keys { - __le16 key_count; - struct mgmt_ltk_info keys[0]; + __le16 key_count; + struct mgmt_ltk_info keys[0]; } __packed; #define MGMT_LOAD_LONG_TERM_KEYS_SIZE 2 @@ -213,8 +212,8 @@ struct mgmt_rp_get_connections { #define MGMT_OP_PIN_CODE_REPLY 0x0016 struct mgmt_cp_pin_code_reply { struct mgmt_addr_info addr; - __u8 pin_len; - __u8 pin_code[16]; + __u8 pin_len; + __u8 pin_code[16]; } __packed; #define MGMT_PIN_CODE_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 17) struct mgmt_rp_pin_code_reply { @@ -229,14 +228,14 @@ struct mgmt_cp_pin_code_neg_reply { #define MGMT_OP_SET_IO_CAPABILITY 0x0018 struct mgmt_cp_set_io_capability { - __u8 io_capability; + __u8 io_capability; } __packed; #define MGMT_SET_IO_CAPABILITY_SIZE 1 #define MGMT_OP_PAIR_DEVICE 0x0019 struct mgmt_cp_pair_device { struct mgmt_addr_info addr; - __u8 io_cap; + __u8 io_cap; } __packed; #define MGMT_PAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) struct mgmt_rp_pair_device { @@ -274,7 +273,7 @@ struct mgmt_cp_user_confirm_neg_reply { #define MGMT_OP_USER_PASSKEY_REPLY 0x001E struct mgmt_cp_user_passkey_reply { struct mgmt_addr_info addr; - __le32 passkey; + __le32 passkey; } __packed; #define MGMT_USER_PASSKEY_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 4) struct mgmt_rp_user_passkey_reply { @@ -290,15 +289,15 @@ struct mgmt_cp_user_passkey_neg_reply { #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 #define MGMT_READ_LOCAL_OOB_DATA_SIZE 0 struct mgmt_rp_read_local_oob_data { - __u8 hash[16]; - __u8 randomizer[16]; + __u8 hash[16]; + __u8 randomizer[16]; } __packed; #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021 struct mgmt_cp_add_remote_oob_data { struct mgmt_addr_info addr; - __u8 hash[16]; - __u8 randomizer[16]; + __u8 hash[16]; + __u8 randomizer[16]; } __packed; #define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) @@ -323,7 +322,7 @@ struct mgmt_cp_stop_discovery { #define MGMT_OP_CONFIRM_NAME 0x0025 struct mgmt_cp_confirm_name { struct mgmt_addr_info addr; - __u8 name_known; + __u8 name_known; } __packed; #define MGMT_CONFIRM_NAME_SIZE (MGMT_ADDR_INFO_SIZE + 1) struct mgmt_rp_confirm_name { @@ -344,20 +343,20 @@ struct mgmt_cp_unblock_device { #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { - __le16 opcode; - __u8 status; - __u8 data[0]; + __le16 opcode; + __u8 status; + __u8 data[0]; } __packed; #define MGMT_EV_CMD_STATUS 0x0002 struct mgmt_ev_cmd_status { - __le16 opcode; - __u8 status; + __le16 opcode; + __u8 status; } __packed; #define MGMT_EV_CONTROLLER_ERROR 0x0003 struct mgmt_ev_controller_error { - __u8 error_code; + __u8 error_code; } __packed; #define MGMT_EV_INDEX_ADDED 0x0004 @@ -368,33 +367,33 @@ struct mgmt_ev_controller_error { #define MGMT_EV_CLASS_OF_DEV_CHANGED 0x0007 struct mgmt_ev_class_of_dev_changed { - __u8 dev_class[3]; + __u8 dev_class[3]; }; #define MGMT_EV_LOCAL_NAME_CHANGED 0x0008 struct mgmt_ev_local_name_changed { - __u8 name[MGMT_MAX_NAME_LENGTH]; - __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; + __u8 name[MGMT_MAX_NAME_LENGTH]; + __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; } __packed; #define MGMT_EV_NEW_LINK_KEY 0x0009 struct mgmt_ev_new_link_key { - __u8 store_hint; + __u8 store_hint; struct mgmt_link_key_info key; } __packed; #define MGMT_EV_NEW_LONG_TERM_KEY 0x000A struct mgmt_ev_new_long_term_key { - __u8 store_hint; + __u8 store_hint; struct mgmt_ltk_info key; } __packed; #define MGMT_EV_DEVICE_CONNECTED 0x000B struct mgmt_ev_device_connected { struct mgmt_addr_info addr; - __le32 flags; - __le16 eir_len; - __u8 eir[0]; + __le32 flags; + __le16 eir_len; + __u8 eir[0]; } __packed; #define MGMT_EV_DEVICE_DISCONNECTED 0x000C @@ -402,20 +401,20 @@ struct mgmt_ev_device_connected { #define MGMT_EV_CONNECT_FAILED 0x000D struct mgmt_ev_connect_failed { struct mgmt_addr_info addr; - __u8 status; + __u8 status; } __packed; #define MGMT_EV_PIN_CODE_REQUEST 0x000E struct mgmt_ev_pin_code_request { struct mgmt_addr_info addr; - __u8 secure; + __u8 secure; } __packed; #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F struct mgmt_ev_user_confirm_request { struct mgmt_addr_info addr; - __u8 confirm_hint; - __le32 value; + __u8 confirm_hint; + __le32 value; } __packed; #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010 @@ -426,7 +425,7 @@ struct mgmt_ev_user_passkey_request { #define MGMT_EV_AUTH_FAILED 0x0011 struct mgmt_ev_auth_failed { struct mgmt_addr_info addr; - __u8 status; + __u8 status; } __packed; #define MGMT_DEV_FOUND_CONFIRM_NAME 0x01 @@ -435,16 +434,16 @@ struct mgmt_ev_auth_failed { #define MGMT_EV_DEVICE_FOUND 0x0012 struct mgmt_ev_device_found { struct mgmt_addr_info addr; - __s8 rssi; - __u8 flags[4]; - __le16 eir_len; - __u8 eir[0]; + __s8 rssi; + __u8 flags[4]; + __le16 eir_len; + __u8 eir[0]; } __packed; #define MGMT_EV_DISCOVERING 0x0013 struct mgmt_ev_discovering { - __u8 type; - __u8 discovering; + __u8 type; + __u8 discovering; } __packed; #define MGMT_EV_DEVICE_BLOCKED 0x0014 -- GitLab From 044e1247344d7ff0dbdb1e7edd80d859a8c19aa6 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Tue, 6 Mar 2012 23:45:42 -0300 Subject: [PATCH 1478/1846] Bluetooth: Use correct type for userspace exported structs It should be __u8 instead of u8. Signed-off-by: Gustavo F. Padovan --- include/net/bluetooth/mgmt.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 61953dc848a6..ffc1377e092e 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h @@ -163,9 +163,9 @@ struct mgmt_cp_remove_uuid { struct mgmt_link_key_info { struct mgmt_addr_info addr; - u8 type; - u8 val[16]; - u8 pin_len; + __u8 type; + __u8 val[16]; + __u8 pin_len; } __packed; #define MGMT_OP_LOAD_LINK_KEYS 0x0012 -- GitLab From f64b993f44c3a5fe709b276ac5652d006afe9d33 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Tue, 6 Mar 2012 23:48:33 -0300 Subject: [PATCH 1479/1846] Bluetooth: Fix coding style in all .h files Proper align the struct definitions. Signed-off-by: Gustavo F. Padovan --- include/net/bluetooth/hci.h | 8 ++--- include/net/bluetooth/hci_core.h | 10 +++--- include/net/bluetooth/hci_mon.h | 8 ++--- include/net/bluetooth/l2cap.h | 52 ++++++++++++++++---------------- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 3acbebfb22b9..344b0f972828 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -693,8 +693,8 @@ struct hci_cp_host_buffer_size { #define HCI_OP_WRITE_EIR 0x0c52 struct hci_cp_write_eir { - __u8 fec; - __u8 data[HCI_MAX_EIR_LENGTH]; + __u8 fec; + __u8 data[HCI_MAX_EIR_LENGTH]; } __packed; #define HCI_OP_READ_SSP_MODE 0x0c55 @@ -725,8 +725,8 @@ struct hci_rp_read_flow_control_mode { #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d struct hci_cp_write_le_host_supported { - __u8 le; - __u8 simul; + __u8 le; + __u8 simul; } __packed; #define HCI_OP_READ_LOCAL_VERSION 0x1001 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 25cb0a15b579..cbbf68a8510d 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -57,7 +57,7 @@ struct inquiry_entry { }; struct discovery_state { - int type; + int type; enum { DISCOVERY_STOPPED, DISCOVERY_STARTING, @@ -65,10 +65,10 @@ struct discovery_state { DISCOVERY_RESOLVING, DISCOVERY_STOPPING, } state; - struct list_head all; /* All devices found during inquiry */ - struct list_head unknown; /* Name state not known */ - struct list_head resolve; /* Name needs to be resolved */ - __u32 timestamp; + struct list_head all; /* All devices found during inquiry */ + struct list_head unknown; /* Name state not known */ + struct list_head resolve; /* Name needs to be resolved */ + __u32 timestamp; }; struct hci_conn_hash { diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h index 07a25c92502c..77d1e5764185 100644 --- a/include/net/bluetooth/hci_mon.h +++ b/include/net/bluetooth/hci_mon.h @@ -41,10 +41,10 @@ struct hci_mon_hdr { #define HCI_MON_SCO_RX_PKT 7 struct hci_mon_new_index { - __u8 type; - __u8 bus; - bdaddr_t bdaddr; - char name[8]; + __u8 type; + __u8 bus; + bdaddr_t bdaddr; + char name[8]; } __packed; #define HCI_MON_NEW_INDEX_SIZE 16 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index e4669d0230c5..9b242c6bf55b 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -492,16 +492,16 @@ struct l2cap_chan { struct sk_buff_head srej_q; struct list_head srej_l; - struct list_head list; - struct list_head global_l; + struct list_head list; + struct list_head global_l; - void *data; - struct l2cap_ops *ops; + void *data; + struct l2cap_ops *ops; struct mutex lock; }; struct l2cap_ops { - char *name; + char *name; struct l2cap_chan *(*new_connection) (void *data); int (*recv) (void *data, struct sk_buff *skb); @@ -513,35 +513,35 @@ struct l2cap_ops { }; struct l2cap_conn { - struct hci_conn *hcon; - struct hci_chan *hchan; + struct hci_conn *hcon; + struct hci_chan *hchan; - bdaddr_t *dst; - bdaddr_t *src; + bdaddr_t *dst; + bdaddr_t *src; - unsigned int mtu; + unsigned int mtu; - __u32 feat_mask; - __u8 fixed_chan_mask; + __u32 feat_mask; + __u8 fixed_chan_mask; - __u8 info_state; - __u8 info_ident; + __u8 info_state; + __u8 info_ident; - struct delayed_work info_timer; + struct delayed_work info_timer; - spinlock_t lock; + spinlock_t lock; - struct sk_buff *rx_skb; - __u32 rx_len; - __u8 tx_ident; + struct sk_buff *rx_skb; + __u32 rx_len; + __u8 tx_ident; - __u8 disc_reason; + __u8 disc_reason; - struct delayed_work security_timer; - struct smp_chan *smp_chan; + struct delayed_work security_timer; + struct smp_chan *smp_chan; - struct list_head chan_l; - struct mutex chan_lock; + struct list_head chan_l; + struct mutex chan_lock; }; #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 @@ -556,9 +556,9 @@ struct l2cap_conn { #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) struct l2cap_pinfo { - struct bt_sock bt; + struct bt_sock bt; struct l2cap_chan *chan; - struct sk_buff *rx_busy_skb; + struct sk_buff *rx_busy_skb; }; enum { -- GitLab From 1e9a905d9afd289bf19f02092a56660c2bcc50db Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Tue, 6 Mar 2012 15:03:59 +0530 Subject: [PATCH 1480/1846] ath6kl: Add provision to define suspend policy in disconnected state. It gives flexibility to the user to define suspend policy when the suspend mode is set to WOW and the device is in disconnected state at the time of suspend. New module parameter wow_mode is added to get the choice from the user. This parameter is valid only if the module parameter suspend_mode is set to WOW. To force WOW in connected state and cut power in disconnected state: suspend_mode=0x3 wow_mode=0x1 To force WOW in connected state and deep sleep in disconnected state (this is also the default wow_mode): suspend_mode=0x3 wow_mode=0x2 If there is no value specified to wow_mode during insmod, deep sleep mode will be tried in the disconnected state. kvalo: clarified commit log Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 5 ++--- drivers/net/wireless/ath/ath6kl/core.c | 9 +++++++++ drivers/net/wireless/ath/ath6kl/core.h | 1 + drivers/net/wireless/ath/ath6kl/sdio.c | 18 +++++++++++++----- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 9abc7a6a69b1..528529406e49 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2046,10 +2046,9 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, ath6kl_tx_data_cleanup(ar); ret = ath6kl_wow_suspend(ar, wow); - if (ret) { - ath6kl_err("wow suspend failed: %d\n", ret); + if (ret) return ret; - } + ar->state = ATH6KL_STATE_WOW; break; diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 84dd9786622f..bc3a41447b8e 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -27,12 +27,14 @@ unsigned int debug_mask; static unsigned int suspend_mode; +static unsigned int wow_mode; static unsigned int uart_debug; static unsigned int ath6kl_p2p; static unsigned int testmode; module_param(debug_mask, uint, 0644); module_param(suspend_mode, uint, 0644); +module_param(wow_mode, uint, 0644); module_param(uart_debug, uint, 0644); module_param(ath6kl_p2p, uint, 0644); module_param(testmode, uint, 0644); @@ -119,6 +121,13 @@ int ath6kl_core_init(struct ath6kl *ar) else ar->suspend_mode = 0; + if (suspend_mode == WLAN_POWER_STATE_WOW && + (wow_mode == WLAN_POWER_STATE_CUT_PWR || + wow_mode == WLAN_POWER_STATE_DEEP_SLEEP)) + ar->wow_suspend_mode = wow_mode; + else + ar->wow_suspend_mode = 0; + if (uart_debug) ar->conf_flags |= ATH6KL_CONF_UART_DEBUG; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index b6bdece63361..b9d810f32006 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -636,6 +636,7 @@ struct ath6kl { u16 conf_flags; u16 suspend_mode; + u16 wow_suspend_mode; wait_queue_head_t event_wq; struct ath6kl_mbox_info mbox_info; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index e2f42a133952..9b6282a14225 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -836,6 +836,7 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct sdio_func *func = ar_sdio->func; mmc_pm_flag_t flags; + bool try_deepsleep = false; int ret; if (ar->state == ATH6KL_STATE_SCHED_SCAN) { @@ -862,14 +863,21 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) goto cut_pwr; ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_WOW, wow); - if (ret) - goto cut_pwr; - - return 0; + if (ret && ret != -ENOTCONN) + ath6kl_err("wow suspend failed: %d\n", ret); + + if (ret && (!ar->wow_suspend_mode || + ar->wow_suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP)) + try_deepsleep = true; + else if (ret && + ar->wow_suspend_mode == WLAN_POWER_STATE_CUT_PWR) + goto cut_pwr; + if (!ret) + return 0; } if (ar->suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP || - !ar->suspend_mode) { + !ar->suspend_mode || try_deepsleep) { flags = sdio_get_host_pm_caps(func); if (!(flags & MMC_PM_KEEP_POWER)) -- GitLab From 390a8c8fae2e7072579198414e631984a61c485e Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Wed, 7 Mar 2012 11:35:04 +0530 Subject: [PATCH 1481/1846] ath6kl: Check wow state before sending control and data pkt Below two scenarios are taken care in this patch which helped to fix the firmware crash during wow suspend/resume. * TX operation (ctrl tx and data tx) has to be controlled based on suspend state. i.e, with respect to WOW mode, control packets are allowed to send from the host until the suspend state goes ATH6KL_STATE_WOW and the data packets are allowed until WOW suspend operation starts. * Similarly, wow resume is NOT allowed if WOW suspend is in progress. Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 30 +++++++++++++++++++--- drivers/net/wireless/ath/ath6kl/core.h | 2 ++ drivers/net/wireless/ath/ath6kl/sdio.c | 7 +++++ drivers/net/wireless/ath/ath6kl/txrx.c | 8 ++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 528529406e49..d877a9766b40 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1948,6 +1948,10 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) if (ret) return ret; + netif_stop_queue(vif->ndev); + + ar->state = ATH6KL_STATE_SUSPENDING; + /* Setup own IP addr for ARP agent. */ in_dev = __in_dev_get_rtnl(vif->ndev); if (!in_dev) @@ -2026,15 +2030,29 @@ static int ath6kl_wow_resume(struct ath6kl *ar) if (!vif) return -EIO; + ar->state = ATH6KL_STATE_RESUMING; + ret = ath6kl_wmi_set_host_sleep_mode_cmd(ar->wmi, vif->fw_vif_idx, ATH6KL_HOST_MODE_AWAKE); - return ret; + if (ret) { + ath6kl_warn("Failed to configure host sleep mode for " + "wow resume: %d\n", ret); + ar->state = ATH6KL_STATE_WOW; + return ret; + } + + ar->state = ATH6KL_STATE_ON; + + netif_wake_queue(vif->ndev); + + return 0; } int ath6kl_cfg80211_suspend(struct ath6kl *ar, enum ath6kl_cfg_suspend_mode mode, struct cfg80211_wowlan *wow) { + enum ath6kl_state prev_state; int ret; switch (mode) { @@ -2045,9 +2063,13 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar, /* Flush all non control pkts in TX path */ ath6kl_tx_data_cleanup(ar); + prev_state = ar->state; + ret = ath6kl_wow_suspend(ar, wow); - if (ret) + if (ret) { + ar->state = prev_state; return ret; + } ar->state = ATH6KL_STATE_WOW; break; @@ -2120,7 +2142,6 @@ int ath6kl_cfg80211_resume(struct ath6kl *ar) return ret; } - ar->state = ATH6KL_STATE_ON; break; case ATH6KL_STATE_DEEPSLEEP: @@ -2194,6 +2215,9 @@ static int __ath6kl_cfg80211_resume(struct wiphy *wiphy) */ void ath6kl_check_wow_status(struct ath6kl *ar) { + if (ar->state == ATH6KL_STATE_SUSPENDING) + return; + if (ar->state == ATH6KL_STATE_WOW) ath6kl_cfg80211_resume(ar); } diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index b9d810f32006..31f13d7a0430 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -537,6 +537,8 @@ enum ath6kl_dev_state { enum ath6kl_state { ATH6KL_STATE_OFF, ATH6KL_STATE_ON, + ATH6KL_STATE_SUSPENDING, + ATH6KL_STATE_RESUMING, ATH6KL_STATE_DEEPSLEEP, ATH6KL_STATE_CUTPOWER, ATH6KL_STATE_WOW, diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 9b6282a14225..5b36086a56cf 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -932,8 +932,15 @@ static int ath6kl_sdio_resume(struct ath6kl *ar) case ATH6KL_STATE_WOW: break; + case ATH6KL_STATE_SCHED_SCAN: break; + + case ATH6KL_STATE_SUSPENDING: + break; + + case ATH6KL_STATE_RESUMING: + break; } ath6kl_cfg80211_resume(ar); diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index 6754441105ef..b05f3537cfd9 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -285,6 +285,9 @@ int ath6kl_control_tx(void *devt, struct sk_buff *skb, int status = 0; struct ath6kl_cookie *cookie = NULL; + if (WARN_ON_ONCE(ar->state == ATH6KL_STATE_WOW)) + return -EACCES; + spin_lock_bh(&ar->lock); ath6kl_dbg(ATH6KL_DBG_WLAN_TX, @@ -360,6 +363,11 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) return 0; } + if (WARN_ON_ONCE(ar->state != ATH6KL_STATE_ON)) { + dev_kfree_skb(skb); + return 0; + } + if (!test_bit(WMI_READY, &ar->flag)) goto fail_tx; -- GitLab From 8f46fccd6cd0d7ba70ba1636e59e98ca17dd2239 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 20 Feb 2012 19:08:07 +0530 Subject: [PATCH 1482/1846] ath6kl: Maintain the listen interval per VIF specific Firmware has the option to support the listen interval per vif specific. Fix this. Listen interval can be set by the TUs or by the number of beacons. Current code enables the user to configure the listen interval in the unit of 'number of beacons' using debugfs entry "listen_interval". Going forward, we need to alter the listen interval in the unit of TUs to get good power numbers while going to WOW suspend/resume. Allowing the user to change the listen interval in the unit of "number of beacons" in debugfs and changing listen interval in wow suspend/resume in the unit of time (TUs) would lead us to confuse. This patch make sures the listen interval is changed only in the unit of time (TUs). Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 1 + drivers/net/wireless/ath/ath6kl/core.c | 2 -- drivers/net/wireless/ath/ath6kl/core.h | 6 +++--- drivers/net/wireless/ath/ath6kl/debug.c | 15 ++++++++++----- drivers/net/wireless/ath/ath6kl/main.c | 6 ++---- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index d877a9766b40..8d6bb323bb74 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -3033,6 +3033,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, vif->wdev.iftype = type; vif->fw_vif_idx = fw_vif_idx; vif->nw_type = vif->next_mode = nw_type; + vif->listen_intvl_t = ATH6KL_DEFAULT_LISTEN_INTVAL; memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); if (fw_vif_idx != 0) diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index bc3a41447b8e..2dc05479b512 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -228,9 +228,7 @@ struct ath6kl *ath6kl_core_create(struct device *dev) clear_bit(SKIP_SCAN, &ar->flag); clear_bit(DESTROY_IN_PROGRESS, &ar->flag); - ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL; ar->tx_pwr = 0; - ar->intra_bss = 1; ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD; diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 31f13d7a0430..727267eb8313 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -60,8 +60,6 @@ #define MAX_DEFAULT_SEND_QUEUE_DEPTH (MAX_DEF_COOKIE_NUM / WMM_NUM_AC) #define DISCON_TIMER_INTVAL 10000 /* in msec */ -#define A_DEFAULT_LISTEN_INTERVAL 1 /* beacon intervals */ -#define A_MAX_WOW_LISTEN_INTERVAL 1000 /* Channel dwell time in fg scan */ #define ATH6KL_FG_SCAN_INTERVAL 50 /* in ms */ @@ -187,6 +185,8 @@ struct ath6kl_fw_ie { #define MBOX_YIELD_LIMIT 99 +#define ATH6KL_DEFAULT_LISTEN_INTVAL 100 /* in TUs */ + /* configuration lags */ /* * ATH6KL_CONF_IGNORE_ERP_BARKER: Ignore the barker premable in @@ -510,6 +510,7 @@ struct ath6kl_vif { bool probe_req_report; u16 next_chan; u16 assoc_bss_beacon_int; + u16 listen_intvl_t; u8 assoc_bss_dtim_period; struct net_device_stats net_stats; struct target_stats target_stats; @@ -569,7 +570,6 @@ struct ath6kl { u8 avail_idx_map; spinlock_t lock; struct semaphore sem; - u16 listen_intvl_b; u8 lrssi_roam_threshold; struct ath6kl_version version; u32 target_type; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 645f923f79b5..56e1cb170299 100755 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -1631,12 +1631,12 @@ static ssize_t ath6kl_listen_int_write(struct file *file, if (kstrtou16(buf, 0, &listen_interval)) return -EINVAL; - if ((listen_interval < 1) || (listen_interval > 50)) + if ((listen_interval < 15) || (listen_interval > 3000)) return -EINVAL; - ar->listen_intvl_b = listen_interval; - ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, 0, - ar->listen_intvl_b); + vif->listen_intvl_t = listen_interval; + ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, + vif->listen_intvl_t, 0); return count; } @@ -1646,10 +1646,15 @@ static ssize_t ath6kl_listen_int_read(struct file *file, size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; + struct ath6kl_vif *vif; char buf[32]; int len; - len = scnprintf(buf, sizeof(buf), "%u\n", ar->listen_intvl_b); + vif = ath6kl_vif_first(ar); + if (!vif) + return -EIO; + + len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index f804cf135a60..bd8388c9db75 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -599,11 +599,9 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, memcpy(vif->bssid, bssid, sizeof(vif->bssid)); vif->bss_ch = channel; - if ((vif->nw_type == INFRA_NETWORK)) { - ar->listen_intvl_b = listen_int; + if ((vif->nw_type == INFRA_NETWORK)) ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, - 0, ar->listen_intvl_b); - } + vif->listen_intvl_t, 0); netif_wake_queue(vif->ndev); -- GitLab From ce0dc0cfeac9fde9964fa4b07aecd7cc604060e0 Mon Sep 17 00:00:00 2001 From: Raja Mani Date: Mon, 20 Feb 2012 19:08:08 +0530 Subject: [PATCH 1483/1846] ath6kl: Set optimal listen intvl,bmiss,scan params while going to wow suspend * In order to save the target power in WOW suspend state, configure the best optimal values for the below parameters, - listen interval. - beacon miss interval. - scan parameters. Default values for above attributes are reverted in wow resume operation. * The default listen interval is set before the host issue connect request. * New function is added to configure beacon miss count. kvalo: minor changes to fix open parenthesis alignment Signed-off-by: Raja Mani Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 59 +++++++++++++++++++++- drivers/net/wireless/ath/ath6kl/core.h | 4 ++ drivers/net/wireless/ath/ath6kl/wmi.c | 20 ++++++++ drivers/net/wireless/ath/ath6kl/wmi.h | 8 +++ 4 files changed, 90 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 8d6bb323bb74..baa3895b1643 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -423,6 +423,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct ath6kl_vif *vif = netdev_priv(dev); int status; u8 nw_subtype = (ar->p2p) ? SUBTYPE_P2PDEV : SUBTYPE_NONE; + u16 interval; ath6kl_cfg80211_sscan_disable(vif); @@ -577,6 +578,20 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->grp_crypto_len, vif->ch_hint); vif->reconnect_flag = 0; + + if (vif->nw_type == INFRA_NETWORK) { + interval = max(vif->listen_intvl_t, + (u16) ATH6KL_MAX_WOW_LISTEN_INTL); + status = ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, + interval, + 0); + if (status) { + ath6kl_err("couldn't set listen intervel\n"); + up(&ar->sem); + return status; + } + } + status = ath6kl_wmi_connect_cmd(ar->wmi, vif->fw_vif_idx, vif->nw_type, vif->dot11_auth_mode, vif->auth_mode, vif->prwise_crypto, @@ -1911,7 +1926,7 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) struct ath6kl_vif *vif; int ret, left; u32 filter = 0; - u16 i; + u16 i, bmiss_time; u8 index = 0; __be32 ips[MAX_IP_ADDRS]; @@ -1950,6 +1965,30 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) netif_stop_queue(vif->ndev); + if (vif->nw_type != AP_NETWORK) { + ret = ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, + ATH6KL_MAX_WOW_LISTEN_INTL, + 0); + if (ret) + return ret; + + /* Set listen interval x 15 times as bmiss time */ + bmiss_time = ATH6KL_MAX_WOW_LISTEN_INTL * 15; + if (bmiss_time > ATH6KL_MAX_BMISS_TIME) + bmiss_time = ATH6KL_MAX_BMISS_TIME; + + ret = ath6kl_wmi_bmisstime_cmd(ar->wmi, vif->fw_vif_idx, + bmiss_time, 0); + if (ret) + return ret; + + ret = ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, + 0xFFFF, 0, 0xFFFF, 0, 0, 0, + 0, 0, 0, 0); + if (ret) + return ret; + } + ar->state = ATH6KL_STATE_SUSPENDING; /* Setup own IP addr for ARP agent. */ @@ -2041,6 +2080,23 @@ static int ath6kl_wow_resume(struct ath6kl *ar) return ret; } + if (vif->nw_type != AP_NETWORK) { + ret = ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx, + 0, 0, 0, 0, 0, 0, 3, 0, 0, 0); + if (ret) + return ret; + + ret = ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, + vif->listen_intvl_t, 0); + if (ret) + return ret; + + ret = ath6kl_wmi_bmisstime_cmd(ar->wmi, vif->fw_vif_idx, + vif->bmiss_time_t, 0); + if (ret) + return ret; + } + ar->state = ATH6KL_STATE_ON; netif_wake_queue(vif->ndev); @@ -3034,6 +3090,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, vif->fw_vif_idx = fw_vif_idx; vif->nw_type = vif->next_mode = nw_type; vif->listen_intvl_t = ATH6KL_DEFAULT_LISTEN_INTVAL; + vif->bmiss_time_t = ATH6KL_DEFAULT_BMISS_TIME; memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN); if (fw_vif_idx != 0) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 727267eb8313..01763cd243b4 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -186,6 +186,9 @@ struct ath6kl_fw_ie { #define MBOX_YIELD_LIMIT 99 #define ATH6KL_DEFAULT_LISTEN_INTVAL 100 /* in TUs */ +#define ATH6KL_DEFAULT_BMISS_TIME 1500 +#define ATH6KL_MAX_WOW_LISTEN_INTL 300 /* in TUs */ +#define ATH6KL_MAX_BMISS_TIME 5000 /* configuration lags */ /* @@ -511,6 +514,7 @@ struct ath6kl_vif { u16 next_chan; u16 assoc_bss_beacon_int; u16 listen_intvl_t; + u16 bmiss_time_t; u8 assoc_bss_dtim_period; struct net_device_stats net_stats; struct target_stats target_stats; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 0a57dcc6041a..573cb26077a9 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -2027,6 +2027,26 @@ int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, return ret; } +int ath6kl_wmi_bmisstime_cmd(struct wmi *wmi, u8 if_idx, + u16 bmiss_time, u16 num_beacons) +{ + struct sk_buff *skb; + struct wmi_bmiss_time_cmd *cmd; + int ret; + + skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_bmiss_time_cmd *) skb->data; + cmd->bmiss_time = cpu_to_le16(bmiss_time); + cmd->num_beacons = cpu_to_le16(num_beacons); + + ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BMISS_TIME_CMDID, + NO_SYNC_WMIFLAG); + return ret; +} + int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) { struct sk_buff *skb; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index cea7429a8a0b..892a7a0a1378 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -998,6 +998,12 @@ struct wmi_listen_int_cmd { __le16 num_beacons; } __packed; +/* WMI_SET_BMISS_TIME_CMDID */ +struct wmi_bmiss_time_cmd { + __le16 bmiss_time; + __le16 num_beacons; +}; + /* WMI_SET_POWER_MODE_CMDID */ enum wmi_power_mode { REC_POWER = 0x01, @@ -2418,6 +2424,8 @@ int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, u16 listen_interval, u16 listen_beacons); +int ath6kl_wmi_bmisstime_cmd(struct wmi *wmi, u8 if_idx, + u16 bmiss_time, u16 num_beacons); int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode); int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, u16 ps_poll_num, u16 dtim_policy, -- GitLab From 1ccba2103a8b3a1041f261301b08b9e16f76df8a Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Wed, 7 Mar 2012 15:31:30 +0100 Subject: [PATCH 1484/1846] can: peak_usb: PCAN-USB specific part: fix little endian usage That patch fixes some bad usage of two little-endian variables, which lead to some warning/error when building the peak_usb driver. Reported-by: Dan Carpenter Acked-by: Marc Kleine-Budde Signed-off-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/peak_usb/pcan_usb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c index 8a7982e18e4e..86f26a1ede4c 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c @@ -741,16 +741,14 @@ static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb, /* can id */ if (cf->can_id & CAN_EFF_FLAG) { - __le32 tmp32 = cpu_to_le32(cf->can_id & CAN_ERR_MASK); + __le32 tmp32 = cpu_to_le32((cf->can_id & CAN_ERR_MASK) << 3); - tmp32 <<= 3; *pc |= PCAN_USB_STATUSLEN_EXT_ID; memcpy(++pc, &tmp32, 4); pc += 4; } else { - __le16 tmp16 = cpu_to_le32(cf->can_id & CAN_ERR_MASK); + __le16 tmp16 = cpu_to_le16((cf->can_id & CAN_ERR_MASK) << 5); - tmp16 <<= 5; memcpy(++pc, &tmp16, 2); pc += 2; } -- GitLab From c15f1c83251049182b1771da004d14f29683ab97 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 14 Feb 2012 00:24:10 +0100 Subject: [PATCH 1485/1846] netfilter: ipset: use NFPROTO_ constants ipset is actually using NFPROTO values rather than AF (xt_set passes that along). Signed-off-by: Jan Engelhardt Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/ipset/ip_set.h | 5 ++++- net/netfilter/ipset/ip_set_bitmap_ip.c | 4 ++-- net/netfilter/ipset/ip_set_bitmap_ipmac.c | 4 ++-- net/netfilter/ipset/ip_set_bitmap_port.c | 4 ++-- net/netfilter/ipset/ip_set_core.c | 16 ++++++++-------- net/netfilter/ipset/ip_set_getport.c | 4 ++-- net/netfilter/ipset/ip_set_hash_ip.c | 18 +++++++++--------- net/netfilter/ipset/ip_set_hash_ipport.c | 10 +++++----- net/netfilter/ipset/ip_set_hash_ipportip.c | 10 +++++----- net/netfilter/ipset/ip_set_hash_ipportnet.c | 12 ++++++------ net/netfilter/ipset/ip_set_hash_net.c | 12 ++++++------ net/netfilter/ipset/ip_set_hash_netiface.c | 12 ++++++------ net/netfilter/ipset/ip_set_hash_netport.c | 12 ++++++------ net/netfilter/ipset/ip_set_list_set.c | 2 +- 14 files changed, 64 insertions(+), 61 deletions(-) diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h index 3540c6e262f7..e7b06f52be84 100644 --- a/include/linux/netfilter/ipset/ip_set.h +++ b/include/linux/netfilter/ipset/ip_set.h @@ -288,7 +288,10 @@ struct ip_set_type { u8 features; /* Set type dimension */ u8 dimension; - /* Supported family: may be AF_UNSPEC for both AF_INET/AF_INET6 */ + /* + * Supported family: may be NFPROTO_UNSPEC for both + * NFPROTO_IPV4/NFPROTO_IPV6. + */ u8 family; /* Type revisions */ u8 revision_min, revision_max; diff --git a/net/netfilter/ipset/ip_set_bitmap_ip.c b/net/netfilter/ipset/ip_set_bitmap_ip.c index e3e73997c3be..a72a4dff0031 100644 --- a/net/netfilter/ipset/ip_set_bitmap_ip.c +++ b/net/netfilter/ipset/ip_set_bitmap_ip.c @@ -442,7 +442,7 @@ init_map_ip(struct ip_set *set, struct bitmap_ip *map, map->timeout = IPSET_NO_TIMEOUT; set->data = map; - set->family = AF_INET; + set->family = NFPROTO_IPV4; return true; } @@ -550,7 +550,7 @@ static struct ip_set_type bitmap_ip_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP, .dimension = IPSET_DIM_ONE, - .family = AF_INET, + .family = NFPROTO_IPV4, .revision_min = 0, .revision_max = 0, .create = bitmap_ip_create, diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c index 56096f544978..81324c12c5be 100644 --- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c +++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c @@ -543,7 +543,7 @@ init_map_ipmac(struct ip_set *set, struct bitmap_ipmac *map, map->timeout = IPSET_NO_TIMEOUT; set->data = map; - set->family = AF_INET; + set->family = NFPROTO_IPV4; return true; } @@ -623,7 +623,7 @@ static struct ip_set_type bitmap_ipmac_type = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP | IPSET_TYPE_MAC, .dimension = IPSET_DIM_TWO, - .family = AF_INET, + .family = NFPROTO_IPV4, .revision_min = 0, .revision_max = 0, .create = bitmap_ipmac_create, diff --git a/net/netfilter/ipset/ip_set_bitmap_port.c b/net/netfilter/ipset/ip_set_bitmap_port.c index 29ba93bb94be..382ec28ba72e 100644 --- a/net/netfilter/ipset/ip_set_bitmap_port.c +++ b/net/netfilter/ipset/ip_set_bitmap_port.c @@ -422,7 +422,7 @@ init_map_port(struct ip_set *set, struct bitmap_port *map, map->timeout = IPSET_NO_TIMEOUT; set->data = map; - set->family = AF_UNSPEC; + set->family = NFPROTO_UNSPEC; return true; } @@ -483,7 +483,7 @@ static struct ip_set_type bitmap_port_type = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_PORT, .dimension = IPSET_DIM_ONE, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .revision_max = 0, .create = bitmap_port_create, diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index e7f90e7082b4..e6c1c9605a58 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -69,7 +69,7 @@ find_set_type(const char *name, u8 family, u8 revision) list_for_each_entry_rcu(type, &ip_set_type_list, list) if (STREQ(type->name, name) && - (type->family == family || type->family == AF_UNSPEC) && + (type->family == family || type->family == NFPROTO_UNSPEC) && revision >= type->revision_min && revision <= type->revision_max) return type; @@ -149,7 +149,7 @@ __find_set_type_minmax(const char *name, u8 family, u8 *min, u8 *max, rcu_read_lock(); list_for_each_entry_rcu(type, &ip_set_type_list, list) if (STREQ(type->name, name) && - (type->family == family || type->family == AF_UNSPEC)) { + (type->family == family || type->family == NFPROTO_UNSPEC)) { found = true; if (type->revision_min < *min) *min = type->revision_min; @@ -164,8 +164,8 @@ __find_set_type_minmax(const char *name, u8 family, u8 *min, u8 *max, __find_set_type_minmax(name, family, min, max, true); } -#define family_name(f) ((f) == AF_INET ? "inet" : \ - (f) == AF_INET6 ? "inet6" : "any") +#define family_name(f) ((f) == NFPROTO_IPV4 ? "inet" : \ + (f) == NFPROTO_IPV6 ? "inet6" : "any") /* Register a set type structure. The type is identified by * the unique triple of name, family and revision. @@ -354,7 +354,7 @@ ip_set_test(ip_set_id_t index, const struct sk_buff *skb, pr_debug("set %s, index %u\n", set->name, index); if (opt->dim < set->type->dimension || - !(opt->family == set->family || set->family == AF_UNSPEC)) + !(opt->family == set->family || set->family == NFPROTO_UNSPEC)) return 0; read_lock_bh(&set->lock); @@ -387,7 +387,7 @@ ip_set_add(ip_set_id_t index, const struct sk_buff *skb, pr_debug("set %s, index %u\n", set->name, index); if (opt->dim < set->type->dimension || - !(opt->family == set->family || set->family == AF_UNSPEC)) + !(opt->family == set->family || set->family == NFPROTO_UNSPEC)) return 0; write_lock_bh(&set->lock); @@ -410,7 +410,7 @@ ip_set_del(ip_set_id_t index, const struct sk_buff *skb, pr_debug("set %s, index %u\n", set->name, index); if (opt->dim < set->type->dimension || - !(opt->family == set->family || set->family == AF_UNSPEC)) + !(opt->family == set->family || set->family == NFPROTO_UNSPEC)) return 0; write_lock_bh(&set->lock); @@ -575,7 +575,7 @@ start_msg(struct sk_buff *skb, u32 pid, u32 seq, unsigned int flags, return NULL; nfmsg = nlmsg_data(nlh); - nfmsg->nfgen_family = AF_INET; + nfmsg->nfgen_family = NFPROTO_IPV4; nfmsg->version = NFNETLINK_V0; nfmsg->res_id = 0; diff --git a/net/netfilter/ipset/ip_set_getport.c b/net/netfilter/ipset/ip_set_getport.c index 1f03556666f4..6fdf88ae2353 100644 --- a/net/netfilter/ipset/ip_set_getport.c +++ b/net/netfilter/ipset/ip_set_getport.c @@ -136,10 +136,10 @@ ip_set_get_ip_port(const struct sk_buff *skb, u8 pf, bool src, __be16 *port) u8 proto; switch (pf) { - case AF_INET: + case NFPROTO_IPV4: ret = ip_set_get_ip4_port(skb, src, port, &proto); break; - case AF_INET6: + case NFPROTO_IPV6: ret = ip_set_get_ip6_port(skb, src, port, &proto); break; default: diff --git a/net/netfilter/ipset/ip_set_hash_ip.c b/net/netfilter/ipset/ip_set_hash_ip.c index 4015fcaf87bc..5139dea6019e 100644 --- a/net/netfilter/ipset/ip_set_hash_ip.c +++ b/net/netfilter/ipset/ip_set_hash_ip.c @@ -366,11 +366,11 @@ hash_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) u8 netmask, hbits; struct ip_set_hash *h; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; - netmask = set->family == AF_INET ? 32 : 128; + netmask = set->family == NFPROTO_IPV4 ? 32 : 128; pr_debug("Create set %s with family %s\n", - set->name, set->family == AF_INET ? "inet" : "inet6"); + set->name, set->family == NFPROTO_IPV4 ? "inet" : "inet6"); if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || !ip_set_optattr_netorder(tb, IPSET_ATTR_MAXELEM) || @@ -389,8 +389,8 @@ hash_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_NETMASK]) { netmask = nla_get_u8(tb[IPSET_ATTR_NETMASK]); - if ((set->family == AF_INET && netmask > 32) || - (set->family == AF_INET6 && netmask > 128) || + if ((set->family == NFPROTO_IPV4 && netmask > 32) || + (set->family == NFPROTO_IPV6 && netmask > 128) || netmask == 0) return -IPSET_ERR_INVALID_NETMASK; } @@ -419,15 +419,15 @@ hash_ip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ip4_tvariant : &hash_ip6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_ip4_gc_init(set); else hash_ip6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ip4_variant : &hash_ip6_variant; } @@ -443,7 +443,7 @@ static struct ip_set_type hash_ip_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP, .dimension = IPSET_DIM_ONE, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .revision_max = 0, .create = hash_ip_create, diff --git a/net/netfilter/ipset/ip_set_hash_ipport.c b/net/netfilter/ipset/ip_set_hash_ipport.c index 37d667e3f6f8..9c27e249c171 100644 --- a/net/netfilter/ipset/ip_set_hash_ipport.c +++ b/net/netfilter/ipset/ip_set_hash_ipport.c @@ -450,7 +450,7 @@ hash_ipport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; u8 hbits; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || @@ -490,15 +490,15 @@ hash_ipport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ipport4_tvariant : &hash_ipport6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_ipport4_gc_init(set); else hash_ipport6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ipport4_variant : &hash_ipport6_variant; } @@ -514,7 +514,7 @@ static struct ip_set_type hash_ipport_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP | IPSET_TYPE_PORT, .dimension = IPSET_DIM_TWO, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .revision_max = 1, /* SCTP and UDPLITE support added */ .create = hash_ipport_create, diff --git a/net/netfilter/ipset/ip_set_hash_ipportip.c b/net/netfilter/ipset/ip_set_hash_ipportip.c index e69e2718fbe1..9134057c0728 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportip.c +++ b/net/netfilter/ipset/ip_set_hash_ipportip.c @@ -468,7 +468,7 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; u8 hbits; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || @@ -508,15 +508,15 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ipportip4_tvariant : &hash_ipportip6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_ipportip4_gc_init(set); else hash_ipportip6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ipportip4_variant : &hash_ipportip6_variant; } @@ -532,7 +532,7 @@ static struct ip_set_type hash_ipportip_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2, .dimension = IPSET_DIM_THREE, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .revision_max = 1, /* SCTP and UDPLITE support added */ .create = hash_ipportip_create, diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c index 64199b4e93c9..0edb35b81e36 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportnet.c +++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c @@ -554,7 +554,7 @@ hash_ipportnet_create(struct ip_set *set, struct nlattr *tb[], u32 flags) u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; u8 hbits; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || @@ -573,7 +573,7 @@ hash_ipportnet_create(struct ip_set *set, struct nlattr *tb[], u32 flags) h = kzalloc(sizeof(*h) + sizeof(struct ip_set_hash_nets) - * (set->family == AF_INET ? 32 : 128), GFP_KERNEL); + * (set->family == NFPROTO_IPV4 ? 32 : 128), GFP_KERNEL); if (!h) return -ENOMEM; @@ -596,16 +596,16 @@ hash_ipportnet_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ipportnet4_tvariant : &hash_ipportnet6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_ipportnet4_gc_init(set); else hash_ipportnet6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_ipportnet4_variant : &hash_ipportnet6_variant; } @@ -621,7 +621,7 @@ static struct ip_set_type hash_ipportnet_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP | IPSET_TYPE_PORT | IPSET_TYPE_IP2, .dimension = IPSET_DIM_THREE, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, /* 1 SCTP and UDPLITE support added */ .revision_max = 2, /* Range as input support for IPv4 added */ diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c index 28988196775e..5a4457adaf85 100644 --- a/net/netfilter/ipset/ip_set_hash_net.c +++ b/net/netfilter/ipset/ip_set_hash_net.c @@ -406,7 +406,7 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags) struct ip_set_hash *h; u8 hbits; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || @@ -425,7 +425,7 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags) h = kzalloc(sizeof(*h) + sizeof(struct ip_set_hash_nets) - * (set->family == AF_INET ? 32 : 128), GFP_KERNEL); + * (set->family == NFPROTO_IPV4 ? 32 : 128), GFP_KERNEL); if (!h) return -ENOMEM; @@ -448,15 +448,15 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_net4_tvariant : &hash_net6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_net4_gc_init(set); else hash_net6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_net4_variant : &hash_net6_variant; } @@ -472,7 +472,7 @@ static struct ip_set_type hash_net_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP, .dimension = IPSET_DIM_ONE, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .revision_max = 1, /* Range as input support for IPv4 added */ .create = hash_net_create, diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c index e13095deb50d..a9fb4afafa8b 100644 --- a/net/netfilter/ipset/ip_set_hash_netiface.c +++ b/net/netfilter/ipset/ip_set_hash_netiface.c @@ -678,7 +678,7 @@ hash_netiface_create(struct ip_set *set, struct nlattr *tb[], u32 flags) u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; u8 hbits; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || @@ -697,7 +697,7 @@ hash_netiface_create(struct ip_set *set, struct nlattr *tb[], u32 flags) h = kzalloc(sizeof(*h) + sizeof(struct ip_set_hash_nets) - * (set->family == AF_INET ? 32 : 128), GFP_KERNEL); + * (set->family == NFPROTO_IPV4 ? 32 : 128), GFP_KERNEL); if (!h) return -ENOMEM; @@ -722,15 +722,15 @@ hash_netiface_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_netiface4_tvariant : &hash_netiface6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_netiface4_gc_init(set); else hash_netiface6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_netiface4_variant : &hash_netiface6_variant; } @@ -746,7 +746,7 @@ static struct ip_set_type hash_netiface_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP | IPSET_TYPE_IFACE, .dimension = IPSET_DIM_TWO, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .create = hash_netiface_create, .create_policy = { diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c index 8f9de7207ec9..1fcc1020eaae 100644 --- a/net/netfilter/ipset/ip_set_hash_netport.c +++ b/net/netfilter/ipset/ip_set_hash_netport.c @@ -507,7 +507,7 @@ hash_netport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM; u8 hbits; - if (!(set->family == AF_INET || set->family == AF_INET6)) + if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6)) return -IPSET_ERR_INVALID_FAMILY; if (unlikely(!ip_set_optattr_netorder(tb, IPSET_ATTR_HASHSIZE) || @@ -526,7 +526,7 @@ hash_netport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) h = kzalloc(sizeof(*h) + sizeof(struct ip_set_hash_nets) - * (set->family == AF_INET ? 32 : 128), GFP_KERNEL); + * (set->family == NFPROTO_IPV4 ? 32 : 128), GFP_KERNEL); if (!h) return -ENOMEM; @@ -549,15 +549,15 @@ hash_netport_create(struct ip_set *set, struct nlattr *tb[], u32 flags) if (tb[IPSET_ATTR_TIMEOUT]) { h->timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_netport4_tvariant : &hash_netport6_tvariant; - if (set->family == AF_INET) + if (set->family == NFPROTO_IPV4) hash_netport4_gc_init(set); else hash_netport6_gc_init(set); } else { - set->variant = set->family == AF_INET + set->variant = set->family == NFPROTO_IPV4 ? &hash_netport4_variant : &hash_netport6_variant; } @@ -573,7 +573,7 @@ static struct ip_set_type hash_netport_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_IP | IPSET_TYPE_PORT, .dimension = IPSET_DIM_TWO, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, /* 1 SCTP and UDPLITE support added */ .revision_max = 2, /* Range as input support for IPv4 added */ diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c index 4d10819d462e..7e095f9005f0 100644 --- a/net/netfilter/ipset/ip_set_list_set.c +++ b/net/netfilter/ipset/ip_set_list_set.c @@ -575,7 +575,7 @@ static struct ip_set_type list_set_type __read_mostly = { .protocol = IPSET_PROTOCOL, .features = IPSET_TYPE_NAME | IPSET_DUMP_LAST, .dimension = IPSET_DIM_ONE, - .family = AF_UNSPEC, + .family = NFPROTO_UNSPEC, .revision_min = 0, .revision_max = 0, .create = list_set_create, -- GitLab From ae8ded1cb88b9c24f3c9552ca9eefd894b069716 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sat, 14 Jan 2012 16:26:20 +0100 Subject: [PATCH 1486/1846] netfilter: ipset: expose userspace-relevant parts in ip_set.h iptables's libxt_SET.c depends on these. Signed-off-by: Jan Engelhardt Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/ipset/ip_set.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h index e7b06f52be84..e921766d3aff 100644 --- a/include/linux/netfilter/ipset/ip_set.h +++ b/include/linux/netfilter/ipset/ip_set.h @@ -11,6 +11,8 @@ * published by the Free Software Foundation. */ +#include + /* The protocol version */ #define IPSET_PROTOCOL 6 @@ -168,19 +170,10 @@ enum ipset_adt { IPSET_CADT_MAX, }; -#ifdef __KERNEL__ -#include -#include -#include -#include -#include -#include -#include - /* Sets are identified by an index in kernel space. Tweak with ip_set_id_t * and IPSET_INVALID_ID if you want to increase the max number of sets. */ -typedef u16 ip_set_id_t; +typedef __u16 ip_set_id_t; #define IPSET_INVALID_ID 65535 @@ -203,6 +196,15 @@ enum ip_set_kopt { IPSET_DIM_THREE_SRC = (1 << IPSET_DIM_THREE), }; +#ifdef __KERNEL__ +#include +#include +#include +#include +#include +#include +#include + /* Set features */ enum ip_set_feature { IPSET_TYPE_IP_FLAG = 0, @@ -453,6 +455,8 @@ bitmap_bytes(u32 a, u32 b) return 4 * ((((b - a + 8) / 8) + 3) / 4); } +#endif /* __KERNEL__ */ + /* Interface to iptables/ip6tables */ #define SO_IP_SET 83 @@ -478,6 +482,4 @@ struct ip_set_req_version { unsigned version; }; -#endif /* __KERNEL__ */ - #endif /*_IP_SET_H */ -- GitLab From 0927a1ac63388271d58e9f7352d71434e1271374 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Tue, 10 Jan 2012 17:04:32 +0100 Subject: [PATCH 1487/1846] netfilter: ipset: Log warning when a hash type of set gets full If the set is full, the SET target cannot add more elements. Log warning so that the admin got notified about it. Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/ipset/ip_set_ahash.h | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/include/linux/netfilter/ipset/ip_set_ahash.h b/include/linux/netfilter/ipset/ip_set_ahash.h index b89fb79cb44f..bd1fc8d16851 100644 --- a/include/linux/netfilter/ipset/ip_set_ahash.h +++ b/include/linux/netfilter/ipset/ip_set_ahash.h @@ -353,9 +353,12 @@ type_pf_resize(struct ip_set *set, bool retried) htable_bits++; pr_debug("attempt to resize set %s from %u to %u, t %p\n", set->name, orig->htable_bits, htable_bits, orig); - if (!htable_bits) + if (!htable_bits) { /* In case we have plenty of memory :-) */ + pr_warning("Cannot increase the hashsize of set %s further\n", + set->name); return -IPSET_ERR_HASH_FULL; + } t = ip_set_alloc(sizeof(*t) + jhash_size(htable_bits) * sizeof(struct hbucket)); if (!t) @@ -407,8 +410,12 @@ type_pf_add(struct ip_set *set, void *value, u32 timeout, u32 flags) int i, ret = 0; u32 key, multi = 0; - if (h->elements >= h->maxelem) + if (h->elements >= h->maxelem) { + if (net_ratelimit()) + pr_warning("Set %s is full, maxelem %u reached\n", + set->name, h->maxelem); return -IPSET_ERR_HASH_FULL; + } rcu_read_lock_bh(); t = rcu_dereference_bh(h->table); @@ -790,9 +797,12 @@ type_pf_tresize(struct ip_set *set, bool retried) retry: ret = 0; htable_bits++; - if (!htable_bits) + if (!htable_bits) { /* In case we have plenty of memory :-) */ + pr_warning("Cannot increase the hashsize of set %s further\n", + set->name); return -IPSET_ERR_HASH_FULL; + } t = ip_set_alloc(sizeof(*t) + jhash_size(htable_bits) * sizeof(struct hbucket)); if (!t) @@ -843,8 +853,12 @@ type_pf_tadd(struct ip_set *set, void *value, u32 timeout, u32 flags) if (h->elements >= h->maxelem) /* FIXME: when set is full, we slow down here */ type_pf_expire(h); - if (h->elements >= h->maxelem) + if (h->elements >= h->maxelem) { + if (net_ratelimit()) + pr_warning("Set %s is full, maxelem %u reached\n", + set->name, h->maxelem); return -IPSET_ERR_HASH_FULL; + } rcu_read_lock_bh(); t = rcu_dereference_bh(h->table); -- GitLab From 2a7cef2a4ba64b9bf0ff9aeaa364554716c06669 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Sat, 14 Jan 2012 17:16:36 +0100 Subject: [PATCH 1488/1846] netfilter: ipset: Exceptions support added to hash:*net* types The "nomatch" keyword and option is added to the hash:*net* types, by which one can add exception entries to sets. Example: ipset create test hash:net ipset add test 192.168.0/24 ipset add test 192.168.0/30 nomatch In this case the IP addresses from 192.168.0/24 except 192.168.0/30 match the elements of the set. Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/ipset/ip_set.h | 4 + include/linux/netfilter/ipset/ip_set_ahash.h | 89 ++++++++---- net/netfilter/ipset/ip_set_hash_ipportnet.c | 135 +++++++++++++----- net/netfilter/ipset/ip_set_hash_net.c | 77 +++++++++-- net/netfilter/ipset/ip_set_hash_netiface.c | 72 ++++++++-- net/netfilter/ipset/ip_set_hash_netport.c | 138 ++++++++++++++----- 6 files changed, 399 insertions(+), 116 deletions(-) diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h index e921766d3aff..2f8e18a23227 100644 --- a/include/linux/netfilter/ipset/ip_set.h +++ b/include/linux/netfilter/ipset/ip_set.h @@ -150,6 +150,7 @@ enum ipset_cmd_flags { IPSET_FLAG_LIST_SETNAME = (1 << IPSET_FLAG_BIT_LIST_SETNAME), IPSET_FLAG_BIT_LIST_HEADER = 2, IPSET_FLAG_LIST_HEADER = (1 << IPSET_FLAG_BIT_LIST_HEADER), + IPSET_FLAG_CMD_MAX = 15, /* Lower half */ }; /* Flags at CADT attribute level */ @@ -158,6 +159,9 @@ enum ipset_cadt_flags { IPSET_FLAG_BEFORE = (1 << IPSET_FLAG_BIT_BEFORE), IPSET_FLAG_BIT_PHYSDEV = 1, IPSET_FLAG_PHYSDEV = (1 << IPSET_FLAG_BIT_PHYSDEV), + IPSET_FLAG_BIT_NOMATCH = 2, + IPSET_FLAG_NOMATCH = (1 << IPSET_FLAG_BIT_NOMATCH), + IPSET_FLAG_CADT_MAX = 15, /* Upper half */ }; /* Commands with settype-specific attributes */ diff --git a/include/linux/netfilter/ipset/ip_set_ahash.h b/include/linux/netfilter/ipset/ip_set_ahash.h index bd1fc8d16851..0e5c3cf7618a 100644 --- a/include/linux/netfilter/ipset/ip_set_ahash.h +++ b/include/linux/netfilter/ipset/ip_set_ahash.h @@ -113,6 +113,12 @@ htable_bits(u32 hashsize) } #ifdef IP_SET_HASH_WITH_NETS +#ifdef IP_SET_HASH_WITH_NETS_PACKED +/* When cidr is packed with nomatch, cidr - 1 is stored in the entry */ +#define CIDR(cidr) (cidr + 1) +#else +#define CIDR(cidr) (cidr) +#endif #define SET_HOST_MASK(family) (family == AF_INET ? 32 : 128) @@ -262,6 +268,12 @@ ip_set_hash_destroy(struct ip_set *set) #define type_pf_data_list TOKEN(TYPE, PF, _data_list) #define type_pf_data_tlist TOKEN(TYPE, PF, _data_tlist) #define type_pf_data_next TOKEN(TYPE, PF, _data_next) +#define type_pf_data_flags TOKEN(TYPE, PF, _data_flags) +#ifdef IP_SET_HASH_WITH_NETS +#define type_pf_data_match TOKEN(TYPE, PF, _data_match) +#else +#define type_pf_data_match(d) 1 +#endif #define type_pf_elem TOKEN(TYPE, PF, _elem) #define type_pf_telem TOKEN(TYPE, PF, _telem) @@ -308,8 +320,10 @@ ip_set_hash_destroy(struct ip_set *set) * we spare the maintenance of the internal counters. */ static int type_pf_elem_add(struct hbucket *n, const struct type_pf_elem *value, - u8 ahash_max) + u8 ahash_max, u32 cadt_flags) { + struct type_pf_elem *data; + if (n->pos >= n->size) { void *tmp; @@ -330,7 +344,13 @@ type_pf_elem_add(struct hbucket *n, const struct type_pf_elem *value, n->value = tmp; n->size += AHASH_INIT_SIZE; } - type_pf_data_copy(ahash_data(n, n->pos++), value); + data = ahash_data(n, n->pos++); + type_pf_data_copy(data, value); +#ifdef IP_SET_HASH_WITH_NETS + /* Resizing won't overwrite stored flags */ + if (cadt_flags) + type_pf_data_flags(data, cadt_flags); +#endif return 0; } @@ -371,7 +391,7 @@ type_pf_resize(struct ip_set *set, bool retried) for (j = 0; j < n->pos; j++) { data = ahash_data(n, j); m = hbucket(t, HKEY(data, h->initval, htable_bits)); - ret = type_pf_elem_add(m, data, AHASH_MAX(h)); + ret = type_pf_elem_add(m, data, AHASH_MAX(h), 0); if (ret < 0) { read_unlock_bh(&set->lock); ahash_destroy(t); @@ -409,6 +429,7 @@ type_pf_add(struct ip_set *set, void *value, u32 timeout, u32 flags) struct hbucket *n; int i, ret = 0; u32 key, multi = 0; + u32 cadt_flags = flags >> 16; if (h->elements >= h->maxelem) { if (net_ratelimit()) @@ -423,11 +444,17 @@ type_pf_add(struct ip_set *set, void *value, u32 timeout, u32 flags) n = hbucket(t, key); for (i = 0; i < n->pos; i++) if (type_pf_data_equal(ahash_data(n, i), d, &multi)) { +#ifdef IP_SET_HASH_WITH_NETS + if (flags & IPSET_FLAG_EXIST) + /* Support overwriting just the flags */ + type_pf_data_flags(ahash_data(n, i), + cadt_flags); +#endif ret = -IPSET_ERR_EXIST; goto out; } TUNE_AHASH_MAX(h, multi); - ret = type_pf_elem_add(n, value, AHASH_MAX(h)); + ret = type_pf_elem_add(n, value, AHASH_MAX(h), cadt_flags); if (ret != 0) { if (ret == -EAGAIN) type_pf_data_next(h, d); @@ -435,7 +462,7 @@ type_pf_add(struct ip_set *set, void *value, u32 timeout, u32 flags) } #ifdef IP_SET_HASH_WITH_NETS - add_cidr(h, d->cidr, HOST_MASK); + add_cidr(h, CIDR(d->cidr), HOST_MASK); #endif h->elements++; out: @@ -470,7 +497,7 @@ type_pf_del(struct ip_set *set, void *value, u32 timeout, u32 flags) n->pos--; h->elements--; #ifdef IP_SET_HASH_WITH_NETS - del_cidr(h, d->cidr, HOST_MASK); + del_cidr(h, CIDR(d->cidr), HOST_MASK); #endif if (n->pos + AHASH_INIT_SIZE < n->size) { void *tmp = kzalloc((n->size - AHASH_INIT_SIZE) @@ -513,7 +540,7 @@ type_pf_test_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout) for (i = 0; i < n->pos; i++) { data = ahash_data(n, i); if (type_pf_data_equal(data, d, &multi)) - return 1; + return type_pf_data_match(data); } } return 0; @@ -535,7 +562,7 @@ type_pf_test(struct ip_set *set, void *value, u32 timeout, u32 flags) #ifdef IP_SET_HASH_WITH_NETS /* If we test an IP address and not a network address, * try all possible network sizes */ - if (d->cidr == SET_HOST_MASK(set->family)) + if (CIDR(d->cidr) == SET_HOST_MASK(set->family)) return type_pf_test_cidrs(set, d, timeout); #endif @@ -544,7 +571,7 @@ type_pf_test(struct ip_set *set, void *value, u32 timeout, u32 flags) for (i = 0; i < n->pos; i++) { data = ahash_data(n, i); if (type_pf_data_equal(data, d, &multi)) - return 1; + return type_pf_data_match(data); } return 0; } @@ -700,7 +727,7 @@ type_pf_data_timeout_set(struct type_pf_elem *data, u32 timeout) static int type_pf_elem_tadd(struct hbucket *n, const struct type_pf_elem *value, - u8 ahash_max, u32 timeout) + u8 ahash_max, u32 cadt_flags, u32 timeout) { struct type_pf_elem *data; @@ -727,6 +754,11 @@ type_pf_elem_tadd(struct hbucket *n, const struct type_pf_elem *value, data = ahash_tdata(n, n->pos++); type_pf_data_copy(data, value); type_pf_data_timeout_set(data, timeout); +#ifdef IP_SET_HASH_WITH_NETS + /* Resizing won't overwrite stored flags */ + if (cadt_flags) + type_pf_data_flags(data, cadt_flags); +#endif return 0; } @@ -747,7 +779,7 @@ type_pf_expire(struct ip_set_hash *h) if (type_pf_data_expired(data)) { pr_debug("expired %u/%u\n", i, j); #ifdef IP_SET_HASH_WITH_NETS - del_cidr(h, data->cidr, HOST_MASK); + del_cidr(h, CIDR(data->cidr), HOST_MASK); #endif if (j != n->pos - 1) /* Not last one */ @@ -815,7 +847,7 @@ type_pf_tresize(struct ip_set *set, bool retried) for (j = 0; j < n->pos; j++) { data = ahash_tdata(n, j); m = hbucket(t, HKEY(data, h->initval, htable_bits)); - ret = type_pf_elem_tadd(m, data, AHASH_MAX(h), + ret = type_pf_elem_tadd(m, data, AHASH_MAX(h), 0, type_pf_data_timeout(data)); if (ret < 0) { read_unlock_bh(&set->lock); @@ -849,6 +881,7 @@ type_pf_tadd(struct ip_set *set, void *value, u32 timeout, u32 flags) int ret = 0, i, j = AHASH_MAX(h) + 1; bool flag_exist = flags & IPSET_FLAG_EXIST; u32 key, multi = 0; + u32 cadt_flags = flags >> 16; if (h->elements >= h->maxelem) /* FIXME: when set is full, we slow down here */ @@ -868,6 +901,7 @@ type_pf_tadd(struct ip_set *set, void *value, u32 timeout, u32 flags) data = ahash_tdata(n, i); if (type_pf_data_equal(data, d, &multi)) { if (type_pf_data_expired(data) || flag_exist) + /* Just timeout value may be updated */ j = i; else { ret = -IPSET_ERR_EXIST; @@ -880,15 +914,18 @@ type_pf_tadd(struct ip_set *set, void *value, u32 timeout, u32 flags) if (j != AHASH_MAX(h) + 1) { data = ahash_tdata(n, j); #ifdef IP_SET_HASH_WITH_NETS - del_cidr(h, data->cidr, HOST_MASK); - add_cidr(h, d->cidr, HOST_MASK); + del_cidr(h, CIDR(data->cidr), HOST_MASK); + add_cidr(h, CIDR(d->cidr), HOST_MASK); #endif type_pf_data_copy(data, d); type_pf_data_timeout_set(data, timeout); +#ifdef IP_SET_HASH_WITH_NETS + type_pf_data_flags(data, cadt_flags); +#endif goto out; } TUNE_AHASH_MAX(h, multi); - ret = type_pf_elem_tadd(n, d, AHASH_MAX(h), timeout); + ret = type_pf_elem_tadd(n, d, AHASH_MAX(h), cadt_flags, timeout); if (ret != 0) { if (ret == -EAGAIN) type_pf_data_next(h, d); @@ -896,7 +933,7 @@ type_pf_tadd(struct ip_set *set, void *value, u32 timeout, u32 flags) } #ifdef IP_SET_HASH_WITH_NETS - add_cidr(h, d->cidr, HOST_MASK); + add_cidr(h, CIDR(d->cidr), HOST_MASK); #endif h->elements++; out: @@ -930,7 +967,7 @@ type_pf_tdel(struct ip_set *set, void *value, u32 timeout, u32 flags) n->pos--; h->elements--; #ifdef IP_SET_HASH_WITH_NETS - del_cidr(h, d->cidr, HOST_MASK); + del_cidr(h, CIDR(d->cidr), HOST_MASK); #endif if (n->pos + AHASH_INIT_SIZE < n->size) { void *tmp = kzalloc((n->size - AHASH_INIT_SIZE) @@ -968,8 +1005,9 @@ type_pf_ttest_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout) n = hbucket(t, key); for (i = 0; i < n->pos; i++) { data = ahash_tdata(n, i); - if (type_pf_data_equal(data, d, &multi)) - return !type_pf_data_expired(data); + if (type_pf_data_equal(data, d, &multi) && + !type_pf_data_expired(data)) + return type_pf_data_match(data); } } return 0; @@ -987,15 +1025,16 @@ type_pf_ttest(struct ip_set *set, void *value, u32 timeout, u32 flags) u32 key, multi = 0; #ifdef IP_SET_HASH_WITH_NETS - if (d->cidr == SET_HOST_MASK(set->family)) + if (CIDR(d->cidr) == SET_HOST_MASK(set->family)) return type_pf_ttest_cidrs(set, d, timeout); #endif key = HKEY(d, h->initval, t->htable_bits); n = hbucket(t, key); for (i = 0; i < n->pos; i++) { data = ahash_tdata(n, i); - if (type_pf_data_equal(data, d, &multi)) - return !type_pf_data_expired(data); + if (type_pf_data_equal(data, d, &multi) && + !type_pf_data_expired(data)) + return type_pf_data_match(data); } return 0; } @@ -1108,14 +1147,17 @@ type_pf_gc_init(struct ip_set *set) #undef type_pf_data_isnull #undef type_pf_data_copy #undef type_pf_data_zero_out +#undef type_pf_data_netmask #undef type_pf_data_list #undef type_pf_data_tlist +#undef type_pf_data_next +#undef type_pf_data_flags +#undef type_pf_data_match #undef type_pf_elem #undef type_pf_telem #undef type_pf_data_timeout #undef type_pf_data_expired -#undef type_pf_data_netmask #undef type_pf_data_timeout_set #undef type_pf_elem_add @@ -1125,6 +1167,7 @@ type_pf_gc_init(struct ip_set *set) #undef type_pf_test #undef type_pf_elem_tadd +#undef type_pf_del_telem #undef type_pf_expire #undef type_pf_tadd #undef type_pf_tdel diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c index 0edb35b81e36..5d05e6969862 100644 --- a/net/netfilter/ipset/ip_set_hash_ipportnet.c +++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c @@ -41,12 +41,19 @@ hash_ipportnet_same_set(const struct ip_set *a, const struct ip_set *b); /* The type variant functions: IPv4 */ +/* We squeeze the "nomatch" flag into cidr: we don't support cidr == 0 + * However this way we have to store internally cidr - 1, + * dancing back and forth. + */ +#define IP_SET_HASH_WITH_NETS_PACKED + /* Member elements without timeout */ struct hash_ipportnet4_elem { __be32 ip; __be32 ip2; __be16 port; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; u8 proto; }; @@ -55,7 +62,8 @@ struct hash_ipportnet4_telem { __be32 ip; __be32 ip2; __be16 port; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; u8 proto; unsigned long timeout; }; @@ -85,11 +93,23 @@ hash_ipportnet4_data_copy(struct hash_ipportnet4_elem *dst, memcpy(dst, src, sizeof(*dst)); } +static inline void +hash_ipportnet4_data_flags(struct hash_ipportnet4_elem *dst, u32 flags) +{ + dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH); +} + +static inline bool +hash_ipportnet4_data_match(const struct hash_ipportnet4_elem *elem) +{ + return !elem->nomatch; +} + static inline void hash_ipportnet4_data_netmask(struct hash_ipportnet4_elem *elem, u8 cidr) { elem->ip2 &= ip_set_netmask(cidr); - elem->cidr = cidr; + elem->cidr = cidr - 1; } static inline void @@ -102,11 +122,15 @@ static bool hash_ipportnet4_data_list(struct sk_buff *skb, const struct hash_ipportnet4_elem *data) { + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; + NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP2, data->ip2); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -119,14 +143,17 @@ hash_ipportnet4_data_tlist(struct sk_buff *skb, { const struct hash_ipportnet4_telem *tdata = (const struct hash_ipportnet4_telem *)data; + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP2, tdata->ip2); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, tdata->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(tdata->timeout))); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; @@ -158,13 +185,11 @@ hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb, const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; struct hash_ipportnet4_elem data = { - .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK + .cidr = h->nets[0].cidr ? h->nets[0].cidr - 1 : HOST_MASK - 1 }; - if (data.cidr == 0) - return -EINVAL; if (adt == IPSET_TEST) - data.cidr = HOST_MASK; + data.cidr = HOST_MASK - 1; if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, &data.port, &data.proto)) @@ -172,7 +197,7 @@ hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb, ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); ip4addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &data.ip2); - data.ip2 &= ip_set_netmask(data.cidr); + data.ip2 &= ip_set_netmask(data.cidr + 1); return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); } @@ -183,17 +208,19 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[], { const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; - struct hash_ipportnet4_elem data = { .cidr = HOST_MASK }; + struct hash_ipportnet4_elem data = { .cidr = HOST_MASK - 1 }; u32 ip, ip_to = 0, p = 0, port, port_to; u32 ip2_from = 0, ip2_to, ip2_last, ip2; u32 timeout = h->timeout; bool with_ports = false; + u8 cidr; int ret; if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || - !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT))) + !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || + !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) return -IPSET_ERR_PROTOCOL; if (tb[IPSET_ATTR_LINENO]) @@ -208,9 +235,10 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[], return ret; if (tb[IPSET_ATTR_CIDR2]) { - data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]); - if (!data.cidr) + cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]); + if (!cidr || cidr > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; + data.cidr = cidr - 1; } if (tb[IPSET_ATTR_PORT]) @@ -236,12 +264,18 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[], timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); } + if (tb[IPSET_ATTR_CADT_FLAGS] && adt == IPSET_ADD) { + u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); + if (cadt_flags & IPSET_FLAG_NOMATCH) + flags |= (cadt_flags << 16); + } + with_ports = with_ports && tb[IPSET_ATTR_PORT_TO]; if (adt == IPSET_TEST || !(tb[IPSET_ATTR_CIDR] || tb[IPSET_ATTR_IP_TO] || with_ports || tb[IPSET_ATTR_IP2_TO])) { data.ip = htonl(ip); - data.ip2 = htonl(ip2_from & ip_set_hostmask(data.cidr)); + data.ip2 = htonl(ip2_from & ip_set_hostmask(data.cidr + 1)); ret = adtfn(set, &data, timeout, flags); return ip_set_eexist(ret, flags) ? 0 : ret; } @@ -275,7 +309,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[], if (ip2_from + UINT_MAX == ip2_to) return -IPSET_ERR_HASH_RANGE; } else { - ip_set_mask_from_to(ip2_from, ip2_to, data.cidr); + ip_set_mask_from_to(ip2_from, ip2_to, data.cidr + 1); } if (retried) @@ -290,7 +324,8 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[], while (!after(ip2, ip2_to)) { data.ip2 = htonl(ip2); ip2_last = ip_set_range_to_cidr(ip2, ip2_to, - &data.cidr); + &cidr); + data.cidr = cidr - 1; ret = adtfn(set, &data, timeout, flags); if (ret && !ip_set_eexist(ret, flags)) @@ -321,7 +356,8 @@ struct hash_ipportnet6_elem { union nf_inet_addr ip; union nf_inet_addr ip2; __be16 port; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; u8 proto; }; @@ -329,7 +365,8 @@ struct hash_ipportnet6_telem { union nf_inet_addr ip; union nf_inet_addr ip2; __be16 port; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; u8 proto; unsigned long timeout; }; @@ -359,6 +396,18 @@ hash_ipportnet6_data_copy(struct hash_ipportnet6_elem *dst, memcpy(dst, src, sizeof(*dst)); } +static inline void +hash_ipportnet6_data_flags(struct hash_ipportnet6_elem *dst, u32 flags) +{ + dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH); +} + +static inline bool +hash_ipportnet6_data_match(const struct hash_ipportnet6_elem *elem) +{ + return !elem->nomatch; +} + static inline void hash_ipportnet6_data_zero_out(struct hash_ipportnet6_elem *elem) { @@ -378,18 +427,22 @@ static inline void hash_ipportnet6_data_netmask(struct hash_ipportnet6_elem *elem, u8 cidr) { ip6_netmask(&elem->ip2, cidr); - elem->cidr = cidr; + elem->cidr = cidr - 1; } static bool hash_ipportnet6_data_list(struct sk_buff *skb, const struct hash_ipportnet6_elem *data) { + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; + NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP2, &data->ip2); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -402,14 +455,17 @@ hash_ipportnet6_data_tlist(struct sk_buff *skb, { const struct hash_ipportnet6_telem *e = (const struct hash_ipportnet6_telem *)data; + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP2, &data->ip2); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR2, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(e->timeout))); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -438,13 +494,11 @@ hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; struct hash_ipportnet6_elem data = { - .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK + .cidr = h->nets[0].cidr ? h->nets[0].cidr - 1 : HOST_MASK - 1 }; - if (data.cidr == 0) - return -EINVAL; if (adt == IPSET_TEST) - data.cidr = HOST_MASK; + data.cidr = HOST_MASK - 1; if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, &data.port, &data.proto)) @@ -452,7 +506,7 @@ hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb, ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); ip6addrptr(skb, opt->flags & IPSET_DIM_THREE_SRC, &data.ip2.in6); - ip6_netmask(&data.ip2, data.cidr); + ip6_netmask(&data.ip2, data.cidr + 1); return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); } @@ -463,16 +517,18 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[], { const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; - struct hash_ipportnet6_elem data = { .cidr = HOST_MASK }; + struct hash_ipportnet6_elem data = { .cidr = HOST_MASK - 1 }; u32 port, port_to; u32 timeout = h->timeout; bool with_ports = false; + u8 cidr; int ret; if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || + !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) || tb[IPSET_ATTR_IP_TO] || tb[IPSET_ATTR_CIDR])) return -IPSET_ERR_PROTOCOL; @@ -490,13 +546,14 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[], if (ret) return ret; - if (tb[IPSET_ATTR_CIDR2]) - data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]); - - if (!data.cidr) - return -IPSET_ERR_INVALID_CIDR; + if (tb[IPSET_ATTR_CIDR2]) { + cidr = nla_get_u8(tb[IPSET_ATTR_CIDR2]); + if (!cidr || cidr > HOST_MASK) + return -IPSET_ERR_INVALID_CIDR; + data.cidr = cidr - 1; + } - ip6_netmask(&data.ip2, data.cidr); + ip6_netmask(&data.ip2, data.cidr + 1); if (tb[IPSET_ATTR_PORT]) data.port = nla_get_be16(tb[IPSET_ATTR_PORT]); @@ -521,6 +578,12 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[], timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); } + if (tb[IPSET_ATTR_CADT_FLAGS] && adt == IPSET_ADD) { + u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); + if (cadt_flags & IPSET_FLAG_NOMATCH) + flags |= (cadt_flags << 16); + } + if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) { ret = adtfn(set, &data, timeout, flags); return ip_set_eexist(ret, flags) ? 0 : ret; @@ -624,7 +687,8 @@ static struct ip_set_type hash_ipportnet_type __read_mostly = { .family = NFPROTO_UNSPEC, .revision_min = 0, /* 1 SCTP and UDPLITE support added */ - .revision_max = 2, /* Range as input support for IPv4 added */ + /* 2 Range as input support for IPv4 added */ + .revision_max = 3, /* nomatch flag support added */ .create = hash_ipportnet_create, .create_policy = { [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, @@ -643,6 +707,7 @@ static struct ip_set_type hash_ipportnet_type __read_mostly = { [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, [IPSET_ATTR_CIDR2] = { .type = NLA_U8 }, [IPSET_ATTR_PROTO] = { .type = NLA_U8 }, + [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, }, diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c index 5a4457adaf85..7c3d945517cf 100644 --- a/net/netfilter/ipset/ip_set_hash_net.c +++ b/net/netfilter/ipset/ip_set_hash_net.c @@ -43,7 +43,7 @@ hash_net_same_set(const struct ip_set *a, const struct ip_set *b); struct hash_net4_elem { __be32 ip; u16 padding0; - u8 padding1; + u8 nomatch; u8 cidr; }; @@ -51,7 +51,7 @@ struct hash_net4_elem { struct hash_net4_telem { __be32 ip; u16 padding0; - u8 padding1; + u8 nomatch; u8 cidr; unsigned long timeout; }; @@ -61,7 +61,8 @@ hash_net4_data_equal(const struct hash_net4_elem *ip1, const struct hash_net4_elem *ip2, u32 *multi) { - return ip1->ip == ip2->ip && ip1->cidr == ip2->cidr; + return ip1->ip == ip2->ip && + ip1->cidr == ip2->cidr; } static inline bool @@ -76,6 +77,19 @@ hash_net4_data_copy(struct hash_net4_elem *dst, { dst->ip = src->ip; dst->cidr = src->cidr; + dst->nomatch = src->nomatch; +} + +static inline void +hash_net4_data_flags(struct hash_net4_elem *dst, u32 flags) +{ + dst->nomatch = flags & IPSET_FLAG_NOMATCH; +} + +static inline bool +hash_net4_data_match(const struct hash_net4_elem *elem) +{ + return !elem->nomatch; } static inline void @@ -95,8 +109,12 @@ hash_net4_data_zero_out(struct hash_net4_elem *elem) static bool hash_net4_data_list(struct sk_buff *skb, const struct hash_net4_elem *data) { + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; + NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -108,11 +126,14 @@ hash_net4_data_tlist(struct sk_buff *skb, const struct hash_net4_elem *data) { const struct hash_net4_telem *tdata = (const struct hash_net4_telem *)data; + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, tdata->cidr); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(tdata->timeout))); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; @@ -167,7 +188,8 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[], int ret; if (unlikely(!tb[IPSET_ATTR_IP] || - !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT))) + !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || + !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) return -IPSET_ERR_PROTOCOL; if (tb[IPSET_ATTR_LINENO]) @@ -179,7 +201,7 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[], if (tb[IPSET_ATTR_CIDR]) { data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!data.cidr) + if (!data.cidr || data.cidr > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; } @@ -189,6 +211,12 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[], timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); } + if (tb[IPSET_ATTR_CADT_FLAGS] && adt == IPSET_ADD) { + u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); + if (cadt_flags & IPSET_FLAG_NOMATCH) + flags |= (cadt_flags << 16); + } + if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) { data.ip = htonl(ip & ip_set_hostmask(data.cidr)); ret = adtfn(set, &data, timeout, flags); @@ -236,14 +264,14 @@ hash_net_same_set(const struct ip_set *a, const struct ip_set *b) struct hash_net6_elem { union nf_inet_addr ip; u16 padding0; - u8 padding1; + u8 nomatch; u8 cidr; }; struct hash_net6_telem { union nf_inet_addr ip; u16 padding0; - u8 padding1; + u8 nomatch; u8 cidr; unsigned long timeout; }; @@ -269,6 +297,19 @@ hash_net6_data_copy(struct hash_net6_elem *dst, { dst->ip.in6 = src->ip.in6; dst->cidr = src->cidr; + dst->nomatch = src->nomatch; +} + +static inline void +hash_net6_data_flags(struct hash_net6_elem *dst, u32 flags) +{ + dst->nomatch = flags & IPSET_FLAG_NOMATCH; +} + +static inline bool +hash_net6_data_match(const struct hash_net6_elem *elem) +{ + return !elem->nomatch; } static inline void @@ -296,8 +337,12 @@ hash_net6_data_netmask(struct hash_net6_elem *elem, u8 cidr) static bool hash_net6_data_list(struct sk_buff *skb, const struct hash_net6_elem *data) { + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; + NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -309,11 +354,14 @@ hash_net6_data_tlist(struct sk_buff *skb, const struct hash_net6_elem *data) { const struct hash_net6_telem *e = (const struct hash_net6_telem *)data; + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, e->cidr); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(e->timeout))); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -366,7 +414,8 @@ hash_net6_uadt(struct ip_set *set, struct nlattr *tb[], int ret; if (unlikely(!tb[IPSET_ATTR_IP] || - !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT))) + !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || + !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) return -IPSET_ERR_PROTOCOL; if (unlikely(tb[IPSET_ATTR_IP_TO])) return -IPSET_ERR_HASH_RANGE_UNSUPPORTED; @@ -381,7 +430,7 @@ hash_net6_uadt(struct ip_set *set, struct nlattr *tb[], if (tb[IPSET_ATTR_CIDR]) data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!data.cidr) + if (!data.cidr || data.cidr > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; ip6_netmask(&data.ip, data.cidr); @@ -392,6 +441,12 @@ hash_net6_uadt(struct ip_set *set, struct nlattr *tb[], timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); } + if (tb[IPSET_ATTR_CADT_FLAGS] && adt == IPSET_ADD) { + u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); + if (cadt_flags & IPSET_FLAG_NOMATCH) + flags |= (cadt_flags << 16); + } + ret = adtfn(set, &data, timeout, flags); return ip_set_eexist(ret, flags) ? 0 : ret; @@ -474,7 +529,8 @@ static struct ip_set_type hash_net_type __read_mostly = { .dimension = IPSET_DIM_ONE, .family = NFPROTO_UNSPEC, .revision_min = 0, - .revision_max = 1, /* Range as input support for IPv4 added */ + /* = 1 Range as input support for IPv4 added */ + .revision_max = 2, /* nomatch flag support added */ .create = hash_net_create, .create_policy = { [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, @@ -488,6 +544,7 @@ static struct ip_set_type hash_net_type __read_mostly = { [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED }, [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, + [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, }, .me = THIS_MODULE, }; diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c index a9fb4afafa8b..f24037ff4322 100644 --- a/net/netfilter/ipset/ip_set_hash_netiface.c +++ b/net/netfilter/ipset/ip_set_hash_netiface.c @@ -163,7 +163,8 @@ struct hash_netiface4_elem_hashed { __be32 ip; u8 physdev; u8 cidr; - u16 padding; + u8 nomatch; + u8 padding; }; #define HKEY_DATALEN sizeof(struct hash_netiface4_elem_hashed) @@ -173,7 +174,8 @@ struct hash_netiface4_elem { __be32 ip; u8 physdev; u8 cidr; - u16 padding; + u8 nomatch; + u8 padding; const char *iface; }; @@ -182,7 +184,8 @@ struct hash_netiface4_telem { __be32 ip; u8 physdev; u8 cidr; - u16 padding; + u8 nomatch; + u8 padding; const char *iface; unsigned long timeout; }; @@ -207,11 +210,25 @@ hash_netiface4_data_isnull(const struct hash_netiface4_elem *elem) static inline void hash_netiface4_data_copy(struct hash_netiface4_elem *dst, - const struct hash_netiface4_elem *src) { + const struct hash_netiface4_elem *src) +{ dst->ip = src->ip; dst->cidr = src->cidr; dst->physdev = src->physdev; dst->iface = src->iface; + dst->nomatch = src->nomatch; +} + +static inline void +hash_netiface4_data_flags(struct hash_netiface4_elem *dst, u32 flags) +{ + dst->nomatch = flags & IPSET_FLAG_NOMATCH; +} + +static inline bool +hash_netiface4_data_match(const struct hash_netiface4_elem *elem) +{ + return !elem->nomatch; } static inline void @@ -233,11 +250,13 @@ hash_netiface4_data_list(struct sk_buff *skb, { u32 flags = data->physdev ? IPSET_FLAG_PHYSDEV : 0; + if (data->nomatch) + flags |= IPSET_FLAG_NOMATCH; NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); if (flags) - NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, flags); + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -252,11 +271,13 @@ hash_netiface4_data_tlist(struct sk_buff *skb, (const struct hash_netiface4_telem *)data; u32 flags = data->physdev ? IPSET_FLAG_PHYSDEV : 0; + if (data->nomatch) + flags |= IPSET_FLAG_NOMATCH; NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); if (flags) - NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, flags); + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(tdata->timeout))); @@ -361,7 +382,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[], if (tb[IPSET_ATTR_CIDR]) { data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!data.cidr) + if (!data.cidr || data.cidr > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; } @@ -387,6 +408,8 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[], u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); if (cadt_flags & IPSET_FLAG_PHYSDEV) data.physdev = 1; + if (adt == IPSET_ADD && (cadt_flags & IPSET_FLAG_NOMATCH)) + flags |= (cadt_flags << 16); } if (adt == IPSET_TEST || !tb[IPSET_ATTR_IP_TO]) { @@ -440,7 +463,8 @@ struct hash_netiface6_elem_hashed { union nf_inet_addr ip; u8 physdev; u8 cidr; - u16 padding; + u8 nomatch; + u8 padding; }; #define HKEY_DATALEN sizeof(struct hash_netiface6_elem_hashed) @@ -449,7 +473,8 @@ struct hash_netiface6_elem { union nf_inet_addr ip; u8 physdev; u8 cidr; - u16 padding; + u8 nomatch; + u8 padding; const char *iface; }; @@ -457,7 +482,8 @@ struct hash_netiface6_telem { union nf_inet_addr ip; u8 physdev; u8 cidr; - u16 padding; + u8 nomatch; + u8 padding; const char *iface; unsigned long timeout; }; @@ -487,9 +513,22 @@ hash_netiface6_data_copy(struct hash_netiface6_elem *dst, memcpy(dst, src, sizeof(*dst)); } +static inline void +hash_netiface6_data_flags(struct hash_netiface6_elem *dst, u32 flags) +{ + dst->nomatch = flags & IPSET_FLAG_NOMATCH; +} + +static inline bool +hash_netiface6_data_match(const struct hash_netiface6_elem *elem) +{ + return !elem->nomatch; +} + static inline void hash_netiface6_data_zero_out(struct hash_netiface6_elem *elem) { + elem->cidr = 0; } static inline void @@ -514,11 +553,13 @@ hash_netiface6_data_list(struct sk_buff *skb, { u32 flags = data->physdev ? IPSET_FLAG_PHYSDEV : 0; + if (data->nomatch) + flags |= IPSET_FLAG_NOMATCH; NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); if (flags) - NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, flags); + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -533,11 +574,13 @@ hash_netiface6_data_tlist(struct sk_buff *skb, (const struct hash_netiface6_telem *)data; u32 flags = data->physdev ? IPSET_FLAG_PHYSDEV : 0; + if (data->nomatch) + flags |= IPSET_FLAG_NOMATCH; NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); NLA_PUT_STRING(skb, IPSET_ATTR_IFACE, data->iface); if (flags) - NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, flags); + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(e->timeout))); return 0; @@ -636,7 +679,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[], if (tb[IPSET_ATTR_CIDR]) data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!data.cidr) + if (!data.cidr || data.cidr > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; ip6_netmask(&data.ip, data.cidr); @@ -662,6 +705,8 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[], u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); if (cadt_flags & IPSET_FLAG_PHYSDEV) data.physdev = 1; + if (adt == IPSET_ADD && (cadt_flags & IPSET_FLAG_NOMATCH)) + flags |= (cadt_flags << 16); } ret = adtfn(set, &data, timeout, flags); @@ -748,6 +793,7 @@ static struct ip_set_type hash_netiface_type __read_mostly = { .dimension = IPSET_DIM_TWO, .family = NFPROTO_UNSPEC, .revision_min = 0, + .revision_max = 1, /* nomatch flag support added */ .create = hash_netiface_create, .create_policy = { [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c index 1fcc1020eaae..ce2e77100b64 100644 --- a/net/netfilter/ipset/ip_set_hash_netport.c +++ b/net/netfilter/ipset/ip_set_hash_netport.c @@ -40,12 +40,19 @@ hash_netport_same_set(const struct ip_set *a, const struct ip_set *b); /* The type variant functions: IPv4 */ +/* We squeeze the "nomatch" flag into cidr: we don't support cidr == 0 + * However this way we have to store internally cidr - 1, + * dancing back and forth. + */ +#define IP_SET_HASH_WITH_NETS_PACKED + /* Member elements without timeout */ struct hash_netport4_elem { __be32 ip; __be16 port; u8 proto; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; }; /* Member elements with timeout support */ @@ -53,7 +60,8 @@ struct hash_netport4_telem { __be32 ip; __be16 port; u8 proto; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; unsigned long timeout; }; @@ -82,13 +90,26 @@ hash_netport4_data_copy(struct hash_netport4_elem *dst, dst->port = src->port; dst->proto = src->proto; dst->cidr = src->cidr; + dst->nomatch = src->nomatch; +} + +static inline void +hash_netport4_data_flags(struct hash_netport4_elem *dst, u32 flags) +{ + dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH); +} + +static inline bool +hash_netport4_data_match(const struct hash_netport4_elem *elem) +{ + return !elem->nomatch; } static inline void hash_netport4_data_netmask(struct hash_netport4_elem *elem, u8 cidr) { elem->ip &= ip_set_netmask(cidr); - elem->cidr = cidr; + elem->cidr = cidr - 1; } static inline void @@ -101,10 +122,14 @@ static bool hash_netport4_data_list(struct sk_buff *skb, const struct hash_netport4_elem *data) { + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; + NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -117,13 +142,16 @@ hash_netport4_data_tlist(struct sk_buff *skb, { const struct hash_netport4_telem *tdata = (const struct hash_netport4_telem *)data; + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, tdata->ip); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, tdata->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(tdata->timeout))); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; @@ -154,20 +182,18 @@ hash_netport4_kadt(struct ip_set *set, const struct sk_buff *skb, const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; struct hash_netport4_elem data = { - .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK + .cidr = h->nets[0].cidr ? h->nets[0].cidr - 1 : HOST_MASK - 1 }; - if (data.cidr == 0) - return -EINVAL; if (adt == IPSET_TEST) - data.cidr = HOST_MASK; + data.cidr = HOST_MASK - 1; if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC, &data.port, &data.proto)) return -EINVAL; ip4addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip); - data.ip &= ip_set_netmask(data.cidr); + data.ip &= ip_set_netmask(data.cidr + 1); return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); } @@ -178,16 +204,18 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[], { const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; - struct hash_netport4_elem data = { .cidr = HOST_MASK }; + struct hash_netport4_elem data = { .cidr = HOST_MASK - 1 }; u32 port, port_to, p = 0, ip = 0, ip_to, last; u32 timeout = h->timeout; bool with_ports = false; + u8 cidr; int ret; if (unlikely(!tb[IPSET_ATTR_IP] || !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || - !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT))) + !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || + !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) return -IPSET_ERR_PROTOCOL; if (tb[IPSET_ATTR_LINENO]) @@ -198,9 +226,10 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[], return ret; if (tb[IPSET_ATTR_CIDR]) { - data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!data.cidr) + cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); + if (!cidr || cidr > HOST_MASK) return -IPSET_ERR_INVALID_CIDR; + data.cidr = cidr - 1; } if (tb[IPSET_ATTR_PORT]) @@ -227,8 +256,15 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[], } with_ports = with_ports && tb[IPSET_ATTR_PORT_TO]; + + if (tb[IPSET_ATTR_CADT_FLAGS] && adt == IPSET_ADD) { + u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); + if (cadt_flags & IPSET_FLAG_NOMATCH) + flags |= (cadt_flags << 16); + } + if (adt == IPSET_TEST || !(with_ports || tb[IPSET_ATTR_IP_TO])) { - data.ip = htonl(ip & ip_set_hostmask(data.cidr)); + data.ip = htonl(ip & ip_set_hostmask(data.cidr + 1)); ret = adtfn(set, &data, timeout, flags); return ip_set_eexist(ret, flags) ? 0 : ret; } @@ -248,14 +284,15 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[], if (ip + UINT_MAX == ip_to) return -IPSET_ERR_HASH_RANGE; } else { - ip_set_mask_from_to(ip, ip_to, data.cidr); + ip_set_mask_from_to(ip, ip_to, data.cidr + 1); } if (retried) ip = h->next.ip; while (!after(ip, ip_to)) { data.ip = htonl(ip); - last = ip_set_range_to_cidr(ip, ip_to, &data.cidr); + last = ip_set_range_to_cidr(ip, ip_to, &cidr); + data.cidr = cidr - 1; p = retried && ip == h->next.ip ? h->next.port : port; for (; p <= port_to; p++) { data.port = htons(p); @@ -288,14 +325,16 @@ struct hash_netport6_elem { union nf_inet_addr ip; __be16 port; u8 proto; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; }; struct hash_netport6_telem { union nf_inet_addr ip; __be16 port; u8 proto; - u8 cidr; + u8 cidr:7; + u8 nomatch:1; unsigned long timeout; }; @@ -323,6 +362,18 @@ hash_netport6_data_copy(struct hash_netport6_elem *dst, memcpy(dst, src, sizeof(*dst)); } +static inline void +hash_netport6_data_flags(struct hash_netport6_elem *dst, u32 flags) +{ + dst->nomatch = !!(flags & IPSET_FLAG_NOMATCH); +} + +static inline bool +hash_netport6_data_match(const struct hash_netport6_elem *elem) +{ + return !elem->nomatch; +} + static inline void hash_netport6_data_zero_out(struct hash_netport6_elem *elem) { @@ -342,17 +393,21 @@ static inline void hash_netport6_data_netmask(struct hash_netport6_elem *elem, u8 cidr) { ip6_netmask(&elem->ip, cidr); - elem->cidr = cidr; + elem->cidr = cidr - 1; } static bool hash_netport6_data_list(struct sk_buff *skb, const struct hash_netport6_elem *data) { + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; + NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &data->ip); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -365,13 +420,16 @@ hash_netport6_data_tlist(struct sk_buff *skb, { const struct hash_netport6_telem *e = (const struct hash_netport6_telem *)data; + u32 flags = data->nomatch ? IPSET_FLAG_NOMATCH : 0; NLA_PUT_IPADDR6(skb, IPSET_ATTR_IP, &e->ip); NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port); - NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr); + NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr + 1); NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto); NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(ip_set_timeout_get(e->timeout))); + if (flags) + NLA_PUT_NET32(skb, IPSET_ATTR_CADT_FLAGS, htonl(flags)); return 0; nla_put_failure: @@ -400,20 +458,18 @@ hash_netport6_kadt(struct ip_set *set, const struct sk_buff *skb, const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; struct hash_netport6_elem data = { - .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK + .cidr = h->nets[0].cidr ? h->nets[0].cidr - 1 : HOST_MASK - 1, }; - if (data.cidr == 0) - return -EINVAL; if (adt == IPSET_TEST) - data.cidr = HOST_MASK; + data.cidr = HOST_MASK - 1; if (!ip_set_get_ip6_port(skb, opt->flags & IPSET_DIM_TWO_SRC, &data.port, &data.proto)) return -EINVAL; ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &data.ip.in6); - ip6_netmask(&data.ip, data.cidr); + ip6_netmask(&data.ip, data.cidr + 1); return adtfn(set, &data, opt_timeout(opt, h), opt->cmdflags); } @@ -424,16 +480,18 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[], { const struct ip_set_hash *h = set->data; ipset_adtfn adtfn = set->variant->adt[adt]; - struct hash_netport6_elem data = { .cidr = HOST_MASK }; + struct hash_netport6_elem data = { .cidr = HOST_MASK - 1 }; u32 port, port_to; u32 timeout = h->timeout; bool with_ports = false; + u8 cidr; int ret; if (unlikely(!tb[IPSET_ATTR_IP] || !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || - !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT))) + !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || + !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS))) return -IPSET_ERR_PROTOCOL; if (unlikely(tb[IPSET_ATTR_IP_TO])) return -IPSET_ERR_HASH_RANGE_UNSUPPORTED; @@ -445,11 +503,13 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[], if (ret) return ret; - if (tb[IPSET_ATTR_CIDR]) - data.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); - if (!data.cidr) - return -IPSET_ERR_INVALID_CIDR; - ip6_netmask(&data.ip, data.cidr); + if (tb[IPSET_ATTR_CIDR]) { + cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]); + if (!cidr || cidr > HOST_MASK) + return -IPSET_ERR_INVALID_CIDR; + data.cidr = cidr - 1; + } + ip6_netmask(&data.ip, data.cidr + 1); if (tb[IPSET_ATTR_PORT]) data.port = nla_get_be16(tb[IPSET_ATTR_PORT]); @@ -474,6 +534,12 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[], timeout = ip_set_timeout_uget(tb[IPSET_ATTR_TIMEOUT]); } + if (tb[IPSET_ATTR_CADT_FLAGS] && adt == IPSET_ADD) { + u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]); + if (cadt_flags & IPSET_FLAG_NOMATCH) + flags |= (cadt_flags << 16); + } + if (adt == IPSET_TEST || !with_ports || !tb[IPSET_ATTR_PORT_TO]) { ret = adtfn(set, &data, timeout, flags); return ip_set_eexist(ret, flags) ? 0 : ret; @@ -576,7 +642,8 @@ static struct ip_set_type hash_netport_type __read_mostly = { .family = NFPROTO_UNSPEC, .revision_min = 0, /* 1 SCTP and UDPLITE support added */ - .revision_max = 2, /* Range as input support for IPv4 added */ + /* 2, Range as input support for IPv4 added */ + .revision_max = 3, /* nomatch flag support added */ .create = hash_netport_create, .create_policy = { [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, @@ -595,6 +662,7 @@ static struct ip_set_type hash_netport_type __read_mostly = { [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, [IPSET_ATTR_LINENO] = { .type = NLA_U32 }, + [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, }, .me = THIS_MODULE, }; -- GitLab From 7f81c951d961bef0bf9aa55449654302b9da8185 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Fri, 13 Jan 2012 22:55:54 +0100 Subject: [PATCH 1489/1846] netfilter: ipset: hash:net,iface timeout bug fixed Timed out entries were still matched till the garbage collector purged them out. The fix is verified in the testsuite. Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/ipset/ip_set_ahash.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/netfilter/ipset/ip_set_ahash.h b/include/linux/netfilter/ipset/ip_set_ahash.h index 0e5c3cf7618a..05a5d72680be 100644 --- a/include/linux/netfilter/ipset/ip_set_ahash.h +++ b/include/linux/netfilter/ipset/ip_set_ahash.h @@ -1005,9 +1005,17 @@ type_pf_ttest_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout) n = hbucket(t, key); for (i = 0; i < n->pos; i++) { data = ahash_tdata(n, i); +#ifdef IP_SET_HASH_WITH_MULTI + if (type_pf_data_equal(data, d, &multi)) { + if (!type_pf_data_expired(data)) + return type_pf_data_match(data); + multi = 0; + } +#else if (type_pf_data_equal(data, d, &multi) && !type_pf_data_expired(data)) return type_pf_data_match(data); +#endif } } return 0; -- GitLab From 660fdb2a0f5f670da4728d7028d3227296e0226c Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 5 Feb 2012 02:34:16 +0100 Subject: [PATCH 1490/1846] netfilter: ctnetlink: allow to set helper for new expectations This patch allow you to set the helper for newly created expectations based of the CTA_EXPECT_HELP_NAME attribute. Before this, the helper set was NULL. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_netlink.c | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 04fb409623d2..1b0aea620d62 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -2042,6 +2042,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, struct nf_conntrack_expect *exp; struct nf_conn *ct; struct nf_conn_help *help; + struct nf_conntrack_helper *helper = NULL; int err = 0; /* caller guarantees that those three CTA_EXPECT_* exist */ @@ -2060,6 +2061,33 @@ ctnetlink_create_expect(struct net *net, u16 zone, if (!h) return -ENOENT; ct = nf_ct_tuplehash_to_ctrack(h); + + /* Look for helper of this expectation */ + if (cda[CTA_EXPECT_HELP_NAME]) { + const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]); + + helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct), + nf_ct_protonum(ct)); + if (helper == NULL) { +#ifdef CONFIG_MODULES + if (request_module("nfct-helper-%s", helpname) < 0) { + err = -EOPNOTSUPP; + goto out; + } + + helper = __nf_conntrack_helper_find(helpname, + nf_ct_l3num(ct), + nf_ct_protonum(ct)); + if (helper) { + err = -EAGAIN; + goto out; + } +#endif + err = -EOPNOTSUPP; + goto out; + } + } + exp = nf_ct_expect_alloc(ct); if (!exp) { err = -ENOMEM; @@ -2090,7 +2118,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, exp->class = 0; exp->expectfn = NULL; exp->master = ct; - exp->helper = NULL; + exp->helper = helper; memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple)); memcpy(&exp->mask.src.u3, &mask.src.u3, sizeof(exp->mask.src.u3)); exp->mask.src.u.all = mask.src.u.all; -- GitLab From b8c5e52c13edc99ce192d78c8a7fe2fd626ac643 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 5 Feb 2012 03:21:12 +0100 Subject: [PATCH 1491/1846] netfilter: ctnetlink: allow to set expectation class This patch allows you to set the expectation class. Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/nfnetlink_conntrack.h | 1 + net/netfilter/nf_conntrack_netlink.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index d498a4426ebf..557a0cfb1433 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -173,6 +173,7 @@ enum ctattr_expect { CTA_EXPECT_HELP_NAME, CTA_EXPECT_ZONE, CTA_EXPECT_FLAGS, + CTA_EXPECT_CLASS, __CTA_EXPECT_MAX }; #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 1b0aea620d62..b6ea39770c80 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -1691,6 +1691,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, NLA_PUT_BE32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout)); NLA_PUT_BE32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp)); NLA_PUT_BE32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags)); + NLA_PUT_BE32(skb, CTA_EXPECT_CLASS, htonl(exp->class)); help = nfct_help(master); if (help) { struct nf_conntrack_helper *helper; @@ -1856,6 +1857,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING }, [CTA_EXPECT_ZONE] = { .type = NLA_U16 }, [CTA_EXPECT_FLAGS] = { .type = NLA_U32 }, + [CTA_EXPECT_CLASS] = { .type = NLA_U32 }, }; static int @@ -2043,6 +2045,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, struct nf_conn *ct; struct nf_conn_help *help; struct nf_conntrack_helper *helper = NULL; + u_int32_t class = 0; int err = 0; /* caller guarantees that those three CTA_EXPECT_* exist */ @@ -2088,6 +2091,13 @@ ctnetlink_create_expect(struct net *net, u16 zone, } } + if (cda[CTA_EXPECT_CLASS] && helper) { + class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS])); + if (class > helper->expect_class_max) { + err = -EINVAL; + goto out; + } + } exp = nf_ct_expect_alloc(ct); if (!exp) { err = -ENOMEM; @@ -2115,7 +2125,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, exp->flags = 0; } - exp->class = 0; + exp->class = class; exp->expectfn = NULL; exp->master = ct; exp->helper = helper; -- GitLab From 076a0ca02644657b13e4af363f487ced2942e9cb Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 5 Feb 2012 03:41:52 +0100 Subject: [PATCH 1492/1846] netfilter: ctnetlink: add NAT support for expectations This patch adds the missing bits to create expectations that are created in NAT setups. --- include/linux/netfilter/nfnetlink_conntrack.h | 9 +++ net/netfilter/nf_conntrack_netlink.c | 68 ++++++++++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index 557a0cfb1433..a2f1f483ecc9 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -174,10 +174,19 @@ enum ctattr_expect { CTA_EXPECT_ZONE, CTA_EXPECT_FLAGS, CTA_EXPECT_CLASS, + CTA_EXPECT_NAT, __CTA_EXPECT_MAX }; #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) +enum ctattr_expect_nat { + CTA_EXPECT_NAT_UNSPEC, + CTA_EXPECT_NAT_DIR, + CTA_EXPECT_NAT_TUPLE, + __CTA_EXPECT_NAT_MAX +}; +#define CTA_EXPECT_NAT_MAX (__CTA_EXPECT_NAT_MAX - 1) + enum ctattr_help { CTA_HELP_UNSPEC, CTA_HELP_NAME, diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index b6ea39770c80..845c8ca28563 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -1675,7 +1675,10 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, struct nf_conn *master = exp->master; long timeout = ((long)exp->timeout.expires - (long)jiffies) / HZ; struct nf_conn_help *help; - +#ifdef CONFIG_NF_NAT_NEEDED + struct nlattr *nest_parms; + struct nf_conntrack_tuple nat_tuple = {}; +#endif if (timeout < 0) timeout = 0; @@ -1688,6 +1691,25 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, CTA_EXPECT_MASTER) < 0) goto nla_put_failure; +#ifdef CONFIG_NF_NAT_NEEDED + if (exp->saved_ip || exp->saved_proto.all) { + nest_parms = nla_nest_start(skb, CTA_EXPECT_NAT | NLA_F_NESTED); + if (!nest_parms) + goto nla_put_failure; + + NLA_PUT_BE32(skb, CTA_EXPECT_NAT_DIR, htonl(exp->dir)); + + nat_tuple.src.l3num = nf_ct_l3num(master); + nat_tuple.src.u3.ip = exp->saved_ip; + nat_tuple.dst.protonum = nf_ct_protonum(master); + nat_tuple.src.u = exp->saved_proto; + + if (ctnetlink_exp_dump_tuple(skb, &nat_tuple, + CTA_EXPECT_NAT_TUPLE) < 0) + goto nla_put_failure; + nla_nest_end(skb, nest_parms); + } +#endif NLA_PUT_BE32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout)); NLA_PUT_BE32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp)); NLA_PUT_BE32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags)); @@ -1858,6 +1880,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { [CTA_EXPECT_ZONE] = { .type = NLA_U16 }, [CTA_EXPECT_FLAGS] = { .type = NLA_U32 }, [CTA_EXPECT_CLASS] = { .type = NLA_U32 }, + [CTA_EXPECT_NAT] = { .type = NLA_NESTED }, }; static int @@ -2033,6 +2056,41 @@ ctnetlink_change_expect(struct nf_conntrack_expect *x, return -EOPNOTSUPP; } +static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX+1] = { + [CTA_EXPECT_NAT_DIR] = { .type = NLA_U32 }, + [CTA_EXPECT_NAT_TUPLE] = { .type = NLA_NESTED }, +}; + +static int +ctnetlink_parse_expect_nat(const struct nlattr *attr, + struct nf_conntrack_expect *exp, + u_int8_t u3) +{ +#ifdef CONFIG_NF_NAT_NEEDED + struct nlattr *tb[CTA_EXPECT_NAT_MAX+1]; + struct nf_conntrack_tuple nat_tuple = {}; + int err; + + nla_parse_nested(tb, CTA_EXPECT_NAT_MAX, attr, exp_nat_nla_policy); + + if (!tb[CTA_EXPECT_NAT_DIR] || !tb[CTA_EXPECT_NAT_TUPLE]) + return -EINVAL; + + err = ctnetlink_parse_tuple((const struct nlattr * const *)tb, + &nat_tuple, CTA_EXPECT_NAT_TUPLE, u3); + if (err < 0) + return err; + + exp->saved_ip = nat_tuple.src.u3.ip; + exp->saved_proto = nat_tuple.src.u; + exp->dir = ntohl(nla_get_be32(tb[CTA_EXPECT_NAT_DIR])); + + return 0; +#else + return -EOPNOTSUPP; +#endif +} + static int ctnetlink_create_expect(struct net *net, u16 zone, const struct nlattr * const cda[], @@ -2133,9 +2191,15 @@ ctnetlink_create_expect(struct net *net, u16 zone, memcpy(&exp->mask.src.u3, &mask.src.u3, sizeof(exp->mask.src.u3)); exp->mask.src.u.all = mask.src.u.all; + if (cda[CTA_EXPECT_NAT]) { + err = ctnetlink_parse_expect_nat(cda[CTA_EXPECT_NAT], + exp, u3); + if (err < 0) + goto err_out; + } err = nf_ct_expect_related_report(exp, pid, report); +err_out: nf_ct_expect_put(exp); - out: nf_ct_put(nf_ct_tuplehash_to_ctrack(h)); return err; -- GitLab From 544d5c7d9f4d1ec4f170bc5bcc522012cb7704bc Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 5 Feb 2012 03:44:51 +0100 Subject: [PATCH 1493/1846] netfilter: ctnetlink: allow to set expectfn for expectations This patch allows you to set expectfn which is specifically used by the NAT side of most of the existing conntrack helpers. I have added a symbol map that uses a string as key to look up for the function that is attached to the expectation object. This is the best solution I came out with to solve this issue. Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/nfnetlink_conntrack.h | 1 + include/net/netfilter/nf_conntrack_helper.h | 13 +++++ net/ipv4/netfilter/nf_nat_core.c | 8 +++ net/ipv4/netfilter/nf_nat_h323.c | 14 +++++ net/ipv4/netfilter/nf_nat_sip.c | 7 +++ net/netfilter/nf_conntrack_helper.c | 54 +++++++++++++++++++ net/netfilter/nf_conntrack_netlink.c | 19 ++++++- 7 files changed, 115 insertions(+), 1 deletion(-) diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index a2f1f483ecc9..e58e4b93c108 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -175,6 +175,7 @@ enum ctattr_expect { CTA_EXPECT_FLAGS, CTA_EXPECT_CLASS, CTA_EXPECT_NAT, + CTA_EXPECT_FN, __CTA_EXPECT_MAX }; #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h index f1c1311adc2c..5767dc242dee 100644 --- a/include/net/netfilter/nf_conntrack_helper.h +++ b/include/net/netfilter/nf_conntrack_helper.h @@ -69,4 +69,17 @@ extern int nf_conntrack_broadcast_help(struct sk_buff *skb, enum ip_conntrack_info ctinfo, unsigned int timeout); +struct nf_ct_helper_expectfn { + struct list_head head; + const char *name; + void (*expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp); +}; + +void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n); +void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n); +struct nf_ct_helper_expectfn * +nf_ct_helper_expectfn_find_by_name(const char *name); +struct nf_ct_helper_expectfn * +nf_ct_helper_expectfn_find_by_symbol(const void *symbol); + #endif /*_NF_CONNTRACK_HELPER_H*/ diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index a708933dc230..abb52adf5acd 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c @@ -686,6 +686,11 @@ static struct pernet_operations nf_nat_net_ops = { .exit = nf_nat_net_exit, }; +static struct nf_ct_helper_expectfn follow_master_nat = { + .name = "nat-follow-master", + .expectfn = nf_nat_follow_master, +}; + static int __init nf_nat_init(void) { size_t i; @@ -717,6 +722,8 @@ static int __init nf_nat_init(void) l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET); + nf_ct_helper_expectfn_register(&follow_master_nat); + BUG_ON(nf_nat_seq_adjust_hook != NULL); RCU_INIT_POINTER(nf_nat_seq_adjust_hook, nf_nat_seq_adjust); BUG_ON(nfnetlink_parse_nat_setup_hook != NULL); @@ -736,6 +743,7 @@ static void __exit nf_nat_cleanup(void) unregister_pernet_subsys(&nf_nat_net_ops); nf_ct_l3proto_put(l3proto); nf_ct_extend_unregister(&nat_extend); + nf_ct_helper_expectfn_unregister(&follow_master_nat); RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL); RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL); RCU_INIT_POINTER(nf_ct_nat_offset, NULL); diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c index dc1dd912baf4..82536701e3a3 100644 --- a/net/ipv4/netfilter/nf_nat_h323.c +++ b/net/ipv4/netfilter/nf_nat_h323.c @@ -568,6 +568,16 @@ static int nat_callforwarding(struct sk_buff *skb, struct nf_conn *ct, return 0; } +static struct nf_ct_helper_expectfn q931_nat = { + .name = "Q.931", + .expectfn = ip_nat_q931_expect, +}; + +static struct nf_ct_helper_expectfn callforwarding_nat = { + .name = "callforwarding", + .expectfn = ip_nat_callforwarding_expect, +}; + /****************************************************************************/ static int __init init(void) { @@ -590,6 +600,8 @@ static int __init init(void) RCU_INIT_POINTER(nat_h245_hook, nat_h245); RCU_INIT_POINTER(nat_callforwarding_hook, nat_callforwarding); RCU_INIT_POINTER(nat_q931_hook, nat_q931); + nf_ct_helper_expectfn_register(&q931_nat); + nf_ct_helper_expectfn_register(&callforwarding_nat); return 0; } @@ -605,6 +617,8 @@ static void __exit fini(void) RCU_INIT_POINTER(nat_h245_hook, NULL); RCU_INIT_POINTER(nat_callforwarding_hook, NULL); RCU_INIT_POINTER(nat_q931_hook, NULL); + nf_ct_helper_expectfn_unregister(&q931_nat); + nf_ct_helper_expectfn_unregister(&callforwarding_nat); synchronize_rcu(); } diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c index d0319f96269f..57932c43960e 100644 --- a/net/ipv4/netfilter/nf_nat_sip.c +++ b/net/ipv4/netfilter/nf_nat_sip.c @@ -526,6 +526,11 @@ static unsigned int ip_nat_sdp_media(struct sk_buff *skb, unsigned int dataoff, return NF_DROP; } +static struct nf_ct_helper_expectfn sip_nat = { + .name = "sip", + .expectfn = ip_nat_sip_expected, +}; + static void __exit nf_nat_sip_fini(void) { RCU_INIT_POINTER(nf_nat_sip_hook, NULL); @@ -535,6 +540,7 @@ static void __exit nf_nat_sip_fini(void) RCU_INIT_POINTER(nf_nat_sdp_port_hook, NULL); RCU_INIT_POINTER(nf_nat_sdp_session_hook, NULL); RCU_INIT_POINTER(nf_nat_sdp_media_hook, NULL); + nf_ct_helper_expectfn_unregister(&sip_nat); synchronize_rcu(); } @@ -554,6 +560,7 @@ static int __init nf_nat_sip_init(void) RCU_INIT_POINTER(nf_nat_sdp_port_hook, ip_nat_sdp_port); RCU_INIT_POINTER(nf_nat_sdp_session_hook, ip_nat_sdp_session); RCU_INIT_POINTER(nf_nat_sdp_media_hook, ip_nat_sdp_media); + nf_ct_helper_expectfn_register(&sip_nat); return 0; } diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c index bbe23baa19b6..436b7cb79ba4 100644 --- a/net/netfilter/nf_conntrack_helper.c +++ b/net/netfilter/nf_conntrack_helper.c @@ -181,6 +181,60 @@ void nf_ct_helper_destroy(struct nf_conn *ct) } } +static LIST_HEAD(nf_ct_helper_expectfn_list); + +void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n) +{ + spin_lock_bh(&nf_conntrack_lock); + list_add_rcu(&n->head, &nf_ct_helper_expectfn_list); + spin_unlock_bh(&nf_conntrack_lock); +} +EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_register); + +void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n) +{ + spin_lock_bh(&nf_conntrack_lock); + list_del_rcu(&n->head); + spin_unlock_bh(&nf_conntrack_lock); +} +EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_unregister); + +struct nf_ct_helper_expectfn * +nf_ct_helper_expectfn_find_by_name(const char *name) +{ + struct nf_ct_helper_expectfn *cur; + bool found = false; + + rcu_read_lock(); + list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { + if (!strcmp(cur->name, name)) { + found = true; + break; + } + } + rcu_read_unlock(); + return found ? cur : NULL; +} +EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_name); + +struct nf_ct_helper_expectfn * +nf_ct_helper_expectfn_find_by_symbol(const void *symbol) +{ + struct nf_ct_helper_expectfn *cur; + bool found = false; + + rcu_read_lock(); + list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { + if (cur->expectfn == symbol) { + found = true; + break; + } + } + rcu_read_unlock(); + return found ? cur : NULL; +} +EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_symbol); + int nf_conntrack_helper_register(struct nf_conntrack_helper *me) { unsigned int h = helper_hash(&me->tuple); diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 845c8ca28563..b8827e8a11fe 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -1679,6 +1679,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, struct nlattr *nest_parms; struct nf_conntrack_tuple nat_tuple = {}; #endif + struct nf_ct_helper_expectfn *expfn; + if (timeout < 0) timeout = 0; @@ -1722,6 +1724,9 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, if (helper) NLA_PUT_STRING(skb, CTA_EXPECT_HELP_NAME, helper->name); } + expfn = nf_ct_helper_expectfn_find_by_symbol(exp->expectfn); + if (expfn != NULL) + NLA_PUT_STRING(skb, CTA_EXPECT_FN, expfn->name); return 0; @@ -1881,6 +1886,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { [CTA_EXPECT_FLAGS] = { .type = NLA_U32 }, [CTA_EXPECT_CLASS] = { .type = NLA_U32 }, [CTA_EXPECT_NAT] = { .type = NLA_NESTED }, + [CTA_EXPECT_FN] = { .type = NLA_NUL_STRING }, }; static int @@ -2182,9 +2188,20 @@ ctnetlink_create_expect(struct net *net, u16 zone, } else exp->flags = 0; } + if (cda[CTA_EXPECT_FN]) { + const char *name = nla_data(cda[CTA_EXPECT_FN]); + struct nf_ct_helper_expectfn *expfn; + + expfn = nf_ct_helper_expectfn_find_by_name(name); + if (expfn == NULL) { + err = -EINVAL; + goto err_out; + } + exp->expectfn = expfn->expectfn; + } else + exp->expectfn = NULL; exp->class = class; - exp->expectfn = NULL; exp->master = ct; exp->helper = helper; memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple)); -- GitLab From 6939c33a757bd006c5e0b8b5fd429fc587a4d0f4 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Fri, 10 Feb 2012 23:10:52 +0100 Subject: [PATCH 1494/1846] netfilter: merge ipt_LOG and ip6_LOG into xt_LOG ipt_LOG and ip6_LOG have a lot of common code, merge them to reduce duplicate code. Signed-off-by: Richard Weinberger Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/Kbuild | 1 + include/linux/netfilter/xt_LOG.h | 19 + include/linux/netfilter_ipv4/ipt_LOG.h | 2 + include/linux/netfilter_ipv6/ip6t_LOG.h | 2 + net/ipv4/netfilter/Kconfig | 9 - net/ipv4/netfilter/Makefile | 1 - net/ipv4/netfilter/ipt_LOG.c | 516 ------------- net/ipv6/netfilter/Kconfig | 9 - net/ipv6/netfilter/Makefile | 1 - net/ipv6/netfilter/ip6t_LOG.c | 527 -------------- net/netfilter/Kconfig | 9 + net/netfilter/Makefile | 1 + net/netfilter/xt_LOG.c | 921 ++++++++++++++++++++++++ 13 files changed, 955 insertions(+), 1063 deletions(-) create mode 100644 include/linux/netfilter/xt_LOG.h delete mode 100644 net/ipv4/netfilter/ipt_LOG.c delete mode 100644 net/ipv6/netfilter/ip6t_LOG.c create mode 100644 net/netfilter/xt_LOG.c diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild index e144f54185c0..aaa72aaa21de 100644 --- a/include/linux/netfilter/Kbuild +++ b/include/linux/netfilter/Kbuild @@ -22,6 +22,7 @@ header-y += xt_CT.h header-y += xt_DSCP.h header-y += xt_IDLETIMER.h header-y += xt_LED.h +header-y += xt_LOG.h header-y += xt_MARK.h header-y += xt_nfacct.h header-y += xt_NFLOG.h diff --git a/include/linux/netfilter/xt_LOG.h b/include/linux/netfilter/xt_LOG.h new file mode 100644 index 000000000000..cac079095305 --- /dev/null +++ b/include/linux/netfilter/xt_LOG.h @@ -0,0 +1,19 @@ +#ifndef _XT_LOG_H +#define _XT_LOG_H + +/* make sure not to change this without changing nf_log.h:NF_LOG_* (!) */ +#define XT_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ +#define XT_LOG_TCPOPT 0x02 /* Log TCP options */ +#define XT_LOG_IPOPT 0x04 /* Log IP options */ +#define XT_LOG_UID 0x08 /* Log UID owning local socket */ +#define XT_LOG_NFLOG 0x10 /* Unsupported, don't reuse */ +#define XT_LOG_MACDECODE 0x20 /* Decode MAC header */ +#define XT_LOG_MASK 0x2f + +struct xt_log_info { + unsigned char level; + unsigned char logflags; + char prefix[30]; +}; + +#endif /* _XT_LOG_H */ diff --git a/include/linux/netfilter_ipv4/ipt_LOG.h b/include/linux/netfilter_ipv4/ipt_LOG.h index dcdbadf9fd4a..5d8152077d71 100644 --- a/include/linux/netfilter_ipv4/ipt_LOG.h +++ b/include/linux/netfilter_ipv4/ipt_LOG.h @@ -1,6 +1,8 @@ #ifndef _IPT_LOG_H #define _IPT_LOG_H +#warning "Please update iptables, this file will be removed soon!" + /* make sure not to change this without changing netfilter.h:NF_LOG_* (!) */ #define IPT_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ #define IPT_LOG_TCPOPT 0x02 /* Log TCP options */ diff --git a/include/linux/netfilter_ipv6/ip6t_LOG.h b/include/linux/netfilter_ipv6/ip6t_LOG.h index 9dd5579e02ec..3dd0bc4e0735 100644 --- a/include/linux/netfilter_ipv6/ip6t_LOG.h +++ b/include/linux/netfilter_ipv6/ip6t_LOG.h @@ -1,6 +1,8 @@ #ifndef _IP6T_LOG_H #define _IP6T_LOG_H +#warning "Please update iptables, this file will be removed soon!" + /* make sure not to change this without changing netfilter.h:NF_LOG_* (!) */ #define IP6T_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ #define IP6T_LOG_TCPOPT 0x02 /* Log TCP options */ diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index 74dfc9e5211f..fcc543cd987a 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig @@ -123,15 +123,6 @@ config IP_NF_TARGET_REJECT To compile it as a module, choose M here. If unsure, say N. -config IP_NF_TARGET_LOG - tristate "LOG target support" - default m if NETFILTER_ADVANCED=n - help - This option adds a `LOG' target, which allows you to create rules in - any iptables table which records the packet header to the syslog. - - To compile it as a module, choose M here. If unsure, say N. - config IP_NF_TARGET_ULOG tristate "ULOG target support" default m if NETFILTER_ADVANCED=n diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile index 213a462b739b..240b68469a7a 100644 --- a/net/ipv4/netfilter/Makefile +++ b/net/ipv4/netfilter/Makefile @@ -54,7 +54,6 @@ obj-$(CONFIG_IP_NF_MATCH_RPFILTER) += ipt_rpfilter.o # targets obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o -obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c deleted file mode 100644 index d76d6c9ed946..000000000000 --- a/net/ipv4/netfilter/ipt_LOG.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * This is a module which is used for logging packets. - */ - -/* (C) 1999-2001 Paul `Rusty' Russell - * (C) 2002-2004 Netfilter Core Team - * - * 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. - */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Netfilter Core Team "); -MODULE_DESCRIPTION("Xtables: IPv4 packet logging to syslog"); - -/* One level of recursion won't kill us */ -static void dump_packet(struct sbuff *m, - const struct nf_loginfo *info, - const struct sk_buff *skb, - unsigned int iphoff) -{ - struct iphdr _iph; - const struct iphdr *ih; - unsigned int logflags; - - if (info->type == NF_LOG_TYPE_LOG) - logflags = info->u.log.logflags; - else - logflags = NF_LOG_MASK; - - ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph); - if (ih == NULL) { - sb_add(m, "TRUNCATED"); - return; - } - - /* Important fields: - * TOS, len, DF/MF, fragment offset, TTL, src, dst, options. */ - /* Max length: 40 "SRC=255.255.255.255 DST=255.255.255.255 " */ - sb_add(m, "SRC=%pI4 DST=%pI4 ", - &ih->saddr, &ih->daddr); - - /* Max length: 46 "LEN=65535 TOS=0xFF PREC=0xFF TTL=255 ID=65535 " */ - sb_add(m, "LEN=%u TOS=0x%02X PREC=0x%02X TTL=%u ID=%u ", - ntohs(ih->tot_len), ih->tos & IPTOS_TOS_MASK, - ih->tos & IPTOS_PREC_MASK, ih->ttl, ntohs(ih->id)); - - /* Max length: 6 "CE DF MF " */ - if (ntohs(ih->frag_off) & IP_CE) - sb_add(m, "CE "); - if (ntohs(ih->frag_off) & IP_DF) - sb_add(m, "DF "); - if (ntohs(ih->frag_off) & IP_MF) - sb_add(m, "MF "); - - /* Max length: 11 "FRAG:65535 " */ - if (ntohs(ih->frag_off) & IP_OFFSET) - sb_add(m, "FRAG:%u ", ntohs(ih->frag_off) & IP_OFFSET); - - if ((logflags & IPT_LOG_IPOPT) && - ih->ihl * 4 > sizeof(struct iphdr)) { - const unsigned char *op; - unsigned char _opt[4 * 15 - sizeof(struct iphdr)]; - unsigned int i, optsize; - - optsize = ih->ihl * 4 - sizeof(struct iphdr); - op = skb_header_pointer(skb, iphoff+sizeof(_iph), - optsize, _opt); - if (op == NULL) { - sb_add(m, "TRUNCATED"); - return; - } - - /* Max length: 127 "OPT (" 15*4*2chars ") " */ - sb_add(m, "OPT ("); - for (i = 0; i < optsize; i++) - sb_add(m, "%02X", op[i]); - sb_add(m, ") "); - } - - switch (ih->protocol) { - case IPPROTO_TCP: { - struct tcphdr _tcph; - const struct tcphdr *th; - - /* Max length: 10 "PROTO=TCP " */ - sb_add(m, "PROTO=TCP "); - - if (ntohs(ih->frag_off) & IP_OFFSET) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - th = skb_header_pointer(skb, iphoff + ih->ihl * 4, - sizeof(_tcph), &_tcph); - if (th == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", - skb->len - iphoff - ih->ihl*4); - break; - } - - /* Max length: 20 "SPT=65535 DPT=65535 " */ - sb_add(m, "SPT=%u DPT=%u ", - ntohs(th->source), ntohs(th->dest)); - /* Max length: 30 "SEQ=4294967295 ACK=4294967295 " */ - if (logflags & IPT_LOG_TCPSEQ) - sb_add(m, "SEQ=%u ACK=%u ", - ntohl(th->seq), ntohl(th->ack_seq)); - /* Max length: 13 "WINDOW=65535 " */ - sb_add(m, "WINDOW=%u ", ntohs(th->window)); - /* Max length: 9 "RES=0x3F " */ - sb_add(m, "RES=0x%02x ", (u8)(ntohl(tcp_flag_word(th) & TCP_RESERVED_BITS) >> 22)); - /* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */ - if (th->cwr) - sb_add(m, "CWR "); - if (th->ece) - sb_add(m, "ECE "); - if (th->urg) - sb_add(m, "URG "); - if (th->ack) - sb_add(m, "ACK "); - if (th->psh) - sb_add(m, "PSH "); - if (th->rst) - sb_add(m, "RST "); - if (th->syn) - sb_add(m, "SYN "); - if (th->fin) - sb_add(m, "FIN "); - /* Max length: 11 "URGP=65535 " */ - sb_add(m, "URGP=%u ", ntohs(th->urg_ptr)); - - if ((logflags & IPT_LOG_TCPOPT) && - th->doff * 4 > sizeof(struct tcphdr)) { - unsigned char _opt[4 * 15 - sizeof(struct tcphdr)]; - const unsigned char *op; - unsigned int i, optsize; - - optsize = th->doff * 4 - sizeof(struct tcphdr); - op = skb_header_pointer(skb, - iphoff+ih->ihl*4+sizeof(_tcph), - optsize, _opt); - if (op == NULL) { - sb_add(m, "TRUNCATED"); - return; - } - - /* Max length: 127 "OPT (" 15*4*2chars ") " */ - sb_add(m, "OPT ("); - for (i = 0; i < optsize; i++) - sb_add(m, "%02X", op[i]); - sb_add(m, ") "); - } - break; - } - case IPPROTO_UDP: - case IPPROTO_UDPLITE: { - struct udphdr _udph; - const struct udphdr *uh; - - if (ih->protocol == IPPROTO_UDP) - /* Max length: 10 "PROTO=UDP " */ - sb_add(m, "PROTO=UDP " ); - else /* Max length: 14 "PROTO=UDPLITE " */ - sb_add(m, "PROTO=UDPLITE "); - - if (ntohs(ih->frag_off) & IP_OFFSET) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - uh = skb_header_pointer(skb, iphoff+ih->ihl*4, - sizeof(_udph), &_udph); - if (uh == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", - skb->len - iphoff - ih->ihl*4); - break; - } - - /* Max length: 20 "SPT=65535 DPT=65535 " */ - sb_add(m, "SPT=%u DPT=%u LEN=%u ", - ntohs(uh->source), ntohs(uh->dest), - ntohs(uh->len)); - break; - } - case IPPROTO_ICMP: { - struct icmphdr _icmph; - const struct icmphdr *ich; - static const size_t required_len[NR_ICMP_TYPES+1] - = { [ICMP_ECHOREPLY] = 4, - [ICMP_DEST_UNREACH] - = 8 + sizeof(struct iphdr), - [ICMP_SOURCE_QUENCH] - = 8 + sizeof(struct iphdr), - [ICMP_REDIRECT] - = 8 + sizeof(struct iphdr), - [ICMP_ECHO] = 4, - [ICMP_TIME_EXCEEDED] - = 8 + sizeof(struct iphdr), - [ICMP_PARAMETERPROB] - = 8 + sizeof(struct iphdr), - [ICMP_TIMESTAMP] = 20, - [ICMP_TIMESTAMPREPLY] = 20, - [ICMP_ADDRESS] = 12, - [ICMP_ADDRESSREPLY] = 12 }; - - /* Max length: 11 "PROTO=ICMP " */ - sb_add(m, "PROTO=ICMP "); - - if (ntohs(ih->frag_off) & IP_OFFSET) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - ich = skb_header_pointer(skb, iphoff + ih->ihl * 4, - sizeof(_icmph), &_icmph); - if (ich == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", - skb->len - iphoff - ih->ihl*4); - break; - } - - /* Max length: 18 "TYPE=255 CODE=255 " */ - sb_add(m, "TYPE=%u CODE=%u ", ich->type, ich->code); - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - if (ich->type <= NR_ICMP_TYPES && - required_len[ich->type] && - skb->len-iphoff-ih->ihl*4 < required_len[ich->type]) { - sb_add(m, "INCOMPLETE [%u bytes] ", - skb->len - iphoff - ih->ihl*4); - break; - } - - switch (ich->type) { - case ICMP_ECHOREPLY: - case ICMP_ECHO: - /* Max length: 19 "ID=65535 SEQ=65535 " */ - sb_add(m, "ID=%u SEQ=%u ", - ntohs(ich->un.echo.id), - ntohs(ich->un.echo.sequence)); - break; - - case ICMP_PARAMETERPROB: - /* Max length: 14 "PARAMETER=255 " */ - sb_add(m, "PARAMETER=%u ", - ntohl(ich->un.gateway) >> 24); - break; - case ICMP_REDIRECT: - /* Max length: 24 "GATEWAY=255.255.255.255 " */ - sb_add(m, "GATEWAY=%pI4 ", &ich->un.gateway); - /* Fall through */ - case ICMP_DEST_UNREACH: - case ICMP_SOURCE_QUENCH: - case ICMP_TIME_EXCEEDED: - /* Max length: 3+maxlen */ - if (!iphoff) { /* Only recurse once. */ - sb_add(m, "["); - dump_packet(m, info, skb, - iphoff + ih->ihl*4+sizeof(_icmph)); - sb_add(m, "] "); - } - - /* Max length: 10 "MTU=65535 " */ - if (ich->type == ICMP_DEST_UNREACH && - ich->code == ICMP_FRAG_NEEDED) - sb_add(m, "MTU=%u ", ntohs(ich->un.frag.mtu)); - } - break; - } - /* Max Length */ - case IPPROTO_AH: { - struct ip_auth_hdr _ahdr; - const struct ip_auth_hdr *ah; - - if (ntohs(ih->frag_off) & IP_OFFSET) - break; - - /* Max length: 9 "PROTO=AH " */ - sb_add(m, "PROTO=AH "); - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - ah = skb_header_pointer(skb, iphoff+ih->ihl*4, - sizeof(_ahdr), &_ahdr); - if (ah == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", - skb->len - iphoff - ih->ihl*4); - break; - } - - /* Length: 15 "SPI=0xF1234567 " */ - sb_add(m, "SPI=0x%x ", ntohl(ah->spi)); - break; - } - case IPPROTO_ESP: { - struct ip_esp_hdr _esph; - const struct ip_esp_hdr *eh; - - /* Max length: 10 "PROTO=ESP " */ - sb_add(m, "PROTO=ESP "); - - if (ntohs(ih->frag_off) & IP_OFFSET) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - eh = skb_header_pointer(skb, iphoff+ih->ihl*4, - sizeof(_esph), &_esph); - if (eh == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", - skb->len - iphoff - ih->ihl*4); - break; - } - - /* Length: 15 "SPI=0xF1234567 " */ - sb_add(m, "SPI=0x%x ", ntohl(eh->spi)); - break; - } - /* Max length: 10 "PROTO 255 " */ - default: - sb_add(m, "PROTO=%u ", ih->protocol); - } - - /* Max length: 15 "UID=4294967295 " */ - if ((logflags & IPT_LOG_UID) && !iphoff && skb->sk) { - read_lock_bh(&skb->sk->sk_callback_lock); - if (skb->sk->sk_socket && skb->sk->sk_socket->file) - sb_add(m, "UID=%u GID=%u ", - skb->sk->sk_socket->file->f_cred->fsuid, - skb->sk->sk_socket->file->f_cred->fsgid); - read_unlock_bh(&skb->sk->sk_callback_lock); - } - - /* Max length: 16 "MARK=0xFFFFFFFF " */ - if (!iphoff && skb->mark) - sb_add(m, "MARK=0x%x ", skb->mark); - - /* Proto Max log string length */ - /* IP: 40+46+6+11+127 = 230 */ - /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */ - /* UDP: 10+max(25,20) = 35 */ - /* UDPLITE: 14+max(25,20) = 39 */ - /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */ - /* ESP: 10+max(25)+15 = 50 */ - /* AH: 9+max(25)+15 = 49 */ - /* unknown: 10 */ - - /* (ICMP allows recursion one level deep) */ - /* maxlen = IP + ICMP + IP + max(TCP,UDP,ICMP,unknown) */ - /* maxlen = 230+ 91 + 230 + 252 = 803 */ -} - -static void dump_mac_header(struct sbuff *m, - const struct nf_loginfo *info, - const struct sk_buff *skb) -{ - struct net_device *dev = skb->dev; - unsigned int logflags = 0; - - if (info->type == NF_LOG_TYPE_LOG) - logflags = info->u.log.logflags; - - if (!(logflags & IPT_LOG_MACDECODE)) - goto fallback; - - switch (dev->type) { - case ARPHRD_ETHER: - sb_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ", - eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, - ntohs(eth_hdr(skb)->h_proto)); - return; - default: - break; - } - -fallback: - sb_add(m, "MAC="); - if (dev->hard_header_len && - skb->mac_header != skb->network_header) { - const unsigned char *p = skb_mac_header(skb); - unsigned int i; - - sb_add(m, "%02x", *p++); - for (i = 1; i < dev->hard_header_len; i++, p++) - sb_add(m, ":%02x", *p); - } - sb_add(m, " "); -} - -static struct nf_loginfo default_loginfo = { - .type = NF_LOG_TYPE_LOG, - .u = { - .log = { - .level = 5, - .logflags = NF_LOG_MASK, - }, - }, -}; - -static void -ipt_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 *loginfo, - const char *prefix) -{ - struct sbuff *m = sb_open(); - - if (!loginfo) - loginfo = &default_loginfo; - - sb_add(m, "<%d>%sIN=%s OUT=%s ", loginfo->u.log.level, - prefix, - in ? in->name : "", - out ? out->name : ""); -#ifdef CONFIG_BRIDGE_NETFILTER - if (skb->nf_bridge) { - const struct net_device *physindev; - const struct net_device *physoutdev; - - physindev = skb->nf_bridge->physindev; - if (physindev && in != physindev) - sb_add(m, "PHYSIN=%s ", physindev->name); - physoutdev = skb->nf_bridge->physoutdev; - if (physoutdev && out != physoutdev) - sb_add(m, "PHYSOUT=%s ", physoutdev->name); - } -#endif - - if (in != NULL) - dump_mac_header(m, loginfo, skb); - - dump_packet(m, loginfo, skb, 0); - - sb_close(m); -} - -static unsigned int -log_tg(struct sk_buff *skb, const struct xt_action_param *par) -{ - const struct ipt_log_info *loginfo = par->targinfo; - struct nf_loginfo li; - - li.type = NF_LOG_TYPE_LOG; - li.u.log.level = loginfo->level; - li.u.log.logflags = loginfo->logflags; - - ipt_log_packet(NFPROTO_IPV4, par->hooknum, skb, par->in, par->out, &li, - loginfo->prefix); - return XT_CONTINUE; -} - -static int log_tg_check(const struct xt_tgchk_param *par) -{ - const struct ipt_log_info *loginfo = par->targinfo; - - if (loginfo->level >= 8) { - pr_debug("level %u >= 8\n", loginfo->level); - return -EINVAL; - } - if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') { - pr_debug("prefix is not null-terminated\n"); - return -EINVAL; - } - return 0; -} - -static struct xt_target log_tg_reg __read_mostly = { - .name = "LOG", - .family = NFPROTO_IPV4, - .target = log_tg, - .targetsize = sizeof(struct ipt_log_info), - .checkentry = log_tg_check, - .me = THIS_MODULE, -}; - -static struct nf_logger ipt_log_logger __read_mostly = { - .name = "ipt_LOG", - .logfn = &ipt_log_packet, - .me = THIS_MODULE, -}; - -static int __init log_tg_init(void) -{ - int ret; - - ret = xt_register_target(&log_tg_reg); - if (ret < 0) - return ret; - nf_log_register(NFPROTO_IPV4, &ipt_log_logger); - return 0; -} - -static void __exit log_tg_exit(void) -{ - nf_log_unregister(&ipt_log_logger); - xt_unregister_target(&log_tg_reg); -} - -module_init(log_tg_init); -module_exit(log_tg_exit); diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig index 9a68fb5b9e77..d33cddd16fbb 100644 --- a/net/ipv6/netfilter/Kconfig +++ b/net/ipv6/netfilter/Kconfig @@ -154,15 +154,6 @@ config IP6_NF_TARGET_HL (e.g. when running oldconfig). It selects CONFIG_NETFILTER_XT_TARGET_HL. -config IP6_NF_TARGET_LOG - tristate "LOG target support" - default m if NETFILTER_ADVANCED=n - help - This option adds a `LOG' target, which allows you to create rules in - any iptables table which records the packet header to the syslog. - - To compile it as a module, choose M here. If unsure, say N. - config IP6_NF_FILTER tristate "Packet filtering" default m if NETFILTER_ADVANCED=n diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile index 2eaed96db02c..d4dfd0a21097 100644 --- a/net/ipv6/netfilter/Makefile +++ b/net/ipv6/netfilter/Makefile @@ -31,5 +31,4 @@ obj-$(CONFIG_IP6_NF_MATCH_RPFILTER) += ip6t_rpfilter.o obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o # targets -obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c deleted file mode 100644 index e6af8d72f26b..000000000000 --- a/net/ipv6/netfilter/ip6t_LOG.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - * This is a module which is used for logging packets. - */ - -/* (C) 2001 Jan Rekorajski - * (C) 2002-2004 Netfilter Core Team - * - * 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. - */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -MODULE_AUTHOR("Jan Rekorajski "); -MODULE_DESCRIPTION("Xtables: IPv6 packet logging to syslog"); -MODULE_LICENSE("GPL"); - -struct in_device; -#include -#include - -/* One level of recursion won't kill us */ -static void dump_packet(struct sbuff *m, - const struct nf_loginfo *info, - const struct sk_buff *skb, unsigned int ip6hoff, - int recurse) -{ - u_int8_t currenthdr; - int fragment; - struct ipv6hdr _ip6h; - const struct ipv6hdr *ih; - unsigned int ptr; - unsigned int hdrlen = 0; - unsigned int logflags; - - if (info->type == NF_LOG_TYPE_LOG) - logflags = info->u.log.logflags; - else - logflags = NF_LOG_MASK; - - ih = skb_header_pointer(skb, ip6hoff, sizeof(_ip6h), &_ip6h); - if (ih == NULL) { - sb_add(m, "TRUNCATED"); - return; - } - - /* Max length: 88 "SRC=0000.0000.0000.0000.0000.0000.0000.0000 DST=0000.0000.0000.0000.0000.0000.0000.0000 " */ - sb_add(m, "SRC=%pI6 DST=%pI6 ", &ih->saddr, &ih->daddr); - - /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */ - sb_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ", - ntohs(ih->payload_len) + sizeof(struct ipv6hdr), - (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20, - ih->hop_limit, - (ntohl(*(__be32 *)ih) & 0x000fffff)); - - fragment = 0; - ptr = ip6hoff + sizeof(struct ipv6hdr); - currenthdr = ih->nexthdr; - while (currenthdr != NEXTHDR_NONE && ip6t_ext_hdr(currenthdr)) { - struct ipv6_opt_hdr _hdr; - const struct ipv6_opt_hdr *hp; - - hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr); - if (hp == NULL) { - sb_add(m, "TRUNCATED"); - return; - } - - /* Max length: 48 "OPT (...) " */ - if (logflags & IP6T_LOG_IPOPT) - sb_add(m, "OPT ( "); - - switch (currenthdr) { - case IPPROTO_FRAGMENT: { - struct frag_hdr _fhdr; - const struct frag_hdr *fh; - - sb_add(m, "FRAG:"); - fh = skb_header_pointer(skb, ptr, sizeof(_fhdr), - &_fhdr); - if (fh == NULL) { - sb_add(m, "TRUNCATED "); - return; - } - - /* Max length: 6 "65535 " */ - sb_add(m, "%u ", ntohs(fh->frag_off) & 0xFFF8); - - /* Max length: 11 "INCOMPLETE " */ - if (fh->frag_off & htons(0x0001)) - sb_add(m, "INCOMPLETE "); - - sb_add(m, "ID:%08x ", ntohl(fh->identification)); - - if (ntohs(fh->frag_off) & 0xFFF8) - fragment = 1; - - hdrlen = 8; - - break; - } - case IPPROTO_DSTOPTS: - case IPPROTO_ROUTING: - case IPPROTO_HOPOPTS: - if (fragment) { - if (logflags & IP6T_LOG_IPOPT) - sb_add(m, ")"); - return; - } - hdrlen = ipv6_optlen(hp); - break; - /* Max Length */ - case IPPROTO_AH: - if (logflags & IP6T_LOG_IPOPT) { - struct ip_auth_hdr _ahdr; - const struct ip_auth_hdr *ah; - - /* Max length: 3 "AH " */ - sb_add(m, "AH "); - - if (fragment) { - sb_add(m, ")"); - return; - } - - ah = skb_header_pointer(skb, ptr, sizeof(_ahdr), - &_ahdr); - if (ah == NULL) { - /* - * Max length: 26 "INCOMPLETE [65535 - * bytes] )" - */ - sb_add(m, "INCOMPLETE [%u bytes] )", - skb->len - ptr); - return; - } - - /* Length: 15 "SPI=0xF1234567 */ - sb_add(m, "SPI=0x%x ", ntohl(ah->spi)); - - } - - hdrlen = (hp->hdrlen+2)<<2; - break; - case IPPROTO_ESP: - if (logflags & IP6T_LOG_IPOPT) { - struct ip_esp_hdr _esph; - const struct ip_esp_hdr *eh; - - /* Max length: 4 "ESP " */ - sb_add(m, "ESP "); - - if (fragment) { - sb_add(m, ")"); - return; - } - - /* - * Max length: 26 "INCOMPLETE [65535 bytes] )" - */ - eh = skb_header_pointer(skb, ptr, sizeof(_esph), - &_esph); - if (eh == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] )", - skb->len - ptr); - return; - } - - /* Length: 16 "SPI=0xF1234567 )" */ - sb_add(m, "SPI=0x%x )", ntohl(eh->spi) ); - - } - return; - default: - /* Max length: 20 "Unknown Ext Hdr 255" */ - sb_add(m, "Unknown Ext Hdr %u", currenthdr); - return; - } - if (logflags & IP6T_LOG_IPOPT) - sb_add(m, ") "); - - currenthdr = hp->nexthdr; - ptr += hdrlen; - } - - switch (currenthdr) { - case IPPROTO_TCP: { - struct tcphdr _tcph; - const struct tcphdr *th; - - /* Max length: 10 "PROTO=TCP " */ - sb_add(m, "PROTO=TCP "); - - if (fragment) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - th = skb_header_pointer(skb, ptr, sizeof(_tcph), &_tcph); - if (th == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", skb->len - ptr); - return; - } - - /* Max length: 20 "SPT=65535 DPT=65535 " */ - sb_add(m, "SPT=%u DPT=%u ", - ntohs(th->source), ntohs(th->dest)); - /* Max length: 30 "SEQ=4294967295 ACK=4294967295 " */ - if (logflags & IP6T_LOG_TCPSEQ) - sb_add(m, "SEQ=%u ACK=%u ", - ntohl(th->seq), ntohl(th->ack_seq)); - /* Max length: 13 "WINDOW=65535 " */ - sb_add(m, "WINDOW=%u ", ntohs(th->window)); - /* Max length: 9 "RES=0x3C " */ - sb_add(m, "RES=0x%02x ", (u_int8_t)(ntohl(tcp_flag_word(th) & TCP_RESERVED_BITS) >> 22)); - /* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */ - if (th->cwr) - sb_add(m, "CWR "); - if (th->ece) - sb_add(m, "ECE "); - if (th->urg) - sb_add(m, "URG "); - if (th->ack) - sb_add(m, "ACK "); - if (th->psh) - sb_add(m, "PSH "); - if (th->rst) - sb_add(m, "RST "); - if (th->syn) - sb_add(m, "SYN "); - if (th->fin) - sb_add(m, "FIN "); - /* Max length: 11 "URGP=65535 " */ - sb_add(m, "URGP=%u ", ntohs(th->urg_ptr)); - - if ((logflags & IP6T_LOG_TCPOPT) && - th->doff * 4 > sizeof(struct tcphdr)) { - u_int8_t _opt[60 - sizeof(struct tcphdr)]; - const u_int8_t *op; - unsigned int i; - unsigned int optsize = th->doff * 4 - - sizeof(struct tcphdr); - - op = skb_header_pointer(skb, - ptr + sizeof(struct tcphdr), - optsize, _opt); - if (op == NULL) { - sb_add(m, "OPT (TRUNCATED)"); - return; - } - - /* Max length: 127 "OPT (" 15*4*2chars ") " */ - sb_add(m, "OPT ("); - for (i =0; i < optsize; i++) - sb_add(m, "%02X", op[i]); - sb_add(m, ") "); - } - break; - } - case IPPROTO_UDP: - case IPPROTO_UDPLITE: { - struct udphdr _udph; - const struct udphdr *uh; - - if (currenthdr == IPPROTO_UDP) - /* Max length: 10 "PROTO=UDP " */ - sb_add(m, "PROTO=UDP " ); - else /* Max length: 14 "PROTO=UDPLITE " */ - sb_add(m, "PROTO=UDPLITE "); - - if (fragment) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - uh = skb_header_pointer(skb, ptr, sizeof(_udph), &_udph); - if (uh == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", skb->len - ptr); - return; - } - - /* Max length: 20 "SPT=65535 DPT=65535 " */ - sb_add(m, "SPT=%u DPT=%u LEN=%u ", - ntohs(uh->source), ntohs(uh->dest), - ntohs(uh->len)); - break; - } - case IPPROTO_ICMPV6: { - struct icmp6hdr _icmp6h; - const struct icmp6hdr *ic; - - /* Max length: 13 "PROTO=ICMPv6 " */ - sb_add(m, "PROTO=ICMPv6 "); - - if (fragment) - break; - - /* Max length: 25 "INCOMPLETE [65535 bytes] " */ - ic = skb_header_pointer(skb, ptr, sizeof(_icmp6h), &_icmp6h); - if (ic == NULL) { - sb_add(m, "INCOMPLETE [%u bytes] ", skb->len - ptr); - return; - } - - /* Max length: 18 "TYPE=255 CODE=255 " */ - sb_add(m, "TYPE=%u CODE=%u ", ic->icmp6_type, ic->icmp6_code); - - switch (ic->icmp6_type) { - case ICMPV6_ECHO_REQUEST: - case ICMPV6_ECHO_REPLY: - /* Max length: 19 "ID=65535 SEQ=65535 " */ - sb_add(m, "ID=%u SEQ=%u ", - ntohs(ic->icmp6_identifier), - ntohs(ic->icmp6_sequence)); - break; - case ICMPV6_MGM_QUERY: - case ICMPV6_MGM_REPORT: - case ICMPV6_MGM_REDUCTION: - break; - - case ICMPV6_PARAMPROB: - /* Max length: 17 "POINTER=ffffffff " */ - sb_add(m, "POINTER=%08x ", ntohl(ic->icmp6_pointer)); - /* Fall through */ - case ICMPV6_DEST_UNREACH: - case ICMPV6_PKT_TOOBIG: - case ICMPV6_TIME_EXCEED: - /* Max length: 3+maxlen */ - if (recurse) { - sb_add(m, "["); - dump_packet(m, info, skb, - ptr + sizeof(_icmp6h), 0); - sb_add(m, "] "); - } - - /* Max length: 10 "MTU=65535 " */ - if (ic->icmp6_type == ICMPV6_PKT_TOOBIG) - sb_add(m, "MTU=%u ", ntohl(ic->icmp6_mtu)); - } - break; - } - /* Max length: 10 "PROTO=255 " */ - default: - sb_add(m, "PROTO=%u ", currenthdr); - } - - /* Max length: 15 "UID=4294967295 " */ - if ((logflags & IP6T_LOG_UID) && recurse && skb->sk) { - read_lock_bh(&skb->sk->sk_callback_lock); - if (skb->sk->sk_socket && skb->sk->sk_socket->file) - sb_add(m, "UID=%u GID=%u ", - skb->sk->sk_socket->file->f_cred->fsuid, - skb->sk->sk_socket->file->f_cred->fsgid); - read_unlock_bh(&skb->sk->sk_callback_lock); - } - - /* Max length: 16 "MARK=0xFFFFFFFF " */ - if (!recurse && skb->mark) - sb_add(m, "MARK=0x%x ", skb->mark); -} - -static void dump_mac_header(struct sbuff *m, - const struct nf_loginfo *info, - const struct sk_buff *skb) -{ - struct net_device *dev = skb->dev; - unsigned int logflags = 0; - - if (info->type == NF_LOG_TYPE_LOG) - logflags = info->u.log.logflags; - - if (!(logflags & IP6T_LOG_MACDECODE)) - goto fallback; - - switch (dev->type) { - case ARPHRD_ETHER: - sb_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ", - eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, - ntohs(eth_hdr(skb)->h_proto)); - return; - default: - break; - } - -fallback: - sb_add(m, "MAC="); - if (dev->hard_header_len && - skb->mac_header != skb->network_header) { - const unsigned char *p = skb_mac_header(skb); - unsigned int len = dev->hard_header_len; - unsigned int i; - - if (dev->type == ARPHRD_SIT && - (p -= ETH_HLEN) < skb->head) - p = NULL; - - if (p != NULL) { - sb_add(m, "%02x", *p++); - for (i = 1; i < len; i++) - sb_add(m, ":%02x", *p++); - } - sb_add(m, " "); - - if (dev->type == ARPHRD_SIT) { - const struct iphdr *iph = - (struct iphdr *)skb_mac_header(skb); - sb_add(m, "TUNNEL=%pI4->%pI4 ", &iph->saddr, &iph->daddr); - } - } else - sb_add(m, " "); -} - -static struct nf_loginfo default_loginfo = { - .type = NF_LOG_TYPE_LOG, - .u = { - .log = { - .level = 5, - .logflags = NF_LOG_MASK, - }, - }, -}; - -static void -ip6t_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 *loginfo, - const char *prefix) -{ - struct sbuff *m = sb_open(); - - if (!loginfo) - loginfo = &default_loginfo; - - sb_add(m, "<%d>%sIN=%s OUT=%s ", loginfo->u.log.level, - prefix, - in ? in->name : "", - out ? out->name : ""); - - if (in != NULL) - dump_mac_header(m, loginfo, skb); - - dump_packet(m, loginfo, skb, skb_network_offset(skb), 1); - - sb_close(m); -} - -static unsigned int -log_tg6(struct sk_buff *skb, const struct xt_action_param *par) -{ - const struct ip6t_log_info *loginfo = par->targinfo; - struct nf_loginfo li; - - li.type = NF_LOG_TYPE_LOG; - li.u.log.level = loginfo->level; - li.u.log.logflags = loginfo->logflags; - - ip6t_log_packet(NFPROTO_IPV6, par->hooknum, skb, par->in, par->out, - &li, loginfo->prefix); - return XT_CONTINUE; -} - - -static int log_tg6_check(const struct xt_tgchk_param *par) -{ - const struct ip6t_log_info *loginfo = par->targinfo; - - if (loginfo->level >= 8) { - pr_debug("level %u >= 8\n", loginfo->level); - return -EINVAL; - } - if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') { - pr_debug("prefix not null-terminated\n"); - return -EINVAL; - } - return 0; -} - -static struct xt_target log_tg6_reg __read_mostly = { - .name = "LOG", - .family = NFPROTO_IPV6, - .target = log_tg6, - .targetsize = sizeof(struct ip6t_log_info), - .checkentry = log_tg6_check, - .me = THIS_MODULE, -}; - -static struct nf_logger ip6t_logger __read_mostly = { - .name = "ip6t_LOG", - .logfn = &ip6t_log_packet, - .me = THIS_MODULE, -}; - -static int __init log_tg6_init(void) -{ - int ret; - - ret = xt_register_target(&log_tg6_reg); - if (ret < 0) - return ret; - nf_log_register(NFPROTO_IPV6, &ip6t_logger); - return 0; -} - -static void __exit log_tg6_exit(void) -{ - nf_log_unregister(&ip6t_logger); - xt_unregister_target(&log_tg6_reg); -} - -module_init(log_tg6_init); -module_exit(log_tg6_exit); diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index f8ac4ef0b794..b895d8b13215 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig @@ -524,6 +524,15 @@ config NETFILTER_XT_TARGET_LED For more information on the LEDs available on your system, see Documentation/leds/leds-class.txt +config NETFILTER_XT_TARGET_LOG + tristate "LOG target support" + default m if NETFILTER_ADVANCED=n + help + This option adds a `LOG' target, which allows you to create rules in + any iptables table which records the packet header to the syslog. + + To compile it as a module, choose M here. If unsure, say N. + config NETFILTER_XT_TARGET_MARK tristate '"MARK" target support' depends on NETFILTER_ADVANCED diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index 40f4c3d636c5..a28c2a6563f8 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CT) += xt_CT.o obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o obj-$(CONFIG_NETFILTER_XT_TARGET_HL) += xt_HL.o obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o +obj-$(CONFIG_NETFILTER_XT_TARGET_LOG) += xt_LOG.o obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o diff --git a/net/netfilter/xt_LOG.c b/net/netfilter/xt_LOG.c new file mode 100644 index 000000000000..1595608a892d --- /dev/null +++ b/net/netfilter/xt_LOG.c @@ -0,0 +1,921 @@ +/* + * This is a module which is used for logging packets. + */ + +/* (C) 1999-2001 Paul `Rusty' Russell + * (C) 2002-2004 Netfilter Core Team + * + * 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. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +static struct nf_loginfo default_loginfo = { + .type = NF_LOG_TYPE_LOG, + .u = { + .log = { + .level = 5, + .logflags = NF_LOG_MASK, + }, + }, +}; + +static int dump_udp_header(struct sbuff *m, const struct sk_buff *skb, + u8 proto, int fragment, unsigned int offset) +{ + struct udphdr _udph; + const struct udphdr *uh; + + if (proto == IPPROTO_UDP) + /* Max length: 10 "PROTO=UDP " */ + sb_add(m, "PROTO=UDP "); + else /* Max length: 14 "PROTO=UDPLITE " */ + sb_add(m, "PROTO=UDPLITE "); + + if (fragment) + goto out; + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + uh = skb_header_pointer(skb, offset, sizeof(_udph), &_udph); + if (uh == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] ", skb->len - offset); + + return 1; + } + + /* Max length: 20 "SPT=65535 DPT=65535 " */ + sb_add(m, "SPT=%u DPT=%u LEN=%u ", ntohs(uh->source), ntohs(uh->dest), + ntohs(uh->len)); + +out: + return 0; +} + +static int dump_tcp_header(struct sbuff *m, const struct sk_buff *skb, + u8 proto, int fragment, unsigned int offset, + unsigned int logflags) +{ + struct tcphdr _tcph; + const struct tcphdr *th; + + /* Max length: 10 "PROTO=TCP " */ + sb_add(m, "PROTO=TCP "); + + if (fragment) + return 0; + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + th = skb_header_pointer(skb, offset, sizeof(_tcph), &_tcph); + if (th == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] ", skb->len - offset); + return 1; + } + + /* Max length: 20 "SPT=65535 DPT=65535 " */ + sb_add(m, "SPT=%u DPT=%u ", ntohs(th->source), ntohs(th->dest)); + /* Max length: 30 "SEQ=4294967295 ACK=4294967295 " */ + if (logflags & XT_LOG_TCPSEQ) + sb_add(m, "SEQ=%u ACK=%u ", ntohl(th->seq), ntohl(th->ack_seq)); + + /* Max length: 13 "WINDOW=65535 " */ + sb_add(m, "WINDOW=%u ", ntohs(th->window)); + /* Max length: 9 "RES=0x3C " */ + sb_add(m, "RES=0x%02x ", (u_int8_t)(ntohl(tcp_flag_word(th) & + TCP_RESERVED_BITS) >> 22)); + /* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */ + if (th->cwr) + sb_add(m, "CWR "); + if (th->ece) + sb_add(m, "ECE "); + if (th->urg) + sb_add(m, "URG "); + if (th->ack) + sb_add(m, "ACK "); + if (th->psh) + sb_add(m, "PSH "); + if (th->rst) + sb_add(m, "RST "); + if (th->syn) + sb_add(m, "SYN "); + if (th->fin) + sb_add(m, "FIN "); + /* Max length: 11 "URGP=65535 " */ + sb_add(m, "URGP=%u ", ntohs(th->urg_ptr)); + + if ((logflags & XT_LOG_TCPOPT) && th->doff*4 > sizeof(struct tcphdr)) { + u_int8_t _opt[60 - sizeof(struct tcphdr)]; + const u_int8_t *op; + unsigned int i; + unsigned int optsize = th->doff*4 - sizeof(struct tcphdr); + + op = skb_header_pointer(skb, offset + sizeof(struct tcphdr), + optsize, _opt); + if (op == NULL) { + sb_add(m, "OPT (TRUNCATED)"); + return 1; + } + + /* Max length: 127 "OPT (" 15*4*2chars ") " */ + sb_add(m, "OPT ("); + for (i = 0; i < optsize; i++) + sb_add(m, "%02X", op[i]); + + sb_add(m, ") "); + } + + return 0; +} + +/* One level of recursion won't kill us */ +static void dump_ipv4_packet(struct sbuff *m, + const struct nf_loginfo *info, + const struct sk_buff *skb, + unsigned int iphoff) +{ + struct iphdr _iph; + const struct iphdr *ih; + unsigned int logflags; + + if (info->type == NF_LOG_TYPE_LOG) + logflags = info->u.log.logflags; + else + logflags = NF_LOG_MASK; + + ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph); + if (ih == NULL) { + sb_add(m, "TRUNCATED"); + return; + } + + /* Important fields: + * TOS, len, DF/MF, fragment offset, TTL, src, dst, options. */ + /* Max length: 40 "SRC=255.255.255.255 DST=255.255.255.255 " */ + sb_add(m, "SRC=%pI4 DST=%pI4 ", + &ih->saddr, &ih->daddr); + + /* Max length: 46 "LEN=65535 TOS=0xFF PREC=0xFF TTL=255 ID=65535 " */ + sb_add(m, "LEN=%u TOS=0x%02X PREC=0x%02X TTL=%u ID=%u ", + ntohs(ih->tot_len), ih->tos & IPTOS_TOS_MASK, + ih->tos & IPTOS_PREC_MASK, ih->ttl, ntohs(ih->id)); + + /* Max length: 6 "CE DF MF " */ + if (ntohs(ih->frag_off) & IP_CE) + sb_add(m, "CE "); + if (ntohs(ih->frag_off) & IP_DF) + sb_add(m, "DF "); + if (ntohs(ih->frag_off) & IP_MF) + sb_add(m, "MF "); + + /* Max length: 11 "FRAG:65535 " */ + if (ntohs(ih->frag_off) & IP_OFFSET) + sb_add(m, "FRAG:%u ", ntohs(ih->frag_off) & IP_OFFSET); + + if ((logflags & XT_LOG_IPOPT) && + ih->ihl * 4 > sizeof(struct iphdr)) { + const unsigned char *op; + unsigned char _opt[4 * 15 - sizeof(struct iphdr)]; + unsigned int i, optsize; + + optsize = ih->ihl * 4 - sizeof(struct iphdr); + op = skb_header_pointer(skb, iphoff+sizeof(_iph), + optsize, _opt); + if (op == NULL) { + sb_add(m, "TRUNCATED"); + return; + } + + /* Max length: 127 "OPT (" 15*4*2chars ") " */ + sb_add(m, "OPT ("); + for (i = 0; i < optsize; i++) + sb_add(m, "%02X", op[i]); + sb_add(m, ") "); + } + + switch (ih->protocol) { + case IPPROTO_TCP: + if (dump_tcp_header(m, skb, ih->protocol, + ntohs(ih->frag_off) & IP_OFFSET, + iphoff+ih->ihl*4, logflags)) + return; + case IPPROTO_UDP: + case IPPROTO_UDPLITE: + if (dump_udp_header(m, skb, ih->protocol, + ntohs(ih->frag_off) & IP_OFFSET, + iphoff+ih->ihl*4)) + return; + case IPPROTO_ICMP: { + struct icmphdr _icmph; + const struct icmphdr *ich; + static const size_t required_len[NR_ICMP_TYPES+1] + = { [ICMP_ECHOREPLY] = 4, + [ICMP_DEST_UNREACH] + = 8 + sizeof(struct iphdr), + [ICMP_SOURCE_QUENCH] + = 8 + sizeof(struct iphdr), + [ICMP_REDIRECT] + = 8 + sizeof(struct iphdr), + [ICMP_ECHO] = 4, + [ICMP_TIME_EXCEEDED] + = 8 + sizeof(struct iphdr), + [ICMP_PARAMETERPROB] + = 8 + sizeof(struct iphdr), + [ICMP_TIMESTAMP] = 20, + [ICMP_TIMESTAMPREPLY] = 20, + [ICMP_ADDRESS] = 12, + [ICMP_ADDRESSREPLY] = 12 }; + + /* Max length: 11 "PROTO=ICMP " */ + sb_add(m, "PROTO=ICMP "); + + if (ntohs(ih->frag_off) & IP_OFFSET) + break; + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + ich = skb_header_pointer(skb, iphoff + ih->ihl * 4, + sizeof(_icmph), &_icmph); + if (ich == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] ", + skb->len - iphoff - ih->ihl*4); + break; + } + + /* Max length: 18 "TYPE=255 CODE=255 " */ + sb_add(m, "TYPE=%u CODE=%u ", ich->type, ich->code); + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + if (ich->type <= NR_ICMP_TYPES && + required_len[ich->type] && + skb->len-iphoff-ih->ihl*4 < required_len[ich->type]) { + sb_add(m, "INCOMPLETE [%u bytes] ", + skb->len - iphoff - ih->ihl*4); + break; + } + + switch (ich->type) { + case ICMP_ECHOREPLY: + case ICMP_ECHO: + /* Max length: 19 "ID=65535 SEQ=65535 " */ + sb_add(m, "ID=%u SEQ=%u ", + ntohs(ich->un.echo.id), + ntohs(ich->un.echo.sequence)); + break; + + case ICMP_PARAMETERPROB: + /* Max length: 14 "PARAMETER=255 " */ + sb_add(m, "PARAMETER=%u ", + ntohl(ich->un.gateway) >> 24); + break; + case ICMP_REDIRECT: + /* Max length: 24 "GATEWAY=255.255.255.255 " */ + sb_add(m, "GATEWAY=%pI4 ", &ich->un.gateway); + /* Fall through */ + case ICMP_DEST_UNREACH: + case ICMP_SOURCE_QUENCH: + case ICMP_TIME_EXCEEDED: + /* Max length: 3+maxlen */ + if (!iphoff) { /* Only recurse once. */ + sb_add(m, "["); + dump_ipv4_packet(m, info, skb, + iphoff + ih->ihl*4+sizeof(_icmph)); + sb_add(m, "] "); + } + + /* Max length: 10 "MTU=65535 " */ + if (ich->type == ICMP_DEST_UNREACH && + ich->code == ICMP_FRAG_NEEDED) + sb_add(m, "MTU=%u ", ntohs(ich->un.frag.mtu)); + } + break; + } + /* Max Length */ + case IPPROTO_AH: { + struct ip_auth_hdr _ahdr; + const struct ip_auth_hdr *ah; + + if (ntohs(ih->frag_off) & IP_OFFSET) + break; + + /* Max length: 9 "PROTO=AH " */ + sb_add(m, "PROTO=AH "); + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + ah = skb_header_pointer(skb, iphoff+ih->ihl*4, + sizeof(_ahdr), &_ahdr); + if (ah == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] ", + skb->len - iphoff - ih->ihl*4); + break; + } + + /* Length: 15 "SPI=0xF1234567 " */ + sb_add(m, "SPI=0x%x ", ntohl(ah->spi)); + break; + } + case IPPROTO_ESP: { + struct ip_esp_hdr _esph; + const struct ip_esp_hdr *eh; + + /* Max length: 10 "PROTO=ESP " */ + sb_add(m, "PROTO=ESP "); + + if (ntohs(ih->frag_off) & IP_OFFSET) + break; + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + eh = skb_header_pointer(skb, iphoff+ih->ihl*4, + sizeof(_esph), &_esph); + if (eh == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] ", + skb->len - iphoff - ih->ihl*4); + break; + } + + /* Length: 15 "SPI=0xF1234567 " */ + sb_add(m, "SPI=0x%x ", ntohl(eh->spi)); + break; + } + /* Max length: 10 "PROTO 255 " */ + default: + sb_add(m, "PROTO=%u ", ih->protocol); + } + + /* Max length: 15 "UID=4294967295 " */ + if ((logflags & XT_LOG_UID) && !iphoff && skb->sk) { + read_lock_bh(&skb->sk->sk_callback_lock); + if (skb->sk->sk_socket && skb->sk->sk_socket->file) + sb_add(m, "UID=%u GID=%u ", + skb->sk->sk_socket->file->f_cred->fsuid, + skb->sk->sk_socket->file->f_cred->fsgid); + read_unlock_bh(&skb->sk->sk_callback_lock); + } + + /* Max length: 16 "MARK=0xFFFFFFFF " */ + if (!iphoff && skb->mark) + sb_add(m, "MARK=0x%x ", skb->mark); + + /* Proto Max log string length */ + /* IP: 40+46+6+11+127 = 230 */ + /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */ + /* UDP: 10+max(25,20) = 35 */ + /* UDPLITE: 14+max(25,20) = 39 */ + /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */ + /* ESP: 10+max(25)+15 = 50 */ + /* AH: 9+max(25)+15 = 49 */ + /* unknown: 10 */ + + /* (ICMP allows recursion one level deep) */ + /* maxlen = IP + ICMP + IP + max(TCP,UDP,ICMP,unknown) */ + /* maxlen = 230+ 91 + 230 + 252 = 803 */ +} + +static void dump_ipv4_mac_header(struct sbuff *m, + const struct nf_loginfo *info, + const struct sk_buff *skb) +{ + struct net_device *dev = skb->dev; + unsigned int logflags = 0; + + if (info->type == NF_LOG_TYPE_LOG) + logflags = info->u.log.logflags; + + if (!(logflags & XT_LOG_MACDECODE)) + goto fallback; + + switch (dev->type) { + case ARPHRD_ETHER: + sb_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ", + eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, + ntohs(eth_hdr(skb)->h_proto)); + return; + default: + break; + } + +fallback: + sb_add(m, "MAC="); + if (dev->hard_header_len && + skb->mac_header != skb->network_header) { + const unsigned char *p = skb_mac_header(skb); + unsigned int i; + + sb_add(m, "%02x", *p++); + for (i = 1; i < dev->hard_header_len; i++, p++) + sb_add(m, ":%02x", *p); + } + sb_add(m, " "); +} + +static void +log_packet_common(struct sbuff *m, + 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 *loginfo, + const char *prefix) +{ + sb_add(m, "<%d>%sIN=%s OUT=%s ", loginfo->u.log.level, + prefix, + in ? in->name : "", + out ? out->name : ""); +#ifdef CONFIG_BRIDGE_NETFILTER + if (skb->nf_bridge) { + const struct net_device *physindev; + const struct net_device *physoutdev; + + physindev = skb->nf_bridge->physindev; + if (physindev && in != physindev) + sb_add(m, "PHYSIN=%s ", physindev->name); + physoutdev = skb->nf_bridge->physoutdev; + if (physoutdev && out != physoutdev) + sb_add(m, "PHYSOUT=%s ", physoutdev->name); + } +#endif +} + + +static void +ipt_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 *loginfo, + const char *prefix) +{ + struct sbuff *m = sb_open(); + + if (!loginfo) + loginfo = &default_loginfo; + + log_packet_common(m, pf, hooknum, skb, in, out, loginfo, prefix); + + if (in != NULL) + dump_ipv4_mac_header(m, loginfo, skb); + + dump_ipv4_packet(m, loginfo, skb, 0); + + sb_close(m); +} + +#if IS_ENABLED(CONFIG_IPV6) +/* One level of recursion won't kill us */ +static void dump_ipv6_packet(struct sbuff *m, + const struct nf_loginfo *info, + const struct sk_buff *skb, unsigned int ip6hoff, + int recurse) +{ + u_int8_t currenthdr; + int fragment; + struct ipv6hdr _ip6h; + const struct ipv6hdr *ih; + unsigned int ptr; + unsigned int hdrlen = 0; + unsigned int logflags; + + if (info->type == NF_LOG_TYPE_LOG) + logflags = info->u.log.logflags; + else + logflags = NF_LOG_MASK; + + ih = skb_header_pointer(skb, ip6hoff, sizeof(_ip6h), &_ip6h); + if (ih == NULL) { + sb_add(m, "TRUNCATED"); + return; + } + + /* Max length: 88 "SRC=0000.0000.0000.0000.0000.0000.0000.0000 DST=0000.0000.0000.0000.0000.0000.0000.0000 " */ + sb_add(m, "SRC=%pI6 DST=%pI6 ", &ih->saddr, &ih->daddr); + + /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */ + sb_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ", + ntohs(ih->payload_len) + sizeof(struct ipv6hdr), + (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20, + ih->hop_limit, + (ntohl(*(__be32 *)ih) & 0x000fffff)); + + fragment = 0; + ptr = ip6hoff + sizeof(struct ipv6hdr); + currenthdr = ih->nexthdr; + while (currenthdr != NEXTHDR_NONE && ip6t_ext_hdr(currenthdr)) { + struct ipv6_opt_hdr _hdr; + const struct ipv6_opt_hdr *hp; + + hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr); + if (hp == NULL) { + sb_add(m, "TRUNCATED"); + return; + } + + /* Max length: 48 "OPT (...) " */ + if (logflags & XT_LOG_IPOPT) + sb_add(m, "OPT ( "); + + switch (currenthdr) { + case IPPROTO_FRAGMENT: { + struct frag_hdr _fhdr; + const struct frag_hdr *fh; + + sb_add(m, "FRAG:"); + fh = skb_header_pointer(skb, ptr, sizeof(_fhdr), + &_fhdr); + if (fh == NULL) { + sb_add(m, "TRUNCATED "); + return; + } + + /* Max length: 6 "65535 " */ + sb_add(m, "%u ", ntohs(fh->frag_off) & 0xFFF8); + + /* Max length: 11 "INCOMPLETE " */ + if (fh->frag_off & htons(0x0001)) + sb_add(m, "INCOMPLETE "); + + sb_add(m, "ID:%08x ", ntohl(fh->identification)); + + if (ntohs(fh->frag_off) & 0xFFF8) + fragment = 1; + + hdrlen = 8; + + break; + } + case IPPROTO_DSTOPTS: + case IPPROTO_ROUTING: + case IPPROTO_HOPOPTS: + if (fragment) { + if (logflags & XT_LOG_IPOPT) + sb_add(m, ")"); + return; + } + hdrlen = ipv6_optlen(hp); + break; + /* Max Length */ + case IPPROTO_AH: + if (logflags & XT_LOG_IPOPT) { + struct ip_auth_hdr _ahdr; + const struct ip_auth_hdr *ah; + + /* Max length: 3 "AH " */ + sb_add(m, "AH "); + + if (fragment) { + sb_add(m, ")"); + return; + } + + ah = skb_header_pointer(skb, ptr, sizeof(_ahdr), + &_ahdr); + if (ah == NULL) { + /* + * Max length: 26 "INCOMPLETE [65535 + * bytes] )" + */ + sb_add(m, "INCOMPLETE [%u bytes] )", + skb->len - ptr); + return; + } + + /* Length: 15 "SPI=0xF1234567 */ + sb_add(m, "SPI=0x%x ", ntohl(ah->spi)); + + } + + hdrlen = (hp->hdrlen+2)<<2; + break; + case IPPROTO_ESP: + if (logflags & XT_LOG_IPOPT) { + struct ip_esp_hdr _esph; + const struct ip_esp_hdr *eh; + + /* Max length: 4 "ESP " */ + sb_add(m, "ESP "); + + if (fragment) { + sb_add(m, ")"); + return; + } + + /* + * Max length: 26 "INCOMPLETE [65535 bytes] )" + */ + eh = skb_header_pointer(skb, ptr, sizeof(_esph), + &_esph); + if (eh == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] )", + skb->len - ptr); + return; + } + + /* Length: 16 "SPI=0xF1234567 )" */ + sb_add(m, "SPI=0x%x )", ntohl(eh->spi)); + + } + return; + default: + /* Max length: 20 "Unknown Ext Hdr 255" */ + sb_add(m, "Unknown Ext Hdr %u", currenthdr); + return; + } + if (logflags & XT_LOG_IPOPT) + sb_add(m, ") "); + + currenthdr = hp->nexthdr; + ptr += hdrlen; + } + + switch (currenthdr) { + case IPPROTO_TCP: + if (dump_tcp_header(m, skb, currenthdr, fragment, ptr, + logflags)) + return; + case IPPROTO_UDP: + case IPPROTO_UDPLITE: + if (dump_udp_header(m, skb, currenthdr, fragment, ptr)) + return; + case IPPROTO_ICMPV6: { + struct icmp6hdr _icmp6h; + const struct icmp6hdr *ic; + + /* Max length: 13 "PROTO=ICMPv6 " */ + sb_add(m, "PROTO=ICMPv6 "); + + if (fragment) + break; + + /* Max length: 25 "INCOMPLETE [65535 bytes] " */ + ic = skb_header_pointer(skb, ptr, sizeof(_icmp6h), &_icmp6h); + if (ic == NULL) { + sb_add(m, "INCOMPLETE [%u bytes] ", skb->len - ptr); + return; + } + + /* Max length: 18 "TYPE=255 CODE=255 " */ + sb_add(m, "TYPE=%u CODE=%u ", ic->icmp6_type, ic->icmp6_code); + + switch (ic->icmp6_type) { + case ICMPV6_ECHO_REQUEST: + case ICMPV6_ECHO_REPLY: + /* Max length: 19 "ID=65535 SEQ=65535 " */ + sb_add(m, "ID=%u SEQ=%u ", + ntohs(ic->icmp6_identifier), + ntohs(ic->icmp6_sequence)); + break; + case ICMPV6_MGM_QUERY: + case ICMPV6_MGM_REPORT: + case ICMPV6_MGM_REDUCTION: + break; + + case ICMPV6_PARAMPROB: + /* Max length: 17 "POINTER=ffffffff " */ + sb_add(m, "POINTER=%08x ", ntohl(ic->icmp6_pointer)); + /* Fall through */ + case ICMPV6_DEST_UNREACH: + case ICMPV6_PKT_TOOBIG: + case ICMPV6_TIME_EXCEED: + /* Max length: 3+maxlen */ + if (recurse) { + sb_add(m, "["); + dump_ipv6_packet(m, info, skb, + ptr + sizeof(_icmp6h), 0); + sb_add(m, "] "); + } + + /* Max length: 10 "MTU=65535 " */ + if (ic->icmp6_type == ICMPV6_PKT_TOOBIG) + sb_add(m, "MTU=%u ", ntohl(ic->icmp6_mtu)); + } + break; + } + /* Max length: 10 "PROTO=255 " */ + default: + sb_add(m, "PROTO=%u ", currenthdr); + } + + /* Max length: 15 "UID=4294967295 " */ + if ((logflags & XT_LOG_UID) && recurse && skb->sk) { + read_lock_bh(&skb->sk->sk_callback_lock); + if (skb->sk->sk_socket && skb->sk->sk_socket->file) + sb_add(m, "UID=%u GID=%u ", + skb->sk->sk_socket->file->f_cred->fsuid, + skb->sk->sk_socket->file->f_cred->fsgid); + read_unlock_bh(&skb->sk->sk_callback_lock); + } + + /* Max length: 16 "MARK=0xFFFFFFFF " */ + if (!recurse && skb->mark) + sb_add(m, "MARK=0x%x ", skb->mark); +} + +static void dump_ipv6_mac_header(struct sbuff *m, + const struct nf_loginfo *info, + const struct sk_buff *skb) +{ + struct net_device *dev = skb->dev; + unsigned int logflags = 0; + + if (info->type == NF_LOG_TYPE_LOG) + logflags = info->u.log.logflags; + + if (!(logflags & XT_LOG_MACDECODE)) + goto fallback; + + switch (dev->type) { + case ARPHRD_ETHER: + sb_add(m, "MACSRC=%pM MACDST=%pM MACPROTO=%04x ", + eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, + ntohs(eth_hdr(skb)->h_proto)); + return; + default: + break; + } + +fallback: + sb_add(m, "MAC="); + if (dev->hard_header_len && + skb->mac_header != skb->network_header) { + const unsigned char *p = skb_mac_header(skb); + unsigned int len = dev->hard_header_len; + unsigned int i; + + if (dev->type == ARPHRD_SIT) { + p -= ETH_HLEN; + + if (p < skb->head) + p = NULL; + } + + if (p != NULL) { + sb_add(m, "%02x", *p++); + for (i = 1; i < len; i++) + sb_add(m, ":%02x", *p++); + } + sb_add(m, " "); + + if (dev->type == ARPHRD_SIT) { + const struct iphdr *iph = + (struct iphdr *)skb_mac_header(skb); + sb_add(m, "TUNNEL=%pI4->%pI4 ", &iph->saddr, + &iph->daddr); + } + } else + sb_add(m, " "); +} + +static void +ip6t_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 *loginfo, + const char *prefix) +{ + struct sbuff *m = sb_open(); + + if (!loginfo) + loginfo = &default_loginfo; + + log_packet_common(m, pf, hooknum, skb, in, out, loginfo, prefix); + + if (in != NULL) + dump_ipv6_mac_header(m, loginfo, skb); + + dump_ipv6_packet(m, loginfo, skb, skb_network_offset(skb), 1); + + sb_close(m); +} +#endif + +static unsigned int +log_tg(struct sk_buff *skb, const struct xt_action_param *par) +{ + const struct xt_log_info *loginfo = par->targinfo; + struct nf_loginfo li; + + li.type = NF_LOG_TYPE_LOG; + li.u.log.level = loginfo->level; + li.u.log.logflags = loginfo->logflags; + + if (par->family == NFPROTO_IPV4) + ipt_log_packet(NFPROTO_IPV4, par->hooknum, skb, par->in, + par->out, &li, loginfo->prefix); +#if IS_ENABLED(CONFIG_IPV6) + else if (par->family == NFPROTO_IPV6) + ip6t_log_packet(NFPROTO_IPV6, par->hooknum, skb, par->in, + par->out, &li, loginfo->prefix); +#endif + else + WARN_ON_ONCE(1); + + return XT_CONTINUE; +} + +static int log_tg_check(const struct xt_tgchk_param *par) +{ + const struct xt_log_info *loginfo = par->targinfo; + + if (par->family != NFPROTO_IPV4 && par->family != NFPROTO_IPV6) + return -EINVAL; + + if (loginfo->level >= 8) { + pr_debug("level %u >= 8\n", loginfo->level); + return -EINVAL; + } + + if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') { + pr_debug("prefix is not null-terminated\n"); + return -EINVAL; + } + + return 0; +} + +static struct xt_target log_tg_regs[] __read_mostly = { + { + .name = "LOG", + .family = NFPROTO_IPV4, + .target = log_tg, + .targetsize = sizeof(struct xt_log_info), + .checkentry = log_tg_check, + .me = THIS_MODULE, + }, +#if IS_ENABLED(CONFIG_IPV6) + { + .name = "LOG", + .family = NFPROTO_IPV6, + .target = log_tg, + .targetsize = sizeof(struct xt_log_info), + .checkentry = log_tg_check, + .me = THIS_MODULE, + }, +#endif +}; + +static struct nf_logger ipt_log_logger __read_mostly = { + .name = "ipt_LOG", + .logfn = &ipt_log_packet, + .me = THIS_MODULE, +}; + +#if IS_ENABLED(CONFIG_IPV6) +static struct nf_logger ip6t_log_logger __read_mostly = { + .name = "ip6t_LOG", + .logfn = &ip6t_log_packet, + .me = THIS_MODULE, +}; +#endif + +static int __init log_tg_init(void) +{ + int ret; + + ret = xt_register_targets(log_tg_regs, ARRAY_SIZE(log_tg_regs)); + if (ret < 0) + return ret; + + nf_log_register(NFPROTO_IPV4, &ipt_log_logger); +#if IS_ENABLED(CONFIG_IPV6) + nf_log_register(NFPROTO_IPV6, &ip6t_log_logger); +#endif + return 0; +} + +static void __exit log_tg_exit(void) +{ + nf_log_unregister(&ipt_log_logger); +#if IS_ENABLED(CONFIG_IPV6) + nf_log_unregister(&ip6t_log_logger); +#endif + xt_unregister_targets(log_tg_regs, ARRAY_SIZE(log_tg_regs)); +} + +module_init(log_tg_init); +module_exit(log_tg_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Netfilter Core Team "); +MODULE_AUTHOR("Jan Rekorajski "); +MODULE_DESCRIPTION("Xtables: IPv4/IPv6 packet logging"); +MODULE_ALIAS("ipt_LOG"); +MODULE_ALIAS("ip6t_LOG"); -- GitLab From 93326ae31222ddb8f4835e0461d3eb9959482ffd Mon Sep 17 00:00:00 2001 From: Tony Zelenoff Date: Wed, 22 Feb 2012 10:47:59 +0400 Subject: [PATCH 1495/1846] netfilter: nf_ct_ecache: trailing whitespace removed Signed-off-by: Tony Zelenoff Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_ecache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c index 14af6329bdda..aa15977b1781 100644 --- a/net/netfilter/nf_conntrack_ecache.c +++ b/net/netfilter/nf_conntrack_ecache.c @@ -70,7 +70,7 @@ void nf_ct_deliver_cached_events(struct nf_conn *ct) else e->missed &= ~missed; spin_unlock_bh(&ct->lock); - } + } } out_unlock: -- GitLab From 58020f77612747271ffa13e63cbff6ba12f49c2e Mon Sep 17 00:00:00 2001 From: Tony Zelenoff Date: Wed, 22 Feb 2012 10:48:01 +0400 Subject: [PATCH 1496/1846] netfilter: nf_ct_ecache: refactor nf_ct_deliver_cached_events * identation lowered * some CPU cycles saved at delayed item variable initialization Signed-off-by: Tony Zelenoff Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_ecache.c | 55 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c index aa15977b1781..5bd3047ddeec 100644 --- a/net/netfilter/nf_conntrack_ecache.c +++ b/net/netfilter/nf_conntrack_ecache.c @@ -32,9 +32,11 @@ static DEFINE_MUTEX(nf_ct_ecache_mutex); void nf_ct_deliver_cached_events(struct nf_conn *ct) { struct net *net = nf_ct_net(ct); - unsigned long events; + unsigned long events, missed; struct nf_ct_event_notifier *notify; struct nf_conntrack_ecache *e; + struct nf_ct_event item; + int ret; rcu_read_lock(); notify = rcu_dereference(net->ct.nf_conntrack_event_cb); @@ -47,31 +49,32 @@ void nf_ct_deliver_cached_events(struct nf_conn *ct) events = xchg(&e->cache, 0); - if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct) && events) { - struct nf_ct_event item = { - .ct = ct, - .pid = 0, - .report = 0 - }; - int ret; - /* We make a copy of the missed event cache without taking - * the lock, thus we may send missed events twice. However, - * this does not harm and it happens very rarely. */ - unsigned long missed = e->missed; - - if (!((events | missed) & e->ctmask)) - goto out_unlock; - - ret = notify->fcn(events | missed, &item); - if (unlikely(ret < 0 || missed)) { - spin_lock_bh(&ct->lock); - if (ret < 0) - e->missed |= events; - else - e->missed &= ~missed; - spin_unlock_bh(&ct->lock); - } - } + if (!nf_ct_is_confirmed(ct) || nf_ct_is_dying(ct) || !events) + goto out_unlock; + + /* We make a copy of the missed event cache without taking + * the lock, thus we may send missed events twice. However, + * this does not harm and it happens very rarely. */ + missed = e->missed; + + if (!((events | missed) & e->ctmask)) + goto out_unlock; + + item.ct = ct; + item.pid = 0; + item.report = 0; + + ret = notify->fcn(events | missed, &item); + + if (likely(ret >= 0 && !missed)) + goto out_unlock; + + spin_lock_bh(&ct->lock); + if (ret < 0) + e->missed |= events; + else + e->missed &= ~missed; + spin_unlock_bh(&ct->lock); out_unlock: rcu_read_unlock(); -- GitLab From 5f1f815103eb13823d34875807c1710b8e2b0f09 Mon Sep 17 00:00:00 2001 From: WANG Cong Date: Wed, 29 Feb 2012 04:05:41 +0100 Subject: [PATCH 1497/1846] netfilter: remove ipt_SAME.h and ipt_realm.h These two headers are not required anymore, they have been replaced by xt_SAME.h and xt_realm.h. Florian Westphal pointed out this. Cc: "David S. Miller" Cc: Florian Westphal Signed-off-by: WANG Cong --- include/linux/netfilter_ipv4/Kbuild | 2 -- include/linux/netfilter_ipv4/ipt_SAME.h | 20 -------------------- include/linux/netfilter_ipv4/ipt_realm.h | 7 ------- 3 files changed, 29 deletions(-) delete mode 100644 include/linux/netfilter_ipv4/ipt_SAME.h delete mode 100644 include/linux/netfilter_ipv4/ipt_realm.h diff --git a/include/linux/netfilter_ipv4/Kbuild b/include/linux/netfilter_ipv4/Kbuild index f9930c87fff3..31f8bec95650 100644 --- a/include/linux/netfilter_ipv4/Kbuild +++ b/include/linux/netfilter_ipv4/Kbuild @@ -4,11 +4,9 @@ header-y += ipt_CLUSTERIP.h header-y += ipt_ECN.h header-y += ipt_LOG.h header-y += ipt_REJECT.h -header-y += ipt_SAME.h header-y += ipt_TTL.h header-y += ipt_ULOG.h header-y += ipt_addrtype.h header-y += ipt_ah.h header-y += ipt_ecn.h -header-y += ipt_realm.h header-y += ipt_ttl.h diff --git a/include/linux/netfilter_ipv4/ipt_SAME.h b/include/linux/netfilter_ipv4/ipt_SAME.h deleted file mode 100644 index 5bca78267afd..000000000000 --- a/include/linux/netfilter_ipv4/ipt_SAME.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _IPT_SAME_H -#define _IPT_SAME_H - -#include - -#define IPT_SAME_MAX_RANGE 10 - -#define IPT_SAME_NODST 0x01 - -struct ipt_same_info { - unsigned char info; - __u32 rangesize; - __u32 ipnum; - __u32 *iparray; - - /* hangs off end. */ - struct nf_nat_range range[IPT_SAME_MAX_RANGE]; -}; - -#endif /*_IPT_SAME_H*/ diff --git a/include/linux/netfilter_ipv4/ipt_realm.h b/include/linux/netfilter_ipv4/ipt_realm.h deleted file mode 100644 index b3996eaa0188..000000000000 --- a/include/linux/netfilter_ipv4/ipt_realm.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _IPT_REALM_H -#define _IPT_REALM_H - -#include -#define ipt_realm_info xt_realm_info - -#endif /* _IPT_REALM_H */ -- GitLab From 417e02bf4280f001464ca55a36e9b3acad94eca4 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Thu, 1 Mar 2012 11:39:15 +0000 Subject: [PATCH 1498/1846] netfilter: xt_LOG: fix bogus extra layer-4 logging information In 16059b5 netfilter: merge ipt_LOG and ip6_LOG into xt_LOG, we have merged ipt_LOG and ip6t_LOG. However: IN=wlan0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=213.150.61.61 DST=192.168.1.133 LEN=40 TOS=0x00 PREC=0x00 TTL=117 ID=10539 DF PROTO=TCP SPT=80 DPT=49013 WINDOW=0 RES=0x00 ACK RST URGP=0 PROTO=UDPLITE SPT=80 DPT=49013 LEN=45843 PROTO=ICMP TYPE=0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Several missing break in the code led to including bogus layer-4 information. This patch fixes this problem. Signed-off-by: Richard Weinberger Signed-off-by: Pablo Neira Ayuso --- net/netfilter/xt_LOG.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/netfilter/xt_LOG.c b/net/netfilter/xt_LOG.c index 1595608a892d..f99f8dee238b 100644 --- a/net/netfilter/xt_LOG.c +++ b/net/netfilter/xt_LOG.c @@ -216,12 +216,14 @@ static void dump_ipv4_packet(struct sbuff *m, ntohs(ih->frag_off) & IP_OFFSET, iphoff+ih->ihl*4, logflags)) return; + break; case IPPROTO_UDP: case IPPROTO_UDPLITE: if (dump_udp_header(m, skb, ih->protocol, ntohs(ih->frag_off) & IP_OFFSET, iphoff+ih->ihl*4)) return; + break; case IPPROTO_ICMP: { struct icmphdr _icmph; const struct icmphdr *ich; @@ -649,10 +651,12 @@ static void dump_ipv6_packet(struct sbuff *m, if (dump_tcp_header(m, skb, currenthdr, fragment, ptr, logflags)) return; + break; case IPPROTO_UDP: case IPPROTO_UDPLITE: if (dump_udp_header(m, skb, currenthdr, fragment, ptr)) return; + break; case IPPROTO_ICMPV6: { struct icmp6hdr _icmp6h; const struct icmp6hdr *ic; -- GitLab From 3b988ece9b42452c59da5844942661cd782b2473 Mon Sep 17 00:00:00 2001 From: Hans Schillstrom Date: Mon, 5 Mar 2012 02:24:29 +0000 Subject: [PATCH 1499/1846] netfilter: ctnetlink: fix lockep splats net/netfilter/nf_conntrack_proto.c:70 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 1, debug_locks = 0 3 locks held by conntrack/3235: nfnl_lock+0x17/0x20 netlink_dump+0x32/0x240 ctnetlink_dump_table+0x3e/0x170 [nf_conntrack_netlink] stack backtrace: Pid: 3235, comm: conntrack Tainted: G W 3.2.0+ #511 Call Trace: [] lockdep_rcu_suspicious+0xe5/0x100 [] __nf_ct_l4proto_find+0x81/0xb0 [nf_conntrack] [] ctnetlink_fill_info+0x215/0x5f0 [nf_conntrack_netlink] [] ctnetlink_dump_table+0xd1/0x170 [nf_conntrack_netlink] [] netlink_dump+0x7f/0x240 [] ? trace_hardirqs_on+0xd/0x10 [] netlink_dump_start+0xdf/0x190 [] ? ctnetlink_change_nat_seq_adj+0x160/0x160 [nf_conntrack_netlink] [] ? ctnetlink_get_conntrack+0x2a0/0x2a0 [nf_conntrack_netlink] [] ctnetlink_get_conntrack+0x89/0x2a0 [nf_conntrack_netlink] [] nfnetlink_rcv_msg+0x467/0x5f0 [] ? nfnetlink_rcv_msg+0x49c/0x5f0 [] ? nfnetlink_rcv_msg+0x342/0x5f0 [] ? get_parent_ip+0x11/0x50 [] ? nfnetlink_subsys_register+0x60/0x60 [] netlink_rcv_skb+0xa9/0xd0 [] nfnetlink_rcv+0x15/0x20 [] netlink_unicast+0x1ae/0x1f0 [] netlink_sendmsg+0x2c6/0x320 [] sock_sendmsg+0x117/0x130 [] ? might_fault+0x53/0xb0 [] ? might_fault+0x9c/0xb0 [] ? might_fault+0x53/0xb0 [] ? move_addr_to_kernel+0x71/0x80 [] sys_sendto+0xfe/0x130 [] ? sys_bind+0xb4/0xd0 [] ? retint_swapgs+0xe/0x13 [] system_call_fastpath+0x16/0x1b Reported-by: Hans Schillstrom Signed-off-by: Eric Dumazet Signed-off-by: Hans Schillstrom --- net/netfilter/nf_conntrack_netlink.c | 40 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index b8827e8a11fe..c1ea64c6c70d 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -110,15 +110,16 @@ ctnetlink_dump_tuples(struct sk_buff *skb, struct nf_conntrack_l3proto *l3proto; struct nf_conntrack_l4proto *l4proto; + rcu_read_lock(); l3proto = __nf_ct_l3proto_find(tuple->src.l3num); ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto); - if (unlikely(ret < 0)) - return ret; - - l4proto = __nf_ct_l4proto_find(tuple->src.l3num, tuple->dst.protonum); - ret = ctnetlink_dump_tuples_proto(skb, tuple, l4proto); - + if (ret >= 0) { + l4proto = __nf_ct_l4proto_find(tuple->src.l3num, + tuple->dst.protonum); + ret = ctnetlink_dump_tuples_proto(skb, tuple, l4proto); + } + rcu_read_unlock(); return ret; } @@ -712,9 +713,11 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) struct hlist_nulls_node *n; struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh); u_int8_t l3proto = nfmsg->nfgen_family; + int res; #ifdef CONFIG_NF_CONNTRACK_MARK const struct ctnetlink_dump_filter *filter = cb->data; #endif + spin_lock_bh(&nf_conntrack_lock); last = (struct nf_conn *)cb->args[1]; for (; cb->args[0] < net->ct.htable_size; cb->args[0]++) { @@ -740,11 +743,14 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) continue; } #endif - if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, - cb->nlh->nlmsg_seq, - NFNL_MSG_TYPE( - cb->nlh->nlmsg_type), - ct) < 0) { + rcu_read_lock(); + res = + ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq, + NFNL_MSG_TYPE(cb->nlh->nlmsg_type), + ct); + rcu_read_unlock(); + if (res < 0) { nf_conntrack_get(&ct->ct_general); cb->args[1] = (unsigned long)ct; goto out; @@ -1649,14 +1655,16 @@ ctnetlink_exp_dump_mask(struct sk_buff *skb, if (!nest_parms) goto nla_put_failure; + rcu_read_lock(); l3proto = __nf_ct_l3proto_find(tuple->src.l3num); ret = ctnetlink_dump_tuples_ip(skb, &m, l3proto); - - if (unlikely(ret < 0)) - goto nla_put_failure; - - l4proto = __nf_ct_l4proto_find(tuple->src.l3num, tuple->dst.protonum); + if (ret >= 0) { + l4proto = __nf_ct_l4proto_find(tuple->src.l3num, + tuple->dst.protonum); ret = ctnetlink_dump_tuples_proto(skb, &m, l4proto); + } + rcu_read_unlock(); + if (unlikely(ret < 0)) goto nla_put_failure; -- GitLab From 5a41db94c60ac2a12b5a559de658a10d174b046d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 28 Feb 2012 02:23:28 +0100 Subject: [PATCH 1500/1846] netfilter: nf_ct_udp[lite]: convert UDP[lite] timeouts to array Use one array to store the UDP timeouts instead of two variables. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_proto_udp.c | 30 ++++++++++++++-------- net/netfilter/nf_conntrack_proto_udplite.c | 25 ++++++++++++------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c index 5f35757fbff0..5b24ff882f95 100644 --- a/net/netfilter/nf_conntrack_proto_udp.c +++ b/net/netfilter/nf_conntrack_proto_udp.c @@ -25,8 +25,16 @@ #include #include -static unsigned int nf_ct_udp_timeout __read_mostly = 30*HZ; -static unsigned int nf_ct_udp_timeout_stream __read_mostly = 180*HZ; +enum udp_conntrack { + UDP_CT_UNREPLIED, + UDP_CT_REPLIED, + UDP_CT_MAX +}; + +static unsigned int udp_timeouts[UDP_CT_MAX] = { + [UDP_CT_UNREPLIED] = 30*HZ, + [UDP_CT_REPLIED] = 180*HZ, +}; static bool udp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff, @@ -74,13 +82,15 @@ static int udp_packet(struct nf_conn *ct, /* If we've seen traffic both ways, this is some kind of UDP stream. Extend timeout. */ if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { - nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_udp_timeout_stream); + nf_ct_refresh_acct(ct, ctinfo, skb, + udp_timeouts[UDP_CT_REPLIED]); /* Also, more likely to be important, and not a probe */ if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status)) nf_conntrack_event_cache(IPCT_ASSURED, ct); - } else - nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_udp_timeout); - + } else { + nf_ct_refresh_acct(ct, ctinfo, skb, + udp_timeouts[UDP_CT_UNREPLIED]); + } return NF_ACCEPT; } @@ -142,14 +152,14 @@ static struct ctl_table_header *udp_sysctl_header; static struct ctl_table udp_sysctl_table[] = { { .procname = "nf_conntrack_udp_timeout", - .data = &nf_ct_udp_timeout, + .data = &udp_timeouts[UDP_CT_UNREPLIED], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "nf_conntrack_udp_timeout_stream", - .data = &nf_ct_udp_timeout_stream, + .data = &udp_timeouts[UDP_CT_REPLIED], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, @@ -160,14 +170,14 @@ static struct ctl_table udp_sysctl_table[] = { static struct ctl_table udp_compat_sysctl_table[] = { { .procname = "ip_conntrack_udp_timeout", - .data = &nf_ct_udp_timeout, + .data = &udp_timeouts[UDP_CT_UNREPLIED], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "ip_conntrack_udp_timeout_stream", - .data = &nf_ct_udp_timeout_stream, + .data = &udp_timeouts[UDP_CT_REPLIED], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c index f52ca1181013..e73071743e01 100644 --- a/net/netfilter/nf_conntrack_proto_udplite.c +++ b/net/netfilter/nf_conntrack_proto_udplite.c @@ -24,8 +24,16 @@ #include #include -static unsigned int nf_ct_udplite_timeout __read_mostly = 30*HZ; -static unsigned int nf_ct_udplite_timeout_stream __read_mostly = 180*HZ; +enum udplite_conntrack { + UDPLITE_CT_UNREPLIED, + UDPLITE_CT_REPLIED, + UDPLITE_CT_MAX +}; + +static unsigned int udplite_timeouts[UDPLITE_CT_MAX] = { + [UDPLITE_CT_UNREPLIED] = 30*HZ, + [UDPLITE_CT_REPLIED] = 180*HZ, +}; static bool udplite_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff, @@ -72,13 +80,14 @@ static int udplite_packet(struct nf_conn *ct, stream. Extend timeout. */ if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { nf_ct_refresh_acct(ct, ctinfo, skb, - nf_ct_udplite_timeout_stream); + udplite_timeouts[UDPLITE_CT_REPLIED]); /* Also, more likely to be important, and not a probe */ if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status)) nf_conntrack_event_cache(IPCT_ASSURED, ct); - } else - nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_udplite_timeout); - + } else { + nf_ct_refresh_acct(ct, ctinfo, skb, + udplite_timeouts[UDPLITE_CT_UNREPLIED]); + } return NF_ACCEPT; } @@ -147,14 +156,14 @@ static struct ctl_table_header *udplite_sysctl_header; static struct ctl_table udplite_sysctl_table[] = { { .procname = "nf_conntrack_udplite_timeout", - .data = &nf_ct_udplite_timeout, + .data = &udplite_timeouts[UDPLITE_CT_UNREPLIED], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "nf_conntrack_udplite_timeout_stream", - .data = &nf_ct_udplite_timeout_stream, + .data = &udplite_timeouts[UDPLITE_CT_REPLIED], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, -- GitLab From 33ee44643f10638f0ce6a96d11e30d1fbe877024 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 28 Feb 2012 16:56:31 +0100 Subject: [PATCH 1501/1846] netfilter: nf_ct_tcp: move retransmission and unacknowledged timeout to array This patch moves the retransmission and unacknowledged timeouts to the tcp_timeouts array. This change is required by follow-up patches. Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/nf_conntrack_tcp.h | 5 +++- net/netfilter/nf_conntrack_proto_tcp.c | 27 +++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/linux/netfilter/nf_conntrack_tcp.h b/include/linux/netfilter/nf_conntrack_tcp.h index 6e135f97e59a..e59868ae12d4 100644 --- a/include/linux/netfilter/nf_conntrack_tcp.h +++ b/include/linux/netfilter/nf_conntrack_tcp.h @@ -18,7 +18,10 @@ enum tcp_conntrack { TCP_CONNTRACK_LISTEN, /* obsolete */ #define TCP_CONNTRACK_SYN_SENT2 TCP_CONNTRACK_LISTEN TCP_CONNTRACK_MAX, - TCP_CONNTRACK_IGNORE + TCP_CONNTRACK_IGNORE, + TCP_CONNTRACK_RETRANS, + TCP_CONNTRACK_UNACK, + TCP_CONNTRACK_TIMEOUT_MAX }; /* Window scaling is advertised by the sender */ diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 97b9f3ebf28c..57c778546094 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c @@ -64,13 +64,7 @@ static const char *const tcp_conntrack_names[] = { #define HOURS * 60 MINS #define DAYS * 24 HOURS -/* RFC1122 says the R2 limit should be at least 100 seconds. - Linux uses 15 packets as limit, which corresponds - to ~13-30min depending on RTO. */ -static unsigned int nf_ct_tcp_timeout_max_retrans __read_mostly = 5 MINS; -static unsigned int nf_ct_tcp_timeout_unacknowledged __read_mostly = 5 MINS; - -static unsigned int tcp_timeouts[TCP_CONNTRACK_MAX] __read_mostly = { +static unsigned int tcp_timeouts[TCP_CONNTRACK_TIMEOUT_MAX] __read_mostly = { [TCP_CONNTRACK_SYN_SENT] = 2 MINS, [TCP_CONNTRACK_SYN_RECV] = 60 SECS, [TCP_CONNTRACK_ESTABLISHED] = 5 DAYS, @@ -80,6 +74,11 @@ static unsigned int tcp_timeouts[TCP_CONNTRACK_MAX] __read_mostly = { [TCP_CONNTRACK_TIME_WAIT] = 2 MINS, [TCP_CONNTRACK_CLOSE] = 10 SECS, [TCP_CONNTRACK_SYN_SENT2] = 2 MINS, +/* RFC1122 says the R2 limit should be at least 100 seconds. + Linux uses 15 packets as limit, which corresponds + to ~13-30min depending on RTO. */ + [TCP_CONNTRACK_RETRANS] = 5 MINS, + [TCP_CONNTRACK_UNACK] = 5 MINS, }; #define sNO TCP_CONNTRACK_NONE @@ -1015,12 +1014,12 @@ static int tcp_packet(struct nf_conn *ct, ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; if (ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans && - tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans) - timeout = nf_ct_tcp_timeout_max_retrans; + tcp_timeouts[new_state] > tcp_timeouts[TCP_CONNTRACK_RETRANS]) + timeout = tcp_timeouts[TCP_CONNTRACK_RETRANS]; else if ((ct->proto.tcp.seen[0].flags | ct->proto.tcp.seen[1].flags) & IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED && - tcp_timeouts[new_state] > nf_ct_tcp_timeout_unacknowledged) - timeout = nf_ct_tcp_timeout_unacknowledged; + tcp_timeouts[new_state] > tcp_timeouts[TCP_CONNTRACK_UNACK]) + timeout = tcp_timeouts[TCP_CONNTRACK_UNACK]; else timeout = tcp_timeouts[new_state]; spin_unlock_bh(&ct->lock); @@ -1301,14 +1300,14 @@ static struct ctl_table tcp_sysctl_table[] = { }, { .procname = "nf_conntrack_tcp_timeout_max_retrans", - .data = &nf_ct_tcp_timeout_max_retrans, + .data = &tcp_timeouts[TCP_CONNTRACK_RETRANS], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, { .procname = "nf_conntrack_tcp_timeout_unacknowledged", - .data = &nf_ct_tcp_timeout_unacknowledged, + .data = &tcp_timeouts[TCP_CONNTRACK_UNACK], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, @@ -1404,7 +1403,7 @@ static struct ctl_table tcp_compat_sysctl_table[] = { }, { .procname = "ip_conntrack_tcp_timeout_max_retrans", - .data = &nf_ct_tcp_timeout_max_retrans, + .data = &tcp_timeouts[TCP_CONNTRACK_RETRANS], .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, -- GitLab From b888341c7f33035694f70428d7001d73f0b2a3b1 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 28 Feb 2012 18:56:39 +0100 Subject: [PATCH 1502/1846] netfilter: nf_ct_gre: add unsigned int array to define timeouts This patch adds an array to define the default GRE timeouts. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_proto_gre.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index f0338791b822..8144f22d159a 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c @@ -41,8 +41,16 @@ #include #include -#define GRE_TIMEOUT (30 * HZ) -#define GRE_STREAM_TIMEOUT (180 * HZ) +enum grep_conntrack { + GRE_CT_UNREPLIED, + GRE_CT_REPLIED, + GRE_CT_MAX +}; + +static unsigned int gre_timeouts[GRE_CT_MAX] = { + [GRE_CT_UNREPLIED] = 30*HZ, + [GRE_CT_REPLIED] = 180*HZ, +}; static int proto_gre_net_id __read_mostly; struct netns_proto_gre { @@ -259,8 +267,8 @@ static bool gre_new(struct nf_conn *ct, const struct sk_buff *skb, /* initialize to sane value. Ideally a conntrack helper * (e.g. in case of pptp) is increasing them */ - ct->proto.gre.stream_timeout = GRE_STREAM_TIMEOUT; - ct->proto.gre.timeout = GRE_TIMEOUT; + ct->proto.gre.stream_timeout = gre_timeouts[GRE_CT_REPLIED]; + ct->proto.gre.timeout = gre_timeouts[GRE_CT_UNREPLIED]; return true; } -- GitLab From 2c8503f55fbdfbeff4164f133df804cf4d316290 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 28 Feb 2012 18:23:31 +0100 Subject: [PATCH 1503/1846] netfilter: nf_conntrack: pass timeout array to l4->new and l4->packet This patch defines a new interface for l4 protocol trackers: unsigned int *(*get_timeouts)(struct net *net); that is used to return the array of unsigned int that contains the timeouts that will be applied for this flow. This is passed to the l4proto->new(...) and l4proto->packet(...) functions to specify the timeout policy. This interface allows per-net global timeout configuration (although only DCCP supports this by now) and it will allow custom custom timeout configuration by means of follow-up patches. Signed-off-by: Pablo Neira Ayuso --- include/net/netfilter/nf_conntrack_l4proto.h | 8 +++-- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 13 +++++++-- .../netfilter/nf_conntrack_proto_icmpv6.c | 13 +++++++-- net/netfilter/nf_conntrack_core.c | 18 ++++++++---- net/netfilter/nf_conntrack_proto_dccp.c | 16 ++++++---- net/netfilter/nf_conntrack_proto_generic.c | 29 ++++++++++++------- net/netfilter/nf_conntrack_proto_gre.c | 15 +++++++--- net/netfilter/nf_conntrack_proto_sctp.c | 14 +++++++-- net/netfilter/nf_conntrack_proto_tcp.c | 22 +++++++++----- net/netfilter/nf_conntrack_proto_udp.c | 16 +++++++--- net/netfilter/nf_conntrack_proto_udplite.c | 16 +++++++--- 11 files changed, 128 insertions(+), 52 deletions(-) diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index e3d3ee3c06a2..c48b67405aa0 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h @@ -39,12 +39,13 @@ struct nf_conntrack_l4proto { unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum); + unsigned int hooknum, + unsigned int *timeouts); /* Called when a new connection for this protocol found; * returns TRUE if it's OK. If so, packet() called next. */ bool (*new)(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff); + unsigned int dataoff, unsigned int *timeouts); /* Called when a conntrack entry is destroyed */ void (*destroy)(struct nf_conn *ct); @@ -60,6 +61,9 @@ struct nf_conntrack_l4proto { /* Print out the private part of the conntrack. */ int (*print_conntrack)(struct seq_file *s, struct nf_conn *); + /* Return the array of timeouts for this protocol. */ + unsigned int *(*get_timeouts)(struct net *net); + /* convert protoinfo to nfnetink attributes */ int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, struct nf_conn *ct); diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index ab5b27a2916f..6b801124b31f 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c @@ -75,25 +75,31 @@ static int icmp_print_tuple(struct seq_file *s, ntohs(tuple->src.u.icmp.id)); } +static unsigned int *icmp_get_timeouts(struct net *net) +{ + return &nf_ct_icmp_timeout; +} + /* Returns verdict for packet, or -1 for invalid. */ static int icmp_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeout) { /* Do not immediately delete the connection after the first successful reply to avoid excessive conntrackd traffic and also to handle correctly ICMP echo reply duplicates. */ - nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_icmp_timeout); + nf_ct_refresh_acct(ct, ctinfo, skb, *timeout); return NF_ACCEPT; } /* Called when a new connection for this protocol found. */ static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { static const u_int8_t valid_new[] = { [ICMP_ECHO] = 1, @@ -298,6 +304,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly = .invert_tuple = icmp_invert_tuple, .print_tuple = icmp_print_tuple, .packet = icmp_packet, + .get_timeouts = icmp_get_timeouts, .new = icmp_new, .error = icmp_error, .destroy = NULL, diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index 7c05e7eacbc6..2eb9751eb7a8 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c @@ -88,25 +88,31 @@ static int icmpv6_print_tuple(struct seq_file *s, ntohs(tuple->src.u.icmp.id)); } +static unsigned int *icmpv6_get_timeouts(struct net *net) +{ + return &nf_ct_icmpv6_timeout; +} + /* Returns verdict for packet, or -1 for invalid. */ static int icmpv6_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeout) { /* Do not immediately delete the connection after the first successful reply to avoid excessive conntrackd traffic and also to handle correctly ICMP echo reply duplicates. */ - nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_icmpv6_timeout); + nf_ct_refresh_acct(ct, ctinfo, skb, *timeout); return NF_ACCEPT; } /* Called when a new connection for this protocol found. */ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { static const u_int8_t valid_new[] = { [ICMPV6_ECHO_REQUEST - 128] = 1, @@ -293,6 +299,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly = .invert_tuple = icmpv6_invert_tuple, .print_tuple = icmpv6_print_tuple, .packet = icmpv6_packet, + .get_timeouts = icmpv6_get_timeouts, .new = icmpv6_new, .error = icmpv6_error, #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index ed86a3be678e..d18995eea1c6 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -763,7 +763,8 @@ init_conntrack(struct net *net, struct nf_conn *tmpl, struct nf_conntrack_l3proto *l3proto, struct nf_conntrack_l4proto *l4proto, struct sk_buff *skb, - unsigned int dataoff, u32 hash) + unsigned int dataoff, u32 hash, + unsigned int *timeouts) { struct nf_conn *ct; struct nf_conn_help *help; @@ -782,7 +783,7 @@ init_conntrack(struct net *net, struct nf_conn *tmpl, if (IS_ERR(ct)) return (struct nf_conntrack_tuple_hash *)ct; - if (!l4proto->new(ct, skb, dataoff)) { + if (!l4proto->new(ct, skb, dataoff, timeouts)) { nf_conntrack_free(ct); pr_debug("init conntrack: can't track with proto module\n"); return NULL; @@ -848,7 +849,8 @@ resolve_normal_ct(struct net *net, struct nf_conn *tmpl, struct nf_conntrack_l3proto *l3proto, struct nf_conntrack_l4proto *l4proto, int *set_reply, - enum ip_conntrack_info *ctinfo) + enum ip_conntrack_info *ctinfo, + unsigned int *timeouts) { struct nf_conntrack_tuple tuple; struct nf_conntrack_tuple_hash *h; @@ -868,7 +870,7 @@ resolve_normal_ct(struct net *net, struct nf_conn *tmpl, h = __nf_conntrack_find_get(net, zone, &tuple, hash); if (!h) { h = init_conntrack(net, tmpl, &tuple, l3proto, l4proto, - skb, dataoff, hash); + skb, dataoff, hash, timeouts); if (!h) return NULL; if (IS_ERR(h)) @@ -909,6 +911,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, enum ip_conntrack_info ctinfo; struct nf_conntrack_l3proto *l3proto; struct nf_conntrack_l4proto *l4proto; + unsigned int *timeouts; unsigned int dataoff; u_int8_t protonum; int set_reply = 0; @@ -955,8 +958,11 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, goto out; } + timeouts = l4proto->get_timeouts(net); + ct = resolve_normal_ct(net, tmpl, skb, dataoff, pf, protonum, - l3proto, l4proto, &set_reply, &ctinfo); + l3proto, l4proto, &set_reply, &ctinfo, + timeouts); if (!ct) { /* Not valid part of a connection */ NF_CT_STAT_INC_ATOMIC(net, invalid); @@ -973,7 +979,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, NF_CT_ASSERT(skb->nfct); - ret = l4proto->packet(ct, skb, dataoff, ctinfo, pf, hooknum); + ret = l4proto->packet(ct, skb, dataoff, ctinfo, pf, hooknum, timeouts); if (ret <= 0) { /* Invalid: inverse of the return code tells * the netfilter core what to do */ diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c index d6dde6dc09e6..8ea33598a0a7 100644 --- a/net/netfilter/nf_conntrack_proto_dccp.c +++ b/net/netfilter/nf_conntrack_proto_dccp.c @@ -423,7 +423,7 @@ static bool dccp_invert_tuple(struct nf_conntrack_tuple *inv, } static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { struct net *net = nf_ct_net(ct); struct dccp_net *dn; @@ -472,12 +472,17 @@ static u64 dccp_ack_seq(const struct dccp_hdr *dh) ntohl(dhack->dccph_ack_nr_low); } +static unsigned int *dccp_get_timeouts(struct net *net) +{ + return dccp_pernet(net)->dccp_timeout; +} + static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - u_int8_t pf, unsigned int hooknum) + u_int8_t pf, unsigned int hooknum, + unsigned int *timeouts) { struct net *net = nf_ct_net(ct); - struct dccp_net *dn; enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); struct dccp_hdr _dh, *dh; u_int8_t type, old_state, new_state; @@ -559,8 +564,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, if (new_state != old_state) nf_conntrack_event_cache(IPCT_PROTOINFO, ct); - dn = dccp_pernet(net); - nf_ct_refresh_acct(ct, ctinfo, skb, dn->dccp_timeout[new_state]); + nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[new_state]); return NF_ACCEPT; } @@ -767,6 +771,7 @@ static struct nf_conntrack_l4proto dccp_proto4 __read_mostly = { .invert_tuple = dccp_invert_tuple, .new = dccp_new, .packet = dccp_packet, + .get_timeouts = dccp_get_timeouts, .error = dccp_error, .print_tuple = dccp_print_tuple, .print_conntrack = dccp_print_conntrack, @@ -789,6 +794,7 @@ static struct nf_conntrack_l4proto dccp_proto6 __read_mostly = { .invert_tuple = dccp_invert_tuple, .new = dccp_new, .packet = dccp_packet, + .get_timeouts = dccp_get_timeouts, .error = dccp_error, .print_tuple = dccp_print_tuple, .print_conntrack = dccp_print_conntrack, diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c index e2091d0c7a2f..0e6c5451db80 100644 --- a/net/netfilter/nf_conntrack_proto_generic.c +++ b/net/netfilter/nf_conntrack_proto_generic.c @@ -40,21 +40,27 @@ static int generic_print_tuple(struct seq_file *s, return 0; } +static unsigned int *generic_get_timeouts(struct net *net) +{ + return &nf_ct_generic_timeout; +} + /* Returns verdict for packet, or -1 for invalid. */ -static int packet(struct nf_conn *ct, - const struct sk_buff *skb, - unsigned int dataoff, - enum ip_conntrack_info ctinfo, - u_int8_t pf, - unsigned int hooknum) +static int generic_packet(struct nf_conn *ct, + const struct sk_buff *skb, + unsigned int dataoff, + enum ip_conntrack_info ctinfo, + u_int8_t pf, + unsigned int hooknum, + unsigned int *timeout) { - nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_generic_timeout); + nf_ct_refresh_acct(ct, ctinfo, skb, *timeout); return NF_ACCEPT; } /* Called when a new connection for this protocol found. */ -static bool new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) +static bool generic_new(struct nf_conn *ct, const struct sk_buff *skb, + unsigned int dataoff, unsigned int *timeouts) { return true; } @@ -93,8 +99,9 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly = .pkt_to_tuple = generic_pkt_to_tuple, .invert_tuple = generic_invert_tuple, .print_tuple = generic_print_tuple, - .packet = packet, - .new = new, + .packet = generic_packet, + .get_timeouts = generic_get_timeouts, + .new = generic_new, #ifdef CONFIG_SYSCTL .ctl_table_header = &generic_sysctl_header, .ctl_table = generic_sysctl_table, diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index 8144f22d159a..1bf01c95658b 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c @@ -235,13 +235,19 @@ static int gre_print_conntrack(struct seq_file *s, struct nf_conn *ct) (ct->proto.gre.stream_timeout / HZ)); } +static unsigned int *gre_get_timeouts(struct net *net) +{ + return gre_timeouts; +} + /* Returns verdict for packet, and may modify conntrack */ static int gre_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeouts) { /* If we've seen traffic both ways, this is a GRE connection. * Extend timeout. */ @@ -260,15 +266,15 @@ static int gre_packet(struct nf_conn *ct, /* Called when a new connection for this protocol found. */ static bool gre_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { pr_debug(": "); nf_ct_dump_tuple(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); /* initialize to sane value. Ideally a conntrack helper * (e.g. in case of pptp) is increasing them */ - ct->proto.gre.stream_timeout = gre_timeouts[GRE_CT_REPLIED]; - ct->proto.gre.timeout = gre_timeouts[GRE_CT_UNREPLIED]; + ct->proto.gre.stream_timeout = timeouts[GRE_CT_REPLIED]; + ct->proto.gre.timeout = timeouts[GRE_CT_UNREPLIED]; return true; } @@ -295,6 +301,7 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 __read_mostly = { .invert_tuple = gre_invert_tuple, .print_tuple = gre_print_tuple, .print_conntrack = gre_print_conntrack, + .get_timeouts = gre_get_timeouts, .packet = gre_packet, .new = gre_new, .destroy = gre_destroy, diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c index afa69136061a..2a0703371e24 100644 --- a/net/netfilter/nf_conntrack_proto_sctp.c +++ b/net/netfilter/nf_conntrack_proto_sctp.c @@ -279,13 +279,19 @@ static int sctp_new_state(enum ip_conntrack_dir dir, return sctp_conntracks[dir][i][cur_state]; } +static unsigned int *sctp_get_timeouts(struct net *net) +{ + return sctp_timeouts; +} + /* Returns verdict for packet, or -NF_ACCEPT for invalid. */ static int sctp_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeouts) { enum sctp_conntrack new_state, old_state; enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); @@ -370,7 +376,7 @@ static int sctp_packet(struct nf_conn *ct, } spin_unlock_bh(&ct->lock); - nf_ct_refresh_acct(ct, ctinfo, skb, sctp_timeouts[new_state]); + nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[new_state]); if (old_state == SCTP_CONNTRACK_COOKIE_ECHOED && dir == IP_CT_DIR_REPLY && @@ -390,7 +396,7 @@ static int sctp_packet(struct nf_conn *ct, /* Called when a new connection for this protocol found. */ static bool sctp_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { enum sctp_conntrack new_state; const struct sctphdr *sh; @@ -664,6 +670,7 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 __read_mostly = { .print_tuple = sctp_print_tuple, .print_conntrack = sctp_print_conntrack, .packet = sctp_packet, + .get_timeouts = sctp_get_timeouts, .new = sctp_new, .me = THIS_MODULE, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) @@ -694,6 +701,7 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 __read_mostly = { .print_tuple = sctp_print_tuple, .print_conntrack = sctp_print_conntrack, .packet = sctp_packet, + .get_timeouts = sctp_get_timeouts, .new = sctp_new, .me = THIS_MODULE, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 57c778546094..8372bb43feb0 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c @@ -813,13 +813,19 @@ static int tcp_error(struct net *net, struct nf_conn *tmpl, return NF_ACCEPT; } +static unsigned int *tcp_get_timeouts(struct net *net) +{ + return tcp_timeouts; +} + /* Returns verdict for packet, or -1 for invalid. */ static int tcp_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeouts) { struct net *net = nf_ct_net(ct); struct nf_conntrack_tuple *tuple; @@ -1014,14 +1020,14 @@ static int tcp_packet(struct nf_conn *ct, ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; if (ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans && - tcp_timeouts[new_state] > tcp_timeouts[TCP_CONNTRACK_RETRANS]) - timeout = tcp_timeouts[TCP_CONNTRACK_RETRANS]; + timeouts[new_state] > timeouts[TCP_CONNTRACK_RETRANS]) + timeout = timeouts[TCP_CONNTRACK_RETRANS]; else if ((ct->proto.tcp.seen[0].flags | ct->proto.tcp.seen[1].flags) & IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED && - tcp_timeouts[new_state] > tcp_timeouts[TCP_CONNTRACK_UNACK]) - timeout = tcp_timeouts[TCP_CONNTRACK_UNACK]; + timeouts[new_state] > timeouts[TCP_CONNTRACK_UNACK]) + timeout = timeouts[TCP_CONNTRACK_UNACK]; else - timeout = tcp_timeouts[new_state]; + timeout = timeouts[new_state]; spin_unlock_bh(&ct->lock); if (new_state != old_state) @@ -1053,7 +1059,7 @@ static int tcp_packet(struct nf_conn *ct, /* Called when a new connection for this protocol found. */ static bool tcp_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { enum tcp_conntrack new_state; const struct tcphdr *th; @@ -1444,6 +1450,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 __read_mostly = .print_tuple = tcp_print_tuple, .print_conntrack = tcp_print_conntrack, .packet = tcp_packet, + .get_timeouts = tcp_get_timeouts, .new = tcp_new, .error = tcp_error, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) @@ -1476,6 +1483,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 __read_mostly = .print_tuple = tcp_print_tuple, .print_conntrack = tcp_print_conntrack, .packet = tcp_packet, + .get_timeouts = tcp_get_timeouts, .new = tcp_new, .error = tcp_error, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c index 5b24ff882f95..70e005992d5b 100644 --- a/net/netfilter/nf_conntrack_proto_udp.c +++ b/net/netfilter/nf_conntrack_proto_udp.c @@ -71,32 +71,38 @@ static int udp_print_tuple(struct seq_file *s, ntohs(tuple->dst.u.udp.port)); } +static unsigned int *udp_get_timeouts(struct net *net) +{ + return udp_timeouts; +} + /* Returns verdict for packet, and may modify conntracktype */ static int udp_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeouts) { /* If we've seen traffic both ways, this is some kind of UDP stream. Extend timeout. */ if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { nf_ct_refresh_acct(ct, ctinfo, skb, - udp_timeouts[UDP_CT_REPLIED]); + timeouts[UDP_CT_REPLIED]); /* Also, more likely to be important, and not a probe */ if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status)) nf_conntrack_event_cache(IPCT_ASSURED, ct); } else { nf_ct_refresh_acct(ct, ctinfo, skb, - udp_timeouts[UDP_CT_UNREPLIED]); + timeouts[UDP_CT_UNREPLIED]); } return NF_ACCEPT; } /* Called when a new connection for this protocol found. */ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { return true; } @@ -196,6 +202,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 __read_mostly = .invert_tuple = udp_invert_tuple, .print_tuple = udp_print_tuple, .packet = udp_packet, + .get_timeouts = udp_get_timeouts, .new = udp_new, .error = udp_error, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) @@ -224,6 +231,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 __read_mostly = .invert_tuple = udp_invert_tuple, .print_tuple = udp_print_tuple, .packet = udp_packet, + .get_timeouts = udp_get_timeouts, .new = udp_new, .error = udp_error, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c index e73071743e01..0b32ccb1d515 100644 --- a/net/netfilter/nf_conntrack_proto_udplite.c +++ b/net/netfilter/nf_conntrack_proto_udplite.c @@ -68,32 +68,38 @@ static int udplite_print_tuple(struct seq_file *s, ntohs(tuple->dst.u.udp.port)); } +static unsigned int *udplite_get_timeouts(struct net *net) +{ + return udplite_timeouts; +} + /* Returns verdict for packet, and may modify conntracktype */ static int udplite_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, - unsigned int hooknum) + unsigned int hooknum, + unsigned int *timeouts) { /* If we've seen traffic both ways, this is some kind of UDP stream. Extend timeout. */ if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { nf_ct_refresh_acct(ct, ctinfo, skb, - udplite_timeouts[UDPLITE_CT_REPLIED]); + timeouts[UDPLITE_CT_REPLIED]); /* Also, more likely to be important, and not a probe */ if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status)) nf_conntrack_event_cache(IPCT_ASSURED, ct); } else { nf_ct_refresh_acct(ct, ctinfo, skb, - udplite_timeouts[UDPLITE_CT_UNREPLIED]); + timeouts[UDPLITE_CT_UNREPLIED]); } return NF_ACCEPT; } /* Called when a new connection for this protocol found. */ static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb, - unsigned int dataoff) + unsigned int dataoff, unsigned int *timeouts) { return true; } @@ -181,6 +187,7 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 __read_mostly = .invert_tuple = udplite_invert_tuple, .print_tuple = udplite_print_tuple, .packet = udplite_packet, + .get_timeouts = udplite_get_timeouts, .new = udplite_new, .error = udplite_error, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) @@ -205,6 +212,7 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 __read_mostly = .invert_tuple = udplite_invert_tuple, .print_tuple = udplite_print_tuple, .packet = udplite_packet, + .get_timeouts = udplite_get_timeouts, .new = udplite_new, .error = udplite_error, #if IS_ENABLED(CONFIG_NF_CT_NETLINK) -- GitLab From 50978462300f74dc48aea4a38471cb69bdf741a5 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 28 Feb 2012 19:13:48 +0100 Subject: [PATCH 1504/1846] netfilter: add cttimeout infrastructure for fine timeout tuning This patch adds the infrastructure to add fine timeout tuning over nfnetlink. Now you can use the NFNL_SUBSYS_CTNETLINK_TIMEOUT subsystem to create/delete/dump timeout objects that contain some specific timeout policy for one flow. The follow up patches will allow you attach timeout policy object to conntrack via the CT target and the conntrack extension infrastructure. Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/Kbuild | 1 + include/linux/netfilter/nfnetlink.h | 3 +- include/linux/netfilter/nfnetlink_cttimeout.h | 114 +++++ include/net/netfilter/nf_conntrack_l4proto.h | 11 + net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 47 +++ .../netfilter/nf_conntrack_proto_icmpv6.c | 47 +++ net/netfilter/Kconfig | 11 + net/netfilter/Makefile | 1 + net/netfilter/nf_conntrack_proto_dccp.c | 70 +++ net/netfilter/nf_conntrack_proto_generic.c | 48 +++ net/netfilter/nf_conntrack_proto_gre.c | 55 +++ net/netfilter/nf_conntrack_proto_sctp.c | 69 +++ net/netfilter/nf_conntrack_proto_tcp.c | 127 ++++++ net/netfilter/nf_conntrack_proto_udp.c | 64 +++ net/netfilter/nf_conntrack_proto_udplite.c | 66 +++ net/netfilter/nfnetlink_cttimeout.c | 398 ++++++++++++++++++ 16 files changed, 1131 insertions(+), 1 deletion(-) create mode 100644 include/linux/netfilter/nfnetlink_cttimeout.h create mode 100644 net/netfilter/nfnetlink_cttimeout.c diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild index aaa72aaa21de..1697036336b6 100644 --- a/include/linux/netfilter/Kbuild +++ b/include/linux/netfilter/Kbuild @@ -10,6 +10,7 @@ header-y += nfnetlink.h header-y += nfnetlink_acct.h header-y += nfnetlink_compat.h header-y += nfnetlink_conntrack.h +header-y += nfnetlink_cttimeout.h header-y += nfnetlink_log.h header-y += nfnetlink_queue.h header-y += x_tables.h diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h index b64454c2f79f..6fd1f0d07e64 100644 --- a/include/linux/netfilter/nfnetlink.h +++ b/include/linux/netfilter/nfnetlink.h @@ -49,7 +49,8 @@ struct nfgenmsg { #define NFNL_SUBSYS_OSF 5 #define NFNL_SUBSYS_IPSET 6 #define NFNL_SUBSYS_ACCT 7 -#define NFNL_SUBSYS_COUNT 8 +#define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8 +#define NFNL_SUBSYS_COUNT 9 #ifdef __KERNEL__ diff --git a/include/linux/netfilter/nfnetlink_cttimeout.h b/include/linux/netfilter/nfnetlink_cttimeout.h new file mode 100644 index 000000000000..a2810a7c5e30 --- /dev/null +++ b/include/linux/netfilter/nfnetlink_cttimeout.h @@ -0,0 +1,114 @@ +#ifndef _CTTIMEOUT_NETLINK_H +#define _CTTIMEOUT_NETLINK_H +#include + +enum ctnl_timeout_msg_types { + IPCTNL_MSG_TIMEOUT_NEW, + IPCTNL_MSG_TIMEOUT_GET, + IPCTNL_MSG_TIMEOUT_DELETE, + + IPCTNL_MSG_TIMEOUT_MAX +}; + +enum ctattr_timeout { + CTA_TIMEOUT_UNSPEC, + CTA_TIMEOUT_NAME, + CTA_TIMEOUT_L3PROTO, + CTA_TIMEOUT_L4PROTO, + CTA_TIMEOUT_DATA, + CTA_TIMEOUT_USE, + __CTA_TIMEOUT_MAX +}; +#define CTA_TIMEOUT_MAX (__CTA_TIMEOUT_MAX - 1) + +enum ctattr_timeout_generic { + CTA_TIMEOUT_GENERIC_UNSPEC, + CTA_TIMEOUT_GENERIC_TIMEOUT, + __CTA_TIMEOUT_GENERIC_MAX +}; +#define CTA_TIMEOUT_GENERIC_MAX (__CTA_TIMEOUT_GENERIC_MAX - 1) + +enum ctattr_timeout_tcp { + CTA_TIMEOUT_TCP_UNSPEC, + CTA_TIMEOUT_TCP_SYN_SENT, + CTA_TIMEOUT_TCP_SYN_RECV, + CTA_TIMEOUT_TCP_ESTABLISHED, + CTA_TIMEOUT_TCP_FIN_WAIT, + CTA_TIMEOUT_TCP_CLOSE_WAIT, + CTA_TIMEOUT_TCP_LAST_ACK, + CTA_TIMEOUT_TCP_TIME_WAIT, + CTA_TIMEOUT_TCP_CLOSE, + CTA_TIMEOUT_TCP_SYN_SENT2, + CTA_TIMEOUT_TCP_RETRANS, + CTA_TIMEOUT_TCP_UNACK, + __CTA_TIMEOUT_TCP_MAX +}; +#define CTA_TIMEOUT_TCP_MAX (__CTA_TIMEOUT_TCP_MAX - 1) + +enum ctattr_timeout_udp { + CTA_TIMEOUT_UDP_UNSPEC, + CTA_TIMEOUT_UDP_UNREPLIED, + CTA_TIMEOUT_UDP_REPLIED, + __CTA_TIMEOUT_UDP_MAX +}; +#define CTA_TIMEOUT_UDP_MAX (__CTA_TIMEOUT_UDP_MAX - 1) + +enum ctattr_timeout_udplite { + CTA_TIMEOUT_UDPLITE_UNSPEC, + CTA_TIMEOUT_UDPLITE_UNREPLIED, + CTA_TIMEOUT_UDPLITE_REPLIED, + __CTA_TIMEOUT_UDPLITE_MAX +}; +#define CTA_TIMEOUT_UDPLITE_MAX (__CTA_TIMEOUT_UDPLITE_MAX - 1) + +enum ctattr_timeout_icmp { + CTA_TIMEOUT_ICMP_UNSPEC, + CTA_TIMEOUT_ICMP_TIMEOUT, + __CTA_TIMEOUT_ICMP_MAX +}; +#define CTA_TIMEOUT_ICMP_MAX (__CTA_TIMEOUT_ICMP_MAX - 1) + +enum ctattr_timeout_dccp { + CTA_TIMEOUT_DCCP_UNSPEC, + CTA_TIMEOUT_DCCP_REQUEST, + CTA_TIMEOUT_DCCP_RESPOND, + CTA_TIMEOUT_DCCP_PARTOPEN, + CTA_TIMEOUT_DCCP_OPEN, + CTA_TIMEOUT_DCCP_CLOSEREQ, + CTA_TIMEOUT_DCCP_CLOSING, + CTA_TIMEOUT_DCCP_TIMEWAIT, + __CTA_TIMEOUT_DCCP_MAX +}; +#define CTA_TIMEOUT_DCCP_MAX (__CTA_TIMEOUT_DCCP_MAX - 1) + +enum ctattr_timeout_sctp { + CTA_TIMEOUT_SCTP_UNSPEC, + CTA_TIMEOUT_SCTP_CLOSED, + CTA_TIMEOUT_SCTP_COOKIE_WAIT, + CTA_TIMEOUT_SCTP_COOKIE_ECHOED, + CTA_TIMEOUT_SCTP_ESTABLISHED, + CTA_TIMEOUT_SCTP_SHUTDOWN_SENT, + CTA_TIMEOUT_SCTP_SHUTDOWN_RECD, + CTA_TIMEOUT_SCTP_SHUTDOWN_ACK_SENT, + __CTA_TIMEOUT_SCTP_MAX +}; +#define CTA_TIMEOUT_SCTP_MAX (__CTA_TIMEOUT_SCTP_MAX - 1) + +enum ctattr_timeout_icmpv6 { + CTA_TIMEOUT_ICMPV6_UNSPEC, + CTA_TIMEOUT_ICMPV6_TIMEOUT, + __CTA_TIMEOUT_ICMPV6_MAX +}; +#define CTA_TIMEOUT_ICMPV6_MAX (__CTA_TIMEOUT_ICMPV6_MAX - 1) + +enum ctattr_timeout_gre { + CTA_TIMEOUT_GRE_UNSPEC, + CTA_TIMEOUT_GRE_UNREPLIED, + CTA_TIMEOUT_GRE_REPLIED, + __CTA_TIMEOUT_GRE_MAX +}; +#define CTA_TIMEOUT_GRE_MAX (__CTA_TIMEOUT_GRE_MAX - 1) + +#define CTNL_TIMEOUT_NAME_MAX 32 + +#endif diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index c48b67405aa0..90c67c7db7e9 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h @@ -83,6 +83,17 @@ struct nf_conntrack_l4proto { size_t nla_size; +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + struct { + size_t obj_size; + int (*nlattr_to_obj)(struct nlattr *tb[], void *data); + int (*obj_to_nlattr)(struct sk_buff *skb, const void *data); + + unsigned int nlattr_max; + const struct nla_policy *nla_policy; + } ctnl_timeout; +#endif + #ifdef CONFIG_SYSCTL struct ctl_table_header **ctl_table_header; struct ctl_table *ctl_table; diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index 6b801124b31f..7cbe9cb261c2 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c @@ -269,6 +269,44 @@ static int icmp_nlattr_tuple_size(void) } #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + +#include +#include + +static int icmp_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeout = data; + + if (tb[CTA_TIMEOUT_ICMP_TIMEOUT]) { + *timeout = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_ICMP_TIMEOUT])) * HZ; + } else { + /* Set default ICMP timeout. */ + *timeout = nf_ct_icmp_timeout; + } + return 0; +} + +static int +icmp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) +{ + const unsigned int *timeout = data; + + NLA_PUT_BE32(skb, CTA_TIMEOUT_ICMP_TIMEOUT, htonl(*timeout / HZ)); + + return 0; + +nla_put_failure: + return -ENOSPC; +} + +static const struct nla_policy +icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = { + [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 }, +}; +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ + #ifdef CONFIG_SYSCTL static struct ctl_table_header *icmp_sysctl_header; static struct ctl_table icmp_sysctl_table[] = { @@ -315,6 +353,15 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly = .nlattr_to_tuple = icmp_nlattr_to_tuple, .nla_policy = icmp_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = icmp_timeout_nlattr_to_obj, + .obj_to_nlattr = icmp_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_ICMP_MAX, + .obj_size = sizeof(unsigned int), + .nla_policy = icmp_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_header = &icmp_sysctl_header, .ctl_table = icmp_sysctl_table, diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index 2eb9751eb7a8..92cc9f2931ae 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c @@ -276,6 +276,44 @@ static int icmpv6_nlattr_tuple_size(void) } #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + +#include +#include + +static int icmpv6_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeout = data; + + if (tb[CTA_TIMEOUT_ICMPV6_TIMEOUT]) { + *timeout = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_ICMPV6_TIMEOUT])) * HZ; + } else { + /* Set default ICMPv6 timeout. */ + *timeout = nf_ct_icmpv6_timeout; + } + return 0; +} + +static int +icmpv6_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) +{ + const unsigned int *timeout = data; + + NLA_PUT_BE32(skb, CTA_TIMEOUT_ICMPV6_TIMEOUT, htonl(*timeout / HZ)); + + return 0; + +nla_put_failure: + return -ENOSPC; +} + +static const struct nla_policy +icmpv6_timeout_nla_policy[CTA_TIMEOUT_ICMPV6_MAX+1] = { + [CTA_TIMEOUT_ICMPV6_TIMEOUT] = { .type = NLA_U32 }, +}; +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ + #ifdef CONFIG_SYSCTL static struct ctl_table_header *icmpv6_sysctl_header; static struct ctl_table icmpv6_sysctl_table[] = { @@ -308,6 +346,15 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly = .nlattr_to_tuple = icmpv6_nlattr_to_tuple, .nla_policy = icmpv6_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = icmpv6_timeout_nlattr_to_obj, + .obj_to_nlattr = icmpv6_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_ICMP_MAX, + .obj_size = sizeof(unsigned int), + .nla_policy = icmpv6_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_header = &icmpv6_sysctl_header, .ctl_table = icmpv6_sysctl_table, diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index b895d8b13215..f3efb6570dd9 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig @@ -314,6 +314,17 @@ config NF_CT_NETLINK help This option enables support for a netlink-based userspace interface +config NF_CT_NETLINK_TIMEOUT + tristate 'Connection tracking timeout tuning via Netlink' + select NETFILTER_NETLINK + depends on NETFILTER_ADVANCED + help + This option enables support for connection tracking timeout + fine-grain tuning. This allows you to attach specific timeout + policies to flows, instead of using the global timeout policy. + + If unsure, say `N'. + endif # NF_CONNTRACK # transparent proxy support diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index a28c2a6563f8..cf7cdd630bdd 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_NF_CT_PROTO_UDPLITE) += nf_conntrack_proto_udplite.o # netlink interface for nf_conntrack obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o +obj-$(CONFIG_NF_CT_NETLINK_TIMEOUT) += nfnetlink_cttimeout.o # connection tracking helpers nf_conntrack_h323-objs := nf_conntrack_h323_main.o nf_conntrack_h323_asn1.o diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c index 8ea33598a0a7..24fdce256cb0 100644 --- a/net/netfilter/nf_conntrack_proto_dccp.c +++ b/net/netfilter/nf_conntrack_proto_dccp.c @@ -706,8 +706,60 @@ static int dccp_nlattr_size(void) return nla_total_size(0) /* CTA_PROTOINFO_DCCP */ + nla_policy_len(dccp_nla_policy, CTA_PROTOINFO_DCCP_MAX + 1); } + #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + +#include +#include + +static int dccp_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + struct dccp_net *dn = dccp_pernet(&init_net); + unsigned int *timeouts = data; + int i; + + /* set default DCCP timeouts. */ + for (i=0; idccp_timeout[i]; + + /* there's a 1:1 mapping between attributes and protocol states. */ + for (i=CTA_TIMEOUT_DCCP_UNSPEC+1; i +#include + +static int generic_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeout = data; + + if (tb[CTA_TIMEOUT_GENERIC_TIMEOUT]) + *timeout = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_GENERIC_TIMEOUT])) * HZ; + else { + /* Set default generic timeout. */ + *timeout = nf_ct_generic_timeout; + } + + return 0; +} + +static int +generic_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) +{ + const unsigned int *timeout = data; + + NLA_PUT_BE32(skb, CTA_TIMEOUT_GENERIC_TIMEOUT, htonl(*timeout / HZ)); + + return 0; + +nla_put_failure: + return -ENOSPC; +} + +static const struct nla_policy +generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = { + [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 }, +}; +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ + #ifdef CONFIG_SYSCTL static struct ctl_table_header *generic_sysctl_header; static struct ctl_table generic_sysctl_table[] = { @@ -102,6 +141,15 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly = .packet = generic_packet, .get_timeouts = generic_get_timeouts, .new = generic_new, +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = generic_timeout_nlattr_to_obj, + .obj_to_nlattr = generic_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_GENERIC_MAX, + .obj_size = sizeof(unsigned int), + .nla_policy = generic_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_header = &generic_sysctl_header, .ctl_table = generic_sysctl_table, diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index 1bf01c95658b..659648c4b14a 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c @@ -292,6 +292,52 @@ static void gre_destroy(struct nf_conn *ct) nf_ct_gre_keymap_destroy(master); } +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + +#include +#include + +static int gre_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeouts = data; + + /* set default timeouts for GRE. */ + timeouts[GRE_CT_UNREPLIED] = gre_timeouts[GRE_CT_UNREPLIED]; + timeouts[GRE_CT_REPLIED] = gre_timeouts[GRE_CT_REPLIED]; + + if (tb[CTA_TIMEOUT_GRE_UNREPLIED]) { + timeouts[GRE_CT_UNREPLIED] = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_GRE_UNREPLIED])) * HZ; + } + if (tb[CTA_TIMEOUT_GRE_REPLIED]) { + timeouts[GRE_CT_REPLIED] = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_GRE_REPLIED])) * HZ; + } + return 0; +} + +static int +gre_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) +{ + const unsigned int *timeouts = data; + + NLA_PUT_BE32(skb, CTA_TIMEOUT_GRE_UNREPLIED, + htonl(timeouts[GRE_CT_UNREPLIED] / HZ)); + NLA_PUT_BE32(skb, CTA_TIMEOUT_GRE_REPLIED, + htonl(timeouts[GRE_CT_REPLIED] / HZ)); + return 0; + +nla_put_failure: + return -ENOSPC; +} + +static const struct nla_policy +gre_timeout_nla_policy[CTA_TIMEOUT_GRE_MAX+1] = { + [CTA_TIMEOUT_GRE_UNREPLIED] = { .type = NLA_U32 }, + [CTA_TIMEOUT_GRE_REPLIED] = { .type = NLA_U32 }, +}; +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ + /* protocol helper struct */ static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 __read_mostly = { .l3proto = AF_INET, @@ -312,6 +358,15 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 __read_mostly = { .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = gre_timeout_nlattr_to_obj, + .obj_to_nlattr = gre_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_GRE_MAX, + .obj_size = sizeof(unsigned int) * GRE_CT_MAX, + .nla_policy = gre_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ }; static int proto_gre_net_init(struct net *net) diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c index 2a0703371e24..72b5088592dc 100644 --- a/net/netfilter/nf_conntrack_proto_sctp.c +++ b/net/netfilter/nf_conntrack_proto_sctp.c @@ -549,6 +549,57 @@ static int sctp_nlattr_size(void) } #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + +#include +#include + +static int sctp_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeouts = data; + int i; + + /* set default SCTP timeouts. */ + for (i=0; i +#include + +static int tcp_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeouts = data; + int i; + + /* set default TCP timeouts. */ + for (i=0; i +#include + +static int udp_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeouts = data; + + /* set default timeouts for UDP. */ + timeouts[UDP_CT_UNREPLIED] = udp_timeouts[UDP_CT_UNREPLIED]; + timeouts[UDP_CT_REPLIED] = udp_timeouts[UDP_CT_REPLIED]; + + if (tb[CTA_TIMEOUT_UDP_UNREPLIED]) { + timeouts[UDP_CT_UNREPLIED] = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDP_UNREPLIED])) * HZ; + } + if (tb[CTA_TIMEOUT_UDP_REPLIED]) { + timeouts[UDP_CT_REPLIED] = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDP_REPLIED])) * HZ; + } + return 0; +} + +static int +udp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) +{ + const unsigned int *timeouts = data; + + NLA_PUT_BE32(skb, CTA_TIMEOUT_UDP_UNREPLIED, + htonl(timeouts[UDP_CT_UNREPLIED] / HZ)); + NLA_PUT_BE32(skb, CTA_TIMEOUT_UDP_REPLIED, + htonl(timeouts[UDP_CT_REPLIED] / HZ)); + return 0; + +nla_put_failure: + return -ENOSPC; +} + +static const struct nla_policy +udp_timeout_nla_policy[CTA_TIMEOUT_UDP_MAX+1] = { + [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 }, + [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 }, +}; +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ + #ifdef CONFIG_SYSCTL static unsigned int udp_sysctl_table_users; static struct ctl_table_header *udp_sysctl_header; @@ -211,6 +257,15 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 __read_mostly = .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = udp_timeout_nlattr_to_obj, + .obj_to_nlattr = udp_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_UDP_MAX, + .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, + .nla_policy = udp_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_users = &udp_sysctl_table_users, .ctl_table_header = &udp_sysctl_header, @@ -240,6 +295,15 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 __read_mostly = .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, .nla_policy = nf_ct_port_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = udp_timeout_nlattr_to_obj, + .obj_to_nlattr = udp_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_UDP_MAX, + .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, + .nla_policy = udp_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_users = &udp_sysctl_table_users, .ctl_table_header = &udp_sysctl_header, diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c index 0b32ccb1d515..e0606392cda0 100644 --- a/net/netfilter/nf_conntrack_proto_udplite.c +++ b/net/netfilter/nf_conntrack_proto_udplite.c @@ -156,6 +156,52 @@ static int udplite_error(struct net *net, struct nf_conn *tmpl, return NF_ACCEPT; } +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + +#include +#include + +static int udplite_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) +{ + unsigned int *timeouts = data; + + /* set default timeouts for UDPlite. */ + timeouts[UDPLITE_CT_UNREPLIED] = udplite_timeouts[UDPLITE_CT_UNREPLIED]; + timeouts[UDPLITE_CT_REPLIED] = udplite_timeouts[UDPLITE_CT_REPLIED]; + + if (tb[CTA_TIMEOUT_UDPLITE_UNREPLIED]) { + timeouts[UDPLITE_CT_UNREPLIED] = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDPLITE_UNREPLIED])) * HZ; + } + if (tb[CTA_TIMEOUT_UDPLITE_REPLIED]) { + timeouts[UDPLITE_CT_REPLIED] = + ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDPLITE_REPLIED])) * HZ; + } + return 0; +} + +static int +udplite_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) +{ + const unsigned int *timeouts = data; + + NLA_PUT_BE32(skb, CTA_TIMEOUT_UDPLITE_UNREPLIED, + htonl(timeouts[UDPLITE_CT_UNREPLIED] / HZ)); + NLA_PUT_BE32(skb, CTA_TIMEOUT_UDPLITE_REPLIED, + htonl(timeouts[UDPLITE_CT_REPLIED] / HZ)); + return 0; + +nla_put_failure: + return -ENOSPC; +} + +static const struct nla_policy +udplite_timeout_nla_policy[CTA_TIMEOUT_UDPLITE_MAX+1] = { + [CTA_TIMEOUT_UDPLITE_UNREPLIED] = { .type = NLA_U32 }, + [CTA_TIMEOUT_UDPLITE_REPLIED] = { .type = NLA_U32 }, +}; +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ + #ifdef CONFIG_SYSCTL static unsigned int udplite_sysctl_table_users; static struct ctl_table_header *udplite_sysctl_header; @@ -196,6 +242,16 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 __read_mostly = .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = udplite_timeout_nlattr_to_obj, + .obj_to_nlattr = udplite_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_UDPLITE_MAX, + .obj_size = sizeof(unsigned int) * + CTA_TIMEOUT_UDPLITE_MAX, + .nla_policy = udplite_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_users = &udplite_sysctl_table_users, .ctl_table_header = &udplite_sysctl_header, @@ -221,6 +277,16 @@ static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 __read_mostly = .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, .nla_policy = nf_ct_port_nla_policy, #endif +#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) + .ctnl_timeout = { + .nlattr_to_obj = udplite_timeout_nlattr_to_obj, + .obj_to_nlattr = udplite_timeout_obj_to_nlattr, + .nlattr_max = CTA_TIMEOUT_UDPLITE_MAX, + .obj_size = sizeof(unsigned int) * + CTA_TIMEOUT_UDPLITE_MAX, + .nla_policy = udplite_timeout_nla_policy, + }, +#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ #ifdef CONFIG_SYSCTL .ctl_table_users = &udplite_sysctl_table_users, .ctl_table_header = &udplite_sysctl_header, diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c new file mode 100644 index 000000000000..b860d5217189 --- /dev/null +++ b/net/netfilter/nfnetlink_cttimeout.c @@ -0,0 +1,398 @@ +/* + * (C) 2012 by Pablo Neira Ayuso + * (C) 2012 by Vyatta Inc. + * + * 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 (or any later at your option). + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Pablo Neira Ayuso "); +MODULE_DESCRIPTION("cttimeout: Extended Netfilter Connection Tracking timeout tuning"); + +struct ctnl_timeout { + struct list_head head; + struct rcu_head rcu_head; + atomic_t refcnt; + char name[CTNL_TIMEOUT_NAME_MAX]; + __u16 l3num; + __u8 l4num; + char data[0]; +}; + +static LIST_HEAD(cttimeout_list); + +static const struct nla_policy cttimeout_nla_policy[CTA_TIMEOUT_MAX+1] = { + [CTA_TIMEOUT_NAME] = { .type = NLA_NUL_STRING }, + [CTA_TIMEOUT_L3PROTO] = { .type = NLA_U16 }, + [CTA_TIMEOUT_L4PROTO] = { .type = NLA_U8 }, + [CTA_TIMEOUT_DATA] = { .type = NLA_NESTED }, +}; + +static int +ctnl_timeout_parse_policy(struct ctnl_timeout *timeout, + struct nf_conntrack_l4proto *l4proto, + const struct nlattr *attr) +{ + int ret = 0; + + if (likely(l4proto->ctnl_timeout.nlattr_to_obj)) { + struct nlattr *tb[l4proto->ctnl_timeout.nlattr_max+1]; + + nla_parse_nested(tb, l4proto->ctnl_timeout.nlattr_max, + attr, l4proto->ctnl_timeout.nla_policy); + + ret = l4proto->ctnl_timeout.nlattr_to_obj(tb, &timeout->data); + } + return ret; +} + +static int +cttimeout_new_timeout(struct sock *ctnl, struct sk_buff *skb, + const struct nlmsghdr *nlh, + const struct nlattr * const cda[]) +{ + __u16 l3num; + __u8 l4num; + struct nf_conntrack_l4proto *l4proto; + struct ctnl_timeout *timeout, *matching = NULL; + char *name; + int ret; + + if (!cda[CTA_TIMEOUT_NAME] || + !cda[CTA_TIMEOUT_L3PROTO] || + !cda[CTA_TIMEOUT_L4PROTO] || + !cda[CTA_TIMEOUT_DATA]) + return -EINVAL; + + name = nla_data(cda[CTA_TIMEOUT_NAME]); + l3num = ntohs(nla_get_be16(cda[CTA_TIMEOUT_L3PROTO])); + l4num = nla_get_u8(cda[CTA_TIMEOUT_L4PROTO]); + + list_for_each_entry(timeout, &cttimeout_list, head) { + if (strncmp(timeout->name, name, CTNL_TIMEOUT_NAME_MAX) != 0) + continue; + + if (nlh->nlmsg_flags & NLM_F_EXCL) + return -EEXIST; + + matching = timeout; + break; + } + + l4proto = __nf_ct_l4proto_find(l3num, l4num); + + /* This protocol is not supportted, skip. */ + if (l4proto->l4proto != l4num) + return -EOPNOTSUPP; + + if (matching) { + if (nlh->nlmsg_flags & NLM_F_REPLACE) { + /* You cannot replace one timeout policy by another of + * different kind, sorry. + */ + if (matching->l3num != l3num || + matching->l4num != l4num) + return -EINVAL; + + ret = ctnl_timeout_parse_policy(matching, l4proto, + cda[CTA_TIMEOUT_DATA]); + return ret; + } + return -EBUSY; + } + + timeout = kzalloc(sizeof(struct ctnl_timeout) + + l4proto->ctnl_timeout.obj_size, GFP_KERNEL); + if (timeout == NULL) + return -ENOMEM; + + ret = ctnl_timeout_parse_policy(timeout, l4proto, + cda[CTA_TIMEOUT_DATA]); + if (ret < 0) + goto err; + + strcpy(timeout->name, nla_data(cda[CTA_TIMEOUT_NAME])); + timeout->l3num = l3num; + timeout->l4num = l4num; + atomic_set(&timeout->refcnt, 1); + list_add_tail_rcu(&timeout->head, &cttimeout_list); + + return 0; +err: + kfree(timeout); + return ret; +} + +static int +ctnl_timeout_fill_info(struct sk_buff *skb, u32 pid, u32 seq, u32 type, + int event, struct ctnl_timeout *timeout) +{ + struct nlmsghdr *nlh; + struct nfgenmsg *nfmsg; + unsigned int flags = pid ? NLM_F_MULTI : 0; + struct nf_conntrack_l4proto *l4proto; + + event |= NFNL_SUBSYS_CTNETLINK_TIMEOUT << 8; + nlh = nlmsg_put(skb, pid, seq, event, sizeof(*nfmsg), flags); + if (nlh == NULL) + goto nlmsg_failure; + + nfmsg = nlmsg_data(nlh); + nfmsg->nfgen_family = AF_UNSPEC; + nfmsg->version = NFNETLINK_V0; + nfmsg->res_id = 0; + + NLA_PUT_STRING(skb, CTA_TIMEOUT_NAME, timeout->name); + NLA_PUT_BE16(skb, CTA_TIMEOUT_L3PROTO, htons(timeout->l3num)); + NLA_PUT_U8(skb, CTA_TIMEOUT_L4PROTO, timeout->l4num); + NLA_PUT_BE32(skb, CTA_TIMEOUT_USE, + htonl(atomic_read(&timeout->refcnt))); + + l4proto = __nf_ct_l4proto_find(timeout->l3num, timeout->l4num); + + /* If the timeout object does not match the layer 4 protocol tracker, + * then skip dumping the data part since we don't know how to + * interpret it. This may happen for UPDlite, SCTP and DCCP since + * you can unload the module. + */ + if (timeout->l4num != l4proto->l4proto) + goto out; + + if (likely(l4proto->ctnl_timeout.obj_to_nlattr)) { + struct nlattr *nest_parms; + int ret; + + nest_parms = nla_nest_start(skb, + CTA_TIMEOUT_DATA | NLA_F_NESTED); + if (!nest_parms) + goto nla_put_failure; + + ret = l4proto->ctnl_timeout.obj_to_nlattr(skb, &timeout->data); + if (ret < 0) + goto nla_put_failure; + + nla_nest_end(skb, nest_parms); + } +out: + nlmsg_end(skb, nlh); + return skb->len; + +nlmsg_failure: +nla_put_failure: + nlmsg_cancel(skb, nlh); + return -1; +} + +static int +ctnl_timeout_dump(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct ctnl_timeout *cur, *last; + + if (cb->args[2]) + return 0; + + last = (struct ctnl_timeout *)cb->args[1]; + if (cb->args[1]) + cb->args[1] = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(cur, &cttimeout_list, head) { + if (last && cur != last) + continue; + + if (ctnl_timeout_fill_info(skb, NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq, + NFNL_MSG_TYPE(cb->nlh->nlmsg_type), + IPCTNL_MSG_TIMEOUT_NEW, cur) < 0) { + cb->args[1] = (unsigned long)cur; + break; + } + } + if (!cb->args[1]) + cb->args[2] = 1; + rcu_read_unlock(); + return skb->len; +} + +static int +cttimeout_get_timeout(struct sock *ctnl, struct sk_buff *skb, + const struct nlmsghdr *nlh, + const struct nlattr * const cda[]) +{ + int ret = -ENOENT; + char *name; + struct ctnl_timeout *cur; + + if (nlh->nlmsg_flags & NLM_F_DUMP) { + struct netlink_dump_control c = { + .dump = ctnl_timeout_dump, + }; + return netlink_dump_start(ctnl, skb, nlh, &c); + } + + if (!cda[CTA_TIMEOUT_NAME]) + return -EINVAL; + name = nla_data(cda[CTA_TIMEOUT_NAME]); + + list_for_each_entry(cur, &cttimeout_list, head) { + struct sk_buff *skb2; + + if (strncmp(cur->name, name, CTNL_TIMEOUT_NAME_MAX) != 0) + continue; + + skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (skb2 == NULL) { + ret = -ENOMEM; + break; + } + + ret = ctnl_timeout_fill_info(skb2, NETLINK_CB(skb).pid, + nlh->nlmsg_seq, + NFNL_MSG_TYPE(nlh->nlmsg_type), + IPCTNL_MSG_TIMEOUT_NEW, cur); + if (ret <= 0) { + kfree_skb(skb2); + break; + } + ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, + MSG_DONTWAIT); + if (ret > 0) + ret = 0; + + /* this avoids a loop in nfnetlink. */ + return ret == -EAGAIN ? -ENOBUFS : ret; + } + return ret; +} + +/* try to delete object, fail if it is still in use. */ +static int ctnl_timeout_try_del(struct ctnl_timeout *timeout) +{ + int ret = 0; + + /* we want to avoid races with nf_ct_timeout_find_get. */ + if (atomic_dec_and_test(&timeout->refcnt)) { + /* We are protected by nfnl mutex. */ + list_del_rcu(&timeout->head); + kfree_rcu(timeout, rcu_head); + } else { + /* still in use, restore reference counter. */ + atomic_inc(&timeout->refcnt); + ret = -EBUSY; + } + return ret; +} + +static int +cttimeout_del_timeout(struct sock *ctnl, struct sk_buff *skb, + const struct nlmsghdr *nlh, + const struct nlattr * const cda[]) +{ + char *name; + struct ctnl_timeout *cur; + int ret = -ENOENT; + + if (!cda[CTA_TIMEOUT_NAME]) { + list_for_each_entry(cur, &cttimeout_list, head) + ctnl_timeout_try_del(cur); + + return 0; + } + name = nla_data(cda[CTA_TIMEOUT_NAME]); + + list_for_each_entry(cur, &cttimeout_list, head) { + if (strncmp(cur->name, name, CTNL_TIMEOUT_NAME_MAX) != 0) + continue; + + ret = ctnl_timeout_try_del(cur); + if (ret < 0) + return ret; + + break; + } + return ret; +} + +static const struct nfnl_callback cttimeout_cb[IPCTNL_MSG_TIMEOUT_MAX] = { + [IPCTNL_MSG_TIMEOUT_NEW] = { .call = cttimeout_new_timeout, + .attr_count = CTA_TIMEOUT_MAX, + .policy = cttimeout_nla_policy }, + [IPCTNL_MSG_TIMEOUT_GET] = { .call = cttimeout_get_timeout, + .attr_count = CTA_TIMEOUT_MAX, + .policy = cttimeout_nla_policy }, + [IPCTNL_MSG_TIMEOUT_DELETE] = { .call = cttimeout_del_timeout, + .attr_count = CTA_TIMEOUT_MAX, + .policy = cttimeout_nla_policy }, +}; + +static const struct nfnetlink_subsystem cttimeout_subsys = { + .name = "conntrack_timeout", + .subsys_id = NFNL_SUBSYS_CTNETLINK_TIMEOUT, + .cb_count = IPCTNL_MSG_TIMEOUT_MAX, + .cb = cttimeout_cb, +}; + +MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_TIMEOUT); + +static int __init cttimeout_init(void) +{ + int ret; + + ret = nfnetlink_subsys_register(&cttimeout_subsys); + if (ret < 0) { + pr_err("cttimeout_init: cannot register cttimeout with " + "nfnetlink.\n"); + goto err_out; + } + return 0; + +err_out: + return ret; +} + +static void __exit cttimeout_exit(void) +{ + struct ctnl_timeout *cur, *tmp; + + pr_info("cttimeout: unregistering from nfnetlink.\n"); + + nfnetlink_subsys_unregister(&cttimeout_subsys); + list_for_each_entry_safe(cur, tmp, &cttimeout_list, head) { + list_del_rcu(&cur->head); + /* We are sure that our objects have no clients at this point, + * it's safe to release them all without checking refcnt. + */ + kfree_rcu(cur, rcu_head); + } +} + +module_init(cttimeout_init); +module_exit(cttimeout_exit); -- GitLab From dd705072412225a97784fe38feee2ebf8d14814d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 28 Feb 2012 23:36:48 +0100 Subject: [PATCH 1505/1846] netfilter: nf_ct_ext: add timeout extension This patch adds the timeout extension, which allows you to attach specific timeout policies to flows. This extension is only used by the template conntrack. Signed-off-by: Pablo Neira Ayuso --- include/net/netfilter/nf_conntrack_extend.h | 4 + include/net/netfilter/nf_conntrack_timeout.h | 78 ++++++++++++++++++++ net/netfilter/Kconfig | 10 +++ net/netfilter/Makefile | 1 + net/netfilter/nf_conntrack_core.c | 7 ++ net/netfilter/nf_conntrack_timeout.c | 60 +++++++++++++++ net/netfilter/nfnetlink_cttimeout.c | 10 --- 7 files changed, 160 insertions(+), 10 deletions(-) create mode 100644 include/net/netfilter/nf_conntrack_timeout.h create mode 100644 net/netfilter/nf_conntrack_timeout.c diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h index 2dcf31703acb..96755c3798a5 100644 --- a/include/net/netfilter/nf_conntrack_extend.h +++ b/include/net/netfilter/nf_conntrack_extend.h @@ -19,6 +19,9 @@ enum nf_ct_ext_id { #endif #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP NF_CT_EXT_TSTAMP, +#endif +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + NF_CT_EXT_TIMEOUT, #endif NF_CT_EXT_NUM, }; @@ -29,6 +32,7 @@ enum nf_ct_ext_id { #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone #define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp +#define NF_CT_EXT_TIMEOUT_TYPE struct nf_conn_timeout /* Extensions: optional stuff which isn't permanently in struct. */ struct nf_ct_ext { diff --git a/include/net/netfilter/nf_conntrack_timeout.h b/include/net/netfilter/nf_conntrack_timeout.h new file mode 100644 index 000000000000..0e04db4a0865 --- /dev/null +++ b/include/net/netfilter/nf_conntrack_timeout.h @@ -0,0 +1,78 @@ +#ifndef _NF_CONNTRACK_TIMEOUT_H +#define _NF_CONNTRACK_TIMEOUT_H + +#include +#include +#include +#include +#include + +#define CTNL_TIMEOUT_NAME_MAX 32 + +struct ctnl_timeout { + struct list_head head; + struct rcu_head rcu_head; + atomic_t refcnt; + char name[CTNL_TIMEOUT_NAME_MAX]; + __u16 l3num; + __u8 l4num; + char data[0]; +}; + +struct nf_conn_timeout { + struct ctnl_timeout *timeout; +}; + +#define NF_CT_TIMEOUT_EXT_DATA(__t) (unsigned int *) &((__t)->timeout->data) + +static inline +struct nf_conn_timeout *nf_ct_timeout_find(const struct nf_conn *ct) +{ +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + return nf_ct_ext_find(ct, NF_CT_EXT_TIMEOUT); +#else + return NULL; +#endif +} + +static inline +struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct, + struct ctnl_timeout *timeout, + gfp_t gfp) +{ +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + struct nf_conn_timeout *timeout_ext; + + timeout_ext = nf_ct_ext_add(ct, NF_CT_EXT_TIMEOUT, gfp); + if (timeout_ext == NULL) + return NULL; + + timeout_ext->timeout = timeout; + + return timeout_ext; +#else + return NULL; +#endif +}; + +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT +extern int nf_conntrack_timeout_init(struct net *net); +extern void nf_conntrack_timeout_fini(struct net *net); +#else +static inline int nf_conntrack_timeout_init(struct net *net) +{ + return 0; +} + +static inline void nf_conntrack_timeout_fini(struct net *net) +{ + return; +} +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ + +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT +extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(const char *name); +extern void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout); +#endif + +#endif /* _NF_CONNTRACK_TIMEOUT_H */ diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index f3efb6570dd9..0c6f67e8f2e5 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig @@ -103,6 +103,16 @@ config NF_CONNTRACK_EVENTS If unsure, say `N'. +config NF_CONNTRACK_TIMEOUT + bool 'Connection tracking timeout' + depends on NETFILTER_ADVANCED + help + This option enables support for connection tracking timeout + extension. This allows you to attach timeout policies to flow + via the CT target. + + If unsure, say `N'. + config NF_CONNTRACK_TIMESTAMP bool 'Connection tracking timestamping' depends on NETFILTER_ADVANCED diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index cf7cdd630bdd..ca3676586f51 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile @@ -1,6 +1,7 @@ netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o nf_conntrack-y := nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_proto.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o nf_conntrack_extend.o nf_conntrack_acct.o +nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMEOUT) += nf_conntrack_timeout.o nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMESTAMP) += nf_conntrack_timestamp.o nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index d18995eea1c6..75398c535719 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -1333,6 +1334,7 @@ static void nf_conntrack_cleanup_net(struct net *net) } nf_ct_free_hashtable(net->ct.hash, net->ct.htable_size); + nf_conntrack_timeout_fini(net); nf_conntrack_ecache_fini(net); nf_conntrack_tstamp_fini(net); nf_conntrack_acct_fini(net); @@ -1564,9 +1566,14 @@ static int nf_conntrack_init_net(struct net *net) ret = nf_conntrack_ecache_init(net); if (ret < 0) goto err_ecache; + ret = nf_conntrack_timeout_init(net); + if (ret < 0) + goto err_timeout; return 0; +err_timeout: + nf_conntrack_timeout_fini(net); err_ecache: nf_conntrack_tstamp_fini(net); err_tstamp: diff --git a/net/netfilter/nf_conntrack_timeout.c b/net/netfilter/nf_conntrack_timeout.c new file mode 100644 index 000000000000..a878ce5b252c --- /dev/null +++ b/net/netfilter/nf_conntrack_timeout.c @@ -0,0 +1,60 @@ +/* + * (C) 2012 by Pablo Neira Ayuso + * (C) 2012 by Vyatta Inc. + * + * 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 (or any later at your option). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +struct ctnl_timeout * +(*nf_ct_timeout_find_get_hook)(const char *name) __read_mostly; +EXPORT_SYMBOL_GPL(nf_ct_timeout_find_get_hook); + +void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout) __read_mostly; +EXPORT_SYMBOL_GPL(nf_ct_timeout_put_hook); + +static struct nf_ct_ext_type timeout_extend __read_mostly = { + .len = sizeof(struct nf_conn_timeout), + .align = __alignof__(struct nf_conn_timeout), + .id = NF_CT_EXT_TIMEOUT, +}; + +int nf_conntrack_timeout_init(struct net *net) +{ + int ret = 0; + + if (net_eq(net, &init_net)) { + ret = nf_ct_extend_register(&timeout_extend); + if (ret < 0) { + printk(KERN_ERR "nf_ct_timeout: Unable to register " + "timeout extension.\n"); + return ret; + } + } + + return 0; +} + +void nf_conntrack_timeout_fini(struct net *net) +{ + if (net_eq(net, &init_net)) + nf_ct_extend_unregister(&timeout_extend); +} diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index b860d5217189..29b989715162 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c @@ -37,16 +37,6 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Pablo Neira Ayuso "); MODULE_DESCRIPTION("cttimeout: Extended Netfilter Connection Tracking timeout tuning"); -struct ctnl_timeout { - struct list_head head; - struct rcu_head rcu_head; - atomic_t refcnt; - char name[CTNL_TIMEOUT_NAME_MAX]; - __u16 l3num; - __u8 l4num; - char data[0]; -}; - static LIST_HEAD(cttimeout_list); static const struct nla_policy cttimeout_nla_policy[CTA_TIMEOUT_MAX+1] = { -- GitLab From 24de58f465165298aaa8f286b2592f0163706cfe Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 29 Feb 2012 02:19:19 +0100 Subject: [PATCH 1506/1846] netfilter: xt_CT: allow to attach timeout policy + glue code This patch allows you to attach the timeout policy via the CT target, it adds a new revision of the target to ensure backward compatibility. Moreover, it also contains the glue code to stick the timeout object defined via nfnetlink_cttimeout to the given flow. Example usage (it requires installing the nfct tool and libnetfilter_cttimeout): 1) create the timeout policy: nfct timeout add tcp-policy0 inet tcp \ established 1000 close 10 time_wait 10 last_ack 10 2) attach the timeout policy to the packet: iptables -I PREROUTING -t raw -p tcp -j CT --timeout tcp-policy0 You have to install the following user-space software: a) libnetfilter_cttimeout: git://git.netfilter.org/libnetfilter_cttimeout b) nfct: git://git.netfilter.org/nfct You also have to get iptables with -j CT --timeout support. Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/xt_CT.h | 12 ++ net/netfilter/nf_conntrack_core.c | 11 +- net/netfilter/nfnetlink_cttimeout.c | 41 ++++++ net/netfilter/xt_CT.c | 220 ++++++++++++++++++++++++++-- 4 files changed, 268 insertions(+), 16 deletions(-) diff --git a/include/linux/netfilter/xt_CT.h b/include/linux/netfilter/xt_CT.h index b56e76811c04..a064b8af360c 100644 --- a/include/linux/netfilter/xt_CT.h +++ b/include/linux/netfilter/xt_CT.h @@ -16,4 +16,16 @@ struct xt_ct_target_info { struct nf_conn *ct __attribute__((aligned(8))); }; +struct xt_ct_target_info_v1 { + __u16 flags; + __u16 zone; + __u32 ct_events; + __u32 exp_events; + char helper[16]; + char timeout[32]; + + /* Used internally by the kernel */ + struct nf_conn *ct __attribute__((aligned(8))); +}; + #endif /* _XT_CT_H */ diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 75398c535719..81e2aa4ca1fe 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -912,6 +912,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, enum ip_conntrack_info ctinfo; struct nf_conntrack_l3proto *l3proto; struct nf_conntrack_l4proto *l4proto; + struct nf_conn_timeout *timeout_ext; unsigned int *timeouts; unsigned int dataoff; u_int8_t protonum; @@ -959,7 +960,15 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, goto out; } - timeouts = l4proto->get_timeouts(net); + /* Decide what timeout policy we want to apply to this flow. */ + if (tmpl) { + timeout_ext = nf_ct_timeout_find(tmpl); + if (timeout_ext) + timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext); + else + timeouts = l4proto->get_timeouts(net); + } else + timeouts = l4proto->get_timeouts(net); ct = resolve_normal_ct(net, tmpl, skb, dataoff, pf, protonum, l3proto, l4proto, &set_reply, &ctinfo, diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index 29b989715162..fec29a43de4d 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -331,6 +332,38 @@ cttimeout_del_timeout(struct sock *ctnl, struct sk_buff *skb, return ret; } +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT +static struct ctnl_timeout *ctnl_timeout_find_get(const char *name) +{ + struct ctnl_timeout *timeout, *matching = NULL; + + rcu_read_lock(); + list_for_each_entry_rcu(timeout, &cttimeout_list, head) { + if (strncmp(timeout->name, name, CTNL_TIMEOUT_NAME_MAX) != 0) + continue; + + if (!try_module_get(THIS_MODULE)) + goto err; + + if (!atomic_inc_not_zero(&timeout->refcnt)) { + module_put(THIS_MODULE); + goto err; + } + matching = timeout; + break; + } +err: + rcu_read_unlock(); + return matching; +} + +static void ctnl_timeout_put(struct ctnl_timeout *timeout) +{ + atomic_dec(&timeout->refcnt); + module_put(THIS_MODULE); +} +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ + static const struct nfnl_callback cttimeout_cb[IPCTNL_MSG_TIMEOUT_MAX] = { [IPCTNL_MSG_TIMEOUT_NEW] = { .call = cttimeout_new_timeout, .attr_count = CTA_TIMEOUT_MAX, @@ -362,6 +395,10 @@ static int __init cttimeout_init(void) "nfnetlink.\n"); goto err_out; } +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + RCU_INIT_POINTER(nf_ct_timeout_find_get_hook, ctnl_timeout_find_get); + RCU_INIT_POINTER(nf_ct_timeout_put_hook, ctnl_timeout_put); +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ return 0; err_out: @@ -382,6 +419,10 @@ static void __exit cttimeout_exit(void) */ kfree_rcu(cur, rcu_head); } +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + RCU_INIT_POINTER(nf_ct_timeout_find_get_hook, NULL); + RCU_INIT_POINTER(nf_ct_timeout_put_hook, NULL); +#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ } module_init(cttimeout_init); diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c index 0221d10de75a..b873445df444 100644 --- a/net/netfilter/xt_CT.c +++ b/net/netfilter/xt_CT.c @@ -16,10 +16,11 @@ #include #include #include +#include #include -static unsigned int xt_ct_target(struct sk_buff *skb, - const struct xt_action_param *par) +static unsigned int xt_ct_target_v0(struct sk_buff *skb, + const struct xt_action_param *par) { const struct xt_ct_target_info *info = par->targinfo; struct nf_conn *ct = info->ct; @@ -35,6 +36,23 @@ static unsigned int xt_ct_target(struct sk_buff *skb, return XT_CONTINUE; } +static unsigned int xt_ct_target_v1(struct sk_buff *skb, + const struct xt_action_param *par) +{ + const struct xt_ct_target_info_v1 *info = par->targinfo; + struct nf_conn *ct = info->ct; + + /* Previously seen (loopback)? Ignore. */ + if (skb->nfct != NULL) + return XT_CONTINUE; + + atomic_inc(&ct->ct_general.use); + skb->nfct = &ct->ct_general; + skb->nfctinfo = IP_CT_NEW; + + return XT_CONTINUE; +} + static u8 xt_ct_find_proto(const struct xt_tgchk_param *par) { if (par->family == NFPROTO_IPV4) { @@ -53,7 +71,7 @@ static u8 xt_ct_find_proto(const struct xt_tgchk_param *par) return 0; } -static int xt_ct_tg_check(const struct xt_tgchk_param *par) +static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par) { struct xt_ct_target_info *info = par->targinfo; struct nf_conntrack_tuple t; @@ -130,7 +148,137 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par) return ret; } -static void xt_ct_tg_destroy(const struct xt_tgdtor_param *par) +static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par) +{ + struct xt_ct_target_info_v1 *info = par->targinfo; + struct nf_conntrack_tuple t; + struct nf_conn_help *help; + struct nf_conn *ct; + int ret = 0; + u8 proto; + + if (info->flags & ~XT_CT_NOTRACK) + return -EINVAL; + + if (info->flags & XT_CT_NOTRACK) { + ct = nf_ct_untracked_get(); + atomic_inc(&ct->ct_general.use); + goto out; + } + +#ifndef CONFIG_NF_CONNTRACK_ZONES + if (info->zone) + goto err1; +#endif + + ret = nf_ct_l3proto_try_module_get(par->family); + if (ret < 0) + goto err1; + + memset(&t, 0, sizeof(t)); + ct = nf_conntrack_alloc(par->net, info->zone, &t, &t, GFP_KERNEL); + ret = PTR_ERR(ct); + if (IS_ERR(ct)) + goto err2; + + ret = 0; + if ((info->ct_events || info->exp_events) && + !nf_ct_ecache_ext_add(ct, info->ct_events, info->exp_events, + GFP_KERNEL)) + goto err3; + + if (info->helper[0]) { + ret = -ENOENT; + proto = xt_ct_find_proto(par); + if (!proto) { + pr_info("You must specify a L4 protocol, " + "and not use inversions on it.\n"); + goto err3; + } + + ret = -ENOMEM; + help = nf_ct_helper_ext_add(ct, GFP_KERNEL); + if (help == NULL) + goto err3; + + ret = -ENOENT; + help->helper = nf_conntrack_helper_try_module_get(info->helper, + par->family, + proto); + if (help->helper == NULL) { + pr_info("No such helper \"%s\"\n", info->helper); + goto err3; + } + } + +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + if (info->timeout) { + typeof(nf_ct_timeout_find_get_hook) timeout_find_get; + struct ctnl_timeout *timeout; + struct nf_conn_timeout *timeout_ext; + + timeout_find_get = + rcu_dereference(nf_ct_timeout_find_get_hook); + + if (timeout_find_get) { + const struct ipt_entry *e = par->entryinfo; + + if (e->ip.invflags & IPT_INV_PROTO) { + ret = -EINVAL; + pr_info("You cannot use inversion on " + "L4 protocol\n"); + goto err3; + } + timeout = timeout_find_get(info->timeout); + if (timeout == NULL) { + ret = -ENOENT; + pr_info("No such timeout policy \"%s\"\n", + info->timeout); + goto err3; + } + if (timeout->l3num != par->family) { + ret = -EINVAL; + pr_info("Timeout policy `%s' can only be " + "used by L3 protocol number %d\n", + info->timeout, timeout->l3num); + goto err3; + } + if (timeout->l4num != e->ip.proto) { + ret = -EINVAL; + pr_info("Timeout policy `%s' can only be " + "used by L4 protocol number %d\n", + info->timeout, timeout->l4num); + goto err3; + } + timeout_ext = nf_ct_timeout_ext_add(ct, timeout, + GFP_KERNEL); + if (timeout_ext == NULL) { + ret = -ENOMEM; + goto err3; + } + } else { + ret = -ENOENT; + pr_info("Timeout policy base is empty\n"); + goto err3; + } + } +#endif + + __set_bit(IPS_TEMPLATE_BIT, &ct->status); + __set_bit(IPS_CONFIRMED_BIT, &ct->status); +out: + info->ct = ct; + return 0; + +err3: + nf_conntrack_free(ct); +err2: + nf_ct_l3proto_module_put(par->family); +err1: + return ret; +} + +static void xt_ct_tg_destroy_v0(const struct xt_tgdtor_param *par) { struct xt_ct_target_info *info = par->targinfo; struct nf_conn *ct = info->ct; @@ -146,25 +294,67 @@ static void xt_ct_tg_destroy(const struct xt_tgdtor_param *par) nf_ct_put(info->ct); } -static struct xt_target xt_ct_tg __read_mostly = { - .name = "CT", - .family = NFPROTO_UNSPEC, - .targetsize = sizeof(struct xt_ct_target_info), - .checkentry = xt_ct_tg_check, - .destroy = xt_ct_tg_destroy, - .target = xt_ct_target, - .table = "raw", - .me = THIS_MODULE, +static void xt_ct_tg_destroy_v1(const struct xt_tgdtor_param *par) +{ + struct xt_ct_target_info_v1 *info = par->targinfo; + struct nf_conn *ct = info->ct; + struct nf_conn_help *help; +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + struct nf_conn_timeout *timeout_ext; + typeof(nf_ct_timeout_put_hook) timeout_put; +#endif + if (!nf_ct_is_untracked(ct)) { + help = nfct_help(ct); + if (help) + module_put(help->helper->me); + + nf_ct_l3proto_module_put(par->family); + +#ifdef CONFIG_NF_CONNTRACK_TIMEOUT + timeout_put = rcu_dereference(nf_ct_timeout_put_hook); + + if (timeout_put) { + timeout_ext = nf_ct_timeout_find(ct); + if (timeout_ext) + timeout_put(timeout_ext->timeout); + } +#endif + } + nf_ct_put(info->ct); +} + +static struct xt_target xt_ct_tg_reg[] __read_mostly = { + { + .name = "CT", + .family = NFPROTO_UNSPEC, + .targetsize = sizeof(struct xt_ct_target_info), + .checkentry = xt_ct_tg_check_v0, + .destroy = xt_ct_tg_destroy_v0, + .target = xt_ct_target_v0, + .table = "raw", + .me = THIS_MODULE, + }, + { + .name = "CT", + .family = NFPROTO_UNSPEC, + .revision = 1, + .targetsize = sizeof(struct xt_ct_target_info_v1), + .checkentry = xt_ct_tg_check_v1, + .destroy = xt_ct_tg_destroy_v1, + .target = xt_ct_target_v1, + .table = "raw", + .me = THIS_MODULE, + }, }; static int __init xt_ct_tg_init(void) { - return xt_register_target(&xt_ct_tg); + return xt_register_targets(xt_ct_tg_reg, ARRAY_SIZE(xt_ct_tg_reg)); } static void __exit xt_ct_tg_exit(void) { - xt_unregister_target(&xt_ct_tg); + xt_unregister_targets(xt_ct_tg_reg, ARRAY_SIZE(xt_ct_tg_reg)); } module_init(xt_ct_tg_init); -- GitLab From ace30d73ef09fd5f95b24c5c1c5aa11963981494 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Thu, 1 Mar 2012 02:56:59 +0000 Subject: [PATCH 1507/1846] netfilter: xt_LOG: add __printf() to sb_add() Helps to find format mismatches at compile time Suggested-by: David Laight Signed-off-by: Eric Dumazet --- include/net/netfilter/xt_log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h index 0dfb34a5b53c..7e1544e8f70d 100644 --- a/include/net/netfilter/xt_log.h +++ b/include/net/netfilter/xt_log.h @@ -6,7 +6,7 @@ struct sbuff { }; static struct sbuff emergency, *emergency_ptr = &emergency; -static int sb_add(struct sbuff *m, const char *f, ...) +static __printf(2, 3) int sb_add(struct sbuff *m, const char *f, ...) { va_list args; int len; -- GitLab From 51b56e263fb875a86e1f90e41b8c0b8a47c69b47 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:57 +0200 Subject: [PATCH 1508/1846] ath6kl: fix pointer style reported by checkpatch: ath6kl/core.h:748: ERROR: "foo * bar" should be "foo *bar" ath6kl/core.h:751: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index 01763cd243b4..f048924313fa 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -754,10 +754,10 @@ struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target, void aggr_module_destroy(struct aggr_info *aggr_info); void aggr_reset_state(struct aggr_info_conn *aggr_conn); -struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 * node_addr); +struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 *node_addr); struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid); -void ath6kl_ready_event(void *devt, u8 * datap, u32 sw_ver, u32 abi_ver); +void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver); int ath6kl_control_tx(void *devt, struct sk_buff *skb, enum htc_endpoint_id eid); void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, -- GitLab From c650538f5dbb433f3438e7fcb0090c6d617b4a0e Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:57 +0200 Subject: [PATCH 1509/1846] ath6kl: fix checkpatch error with EPSTAT() macro ath6kl/debug.c:739: ERROR: Macros with complex values should be enclosed in parenthesis Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 56e1cb170299..4bebf8eb23d3 100755 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -740,9 +740,13 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file, return -ENOMEM; #define EPSTAT(name) \ - len = print_endpoint_stat(target, buf, buf_len, len, \ - offsetof(struct htc_endpoint_stats, name), \ - #name) + do { \ + len = print_endpoint_stat(target, buf, buf_len, len, \ + offsetof(struct htc_endpoint_stats, \ + name), \ + #name); \ + } while (0) + EPSTAT(cred_low_indicate); EPSTAT(tx_issued); EPSTAT(tx_pkt_bundled); -- GitLab From 96f1fadc94bc8dcde814109439e416143eed50fa Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:57 +0200 Subject: [PATCH 1510/1846] ath6kl: alignment should match open parenthesis Fix the issues which checkpatch found and were easy to fix. Especially callers of ath6kl_bmi_write() are tricky and that needs to be fixed separately. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/bmi.c | 6 +-- drivers/net/wireless/ath/ath6kl/cfg80211.c | 18 +++---- drivers/net/wireless/ath/ath6kl/core.c | 6 +-- drivers/net/wireless/ath/ath6kl/debug.c | 48 ++++++++--------- drivers/net/wireless/ath/ath6kl/hif.c | 6 +-- drivers/net/wireless/ath/ath6kl/htc.c | 62 +++++++++++----------- drivers/net/wireless/ath/ath6kl/init.c | 20 +++---- drivers/net/wireless/ath/ath6kl/main.c | 18 +++---- drivers/net/wireless/ath/ath6kl/sdio.c | 6 +-- drivers/net/wireless/ath/ath6kl/txrx.c | 18 +++---- drivers/net/wireless/ath/ath6kl/wmi.c | 22 ++++---- 11 files changed, 115 insertions(+), 115 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/bmi.c b/drivers/net/wireless/ath/ath6kl/bmi.c index 05d1d8941fd1..334dbd834b3a 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.c +++ b/drivers/net/wireless/ath/ath6kl/bmi.c @@ -106,7 +106,7 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, } ath6kl_dbg(ATH6KL_DBG_BMI, "target info (ver: 0x%x type: 0x%x)\n", - targ_info->version, targ_info->type); + targ_info->version, targ_info->type); return 0; } @@ -193,7 +193,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) memset(ar->bmi.cmd_buf, 0, ar->bmi.max_data_size + header); ath6kl_dbg(ATH6KL_DBG_BMI, - "bmi write memory: addr: 0x%x, len: %d\n", addr, len); + "bmi write memory: addr: 0x%x, len: %d\n", addr, len); len_remain = len; while (len_remain) { @@ -435,7 +435,7 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len) memcpy(&(ar->bmi.cmd_buf[offset]), &tx_len, sizeof(tx_len)); offset += sizeof(tx_len); memcpy(&(ar->bmi.cmd_buf[offset]), &buf[len - len_remain], - tx_len); + tx_len); offset += tx_len; ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index baa3895b1643..e1b0acc5a065 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -390,7 +390,7 @@ static bool ath6kl_is_valid_iftype(struct ath6kl *ar, enum nl80211_iftype type, return false; if (ar->ibss_if_active || ((type == NL80211_IFTYPE_ADHOC) && - ar->num_vif)) + ar->num_vif)) return false; if (type == NL80211_IFTYPE_STATION || @@ -556,7 +556,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, if (!ar->usr_bss_filter) { clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); if (ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, - ALL_BSS_FILTER, 0) != 0) { + ALL_BSS_FILTER, 0) != 0) { ath6kl_err("couldn't set bss filtering\n"); up(&ar->sem); return -EIO; @@ -848,13 +848,13 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, if (vif->sme_state == SME_CONNECTING) { cfg80211_connect_result(vif->ndev, - bssid, NULL, 0, - NULL, 0, - WLAN_STATUS_UNSPECIFIED_FAILURE, - GFP_KERNEL); + bssid, NULL, 0, + NULL, 0, + WLAN_STATUS_UNSPECIFIED_FAILURE, + GFP_KERNEL); } else if (vif->sme_state == SME_CONNECTED) { cfg80211_disconnected(vif->ndev, reason, - NULL, 0, GFP_KERNEL); + NULL, 0, GFP_KERNEL); } vif->sme_state = SME_DISCONNECTED; @@ -936,7 +936,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, force_fg_scan = 1; if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, - ar->fw_capabilities)) { + ar->fw_capabilities)) { /* * If capable of doing P2P mgmt operations using * station interface, send additional information like @@ -1371,7 +1371,7 @@ static int ath6kl_cfg80211_set_power_mgmt(struct wiphy *wiphy, } if (ath6kl_wmi_powermode_cmd(ar->wmi, vif->fw_vif_idx, - mode.pwr_mode) != 0) { + mode.pwr_mode) != 0) { ath6kl_err("wmi_powermode_cmd failed\n"); return -EIO; } diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c index 2dc05479b512..45e641f3a41b 100644 --- a/drivers/net/wireless/ath/ath6kl/core.c +++ b/drivers/net/wireless/ath/ath6kl/core.c @@ -115,8 +115,8 @@ int ath6kl_core_init(struct ath6kl *ar) ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; if (suspend_mode && - suspend_mode >= WLAN_POWER_STATE_CUT_PWR && - suspend_mode <= WLAN_POWER_STATE_WOW) + suspend_mode >= WLAN_POWER_STATE_CUT_PWR && + suspend_mode <= WLAN_POWER_STATE_WOW) ar->suspend_mode = suspend_mode; else ar->suspend_mode = 0; @@ -174,7 +174,7 @@ int ath6kl_core_init(struct ath6kl *ar) } ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n", - __func__, ndev->name, ndev, ar); + __func__, ndev->name, ndev, ar); return ret; diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 4bebf8eb23d3..9170b05e5d87 100755 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -119,29 +119,29 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, if (irq_proc_reg != NULL) { ath6kl_dbg(ATH6KL_DBG_IRQ, - "Host Int status: 0x%x\n", - irq_proc_reg->host_int_status); + "Host Int status: 0x%x\n", + irq_proc_reg->host_int_status); ath6kl_dbg(ATH6KL_DBG_IRQ, "CPU Int status: 0x%x\n", - irq_proc_reg->cpu_int_status); + irq_proc_reg->cpu_int_status); ath6kl_dbg(ATH6KL_DBG_IRQ, "Error Int status: 0x%x\n", - irq_proc_reg->error_int_status); + irq_proc_reg->error_int_status); ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status: 0x%x\n", - irq_proc_reg->counter_int_status); + irq_proc_reg->counter_int_status); ath6kl_dbg(ATH6KL_DBG_IRQ, "Mbox Frame: 0x%x\n", - irq_proc_reg->mbox_frame); + irq_proc_reg->mbox_frame); ath6kl_dbg(ATH6KL_DBG_IRQ, "Rx Lookahead Valid: 0x%x\n", - irq_proc_reg->rx_lkahd_valid); + irq_proc_reg->rx_lkahd_valid); ath6kl_dbg(ATH6KL_DBG_IRQ, "Rx Lookahead 0: 0x%x\n", - irq_proc_reg->rx_lkahd[0]); + irq_proc_reg->rx_lkahd[0]); ath6kl_dbg(ATH6KL_DBG_IRQ, "Rx Lookahead 1: 0x%x\n", - irq_proc_reg->rx_lkahd[1]); + irq_proc_reg->rx_lkahd[1]); if (dev->ar->mbox_info.gmbox_addr != 0) { /* @@ -149,27 +149,27 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, * additional state. */ ath6kl_dbg(ATH6KL_DBG_IRQ, - "GMBOX Host Int status 2: 0x%x\n", - irq_proc_reg->host_int_status2); + "GMBOX Host Int status 2: 0x%x\n", + irq_proc_reg->host_int_status2); ath6kl_dbg(ATH6KL_DBG_IRQ, - "GMBOX RX Avail: 0x%x\n", - irq_proc_reg->gmbox_rx_avail); + "GMBOX RX Avail: 0x%x\n", + irq_proc_reg->gmbox_rx_avail); ath6kl_dbg(ATH6KL_DBG_IRQ, - "GMBOX lookahead alias 0: 0x%x\n", - irq_proc_reg->rx_gmbox_lkahd_alias[0]); + "GMBOX lookahead alias 0: 0x%x\n", + irq_proc_reg->rx_gmbox_lkahd_alias[0]); ath6kl_dbg(ATH6KL_DBG_IRQ, - "GMBOX lookahead alias 1: 0x%x\n", - irq_proc_reg->rx_gmbox_lkahd_alias[1]); + "GMBOX lookahead alias 1: 0x%x\n", + irq_proc_reg->rx_gmbox_lkahd_alias[1]); } } if (irq_enable_reg != NULL) { ath6kl_dbg(ATH6KL_DBG_IRQ, - "Int status Enable: 0x%x\n", - irq_enable_reg->int_status_en); + "Int status Enable: 0x%x\n", + irq_enable_reg->int_status_en); ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status Enable: 0x%x\n", - irq_enable_reg->cntr_int_status_en); + irq_enable_reg->cntr_int_status_en); } ath6kl_dbg(ATH6KL_DBG_IRQ, "<------------------------------->\n"); } @@ -1804,19 +1804,19 @@ int ath6kl_debug_init_fs(struct ath6kl *ar) ar->debugfs_phy, ar, &fops_disconnect_timeout); debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar, - &fops_create_qos); + &fops_create_qos); debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar, - &fops_delete_qos); + &fops_delete_qos); debugfs_create_file("bgscan_interval", S_IWUSR, - ar->debugfs_phy, ar, &fops_bgscan_int); + ar->debugfs_phy, ar, &fops_bgscan_int); debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar, &fops_listen_int); debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar, - &fops_power_params); + &fops_power_params); return 0; } diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c index 3e569b265332..68ed6c2665b7 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.c +++ b/drivers/net/wireless/ath/ath6kl/hif.c @@ -90,7 +90,7 @@ static void ath6kl_hif_dump_fw_crash(struct ath6kl *ar) } ath6kl_dbg(ATH6KL_DBG_IRQ, "register dump data address 0x%x\n", - regdump_addr); + regdump_addr); regdump_addr = TARG_VTOP(ar->target_type, regdump_addr); /* fetch register dump data */ @@ -285,7 +285,7 @@ static int ath6kl_hif_proc_counter_intr(struct ath6kl_device *dev) dev->irq_en_reg.cntr_int_status_en; ath6kl_dbg(ATH6KL_DBG_IRQ, - "valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n", + "valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n", counter_int_status); /* @@ -360,7 +360,7 @@ static int ath6kl_hif_proc_cpu_intr(struct ath6kl_device *dev) } ath6kl_dbg(ATH6KL_DBG_IRQ, - "valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n", + "valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n", cpu_int_status); /* Clear the interrupt */ diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index c6f45a744d52..0204b8314beb 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -185,8 +185,8 @@ static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, if (cur_dist_list->credits > cur_dist_list->cred_assngd) ath6kl_credit_reduce(cred_info, - cur_dist_list, - cur_dist_list->cred_assngd); + cur_dist_list, + cur_dist_list->cred_assngd); if (cur_dist_list->credits > cur_dist_list->cred_norm) @@ -464,8 +464,8 @@ static void htc_async_tx_scat_complete(struct htc_target *target, INIT_LIST_HEAD(&tx_compq); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc tx scat complete len %d entries %d\n", - scat_req->len, scat_req->scat_entries); + "htc tx scat complete len %d entries %d\n", + scat_req->len, scat_req->scat_entries); if (scat_req->status) ath6kl_err("send scatter req failed: %d\n", scat_req->status); @@ -603,8 +603,8 @@ static void ath6kl_htc_tx_pkts_get(struct htc_target *target, list); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc tx got packet 0x%p queue depth %d\n", - packet, get_queue_depth(&endpoint->txq)); + "htc tx got packet 0x%p queue depth %d\n", + packet, get_queue_depth(&endpoint->txq)); len = CALC_TXRX_PADDED_LEN(target, packet->act_len + HTC_HDR_LENGTH); @@ -701,8 +701,8 @@ static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, scat_req->scat_list[i].packet = packet; /* prepare packet and flag message as part of a send bundle */ ath6kl_htc_tx_prep_pkt(packet, - packet->info.tx.flags | HTC_FLAGS_SEND_BUNDLE, - cred_pad, packet->info.tx.seqno); + packet->info.tx.flags | HTC_FLAGS_SEND_BUNDLE, + cred_pad, packet->info.tx.seqno); /* Make sure the buffer is 4-byte aligned */ ath6kl_htc_tx_buf_align(&packet->buf, packet->act_len + HTC_HDR_LENGTH); @@ -752,7 +752,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, u8 ac = WMM_NUM_AC; if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) || - (WMI_CONTROL_SVC != endpoint->svc_id)) + (WMI_CONTROL_SVC != endpoint->svc_id)) ac = target->dev->ar->ep2ac_map[endpoint->eid]; while (true) { @@ -769,7 +769,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, if (!scat_req) { /* no scatter resources */ ath6kl_dbg(ATH6KL_DBG_HTC, - "htc tx no more scatter resources\n"); + "htc tx no more scatter resources\n"); break; } @@ -860,7 +860,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, INIT_LIST_HEAD(&txq); if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) || - (WMI_CONTROL_SVC != endpoint->svc_id)) + (WMI_CONTROL_SVC != endpoint->svc_id)) ac = target->dev->ar->ep2ac_map[endpoint->eid]; while (true) { @@ -918,7 +918,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, */ if (!bundle_sent) { if (!(target->tx_bndl_mask & (1 << ac)) && - (ac < WMM_NUM_AC)) { + (ac < WMM_NUM_AC)) { if (++target->ac_tx_count[ac] >= TX_RESUME_BUNDLE_THRESHOLD) { target->ac_tx_count[ac] = 0; @@ -1042,8 +1042,8 @@ static int htc_setup_tx_complete(struct htc_target *target) memcpy(&setup_comp_ext->flags, &flags, sizeof(setup_comp_ext->flags)); set_htc_pkt_info(send_pkt, NULL, (u8 *) setup_comp_ext, - sizeof(struct htc_setup_comp_ext_msg), - ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); + sizeof(struct htc_setup_comp_ext_msg), + ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); } else { struct htc_setup_comp_msg *setup_comp; @@ -1051,8 +1051,8 @@ static int htc_setup_tx_complete(struct htc_target *target) memset(setup_comp, 0, sizeof(struct htc_setup_comp_msg)); setup_comp->msg_id = cpu_to_le16(HTC_MSG_SETUP_COMPLETE_ID); set_htc_pkt_info(send_pkt, NULL, (u8 *) setup_comp, - sizeof(struct htc_setup_comp_msg), - ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); + sizeof(struct htc_setup_comp_msg), + ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG); } /* we want synchronous operation */ @@ -1151,9 +1151,9 @@ void ath6kl_htc_flush_txep(struct htc_target *target, packet->status = -ECANCELED; list_del(&packet->list); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc tx flushing pkt 0x%p len %d ep %d tag 0x%x\n", - packet, packet->act_len, - packet->endpoint, packet->info.tx.tag); + "htc tx flushing pkt 0x%p len %d ep %d tag 0x%x\n", + packet, packet->act_len, + packet->endpoint, packet->info.tx.tag); INIT_LIST_HEAD(&container); list_add_tail(&packet->list, &container); @@ -1553,7 +1553,7 @@ static void htc_ctrl_rx(struct htc_target *context, struct htc_packet *packets) if (packets->act_len > 0) { ath6kl_err("htc_ctrl_rx, got message with len:%zu\n", - packets->act_len + HTC_HDR_LENGTH); + packets->act_len + HTC_HDR_LENGTH); ath6kl_dbg_dump(ATH6KL_DBG_HTC, "htc rx unexpected endpoint 0 message", "", @@ -2101,13 +2101,13 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target, list_for_each_entry_safe(packet, tmp_pkt, rx_pktq, list) { list_del(&packet->list); htc_reclaim_rxbuf(target, packet, - &target->endpoint[packet->endpoint]); + &target->endpoint[packet->endpoint]); } list_for_each_entry_safe(packet, tmp_pkt, &tmp_rxq, list) { list_del(&packet->list); htc_reclaim_rxbuf(target, packet, - &target->endpoint[packet->endpoint]); + &target->endpoint[packet->endpoint]); } return status; @@ -2239,11 +2239,11 @@ static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target) u32 look_ahead; if (ath6kl_hif_poll_mboxmsg_rx(target->dev, &look_ahead, - HTC_TARGET_RESPONSE_TIMEOUT)) + HTC_TARGET_RESPONSE_TIMEOUT)) return NULL; ath6kl_dbg(ATH6KL_DBG_HTC, - "htc rx wait ctrl look_ahead 0x%X\n", look_ahead); + "htc rx wait ctrl look_ahead 0x%X\n", look_ahead); htc_hdr = (struct htc_frame_hdr *)&look_ahead; @@ -2308,7 +2308,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, depth = get_queue_depth(pkt_queue); ath6kl_dbg(ATH6KL_DBG_HTC, - "htc rx add multiple ep id %d cnt %d len %d\n", + "htc rx add multiple ep id %d cnt %d len %d\n", first_pkt->endpoint, depth, first_pkt->buf_len); endpoint = &target->endpoint[first_pkt->endpoint]; @@ -2334,8 +2334,8 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, if (target->rx_st_flags & HTC_RECV_WAIT_BUFFERS) { if (target->ep_waiting == first_pkt->endpoint) { ath6kl_dbg(ATH6KL_DBG_HTC, - "htc rx blocked on ep %d, unblocking\n", - target->ep_waiting); + "htc rx blocked on ep %d, unblocking\n", + target->ep_waiting); target->rx_st_flags &= ~HTC_RECV_WAIT_BUFFERS; target->ep_waiting = ENDPOINT_MAX; rx_unblock = true; @@ -2676,8 +2676,8 @@ int ath6kl_htc_wait_target(struct htc_target *target) } ath6kl_dbg(ATH6KL_DBG_BOOT, "htc using protocol %s (%d)\n", - (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", - target->htc_tgt_ver); + (target->htc_tgt_ver == HTC_VERSION_2P0) ? "2.0" : ">= 2.1", + target->htc_tgt_ver); if (target->msg_per_bndl_max > 0) htc_setup_msg_bndl(target); @@ -2871,14 +2871,14 @@ void ath6kl_htc_cleanup(struct htc_target *target) ath6kl_hif_cleanup_scatter(target->dev->ar); list_for_each_entry_safe(packet, tmp_packet, - &target->free_ctrl_txbuf, list) { + &target->free_ctrl_txbuf, list) { list_del(&packet->list); kfree(packet->buf_start); kfree(packet); } list_for_each_entry_safe(packet, tmp_packet, - &target->free_ctrl_rxbuf, list) { + &target->free_ctrl_rxbuf, list) { list_del(&packet->list); kfree(packet->buf_start); kfree(packet); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index f3b5502362d8..445426f3f9ed 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -414,13 +414,13 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) } if (ath6kl_wmi_set_keepalive_cmd(ar->wmi, idx, - WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) { + WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) { ath6kl_err("unable to set keep alive interval\n"); status = -EIO; } if (ath6kl_wmi_disctimeout_cmd(ar->wmi, idx, - WLAN_CONFIG_DISCONNECT_TIMEOUT)) { + WLAN_CONFIG_DISCONNECT_TIMEOUT)) { ath6kl_err("unable to set disconnect timeout\n"); status = -EIO; } @@ -833,13 +833,13 @@ static int ath6kl_fetch_testscript_file(struct ath6kl *ar) return 0; snprintf(filename, sizeof(filename), "%s/%s", - ar->hw.fw.dir, ar->hw.fw.testscript); + ar->hw.fw.dir, ar->hw.fw.testscript); ret = ath6kl_get_fw(ar, filename, &ar->fw_testscript, &ar->fw_testscript_len); if (ret) { ath6kl_err("Failed to get testscript file %s: %d\n", - filename, ret); + filename, ret); return ret; } @@ -923,7 +923,7 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name) switch (ie_id) { case ATH6KL_FW_IE_OTP_IMAGE: ath6kl_dbg(ATH6KL_DBG_BOOT, "found otp image ie (%zd B)\n", - ie_len); + ie_len); ar->fw_otp = kmemdup(data, ie_len, GFP_KERNEL); @@ -936,7 +936,7 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name) break; case ATH6KL_FW_IE_FW_IMAGE: ath6kl_dbg(ATH6KL_DBG_BOOT, "found fw image ie (%zd B)\n", - ie_len); + ie_len); /* in testmode we already might have a fw file */ if (ar->fw != NULL) @@ -953,7 +953,7 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name) break; case ATH6KL_FW_IE_PATCH_IMAGE: ath6kl_dbg(ATH6KL_DBG_BOOT, "found patch image ie (%zd B)\n", - ie_len); + ie_len); ar->fw_patch = kmemdup(data, ie_len, GFP_KERNEL); @@ -1313,7 +1313,7 @@ static int ath6kl_upload_testscript(struct ath6kl *ar) address = ar->hw.testscript_addr; ath6kl_dbg(ATH6KL_DBG_BOOT, "writing testscript to 0x%x (%zd B)\n", - address, ar->fw_testscript_len); + address, ar->fw_testscript_len); ret = ath6kl_bmi_write(ar, address, ar->fw_testscript, ar->fw_testscript_len); @@ -1349,7 +1349,7 @@ static int ath6kl_init_upload(struct ath6kl *ar) int status = 0; if (ar->target_type != TARGET_TYPE_AR6003 && - ar->target_type != TARGET_TYPE_AR6004) + ar->target_type != TARGET_TYPE_AR6004) return -EINVAL; /* temporarily disable system sleep */ @@ -1730,7 +1730,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar) * configure NOT to reset the target during a debug session. */ ath6kl_dbg(ATH6KL_DBG_TRC, - "attempting to reset target on instance destroy\n"); + "attempting to reset target on instance destroy\n"); ath6kl_reset_device(ar, ar->target_type, true, true); clear_bit(WLAN_ENABLED, &ar->flag); diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index bd8388c9db75..91dbeb930298 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -350,7 +350,7 @@ void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, __le32 data; if (target_type != TARGET_TYPE_AR6003 && - target_type != TARGET_TYPE_AR6004) + target_type != TARGET_TYPE_AR6004) return; data = cold_reset ? cpu_to_le32(RESET_CONTROL_COLD_RST) : @@ -948,8 +948,8 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, } ath6kl_cfg80211_disconnect_event(vif, reason, bssid, - assoc_resp_len, assoc_info, - prot_reason_status); + assoc_resp_len, assoc_info, + prot_reason_status); aggr_reset_state(vif->aggr_cntxt->aggr_conn); @@ -969,7 +969,7 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, } else { set_bit(CONNECT_PEND, &vif->flags); if (((reason == ASSOC_FAILED) && - (prot_reason_status == 0x11)) || + (prot_reason_status == 0x11)) || ((reason == ASSOC_FAILED) && (prot_reason_status == 0x0) && (vif->reconnect_flag == 1))) { set_bit(CONNECTED, &vif->flags); @@ -1105,7 +1105,7 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) if (mc_all_on || mc_all_off) { /* Enable/disable all multicast */ ath6kl_dbg(ATH6KL_DBG_TRC, "%s multicast filter\n", - mc_all_on ? "enabling" : "disabling"); + mc_all_on ? "enabling" : "disabling"); ret = ath6kl_wmi_mcast_filter_cmd(vif->ar->wmi, vif->fw_vif_idx, mc_all_on); if (ret) @@ -1118,7 +1118,7 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) found = false; netdev_for_each_mc_addr(ha, ndev) { if (memcmp(ha->addr, mc_filter->hw_addr, - ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE) == 0) { + ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE) == 0) { found = true; break; } @@ -1137,7 +1137,7 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) false); if (ret) { ath6kl_warn("Failed to remove multicast filter:%pM\n", - mc_filter->hw_addr); + mc_filter->hw_addr); return; } @@ -1152,7 +1152,7 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) found = false; list_for_each_entry(mc_filter, &vif->mc_filter, list) { if (memcmp(ha->addr, mc_filter->hw_addr, - ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE) == 0) { + ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE) == 0) { found = true; break; } @@ -1177,7 +1177,7 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) true); if (ret) { ath6kl_warn("Failed to add multicast filter :%pM\n", - mc_filter->hw_addr); + mc_filter->hw_addr); kfree(mc_filter); goto out; } diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 5b36086a56cf..5d5f3faa1f04 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -656,8 +656,8 @@ static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar, return -EINVAL; ath6kl_dbg(ATH6KL_DBG_SCATTER, - "hif-scatter: total len: %d scatter entries: %d\n", - scat_req->len, scat_req->scat_entries); + "hif-scatter: total len: %d scatter entries: %d\n", + scat_req->len, scat_req->scat_entries); if (request & HIF_SYNCHRONOUS) status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest); @@ -1019,7 +1019,7 @@ static int ath6kl_sdio_diag_read32(struct ath6kl *ar, u32 address, u32 *data) (u8 *)data, sizeof(u32), HIF_RD_SYNC_BYTE_INC); if (status) { ath6kl_err("%s: failed to read from window data addr\n", - __func__); + __func__); return status; } diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c index b05f3537cfd9..f85353fd1792 100644 --- a/drivers/net/wireless/ath/ath6kl/txrx.c +++ b/drivers/net/wireless/ath/ath6kl/txrx.c @@ -159,8 +159,8 @@ static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn, */ if (is_apsdq_empty) { ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi, - vif->fw_vif_idx, - conn->aid, 1, 0); + vif->fw_vif_idx, + conn->aid, 1, 0); } *flags |= WMI_DATA_HDR_FLAGS_UAPSD; @@ -379,7 +379,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) if (test_bit(WMI_ENABLED, &ar->flag)) { if ((dev->features & NETIF_F_IP_CSUM) && - (csum == CHECKSUM_PARTIAL)) { + (csum == CHECKSUM_PARTIAL)) { csum_start = skb->csum_start - (skb_network_header(skb) - skb->head) + sizeof(struct ath6kl_llc_snap_hdr); @@ -403,7 +403,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) } if ((dev->features & NETIF_F_IP_CSUM) && - (csum == CHECKSUM_PARTIAL)) { + (csum == CHECKSUM_PARTIAL)) { meta_v2.csum_start = csum_start; meta_v2.csum_dest = csum_dest; @@ -428,7 +428,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) } if ((vif->nw_type == ADHOC_NETWORK) && - ar->ibss_ps_enable && test_bit(CONNECTED, &vif->flags)) + ar->ibss_ps_enable && test_bit(CONNECTED, &vif->flags)) chk_adhoc_ps_mapping = true; else { /* get the stream mapping */ @@ -886,7 +886,7 @@ void ath6kl_rx_refill(struct htc_target *target, enum htc_endpoint_id endpoint) if (!IS_ALIGNED((unsigned long) skb->data, 4)) skb->data = PTR_ALIGN(skb->data - 4, 4); set_htc_rxpkt_info(packet, skb, skb->data, - ATH6KL_BUFFER_SIZE, endpoint); + ATH6KL_BUFFER_SIZE, endpoint); list_add_tail(&packet->list, &queue); } @@ -1266,8 +1266,8 @@ static void ath6kl_uapsd_trigger_frame_rx(struct ath6kl_vif *vif, flags = 0; ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi, - vif->fw_vif_idx, - conn->aid, 0, flags); + vif->fw_vif_idx, + conn->aid, 0, flags); } return; @@ -1575,7 +1575,7 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) aggr_conn = vif->aggr_cntxt->aggr_conn; if (aggr_process_recv_frm(aggr_conn, tid, seq_no, - is_amsdu, skb)) { + is_amsdu, skb)) { /* aggregation code will handle the skb */ return; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 573cb26077a9..73ac21e172df 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -127,7 +127,7 @@ int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) if (!is_ethertype(be16_to_cpu(type))) { ath6kl_dbg(ATH6KL_DBG_WMI, - "%s: pkt is already in 802.3 format\n", __func__); + "%s: pkt is already in 802.3 format\n", __func__); return 0; } @@ -911,7 +911,7 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) regpair = ath6kl_get_regpair((u16) reg_code); country = ath6kl_regd_find_country_by_rd((u16) reg_code); ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n", - regpair->regDmnEnum); + regpair->regDmnEnum); } if (country && wmi->parent_dev->wiphy_registered) { @@ -921,7 +921,7 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) regulatory_hint(wmi->parent_dev->wiphy, alpha2); ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", - alpha2[0], alpha2[1]); + alpha2[0], alpha2[1]); } } @@ -1365,8 +1365,8 @@ static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, /* Upper threshold breached */ if (rssi < sq_thresh->upper_threshold[0]) { ath6kl_dbg(ATH6KL_DBG_WMI, - "spurious upper rssi threshold event: %d\n", - rssi); + "spurious upper rssi threshold event: %d\n", + rssi); } else if ((rssi < sq_thresh->upper_threshold[1]) && (rssi >= sq_thresh->upper_threshold[0])) { new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; @@ -1389,7 +1389,7 @@ static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, /* Lower threshold breached */ if (rssi > sq_thresh->lower_threshold[0]) { ath6kl_dbg(ATH6KL_DBG_WMI, - "spurious lower rssi threshold event: %d %d\n", + "spurious lower rssi threshold event: %d %d\n", rssi, sq_thresh->lower_threshold[0]); } else if ((rssi > sq_thresh->lower_threshold[1]) && (rssi <= sq_thresh->lower_threshold[0])) { @@ -1550,8 +1550,8 @@ static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, /* Upper threshold breached */ if (snr < sq_thresh->upper_threshold[0]) { ath6kl_dbg(ATH6KL_DBG_WMI, - "spurious upper snr threshold event: %d\n", - snr); + "spurious upper snr threshold event: %d\n", + snr); } else if ((snr < sq_thresh->upper_threshold[1]) && (snr >= sq_thresh->upper_threshold[0])) { new_threshold = WMI_SNR_THRESHOLD1_ABOVE; @@ -1568,8 +1568,8 @@ static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, /* Lower threshold breached */ if (snr > sq_thresh->lower_threshold[0]) { ath6kl_dbg(ATH6KL_DBG_WMI, - "spurious lower snr threshold event: %d\n", - sq_thresh->lower_threshold[0]); + "spurious lower snr threshold event: %d\n", + sq_thresh->lower_threshold[0]); } else if ((snr > sq_thresh->lower_threshold[1]) && (snr <= sq_thresh->lower_threshold[0])) { new_threshold = WMI_SNR_THRESHOLD4_BELOW; @@ -2632,7 +2632,7 @@ int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, int ret; if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) && - wow_mode != ATH6KL_WOW_MODE_DISABLE) { + wow_mode != ATH6KL_WOW_MODE_DISABLE) { ath6kl_err("invalid wow mode: %d\n", wow_mode); return -EINVAL; } -- GitLab From ddc3d77c80bbaae562a91d4e032b56b2e4570f90 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:58 +0200 Subject: [PATCH 1511/1846] ath6kl: logical continuations should be on the previous line All found by checkpatch: ath6kl/wmi.c:1036: CHECK: Logical continuations should be on the previous line Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 10 +++++----- drivers/net/wireless/ath/ath6kl/htc.c | 8 ++++---- drivers/net/wireless/ath/ath6kl/main.c | 4 ++-- drivers/net/wireless/ath/ath6kl/wmi.c | 9 +++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index e1b0acc5a065..e14d1a072cfe 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -614,8 +614,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } if ((!(ar->connect_ctrl_flags & CONNECT_DO_WPA_OFFLOAD)) && - ((vif->auth_mode == WPA_PSK_AUTH) - || (vif->auth_mode == WPA2_PSK_AUTH))) { + ((vif->auth_mode == WPA_PSK_AUTH) || + (vif->auth_mode == WPA2_PSK_AUTH))) { mod_timer(&vif->disconnect_timer, jiffies + msecs_to_jiffies(DISCON_TIMER_INTVAL)); } @@ -1068,9 +1068,9 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, return -ENOTSUPP; } - if (((vif->auth_mode == WPA_PSK_AUTH) - || (vif->auth_mode == WPA2_PSK_AUTH)) - && (key_usage & GROUP_USAGE)) + if (((vif->auth_mode == WPA_PSK_AUTH) || + (vif->auth_mode == WPA2_PSK_AUTH)) && + (key_usage & GROUP_USAGE)) del_timer(&vif->disconnect_timer); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 0204b8314beb..24cfc3bb961e 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -1672,8 +1672,8 @@ static int htc_parse_trailer(struct htc_target *target, } lk_ahd = (struct htc_lookahead_report *) record_buf; - if ((lk_ahd->pre_valid == ((~lk_ahd->post_valid) & 0xFF)) - && next_lk_ahds) { + if ((lk_ahd->pre_valid == ((~lk_ahd->post_valid) & 0xFF)) && + next_lk_ahds) { ath6kl_dbg(ATH6KL_DBG_HTC, "htc rx lk_ahd found pre_valid 0x%x post_valid 0x%x\n", @@ -2449,8 +2449,8 @@ int ath6kl_htc_conn_service(struct htc_target *target, resp_msg = (struct htc_conn_service_resp *)rx_pkt->buf; - if ((le16_to_cpu(resp_msg->msg_id) != HTC_MSG_CONN_SVC_RESP_ID) - || (rx_pkt->act_len < sizeof(*resp_msg))) { + if ((le16_to_cpu(resp_msg->msg_id) != HTC_MSG_CONN_SVC_RESP_ID) || + (rx_pkt->act_len < sizeof(*resp_msg))) { status = -ENOMEM; goto fail_tx; } diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c index 91dbeb930298..229e1922ebe4 100644 --- a/drivers/net/wireless/ath/ath6kl/main.c +++ b/drivers/net/wireless/ath/ath6kl/main.c @@ -970,8 +970,8 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, set_bit(CONNECT_PEND, &vif->flags); if (((reason == ASSOC_FAILED) && (prot_reason_status == 0x11)) || - ((reason == ASSOC_FAILED) && (prot_reason_status == 0x0) - && (vif->reconnect_flag == 1))) { + ((reason == ASSOC_FAILED) && (prot_reason_status == 0x0) && + (vif->reconnect_flag == 1))) { set_bit(CONNECTED, &vif->flags); return; } diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c index 73ac21e172df..79aa90ba9163 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.c +++ b/drivers/net/wireless/ath/ath6kl/wmi.c @@ -826,8 +826,8 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { /* WMM OUT (00:50:F2) */ - if (pie[1] > 5 - && pie[6] == WMM_PARAM_OUI_SUBTYPE) + if (pie[1] > 5 && + pie[6] == WMM_PARAM_OUI_SUBTYPE) wmi->is_wmm_enabled = true; } break; @@ -1032,8 +1032,9 @@ static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len, if (len < 8 + 2 + 2) return -EINVAL; - if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags) - && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { + if (bih->frame_type == BEACON_FTYPE && + test_bit(CONNECTED, &vif->flags) && + memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { const u8 *tim; tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, len - 8 - 2 - 2); -- GitLab From d0d670abcf97d2e1a369449847d776ebbfba292d Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:58 +0200 Subject: [PATCH 1512/1846] ath6kl: remove multiple assignments Found by checkpatch: drivers/net/wireless/ath/ath6kl/cfg80211.c:1295: CHECK: multiple assignments should be avoided drivers/net/wireless/ath/ath6kl/cfg80211.c:3000: CHECK: multiple assignments should be avoided Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index e14d1a072cfe..9b87e6bf6c27 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -1285,7 +1285,6 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, { struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy); struct ath6kl_vif *vif; - u8 ath6kl_dbm; int dbm = MBM_TO_DBM(mbm); ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type 0x%x, dbm %d\n", __func__, @@ -1302,7 +1301,7 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, case NL80211_TX_POWER_AUTOMATIC: return 0; case NL80211_TX_POWER_LIMITED: - ar->tx_pwr = ath6kl_dbm = dbm; + ar->tx_pwr = dbm; break; default: ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: type 0x%x not supported\n", @@ -1310,7 +1309,7 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy, return -EOPNOTSUPP; } - ath6kl_wmi_set_tx_pwr_cmd(ar->wmi, vif->fw_vif_idx, ath6kl_dbm); + ath6kl_wmi_set_tx_pwr_cmd(ar->wmi, vif->fw_vif_idx, dbm); return 0; } @@ -3088,7 +3087,8 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, vif->wdev.netdev = ndev; vif->wdev.iftype = type; vif->fw_vif_idx = fw_vif_idx; - vif->nw_type = vif->next_mode = nw_type; + vif->nw_type = nw_type; + vif->next_mode = nw_type; vif->listen_intvl_t = ATH6KL_DEFAULT_LISTEN_INTVAL; vif->bmiss_time_t = ATH6KL_DEFAULT_BMISS_TIME; -- GitLab From 24fc32b35647401bbf03b3e2d5f01c6d0579a01c Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:58 +0200 Subject: [PATCH 1513/1846] ath6kl: add ath6kl_bmi_write_hi32() We have a lot of 32 bit writes to the host interest area and the code doing that is ugly. Clean that up by adding ath6kl_bmi_write_hi32(). This also fixes few checkpatch warnings. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/bmi.h | 9 +++ drivers/net/wireless/ath/ath6kl/init.c | 99 ++++++-------------------- 2 files changed, 32 insertions(+), 76 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/bmi.h b/drivers/net/wireless/ath/ath6kl/bmi.h index 114f7b265a3a..e6a7330aadcd 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.h +++ b/drivers/net/wireless/ath/ath6kl/bmi.h @@ -223,6 +223,15 @@ struct ath6kl_bmi_target_info { __le32 type; /* target type */ } __packed; +#define ath6kl_bmi_write_hi32(ar, item, val) \ + ({ \ + u32 addr, v; \ + addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \ + v = val; \ + ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v)); \ + }) + + int ath6kl_bmi_init(struct ath6kl *ar); void ath6kl_bmi_cleanup(struct ath6kl *ar); void ath6kl_bmi_reset(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 445426f3f9ed..da5900d30caa 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -352,11 +352,7 @@ static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val, blk_size |= ((u32)htc_ctrl_buf) << 16; /* set the host interest area for the block size */ - status = ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_mbox_io_block_sz)), - (u8 *)&blk_size, - 4); + status = ath6kl_bmi_write_hi32(ar, hi_mbox_io_block_sz, blk_size); if (status) { ath6kl_err("bmi_write_memory for IO block size failed\n"); goto out; @@ -368,11 +364,8 @@ static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val, if (mbox_isr_yield_val) { /* set the host interest area for the mbox ISR yield limit */ - status = ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_mbox_isr_yield_limit)), - (u8 *)&mbox_isr_yield_val, - 4); + status = ath6kl_bmi_write_hi32(ar, hi_mbox_isr_yield_limit, + mbox_isr_yield_val); if (status) { ath6kl_err("bmi_write_memory for yield limit failed\n"); goto out; @@ -463,8 +456,7 @@ int ath6kl_configure_target(struct ath6kl *ar) int i, status; param = !!(ar->conf_flags & ATH6KL_CONF_UART_DEBUG); - if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_serial_enable)), (u8 *)¶m, 4)) { + if (ath6kl_bmi_write_hi32(ar, hi_serial_enable, param)) { ath6kl_err("bmi_write_memory for uart debug failed\n"); return -EIO; } @@ -500,11 +492,8 @@ int ath6kl_configure_target(struct ath6kl *ar) if (ar->p2p && ar->vif_max == 1) fw_submode = HI_OPTION_FW_SUBMODE_P2PDEV; - param = HTC_PROTOCOL_VERSION; - if (ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_app_host_interest)), - (u8 *)¶m, 4) != 0) { + if (ath6kl_bmi_write_hi32(ar, hi_app_host_interest, + HTC_PROTOCOL_VERSION) != 0) { ath6kl_err("bmi_write_memory for htc version failed\n"); return -EIO; } @@ -527,11 +516,7 @@ int ath6kl_configure_target(struct ath6kl *ar) param |= (0 << HI_OPTION_MAC_ADDR_METHOD_SHIFT); param |= (0 << HI_OPTION_FW_BRIDGE_SHIFT); - if (ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_option_flag)), - (u8 *)¶m, - 4) != 0) { + if (ath6kl_bmi_write_hi32(ar, hi_option_flag, param) != 0) { ath6kl_err("bmi_write_memory for setting fwmode failed\n"); return -EIO; } @@ -550,16 +535,13 @@ int ath6kl_configure_target(struct ath6kl *ar) param = ar->hw.board_ext_data_addr; ram_reserved_size = ar->hw.reserved_ram_size; - if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_board_ext_data)), - (u8 *)¶m, 4) != 0) { + if (ath6kl_bmi_write_hi32(ar, hi_board_ext_data, param) != 0) { ath6kl_err("bmi_write_memory for hi_board_ext_data failed\n"); return -EIO; } - if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_end_ram_reserve_sz)), - (u8 *)&ram_reserved_size, 4) != 0) { + if (ath6kl_bmi_write_hi32(ar, hi_end_ram_reserve_sz, + ram_reserved_size) != 0) { ath6kl_err("bmi_write_memory for hi_end_ram_reserve_sz failed\n"); return -EIO; } @@ -570,20 +552,13 @@ int ath6kl_configure_target(struct ath6kl *ar) return -EIO; /* Configure GPIO AR600x UART */ - param = ar->hw.uarttx_pin; - status = ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_dbg_uart_txpin)), - (u8 *)¶m, 4); + status = ath6kl_bmi_write_hi32(ar, hi_dbg_uart_txpin, + ar->hw.uarttx_pin); if (status) return status; /* Configure target refclk_hz */ - param = ar->hw.refclk_hz; - status = ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_refclk_hz)), - (u8 *)¶m, 4); + status = ath6kl_bmi_write_hi32(ar, hi_refclk_hz, ar->hw.refclk_hz); if (status) return status; @@ -1096,11 +1071,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) * writing board data. */ if (ar->hw.board_addr != 0) { - board_address = ar->hw.board_addr; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_board_data)), - (u8 *) &board_address, 4); + ath6kl_bmi_write_hi32(ar, hi_board_data, + ar->hw.board_addr); } else { ath6kl_bmi_read(ar, ath6kl_get_hi_item_addr(ar, @@ -1157,10 +1129,7 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) /* record that extended board data is initialized */ param = (board_ext_data_size << 16) | 1; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_board_ext_data_config)), - (unsigned char *) ¶m, 4); + ath6kl_bmi_write_hi32(ar, hi_board_ext_data_config, param); } if (ar->fw_board_len < board_data_size) { @@ -1181,11 +1150,7 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) } /* record the fact that Board Data IS initialized */ - param = 1; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_board_data_initialized)), - (u8 *)¶m, 4); + ath6kl_bmi_write_hi32(ar, hi_board_data_initialized, 1); return ret; } @@ -1273,7 +1238,7 @@ static int ath6kl_upload_firmware(struct ath6kl *ar) static int ath6kl_upload_patch(struct ath6kl *ar) { - u32 address, param; + u32 address; int ret; if (ar->fw_patch == NULL) @@ -1290,18 +1255,14 @@ static int ath6kl_upload_patch(struct ath6kl *ar) return ret; } - param = address; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_dset_list_head)), - (unsigned char *) ¶m, 4); + ath6kl_bmi_write_hi32(ar, hi_dset_list_head, address); return 0; } static int ath6kl_upload_testscript(struct ath6kl *ar) { - u32 address, param; + u32 address; int ret; if (ar->testmode != 2) @@ -1322,23 +1283,9 @@ static int ath6kl_upload_testscript(struct ath6kl *ar) return ret; } - param = address; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_ota_testscript)), - (unsigned char *) ¶m, 4); - - param = 4096; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_end_ram_reserve_sz)), - (unsigned char *) ¶m, 4); - - param = 1; - ath6kl_bmi_write(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_test_apps_related)), - (unsigned char *) ¶m, 4); + ath6kl_bmi_write_hi32(ar, hi_ota_testscript, address); + ath6kl_bmi_write_hi32(ar, hi_end_ram_reserve_sz, 4096); + ath6kl_bmi_write_hi32(ar, hi_test_apps_related, 1); return 0; } -- GitLab From 80fb26863952eecef70b4e93c283d99584fbb912 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:59 +0200 Subject: [PATCH 1514/1846] ath6kl: add ath6kl_bmi_read_hi32() There are few 32 bit reads from the host interest area. Add ath6kl_bmi_read_hi32() to make it easier to do that. As code is cleaner this also fixes few checkpatch warnings. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/bmi.h | 7 +++++++ drivers/net/wireless/ath/ath6kl/init.c | 20 ++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/bmi.h b/drivers/net/wireless/ath/ath6kl/bmi.h index e6a7330aadcd..3c5b382a3529 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.h +++ b/drivers/net/wireless/ath/ath6kl/bmi.h @@ -231,6 +231,13 @@ struct ath6kl_bmi_target_info { ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v)); \ }) +#define ath6kl_bmi_read_hi32(ar, item, val) \ + ({ \ + u32 addr, *check_type = val; \ + (void) (check_type == val); \ + addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \ + ath6kl_bmi_read(ar, addr, (u8 *) val, 4); \ + }) int ath6kl_bmi_init(struct ath6kl *ar); void ath6kl_bmi_cleanup(struct ath6kl *ar); diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index da5900d30caa..d1d121dc8970 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -501,10 +501,7 @@ int ath6kl_configure_target(struct ath6kl *ar) /* set the firmware mode to STA/IBSS/AP */ param = 0; - if (ath6kl_bmi_read(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_option_flag)), - (u8 *)¶m, 4) != 0) { + if (ath6kl_bmi_read_hi32(ar, hi_option_flag, ¶m) != 0) { ath6kl_err("bmi_read_memory for setting fwmode failed\n"); return -EIO; } @@ -1074,17 +1071,11 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) ath6kl_bmi_write_hi32(ar, hi_board_data, ar->hw.board_addr); } else { - ath6kl_bmi_read(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_board_data)), - (u8 *) &board_address, 4); + ath6kl_bmi_read_hi32(ar, hi_board_data, &board_address); } /* determine where in target ram to write extended board data */ - ath6kl_bmi_read(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_board_ext_data)), - (u8 *) &board_ext_address, 4); + ath6kl_bmi_read_hi32(ar, hi_board_ext_data, &board_ext_address); if (ar->target_type == TARGET_TYPE_AR6003 && board_ext_address == 0) { @@ -1177,10 +1168,7 @@ static int ath6kl_upload_otp(struct ath6kl *ar) } /* read firmware start address */ - ret = ath6kl_bmi_read(ar, - ath6kl_get_hi_item_addr(ar, - HI_ITEM(hi_app_start)), - (u8 *) &address, sizeof(address)); + ret = ath6kl_bmi_read_hi32(ar, hi_app_start, &address); if (ret) { ath6kl_err("Failed to read hi_app_start: %d\n", ret); -- GitLab From 1ca4d0b6b903125b86df0586e5cb3db0b6674bb7 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:03:59 +0200 Subject: [PATCH 1515/1846] ath6kl: fix error handling ath6kl_target_config_wlan_params() The error handling in ath6kl_target_config_wlan_params() was just weird, fix that. This also fixes some of the open parenthesis alignment issues reported by checkpatch. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 66 +++++++++++++++----------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index d1d121dc8970..c7d514995b09 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -378,7 +378,6 @@ static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val, static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) { - int status = 0; int ret; /* @@ -386,43 +385,54 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) * default values. Required if checksum offload is needed. Set * RxMetaVersion to 2. */ - if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, idx, - ar->rx_meta_ver, 0, 0)) { - ath6kl_err("unable to set the rx frame format\n"); - status = -EIO; + ret = ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, idx, + ar->rx_meta_ver, 0, 0); + if (ret) { + ath6kl_err("unable to set the rx frame format: %d\n", ret); + return ret; } - if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN) - if ((ath6kl_wmi_pmparams_cmd(ar->wmi, idx, 0, 1, 0, 0, 1, - IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) { - ath6kl_err("unable to set power save fail event policy\n"); - status = -EIO; + if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN) { + ret = ath6kl_wmi_pmparams_cmd(ar->wmi, idx, 0, 1, 0, 0, 1, + IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN); + if (ret) { + ath6kl_err("unable to set power save fail event policy: %d\n", + ret); + return ret; } + } - if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER)) - if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, idx, 0, - WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) { - ath6kl_err("unable to set barker preamble policy\n"); - status = -EIO; + if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER)) { + ret = ath6kl_wmi_set_lpreamble_cmd(ar->wmi, idx, 0, + WMI_DONOT_IGNORE_BARKER_IN_ERP); + if (ret) { + ath6kl_err("unable to set barker preamble policy: %d\n", + ret); + return ret; } + } - if (ath6kl_wmi_set_keepalive_cmd(ar->wmi, idx, - WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) { - ath6kl_err("unable to set keep alive interval\n"); - status = -EIO; + ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, idx, + WLAN_CONFIG_KEEP_ALIVE_INTERVAL); + if (ret) { + ath6kl_err("unable to set keep alive interval: %d\n", ret); + return ret; } - if (ath6kl_wmi_disctimeout_cmd(ar->wmi, idx, - WLAN_CONFIG_DISCONNECT_TIMEOUT)) { - ath6kl_err("unable to set disconnect timeout\n"); - status = -EIO; + ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, idx, + WLAN_CONFIG_DISCONNECT_TIMEOUT); + if (ret) { + ath6kl_err("unable to set disconnect timeout: %d\n", ret); + return ret; } - if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST)) - if (ath6kl_wmi_set_wmm_txop(ar->wmi, idx, WMI_TXOP_DISABLED)) { - ath6kl_err("unable to set txop bursting\n"); - status = -EIO; + if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST)) { + ret = ath6kl_wmi_set_wmm_txop(ar->wmi, idx, WMI_TXOP_DISABLED); + if (ret) { + ath6kl_err("unable to set txop bursting: %d\n", ret); + return ret; } + } if (ar->p2p && (ar->vif_max == 1 || idx)) { ret = ath6kl_wmi_info_req_cmd(ar->wmi, idx, @@ -446,7 +456,7 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) } } - return status; + return ret; } int ath6kl_configure_target(struct ath6kl *ar) -- GitLab From 8c9bb054f866cefd54bf7d551bf69a1ab3ff2089 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:04:00 +0200 Subject: [PATCH 1516/1846] ath6kl: fix open paranthesis alignment in ath6kl_cfg80211_connect() ath6kl/cfg80211.c:462: CHECK: Alignment should match open parenthesis Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 9b87e6bf6c27..37908e60e863 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -416,6 +416,12 @@ static bool ath6kl_is_valid_iftype(struct ath6kl *ar, enum nl80211_iftype type, return false; } +static bool ath6kl_is_tx_pending(struct ath6kl *ar) +{ + return ar->tx_pending[ath6kl_wmi_get_control_ep(ar->wmi)] == 0; +} + + static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { @@ -460,8 +466,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, * sleep until the command queue drains */ wait_event_interruptible_timeout(ar->event_wq, - ar->tx_pending[ath6kl_wmi_get_control_ep(ar->wmi)] == 0, - WMI_TIMEOUT); + ath6kl_is_tx_pending(ar), + WMI_TIMEOUT); if (signal_pending(current)) { ath6kl_err("cmd queue drain timeout\n"); up(&ar->sem); -- GitLab From 12eb9444a8df7ab4aa5f4c91f8e3049af5d9819b Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:04:00 +0200 Subject: [PATCH 1517/1846] ath6kl: document all spinlocks Also fixes quite a few checkpatch warnings like this: ath6kl/hif.h:226: CHECK: spinlock_t definition without comment Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/core.h | 21 +++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/hif.h | 1 + drivers/net/wireless/ath/ath6kl/htc.h | 7 +++++++ drivers/net/wireless/ath/ath6kl/sdio.c | 5 +++++ drivers/net/wireless/ath/ath6kl/wmi.h | 2 ++ 5 files changed, 36 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h index f048924313fa..f1dd8906be45 100644 --- a/drivers/net/wireless/ath/ath6kl/core.h +++ b/drivers/net/wireless/ath/ath6kl/core.h @@ -233,6 +233,12 @@ struct rxtid { u32 hold_q_sz; struct skb_hold_q *hold_q; struct sk_buff_head q; + + /* + * FIXME: No clue what this should protect. Apparently it should + * protect some of the fields above but they are also accessed + * without taking the lock. + */ spinlock_t lock; }; @@ -311,7 +317,10 @@ struct ath6kl_sta { u8 auth; u8 wpa_ie[ATH6KL_MAX_IE]; struct sk_buff_head psq; + + /* protects psq, mgmt_psq, apsdq, and mgmt_psq_len fields */ spinlock_t psq_lock; + struct list_head mgmt_psq; size_t mgmt_psq_len; u8 apsd_info; @@ -572,7 +581,13 @@ struct ath6kl { unsigned int vif_max; u8 max_norm_iface; u8 avail_idx_map; + + /* + * Protects at least amsdu_rx_buffer_queue, ath6kl_alloc_cookie() + * calls, tx_pending and total_tx_data_pend. + */ spinlock_t lock; + struct semaphore sem; u8 lrssi_roam_threshold; struct ath6kl_version version; @@ -599,7 +614,13 @@ struct ath6kl { u8 sta_list_index; struct ath6kl_req_key ap_mode_bkey; struct sk_buff_head mcastpsq; + + /* + * FIXME: protects access to mcastpsq but is actually useless as + * all skbe_queue_*() functions provide serialisation themselves + */ spinlock_t mcastpsq_lock; + u8 intra_bss; struct wmi_ap_mode_stat ap_stats; u8 ap_country_code[3]; diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h index 904458ab484b..20ed6b73517b 100644 --- a/drivers/net/wireless/ath/ath6kl/hif.h +++ b/drivers/net/wireless/ath/ath6kl/hif.h @@ -223,6 +223,7 @@ struct ath6kl_irq_enable_reg { } __packed; struct ath6kl_device { + /* protects irq_proc_reg and irq_en_reg below */ spinlock_t lock; struct ath6kl_irq_proc_registers irq_proc_reg; struct ath6kl_irq_enable_reg irq_en_reg; diff --git a/drivers/net/wireless/ath/ath6kl/htc.h b/drivers/net/wireless/ath/ath6kl/htc.h index 2de4d6fc1e32..5027ccc36b62 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.h +++ b/drivers/net/wireless/ath/ath6kl/htc.h @@ -523,9 +523,16 @@ struct htc_target { struct ath6kl_htc_credit_info *credit_info; int tgt_creds; unsigned int tgt_cred_sz; + + /* protects free_ctrl_txbuf and free_ctrl_rxbuf */ spinlock_t htc_lock; + + /* FIXME: does this protext rx_bufq and endpoint structures or what? */ spinlock_t rx_lock; + + /* protects endpoint->txq */ spinlock_t tx_lock; + struct ath6kl_device *dev; u32 htc_flags; u32 rx_st_flags; diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 5d5f3faa1f04..5a03082ee589 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -32,6 +32,7 @@ struct ath6kl_sdio { struct sdio_func *func; + /* protects access to bus_req_freeq */ spinlock_t lock; /* free list */ @@ -53,13 +54,17 @@ struct ath6kl_sdio { atomic_t irq_handling; wait_queue_head_t irq_wq; + /* protects access to scat_req */ spinlock_t scat_lock; + bool scatter_enabled; bool is_disabled; const struct sdio_device_id *id; struct work_struct wr_async_work; struct list_head wr_asyncq; + + /* protects access to wr_asyncq */ spinlock_t wr_async_lock; }; diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index 892a7a0a1378..e0d9145c1cf7 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -111,6 +111,8 @@ struct wmi { u8 fat_pipe_exist; struct ath6kl *parent_dev; u8 pwr_mode; + + /* protects fat_pipe_exist and stream_exist_for_ac */ spinlock_t lock; enum htc_endpoint_id ep_id; struct sq_threshold_params -- GitLab From 05aab177a9a231455d8dfcb71c7179da0985e7f8 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:04:00 +0200 Subject: [PATCH 1518/1846] ath6kl: fix too long lines Found by checkpatch: drivers/net/wireless/ath/ath6kl/init.c:78: WARNING: line over 80 characters drivers/net/wireless/ath/ath6kl/init.c:397: WARNING: line over 80 characters drivers/net/wireless/ath/ath6kl/init.c:407: WARNING: line over 80 characters drivers/net/wireless/ath/ath6kl/htc.c:189: WARNING: line over 80 characters drivers/net/wireless/ath/ath6kl/htc.c:704: WARNING: line over 80 characters drivers/net/wireless/ath/ath6kl/htc.c:2452: WARNING: line over 80 characters Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/htc.c | 43 +++++++++++++------------- drivers/net/wireless/ath/ath6kl/init.c | 6 ++-- drivers/net/wireless/ath/ath6kl/wmi.h | 4 +-- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/htc.c b/drivers/net/wireless/ath/ath6kl/htc.c index 24cfc3bb961e..4849d99cce77 100644 --- a/drivers/net/wireless/ath/ath6kl/htc.c +++ b/drivers/net/wireless/ath/ath6kl/htc.c @@ -172,31 +172,29 @@ static void ath6kl_credit_reduce(struct ath6kl_htc_credit_info *cred_info, static void ath6kl_credit_update(struct ath6kl_htc_credit_info *cred_info, struct list_head *epdist_list) { - struct htc_endpoint_credit_dist *cur_dist_list; + struct htc_endpoint_credit_dist *cur_list; - list_for_each_entry(cur_dist_list, epdist_list, list) { - if (cur_dist_list->endpoint == ENDPOINT_0) + list_for_each_entry(cur_list, epdist_list, list) { + if (cur_list->endpoint == ENDPOINT_0) continue; - if (cur_dist_list->cred_to_dist > 0) { - cur_dist_list->credits += - cur_dist_list->cred_to_dist; - cur_dist_list->cred_to_dist = 0; - if (cur_dist_list->credits > - cur_dist_list->cred_assngd) + if (cur_list->cred_to_dist > 0) { + cur_list->credits += cur_list->cred_to_dist; + cur_list->cred_to_dist = 0; + + if (cur_list->credits > cur_list->cred_assngd) ath6kl_credit_reduce(cred_info, - cur_dist_list, - cur_dist_list->cred_assngd); + cur_list, + cur_list->cred_assngd); - if (cur_dist_list->credits > - cur_dist_list->cred_norm) - ath6kl_credit_reduce(cred_info, cur_dist_list, - cur_dist_list->cred_norm); + if (cur_list->credits > cur_list->cred_norm) + ath6kl_credit_reduce(cred_info, cur_list, + cur_list->cred_norm); - if (!(cur_dist_list->dist_flags & HTC_EP_ACTIVE)) { - if (cur_dist_list->txq_depth == 0) + if (!(cur_list->dist_flags & HTC_EP_ACTIVE)) { + if (cur_list->txq_depth == 0) ath6kl_credit_reduce(cred_info, - cur_dist_list, 0); + cur_list, 0); } } } @@ -674,6 +672,7 @@ static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, struct htc_packet *packet; int i, len, rem_scat, cred_pad; int status = 0; + u8 flags; rem_scat = target->max_tx_bndl_sz; @@ -700,8 +699,8 @@ static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target, scat_req->scat_list[i].packet = packet; /* prepare packet and flag message as part of a send bundle */ - ath6kl_htc_tx_prep_pkt(packet, - packet->info.tx.flags | HTC_FLAGS_SEND_BUNDLE, + flags = packet->info.tx.flags | HTC_FLAGS_SEND_BUNDLE; + ath6kl_htc_tx_prep_pkt(packet, flags, cred_pad, packet->info.tx.seqno); /* Make sure the buffer is 4-byte aligned */ ath6kl_htc_tx_buf_align(&packet->buf, @@ -2405,6 +2404,7 @@ int ath6kl_htc_conn_service(struct htc_target *target, enum htc_endpoint_id assigned_ep = ENDPOINT_MAX; unsigned int max_msg_sz = 0; int status = 0; + u16 msg_id; ath6kl_dbg(ATH6KL_DBG_HTC, "htc connect service target 0x%p service id 0x%x\n", @@ -2448,8 +2448,9 @@ int ath6kl_htc_conn_service(struct htc_target *target, } resp_msg = (struct htc_conn_service_resp *)rx_pkt->buf; + msg_id = le16_to_cpu(resp_msg->msg_id); - if ((le16_to_cpu(resp_msg->msg_id) != HTC_MSG_CONN_SVC_RESP_ID) || + if ((msg_id != HTC_MSG_CONN_SVC_RESP_ID) || (rx_pkt->act_len < sizeof(*resp_msg))) { status = -ENOMEM; goto fail_tx; diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index c7d514995b09..231675d4bf70 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -75,7 +75,7 @@ static const struct ath6kl_hw hw_list[] = { }, .fw_board = AR6003_HW_2_1_1_BOARD_DATA_FILE, - .fw_default_board = AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE, + .fw_default_board = AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE, }, { .id = AR6004_HW_1_0_VERSION, @@ -394,7 +394,7 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN) { ret = ath6kl_wmi_pmparams_cmd(ar->wmi, idx, 0, 1, 0, 0, 1, - IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN); + IGNORE_PS_FAIL_DURING_SCAN); if (ret) { ath6kl_err("unable to set power save fail event policy: %d\n", ret); @@ -404,7 +404,7 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER)) { ret = ath6kl_wmi_set_lpreamble_cmd(ar->wmi, idx, 0, - WMI_DONOT_IGNORE_BARKER_IN_ERP); + WMI_FOLLOW_BARKER_IN_ERP); if (ret) { ath6kl_err("unable to set barker preamble policy: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h index e0d9145c1cf7..4092e3e80790 100644 --- a/drivers/net/wireless/ath/ath6kl/wmi.h +++ b/drivers/net/wireless/ath/ath6kl/wmi.h @@ -1023,7 +1023,7 @@ struct wmi_power_mode_cmd { */ enum power_save_fail_event_policy { SEND_POWER_SAVE_FAIL_EVENT_ALWAYS = 1, - IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN = 2, + IGNORE_PS_FAIL_DURING_SCAN = 2, }; struct wmi_power_params_cmd { @@ -1221,7 +1221,7 @@ struct wmi_snr_threshold_params_cmd { enum wmi_preamble_policy { WMI_IGNORE_BARKER_IN_ERP = 0, - WMI_DONOT_IGNORE_BARKER_IN_ERP + WMI_FOLLOW_BARKER_IN_ERP, }; struct wmi_set_lpreamble_cmd { -- GitLab From b51f92e09ab63f49bb32769cc3a7d0d49ffefcdf Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 7 Mar 2012 20:04:00 +0200 Subject: [PATCH 1519/1846] ath6kl: make ath6kl_bmi_[read|write]_hi32() endian safe ath6kl_bmi_[read|write]_hi32() did not have endian support, fix that. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/bmi.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/bmi.h b/drivers/net/wireless/ath/ath6kl/bmi.h index 3c5b382a3529..18fdd69e1f71 100644 --- a/drivers/net/wireless/ath/ath6kl/bmi.h +++ b/drivers/net/wireless/ath/ath6kl/bmi.h @@ -225,18 +225,25 @@ struct ath6kl_bmi_target_info { #define ath6kl_bmi_write_hi32(ar, item, val) \ ({ \ - u32 addr, v; \ + u32 addr; \ + __le32 v; \ + \ addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \ - v = val; \ + v = cpu_to_le32(val); \ ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v)); \ }) #define ath6kl_bmi_read_hi32(ar, item, val) \ ({ \ u32 addr, *check_type = val; \ + __le32 tmp; \ + int ret; \ + \ (void) (check_type == val); \ addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \ - ath6kl_bmi_read(ar, addr, (u8 *) val, 4); \ + ret = ath6kl_bmi_read(ar, addr, (u8 *) &tmp, 4); \ + *val = le32_to_cpu(tmp); \ + ret; \ }) int ath6kl_bmi_init(struct ath6kl *ar); -- GitLab From fcff4f108dce0692410f390a05565f4b1b84577f Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Thu, 23 Feb 2012 17:59:53 -0800 Subject: [PATCH 1520/1846] mac80211: Filter duplicate IE ids mac80211 is lenient with respect to reception of corrupted beacons. Even if the frame is corrupted as a whole, the available IE elements are still passed back and accepted, sometimes replacing legitimate data. It is unknown to what extent this "feature" is made use of, but it is clear that in some cases, this is detrimental. One such case is reported in http://crosbug.com/26832 where an AP corrupts its beacons but not its probe responses. One approach would be to completely reject frames with invaid data (for example, if the last tag extends beyond the end of the enclosing PDU). The enclosed approach is much more conservative: we simply prevent later IEs from overwriting the state from previous ones. This approach hopes that there might be some salient data in the IE stream before the corruption, and seeks to at least prevent that data from being overwritten. This approach will fix the case above. Further, we flag element structures that contain data we think might be corrupted, so that as we fill the mac80211 BSS structure, we try not to replace data from an un-corrupted probe response with that of a corrupted beacon, for example. Short of any statistics gathering in the various forms of AP breakage, it's not possible to ascertain the side effects of more stringent discarding of data. Signed-off-by: Paul Stewart Cc: Sam Leffler Cc: Eliad Peller Acked-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ieee80211_i.h | 41 ++++++++++++++++++++++ net/mac80211/mlme.c | 14 ++++++++ net/mac80211/scan.c | 71 +++++++++++++++++++++++++++----------- net/mac80211/util.c | 37 ++++++++++++++++++-- 4 files changed, 141 insertions(+), 22 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 24cb1080e238..796b13bfc953 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -105,6 +105,44 @@ struct ieee80211_bss { */ bool has_erp_value; u8 erp_value; + + /* Keep track of the corruption of the last beacon/probe response. */ + u8 corrupt_data; + + /* Keep track of what bits of information we have valid info for. */ + u8 valid_data; +}; + +/** + * enum ieee80211_corrupt_data_flags - BSS data corruption flags + * @IEEE80211_BSS_CORRUPT_BEACON: last beacon frame received was corrupted + * @IEEE80211_BSS_CORRUPT_PROBE_RESP: last probe response received was corrupted + * + * These are bss flags that are attached to a bss in the + * @corrupt_data field of &struct ieee80211_bss. + */ +enum ieee80211_bss_corrupt_data_flags { + IEEE80211_BSS_CORRUPT_BEACON = BIT(0), + IEEE80211_BSS_CORRUPT_PROBE_RESP = BIT(1) +}; + +/** + * enum ieee80211_valid_data_flags - BSS valid data flags + * @IEEE80211_BSS_VALID_DTIM: DTIM data was gathered from non-corrupt IE + * @IEEE80211_BSS_VALID_WMM: WMM/UAPSD data was gathered from non-corrupt IE + * @IEEE80211_BSS_VALID_RATES: Supported rates were gathered from non-corrupt IE + * @IEEE80211_BSS_VALID_ERP: ERP flag was gathered from non-corrupt IE + * + * These are bss flags that are attached to a bss in the + * @valid_data field of &struct ieee80211_bss. They show which parts + * of the data structure were recieved as a result of an un-corrupted + * beacon/probe response. + */ +enum ieee80211_bss_valid_data_flags { + IEEE80211_BSS_VALID_DTIM = BIT(0), + IEEE80211_BSS_VALID_WMM = BIT(1), + IEEE80211_BSS_VALID_RATES = BIT(2), + IEEE80211_BSS_VALID_ERP = BIT(3) }; static inline u8 *bss_mesh_cfg(struct ieee80211_bss *bss) @@ -1120,6 +1158,9 @@ struct ieee802_11_elems { u8 quiet_elem_len; u8 num_of_quiet_elem; /* can be more the one */ u8 timeout_int_len; + + /* whether a parse error occurred while retrieving these elements */ + bool parse_error; }; static inline struct ieee80211_local *hw_to_local( diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 92c5eb124d6f..c08924aeac00 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3446,6 +3446,20 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, } run_again(ifmgd, assoc_data->timeout); + if (bss->corrupt_data) { + char *corrupt_type = "data"; + if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_BEACON) { + if (bss->corrupt_data & + IEEE80211_BSS_CORRUPT_PROBE_RESP) + corrupt_type = "beacon and probe response"; + else + corrupt_type = "beacon"; + } else if (bss->corrupt_data & IEEE80211_BSS_CORRUPT_PROBE_RESP) + corrupt_type = "probe response"; + printk(KERN_DEBUG "%s: associating with AP with corrupt %s\n", + sdata->name, corrupt_type); + } + err = 0; goto out; err_clear: diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index a9d7235df7c3..33cd16901378 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -104,16 +104,35 @@ ieee80211_bss_info_update(struct ieee80211_local *local, cbss->free_priv = ieee80211_rx_bss_free; bss = (void *)cbss->priv; + if (elems->parse_error) { + if (beacon) + bss->corrupt_data |= IEEE80211_BSS_CORRUPT_BEACON; + else + bss->corrupt_data |= IEEE80211_BSS_CORRUPT_PROBE_RESP; + } else { + if (beacon) + bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_BEACON; + else + bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_PROBE_RESP; + } + /* save the ERP value so that it is available at association time */ - if (elems->erp_info && elems->erp_info_len >= 1) { + if (elems->erp_info && elems->erp_info_len >= 1 && + (!elems->parse_error || + !(bss->valid_data & IEEE80211_BSS_VALID_ERP))) { bss->erp_value = elems->erp_info[0]; bss->has_erp_value = true; + if (!elems->parse_error) + bss->valid_data |= IEEE80211_BSS_VALID_ERP; } - if (elems->tim) { + if (elems->tim && (!elems->parse_error || + !(bss->valid_data & IEEE80211_BSS_VALID_DTIM))) { struct ieee80211_tim_ie *tim_ie = (struct ieee80211_tim_ie *)elems->tim; bss->dtim_period = tim_ie->dtim_period; + if (!elems->parse_error) + bss->valid_data |= IEEE80211_BSS_VALID_DTIM; } /* If the beacon had no TIM IE, or it was invalid, use 1 */ @@ -121,26 +140,38 @@ ieee80211_bss_info_update(struct ieee80211_local *local, bss->dtim_period = 1; /* replace old supported rates if we get new values */ - srlen = 0; - if (elems->supp_rates) { - clen = IEEE80211_MAX_SUPP_RATES; - if (clen > elems->supp_rates_len) - clen = elems->supp_rates_len; - memcpy(bss->supp_rates, elems->supp_rates, clen); - srlen += clen; - } - if (elems->ext_supp_rates) { - clen = IEEE80211_MAX_SUPP_RATES - srlen; - if (clen > elems->ext_supp_rates_len) - clen = elems->ext_supp_rates_len; - memcpy(bss->supp_rates + srlen, elems->ext_supp_rates, clen); - srlen += clen; + if (!elems->parse_error || + !(bss->valid_data & IEEE80211_BSS_VALID_RATES)) { + srlen = 0; + if (elems->supp_rates) { + clen = IEEE80211_MAX_SUPP_RATES; + if (clen > elems->supp_rates_len) + clen = elems->supp_rates_len; + memcpy(bss->supp_rates, elems->supp_rates, clen); + srlen += clen; + } + if (elems->ext_supp_rates) { + clen = IEEE80211_MAX_SUPP_RATES - srlen; + if (clen > elems->ext_supp_rates_len) + clen = elems->ext_supp_rates_len; + memcpy(bss->supp_rates + srlen, elems->ext_supp_rates, + clen); + srlen += clen; + } + if (srlen) { + bss->supp_rates_len = srlen; + if (!elems->parse_error) + bss->valid_data |= IEEE80211_BSS_VALID_RATES; + } } - if (srlen) - bss->supp_rates_len = srlen; - bss->wmm_used = elems->wmm_param || elems->wmm_info; - bss->uapsd_supported = is_uapsd_supported(elems); + if (!elems->parse_error || + !(bss->valid_data & IEEE80211_BSS_VALID_WMM)) { + bss->wmm_used = elems->wmm_param || elems->wmm_info; + bss->uapsd_supported = is_uapsd_supported(elems); + if (!elems->parse_error) + bss->valid_data |= IEEE80211_BSS_VALID_WMM; + } if (!beacon) bss->last_probe_resp = jiffies; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 0a5ad95ac8b0..32f7a3b3d43c 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -572,24 +572,40 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, size_t left = len; u8 *pos = start; bool calc_crc = filter != 0; + DECLARE_BITMAP(seen_elems, 256); + bitmap_zero(seen_elems, 256); memset(elems, 0, sizeof(*elems)); elems->ie_start = start; elems->total_len = len; while (left >= 2) { u8 id, elen; + bool elem_parse_failed; id = *pos++; elen = *pos++; left -= 2; - if (elen > left) + if (elen > left) { + elems->parse_error = true; break; + } + + if (id != WLAN_EID_VENDOR_SPECIFIC && + id != WLAN_EID_QUIET && + test_bit(id, seen_elems)) { + elems->parse_error = true; + left -= elen; + pos += elen; + continue; + } if (calc_crc && id < 64 && (filter & (1ULL << id))) crc = crc32_be(crc, pos - 2, elen + 2); + elem_parse_failed = false; + switch (id) { case WLAN_EID_SSID: elems->ssid = pos; @@ -615,7 +631,8 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, if (elen >= sizeof(struct ieee80211_tim_ie)) { elems->tim = (void *)pos; elems->tim_len = elen; - } + } else + elem_parse_failed = true; break; case WLAN_EID_IBSS_PARAMS: elems->ibss_params = pos; @@ -664,10 +681,14 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, case WLAN_EID_HT_CAPABILITY: if (elen >= sizeof(struct ieee80211_ht_cap)) elems->ht_cap_elem = (void *)pos; + else + elem_parse_failed = true; break; case WLAN_EID_HT_INFORMATION: if (elen >= sizeof(struct ieee80211_ht_info)) elems->ht_info_elem = (void *)pos; + else + elem_parse_failed = true; break; case WLAN_EID_MESH_ID: elems->mesh_id = pos; @@ -676,6 +697,8 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, case WLAN_EID_MESH_CONFIG: if (elen >= sizeof(struct ieee80211_meshconf_ie)) elems->mesh_config = (void *)pos; + else + elem_parse_failed = true; break; case WLAN_EID_PEER_MGMT: elems->peering = pos; @@ -696,6 +719,8 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, case WLAN_EID_RANN: if (elen >= sizeof(struct ieee80211_rann_ie)) elems->rann = (void *)pos; + else + elem_parse_failed = true; break; case WLAN_EID_CHANNEL_SWITCH: elems->ch_switch_elem = pos; @@ -724,10 +749,18 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, break; } + if (elem_parse_failed) + elems->parse_error = true; + else + set_bit(id, seen_elems); + left -= elen; pos += elen; } + if (left != 0) + elems->parse_error = true; + return crc; } -- GitLab From 9c083af8683808e486c20ca1f36da520d82e5981 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 3 Mar 2012 15:17:02 +0100 Subject: [PATCH 1521/1846] ath9k_hw: use cold instead of warm reset on AR9280 Cold reset is more reliable for getting the hardware out of some specific stuck states. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 8c840cad3ac2..d582cf73098f 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1386,10 +1386,16 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type) static bool ath9k_hw_chip_reset(struct ath_hw *ah, struct ath9k_channel *chan) { - if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) { - if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) - return false; - } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM)) + int reset_type = ATH9K_RESET_WARM; + + if (AR_SREV_9280(ah)) { + if (ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) + reset_type = ATH9K_RESET_POWER_ON; + else + reset_type = ATH9K_RESET_COLD; + } + + if (!ath9k_hw_set_reset_reg(ah, reset_type)) return false; if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) -- GitLab From 5baec7422c8c8f70c62b9493acf31d4854b09070 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 3 Mar 2012 15:17:03 +0100 Subject: [PATCH 1522/1846] ath9k: make MAC sample statistics optional They're more expensive than some of the other debug options and only used in very rare situations, so it sometimes makes sense to disable them while leaving in debugfs support. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/Kconfig | 8 ++++++++ drivers/net/wireless/ath/ath9k/debug.c | 10 ++++++++++ drivers/net/wireless/ath/ath9k/debug.h | 20 +++++++++++++++----- drivers/net/wireless/ath/ath9k/init.c | 4 +++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index 595a272aa96e..e507e78398f3 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig @@ -81,6 +81,14 @@ config ATH9K_DFS_CERTIFIED developed. At this point enabling this option won't do anything except increase code size. +config ATH9K_MAC_DEBUG + bool "Atheros MAC statistics" + depends on ATH9K_DEBUGFS + default y + ---help--- + This option enables collection of statistics for Rx/Tx status + data and some other MAC related statistics + config ATH9K_RATE_CONTROL bool "Atheros ath9k rate control" depends on ATH9K diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 228c18189a3a..03a474092e8b 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -818,6 +818,7 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) TX_STAT_INC(qnum, delim_underrun); +#ifdef CONFIG_ATH9K_MAC_DEBUG spin_lock(&sc->debug.samp_lock); TX_SAMP_DBG(jiffies) = jiffies; TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; @@ -844,6 +845,7 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; spin_unlock(&sc->debug.samp_lock); +#endif #undef TX_SAMP_DBG } @@ -1019,6 +1021,7 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna; +#ifdef CONFIG_ATH9K_MAC_DEBUG spin_lock(&sc->debug.samp_lock); RX_SAMP_DBG(jiffies) = jiffies; RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; @@ -1035,6 +1038,8 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; spin_unlock(&sc->debug.samp_lock); +#endif + #undef RX_STAT_INC #undef RX_PHY_ERR_INC #undef RX_SAMP_DBG @@ -1278,6 +1283,8 @@ static const struct file_operations fops_modal_eeprom = { .llseek = default_llseek, }; +#ifdef CONFIG_ATH9K_MAC_DEBUG + void ath9k_debug_samp_bb_mac(struct ath_softc *sc) { #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) @@ -1551,6 +1558,7 @@ static const struct file_operations fops_samps = { .llseek = default_llseek, }; +#endif int ath9k_init_debug(struct ath_hw *ah) { @@ -1604,8 +1612,10 @@ int ath9k_init_debug(struct ath_hw *ah) &fops_base_eeprom); debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_modal_eeprom); +#ifdef CONFIG_ATH9K_MAC_DEBUG debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_samps); +#endif debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index 776a24ada600..7a519582232a 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h @@ -235,16 +235,17 @@ struct ath9k_debug { struct dentry *debugfs_phy; u32 regidx; struct ath_stats stats; +#ifdef CONFIG_ATH9K_MAC_DEBUG spinlock_t samp_lock; struct ath_dbg_bb_mac_samp bb_mac_samp[ATH_DBG_MAX_SAMPLES]; u8 sampidx; u8 tsidx; u8 rsidx; +#endif }; int ath9k_init_debug(struct ath_hw *ah); -void ath9k_debug_samp_bb_mac(struct ath_softc *sc); void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, struct ath_tx_status *ts, struct ath_txq *txq, @@ -258,10 +259,6 @@ static inline int ath9k_init_debug(struct ath_hw *ah) return 0; } -static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc) -{ -} - static inline void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) { @@ -282,4 +279,17 @@ static inline void ath_debug_stat_rx(struct ath_softc *sc, #endif /* CONFIG_ATH9K_DEBUGFS */ +#ifdef CONFIG_ATH9K_MAC_DEBUG + +void ath9k_debug_samp_bb_mac(struct ath_softc *sc); + +#else + +static inline void ath9k_debug_samp_bb_mac(struct ath_softc *sc) +{ +} + +#endif + + #endif /* DEBUG_H */ diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index d8b05961f7e3..944e9b518f19 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -555,8 +555,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, mutex_init(&sc->mutex); #ifdef CONFIG_ATH9K_DEBUGFS spin_lock_init(&sc->nodes_lock); - spin_lock_init(&sc->debug.samp_lock); INIT_LIST_HEAD(&sc->nodes); +#endif +#ifdef CONFIG_ATH9K_MAC_DEBUG + spin_lock_init(&sc->debug.samp_lock); #endif tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet, -- GitLab From fc16fd8808968063929bbb198eb8bb46d40e36ce Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 3 Mar 2012 15:17:04 +0100 Subject: [PATCH 1523/1846] ath9k: remove rssi/antenna information from recv debug stats The way this is implemented (simply storing the last value) is absolutely worthless for debugging anything, and the same information is also available through the MAC sample feature, so there's no point in keeping this around. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/debug.c | 31 -------------------------- drivers/net/wireless/ath/ath9k/debug.h | 7 ------ 2 files changed, 38 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 03a474092e8b..c2edf688da49 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -943,27 +943,6 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "RSSI-CTL0", - sc->debug.stats.rxstats.rs_rssi_ctl0); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "RSSI-CTL1", - sc->debug.stats.rxstats.rs_rssi_ctl1); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "RSSI-CTL2", - sc->debug.stats.rxstats.rs_rssi_ctl2); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "RSSI-EXT0", - sc->debug.stats.rxstats.rs_rssi_ext0); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "RSSI-EXT1", - sc->debug.stats.rxstats.rs_rssi_ext1); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "RSSI-EXT2", - sc->debug.stats.rxstats.rs_rssi_ext2); - len += snprintf(buf + len, size - len, - "%22s : %10d\n", "Rx Antenna", - sc->debug.stats.rxstats.rs_antenna); len += snprintf(buf + len, size - len, "%22s : %10u\n", "RX-Pkts-All", sc->debug.stats.rxstats.rx_pkts_all); @@ -1011,16 +990,6 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) RX_PHY_ERR_INC(rs->rs_phyerr); } - sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0; - sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1; - sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2; - - sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0; - sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1; - sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2; - - sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna; - #ifdef CONFIG_ATH9K_MAC_DEBUG spin_lock(&sc->debug.samp_lock); RX_SAMP_DBG(jiffies) = jiffies; diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index 7a519582232a..64fcfad467bf 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h @@ -165,13 +165,6 @@ struct ath_rx_stats { u32 post_delim_crc_err; u32 decrypt_busy_err; u32 phy_err_stats[ATH9K_PHYERR_MAX]; - int8_t rs_rssi_ctl0; - int8_t rs_rssi_ctl1; - int8_t rs_rssi_ctl2; - int8_t rs_rssi_ext0; - int8_t rs_rssi_ext1; - int8_t rs_rssi_ext2; - u8 rs_antenna; }; enum ath_reset_type { -- GitLab From 3a2923e83c6036f55ad4a39c8ee9a7d4accd9539 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 3 Mar 2012 15:17:05 +0100 Subject: [PATCH 1524/1846] ath9k: get rid of double queueing of rx frames on EDMA Process rx status directly instead of separating the completion test from the actual rx status processing. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 18 +++------ drivers/net/wireless/ath/ath9k/ath9k.h | 1 - drivers/net/wireless/ath/ath9k/recv.c | 45 ++++++++++----------- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 01d5c1a4d746..a66a13b76848 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -436,20 +436,14 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr; unsigned int phyerr; - /* TODO: byte swap on big endian for ar9300_10 */ - - if (!rxs) { - if ((rxsp->status11 & AR_RxDone) == 0) - return -EINPROGRESS; - - if (MS(rxsp->ds_info, AR_DescId) != 0x168c) - return -EINVAL; + if ((rxsp->status11 & AR_RxDone) == 0) + return -EINPROGRESS; - if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0) - return -EINPROGRESS; + if (MS(rxsp->ds_info, AR_DescId) != 0x168c) + return -EINVAL; - return 0; - } + if ((rxsp->ds_info & (AR_TxRxDesc | AR_CtrlStat)) != 0) + return -EINPROGRESS; rxs->rs_status = 0; rxs->rs_flags = 0; diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index c2ccba676eca..3d8e51cd5d8f 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -299,7 +299,6 @@ struct ath_tx { struct ath_rx_edma { struct sk_buff_head rx_fifo; - struct sk_buff_head rx_buffers; u32 rx_fifo_hwsize; }; diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 4633f513a80b..c95b77cdf3bb 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -227,7 +227,6 @@ static void ath_rx_edma_cleanup(struct ath_softc *sc) static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size) { skb_queue_head_init(&rx_edma->rx_fifo); - skb_queue_head_init(&rx_edma->rx_buffers); rx_edma->rx_fifo_hwsize = size; } @@ -653,7 +652,9 @@ static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb, bool mybeacon) } static bool ath_edma_get_buffers(struct ath_softc *sc, - enum ath9k_rx_qtype qtype) + enum ath9k_rx_qtype qtype, + struct ath_rx_status *rs, + struct ath_buf **dest) { struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype]; struct ath_hw *ah = sc->sc_ah; @@ -672,7 +673,7 @@ static bool ath_edma_get_buffers(struct ath_softc *sc, dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, common->rx_bufsize, DMA_FROM_DEVICE); - ret = ath9k_hw_process_rxdesc_edma(ah, NULL, skb->data); + ret = ath9k_hw_process_rxdesc_edma(ah, rs, skb->data); if (ret == -EINPROGRESS) { /*let device gain the buffer again*/ dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, @@ -685,20 +686,21 @@ static bool ath_edma_get_buffers(struct ath_softc *sc, /* corrupt descriptor, skip this one and the following one */ list_add_tail(&bf->list, &sc->rx.rxbuf); ath_rx_edma_buf_link(sc, qtype); - skb = skb_peek(&rx_edma->rx_fifo); - if (!skb) - return true; - bf = SKB_CB_ATHBUF(skb); - BUG_ON(!bf); + skb = skb_peek(&rx_edma->rx_fifo); + if (skb) { + bf = SKB_CB_ATHBUF(skb); + BUG_ON(!bf); - __skb_unlink(skb, &rx_edma->rx_fifo); - list_add_tail(&bf->list, &sc->rx.rxbuf); - ath_rx_edma_buf_link(sc, qtype); - return true; + __skb_unlink(skb, &rx_edma->rx_fifo); + list_add_tail(&bf->list, &sc->rx.rxbuf); + ath_rx_edma_buf_link(sc, qtype); + } else { + bf = NULL; + } } - skb_queue_tail(&rx_edma->rx_buffers, skb); + *dest = bf; return true; } @@ -706,18 +708,15 @@ static struct ath_buf *ath_edma_get_next_rx_buf(struct ath_softc *sc, struct ath_rx_status *rs, enum ath9k_rx_qtype qtype) { - struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype]; - struct sk_buff *skb; - struct ath_buf *bf; + struct ath_buf *bf = NULL; - while (ath_edma_get_buffers(sc, qtype)); - skb = __skb_dequeue(&rx_edma->rx_buffers); - if (!skb) - return NULL; + while (ath_edma_get_buffers(sc, qtype, rs, &bf)) { + if (!bf) + continue; - bf = SKB_CB_ATHBUF(skb); - ath9k_hw_process_rxdesc_edma(sc->sc_ah, rs, skb->data); - return bf; + return bf; + } + return NULL; } static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc, -- GitLab From 2ef167557c0a26c88162ecffb017bfcc51eb7b29 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 3 Mar 2012 15:17:06 +0100 Subject: [PATCH 1525/1846] ath9k: fix signal strength reporting issues On A-MPDU frames, the hardware only reports valid signal strength data for the last subframe. The driver also mangled rx_stats->rs_rssi using the ATH_EP_RND macro in a way that may make sense for ANI, but definitely not for reporting to mac80211. This patch changes the code to calculate the signal strength from the rssi directly instead of taking the average value, and flag everything but the last subframe in an A-MPDU to tell mac80211 to ignore the signal strength entirely, fixing signal strength fluctuation issues reported by various users. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index c95b77cdf3bb..1b1b279c304a 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -948,6 +948,7 @@ static void ath9k_process_rssi(struct ath_common *common, struct ath_softc *sc = hw->priv; struct ath_hw *ah = common->ah; int last_rssi; + int rssi = rx_stats->rs_rssi; if (!rx_stats->is_mybeacon || ((ah->opmode != NL80211_IFTYPE_STATION) && @@ -959,13 +960,12 @@ static void ath9k_process_rssi(struct ath_common *common, last_rssi = sc->last_rssi; if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER)) - rx_stats->rs_rssi = ATH_EP_RND(last_rssi, - ATH_RSSI_EP_MULTIPLIER); - if (rx_stats->rs_rssi < 0) - rx_stats->rs_rssi = 0; + rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER); + if (rssi < 0) + rssi = 0; /* Update Beacon RSSI, this is used by ANI. */ - ah->stats.avgbrssi = rx_stats->rs_rssi; + ah->stats.avgbrssi = rssi; } /* @@ -1005,6 +1005,8 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common, rx_status->signal = ah->noise + rx_stats->rs_rssi; rx_status->antenna = rx_stats->rs_antenna; rx_status->flag |= RX_FLAG_MACTIME_MPDU; + if (rx_stats->rs_moreaggr) + rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL; return 0; } -- GitLab From 3d4f96997263d97cd4d60373f1ed8184ee6df31b Mon Sep 17 00:00:00 2001 From: Ashok Nagarajan Date: Tue, 6 Mar 2012 12:48:30 -0800 Subject: [PATCH 1526/1846] mac80211: Fix potential null pointer dereferencing The patch "{nl,cfg,mac}80211: Implement RSSI threshold for mesh peering" has a potential null pointer dereferencing problem. Thanks to Dan Carpenter for pointing out. This patch will fix the issue. Signed-off-by: Ashok Nagarajan Signed-off-by: John W. Linville --- net/mac80211/mesh_plink.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 80ce52772538..4e53c4cbca9e 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -31,10 +31,11 @@ #define dot11MeshHoldingTimeout(s) (s->u.mesh.mshcfg.dot11MeshHoldingTimeout) #define dot11MeshMaxPeerLinks(s) (s->u.mesh.mshcfg.dot11MeshMaxPeerLinks) -#define sta_meets_rssi_threshold(sta, sdata) \ +/* We only need a valid sta if user configured a minimum rssi_threshold. */ +#define rssi_threshold_check(sta, sdata) \ (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\ - (s8) -ewma_read(&sta->avg_signal) > \ - sdata->u.mesh.mshcfg.rssi_threshold) + (sta && (s8) -ewma_read(&sta->avg_signal) > \ + sdata->u.mesh.mshcfg.rssi_threshold)) enum plink_event { PLINK_UNDEFINED, @@ -307,7 +308,7 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, sta->plink_state == NL80211_PLINK_LISTEN && sdata->u.mesh.accepting_plinks && sdata->u.mesh.mshcfg.auto_open_plinks && - sta_meets_rssi_threshold(sta, sdata)) + rssi_threshold_check(sta, sdata)) mesh_plink_open(sta); rcu_read_unlock(); @@ -538,9 +539,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m } if (ftype == WLAN_SP_MESH_PEERING_OPEN && - !sta_meets_rssi_threshold(sta, sdata)) { + !rssi_threshold_check(sta, sdata)) { mpl_dbg("Mesh plink: %pM does not meet rssi threshold\n", - sta->sta.addr); + mgmt->sa); rcu_read_unlock(); return; } -- GitLab From e19918855dc4822a24787a6d0048205b011e5ecb Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:36 -0800 Subject: [PATCH 1527/1846] iwlwifi: move ucode loading to op_mode uCode loading belongs to the op_mode, as it is dependent on various things there and the commands sent during it are specific to it. Move the prototypes to iwl-agn.h to indicate this. To make this possible, also move all the calibration handling (which is op_mode dependent after all). 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 | 26 ++- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 9 +- drivers/net/wireless/iwlwifi/iwl-agn.h | 10 + drivers/net/wireless/iwlwifi/iwl-dev.h | 2 + drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 14 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 8 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 - drivers/net/wireless/iwlwifi/iwl-trans.h | 19 -- drivers/net/wireless/iwlwifi/iwl-ucode.c | 205 +++++++++--------- drivers/net/wireless/iwlwifi/iwl-wifi.h | 8 - 13 files changed, 150 insertions(+), 160 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 84fc5ce91b35..29f94597b55f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -75,6 +75,14 @@ * INIT calibrations framework *****************************************************************************/ +/* Opaque calibration results */ +struct iwl_calib_result { + struct list_head list; + size_t cmd_len; + struct iwl_calib_hdr hdr; + /* data follows */ +}; + struct statistics_general_data { u32 beacon_silence_rssi_a; u32 beacon_silence_rssi_b; @@ -84,7 +92,7 @@ struct statistics_general_data { u32 beacon_energy_c; }; -int iwl_send_calib_results(struct iwl_trans *trans) +int iwl_send_calib_results(struct iwl_priv *priv) { struct iwl_host_cmd hcmd = { .id = REPLY_PHY_CALIBRATION_CMD, @@ -92,15 +100,15 @@ int iwl_send_calib_results(struct iwl_trans *trans) }; struct iwl_calib_result *res; - list_for_each_entry(res, &trans->calib_results, list) { + list_for_each_entry(res, &priv->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, &hcmd); + ret = iwl_trans_send_cmd(trans(priv), &hcmd); if (ret) { - IWL_ERR(trans, "Error %d on calib cmd %d\n", + IWL_ERR(priv, "Error %d on calib cmd %d\n", ret, res->hdr.op_code); return ret; } @@ -109,7 +117,7 @@ int iwl_send_calib_results(struct iwl_trans *trans) return 0; } -int iwl_calib_set(struct iwl_trans *trans, +int iwl_calib_set(struct iwl_priv *priv, const struct iwl_calib_hdr *cmd, int len) { struct iwl_calib_result *res, *tmp; @@ -121,7 +129,7 @@ int iwl_calib_set(struct iwl_trans *trans, memcpy(&res->hdr, cmd, len); res->cmd_len = len; - list_for_each_entry(tmp, &trans->calib_results, list) { + 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); @@ -130,16 +138,16 @@ int iwl_calib_set(struct iwl_trans *trans, } /* wasn't in list already */ - list_add_tail(&res->list, &trans->calib_results); + list_add_tail(&res->list, &priv->calib_results); return 0; } -void iwl_calib_free_results(struct iwl_trans *trans) +void iwl_calib_free_results(struct iwl_priv *priv) { struct iwl_calib_result *res, *tmp; - list_for_each_entry_safe(res, tmp, &trans->calib_results, list) { + 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-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index e96af5133e06..45b060a45d9d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1195,7 +1195,7 @@ int iwlagn_suspend(struct iwl_priv *priv, priv->wowlan = true; - ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_WOWLAN); + ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); if (ret) goto out; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 8e025e0df50d..d16e73d1b5c9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1177,7 +1177,7 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, pkt->hdr.cmd); w->triggered = true; if (w->fn) - w->fn(trans(priv), pkt, w->fn_data); + w->fn(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 8bb3f173bfa0..f53308fb428e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -671,14 +671,14 @@ int iwl_alive_start(struct iwl_priv *priv) priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; priv->cur_rssi_ctx = NULL; - iwl_send_prio_tbl(trans(priv)); + iwl_send_prio_tbl(priv); /* FIXME: w/a to force change uCode BT state machine */ - ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN, + ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; - ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_CLOSE, + ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; @@ -1040,7 +1040,7 @@ static int iwl_init_drv(struct iwl_priv *priv) mutex_init(&priv->shrd->mutex); - INIT_LIST_HEAD(&trans(priv)->calib_results); + INIT_LIST_HEAD(&priv->calib_results); priv->ieee_channels = NULL; priv->ieee_rates = NULL; @@ -1105,6 +1105,7 @@ static void iwl_uninit_drv(struct iwl_priv *priv) kfree(priv->scan_cmd); kfree(priv->beacon_cmd); kfree(rcu_dereference_raw(priv->noa_data)); + iwl_calib_free_results(priv); #ifdef CONFIG_IWLWIFI_DEBUGFS kfree(priv->wowlan_sram); #endif diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 70100f9a2e5c..2a90d779eecf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -113,6 +113,16 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags); +int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); +void iwl_send_prio_tbl(struct iwl_priv *priv); +int iwl_init_alive_start(struct iwl_priv *priv); +int iwl_run_init_ucode(struct iwl_priv *priv); +int iwl_load_ucode_wait_alive(struct iwl_priv *priv, + enum iwl_ucode_type ucode_type); +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); /* lib */ int iwlagn_send_tx_power(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 5957209b2f37..7199748faaab 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -724,6 +724,8 @@ struct iwl_priv { struct ieee80211_rate *ieee_rates; struct kmem_cache *tx_cmd_pool; + struct list_head calib_results; + struct workqueue_struct *workqueue; enum ieee80211_band band; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 7f937151a8af..37330addce79 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -278,13 +278,13 @@ static int __iwl_up(struct iwl_priv *priv) } } - ret = iwl_run_init_ucode(trans(priv)); + ret = iwl_run_init_ucode(priv); if (ret) { IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); goto error; } - ret = iwl_load_ucode_wait_alive(trans(priv), IWL_UCODE_REGULAR); + ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); if (ret) { IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); goto error; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index ef80e0386c30..dc5544653bc0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -233,7 +233,7 @@ enum iwl_ucode_type { struct iwl_notification_wait { struct list_head list; - void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt, + void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt, void *data); void *fn_data; @@ -472,12 +472,12 @@ bool iwl_check_for_ct_kill(struct iwl_priv *priv); 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_trans *trans, - struct iwl_rx_packet *pkt, - void *data), - void *fn_data); + 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, diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index b24b166a9482..ec803ea08675 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -422,7 +422,7 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) iwl_init_notification_wait(priv->shrd, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); - ret = iwl_init_alive_start(trans(priv)); + ret = iwl_init_alive_start(priv); if (ret) { IWL_ERR(priv, "Fail init calibration: %d\n", ret); goto cfg_init_calib_error; @@ -484,7 +484,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: - status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT); + status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT); if (status) IWL_ERR(priv, "Error loading init ucode: %d\n", status); break; @@ -495,7 +495,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: - status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_REGULAR); + status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); if (status) { IWL_ERR(priv, "Error loading runtime ucode: %d\n", status); @@ -510,7 +510,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: iwl_scan_cancel_timeout(priv, 200); iwl_trans_stop_device(trans); - status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_WOWLAN); + status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); if (status) { IWL_ERR(priv, "Error loading WOWLAN ucode: %d\n", status); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 3ae2fd720ed8..f49aa181f4af 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1632,7 +1632,6 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - iwl_calib_free_results(trans); iwl_trans_pcie_tx_free(trans); #ifndef CONFIG_IWLWIFI_IDI iwl_trans_pcie_rx_free(trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index b09192a028de..6fa0c860a5e2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -315,14 +315,6 @@ struct iwl_trans_ops { u32 (*read32)(struct iwl_trans *trans, u32 ofs); }; -/* Opaque calibration results */ -struct iwl_calib_result { - struct list_head list; - size_t cmd_len; - struct iwl_calib_hdr hdr; - /* data follows */ -}; - /** * enum iwl_trans_state - state of the transport layer * @@ -349,7 +341,6 @@ enum iwl_trans_state { * @ucode_write_complete: indicates that the ucode has been copied. * @nvm_device_type: indicates OTP or eeprom * @pm_support: set to true in start_hw if link pm is supported - * @calib_results: list head for init calibration results */ struct iwl_trans { const struct iwl_trans_ops *ops; @@ -369,8 +360,6 @@ struct iwl_trans { int nvm_device_type; bool pm_support; - 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] __aligned(sizeof(void *)); @@ -573,14 +562,6 @@ static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) return trans->ops->read32(trans, ofs); } -/***************************************************** -* Utils functions -******************************************************/ -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); - /***************************************************** * Transport layers implementations + their allocation function ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 64a9c5ce5f89..340575a01ead 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -80,16 +80,16 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { * ******************************************************************************/ -static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic, - enum iwl_ucode_type ucode_type) +static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv, + enum iwl_ucode_type ucode_type) { switch (ucode_type) { case IWL_UCODE_INIT: - return &nic->fw.ucode_init; + return &nic(priv)->fw.ucode_init; case IWL_UCODE_WOWLAN: - return &nic->fw.ucode_wowlan; + return &nic(priv)->fw.ucode_wowlan; case IWL_UCODE_REGULAR: - return &nic->fw.ucode_rt; + return &nic(priv)->fw.ucode_rt; case IWL_UCODE_NONE: break; } @@ -99,23 +99,23 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_nic *nic, /* * Calibration */ -static int iwl_set_Xtal_calib(struct iwl_trans *trans) +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(trans->shrd, 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]); cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); - return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwl_set_temperature_offset_calib(struct iwl_trans *trans) +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(trans->shrd, + (__le16 *)iwl_eeprom_query_addr(priv->shrd, EEPROM_RAW_TEMPERATURE); memset(&cmd, 0, sizeof(cmd)); @@ -124,48 +124,48 @@ static int iwl_set_temperature_offset_calib(struct iwl_trans *trans) if (!(cmd.radio_sensor_offset)) cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; - IWL_DEBUG_CALIB(trans, "Radio sensor offset: %d\n", + IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", le16_to_cpu(cmd.radio_sensor_offset)); - return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwl_set_temperature_offset_calib_v2(struct iwl_trans *trans) +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(trans->shrd, + __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv->shrd, EEPROM_KELVIN_TEMPERATURE); __le16 *offset_calib_low = - (__le16 *)iwl_eeprom_query_addr(trans->shrd, + (__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(trans->shrd, + 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)); memcpy(&cmd.radio_sensor_offset_low, offset_calib_low, sizeof(*offset_calib_low)); if (!(cmd.radio_sensor_offset_low)) { - IWL_DEBUG_CALIB(trans, "no info in EEPROM, use default\n"); + 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(trans, "Radio sensor offset high: %d\n", + IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n", le16_to_cpu(cmd.radio_sensor_offset_high)); - IWL_DEBUG_CALIB(trans, "Radio sensor offset low: %d\n", + IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n", le16_to_cpu(cmd.radio_sensor_offset_low)); - IWL_DEBUG_CALIB(trans, "Voltage Ref: %d\n", + IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", le16_to_cpu(cmd.burntVoltageRef)); - return iwl_calib_set(trans, (void *)&cmd, sizeof(cmd)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwl_send_calib_cfg(struct iwl_trans *trans) +static int iwl_send_calib_cfg(struct iwl_priv *priv) { struct iwl_calib_cfg_cmd calib_cfg_cmd; struct iwl_host_cmd cmd = { @@ -181,7 +181,7 @@ static int iwl_send_calib_cfg(struct iwl_trans *trans) calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; - return iwl_trans_send_cmd(trans, &cmd); + return iwl_trans_send_cmd(trans(priv), &cmd); } int iwlagn_rx_calib_result(struct iwl_priv *priv, @@ -195,33 +195,33 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv, /* reduce the size of the length field itself */ len -= 4; - if (iwl_calib_set(trans(priv), hdr, len)) + if (iwl_calib_set(priv, hdr, len)) IWL_ERR(priv, "Failed to record calibration data %d\n", hdr->op_code); return 0; } -int iwl_init_alive_start(struct iwl_trans *trans) +int iwl_init_alive_start(struct iwl_priv *priv) { int ret; - if (cfg(trans)->bt_params && - cfg(trans)->bt_params->advanced_bt_coexist) { + if (cfg(priv)->bt_params && + cfg(priv)->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 = iwl_send_bt_env(trans, IWL_BT_COEX_ENV_OPEN, + ret = iwl_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; } - ret = iwl_send_calib_cfg(trans); + ret = iwl_send_calib_cfg(priv); if (ret) return ret; @@ -229,21 +229,21 @@ int iwl_init_alive_start(struct iwl_trans *trans) * temperature offset calibration is only needed for runtime ucode, * so prepare the value now. */ - if (cfg(trans)->need_temp_offset_calib) { - if (cfg(trans)->temp_offset_v2) - return iwl_set_temperature_offset_calib_v2(trans); + if (cfg(priv)->need_temp_offset_calib) { + if (cfg(priv)->temp_offset_v2) + return iwl_set_temperature_offset_calib_v2(priv); else - return iwl_set_temperature_offset_calib(trans); + return iwl_set_temperature_offset_calib(priv); } return 0; } -static int iwl_send_wimax_coex(struct iwl_trans *trans) +static int iwl_send_wimax_coex(struct iwl_priv *priv) { struct iwl_wimax_coex_cmd coex_cmd; - if (cfg(trans)->base_params->support_wimax_coexist) { + if (cfg(priv)->base_params->support_wimax_coexist) { /* UnMask wake up src at associated sleep */ coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK; @@ -262,7 +262,7 @@ static int iwl_send_wimax_coex(struct iwl_trans *trans) /* coexistence is disabled */ memset(&coex_cmd, 0, sizeof(coex_cmd)); } - return iwl_trans_send_cmd_pdu(trans, + return iwl_trans_send_cmd_pdu(trans(priv), COEX_PRIORITY_TABLE_CMD, CMD_SYNC, sizeof(coex_cmd), &coex_cmd); } @@ -289,37 +289,36 @@ static const u8 iwl_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { 0, 0, 0, 0, 0, 0, 0 }; -void iwl_send_prio_tbl(struct iwl_trans *trans) +void iwl_send_prio_tbl(struct iwl_priv *priv) { struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl, sizeof(iwl_bt_prio_tbl)); - if (iwl_trans_send_cmd_pdu(trans, + if (iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, sizeof(prio_tbl_cmd), &prio_tbl_cmd)) - IWL_ERR(trans, "failed to send BT prio tbl command\n"); + IWL_ERR(priv, "failed to send BT prio tbl command\n"); } -int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type) +int iwl_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, + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_COEX_PROT_ENV, CMD_SYNC, sizeof(env_cmd), &env_cmd); if (ret) - IWL_ERR(trans, "failed to send BT env command\n"); + IWL_ERR(priv, "failed to send BT env command\n"); return ret; } -static int iwl_alive_notify(struct iwl_trans *trans) +static int iwl_alive_notify(struct iwl_priv *priv) { - struct iwl_priv *priv = priv(trans); struct iwl_rxon_context *ctx; int ret; @@ -332,21 +331,21 @@ static int iwl_alive_notify(struct iwl_trans *trans) if (!priv->tx_cmd_pool) return -ENOMEM; - iwl_trans_fw_alive(trans); + iwl_trans_fw_alive(trans(priv)); for_each_context(priv, ctx) ctx->last_tx_rejected = false; - ret = iwl_send_wimax_coex(trans); + ret = iwl_send_wimax_coex(priv); if (ret) return ret; if (!cfg(priv)->no_xtal_calib) { - ret = iwl_set_Xtal_calib(trans); + ret = iwl_set_Xtal_calib(priv); if (ret) return ret; } - return iwl_send_calib_results(trans); + return iwl_send_calib_results(priv); } @@ -355,24 +354,23 @@ static int iwl_alive_notify(struct iwl_trans *trans) * 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_nic *nic, - struct fw_desc *fw_desc) +static int iwl_verify_inst_sparse(struct iwl_priv *priv, + struct fw_desc *fw_desc) { - struct iwl_trans *trans = trans(nic); __le32 *image = (__le32 *)fw_desc->v_addr; u32 len = fw_desc->len; u32 val; u32 i; - IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(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_write_direct32(trans, HBUS_TARG_MEM_RADDR, + iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR, i + IWLAGN_RTC_INST_LOWER_BOUND); - val = iwl_read32(trans, HBUS_TARG_MEM_RDAT); + val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) return -EIO; } @@ -380,28 +378,27 @@ static int iwl_verify_inst_sparse(struct iwl_nic *nic, return 0; } -static void iwl_print_mismatch_inst(struct iwl_nic *nic, +static void iwl_print_mismatch_inst(struct iwl_priv *priv, struct fw_desc *fw_desc) { - struct iwl_trans *trans = trans(nic); __le32 *image = (__le32 *)fw_desc->v_addr; u32 len = fw_desc->len; u32 val; u32 offs; int errors = 0; - IWL_DEBUG_FW(nic, "ucode inst image size is %u\n", len); + IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); - iwl_write_direct32(trans, HBUS_TARG_MEM_RADDR, + iwl_write_direct32(trans(priv), 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(trans, HBUS_TARG_MEM_RDAT); + val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(nic, "uCode INST section at " + IWL_ERR(priv, "uCode INST section at " "offset 0x%x, is 0x%x, s/b 0x%x\n", offs, val, le32_to_cpu(*image)); errors++; @@ -413,24 +410,24 @@ static void iwl_print_mismatch_inst(struct iwl_nic *nic, * iwl_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int iwl_verify_ucode(struct iwl_nic *nic, +static int iwl_verify_ucode(struct iwl_priv *priv, enum iwl_ucode_type ucode_type) { - struct fw_img *img = iwl_get_ucode_image(nic, ucode_type); + struct fw_img *img = iwl_get_ucode_image(priv, ucode_type); if (!img) { - IWL_ERR(nic, "Invalid ucode requested (%d)\n", ucode_type); + IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); return -EINVAL; } - if (!iwl_verify_inst_sparse(nic, &img->code)) { - IWL_DEBUG_FW(nic, "uCode is good in inst SRAM\n"); + if (!iwl_verify_inst_sparse(priv, &img->code)) { + IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(nic, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); + IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - iwl_print_mismatch_inst(nic, &img->code); + iwl_print_mismatch_inst(priv, &img->code); return -EIO; } @@ -439,7 +436,7 @@ struct iwl_alive_data { u8 subtype; }; -static void iwl_alive_fn(struct iwl_trans *trans, +static void iwl_alive_fn(struct iwl_priv *priv, struct iwl_rx_packet *pkt, void *data) { @@ -448,14 +445,14 @@ static void iwl_alive_fn(struct iwl_trans *trans, palive = &pkt->u.alive_frame; - IWL_DEBUG_FW(trans, "Alive ucode status 0x%08X revision " + IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); - trans->shrd->device_pointers.error_event_table = + priv->shrd->device_pointers.error_event_table = le32_to_cpu(palive->error_event_table_ptr); - trans->shrd->device_pointers.log_event_table = + priv->shrd->device_pointers.log_event_table = le32_to_cpu(palive->log_event_table_ptr); alive_data->subtype = palive->ver_subtype; @@ -464,12 +461,12 @@ static void iwl_alive_fn(struct iwl_trans *trans, /* notification wait support */ void iwl_init_notification_wait(struct iwl_shared *shrd, - struct iwl_notification_wait *wait_entry, - u8 cmd, - void (*fn)(struct iwl_trans *trans, - struct iwl_rx_packet *pkt, - void *data), - void *fn_data) + 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; @@ -529,7 +526,7 @@ void iwl_abort_notification_waits(struct iwl_shared *shrd) #define UCODE_ALIVE_TIMEOUT HZ #define UCODE_CALIB_TIMEOUT (2*HZ) -int iwl_load_ucode_wait_alive(struct iwl_trans *trans, +int iwl_load_ucode_wait_alive(struct iwl_priv *priv, enum iwl_ucode_type ucode_type) { struct iwl_notification_wait alive_wait; @@ -538,20 +535,20 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, int ret; enum iwl_ucode_type old_type; - iwl_init_notification_wait(trans->shrd, &alive_wait, REPLY_ALIVE, + iwl_init_notification_wait(priv->shrd, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); - old_type = trans->shrd->ucode_type; - trans->shrd->ucode_type = ucode_type; - fw = iwl_get_ucode_image(nic(trans), ucode_type); + old_type = priv->shrd->ucode_type; + priv->shrd->ucode_type = ucode_type; + fw = iwl_get_ucode_image(priv, ucode_type); if (!fw) return -EINVAL; - ret = iwl_trans_start_fw(trans, fw); + ret = iwl_trans_start_fw(trans(priv), fw); if (ret) { - trans->shrd->ucode_type = old_type; - iwl_remove_notification(trans->shrd, &alive_wait); + priv->shrd->ucode_type = old_type; + iwl_remove_notification(priv->shrd, &alive_wait); return ret; } @@ -559,16 +556,16 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, * Some things may run in the background now, but we * just wait for the ALIVE notification here. */ - ret = iwl_wait_notification(trans->shrd, &alive_wait, + ret = iwl_wait_notification(priv->shrd, &alive_wait, UCODE_ALIVE_TIMEOUT); if (ret) { - trans->shrd->ucode_type = old_type; + priv->shrd->ucode_type = old_type; return ret; } if (!alive_data.valid) { - IWL_ERR(trans, "Loaded ucode is not valid!\n"); - trans->shrd->ucode_type = old_type; + IWL_ERR(priv, "Loaded ucode is not valid!\n"); + priv->shrd->ucode_type = old_type; return -EIO; } @@ -578,9 +575,9 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, * skip it for WoWLAN. */ if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(nic(trans), ucode_type); + ret = iwl_verify_ucode(priv, ucode_type); if (ret) { - trans->shrd->ucode_type = old_type; + priv->shrd->ucode_type = old_type; return ret; } @@ -588,41 +585,41 @@ int iwl_load_ucode_wait_alive(struct iwl_trans *trans, msleep(5); } - ret = iwl_alive_notify(trans); + ret = iwl_alive_notify(priv); if (ret) { - IWL_WARN(trans, + IWL_WARN(priv, "Could not complete ALIVE transition: %d\n", ret); - trans->shrd->ucode_type = old_type; + priv->shrd->ucode_type = old_type; return ret; } return 0; } -int iwl_run_init_ucode(struct iwl_trans *trans) +int iwl_run_init_ucode(struct iwl_priv *priv) { struct iwl_notification_wait calib_wait; int ret; - lockdep_assert_held(&trans->shrd->mutex); + lockdep_assert_held(&priv->shrd->mutex); /* No init ucode required? Curious, but maybe ok */ - if (!nic(trans)->fw.ucode_init.code.len) + if (!nic(priv)->fw.ucode_init.code.len) return 0; - if (trans->shrd->ucode_type != IWL_UCODE_NONE) + if (priv->shrd->ucode_type != IWL_UCODE_NONE) return 0; - iwl_init_notification_wait(trans->shrd, &calib_wait, + iwl_init_notification_wait(priv->shrd, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); /* Will also start the device */ - ret = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT); + ret = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT); if (ret) goto error; - ret = iwl_init_alive_start(trans); + ret = iwl_init_alive_start(priv); if (ret) goto error; @@ -630,15 +627,15 @@ int iwl_run_init_ucode(struct iwl_trans *trans) * Some things may run in the background now, but we * just wait for the calibration complete notification. */ - ret = iwl_wait_notification(trans->shrd, &calib_wait, + ret = iwl_wait_notification(priv->shrd, &calib_wait, UCODE_CALIB_TIMEOUT); goto out; error: - iwl_remove_notification(trans->shrd, &calib_wait); + iwl_remove_notification(priv->shrd, &calib_wait); out: /* Whatever happened, stop the device */ - iwl_trans_stop_device(trans); + iwl_trans_stop_device(trans(priv)); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index d157931e1e95..753e338e77d0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -95,12 +95,4 @@ struct iwl_nic { struct completion request_firmware_complete; }; - - -int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); -void iwl_send_prio_tbl(struct iwl_trans *trans); -int iwl_init_alive_start(struct iwl_trans *trans); -int iwl_run_init_ucode(struct iwl_trans *trans); -int iwl_load_ucode_wait_alive(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type); #endif /* __iwl_wifi_h__ */ -- GitLab From 0692fe41b36159be5d8c7d4eef0699e79c383c85 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:37 -0800 Subject: [PATCH 1528/1846] iwlwifi: split out firmware store Through the driver, struct iwl_fw will store the firmware. Split this out into a separate file, iwl-fw.h, and make all other code use it. To do this, also move the log pointers into it, and remove the knowledge of "nic" from everything. Now the op_mode has a fw pointer, and (unfortunately) for now the shared data also needs to keep one for the transport to access dump the error log -- I think that will move later. Since I wanted to constify the firmware pointers, some more changes were needed. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 5 +- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 10 +- drivers/net/wireless/iwlwifi/iwl-agn.h | 2 +- drivers/net/wireless/iwlwifi/iwl-commands.h | 12 -- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 9 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 + drivers/net/wireless/iwlwifi/iwl-drv.c | 49 +++--- drivers/net/wireless/iwlwifi/iwl-fw.h | 146 ++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 10 +- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 4 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 5 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 16 +- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 23 ++- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 9 +- drivers/net/wireless/iwlwifi/iwl-trans.h | 5 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 21 ++- drivers/net/wireless/iwlwifi/iwl-ucode.h | 60 ------- drivers/net/wireless/iwlwifi/iwl-wifi.h | 10 -- 19 files changed, 236 insertions(+), 163 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-fw.h diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 29f94597b55f..4928f6f52bf1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -69,7 +69,6 @@ #include "iwl-trans.h" #include "iwl-agn.h" #include "iwl-wifi.h" -#include "iwl-ucode.h" /***************************************************************************** * INIT calibrations framework @@ -644,7 +643,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv) data->last_bad_plcp_cnt_cck = 0; data->last_fa_cnt_cck = 0; - if (nic(priv)->fw.enhance_sensitivity_table) + if (priv->fw->enhance_sensitivity_table) ret |= iwl_enhance_sensitivity_write(priv); else ret |= iwl_sensitivity_write(priv); @@ -754,7 +753,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv) iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); - if (nic(priv)->fw.enhance_sensitivity_table) + if (priv->fw->enhance_sensitivity_table) iwl_enhance_sensitivity_write(priv); else iwl_sensitivity_write(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 45b060a45d9d..89be05615dd9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -77,7 +77,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv) tx_power_cmd.flags = IWLAGN_TX_POWER_NO_CLOSED; tx_power_cmd.srv_chan_lmt = IWLAGN_TX_POWER_AUTO; - if (IWL_UCODE_API(nic(priv)->fw.ucode_ver) == 1) + if (IWL_UCODE_API(priv->fw->ucode_ver) == 1) tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD_V1; else tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index f53308fb428e..c3040ad86e89 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -41,7 +41,6 @@ #include -#include "iwl-ucode.h" #include "iwl-eeprom.h" #include "iwl-wifi.h" #include "iwl-dev.h" @@ -616,7 +615,7 @@ static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant) .valid = cpu_to_le32(valid_tx_ant), }; - if (IWL_UCODE_API(nic(priv)->fw.ucode_ver) > 1) { + if (IWL_UCODE_API(priv->fw->ucode_ver) > 1) { IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant); return iwl_trans_send_cmd_pdu(trans(priv), TX_ANT_CONFIGURATION_CMD, @@ -1174,9 +1173,9 @@ static void iwl_debug_config(struct iwl_priv *priv) #endif } -static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) +static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, + const struct iwl_fw *fw) { - struct iwl_fw *fw = &nic(trans)->fw; int err = 0; struct iwl_priv *priv; struct ieee80211_hw *hw; @@ -1200,6 +1199,9 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans) priv = IWL_OP_MODE_GET_DVM(op_mode); priv->shrd = trans->shrd; priv->shrd->priv = priv; + priv->fw = fw; + /* TODO: remove fw from shared data later */ + priv->shrd->fw = fw; iwl_trans_configure(trans(priv), op_mode); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 2a90d779eecf..f55243828698 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -93,7 +93,7 @@ void iwl_nic_error(struct iwl_op_mode *op_mode); /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); int iwlagn_mac_setup_register(struct iwl_priv *priv, - struct iwl_ucode_capabilities *capa); + const struct iwl_ucode_capabilities *capa); void iwlagn_mac_unregister(struct iwl_priv *priv); /* RXON */ diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index c20618d92268..aa8993065cdf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -74,13 +74,6 @@ struct iwl_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) - - /* Tx rates */ #define IWL_CCK_RATES 4 #define IWL_OFDM_RATES 8 @@ -3151,8 +3144,6 @@ struct iwl_enhance_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 enum { IWL_PHY_CALIBRATE_DC_CMD = 8, IWL_PHY_CALIBRATE_LO_CMD = 9, @@ -3161,11 +3152,8 @@ enum { IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16, IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD = 18, - IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, }; -#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253) - /* This enum defines the bitmap of various calibrations to enable in both * init ucode and runtime ucode through CALIBRATION_CFG_CMD. */ diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index b6740c33b519..0e63cb70c713 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -235,12 +235,11 @@ 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_nic *nic = nic(priv); priv->dbgfs_sram_offset = 0x800000; - if (nic->shrd->ucode_type == IWL_UCODE_INIT) - priv->dbgfs_sram_len = nic->fw.ucode_init.data.len; + if (priv->shrd->ucode_type == IWL_UCODE_INIT) + priv->dbgfs_sram_len = priv->fw->ucode_init.data.len; else - priv->dbgfs_sram_len = nic->fw.ucode_rt.data.len; + priv->dbgfs_sram_len = priv->fw->ucode_rt.data.len; } len = priv->dbgfs_sram_len; @@ -343,7 +342,7 @@ static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, priv->wowlan_sram, - nic(priv)->fw.ucode_wowlan.data.len); + priv->fw->ucode_wowlan.data.len); } static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 7199748faaab..4def9f961891 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -715,6 +715,7 @@ struct iwl_priv { /*data shared among all the driver's layers */ struct iwl_shared *shrd; + const struct iwl_fw *fw; spinlock_t sta_lock; diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 1a588f36b591..351b2f908383 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -71,6 +71,9 @@ #include "iwl-shared.h" #include "iwl-op-mode.h" +/* private includes */ +#include "iwl-ucode.h" + static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc) { if (desc->v_addr) @@ -641,20 +644,20 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * for each event, which is of mode 1 (including timestamp) for all * new microcodes that include this information. */ - nic->init_evtlog_ptr = pieces.init_evtlog_ptr; + fw->init_evtlog_ptr = pieces.init_evtlog_ptr; if (pieces.init_evtlog_size) - nic->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; + fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; else - nic->init_evtlog_size = + fw->init_evtlog_size = cfg->base_params->max_event_log_size; - nic->init_errlog_ptr = pieces.init_errlog_ptr; - nic->inst_evtlog_ptr = pieces.inst_evtlog_ptr; + fw->init_errlog_ptr = pieces.init_errlog_ptr; + fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr; if (pieces.inst_evtlog_size) - nic->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; + fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; else - nic->inst_evtlog_size = + fw->inst_evtlog_size = cfg->base_params->max_event_log_size; - nic->inst_errlog_ptr = pieces.inst_errlog_ptr; + fw->inst_errlog_ptr = pieces.inst_errlog_ptr; /* * figure out the offset of chain noise reset and gain commands @@ -669,7 +672,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) release_firmware(ucode_raw); complete(&nic->request_firmware_complete); - nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans); + nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans, &nic->fw); if (!nic->op_mode) goto out_unbind; @@ -695,24 +698,27 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) int iwl_drv_start(struct iwl_shared *shrd, struct iwl_trans *trans, const struct iwl_cfg *cfg) { + struct iwl_nic *nic; int ret; shrd->cfg = cfg; - shrd->nic = kzalloc(sizeof(*shrd->nic), GFP_KERNEL); - if (!shrd->nic) { + nic = kzalloc(sizeof(*nic), GFP_KERNEL); + if (!nic) { dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_nic"); return -ENOMEM; } - shrd->nic->shrd = shrd; + nic->shrd = shrd; + shrd->nic = nic; - init_completion(&shrd->nic->request_firmware_complete); + init_completion(&nic->request_firmware_complete); - ret = iwl_request_firmware(shrd->nic, true); + ret = iwl_request_firmware(nic, true); if (ret) { dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw"); - kfree(shrd->nic); + kfree(nic); + shrd->nic = NULL; } return ret; @@ -720,13 +726,16 @@ int iwl_drv_start(struct iwl_shared *shrd, void iwl_drv_stop(struct iwl_shared *shrd) { - wait_for_completion(&shrd->nic->request_firmware_complete); + struct iwl_nic *nic = shrd->nic; + + wait_for_completion(&nic->request_firmware_complete); /* op_mode can be NULL if its start failed */ - if (shrd->nic->op_mode) - iwl_op_mode_stop(shrd->nic->op_mode); + if (nic->op_mode) + iwl_op_mode_stop(nic->op_mode); - iwl_dealloc_ucode(shrd->nic); + iwl_dealloc_ucode(nic); - kfree(shrd->nic); + kfree(nic); + shrd->nic = NULL; } diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h new file mode 100644 index 000000000000..453812a21176 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h @@ -0,0 +1,146 @@ +/****************************************************************************** + * + * 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 - 2012 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 - 2012 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 __iwl_fw_h__ +#define __iwl_fw_h__ +#include + +/** + * enum iwl_ucode_tlv_flag - ucode API flags + * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously + * was a separate TLV but moved here to save space. + * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID, + * treats good CRC threshold as a boolean + * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). + * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. + */ +enum iwl_ucode_tlv_flag { + IWL_UCODE_TLV_FLAGS_PAN = BIT(0), + IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), + IWL_UCODE_TLV_FLAGS_MFP = BIT(2), + IWL_UCODE_TLV_FLAGS_P2P = BIT(3), +}; + +/* The default calibrate table size if not specified by firmware file */ +#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 +#define IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE 19 +#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE 253 + +struct iwl_ucode_capabilities { + u32 max_probe_length; + u32 standard_phy_calibration_size; + u32 flags; +}; + +/* one for each uCode image (inst/data, boot/init/runtime) */ +struct fw_desc { + dma_addr_t p_addr; /* hardware address */ + void *v_addr; /* software address */ + u32 len; /* size in bytes */ +}; + +struct fw_img { + struct fw_desc code; /* firmware code image */ + struct fw_desc data; /* firmware data image */ +}; + +/* 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) + +/** + * struct iwl_fw - variables associated with the firmware + * + * @ucode_ver: ucode version from the ucode file + * @fw_version: firmware version string + * @ucode_rt: run time ucode image + * @ucode_init: init ucode image + * @ucode_wowlan: wake on wireless ucode image (optional) + * @ucode_capa: capabilities parsed from the ucode file. + * @enhance_sensitivity_table: device can do enhanced sensitivity. + * @init_evtlog_ptr: event log offset for init ucode. + * @init_evtlog_size: event log size for init ucode. + * @init_errlog_ptr: error log offfset for init ucode. + * @inst_evtlog_ptr: event log offset for runtime ucode. + * @inst_evtlog_size: event log size for runtime ucode. + * @inst_errlog_ptr: error log offfset for runtime ucode. + */ +struct iwl_fw { + u32 ucode_ver; + + char fw_version[ETHTOOL_BUSINFO_LEN]; + + /* ucode images */ + struct fw_img ucode_rt; + struct fw_img ucode_init; + struct fw_img ucode_wowlan; + + struct iwl_ucode_capabilities ucode_capa; + bool enhance_sensitivity_table; + + u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; + u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; +}; + +#endif /* __iwl_fw_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 37330addce79..3bcd2a766074 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -42,7 +42,6 @@ #include -#include "iwl-ucode.h" #include "iwl-eeprom.h" #include "iwl-wifi.h" #include "iwl-dev.h" @@ -136,7 +135,7 @@ iwlagn_iface_combinations_p2p[] = { * other mac80211 functions grouped here. */ int iwlagn_mac_setup_register(struct iwl_priv *priv, - struct iwl_ucode_capabilities *capa) + const struct iwl_ucode_capabilities *capa) { int ret; struct ieee80211_hw *hw = priv->hw; @@ -195,7 +194,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_DISABLE_BEACON_HINTS | WIPHY_FLAG_IBSS_RSN; - if (nic(priv)->fw.ucode_wowlan.code.len && + if (priv->fw->ucode_wowlan.code.len && trans(priv)->ops->wowlan_suspend && device_can_wakeup(trans(priv)->dev)) { hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | @@ -456,17 +455,16 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) #ifdef CONFIG_IWLWIFI_DEBUGFS if (ret == 0) { - struct iwl_nic *nic = nic(priv); if (!priv->wowlan_sram) priv->wowlan_sram = - kzalloc(nic->fw.ucode_wowlan.data.len, + kzalloc(priv->fw->ucode_wowlan.data.len, GFP_KERNEL); if (priv->wowlan_sram) _iwl_read_targ_mem_words( trans(priv), 0x800000, priv->wowlan_sram, - nic->fw.ucode_wowlan.data.len / 4); + priv->fw->ucode_wowlan.data.len / 4); } #endif } diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index 41e58a136715..55b8b27a9560 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -68,6 +68,7 @@ struct iwl_trans; struct sk_buff; struct iwl_device_cmd; struct iwl_rx_cmd_buffer; +struct iwl_fw; /** * DOC: Operational mode - what is it ? @@ -123,7 +124,8 @@ struct iwl_rx_cmd_buffer; * @nic_error: error notification. Must be atomic */ struct iwl_op_mode_ops { - struct iwl_op_mode *(*start)(struct iwl_trans *trans); + struct iwl_op_mode *(*start)(struct iwl_trans *trans, + const struct iwl_fw *fw); void (*stop)(struct iwl_op_mode *op_mode); int (*rx)(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index dc5544653bc0..3754c35a1a50 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -70,6 +70,7 @@ #include #include "iwl-commands.h" +#include "iwl-fw.h" /** * DOC: shared area - role and goal @@ -418,8 +419,9 @@ struct iwl_shared { const struct iwl_cfg *cfg; struct iwl_priv *priv; struct iwl_trans *trans; - struct iwl_nic *nic; + void *nic; struct iwl_hw_params hw_params; + const struct iwl_fw *fw; struct mutex mutex; @@ -446,7 +448,6 @@ struct iwl_shared { /*Whatever _m is (iwl_trans, iwl_priv, these macros will work */ #define priv(_m) ((_m)->shrd->priv) #define cfg(_m) ((_m)->shrd->cfg) -#define nic(_m) ((_m)->shrd->nic) #define trans(_m) ((_m)->shrd->trans) #define hw_params(_m) ((_m)->shrd->hw_params) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index ec803ea08675..fd25dd1d62e0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -553,7 +553,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: IWL_INFO(priv, "uCode version raw: 0x%x\n", - nic(priv)->fw.ucode_ver); + priv->fw->ucode_ver); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); if (!skb) { @@ -561,7 +561,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) return -ENOMEM; } NLA_PUT_U32(skb, IWL_TM_ATTR_FW_VERSION, - nic(priv)->fw.ucode_ver); + priv->fw->ucode_ver); status = cfg80211_testmode_reply(skb); if (status < 0) IWL_ERR(priv, "Error sending msg : %d\n", status); @@ -590,16 +590,16 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) } switch (priv->shrd->ucode_type) { case IWL_UCODE_REGULAR: - inst_size = nic(priv)->fw.ucode_rt.code.len; - data_size = nic(priv)->fw.ucode_rt.data.len; + inst_size = priv->fw->ucode_rt.code.len; + data_size = priv->fw->ucode_rt.data.len; break; case IWL_UCODE_INIT: - inst_size = nic(priv)->fw.ucode_init.code.len; - data_size = nic(priv)->fw.ucode_init.data.len; + inst_size = priv->fw->ucode_init.code.len; + data_size = priv->fw->ucode_init.data.len; break; case IWL_UCODE_WOWLAN: - inst_size = nic(priv)->fw.ucode_wowlan.code.len; - data_size = nic(priv)->fw.ucode_wowlan.data.len; + inst_size = priv->fw->ucode_wowlan.code.len; + data_size = priv->fw->ucode_wowlan.data.len; break; case IWL_UCODE_NONE: IWL_ERR(priv, "No uCode has not been loaded\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index bf560e9f87b7..69e4544afe24 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -602,17 +602,16 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) { u32 base; struct iwl_error_event_table table; - struct iwl_nic *nic = nic(trans); struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); base = trans->shrd->device_pointers.error_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) - base = nic->init_errlog_ptr; + base = trans->shrd->fw->init_errlog_ptr; } else { if (!base) - base = nic->inst_errlog_ptr; + base = trans->shrd->fw->inst_errlog_ptr; } if (!iwlagn_hw_valid_rtc_data_addr(base)) { @@ -634,7 +633,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) trans_pcie->isr_stats.err_code = table.error_id; - trace_iwlwifi_dev_ucode_error(priv(nic), table.error_id, table.tsf_low, + trace_iwlwifi_dev_ucode_error(priv(trans), table.error_id, table.tsf_low, table.data1, table.data2, table.line, table.blink1, table.blink2, table.ilink1, table.ilink2, table.bcon_time, table.gp1, @@ -700,7 +699,7 @@ static void iwl_irq_handle_error(struct iwl_trans *trans) } IWL_ERR(trans, "Loaded firmware version: %s\n", - nic(trans)->fw.fw_version); + trans->shrd->fw->fw_version); iwl_dump_nic_error_log(trans); iwl_dump_csr(trans); @@ -726,7 +725,6 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, u32 ptr; /* SRAM byte address of log data */ u32 ev, time, data; /* event log data */ unsigned long reg_flags; - struct iwl_nic *nic = nic(trans); if (num_events == 0) return pos; @@ -734,10 +732,10 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, base = trans->shrd->device_pointers.log_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) - base = nic->init_evtlog_ptr; + base = trans->shrd->fw->init_evtlog_ptr; } else { if (!base) - base = nic->inst_evtlog_ptr; + base = trans->shrd->fw->inst_evtlog_ptr; } if (mode == 0) @@ -843,17 +841,16 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, u32 logsize; int pos = 0; size_t bufsz = 0; - struct iwl_nic *nic = nic(trans); base = trans->shrd->device_pointers.log_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { - logsize = nic->init_evtlog_size; + logsize = trans->shrd->fw->init_evtlog_size; if (!base) - base = nic->init_evtlog_ptr; + base = trans->shrd->fw->init_evtlog_ptr; } else { - logsize = nic->inst_evtlog_size; + logsize = trans->shrd->fw->inst_evtlog_size; if (!base) - base = nic->inst_evtlog_ptr; + base = trans->shrd->fw->inst_evtlog_ptr; } if (!iwlagn_hw_valid_rtc_data_addr(base)) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index f49aa181f4af..d7dbd80eb108 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -76,7 +76,6 @@ #include "iwl-eeprom.h" #include "iwl-agn-hw.h" #include "iwl-core.h" -#include "iwl-ucode.h" #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) @@ -947,7 +946,7 @@ static const u8 iwlagn_pan_ac_to_queue[] = { * ucode */ static int iwl_load_section(struct iwl_trans *trans, const char *name, - struct fw_desc *image, u32 dst_addr) + const struct fw_desc *image, u32 dst_addr) { dma_addr_t phy_addr = image->p_addr; u32 byte_cnt = image->len; @@ -995,7 +994,8 @@ static int iwl_load_section(struct iwl_trans *trans, const char *name, return 0; } -static int iwl_load_given_ucode(struct iwl_trans *trans, struct fw_img *image) +static int iwl_load_given_ucode(struct iwl_trans *trans, + const struct fw_img *image) { int ret = 0; @@ -1015,7 +1015,8 @@ static int iwl_load_given_ucode(struct iwl_trans *trans, struct fw_img *image) return 0; } -static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw) +static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, + const struct fw_img *fw) { int ret; struct iwl_trans_pcie *trans_pcie = diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 6fa0c860a5e2..ec5249c8a7f4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -272,7 +272,7 @@ struct iwl_trans_ops { int (*start_hw)(struct iwl_trans *iwl_trans); void (*stop_hw)(struct iwl_trans *iwl_trans); - int (*start_fw)(struct iwl_trans *trans, struct fw_img *fw); + int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw); void (*fw_alive)(struct iwl_trans *trans); void (*stop_device)(struct iwl_trans *trans); @@ -400,7 +400,8 @@ static inline void iwl_trans_fw_alive(struct iwl_trans *trans) trans->state = IWL_TRANS_FW_ALIVE; } -static inline int iwl_trans_start_fw(struct iwl_trans *trans, struct fw_img *fw) +static inline int iwl_trans_start_fw(struct iwl_trans *trans, + const struct fw_img *fw) { might_sleep(); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 340575a01ead..f78b1552ef7c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -31,7 +31,6 @@ #include #include -#include "iwl-ucode.h" #include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" @@ -80,16 +79,16 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { * ******************************************************************************/ -static inline struct fw_img *iwl_get_ucode_image(struct iwl_priv *priv, - enum iwl_ucode_type ucode_type) +static inline const struct fw_img * +iwl_get_ucode_image(struct iwl_priv *priv, enum iwl_ucode_type ucode_type) { switch (ucode_type) { case IWL_UCODE_INIT: - return &nic(priv)->fw.ucode_init; + return &priv->fw->ucode_init; case IWL_UCODE_WOWLAN: - return &nic(priv)->fw.ucode_wowlan; + return &priv->fw->ucode_wowlan; case IWL_UCODE_REGULAR: - return &nic(priv)->fw.ucode_rt; + return &priv->fw->ucode_rt; case IWL_UCODE_NONE: break; } @@ -355,7 +354,7 @@ static int iwl_alive_notify(struct iwl_priv *priv) * it's a pretty good bet that everything between them is good, too. */ static int iwl_verify_inst_sparse(struct iwl_priv *priv, - struct fw_desc *fw_desc) + const struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; u32 len = fw_desc->len; @@ -379,7 +378,7 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, } static void iwl_print_mismatch_inst(struct iwl_priv *priv, - struct fw_desc *fw_desc) + const struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; u32 len = fw_desc->len; @@ -413,7 +412,7 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, static int iwl_verify_ucode(struct iwl_priv *priv, enum iwl_ucode_type ucode_type) { - struct fw_img *img = iwl_get_ucode_image(priv, ucode_type); + const struct fw_img *img = iwl_get_ucode_image(priv, ucode_type); if (!img) { IWL_ERR(priv, "Invalid ucode requested (%d)\n", ucode_type); @@ -531,7 +530,7 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv, { struct iwl_notification_wait alive_wait; struct iwl_alive_data alive_data; - struct fw_img *fw; + const struct fw_img *fw; int ret; enum iwl_ucode_type old_type; @@ -604,7 +603,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv) lockdep_assert_held(&priv->shrd->mutex); /* No init ucode required? Curious, but maybe ok */ - if (!nic(priv)->fw.ucode_init.code.len) + if (!priv->fw->ucode_init.code.len) return 0; if (priv->shrd->ucode_type != IWL_UCODE_NONE) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-ucode.h index 8bebeb003bef..cdab28784404 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.h +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.h @@ -126,22 +126,6 @@ enum iwl_ucode_tlv_type { IWL_UCODE_TLV_FLAGS = 18, }; -/** - * enum iwl_ucode_tlv_flag - ucode API flags - * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously - * was a separate TLV but moved here to save space. - * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID, - * treats good CRC threshold as a boolean - * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w). - * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P. - */ -enum iwl_ucode_tlv_flag { - IWL_UCODE_TLV_FLAGS_PAN = BIT(0), - IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1), - IWL_UCODE_TLV_FLAGS_MFP = BIT(2), - IWL_UCODE_TLV_FLAGS_P2P = BIT(3), -}; - struct iwl_ucode_tlv { __le16 type; /* see above */ __le16 alternative; /* see comment */ @@ -173,48 +157,4 @@ struct iwl_tlv_ucode_header { u8 data[0]; }; -struct iwl_ucode_capabilities { - u32 max_probe_length; - u32 standard_phy_calibration_size; - u32 flags; -}; - -/* one for each uCode image (inst/data, boot/init/runtime) */ -struct fw_desc { - dma_addr_t p_addr; /* hardware address */ - void *v_addr; /* software address */ - u32 len; /* size in bytes */ -}; - -struct fw_img { - struct fw_desc code; /* firmware code image */ - struct fw_desc data; /* firmware data image */ -}; - -/** - * struct iwl_fw - variables associated with the firmware - * - * @ucode_ver: ucode version from the ucode file - * @fw_version: firmware version string - * @ucode_rt: run time ucode image - * @ucode_init: init ucode image - * @ucode_wowlan: wake on wireless ucode image (optional) - * @ucode_capa: capabilities parsed from the ucode file. - * @enhance_sensitivity_table: device can do enhanced sensitivity. - */ -struct iwl_fw { - - u32 ucode_ver; - - char fw_version[ETHTOOL_BUSINFO_LEN]; - - /* ucode images */ - struct fw_img ucode_rt; - struct fw_img ucode_init; - struct fw_img ucode_wowlan; - - struct iwl_ucode_capabilities ucode_capa; - bool enhance_sensitivity_table; -}; - #endif /* __iwl_ucode_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h index 753e338e77d0..a71624d3ea23 100644 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h @@ -64,7 +64,6 @@ #define __iwl_wifi_h__ #include "iwl-shared.h" -#include "iwl-ucode.h" /** * struct iwl_nic - nic common data @@ -73,12 +72,6 @@ * @op_mode: the running op_mode * @fw_index: firmware revision to try loading * @firmware_name: composite filename of ucode file to load - * @init_evtlog_ptr: event log offset for init ucode. - * @init_evtlog_size: event log size for init ucode. - * @init_errlog_ptr: error log offfset for init ucode. - * @inst_evtlog_ptr: event log offset for runtime ucode. - * @inst_evtlog_size: event log size for runtime ucode. - * @inst_errlog_ptr: error log offfset for runtime ucode. * @request_firmware_complete: the firmware has been obtained from user space */ struct iwl_nic { @@ -90,9 +83,6 @@ struct iwl_nic { int fw_index; /* firmware we're trying to load */ char firmware_name[25]; /* name of firmware file to load */ - u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; - u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; - struct completion request_firmware_complete; }; #endif /* __iwl_wifi_h__ */ -- GitLab From 965974a631756ab2729469b9ecadfe61ee44dfc5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:38 -0800 Subject: [PATCH 1529/1846] iwlwifi: remove iwl-wifi.h This file was recently introduced, but then directly abused -- it contained private data that shouldn't have been used by anything but the implementation of firmware requests and some very core code. Now that it is no longer accessed by any code but the code in iwl-drv.c, we can dissolve it. Also rename the iwl_nic struct to iwl_drv to better reflect where and how it is used. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 1 - drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 1 - drivers/net/wireless/iwlwifi/iwl-agn.c | 1 - drivers/net/wireless/iwlwifi/iwl-core.c | 1 - drivers/net/wireless/iwlwifi/iwl-debugfs.c | 1 - drivers/net/wireless/iwlwifi/iwl-drv.c | 272 ++++++++++-------- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 1 - drivers/net/wireless/iwlwifi/iwl-shared.h | 2 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 1 - .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 1 - drivers/net/wireless/iwlwifi/iwl-ucode.c | 1 - drivers/net/wireless/iwlwifi/iwl-wifi.h | 88 ------ 12 files changed, 148 insertions(+), 223 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-wifi.h diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 4928f6f52bf1..588d107b82f4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -68,7 +68,6 @@ #include "iwl-agn-calib.h" #include "iwl-trans.h" #include "iwl-agn.h" -#include "iwl-wifi.h" /***************************************************************************** * INIT calibrations framework diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 89be05615dd9..b06283282283 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -32,7 +32,6 @@ #include #include -#include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-io.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index c3040ad86e89..cdfe76151072 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -42,7 +42,6 @@ #include #include "iwl-eeprom.h" -#include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-io.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index c5df3e3d975b..9ae17c3bb885 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -41,7 +41,6 @@ #include "iwl-shared.h" #include "iwl-agn.h" #include "iwl-trans.h" -#include "iwl-wifi.h" const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 0e63cb70c713..bc3e267ed4c0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -40,7 +40,6 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-agn.h" -#include "iwl-wifi.h" /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 351b2f908383..f1beeab1e601 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -67,36 +67,58 @@ #include "iwl-drv.h" #include "iwl-trans.h" -#include "iwl-wifi.h" #include "iwl-shared.h" #include "iwl-op-mode.h" /* private includes */ #include "iwl-ucode.h" -static void iwl_free_fw_desc(struct iwl_nic *nic, struct fw_desc *desc) +/** + * struct iwl_drv - drv common data + * @fw: the iwl_fw structure + * @shrd: pointer to common shared structure + * @op_mode: the running op_mode + * @fw_index: firmware revision to try loading + * @firmware_name: composite filename of ucode file to load + * @request_firmware_complete: the firmware has been obtained from user space + */ +struct iwl_drv { + struct iwl_fw fw; + + struct iwl_shared *shrd; + struct iwl_op_mode *op_mode; + + int fw_index; /* firmware we're trying to load */ + char firmware_name[25]; /* name of firmware file to load */ + + struct completion request_firmware_complete; +}; + + + +static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) { if (desc->v_addr) - dma_free_coherent(trans(nic)->dev, desc->len, + dma_free_coherent(trans(drv)->dev, desc->len, desc->v_addr, desc->p_addr); desc->v_addr = NULL; desc->len = 0; } -static void iwl_free_fw_img(struct iwl_nic *nic, struct fw_img *img) +static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img) { - iwl_free_fw_desc(nic, &img->code); - iwl_free_fw_desc(nic, &img->data); + iwl_free_fw_desc(drv, &img->code); + iwl_free_fw_desc(drv, &img->data); } -static void iwl_dealloc_ucode(struct iwl_nic *nic) +static void iwl_dealloc_ucode(struct iwl_drv *drv) { - iwl_free_fw_img(nic, &nic->fw.ucode_rt); - iwl_free_fw_img(nic, &nic->fw.ucode_init); - iwl_free_fw_img(nic, &nic->fw.ucode_wowlan); + iwl_free_fw_img(drv, &drv->fw.ucode_rt); + iwl_free_fw_img(drv, &drv->fw.ucode_init); + iwl_free_fw_img(drv, &drv->fw.ucode_wowlan); } -static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc, +static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, const void *data, size_t len) { if (!len) { @@ -104,7 +126,7 @@ static int iwl_alloc_fw_desc(struct iwl_nic *nic, struct fw_desc *desc, return -EINVAL; } - desc->v_addr = dma_alloc_coherent(trans(nic)->dev, len, + desc->v_addr = dma_alloc_coherent(trans(drv)->dev, len, &desc->p_addr, GFP_KERNEL); if (!desc->v_addr) return -ENOMEM; @@ -119,40 +141,40 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); #define UCODE_EXPERIMENTAL_INDEX 100 #define UCODE_EXPERIMENTAL_TAG "exp" -static int iwl_request_firmware(struct iwl_nic *nic, bool first) +static int iwl_request_firmware(struct iwl_drv *drv, bool first) { - const struct iwl_cfg *cfg = cfg(nic); + const struct iwl_cfg *cfg = cfg(drv); const char *name_pre = cfg->fw_name_pre; char tag[8]; if (first) { #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE - nic->fw_index = UCODE_EXPERIMENTAL_INDEX; + drv->fw_index = UCODE_EXPERIMENTAL_INDEX; strcpy(tag, UCODE_EXPERIMENTAL_TAG); - } else if (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) { + } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { #endif - nic->fw_index = cfg->ucode_api_max; - sprintf(tag, "%d", nic->fw_index); + drv->fw_index = cfg->ucode_api_max; + sprintf(tag, "%d", drv->fw_index); } else { - nic->fw_index--; - sprintf(tag, "%d", nic->fw_index); + drv->fw_index--; + sprintf(tag, "%d", drv->fw_index); } - if (nic->fw_index < cfg->ucode_api_min) { - IWL_ERR(nic, "no suitable firmware found!\n"); + if (drv->fw_index < cfg->ucode_api_min) { + IWL_ERR(drv, "no suitable firmware found!\n"); return -ENOENT; } - sprintf(nic->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IWL_DEBUG_INFO(nic, "attempting to load firmware %s'%s'\n", - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n", + (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) ? "EXPERIMENTAL " : "", - nic->firmware_name); + drv->firmware_name); - return request_firmware_nowait(THIS_MODULE, 1, nic->firmware_name, - trans(nic)->dev, - GFP_KERNEL, nic, iwl_ucode_callback); + return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, + trans(drv)->dev, + GFP_KERNEL, drv, iwl_ucode_callback); } struct iwlagn_firmware_pieces { @@ -164,7 +186,7 @@ struct iwlagn_firmware_pieces { u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; }; -static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, +static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, const struct firmware *ucode_raw, struct iwlagn_firmware_pieces *pieces) { @@ -173,14 +195,14 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, char buildstr[25]; const u8 *src; - nic->fw.ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IWL_UCODE_API(nic->fw.ucode_ver); + drv->fw.ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IWL_UCODE_API(drv->fw.ucode_ver); switch (api_ver) { default: hdr_size = 28; if (ucode_raw->size < hdr_size) { - IWL_ERR(nic, "File size too small!\n"); + IWL_ERR(drv, "File size too small!\n"); return -EINVAL; } build = le32_to_cpu(ucode->u.v2.build); @@ -196,7 +218,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IWL_ERR(nic, "File size too small!\n"); + IWL_ERR(drv, "File size too small!\n"); return -EINVAL; } build = 0; @@ -211,18 +233,18 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, if (build) sprintf(buildstr, " build %u%s", build, - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) ? " (EXP)" : ""); else buildstr[0] = '\0'; - snprintf(nic->fw.fw_version, - sizeof(nic->fw.fw_version), + snprintf(drv->fw.fw_version, + sizeof(drv->fw.fw_version), "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(nic->fw.ucode_ver), - IWL_UCODE_MINOR(nic->fw.ucode_ver), - IWL_UCODE_API(nic->fw.ucode_ver), - IWL_UCODE_SERIAL(nic->fw.ucode_ver), + IWL_UCODE_MAJOR(drv->fw.ucode_ver), + IWL_UCODE_MINOR(drv->fw.ucode_ver), + IWL_UCODE_API(drv->fw.ucode_ver), + IWL_UCODE_SERIAL(drv->fw.ucode_ver), buildstr); /* Verify size of file vs. image size info in file's header */ @@ -230,7 +252,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, pieces->data_size + pieces->init_size + pieces->init_data_size) { - IWL_ERR(nic, + IWL_ERR(drv, "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -248,7 +270,7 @@ static int iwl_parse_v1_v2_firmware(struct iwl_nic *nic, return 0; } -static int iwl_parse_tlv_firmware(struct iwl_nic *nic, +static int iwl_parse_tlv_firmware(struct iwl_drv *drv, const struct firmware *ucode_raw, struct iwlagn_firmware_pieces *pieces, struct iwl_ucode_capabilities *capa) @@ -267,12 +289,12 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, u32 build; if (len < sizeof(*ucode)) { - IWL_ERR(nic, "uCode has invalid length: %zd\n", len); + IWL_ERR(drv, "uCode has invalid length: %zd\n", len); return -EINVAL; } if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { - IWL_ERR(nic, "invalid uCode magic: 0X%x\n", + IWL_ERR(drv, "invalid uCode magic: 0X%x\n", le32_to_cpu(ucode->magic)); return -EINVAL; } @@ -290,27 +312,27 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) wanted_alternative--; if (wanted_alternative && wanted_alternative != tmp) - IWL_WARN(nic, + IWL_WARN(drv, "uCode alternative %d not available, choosing %d\n", tmp, wanted_alternative); - nic->fw.ucode_ver = le32_to_cpu(ucode->ver); + drv->fw.ucode_ver = le32_to_cpu(ucode->ver); build = le32_to_cpu(ucode->build); if (build) sprintf(buildstr, " build %u%s", build, - (nic->fw_index == UCODE_EXPERIMENTAL_INDEX) + (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) ? " (EXP)" : ""); else buildstr[0] = '\0'; - snprintf(nic->fw.fw_version, - sizeof(nic->fw.fw_version), + snprintf(drv->fw.fw_version, + sizeof(drv->fw.fw_version), "%u.%u.%u.%u%s", - IWL_UCODE_MAJOR(nic->fw.ucode_ver), - IWL_UCODE_MINOR(nic->fw.ucode_ver), - IWL_UCODE_API(nic->fw.ucode_ver), - IWL_UCODE_SERIAL(nic->fw.ucode_ver), + IWL_UCODE_MAJOR(drv->fw.ucode_ver), + IWL_UCODE_MINOR(drv->fw.ucode_ver), + IWL_UCODE_API(drv->fw.ucode_ver), + IWL_UCODE_SERIAL(drv->fw.ucode_ver), buildstr); data = ucode->data; @@ -329,7 +351,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, tlv_data = tlv->data; if (len < tlv_len) { - IWL_ERR(nic, "invalid TLV len: %zd/%u\n", + IWL_ERR(drv, "invalid TLV len: %zd/%u\n", len, tlv_len); return -EINVAL; } @@ -362,7 +384,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, pieces->init_data_size = tlv_len; break; case IWL_UCODE_TLV_BOOT: - IWL_ERR(nic, "Found unexpected BOOT ucode\n"); + IWL_ERR(drv, "Found unexpected BOOT ucode\n"); break; case IWL_UCODE_TLV_PROBE_MAX_LEN: if (tlv_len != sizeof(u32)) @@ -430,7 +452,7 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, case IWL_UCODE_TLV_ENHANCE_SENS_TBL: if (tlv_len) goto invalid_tlv_len; - nic->fw.enhance_sensitivity_table = true; + drv->fw.enhance_sensitivity_table = true; break; case IWL_UCODE_TLV_WOWLAN_INST: pieces->wowlan_inst = tlv_data; @@ -447,22 +469,22 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, le32_to_cpup((__le32 *)tlv_data); break; default: - IWL_DEBUG_INFO(nic, "unknown TLV: %d\n", tlv_type); + IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type); break; } } if (len) { - IWL_ERR(nic, "invalid TLV after parsing: %zd\n", len); - iwl_print_hex_dump(nic, IWL_DL_FW, (u8 *)data, len); + IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len); + iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len); return -EINVAL; } return 0; invalid_tlv_len: - IWL_ERR(nic, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); - iwl_print_hex_dump(nic, IWL_DL_FW, tlv_data, tlv_len); + IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); + iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len); return -EINVAL; } @@ -475,9 +497,9 @@ static int iwl_parse_tlv_firmware(struct iwl_nic *nic, */ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) { - struct iwl_nic *nic = context; - const struct iwl_cfg *cfg = cfg(nic); - struct iwl_fw *fw = &nic->fw; + struct iwl_drv *drv = context; + const struct iwl_cfg *cfg = cfg(drv); + struct iwl_fw *fw = &drv->fw; struct iwl_ucode_header *ucode; int err; struct iwlagn_firmware_pieces pieces; @@ -496,19 +518,19 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { - if (nic->fw_index <= api_ok) - IWL_ERR(nic, + if (drv->fw_index <= api_ok) + IWL_ERR(drv, "request for firmware file '%s' failed.\n", - nic->firmware_name); + drv->firmware_name); goto try_again; } - IWL_DEBUG_INFO(nic, "Loaded firmware file '%s' (%zd bytes).\n", - nic->firmware_name, ucode_raw->size); + IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n", + drv->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IWL_ERR(nic, "File size way too small!\n"); + IWL_ERR(drv, "File size way too small!\n"); goto try_again; } @@ -516,15 +538,15 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) ucode = (struct iwl_ucode_header *)ucode_raw->data; if (ucode->ver) - err = iwl_parse_v1_v2_firmware(nic, ucode_raw, &pieces); + err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces); else - err = iwl_parse_tlv_firmware(nic, ucode_raw, &pieces, + err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces, &fw->ucode_capa); if (err) goto try_again; - api_ver = IWL_UCODE_API(nic->fw.ucode_ver); + api_ver = IWL_UCODE_API(drv->fw.ucode_ver); /* * api_ver should match the api version forming part of the @@ -532,9 +554,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ /* no api version check required for experimental uCode */ - if (nic->fw_index != UCODE_EXPERIMENTAL_INDEX) { + if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) { if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(nic, + IWL_ERR(drv, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -543,19 +565,19 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (api_ver < api_ok) { if (api_ok != api_max) - IWL_ERR(nic, "Firmware has old API version, " + IWL_ERR(drv, "Firmware has old API version, " "expected v%u through v%u, got v%u.\n", api_ok, api_max, api_ver); else - IWL_ERR(nic, "Firmware has old API version, " + IWL_ERR(drv, "Firmware has old API version, " "expected v%u, got v%u.\n", api_max, api_ver); - IWL_ERR(nic, "New firmware can be obtained from " + IWL_ERR(drv, "New firmware can be obtained from " "http://www.intellinuxwireless.org/.\n"); } } - IWL_INFO(nic, "loaded firmware version %s", nic->fw.fw_version); + IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version); /* * For any of the failures below (before allocating pci memory) @@ -563,38 +585,38 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IWL_DEBUG_INFO(nic, "f/w package hdr ucode version raw = 0x%x\n", - nic->fw.ucode_ver); - IWL_DEBUG_INFO(nic, "f/w package hdr runtime inst size = %Zd\n", + IWL_DEBUG_INFO(drv, "f/w package hdr ucode version raw = 0x%x\n", + drv->fw.ucode_ver); + IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IWL_DEBUG_INFO(nic, "f/w package hdr runtime data size = %Zd\n", + IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IWL_DEBUG_INFO(nic, "f/w package hdr init inst size = %Zd\n", + IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", pieces.init_size); - IWL_DEBUG_INFO(nic, "f/w package hdr init data size = %Zd\n", + IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", pieces.init_data_size); /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > cfg->max_inst_size) { - IWL_ERR(nic, "uCode instr len %Zd too large to fit in\n", + IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } if (pieces.data_size > cfg->max_data_size) { - IWL_ERR(nic, "uCode data len %Zd too large to fit in\n", + IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } if (pieces.init_size > cfg->max_inst_size) { - IWL_ERR(nic, "uCode init instr len %Zd too large to fit in\n", + IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } if (pieces.init_data_size > cfg->max_data_size) { - IWL_ERR(nic, "uCode init data len %Zd too large to fit in\n", + IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } @@ -604,34 +626,34 @@ static void iwl_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 */ - if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.code, + if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic, &nic->fw.ucode_rt.data, + if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_init.code, + if (iwl_alloc_fw_desc(drv, + &drv->fw.ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_init.data, + if (iwl_alloc_fw_desc(drv, + &drv->fw.ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; } /* WoWLAN instructions and data */ if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_wowlan.code, + if (iwl_alloc_fw_desc(drv, + &drv->fw.ucode_wowlan.code, pieces.wowlan_inst, pieces.wowlan_inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(nic, - &nic->fw.ucode_wowlan.data, + if (iwl_alloc_fw_desc(drv, + &drv->fw.ucode_wowlan.data, pieces.wowlan_data, pieces.wowlan_data_size)) goto err_pci_alloc; @@ -670,11 +692,11 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); - complete(&nic->request_firmware_complete); + complete(&drv->request_firmware_complete); - nic->op_mode = iwl_dvm_ops.start(nic->shrd->trans, &nic->fw); + drv->op_mode = iwl_dvm_ops.start(drv->shrd->trans, &drv->fw); - if (!nic->op_mode) + if (!drv->op_mode) goto out_unbind; return; @@ -682,43 +704,43 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) try_again: /* try next, if any */ release_firmware(ucode_raw); - if (iwl_request_firmware(nic, false)) + if (iwl_request_firmware(drv, false)) goto out_unbind; return; err_pci_alloc: - IWL_ERR(nic, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(nic); + IWL_ERR(drv, "failed to allocate pci memory\n"); + iwl_dealloc_ucode(drv); release_firmware(ucode_raw); out_unbind: - complete(&nic->request_firmware_complete); - device_release_driver(trans(nic)->dev); + complete(&drv->request_firmware_complete); + device_release_driver(trans(drv)->dev); } int iwl_drv_start(struct iwl_shared *shrd, struct iwl_trans *trans, const struct iwl_cfg *cfg) { - struct iwl_nic *nic; + struct iwl_drv *drv; int ret; shrd->cfg = cfg; - nic = kzalloc(sizeof(*nic), GFP_KERNEL); - if (!nic) { - dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_nic"); + drv = kzalloc(sizeof(*drv), GFP_KERNEL); + if (!drv) { + dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_drv"); return -ENOMEM; } - nic->shrd = shrd; - shrd->nic = nic; + drv->shrd = shrd; + shrd->drv = drv; - init_completion(&nic->request_firmware_complete); + init_completion(&drv->request_firmware_complete); - ret = iwl_request_firmware(nic, true); + ret = iwl_request_firmware(drv, true); if (ret) { dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw"); - kfree(nic); - shrd->nic = NULL; + kfree(drv); + shrd->drv = NULL; } return ret; @@ -726,16 +748,16 @@ int iwl_drv_start(struct iwl_shared *shrd, void iwl_drv_stop(struct iwl_shared *shrd) { - struct iwl_nic *nic = shrd->nic; + struct iwl_drv *drv = shrd->drv; - wait_for_completion(&nic->request_firmware_complete); + wait_for_completion(&drv->request_firmware_complete); /* op_mode can be NULL if its start failed */ - if (nic->op_mode) - iwl_op_mode_stop(nic->op_mode); + if (drv->op_mode) + iwl_op_mode_stop(drv->op_mode); - iwl_dealloc_ucode(nic); + iwl_dealloc_ucode(drv); - kfree(nic); - shrd->nic = NULL; + kfree(drv); + shrd->drv = NULL; } diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 3bcd2a766074..3c9a8faba4e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -43,7 +43,6 @@ #include #include "iwl-eeprom.h" -#include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-io.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 3754c35a1a50..bb34766609db 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -419,7 +419,7 @@ struct iwl_shared { const struct iwl_cfg *cfg; struct iwl_priv *priv; struct iwl_trans *trans; - void *nic; + void *drv; struct iwl_hw_params hw_params; const struct iwl_fw *fw; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index fd25dd1d62e0..c1ecf0fba372 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -70,7 +70,6 @@ #include #include -#include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-debug.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 69e4544afe24..c3c2de3b3169 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -34,7 +34,6 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-trans-pcie-int.h" -#include "iwl-wifi.h" #include "iwl-op-mode.h" #ifdef CONFIG_IWLWIFI_IDI diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index f78b1552ef7c..3747edb7c292 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -31,7 +31,6 @@ #include #include -#include "iwl-wifi.h" #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-io.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h deleted file mode 100644 index a71624d3ea23..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-wifi.h +++ /dev/null @@ -1,88 +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 - 2012 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 - 2012 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 __iwl_wifi_h__ -#define __iwl_wifi_h__ - -#include "iwl-shared.h" - -/** - * struct iwl_nic - nic common data - * @fw: the iwl_fw structure - * @shrd: pointer to common shared structure - * @op_mode: the running op_mode - * @fw_index: firmware revision to try loading - * @firmware_name: composite filename of ucode file to load - * @request_firmware_complete: the firmware has been obtained from user space - */ -struct iwl_nic { - struct iwl_fw fw; - - struct iwl_shared *shrd; - struct iwl_op_mode *op_mode; - - int fw_index; /* firmware we're trying to load */ - char firmware_name[25]; /* name of firmware file to load */ - - struct completion request_firmware_complete; -}; -#endif /* __iwl_wifi_h__ */ -- GitLab From e10a0533a9172471b52bd9512838d766420a3baf Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:39 -0800 Subject: [PATCH 1530/1846] iwlwifi: add wrappers for command sending Add wrappers to send commands from the DVM op-mode (which essentially consists of the current driver). This will allow us to move specific sanity checks there. Also, this removes iwl_trans_send_cmd_pdu() since that can now be taken care of in the DVM-specific wrapper. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/Makefile | 1 - drivers/net/wireless/iwlwifi/iwl-5000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-6000.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 8 +- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 38 +++++++--- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 16 ++-- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 8 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 10 +-- drivers/net/wireless/iwlwifi/iwl-agn.h | 5 ++ drivers/net/wireless/iwlwifi/iwl-core.c | 10 +-- drivers/net/wireless/iwlwifi/iwl-led.c | 2 +- drivers/net/wireless/iwlwifi/iwl-power.c | 2 +- drivers/net/wireless/iwlwifi/iwl-scan.c | 4 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans.c | 77 -------------------- drivers/net/wireless/iwlwifi/iwl-trans.h | 3 - drivers/net/wireless/iwlwifi/iwl-ucode.c | 8 +- 17 files changed, 70 insertions(+), 128 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-trans.c diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index afa0bb8f3245..f2a903d01aa9 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -14,7 +14,6 @@ iwlwifi-objs += iwl-1000.o iwlwifi-objs += iwl-2000.o iwlwifi-objs += iwl-pci.o iwlwifi-objs += iwl-drv.o -iwlwifi-objs += iwl-trans.o iwlwifi-objs += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index dff75a09eb48..aebdfd7e01a5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -281,7 +281,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv, return -EFAULT; } - return iwl_trans_send_cmd(trans(priv), &hcmd); + return iwl_dvm_send_cmd(priv, &hcmd); } static struct iwl_lib_ops iwl5000_lib = { diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index ef896630625d..150bef078609 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -232,7 +232,7 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv, return -EFAULT; } - return iwl_trans_send_cmd(trans(priv), &hcmd); + return iwl_dvm_send_cmd(priv, &hcmd); } static struct iwl_lib_ops iwl6000_lib = { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 588d107b82f4..579679edd5f1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -104,7 +104,7 @@ int iwl_send_calib_results(struct iwl_priv *priv) 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_dvm_send_cmd(priv, &hcmd); if (ret) { IWL_ERR(priv, "Error %d on calib cmd %d\n", ret, res->hdr.op_code); @@ -500,7 +500,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv) memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), sizeof(u16)*HD_TABLE_SIZE); - return iwl_trans_send_cmd(trans(priv), &cmd_out); + return iwl_dvm_send_cmd(priv, &cmd_out); } /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ @@ -589,7 +589,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv) &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]), sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES); - return iwl_trans_send_cmd(trans(priv), &cmd_out); + return iwl_dvm_send_cmd(priv, &cmd_out); } void iwl_init_sensitivity(struct iwl_priv *priv) @@ -930,7 +930,7 @@ static void iwlagn_gain_computation(struct iwl_priv *priv, priv->phy_calib_chain_noise_gain_cmd); cmd.delta_gain_1 = data->delta_gain_code[1]; cmd.delta_gain_2 = data->delta_gain_code[2]; - iwl_trans_send_cmd_pdu(trans(priv), REPLY_PHY_CALIBRATION_CMD, + iwl_dvm_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, CMD_ASYNC, sizeof(cmd), &cmd); data->radio_write = 1; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index b06283282283..4c777dfc0db0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -81,7 +81,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv) else tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD; - return iwl_trans_send_cmd_pdu(trans(priv), tx_ant_cfg_cmd, CMD_SYNC, + return iwl_dvm_send_cmd_pdu(priv, tx_ant_cfg_cmd, CMD_SYNC, sizeof(tx_power_cmd), &tx_power_cmd); } @@ -241,7 +241,7 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control) flush_cmd.fifo_control); flush_cmd.flush_control = cpu_to_le16(flush_control); - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_dvm_send_cmd(priv, &cmd); } void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control) @@ -435,12 +435,12 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv) if (cfg(priv)->bt_params->bt_session_2) { memcpy(&bt_cmd_2000.basic, &basic, sizeof(basic)); - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG, + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG, CMD_SYNC, sizeof(bt_cmd_2000), &bt_cmd_2000); } else { memcpy(&bt_cmd_6000.basic, &basic, sizeof(basic)); - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG, + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG, CMD_SYNC, sizeof(bt_cmd_6000), &bt_cmd_6000); } if (ret) @@ -1115,7 +1115,7 @@ int iwlagn_send_patterns(struct iwl_priv *priv, } cmd.data[0] = pattern_cmd; - err = iwl_trans_send_cmd(trans(priv), &cmd); + err = iwl_dvm_send_cmd(priv, &cmd); kfree(pattern_cmd); return err; } @@ -1241,13 +1241,13 @@ int iwlagn_suspend(struct iwl_priv *priv, .len[0] = sizeof(key_data.rsc_tsc), }; - ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); + ret = iwl_dvm_send_cmd(priv, &rsc_tsc_cmd); if (ret) goto out; } if (key_data.use_tkip) { - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WOWLAN_TKIP_PARAMS, CMD_SYNC, sizeof(tkip_cmd), &tkip_cmd); @@ -1263,7 +1263,7 @@ int iwlagn_suspend(struct iwl_priv *priv, kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); kek_kck_cmd.replay_ctr = priv->replay_ctr; - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WOWLAN_KEK_KCK_MATERIAL, CMD_SYNC, sizeof(kek_kck_cmd), &kek_kck_cmd); @@ -1272,12 +1272,12 @@ int iwlagn_suspend(struct iwl_priv *priv, } } - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_D3_CONFIG, CMD_SYNC, sizeof(d3_cfg_cmd), &d3_cfg_cmd); if (ret) goto out; - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WOWLAN_WAKEUP_FILTER, CMD_SYNC, sizeof(wakeup_filter_cmd), &wakeup_filter_cmd); if (ret) @@ -1289,3 +1289,21 @@ int iwlagn_suspend(struct iwl_priv *priv, return ret; } #endif + +int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +{ + return iwl_trans_send_cmd(trans(priv), cmd); +} + +int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id, + u32 flags, u16 len, const void *data) +{ + struct iwl_host_cmd cmd = { + .id = id, + .len = { len, }, + .data = { data, }, + .flags = flags, + }; + + return iwl_dvm_send_cmd(priv, &cmd); +} diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index e806ad82e7e3..53114db9c9c3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -39,7 +39,7 @@ static int iwlagn_disable_bss(struct iwl_priv *priv, int ret; send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd, + ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, sizeof(*send), send); send->filter_flags = old_filter; @@ -66,7 +66,7 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; send->dev_type = RXON_DEV_TYPE_P2P; - ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd, + ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, sizeof(*send), send); send->filter_flags = old_filter; @@ -92,7 +92,7 @@ static int iwlagn_disconn_pan(struct iwl_priv *priv, int ret; send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd, CMD_SYNC, + ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, sizeof(*send), send); send->filter_flags = old_filter; @@ -121,7 +121,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv, ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->qos_cmd, CMD_SYNC, + ret = iwl_dvm_send_cmd_pdu(priv, ctx->qos_cmd, CMD_SYNC, sizeof(struct iwl_qosparam_cmd), &ctx->qos_data.def_qos_parm); if (ret) @@ -180,7 +180,7 @@ static int iwlagn_send_rxon_assoc(struct iwl_priv *priv, ctx->staging.ofdm_ht_triple_stream_basic_rates; rxon_assoc.acquisition_data = ctx->staging.acquisition_data; - ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_assoc_cmd, + ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_assoc_cmd, CMD_ASYNC, sizeof(rxon_assoc), &rxon_assoc); return ret; } @@ -266,7 +266,7 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv, * Associated RXON doesn't clear the station table in uCode, * so we don't need to restore stations etc. after this. */ - ret = iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_cmd, CMD_SYNC, + ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, CMD_SYNC, sizeof(struct iwl_rxon_cmd), &ctx->staging); if (ret) { IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); @@ -385,7 +385,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv) cmd.slots[0].width = cpu_to_le16(slot0); cmd.slots[1].width = cpu_to_le16(slot1); - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WIPAN_PARAMS, CMD_SYNC, + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC, sizeof(cmd), &cmd); if (ret) IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret); @@ -771,7 +771,7 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv) memset(&cmd, 0, sizeof(cmd)); iwl_set_calib_hdr(&cmd.hdr, priv->phy_calib_chain_noise_reset_cmd); - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, CMD_SYNC, sizeof(cmd), &cmd); if (ret) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index ca080265a829..73a25f48cd53 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -153,7 +153,7 @@ int iwl_send_add_sta(struct iwl_priv *priv, might_sleep(); } - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); if (ret || (flags & CMD_ASYNC)) return ret; @@ -447,7 +447,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, cmd.flags |= CMD_WANT_SKB; - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); if (ret) return ret; @@ -785,7 +785,7 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return -EINVAL; if (is_lq_table_valid(priv, ctx, lq)) - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); else ret = -EINVAL; @@ -970,7 +970,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, cmd.len[0] = cmd_size; if (not_empty || send_if_empty) - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_dvm_send_cmd(priv, &cmd); else return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index cdfe76151072..3f59a773b3e0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -197,7 +197,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv) cmd.data[1] = priv->beacon_skb->data; cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY; - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_dvm_send_cmd(priv, &cmd); } static void iwl_bg_beacon_update(struct work_struct *work) @@ -563,7 +563,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv) adv_cmd.critical_temperature_exit = cpu_to_le32(hw_params(priv).ct_kill_exit_threshold); - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, CMD_SYNC, sizeof(adv_cmd), &adv_cmd); if (ret) @@ -578,7 +578,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv) cmd.critical_temperature_R = cpu_to_le32(hw_params(priv).ct_kill_threshold); - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, CMD_SYNC, sizeof(cmd), &cmd); if (ret) @@ -604,7 +604,7 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg) calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_RT_CFG_ALL; calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg); - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_dvm_send_cmd(priv, &cmd); } @@ -616,7 +616,7 @@ static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant) if (IWL_UCODE_API(priv->fw->ucode_ver) > 1) { IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant); - return iwl_trans_send_cmd_pdu(trans(priv), + return iwl_dvm_send_cmd_pdu(priv, TX_ANT_CONFIGURATION_CMD, CMD_SYNC, sizeof(struct iwl_tx_ant_config_cmd), diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index f55243828698..dfd86f288dee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -96,6 +96,11 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, const struct iwl_ucode_capabilities *capa); void iwlagn_mac_unregister(struct iwl_priv *priv); +/* commands */ +int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); +int iwl_dvm_send_cmd_pdu(struct iwl_priv *priv, u8 id, + u32 flags, u16 len, const void *data); + /* RXON */ int iwlagn_set_pan_params(struct iwl_priv *priv); int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 9ae17c3bb885..aaea51ee4185 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -369,7 +369,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) le32_to_cpu(ctx->timing.beacon_init_val), le16_to_cpu(ctx->timing.atim_window)); - return iwl_trans_send_cmd_pdu(trans(priv), ctx->rxon_timing_cmd, + return iwl_dvm_send_cmd_pdu(priv, ctx->rxon_timing_cmd, CMD_SYNC, sizeof(ctx->timing), &ctx->timing); } @@ -958,7 +958,7 @@ void iwl_send_bt_config(struct iwl_priv *priv) IWL_DEBUG_INFO(priv, "BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (iwl_trans_send_cmd_pdu(trans(priv), REPLY_BT_CONFIG, + if (iwl_dvm_send_cmd_pdu(priv, REPLY_BT_CONFIG, CMD_SYNC, sizeof(struct iwl_bt_cmd), &bt_cmd)) IWL_ERR(priv, "failed to send BT Coex Config\n"); } @@ -971,12 +971,12 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD, + return iwl_dvm_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, CMD_ASYNC, sizeof(struct iwl_statistics_cmd), &statistics_cmd); else - return iwl_trans_send_cmd_pdu(trans(priv), REPLY_STATISTICS_CMD, + return iwl_dvm_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, CMD_SYNC, sizeof(struct iwl_statistics_cmd), &statistics_cmd); @@ -1300,7 +1300,7 @@ int iwl_cmd_echo_test(struct iwl_priv *priv) .flags = CMD_SYNC, }; - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); if (ret) IWL_ERR(priv, "echo testing fail: 0X%x\n", ret); else diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 5c7741f07aa0..f2f706f084a5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -112,7 +112,7 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd) iwl_write32(trans(priv), CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_dvm_send_cmd(priv, &cmd); } /* Set led pattern command */ diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index 1ef3c4da1605..46ca82062c2e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -336,7 +336,7 @@ static int iwl_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_trans_send_cmd_pdu(trans(priv), POWER_TABLE_CMD, CMD_SYNC, + return iwl_dvm_send_cmd_pdu(priv, POWER_TABLE_CMD, CMD_SYNC, sizeof(struct iwl_powertable_cmd), cmd); } diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 28899dabe6fb..dcba74883307 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -72,7 +72,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) test_bit(STATUS_FW_ERROR, &priv->shrd->status)) return -EIO; - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); if (ret) return ret; @@ -887,7 +887,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) if (ret) return ret; - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); if (ret) { clear_bit(STATUS_SCAN_HW, &priv->shrd->status); iwlagn_set_pan_params(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index c1ecf0fba372..f26765b3a661 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -282,7 +282,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) IWL_DEBUG_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," " len %d\n", cmd.id, cmd.flags, cmd.len[0]); - ret = iwl_trans_send_cmd(trans(priv), &cmd); + ret = iwl_dvm_send_cmd(priv, &cmd); if (ret) { IWL_ERR(priv, "Failed to send hcmd\n"); return ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c deleted file mode 100644 index 506c062343b2..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-trans.c +++ /dev/null @@ -1,77 +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) 2007 - 2012 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 - 2012 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 "iwl-trans.h" - -int iwl_trans_send_cmd_pdu(struct iwl_trans *trans, u8 id, - u32 flags, u16 len, const void *data) -{ - struct iwl_host_cmd cmd = { - .id = id, - .len = { len, }, - .data = { data, }, - .flags = flags, - }; - - return iwl_trans_send_cmd(trans, &cmd); -} diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index ec5249c8a7f4..a8d476a44c58 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -443,9 +443,6 @@ static inline int iwl_trans_send_cmd(struct iwl_trans *trans, return trans->ops->send_cmd(trans, cmd); } -int iwl_trans_send_cmd_pdu(struct iwl_trans *trans, u8 id, - u32 flags, u16 len, const void *data); - static inline int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb, struct iwl_device_cmd *dev_cmd, enum iwl_rxon_context_id ctx, u8 sta_id, u8 tid) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 3747edb7c292..1cbe8e9926f1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -179,7 +179,7 @@ static int iwl_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_dvm_send_cmd(priv, &cmd); } int iwlagn_rx_calib_result(struct iwl_priv *priv, @@ -260,7 +260,7 @@ static int iwl_send_wimax_coex(struct iwl_priv *priv) /* coexistence is disabled */ memset(&coex_cmd, 0, sizeof(coex_cmd)); } - return iwl_trans_send_cmd_pdu(trans(priv), + return iwl_dvm_send_cmd_pdu(priv, COEX_PRIORITY_TABLE_CMD, CMD_SYNC, sizeof(coex_cmd), &coex_cmd); } @@ -293,7 +293,7 @@ void iwl_send_prio_tbl(struct iwl_priv *priv) memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl, sizeof(iwl_bt_prio_tbl)); - if (iwl_trans_send_cmd_pdu(trans(priv), + if (iwl_dvm_send_cmd_pdu(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"); @@ -306,7 +306,7 @@ int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) env_cmd.action = action; env_cmd.type = type; - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_dvm_send_cmd_pdu(priv, REPLY_BT_COEX_PROT_ENV, CMD_SYNC, sizeof(env_cmd), &env_cmd); if (ret) -- GitLab From 721c32f72d8007dc0148ee88c046a4ade794a7b7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:40 -0800 Subject: [PATCH 1531/1846] iwlwifi: move RF/CT kill check to command wrapper Currently, we cannot send any commands when the uCode is in RF or CT kill, but that will not be true for all new uCode versions, so we need to move the check into the uCode specific code. Also remove the duplicate rfkill check. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 6 ++++++ .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 19 ++++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 4c777dfc0db0..11f24110d3fe 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1292,6 +1292,12 @@ int iwlagn_suspend(struct iwl_priv *priv, int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) { + if (iwl_is_rfkill(priv->shrd) || iwl_is_ctkill(priv->shrd)) { + IWL_WARN(priv, "Not sending command - %s KILL\n", + iwl_is_rfkill(priv->shrd) ? "RF" : "CT"); + return -EIO; + } + return iwl_trans_send_cmd(trans(priv), cmd); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 0164154f9c97..c85975e63d75 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -721,12 +721,6 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) if (WARN_ON(copy_size > TFD_MAX_PAYLOAD_SIZE)) return -EINVAL; - if (iwl_is_rfkill(trans->shrd) || iwl_is_ctkill(trans->shrd)) { - IWL_WARN(trans, "Not sending command - %s KILL\n", - iwl_is_rfkill(trans->shrd) ? "RF" : "CT"); - return -EIO; - } - spin_lock_bh(&txq->lock); if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { @@ -965,7 +959,7 @@ static int iwl_send_cmd_async(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ret = iwl_enqueue_hcmd(trans, cmd); if (ret < 0) { - IWL_DEBUG_QUIET_RFKILL(trans, + IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", get_cmd_string(cmd->id), ret); return ret; @@ -984,11 +978,6 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", get_cmd_string(cmd->id)); - if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { - IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", - get_cmd_string(cmd->id)); - return -ECANCELED; - } if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { IWL_ERR(trans, "Command %s failed: FW Error\n", get_cmd_string(cmd->id)); @@ -1002,7 +991,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) if (cmd_idx < 0) { ret = cmd_idx; clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); - IWL_DEBUG_QUIET_RFKILL(trans, + IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", get_cmd_string(cmd->id), ret); return ret; @@ -1017,12 +1006,12 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) &trans_pcie->txq[trans->shrd->cmd_queue]; struct iwl_queue *q = &txq->q; - IWL_DEBUG_QUIET_RFKILL(trans, + IWL_ERR(trans, "Error sending %s: time out after %dms.\n", get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - IWL_DEBUG_QUIET_RFKILL(trans, + IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", q->read_ptr, q->write_ptr); -- GitLab From 2cc39c94c15ba1d5f6f71ab73f3369f9c17856ad Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:41 -0800 Subject: [PATCH 1532/1846] iwlwifi: move lockdep assertion into DVM The fact that the mutex must be held is an implementation detail of DVM, but something has to ensure that no two synchronous cmds are submitted concurrently. Move the lockdep assertion into the DVM-specific code, but also make the transport abort if there are two concurrently commands. The assertion is much more useful though as the transport check can only catch it when it actually happens, while the assertion makes sure it can't possibly happen. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 8 ++++++++ drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 11f24110d3fe..238f824c2f3e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1298,6 +1298,14 @@ int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) return -EIO; } + /* + * Synchronous commands from this op-mode must hold + * the mutex, this ensures we don't try to send two + * (or more) synchronous commands at a time. + */ + if (cmd->flags & CMD_SYNC) + lockdep_assert_held(&priv->shrd->mutex); + return iwl_trans_send_cmd(trans(priv), cmd); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index c85975e63d75..ca4ceeacc989 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -973,8 +973,6 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) int cmd_idx; int ret; - lockdep_assert_held(&trans->shrd->mutex); - IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", get_cmd_string(cmd->id)); @@ -983,7 +981,14 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) get_cmd_string(cmd->id)); return -EIO; } - set_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); + + if (WARN_ON(test_and_set_bit(STATUS_HCMD_ACTIVE, + &trans->shrd->status))) { + IWL_ERR(trans, "Command %s: a command is already active!\n", + get_cmd_string(cmd->id)); + return -EIO; + } + IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", get_cmd_string(cmd->id)); -- GitLab From b1eea297d6b522b801c95b60b1e64fb61228c6c7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:42 -0800 Subject: [PATCH 1533/1846] iwlwifi: move mutex out of shared Now the mutex no longer needs to be shared, so move it into iwl_priv. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 20 ++--- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 20 ++--- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 18 ++--- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 8 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 32 ++++---- drivers/net/wireless/iwlwifi/iwl-core.c | 4 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 12 +-- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 + drivers/net/wireless/iwlwifi/iwl-mac80211.c | 82 ++++++++++----------- drivers/net/wireless/iwlwifi/iwl-power.c | 2 +- drivers/net/wireless/iwlwifi/iwl-scan.c | 32 ++++---- drivers/net/wireless/iwlwifi/iwl-shared.h | 4 - drivers/net/wireless/iwlwifi/iwl-testmode.c | 8 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 2 +- 14 files changed, 122 insertions(+), 124 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 238f824c2f3e..90f1f8a506f2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -246,7 +246,7 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control) void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control) { - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); ieee80211_stop_queues(priv->hw); if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { IWL_ERR(priv, "flush request fail\n"); @@ -256,7 +256,7 @@ void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control) iwl_trans_wait_tx_queue_empty(trans(priv)); done: ieee80211_wake_queues(priv->hw); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } /* @@ -453,7 +453,7 @@ void iwlagn_bt_adjust_rssi_monitor(struct iwl_priv *priv, bool rssi_ena) struct iwl_rxon_context *ctx, *found_ctx = NULL; bool found_ap = false; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); /* Check whether AP or GO mode is active. */ if (rssi_ena) { @@ -566,7 +566,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work) break; } - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); /* * We can not send command to firmware while scanning. When the scan @@ -594,7 +594,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work) */ iwlagn_bt_coex_rssi_monitor(priv); out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } /* @@ -969,7 +969,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, u16 p1k[IWLAGN_P1K_SIZE]; int ret, i; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) && @@ -1075,7 +1075,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, break; } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } int iwlagn_send_patterns(struct iwl_priv *priv, @@ -1222,11 +1222,11 @@ int iwlagn_suspend(struct iwl_priv *priv, * constraints. Since we're in the suspend path * that isn't really a problem though. */ - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); ieee80211_iter_keys(priv->hw, ctx->vif, iwlagn_wowlan_program_keys, &key_data); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (key_data.error) { ret = -EIO; goto out; @@ -1304,7 +1304,7 @@ int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) * (or more) synchronous commands at a time. */ if (cmd->flags & CMD_SYNC) - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); return iwl_trans_send_cmd(trans(priv), cmd); } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 53114db9c9c3..2c5e7ec697e9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -131,7 +131,7 @@ static void iwlagn_update_qos(struct iwl_priv *priv, static int iwlagn_update_beacon(struct iwl_priv *priv, struct ieee80211_vif *vif) { - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); dev_kfree_skb(priv->beacon_skb); priv->beacon_skb = ieee80211_beacon_get(priv->hw, vif); @@ -313,7 +313,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv) BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS]; ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN]; @@ -418,7 +418,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (!iwl_is_alive(priv->shrd)) return -EBUSY; @@ -549,7 +549,7 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) IWL_DEBUG_MAC80211(priv, "enter: changed %#x", changed); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); @@ -650,7 +650,7 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) iwlagn_commit_rxon(priv, ctx); } out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return ret; @@ -667,7 +667,7 @@ static void iwlagn_check_needed_chains(struct iwl_priv *priv, struct ieee80211_sta_ht_cap *ht_cap; bool need_multiple; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); switch (vif->type) { case NL80211_IFTYPE_STATION: @@ -792,17 +792,17 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, int ret; bool force = false; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (unlikely(!iwl_is_ready(priv->shrd))) { IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return; } if (unlikely(!ctx->vif)) { IWL_DEBUG_MAC80211(priv, "leave - vif is NULL\n"); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return; } @@ -931,7 +931,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, IWL_ERR(priv, "Error sending IBSS beacon\n"); } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } void iwlagn_post_scan(struct iwl_priv *priv) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 73a25f48cd53..14fbdecccd26 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -811,7 +811,7 @@ void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u32 rate_flags = 0; __le32 rate_n_flags; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); memset(link_cmd, 0, sizeof(*link_cmd)); @@ -978,7 +978,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, int iwl_restore_default_wep_keys(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); return iwl_send_static_wepkey_cmd(priv, ctx, false); } @@ -989,7 +989,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv, { int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", keyconf->keyidx); @@ -1014,7 +1014,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv, { int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { @@ -1166,7 +1166,7 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, if (sta_id == IWL_INVALID_STATION) return 0; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); ctx->key_mapping_keys--; @@ -1206,7 +1206,7 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, if (sta_id == IWL_INVALID_STATION) return -EINVAL; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); keyconf->hw_key_idx = iwl_get_free_ucode_key_offset(priv); if (keyconf->hw_key_idx == WEP_INVALID_OFFSET) @@ -1340,7 +1340,7 @@ int iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) { struct iwl_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); /* Remove "disable" flag, to enable Tx for this TID */ spin_lock_bh(&priv->sta_lock); @@ -1359,7 +1359,7 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, int sta_id; struct iwl_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); sta_id = iwl_sta_id(sta); if (sta_id == IWL_INVALID_STATION) @@ -1383,7 +1383,7 @@ int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, int sta_id; struct iwl_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); sta_id = iwl_sta_id(sta); if (sta_id == IWL_INVALID_STATION) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index 56d7c0e38163..85fe590ee721 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -310,7 +310,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force) tt->tt_power_mode = IWL_POWER_INDEX_5; break; } - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (old_state == IWL_TI_CT_KILL) clear_bit(STATUS_CT_KILL, &priv->shrd->status); if (tt->state != IWL_TI_CT_KILL && @@ -341,7 +341,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force) IWL_DEBUG_TEMP(priv, "Power Index change to %u\n", tt->tt_power_mode); } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } } @@ -451,7 +451,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) * in case get disabled before */ iwl_set_rxon_ht(priv, &priv->current_ht_config); } - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (old_state == IWL_TI_CT_KILL) clear_bit(STATUS_CT_KILL, &priv->shrd->status); if (tt->state != IWL_TI_CT_KILL && @@ -486,7 +486,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) iwl_perform_ct_kill_task(priv, false); } } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 3f59a773b3e0..863c27e20dbc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -132,7 +132,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv) * beacon contents. */ - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (!priv->beacon_ctx) { IWL_ERR(priv, "trying to build beacon w/o beacon context!\n"); @@ -206,7 +206,7 @@ static void iwl_bg_beacon_update(struct work_struct *work) container_of(work, struct iwl_priv, beacon_update); struct sk_buff *beacon; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (!priv->beacon_ctx) { IWL_ERR(priv, "updating beacon w/o beacon context!\n"); goto out; @@ -236,7 +236,7 @@ static void iwl_bg_beacon_update(struct work_struct *work) iwlagn_send_beacon_cmd(priv); out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } static void iwl_bg_bt_runtime_config(struct work_struct *work) @@ -259,7 +259,7 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work) container_of(work, struct iwl_priv, bt_full_concurrency); struct iwl_rxon_context *ctx; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) goto out; @@ -283,7 +283,7 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work) iwlagn_send_advance_bt_config(priv); out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } /** @@ -774,7 +774,7 @@ void iwl_down(struct iwl_priv *priv) IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); iwl_scan_cancel_timeout(priv, 200); @@ -844,11 +844,11 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, run_time_calib_work); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || test_bit(STATUS_SCANNING, &priv->shrd->status)) { - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return; } @@ -857,7 +857,7 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work) iwl_sensitivity_calibration(priv); } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } void iwlagn_prepare_restart(struct iwl_priv *priv) @@ -869,7 +869,7 @@ void iwlagn_prepare_restart(struct iwl_priv *priv) u8 bt_status; bool bt_is_sco; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); for_each_context(priv, ctx) ctx->vif = NULL; @@ -907,9 +907,9 @@ static void iwl_bg_restart(struct work_struct *data) return; if (test_and_clear_bit(STATUS_FW_ERROR, &priv->shrd->status)) { - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwlagn_prepare_restart(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); iwl_cancel_deferred_work(priv); ieee80211_restart_hw(priv->hw); } else { @@ -924,7 +924,7 @@ void iwlagn_disable_roc(struct iwl_priv *priv) { struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (!priv->hw_roc_setup) return; @@ -947,9 +947,9 @@ static void iwlagn_disable_roc_work(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, hw_roc_disable_work.work); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwlagn_disable_roc(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } /***************************************************************************** @@ -1036,7 +1036,7 @@ static int iwl_init_drv(struct iwl_priv *priv) spin_lock_init(&priv->sta_lock); - mutex_init(&priv->shrd->mutex); + mutex_init(&priv->mutex); INIT_LIST_HEAD(&priv->calib_results); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index aaea51ee4185..387eeeedb41d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -316,7 +316,7 @@ int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) conf = &priv->hw->conf; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); @@ -892,7 +892,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) bool defer; struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (priv->tx_power_user_lmt == tx_power && !force) return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index bc3e267ed4c0..b9b6d628f59a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -761,9 +761,9 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, priv->power_data.debug_sleep_level_override = value; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_power_update_mode(priv, true); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return count; } @@ -1708,9 +1708,9 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, return -EINVAL; /* make request to uCode to retrieve statistics information */ - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); ret = iwl_send_statistics_request(priv, CMD_SYNC, false); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); if (ret) { IWL_ERR(priv, @@ -2106,9 +2106,9 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file, return -EFAULT; /* make request to uCode to retrieve statistics information */ - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_send_statistics_request(priv, CMD_SYNC, true); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return count; } diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 4def9f961891..73acbab6c248 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "iwl-eeprom.h" @@ -718,6 +719,7 @@ struct iwl_priv { const struct iwl_fw *fw; spinlock_t sta_lock; + struct mutex mutex; /* ieee device used by generic ieee processing code */ struct ieee80211_hw *hw; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 3c9a8faba4e6..30861765b512 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -261,7 +261,7 @@ static int __iwl_up(struct iwl_priv *priv) struct iwl_rxon_context *ctx; int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); @@ -310,9 +310,9 @@ static int iwlagn_mac_start(struct ieee80211_hw *hw) IWL_DEBUG_MAC80211(priv, "enter\n"); /* we should be verifying the device is ready to be opened */ - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); ret = __iwl_up(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); if (ret) return ret; @@ -340,9 +340,9 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw) priv->is_open = 0; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_down(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); iwl_cancel_deferred_work(priv); @@ -367,7 +367,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, return; IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) goto out; @@ -379,7 +379,7 @@ static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, priv->have_rekey_data = true; out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); } @@ -396,7 +396,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, return -EINVAL; IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); /* Don't attempt WoWLAN when not associated, tear down instead. */ if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || @@ -420,7 +420,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, iwlagn_prepare_restart(priv); ieee80211_restart_hw(priv->hw); out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return ret; @@ -436,7 +436,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) int ret = -EIO; IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); @@ -481,7 +481,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) iwl_connection_init_rx_config(priv, ctx); iwlagn_set_rxon_chain(priv, ctx); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); ieee80211_resume_disconnect(vif); @@ -559,7 +559,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) return 0; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_scan_cancel_timeout(priv, 100); BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); @@ -610,7 +610,7 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = -EINVAL; } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return ret; @@ -633,7 +633,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, return -EACCES; IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); switch (action) { case IEEE80211_AMPDU_RX_START: @@ -675,7 +675,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, ret = iwlagn_tx_agg_oper(priv, vif, sta, tid, buf_size); break; } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return ret; } @@ -746,7 +746,7 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211(priv, "station %pM state change %d->%d\n", sta->addr, old_state, new_state); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (vif->type == NL80211_IFTYPE_STATION) { if (old_state == IEEE80211_STA_NOTEXIST && new_state == IEEE80211_STA_NONE) @@ -807,7 +807,7 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, if (iwl_is_rfkill(priv->shrd)) ret = 0; - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return ret; @@ -834,7 +834,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (iwl_is_rfkill(priv->shrd)) goto out; @@ -890,7 +890,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, } out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); } @@ -920,7 +920,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw, #undef CHK - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); for_each_context(priv, ctx) { ctx->staging.filter_flags &= ~filter_nand; @@ -932,7 +932,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw, */ } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); /* * Receiving all multicast frames is always enabled by the @@ -948,7 +948,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) { struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "enter\n"); if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { @@ -974,7 +974,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); iwl_trans_wait_tx_queue_empty(trans(priv)); done: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); } @@ -994,7 +994,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, return -EOPNOTSUPP; IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { err = -EBUSY; @@ -1065,7 +1065,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, iwlagn_disable_roc(priv); out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return err; @@ -1079,10 +1079,10 @@ static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) return -EOPNOTSUPP; IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); iwlagn_disable_roc(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return 0; @@ -1094,7 +1094,7 @@ static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (cfg(priv)->bt_params && cfg(priv)->bt_params->advanced_bt_coexist) { @@ -1109,7 +1109,7 @@ static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, "ignoring RSSI callback\n"); } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); } @@ -1149,7 +1149,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, q = AC_NUM - 1 - queue; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); ctx->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); @@ -1161,7 +1161,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return 0; @@ -1189,7 +1189,7 @@ static int iwl_setup_interface(struct iwl_priv *priv, struct ieee80211_vif *vif = ctx->vif; int err; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); /* * This variable will be correct only when there's just @@ -1234,7 +1234,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, cancel_delayed_work_sync(&priv->hw_roc_disable_work); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwlagn_disable_roc(priv); @@ -1281,7 +1281,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, ctx->vif = NULL; priv->iw_mode = NL80211_IFTYPE_STATION; out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return err; @@ -1293,7 +1293,7 @@ static void iwl_teardown_interface(struct iwl_priv *priv, { struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (priv->scan_vif == vif) { iwl_scan_cancel_timeout(priv, 200); @@ -1325,7 +1325,7 @@ static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211(priv, "enter\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (WARN_ON(ctx->vif != vif)) { struct iwl_rxon_context *tmp; @@ -1338,7 +1338,7 @@ static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, iwl_teardown_interface(priv, vif, false); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); @@ -1360,7 +1360,7 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, newtype = ieee80211_iftype_p2p(newtype, newp2p); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { /* @@ -1424,7 +1424,7 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, err = 0; out: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); return err; @@ -1442,7 +1442,7 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, if (req->n_channels == 0) return -EINVAL; - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); /* * If an internal scan is in progress, just set @@ -1471,7 +1471,7 @@ static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211(priv, "leave\n"); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index 46ca82062c2e..d76ff239d5f1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -383,7 +383,7 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, int ret; bool update_chains; - lockdep_assert_held(&priv->shrd->mutex); + 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 || diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index dcba74883307..6cf2cb318882 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -115,7 +115,7 @@ static void iwl_process_scan_complete(struct iwl_priv *priv) { bool aborted; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (!test_and_clear_bit(STATUS_SCAN_COMPLETE, &priv->shrd->status)) return; @@ -172,7 +172,7 @@ static void iwl_process_scan_complete(struct iwl_priv *priv) void iwl_force_scan_end(struct iwl_priv *priv) { - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (!test_bit(STATUS_SCANNING, &priv->shrd->status)) { IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); @@ -191,7 +191,7 @@ static void iwl_do_scan_abort(struct iwl_priv *priv) { int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (!test_bit(STATUS_SCANNING, &priv->shrd->status)) { IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); @@ -230,7 +230,7 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); IWL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); @@ -595,7 +595,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) u8 scan_tx_antennas = hw_params(priv).valid_tx_ant; int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); if (vif) ctx = iwl_rxon_ctx_from_vif(vif); @@ -912,7 +912,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, { int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); cancel_delayed_work(&priv->scan_check); @@ -972,7 +972,7 @@ static void iwl_bg_start_internal_scan(struct work_struct *work) IWL_DEBUG_SCAN(priv, "Start internal scan\n"); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); if (priv->scan_type == IWL_SCAN_RADIO_RESET) { IWL_DEBUG_SCAN(priv, "Internal scan already in progress\n"); @@ -987,7 +987,7 @@ static void iwl_bg_start_internal_scan(struct work_struct *work) if (iwl_scan_initiate(priv, NULL, IWL_SCAN_RADIO_RESET, priv->band)) IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n"); unlock: - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } static void iwl_bg_scan_check(struct work_struct *data) @@ -1000,9 +1000,9 @@ static void iwl_bg_scan_check(struct work_struct *data) /* 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->shrd->mutex); + mutex_lock(&priv->mutex); iwl_force_scan_end(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } /** @@ -1060,9 +1060,9 @@ static void iwl_bg_abort_scan(struct work_struct *work) /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_scan_cancel_timeout(priv, 200); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } static void iwl_bg_scan_completed(struct work_struct *work) @@ -1070,9 +1070,9 @@ static void iwl_bg_scan_completed(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, scan_completed); - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_process_scan_complete(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } void iwl_setup_scan_deferred_work(struct iwl_priv *priv) @@ -1090,8 +1090,8 @@ void iwl_cancel_scan_deferred_work(struct iwl_priv *priv) cancel_work_sync(&priv->scan_completed); if (cancel_delayed_work_sync(&priv->scan_check)) { - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); iwl_force_scan_end(priv); - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index bb34766609db..30b942f77814 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -65,7 +65,6 @@ #include #include -#include #include #include @@ -399,7 +398,6 @@ struct iwl_cfg { * @nic: pointer to the nic data * @hw_params: see struct iwl_hw_params * @lock: protect general shared data - * @mutex: * @wait_command_queue: the wait_queue for SYNC host command nad uCode load * @eeprom: pointer to the eeprom/OTP image * @ucode_type: indicator of loaded ucode image @@ -423,8 +421,6 @@ struct iwl_shared { struct iwl_hw_params hw_params; const struct iwl_fw *fw; - struct mutex mutex; - wait_queue_head_t wait_command_queue; /* eeprom -- this is in the card's little endian byte order */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index f26765b3a661..095d71dc99c4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -975,7 +975,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) return -ENOMSG; } /* in case multiple accesses to the device happens */ - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_UCODE: @@ -1027,7 +1027,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) break; } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return result; } @@ -1062,7 +1062,7 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, } /* in case multiple accesses to the device happens */ - mutex_lock(&priv->shrd->mutex); + mutex_lock(&priv->mutex); switch (cmd) { case IWL_TM_CMD_APP2DEV_READ_TRACE: IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); @@ -1077,6 +1077,6 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, break; } - mutex_unlock(&priv->shrd->mutex); + mutex_unlock(&priv->mutex); return result; } diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 1cbe8e9926f1..c1c5e1f2223a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -599,7 +599,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv) struct iwl_notification_wait calib_wait; int ret; - lockdep_assert_held(&priv->shrd->mutex); + lockdep_assert_held(&priv->mutex); /* No init ucode required? Curious, but maybe ok */ if (!priv->fw->ucode_init.code.len) -- GitLab From c9eec95cb429359efd39a3c87fb1544fe2b77bc5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:43 -0800 Subject: [PATCH 1534/1846] iwlwifi: move rfkill status handling out of transport The transport layer should only check the hardware RF kill status, not impose any policy or reaction based on it, so move that out of it into the op_mode. For now keep the restriction on loading firmware, that will have to be removed later. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.c | 5 +++ .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 24 +++--------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 39 ++++++------------- 3 files changed, 22 insertions(+), 46 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 387eeeedb41d..a2ef78c6af60 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1460,6 +1460,11 @@ void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) { struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + if (state) + set_bit(STATUS_RF_KILL_HW, &priv->shrd->status); + else + clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status); + wiphy_rfkill_set_hw_state(priv->hw->wiphy, state); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index c3c2de3b3169..e8d3129d5bde 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1016,30 +1016,16 @@ void iwl_irq_tasklet(struct iwl_trans *trans) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { - int hw_rf_kill = 0; - if (!(iwl_read32(trans, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) - hw_rf_kill = 1; + bool hw_rfkill; + hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); IWL_WARN(trans, "RF_KILL bit toggled to %s.\n", - hw_rf_kill ? "disable radio" : "enable radio"); + hw_rfkill ? "disable radio" : "enable radio"); 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, &trans->shrd->status)) { - if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, - &trans->shrd->status); - else - clear_bit(STATUS_RF_KILL_HW, - &trans->shrd->status); - iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rf_kill); - } + iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); handled |= CSR_INT_BIT_RF_KILL; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index d7dbd80eb108..4a05216242a9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1021,6 +1021,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, int ret; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + bool hw_rfkill; trans->shrd->ucode_owner = IWL_OWNERSHIP_DRIVER; trans_pcie->ac_to_queue[IWL_RXON_CTX_BSS] = iwlagn_bss_ac_to_queue; @@ -1039,14 +1040,11 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, } /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(trans, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - else - set_bit(STATUS_RF_KILL_HW, &trans->shrd->status); + hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); - if (iwl_is_rfkill(trans->shrd)) { - iwl_op_mode_hw_rf_kill(trans->op_mode, true); + if (hw_rfkill) { iwl_enable_interrupts(trans); return -ERFKILL; } @@ -1506,6 +1504,7 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); int err; + bool hw_rfkill; trans_pcie->inta_mask = CSR_INI_SET_MASK; @@ -1535,16 +1534,9 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) iwl_apm_init(trans); - /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(trans, - CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - else - set_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - - iwl_op_mode_hw_rf_kill(trans->op_mode, - test_bit(STATUS_RF_KILL_HW, - &trans->shrd->status)); + hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); return err; @@ -1659,19 +1651,12 @@ static int iwl_trans_pcie_suspend(struct iwl_trans *trans) static int iwl_trans_pcie_resume(struct iwl_trans *trans) { - bool hw_rfkill = false; + bool hw_rfkill; iwl_enable_interrupts(trans); - if (!(iwl_read32(trans, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) - hw_rfkill = true; - - if (hw_rfkill) - set_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - else - clear_bit(STATUS_RF_KILL_HW, &trans->shrd->status); - + hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); return 0; -- GitLab From 3995deafdae1b802a117b3d6d18bc9e5ce3d1340 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:44 -0800 Subject: [PATCH 1535/1846] iwlwifi: rename ucode.h to fw-file.h That name better reflects the contents of the file and the fact that it isn't related to iwl-ucode.c. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-drv.c | 2 +- drivers/net/wireless/iwlwifi/{iwl-ucode.h => iwl-fw-file.h} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename drivers/net/wireless/iwlwifi/{iwl-ucode.h => iwl-fw-file.h} (98%) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index f1beeab1e601..29a3ae48df6d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -71,7 +71,7 @@ #include "iwl-op-mode.h" /* private includes */ -#include "iwl-ucode.h" +#include "iwl-fw-file.h" /** * struct iwl_drv - drv common data diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.h b/drivers/net/wireless/iwlwifi/iwl-fw-file.h similarity index 98% rename from drivers/net/wireless/iwlwifi/iwl-ucode.h rename to drivers/net/wireless/iwlwifi/iwl-fw-file.h index cdab28784404..7ca6c9526357 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw-file.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_ucode_h__ -#define __iwl_ucode_h__ +#ifndef __iwl_fw_file_h__ +#define __iwl_fw_file_h__ #include @@ -157,4 +157,4 @@ struct iwl_tlv_ucode_header { u8 data[0]; }; -#endif /* __iwl_ucode_h__ */ +#endif /* __iwl_fw_file_h__ */ -- GitLab From 496bab39b5a8ef9c916cdb961dec5bbb5ba263f7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:45 -0800 Subject: [PATCH 1536/1846] iwlwifi: remove AMT check from transport As iwl_prepare_card_hw() is idempotent (and many cards support AMT anyway) there's no point in calling iwl_prepare_card_hw() only for AMT capable devices -- call it always and simplify the code that way. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 4a05216242a9..4a2d4b58cdc8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1033,8 +1033,8 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, trans_pcie->mcast_queue[IWL_RXON_CTX_BSS] = 0; trans_pcie->mcast_queue[IWL_RXON_CTX_PAN] = IWL_IPAN_MCAST_QUEUE; - if ((hw_params(trans).sku & EEPROM_SKU_CAP_AMT_ENABLE) && - iwl_prepare_card_hw(trans)) { + /* This may fail if AMT took ownership of the device */ + if (iwl_prepare_card_hw(trans)) { IWL_WARN(trans, "Exit HW not ready\n"); return -EIO; } -- GitLab From 0dde86b2f2999a25dcc62a27cb768c35a418890a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:46 -0800 Subject: [PATCH 1537/1846] iwlwifi: remove shadow_reg_enable from hw_params There's no need to copy shadow_reg_enable into hw_params since it is a pure hardware parameter that will never change, we can access it from the config directly. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 -- drivers/net/wireless/iwlwifi/iwl-power.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 +- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 863c27e20dbc..f8163717d7d1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1127,8 +1127,6 @@ static void iwl_set_hw_params(struct iwl_priv *priv) hw_params(priv).num_ampdu_queues = cfg(priv)->base_params->num_of_ampdu_queues; - hw_params(priv).shadow_reg_enable = - cfg(priv)->base_params->shadow_reg_enable; hw_params(priv).wd_timeout = cfg(priv)->base_params->wd_timeout; /* Device-specific setup */ diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index d76ff239d5f1..f79ff16e29f4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -215,7 +215,7 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv, else cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK; - if (hw_params(priv).shadow_reg_enable) + if (cfg(priv)->base_params->shadow_reg_enable) cmd->flags |= IWL_POWER_SHADOW_REG_ENA; else cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA; @@ -301,7 +301,7 @@ static void iwl_power_fill_sleep_cmd(struct iwl_priv *priv, if (priv->power_data.bus_pm) cmd->flags |= IWL_POWER_PCI_PM_MSK; - if (hw_params(priv).shadow_reg_enable) + if (cfg(priv)->base_params->shadow_reg_enable) cmd->flags |= IWL_POWER_SHADOW_REG_ENA; else cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 30b942f77814..a5ab58ce0307 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -185,7 +185,6 @@ struct iwl_hw_params { u8 valid_tx_ant; u8 valid_rx_ant; u8 ht40_channel; - bool shadow_reg_enable; u16 sku; u32 rx_page_order; u32 ct_kill_threshold; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index e8d3129d5bde..911a9f113f1f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -141,7 +141,7 @@ void iwl_rx_queue_update_write_ptr(struct iwl_trans *trans, if (q->need_update == 0) goto exit_unlock; - if (hw_params(trans).shadow_reg_enable) { + if (cfg(trans)->base_params->shadow_reg_enable) { /* shadow register enabled */ /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index ca4ceeacc989..2573f7149f16 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -136,7 +136,7 @@ void iwl_txq_update_write_ptr(struct iwl_trans *trans, struct iwl_tx_queue *txq) if (txq->need_update == 0) return; - if (hw_params(trans).shadow_reg_enable) { + if (cfg(trans)->base_params->shadow_reg_enable) { /* shadow register enabled */ iwl_write32(trans, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 4a2d4b58cdc8..44050fa414d1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -828,7 +828,7 @@ static int iwl_nic_init(struct iwl_trans *trans) if (iwl_tx_init(trans)) return -ENOMEM; - if (hw_params(trans).shadow_reg_enable) { + if (cfg(trans)->base_params->shadow_reg_enable) { /* enable shadow regs in HW */ iwl_set_bit(trans, CSR_MAC_SHADOW_REG_CTRL, 0x800FFFFF); -- GitLab From 84abd2cc066fc077c424d0faf7618be348a7efb2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:47 -0800 Subject: [PATCH 1538/1846] iwlwifi: move status check functions out of shared They are only used in the DVM op_mode. Also move the rfkill debug macros that depend on them. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 1 + drivers/net/wireless/iwlwifi/iwl-agn.h | 64 +++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-debug.h | 16 ------ drivers/net/wireless/iwlwifi/iwl-shared.h | 42 --------------- 4 files changed, 65 insertions(+), 58 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index 85fe590ee721..7712c5537370 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -34,6 +34,7 @@ #include +#include "iwl-agn.h" #include "iwl-eeprom.h" #include "iwl-dev.h" #include "iwl-core.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index dfd86f288dee..1f62d6d1fc65 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -383,4 +383,68 @@ static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv, } #endif +/* status checks */ + +static inline int iwl_is_ready(struct iwl_shared *shrd) +{ + /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are + * set but EXIT_PENDING is not */ + return test_bit(STATUS_READY, &shrd->status) && + test_bit(STATUS_GEO_CONFIGURED, &shrd->status) && + !test_bit(STATUS_EXIT_PENDING, &shrd->status); +} + +static inline int iwl_is_alive(struct iwl_shared *shrd) +{ + return test_bit(STATUS_ALIVE, &shrd->status); +} + +static inline int iwl_is_init(struct iwl_shared *shrd) +{ + return test_bit(STATUS_INIT, &shrd->status); +} + +static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd) +{ + return test_bit(STATUS_RF_KILL_HW, &shrd->status); +} + +static inline int iwl_is_rfkill(struct iwl_shared *shrd) +{ + return iwl_is_rfkill_hw(shrd); +} + +static inline int iwl_is_ctkill(struct iwl_shared *shrd) +{ + return test_bit(STATUS_CT_KILL, &shrd->status); +} + +static inline int iwl_is_ready_rf(struct iwl_shared *shrd) +{ + if (iwl_is_rfkill(shrd)) + return 0; + + return iwl_is_ready(shrd); +} + +#ifdef CONFIG_IWLWIFI_DEBUG +#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ +do { \ + if (!iwl_is_rfkill((m)->shrd)) \ + IWL_ERR(m, fmt, ##args); \ + else \ + __iwl_err(trans(m)->dev, true, \ + !iwl_have_debug_level(IWL_DL_RADIO), \ + fmt, ##args); \ +} while (0) +#else +#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ +do { \ + if (!iwl_is_rfkill((m)->shrd)) \ + IWL_ERR(m, fmt, ##args); \ + else \ + __iwl_err(trans(m)->dev, true, true, fmt, ##args); \ +} while (0) +#endif /* CONFIG_IWLWIFI_DEBUG */ + #endif /* __iwl_agn_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 163d259198be..a6b32a11e103 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -76,24 +76,8 @@ do { \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) -#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ -do { \ - if (!iwl_is_rfkill((m)->shrd)) \ - IWL_ERR(m, fmt, ##args); \ - else \ - __iwl_err(trans(m)->dev, true, \ - !iwl_have_debug_level(IWL_DL_RADIO), \ - fmt, ##args); \ -} while (0) #else #define iwl_print_hex_dump(m, level, p, len) -#define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ -do { \ - if (!iwl_is_rfkill((m)->shrd)) \ - IWL_ERR(m, fmt, ##args); \ - else \ - __iwl_err(trans(m)->dev, true, true, fmt, ##args); \ -} while (0) #endif /* CONFIG_IWLWIFI_DEBUG */ #ifdef CONFIG_IWLWIFI_DEBUGFS diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index a5ab58ce0307..5e12b504aacf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -508,46 +508,4 @@ iwl_remove_notification(struct iwl_shared *shrd, #define STATUS_CHANNEL_SWITCH_PENDING 19 #define STATUS_SCAN_COMPLETE 20 -static inline int iwl_is_ready(struct iwl_shared *shrd) -{ - /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are - * set but EXIT_PENDING is not */ - return test_bit(STATUS_READY, &shrd->status) && - test_bit(STATUS_GEO_CONFIGURED, &shrd->status) && - !test_bit(STATUS_EXIT_PENDING, &shrd->status); -} - -static inline int iwl_is_alive(struct iwl_shared *shrd) -{ - return test_bit(STATUS_ALIVE, &shrd->status); -} - -static inline int iwl_is_init(struct iwl_shared *shrd) -{ - return test_bit(STATUS_INIT, &shrd->status); -} - -static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd) -{ - return test_bit(STATUS_RF_KILL_HW, &shrd->status); -} - -static inline int iwl_is_rfkill(struct iwl_shared *shrd) -{ - return iwl_is_rfkill_hw(shrd); -} - -static inline int iwl_is_ctkill(struct iwl_shared *shrd) -{ - return test_bit(STATUS_CT_KILL, &shrd->status); -} - -static inline int iwl_is_ready_rf(struct iwl_shared *shrd) -{ - if (iwl_is_rfkill(shrd)) - return 0; - - return iwl_is_ready(shrd); -} - #endif /* #__iwl_shared_h__ */ -- GitLab From 6c1011e1918be17f7f8ccca5442cd517f9c29d17 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:48 -0800 Subject: [PATCH 1539/1846] iwlwifi: make tracing use device as identifier Tracing used the priv pointer as an identifier, which has the problem that we don't have it in all code, and also some people say no pointers should be "leaked" to userspace. Use the device name instead, it is more useful anyway. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 9 +- drivers/net/wireless/iwlwifi/iwl-devtrace.h | 141 +++++++++--------- drivers/net/wireless/iwlwifi/iwl-io.h | 6 +- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 16 +- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 +- 6 files changed, 90 insertions(+), 86 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index f8163717d7d1..276570025e52 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -353,11 +353,12 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, ev = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); time = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); if (mode == 0) { - trace_iwlwifi_dev_ucode_cont_event(priv, 0, time, ev); + trace_iwlwifi_dev_ucode_cont_event( + trans(priv)->dev, 0, time, ev); } else { data = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); - trace_iwlwifi_dev_ucode_cont_event(priv, time, - data, ev); + trace_iwlwifi_dev_ucode_cont_event( + trans(priv)->dev, time, data, ev); } } /* Allow device to power down */ @@ -422,7 +423,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv) else priv->event_log.wraps_once_count++; - trace_iwlwifi_dev_ucode_wrap_event(priv, + trace_iwlwifi_dev_ucode_wrap_event(trans(priv)->dev, num_wraps - priv->event_log.num_wraps, next_entry, priv->event_log.next_entry); diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h index 96e62338cec0..06203d6a1d86 100644 --- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h @@ -41,130 +41,134 @@ static inline void trace_ ## name(proto) {} static inline void trace_ ## name(proto) {} #endif -#define PRIV_ENTRY __field(void *, priv) -#define PRIV_ASSIGN __entry->priv = priv +#define DEV_ENTRY __string(dev, dev_name(dev)) +#define DEV_ASSIGN __assign_str(dev, dev_name(dev)) #undef TRACE_SYSTEM #define TRACE_SYSTEM iwlwifi_io TRACE_EVENT(iwlwifi_dev_ioread32, - TP_PROTO(void *priv, u32 offs, u32 val), - TP_ARGS(priv, offs, val), + TP_PROTO(const struct device *dev, u32 offs, u32 val), + TP_ARGS(dev, offs, val), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, offs) __field(u32, val) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->offs = offs; __entry->val = val; ), - TP_printk("[%p] read io[%#x] = %#x", __entry->priv, __entry->offs, __entry->val) + TP_printk("[%s] read io[%#x] = %#x", + __get_str(dev), __entry->offs, __entry->val) ); TRACE_EVENT(iwlwifi_dev_iowrite8, - TP_PROTO(void *priv, u32 offs, u8 val), - TP_ARGS(priv, offs, val), + TP_PROTO(const struct device *dev, u32 offs, u8 val), + TP_ARGS(dev, offs, val), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, offs) __field(u8, val) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->offs = offs; __entry->val = val; ), - TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, __entry->offs, __entry->val) + TP_printk("[%s] write io[%#x] = %#x)", + __get_str(dev), __entry->offs, __entry->val) ); TRACE_EVENT(iwlwifi_dev_iowrite32, - TP_PROTO(void *priv, u32 offs, u32 val), - TP_ARGS(priv, offs, val), + TP_PROTO(const struct device *dev, u32 offs, u32 val), + TP_ARGS(dev, offs, val), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, offs) __field(u32, val) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->offs = offs; __entry->val = val; ), - TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, __entry->offs, __entry->val) + TP_printk("[%s] write io[%#x] = %#x)", + __get_str(dev), __entry->offs, __entry->val) ); TRACE_EVENT(iwlwifi_dev_irq, - TP_PROTO(void *priv), - TP_ARGS(priv), + TP_PROTO(const struct device *dev), + TP_ARGS(dev), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; ), /* TP_printk("") doesn't compile */ TP_printk("%d", 0) ); TRACE_EVENT(iwlwifi_dev_ict_read, - TP_PROTO(void *priv, u32 index, u32 value), - TP_ARGS(priv, index, value), + TP_PROTO(const struct device *dev, u32 index, u32 value), + TP_ARGS(dev, index, value), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, index) __field(u32, value) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->index = index; __entry->value = value; ), - TP_printk("read ict[%d] = %#.8x", __entry->index, __entry->value) + TP_printk("[%s] read ict[%d] = %#.8x", + __get_str(dev), __entry->index, __entry->value) ); #undef TRACE_SYSTEM #define TRACE_SYSTEM iwlwifi_ucode TRACE_EVENT(iwlwifi_dev_ucode_cont_event, - TP_PROTO(void *priv, u32 time, u32 data, u32 ev), - TP_ARGS(priv, time, data, ev), + TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev), + TP_ARGS(dev, time, data, ev), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, time) __field(u32, data) __field(u32, ev) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->time = time; __entry->data = data; __entry->ev = ev; ), - TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u", - __entry->priv, __entry->time, __entry->data, __entry->ev) + TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u", + __get_str(dev), __entry->time, __entry->data, __entry->ev) ); TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, - TP_PROTO(void *priv, u32 wraps, u32 n_entry, u32 p_entry), - TP_ARGS(priv, wraps, n_entry, p_entry), + TP_PROTO(const struct device *dev, u32 wraps, u32 n_entry, u32 p_entry), + TP_ARGS(dev, wraps, n_entry, p_entry), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, wraps) __field(u32, n_entry) __field(u32, p_entry) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->wraps = wraps; __entry->n_entry = n_entry; __entry->p_entry = p_entry; ), - TP_printk("[%p] wraps=#%02d n=0x%X p=0x%X", - __entry->priv, __entry->wraps, __entry->n_entry, + TP_printk("[%s] wraps=#%02d n=0x%X p=0x%X", + __get_str(dev), __entry->wraps, __entry->n_entry, __entry->p_entry) ); @@ -232,52 +236,52 @@ TRACE_EVENT(iwlwifi_dbg, #define TRACE_SYSTEM iwlwifi TRACE_EVENT(iwlwifi_dev_hcmd, - TP_PROTO(void *priv, u32 flags, + TP_PROTO(const struct device *dev, u32 flags, const void *hcmd0, size_t len0, const void *hcmd1, size_t len1, const void *hcmd2, size_t len2), - TP_ARGS(priv, flags, hcmd0, len0, hcmd1, len1, hcmd2, len2), + TP_ARGS(dev, flags, hcmd0, len0, hcmd1, len1, hcmd2, len2), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __dynamic_array(u8, hcmd0, len0) __dynamic_array(u8, hcmd1, len1) __dynamic_array(u8, hcmd2, len2) __field(u32, flags) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; memcpy(__get_dynamic_array(hcmd0), hcmd0, len0); memcpy(__get_dynamic_array(hcmd1), hcmd1, len1); memcpy(__get_dynamic_array(hcmd2), hcmd2, len2); __entry->flags = flags; ), - TP_printk("[%p] hcmd %#.2x (%ssync)", - __entry->priv, ((u8 *)__get_dynamic_array(hcmd0))[0], + TP_printk("[%s] hcmd %#.2x (%ssync)", + __get_str(dev), ((u8 *)__get_dynamic_array(hcmd0))[0], __entry->flags & CMD_ASYNC ? "a" : "") ); TRACE_EVENT(iwlwifi_dev_rx, - TP_PROTO(void *priv, void *rxbuf, size_t len), - TP_ARGS(priv, rxbuf, len), + TP_PROTO(const struct device *dev, void *rxbuf, size_t len), + TP_ARGS(dev, rxbuf, len), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __dynamic_array(u8, rxbuf, len) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; memcpy(__get_dynamic_array(rxbuf), rxbuf, len); ), - TP_printk("[%p] RX cmd %#.2x", - __entry->priv, ((u8 *)__get_dynamic_array(rxbuf))[4]) + TP_printk("[%s] RX cmd %#.2x", + __get_str(dev), ((u8 *)__get_dynamic_array(rxbuf))[4]) ); TRACE_EVENT(iwlwifi_dev_tx, - TP_PROTO(void *priv, void *tfd, size_t tfdlen, + TP_PROTO(const struct device *dev, 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_ARGS(dev, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(size_t, framelen) __dynamic_array(u8, tfd, tfdlen) @@ -291,29 +295,28 @@ TRACE_EVENT(iwlwifi_dev_tx, __dynamic_array(u8, buf1, buf1_len) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_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], + TP_printk("[%s] TX %.2x (%zu bytes)", + __get_str(dev), ((u8 *)__get_dynamic_array(buf0))[0], __entry->framelen) ); TRACE_EVENT(iwlwifi_dev_ucode_error, - TP_PROTO(void *priv, u32 desc, u32 tsf_low, + TP_PROTO(const struct device *dev, u32 desc, u32 tsf_low, u32 data1, u32 data2, u32 line, u32 blink1, u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time, u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver, u32 brd_ver), - TP_ARGS(priv, desc, tsf_low, data1, data2, line, + TP_ARGS(dev, desc, tsf_low, data1, data2, line, blink1, blink2, ilink1, ilink2, bcon_time, gp1, gp2, gp3, ucode_ver, hw_ver, brd_ver), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, desc) __field(u32, tsf_low) __field(u32, data1) @@ -332,7 +335,7 @@ TRACE_EVENT(iwlwifi_dev_ucode_error, __field(u32, brd_ver) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->desc = desc; __entry->tsf_low = tsf_low; __entry->data1 = data1; @@ -350,11 +353,11 @@ TRACE_EVENT(iwlwifi_dev_ucode_error, __entry->hw_ver = hw_ver; __entry->brd_ver = brd_ver; ), - TP_printk("[%p] #%02d %010u data 0x%08X 0x%08X line %u, " + TP_printk("[%s] #%02d %010u data 0x%08X 0x%08X line %u, " "blink 0x%05X 0x%05X ilink 0x%05X 0x%05X " "bcon_tm %010u gp 0x%08X 0x%08X 0x%08X uCode 0x%08X " "hw 0x%08X brd 0x%08X", - __entry->priv, __entry->desc, __entry->tsf_low, + __get_str(dev), __entry->desc, __entry->tsf_low, __entry->data1, __entry->data2, __entry->line, __entry->blink1, __entry->blink2, __entry->ilink1, __entry->ilink2, @@ -364,23 +367,23 @@ TRACE_EVENT(iwlwifi_dev_ucode_error, ); TRACE_EVENT(iwlwifi_dev_ucode_event, - TP_PROTO(void *priv, u32 time, u32 data, u32 ev), - TP_ARGS(priv, time, data, ev), + TP_PROTO(const struct device *dev, u32 time, u32 data, u32 ev), + TP_ARGS(dev, time, data, ev), TP_STRUCT__entry( - PRIV_ENTRY + DEV_ENTRY __field(u32, time) __field(u32, data) __field(u32, ev) ), TP_fast_assign( - PRIV_ASSIGN; + DEV_ASSIGN; __entry->time = time; __entry->data = data; __entry->ev = ev; ), - TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u", - __entry->priv, __entry->time, __entry->data, __entry->ev) + TP_printk("[%s] EVT_LOGT:%010u:0x%08x:%04u", + __get_str(dev), __entry->time, __entry->data, __entry->ev) ); #endif /* __IWLWIFI_DEVICE_TRACE */ diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index 782486fc2f8f..1136dc19936a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h @@ -35,20 +35,20 @@ static inline void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val) { - trace_iwlwifi_dev_iowrite8(priv(trans), ofs, val); + trace_iwlwifi_dev_iowrite8(trans->dev, ofs, val); iwl_trans_write8(trans, ofs, val); } static inline void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val) { - trace_iwlwifi_dev_iowrite32(priv(trans), ofs, val); + trace_iwlwifi_dev_iowrite32(trans->dev, ofs, val); iwl_trans_write32(trans, ofs, val); } static inline u32 iwl_read32(struct iwl_trans *trans, u32 ofs) { u32 val = iwl_trans_read32(trans, ofs); - trace_iwlwifi_dev_ioread32(priv(trans), ofs, val); + trace_iwlwifi_dev_ioread32(trans->dev, ofs, val); return val; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 911a9f113f1f..33a933b78e52 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -388,7 +388,7 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans, len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ - trace_iwlwifi_dev_rx(priv(trans), pkt, len); + trace_iwlwifi_dev_rx(trans->dev, pkt, len); /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -632,7 +632,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) trans_pcie->isr_stats.err_code = table.error_id; - trace_iwlwifi_dev_ucode_error(priv(trans), table.error_id, table.tsf_low, + trace_iwlwifi_dev_ucode_error(trans->dev, table.error_id, table.tsf_low, table.data1, table.data2, table.line, table.blink1, table.blink2, table.ilink1, table.ilink2, table.bcon_time, table.gp1, @@ -764,7 +764,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, "EVT_LOG:0x%08x:%04u\n", time, ev); } else { - trace_iwlwifi_dev_ucode_event(priv(trans), 0, + trace_iwlwifi_dev_ucode_event(trans->dev, 0, time, ev); IWL_ERR(trans, "EVT_LOG:0x%08x:%04u\n", time, ev); @@ -778,7 +778,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, } else { IWL_ERR(trans, "EVT_LOGT:%010u:0x%08x:%04u\n", time, data, ev); - trace_iwlwifi_dev_ucode_event(priv(trans), time, + trace_iwlwifi_dev_ucode_event(trans->dev, time, data, ev); } } @@ -1262,7 +1262,7 @@ static irqreturn_t iwl_isr(int irq, void *data) if (!trans) return IRQ_NONE; - trace_iwlwifi_dev_irq(priv(trans)); + trace_iwlwifi_dev_irq(trans->dev); trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); @@ -1352,7 +1352,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) if (!trans_pcie->use_ict) return iwl_isr(irq, data); - trace_iwlwifi_dev_irq(priv(trans)); + trace_iwlwifi_dev_irq(trans->dev); spin_lock_irqsave(&trans_pcie->irq_lock, flags); @@ -1369,7 +1369,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]); - trace_iwlwifi_dev_ict_read(priv(trans), trans_pcie->ict_index, read); + trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index, read); if (!read) { IWL_DEBUG_ISR(trans, "Ignore interrupt, inta == 0\n"); goto none; @@ -1388,7 +1388,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) iwl_queue_inc_wrap(trans_pcie->ict_index, ICT_COUNT); read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]); - trace_iwlwifi_dev_ict_read(priv(trans), trans_pcie->ict_index, + trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index, read); } while (read); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 2573f7149f16..844606b436ed 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -820,7 +820,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) /* check that tracing gets all possible blocks */ BUILD_BUG_ON(IWL_MAX_CMD_TFDS + 1 != 3); #ifdef CONFIG_IWLWIFI_DEVICE_TRACING - trace_iwlwifi_dev_hcmd(priv(trans), cmd->flags, + trace_iwlwifi_dev_hcmd(trans->dev, cmd->flags, trace_bufs[0], trace_lens[0], trace_bufs[1], trace_lens[1], trace_bufs[2], trace_lens[2]); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 44050fa414d1..ef4e1222a318 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1468,7 +1468,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, dma_sync_single_for_device(trans->dev, txcmd_phys, firstlen, DMA_BIDIRECTIONAL); - trace_iwlwifi_dev_tx(priv(trans), + trace_iwlwifi_dev_tx(trans->dev, &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr], sizeof(struct iwl_tfd), &dev_cmd->hdr, firstlen, -- GitLab From 0e781842cb25ed3a9d0a91bdf05c0717150c9343 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:49 -0800 Subject: [PATCH 1540/1846] iwlwifi: virtualize command queue full behaviour When the command queue is full, the transport will return -ENOSPC, but the reaction to that depends on the op_mode. Virtualize that, the DVM op_mode checks for CT-kill and restarts the hardware otherwise. We may be able to get rid of this callback by putting the behaviour check into the wrapper but that needs more careful evaluation. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 11 +++++++++++ drivers/net/wireless/iwlwifi/iwl-agn.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-op-mode.h | 7 +++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 7 +------ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 276570025e52..7c3165ed85bc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1403,6 +1403,16 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) ieee80211_free_hw(priv->hw); } +static void iwl_cmd_queue_full(struct iwl_op_mode *op_mode) +{ + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + + if (!iwl_check_for_ct_kill(priv)) { + IWL_ERR(priv, "Restarting adapter queue is full\n"); + iwl_nic_error(op_mode); + } +} + const struct iwl_op_mode_ops iwl_dvm_ops = { .start = iwl_op_mode_dvm_start, .stop = iwl_op_mode_dvm_stop, @@ -1412,6 +1422,7 @@ const struct iwl_op_mode_ops iwl_dvm_ops = { .hw_rf_kill = iwl_set_hw_rfkill_state, .free_skb = iwl_free_skb, .nic_error = iwl_nic_error, + .cmd_queue_full = iwl_cmd_queue_full, }; /***************************************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 1f62d6d1fc65..ec3a90c42efb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -90,6 +90,8 @@ void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state); void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_nic_error(struct iwl_op_mode *op_mode); +bool iwl_check_for_ct_kill(struct iwl_priv *priv); + /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); int iwlagn_mac_setup_register(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index 55b8b27a9560..a4a4907803ca 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -122,6 +122,7 @@ struct iwl_fw; * there are Tx packets pending in the transport layer. * Must be atomic * @nic_error: error notification. Must be atomic + * @cmd_queue_full: Called when the command queue gets full. Must be atomic. */ struct iwl_op_mode_ops { struct iwl_op_mode *(*start)(struct iwl_trans *trans, @@ -134,6 +135,7 @@ struct iwl_op_mode_ops { void (*hw_rf_kill)(struct iwl_op_mode *op_mode, bool state); void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); void (*nic_error)(struct iwl_op_mode *op_mode); + void (*cmd_queue_full)(struct iwl_op_mode *op_mode); }; /** @@ -192,6 +194,11 @@ static inline void iwl_op_mode_nic_error(struct iwl_op_mode *op_mode) op_mode->ops->nic_error(op_mode); } +static inline void iwl_op_mode_cmd_queue_full(struct iwl_op_mode *op_mode) +{ + op_mode->ops->cmd_queue_full(op_mode); +} + /***************************************************** * Op mode layers implementations ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 5e12b504aacf..8ee528479c95 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -461,8 +461,6 @@ enum iwl_rxon_context_id { int iwlagn_hw_valid_rtc_data_addr(u32 addr); void iwl_nic_config(struct iwl_priv *priv); const char *get_cmd_string(u8 cmd); -bool iwl_check_for_ct_kill(struct iwl_priv *priv); - /* notification wait support */ void iwl_abort_notification_waits(struct iwl_shared *shrd); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 844606b436ed..7feeb2d52146 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -671,7 +671,6 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) dma_addr_t phys_addr; u32 idx; u16 copy_size, cmd_size; - bool is_ct_kill = false; bool had_nocopy = false; int i; u8 *cmd_dest; @@ -727,11 +726,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) spin_unlock_bh(&txq->lock); IWL_ERR(trans, "No space in command queue\n"); - is_ct_kill = iwl_check_for_ct_kill(priv(trans)); - if (!is_ct_kill) { - IWL_ERR(trans, "Restarting adapter queue is full\n"); - iwl_op_mode_nic_error(trans->op_mode); - } + iwl_op_mode_cmd_queue_full(trans->op_mode); return -ENOSPC; } -- GitLab From 1b29dc94ac2e96c9a31b566dc609bf1d4eb87cc2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:50 -0800 Subject: [PATCH 1541/1846] iwlwifi: clean up iwl-core.h inclusions The transport doesn't need to include iwl-core.h any more. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 33a933b78e52..f1456211c294 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -30,8 +30,7 @@ #include #include -/*TODO: Remove include to iwl-core.h*/ -#include "iwl-core.h" +#include "iwl-prph.h" #include "iwl-io.h" #include "iwl-trans-pcie-int.h" #include "iwl-op-mode.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ef4e1222a318..6090e9800ce4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -75,7 +75,6 @@ #include "iwl-shared.h" #include "iwl-eeprom.h" #include "iwl-agn-hw.h" -#include "iwl-core.h" #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -- GitLab From ae9625a1a947f33579c244b730001f2ea7d15045 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:51 -0800 Subject: [PATCH 1542/1846] iwlwifi: remove num_of_queues module parameter This is a hardware parameter, so it shouldn't be configurable by the user. Users can disable aggregation (which is the only thing affected) with 11n_disable. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 5 ----- drivers/net/wireless/iwlwifi/iwl-2000.c | 5 ----- drivers/net/wireless/iwlwifi/iwl-5000.c | 10 ---------- drivers/net/wireless/iwlwifi/iwl-6000.c | 5 ----- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 -- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- 6 files changed, 29 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 2199a0e5c4f0..5039a9a47767 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -122,11 +122,6 @@ static struct iwl_sensitivity_ranges iwl1000_sensitivity = { static void iwl1000_hw_set_hw_params(struct iwl_priv *priv) { - if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && - iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) - cfg(priv)->base_params->num_of_queues = - iwlagn_mod_params.num_of_queues; - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 1ba020723537..c1739626aeb4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -118,11 +118,6 @@ static struct iwl_sensitivity_ranges iwl2000_sensitivity = { static void iwl2000_hw_set_hw_params(struct iwl_priv *priv) { - if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && - iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) - cfg(priv)->base_params->num_of_queues = - iwlagn_mod_params.num_of_queues; - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index aebdfd7e01a5..fc6ec07de877 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -157,11 +157,6 @@ static void iwl5000_set_ct_threshold(struct iwl_priv *priv) static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) { - if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && - iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) - cfg(priv)->base_params->num_of_queues = - iwlagn_mod_params.num_of_queues; - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | @@ -180,11 +175,6 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) static void iwl5150_hw_set_hw_params(struct iwl_priv *priv) { - if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && - iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) - cfg(priv)->base_params->num_of_queues = - iwlagn_mod_params.num_of_queues; - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 150bef078609..a64f0f281249 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -139,11 +139,6 @@ static struct iwl_sensitivity_ranges iwl6000_sensitivity = { static void iwl6000_hw_set_hw_params(struct iwl_priv *priv) { - if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES && - iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES) - cfg(priv)->base_params->num_of_queues = - iwlagn_mod_params.num_of_queues; - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 7c3165ed85bc..8cf149cd20ca 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1471,8 +1471,6 @@ MODULE_PARM_DESC(debug, "debug output mask"); module_param_named(swcrypto, iwlagn_mod_params.sw_crypto, int, S_IRUGO); MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); -module_param_named(queues_num, iwlagn_mod_params.num_of_queues, int, S_IRUGO); -MODULE_PARM_DESC(queues_num, "number of hw queues."); module_param_named(11n_disable, iwlagn_mod_params.disable_11n, uint, S_IRUGO); MODULE_PARM_DESC(11n_disable, "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX"); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 8ee528479c95..ab2e1f771a11 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -115,7 +115,6 @@ extern struct iwl_mod_params iwlagn_mod_params; * Holds the module parameters * * @sw_crypto: using hardware encryption, default = 0 - * @num_of_queues: number of tx queue, HW dependent * @disable_11n: disable 11n capabilities, default = 0, * use IWL_DISABLE_HT_* constants * @amsdu_size_8K: enable 8K amsdu size, default = 1 @@ -137,7 +136,6 @@ extern struct iwl_mod_params iwlagn_mod_params; */ struct iwl_mod_params { int sw_crypto; - int num_of_queues; unsigned int disable_11n; int amsdu_size_8K; int antenna; -- GitLab From 3cc241ad713dcc4e193aec40307e9070bf817908 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:52 -0800 Subject: [PATCH 1543/1846] iwlwifi: remove max_txq_num from hw_params This can be used directly from the config now. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index a2ef78c6af60..25fdb805abc3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1345,7 +1345,7 @@ void iwl_bg_watchdog(unsigned long data) return; /* monitor and check for stuck queues */ - for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) + for (cnt = 0; cnt < cfg(priv)->base_params->num_of_queues; cnt++) if (iwl_check_stuck_queue(priv, cnt)) return; -- GitLab From ab5c0f1f2d525ed17f1abf727d213cf220ed26a8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:53 -0800 Subject: [PATCH 1544/1846] iwlwifi: keep plcp_delta_threshold in priv The base_params shouldn't be writable, so keep a copy of this in priv that can be modified. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 3 +++ drivers/net/wireless/iwlwifi/iwl-debugfs.c | 6 +++--- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index d16e73d1b5c9..5c9c88b8609f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -320,7 +320,7 @@ static bool iwlagn_good_plcp_health(struct iwl_priv *priv, unsigned int msecs) { int delta; - int threshold = cfg(priv)->base_params->plcp_delta_threshold; + int threshold = priv->plcp_delta_threshold; if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) { IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8cf149cd20ca..ac23aa3dd6d7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1045,6 +1045,9 @@ static int iwl_init_drv(struct iwl_priv *priv) priv->ieee_rates = NULL; priv->band = IEEE80211_BAND_2GHZ; + priv->plcp_delta_threshold = + cfg(priv)->base_params->plcp_delta_threshold; + priv->iw_mode = NL80211_IFTYPE_STATION; priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index b9b6d628f59a..ade4134fc1ec 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2241,7 +2241,7 @@ static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "%u\n", - cfg(priv)->base_params->plcp_delta_threshold); + priv->plcp_delta_threshold); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -2263,10 +2263,10 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, return -EINVAL; if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) - cfg(priv)->base_params->plcp_delta_threshold = + priv->plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; else - cfg(priv)->base_params->plcp_delta_threshold = plcp; + priv->plcp_delta_threshold = plcp; return count; } diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 73acbab6c248..0c397fd635a3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -770,6 +770,8 @@ struct iwl_priv { struct iwl_channel_info *channel_info; /* channel info array */ u8 channel_count; /* # of channels */ + u8 plcp_delta_threshold; + /* thermal calibration */ s32 temperature; /* Celsius */ s32 last_temperature; -- GitLab From e7a09438b3369732b9c5cfbca24d3bc894fc1ec1 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:54 -0800 Subject: [PATCH 1545/1846] iwlwifi: use watchdog timeout from hw_params This is the version that can be modified, the config params should be read-only. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 25fdb805abc3..2422eef6d15f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1340,7 +1340,7 @@ void iwl_bg_watchdog(unsigned long data) if (iwl_is_rfkill(priv->shrd)) return; - timeout = cfg(priv)->base_params->wd_timeout; + timeout = hw_params(priv).wd_timeout; if (timeout == 0) return; @@ -1355,7 +1355,7 @@ void iwl_bg_watchdog(unsigned long data) void iwl_setup_watchdog(struct iwl_priv *priv) { - unsigned int timeout = cfg(priv)->base_params->wd_timeout; + unsigned int timeout = hw_params(priv).wd_timeout; if (!iwlagn_mod_params.wd_disable) { /* use system default */ diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index ade4134fc1ec..116c7851f3b1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2368,7 +2368,7 @@ static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file, if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) timeout = IWL_DEF_WD_TIMEOUT; - cfg(priv)->base_params->wd_timeout = timeout; + hw_params(priv).wd_timeout = timeout; iwl_setup_watchdog(priv); return count; } -- GitLab From b9ad70da6a7ed166539b188a95e0aef119555e14 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:55 -0800 Subject: [PATCH 1546/1846] iwlwifi: put use_rts_for_aggregation into hw_params The hardware config ht_params shouldn't be modified, so copy the use_rts_for_aggregation parameter into hw_params and use/modify it there. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++++ drivers/net/wireless/iwlwifi/iwl-debugfs.c | 6 +++--- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 ++ 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 2c5e7ec697e9..e191d394cfa0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -436,8 +436,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * force CTS-to-self frames protection if RTS-CTS is not preferred * one aggregation protection method */ - if (!(cfg(priv)->ht_params && - cfg(priv)->ht_params->use_rts_for_aggregation)) + if (!hw_params(priv).use_rts_for_aggregation) ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index dd28785e1a5c..151400cf51e0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -594,8 +594,7 @@ int iwlagn_tx_agg_oper(struct iwl_priv *priv, struct ieee80211_vif *vif, sta_priv->max_agg_bufsize = min(sta_priv->max_agg_bufsize, buf_size); - if (cfg(priv)->ht_params && - cfg(priv)->ht_params->use_rts_for_aggregation) { + if (hw_params(priv).use_rts_for_aggregation) { /* * switch to RTS/CTS if it is the prefer protection * method for HT traffic diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ac23aa3dd6d7..ce62a2fcd67f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1119,6 +1119,10 @@ static void iwl_uninit_drv(struct iwl_priv *priv) static void iwl_set_hw_params(struct iwl_priv *priv) { + if (cfg(priv)->ht_params) + hw_params(priv).use_rts_for_aggregation = + cfg(priv)->ht_params->use_rts_for_aggregation; + if (iwlagn_mod_params.amsdu_size_8K) hw_params(priv).rx_page_order = get_order(IWL_RX_BUF_SIZE_8K); diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 116c7851f3b1..0a898c54c733 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -2431,7 +2431,7 @@ static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, if (cfg(priv)->ht_params) pos += scnprintf(buf + pos, bufsz - pos, "use %s for aggregation\n", - (cfg(priv)->ht_params->use_rts_for_aggregation) ? + (hw_params(priv).use_rts_for_aggregation) ? "rts/cts" : "cts-to-self"); else pos += scnprintf(buf + pos, bufsz - pos, "N/A"); @@ -2458,9 +2458,9 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, if (sscanf(buf, "%d", &rts) != 1) return -EINVAL; if (rts) - cfg(priv)->ht_params->use_rts_for_aggregation = true; + hw_params(priv).use_rts_for_aggregation = true; else - cfg(priv)->ht_params->use_rts_for_aggregation = false; + hw_params(priv).use_rts_for_aggregation = false; return count; } diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 30861765b512..d2c1d714c89c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -660,8 +660,8 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", priv->agg_tids_count); } - if (!priv->agg_tids_count && cfg(priv)->ht_params && - cfg(priv)->ht_params->use_rts_for_aggregation) { + if (!priv->agg_tids_count && + hw_params(priv).use_rts_for_aggregation) { /* * switch off RTS/CTS if it was previously enabled */ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index ab2e1f771a11..7c9502703e82 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -174,6 +174,7 @@ struct iwl_mod_params { * relevant for 1000, 6000 and up * @wd_timeout: TX queues watchdog timeout * @struct iwl_sensitivity_ranges: range of sensitivity values + * @use_rts_for_aggregation: use rts/cts protection for HT traffic */ struct iwl_hw_params { u8 max_txq_num; @@ -183,6 +184,7 @@ struct iwl_hw_params { u8 valid_tx_ant; u8 valid_rx_ant; u8 ht40_channel; + bool use_rts_for_aggregation; u16 sku; u32 rx_page_order; u32 ct_kill_threshold; -- GitLab From 6794f3ee1dc4a2f7ebed99a4c075f00bbebbcfdc Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:56 -0800 Subject: [PATCH 1547/1846] iwlwifi: constify remaining config data The HW configuration settings base_params, ht_params and bt_params all should be const, make it so. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 5 +++-- drivers/net/wireless/iwlwifi/iwl-2000.c | 8 ++++---- drivers/net/wireless/iwlwifi/iwl-5000.c | 5 +++-- drivers/net/wireless/iwlwifi/iwl-6000.c | 11 ++++++----- drivers/net/wireless/iwlwifi/iwl-shared.h | 6 +++--- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 5039a9a47767..5abebc355f7f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -157,7 +157,7 @@ static struct iwl_lib_ops iwl1000_lib = { .temperature = iwlagn_temperature, }; -static struct iwl_base_params iwl1000_base_params = { +static const struct iwl_base_params iwl1000_base_params = { .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, .eeprom_size = OTP_LOW_IMAGE_SIZE, @@ -172,7 +172,8 @@ static struct iwl_base_params iwl1000_base_params = { .max_event_log_size = 128, .wd_disable = true, }; -static struct iwl_ht_params iwl1000_ht_params = { + +static const struct iwl_ht_params iwl1000_ht_params = { .ht_greenfield_support = true, .use_rts_for_aggregation = true, /* use rts/cts protection */ .smps_mode = IEEE80211_SMPS_DYNAMIC, diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index c1739626aeb4..446d010dfe84 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -175,7 +175,7 @@ static struct iwl_lib_ops iwl2030_lib = { .temperature = iwlagn_temperature, }; -static struct iwl_base_params iwl2000_base_params = { +static const struct iwl_base_params iwl2000_base_params = { .eeprom_size = OTP_LOW_IMAGE_SIZE, .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, @@ -194,7 +194,7 @@ static struct iwl_base_params iwl2000_base_params = { }; -static struct iwl_base_params iwl2030_base_params = { +static const struct iwl_base_params iwl2030_base_params = { .eeprom_size = OTP_LOW_IMAGE_SIZE, .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, @@ -212,12 +212,12 @@ static struct iwl_base_params iwl2030_base_params = { .hd_v2 = true, }; -static struct iwl_ht_params iwl2000_ht_params = { +static const struct iwl_ht_params iwl2000_ht_params = { .ht_greenfield_support = true, .use_rts_for_aggregation = true, /* use rts/cts protection */ }; -static struct iwl_bt_params iwl2030_bt_params = { +static const struct iwl_bt_params iwl2030_bt_params = { /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */ .advanced_bt_coexist = true, .agg_time_limit = BT_AGG_THRESHOLD_DEF, diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index fc6ec07de877..821ed3a36e52 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -310,7 +310,7 @@ static struct iwl_lib_ops iwl5150_lib = { .temperature = iwl5150_temperature, }; -static struct iwl_base_params iwl5000_base_params = { +static const struct iwl_base_params iwl5000_base_params = { .eeprom_size = IWLAGN_EEPROM_IMG_SIZE, .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, @@ -323,7 +323,8 @@ static struct iwl_base_params iwl5000_base_params = { .no_idle_support = true, .wd_disable = true, }; -static struct iwl_ht_params iwl5000_ht_params = { + +static const struct iwl_ht_params iwl5000_ht_params = { .ht_greenfield_support = true, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index a64f0f281249..d2e24824fc08 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -271,7 +271,7 @@ static struct iwl_lib_ops iwl6030_lib = { .temperature = iwlagn_temperature, }; -static struct iwl_base_params iwl6000_base_params = { +static const struct iwl_base_params iwl6000_base_params = { .eeprom_size = OTP_LOW_IMAGE_SIZE, .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, @@ -288,7 +288,7 @@ static struct iwl_base_params iwl6000_base_params = { .shadow_reg_enable = true, }; -static struct iwl_base_params iwl6050_base_params = { +static const struct iwl_base_params iwl6050_base_params = { .eeprom_size = OTP_LOW_IMAGE_SIZE, .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, @@ -304,7 +304,8 @@ static struct iwl_base_params iwl6050_base_params = { .max_event_log_size = 1024, .shadow_reg_enable = true, }; -static struct iwl_base_params iwl6000_g2_base_params = { + +static const struct iwl_base_params iwl6000_g2_base_params = { .eeprom_size = OTP_LOW_IMAGE_SIZE, .num_of_queues = IWLAGN_NUM_QUEUES, .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES, @@ -321,12 +322,12 @@ static struct iwl_base_params iwl6000_g2_base_params = { .shadow_reg_enable = true, }; -static struct iwl_ht_params iwl6000_ht_params = { +static const struct iwl_ht_params iwl6000_ht_params = { .ht_greenfield_support = true, .use_rts_for_aggregation = true, /* use rts/cts protection */ }; -static struct iwl_bt_params iwl6000_bt_params = { +static const struct iwl_bt_params iwl6000_bt_params = { /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */ .advanced_bt_coexist = true, .agg_time_limit = BT_AGG_THRESHOLD_DEF, diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 7c9502703e82..5a67fa141744 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -366,10 +366,10 @@ struct iwl_cfg { const struct iwl_lib_ops *lib; void (*additional_nic_config)(struct iwl_priv *priv); /* params not likely to change within a device family */ - struct iwl_base_params *base_params; + const struct iwl_base_params *base_params; /* params likely to change within a device family */ - struct iwl_ht_params *ht_params; - struct iwl_bt_params *bt_params; + const struct iwl_ht_params *ht_params; + const struct iwl_bt_params *bt_params; enum iwl_pa_type pa_type; /* if used set to IWL_PA_SYSTEM */ const bool need_temp_offset_calib; /* if used set to true */ const bool no_xtal_calib; -- GitLab From f47208934b2aba432722baeb86a72fcbfd26b593 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:57 -0800 Subject: [PATCH 1548/1846] iwlwifi: fix notification wait bug In "iwlwifi: consolidate the start_device flow" Emmanuel added the return if the fw isn't there but forgot to take into account that the struct for notification wait needs to be added only after the check -- fix that. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-ucode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index c1c5e1f2223a..686d456d226e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -533,9 +533,6 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv, int ret; enum iwl_ucode_type old_type; - iwl_init_notification_wait(priv->shrd, &alive_wait, REPLY_ALIVE, - iwl_alive_fn, &alive_data); - old_type = priv->shrd->ucode_type; priv->shrd->ucode_type = ucode_type; fw = iwl_get_ucode_image(priv, ucode_type); @@ -543,6 +540,9 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv, if (!fw) return -EINVAL; + iwl_init_notification_wait(priv->shrd, &alive_wait, REPLY_ALIVE, + iwl_alive_fn, &alive_data); + ret = iwl_trans_start_fw(trans(priv), fw); if (ret) { priv->shrd->ucode_type = old_type; -- GitLab From 4bd14dd5f77bbe3c51f50f4e86d3b8960e6a518c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:58 -0800 Subject: [PATCH 1549/1846] iwlwifi: abstract out notification wait support This will be sharable, but needs to live in the op_mode as it is dependent on command processing. Make a library out of the notification wait code. Since I wrote all of the code originally and only Intel employees changed it, we can also relicense it to dual BSD/GPL. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/Makefile | 1 + drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 24 +-- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 11 +- drivers/net/wireless/iwlwifi/iwl-core.c | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 3 + drivers/net/wireless/iwlwifi/iwl-notif-wait.c | 157 ++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-notif-wait.h | 130 +++++++++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 55 ------ drivers/net/wireless/iwlwifi/iwl-testmode.c | 10 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 81 +-------- 10 files changed, 314 insertions(+), 160 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-notif-wait.c create mode 100644 drivers/net/wireless/iwlwifi/iwl-notif-wait.h diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index f2a903d01aa9..85d163ed3db1 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -14,6 +14,7 @@ iwlwifi-objs += iwl-1000.o iwlwifi-objs += iwl-2000.o iwlwifi-objs += iwl-pci.o iwlwifi-objs += iwl-drv.o +iwlwifi-objs += iwl-notif-wait.o iwlwifi-objs += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 5c9c88b8609f..f17142bb5df1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1142,9 +1142,7 @@ 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->shrd->notif_wait_lock); - INIT_LIST_HEAD(&priv->shrd->notif_waits); - init_waitqueue_head(&priv->shrd->notif_waitq); + iwl_notification_wait_init(&priv->notif_wait); /* Set up BT Rx handlers */ if (cfg(priv)->lib->bt_rx_handler_setup) @@ -1164,25 +1162,7 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, * even if the RX handler consumes the RXB we have * access to it in the notification wait entry. */ - if (!list_empty(&priv->shrd->notif_waits)) { - struct iwl_notification_wait *w; - - 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, - "Notif: %s, 0x%02x - wake the callers up\n", - get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - w->triggered = true; - if (w->fn) - w->fn(priv, pkt, w->fn_data); - } - spin_unlock(&priv->shrd->notif_wait_lock); - - wake_up_all(&priv->shrd->notif_waitq); - } + iwl_notification_wait_notify(&priv->notif_wait, pkt); if (priv->pre_rx_handler && priv->shrd->ucode_owner == IWL_OWNERSHIP_TM) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index e191d394cfa0..9d955fa387e5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -60,9 +60,9 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, u8 old_dev_type = send->dev_type; int ret; - iwl_init_notification_wait(priv->shrd, &disable_wait, - REPLY_WIPAN_DEACTIVATION_COMPLETE, - NULL, NULL); + iwl_init_notification_wait(&priv->notif_wait, &disable_wait, + REPLY_WIPAN_DEACTIVATION_COMPLETE, + NULL, NULL); send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; send->dev_type = RXON_DEV_TYPE_P2P; @@ -74,9 +74,10 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, if (ret) { IWL_ERR(priv, "Error disabling PAN (%d)\n", ret); - iwl_remove_notification(priv->shrd, &disable_wait); + iwl_remove_notification(&priv->notif_wait, &disable_wait); } else { - ret = iwl_wait_notification(priv->shrd, &disable_wait, HZ); + ret = iwl_wait_notification(&priv->notif_wait, + &disable_wait, HZ); if (ret) IWL_ERR(priv, "Timed out waiting for PAN disable\n"); } diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 2422eef6d15f..5f0e07c0b50c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -845,7 +845,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status); - iwl_abort_notification_waits(priv->shrd); + iwl_abort_notification_waits(&priv->notif_wait); /* 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 0c397fd635a3..c57e605b26b7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -51,6 +51,7 @@ #include "iwl-trans.h" #include "iwl-shared.h" #include "iwl-op-mode.h" +#include "iwl-notif-wait.h" struct iwl_tx_queue; @@ -739,6 +740,8 @@ struct iwl_priv { struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); + struct iwl_notif_wait_data notif_wait; + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; /* spectrum measurement report caching */ diff --git a/drivers/net/wireless/iwlwifi/iwl-notif-wait.c b/drivers/net/wireless/iwlwifi/iwl-notif-wait.c new file mode 100644 index 000000000000..88dc4a0f96b4 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-notif-wait.c @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * 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) 2007 - 2012 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 - 2012 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 "iwl-notif-wait.h" + + +void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_wait) +{ + spin_lock_init(¬if_wait->notif_wait_lock); + INIT_LIST_HEAD(¬if_wait->notif_waits); + init_waitqueue_head(¬if_wait->notif_waitq); +} + +void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_wait, + struct iwl_rx_packet *pkt) +{ + if (!list_empty(¬if_wait->notif_waits)) { + struct iwl_notification_wait *w; + + spin_lock(¬if_wait->notif_wait_lock); + list_for_each_entry(w, ¬if_wait->notif_waits, list) { + if (w->cmd != pkt->hdr.cmd) + continue; + w->triggered = true; + if (w->fn) + w->fn(notif_wait, pkt, w->fn_data); + } + spin_unlock(¬if_wait->notif_wait_lock); + + wake_up_all(¬if_wait->notif_waitq); + } +} + +void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_wait) +{ + unsigned long flags; + struct iwl_notification_wait *wait_entry; + + spin_lock_irqsave(¬if_wait->notif_wait_lock, flags); + list_for_each_entry(wait_entry, ¬if_wait->notif_waits, list) + wait_entry->aborted = true; + spin_unlock_irqrestore(¬if_wait->notif_wait_lock, flags); + + wake_up_all(¬if_wait->notif_waitq); +} + + +void +iwl_init_notification_wait(struct iwl_notif_wait_data *notif_wait, + struct iwl_notification_wait *wait_entry, + u8 cmd, + void (*fn)(struct iwl_notif_wait_data *notif_wait, + 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(¬if_wait->notif_wait_lock); + list_add(&wait_entry->list, ¬if_wait->notif_waits); + spin_unlock_bh(¬if_wait->notif_wait_lock); +} + +int iwl_wait_notification(struct iwl_notif_wait_data *notif_wait, + struct iwl_notification_wait *wait_entry, + unsigned long timeout) +{ + int ret; + + ret = wait_event_timeout(notif_wait->notif_waitq, + wait_entry->triggered || wait_entry->aborted, + timeout); + + spin_lock_bh(¬if_wait->notif_wait_lock); + list_del(&wait_entry->list); + spin_unlock_bh(¬if_wait->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_notif_wait_data *notif_wait, + struct iwl_notification_wait *wait_entry) +{ + spin_lock_bh(¬if_wait->notif_wait_lock); + list_del(&wait_entry->list); + spin_unlock_bh(¬if_wait->notif_wait_lock); +} diff --git a/drivers/net/wireless/iwlwifi/iwl-notif-wait.h b/drivers/net/wireless/iwlwifi/iwl-notif-wait.h new file mode 100644 index 000000000000..419f1ad65441 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-notif-wait.h @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * 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) 2007 - 2012 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 - 2012 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 + * 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 __iwl_notif_wait_h__ +#define __iwl_notif_wait_h__ + +#include + +/* TODO: remove later */ +#include "iwl-commands.h" + +struct iwl_notif_wait_data { + struct list_head notif_waits; + spinlock_t notif_wait_lock; + wait_queue_head_t notif_waitq; +}; + +/** + * 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_notif_wait_data *notif_data, + struct iwl_rx_packet *pkt, void *data); + void *fn_data; + + u8 cmd; + bool triggered, aborted; +}; + + +/* caller functions */ +void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_data); +void iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_data, + struct iwl_rx_packet *pkt); +void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_data); + +/* user functions */ +void __acquires(wait_entry) +iwl_init_notification_wait(struct iwl_notif_wait_data *notif_data, + struct iwl_notification_wait *wait_entry, + u8 cmd, + void (*fn)(struct iwl_notif_wait_data *notif_data, + struct iwl_rx_packet *pkt, void *data), + void *fn_data); + +int __must_check __releases(wait_entry) +iwl_wait_notification(struct iwl_notif_wait_data *notif_data, + struct iwl_notification_wait *wait_entry, + unsigned long timeout); + +void __releases(wait_entry) +iwl_remove_notification(struct iwl_notif_wait_data *notif_data, + struct iwl_notification_wait *wait_entry); + +#endif /* __iwl_notif_wait_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 5a67fa141744..8ffc76079121 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -211,35 +211,6 @@ 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; -}; - /** * enum iwl_pa_type - Power Amplifier type * @IWL_PA_SYSTEM: based on uCode configuration @@ -400,9 +371,6 @@ struct iwl_cfg { * @wait_command_queue: the wait_queue for SYNC host command nad uCode load * @eeprom: pointer to the eeprom/OTP image * @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 * @device_pointers: pointers to ucode event tables */ struct iwl_shared { @@ -428,11 +396,6 @@ 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; - struct { u32 error_event_table; u32 log_event_table; @@ -462,24 +425,6 @@ int iwlagn_hw_valid_rtc_data_addr(u32 addr); void iwl_nic_config(struct iwl_priv *priv); const char *get_cmd_string(u8 cmd); -/* 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); - #define IWL_CMD(x) case x: return #x /***************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 095d71dc99c4..cc049d22151f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -418,23 +418,23 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) struct iwl_notification_wait calib_wait; int ret; - iwl_init_notification_wait(priv->shrd, &calib_wait, - CALIBRATION_COMPLETE_NOTIFICATION, - NULL, NULL); + iwl_init_notification_wait(&priv->notif_wait, &calib_wait, + CALIBRATION_COMPLETE_NOTIFICATION, + NULL, NULL); ret = iwl_init_alive_start(priv); if (ret) { IWL_ERR(priv, "Fail init calibration: %d\n", ret); goto cfg_init_calib_error; } - ret = iwl_wait_notification(priv->shrd, &calib_wait, 2 * HZ); + ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, 2 * HZ); if (ret) IWL_ERR(priv, "Error detecting" " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); return ret; cfg_init_calib_error: - iwl_remove_notification(priv->shrd, &calib_wait); + iwl_remove_notification(&priv->notif_wait, &calib_wait); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 686d456d226e..4d34327f9425 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -29,7 +29,6 @@ #include #include -#include #include "iwl-dev.h" #include "iwl-core.h" @@ -434,10 +433,12 @@ struct iwl_alive_data { u8 subtype; }; -static void iwl_alive_fn(struct iwl_priv *priv, +static void iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, struct iwl_rx_packet *pkt, void *data) { + struct iwl_priv *priv = + container_of(notif_wait, struct iwl_priv, notif_wait); struct iwl_alive_data *alive_data = data; struct iwl_alive_resp *palive; @@ -457,70 +458,6 @@ 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) @@ -540,13 +477,13 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv, if (!fw) return -EINVAL; - iwl_init_notification_wait(priv->shrd, &alive_wait, REPLY_ALIVE, + iwl_init_notification_wait(&priv->notif_wait, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); ret = iwl_trans_start_fw(trans(priv), fw); if (ret) { priv->shrd->ucode_type = old_type; - iwl_remove_notification(priv->shrd, &alive_wait); + iwl_remove_notification(&priv->notif_wait, &alive_wait); return ret; } @@ -554,7 +491,7 @@ int iwl_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 = iwl_wait_notification(priv->shrd, &alive_wait, + ret = iwl_wait_notification(&priv->notif_wait, &alive_wait, UCODE_ALIVE_TIMEOUT); if (ret) { priv->shrd->ucode_type = old_type; @@ -608,7 +545,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv) if (priv->shrd->ucode_type != IWL_UCODE_NONE) return 0; - iwl_init_notification_wait(priv->shrd, &calib_wait, + iwl_init_notification_wait(&priv->notif_wait, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); @@ -625,13 +562,13 @@ int iwl_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 = iwl_wait_notification(priv->shrd, &calib_wait, + ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, UCODE_CALIB_TIMEOUT); goto out; error: - iwl_remove_notification(priv->shrd, &calib_wait); + iwl_remove_notification(&priv->notif_wait, &calib_wait); out: /* Whatever happened, stop the device */ iwl_trans_stop_device(trans(priv)); -- GitLab From 947a9407e34e7c8d44a0f4d95bbb1e5eae5459c0 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:30:59 -0800 Subject: [PATCH 1550/1846] iwlwifi: move ucode_owner to priv The transport doesn't really need to know as we can enforce it in the command wrapper. Move the ucode_owner variable into priv and do all enforcing there. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 6 ++++++ drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 ++ drivers/net/wireless/iwlwifi/iwl-dev.h | 4 ++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 4 ---- drivers/net/wireless/iwlwifi/iwl-testmode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 6 ------ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 - 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 90f1f8a506f2..dec2693c8cba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1306,6 +1306,12 @@ int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) if (cmd->flags & CMD_SYNC) lockdep_assert_held(&priv->mutex); + if (priv->ucode_owner == IWL_OWNERSHIP_TM && + !(cmd->flags & CMD_ON_DEMAND)) { + IWL_DEBUG_HC(priv, "tm own the uCode, no regular hcmd send\n"); + return -EIO; + } + return iwl_trans_send_cmd(trans(priv), cmd); } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index f17142bb5df1..08de306c4c22 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_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, iwl_notification_wait_notify(&priv->notif_wait, pkt); if (priv->pre_rx_handler && - priv->shrd->ucode_owner == IWL_OWNERSHIP_TM) + priv->ucode_owner == IWL_OWNERSHIP_TM) priv->pre_rx_handler(priv, rxb); else { /* Based on type of command response or notification, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ce62a2fcd67f..afded2947edd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1053,6 +1053,8 @@ static int iwl_init_drv(struct iwl_priv *priv) priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; priv->agg_tids_count = 0; + priv->ucode_owner = IWL_OWNERSHIP_DRIVER; + /* initialize force reset */ priv->force_reset[IWL_RF_RESET].reset_duration = IWL_DELAY_NEXT_FORCE_RF_RESET; diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index c57e605b26b7..a301daf18fbc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -748,6 +748,10 @@ struct iwl_priv { struct iwl_spectrum_notification measure_report; u8 measurement_status; +#define IWL_OWNERSHIP_DRIVER 0 +#define IWL_OWNERSHIP_TM 1 + u8 ucode_owner; + /* ucode beacon time */ u32 ucode_beacon_time; int missed_beacon_threshold; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 8ffc76079121..a648a2b4934a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -356,7 +356,6 @@ struct iwl_cfg { /** * struct iwl_shared - shared fields for all the layers of the driver * - * @ucode_owner: IWL_OWNERSHIP_* * @cmd_queue: command queue number * @status: STATUS_* * @wowlan: are we running wowlan uCode @@ -374,9 +373,6 @@ struct iwl_cfg { * @device_pointers: pointers to ucode event tables */ struct iwl_shared { -#define IWL_OWNERSHIP_DRIVER 0 -#define IWL_OWNERSHIP_TM 1 - u8 ucode_owner; u8 cmd_queue; unsigned long status; u8 valid_contexts; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index cc049d22151f..63868df32263 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -770,7 +770,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) - priv->shrd->ucode_owner = owner; + priv->ucode_owner = owner; else { IWL_ERR(priv, "Invalid owner\n"); return -EINVAL; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 7feeb2d52146..73febc9726cb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -685,12 +685,6 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) return -EIO; } - if ((trans->shrd->ucode_owner == IWL_OWNERSHIP_TM) && - !(cmd->flags & CMD_ON_DEMAND)) { - IWL_DEBUG_HC(trans, "tm own the uCode, no regular hcmd send\n"); - return -EIO; - } - copy_size = sizeof(out_cmd->hdr); cmd_size = sizeof(out_cmd->hdr); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 6090e9800ce4..598a92d50895 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1022,7 +1022,6 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, IWL_TRANS_GET_PCIE_TRANS(trans); bool hw_rfkill; - trans->shrd->ucode_owner = IWL_OWNERSHIP_DRIVER; trans_pcie->ac_to_queue[IWL_RXON_CTX_BSS] = iwlagn_bss_ac_to_queue; trans_pcie->ac_to_queue[IWL_RXON_CTX_PAN] = iwlagn_pan_ac_to_queue; -- GitLab From 13df1aab4aa3cd99693c0cdeb7177e5359218431 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:00 -0800 Subject: [PATCH 1551/1846] iwlwifi: move all uCode load variables All variables related to uCode loading (the waitqueue and done indication) should be in the PCI-E transport's private data as this is transport specific. Move them there. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 6 ++++++ drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 8 +++++--- drivers/net/wireless/iwlwifi/iwl-trans.h | 3 --- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index a648a2b4934a..6b1c29b9bae8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -367,7 +367,7 @@ struct iwl_cfg { * @nic: pointer to the nic data * @hw_params: see struct iwl_hw_params * @lock: protect general shared data - * @wait_command_queue: the wait_queue for SYNC host command nad uCode load + * @wait_command_queue: the wait_queue for SYNC host commands * @eeprom: pointer to the eeprom/OTP image * @ucode_type: indicator of loaded ucode image * @device_pointers: pointers to ucode event tables diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 44952c371d33..93f49acac31b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "iwl-fh.h" @@ -243,6 +244,8 @@ struct iwl_tx_queue { * queue_stop_count: tracks what SW queue is stopped * @pci_dev: basic pci-network driver stuff * @hw_base: pci hardware address support + * @ucode_write_complete: indicates that the ucode has been copied. + * @ucode_write_waitq: wait queue for uCode load */ struct iwl_trans_pcie { struct iwl_rx_queue rxq; @@ -279,6 +282,9 @@ struct iwl_trans_pcie { /* PCI bus related data */ struct pci_dev *pci_dev; void __iomem *hw_base; + + bool ucode_write_complete; + wait_queue_head_t ucode_write_waitq; }; #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index f1456211c294..83cc60e8f607 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1114,8 +1114,8 @@ void iwl_irq_tasklet(struct iwl_trans *trans) isr_stats->tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ - trans->ucode_write_complete = 1; - wake_up(&trans->shrd->wait_command_queue); + trans_pcie->ucode_write_complete = true; + wake_up(&trans_pcie->ucode_write_waitq); } if (inta & ~handled) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 598a92d50895..6ee46cba2c21 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -947,11 +947,12 @@ static const u8 iwlagn_pan_ac_to_queue[] = { static int iwl_load_section(struct iwl_trans *trans, const char *name, const struct fw_desc *image, u32 dst_addr) { + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); dma_addr_t phy_addr = image->p_addr; u32 byte_cnt = image->len; int ret; - trans->ucode_write_complete = 0; + trans_pcie->ucode_write_complete = false; iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), @@ -982,8 +983,8 @@ static int iwl_load_section(struct iwl_trans *trans, const char *name, FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); IWL_DEBUG_FW(trans, "%s uCode section being loaded...\n", name); - ret = wait_event_timeout(trans->shrd->wait_command_queue, - trans->ucode_write_complete, 5 * HZ); + ret = wait_event_timeout(trans_pcie->ucode_write_waitq, + trans_pcie->ucode_write_complete, 5 * HZ); if (!ret) { IWL_ERR(trans, "Could not load the %s uCode section\n", name); @@ -2255,6 +2256,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, trans->shrd = shrd; trans_pcie->trans = trans; spin_lock_init(&trans_pcie->irq_lock); + init_waitqueue_head(&trans_pcie->ucode_write_waitq); /* W/A - seems to solve weird behavior. We need to remove this if we * don't want to stay in L1 all the time. This wastes a lot of power */ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index a8d476a44c58..dcad69491786 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -338,7 +338,6 @@ enum iwl_trans_state { * @hw_id: a u32 with the ID of the device / subdevice. * Set during transport allocation. * @hw_id_str: a string with info about HW ID. Set during transport allocation. - * @ucode_write_complete: indicates that the ucode has been copied. * @nvm_device_type: indicates OTP or eeprom * @pm_support: set to true in start_hw if link pm is supported */ @@ -355,8 +354,6 @@ struct iwl_trans { u32 hw_id; char hw_id_str[52]; - u8 ucode_write_complete; - int nvm_device_type; bool pm_support; -- GitLab From 7559553660da6cda3aa798c4e8eb681b63402819 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:01 -0800 Subject: [PATCH 1552/1846] iwlwifi: move irq to PCIe Even if the variable might also be used by other transports, there's no need for anything outside of the transport itself to access it, so move it into the private area. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 12 ++++++------ drivers/net/wireless/iwlwifi/iwl-trans.h | 2 -- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 93f49acac31b..d13b8d1f08fa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -231,6 +231,7 @@ struct iwl_tx_queue { * @rxq: all the RX queue data * @rx_replenish: work that will be called when buffers need to be allocated * @trans: pointer to the generic transport area + * @irq - the irq number for the device * @irq_requested: true when the irq has been requested * @scd_base_addr: scheduler sram base address in SRAM * @scd_bc_tbls: pointer to the byte count table of the scheduler @@ -262,6 +263,7 @@ struct iwl_trans_pcie { struct tasklet_struct irq_tasklet; struct isr_statistics isr_stats; + unsigned int irq; spinlock_t irq_lock; u32 inta_mask; u32 scd_base_addr; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 6ee46cba2c21..16cb4a3511e1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1294,7 +1294,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* wait to make sure we flush pending tasklet*/ - synchronize_irq(trans->irq); + synchronize_irq(trans_pcie->irq); tasklet_kill(&trans_pcie->irq_tasklet); cancel_work_sync(&trans_pcie->rx_replenish); @@ -1513,11 +1513,11 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) iwl_alloc_isr_ict(trans); - err = request_irq(trans->irq, iwl_isr_ict, IRQF_SHARED, + err = request_irq(trans_pcie->irq, iwl_isr_ict, IRQF_SHARED, DRV_NAME, trans); if (err) { IWL_ERR(trans, "Error allocating IRQ %d\n", - trans->irq); + trans_pcie->irq); goto error; } @@ -1540,7 +1540,7 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) return err; err_free_irq: - free_irq(trans->irq, trans); + free_irq(trans_pcie->irq, trans); error: iwl_free_isr_ict(trans); tasklet_kill(&trans_pcie->irq_tasklet); @@ -1629,7 +1629,7 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans) iwl_trans_pcie_rx_free(trans); #endif if (trans_pcie->irq_requested == true) { - free_irq(trans->irq, trans); + free_irq(trans_pcie->irq, trans); iwl_free_isr_ict(trans); } @@ -2318,7 +2318,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, "pci_enable_msi failed(0X%x)", err); trans->dev = &pdev->dev; - trans->irq = pdev->irq; + trans_pcie->irq = pdev->irq; trans_pcie->pci_dev = pdev; trans->hw_rev = iwl_read32(trans, CSR_HW_REV); trans->hw_id = (pdev->device << 16) + pdev->subsystem_device; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index dcad69491786..a4a9efce7a7c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -334,7 +334,6 @@ enum iwl_trans_state { * @shrd - pointer to iwl_shared which holds shared data from the upper layer * @reg_lock - protect hw register access * @dev - pointer to struct device * that represents the device - * @irq - the irq number for the device * @hw_id: a u32 with the ID of the device / subdevice. * Set during transport allocation. * @hw_id_str: a string with info about HW ID. Set during transport allocation. @@ -349,7 +348,6 @@ struct iwl_trans { spinlock_t reg_lock; struct device *dev; - unsigned int irq; u32 hw_rev; u32 hw_id; char hw_id_str[52]; -- GitLab From f8d7c1a18d5e77b17b5cc1ebefa21eaea7f2d0fa Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:02 -0800 Subject: [PATCH 1553/1846] iwlwifi: move packet to transport The base packet structure will (hopefully) be the same for all transports, but what is in it differs. Remove the union of all the possible contents and move the packet itself into the transport header file. This requires changing all users of the union to just use pkt->data. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 50 +++++------ drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 8 +- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 4 +- drivers/net/wireless/iwlwifi/iwl-commands.h | 84 ------------------- drivers/net/wireless/iwlwifi/iwl-notif-wait.h | 3 +- drivers/net/wireless/iwlwifi/iwl-scan.c | 21 +++-- drivers/net/wireless/iwlwifi/iwl-trans.h | 56 +++++++++++++ drivers/net/wireless/iwlwifi/iwl-ucode.c | 4 +- 9 files changed, 103 insertions(+), 129 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index dec2693c8cba..b2ee1f9373c0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -710,7 +710,7 @@ int iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_bt_coex_profile_notif *coex = &pkt->u.bt_coex_profile_notif; + struct iwl_bt_coex_profile_notif *coex = (void *)pkt->data; struct iwl_bt_uart_msg *uart_msg = &coex->last_bt_uart_msg; if (priv->bt_enable_flag == IWLAGN_BT_FLAG_COEX_MODE_DISABLED) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 08de306c4c22..521c820ea10a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -135,14 +135,15 @@ static int iwlagn_rx_reply_error(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct iwl_error_resp *err_resp = (void *)pkt->data; IWL_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), - 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)); + le32_to_cpu(err_resp->error_type), + get_cmd_string(err_resp->cmd_id), + err_resp->cmd_id, + le16_to_cpu(err_resp->bad_cmd_seq_num), + le32_to_cpu(err_resp->error_info)); return 0; } @@ -150,7 +151,7 @@ static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_csa_notification *csa = &(pkt->u.csa_notif); + struct iwl_csa_notification *csa = (void *)pkt->data; /* * MULTI-FIXME * See iwlagn_mac_channel_switch. @@ -181,7 +182,7 @@ static int iwlagn_rx_spectrum_measure_notif(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif); + struct iwl_spectrum_notification *report = (void *)pkt->data; if (!report->state) { IWL_DEBUG_11H(priv, @@ -200,7 +201,7 @@ static int iwlagn_rx_pm_sleep_notif(struct iwl_priv *priv, { #ifdef CONFIG_IWLWIFI_DEBUG struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); + struct iwl_sleep_notification *sleep = (void *)pkt->data; IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif @@ -217,7 +218,7 @@ static int iwlagn_rx_pm_debug_statistics_notif(struct iwl_priv *priv, IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " "notification for %s:\n", len, get_cmd_string(pkt->hdr.cmd)); - iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len); + iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->data, len); return 0; } @@ -226,7 +227,7 @@ static int iwlagn_rx_beacon_notif(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwlagn_beacon_notif *beacon = (void *)pkt->u.raw; + struct iwlagn_beacon_notif *beacon = (void *)pkt->data; #ifdef CONFIG_IWLWIFI_DEBUG u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status); u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); @@ -515,7 +516,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, if (len == sizeof(struct iwl_bt_notif_statistics)) { struct iwl_bt_notif_statistics *stats; - stats = &pkt->u.stats_bt; + stats = (void *)&pkt->data; flag = &stats->flag; common = &stats->general.common; rx_non_phy = &stats->rx.general.common; @@ -533,7 +534,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, #endif } else if (len == sizeof(struct iwl_notif_statistics)) { struct iwl_notif_statistics *stats; - stats = &pkt->u.stats; + stats = (void *)&pkt->data; flag = &stats->flag; common = &stats->general.common; rx_non_phy = &stats->rx.general; @@ -601,8 +602,9 @@ static int iwlagn_rx_reply_statistics(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct iwl_notif_statistics *stats = (void *)pkt->data; - if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { + if (le32_to_cpu(stats->flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_DEBUGFS memset(&priv->accum_stats, 0, sizeof(priv->accum_stats)); @@ -624,7 +626,8 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); + struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; + u32 flags = le32_to_cpu(card_state_notif->flags); unsigned long status = priv->shrd->status; IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", @@ -678,9 +681,8 @@ static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv, { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_missed_beacon_notif *missed_beacon; + struct iwl_missed_beacon_notif *missed_beacon = (void *)pkt->data; - missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > priv->missed_beacon_threshold) { IWL_DEBUG_CALIB(priv, @@ -704,7 +706,7 @@ static int iwlagn_rx_reply_rx_phy(struct iwl_priv *priv, struct iwl_rx_packet *pkt = rxb_addr(rxb); priv->last_phy_res_valid = true; - memcpy(&priv->last_phy_res, pkt->u.raw, + memcpy(&priv->last_phy_res, pkt->data, sizeof(struct iwl_rx_phy_res)); return 0; } @@ -949,12 +951,12 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv, * received. */ if (pkt->hdr.cmd == REPLY_RX) { - phy_res = (struct iwl_rx_phy_res *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + phy_res = (struct iwl_rx_phy_res *)pkt->data; + header = (struct ieee80211_hdr *)(pkt->data + 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) + + rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*phy_res) + phy_res->cfg_phy_cnt + len); ampdu_status = le32_to_cpu(rx_pkt_status); } else { @@ -963,10 +965,10 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv, return 0; } phy_res = &priv->last_phy_res; - amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); + amsdu = (struct iwl_rx_mpdu_res_start *)pkt->data; + header = (struct ieee80211_hdr *)(pkt->data + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); + rx_pkt_status = *(__le32 *)(pkt->data + sizeof(*amsdu) + len); ampdu_status = iwlagn_translate_rx_status(priv, le32_to_cpu(rx_pkt_status)); } @@ -1051,7 +1053,7 @@ static int iwlagn_rx_noa_notification(struct iwl_priv *priv, { struct iwl_wipan_noa_data *new_data, *old_data; struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->u.raw; + struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->data; /* no condition -- we're in softirq */ old_data = rcu_dereference_protected(priv->noa_data, true); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 14fbdecccd26..cb6c2300cf44 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -64,6 +64,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, struct iwl_addsta_cmd *addsta, struct iwl_rx_packet *pkt) { + struct iwl_add_sta_resp *add_sta_resp = (void *)pkt->data; u8 sta_id = addsta->sta.sta_id; int ret = -EIO; @@ -78,7 +79,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, spin_lock(&priv->sta_lock); - switch (pkt->u.add_sta.status) { + switch (add_sta_resp->status) { case ADD_STA_SUCCESS_MSK: IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); ret = iwl_sta_ucode_activate(priv, sta_id); @@ -97,7 +98,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, break; default: IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", - pkt->u.add_sta.status); + add_sta_resp->status); break; } @@ -460,7 +461,8 @@ static int iwl_send_remove_station(struct iwl_priv *priv, } if (!ret) { - switch (pkt->u.rem_sta.status) { + struct iwl_rem_sta_resp *rem_sta_resp = (void *)pkt->data; + switch (rem_sta_resp->status) { case REM_STA_SUCCESS_MSK: if (!temporary) { spin_lock_bh(&priv->sta_lock); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 151400cf51e0..0ef59d9a99ee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -983,7 +983,7 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int cmd_index __maybe_unused = SEQ_TO_INDEX(sequence); - struct iwlagn_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + struct iwlagn_tx_resp *tx_resp = (void *)pkt->data; struct ieee80211_hdr *hdr; u32 status = le16_to_cpu(tx_resp->status.status); u16 ssn = iwlagn_get_scd_ssn(tx_resp); @@ -1111,7 +1111,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; + struct iwl_compressed_ba_resp *ba_resp = (void *)pkt->data; struct iwl_ht_agg *agg; struct sk_buff_head reclaimed_skbs; struct ieee80211_tx_info *info; diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index aa8993065cdf..70ba962732f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -206,48 +206,6 @@ enum { /* iwl_cmd_header flags value */ #define IWL_CMD_FAILED_MSK 0x40 -#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_RX_FRAME cpu_to_le16(0x8000) - -/** - * struct iwl_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 { - u8 cmd; /* Command ID: REPLY_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 REPLY_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 index - position within TX queue - * 8:12 TX queue id - * 13:14 reserved - * 15 unsolicited RX or uCode-originated notification - */ - __le16 sequence; - - /* command or response/notification data follows immediately */ - u8 data[0]; -} __packed; - - /** * iwlagn rate_n_flags bit fields * @@ -3893,48 +3851,6 @@ struct iwlagn_wowlan_kek_kck_material_cmd { __le64 replay_ctr; } __packed; -/****************************************************************************** - * (13) - * Union of all expected notifications/responses: - * - *****************************************************************************/ -#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */ - -struct iwl_rx_packet { - /* - * 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 iwl_cmd_header hdr; - union { - 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_bt_notif_statistics stats_bt; - struct iwl_compressed_ba_resp compressed_ba; - struct iwl_missed_beacon_notif missed_beacon; - struct iwl_coex_medium_notification coex_medium_notif; - struct iwl_coex_event_resp coex_event; - struct iwl_bt_coex_profile_notif bt_coex_profile_notif; - __le32 status; - u8 raw[0]; - } u; -} __packed; - int iwl_agn_check_rxon_cmd(struct iwl_priv *priv); /* diff --git a/drivers/net/wireless/iwlwifi/iwl-notif-wait.h b/drivers/net/wireless/iwlwifi/iwl-notif-wait.h index 419f1ad65441..5e8af957aa7b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-notif-wait.h +++ b/drivers/net/wireless/iwlwifi/iwl-notif-wait.h @@ -64,8 +64,7 @@ #include -/* TODO: remove later */ -#include "iwl-commands.h" +#include "iwl-trans.h" struct iwl_notif_wait_data { struct list_head notif_waits; diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 6cf2cb318882..91a14577b8a8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -57,11 +57,11 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) { int ret; - struct iwl_rx_packet *pkt; struct iwl_host_cmd cmd = { .id = REPLY_SCAN_ABORT_CMD, .flags = CMD_SYNC | CMD_WANT_SKB, }; + __le32 *status; /* Exit instantly with error when device is not ready * to receive scan abort command or it does not perform @@ -76,15 +76,16 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) if (ret) return ret; - pkt = cmd.resp_pkt; - if (pkt->u.status != CAN_ABORT_STATUS) { + status = (void *)cmd.resp_pkt->data; + if (*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. */ - IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); + IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", + le32_to_cpu(*status)); ret = -EIO; } @@ -265,8 +266,7 @@ static int iwl_rx_reply_scan(struct iwl_priv *priv, { #ifdef CONFIG_IWLWIFI_DEBUG struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanreq_notification *notif = - (struct iwl_scanreq_notification *)pkt->u.raw; + struct iwl_scanreq_notification *notif = (void *)pkt->data; IWL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); #endif @@ -279,8 +279,8 @@ static int iwl_rx_scan_start_notif(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanstart_notification *notif = - (struct iwl_scanstart_notification *)pkt->u.raw; + struct iwl_scanstart_notification *notif = (void *)pkt->data; + priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); IWL_DEBUG_SCAN(priv, "Scan start: " "%d [802.11%s] " @@ -307,8 +307,7 @@ static int iwl_rx_scan_results_notif(struct iwl_priv *priv, { #ifdef CONFIG_IWLWIFI_DEBUG struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanresults_notification *notif = - (struct iwl_scanresults_notification *)pkt->u.raw; + struct iwl_scanresults_notification *notif = (void *)pkt->data; IWL_DEBUG_SCAN(priv, "Scan ch.res: " "%d [802.11%s] " @@ -332,7 +331,7 @@ static int iwl_rx_scan_complete_notif(struct iwl_priv *priv, struct iwl_device_cmd *cmd) { struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; + struct iwl_scancomplete_notification *scan_notif = (void *)pkt->data; IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index a4a9efce7a7c..15bb208ab347 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -122,6 +122,62 @@ struct dentry; #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 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_RX_FRAME cpu_to_le16(0x8000) + +/** + * struct iwl_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 { + u8 cmd; /* Command ID: REPLY_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 REPLY_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 index - position within TX queue + * 8:12 TX queue id + * 13:14 reserved + * 15 unsolicited RX or uCode-originated notification + */ + __le16 sequence; +} __packed; + + +#define FH_RSCSR_FRAME_SIZE_MSK 0x00003FFF /* bits 0-13 */ + +struct iwl_rx_packet { + /* + * 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 iwl_cmd_header hdr; + u8 data[]; +} __packed; /** * enum CMD_MODE - how to send the host commands ? diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 4d34327f9425..8267dbe869d5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -186,7 +186,7 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv, 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; + struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->data; int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; /* reduce the size of the length field itself */ @@ -442,7 +442,7 @@ static void iwl_alive_fn(struct iwl_notif_wait_data *notif_wait, struct iwl_alive_data *alive_data = data; struct iwl_alive_resp *palive; - palive = &pkt->u.alive_frame; + palive = (void *)pkt->data; IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", -- GitLab From ecdb975c92c6ff63673f6380b87ab1e696dfae38 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:03 -0800 Subject: [PATCH 1554/1846] iwlwifi: virtualize nic_config The nic_config sets uCode dependent register bits, so it must be virtual in the op_mode. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 8 ++++++++ drivers/net/wireless/iwlwifi/iwl-core.c | 5 ----- drivers/net/wireless/iwlwifi/iwl-op-mode.h | 9 +++++++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 1 - drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index afded2947edd..98f32e57f7f0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1422,6 +1422,13 @@ static void iwl_cmd_queue_full(struct iwl_op_mode *op_mode) } } +static void iwl_nic_config(struct iwl_op_mode *op_mode) +{ + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + + cfg(priv)->lib->nic_config(priv); +} + const struct iwl_op_mode_ops iwl_dvm_ops = { .start = iwl_op_mode_dvm_start, .stop = iwl_op_mode_dvm_stop, @@ -1432,6 +1439,7 @@ const struct iwl_op_mode_ops iwl_dvm_ops = { .free_skb = iwl_free_skb, .nic_error = iwl_nic_error, .cmd_queue_full = iwl_cmd_queue_full, + .nic_config = iwl_nic_config, }; /***************************************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 5f0e07c0b50c..f43f51d1570e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1468,11 +1468,6 @@ void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) wiphy_rfkill_set_hw_state(priv->hw->wiphy, state); } -void iwl_nic_config(struct iwl_priv *priv) -{ - cfg(priv)->lib->nic_config(priv); -} - void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) { struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); diff --git a/drivers/net/wireless/iwlwifi/iwl-op-mode.h b/drivers/net/wireless/iwlwifi/iwl-op-mode.h index a4a4907803ca..6ea4163ff56a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-op-mode.h +++ b/drivers/net/wireless/iwlwifi/iwl-op-mode.h @@ -123,6 +123,8 @@ struct iwl_fw; * Must be atomic * @nic_error: error notification. Must be atomic * @cmd_queue_full: Called when the command queue gets full. Must be atomic. + * @nic_config: configure NIC, called before firmware is started. + * May sleep */ struct iwl_op_mode_ops { struct iwl_op_mode *(*start)(struct iwl_trans *trans, @@ -136,6 +138,7 @@ struct iwl_op_mode_ops { void (*free_skb)(struct iwl_op_mode *op_mode, struct sk_buff *skb); void (*nic_error)(struct iwl_op_mode *op_mode); void (*cmd_queue_full)(struct iwl_op_mode *op_mode); + void (*nic_config)(struct iwl_op_mode *op_mode); }; /** @@ -199,6 +202,12 @@ static inline void iwl_op_mode_cmd_queue_full(struct iwl_op_mode *op_mode) op_mode->ops->cmd_queue_full(op_mode); } +static inline void iwl_op_mode_nic_config(struct iwl_op_mode *op_mode) +{ + might_sleep(); + op_mode->ops->nic_config(op_mode); +} + /***************************************************** * Op mode layers implementations ******************************************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 6b1c29b9bae8..26894dbadef2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -418,7 +418,6 @@ enum iwl_rxon_context_id { }; int iwlagn_hw_valid_rtc_data_addr(u32 addr); -void iwl_nic_config(struct iwl_priv *priv); const char *get_cmd_string(u8 cmd); #define IWL_CMD(x) case x: return #x diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 16cb4a3511e1..26bb44242090 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -816,7 +816,7 @@ static int iwl_nic_init(struct iwl_trans *trans) iwl_set_pwr_vmain(trans); - iwl_nic_config(priv(trans)); + iwl_op_mode_nic_config(trans->op_mode); #ifndef CONFIG_IWLWIFI_IDI /* Allocate the RX queue, or reset if it is already allocated */ -- GitLab From ef0ef9c8de7e7a069bc2c80a8687c4ab9fa9aff2 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:04 -0800 Subject: [PATCH 1555/1846] iwlwifi: remove priv from shared Finally nothing needs to access priv from shared any more, 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-agn.c | 1 - drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 98f32e57f7f0..4cd375c811e2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1205,7 +1205,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, op_mode->ops = &iwl_dvm_ops; priv = IWL_OP_MODE_GET_DVM(op_mode); priv->shrd = trans->shrd; - priv->shrd->priv = priv; priv->fw = fw; /* TODO: remove fw from shared data later */ priv->shrd->fw = fw; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 26894dbadef2..f8bef163dea3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -378,7 +378,6 @@ struct iwl_shared { u8 valid_contexts; const struct iwl_cfg *cfg; - struct iwl_priv *priv; struct iwl_trans *trans; void *drv; struct iwl_hw_params hw_params; @@ -400,7 +399,6 @@ struct iwl_shared { }; /*Whatever _m is (iwl_trans, iwl_priv, these macros will work */ -#define priv(_m) ((_m)->shrd->priv) #define cfg(_m) ((_m)->shrd->cfg) #define trans(_m) ((_m)->shrd->trans) #define hw_params(_m) ((_m)->shrd->hw_params) -- GitLab From 55bba9eafbaa1d63df8158967fbe69c1a4aa71b1 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:05 -0800 Subject: [PATCH 1556/1846] iwlwifi: remove PA type configuration No need to have a special config variable for the PA type, we can just use the additional NIC config function to config the hardware correctly. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-6000.c | 17 +++++++++-------- drivers/net/wireless/iwlwifi/iwl-shared.h | 12 ------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index d2e24824fc08..d299f05dfc9b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -96,20 +96,21 @@ static void iwl6150_additional_nic_config(struct iwl_priv *priv) CSR_GP_DRIVER_REG_BIT_6050_1x2); } +static void iwl6000i_additional_nic_config(struct iwl_priv *priv) +{ + /* 2x2 IPA phy type */ + iwl_write32(trans(priv), CSR_GP_DRIVER_REG, + CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA); +} + /* NIC configuration for 6000 series */ static void iwl6000_nic_config(struct iwl_priv *priv) { iwl_rf_config(priv); - /* no locking required for register write */ - if (cfg(priv)->pa_type == IWL_PA_INTERNAL) { - /* 2x2 IPA phy type */ - iwl_write32(trans(priv), CSR_GP_DRIVER_REG, - CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA); - } /* do additional nic configuration if needed */ if (cfg(priv)->additional_nic_config) - cfg(priv)->additional_nic_config(priv); + cfg(priv)->additional_nic_config(priv); } static struct iwl_sensitivity_ranges iwl6000_sensitivity = { @@ -473,8 +474,8 @@ const struct iwl_cfg iwl130_bg_cfg = { .eeprom_ver = EEPROM_6000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, \ .lib = &iwl6000_lib, \ + .additional_nic_config = iwl6000i_additional_nic_config,\ .base_params = &iwl6000_base_params, \ - .pa_type = IWL_PA_INTERNAL, \ .led_mode = IWL_LED_BLINK const struct iwl_cfg iwl6000i_2agn_cfg = { diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index f8bef163dea3..ff3394c47635 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -211,16 +211,6 @@ enum iwl_ucode_type { IWL_UCODE_WOWLAN, }; -/** - * enum iwl_pa_type - Power Amplifier type - * @IWL_PA_SYSTEM: based on uCode configuration - * @IWL_PA_INTERNAL: use Internal only - */ -enum iwl_pa_type { - IWL_PA_SYSTEM = 0, - IWL_PA_INTERNAL = 1, -}; - /* * LED mode * IWL_LED_DEFAULT: use device default @@ -301,7 +291,6 @@ struct iwl_base_params { * @base_params: pointer to basic parameters * @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_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 @@ -341,7 +330,6 @@ struct iwl_cfg { /* params likely to change within a device family */ const struct iwl_ht_params *ht_params; const struct iwl_bt_params *bt_params; - enum iwl_pa_type pa_type; /* if used set to IWL_PA_SYSTEM */ const bool need_temp_offset_calib; /* if used set to true */ const bool no_xtal_calib; u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; -- GitLab From eae63b858f9a238a8868846dc5f27fc5e1865659 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:06 -0800 Subject: [PATCH 1557/1846] iwlwifi: don't include iwl-prph.h everywhere It's only needed in a few places. Signed-off-by: Johannes Berg 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-dev.h | 2 -- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 1 + drivers/net/wireless/iwlwifi/iwl-testmode.c | 1 + 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 5abebc355f7f..f6e6f57aade5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -43,6 +43,7 @@ #include "iwl-agn-hw.h" #include "iwl-shared.h" #include "iwl-cfg.h" +#include "iwl-prph.h" /* Highest firmware API version supported */ #define IWL1000_UCODE_API_MAX 6 diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 821ed3a36e52..907a0b22f7b2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -45,6 +45,7 @@ #include "iwl-trans.h" #include "iwl-shared.h" #include "iwl-cfg.h" +#include "iwl-prph.h" /* Highest firmware API version supported */ #define IWL5000_UCODE_API_MAX 5 diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index a301daf18fbc..d1e722bd9f5b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -37,11 +37,9 @@ #include #include #include -#include #include "iwl-eeprom.h" #include "iwl-csr.h" -#include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-agn-hw.h" #include "iwl-led.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index f965ee333920..e2d80849001f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -75,6 +75,7 @@ #include "iwl-agn.h" #include "iwl-eeprom.h" #include "iwl-io.h" +#include "iwl-prph.h" /************************** EEPROM BANDS **************************** * diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 63868df32263..5b06916be610 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -78,6 +78,7 @@ #include "iwl-testmode.h" #include "iwl-trans.h" #include "iwl-fh.h" +#include "iwl-prph.h" /* Periphery registers absolute lower bound. This is used in order to -- GitLab From e7a0d0c4499c4dadec752459c6b15b240db4c3a8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:07 -0800 Subject: [PATCH 1558/1846] iwlwifi: clean up iwl-commands.h Do some cleanups here: * remove an unused prototype * remove some unused constants * clean up includes Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 2 +- drivers/net/wireless/iwlwifi/iwl-commands.h | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index cb6c2300cf44..cf5cc1060cf4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -26,7 +26,7 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * *****************************************************************************/ - +#include #include #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 70ba962732f7..9ed73e5154be 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -69,15 +69,9 @@ #ifndef __iwl_commands_h__ #define __iwl_commands_h__ -#include #include +#include -struct iwl_priv; - -/* Tx rates */ -#define IWL_CCK_RATES 4 -#define IWL_OFDM_RATES 8 -#define IWL_MAX_RATES (IWL_CCK_RATES + IWL_OFDM_RATES) enum { REPLY_ALIVE = 0x1, @@ -3851,8 +3845,6 @@ struct iwlagn_wowlan_kek_kck_material_cmd { __le64 replay_ctr; } __packed; -int iwl_agn_check_rxon_cmd(struct iwl_priv *priv); - /* * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification) */ -- GitLab From b443d8d8a2b4c3def4b47c17a44bb17ea0a3202f Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 6 Mar 2012 13:31:08 -0800 Subject: [PATCH 1559/1846] iwlwifi: make iwl_fill_probe_req static This function is only used in iwl-scan.c, so if we move it up a little in the file it can be made static. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.h | 2 - drivers/net/wireless/iwlwifi/iwl-scan.c | 98 ++++++++++++------------- 2 files changed, 49 insertions(+), 51 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 7259cbf77da4..e0423c4c01c7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -202,8 +202,6 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); void iwl_force_scan_end(struct iwl_priv *priv); void iwl_internal_short_hw_scan(struct iwl_priv *priv); int iwl_force_reset(struct iwl_priv *priv, int mode, bool external); -u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ie, int ie_len, int left); void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); void iwl_setup_scan_deferred_work(struct iwl_priv *priv); void iwl_cancel_scan_deferred_work(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 91a14577b8a8..8c3fb3233d9f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -572,6 +572,53 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv, return added; } +/** + * iwl_fill_probe_req - fill in all required fields and IE for probe request + */ + +static u16 iwl_fill_probe_req(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, iwl_bcast_addr, ETH_ALEN); + memcpy(frame->sa, ta, ETH_ALEN); + memcpy(frame->bssid, iwl_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; +} + static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) { struct iwl_host_cmd cmd = { @@ -791,7 +838,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan->rx_chain = cpu_to_le16(rx_chain); switch (priv->scan_type) { case IWL_SCAN_NORMAL: - cmd_len = iwl_fill_probe_req(priv, + cmd_len = iwl_fill_probe_req( (struct ieee80211_mgmt *)scan->data, vif->addr, priv->scan_request->ie, @@ -801,7 +848,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) case IWL_SCAN_RADIO_RESET: case IWL_SCAN_ROC: /* use bcast addr, will not be transmitted but must be valid */ - cmd_len = iwl_fill_probe_req(priv, + cmd_len = iwl_fill_probe_req( (struct ieee80211_mgmt *)scan->data, iwl_bcast_addr, NULL, 0, IWL_MAX_SCAN_SIZE - sizeof(*scan)); @@ -1004,53 +1051,6 @@ static void iwl_bg_scan_check(struct work_struct *data) mutex_unlock(&priv->mutex); } -/** - * iwl_fill_probe_req - fill in all required fields and IE for probe request - */ - -u16 iwl_fill_probe_req(struct iwl_priv *priv, 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, iwl_bcast_addr, ETH_ALEN); - memcpy(frame->sa, ta, ETH_ALEN); - memcpy(frame->bssid, iwl_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; -} - static void iwl_bg_abort_scan(struct work_struct *work) { struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); -- GitLab From f06c7885c3dd3db8eb771e10615ee41425607e95 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Tue, 6 Mar 2012 16:42:09 -0800 Subject: [PATCH 1560/1846] mac80211: fix smatch lock errors in mesh smatch was complaining: CHECK net/mac80211/mesh_pathtbl.c net/mac80211/mesh_pathtbl.c:562 mesh_path_add() error: double lock 'bottom_half:' net/mac80211/mesh_pathtbl.c:580 mesh_path_add() error: double unlock 'bottom_half:' net/mac80211/mesh_pathtbl.c:589 mesh_path_add() error: double unlock 'bottom_half:' net/mac80211/mesh_pathtbl.c:691 mpp_path_add() error: double lock 'bottom_half:' net/mac80211/mesh_pathtbl.c:707 mpp_path_add() error: double unlock 'bottom_half:' net/mac80211/mesh_pathtbl.c:716 mpp_path_add() error: double unlock 'bottom_half:' net/mac80211/mesh_pathtbl.c:814 mesh_path_flush_by_nexthop() error: double lock 'bottom_half:' net/mac80211/mesh_pathtbl.c:819 mesh_path_flush_by_nexthop() error: double unlock 'bottom_half:' net/mac80211/mesh_pathtbl.c:887 mesh_path_del() error: double lock 'bottom_half:' net/mac80211/mesh_pathtbl.c:901 mesh_path_del() error: double unlock 'bottom_half:' So don't lock / unlock with _bh() while bottom halves are already disabled. Reported-by: Johannes Berg Signed-off-by: Thomas Pedersen Signed-off-by: John W. Linville --- net/mac80211/mesh_pathtbl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 157642f780b9..be1361b5f7ad 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -559,7 +559,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) hash_idx = mesh_table_hash(dst, sdata, tbl); bucket = &tbl->hash_buckets[hash_idx]; - spin_lock_bh(&tbl->hashwlock[hash_idx]); + spin_lock(&tbl->hashwlock[hash_idx]); err = -EEXIST; hlist_for_each_entry(node, n, bucket, list) { @@ -576,7 +576,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) mesh_paths_generation++; - spin_unlock_bh(&tbl->hashwlock[hash_idx]); + spin_unlock(&tbl->hashwlock[hash_idx]); read_unlock_bh(&pathtbl_resize_lock); if (grow) { set_bit(MESH_WORK_GROW_MPATH_TABLE, &ifmsh->wrkq_flags); @@ -585,7 +585,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) return 0; err_exists: - spin_unlock_bh(&tbl->hashwlock[hash_idx]); + spin_unlock(&tbl->hashwlock[hash_idx]); read_unlock_bh(&pathtbl_resize_lock); kfree(new_node); err_node_alloc: @@ -688,7 +688,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) hash_idx = mesh_table_hash(dst, sdata, tbl); bucket = &tbl->hash_buckets[hash_idx]; - spin_lock_bh(&tbl->hashwlock[hash_idx]); + spin_lock(&tbl->hashwlock[hash_idx]); err = -EEXIST; hlist_for_each_entry(node, n, bucket, list) { @@ -703,7 +703,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) tbl->mean_chain_len * (tbl->hash_mask + 1)) grow = 1; - spin_unlock_bh(&tbl->hashwlock[hash_idx]); + spin_unlock(&tbl->hashwlock[hash_idx]); read_unlock_bh(&pathtbl_resize_lock); if (grow) { set_bit(MESH_WORK_GROW_MPP_TABLE, &ifmsh->wrkq_flags); @@ -712,7 +712,7 @@ int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) return 0; err_exists: - spin_unlock_bh(&tbl->hashwlock[hash_idx]); + spin_unlock(&tbl->hashwlock[hash_idx]); read_unlock_bh(&pathtbl_resize_lock); kfree(new_node); err_node_alloc: @@ -811,9 +811,9 @@ void mesh_path_flush_by_nexthop(struct sta_info *sta) for_each_mesh_entry(tbl, p, node, i) { mpath = node->mpath; if (rcu_dereference(mpath->next_hop) == sta) { - spin_lock_bh(&tbl->hashwlock[i]); + spin_lock(&tbl->hashwlock[i]); __mesh_path_del(tbl, node); - spin_unlock_bh(&tbl->hashwlock[i]); + spin_unlock(&tbl->hashwlock[i]); } } read_unlock_bh(&pathtbl_resize_lock); @@ -884,7 +884,7 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) hash_idx = mesh_table_hash(addr, sdata, tbl); bucket = &tbl->hash_buckets[hash_idx]; - spin_lock_bh(&tbl->hashwlock[hash_idx]); + spin_lock(&tbl->hashwlock[hash_idx]); hlist_for_each_entry(node, n, bucket, list) { mpath = node->mpath; if (mpath->sdata == sdata && @@ -897,7 +897,7 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) err = -ENXIO; enddel: mesh_paths_generation++; - spin_unlock_bh(&tbl->hashwlock[hash_idx]); + spin_unlock(&tbl->hashwlock[hash_idx]); read_unlock_bh(&pathtbl_resize_lock); return err; } -- GitLab From 0d33cd782990b13d992109d16e11205e1ac547bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 7 Mar 2012 09:11:22 +0100 Subject: [PATCH 1561/1846] bcma: silence PMU warning for BCM4331 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/bcma/driver_chipcommon_pmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bcma/driver_chipcommon_pmu.c b/drivers/bcma/driver_chipcommon_pmu.c index 800163c8c2e7..a058842f14fd 100644 --- a/drivers/bcma/driver_chipcommon_pmu.c +++ b/drivers/bcma/driver_chipcommon_pmu.c @@ -80,6 +80,7 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc) min_msk = 0x200D; max_msk = 0xFFFF; break; + case 0x4331: case 43224: case 43225: break; -- GitLab From 41b58f189ada1a12d3c9417c3eedd5b910d8d09f Mon Sep 17 00:00:00 2001 From: Attila Fazekas Date: Thu, 23 Feb 2012 19:50:35 +0100 Subject: [PATCH 1562/1846] rtl8187: Add AD-HOC support Add AD-HOC support to the rtl8187 based on the rtl8180 source Signed-off-by: Attila Fazekas Acked-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtl818x/rtl8187/dev.c | 110 +++++++++++++++--- .../net/wireless/rtl818x/rtl8187/rtl8187.h | 9 ++ 2 files changed, 100 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c index 638fbef693e6..cf53ac9d6f23 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c @@ -8,7 +8,7 @@ * Copyright 2005 Andrea Merello , et al. * * The driver was extended to the RTL8187B in 2008 by: - * Herton Ronaldo Krzesinski + * Herton Ronaldo Krzesinski * Hin-Tak Leung * Larry Finger * @@ -232,6 +232,7 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) { struct rtl8187_priv *priv = dev->priv; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *tx_hdr = (struct ieee80211_hdr *)(skb->data); unsigned int ep; void *buf; struct urb *urb; @@ -249,7 +250,7 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) flags |= RTL818X_TX_DESC_FLAG_NO_ENC; flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24; - if (ieee80211_has_morefrags(((struct ieee80211_hdr *)skb->data)->frame_control)) + if (ieee80211_has_morefrags(tx_hdr->frame_control)) flags |= RTL818X_TX_DESC_FLAG_MOREFRAG; if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { flags |= RTL818X_TX_DESC_FLAG_RTS; @@ -261,6 +262,13 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; } + if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { + if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) + priv->seqno += 0x10; + tx_hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); + tx_hdr->seq_ctrl |= cpu_to_le16(priv->seqno); + } + if (!priv->is_rtl8187b) { struct rtl8187_tx_hdr *hdr = (struct rtl8187_tx_hdr *)skb_push(skb, sizeof(*hdr)); @@ -274,8 +282,6 @@ static void rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb) } else { /* fc needs to be calculated before skb_push() */ unsigned int epmap[4] = { 6, 7, 5, 4 }; - struct ieee80211_hdr *tx_hdr = - (struct ieee80211_hdr *)(skb->data); u16 fc = le16_to_cpu(tx_hdr->frame_control); struct rtl8187b_tx_hdr *hdr = @@ -1031,10 +1037,61 @@ static void rtl8187_stop(struct ieee80211_hw *dev) cancel_delayed_work_sync(&priv->work); } +static u64 rtl8187_get_tsf(struct ieee80211_hw *dev, struct ieee80211_vif *vif) +{ + struct rtl8187_priv *priv = dev->priv; + + return rtl818x_ioread32(priv, &priv->map->TSFT[0]) | + (u64)(rtl818x_ioread32(priv, &priv->map->TSFT[1])) << 32; +} + + +static void rtl8187_beacon_work(struct work_struct *work) +{ + struct rtl8187_vif *vif_priv = + container_of(work, struct rtl8187_vif, beacon_work.work); + struct ieee80211_vif *vif = + container_of((void *)vif_priv, struct ieee80211_vif, drv_priv); + struct ieee80211_hw *dev = vif_priv->dev; + struct ieee80211_mgmt *mgmt; + struct sk_buff *skb; + + /* don't overflow the tx ring */ + if (ieee80211_queue_stopped(dev, 0)) + goto resched; + + /* grab a fresh beacon */ + skb = ieee80211_beacon_get(dev, vif); + if (!skb) + goto resched; + + /* + * update beacon timestamp w/ TSF value + * TODO: make hardware update beacon timestamp + */ + mgmt = (struct ieee80211_mgmt *)skb->data; + mgmt->u.beacon.timestamp = cpu_to_le64(rtl8187_get_tsf(dev, vif)); + + /* TODO: use actual beacon queue */ + skb_set_queue_mapping(skb, 0); + + rtl8187_tx(dev, skb); + +resched: + /* + * schedule next beacon + * TODO: use hardware support for beacon timing + */ + schedule_delayed_work(&vif_priv->beacon_work, + usecs_to_jiffies(1024 * vif->bss_conf.beacon_int)); +} + + static int rtl8187_add_interface(struct ieee80211_hw *dev, struct ieee80211_vif *vif) { struct rtl8187_priv *priv = dev->priv; + struct rtl8187_vif *vif_priv; int i; int ret = -EOPNOTSUPP; @@ -1044,6 +1101,7 @@ static int rtl8187_add_interface(struct ieee80211_hw *dev, switch (vif->type) { case NL80211_IFTYPE_STATION: + case NL80211_IFTYPE_ADHOC: break; default: goto exit; @@ -1052,6 +1110,13 @@ static int rtl8187_add_interface(struct ieee80211_hw *dev, ret = 0; priv->vif = vif; + /* Initialize driver private area */ + vif_priv = (struct rtl8187_vif *)&vif->drv_priv; + vif_priv->dev = dev; + INIT_DELAYED_WORK(&vif_priv->beacon_work, rtl8187_beacon_work); + vif_priv->enable_beacon = false; + + rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); for (i = 0; i < ETH_ALEN; i++) rtl818x_iowrite8(priv, &priv->map->MAC[i], @@ -1175,9 +1240,12 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev, u32 changed) { struct rtl8187_priv *priv = dev->priv; + struct rtl8187_vif *vif_priv; int i; u8 reg; + vif_priv = (struct rtl8187_vif *)&vif->drv_priv; + if (changed & BSS_CHANGED_BSSID) { mutex_lock(&priv->conf_mutex); for (i = 0; i < ETH_ALEN; i++) @@ -1189,8 +1257,12 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev, else reg = 0; - if (is_valid_ether_addr(info->bssid)) - reg |= RTL818X_MSR_INFRA; + if (is_valid_ether_addr(info->bssid)) { + if (vif->type == NL80211_IFTYPE_ADHOC) + reg |= RTL818X_MSR_ADHOC; + else + reg |= RTL818X_MSR_INFRA; + } else reg |= RTL818X_MSR_NO_LINK; @@ -1202,6 +1274,16 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev, if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_ERP_PREAMBLE)) rtl8187_conf_erp(priv, info->use_short_slot, info->use_short_preamble); + + if (changed & BSS_CHANGED_BEACON_ENABLED) + vif_priv->enable_beacon = info->enable_beacon; + + if (changed & (BSS_CHANGED_BEACON_ENABLED | BSS_CHANGED_BEACON)) { + cancel_delayed_work_sync(&vif_priv->beacon_work); + if (vif_priv->enable_beacon) + schedule_work(&vif_priv->beacon_work.work); + } + } static u64 rtl8187_prepare_multicast(struct ieee80211_hw *dev, @@ -1279,13 +1361,6 @@ static int rtl8187_conf_tx(struct ieee80211_hw *dev, return 0; } -static u64 rtl8187_get_tsf(struct ieee80211_hw *dev, struct ieee80211_vif *vif) -{ - struct rtl8187_priv *priv = dev->priv; - - return rtl818x_ioread32(priv, &priv->map->TSFT[0]) | - (u64)(rtl818x_ioread32(priv, &priv->map->TSFT[1])) << 32; -} static const struct ieee80211_ops rtl8187_ops = { .tx = rtl8187_tx, @@ -1514,12 +1589,9 @@ static int __devinit rtl8187_probe(struct usb_interface *intf, if (reg & 0xFF00) priv->rfkill_mask = RFKILL_MASK_8198; } - - /* - * XXX: Once this driver supports anything that requires - * beacons it must implement IEEE80211_TX_CTL_ASSIGN_SEQ. - */ - dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); + dev->vif_data_size = sizeof(struct rtl8187_vif); + dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC) ; if ((id->driver_info == DEVICE_RTL8187) && priv->is_rtl8187b) printk(KERN_INFO "rtl8187: inconsistency between id with OEM" diff --git a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h index f1cc90751dbf..e19a20a8e955 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h @@ -89,6 +89,14 @@ enum { DEVICE_RTL8187B }; +struct rtl8187_vif { + struct ieee80211_hw *dev; + + /* beaconing */ + struct delayed_work beacon_work; + bool enable_beacon; +}; + struct rtl8187_priv { /* common between rtl818x drivers */ struct rtl818x_csr *map; @@ -141,6 +149,7 @@ struct rtl8187_priv { __le32 bits32; } *io_dmabuf; bool rfkill_off; + u16 seqno; }; void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data); -- GitLab From b4fb05ea402cb6930b40d3152d8acabc391b23e2 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 7 Mar 2012 04:45:43 +0000 Subject: [PATCH 1563/1846] tcp: md5: correct a RCU lockdep splat commit a8afca0329 (tcp: md5: protects md5sig_info with RCU) added a lockdep splat in tcp_md5_do_lookup() in case a timer fires a tcp retransmit. At this point, socket lock is owned by the sofirq handler, not the user, so we should adjust a bit the lockdep condition, as we dont hold rcu_read_lock(). Signed-off-by: Eric Dumazet Reported-by: Valdis Kletnieks Signed-off-by: David S. Miller --- net/ipv4/tcp_ipv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 94abee8cf563..507924b640ef 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -927,7 +927,8 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, /* caller either holds rcu_read_lock() or socket lock */ md5sig = rcu_dereference_check(tp->md5sig_info, - sock_owned_by_user(sk)); + sock_owned_by_user(sk) || + lockdep_is_held(&sk->sk_lock.slock)); if (!md5sig) return NULL; #if IS_ENABLED(CONFIG_IPV6) -- GitLab From 04124681f104c1980024ff249a34a77a249fd2bc Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Thu, 8 Mar 2012 01:25:00 -0300 Subject: [PATCH 1564/1846] Bluetooth: fix conding style issues all over the tree Signed-off-by: Gustavo F. Padovan --- drivers/bluetooth/btmrvl_debugfs.c | 23 +- include/net/bluetooth/hci_core.h | 67 ++-- net/bluetooth/hci_core.c | 49 ++- net/bluetooth/hci_event.c | 110 ++++--- net/bluetooth/l2cap_core.c | 11 +- net/bluetooth/l2cap_sock.c | 3 +- net/bluetooth/mgmt.c | 489 ++++++++++++++--------------- net/bluetooth/smp.c | 30 +- 8 files changed, 384 insertions(+), 398 deletions(-) diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c index 3497347e6dbb..6c20bbb54b71 100644 --- a/drivers/bluetooth/btmrvl_debugfs.c +++ b/drivers/bluetooth/btmrvl_debugfs.c @@ -401,28 +401,29 @@ void btmrvl_debugfs_init(struct hci_dev *hdev) dbg->config_dir = debugfs_create_dir("config", hdev->debugfs); dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, - priv, &btmrvl_psmode_fops); + priv, &btmrvl_psmode_fops); dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir, - priv, &btmrvl_pscmd_fops); + priv, &btmrvl_pscmd_fops); dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir, - priv, &btmrvl_gpiogap_fops); + priv, &btmrvl_gpiogap_fops); dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir, - priv, &btmrvl_hsmode_fops); + priv, &btmrvl_hsmode_fops); dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir, - priv, &btmrvl_hscmd_fops); + priv, &btmrvl_hscmd_fops); dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, - priv, &btmrvl_hscfgcmd_fops); + priv, &btmrvl_hscfgcmd_fops); dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); dbg->curpsmode = debugfs_create_file("curpsmode", 0444, - dbg->status_dir, priv, &btmrvl_curpsmode_fops); + dbg->status_dir, priv, + &btmrvl_curpsmode_fops); dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir, - priv, &btmrvl_psstate_fops); + priv, &btmrvl_psstate_fops); dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir, - priv, &btmrvl_hsstate_fops); + priv, &btmrvl_hsstate_fops); dbg->txdnldready = debugfs_create_file("txdnldready", 0444, - dbg->status_dir, priv, - &btmrvl_txdnldready_fops); + dbg->status_dir, priv, + &btmrvl_txdnldready_fops); } void btmrvl_debugfs_remove(struct hci_dev *hdev) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index cbbf68a8510d..daefaac51131 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -398,16 +398,16 @@ static inline long inquiry_entry_age(struct inquiry_entry *e) } struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, - bdaddr_t *bdaddr); + bdaddr_t *bdaddr); struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, - bdaddr_t *bdaddr); + bdaddr_t *bdaddr); struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, - bdaddr_t *bdaddr, - int state); + bdaddr_t *bdaddr, + int state); void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, - struct inquiry_entry *ie); + struct inquiry_entry *ie); bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, - bool name_known, bool *ssp); + bool name_known, bool *ssp); /* ----- HCI Connections ----- */ enum { @@ -669,13 +669,13 @@ int hci_uuids_clear(struct hci_dev *hdev); int hci_link_keys_clear(struct hci_dev *hdev); struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, - bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); + bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, - int new_key, u8 authenticated, u8 tk[16], - u8 enc_size, u16 ediv, u8 rand[8]); + int new_key, u8 authenticated, u8 tk[16], u8 enc_size, u16 ediv, + u8 rand[8]); struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 addr_type); + u8 addr_type); int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_smp_ltks_clear(struct hci_dev *hdev); int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); @@ -931,7 +931,7 @@ static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) } static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data, - u8 data_len) + u8 data_len) { eir[eir_len++] = sizeof(type) + data_len; eir[eir_len++] = type; @@ -978,50 +978,49 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); int mgmt_connectable(struct hci_dev *hdev, u8 connectable); int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, - u8 persistent); + u8 persistent); int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u32 flags, u8 *name, - u8 name_len, u8 *dev_class); + u8 addr_type, u32 flags, u8 *name, u8 name_len, + u8 *dev_class); int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type); + u8 link_type, u8 addr_type); int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status); + u8 link_type, u8 addr_type, u8 status); int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 status); + u8 addr_type, u8 status); int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); + u8 status); int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); + u8 status); int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, __le32 value, - u8 confirm_hint); + u8 link_type, u8 addr_type, __le32 value, + u8 confirm_hint); int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status); + u8 link_type, u8 addr_type, u8 status); int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status); + u8 link_type, u8 addr_type, u8 status); int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type); + u8 link_type, u8 addr_type); int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status); + u8 link_type, u8 addr_type, u8 status); int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status); + u8 link_type, u8 addr_type, u8 status); int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 status); + u8 addr_type, u8 status); int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, - u8 status); + u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, - u8 *randomizer, u8 status); + u8 *randomizer, u8 status); int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 ssp, u8 *eir, - u16 eir_len); + u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, + u8 ssp, u8 *eir, u16 eir_len); int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, s8 rssi, u8 *name, u8 name_len); + u8 addr_type, s8 rssi, u8 *name, u8 name_len); int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); int mgmt_discovering(struct hci_dev *hdev, u8 discovering); @@ -1071,6 +1070,6 @@ void hci_le_ltk_neg_reply(struct hci_conn *conn); int hci_do_inquiry(struct hci_dev *hdev, u8 length); int hci_cancel_inquiry(struct hci_dev *hdev); int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, - int timeout); + int timeout); #endif /* __HCI_CORE_H */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 661d65fc487b..59ec99eb739b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -431,7 +431,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b } struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, - bdaddr_t *bdaddr) + bdaddr_t *bdaddr) { struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *e; @@ -447,8 +447,8 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, } struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, - bdaddr_t *bdaddr, - int state) + bdaddr_t *bdaddr, + int state) { struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *e; @@ -466,7 +466,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, } void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, - struct inquiry_entry *ie) + struct inquiry_entry *ie) { struct discovery_state *cache = &hdev->discovery; struct list_head *pos = &cache->resolve; @@ -485,7 +485,7 @@ void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, } bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, - bool name_known, bool *ssp) + bool name_known, bool *ssp) { struct discovery_state *cache = &hdev->discovery; struct inquiry_entry *ie; @@ -1264,7 +1264,7 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) EXPORT_SYMBOL(hci_find_ltk); struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 addr_type) + u8 addr_type) { struct smp_ltk *k; @@ -1278,7 +1278,7 @@ struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, EXPORT_SYMBOL(hci_find_ltk_by_addr); int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, - bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) + bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) { struct link_key *key, *old_key; u8 old_key_type, persistent; @@ -1333,8 +1333,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, } int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, - int new_key, u8 authenticated, u8 tk[16], - u8 enc_size, u16 ediv, u8 rand[8]) + int new_key, u8 authenticated, u8 tk[16], u8 enc_size, u16 + ediv, u8 rand[8]) { struct smp_ltk *key, *old_key; @@ -1413,7 +1413,7 @@ static void hci_cmd_timer(unsigned long arg) } struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, - bdaddr_t *bdaddr) + bdaddr_t *bdaddr) { struct oob_data *data; @@ -1453,7 +1453,7 @@ int hci_remote_oob_data_clear(struct hci_dev *hdev) } int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, - u8 *randomizer) + u8 *randomizer) { struct oob_data *data; @@ -1476,8 +1476,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, return 0; } -struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, - bdaddr_t *bdaddr) +struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) { struct bdaddr_list *b; @@ -1545,7 +1544,7 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) static void hci_clear_adv_cache(struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, - adv_work.work); + adv_work.work); hci_dev_lock(hdev); @@ -1588,11 +1587,7 @@ static inline int is_connectable_adv(u8 evt_type) } int hci_add_adv_entry(struct hci_dev *hdev, - struct hci_ev_le_advertising_info *ev) -{ - struct adv_entry *entry; - - if (!is_connectable_adv(ev->evt_type)) + struct hci_ev_le_advertising_info *ev) { struct adv_entry *entry; if (!is_connectable_adv(ev->evt_type)) return -EINVAL; /* Only new entries should be added to adv_entries. So, if @@ -1639,7 +1634,7 @@ static void le_scan_enable_req(struct hci_dev *hdev, unsigned long opt) } static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, - u16 window, int timeout) + u16 window, int timeout) { long timeo = msecs_to_jiffies(3000); struct le_scan_params param; @@ -1657,7 +1652,7 @@ static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, hci_req_lock(hdev); err = __hci_request(hdev, le_scan_param_req, (unsigned long) ¶m, - timeo); + timeo); if (!err) err = __hci_request(hdev, le_scan_enable_req, 0, timeo); @@ -1667,7 +1662,7 @@ static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, return err; schedule_delayed_work(&hdev->le_scan_disable, - msecs_to_jiffies(timeout)); + msecs_to_jiffies(timeout)); return 0; } @@ -1675,7 +1670,7 @@ static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, static void le_scan_disable_work(struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, - le_scan_disable.work); + le_scan_disable.work); struct hci_cp_le_set_scan_enable cp; BT_DBG("%s", hdev->name); @@ -1692,12 +1687,12 @@ static void le_scan_work(struct work_struct *work) BT_DBG("%s", hdev->name); - hci_do_le_scan(hdev, param->type, param->interval, - param->window, param->timeout); + hci_do_le_scan(hdev, param->type, param->interval, param->window, + param->timeout); } int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, - int timeout) + int timeout) { struct le_scan_params *param = &hdev->le_scan_params; @@ -2558,7 +2553,7 @@ static inline void hci_sched_acl_pkt(struct hci_dev *hdev) skb = skb_dequeue(&chan->data_q); hci_conn_enter_active_mode(chan->conn, - bt_cb(skb)->force_active); + bt_cb(skb)->force_active); hci_send_frame(skb); hdev->acl_last_tx = jiffies; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6a817daf095b..badb7851d116 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -556,7 +556,7 @@ static void hci_setup(struct hci_dev *hdev) if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { u8 mode = 0x01; hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, - sizeof(mode), &mode); + sizeof(mode), &mode); } else { struct hci_cp_write_eir cp; @@ -577,14 +577,14 @@ static void hci_setup(struct hci_dev *hdev) struct hci_cp_read_local_ext_features cp; cp.page = 0x01; - hci_send_cmd(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, - sizeof(cp), &cp); + hci_send_cmd(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, sizeof(cp), + &cp); } if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) { u8 enable = 1; - hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, - sizeof(enable), &enable); + hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, sizeof(enable), + &enable); } } @@ -628,8 +628,8 @@ static void hci_setup_link_policy(struct hci_dev *hdev) link_policy |= HCI_LP_PARK; link_policy = cpu_to_le16(link_policy); - hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, - sizeof(link_policy), &link_policy); + hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, sizeof(link_policy), + &link_policy); } static void hci_cc_read_local_commands(struct hci_dev *hdev, struct sk_buff *skb) @@ -717,8 +717,8 @@ static void hci_set_le_support(struct hci_dev *hdev) } if (cp.le != !!(hdev->host_features[0] & LMP_HOST_LE)) - hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, - sizeof(cp), &cp); + hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp), + &cp); } static void hci_cc_read_local_ext_features(struct hci_dev *hdev, @@ -976,8 +976,8 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) hci_dev_lock(hdev); if (test_bit(HCI_MGMT, &hdev->dev_flags)) - mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, - 0, rp->status); + mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, + rp->status); hci_dev_unlock(hdev); } @@ -993,8 +993,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, - ACL_LINK, 0, - rp->status); + ACL_LINK, 0, rp->status); hci_dev_unlock(hdev); } @@ -1009,7 +1008,7 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb) if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, - 0, rp->status); + 0, rp->status); hci_dev_unlock(hdev); } @@ -1025,8 +1024,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, if (test_bit(HCI_MGMT, &hdev->dev_flags)) mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, - ACL_LINK, 0, - rp->status); + ACL_LINK, 0, rp->status); hci_dev_unlock(hdev); } @@ -1337,7 +1335,7 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev, } static inline int hci_resolve_name(struct hci_dev *hdev, - struct inquiry_entry *e) + struct inquiry_entry *e) { struct hci_cp_remote_name_req cp; @@ -1369,14 +1367,14 @@ static bool hci_resolve_next_name(struct hci_dev *hdev) } static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, - bdaddr_t *bdaddr, u8 *name, u8 name_len) + bdaddr_t *bdaddr, u8 *name, u8 name_len) { struct discovery_state *discov = &hdev->discovery; struct inquiry_entry *e; if (conn && !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) - mgmt_device_connected(hdev, bdaddr, ACL_LINK, 0x00, 0, - name, name_len, conn->dev_class); + mgmt_device_connected(hdev, bdaddr, ACL_LINK, 0x00, 0, name, + name_len, conn->dev_class); if (discov->state == DISCOVERY_STOPPED) return; @@ -1393,7 +1391,7 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn, list_del(&e->list); if (name) mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00, - e->data.rssi, name, name_len); + e->data.rssi, name, name_len); } if (hci_resolve_next_name(hdev)) @@ -1602,7 +1600,7 @@ static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); if (conn) mgmt_disconnect_failed(hdev, &conn->dst, conn->type, - conn->dst_type, status); + conn->dst_type, status); hci_dev_unlock(hdev); } @@ -1718,8 +1716,8 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * name_known = hci_inquiry_cache_update(hdev, &data, false, &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, 0, !name_known, ssp, - NULL, 0); + info->dev_class, 0, !name_known, ssp, NULL, + 0); } hci_dev_unlock(hdev); @@ -1770,7 +1768,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s struct hci_cp_read_remote_features cp; cp.handle = ev->handle; hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES, - sizeof(cp), &cp); + sizeof(cp), &cp); } /* Set packet type for incoming connection */ @@ -1778,14 +1776,14 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s struct hci_cp_change_conn_ptype cp; cp.handle = ev->handle; cp.pkt_type = cpu_to_le16(conn->pkt_type); - hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, - sizeof(cp), &cp); + hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), + &cp); } } else { conn->state = BT_CLOSED; if (conn->type == ACL_LINK) mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, - conn->dst_type, ev->status); + conn->dst_type, ev->status); } if (conn->type == ACL_LINK) @@ -1850,8 +1848,8 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk else cp.role = 0x01; /* Remain slave */ - hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, - sizeof(cp), &cp); + hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), + &cp); } else { struct hci_cp_accept_sync_conn_req cp; @@ -1865,7 +1863,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk cp.retrans_effort = 0xff; hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, - sizeof(cp), &cp); + sizeof(cp), &cp); } } else { /* Connection rejected */ @@ -1900,7 +1898,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff conn->dst_type, ev->status); else mgmt_device_disconnected(hdev, &conn->dst, conn->type, - conn->dst_type); + conn->dst_type); } if (ev->status == 0) { @@ -1935,7 +1933,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s } } else { mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, - ev->status); + ev->status); } clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); @@ -1996,7 +1994,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb if (ev->status == 0) hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name, - strnlen(ev->name, HCI_MAX_NAME_LENGTH)); + strnlen(ev->name, HCI_MAX_NAME_LENGTH)); else hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0); @@ -2111,8 +2109,8 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &conn->dst, conn->type, - conn->dst_type, 0, NULL, 0, - conn->dev_class); + conn->dst_type, 0, NULL, 0, + conn->dev_class); if (!hci_outgoing_auth_needed(hdev, conn)) { conn->state = BT_CONNECTED; @@ -2524,7 +2522,7 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s } static inline void hci_num_comp_blocks_evt(struct hci_dev *hdev, - struct sk_buff *skb) + struct sk_buff *skb) { struct hci_ev_num_comp_blocks *ev = (void *) skb->data; int i; @@ -2816,10 +2814,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.ssp_mode = 0x00; name_known = hci_inquiry_cache_update(hdev, &data, - false, &ssp); + false, &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, info->rssi, - !name_known, ssp, NULL, 0); + info->dev_class, info->rssi, + !name_known, ssp, NULL, 0); } } else { struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); @@ -2834,10 +2832,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct data.rssi = info->rssi; data.ssp_mode = 0x00; name_known = hci_inquiry_cache_update(hdev, &data, - false, &ssp); + false, &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, info->rssi, - !name_known, ssp, NULL, 0); + info->dev_class, info->rssi, + !name_known, ssp, NULL, 0); } } @@ -2879,8 +2877,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp); } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &conn->dst, conn->type, - conn->dst_type, 0, NULL, 0, - conn->dev_class); + conn->dst_type, 0, NULL, 0, + conn->dev_class); if (!hci_outgoing_auth_needed(hdev, conn)) { conn->state = BT_CONNECTED; @@ -2986,17 +2984,16 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct if (test_bit(HCI_MGMT, &hdev->dev_flags)) name_known = eir_has_data_type(info->data, - sizeof(info->data), - EIR_NAME_COMPLETE); + sizeof(info->data), + EIR_NAME_COMPLETE); else name_known = true; name_known = hci_inquiry_cache_update(hdev, &data, name_known, - &ssp); + &ssp); mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, - info->dev_class, info->rssi, - !name_known, ssp, info->data, - sizeof(info->data)); + info->dev_class, info->rssi, !name_known, + ssp, info->data, sizeof(info->data)); } hci_dev_unlock(hdev); @@ -3157,7 +3154,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, confirm: mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, ev->passkey, - confirm_hint); + confirm_hint); unlock: hci_dev_unlock(hdev); @@ -3198,7 +3195,7 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_ * the mgmt_auth_failed event */ if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status != 0) mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, - ev->status); + ev->status); hci_conn_put(conn); @@ -3223,7 +3220,7 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_ } static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev, - struct sk_buff *skb) + struct sk_buff *skb) { struct hci_ev_remote_oob_data_request *ev = (void *) skb->data; struct oob_data *data; @@ -3289,7 +3286,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) mgmt_device_connected(hdev, &ev->bdaddr, conn->type, - conn->dst_type, 0, NULL, 0, NULL); + conn->dst_type, 0, NULL, 0, NULL); conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); @@ -3320,8 +3317,7 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev, rssi = ev->data[ev->length]; mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type, - NULL, rssi, 0, 1, ev->data, - ev->length); + NULL, rssi, 0, 1, ev->data, ev->length); ptr += sizeof(*ev) + ev->length + 1; } diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0b1aabff8649..3e450f4a3125 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -1546,7 +1546,9 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) l2cap_send_sframe(chan, control); } -static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, struct msghdr *msg, int len, int count, struct sk_buff *skb) +static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, + struct msghdr *msg, int len, + int count, struct sk_buff *skb) { struct l2cap_conn *conn = chan->conn; struct sk_buff **frag; @@ -1564,7 +1566,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, struct msghdr count = min_t(unsigned int, conn->mtu, len); *frag = chan->ops->alloc_skb(chan, count, - msg->msg_flags & MSG_DONTWAIT, &err); + msg->msg_flags & MSG_DONTWAIT, + &err); if (!*frag) return err; @@ -1596,7 +1599,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, count = min_t(unsigned int, (conn->mtu - hlen), len); skb = chan->ops->alloc_skb(chan, count + hlen, - msg->msg_flags & MSG_DONTWAIT, &err); + msg->msg_flags & MSG_DONTWAIT, &err); if (!skb) return ERR_PTR(err); @@ -1631,7 +1634,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, count = min_t(unsigned int, (conn->mtu - hlen), len); skb = chan->ops->alloc_skb(chan, count + hlen, - msg->msg_flags & MSG_DONTWAIT, &err); + msg->msg_flags & MSG_DONTWAIT, &err); if (!skb) return ERR_PTR(err); diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 3da56c5c1fc9..c4fe583b0af6 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -926,7 +926,8 @@ static void l2cap_sock_state_change_cb(void *data, int state) } static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, - unsigned long len, int nb, int *err) + unsigned long len, int nb, + int *err) { struct sock *sk = chan->sk; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4ca009268afb..7fcff8887131 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -234,7 +234,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) } static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, - void *rp, size_t rp_len) + void *rp, size_t rp_len) { struct sk_buff *skb; struct mgmt_hdr *hdr; @@ -267,8 +267,8 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, return err; } -static int read_version(struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len) +static int read_version(struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len) { struct mgmt_rp_read_version rp; @@ -278,11 +278,11 @@ static int read_version(struct sock *sk, struct hci_dev *hdev, put_unaligned_le16(MGMT_REVISION, &rp.revision); return cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_VERSION, 0, &rp, - sizeof(rp)); + sizeof(rp)); } -static int read_commands(struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len) +static int read_commands(struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len) { struct mgmt_rp_read_commands *rp; u16 num_commands = ARRAY_SIZE(mgmt_commands); @@ -309,14 +309,14 @@ static int read_commands(struct sock *sk, struct hci_dev *hdev, put_unaligned_le16(mgmt_events[i], opcode); err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_COMMANDS, 0, rp, - rp_size); + rp_size); kfree(rp); return err; } -static int read_index_list(struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len) +static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len) { struct mgmt_rp_read_index_list *rp; struct list_head *p; @@ -355,7 +355,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, read_unlock(&hci_dev_list_lock); err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp, - rp_len); + rp_len); kfree(rp); @@ -600,7 +600,7 @@ static int update_class(struct hci_dev *hdev) static void service_cache_off(struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, - service_cache.work); + service_cache.work); if (!test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) return; @@ -629,7 +629,7 @@ static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) } static int read_controller_info(struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len) + void *data, u16 data_len) { struct mgmt_rp_read_info rp; @@ -656,7 +656,7 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev, hci_dev_unlock(hdev); return cmd_complete(sk, hdev->id, MGMT_OP_READ_INFO, 0, &rp, - sizeof(rp)); + sizeof(rp)); } static void mgmt_pending_free(struct pending_cmd *cmd) @@ -667,8 +667,8 @@ static void mgmt_pending_free(struct pending_cmd *cmd) } static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, - struct hci_dev *hdev, - void *data, u16 len) + struct hci_dev *hdev, void *data, + u16 len) { struct pending_cmd *cmd; @@ -697,8 +697,8 @@ static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, } static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, - void (*cb)(struct pending_cmd *cmd, void *data), - void *data) + void (*cb)(struct pending_cmd *cmd, void *data), + void *data) { struct list_head *p, *n; @@ -737,11 +737,11 @@ static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev) __le32 settings = cpu_to_le32(get_current_settings(hdev)); return cmd_complete(sk, hdev->id, opcode, 0, &settings, - sizeof(settings)); + sizeof(settings)); } static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_mode *cp = data; struct pending_cmd *cmd; @@ -768,7 +768,7 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } @@ -790,8 +790,8 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, return err; } -static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, - u16 data_len, struct sock *skip_sk) +static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 data_len, + struct sock *skip_sk) { struct sk_buff *skb; struct mgmt_hdr *hdr; @@ -830,7 +830,7 @@ static int new_settings(struct hci_dev *hdev, struct sock *skip) } static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_set_discoverable *cp = data; struct pending_cmd *cmd; @@ -843,26 +843,26 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, timeout = get_unaligned_le16(&cp->timeout); if (!cp->val && timeout > 0) return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); hci_dev_lock(hdev); if (!hdev_is_powered(hdev) && timeout > 0) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto failed; } if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, - MGMT_STATUS_REJECTED); + MGMT_STATUS_REJECTED); goto failed; } @@ -926,7 +926,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, } static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_mode *cp = data; struct pending_cmd *cmd; @@ -963,7 +963,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } @@ -998,7 +998,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, } static int set_pairable(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_mode *cp = data; int err; @@ -1023,8 +1023,8 @@ static int set_pairable(struct sock *sk, struct hci_dev *hdev, void *data, return err; } -static int set_link_security(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) +static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_mode *cp = data; struct pending_cmd *cmd; @@ -1056,7 +1056,7 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, if (mgmt_pending_find(MGMT_OP_SET_LINK_SECURITY, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } @@ -1097,7 +1097,7 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, - MGMT_STATUS_NOT_SUPPORTED); + MGMT_STATUS_NOT_SUPPORTED); goto failed; } @@ -1122,8 +1122,8 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) } if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { - err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, - MGMT_STATUS_BUSY); + err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, + MGMT_STATUS_BUSY); goto failed; } @@ -1157,7 +1157,7 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) if (!enable_hs) return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, - MGMT_STATUS_NOT_SUPPORTED); + MGMT_STATUS_NOT_SUPPORTED); if (cp->val) set_bit(HCI_HS_ENABLED, &hdev->dev_flags); @@ -1181,7 +1181,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) if (!enable_le || !(hdev->features[4] & LMP_LE)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, - MGMT_STATUS_NOT_SUPPORTED); + MGMT_STATUS_NOT_SUPPORTED); goto unlock; } @@ -1208,7 +1208,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto unlock; } @@ -1225,8 +1225,8 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) hci_cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); } - err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, - sizeof(hci_cp), &hci_cp); + err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp), + &hci_cp); if (err < 0) { mgmt_pending_remove(cmd); goto unlock; @@ -1250,7 +1250,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } @@ -1275,7 +1275,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_UUID, 0, - hdev->dev_class, 3); + hdev->dev_class, 3); goto failed; } @@ -1318,7 +1318,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto unlock; } @@ -1327,7 +1327,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, if (enable_service_cache(hdev)) { err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_UUID, - 0, hdev->dev_class, 3); + 0, hdev->dev_class, 3); goto unlock; } @@ -1348,7 +1348,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, if (found == 0) { err = cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto unlock; } @@ -1363,7 +1363,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_UUID, 0, - hdev->dev_class, 3); + hdev->dev_class, 3); goto unlock; } @@ -1379,7 +1379,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, } static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_set_dev_class *cp = data; struct pending_cmd *cmd; @@ -1391,7 +1391,7 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto unlock; } @@ -1400,7 +1400,7 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, if (!hdev_is_powered(hdev)) { err = cmd_complete(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 0, - hdev->dev_class, 3); + hdev->dev_class, 3); goto unlock; } @@ -1417,7 +1417,7 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, if (!test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { err = cmd_complete(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 0, - hdev->dev_class, 3); + hdev->dev_class, 3); goto unlock; } @@ -1447,7 +1447,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, BT_ERR("load_link_keys: expected %u bytes, got %u bytes", len, expected_len); return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); } BT_DBG("%s debug_keys %u key_count %u", hdev->name, cp->debug_keys, @@ -1468,7 +1468,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, struct mgmt_link_key_info *key = &cp->keys[i]; hci_add_link_key(hdev, NULL, 0, &key->addr.bdaddr, key->val, - key->type, key->pin_len); + key->type, key->pin_len); } cmd_complete(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0); @@ -1479,7 +1479,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, } static int device_unpaired(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 addr_type, struct sock *skip_sk) + u8 addr_type, struct sock *skip_sk) { struct mgmt_ev_device_unpaired ev; @@ -1487,11 +1487,11 @@ static int device_unpaired(struct hci_dev *hdev, bdaddr_t *bdaddr, ev.addr.type = addr_type; return mgmt_event(MGMT_EV_DEVICE_UNPAIRED, hdev, &ev, sizeof(ev), - skip_sk); + skip_sk); } static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_unpair_device *cp = data; struct mgmt_rp_unpair_device rp; @@ -1508,8 +1508,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, if (!hdev_is_powered(hdev)) { err = cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, - MGMT_STATUS_NOT_POWERED, - &rp, sizeof(rp)); + MGMT_STATUS_NOT_POWERED, &rp, sizeof(rp)); goto unlock; } @@ -1520,8 +1519,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, if (err < 0) { err = cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, - MGMT_STATUS_NOT_PAIRED, - &rp, sizeof(rp)); + MGMT_STATUS_NOT_PAIRED, &rp, sizeof(rp)); goto unlock; } @@ -1538,13 +1536,13 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, if (!conn) { err = cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, 0, - &rp, sizeof(rp)); + &rp, sizeof(rp)); device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); goto unlock; } cmd = mgmt_pending_add(sk, MGMT_OP_UNPAIR_DEVICE, hdev, cp, - sizeof(*cp)); + sizeof(*cp)); if (!cmd) { err = -ENOMEM; goto unlock; @@ -1562,7 +1560,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, } static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_disconnect *cp = data; struct hci_cp_disconnect dc; @@ -1576,13 +1574,13 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, if (!test_bit(HCI_UP, &hdev->flags)) { err = cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto failed; } if (mgmt_pending_find(MGMT_OP_DISCONNECT, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } @@ -1593,7 +1591,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, if (!conn) { err = cmd_status(sk, hdev->id, MGMT_OP_DISCONNECT, - MGMT_STATUS_NOT_CONNECTED); + MGMT_STATUS_NOT_CONNECTED); goto failed; } @@ -1634,8 +1632,8 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type) } } -static int get_connections(struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len) +static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len) { struct mgmt_rp_get_connections *rp; struct hci_conn *c; @@ -1649,7 +1647,7 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto unlock; } @@ -1683,7 +1681,7 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); err = cmd_complete(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, 0, rp, - rp_len); + rp_len); kfree(rp); @@ -1693,18 +1691,18 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, } static int send_pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, - struct mgmt_cp_pin_code_neg_reply *cp) + struct mgmt_cp_pin_code_neg_reply *cp) { struct pending_cmd *cmd; int err; cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, hdev, cp, - sizeof(*cp)); + sizeof(*cp)); if (!cmd) return -ENOMEM; err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, - sizeof(cp->addr.bdaddr), &cp->addr.bdaddr); + sizeof(cp->addr.bdaddr), &cp->addr.bdaddr); if (err < 0) mgmt_pending_remove(cmd); @@ -1712,7 +1710,7 @@ static int send_pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, } static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct hci_conn *conn; struct mgmt_cp_pin_code_reply *cp = data; @@ -1726,14 +1724,14 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto failed; } conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); if (!conn) { err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, - MGMT_STATUS_NOT_CONNECTED); + MGMT_STATUS_NOT_CONNECTED); goto failed; } @@ -1747,7 +1745,7 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, err = send_pin_code_neg_reply(sk, hdev, &ncp); if (err >= 0) err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto failed; } @@ -1772,7 +1770,7 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data, } static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) + void *data, u16 len) { struct mgmt_cp_pin_code_neg_reply *cp = data; int err; @@ -1783,7 +1781,7 @@ static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto failed; } @@ -1794,8 +1792,8 @@ static int pin_code_neg_reply(struct sock *sk, struct hci_dev *hdev, return err; } -static int set_io_capability(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) +static int set_io_capability(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_set_io_capability *cp = data; @@ -1810,8 +1808,8 @@ static int set_io_capability(struct sock *sk, struct hci_dev *hdev, hci_dev_unlock(hdev); - return cmd_complete(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, 0, - NULL, 0); + return cmd_complete(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, 0, NULL, + 0); } static inline struct pending_cmd *find_pairing(struct hci_conn *conn) @@ -1841,7 +1839,7 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) rp.addr.type = link_to_mgmt(conn->type, conn->dst_type); cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, - &rp, sizeof(rp)); + &rp, sizeof(rp)); /* So we don't get further callbacks for this connection */ conn->connect_cfm_cb = NULL; @@ -1867,7 +1865,7 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status) } static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_pair_device *cp = data; struct mgmt_rp_pair_device rp; @@ -1882,7 +1880,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_PAIR_DEVICE, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto unlock; } @@ -1894,10 +1892,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, if (cp->addr.type == MGMT_ADDR_BREDR) conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr, sec_level, - auth_type); + auth_type); else conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr, sec_level, - auth_type); + auth_type); memset(&rp, 0, sizeof(rp)); bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); @@ -1905,15 +1903,15 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, if (IS_ERR(conn)) { err = cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, - MGMT_STATUS_CONNECT_FAILED, - &rp, sizeof(rp)); + MGMT_STATUS_CONNECT_FAILED, &rp, + sizeof(rp)); goto unlock; } if (conn->connect_cfm_cb) { hci_conn_put(conn); err = cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, - MGMT_STATUS_BUSY, &rp, sizeof(rp)); + MGMT_STATUS_BUSY, &rp, sizeof(rp)); goto unlock; } @@ -1944,8 +1942,8 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, return err; } -static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) +static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_addr_info *addr = data; struct pending_cmd *cmd; @@ -1958,14 +1956,14 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto unlock; } cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev); if (!cmd) { err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto unlock; } @@ -1973,22 +1971,22 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, if (bacmp(&addr->bdaddr, &conn->dst) != 0) { err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto unlock; } pairing_complete(cmd, MGMT_STATUS_CANCELLED); err = cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, - addr, sizeof(*addr)); + addr, sizeof(*addr)); unlock: hci_dev_unlock(hdev); return err; } static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 type, u16 mgmt_op, - u16 hci_op, __le32 passkey) + bdaddr_t *bdaddr, u8 type, u16 mgmt_op, + u16 hci_op, __le32 passkey) { struct pending_cmd *cmd; struct hci_conn *conn; @@ -1998,7 +1996,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, mgmt_op, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto done; } @@ -2009,7 +2007,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, if (!conn) { err = cmd_status(sk, hdev->id, mgmt_op, - MGMT_STATUS_NOT_CONNECTED); + MGMT_STATUS_NOT_CONNECTED); goto done; } @@ -2019,10 +2017,10 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, if (!err) err = cmd_status(sk, hdev->id, mgmt_op, - MGMT_STATUS_SUCCESS); + MGMT_STATUS_SUCCESS); else err = cmd_status(sk, hdev->id, mgmt_op, - MGMT_STATUS_FAILED); + MGMT_STATUS_FAILED); goto done; } @@ -2051,8 +2049,8 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, return err; } -static int user_confirm_reply(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) +static int user_confirm_reply(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_user_confirm_reply *cp = data; @@ -2060,48 +2058,47 @@ static int user_confirm_reply(struct sock *sk, struct hci_dev *hdev, if (len != sizeof(*cp)) return cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_REPLY, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, - MGMT_OP_USER_CONFIRM_REPLY, - HCI_OP_USER_CONFIRM_REPLY, 0); + MGMT_OP_USER_CONFIRM_REPLY, + HCI_OP_USER_CONFIRM_REPLY, 0); } static int user_confirm_neg_reply(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) + void *data, u16 len) { struct mgmt_cp_user_confirm_neg_reply *cp = data; BT_DBG(""); return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, - MGMT_OP_USER_CONFIRM_NEG_REPLY, - HCI_OP_USER_CONFIRM_NEG_REPLY, 0); + MGMT_OP_USER_CONFIRM_NEG_REPLY, + HCI_OP_USER_CONFIRM_NEG_REPLY, 0); } -static int user_passkey_reply(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) +static int user_passkey_reply(struct sock *sk, struct hci_dev *hdev, void *data, + u16 len) { struct mgmt_cp_user_passkey_reply *cp = data; BT_DBG(""); return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, - MGMT_OP_USER_PASSKEY_REPLY, - HCI_OP_USER_PASSKEY_REPLY, - cp->passkey); + MGMT_OP_USER_PASSKEY_REPLY, + HCI_OP_USER_PASSKEY_REPLY, cp->passkey); } static int user_passkey_neg_reply(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) + void *data, u16 len) { struct mgmt_cp_user_passkey_neg_reply *cp = data; BT_DBG(""); return user_pairing_resp(sk, hdev, &cp->addr.bdaddr, cp->addr.type, - MGMT_OP_USER_PASSKEY_NEG_REPLY, - HCI_OP_USER_PASSKEY_NEG_REPLY, 0); + MGMT_OP_USER_PASSKEY_NEG_REPLY, + HCI_OP_USER_PASSKEY_NEG_REPLY, 0); } static int update_name(struct hci_dev *hdev, const char *name) @@ -2114,7 +2111,7 @@ static int update_name(struct hci_dev *hdev, const char *name) } static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_set_local_name *cp = data; struct pending_cmd *cmd; @@ -2130,12 +2127,12 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name)); err = cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, - data, len); + data, len); if (err < 0) goto failed; err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, data, len, - sk); + sk); goto failed; } @@ -2156,7 +2153,7 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, } static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len) + void *data, u16 data_len) { struct pending_cmd *cmd; int err; @@ -2167,19 +2164,19 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto unlock; } if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, - MGMT_STATUS_NOT_SUPPORTED); + MGMT_STATUS_NOT_SUPPORTED); goto unlock; } if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto unlock; } @@ -2199,7 +2196,7 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev, } static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) + void *data, u16 len) { struct mgmt_cp_add_remote_oob_data *cp = data; u8 status; @@ -2211,20 +2208,20 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, - MGMT_STATUS_NOT_POWERED, - &cp->addr, sizeof(cp->addr)); + MGMT_STATUS_NOT_POWERED, &cp->addr, + sizeof(cp->addr)); goto unlock; } err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, - cp->randomizer); + cp->randomizer); if (err < 0) status = MGMT_STATUS_FAILED; else status = 0; err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, status, - &cp->addr, sizeof(cp->addr)); + &cp->addr, sizeof(cp->addr)); unlock: hci_dev_unlock(hdev); @@ -2244,9 +2241,9 @@ static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_complete(sk, hdev->id, - MGMT_OP_REMOVE_REMOTE_OOB_DATA, - MGMT_STATUS_NOT_POWERED, - &cp->addr, sizeof(cp->addr)); + MGMT_OP_REMOVE_REMOTE_OOB_DATA, + MGMT_STATUS_NOT_POWERED, &cp->addr, + sizeof(cp->addr)); goto unlock; } @@ -2257,7 +2254,7 @@ static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev, status = 0; err = cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA, - status, &cp->addr, sizeof(cp->addr)); + status, &cp->addr, sizeof(cp->addr)); unlock: hci_dev_unlock(hdev); @@ -2282,7 +2279,7 @@ int mgmt_interleaved_discovery(struct hci_dev *hdev) } static int start_discovery(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) + void *data, u16 len) { struct mgmt_cp_start_discovery *cp = data; struct pending_cmd *cmd; @@ -2294,13 +2291,13 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); goto failed; } if (hdev->discovery.state != DISCOVERY_STOPPED) { err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, - MGMT_STATUS_BUSY); + MGMT_STATUS_BUSY); goto failed; } @@ -2323,7 +2320,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, case DISCOV_TYPE_LE: if (lmp_host_le_capable(hdev)) err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, - LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); + LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); else err = -ENOTSUPP; break; @@ -2331,7 +2328,8 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, case DISCOV_TYPE_INTERLEAVED: if (lmp_host_le_capable(hdev) && lmp_bredr_capable(hdev)) err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, - LE_SCAN_WIN, LE_SCAN_TIMEOUT_BREDR_LE); + LE_SCAN_WIN, + LE_SCAN_TIMEOUT_BREDR_LE); else err = -ENOTSUPP; break; @@ -2351,7 +2349,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, } static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_stop_discovery *mgmt_cp = data; struct pending_cmd *cmd; @@ -2365,15 +2363,15 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, if (!hci_discovery_active(hdev)) { err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, - MGMT_STATUS_REJECTED, - &mgmt_cp->type, sizeof(mgmt_cp->type)); + MGMT_STATUS_REJECTED, &mgmt_cp->type, + sizeof(mgmt_cp->type)); goto unlock; } if (hdev->discovery.type != mgmt_cp->type) { err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, - MGMT_STATUS_INVALID_PARAMS, - &mgmt_cp->type, sizeof(mgmt_cp->type)); + MGMT_STATUS_INVALID_PARAMS, &mgmt_cp->type, + sizeof(mgmt_cp->type)); goto unlock; } @@ -2396,14 +2394,14 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, if (!e) { mgmt_pending_remove(cmd); err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, 0, - &mgmt_cp->type, sizeof(mgmt_cp->type)); + &mgmt_cp->type, sizeof(mgmt_cp->type)); hci_discovery_set_state(hdev, DISCOVERY_STOPPED); goto unlock; } bacpy(&cp.bdaddr, &e->data.bdaddr); - err = hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ_CANCEL, - sizeof(cp), &cp); + err = hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ_CANCEL, sizeof(cp), + &cp); if (err < 0) mgmt_pending_remove(cmd); else @@ -2415,7 +2413,7 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, } static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_confirm_name *cp = data; struct inquiry_entry *e; @@ -2427,14 +2425,14 @@ static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data, if (!hci_discovery_active(hdev)) { err = cmd_status(sk, hdev->id, MGMT_OP_CONFIRM_NAME, - MGMT_STATUS_FAILED); + MGMT_STATUS_FAILED); goto failed; } e = hci_inquiry_cache_lookup_unknown(hdev, &cp->addr.bdaddr); if (!e) { err = cmd_status(sk, hdev->id, MGMT_OP_CONFIRM_NAME, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto failed; } @@ -2454,7 +2452,7 @@ static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data, } static int block_device(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_block_device *cp = data; u8 status; @@ -2471,7 +2469,7 @@ static int block_device(struct sock *sk, struct hci_dev *hdev, void *data, status = 0; err = cmd_complete(sk, hdev->id, MGMT_OP_BLOCK_DEVICE, status, - &cp->addr, sizeof(cp->addr)); + &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); @@ -2479,7 +2477,7 @@ static int block_device(struct sock *sk, struct hci_dev *hdev, void *data, } static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data, - u16 len) + u16 len) { struct mgmt_cp_unblock_device *cp = data; u8 status; @@ -2496,7 +2494,7 @@ static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data, status = 0; err = cmd_complete(sk, hdev->id, MGMT_OP_UNBLOCK_DEVICE, status, - &cp->addr, sizeof(cp->addr)); + &cp->addr, sizeof(cp->addr)); hci_dev_unlock(hdev); @@ -2504,7 +2502,7 @@ static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data, } static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, - void *data, u16 len) + void *data, u16 len) { struct mgmt_mode *cp = data; struct hci_cp_write_page_scan_activity acp; @@ -2515,11 +2513,11 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, if (!hdev_is_powered(hdev)) return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_NOT_POWERED); + MGMT_STATUS_NOT_POWERED); if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_REJECTED); + MGMT_STATUS_REJECTED); hci_dev_lock(hdev); @@ -2533,30 +2531,30 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, acp.window = 0x0012; /* default 11.25 msec page scan window */ - err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, - sizeof(acp), &acp); + err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY, sizeof(acp), + &acp); if (err < 0) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_FAILED); + MGMT_STATUS_FAILED); goto done; } err = hci_send_cmd(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type); if (err < 0) { err = cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, - MGMT_STATUS_FAILED); + MGMT_STATUS_FAILED); goto done; } err = cmd_complete(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, 0, - NULL, 0); + NULL, 0); done: hci_dev_unlock(hdev); return err; } static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, - void *cp_data, u16 len) + void *cp_data, u16 len) { struct mgmt_cp_load_long_term_keys *cp = cp_data; u16 key_count, expected_len; @@ -2570,7 +2568,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, BT_ERR("load_keys: expected %u bytes, got %u bytes", len, expected_len); return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, - EINVAL); + EINVAL); } BT_DBG("%s key_count %u", hdev->name, key_count); @@ -2589,8 +2587,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, type = HCI_SMP_LTK_SLAVE; hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type, - type, 0, key->authenticated, key->val, - key->enc_size, key->ediv, key->rand); + type, 0, key->authenticated, key->val, + key->enc_size, key->ediv, key->rand); } hci_dev_unlock(hdev); @@ -2599,8 +2597,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, } struct mgmt_handler { - int (*func) (struct sock *sk, struct hci_dev *hdev, - void *data, u16 data_len); + int (*func) (struct sock *sk, struct hci_dev *hdev, void *data, + u16 data_len); bool var_len; size_t data_len; } mgmt_handlers[] = { @@ -2685,7 +2683,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) hdev = hci_dev_get(index); if (!hdev) { err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_INDEX); + MGMT_STATUS_INVALID_INDEX); goto done; } } @@ -2694,14 +2692,14 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) mgmt_handlers[opcode].func == NULL) { BT_DBG("Unknown op %u", opcode); err = cmd_status(sk, index, opcode, - MGMT_STATUS_UNKNOWN_COMMAND); + MGMT_STATUS_UNKNOWN_COMMAND); goto done; } if ((hdev && opcode < MGMT_OP_READ_INFO) || (!hdev && opcode >= MGMT_OP_READ_INFO)) { err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_INDEX); + MGMT_STATUS_INVALID_INDEX); goto done; } @@ -2710,7 +2708,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) if ((handler->var_len && len < handler->data_len) || (!handler->var_len && len != handler->data_len)) { err = cmd_status(sk, index, opcode, - MGMT_STATUS_INVALID_PARAMS); + MGMT_STATUS_INVALID_PARAMS); goto done; } @@ -2829,7 +2827,7 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) } mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, settings_rsp, - &match); + &match); if (changed) err = new_settings(hdev, match.sk); @@ -2855,7 +2853,7 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable) } mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, settings_rsp, - &match); + &match); if (changed) err = new_settings(hdev, match.sk); @@ -2872,17 +2870,16 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) if (scan & SCAN_PAGE) mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, - cmd_status_rsp, &mgmt_err); + cmd_status_rsp, &mgmt_err); if (scan & SCAN_INQUIRY) mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, - cmd_status_rsp, &mgmt_err); + cmd_status_rsp, &mgmt_err); return 0; } -int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, - u8 persistent) +int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent) { struct mgmt_ev_new_link_key ev; @@ -2917,13 +2914,13 @@ int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent) memcpy(ev.key.rand, key->rand, sizeof(key->rand)); memcpy(ev.key.val, key->val, sizeof(key->val)); - return mgmt_event(MGMT_EV_NEW_LONG_TERM_KEY, hdev, - &ev, sizeof(ev), NULL); + return mgmt_event(MGMT_EV_NEW_LONG_TERM_KEY, hdev, &ev, sizeof(ev), + NULL); } int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u32 flags, u8 *name, - u8 name_len, u8 *dev_class) + u8 addr_type, u32 flags, u8 *name, u8 name_len, + u8 *dev_class) { char buf[512]; struct mgmt_ev_device_connected *ev = (void *) buf; @@ -2936,16 +2933,16 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, if (name_len > 0) eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, - name, name_len); + name, name_len); if (dev_class && memcmp(dev_class, "\0\0\0", 3) != 0) eir_len = eir_append_data(&ev->eir[eir_len], eir_len, - EIR_CLASS_OF_DEV, dev_class, 3); + EIR_CLASS_OF_DEV, dev_class, 3); put_unaligned_le16(eir_len, &ev->eir_len); return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, buf, - sizeof(*ev) + eir_len, NULL); + sizeof(*ev) + eir_len, NULL); } static void disconnect_rsp(struct pending_cmd *cmd, void *data) @@ -2958,7 +2955,7 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) rp.addr.type = cp->addr.type; cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, 0, &rp, - sizeof(rp)); + sizeof(rp)); *sk = cmd->sk; sock_hold(*sk); @@ -2984,7 +2981,7 @@ static void unpair_device_rsp(struct pending_cmd *cmd, void *data) } int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type) + u8 link_type, u8 addr_type) { struct mgmt_addr_info ev; struct sock *sk = NULL; @@ -2996,19 +2993,19 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, ev.type = link_to_mgmt(link_type, addr_type); err = mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev), - sk); + sk); if (sk) - sock_put(sk); + sock_put(sk); mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, - hdev); + hdev); return err; } int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status) + u8 link_type, u8 addr_type, u8 status) { struct mgmt_rp_disconnect rp; struct pending_cmd *cmd; @@ -3022,7 +3019,7 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, rp.addr.type = link_to_mgmt(link_type, addr_type); err = cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT, - mgmt_status(status), &rp, sizeof(rp)); + mgmt_status(status), &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3032,7 +3029,7 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, } int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 status) + u8 addr_type, u8 status) { struct mgmt_ev_connect_failed ev; @@ -3052,11 +3049,11 @@ int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure) ev.secure = secure; return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev), - NULL); + NULL); } int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status) + u8 status) { struct pending_cmd *cmd; struct mgmt_rp_pin_code_reply rp; @@ -3070,7 +3067,7 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, rp.addr.type = MGMT_ADDR_BREDR; err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, - mgmt_status(status), &rp, sizeof(rp)); + mgmt_status(status), &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3078,7 +3075,7 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, } int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status) + u8 status) { struct pending_cmd *cmd; struct mgmt_rp_pin_code_reply rp; @@ -3092,7 +3089,7 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, rp.addr.type = MGMT_ADDR_BREDR; err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, - mgmt_status(status), &rp, sizeof(rp)); + mgmt_status(status), &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3100,8 +3097,8 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, } int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, __le32 value, - u8 confirm_hint) + u8 link_type, u8 addr_type, __le32 value, + u8 confirm_hint) { struct mgmt_ev_user_confirm_request ev; @@ -3113,7 +3110,7 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, put_unaligned_le32(value, &ev.value); return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev), - NULL); + NULL); } int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, @@ -3127,7 +3124,7 @@ int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, ev.addr.type = link_to_mgmt(link_type, addr_type); return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev), - NULL); + NULL); } static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, @@ -3145,7 +3142,7 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, bacpy(&rp.addr.bdaddr, bdaddr); rp.addr.type = link_to_mgmt(link_type, addr_type); err = cmd_complete(cmd->sk, hdev->id, opcode, mgmt_status(status), - &rp, sizeof(rp)); + &rp, sizeof(rp)); mgmt_pending_remove(cmd); @@ -3153,35 +3150,35 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, } int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status) + u8 link_type, u8 addr_type, u8 status) { return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, - status, MGMT_OP_USER_CONFIRM_REPLY); + status, MGMT_OP_USER_CONFIRM_REPLY); } int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status) + u8 link_type, u8 addr_type, u8 status) { return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, - status, MGMT_OP_USER_CONFIRM_NEG_REPLY); + status, MGMT_OP_USER_CONFIRM_NEG_REPLY); } int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status) + u8 link_type, u8 addr_type, u8 status) { return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, - status, MGMT_OP_USER_PASSKEY_REPLY); + status, MGMT_OP_USER_PASSKEY_REPLY); } int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 link_type, u8 addr_type, u8 status) + u8 link_type, u8 addr_type, u8 status) { return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type, - status, MGMT_OP_USER_PASSKEY_NEG_REPLY); + status, MGMT_OP_USER_PASSKEY_NEG_REPLY); } int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 status) + u8 addr_type, u8 status) { struct mgmt_ev_auth_failed ev; @@ -3201,7 +3198,7 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) if (status) { u8 mgmt_err = mgmt_status(status); mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, - cmd_status_rsp, &mgmt_err); + cmd_status_rsp, &mgmt_err); return 0; } @@ -3214,7 +3211,7 @@ int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) } mgmt_pending_foreach(MGMT_OP_SET_LINK_SECURITY, hdev, settings_rsp, - &match); + &match); if (changed) err = new_settings(hdev, match.sk); @@ -3249,11 +3246,11 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) u8 mgmt_err = mgmt_status(status); if (enable && test_and_clear_bit(HCI_SSP_ENABLED, - &hdev->dev_flags)) + &hdev->dev_flags)) err = new_settings(hdev, NULL); - mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, - cmd_status_rsp, &mgmt_err); + mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, cmd_status_rsp, + &mgmt_err); return err; } @@ -3287,7 +3284,7 @@ static void class_rsp(struct pending_cmd *cmd, void *data) struct cmd_lookup *match = data; cmd_complete(cmd->sk, cmd->index, cmd->opcode, match->mgmt_status, - match->hdev->dev_class, 3); + match->hdev->dev_class, 3); list_del(&cmd->list); @@ -3300,7 +3297,7 @@ static void class_rsp(struct pending_cmd *cmd, void *data) } int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, - u8 status) + u8 status) { struct cmd_lookup match = { NULL, hdev, mgmt_status(status) }; int err = 0; @@ -3312,8 +3309,8 @@ int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, mgmt_pending_foreach(MGMT_OP_REMOVE_UUID, hdev, class_rsp, &match); if (!status) - err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, - dev_class, 3, NULL); + err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class, + 3, NULL); if (match.sk) sock_put(match.sk); @@ -3347,19 +3344,19 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) if (status) { err = cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, - mgmt_status(status)); + mgmt_status(status)); goto failed; } err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, &ev, - sizeof(ev)); + sizeof(ev)); if (err < 0) goto failed; send_event: if (changed) err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, - sizeof(ev), cmd ? cmd->sk : NULL); + sizeof(ev), cmd ? cmd->sk : NULL); update_eir(hdev); @@ -3370,7 +3367,7 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) } int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, - u8 *randomizer, u8 status) + u8 *randomizer, u8 status) { struct pending_cmd *cmd; int err; @@ -3382,9 +3379,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, return -ENOENT; if (status) { - err = cmd_status(cmd->sk, hdev->id, - MGMT_OP_READ_LOCAL_OOB_DATA, - mgmt_status(status)); + err = cmd_status(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, + mgmt_status(status)); } else { struct mgmt_rp_read_local_oob_data rp; @@ -3392,8 +3388,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, memcpy(rp.randomizer, randomizer, sizeof(rp.randomizer)); err = cmd_complete(cmd->sk, hdev->id, - MGMT_OP_READ_LOCAL_OOB_DATA, - 0, &rp, sizeof(rp)); + MGMT_OP_READ_LOCAL_OOB_DATA, 0, &rp, + sizeof(rp)); } mgmt_pending_remove(cmd); @@ -3411,11 +3407,11 @@ int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) u8 mgmt_err = mgmt_status(status); if (enable && test_and_clear_bit(HCI_LE_ENABLED, - &hdev->dev_flags)) - err = new_settings(hdev, NULL); + &hdev->dev_flags)) + err = new_settings(hdev, NULL); mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, - cmd_status_rsp, &mgmt_err); + cmd_status_rsp, &mgmt_err); return err; } @@ -3440,8 +3436,8 @@ int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) } int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, u8 *dev_class, s8 rssi, - u8 cfm_name, u8 ssp, u8 *eir, u16 eir_len) + u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, u8 + ssp, u8 *eir, u16 eir_len) { char buf[512]; struct mgmt_ev_device_found *ev = (void *) buf; @@ -3466,7 +3462,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, if (dev_class && !eir_has_data_type(ev->eir, eir_len, EIR_CLASS_OF_DEV)) eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV, - dev_class, 3); + dev_class, 3); put_unaligned_le16(eir_len, &ev->eir_len); @@ -3476,7 +3472,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, } int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, - u8 addr_type, s8 rssi, u8 *name, u8 name_len) + u8 addr_type, s8 rssi, u8 *name, u8 name_len) { struct mgmt_ev_device_found *ev; char buf[sizeof(*ev) + HCI_MAX_NAME_LENGTH + 2]; @@ -3491,12 +3487,12 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, ev->rssi = rssi; eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name, - name_len); + name_len); put_unaligned_le16(eir_len, &ev->eir_len); return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, - sizeof(*ev) + eir_len, NULL); + sizeof(*ev) + eir_len, NULL); } int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) @@ -3514,7 +3510,7 @@ int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status) type = hdev->discovery.type; err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status), - &type, sizeof(type)); + &type, sizeof(type)); mgmt_pending_remove(cmd); return err; @@ -3530,8 +3526,7 @@ int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status) return -ENOENT; err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status), - &hdev->discovery.type, - sizeof(hdev->discovery.type)); + &hdev->discovery.type, sizeof(hdev->discovery.type)); mgmt_pending_remove(cmd); return err; @@ -3552,8 +3547,8 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) if (cmd != NULL) { u8 type = hdev->discovery.type; - cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, - &type, sizeof(type)); + cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0, &type, + sizeof(type)); mgmt_pending_remove(cmd); } @@ -3575,7 +3570,7 @@ int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) ev.addr.type = type; return mgmt_event(MGMT_EV_DEVICE_BLOCKED, hdev, &ev, sizeof(ev), - cmd ? cmd->sk : NULL); + cmd ? cmd->sk : NULL); } int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) @@ -3589,7 +3584,7 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) ev.addr.type = type; return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev), - cmd ? cmd->sk : NULL); + cmd ? cmd->sk : NULL); } module_param(enable_hs, bool, 0644); diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 75937d73d8ae..8f56282c247d 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -264,7 +264,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send) clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type, - hcon->dst_type, reason); + hcon->dst_type, reason); if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) { cancel_delayed_work_sync(&conn->security_timer); @@ -384,12 +384,11 @@ static void confirm_work(struct work_struct *work) if (conn->hcon->out) ret = smp_c1(tfm, smp->tk, smp->prnd, smp->preq, smp->prsp, 0, - conn->src, conn->hcon->dst_type, conn->dst, - res); + conn->src, conn->hcon->dst_type, conn->dst, res); else ret = smp_c1(tfm, smp->tk, smp->prnd, smp->preq, smp->prsp, - conn->hcon->dst_type, conn->dst, 0, conn->src, - res); + conn->hcon->dst_type, conn->dst, 0, conn->src, + res); if (ret) { reason = SMP_UNSPECIFIED; goto error; @@ -424,12 +423,10 @@ static void random_work(struct work_struct *work) if (hcon->out) ret = smp_c1(tfm, smp->tk, smp->rrnd, smp->preq, smp->prsp, 0, - conn->src, hcon->dst_type, conn->dst, - res); + conn->src, hcon->dst_type, conn->dst, res); else ret = smp_c1(tfm, smp->tk, smp->rrnd, smp->preq, smp->prsp, - hcon->dst_type, conn->dst, 0, conn->src, - res); + hcon->dst_type, conn->dst, 0, conn->src, res); if (ret) { reason = SMP_UNSPECIFIED; goto error; @@ -454,7 +451,7 @@ static void random_work(struct work_struct *work) swap128(key, stk); memset(stk + smp->enc_key_size, 0, - SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); + SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) { reason = SMP_UNSPECIFIED; @@ -480,8 +477,8 @@ static void random_work(struct work_struct *work) SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); hci_add_ltk(hcon->hdev, conn->dst, hcon->dst_type, - HCI_SMP_STK_SLAVE, 0, 0, stk, - smp->enc_key_size, ediv, rand); + HCI_SMP_STK_SLAVE, 0, 0, stk, smp->enc_key_size, + ediv, rand); } return; @@ -829,8 +826,8 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb) hci_dev_lock(hdev); authenticated = (conn->hcon->sec_level == BT_SECURITY_HIGH); hci_add_ltk(conn->hcon->hdev, conn->dst, hcon->dst_type, - HCI_SMP_LTK, 1, authenticated, smp->tk, - smp->enc_key_size, rp->ediv, rp->rand); + HCI_SMP_LTK, 1, authenticated, smp->tk, smp->enc_key_size, + rp->ediv, rp->rand); smp_distribute_keys(conn, 1); hci_dev_unlock(hdev); @@ -954,9 +951,8 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) authenticated = hcon->sec_level == BT_SECURITY_HIGH; hci_add_ltk(conn->hcon->hdev, conn->dst, hcon->dst_type, - HCI_SMP_LTK_SLAVE, 1, authenticated, - enc.ltk, smp->enc_key_size, - ediv, ident.rand); + HCI_SMP_LTK_SLAVE, 1, authenticated, + enc.ltk, smp->enc_key_size, ediv, ident.rand); ident.ediv = cpu_to_le16(ediv); -- GitLab From 9498ba7a1d38d42eef4ef6d906ab1743c9f0fd6f Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 5 Dec 2011 22:15:29 +0000 Subject: [PATCH 1565/1846] Bluetooth: Adding USB device 13d3:3375 as an Atheros AR3012. The bluetooth module in the Asus UX31/UX21 is based on Atheros AR3012 and requires a firmware to be uploaded before it's usable. output of usb-devices for this module: T: Bus=01 Lev=02 Prnt=02 Port=07 Cnt=03 Dev#= 6 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3375 Rev=00.02 S: Manufacturer=Atheros Communications S: Product=Bluetooth USB Host Controller S: SerialNumber=Alaska Day 2006 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb Signed-off-by: Eran Tested-by: Michal Labedzki Signed-off-by: Gustavo F. Padovan --- drivers/bluetooth/ath3k.c | 2 ++ drivers/bluetooth/btusb.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 4eca6e5cbf22..48442476ec00 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -72,6 +72,7 @@ static struct usb_device_id ath3k_table[] = { /* Atheros AR3012 with sflash firmware*/ { USB_DEVICE(0x0CF3, 0x3004) }, + { USB_DEVICE(0x13d3, 0x3375) }, /* Atheros AR5BBU12 with sflash firmware */ { USB_DEVICE(0x0489, 0xE02C) }, @@ -88,6 +89,7 @@ static struct usb_device_id ath3k_blist_tbl[] = { /* Atheros AR3012 with sflash firmware*/ { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, + { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, { } /* Terminating entry */ }; diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 22f695e2b730..480cad920048 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -129,6 +129,7 @@ static struct usb_device_id blacklist_table[] = { /* Atheros 3012 with sflash firmware */ { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, + { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, /* Atheros AR5BBU12 with sflash firmware */ { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, -- GitLab From e57d758ae8e8f00e80f233c823aeeef34bd92796 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 7 Mar 2012 20:20:14 +0200 Subject: [PATCH 1566/1846] Bluetooth: Fix using uninitialized variable + src/net/bluetooth/rfcomm/tty.c: warning: 'p' is used uninitialized in this function: => 218 + src/net/bluetooth/rfcomm/tty.c: warning: 'p' may be used uninitialized in this function: => 218 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Gustavo F. Padovan --- net/bluetooth/rfcomm/tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index a2d4f5122a6a..c179734f143f 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c @@ -196,7 +196,7 @@ static DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL); static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) { struct rfcomm_dev *dev, *entry; - struct list_head *head = &rfcomm_dev_list, *p; + struct list_head *head = &rfcomm_dev_list; int err = 0; BT_DBG("id %d channel %d", req->dev_id, req->channel); @@ -215,7 +215,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) break; dev->id++; - head = p; + head = &entry->list; } } else { dev->id = req->dev_id; @@ -229,7 +229,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) if (entry->id > dev->id - 1) break; - head = p; + head = &entry->list; } } -- GitLab From b3ff53ff006b7906c88adf9d0fccc06a8877fae1 Mon Sep 17 00:00:00 2001 From: Ido Yariv Date: Mon, 5 Mar 2012 20:07:08 +0200 Subject: [PATCH 1567/1846] Bluetooth: Fix access to the STK generation methods matrix The major index of the table is actually the remote I/O capabilities, not the local ones. As a result, devices with different I/O capabilities could have used wrong or even unsupported generation methods. Signed-off-by: Ido Yariv CC: Brian Gix Acked-by: Vinicius Costa Gomes Signed-off-by: Gustavo F. Padovan --- net/bluetooth/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 8f56282c247d..9883d673873c 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -310,7 +310,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, remote_io > SMP_IO_KEYBOARD_DISPLAY) method = JUST_WORKS; else - method = gen_method[local_io][remote_io]; + method = gen_method[remote_io][local_io]; /* If not bonding, don't ask user to confirm a Zero TK */ if (!(auth & SMP_AUTH_BONDING) && method == JUST_CFM) -- GitLab From fdde0a26a218d95e2ea38c0838ab6f24040af14c Mon Sep 17 00:00:00 2001 From: Ido Yariv Date: Mon, 5 Mar 2012 20:09:38 +0200 Subject: [PATCH 1568/1846] Bluetooth: Set security level on incoming pairing request If a master would like to raise the security level, it will send a pairing request. While the pending security level is set on an incoming security request (from a slave), it is not set on a pairing request. As a result, the security level would not be raised on the slave in such case. Fix this by setting the pending security when receiving pairing requests according to the requested authorization. Signed-off-by: Ido Yariv Acked-by: Vinicius Costa Gomes Signed-off-by: Gustavo F. Padovan --- net/bluetooth/smp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 9883d673873c..deb119875fd9 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -589,6 +589,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) if (req->auth_req & SMP_AUTH_BONDING) auth = req->auth_req; + conn->hcon->pending_sec_level = authreq_to_seclevel(auth); + build_pairing_cmd(conn, req, &rsp, auth); key_size = min(req->max_key_size, rsp.max_key_size); -- GitLab From 9fbd87d413921f36d2f55cee1d082323e6eb1d5f Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 7 Mar 2012 02:06:23 +0000 Subject: [PATCH 1569/1846] af_iucv: handle netdev events In case of transport through HiperSockets the underlying network interface may switch to DOWN state or the underlying network device may recover. In both cases the socket must change to IUCV_DISCONN state. If the interface goes down, af_iucv has a chance to notify its connection peer in addition. Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- net/iucv/af_iucv.c | 106 ++++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 98d1f0ba7fe9..31537c5eb17e 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -453,14 +453,28 @@ static void iucv_sever_path(struct sock *sk, int with_user_data) } } +/* Send FIN through an IUCV socket for HIPER transport */ +static int iucv_send_ctrl(struct sock *sk, u8 flags) +{ + int err = 0; + int blen; + struct sk_buff *skb; + + blen = sizeof(struct af_iucv_trans_hdr) + ETH_HLEN; + skb = sock_alloc_send_skb(sk, blen, 1, &err); + if (skb) { + skb_reserve(skb, blen); + err = afiucv_hs_send(NULL, sk, skb, flags); + } + return err; +} + /* Close an IUCV socket */ static void iucv_sock_close(struct sock *sk) { struct iucv_sock *iucv = iucv_sk(sk); unsigned long timeo; int err = 0; - int blen; - struct sk_buff *skb; lock_sock(sk); @@ -471,14 +485,7 @@ static void iucv_sock_close(struct sock *sk) case IUCV_CONNECTED: if (iucv->transport == AF_IUCV_TRANS_HIPER) { - /* send fin */ - blen = sizeof(struct af_iucv_trans_hdr) + ETH_HLEN; - skb = sock_alloc_send_skb(sk, blen, 1, &err); - if (skb) { - skb_reserve(skb, blen); - err = afiucv_hs_send(NULL, sk, skb, - AF_IUCV_FLAG_FIN); - } + err = iucv_send_ctrl(sk, AF_IUCV_FLAG_FIN); sk->sk_state = IUCV_DISCONN; sk->sk_state_change(sk); } @@ -782,26 +789,6 @@ static int iucv_sock_autobind(struct sock *sk) return err; } -static int afiucv_hs_connect(struct socket *sock) -{ - struct sock *sk = sock->sk; - struct sk_buff *skb; - int blen = sizeof(struct af_iucv_trans_hdr) + ETH_HLEN; - int err = 0; - - /* send syn */ - skb = sock_alloc_send_skb(sk, blen, 1, &err); - if (!skb) { - err = -ENOMEM; - goto done; - } - skb->dev = NULL; - skb_reserve(skb, blen); - err = afiucv_hs_send(NULL, sk, skb, AF_IUCV_FLAG_SYN); -done: - return err; -} - static int afiucv_path_connect(struct socket *sock, struct sockaddr *addr) { struct sockaddr_iucv *sa = (struct sockaddr_iucv *) addr; @@ -882,7 +869,7 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr, memcpy(iucv->dst_name, sa->siucv_name, 8); if (iucv->transport == AF_IUCV_TRANS_HIPER) - err = afiucv_hs_connect(sock); + err = iucv_send_ctrl(sock->sk, AF_IUCV_FLAG_SYN); else err = afiucv_path_connect(sock, addr); if (err) @@ -1332,8 +1319,7 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct sock *sk = sock->sk; struct iucv_sock *iucv = iucv_sk(sk); unsigned int copied, rlen; - struct sk_buff *skb, *rskb, *cskb, *sskb; - int blen; + struct sk_buff *skb, *rskb, *cskb; int err = 0; if ((sk->sk_state == IUCV_DISCONN) && @@ -1422,15 +1408,7 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, iucv_process_message_q(sk); if (atomic_read(&iucv->msg_recv) >= iucv->msglimit / 2) { - /* send WIN to peer */ - blen = sizeof(struct af_iucv_trans_hdr) + - ETH_HLEN; - sskb = sock_alloc_send_skb(sk, blen, 1, &err); - if (sskb) { - skb_reserve(sskb, blen); - err = afiucv_hs_send(NULL, sk, sskb, - AF_IUCV_FLAG_WIN); - } + err = iucv_send_ctrl(sk, AF_IUCV_FLAG_WIN); if (err) { sk->sk_state = IUCV_DISCONN; sk->sk_state_change(sk); @@ -2289,6 +2267,44 @@ static void afiucv_hs_callback_txnotify(struct sk_buff *skb, } } + +/* + * afiucv_netdev_event: handle netdev notifier chain events + */ +static int afiucv_netdev_event(struct notifier_block *this, + unsigned long event, void *ptr) +{ + struct net_device *event_dev = (struct net_device *)ptr; + struct hlist_node *node; + struct sock *sk; + struct iucv_sock *iucv; + + switch (event) { + case NETDEV_REBOOT: + case NETDEV_GOING_DOWN: + sk_for_each(sk, node, &iucv_sk_list.head) { + iucv = iucv_sk(sk); + if ((iucv->hs_dev == event_dev) && + (sk->sk_state == IUCV_CONNECTED)) { + if (event == NETDEV_GOING_DOWN) + iucv_send_ctrl(sk, AF_IUCV_FLAG_FIN); + sk->sk_state = IUCV_DISCONN; + sk->sk_state_change(sk); + } + } + break; + case NETDEV_DOWN: + case NETDEV_UNREGISTER: + default: + break; + } + return NOTIFY_DONE; +} + +static struct notifier_block afiucv_netdev_notifier = { + .notifier_call = afiucv_netdev_event, +}; + static const struct proto_ops iucv_sock_ops = { .family = PF_IUCV, .owner = THIS_MODULE, @@ -2388,7 +2404,8 @@ static int __init afiucv_init(void) err = afiucv_iucv_init(); if (err) goto out_sock; - } + } else + register_netdevice_notifier(&afiucv_netdev_notifier); dev_add_pack(&iucv_packet_type); return 0; @@ -2409,7 +2426,8 @@ static void __exit afiucv_exit(void) driver_unregister(&af_iucv_driver); pr_iucv->iucv_unregister(&af_iucv_handler, 0); symbol_put(iucv_if); - } + } else + unregister_netdevice_notifier(&afiucv_netdev_notifier); dev_remove_pack(&iucv_packet_type); sock_unregister(PF_IUCV); proto_unregister(&iucv_proto); -- GitLab From 82492a355fac112908271faa74f473a38c1fb647 Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 7 Mar 2012 02:06:24 +0000 Subject: [PATCH 1570/1846] af_iucv: add shutdown for HS transport AF_IUCV sockets offer a shutdown function. This patch makes sure shutdown works for HS transport as well. Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- include/net/iucv/af_iucv.h | 1 + net/iucv/af_iucv.c | 79 +++++++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h index 2e1d5ecc2d1b..cc7c19732389 100644 --- a/include/net/iucv/af_iucv.h +++ b/include/net/iucv/af_iucv.h @@ -62,6 +62,7 @@ struct sock_msg_q { #define AF_IUCV_FLAG_SYN 0x2 #define AF_IUCV_FLAG_FIN 0x4 #define AF_IUCV_FLAG_WIN 0x8 +#define AF_IUCV_FLAG_SHT 0x10 struct af_iucv_trans_hdr { u16 magic; diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 31537c5eb17e..07d7d55a1b93 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -165,8 +165,6 @@ static int afiucv_pm_freeze(struct device *dev) read_lock(&iucv_sk_list.lock); sk_for_each(sk, node, &iucv_sk_list.head) { iucv = iucv_sk(sk); - skb_queue_purge(&iucv->send_skb_q); - skb_queue_purge(&iucv->backlog_skb_q); switch (sk->sk_state) { case IUCV_DISCONN: case IUCV_CLOSING: @@ -405,7 +403,19 @@ static struct sock *__iucv_get_sock_by_name(char *nm) static void iucv_sock_destruct(struct sock *sk) { skb_queue_purge(&sk->sk_receive_queue); - skb_queue_purge(&sk->sk_write_queue); + skb_queue_purge(&sk->sk_error_queue); + + sk_mem_reclaim(sk); + + if (!sock_flag(sk, SOCK_DEAD)) { + pr_err("Attempt to release alive iucv socket %p\n", sk); + return; + } + + WARN_ON(atomic_read(&sk->sk_rmem_alloc)); + WARN_ON(atomic_read(&sk->sk_wmem_alloc)); + WARN_ON(sk->sk_wmem_queued); + WARN_ON(sk->sk_forward_alloc); } /* Cleanup Listen */ @@ -1342,6 +1352,8 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, rlen = skb->len; /* real length of skb */ copied = min_t(unsigned int, rlen, len); + if (!rlen) + sk->sk_shutdown = sk->sk_shutdown | RCV_SHUTDOWN; cskb = skb; if (skb_copy_datagram_iovec(cskb, 0, msg->msg_iov, copied)) { @@ -1493,42 +1505,47 @@ static int iucv_sock_shutdown(struct socket *sock, int how) lock_sock(sk); switch (sk->sk_state) { + case IUCV_LISTEN: case IUCV_DISCONN: case IUCV_CLOSING: case IUCV_CLOSED: err = -ENOTCONN; goto fail; - default: - sk->sk_shutdown |= how; break; } if (how == SEND_SHUTDOWN || how == SHUTDOWN_MASK) { - txmsg.class = 0; - txmsg.tag = 0; - err = pr_iucv->message_send(iucv->path, &txmsg, IUCV_IPRMDATA, - 0, (void *) iprm_shutdown, 8); - if (err) { - switch (err) { - case 1: - err = -ENOTCONN; - break; - case 2: - err = -ECONNRESET; - break; - default: - err = -ENOTCONN; - break; + if (iucv->transport == AF_IUCV_TRANS_IUCV) { + txmsg.class = 0; + txmsg.tag = 0; + err = pr_iucv->message_send(iucv->path, &txmsg, + IUCV_IPRMDATA, 0, (void *) iprm_shutdown, 8); + if (err) { + switch (err) { + case 1: + err = -ENOTCONN; + break; + case 2: + err = -ECONNRESET; + break; + default: + err = -ENOTCONN; + break; + } } - } + } else + iucv_send_ctrl(sk, AF_IUCV_FLAG_SHT); } + sk->sk_shutdown |= how; if (how == RCV_SHUTDOWN || how == SHUTDOWN_MASK) { - err = pr_iucv->path_quiesce(iucv->path, NULL); - if (err) - err = -ENOTCONN; - + if (iucv->transport == AF_IUCV_TRANS_IUCV) { + err = pr_iucv->path_quiesce(iucv->path, NULL); + if (err) + err = -ENOTCONN; +/* skb_queue_purge(&sk->sk_receive_queue); */ + } skb_queue_purge(&sk->sk_receive_queue); } @@ -2066,8 +2083,13 @@ static int afiucv_hs_callback_rx(struct sock *sk, struct sk_buff *skb) return NET_RX_SUCCESS; } + if (sk->sk_shutdown & RCV_SHUTDOWN) { + kfree_skb(skb); + return NET_RX_SUCCESS; + } + /* write stuff from iucv_msg to skb cb */ - if (skb->len <= sizeof(struct af_iucv_trans_hdr)) { + if (skb->len < sizeof(struct af_iucv_trans_hdr)) { kfree_skb(skb); return NET_RX_SUCCESS; } @@ -2173,7 +2195,10 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, kfree_skb(skb); break; } - /* fall through */ + /* fall through and receive non-zero length data */ + case (AF_IUCV_FLAG_SHT): + /* shutdown request */ + /* fall through and receive zero length data */ case 0: /* plain data frame */ memcpy(CB_TRGCLS(skb), &trans_hdr->iucv_hdr.class, -- GitLab From 2022e00cd5c0a9b43163834a51af664de16cfc3c Mon Sep 17 00:00:00 2001 From: Frank Blaschka Date: Wed, 7 Mar 2012 02:06:25 +0000 Subject: [PATCH 1571/1846] qeth: synchronize discipline module loading During system startup udev may try to configure devices in parallel so we have to synchronize discipline module loading. Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index cbb101828dc3..ef17d8366ce2 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -51,6 +51,7 @@ static struct kmem_cache *qeth_qdio_outbuf_cache; static struct device *qeth_core_root_dev; static unsigned int known_devices[][6] = QETH_MODELLIST_ARRAY; static struct lock_class_key qdio_out_skb_queue_key; +static struct mutex qeth_mod_mutex; static void qeth_send_control_data_cb(struct qeth_channel *, struct qeth_cmd_buffer *); @@ -5040,6 +5041,7 @@ int qeth_core_load_discipline(struct qeth_card *card, enum qeth_discipline_id discipline) { int rc = 0; + mutex_lock(&qeth_mod_mutex); switch (discipline) { case QETH_DISCIPLINE_LAYER3: card->discipline.ccwgdriver = try_then_request_module( @@ -5057,6 +5059,7 @@ int qeth_core_load_discipline(struct qeth_card *card, "support discipline %d\n", discipline); rc = -EINVAL; } + mutex_unlock(&qeth_mod_mutex); return rc; } @@ -5540,6 +5543,7 @@ static int __init qeth_core_init(void) pr_info("loading core functions\n"); INIT_LIST_HEAD(&qeth_core_card_list.list); rwlock_init(&qeth_core_card_list.rwlock); + mutex_init(&qeth_mod_mutex); rc = qeth_register_dbf_views(); if (rc) -- GitLab From ce1f893837afeee8aea0c5f6a32ebba16816beec Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 7 Mar 2012 02:06:26 +0000 Subject: [PATCH 1572/1846] ctcm: make ctcmpc debugging compilable ctcmpc debugging can be activated defining constant DEBUGCCW. The debugging part contains wrong checks for 64 bit addresses. Thus the debugging version does not compile. This patch corrects the 64-bit address checks to make it compilable. Signed-off-by: Ursula Braun Reviewed-by: Belinda Thompson Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- drivers/s390/net/ctcm_main.c | 3 +++ drivers/s390/net/ctcm_mpc.c | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 5cb93a8e3403..11f3b071f305 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -562,6 +562,9 @@ static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb) skb_queue_tail(&ch->io_queue, skb); ccw_idx = 3; } + if (do_debug_ccw) + ctcmpc_dumpit((char *)&ch->ccw[ccw_idx], + sizeof(struct ccw1) * 3); ch->retry = 0; fsm_newstate(ch->fsm, CTC_STATE_TX); fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch); diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index da4c747335e7..ac7975b7a837 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c @@ -53,8 +53,8 @@ #include #include -#include "ctcm_mpc.h" #include "ctcm_main.h" +#include "ctcm_mpc.h" #include "ctcm_fsms.h" static const struct xid2 init_xid = { @@ -132,7 +132,7 @@ void ctcmpc_dumpit(char *buf, int len) __u32 ct, sw, rm, dup; char *ptr, *rptr; char tbuf[82], tdup[82]; - #if (UTS_MACHINE == s390x) + #ifdef CONFIG_64BIT char addr[22]; #else char addr[12]; @@ -149,8 +149,8 @@ void ctcmpc_dumpit(char *buf, int len) for (ct = 0; ct < len; ct++, ptr++, rptr++) { if (sw == 0) { - #if (UTS_MACHINE == s390x) - sprintf(addr, "%16.16lx", (__u64)rptr); + #ifdef CONFIG_64BIT + sprintf(addr, "%16.16llx", (__u64)rptr); #else sprintf(addr, "%8.8X", (__u32)rptr); #endif @@ -164,8 +164,8 @@ void ctcmpc_dumpit(char *buf, int len) if (sw == 8) strcat(bhex, " "); - #if (UTS_MACHINE == s390x) - sprintf(tbuf, "%2.2lX", (__u64)*ptr); + #if CONFIG_64BIT + sprintf(tbuf, "%2.2llX", (__u64)*ptr); #else sprintf(tbuf, "%2.2X", (__u32)*ptr); #endif -- GitLab From 205a8b649cf6c0a1e6e7512b65c72df480e2a883 Mon Sep 17 00:00:00 2001 From: Belinda Thompson Date: Wed, 7 Mar 2012 02:06:27 +0000 Subject: [PATCH 1573/1846] ctcm: use correct idal word list for ctcmpc Communication Server Linux uses the ctcmpc code of the ctcm driver. Sending problems have shown up caused by a wrong idal word list for the first ccw. Function ctcmpc_chx_txdone() invokes the function to prepare the idal word list without setting an appropriate length for the first ccw, which may lead to an incomplete idal word list. This patch sets the maximum buffer size as data length of the first ccw. Thus correct idal word lists are guaranteed in all cases. Signed-off-by: Belinda Thompson Reviewed-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- drivers/s390/net/ctcm_fsms.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/s390/net/ctcm_fsms.c b/drivers/s390/net/ctcm_fsms.c index 2d602207541b..a69766900a17 100644 --- a/drivers/s390/net/ctcm_fsms.c +++ b/drivers/s390/net/ctcm_fsms.c @@ -1341,6 +1341,12 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) spin_unlock(&ch->collect_lock); clear_normalized_cda(&ch->ccw[1]); + + CTCM_PR_DBGDATA("ccwcda=0x%p data=0x%p\n", + (void *)(unsigned long)ch->ccw[1].cda, + ch->trans_skb->data); + ch->ccw[1].count = ch->max_bufsize; + if (set_normalized_cda(&ch->ccw[1], ch->trans_skb->data)) { dev_kfree_skb_any(ch->trans_skb); ch->trans_skb = NULL; @@ -1350,6 +1356,11 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); return; } + + CTCM_PR_DBGDATA("ccwcda=0x%p data=0x%p\n", + (void *)(unsigned long)ch->ccw[1].cda, + ch->trans_skb->data); + ch->ccw[1].count = ch->trans_skb->len; fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch); ch->prof.send_stamp = current_kernel_time(); /* xtime */ -- GitLab From e0a8114c034cf8012565c5d56dd90967023cc724 Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Wed, 7 Mar 2012 02:06:28 +0000 Subject: [PATCH 1574/1846] qeth: meaningful return code for set_mac_address Setting an invalid mac-address for a qeth layer2 device returns with a strange error code: # ip link set hsi1 address 00:00:00:00:00:01 RTNETLINK answers: Unknown error 18446744073709486085 Problem is caused by wrong usage of the return_code field within structure qeth_ipa_cmd. With this patch the ip command above returns SIOCSIFHWADDR: Invalid argument Signed-off-by: Ursula Braun Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 6 +++--- drivers/s390/net/qeth_core_mpc.c | 1 + drivers/s390/net/qeth_core_mpc.h | 1 + drivers/s390/net/qeth_l2_main.c | 4 +--- drivers/s390/net/qeth_l3_main.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index ef17d8366ce2..120955c66410 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -2945,8 +2945,8 @@ static int qeth_query_ipassists_cb(struct qeth_card *card, card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; } QETH_DBF_TEXT(SETUP, 2, "suppenbl"); - QETH_DBF_TEXT_(SETUP, 2, "%x", cmd->hdr.ipa_supported); - QETH_DBF_TEXT_(SETUP, 2, "%x", cmd->hdr.ipa_enabled); + QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported); + QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled); return 0; } @@ -4322,7 +4322,7 @@ static int qeth_snmp_command_cb(struct qeth_card *card, /* check if there is enough room in userspace */ if ((qinfo->udata_len - qinfo->udata_offset) < data_len) { QETH_CARD_TEXT_(card, 4, "scer3%i", -ENOMEM); - cmd->hdr.return_code = -ENOMEM; + cmd->hdr.return_code = IPA_RC_ENOMEM; return 0; } QETH_CARD_TEXT_(card, 4, "snore%i", diff --git a/drivers/s390/net/qeth_core_mpc.c b/drivers/s390/net/qeth_core_mpc.c index ec24901c802c..7fab6544def6 100644 --- a/drivers/s390/net/qeth_core_mpc.c +++ b/drivers/s390/net/qeth_core_mpc.c @@ -207,6 +207,7 @@ static struct ipa_rc_msg qeth_ipa_rc_msg[] = { {IPA_RC_MC_ADDR_ALREADY_DEFINED, "Multicast address already defined"}, {IPA_RC_LAN_OFFLINE, "STRTLAN_LAN_DISABLED - LAN offline"}, {IPA_RC_INVALID_IP_VERSION2, "Invalid IP version"}, + {IPA_RC_ENOMEM, "Memory problem"}, {IPA_RC_FFFF, "Unknown Error"} }; diff --git a/drivers/s390/net/qeth_core_mpc.h b/drivers/s390/net/qeth_core_mpc.h index 578e19a2de6b..ff41e42004ac 100644 --- a/drivers/s390/net/qeth_core_mpc.h +++ b/drivers/s390/net/qeth_core_mpc.h @@ -190,6 +190,7 @@ enum qeth_ipa_return_codes { IPA_RC_MC_ADDR_ALREADY_DEFINED = 0xe013, IPA_RC_LAN_OFFLINE = 0xe080, IPA_RC_INVALID_IP_VERSION2 = 0xf001, + IPA_RC_ENOMEM = 0xfffe, IPA_RC_FFFF = 0xffff }; /* for DELIP */ diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index e5c9cf15e5c6..0e7c29d1d7ef 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -576,7 +576,6 @@ static int qeth_l2_send_setmac_cb(struct qeth_card *card, default: break; } - cmd->hdr.return_code = -EIO; } else { card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; memcpy(card->dev->dev_addr, cmd->data.setdelmac.mac, @@ -605,7 +604,6 @@ static int qeth_l2_send_delmac_cb(struct qeth_card *card, cmd = (struct qeth_ipa_cmd *) data; if (cmd->hdr.return_code) { QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code); - cmd->hdr.return_code = -EIO; return 0; } card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; @@ -682,7 +680,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p) rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]); if (!rc) rc = qeth_l2_send_setmac(card, addr->sa_data); - return rc; + return rc ? -EINVAL : 0; } static void qeth_l2_set_multicast_list(struct net_device *dev) diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 73bf8889984b..f85921607686 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -2430,7 +2430,7 @@ static int qeth_l3_arp_query_cb(struct qeth_card *card, if ((qinfo->udata_len - qinfo->udata_offset) < esize) { QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOMEM); - cmd->hdr.return_code = -ENOMEM; + cmd->hdr.return_code = IPA_RC_ENOMEM; goto out_error; } -- GitLab From e427babeefe10023d348e2a3db272612d6e79dc3 Mon Sep 17 00:00:00 2001 From: Klaus-Dieter Wacker Date: Wed, 7 Mar 2012 02:06:29 +0000 Subject: [PATCH 1575/1846] lcs: Return zero from ccwgroup devs set_offline function A return code of non-zero of the devs ccwgroup set_offline function leaves the dev in online state. Having done a partly offlining may leave the dev in unusable state. To make sure the dev is set to offline, zero is returned. A setup trace entry is written in case the offlining steps encountered some trouble. Signed-off-by: Klaus-Dieter Wacker Signed-off-by: Frank Blaschka Signed-off-by: David S. Miller --- drivers/s390/net/lcs.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index 863fc2197155..687efe4d589a 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -2240,7 +2240,7 @@ __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode) { struct lcs_card *card; enum lcs_dev_states recover_state; - int ret; + int ret = 0, ret2 = 0, ret3 = 0; LCS_DBF_TEXT(3, setup, "shtdndev"); card = dev_get_drvdata(&ccwgdev->dev); @@ -2255,13 +2255,15 @@ __lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode) recover_state = card->state; ret = lcs_stop_device(card->dev); - ret = ccw_device_set_offline(card->read.ccwdev); - ret = ccw_device_set_offline(card->write.ccwdev); + ret2 = ccw_device_set_offline(card->read.ccwdev); + ret3 = ccw_device_set_offline(card->write.ccwdev); + if (!ret) + ret = (ret2) ? ret2 : ret3; + if (ret) + LCS_DBF_TEXT_(3, setup, "1err:%d", ret); if (recover_state == DEV_STATE_UP) { card->state = DEV_STATE_RECOVER; } - if (ret) - return ret; return 0; } -- GitLab From b8622cbd58f345d48f683d881abe3037c60aa673 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Wed, 7 Mar 2012 03:50:44 +0000 Subject: [PATCH 1576/1846] enic: Fix addr valid check in enic_set_vf_mac zero mac address is a valid address for VIC dynamic vnic and sriov Vf's. Fix the check in enic_set_vf_mac appropriately Signed-off-by: Roopa Prabhu Signed-off-by: Christian Benvenuti Signed-off-by: Sujith Sankar Signed-off-by: David S. Miller --- drivers/net/ethernet/cisco/enic/enic.h | 2 +- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index cf1fb4b9a4ad..afe9b1662b8c 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.38" +#define DRV_VERSION "2.1.1.39" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 9080ed651666..77b4e873f91c 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1069,7 +1069,7 @@ static int enic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) if (err) return err; - if (is_valid_ether_addr(mac)) { + if (is_valid_ether_addr(mac) || is_zero_ether_addr(mac)) { if (vf == PORT_SELF_VF) { memcpy(pp->vf_mac, mac, ETH_ALEN); return 0; -- GitLab From 55df5afb13718cda49128fa5985556df91d07765 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Sat, 3 Mar 2012 22:18:00 +0200 Subject: [PATCH 1577/1846] wl12xx: implement SW Tx watchdog Track freed FW blocks during Tx. If no blocks were freed during a predefined timeout, initiate a HW recovery. This helps in situations when the FW watchdog fails. Don't trigger recovery during activities that can temporarily stop Tx. This includes: - scanning - buffering packets for sleeping stations (AP role) - ROC on any role Signed-off-by: Arik Nemtsov Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 8 ++ drivers/net/wireless/wl12xx/conf.h | 3 + drivers/net/wireless/wl12xx/main.c | 110 +++++++++++++++++++++++++++ drivers/net/wireless/wl12xx/scan.c | 6 ++ drivers/net/wireless/wl12xx/tx.c | 4 + drivers/net/wireless/wl12xx/tx.h | 1 + drivers/net/wireless/wl12xx/wl12xx.h | 3 + 7 files changed, 135 insertions(+) diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 1ef212f6440f..3414fc11e9ba 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1818,6 +1818,14 @@ int wl12xx_croc(struct wl1271 *wl, u8 role_id) goto out; __clear_bit(role_id, wl->roc_map); + + /* + * Rearm the tx watchdog when removing the last ROC. This prevents + * recoveries due to just finished ROCs - when Tx hasn't yet had + * a chance to get out. + */ + if (find_first_bit(wl->roc_map, WL12XX_MAX_ROLES) >= WL12XX_MAX_ROLES) + wl12xx_rearm_tx_watchdog_locked(wl); out: return ret; } diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index cc50faaf03d1..3e581e19424c 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -690,6 +690,9 @@ struct conf_tx_settings { */ u8 tmpl_short_retry_limit; u8 tmpl_long_retry_limit; + + /* Time in ms for Tx watchdog timer to expire */ + u32 tx_watchdog_timeout; }; enum { diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 95a76a5f9eeb..39002363611e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -217,6 +217,7 @@ static struct conf_drv_settings default_conf = { .basic_rate_5 = CONF_HW_BIT_RATE_6MBPS, .tmpl_short_retry_limit = 10, .tmpl_long_retry_limit = 10, + .tx_watchdog_timeout = 5000, }, .conn = { .wake_up_event = CONF_WAKE_UP_EVENT_DTIM, @@ -553,6 +554,80 @@ static void wl1271_rx_streaming_timer(unsigned long data) ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_disable_work); } +/* wl->mutex must be taken */ +void wl12xx_rearm_tx_watchdog_locked(struct wl1271 *wl) +{ + /* if the watchdog is not armed, don't do anything */ + if (wl->tx_allocated_blocks == 0) + return; + + cancel_delayed_work(&wl->tx_watchdog_work); + ieee80211_queue_delayed_work(wl->hw, &wl->tx_watchdog_work, + msecs_to_jiffies(wl->conf.tx.tx_watchdog_timeout)); +} + +static void wl12xx_tx_watchdog_work(struct work_struct *work) +{ + struct delayed_work *dwork; + struct wl1271 *wl; + + dwork = container_of(work, struct delayed_work, work); + wl = container_of(dwork, struct wl1271, tx_watchdog_work); + + mutex_lock(&wl->mutex); + + if (unlikely(wl->state == WL1271_STATE_OFF)) + goto out; + + /* Tx went out in the meantime - everything is ok */ + if (unlikely(wl->tx_allocated_blocks == 0)) + goto out; + + /* + * if a ROC is in progress, we might not have any Tx for a long + * time (e.g. pending Tx on the non-ROC channels) + */ + if (find_first_bit(wl->roc_map, WL12XX_MAX_ROLES) < WL12XX_MAX_ROLES) { + wl1271_debug(DEBUG_TX, "No Tx (in FW) for %d ms due to ROC", + wl->conf.tx.tx_watchdog_timeout); + wl12xx_rearm_tx_watchdog_locked(wl); + goto out; + } + + /* + * if a scan is in progress, we might not have any Tx for a long + * time + */ + if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { + wl1271_debug(DEBUG_TX, "No Tx (in FW) for %d ms due to scan", + wl->conf.tx.tx_watchdog_timeout); + wl12xx_rearm_tx_watchdog_locked(wl); + goto out; + } + + /* + * AP might cache a frame for a long time for a sleeping station, + * so rearm the timer if there's an AP interface with stations. If + * Tx is genuinely stuck we will most hopefully discover it when all + * stations are removed due to inactivity. + */ + if (wl->active_sta_count) { + wl1271_debug(DEBUG_TX, "No Tx (in FW) for %d ms. AP has " + " %d stations", + wl->conf.tx.tx_watchdog_timeout, + wl->active_sta_count); + wl12xx_rearm_tx_watchdog_locked(wl); + goto out; + } + + wl1271_error("Tx stuck (in FW) for %d ms. Starting recovery", + wl->conf.tx.tx_watchdog_timeout); + wl12xx_queue_recovery_work(wl); + +out: + mutex_unlock(&wl->mutex); +} + static void wl1271_conf_init(struct wl1271 *wl) { @@ -745,6 +820,18 @@ static void wl12xx_fw_status(struct wl1271 *wl, wl->tx_allocated_blocks -= freed_blocks; + /* + * If the FW freed some blocks: + * If we still have allocated blocks - re-arm the timer, Tx is + * not stuck. Otherwise, cancel the timer (no Tx currently). + */ + if (freed_blocks) { + if (wl->tx_allocated_blocks) + wl12xx_rearm_tx_watchdog_locked(wl); + else + cancel_delayed_work(&wl->tx_watchdog_work); + } + avail = le32_to_cpu(status->tx_total) - wl->tx_allocated_blocks; /* @@ -1418,6 +1505,7 @@ int wl1271_plt_stop(struct wl1271 *wl) cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->recovery_work); cancel_delayed_work_sync(&wl->elp_work); + cancel_delayed_work_sync(&wl->tx_watchdog_work); mutex_lock(&wl->mutex); wl1271_power_off(wl); @@ -1789,6 +1877,7 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->tx_work); cancel_delayed_work_sync(&wl->elp_work); + cancel_delayed_work_sync(&wl->tx_watchdog_work); /* let's notify MAC80211 about the remaining pending TX frames */ wl12xx_tx_reset(wl, true); @@ -2218,6 +2307,12 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (wl->scan.state != WL1271_SCAN_STATE_IDLE && wl->scan_vif == vif) { + /* + * Rearm the tx watchdog just before idling scan. This + * prevents just-finished scans from triggering the watchdog + */ + wl12xx_rearm_tx_watchdog_locked(wl); + wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan_vif = NULL; @@ -3129,6 +3224,13 @@ static void wl1271_op_cancel_hw_scan(struct ieee80211_hw *hw, if (ret < 0) goto out_sleep; } + + /* + * Rearm the tx watchdog just before idling scan. This + * prevents just-finished scans from triggering the watchdog + */ + wl12xx_rearm_tx_watchdog_locked(wl); + wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan_vif = NULL; @@ -4138,6 +4240,13 @@ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); wl12xx_free_link(wl, wlvif, &hlid); wl->active_sta_count--; + + /* + * rearm the tx watchdog when the last STA is freed - give the FW a + * chance to return STA-buffered packets before complaining. + */ + if (wl->active_sta_count == 0) + wl12xx_rearm_tx_watchdog_locked(wl); } static int wl12xx_sta_add(struct wl1271 *wl, @@ -5212,6 +5321,7 @@ static 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_DELAYED_WORK(&wl->tx_watchdog_work, wl12xx_tx_watchdog_work); wl->freezable_wq = create_freezable_workqueue("wl12xx_wq"); if (!wl->freezable_wq) { diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e43a6b2c1d91..fcba055ef196 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -55,6 +55,12 @@ void wl1271_scan_complete_work(struct work_struct *work) vif = wl->scan_vif; wlvif = wl12xx_vif_to_data(vif); + /* + * Rearm the tx watchdog just before idling scan. This + * prevents just-finished scans from triggering the watchdog + */ + wl12xx_rearm_tx_watchdog_locked(wl); + wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan.req = NULL; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8f78fddcb723..43ae49143d68 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -226,6 +226,10 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl->tx_blocks_available -= total_blocks; wl->tx_allocated_blocks += total_blocks; + /* If the FW was empty before, arm the Tx watchdog */ + if (wl->tx_allocated_blocks == total_blocks) + wl12xx_rearm_tx_watchdog_locked(wl); + ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index e3977b55a710..5cf8c32d40d1 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -227,5 +227,6 @@ 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); +void wl12xx_rearm_tx_watchdog_locked(struct wl1271 *wl); #endif diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 6e13a3073e9f..749a15a75d38 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -495,6 +495,9 @@ struct wl1271 { /* last wlvif we transmitted from */ struct wl12xx_vif *last_wlvif; + + /* work to fire when Tx is stuck */ + struct delayed_work tx_watchdog_work; }; struct wl1271_station { -- GitLab From fdeff46586e01c4b8ceb461a72a46fc6ef00a771 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:10 -0800 Subject: [PATCH 1578/1846] iwlwifi: remove unused arguments from iwlagn_gain_computation The function has two arguments it never uses, remove them. 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 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 579679edd5f1..84cbe7bb504c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -879,10 +879,8 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, } static void iwlagn_gain_computation(struct iwl_priv *priv, - u32 average_noise[NUM_RX_CHAINS], - u16 min_average_noise_antenna_i, - u32 min_average_noise, - u8 default_chain) + u32 average_noise[NUM_RX_CHAINS], + u8 default_chain) { int i; s32 delta_g; @@ -1087,7 +1085,6 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) min_average_noise, min_average_noise_antenna_i); iwlagn_gain_computation(priv, average_noise, - min_average_noise_antenna_i, min_average_noise, find_first_chain(hw_params(priv).valid_rx_ant)); /* Some power changes may have been made during the calibration. -- GitLab From 9b6ca44823a1414a26054fd0b5cd94f31c105ac8 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:11 -0800 Subject: [PATCH 1579/1846] iwlwifi: remove unused argument from rs_initialize_lq The function never uses its conf argument, 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-agn-rs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 9895b807246b..53f8c51cfcdb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -2677,7 +2677,6 @@ static void rs_rate_scale_perform(struct iwl_priv *priv, * which requires station table entry to exist). */ static void rs_initialize_lq(struct iwl_priv *priv, - struct ieee80211_conf *conf, struct ieee80211_sta *sta, struct iwl_lq_sta *lq_sta) { @@ -2912,7 +2911,7 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i lq_sta->dbg_fixed_rate = 0; #endif - rs_initialize_lq(priv, conf, sta, lq_sta); + rs_initialize_lq(priv, sta, lq_sta); } static void rs_fill_link_cmd(struct iwl_priv *priv, -- GitLab From 955570fc662194c6a1128028a579d7e9014c30aa Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:12 -0800 Subject: [PATCH 1580/1846] iwlwifi: move iwl_sta_id_or_broadcast to user There's only one user, so the function can be moved into the correct file. It also loses an argument along the way. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 31 ++++++++++++++++++++++- drivers/net/wireless/iwlwifi/iwl-agn.h | 31 ----------------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 0ef59d9a99ee..c454c6782395 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -248,6 +248,35 @@ static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv, } } +/** + * iwl_sta_id_or_broadcast - return sta_id or broadcast sta + * @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 int iwl_sta_id_or_broadcast(struct iwl_rxon_context *context, + struct ieee80211_sta *sta) +{ + int sta_id; + + if (!sta) + return context->bcast_sta_id; + + sta_id = iwl_sta_id(sta); + + /* + * mac80211 should not be passing a partially + * initialised station! + */ + WARN_ON(sta_id == IWL_INVALID_STATION); + + return sta_id; +} + /* * start REPLY_TX command process */ @@ -304,7 +333,7 @@ int iwlagn_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_sta_id_or_broadcast(priv, ctx, info->control.sta); + sta_id = iwl_sta_id_or_broadcast(ctx, info->control.sta); if (sta_id == IWL_INVALID_STATION) { IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", hdr->addr1); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index ec3a90c42efb..8384c057babb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -258,37 +258,6 @@ static inline int iwl_sta_id(struct ieee80211_sta *sta) return ((struct iwl_station_priv *)sta->drv_priv)->sta_id; } -/** - * iwl_sta_id_or_broadcast - return sta_id or broadcast sta - * @priv: iwl priv - * @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 iwl_sta_id_or_broadcast(struct iwl_priv *priv, - struct iwl_rxon_context *context, - struct ieee80211_sta *sta) -{ - int sta_id; - - if (!sta) - return context->bcast_sta_id; - - sta_id = iwl_sta_id(sta); - - /* - * mac80211 should not be passing a partially - * initialised station! - */ - WARN_ON(sta_id == IWL_INVALID_STATION); - - return sta_id; -} - int iwlagn_alloc_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx); int iwlagn_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, -- GitLab From 03dadf96aa48acbd2501f21d1c1b5740b93b7c72 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:13 -0800 Subject: [PATCH 1581/1846] iwlwifi: remove unused argument from iwl_init_hw_rates The function never uses the priv argument as it only fills in the passed data, so remove the argument. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 4cd375c811e2..397faf9023e4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1010,8 +1010,7 @@ void iwl_cancel_deferred_work(struct iwl_priv *priv) del_timer_sync(&priv->ucode_trace); } -static void iwl_init_hw_rates(struct iwl_priv *priv, - struct ieee80211_rate *rates) +static void iwl_init_hw_rates(struct ieee80211_rate *rates) { int i; @@ -1090,7 +1089,7 @@ static int iwl_init_drv(struct iwl_priv *priv) IWL_ERR(priv, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - iwl_init_hw_rates(priv, priv->ieee_rates); + iwl_init_hw_rates(priv->ieee_rates); return 0; -- GitLab From c1803c9459a9cd751eb46da9e60e49728aae7a5a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:14 -0800 Subject: [PATCH 1582/1846] iwlwifi: remove two unused arguments in testmode The dump functions never access the incoming attributes, so don't pass them. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 5b06916be610..1d732092ebe7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -713,7 +713,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) return -EMSGSIZE; } -static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, +static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct sk_buff *skb, struct netlink_callback *cb) { @@ -905,9 +905,9 @@ static int iwl_testmode_indirect_mem(struct ieee80211_hw *hw, } } -static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, struct nlattr **tb, - struct sk_buff *skb, - struct netlink_callback *cb) +static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, + struct sk_buff *skb, + struct netlink_callback *cb) { struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); int idx, length; @@ -1067,11 +1067,11 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, 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); + result = iwl_testmode_trace_dump(hw, skb, cb); break; case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP: IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); - result = iwl_testmode_buffer_dump(hw, tb, skb, cb); + result = iwl_testmode_buffer_dump(hw, skb, cb); break; default: result = -EINVAL; -- GitLab From ea886a6014024d027fa207b8765e46d746cd2a18 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:15 -0800 Subject: [PATCH 1583/1846] iwlwifi: remove unused argument from iwlagn_suspend There's not much point in passing priv and hw pointers since they can be derived from each other, and the function doesn't use the hw pointer anyway. Remove it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-agn.h | 3 +-- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index b2ee1f9373c0..6d8a8578778c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1120,8 +1120,7 @@ int iwlagn_send_patterns(struct iwl_priv *priv, return err; } -int iwlagn_suspend(struct iwl_priv *priv, - struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) +int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan) { struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; struct iwl_rxon_cmd rxon; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 8384c057babb..82930ef86ad1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -141,8 +141,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv); #ifdef CONFIG_PM_SLEEP int iwlagn_send_patterns(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan); -int iwlagn_suspend(struct iwl_priv *priv, - struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); +int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan); #endif /* rx */ diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index d2c1d714c89c..bdcbbd0d3467 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -405,7 +405,7 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw, goto out; } - ret = iwlagn_suspend(priv, hw, wowlan); + ret = iwlagn_suspend(priv, wowlan); if (ret) goto error; -- GitLab From e755f882b7e72c48da820acc24196532977cfd07 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:16 -0800 Subject: [PATCH 1584/1846] iwlwifi: redesign PASSIVE_NO_RX workaround The PASSIVE_NO_RX workaround currently crosses through the op_mode and transport layers, which is a bit odd. This also isn't necessary, if the transport simply reports when queues are full (or no longer full) the op_mode can keep track of this state, and report to mac80211 only what *it* thinks is appropriate. What is appropriate can then be based on whether queues should be stopped to wait for RX or not. This significantly simplifies the transport API, it no longer needs to expose anything to stop a queue, nor to wake "any" queue, this can all be handled in the upper layer completely. Also simplify the handling to not be dependent on the context, that makes little sense as the queues are shared and both contexts have to be on the same channel anyway. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 8 ++--- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 8 ++--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 12 +++---- drivers/net/wireless/iwlwifi/iwl-agn.c | 33 +++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-agn.h | 5 ++- drivers/net/wireless/iwlwifi/iwl-core.c | 14 -------- drivers/net/wireless/iwlwifi/iwl-dev.h | 5 +-- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 12 ------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 36 ++----------------- drivers/net/wireless/iwlwifi/iwl-trans.h | 36 ++----------------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 6 ++-- 11 files changed, 56 insertions(+), 119 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 521c820ea10a..a9bdbad6663e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -807,16 +807,12 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv, * sometimes even after already having transmitted frames for the * association because the new RXON may reset the information. */ - if (unlikely(ieee80211_is_beacon(fc))) { + if (unlikely(ieee80211_is_beacon(fc) && priv->passive_no_rx)) { for_each_context(priv, ctx) { - if (!ctx->last_tx_rejected) - continue; if (compare_ether_addr(hdr->addr3, ctx->active.bssid_addr)) continue; - ctx->last_tx_rejected = false; - iwl_trans_wake_any_queue(trans(priv), ctx->ctxid, - "channel got active"); + iwlagn_lift_passive_no_rx(priv); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 9d955fa387e5..66e9a71aaac6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -833,12 +833,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, * not get stuck in this case either since it * can happen if userspace gets confused. */ - if (ctx->last_tx_rejected) { - ctx->last_tx_rejected = false; - iwl_trans_wake_any_queue(trans(priv), - ctx->ctxid, - "Disassoc: flush queue"); - } + iwlagn_lift_passive_no_rx(priv); + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; if (ctx->ctxid == IWL_RXON_CTX_BSS) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index c454c6782395..a19db4c0c9fa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -1064,8 +1064,8 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, } /*we can free until ssn % q.n_bd not inclusive */ - WARN_ON(iwl_trans_reclaim(trans(priv), sta_id, tid, txq_id, - ssn, status, &skbs)); + WARN_ON(iwl_trans_reclaim(trans(priv), sta_id, tid, + txq_id, ssn, &skbs)); iwlagn_check_ratid_empty(priv, sta_id, tid); freed = 0; @@ -1086,9 +1086,9 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, if (status == TX_STATUS_FAIL_PASSIVE_NO_RX && iwl_is_associated_ctx(ctx) && ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION) { - ctx->last_tx_rejected = true; - iwl_trans_stop_queue(trans(priv), txq_id, - "Tx on passive channel"); + /* block and stop all queues */ + priv->passive_no_rx = true; + ieee80211_stop_queues(priv->hw); IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " @@ -1182,7 +1182,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, * block-ack window (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (iwl_trans_reclaim(trans(priv), sta_id, tid, scd_flow, - ba_resp_scd_ssn, 0, &reclaimed_skbs)) { + ba_resp_scd_ssn, &reclaimed_skbs)) { spin_unlock(&priv->sta_lock); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 397faf9023e4..29f40eab9715 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1427,6 +1427,39 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode) cfg(priv)->lib->nic_config(priv); } +static void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac) +{ + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + + set_bit(ac, &priv->transport_queue_stop); + ieee80211_stop_queue(priv->hw, ac); +} + +static void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac) +{ + struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + + clear_bit(ac, &priv->transport_queue_stop); + + if (!priv->passive_no_rx) + ieee80211_wake_queue(priv->hw, ac); +} + +void iwlagn_lift_passive_no_rx(struct iwl_priv *priv) +{ + int ac; + + if (!priv->passive_no_rx) + return; + + for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) { + if (!test_bit(ac, &priv->transport_queue_stop)) + ieee80211_wake_queue(priv->hw, ac); + } + + priv->passive_no_rx = false; +} + const struct iwl_op_mode_ops iwl_dvm_ops = { .start = iwl_op_mode_dvm_start, .stop = iwl_op_mode_dvm_stop, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 82930ef86ad1..b56498b796c2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -84,14 +84,13 @@ void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb); int __must_check iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); -void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); -void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state); -void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac); void iwl_nic_error(struct iwl_op_mode *op_mode); bool iwl_check_for_ct_kill(struct iwl_priv *priv); +void iwlagn_lift_passive_no_rx(struct iwl_priv *priv); + /* MAC80211 */ struct ieee80211_hw *iwl_alloc_all(void); int iwlagn_mac_setup_register(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f43f51d1570e..f50bd4263b88 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1477,17 +1477,3 @@ void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) kmem_cache_free(priv->tx_cmd_pool, (info->driver_data[1])); dev_kfree_skb_any(skb); } - -void iwl_stop_sw_queue(struct iwl_op_mode *op_mode, u8 ac) -{ - struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); - - ieee80211_stop_queue(priv->hw, ac); -} - -void iwl_wake_sw_queue(struct iwl_op_mode *op_mode, u8 ac) -{ - struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); - - ieee80211_wake_queue(priv->hw, ac); -} diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index d1e722bd9f5b..74429702b130 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -670,8 +670,6 @@ struct iwl_rxon_context { bool enabled, is_40mhz; u8 extension_chan_offset; } ht; - - bool last_tx_rejected; }; enum iwl_scan_type { @@ -720,6 +718,9 @@ struct iwl_priv { spinlock_t sta_lock; struct mutex mutex; + unsigned long transport_queue_stop; + bool passive_no_rx; + /* ieee device used by generic ieee processing code */ struct ieee80211_hw *hw; struct ieee80211_channel *ieee_channels; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index d13b8d1f08fa..4f73a6d06509 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -451,18 +451,6 @@ static inline void iwl_stop_queue(struct iwl_trans *trans, } } -#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 iwl_txq_ctx_activate(struct iwl_trans_pcie *trans_pcie, int txq_id) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 26bb44242090..1c4fbcd348a8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1559,8 +1559,7 @@ static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans) } static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, - int txq_id, int ssn, u32 status, - struct sk_buff_head *skbs) + int txq_id, int ssn, struct sk_buff_head *skbs) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id]; @@ -1593,9 +1592,7 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, 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 && - (!txq->sched_retry || - status != TX_STATUS_FAIL_PASSIVE_NO_RX)) + if (iwl_queue_space(&txq->q) > txq->q.low_mark) iwl_wake_queue(trans, txq, "Packets reclaimed"); } @@ -1662,32 +1659,6 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans) } #endif /* CONFIG_PM_SLEEP */ -static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, - enum iwl_rxon_context_id ctx, - const char *msg) -{ - u8 ac, txq_id; - struct iwl_trans_pcie *trans_pcie = - IWL_TRANS_GET_PCIE_TRANS(trans); - - for (ac = 0; ac < AC_NUM; ac++) { - txq_id = trans_pcie->ac_to_queue[ctx][ac]; - IWL_DEBUG_TX_QUEUES(trans, "Queue Status: Q[%d] %s\n", - ac, - (atomic_read(&trans_pcie->queue_stop_count[ac]) > 0) - ? "stopped" : "awake"); - iwl_wake_queue(trans, &trans_pcie->txq[txq_id], msg); - } -} - -static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id, - const char *msg) -{ - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - - iwl_stop_queue(trans, &trans_pcie->txq[txq_id], msg); -} - #define IWL_FLUSH_WAIT_MS 2000 static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans) @@ -2207,8 +2178,6 @@ const struct iwl_trans_ops trans_ops_pcie = { .wowlan_suspend = iwl_trans_pcie_wowlan_suspend, - .wake_any_queue = iwl_trans_pcie_wake_any_queue, - .send_cmd = iwl_trans_pcie_send_cmd, .tx = iwl_trans_pcie_tx, @@ -2219,7 +2188,6 @@ const struct iwl_trans_ops trans_ops_pcie = { .tx_agg_setup = iwl_trans_pcie_tx_agg_setup, .free = iwl_trans_pcie_free, - .stop_queue = iwl_trans_pcie_stop_queue, .dbgfs_register = iwl_trans_pcie_dbgfs_register, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 15bb208ab347..609949f0299c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -289,7 +289,6 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) * May sleep * @fw_alive: called when the fw sends alive notification * May sleep - * @wake_any_queue: wake all the queues of a specfic context IWL_RXON_CTX_* * @stop_device:stops the whole device (embedded CPU put to reset) * May sleep * @wowlan_suspend: put the device into the correct mode for WoWLAN during @@ -312,7 +311,6 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) * irq, tasklet etc... From this point on, the device may not issue * any interrupt (incl. RFKILL). * May sleep - * @stop_queue: stop a specific queue * @check_stuck_queue: check if a specific queue is stuck * @wait_tx_queue_empty: wait until all tx queues are empty * May sleep @@ -334,18 +332,13 @@ struct iwl_trans_ops { void (*wowlan_suspend)(struct iwl_trans *trans); - void (*wake_any_queue)(struct iwl_trans *trans, - enum iwl_rxon_context_id ctx, - const char *msg); - int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd); int (*tx)(struct iwl_trans *trans, struct sk_buff *skb, struct iwl_device_cmd *dev_cmd, enum iwl_rxon_context_id ctx, u8 sta_id, u8 tid); int (*reclaim)(struct iwl_trans *trans, int sta_id, int tid, - int txq_id, int ssn, u32 status, - struct sk_buff_head *skbs); + int txq_id, int ssn, struct sk_buff_head *skbs); int (*tx_agg_disable)(struct iwl_trans *trans, int sta_id, int tid); @@ -357,8 +350,6 @@ struct iwl_trans_ops { void (*free)(struct iwl_trans *trans); - void (*stop_queue)(struct iwl_trans *trans, int q, const char *msg); - int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); int (*check_stuck_queue)(struct iwl_trans *trans, int q); int (*wait_tx_queue_empty)(struct iwl_trans *trans); @@ -474,17 +465,6 @@ static inline void iwl_trans_wowlan_suspend(struct iwl_trans *trans) trans->ops->wowlan_suspend(trans); } -static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, - enum iwl_rxon_context_id ctx, - const char *msg) -{ - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); - - trans->ops->wake_any_queue(trans, ctx, msg); -} - - static inline int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) { @@ -505,14 +485,13 @@ static inline int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb, } static inline int iwl_trans_reclaim(struct iwl_trans *trans, int sta_id, - int tid, int txq_id, int ssn, u32 status, + int tid, int txq_id, int ssn, struct sk_buff_head *skbs) { if (trans->state != IWL_TRANS_FW_ALIVE) IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); - return trans->ops->reclaim(trans, sta_id, tid, txq_id, ssn, - status, skbs); + return trans->ops->reclaim(trans, sta_id, tid, txq_id, ssn, skbs); } static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, @@ -554,15 +533,6 @@ static inline void iwl_trans_free(struct iwl_trans *trans) trans->ops->free(trans); } -static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q, - const char *msg) -{ - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); - - trans->ops->stop_queue(trans, q, msg); -} - static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) { if (trans->state != IWL_TRANS_FW_ALIVE) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 8267dbe869d5..404fd8e7958b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -316,7 +316,6 @@ int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) static int iwl_alive_notify(struct iwl_priv *priv) { - struct iwl_rxon_context *ctx; int ret; if (!priv->tx_cmd_pool) @@ -329,8 +328,9 @@ static int iwl_alive_notify(struct iwl_priv *priv) return -ENOMEM; iwl_trans_fw_alive(trans(priv)); - for_each_context(priv, ctx) - ctx->last_tx_rejected = false; + + priv->passive_no_rx = false; + priv->transport_queue_stop = 0; ret = iwl_send_wimax_coex(priv); if (ret) -- GitLab From b0b4619273dd8b9414a4632f8f229e4f2897ff45 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:17 -0800 Subject: [PATCH 1585/1846] iwlwifi: transport's tx_agg_disable must be atomic At least as long as it is called from the reclaim flow (iwlagn_check_ratid_empty) it must be atomic. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 609949f0299c..ed6ab449e439 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -306,7 +306,7 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) * ready and a successful ADDBA response has been received. * May sleep * @tx_agg_disable: de-configure a Tx queue to send AMPDUs - * May sleep + * Must be atomic * @free: release all the ressource for the transport layer itself such as * irq, tasklet etc... From this point on, the device may not issue * any interrupt (incl. RFKILL). @@ -497,8 +497,6 @@ static inline int iwl_trans_reclaim(struct iwl_trans *trans, int sta_id, static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) { - might_sleep(); - if (trans->state != IWL_TRANS_FW_ALIVE) IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); -- GitLab From 562f08eb8020cf3672c3743752f82d962ecb7788 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:18 -0800 Subject: [PATCH 1586/1846] iwlwifi: remove BT handlers from lib_ops There's no need to have operations for these as they simply depend on whether the device has built-in bluetooth, so just duplicate the information already there (whether bt_params is present or not). Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-2000.c | 3 --- drivers/net/wireless/iwlwifi/iwl-6000.c | 3 --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 5 ++--- drivers/net/wireless/iwlwifi/iwl-agn.c | 8 ++++---- drivers/net/wireless/iwlwifi/iwl-core.h | 6 ------ 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 446d010dfe84..d6ba8419c940 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -156,9 +156,6 @@ static struct iwl_lib_ops iwl2000_lib = { static struct iwl_lib_ops iwl2030_lib = { .set_hw_params = iwl2000_hw_set_hw_params, - .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup, - .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work, - .cancel_deferred_work = iwlagn_bt_cancel_deferred_work, .nic_config = iwl2000_nic_config, .eeprom_ops = { .regulatory_bands = { diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index d299f05dfc9b..904c50af92fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -252,9 +252,6 @@ static struct iwl_lib_ops iwl6000_lib = { static struct iwl_lib_ops iwl6030_lib = { .set_hw_params = iwl6000_hw_set_hw_params, - .bt_rx_handler_setup = iwlagn_bt_rx_handler_setup, - .bt_setup_deferred_work = iwlagn_bt_setup_deferred_work, - .cancel_deferred_work = iwlagn_bt_cancel_deferred_work, .set_channel_switch = iwl6000_hw_channel_switch, .nic_config = iwl6000_nic_config, .eeprom_ops = { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index a9bdbad6663e..e504675f2637 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1143,9 +1143,8 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) iwl_notification_wait_init(&priv->notif_wait); /* Set up BT Rx handlers */ - if (cfg(priv)->lib->bt_rx_handler_setup) - cfg(priv)->lib->bt_rx_handler_setup(priv); - + if (cfg(priv)->bt_params) + iwlagn_bt_rx_handler_setup(priv); } int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 29f40eab9715..5f390f8d3b8b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -976,8 +976,8 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) iwl_setup_scan_deferred_work(priv); - if (cfg(priv)->lib->bt_setup_deferred_work) - cfg(priv)->lib->bt_setup_deferred_work(priv); + if (cfg(priv)->bt_params) + iwlagn_bt_setup_deferred_work(priv); init_timer(&priv->statistics_periodic); priv->statistics_periodic.data = (unsigned long)priv; @@ -994,8 +994,8 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) void iwl_cancel_deferred_work(struct iwl_priv *priv) { - if (cfg(priv)->lib->cancel_deferred_work) - cfg(priv)->lib->cancel_deferred_work(priv); + if (cfg(priv)->bt_params) + iwlagn_bt_cancel_deferred_work(priv); cancel_work_sync(&priv->run_time_calib_work); cancel_work_sync(&priv->beacon_update); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index e0423c4c01c7..95f6b7b0abf7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -77,12 +77,6 @@ struct iwl_cmd; struct iwl_lib_ops { /* set hw dependent parameters */ void (*set_hw_params)(struct iwl_priv *priv); - /* setup BT Rx handler */ - void (*bt_rx_handler_setup)(struct iwl_priv *priv); - /* setup BT related deferred work */ - void (*bt_setup_deferred_work)(struct iwl_priv *priv); - /* cancel deferred work */ - void (*cancel_deferred_work)(struct iwl_priv *priv); int (*set_channel_switch)(struct iwl_priv *priv, struct ieee80211_channel_switch *ch_switch); /* device specific configuration */ -- GitLab From a75a79a84ffd7fea9e10f327d1e2f2fa25770375 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:19 -0800 Subject: [PATCH 1587/1846] iwlwifi: move BT/HT params to shared Hardware parameters will be shared, so move the definitions into the shared header file. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-core.h | 24 ----------------------- drivers/net/wireless/iwlwifi/iwl-shared.h | 24 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 95f6b7b0abf7..635eb685edeb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -89,30 +89,6 @@ struct iwl_lib_ops { void (*temperature)(struct iwl_priv *priv); }; -/* - * @advanced_bt_coexist: support advanced bt coexist - * @bt_init_traffic_load: specify initial bt traffic load - * @bt_prio_boost: default bt priority boost value - * @agg_time_limit: maximum number of uSec in aggregation - * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode - */ -struct iwl_bt_params { - bool advanced_bt_coexist; - u8 bt_init_traffic_load; - u8 bt_prio_boost; - u16 agg_time_limit; - bool bt_sco_disable; - bool bt_session_2; -}; -/* - * @use_rts_for_aggregation: use rts/cts protection for HT traffic - */ -struct iwl_ht_params { - const bool ht_greenfield_support; /* if used set to true */ - bool use_rts_for_aggregation; - enum ieee80211_smps_mode smps_mode; -}; - /*************************** * L i b * ***************************/ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index ff3394c47635..45409fcfbbd7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -270,6 +270,30 @@ struct iwl_base_params { const bool wd_disable; }; +/* + * @advanced_bt_coexist: support advanced bt coexist + * @bt_init_traffic_load: specify initial bt traffic load + * @bt_prio_boost: default bt priority boost value + * @agg_time_limit: maximum number of uSec in aggregation + * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode + */ +struct iwl_bt_params { + bool advanced_bt_coexist; + u8 bt_init_traffic_load; + u8 bt_prio_boost; + u16 agg_time_limit; + bool bt_sco_disable; + bool bt_session_2; +}; +/* + * @use_rts_for_aggregation: use rts/cts protection for HT traffic + */ +struct iwl_ht_params { + const bool ht_greenfield_support; /* if used set to true */ + bool use_rts_for_aggregation; + enum ieee80211_smps_mode smps_mode; +}; + /** * struct iwl_cfg * @name: Offical name of the device -- GitLab From 51dc51d12bd609644bbe9877825a1a25a6016639 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:20 -0800 Subject: [PATCH 1588/1846] iwlwifi: make EEPROM enhanced TX power a bool There's no need to carry around the function pointer when a boolean indicating that the EEPROM stores enhanced TX power information is sufficient. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-2000.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-6000.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn.h | 1 - drivers/net/wireless/iwlwifi/iwl-eeprom.c | 6 +++--- drivers/net/wireless/iwlwifi/iwl-eeprom.h | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index d6ba8419c940..14ce83bc71a5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -149,7 +149,7 @@ static struct iwl_lib_ops iwl2000_lib = { EEPROM_6000_REG_BAND_24_HT40_CHANNELS, EEPROM_REGULATORY_BAND_NO_HT40, }, - .update_enhanced_txpower = iwl_eeprom_enhanced_txpower, + .enhanced_txpower = true, }, .temperature = iwlagn_temperature, }; @@ -167,7 +167,7 @@ static struct iwl_lib_ops iwl2030_lib = { EEPROM_6000_REG_BAND_24_HT40_CHANNELS, EEPROM_REGULATORY_BAND_NO_HT40, }, - .update_enhanced_txpower = iwl_eeprom_enhanced_txpower, + .enhanced_txpower = true, }, .temperature = iwlagn_temperature, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 904c50af92fd..0f89e45da1a2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -245,7 +245,7 @@ static struct iwl_lib_ops iwl6000_lib = { EEPROM_6000_REG_BAND_24_HT40_CHANNELS, EEPROM_REG_BAND_52_HT40_CHANNELS }, - .update_enhanced_txpower = iwl_eeprom_enhanced_txpower, + .enhanced_txpower = true, }, .temperature = iwlagn_temperature, }; @@ -264,7 +264,7 @@ static struct iwl_lib_ops iwl6030_lib = { EEPROM_6000_REG_BAND_24_HT40_CHANNELS, EEPROM_REG_BAND_52_HT40_CHANNELS }, - .update_enhanced_txpower = iwl_eeprom_enhanced_txpower, + .enhanced_txpower = true, }, .temperature = iwlagn_temperature, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index b56498b796c2..6345ab0f2a96 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -305,7 +305,6 @@ 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_shared *shrd, u8 *mac); extern int iwl_alive_start(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index e2d80849001f..23cea42b9495 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -589,7 +589,7 @@ iwl_eeprom_enh_txp_read_element(struct iwl_priv *priv, #define TXP_CHECK_AND_PRINT(x) ((txp->flags & IWL_EEPROM_ENH_TXP_FL_##x) \ ? # x " " : "") -void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) +static void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) { struct iwl_shared *shrd = priv->shrd; struct iwl_eeprom_enhanced_txpwr *txp_array, *txp; @@ -1025,8 +1025,8 @@ int iwl_init_channel_map(struct iwl_priv *priv) * driver need to process addition information * to determine the max channel tx power limits */ - if (cfg(priv)->lib->eeprom_ops.update_enhanced_txpower) - cfg(priv)->lib->eeprom_ops.update_enhanced_txpower(priv); + if (cfg(priv)->lib->eeprom_ops.enhanced_txpower) + iwl_eeprom_enhanced_txpower(priv); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 3b17056d5675..e4a758340996 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -302,7 +302,7 @@ extern const u8 iwl_eeprom_band_1[14]; struct iwl_eeprom_ops { const u32 regulatory_bands[7]; - void (*update_enhanced_txpower) (struct iwl_priv *priv); + bool enhanced_txpower; }; -- GitLab From 9563fe1696fa0ced8cfa3f935736d4662a81c1c3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:21 -0800 Subject: [PATCH 1589/1846] iwlwifi: remove unused max_nrg_cck from sensitivity and constify The sensitivity parameters are never modified, so they should be const. Also remove the unused max_nrg_cck value to save some space. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-2000.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-5000.c | 4 +--- drivers/net/wireless/iwlwifi/iwl-6000.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index f6e6f57aade5..450250332e4b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -96,9 +96,8 @@ static void iwl1000_nic_config(struct iwl_priv *priv) ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK); } -static struct iwl_sensitivity_ranges iwl1000_sensitivity = { +static const struct iwl_sensitivity_ranges iwl1000_sensitivity = { .min_nrg_cck = 95, - .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 90, .auto_corr_min_ofdm_mrc = 170, .auto_corr_min_ofdm_x1 = 120, diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index 14ce83bc71a5..abfd901e81a2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -91,9 +91,8 @@ static void iwl2000_nic_config(struct iwl_priv *priv) CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER); } -static struct iwl_sensitivity_ranges iwl2000_sensitivity = { +static const struct iwl_sensitivity_ranges iwl2000_sensitivity = { .min_nrg_cck = 97, - .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 80, .auto_corr_min_ofdm_mrc = 128, .auto_corr_min_ofdm_x1 = 105, diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 907a0b22f7b2..9e187f8f5ae4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -75,9 +75,8 @@ static void iwl5000_nic_config(struct iwl_priv *priv) ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); } -static struct iwl_sensitivity_ranges iwl5000_sensitivity = { +static const struct iwl_sensitivity_ranges iwl5000_sensitivity = { .min_nrg_cck = 100, - .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 90, .auto_corr_min_ofdm_mrc = 170, .auto_corr_min_ofdm_x1 = 105, @@ -102,7 +101,6 @@ static struct iwl_sensitivity_ranges iwl5000_sensitivity = { static struct iwl_sensitivity_ranges iwl5150_sensitivity = { .min_nrg_cck = 95, - .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 90, .auto_corr_min_ofdm_mrc = 170, .auto_corr_min_ofdm_x1 = 105, diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 0f89e45da1a2..e64bc6b7bcbf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -113,9 +113,8 @@ static void iwl6000_nic_config(struct iwl_priv *priv) cfg(priv)->additional_nic_config(priv); } -static struct iwl_sensitivity_ranges iwl6000_sensitivity = { +static const struct iwl_sensitivity_ranges iwl6000_sensitivity = { .min_nrg_cck = 110, - .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 80, .auto_corr_min_ofdm_mrc = 128, .auto_corr_min_ofdm_x1 = 105, diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 74429702b130..c3f372e2c142 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -294,7 +294,6 @@ struct iwl_vif_priv { struct iwl_sensitivity_ranges { u16 min_nrg_cck; - u16 max_nrg_cck; u16 nrg_th_cck; u16 nrg_th_ofdm; -- GitLab From 9441b85d59ec9d06cbe749e12a59a06c09e601fa Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:22 -0800 Subject: [PATCH 1590/1846] iwlwifi: return error if loading uCode failed In "iwlwifi: consolidate the start_device flow" the code flow changed and the firmware is now loaded by the transport layer, but the change unfortunately lost error checking -- restore. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 1c4fbcd348a8..ef76a3916189 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1070,9 +1070,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Load the given image to the HW */ - iwl_load_given_ucode(trans, fw); - - return 0; + return iwl_load_given_ucode(trans, fw); } /* -- GitLab From aa5affbacb24cb5d8fd6f7c66e57d62164ed6d34 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:23 -0800 Subject: [PATCH 1591/1846] iwlwifi: dump stack when fail to gain access to the device Print dump stack when the device is not responding. This should give some more clue about the reason of failure. Also change the message we print, since "MAC in deep sleep" is kinda confusing. On the way add unlikely(), as fail to gain NIC access is hmm ... unlikely. Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index e2e3b5c9cf7f..fc365350a3e7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -121,10 +121,10 @@ int iwl_grab_nic_access_silent(struct iwl_trans *trans) int iwl_grab_nic_access(struct iwl_trans *trans) { int ret = iwl_grab_nic_access_silent(trans); - if (ret) { + if (unlikely(ret)) { u32 val = iwl_read32(trans, CSR_GP_CNTRL); - IWL_ERR(trans, - "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); + WARN_ONCE(1, "Timeout waiting for hardware access " + "(CSR_GP_CNTRL 0x%08x)\n", val); } return ret; -- GitLab From bfe4b80e9f7385f34986736cdc094be56782109a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:24 -0800 Subject: [PATCH 1592/1846] iwlwifi: always check if got h/w access before write Before we write to the device registers always check if iwl_grap_nic_access() was successful. On the way change return type of grab_nic_access() to bool, and add likely()/unlikely() statement. Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-io.c | 53 ++++++++++--------- drivers/net/wireless/iwlwifi/iwl-io.h | 2 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 4 +- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index 7712c5537370..9a12b70c7d4f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -189,7 +189,7 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data) } iwl_read32(trans(priv), CSR_UCODE_DRV_GP1); spin_lock_irqsave(&trans(priv)->reg_lock, flags); - if (!iwl_grab_nic_access(trans(priv))) + if (likely(iwl_grab_nic_access(trans(priv)))) iwl_release_nic_access(trans(priv)); spin_unlock_irqrestore(&trans(priv)->reg_lock, flags); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 5f390f8d3b8b..ce9ebeb89e4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -327,7 +327,7 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, /* Make sure device is powered up for SRAM reads */ spin_lock_irqsave(&trans(priv)->reg_lock, reg_flags); - if (iwl_grab_nic_access(trans(priv))) { + if (unlikely(!iwl_grab_nic_access(trans(priv)))) { spin_unlock_irqrestore(&trans(priv)->reg_lock, reg_flags); return; } diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index fc365350a3e7..fa69845954cf 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -118,16 +118,17 @@ int iwl_grab_nic_access_silent(struct iwl_trans *trans) return 0; } -int iwl_grab_nic_access(struct iwl_trans *trans) +bool iwl_grab_nic_access(struct iwl_trans *trans) { int ret = iwl_grab_nic_access_silent(trans); if (unlikely(ret)) { u32 val = iwl_read32(trans, CSR_GP_CNTRL); WARN_ONCE(1, "Timeout waiting for hardware access " "(CSR_GP_CNTRL 0x%08x)\n", val); + return false; } - return ret; + return true; } void iwl_release_nic_access(struct iwl_trans *trans) @@ -156,7 +157,7 @@ void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value) unsigned long flags; spin_lock_irqsave(&trans->reg_lock, flags); - if (!iwl_grab_nic_access(trans)) { + if (likely(iwl_grab_nic_access(trans))) { iwl_write32(trans, reg, value); iwl_release_nic_access(trans); } @@ -211,7 +212,7 @@ void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) unsigned long flags; spin_lock_irqsave(&trans->reg_lock, flags); - if (!iwl_grab_nic_access(trans)) { + if (likely(iwl_grab_nic_access(trans))) { __iwl_write_prph(trans, addr, val); iwl_release_nic_access(trans); } @@ -223,9 +224,11 @@ void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) unsigned long flags; spin_lock_irqsave(&trans->reg_lock, flags); - iwl_grab_nic_access(trans); - __iwl_write_prph(trans, reg, __iwl_read_prph(trans, reg) | mask); - iwl_release_nic_access(trans); + if (likely(iwl_grab_nic_access(trans))) { + __iwl_write_prph(trans, reg, + __iwl_read_prph(trans, reg) | mask); + iwl_release_nic_access(trans); + } spin_unlock_irqrestore(&trans->reg_lock, flags); } @@ -235,10 +238,11 @@ void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg, unsigned long flags; spin_lock_irqsave(&trans->reg_lock, flags); - iwl_grab_nic_access(trans); - __iwl_write_prph(trans, reg, - (__iwl_read_prph(trans, reg) & mask) | bits); - iwl_release_nic_access(trans); + if (likely(iwl_grab_nic_access(trans))) { + __iwl_write_prph(trans, reg, + (__iwl_read_prph(trans, reg) & mask) | bits); + iwl_release_nic_access(trans); + } spin_unlock_irqrestore(&trans->reg_lock, flags); } @@ -248,10 +252,11 @@ void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask) u32 val; spin_lock_irqsave(&trans->reg_lock, flags); - iwl_grab_nic_access(trans); - val = __iwl_read_prph(trans, reg); - __iwl_write_prph(trans, reg, (val & ~mask)); - iwl_release_nic_access(trans); + if (likely(iwl_grab_nic_access(trans))) { + val = __iwl_read_prph(trans, reg); + __iwl_write_prph(trans, reg, (val & ~mask)); + iwl_release_nic_access(trans); + } spin_unlock_irqrestore(&trans->reg_lock, flags); } @@ -263,15 +268,13 @@ void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr, u32 *vals = buf; spin_lock_irqsave(&trans->reg_lock, flags); - iwl_grab_nic_access(trans); - - iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr); - rmb(); - - for (offs = 0; offs < words; offs++) - vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT); - - iwl_release_nic_access(trans); + if (likely(iwl_grab_nic_access(trans))) { + iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr); + rmb(); + for (offs = 0; offs < words; offs++) + vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT); + iwl_release_nic_access(trans); + } spin_unlock_irqrestore(&trans->reg_lock, flags); } @@ -292,7 +295,7 @@ int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr, u32 *vals = buf; spin_lock_irqsave(&trans->reg_lock, flags); - if (!iwl_grab_nic_access(trans)) { + if (likely(iwl_grab_nic_access(trans))) { iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr); wmb(); diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index 1136dc19936a..09b856768f62 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h @@ -61,7 +61,7 @@ int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, int timeout); int iwl_grab_nic_access_silent(struct iwl_trans *trans); -int iwl_grab_nic_access(struct iwl_trans *trans); +bool iwl_grab_nic_access(struct iwl_trans *trans); void iwl_release_nic_access(struct iwl_trans *trans); u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index bdcbbd0d3467..91a42c3261aa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -445,7 +445,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) if (iwlagn_hw_valid_rtc_data_addr(base)) { spin_lock_irqsave(&trans(priv)->reg_lock, flags); ret = iwl_grab_nic_access_silent(trans(priv)); - if (ret == 0) { + if (likely(ret == 0)) { iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, base); status = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); iwl_release_nic_access(trans(priv)); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 83cc60e8f607..5d1fc7b1b0a3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -745,7 +745,8 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, /* Make sure device is powered up for SRAM reads */ spin_lock_irqsave(&trans->reg_lock, reg_flags); - iwl_grab_nic_access(trans); + if (unlikely(!iwl_grab_nic_access(trans))) + goto out_unlock; /* Set starting address; reads will auto-increment */ iwl_write32(trans, HBUS_TARG_MEM_RADDR, ptr); @@ -785,6 +786,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, /* Allow device to power down */ iwl_release_nic_access(trans); +out_unlock: spin_unlock_irqrestore(&trans->reg_lock, reg_flags); return pos; } -- GitLab From 3a73a30049f20a0ff3ef1c5c10170a9c5539e042 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:25 -0800 Subject: [PATCH 1593/1846] iwlwifi: cleanup/fix memory barriers wmb(), rmb() are not needed when writel(), readl() are used as accessors for MMIO. We use them indirectly via iowrite32(), ioread32(). What is needed mmiowb(), for synchronizing writes coming from different CPUs on PCIe bridge (see in patch comments). This fortunately is not needed on x86, where mmiowb() is just defined as compiler barrier. As iwlwifi devices are most likely not used on anything other than x86, this is not so important fix. Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 1 - drivers/net/wireless/iwlwifi/iwl-io.c | 12 +++++++----- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ce9ebeb89e4c..64bc2859dd1b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -334,7 +334,6 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, /* Set starting address; reads will auto-increment */ iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, ptr); - rmb(); /* * Refuse to read more than would have fit into the log from diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index fa69845954cf..081dd34d2387 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -136,6 +136,13 @@ void iwl_release_nic_access(struct iwl_trans *trans) lockdep_assert_held(&trans->reg_lock); __iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + /* + * Above we read the CSR_GP_CNTRL register, which will flush + * any previous writes, but we need the write that clears the + * MAC_ACCESS_REQ bit to be performed before any other writes + * scheduled on different CPUs (after we drop reg_lock). + */ + mmiowb(); } u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg) @@ -182,7 +189,6 @@ int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask, static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 reg) { iwl_write32(trans, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); - rmb(); return iwl_read32(trans, HBUS_TARG_PRPH_RDAT); } @@ -190,7 +196,6 @@ static inline void __iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val) { iwl_write32(trans, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); - wmb(); iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val); } @@ -270,7 +275,6 @@ void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr, spin_lock_irqsave(&trans->reg_lock, flags); if (likely(iwl_grab_nic_access(trans))) { iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr); - rmb(); for (offs = 0; offs < words; offs++) vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT); iwl_release_nic_access(trans); @@ -297,8 +301,6 @@ int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr, spin_lock_irqsave(&trans->reg_lock, flags); if (likely(iwl_grab_nic_access(trans))) { iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr); - wmb(); - for (offs = 0; offs < words; offs++) iwl_write32(trans, HBUS_TARG_MEM_WDAT, vals[offs]); iwl_release_nic_access(trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 5d1fc7b1b0a3..787229b352f6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -750,7 +750,6 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, /* Set starting address; reads will auto-increment */ iwl_write32(trans, HBUS_TARG_MEM_RADDR, ptr); - rmb(); /* "time" is actually "data" for mode 0 (no timestamp). * place event id # at far right for easier visual parsing. */ -- GitLab From 05f5b97ee0013fefbd9139cf8c3eda5f2a88c04a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:26 -0800 Subject: [PATCH 1594/1846] iwlwifi: use writeb,writel,readl directly That change will save us some CPU cycles at run time. Having port-based I/O seems to be not possible for PCIe devices. Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/Kconfig | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index ae08498dfcad..5afd06ef0d8b 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig @@ -1,6 +1,6 @@ config IWLWIFI tristate "Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlwifi) " - depends on PCI && MAC80211 + depends on PCI && MAC80211 && HAS_IOMEM select FW_LOADER select NEW_LEDS select LEDS_CLASS diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index ef76a3916189..389f99e6a8eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1600,18 +1600,17 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val) { - iowrite8(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); + writeb(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); } static void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val) { - iowrite32(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); + writel(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); } static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) { - u32 val = ioread32(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); - return val; + return readl(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); } static void iwl_trans_pcie_free(struct iwl_trans *trans) @@ -1629,7 +1628,7 @@ static void iwl_trans_pcie_free(struct iwl_trans *trans) } pci_disable_msi(trans_pcie->pci_dev); - pci_iounmap(trans_pcie->pci_dev, trans_pcie->hw_base); + iounmap(trans_pcie->hw_base); pci_release_regions(trans_pcie->pci_dev); pci_disable_device(trans_pcie->pci_dev); @@ -2258,9 +2257,9 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, goto out_pci_disable_device; } - trans_pcie->hw_base = pci_iomap(pdev, 0, 0); + trans_pcie->hw_base = pci_ioremap_bar(pdev, 0); if (!trans_pcie->hw_base) { - dev_printk(KERN_ERR, &pdev->dev, "pci_iomap failed"); + dev_printk(KERN_ERR, &pdev->dev, "pci_ioremap_bar failed"); err = -ENODEV; goto out_pci_release_regions; } -- GitLab From c2945f390dbc725f3c3ef044a6a3f4e3909a7758 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:27 -0800 Subject: [PATCH 1595/1846] iwlwifi: print DMA stop timeout error only if it happened iwl_poll_direct_bit() return negative error value on timeout, positive values do not indicate an error. Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 389f99e6a8eb..aced6f8ae1e9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1211,7 +1211,7 @@ static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans) */ static int iwl_trans_tx_stop(struct iwl_trans *trans) { - int ch, txq_id; + int ch, txq_id, ret; unsigned long flags; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); @@ -1224,9 +1224,10 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans) for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) { iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (iwl_poll_direct_bit(trans, FH_TSSR_TX_STATUS_REG, + ret = iwl_poll_direct_bit(trans, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), - 1000)) + 1000); + if (ret < 0) IWL_ERR(trans, "Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, iwl_read_direct32(trans, -- GitLab From 8722c899a07f45457464803142bd1c2d2a2c3bd8 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:28 -0800 Subject: [PATCH 1596/1846] iwlwifi: reintroduce iwl_enable_rfkill_int If device is disabled by rfkill switch, do not enable all interrupts, but only CSR_INT_BIT_RF_KILL to receive rfkill state change. Unblocking other interrupts might cause problems, since driver can not be prepared for receive them. Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 6 ++++++ drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 6 ++---- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 13 ++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 4f73a6d06509..93d89a375a1c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -376,6 +376,12 @@ static inline void iwl_enable_interrupts(struct iwl_trans *trans) iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask); } +static inline void iwl_enable_rfkill_int(struct iwl_trans *trans) +{ + IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n"); + iwl_write32(trans, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); +} + /* * we have 8 bits used like this: * diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 787229b352f6..2d6ea42b0d8e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1134,10 +1134,8 @@ void iwl_irq_tasklet(struct iwl_trans *trans) if (test_bit(STATUS_INT_ENABLED, &trans->shrd->status)) iwl_enable_interrupts(trans); /* Re-enable RF_KILL if it occurred */ - else if (handled & CSR_INT_BIT_RF_KILL) { - IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n"); - iwl_write32(trans, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); - } + else if (handled & CSR_INT_BIT_RF_KILL) + iwl_enable_rfkill_int(trans); } /****************************************************************************** diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index aced6f8ae1e9..88e1c427f8f5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1044,7 +1044,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); if (hw_rfkill) { - iwl_enable_interrupts(trans); + iwl_enable_rfkill_int(trans); return -ERFKILL; } @@ -1553,8 +1553,7 @@ static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans) iwl_write32(trans, CSR_INT, 0xFFFFFFFF); /* Even if we stop the HW, we still want the RF kill interrupt */ - IWL_DEBUG_ISR(trans, "Enabling rfkill interrupt\n"); - iwl_write32(trans, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + iwl_enable_rfkill_int(trans); } static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, @@ -1647,10 +1646,14 @@ static int iwl_trans_pcie_resume(struct iwl_trans *trans) { bool hw_rfkill; - iwl_enable_interrupts(trans); - hw_rfkill = !(iwl_read32(trans, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + + if (hw_rfkill) + iwl_enable_rfkill_int(trans); + else + iwl_enable_interrupts(trans); + iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); return 0; -- GitLab From 0aef8ddc8bedac1db4c96fddc9fb1b44b730cf4f Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Wed, 7 Mar 2012 09:52:29 -0800 Subject: [PATCH 1597/1846] iwlwifi: add testmode command for rx forwarding Added a testmode command which tells iwl_rx_dispatch to send the RX both as a notification to nl80211 and with the registered RX handlers. This is used for monitoring RX from userspace while preserving the regular flows in the driver. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 20 ++++++++++--- drivers/net/wireless/iwlwifi/iwl-testmode.c | 32 +++++++++++++++++++-- drivers/net/wireless/iwlwifi/iwl-testmode.h | 13 +++++++-- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index e504675f2637..8e7cdfaf10cc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1152,6 +1152,8 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, { struct iwl_rx_packet *pkt = rxb_addr(rxb); struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + void (*pre_rx_handler)(struct iwl_priv *, + struct iwl_rx_cmd_buffer *); int err = 0; /* @@ -1161,10 +1163,20 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb, */ iwl_notification_wait_notify(&priv->notif_wait, pkt); - if (priv->pre_rx_handler && - priv->ucode_owner == IWL_OWNERSHIP_TM) - priv->pre_rx_handler(priv, rxb); - else { + /* RX data may be forwarded to userspace (using pre_rx_handler) in one + * of two cases: the first, that the user owns the uCode through + * testmode - in such case the pre_rx_handler is set and no further + * processing takes place. The other case is when the user want to + * monitor the rx w/o affecting the regular flow - the pre_rx_handler + * will be set but the ownership flag != IWL_OWNERSHIP_TM and the flow + * continues. + * We need to use ACCESS_ONCE to prevent a case where the handler + * changes between the check and the call. + */ + pre_rx_handler = ACCESS_ONCE(priv->pre_rx_handler); + if (pre_rx_handler) + pre_rx_handler(priv, rxb); + if (priv->ucode_owner != IWL_OWNERSHIP_TM) { /* Based on type of command response or notification, * handle those that need handling via function in * rx_handlers table. See iwl_setup_rx_handlers() */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 1d732092ebe7..b8044bcd5044 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -125,6 +125,8 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, }, [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, }, [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_ENABLE_NOTIFICATION] = {.type = NLA_FLAG, }, }; /* @@ -194,7 +196,7 @@ static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, void iwl_testmode_init(struct iwl_priv *priv) { - priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; + priv->pre_rx_handler = NULL; priv->testmode_trace.trace_enabled = false; priv->testmode_mem.read_in_progress = false; } @@ -770,9 +772,13 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) } owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); - if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) + if (owner == IWL_OWNERSHIP_DRIVER) { priv->ucode_owner = owner; - else { + priv->pre_rx_handler = NULL; + } else if (owner == IWL_OWNERSHIP_TM) { + priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; + priv->ucode_owner = owner; + } else { IWL_ERR(priv, "Invalid owner\n"); return -EINVAL; } @@ -937,6 +943,20 @@ static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, return -ENOBUFS; } +static int iwl_testmode_notifications(struct ieee80211_hw *hw, + struct nlattr **tb) +{ + struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); + bool enable; + + enable = nla_get_flag(tb[IWL_TM_ATTR_ENABLE_NOTIFICATION]); + if (enable) + priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; + else + priv->pre_rx_handler = NULL; + return 0; +} + /* 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 @@ -1022,6 +1042,12 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) result = iwl_testmode_indirect_mem(hw, tb); break; + case IWL_TM_CMD_APP2DEV_NOTIFICATIONS: + IWL_DEBUG_INFO(priv, "testmode notifications cmd " + "to driver\n"); + result = iwl_testmode_notifications(hw, tb); + break; + default: IWL_ERR(priv, "Unknown testmode command\n"); result = -ENOSYS; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 69b2e80f4071..6ba211b09426 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -122,6 +122,9 @@ * Fore reading, a READ command is sent from the userspace and the data * is returned when the user calls a DUMP command. * For writing, only a WRITE command is used. + * @IWL_TM_CMD_APP2DEV_NOTIFICATIONS: + * Command to enable/disable notifications (currently RX packets) from the + * driver to userspace. */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, @@ -152,7 +155,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ = 26, IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP = 27, IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE = 28, - IWL_TM_CMD_MAX = 29, + IWL_TM_CMD_APP2DEV_NOTIFICATIONS = 29, + IWL_TM_CMD_MAX = 30, }; /* @@ -256,6 +260,10 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE this flag * indicates that the user wants to receive the response of the command * in a reply SKB. If it's not present, the response is not returned. + * @IWL_TM_ATTR_ENABLE_NOTIFICATIONS: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_NOTIFICATIONS, this + * flag enables (if present) or disables (if not) the forwarding + * to userspace. */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -282,7 +290,8 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_FW_INST_SIZE = 21, IWL_TM_ATTR_FW_DATA_SIZE = 22, IWL_TM_ATTR_UCODE_CMD_SKB = 23, - IWL_TM_ATTR_MAX = 24, + IWL_TM_ATTR_ENABLE_NOTIFICATION = 24, + IWL_TM_ATTR_MAX = 25, }; /* uCode trace buffer */ -- GitLab From 8e81f65fdc7f5d292bb3c115b748767d921823c1 Mon Sep 17 00:00:00 2001 From: Amit Beka Date: Wed, 7 Mar 2012 09:52:30 -0800 Subject: [PATCH 1598/1846] iwlwifi: fixed testmode notifications length The length of iwl_rx_packet doesn't include the dword for the length itself, so add it manually. Signed-off-by: Amit Beka Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index b8044bcd5044..b06c6763cb7a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -185,7 +185,8 @@ static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, 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); + /* the length doesn't include len_n_flags field, so add it manually */ + NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, length + sizeof(__le32), data); cfg80211_testmode_event(skb, GFP_ATOMIC); return; -- GitLab From 18c57d3c1e31a91a5925da001c19d521178d00bd Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Wed, 7 Mar 2012 09:52:31 -0800 Subject: [PATCH 1599/1846] iwlwifi: add option to test MFP Add a Kconfig symbol to enable MFP for testing even if the firmware file doesn't advertise it. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/Kconfig | 9 +++++++++ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index 5afd06ef0d8b..2fe62730dddd 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig @@ -127,3 +127,12 @@ config IWLWIFI_P2P support when it is loaded. Say Y only if you want to experiment with P2P. + +config IWLWIFI_EXPERIMENTAL_MFP + bool "support MFP (802.11w) even if uCode doesn't advertise" + depends on IWLWIFI + help + This option enables experimental MFP (802.11W) support + even if the microcode doesn't advertise it. + + Say Y only if you want to experiment with MFP. diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 91a42c3261aa..dcf39f84f239 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -163,7 +163,10 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; +#ifndef CONFIG_IWLWIFI_EXPERIMENTAL_MFP + /* enable 11w if the uCode advertise */ if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) +#endif /* !CONFIG_IWLWIFI_EXPERIMENTAL_MFP */ hw->flags |= IEEE80211_HW_MFP_CAPABLE; hw->sta_data_size = sizeof(struct iwl_station_priv); -- GitLab From 9a716863ae4a2f039bc4d0b2b2bb4b24a1dc7a91 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 7 Mar 2012 09:52:32 -0800 Subject: [PATCH 1600/1846] iwlwifi: separate status to priv and trans The shared status bits are a mixture of transport and op mode bits. Some are used just by one or the other, some are shared. Begin the de-tangling of these bits. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 16 +++++++--------- drivers/net/wireless/iwlwifi/iwl-agn.h | 9 ++------- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 6 +----- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 + .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 -- 7 files changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 6d8a8578778c..3fed4bbb7e82 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1291,7 +1291,7 @@ int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan) int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) { - if (iwl_is_rfkill(priv->shrd) || iwl_is_ctkill(priv->shrd)) { + if (iwl_is_rfkill(priv->shrd) || iwl_is_ctkill(priv)) { IWL_WARN(priv, "Not sending command - %s KILL\n", iwl_is_rfkill(priv->shrd) ? "RF" : "CT"); return -EIO; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index 9a12b70c7d4f..fa9415309cd6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -233,7 +233,7 @@ static void iwl_tt_ready_for_ct_kill(unsigned long data) IWL_DEBUG_TEMP(priv, "entering CT_KILL state when " "temperature timer expired\n"); tt->state = IWL_TI_CT_KILL; - set_bit(STATUS_CT_KILL, &priv->shrd->status); + set_bit(STATUS_CT_KILL, &priv->status); iwl_perform_ct_kill_task(priv, true); } } @@ -313,22 +313,21 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force) } mutex_lock(&priv->mutex); if (old_state == IWL_TI_CT_KILL) - clear_bit(STATUS_CT_KILL, &priv->shrd->status); + clear_bit(STATUS_CT_KILL, &priv->status); if (tt->state != IWL_TI_CT_KILL && iwl_power_update_mode(priv, true)) { /* TT state not updated * try again during next temperature read */ if (old_state == IWL_TI_CT_KILL) - set_bit(STATUS_CT_KILL, &priv->shrd->status); + set_bit(STATUS_CT_KILL, &priv->status); tt->state = old_state; IWL_ERR(priv, "Cannot update power mode, " "TT state not updated\n"); } else { if (tt->state == IWL_TI_CT_KILL) { if (force) { - set_bit(STATUS_CT_KILL, - &priv->shrd->status); + set_bit(STATUS_CT_KILL, &priv->status); iwl_perform_ct_kill_task(priv, true); } else { iwl_prepare_ct_kill_task(priv); @@ -454,7 +453,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) } mutex_lock(&priv->mutex); if (old_state == IWL_TI_CT_KILL) - clear_bit(STATUS_CT_KILL, &priv->shrd->status); + clear_bit(STATUS_CT_KILL, &priv->status); if (tt->state != IWL_TI_CT_KILL && iwl_power_update_mode(priv, true)) { /* TT state not updated @@ -463,7 +462,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) IWL_ERR(priv, "Cannot update power mode, " "TT state not updated\n"); if (old_state == IWL_TI_CT_KILL) - set_bit(STATUS_CT_KILL, &priv->shrd->status); + set_bit(STATUS_CT_KILL, &priv->status); tt->state = old_state; } else { IWL_DEBUG_TEMP(priv, @@ -474,8 +473,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) if (force) { IWL_DEBUG_TEMP(priv, "Enter IWL_TI_CT_KILL\n"); - set_bit(STATUS_CT_KILL, - &priv->shrd->status); + set_bit(STATUS_CT_KILL, &priv->status); iwl_perform_ct_kill_task(priv, true); } else { iwl_prepare_ct_kill_task(priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 6345ab0f2a96..ede1852b1d7e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -367,11 +367,6 @@ static inline int iwl_is_alive(struct iwl_shared *shrd) return test_bit(STATUS_ALIVE, &shrd->status); } -static inline int iwl_is_init(struct iwl_shared *shrd) -{ - return test_bit(STATUS_INIT, &shrd->status); -} - static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd) { return test_bit(STATUS_RF_KILL_HW, &shrd->status); @@ -382,9 +377,9 @@ static inline int iwl_is_rfkill(struct iwl_shared *shrd) return iwl_is_rfkill_hw(shrd); } -static inline int iwl_is_ctkill(struct iwl_shared *shrd) +static inline int iwl_is_ctkill(struct iwl_priv *priv) { - return test_bit(STATUS_CT_KILL, &shrd->status); + return test_bit(STATUS_CT_KILL, &priv->status); } static inline int iwl_is_ready_rf(struct iwl_shared *shrd) diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 0a898c54c733..1c235d685ae6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -530,15 +530,11 @@ static ssize_t iwl_dbgfs_status_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", - test_bit(STATUS_CT_KILL, &priv->shrd->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", - test_bit(STATUS_INIT, &priv->shrd->status)); + test_bit(STATUS_CT_KILL, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", test_bit(STATUS_ALIVE, &priv->shrd->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", test_bit(STATUS_READY, &priv->shrd->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", - test_bit(STATUS_TEMPERATURE, &priv->shrd->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index c3f372e2c142..1b05faea7965 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -713,6 +713,7 @@ struct iwl_priv { /*data shared among all the driver's layers */ struct iwl_shared *shrd; const struct iwl_fw *fw; + unsigned long status; spinlock_t sta_lock; struct mutex mutex; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 93d89a375a1c..16a32ae4046e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -247,6 +247,7 @@ struct iwl_tx_queue { * @hw_base: pci hardware address support * @ucode_write_complete: indicates that the ucode has been copied. * @ucode_write_waitq: wait queue for uCode load + * @status - transport specific status flags */ struct iwl_trans_pcie { struct iwl_rx_queue rxq; @@ -287,6 +288,7 @@ struct iwl_trans_pcie { bool ucode_write_complete; wait_queue_head_t ucode_write_waitq; + unsigned long status; }; #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 88e1c427f8f5..e78098e79ee1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -833,8 +833,6 @@ static int iwl_nic_init(struct iwl_trans *trans) 0x800FFFFF); } - set_bit(STATUS_INIT, &trans->shrd->status); - return 0; } -- GitLab From 354928dd00d0437149991fad7637c411ba1c62f0 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 7 Mar 2012 09:52:33 -0800 Subject: [PATCH 1601/1846] iwlwifi: make tx_cmd_pool kmem cache global Otherwise we are not able to run more than one device per driver: [ 24.743045] kmem_cache_create: duplicate cache iwl_dev_cmd [ 24.743051] Pid: 3165, comm: NetworkManager Not tainted 3.3.0-rc2-wl+ #5 [ 24.743054] Call Trace: [ 24.743066] [] kmem_cache_create+0x655/0x700 [ 24.743101] [] iwl_alive_notify+0x1cb/0x1f0 [iwlwifi] [ 24.743111] [] iwl_load_ucode_wait_alive+0x1b2/0x220 [iwlwifi] [ 24.743142] [] iwl_run_init_ucode+0x73/0x100 [iwlwifi] [ 24.743152] [] __iwl_up+0x81/0x220 [iwlwifi] [ 24.743161] [] iwlagn_mac_start+0x80/0x190 [iwlwifi] [ 24.743188] [] ieee80211_do_open+0x293/0x770 [mac80211] Signed-off-by: Stanislaw Gruszka Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 8 ++++---- drivers/net/wireless/iwlwifi/iwl-agn.c | 21 +++++++++++++++------ drivers/net/wireless/iwlwifi/iwl-core.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-dev.h | 2 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 9 --------- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index a19db4c0c9fa..97ebfd26212e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -367,7 +367,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (info->flags & IEEE80211_TX_CTL_AMPDU) is_agg = true; - dev_cmd = kmem_cache_alloc(priv->tx_cmd_pool, GFP_ATOMIC); + dev_cmd = kmem_cache_alloc(iwl_tx_cmd_pool, GFP_ATOMIC); if (unlikely(!dev_cmd)) goto drop_unlock_priv; @@ -458,7 +458,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) drop_unlock_sta: if (dev_cmd) - kmem_cache_free(priv->tx_cmd_pool, dev_cmd); + kmem_cache_free(iwl_tx_cmd_pool, dev_cmd); spin_unlock(&priv->sta_lock); drop_unlock_priv: return -1; @@ -1078,7 +1078,7 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, info = IEEE80211_SKB_CB(skb); ctx = info->driver_data[0]; - kmem_cache_free(priv->tx_cmd_pool, + kmem_cache_free(iwl_tx_cmd_pool, (info->driver_data[1])); memset(&info->status, 0, sizeof(info->status)); @@ -1229,7 +1229,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, WARN_ON_ONCE(1); info = IEEE80211_SKB_CB(skb); - kmem_cache_free(priv->tx_cmd_pool, (info->driver_data[1])); + kmem_cache_free(iwl_tx_cmd_pool, (info->driver_data[1])); if (freed == 1) { /* this is the first skb we deliver in this batch */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 64bc2859dd1b..7927e3e11097 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1102,8 +1102,6 @@ static void iwl_uninit_drv(struct iwl_priv *priv) { iwl_free_geos(priv); iwl_free_channel_map(priv); - if (priv->tx_cmd_pool) - kmem_cache_destroy(priv->tx_cmd_pool); kfree(priv->scan_cmd); kfree(priv->beacon_cmd); kfree(rcu_dereference_raw(priv->noa_data)); @@ -1477,6 +1475,9 @@ const struct iwl_op_mode_ops iwl_dvm_ops = { * driver and module entry point * *****************************************************************************/ + +struct kmem_cache *iwl_tx_cmd_pool; + static int __init iwl_init(void) { @@ -1484,20 +1485,27 @@ static int __init iwl_init(void) pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); pr_info(DRV_COPYRIGHT "\n"); + iwl_tx_cmd_pool = kmem_cache_create("iwl_dev_cmd", + sizeof(struct iwl_device_cmd), + sizeof(void *), 0, NULL); + if (!iwl_tx_cmd_pool) + return -ENOMEM; + ret = iwlagn_rate_control_register(); if (ret) { pr_err("Unable to register rate control algorithm: %d\n", ret); - return ret; + goto error_rc_register; } ret = iwl_pci_register_driver(); - if (ret) - goto error_register; + goto error_pci_register; return ret; -error_register: +error_pci_register: iwlagn_rate_control_unregister(); +error_rc_register: + kmem_cache_destroy(iwl_tx_cmd_pool); return ret; } @@ -1505,6 +1513,7 @@ static void __exit iwl_exit(void) { iwl_pci_unregister_driver(); iwlagn_rate_control_unregister(); + kmem_cache_destroy(iwl_tx_cmd_pool); } module_exit(iwl_exit); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f50bd4263b88..df7b165b290c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1470,10 +1470,9 @@ void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) { - struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); struct ieee80211_tx_info *info; info = IEEE80211_SKB_CB(skb); - kmem_cache_free(priv->tx_cmd_pool, (info->driver_data[1])); + kmem_cache_free(iwl_tx_cmd_pool, (info->driver_data[1])); dev_kfree_skb_any(skb); } diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 1b05faea7965..aa4b3b122da4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -725,7 +725,6 @@ struct iwl_priv { struct ieee80211_hw *hw; struct ieee80211_channel *ieee_channels; struct ieee80211_rate *ieee_rates; - struct kmem_cache *tx_cmd_pool; struct list_head calib_results; @@ -983,6 +982,7 @@ struct iwl_priv { bool have_rekey_data; }; /*iwl_priv */ +extern struct kmem_cache *iwl_tx_cmd_pool; extern struct iwl_mod_params iwlagn_mod_params; static inline struct iwl_rxon_context * diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 404fd8e7958b..d97cf44b75ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -318,15 +318,6 @@ static int iwl_alive_notify(struct iwl_priv *priv) { int ret; - if (!priv->tx_cmd_pool) - priv->tx_cmd_pool = - kmem_cache_create("iwl_dev_cmd", - sizeof(struct iwl_device_cmd), - sizeof(void *), 0, NULL); - - if (!priv->tx_cmd_pool) - return -ENOMEM; - iwl_trans_fw_alive(trans(priv)); priv->passive_no_rx = false; -- GitLab From 3251715dc51a8cbd2cd030ff94fe36f37b4b9e74 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 7 Mar 2012 09:52:34 -0800 Subject: [PATCH 1602/1846] iwlwifi: log stop / wake queues There were a few missing occurences when we get PASSIVE_NO_RX 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 | 2 ++ drivers/net/wireless/iwlwifi/iwl-agn.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 97ebfd26212e..ac5c1311ef33 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -1088,6 +1088,8 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, ctx->vif->type == NL80211_IFTYPE_STATION) { /* block and stop all queues */ priv->passive_no_rx = true; + IWL_DEBUG_TX_QUEUES(priv, "stop all queues: " + "passive channel"); ieee80211_stop_queues(priv->hw); IWL_DEBUG_TX_REPLY(priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 7927e3e11097..6ed2f782177b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1450,8 +1450,12 @@ void iwlagn_lift_passive_no_rx(struct iwl_priv *priv) return; for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) { - if (!test_bit(ac, &priv->transport_queue_stop)) + if (!test_bit(ac, &priv->transport_queue_stop)) { + IWL_DEBUG_TX_QUEUES(priv, "Wake queue %d"); ieee80211_wake_queue(priv->hw, ac); + } else { + IWL_DEBUG_TX_QUEUES(priv, "Don't wake queue %d"); + } } priv->passive_no_rx = false; -- GitLab From 92d743ae105314a865b3fca9128da11525d22203 Mon Sep 17 00:00:00 2001 From: Meenakshi Venkataraman Date: Wed, 7 Mar 2012 09:52:35 -0800 Subject: [PATCH 1603/1846] iwlwifi: configure transport layer from dvm op mode Introduce the iwl_trans_config struct which contains state variables that only the op mode can determine, but which the transport layer needs to know. Signed-off-by: Meenakshi Venkataraman Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 10 +++++++++- drivers/net/wireless/iwlwifi/iwl-trans.h | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6ed2f782177b..83018ec11bc7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1185,6 +1185,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, struct iwl_op_mode *op_mode; u16 num_mac; u32 ucode_flags; + struct iwl_trans_config trans_cfg; /************************ * 1. Allocating HW data @@ -1205,7 +1206,14 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, /* TODO: remove fw from shared data later */ priv->shrd->fw = fw; - iwl_trans_configure(trans(priv), op_mode); + /* + * Populate the state variables that the transport layer needs + * to know about. + */ + trans_cfg.op_mode = op_mode; + + /* Configure transport layer */ + iwl_trans_configure(trans(priv), &trans_cfg); /* At this point both hw and priv are allocated. */ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index ed6ab449e439..b6fd42779624 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -274,6 +274,16 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) return p; } +/** + * struct iwl_trans_config - transport configuration + * + * @op_mode: pointer to the upper layer. + * Must be set before any other call. + */ +struct iwl_trans_config { + struct iwl_op_mode *op_mode; +}; + /** * struct iwl_trans_ops - transport specific operations * @@ -408,13 +418,13 @@ struct iwl_trans { }; static inline void iwl_trans_configure(struct iwl_trans *trans, - struct iwl_op_mode *op_mode) + const struct iwl_trans_config *trans_cfg) { /* * only set the op_mode for the moment. Later on, this function will do * more */ - trans->op_mode = op_mode; + trans->op_mode = trans_cfg->op_mode; } static inline int iwl_trans_start_hw(struct iwl_trans *trans) -- GitLab From 9bdfbfadc4f0b3a756b54e7ec7cfaf92c22ce258 Mon Sep 17 00:00:00 2001 From: Meenakshi Venkataraman Date: Wed, 7 Mar 2012 09:52:36 -0800 Subject: [PATCH 1604/1846] iwlwifi: move setting up fw parameters Gather parameters required to configure the transport layer before invoking the transport configuration API. Change-Id: I5b39da284af6d9b5432a08911b4e1173a4d7207d Signed-off-by: Meenakshi Venkataraman Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 45 ++++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 83018ec11bc7..397342402d1e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1206,6 +1206,30 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, /* TODO: remove fw from shared data later */ priv->shrd->fw = fw; + /************************ + * 2. Setup HW constants + ************************/ + iwl_set_hw_params(priv); + + ucode_flags = fw->ucode_capa.flags; + +#ifndef CONFIG_IWLWIFI_P2P + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; +#endif + if (!(hw_params(priv).sku & EEPROM_SKU_CAP_IPAN_ENABLE)) + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; + + /* + * if not PAN, then don't support P2P -- might be a uCode + * packaging bug or due to the eeprom check above + */ + if (!(ucode_flags & IWL_UCODE_TLV_FLAGS_PAN)) + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; + + + /***************************** + * Configure transport layer + *****************************/ /* * Populate the state variables that the transport layer needs * to know about. @@ -1286,27 +1310,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, priv->hw->wiphy->n_addresses++; } - /************************ - * 5. Setup HW constants - ************************/ - iwl_set_hw_params(priv); - - ucode_flags = fw->ucode_capa.flags; - -#ifndef CONFIG_IWLWIFI_P2P - ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; -#endif - if (!(hw_params(priv).sku & EEPROM_SKU_CAP_IPAN_ENABLE)) - ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; - - /* - * if not PAN, then don't support P2P -- might be a uCode - * packaging bug or due to the eeprom check above - */ - if (!(ucode_flags & IWL_UCODE_TLV_FLAGS_PAN)) - ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; - - /******************* * 6. Setup priv *******************/ -- GitLab From 83626404a70da74c67f32f119e53c0ba032ba2d8 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 7 Mar 2012 09:52:37 -0800 Subject: [PATCH 1605/1846] iwlwifi: more status bit factoring Continue splitting the status bits between transport and op_mode. All but a few are separated. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 8 +-- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 18 +++---- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 14 +++--- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 6 +-- drivers/net/wireless/iwlwifi/iwl-agn-tt.c | 20 ++++---- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 4 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 40 +++++++-------- drivers/net/wireless/iwlwifi/iwl-agn.h | 31 +++++------- drivers/net/wireless/iwlwifi/iwl-core.c | 31 ++++++------ drivers/net/wireless/iwlwifi/iwl-debugfs.c | 38 +++++++------- drivers/net/wireless/iwlwifi/iwl-led.c | 2 +- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 34 ++++++------- drivers/net/wireless/iwlwifi/iwl-power.c | 4 +- drivers/net/wireless/iwlwifi/iwl-scan.c | 50 +++++++++---------- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 8 +-- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 10 ++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 8 +-- 17 files changed, 160 insertions(+), 166 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 3fed4bbb7e82..915183a3a873 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -51,7 +51,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv) struct iwlagn_tx_power_dbm_cmd tx_power_cmd; u8 tx_ant_cfg_cmd; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->shrd->status), + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), "TX Power requested while scanning!\n")) return -EAGAIN; @@ -575,7 +575,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work) * STATUS_SCANNING to avoid race when queue_work two times from * different notifications, but quit and not perform any work at all. */ - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) + if (test_bit(STATUS_SCAN_HW, &priv->status)) goto out; iwl_update_chain_flags(priv); @@ -1291,9 +1291,9 @@ int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan) int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) { - if (iwl_is_rfkill(priv->shrd) || iwl_is_ctkill(priv)) { + if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) { IWL_WARN(priv, "Not sending command - %s KILL\n", - iwl_is_rfkill(priv->shrd) ? "RF" : "CT"); + iwl_is_rfkill(priv) ? "RF" : "CT"); return -EIO; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 8e7cdfaf10cc..3ad43330f6a1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -159,7 +159,7 @@ static int iwlagn_rx_csa(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; struct iwl_rxon_cmd *rxon = (void *)&ctx->active; - if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) + if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) return 0; if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) { @@ -355,7 +355,7 @@ static void iwlagn_recover_from_statistics(struct iwl_priv *priv, { unsigned int msecs; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies); @@ -575,7 +575,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, priv->rx_statistics_jiffies = stamp; - set_bit(STATUS_STATISTICS, &priv->shrd->status); + set_bit(STATUS_STATISTICS, &priv->status); /* Reschedule the statistics timer to occur in * reg_recalib_period seconds to ensure we get a @@ -584,7 +584,7 @@ static int iwlagn_rx_statistics(struct iwl_priv *priv, mod_timer(&priv->statistics_periodic, jiffies + msecs_to_jiffies(reg_recalib_period * 1000)); - if (unlikely(!test_bit(STATUS_SCANNING, &priv->shrd->status)) && + if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { iwlagn_rx_calc_noise(priv); queue_work(priv->workqueue, &priv->run_time_calib_work); @@ -658,18 +658,18 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, iwl_tt_exit_ct_kill(priv); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &priv->shrd->status); + set_bit(STATUS_RF_KILL_HW, &priv->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status); + clear_bit(STATUS_RF_KILL_HW, &priv->status); if (!(flags & RXON_CARD_DISABLED)) iwl_scan_cancel(priv); if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &priv->shrd->status))) + test_bit(STATUS_RF_KILL_HW, &priv->status))) wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)); + test_bit(STATUS_RF_KILL_HW, &priv->status)); else wake_up(&priv->shrd->wait_command_queue); return 0; @@ -691,7 +691,7 @@ static int iwlagn_rx_missed_beacon_notif(struct iwl_priv *priv, 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->shrd->status)) + if (!test_bit(STATUS_SCANNING, &priv->status)) iwl_init_sensitivity(priv); } return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 66e9a71aaac6..36909077f994 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -361,7 +361,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv) slot0 = bcnint / 2; slot1 = bcnint - slot0; - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status) || + if (test_bit(STATUS_SCAN_HW, &priv->status) || (!ctx_bss->vif->bss_conf.idle && !ctx_bss->vif->bss_conf.assoc)) { slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME; @@ -377,7 +377,7 @@ int iwlagn_set_pan_params(struct iwl_priv *priv) ctx_pan->beacon_int; slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1); - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { + if (test_bit(STATUS_SCAN_HW, &priv->status)) { slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME; slot1 = IWL_MIN_SLOT_TIME; } @@ -421,7 +421,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) lockdep_assert_held(&priv->mutex); - if (!iwl_is_alive(priv->shrd)) + if (!iwl_is_alive(priv)) return -EBUSY; /* This function hardcodes a bunch of dual-mode assumptions */ @@ -457,7 +457,7 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * receive commit_rxon request * abort any previous channel switch if still in process */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status) && + 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", le16_to_cpu(priv->switch_channel)); @@ -551,12 +551,12 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&priv->mutex); - if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { + if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); goto out; } - if (!iwl_is_ready(priv->shrd)) { + if (!iwl_is_ready(priv)) { IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); goto out; } @@ -794,7 +794,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); - if (unlikely(!iwl_is_ready(priv->shrd))) { + if (unlikely(!iwl_is_ready(priv))) { IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); mutex_unlock(&priv->mutex); return; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index cf5cc1060cf4..23e9eab477bb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -490,7 +490,7 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, { u8 tid; - if (!iwl_is_ready(priv->shrd)) { + if (!iwl_is_ready(priv)) { IWL_DEBUG_INFO(priv, "Unable to remove station %pM, device not ready.\n", addr); @@ -598,7 +598,7 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) int ret; bool send_lq; - if (!iwl_is_ready(priv->shrd)) { + if (!iwl_is_ready(priv)) { IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n"); return; @@ -997,7 +997,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv, keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (iwl_is_rfkill(priv->shrd)) { + if (iwl_is_rfkill(priv)) { IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index fa9415309cd6..baaf5ba2fc38 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -174,7 +174,7 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data) struct iwl_tt_mgmt *tt = &priv->thermal_throttle; unsigned long flags; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (tt->state == IWL_TI_CT_KILL) { @@ -225,7 +225,7 @@ static void iwl_tt_ready_for_ct_kill(unsigned long data) struct iwl_priv *priv = (struct iwl_priv *)data; struct iwl_tt_mgmt *tt = &priv->thermal_throttle; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; /* temperature timer expired, ready to go into CT_KILL state */ @@ -504,10 +504,10 @@ static void iwl_bg_ct_enter(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_enter); struct iwl_tt_mgmt *tt = &priv->thermal_throttle; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - if (!iwl_is_ready(priv->shrd)) + if (!iwl_is_ready(priv)) return; if (tt->state != IWL_TI_CT_KILL) { @@ -533,10 +533,10 @@ static void iwl_bg_ct_exit(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_exit); struct iwl_tt_mgmt *tt = &priv->thermal_throttle; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - if (!iwl_is_ready(priv->shrd)) + if (!iwl_is_ready(priv)) return; /* stop ct_kill_exit_tm timer */ @@ -563,7 +563,7 @@ static void iwl_bg_ct_exit(struct work_struct *work) void iwl_tt_enter_ct_kill(struct iwl_priv *priv) { - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; IWL_DEBUG_TEMP(priv, "Queueing critical temperature enter.\n"); @@ -572,7 +572,7 @@ void iwl_tt_enter_ct_kill(struct iwl_priv *priv) void iwl_tt_exit_ct_kill(struct iwl_priv *priv) { - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; IWL_DEBUG_TEMP(priv, "Queueing critical temperature exit.\n"); @@ -584,7 +584,7 @@ static void iwl_bg_tt_work(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, tt_work); s32 temp = priv->temperature; /* degrees CELSIUS except specified */ - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (!priv->thermal_throttle.advanced_tt) @@ -595,7 +595,7 @@ static void iwl_bg_tt_work(struct work_struct *work) void iwl_tt_handler(struct iwl_priv *priv) { - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; IWL_DEBUG_TEMP(priv, "Queueing thermal throttling work.\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index ac5c1311ef33..9f224548b636 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -297,7 +297,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (info->control.vif) ctx = iwl_rxon_ctx_from_vif(info->control.vif); - if (iwl_is_rfkill(priv->shrd)) { + if (iwl_is_rfkill(priv)) { IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); goto drop_unlock_priv; } @@ -1000,7 +1000,7 @@ static void iwl_check_abort_status(struct iwl_priv *priv, { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { IWL_ERR(priv, "Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) queue_work(priv->workqueue, &priv->tx_flush); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 397342402d1e..d45def33d0f6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -244,11 +244,11 @@ static void iwl_bg_bt_runtime_config(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, bt_runtime_config); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; /* dont send host command if rf-kill is on */ - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) return; iwlagn_send_advance_bt_config(priv); } @@ -261,11 +261,11 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work) mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; /* dont send host command if rf-kill is on */ - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) goto out; IWL_DEBUG_INFO(priv, "BT coex in %s mode\n", @@ -300,11 +300,11 @@ static void iwl_bg_statistics_periodic(unsigned long data) { struct iwl_priv *priv = (struct iwl_priv *)data; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; /* dont send host command if rf-kill is on */ - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) return; iwl_send_statistics_request(priv, CMD_ASYNC, false); @@ -461,7 +461,7 @@ static void iwl_bg_ucode_trace(unsigned long data) { struct iwl_priv *priv = (struct iwl_priv *)data; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (priv->event_log.ucode_trace) { @@ -477,11 +477,11 @@ static void iwl_bg_tx_flush(struct work_struct *work) struct iwl_priv *priv = container_of(work, struct iwl_priv, tx_flush); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; /* do nothing if rf-kill is on */ - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) return; IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n"); @@ -640,12 +640,12 @@ int iwl_alive_start(struct iwl_priv *priv) IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &priv->shrd->status); + set_bit(STATUS_ALIVE, &priv->status); /* Enable watchdog to monitor the driver tx queues */ iwl_setup_watchdog(priv); - if (iwl_is_rfkill(priv->shrd)) + if (iwl_is_rfkill(priv)) return -ERFKILL; if (priv->event_log.ucode_trace) { @@ -719,7 +719,7 @@ int iwl_alive_start(struct iwl_priv *priv) iwl_reset_run_time_calib(priv); } - set_bit(STATUS_READY, &priv->shrd->status); + set_bit(STATUS_READY, &priv->status); /* Configure the adapter for unassociated operation */ ret = iwlagn_commit_rxon(priv, ctx); @@ -786,7 +786,7 @@ void iwl_down(struct iwl_priv *priv) ieee80211_remain_on_channel_expired(priv->hw); exit_pending = - test_and_set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); + test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set * to prevent rearm timer */ @@ -811,7 +811,7 @@ void iwl_down(struct iwl_priv *priv) /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); + clear_bit(STATUS_EXIT_PENDING, &priv->status); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); @@ -820,13 +820,13 @@ void iwl_down(struct iwl_priv *priv) /* Clear out all status bits but a few that are stable across reset */ priv->shrd->status &= - test_bit(STATUS_RF_KILL_HW, &priv->shrd->status) << + test_bit(STATUS_RF_KILL_HW, &priv->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status) << + test_bit(STATUS_GEO_CONFIGURED, &priv->status) << STATUS_GEO_CONFIGURED | test_bit(STATUS_FW_ERROR, &priv->shrd->status) << STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) << + test_bit(STATUS_EXIT_PENDING, &priv->status) << STATUS_EXIT_PENDING; dev_kfree_skb(priv->beacon_skb); @@ -846,8 +846,8 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work) mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || - test_bit(STATUS_SCANNING, &priv->shrd->status)) { + if (test_bit(STATUS_EXIT_PENDING, &priv->status) || + test_bit(STATUS_SCANNING, &priv->status)) { mutex_unlock(&priv->mutex); return; } @@ -903,7 +903,7 @@ static void iwl_bg_restart(struct work_struct *data) { struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (test_and_clear_bit(STATUS_FW_ERROR, &priv->shrd->status)) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index ede1852b1d7e..eb96855ddf8d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -353,28 +353,23 @@ static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv, /* status checks */ -static inline int iwl_is_ready(struct iwl_shared *shrd) +static inline int iwl_is_ready(struct iwl_priv *priv) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ - return test_bit(STATUS_READY, &shrd->status) && - test_bit(STATUS_GEO_CONFIGURED, &shrd->status) && - !test_bit(STATUS_EXIT_PENDING, &shrd->status); + return test_bit(STATUS_READY, &priv->status) && + test_bit(STATUS_GEO_CONFIGURED, &priv->status) && + !test_bit(STATUS_EXIT_PENDING, &priv->status); } -static inline int iwl_is_alive(struct iwl_shared *shrd) +static inline int iwl_is_alive(struct iwl_priv *priv) { - return test_bit(STATUS_ALIVE, &shrd->status); + return test_bit(STATUS_ALIVE, &priv->status); } -static inline int iwl_is_rfkill_hw(struct iwl_shared *shrd) +static inline int iwl_is_rfkill(struct iwl_priv *priv) { - return test_bit(STATUS_RF_KILL_HW, &shrd->status); -} - -static inline int iwl_is_rfkill(struct iwl_shared *shrd) -{ - return iwl_is_rfkill_hw(shrd); + return test_bit(STATUS_RF_KILL_HW, &priv->status); } static inline int iwl_is_ctkill(struct iwl_priv *priv) @@ -382,18 +377,18 @@ static inline int iwl_is_ctkill(struct iwl_priv *priv) return test_bit(STATUS_CT_KILL, &priv->status); } -static inline int iwl_is_ready_rf(struct iwl_shared *shrd) +static inline int iwl_is_ready_rf(struct iwl_priv *priv) { - if (iwl_is_rfkill(shrd)) + if (iwl_is_rfkill(priv)) return 0; - return iwl_is_ready(shrd); + return iwl_is_ready(priv); } #ifdef CONFIG_IWLWIFI_DEBUG #define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ do { \ - if (!iwl_is_rfkill((m)->shrd)) \ + if (!iwl_is_rfkill((m))) \ IWL_ERR(m, fmt, ##args); \ else \ __iwl_err(trans(m)->dev, true, \ @@ -403,7 +398,7 @@ do { \ #else #define IWL_DEBUG_QUIET_RFKILL(m, fmt, args...) \ do { \ - if (!iwl_is_rfkill((m)->shrd)) \ + if (!iwl_is_rfkill((m))) \ IWL_ERR(m, fmt, ##args); \ else \ __iwl_err(trans(m)->dev, true, true, fmt, ##args); \ diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index df7b165b290c..8b85940731f2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -113,7 +113,7 @@ int iwl_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"); - set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status); + set_bit(STATUS_GEO_CONFIGURED, &priv->status); return 0; } @@ -212,7 +212,7 @@ int iwl_init_geos(struct iwl_priv *priv) priv->bands[IEEE80211_BAND_2GHZ].n_channels, priv->bands[IEEE80211_BAND_5GHZ].n_channels); - set_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status); + set_bit(STATUS_GEO_CONFIGURED, &priv->status); return 0; } @@ -224,7 +224,7 @@ void iwl_free_geos(struct iwl_priv *priv) { kfree(priv->ieee_channels); kfree(priv->ieee_rates); - clear_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status); + clear_bit(STATUS_GEO_CONFIGURED, &priv->status); } static bool iwl_is_channel_extension(struct iwl_priv *priv, @@ -798,11 +798,10 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success) */ struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, - &priv->shrd->status)) + if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) ieee80211_chswitch_done(ctx->vif, is_success); } @@ -849,7 +848,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) /* Keep the restart process from trying to send host * commands by clearing the ready bit */ - clear_bit(STATUS_READY, &priv->shrd->status); + clear_bit(STATUS_READY, &priv->status); wake_up(&priv->shrd->wait_command_queue); @@ -874,7 +873,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) priv->reload_count = 0; } - if (!test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { + if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { if (iwlagn_mod_params.restart_fw) { IWL_DEBUG_FW_ERRORS(priv, "Restarting adapter due to uCode error.\n"); @@ -912,7 +911,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) return -EINVAL; } - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) return -EIO; /* scan complete and commit_rxon use tx_power_next value, @@ -920,7 +919,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) priv->tx_power_next = tx_power; /* do not set tx power when scanning or channel changing */ - defer = test_bit(STATUS_SCANNING, &priv->shrd->status) || + 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"); @@ -1219,7 +1218,7 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) static void iwl_force_rf_reset(struct iwl_priv *priv) { - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (!iwl_is_any_associated(priv)) { @@ -1244,7 +1243,7 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external) { struct iwl_force_reset *force_reset; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EINVAL; if (mode >= IWL_MAX_FORCE_RESET) { @@ -1334,10 +1333,10 @@ void iwl_bg_watchdog(unsigned long data) int cnt; unsigned long timeout; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - if (iwl_is_rfkill(priv->shrd)) + if (iwl_is_rfkill(priv)) return; timeout = hw_params(priv).wd_timeout; @@ -1461,9 +1460,9 @@ void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); if (state) - set_bit(STATUS_RF_KILL_HW, &priv->shrd->status); + set_bit(STATUS_RF_KILL_HW, &priv->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->shrd->status); + clear_bit(STATUS_RF_KILL_HW, &priv->status); wiphy_rfkill_set_hw_state(priv->hw->wiphy, state); } diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 1c235d685ae6..7a1334e8c358 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -454,7 +454,7 @@ static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, char *buf; ssize_t ret; - if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)) + if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -525,28 +525,26 @@ static ssize_t iwl_dbgfs_status_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", - test_bit(STATUS_INT_ENABLED, &priv->shrd->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", - test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)); + test_bit(STATUS_RF_KILL_HW, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", test_bit(STATUS_CT_KILL, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", - test_bit(STATUS_ALIVE, &priv->shrd->status)); + test_bit(STATUS_ALIVE, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", - test_bit(STATUS_READY, &priv->shrd->status)); + test_bit(STATUS_READY, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", - test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)); + test_bit(STATUS_GEO_CONFIGURED, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", - test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)); + test_bit(STATUS_EXIT_PENDING, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", - test_bit(STATUS_STATISTICS, &priv->shrd->status)); + test_bit(STATUS_STATISTICS, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", - test_bit(STATUS_SCANNING, &priv->shrd->status)); + test_bit(STATUS_SCANNING, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", - test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status)); + test_bit(STATUS_SCAN_ABORTING, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", - test_bit(STATUS_SCAN_HW, &priv->shrd->status)); + test_bit(STATUS_SCAN_HW, &priv->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", test_bit(STATUS_POWER_PMI, &priv->shrd->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", @@ -752,7 +750,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) return -EINVAL; - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) return -EAGAIN; priv->power_data.debug_sleep_level_override = value; @@ -947,7 +945,7 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, struct statistics_rx_non_phy *delta_general, *max_general; struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - if (!iwl_is_alive(priv->shrd)) + if (!iwl_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -1376,7 +1374,7 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, ssize_t ret; struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!iwl_is_alive(priv->shrd)) + if (!iwl_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -1578,7 +1576,7 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct statistics_div *div, *accum_div, *delta_div, *max_div; - if (!iwl_is_alive(priv->shrd)) + if (!iwl_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -1697,7 +1695,7 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, ssize_t ret; struct statistics_bt_activity *bt, *accum_bt; - if (!iwl_is_alive(priv->shrd)) + if (!iwl_is_alive(priv)) return -EAGAIN; if (!priv->bt_enable_flag) @@ -1790,7 +1788,7 @@ static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200; ssize_t ret; - if (!iwl_is_alive(priv->shrd)) + if (!iwl_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -2148,7 +2146,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, if (trace) { priv->event_log.ucode_trace = true; - if (iwl_is_alive(priv->shrd)) { + if (iwl_is_alive(priv)) { /* start collecting data now */ mod_timer(&priv->ucode_trace, jiffies); } @@ -2338,7 +2336,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, if (sscanf(buf, "%d", &flush) != 1) return -EINVAL; - if (iwl_is_rfkill(priv->shrd)) + if (iwl_is_rfkill(priv)) return -EFAULT; iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index f2f706f084a5..1993a2b7ae63 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c @@ -126,7 +126,7 @@ static int iwl_led_cmd(struct iwl_priv *priv, }; int ret; - if (!test_bit(STATUS_READY, &priv->shrd->status)) + if (!test_bit(STATUS_READY, &priv->status)) return -EBUSY; if (priv->blink_on == on && priv->blink_off == off) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index dcf39f84f239..54d3709c0a6c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -266,7 +266,7 @@ static int __iwl_up(struct iwl_priv *priv) lockdep_assert_held(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); return -EIO; } @@ -297,9 +297,9 @@ static int __iwl_up(struct iwl_priv *priv) return 0; error: - set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); + set_bit(STATUS_EXIT_PENDING, &priv->status); iwl_down(priv); - clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); + clear_bit(STATUS_EXIT_PENDING, &priv->status); IWL_ERR(priv, "Unable to initialize device.\n"); return ret; @@ -322,7 +322,7 @@ static int iwlagn_mac_start(struct ieee80211_hw *hw) IWL_DEBUG_INFO(priv, "Start UP work done.\n"); /* Now we should be done, and the READY bit should be set. */ - if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) + if (WARN_ON(!test_bit(STATUS_READY, &priv->status))) ret = -EIO; iwlagn_led_enable(priv); @@ -807,7 +807,7 @@ static int iwlagn_mac_sta_state(struct ieee80211_hw *hw, * mac80211 might WARN if we fail, but due the way we * (badly) handle hard rfkill, we might fail here */ - if (iwl_is_rfkill(priv->shrd)) + if (iwl_is_rfkill(priv)) ret = 0; mutex_unlock(&priv->mutex); @@ -839,12 +839,12 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); - if (iwl_is_rfkill(priv->shrd)) + if (iwl_is_rfkill(priv)) goto out; - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || - test_bit(STATUS_SCANNING, &priv->shrd->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) + if (test_bit(STATUS_EXIT_PENDING, &priv->status) || + test_bit(STATUS_SCANNING, &priv->status) || + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) goto out; if (!iwl_is_associated_ctx(ctx)) @@ -884,10 +884,10 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, * at this point, staging_rxon has the * configuration for channel switch */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); priv->switch_channel = cpu_to_le16(ch); if (cfg(priv)->lib->set_channel_switch(priv, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); priv->switch_channel = 0; ieee80211_chswitch_done(ctx->vif, false); } @@ -954,11 +954,11 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) mutex_lock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "enter\n"); - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); goto done; } - if (iwl_is_rfkill(priv->shrd)) { + if (iwl_is_rfkill(priv)) { IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); goto done; } @@ -999,7 +999,7 @@ static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->mutex); - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { + if (test_bit(STATUS_SCAN_HW, &priv->status)) { err = -EBUSY; goto out; } @@ -1140,7 +1140,7 @@ static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211(priv, "enter\n"); - if (!iwl_is_ready_rf(priv->shrd)) { + if (!iwl_is_ready_rf(priv)) { IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); return -EIO; } @@ -1241,7 +1241,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, iwlagn_disable_roc(priv); - if (!iwl_is_ready_rf(priv->shrd)) { + if (!iwl_is_ready_rf(priv)) { IWL_WARN(priv, "Try to add interface when device not ready\n"); err = -EINVAL; goto out; @@ -1365,7 +1365,7 @@ static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); - if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { + if (!ctx->vif || !iwl_is_ready_rf(priv)) { /* * Huh? But wait ... this can maybe happen when * we're in the middle of a firmware restart! diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index f79ff16e29f4..958d9d09aee3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c @@ -392,12 +392,12 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_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->shrd->status) && !force) { + if (test_bit(STATUS_SCANNING, &priv->status) && !force) { IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 8c3fb3233d9f..902efe4bc898 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c @@ -66,9 +66,9 @@ static int iwl_send_scan_abort(struct iwl_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->shrd->status) || - !test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status) || - !test_bit(STATUS_SCAN_HW, &priv->shrd->status) || + 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->shrd->status)) return -EIO; @@ -118,18 +118,18 @@ static void iwl_process_scan_complete(struct iwl_priv *priv) lockdep_assert_held(&priv->mutex); - if (!test_and_clear_bit(STATUS_SCAN_COMPLETE, &priv->shrd->status)) + if (!test_and_clear_bit(STATUS_SCAN_COMPLETE, &priv->status)) return; IWL_DEBUG_SCAN(priv, "Completed scan.\n"); cancel_delayed_work(&priv->scan_check); - aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->shrd->status); + aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status); if (aborted) IWL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); - if (!test_and_clear_bit(STATUS_SCANNING, &priv->shrd->status)) { + if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) { IWL_DEBUG_SCAN(priv, "Scan already completed.\n"); goto out_settings; } @@ -165,7 +165,7 @@ static void iwl_process_scan_complete(struct iwl_priv *priv) out_settings: /* Can we still talk to firmware ? */ - if (!iwl_is_ready_rf(priv->shrd)) + if (!iwl_is_ready_rf(priv)) return; iwlagn_post_scan(priv); @@ -175,16 +175,16 @@ void iwl_force_scan_end(struct iwl_priv *priv) { lockdep_assert_held(&priv->mutex); - if (!test_bit(STATUS_SCANNING, &priv->shrd->status)) { + if (!test_bit(STATUS_SCANNING, &priv->status)) { IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); return; } IWL_DEBUG_SCAN(priv, "Forcing scan end\n"); - clear_bit(STATUS_SCANNING, &priv->shrd->status); - clear_bit(STATUS_SCAN_HW, &priv->shrd->status); - clear_bit(STATUS_SCAN_ABORTING, &priv->shrd->status); - clear_bit(STATUS_SCAN_COMPLETE, &priv->shrd->status); + clear_bit(STATUS_SCANNING, &priv->status); + clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_ABORTING, &priv->status); + clear_bit(STATUS_SCAN_COMPLETE, &priv->status); iwl_complete_scan(priv, true); } @@ -194,12 +194,12 @@ static void iwl_do_scan_abort(struct iwl_priv *priv) lockdep_assert_held(&priv->mutex); - if (!test_bit(STATUS_SCANNING, &priv->shrd->status)) { + if (!test_bit(STATUS_SCANNING, &priv->status)) { IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); return; } - if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->shrd->status)) { + if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) { IWL_DEBUG_SCAN(priv, "Scan abort in progress\n"); return; } @@ -238,7 +238,7 @@ void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) iwl_do_scan_abort(priv); while (time_before_eq(jiffies, timeout)) { - if (!test_bit(STATUS_SCAN_HW, &priv->shrd->status)) + if (!test_bit(STATUS_SCAN_HW, &priv->status)) goto finished; msleep(20); } @@ -350,8 +350,8 @@ static int iwl_rx_scan_complete_notif(struct iwl_priv *priv, * to clear, we need to set SCAN_COMPLETE before clearing SCAN_HW * to avoid a race there. */ - set_bit(STATUS_SCAN_COMPLETE, &priv->shrd->status); - clear_bit(STATUS_SCAN_HW, &priv->shrd->status); + set_bit(STATUS_SCAN_COMPLETE, &priv->status); + clear_bit(STATUS_SCAN_HW, &priv->status); queue_work(priv->workqueue, &priv->scan_completed); if (priv->iw_mode != NL80211_IFTYPE_ADHOC && @@ -927,7 +927,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan->len = cpu_to_le16(cmd.len[0]); /* set scan bit here for PAN params */ - set_bit(STATUS_SCAN_HW, &priv->shrd->status); + set_bit(STATUS_SCAN_HW, &priv->status); ret = iwlagn_set_pan_params(priv); if (ret) @@ -935,7 +935,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) ret = iwl_dvm_send_cmd(priv, &cmd); if (ret) { - clear_bit(STATUS_SCAN_HW, &priv->shrd->status); + clear_bit(STATUS_SCAN_HW, &priv->status); iwlagn_set_pan_params(priv); } @@ -962,18 +962,18 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, cancel_delayed_work(&priv->scan_check); - if (!iwl_is_ready_rf(priv->shrd)) { + if (!iwl_is_ready_rf(priv)) { IWL_WARN(priv, "Request scan called when driver not ready.\n"); return -EIO; } - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { + if (test_bit(STATUS_SCAN_HW, &priv->status)) { IWL_DEBUG_SCAN(priv, "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } - if (test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status)) { + if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { IWL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); return -EBUSY; } @@ -983,14 +983,14 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv, scan_type == IWL_SCAN_ROC ? "remain-on-channel " : "internal short "); - set_bit(STATUS_SCANNING, &priv->shrd->status); + set_bit(STATUS_SCANNING, &priv->status); priv->scan_type = scan_type; priv->scan_start = jiffies; priv->scan_band = band; ret = iwlagn_request_scan(priv, vif); if (ret) { - clear_bit(STATUS_SCANNING, &priv->shrd->status); + clear_bit(STATUS_SCANNING, &priv->status); priv->scan_type = IWL_SCAN_NORMAL; return ret; } @@ -1025,7 +1025,7 @@ static void iwl_bg_start_internal_scan(struct work_struct *work) goto unlock; } - if (test_bit(STATUS_SCANNING, &priv->shrd->status)) { + if (test_bit(STATUS_SCANNING, &priv->status)) { IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); goto unlock; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 16a32ae4046e..dd64e69b1569 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -356,7 +356,8 @@ void iwl_dump_csr(struct iwl_trans *trans); ******************************************************/ static inline void iwl_disable_interrupts(struct iwl_trans *trans) { - clear_bit(STATUS_INT_ENABLED, &trans->shrd->status); + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + clear_bit(STATUS_INT_ENABLED, &trans_pcie->status); /* disable interrupts from uCode/NIC to host */ iwl_write32(trans, CSR_INT_MASK, 0x00000000); @@ -370,11 +371,10 @@ static inline void iwl_disable_interrupts(struct iwl_trans *trans) static inline void iwl_enable_interrupts(struct iwl_trans *trans) { - struct iwl_trans_pcie *trans_pcie = - IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); IWL_DEBUG_ISR(trans, "Enabling interrupts\n"); - set_bit(STATUS_INT_ENABLED, &trans->shrd->status); + set_bit(STATUS_INT_ENABLED, &trans_pcie->status); iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask); } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 2d6ea42b0d8e..32820913a2fd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1131,7 +1131,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &trans->shrd->status)) + if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status)) iwl_enable_interrupts(trans); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) @@ -1303,7 +1303,7 @@ static irqreturn_t iwl_isr(int irq, void *data) /* iwl_irq_tasklet() will service interrupts and re-enable them */ if (likely(inta)) tasklet_schedule(&trans_pcie->irq_tasklet); - else if (test_bit(STATUS_INT_ENABLED, &trans->shrd->status) && + else if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && !trans_pcie->inta) iwl_enable_interrupts(trans); @@ -1314,7 +1314,7 @@ static irqreturn_t iwl_isr(int irq, void *data) none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq and no schedules tasklet. */ - if (test_bit(STATUS_INT_ENABLED, &trans->shrd->status) && + if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && !trans_pcie->inta) iwl_enable_interrupts(trans); @@ -1414,7 +1414,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) /* iwl_irq_tasklet() will service interrupts and re-enable them */ if (likely(inta)) tasklet_schedule(&trans_pcie->irq_tasklet); - else if (test_bit(STATUS_INT_ENABLED, &trans->shrd->status) && + else if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && !trans_pcie->inta) { /* Allow interrupt if was disabled by this handler and * no tasklet was schedules, We should not enable interrupt, @@ -1430,7 +1430,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data) /* 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, &trans->shrd->status) && + if (test_bit(STATUS_INT_ENABLED, &trans_pcie->status) && !trans_pcie->inta) iwl_enable_interrupts(trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index e78098e79ee1..3b8a5fb771f6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -684,6 +684,7 @@ static void iwl_apm_config(struct iwl_trans *trans) */ static int iwl_apm_init(struct iwl_trans *trans) { + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); int ret = 0; IWL_DEBUG_INFO(trans, "Init card's basic functions\n"); @@ -753,7 +754,7 @@ static int iwl_apm_init(struct iwl_trans *trans) iwl_set_bits_prph(trans, APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); - set_bit(STATUS_DEVICE_ENABLED, &trans->shrd->status); + set_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); out: return ret; @@ -779,9 +780,10 @@ static int iwl_apm_stop_master(struct iwl_trans *trans) static void iwl_apm_stop(struct iwl_trans *trans) { + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n"); - clear_bit(STATUS_DEVICE_ENABLED, &trans->shrd->status); + clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); /* Stop device's DMA activity */ iwl_apm_stop_master(trans); @@ -1265,7 +1267,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) * restart. So don't process again if the device is * already dead. */ - if (test_bit(STATUS_DEVICE_ENABLED, &trans->shrd->status)) { + if (test_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status)) { iwl_trans_tx_stop(trans); #ifndef CONFIG_IWLWIFI_IDI iwl_trans_rx_stop(trans); -- GitLab From bada991b4590122c847520ed2b651b679c16afd3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:39 -0800 Subject: [PATCH 1606/1846] iwlwifi: remove messages from queue wake/stop The only reason we ever stop/wake queues at the transport level is now that they become full (or non-full), so the messages aren't useful any more -- remove them. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 36 +++++++++---------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index dd64e69b1569..c0e68097fcb5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -409,7 +409,7 @@ static inline u8 iwl_get_queue_ac(struct iwl_tx_queue *txq) } static inline void iwl_wake_queue(struct iwl_trans *trans, - struct iwl_tx_queue *txq, const char *msg) + struct iwl_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -420,19 +420,19 @@ static inline void iwl_wake_queue(struct iwl_trans *trans, if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) { if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) { iwl_op_mode_queue_not_full(trans->op_mode, ac); - IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d. %s", - hwq, ac, msg); + IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d", + hwq, ac); } else { - IWL_DEBUG_TX_QUEUES(trans, "Don't wake hwq %d ac %d" - " stop count %d. %s", - hwq, ac, atomic_read(&trans_pcie-> - queue_stop_count[ac]), msg); + IWL_DEBUG_TX_QUEUES(trans, + "Don't wake hwq %d ac %d stop count %d", + hwq, ac, + atomic_read(&trans_pcie->queue_stop_count[ac])); } } } static inline void iwl_stop_queue(struct iwl_trans *trans, - struct iwl_tx_queue *txq, const char *msg) + struct iwl_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -443,19 +443,19 @@ static inline void iwl_stop_queue(struct iwl_trans *trans, if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) { if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) { iwl_op_mode_queue_full(trans->op_mode, ac); - IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d ac %d" - " stop count %d. %s", - hwq, ac, atomic_read(&trans_pcie-> - queue_stop_count[ac]), msg); + IWL_DEBUG_TX_QUEUES(trans, + "Stop hwq %d ac %d stop count %d", + hwq, ac, + atomic_read(&trans_pcie->queue_stop_count[ac])); } else { - IWL_DEBUG_TX_QUEUES(trans, "Don't stop hwq %d ac %d" - " stop count %d. %s", - hwq, ac, atomic_read(&trans_pcie-> - queue_stop_count[ac]), msg); + IWL_DEBUG_TX_QUEUES(trans, + "Don't stop hwq %d ac %d stop count %d", + hwq, ac, + atomic_read(&trans_pcie->queue_stop_count[ac])); } } else { - IWL_DEBUG_TX_QUEUES(trans, "stop hwq %d, but it is stopped/ %s", - hwq, msg); + IWL_DEBUG_TX_QUEUES(trans, "stop hwq %d, but it is stopped", + hwq); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 3b8a5fb771f6..6172651d7e25 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1487,7 +1487,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, txq->need_update = 1; iwl_txq_update_write_ptr(trans, txq); } else { - iwl_stop_queue(trans, txq, "Queue is full"); + iwl_stop_queue(trans, txq); } } spin_unlock(&txq->lock); @@ -1591,7 +1591,7 @@ static int iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, tfd_num, ssn); freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs); if (iwl_queue_space(&txq->q) > txq->q.low_mark) - iwl_wake_queue(trans, txq, "Packets reclaimed"); + iwl_wake_queue(trans, txq); } spin_unlock(&txq->lock); -- GitLab From e6dd5838acf312516fcc4eb34516de5bc45e2980 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:40 -0800 Subject: [PATCH 1607/1846] iwlwifi: make iwl_init_context static It's not needed anywhere but during init. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index d45def33d0f6..8c21db81ba5f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -488,7 +488,7 @@ static void iwl_bg_tx_flush(struct work_struct *work) iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); } -void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) +static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) { int i; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index eb96855ddf8d..5410dfd40694 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -118,7 +118,6 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf, int iwlagn_rx_calib_result(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd); -void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags); int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); void iwl_send_prio_tbl(struct iwl_priv *priv); int iwl_init_alive_start(struct iwl_priv *priv); -- GitLab From 974205153be8944539890084a170e3ad407164bc Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Mar 2012 09:52:42 -0800 Subject: [PATCH 1608/1846] iwlwifi: don't delete AP station directly With the mac80211 deauth sequence changes, the station is deleted before the device is set unassociated. This can cause the device to get confused as it expects the station to be there while the associated bit is set. To fix this, do not delete the AP station from the device when mac80211 asks for deletion, instead just mark it as unused and rely on the unassociated RXON to drop it from the station database in the device. 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 | 35 +++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-agn.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 22 +++++++++---- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 23e9eab477bb..c4175603864b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -546,6 +546,41 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, return -EINVAL; } +void iwl_deactivate_station(struct iwl_priv *priv, const u8 sta_id, + const u8 *addr) +{ + u8 tid; + + if (!iwl_is_ready(priv)) { + IWL_DEBUG_INFO(priv, + "Unable to remove station %pM, device not ready.\n", + addr); + return; + } + + IWL_DEBUG_ASSOC(priv, "Deactivating STA: %pM (%d)\n", addr, sta_id); + + if (WARN_ON_ONCE(sta_id == IWL_INVALID_STATION)) + return; + + spin_lock_bh(&priv->sta_lock); + + WARN_ON_ONCE(!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)); + + for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) + memset(&priv->tid_data[sta_id][tid], 0, + sizeof(priv->tid_data[sta_id][tid])); + + priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; + + priv->num_stations--; + + if (WARN_ON_ONCE(priv->num_stations < 0)) + priv->num_stations = 0; + + spin_unlock_bh(&priv->sta_lock); +} + /** * iwl_clear_ucode_stations - clear ucode station table bits * diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 5410dfd40694..3780a03f2716 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -234,6 +234,8 @@ int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx, struct ieee80211_sta *sta, u8 *sta_id_r); int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, const u8 *addr); +void iwl_deactivate_station(struct iwl_priv *priv, const u8 sta_id, + const u8 *addr); u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta); diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 54d3709c0a6c..9212ee3bef9b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -724,12 +724,22 @@ static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; int ret; - IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", - sta->addr); - ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); - if (ret) - IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", - sta->addr); + IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", sta->addr); + + if (vif->type == NL80211_IFTYPE_STATION) { + /* + * Station will be removed from device when the RXON + * is set to unassociated -- just deactivate it here + * to avoid re-programming it. + */ + ret = 0; + iwl_deactivate_station(priv, sta_priv->sta_id, sta->addr); + } else { + ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); + if (ret) + IWL_DEBUG_QUIET_RFKILL(priv, + "Error removing station %pM\n", sta->addr); + } return ret; } -- GitLab From 1353a7ba7ebe62dedc60a5ba75c434cfad960ede Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 7 Mar 2012 09:52:43 -0800 Subject: [PATCH 1609/1846] iwlwifi: correct status bit refactoring errors I missed a couple of status bits in my refactoring changes. This fixes the ones I missed. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 3ad43330f6a1..cc0227c1f352 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -628,7 +628,7 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, struct iwl_rx_packet *pkt = rxb_addr(rxb); struct iwl_card_state_notif *card_state_notif = (void *)pkt->data; u32 flags = le32_to_cpu(card_state_notif->flags); - unsigned long status = priv->shrd->status; + unsigned long status = priv->status; IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8c21db81ba5f..60f1dc640c94 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -819,15 +819,15 @@ void iwl_down(struct iwl_priv *priv) iwl_trans_stop_device(trans(priv)); /* Clear out all status bits but a few that are stable across reset */ - priv->shrd->status &= - test_bit(STATUS_RF_KILL_HW, &priv->status) << + priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << STATUS_RF_KILL_HW | test_bit(STATUS_GEO_CONFIGURED, &priv->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &priv->shrd->status) << - STATUS_FW_ERROR | test_bit(STATUS_EXIT_PENDING, &priv->status) << STATUS_EXIT_PENDING; + priv->shrd->status &= + test_bit(STATUS_FW_ERROR, &priv->shrd->status) << + STATUS_FW_ERROR; dev_kfree_skb(priv->beacon_skb); priv->beacon_skb = NULL; -- GitLab From f44d4eb54432a0109ff15b2669c91f061428ff39 Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Wed, 7 Mar 2012 21:31:13 +0100 Subject: [PATCH 1610/1846] mac80211: update ieee80211_tx_rate_control kerneldoc * add entry for rate_idx_mcs_mask * fix order of entries to represent the structs' order Signed-off-by: Simon Wunderlich Signed-off-by: John W. Linville --- include/net/mac80211.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index c06974accfa6..f7917f765cbc 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -3568,6 +3568,8 @@ enum rate_control_changed { * @hw: The hardware the algorithm is invoked for. * @sband: The band this frame is being transmitted on. * @bss_conf: the current BSS configuration + * @skb: the skb that will be transmitted, the control information in it needs + * to be filled in * @reported_rate: The rate control algorithm can fill this in to indicate * which rate should be reported to userspace as the current rate and * used for rate calculations in the mesh network. @@ -3575,12 +3577,11 @@ enum rate_control_changed { * RTS threshold * @short_preamble: whether mac80211 will request short-preamble transmission * if the selected rate supports it - * @max_rate_idx: user-requested maximum rate (not MCS for now) + * @max_rate_idx: user-requested maximum (legacy) rate * (deprecated; this will be removed once drivers get updated to use * rate_idx_mask) - * @rate_idx_mask: user-requested rate mask (not MCS for now) - * @skb: the skb that will be transmitted, the control information in it needs - * to be filled in + * @rate_idx_mask: user-requested (legacy) rate mask + * @rate_idx_mcs_mask: user-requested MCS rate mask * @bss: whether this frame is sent out in AP or IBSS mode */ struct ieee80211_tx_rate_control { -- GitLab From d11f0ca0121996461b17e93941e9dfa0a9eebbd1 Mon Sep 17 00:00:00 2001 From: Stanislav Yakovlev Date: Wed, 7 Mar 2012 19:32:40 -0500 Subject: [PATCH 1611/1846] net/wireless: ipw2x00: remove WEXT_USECHANNELS define Driver does not use it any more. Signed-off-by: Stanislav Yakovlev Signed-off-by: John W. Linville --- drivers/net/wireless/ipw2x00/ipw2100.c | 2 -- drivers/net/wireless/ipw2x00/ipw2200.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index 5d7e97e63def..ddf340f914da 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c @@ -298,8 +298,6 @@ static const char *command_types[] = { }; #endif -#define WEXT_USECHANNELS 1 - static const long ipw2100_frequencies[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, diff --git a/drivers/net/wireless/ipw2x00/ipw2200.h b/drivers/net/wireless/ipw2x00/ipw2200.h index ecb561d7a7a0..66e84ec0eb55 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.h +++ b/drivers/net/wireless/ipw2x00/ipw2200.h @@ -27,8 +27,6 @@ #ifndef __ipw2200_h__ #define __ipw2200_h__ -#define WEXT_USECHANNELS 1 - #include #include #include -- GitLab From 8763848e03a9098e5b6f81428a98738dc960a436 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Wed, 7 Mar 2012 19:36:07 -0800 Subject: [PATCH 1612/1846] mwifiex: correction in number of bitrates In recent commit "mwifiex: correct bitrates advertised..", we have removed 22Mbps and 72Mbps bitrates from supported bitrate array. It means number of bitrates has reduced from 14 to 12. Initialize ".n_bitrates" to array size instead of hardcoding it. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index b4890a01ba92..84508b065265 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -646,7 +646,7 @@ static struct ieee80211_supported_band mwifiex_band_2ghz = { .channels = mwifiex_channels_2ghz, .n_channels = ARRAY_SIZE(mwifiex_channels_2ghz), .bitrates = mwifiex_rates, - .n_bitrates = 14, + .n_bitrates = ARRAY_SIZE(mwifiex_rates), }; static struct ieee80211_channel mwifiex_channels_5ghz[] = { -- GitLab From 0343c5543b1d3ffa08e6716d82afb62648b80eba Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 8 Mar 2012 05:55:58 +0000 Subject: [PATCH 1613/1846] sctp: Export sctp_do_peeloff lookup sctp_association within sctp_do_peeloff() to enable its use outside of the sctp code with minimal knowledge of the former. Signed-off-by: Benjamin Poirier Acked-by: Vlad Yasevich Signed-off-by: David S. Miller --- include/net/sctp/sctp.h | 1 + net/sctp/socket.c | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index d3685615a8b0..6ee44b24864a 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h @@ -413,6 +413,7 @@ static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) /* Look up the association by its id. */ struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id); +int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp); /* A macro to walk a list of skbs. */ #define sctp_skb_for_each(pos, head, tmp) \ diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 408ebd0e7330..06b42b7f5a02 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4170,14 +4170,16 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv } /* Helper routine to branch off an association to a new socket. */ -SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc, - struct socket **sockp) +int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp) { - struct sock *sk = asoc->base.sk; + struct sctp_association *asoc = sctp_id2assoc(sk, id); struct socket *sock; struct sctp_af *af; int err = 0; + if (!asoc) + return -EINVAL; + /* An association cannot be branched off from an already peeled-off * socket, nor is this supported for tcp style sockets. */ @@ -4206,13 +4208,13 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc, return err; } +EXPORT_SYMBOL(sctp_do_peeloff); static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval, int __user *optlen) { sctp_peeloff_arg_t peeloff; struct socket *newsock; int retval = 0; - struct sctp_association *asoc; if (len < sizeof(sctp_peeloff_arg_t)) return -EINVAL; @@ -4220,15 +4222,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval if (copy_from_user(&peeloff, optval, len)) return -EFAULT; - asoc = sctp_id2assoc(sk, peeloff.associd); - if (!asoc) { - retval = -EINVAL; - goto out; - } - - SCTP_DEBUG_PRINTK("%s: sk: %p asoc: %p\n", __func__, sk, asoc); - - retval = sctp_do_peeloff(asoc, &newsock); + retval = sctp_do_peeloff(sk, peeloff.associd, &newsock); if (retval < 0) goto out; @@ -4239,8 +4233,8 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval goto out; } - SCTP_DEBUG_PRINTK("%s: sk: %p asoc: %p newsk: %p sd: %d\n", - __func__, sk, asoc, newsock->sk, retval); + SCTP_DEBUG_PRINTK("%s: sk: %p newsk: %p sd: %d\n", + __func__, sk, newsock->sk, retval); /* Return the fd mapped to the new socket. */ peeloff.sd = retval; -- GitLab From 2f2d76cc3e938389feee671b46252dde6880b3b7 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 8 Mar 2012 05:55:59 +0000 Subject: [PATCH 1614/1846] dlm: Do not allocate a fd for peeloff avoids allocating a fd that a) propagates to every kernel thread and usermodehelper b) is not properly released. References: http://article.gmane.org/gmane.linux.network.drbd/22529 Signed-off-by: Benjamin Poirier Signed-off-by: David S. Miller --- fs/dlm/lowcomms.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 0b3109ee4257..ca0c59a4246c 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -474,9 +475,6 @@ static void process_sctp_notification(struct connection *con, int prim_len, ret; int addr_len; struct connection *new_con; - sctp_peeloff_arg_t parg; - int parglen = sizeof(parg); - int err; /* * We get this before any data for an association. @@ -525,23 +523,19 @@ static void process_sctp_notification(struct connection *con, return; /* Peel off a new sock */ - parg.associd = sn->sn_assoc_change.sac_assoc_id; - ret = kernel_getsockopt(con->sock, IPPROTO_SCTP, - SCTP_SOCKOPT_PEELOFF, - (void *)&parg, &parglen); + sctp_lock_sock(con->sock->sk); + ret = sctp_do_peeloff(con->sock->sk, + sn->sn_assoc_change.sac_assoc_id, + &new_con->sock); + sctp_release_sock(con->sock->sk); if (ret < 0) { log_print("Can't peel off a socket for " "connection %d to node %d: err=%d", - parg.associd, nodeid, ret); - return; - } - new_con->sock = sockfd_lookup(parg.sd, &err); - if (!new_con->sock) { - log_print("sockfd_lookup error %d", err); + (int)sn->sn_assoc_change.sac_assoc_id, + nodeid, ret); return; } add_sock(new_con->sock, new_con); - sockfd_put(new_con->sock); log_print("connecting to %d sctp association %d", nodeid, (int)sn->sn_assoc_change.sac_assoc_id); -- GitLab From c6f600fcfe8a7e4f594fc4c80b2c7b66f248958b Mon Sep 17 00:00:00 2001 From: Meenakshi Venkataraman Date: Thu, 8 Mar 2012 11:29:12 -0800 Subject: [PATCH 1615/1846] iwlwifi: move command queue number out of the iwl_shared struct The command queue number is required by the transport layer, but it can be determined only by the op mode. Move this parameter to the dvm op mode, and configure the transport layer using an API. Signed-off-by: Meenakshi Venkataraman Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 16 ++++----- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 ++ .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 24 ++++++------- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 34 +++++++++++++------ drivers/net/wireless/iwlwifi/iwl-trans.h | 9 +++++ 7 files changed, 56 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 60f1dc640c94..1e6b5e41a72b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1236,6 +1236,14 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, */ trans_cfg.op_mode = op_mode; + if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) { + priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; + trans_cfg.cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; + } else { + priv->sta_key_max_num = STA_KEY_MAX_NUM; + trans_cfg.cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; + } + /* Configure transport layer */ iwl_trans_configure(trans(priv), &trans_cfg); @@ -1336,14 +1344,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, priv->new_scan_threshold_behaviour = !!(ucode_flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); - if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) { - priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; - priv->shrd->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; - } else { - priv->sta_key_max_num = STA_KEY_MAX_NUM; - priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; - } - priv->phy_calib_chain_noise_reset_cmd = fw->ucode_capa.standard_phy_calibration_size; priv->phy_calib_chain_noise_gain_cmd = diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 45409fcfbbd7..0d957ca3d6c6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -368,7 +368,6 @@ struct iwl_cfg { /** * struct iwl_shared - shared fields for all the layers of the driver * - * @cmd_queue: command queue number * @status: STATUS_* * @wowlan: are we running wowlan uCode * @valid_contexts: microcode/device supports multiple contexts @@ -385,7 +384,6 @@ struct iwl_cfg { * @device_pointers: pointers to ucode event tables */ struct iwl_shared { - u8 cmd_queue; unsigned long status; u8 valid_contexts; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index c0e68097fcb5..67965599bb30 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -248,6 +248,7 @@ struct iwl_tx_queue { * @ucode_write_complete: indicates that the ucode has been copied. * @ucode_write_waitq: wait queue for uCode load * @status - transport specific status flags + * @cmd_queue - command queue number */ struct iwl_trans_pcie { struct iwl_rx_queue rxq; @@ -289,6 +290,7 @@ struct iwl_trans_pcie { bool ucode_write_complete; wait_queue_head_t ucode_write_waitq; unsigned long status; + u8 cmd_queue; }; #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 32820913a2fd..a5547a155b95 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -361,7 +361,7 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans, { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_rx_queue *rxq = &trans_pcie->rxq; - struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue]; + struct iwl_tx_queue *txq = &trans_pcie->txq[trans_pcie->cmd_queue]; struct iwl_device_cmd *cmd; unsigned long flags; int len, err; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 73febc9726cb..2b1df0092aee 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -397,7 +397,7 @@ static void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_trans *trans, WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX); - if (txq_id != trans->shrd->cmd_queue) + if (txq_id != trans_pcie->cmd_queue) sta_id = tx_cmd->sta_id; bc_ent = cpu_to_le16(1 | (sta_id << 12)); @@ -664,7 +664,7 @@ int iwl_trans_pcie_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue]; + struct iwl_tx_queue *txq = &trans_pcie->txq[trans_pcie->cmd_queue]; struct iwl_queue *q = &txq->q; struct iwl_device_cmd *out_cmd; struct iwl_cmd_meta *out_meta; @@ -737,7 +737,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) out_cmd->hdr.cmd = cmd->id; out_cmd->hdr.flags = 0; out_cmd->hdr.sequence = - cpu_to_le16(QUEUE_TO_SEQ(trans->shrd->cmd_queue) | + cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->cmd_queue) | INDEX_TO_SEQ(q->write_ptr)); /* and copy the data that needs to be copied */ @@ -757,7 +757,7 @@ static int iwl_enqueue_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), cmd_size, - q->write_ptr, idx, trans->shrd->cmd_queue); + q->write_ptr, idx, trans_pcie->cmd_queue); phys_addr = dma_map_single(trans->dev, &out_cmd->hdr, copy_size, DMA_BIDIRECTIONAL); @@ -881,16 +881,16 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb, struct iwl_device_cmd *cmd; struct iwl_cmd_meta *meta; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - struct iwl_tx_queue *txq = &trans_pcie->txq[trans->shrd->cmd_queue]; + struct iwl_tx_queue *txq = &trans_pcie->txq[trans_pcie->cmd_queue]; /* 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 != trans->shrd->cmd_queue, + if (WARN(txq_id != trans_pcie->cmd_queue, "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, trans->shrd->cmd_queue, sequence, - trans_pcie->txq[trans->shrd->cmd_queue].q.read_ptr, - trans_pcie->txq[trans->shrd->cmd_queue].q.write_ptr)) { + txq_id, trans_pcie->cmd_queue, sequence, + trans_pcie->txq[trans_pcie->cmd_queue].q.read_ptr, + trans_pcie->txq[trans_pcie->cmd_queue].q.write_ptr)) { iwl_print_hex_error(trans, pkt, 32); return; } @@ -997,7 +997,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) if (!ret) { if (test_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status)) { struct iwl_tx_queue *txq = - &trans_pcie->txq[trans->shrd->cmd_queue]; + &trans_pcie->txq[trans_pcie->cmd_queue]; struct iwl_queue *q = &txq->q; IWL_ERR(trans, @@ -1034,7 +1034,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) * in later, it will possibly set an invalid * address (cmd->meta.source). */ - trans_pcie->txq[trans->shrd->cmd_queue].meta[cmd_idx].flags &= + trans_pcie->txq[trans_pcie->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; } @@ -1065,7 +1065,7 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index, int freed = 0; /* This function is not meant to release cmd queue*/ - if (WARN_ON(txq_id == trans->shrd->cmd_queue)) + if (WARN_ON(txq_id == trans_pcie->cmd_queue)) return 0; lockdep_assert_held(&txq->lock); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 6172651d7e25..8170133d8173 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -78,6 +78,10 @@ #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) +#define SCD_QUEUECHAIN_SEL_ALL(trans, trans_pcie) \ + (((1<base_params->num_of_queues) - 1) &\ + (~(1<<(trans_pcie)->cmd_queue))) + static int iwl_trans_rx_alloc(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = @@ -301,6 +305,7 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans, { size_t tfd_sz = sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX; int i; + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); if (WARN_ON(txq->meta || txq->cmd || txq->skbs || txq->tfds)) return -EINVAL; @@ -313,7 +318,7 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans, if (!txq->meta || !txq->cmd) goto error; - if (txq_id == trans->shrd->cmd_queue) + if (txq_id == trans_pcie->cmd_queue) for (i = 0; i < slots_num; i++) { txq->cmd[i] = kmalloc(sizeof(struct iwl_device_cmd), GFP_KERNEL); @@ -324,7 +329,7 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans, /* Alloc driver data array and TFD circular buffer */ /* Driver private data, only for Tx (not command) queues, * not shared with device. */ - if (txq_id != trans->shrd->cmd_queue) { + if (txq_id != trans_pcie->cmd_queue) { txq->skbs = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(txq->skbs[0]), GFP_KERNEL); if (!txq->skbs) { @@ -352,7 +357,7 @@ static int iwl_trans_txq_alloc(struct iwl_trans *trans, txq->skbs = NULL; /* since txq->cmd has been zeroed, * all non allocated cmd[i] will be NULL */ - if (txq->cmd && txq_id == trans->shrd->cmd_queue) + if (txq->cmd && txq_id == trans_pcie->cmd_queue) for (i = 0; i < slots_num; i++) kfree(txq->cmd[i]); kfree(txq->meta); @@ -418,7 +423,7 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id) /* In the command queue, all the TBs are mapped as BIDI * so unmap them as such. */ - if (txq_id == trans->shrd->cmd_queue) + if (txq_id == trans_pcie->cmd_queue) dma_dir = DMA_BIDIRECTIONAL; else dma_dir = DMA_TO_DEVICE; @@ -454,7 +459,7 @@ static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id) /* De-alloc array of command/tx buffers */ - if (txq_id == trans->shrd->cmd_queue) + if (txq_id == trans_pcie->cmd_queue) for (i = 0; i < txq->q.n_window; i++) kfree(txq->cmd[i]); @@ -551,7 +556,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans) /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { - slots_num = (txq_id == trans->shrd->cmd_queue) ? + slots_num = (txq_id == trans->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; ret = iwl_trans_txq_alloc(trans, &trans_pcie->txq[txq_id], slots_num, txq_id); @@ -596,7 +601,7 @@ static int iwl_tx_init(struct iwl_trans *trans) /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { - slots_num = (txq_id == trans->shrd->cmd_queue) ? + slots_num = (txq_id == trans->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; ret = iwl_trans_txq_init(trans, &trans_pcie->txq[txq_id], slots_num, txq_id); @@ -1130,7 +1135,7 @@ static void iwl_tx_start(struct iwl_trans *trans) reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); iwl_write_prph(trans, SCD_QUEUECHAIN_SEL, - SCD_QUEUECHAIN_SEL_ALL(trans)); + SCD_QUEUECHAIN_SEL_ALL(trans, trans_pcie)); iwl_write_prph(trans, SCD_AGGR_SEL, 0); /* initiate the queues */ @@ -1162,7 +1167,7 @@ static void iwl_tx_start(struct iwl_trans *trans) else queue_to_fifo = iwlagn_default_queue_to_tx_fifo; - iwl_trans_set_wr_ptrs(trans, trans->shrd->cmd_queue, 0); + iwl_trans_set_wr_ptrs(trans, trans_pcie->cmd_queue, 0); /* make sure all queue are not stopped */ memset(&trans_pcie->queue_stopped[0], 0, @@ -1613,6 +1618,14 @@ static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) return readl(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); } +static void iwl_trans_pcie_configure(struct iwl_trans *trans, + const struct iwl_trans_config *trans_cfg) +{ + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + + trans_pcie->cmd_queue = trans_cfg->cmd_queue; +} + static void iwl_trans_pcie_free(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = @@ -1673,7 +1686,7 @@ static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans) /* waiting for all the tx frames complete might take a while */ for (cnt = 0; cnt < hw_params(trans).max_txq_num; cnt++) { - if (cnt == trans->shrd->cmd_queue) + if (cnt == trans->cmd_queue) continue; txq = &trans_pcie->txq[cnt]; q = &txq->q; @@ -2202,6 +2215,7 @@ const struct iwl_trans_ops trans_ops_pcie = { .write8 = iwl_trans_pcie_write8, .write32 = iwl_trans_pcie_write32, .read32 = iwl_trans_pcie_read32, + .configure = iwl_trans_pcie_configure, }; struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index b6fd42779624..a40c2726c190 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -279,9 +279,12 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) * * @op_mode: pointer to the upper layer. * Must be set before any other call. + * @cmd_queue: the index of the command queue. + * Must be set before start_fw. */ struct iwl_trans_config { struct iwl_op_mode *op_mode; + u8 cmd_queue; }; /** @@ -331,6 +334,8 @@ struct iwl_trans_config { * @write8: write a u8 to a register at offset ofs from the BAR * @write32: write a u32 to a register at offset ofs from the BAR * @read32: read a u32 register at offset ofs from the BAR + * @configure: configure parameters required by the transport layer from + * the op_mode. */ struct iwl_trans_ops { @@ -370,6 +375,8 @@ struct iwl_trans_ops { void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); u32 (*read32)(struct iwl_trans *trans, u32 ofs); + void (*configure)(struct iwl_trans *trans, + const struct iwl_trans_config *trans_cfg); }; /** @@ -425,6 +432,8 @@ static inline void iwl_trans_configure(struct iwl_trans *trans, * more */ trans->op_mode = trans_cfg->op_mode; + + trans->ops->configure(trans, trans_cfg); } static inline int iwl_trans_start_hw(struct iwl_trans *trans) -- GitLab From 3dc420be8ce72688bd333afdab6d911e3ceb94e7 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 7 Mar 2012 09:52:41 -0800 Subject: [PATCH 1616/1846] iwlwifi: restore PAN support in iwlwifi: move setting up fw parameters Meenakshi moved code up to configure the transport layer, but this code read the sku before it was set (from the EEPROM). This killed P2P. Only the ucode_flags are needed to configure the transport layer, not the sku which _must_ be set after the EEPROM is read. We need to reconfigure the transport in case the EEPROM disabled PAN support. This is not the nicest thing to do, but we have no choice. Document that we are allowed to configure the transport several times before start_fw, but not after. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 59 ++++++++++++------------ drivers/net/wireless/iwlwifi/iwl-trans.h | 3 +- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 1e6b5e41a72b..28422c03d673 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1206,35 +1206,17 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, /* TODO: remove fw from shared data later */ priv->shrd->fw = fw; - /************************ - * 2. Setup HW constants - ************************/ - iwl_set_hw_params(priv); + /* + * Populate the state variables that the transport layer needs + * to know about. + */ + trans_cfg.op_mode = op_mode; ucode_flags = fw->ucode_capa.flags; #ifndef CONFIG_IWLWIFI_P2P ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; #endif - if (!(hw_params(priv).sku & EEPROM_SKU_CAP_IPAN_ENABLE)) - ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; - - /* - * if not PAN, then don't support P2P -- might be a uCode - * packaging bug or due to the eeprom check above - */ - if (!(ucode_flags & IWL_UCODE_TLV_FLAGS_PAN)) - ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; - - - /***************************** - * Configure transport layer - *****************************/ - /* - * Populate the state variables that the transport layer needs - * to know about. - */ - trans_cfg.op_mode = op_mode; if (ucode_flags & IWL_UCODE_TLV_FLAGS_PAN) { priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; @@ -1277,7 +1259,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, spin_lock_init(&priv->statistics.lock); /*********************** - * 3. Read REV register + * 2. Read REV register ***********************/ IWL_INFO(priv, "Detected %s, REV=0x%X\n", cfg(priv)->name, trans(priv)->hw_rev); @@ -1287,9 +1269,8 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, goto out_free_traffic_mem; /***************** - * 4. Read EEPROM + * 3. Read EEPROM *****************/ - /* Read the EEPROM */ err = iwl_eeprom_init(trans(priv), trans(priv)->hw_rev); /* Reset chip to save power until we load uCode during "up". */ iwl_trans_stop_hw(trans(priv)); @@ -1318,8 +1299,28 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, priv->hw->wiphy->n_addresses++; } + /************************ + * 4. Setup HW constants + ************************/ + iwl_set_hw_params(priv); + + if (!(hw_params(priv).sku & EEPROM_SKU_CAP_IPAN_ENABLE)) { + IWL_DEBUG_INFO(priv, "Your EEPROM disabled PAN"); + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN; + /* + * if not PAN, then don't support P2P -- might be a uCode + * packaging bug or due to the eeprom check above + */ + ucode_flags &= ~IWL_UCODE_TLV_FLAGS_P2P; + priv->sta_key_max_num = STA_KEY_MAX_NUM; + trans_cfg.cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; + + /* Configure transport layer again*/ + iwl_trans_configure(trans(priv), &trans_cfg); + } + /******************* - * 6. Setup priv + * 5. Setup priv *******************/ err = iwl_init_drv(priv); @@ -1328,7 +1329,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, /* At this point both hw and priv are initialized. */ /******************** - * 7. Setup services + * 6. Setup services ********************/ iwl_setup_deferred_work(priv); iwl_setup_rx_handlers(priv); @@ -1355,7 +1356,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, /************************************************** * This is still part of probe() in a sense... * - * 9. Setup and register with mac80211 and debugfs + * 7. Setup and register with mac80211 and debugfs **************************************************/ err = iwlagn_mac_setup_register(priv, &fw->ucode_capa); if (err) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index a40c2726c190..7d1990c7f658 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -335,7 +335,8 @@ struct iwl_trans_config { * @write32: write a u32 to a register at offset ofs from the BAR * @read32: read a u32 register at offset ofs from the BAR * @configure: configure parameters required by the transport layer from - * the op_mode. + * the op_mode. May be called several times before start_fw, can't be + * called after that. */ struct iwl_trans_ops { -- GitLab From 9ba1947a89938ee83e7c16709ee4095ae3e36c44 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 9 Mar 2012 10:12:42 -0800 Subject: [PATCH 1617/1846] iwlwifi: fix cmd_queue number merge iwlwifi: move command queue number out of the iwl_shared struct move the cmd_queue out of iwl_shared struct, but for some reason the patch is half done and fail compile Here is the fix John, could you apply this patch to wireless-next to address the issue Thanks Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-prph.h | 4 ---- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h index a4d11016c3b4..75dc20bd965b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-prph.h +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h @@ -216,10 +216,6 @@ #define SCD_TRANS_TBL_OFFSET_QUEUE(x) \ ((SCD_TRANS_TBL_MEM_LOWER_BOUND + ((x) * 2)) & 0xfffc) -#define SCD_QUEUECHAIN_SEL_ALL(priv) \ - (((1<shrd->cmd_queue))) - #define SCD_BASE (PRPH_BASE + 0xa02c00) #define SCD_SRAM_BASE_ADDR (SCD_BASE + 0x0) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 8170133d8173..a3ac6d814637 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -556,7 +556,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans) /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { - slots_num = (txq_id == trans->cmd_queue) ? + slots_num = (txq_id == trans_pcie->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; ret = iwl_trans_txq_alloc(trans, &trans_pcie->txq[txq_id], slots_num, txq_id); @@ -601,7 +601,7 @@ static int iwl_tx_init(struct iwl_trans *trans) /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { - slots_num = (txq_id == trans->cmd_queue) ? + slots_num = (txq_id == trans_pcie->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; ret = iwl_trans_txq_init(trans, &trans_pcie->txq[txq_id], slots_num, txq_id); @@ -1686,7 +1686,7 @@ static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans) /* waiting for all the tx frames complete might take a while */ for (cnt = 0; cnt < hw_params(trans).max_txq_num; cnt++) { - if (cnt == trans->cmd_queue) + if (cnt == trans_pcie->cmd_queue) continue; txq = &trans_pcie->txq[cnt]; q = &txq->q; -- GitLab From 1745e4405b2c0da6db2ec4b6bc0ad930612d8295 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 9 Mar 2012 11:13:40 -0800 Subject: [PATCH 1618/1846] iwlwifi: fix the delta for remove max_txq_num patch BIg portion of "iwlwifi: remove max_txq_num from hw_params" was missing during merge, here is the fix for it. Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 2 -- drivers/net/wireless/iwlwifi/iwl-2000.c | 2 -- drivers/net/wireless/iwlwifi/iwl-5000.c | 4 --- drivers/net/wireless/iwlwifi/iwl-6000.c | 2 -- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- .../net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 3 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 30 +++++++++++-------- 10 files changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 450250332e4b..5b0d888f746b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -122,8 +122,6 @@ static const struct iwl_sensitivity_ranges iwl1000_sensitivity = { static void iwl1000_hw_set_hw_params(struct iwl_priv *priv) { - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); hw_params(priv).tx_chains_num = diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index abfd901e81a2..5635b9e2c69e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -117,8 +117,6 @@ static const struct iwl_sensitivity_ranges iwl2000_sensitivity = { static void iwl2000_hw_set_hw_params(struct iwl_priv *priv) { - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); hw_params(priv).tx_chains_num = diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 9e187f8f5ae4..a805e97b89af 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -156,8 +156,6 @@ static void iwl5000_set_ct_threshold(struct iwl_priv *priv) static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) { - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); @@ -174,8 +172,6 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) static void iwl5150_hw_set_hw_params(struct iwl_priv *priv) { - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index e64bc6b7bcbf..64060cd738b5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -139,8 +139,6 @@ static const struct iwl_sensitivity_ranges iwl6000_sensitivity = { static void iwl6000_hw_set_hw_params(struct iwl_priv *priv) { - hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues; - hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 9f224548b636..34adedc74d35 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -1159,7 +1159,7 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_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 >= hw_params(priv).max_txq_num) { + if (scd_flow >= cfg(priv)->base_params->num_of_queues) { IWL_ERR(priv, "BUG_ON scd_flow is bigger than number of queues\n"); return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 7a1334e8c358..9b71c87847c2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -828,7 +828,7 @@ static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, char *buf; int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (hw_params(priv).max_txq_num * 32 * 8) + 400; + (cfg(priv)->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 0d957ca3d6c6..cf34087aa2fe 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -160,7 +160,6 @@ struct iwl_mod_params { * * Holds the module parameters * - * @max_txq_num: Max # Tx queues supported * @num_ampdu_queues: num of ampdu queues * @tx_chains_num: Number of TX chains * @rx_chains_num: Number of RX chains @@ -177,7 +176,6 @@ struct iwl_mod_params { * @use_rts_for_aggregation: use rts/cts protection for HT traffic */ struct iwl_hw_params { - u8 max_txq_num; u8 num_ampdu_queues; u8 tx_chains_num; u8 rx_chains_num; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index a5547a155b95..9bc3c73af5e9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -1050,7 +1050,7 @@ void iwl_irq_tasklet(struct iwl_trans *trans) if (inta & CSR_INT_BIT_WAKEUP) { IWL_DEBUG_ISR(trans, "Wakeup interrupt\n"); iwl_rx_queue_update_write_ptr(trans, &trans_pcie->rxq); - for (i = 0; i < hw_params(trans).max_txq_num; i++) + for (i = 0; i < cfg(trans)->base_params->num_of_queues; i++) iwl_txq_update_write_ptr(trans, &trans_pcie->txq[i]); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 2b1df0092aee..565c664f6dce 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -595,7 +595,8 @@ static int iwlagn_txq_ctx_activate_free(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); int txq_id; - for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) + for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; + txq_id++) if (!test_and_set_bit(txq_id, &trans_pcie->txq_ctx_active_msk)) return txq_id; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index a3ac6d814637..91628565409f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -497,7 +497,7 @@ static void iwl_trans_pcie_tx_free(struct iwl_trans *trans) /* Tx queues */ if (trans_pcie->txq) { for (txq_id = 0; - txq_id < hw_params(trans).max_txq_num; txq_id++) + txq_id < cfg(trans)->base_params->num_of_queues; txq_id++) iwl_tx_queue_free(trans, txq_id); } @@ -522,7 +522,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans) int txq_id, slots_num; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - u16 scd_bc_tbls_size = hw_params(trans).max_txq_num * + u16 scd_bc_tbls_size = cfg(trans)->base_params->num_of_queues * sizeof(struct iwlagn_scd_bc_tbl); /*It is not allowed to alloc twice, so warn when this happens. @@ -546,7 +546,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans) goto error; } - trans_pcie->txq = kcalloc(hw_params(trans).max_txq_num, + trans_pcie->txq = kcalloc(cfg(trans)->base_params->num_of_queues, sizeof(struct iwl_tx_queue), GFP_KERNEL); if (!trans_pcie->txq) { IWL_ERR(trans, "Not enough memory for txq\n"); @@ -555,7 +555,8 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans) } /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { + for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; + txq_id++) { slots_num = (txq_id == trans_pcie->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; ret = iwl_trans_txq_alloc(trans, &trans_pcie->txq[txq_id], @@ -600,7 +601,8 @@ static int iwl_tx_init(struct iwl_trans *trans) spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) { + for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; + txq_id++) { slots_num = (txq_id == trans_pcie->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; ret = iwl_trans_txq_init(trans, &trans_pcie->txq[txq_id], @@ -1116,7 +1118,8 @@ static void iwl_tx_start(struct iwl_trans *trans) a += 4) iwl_write_targ_mem(trans, a, 0); for (; a < trans_pcie->scd_base_addr + - SCD_TRANS_TBL_OFFSET_QUEUE(hw_params(trans).max_txq_num); + SCD_TRANS_TBL_OFFSET_QUEUE( + cfg(trans)->base_params->num_of_queues); a += 4) iwl_write_targ_mem(trans, a, 0); @@ -1139,7 +1142,7 @@ static void iwl_tx_start(struct iwl_trans *trans) iwl_write_prph(trans, SCD_AGGR_SEL, 0); /* initiate the queues */ - for (i = 0; i < hw_params(trans).max_txq_num; i++) { + for (i = 0; i < cfg(trans)->base_params->num_of_queues; i++) { iwl_write_prph(trans, SCD_QUEUE_RDPTR(i), 0); iwl_write_direct32(trans, HBUS_TARG_WRPTR, 0 | (i << 8)); iwl_write_targ_mem(trans, trans_pcie->scd_base_addr + @@ -1156,7 +1159,7 @@ static void iwl_tx_start(struct iwl_trans *trans) } iwl_write_prph(trans, SCD_INTERRUPT_MASK, - IWL_MASK(0, hw_params(trans).max_txq_num)); + IWL_MASK(0, cfg(trans)->base_params->num_of_queues)); /* Activate all Tx DMA/FIFO channels */ iwl_trans_txq_set_sched(trans, IWL_MASK(0, 7)); @@ -1246,7 +1249,8 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans) } /* Unmap DMA from host system and free skb's */ - for (txq_id = 0; txq_id < hw_params(trans).max_txq_num; txq_id++) + for (txq_id = 0; txq_id < cfg(trans)->base_params->num_of_queues; + txq_id++) iwl_tx_queue_unmap(trans, txq_id); return 0; @@ -1685,7 +1689,7 @@ static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans) int ret = 0; /* waiting for all the tx frames complete might take a while */ - for (cnt = 0; cnt < hw_params(trans).max_txq_num; cnt++) { + for (cnt = 0; cnt < cfg(trans)->base_params->num_of_queues; cnt++) { if (cnt == trans_pcie->cmd_queue) continue; txq = &trans_pcie->txq[cnt]; @@ -1931,7 +1935,9 @@ static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, int pos = 0; int cnt; int ret; - const size_t bufsz = sizeof(char) * 64 * hw_params(trans).max_txq_num; + size_t bufsz; + + bufsz = sizeof(char) * 64 * cfg(trans)->base_params->num_of_queues; if (!trans_pcie->txq) { IWL_ERR(trans, "txq not ready\n"); @@ -1941,7 +1947,7 @@ static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, if (!buf) return -ENOMEM; - for (cnt = 0; cnt < hw_params(trans).max_txq_num; cnt++) { + for (cnt = 0; cnt < cfg(trans)->base_params->num_of_queues; cnt++) { txq = &trans_pcie->txq[cnt]; q = &txq->q; pos += scnprintf(buf + pos, bufsz - pos, -- GitLab From 863d08ece9bf11043541e8017cfbdd16b800fbe5 Mon Sep 17 00:00:00 2001 From: Takahiro Shimizu Date: Wed, 7 Mar 2012 22:16:26 +0000 Subject: [PATCH 1619/1846] supports eg20t ptp clock Supports EG20T ptp clock in the driver Changes e-mail address. Adds number. Signed-off-by: Takahiro Shimizu Signed-off-by: David S. Miller --- drivers/ptp/Kconfig | 13 + drivers/ptp/Makefile | 1 + drivers/ptp/ptp_pch.c | 730 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 744 insertions(+) create mode 100644 drivers/ptp/ptp_pch.c diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig index 68d720102296..cd9bc3b129bc 100644 --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -72,4 +72,17 @@ config DP83640_PHY In order for this to work, your MAC driver must also implement the skb_tx_timetamp() function. +config PTP_1588_CLOCK_PCH + tristate "Intel PCH EG20T as PTP clock" + depends on PTP_1588_CLOCK + depends on PCH_GBE + help + This driver adds support for using the PCH EG20T as a PTP + clock. This clock is only useful if your PTP programs are + getting hardware time stamps on the PTP Ethernet packets + using the SO_TIMESTAMPING API. + + To compile this driver as a module, choose M here: the module + will be called ptp_pch. + endmenu diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile index f6933e83de72..8b58597298de 100644 --- a/drivers/ptp/Makefile +++ b/drivers/ptp/Makefile @@ -5,3 +5,4 @@ ptp-y := ptp_clock.o ptp_chardev.o ptp_sysfs.o obj-$(CONFIG_PTP_1588_CLOCK) += ptp.o obj-$(CONFIG_PTP_1588_CLOCK_IXP46X) += ptp_ixp46x.o +obj-$(CONFIG_PTP_1588_CLOCK_PCH) += ptp_pch.o diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c new file mode 100644 index 000000000000..0b38ee1b0f85 --- /dev/null +++ b/drivers/ptp/ptp_pch.c @@ -0,0 +1,730 @@ +/* + * PTP 1588 clock using the EG20T PCH + * + * Copyright (C) 2010 OMICRON electronics GmbH + * Copyright (C) 2011-2012 LAPIS SEMICONDUCTOR Co., LTD. + * + * This code was derived from the IXP46X driver. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define STATION_ADDR_LEN 20 +#define PCI_DEVICE_ID_PCH_1588 0x8819 +#define IO_MEM_BAR 1 + +#define DEFAULT_ADDEND 0xA0000000 +#define TICKS_NS_SHIFT 5 +#define N_EXT_TS 2 + +enum pch_status { + PCH_SUCCESS, + PCH_INVALIDPARAM, + PCH_NOTIMESTAMP, + PCH_INTERRUPTMODEINUSE, + PCH_FAILED, + PCH_UNSUPPORTED, +}; +/** + * struct pch_ts_regs - IEEE 1588 registers + */ +struct pch_ts_regs { + u32 control; + u32 event; + u32 addend; + u32 accum; + u32 test; + u32 ts_compare; + u32 rsystime_lo; + u32 rsystime_hi; + u32 systime_lo; + u32 systime_hi; + u32 trgt_lo; + u32 trgt_hi; + u32 asms_lo; + u32 asms_hi; + u32 amms_lo; + u32 amms_hi; + u32 ch_control; + u32 ch_event; + u32 tx_snap_lo; + u32 tx_snap_hi; + u32 rx_snap_lo; + u32 rx_snap_hi; + u32 src_uuid_lo; + u32 src_uuid_hi; + u32 can_status; + u32 can_snap_lo; + u32 can_snap_hi; + u32 ts_sel; + u32 ts_st[6]; + u32 reserve1[14]; + u32 stl_max_set_en; + u32 stl_max_set; + u32 reserve2[13]; + u32 srst; +}; + +#define PCH_TSC_RESET (1 << 0) +#define PCH_TSC_TTM_MASK (1 << 1) +#define PCH_TSC_ASMS_MASK (1 << 2) +#define PCH_TSC_AMMS_MASK (1 << 3) +#define PCH_TSC_PPSM_MASK (1 << 4) +#define PCH_TSE_TTIPEND (1 << 1) +#define PCH_TSE_SNS (1 << 2) +#define PCH_TSE_SNM (1 << 3) +#define PCH_TSE_PPS (1 << 4) +#define PCH_CC_MM (1 << 0) +#define PCH_CC_TA (1 << 1) + +#define PCH_CC_MODE_SHIFT 16 +#define PCH_CC_MODE_MASK 0x001F0000 +#define PCH_CC_VERSION (1 << 31) +#define PCH_CE_TXS (1 << 0) +#define PCH_CE_RXS (1 << 1) +#define PCH_CE_OVR (1 << 0) +#define PCH_CE_VAL (1 << 1) +#define PCH_ECS_ETH (1 << 0) + +#define PCH_ECS_CAN (1 << 1) +#define PCH_STATION_BYTES 6 + +#define PCH_IEEE1588_ETH (1 << 0) +#define PCH_IEEE1588_CAN (1 << 1) +/** + * struct pch_dev - Driver private data + */ +struct pch_dev { + struct pch_ts_regs *regs; + struct ptp_clock *ptp_clock; + struct ptp_clock_info caps; + int exts0_enabled; + int exts1_enabled; + + u32 mem_base; + u32 mem_size; + u32 irq; + struct pci_dev *pdev; + spinlock_t register_lock; +}; + +/** + * struct pch_params - 1588 module parameter + */ +struct pch_params { + u8 station[STATION_ADDR_LEN]; +}; + +/* structure to hold the module parameters */ +static struct pch_params pch_param = { + "00:00:00:00:00:00" +}; + +/* + * Register access functions + */ +static inline void pch_eth_enable_set(struct pch_dev *chip) +{ + u32 val; + /* SET the eth_enable bit */ + val = ioread32(&chip->regs->ts_sel) | (PCH_ECS_ETH); + iowrite32(val, (&chip->regs->ts_sel)); +} + +static u64 pch_systime_read(struct pch_ts_regs *regs) +{ + u64 ns; + u32 lo, hi; + + lo = ioread32(®s->systime_lo); + hi = ioread32(®s->systime_hi); + + ns = ((u64) hi) << 32; + ns |= lo; + ns <<= TICKS_NS_SHIFT; + + return ns; +} + +static void pch_systime_write(struct pch_ts_regs *regs, u64 ns) +{ + u32 hi, lo; + + ns >>= TICKS_NS_SHIFT; + hi = ns >> 32; + lo = ns & 0xffffffff; + + iowrite32(lo, ®s->systime_lo); + iowrite32(hi, ®s->systime_hi); +} + +static inline void pch_block_reset(struct pch_dev *chip) +{ + u32 val; + /* Reset Hardware Assist block */ + val = ioread32(&chip->regs->control) | PCH_TSC_RESET; + iowrite32(val, (&chip->regs->control)); + val = val & ~PCH_TSC_RESET; + iowrite32(val, (&chip->regs->control)); +} + +u32 pch_ch_control_read(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + u32 val; + + val = ioread32(&chip->regs->ch_control); + + return val; +} +EXPORT_SYMBOL(pch_ch_control_read); + +void pch_ch_control_write(struct pci_dev *pdev, u32 val) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + + iowrite32(val, (&chip->regs->ch_control)); +} +EXPORT_SYMBOL(pch_ch_control_write); + +u32 pch_ch_event_read(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + u32 val; + + val = ioread32(&chip->regs->ch_event); + + return val; +} +EXPORT_SYMBOL(pch_ch_event_read); + +void pch_ch_event_write(struct pci_dev *pdev, u32 val) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + + iowrite32(val, (&chip->regs->ch_event)); +} +EXPORT_SYMBOL(pch_ch_event_write); + +u32 pch_src_uuid_lo_read(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + u32 val; + + val = ioread32(&chip->regs->src_uuid_lo); + + return val; +} +EXPORT_SYMBOL(pch_src_uuid_lo_read); + +u32 pch_src_uuid_hi_read(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + u32 val; + + val = ioread32(&chip->regs->src_uuid_hi); + + return val; +} +EXPORT_SYMBOL(pch_src_uuid_hi_read); + +u64 pch_rx_snap_read(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + u64 ns; + u32 lo, hi; + + lo = ioread32(&chip->regs->rx_snap_lo); + hi = ioread32(&chip->regs->rx_snap_hi); + + ns = ((u64) hi) << 32; + ns |= lo; + + return ns; +} +EXPORT_SYMBOL(pch_rx_snap_read); + +u64 pch_tx_snap_read(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + u64 ns; + u32 lo, hi; + + lo = ioread32(&chip->regs->tx_snap_lo); + hi = ioread32(&chip->regs->tx_snap_hi); + + ns = ((u64) hi) << 32; + ns |= lo; + + return ns; +} +EXPORT_SYMBOL(pch_tx_snap_read); + +/* This function enables all 64 bits in system time registers [high & low]. +This is a work-around for non continuous value in the SystemTime Register*/ +static void pch_set_system_time_count(struct pch_dev *chip) +{ + iowrite32(0x01, &chip->regs->stl_max_set_en); + iowrite32(0xFFFFFFFF, &chip->regs->stl_max_set); + iowrite32(0x00, &chip->regs->stl_max_set_en); +} + +static void pch_reset(struct pch_dev *chip) +{ + /* Reset Hardware Assist */ + pch_block_reset(chip); + + /* enable all 32 bits in system time registers */ + pch_set_system_time_count(chip); +} + +/** + * pch_set_station_address() - This API sets the station address used by + * IEEE 1588 hardware when looking at PTP + * traffic on the ethernet interface + * @addr: dress which contain the column separated address to be used. + */ +static int pch_set_station_address(u8 *addr, struct pci_dev *pdev) +{ + s32 i; + struct pch_dev *chip = pci_get_drvdata(pdev); + + /* Verify the parameter */ + if ((chip->regs == 0) || addr == (u8 *)NULL) { + dev_err(&pdev->dev, + "invalid params returning PCH_INVALIDPARAM\n"); + return PCH_INVALIDPARAM; + } + /* For all station address bytes */ + for (i = 0; i < PCH_STATION_BYTES; i++) { + u32 val; + s32 tmp; + + tmp = hex_to_bin(addr[i * 3]); + if (tmp < 0) { + dev_err(&pdev->dev, + "invalid params returning PCH_INVALIDPARAM\n"); + return PCH_INVALIDPARAM; + } + val = tmp * 16; + tmp = hex_to_bin(addr[(i * 3) + 1]); + if (tmp < 0) { + dev_err(&pdev->dev, + "invalid params returning PCH_INVALIDPARAM\n"); + return PCH_INVALIDPARAM; + } + val += tmp; + /* Expects ':' separated addresses */ + if ((i < 5) && (addr[(i * 3) + 2] != ':')) { + dev_err(&pdev->dev, + "invalid params returning PCH_INVALIDPARAM\n"); + return PCH_INVALIDPARAM; + } + + /* Ideally we should set the address only after validating + entire string */ + dev_dbg(&pdev->dev, "invoking pch_station_set\n"); + iowrite32(val, &chip->regs->ts_st[i]); + } + return 0; +} + +/* + * Interrupt service routine + */ +static irqreturn_t isr(int irq, void *priv) +{ + struct pch_dev *pch_dev = priv; + struct pch_ts_regs *regs = pch_dev->regs; + struct ptp_clock_event event; + u32 ack = 0, lo, hi, val; + + val = ioread32(®s->event); + + if (val & PCH_TSE_SNS) { + ack |= PCH_TSE_SNS; + if (pch_dev->exts0_enabled) { + hi = ioread32(®s->asms_hi); + lo = ioread32(®s->asms_lo); + event.type = PTP_CLOCK_EXTTS; + event.index = 0; + event.timestamp = ((u64) hi) << 32; + event.timestamp |= lo; + event.timestamp <<= TICKS_NS_SHIFT; + ptp_clock_event(pch_dev->ptp_clock, &event); + } + } + + if (val & PCH_TSE_SNM) { + ack |= PCH_TSE_SNM; + if (pch_dev->exts1_enabled) { + hi = ioread32(®s->amms_hi); + lo = ioread32(®s->amms_lo); + event.type = PTP_CLOCK_EXTTS; + event.index = 1; + event.timestamp = ((u64) hi) << 32; + event.timestamp |= lo; + event.timestamp <<= TICKS_NS_SHIFT; + ptp_clock_event(pch_dev->ptp_clock, &event); + } + } + + if (val & PCH_TSE_TTIPEND) + ack |= PCH_TSE_TTIPEND; /* this bit seems to be always set */ + + if (ack) { + iowrite32(ack, ®s->event); + return IRQ_HANDLED; + } else + return IRQ_NONE; +} + +/* + * PTP clock operations + */ + +static int ptp_pch_adjfreq(struct ptp_clock_info *ptp, s32 ppb) +{ + u64 adj; + u32 diff, addend; + int neg_adj = 0; + struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps); + struct pch_ts_regs *regs = pch_dev->regs; + + if (ppb < 0) { + neg_adj = 1; + ppb = -ppb; + } + addend = DEFAULT_ADDEND; + adj = addend; + adj *= ppb; + diff = div_u64(adj, 1000000000ULL); + + addend = neg_adj ? addend - diff : addend + diff; + + iowrite32(addend, ®s->addend); + + return 0; +} + +static int ptp_pch_adjtime(struct ptp_clock_info *ptp, s64 delta) +{ + s64 now; + unsigned long flags; + struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps); + struct pch_ts_regs *regs = pch_dev->regs; + + spin_lock_irqsave(&pch_dev->register_lock, flags); + now = pch_systime_read(regs); + now += delta; + pch_systime_write(regs, now); + spin_unlock_irqrestore(&pch_dev->register_lock, flags); + + return 0; +} + +static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec *ts) +{ + u64 ns; + u32 remainder; + unsigned long flags; + struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps); + struct pch_ts_regs *regs = pch_dev->regs; + + spin_lock_irqsave(&pch_dev->register_lock, flags); + ns = pch_systime_read(regs); + spin_unlock_irqrestore(&pch_dev->register_lock, flags); + + ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder); + ts->tv_nsec = remainder; + return 0; +} + +static int ptp_pch_settime(struct ptp_clock_info *ptp, + const struct timespec *ts) +{ + u64 ns; + unsigned long flags; + struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps); + struct pch_ts_regs *regs = pch_dev->regs; + + ns = ts->tv_sec * 1000000000ULL; + ns += ts->tv_nsec; + + spin_lock_irqsave(&pch_dev->register_lock, flags); + pch_systime_write(regs, ns); + spin_unlock_irqrestore(&pch_dev->register_lock, flags); + + return 0; +} + +static int ptp_pch_enable(struct ptp_clock_info *ptp, + struct ptp_clock_request *rq, int on) +{ + struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps); + + switch (rq->type) { + case PTP_CLK_REQ_EXTTS: + switch (rq->extts.index) { + case 0: + pch_dev->exts0_enabled = on ? 1 : 0; + break; + case 1: + pch_dev->exts1_enabled = on ? 1 : 0; + break; + default: + return -EINVAL; + } + return 0; + default: + break; + } + + return -EOPNOTSUPP; +} + +static struct ptp_clock_info ptp_pch_caps = { + .owner = THIS_MODULE, + .name = "PCH timer", + .max_adj = 50000000, + .n_ext_ts = N_EXT_TS, + .pps = 0, + .adjfreq = ptp_pch_adjfreq, + .adjtime = ptp_pch_adjtime, + .gettime = ptp_pch_gettime, + .settime = ptp_pch_settime, + .enable = ptp_pch_enable, +}; + + +#ifdef CONFIG_PM +static s32 pch_suspend(struct pci_dev *pdev, pm_message_t state) +{ + pci_disable_device(pdev); + pci_enable_wake(pdev, PCI_D3hot, 0); + + if (pci_save_state(pdev) != 0) { + dev_err(&pdev->dev, "could not save PCI config state\n"); + return -ENOMEM; + } + pci_set_power_state(pdev, pci_choose_state(pdev, state)); + + return 0; +} + +static s32 pch_resume(struct pci_dev *pdev) +{ + s32 ret; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + ret = pci_enable_device(pdev); + if (ret) { + dev_err(&pdev->dev, "pci_enable_device failed\n"); + return ret; + } + pci_enable_wake(pdev, PCI_D3hot, 0); + return 0; +} +#else +#define pch_suspend NULL +#define pch_resume NULL +#endif + +static void __devexit pch_remove(struct pci_dev *pdev) +{ + struct pch_dev *chip = pci_get_drvdata(pdev); + + ptp_clock_unregister(chip->ptp_clock); + /* free the interrupt */ + if (pdev->irq != 0) + free_irq(pdev->irq, chip); + + /* unmap the virtual IO memory space */ + if (chip->regs != 0) { + iounmap(chip->regs); + chip->regs = 0; + } + /* release the reserved IO memory space */ + if (chip->mem_base != 0) { + release_mem_region(chip->mem_base, chip->mem_size); + chip->mem_base = 0; + } + pci_disable_device(pdev); + kfree(chip); + dev_info(&pdev->dev, "complete\n"); +} + +static s32 __devinit +pch_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + s32 ret; + unsigned long flags; + struct pch_dev *chip; + + chip = kzalloc(sizeof(struct pch_dev), GFP_KERNEL); + if (chip == NULL) + return -ENOMEM; + + /* enable the 1588 pci device */ + ret = pci_enable_device(pdev); + if (ret != 0) { + dev_err(&pdev->dev, "could not enable the pci device\n"); + goto err_pci_en; + } + + chip->mem_base = pci_resource_start(pdev, IO_MEM_BAR); + if (!chip->mem_base) { + dev_err(&pdev->dev, "could not locate IO memory address\n"); + ret = -ENODEV; + goto err_pci_start; + } + + /* retrieve the available length of the IO memory space */ + chip->mem_size = pci_resource_len(pdev, IO_MEM_BAR); + + /* allocate the memory for the device registers */ + if (!request_mem_region(chip->mem_base, chip->mem_size, "1588_regs")) { + dev_err(&pdev->dev, + "could not allocate register memory space\n"); + ret = -EBUSY; + goto err_req_mem_region; + } + + /* get the virtual address to the 1588 registers */ + chip->regs = ioremap(chip->mem_base, chip->mem_size); + + if (!chip->regs) { + dev_err(&pdev->dev, "Could not get virtual address\n"); + ret = -ENOMEM; + goto err_ioremap; + } + + chip->caps = ptp_pch_caps; + chip->ptp_clock = ptp_clock_register(&chip->caps); + + if (IS_ERR(chip->ptp_clock)) + return PTR_ERR(chip->ptp_clock); + + spin_lock_init(&chip->register_lock); + + ret = request_irq(pdev->irq, &isr, IRQF_SHARED, KBUILD_MODNAME, chip); + if (ret != 0) { + dev_err(&pdev->dev, "failed to get irq %d\n", pdev->irq); + goto err_req_irq; + } + + /* indicate success */ + chip->irq = pdev->irq; + chip->pdev = pdev; + pci_set_drvdata(pdev, chip); + + spin_lock_irqsave(&chip->register_lock, flags); + /* reset the ieee1588 h/w */ + pch_reset(chip); + + iowrite32(DEFAULT_ADDEND, &chip->regs->addend); + iowrite32(1, &chip->regs->trgt_lo); + iowrite32(0, &chip->regs->trgt_hi); + iowrite32(PCH_TSE_TTIPEND, &chip->regs->event); + /* Version: IEEE1588 v1 and IEEE1588-2008, Mode: All Evwnt, Locked */ + iowrite32(0x80020000, &chip->regs->ch_control); + + pch_eth_enable_set(chip); + + if (strcmp(pch_param.station, "00:00:00:00:00:00") != 0) { + if (pch_set_station_address(pch_param.station, pdev) != 0) { + dev_err(&pdev->dev, + "Invalid station address parameter\n" + "Module loaded but station address not set correctly\n" + ); + } + } + spin_unlock_irqrestore(&chip->register_lock, flags); + return 0; + +err_req_irq: + ptp_clock_unregister(chip->ptp_clock); + iounmap(chip->regs); + chip->regs = 0; + +err_ioremap: + release_mem_region(chip->mem_base, chip->mem_size); + +err_req_mem_region: + chip->mem_base = 0; + +err_pci_start: + pci_disable_device(pdev); + +err_pci_en: + kfree(chip); + dev_err(&pdev->dev, "probe failed(ret=0x%x)\n", ret); + + return ret; +} + +static DEFINE_PCI_DEVICE_TABLE(pch_ieee1588_pcidev_id) = { + { + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_PCH_1588 + }, + {0} +}; + +static struct pci_driver pch_pcidev = { + .name = KBUILD_MODNAME, + .id_table = pch_ieee1588_pcidev_id, + .probe = pch_probe, + .remove = pch_remove, + .suspend = pch_suspend, + .resume = pch_resume, +}; + +static void __exit ptp_pch_exit(void) +{ + pci_unregister_driver(&pch_pcidev); +} + +static s32 __init ptp_pch_init(void) +{ + s32 ret; + + /* register the driver with the pci core */ + ret = pci_register_driver(&pch_pcidev); + + return ret; +} + +module_init(ptp_pch_init); +module_exit(ptp_pch_exit); + +module_param_string(station, pch_param.station, sizeof pch_param.station, 0444); +MODULE_PARM_DESC(station, + "IEEE 1588 station address to use - column separated hex values"); + +MODULE_AUTHOR("LAPIS SEMICONDUCTOR, "); +MODULE_DESCRIPTION("PTP clock using the EG20T timer"); +MODULE_LICENSE("GPL"); -- GitLab From 1a0bdadb4e36abac63b0a9787f372aac30c11a9e Mon Sep 17 00:00:00 2001 From: Takahiroi Shimizu Date: Wed, 7 Mar 2012 22:16:27 +0000 Subject: [PATCH 1620/1846] net/pch_gbe: supports eg20t ptp clock Supports EG20T ptp clock in the driver Changes e-mail address. Adds number. Signed-off-by: Takahiro Shimizu Signed-off-by: David S. Miller --- drivers/net/ethernet/oki-semi/pch_gbe/Kconfig | 13 ++ .../net/ethernet/oki-semi/pch_gbe/pch_gbe.h | 13 ++ .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 217 +++++++++++++++++- 3 files changed, 240 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig index 00bc4fc968c7..bce01641ee6b 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig +++ b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig @@ -20,3 +20,16 @@ config PCH_GBE purpose use. ML7223/ML7831 is companion chip for Intel Atom E6xx series. ML7223/ML7831 is completely compatible for Intel EG20T PCH. + +if PCH_GBE + +config PCH_PTP + bool "PCH PTP clock support" + default n + depends on PTP_1588_CLOCK_PCH + ---help--- + Say Y here if you want to use Precision Time Protocol (PTP) in the + driver. PTP is a method to precisely synchronize distributed clocks + over Ethernet networks. + +endif # PCH_GBE diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h index a09a07197eb5..dd14915f54bb 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h @@ -630,6 +630,9 @@ struct pch_gbe_adapter { unsigned long tx_queue_len; bool have_msi; bool rx_stop_flag; + int hwts_tx_en; + int hwts_rx_en; + struct pci_dev *ptp_pdev; }; extern const char pch_driver_version[]; @@ -648,6 +651,16 @@ extern void pch_gbe_free_tx_resources(struct pch_gbe_adapter *adapter, extern void pch_gbe_free_rx_resources(struct pch_gbe_adapter *adapter, struct pch_gbe_rx_ring *rx_ring); extern void pch_gbe_update_stats(struct pch_gbe_adapter *adapter); +#ifdef CONFIG_PCH_PTP +extern u32 pch_ch_control_read(struct pci_dev *pdev); +extern void pch_ch_control_write(struct pci_dev *pdev, u32 val); +extern u32 pch_ch_event_read(struct pci_dev *pdev); +extern void pch_ch_event_write(struct pci_dev *pdev, u32 val); +extern u32 pch_src_uuid_lo_read(struct pci_dev *pdev); +extern u32 pch_src_uuid_hi_read(struct pci_dev *pdev); +extern u64 pch_rx_snap_read(struct pci_dev *pdev); +extern u64 pch_tx_snap_read(struct pci_dev *pdev); +#endif /* pch_gbe_param.c */ extern void pch_gbe_check_options(struct pch_gbe_adapter *adapter); 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 69a66545c8ae..8035e5ff6e06 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 @@ -1,6 +1,6 @@ /* * Copyright (C) 1999 - 2010 Intel Corporation. - * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD. + * Copyright (C) 2010 - 2012 LAPIS SEMICONDUCTOR CO., LTD. * * This code was derived from the Intel e1000e Linux driver. * @@ -21,6 +21,10 @@ #include "pch_gbe.h" #include "pch_gbe_api.h" #include +#ifdef CONFIG_PCH_PTP +#include +#include +#endif #define DRV_VERSION "1.00" const char pch_driver_version[] = DRV_VERSION; @@ -95,12 +99,195 @@ const char pch_driver_version[] = DRV_VERSION; #define PCH_GBE_INT_DISABLE_ALL 0 +#ifdef CONFIG_PCH_PTP +/* Macros for ieee1588 */ +#define TICKS_NS_SHIFT 5 + +/* 0x40 Time Synchronization Channel Control Register Bits */ +#define MASTER_MODE (1<<0) +#define SLAVE_MODE (0<<0) +#define V2_MODE (1<<31) +#define CAP_MODE0 (0<<16) +#define CAP_MODE2 (1<<17) + +/* 0x44 Time Synchronization Channel Event Register Bits */ +#define TX_SNAPSHOT_LOCKED (1<<0) +#define RX_SNAPSHOT_LOCKED (1<<1) +#endif + static unsigned int copybreak __read_mostly = PCH_GBE_COPYBREAK_DEFAULT; static int pch_gbe_mdio_read(struct net_device *netdev, int addr, int reg); static void pch_gbe_mdio_write(struct net_device *netdev, int addr, int reg, int data); +#ifdef CONFIG_PCH_PTP +static struct sock_filter ptp_filter[] = { + PTP_FILTER +}; + +static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid) +{ + u8 *data = skb->data; + unsigned int offset; + u16 *hi, *id; + u32 lo; + + if ((sk_run_filter(skb, ptp_filter) != PTP_CLASS_V2_IPV4) && + (sk_run_filter(skb, ptp_filter) != PTP_CLASS_V1_IPV4)) { + return 0; + } + + offset = ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; + + if (skb->len < offset + OFF_PTP_SEQUENCE_ID + sizeof(seqid)) + return 0; + + hi = (u16 *)(data + offset + OFF_PTP_SOURCE_UUID); + id = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID); + + memcpy(&lo, &hi[1], sizeof(lo)); + + return (uid_hi == *hi && + uid_lo == lo && + seqid == *id); +} + +static void pch_rx_timestamp( + struct pch_gbe_adapter *adapter, struct sk_buff *skb) +{ + struct skb_shared_hwtstamps *shhwtstamps; + struct pci_dev *pdev; + u64 ns; + u32 hi, lo, val; + u16 uid, seq; + + if (!adapter->hwts_rx_en) + return; + + /* Get ieee1588's dev information */ + pdev = adapter->ptp_pdev; + + val = pch_ch_event_read(pdev); + + if (!(val & RX_SNAPSHOT_LOCKED)) + return; + + lo = pch_src_uuid_lo_read(pdev); + hi = pch_src_uuid_hi_read(pdev); + + uid = hi & 0xffff; + seq = (hi >> 16) & 0xffff; + + if (!pch_ptp_match(skb, htons(uid), htonl(lo), htons(seq))) + goto out; + + ns = pch_rx_snap_read(pdev); + ns <<= TICKS_NS_SHIFT; + + shhwtstamps = skb_hwtstamps(skb); + memset(shhwtstamps, 0, sizeof(*shhwtstamps)); + shhwtstamps->hwtstamp = ns_to_ktime(ns); +out: + pch_ch_event_write(pdev, RX_SNAPSHOT_LOCKED); +} + +static void pch_tx_timestamp( + struct pch_gbe_adapter *adapter, struct sk_buff *skb) +{ + struct skb_shared_hwtstamps shhwtstamps; + struct pci_dev *pdev; + struct skb_shared_info *shtx; + u64 ns; + u32 cnt, val; + + shtx = skb_shinfo(skb); + if (unlikely(shtx->tx_flags & SKBTX_HW_TSTAMP && adapter->hwts_tx_en)) + shtx->tx_flags |= SKBTX_IN_PROGRESS; + else + return; + + /* Get ieee1588's dev information */ + pdev = adapter->ptp_pdev; + + /* + * This really stinks, but we have to poll for the Tx time stamp. + * Usually, the time stamp is ready after 4 to 6 microseconds. + */ + for (cnt = 0; cnt < 100; cnt++) { + val = pch_ch_event_read(pdev); + if (val & TX_SNAPSHOT_LOCKED) + break; + udelay(1); + } + if (!(val & TX_SNAPSHOT_LOCKED)) { + shtx->tx_flags &= ~SKBTX_IN_PROGRESS; + return; + } + + ns = pch_tx_snap_read(pdev); + ns <<= TICKS_NS_SHIFT; + + memset(&shhwtstamps, 0, sizeof(shhwtstamps)); + shhwtstamps.hwtstamp = ns_to_ktime(ns); + skb_tstamp_tx(skb, &shhwtstamps); + + pch_ch_event_write(pdev, TX_SNAPSHOT_LOCKED); +} + +static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) +{ + struct hwtstamp_config cfg; + struct pch_gbe_adapter *adapter = netdev_priv(netdev); + struct pci_dev *pdev; + + if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) + return -EFAULT; + + if (cfg.flags) /* reserved for future extensions */ + return -EINVAL; + + /* Get ieee1588's dev information */ + pdev = adapter->ptp_pdev; + + switch (cfg.tx_type) { + case HWTSTAMP_TX_OFF: + adapter->hwts_tx_en = 0; + break; + case HWTSTAMP_TX_ON: + adapter->hwts_tx_en = 1; + break; + default: + return -ERANGE; + } + + switch (cfg.rx_filter) { + case HWTSTAMP_FILTER_NONE: + adapter->hwts_rx_en = 0; + break; + case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: + adapter->hwts_rx_en = 0; + pch_ch_control_write(pdev, (SLAVE_MODE | CAP_MODE0)); + break; + case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: + adapter->hwts_rx_en = 1; + pch_ch_control_write(pdev, (MASTER_MODE | CAP_MODE0)); + break; + case HWTSTAMP_FILTER_PTP_V2_EVENT: + adapter->hwts_rx_en = 1; + pch_ch_control_write(pdev, (V2_MODE | CAP_MODE2)); + break; + default: + return -ERANGE; + } + + /* Clear out any old time stamps. */ + pch_ch_event_write(pdev, TX_SNAPSHOT_LOCKED | RX_SNAPSHOT_LOCKED); + + return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; +} +#endif + inline void pch_gbe_mac_load_mac_addr(struct pch_gbe_hw *hw) { iowrite32(0x01, &hw->reg->MAC_ADDR_LOAD); @@ -1072,6 +1259,11 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter, iowrite32(tx_ring->dma + (int)sizeof(struct pch_gbe_tx_desc) * ring_num, &hw->reg->TX_DSC_SW_P); + +#ifdef CONFIG_PCH_PTP + pch_tx_timestamp(adapter, skb); +#endif + dev_kfree_skb_any(skb); } @@ -1543,6 +1735,11 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, adapter->stats.multicast++; /* Write meta date of skb */ skb_put(skb, length); + +#ifdef CONFIG_PCH_PTP + pch_rx_timestamp(adapter, skb); +#endif + skb->protocol = eth_type_trans(skb, netdev); if (tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK) skb->ip_summed = CHECKSUM_NONE; @@ -2144,6 +2341,11 @@ static int pch_gbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) pr_debug("cmd : 0x%04x\n", cmd); +#ifdef CONFIG_PCH_PTP + if (cmd == SIOCSHWTSTAMP) + return hwtstamp_ioctl(netdev, ifr, cmd); +#endif + return generic_mii_ioctl(&adapter->mii, if_mii(ifr), cmd, NULL); } @@ -2435,6 +2637,15 @@ static int pch_gbe_probe(struct pci_dev *pdev, goto err_free_netdev; } +#ifdef CONFIG_PCH_PTP + adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number, + PCI_DEVFN(12, 4)); + if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter))) { + pr_err("Bad ptp filter\n"); + return -EINVAL; + } +#endif + netdev->netdev_ops = &pch_gbe_netdev_ops; netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD; netif_napi_add(netdev, &adapter->napi, @@ -2499,7 +2710,7 @@ static int pch_gbe_probe(struct pci_dev *pdev, netif_carrier_off(netdev); netif_stop_queue(netdev); - dev_dbg(&pdev->dev, "OKIsemi(R) PCH Network Connection\n"); + dev_dbg(&pdev->dev, "PCH Network Connection\n"); device_set_wakeup_enable(&pdev->dev, 1); return 0; @@ -2600,7 +2811,7 @@ module_init(pch_gbe_init_module); module_exit(pch_gbe_exit_module); MODULE_DESCRIPTION("EG20T PCH Gigabit ethernet Driver"); -MODULE_AUTHOR("OKI SEMICONDUCTOR, "); +MODULE_AUTHOR("LAPIS SEMICONDUCTOR, "); MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_VERSION); MODULE_DEVICE_TABLE(pci, pch_gbe_pcidev_id); -- GitLab From ba57b4db2624793c6eb8f2c051c9f7b8a6e7b6a6 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 7 Mar 2012 20:45:32 -0500 Subject: [PATCH 1621/1846] ipv4: Make ip_call_ra_chain() return bool. Signed-off-by: David S. Miller --- include/net/ip.h | 2 +- net/ipv4/ip_input.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 775009f9eaba..b53d65f24f7b 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -388,7 +388,7 @@ static inline int sk_mc_loop(struct sock *sk) return 1; } -extern int ip_call_ra_chain(struct sk_buff *skb); +extern bool ip_call_ra_chain(struct sk_buff *skb); /* * Functions provided by ip_fragment.c diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 073a9b01c40c..70afe5bf1945 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -148,7 +148,7 @@ /* * Process Router Attention IP option (RFC 2113) */ -int ip_call_ra_chain(struct sk_buff *skb) +bool ip_call_ra_chain(struct sk_buff *skb) { struct ip_ra_chain *ra; u8 protocol = ip_hdr(skb)->protocol; @@ -167,7 +167,7 @@ int ip_call_ra_chain(struct sk_buff *skb) net_eq(sock_net(sk), dev_net(dev))) { if (ip_is_fragment(ip_hdr(skb))) { if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) - return 1; + return true; } if (last) { struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); @@ -180,9 +180,9 @@ int ip_call_ra_chain(struct sk_buff *skb) if (last) { raw_rcv(last, skb); - return 1; + return true; } - return 0; + return false; } static int ip_local_deliver_finish(struct sk_buff *skb) -- GitLab From 6a91395f20119d696330e2604451614a64369d1b Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 7 Mar 2012 20:48:08 -0500 Subject: [PATCH 1622/1846] ipv4: Make ip_rcv_options() return bool. Signed-off-by: David S. Miller --- net/ipv4/ip_input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 70afe5bf1945..bdaa2c5c28e4 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -265,7 +265,7 @@ int ip_local_deliver(struct sk_buff *skb) ip_local_deliver_finish); } -static inline int ip_rcv_options(struct sk_buff *skb) +static inline bool ip_rcv_options(struct sk_buff *skb) { struct ip_options *opt; const struct iphdr *iph; @@ -309,9 +309,9 @@ static inline int ip_rcv_options(struct sk_buff *skb) goto drop; } - return 0; + return false; drop: - return -1; + return true; } static int ip_rcv_finish(struct sk_buff *skb) -- GitLab From bdcc0924c8c6e6362bb93b6120631f257aac6f87 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 7 Mar 2012 20:53:36 -0500 Subject: [PATCH 1623/1846] net: Use bool in skbuff.h helper functions. In particular do this for skb_is_nonlinear(), skb_is_gso(), and skb_is_gso_v6(). Signed-off-by: David S. Miller --- include/linux/skbuff.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 79ef8209bbb7..8dc8257eab8b 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1173,7 +1173,7 @@ static inline struct sk_buff *__skb_dequeue_tail(struct sk_buff_head *list) } -static inline int skb_is_nonlinear(const struct sk_buff *skb) +static inline bool skb_is_nonlinear(const struct sk_buff *skb) { return skb->data_len; } @@ -2469,12 +2469,12 @@ static inline struct sec_path *skb_sec_path(struct sk_buff *skb) } #endif -static inline int skb_is_gso(const struct sk_buff *skb) +static inline bool skb_is_gso(const struct sk_buff *skb) { return skb_shinfo(skb)->gso_size; } -static inline int skb_is_gso_v6(const struct sk_buff *skb) +static inline bool skb_is_gso_v6(const struct sk_buff *skb) { return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; } -- GitLab From 4d29515f5a2e062c3fe82bfb574da70ed544ffad Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 7 Mar 2012 21:02:35 -0500 Subject: [PATCH 1624/1846] net: Use bool in netdevice.h helpers. Specifically use it in napi_disable_pending(), napi_schedule_prep(), napi_reschedule(), netif_tx_queue_stopped(), netif_queue_stopped(), netif_xmit_stopped(), netif_xmit_frozen_or_stopped(), netif_running(), __netif_subqueue_stopped(), netif_subqueue_stopped(), netif_is_multiquue(), netif_carrier_ok(), netif_dormant(), netif_oper_up(), netif_device_present(), __netif_tx_trylock(), net_gso_ok(), skb_gso_ok(), netif_needs_gso(), and netif_is_bond_slave(). Signed-off-by: David S. Miller --- include/linux/netdevice.h | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a89933bc4f2f..b195a34440bb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -417,7 +417,7 @@ typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); extern void __napi_schedule(struct napi_struct *n); -static inline int napi_disable_pending(struct napi_struct *n) +static inline bool napi_disable_pending(struct napi_struct *n) { return test_bit(NAPI_STATE_DISABLE, &n->state); } @@ -431,7 +431,7 @@ static inline int napi_disable_pending(struct napi_struct *n) * insure only one NAPI poll instance runs. We also make * sure there is no pending NAPI disable. */ -static inline int napi_schedule_prep(struct napi_struct *n) +static inline bool napi_schedule_prep(struct napi_struct *n) { return !napi_disable_pending(n) && !test_and_set_bit(NAPI_STATE_SCHED, &n->state); @@ -451,13 +451,13 @@ static inline void napi_schedule(struct napi_struct *n) } /* Try to reschedule poll. Called by dev->poll() after napi_complete(). */ -static inline int napi_reschedule(struct napi_struct *napi) +static inline bool napi_reschedule(struct napi_struct *napi) { if (napi_schedule_prep(napi)) { __napi_schedule(napi); - return 1; + return true; } - return 0; + return false; } /** @@ -1868,7 +1868,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev) } } -static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) +static inline bool netif_tx_queue_stopped(const struct netdev_queue *dev_queue) { return test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state); } @@ -1879,17 +1879,17 @@ static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) * * Test if transmit queue on device is currently unable to send. */ -static inline int netif_queue_stopped(const struct net_device *dev) +static inline bool netif_queue_stopped(const struct net_device *dev) { return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); } -static inline int netif_xmit_stopped(const struct netdev_queue *dev_queue) +static inline bool netif_xmit_stopped(const struct netdev_queue *dev_queue) { return dev_queue->state & QUEUE_STATE_ANY_XOFF; } -static inline int netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue) +static inline bool netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue) { return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN; } @@ -1954,7 +1954,7 @@ static inline void netdev_reset_queue(struct net_device *dev_queue) * * Test if the device has been brought up. */ -static inline int netif_running(const struct net_device *dev) +static inline bool netif_running(const struct net_device *dev) { return test_bit(__LINK_STATE_START, &dev->state); } @@ -2004,16 +2004,16 @@ static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index) * * Check individual transmit queue of a device with multiple transmit queues. */ -static inline int __netif_subqueue_stopped(const struct net_device *dev, - u16 queue_index) +static inline bool __netif_subqueue_stopped(const struct net_device *dev, + u16 queue_index) { struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index); return netif_tx_queue_stopped(txq); } -static inline int netif_subqueue_stopped(const struct net_device *dev, - struct sk_buff *skb) +static inline bool netif_subqueue_stopped(const struct net_device *dev, + struct sk_buff *skb) { return __netif_subqueue_stopped(dev, skb_get_queue_mapping(skb)); } @@ -2052,7 +2052,7 @@ static inline u16 skb_tx_hash(const struct net_device *dev, * * Check if device has multiple transmit queues */ -static inline int netif_is_multiqueue(const struct net_device *dev) +static inline bool netif_is_multiqueue(const struct net_device *dev) { return dev->num_tx_queues > 1; } @@ -2188,7 +2188,7 @@ extern void linkwatch_forget_dev(struct net_device *dev); * * Check if carrier is present on device */ -static inline int netif_carrier_ok(const struct net_device *dev) +static inline bool netif_carrier_ok(const struct net_device *dev) { return !test_bit(__LINK_STATE_NOCARRIER, &dev->state); } @@ -2240,7 +2240,7 @@ static inline void netif_dormant_off(struct net_device *dev) * * Check if carrier is present on device */ -static inline int netif_dormant(const struct net_device *dev) +static inline bool netif_dormant(const struct net_device *dev) { return test_bit(__LINK_STATE_DORMANT, &dev->state); } @@ -2252,7 +2252,7 @@ static inline int netif_dormant(const struct net_device *dev) * * Check if carrier is operational */ -static inline int netif_oper_up(const struct net_device *dev) +static inline bool netif_oper_up(const struct net_device *dev) { return (dev->operstate == IF_OPER_UP || dev->operstate == IF_OPER_UNKNOWN /* backward compat */); @@ -2264,7 +2264,7 @@ static inline int netif_oper_up(const struct net_device *dev) * * Check if device has not been removed from system. */ -static inline int netif_device_present(struct net_device *dev) +static inline bool netif_device_present(struct net_device *dev) { return test_bit(__LINK_STATE_PRESENT, &dev->state); } @@ -2334,9 +2334,9 @@ static inline void __netif_tx_lock_bh(struct netdev_queue *txq) txq->xmit_lock_owner = smp_processor_id(); } -static inline int __netif_tx_trylock(struct netdev_queue *txq) +static inline bool __netif_tx_trylock(struct netdev_queue *txq) { - int ok = spin_trylock(&txq->_xmit_lock); + bool ok = spin_trylock(&txq->_xmit_lock); if (likely(ok)) txq->xmit_lock_owner = smp_processor_id(); return ok; @@ -2614,7 +2614,7 @@ void netif_stacked_transfer_operstate(const struct net_device *rootdev, netdev_features_t netif_skb_features(struct sk_buff *skb); -static inline int net_gso_ok(netdev_features_t features, int gso_type) +static inline bool net_gso_ok(netdev_features_t features, int gso_type) { netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT; @@ -2629,14 +2629,14 @@ static inline int net_gso_ok(netdev_features_t features, int gso_type) return (features & feature) == feature; } -static inline int skb_gso_ok(struct sk_buff *skb, netdev_features_t features) +static inline bool skb_gso_ok(struct sk_buff *skb, netdev_features_t features) { return net_gso_ok(features, skb_shinfo(skb)->gso_type) && (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST)); } -static inline int netif_needs_gso(struct sk_buff *skb, - netdev_features_t features) +static inline bool netif_needs_gso(struct sk_buff *skb, + netdev_features_t features) { return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); @@ -2648,7 +2648,7 @@ static inline void netif_set_gso_max_size(struct net_device *dev, dev->gso_max_size = size; } -static inline int netif_is_bond_slave(struct net_device *dev) +static inline bool netif_is_bond_slave(struct net_device *dev) { return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING; } -- GitLab From d8d789497aa016f802b95606c6473e92361ec0b5 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 9 Mar 2012 14:47:24 -0800 Subject: [PATCH 1625/1846] ptp_pch: rename pch_pcidev to pci_driver to fix section mismatch warnings. Signed-off-by: David S. Miller --- drivers/ptp/ptp_pch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c index 0b38ee1b0f85..375eb04c16ea 100644 --- a/drivers/ptp/ptp_pch.c +++ b/drivers/ptp/ptp_pch.c @@ -694,7 +694,7 @@ static DEFINE_PCI_DEVICE_TABLE(pch_ieee1588_pcidev_id) = { {0} }; -static struct pci_driver pch_pcidev = { +static struct pci_driver pch_driver = { .name = KBUILD_MODNAME, .id_table = pch_ieee1588_pcidev_id, .probe = pch_probe, @@ -705,7 +705,7 @@ static struct pci_driver pch_pcidev = { static void __exit ptp_pch_exit(void) { - pci_unregister_driver(&pch_pcidev); + pci_unregister_driver(&pch_driver); } static s32 __init ptp_pch_init(void) @@ -713,7 +713,7 @@ static s32 __init ptp_pch_init(void) s32 ret; /* register the driver with the pci core */ - ret = pci_register_driver(&pch_pcidev); + ret = pci_register_driver(&pch_driver); return ret; } -- GitLab From a320757ab86c1a2a38bff84d33e3ef7dbf489428 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 9 Mar 2012 23:41:26 -0500 Subject: [PATCH 1626/1846] net: powerpc: remove the legacy iSeries ethernet driver This driver is specific to the PowerPC legcay iSeries platform which is being removed. Cc: David Miller Cc: Signed-off-by: Stephen Rothwell Acked-by: David S. Miller Signed-off-by: Benjamin Herrenschmidt --- drivers/net/ethernet/ibm/Kconfig | 4 - drivers/net/ethernet/ibm/Makefile | 1 - drivers/net/ethernet/ibm/iseries_veth.c | 1708 ----------------------- 3 files changed, 1713 deletions(-) delete mode 100644 drivers/net/ethernet/ibm/iseries_veth.c diff --git a/drivers/net/ethernet/ibm/Kconfig b/drivers/net/ethernet/ibm/Kconfig index 9e16f3fa97b2..b9773d229192 100644 --- a/drivers/net/ethernet/ibm/Kconfig +++ b/drivers/net/ethernet/ibm/Kconfig @@ -29,10 +29,6 @@ config IBMVETH To compile this driver as a module, choose M here. The module will be called ibmveth. -config ISERIES_VETH - tristate "iSeries Virtual Ethernet driver support" - depends on PPC_ISERIES - source "drivers/net/ethernet/ibm/emac/Kconfig" config EHEA diff --git a/drivers/net/ethernet/ibm/Makefile b/drivers/net/ethernet/ibm/Makefile index 5a7d4e9ac803..2f04e71a5926 100644 --- a/drivers/net/ethernet/ibm/Makefile +++ b/drivers/net/ethernet/ibm/Makefile @@ -3,6 +3,5 @@ # obj-$(CONFIG_IBMVETH) += ibmveth.o -obj-$(CONFIG_ISERIES_VETH) += iseries_veth.o obj-$(CONFIG_IBM_EMAC) += emac/ obj-$(CONFIG_EHEA) += ehea/ diff --git a/drivers/net/ethernet/ibm/iseries_veth.c b/drivers/net/ethernet/ibm/iseries_veth.c deleted file mode 100644 index 1cafa6562a06..000000000000 --- a/drivers/net/ethernet/ibm/iseries_veth.c +++ /dev/null @@ -1,1708 +0,0 @@ -/* File veth.c created by Kyle A. Lucke on Mon Aug 7 2000. */ -/* - * IBM eServer iSeries Virtual Ethernet Device Driver - * Copyright (C) 2001 Kyle A. Lucke (klucke@us.ibm.com), IBM Corp. - * Substantially cleaned up by: - * Copyright (C) 2003 David Gibson , IBM Corporation. - * Copyright (C) 2004-2005 Michael Ellerman, IBM Corporation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - * - * - * This module implements the virtual ethernet device for iSeries LPAR - * Linux. It uses hypervisor message passing to implement an - * ethernet-like network device communicating between partitions on - * the iSeries. - * - * The iSeries LPAR hypervisor currently allows for up to 16 different - * virtual ethernets. These are all dynamically configurable on - * OS/400 partitions, but dynamic configuration is not supported under - * Linux yet. An ethXX network device will be created for each - * virtual ethernet this partition is connected to. - * - * - This driver is responsible for routing packets to and from other - * partitions. The MAC addresses used by the virtual ethernets - * contains meaning and must not be modified. - * - * - Having 2 virtual ethernets to the same remote partition DOES NOT - * double the available bandwidth. The 2 devices will share the - * available hypervisor bandwidth. - * - * - If you send a packet to your own mac address, it will just be - * dropped, you won't get it on the receive side. - * - * - Multicast is implemented by sending the frame frame to every - * other partition. It is the responsibility of the receiving - * partition to filter the addresses desired. - * - * Tunable parameters: - * - * VETH_NUMBUFFERS: This compile time option defaults to 120. It - * controls how much memory Linux will allocate per remote partition - * it is communicating with. It can be thought of as the maximum - * number of packets outstanding to a remote partition at a time. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef DEBUG - -MODULE_AUTHOR("Kyle Lucke "); -MODULE_DESCRIPTION("iSeries Virtual ethernet driver"); -MODULE_LICENSE("GPL"); - -#define VETH_EVENT_CAP (0) -#define VETH_EVENT_FRAMES (1) -#define VETH_EVENT_MONITOR (2) -#define VETH_EVENT_FRAMES_ACK (3) - -#define VETH_MAX_ACKS_PER_MSG (20) -#define VETH_MAX_FRAMES_PER_MSG (6) - -struct veth_frames_data { - u32 addr[VETH_MAX_FRAMES_PER_MSG]; - u16 len[VETH_MAX_FRAMES_PER_MSG]; - u32 eofmask; -}; -#define VETH_EOF_SHIFT (32-VETH_MAX_FRAMES_PER_MSG) - -struct veth_frames_ack_data { - u16 token[VETH_MAX_ACKS_PER_MSG]; -}; - -struct veth_cap_data { - u8 caps_version; - u8 rsvd1; - u16 num_buffers; - u16 ack_threshold; - u16 rsvd2; - u32 ack_timeout; - u32 rsvd3; - u64 rsvd4[3]; -}; - -struct veth_lpevent { - struct HvLpEvent base_event; - union { - struct veth_cap_data caps_data; - struct veth_frames_data frames_data; - struct veth_frames_ack_data frames_ack_data; - } u; - -}; - -#define DRV_NAME "iseries_veth" -#define DRV_VERSION "2.0" - -#define VETH_NUMBUFFERS (120) -#define VETH_ACKTIMEOUT (1000000) /* microseconds */ -#define VETH_MAX_MCAST (12) - -#define VETH_MAX_MTU (9000) - -#if VETH_NUMBUFFERS < 10 -#define ACK_THRESHOLD (1) -#elif VETH_NUMBUFFERS < 20 -#define ACK_THRESHOLD (4) -#elif VETH_NUMBUFFERS < 40 -#define ACK_THRESHOLD (10) -#else -#define ACK_THRESHOLD (20) -#endif - -#define VETH_STATE_SHUTDOWN (0x0001) -#define VETH_STATE_OPEN (0x0002) -#define VETH_STATE_RESET (0x0004) -#define VETH_STATE_SENTMON (0x0008) -#define VETH_STATE_SENTCAPS (0x0010) -#define VETH_STATE_GOTCAPACK (0x0020) -#define VETH_STATE_GOTCAPS (0x0040) -#define VETH_STATE_SENTCAPACK (0x0080) -#define VETH_STATE_READY (0x0100) - -struct veth_msg { - struct veth_msg *next; - struct veth_frames_data data; - int token; - int in_use; - struct sk_buff *skb; - struct device *dev; -}; - -struct veth_lpar_connection { - HvLpIndex remote_lp; - struct delayed_work statemachine_wq; - struct veth_msg *msgs; - int num_events; - struct veth_cap_data local_caps; - - struct kobject kobject; - struct timer_list ack_timer; - - struct timer_list reset_timer; - unsigned int reset_timeout; - unsigned long last_contact; - int outstanding_tx; - - spinlock_t lock; - unsigned long state; - HvLpInstanceId src_inst; - HvLpInstanceId dst_inst; - struct veth_lpevent cap_event, cap_ack_event; - u16 pending_acks[VETH_MAX_ACKS_PER_MSG]; - u32 num_pending_acks; - - int num_ack_events; - struct veth_cap_data remote_caps; - u32 ack_timeout; - - struct veth_msg *msg_stack_head; -}; - -struct veth_port { - struct device *dev; - u64 mac_addr; - HvLpIndexMap lpar_map; - - /* queue_lock protects the stopped_map and dev's queue. */ - spinlock_t queue_lock; - HvLpIndexMap stopped_map; - - /* mcast_gate protects promiscuous, num_mcast & mcast_addr. */ - rwlock_t mcast_gate; - int promiscuous; - int num_mcast; - u64 mcast_addr[VETH_MAX_MCAST]; - - struct kobject kobject; -}; - -static HvLpIndex this_lp; -static struct veth_lpar_connection *veth_cnx[HVMAXARCHITECTEDLPS]; /* = 0 */ -static struct net_device *veth_dev[HVMAXARCHITECTEDVIRTUALLANS]; /* = 0 */ - -static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev); -static void veth_recycle_msg(struct veth_lpar_connection *, struct veth_msg *); -static void veth_wake_queues(struct veth_lpar_connection *cnx); -static void veth_stop_queues(struct veth_lpar_connection *cnx); -static void veth_receive(struct veth_lpar_connection *, struct veth_lpevent *); -static void veth_release_connection(struct kobject *kobject); -static void veth_timed_ack(unsigned long ptr); -static void veth_timed_reset(unsigned long ptr); - -/* - * Utility functions - */ - -#define veth_info(fmt, args...) \ - printk(KERN_INFO DRV_NAME ": " fmt, ## args) - -#define veth_error(fmt, args...) \ - printk(KERN_ERR DRV_NAME ": Error: " fmt, ## args) - -#ifdef DEBUG -#define veth_debug(fmt, args...) \ - printk(KERN_DEBUG DRV_NAME ": " fmt, ## args) -#else -#define veth_debug(fmt, args...) do {} while (0) -#endif - -/* You must hold the connection's lock when you call this function. */ -static inline void veth_stack_push(struct veth_lpar_connection *cnx, - struct veth_msg *msg) -{ - msg->next = cnx->msg_stack_head; - cnx->msg_stack_head = msg; -} - -/* You must hold the connection's lock when you call this function. */ -static inline struct veth_msg *veth_stack_pop(struct veth_lpar_connection *cnx) -{ - struct veth_msg *msg; - - msg = cnx->msg_stack_head; - if (msg) - cnx->msg_stack_head = cnx->msg_stack_head->next; - - return msg; -} - -/* You must hold the connection's lock when you call this function. */ -static inline int veth_stack_is_empty(struct veth_lpar_connection *cnx) -{ - return cnx->msg_stack_head == NULL; -} - -static inline HvLpEvent_Rc -veth_signalevent(struct veth_lpar_connection *cnx, u16 subtype, - HvLpEvent_AckInd ackind, HvLpEvent_AckType acktype, - u64 token, - u64 data1, u64 data2, u64 data3, u64 data4, u64 data5) -{ - return HvCallEvent_signalLpEventFast(cnx->remote_lp, - HvLpEvent_Type_VirtualLan, - subtype, ackind, acktype, - cnx->src_inst, - cnx->dst_inst, - token, data1, data2, data3, - data4, data5); -} - -static inline HvLpEvent_Rc veth_signaldata(struct veth_lpar_connection *cnx, - u16 subtype, u64 token, void *data) -{ - u64 *p = (u64 *) data; - - return veth_signalevent(cnx, subtype, HvLpEvent_AckInd_NoAck, - HvLpEvent_AckType_ImmediateAck, - token, p[0], p[1], p[2], p[3], p[4]); -} - -struct veth_allocation { - struct completion c; - int num; -}; - -static void veth_complete_allocation(void *parm, int number) -{ - struct veth_allocation *vc = (struct veth_allocation *)parm; - - vc->num = number; - complete(&vc->c); -} - -static int veth_allocate_events(HvLpIndex rlp, int number) -{ - struct veth_allocation vc = - { COMPLETION_INITIALIZER_ONSTACK(vc.c), 0 }; - - mf_allocate_lp_events(rlp, HvLpEvent_Type_VirtualLan, - sizeof(struct veth_lpevent), number, - &veth_complete_allocation, &vc); - wait_for_completion(&vc.c); - - return vc.num; -} - -/* - * sysfs support - */ - -struct veth_cnx_attribute { - struct attribute attr; - ssize_t (*show)(struct veth_lpar_connection *, char *buf); - ssize_t (*store)(struct veth_lpar_connection *, const char *buf); -}; - -static ssize_t veth_cnx_attribute_show(struct kobject *kobj, - struct attribute *attr, char *buf) -{ - struct veth_cnx_attribute *cnx_attr; - struct veth_lpar_connection *cnx; - - cnx_attr = container_of(attr, struct veth_cnx_attribute, attr); - cnx = container_of(kobj, struct veth_lpar_connection, kobject); - - if (!cnx_attr->show) - return -EIO; - - return cnx_attr->show(cnx, buf); -} - -#define CUSTOM_CNX_ATTR(_name, _format, _expression) \ -static ssize_t _name##_show(struct veth_lpar_connection *cnx, char *buf)\ -{ \ - return sprintf(buf, _format, _expression); \ -} \ -struct veth_cnx_attribute veth_cnx_attr_##_name = __ATTR_RO(_name) - -#define SIMPLE_CNX_ATTR(_name) \ - CUSTOM_CNX_ATTR(_name, "%lu\n", (unsigned long)cnx->_name) - -SIMPLE_CNX_ATTR(outstanding_tx); -SIMPLE_CNX_ATTR(remote_lp); -SIMPLE_CNX_ATTR(num_events); -SIMPLE_CNX_ATTR(src_inst); -SIMPLE_CNX_ATTR(dst_inst); -SIMPLE_CNX_ATTR(num_pending_acks); -SIMPLE_CNX_ATTR(num_ack_events); -CUSTOM_CNX_ATTR(ack_timeout, "%d\n", jiffies_to_msecs(cnx->ack_timeout)); -CUSTOM_CNX_ATTR(reset_timeout, "%d\n", jiffies_to_msecs(cnx->reset_timeout)); -CUSTOM_CNX_ATTR(state, "0x%.4lX\n", cnx->state); -CUSTOM_CNX_ATTR(last_contact, "%d\n", cnx->last_contact ? - jiffies_to_msecs(jiffies - cnx->last_contact) : 0); - -#define GET_CNX_ATTR(_name) (&veth_cnx_attr_##_name.attr) - -static struct attribute *veth_cnx_default_attrs[] = { - GET_CNX_ATTR(outstanding_tx), - GET_CNX_ATTR(remote_lp), - GET_CNX_ATTR(num_events), - GET_CNX_ATTR(reset_timeout), - GET_CNX_ATTR(last_contact), - GET_CNX_ATTR(state), - GET_CNX_ATTR(src_inst), - GET_CNX_ATTR(dst_inst), - GET_CNX_ATTR(num_pending_acks), - GET_CNX_ATTR(num_ack_events), - GET_CNX_ATTR(ack_timeout), - NULL -}; - -static const struct sysfs_ops veth_cnx_sysfs_ops = { - .show = veth_cnx_attribute_show -}; - -static struct kobj_type veth_lpar_connection_ktype = { - .release = veth_release_connection, - .sysfs_ops = &veth_cnx_sysfs_ops, - .default_attrs = veth_cnx_default_attrs -}; - -struct veth_port_attribute { - struct attribute attr; - ssize_t (*show)(struct veth_port *, char *buf); - ssize_t (*store)(struct veth_port *, const char *buf); -}; - -static ssize_t veth_port_attribute_show(struct kobject *kobj, - struct attribute *attr, char *buf) -{ - struct veth_port_attribute *port_attr; - struct veth_port *port; - - port_attr = container_of(attr, struct veth_port_attribute, attr); - port = container_of(kobj, struct veth_port, kobject); - - if (!port_attr->show) - return -EIO; - - return port_attr->show(port, buf); -} - -#define CUSTOM_PORT_ATTR(_name, _format, _expression) \ -static ssize_t _name##_show(struct veth_port *port, char *buf) \ -{ \ - return sprintf(buf, _format, _expression); \ -} \ -struct veth_port_attribute veth_port_attr_##_name = __ATTR_RO(_name) - -#define SIMPLE_PORT_ATTR(_name) \ - CUSTOM_PORT_ATTR(_name, "%lu\n", (unsigned long)port->_name) - -SIMPLE_PORT_ATTR(promiscuous); -SIMPLE_PORT_ATTR(num_mcast); -CUSTOM_PORT_ATTR(lpar_map, "0x%X\n", port->lpar_map); -CUSTOM_PORT_ATTR(stopped_map, "0x%X\n", port->stopped_map); -CUSTOM_PORT_ATTR(mac_addr, "0x%llX\n", port->mac_addr); - -#define GET_PORT_ATTR(_name) (&veth_port_attr_##_name.attr) -static struct attribute *veth_port_default_attrs[] = { - GET_PORT_ATTR(mac_addr), - GET_PORT_ATTR(lpar_map), - GET_PORT_ATTR(stopped_map), - GET_PORT_ATTR(promiscuous), - GET_PORT_ATTR(num_mcast), - NULL -}; - -static const struct sysfs_ops veth_port_sysfs_ops = { - .show = veth_port_attribute_show -}; - -static struct kobj_type veth_port_ktype = { - .sysfs_ops = &veth_port_sysfs_ops, - .default_attrs = veth_port_default_attrs -}; - -/* - * LPAR connection code - */ - -static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx) -{ - schedule_delayed_work(&cnx->statemachine_wq, 0); -} - -static void veth_take_cap(struct veth_lpar_connection *cnx, - struct veth_lpevent *event) -{ - unsigned long flags; - - spin_lock_irqsave(&cnx->lock, flags); - /* Receiving caps may mean the other end has just come up, so - * we need to reload the instance ID of the far end */ - cnx->dst_inst = - HvCallEvent_getTargetLpInstanceId(cnx->remote_lp, - HvLpEvent_Type_VirtualLan); - - if (cnx->state & VETH_STATE_GOTCAPS) { - veth_error("Received a second capabilities from LPAR %d.\n", - cnx->remote_lp); - event->base_event.xRc = HvLpEvent_Rc_BufferNotAvailable; - HvCallEvent_ackLpEvent((struct HvLpEvent *) event); - } else { - memcpy(&cnx->cap_event, event, sizeof(cnx->cap_event)); - cnx->state |= VETH_STATE_GOTCAPS; - veth_kick_statemachine(cnx); - } - spin_unlock_irqrestore(&cnx->lock, flags); -} - -static void veth_take_cap_ack(struct veth_lpar_connection *cnx, - struct veth_lpevent *event) -{ - unsigned long flags; - - spin_lock_irqsave(&cnx->lock, flags); - if (cnx->state & VETH_STATE_GOTCAPACK) { - veth_error("Received a second capabilities ack from LPAR %d.\n", - cnx->remote_lp); - } else { - memcpy(&cnx->cap_ack_event, event, - sizeof(cnx->cap_ack_event)); - cnx->state |= VETH_STATE_GOTCAPACK; - veth_kick_statemachine(cnx); - } - spin_unlock_irqrestore(&cnx->lock, flags); -} - -static void veth_take_monitor_ack(struct veth_lpar_connection *cnx, - struct veth_lpevent *event) -{ - unsigned long flags; - - spin_lock_irqsave(&cnx->lock, flags); - veth_debug("cnx %d: lost connection.\n", cnx->remote_lp); - - /* Avoid kicking the statemachine once we're shutdown. - * It's unnecessary and it could break veth_stop_connection(). */ - - if (! (cnx->state & VETH_STATE_SHUTDOWN)) { - cnx->state |= VETH_STATE_RESET; - veth_kick_statemachine(cnx); - } - spin_unlock_irqrestore(&cnx->lock, flags); -} - -static void veth_handle_ack(struct veth_lpevent *event) -{ - HvLpIndex rlp = event->base_event.xTargetLp; - struct veth_lpar_connection *cnx = veth_cnx[rlp]; - - BUG_ON(! cnx); - - switch (event->base_event.xSubtype) { - case VETH_EVENT_CAP: - veth_take_cap_ack(cnx, event); - break; - case VETH_EVENT_MONITOR: - veth_take_monitor_ack(cnx, event); - break; - default: - veth_error("Unknown ack type %d from LPAR %d.\n", - event->base_event.xSubtype, rlp); - } -} - -static void veth_handle_int(struct veth_lpevent *event) -{ - HvLpIndex rlp = event->base_event.xSourceLp; - struct veth_lpar_connection *cnx = veth_cnx[rlp]; - unsigned long flags; - int i, acked = 0; - - BUG_ON(! cnx); - - switch (event->base_event.xSubtype) { - case VETH_EVENT_CAP: - veth_take_cap(cnx, event); - break; - case VETH_EVENT_MONITOR: - /* do nothing... this'll hang out here til we're dead, - * and the hypervisor will return it for us. */ - break; - case VETH_EVENT_FRAMES_ACK: - spin_lock_irqsave(&cnx->lock, flags); - - for (i = 0; i < VETH_MAX_ACKS_PER_MSG; ++i) { - u16 msgnum = event->u.frames_ack_data.token[i]; - - if (msgnum < VETH_NUMBUFFERS) { - veth_recycle_msg(cnx, cnx->msgs + msgnum); - cnx->outstanding_tx--; - acked++; - } - } - - if (acked > 0) { - cnx->last_contact = jiffies; - veth_wake_queues(cnx); - } - - spin_unlock_irqrestore(&cnx->lock, flags); - break; - case VETH_EVENT_FRAMES: - veth_receive(cnx, event); - break; - default: - veth_error("Unknown interrupt type %d from LPAR %d.\n", - event->base_event.xSubtype, rlp); - } -} - -static void veth_handle_event(struct HvLpEvent *event) -{ - struct veth_lpevent *veth_event = (struct veth_lpevent *)event; - - if (hvlpevent_is_ack(event)) - veth_handle_ack(veth_event); - else - veth_handle_int(veth_event); -} - -static int veth_process_caps(struct veth_lpar_connection *cnx) -{ - struct veth_cap_data *remote_caps = &cnx->remote_caps; - int num_acks_needed; - - /* Convert timer to jiffies */ - cnx->ack_timeout = remote_caps->ack_timeout * HZ / 1000000; - - if ( (remote_caps->num_buffers == 0) || - (remote_caps->ack_threshold > VETH_MAX_ACKS_PER_MSG) || - (remote_caps->ack_threshold == 0) || - (cnx->ack_timeout == 0) ) { - veth_error("Received incompatible capabilities from LPAR %d.\n", - cnx->remote_lp); - return HvLpEvent_Rc_InvalidSubtypeData; - } - - num_acks_needed = (remote_caps->num_buffers - / remote_caps->ack_threshold) + 1; - - /* FIXME: locking on num_ack_events? */ - if (cnx->num_ack_events < num_acks_needed) { - int num; - - num = veth_allocate_events(cnx->remote_lp, - num_acks_needed-cnx->num_ack_events); - if (num > 0) - cnx->num_ack_events += num; - - if (cnx->num_ack_events < num_acks_needed) { - veth_error("Couldn't allocate enough ack events " - "for LPAR %d.\n", cnx->remote_lp); - - return HvLpEvent_Rc_BufferNotAvailable; - } - } - - - return HvLpEvent_Rc_Good; -} - -/* FIXME: The gotos here are a bit dubious */ -static void veth_statemachine(struct work_struct *work) -{ - struct veth_lpar_connection *cnx = - container_of(work, struct veth_lpar_connection, - statemachine_wq.work); - int rlp = cnx->remote_lp; - int rc; - - spin_lock_irq(&cnx->lock); - - restart: - if (cnx->state & VETH_STATE_RESET) { - if (cnx->state & VETH_STATE_OPEN) - HvCallEvent_closeLpEventPath(cnx->remote_lp, - HvLpEvent_Type_VirtualLan); - - /* - * Reset ack data. This prevents the ack_timer actually - * doing anything, even if it runs one more time when - * we drop the lock below. - */ - memset(&cnx->pending_acks, 0xff, sizeof (cnx->pending_acks)); - cnx->num_pending_acks = 0; - - cnx->state &= ~(VETH_STATE_RESET | VETH_STATE_SENTMON - | VETH_STATE_OPEN | VETH_STATE_SENTCAPS - | VETH_STATE_GOTCAPACK | VETH_STATE_GOTCAPS - | VETH_STATE_SENTCAPACK | VETH_STATE_READY); - - /* Clean up any leftover messages */ - if (cnx->msgs) { - int i; - for (i = 0; i < VETH_NUMBUFFERS; ++i) - veth_recycle_msg(cnx, cnx->msgs + i); - } - - cnx->outstanding_tx = 0; - veth_wake_queues(cnx); - - /* Drop the lock so we can do stuff that might sleep or - * take other locks. */ - spin_unlock_irq(&cnx->lock); - - del_timer_sync(&cnx->ack_timer); - del_timer_sync(&cnx->reset_timer); - - spin_lock_irq(&cnx->lock); - - if (cnx->state & VETH_STATE_RESET) - goto restart; - - /* Hack, wait for the other end to reset itself. */ - if (! (cnx->state & VETH_STATE_SHUTDOWN)) { - schedule_delayed_work(&cnx->statemachine_wq, 5 * HZ); - goto out; - } - } - - if (cnx->state & VETH_STATE_SHUTDOWN) - /* It's all over, do nothing */ - goto out; - - if ( !(cnx->state & VETH_STATE_OPEN) ) { - if (! cnx->msgs || (cnx->num_events < (2 + VETH_NUMBUFFERS)) ) - goto cant_cope; - - HvCallEvent_openLpEventPath(rlp, HvLpEvent_Type_VirtualLan); - cnx->src_inst = - HvCallEvent_getSourceLpInstanceId(rlp, - HvLpEvent_Type_VirtualLan); - cnx->dst_inst = - HvCallEvent_getTargetLpInstanceId(rlp, - HvLpEvent_Type_VirtualLan); - cnx->state |= VETH_STATE_OPEN; - } - - if ( (cnx->state & VETH_STATE_OPEN) && - !(cnx->state & VETH_STATE_SENTMON) ) { - rc = veth_signalevent(cnx, VETH_EVENT_MONITOR, - HvLpEvent_AckInd_DoAck, - HvLpEvent_AckType_DeferredAck, - 0, 0, 0, 0, 0, 0); - - if (rc == HvLpEvent_Rc_Good) { - cnx->state |= VETH_STATE_SENTMON; - } else { - if ( (rc != HvLpEvent_Rc_PartitionDead) && - (rc != HvLpEvent_Rc_PathClosed) ) - veth_error("Error sending monitor to LPAR %d, " - "rc = %d\n", rlp, rc); - - /* Oh well, hope we get a cap from the other - * end and do better when that kicks us */ - goto out; - } - } - - if ( (cnx->state & VETH_STATE_OPEN) && - !(cnx->state & VETH_STATE_SENTCAPS)) { - u64 *rawcap = (u64 *)&cnx->local_caps; - - rc = veth_signalevent(cnx, VETH_EVENT_CAP, - HvLpEvent_AckInd_DoAck, - HvLpEvent_AckType_ImmediateAck, - 0, rawcap[0], rawcap[1], rawcap[2], - rawcap[3], rawcap[4]); - - if (rc == HvLpEvent_Rc_Good) { - cnx->state |= VETH_STATE_SENTCAPS; - } else { - if ( (rc != HvLpEvent_Rc_PartitionDead) && - (rc != HvLpEvent_Rc_PathClosed) ) - veth_error("Error sending caps to LPAR %d, " - "rc = %d\n", rlp, rc); - - /* Oh well, hope we get a cap from the other - * end and do better when that kicks us */ - goto out; - } - } - - if ((cnx->state & VETH_STATE_GOTCAPS) && - !(cnx->state & VETH_STATE_SENTCAPACK)) { - struct veth_cap_data *remote_caps = &cnx->remote_caps; - - memcpy(remote_caps, &cnx->cap_event.u.caps_data, - sizeof(*remote_caps)); - - spin_unlock_irq(&cnx->lock); - rc = veth_process_caps(cnx); - spin_lock_irq(&cnx->lock); - - /* We dropped the lock, so recheck for anything which - * might mess us up */ - if (cnx->state & (VETH_STATE_RESET|VETH_STATE_SHUTDOWN)) - goto restart; - - cnx->cap_event.base_event.xRc = rc; - HvCallEvent_ackLpEvent((struct HvLpEvent *)&cnx->cap_event); - if (rc == HvLpEvent_Rc_Good) - cnx->state |= VETH_STATE_SENTCAPACK; - else - goto cant_cope; - } - - if ((cnx->state & VETH_STATE_GOTCAPACK) && - (cnx->state & VETH_STATE_GOTCAPS) && - !(cnx->state & VETH_STATE_READY)) { - if (cnx->cap_ack_event.base_event.xRc == HvLpEvent_Rc_Good) { - /* Start the ACK timer */ - cnx->ack_timer.expires = jiffies + cnx->ack_timeout; - add_timer(&cnx->ack_timer); - cnx->state |= VETH_STATE_READY; - } else { - veth_error("Caps rejected by LPAR %d, rc = %d\n", - rlp, cnx->cap_ack_event.base_event.xRc); - goto cant_cope; - } - } - - out: - spin_unlock_irq(&cnx->lock); - return; - - cant_cope: - /* FIXME: we get here if something happens we really can't - * cope with. The link will never work once we get here, and - * all we can do is not lock the rest of the system up */ - veth_error("Unrecoverable error on connection to LPAR %d, shutting down" - " (state = 0x%04lx)\n", rlp, cnx->state); - cnx->state |= VETH_STATE_SHUTDOWN; - spin_unlock_irq(&cnx->lock); -} - -static int veth_init_connection(u8 rlp) -{ - struct veth_lpar_connection *cnx; - struct veth_msg *msgs; - int i; - - if ( (rlp == this_lp) || - ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) ) - return 0; - - cnx = kzalloc(sizeof(*cnx), GFP_KERNEL); - if (! cnx) - return -ENOMEM; - - cnx->remote_lp = rlp; - spin_lock_init(&cnx->lock); - INIT_DELAYED_WORK(&cnx->statemachine_wq, veth_statemachine); - - init_timer(&cnx->ack_timer); - cnx->ack_timer.function = veth_timed_ack; - cnx->ack_timer.data = (unsigned long) cnx; - - init_timer(&cnx->reset_timer); - cnx->reset_timer.function = veth_timed_reset; - cnx->reset_timer.data = (unsigned long) cnx; - cnx->reset_timeout = 5 * HZ * (VETH_ACKTIMEOUT / 1000000); - - memset(&cnx->pending_acks, 0xff, sizeof (cnx->pending_acks)); - - veth_cnx[rlp] = cnx; - - /* This gets us 1 reference, which is held on behalf of the driver - * infrastructure. It's released at module unload. */ - kobject_init(&cnx->kobject, &veth_lpar_connection_ktype); - - msgs = kcalloc(VETH_NUMBUFFERS, sizeof(struct veth_msg), GFP_KERNEL); - if (! msgs) { - veth_error("Can't allocate buffers for LPAR %d.\n", rlp); - return -ENOMEM; - } - - cnx->msgs = msgs; - - for (i = 0; i < VETH_NUMBUFFERS; i++) { - msgs[i].token = i; - veth_stack_push(cnx, msgs + i); - } - - cnx->num_events = veth_allocate_events(rlp, 2 + VETH_NUMBUFFERS); - - if (cnx->num_events < (2 + VETH_NUMBUFFERS)) { - veth_error("Can't allocate enough events for LPAR %d.\n", rlp); - return -ENOMEM; - } - - cnx->local_caps.num_buffers = VETH_NUMBUFFERS; - cnx->local_caps.ack_threshold = ACK_THRESHOLD; - cnx->local_caps.ack_timeout = VETH_ACKTIMEOUT; - - return 0; -} - -static void veth_stop_connection(struct veth_lpar_connection *cnx) -{ - if (!cnx) - return; - - spin_lock_irq(&cnx->lock); - cnx->state |= VETH_STATE_RESET | VETH_STATE_SHUTDOWN; - veth_kick_statemachine(cnx); - spin_unlock_irq(&cnx->lock); - - /* ensure the statemachine runs now and waits for its completion */ - flush_delayed_work_sync(&cnx->statemachine_wq); -} - -static void veth_destroy_connection(struct veth_lpar_connection *cnx) -{ - if (!cnx) - return; - - if (cnx->num_events > 0) - mf_deallocate_lp_events(cnx->remote_lp, - HvLpEvent_Type_VirtualLan, - cnx->num_events, - NULL, NULL); - if (cnx->num_ack_events > 0) - mf_deallocate_lp_events(cnx->remote_lp, - HvLpEvent_Type_VirtualLan, - cnx->num_ack_events, - NULL, NULL); - - kfree(cnx->msgs); - veth_cnx[cnx->remote_lp] = NULL; - kfree(cnx); -} - -static void veth_release_connection(struct kobject *kobj) -{ - struct veth_lpar_connection *cnx; - cnx = container_of(kobj, struct veth_lpar_connection, kobject); - veth_stop_connection(cnx); - veth_destroy_connection(cnx); -} - -/* - * net_device code - */ - -static int veth_open(struct net_device *dev) -{ - netif_start_queue(dev); - return 0; -} - -static int veth_close(struct net_device *dev) -{ - netif_stop_queue(dev); - return 0; -} - -static int veth_change_mtu(struct net_device *dev, int new_mtu) -{ - if ((new_mtu < 68) || (new_mtu > VETH_MAX_MTU)) - return -EINVAL; - dev->mtu = new_mtu; - return 0; -} - -static void veth_set_multicast_list(struct net_device *dev) -{ - struct veth_port *port = netdev_priv(dev); - unsigned long flags; - - write_lock_irqsave(&port->mcast_gate, flags); - - if ((dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI) || - (netdev_mc_count(dev) > VETH_MAX_MCAST)) { - port->promiscuous = 1; - } else { - struct netdev_hw_addr *ha; - - port->promiscuous = 0; - - /* Update table */ - port->num_mcast = 0; - - netdev_for_each_mc_addr(ha, dev) { - u8 *addr = ha->addr; - u64 xaddr = 0; - - memcpy(&xaddr, addr, ETH_ALEN); - port->mcast_addr[port->num_mcast] = xaddr; - port->num_mcast++; - } - } - - write_unlock_irqrestore(&port->mcast_gate, flags); -} - -static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) -{ - strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1); - info->driver[sizeof(info->driver) - 1] = '\0'; - strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1); - info->version[sizeof(info->version) - 1] = '\0'; -} - -static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) -{ - ecmd->supported = (SUPPORTED_1000baseT_Full - | SUPPORTED_Autoneg | SUPPORTED_FIBRE); - ecmd->advertising = (SUPPORTED_1000baseT_Full - | SUPPORTED_Autoneg | SUPPORTED_FIBRE); - ecmd->port = PORT_FIBRE; - ecmd->transceiver = XCVR_INTERNAL; - ecmd->phy_address = 0; - ecmd->speed = SPEED_1000; - ecmd->duplex = DUPLEX_FULL; - ecmd->autoneg = AUTONEG_ENABLE; - ecmd->maxtxpkt = 120; - ecmd->maxrxpkt = 120; - return 0; -} - -static const struct ethtool_ops ops = { - .get_drvinfo = veth_get_drvinfo, - .get_settings = veth_get_settings, - .get_link = ethtool_op_get_link, -}; - -static const struct net_device_ops veth_netdev_ops = { - .ndo_open = veth_open, - .ndo_stop = veth_close, - .ndo_start_xmit = veth_start_xmit, - .ndo_change_mtu = veth_change_mtu, - .ndo_set_rx_mode = veth_set_multicast_list, - .ndo_set_mac_address = NULL, - .ndo_validate_addr = eth_validate_addr, -}; - -static struct net_device *veth_probe_one(int vlan, - struct vio_dev *vio_dev) -{ - struct net_device *dev; - struct veth_port *port; - struct device *vdev = &vio_dev->dev; - int i, rc; - const unsigned char *mac_addr; - - mac_addr = vio_get_attribute(vio_dev, "local-mac-address", NULL); - if (mac_addr == NULL) - mac_addr = vio_get_attribute(vio_dev, "mac-address", NULL); - if (mac_addr == NULL) { - veth_error("Unable to fetch MAC address from device tree.\n"); - return NULL; - } - - dev = alloc_etherdev(sizeof (struct veth_port)); - if (!dev) - return NULL; - - port = netdev_priv(dev); - - spin_lock_init(&port->queue_lock); - rwlock_init(&port->mcast_gate); - port->stopped_map = 0; - - for (i = 0; i < HVMAXARCHITECTEDLPS; i++) { - HvLpVirtualLanIndexMap map; - - if (i == this_lp) - continue; - map = HvLpConfig_getVirtualLanIndexMapForLp(i); - if (map & (0x8000 >> vlan)) - port->lpar_map |= (1 << i); - } - port->dev = vdev; - - memcpy(dev->dev_addr, mac_addr, ETH_ALEN); - - dev->mtu = VETH_MAX_MTU; - - memcpy(&port->mac_addr, mac_addr, ETH_ALEN); - - dev->netdev_ops = &veth_netdev_ops; - SET_ETHTOOL_OPS(dev, &ops); - - SET_NETDEV_DEV(dev, vdev); - - rc = register_netdev(dev); - if (rc != 0) { - veth_error("Failed registering net device for vlan%d.\n", vlan); - free_netdev(dev); - return NULL; - } - - kobject_init(&port->kobject, &veth_port_ktype); - if (0 != kobject_add(&port->kobject, &dev->dev.kobj, "veth_port")) - veth_error("Failed adding port for %s to sysfs.\n", dev->name); - - veth_info("%s attached to iSeries vlan %d (LPAR map = 0x%.4X)\n", - dev->name, vlan, port->lpar_map); - - return dev; -} - -/* - * Tx path - */ - -static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp, - struct net_device *dev) -{ - struct veth_lpar_connection *cnx = veth_cnx[rlp]; - struct veth_port *port = netdev_priv(dev); - HvLpEvent_Rc rc; - struct veth_msg *msg = NULL; - unsigned long flags; - - if (! cnx) - return 0; - - spin_lock_irqsave(&cnx->lock, flags); - - if (! (cnx->state & VETH_STATE_READY)) - goto no_error; - - if ((skb->len - ETH_HLEN) > VETH_MAX_MTU) - goto drop; - - msg = veth_stack_pop(cnx); - if (! msg) - goto drop; - - msg->in_use = 1; - msg->skb = skb_get(skb); - - msg->data.addr[0] = dma_map_single(port->dev, skb->data, - skb->len, DMA_TO_DEVICE); - - if (dma_mapping_error(port->dev, msg->data.addr[0])) - goto recycle_and_drop; - - msg->dev = port->dev; - msg->data.len[0] = skb->len; - msg->data.eofmask = 1 << VETH_EOF_SHIFT; - - rc = veth_signaldata(cnx, VETH_EVENT_FRAMES, msg->token, &msg->data); - - if (rc != HvLpEvent_Rc_Good) - goto recycle_and_drop; - - /* If the timer's not already running, start it now. */ - if (0 == cnx->outstanding_tx) - mod_timer(&cnx->reset_timer, jiffies + cnx->reset_timeout); - - cnx->last_contact = jiffies; - cnx->outstanding_tx++; - - if (veth_stack_is_empty(cnx)) - veth_stop_queues(cnx); - - no_error: - spin_unlock_irqrestore(&cnx->lock, flags); - return 0; - - recycle_and_drop: - veth_recycle_msg(cnx, msg); - drop: - spin_unlock_irqrestore(&cnx->lock, flags); - return 1; -} - -static void veth_transmit_to_many(struct sk_buff *skb, - HvLpIndexMap lpmask, - struct net_device *dev) -{ - int i, success, error; - - success = error = 0; - - for (i = 0; i < HVMAXARCHITECTEDLPS; i++) { - if ((lpmask & (1 << i)) == 0) - continue; - - if (veth_transmit_to_one(skb, i, dev)) - error = 1; - else - success = 1; - } - - if (error) - dev->stats.tx_errors++; - - if (success) { - dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; - } -} - -static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - unsigned char *frame = skb->data; - struct veth_port *port = netdev_priv(dev); - HvLpIndexMap lpmask; - - if (is_unicast_ether_addr(frame)) { - /* unicast packet */ - HvLpIndex rlp = frame[5]; - - if ( ! ((1 << rlp) & port->lpar_map) ) { - dev_kfree_skb(skb); - return NETDEV_TX_OK; - } - - lpmask = 1 << rlp; - } else { - lpmask = port->lpar_map; - } - - veth_transmit_to_many(skb, lpmask, dev); - - dev_kfree_skb(skb); - - return NETDEV_TX_OK; -} - -/* You must hold the connection's lock when you call this function. */ -static void veth_recycle_msg(struct veth_lpar_connection *cnx, - struct veth_msg *msg) -{ - u32 dma_address, dma_length; - - if (msg->in_use) { - msg->in_use = 0; - dma_address = msg->data.addr[0]; - dma_length = msg->data.len[0]; - - if (!dma_mapping_error(msg->dev, dma_address)) - dma_unmap_single(msg->dev, dma_address, dma_length, - DMA_TO_DEVICE); - - if (msg->skb) { - dev_kfree_skb_any(msg->skb); - msg->skb = NULL; - } - - memset(&msg->data, 0, sizeof(msg->data)); - veth_stack_push(cnx, msg); - } else if (cnx->state & VETH_STATE_OPEN) { - veth_error("Non-pending frame (# %d) acked by LPAR %d.\n", - cnx->remote_lp, msg->token); - } -} - -static void veth_wake_queues(struct veth_lpar_connection *cnx) -{ - int i; - - for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) { - struct net_device *dev = veth_dev[i]; - struct veth_port *port; - unsigned long flags; - - if (! dev) - continue; - - port = netdev_priv(dev); - - if (! (port->lpar_map & (1<remote_lp))) - continue; - - spin_lock_irqsave(&port->queue_lock, flags); - - port->stopped_map &= ~(1 << cnx->remote_lp); - - if (0 == port->stopped_map && netif_queue_stopped(dev)) { - veth_debug("cnx %d: woke queue for %s.\n", - cnx->remote_lp, dev->name); - netif_wake_queue(dev); - } - spin_unlock_irqrestore(&port->queue_lock, flags); - } -} - -static void veth_stop_queues(struct veth_lpar_connection *cnx) -{ - int i; - - for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) { - struct net_device *dev = veth_dev[i]; - struct veth_port *port; - - if (! dev) - continue; - - port = netdev_priv(dev); - - /* If this cnx is not on the vlan for this port, continue */ - if (! (port->lpar_map & (1 << cnx->remote_lp))) - continue; - - spin_lock(&port->queue_lock); - - netif_stop_queue(dev); - port->stopped_map |= (1 << cnx->remote_lp); - - veth_debug("cnx %d: stopped queue for %s, map = 0x%x.\n", - cnx->remote_lp, dev->name, port->stopped_map); - - spin_unlock(&port->queue_lock); - } -} - -static void veth_timed_reset(unsigned long ptr) -{ - struct veth_lpar_connection *cnx = (struct veth_lpar_connection *)ptr; - unsigned long trigger_time, flags; - - /* FIXME is it possible this fires after veth_stop_connection()? - * That would reschedule the statemachine for 5 seconds and probably - * execute it after the module's been unloaded. Hmm. */ - - spin_lock_irqsave(&cnx->lock, flags); - - if (cnx->outstanding_tx > 0) { - trigger_time = cnx->last_contact + cnx->reset_timeout; - - if (trigger_time < jiffies) { - cnx->state |= VETH_STATE_RESET; - veth_kick_statemachine(cnx); - veth_error("%d packets not acked by LPAR %d within %d " - "seconds, resetting.\n", - cnx->outstanding_tx, cnx->remote_lp, - cnx->reset_timeout / HZ); - } else { - /* Reschedule the timer */ - trigger_time = jiffies + cnx->reset_timeout; - mod_timer(&cnx->reset_timer, trigger_time); - } - } - - spin_unlock_irqrestore(&cnx->lock, flags); -} - -/* - * Rx path - */ - -static inline int veth_frame_wanted(struct veth_port *port, u64 mac_addr) -{ - int wanted = 0; - int i; - unsigned long flags; - - if ( (mac_addr == port->mac_addr) || (mac_addr == 0xffffffffffff0000) ) - return 1; - - read_lock_irqsave(&port->mcast_gate, flags); - - if (port->promiscuous) { - wanted = 1; - goto out; - } - - for (i = 0; i < port->num_mcast; ++i) { - if (port->mcast_addr[i] == mac_addr) { - wanted = 1; - break; - } - } - - out: - read_unlock_irqrestore(&port->mcast_gate, flags); - - return wanted; -} - -struct dma_chunk { - u64 addr; - u64 size; -}; - -#define VETH_MAX_PAGES_PER_FRAME ( (VETH_MAX_MTU+PAGE_SIZE-2)/PAGE_SIZE + 1 ) - -static inline void veth_build_dma_list(struct dma_chunk *list, - unsigned char *p, unsigned long length) -{ - unsigned long done; - int i = 1; - - /* FIXME: skbs are contiguous in real addresses. Do we - * really need to break it into PAGE_SIZE chunks, or can we do - * it just at the granularity of iSeries real->absolute - * mapping? Indeed, given the way the allocator works, can we - * count on them being absolutely contiguous? */ - list[0].addr = iseries_hv_addr(p); - list[0].size = min(length, - PAGE_SIZE - ((unsigned long)p & ~PAGE_MASK)); - - done = list[0].size; - while (done < length) { - list[i].addr = iseries_hv_addr(p + done); - list[i].size = min(length-done, PAGE_SIZE); - done += list[i].size; - i++; - } -} - -static void veth_flush_acks(struct veth_lpar_connection *cnx) -{ - HvLpEvent_Rc rc; - - rc = veth_signaldata(cnx, VETH_EVENT_FRAMES_ACK, - 0, &cnx->pending_acks); - - if (rc != HvLpEvent_Rc_Good) - veth_error("Failed acking frames from LPAR %d, rc = %d\n", - cnx->remote_lp, (int)rc); - - cnx->num_pending_acks = 0; - memset(&cnx->pending_acks, 0xff, sizeof(cnx->pending_acks)); -} - -static void veth_receive(struct veth_lpar_connection *cnx, - struct veth_lpevent *event) -{ - struct veth_frames_data *senddata = &event->u.frames_data; - int startchunk = 0; - int nchunks; - unsigned long flags; - HvLpDma_Rc rc; - - do { - u16 length = 0; - struct sk_buff *skb; - struct dma_chunk local_list[VETH_MAX_PAGES_PER_FRAME]; - struct dma_chunk remote_list[VETH_MAX_FRAMES_PER_MSG]; - u64 dest; - HvLpVirtualLanIndex vlan; - struct net_device *dev; - struct veth_port *port; - - /* FIXME: do we need this? */ - memset(local_list, 0, sizeof(local_list)); - memset(remote_list, 0, sizeof(remote_list)); - - /* a 0 address marks the end of the valid entries */ - if (senddata->addr[startchunk] == 0) - break; - - /* make sure that we have at least 1 EOF entry in the - * remaining entries */ - if (! (senddata->eofmask >> (startchunk + VETH_EOF_SHIFT))) { - veth_error("Missing EOF fragment in event " - "eofmask = 0x%x startchunk = %d\n", - (unsigned)senddata->eofmask, - startchunk); - break; - } - - /* build list of chunks in this frame */ - nchunks = 0; - do { - remote_list[nchunks].addr = - (u64) senddata->addr[startchunk+nchunks] << 32; - remote_list[nchunks].size = - senddata->len[startchunk+nchunks]; - length += remote_list[nchunks].size; - } while (! (senddata->eofmask & - (1 << (VETH_EOF_SHIFT + startchunk + nchunks++)))); - - /* length == total length of all chunks */ - /* nchunks == # of chunks in this frame */ - - if ((length - ETH_HLEN) > VETH_MAX_MTU) { - veth_error("Received oversize frame from LPAR %d " - "(length = %d)\n", - cnx->remote_lp, length); - continue; - } - - skb = alloc_skb(length, GFP_ATOMIC); - if (!skb) - continue; - - veth_build_dma_list(local_list, skb->data, length); - - rc = HvCallEvent_dmaBufList(HvLpEvent_Type_VirtualLan, - event->base_event.xSourceLp, - HvLpDma_Direction_RemoteToLocal, - cnx->src_inst, - cnx->dst_inst, - HvLpDma_AddressType_RealAddress, - HvLpDma_AddressType_TceIndex, - iseries_hv_addr(&local_list), - iseries_hv_addr(&remote_list), - length); - if (rc != HvLpDma_Rc_Good) { - dev_kfree_skb_irq(skb); - continue; - } - - vlan = skb->data[9]; - dev = veth_dev[vlan]; - if (! dev) { - /* - * Some earlier versions of the driver sent - * broadcasts down all connections, even to lpars - * that weren't on the relevant vlan. So ignore - * packets belonging to a vlan we're not on. - * We can also be here if we receive packets while - * the driver is going down, because then dev is NULL. - */ - dev_kfree_skb_irq(skb); - continue; - } - - port = netdev_priv(dev); - dest = *((u64 *) skb->data) & 0xFFFFFFFFFFFF0000; - - if ((vlan > HVMAXARCHITECTEDVIRTUALLANS) || !port) { - dev_kfree_skb_irq(skb); - continue; - } - if (! veth_frame_wanted(port, dest)) { - dev_kfree_skb_irq(skb); - continue; - } - - skb_put(skb, length); - skb->protocol = eth_type_trans(skb, dev); - skb_checksum_none_assert(skb); - netif_rx(skb); /* send it up */ - dev->stats.rx_packets++; - dev->stats.rx_bytes += length; - } while (startchunk += nchunks, startchunk < VETH_MAX_FRAMES_PER_MSG); - - /* Ack it */ - spin_lock_irqsave(&cnx->lock, flags); - BUG_ON(cnx->num_pending_acks > VETH_MAX_ACKS_PER_MSG); - - cnx->pending_acks[cnx->num_pending_acks++] = - event->base_event.xCorrelationToken; - - if ( (cnx->num_pending_acks >= cnx->remote_caps.ack_threshold) || - (cnx->num_pending_acks >= VETH_MAX_ACKS_PER_MSG) ) - veth_flush_acks(cnx); - - spin_unlock_irqrestore(&cnx->lock, flags); -} - -static void veth_timed_ack(unsigned long ptr) -{ - struct veth_lpar_connection *cnx = (struct veth_lpar_connection *) ptr; - unsigned long flags; - - /* Ack all the events */ - spin_lock_irqsave(&cnx->lock, flags); - if (cnx->num_pending_acks > 0) - veth_flush_acks(cnx); - - /* Reschedule the timer */ - cnx->ack_timer.expires = jiffies + cnx->ack_timeout; - add_timer(&cnx->ack_timer); - spin_unlock_irqrestore(&cnx->lock, flags); -} - -static int veth_remove(struct vio_dev *vdev) -{ - struct veth_lpar_connection *cnx; - struct net_device *dev; - struct veth_port *port; - int i; - - dev = veth_dev[vdev->unit_address]; - - if (! dev) - return 0; - - port = netdev_priv(dev); - - for (i = 0; i < HVMAXARCHITECTEDLPS; i++) { - cnx = veth_cnx[i]; - - if (cnx && (port->lpar_map & (1 << i))) { - /* Drop our reference to connections on our VLAN */ - kobject_put(&cnx->kobject); - } - } - - veth_dev[vdev->unit_address] = NULL; - kobject_del(&port->kobject); - kobject_put(&port->kobject); - unregister_netdev(dev); - free_netdev(dev); - - return 0; -} - -static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id) -{ - int i = vdev->unit_address; - struct net_device *dev; - struct veth_port *port; - - dev = veth_probe_one(i, vdev); - if (dev == NULL) { - veth_remove(vdev); - return 1; - } - veth_dev[i] = dev; - - port = netdev_priv(dev); - - /* Start the state machine on each connection on this vlan. If we're - * the first dev to do so this will commence link negotiation */ - for (i = 0; i < HVMAXARCHITECTEDLPS; i++) { - struct veth_lpar_connection *cnx; - - if (! (port->lpar_map & (1 << i))) - continue; - - cnx = veth_cnx[i]; - if (!cnx) - continue; - - kobject_get(&cnx->kobject); - veth_kick_statemachine(cnx); - } - - return 0; -} - -/** - * veth_device_table: Used by vio.c to match devices that we - * support. - */ -static struct vio_device_id veth_device_table[] __devinitdata = { - { "network", "IBM,iSeries-l-lan" }, - { "", "" } -}; -MODULE_DEVICE_TABLE(vio, veth_device_table); - -static struct vio_driver veth_driver = { - .id_table = veth_device_table, - .probe = veth_probe, - .remove = veth_remove, - .driver = { - .name = DRV_NAME, - .owner = THIS_MODULE, - } -}; - -/* - * Module initialization/cleanup - */ - -static void __exit veth_module_cleanup(void) -{ - int i; - struct veth_lpar_connection *cnx; - - /* Disconnect our "irq" to stop events coming from the Hypervisor. */ - HvLpEvent_unregisterHandler(HvLpEvent_Type_VirtualLan); - - for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) { - cnx = veth_cnx[i]; - - if (!cnx) - continue; - - /* Cancel work queued from Hypervisor callbacks */ - cancel_delayed_work_sync(&cnx->statemachine_wq); - /* Remove the connection from sysfs */ - kobject_del(&cnx->kobject); - /* Drop the driver's reference to the connection */ - kobject_put(&cnx->kobject); - } - - /* Unregister the driver, which will close all the netdevs and stop - * the connections when they're no longer referenced. */ - vio_unregister_driver(&veth_driver); -} -module_exit(veth_module_cleanup); - -static int __init veth_module_init(void) -{ - int i; - int rc; - - if (!firmware_has_feature(FW_FEATURE_ISERIES)) - return -ENODEV; - - this_lp = HvLpConfig_getLpIndex_outline(); - - for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) { - rc = veth_init_connection(i); - if (rc != 0) - goto error; - } - - HvLpEvent_registerHandler(HvLpEvent_Type_VirtualLan, - &veth_handle_event); - - rc = vio_register_driver(&veth_driver); - if (rc != 0) - goto error; - - for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) { - struct kobject *kobj; - - if (!veth_cnx[i]) - continue; - - kobj = &veth_cnx[i]->kobject; - /* If the add failes, complain but otherwise continue */ - if (0 != driver_add_kobj(&veth_driver.driver, kobj, - "cnx%.2d", veth_cnx[i]->remote_lp)) - veth_error("cnx %d: Failed adding to sysfs.\n", i); - } - - return 0; - -error: - for (i = 0; i < HVMAXARCHITECTEDLPS; ++i) { - veth_destroy_connection(veth_cnx[i]); - } - - return rc; -} -module_init(veth_module_init); -- GitLab From e27566ed370da09e3b812d3d76dce002915a5bdd Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 09:54:01 +0100 Subject: [PATCH 1627/1846] r8169: move the driver removal method to the end of the driver file. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 58 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index c04df3d2b2a9..ef6ef604f174 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -4263,34 +4263,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto out; } -static void __devexit rtl8169_remove_one(struct pci_dev *pdev) -{ - struct net_device *dev = pci_get_drvdata(pdev); - struct rtl8169_private *tp = netdev_priv(dev); - - if (tp->mac_version == RTL_GIGA_MAC_VER_27 || - tp->mac_version == RTL_GIGA_MAC_VER_28 || - tp->mac_version == RTL_GIGA_MAC_VER_31) { - rtl8168_driver_stop(tp); - } - - cancel_work_sync(&tp->wk.work); - - unregister_netdev(dev); - - rtl_release_firmware(tp); - - if (pci_dev_run_wake(pdev)) - pm_runtime_get_noresume(&pdev->dev); - - /* restore original MAC address */ - rtl_rar_set(tp, dev->perm_addr); - - rtl_disable_msi(pdev, tp); - rtl8169_release_board(pdev, dev, tp->mmio_addr); - pci_set_drvdata(pdev, NULL); -} - static void rtl_request_uncached_firmware(struct rtl8169_private *tp) { struct rtl_fw *rtl_fw; @@ -6316,11 +6288,39 @@ static void rtl_shutdown(struct pci_dev *pdev) pm_runtime_put_noidle(d); } +static void __devexit rtl_remove_one(struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct rtl8169_private *tp = netdev_priv(dev); + + if (tp->mac_version == RTL_GIGA_MAC_VER_27 || + tp->mac_version == RTL_GIGA_MAC_VER_28 || + tp->mac_version == RTL_GIGA_MAC_VER_31) { + rtl8168_driver_stop(tp); + } + + cancel_work_sync(&tp->wk.work); + + unregister_netdev(dev); + + rtl_release_firmware(tp); + + if (pci_dev_run_wake(pdev)) + pm_runtime_get_noresume(&pdev->dev); + + /* restore original MAC address */ + rtl_rar_set(tp, dev->perm_addr); + + rtl_disable_msi(pdev, tp); + rtl8169_release_board(pdev, dev, tp->mmio_addr); + pci_set_drvdata(pdev, NULL); +} + static struct pci_driver rtl8169_pci_driver = { .name = MODULENAME, .id_table = rtl8169_pci_tbl, .probe = rtl8169_init_one, - .remove = __devexit_p(rtl8169_remove_one), + .remove = __devexit_p(rtl_remove_one), .shutdown = rtl_shutdown, .driver.pm = RTL8169_PM_OPS, }; -- GitLab From 3b6cf25de260d5607fa1fe48ba1af0f6d057708e Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 09:59:04 +0100 Subject: [PATCH 1628/1846] r8169: move the driver probe method to the end of the driver file. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 492 +++++++++++++-------------- 1 file changed, 246 insertions(+), 246 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index ef6ef604f174..3455d37a63a5 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -4018,251 +4018,6 @@ static void rtl_hw_reset(struct rtl8169_private *tp) } } -static int __devinit -rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; - const unsigned int region = cfg->region; - struct rtl8169_private *tp; - struct mii_if_info *mii; - struct net_device *dev; - void __iomem *ioaddr; - int chipset, i; - int rc; - - if (netif_msg_drv(&debug)) { - printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", - MODULENAME, RTL8169_VERSION); - } - - dev = alloc_etherdev(sizeof (*tp)); - if (!dev) { - rc = -ENOMEM; - goto out; - } - - SET_NETDEV_DEV(dev, &pdev->dev); - dev->netdev_ops = &rtl8169_netdev_ops; - tp = netdev_priv(dev); - tp->dev = dev; - tp->pci_dev = pdev; - tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); - - mii = &tp->mii; - mii->dev = dev; - mii->mdio_read = rtl_mdio_read; - mii->mdio_write = rtl_mdio_write; - mii->phy_id_mask = 0x1f; - mii->reg_num_mask = 0x1f; - mii->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII); - - /* disable ASPM completely as that cause random device stop working - * problems as well as full system hangs for some PCIe devices users */ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); - - /* enable device (incl. PCI PM wakeup and hotplug setup) */ - rc = pci_enable_device(pdev); - if (rc < 0) { - netif_err(tp, probe, dev, "enable failure\n"); - goto err_out_free_dev_1; - } - - if (pci_set_mwi(pdev) < 0) - netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n"); - - /* make sure PCI base addr 1 is MMIO */ - if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { - netif_err(tp, probe, dev, - "region #%d not an MMIO resource, aborting\n", - region); - rc = -ENODEV; - goto err_out_mwi_2; - } - - /* check for weird/broken PCI region reporting */ - if (pci_resource_len(pdev, region) < R8169_REGS_SIZE) { - netif_err(tp, probe, dev, - "Invalid PCI region size(s), aborting\n"); - rc = -ENODEV; - goto err_out_mwi_2; - } - - rc = pci_request_regions(pdev, MODULENAME); - if (rc < 0) { - netif_err(tp, probe, dev, "could not request regions\n"); - goto err_out_mwi_2; - } - - tp->cp_cmd = RxChkSum; - - if ((sizeof(dma_addr_t) > 4) && - !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { - tp->cp_cmd |= PCIDAC; - dev->features |= NETIF_F_HIGHDMA; - } else { - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (rc < 0) { - netif_err(tp, probe, dev, "DMA configuration failed\n"); - goto err_out_free_res_3; - } - } - - /* ioremap MMIO region */ - ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); - if (!ioaddr) { - netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); - rc = -EIO; - goto err_out_free_res_3; - } - tp->mmio_addr = ioaddr; - - if (!pci_is_pcie(pdev)) - netif_info(tp, probe, dev, "not PCI Express\n"); - - /* Identify chip attached to board */ - rtl8169_get_mac_version(tp, dev, cfg->default_ver); - - rtl_init_rxcfg(tp); - - rtl_irq_disable(tp); - - rtl_hw_reset(tp); - - rtl_ack_events(tp, 0xffff); - - pci_set_master(pdev); - - /* - * Pretend we are using VLANs; This bypasses a nasty bug where - * Interrupts stop flowing on high load on 8110SCd controllers. - */ - if (tp->mac_version == RTL_GIGA_MAC_VER_05) - tp->cp_cmd |= RxVlan; - - rtl_init_mdio_ops(tp); - rtl_init_pll_power_ops(tp); - rtl_init_jumbo_ops(tp); - - rtl8169_print_mac_version(tp); - - chipset = tp->mac_version; - tp->txd_version = rtl_chip_infos[chipset].txd_version; - - RTL_W8(Cfg9346, Cfg9346_Unlock); - RTL_W8(Config1, RTL_R8(Config1) | PMEnable); - RTL_W8(Config5, RTL_R8(Config5) & PMEStatus); - if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0) - tp->features |= RTL_FEATURE_WOL; - if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0) - tp->features |= RTL_FEATURE_WOL; - tp->features |= rtl_try_msi(tp, cfg); - RTL_W8(Cfg9346, Cfg9346_Lock); - - if (rtl_tbi_enabled(tp)) { - tp->set_speed = rtl8169_set_speed_tbi; - tp->get_settings = rtl8169_gset_tbi; - tp->phy_reset_enable = rtl8169_tbi_reset_enable; - tp->phy_reset_pending = rtl8169_tbi_reset_pending; - tp->link_ok = rtl8169_tbi_link_ok; - tp->do_ioctl = rtl_tbi_ioctl; - } else { - tp->set_speed = rtl8169_set_speed_xmii; - tp->get_settings = rtl8169_gset_xmii; - tp->phy_reset_enable = rtl8169_xmii_reset_enable; - tp->phy_reset_pending = rtl8169_xmii_reset_pending; - tp->link_ok = rtl8169_xmii_link_ok; - tp->do_ioctl = rtl_xmii_ioctl; - } - - mutex_init(&tp->wk.mutex); - - /* Get MAC address */ - for (i = 0; i < ETH_ALEN; i++) - dev->dev_addr[i] = RTL_R8(MAC0 + i); - memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); - - SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); - dev->watchdog_timeo = RTL8169_TX_TIMEOUT; - dev->irq = pdev->irq; - dev->base_addr = (unsigned long) ioaddr; - - netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); - - /* don't enable SG, IP_CSUM and TSO by default - it might not work - * properly for all devices */ - dev->features |= NETIF_F_RXCSUM | - NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; - - dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | - NETIF_F_RXCSUM | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; - dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | - NETIF_F_HIGHDMA; - - if (tp->mac_version == RTL_GIGA_MAC_VER_05) - /* 8110SCd requires hardware Rx VLAN - disallow toggling */ - dev->hw_features &= ~NETIF_F_HW_VLAN_RX; - - dev->hw_features |= NETIF_F_RXALL; - dev->hw_features |= NETIF_F_RXFCS; - - tp->hw_start = cfg->hw_start; - tp->event_slow = cfg->event_slow; - - tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ? - ~(RxBOVF | RxFOVF) : ~0; - - init_timer(&tp->timer); - tp->timer.data = (unsigned long) dev; - tp->timer.function = rtl8169_phy_timer; - - tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; - - rc = register_netdev(dev); - if (rc < 0) - goto err_out_msi_4; - - pci_set_drvdata(pdev, dev); - - netif_info(tp, probe, dev, "%s at 0x%lx, %pM, XID %08x IRQ %d\n", - rtl_chip_infos[chipset].name, dev->base_addr, dev->dev_addr, - (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); - if (rtl_chip_infos[chipset].jumbo_max != JUMBO_1K) { - netif_info(tp, probe, dev, "jumbo features [frames: %d bytes, " - "tx checksumming: %s]\n", - rtl_chip_infos[chipset].jumbo_max, - rtl_chip_infos[chipset].jumbo_tx_csum ? "ok" : "ko"); - } - - if (tp->mac_version == RTL_GIGA_MAC_VER_27 || - tp->mac_version == RTL_GIGA_MAC_VER_28 || - tp->mac_version == RTL_GIGA_MAC_VER_31) { - rtl8168_driver_start(tp); - } - - device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); - - if (pci_dev_run_wake(pdev)) - pm_runtime_put_noidle(&pdev->dev); - - netif_carrier_off(dev); - -out: - return rc; - -err_out_msi_4: - rtl_disable_msi(pdev, tp); - iounmap(ioaddr); -err_out_free_res_3: - pci_release_regions(pdev); -err_out_mwi_2: - pci_clear_mwi(pdev); - pci_disable_device(pdev); -err_out_free_dev_1: - free_netdev(dev); - goto out; -} - static void rtl_request_uncached_firmware(struct rtl8169_private *tp) { struct rtl_fw *rtl_fw; @@ -6316,10 +6071,255 @@ static void __devexit rtl_remove_one(struct pci_dev *pdev) pci_set_drvdata(pdev, NULL); } +static int __devinit +rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; + const unsigned int region = cfg->region; + struct rtl8169_private *tp; + struct mii_if_info *mii; + struct net_device *dev; + void __iomem *ioaddr; + int chipset, i; + int rc; + + if (netif_msg_drv(&debug)) { + printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", + MODULENAME, RTL8169_VERSION); + } + + dev = alloc_etherdev(sizeof (*tp)); + if (!dev) { + rc = -ENOMEM; + goto out; + } + + SET_NETDEV_DEV(dev, &pdev->dev); + dev->netdev_ops = &rtl8169_netdev_ops; + tp = netdev_priv(dev); + tp->dev = dev; + tp->pci_dev = pdev; + tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); + + mii = &tp->mii; + mii->dev = dev; + mii->mdio_read = rtl_mdio_read; + mii->mdio_write = rtl_mdio_write; + mii->phy_id_mask = 0x1f; + mii->reg_num_mask = 0x1f; + mii->supports_gmii = !!(cfg->features & RTL_FEATURE_GMII); + + /* disable ASPM completely as that cause random device stop working + * problems as well as full system hangs for some PCIe devices users */ + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + + /* enable device (incl. PCI PM wakeup and hotplug setup) */ + rc = pci_enable_device(pdev); + if (rc < 0) { + netif_err(tp, probe, dev, "enable failure\n"); + goto err_out_free_dev_1; + } + + if (pci_set_mwi(pdev) < 0) + netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n"); + + /* make sure PCI base addr 1 is MMIO */ + if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { + netif_err(tp, probe, dev, + "region #%d not an MMIO resource, aborting\n", + region); + rc = -ENODEV; + goto err_out_mwi_2; + } + + /* check for weird/broken PCI region reporting */ + if (pci_resource_len(pdev, region) < R8169_REGS_SIZE) { + netif_err(tp, probe, dev, + "Invalid PCI region size(s), aborting\n"); + rc = -ENODEV; + goto err_out_mwi_2; + } + + rc = pci_request_regions(pdev, MODULENAME); + if (rc < 0) { + netif_err(tp, probe, dev, "could not request regions\n"); + goto err_out_mwi_2; + } + + tp->cp_cmd = RxChkSum; + + if ((sizeof(dma_addr_t) > 4) && + !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) { + tp->cp_cmd |= PCIDAC; + dev->features |= NETIF_F_HIGHDMA; + } else { + rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (rc < 0) { + netif_err(tp, probe, dev, "DMA configuration failed\n"); + goto err_out_free_res_3; + } + } + + /* ioremap MMIO region */ + ioaddr = ioremap(pci_resource_start(pdev, region), R8169_REGS_SIZE); + if (!ioaddr) { + netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); + rc = -EIO; + goto err_out_free_res_3; + } + tp->mmio_addr = ioaddr; + + if (!pci_is_pcie(pdev)) + netif_info(tp, probe, dev, "not PCI Express\n"); + + /* Identify chip attached to board */ + rtl8169_get_mac_version(tp, dev, cfg->default_ver); + + rtl_init_rxcfg(tp); + + rtl_irq_disable(tp); + + rtl_hw_reset(tp); + + rtl_ack_events(tp, 0xffff); + + pci_set_master(pdev); + + /* + * Pretend we are using VLANs; This bypasses a nasty bug where + * Interrupts stop flowing on high load on 8110SCd controllers. + */ + if (tp->mac_version == RTL_GIGA_MAC_VER_05) + tp->cp_cmd |= RxVlan; + + rtl_init_mdio_ops(tp); + rtl_init_pll_power_ops(tp); + rtl_init_jumbo_ops(tp); + + rtl8169_print_mac_version(tp); + + chipset = tp->mac_version; + tp->txd_version = rtl_chip_infos[chipset].txd_version; + + RTL_W8(Cfg9346, Cfg9346_Unlock); + RTL_W8(Config1, RTL_R8(Config1) | PMEnable); + RTL_W8(Config5, RTL_R8(Config5) & PMEStatus); + if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0) + tp->features |= RTL_FEATURE_WOL; + if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0) + tp->features |= RTL_FEATURE_WOL; + tp->features |= rtl_try_msi(tp, cfg); + RTL_W8(Cfg9346, Cfg9346_Lock); + + if (rtl_tbi_enabled(tp)) { + tp->set_speed = rtl8169_set_speed_tbi; + tp->get_settings = rtl8169_gset_tbi; + tp->phy_reset_enable = rtl8169_tbi_reset_enable; + tp->phy_reset_pending = rtl8169_tbi_reset_pending; + tp->link_ok = rtl8169_tbi_link_ok; + tp->do_ioctl = rtl_tbi_ioctl; + } else { + tp->set_speed = rtl8169_set_speed_xmii; + tp->get_settings = rtl8169_gset_xmii; + tp->phy_reset_enable = rtl8169_xmii_reset_enable; + tp->phy_reset_pending = rtl8169_xmii_reset_pending; + tp->link_ok = rtl8169_xmii_link_ok; + tp->do_ioctl = rtl_xmii_ioctl; + } + + mutex_init(&tp->wk.mutex); + + /* Get MAC address */ + for (i = 0; i < ETH_ALEN; i++) + dev->dev_addr[i] = RTL_R8(MAC0 + i); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); + + SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); + dev->watchdog_timeo = RTL8169_TX_TIMEOUT; + dev->irq = pdev->irq; + dev->base_addr = (unsigned long) ioaddr; + + netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); + + /* don't enable SG, IP_CSUM and TSO by default - it might not work + * properly for all devices */ + dev->features |= NETIF_F_RXCSUM | + NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; + + dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | + NETIF_F_RXCSUM | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; + dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | + NETIF_F_HIGHDMA; + + if (tp->mac_version == RTL_GIGA_MAC_VER_05) + /* 8110SCd requires hardware Rx VLAN - disallow toggling */ + dev->hw_features &= ~NETIF_F_HW_VLAN_RX; + + dev->hw_features |= NETIF_F_RXALL; + dev->hw_features |= NETIF_F_RXFCS; + + tp->hw_start = cfg->hw_start; + tp->event_slow = cfg->event_slow; + + tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ? + ~(RxBOVF | RxFOVF) : ~0; + + init_timer(&tp->timer); + tp->timer.data = (unsigned long) dev; + tp->timer.function = rtl8169_phy_timer; + + tp->rtl_fw = RTL_FIRMWARE_UNKNOWN; + + rc = register_netdev(dev); + if (rc < 0) + goto err_out_msi_4; + + pci_set_drvdata(pdev, dev); + + netif_info(tp, probe, dev, "%s at 0x%lx, %pM, XID %08x IRQ %d\n", + rtl_chip_infos[chipset].name, dev->base_addr, dev->dev_addr, + (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); + if (rtl_chip_infos[chipset].jumbo_max != JUMBO_1K) { + netif_info(tp, probe, dev, "jumbo features [frames: %d bytes, " + "tx checksumming: %s]\n", + rtl_chip_infos[chipset].jumbo_max, + rtl_chip_infos[chipset].jumbo_tx_csum ? "ok" : "ko"); + } + + if (tp->mac_version == RTL_GIGA_MAC_VER_27 || + tp->mac_version == RTL_GIGA_MAC_VER_28 || + tp->mac_version == RTL_GIGA_MAC_VER_31) { + rtl8168_driver_start(tp); + } + + device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); + + if (pci_dev_run_wake(pdev)) + pm_runtime_put_noidle(&pdev->dev); + + netif_carrier_off(dev); + +out: + return rc; + +err_out_msi_4: + rtl_disable_msi(pdev, tp); + iounmap(ioaddr); +err_out_free_res_3: + pci_release_regions(pdev); +err_out_mwi_2: + pci_clear_mwi(pdev); + pci_disable_device(pdev); +err_out_free_dev_1: + free_netdev(dev); + goto out; +} + static struct pci_driver rtl8169_pci_driver = { .name = MODULENAME, .id_table = rtl8169_pci_tbl, - .probe = rtl8169_init_one, + .probe = rtl_init_one, .remove = __devexit_p(rtl_remove_one), .shutdown = rtl_shutdown, .driver.pm = RTL8169_PM_OPS, -- GitLab From fa9c385ef57c1a04966f01314f96fb7c9347d924 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 10:01:50 +0100 Subject: [PATCH 1629/1846] r8169: move net_device_ops beyond the methods it references. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 49 ++++++++++++---------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 3455d37a63a5..5ce9f640fa24 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -774,19 +774,10 @@ MODULE_FIRMWARE(FIRMWARE_8105E_1); MODULE_FIRMWARE(FIRMWARE_8168F_1); MODULE_FIRMWARE(FIRMWARE_8168F_2); -static int rtl8169_open(struct net_device *dev); -static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, - struct net_device *dev); static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance); static int rtl8169_init_ring(struct net_device *dev); static void rtl_hw_start(struct net_device *dev); -static int rtl8169_close(struct net_device *dev); static void rtl_set_rx_mode(struct net_device *dev); -static void rtl8169_tx_timeout(struct net_device *dev); -static struct rtnl_link_stats64 *rtl8169_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 - *stats); -static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); static void rtl8169_rx_clear(struct rtl8169_private *tp); static int rtl8169_poll(struct napi_struct *napi, int budget); @@ -3528,25 +3519,6 @@ static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp) } } -static const struct net_device_ops rtl8169_netdev_ops = { - .ndo_open = rtl8169_open, - .ndo_stop = rtl8169_close, - .ndo_get_stats64 = rtl8169_get_stats64, - .ndo_start_xmit = rtl8169_start_xmit, - .ndo_tx_timeout = rtl8169_tx_timeout, - .ndo_validate_addr = eth_validate_addr, - .ndo_change_mtu = rtl8169_change_mtu, - .ndo_fix_features = rtl8169_fix_features, - .ndo_set_features = rtl8169_set_features, - .ndo_set_mac_address = rtl_set_mac_address, - .ndo_do_ioctl = rtl8169_ioctl, - .ndo_set_rx_mode = rtl_set_rx_mode, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = rtl8169_netpoll, -#endif - -}; - static void __devinit rtl_init_mdio_ops(struct rtl8169_private *tp) { struct mdio_ops *ops = &tp->mdio_ops; @@ -6071,6 +6043,25 @@ static void __devexit rtl_remove_one(struct pci_dev *pdev) pci_set_drvdata(pdev, NULL); } +static const struct net_device_ops rtl_netdev_ops = { + .ndo_open = rtl8169_open, + .ndo_stop = rtl8169_close, + .ndo_get_stats64 = rtl8169_get_stats64, + .ndo_start_xmit = rtl8169_start_xmit, + .ndo_tx_timeout = rtl8169_tx_timeout, + .ndo_validate_addr = eth_validate_addr, + .ndo_change_mtu = rtl8169_change_mtu, + .ndo_fix_features = rtl8169_fix_features, + .ndo_set_features = rtl8169_set_features, + .ndo_set_mac_address = rtl_set_mac_address, + .ndo_do_ioctl = rtl8169_ioctl, + .ndo_set_rx_mode = rtl_set_rx_mode, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = rtl8169_netpoll, +#endif + +}; + static int __devinit rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -6095,7 +6086,7 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) } SET_NETDEV_DEV(dev, &pdev->dev); - dev->netdev_ops = &rtl8169_netdev_ops; + dev->netdev_ops = &rtl_netdev_ops; tp = netdev_priv(dev); tp->dev = dev; tp->pci_dev = pdev; -- GitLab From e6b763ea0527f1038752a591e4b45cffacc4bba2 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 09:35:39 +0100 Subject: [PATCH 1630/1846] r8169: move rtl_set_rx_mode before its rtl_hw_start callers. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 101 +++++++++++++-------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 5ce9f640fa24..abb6dead24d9 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -777,7 +777,6 @@ MODULE_FIRMWARE(FIRMWARE_8168F_2); static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance); static int rtl8169_init_ring(struct net_device *dev); static void rtl_hw_start(struct net_device *dev); -static void rtl_set_rx_mode(struct net_device *dev); static void rtl8169_rx_clear(struct rtl8169_private *tp); static int rtl8169_poll(struct napi_struct *napi, int budget); @@ -4223,6 +4222,56 @@ static void rtl8169_set_magic_reg(void __iomem *ioaddr, unsigned mac_version) } } +static void rtl_set_rx_mode(struct net_device *dev) +{ + struct rtl8169_private *tp = netdev_priv(dev); + void __iomem *ioaddr = tp->mmio_addr; + u32 mc_filter[2]; /* Multicast hash filter */ + int rx_mode; + u32 tmp = 0; + + if (dev->flags & IFF_PROMISC) { + /* Unconditionally log net taps. */ + netif_notice(tp, link, dev, "Promiscuous mode enabled\n"); + rx_mode = + AcceptBroadcast | AcceptMulticast | AcceptMyPhys | + AcceptAllPhys; + mc_filter[1] = mc_filter[0] = 0xffffffff; + } else if ((netdev_mc_count(dev) > multicast_filter_limit) || + (dev->flags & IFF_ALLMULTI)) { + /* Too many to filter perfectly -- accept all multicasts. */ + rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; + mc_filter[1] = mc_filter[0] = 0xffffffff; + } else { + struct netdev_hw_addr *ha; + + rx_mode = AcceptBroadcast | AcceptMyPhys; + mc_filter[1] = mc_filter[0] = 0; + netdev_for_each_mc_addr(ha, dev) { + int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); + rx_mode |= AcceptMulticast; + } + } + + if (dev->features & NETIF_F_RXALL) + rx_mode |= (AcceptErr | AcceptRunt); + + tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode; + + if (tp->mac_version > RTL_GIGA_MAC_VER_06) { + u32 data = mc_filter[0]; + + mc_filter[0] = swab32(mc_filter[1]); + mc_filter[1] = swab32(data); + } + + RTL_W32(MAR0 + 4, mc_filter[1]); + RTL_W32(MAR0 + 0, mc_filter[0]); + + RTL_W32(RxConfig, tmp); +} + static void rtl_hw_start_8169(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); @@ -5757,56 +5806,6 @@ static int rtl8169_close(struct net_device *dev) return 0; } -static void rtl_set_rx_mode(struct net_device *dev) -{ - struct rtl8169_private *tp = netdev_priv(dev); - void __iomem *ioaddr = tp->mmio_addr; - u32 mc_filter[2]; /* Multicast hash filter */ - int rx_mode; - u32 tmp = 0; - - if (dev->flags & IFF_PROMISC) { - /* Unconditionally log net taps. */ - netif_notice(tp, link, dev, "Promiscuous mode enabled\n"); - rx_mode = - AcceptBroadcast | AcceptMulticast | AcceptMyPhys | - AcceptAllPhys; - mc_filter[1] = mc_filter[0] = 0xffffffff; - } else if ((netdev_mc_count(dev) > multicast_filter_limit) || - (dev->flags & IFF_ALLMULTI)) { - /* Too many to filter perfectly -- accept all multicasts. */ - rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; - mc_filter[1] = mc_filter[0] = 0xffffffff; - } else { - struct netdev_hw_addr *ha; - - rx_mode = AcceptBroadcast | AcceptMyPhys; - mc_filter[1] = mc_filter[0] = 0; - netdev_for_each_mc_addr(ha, dev) { - int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; - mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); - rx_mode |= AcceptMulticast; - } - } - - if (dev->features & NETIF_F_RXALL) - rx_mode |= (AcceptErr | AcceptRunt); - - tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode; - - if (tp->mac_version > RTL_GIGA_MAC_VER_06) { - u32 data = mc_filter[0]; - - mc_filter[0] = swab32(mc_filter[1]); - mc_filter[1] = swab32(data); - } - - RTL_W32(MAR0 + 4, mc_filter[1]); - RTL_W32(MAR0 + 0, mc_filter[0]); - - RTL_W32(RxConfig, tmp); -} - static struct rtnl_link_stats64 * rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { -- GitLab From df43ac7831a0e321b6b183b7eb48ae4577207453 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 09:48:40 +0100 Subject: [PATCH 1631/1846] r8169: move rtl8169_open after rtl_task it depends on. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 168 +++++++++++++-------------- 1 file changed, 81 insertions(+), 87 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index abb6dead24d9..8d4515ed7946 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -775,10 +775,6 @@ MODULE_FIRMWARE(FIRMWARE_8168F_1); MODULE_FIRMWARE(FIRMWARE_8168F_2); static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance); -static int rtl8169_init_ring(struct net_device *dev); -static void rtl_hw_start(struct net_device *dev); -static void rtl8169_rx_clear(struct rtl8169_private *tp); -static int rtl8169_poll(struct napi_struct *napi, int budget); static void rtl_lock_work(struct rtl8169_private *tp) { @@ -4033,88 +4029,6 @@ static void rtl_request_firmware(struct rtl8169_private *tp) rtl_request_uncached_firmware(tp); } -static void rtl_task(struct work_struct *); - -static int rtl8169_open(struct net_device *dev) -{ - struct rtl8169_private *tp = netdev_priv(dev); - void __iomem *ioaddr = tp->mmio_addr; - struct pci_dev *pdev = tp->pci_dev; - int retval = -ENOMEM; - - pm_runtime_get_sync(&pdev->dev); - - /* - * Rx and Tx desscriptors needs 256 bytes alignment. - * dma_alloc_coherent provides more. - */ - tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8169_TX_RING_BYTES, - &tp->TxPhyAddr, GFP_KERNEL); - if (!tp->TxDescArray) - goto err_pm_runtime_put; - - tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES, - &tp->RxPhyAddr, GFP_KERNEL); - if (!tp->RxDescArray) - goto err_free_tx_0; - - retval = rtl8169_init_ring(dev); - if (retval < 0) - goto err_free_rx_1; - - INIT_WORK(&tp->wk.work, rtl_task); - - smp_mb(); - - rtl_request_firmware(tp); - - retval = request_irq(dev->irq, rtl8169_interrupt, - (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, - dev->name, dev); - if (retval < 0) - goto err_release_fw_2; - - rtl_lock_work(tp); - - set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); - - napi_enable(&tp->napi); - - rtl8169_init_phy(dev, tp); - - __rtl8169_set_features(dev, dev->features); - - rtl_pll_power_up(tp); - - rtl_hw_start(dev); - - netif_start_queue(dev); - - rtl_unlock_work(tp); - - tp->saved_wolopts = 0; - pm_runtime_put_noidle(&pdev->dev); - - rtl8169_check_link_status(dev, tp, ioaddr); -out: - return retval; - -err_release_fw_2: - rtl_release_firmware(tp); - rtl8169_rx_clear(tp); -err_free_rx_1: - dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, - tp->RxPhyAddr); - tp->RxDescArray = NULL; -err_free_tx_0: - dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray, - tp->TxPhyAddr); - tp->TxDescArray = NULL; -err_pm_runtime_put: - pm_runtime_put_noidle(&pdev->dev); - goto out; -} - static void rtl_rx_close(struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; @@ -5806,6 +5720,86 @@ static int rtl8169_close(struct net_device *dev) return 0; } +static int rtl_open(struct net_device *dev) +{ + struct rtl8169_private *tp = netdev_priv(dev); + void __iomem *ioaddr = tp->mmio_addr; + struct pci_dev *pdev = tp->pci_dev; + int retval = -ENOMEM; + + pm_runtime_get_sync(&pdev->dev); + + /* + * Rx and Tx desscriptors needs 256 bytes alignment. + * dma_alloc_coherent provides more. + */ + tp->TxDescArray = dma_alloc_coherent(&pdev->dev, R8169_TX_RING_BYTES, + &tp->TxPhyAddr, GFP_KERNEL); + if (!tp->TxDescArray) + goto err_pm_runtime_put; + + tp->RxDescArray = dma_alloc_coherent(&pdev->dev, R8169_RX_RING_BYTES, + &tp->RxPhyAddr, GFP_KERNEL); + if (!tp->RxDescArray) + goto err_free_tx_0; + + retval = rtl8169_init_ring(dev); + if (retval < 0) + goto err_free_rx_1; + + INIT_WORK(&tp->wk.work, rtl_task); + + smp_mb(); + + rtl_request_firmware(tp); + + retval = request_irq(dev->irq, rtl8169_interrupt, + (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, + dev->name, dev); + if (retval < 0) + goto err_release_fw_2; + + rtl_lock_work(tp); + + set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); + + napi_enable(&tp->napi); + + rtl8169_init_phy(dev, tp); + + __rtl8169_set_features(dev, dev->features); + + rtl_pll_power_up(tp); + + rtl_hw_start(dev); + + netif_start_queue(dev); + + rtl_unlock_work(tp); + + tp->saved_wolopts = 0; + pm_runtime_put_noidle(&pdev->dev); + + rtl8169_check_link_status(dev, tp, ioaddr); +out: + return retval; + +err_release_fw_2: + rtl_release_firmware(tp); + rtl8169_rx_clear(tp); +err_free_rx_1: + dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, + tp->RxPhyAddr); + tp->RxDescArray = NULL; +err_free_tx_0: + dma_free_coherent(&pdev->dev, R8169_TX_RING_BYTES, tp->TxDescArray, + tp->TxPhyAddr); + tp->TxDescArray = NULL; +err_pm_runtime_put: + pm_runtime_put_noidle(&pdev->dev); + goto out; +} + static struct rtnl_link_stats64 * rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { @@ -6043,7 +6037,7 @@ static void __devexit rtl_remove_one(struct pci_dev *pdev) } static const struct net_device_ops rtl_netdev_ops = { - .ndo_open = rtl8169_open, + .ndo_open = rtl_open, .ndo_stop = rtl8169_close, .ndo_get_stats64 = rtl8169_get_stats64, .ndo_start_xmit = rtl8169_start_xmit, -- GitLab From dc1c00ce70da5d3bb3fc97707e04f598ff72e7ba Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 10:06:18 +0100 Subject: [PATCH 1632/1846] r8169: move the netpoll handler after the irq handler. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 8d4515ed7946..12329c5e1ede 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -774,8 +774,6 @@ MODULE_FIRMWARE(FIRMWARE_8105E_1); MODULE_FIRMWARE(FIRMWARE_8168F_1); MODULE_FIRMWARE(FIRMWARE_8168F_2); -static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance); - static void rtl_lock_work(struct rtl8169_private *tp) { mutex_lock(&tp->wk.mutex); @@ -3289,15 +3287,6 @@ static void rtl8169_phy_timer(unsigned long __opaque) rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING); } -#ifdef CONFIG_NET_POLL_CONTROLLER -static void rtl8169_netpoll(struct net_device *dev) -{ - struct rtl8169_private *tp = netdev_priv(dev); - - rtl8169_interrupt(tp->pci_dev->irq, dev); -} -#endif - static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev, void __iomem *ioaddr) { @@ -5720,6 +5709,15 @@ static int rtl8169_close(struct net_device *dev) return 0; } +#ifdef CONFIG_NET_POLL_CONTROLLER +static void rtl8169_netpoll(struct net_device *dev) +{ + struct rtl8169_private *tp = netdev_priv(dev); + + rtl8169_interrupt(tp->pci_dev->irq, dev); +} +#endif + static int rtl_open(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); -- GitLab From 31fa8b1855cb1f1fd99e2f2f9b8f2c8f113e9f2e Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Thu, 8 Mar 2012 10:09:40 +0100 Subject: [PATCH 1633/1846] r8169: move rtl_cfg_info closer to its caller. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 118 +++++++++++++-------------- 1 file changed, 57 insertions(+), 61 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 12329c5e1ede..390e69a548d3 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -255,10 +255,6 @@ enum cfg_version { RTL_CFG_2 }; -static void rtl_hw_start_8169(struct net_device *); -static void rtl_hw_start_8168(struct net_device *); -static void rtl_hw_start_8101(struct net_device *); - static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, @@ -3438,63 +3434,6 @@ static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data return -EOPNOTSUPP; } -static const struct rtl_cfg_info { - void (*hw_start)(struct net_device *); - unsigned int region; - unsigned int align; - u16 event_slow; - unsigned features; - u8 default_ver; -} rtl_cfg_infos [] = { - [RTL_CFG_0] = { - .hw_start = rtl_hw_start_8169, - .region = 1, - .align = 0, - .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver, - .features = RTL_FEATURE_GMII, - .default_ver = RTL_GIGA_MAC_VER_01, - }, - [RTL_CFG_1] = { - .hw_start = rtl_hw_start_8168, - .region = 2, - .align = 8, - .event_slow = SYSErr | LinkChg | RxOverflow, - .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI, - .default_ver = RTL_GIGA_MAC_VER_11, - }, - [RTL_CFG_2] = { - .hw_start = rtl_hw_start_8101, - .region = 2, - .align = 8, - .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver | - PCSTimeout, - .features = RTL_FEATURE_MSI, - .default_ver = RTL_GIGA_MAC_VER_13, - } -}; - -/* Cfg9346_Unlock assumed. */ -static unsigned rtl_try_msi(struct rtl8169_private *tp, - const struct rtl_cfg_info *cfg) -{ - void __iomem *ioaddr = tp->mmio_addr; - unsigned msi = 0; - u8 cfg2; - - cfg2 = RTL_R8(Config2) & ~MSIEnable; - if (cfg->features & RTL_FEATURE_MSI) { - if (pci_enable_msi(tp->pci_dev)) { - netif_info(tp, hw, tp->dev, "no MSI. Back to INTx.\n"); - } else { - cfg2 |= MSIEnable; - msi = RTL_FEATURE_MSI; - } - } - if (tp->mac_version <= RTL_GIGA_MAC_VER_06) - RTL_W8(Config2, cfg2); - return msi; -} - static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp) { if (tp->features & RTL_FEATURE_MSI) { @@ -6053,6 +5992,63 @@ static const struct net_device_ops rtl_netdev_ops = { }; +static const struct rtl_cfg_info { + void (*hw_start)(struct net_device *); + unsigned int region; + unsigned int align; + u16 event_slow; + unsigned features; + u8 default_ver; +} rtl_cfg_infos [] = { + [RTL_CFG_0] = { + .hw_start = rtl_hw_start_8169, + .region = 1, + .align = 0, + .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver, + .features = RTL_FEATURE_GMII, + .default_ver = RTL_GIGA_MAC_VER_01, + }, + [RTL_CFG_1] = { + .hw_start = rtl_hw_start_8168, + .region = 2, + .align = 8, + .event_slow = SYSErr | LinkChg | RxOverflow, + .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI, + .default_ver = RTL_GIGA_MAC_VER_11, + }, + [RTL_CFG_2] = { + .hw_start = rtl_hw_start_8101, + .region = 2, + .align = 8, + .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver | + PCSTimeout, + .features = RTL_FEATURE_MSI, + .default_ver = RTL_GIGA_MAC_VER_13, + } +}; + +/* Cfg9346_Unlock assumed. */ +static unsigned rtl_try_msi(struct rtl8169_private *tp, + const struct rtl_cfg_info *cfg) +{ + void __iomem *ioaddr = tp->mmio_addr; + unsigned msi = 0; + u8 cfg2; + + cfg2 = RTL_R8(Config2) & ~MSIEnable; + if (cfg->features & RTL_FEATURE_MSI) { + if (pci_enable_msi(tp->pci_dev)) { + netif_info(tp, hw, tp->dev, "no MSI. Back to INTx.\n"); + } else { + cfg2 |= MSIEnable; + msi = RTL_FEATURE_MSI; + } + } + if (tp->mac_version <= RTL_GIGA_MAC_VER_06) + RTL_W8(Config2, cfg2); + return msi; +} + static int __devinit rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { -- GitLab From 92a7c4e7183bcd29e2366f1ee784ad395c291134 Mon Sep 17 00:00:00 2001 From: Francois Romieu Date: Sat, 10 Mar 2012 10:42:12 +0100 Subject: [PATCH 1634/1846] r8169: stop using net_device.{base_addr, irq}. The driver does not need this leftover of the ISA drivers era. Signed-off-by: Francois Romieu Cc: Hayes Wang --- drivers/net/ethernet/realtek/r8169.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 390e69a548d3..4aa419487ced 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5634,7 +5634,7 @@ static int rtl8169_close(struct net_device *dev) rtl8169_down(dev); rtl_unlock_work(tp); - free_irq(dev->irq, dev); + free_irq(pdev->irq, dev); dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, tp->RxPhyAddr); @@ -5690,7 +5690,7 @@ static int rtl_open(struct net_device *dev) rtl_request_firmware(tp); - retval = request_irq(dev->irq, rtl8169_interrupt, + retval = request_irq(pdev->irq, rtl8169_interrupt, (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, dev->name, dev); if (retval < 0) @@ -6215,8 +6215,6 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops); dev->watchdog_timeo = RTL8169_TX_TIMEOUT; - dev->irq = pdev->irq; - dev->base_addr = (unsigned long) ioaddr; netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); @@ -6255,9 +6253,9 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, dev); - netif_info(tp, probe, dev, "%s at 0x%lx, %pM, XID %08x IRQ %d\n", - rtl_chip_infos[chipset].name, dev->base_addr, dev->dev_addr, - (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); + netif_info(tp, probe, dev, "%s at 0x%p, %pM, XID %08x IRQ %d\n", + rtl_chip_infos[chipset].name, ioaddr, dev->dev_addr, + (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), pdev->irq); if (rtl_chip_infos[chipset].jumbo_max != JUMBO_1K) { netif_info(tp, probe, dev, "jumbo features [frames: %d bytes, " "tx checksumming: %s]\n", -- GitLab From 86ceb360565d06fcee96be85c4bafe9264756eca Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 7 Mar 2012 09:07:45 +0100 Subject: [PATCH 1635/1846] batman-adv: Ignore 80-chars per line limits for strings Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/bat_iv_ogm.c | 54 ++++++++---------- net/batman-adv/bat_sysfs.c | 16 +++--- net/batman-adv/gateway_client.c | 31 +++++------ net/batman-adv/gateway_common.c | 8 +-- net/batman-adv/hard-interface.c | 36 ++++-------- net/batman-adv/icmp_socket.c | 12 ++-- net/batman-adv/main.c | 8 +-- net/batman-adv/originator.c | 14 ++--- net/batman-adv/routing.c | 27 ++++----- net/batman-adv/send.c | 4 +- net/batman-adv/soft-interface.c | 15 +++-- net/batman-adv/translation-table.c | 89 +++++++++++++++--------------- 12 files changed, 137 insertions(+), 177 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 2b66daef1ef6..677997b5c485 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -132,8 +132,7 @@ static void bat_iv_ogm_send_to_if(struct forw_packet *forw_packet, "Sending own" : "Forwarding")); bat_dbg(DBG_BATMAN, bat_priv, - "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," - " IDF %s, ttvn %d) on interface %s [%pM]\n", + "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", fwd_str, (packet_num > 0 ? "aggregated " : ""), batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), @@ -171,8 +170,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) directlink = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); if (!forw_packet->if_incoming) { - pr_err("Error - can't forward packet: incoming iface not " - "specified\n"); + pr_err("Error - can't forward packet: incoming iface not specified\n"); goto out; } @@ -193,8 +191,7 @@ static void bat_iv_ogm_emit(struct forw_packet *forw_packet) /* FIXME: what about aggregated packets ? */ bat_dbg(DBG_BATMAN, bat_priv, - "%s packet (originator %pM, seqno %d, TTL %d) " - "on interface %s [%pM]\n", + "%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%pM]\n", (forw_packet->own ? "Sending own" : "Forwarding"), batman_ogm_packet->orig, ntohl(batman_ogm_packet->seqno), @@ -508,8 +505,7 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv); bat_dbg(DBG_BATMAN, bat_priv, - "Forwarding packet: tq_orig: %i, tq_avg: %i, " - "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n", + "Forwarding packet: tq_orig: %i, tq_avg: %i, tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n", in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1, batman_ogm_packet->header.ttl); @@ -589,8 +585,8 @@ static void bat_iv_ogm_orig_update(struct bat_priv *bat_priv, struct hlist_node *node; uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; - bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): " - "Searching and updating originator entry of received packet\n"); + bat_dbg(DBG_BATMAN, bat_priv, + "update_originator(): Searching and updating originator entry of received packet\n"); rcu_read_lock(); hlist_for_each_entry_rcu(tmp_neigh_node, node, @@ -802,10 +798,7 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, (TQ_MAX_VALUE * TQ_MAX_VALUE)); bat_dbg(DBG_BATMAN, bat_priv, - "bidirectional: " - "orig = %-15pM neigh = %-15pM => own_bcast = %2i, " - "real recv = %2i, local tq: %3i, asym_penalty: %3i, " - "total tq: %3i\n", + "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", orig_node->orig, orig_neigh_node->orig, total_count, neigh_rq_count, tq_own, tq_asym_penalty, batman_ogm_packet->tq); @@ -933,9 +926,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, batman_ogm_packet->orig) ? 1 : 0); bat_dbg(DBG_BATMAN, bat_priv, - "Received BATMAN packet via NB: %pM, IF: %s [%pM] " - "(from OG: %pM, via prev OG: %pM, seqno %d, ttvn %u, " - "crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", + "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %d, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", ethhdr->h_source, if_incoming->net_dev->name, if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, batman_ogm_packet->prev_sender, batman_ogm_packet->seqno, @@ -978,16 +969,15 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, if (is_my_addr) { bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: received my own broadcast (sender: %pM" - ")\n", + "Drop packet: received my own broadcast (sender: %pM)\n", ethhdr->h_source); return; } if (is_broadcast) { - bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: " - "ignoring all packets with broadcast source addr (sender: %pM" - ")\n", ethhdr->h_source); + bat_dbg(DBG_BATMAN, bat_priv, + "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", + ethhdr->h_source); return; } @@ -1017,16 +1007,16 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); } - bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: " - "originator packet from myself (via neighbor)\n"); + bat_dbg(DBG_BATMAN, bat_priv, + "Drop packet: originator packet from myself (via neighbor)\n"); orig_node_free_ref(orig_neigh_node); return; } if (is_my_oldorig) { bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: ignoring all rebroadcast echos (sender: " - "%pM)\n", ethhdr->h_source); + "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", + ethhdr->h_source); return; } @@ -1039,8 +1029,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, if (is_duplicate == -1) { bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: packet within seqno protection time " - "(sender: %pM)\n", ethhdr->h_source); + "Drop packet: packet within seqno protection time (sender: %pM)\n", + ethhdr->h_source); goto out; } @@ -1061,8 +1051,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, batman_ogm_packet->prev_sender)) && (compare_eth(router->addr, router_router->addr))) { bat_dbg(DBG_BATMAN, bat_priv, - "Drop packet: ignoring all rebroadcast packets that " - "may make me loop (sender: %pM)\n", ethhdr->h_source); + "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", + ethhdr->h_source); goto out; } @@ -1106,8 +1096,8 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, bat_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1, if_incoming); - bat_dbg(DBG_BATMAN, bat_priv, "Forwarding packet: " - "rebroadcast neighbor packet with direct link flag\n"); + bat_dbg(DBG_BATMAN, bat_priv, + "Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); goto out_neigh; } diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c index b00101db5cc6..68ff759fc304 100644 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c @@ -255,8 +255,8 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, buff[count - 1] = '\0'; bat_info(net_dev, - "Invalid parameter for 'vis mode' setting received: " - "%s\n", buff); + "Invalid parameter for 'vis mode' setting received: %s\n", + buff); return -EINVAL; } @@ -330,8 +330,8 @@ static ssize_t store_gw_mode(struct kobject *kobj, struct attribute *attr, if (gw_mode_tmp < 0) { bat_info(net_dev, - "Invalid parameter for 'gw mode' setting received: " - "%s\n", buff); + "Invalid parameter for 'gw mode' setting received: %s\n", + buff); return -EINVAL; } @@ -502,8 +502,8 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr, buff[count - 1] = '\0'; if (strlen(buff) >= IFNAMSIZ) { - pr_err("Invalid parameter for 'mesh_iface' setting received: " - "interface name too long '%s'\n", buff); + pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n", + buff); hardif_free_ref(hard_iface); return -EINVAL; } @@ -677,8 +677,8 @@ int throw_uevent(struct bat_priv *bat_priv, enum uev_type type, hardif_free_ref(primary_if); if (ret) - bat_dbg(DBG_BATMAN, bat_priv, "Impossible to send " - "uevent for (%s,%s,%s) event (err: %d)\n", + bat_dbg(DBG_BATMAN, bat_priv, + "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", uev_type_str[type], uev_action_str[action], (action == UEV_DEL ? "NULL" : data), ret); return ret; diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 0fa8e2d7c46e..6f9b9b78f77d 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -224,16 +224,13 @@ void gw_election(struct bat_priv *bat_priv) } else if ((!curr_gw) && (next_gw)) { bat_dbg(DBG_BATMAN, bat_priv, "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", - next_gw->orig_node->orig, - next_gw->orig_node->gw_flags, + next_gw->orig_node->orig, next_gw->orig_node->gw_flags, router->tq_avg); throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); } else { bat_dbg(DBG_BATMAN, bat_priv, - "Changing route to gateway %pM " - "(gw_flags: %i, tq: %i)\n", - next_gw->orig_node->orig, - next_gw->orig_node->gw_flags, + "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", + next_gw->orig_node->orig, next_gw->orig_node->gw_flags, router->tq_avg); throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); } @@ -287,8 +284,7 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) goto out; bat_dbg(DBG_BATMAN, bat_priv, - "Restarting gateway selection: better gateway found (tq curr: " - "%i, tq new: %i)\n", + "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", gw_tq_avg, orig_tq_avg); deselect: @@ -352,8 +348,7 @@ void gw_node_update(struct bat_priv *bat_priv, continue; bat_dbg(DBG_BATMAN, bat_priv, - "Gateway class of originator %pM changed from " - "%i to %i\n", + "Gateway class of originator %pM changed from %i to %i\n", orig_node->orig, gw_node->orig_node->gw_flags, new_gwflags); @@ -474,23 +469,23 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset) primary_if = primary_if_get_selected(bat_priv); if (!primary_if) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - please " - "specify interfaces to enable it\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - please specify interfaces to enable it\n", net_dev->name); goto out; } if (primary_if->if_status != IF_ACTIVE) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - " - "primary interface not active\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); goto out; } - seq_printf(seq, " %-12s (%s/%i) %17s [%10s]: gw_class ... " - "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", - "Gateway", "#", TQ_MAX_VALUE, "Nexthop", - "outgoingIF", SOURCE_VERSION, primary_if->net_dev->name, + seq_printf(seq, + " %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", + "Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", + SOURCE_VERSION, primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name); rcu_read_lock(); diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 3ccb9c87fd19..ca57ac7d73b2 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c @@ -125,8 +125,8 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, ret = kstrtol(slash_ptr + 1, 10, &lup); if (ret) { bat_err(net_dev, - "Upload speed of gateway mode invalid: " - "%s\n", slash_ptr + 1); + "Upload speed of gateway mode invalid: %s\n", + slash_ptr + 1); return false; } @@ -163,8 +163,8 @@ ssize_t gw_bandwidth_set(struct net_device *net_dev, char *buff, size_t count) gw_bandwidth_to_kbit((uint8_t)gw_bandwidth_tmp, &down, &up); gw_deselect(bat_priv); - bat_info(net_dev, "Changing gateway bandwidth from: '%i' to: '%ld' " - "(propagating: %d%s/%d%s)\n", + bat_info(net_dev, + "Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n", atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp, (down > 2048 ? down / 1024 : down), (down > 2048 ? "MBit" : "KBit"), diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 409d0273c9d1..377897701a85 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -175,11 +175,9 @@ static void check_known_mac_addr(const struct net_device *net_dev) net_dev->dev_addr)) continue; - pr_warning("The newly added mac address (%pM) already exists " - "on: %s\n", net_dev->dev_addr, - hard_iface->net_dev->name); - pr_warning("It is strongly recommended to keep mac addresses " - "unique to avoid problems!\n"); + pr_warning("The newly added mac address (%pM) already exists on: %s\n", + net_dev->dev_addr, hard_iface->net_dev->name); + pr_warning("It is strongly recommended to keep mac addresses unique to avoid problems!\n"); } rcu_read_unlock(); } @@ -282,10 +280,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, /* hard-interface is part of a bridge */ if (hard_iface->net_dev->priv_flags & IFF_BRIDGE_PORT) - pr_err("You are about to enable batman-adv on '%s' which " - "already is part of a bridge. Unless you know exactly " - "what you are doing this is probably wrong and won't " - "work the way you think it would.\n", + pr_err("You are about to enable batman-adv on '%s' which already is part of a bridge. Unless you know exactly what you are doing this is probably wrong and won't work the way you think it would.\n", hard_iface->net_dev->name); soft_iface = dev_get_by_name(&init_net, iface_name); @@ -303,8 +298,7 @@ int hardif_enable_interface(struct hard_iface *hard_iface, } if (!softif_is_valid(soft_iface)) { - pr_err("Can't create batman mesh interface %s: " - "already exists as regular interface\n", + pr_err("Can't create batman mesh interface %s: already exists as regular interface\n", soft_iface->name); dev_put(soft_iface); ret = -EINVAL; @@ -317,8 +311,9 @@ int hardif_enable_interface(struct hard_iface *hard_iface, bat_priv->bat_algo_ops->bat_ogm_init(hard_iface); if (!hard_iface->packet_buff) { - bat_err(hard_iface->soft_iface, "Can't add interface packet " - "(%s): out of memory\n", hard_iface->net_dev->name); + bat_err(hard_iface->soft_iface, + "Can't add interface packet (%s): out of memory\n", + hard_iface->net_dev->name); ret = -ENOMEM; goto err; } @@ -341,29 +336,22 @@ int hardif_enable_interface(struct hard_iface *hard_iface, if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < ETH_DATA_LEN + BAT_HEADER_LEN) bat_info(hard_iface->soft_iface, - "The MTU of interface %s is too small (%i) to handle " - "the transport of batman-adv packets. Packets going " - "over this interface will be fragmented on layer2 " - "which could impact the performance. Setting the MTU " - "to %zi would solve the problem.\n", + "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n", hard_iface->net_dev->name, hard_iface->net_dev->mtu, ETH_DATA_LEN + BAT_HEADER_LEN); if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < ETH_DATA_LEN + BAT_HEADER_LEN) bat_info(hard_iface->soft_iface, - "The MTU of interface %s is too small (%i) to handle " - "the transport of batman-adv packets. If you " - "experience problems getting traffic through try " - "increasing the MTU to %zi.\n", + "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n", hard_iface->net_dev->name, hard_iface->net_dev->mtu, ETH_DATA_LEN + BAT_HEADER_LEN); if (hardif_is_iface_up(hard_iface)) hardif_activate_interface(hard_iface); else - bat_err(hard_iface->soft_iface, "Not using interface %s " - "(retrying later): interface not active\n", + bat_err(hard_iface->soft_iface, + "Not using interface %s (retrying later): interface not active\n", hard_iface->net_dev->name); /* begin scheduling originator messages on that interface */ diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index 9b755f9eb182..b87518edcef9 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -59,8 +59,7 @@ static int bat_socket_open(struct inode *inode, struct file *file) } if (i == ARRAY_SIZE(socket_client_hash)) { - pr_err("Error - can't add another packet client: " - "maximum number of clients reached\n"); + pr_err("Error - can't add another packet client: maximum number of clients reached\n"); kfree(socket_client); return -EXFULL; } @@ -162,8 +161,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, if (len < sizeof(struct icmp_packet)) { bat_dbg(DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: " - "invalid packet size\n"); + "Error - can't send packet from char device: invalid packet size\n"); return -EINVAL; } @@ -193,16 +191,14 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, if (icmp_packet->header.packet_type != BAT_ICMP) { bat_dbg(DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: " - "got bogus packet type (expected: BAT_ICMP)\n"); + "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); len = -EINVAL; goto free_skb; } if (icmp_packet->msg_type != ECHO_REQUEST) { bat_dbg(DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: " - "got bogus message type (expected: ECHO_REQUEST)\n"); + "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); len = -EINVAL; goto free_skb; } diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 08f3b3a8e883..6d51caaf8cec 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -64,8 +64,8 @@ static int __init batman_init(void) register_netdevice_notifier(&hard_if_notifier); - pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) " - "loaded\n", SOURCE_VERSION, COMPAT_VERSION); + pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n", + SOURCE_VERSION, COMPAT_VERSION); return 0; } @@ -201,8 +201,8 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops) bat_algo_ops_tmp = bat_algo_get(bat_algo_ops->name); if (bat_algo_ops_tmp) { - pr_info("Trying to register already registered routing " - "algorithm: %s\n", bat_algo_ops->name); + pr_info("Trying to register already registered routing algorithm: %s\n", + bat_algo_ops->name); goto out; } diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 371cc93d8e17..43c0a4f1399e 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -294,14 +294,12 @@ static bool purge_orig_neighbors(struct bat_priv *bat_priv, (neigh_node->if_incoming->if_status == IF_TO_BE_REMOVED)) bat_dbg(DBG_BATMAN, bat_priv, - "neighbor purge: originator %pM, " - "neighbor: %pM, iface: %s\n", + "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", orig_node->orig, neigh_node->addr, neigh_node->if_incoming->net_dev->name); else bat_dbg(DBG_BATMAN, bat_priv, - "neighbor timeout: originator %pM, " - "neighbor: %pM, last_valid: %lu\n", + "neighbor timeout: originator %pM, neighbor: %pM, last_valid: %lu\n", orig_node->orig, neigh_node->addr, (neigh_node->last_valid / HZ)); @@ -416,15 +414,15 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) primary_if = primary_if_get_selected(bat_priv); if (!primary_if) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - " - "please specify interfaces to enable it\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - please specify interfaces to enable it\n", net_dev->name); goto out; } if (primary_if->if_status != IF_ACTIVE) { - ret = seq_printf(seq, "BATMAN mesh %s " - "disabled - primary interface not active\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); goto out; } diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index f53515562a4f..01b66d4a5aad 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -83,8 +83,7 @@ static void _update_route(struct bat_priv *bat_priv, /* route changed */ } else if (neigh_node && curr_router) { bat_dbg(DBG_ROUTES, bat_priv, - "Changing route towards: %pM " - "(now via %pM - was via %pM)\n", + "Changing route towards: %pM (now via %pM - was via %pM)\n", orig_node->orig, neigh_node->addr, curr_router->addr); } @@ -345,9 +344,8 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, /* send TTL exceeded if packet is an echo request (traceroute) */ if (icmp_packet->msg_type != ECHO_REQUEST) { - pr_debug("Warning - can't forward icmp packet from %pM to " - "%pM: ttl exceeded\n", icmp_packet->orig, - icmp_packet->dst); + pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n", + icmp_packet->orig, icmp_packet->dst); goto out; } @@ -674,9 +672,9 @@ int recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) if (!orig_node) goto out; - bat_dbg(DBG_TT, bat_priv, "Received ROAMING_ADV from %pM " - "(client %pM)\n", roam_adv_packet->src, - roam_adv_packet->client); + bat_dbg(DBG_TT, bat_priv, + "Received ROAMING_ADV from %pM (client %pM)\n", + roam_adv_packet->src, roam_adv_packet->client); tt_global_add(bat_priv, orig_node, roam_adv_packet->client, atomic_read(&orig_node->last_ttvn) + 1, true, false); @@ -813,9 +811,8 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) /* TTL exceeded */ if (unicast_packet->header.ttl < 2) { - pr_debug("Warning - can't forward unicast packet from %pM to " - "%pM: ttl exceeded\n", ethhdr->h_source, - unicast_packet->dest); + pr_debug("Warning - can't forward unicast packet from %pM to %pM: ttl exceeded\n", + ethhdr->h_source, unicast_packet->dest); goto out; } @@ -934,10 +931,10 @@ static int check_unicast_ttvn(struct bat_priv *bat_priv, orig_node_free_ref(orig_node); } - bat_dbg(DBG_ROUTES, bat_priv, "TTVN mismatch (old_ttvn %u " - "new_ttvn %u)! Rerouting unicast packet (for %pM) to " - "%pM\n", unicast_packet->ttvn, curr_ttvn, - ethhdr->h_dest, unicast_packet->dest); + bat_dbg(DBG_ROUTES, bat_priv, + "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", + unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, + unicast_packet->dest); unicast_packet->ttvn = curr_ttvn; } diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 413758065323..f261ccffbd9d 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -45,8 +45,8 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, goto send_skb_err; if (!(hard_iface->net_dev->flags & IFF_UP)) { - pr_warning("Interface %s is not up - can't send packet via " - "that interface!\n", hard_iface->net_dev->name); + pr_warning("Interface %s is not up - can't send packet via that interface!\n", + hard_iface->net_dev->name); goto send_skb_err; } diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index c39c120e1171..3ba057d93521 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -252,8 +252,8 @@ static void softif_neigh_vid_select(struct bat_priv *bat_priv, vid, curr_neigh->addr); else if ((curr_neigh) && (new_neigh)) bat_dbg(DBG_ROUTES, bat_priv, - "Changing mesh exit point on vid: %d from %pM " - "to %pM.\n", vid, curr_neigh->addr, new_neigh->addr); + "Changing mesh exit point on vid: %d from %pM to %pM.\n", + vid, curr_neigh->addr, new_neigh->addr); else if ((!curr_neigh) && (new_neigh)) bat_dbg(DBG_ROUTES, bat_priv, "Setting mesh exit point on vid: %d to %pM.\n", @@ -327,15 +327,15 @@ int softif_neigh_seq_print_text(struct seq_file *seq, void *offset) primary_if = primary_if_get_selected(bat_priv); if (!primary_if) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - " - "please specify interfaces to enable it\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - please specify interfaces to enable it\n", net_dev->name); goto out; } if (primary_if->if_status != IF_ACTIVE) { - ret = seq_printf(seq, "BATMAN mesh %s " - "disabled - primary interface not active\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); goto out; } @@ -403,8 +403,7 @@ void softif_neigh_purge(struct bat_priv *bat_priv) if (curr_softif_neigh == softif_neigh) { bat_dbg(DBG_ROUTES, bat_priv, - "Current mesh exit point on vid: %d " - "'%pM' vanished.\n", + "Current mesh exit point on vid: %d '%pM' vanished.\n", softif_neigh_vid->vid, softif_neigh->addr); do_deselect = 1; diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index c9507057c98e..1f8692127840 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -309,21 +309,21 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) primary_if = primary_if_get_selected(bat_priv); if (!primary_if) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - " - "please specify interfaces to enable it\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - please specify interfaces to enable it\n", net_dev->name); goto out; } if (primary_if->if_status != IF_ACTIVE) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - " - "primary interface not active\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); goto out; } - seq_printf(seq, "Locally retrieved addresses (from %s) " - "announced via TT (TTVN: %u):\n", + seq_printf(seq, + "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", net_dev->name, (uint8_t)atomic_read(&bat_priv->ttvn)); for (i = 0; i < hash->size; i++) { @@ -365,8 +365,9 @@ static void tt_local_set_pending(struct bat_priv *bat_priv, * response issued before the net ttvn increment (consistency check) */ tt_local_entry->common.flags |= TT_CLIENT_PENDING; - bat_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) pending to be removed: " - "%s\n", tt_local_entry->common.addr, message); + bat_dbg(DBG_TT, bat_priv, + "Local tt entry (%pM) pending to be removed: %s\n", + tt_local_entry->common.addr, message); } void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, @@ -574,15 +575,15 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) primary_if = primary_if_get_selected(bat_priv); if (!primary_if) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - please " - "specify interfaces to enable it\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - please specify interfaces to enable it\n", net_dev->name); goto out; } if (primary_if->if_status != IF_ACTIVE) { - ret = seq_printf(seq, "BATMAN mesh %s disabled - " - "primary interface not active\n", + ret = seq_printf(seq, + "BATMAN mesh %s disabled - primary interface not active\n", net_dev->name); goto out; } @@ -602,18 +603,18 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, common); - seq_printf(seq, " * %pM (%3u) via %pM (%3u) " - "[%c%c]\n", - tt_global_entry->common.addr, - tt_global_entry->ttvn, - tt_global_entry->orig_node->orig, - (uint8_t) atomic_read( + seq_printf(seq, + " * %pM (%3u) via %pM (%3u) [%c%c]\n", + tt_global_entry->common.addr, + tt_global_entry->ttvn, + tt_global_entry->orig_node->orig, + (uint8_t) atomic_read( &tt_global_entry->orig_node-> last_ttvn), - (tt_global_entry->common.flags & - TT_CLIENT_ROAM ? 'R' : '.'), - (tt_global_entry->common.flags & - TT_CLIENT_WIFI ? 'W' : '.')); + (tt_global_entry->common.flags & + TT_CLIENT_ROAM ? 'R' : '.'), + (tt_global_entry->common.flags & + TT_CLIENT_WIFI ? 'W' : '.')); } rcu_read_unlock(); } @@ -710,8 +711,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, common); if (tt_global_entry->orig_node == orig_node) { bat_dbg(DBG_TT, bat_priv, - "Deleting global tt entry %pM " - "(via %pM): %s\n", + "Deleting global tt entry %pM (via %pM): %s\n", tt_global_entry->common.addr, tt_global_entry->orig_node->orig, message); @@ -751,8 +751,8 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) TT_CLIENT_ROAM_TIMEOUT)) continue; - bat_dbg(DBG_TT, bat_priv, "Deleting global " - "tt entry (%pM): Roaming timeout\n", + bat_dbg(DBG_TT, bat_priv, + "Deleting global tt entry (%pM): Roaming timeout\n", tt_global_entry->common.addr); atomic_dec(&tt_global_entry->orig_node->tt_size); hlist_del_rcu(node); @@ -1134,8 +1134,9 @@ static int send_tt_request(struct bat_priv *bat_priv, if (!neigh_node) goto out; - bat_dbg(DBG_TT, bat_priv, "Sending TT_REQUEST to %pM via %pM " - "[%c]\n", dst_orig_node->orig, neigh_node->addr, + bat_dbg(DBG_TT, bat_priv, + "Sending TT_REQUEST to %pM via %pM [%c]\n", + dst_orig_node->orig, neigh_node->addr, (full_table ? 'F' : '.')); send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); @@ -1172,9 +1173,8 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, struct tt_query_packet *tt_response; bat_dbg(DBG_TT, bat_priv, - "Received TT_REQUEST from %pM for " - "ttvn: %u (%pM) [%c]\n", tt_request->src, - tt_request->ttvn, tt_request->dst, + "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", + tt_request->src, tt_request->ttvn, tt_request->dst, (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); /* Let's get the orig node of the REAL destination */ @@ -1299,9 +1299,8 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, struct tt_query_packet *tt_response; bat_dbg(DBG_TT, bat_priv, - "Received TT_REQUEST from %pM for " - "ttvn: %u (me) [%c]\n", tt_request->src, - tt_request->ttvn, + "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", + tt_request->src, tt_request->ttvn, (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); @@ -1504,10 +1503,9 @@ void handle_tt_response(struct bat_priv *bat_priv, struct tt_req_node *node, *safe; struct orig_node *orig_node = NULL; - bat_dbg(DBG_TT, bat_priv, "Received TT_RESPONSE from %pM for " - "ttvn %d t_size: %d [%c]\n", - tt_response->src, tt_response->ttvn, - tt_response->tt_data, + bat_dbg(DBG_TT, bat_priv, + "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", + tt_response->src, tt_response->ttvn, tt_response->tt_data, (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); orig_node = orig_hash_find(bat_priv, tt_response->src); @@ -1771,8 +1769,9 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) continue; - bat_dbg(DBG_TT, bat_priv, "Deleting local tt entry " - "(%pM): pending\n", tt_common_entry->addr); + bat_dbg(DBG_TT, bat_priv, + "Deleting local tt entry (%pM): pending\n", + tt_common_entry->addr); atomic_dec(&bat_priv->num_local_tt); hlist_del_rcu(node); @@ -1877,12 +1876,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, if (!orig_node->tt_initialised || ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { request_table: - bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " - "Need to retrieve the correct information " - "(ttvn: %u last_ttvn: %u crc: %u last_crc: " - "%u num_changes: %u)\n", orig_node->orig, ttvn, - orig_ttvn, tt_crc, orig_node->tt_crc, - tt_num_changes); + bat_dbg(DBG_TT, bat_priv, + "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", + orig_node->orig, ttvn, orig_ttvn, tt_crc, + orig_node->tt_crc, tt_num_changes); send_tt_request(bat_priv, orig_node, ttvn, tt_crc, full_table); return; -- GitLab From 21a1236bc3155c0c2efcce8ba03540fdf979ac00 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 7 Mar 2012 09:07:46 +0100 Subject: [PATCH 1636/1846] batman-adv: Don't begin block comments with only a /* line Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/bat_iv_ogm.c | 3 +-- net/batman-adv/main.h | 13 ++----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 677997b5c485..a6d5d63fb6ad 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -779,8 +779,7 @@ static int bat_iv_ogm_calc_tq(struct orig_node *orig_node, * information */ tq_own = (TQ_MAX_VALUE * total_count) / neigh_rq_count; - /* - * 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does + /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does * affect the nearly-symmetric links only a little, but * punishes asymmetric links more. This will give a value * between 0 and TQ_MAX_VALUE diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 1468788a9d64..94fa1c2393a6 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -107,9 +107,7 @@ enum uev_type { #define GW_THRESHOLD 50 -/* - * Debug Messages - */ +/* Debug Messages */ #ifdef pr_fmt #undef pr_fmt #endif @@ -124,14 +122,7 @@ enum dbg_level { DBG_ALL = 7 }; - -/* - * Vis - */ - -/* - * Kernel headers - */ +/* Kernel headers */ #include /* mutex */ #include /* needed by all modules */ -- GitLab From 96741ade15187bfde3dddc4092a88ba7a7c9183c Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 7 Mar 2012 09:07:47 +0100 Subject: [PATCH 1637/1846] batman-adv: Use {} braces consistent on the arms of a statement Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/routing.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 01b66d4a5aad..7f8e15899417 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -237,8 +237,9 @@ int window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, "old packet received, start protection\n"); return 0; - } else + } else { return 1; + } } return 0; } -- GitLab From 40e0c4f51d3fc3fd54edc797adae314fbe2b96a6 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 7 Mar 2012 09:07:48 +0100 Subject: [PATCH 1638/1846] batman-adv: Remove spaces after a cast Signed-off-by: Sven Eckelmann Signed-off-by: Marek Lindner --- net/batman-adv/send.c | 2 +- net/batman-adv/unicast.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index f261ccffbd9d..af7a6741a685 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -56,7 +56,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, skb_reset_mac_header(skb); - ethhdr = (struct ethhdr *) skb_mac_header(skb); + ethhdr = (struct ethhdr *)skb_mac_header(skb); memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 0897dfa72c59..676f6a626b2c 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c @@ -66,7 +66,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, kfree_skb(tmp_skb); memmove(skb->data + uni_diff, skb->data, hdr_len); - unicast_packet = (struct unicast_packet *) skb_pull(skb, uni_diff); + unicast_packet = (struct unicast_packet *)skb_pull(skb, uni_diff); unicast_packet->header.packet_type = BAT_UNICAST; return skb; @@ -238,7 +238,7 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, goto dropped; skb_reserve(frag_skb, ucf_hdr_len); - unicast_packet = (struct unicast_packet *) skb->data; + unicast_packet = (struct unicast_packet *)skb->data; memcpy(&tmp_uc, unicast_packet, uc_hdr_len); skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len); -- GitLab From 374458b3fe4288f820dbf3de0728e314d969f9e4 Mon Sep 17 00:00:00 2001 From: Dmitry Tarnyagin Date: Sun, 11 Mar 2012 10:28:31 +0000 Subject: [PATCH 1639/1846] caif: Fix for a race in socket transmit with flow control. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kill faulty checks on flow-off leading to connection drop at race conditions. caif_socket checks for flow-on before transmitting and goes to sleep or return -EAGAIN upon flow stop. Remove faulty subsequent checks on flow-off leading to connection drop. Also fix memory leaks on some of the errors paths. Signed-off-by: Sjur Brændeland Signed-off-by: David S. Miller --- net/caif/cfdbgl.c | 4 +++- net/caif/cfdgml.c | 9 +++++++-- net/caif/cfrfml.c | 25 +++++++++++-------------- net/caif/cfsrvl.c | 6 +----- net/caif/cfutill.c | 5 ++++- net/caif/cfvidl.c | 6 +++++- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/net/caif/cfdbgl.c b/net/caif/cfdbgl.c index 65d6ef3cf9aa..2914659eb9b2 100644 --- a/net/caif/cfdbgl.c +++ b/net/caif/cfdbgl.c @@ -41,8 +41,10 @@ static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt) struct caif_payload_info *info; int ret; - if (!cfsrvl_ready(service, &ret)) + if (!cfsrvl_ready(service, &ret)) { + cfpkt_destroy(pkt); return ret; + } /* Add info for MUX-layer to route the packet out */ info = cfpkt_info(pkt); diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c index 0f5ff27aa41c..a63f4a5f5aff 100644 --- a/net/caif/cfdgml.c +++ b/net/caif/cfdgml.c @@ -86,12 +86,17 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt) struct caif_payload_info *info; struct cfsrvl *service = container_obj(layr); int ret; - if (!cfsrvl_ready(service, &ret)) + + if (!cfsrvl_ready(service, &ret)) { + cfpkt_destroy(pkt); return ret; + } /* STE Modem cannot handle more than 1500 bytes datagrams */ - if (cfpkt_getlen(pkt) > DGM_MTU) + if (cfpkt_getlen(pkt) > DGM_MTU) { + cfpkt_destroy(pkt); return -EMSGSIZE; + } cfpkt_add_head(pkt, &zero, 3); packet_type = 0x08; /* B9 set - UNCLASSIFIED */ diff --git a/net/caif/cfrfml.c b/net/caif/cfrfml.c index 6dc75d4f8d94..2b563ad04597 100644 --- a/net/caif/cfrfml.c +++ b/net/caif/cfrfml.c @@ -184,6 +184,11 @@ static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt) rfml->serv.dev_info.id); } spin_unlock(&rfml->sync); + + if (unlikely(err == -EAGAIN)) + /* It is not possible to recover after drop of a fragment */ + err = -EIO; + return err; } @@ -218,7 +223,7 @@ static int cfrfml_transmit(struct cflayer *layr, struct cfpkt *pkt) caif_assert(layr->dn->transmit != NULL); if (!cfsrvl_ready(&rfml->serv, &err)) - return err; + goto out; err = -EPROTO; if (cfpkt_getlen(pkt) <= RFM_HEAD_SIZE-1) @@ -251,8 +256,11 @@ static int cfrfml_transmit(struct cflayer *layr, struct cfpkt *pkt) err = cfrfml_transmit_segment(rfml, frontpkt); - if (err != 0) + if (err != 0) { + frontpkt = NULL; goto out; + } + frontpkt = rearpkt; rearpkt = NULL; @@ -286,19 +294,8 @@ static int cfrfml_transmit(struct cflayer *layr, struct cfpkt *pkt) if (rearpkt) cfpkt_destroy(rearpkt); - if (frontpkt && frontpkt != pkt) { - + if (frontpkt) cfpkt_destroy(frontpkt); - /* - * Socket layer will free the original packet, - * but this packet may already be sent and - * freed. So we have to return 0 in this case - * to avoid socket layer to re-free this packet. - * The return of shutdown indication will - * cause connection to be invalidated anyhow. - */ - err = 0; - } } return err; diff --git a/net/caif/cfsrvl.c b/net/caif/cfsrvl.c index b99f5b22689d..4aa33d4496b6 100644 --- a/net/caif/cfsrvl.c +++ b/net/caif/cfsrvl.c @@ -174,15 +174,11 @@ void cfsrvl_init(struct cfsrvl *service, bool cfsrvl_ready(struct cfsrvl *service, int *err) { - if (service->open && service->modem_flow_on && service->phy_flow_on) - return true; if (!service->open) { *err = -ENOTCONN; return false; } - caif_assert(!(service->modem_flow_on && service->phy_flow_on)); - *err = -EAGAIN; - return false; + return true; } u8 cfsrvl_getphyid(struct cflayer *layer) diff --git a/net/caif/cfutill.c b/net/caif/cfutill.c index 53e49f3e3af3..86d2dadb4b73 100644 --- a/net/caif/cfutill.c +++ b/net/caif/cfutill.c @@ -84,8 +84,11 @@ static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt) caif_assert(layr != NULL); caif_assert(layr->dn != NULL); caif_assert(layr->dn->transmit != NULL); - if (!cfsrvl_ready(service, &ret)) + + if (!cfsrvl_ready(service, &ret)) { + cfpkt_destroy(pkt); return ret; + } cfpkt_add_head(pkt, &zero, 1); /* Add info for MUX-layer to route the packet out. */ diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c index e3f37db40ac3..a8e2a2d758a5 100644 --- a/net/caif/cfvidl.c +++ b/net/caif/cfvidl.c @@ -50,8 +50,12 @@ static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt) struct caif_payload_info *info; u32 videoheader = 0; int ret; - if (!cfsrvl_ready(service, &ret)) + + if (!cfsrvl_ready(service, &ret)) { + cfpkt_destroy(pkt); return ret; + } + cfpkt_add_head(pkt, &videoheader, 4); /* Add info for MUX-layer to route the packet out */ info = cfpkt_info(pkt); -- GitLab From e3abcc2a8538f7d5f64dbf85404bdf8a1d1581b3 Mon Sep 17 00:00:00 2001 From: "sjur.brandeland@stericsson.com" Date: Sun, 11 Mar 2012 10:28:32 +0000 Subject: [PATCH 1640/1846] caif: make zero a legal caif connetion id. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Connection ID configured through RTNL must allow zero as connection id. If connection-id is not given when creating the interface, configure a loopback interface using ifindex as connection-id. Signed-off-by: Sjur Brændeland Signed-off-by: David S. Miller --- net/caif/chnl_net.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c index e866234d0e5a..20618dd3088b 100644 --- a/net/caif/chnl_net.c +++ b/net/caif/chnl_net.c @@ -28,6 +28,7 @@ /* 5 sec. connect timeout */ #define CONNECT_TIMEOUT (5 * HZ) #define CAIF_NET_DEFAULT_QUEUE_LEN 500 +#define UNDEF_CONNID 0xffffffff /*This list is protected by the rtnl lock. */ static LIST_HEAD(chnl_net_list); @@ -408,7 +409,7 @@ static void ipcaif_net_setup(struct net_device *dev) priv->conn_req.link_selector = CAIF_LINK_HIGH_BANDW; priv->conn_req.priority = CAIF_PRIO_LOW; /* Insert illegal value */ - priv->conn_req.sockaddr.u.dgm.connection_id = 0; + priv->conn_req.sockaddr.u.dgm.connection_id = UNDEF_CONNID; priv->flowenabled = false; init_waitqueue_head(&priv->netmgmt_wq); @@ -471,9 +472,11 @@ static int ipcaif_newlink(struct net *src_net, struct net_device *dev, else list_add(&caifdev->list_field, &chnl_net_list); - /* Take ifindex as connection-id if null */ - if (caifdev->conn_req.sockaddr.u.dgm.connection_id == 0) + /* Use ifindex as connection id, and use loopback channel default. */ + if (caifdev->conn_req.sockaddr.u.dgm.connection_id == UNDEF_CONNID) { caifdev->conn_req.sockaddr.u.dgm.connection_id = dev->ifindex; + caifdev->conn_req.protocol = CAIFPROTO_DATAGRAM_LOOP; + } return ret; } -- GitLab From 5eac5f6d3706cc075c543007ad1e70150faac7ba Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 11 Mar 2012 11:16:25 +0000 Subject: [PATCH 1641/1846] drivers/atm/eni.c: ensure arguments to request_irq and free_irq are compatible Convert calls to free_irq so that the second argument is the same as the last argument of the corresponding call to request_irq. Without this property, free_irq does nothing. Signed-off-by: Julia Lawall Signed-off-by: David S. Miller --- drivers/atm/eni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index 956e9accb051..485a11a6de96 100644 --- a/drivers/atm/eni.c +++ b/drivers/atm/eni.c @@ -1873,7 +1873,7 @@ static int __devinit eni_start(struct atm_dev *dev) kfree(eni_dev->free_list); free_irq: - free_irq(eni_dev->irq, eni_dev); + free_irq(eni_dev->irq, dev); out: return error; -- GitLab From a997cbb330689f476646330a9708725dd1523aba Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sun, 11 Mar 2012 11:49:02 +0000 Subject: [PATCH 1642/1846] drivers/net/irda/{ali-ircc, via-ircc, w83977af-ir}.c: ensure arguments to request_irq and free_irq are compatible Convert calls to free_irq so that the second argument is the same as the last argument of the corresponding call to request_irq. Without this property, free_irq does nothing. Signed-off-by: Julia Lawall Signed-off-by: David S. Miller --- drivers/net/irda/ali-ircc.c | 2 +- drivers/net/irda/via-ircc.c | 4 ++-- drivers/net/irda/w83977af_ir.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index 963067d3bda2..dcc80d652b78 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c @@ -1368,7 +1368,7 @@ static int ali_ircc_net_open(struct net_device *dev) IRDA_WARNING("%s, unable to allocate dma=%d\n", ALI_IRCC_DRIVER_NAME, self->io.dma); - free_irq(self->io.irq, self); + free_irq(self->io.irq, dev); return -EAGAIN; } diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index 2d456dd164fb..1a89fd459dd5 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c @@ -1495,14 +1495,14 @@ static int via_ircc_net_open(struct net_device *dev) if (request_dma(self->io.dma, dev->name)) { IRDA_WARNING("%s, unable to allocate dma=%d\n", driver_name, self->io.dma); - free_irq(self->io.irq, self); + free_irq(self->io.irq, dev); return -EAGAIN; } if (self->io.dma2 != self->io.dma) { if (request_dma(self->io.dma2, dev->name)) { IRDA_WARNING("%s, unable to allocate dma2=%d\n", driver_name, self->io.dma2); - free_irq(self->io.irq, self); + free_irq(self->io.irq, dev); free_dma(self->io.dma); return -EAGAIN; } diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c index 7d43506c7032..f5bb92f15880 100644 --- a/drivers/net/irda/w83977af_ir.c +++ b/drivers/net/irda/w83977af_ir.c @@ -1172,7 +1172,7 @@ static int w83977af_net_open(struct net_device *dev) * and clean up on failure. */ if (request_dma(self->io.dma, dev->name)) { - free_irq(self->io.irq, self); + free_irq(self->io.irq, dev); return -EAGAIN; } -- GitLab From 5047fb5d1dfcc92cf2133f246c1fe7b447ec4e5f Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 10 Mar 2012 07:29:42 +0000 Subject: [PATCH 1643/1846] r8169: enable transmit time stamping. This patch has been tested on a machine with the Realtek RTL8101E/RTL8102E PCI Express Fast Ethernet controller (rev 05). Cc: Realtek linux nic maintainers Cc: Francois Romieu Signed-off-by: Richard Cochran Signed-off-by: David S. Miller --- drivers/net/ethernet/realtek/r8169.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 4aa419487ced..27c358c8f4dc 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -5154,6 +5154,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, netdev_sent_queue(dev, skb->len); + skb_tx_timestamp(skb); + wmb(); /* Anti gcc 2.95.3 bugware (sic) */ -- GitLab From 7fbc415d7bd0ff0224eea53c678fa9f13f646b4f Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 10 Mar 2012 01:55:53 +0000 Subject: [PATCH 1644/1846] MAINTAINERS: add an entry for the PHC code Some months ago, tglx asked me off list if I would maintain the PTP Hardware Clock code. Since then, the code has been fully merged, and I am actively looking after it. This patch makes it official. Signed-off-by: Richard Cochran Acked-by: John Stultz Signed-off-by: David S. Miller --- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0d01192651ef..209a386214c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5317,6 +5317,17 @@ L: cbe-oss-dev@lists.ozlabs.org S: Maintained F: drivers/block/ps3vram.c +PTP HARDWARE CLOCK SUPPORT +M: Richard Cochran +S: Maintained +W: http://linuxptp.sourceforge.net/ +F: Documentation/ABI/testing/sysfs-ptp +F: Documentation/ptp/* +F: drivers/net/gianfar_ptp.c +F: drivers/net/phy/dp83640* +F: drivers/ptp/* +F: include/linux/ptp_cl* + PTRACE SUPPORT M: Roland McGrath M: Oleg Nesterov -- GitLab From 8b2aaedee4eaa94e816144ed54b9707b96be29f8 Mon Sep 17 00:00:00 2001 From: Li Wei Date: Wed, 7 Mar 2012 14:58:07 +0000 Subject: [PATCH 1645/1846] ipv6: Fix Smatch warning. With commit d6ddef9e641d(IPv6: Fix not join all-router mcast group when forwarding set.) I check 'dev' after it's dereference that leads to a Smatch complaint: net/ipv6/addrconf.c:438 ipv6_add_dev() warn: variable dereferenced before check 'dev' (see line 432) net/ipv6/addrconf.c 431 /* protected by rtnl_lock */ 432 rcu_assign_pointer(dev->ip6_ptr, ndev); ^^^^^^^^^^^^ Old dereference. 433 434 /* Join all-node multicast group */ 435 ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes); 436 437 /* Join all-router multicast group if forwarding is set */ 438 if (ndev->cnf.forwarding && dev && (dev->flags & IFF_MULTICAST)) ^^^ Remove the check to avoid the complaint as 'dev' can't be NULL. Reported-by: Dan Carpenter Signed-off-by: Li Wei Signed-off-by: David S. Miller --- net/ipv6/addrconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 6b8ebc5da0e1..6a3bb6077e19 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -435,7 +435,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev) ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes); /* Join all-router multicast group if forwarding is set */ - if (ndev->cnf.forwarding && dev && (dev->flags & IFF_MULTICAST)) + if (ndev->cnf.forwarding && (dev->flags & IFF_MULTICAST)) ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters); return ndev; -- GitLab From 43db362d3adda9e0a915ddb9a8d1a41186e19179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Sun, 11 Mar 2012 12:51:50 +0000 Subject: [PATCH 1646/1846] net: get rid of some pointless casts to sockaddr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following 4 functions: move_addr_to_kernel move_addr_to_user verify_iovec verify_compat_iovec are always effectively called with a sockaddr_storage. Make this explicit by changing their signature. This removes a large number of casts from sockaddr_storage to sockaddr. Signed-off-by: Maciej Żenczykowski Signed-off-by: David S. Miller --- include/linux/socket.h | 4 ++-- include/net/compat.h | 2 +- net/compat.c | 2 +- net/core/iovec.c | 2 +- net/socket.c | 36 ++++++++++++++---------------------- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/include/linux/socket.h b/include/linux/socket.h index d0e77f607a79..da2d3e2543f3 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -326,11 +326,11 @@ extern int csum_partial_copy_fromiovecend(unsigned char *kdata, int offset, unsigned int len, __wsum *csump); -extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode); +extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode); extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len); extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata, int offset, int len); -extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *kaddr); +extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr); extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); struct timespec; diff --git a/include/net/compat.h b/include/net/compat.h index 9ee75edcc295..a974ae92d182 100644 --- a/include/net/compat.h +++ b/include/net/compat.h @@ -41,7 +41,7 @@ extern int compat_sock_get_timestampns(struct sock *, struct timespec __user *); #endif /* defined(CONFIG_COMPAT) */ extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *); -extern int verify_compat_iovec(struct msghdr *, struct iovec *, struct sockaddr *, int); +extern int verify_compat_iovec(struct msghdr *, struct iovec *, struct sockaddr_storage *, int); extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsigned); extern asmlinkage long compat_sys_sendmmsg(int, struct compat_mmsghdr __user *, unsigned, unsigned); diff --git a/net/compat.c b/net/compat.c index 6def90e0a112..64b4515a64e6 100644 --- a/net/compat.c +++ b/net/compat.c @@ -79,7 +79,7 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg) /* I've named the args so it is easy to tell whose space the pointers are in. */ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov, - struct sockaddr *kern_address, int mode) + struct sockaddr_storage *kern_address, int mode) { int tot_len; diff --git a/net/core/iovec.c b/net/core/iovec.c index c40f27e7d208..7e7aeb01de45 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c @@ -35,7 +35,7 @@ * in any case. */ -int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode) +int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode) { int size, ct, err; diff --git a/net/socket.c b/net/socket.c index 28a96af484b4..12a48d846223 100644 --- a/net/socket.c +++ b/net/socket.c @@ -181,7 +181,7 @@ static DEFINE_PER_CPU(int, sockets_in_use); * invalid addresses -EFAULT is returned. On a success 0 is returned. */ -int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *kaddr) +int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr) { if (ulen < 0 || ulen > sizeof(struct sockaddr_storage)) return -EINVAL; @@ -209,7 +209,7 @@ int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *kaddr) * specified. Zero is returned for a success. */ -static int move_addr_to_user(struct sockaddr *kaddr, int klen, +static int move_addr_to_user(struct sockaddr_storage *kaddr, int klen, void __user *uaddr, int __user *ulen) { int err; @@ -1449,7 +1449,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen) sock = sockfd_lookup_light(fd, &err, &fput_needed); if (sock) { - err = move_addr_to_kernel(umyaddr, addrlen, (struct sockaddr *)&address); + err = move_addr_to_kernel(umyaddr, addrlen, &address); if (err >= 0) { err = security_socket_bind(sock, (struct sockaddr *)&address, @@ -1556,7 +1556,7 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, err = -ECONNABORTED; goto out_fd; } - err = move_addr_to_user((struct sockaddr *)&address, + err = move_addr_to_user(&address, len, upeer_sockaddr, upeer_addrlen); if (err < 0) goto out_fd; @@ -1605,7 +1605,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr, sock = sockfd_lookup_light(fd, &err, &fput_needed); if (!sock) goto out; - err = move_addr_to_kernel(uservaddr, addrlen, (struct sockaddr *)&address); + err = move_addr_to_kernel(uservaddr, addrlen, &address); if (err < 0) goto out_put; @@ -1645,7 +1645,7 @@ SYSCALL_DEFINE3(getsockname, int, fd, struct sockaddr __user *, usockaddr, err = sock->ops->getname(sock, (struct sockaddr *)&address, &len, 0); if (err) goto out_put; - err = move_addr_to_user((struct sockaddr *)&address, len, usockaddr, usockaddr_len); + err = move_addr_to_user(&address, len, usockaddr, usockaddr_len); out_put: fput_light(sock->file, fput_needed); @@ -1677,7 +1677,7 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr, sock->ops->getname(sock, (struct sockaddr *)&address, &len, 1); if (!err) - err = move_addr_to_user((struct sockaddr *)&address, len, usockaddr, + err = move_addr_to_user(&address, len, usockaddr, usockaddr_len); fput_light(sock->file, fput_needed); } @@ -1716,7 +1716,7 @@ SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len, msg.msg_controllen = 0; msg.msg_namelen = 0; if (addr) { - err = move_addr_to_kernel(addr, addr_len, (struct sockaddr *)&address); + err = move_addr_to_kernel(addr, addr_len, &address); if (err < 0) goto out_put; msg.msg_name = (struct sockaddr *)&address; @@ -1779,7 +1779,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size, err = sock_recvmsg(sock, &msg, size, flags); if (err >= 0 && addr != NULL) { - err2 = move_addr_to_user((struct sockaddr *)&address, + err2 = move_addr_to_user(&address, msg.msg_namelen, addr, addr_len); if (err2 < 0) err = err2; @@ -1933,13 +1933,9 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg, /* This will also move the address data into kernel space */ if (MSG_CMSG_COMPAT & flags) { - err = verify_compat_iovec(msg_sys, iov, - (struct sockaddr *)&address, - VERIFY_READ); + err = verify_compat_iovec(msg_sys, iov, &address, VERIFY_READ); } else - err = verify_iovec(msg_sys, iov, - (struct sockaddr *)&address, - VERIFY_READ); + err = verify_iovec(msg_sys, iov, &address, VERIFY_READ); if (err < 0) goto out_freeiov; total_len = err; @@ -2143,13 +2139,9 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg, uaddr = (__force void __user *)msg_sys->msg_name; uaddr_len = COMPAT_NAMELEN(msg); if (MSG_CMSG_COMPAT & flags) { - err = verify_compat_iovec(msg_sys, iov, - (struct sockaddr *)&addr, - VERIFY_WRITE); + err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE); } else - err = verify_iovec(msg_sys, iov, - (struct sockaddr *)&addr, - VERIFY_WRITE); + err = verify_iovec(msg_sys, iov, &addr, VERIFY_WRITE); if (err < 0) goto out_freeiov; total_len = err; @@ -2166,7 +2158,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg, len = err; if (uaddr != NULL) { - err = move_addr_to_user((struct sockaddr *)&addr, + err = move_addr_to_user(&addr, msg_sys->msg_namelen, uaddr, uaddr_len); if (err < 0) -- GitLab From 058bd4d2a4ff0aaa4a5381c67e776729d840c785 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 11 Mar 2012 18:36:11 +0000 Subject: [PATCH 1647/1846] net: Convert printks to pr_ Use a more current kernel messaging style. Convert a printk block to print_hex_dump. Coalesce formats, align arguments. Use %s, __func__ instead of embedding function names. Some messages that were prefixed with _close are now prefixed with _fini. Some ah4 and esp messages are now not prefixed with "ip ". The intent of this patch is to later add something like #define pr_fmt(fmt) "IPv4: " fmt. to standardize the output messages. Text size is trivially reduced. (x86-32 allyesconfig) $ size net/ipv4/built-in.o* text data bss dec hex filename 887888 31558 249696 1169142 11d6f6 net/ipv4/built-in.o.new 887934 31558 249800 1169292 11d78c net/ipv4/built-in.o.old Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- net/ipv4/af_inet.c | 25 ++++----- net/ipv4/ah4.c | 14 ++--- net/ipv4/esp4.c | 8 +-- net/ipv4/fib_frontend.c | 6 +-- net/ipv4/fib_semantics.c | 2 +- net/ipv4/fib_trie.c | 5 +- net/ipv4/icmp.c | 19 +++---- net/ipv4/ip_fragment.c | 3 +- net/ipv4/ip_gre.c | 6 +-- net/ipv4/ip_input.c | 4 +- net/ipv4/ip_options.c | 2 +- net/ipv4/ipcomp.c | 8 +-- net/ipv4/ipconfig.c | 110 +++++++++++++++++++-------------------- net/ipv4/ipip.c | 4 +- net/ipv4/ipmr.c | 4 +- net/ipv4/ping.c | 18 +++---- net/ipv4/raw.c | 7 +-- net/ipv4/route.c | 43 +++++++-------- net/ipv4/tcp.c | 7 ++- net/ipv4/tcp_cong.c | 7 ++- net/ipv4/tcp_input.c | 8 +-- net/ipv4/tcp_ipv4.c | 8 +-- net/ipv4/tunnel4.c | 8 +-- net/ipv4/udplite.c | 4 +- net/ipv4/xfrm4_tunnel.c | 14 ++--- 25 files changed, 163 insertions(+), 181 deletions(-) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index e588a34e85c2..b7a946611f2f 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1085,13 +1085,11 @@ void inet_register_protosw(struct inet_protosw *p) return; out_permanent: - printk(KERN_ERR "Attempt to override permanent protocol %d.\n", - protocol); + pr_err("Attempt to override permanent protocol %d\n", protocol); goto out; out_illegal: - printk(KERN_ERR - "Ignoring attempt to register invalid socket type %d.\n", + pr_err("Ignoring attempt to register invalid socket type %d\n", p->type); goto out; } @@ -1100,8 +1098,7 @@ EXPORT_SYMBOL(inet_register_protosw); void inet_unregister_protosw(struct inet_protosw *p) { if (INET_PROTOSW_PERMANENT & p->flags) { - printk(KERN_ERR - "Attempt to unregister permanent protocol %d.\n", + pr_err("Attempt to unregister permanent protocol %d\n", p->protocol); } else { spin_lock_bh(&inetsw_lock); @@ -1150,8 +1147,8 @@ static int inet_sk_reselect_saddr(struct sock *sk) return 0; if (sysctl_ip_dynaddr > 1) { - printk(KERN_INFO "%s(): shifting inet->saddr from %pI4 to %pI4\n", - __func__, &old_saddr, &new_saddr); + pr_info("%s(): shifting inet->saddr from %pI4 to %pI4\n", + __func__, &old_saddr, &new_saddr); } inet->inet_saddr = inet->inet_rcv_saddr = new_saddr; @@ -1680,14 +1677,14 @@ static int __init inet_init(void) */ if (inet_add_protocol(&icmp_protocol, IPPROTO_ICMP) < 0) - printk(KERN_CRIT "inet_init: Cannot add ICMP protocol\n"); + pr_crit("%s: Cannot add ICMP protocol\n", __func__); if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0) - printk(KERN_CRIT "inet_init: Cannot add UDP protocol\n"); + pr_crit("%s: Cannot add UDP protocol\n", __func__); if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0) - printk(KERN_CRIT "inet_init: Cannot add TCP protocol\n"); + pr_crit("%s: Cannot add TCP protocol\n", __func__); #ifdef CONFIG_IP_MULTICAST if (inet_add_protocol(&igmp_protocol, IPPROTO_IGMP) < 0) - printk(KERN_CRIT "inet_init: Cannot add IGMP protocol\n"); + pr_crit("%s: Cannot add IGMP protocol\n", __func__); #endif /* Register the socket-side information for inet_create. */ @@ -1734,14 +1731,14 @@ static int __init inet_init(void) */ #if defined(CONFIG_IP_MROUTE) if (ip_mr_init()) - printk(KERN_CRIT "inet_init: Cannot init ipv4 mroute\n"); + pr_crit("%s: Cannot init ipv4 mroute\n", __func__); #endif /* * Initialise per-cpu ipv4 mibs */ if (init_ipv4_mibs()) - printk(KERN_CRIT "inet_init: Cannot init ipv4 mibs\n"); + pr_crit("%s: Cannot init ipv4 mibs\n", __func__); ipv4_proc_init(); diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 36d14406261e..b5524660c81d 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -445,9 +445,9 @@ static int ah_init_state(struct xfrm_state *x) if (aalg_desc->uinfo.auth.icv_fullbits/8 != crypto_ahash_digestsize(ahash)) { - printk(KERN_INFO "AH: %s digestsize %u != %hu\n", - x->aalg->alg_name, crypto_ahash_digestsize(ahash), - aalg_desc->uinfo.auth.icv_fullbits/8); + pr_info("AH: %s digestsize %u != %hu\n", + x->aalg->alg_name, crypto_ahash_digestsize(ahash), + aalg_desc->uinfo.auth.icv_fullbits/8); goto error; } @@ -510,11 +510,11 @@ static const struct net_protocol ah4_protocol = { static int __init ah4_init(void) { if (xfrm_register_type(&ah_type, AF_INET) < 0) { - printk(KERN_INFO "ip ah init: can't add xfrm type\n"); + pr_info("%s: can't add xfrm type\n", __func__); return -EAGAIN; } if (inet_add_protocol(&ah4_protocol, IPPROTO_AH) < 0) { - printk(KERN_INFO "ip ah init: can't add protocol\n"); + pr_info("%s: can't add protocol\n", __func__); xfrm_unregister_type(&ah_type, AF_INET); return -EAGAIN; } @@ -524,9 +524,9 @@ static int __init ah4_init(void) static void __exit ah4_fini(void) { if (inet_del_protocol(&ah4_protocol, IPPROTO_AH) < 0) - printk(KERN_INFO "ip ah close: can't remove protocol\n"); + pr_info("%s: can't remove protocol\n", __func__); if (xfrm_unregister_type(&ah_type, AF_INET) < 0) - printk(KERN_INFO "ip ah close: can't remove xfrm type\n"); + pr_info("%s: can't remove xfrm type\n", __func__); } module_init(ah4_init); diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index a5b413416da3..0a86dbe9454b 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -706,11 +706,11 @@ static const struct net_protocol esp4_protocol = { static int __init esp4_init(void) { if (xfrm_register_type(&esp_type, AF_INET) < 0) { - printk(KERN_INFO "ip esp init: can't add xfrm type\n"); + pr_info("%s: can't add xfrm type\n", __func__); return -EAGAIN; } if (inet_add_protocol(&esp4_protocol, IPPROTO_ESP) < 0) { - printk(KERN_INFO "ip esp init: can't add protocol\n"); + pr_info("%s: can't add protocol\n", __func__); xfrm_unregister_type(&esp_type, AF_INET); return -EAGAIN; } @@ -720,9 +720,9 @@ static int __init esp4_init(void) static void __exit esp4_fini(void) { if (inet_del_protocol(&esp4_protocol, IPPROTO_ESP) < 0) - printk(KERN_INFO "ip esp close: can't remove protocol\n"); + pr_info("%s: can't remove protocol\n", __func__); if (xfrm_unregister_type(&esp_type, AF_INET) < 0) - printk(KERN_INFO "ip esp close: can't remove xfrm type\n"); + pr_info("%s: can't remove xfrm type\n", __func__); } module_init(esp4_init); diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 92fc5f69f5da..76e72bacc217 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -695,7 +695,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa) if (ifa->ifa_flags & IFA_F_SECONDARY) { prim = inet_ifa_byprefix(in_dev, prefix, mask); if (prim == NULL) { - printk(KERN_WARNING "fib_add_ifaddr: bug: prim == NULL\n"); + pr_warn("%s: bug: prim == NULL\n", __func__); return; } } @@ -749,11 +749,11 @@ void fib_del_ifaddr(struct in_ifaddr *ifa, struct in_ifaddr *iprim) if (ifa->ifa_flags & IFA_F_SECONDARY) { prim = inet_ifa_byprefix(in_dev, any, ifa->ifa_mask); if (prim == NULL) { - printk(KERN_WARNING "fib_del_ifaddr: bug: prim == NULL\n"); + pr_warn("%s: bug: prim == NULL\n", __func__); return; } if (iprim && iprim != prim) { - printk(KERN_WARNING "fib_del_ifaddr: bug: iprim != prim\n"); + pr_warn("%s: bug: iprim != prim\n", __func__); return; } } else if (!ipv4_is_zeronet(any) && diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 80106d89d548..a8c5c1d6715b 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -154,7 +154,7 @@ static void free_fib_info_rcu(struct rcu_head *head) void free_fib_info(struct fib_info *fi) { if (fi->fib_dead == 0) { - pr_warning("Freeing alive fib_info %p\n", fi); + pr_warn("Freeing alive fib_info %p\n", fi); return; } change_nexthops(fi) { diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 2b555a5521e0..da9b9cb2282d 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -1170,9 +1170,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen) } if (tp && tp->pos + tp->bits > 32) - pr_warning("fib_trie" - " tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", - tp, tp->pos, tp->bits, key, plen); + pr_warn("fib_trie tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", + tp, tp->pos, tp->bits, key, plen); /* Rebalance the trie */ diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index ab188ae12fd9..5c7323b7810f 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -670,7 +670,7 @@ static void icmp_unreach(struct sk_buff *skb) break; case ICMP_FRAG_NEEDED: if (ipv4_config.no_pmtu_disc) { - LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set.\n", + LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set\n", &iph->daddr); } else { info = ip_rt_frag_needed(net, iph, @@ -681,7 +681,7 @@ static void icmp_unreach(struct sk_buff *skb) } break; case ICMP_SR_FAILED: - LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed.\n", + LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed\n", &iph->daddr); break; default: @@ -713,13 +713,10 @@ static void icmp_unreach(struct sk_buff *skb) if (!net->ipv4.sysctl_icmp_ignore_bogus_error_responses && inet_addr_type(net, iph->daddr) == RTN_BROADCAST) { if (net_ratelimit()) - printk(KERN_WARNING "%pI4 sent an invalid ICMP " - "type %u, code %u " - "error to a broadcast: %pI4 on %s\n", - &ip_hdr(skb)->saddr, - icmph->type, icmph->code, - &iph->daddr, - skb->dev->name); + pr_warn("%pI4 sent an invalid ICMP type %u, code %u error to a broadcast: %pI4 on %s\n", + &ip_hdr(skb)->saddr, + icmph->type, icmph->code, + &iph->daddr, skb->dev->name); goto out; } @@ -946,8 +943,8 @@ static void icmp_address_reply(struct sk_buff *skb) break; } if (!ifa && net_ratelimit()) { - printk(KERN_INFO "Wrong address mask %pI4 from %s/%pI4\n", - mp, dev->name, &ip_hdr(skb)->saddr); + pr_info("Wrong address mask %pI4 from %s/%pI4\n", + mp, dev->name, &ip_hdr(skb)->saddr); } } } diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 1f23a57aa9e6..b2fd333abd59 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -643,8 +643,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, goto out_fail; out_oversize: if (net_ratelimit()) - printk(KERN_INFO "Oversized IP packet from %pI4.\n", - &qp->saddr); + pr_info("Oversized IP packet from %pI4\n", &qp->saddr); out_fail: IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS); return err; diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 6ef66af12291..185e0a75ecec 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1716,7 +1716,7 @@ static int __init ipgre_init(void) { int err; - printk(KERN_INFO "GRE over IPv4 tunneling driver\n"); + pr_info("GRE over IPv4 tunneling driver\n"); err = register_pernet_device(&ipgre_net_ops); if (err < 0) @@ -1724,7 +1724,7 @@ static int __init ipgre_init(void) err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO); if (err < 0) { - printk(KERN_INFO "ipgre init: can't add protocol\n"); + pr_info("%s: can't add protocol\n", __func__); goto add_proto_failed; } @@ -1753,7 +1753,7 @@ static void __exit ipgre_fini(void) rtnl_link_unregister(&ipgre_tap_ops); rtnl_link_unregister(&ipgre_link_ops); if (gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0) - printk(KERN_INFO "ipgre close: can't remove protocol\n"); + pr_info("%s: can't remove protocol\n", __func__); unregister_pernet_device(&ipgre_net_ops); } diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index bdaa2c5c28e4..de8e9be4aac8 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -299,8 +299,8 @@ static inline bool ip_rcv_options(struct sk_buff *skb) if (!IN_DEV_SOURCE_ROUTE(in_dev)) { if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) - printk(KERN_INFO "source route option %pI4 -> %pI4\n", - &iph->saddr, &iph->daddr); + pr_info("source route option %pI4 -> %pI4\n", + &iph->saddr, &iph->daddr); goto drop; } } diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 42dd1a90edea..e25ee7c8bdde 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -577,7 +577,7 @@ void ip_forward_options(struct sk_buff *skb) ip_rt_get_source(&optptr[srrptr-1], skb, rt); optptr[2] = srrptr+4; } else if (net_ratelimit()) - printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n"); + pr_crit("%s(): Argh! Destination lost!\n", __func__); if (opt->ts_needaddr) { optptr = raw + opt->ts; ip_rt_get_source(&optptr[optptr[2]-9], skb, rt); diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index c857f6f49b03..63b64c45a826 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c @@ -156,11 +156,11 @@ static const struct net_protocol ipcomp4_protocol = { static int __init ipcomp4_init(void) { if (xfrm_register_type(&ipcomp_type, AF_INET) < 0) { - printk(KERN_INFO "ipcomp init: can't add xfrm type\n"); + pr_info("%s: can't add xfrm type\n", __func__); return -EAGAIN; } if (inet_add_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) { - printk(KERN_INFO "ipcomp init: can't add protocol\n"); + pr_info("%s: can't add protocol\n", __func__); xfrm_unregister_type(&ipcomp_type, AF_INET); return -EAGAIN; } @@ -170,9 +170,9 @@ static int __init ipcomp4_init(void) static void __exit ipcomp4_fini(void) { if (inet_del_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) - printk(KERN_INFO "ip ipcomp close: can't remove protocol\n"); + pr_info("%s: can't remove protocol\n", __func__); if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0) - printk(KERN_INFO "ip ipcomp close: can't remove xfrm type\n"); + pr_info("%s: can't remove xfrm type\n", __func__); } module_init(ipcomp4_init); diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 6e412a60a91f..92ac7e7363a0 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -214,7 +214,7 @@ static int __init ic_open_devs(void) if (!(dev->flags & IFF_LOOPBACK)) continue; if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) - printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name); + pr_err("IP-Config: Failed to open %s\n", dev->name); } for_each_netdev(&init_net, dev) { @@ -223,7 +223,8 @@ static int __init ic_open_devs(void) if (dev->mtu >= 364) able |= IC_BOOTP; else - printk(KERN_WARNING "DHCP/BOOTP: Ignoring device %s, MTU %d too small", dev->name, dev->mtu); + pr_warn("DHCP/BOOTP: Ignoring device %s, MTU %d too small", + dev->name, dev->mtu); if (!(dev->flags & IFF_NOARP)) able |= IC_RARP; able &= ic_proto_enabled; @@ -231,7 +232,8 @@ static int __init ic_open_devs(void) continue; oflags = dev->flags; if (dev_change_flags(dev, oflags | IFF_UP) < 0) { - printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name); + pr_err("IP-Config: Failed to open %s\n", + dev->name); continue; } if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) { @@ -273,9 +275,10 @@ static int __init ic_open_devs(void) if (!ic_first_dev) { if (user_dev_name[0]) - printk(KERN_ERR "IP-Config: Device `%s' not found.\n", user_dev_name); + pr_err("IP-Config: Device `%s' not found\n", + user_dev_name); else - printk(KERN_ERR "IP-Config: No network devices available.\n"); + pr_err("IP-Config: No network devices available\n"); return -ENODEV; } return 0; @@ -359,17 +362,20 @@ static int __init ic_setup_if(void) strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name); set_sockaddr(sin, ic_myaddr, 0); if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) { - printk(KERN_ERR "IP-Config: Unable to set interface address (%d).\n", err); + pr_err("IP-Config: Unable to set interface address (%d)\n", + err); return -1; } set_sockaddr(sin, ic_netmask, 0); if ((err = ic_devinet_ioctl(SIOCSIFNETMASK, &ir)) < 0) { - printk(KERN_ERR "IP-Config: Unable to set interface netmask (%d).\n", err); + pr_err("IP-Config: Unable to set interface netmask (%d)\n", + err); return -1; } set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0); if ((err = ic_devinet_ioctl(SIOCSIFBRDADDR, &ir)) < 0) { - printk(KERN_ERR "IP-Config: Unable to set interface broadcast address (%d).\n", err); + pr_err("IP-Config: Unable to set interface broadcast address (%d)\n", + err); return -1; } /* Handle the case where we need non-standard MTU on the boot link (a network @@ -380,8 +386,8 @@ static int __init ic_setup_if(void) strcpy(ir.ifr_name, ic_dev->name); ir.ifr_mtu = ic_dev_mtu; if ((err = ic_dev_ioctl(SIOCSIFMTU, &ir)) < 0) - printk(KERN_ERR "IP-Config: Unable to set interface mtu to %d (%d).\n", - ic_dev_mtu, err); + pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n", + ic_dev_mtu, err); } return 0; } @@ -396,7 +402,7 @@ static int __init ic_setup_routes(void) memset(&rm, 0, sizeof(rm)); if ((ic_gateway ^ ic_myaddr) & ic_netmask) { - printk(KERN_ERR "IP-Config: Gateway not on directly connected network.\n"); + pr_err("IP-Config: Gateway not on directly connected network\n"); return -1; } set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0); @@ -404,7 +410,8 @@ static int __init ic_setup_routes(void) set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0); rm.rt_flags = RTF_UP | RTF_GATEWAY; if ((err = ic_route_ioctl(SIOCADDRT, &rm)) < 0) { - printk(KERN_ERR "IP-Config: Cannot add default route (%d).\n", err); + pr_err("IP-Config: Cannot add default route (%d)\n", + err); return -1; } } @@ -437,8 +444,8 @@ static int __init ic_defaults(void) else if (IN_CLASSC(ntohl(ic_myaddr))) ic_netmask = htonl(IN_CLASSC_NET); else { - printk(KERN_ERR "IP-Config: Unable to guess netmask for address %pI4\n", - &ic_myaddr); + pr_err("IP-Config: Unable to guess netmask for address %pI4\n", + &ic_myaddr); return -1; } printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask); @@ -688,8 +695,8 @@ ic_dhcp_init_options(u8 *options) e += len; } if (*vendor_class_identifier) { - printk(KERN_INFO "DHCP: sending class identifier \"%s\"\n", - vendor_class_identifier); + pr_info("DHCP: sending class identifier \"%s\"\n", + vendor_class_identifier); *e++ = 60; /* Class-identifier */ len = strlen(vendor_class_identifier); *e++ = len; @@ -949,8 +956,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str /* Fragments are not supported */ if (ip_is_fragment(h)) { if (net_ratelimit()) - printk(KERN_ERR "DHCP/BOOTP: Ignoring fragmented " - "reply.\n"); + pr_err("DHCP/BOOTP: Ignoring fragmented reply\n"); goto drop; } @@ -999,8 +1005,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str if (b->op != BOOTP_REPLY || b->xid != d->xid) { if (net_ratelimit()) - printk(KERN_ERR "DHCP/BOOTP: Reply not for us, " - "op[%x] xid[%x]\n", + pr_err("DHCP/BOOTP: Reply not for us, op[%x] xid[%x]\n", b->op, b->xid); goto drop_unlock; } @@ -1008,7 +1013,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str /* Is it a reply for the device we are configuring? */ if (b->xid != ic_dev_xid) { if (net_ratelimit()) - printk(KERN_ERR "DHCP/BOOTP: Ignoring delayed packet\n"); + pr_err("DHCP/BOOTP: Ignoring delayed packet\n"); goto drop_unlock; } @@ -1146,17 +1151,17 @@ static int __init ic_dynamic(void) * are missing, and without DHCP/BOOTP/RARP we are unable to get it. */ if (!ic_proto_enabled) { - printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n"); + pr_err("IP-Config: Incomplete network configuration information\n"); return -1; } #ifdef IPCONFIG_BOOTP if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP) - printk(KERN_ERR "DHCP/BOOTP: No suitable device found.\n"); + pr_err("DHCP/BOOTP: No suitable device found\n"); #endif #ifdef IPCONFIG_RARP if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP) - printk(KERN_ERR "RARP: No suitable device found.\n"); + pr_err("RARP: No suitable device found\n"); #endif if (!ic_proto_have_if) @@ -1183,11 +1188,11 @@ static int __init ic_dynamic(void) * [Actually we could now, but the nothing else running note still * applies.. - AC] */ - printk(KERN_NOTICE "Sending %s%s%s requests .", - do_bootp - ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "", - (do_bootp && do_rarp) ? " and " : "", - do_rarp ? "RARP" : ""); + pr_notice("Sending %s%s%s requests .", + do_bootp + ? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "", + (do_bootp && do_rarp) ? " and " : "", + do_rarp ? "RARP" : ""); start_jiffies = jiffies; d = ic_first_dev; @@ -1216,13 +1221,13 @@ static int __init ic_dynamic(void) (ic_proto_enabled & IC_USE_DHCP) && ic_dhcp_msgtype != DHCPACK) { ic_got_reply = 0; - printk(KERN_CONT ","); + pr_cont(","); continue; } #endif /* IPCONFIG_DHCP */ if (ic_got_reply) { - printk(KERN_CONT " OK\n"); + pr_cont(" OK\n"); break; } @@ -1230,7 +1235,7 @@ static int __init ic_dynamic(void) continue; if (! --retries) { - printk(KERN_CONT " timed out!\n"); + pr_cont(" timed out!\n"); break; } @@ -1240,7 +1245,7 @@ static int __init ic_dynamic(void) if (timeout > CONF_TIMEOUT_MAX) timeout = CONF_TIMEOUT_MAX; - printk(KERN_CONT "."); + pr_cont("."); } #ifdef IPCONFIG_BOOTP @@ -1260,8 +1265,8 @@ static int __init ic_dynamic(void) printk("IP-Config: Got %s answer from %pI4, ", ((ic_got_reply & IC_RARP) ? "RARP" : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"), - &ic_servaddr); - printk(KERN_CONT "my address is %pI4\n", &ic_myaddr); + &ic_servaddr); + pr_cont("my address is %pI4\n", &ic_myaddr); return 0; } @@ -1437,24 +1442,22 @@ static int __init ip_auto_config(void) */ #ifdef CONFIG_ROOT_NFS if (ROOT_DEV == Root_NFS) { - printk(KERN_ERR - "IP-Config: Retrying forever (NFS root)...\n"); + pr_err("IP-Config: Retrying forever (NFS root)...\n"); goto try_try_again; } #endif if (--retries) { - printk(KERN_ERR - "IP-Config: Reopening network devices...\n"); + pr_err("IP-Config: Reopening network devices...\n"); goto try_try_again; } /* Oh, well. At least we tried. */ - printk(KERN_ERR "IP-Config: Auto-configuration of network failed.\n"); + pr_err("IP-Config: Auto-configuration of network failed\n"); return -1; } #else /* !DYNAMIC */ - printk(KERN_ERR "IP-Config: Incomplete network configuration information.\n"); + pr_err("IP-Config: Incomplete network configuration information\n"); ic_close_devs(); return -1; #endif /* IPCONFIG_DYNAMIC */ @@ -1492,19 +1495,16 @@ static int __init ip_auto_config(void) /* * Clue in the operator. */ - printk("IP-Config: Complete:\n"); - printk(" device=%s", ic_dev->name); - printk(KERN_CONT ", addr=%pI4", &ic_myaddr); - printk(KERN_CONT ", mask=%pI4", &ic_netmask); - printk(KERN_CONT ", gw=%pI4", &ic_gateway); - printk(KERN_CONT ",\n host=%s, domain=%s, nis-domain=%s", - utsname()->nodename, ic_domain, utsname()->domainname); - printk(KERN_CONT ",\n bootserver=%pI4", &ic_servaddr); - printk(KERN_CONT ", rootserver=%pI4", &root_server_addr); - printk(KERN_CONT ", rootpath=%s", root_server_path); + pr_info("IP-Config: Complete:\n"); + pr_info(" device=%s, addr=%pI4, mask=%pI4, gw=%pI4\n", + ic_dev->name, &ic_myaddr, &ic_netmask, &ic_gateway); + pr_info(" host=%s, domain=%s, nis-domain=%s\n", + utsname()->nodename, ic_domain, utsname()->domainname); + pr_info(" bootserver=%pI4, rootserver=%pI4, rootpath=%s", + &ic_servaddr, &root_server_addr, root_server_path); if (ic_dev_mtu) - printk(KERN_CONT ", mtu=%d", ic_dev_mtu); - printk(KERN_CONT "\n"); + pr_cont(", mtu=%d", ic_dev_mtu); + pr_cont("\n"); #endif /* !SILENT */ return 0; @@ -1637,8 +1637,8 @@ static int __init vendor_class_identifier_setup(char *addrs) if (strlcpy(vendor_class_identifier, addrs, sizeof(vendor_class_identifier)) >= sizeof(vendor_class_identifier)) - printk(KERN_WARNING "DHCP: vendorclass too long, truncated to \"%s\"", - vendor_class_identifier); + pr_warn("DHCP: vendorclass too long, truncated to \"%s\"", + vendor_class_identifier); return 1; } diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index f84ebff5cdb0..ae1413e3f2f8 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -892,7 +892,7 @@ static int __init ipip_init(void) err = xfrm4_tunnel_register(&ipip_handler, AF_INET); if (err < 0) { unregister_pernet_device(&ipip_net_ops); - printk(KERN_INFO "ipip init: can't register tunnel\n"); + pr_info("%s: can't register tunnel\n", __func__); } return err; } @@ -900,7 +900,7 @@ static int __init ipip_init(void) static void __exit ipip_fini(void) { if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET)) - printk(KERN_INFO "ipip close: can't deregister tunnel\n"); + pr_info("%s: can't deregister tunnel\n", __func__); unregister_pernet_device(&ipip_net_ops); } diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 7bc2db6db8d4..0518a4fb177b 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -951,7 +951,7 @@ static int ipmr_cache_report(struct mr_table *mrt, rcu_read_unlock(); if (ret < 0) { if (net_ratelimit()) - printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n"); + pr_warn("mroute: pending queue full, dropping entries\n"); kfree_skb(skb); } @@ -2538,7 +2538,7 @@ int __init ip_mr_init(void) goto reg_notif_fail; #ifdef CONFIG_IP_PIMSM_V2 if (inet_add_protocol(&pim_protocol, IPPROTO_PIM) < 0) { - printk(KERN_ERR "ip_mr_init: can't add PIM protocol\n"); + pr_err("%s: can't add PIM protocol\n", __func__); err = -EAGAIN; goto add_proto_fail; } diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 4398a45a9600..ab6b36e6da15 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -156,7 +156,7 @@ static struct sock *ping_v4_lookup(struct net *net, __be32 saddr, __be32 daddr, struct hlist_nulls_node *hnode; pr_debug("try to find: num = %d, daddr = %pI4, dif = %d\n", - (int)ident, &daddr, dif); + (int)ident, &daddr, dif); read_lock_bh(&ping_table.lock); ping_portaddr_for_each_entry(sk, hnode, hslot) { @@ -229,7 +229,7 @@ static int ping_init_sock(struct sock *sk) static void ping_close(struct sock *sk, long timeout) { pr_debug("ping_close(sk=%p,sk->num=%u)\n", - inet_sk(sk), inet_sk(sk)->inet_num); + inet_sk(sk), inet_sk(sk)->inet_num); pr_debug("isk->refcnt = %d\n", sk->sk_refcnt.counter); sk_common_release(sk); @@ -252,7 +252,7 @@ static int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) return -EINVAL; pr_debug("ping_v4_bind(sk=%p,sa_addr=%08x,sa_port=%d)\n", - sk, addr->sin_addr.s_addr, ntohs(addr->sin_port)); + sk, addr->sin_addr.s_addr, ntohs(addr->sin_port)); chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); if (addr->sin_addr.s_addr == htonl(INADDR_ANY)) @@ -280,9 +280,9 @@ static int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) } pr_debug("after bind(): num = %d, daddr = %pI4, dif = %d\n", - (int)isk->inet_num, - &isk->inet_rcv_saddr, - (int)sk->sk_bound_dev_if); + (int)isk->inet_num, + &isk->inet_rcv_saddr, + (int)sk->sk_bound_dev_if); err = 0; if (isk->inet_rcv_saddr) @@ -335,7 +335,7 @@ void ping_err(struct sk_buff *skb, u32 info) return; pr_debug("ping_err(type=%04x,code=%04x,id=%04x,seq=%04x)\n", type, - code, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); + code, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); sk = ping_v4_lookup(net, iph->daddr, iph->saddr, ntohs(icmph->un.echo.id), skb->dev->ifindex); @@ -679,7 +679,7 @@ static int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, static int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", - inet_sk(sk), inet_sk(sk)->inet_num, skb); + inet_sk(sk), inet_sk(sk)->inet_num, skb); if (sock_queue_rcv_skb(sk, skb) < 0) { kfree_skb(skb); pr_debug("ping_queue_rcv_skb -> failed\n"); @@ -705,7 +705,7 @@ void ping_rcv(struct sk_buff *skb) /* We assume the packet has already been checked by icmp_rcv */ pr_debug("ping_rcv(skb=%p,id=%04x,seq=%04x)\n", - skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); + skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); /* Push ICMP header back */ skb_push(skb, skb->data - (u8 *)icmph); diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index ab466305b629..bbd604c68e68 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -491,11 +491,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, if (msg->msg_namelen < sizeof(*usin)) goto out; if (usin->sin_family != AF_INET) { - static int complained; - if (!complained++) - printk(KERN_INFO "%s forgot to set AF_INET in " - "raw sendmsg. Fix it!\n", - current->comm); + pr_info_once("%s: %s forgot to set AF_INET. Fix it!\n", + __func__, current->comm); err = -EAFNOSUPPORT; if (usin->sin_family) goto out; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 815989b90dea..cbda6de0a77c 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -959,7 +959,7 @@ void rt_cache_flush_batch(struct net *net) static void rt_emergency_hash_rebuild(struct net *net) { if (net_ratelimit()) - printk(KERN_WARNING "Route hash chain too long!\n"); + pr_warn("Route hash chain too long!\n"); rt_cache_invalidate(net); } @@ -1083,7 +1083,7 @@ static int rt_garbage_collect(struct dst_ops *ops) if (dst_entries_get_slow(&ipv4_dst_ops) < ip_rt_max_size) goto out; if (net_ratelimit()) - printk(KERN_WARNING "dst cache overflow\n"); + pr_warn("dst cache overflow\n"); RT_CACHE_STAT_INC(gc_dst_overflow); return 1; @@ -1181,8 +1181,7 @@ static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, int err = rt_bind_neighbour(rt); if (err) { if (net_ratelimit()) - printk(KERN_WARNING - "Neighbour table failure & not caching routes.\n"); + pr_warn("Neighbour table failure & not caching routes\n"); ip_rt_put(rt); return ERR_PTR(err); } @@ -1258,7 +1257,7 @@ static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, struct net *net = dev_net(rt->dst.dev); int num = ++net->ipv4.current_rt_cache_rebuild_count; if (!rt_caching(net)) { - printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n", + pr_warn("%s: %d rebuilds is over limit, route caching disabled\n", rt->dst.dev->name, num); } rt_emergency_hash_rebuild(net); @@ -1299,7 +1298,7 @@ static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, } if (net_ratelimit()) - printk(KERN_WARNING "ipv4: Neighbour table overflow.\n"); + pr_warn("ipv4: Neighbour table overflow\n"); rt_drop(rt); return ERR_PTR(-ENOBUFS); } @@ -1503,10 +1502,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, reject_redirect: #ifdef CONFIG_IP_ROUTE_VERBOSE if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) - printk(KERN_INFO "Redirect from %pI4 on %s about %pI4 ignored.\n" + pr_info("Redirect from %pI4 on %s about %pI4 ignored\n" " Advised path = %pI4 -> %pI4\n", - &old_gw, dev->name, &new_gw, - &saddr, &daddr); + &old_gw, dev->name, &new_gw, + &saddr, &daddr); #endif ; } @@ -1618,8 +1617,8 @@ void ip_rt_send_redirect(struct sk_buff *skb) if (log_martians && peer->rate_tokens == ip_rt_redirect_number && net_ratelimit()) - printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n", - &ip_hdr(skb)->saddr, rt->rt_iif, + pr_warn("host %pI4/if%d ignores redirects for %pI4 to %pI4\n", + &ip_hdr(skb)->saddr, rt->rt_iif, &rt->rt_dst, &rt->rt_gateway); #endif } @@ -2105,18 +2104,13 @@ static void ip_handle_martian_source(struct net_device *dev, * RFC1812 recommendation, if source is martian, * the only hint is MAC header. */ - printk(KERN_WARNING "martian source %pI4 from %pI4, on dev %s\n", + pr_warn("martian source %pI4 from %pI4, on dev %s\n", &daddr, &saddr, dev->name); if (dev->hard_header_len && skb_mac_header_was_set(skb)) { - int i; - const unsigned char *p = skb_mac_header(skb); - printk(KERN_WARNING "ll header: "); - for (i = 0; i < dev->hard_header_len; i++, p++) { - printk("%02x", *p); - if (i < (dev->hard_header_len - 1)) - printk(":"); - } - printk("\n"); + print_hex_dump(KERN_WARNING, "ll header: ", + DUMP_PREFIX_OFFSET, 16, 1, + skb_mac_header(skb), + dev->hard_header_len, true); } } #endif @@ -2140,8 +2134,7 @@ static int __mkroute_input(struct sk_buff *skb, out_dev = __in_dev_get_rcu(FIB_RES_DEV(*res)); if (out_dev == NULL) { if (net_ratelimit()) - printk(KERN_CRIT "Bug in ip_route_input" \ - "_slow(). Please, report\n"); + pr_crit("Bug in ip_route_input_slow(). Please report.\n"); return -EINVAL; } @@ -2413,7 +2406,7 @@ out: return err; RT_CACHE_STAT_INC(in_martian_dst); #ifdef CONFIG_IP_ROUTE_VERBOSE if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit()) - printk(KERN_WARNING "martian destination %pI4 from %pI4, dev %s\n", + pr_warn("martian destination %pI4 from %pI4, dev %s\n", &daddr, &saddr, dev->name); #endif @@ -3490,7 +3483,7 @@ int __init ip_rt_init(void) net_random() % ip_rt_gc_interval + ip_rt_gc_interval); if (ip_rt_proc_init()) - printk(KERN_ERR "Unable to create route proc files\n"); + pr_err("Unable to create route proc files\n"); #ifdef CONFIG_XFRM xfrm_init(); xfrm4_init(ip_rt_max_size); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 22ef5f9fd2ff..2baba1bed810 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1675,7 +1675,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, if (tp->ucopy.dma_cookie < 0) { - printk(KERN_ALERT "dma_cookie < 0\n"); + pr_alert("dma_cookie < 0\n"); /* Exception. Bailout! */ if (!copied) @@ -3311,9 +3311,8 @@ void __init tcp_init(void) sysctl_tcp_rmem[1] = 87380; sysctl_tcp_rmem[2] = max(87380, max_share); - printk(KERN_INFO "TCP: Hash tables configured " - "(established %u bind %u)\n", - tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size); + pr_info("TCP: Hash tables configured (established %u bind %u)\n", + tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size); tcp_register_congestion_control(&tcp_reno); diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index fc6d475f488f..67bab75f441f 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -41,18 +41,17 @@ int tcp_register_congestion_control(struct tcp_congestion_ops *ca) /* all algorithms must implement ssthresh and cong_avoid ops */ if (!ca->ssthresh || !ca->cong_avoid) { - printk(KERN_ERR "TCP %s does not implement required ops\n", - ca->name); + pr_err("TCP %s does not implement required ops\n", ca->name); return -EINVAL; } spin_lock(&tcp_cong_list_lock); if (tcp_ca_find(ca->name)) { - printk(KERN_NOTICE "TCP %s already registered\n", ca->name); + pr_notice("TCP %s already registered\n", ca->name); ret = -EEXIST; } else { list_add_tail_rcu(&ca->list, &tcp_cong_list); - printk(KERN_INFO "TCP %s registered\n", ca->name); + pr_info("TCP %s registered\n", ca->name); } spin_unlock(&tcp_cong_list_lock); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index b5e315f13641..23ca3663d1e8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3867,9 +3867,9 @@ void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *o opt_rx->wscale_ok = 1; if (snd_wscale > 14) { if (net_ratelimit()) - printk(KERN_INFO "tcp_parse_options: Illegal window " - "scaling value %d >14 received.\n", - snd_wscale); + pr_info("%s: Illegal window scaling value %d >14 received\n", + __func__, + snd_wscale); snd_wscale = 14; } opt_rx->snd_wscale = snd_wscale; @@ -4191,7 +4191,7 @@ static void tcp_fin(struct sock *sk) /* Only TCP_LISTEN and TCP_CLOSE are left, in these * cases we should never reach this piece of code. */ - printk(KERN_ERR "%s: Impossible, sk->sk_state=%d\n", + pr_err("%s: Impossible, sk->sk_state=%d\n", __func__, sk->sk_state); break; } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 507924b640ef..257dba66eaca 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1227,10 +1227,10 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) if (genhash || memcmp(hash_location, newhash, 16) != 0) { if (net_ratelimit()) { - printk(KERN_INFO "MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s\n", - &iph->saddr, ntohs(th->source), - &iph->daddr, ntohs(th->dest), - genhash ? " tcp_v4_calc_md5_hash failed" : ""); + pr_info("MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s\n", + &iph->saddr, ntohs(th->source), + &iph->daddr, ntohs(th->dest), + genhash ? " tcp_v4_calc_md5_hash failed" : ""); } return 1; } diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c index 01775983b997..0d0171830620 100644 --- a/net/ipv4/tunnel4.c +++ b/net/ipv4/tunnel4.c @@ -164,12 +164,12 @@ static const struct net_protocol tunnel64_protocol = { static int __init tunnel4_init(void) { if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) { - printk(KERN_ERR "tunnel4 init: can't add protocol\n"); + pr_err("%s: can't add protocol\n", __func__); return -EAGAIN; } #if IS_ENABLED(CONFIG_IPV6) if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) { - printk(KERN_ERR "tunnel64 init: can't add protocol\n"); + pr_err("tunnel64 init: can't add protocol\n"); inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP); return -EAGAIN; } @@ -181,10 +181,10 @@ static void __exit tunnel4_fini(void) { #if IS_ENABLED(CONFIG_IPV6) if (inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6)) - printk(KERN_ERR "tunnel64 close: can't remove protocol\n"); + pr_err("tunnel64 close: can't remove protocol\n"); #endif if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP)) - printk(KERN_ERR "tunnel4 close: can't remove protocol\n"); + pr_err("tunnel4 close: can't remove protocol\n"); } module_init(tunnel4_init); diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 12e9499a1a6c..280bfb12adcc 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -129,11 +129,11 @@ void __init udplite4_register(void) inet_register_protosw(&udplite4_protosw); if (udplite4_proc_init()) - printk(KERN_ERR "%s: Cannot register /proc!\n", __func__); + pr_err("%s: Cannot register /proc!\n", __func__); return; out_unregister_proto: proto_unregister(&udplite_prot); out_register_err: - printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __func__); + pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__); } diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c index 9247d9d70e9d..5b48f49df0ba 100644 --- a/net/ipv4/xfrm4_tunnel.c +++ b/net/ipv4/xfrm4_tunnel.c @@ -75,18 +75,18 @@ static struct xfrm_tunnel xfrm64_tunnel_handler __read_mostly = { static int __init ipip_init(void) { if (xfrm_register_type(&ipip_type, AF_INET) < 0) { - printk(KERN_INFO "ipip init: can't add xfrm type\n"); + pr_info("%s: can't add xfrm type\n", __func__); return -EAGAIN; } if (xfrm4_tunnel_register(&xfrm_tunnel_handler, AF_INET)) { - printk(KERN_INFO "ipip init: can't add xfrm handler for AF_INET\n"); + pr_info("%s: can't add xfrm handler for AF_INET\n", __func__); xfrm_unregister_type(&ipip_type, AF_INET); return -EAGAIN; } #if IS_ENABLED(CONFIG_IPV6) if (xfrm4_tunnel_register(&xfrm64_tunnel_handler, AF_INET6)) { - printk(KERN_INFO "ipip init: can't add xfrm handler for AF_INET6\n"); + pr_info("%s: can't add xfrm handler for AF_INET6\n", __func__); xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET); xfrm_unregister_type(&ipip_type, AF_INET); return -EAGAIN; @@ -99,12 +99,14 @@ static void __exit ipip_fini(void) { #if IS_ENABLED(CONFIG_IPV6) if (xfrm4_tunnel_deregister(&xfrm64_tunnel_handler, AF_INET6)) - printk(KERN_INFO "ipip close: can't remove xfrm handler for AF_INET6\n"); + pr_info("%s: can't remove xfrm handler for AF_INET6\n", + __func__); #endif if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET)) - printk(KERN_INFO "ipip close: can't remove xfrm handler for AF_INET\n"); + pr_info("%s: can't remove xfrm handler for AF_INET\n", + __func__); if (xfrm_unregister_type(&ipip_type, AF_INET) < 0) - printk(KERN_INFO "ipip close: can't remove xfrm type\n"); + pr_info("%s: can't remove xfrm type\n", __func__); } module_init(ipip_init); -- GitLab From 17a7b16df4ba8e71e149fcf31e0b639ff45ddf84 Mon Sep 17 00:00:00 2001 From: Aarthi Thiruvengadam Date: Thu, 8 Mar 2012 12:25:02 -0800 Subject: [PATCH 1648/1846] ath6kl: Fix merge error in ath6kl_set_ies() Portion of the commit id 080eec4fb4 ("ath6kl: Clear the IE in firmware if not set") was overwritten by mistake due to a merge conflict. This patch fixes the code back to how it should be. kvalo: more details to the commit log Signed-off-by: Aarthi Thiruvengadam Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 37908e60e863..5ecc53af3ac6 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -2366,30 +2366,27 @@ static int ath6kl_set_ies(struct ath6kl_vif *vif, struct ath6kl *ar = vif->ar; int res; - if (info->beacon_ies) { - res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, - WMI_FRAME_BEACON, - info->beacon_ies, - info->beacon_ies_len); - if (res) - return res; - } - - if (info->proberesp_ies) { - res = ath6kl_set_ap_probe_resp_ies(vif, info->proberesp_ies, - info->proberesp_ies_len); - if (res) - return res; - } - - if (info->assocresp_ies) { - res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, - WMI_FRAME_ASSOC_RESP, - info->assocresp_ies, - info->assocresp_ies_len); - if (res) - return res; - } + /* this also clears IE in fw if it's not set */ + res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_BEACON, + info->beacon_ies, + info->beacon_ies_len); + if (res) + return res; + + /* this also clears IE in fw if it's not set */ + res = ath6kl_set_ap_probe_resp_ies(vif, info->proberesp_ies, + info->proberesp_ies_len); + if (res) + return res; + + /* this also clears IE in fw if it's not set */ + res = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx, + WMI_FRAME_ASSOC_RESP, + info->assocresp_ies, + info->assocresp_ies_len); + if (res) + return res; return 0; } -- GitLab From bff2ec2b916cc85628f3025e08660c0350f03650 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Mon, 12 Mar 2012 07:51:07 +0530 Subject: [PATCH 1649/1846] ath9k: Fix BTCOEX shutdown Flush MCI profiles only if MCI is being actually used. This fixes a panic on driver unload when non-MCI devices are being used and btcoex_enable is set. BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] ath_mci_flush_profile+0x12/0x100 [ath9k] Call Trace: [] ath9k_stop_btcoex+0x5e/0x80 [ath9k] [] ath9k_stop+0xb7/0x230 [ath9k] [] ieee80211_stop_device+0x50/0x180 [mac80211] [] ieee80211_do_stop+0x2af/0x6a0 [mac80211] [] ieee80211_stop+0x1a/0x20 [mac80211] [] __dev_close_many+0x86/0xe0 [] dev_close_many+0xa0/0x110 [] rollback_registered_many+0xe8/0x260 [] unregister_netdevice_many+0x1b/0x80 [] ieee80211_remove_interfaces+0xd0/0x110 [mac80211] [] ieee80211_unregister_hw+0x53/0x120 [mac80211] [] ath9k_deinit_device+0x44/0x70 [ath9k] [] ath_pci_remove+0x54/0xa0 [ath9k] [] pci_device_remove+0x46/0x110 [] __device_release_driver+0x7c/0xe0 [] driver_detach+0xd0/0xe0 [] bus_remove_driver+0x88/0xe0 [] driver_unregister+0x62/0xa0 [] pci_unregister_driver+0x44/0xc0 [] ath_pci_exit+0x15/0x20 [ath9k] [] ath9k_exit+0x15/0x31 [ath9k] [] sys_delete_module+0x18c/0x270 [] ? retint_swapgs+0x13/0x1b [] ? trace_hardirqs_on_thunk+0x3a/0x3f [] system_call_fastpath+0x16/0x1b Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/gpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c index 63e4c4b1cb3d..fbe23de1297f 100644 --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c @@ -362,7 +362,8 @@ void ath9k_stop_btcoex(struct ath_softc *sc) ath9k_hw_btcoex_disable(ah); if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_3WIRE) ath9k_btcoex_timer_pause(sc); - ath_mci_flush_profile(&sc->btcoex.mci); + if (ath9k_hw_get_btcoex_scheme(ah) == ATH_BTCOEX_CFG_MCI) + ath_mci_flush_profile(&sc->btcoex.mci); } } -- GitLab From 4486ea987efdaa546bdda569e3dfacdc14a9fb13 Mon Sep 17 00:00:00 2001 From: Bala Shanmugam Date: Wed, 7 Mar 2012 17:27:12 +0530 Subject: [PATCH 1650/1846] cfg80211: Add background scan period attribute. Receive background scan period as part of connect command and pass the same to the driver. Signed-off-by: Bala Shanmugam Signed-off-by: John W. Linville --- include/linux/nl80211.h | 10 ++++++++++ include/net/cfg80211.h | 3 +++ net/wireless/nl80211.c | 8 ++++++++ net/wireless/wext-sme.c | 3 +++ 4 files changed, 24 insertions(+) diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index c37d67add090..e474f6e780cc 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -369,6 +369,11 @@ * %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT, * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE and * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT. + * Background scan period can optionally be + * specified in %NL80211_ATTR_BG_SCAN_PERIOD, + * if not specified default background scan configuration + * in driver is used and if period value is 0, bg scan will be disabled. + * This attribute is ignored if driver does not support roam scan. * It is also sent as an event, with the BSSID and response IEs when the * connection is established or failed to be established. This can be * determined by the STATUS_CODE attribute. @@ -1207,6 +1212,9 @@ enum nl80211_commands { * this attribute is (depending on the driver capabilities) added to * received frames indicated with %NL80211_CMD_FRAME. * + * @NL80211_ATTR_BG_SCAN_PERIOD: Background scan period in seconds + * or 0 to disable background scan. + * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1456,6 +1464,8 @@ enum nl80211_attrs { NL80211_ATTR_RX_SIGNAL_DBM, + NL80211_ATTR_BG_SCAN_PERIOD, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 57c9fddc2acf..66f460325e24 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1203,6 +1203,8 @@ struct cfg80211_ibss_params { * @key_idx: index of WEP key for shared key authentication * @key: WEP key for shared key authentication * @flags: See &enum cfg80211_assoc_req_flags + * @bg_scan_period: Background scan period in seconds + * or -1 to indicate that default value is to be used. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask * will be used in ht_capa. Un-supported values will be ignored. * @ht_capa_mask: The bits of ht_capa which are to be used. @@ -1220,6 +1222,7 @@ struct cfg80211_connect_params { const u8 *key; u8 key_len, key_idx; u32 flags; + int bg_scan_period; struct ieee80211_ht_cap ht_capa; struct ieee80211_ht_cap ht_capa_mask; }; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 39dbdf2adb12..4c1eb9472ddb 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -205,6 +205,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { }, [NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 }, [NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 }, + [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 }, }; /* policy for the key attributes */ @@ -5116,6 +5117,13 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) wiphy = &rdev->wiphy; + connect.bg_scan_period = -1; + if (info->attrs[NL80211_ATTR_BG_SCAN_PERIOD] && + (wiphy->flags & WIPHY_FLAG_SUPPORTS_FW_ROAM)) { + connect.bg_scan_period = + nla_get_u16(info->attrs[NL80211_ATTR_BG_SCAN_PERIOD]); + } + if (info->attrs[NL80211_ATTR_MAC]) connect.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); connect.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); diff --git a/net/wireless/wext-sme.c b/net/wireless/wext-sme.c index 326750b99151..7c01c2f3b6cf 100644 --- a/net/wireless/wext-sme.c +++ b/net/wireless/wext-sme.c @@ -30,6 +30,9 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, wdev->wext.connect.ie = wdev->wext.ie; wdev->wext.connect.ie_len = wdev->wext.ie_len; + /* Use default background scan period */ + wdev->wext.connect.bg_scan_period = -1; + if (wdev->wext.keys) { wdev->wext.keys->def = wdev->wext.default_key; wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key; -- GitLab From aa4545806025c63ec12cfe17528de16dca36b785 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Wed, 7 Mar 2012 17:20:30 +0100 Subject: [PATCH 1651/1846] mac80211: Limit TID buffering during BA session setup/teardown While setting up or tearing down a BA session mac80211 is buffering pending frames for the according TID. However, there's currently no limit on how many frames are buffered possibly leading to an out-of- memory situation. This can happen on systems with little memory when the CPU is fully loaded since the BA session work is executed in process context while frames can still come via softirq. Apply a limitation to the TIDs pending queue to avoid consuming too much memory in this situation. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- net/mac80211/tx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 570737df2d22..d9e791d2b543 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1065,6 +1065,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, { bool queued = false; bool reset_agg_timer = false; + struct sk_buff *purge_skb = NULL; if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { info->flags |= IEEE80211_TX_CTL_AMPDU; @@ -1106,8 +1107,13 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, info->control.vif = &tx->sdata->vif; info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; __skb_queue_tail(&tid_tx->pending, skb); + if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) + purge_skb = __skb_dequeue(&tid_tx->pending); } spin_unlock(&tx->sta->lock); + + if (purge_skb) + dev_kfree_skb(purge_skb); } /* reset session timer */ -- GitLab From 4e13f092f755df5ed8169c8d8bfb952dc057e1aa Mon Sep 17 00:00:00 2001 From: Ashok Nagarajan Date: Thu, 8 Mar 2012 09:27:34 -0800 Subject: [PATCH 1652/1846] mac80211_hwsim: Fix set mactime on receiver hwsim radio The patch "mac80211_hwsim: Add tsf to beacons, probe responses and radiotap header" was setting the mactime on wrong hwsim radio. This patch fixes it. Signed-off-by: Ashok Nagarajan Signed-off-by: Javier Cardona Signed-off-by: John W. Linville --- drivers/net/wireless/mac80211_hwsim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index b4f6cb3298a4..b7ce6a6e355f 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -639,7 +639,6 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, } memset(&rx_status, 0, sizeof(rx_status)); - rx_status.mactime = le64_to_cpu(__mac80211_hwsim_get_tsf(data)); rx_status.flag |= RX_FLAG_MACTIME_MPDU; rx_status.freq = data->channel->center_freq; rx_status.band = data->channel->band; @@ -684,6 +683,8 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, if (mac80211_hwsim_addr_match(data2, hdr->addr1)) ack = true; + rx_status.mactime = + le64_to_cpu(__mac80211_hwsim_get_tsf(data2)); memcpy(IEEE80211_SKB_RXCB(nskb), &rx_status, sizeof(rx_status)); ieee80211_rx_irqsafe(data2->hw, nskb); } -- GitLab From 98b36a029550def4b3e76cc44d4345bf20a729bd Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 8 Mar 2012 10:20:55 -0800 Subject: [PATCH 1653/1846] ath9k: Add wiphy name to log messages. On systems with multiple NICs, it's nice to know which one is producing warnings. Here is an example of the new ouput: ath: wiphy0: Failed to stop TX DMA, queues=0x005! Signed-off-by: Ben Greear Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath.h | 26 +++++++++++--------------- drivers/net/wireless/ath/main.c | 9 +++++++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index efc01110dc34..c54b7d37bff1 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -174,28 +174,24 @@ 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 __printf(2, 3) void ath_printk(const char *level, const char *fmt, ...); - -#define _ath_printk(level, common, fmt, ...) \ -do { \ - __always_unused struct ath_common *unused = common; \ - ath_printk(level, fmt, ##__VA_ARGS__); \ -} while (0) +__printf(3, 4) +void ath_printk(const char *level, const struct ath_common *common, + const char *fmt, ...); #define ath_emerg(common, fmt, ...) \ - _ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) #define ath_alert(common, fmt, ...) \ - _ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) #define ath_crit(common, fmt, ...) \ - _ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) #define ath_err(common, fmt, ...) \ - _ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) #define ath_warn(common, fmt, ...) \ - _ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__) #define ath_notice(common, fmt, ...) \ - _ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) #define ath_info(common, fmt, ...) \ - _ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) /** * enum ath_debug_level - atheros wireless debug level @@ -256,7 +252,7 @@ enum ATH_DEBUG { #define ath_dbg(common, dbg_mask, fmt, ...) \ do { \ if ((common)->debug_mask & ATH_DBG_##dbg_mask) \ - _ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ + ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ } while (0) #define ATH_DBG_WARN(foo, arg...) WARN(foo, arg) diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c index d9218fe02036..ea2c737138d3 100644 --- a/drivers/net/wireless/ath/main.c +++ b/drivers/net/wireless/ath/main.c @@ -57,7 +57,8 @@ struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, } EXPORT_SYMBOL(ath_rxbuf_alloc); -void ath_printk(const char *level, const char *fmt, ...) +void ath_printk(const char *level, const struct ath_common* common, + const char *fmt, ...) { struct va_format vaf; va_list args; @@ -67,7 +68,11 @@ void ath_printk(const char *level, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - printk("%sath: %pV", level, &vaf); + if (common && common->hw && common->hw->wiphy) + printk("%sath: %s: %pV", + level, wiphy_name(common->hw->wiphy), &vaf); + else + printk("%sath: %pV", level, &vaf); va_end(args); } -- GitLab From 138f07edb6b5a905cedf5c4fe96d6b2a45d8fb30 Mon Sep 17 00:00:00 2001 From: Stanislav Yakovlev Date: Thu, 8 Mar 2012 19:06:50 -0500 Subject: [PATCH 1654/1846] net/wireless: ipw2x00: remove unused definitions for regulatory domain ipw2200 driver does not use these defines, it uses geo struct instead. Therefore remove them from its header. Note: we keep them in the ipw2100 driver's header, because the driver still uses them. Signed-off-by: Stanislav Yakovlev Signed-off-by: John W. Linville --- drivers/net/wireless/ipw2x00/ipw2200.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/net/wireless/ipw2x00/ipw2200.h b/drivers/net/wireless/ipw2x00/ipw2200.h index 66e84ec0eb55..570d6fb88967 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.h +++ b/drivers/net/wireless/ipw2x00/ipw2200.h @@ -1997,18 +1997,6 @@ struct ipw_cmd_log { #define CFG_SYS_ANTENNA_B 0x03 /* force antenna B */ #define CFG_SYS_ANTENNA_SLOW_DIV 0x02 /* consider background noise */ -/* - * The definitions below were lifted off the ipw2100 driver, which only - * supports 'b' mode, so I'm sure these are not exactly correct. - * - * Somebody fix these!! - */ -#define REG_MIN_CHANNEL 0 -#define REG_MAX_CHANNEL 14 - -#define REG_CHANNEL_MASK 0x00003FFF -#define IPW_IBSS_11B_DEFAULT_MASK 0x87ff - #define IPW_MAX_CONFIG_RETRIES 10 #endif /* __ipw2200_h__ */ -- GitLab From 3789d59c24cb142e4590492c3b5137a7c3dec352 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Fri, 9 Mar 2012 12:01:55 +0530 Subject: [PATCH 1655/1846] ath9k_hw: Fix enabling of MCI and RTT tested in AR9462 Rev:2, both hardware capability flag are set Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 13 +++++++++++-- drivers/net/wireless/ath/ath9k/reg.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index d582cf73098f..02cc1ce3dd6a 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2390,8 +2390,17 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) if (AR_SREV_9485_OR_LATER(ah)) ah->enabled_cals |= TX_IQ_ON_AGC_CAL; } - if (AR_SREV_9462(ah)) - pCap->hw_caps |= ATH9K_HW_CAP_RTT | ATH9K_HW_CAP_MCI; + + if (AR_SREV_9462(ah)) { + + if (!(ah->ent_mode & AR_ENT_OTP_49GHZ_DISABLE)) + pCap->hw_caps |= ATH9K_HW_CAP_MCI; + + if (AR_SREV_9462_20(ah)) + pCap->hw_caps |= ATH9K_HW_CAP_RTT; + + } + return 0; } diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h index 80b1856f817d..458f81b4a7cb 100644 --- a/drivers/net/wireless/ath/ath9k/reg.h +++ b/drivers/net/wireless/ath/ath9k/reg.h @@ -1151,6 +1151,7 @@ enum { #define AR_INTR_PRIO_ASYNC_ENABLE (AR_SREV_9340(ah) ? 0x4094 : 0x40d4) #define AR_ENT_OTP 0x40d8 #define AR_ENT_OTP_CHAIN2_DISABLE 0x00020000 +#define AR_ENT_OTP_49GHZ_DISABLE 0x00100000 #define AR_ENT_OTP_MIN_PKT_SIZE_DISABLE 0x00800000 #define AR_CH0_BB_DPLL1 0x16180 -- GitLab From 177958e9679c23537411066cc41b205635dacb14 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 9 Mar 2012 12:49:21 +0100 Subject: [PATCH 1656/1846] mac80211: remove tx_sync When the station state callback was added, this was no longer needed in theory. With the iwlwifi changes to remove use of it landing, we can kill the entire tx-sync framework again, RIP. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/mac80211.h | 41 ----------------------------------- net/mac80211/driver-ops.h | 35 ------------------------------ net/mac80211/driver-trace.h | 43 ------------------------------------- net/mac80211/ieee80211_i.h | 1 - net/mac80211/mlme.c | 41 ----------------------------------- 5 files changed, 161 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index f7917f765cbc..44e4dfcb5722 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1765,20 +1765,6 @@ enum ieee80211_ampdu_mlme_action { IEEE80211_AMPDU_TX_OPERATIONAL, }; -/** - * enum ieee80211_tx_sync_type - TX sync type - * @IEEE80211_TX_SYNC_AUTH: sync TX for authentication - * (and possibly also before direct probe) - * @IEEE80211_TX_SYNC_ASSOC: sync TX for association - * @IEEE80211_TX_SYNC_ACTION: sync TX for action frame - * (not implemented yet) - */ -enum ieee80211_tx_sync_type { - IEEE80211_TX_SYNC_AUTH, - IEEE80211_TX_SYNC_ASSOC, - IEEE80211_TX_SYNC_ACTION, -}; - /** * enum ieee80211_frame_release_type - frame release reason * @IEEE80211_FRAME_RELEASE_PSPOLL: frame released for PS-Poll @@ -1889,26 +1875,6 @@ enum ieee80211_frame_release_type { * of the bss parameters has changed when a call is made. The callback * can sleep. * - * @tx_sync: Called before a frame is sent to an AP/GO. In the GO case, the - * driver should sync with the GO's powersaving so the device doesn't - * transmit the frame while the GO is asleep. In the regular AP case - * it may be used by drivers for devices implementing other restrictions - * on talking to APs, e.g. due to regulatory enforcement or just HW - * restrictions. - * This function is called for every authentication, association and - * action frame separately since applications might attempt to auth - * with multiple APs before chosing one to associate to. If it returns - * an error, the corresponding authentication, association or frame - * transmission is aborted and reported as having failed. It is always - * called after tuning to the correct channel. - * The callback might be called multiple times before @finish_tx_sync - * (but @finish_tx_sync will be called once for each) but in practice - * this is unlikely to happen. It can also refuse in that case if the - * driver cannot handle that situation. - * This callback can sleep. - * @finish_tx_sync: Called as a counterpart to @tx_sync, unless that returned - * an error. This callback can sleep. - * * @prepare_multicast: Prepare for multicast filter configuration. * This callback is optional, and its return value is passed * to configure_filter(). This callback must be atomic. @@ -2180,13 +2146,6 @@ struct ieee80211_ops { struct ieee80211_bss_conf *info, u32 changed); - int (*tx_sync)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - const u8 *bssid, enum ieee80211_tx_sync_type type); - void (*finish_tx_sync)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *bssid, - enum ieee80211_tx_sync_type type); - u64 (*prepare_multicast)(struct ieee80211_hw *hw, struct netdev_hw_addr_list *mc_list); void (*configure_filter)(struct ieee80211_hw *hw, diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 70dfb6415c20..af4691fed645 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -168,41 +168,6 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local, trace_drv_return_void(local); } -static inline int drv_tx_sync(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - const u8 *bssid, - enum ieee80211_tx_sync_type type) -{ - int ret = 0; - - might_sleep(); - - check_sdata_in_driver(sdata); - - trace_drv_tx_sync(local, sdata, bssid, type); - if (local->ops->tx_sync) - ret = local->ops->tx_sync(&local->hw, &sdata->vif, - bssid, type); - trace_drv_return_int(local, ret); - return ret; -} - -static inline void drv_finish_tx_sync(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - const u8 *bssid, - enum ieee80211_tx_sync_type type) -{ - might_sleep(); - - check_sdata_in_driver(sdata); - - trace_drv_finish_tx_sync(local, sdata, bssid, type); - if (local->ops->finish_tx_sync) - local->ops->finish_tx_sync(&local->hw, &sdata->vif, - bssid, type); - trace_drv_return_void(local); -} - static inline u64 drv_prepare_multicast(struct ieee80211_local *local, struct netdev_hw_addr_list *mc_list) { diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h index 384e2f08c187..7034209ad3f4 100644 --- a/net/mac80211/driver-trace.h +++ b/net/mac80211/driver-trace.h @@ -308,49 +308,6 @@ TRACE_EVENT(drv_bss_info_changed, ) ); -DECLARE_EVENT_CLASS(tx_sync_evt, - TP_PROTO(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - const u8 *bssid, - enum ieee80211_tx_sync_type type), - TP_ARGS(local, sdata, bssid, type), - - TP_STRUCT__entry( - LOCAL_ENTRY - VIF_ENTRY - __array(char, bssid, ETH_ALEN) - __field(u32, sync_type) - ), - - TP_fast_assign( - LOCAL_ASSIGN; - VIF_ASSIGN; - memcpy(__entry->bssid, bssid, ETH_ALEN); - __entry->sync_type = type; - ), - - TP_printk( - LOCAL_PR_FMT VIF_PR_FMT " bssid:%pM type:%d", - LOCAL_PR_ARG, VIF_PR_ARG, __entry->bssid, __entry->sync_type - ) -); - -DEFINE_EVENT(tx_sync_evt, drv_tx_sync, - TP_PROTO(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - const u8 *bssid, - enum ieee80211_tx_sync_type type), - TP_ARGS(local, sdata, bssid, type) -); - -DEFINE_EVENT(tx_sync_evt, drv_finish_tx_sync, - TP_PROTO(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - const u8 *bssid, - enum ieee80211_tx_sync_type type), - TP_ARGS(local, sdata, bssid, type) -); - TRACE_EVENT(drv_prepare_multicast, TP_PROTO(struct ieee80211_local *local, int mc_count), diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 796b13bfc953..3c62ded64e32 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -388,7 +388,6 @@ struct ieee80211_mgd_auth_data { u8 key[WLAN_KEY_LEN_WEP104]; u8 key_len, key_idx; - bool synced; bool done; size_t ie_len; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index c08924aeac00..1d09df248c56 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1770,11 +1770,6 @@ static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, lockdep_assert_held(&sdata->u.mgd.mtx); - if (auth_data->synced) - drv_finish_tx_sync(sdata->local, sdata, - auth_data->bss->bssid, - IEEE80211_TX_SYNC_AUTH); - if (!assoc) { sta_info_destroy_addr(sdata, auth_data->bss->bssid); @@ -1862,10 +1857,6 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, printk(KERN_DEBUG "%s: authenticated\n", sdata->name); out: - if (ifmgd->auth_data->synced) - drv_finish_tx_sync(sdata->local, sdata, bssid, - IEEE80211_TX_SYNC_AUTH); - ifmgd->auth_data->synced = false; ifmgd->auth_data->done = true; ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; run_again(ifmgd, ifmgd->auth_data->timeout); @@ -2005,11 +1996,6 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata, lockdep_assert_held(&sdata->u.mgd.mtx); - if (assoc_data->synced) - drv_finish_tx_sync(sdata->local, sdata, - assoc_data->bss->bssid, - IEEE80211_TX_SYNC_ASSOC); - if (!assoc) { sta_info_destroy_addr(sdata, assoc_data->bss->bssid); @@ -2255,14 +2241,6 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, } else { printk(KERN_DEBUG "%s: associated\n", sdata->name); - /* tell driver about sync done first */ - if (assoc_data->synced) { - drv_finish_tx_sync(sdata->local, sdata, - assoc_data->bss->bssid, - IEEE80211_TX_SYNC_ASSOC); - assoc_data->synced = false; - } - if (!ieee80211_assoc_success(sdata, *bss, mgmt, len)) { /* oops -- internal error -- send timeout for now */ ieee80211_destroy_assoc_data(sdata, true); @@ -2747,14 +2725,6 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) if (WARN_ON_ONCE(!auth_data)) return -EINVAL; - if (!auth_data->synced) { - int ret = drv_tx_sync(local, sdata, auth_data->bss->bssid, - IEEE80211_TX_SYNC_AUTH); - if (ret) - return ret; - } - auth_data->synced = true; - auth_data->tries++; if (auth_data->tries > IEEE80211_AUTH_MAX_TRIES) { @@ -2811,14 +2781,6 @@ static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata) lockdep_assert_held(&sdata->u.mgd.mtx); - if (!assoc_data->synced) { - int ret = drv_tx_sync(local, sdata, assoc_data->bss->bssid, - IEEE80211_TX_SYNC_ASSOC); - if (ret) - return ret; - } - assoc_data->synced = true; - assoc_data->tries++; if (assoc_data->tries > IEEE80211_ASSOC_MAX_TRIES) { printk(KERN_DEBUG "%s: association with %pM timed out\n", @@ -3245,9 +3207,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, err = ieee80211_probe_auth(sdata); if (err) { - if (auth_data->synced) - drv_finish_tx_sync(local, sdata, req->bss->bssid, - IEEE80211_TX_SYNC_AUTH); sta_info_destroy_addr(sdata, req->bss->bssid); goto err_clear; } -- GitLab From 3cc5240b5e036abb565c8ac7cffdcceb06a13517 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 9 Mar 2012 13:12:35 +0100 Subject: [PATCH 1657/1846] mac80211: set channel back after disassociating As we've discussed, we want to avoid channel changes while associated. While the part when we actually associate needs a bit more work, the bit that happens on disassociating can be changed quite easily. Move the channel type change later in the disassociate process to set the channel only after the driver was told that it's now disassociated. As the driver could expect powersave to be enabled only when associated, this thus results in splitting the config call, but overall what happens makes more sense this way. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 1d09df248c56..5c2ba80c2932 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1394,7 +1394,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_local *local = sdata->local; struct sta_info *sta; - u32 changed = 0, config_changed = 0; + u32 changed = 0; u8 bssid[ETH_ALEN]; ASSERT_MGD_MTX(ifmgd); @@ -1454,9 +1454,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, changed |= BSS_CHANGED_ASSOC; sdata->vif.bss_conf.assoc = false; - /* channel(_type) changes are handled by ieee80211_hw_config */ - WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT)); - /* on the next assoc, re-program HT parameters */ sdata->ht_opmode_valid = false; memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); @@ -1469,12 +1466,10 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, if (local->hw.conf.flags & IEEE80211_CONF_PS) { local->hw.conf.flags &= ~IEEE80211_CONF_PS; - config_changed |= IEEE80211_CONF_CHANGE_PS; + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); } local->ps_sdata = NULL; - ieee80211_hw_config(local, config_changed); - /* Disable ARP filtering */ if (sdata->vif.bss_conf.arp_filter_enabled) { sdata->vif.bss_conf.arp_filter_enabled = false; @@ -1488,6 +1483,10 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; ieee80211_bss_info_change_notify(sdata, changed); + /* channel(_type) changes are handled by ieee80211_hw_config */ + WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT)); + ieee80211_hw_config(local, 0); + /* disassociated - set to defaults now */ ieee80211_set_wmm_default(sdata, false); -- GitLab From e9219779f943dfa1010ccbb63de14d49a47c43ee Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Fri, 9 Mar 2012 14:13:45 +0100 Subject: [PATCH 1658/1846] mac80211: Disable MCS > 7 in minstrel_ht when STA uses static SMPS Disable multi stream rates (MCS > 7) when a STA is in static SMPS mode since it has only one active rx chain. Hence, it doesn't even make sense to sample multi stream rates. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- net/mac80211/rc80211_minstrel_ht.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index ff5f7b84e825..2b42564d6e29 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -692,6 +692,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, int ack_dur; int stbc; int i; + unsigned int smps; /* fall back to the old minstrel for legacy stations */ if (!sta->ht_cap.ht_supported) @@ -731,6 +732,9 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, oper_chan_type != NL80211_CHAN_HT40PLUS) sta_cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; + smps = (sta_cap & IEEE80211_HT_CAP_SM_PS) >> + IEEE80211_HT_CAP_SM_PS_SHIFT; + for (i = 0; i < ARRAY_SIZE(mi->groups); i++) { u16 req = 0; @@ -748,6 +752,11 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, if ((sta_cap & req) != req) continue; + /* Mark MCS > 7 as unsupported if STA is in static SMPS mode */ + if (smps == WLAN_HT_CAP_SM_PS_STATIC && + minstrel_mcs_groups[i].streams > 1) + continue; + mi->groups[i].supported = mcs->rx_mask[minstrel_mcs_groups[i].streams - 1]; -- GitLab From 290d60891eb659e52204ec209e08cc0cabc5b99f Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Fri, 9 Mar 2012 15:31:50 +0100 Subject: [PATCH 1659/1846] rt2x00: Fix beacon skew in rt2800pci rt2800pci is suffering from beacon skew in AP mode. Some powersaving clients (like VOIP phones) are getting into trouble after some time when the beacon skew is getting too big. The ralink legacy drivers contain a function that indicates that the beacon timer is off by 1us per tbtt. And this function works around that by reducing the beacon interval for every 64th beacon transmission by 64us (the smallest possible value). Do the same in rt2800pci. This allows proper powersaving when rt2800pci is used in AP mode. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800.h | 7 +++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 26 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h index e5c05d8c7448..063bfa8b91f4 100644 --- a/drivers/net/wireless/rt2x00/rt2800.h +++ b/drivers/net/wireless/rt2x00/rt2800.h @@ -2474,6 +2474,12 @@ struct mac_iveiv_entry { */ #define EIRP_MAX_TX_POWER_LIMIT 0x50 +/* + * Number of TBTT intervals after which we have to adjust + * the hw beacon timer. + */ +#define BCN_TBTT_OFFSET 64 + /* * RT2800 driver data structure */ @@ -2484,6 +2490,7 @@ struct rt2800_drv_data { u8 bbp26; u8 txmixer_gain_24g; u8 txmixer_gain_5g; + unsigned int tbtt_tick; }; #endif /* RT2800_H */ diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 9375db455456..0397bbf0ce01 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -809,7 +809,33 @@ static void rt2800pci_pretbtt_tasklet(unsigned long data) static void rt2800pci_tbtt_tasklet(unsigned long data) { struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; + u32 reg; + rt2x00lib_beacondone(rt2x00dev); + + if (rt2x00dev->intf_ap_count) { + /* + * The rt2800pci hardware tbtt timer is off by 1us per tbtt + * causing beacon skew and as a result causing problems with + * some powersaving clients over time. Shorten the beacon + * interval every 64 beacons by 64us to mitigate this effect. + */ + if (drv_data->tbtt_tick == (BCN_TBTT_OFFSET - 2)) { + rt2x00pci_register_read(rt2x00dev, BCN_TIME_CFG, ®); + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL, + (rt2x00dev->beacon_int * 16) - 1); + rt2x00pci_register_write(rt2x00dev, BCN_TIME_CFG, reg); + } else if (drv_data->tbtt_tick == (BCN_TBTT_OFFSET - 1)) { + rt2x00pci_register_read(rt2x00dev, BCN_TIME_CFG, ®); + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL, + (rt2x00dev->beacon_int * 16)); + rt2x00pci_register_write(rt2x00dev, BCN_TIME_CFG, reg); + } + drv_data->tbtt_tick++; + drv_data->tbtt_tick %= BCN_TBTT_OFFSET; + } + if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) rt2800pci_enable_interrupt(rt2x00dev, INT_MASK_CSR_TBTT); } -- GitLab From 3cd7920a2be893ed0ba58baaed8fc2930e822fc7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 9 Mar 2012 17:25:33 +0100 Subject: [PATCH 1660/1846] mac80211: add auth/assoc/deauth flow diagram I've been working on some documentation, so let's add this diagram to the kernel tree where at least it has a chance of being maintained :-) Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- .../networking/mac80211-auth-assoc-deauth.txt | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/networking/mac80211-auth-assoc-deauth.txt diff --git a/Documentation/networking/mac80211-auth-assoc-deauth.txt b/Documentation/networking/mac80211-auth-assoc-deauth.txt new file mode 100644 index 000000000000..721773d2b9d2 --- /dev/null +++ b/Documentation/networking/mac80211-auth-assoc-deauth.txt @@ -0,0 +1,99 @@ +# +# This outlines the Linux authentication/association and +# deauthentication/disassociation flows. +# +# This can be converted into a diagram using the service +# at http://www.websequencediagrams.com/ +# + +participant userspace +participant mac80211 +participant driver + +alt authentication needed (not FT) +userspace->mac80211: authenticate + +alt authenticated/authenticating already +mac80211->driver: sta_state(AP, not-exist) +mac80211->driver: bss_info_changed(clear BSSID) +else associated +note over mac80211,driver +like deauth/disassoc, without sending the +BA session stop & deauth/disassoc frames +end note +end + +mac80211->driver: config(channel, non-HT) +mac80211->driver: bss_info_changed(set BSSID, basic rate bitmap) +mac80211->driver: sta_state(AP, exists) + +alt no probe request data known +mac80211->driver: TX directed probe request +driver->mac80211: RX probe response +end + +mac80211->driver: TX auth frame +driver->mac80211: RX auth frame + +alt WEP shared key auth +mac80211->driver: TX auth frame +driver->mac80211: RX auth frame +end + +mac80211->driver: sta_state(AP, authenticated) +mac80211->userspace: RX auth frame + +end + +userspace->mac80211: associate +alt authenticated or associated +note over mac80211,driver: cleanup like for authenticate +end + +alt not previously authenticated (FT) +mac80211->driver: config(channel, non-HT) +mac80211->driver: bss_info_changed(set BSSID, basic rate bitmap) +mac80211->driver: sta_state(AP, exists) +mac80211->driver: sta_state(AP, authenticated) +end +mac80211->driver: TX assoc +driver->mac80211: RX assoc response +note over mac80211: init rate control +mac80211->driver: sta_state(AP, associated) + +alt not using WPA +mac80211->driver: sta_state(AP, authorized) +end + +mac80211->driver: set up QoS parameters + +alt is HT channel +mac80211->driver: config(channel, HT params) +end + +mac80211->driver: bss_info_changed(QoS, HT, associated with AID) +mac80211->userspace: associated + +note left of userspace: associated now + +alt using WPA +note over userspace +do 4-way-handshake +(data frames) +end note +userspace->mac80211: authorized +mac80211->driver: sta_state(AP, authorized) +end + +userspace->mac80211: deauthenticate/disassociate +mac80211->driver: stop BA sessions +mac80211->driver: TX deauth/disassoc +mac80211->driver: flush frames +mac80211->driver: sta_state(AP,associated) +mac80211->driver: sta_state(AP,authenticated) +mac80211->driver: sta_state(AP,exist) +mac80211->driver: sta_state(AP,not-exist) +mac80211->driver: turn off powersave +mac80211->driver: bss_info_changed(clear BSSID, not associated, no QoS, ...) +mac80211->driver: config(non-HT channel type) +mac80211->userspace: disconnected -- GitLab From 9f61903ca24e67c22c02de9fd223a98e03f7797a Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Sat, 10 Mar 2012 05:06:49 +0530 Subject: [PATCH 1661/1846] ath9k: configure bss info at assoc notification The proper place to configure bss info is at assoc notification. So that ath9k continues to work if the supirous bssid notification will be removed in future. Cc: Johannes Berg Reported-by: Sujith Manoharan Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index cc2535c38bed..33403a92e45f 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1973,7 +1973,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, ath9k_ps_wakeup(sc); mutex_lock(&sc->mutex); - if (changed & BSS_CHANGED_BSSID) { + if (changed & BSS_CHANGED_ASSOC) { ath9k_config_bss(sc, vif); ath_dbg(common, CONFIG, "BSSID: %pM aid: 0x%x\n", -- GitLab From ffb1c56a9706c7e4f1911faa14626b2bb3973479 Mon Sep 17 00:00:00 2001 From: Ashok Nagarajan Date: Fri, 9 Mar 2012 18:57:39 -0800 Subject: [PATCH 1662/1846] ath9k: Fix mactime from being clobbered in rx_status mactime was being overwritten by the function ath9k_rx_skb_preprocess. Fixed by memsetting rx_status in ath_rx_tasklet. Signed-off-by: Ashok Nagarajan Signed-off-by: Javier Cardona Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 1b1b279c304a..f4ae3ba994a8 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -982,8 +982,6 @@ static int ath9k_rx_skb_preprocess(struct ath_common *common, { struct ath_hw *ah = common->ah; - memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); - /* * everything but the rate is checked here, the rate check is done * separately to avoid doing two lookups for a rate for each frame. @@ -1841,6 +1839,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) if (sc->sc_flags & SC_OP_RXFLUSH) goto requeue_drop_frag; + memset(rxs, 0, sizeof(struct ieee80211_rx_status)); + rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; if (rs.rs_tstamp > tsf_lower && unlikely(rs.rs_tstamp - tsf_lower > 0x10000000)) -- GitLab From c1afdaff90538ef085b756454f12b29575411214 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 10 Mar 2012 13:57:04 +0100 Subject: [PATCH 1663/1846] ath9k: fix going to full-sleep on PS idle The check for PS_WAIT_FOR_TX_ACK was inverted, the hardware should only go to full sleep if no tx is pending. Reported-by: Sujith Manoharan Signed-off-by: Felix Fietkau Cc: stable@vger.kernel.org Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 33403a92e45f..4a9901090811 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -118,13 +118,15 @@ void ath9k_ps_restore(struct ath_softc *sc) if (--sc->ps_usecount != 0) goto unlock; - if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK)) + if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) + goto unlock; + + if (sc->ps_idle) mode = ATH9K_PM_FULL_SLEEP; else if (sc->ps_enabled && !(sc->ps_flags & (PS_WAIT_FOR_BEACON | PS_WAIT_FOR_CAB | - PS_WAIT_FOR_PSPOLL_DATA | - PS_WAIT_FOR_TX_ACK))) + PS_WAIT_FOR_PSPOLL_DATA))) mode = ATH9K_PM_NETWORK_SLEEP; else goto unlock; -- GitLab From 10d8f31ebbd6ea9aa8d65d2f04ebef63225052de Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 10 Mar 2012 13:00:06 -0800 Subject: [PATCH 1664/1846] iwlwifi: remove TX hex debug Tracing is much better for this, so remove the hex printk debug for the TX command. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 91628565409f..14b0361d46ea 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1466,8 +1466,6 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, IWL_DEBUG_TX(trans, "sequence nr = 0X%x\n", le16_to_cpu(dev_cmd->hdr.sequence)); IWL_DEBUG_TX(trans, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - iwl_print_hex_dump(trans, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - iwl_print_hex_dump(trans, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ iwl_trans_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len)); -- GitLab From d663ee73f62903aed334eca25832a76c4a7e4c1c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 10 Mar 2012 13:00:07 -0800 Subject: [PATCH 1665/1846] iwlwifi: abstract out missing SEQ_RX_FRAME workaround Mohammed Shafi ran into [1] the SEQ_RX_FRAME workaround warning with a statistics notification, this means we can't just remove it as we'd hoped. Abstract it out so that the higher layer can configure this as a kind of "filter" in the transport. [1] http://mid.gmane.org/CAD2nsn1_DzbRHuSbS_1rFNzuux_9pW1-pABEasQ01_y7-ndO5w@mail.gmail.com Reported-by: Mohammed Shafi Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 10 +++++++ .../net/wireless/iwlwifi/iwl-trans-pcie-int.h | 2 ++ .../net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 29 +++++++------------ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 7 +++++ drivers/net/wireless/iwlwifi/iwl-trans.h | 9 ++++++ 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 28422c03d673..5ef15855be2f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1186,6 +1186,14 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, u16 num_mac; u32 ucode_flags; struct iwl_trans_config trans_cfg; + static const u8 no_reclaim_cmds[] = { + REPLY_RX_PHY_CMD, + REPLY_RX, + REPLY_RX_MPDU_CMD, + REPLY_COMPRESSED_BA, + STATISTICS_NOTIFICATION, + REPLY_TX, + }; /************************ * 1. Allocating HW data @@ -1211,6 +1219,8 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans, * to know about. */ trans_cfg.op_mode = op_mode; + trans_cfg.no_reclaim_cmds = no_reclaim_cmds; + trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds); ucode_flags = fw->ucode_capa.flags; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index 67965599bb30..1c2fe87bd7e2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -291,6 +291,8 @@ struct iwl_trans_pcie { wait_queue_head_t ucode_write_waitq; unsigned long status; u8 cmd_queue; + u8 n_no_reclaim_cmds; + u8 no_reclaim_cmds[MAX_NO_RECLAIM_CMDS]; }; #define IWL_TRANS_GET_PCIE_TRANS(_iwl_trans) \ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 9bc3c73af5e9..8bec0e1ccb54 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -395,13 +395,17 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans, * 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); + reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME); + if (reclaim) { + int i; + + for (i = 0; i < trans_pcie->n_no_reclaim_cmds; i++) { + if (trans_pcie->no_reclaim_cmds[i] == pkt->hdr.cmd) { + reclaim = false; + break; + } + } + } sequence = le16_to_cpu(pkt->hdr.sequence); index = SEQ_TO_INDEX(sequence); @@ -412,17 +416,6 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans, else cmd = NULL; - /* warn if this is cmd response / notification and the uCode - * didn't set the SEQ_RX_FRAME for a frame that is - * uCode-originated - * If you saw this code after the second half of 2012, then - * please remove it - */ - WARN(pkt->hdr.cmd != REPLY_TX && reclaim == false && - (!(pkt->hdr.sequence & SEQ_RX_FRAME)), - "reclaim is false, SEQ_RX_FRAME unset: %s\n", - get_cmd_string(pkt->hdr.cmd)); - err = iwl_op_mode_rx(trans->op_mode, &rxcb, cmd); /* diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 14b0361d46ea..4900dfa59df7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1626,6 +1626,13 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans, struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); trans_pcie->cmd_queue = trans_cfg->cmd_queue; + if (WARN_ON(trans_cfg->n_no_reclaim_cmds > MAX_NO_RECLAIM_CMDS)) + trans_pcie->n_no_reclaim_cmds = 0; + else + trans_pcie->n_no_reclaim_cmds = trans_cfg->n_no_reclaim_cmds; + if (trans_pcie->n_no_reclaim_cmds) + memcpy(trans_pcie->no_reclaim_cmds, trans_cfg->no_reclaim_cmds, + trans_pcie->n_no_reclaim_cmds * sizeof(u8)); } static void iwl_trans_pcie_free(struct iwl_trans *trans) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 7d1990c7f658..95f3faf4e866 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -274,6 +274,8 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) return p; } +#define MAX_NO_RECLAIM_CMDS 6 + /** * struct iwl_trans_config - transport configuration * @@ -281,10 +283,17 @@ static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) * Must be set before any other call. * @cmd_queue: the index of the command queue. * Must be set before start_fw. + * @no_reclaim_cmds: Some devices erroneously don't set the + * SEQ_RX_FRAME bit on some notifications, this is the + * list of such notifications to filter. Max length is + * %MAX_NO_RECLAIM_CMDS. + * @n_no_reclaim_cmds: # of commands in list */ struct iwl_trans_config { struct iwl_op_mode *op_mode; u8 cmd_queue; + const u8 *no_reclaim_cmds; + int n_no_reclaim_cmds; }; /** -- GitLab From f0d120af8f55649571c681f49c920b0822050fa5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 10 Mar 2012 13:00:08 -0800 Subject: [PATCH 1666/1846] iwlwifi: convert bad state message into warning Looking at logs, I see that we did get the bad state message a few times for some reason, but it doesn't indicate why or where it came from, so make it a warning in order to identify it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans.h | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 95f3faf4e866..782cb0ddc962 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -497,8 +497,8 @@ static inline void iwl_trans_wowlan_suspend(struct iwl_trans *trans) static inline int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) { - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); return trans->ops->send_cmd(trans, cmd); } @@ -517,8 +517,8 @@ static inline int iwl_trans_reclaim(struct iwl_trans *trans, int sta_id, int tid, int txq_id, int ssn, struct sk_buff_head *skbs) { - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); return trans->ops->reclaim(trans, sta_id, tid, txq_id, ssn, skbs); } @@ -526,8 +526,8 @@ static inline int iwl_trans_reclaim(struct iwl_trans *trans, int sta_id, static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, int sta_id, int tid) { - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); return trans->ops->tx_agg_disable(trans, sta_id, tid); } @@ -535,8 +535,8 @@ static inline int iwl_trans_tx_agg_disable(struct iwl_trans *trans, static inline int iwl_trans_tx_agg_alloc(struct iwl_trans *trans, int sta_id, int tid) { - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); return trans->ops->tx_agg_alloc(trans, sta_id, tid); } @@ -549,8 +549,8 @@ static inline void iwl_trans_tx_agg_setup(struct iwl_trans *trans, { might_sleep(); - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); trans->ops->tx_agg_setup(trans, ctx, sta_id, tid, frame_limit, ssn); } @@ -562,16 +562,16 @@ static inline void iwl_trans_free(struct iwl_trans *trans) static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) { - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); return trans->ops->wait_tx_queue_empty(trans); } static inline int iwl_trans_check_stuck_queue(struct iwl_trans *trans, int q) { - if (trans->state != IWL_TRANS_FW_ALIVE) - IWL_ERR(trans, "%s bad state = %d", __func__, trans->state); + WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, + "%s bad state = %d", __func__, trans->state); return trans->ops->check_stuck_queue(trans, q); } -- GitLab From 69a10b29eb87cf186cac20921b4884e349b59c97 Mon Sep 17 00:00:00 2001 From: Meenakshi Venkataraman Date: Sat, 10 Mar 2012 13:00:09 -0800 Subject: [PATCH 1667/1846] iwlwifi: move wait_command_queue from shared to trans This wait queue really belongs to the transport layer, as it is used for sending synchronous commands to the HW. However, only op_mode knows about errors and exceptional conditions, so make this queue accessible by the op_mode. Signed-off-by: Meenakshi Venkataraman Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 -- drivers/net/wireless/iwlwifi/iwl-core.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 3 --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 3 +++ drivers/net/wireless/iwlwifi/iwl-trans.h | 3 +++ 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index cc0227c1f352..44c6f712b77d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -671,7 +671,7 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv, wiphy_rfkill_set_hw_state(priv->hw->wiphy, test_bit(STATUS_RF_KILL_HW, &priv->status)); else - wake_up(&priv->shrd->wait_command_queue); + wake_up(&trans(priv)->wait_command_queue); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 5ef15855be2f..66d7446ff07b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -962,8 +962,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv) { priv->workqueue = create_singlethread_workqueue(DRV_NAME); - init_waitqueue_head(&priv->shrd->wait_command_queue); - INIT_WORK(&priv->restart, iwl_bg_restart); INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 8b85940731f2..e3eda50a5a67 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -850,7 +850,7 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) * commands by clearing the ready bit */ clear_bit(STATUS_READY, &priv->status); - wake_up(&priv->shrd->wait_command_queue); + wake_up(&trans(priv)->wait_command_queue); if (!ondemand) { /* diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index cf34087aa2fe..29d2a85232fc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -376,7 +376,6 @@ struct iwl_cfg { * @nic: pointer to the nic data * @hw_params: see struct iwl_hw_params * @lock: protect general shared data - * @wait_command_queue: the wait_queue for SYNC host commands * @eeprom: pointer to the eeprom/OTP image * @ucode_type: indicator of loaded ucode image * @device_pointers: pointers to ucode event tables @@ -391,8 +390,6 @@ struct iwl_shared { struct iwl_hw_params hw_params; const struct iwl_fw *fw; - wait_queue_head_t wait_command_queue; - /* eeprom -- this is in the card's little endian byte order */ u8 *eeprom; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index 8bec0e1ccb54..8b1a7988e176 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -684,7 +684,7 @@ static void iwl_irq_handle_error(struct iwl_trans *trans) */ clear_bit(STATUS_READY, &trans->shrd->status); clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); - wake_up(&trans->shrd->wait_command_queue); + wake_up(&trans->wait_command_queue); IWL_ERR(trans, "RF is used by WiMAX\n"); return; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 565c664f6dce..a66ad9b590a4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -928,7 +928,7 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_cmd_buffer *rxb, clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", get_cmd_string(cmd->hdr.cmd)); - wake_up(&trans->shrd->wait_command_queue); + wake_up(&trans->wait_command_queue); } meta->flags = 0; @@ -992,7 +992,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) return ret; } - ret = wait_event_timeout(trans->shrd->wait_command_queue, + ret = wait_event_timeout(trans->wait_command_queue, !test_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status), HOST_COMPLETE_TIMEOUT); if (!ret) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 4900dfa59df7..0e8e31a53c7a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -2327,6 +2327,9 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); } + /* Initialize the wait queue for commands */ + init_waitqueue_head(&trans->wait_command_queue); + return trans; out_pci_release_regions: diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 782cb0ddc962..0c81cbaa8088 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -413,6 +413,7 @@ enum iwl_trans_state { * @hw_id_str: a string with info about HW ID. Set during transport allocation. * @nvm_device_type: indicates OTP or eeprom * @pm_support: set to true in start_hw if link pm is supported + * @wait_command_queue: the wait_queue for SYNC host commands */ struct iwl_trans { const struct iwl_trans_ops *ops; @@ -429,6 +430,8 @@ struct iwl_trans { int nvm_device_type; bool pm_support; + wait_queue_head_t wait_command_queue; + /* pointer to trans specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ char trans_specific[0] __aligned(sizeof(void *)); -- GitLab From 8f7ffbe2b275e5315773322161945a24518e31f4 Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Sat, 10 Mar 2012 13:00:10 -0800 Subject: [PATCH 1668/1846] iwlwifi: avoid some operations if no uCode loaded Printing the SRAM and similar testmode operations could be triggered when no uCode is loaded; prevent those invalid operations by tracking whether uCode is loaded. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 1 + drivers/net/wireless/iwlwifi/iwl-agn.c | 2 ++ drivers/net/wireless/iwlwifi/iwl-core.c | 3 ++ drivers/net/wireless/iwlwifi/iwl-debugfs.c | 15 ++++++-- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 + drivers/net/wireless/iwlwifi/iwl-testmode.c | 40 +++++++++++---------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 6 ++++ 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 915183a3a873..3e1698dc995f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1189,6 +1189,7 @@ int iwlagn_suspend(struct iwl_priv *priv, struct cfg80211_wowlan *wowlan) memcpy(&rxon, &ctx->active, sizeof(rxon)); + priv->ucode_loaded = false; iwl_trans_stop_device(trans(priv)); priv->wowlan = true; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 66d7446ff07b..f1226dbf789d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -816,6 +816,7 @@ void iwl_down(struct iwl_priv *priv) if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); + priv->ucode_loaded = false; iwl_trans_stop_device(trans(priv)); /* Clear out all status bits but a few that are stable across reset */ @@ -1406,6 +1407,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode) iwl_tt_exit(priv); /*This will stop the queues, move the device to low power state */ + priv->ucode_loaded = false; iwl_trans_stop_device(trans(priv)); iwl_eeprom_free(priv->shrd); diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index e3eda50a5a67..46490d3b95b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -838,6 +838,9 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) iwl_print_rx_config_cmd(priv, IWL_RXON_CTX_BSS); #endif + /* uCode is no longer loaded. */ + priv->ucode_loaded = false; + /* Set the FW error flag -- cleared on iwl_down */ set_bit(STATUS_FW_ERROR, &priv->shrd->status); diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 9b71c87847c2..89cb9a7a3b56 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -235,10 +235,21 @@ 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) { priv->dbgfs_sram_offset = 0x800000; - if (priv->shrd->ucode_type == IWL_UCODE_INIT) + if (!priv->ucode_loaded) { + IWL_ERR(priv, "No uCode has been loadded.\n"); + return -EINVAL; + } + if (priv->shrd->ucode_type == IWL_UCODE_INIT) { priv->dbgfs_sram_len = priv->fw->ucode_init.data.len; - else + } else if (priv->shrd->ucode_type == IWL_UCODE_REGULAR) { priv->dbgfs_sram_len = priv->fw->ucode_rt.data.len; + } else if (priv->shrd->ucode_type == IWL_UCODE_WOWLAN) { + priv->dbgfs_sram_len = priv->fw->ucode_wowlan.data.len; + } else { + IWL_ERR(priv, "Unsupported type of uCode loaded?" + " that shouldn't happen.\n"); + return -EINVAL; + } } len = priv->dbgfs_sram_len; diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index aa4b3b122da4..01dbe1162f96 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -769,6 +769,7 @@ struct iwl_priv { /* firmware reload counter and timestamp */ unsigned long reload_jiffies; int reload_count; + bool ucode_loaded; /* we allocate array of iwl_channel_info for NIC's valid channels. * Access via channel # using indirect index array */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index b06c6763cb7a..c6c084f45b72 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -494,6 +494,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: iwl_testmode_cfg_init_calib(priv); + priv->ucode_loaded = false; iwl_trans_stop_device(trans); break; @@ -512,6 +513,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: iwl_scan_cancel_timeout(priv, 200); + priv->ucode_loaded = false; iwl_trans_stop_device(trans); status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); if (status) { @@ -591,25 +593,27 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) IWL_ERR(priv, "Memory allocation fail\n"); return -ENOMEM; } - switch (priv->shrd->ucode_type) { - case IWL_UCODE_REGULAR: - inst_size = priv->fw->ucode_rt.code.len; - data_size = priv->fw->ucode_rt.data.len; - break; - case IWL_UCODE_INIT: - inst_size = priv->fw->ucode_init.code.len; - data_size = priv->fw->ucode_init.data.len; - break; - case IWL_UCODE_WOWLAN: - inst_size = priv->fw->ucode_wowlan.code.len; - data_size = priv->fw->ucode_wowlan.data.len; - break; - case IWL_UCODE_NONE: + if (!priv->ucode_loaded) { IWL_ERR(priv, "No uCode has not been loaded\n"); - break; - default: - IWL_ERR(priv, "Unsupported uCode type\n"); - break; + return -EINVAL; + } else { + switch (priv->shrd->ucode_type) { + case IWL_UCODE_REGULAR: + inst_size = priv->fw->ucode_rt.code.len; + data_size = priv->fw->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + inst_size = priv->fw->ucode_init.code.len; + data_size = priv->fw->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + inst_size = priv->fw->ucode_wowlan.code.len; + data_size = priv->fw->ucode_wowlan.data.len; + break; + default: + IWL_ERR(priv, "Unsupported uCode type\n"); + break; + } } NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type); NLA_PUT_U32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index d97cf44b75ba..ae935c0e3563 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -465,6 +465,8 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv, priv->shrd->ucode_type = ucode_type; fw = iwl_get_ucode_image(priv, ucode_type); + priv->ucode_loaded = false; + if (!fw) return -EINVAL; @@ -519,6 +521,8 @@ int iwl_load_ucode_wait_alive(struct iwl_priv *priv, return ret; } + priv->ucode_loaded = true; + return 0; } @@ -563,5 +567,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv) out: /* Whatever happened, stop the device */ iwl_trans_stop_device(trans(priv)); + priv->ucode_loaded = false; + return ret; } -- GitLab From b5ea1624833b816184aa262c190f2774b8d2ea63 Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Sat, 10 Mar 2012 13:00:11 -0800 Subject: [PATCH 1669/1846] iwlwifi: explicitly track whether INIT uCode was run Remove IWL_UCODE_NONE from enum iwl_ucode_type which, by being the default value in 0-initialized memory, implicitly allowed us to track whether any uCode had ever been loaded successfully (which would have been the INIT uCode) and instead explicitly track whether or not INIT uCode has been run. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 + drivers/net/wireless/iwlwifi/iwl-shared.h | 4 +--- drivers/net/wireless/iwlwifi/iwl-ucode.c | 6 ++++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 01dbe1162f96..16956b777f96 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -770,6 +770,7 @@ struct iwl_priv { unsigned long reload_jiffies; int reload_count; bool ucode_loaded; + bool init_ucode_run; /* Don't run init uCode again */ /* we allocate array of iwl_channel_info for NIC's valid channels. * Access via channel # using indirect index array */ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 29d2a85232fc..4cd2eced8a4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -195,15 +195,13 @@ struct iwl_hw_params { /** * enum iwl_ucode_type * - * The type of ucode currently loaded on the hardware. + * The type of ucode. * - * @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, diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index ae935c0e3563..0908880dd7ac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -87,7 +87,7 @@ iwl_get_ucode_image(struct iwl_priv *priv, enum iwl_ucode_type ucode_type) return &priv->fw->ucode_wowlan; case IWL_UCODE_REGULAR: return &priv->fw->ucode_rt; - case IWL_UCODE_NONE: + default: break; } return NULL; @@ -537,7 +537,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv) if (!priv->fw->ucode_init.code.len) return 0; - if (priv->shrd->ucode_type != IWL_UCODE_NONE) + if (priv->init_ucode_run) return 0; iwl_init_notification_wait(&priv->notif_wait, &calib_wait, @@ -559,6 +559,8 @@ int iwl_run_init_ucode(struct iwl_priv *priv) */ ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, UCODE_CALIB_TIMEOUT); + if (!ret) + priv->init_ucode_run = true; goto out; -- GitLab From 0cedacc5797bbae5b07e5e861fbe7b8e33f2ef78 Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Sat, 10 Mar 2012 13:00:12 -0800 Subject: [PATCH 1670/1846] iwlwifi: more modularity in fw images and sections Changed iwl_firmware_pieces structure to support an array of separate images, and an array of sections for each image. In fw_sec and fw_desc structures, added a field for offset from the HW address, to support 16.0 uCode that provides an offset instead of any other data about the section. This field is filled with default values when parsing instruction or data section. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-drv.c | 280 ++++++++++++++++------ drivers/net/wireless/iwlwifi/iwl-fw.h | 3 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 1 + 3 files changed, 207 insertions(+), 77 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 29a3ae48df6d..a21af3df6c8a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -69,6 +69,7 @@ #include "iwl-trans.h" #include "iwl-shared.h" #include "iwl-op-mode.h" +#include "iwl-agn-hw.h" /* private includes */ #include "iwl-fw-file.h" @@ -96,6 +97,16 @@ struct iwl_drv { +/* + * struct fw_sec: Just for the image parsing proccess. + * For the fw storage we are using struct fw_desc. + */ +struct fw_sec { + const void *data; /* the sec data */ + size_t size; /* section size */ + u32 offset; /* offset of writing in the device */ +}; + static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) { if (desc->v_addr) @@ -119,20 +130,21 @@ static void iwl_dealloc_ucode(struct iwl_drv *drv) } static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, - const void *data, size_t len) + struct fw_sec *sec) { - if (!len) { + if (!sec || !sec->size) { desc->v_addr = NULL; return -EINVAL; } - desc->v_addr = dma_alloc_coherent(trans(drv)->dev, len, + desc->v_addr = dma_alloc_coherent(trans(drv)->dev, sec->size, &desc->p_addr, GFP_KERNEL); if (!desc->v_addr) return -ENOMEM; - desc->len = len; - memcpy(desc->v_addr, data, len); + desc->len = sec->size; + desc->offset = sec->offset; + memcpy(desc->v_addr, sec->data, sec->size); return 0; } @@ -177,18 +189,77 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first) GFP_KERNEL, drv, iwl_ucode_callback); } -struct iwlagn_firmware_pieces { - const void *inst, *data, *init, *init_data, *wowlan_inst, *wowlan_data; - size_t inst_size, data_size, init_size, init_data_size, - wowlan_inst_size, wowlan_data_size; +/* + * enumeration of ucode section. + * This enumeration is used for legacy tlv style (before 16.0 uCode). + */ +enum iwl_ucode_sec { + IWL_UCODE_SECTION_INST, + IWL_UCODE_SECTION_DATA, +}; +/* + * For 16.0 uCode and above, there is no differentiation between section, + * just an offset to the HW address. + */ +#define UCODE_SECTION_MAX 4 + +struct fw_img_parsing { + struct fw_sec sec[UCODE_SECTION_MAX]; + int sec_counter; +}; + +struct iwl_firmware_pieces { + struct fw_img_parsing img[IWL_UCODE_TYPE_MAX]; u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; }; +/* + * These functions are just to extract uCode section data from the pieces + * structure. + */ +static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces, + enum iwl_ucode_type type, + int sec) +{ + return &pieces->img[type].sec[sec]; +} + +static void set_sec_data(struct iwl_firmware_pieces *pieces, + enum iwl_ucode_type type, + int sec, + const void *data) +{ + pieces->img[type].sec[sec].data = data; +} + +static void set_sec_size(struct iwl_firmware_pieces *pieces, + enum iwl_ucode_type type, + int sec, + size_t size) +{ + pieces->img[type].sec[sec].size = size; +} + +static size_t get_sec_size(struct iwl_firmware_pieces *pieces, + enum iwl_ucode_type type, + int sec) +{ + return pieces->img[type].sec[sec].size; +} + +static void set_sec_offset(struct iwl_firmware_pieces *pieces, + enum iwl_ucode_type type, + int sec, + u32 offset) +{ + pieces->img[type].sec[sec].offset = offset; +} + static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, - const struct firmware *ucode_raw, - struct iwlagn_firmware_pieces *pieces) + const struct firmware *ucode_raw, + struct iwl_firmware_pieces *pieces) { struct iwl_ucode_header *ucode = (void *)ucode_raw->data; u32 api_ver, hdr_size, build; @@ -206,11 +277,14 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, return -EINVAL; } build = le32_to_cpu(ucode->u.v2.build); - pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); - pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); - pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); - pieces->init_data_size = - le32_to_cpu(ucode->u.v2.init_data_size); + set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, + le32_to_cpu(ucode->u.v2.inst_size)); + set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, + le32_to_cpu(ucode->u.v2.data_size)); + set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, + le32_to_cpu(ucode->u.v2.init_size)); + set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, + le32_to_cpu(ucode->u.v2.init_data_size)); src = ucode->u.v2.data; break; case 0: @@ -222,11 +296,14 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, return -EINVAL; } build = 0; - pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); - pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); - pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); - pieces->init_data_size = - le32_to_cpu(ucode->u.v1.init_data_size); + set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, + le32_to_cpu(ucode->u.v1.inst_size)); + set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, + le32_to_cpu(ucode->u.v1.data_size)); + set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, + le32_to_cpu(ucode->u.v1.init_size)); + set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, + le32_to_cpu(ucode->u.v1.init_data_size)); src = ucode->u.v1.data; break; } @@ -248,9 +325,12 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, buildstr); /* 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) { + + if (ucode_raw->size != hdr_size + + get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) + + get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) + + get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) + + get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { IWL_ERR(drv, "uCode file size %d does not match expected size\n", @@ -258,21 +338,29 @@ static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, 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; + set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src); + src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST); + set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, + IWLAGN_RTC_INST_LOWER_BOUND); + set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src); + src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA); + set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, + IWLAGN_RTC_DATA_LOWER_BOUND); + set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src); + src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST); + set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, + IWLAGN_RTC_INST_LOWER_BOUND); + set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src); + src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA); + set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, + IWLAGN_RTC_DATA_LOWER_BOUND); return 0; } static int iwl_parse_tlv_firmware(struct iwl_drv *drv, const struct firmware *ucode_raw, - struct iwlagn_firmware_pieces *pieces, + struct iwl_firmware_pieces *pieces, struct iwl_ucode_capabilities *capa) { struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; @@ -368,20 +456,40 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, switch (tlv_type) { case IWL_UCODE_TLV_INST: - pieces->inst = tlv_data; - pieces->inst_size = tlv_len; + set_sec_data(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST, tlv_data); + set_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST, tlv_len); + set_sec_offset(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST, + IWLAGN_RTC_INST_LOWER_BOUND); break; case IWL_UCODE_TLV_DATA: - pieces->data = tlv_data; - pieces->data_size = tlv_len; + set_sec_data(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA, tlv_data); + set_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA, tlv_len); + set_sec_offset(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA, + IWLAGN_RTC_DATA_LOWER_BOUND); break; case IWL_UCODE_TLV_INIT: - pieces->init = tlv_data; - pieces->init_size = tlv_len; + set_sec_data(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_INST, tlv_data); + set_sec_size(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_INST, tlv_len); + set_sec_offset(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_INST, + IWLAGN_RTC_INST_LOWER_BOUND); break; case IWL_UCODE_TLV_INIT_DATA: - pieces->init_data = tlv_data; - pieces->init_data_size = tlv_len; + set_sec_data(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_DATA, tlv_data); + set_sec_size(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_DATA, tlv_len); + set_sec_offset(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_DATA, + IWLAGN_RTC_DATA_LOWER_BOUND); break; case IWL_UCODE_TLV_BOOT: IWL_ERR(drv, "Found unexpected BOOT ucode\n"); @@ -455,12 +563,22 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, drv->fw.enhance_sensitivity_table = true; break; case IWL_UCODE_TLV_WOWLAN_INST: - pieces->wowlan_inst = tlv_data; - pieces->wowlan_inst_size = tlv_len; + set_sec_data(pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_INST, tlv_data); + set_sec_size(pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_INST, tlv_len); + set_sec_offset(pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_INST, + IWLAGN_RTC_INST_LOWER_BOUND); break; case IWL_UCODE_TLV_WOWLAN_DATA: - pieces->wowlan_data = tlv_data; - pieces->wowlan_data_size = tlv_len; + set_sec_data(pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_DATA, tlv_data); + set_sec_size(pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_DATA, tlv_len); + set_sec_offset(pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_DATA, + IWLAGN_RTC_DATA_LOWER_BOUND); break; case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: if (tlv_len != sizeof(u32)) @@ -502,7 +620,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) struct iwl_fw *fw = &drv->fw; struct iwl_ucode_header *ucode; int err; - struct iwlagn_firmware_pieces pieces; + struct iwl_firmware_pieces pieces; const unsigned int api_max = cfg->ucode_api_max; unsigned int api_ok = cfg->ucode_api_ok; const unsigned int api_min = cfg->ucode_api_min; @@ -588,36 +706,46 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) IWL_DEBUG_INFO(drv, "f/w package hdr ucode version raw = 0x%x\n", drv->fw.ucode_ver); IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", - pieces.inst_size); + get_sec_size(&pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST)); IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", - pieces.data_size); + get_sec_size(&pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA)); IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", - pieces.init_size); + get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST)); IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", - pieces.init_data_size); + get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)); /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > cfg->max_inst_size) { + if (get_sec_size(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) > + cfg->max_inst_size) { IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", - pieces.inst_size); + get_sec_size(&pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST)); goto try_again; } - if (pieces.data_size > cfg->max_data_size) { + if (get_sec_size(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) > + cfg->max_data_size) { IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", - pieces.data_size); + get_sec_size(&pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA)); goto try_again; } - if (pieces.init_size > cfg->max_inst_size) { + if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > + cfg->max_inst_size) { IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", - pieces.init_size); + get_sec_size(&pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_INST)); goto try_again; } - if (pieces.init_data_size > cfg->max_data_size) { + if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > + cfg->max_data_size) { IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", - pieces.init_data_size); + get_sec_size(&pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA)); goto try_again; } @@ -627,35 +755,35 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code, - pieces.inst, pieces.inst_size)) + get_sec(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST))) goto err_pci_alloc; if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data, - pieces.data, pieces.data_size)) + get_sec(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA))) goto err_pci_alloc; /* Initialization instructions and data */ - if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(drv, - &drv->fw.ucode_init.code, - pieces.init, pieces.init_size)) + if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) && + get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { + if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_init.code, + get_sec(&pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_INST))) goto err_pci_alloc; - if (iwl_alloc_fw_desc(drv, - &drv->fw.ucode_init.data, - pieces.init_data, pieces.init_data_size)) + if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_init.data, + get_sec(&pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_DATA))) goto err_pci_alloc; } /* WoWLAN instructions and data */ - if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { - if (iwl_alloc_fw_desc(drv, - &drv->fw.ucode_wowlan.code, - pieces.wowlan_inst, - pieces.wowlan_inst_size)) + if (get_sec_size(&pieces, IWL_UCODE_WOWLAN, IWL_UCODE_SECTION_INST) && + get_sec_size(&pieces, IWL_UCODE_WOWLAN, IWL_UCODE_SECTION_DATA)) { + if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_wowlan.code, + get_sec(&pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_INST))) goto err_pci_alloc; - if (iwl_alloc_fw_desc(drv, - &drv->fw.ucode_wowlan.data, - pieces.wowlan_data, - pieces.wowlan_data_size)) + if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_wowlan.data, + get_sec(&pieces, IWL_UCODE_WOWLAN, + IWL_UCODE_SECTION_DATA))) goto err_pci_alloc; } diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index 453812a21176..253f7e501d46 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h @@ -91,11 +91,12 @@ struct iwl_ucode_capabilities { u32 flags; }; -/* one for each uCode image (inst/data, boot/init/runtime) */ +/* one for each uCode image (inst/data, init/runtime/wowlan) */ struct fw_desc { dma_addr_t p_addr; /* hardware address */ void *v_addr; /* software address */ u32 len; /* size in bytes */ + u32 offset; /* offset in the device */ }; struct fw_img { diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 4cd2eced8a4c..d899c5c40e07 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -205,6 +205,7 @@ enum iwl_ucode_type { IWL_UCODE_REGULAR, IWL_UCODE_INIT, IWL_UCODE_WOWLAN, + IWL_UCODE_TYPE_MAX, }; /* -- GitLab From ed8c8365c4431eeb733def3dd314cf303e1b12ea Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Sat, 10 Mar 2012 13:00:13 -0800 Subject: [PATCH 1671/1846] iwlwifi: Add TLVs and fields for 16.0 uCode New TLVs for ucode sections that are not known as instruction or data. New TLVs for phy-configuration and default calibrations. Add default calib and phy config fields to iwl_fw. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-drv.c | 84 ++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-fw-file.h | 5 ++ drivers/net/wireless/iwlwifi/iwl-fw.h | 19 +++++ drivers/net/wireless/iwlwifi/iwl-shared.h | 16 ----- 4 files changed, 108 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index a21af3df6c8a..19ccd36a55b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -208,6 +208,25 @@ struct fw_img_parsing { int sec_counter; }; +/* + * struct fw_sec_parsing: to extract fw section and it's offset from tlv + */ +struct fw_sec_parsing { + __le32 offset; + const u8 data[]; +} __packed; + +/** + * struct iwl_tlv_calib_data - parse the default calib data from TLV + * + * @ucode_type: the uCode to which the following default calib relates. + * @calib: default calibrations. + */ +struct iwl_tlv_calib_data { + __le32 ucode_type; + __le64 calib; +} __packed; + struct iwl_firmware_pieces { struct fw_img_parsing img[IWL_UCODE_TYPE_MAX]; @@ -257,6 +276,47 @@ static void set_sec_offset(struct iwl_firmware_pieces *pieces, pieces->img[type].sec[sec].offset = offset; } +/* + * Gets uCode section from tlv. + */ +static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces, + const void *data, enum iwl_ucode_type type, + int size) +{ + struct fw_img_parsing *img; + struct fw_sec *sec; + struct fw_sec_parsing *sec_parse; + + if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX)) + return -1; + + sec_parse = (struct fw_sec_parsing *)data; + + img = &pieces->img[type]; + sec = &img->sec[img->sec_counter]; + + sec->offset = le32_to_cpu(sec_parse->offset); + sec->data = sec_parse->data; + + ++img->sec_counter; + + return 0; +} + +static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data) +{ + struct iwl_tlv_calib_data *def_calib = + (struct iwl_tlv_calib_data *)data; + u32 ucode_type = le32_to_cpu(def_calib->ucode_type); + if (ucode_type >= IWL_UCODE_TYPE_MAX) { + IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n", + ucode_type); + return -EINVAL; + } + drv->fw.default_calib[ucode_type] = le64_to_cpu(def_calib->calib); + return 0; +} + static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, const struct firmware *ucode_raw, struct iwl_firmware_pieces *pieces) @@ -586,6 +646,29 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, capa->standard_phy_calibration_size = le32_to_cpup((__le32 *)tlv_data); break; + case IWL_UCODE_TLV_SEC_RT: + iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, + tlv_len); + break; + case IWL_UCODE_TLV_SEC_INIT: + iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, + tlv_len); + break; + case IWL_UCODE_TLV_SEC_WOWLAN: + iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, + tlv_len); + break; + case IWL_UCODE_TLV_DEF_CALIB: + if (tlv_len != sizeof(struct iwl_tlv_calib_data)) + goto invalid_tlv_len; + if (iwl_set_default_calib(drv, tlv_data)) + goto tlv_error; + break; + case IWL_UCODE_TLV_PHY_SKU: + if (tlv_len != sizeof(u32)) + goto invalid_tlv_len; + drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data); + break; default: IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type); break; @@ -602,6 +685,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, invalid_tlv_len: IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); + tlv_error: iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len); return -EINVAL; diff --git a/drivers/net/wireless/iwlwifi/iwl-fw-file.h b/drivers/net/wireless/iwlwifi/iwl-fw-file.h index 7ca6c9526357..c924ccb93c8c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw-file.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw-file.h @@ -124,6 +124,11 @@ enum iwl_ucode_tlv_type { IWL_UCODE_TLV_WOWLAN_INST = 16, IWL_UCODE_TLV_WOWLAN_DATA = 17, IWL_UCODE_TLV_FLAGS = 18, + IWL_UCODE_TLV_SEC_RT = 19, + IWL_UCODE_TLV_SEC_INIT = 20, + IWL_UCODE_TLV_SEC_WOWLAN = 21, + IWL_UCODE_TLV_DEF_CALIB = 22, + IWL_UCODE_TLV_PHY_SKU = 23, }; struct iwl_ucode_tlv { diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index 253f7e501d46..c99a7fd1d29a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h @@ -85,6 +85,22 @@ enum iwl_ucode_tlv_flag { #define IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE 19 #define IWL_MAX_PHY_CALIBRATE_TBL_SIZE 253 +/** + * enum iwl_ucode_type + * + * The type of ucode. + * + * @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_REGULAR, + IWL_UCODE_INIT, + IWL_UCODE_WOWLAN, + IWL_UCODE_TYPE_MAX, +}; + struct iwl_ucode_capabilities { u32 max_probe_length; u32 standard_phy_calibration_size; @@ -142,6 +158,9 @@ struct iwl_fw { u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; + + u64 default_calib[IWL_UCODE_TYPE_MAX]; + u32 phy_config; }; #endif /* __iwl_fw_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index d899c5c40e07..b515d657a0ad 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -192,22 +192,6 @@ struct iwl_hw_params { const struct iwl_sensitivity_ranges *sens; }; -/** - * enum iwl_ucode_type - * - * The type of ucode. - * - * @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_REGULAR, - IWL_UCODE_INIT, - IWL_UCODE_WOWLAN, - IWL_UCODE_TYPE_MAX, -}; - /* * LED mode * IWL_LED_DEFAULT: use device default -- GitLab From 6dfa8d019cd21d08634ceb65a3fb90d0648bd93b Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Sat, 10 Mar 2012 13:00:14 -0800 Subject: [PATCH 1672/1846] iwlwifi: change struct iwl_fw Change iwl_fw struct to hold an array of fw_img instead of three separated instances. Change fw_img to hold an array of fw_desc instead of two separate descriptors for instructions and data. Change load_given_ucode, load_section, verification functions etc. to support this structure. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 17 +-- drivers/net/wireless/iwlwifi/iwl-drv.c | 141 ++++++++++-------- drivers/net/wireless/iwlwifi/iwl-fw.h | 25 +++- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 15 +- drivers/net/wireless/iwlwifi/iwl-testmode.c | 21 +-- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 32 ++-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 29 ++-- 7 files changed, 139 insertions(+), 141 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 89cb9a7a3b56..b7b1c04f2fba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -230,6 +230,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, int pos = 0; int sram; struct iwl_priv *priv = file->private_data; + const struct fw_img *img; size_t bufsz; /* default is to dump the entire data segment */ @@ -239,17 +240,8 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, IWL_ERR(priv, "No uCode has been loadded.\n"); return -EINVAL; } - if (priv->shrd->ucode_type == IWL_UCODE_INIT) { - priv->dbgfs_sram_len = priv->fw->ucode_init.data.len; - } else if (priv->shrd->ucode_type == IWL_UCODE_REGULAR) { - priv->dbgfs_sram_len = priv->fw->ucode_rt.data.len; - } else if (priv->shrd->ucode_type == IWL_UCODE_WOWLAN) { - priv->dbgfs_sram_len = priv->fw->ucode_wowlan.data.len; - } else { - IWL_ERR(priv, "Unsupported type of uCode loaded?" - " that shouldn't happen.\n"); - return -EINVAL; - } + img = &priv->fw->img[priv->shrd->ucode_type]; + priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; } len = priv->dbgfs_sram_len; @@ -346,13 +338,14 @@ static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, size_t count, loff_t *ppos) { struct iwl_priv *priv = file->private_data; + const struct fw_img *img = &priv->fw->img[IWL_UCODE_WOWLAN]; if (!priv->wowlan_sram) return -ENODATA; return simple_read_from_buffer(user_buf, count, ppos, priv->wowlan_sram, - priv->fw->ucode_wowlan.data.len); + img->sec[IWL_UCODE_SECTION_DATA].len); } static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 19ccd36a55b3..54e09696fc9d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -118,15 +118,16 @@ static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img) { - iwl_free_fw_desc(drv, &img->code); - iwl_free_fw_desc(drv, &img->data); + int i; + for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) + iwl_free_fw_desc(drv, &img->sec[i]); } static void iwl_dealloc_ucode(struct iwl_drv *drv) { - iwl_free_fw_img(drv, &drv->fw.ucode_rt); - iwl_free_fw_img(drv, &drv->fw.ucode_init); - iwl_free_fw_img(drv, &drv->fw.ucode_wowlan); + int i; + for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) + iwl_free_fw_img(drv, drv->fw.img + i); } static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, @@ -189,22 +190,8 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first) GFP_KERNEL, drv, iwl_ucode_callback); } -/* - * enumeration of ucode section. - * This enumeration is used for legacy tlv style (before 16.0 uCode). - */ -enum iwl_ucode_sec { - IWL_UCODE_SECTION_INST, - IWL_UCODE_SECTION_DATA, -}; -/* - * For 16.0 uCode and above, there is no differentiation between section, - * just an offset to the HW address. - */ -#define UCODE_SECTION_MAX 4 - struct fw_img_parsing { - struct fw_sec sec[UCODE_SECTION_MAX]; + struct fw_sec sec[IWL_UCODE_SECTION_MAX]; int sec_counter; }; @@ -691,6 +678,71 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, return -EINVAL; } +static int alloc_pci_desc(struct iwl_drv *drv, + struct iwl_firmware_pieces *pieces, + enum iwl_ucode_type type) +{ + int i; + for (i = 0; + i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i); + i++) + if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]), + get_sec(pieces, type, i))) + return -1; + return 0; +} + +static int validate_sec_sizes(struct iwl_drv *drv, + struct iwl_firmware_pieces *pieces, + const struct iwl_cfg *cfg) +{ + IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", + get_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST)); + IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", + get_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA)); + IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", + get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST)); + IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", + get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)); + + /* Verify that uCode images will fit in card's SRAM. */ + if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) > + cfg->max_inst_size) { + IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", + get_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_INST)); + return -1; + } + + if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) > + cfg->max_data_size) { + IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", + get_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA)); + return -1; + } + + if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > + cfg->max_inst_size) { + IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", + get_sec_size(pieces, IWL_UCODE_INIT, + IWL_UCODE_SECTION_INST)); + return -1; + } + + if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > + cfg->max_data_size) { + IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", + get_sec_size(pieces, IWL_UCODE_REGULAR, + IWL_UCODE_SECTION_DATA)); + return -1; + } + return 0; +} + + /** * iwl_ucode_callback - callback when firmware was loaded * @@ -709,6 +761,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) unsigned int api_ok = cfg->ucode_api_ok; const unsigned int api_min = cfg->ucode_api_min; u32 api_ver; + int i; fw->ucode_capa.max_probe_length = 200; fw->ucode_capa.standard_phy_calibration_size = @@ -817,59 +870,17 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) goto try_again; } - if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > - cfg->max_inst_size) { - IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", - get_sec_size(&pieces, IWL_UCODE_INIT, - IWL_UCODE_SECTION_INST)); + if (validate_sec_sizes(drv, &pieces, cfg)) goto try_again; - } - - if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > - cfg->max_data_size) { - IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", - get_sec_size(&pieces, IWL_UCODE_REGULAR, - IWL_UCODE_SECTION_DATA)); - 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 */ - if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.code, - get_sec(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST))) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_rt.data, - get_sec(&pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA))) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) && - get_sec_size(&pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { - if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_init.code, - get_sec(&pieces, IWL_UCODE_INIT, - IWL_UCODE_SECTION_INST))) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_init.data, - get_sec(&pieces, IWL_UCODE_INIT, - IWL_UCODE_SECTION_DATA))) + for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) + if (alloc_pci_desc(drv, &pieces, i)) goto err_pci_alloc; - } - - /* WoWLAN instructions and data */ - if (get_sec_size(&pieces, IWL_UCODE_WOWLAN, IWL_UCODE_SECTION_INST) && - get_sec_size(&pieces, IWL_UCODE_WOWLAN, IWL_UCODE_SECTION_DATA)) { - if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_wowlan.code, - get_sec(&pieces, IWL_UCODE_WOWLAN, - IWL_UCODE_SECTION_INST))) - goto err_pci_alloc; - if (iwl_alloc_fw_desc(drv, &drv->fw.ucode_wowlan.data, - get_sec(&pieces, IWL_UCODE_WOWLAN, - IWL_UCODE_SECTION_DATA))) - goto err_pci_alloc; - } /* Now that we can no longer fail, copy information */ diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index c99a7fd1d29a..5d634f3db929 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h @@ -101,6 +101,20 @@ enum iwl_ucode_type { IWL_UCODE_TYPE_MAX, }; +/* + * enumeration of ucode section. + * This enumeration is used for legacy tlv style (before 16.0 uCode). + */ +enum iwl_ucode_sec { + IWL_UCODE_SECTION_INST, + IWL_UCODE_SECTION_DATA, +}; +/* + * For 16.0 uCode and above, there is no differentiation between sections, + * just an offset to the HW address. + */ +#define IWL_UCODE_SECTION_MAX 4 + struct iwl_ucode_capabilities { u32 max_probe_length; u32 standard_phy_calibration_size; @@ -116,8 +130,7 @@ struct fw_desc { }; struct fw_img { - struct fw_desc code; /* firmware code image */ - struct fw_desc data; /* firmware data image */ + struct fw_desc sec[IWL_UCODE_SECTION_MAX]; }; /* uCode version contains 4 values: Major/Minor/API/Serial */ @@ -131,9 +144,7 @@ struct fw_img { * * @ucode_ver: ucode version from the ucode file * @fw_version: firmware version string - * @ucode_rt: run time ucode image - * @ucode_init: init ucode image - * @ucode_wowlan: wake on wireless ucode image (optional) + * @img: ucode image like ucode_rt, ucode_init, ucode_wowlan. * @ucode_capa: capabilities parsed from the ucode file. * @enhance_sensitivity_table: device can do enhanced sensitivity. * @init_evtlog_ptr: event log offset for init ucode. @@ -149,9 +160,7 @@ struct iwl_fw { char fw_version[ETHTOOL_BUSINFO_LEN]; /* ucode images */ - struct fw_img ucode_rt; - struct fw_img ucode_init; - struct fw_img ucode_wowlan; + struct fw_img img[IWL_UCODE_TYPE_MAX]; struct iwl_ucode_capabilities ucode_capa; bool enhance_sensitivity_table; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 9212ee3bef9b..b6805f8e9a01 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -196,7 +196,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_DISABLE_BEACON_HINTS | WIPHY_FLAG_IBSS_RSN; - if (priv->fw->ucode_wowlan.code.len && + if (priv->fw->img[IWL_UCODE_WOWLAN].sec[0].len && trans(priv)->ops->wowlan_suspend && device_can_wakeup(trans(priv)->dev)) { hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | @@ -437,6 +437,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) unsigned long flags; u32 base, status = 0xffffffff; int ret = -EIO; + const struct fw_img *img; IWL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->mutex); @@ -457,16 +458,18 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) #ifdef CONFIG_IWLWIFI_DEBUGFS if (ret == 0) { - if (!priv->wowlan_sram) + img = &(priv->fw->img[IWL_UCODE_WOWLAN]); + if (!priv->wowlan_sram) { priv->wowlan_sram = - kzalloc(priv->fw->ucode_wowlan.data.len, + kzalloc(img->sec[IWL_UCODE_SECTION_DATA].len, GFP_KERNEL); + } if (priv->wowlan_sram) _iwl_read_targ_mem_words( - trans(priv), 0x800000, - priv->wowlan_sram, - priv->fw->ucode_wowlan.data.len / 4); + trans(priv), 0x800000, + priv->wowlan_sram, + img->sec[IWL_UCODE_SECTION_DATA].len / 4); } #endif } diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index c6c084f45b72..76f7f9251436 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -466,6 +466,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) unsigned char *rsp_data_ptr = NULL; int status = 0, rsp_data_len = 0; u32 devid, inst_size = 0, data_size = 0; + const struct fw_img *img; switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: @@ -597,23 +598,9 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) IWL_ERR(priv, "No uCode has not been loaded\n"); return -EINVAL; } else { - switch (priv->shrd->ucode_type) { - case IWL_UCODE_REGULAR: - inst_size = priv->fw->ucode_rt.code.len; - data_size = priv->fw->ucode_rt.data.len; - break; - case IWL_UCODE_INIT: - inst_size = priv->fw->ucode_init.code.len; - data_size = priv->fw->ucode_init.data.len; - break; - case IWL_UCODE_WOWLAN: - inst_size = priv->fw->ucode_wowlan.code.len; - data_size = priv->fw->ucode_wowlan.data.len; - break; - default: - IWL_ERR(priv, "Unsupported uCode type\n"); - break; - } + img = &priv->fw->img[priv->shrd->ucode_type]; + inst_size = img->sec[IWL_UCODE_SECTION_INST].len; + data_size = img->sec[IWL_UCODE_SECTION_DATA].len; } NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type); NLA_PUT_U32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 0e8e31a53c7a..b4f796c82e1e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -951,12 +951,13 @@ static const u8 iwlagn_pan_ac_to_queue[] = { /* * ucode */ -static int iwl_load_section(struct iwl_trans *trans, const char *name, - const struct fw_desc *image, u32 dst_addr) +static int iwl_load_section(struct iwl_trans *trans, u8 section_num, + const struct fw_desc *section) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - dma_addr_t phy_addr = image->p_addr; - u32 byte_cnt = image->len; + dma_addr_t phy_addr = section->p_addr; + u32 byte_cnt = section->len; + u32 dst_addr = section->offset; int ret; trans_pcie->ucode_write_complete = false; @@ -989,12 +990,13 @@ static int iwl_load_section(struct iwl_trans *trans, const char *name, FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); - IWL_DEBUG_FW(trans, "%s uCode section being loaded...\n", name); + IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n", + section_num); ret = wait_event_timeout(trans_pcie->ucode_write_waitq, trans_pcie->ucode_write_complete, 5 * HZ); if (!ret) { - IWL_ERR(trans, "Could not load the %s uCode section\n", - name); + IWL_ERR(trans, "Could not load the [%d] uCode section\n", + section_num); return -ETIMEDOUT; } @@ -1005,16 +1007,16 @@ static int iwl_load_given_ucode(struct iwl_trans *trans, const struct fw_img *image) { int ret = 0; + int i; - ret = iwl_load_section(trans, "INST", &image->code, - IWLAGN_RTC_INST_LOWER_BOUND); - if (ret) - return ret; + for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) { + if (!image->sec[i].p_addr) + break; - ret = iwl_load_section(trans, "DATA", &image->data, - IWLAGN_RTC_DATA_LOWER_BOUND); - if (ret) - return ret; + ret = iwl_load_section(trans, i, &image->sec[i]); + if (ret) + return ret; + } /* Remove all resets to allow NIC to operate */ iwl_write32(trans, CSR_RESET, 0); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0908880dd7ac..252828728837 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -80,17 +80,10 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { static inline const struct fw_img * iwl_get_ucode_image(struct iwl_priv *priv, enum iwl_ucode_type ucode_type) { - switch (ucode_type) { - case IWL_UCODE_INIT: - return &priv->fw->ucode_init; - case IWL_UCODE_WOWLAN: - return &priv->fw->ucode_wowlan; - case IWL_UCODE_REGULAR: - return &priv->fw->ucode_rt; - default: - break; - } - return NULL; + if (ucode_type >= IWL_UCODE_TYPE_MAX) + return NULL; + + return &priv->fw->img[ucode_type]; } /* @@ -342,7 +335,7 @@ static int iwl_alive_notify(struct iwl_priv *priv) * 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_priv *priv, +static int iwl_verify_sec_sparse(struct iwl_priv *priv, const struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; @@ -357,7 +350,7 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, /* NOTE: Use the debugless read so we don't flood kernel log * if IWL_DL_IO is set */ iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR, - i + IWLAGN_RTC_INST_LOWER_BOUND); + i + fw_desc->offset); val = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) return -EIO; @@ -366,7 +359,7 @@ static int iwl_verify_inst_sparse(struct iwl_priv *priv, return 0; } -static void iwl_print_mismatch_inst(struct iwl_priv *priv, +static void iwl_print_mismatch_sec(struct iwl_priv *priv, const struct fw_desc *fw_desc) { __le32 *image = (__le32 *)fw_desc->v_addr; @@ -378,7 +371,7 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); iwl_write_direct32(trans(priv), HBUS_TARG_MEM_RADDR, - IWLAGN_RTC_INST_LOWER_BOUND); + fw_desc->offset); for (offs = 0; offs < len && errors < 20; @@ -408,14 +401,14 @@ static int iwl_verify_ucode(struct iwl_priv *priv, return -EINVAL; } - if (!iwl_verify_inst_sparse(priv, &img->code)) { + if (!iwl_verify_sec_sparse(priv, &img->sec[IWL_UCODE_SECTION_INST])) { IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); return 0; } IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - iwl_print_mismatch_inst(priv, &img->code); + iwl_print_mismatch_sec(priv, &img->sec[IWL_UCODE_SECTION_INST]); return -EIO; } @@ -534,7 +527,7 @@ int iwl_run_init_ucode(struct iwl_priv *priv) lockdep_assert_held(&priv->mutex); /* No init ucode required? Curious, but maybe ok */ - if (!priv->fw->ucode_init.code.len) + if (!priv->fw->img[IWL_UCODE_INIT].sec[0].len) return 0; if (priv->init_ucode_run) -- GitLab From 4db2c9aeb28762ea7416122d03a7e5c8d87eb924 Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Sat, 10 Mar 2012 13:00:15 -0800 Subject: [PATCH 1673/1846] iwlwifi: Add bool mvm_ucode to iwl_fw mvm_ucode is true when mvm TLVs arive. Signed-off-by: David Spinadel Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-drv.c | 9 ++++++++- drivers/net/wireless/iwlwifi/iwl-fw.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c index 54e09696fc9d..6f312c77af5e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/iwlwifi/iwl-drv.c @@ -636,14 +636,17 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, case IWL_UCODE_TLV_SEC_RT: iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, tlv_len); + drv->fw.mvm_fw = true; break; case IWL_UCODE_TLV_SEC_INIT: iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, tlv_len); + drv->fw.mvm_fw = true; break; case IWL_UCODE_TLV_SEC_WOWLAN: iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, tlv_len); + drv->fw.mvm_fw = true; break; case IWL_UCODE_TLV_DEF_CALIB: if (tlv_len != sizeof(struct iwl_tlv_calib_data)) @@ -870,7 +873,11 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) goto try_again; } - if (validate_sec_sizes(drv, &pieces, cfg)) + /* + * In mvm uCode there is no difference between data and instructions + * sections. + */ + if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, cfg)) goto try_again; /* Allocate ucode buffers for card's bus-master loading ... */ diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index 5d634f3db929..8e36bdc1e522 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h @@ -170,6 +170,8 @@ struct iwl_fw { u64 default_calib[IWL_UCODE_TYPE_MAX]; u32 phy_config; + + bool mvm_fw; }; #endif /* __iwl_fw_h__ */ -- GitLab From de5036aae635b7ea5a920e56fcf074a333b325ca Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Mar 2012 15:02:03 +0100 Subject: [PATCH 1674/1846] mac80211: move misplaced comment Looks like some changes in this area moved the code but not the comment that belongs to the code, move it to the right place. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 5c2ba80c2932..059a4eba9fec 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3274,6 +3274,13 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, ifmgd->beacon_crc_valid = false; + /* + * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode. + * We still associate in non-HT mode (11a/b/g) if any one of these + * ciphers is configured as pairwise. + * We can set this to true for non-11n hardware, that'll be checked + * separately along with the peer capabilities. + */ for (i = 0; i < req->crypto.n_ciphers_pairwise; i++) if (req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_WEP40 || req->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP || @@ -3302,13 +3309,6 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, } else ifmgd->ap_smps = ifmgd->req_smps; - /* - * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode. - * We still associate in non-HT mode (11a/b/g) if any one of these - * ciphers is configured as pairwise. - * We can set this to true for non-11n hardware, that'll be checked - * separately along with the peer capabilities. - */ assoc_data->capability = req->bss->capability; assoc_data->wmm_used = bss->wmm_used; assoc_data->supp_rates = bss->supp_rates; -- GitLab From 4e74bfdb30f79e9bf87aa359eff29fbdb93cc12a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Mar 2012 15:02:04 +0100 Subject: [PATCH 1675/1846] mac80211: simplify HT checks Always set/use IEEE80211_STA_DISABLE_11N instead of duplicating the queue, WMM and HT checks in all places. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 57 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 059a4eba9fec..5dfc1e8a1a22 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -192,33 +192,27 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; - prev_chantype = sdata->vif.bss_conf.channel_type; - /* HT is not supported */ - if (!sband->ht_cap.ht_supported) - enable_ht = false; - if (enable_ht) { - hti_cfreq = ieee80211_channel_to_frequency(hti->control_chan, - sband->band); - /* check that channel matches the right operating channel */ - if (local->hw.conf.channel->center_freq != hti_cfreq) { - /* Some APs mess this up, evidently. - * Netgear WNDR3700 sometimes reports 4 higher than - * the actual channel, for instance. - */ - printk(KERN_DEBUG - "%s: Wrong control channel in association" - " response: configured center-freq: %d" - " hti-cfreq: %d hti->control_chan: %d" - " band: %d. Disabling HT.\n", - sdata->name, - local->hw.conf.channel->center_freq, - hti_cfreq, hti->control_chan, - sband->band); - enable_ht = false; - } + hti_cfreq = ieee80211_channel_to_frequency(hti->control_chan, + sband->band); + /* check that channel matches the right operating channel */ + if (local->hw.conf.channel->center_freq != hti_cfreq) { + /* Some APs mess this up, evidently. + * Netgear WNDR3700 sometimes reports 4 higher than + * the actual channel, for instance. + */ + printk(KERN_DEBUG + "%s: Wrong control channel in association" + " response: configured center-freq: %d" + " hti-cfreq: %d hti->control_chan: %d" + " band: %d. Disabling HT.\n", + sdata->name, + local->hw.conf.channel->center_freq, + hti_cfreq, hti->control_chan, + sband->band); + enable_ht = false; } if (enable_ht) { @@ -335,9 +329,6 @@ static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata, BUILD_BUG_ON(sizeof(ht_cap) != sizeof(sband->ht_cap)); - if (!sband->ht_cap.ht_supported) - return; - if (!ht_info_ie) return; @@ -405,7 +396,6 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) u16 capab; struct ieee80211_supported_band *sband; u32 rates = 0; - struct ieee80211_bss *bss = (void *)assoc_data->bss->priv; lockdep_assert_held(&ifmgd->mtx); @@ -566,8 +556,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) offset = noffset; } - if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N) && - bss->wmm_used && local->hw.queues >= 4) + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) ieee80211_add_ht_ie(sdata, skb, assoc_data->ht_information_ie, sband, local->oper_channel, ifmgd->ap_smps); @@ -2147,7 +2136,6 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, changed |= BSS_CHANGED_QOS; if (elems.ht_info_elem && elems.wmm_param && - (sdata->local->hw.queues >= 4) && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, cbss->bssid, ap_ht_cap_flags, @@ -3232,6 +3220,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_bss *bss = (void *)req->bss->priv; struct ieee80211_mgd_assoc_data *assoc_data; + struct ieee80211_supported_band *sband; struct sta_info *sta; const u8 *ssidie; int i, err; @@ -3290,6 +3279,12 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, if (req->flags & ASSOC_REQ_DISABLE_HT) ifmgd->flags |= IEEE80211_STA_DISABLE_11N; + /* Also disable HT if we don't support it or the AP doesn't use WMM */ + sband = local->hw.wiphy->bands[req->bss->channel->band]; + if (!sband->ht_cap.ht_supported || + local->hw.queues < 4 || !bss->wmm_used) + ifmgd->flags |= IEEE80211_STA_DISABLE_11N; + memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa)); memcpy(&ifmgd->ht_capa_mask, &req->ht_capa_mask, sizeof(ifmgd->ht_capa_mask)); -- GitLab From 76f0303d61b3c7f1918ab63a64e77450a4418a60 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Mar 2012 15:02:05 +0100 Subject: [PATCH 1676/1846] mac80211: simplify wmm check during association Instead of setting assoc_data->wmm_used solely based on the BSS also take into account our own capabilities and later check those. Also rename "wmm_used" and "uapsd_used" to just "wmm" and "uapsd". Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/mlme.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 3c62ded64e32..173c1396070d 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -407,7 +407,7 @@ struct ieee80211_mgd_assoc_data { u8 ssid[IEEE80211_MAX_SSID_LEN]; u8 ssid_len; u8 supp_rates_len; - bool wmm_used, uapsd_used; + bool wmm, uapsd; bool have_beacon; bool sent_assoc; bool synced; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 5dfc1e8a1a22..b60768368ce5 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -570,8 +570,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) offset = noffset; } - if (assoc_data->wmm_used && local->hw.queues >= 4) { - if (assoc_data->uapsd_used) { + if (assoc_data->wmm) { + if (assoc_data->uapsd) { qos_info = local->uapsd_queues; qos_info |= (local->uapsd_max_sp_len << IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); @@ -3305,7 +3305,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, ifmgd->ap_smps = ifmgd->req_smps; assoc_data->capability = req->bss->capability; - assoc_data->wmm_used = bss->wmm_used; + assoc_data->wmm = bss->wmm_used && (local->hw.queues >= 4); assoc_data->supp_rates = bss->supp_rates; assoc_data->supp_rates_len = bss->supp_rates_len; assoc_data->ht_information_ie = @@ -3313,10 +3313,10 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, if (bss->wmm_used && bss->uapsd_supported && (sdata->local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD)) { - assoc_data->uapsd_used = true; + assoc_data->uapsd = true; ifmgd->flags |= IEEE80211_STA_UAPSD_ENABLED; } else { - assoc_data->uapsd_used = false; + assoc_data->uapsd = false; ifmgd->flags &= ~IEEE80211_STA_UAPSD_ENABLED; } -- GitLab From 0775f9f90cdaf40fbf69b3192b3dddb2b3436f45 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Mar 2012 15:02:06 +0100 Subject: [PATCH 1677/1846] mac80211: remove spurious BSSID change flag The BSSID has been set a lot earlier already and didn't change again in ieee80211_set_associated(). Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index b60768368ce5..5c82354d18c4 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1351,9 +1351,6 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, */ bss_info_changed |= BSS_CHANGED_BASIC_RATES; - /* And the BSSID changed - we're associated now */ - bss_info_changed |= BSS_CHANGED_BSSID; - /* Tell the driver to monitor connection quality (if supported) */ if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI && bss_conf->cqm_rssi_thold) -- GitLab From a1cf775deae9d0f1e5475337ab13c593ad427cee Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Mar 2012 15:02:07 +0100 Subject: [PATCH 1678/1846] mac80211: refactor common auth/assoc setup code As associating is possible without first authenticating (for FT over DS) association also has to be able to switch to the right channel, insert the station entry etc. Factor out this common code into a new function called ieee80211_prep_connection(). Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 121 +++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 5c82354d18c4..81e0124e68ce 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3089,6 +3089,60 @@ int ieee80211_max_network_latency(struct notifier_block *nb, return 0; } +static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, + struct cfg80211_bss *bss, bool assoc) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct sta_info *sta; + bool have_sta = false; + int err; + + if (WARN_ON(!ifmgd->auth_data && !ifmgd->assoc_data)) + return -EINVAL; + + if (assoc) { + rcu_read_lock(); + have_sta = sta_info_get(sdata, bss->bssid); + rcu_read_unlock(); + } + + if (!have_sta) { + sta = sta_info_alloc(sdata, bss->bssid, GFP_KERNEL); + if (!sta) + return -ENOMEM; + } + + mutex_lock(&local->mtx); + ieee80211_recalc_idle(sdata->local); + mutex_unlock(&local->mtx); + + /* switch to the right channel */ + local->oper_channel = bss->channel; + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); + + if (!have_sta) { + /* set BSSID - if STA already there this will be set too */ + memcpy(ifmgd->bssid, bss->bssid, ETH_ALEN); + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); + + if (assoc) + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); + + err = sta_info_insert(sta); + sta = NULL; + if (err) { + printk(KERN_DEBUG + "%s: failed to insert STA entry for the AP (error %d)\n", + sdata->name, err); + return err; + } + } else + WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, bss->bssid)); + + return 0; +} + /* config hooks */ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, struct cfg80211_auth_request *req) @@ -3096,7 +3150,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_mgd_auth_data *auth_data; - struct sta_info *sta; u16 auth_alg; int err; @@ -3162,32 +3215,9 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, printk(KERN_DEBUG "%s: authenticate with %pM\n", sdata->name, req->bss->bssid); - mutex_lock(&local->mtx); - ieee80211_recalc_idle(sdata->local); - mutex_unlock(&local->mtx); - - /* switch to the right channel */ - local->oper_channel = req->bss->channel; - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); - - /* set BSSID */ - memcpy(ifmgd->bssid, req->bss->bssid, ETH_ALEN); - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); - - /* add station entry */ - sta = sta_info_alloc(sdata, req->bss->bssid, GFP_KERNEL); - if (!sta) { - err = -ENOMEM; - goto err_clear; - } - - err = sta_info_insert(sta); - if (err) { - printk(KERN_DEBUG - "%s: failed to insert STA entry for the AP %pM (error %d)\n", - sdata->name, req->bss->bssid, err); + err = ieee80211_prep_connection(sdata, req->bss, false); + if (err) goto err_clear; - } err = ieee80211_probe_auth(sdata); if (err) { @@ -3218,7 +3248,6 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, struct ieee80211_bss *bss = (void *)req->bss->priv; struct ieee80211_mgd_assoc_data *assoc_data; struct ieee80211_supported_band *sband; - struct sta_info *sta; const u8 *ssidie; int i, err; @@ -3343,41 +3372,9 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, ifmgd->assoc_data = assoc_data; - mutex_lock(&local->mtx); - ieee80211_recalc_idle(sdata->local); - mutex_unlock(&local->mtx); - - /* switch to the right channel */ - local->oper_channel = req->bss->channel; - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); - - rcu_read_lock(); - sta = sta_info_get(sdata, req->bss->bssid); - rcu_read_unlock(); - - if (!sta) { - /* set BSSID */ - memcpy(ifmgd->bssid, req->bss->bssid, ETH_ALEN); - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); - - sta = sta_info_alloc(sdata, req->bss->bssid, GFP_KERNEL); - if (!sta) { - err = -ENOMEM; - goto err_clear; - } - - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); - - err = sta_info_insert(sta); - sta = NULL; - if (err) { - printk(KERN_DEBUG - "%s: failed to insert STA entry for the AP (error %d)\n", - sdata->name, err); - goto err_clear; - } - } else - WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, req->bss->bssid)); + err = ieee80211_prep_connection(sdata, req->bss, true); + if (err) + goto err_clear; if (!bss->dtim_period && sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) { -- GitLab From 5d6a1b069b7f72298aff2306a2d02b0188668218 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Mar 2012 15:02:08 +0100 Subject: [PATCH 1679/1846] mac80211: set basic rates earlier The authentication and association handshake already happens in the context of the new BSS, and the basic rates are needed at least for the ACK response frame to the authentication or association response frames. Therefore the basic rates should already be configured into the driver when those frames are sent. Change the logic to set up the basic rates in the connection preparation that happens for authentication and association (if needed). Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/mlme.c | 97 +++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 81e0124e68ce..39c13939008b 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1344,12 +1344,6 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, bss_conf->dtim_period = 0; bss_conf->assoc = 1; - /* - * For now just always ask the driver to update the basic rateset - * when we have associated, we aren't checking whether it actually - * changed or not. - */ - bss_info_changed |= BSS_CHANGED_BASIC_RATES; /* Tell the driver to monitor connection quality (if supported) */ if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI && @@ -2001,15 +1995,12 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, struct ieee80211_supported_band *sband; struct sta_info *sta; u8 *pos; - u32 rates, basic_rates; u16 capab_info, aid; struct ieee802_11_elems elems; struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; u32 changed = 0; int err; - bool have_higher_than_11mbit = false; u16 ap_ht_cap_flags; - int min_rate = INT_MAX, min_rate_index = -1; /* AssocResp and ReassocResp have identical structure */ @@ -2054,39 +2045,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, return false; } - rates = 0; - basic_rates = 0; sband = local->hw.wiphy->bands[local->oper_channel->band]; - ieee80211_get_rates(sband, elems.supp_rates, elems.supp_rates_len, - &rates, &basic_rates, &have_higher_than_11mbit, - &min_rate, &min_rate_index); - - ieee80211_get_rates(sband, elems.ext_supp_rates, - elems.ext_supp_rates_len, &rates, &basic_rates, - &have_higher_than_11mbit, - &min_rate, &min_rate_index); - - /* - * some buggy APs don't advertise basic_rates. use the lowest - * supported rate instead. - */ - if (unlikely(!basic_rates) && min_rate_index >= 0) { - printk(KERN_DEBUG "%s: No basic rates in AssocResp. " - "Using min supported rate instead.\n", sdata->name); - basic_rates = BIT(min_rate_index); - } - - sta->sta.supp_rates[local->oper_channel->band] = rates; - sdata->vif.bss_conf.basic_rates = basic_rates; - - /* cf. IEEE 802.11 9.2.12 */ - if (local->oper_channel->band == IEEE80211_BAND_2GHZ && - have_higher_than_11mbit) - sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; - else - sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; - if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, elems.ht_cap_elem, &sta->sta.ht_cap); @@ -3090,10 +3050,11 @@ int ieee80211_max_network_latency(struct notifier_block *nb, } static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, - struct cfg80211_bss *bss, bool assoc) + struct cfg80211_bss *cbss, bool assoc) { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_bss *bss = (void *)cbss->priv; struct sta_info *sta; bool have_sta = false; int err; @@ -3103,12 +3064,12 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, if (assoc) { rcu_read_lock(); - have_sta = sta_info_get(sdata, bss->bssid); + have_sta = sta_info_get(sdata, cbss->bssid); rcu_read_unlock(); } if (!have_sta) { - sta = sta_info_alloc(sdata, bss->bssid, GFP_KERNEL); + sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL); if (!sta) return -ENOMEM; } @@ -3118,13 +3079,53 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, mutex_unlock(&local->mtx); /* switch to the right channel */ - local->oper_channel = bss->channel; + local->oper_channel = cbss->channel; ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); if (!have_sta) { - /* set BSSID - if STA already there this will be set too */ - memcpy(ifmgd->bssid, bss->bssid, ETH_ALEN); - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); + struct ieee80211_supported_band *sband; + u32 rates = 0, basic_rates = 0; + bool have_higher_than_11mbit; + int min_rate = INT_MAX, min_rate_index = -1; + + sband = sdata->local->hw.wiphy->bands[cbss->channel->band]; + + ieee80211_get_rates(sband, bss->supp_rates, + bss->supp_rates_len, + &rates, &basic_rates, + &have_higher_than_11mbit, + &min_rate, &min_rate_index); + + /* + * This used to be a workaround for basic rates missing + * in the association response frame. Now that we no + * longer use the basic rates from there, it probably + * doesn't happen any more, but keep the workaround so + * in case some *other* APs are buggy in different ways + * we can connect -- with a warning. + */ + if (!basic_rates && min_rate_index >= 0) { + printk(KERN_DEBUG + "%s: No basic rates, using min rate instead.\n", + sdata->name); + basic_rates = BIT(min_rate_index); + } + + sta->sta.supp_rates[cbss->channel->band] = rates; + sdata->vif.bss_conf.basic_rates = basic_rates; + + /* cf. IEEE 802.11 9.2.12 */ + if (local->oper_channel->band == IEEE80211_BAND_2GHZ && + have_higher_than_11mbit) + sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; + else + sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; + + memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN); + + /* tell driver about BSSID and basic rates */ + ieee80211_bss_info_change_notify(sdata, + BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES); if (assoc) sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); @@ -3138,7 +3139,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, return err; } } else - WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, bss->bssid)); + WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, cbss->bssid)); return 0; } -- GitLab From afd465030acb4098abcb6b965a5aebc7ea2209e0 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 12 Mar 2012 07:03:32 +0000 Subject: [PATCH 1680/1846] net: ipv4: Standardize prefixes for message logging Add #define pr_fmt(fmt) as appropriate. Add "IPv4: ", "TCP: ", and "IPsec: " to appropriate files. Standardize on "UDPLite: " for appropriate uses. Some prefixes were previously "UDPLITE: " and "UDP-Lite: ". Add KBUILD_MODNAME ": " to icmp and gre. Remove embedded prefixes as appropriate. Add missing "\n" to pr_info in gre.c. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- include/net/udplite.h | 4 ++-- net/ipv4/af_inet.c | 2 ++ net/ipv4/ah4.c | 9 ++++++--- net/ipv4/esp4.c | 2 ++ net/ipv4/gre.c | 6 ++++-- net/ipv4/icmp.c | 6 ++++-- net/ipv4/ip_fragment.c | 8 +++++--- net/ipv4/ip_gre.c | 2 ++ net/ipv4/ip_input.c | 2 ++ net/ipv4/ip_options.c | 2 ++ net/ipv4/route.c | 4 +++- net/ipv4/tcp.c | 11 +++++++---- net/ipv4/tcp_cong.c | 8 +++++--- net/ipv4/tcp_input.c | 2 ++ net/ipv4/tcp_ipv4.c | 6 +++--- net/ipv4/tcp_probe.c | 4 +++- net/ipv4/tcp_timer.c | 14 ++++++++------ net/ipv4/udp.c | 34 ++++++++++++++-------------------- net/ipv4/udplite.c | 3 +++ net/ipv4/xfrm4_tunnel.c | 2 ++ 20 files changed, 81 insertions(+), 50 deletions(-) diff --git a/include/net/udplite.h b/include/net/udplite.h index 5f097ca7d5c5..71375459a884 100644 --- a/include/net/udplite.h +++ b/include/net/udplite.h @@ -40,7 +40,7 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh) * checksum. UDP-Lite (like IPv6) mandates checksums, hence packets * with a zero checksum field are illegal. */ if (uh->check == 0) { - LIMIT_NETDEBUG(KERN_DEBUG "UDPLITE: zeroed checksum field\n"); + LIMIT_NETDEBUG(KERN_DEBUG "UDPLite: zeroed checksum field\n"); return 1; } @@ -52,7 +52,7 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh) /* * Coverage length violates RFC 3828: log and discard silently. */ - LIMIT_NETDEBUG(KERN_DEBUG "UDPLITE: bad csum coverage %d/%d\n", + LIMIT_NETDEBUG(KERN_DEBUG "UDPLite: bad csum coverage %d/%d\n", cscov, skb->len); return 1; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index b7a946611f2f..fdf49fd44bb4 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -65,6 +65,8 @@ * 2 of the License, or (at your option) any later version. */ +#define pr_fmt(fmt) "IPv4: " fmt + #include #include #include diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index b5524660c81d..fd508b526014 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -1,3 +1,5 @@ +#define pr_fmt(fmt) "IPsec: " fmt + #include #include #include @@ -445,9 +447,10 @@ static int ah_init_state(struct xfrm_state *x) if (aalg_desc->uinfo.auth.icv_fullbits/8 != crypto_ahash_digestsize(ahash)) { - pr_info("AH: %s digestsize %u != %hu\n", - x->aalg->alg_name, crypto_ahash_digestsize(ahash), - aalg_desc->uinfo.auth.icv_fullbits/8); + pr_info("%s: %s digestsize %u != %hu\n", + __func__, x->aalg->alg_name, + crypto_ahash_digestsize(ahash), + aalg_desc->uinfo.auth.icv_fullbits / 8); goto error; } diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 0a86dbe9454b..89a47b35905d 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -1,3 +1,5 @@ +#define pr_fmt(fmt) "IPsec: " fmt + #include #include #include diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c index 8cb1ebb7cd74..42a491055c76 100644 --- a/net/ipv4/gre.c +++ b/net/ipv4/gre.c @@ -10,6 +10,8 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -118,10 +120,10 @@ static const struct net_protocol net_gre_protocol = { static int __init gre_init(void) { - pr_info("GRE over IPv4 demultiplexor driver"); + pr_info("GRE over IPv4 demultiplexor driver\n"); if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) { - pr_err("gre: can't add protocol\n"); + pr_err("can't add protocol\n"); return -EAGAIN; } diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 5c7323b7810f..9664d353ccd8 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -62,6 +62,8 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -670,7 +672,7 @@ static void icmp_unreach(struct sk_buff *skb) break; case ICMP_FRAG_NEEDED: if (ipv4_config.no_pmtu_disc) { - LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: fragmentation needed and DF set\n", + LIMIT_NETDEBUG(KERN_INFO pr_fmt("%pI4: fragmentation needed and DF set\n"), &iph->daddr); } else { info = ip_rt_frag_needed(net, iph, @@ -681,7 +683,7 @@ static void icmp_unreach(struct sk_buff *skb) } break; case ICMP_SR_FAILED: - LIMIT_NETDEBUG(KERN_INFO "ICMP: %pI4: Source Route Failed\n", + LIMIT_NETDEBUG(KERN_INFO pr_fmt("%pI4: Source Route Failed\n"), &iph->daddr); break; default: diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index b2fd333abd59..3727e234c884 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -20,6 +20,8 @@ * Patrick McHardy : LRU queue of frag heads for evictor. */ +#define pr_fmt(fmt) "IPv4: " fmt + #include #include #include @@ -299,7 +301,7 @@ static inline struct ipq *ip_find(struct net *net, struct iphdr *iph, u32 user) return container_of(q, struct ipq, q); out_nomem: - LIMIT_NETDEBUG(KERN_ERR "ip_frag_create: no memory left !\n"); + LIMIT_NETDEBUG(KERN_ERR pr_fmt("ip_frag_create: no memory left !\n")); return NULL; } @@ -637,8 +639,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, return 0; out_nomem: - LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing " - "queue %p\n", qp); + LIMIT_NETDEBUG(KERN_ERR pr_fmt("queue_glue: no memory for gluing queue %p\n"), + qp); err = -ENOMEM; goto out_fail; out_oversize: diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 185e0a75ecec..b57532d4742c 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -10,6 +10,8 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index de8e9be4aac8..f3f1108940f5 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -113,6 +113,8 @@ * 2 of the License, or (at your option) any later version. */ +#define pr_fmt(fmt) "IPv4: " fmt + #include #include #include diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index e25ee7c8bdde..a0d0d9d9b870 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -9,6 +9,8 @@ * */ +#define pr_fmt(fmt) "IPv4: " fmt + #include #include #include diff --git a/net/ipv4/route.c b/net/ipv4/route.c index cbda6de0a77c..12ccf880eb88 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -62,6 +62,8 @@ * 2 of the License, or (at your option) any later version. */ +#define pr_fmt(fmt) "IPv4: " fmt + #include #include #include @@ -1298,7 +1300,7 @@ static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, } if (net_ratelimit()) - pr_warn("ipv4: Neighbour table overflow\n"); + pr_warn("Neighbour table overflow\n"); rt_drop(rt); return ERR_PTR(-ENOBUFS); } diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 2baba1bed810..cfd7edda0a8e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -245,6 +245,8 @@ * TCP_CLOSE socket is finished */ +#define pr_fmt(fmt) "TCP: " fmt + #include #include #include @@ -1675,7 +1677,8 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, if (tp->ucopy.dma_cookie < 0) { - pr_alert("dma_cookie < 0\n"); + pr_alert("%s: dma_cookie < 0\n", + __func__); /* Exception. Bailout! */ if (!copied) @@ -1884,9 +1887,9 @@ bool tcp_check_oom(struct sock *sk, int shift) out_of_socket_memory = tcp_out_of_memory(sk); if (too_many_orphans && net_ratelimit()) - pr_info("TCP: too many orphaned sockets\n"); + pr_info("too many orphaned sockets\n"); if (out_of_socket_memory && net_ratelimit()) - pr_info("TCP: out of memory -- consider tuning tcp_mem\n"); + pr_info("out of memory -- consider tuning tcp_mem\n"); return too_many_orphans || out_of_socket_memory; } @@ -3311,7 +3314,7 @@ void __init tcp_init(void) sysctl_tcp_rmem[1] = 87380; sysctl_tcp_rmem[2] = max(87380, max_share); - pr_info("TCP: Hash tables configured (established %u bind %u)\n", + pr_info("Hash tables configured (established %u bind %u)\n", tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size); tcp_register_congestion_control(&tcp_reno); diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index 67bab75f441f..272a84593c85 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -6,6 +6,8 @@ * Copyright (C) 2005 Stephen Hemminger */ +#define pr_fmt(fmt) "TCP: " fmt + #include #include #include @@ -41,17 +43,17 @@ int tcp_register_congestion_control(struct tcp_congestion_ops *ca) /* all algorithms must implement ssthresh and cong_avoid ops */ if (!ca->ssthresh || !ca->cong_avoid) { - pr_err("TCP %s does not implement required ops\n", ca->name); + pr_err("%s does not implement required ops\n", ca->name); return -EINVAL; } spin_lock(&tcp_cong_list_lock); if (tcp_ca_find(ca->name)) { - pr_notice("TCP %s already registered\n", ca->name); + pr_notice("%s already registered\n", ca->name); ret = -EEXIST; } else { list_add_tail_rcu(&ca->list, &tcp_cong_list); - pr_info("TCP %s registered\n", ca->name); + pr_info("%s registered\n", ca->name); } spin_unlock(&tcp_cong_list_lock); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 23ca3663d1e8..68d4057cba00 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -61,6 +61,8 @@ * Pasi Sarolahti: F-RTO for dealing with spurious RTOs */ +#define pr_fmt(fmt) "TCP: " fmt + #include #include #include diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 257dba66eaca..fe9f604ed1e2 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -50,6 +50,7 @@ * a single port at the same time. */ +#define pr_fmt(fmt) "TCP: " fmt #include #include @@ -876,8 +877,7 @@ int tcp_syn_flood_action(struct sock *sk, lopt = inet_csk(sk)->icsk_accept_queue.listen_opt; if (!lopt->synflood_warned) { lopt->synflood_warned = 1; - pr_info("%s: Possible SYN flooding on port %d. %s. " - " Check SNMP counters.\n", + pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n", proto, ntohs(tcp_hdr(skb)->dest), msg); } return want_cookie; @@ -1399,7 +1399,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) * to destinations, already remembered * to the moment of synflood. */ - LIMIT_NETDEBUG(KERN_DEBUG "TCP: drop open request from %pI4/%u\n", + LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("drop open request from %pI4/%u\n"), &saddr, ntohs(tcp_hdr(skb)->source)); goto drop_and_release; } diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c index 85ee7eb7e38e..a981cdc0a6e9 100644 --- a/net/ipv4/tcp_probe.c +++ b/net/ipv4/tcp_probe.c @@ -18,6 +18,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -239,7 +241,7 @@ static __init int tcpprobe_init(void) if (ret) goto err1; - pr_info("TCP probe registered (port=%d) bufsize=%u\n", port, bufsize); + pr_info("probe registered (port=%d) bufsize=%u\n", port, bufsize); return 0; err1: proc_net_remove(&init_net, procname); diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index cd2e0723266d..34d4a02c2f16 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -333,16 +333,18 @@ void tcp_retransmit_timer(struct sock *sk) */ struct inet_sock *inet = inet_sk(sk); if (sk->sk_family == AF_INET) { - LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", - &inet->inet_daddr, ntohs(inet->inet_dport), - inet->inet_num, tp->snd_una, tp->snd_nxt); + LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n"), + &inet->inet_daddr, + ntohs(inet->inet_dport), inet->inet_num, + tp->snd_una, tp->snd_nxt); } #if IS_ENABLED(CONFIG_IPV6) else if (sk->sk_family == AF_INET6) { struct ipv6_pinfo *np = inet6_sk(sk); - LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", - &np->daddr, ntohs(inet->inet_dport), - inet->inet_num, tp->snd_una, tp->snd_nxt); + LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n"), + &np->daddr, + ntohs(inet->inet_dport), inet->inet_num, + tp->snd_una, tp->snd_nxt); } #endif if (tcp_time_stamp - tp->rcv_tstamp > TCP_RTO_MAX) { diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 7c41ab84e72e..d6f5feeb3eaf 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -77,6 +77,8 @@ * 2 of the License, or (at your option) any later version. */ +#define pr_fmt(fmt) "UDP: " fmt + #include #include #include @@ -975,7 +977,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, /* ... which is an evident application bug. --ANK */ release_sock(sk); - LIMIT_NETDEBUG(KERN_DEBUG "udp cork app bug 2\n"); + LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("cork app bug 2\n")); err = -EINVAL; goto out; } @@ -1054,7 +1056,7 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset, if (unlikely(!up->pending)) { release_sock(sk); - LIMIT_NETDEBUG(KERN_DEBUG "udp cork app bug 3\n"); + LIMIT_NETDEBUG(KERN_DEBUG pr_fmt("udp cork app bug 3\n")); return -EINVAL; } @@ -1447,9 +1449,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) * provided by the application." */ if (up->pcrlen == 0) { /* full coverage was set */ - LIMIT_NETDEBUG(KERN_WARNING "UDPLITE: partial coverage " - "%d while full coverage %d requested\n", - UDP_SKB_CB(skb)->cscov, skb->len); + LIMIT_NETDEBUG(KERN_WARNING "UDPLite: partial coverage %d while full coverage %d requested\n", + UDP_SKB_CB(skb)->cscov, skb->len); goto drop; } /* The next case involves violating the min. coverage requested @@ -1459,9 +1460,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) * Therefore the above ...()->partial_cov statement is essential. */ if (UDP_SKB_CB(skb)->cscov < up->pcrlen) { - LIMIT_NETDEBUG(KERN_WARNING - "UDPLITE: coverage %d too small, need min %d\n", - UDP_SKB_CB(skb)->cscov, up->pcrlen); + LIMIT_NETDEBUG(KERN_WARNING "UDPLite: coverage %d too small, need min %d\n", + UDP_SKB_CB(skb)->cscov, up->pcrlen); goto drop; } } @@ -1689,13 +1689,10 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, short_packet: LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %pI4:%u %d/%d to %pI4:%u\n", - proto == IPPROTO_UDPLITE ? "-Lite" : "", - &saddr, - ntohs(uh->source), - ulen, - skb->len, - &daddr, - ntohs(uh->dest)); + proto == IPPROTO_UDPLITE ? "Lite" : "", + &saddr, ntohs(uh->source), + ulen, skb->len, + &daddr, ntohs(uh->dest)); goto drop; csum_error: @@ -1704,11 +1701,8 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, * the network is concerned, anyway) as per 4.1.3.4 (MUST). */ LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n", - proto == IPPROTO_UDPLITE ? "-Lite" : "", - &saddr, - ntohs(uh->source), - &daddr, - ntohs(uh->dest), + proto == IPPROTO_UDPLITE ? "Lite" : "", + &saddr, ntohs(uh->source), &daddr, ntohs(uh->dest), ulen); drop: UDP_INC_STATS_BH(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE); diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 280bfb12adcc..2c46acd4cc36 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -10,6 +10,9 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ + +#define pr_fmt(fmt) "UDPLite: " fmt + #include #include "udp_impl.h" diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c index 5b48f49df0ba..05a5df2febc9 100644 --- a/net/ipv4/xfrm4_tunnel.c +++ b/net/ipv4/xfrm4_tunnel.c @@ -3,6 +3,8 @@ * Copyright (C) 2003 David S. Miller (davem@redhat.com) */ +#define pr_fmt(fmt) "IPsec: " fmt + #include #include #include -- GitLab From ef31bef6216db76950c38f1993b45953402f4c63 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Mon, 12 Mar 2012 10:20:49 +0000 Subject: [PATCH 1681/1846] net/hyperv: Fix data corruption in rndis_filter_receive() Limiting the memcpy to be the sizeof(struct rndis_message) can truncate the message if there are Per-Packet-Info or Out-of-Band data. In my earlier patch (commit 45326342), the unnecessary kmap_atomic and kunmap_atomic surrounding this memcpy have been removed because the memory in the receive buffer is always mapped. This memcpy is not necessary either. To fix the bug, I removed the memcpy. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan Signed-off-by: David S. Miller --- drivers/net/hyperv/rndis_filter.c | 33 +++++++++---------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 136efd84373f..0c3d7d9f51d3 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -352,8 +352,7 @@ int rndis_filter_receive(struct hv_device *dev, { struct netvsc_device *net_dev = hv_get_drvdata(dev); struct rndis_device *rndis_dev; - struct rndis_message rndis_msg; - struct rndis_message *rndis_hdr; + struct rndis_message *rndis_msg; struct net_device *ndev; if (!net_dev) @@ -375,46 +374,32 @@ int rndis_filter_receive(struct hv_device *dev, return -ENODEV; } - rndis_hdr = pkt->data; - - /* Make sure we got a valid rndis message */ - if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) && - (rndis_hdr->msg_len > sizeof(struct rndis_message))) { - netdev_err(ndev, "incoming rndis message buffer overflow " - "detected (got %u, max %zu)..marking it an error!\n", - rndis_hdr->msg_len, - sizeof(struct rndis_message)); - } + rndis_msg = pkt->data; - memcpy(&rndis_msg, rndis_hdr, - (rndis_hdr->msg_len > sizeof(struct rndis_message)) ? - sizeof(struct rndis_message) : - rndis_hdr->msg_len); + dump_rndis_message(dev, rndis_msg); - dump_rndis_message(dev, &rndis_msg); - - switch (rndis_msg.ndis_msg_type) { + switch (rndis_msg->ndis_msg_type) { case REMOTE_NDIS_PACKET_MSG: /* data msg */ - rndis_filter_receive_data(rndis_dev, &rndis_msg, pkt); + rndis_filter_receive_data(rndis_dev, rndis_msg, pkt); break; case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: /* completion msgs */ - rndis_filter_receive_response(rndis_dev, &rndis_msg); + rndis_filter_receive_response(rndis_dev, rndis_msg); break; case REMOTE_NDIS_INDICATE_STATUS_MSG: /* notification msgs */ - rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg); + rndis_filter_receive_indicate_status(rndis_dev, rndis_msg); break; default: netdev_err(ndev, "unhandled rndis message (type %u len %u)\n", - rndis_msg.ndis_msg_type, - rndis_msg.msg_len); + rndis_msg->ndis_msg_type, + rndis_msg->msg_len); break; } -- GitLab From 1f5f3a75e216fe771b8d6805e0bb2f43595a6ee1 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Mon, 12 Mar 2012 10:20:50 +0000 Subject: [PATCH 1682/1846] net/hyperv: Add support for vlan trunking from guests With this feature, a Linux guest can now configure multiple vlans through a single synthetic NIC on Win8 Hyper-V host. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan Signed-off-by: David S. Miller --- drivers/net/hyperv/hyperv_net.h | 34 +++++++++++++++++- drivers/net/hyperv/netvsc.c | 3 +- drivers/net/hyperv/netvsc_drv.c | 8 +++-- drivers/net/hyperv/rndis_filter.c | 60 +++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 4 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index dec5836ae075..c35824552792 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -49,6 +49,7 @@ struct hv_netvsc_packet { struct hv_device *device; bool is_data_pkt; + u16 vlan_tci; /* * Valid only for receives when we break a xfer page packet @@ -926,9 +927,40 @@ struct rndis_oobd { struct rndis_per_packet_info { u32 size; u32 type; - u32 per_pkt_info_offset; + u32 ppi_offset; +}; + +enum ndis_per_pkt_info_type { + TCPIP_CHKSUM_PKTINFO, + IPSEC_PKTINFO, + TCP_LARGESEND_PKTINFO, + CLASSIFICATION_HANDLE_PKTINFO, + NDIS_RESERVED, + SG_LIST_PKTINFO, + IEEE_8021Q_INFO, + ORIGINAL_PKTINFO, + PACKET_CANCEL_ID, + ORIGINAL_NET_BUFLIST, + CACHED_NET_BUFLIST, + SHORT_PKT_PADINFO, + MAX_PER_PKT_INFO +}; + +struct ndis_pkt_8021q_info { + union { + struct { + u32 pri:3; /* User Priority */ + u32 cfi:1; /* Canonical Format ID */ + u32 vlanid:12; /* VLAN ID */ + u32 reserved:16; + }; + u32 value; + }; }; +#define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \ + sizeof(struct ndis_pkt_8021q_info)) + /* Format of Information buffer passed in a SetRequest for the OID */ /* OID_GEN_RNDIS_CONFIG_PARAMETER. */ struct rndis_config_parameter_info { diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 8965b45ce5a5..d025c83cd12a 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -300,6 +300,7 @@ static int negotiate_nvsp_ver(struct hv_device *device, memset(init_packet, 0, sizeof(struct nvsp_message)); init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG; init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu; + init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1; ret = vmbus_sendpacket(device->channel, init_packet, sizeof(struct nvsp_message), @@ -341,7 +342,7 @@ static int netvsc_connect_vsp(struct hv_device *device) /* Send the ndis version */ memset(init_packet, 0, sizeof(struct nvsp_message)); - ndis_version = 0x00050000; + ndis_version = 0x00050001; init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_NDIS_VER; init_packet->msg.v1_msg. diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 217dfedbba20..0f8e8344891b 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -159,7 +159,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) /* Allocate a netvsc packet based on # of frags. */ packet = kzalloc(sizeof(struct hv_netvsc_packet) + (num_pages * sizeof(struct hv_page_buffer)) + - sizeof(struct rndis_filter_packet), GFP_ATOMIC); + sizeof(struct rndis_filter_packet) + + NDIS_VLAN_PPI_SIZE, GFP_ATOMIC); if (!packet) { /* out of memory, drop packet */ netdev_err(net, "unable to allocate hv_netvsc_packet\n"); @@ -169,6 +170,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) return NETDEV_TX_BUSY; } + packet->vlan_tci = skb->vlan_tci; + packet->extension = (void *)(unsigned long)packet + sizeof(struct hv_netvsc_packet) + (num_pages * sizeof(struct hv_page_buffer)); @@ -293,6 +296,7 @@ int netvsc_recv_callback(struct hv_device *device_obj, skb->protocol = eth_type_trans(skb, net); skb->ip_summed = CHECKSUM_NONE; + skb->vlan_tci = packet->vlan_tci; net->stats.rx_packets++; net->stats.rx_bytes += packet->total_data_buflen; @@ -407,7 +411,7 @@ static int netvsc_probe(struct hv_device *dev, /* TODO: Add GSO and Checksum offload */ net->hw_features = NETIF_F_SG; - net->features = NETIF_F_SG; + net->features = NETIF_F_SG | NETIF_F_HW_VLAN_TX; SET_ETHTOOL_OPS(net, ðtool_ops); SET_NETDEV_DEV(net, &dev->device); diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 0c3d7d9f51d3..d6be64bcefd4 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "hyperv_net.h" @@ -303,12 +304,39 @@ static void rndis_filter_receive_indicate_status(struct rndis_device *dev, } } +/* + * Get the Per-Packet-Info with the specified type + * return NULL if not found. + */ +static inline void *rndis_get_ppi(struct rndis_packet *rpkt, u32 type) +{ + struct rndis_per_packet_info *ppi; + int len; + + if (rpkt->per_pkt_info_offset == 0) + return NULL; + + ppi = (struct rndis_per_packet_info *)((ulong)rpkt + + rpkt->per_pkt_info_offset); + len = rpkt->per_pkt_info_len; + + while (len > 0) { + if (ppi->type == type) + return (void *)((ulong)ppi + ppi->ppi_offset); + len -= ppi->size; + ppi = (struct rndis_per_packet_info *)((ulong)ppi + ppi->size); + } + + return NULL; +} + static void rndis_filter_receive_data(struct rndis_device *dev, struct rndis_message *msg, struct hv_netvsc_packet *pkt) { struct rndis_packet *rndis_pkt; u32 data_offset; + struct ndis_pkt_8021q_info *vlan; rndis_pkt = &msg->msg.pkt; @@ -344,6 +372,14 @@ static void rndis_filter_receive_data(struct rndis_device *dev, pkt->is_data_pkt = true; + vlan = rndis_get_ppi(rndis_pkt, IEEE_8021Q_INFO); + if (vlan) { + pkt->vlan_tci = VLAN_TAG_PRESENT | vlan->vlanid | + (vlan->pri << VLAN_PRIO_SHIFT); + } else { + pkt->vlan_tci = 0; + } + netvsc_recv_callback(dev->net_dev->dev, pkt); } @@ -759,12 +795,15 @@ int rndis_filter_send(struct hv_device *dev, struct rndis_message *rndis_msg; struct rndis_packet *rndis_pkt; u32 rndis_msg_size; + bool isvlan = pkt->vlan_tci & VLAN_TAG_PRESENT; /* Add the rndis header */ filter_pkt = (struct rndis_filter_packet *)pkt->extension; rndis_msg = &filter_pkt->msg; rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet); + if (isvlan) + rndis_msg_size += NDIS_VLAN_PPI_SIZE; rndis_msg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; rndis_msg->msg_len = pkt->total_data_buflen + @@ -772,8 +811,29 @@ int rndis_filter_send(struct hv_device *dev, rndis_pkt = &rndis_msg->msg.pkt; rndis_pkt->data_offset = sizeof(struct rndis_packet); + if (isvlan) + rndis_pkt->data_offset += NDIS_VLAN_PPI_SIZE; rndis_pkt->data_len = pkt->total_data_buflen; + if (isvlan) { + struct rndis_per_packet_info *ppi; + struct ndis_pkt_8021q_info *vlan; + + rndis_pkt->per_pkt_info_offset = sizeof(struct rndis_packet); + rndis_pkt->per_pkt_info_len = NDIS_VLAN_PPI_SIZE; + + ppi = (struct rndis_per_packet_info *)((ulong)rndis_pkt + + rndis_pkt->per_pkt_info_offset); + ppi->size = NDIS_VLAN_PPI_SIZE; + ppi->type = IEEE_8021Q_INFO; + ppi->ppi_offset = sizeof(struct rndis_per_packet_info); + + vlan = (struct ndis_pkt_8021q_info *)((ulong)ppi + + ppi->ppi_offset); + vlan->vlanid = pkt->vlan_tci & VLAN_VID_MASK; + vlan->pri = (pkt->vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; + } + pkt->is_data_pkt = true; pkt->page_buf[0].pfn = virt_to_phys(rndis_msg) >> PAGE_SHIFT; pkt->page_buf[0].offset = -- GitLab From b7370112f5195ae2e2e52b5ef46961422fa4daf0 Mon Sep 17 00:00:00 2001 From: "stigge@antcom.de" Date: Thu, 8 Mar 2012 11:49:17 +0000 Subject: [PATCH 1683/1846] lpc32xx: Added ethernet driver This patch adds an ethernet driver for the LPC32xx ARM SoC. Signed-off-by: Roland Stigge Signed-off-by: David S. Miller --- drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/nxp/Kconfig | 8 + drivers/net/ethernet/nxp/Makefile | 1 + drivers/net/ethernet/nxp/lpc_eth.c | 1604 ++++++++++++++++++++++++++++ 5 files changed, 1615 insertions(+) create mode 100644 drivers/net/ethernet/nxp/Kconfig create mode 100644 drivers/net/ethernet/nxp/Makefile create mode 100644 drivers/net/ethernet/nxp/lpc_eth.c diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index 3474a61d4705..c63a64cb6085 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -126,6 +126,7 @@ config NET_NETX source "drivers/net/ethernet/nuvoton/Kconfig" source "drivers/net/ethernet/nvidia/Kconfig" +source "drivers/net/ethernet/nxp/Kconfig" source "drivers/net/ethernet/octeon/Kconfig" source "drivers/net/ethernet/oki-semi/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 08d5f0388877..9676a5109d94 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/ obj-$(CONFIG_NET_NETX) += netx-eth.o obj-$(CONFIG_NET_VENDOR_NUVOTON) += nuvoton/ obj-$(CONFIG_NET_VENDOR_NVIDIA) += nvidia/ +obj-$(CONFIG_LPC_ENET) += nxp/ obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/ obj-$(CONFIG_NET_VENDOR_OKI) += oki-semi/ obj-$(CONFIG_ETHOC) += ethoc.o diff --git a/drivers/net/ethernet/nxp/Kconfig b/drivers/net/ethernet/nxp/Kconfig new file mode 100644 index 000000000000..0d9baf98a3b9 --- /dev/null +++ b/drivers/net/ethernet/nxp/Kconfig @@ -0,0 +1,8 @@ +config LPC_ENET + tristate "NXP ethernet MAC on LPC devices" + depends on ARCH_LPC32XX + select PHYLIB + help + Say Y or M here if you want to use the NXP ethernet MAC included on + some NXP LPC devices. You can safely enable this option for LPC32xx + SoC. Also available as a module. diff --git a/drivers/net/ethernet/nxp/Makefile b/drivers/net/ethernet/nxp/Makefile new file mode 100644 index 000000000000..a128114e6895 --- /dev/null +++ b/drivers/net/ethernet/nxp/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_LPC_ENET) += lpc_eth.o diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c new file mode 100644 index 000000000000..69444247c20b --- /dev/null +++ b/drivers/net/ethernet/nxp/lpc_eth.c @@ -0,0 +1,1604 @@ +/* + * drivers/net/ethernet/nxp/lpc_eth.c + * + * Author: Kevin Wells + * + * Copyright (C) 2010 NXP Semiconductors + * Copyright (C) 2012 Roland Stigge + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define MODNAME "lpc-eth" +#define DRV_VERSION "1.00" +#define PHYDEF_ADDR 0x00 + +#define ENET_MAXF_SIZE 1536 +#define ENET_RX_DESC 48 +#define ENET_TX_DESC 16 + +#define NAPI_WEIGHT 16 + +/* + * Ethernet MAC controller Register offsets + */ +#define LPC_ENET_MAC1(x) (x + 0x000) +#define LPC_ENET_MAC2(x) (x + 0x004) +#define LPC_ENET_IPGT(x) (x + 0x008) +#define LPC_ENET_IPGR(x) (x + 0x00C) +#define LPC_ENET_CLRT(x) (x + 0x010) +#define LPC_ENET_MAXF(x) (x + 0x014) +#define LPC_ENET_SUPP(x) (x + 0x018) +#define LPC_ENET_TEST(x) (x + 0x01C) +#define LPC_ENET_MCFG(x) (x + 0x020) +#define LPC_ENET_MCMD(x) (x + 0x024) +#define LPC_ENET_MADR(x) (x + 0x028) +#define LPC_ENET_MWTD(x) (x + 0x02C) +#define LPC_ENET_MRDD(x) (x + 0x030) +#define LPC_ENET_MIND(x) (x + 0x034) +#define LPC_ENET_SA0(x) (x + 0x040) +#define LPC_ENET_SA1(x) (x + 0x044) +#define LPC_ENET_SA2(x) (x + 0x048) +#define LPC_ENET_COMMAND(x) (x + 0x100) +#define LPC_ENET_STATUS(x) (x + 0x104) +#define LPC_ENET_RXDESCRIPTOR(x) (x + 0x108) +#define LPC_ENET_RXSTATUS(x) (x + 0x10C) +#define LPC_ENET_RXDESCRIPTORNUMBER(x) (x + 0x110) +#define LPC_ENET_RXPRODUCEINDEX(x) (x + 0x114) +#define LPC_ENET_RXCONSUMEINDEX(x) (x + 0x118) +#define LPC_ENET_TXDESCRIPTOR(x) (x + 0x11C) +#define LPC_ENET_TXSTATUS(x) (x + 0x120) +#define LPC_ENET_TXDESCRIPTORNUMBER(x) (x + 0x124) +#define LPC_ENET_TXPRODUCEINDEX(x) (x + 0x128) +#define LPC_ENET_TXCONSUMEINDEX(x) (x + 0x12C) +#define LPC_ENET_TSV0(x) (x + 0x158) +#define LPC_ENET_TSV1(x) (x + 0x15C) +#define LPC_ENET_RSV(x) (x + 0x160) +#define LPC_ENET_FLOWCONTROLCOUNTER(x) (x + 0x170) +#define LPC_ENET_FLOWCONTROLSTATUS(x) (x + 0x174) +#define LPC_ENET_RXFILTER_CTRL(x) (x + 0x200) +#define LPC_ENET_RXFILTERWOLSTATUS(x) (x + 0x204) +#define LPC_ENET_RXFILTERWOLCLEAR(x) (x + 0x208) +#define LPC_ENET_HASHFILTERL(x) (x + 0x210) +#define LPC_ENET_HASHFILTERH(x) (x + 0x214) +#define LPC_ENET_INTSTATUS(x) (x + 0xFE0) +#define LPC_ENET_INTENABLE(x) (x + 0xFE4) +#define LPC_ENET_INTCLEAR(x) (x + 0xFE8) +#define LPC_ENET_INTSET(x) (x + 0xFEC) +#define LPC_ENET_POWERDOWN(x) (x + 0xFF4) + +/* + * mac1 register definitions + */ +#define LPC_MAC1_RECV_ENABLE (1 << 0) +#define LPC_MAC1_PASS_ALL_RX_FRAMES (1 << 1) +#define LPC_MAC1_RX_FLOW_CONTROL (1 << 2) +#define LPC_MAC1_TX_FLOW_CONTROL (1 << 3) +#define LPC_MAC1_LOOPBACK (1 << 4) +#define LPC_MAC1_RESET_TX (1 << 8) +#define LPC_MAC1_RESET_MCS_TX (1 << 9) +#define LPC_MAC1_RESET_RX (1 << 10) +#define LPC_MAC1_RESET_MCS_RX (1 << 11) +#define LPC_MAC1_SIMULATION_RESET (1 << 14) +#define LPC_MAC1_SOFT_RESET (1 << 15) + +/* + * mac2 register definitions + */ +#define LPC_MAC2_FULL_DUPLEX (1 << 0) +#define LPC_MAC2_FRAME_LENGTH_CHECKING (1 << 1) +#define LPC_MAC2_HUGH_LENGTH_CHECKING (1 << 2) +#define LPC_MAC2_DELAYED_CRC (1 << 3) +#define LPC_MAC2_CRC_ENABLE (1 << 4) +#define LPC_MAC2_PAD_CRC_ENABLE (1 << 5) +#define LPC_MAC2_VLAN_PAD_ENABLE (1 << 6) +#define LPC_MAC2_AUTO_DETECT_PAD_ENABLE (1 << 7) +#define LPC_MAC2_PURE_PREAMBLE_ENFORCEMENT (1 << 8) +#define LPC_MAC2_LONG_PREAMBLE_ENFORCEMENT (1 << 9) +#define LPC_MAC2_NO_BACKOFF (1 << 12) +#define LPC_MAC2_BACK_PRESSURE (1 << 13) +#define LPC_MAC2_EXCESS_DEFER (1 << 14) + +/* + * ipgt register definitions + */ +#define LPC_IPGT_LOAD(n) ((n) & 0x7F) + +/* + * ipgr register definitions + */ +#define LPC_IPGR_LOAD_PART2(n) ((n) & 0x7F) +#define LPC_IPGR_LOAD_PART1(n) (((n) & 0x7F) << 8) + +/* + * clrt register definitions + */ +#define LPC_CLRT_LOAD_RETRY_MAX(n) ((n) & 0xF) +#define LPC_CLRT_LOAD_COLLISION_WINDOW(n) (((n) & 0x3F) << 8) + +/* + * maxf register definitions + */ +#define LPC_MAXF_LOAD_MAX_FRAME_LEN(n) ((n) & 0xFFFF) + +/* + * supp register definitions + */ +#define LPC_SUPP_SPEED (1 << 8) +#define LPC_SUPP_RESET_RMII (1 << 11) + +/* + * test register definitions + */ +#define LPC_TEST_SHORTCUT_PAUSE_QUANTA (1 << 0) +#define LPC_TEST_PAUSE (1 << 1) +#define LPC_TEST_BACKPRESSURE (1 << 2) + +/* + * mcfg register definitions + */ +#define LPC_MCFG_SCAN_INCREMENT (1 << 0) +#define LPC_MCFG_SUPPRESS_PREAMBLE (1 << 1) +#define LPC_MCFG_CLOCK_SELECT(n) (((n) & 0x7) << 2) +#define LPC_MCFG_CLOCK_HOST_DIV_4 0 +#define LPC_MCFG_CLOCK_HOST_DIV_6 2 +#define LPC_MCFG_CLOCK_HOST_DIV_8 3 +#define LPC_MCFG_CLOCK_HOST_DIV_10 4 +#define LPC_MCFG_CLOCK_HOST_DIV_14 5 +#define LPC_MCFG_CLOCK_HOST_DIV_20 6 +#define LPC_MCFG_CLOCK_HOST_DIV_28 7 +#define LPC_MCFG_RESET_MII_MGMT (1 << 15) + +/* + * mcmd register definitions + */ +#define LPC_MCMD_READ (1 << 0) +#define LPC_MCMD_SCAN (1 << 1) + +/* + * madr register definitions + */ +#define LPC_MADR_REGISTER_ADDRESS(n) ((n) & 0x1F) +#define LPC_MADR_PHY_0ADDRESS(n) (((n) & 0x1F) << 8) + +/* + * mwtd register definitions + */ +#define LPC_MWDT_WRITE(n) ((n) & 0xFFFF) + +/* + * mrdd register definitions + */ +#define LPC_MRDD_READ_MASK 0xFFFF + +/* + * mind register definitions + */ +#define LPC_MIND_BUSY (1 << 0) +#define LPC_MIND_SCANNING (1 << 1) +#define LPC_MIND_NOT_VALID (1 << 2) +#define LPC_MIND_MII_LINK_FAIL (1 << 3) + +/* + * command register definitions + */ +#define LPC_COMMAND_RXENABLE (1 << 0) +#define LPC_COMMAND_TXENABLE (1 << 1) +#define LPC_COMMAND_REG_RESET (1 << 3) +#define LPC_COMMAND_TXRESET (1 << 4) +#define LPC_COMMAND_RXRESET (1 << 5) +#define LPC_COMMAND_PASSRUNTFRAME (1 << 6) +#define LPC_COMMAND_PASSRXFILTER (1 << 7) +#define LPC_COMMAND_TXFLOWCONTROL (1 << 8) +#define LPC_COMMAND_RMII (1 << 9) +#define LPC_COMMAND_FULLDUPLEX (1 << 10) + +/* + * status register definitions + */ +#define LPC_STATUS_RXACTIVE (1 << 0) +#define LPC_STATUS_TXACTIVE (1 << 1) + +/* + * tsv0 register definitions + */ +#define LPC_TSV0_CRC_ERROR (1 << 0) +#define LPC_TSV0_LENGTH_CHECK_ERROR (1 << 1) +#define LPC_TSV0_LENGTH_OUT_OF_RANGE (1 << 2) +#define LPC_TSV0_DONE (1 << 3) +#define LPC_TSV0_MULTICAST (1 << 4) +#define LPC_TSV0_BROADCAST (1 << 5) +#define LPC_TSV0_PACKET_DEFER (1 << 6) +#define LPC_TSV0_ESCESSIVE_DEFER (1 << 7) +#define LPC_TSV0_ESCESSIVE_COLLISION (1 << 8) +#define LPC_TSV0_LATE_COLLISION (1 << 9) +#define LPC_TSV0_GIANT (1 << 10) +#define LPC_TSV0_UNDERRUN (1 << 11) +#define LPC_TSV0_TOTAL_BYTES(n) (((n) >> 12) & 0xFFFF) +#define LPC_TSV0_CONTROL_FRAME (1 << 28) +#define LPC_TSV0_PAUSE (1 << 29) +#define LPC_TSV0_BACKPRESSURE (1 << 30) +#define LPC_TSV0_VLAN (1 << 31) + +/* + * tsv1 register definitions + */ +#define LPC_TSV1_TRANSMIT_BYTE_COUNT(n) ((n) & 0xFFFF) +#define LPC_TSV1_COLLISION_COUNT(n) (((n) >> 16) & 0xF) + +/* + * rsv register definitions + */ +#define LPC_RSV_RECEIVED_BYTE_COUNT(n) ((n) & 0xFFFF) +#define LPC_RSV_RXDV_EVENT_IGNORED (1 << 16) +#define LPC_RSV_RXDV_EVENT_PREVIOUSLY_SEEN (1 << 17) +#define LPC_RSV_CARRIER_EVNT_PREVIOUS_SEEN (1 << 18) +#define LPC_RSV_RECEIVE_CODE_VIOLATION (1 << 19) +#define LPC_RSV_CRC_ERROR (1 << 20) +#define LPC_RSV_LENGTH_CHECK_ERROR (1 << 21) +#define LPC_RSV_LENGTH_OUT_OF_RANGE (1 << 22) +#define LPC_RSV_RECEIVE_OK (1 << 23) +#define LPC_RSV_MULTICAST (1 << 24) +#define LPC_RSV_BROADCAST (1 << 25) +#define LPC_RSV_DRIBBLE_NIBBLE (1 << 26) +#define LPC_RSV_CONTROL_FRAME (1 << 27) +#define LPC_RSV_PAUSE (1 << 28) +#define LPC_RSV_UNSUPPORTED_OPCODE (1 << 29) +#define LPC_RSV_VLAN (1 << 30) + +/* + * flowcontrolcounter register definitions + */ +#define LPC_FCCR_MIRRORCOUNTER(n) ((n) & 0xFFFF) +#define LPC_FCCR_PAUSETIMER(n) (((n) >> 16) & 0xFFFF) + +/* + * flowcontrolstatus register definitions + */ +#define LPC_FCCR_MIRRORCOUNTERCURRENT(n) ((n) & 0xFFFF) + +/* + * rxfliterctrl, rxfilterwolstatus, and rxfilterwolclear shared + * register definitions + */ +#define LPC_RXFLTRW_ACCEPTUNICAST (1 << 0) +#define LPC_RXFLTRW_ACCEPTUBROADCAST (1 << 1) +#define LPC_RXFLTRW_ACCEPTUMULTICAST (1 << 2) +#define LPC_RXFLTRW_ACCEPTUNICASTHASH (1 << 3) +#define LPC_RXFLTRW_ACCEPTUMULTICASTHASH (1 << 4) +#define LPC_RXFLTRW_ACCEPTPERFECT (1 << 5) + +/* + * rxfliterctrl register definitions + */ +#define LPC_RXFLTRWSTS_MAGICPACKETENWOL (1 << 12) +#define LPC_RXFLTRWSTS_RXFILTERENWOL (1 << 13) + +/* + * rxfilterwolstatus/rxfilterwolclear register definitions + */ +#define LPC_RXFLTRWSTS_RXFILTERWOL (1 << 7) +#define LPC_RXFLTRWSTS_MAGICPACKETWOL (1 << 8) + +/* + * intstatus, intenable, intclear, and Intset shared register + * definitions + */ +#define LPC_MACINT_RXOVERRUNINTEN (1 << 0) +#define LPC_MACINT_RXERRORONINT (1 << 1) +#define LPC_MACINT_RXFINISHEDINTEN (1 << 2) +#define LPC_MACINT_RXDONEINTEN (1 << 3) +#define LPC_MACINT_TXUNDERRUNINTEN (1 << 4) +#define LPC_MACINT_TXERRORINTEN (1 << 5) +#define LPC_MACINT_TXFINISHEDINTEN (1 << 6) +#define LPC_MACINT_TXDONEINTEN (1 << 7) +#define LPC_MACINT_SOFTINTEN (1 << 12) +#define LPC_MACINT_WAKEUPINTEN (1 << 13) + +/* + * powerdown register definitions + */ +#define LPC_POWERDOWN_MACAHB (1 << 31) + +/* Upon the upcoming introduction of device tree usage in LPC32xx, + * lpc_phy_interface_mode() and use_iram_for_net() will be extended with a + * device parameter for access to device tree information at runtime, instead + * of defining the values at compile time + */ +static inline phy_interface_t lpc_phy_interface_mode(void) +{ +#ifdef CONFIG_ARCH_LPC32XX_MII_SUPPORT + return PHY_INTERFACE_MODE_MII; +#else + return PHY_INTERFACE_MODE_RMII; +#endif +} + +static inline int use_iram_for_net(void) +{ +#ifdef CONFIG_ARCH_LPC32XX_IRAM_FOR_NET + return 1; +#else + return 0; +#endif +} + +/* Receive Status information word */ +#define RXSTATUS_SIZE 0x000007FF +#define RXSTATUS_CONTROL (1 << 18) +#define RXSTATUS_VLAN (1 << 19) +#define RXSTATUS_FILTER (1 << 20) +#define RXSTATUS_MULTICAST (1 << 21) +#define RXSTATUS_BROADCAST (1 << 22) +#define RXSTATUS_CRC (1 << 23) +#define RXSTATUS_SYMBOL (1 << 24) +#define RXSTATUS_LENGTH (1 << 25) +#define RXSTATUS_RANGE (1 << 26) +#define RXSTATUS_ALIGN (1 << 27) +#define RXSTATUS_OVERRUN (1 << 28) +#define RXSTATUS_NODESC (1 << 29) +#define RXSTATUS_LAST (1 << 30) +#define RXSTATUS_ERROR (1 << 31) + +#define RXSTATUS_STATUS_ERROR \ + (RXSTATUS_NODESC | RXSTATUS_OVERRUN | RXSTATUS_ALIGN | \ + RXSTATUS_RANGE | RXSTATUS_LENGTH | RXSTATUS_SYMBOL | RXSTATUS_CRC) + +/* Receive Descriptor control word */ +#define RXDESC_CONTROL_SIZE 0x000007FF +#define RXDESC_CONTROL_INT (1 << 31) + +/* Transmit Status information word */ +#define TXSTATUS_COLLISIONS_GET(x) (((x) >> 21) & 0xF) +#define TXSTATUS_DEFER (1 << 25) +#define TXSTATUS_EXCESSDEFER (1 << 26) +#define TXSTATUS_EXCESSCOLL (1 << 27) +#define TXSTATUS_LATECOLL (1 << 28) +#define TXSTATUS_UNDERRUN (1 << 29) +#define TXSTATUS_NODESC (1 << 30) +#define TXSTATUS_ERROR (1 << 31) + +/* Transmit Descriptor control word */ +#define TXDESC_CONTROL_SIZE 0x000007FF +#define TXDESC_CONTROL_OVERRIDE (1 << 26) +#define TXDESC_CONTROL_HUGE (1 << 27) +#define TXDESC_CONTROL_PAD (1 << 28) +#define TXDESC_CONTROL_CRC (1 << 29) +#define TXDESC_CONTROL_LAST (1 << 30) +#define TXDESC_CONTROL_INT (1 << 31) + +static int lpc_eth_hard_start_xmit(struct sk_buff *skb, + struct net_device *ndev); + +/* + * Structure of a TX/RX descriptors and RX status + */ +struct txrx_desc_t { + __le32 packet; + __le32 control; +}; +struct rx_status_t { + __le32 statusinfo; + __le32 statushashcrc; +}; + +/* + * Device driver data structure + */ +struct netdata_local { + struct platform_device *pdev; + struct net_device *ndev; + spinlock_t lock; + void __iomem *net_base; + u32 msg_enable; + struct sk_buff *skb[ENET_TX_DESC]; + unsigned int last_tx_idx; + unsigned int num_used_tx_buffs; + struct mii_bus *mii_bus; + struct phy_device *phy_dev; + struct clk *clk; + dma_addr_t dma_buff_base_p; + void *dma_buff_base_v; + size_t dma_buff_size; + struct txrx_desc_t *tx_desc_v; + u32 *tx_stat_v; + void *tx_buff_v; + struct txrx_desc_t *rx_desc_v; + struct rx_status_t *rx_stat_v; + void *rx_buff_v; + int link; + int speed; + int duplex; + struct napi_struct napi; +}; + +/* + * MAC support functions + */ +static void __lpc_set_mac(struct netdata_local *pldat, u8 *mac) +{ + u32 tmp; + + /* Set station address */ + tmp = mac[0] | ((u32)mac[1] << 8); + writel(tmp, LPC_ENET_SA2(pldat->net_base)); + tmp = mac[2] | ((u32)mac[3] << 8); + writel(tmp, LPC_ENET_SA1(pldat->net_base)); + tmp = mac[4] | ((u32)mac[5] << 8); + writel(tmp, LPC_ENET_SA0(pldat->net_base)); + + netdev_dbg(pldat->ndev, "Ethernet MAC address %pM\n", mac); +} + +static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac) +{ + u32 tmp; + + /* Get station address */ + tmp = readl(LPC_ENET_SA2(pldat->net_base)); + mac[0] = tmp & 0xFF; + mac[1] = tmp >> 8; + tmp = readl(LPC_ENET_SA1(pldat->net_base)); + mac[2] = tmp & 0xFF; + mac[3] = tmp >> 8; + tmp = readl(LPC_ENET_SA0(pldat->net_base)); + mac[4] = tmp & 0xFF; + mac[5] = tmp >> 8; +} + +static void __lpc_eth_clock_enable(struct netdata_local *pldat, + bool enable) +{ + if (enable) + clk_enable(pldat->clk); + else + clk_disable(pldat->clk); +} + +static void __lpc_params_setup(struct netdata_local *pldat) +{ + u32 tmp; + + if (pldat->duplex == DUPLEX_FULL) { + tmp = readl(LPC_ENET_MAC2(pldat->net_base)); + tmp |= LPC_MAC2_FULL_DUPLEX; + writel(tmp, LPC_ENET_MAC2(pldat->net_base)); + tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); + tmp |= LPC_COMMAND_FULLDUPLEX; + writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); + writel(LPC_IPGT_LOAD(0x15), LPC_ENET_IPGT(pldat->net_base)); + } else { + tmp = readl(LPC_ENET_MAC2(pldat->net_base)); + tmp &= ~LPC_MAC2_FULL_DUPLEX; + writel(tmp, LPC_ENET_MAC2(pldat->net_base)); + tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); + tmp &= ~LPC_COMMAND_FULLDUPLEX; + writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); + writel(LPC_IPGT_LOAD(0x12), LPC_ENET_IPGT(pldat->net_base)); + } + + if (pldat->speed == SPEED_100) + writel(LPC_SUPP_SPEED, LPC_ENET_SUPP(pldat->net_base)); + else + writel(0, LPC_ENET_SUPP(pldat->net_base)); +} + +static void __lpc_eth_reset(struct netdata_local *pldat) +{ + /* Reset all MAC logic */ + writel((LPC_MAC1_RESET_TX | LPC_MAC1_RESET_MCS_TX | LPC_MAC1_RESET_RX | + LPC_MAC1_RESET_MCS_RX | LPC_MAC1_SIMULATION_RESET | + LPC_MAC1_SOFT_RESET), LPC_ENET_MAC1(pldat->net_base)); + writel((LPC_COMMAND_REG_RESET | LPC_COMMAND_TXRESET | + LPC_COMMAND_RXRESET), LPC_ENET_COMMAND(pldat->net_base)); +} + +static int __lpc_mii_mngt_reset(struct netdata_local *pldat) +{ + /* Reset MII management hardware */ + writel(LPC_MCFG_RESET_MII_MGMT, LPC_ENET_MCFG(pldat->net_base)); + + /* Setup MII clock to slowest rate with a /28 divider */ + writel(LPC_MCFG_CLOCK_SELECT(LPC_MCFG_CLOCK_HOST_DIV_28), + LPC_ENET_MCFG(pldat->net_base)); + + return 0; +} + +static inline phys_addr_t __va_to_pa(void *addr, struct netdata_local *pldat) +{ + phys_addr_t phaddr; + + phaddr = addr - pldat->dma_buff_base_v; + phaddr += pldat->dma_buff_base_p; + + return phaddr; +} + +static void lpc_eth_enable_int(void __iomem *regbase) +{ + writel((LPC_MACINT_RXDONEINTEN | LPC_MACINT_TXDONEINTEN), + LPC_ENET_INTENABLE(regbase)); +} + +static void lpc_eth_disable_int(void __iomem *regbase) +{ + writel(0, LPC_ENET_INTENABLE(regbase)); +} + +/* Setup TX/RX descriptors */ +static void __lpc_txrx_desc_setup(struct netdata_local *pldat) +{ + u32 *ptxstat; + void *tbuff; + int i; + struct txrx_desc_t *ptxrxdesc; + struct rx_status_t *prxstat; + + tbuff = PTR_ALIGN(pldat->dma_buff_base_v, 16); + + /* Setup TX descriptors, status, and buffers */ + pldat->tx_desc_v = tbuff; + tbuff += sizeof(struct txrx_desc_t) * ENET_TX_DESC; + + pldat->tx_stat_v = tbuff; + tbuff += sizeof(u32) * ENET_TX_DESC; + + tbuff = PTR_ALIGN(tbuff, 16); + pldat->tx_buff_v = tbuff; + tbuff += ENET_MAXF_SIZE * ENET_TX_DESC; + + /* Setup RX descriptors, status, and buffers */ + pldat->rx_desc_v = tbuff; + tbuff += sizeof(struct txrx_desc_t) * ENET_RX_DESC; + + tbuff = PTR_ALIGN(tbuff, 16); + pldat->rx_stat_v = tbuff; + tbuff += sizeof(struct rx_status_t) * ENET_RX_DESC; + + tbuff = PTR_ALIGN(tbuff, 16); + pldat->rx_buff_v = tbuff; + tbuff += ENET_MAXF_SIZE * ENET_RX_DESC; + + /* Map the TX descriptors to the TX buffers in hardware */ + for (i = 0; i < ENET_TX_DESC; i++) { + ptxstat = &pldat->tx_stat_v[i]; + ptxrxdesc = &pldat->tx_desc_v[i]; + + ptxrxdesc->packet = __va_to_pa( + pldat->tx_buff_v + i * ENET_MAXF_SIZE, pldat); + ptxrxdesc->control = 0; + *ptxstat = 0; + } + + /* Map the RX descriptors to the RX buffers in hardware */ + for (i = 0; i < ENET_RX_DESC; i++) { + prxstat = &pldat->rx_stat_v[i]; + ptxrxdesc = &pldat->rx_desc_v[i]; + + ptxrxdesc->packet = __va_to_pa( + pldat->rx_buff_v + i * ENET_MAXF_SIZE, pldat); + ptxrxdesc->control = RXDESC_CONTROL_INT | (ENET_MAXF_SIZE - 1); + prxstat->statusinfo = 0; + prxstat->statushashcrc = 0; + } + + /* Setup base addresses in hardware to point to buffers and + * descriptors + */ + writel((ENET_TX_DESC - 1), + LPC_ENET_TXDESCRIPTORNUMBER(pldat->net_base)); + writel(__va_to_pa(pldat->tx_desc_v, pldat), + LPC_ENET_TXDESCRIPTOR(pldat->net_base)); + writel(__va_to_pa(pldat->tx_stat_v, pldat), + LPC_ENET_TXSTATUS(pldat->net_base)); + writel((ENET_RX_DESC - 1), + LPC_ENET_RXDESCRIPTORNUMBER(pldat->net_base)); + writel(__va_to_pa(pldat->rx_desc_v, pldat), + LPC_ENET_RXDESCRIPTOR(pldat->net_base)); + writel(__va_to_pa(pldat->rx_stat_v, pldat), + LPC_ENET_RXSTATUS(pldat->net_base)); +} + +static void __lpc_eth_init(struct netdata_local *pldat) +{ + u32 tmp; + + /* Disable controller and reset */ + tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); + tmp &= ~LPC_COMMAND_RXENABLE | LPC_COMMAND_TXENABLE; + writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); + tmp = readl(LPC_ENET_MAC1(pldat->net_base)); + tmp &= ~LPC_MAC1_RECV_ENABLE; + writel(tmp, LPC_ENET_MAC1(pldat->net_base)); + + /* Initial MAC setup */ + writel(LPC_MAC1_PASS_ALL_RX_FRAMES, LPC_ENET_MAC1(pldat->net_base)); + writel((LPC_MAC2_PAD_CRC_ENABLE | LPC_MAC2_CRC_ENABLE), + LPC_ENET_MAC2(pldat->net_base)); + writel(ENET_MAXF_SIZE, LPC_ENET_MAXF(pldat->net_base)); + + /* Collision window, gap */ + writel((LPC_CLRT_LOAD_RETRY_MAX(0xF) | + LPC_CLRT_LOAD_COLLISION_WINDOW(0x37)), + LPC_ENET_CLRT(pldat->net_base)); + writel(LPC_IPGR_LOAD_PART2(0x12), LPC_ENET_IPGR(pldat->net_base)); + + if (lpc_phy_interface_mode() == PHY_INTERFACE_MODE_MII) + writel(LPC_COMMAND_PASSRUNTFRAME, + LPC_ENET_COMMAND(pldat->net_base)); + else { + writel((LPC_COMMAND_PASSRUNTFRAME | LPC_COMMAND_RMII), + LPC_ENET_COMMAND(pldat->net_base)); + writel(LPC_SUPP_RESET_RMII, LPC_ENET_SUPP(pldat->net_base)); + } + + __lpc_params_setup(pldat); + + /* Setup TX and RX descriptors */ + __lpc_txrx_desc_setup(pldat); + + /* Setup packet filtering */ + writel((LPC_RXFLTRW_ACCEPTUBROADCAST | LPC_RXFLTRW_ACCEPTPERFECT), + LPC_ENET_RXFILTER_CTRL(pldat->net_base)); + + /* Get the next TX buffer output index */ + pldat->num_used_tx_buffs = 0; + pldat->last_tx_idx = + readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); + + /* Clear and enable interrupts */ + writel(0xFFFF, LPC_ENET_INTCLEAR(pldat->net_base)); + smp_wmb(); + lpc_eth_enable_int(pldat->net_base); + + /* Enable controller */ + tmp = readl(LPC_ENET_COMMAND(pldat->net_base)); + tmp |= LPC_COMMAND_RXENABLE | LPC_COMMAND_TXENABLE; + writel(tmp, LPC_ENET_COMMAND(pldat->net_base)); + tmp = readl(LPC_ENET_MAC1(pldat->net_base)); + tmp |= LPC_MAC1_RECV_ENABLE; + writel(tmp, LPC_ENET_MAC1(pldat->net_base)); +} + +static void __lpc_eth_shutdown(struct netdata_local *pldat) +{ + /* Reset ethernet and power down PHY */ + __lpc_eth_reset(pldat); + writel(0, LPC_ENET_MAC1(pldat->net_base)); + writel(0, LPC_ENET_MAC2(pldat->net_base)); +} + +/* + * MAC<--->PHY support functions + */ +static int lpc_mdio_read(struct mii_bus *bus, int phy_id, int phyreg) +{ + struct netdata_local *pldat = bus->priv; + unsigned long timeout = jiffies + msecs_to_jiffies(100); + int lps; + + writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base)); + writel(LPC_MCMD_READ, LPC_ENET_MCMD(pldat->net_base)); + + /* Wait for unbusy status */ + while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) { + if (time_after(jiffies, timeout)) + return -EIO; + cpu_relax(); + } + + lps = readl(LPC_ENET_MRDD(pldat->net_base)); + writel(0, LPC_ENET_MCMD(pldat->net_base)); + + return lps; +} + +static int lpc_mdio_write(struct mii_bus *bus, int phy_id, int phyreg, + u16 phydata) +{ + struct netdata_local *pldat = bus->priv; + unsigned long timeout = jiffies + msecs_to_jiffies(100); + + writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base)); + writel(phydata, LPC_ENET_MWTD(pldat->net_base)); + + /* Wait for completion */ + while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) { + if (time_after(jiffies, timeout)) + return -EIO; + cpu_relax(); + } + + return 0; +} + +static int lpc_mdio_reset(struct mii_bus *bus) +{ + return __lpc_mii_mngt_reset((struct netdata_local *)bus->priv); +} + +static void lpc_handle_link_change(struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct phy_device *phydev = pldat->phy_dev; + unsigned long flags; + + bool status_change = false; + + spin_lock_irqsave(&pldat->lock, flags); + + if (phydev->link) { + if ((pldat->speed != phydev->speed) || + (pldat->duplex != phydev->duplex)) { + pldat->speed = phydev->speed; + pldat->duplex = phydev->duplex; + status_change = true; + } + } + + if (phydev->link != pldat->link) { + if (!phydev->link) { + pldat->speed = 0; + pldat->duplex = -1; + } + pldat->link = phydev->link; + + status_change = true; + } + + spin_unlock_irqrestore(&pldat->lock, flags); + + if (status_change) + __lpc_params_setup(pldat); +} + +static int lpc_mii_probe(struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct phy_device *phydev = phy_find_first(pldat->mii_bus); + + if (!phydev) { + netdev_err(ndev, "no PHY found\n"); + return -ENODEV; + } + + /* Attach to the PHY */ + if (lpc_phy_interface_mode() == PHY_INTERFACE_MODE_MII) + netdev_info(ndev, "using MII interface\n"); + else + netdev_info(ndev, "using RMII interface\n"); + phydev = phy_connect(ndev, dev_name(&phydev->dev), + &lpc_handle_link_change, 0, lpc_phy_interface_mode()); + + if (IS_ERR(phydev)) { + netdev_err(ndev, "Could not attach to PHY\n"); + return PTR_ERR(phydev); + } + + /* mask with MAC supported features */ + phydev->supported &= PHY_BASIC_FEATURES; + + phydev->advertising = phydev->supported; + + pldat->link = 0; + pldat->speed = 0; + pldat->duplex = -1; + pldat->phy_dev = phydev; + + netdev_info(ndev, + "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", + phydev->drv->name, dev_name(&phydev->dev), phydev->irq); + return 0; +} + +static int lpc_mii_init(struct netdata_local *pldat) +{ + int err = -ENXIO, i; + + pldat->mii_bus = mdiobus_alloc(); + if (!pldat->mii_bus) { + err = -ENOMEM; + goto err_out; + } + + /* Setup MII mode */ + if (lpc_phy_interface_mode() == PHY_INTERFACE_MODE_MII) + writel(LPC_COMMAND_PASSRUNTFRAME, + LPC_ENET_COMMAND(pldat->net_base)); + else { + writel((LPC_COMMAND_PASSRUNTFRAME | LPC_COMMAND_RMII), + LPC_ENET_COMMAND(pldat->net_base)); + writel(LPC_SUPP_RESET_RMII, LPC_ENET_SUPP(pldat->net_base)); + } + + pldat->mii_bus->name = "lpc_mii_bus"; + pldat->mii_bus->read = &lpc_mdio_read; + pldat->mii_bus->write = &lpc_mdio_write; + pldat->mii_bus->reset = &lpc_mdio_reset; + snprintf(pldat->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", + pldat->pdev->name, pldat->pdev->id); + pldat->mii_bus->priv = pldat; + pldat->mii_bus->parent = &pldat->pdev->dev; + + pldat->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); + if (!pldat->mii_bus->irq) { + err = -ENOMEM; + goto err_out_1; + } + + for (i = 0; i < PHY_MAX_ADDR; i++) + pldat->mii_bus->irq[i] = PHY_POLL; + + platform_set_drvdata(pldat->pdev, pldat->mii_bus); + + if (mdiobus_register(pldat->mii_bus)) + goto err_out_free_mdio_irq; + + if (lpc_mii_probe(pldat->ndev) != 0) + goto err_out_unregister_bus; + + return 0; + +err_out_unregister_bus: + mdiobus_unregister(pldat->mii_bus); +err_out_free_mdio_irq: + kfree(pldat->mii_bus->irq); +err_out_1: + mdiobus_free(pldat->mii_bus); +err_out: + return err; +} + +static void __lpc_handle_xmit(struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct sk_buff *skb; + u32 txcidx, *ptxstat, txstat; + + txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); + while (pldat->last_tx_idx != txcidx) { + skb = pldat->skb[pldat->last_tx_idx]; + + /* A buffer is available, get buffer status */ + ptxstat = &pldat->tx_stat_v[pldat->last_tx_idx]; + txstat = *ptxstat; + + /* Next buffer and decrement used buffer counter */ + pldat->num_used_tx_buffs--; + pldat->last_tx_idx++; + if (pldat->last_tx_idx >= ENET_TX_DESC) + pldat->last_tx_idx = 0; + + /* Update collision counter */ + ndev->stats.collisions += TXSTATUS_COLLISIONS_GET(txstat); + + /* Any errors occurred? */ + if (txstat & TXSTATUS_ERROR) { + if (txstat & TXSTATUS_UNDERRUN) { + /* FIFO underrun */ + ndev->stats.tx_fifo_errors++; + } + if (txstat & TXSTATUS_LATECOLL) { + /* Late collision */ + ndev->stats.tx_aborted_errors++; + } + if (txstat & TXSTATUS_EXCESSCOLL) { + /* Excessive collision */ + ndev->stats.tx_aborted_errors++; + } + if (txstat & TXSTATUS_EXCESSDEFER) { + /* Defer limit */ + ndev->stats.tx_aborted_errors++; + } + ndev->stats.tx_errors++; + } else { + /* Update stats */ + ndev->stats.tx_packets++; + ndev->stats.tx_bytes += skb->len; + + /* Free buffer */ + dev_kfree_skb_irq(skb); + } + + txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base)); + } + + if (netif_queue_stopped(ndev)) + netif_wake_queue(ndev); +} + +static int __lpc_handle_recv(struct net_device *ndev, int budget) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct sk_buff *skb; + u32 rxconsidx, len, ethst; + struct rx_status_t *prxstat; + u8 *prdbuf; + int rx_done = 0; + + /* Get the current RX buffer indexes */ + rxconsidx = readl(LPC_ENET_RXCONSUMEINDEX(pldat->net_base)); + while (rx_done < budget && rxconsidx != + readl(LPC_ENET_RXPRODUCEINDEX(pldat->net_base))) { + /* Get pointer to receive status */ + prxstat = &pldat->rx_stat_v[rxconsidx]; + len = (prxstat->statusinfo & RXSTATUS_SIZE) + 1; + + /* Status error? */ + ethst = prxstat->statusinfo; + if ((ethst & (RXSTATUS_ERROR | RXSTATUS_STATUS_ERROR)) == + (RXSTATUS_ERROR | RXSTATUS_RANGE)) + ethst &= ~RXSTATUS_ERROR; + + if (ethst & RXSTATUS_ERROR) { + int si = prxstat->statusinfo; + /* Check statuses */ + if (si & RXSTATUS_OVERRUN) { + /* Overrun error */ + ndev->stats.rx_fifo_errors++; + } else if (si & RXSTATUS_CRC) { + /* CRC error */ + ndev->stats.rx_crc_errors++; + } else if (si & RXSTATUS_LENGTH) { + /* Length error */ + ndev->stats.rx_length_errors++; + } else if (si & RXSTATUS_ERROR) { + /* Other error */ + ndev->stats.rx_length_errors++; + } + ndev->stats.rx_errors++; + } else { + /* Packet is good */ + skb = dev_alloc_skb(len + 8); + if (!skb) + ndev->stats.rx_dropped++; + else { + prdbuf = skb_put(skb, len); + + /* Copy packet from buffer */ + memcpy(prdbuf, pldat->rx_buff_v + + rxconsidx * ENET_MAXF_SIZE, len); + + /* Pass to upper layer */ + skb->protocol = eth_type_trans(skb, ndev); + netif_receive_skb(skb); + ndev->stats.rx_packets++; + ndev->stats.rx_bytes += len; + } + } + + /* Increment consume index */ + rxconsidx = rxconsidx + 1; + if (rxconsidx >= ENET_RX_DESC) + rxconsidx = 0; + writel(rxconsidx, + LPC_ENET_RXCONSUMEINDEX(pldat->net_base)); + rx_done++; + } + + return rx_done; +} + +static int lpc_eth_poll(struct napi_struct *napi, int budget) +{ + struct netdata_local *pldat = container_of(napi, + struct netdata_local, napi); + struct net_device *ndev = pldat->ndev; + int rx_done = 0; + struct netdev_queue *txq = netdev_get_tx_queue(ndev, 0); + + __netif_tx_lock(txq, smp_processor_id()); + __lpc_handle_xmit(ndev); + __netif_tx_unlock(txq); + rx_done = __lpc_handle_recv(ndev, budget); + + if (rx_done < budget) { + napi_complete(napi); + lpc_eth_enable_int(pldat->net_base); + } + + return rx_done; +} + +static irqreturn_t __lpc_eth_interrupt(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct netdata_local *pldat = netdev_priv(ndev); + u32 tmp; + + spin_lock(&pldat->lock); + + tmp = readl(LPC_ENET_INTSTATUS(pldat->net_base)); + /* Clear interrupts */ + writel(tmp, LPC_ENET_INTCLEAR(pldat->net_base)); + + lpc_eth_disable_int(pldat->net_base); + if (likely(napi_schedule_prep(&pldat->napi))) + __napi_schedule(&pldat->napi); + + spin_unlock(&pldat->lock); + + return IRQ_HANDLED; +} + +static int lpc_eth_close(struct net_device *ndev) +{ + unsigned long flags; + struct netdata_local *pldat = netdev_priv(ndev); + + if (netif_msg_ifdown(pldat)) + dev_dbg(&pldat->pdev->dev, "shutting down %s\n", ndev->name); + + napi_disable(&pldat->napi); + netif_stop_queue(ndev); + + if (pldat->phy_dev) + phy_stop(pldat->phy_dev); + + spin_lock_irqsave(&pldat->lock, flags); + __lpc_eth_reset(pldat); + netif_carrier_off(ndev); + writel(0, LPC_ENET_MAC1(pldat->net_base)); + writel(0, LPC_ENET_MAC2(pldat->net_base)); + spin_unlock_irqrestore(&pldat->lock, flags); + + __lpc_eth_clock_enable(pldat, false); + + return 0; +} + +static int lpc_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + u32 len, txidx; + u32 *ptxstat; + struct txrx_desc_t *ptxrxdesc; + + len = skb->len; + + spin_lock_irq(&pldat->lock); + + if (pldat->num_used_tx_buffs >= (ENET_TX_DESC - 1)) { + /* This function should never be called when there are no + buffers */ + netif_stop_queue(ndev); + spin_unlock_irq(&pldat->lock); + WARN(1, "BUG! TX request when no free TX buffers!\n"); + return NETDEV_TX_BUSY; + } + + /* Get the next TX descriptor index */ + txidx = readl(LPC_ENET_TXPRODUCEINDEX(pldat->net_base)); + + /* Setup control for the transfer */ + ptxstat = &pldat->tx_stat_v[txidx]; + *ptxstat = 0; + ptxrxdesc = &pldat->tx_desc_v[txidx]; + ptxrxdesc->control = + (len - 1) | TXDESC_CONTROL_LAST | TXDESC_CONTROL_INT; + + /* Copy data to the DMA buffer */ + memcpy(pldat->tx_buff_v + txidx * ENET_MAXF_SIZE, skb->data, len); + + /* Save the buffer and increment the buffer counter */ + pldat->skb[txidx] = skb; + pldat->num_used_tx_buffs++; + + /* Start transmit */ + txidx++; + if (txidx >= ENET_TX_DESC) + txidx = 0; + writel(txidx, LPC_ENET_TXPRODUCEINDEX(pldat->net_base)); + + /* Stop queue if no more TX buffers */ + if (pldat->num_used_tx_buffs >= (ENET_TX_DESC - 1)) + netif_stop_queue(ndev); + + spin_unlock_irq(&pldat->lock); + + return NETDEV_TX_OK; +} + +static int lpc_set_mac_address(struct net_device *ndev, void *p) +{ + struct sockaddr *addr = p; + struct netdata_local *pldat = netdev_priv(ndev); + unsigned long flags; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + memcpy(ndev->dev_addr, addr->sa_data, ETH_ALEN); + + spin_lock_irqsave(&pldat->lock, flags); + + /* Set station address */ + __lpc_set_mac(pldat, ndev->dev_addr); + + spin_unlock_irqrestore(&pldat->lock, flags); + + return 0; +} + +static void lpc_eth_set_multicast_list(struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct netdev_hw_addr_list *mcptr = &ndev->mc; + struct netdev_hw_addr *ha; + u32 tmp32, hash_val, hashlo, hashhi; + unsigned long flags; + + spin_lock_irqsave(&pldat->lock, flags); + + /* Set station address */ + __lpc_set_mac(pldat, ndev->dev_addr); + + tmp32 = LPC_RXFLTRW_ACCEPTUBROADCAST | LPC_RXFLTRW_ACCEPTPERFECT; + + if (ndev->flags & IFF_PROMISC) + tmp32 |= LPC_RXFLTRW_ACCEPTUNICAST | + LPC_RXFLTRW_ACCEPTUMULTICAST; + if (ndev->flags & IFF_ALLMULTI) + tmp32 |= LPC_RXFLTRW_ACCEPTUMULTICAST; + + if (netdev_hw_addr_list_count(mcptr)) + tmp32 |= LPC_RXFLTRW_ACCEPTUMULTICASTHASH; + + writel(tmp32, LPC_ENET_RXFILTER_CTRL(pldat->net_base)); + + + /* Set initial hash table */ + hashlo = 0x0; + hashhi = 0x0; + + /* 64 bits : multicast address in hash table */ + netdev_hw_addr_list_for_each(ha, mcptr) { + hash_val = (ether_crc(6, ha->addr) >> 23) & 0x3F; + + if (hash_val >= 32) + hashhi |= 1 << (hash_val - 32); + else + hashlo |= 1 << hash_val; + } + + writel(hashlo, LPC_ENET_HASHFILTERL(pldat->net_base)); + writel(hashhi, LPC_ENET_HASHFILTERH(pldat->net_base)); + + spin_unlock_irqrestore(&pldat->lock, flags); +} + +static int lpc_eth_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct phy_device *phydev = pldat->phy_dev; + + if (!netif_running(ndev)) + return -EINVAL; + + if (!phydev) + return -ENODEV; + + return phy_mii_ioctl(phydev, req, cmd); +} + +static int lpc_eth_open(struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + + if (netif_msg_ifup(pldat)) + dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name); + + if (!is_valid_ether_addr(ndev->dev_addr)) + return -EADDRNOTAVAIL; + + __lpc_eth_clock_enable(pldat, true); + + /* Reset and initialize */ + __lpc_eth_reset(pldat); + __lpc_eth_init(pldat); + + /* schedule a link state check */ + phy_start(pldat->phy_dev); + netif_start_queue(ndev); + napi_enable(&pldat->napi); + + return 0; +} + +/* + * Ethtool ops + */ +static void lpc_eth_ethtool_getdrvinfo(struct net_device *ndev, + struct ethtool_drvinfo *info) +{ + strcpy(info->driver, MODNAME); + strcpy(info->version, DRV_VERSION); + strcpy(info->bus_info, dev_name(ndev->dev.parent)); +} + +static u32 lpc_eth_ethtool_getmsglevel(struct net_device *ndev) +{ + struct netdata_local *pldat = netdev_priv(ndev); + + return pldat->msg_enable; +} + +static void lpc_eth_ethtool_setmsglevel(struct net_device *ndev, u32 level) +{ + struct netdata_local *pldat = netdev_priv(ndev); + + pldat->msg_enable = level; +} + +static int lpc_eth_ethtool_getsettings(struct net_device *ndev, + struct ethtool_cmd *cmd) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct phy_device *phydev = pldat->phy_dev; + + if (!phydev) + return -EOPNOTSUPP; + + return phy_ethtool_gset(phydev, cmd); +} + +static int lpc_eth_ethtool_setsettings(struct net_device *ndev, + struct ethtool_cmd *cmd) +{ + struct netdata_local *pldat = netdev_priv(ndev); + struct phy_device *phydev = pldat->phy_dev; + + if (!phydev) + return -EOPNOTSUPP; + + return phy_ethtool_sset(phydev, cmd); +} + +static const struct ethtool_ops lpc_eth_ethtool_ops = { + .get_drvinfo = lpc_eth_ethtool_getdrvinfo, + .get_settings = lpc_eth_ethtool_getsettings, + .set_settings = lpc_eth_ethtool_setsettings, + .get_msglevel = lpc_eth_ethtool_getmsglevel, + .set_msglevel = lpc_eth_ethtool_setmsglevel, + .get_link = ethtool_op_get_link, +}; + +static const struct net_device_ops lpc_netdev_ops = { + .ndo_open = lpc_eth_open, + .ndo_stop = lpc_eth_close, + .ndo_start_xmit = lpc_eth_hard_start_xmit, + .ndo_set_rx_mode = lpc_eth_set_multicast_list, + .ndo_do_ioctl = lpc_eth_ioctl, + .ndo_set_mac_address = lpc_set_mac_address, +}; + +static int lpc_eth_drv_probe(struct platform_device *pdev) +{ + struct resource *res; + struct resource *dma_res; + struct net_device *ndev; + struct netdata_local *pldat; + struct phy_device *phydev; + dma_addr_t dma_handle; + int irq, ret; + + /* Get platform resources */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + dma_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + irq = platform_get_irq(pdev, 0); + if ((!res) || (!dma_res) || (irq < 0) || (irq >= NR_IRQS)) { + dev_err(&pdev->dev, "error getting resources.\n"); + ret = -ENXIO; + goto err_exit; + } + + /* Allocate net driver data structure */ + ndev = alloc_etherdev(sizeof(struct netdata_local)); + if (!ndev) { + dev_err(&pdev->dev, "could not allocate device.\n"); + ret = -ENOMEM; + goto err_exit; + } + + SET_NETDEV_DEV(ndev, &pdev->dev); + + pldat = netdev_priv(ndev); + pldat->pdev = pdev; + pldat->ndev = ndev; + + spin_lock_init(&pldat->lock); + + /* Save resources */ + ndev->irq = irq; + + /* Get clock for the device */ + pldat->clk = clk_get(&pdev->dev, NULL); + if (IS_ERR(pldat->clk)) { + dev_err(&pdev->dev, "error getting clock.\n"); + ret = PTR_ERR(pldat->clk); + goto err_out_free_dev; + } + + /* Enable network clock */ + __lpc_eth_clock_enable(pldat, true); + + /* Map IO space */ + pldat->net_base = ioremap(res->start, res->end - res->start + 1); + if (!pldat->net_base) { + dev_err(&pdev->dev, "failed to map registers\n"); + ret = -ENOMEM; + goto err_out_disable_clocks; + } + ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0, + ndev->name, ndev); + if (ret) { + dev_err(&pdev->dev, "error requesting interrupt.\n"); + goto err_out_iounmap; + } + + /* Fill in the fields of the device structure with ethernet values. */ + ether_setup(ndev); + + /* Setup driver functions */ + ndev->netdev_ops = &lpc_netdev_ops; + ndev->ethtool_ops = &lpc_eth_ethtool_ops; + ndev->watchdog_timeo = msecs_to_jiffies(2500); + + /* Get size of DMA buffers/descriptors region */ + pldat->dma_buff_size = (ENET_TX_DESC + ENET_RX_DESC) * (ENET_MAXF_SIZE + + sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t)); + pldat->dma_buff_base_v = 0; + + if (use_iram_for_net()) { + dma_handle = dma_res->start; + if (pldat->dma_buff_size <= lpc32xx_return_iram_size()) + pldat->dma_buff_base_v = + io_p2v(dma_res->start); + else + netdev_err(ndev, + "IRAM not big enough for net buffers, using SDRAM instead.\n"); + } + + if (pldat->dma_buff_base_v == 0) { + pldat->dma_buff_size = PAGE_ALIGN(pldat->dma_buff_size); + + /* Allocate a chunk of memory for the DMA ethernet buffers + and descriptors */ + pldat->dma_buff_base_v = + dma_alloc_coherent(&pldat->pdev->dev, + pldat->dma_buff_size, &dma_handle, + GFP_KERNEL); + + if (pldat->dma_buff_base_v == NULL) { + dev_err(&pdev->dev, "error getting DMA region.\n"); + ret = -ENOMEM; + goto err_out_free_irq; + } + } + pldat->dma_buff_base_p = dma_handle; + + netdev_dbg(ndev, "IO address start :0x%08x\n", + res->start); + netdev_dbg(ndev, "IO address size :%d\n", + res->end - res->start + 1); + netdev_err(ndev, "IO address (mapped) :0x%p\n", + pldat->net_base); + netdev_dbg(ndev, "IRQ number :%d\n", ndev->irq); + netdev_dbg(ndev, "DMA buffer size :%d\n", pldat->dma_buff_size); + netdev_dbg(ndev, "DMA buffer P address :0x%08x\n", + pldat->dma_buff_base_p); + netdev_dbg(ndev, "DMA buffer V address :0x%p\n", + pldat->dma_buff_base_v); + + /* Get MAC address from current HW setting (POR state is all zeros) */ + __lpc_get_mac(pldat, ndev->dev_addr); + +#ifdef CONFIG_OF_NET + if (!is_valid_ether_addr(ndev->dev_addr)) { + const char *macaddr = of_get_mac_address(pdev->dev.of_node); + if (macaddr) + memcpy(ndev->dev_addr, macaddr, ETH_ALEN); + } +#endif + if (!is_valid_ether_addr(ndev->dev_addr)) + dev_hw_addr_random(ndev, ndev->dev_addr); + + /* Reset the ethernet controller */ + __lpc_eth_reset(pldat); + + /* then shut everything down to save power */ + __lpc_eth_shutdown(pldat); + + /* Set default parameters */ + pldat->msg_enable = NETIF_MSG_LINK; + + /* Force an MII interface reset and clock setup */ + __lpc_mii_mngt_reset(pldat); + + /* Force default PHY interface setup in chip, this will probably be + changed by the PHY driver */ + pldat->link = 0; + pldat->speed = 100; + pldat->duplex = DUPLEX_FULL; + __lpc_params_setup(pldat); + + netif_napi_add(ndev, &pldat->napi, lpc_eth_poll, NAPI_WEIGHT); + + ret = register_netdev(ndev); + if (ret) { + dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); + goto err_out_dma_unmap; + } + platform_set_drvdata(pdev, ndev); + + if (lpc_mii_init(pldat) != 0) + goto err_out_unregister_netdev; + + netdev_info(ndev, "LPC mac at 0x%08x irq %d\n", + res->start, ndev->irq); + + phydev = pldat->phy_dev; + + device_init_wakeup(&pdev->dev, 1); + device_set_wakeup_enable(&pdev->dev, 0); + + return 0; + +err_out_unregister_netdev: + platform_set_drvdata(pdev, NULL); + unregister_netdev(ndev); +err_out_dma_unmap: + if (!use_iram_for_net() || + pldat->dma_buff_size > lpc32xx_return_iram_size()) + dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size, + pldat->dma_buff_base_v, + pldat->dma_buff_base_p); +err_out_free_irq: + free_irq(ndev->irq, ndev); +err_out_iounmap: + iounmap(pldat->net_base); +err_out_disable_clocks: + clk_disable(pldat->clk); + clk_put(pldat->clk); +err_out_free_dev: + free_netdev(ndev); +err_exit: + pr_err("%s: not found (%d).\n", MODNAME, ret); + return ret; +} + +static int lpc_eth_drv_remove(struct platform_device *pdev) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct netdata_local *pldat = netdev_priv(ndev); + + unregister_netdev(ndev); + platform_set_drvdata(pdev, NULL); + + if (!use_iram_for_net() || + pldat->dma_buff_size > lpc32xx_return_iram_size()) + dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size, + pldat->dma_buff_base_v, + pldat->dma_buff_base_p); + free_irq(ndev->irq, ndev); + iounmap(pldat->net_base); + mdiobus_free(pldat->mii_bus); + clk_disable(pldat->clk); + clk_put(pldat->clk); + free_netdev(ndev); + + return 0; +} + +#ifdef CONFIG_PM +static int lpc_eth_drv_suspend(struct platform_device *pdev, + pm_message_t state) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct netdata_local *pldat = netdev_priv(ndev); + + if (device_may_wakeup(&pdev->dev)) + enable_irq_wake(ndev->irq); + + if (ndev) { + if (netif_running(ndev)) { + netif_device_detach(ndev); + __lpc_eth_shutdown(pldat); + clk_disable(pldat->clk); + + /* + * Reset again now clock is disable to be sure + * EMC_MDC is down + */ + __lpc_eth_reset(pldat); + } + } + + return 0; +} + +static int lpc_eth_drv_resume(struct platform_device *pdev) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct netdata_local *pldat; + + if (device_may_wakeup(&pdev->dev)) + disable_irq_wake(ndev->irq); + + if (ndev) { + if (netif_running(ndev)) { + pldat = netdev_priv(ndev); + + /* Enable interface clock */ + clk_enable(pldat->clk); + + /* Reset and initialize */ + __lpc_eth_reset(pldat); + __lpc_eth_init(pldat); + + netif_device_attach(ndev); + } + } + + return 0; +} +#endif + +static struct platform_driver lpc_eth_driver = { + .probe = lpc_eth_drv_probe, + .remove = __devexit_p(lpc_eth_drv_remove), +#ifdef CONFIG_PM + .suspend = lpc_eth_drv_suspend, + .resume = lpc_eth_drv_resume, +#endif + .driver = { + .name = MODNAME, + }, +}; + +module_platform_driver(lpc_eth_driver); + +MODULE_AUTHOR("Kevin Wells "); +MODULE_AUTHOR("Roland Stigge "); +MODULE_DESCRIPTION("LPC Ethernet Driver"); +MODULE_LICENSE("GPL"); -- GitLab From 0a52fd019625867e766c0f6126b7a15b709f83ec Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:07 +0000 Subject: [PATCH 1684/1846] bnx2x: move LLH_CAM to header, apply naming conventions These definitions are united into the header. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 13 ++++--------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 7 +++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index adfae6bb430b..f7896c2097e4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -611,12 +611,6 @@ static inline u8 bnx2x_vlan_mac_get_rx_tx_flag(struct bnx2x_vlan_mac_obj *o) return rx_tx_flag; } -/* LLH CAM line allocations */ -enum { - LLH_CAM_ISCSI_ETH_LINE = 0, - LLH_CAM_ETH_LINE, - LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2 -}; static inline void bnx2x_set_mac_in_nig(struct bnx2x *bp, bool add, unsigned char *dev_addr, int index) @@ -625,7 +619,7 @@ static inline void bnx2x_set_mac_in_nig(struct bnx2x *bp, u32 reg_offset = BP_PORT(bp) ? NIG_REG_LLH1_FUNC_MEM : NIG_REG_LLH0_FUNC_MEM; - if (!IS_MF_SI(bp) || index > LLH_CAM_MAX_PF_LINE) + if (!IS_MF_SI(bp) || index > BNX2X_LLH_CAM_MAX_PF_LINE) return; DP(BNX2X_MSG_SP, "Going to %s LLH configuration at entry %d\n", @@ -731,9 +725,10 @@ static void bnx2x_set_one_mac_e2(struct bnx2x *bp, if (cmd != BNX2X_VLAN_MAC_MOVE) { if (test_bit(BNX2X_ISCSI_ETH_MAC, vlan_mac_flags)) bnx2x_set_mac_in_nig(bp, add, mac, - LLH_CAM_ISCSI_ETH_LINE); + BNX2X_LLH_CAM_ISCSI_ETH_LINE); else if (test_bit(BNX2X_ETH_MAC, vlan_mac_flags)) - bnx2x_set_mac_in_nig(bp, add, mac, LLH_CAM_ETH_LINE); + bnx2x_set_mac_in_nig(bp, add, mac, + BNX2X_LLH_CAM_ETH_LINE); } /* Reset the ramrod data buffer for the first rule */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h index 685d42e1b2fc..0be63e70ea51 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h @@ -423,6 +423,13 @@ struct bnx2x_vlan_mac_obj { int (*wait)(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o); }; +enum { + BNX2X_LLH_CAM_ISCSI_ETH_LINE = 0, + BNX2X_LLH_CAM_ETH_LINE, + BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2 +}; + + /** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */ /* RX_MODE ramrod spesial flags: set in rx_mode_flags field in -- GitLab From c121089d9769a404468749b31c52c4d284cb56be Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:08 +0000 Subject: [PATCH 1685/1846] bnx2x: removed unused function bnx2x_queue_set_cos_cid Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index f7896c2097e4..2b18ccd1e739 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -5181,13 +5181,6 @@ void bnx2x_init_queue_obj(struct bnx2x *bp, obj->set_pending = bnx2x_queue_set_pending; } -void bnx2x_queue_set_cos_cid(struct bnx2x *bp, - struct bnx2x_queue_sp_obj *obj, - u32 cid, u8 index) -{ - obj->cids[index] = cid; -} - /********************** Function state object *********************************/ enum bnx2x_func_state bnx2x_func_get_state(struct bnx2x *bp, struct bnx2x_func_sp_obj *o) -- GitLab From 33ac338cf97f5e225c62ebcb3ff1a40bf32c88ad Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:09 +0000 Subject: [PATCH 1686/1846] bnx2x: set_one_mac_e1x uses raw's state as input Previously, we used a hard-coded value as paramater, instead of using the input's value. This is now remedied, as in other flows. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 2b18ccd1e739..f913cdd17283 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -864,7 +864,7 @@ static void bnx2x_set_one_mac_e1x(struct bnx2x *bp, /* Reset the ramrod data buffer */ memset(config, 0, sizeof(*config)); - bnx2x_vlan_mac_set_rdata_e1x(bp, o, BNX2X_FILTER_MAC_PENDING, + bnx2x_vlan_mac_set_rdata_e1x(bp, o, raw->state, cam_offset, add, elem->cmd_data.vlan_mac.u.mac.mac, 0, ETH_VLAN_FILTER_ANY_VLAN, config); -- GitLab From 259afa1f725dc7ec1626835b9ac54827a46cdf80 Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:10 +0000 Subject: [PATCH 1687/1846] bnx2x: use param's id instead of sp_obj's id Previously, we've used the object's function id instead of using the input's value. This is remedied, as in other flows. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index b4afef60a25b..bf14a08f0796 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -2800,6 +2800,7 @@ static void bnx2x_pf_rx_q_prep(struct bnx2x *bp, rxq_init->sge_buf_sz = sge_sz; rxq_init->max_sges_pkt = max_sge; rxq_init->rss_engine_id = BP_FUNC(bp); + rxq_init->mcast_engine_id = BP_FUNC(bp); /* Maximum number or simultaneous TPA aggregation for this Queue. * diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index f913cdd17283..1999fa58704d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -4473,7 +4473,7 @@ static void bnx2x_q_fill_init_rx_data(struct bnx2x_queue_sp_obj *o, rx_data->is_leading_rss = test_bit(BNX2X_Q_FLG_LEADING_RSS, flags); if (test_bit(BNX2X_Q_FLG_MCAST, flags)) { - rx_data->approx_mcast_engine_id = o->func_id; + rx_data->approx_mcast_engine_id = params->mcast_engine_id; rx_data->is_approx_mcast = 1; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h index 0be63e70ea51..4ce351b4d517 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h @@ -897,6 +897,9 @@ struct bnx2x_rxq_setup_params { u8 max_tpa_queues; u8 rss_engine_id; + /* valid iff BNX2X_Q_FLG_MCAST */ + u8 mcast_engine_id; + u8 cache_line_log; u8 sb_cq_index; -- GitLab From 9ce392d4fa43c3abb9ab02a29e225084ed84451e Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:11 +0000 Subject: [PATCH 1688/1846] bnx2x: mark functions as loaded on shared memory This change enables the FW to make more accurate decisions regarding the active functions. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index f82dfff58243..c11e50d328c4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -2007,6 +2007,15 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); #endif + /* mark driver is loaded in shmem2 */ + if (SHMEM2_HAS(bp, drv_capabilities_flag)) { + u32 val; + val = SHMEM2_RD(bp, drv_capabilities_flag[BP_FW_MB_IDX(bp)]); + SHMEM2_WR(bp, drv_capabilities_flag[BP_FW_MB_IDX(bp)], + val | DRV_FLAGS_CAPABILITIES_LOADED_SUPPORTED | + DRV_FLAGS_CAPABILITIES_LOADED_L2); + } + /* Wait for all pending SP commands to complete */ if (!bnx2x_wait_sp_comp(bp, ~0x0UL)) { BNX2X_ERR("Timeout waiting for SP elements to complete\n"); @@ -2060,6 +2069,14 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) int i; bool global = false; + /* mark driver is unloaded in shmem2 */ + if (SHMEM2_HAS(bp, drv_capabilities_flag)) { + u32 val; + val = SHMEM2_RD(bp, drv_capabilities_flag[BP_FW_MB_IDX(bp)]); + SHMEM2_WR(bp, drv_capabilities_flag[BP_FW_MB_IDX(bp)], + val & ~DRV_FLAGS_CAPABILITIES_LOADED_L2); + } + if ((bp->state == BNX2X_STATE_CLOSED) || (bp->state == BNX2X_STATE_ERROR)) { /* We can get here if the driver has been unloaded -- GitLab From 382984618e847ad4621d7ccbd48f5ec702c6a78e Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:12 +0000 Subject: [PATCH 1689/1846] bnx2x: ethtool now returns unknown speed/duplex Previously, unless both interface and link were up, ethtool returned the requested speed/duplex when asked for the interface's settings. This change will now enable the driver to answer correctly (i.e., return unknown as its answer). Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 9c24d536edef..8f8421d4dfff 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -222,20 +222,23 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) (SUPPORTED_TP | SUPPORTED_FIBRE)); cmd->advertising = bp->port.advertising[cfg_idx]; - if ((bp->state == BNX2X_STATE_OPEN) && - !(bp->flags & MF_FUNC_DIS) && - (bp->link_vars.link_up)) { - ethtool_cmd_speed_set(cmd, bp->link_vars.line_speed); - cmd->duplex = bp->link_vars.duplex; + if ((bp->state == BNX2X_STATE_OPEN) && (bp->link_vars.link_up)) { + if (!(bp->flags & MF_FUNC_DIS)) { + ethtool_cmd_speed_set(cmd, bp->link_vars.line_speed); + cmd->duplex = bp->link_vars.duplex; + } else { + ethtool_cmd_speed_set( + cmd, bp->link_params.req_line_speed[cfg_idx]); + cmd->duplex = bp->link_params.req_duplex[cfg_idx]; + } + + if (IS_MF(bp) && !BP_NOMCP(bp)) + ethtool_cmd_speed_set(cmd, bnx2x_get_mf_speed(bp)); } else { - ethtool_cmd_speed_set( - cmd, bp->link_params.req_line_speed[cfg_idx]); - cmd->duplex = bp->link_params.req_duplex[cfg_idx]; + cmd->duplex = DUPLEX_UNKNOWN; + ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN); } - if (IS_MF(bp)) - ethtool_cmd_speed_set(cmd, bnx2x_get_mf_speed(bp)); - cmd->port = bnx2x_get_port_type(bp); cmd->phy_address = bp->mdio.prtad; @@ -309,6 +312,10 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) speed = ethtool_cmd_speed(cmd); + /* If recieved a request for an unknown duplex, assume full*/ + if (cmd->duplex == DUPLEX_UNKNOWN) + cmd->duplex = DUPLEX_FULL; + if (IS_MF_SI(bp)) { u32 part; u32 line_speed = bp->link_vars.line_speed; -- GitLab From 241fb5d2b4205a523a50a85f9c312e1eda8ec53d Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Mon, 12 Mar 2012 08:53:13 +0000 Subject: [PATCH 1690/1846] bnx2x: ethtool returns req. AN even when AN fails Previously, if autoneg failed, ethtool would return the achieved autoneg. This patch corrects this, causing ethtool to return the requested autoneg capabilities even if autoneg fails. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 8f8421d4dfff..858d1b5433de 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -1450,7 +1450,7 @@ static void bnx2x_get_pauseparam(struct net_device *dev, BNX2X_FLOW_CTRL_AUTO); if (!epause->autoneg) - cfg_reg = bp->link_vars.flow_ctrl; + cfg_reg = bp->link_params.req_flow_ctrl[cfg_idx]; else cfg_reg = bp->link_params.req_fc_auto_adv; -- GitLab From f124488e4713dc9afa2028553261b1d399286e68 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Mon, 12 Mar 2012 08:53:14 +0000 Subject: [PATCH 1691/1846] bnx2x: code doesn't use stats for allocating Rx BDs Previously, allocation used queue statistics directly in its calcualtion. This change causes these calculations to be summed into the statistics, without being affected by them. Signed-off-by: Dmitry Kravkov Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 33aa7de24016..cc02ae51a30d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1143,7 +1143,7 @@ static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp, { struct bnx2x *bp = fp->bp; u16 ring_prod, cqe_ring_prod; - int i; + int i, failure_cnt = 0; fp->rx_comp_cons = 0; cqe_ring_prod = ring_prod = 0; @@ -1153,18 +1153,17 @@ static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp, */ for (i = 0; i < rx_ring_size; i++) { if (bnx2x_alloc_rx_data(bp, fp, ring_prod) < 0) { - fp->eth_q_stats.rx_skb_alloc_failed++; + failure_cnt++; continue; } ring_prod = NEXT_RX_IDX(ring_prod); cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod); - WARN_ON(ring_prod <= (i - fp->eth_q_stats.rx_skb_alloc_failed)); + WARN_ON(ring_prod <= (i - failure_cnt)); } - if (fp->eth_q_stats.rx_skb_alloc_failed) - BNX2X_ERR("was only able to allocate " - "%d rx skbs on queue[%d]\n", - (i - fp->eth_q_stats.rx_skb_alloc_failed), fp->index); + if (failure_cnt) + BNX2X_ERR("was only able to allocate %d rx skbs on queue[%d]\n", + i - failure_cnt, fp->index); fp->rx_bd_prod = ring_prod; /* Limit the CQE producer by the CQE ring size */ @@ -1172,7 +1171,9 @@ static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp, cqe_ring_prod); fp->rx_pkt = fp->rx_calls = 0; - return i - fp->eth_q_stats.rx_skb_alloc_failed; + fp->eth_q_stats.rx_skb_alloc_failed += failure_cnt; + + return i - failure_cnt; } /* Statistics ID are global per chip/path, while Client IDs for E1x are per -- GitLab From 51a76c30929cc8b7d541f51e634f146e54ea9bb7 Mon Sep 17 00:00:00 2001 From: Jeff Kirsher Date: Thu, 19 Jan 2012 18:31:34 +0000 Subject: [PATCH 1692/1846] igb: fix ethtool offline test A bug was introduced with the following patch: Commmit bdbc063129e811264cd6c311d8c2d9b95de01231 Author: Eric Dumazet igb: Add support for byte queue limits. The ethtool offline tests will cause a perpetual link flap, this is because the tests also need to account for byte queue limits (BQL). CC: Eric Dumazet Signed-off-by: Jeff Kirsher Signed-off-by: John Fastabend Tested-by: Jeff Pieper --- drivers/net/ethernet/intel/igb/igb_ethtool.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index aa399a8a8f0d..e10821a0f249 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -1577,7 +1577,9 @@ static int igb_clean_test_rings(struct igb_ring *rx_ring, union e1000_adv_rx_desc *rx_desc; struct igb_rx_buffer *rx_buffer_info; struct igb_tx_buffer *tx_buffer_info; + struct netdev_queue *txq; u16 rx_ntc, tx_ntc, count = 0; + unsigned int total_bytes = 0, total_packets = 0; /* initialize next to clean and descriptor values */ rx_ntc = rx_ring->next_to_clean; @@ -1601,6 +1603,8 @@ static int igb_clean_test_rings(struct igb_ring *rx_ring, /* unmap buffer on tx side */ tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc]; + total_bytes += tx_buffer_info->bytecount; + total_packets += tx_buffer_info->gso_segs; igb_unmap_and_free_tx_resource(tx_ring, tx_buffer_info); /* increment rx/tx next to clean counters */ @@ -1615,6 +1619,9 @@ static int igb_clean_test_rings(struct igb_ring *rx_ring, rx_desc = IGB_RX_DESC(rx_ring, rx_ntc); } + txq = netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index); + netdev_tx_completed_queue(txq, total_packets, total_bytes); + /* re-map buffers to ring, store next to clean values */ igb_alloc_rx_buffers(rx_ring, count); rx_ring->next_to_clean = rx_ntc; -- GitLab From 35551c47495a762fcfa5ca6217bf3eb36983d0df Mon Sep 17 00:00:00 2001 From: Jeff Kirsher Date: Fri, 23 Sep 2011 15:34:38 +0000 Subject: [PATCH 1693/1846] ixgbe: remove tie between NAPI work limits and interrupt moderation As noted by Ben Hutchings and David Miller, work limits for NAPI should not be tied to interrupt moderation parameters. This should be handled by NAPI, possibly through sysfs. Neil Horman & Stephen Hemminger are working on a solution for NAPI currently. In the meantime, remove this tie between work limits and interrupt moderation. Signed-off-by: Jeff Kirsher CC: Ben Hutchings Tested-by: Phil Schmitt --- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 8e2e4732b1a7..4846206a1014 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -2108,8 +2108,6 @@ static int ixgbe_get_coalesce(struct net_device *netdev, { struct ixgbe_adapter *adapter = netdev_priv(netdev); - ec->tx_max_coalesced_frames_irq = adapter->tx_work_limit; - /* only valid if in constant ITR mode */ if (adapter->rx_itr_setting <= 1) ec->rx_coalesce_usecs = adapter->rx_itr_setting; @@ -2177,9 +2175,6 @@ static int ixgbe_set_coalesce(struct net_device *netdev, && ec->tx_coalesce_usecs) return -EINVAL; - if (ec->tx_max_coalesced_frames_irq) - adapter->tx_work_limit = ec->tx_max_coalesced_frames_irq; - if ((ec->rx_coalesce_usecs > (IXGBE_MAX_EITR >> 2)) || (ec->tx_coalesce_usecs > (IXGBE_MAX_EITR >> 2))) return -EINVAL; @@ -2214,7 +2209,6 @@ static int ixgbe_set_coalesce(struct net_device *netdev, for (i = 0; i < num_vectors; i++) { q_vector = adapter->q_vector[i]; - q_vector->tx.work_limit = adapter->tx_work_limit; if (q_vector->tx.count && !q_vector->rx.count) /* tx only */ q_vector->itr = tx_itr_param; -- GitLab From b2d96e0ac07cf4929c6b0eb13121672048368117 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 7 Feb 2012 08:14:33 +0000 Subject: [PATCH 1694/1846] ixgbe: add support for byte queue limits This adds support for byte queue limits (BQL). Based on patch from Eric Dumazet for igb. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 5 +++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 2807a25e04e6..f05bfdbf2f32 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -643,4 +643,9 @@ extern int ixgbe_fcoe_get_hbainfo(struct net_device *netdev, struct netdev_fcoe_hbainfo *info); #endif /* IXGBE_FCOE */ +static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring) +{ + return netdev_get_tx_queue(ring->netdev, ring->queue_index); +} + #endif /* _IXGBE_H_ */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 23a466530a04..060964378e58 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -840,6 +840,9 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, return true; } + netdev_tx_completed_queue(txring_txq(tx_ring), + total_packets, total_bytes); + #define TX_WAKE_THRESHOLD (DESC_NEEDED * 2) if (unlikely(total_packets && netif_carrier_ok(tx_ring->netdev) && (ixgbe_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD))) { @@ -2617,6 +2620,8 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, /* enable queue */ IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(reg_idx), txdctl); + netdev_tx_reset_queue(txring_txq(ring)); + /* TXDCTL.EN will return 0 on 82598 if link is down, so skip it */ if (hw->mac.type == ixgbe_mac_82598EB && !(IXGBE_READ_REG(hw, IXGBE_LINKS) & IXGBE_LINKS_UP)) @@ -6808,6 +6813,8 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, tx_buffer_info->gso_segs = gso_segs; tx_buffer_info->skb = skb; + netdev_tx_sent_queue(txring_txq(tx_ring), tx_buffer_info->bytecount); + /* set the timestamp */ first->time_stamp = jiffies; -- GitLab From 5c4903549c05bbb373479e0ce2992573c120654a Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 7 Feb 2012 02:29:01 +0000 Subject: [PATCH 1695/1846] net: Fix issue with netdev_tx_reset_queue not resetting queue from XOFF state We are seeing dev_watchdog hangs on several drivers. I suspect this is due to the __QUEUE_STATE_STACK_XOFF bit being set prior to a reset for link change, and then not being cleared by netdev_tx_reset_queue. This change corrects that. In addition we were seeing dev_watchdog hangs on igb after running the ethtool tests. We found this to be due to the fact that the ethtool test runs the same logic as ndo_start_xmit, but we were never clearing the XOFF flag since the loopback test in ethtool does not do byte queue accounting. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/igb/igb_main.c | 3 ++- include/linux/netdevice.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index fda824735e18..e96cef89f121 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2752,6 +2752,8 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, txdctl |= E1000_TXDCTL_QUEUE_ENABLE; wr32(E1000_TXDCTL(reg_idx), txdctl); + + netdev_tx_reset_queue(txring_txq(ring)); } /** @@ -3244,7 +3246,6 @@ static void igb_clean_tx_ring(struct igb_ring *tx_ring) buffer_info = &tx_ring->tx_buffer_info[i]; igb_unmap_and_free_tx_resource(tx_ring, buffer_info); } - netdev_tx_reset_queue(txring_txq(tx_ring)); size = sizeof(struct igb_tx_buffer) * tx_ring->count; memset(tx_ring->tx_buffer_info, 0, size); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b195a34440bb..4bf314fe2145 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1939,6 +1939,7 @@ static inline void netdev_completed_queue(struct net_device *dev, static inline void netdev_tx_reset_queue(struct netdev_queue *q) { #ifdef CONFIG_BQL + clear_bit(__QUEUE_STATE_STACK_XOFF, &q->state); dql_reset(&q->dql); #endif } -- GitLab From b37c0fbe3f6dfba1f8ad2aed47fb40578a254635 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Tue, 7 Feb 2012 02:29:06 +0000 Subject: [PATCH 1696/1846] net: Add memory barriers to prevent possible race in byte queue limits This change adds a memory barrier to the byte queue limit code to address a possible race as has been seen in the past with the netif_stop_queue/netif_wake_queue logic. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- include/linux/netdevice.h | 49 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 4bf314fe2145..4535a4ea9760 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1899,12 +1899,22 @@ static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue, { #ifdef CONFIG_BQL dql_queued(&dev_queue->dql, bytes); - if (unlikely(dql_avail(&dev_queue->dql) < 0)) { - set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state); - if (unlikely(dql_avail(&dev_queue->dql) >= 0)) - clear_bit(__QUEUE_STATE_STACK_XOFF, - &dev_queue->state); - } + + if (likely(dql_avail(&dev_queue->dql) >= 0)) + return; + + set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state); + + /* + * The XOFF flag must be set before checking the dql_avail below, + * because in netdev_tx_completed_queue we update the dql_completed + * before checking the XOFF flag. + */ + smp_mb(); + + /* check again in case another CPU has just made room avail */ + if (unlikely(dql_avail(&dev_queue->dql) >= 0)) + clear_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state); #endif } @@ -1917,16 +1927,23 @@ static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue, unsigned pkts, unsigned bytes) { #ifdef CONFIG_BQL - if (likely(bytes)) { - dql_completed(&dev_queue->dql, bytes); - if (unlikely(test_bit(__QUEUE_STATE_STACK_XOFF, - &dev_queue->state) && - dql_avail(&dev_queue->dql) >= 0)) { - if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF, - &dev_queue->state)) - netif_schedule_queue(dev_queue); - } - } + if (unlikely(!bytes)) + return; + + dql_completed(&dev_queue->dql, bytes); + + /* + * Without the memory barrier there is a small possiblity that + * netdev_tx_sent_queue will miss the update and cause the queue to + * be stopped forever + */ + smp_mb(); + + if (dql_avail(&dev_queue->dql) < 0) + return; + + if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state)) + netif_schedule_queue(dev_queue); #endif } -- GitLab From 7f83a9e6292b49d1540f82f295ac8710ba562c5f Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:23 +0000 Subject: [PATCH 1697/1846] ixgbe: Do no clear Tx status bits since eop_desc provides enough info There isn't any need to clear the status bits in the descriptors due to the fact that the eop_desc provides enough information for us to know that we have cleaned to the last packet that the software has put on the ring. The status bits are cleared as a part of putting the frame on the ring so as long as we do not read the descriptor bit prior to reading the value eop_desc we should be able to guarantee that we will not clean beyond the end of the current data stream. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 060964378e58..a2c14bfd4b3f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -763,6 +763,9 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, if (!eop_desc) break; + /* prevent any other reads prior to eop_desc */ + rmb(); + /* if DD is not set pending work has not been completed */ if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD))) break; @@ -773,12 +776,8 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, /* clear next_to_watch to prevent false hangs */ tx_buffer->next_to_watch = NULL; - /* prevent any other reads prior to eop_desc being verified */ - rmb(); - do { ixgbe_unmap_tx_resource(tx_ring, tx_buffer); - tx_desc->wb.status = 0; if (likely(tx_desc == eop_desc)) { eop_desc = NULL; dev_kfree_skb_any(tx_buffer->skb); -- GitLab From 46646e61ea068b11758e8ffed3f4db300323dfc6 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:28 +0000 Subject: [PATCH 1698/1846] ixgbe: Reorder adapter contents for better cache utilization This change moves several frequently accessed items together into one cache line in order to reduce cache misses in the hot-path. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 94 ++++++++++++------------ 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index f05bfdbf2f32..c5cd2b678b44 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -373,8 +373,16 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring) #define MIN_MSIX_Q_VECTORS 2 #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS) +/* default to trying for four seconds */ +#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ) + /* board specific private data structure */ struct ixgbe_adapter { + unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; + /* OS defined structs */ + struct net_device *netdev; + struct pci_dev *pdev; + unsigned long state; /* Some features need tri-state capability, @@ -418,59 +426,50 @@ struct ixgbe_adapter { #define IXGBE_FLAG2_RESET_REQUESTED (u32)(1 << 6) #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT (u32)(1 << 7) - unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; - u16 bd_number; - struct ixgbe_q_vector *q_vector[MAX_MSIX_Q_VECTORS]; - /* DCB parameters */ - struct ieee_pfc *ixgbe_ieee_pfc; - struct ieee_ets *ixgbe_ieee_ets; - struct ixgbe_dcb_config dcb_cfg; - struct ixgbe_dcb_config temp_dcb_cfg; - u8 dcb_set_bitmap; - u8 dcbx_cap; - enum ixgbe_fc_mode last_lfc_mode; - - /* Interrupt Throttle Rate */ - u32 rx_itr_setting; - u32 tx_itr_setting; - u16 eitr_low; - u16 eitr_high; - - /* Work limits */ + /* Tx fast path data */ + int num_tx_queues; + u16 tx_itr_setting; u16 tx_work_limit; + /* Rx fast path data */ + int num_rx_queues; + u16 rx_itr_setting; + /* TX */ struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp; - int num_tx_queues; - u32 tx_timeout_count; - bool detect_tx_hung; u64 restart_queue; u64 lsc_int; + u32 tx_timeout_count; /* RX */ - struct ixgbe_ring *rx_ring[MAX_RX_QUEUES] ____cacheline_aligned_in_smp; - int num_rx_queues; + struct ixgbe_ring *rx_ring[MAX_RX_QUEUES]; int num_rx_pools; /* == num_rx_queues in 82598 */ int num_rx_queues_per_pool; /* 1 if 82598, can be many if 82599 */ u64 hw_csum_rx_error; u64 hw_rx_no_dma_resources; + u64 rsc_total_count; + u64 rsc_total_flush; u64 non_eop_descs; - int num_msix_vectors; - int max_msix_q_vectors; /* true count of q_vectors for device */ - struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE]; - struct msix_entry *msix_entries; - u32 alloc_rx_page_failed; u32 alloc_rx_buff_failed; -/* default to trying for four seconds */ -#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ) + struct ixgbe_q_vector *q_vector[MAX_MSIX_Q_VECTORS]; - /* OS defined structs */ - struct net_device *netdev; - struct pci_dev *pdev; + /* DCB parameters */ + struct ieee_pfc *ixgbe_ieee_pfc; + struct ieee_ets *ixgbe_ieee_ets; + struct ixgbe_dcb_config dcb_cfg; + struct ixgbe_dcb_config temp_dcb_cfg; + u8 dcb_set_bitmap; + u8 dcbx_cap; + enum ixgbe_fc_mode last_lfc_mode; + + int num_msix_vectors; + int max_msix_q_vectors; /* true count of q_vectors for device */ + struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE]; + struct msix_entry *msix_entries; u32 test_icr; struct ixgbe_ring test_tx_ring; @@ -481,10 +480,6 @@ struct ixgbe_adapter { u16 msg_enable; struct ixgbe_hw_stats stats; - /* Interrupt Throttle Rate */ - u32 rx_eitr_param; - u32 tx_eitr_param; - u64 tx_busy; unsigned int tx_ring_count; unsigned int rx_ring_count; @@ -493,25 +488,35 @@ struct ixgbe_adapter { bool link_up; unsigned long link_check_timeout; - struct work_struct service_task; struct timer_list service_timer; + struct work_struct service_task; + + struct hlist_head fdir_filter_list; + unsigned long fdir_overflow; /* number of times ATR was backed off */ + union ixgbe_atr_input fdir_mask; + int fdir_filter_count; u32 fdir_pballoc; u32 atr_sample_rate; - unsigned long fdir_overflow; /* number of times ATR was backed off */ spinlock_t fdir_perfect_lock; + #ifdef IXGBE_FCOE struct ixgbe_fcoe fcoe; #endif /* IXGBE_FCOE */ - u64 rsc_total_count; - u64 rsc_total_flush; u32 wol; + + /* Interrupt Throttle Rate */ + u16 eitr_low; + u16 eitr_high; + + u16 bd_number; + u16 eeprom_verh; u16 eeprom_verl; u16 eeprom_cap; int node; - u32 led_reg; u32 interrupt_event; + u32 led_reg; /* SR-IOV */ DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS); @@ -521,9 +526,6 @@ struct ixgbe_adapter { struct vf_macvlans vf_mvs; struct vf_macvlans *mv_list; - struct hlist_head fdir_filter_list; - union ixgbe_atr_input fdir_mask; - int fdir_filter_count; u32 timer_event_accumulator; u32 vferr_refcount; }; -- GitLab From e954b374b4e42c5335679ec6d79ca2c50ce5d422 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:38 +0000 Subject: [PATCH 1699/1846] ixgbe: Address issues with Tx WHTRESH value not being set correctly This change is meant to address the fact that the tx_itr_setting was dropping to 0 when no separate Tx vectors were provided. This had resulted in the driver incorrectly configuring the Tx ring with a WTHRESH of 1 in order to avoid Tx hangs even though that was not necessary. This change makes it so that we instead take a look at the Tx ring's q_vector to determine if the ring will have an ITR value less than 8us. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index a2c14bfd4b3f..fc3c33a2c205 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2595,12 +2595,15 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, * to or less than the number of on chip descriptors, which is * currently 40. */ - if (!adapter->tx_itr_setting || !adapter->rx_itr_setting) + if (!ring->q_vector || (ring->q_vector->itr < 8)) txdctl |= (1 << 16); /* WTHRESH = 1 */ else txdctl |= (8 << 16); /* WTHRESH = 8 */ - /* PTHRESH=32 is needed to avoid a Tx hang with DFP enabled. */ + /* + * Setting PTHRESH to 32 both improves performance + * and avoids a TX hang with DFP enabled + */ txdctl |= (1 << 8) | /* HTHRESH = 1 */ 32; /* PTHRESH = 32 */ -- GitLab From 5d967eb7f84d2761d624d033c2583187b37b56ce Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:43 +0000 Subject: [PATCH 1700/1846] ixgbe: Correct Adaptive Interrupt Moderation so that it will change values This change corrects an issue in which Adaptive Interrupt Moderation was not changing values due to the fact that we were performing an and operation on the resultant value that was causing the value to never change from the default 20K interrupts per second. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index fc3c33a2c205..bad9c0508dfe 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1834,7 +1834,7 @@ void ixgbe_write_eitr(struct ixgbe_q_vector *q_vector) struct ixgbe_adapter *adapter = q_vector->adapter; struct ixgbe_hw *hw = &adapter->hw; int v_idx = q_vector->v_idx; - u32 itr_reg = q_vector->itr; + u32 itr_reg = q_vector->itr & IXGBE_MAX_EITR; switch (adapter->hw.mac.type) { case ixgbe_mac_82598EB: @@ -1886,7 +1886,7 @@ static void ixgbe_set_itr(struct ixgbe_q_vector *q_vector) ((9 * new_itr) + q_vector->itr); /* save the algorithm value here */ - q_vector->itr = new_itr & IXGBE_MAX_EITR; + q_vector->itr = new_itr; ixgbe_write_eitr(q_vector); } -- GitLab From 8f15486dd0f6e8423cb33fa8513ed9d074476471 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Fri, 10 Feb 2012 02:08:37 +0000 Subject: [PATCH 1701/1846] ixgbe: Default to queue pairs when number of queues is less than CPUs The old code had several errors in how it was determining the vector budget. In order to simplify things this patch updates the code so that it will attempt to always allocated paired Rx/Tx vectors instead of attempting to allocate individual vectors when the number of queues is less than the number of CPUs. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index c5cd2b678b44..f25b4e2f8c57 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -370,7 +370,7 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring) #define MAX_MSIX_Q_VECTORS MAX_MSIX_Q_VECTORS_82599 #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599 -#define MIN_MSIX_Q_VECTORS 2 +#define MIN_MSIX_Q_VECTORS 1 #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS) /* default to trying for four seconds */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index bad9c0508dfe..80ae91902aab 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -4561,11 +4561,9 @@ static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, { int err, vector_threshold; - /* We'll want at least 3 (vector_threshold): - * 1) TxQ[0] Cleanup - * 2) RxQ[0] Cleanup - * 3) Other (Link Status Change, etc.) - * 4) TCP Timer (optional) + /* We'll want at least 2 (vector_threshold): + * 1) TxQ[0] + RxQ[0] handler + * 2) Other (Link Status Change, etc.) */ vector_threshold = MIN_MSIX_COUNT; @@ -4919,9 +4917,11 @@ static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) * doesn't do us much good if we have a lot more vectors * than CPU's. So let's be conservative and only ask for * (roughly) the same number of vectors as there are CPU's. + * The default is to use pairs of vectors. */ - v_budget = min(adapter->num_rx_queues + adapter->num_tx_queues, - (int)num_online_cpus()) + NON_Q_VECTORS; + v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues); + v_budget = min_t(int, v_budget, num_online_cpus()); + v_budget += NON_Q_VECTORS; /* * At the same time, hardware can only support a maximum of -- GitLab From b9f6ed2bab0b087bdff870b7173f1d89efd96e54 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:54 +0000 Subject: [PATCH 1702/1846] ixgbe: Drop unnecessary napi_schedule_prep and spare blank line from ixgbe_intr This patch is a minor cleanup to address the unnecessary use of napi_schedule_prep in ixgbe_intr and to also remove a blank line that is not needed since it is separating a comment from the line it is explaining. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 80ae91902aab..b1f53eda8e3f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2401,16 +2401,13 @@ static irqreturn_t ixgbe_intr(int irq, void *data) ixgbe_check_fan_failure(adapter, eicr); - if (napi_schedule_prep(&(q_vector->napi))) { - /* would disable interrupts here but EIAM disabled it */ - __napi_schedule(&(q_vector->napi)); - } + /* would disable interrupts here but EIAM disabled it */ + napi_schedule(&q_vector->napi); /* * re-enable link(maybe) and non-queue interrupts, no flush. * ixgbe_poll will re-enable the queue interrupts */ - if (!test_bit(__IXGBE_DOWN, &adapter->state)) ixgbe_irq_enable(adapter, false, false); -- GitLab From de88eeeb16b164b615a5d71ad5fa0b7d51b14435 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:49:59 +0000 Subject: [PATCH 1703/1846] ixgbe: Allocate rings as part of the q_vector This patch makes the rings a part of the q_vector directly instead of indirectly. Specifically on x86 systems this helps to avoid any cache set conflicts between the q_vector, the tx_rings, and the rx_rings as the critical stride is 4K and in order to cross that boundary you would need to have over 15 rings on a single q_vector. In addition this allows for smarter allocations when Flow Director is enabled. Previously Flow Director would set the irq_affinity hints based on the CPU and was still using a node interleaving approach which on some systems would end up with the two values mismatched. With the new approach we can set the affinity for the irq_vector and use the CPU for that affinity to determine the node value for the node and the rings. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 10 +- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 489 +++++++++--------- 3 files changed, 244 insertions(+), 257 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index f25b4e2f8c57..699899ac85d0 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -254,10 +254,8 @@ struct ixgbe_ring { struct ixgbe_tx_queue_stats tx_stats; struct ixgbe_rx_queue_stats rx_stats; }; - int numa_node; unsigned int size; /* length in bytes */ dma_addr_t dma; /* phys. address of descriptor ring */ - struct rcu_head rcu; struct ixgbe_q_vector *q_vector; /* back-pointer to host q_vector */ } ____cacheline_internodealigned_in_smp; @@ -317,8 +315,13 @@ struct ixgbe_q_vector { struct ixgbe_ring_container rx, tx; struct napi_struct napi; - cpumask_var_t affinity_mask; + cpumask_t affinity_mask; + int numa_node; + struct rcu_head rcu; /* to avoid race with update stats on free */ char name[IFNAMSIZ + 9]; + + /* for dynamic allocation of rings associated with this q_vector */ + struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp; }; /* @@ -514,7 +517,6 @@ struct ixgbe_adapter { u16 eeprom_verl; u16 eeprom_cap; - int node; u32 interrupt_event; u32 led_reg; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 4846206a1014..51d159b130b3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -1591,7 +1591,6 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) tx_ring->dev = &adapter->pdev->dev; tx_ring->netdev = adapter->netdev; tx_ring->reg_idx = adapter->tx_ring[0]->reg_idx; - tx_ring->numa_node = adapter->node; err = ixgbe_setup_tx_resources(tx_ring); if (err) @@ -1617,7 +1616,6 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) rx_ring->netdev = adapter->netdev; rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx; rx_ring->rx_buf_len = IXGBE_RXBUFFER_2K; - rx_ring->numa_node = adapter->node; err = ixgbe_setup_rx_resources(rx_ring); if (err) { diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index b1f53eda8e3f..604540d6c6b6 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1893,7 +1893,7 @@ static void ixgbe_set_itr(struct ixgbe_q_vector *q_vector) } /** - * ixgbe_check_overtemp_subtask - check for over tempurature + * ixgbe_check_overtemp_subtask - check for over temperature * @adapter: pointer to adapter **/ static void ixgbe_check_overtemp_subtask(struct ixgbe_adapter *adapter) @@ -2205,78 +2205,6 @@ static irqreturn_t ixgbe_msix_clean_rings(int irq, void *data) return IRQ_HANDLED; } -static inline void map_vector_to_rxq(struct ixgbe_adapter *a, int v_idx, - int r_idx) -{ - struct ixgbe_q_vector *q_vector = a->q_vector[v_idx]; - struct ixgbe_ring *rx_ring = a->rx_ring[r_idx]; - - rx_ring->q_vector = q_vector; - rx_ring->next = q_vector->rx.ring; - q_vector->rx.ring = rx_ring; - q_vector->rx.count++; -} - -static inline void map_vector_to_txq(struct ixgbe_adapter *a, int v_idx, - int t_idx) -{ - struct ixgbe_q_vector *q_vector = a->q_vector[v_idx]; - struct ixgbe_ring *tx_ring = a->tx_ring[t_idx]; - - tx_ring->q_vector = q_vector; - tx_ring->next = q_vector->tx.ring; - q_vector->tx.ring = tx_ring; - q_vector->tx.count++; - q_vector->tx.work_limit = a->tx_work_limit; -} - -/** - * ixgbe_map_rings_to_vectors - Maps descriptor rings to vectors - * @adapter: board private structure to initialize - * - * This function maps descriptor rings to the queue-specific vectors - * we were allotted through the MSI-X enabling code. Ideally, we'd have - * one vector per ring/queue, but on a constrained vector budget, we - * group the rings as "efficiently" as possible. You would add new - * mapping configurations in here. - **/ -static void ixgbe_map_rings_to_vectors(struct ixgbe_adapter *adapter) -{ - int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; - int rxr_remaining = adapter->num_rx_queues, rxr_idx = 0; - int txr_remaining = adapter->num_tx_queues, txr_idx = 0; - int v_start = 0; - - /* only one q_vector if MSI-X is disabled. */ - if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) - q_vectors = 1; - - /* - * If we don't have enough vectors for a 1-to-1 mapping, we'll have to - * group them so there are multiple queues per vector. - * - * Re-adjusting *qpv takes care of the remainder. - */ - for (; v_start < q_vectors && rxr_remaining; v_start++) { - int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - v_start); - for (; rqpv; rqpv--, rxr_idx++, rxr_remaining--) - map_vector_to_rxq(adapter, v_start, rxr_idx); - } - - /* - * If there are not enough q_vectors for each ring to have it's own - * vector then we must pair up Rx/Tx on a each vector - */ - if ((v_start + txr_remaining) > q_vectors) - v_start = 0; - - for (; v_start < q_vectors && txr_remaining; v_start++) { - int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - v_start); - for (; tqpv; tqpv--, txr_idx++, txr_remaining--) - map_vector_to_txq(adapter, v_start, txr_idx); - } -} - /** * ixgbe_request_msix_irqs - Initialize MSI-X interrupts * @adapter: board private structure @@ -2320,14 +2248,14 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { /* assign the mask for this irq */ irq_set_affinity_hint(entry->vector, - q_vector->affinity_mask); + &q_vector->affinity_mask); } } err = request_irq(adapter->msix_entries[vector].vector, ixgbe_msix_other, 0, netdev->name, adapter); if (err) { - e_err(probe, "request_irq for msix_lsc failed: %d\n", err); + e_err(probe, "request_irq for msix_other failed: %d\n", err); goto free_queue_irqs; } @@ -2414,31 +2342,6 @@ static irqreturn_t ixgbe_intr(int irq, void *data) return IRQ_HANDLED; } -static inline void ixgbe_reset_q_vectors(struct ixgbe_adapter *adapter) -{ - int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; - int i; - - /* legacy and MSI only use one vector */ - if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) - q_vectors = 1; - - for (i = 0; i < adapter->num_rx_queues; i++) { - adapter->rx_ring[i]->q_vector = NULL; - adapter->rx_ring[i]->next = NULL; - } - for (i = 0; i < adapter->num_tx_queues; i++) { - adapter->tx_ring[i]->q_vector = NULL; - adapter->tx_ring[i]->next = NULL; - } - - for (i = 0; i < q_vectors; i++) { - struct ixgbe_q_vector *q_vector = adapter->q_vector[i]; - memset(&q_vector->rx, 0, sizeof(struct ixgbe_ring_container)); - memset(&q_vector->tx, 0, sizeof(struct ixgbe_ring_container)); - } -} - /** * ixgbe_request_irq - initialize interrupts * @adapter: board private structure @@ -2451,9 +2354,6 @@ static int ixgbe_request_irq(struct ixgbe_adapter *adapter) struct net_device *netdev = adapter->netdev; int err; - /* map all of the rings to the q_vectors */ - ixgbe_map_rings_to_vectors(adapter); - if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) err = ixgbe_request_msix_irqs(adapter); else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) @@ -2463,13 +2363,9 @@ static int ixgbe_request_irq(struct ixgbe_adapter *adapter) err = request_irq(adapter->pdev->irq, ixgbe_intr, IRQF_SHARED, netdev->name, adapter); - if (err) { + if (err) e_err(probe, "request_irq failed, Error %d\n", err); - /* place q_vectors and rings back into a known good state */ - ixgbe_reset_q_vectors(adapter); - } - return err; } @@ -2499,9 +2395,6 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter) } else { free_irq(adapter->pdev->irq, adapter); } - - /* clear q_vector state information */ - ixgbe_reset_q_vectors(adapter); } /** @@ -4827,75 +4720,6 @@ static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter) return; } -/** - * ixgbe_alloc_queues - Allocate memory for all rings - * @adapter: board private structure to initialize - * - * We allocate one ring per queue at run-time since we don't know the - * number of queues at compile-time. The polling_netdev array is - * intended for Multiqueue, but should work fine with a single queue. - **/ -static int ixgbe_alloc_queues(struct ixgbe_adapter *adapter) -{ - int rx = 0, tx = 0, nid = adapter->node; - - if (nid < 0 || !node_online(nid)) - nid = first_online_node; - - for (; tx < adapter->num_tx_queues; tx++) { - struct ixgbe_ring *ring; - - ring = kzalloc_node(sizeof(*ring), GFP_KERNEL, nid); - if (!ring) - ring = kzalloc(sizeof(*ring), GFP_KERNEL); - if (!ring) - goto err_allocation; - ring->count = adapter->tx_ring_count; - ring->queue_index = tx; - ring->numa_node = nid; - ring->dev = &adapter->pdev->dev; - ring->netdev = adapter->netdev; - - adapter->tx_ring[tx] = ring; - } - - for (; rx < adapter->num_rx_queues; rx++) { - struct ixgbe_ring *ring; - - ring = kzalloc_node(sizeof(*ring), GFP_KERNEL, nid); - if (!ring) - ring = kzalloc(sizeof(*ring), GFP_KERNEL); - if (!ring) - goto err_allocation; - ring->count = adapter->rx_ring_count; - ring->queue_index = rx; - ring->numa_node = nid; - ring->dev = &adapter->pdev->dev; - ring->netdev = adapter->netdev; - - /* - * 82599 errata, UDP frames with a 0 checksum can be marked as - * checksum errors. - */ - if (adapter->hw.mac.type == ixgbe_mac_82599EB) - set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); - - adapter->rx_ring[rx] = ring; - } - - ixgbe_cache_ring_register(adapter); - - return 0; - -err_allocation: - while (tx) - kfree(adapter->tx_ring[--tx]); - - while (rx) - kfree(adapter->rx_ring[--rx]); - return -ENOMEM; -} - /** * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported * @adapter: board private structure to initialize @@ -4927,7 +4751,7 @@ static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) * descriptor queues supported by our device. Thus, we cap it off in * those rare cases where the cpu count also exceeds our vector limit. */ - v_budget = min(v_budget, (int)hw->mac.max_msix_vectors); + v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors); /* A failure in MSI-X entry allocation isn't fatal, but it does * mean we disable MSI-X capabilities of the adapter. */ @@ -4974,6 +4798,164 @@ static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) return err; } +static void ixgbe_add_ring(struct ixgbe_ring *ring, + struct ixgbe_ring_container *head) +{ + ring->next = head->ring; + head->ring = ring; + head->count++; +} + +/** + * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector + * @adapter: board private structure to initialize + * @v_idx: index of vector in adapter struct + * + * We allocate one q_vector. If allocation fails we return -ENOMEM. + **/ +static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter, int v_idx, + int txr_count, int txr_idx, + int rxr_count, int rxr_idx) +{ + struct ixgbe_q_vector *q_vector; + struct ixgbe_ring *ring; + int node = -1; + int cpu = -1; + int ring_count, size; + + ring_count = txr_count + rxr_count; + size = sizeof(struct ixgbe_q_vector) + + (sizeof(struct ixgbe_ring) * ring_count); + + /* customize cpu for Flow Director mapping */ + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { + if (cpu_online(v_idx)) { + cpu = v_idx; + node = cpu_to_node(cpu); + } + } + + /* allocate q_vector and rings */ + q_vector = kzalloc_node(size, GFP_KERNEL, node); + if (!q_vector) + q_vector = kzalloc(size, GFP_KERNEL); + if (!q_vector) + return -ENOMEM; + + /* setup affinity mask and node */ + if (cpu != -1) + cpumask_set_cpu(cpu, &q_vector->affinity_mask); + else + cpumask_copy(&q_vector->affinity_mask, cpu_online_mask); + q_vector->numa_node = node; + + /* initialize NAPI */ + netif_napi_add(adapter->netdev, &q_vector->napi, + ixgbe_poll, 64); + + /* tie q_vector and adapter together */ + adapter->q_vector[v_idx] = q_vector; + q_vector->adapter = adapter; + q_vector->v_idx = v_idx; + + /* initialize work limits */ + q_vector->tx.work_limit = adapter->tx_work_limit; + + /* initialize pointer to rings */ + ring = q_vector->ring; + + while (txr_count) { + /* assign generic ring traits */ + ring->dev = &adapter->pdev->dev; + ring->netdev = adapter->netdev; + + /* configure backlink on ring */ + ring->q_vector = q_vector; + + /* update q_vector Tx values */ + ixgbe_add_ring(ring, &q_vector->tx); + + /* apply Tx specific ring traits */ + ring->count = adapter->tx_ring_count; + ring->queue_index = txr_idx; + + /* assign ring to adapter */ + adapter->tx_ring[txr_idx] = ring; + + /* update count and index */ + txr_count--; + txr_idx++; + + /* push pointer to next ring */ + ring++; + } + + while (rxr_count) { + /* assign generic ring traits */ + ring->dev = &adapter->pdev->dev; + ring->netdev = adapter->netdev; + + /* configure backlink on ring */ + ring->q_vector = q_vector; + + /* update q_vector Rx values */ + ixgbe_add_ring(ring, &q_vector->rx); + + /* + * 82599 errata, UDP frames with a 0 checksum + * can be marked as checksum errors. + */ + if (adapter->hw.mac.type == ixgbe_mac_82599EB) + set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); + + /* apply Rx specific ring traits */ + ring->count = adapter->rx_ring_count; + ring->queue_index = rxr_idx; + + /* assign ring to adapter */ + adapter->rx_ring[rxr_idx] = ring; + + /* update count and index */ + rxr_count--; + rxr_idx++; + + /* push pointer to next ring */ + ring++; + } + + return 0; +} + +/** + * ixgbe_free_q_vector - Free memory allocated for specific interrupt vector + * @adapter: board private structure to initialize + * @v_idx: Index of vector to be freed + * + * This function frees the memory allocated to the q_vector. In addition if + * NAPI is enabled it will delete any references to the NAPI struct prior + * to freeing the q_vector. + **/ +static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx) +{ + struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx]; + struct ixgbe_ring *ring; + + for (ring = q_vector->tx.ring; ring != NULL; ring = ring->next) + adapter->tx_ring[ring->queue_index] = NULL; + + for (ring = q_vector->rx.ring; ring != NULL; ring = ring->next) + adapter->rx_ring[ring->queue_index] = NULL; + + adapter->q_vector[v_idx] = NULL; + netif_napi_del(&q_vector->napi); + + /* + * ixgbe_get_stats64() might access the rings on this vector, + * we must wait a grace period before freeing it. + */ + kfree_rcu(q_vector, rcu); +} + /** * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors * @adapter: board private structure to initialize @@ -4983,33 +4965,46 @@ static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) **/ static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) { - int v_idx, num_q_vectors; - struct ixgbe_q_vector *q_vector; + int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; + int rxr_remaining = adapter->num_rx_queues; + int txr_remaining = adapter->num_tx_queues; + int rxr_idx = 0, txr_idx = 0, v_idx = 0; + int err; - if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) - num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; - else - num_q_vectors = 1; + /* only one q_vector if MSI-X is disabled. */ + if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) + q_vectors = 1; - for (v_idx = 0; v_idx < num_q_vectors; v_idx++) { - q_vector = kzalloc_node(sizeof(struct ixgbe_q_vector), - GFP_KERNEL, adapter->node); - if (!q_vector) - q_vector = kzalloc(sizeof(struct ixgbe_q_vector), - GFP_KERNEL); - if (!q_vector) - goto err_out; + if (q_vectors >= (rxr_remaining + txr_remaining)) { + for (; rxr_remaining; v_idx++, q_vectors--) { + int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors); + err = ixgbe_alloc_q_vector(adapter, v_idx, + 0, 0, rqpv, rxr_idx); - q_vector->adapter = adapter; - q_vector->v_idx = v_idx; + if (err) + goto err_out; + + /* update counts and index */ + rxr_remaining -= rqpv; + rxr_idx += rqpv; + } + } - /* Allocate the affinity_hint cpumask, configure the mask */ - if (!alloc_cpumask_var(&q_vector->affinity_mask, GFP_KERNEL)) + for (; q_vectors; v_idx++, q_vectors--) { + int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors); + int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors); + err = ixgbe_alloc_q_vector(adapter, v_idx, + tqpv, txr_idx, + rqpv, rxr_idx); + + if (err) goto err_out; - cpumask_set_cpu(v_idx, q_vector->affinity_mask); - netif_napi_add(adapter->netdev, &q_vector->napi, - ixgbe_poll, 64); - adapter->q_vector[v_idx] = q_vector; + + /* update counts and index */ + rxr_remaining -= rqpv; + rxr_idx += rqpv; + txr_remaining -= tqpv; + txr_idx += tqpv; } return 0; @@ -5017,12 +5012,9 @@ static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) err_out: while (v_idx) { v_idx--; - q_vector = adapter->q_vector[v_idx]; - netif_napi_del(&q_vector->napi); - free_cpumask_var(q_vector->affinity_mask); - kfree(q_vector); - adapter->q_vector[v_idx] = NULL; + ixgbe_free_q_vector(adapter, v_idx); } + return -ENOMEM; } @@ -5036,20 +5028,15 @@ static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) **/ static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter) { - int v_idx, num_q_vectors; + int v_idx, q_vectors; if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) - num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; + q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; else - num_q_vectors = 1; + q_vectors = 1; - for (v_idx = 0; v_idx < num_q_vectors; v_idx++) { - struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx]; - adapter->q_vector[v_idx] = NULL; - netif_napi_del(&q_vector->napi); - free_cpumask_var(q_vector->affinity_mask); - kfree(q_vector); - } + for (v_idx = 0; v_idx < q_vectors; v_idx++) + ixgbe_free_q_vector(adapter, v_idx); } static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter) @@ -5096,11 +5083,7 @@ int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) goto err_alloc_q_vectors; } - err = ixgbe_alloc_queues(adapter); - if (err) { - e_dev_err("Unable to allocate memory for queues\n"); - goto err_alloc_queues; - } + ixgbe_cache_ring_register(adapter); e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n", (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled", @@ -5110,8 +5093,6 @@ int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) return 0; -err_alloc_queues: - ixgbe_free_q_vectors(adapter); err_alloc_q_vectors: ixgbe_reset_interrupt_capability(adapter); err_set_interrupt: @@ -5127,22 +5108,6 @@ int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) **/ void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter) { - int i; - - for (i = 0; i < adapter->num_tx_queues; i++) { - kfree(adapter->tx_ring[i]); - adapter->tx_ring[i] = NULL; - } - for (i = 0; i < adapter->num_rx_queues; i++) { - struct ixgbe_ring *ring = adapter->rx_ring[i]; - - /* ixgbe_get_stats64() might access this ring, we must wait - * a grace period before freeing it. - */ - kfree_rcu(ring, rcu); - adapter->rx_ring[i] = NULL; - } - adapter->num_tx_queues = 0; adapter->num_rx_queues = 0; @@ -5286,9 +5251,6 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) return -EIO; } - /* get assigned NUMA node */ - adapter->node = dev_to_node(&pdev->dev); - set_bit(__IXGBE_DOWN, &adapter->state); return 0; @@ -5303,10 +5265,16 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) int ixgbe_setup_tx_resources(struct ixgbe_ring *tx_ring) { struct device *dev = tx_ring->dev; + int orig_node = dev_to_node(dev); + int numa_node = -1; int size; size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count; - tx_ring->tx_buffer_info = vzalloc_node(size, tx_ring->numa_node); + + if (tx_ring->q_vector) + numa_node = tx_ring->q_vector->numa_node; + + tx_ring->tx_buffer_info = vzalloc_node(size, numa_node); if (!tx_ring->tx_buffer_info) tx_ring->tx_buffer_info = vzalloc(size); if (!tx_ring->tx_buffer_info) @@ -5316,8 +5284,15 @@ int ixgbe_setup_tx_resources(struct ixgbe_ring *tx_ring) tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc); tx_ring->size = ALIGN(tx_ring->size, 4096); - tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, - &tx_ring->dma, GFP_KERNEL); + set_dev_node(dev, numa_node); + tx_ring->desc = dma_alloc_coherent(dev, + tx_ring->size, + &tx_ring->dma, + GFP_KERNEL); + set_dev_node(dev, orig_node); + if (!tx_ring->desc) + tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, + &tx_ring->dma, GFP_KERNEL); if (!tx_ring->desc) goto err; @@ -5366,10 +5341,16 @@ static int ixgbe_setup_all_tx_resources(struct ixgbe_adapter *adapter) int ixgbe_setup_rx_resources(struct ixgbe_ring *rx_ring) { struct device *dev = rx_ring->dev; + int orig_node = dev_to_node(dev); + int numa_node = -1; int size; size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; - rx_ring->rx_buffer_info = vzalloc_node(size, rx_ring->numa_node); + + if (rx_ring->q_vector) + numa_node = rx_ring->q_vector->numa_node; + + rx_ring->rx_buffer_info = vzalloc_node(size, numa_node); if (!rx_ring->rx_buffer_info) rx_ring->rx_buffer_info = vzalloc(size); if (!rx_ring->rx_buffer_info) @@ -5379,9 +5360,15 @@ int ixgbe_setup_rx_resources(struct ixgbe_ring *rx_ring) rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); rx_ring->size = ALIGN(rx_ring->size, 4096); - rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, - &rx_ring->dma, GFP_KERNEL); - + set_dev_node(dev, numa_node); + rx_ring->desc = dma_alloc_coherent(dev, + rx_ring->size, + &rx_ring->dma, + GFP_KERNEL); + set_dev_node(dev, orig_node); + if (!rx_ring->desc) + rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, + &rx_ring->dma, GFP_KERNEL); if (!rx_ring->desc) goto err; -- GitLab From a557928e26b08496c8f4b6c04e3838ad8048ad85 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:04 +0000 Subject: [PATCH 1704/1846] ixgbe: Add iterator for cycling through rings on a q_vector Since there are multiple spots where we have to cycle through all of the rings on a q_vector it makes sense to just add a function for iterating through all of them. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 4 ++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 699899ac85d0..03175cb7f078 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -296,6 +296,10 @@ struct ixgbe_ring_container { u8 itr; /* current ITR setting for ring */ }; +/* iterator for handling rings in ring container */ +#define ixgbe_for_each_ring(pos, head) \ + for (pos = (head).ring; pos != NULL; pos = pos->next) + #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \ ? 8 : 1) #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 604540d6c6b6..95240ab29177 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -928,10 +928,10 @@ static void ixgbe_update_dca(struct ixgbe_q_vector *q_vector) if (q_vector->cpu == cpu) goto out_no_update; - for (ring = q_vector->tx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->tx) ixgbe_update_tx_dca(adapter, ring, cpu); - for (ring = q_vector->rx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->rx) ixgbe_update_rx_dca(adapter, ring, cpu); q_vector->cpu = cpu; @@ -1706,10 +1706,10 @@ static void ixgbe_configure_msix(struct ixgbe_adapter *adapter) struct ixgbe_ring *ring; q_vector = adapter->q_vector[v_idx]; - for (ring = q_vector->rx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->rx) ixgbe_set_ivar(adapter, 0, ring->reg_idx, v_idx); - for (ring = q_vector->tx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->tx) ixgbe_set_ivar(adapter, 1, ring->reg_idx, v_idx); if (q_vector->tx.ring && !q_vector->rx.ring) { @@ -4195,7 +4195,7 @@ static int ixgbe_poll(struct napi_struct *napi, int budget) ixgbe_update_dca(q_vector); #endif - for (ring = q_vector->tx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->tx) clean_complete &= !!ixgbe_clean_tx_irq(q_vector, ring); /* attempt to distribute budget to each queue fairly, but don't allow @@ -4205,7 +4205,7 @@ static int ixgbe_poll(struct napi_struct *napi, int budget) else per_ring_budget = budget; - for (ring = q_vector->rx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->rx) clean_complete &= ixgbe_clean_rx_irq(q_vector, ring, per_ring_budget); @@ -4940,10 +4940,10 @@ static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx) struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx]; struct ixgbe_ring *ring; - for (ring = q_vector->tx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->tx) adapter->tx_ring[ring->queue_index] = NULL; - for (ring = q_vector->rx.ring; ring != NULL; ring = ring->next) + ixgbe_for_each_ring(ring, q_vector->rx) adapter->rx_ring[ring->queue_index] = NULL; adapter->q_vector[v_idx] = NULL; -- GitLab From 3832b26e49ad9e585239b32f763c31679f9e41fe Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:09 +0000 Subject: [PATCH 1705/1846] ixgbe: Simplify logic for ethtool loopback frame creation and testing This change makes it a bit easier to do the loopback frame creating and testing. Previously we were doing an and to drop the last bit, and then dividing the frame_size by 2 in order to get locations for frame bytes and testing. Instead we can simplify it by just shifting the register one bit to the right and using that for the frame offsets. This change also replaces all instances of rx_buffer_info with just rx_buffer since that is closer to the name of the actual structure being used and can save a few extra characters. In addition I have updated the logic for cleaning up a test frame so that we pass an rx_buffer instead of the sk_buff. The main motivation behind this is changes that will replace the sk_buff with just a page in the future. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 51d159b130b3..1216bae913e3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -1701,63 +1701,65 @@ static void ixgbe_loopback_cleanup(struct ixgbe_adapter *adapter) } static void ixgbe_create_lbtest_frame(struct sk_buff *skb, - unsigned int frame_size) + unsigned int frame_size) { memset(skb->data, 0xFF, frame_size); - frame_size &= ~1; - memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); - memset(&skb->data[frame_size / 2 + 10], 0xBE, 1); - memset(&skb->data[frame_size / 2 + 12], 0xAF, 1); + frame_size >>= 1; + memset(&skb->data[frame_size], 0xAA, frame_size / 2 - 1); + memset(&skb->data[frame_size + 10], 0xBE, 1); + memset(&skb->data[frame_size + 12], 0xAF, 1); } -static int ixgbe_check_lbtest_frame(struct sk_buff *skb, - unsigned int frame_size) +static bool ixgbe_check_lbtest_frame(struct ixgbe_rx_buffer *rx_buffer, + unsigned int frame_size) { - frame_size &= ~1; - if (*(skb->data + 3) == 0xFF) { - if ((*(skb->data + frame_size / 2 + 10) == 0xBE) && - (*(skb->data + frame_size / 2 + 12) == 0xAF)) { - return 0; - } - } - return 13; + unsigned char *data; + bool match = true; + + frame_size >>= 1; + + data = rx_buffer->skb->data; + + if (data[3] != 0xFF || + data[frame_size + 10] != 0xBE || + data[frame_size + 12] != 0xAF) + match = false; + + return match; } static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring, - struct ixgbe_ring *tx_ring, - unsigned int size) + struct ixgbe_ring *tx_ring, + unsigned int size) { union ixgbe_adv_rx_desc *rx_desc; - struct ixgbe_rx_buffer *rx_buffer_info; - struct ixgbe_tx_buffer *tx_buffer_info; - const int bufsz = rx_ring->rx_buf_len; - u32 staterr; + struct ixgbe_rx_buffer *rx_buffer; + struct ixgbe_tx_buffer *tx_buffer; u16 rx_ntc, tx_ntc, count = 0; /* initialize next to clean and descriptor values */ rx_ntc = rx_ring->next_to_clean; tx_ntc = tx_ring->next_to_clean; rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc); - staterr = le32_to_cpu(rx_desc->wb.upper.status_error); - while (staterr & IXGBE_RXD_STAT_DD) { + while (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) { /* check Rx buffer */ - rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc]; + rx_buffer = &rx_ring->rx_buffer_info[rx_ntc]; /* unmap Rx buffer, will be remapped by alloc_rx_buffers */ dma_unmap_single(rx_ring->dev, - rx_buffer_info->dma, - bufsz, + rx_buffer->dma, + rx_ring->rx_buf_len, DMA_FROM_DEVICE); - rx_buffer_info->dma = 0; + rx_buffer->dma = 0; /* verify contents of skb */ - if (!ixgbe_check_lbtest_frame(rx_buffer_info->skb, size)) + if (ixgbe_check_lbtest_frame(rx_buffer, size)) count++; /* unmap buffer on Tx side */ - tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc]; - ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer_info); + tx_buffer = &tx_ring->tx_buffer_info[tx_ntc]; + ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer); /* increment Rx/Tx next to clean counters */ rx_ntc++; @@ -1769,7 +1771,6 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring, /* fetch next descriptor */ rx_desc = IXGBE_RX_DESC(rx_ring, rx_ntc); - staterr = le32_to_cpu(rx_desc->wb.upper.status_error); } /* re-map buffers to ring, store next to clean values */ -- GitLab From b0fc7c1a643bb0e689cd2846b0edf7c707a87600 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 12 Mar 2012 13:22:54 +0200 Subject: [PATCH 1706/1846] ath6kl: fix regression in ath6kl_upload_board_file() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit My patch 24fc32b3 ("ath6kl: add ath6kl_bmi_write_hi32()") caused a regression in ath6kl_upload_board_file() and the board_address variable was not properly initialised in some cases: ath6kl/init.c:1068:6: warning: ‘board_address’ may be used uninitialized in this function Most likely this broke ar6004 support but I can't test that right now. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 231675d4bf70..03cae142f178 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1078,8 +1078,9 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) * writing board data. */ if (ar->hw.board_addr != 0) { + board_address = ar->hw.board_addr; ath6kl_bmi_write_hi32(ar, hi_board_data, - ar->hw.board_addr); + board_address); } else { ath6kl_bmi_read_hi32(ar, hi_board_data, &board_address); } -- GitLab From 06f33f13ac2562cddf44285bfdea6cfb0cdd3515 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 12 Mar 2012 13:23:03 +0200 Subject: [PATCH 1707/1846] ath6kl: replace strict_strtoul() with kstrtoul() Recommended by checkpatch. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index 9170b05e5d87..552adb3f80d0 100755 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -856,17 +856,9 @@ static ssize_t ath6kl_regread_write(struct file *file, size_t count, loff_t *ppos) { struct ath6kl *ar = file->private_data; - u8 buf[50]; - unsigned int len; unsigned long reg_addr; - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - - buf[len] = '\0'; - - if (strict_strtoul(buf, 0, ®_addr)) + if (kstrtoul_from_user(user_buf, count, 0, ®_addr)) return -EINVAL; if ((reg_addr % 4) != 0) @@ -980,15 +972,8 @@ static ssize_t ath6kl_lrssi_roam_write(struct file *file, { struct ath6kl *ar = file->private_data; unsigned long lrssi_roam_threshold; - char buf[32]; - ssize_t len; - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - - buf[len] = '\0'; - if (strict_strtoul(buf, 0, &lrssi_roam_threshold)) + if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold)) return -EINVAL; ar->lrssi_roam_threshold = lrssi_roam_threshold; -- GitLab From 7433a49010fbb637de6ce14080fd89067156ccb7 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 12 Mar 2012 13:23:14 +0200 Subject: [PATCH 1708/1846] ath6kl: fix open parenthesis alignment in ath6kl_sdio_suspend() ath6kl/sdio.c:875: CHECK: Alignment should match open parenthesis Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/sdio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 5a03082ee589..53528648b425 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -871,12 +871,13 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) if (ret && ret != -ENOTCONN) ath6kl_err("wow suspend failed: %d\n", ret); - if (ret && (!ar->wow_suspend_mode || - ar->wow_suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP)) - try_deepsleep = true; + if (ret && + (!ar->wow_suspend_mode || + ar->wow_suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP)) + try_deepsleep = true; else if (ret && ar->wow_suspend_mode == WLAN_POWER_STATE_CUT_PWR) - goto cut_pwr; + goto cut_pwr; if (!ret) return 0; } -- GitLab From b5283871ceced6e50728c51e4de811d1deadc962 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Mon, 12 Mar 2012 13:23:23 +0200 Subject: [PATCH 1709/1846] ath6kl: use max_t() in ath6kl_cfg80211_connect() ath6kl/cfg80211.c:589: WARNING: max() should probably be max_t(u16, vif->listen_intvl_t, ATH6KL_MAX_WOW_LISTEN_INTL) Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/cfg80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 5ecc53af3ac6..00d38952b5fb 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -586,8 +586,8 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, vif->reconnect_flag = 0; if (vif->nw_type == INFRA_NETWORK) { - interval = max(vif->listen_intvl_t, - (u16) ATH6KL_MAX_WOW_LISTEN_INTL); + interval = max_t(u16, vif->listen_intvl_t, + ATH6KL_MAX_WOW_LISTEN_INTL); status = ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, interval, 0); -- GitLab From 9df2a0b7096873e91d1b6b0e842e9f6bdc7ee9fd Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Tue, 13 Mar 2012 14:36:27 +0200 Subject: [PATCH 1710/1846] ath6kl: fix debug.c file mode Commit 7504a3e1 ("ath6kl: add padding to firmware log records") accidentally changed debug.c mode from 100644 to 100755. Revert that back to original. Signed-off-by: Kalle Valo --- drivers/net/wireless/ath/ath6kl/debug.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 drivers/net/wireless/ath/ath6kl/debug.c diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c old mode 100755 new mode 100644 -- GitLab From a3ea2c76b193be5794e0de6aff66e14c21b904f8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 8 Mar 2012 22:25:57 -0600 Subject: [PATCH 1711/1846] b43legacy: Load firmware from work queue instead of from probe routine Recent changes in udev are causing problems for drivers that load firmware from the probe routine. As b43legacy has such a structure, it must be changed. As this driver loads 3 or 4 firmware files, changing to the asynchronous routine request_firmware_nowait() would be complicated. In this implementation, the probe routine starts a work queue that calls the firmware loading routines. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/b43legacy/b43legacy.h | 3 ++ drivers/net/wireless/b43legacy/main.c | 33 +++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h index 98e3d44400c6..a29da674e69d 100644 --- a/drivers/net/wireless/b43legacy/b43legacy.h +++ b/drivers/net/wireless/b43legacy/b43legacy.h @@ -581,6 +581,9 @@ struct b43legacy_wl { struct mutex mutex; /* locks wireless core state */ spinlock_t leds_lock; /* lock for leds */ + /* firmware loading work */ + struct work_struct firmware_load; + /* We can only have one operating interface (802.11 core) * at a time. General information about this interface follows. */ diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 75e70bce40f6..df7e16dfb36c 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c @@ -1557,8 +1557,15 @@ static int do_request_fw(struct b43legacy_wldev *dev, return -EPROTO; } -static int b43legacy_request_firmware(struct b43legacy_wldev *dev) +static int b43legacy_one_core_attach(struct ssb_device *dev, + struct b43legacy_wl *wl); +static void b43legacy_one_core_detach(struct ssb_device *dev); + +static void b43legacy_request_firmware(struct work_struct *work) { + struct b43legacy_wl *wl = container_of(work, + struct b43legacy_wl, firmware_load); + struct b43legacy_wldev *dev = wl->current_dev; struct b43legacy_firmware *fw = &dev->fw; const u8 rev = dev->dev->id.revision; const char *filename; @@ -1624,8 +1631,14 @@ static int b43legacy_request_firmware(struct b43legacy_wldev *dev) if (err) goto err_load; } + err = ieee80211_register_hw(wl->hw); + if (err) + goto err_one_core_detach; + return; - return 0; +err_one_core_detach: + b43legacy_one_core_detach(dev->dev); + goto error; err_load: b43legacy_print_fw_helptext(dev->wl); @@ -1639,7 +1652,7 @@ static int b43legacy_request_firmware(struct b43legacy_wldev *dev) error: b43legacy_release_firmware(dev); - return err; + return; } static int b43legacy_upload_microcode(struct b43legacy_wldev *dev) @@ -2153,9 +2166,6 @@ static int b43legacy_chip_init(struct b43legacy_wldev *dev) macctl |= B43legacy_MACCTL_INFRA; b43legacy_write32(dev, B43legacy_MMIO_MACCTL, macctl); - err = b43legacy_request_firmware(dev); - if (err) - goto out; err = b43legacy_upload_microcode(dev); if (err) goto out; /* firmware is released later */ @@ -3860,17 +3870,13 @@ static int b43legacy_probe(struct ssb_device *dev, if (err) goto err_wireless_exit; - if (first) { - err = ieee80211_register_hw(wl->hw); - if (err) - goto err_one_core_detach; - } + /* setup and start work to load firmware */ + INIT_WORK(&wl->firmware_load, b43legacy_request_firmware); + schedule_work(&wl->firmware_load); out: return err; -err_one_core_detach: - b43legacy_one_core_detach(dev); err_wireless_exit: if (first) b43legacy_wireless_exit(dev, wl); @@ -3885,6 +3891,7 @@ static void b43legacy_remove(struct ssb_device *dev) /* We must cancel any work here before unregistering from ieee80211, * as the ieee80211 unreg will destroy the workqueue. */ cancel_work_sync(&wldev->restart_work); + cancel_work_sync(&wl->firmware_load); B43legacy_WARN_ON(!wl); if (wl->current_dev == wldev) -- GitLab From 6b6fa5868eec26bdc6a83543cebb8cf832a2645a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 8 Mar 2012 22:27:46 -0600 Subject: [PATCH 1712/1846] b43: Load firmware from a work queue and not from the probe routine Recent changes in udev are causing problems for drivers that load firmware from the probe routine. As b43 has such a structure, it must be changed. As this driver loads more than 1 firmware file, changing to the asynchronous routine request_firmware_nowait() would be complicated. In this implementation, the probe routine starts a queue that calls the firmware loading routines. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/b43/b43.h | 3 ++ drivers/net/wireless/b43/main.c | 59 ++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 835462dc1206..67c13af6f206 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h @@ -932,6 +932,9 @@ struct b43_wl { /* Flag that implement the queues stopping. */ bool tx_queue_stopped[B43_QOS_QUEUE_NUM]; + /* firmware loading work */ + struct work_struct firmware_load; + /* The device LEDs. */ struct b43_leds leds; diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 1d633f3b3274..c79e6638c88d 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -2390,8 +2390,14 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx) return err; } -static int b43_request_firmware(struct b43_wldev *dev) +static int b43_one_core_attach(struct b43_bus_dev *dev, struct b43_wl *wl); +static void b43_one_core_detach(struct b43_bus_dev *dev); + +static void b43_request_firmware(struct work_struct *work) { + struct b43_wl *wl = container_of(work, + struct b43_wl, firmware_load); + struct b43_wldev *dev = wl->current_dev; struct b43_request_fw_context *ctx; unsigned int i; int err; @@ -2399,23 +2405,23 @@ static int b43_request_firmware(struct b43_wldev *dev) ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) - return -ENOMEM; + return; ctx->dev = dev; ctx->req_type = B43_FWTYPE_PROPRIETARY; err = b43_try_request_fw(ctx); if (!err) - goto out; /* Successfully loaded it. */ - err = ctx->fatal_failure; - if (err) + goto start_ieee80211; /* Successfully loaded it. */ + /* Was fw version known? */ + if (ctx->fatal_failure) goto out; + /* proprietary fw not found, try open source */ ctx->req_type = B43_FWTYPE_OPENSOURCE; err = b43_try_request_fw(ctx); if (!err) - goto out; /* Successfully loaded it. */ - err = ctx->fatal_failure; - if (err) + goto start_ieee80211; /* Successfully loaded it. */ + if(ctx->fatal_failure) goto out; /* Could not find a usable firmware. Print the errors. */ @@ -2425,11 +2431,20 @@ static int b43_request_firmware(struct b43_wldev *dev) b43err(dev->wl, errmsg); } b43_print_fw_helptext(dev->wl, 1); - err = -ENOENT; + goto out; + +start_ieee80211: + err = ieee80211_register_hw(wl->hw); + if (err) + goto err_one_core_detach; + b43_leds_register(wl->current_dev); + goto out; + +err_one_core_detach: + b43_one_core_detach(dev->dev); out: kfree(ctx); - return err; } static int b43_upload_microcode(struct b43_wldev *dev) @@ -3023,9 +3038,6 @@ static int b43_chip_init(struct b43_wldev *dev) macctl |= B43_MACCTL_INFRA; b43_write32(dev, B43_MMIO_MACCTL, macctl); - err = b43_request_firmware(dev); - if (err) - goto out; err = b43_upload_microcode(dev); if (err) goto out; /* firmware is released later */ @@ -4155,6 +4167,7 @@ static struct b43_wldev * b43_wireless_core_stop(struct b43_wldev *dev) mutex_unlock(&wl->mutex); cancel_delayed_work_sync(&dev->periodic_work); cancel_work_sync(&wl->tx_work); + cancel_work_sync(&wl->firmware_load); mutex_lock(&wl->mutex); dev = wl->current_dev; if (!dev || b43_status(dev) < B43_STAT_STARTED) { @@ -5314,16 +5327,13 @@ static int b43_bcma_probe(struct bcma_device *core) if (err) goto bcma_err_wireless_exit; - err = ieee80211_register_hw(wl->hw); - if (err) - goto bcma_err_one_core_detach; - b43_leds_register(wl->current_dev); + /* setup and start work to load firmware */ + INIT_WORK(&wl->firmware_load, b43_request_firmware); + schedule_work(&wl->firmware_load); bcma_out: return err; -bcma_err_one_core_detach: - b43_one_core_detach(dev); bcma_err_wireless_exit: ieee80211_free_hw(wl->hw); return err; @@ -5390,18 +5400,13 @@ int b43_ssb_probe(struct ssb_device *sdev, const struct ssb_device_id *id) if (err) goto err_wireless_exit; - if (first) { - err = ieee80211_register_hw(wl->hw); - if (err) - goto err_one_core_detach; - b43_leds_register(wl->current_dev); - } + /* setup and start work to load firmware */ + INIT_WORK(&wl->firmware_load, b43_request_firmware); + schedule_work(&wl->firmware_load); out: return err; - err_one_core_detach: - b43_one_core_detach(dev); err_wireless_exit: if (first) b43_wireless_exit(dev, wl); -- GitLab From 617bbde878604adfcd557fc2a8952f77ab4ebd95 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 12 Mar 2012 13:49:13 +0100 Subject: [PATCH 1713/1846] mac80211: move RX WEP weak IV counting This is better done inside the WEP decrypt function where it doesn't have to check all the conditions any more since they've been tested already. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/rx.c | 7 ------- net/mac80211/wep.c | 10 ++++++---- net/mac80211/wep.h | 1 - 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 5f6e32ca0858..b38da13e2a88 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1070,13 +1070,6 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) switch (rx->key->conf.cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - /* Check for weak IVs if possible */ - if (rx->sta && ieee80211_is_data(fc) && - (!(status->flag & RX_FLAG_IV_STRIPPED) || - !(status->flag & RX_FLAG_DECRYPTED)) && - ieee80211_wep_is_weak_iv(rx->skb, rx->key)) - rx->sta->wep_weak_iv_count++; - result = ieee80211_crypto_wep_decrypt(rx); break; case WLAN_CIPHER_SUITE_TKIP: diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index 68ad351479df..5cd87ba11bb7 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c @@ -263,16 +263,14 @@ static int ieee80211_wep_decrypt(struct ieee80211_local *local, } -bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) +static bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, + struct ieee80211_key *key) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; unsigned int hdrlen; u8 *ivpos; u32 iv; - if (!ieee80211_has_protected(hdr->frame_control)) - return false; - hdrlen = ieee80211_hdrlen(hdr->frame_control); ivpos = skb->data + hdrlen; iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; @@ -292,9 +290,13 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) return RX_CONTINUE; if (!(status->flag & RX_FLAG_DECRYPTED)) { + if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) + rx->sta->wep_weak_iv_count++; if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) return RX_DROP_UNUSABLE; } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { + if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) + rx->sta->wep_weak_iv_count++; ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); /* remove ICV */ skb_trim(rx->skb, rx->skb->len - WEP_ICV_LEN); diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h index 01e54840a628..9615749d1f65 100644 --- a/net/mac80211/wep.h +++ b/net/mac80211/wep.h @@ -25,7 +25,6 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, const u8 *key, int keylen, int keyidx); int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, size_t klen, u8 *data, size_t data_len); -bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); ieee80211_rx_result ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx); -- GitLab From a8286911881948c7a2ecc63ee4224c258cce2da3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 12 Mar 2012 13:49:14 +0100 Subject: [PATCH 1714/1846] mac80211: linearize SKBs as needed for crypto Not linearizing every SKB will help actually pass non-linear SKBs all the way up when on an encrypted connection. For now, linearize TKIP completely as it is lower performance and I don't quite grok all the details. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/rx.c | 6 ++---- net/mac80211/wep.c | 11 ++++++++--- net/mac80211/wpa.c | 22 +++++++++++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index b38da13e2a88..53c88d145472 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1063,10 +1063,6 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) return RX_DROP_MONITOR; } - if (skb_linearize(rx->skb)) - return RX_DROP_UNUSABLE; - /* the hdr variable is invalid now! */ - switch (rx->key->conf.cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: @@ -1089,6 +1085,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) return RX_DROP_UNUSABLE; } + /* the hdr variable is invalid after the decrypt handlers */ + /* either the frame has been decrypted or will be dropped */ status->flag |= RX_FLAG_DECRYPTED; diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index 5cd87ba11bb7..7aa31bbfaa3b 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c @@ -284,22 +284,27 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) struct sk_buff *skb = rx->skb; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + __le16 fc = hdr->frame_control; - if (!ieee80211_is_data(hdr->frame_control) && - !ieee80211_is_auth(hdr->frame_control)) + if (!ieee80211_is_data(fc) && !ieee80211_is_auth(fc)) return RX_CONTINUE; if (!(status->flag & RX_FLAG_DECRYPTED)) { + if (skb_linearize(rx->skb)) + return RX_DROP_UNUSABLE; if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) rx->sta->wep_weak_iv_count++; if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) return RX_DROP_UNUSABLE; } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { + if (!pskb_may_pull(rx->skb, ieee80211_hdrlen(fc) + WEP_IV_LEN)) + return RX_DROP_UNUSABLE; if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) rx->sta->wep_weak_iv_count++; ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); /* remove ICV */ - skb_trim(rx->skb, rx->skb->len - WEP_ICV_LEN); + if (pskb_trim(rx->skb, rx->skb->len - WEP_ICV_LEN)) + return RX_DROP_UNUSABLE; } return RX_CONTINUE; diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index b758350919ff..0ae23c60968c 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -138,6 +138,10 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx) if (skb->len < hdrlen + MICHAEL_MIC_LEN) return RX_DROP_UNUSABLE; + if (skb_linearize(rx->skb)) + return RX_DROP_UNUSABLE; + hdr = (void *)skb->data; + data = skb->data + hdrlen; data_len = skb->len - hdrlen - MICHAEL_MIC_LEN; key = &rx->key->conf.key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]; @@ -253,6 +257,11 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) if (!rx->sta || skb->len - hdrlen < 12) return RX_DROP_UNUSABLE; + /* it may be possible to optimize this a bit more */ + if (skb_linearize(rx->skb)) + return RX_DROP_UNUSABLE; + hdr = (void *)skb->data; + /* * Let TKIP code verify IV, but skip decryption. * In the case where hardware checks the IV as well, @@ -484,6 +493,14 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) if (!rx->sta || data_len < 0) return RX_DROP_UNUSABLE; + if (status->flag & RX_FLAG_DECRYPTED) { + if (!pskb_may_pull(rx->skb, hdrlen + CCMP_HDR_LEN)) + return RX_DROP_UNUSABLE; + } else { + if (skb_linearize(rx->skb)) + return RX_DROP_UNUSABLE; + } + ccmp_hdr2pn(pn, skb->data + hdrlen); queue = rx->security_idx; @@ -509,7 +526,8 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) memcpy(key->u.ccmp.rx_pn[queue], pn, CCMP_PN_LEN); /* Remove CCMP header and MIC */ - skb_trim(skb, skb->len - CCMP_MIC_LEN); + if (pskb_trim(skb, skb->len - CCMP_MIC_LEN)) + return RX_DROP_UNUSABLE; memmove(skb->data + CCMP_HDR_LEN, skb->data, hdrlen); skb_pull(skb, CCMP_HDR_LEN); @@ -609,6 +627,8 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx) if (!ieee80211_is_mgmt(hdr->frame_control)) return RX_CONTINUE; + /* management frames are already linear */ + if (skb->len < 24 + sizeof(*mmie)) return RX_DROP_UNUSABLE; -- GitLab From 3e822635a79c55a7768ec38cd5007081dae95171 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 12 Mar 2012 19:35:08 -0700 Subject: [PATCH 1715/1846] mwifiex: rename long function names to shorter ones This saves some space and adds better readability. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/11n.c | 60 +++++++++----------- drivers/net/wireless/mwifiex/11n.h | 9 ++- drivers/net/wireless/mwifiex/11n_rxreorder.c | 6 +- drivers/net/wireless/mwifiex/11n_rxreorder.h | 5 +- drivers/net/wireless/mwifiex/main.h | 6 +- drivers/net/wireless/mwifiex/wmm.c | 10 ++-- 6 files changed, 43 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c index 34bba5234294..aeb456d6396f 100644 --- a/drivers/net/wireless/mwifiex/11n.c +++ b/drivers/net/wireless/mwifiex/11n.c @@ -69,8 +69,8 @@ mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type, * table which matches the requested BA status. */ static struct mwifiex_tx_ba_stream_tbl * -mwifiex_11n_get_tx_ba_stream_status(struct mwifiex_private *priv, - enum mwifiex_ba_status ba_status) +mwifiex_get_ba_status(struct mwifiex_private *priv, + enum mwifiex_ba_status ba_status) { struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; unsigned long flags; @@ -107,12 +107,11 @@ int mwifiex_ret_11n_delba(struct mwifiex_private *priv, tid = del_ba_param_set >> DELBA_TID_POS; if (del_ba->del_result == BA_RESULT_SUCCESS) { - mwifiex_11n_delete_ba_stream_tbl(priv, tid, - del_ba->peer_mac_addr, TYPE_DELBA_SENT, - INITIATOR_BIT(del_ba_param_set)); + mwifiex_del_ba_tbl(priv, tid, del_ba->peer_mac_addr, + TYPE_DELBA_SENT, + INITIATOR_BIT(del_ba_param_set)); - tx_ba_tbl = mwifiex_11n_get_tx_ba_stream_status(priv, - BA_STREAM_SETUP_INPROGRESS); + tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS); if (tx_ba_tbl) mwifiex_send_addba(priv, tx_ba_tbl->tid, tx_ba_tbl->ra); @@ -120,18 +119,17 @@ int mwifiex_ret_11n_delba(struct mwifiex_private *priv, * In case of failure, recreate the deleted stream in case * we initiated the ADDBA */ - if (INITIATOR_BIT(del_ba_param_set)) { - mwifiex_11n_create_tx_ba_stream_tbl(priv, - del_ba->peer_mac_addr, tid, - BA_STREAM_SETUP_INPROGRESS); - - tx_ba_tbl = mwifiex_11n_get_tx_ba_stream_status(priv, - BA_STREAM_SETUP_INPROGRESS); - if (tx_ba_tbl) - mwifiex_11n_delete_ba_stream_tbl(priv, - tx_ba_tbl->tid, tx_ba_tbl->ra, - TYPE_DELBA_SENT, true); - } + if (!INITIATOR_BIT(del_ba_param_set)) + return 0; + + mwifiex_create_ba_tbl(priv, del_ba->peer_mac_addr, tid, + BA_SETUP_INPROGRESS); + + tx_ba_tbl = mwifiex_get_ba_status(priv, BA_SETUP_INPROGRESS); + + if (tx_ba_tbl) + mwifiex_del_ba_tbl(priv, tx_ba_tbl->tid, tx_ba_tbl->ra, + TYPE_DELBA_SENT, true); } return 0; @@ -160,18 +158,17 @@ int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv, & IEEE80211_ADDBA_PARAM_TID_MASK) >> BLOCKACKPARAM_TID_POS; if (le16_to_cpu(add_ba_rsp->status_code) == BA_RESULT_SUCCESS) { - tx_ba_tbl = mwifiex_11n_get_tx_ba_stream_tbl(priv, tid, + tx_ba_tbl = mwifiex_get_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr); if (tx_ba_tbl) { dev_dbg(priv->adapter->dev, "info: BA stream complete\n"); - tx_ba_tbl->ba_status = BA_STREAM_SETUP_COMPLETE; + tx_ba_tbl->ba_status = BA_SETUP_COMPLETE; } else { dev_err(priv->adapter->dev, "BA stream not created\n"); } } else { - mwifiex_11n_delete_ba_stream_tbl(priv, tid, - add_ba_rsp->peer_mac_addr, - TYPE_DELBA_SENT, true); + mwifiex_del_ba_tbl(priv, tid, add_ba_rsp->peer_mac_addr, + TYPE_DELBA_SENT, true); if (add_ba_rsp->add_rsp_result != BA_RESULT_TIMEOUT) priv->aggr_prio_tbl[tid].ampdu_ap = BA_STREAM_NOT_ALLOWED; @@ -544,8 +541,7 @@ void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv) * table which matches the given RA/TID pair. */ struct mwifiex_tx_ba_stream_tbl * -mwifiex_11n_get_tx_ba_stream_tbl(struct mwifiex_private *priv, - int tid, u8 *ra) +mwifiex_get_ba_tbl(struct mwifiex_private *priv, int tid, u8 *ra) { struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl; unsigned long flags; @@ -567,14 +563,13 @@ mwifiex_11n_get_tx_ba_stream_tbl(struct mwifiex_private *priv, * This function creates an entry in Tx BA stream table for the * given RA/TID pair. */ -void mwifiex_11n_create_tx_ba_stream_tbl(struct mwifiex_private *priv, - u8 *ra, int tid, - enum mwifiex_ba_status ba_status) +void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid, + enum mwifiex_ba_status ba_status) { struct mwifiex_tx_ba_stream_tbl *new_node; unsigned long flags; - if (!mwifiex_11n_get_tx_ba_stream_tbl(priv, tid, ra)) { + if (!mwifiex_get_ba_tbl(priv, tid, ra)) { new_node = kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl), GFP_ATOMIC); if (!new_node) { @@ -668,9 +663,8 @@ void mwifiex_11n_delete_ba_stream(struct mwifiex_private *priv, u8 *del_ba) tid = del_ba_param_set >> DELBA_TID_POS; - mwifiex_11n_delete_ba_stream_tbl(priv, tid, cmd_del_ba->peer_mac_addr, - TYPE_DELBA_RECEIVE, - INITIATOR_BIT(del_ba_param_set)); + mwifiex_del_ba_tbl(priv, tid, cmd_del_ba->peer_mac_addr, + TYPE_DELBA_RECEIVE, INITIATOR_BIT(del_ba_param_set)); } /* diff --git a/drivers/net/wireless/mwifiex/11n.h b/drivers/net/wireless/mwifiex/11n.h index 90b421e343d4..139aa6ee1fbe 100644 --- a/drivers/net/wireless/mwifiex/11n.h +++ b/drivers/net/wireless/mwifiex/11n.h @@ -46,13 +46,12 @@ void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv, struct mwifiex_tx_ba_stream_tbl *tx_tbl); void mwifiex_11n_delete_all_tx_ba_stream_tbl(struct mwifiex_private *priv); -struct mwifiex_tx_ba_stream_tbl *mwifiex_11n_get_tx_ba_stream_tbl(struct +struct mwifiex_tx_ba_stream_tbl *mwifiex_get_ba_tbl(struct mwifiex_private *priv, int tid, u8 *ra); -void mwifiex_11n_create_tx_ba_stream_tbl(struct mwifiex_private *priv, u8 *ra, - int tid, - enum mwifiex_ba_status ba_status); +void mwifiex_create_ba_tbl(struct mwifiex_private *priv, u8 *ra, int tid, + enum mwifiex_ba_status ba_status); int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac); int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac, int initiator); @@ -154,7 +153,7 @@ mwifiex_is_ba_stream_setup(struct mwifiex_private *priv, { struct mwifiex_tx_ba_stream_tbl *tx_tbl; - tx_tbl = mwifiex_11n_get_tx_ba_stream_tbl(priv, tid, ptr->ra); + tx_tbl = mwifiex_get_ba_tbl(priv, tid, ptr->ra); if (tx_tbl && IS_BASTREAM_SETUP(tx_tbl)) return true; diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c index 681d3f2a4c28..ad41fab970b5 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c @@ -480,8 +480,8 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, * The TID/TA are taken from del BA event body. */ void -mwifiex_11n_delete_ba_stream_tbl(struct mwifiex_private *priv, int tid, - u8 *peer_mac, u8 type, int initiator) +mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, + u8 type, int initiator) { struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; struct mwifiex_tx_ba_stream_tbl *ptx_tbl; @@ -506,7 +506,7 @@ mwifiex_11n_delete_ba_stream_tbl(struct mwifiex_private *priv, int tid, } mwifiex_11n_delete_rx_reorder_tbl_entry(priv, rx_reor_tbl_ptr); } else { - ptx_tbl = mwifiex_11n_get_tx_ba_stream_tbl(priv, tid, peer_mac); + ptx_tbl = mwifiex_get_ba_tbl(priv, tid, peer_mac); if (!ptx_tbl) { dev_dbg(priv->adapter->dev, "event: TID, RA not found in table\n"); diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.h b/drivers/net/wireless/mwifiex/11n_rxreorder.h index 033c8adbdcd4..f1bffebabc60 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.h +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.h @@ -41,9 +41,8 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *, u16 seqNum, u16 tid, u8 *ta, u8 pkttype, void *payload); -void mwifiex_11n_delete_ba_stream_tbl(struct mwifiex_private *priv, int Tid, - u8 *PeerMACAddr, u8 type, - int initiator); +void mwifiex_del_ba_tbl(struct mwifiex_private *priv, int Tid, + u8 *PeerMACAddr, u8 type, int initiator); void mwifiex_11n_ba_stream_timeout(struct mwifiex_private *priv, struct host_cmd_ds_11n_batimeout *event); int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 6dc116647411..58748b143609 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -462,9 +462,9 @@ struct mwifiex_private { }; enum mwifiex_ba_status { - BA_STREAM_NOT_SETUP = 0, - BA_STREAM_SETUP_INPROGRESS, - BA_STREAM_SETUP_COMPLETE + BA_SETUP_NONE = 0, + BA_SETUP_INPROGRESS, + BA_SETUP_COMPLETE }; struct mwifiex_tx_ba_stream_tbl { diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index 75f79ef9f6cf..5757ebd2163a 100644 --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c @@ -1218,15 +1218,13 @@ mwifiex_dequeue_tx_packet(struct mwifiex_adapter *adapter) } else { if (mwifiex_is_ampdu_allowed(priv, tid)) { if (mwifiex_space_avail_for_new_ba_stream(adapter)) { - mwifiex_11n_create_tx_ba_stream_tbl(priv, - ptr->ra, tid, - BA_STREAM_SETUP_INPROGRESS); + mwifiex_create_ba_tbl(priv, ptr->ra, tid, + BA_SETUP_INPROGRESS); mwifiex_send_addba(priv, tid, ptr->ra); } else if (mwifiex_find_stream_to_delete (priv, tid, &tid_del, ra)) { - mwifiex_11n_create_tx_ba_stream_tbl(priv, - ptr->ra, tid, - BA_STREAM_SETUP_INPROGRESS); + mwifiex_create_ba_tbl(priv, ptr->ra, tid, + BA_SETUP_INPROGRESS); mwifiex_send_delba(priv, tid_del, ra, 1); } } -- GitLab From 985d68a3bb7678d6b4d5175f52d70b7f3abb992a Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 12 Mar 2012 19:35:09 -0700 Subject: [PATCH 1716/1846] mwifiex: rearrange switch statement Fixing coding style by rearranging the switch statement Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sta_cmdresp.c | 198 +++++++++------------ 1 file changed, 87 insertions(+), 111 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c index 0d8618a8443f..3f13ff0cd262 100644 --- a/drivers/net/wireless/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c @@ -420,38 +420,34 @@ static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv, switch (action) { case HostCmd_ACT_GEN_GET: - { - pg_tlv_hdr = - (struct mwifiex_types_power_group *) ((u8 *) - txp_cfg + - sizeof - (struct - host_cmd_ds_txpwr_cfg)); - pg = (struct mwifiex_power_group *) ((u8 *) - pg_tlv_hdr + - sizeof(struct - mwifiex_types_power_group)); - if (adapter->hw_status == - MWIFIEX_HW_STATUS_INITIALIZING) - mwifiex_get_power_level(priv, txp_cfg); - priv->tx_power_level = (u16) pg->power_min; - break; - } + pg_tlv_hdr = (struct mwifiex_types_power_group *) + ((u8 *) txp_cfg + + sizeof(struct host_cmd_ds_txpwr_cfg)); + + pg = (struct mwifiex_power_group *) + ((u8 *) pg_tlv_hdr + + sizeof(struct mwifiex_types_power_group)); + + if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) + mwifiex_get_power_level(priv, txp_cfg); + + priv->tx_power_level = (u16) pg->power_min; + break; + case HostCmd_ACT_GEN_SET: - if (le32_to_cpu(txp_cfg->mode)) { - pg_tlv_hdr = - (struct mwifiex_types_power_group *) ((u8 *) - txp_cfg + - sizeof - (struct - host_cmd_ds_txpwr_cfg)); - pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr - + - sizeof(struct - mwifiex_types_power_group)); - if (pg->power_max == pg->power_min) - priv->tx_power_level = (u16) pg->power_min; - } + if (!le32_to_cpu(txp_cfg->mode)) + break; + + pg_tlv_hdr = (struct mwifiex_types_power_group *) + ((u8 *) txp_cfg + + sizeof(struct host_cmd_ds_txpwr_cfg)); + + pg = (struct mwifiex_power_group *) + ((u8 *) pg_tlv_hdr + + sizeof(struct mwifiex_types_power_group)); + + if (pg->power_max == pg->power_min) + priv->tx_power_level = (u16) pg->power_min; break; default: dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n", @@ -679,90 +675,70 @@ static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp, { struct mwifiex_ds_reg_rw *reg_rw; struct mwifiex_ds_read_eeprom *eeprom; + union reg { + struct host_cmd_ds_mac_reg_access *mac; + struct host_cmd_ds_bbp_reg_access *bbp; + struct host_cmd_ds_rf_reg_access *rf; + struct host_cmd_ds_pmic_reg_access *pmic; + struct host_cmd_ds_802_11_eeprom_access *eeprom; + } r; + + if (!data_buf) + return 0; - if (data_buf) { - reg_rw = data_buf; - eeprom = data_buf; - switch (type) { - case HostCmd_CMD_MAC_REG_ACCESS: - { - struct host_cmd_ds_mac_reg_access *reg; - reg = (struct host_cmd_ds_mac_reg_access *) - &resp->params.mac_reg; - reg_rw->offset = cpu_to_le32( - (u32) le16_to_cpu(reg->offset)); - reg_rw->value = reg->value; - break; - } - case HostCmd_CMD_BBP_REG_ACCESS: - { - struct host_cmd_ds_bbp_reg_access *reg; - reg = (struct host_cmd_ds_bbp_reg_access *) - &resp->params.bbp_reg; - reg_rw->offset = cpu_to_le32( - (u32) le16_to_cpu(reg->offset)); - reg_rw->value = cpu_to_le32((u32) reg->value); - break; - } + reg_rw = data_buf; + eeprom = data_buf; + switch (type) { + case HostCmd_CMD_MAC_REG_ACCESS: + r.mac = (struct host_cmd_ds_mac_reg_access *) + &resp->params.mac_reg; + reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset)); + reg_rw->value = r.mac->value; + break; + case HostCmd_CMD_BBP_REG_ACCESS: + r.bbp = (struct host_cmd_ds_bbp_reg_access *) + &resp->params.bbp_reg; + reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset)); + reg_rw->value = cpu_to_le32((u32) r.bbp->value); + break; - case HostCmd_CMD_RF_REG_ACCESS: - { - struct host_cmd_ds_rf_reg_access *reg; - reg = (struct host_cmd_ds_rf_reg_access *) - &resp->params.rf_reg; - reg_rw->offset = cpu_to_le32( - (u32) le16_to_cpu(reg->offset)); - reg_rw->value = cpu_to_le32((u32) reg->value); - break; - } - case HostCmd_CMD_PMIC_REG_ACCESS: - { - struct host_cmd_ds_pmic_reg_access *reg; - reg = (struct host_cmd_ds_pmic_reg_access *) - &resp->params.pmic_reg; - reg_rw->offset = cpu_to_le32( - (u32) le16_to_cpu(reg->offset)); - reg_rw->value = cpu_to_le32((u32) reg->value); - break; - } - case HostCmd_CMD_CAU_REG_ACCESS: - { - struct host_cmd_ds_rf_reg_access *reg; - reg = (struct host_cmd_ds_rf_reg_access *) - &resp->params.rf_reg; - reg_rw->offset = cpu_to_le32( - (u32) le16_to_cpu(reg->offset)); - reg_rw->value = cpu_to_le32((u32) reg->value); - break; - } - case HostCmd_CMD_802_11_EEPROM_ACCESS: - { - struct host_cmd_ds_802_11_eeprom_access - *cmd_eeprom = - (struct host_cmd_ds_802_11_eeprom_access - *) &resp->params.eeprom; - pr_debug("info: EEPROM read len=%x\n", - cmd_eeprom->byte_count); - if (le16_to_cpu(eeprom->byte_count) < - le16_to_cpu( - cmd_eeprom->byte_count)) { - eeprom->byte_count = cpu_to_le16(0); - pr_debug("info: EEPROM read " - "length is too big\n"); - return -1; - } - eeprom->offset = cmd_eeprom->offset; - eeprom->byte_count = cmd_eeprom->byte_count; - if (le16_to_cpu(eeprom->byte_count) > 0) - memcpy(&eeprom->value, - &cmd_eeprom->value, - le16_to_cpu(eeprom->byte_count)); - - break; - } - default: + case HostCmd_CMD_RF_REG_ACCESS: + r.rf = (struct host_cmd_ds_rf_reg_access *) + &resp->params.rf_reg; + reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset)); + reg_rw->value = cpu_to_le32((u32) r.bbp->value); + break; + case HostCmd_CMD_PMIC_REG_ACCESS: + r.pmic = (struct host_cmd_ds_pmic_reg_access *) + &resp->params.pmic_reg; + reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset)); + reg_rw->value = cpu_to_le32((u32) r.pmic->value); + break; + case HostCmd_CMD_CAU_REG_ACCESS: + r.rf = (struct host_cmd_ds_rf_reg_access *) + &resp->params.rf_reg; + reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset)); + reg_rw->value = cpu_to_le32((u32) r.rf->value); + break; + case HostCmd_CMD_802_11_EEPROM_ACCESS: + r.eeprom = (struct host_cmd_ds_802_11_eeprom_access *) + &resp->params.eeprom; + pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count); + if (le16_to_cpu(eeprom->byte_count) < + le16_to_cpu(r.eeprom->byte_count)) { + eeprom->byte_count = cpu_to_le16(0); + pr_debug("info: EEPROM read length is too big\n"); return -1; } + eeprom->offset = r.eeprom->offset; + eeprom->byte_count = r.eeprom->byte_count; + if (le16_to_cpu(eeprom->byte_count) > 0) + memcpy(&eeprom->value, &r.eeprom->value, + le16_to_cpu(r.eeprom->byte_count)); + + break; + default: + return -1; } return 0; } -- GitLab From 6685d109f4b60604fd206cff01355094a2e3b419 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 12 Mar 2012 19:35:10 -0700 Subject: [PATCH 1717/1846] mwifiex: merge functions to derive cfp by chan & freq in one There exist different functions with very long names to derive the channel frequency and power tripplet based on band and channel/freq. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfp.c | 86 +++++++++--------------- drivers/net/wireless/mwifiex/join.c | 9 ++- drivers/net/wireless/mwifiex/main.h | 9 +-- drivers/net/wireless/mwifiex/scan.c | 11 ++- drivers/net/wireless/mwifiex/sta_ioctl.c | 13 ++-- 5 files changed, 46 insertions(+), 82 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfp.c b/drivers/net/wireless/mwifiex/cfp.c index 1782a77f15dc..7541d9a4a6ed 100644 --- a/drivers/net/wireless/mwifiex/cfp.c +++ b/drivers/net/wireless/mwifiex/cfp.c @@ -169,59 +169,18 @@ u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, u8 *rates) /* * This function locates the Channel-Frequency-Power triplet based upon - * band and channel parameters. + * band and channel/frequency parameters. */ struct mwifiex_chan_freq_power * -mwifiex_get_cfp_by_band_and_channel_from_cfg80211(struct mwifiex_private - *priv, u8 band, u16 channel) +mwifiex_get_cfp(struct mwifiex_private *priv, u8 band, u16 channel, u32 freq) { struct mwifiex_chan_freq_power *cfp = NULL; struct ieee80211_supported_band *sband; - struct ieee80211_channel *ch; + struct ieee80211_channel *ch = NULL; int i; - if (mwifiex_band_to_radio_type(band) == HostCmd_SCAN_RADIO_TYPE_BG) - sband = priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ]; - else - sband = priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ]; - - if (!sband) { - dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d" - " & channel %d\n", __func__, band, channel); + if (!channel && !freq) return cfp; - } - - for (i = 0; i < sband->n_channels; i++) { - ch = &sband->channels[i]; - if (((ch->hw_value == channel) || - (channel == FIRST_VALID_CHANNEL)) - && !(ch->flags & IEEE80211_CHAN_DISABLED)) { - priv->cfp.channel = channel; - priv->cfp.freq = ch->center_freq; - priv->cfp.max_tx_power = ch->max_power; - cfp = &priv->cfp; - break; - } - } - if (i == sband->n_channels) - dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d" - " & channel %d\n", __func__, band, channel); - - return cfp; -} - -/* - * This function locates the Channel-Frequency-Power triplet based upon - * band and frequency parameters. - */ -struct mwifiex_chan_freq_power * -mwifiex_get_cfp_by_band_and_freq_from_cfg80211(struct mwifiex_private *priv, - u8 band, u32 freq) -{ - struct mwifiex_chan_freq_power *cfp = NULL; - struct ieee80211_supported_band *sband; - struct ieee80211_channel *ch; - int i; if (mwifiex_band_to_radio_type(band) == HostCmd_SCAN_RADIO_TYPE_BG) sband = priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ]; @@ -229,25 +188,40 @@ mwifiex_get_cfp_by_band_and_freq_from_cfg80211(struct mwifiex_private *priv, sband = priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ]; if (!sband) { - dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d" - " & freq %d\n", __func__, band, freq); + dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d\n", + __func__, band); return cfp; } for (i = 0; i < sband->n_channels; i++) { ch = &sband->channels[i]; - if ((ch->center_freq == freq) && - !(ch->flags & IEEE80211_CHAN_DISABLED)) { - priv->cfp.channel = ch->hw_value; - priv->cfp.freq = freq; - priv->cfp.max_tx_power = ch->max_power; - cfp = &priv->cfp; - break; + + if (ch->flags & IEEE80211_CHAN_DISABLED) + continue; + + if (freq) { + if (ch->center_freq == freq) + break; + } else { + /* find by valid channel*/ + if (ch->hw_value == channel || + channel == FIRST_VALID_CHANNEL) + break; } } - if (i == sband->n_channels) + if (i == sband->n_channels) { dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d" - " & freq %d\n", __func__, band, freq); + " & channel=%d freq=%d\n", __func__, band, channel, + freq); + } else { + if (!ch) + return cfp; + + priv->cfp.channel = ch->hw_value; + priv->cfp.freq = ch->center_freq; + priv->cfp.max_tx_power = ch->max_power; + cfp = &priv->cfp; + } return cfp; } diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index bce9991612c8..803275f58c78 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -777,12 +777,11 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, adhoc_start->phy_param_set.ds_param_set.element_id = DS_PARA_IE_ID; adhoc_start->phy_param_set.ds_param_set.len = DS_PARA_IE_LEN; - if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211 - (priv, adapter->adhoc_start_band, (u16) - priv->adhoc_channel)) { + if (!mwifiex_get_cfp(priv, adapter->adhoc_start_band, + (u16) priv->adhoc_channel, 0)) { struct mwifiex_chan_freq_power *cfp; - cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211(priv, - adapter->adhoc_start_band, FIRST_VALID_CHANNEL); + cfp = mwifiex_get_cfp(priv, adapter->adhoc_start_band, + FIRST_VALID_CHANNEL, 0); if (cfp) priv->adhoc_channel = (u8) cfp->channel; } diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 58748b143609..c0df48f63e11 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -771,13 +771,8 @@ int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, struct host_cmd_ds_command *resp); int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd); -struct mwifiex_chan_freq_power * - mwifiex_get_cfp_by_band_and_channel_from_cfg80211( - struct mwifiex_private *priv, - u8 band, u16 channel); -struct mwifiex_chan_freq_power *mwifiex_get_cfp_by_band_and_freq_from_cfg80211( - struct mwifiex_private *priv, - u8 band, u32 freq); +struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv, + u8 band, u16 channel, u32 freq); u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv, u8 index, u8 ht_info); u32 mwifiex_find_freq_from_band_chan(u8, u8); diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index fd0302fe5bd8..0a0c2890adfa 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -1434,8 +1434,8 @@ int mwifiex_check_network_compatibility(struct mwifiex_private *priv, if (!bss_desc) return -1; - if ((mwifiex_get_cfp_by_band_and_channel_from_cfg80211(priv, - (u8) bss_desc->bss_band, (u16) bss_desc->channel))) { + if ((mwifiex_get_cfp(priv, (u8) bss_desc->bss_band, + (u16) bss_desc->channel, 0))) { switch (priv->bss_mode) { case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_ADHOC: @@ -1625,7 +1625,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, s32 rssi; const u8 *ie_buf; size_t ie_len; - int channel = -1; + u16 channel = 0; u64 network_tsf = 0; u16 beacon_size = 0; u32 curr_bcn_bytes; @@ -1723,7 +1723,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE], sizeof(network_tsf)); - if (channel != -1) { + if (channel) { struct ieee80211_channel *chan; u8 band; @@ -1736,8 +1736,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, & (BIT(0) | BIT(1))); } - cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211( - priv, (u8)band, (u16)channel); + cfp = mwifiex_get_cfp(priv, band, channel, 0); freq = cfp ? cfp->freq : 0; diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 0ae1209646c1..a3d79f4a6192 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -529,11 +529,10 @@ int mwifiex_bss_set_channel(struct mwifiex_private *priv, adapter->adhoc_start_band = BAND_G | BAND_B; if (chan->channel) { if (chan->channel <= MAX_CHANNEL_BAND_BG) - cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211 - (priv, 0, (u16) chan->channel); + cfp = mwifiex_get_cfp(priv, 0, (u16) chan->channel, 0); if (!cfp) { - cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211 - (priv, BAND_A, (u16) chan->channel); + cfp = mwifiex_get_cfp(priv, BAND_A, + (u16) chan->channel, 0); if (cfp) { if (adapter->adhoc_11n_enabled) adapter->adhoc_start_band = BAND_A @@ -544,11 +543,9 @@ int mwifiex_bss_set_channel(struct mwifiex_private *priv, } } else { if (chan->freq <= MAX_FREQUENCY_BAND_BG) - cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211( - priv, 0, chan->freq); + cfp = mwifiex_get_cfp(priv, 0, 0, chan->freq); if (!cfp) { - cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211 - (priv, BAND_A, chan->freq); + cfp = mwifiex_get_cfp(priv, BAND_A, 0, chan->freq); if (cfp) { if (adapter->adhoc_11n_enabled) adapter->adhoc_start_band = BAND_A -- GitLab From e7891ba2de9a67f22e5fd2a137f98d89cfb71348 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 12 Mar 2012 19:35:11 -0700 Subject: [PATCH 1718/1846] mwifiex: use usleep_range instead of udelay For the delay of 10 uSec or more usleep_range is prefered. Unlike udelay, sleep_range avoids large number of undesired interrupts. Ref Documentation/timers/timers-howto.txt Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/pcie.c | 6 +++--- drivers/net/wireless/mwifiex/sdio.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 405350940a45..1033f00a775f 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -288,7 +288,7 @@ static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) while (mwifiex_pcie_ok_to_access_hw(adapter)) { i++; - udelay(10); + usleep_range(10, 20); /* 50ms max wait */ if (i == 50000) break; @@ -1088,7 +1088,7 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) card->cmdrsp_buf->len); while (mwifiex_pcie_ok_to_access_hw(adapter) && (count++ < 10)) - udelay(50); + usleep_range(50, 60); } else { dev_err(adapter->dev, "There is no command but " "got cmdrsp\n"); @@ -1337,7 +1337,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, } if (len) break; - udelay(10); + usleep_range(10, 20); } if (!len) { diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index d39d8457f252..fe6fbc123b2e 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -583,7 +583,7 @@ mwifiex_sdio_poll_card_status(struct mwifiex_adapter *adapter, u8 bits) else if ((cs & bits) == bits) return 0; - udelay(10); + usleep_range(10, 20); } dev_err(adapter->dev, "poll card status failed, tries = %d\n", @@ -761,7 +761,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, if (len) break; - udelay(10); + usleep_range(10, 20); } if (!len) { -- GitLab From bb7de2bad5cb527e5fdc6b64d7f5d6e5009f2962 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 12 Mar 2012 19:35:12 -0700 Subject: [PATCH 1719/1846] mwifiex: rearrange if and else blocks to avoid extra indentation This adds better readability. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/11n_rxreorder.c | 15 ++-- drivers/net/wireless/mwifiex/sta_cmdresp.c | 93 +++++++++----------- drivers/net/wireless/mwifiex/wmm.c | 30 ++++--- 3 files changed, 68 insertions(+), 70 deletions(-) diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c index ad41fab970b5..491cd85cb6f2 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c @@ -205,14 +205,17 @@ mwifiex_flush_data(unsigned long context) int start_win; start_win = mwifiex_11n_find_last_seq_num(reorder_cnxt->ptr); - if (start_win >= 0) { - dev_dbg(reorder_cnxt->priv->adapter->dev, - "info: flush data %d\n", start_win); + + if (start_win < 0) + return; + + dev_dbg(reorder_cnxt->priv->adapter->dev, "info: flush data %d\n", + start_win); mwifiex_11n_dispatch_pkt_until_start_win(reorder_cnxt->priv, reorder_cnxt->ptr, - ((reorder_cnxt->ptr->start_win + - start_win + 1) & (MAX_TID_VALUE - 1))); - } + ((reorder_cnxt->ptr->start_win + + start_win + 1) & + (MAX_TID_VALUE - 1))); } /* diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c index 3f13ff0cd262..a2a9c513e26b 100644 --- a/drivers/net/wireless/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c @@ -327,31 +327,26 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, HostCmd_CMD_802_11_TX_RATE_QUERY, HostCmd_ACT_GEN_GET, 0, NULL); - if (ds_rate) { - if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) { - if (priv->is_data_rate_auto) { - ds_rate->is_rate_auto = 1; - } else { - ds_rate->rate = mwifiex_get_rate_index(priv-> - bitmap_rates, - sizeof(priv-> - bitmap_rates)); - if (ds_rate->rate >= - MWIFIEX_RATE_BITMAP_OFDM0 - && ds_rate->rate <= - MWIFIEX_RATE_BITMAP_OFDM7) - ds_rate->rate -= - (MWIFIEX_RATE_BITMAP_OFDM0 - - MWIFIEX_RATE_INDEX_OFDM0); - if (ds_rate->rate >= - MWIFIEX_RATE_BITMAP_MCS0 - && ds_rate->rate <= - MWIFIEX_RATE_BITMAP_MCS127) - ds_rate->rate -= - (MWIFIEX_RATE_BITMAP_MCS0 - - MWIFIEX_RATE_INDEX_MCS0); - } - } + if (!ds_rate) + return ret; + + if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) { + if (priv->is_data_rate_auto) { + ds_rate->is_rate_auto = 1; + return ret; + } + ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates, + sizeof(priv->bitmap_rates)); + + if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 && + ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7) + ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 - + MWIFIEX_RATE_INDEX_OFDM0); + + if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 && + ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127) + ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 - + MWIFIEX_RATE_INDEX_MCS0); } return ret; @@ -369,34 +364,32 @@ static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf) struct mwifiex_types_power_group *pg_tlv_hdr; struct mwifiex_power_group *pg; - if (data_buf) { - pg_tlv_hdr = - (struct mwifiex_types_power_group *) ((u8 *) data_buf - + sizeof(struct host_cmd_ds_txpwr_cfg)); - pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr + - sizeof(struct mwifiex_types_power_group)); - length = pg_tlv_hdr->length; - if (length > 0) { + if (!data_buf) + return -1; + + pg_tlv_hdr = (struct mwifiex_types_power_group *) + ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg)); + pg = (struct mwifiex_power_group *) + ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group)); + length = pg_tlv_hdr->length; + if (length > 0) { + max_power = pg->power_max; + min_power = pg->power_min; + length -= sizeof(struct mwifiex_power_group); + } + while (length) { + pg++; + if (max_power < pg->power_max) max_power = pg->power_max; - min_power = pg->power_min; - length -= sizeof(struct mwifiex_power_group); - } - while (length) { - pg++; - if (max_power < pg->power_max) - max_power = pg->power_max; - if (min_power > pg->power_min) - min_power = pg->power_min; + if (min_power > pg->power_min) + min_power = pg->power_min; - length -= sizeof(struct mwifiex_power_group); - } - if (pg_tlv_hdr->length > 0) { - priv->min_tx_power_level = (u8) min_power; - priv->max_tx_power_level = (u8) max_power; - } - } else { - return -1; + length -= sizeof(struct mwifiex_power_group); + } + if (pg_tlv_hdr->length > 0) { + priv->min_tx_power_level = (u8) min_power; + priv->max_tx_power_level = (u8) max_power; } return 0; diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index 5757ebd2163a..6f0cc210f79a 100644 --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c @@ -850,6 +850,7 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter, struct mwifiex_ra_list_tbl *ptr, *head; struct mwifiex_bss_prio_node *bssprio_node, *bssprio_head; struct mwifiex_tid_tbl *tid_ptr; + atomic_t *hqp; int is_list_empty; unsigned long flags; int i, j; @@ -879,12 +880,8 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter, } do { - atomic_t *hqp; - spinlock_t *lock; - priv_tmp = bssprio_node->priv; hqp = &priv_tmp->wmm.highest_queued_prio; - lock = &priv_tmp->wmm.ra_list_spinlock; for (i = atomic_read(hqp); i >= LOW_PRIO_TID; --i) { @@ -923,16 +920,10 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter, do { is_list_empty = skb_queue_empty(&ptr->skb_head); - if (!is_list_empty) { - spin_lock_irqsave(lock, flags); - if (atomic_read(hqp) > i) - atomic_set(hqp, i); - spin_unlock_irqrestore(lock, - flags); - *priv = priv_tmp; - *tid = tos_to_tid[i]; - return ptr; - } + + if (!is_list_empty) + goto found; + /* Get next ra */ ptr = list_first_entry(&ptr->list, struct mwifiex_ra_list_tbl, @@ -969,6 +960,17 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter, } while (bssprio_node != bssprio_head); } return NULL; + +found: + spin_lock_irqsave(&priv_tmp->wmm.ra_list_spinlock, flags); + if (atomic_read(hqp) > i) + atomic_set(hqp, i); + spin_unlock_irqrestore(&priv_tmp->wmm.ra_list_spinlock, flags); + + *priv = priv_tmp; + *tid = tos_to_tid[i]; + + return ptr; } /* -- GitLab From 8c00228e98bd2c8ab92b6f364f196cb60a7ff76d Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Mon, 12 Mar 2012 19:35:13 -0700 Subject: [PATCH 1720/1846] mwifiex: rename fuctions and variables for better readability Renaming the long fuctions and variable names from 11n_rxreoder.c file to shorter ones for better readability. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/11n_rxreorder.c | 160 +++++++++---------- 1 file changed, 73 insertions(+), 87 deletions(-) diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c index 491cd85cb6f2..06f5d3684027 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c @@ -27,31 +27,31 @@ #include "11n_rxreorder.h" /* - * This function dispatches all packets in the Rx reorder table. + * This function dispatches all packets in the Rx reorder table until the + * start window. * * There could be holes in the buffer, which are skipped by the function. * Since the buffer is linear, the function uses rotation to simulate * circular buffer. */ static void -mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, - struct mwifiex_rx_reorder_tbl - *rx_reor_tbl_ptr, int start_win) +mwifiex_11n_dispatch_pkt(struct mwifiex_private *priv, + struct mwifiex_rx_reorder_tbl *tbl, int start_win) { - int no_pkt_to_send, i; + int pkt_to_send, i; void *rx_tmp_ptr; unsigned long flags; - no_pkt_to_send = (start_win > rx_reor_tbl_ptr->start_win) ? - min((start_win - rx_reor_tbl_ptr->start_win), - rx_reor_tbl_ptr->win_size) : rx_reor_tbl_ptr->win_size; + pkt_to_send = (start_win > tbl->start_win) ? + min((start_win - tbl->start_win), tbl->win_size) : + tbl->win_size; - for (i = 0; i < no_pkt_to_send; ++i) { + for (i = 0; i < pkt_to_send; ++i) { spin_lock_irqsave(&priv->rx_pkt_lock, flags); rx_tmp_ptr = NULL; - if (rx_reor_tbl_ptr->rx_reorder_ptr[i]) { - rx_tmp_ptr = rx_reor_tbl_ptr->rx_reorder_ptr[i]; - rx_reor_tbl_ptr->rx_reorder_ptr[i] = NULL; + if (tbl->rx_reorder_ptr[i]) { + rx_tmp_ptr = tbl->rx_reorder_ptr[i]; + tbl->rx_reorder_ptr[i] = NULL; } spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); if (rx_tmp_ptr) @@ -63,13 +63,12 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, * We don't have a circular buffer, hence use rotation to simulate * circular buffer */ - for (i = 0; i < rx_reor_tbl_ptr->win_size - no_pkt_to_send; ++i) { - rx_reor_tbl_ptr->rx_reorder_ptr[i] = - rx_reor_tbl_ptr->rx_reorder_ptr[no_pkt_to_send + i]; - rx_reor_tbl_ptr->rx_reorder_ptr[no_pkt_to_send + i] = NULL; + for (i = 0; i < tbl->win_size - pkt_to_send; ++i) { + tbl->rx_reorder_ptr[i] = tbl->rx_reorder_ptr[pkt_to_send + i]; + tbl->rx_reorder_ptr[pkt_to_send + i] = NULL; } - rx_reor_tbl_ptr->start_win = start_win; + tbl->start_win = start_win; spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); } @@ -83,20 +82,20 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, */ static void mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, - struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr) + struct mwifiex_rx_reorder_tbl *tbl) { int i, j, xchg; void *rx_tmp_ptr; unsigned long flags; - for (i = 0; i < rx_reor_tbl_ptr->win_size; ++i) { + for (i = 0; i < tbl->win_size; ++i) { spin_lock_irqsave(&priv->rx_pkt_lock, flags); - if (!rx_reor_tbl_ptr->rx_reorder_ptr[i]) { + if (!tbl->rx_reorder_ptr[i]) { spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); break; } - rx_tmp_ptr = rx_reor_tbl_ptr->rx_reorder_ptr[i]; - rx_reor_tbl_ptr->rx_reorder_ptr[i] = NULL; + rx_tmp_ptr = tbl->rx_reorder_ptr[i]; + tbl->rx_reorder_ptr[i] = NULL; spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); mwifiex_process_rx_packet(priv->adapter, rx_tmp_ptr); } @@ -107,15 +106,13 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, * circular buffer */ if (i > 0) { - xchg = rx_reor_tbl_ptr->win_size - i; + xchg = tbl->win_size - i; for (j = 0; j < xchg; ++j) { - rx_reor_tbl_ptr->rx_reorder_ptr[j] = - rx_reor_tbl_ptr->rx_reorder_ptr[i + j]; - rx_reor_tbl_ptr->rx_reorder_ptr[i + j] = NULL; + tbl->rx_reorder_ptr[j] = tbl->rx_reorder_ptr[i + j]; + tbl->rx_reorder_ptr[i + j] = NULL; } } - rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i) - &(MAX_TID_VALUE - 1); + tbl->start_win = (tbl->start_win + i) & (MAX_TID_VALUE - 1); spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); } @@ -126,28 +123,25 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, * pending packets in the Rx reorder table before deletion. */ static void -mwifiex_11n_delete_rx_reorder_tbl_entry(struct mwifiex_private *priv, - struct mwifiex_rx_reorder_tbl - *rx_reor_tbl_ptr) +mwifiex_del_rx_reorder_entry(struct mwifiex_private *priv, + struct mwifiex_rx_reorder_tbl *tbl) { unsigned long flags; - if (!rx_reor_tbl_ptr) + if (!tbl) return; - mwifiex_11n_dispatch_pkt_until_start_win(priv, rx_reor_tbl_ptr, - (rx_reor_tbl_ptr->start_win + - rx_reor_tbl_ptr->win_size) - &(MAX_TID_VALUE - 1)); + mwifiex_11n_dispatch_pkt(priv, tbl, (tbl->start_win + tbl->win_size) & + (MAX_TID_VALUE - 1)); - del_timer(&rx_reor_tbl_ptr->timer_context.timer); + del_timer(&tbl->timer_context.timer); spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); - list_del(&rx_reor_tbl_ptr->list); + list_del(&tbl->list); spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); - kfree(rx_reor_tbl_ptr->rx_reorder_ptr); - kfree(rx_reor_tbl_ptr); + kfree(tbl->rx_reorder_ptr); + kfree(tbl); } /* @@ -157,16 +151,15 @@ mwifiex_11n_delete_rx_reorder_tbl_entry(struct mwifiex_private *priv, static struct mwifiex_rx_reorder_tbl * mwifiex_11n_get_rx_reorder_tbl(struct mwifiex_private *priv, int tid, u8 *ta) { - struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; + struct mwifiex_rx_reorder_tbl *tbl; unsigned long flags; spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); - list_for_each_entry(rx_reor_tbl_ptr, &priv->rx_reorder_tbl_ptr, list) { - if ((!memcmp(rx_reor_tbl_ptr->ta, ta, ETH_ALEN)) - && (rx_reor_tbl_ptr->tid == tid)) { + list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list) { + if (!memcmp(tbl->ta, ta, ETH_ALEN) && tbl->tid == tid) { spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); - return rx_reor_tbl_ptr; + return tbl; } } spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); @@ -200,22 +193,19 @@ mwifiex_11n_find_last_seq_num(struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr) static void mwifiex_flush_data(unsigned long context) { - struct reorder_tmr_cnxt *reorder_cnxt = + struct reorder_tmr_cnxt *ctx = (struct reorder_tmr_cnxt *) context; int start_win; - start_win = mwifiex_11n_find_last_seq_num(reorder_cnxt->ptr); + start_win = mwifiex_11n_find_last_seq_num(ctx->ptr); if (start_win < 0) return; - dev_dbg(reorder_cnxt->priv->adapter->dev, "info: flush data %d\n", - start_win); - mwifiex_11n_dispatch_pkt_until_start_win(reorder_cnxt->priv, - reorder_cnxt->ptr, - ((reorder_cnxt->ptr->start_win - + start_win + 1) & - (MAX_TID_VALUE - 1))); + dev_dbg(ctx->priv->adapter->dev, "info: flush data %d\n", start_win); + mwifiex_11n_dispatch_pkt(ctx->priv, ctx->ptr, + (ctx->ptr->start_win + start_win + 1) & + (MAX_TID_VALUE - 1)); } /* @@ -233,7 +223,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, int tid, int win_size, int seq_num) { int i; - struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr, *new_node; + struct mwifiex_rx_reorder_tbl *tbl, *new_node; u16 last_seq = 0; unsigned long flags; @@ -241,13 +231,12 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, * If we get a TID, ta pair which is already present dispatch all the * the packets and move the window size until the ssn */ - rx_reor_tbl_ptr = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); - if (rx_reor_tbl_ptr) { - mwifiex_11n_dispatch_pkt_until_start_win(priv, rx_reor_tbl_ptr, - seq_num); + tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); + if (tbl) { + mwifiex_11n_dispatch_pkt(priv, tbl, seq_num); return; } - /* if !rx_reor_tbl_ptr then create one */ + /* if !tbl then create one */ new_node = kzalloc(sizeof(struct mwifiex_rx_reorder_tbl), GFP_KERNEL); if (!new_node) { dev_err(priv->adapter->dev, "%s: failed to alloc new_node\n", @@ -404,24 +393,23 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, u16 seq_num, u16 tid, u8 *ta, u8 pkt_type, void *payload) { - struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; + struct mwifiex_rx_reorder_tbl *tbl; int start_win, end_win, win_size; u16 pkt_index; - rx_reor_tbl_ptr = - mwifiex_11n_get_rx_reorder_tbl((struct mwifiex_private *) priv, - tid, ta); - if (!rx_reor_tbl_ptr) { + tbl = mwifiex_11n_get_rx_reorder_tbl((struct mwifiex_private *) priv, + tid, ta); + if (!tbl) { if (pkt_type != PKT_TYPE_BAR) mwifiex_process_rx_packet(priv->adapter, payload); return 0; } - start_win = rx_reor_tbl_ptr->start_win; - win_size = rx_reor_tbl_ptr->win_size; + start_win = tbl->start_win; + win_size = tbl->win_size; end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1); - del_timer(&rx_reor_tbl_ptr->timer_context.timer); - mod_timer(&rx_reor_tbl_ptr->timer_context.timer, jiffies - + (MIN_FLUSH_TIMER_MS * win_size * HZ) / 1000); + del_timer(&tbl->timer_context.timer); + mod_timer(&tbl->timer_context.timer, + jiffies + (MIN_FLUSH_TIMER_MS * win_size * HZ) / 1000); /* * If seq_num is less then starting win then ignore and drop the @@ -452,8 +440,7 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, start_win = (end_win - win_size) + 1; else start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1; - mwifiex_11n_dispatch_pkt_until_start_win(priv, - rx_reor_tbl_ptr, start_win); + mwifiex_11n_dispatch_pkt(priv, tbl, start_win); } if (pkt_type != PKT_TYPE_BAR) { @@ -462,17 +449,17 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, else pkt_index = (seq_num+MAX_TID_VALUE) - start_win; - if (rx_reor_tbl_ptr->rx_reorder_ptr[pkt_index]) + if (tbl->rx_reorder_ptr[pkt_index]) return -1; - rx_reor_tbl_ptr->rx_reorder_ptr[pkt_index] = payload; + tbl->rx_reorder_ptr[pkt_index] = payload; } /* * Dispatch all packets sequentially from start_win until a * hole is found and adjust the start_win appropriately */ - mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); + mwifiex_11n_scan_and_dispatch(priv, tbl); return 0; } @@ -486,7 +473,7 @@ void mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, u8 type, int initiator) { - struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; + struct mwifiex_rx_reorder_tbl *tbl; struct mwifiex_tx_ba_stream_tbl *ptx_tbl; u8 cleanup_rx_reorder_tbl; unsigned long flags; @@ -500,14 +487,14 @@ mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, "initiator=%d\n", peer_mac, tid, initiator); if (cleanup_rx_reorder_tbl) { - rx_reor_tbl_ptr = mwifiex_11n_get_rx_reorder_tbl(priv, tid, + tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, peer_mac); - if (!rx_reor_tbl_ptr) { + if (!tbl) { dev_dbg(priv->adapter->dev, "event: TID, TA not found in table\n"); return; } - mwifiex_11n_delete_rx_reorder_tbl_entry(priv, rx_reor_tbl_ptr); + mwifiex_del_rx_reorder_entry(priv, tbl); } else { ptx_tbl = mwifiex_get_ba_tbl(priv, tid, peer_mac); if (!ptx_tbl) { @@ -535,7 +522,7 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, (struct host_cmd_ds_11n_addba_rsp *) &resp->params.add_ba_rsp; int tid, win_size; - struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; + struct mwifiex_rx_reorder_tbl *tbl; uint16_t block_ack_param_set; block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set); @@ -557,13 +544,12 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, tid, add_ba_rsp->ssn, win_size); } else { dev_err(priv->adapter->dev, "ADDBA RSP: failed %pM tid=%d)\n", - add_ba_rsp->peer_mac_addr, tid); + add_ba_rsp->peer_mac_addr, tid); - rx_reor_tbl_ptr = mwifiex_11n_get_rx_reorder_tbl(priv, - tid, add_ba_rsp->peer_mac_addr); - if (rx_reor_tbl_ptr) - mwifiex_11n_delete_rx_reorder_tbl_entry(priv, - rx_reor_tbl_ptr); + tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, + add_ba_rsp->peer_mac_addr); + if (tbl) + mwifiex_del_rx_reorder_entry(priv, tbl); } return 0; @@ -602,7 +588,7 @@ void mwifiex_11n_cleanup_reorder_tbl(struct mwifiex_private *priv) list_for_each_entry_safe(del_tbl_ptr, tmp_node, &priv->rx_reorder_tbl_ptr, list) { spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); - mwifiex_11n_delete_rx_reorder_tbl_entry(priv, del_tbl_ptr); + mwifiex_del_rx_reorder_entry(priv, del_tbl_ptr); spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); } spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); -- GitLab From 6d430c2566467aaa6f39cbf7d0f6da5090db7007 Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Tue, 13 Mar 2012 10:57:51 +0100 Subject: [PATCH 1721/1846] Documentation: make exists consistent Signed-off-by: Yegor Yefremov Signed-off-by: John W. Linville --- Documentation/networking/mac80211-auth-assoc-deauth.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/mac80211-auth-assoc-deauth.txt b/Documentation/networking/mac80211-auth-assoc-deauth.txt index 721773d2b9d2..e0a2aa585ca3 100644 --- a/Documentation/networking/mac80211-auth-assoc-deauth.txt +++ b/Documentation/networking/mac80211-auth-assoc-deauth.txt @@ -14,7 +14,7 @@ alt authentication needed (not FT) userspace->mac80211: authenticate alt authenticated/authenticating already -mac80211->driver: sta_state(AP, not-exist) +mac80211->driver: sta_state(AP, not-exists) mac80211->driver: bss_info_changed(clear BSSID) else associated note over mac80211,driver @@ -91,8 +91,8 @@ mac80211->driver: TX deauth/disassoc mac80211->driver: flush frames mac80211->driver: sta_state(AP,associated) mac80211->driver: sta_state(AP,authenticated) -mac80211->driver: sta_state(AP,exist) -mac80211->driver: sta_state(AP,not-exist) +mac80211->driver: sta_state(AP,exists) +mac80211->driver: sta_state(AP,not-exists) mac80211->driver: turn off powersave mac80211->driver: bss_info_changed(clear BSSID, not associated, no QoS, ...) mac80211->driver: config(non-HT channel type) -- GitLab From 8e6cffb3b42f03a47a56ede928b006f117628646 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 13 Mar 2012 13:57:03 +0100 Subject: [PATCH 1722/1846] brmc80211: dont use jiffies for BSS TSF The cfg80211_inform_bss() timestamp argument is intended to be the TSF, not any form of host timestamp. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 15d7f00513be..d13ae9c299f2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -2003,7 +2003,6 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, s32 err = 0; u16 channel; u32 freq; - u64 notify_timestamp; u16 notify_capability; u16 notify_interval; u8 *notify_ie; @@ -2026,7 +2025,6 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, freq = ieee80211_channel_to_frequency(channel, band->band); notify_channel = ieee80211_get_channel(wiphy, freq); - notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ notify_capability = le16_to_cpu(bi->capability); notify_interval = le16_to_cpu(bi->beacon_period); notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); @@ -2040,10 +2038,9 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, WL_CONN("Capability: %X\n", notify_capability); WL_CONN("Beacon interval: %d\n", notify_interval); WL_CONN("Signal: %d\n", notify_signal); - WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID, - notify_timestamp, notify_capability, notify_interval, notify_ie, + 0, notify_capability, notify_interval, notify_ie, notify_ielen, notify_signal, GFP_KERNEL); if (!bss) @@ -2098,7 +2095,6 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, s32 err = 0; u16 channel; u32 freq; - u64 notify_timestamp; u16 notify_capability; u16 notify_interval; u8 *notify_ie; @@ -2134,7 +2130,6 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, freq = ieee80211_channel_to_frequency(channel, band->band); notify_channel = ieee80211_get_channel(wiphy, freq); - notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */ notify_capability = le16_to_cpu(bi->capability); notify_interval = le16_to_cpu(bi->beacon_period); notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); @@ -2145,10 +2140,9 @@ static s32 wl_inform_ibss(struct brcmf_cfg80211_priv *cfg_priv, WL_CONN("capability: %X\n", notify_capability); WL_CONN("beacon interval: %d\n", notify_interval); WL_CONN("signal: %d\n", notify_signal); - WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); bss = cfg80211_inform_bss(wiphy, notify_channel, bssid, - notify_timestamp, notify_capability, notify_interval, + 0, notify_capability, notify_interval, notify_ie, notify_ielen, notify_signal, GFP_KERNEL); if (!bss) { -- GitLab From 7b8bcff2e0f11981dd6840f9feefe0914e4ea521 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 13 Mar 2012 13:57:04 +0100 Subject: [PATCH 1723/1846] cfg80211: clarify timestamp in cfg80211_inform_bss This is intended to be the timestamp sent by the peer in the beacon/probe response, not any form of host timestamp. Clarify the documentation and variable names. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- include/net/cfg80211.h | 7 +++---- net/wireless/scan.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 66f460325e24..69b7ad3a9925 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2697,7 +2697,7 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, * @wiphy: the wiphy reporting the BSS * @channel: The channel the frame was received on * @bssid: the BSSID of the BSS - * @timestamp: the TSF timestamp sent by the peer + * @tsf: the TSF sent by the peer in the beacon/probe response (or 0) * @capability: the capability field sent by the peer * @beacon_interval: the beacon interval announced by the peer * @ie: additional IEs sent by the peer @@ -2713,9 +2713,8 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, struct cfg80211_bss * __must_check cfg80211_inform_bss(struct wiphy *wiphy, struct ieee80211_channel *channel, - const u8 *bssid, - u64 timestamp, u16 capability, u16 beacon_interval, - const u8 *ie, size_t ielen, + const u8 *bssid, u64 tsf, u16 capability, + u16 beacon_interval, const u8 *ie, size_t ielen, s32 signal, gfp_t gfp); struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, diff --git a/net/wireless/scan.c b/net/wireless/scan.c index afde7e5f0010..70faadf16a32 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -734,9 +734,8 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev, struct cfg80211_bss* cfg80211_inform_bss(struct wiphy *wiphy, struct ieee80211_channel *channel, - const u8 *bssid, - u64 timestamp, u16 capability, u16 beacon_interval, - const u8 *ie, size_t ielen, + const u8 *bssid, u64 tsf, u16 capability, + u16 beacon_interval, const u8 *ie, size_t ielen, s32 signal, gfp_t gfp) { struct cfg80211_internal_bss *res; @@ -758,7 +757,7 @@ cfg80211_inform_bss(struct wiphy *wiphy, memcpy(res->pub.bssid, bssid, ETH_ALEN); res->pub.channel = channel; res->pub.signal = signal; - res->pub.tsf = timestamp; + res->pub.tsf = tsf; res->pub.beacon_interval = beacon_interval; res->pub.capability = capability; /* -- GitLab From e9ac0745c734d39cb55ce45f1fb03a85c972b35a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 13 Mar 2012 14:29:30 +0100 Subject: [PATCH 1724/1846] mac80211: rename bss_conf timestamp to last_tsf This value is not really very useful by itself, yet some drivers (including iwlwifi until I can figure out what it should do) use it. At least rename it to "last_tsf" to indicate the meaning and add a note that it may be really old. I suspect the value may become useful combined with the rx_status->mactime, but we don't (yet) store that value and pass it to the driver. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 2 +- drivers/net/wireless/rt2x00/rt2x00config.c | 2 +- include/net/mac80211.h | 5 +++-- net/mac80211/driver-trace.h | 2 +- net/mac80211/mlme.c | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index b42052b47d8e..e5ac04739bcc 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -5355,7 +5355,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (changes & BSS_CHANGED_ASSOC) { D_MAC80211("ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { - il->timestamp = bss_conf->timestamp; + il->timestamp = bss_conf->last_tsf; if (!il_is_rfkill(il)) il->ops->post_associate(il); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 36909077f994..2e1a31797a9e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -822,7 +822,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, if (changes & BSS_CHANGED_ASSOC) { if (bss_conf->assoc) { - priv->timestamp = bss_conf->timestamp; + priv->timestamp = bss_conf->last_tsf; ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; } else { /* diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c index d7c0f86c9e43..293676bfa571 100644 --- a/drivers/net/wireless/rt2x00/rt2x00config.c +++ b/drivers/net/wireless/rt2x00/rt2x00config.c @@ -102,7 +102,7 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev, /* Update the AID, this is needed for dynamic PS support */ rt2x00dev->aid = bss_conf->assoc ? bss_conf->aid : 0; - rt2x00dev->last_beacon = bss_conf->timestamp; + rt2x00dev->last_beacon = bss_conf->last_tsf; /* Update global beacon interval time, this is needed for PS support */ rt2x00dev->beacon_int = bss_conf->beacon_int; diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 44e4dfcb5722..9a012be615ff 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -229,7 +229,8 @@ enum ieee80211_rssi_event { * valid in station mode only while @assoc is true and if also * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf * @ps_dtim_period) - * @timestamp: beacon timestamp + * @last_tsf: last beacon's/probe response's TSF timestamp (could be old + * as it may have been received during scanning long ago) * @beacon_int: beacon interval * @assoc_capability: capabilities taken from assoc resp * @basic_rates: bitmap of basic rates, each bit stands for an @@ -276,7 +277,7 @@ struct ieee80211_bss_conf { u8 dtim_period; u16 beacon_int; u16 assoc_capability; - u64 timestamp; + u64 last_tsf; u32 basic_rates; int mcast_rate[IEEE80211_NUM_BANDS]; u16 ht_operation_mode; diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h index 7034209ad3f4..21d6f5290a1c 100644 --- a/net/mac80211/driver-trace.h +++ b/net/mac80211/driver-trace.h @@ -296,7 +296,7 @@ TRACE_EVENT(drv_bss_info_changed, __entry->dtimper = info->dtim_period; __entry->bcnint = info->beacon_int; __entry->assoc_cap = info->assoc_capability; - __entry->timestamp = info->timestamp; + __entry->timestamp = info->last_tsf; __entry->basic_rates = info->basic_rates; __entry->enable_beacon = info->enable_beacon; __entry->ht_operation_mode = info->ht_operation_mode; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 39c13939008b..90d1db36cdef 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1318,7 +1318,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, bss_info_changed |= BSS_CHANGED_ASSOC; /* set timing information */ bss_conf->beacon_int = cbss->beacon_interval; - bss_conf->timestamp = cbss->tsf; + bss_conf->last_tsf = cbss->tsf; bss_info_changed |= BSS_CHANGED_BEACON_INT; bss_info_changed |= ieee80211_handle_bss_capability(sdata, -- GitLab From 3117bbdb7899d43927c8ce4fe885ab7c1231c121 Mon Sep 17 00:00:00 2001 From: Paul Stewart Date: Tue, 13 Mar 2012 07:46:18 -0700 Subject: [PATCH 1725/1846] mac80211: Don't let regulatory make us deaf When regulatory information changes our HT behavior (e.g, when we get a country code from the AP we have just associated with), we should use this information to change the power with which we transmit, and what channels we transmit. Sometimes the channel parameters we derive from regulatory information contradicts the parameters we used in association. For example, we could have associated specifying HT40, but the regulatory rules we apply may forbid HT40 operation. In the situation above, we should reconfigure ourselves to transmit in HT20 only, however it makes no sense for us to disable receive in HT40, since if we associated with these parameters, the AP has every reason to expect we can and will receive packets this way. The code in mac80211 does not have the capability of sending the appropriate action frames to signal a change in HT behaviour so the AP has no clue we can no longer receive frames encoded this way. In some broken AP implementations, this can leave us effectively deaf if the AP never retries in lower HT rates. This change breaks up the channel_type parameter in the ieee80211_enable_ht function into a separate receive and transmit part. It honors the channel flags set by regulatory in order to configure the rate control algorithm, but uses the capability flags to configure the channel on the radio, since these were used in association to set the AP's transmit rate. Signed-off-by: Paul Stewart Cc: Sam Leffler Cc: Johannes Berg Reviewed-by: Luis R Rodriguez Signed-off-by: John W. Linville --- net/mac80211/chan.c | 27 +++++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 3 +++ net/mac80211/mlme.c | 32 ++++++++++++++++---------------- net/mac80211/rx.c | 8 +++++--- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index d1f7abddb182..e00ce8c3e28e 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -3,6 +3,7 @@ */ #include +#include #include "ieee80211_i.h" static enum ieee80211_chan_mode @@ -134,3 +135,29 @@ bool ieee80211_set_channel_type(struct ieee80211_local *local, return result; } + +/* + * ieee80211_get_tx_channel_type returns the channel type we should + * use for packet transmission, given the channel capability and + * whatever regulatory flags we have been given. + */ +enum nl80211_channel_type ieee80211_get_tx_channel_type( + struct ieee80211_local *local, + enum nl80211_channel_type channel_type) +{ + switch (channel_type) { + case NL80211_CHAN_HT40PLUS: + if (local->hw.conf.channel->flags & + IEEE80211_CHAN_NO_HT40PLUS) + return NL80211_CHAN_HT20; + break; + case NL80211_CHAN_HT40MINUS: + if (local->hw.conf.channel->flags & + IEEE80211_CHAN_NO_HT40MINUS) + return NL80211_CHAN_HT20; + break; + default: + break; + } + return channel_type; +} diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 173c1396070d..63fb0eb79d8e 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1502,6 +1502,9 @@ bool ieee80211_set_channel_type(struct ieee80211_local *local, enum nl80211_channel_type chantype); enum nl80211_channel_type ieee80211_ht_info_to_channel_type(struct ieee80211_ht_info *ht_info); +enum nl80211_channel_type ieee80211_get_tx_channel_type( + struct ieee80211_local *local, + enum nl80211_channel_type channel_type); #ifdef CONFIG_MAC80211_NOINLINE #define debug_noinline noinline diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 90d1db36cdef..0df22372af8d 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -189,7 +189,8 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, u16 ht_opmode; bool enable_ht = true; enum nl80211_channel_type prev_chantype; - enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; + enum nl80211_channel_type rx_channel_type = NL80211_CHAN_NO_HT; + enum nl80211_channel_type tx_channel_type; sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; prev_chantype = sdata->vif.bss_conf.channel_type; @@ -216,7 +217,7 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, } if (enable_ht) { - channel_type = NL80211_CHAN_HT20; + rx_channel_type = NL80211_CHAN_HT20; if (!(ap_ht_cap_flags & IEEE80211_HT_CAP_40MHZ_INTOLERANT) && !ieee80111_cfg_override_disables_ht40(sdata) && @@ -224,29 +225,28 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, (hti->ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) { switch(hti->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: - if (!(local->hw.conf.channel->flags & - IEEE80211_CHAN_NO_HT40PLUS)) - channel_type = NL80211_CHAN_HT40PLUS; + rx_channel_type = NL80211_CHAN_HT40PLUS; break; case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - if (!(local->hw.conf.channel->flags & - IEEE80211_CHAN_NO_HT40MINUS)) - channel_type = NL80211_CHAN_HT40MINUS; + rx_channel_type = NL80211_CHAN_HT40MINUS; break; } } } + tx_channel_type = ieee80211_get_tx_channel_type(local, rx_channel_type); + if (local->tmp_channel) - local->tmp_channel_type = channel_type; + local->tmp_channel_type = rx_channel_type; - if (!ieee80211_set_channel_type(local, sdata, channel_type)) { + if (!ieee80211_set_channel_type(local, sdata, rx_channel_type)) { /* can only fail due to HT40+/- mismatch */ - channel_type = NL80211_CHAN_HT20; - WARN_ON(!ieee80211_set_channel_type(local, sdata, channel_type)); + rx_channel_type = NL80211_CHAN_HT20; + WARN_ON(!ieee80211_set_channel_type(local, sdata, + rx_channel_type)); } - if (beacon_htcap_ie && (prev_chantype != channel_type)) { + if (beacon_htcap_ie && (prev_chantype != rx_channel_type)) { /* * Whenever the AP announces the HT mode change that can be * 40MHz intolerant or etc., it would be safer to stop tx @@ -264,13 +264,13 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, /* channel_type change automatically detected */ ieee80211_hw_config(local, 0); - if (prev_chantype != channel_type) { + if (prev_chantype != tx_channel_type) { rcu_read_lock(); sta = sta_info_get(sdata, bssid); if (sta) rate_control_rate_update(local, sband, sta, IEEE80211_RC_HT_CHANGED, - channel_type); + tx_channel_type); rcu_read_unlock(); if (beacon_htcap_ie) @@ -283,7 +283,7 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata, /* if bss configuration changed store the new one */ if (sdata->ht_opmode_valid != enable_ht || sdata->vif.bss_conf.ht_operation_mode != ht_opmode || - prev_chantype != channel_type) { + prev_chantype != rx_channel_type) { changed |= BSS_CHANGED_HT; sdata->vif.bss_conf.ht_operation_mode = ht_opmode; sdata->ht_opmode_valid = enable_ht; diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 53c88d145472..bcfe8c77c839 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2269,9 +2269,11 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) sband = rx->local->hw.wiphy->bands[status->band]; - rate_control_rate_update(local, sband, rx->sta, - IEEE80211_RC_SMPS_CHANGED, - local->_oper_channel_type); + rate_control_rate_update( + local, sband, rx->sta, + IEEE80211_RC_SMPS_CHANGED, + ieee80211_get_tx_channel_type( + local, local->_oper_channel_type)); goto handled; } default: -- GitLab From 5edc4465826bf5be4da678822b0c0e35666b6d67 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 8 Feb 2012 16:14:59 +0000 Subject: [PATCH 1726/1846] ixgb: Remove unnecessary defines, use pr_debug Use the current logging styles. Remove unnecessary _DEBUG_DRIVER_ and PFX, use pr_debug. Coalesce format. Signed-off-by: Joe Perches Tested-by: Jeff Pieper Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgb/ixgb.h | 12 ------------ drivers/net/ethernet/intel/ixgb/ixgb_main.c | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgb/ixgb.h b/drivers/net/ethernet/intel/ixgb/ixgb.h index cb23448fe2fa..4d2ae97ff1b3 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb.h +++ b/drivers/net/ethernet/intel/ixgb/ixgb.h @@ -75,18 +75,6 @@ struct ixgb_adapter; #include "ixgb_ee.h" #include "ixgb_ids.h" -#define PFX "ixgb: " - -#ifdef _DEBUG_DRIVER_ -#define IXGB_DBG(fmt, args...) printk(KERN_DEBUG PFX fmt, ##args) -#else -#define IXGB_DBG(fmt, args...) \ -do { \ - if (0) \ - printk(KERN_DEBUG PFX fmt, ##args); \ -} while (0) -#endif - /* TX/RX descriptor defines */ #define DEFAULT_TXD 256 #define MAX_TXD 4096 diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index 002478801a1b..82aaa792cbf3 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c @@ -2068,8 +2068,8 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do) /* All receives must fit into a single buffer */ - IXGB_DBG("Receive packet consumed multiple buffers " - "length<%x>\n", length); + pr_debug("Receive packet consumed multiple buffers length<%x>\n", + length); dev_kfree_skb_irq(skb); goto rxdesc_done; -- GitLab From bdda1a61c1dbb1e3a4f76c944b7c1e3b3731c861 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:14 +0000 Subject: [PATCH 1727/1846] ixgbe: Do not disable read relaxed ordering when DCA is enabled A previous fix had gone though and disabled relaxed ordering for Rx descriptor read fetching. This was not necessary as this functions correctly and has no ill effects on the system. In addition several of the defines used for the DCA control registers were incorrect in that they indicated descriptor effects when they actually had an impact on either data or header write back. As such I have update these to correctly reflect either DATA or HEAD. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/ixgbe/ixgbe_82598.c | 6 +- .../net/ethernet/intel/ixgbe/ixgbe_common.c | 6 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 71 ++++++++++--------- drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 8 ++- 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c index 752dbe6f0f54..85d2e2c4ce4a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c @@ -213,15 +213,15 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw) for (i = 0; ((i < hw->mac.max_tx_queues) && (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i)); - regval &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN; + regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN; IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval); } for (i = 0; ((i < hw->mac.max_rx_queues) && (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); - regval &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN | - IXGBE_DCA_RXCTRL_DESC_HSRO_EN); + regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN | + IXGBE_DCA_RXCTRL_HEAD_WRO_EN); IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 87f6b4f8abbd..67ec37b731aa 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -128,14 +128,14 @@ s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw) /* Disable relaxed ordering */ for (i = 0; i < hw->mac.max_tx_queues; i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL_82599(i)); - regval &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN; + regval &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN; IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL_82599(i), regval); } for (i = 0; i < hw->mac.max_rx_queues; i++) { regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i)); - regval &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN | - IXGBE_DCA_RXCTRL_DESC_HSRO_EN); + regval &= ~(IXGBE_DCA_RXCTRL_DATA_WRO_EN | + IXGBE_DCA_RXCTRL_HEAD_WRO_EN); IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 95240ab29177..ac3532446594 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -860,63 +860,68 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, } #ifdef CONFIG_IXGBE_DCA -static void ixgbe_update_rx_dca(struct ixgbe_adapter *adapter, - struct ixgbe_ring *rx_ring, +static void ixgbe_update_tx_dca(struct ixgbe_adapter *adapter, + struct ixgbe_ring *tx_ring, int cpu) { struct ixgbe_hw *hw = &adapter->hw; - u32 rxctrl; - u8 reg_idx = rx_ring->reg_idx; + u32 txctrl = dca3_get_tag(tx_ring->dev, cpu); + u16 reg_offset; - rxctrl = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(reg_idx)); switch (hw->mac.type) { case ixgbe_mac_82598EB: - rxctrl &= ~IXGBE_DCA_RXCTRL_CPUID_MASK; - rxctrl |= dca3_get_tag(rx_ring->dev, cpu); + reg_offset = IXGBE_DCA_TXCTRL(tx_ring->reg_idx); break; case ixgbe_mac_82599EB: case ixgbe_mac_X540: - rxctrl &= ~IXGBE_DCA_RXCTRL_CPUID_MASK_82599; - rxctrl |= (dca3_get_tag(rx_ring->dev, cpu) << - IXGBE_DCA_RXCTRL_CPUID_SHIFT_82599); + reg_offset = IXGBE_DCA_TXCTRL_82599(tx_ring->reg_idx); + txctrl <<= IXGBE_DCA_TXCTRL_CPUID_SHIFT_82599; break; default: - break; + /* for unknown hardware do not write register */ + return; } - rxctrl |= IXGBE_DCA_RXCTRL_DESC_DCA_EN; - rxctrl |= IXGBE_DCA_RXCTRL_HEAD_DCA_EN; - rxctrl &= ~(IXGBE_DCA_RXCTRL_DESC_RRO_EN); - IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(reg_idx), rxctrl); + + /* + * We can enable relaxed ordering for reads, but not writes when + * DCA is enabled. This is due to a known issue in some chipsets + * which will cause the DCA tag to be cleared. + */ + txctrl |= IXGBE_DCA_TXCTRL_DESC_RRO_EN | + IXGBE_DCA_TXCTRL_DATA_RRO_EN | + IXGBE_DCA_TXCTRL_DESC_DCA_EN; + + IXGBE_WRITE_REG(hw, reg_offset, txctrl); } -static void ixgbe_update_tx_dca(struct ixgbe_adapter *adapter, - struct ixgbe_ring *tx_ring, +static void ixgbe_update_rx_dca(struct ixgbe_adapter *adapter, + struct ixgbe_ring *rx_ring, int cpu) { struct ixgbe_hw *hw = &adapter->hw; - u32 txctrl; - u8 reg_idx = tx_ring->reg_idx; + u32 rxctrl = dca3_get_tag(rx_ring->dev, cpu); + u8 reg_idx = rx_ring->reg_idx; + switch (hw->mac.type) { - case ixgbe_mac_82598EB: - txctrl = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(reg_idx)); - txctrl &= ~IXGBE_DCA_TXCTRL_CPUID_MASK; - txctrl |= dca3_get_tag(tx_ring->dev, cpu); - txctrl |= IXGBE_DCA_TXCTRL_DESC_DCA_EN; - IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(reg_idx), txctrl); - break; case ixgbe_mac_82599EB: case ixgbe_mac_X540: - txctrl = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL_82599(reg_idx)); - txctrl &= ~IXGBE_DCA_TXCTRL_CPUID_MASK_82599; - txctrl |= (dca3_get_tag(tx_ring->dev, cpu) << - IXGBE_DCA_TXCTRL_CPUID_SHIFT_82599); - txctrl |= IXGBE_DCA_TXCTRL_DESC_DCA_EN; - IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL_82599(reg_idx), txctrl); + rxctrl <<= IXGBE_DCA_RXCTRL_CPUID_SHIFT_82599; break; default: break; } + + /* + * We can enable relaxed ordering for reads, but not writes when + * DCA is enabled. This is due to a known issue in some chipsets + * which will cause the DCA tag to be cleared. + */ + rxctrl |= IXGBE_DCA_RXCTRL_DESC_RRO_EN | + IXGBE_DCA_RXCTRL_DATA_DCA_EN | + IXGBE_DCA_RXCTRL_DESC_DCA_EN; + + IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(reg_idx), rxctrl); } static void ixgbe_update_dca(struct ixgbe_q_vector *q_vector) @@ -991,8 +996,8 @@ static int __ixgbe_notify_dca(struct device *dev, void *data) return 0; } -#endif /* CONFIG_IXGBE_DCA */ +#endif /* CONFIG_IXGBE_DCA */ static inline void ixgbe_rx_hash(struct ixgbe_ring *ring, union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 4c060292395f..54e2a5e8006f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h @@ -1021,14 +1021,16 @@ #define IXGBE_DCA_RXCTRL_HEAD_DCA_EN (1 << 6) /* DCA Rx Desc header enable */ #define IXGBE_DCA_RXCTRL_DATA_DCA_EN (1 << 7) /* DCA Rx Desc payload enable */ #define IXGBE_DCA_RXCTRL_DESC_RRO_EN (1 << 9) /* DCA Rx rd Desc Relax Order */ -#define IXGBE_DCA_RXCTRL_DESC_WRO_EN (1 << 13) /* DCA Rx wr Desc Relax Order */ -#define IXGBE_DCA_RXCTRL_DESC_HSRO_EN (1 << 15) /* DCA Rx Split Header RO */ +#define IXGBE_DCA_RXCTRL_DATA_WRO_EN (1 << 13) /* Rx wr data Relax Order */ +#define IXGBE_DCA_RXCTRL_HEAD_WRO_EN (1 << 15) /* Rx wr header RO */ #define IXGBE_DCA_TXCTRL_CPUID_MASK 0x0000001F /* Tx CPUID Mask */ #define IXGBE_DCA_TXCTRL_CPUID_MASK_82599 0xFF000000 /* Tx CPUID Mask */ #define IXGBE_DCA_TXCTRL_CPUID_SHIFT_82599 24 /* Tx CPUID Shift */ #define IXGBE_DCA_TXCTRL_DESC_DCA_EN (1 << 5) /* DCA Tx Desc enable */ -#define IXGBE_DCA_TXCTRL_TX_WB_RO_EN (1 << 11) /* Tx Desc writeback RO bit */ +#define IXGBE_DCA_TXCTRL_DESC_RRO_EN (1 << 9) /* Tx rd Desc Relax Order */ +#define IXGBE_DCA_TXCTRL_DESC_WRO_EN (1 << 11) /* Tx Desc writeback RO bit */ +#define IXGBE_DCA_TXCTRL_DATA_RRO_EN (1 << 13) /* Tx rd data Relax Order */ #define IXGBE_DCA_MAX_QUEUES_82598 16 /* DCA regs only on 16 queues */ /* MSCA Bit Masks */ -- GitLab From 621bd70eda47f33aa5f3a48da56649c0cb7e2329 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:20 +0000 Subject: [PATCH 1728/1846] ixgbe: Replace eitr_low and eitr_high with static values in ixgbe_update_itr There isn't much point in using variables to store the values of eitr_low and eitr_high since they are not user changeable. As such I am replacing them with the constants 10 and 20 in order to avoid any confusion on what the values actually are. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 4 ---- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 21 +++++++------------ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 03175cb7f078..f069c1b10753 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -511,10 +511,6 @@ struct ixgbe_adapter { #endif /* IXGBE_FCOE */ u32 wol; - /* Interrupt Throttle Rate */ - u16 eitr_low; - u16 eitr_high; - u16 bd_number; u16 eeprom_verh; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index ac3532446594..71ced437be70 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1782,20 +1782,19 @@ enum latency_range { static void ixgbe_update_itr(struct ixgbe_q_vector *q_vector, struct ixgbe_ring_container *ring_container) { - u64 bytes_perint; - struct ixgbe_adapter *adapter = q_vector->adapter; int bytes = ring_container->total_bytes; int packets = ring_container->total_packets; u32 timepassed_us; + u64 bytes_perint; u8 itr_setting = ring_container->itr; if (packets == 0) return; /* simple throttlerate management - * 0-20MB/s lowest (100000 ints/s) - * 20-100MB/s low (20000 ints/s) - * 100-1249MB/s bulk (8000 ints/s) + * 0-10MB/s lowest (100000 ints/s) + * 10-20MB/s low (20000 ints/s) + * 20-1249MB/s bulk (8000 ints/s) */ /* what was last interrupt timeslice? */ timepassed_us = q_vector->itr >> 2; @@ -1803,17 +1802,17 @@ static void ixgbe_update_itr(struct ixgbe_q_vector *q_vector, switch (itr_setting) { case lowest_latency: - if (bytes_perint > adapter->eitr_low) + if (bytes_perint > 10) itr_setting = low_latency; break; case low_latency: - if (bytes_perint > adapter->eitr_high) + if (bytes_perint > 20) itr_setting = bulk_latency; - else if (bytes_perint <= adapter->eitr_low) + else if (bytes_perint <= 10) itr_setting = lowest_latency; break; case bulk_latency: - if (bytes_perint <= adapter->eitr_high) + if (bytes_perint <= 20) itr_setting = low_latency; break; } @@ -5239,10 +5238,6 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) adapter->rx_itr_setting = 1; adapter->tx_itr_setting = 1; - /* set defaults for eitr in MegaBytes */ - adapter->eitr_low = 10; - adapter->eitr_high = 20; - /* set default ring sizes */ adapter->tx_ring_count = IXGBE_DEFAULT_TXD; adapter->rx_ring_count = IXGBE_DEFAULT_RXD; -- GitLab From 9cdcf098800d9549b0bf1e759f8b456baabfb939 Mon Sep 17 00:00:00 2001 From: Don Skidmore Date: Fri, 17 Feb 2012 07:38:13 +0000 Subject: [PATCH 1729/1846] ixgbe: fix obvious return value bug. This is clearly a typeo where we are not checking the return value from get_link_capabilities but should. This patch corrects that. Signed-off-by: Don Skidmore Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c index 4e59083a3de2..e39df2203add 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c @@ -779,7 +779,8 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN; /* Check to see if speed passed in is supported. */ - hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg); + status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities, + &autoneg); if (status != 0) goto out; -- GitLab From 3ed69d7e318ce17c77d91fd09a963cf48ce3a8a9 Mon Sep 17 00:00:00 2001 From: Jesse Brandeburg Date: Fri, 10 Feb 2012 10:20:02 +0000 Subject: [PATCH 1730/1846] ixgbe: use typed min/max functions where possible using the form min((int)var, ver)) is replaced by min_t(int, ...) Signed-off-by: Jesse Brandeburg Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 8 ++++---- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 1216bae913e3..24f7291dbe57 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -935,12 +935,12 @@ static int ixgbe_set_ringparam(struct net_device *netdev, if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) return -EINVAL; - new_rx_count = max(ring->rx_pending, (u32)IXGBE_MIN_RXD); - new_rx_count = min(new_rx_count, (u32)IXGBE_MAX_RXD); + new_rx_count = max_t(u32, ring->rx_pending, IXGBE_MIN_RXD); + new_rx_count = min_t(u32, new_rx_count, IXGBE_MAX_RXD); new_rx_count = ALIGN(new_rx_count, IXGBE_REQ_RX_DESCRIPTOR_MULTIPLE); - new_tx_count = max(ring->tx_pending, (u32)IXGBE_MIN_TXD); - new_tx_count = min(new_tx_count, (u32)IXGBE_MAX_TXD); + new_tx_count = max_t(u32, ring->tx_pending, IXGBE_MIN_TXD); + new_tx_count = min_t(u32, new_tx_count, IXGBE_MAX_TXD); new_tx_count = ALIGN(new_tx_count, IXGBE_REQ_TX_DESCRIPTOR_MULTIPLE); if ((new_tx_count == adapter->tx_ring[0]->count) && diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 71ced437be70..fce33f1f9151 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -4316,7 +4316,7 @@ static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter) if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) return false; - f->indices = min((int)num_online_cpus(), f->indices); + f->indices = min_t(int, num_online_cpus(), f->indices); adapter->num_rx_queues = 1; adapter->num_tx_queues = 1; @@ -4352,8 +4352,8 @@ static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter) return false; /* Map queue offset and counts onto allocated tx queues */ - per_tc_q = min(dev->num_tx_queues / tcs, (unsigned int)DCB_QUEUE_CAP); - q = min((int)num_online_cpus(), per_tc_q); + per_tc_q = min_t(unsigned int, dev->num_tx_queues / tcs, DCB_QUEUE_CAP); + q = min_t(int, num_online_cpus(), per_tc_q); for (i = 0; i < tcs; i++) { netdev_set_tc_queue(dev, i, q, offset); @@ -5146,7 +5146,7 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) hw->subsystem_device_id = pdev->subsystem_device; /* Set capability flags */ - rss = min(IXGBE_MAX_RSS_INDICES, (int)num_online_cpus()); + rss = min_t(int, IXGBE_MAX_RSS_INDICES, num_online_cpus()); adapter->ring_feature[RING_F_RSS].indices = rss; adapter->flags |= IXGBE_FLAG_RSS_ENABLED; switch (hw->mac.type) { -- GitLab From d2f5e7f3af777d52ce110ae60e8cb788bc93141c Mon Sep 17 00:00:00 2001 From: Atita Shirwaikar Date: Sat, 18 Feb 2012 02:58:58 +0000 Subject: [PATCH 1731/1846] ixgbe: Fix race condition where RX buffer could become corrupted. There was a race condition in the reset path where the RX buffer could become corrupted during Fdir configuration.This is due to a HW bug.The fix right now is to lock the buffer while we do the fdir configuration.Since we were using similar workaround for another bug, I moved the existing code to a function and reused it.HW team also recommended that IXGBE_MAX_SECRX_POLL value be changed from 30 to 40.The erratum for this bug will be published in the next release 82599 Spec Update Signed-off-by: Atita Shirwaikar Acked-by: Peter P Waskiewicz Jr Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/ixgbe/ixgbe_82599.c | 29 ++--------- .../net/ethernet/intel/ixgbe/ixgbe_common.c | 52 +++++++++++++++++++ .../net/ethernet/intel/ixgbe/ixgbe_common.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 21 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c | 2 + 6 files changed, 84 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c index e39df2203add..9c14685358eb 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c @@ -1907,38 +1907,17 @@ static u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw) **/ static s32 ixgbe_enable_rx_dma_82599(struct ixgbe_hw *hw, u32 regval) { -#define IXGBE_MAX_SECRX_POLL 30 - int i; - int secrxreg; - /* * Workaround for 82599 silicon errata when enabling the Rx datapath. * If traffic is incoming before we enable the Rx unit, it could hang * the Rx DMA unit. Therefore, make sure the security engine is * completely disabled prior to enabling the Rx unit. */ - secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL); - secrxreg |= IXGBE_SECRXCTRL_RX_DIS; - IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg); - for (i = 0; i < IXGBE_MAX_SECRX_POLL; i++) { - secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT); - if (secrxreg & IXGBE_SECRXSTAT_SECRX_RDY) - break; - else - /* Use interrupt-safe sleep just in case */ - udelay(10); - } - - /* For informational purposes only */ - if (i >= IXGBE_MAX_SECRX_POLL) - hw_dbg(hw, "Rx unit being enabled before security " - "path fully disabled. Continuing with init.\n"); + hw->mac.ops.disable_rx_buff(hw); IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, regval); - secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL); - secrxreg &= ~IXGBE_SECRXCTRL_RX_DIS; - IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg); - IXGBE_WRITE_FLUSH(hw); + + hw->mac.ops.enable_rx_buff(hw); return 0; } @@ -2103,6 +2082,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = { .get_media_type = &ixgbe_get_media_type_82599, .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82599, .enable_rx_dma = &ixgbe_enable_rx_dma_82599, + .disable_rx_buff = &ixgbe_disable_rx_buff_generic, + .enable_rx_buff = &ixgbe_enable_rx_buff_generic, .get_mac_addr = &ixgbe_get_mac_addr_generic, .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic, .get_device_caps = &ixgbe_get_device_caps_generic, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 67ec37b731aa..6117bfd924cc 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -2577,6 +2577,58 @@ void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask) ixgbe_release_eeprom_semaphore(hw); } +/** + * ixgbe_disable_rx_buff_generic - Stops the receive data path + * @hw: pointer to hardware structure + * + * Stops the receive data path and waits for the HW to internally + * empty the Rx security block. + **/ +s32 ixgbe_disable_rx_buff_generic(struct ixgbe_hw *hw) +{ +#define IXGBE_MAX_SECRX_POLL 40 + int i; + int secrxreg; + + secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL); + secrxreg |= IXGBE_SECRXCTRL_RX_DIS; + IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg); + for (i = 0; i < IXGBE_MAX_SECRX_POLL; i++) { + secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT); + if (secrxreg & IXGBE_SECRXSTAT_SECRX_RDY) + break; + else + /* Use interrupt-safe sleep just in case */ + udelay(10); + } + + /* For informational purposes only */ + if (i >= IXGBE_MAX_SECRX_POLL) + hw_dbg(hw, "Rx unit being enabled before security " + "path fully disabled. Continuing with init.\n"); + + return 0; + +} + +/** + * ixgbe_enable_rx_buff - Enables the receive data path + * @hw: pointer to hardware structure + * + * Enables the receive data path + **/ +s32 ixgbe_enable_rx_buff_generic(struct ixgbe_hw *hw) +{ + int secrxreg; + + secrxreg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL); + secrxreg &= ~IXGBE_SECRXCTRL_RX_DIS; + IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, secrxreg); + IXGBE_WRITE_FLUSH(hw); + + return 0; +} + /** * ixgbe_enable_rx_dma_generic - Enable the Rx DMA unit * @hw: pointer to hardware structure diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h index 2c834c46bba1..204f06235b45 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h @@ -74,6 +74,8 @@ s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, struct net_device *netdev); s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw); s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw); +s32 ixgbe_disable_rx_buff_generic(struct ixgbe_hw *hw); +s32 ixgbe_enable_rx_buff_generic(struct ixgbe_hw *hw); s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval); s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num); s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index fce33f1f9151..e1444bde02bb 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -3661,6 +3661,8 @@ static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter) static void ixgbe_configure(struct ixgbe_adapter *adapter) { + struct ixgbe_hw *hw = &adapter->hw; + ixgbe_configure_pb(adapter); #ifdef CONFIG_IXGBE_DCB ixgbe_configure_dcb(adapter); @@ -3674,6 +3676,16 @@ static void ixgbe_configure(struct ixgbe_adapter *adapter) ixgbe_configure_fcoe(adapter); #endif /* IXGBE_FCOE */ + + switch (hw->mac.type) { + case ixgbe_mac_82599EB: + case ixgbe_mac_X540: + hw->mac.ops.disable_rx_buff(hw); + break; + default: + break; + } + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { ixgbe_init_fdir_signature_82599(&adapter->hw, adapter->fdir_pballoc); @@ -3683,6 +3695,15 @@ static void ixgbe_configure(struct ixgbe_adapter *adapter) ixgbe_fdir_filter_restore(adapter); } + switch (hw->mac.type) { + case ixgbe_mac_82599EB: + case ixgbe_mac_X540: + hw->mac.ops.enable_rx_buff(hw); + break; + default: + break; + } + ixgbe_configure_virtualization(adapter); ixgbe_configure_tx(adapter); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 54e2a5e8006f..8636e8344fc9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h @@ -2728,6 +2728,8 @@ struct ixgbe_mac_operations { s32 (*read_analog_reg8)(struct ixgbe_hw*, u32, u8*); s32 (*write_analog_reg8)(struct ixgbe_hw*, u32, u8); s32 (*setup_sfp)(struct ixgbe_hw *); + s32 (*disable_rx_buff)(struct ixgbe_hw *); + s32 (*enable_rx_buff)(struct ixgbe_hw *); s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u16); void (*release_swfw_sync)(struct ixgbe_hw *, u16); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c index 5e9f05fa0134..97a991403bbd 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c @@ -847,6 +847,8 @@ static struct ixgbe_mac_operations mac_ops_X540 = { .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540, .release_swfw_sync = &ixgbe_release_swfw_sync_X540, + .disable_rx_buff = &ixgbe_disable_rx_buff_generic, + .enable_rx_buff = &ixgbe_enable_rx_buff_generic, }; static struct ixgbe_eeprom_operations eeprom_ops_X540 = { -- GitLab From cdf485be3a63d1f34293740fb726088c6840ceea Mon Sep 17 00:00:00 2001 From: John Fastabend Date: Sat, 11 Feb 2012 06:26:00 +0000 Subject: [PATCH 1732/1846] ixgbe: dcb: use DCB config values for FCoE traffic class on open Disabling and enabling DCB can cause FCoE hardware initialization to occur on the incorrect traffic class when the up2tc mapping has not yet been reconfigured. Fix this by using the DCB configuration maps that are correct and will be pushed at mqprio after DCB driver setup completes successfully. Signed-off-by: John Fastabend Tested-by: Marcus Dennis Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index e1444bde02bb..167e898fbba6 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -4391,11 +4391,13 @@ static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter) * configuration later. */ if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { + u8 prio_tc[MAX_USER_PRIORITY] = {0}; int tc; struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; - tc = netdev_get_prio_tc_map(dev, adapter->fcoe.up); + ixgbe_dcb_unpack_map(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_tc); + tc = prio_tc[adapter->fcoe.up]; f->indices = dev->tc_to_txq[tc].count; f->mask = dev->tc_to_txq[tc].offset; } -- GitLab From 842668417c13f5fca19d9db29f508500cd621af0 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:34 -0700 Subject: [PATCH 1733/1846] mwifiex: fix checkpatch --strict warnings/errors Part 1 For files 11n.c, 11n.h, 11n_aggr.c, 11n_rxreorder.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/11n.c | 22 +++++----- drivers/net/wireless/mwifiex/11n.h | 7 ++-- drivers/net/wireless/mwifiex/11n_aggr.c | 15 ++++--- drivers/net/wireless/mwifiex/11n_rxreorder.c | 42 ++++++++++---------- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c index aeb456d6396f..a5e182b5e944 100644 --- a/drivers/net/wireless/mwifiex/11n.c +++ b/drivers/net/wireless/mwifiex/11n.c @@ -44,16 +44,16 @@ mwifiex_fill_cap_info(struct mwifiex_private *priv, u8 radio_type, ht_cap->ht_cap.ampdu_params_info = (sband->ht_cap.ampdu_factor & - IEEE80211_HT_AMPDU_PARM_FACTOR)| + IEEE80211_HT_AMPDU_PARM_FACTOR) | ((sband->ht_cap.ampdu_density << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT) & IEEE80211_HT_AMPDU_PARM_DENSITY); memcpy((u8 *) &ht_cap->ht_cap.mcs, &sband->ht_cap.mcs, - sizeof(sband->ht_cap.mcs)); + sizeof(sband->ht_cap.mcs)); if (priv->bss_mode == NL80211_IFTYPE_STATION || - (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) + sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */ SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask); @@ -389,9 +389,9 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, chan_list->chan_scan_param[0].radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band); - if ((sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) - && (bss_desc->bcn_ht_info->ht_param & - IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) + if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && + bss_desc->bcn_ht_info->ht_param & + IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) SET_SECONDARYCHAN(chan_list->chan_scan_param[0]. radio_type, (bss_desc->bcn_ht_info->ht_param & @@ -464,7 +464,7 @@ mwifiex_cfg_tx_buf(struct mwifiex_private *priv, tx_buf = min(priv->adapter->max_tx_buf_size, max_amsdu); dev_dbg(priv->adapter->dev, "info: max_amsdu=%d, max_tx_buf=%d\n", - max_amsdu, priv->adapter->max_tx_buf_size); + max_amsdu, priv->adapter->max_tx_buf_size); if (priv->adapter->curr_tx_buf_size <= MWIFIEX_TX_DATA_BUF_SIZE_2K) curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K; @@ -504,7 +504,7 @@ void mwifiex_11n_delete_tx_ba_stream_tbl_entry(struct mwifiex_private *priv, struct mwifiex_tx_ba_stream_tbl *tx_ba_tsr_tbl) { if (!tx_ba_tsr_tbl && - mwifiex_is_tx_ba_stream_ptr_valid(priv, tx_ba_tsr_tbl)) + mwifiex_is_tx_ba_stream_ptr_valid(priv, tx_ba_tsr_tbl)) return; dev_dbg(priv->adapter->dev, "info: tx_ba_tsr_tbl %p\n", tx_ba_tsr_tbl); @@ -548,8 +548,8 @@ mwifiex_get_ba_tbl(struct mwifiex_private *priv, int tid, u8 *ra) spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { - if ((!memcmp(tx_ba_tsr_tbl->ra, ra, ETH_ALEN)) - && (tx_ba_tsr_tbl->tid == tid)) { + if (!memcmp(tx_ba_tsr_tbl->ra, ra, ETH_ALEN) && + tx_ba_tsr_tbl->tid == tid) { spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); return tx_ba_tsr_tbl; @@ -718,7 +718,7 @@ int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv, list_for_each_entry(tx_ba_tsr_tbl, &priv->tx_ba_stream_tbl_ptr, list) { rx_reo_tbl->tid = (u16) tx_ba_tsr_tbl->tid; dev_dbg(priv->adapter->dev, "data: %s tid=%d\n", - __func__, rx_reo_tbl->tid); + __func__, rx_reo_tbl->tid); memcpy(rx_reo_tbl->ra, tx_ba_tsr_tbl->ra, ETH_ALEN); rx_reo_tbl++; count++; diff --git a/drivers/net/wireless/mwifiex/11n.h b/drivers/net/wireless/mwifiex/11n.h index 139aa6ee1fbe..77646d777dce 100644 --- a/drivers/net/wireless/mwifiex/11n.h +++ b/drivers/net/wireless/mwifiex/11n.h @@ -86,9 +86,8 @@ mwifiex_is_ampdu_allowed(struct mwifiex_private *priv, int tid) static inline u8 mwifiex_is_amsdu_allowed(struct mwifiex_private *priv, int tid) { - return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) - && ((priv->is_data_rate_auto) - || !((priv->bitmap_rates[2]) & 0x03))) + return (((priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED) && + (priv->is_data_rate_auto || !(priv->bitmap_rates[2] & 0x03))) ? true : false); } @@ -149,7 +148,7 @@ mwifiex_find_stream_to_delete(struct mwifiex_private *priv, int ptr_tid, */ static inline int mwifiex_is_ba_stream_setup(struct mwifiex_private *priv, - struct mwifiex_ra_list_tbl *ptr, int tid) + struct mwifiex_ra_list_tbl *ptr, int tid) { struct mwifiex_tx_ba_stream_tbl *tx_tbl; diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c index ea6832dc6677..9eefb2a0ce9f 100644 --- a/drivers/net/wireless/mwifiex/11n_aggr.c +++ b/drivers/net/wireless/mwifiex/11n_aggr.c @@ -84,7 +84,7 @@ mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr, /* Add payload */ skb_put(skb_aggr, skb_src->len); memcpy(skb_aggr->data + sizeof(*tx_header), skb_src->data, - skb_src->len); + skb_src->len); *pad = (((skb_src->len + LLC_SNAP_LEN) & 3)) ? (4 - (((skb_src->len + LLC_SNAP_LEN)) & 3)) : 0; skb_put(skb_aggr, *pad); @@ -119,14 +119,14 @@ mwifiex_11n_form_amsdu_txpd(struct mwifiex_private *priv, local_tx_pd->tx_pkt_offset = cpu_to_le16(sizeof(struct txpd)); local_tx_pd->tx_pkt_type = cpu_to_le16(PKT_TYPE_AMSDU); local_tx_pd->tx_pkt_length = cpu_to_le16(skb->len - - sizeof(*local_tx_pd)); + sizeof(*local_tx_pd)); if (local_tx_pd->tx_control == 0) /* TxCtrl set by user or default */ local_tx_pd->tx_control = cpu_to_le32(priv->pkt_tx_ctrl); - if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && - (priv->adapter->pps_uapsd_mode)) { + if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA && + priv->adapter->pps_uapsd_mode) { if (true == mwifiex_check_last_packet_indication(priv)) { priv->adapter->tx_lock_flag = true; local_tx_pd->flags = @@ -257,9 +257,8 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, mwifiex_write_data_complete(adapter, skb_aggr, -1); return -1; } - if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && - (adapter->pps_uapsd_mode) && - (adapter->tx_lock_flag)) { + if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA && + adapter->pps_uapsd_mode && adapter->tx_lock_flag) { priv->adapter->tx_lock_flag = false; if (ptx_pd) ptx_pd->flags = 0; @@ -279,7 +278,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, case -1: adapter->data_sent = false; dev_err(adapter->dev, "%s: host_to_card failed: %#x\n", - __func__, ret); + __func__, ret); adapter->dbg.num_tx_host_to_card_failure++; mwifiex_write_data_complete(adapter, skb_aggr, ret); return 0; diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c index 06f5d3684027..9c44088054dd 100644 --- a/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c @@ -220,7 +220,7 @@ mwifiex_flush_data(unsigned long context) */ static void mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, - int tid, int win_size, int seq_num) + int tid, int win_size, int seq_num) { int i; struct mwifiex_rx_reorder_tbl *tbl, *new_node; @@ -240,7 +240,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, new_node = kzalloc(sizeof(struct mwifiex_rx_reorder_tbl), GFP_KERNEL); if (!new_node) { dev_err(priv->adapter->dev, "%s: failed to alloc new_node\n", - __func__); + __func__); return; } @@ -352,7 +352,8 @@ int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv, cmd_addba_req->block_ack_param_set = cpu_to_le16(block_ack_param_set); mwifiex_11n_create_rx_reorder_tbl(priv, cmd_addba_req->peer_mac_addr, - tid, win_size, le16_to_cpu(cmd_addba_req->ssn)); + tid, win_size, + le16_to_cpu(cmd_addba_req->ssn)); return 0; } @@ -416,11 +417,11 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, * packet */ if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) {/* Wrap */ - if (seq_num >= ((start_win + (TWOPOW11)) & (MAX_TID_VALUE - 1)) - && (seq_num < start_win)) + if (seq_num >= ((start_win + TWOPOW11) & + (MAX_TID_VALUE - 1)) && (seq_num < start_win)) return -1; - } else if ((seq_num < start_win) - || (seq_num > (start_win + (TWOPOW11)))) { + } else if ((seq_num < start_win) || + (seq_num > (start_win + TWOPOW11))) { return -1; } @@ -431,10 +432,11 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, if (pkt_type == PKT_TYPE_BAR) seq_num = ((seq_num + win_size) - 1) & (MAX_TID_VALUE - 1); - if (((end_win < start_win) - && (seq_num < (TWOPOW11 - (MAX_TID_VALUE - start_win))) - && (seq_num > end_win)) || ((end_win > start_win) - && ((seq_num > end_win) || (seq_num < start_win)))) { + if (((end_win < start_win) && + (seq_num < (TWOPOW11 - (MAX_TID_VALUE - start_win))) && + (seq_num > end_win)) || + ((end_win > start_win) && ((seq_num > end_win) || + (seq_num < start_win)))) { end_win = seq_num; if (((seq_num - win_size) + 1) >= 0) start_win = (end_win - win_size) + 1; @@ -483,15 +485,15 @@ mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, else cleanup_rx_reorder_tbl = (initiator) ? false : true; - dev_dbg(priv->adapter->dev, "event: DELBA: %pM tid=%d, " - "initiator=%d\n", peer_mac, tid, initiator); + dev_dbg(priv->adapter->dev, "event: DELBA: %pM tid=%d initiator=%d\n", + peer_mac, tid, initiator); if (cleanup_rx_reorder_tbl) { tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, peer_mac); if (!tbl) { dev_dbg(priv->adapter->dev, - "event: TID, TA not found in table\n"); + "event: TID, TA not found in table\n"); return; } mwifiex_del_rx_reorder_entry(priv, tbl); @@ -499,7 +501,7 @@ mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, ptx_tbl = mwifiex_get_ba_tbl(priv, tid, peer_mac); if (!ptx_tbl) { dev_dbg(priv->adapter->dev, - "event: TID, RA not found in table\n"); + "event: TID, RA not found in table\n"); return; } @@ -538,13 +540,13 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> BLOCKACKPARAM_WINSIZE_POS; - dev_dbg(priv->adapter->dev, "cmd: ADDBA RSP: %pM" - " tid=%d ssn=%d win_size=%d\n", - add_ba_rsp->peer_mac_addr, - tid, add_ba_rsp->ssn, win_size); + dev_dbg(priv->adapter->dev, + "cmd: ADDBA RSP: %pM tid=%d ssn=%d win_size=%d\n", + add_ba_rsp->peer_mac_addr, tid, + add_ba_rsp->ssn, win_size); } else { dev_err(priv->adapter->dev, "ADDBA RSP: failed %pM tid=%d)\n", - add_ba_rsp->peer_mac_addr, tid); + add_ba_rsp->peer_mac_addr, tid); tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, add_ba_rsp->peer_mac_addr); -- GitLab From aea0701e221e46c267a68187f9e6e0881e9a6a49 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:35 -0700 Subject: [PATCH 1734/1846] mwifiex: fix checkpatch --strict warnings/errors Part 2 For files cfg80211.c, cfp.c, and cmdevt.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 90 +++++++------ drivers/net/wireless/mwifiex/cfp.c | 4 +- drivers/net/wireless/mwifiex/cmdevt.c | 166 +++++++++++++----------- 3 files changed, 133 insertions(+), 127 deletions(-) diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 84508b065265..65050384c42b 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -127,8 +127,7 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, if (timeout) wiphy_dbg(wiphy, - "info: ignoring the timeout value" - " for IEEE power save\n"); + "info: ignore timeout value for IEEE Power Save\n"); ps_mode = enabled; @@ -168,7 +167,7 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); if (mwifiex_set_encode(priv, params->key, params->key_len, - key_index, 0)) { + key_index, 0)) { wiphy_err(wiphy, "crypto keys added\n"); return -EFAULT; } @@ -225,7 +224,7 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) } if (ch->hw_value == next_chan + 1 && - ch->max_power == max_pwr) { + ch->max_power == max_pwr) { next_chan++; no_of_parsed_chan++; } else { @@ -252,7 +251,7 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) domain_info->no_of_triplet = no_of_triplet; if (mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11D_DOMAIN_INFO, - HostCmd_ACT_GEN_SET, 0, NULL)) { + HostCmd_ACT_GEN_SET, 0, NULL)) { wiphy_err(wiphy, "11D: setting domain info in FW\n"); return -1; } @@ -271,7 +270,7 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) * - Set bt Country IE */ static int mwifiex_reg_notifier(struct wiphy *wiphy, - struct regulatory_request *request) + struct regulatory_request *request) { struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); @@ -316,7 +315,7 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv, if (chan->band == IEEE80211_BAND_2GHZ) { if (channel_type == NL80211_CHAN_NO_HT) if (priv->adapter->config_bands == BAND_B || - priv->adapter->config_bands == BAND_G) + priv->adapter->config_bands == BAND_G) config_bands = priv->adapter->config_bands; else @@ -336,7 +335,7 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv, if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { adapter->adhoc_start_band = config_bands; if ((config_bands & BAND_GN) || - (config_bands & BAND_AN)) + (config_bands & BAND_AN)) adapter->adhoc_11n_enabled = true; else adapter->adhoc_11n_enabled = false; @@ -350,9 +349,8 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv, mwifiex_send_domain_info_cmd_fw(wiphy); } - wiphy_dbg(wiphy, "info: setting band %d, channel offset %d and " - "mode %d\n", config_bands, adapter->sec_chan_offset, - priv->bss_mode); + wiphy_dbg(wiphy, "info: setting band %d, chan offset %d, mode %d\n", + config_bands, adapter->sec_chan_offset, priv->bss_mode); if (!chan) return 0; @@ -403,8 +401,8 @@ mwifiex_set_frag(struct mwifiex_private *priv, u32 frag_thr) { int ret; - if (frag_thr < MWIFIEX_FRAG_MIN_VALUE - || frag_thr > MWIFIEX_FRAG_MAX_VALUE) + if (frag_thr < MWIFIEX_FRAG_MIN_VALUE || + frag_thr > MWIFIEX_FRAG_MAX_VALUE) return -EINVAL; /* Send request to firmware */ @@ -746,8 +744,7 @@ static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy *wiphy, adapter->channel_type = NL80211_CHAN_NO_HT; wiphy_debug(wiphy, "info: device configured in 802.11%s%s mode\n", - (mode & BAND_B) ? "b" : "", - (mode & BAND_G) ? "g" : ""); + (mode & BAND_B) ? "b" : "", (mode & BAND_G) ? "g" : ""); return 0; } @@ -802,8 +799,7 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) ie_buf[1] = bss_info.ssid.ssid_len; memcpy(&ie_buf[sizeof(struct ieee_types_header)], - &bss_info.ssid.ssid, - bss_info.ssid.ssid_len); + &bss_info.ssid.ssid, bss_info.ssid.ssid_len); ie_len = ie_buf[1] + sizeof(struct ieee_types_header); band = mwifiex_band_to_radio_type(priv->curr_bss_params.band); @@ -812,8 +808,8 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) band)); bss = cfg80211_inform_bss(priv->wdev->wiphy, chan, - bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, - 0, ie_buf, ie_len, 0, GFP_KERNEL); + bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, + 0, ie_buf, ie_len, 0, GFP_KERNEL); cfg80211_put_bss(bss); memcpy(priv->cfg_bssid, bss_info.bssid, ETH_ALEN); @@ -952,14 +948,15 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, if (!bss) { if (is_scanning_required) { - dev_warn(priv->adapter->dev, "assoc: requested " - "bss not found in scan results\n"); + dev_warn(priv->adapter->dev, + "assoc: requested bss not found in scan results\n"); break; } is_scanning_required = 1; } else { - dev_dbg(priv->adapter->dev, "info: trying to associate to %s and bssid %pM\n", - (char *) req_ssid.ssid, bss->bssid); + dev_dbg(priv->adapter->dev, + "info: trying to associate to '%s' bssid %pM\n", + (char *) req_ssid.ssid, bss->bssid); memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN); break; } @@ -999,7 +996,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, } wiphy_dbg(wiphy, "info: Trying to associate to %s and bssid %pM\n", - (char *) sme->ssid, sme->bssid); + (char *) sme->ssid, sme->bssid); ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid, priv->bss_mode, sme->channel, sme, 0); @@ -1041,11 +1038,11 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, } wiphy_dbg(wiphy, "info: trying to join to %s and bssid %pM\n", - (char *) params->ssid, params->bssid); + (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); + params->bssid, priv->bss_mode, + params->channel, NULL, params->privacy); done: if (!ret) { cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL); @@ -1072,7 +1069,7 @@ mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n", - priv->cfg_bssid); + priv->cfg_bssid); if (mwifiex_deauthenticate(priv, NULL)) return -EFAULT; @@ -1101,7 +1098,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, priv->scan_request = request; priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), - GFP_KERNEL); + GFP_KERNEL); if (!priv->user_scan_cfg) { dev_err(priv->adapter->dev, "failed to alloc scan_req\n"); return -ENOMEM; @@ -1117,10 +1114,10 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) priv->user_scan_cfg->chan_list[i].scan_type = - MWIFIEX_SCAN_TYPE_PASSIVE; + MWIFIEX_SCAN_TYPE_PASSIVE; else priv->user_scan_cfg->chan_list[i].scan_type = - MWIFIEX_SCAN_TYPE_ACTIVE; + MWIFIEX_SCAN_TYPE_ACTIVE; priv->user_scan_cfg->chan_list[i].scan_time = 0; } @@ -1191,9 +1188,9 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info, memset(mcs, 0xff, rx_mcs_supp); /* Clear all the other values */ memset(&mcs[rx_mcs_supp], 0, - sizeof(struct ieee80211_mcs_info) - rx_mcs_supp); + sizeof(struct ieee80211_mcs_info) - rx_mcs_supp); if (priv->bss_mode == NL80211_IFTYPE_STATION || - ISSUPP_CHANWIDTH40(adapter->hw_dot_11n_dev_cap)) + ISSUPP_CHANWIDTH40(adapter->hw_dot_11n_dev_cap)) /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */ SETHT_MCS32(mcs_set.rx_mask); @@ -1206,10 +1203,10 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info, * create a new virtual interface with the given name */ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, - char *name, - enum nl80211_iftype type, - u32 *flags, - struct vif_params *params) + char *name, + enum nl80211_iftype type, + u32 *flags, + struct vif_params *params) { struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); struct mwifiex_adapter *adapter; @@ -1367,11 +1364,12 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv) int ret; void *wdev_priv; struct wireless_dev *wdev; + struct ieee80211_sta_ht_cap *ht_info; wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); if (!wdev) { dev_err(priv->adapter->dev, "%s: allocating wireless device\n", - __func__); + __func__); return -ENOMEM; } wdev->wiphy = @@ -1383,17 +1381,17 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv) } wdev->iftype = NL80211_IFTYPE_STATION; wdev->wiphy->max_scan_ssids = 10; - wdev->wiphy->interface_modes = - BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); + wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC); wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &mwifiex_band_2ghz; - mwifiex_setup_ht_caps( - &wdev->wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap, priv); + ht_info = &wdev->wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap; + mwifiex_setup_ht_caps(ht_info, priv); if (priv->adapter->config_bands & BAND_A) { wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &mwifiex_band_5ghz; - mwifiex_setup_ht_caps( - &wdev->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap, priv); + ht_info = &wdev->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap; + mwifiex_setup_ht_caps(ht_info, priv); } else { wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; } @@ -1420,13 +1418,13 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv) ret = wiphy_register(wdev->wiphy); if (ret < 0) { dev_err(priv->adapter->dev, "%s: registering cfg80211 device\n", - __func__); + __func__); wiphy_free(wdev->wiphy); kfree(wdev); return ret; } else { dev_dbg(priv->adapter->dev, - "info: successfully registered wiphy device\n"); + "info: successfully registered wiphy device\n"); } priv->wdev = wdev; diff --git a/drivers/net/wireless/mwifiex/cfp.c b/drivers/net/wireless/mwifiex/cfp.c index 7541d9a4a6ed..2fe1c33765b8 100644 --- a/drivers/net/wireless/mwifiex/cfp.c +++ b/drivers/net/wireless/mwifiex/cfp.c @@ -163,8 +163,8 @@ u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, u8 *rates) return mwifiex_get_supported_rates(priv, rates); else return mwifiex_copy_rates(rates, 0, - priv->curr_bss_params.data_rates, - priv->curr_bss_params.num_of_rates); + priv->curr_bss_params.data_rates, + priv->curr_bss_params.num_of_rates); } /* diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c index c82eb7ff2fa2..07f6e0092552 100644 --- a/drivers/net/wireless/mwifiex/cmdevt.c +++ b/drivers/net/wireless/mwifiex/cmdevt.c @@ -67,7 +67,7 @@ mwifiex_get_cmd_node(struct mwifiex_adapter *adapter) return NULL; } cmd_node = list_first_entry(&adapter->cmd_free_q, - struct cmd_ctrl_node, list); + struct cmd_ctrl_node, list); list_del(&cmd_node->list); spin_unlock_irqrestore(&adapter->cmd_free_q_lock, flags); @@ -158,8 +158,9 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, /* Set command sequence number */ adapter->seq_num++; host_cmd->seq_num = cpu_to_le16(HostCmd_SET_SEQ_NO_BSS_INFO - (adapter->seq_num, cmd_node->priv->bss_num, - cmd_node->priv->bss_type)); + (adapter->seq_num, + cmd_node->priv->bss_num, + cmd_node->priv->bss_type)); spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); adapter->curr_cmd = cmd_node; @@ -174,8 +175,8 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, dev_dbg(adapter->dev, "cmd: DNLD_CMD: (%lu.%lu): %#x, act %#x, len %d," " seqno %#x\n", tstamp.tv_sec, tstamp.tv_usec, cmd_code, - le16_to_cpu(*(__le16 *) ((u8 *) host_cmd + S_DS_GEN)), cmd_size, - le16_to_cpu(host_cmd->seq_num)); + le16_to_cpu(*(__le16 *) ((u8 *) host_cmd + S_DS_GEN)), cmd_size, + le16_to_cpu(host_cmd->seq_num)); skb_push(cmd_node->cmd_skb, INTF_HEADER_LEN); @@ -200,17 +201,17 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, /* Save the last command id and action to debug log */ adapter->dbg.last_cmd_index = - (adapter->dbg.last_cmd_index + 1) % DBG_CMD_NUM; + (adapter->dbg.last_cmd_index + 1) % DBG_CMD_NUM; adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index] = cmd_code; adapter->dbg.last_cmd_act[adapter->dbg.last_cmd_index] = - le16_to_cpu(*(__le16 *) ((u8 *) host_cmd + S_DS_GEN)); + le16_to_cpu(*(__le16 *) ((u8 *) host_cmd + S_DS_GEN)); /* Clear BSS_NO_BITS from HostCmd */ cmd_code &= HostCmd_CMD_ID_MASK; /* Setup the timer after transmit command */ mod_timer(&adapter->cmd_timer, - jiffies + (MWIFIEX_TIMER_10S * HZ) / 1000); + jiffies + (MWIFIEX_TIMER_10S * HZ) / 1000); return 0; } @@ -230,7 +231,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) struct mwifiex_private *priv; struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) - adapter->sleep_cfm->data; + adapter->sleep_cfm->data; priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); sleep_cfm_buf->seq_num = @@ -250,7 +251,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) return -1; } if (GET_BSS_ROLE(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY)) - == MWIFIEX_BSS_ROLE_STA) { + == MWIFIEX_BSS_ROLE_STA) { if (!sleep_cfm_buf->resp_ctrl) /* Response is not needed for sleep confirm command */ @@ -258,12 +259,12 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) else adapter->ps_state = PS_STATE_SLEEP_CFM; - if (!sleep_cfm_buf->resp_ctrl - && (adapter->is_hs_configured - && !adapter->sleep_period.period)) { + if (!sleep_cfm_buf->resp_ctrl && + (adapter->is_hs_configured && + !adapter->sleep_period.period)) { adapter->pm_wakeup_card_req = true; - mwifiex_hs_activated_event(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_STA), true); + mwifiex_hs_activated_event(mwifiex_get_priv + (adapter, MWIFIEX_BSS_ROLE_STA), true); } } @@ -293,7 +294,7 @@ int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter) cmd_array = kzalloc(buf_size, GFP_KERNEL); if (!cmd_array) { dev_err(adapter->dev, "%s: failed to alloc cmd_array\n", - __func__); + __func__); return -ENOMEM; } @@ -376,9 +377,9 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter) /* Save the last event to debug log */ adapter->dbg.last_event_index = - (adapter->dbg.last_event_index + 1) % DBG_CMD_NUM; + (adapter->dbg.last_event_index + 1) % DBG_CMD_NUM; adapter->dbg.last_event[adapter->dbg.last_event_index] = - (u16) eventcause; + (u16) eventcause; /* Get BSS number and corresponding priv */ priv = mwifiex_get_priv_by_id(adapter, EVENT_GET_BSS_NUM(eventcause), @@ -398,7 +399,7 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter) if (eventcause != EVENT_PS_SLEEP && eventcause != EVENT_PS_AWAKE) { do_gettimeofday(&tstamp); dev_dbg(adapter->dev, "event: %lu.%lu: cause: %#x\n", - tstamp.tv_sec, tstamp.tv_usec, eventcause); + tstamp.tv_sec, tstamp.tv_usec, eventcause); } ret = mwifiex_process_sta_event(priv); @@ -509,7 +510,7 @@ int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no, /* Return error, since the command preparation failed */ if (ret) { dev_err(adapter->dev, "PREP_CMD: cmd %#x preparation failed\n", - cmd_no); + cmd_no); mwifiex_insert_cmd_to_free_q(adapter, cmd_node); return -1; } @@ -577,9 +578,9 @@ mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter, /* Exit_PS command needs to be queued in the header always. */ if (command == HostCmd_CMD_802_11_PS_MODE_ENH) { struct host_cmd_ds_802_11_ps_mode_enh *pm = - &host_cmd->params.psmode_enh; - if ((le16_to_cpu(pm->action) == DIS_PS) - || (le16_to_cpu(pm->action) == DIS_AUTO_PS)) { + &host_cmd->params.psmode_enh; + if ((le16_to_cpu(pm->action) == DIS_PS) || + (le16_to_cpu(pm->action) == DIS_AUTO_PS)) { if (adapter->ps_state != PS_STATE_AWAKE) add_tail = false; } @@ -692,7 +693,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) if (!adapter->curr_cmd || !adapter->curr_cmd->resp_skb) { resp = (struct host_cmd_ds_command *) adapter->upld_buf; dev_err(adapter->dev, "CMD_RESP: NULL curr_cmd, %#x\n", - le16_to_cpu(resp->command)); + le16_to_cpu(resp->command)); return -1; } @@ -701,7 +702,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data; if (adapter->curr_cmd->cmd_flag & CMD_F_CANCELED) { dev_err(adapter->dev, "CMD_RESP: %#x been canceled\n", - le16_to_cpu(resp->command)); + le16_to_cpu(resp->command)); mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); adapter->curr_cmd = NULL; @@ -725,8 +726,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) /* Get BSS number and corresponding priv */ priv = mwifiex_get_priv_by_id(adapter, - HostCmd_GET_BSS_NO(le16_to_cpu(resp->seq_num)), - HostCmd_GET_BSS_TYPE(le16_to_cpu(resp->seq_num))); + HostCmd_GET_BSS_NO(le16_to_cpu(resp->seq_num)), + HostCmd_GET_BSS_TYPE(le16_to_cpu(resp->seq_num))); if (!priv) priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); /* Clear RET_BIT from HostCmd */ @@ -737,9 +738,9 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) /* Save the last command response to debug log */ adapter->dbg.last_cmd_resp_index = - (adapter->dbg.last_cmd_resp_index + 1) % DBG_CMD_NUM; + (adapter->dbg.last_cmd_resp_index + 1) % DBG_CMD_NUM; adapter->dbg.last_cmd_resp_id[adapter->dbg.last_cmd_resp_index] = - orig_cmdresp_no; + orig_cmdresp_no; do_gettimeofday(&tstamp); dev_dbg(adapter->dev, "cmd: CMD_RESP: (%lu.%lu): 0x%x, result %d," @@ -761,8 +762,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) if (adapter->curr_cmd->cmd_flag & CMD_F_HOSTCMD) { adapter->curr_cmd->cmd_flag &= ~CMD_F_HOSTCMD; - if ((cmdresp_result == HostCmd_RESULT_OK) - && (cmdresp_no == HostCmd_CMD_802_11_HS_CFG_ENH)) + if ((cmdresp_result == HostCmd_RESULT_OK) && + (cmdresp_no == HostCmd_CMD_802_11_HS_CFG_ENH)) ret = mwifiex_ret_802_11_hs_cfg(priv, resp); } else { /* handle response */ @@ -824,44 +825,45 @@ mwifiex_cmd_timeout_func(unsigned long function_context) adapter->dbg.timeout_cmd_act = adapter->dbg.last_cmd_act[adapter->dbg.last_cmd_index]; do_gettimeofday(&tstamp); - dev_err(adapter->dev, "%s: Timeout cmd id (%lu.%lu) = %#x," - " act = %#x\n", __func__, - tstamp.tv_sec, tstamp.tv_usec, - adapter->dbg.timeout_cmd_id, - adapter->dbg.timeout_cmd_act); + dev_err(adapter->dev, + "%s: Timeout cmd id (%lu.%lu) = %#x, act = %#x\n", + __func__, tstamp.tv_sec, tstamp.tv_usec, + adapter->dbg.timeout_cmd_id, + adapter->dbg.timeout_cmd_act); dev_err(adapter->dev, "num_data_h2c_failure = %d\n", - adapter->dbg.num_tx_host_to_card_failure); + adapter->dbg.num_tx_host_to_card_failure); dev_err(adapter->dev, "num_cmd_h2c_failure = %d\n", - adapter->dbg.num_cmd_host_to_card_failure); + adapter->dbg.num_cmd_host_to_card_failure); dev_err(adapter->dev, "num_cmd_timeout = %d\n", - adapter->dbg.num_cmd_timeout); + adapter->dbg.num_cmd_timeout); dev_err(adapter->dev, "num_tx_timeout = %d\n", - adapter->dbg.num_tx_timeout); + adapter->dbg.num_tx_timeout); dev_err(adapter->dev, "last_cmd_index = %d\n", - adapter->dbg.last_cmd_index); + adapter->dbg.last_cmd_index); print_hex_dump_bytes("last_cmd_id: ", DUMP_PREFIX_OFFSET, - adapter->dbg.last_cmd_id, DBG_CMD_NUM); + adapter->dbg.last_cmd_id, DBG_CMD_NUM); print_hex_dump_bytes("last_cmd_act: ", DUMP_PREFIX_OFFSET, - adapter->dbg.last_cmd_act, DBG_CMD_NUM); + adapter->dbg.last_cmd_act, DBG_CMD_NUM); dev_err(adapter->dev, "last_cmd_resp_index = %d\n", - adapter->dbg.last_cmd_resp_index); + adapter->dbg.last_cmd_resp_index); print_hex_dump_bytes("last_cmd_resp_id: ", DUMP_PREFIX_OFFSET, - adapter->dbg.last_cmd_resp_id, DBG_CMD_NUM); + adapter->dbg.last_cmd_resp_id, + DBG_CMD_NUM); dev_err(adapter->dev, "last_event_index = %d\n", - adapter->dbg.last_event_index); + adapter->dbg.last_event_index); print_hex_dump_bytes("last_event: ", DUMP_PREFIX_OFFSET, - adapter->dbg.last_event, DBG_CMD_NUM); + adapter->dbg.last_event, DBG_CMD_NUM); dev_err(adapter->dev, "data_sent=%d cmd_sent=%d\n", - adapter->data_sent, adapter->cmd_sent); + adapter->data_sent, adapter->cmd_sent); dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n", - adapter->ps_mode, adapter->ps_state); + adapter->ps_mode, adapter->ps_state); } if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) mwifiex_init_fw_complete(adapter); @@ -942,7 +944,7 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter) uint16_t cancel_scan_cmd = false; if ((adapter->curr_cmd) && - (adapter->curr_cmd->wait_q_enabled)) { + (adapter->curr_cmd->wait_q_enabled)) { spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags); cmd_node = adapter->curr_cmd; cmd_node->wait_q_enabled = false; @@ -996,9 +998,9 @@ mwifiex_check_ps_cond(struct mwifiex_adapter *adapter) else dev_dbg(adapter->dev, "cmd: Delay Sleep Confirm (%s%s%s)\n", - (adapter->cmd_sent) ? "D" : "", - (adapter->curr_cmd) ? "C" : "", - (IS_CARD_RX_RCVD(adapter)) ? "R" : ""); + (adapter->cmd_sent) ? "D" : "", + (adapter->curr_cmd) ? "C" : "", + (IS_CARD_RX_RCVD(adapter)) ? "R" : ""); } /* @@ -1050,8 +1052,8 @@ int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv, dev_dbg(adapter->dev, "cmd: CMD_RESP: HS_CFG cmd reply" " result=%#x, conditions=0x%x gpio=0x%x gap=0x%x\n", resp->result, conditions, - phs_cfg->params.hs_config.gpio, - phs_cfg->params.hs_config.gap); + phs_cfg->params.hs_config.gpio, + phs_cfg->params.hs_config.gap); } if (conditions != HOST_SLEEP_CFG_CANCEL) { adapter->is_hs_configured = true; @@ -1078,7 +1080,8 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter) adapter->hs_activated = false; adapter->is_hs_configured = false; mwifiex_hs_activated_event(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY), false); + MWIFIEX_BSS_ROLE_ANY), + false); } /* @@ -1114,22 +1117,24 @@ mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *adapter, command &= HostCmd_CMD_ID_MASK; if (command != HostCmd_CMD_802_11_PS_MODE_ENH) { - dev_err(adapter->dev, "%s: received unexpected response for" - " cmd %x, result = %x\n", __func__, command, result); + dev_err(adapter->dev, + "%s: rcvd unexpected resp for cmd %#x, result = %x\n", + __func__, command, result); return; } if (result) { dev_err(adapter->dev, "%s: sleep confirm cmd failed\n", - __func__); + __func__); adapter->pm_wakeup_card_req = false; adapter->ps_state = PS_STATE_AWAKE; return; } adapter->pm_wakeup_card_req = true; if (adapter->is_hs_configured) - mwifiex_hs_activated_event(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY), true); + mwifiex_hs_activated_event(mwifiex_get_priv + (adapter, MWIFIEX_BSS_ROLE_ANY), + true); adapter->ps_state = PS_STATE_SLEEP; cmd->command = cpu_to_le16(command); cmd->seq_num = cpu_to_le16(seq_num); @@ -1163,17 +1168,17 @@ int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, psmode_enh->action = cpu_to_le16(DIS_AUTO_PS); psmode_enh->params.ps_bitmap = cpu_to_le16(ps_bitmap); cmd->size = cpu_to_le16(S_DS_GEN + sizeof(psmode_enh->action) + - sizeof(psmode_enh->params.ps_bitmap)); + sizeof(psmode_enh->params.ps_bitmap)); } else if (cmd_action == GET_PS) { psmode_enh->action = cpu_to_le16(GET_PS); psmode_enh->params.ps_bitmap = cpu_to_le16(ps_bitmap); cmd->size = cpu_to_le16(S_DS_GEN + sizeof(psmode_enh->action) + - sizeof(psmode_enh->params.ps_bitmap)); + sizeof(psmode_enh->params.ps_bitmap)); } else if (cmd_action == EN_AUTO_PS) { psmode_enh->action = cpu_to_le16(EN_AUTO_PS); psmode_enh->params.ps_bitmap = cpu_to_le16(ps_bitmap); cmd_size = S_DS_GEN + sizeof(psmode_enh->action) + - sizeof(psmode_enh->params.ps_bitmap); + sizeof(psmode_enh->params.ps_bitmap); tlv = (u8 *) cmd + cmd_size; if (ps_bitmap & BITMAP_STA_PS) { struct mwifiex_adapter *adapter = priv->adapter; @@ -1187,19 +1192,18 @@ int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, tlv += sizeof(*ps_tlv); dev_dbg(adapter->dev, "cmd: PS Command: Enter PS\n"); ps_mode->null_pkt_interval = - cpu_to_le16(adapter->null_pkt_interval); + cpu_to_le16(adapter->null_pkt_interval); ps_mode->multiple_dtims = - cpu_to_le16(adapter->multiple_dtim); + cpu_to_le16(adapter->multiple_dtim); ps_mode->bcn_miss_timeout = - cpu_to_le16(adapter->bcn_miss_time_out); + cpu_to_le16(adapter->bcn_miss_time_out); ps_mode->local_listen_interval = cpu_to_le16(adapter->local_listen_interval); ps_mode->adhoc_wake_period = cpu_to_le16(adapter->adhoc_awake_period); ps_mode->delay_to_ps = - cpu_to_le16(adapter->delay_to_ps); - ps_mode->mode = - cpu_to_le16(adapter->enhanced_ps_mode); + cpu_to_le16(adapter->delay_to_ps); + ps_mode->mode = cpu_to_le16(adapter->enhanced_ps_mode); } if (ps_bitmap & BITMAP_AUTO_DS) { @@ -1217,7 +1221,7 @@ int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, if (auto_ds) idletime = auto_ds->idle_time; dev_dbg(priv->adapter->dev, - "cmd: PS Command: Enter Auto Deep Sleep\n"); + "cmd: PS Command: Enter Auto Deep Sleep\n"); auto_ds_tlv->deep_sleep_timeout = cpu_to_le16(idletime); } cmd->size = cpu_to_le16(cmd_size); @@ -1244,8 +1248,9 @@ int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv, uint16_t auto_ps_bitmap = le16_to_cpu(ps_mode->params.ps_bitmap); - dev_dbg(adapter->dev, "info: %s: PS_MODE cmd reply result=%#x action=%#X\n", - __func__, resp->result, action); + dev_dbg(adapter->dev, + "info: %s: PS_MODE cmd reply result=%#x action=%#X\n", + __func__, resp->result, action); if (action == EN_AUTO_PS) { if (auto_ps_bitmap & BITMAP_AUTO_DS) { dev_dbg(adapter->dev, "cmd: Enabled auto deep sleep\n"); @@ -1254,7 +1259,8 @@ int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv, if (auto_ps_bitmap & BITMAP_STA_PS) { dev_dbg(adapter->dev, "cmd: Enabled STA power save\n"); if (adapter->sleep_period.period) - dev_dbg(adapter->dev, "cmd: set to uapsd/pps mode\n"); + dev_dbg(adapter->dev, + "cmd: set to uapsd/pps mode\n"); } } else if (action == DIS_AUTO_PS) { if (ps_bitmap & BITMAP_AUTO_DS) { @@ -1373,12 +1379,13 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, adapter->number_of_antenna = le16_to_cpu(hw_spec->number_of_antenna); dev_dbg(adapter->dev, "info: GET_HW_SPEC: fw_release_number- %#x\n", - adapter->fw_release_number); + adapter->fw_release_number); dev_dbg(adapter->dev, "info: GET_HW_SPEC: permanent addr: %pM\n", - hw_spec->permanent_addr); - dev_dbg(adapter->dev, "info: GET_HW_SPEC: hw_if_version=%#x version=%#x\n", + hw_spec->permanent_addr); + dev_dbg(adapter->dev, + "info: GET_HW_SPEC: hw_if_version=%#x version=%#x\n", le16_to_cpu(hw_spec->hw_if_version), - le16_to_cpu(hw_spec->version)); + le16_to_cpu(hw_spec->version)); if (priv->curr_addr[0] == 0xff) memmove(priv->curr_addr, hw_spec->permanent_addr, ETH_ALEN); @@ -1393,7 +1400,8 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, /* If it's unidentified region code, use the default (USA) */ if (i >= MWIFIEX_MAX_REGION_CODE) { adapter->region_code = 0x10; - dev_dbg(adapter->dev, "cmd: unknown region code, use default (USA)\n"); + dev_dbg(adapter->dev, + "cmd: unknown region code, use default (USA)\n"); } adapter->hw_dot_11n_dev_cap = le32_to_cpu(hw_spec->dot_11n_dev_cap); -- GitLab From 931f15842a9e1251d46a681bd10d2033f6fb1ffd Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:36 -0700 Subject: [PATCH 1735/1846] mwifiex: fix checkpatch --strict warnings/errors Part 3 For files fw.h, init.c and join.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/fw.h | 4 +- drivers/net/wireless/mwifiex/init.c | 31 +++--- drivers/net/wireless/mwifiex/join.c | 164 ++++++++++++++-------------- 3 files changed, 98 insertions(+), 101 deletions(-) diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h index fc4ffee6c6b9..e98fc5af73dc 100644 --- a/drivers/net/wireless/mwifiex/fw.h +++ b/drivers/net/wireless/mwifiex/fw.h @@ -117,8 +117,8 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { #define BA_STREAM_NOT_ALLOWED 0xff #define IS_11N_ENABLED(priv) ((priv->adapter->config_bands & BAND_GN || \ - priv->adapter->config_bands & BAND_AN) \ - && priv->curr_bss_params.bss_descriptor.bcn_ht_cap) + priv->adapter->config_bands & BAND_AN) && \ + priv->curr_bss_params.bss_descriptor.bcn_ht_cap) #define INITIATOR_BIT(DelBAParamSet) (((DelBAParamSet) &\ BIT(DELBA_INITIATOR_POS)) >> DELBA_INITIATOR_POS) diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index e81bf6ef1666..54bb4839b57c 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c @@ -35,28 +35,24 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv) { struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_bss_prio_node *bss_prio; + struct mwifiex_bss_prio_tbl *tbl = adapter->bss_prio_tbl; unsigned long flags; bss_prio = kzalloc(sizeof(struct mwifiex_bss_prio_node), GFP_KERNEL); if (!bss_prio) { dev_err(adapter->dev, "%s: failed to alloc bss_prio\n", - __func__); + __func__); return -ENOMEM; } bss_prio->priv = priv; INIT_LIST_HEAD(&bss_prio->list); - if (!adapter->bss_prio_tbl[priv->bss_priority].bss_prio_cur) - adapter->bss_prio_tbl[priv->bss_priority].bss_prio_cur = - bss_prio; - - spin_lock_irqsave(&adapter->bss_prio_tbl[priv->bss_priority] - .bss_prio_lock, flags); - list_add_tail(&bss_prio->list, - &adapter->bss_prio_tbl[priv->bss_priority] - .bss_prio_head); - spin_unlock_irqrestore(&adapter->bss_prio_tbl[priv->bss_priority] - .bss_prio_lock, flags); + if (!tbl[priv->bss_priority].bss_prio_cur) + tbl[priv->bss_priority].bss_prio_cur = bss_prio; + + spin_lock_irqsave(&tbl[priv->bss_priority].bss_prio_lock, flags); + list_add_tail(&bss_prio->list, &tbl[priv->bss_priority].bss_prio_head); + spin_unlock_irqrestore(&tbl[priv->bss_priority].bss_prio_lock, flags); return 0; } @@ -157,13 +153,13 @@ static int mwifiex_allocate_adapter(struct mwifiex_adapter *adapter) ret = mwifiex_alloc_cmd_buffer(adapter); if (ret) { dev_err(adapter->dev, "%s: failed to alloc cmd buffer\n", - __func__); + __func__); return -1; } adapter->sleep_cfm = dev_alloc_skb(sizeof(struct mwifiex_opt_sleep_confirm) - + INTF_HEADER_LEN); + + INTF_HEADER_LEN); if (!adapter->sleep_cfm) { dev_err(adapter->dev, "%s: failed to alloc sleep cfm" @@ -520,7 +516,7 @@ static void mwifiex_delete_bss_prio_tbl(struct mwifiex_private *priv) struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_bss_prio_node *bssprio_node, *tmp_node, **cur; struct list_head *head; - spinlock_t *lock; + spinlock_t *lock; /* bss priority lock */ unsigned long flags; for (i = 0; i < adapter->priv_num; ++i) { @@ -638,7 +634,7 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, ret = adapter->if_ops.check_fw_status(adapter, poll_num); if (!ret) { dev_notice(adapter->dev, - "WLAN FW already running! Skip FW download\n"); + "WLAN FW already running! Skip FW download\n"); goto done; } poll_num = MAX_FIRMWARE_POLL_TRIES; @@ -646,8 +642,7 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, /* Check if we are the winner for downloading FW */ if (!adapter->winner) { dev_notice(adapter->dev, - "Other interface already running!" - " Skip FW download\n"); + "Other intf already running! Skip FW download\n"); poll_num = MAX_MULTI_INTERFACE_POLL_TRIES; goto poll_fw; } diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c index 803275f58c78..8f9382b9c3ca 100644 --- a/drivers/net/wireless/mwifiex/join.c +++ b/drivers/net/wireless/mwifiex/join.c @@ -52,8 +52,9 @@ mwifiex_cmd_append_generic_ie(struct mwifiex_private *priv, u8 **buffer) * parameter buffer pointer. */ if (priv->gen_ie_buf_len) { - dev_dbg(priv->adapter->dev, "info: %s: append generic %d to %p\n", - __func__, priv->gen_ie_buf_len, *buffer); + dev_dbg(priv->adapter->dev, + "info: %s: append generic ie len %d to %p\n", + __func__, priv->gen_ie_buf_len, *buffer); /* Wrap the generic IE buffer with a pass through TLV type */ ie_header.type = cpu_to_le16(TLV_TYPE_PASSTHROUGH); @@ -123,8 +124,9 @@ mwifiex_cmd_append_tsf_tlv(struct mwifiex_private *priv, u8 **buffer, memcpy(&tsf_val, bss_desc->time_stamp, sizeof(tsf_val)); - dev_dbg(priv->adapter->dev, "info: %s: TSF offset calc: %016llx - " - "%016llx\n", __func__, tsf_val, bss_desc->network_tsf); + dev_dbg(priv->adapter->dev, + "info: %s: TSF offset calc: %016llx - %016llx\n", + __func__, tsf_val, bss_desc->network_tsf); memcpy(*buffer, &tsf_val, sizeof(tsf_val)); *buffer += sizeof(tsf_val); @@ -167,7 +169,7 @@ static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1, } dev_dbg(priv->adapter->dev, "info: Tx data rate set to %#x\n", - priv->data_rate); + priv->data_rate); if (!priv->is_data_rate_auto) { while (*ptr) { @@ -212,7 +214,7 @@ mwifiex_setup_rates_from_bssdesc(struct mwifiex_private *priv, card_rates, card_rates_size)) { *out_rates_size = 0; dev_err(priv->adapter->dev, "%s: cannot get common rates\n", - __func__); + __func__); return -1; } @@ -248,7 +250,7 @@ mwifiex_cmd_append_wapi_ie(struct mwifiex_private *priv, u8 **buffer) */ if (priv->wapi_ie_len) { dev_dbg(priv->adapter->dev, "cmd: append wapi ie %d to %p\n", - priv->wapi_ie_len, *buffer); + priv->wapi_ie_len, *buffer); /* Wrap the generic IE buffer with a pass through TLV type */ ie_header.type = cpu_to_le16(TLV_TYPE_WAPI_IE); @@ -293,10 +295,10 @@ static int mwifiex_append_rsn_ie_wpa_wpa2(struct mwifiex_private *priv, le16_to_cpu(rsn_ie_tlv->header.type) & 0x00FF); rsn_ie_tlv->header.len = cpu_to_le16((u16) priv->wpa_ie[1]); rsn_ie_tlv->header.len = cpu_to_le16(le16_to_cpu(rsn_ie_tlv->header.len) - & 0x00FF); + & 0x00FF); if (le16_to_cpu(rsn_ie_tlv->header.len) <= (sizeof(priv->wpa_ie) - 2)) memcpy(rsn_ie_tlv->rsn_ie, &priv->wpa_ie[2], - le16_to_cpu(rsn_ie_tlv->header.len)); + le16_to_cpu(rsn_ie_tlv->header.len)); else return -1; @@ -379,7 +381,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, ssid_tlv->header.type = cpu_to_le16(WLAN_EID_SSID); ssid_tlv->header.len = cpu_to_le16((u16) bss_desc->ssid.ssid_len); memcpy(ssid_tlv->ssid, bss_desc->ssid.ssid, - le16_to_cpu(ssid_tlv->header.len)); + le16_to_cpu(ssid_tlv->header.len)); pos += sizeof(ssid_tlv->header) + le16_to_cpu(ssid_tlv->header.len); phy_tlv = (struct mwifiex_ie_types_phy_param_set *) pos; @@ -411,7 +413,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, memcpy(rates_tlv->rates, rates, rates_size); pos += sizeof(rates_tlv->header) + rates_size; dev_dbg(priv->adapter->dev, "info: ASSOC_CMD: rates size = %d\n", - rates_size); + rates_size); /* Add the Authentication type to be used for Auth frames */ auth_tlv = (struct mwifiex_ie_types_auth_type *) pos; @@ -425,12 +427,12 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, pos += sizeof(auth_tlv->header) + le16_to_cpu(auth_tlv->header.len); - if (IS_SUPPORT_MULTI_BANDS(priv->adapter) - && !(ISSUPP_11NENABLED(priv->adapter->fw_cap_info) - && (!bss_desc->disable_11n) - && (priv->adapter->config_bands & BAND_GN - || priv->adapter->config_bands & BAND_AN) - && (bss_desc->bcn_ht_cap) + if (IS_SUPPORT_MULTI_BANDS(priv->adapter) && + !(ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && + (!bss_desc->disable_11n) && + (priv->adapter->config_bands & BAND_GN || + priv->adapter->config_bands & BAND_AN) && + (bss_desc->bcn_ht_cap) ) ) { /* Append a channel TLV for the channel the attempted AP was @@ -445,13 +447,13 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, chan_tlv->chan_scan_param[0].chan_number = (bss_desc->phy_param_set.ds_param_set.current_chan); dev_dbg(priv->adapter->dev, "info: Assoc: TLV Chan = %d\n", - chan_tlv->chan_scan_param[0].chan_number); + chan_tlv->chan_scan_param[0].chan_number); chan_tlv->chan_scan_param[0].radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band); dev_dbg(priv->adapter->dev, "info: Assoc: TLV Band = %d\n", - chan_tlv->chan_scan_param[0].radio_type); + chan_tlv->chan_scan_param[0].radio_type); pos += sizeof(chan_tlv->header) + sizeof(struct mwifiex_chan_scan_param_set); } @@ -464,10 +466,10 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, return -1; } - if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) - && (!bss_desc->disable_11n) - && (priv->adapter->config_bands & BAND_GN - || priv->adapter->config_bands & BAND_AN)) + if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && + (!bss_desc->disable_11n) && + (priv->adapter->config_bands & BAND_GN || + priv->adapter->config_bands & BAND_AN)) mwifiex_cmd_append_11n_tlv(priv, bss_desc, &pos); /* Append vendor specific IE TLV */ @@ -493,7 +495,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, tmp_cap &= CAPINFO_MASK; dev_dbg(priv->adapter->dev, "info: ASSOC_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n", - tmp_cap, CAPINFO_MASK); + tmp_cap, CAPINFO_MASK); assoc->cap_info_bitmap = cpu_to_le16(tmp_cap); return 0; @@ -573,17 +575,17 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, assoc_rsp = (struct ieee_types_assoc_rsp *) &resp->params; priv->assoc_rsp_size = min(le16_to_cpu(resp->size) - S_DS_GEN, - sizeof(priv->assoc_rsp_buf)); + sizeof(priv->assoc_rsp_buf)); memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size); if (le16_to_cpu(assoc_rsp->status_code)) { priv->adapter->dbg.num_cmd_assoc_failure++; - dev_err(priv->adapter->dev, "ASSOC_RESP: association failed, " - "status code = %d, error = 0x%x, a_id = 0x%x\n", - le16_to_cpu(assoc_rsp->status_code), - le16_to_cpu(assoc_rsp->cap_info_bitmap), - le16_to_cpu(assoc_rsp->a_id)); + dev_err(priv->adapter->dev, + "ASSOC_RESP: failed, status code=%d err=%#x a_id=%#x\n", + le16_to_cpu(assoc_rsp->status_code), + le16_to_cpu(assoc_rsp->cap_info_bitmap), + le16_to_cpu(assoc_rsp->a_id)); ret = le16_to_cpu(assoc_rsp->status_code); goto done; @@ -600,7 +602,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, bss_desc = priv->attempted_bss_desc; dev_dbg(priv->adapter->dev, "info: ASSOC_RESP: %s\n", - bss_desc->ssid.ssid); + bss_desc->ssid.ssid); /* Make a copy of current BSSID descriptor */ memcpy(&priv->curr_bss_params.bss_descriptor, @@ -617,8 +619,8 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, else priv->curr_bss_params.wmm_enabled = false; - if ((priv->wmm_required || bss_desc->bcn_ht_cap) - && priv->curr_bss_params.wmm_enabled) + if ((priv->wmm_required || bss_desc->bcn_ht_cap) && + priv->curr_bss_params.wmm_enabled) priv->wmm_enabled = true; else priv->wmm_enabled = false; @@ -631,7 +633,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, IEEE80211_WMM_IE_AP_QOSINFO_UAPSD) ? 1 : 0); dev_dbg(priv->adapter->dev, "info: ASSOC_RESP: curr_pkt_filter is %#x\n", - priv->curr_pkt_filter); + priv->curr_pkt_filter); if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled) priv->wpa_is_gtk_set = false; @@ -755,7 +757,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, memcpy(adhoc_start->ssid, req_ssid->ssid, req_ssid->ssid_len); dev_dbg(adapter->dev, "info: ADHOC_S_CMD: SSID = %s\n", - adhoc_start->ssid); + adhoc_start->ssid); memset(bss_desc->ssid.ssid, 0, IEEE80211_MAX_SSID_LEN); memcpy(bss_desc->ssid.ssid, req_ssid->ssid, req_ssid->ssid_len); @@ -792,7 +794,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, } dev_dbg(adapter->dev, "info: ADHOC_S_CMD: creating ADHOC on channel %d\n", - priv->adhoc_channel); + priv->adhoc_channel); priv->curr_bss_params.bss_descriptor.channel = priv->adhoc_channel; priv->curr_bss_params.band = adapter->adhoc_start_band; @@ -813,7 +815,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, adhoc_start->ss_param_set.ibss_param_set.element_id = IBSS_PARA_IE_ID; adhoc_start->ss_param_set.ibss_param_set.len = IBSS_PARA_IE_LEN; adhoc_start->ss_param_set.ibss_param_set.atim_window - = cpu_to_le16(priv->atim_window); + = cpu_to_le16(priv->atim_window); memcpy(&bss_desc->ss_param_set, &adhoc_start->ss_param_set, sizeof(union ieee_types_ss_param_set)); @@ -841,10 +843,10 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, if ((adapter->adhoc_start_band & BAND_G) && (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, - HostCmd_ACT_GEN_SET, 0, - &priv->curr_pkt_filter)) { + HostCmd_ACT_GEN_SET, 0, + &priv->curr_pkt_filter)) { dev_err(adapter->dev, - "ADHOC_S_CMD: G Protection config failed\n"); + "ADHOC_S_CMD: G Protection config failed\n"); return -1; } } @@ -860,8 +862,8 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, &adhoc_start->data_rate, priv->curr_bss_params.num_of_rates); dev_dbg(adapter->dev, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n", - adhoc_start->data_rate[0], adhoc_start->data_rate[1], - adhoc_start->data_rate[2], adhoc_start->data_rate[3]); + adhoc_start->data_rate[0], adhoc_start->data_rate[1], + adhoc_start->data_rate[2], adhoc_start->data_rate[3]); dev_dbg(adapter->dev, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n"); @@ -878,12 +880,12 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, (u8) priv->curr_bss_params.bss_descriptor.channel; dev_dbg(adapter->dev, "info: ADHOC_S_CMD: TLV Chan = %d\n", - chan_tlv->chan_scan_param[0].chan_number); + chan_tlv->chan_scan_param[0].chan_number); chan_tlv->chan_scan_param[0].radio_type = mwifiex_band_to_radio_type(priv->curr_bss_params.band); - if (adapter->adhoc_start_band & BAND_GN - || adapter->adhoc_start_band & BAND_AN) { + if (adapter->adhoc_start_band & BAND_GN || + adapter->adhoc_start_band & BAND_AN) { if (adapter->sec_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) chan_tlv->chan_scan_param[0].radio_type |= @@ -894,7 +896,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, (IEEE80211_HT_PARAM_CHA_SEC_BELOW << 4); } dev_dbg(adapter->dev, "info: ADHOC_S_CMD: TLV Band = %d\n", - chan_tlv->chan_scan_param[0].radio_type); + chan_tlv->chan_scan_param[0].radio_type); pos += sizeof(chan_tlv->header) + sizeof(struct mwifiex_chan_scan_param_set); cmd_append_size += @@ -925,15 +927,14 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, mwifiex_fill_cap_info(priv, radio_type, ht_cap); pos += sizeof(struct mwifiex_ie_types_htcap); - cmd_append_size += - sizeof(struct mwifiex_ie_types_htcap); + cmd_append_size += sizeof(struct mwifiex_ie_types_htcap); /* Fill HT INFORMATION */ ht_info = (struct mwifiex_ie_types_htinfo *) pos; memset(ht_info, 0, sizeof(struct mwifiex_ie_types_htinfo)); ht_info->header.type = cpu_to_le16(WLAN_EID_HT_INFORMATION); ht_info->header.len = - cpu_to_le16(sizeof(struct ieee80211_ht_info)); + cpu_to_le16(sizeof(struct ieee80211_ht_info)); ht_info->ht_info.control_chan = (u8) priv->curr_bss_params.bss_descriptor.channel; @@ -947,12 +948,12 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, ht_info->ht_info.basic_set[0] = 0xff; pos += sizeof(struct mwifiex_ie_types_htinfo); cmd_append_size += - sizeof(struct mwifiex_ie_types_htinfo); + sizeof(struct mwifiex_ie_types_htinfo); } - cmd->size = cpu_to_le16((u16) - (sizeof(struct host_cmd_ds_802_11_ad_hoc_start) - + S_DS_GEN + cmd_append_size)); + cmd->size = + cpu_to_le16((u16)(sizeof(struct host_cmd_ds_802_11_ad_hoc_start) + + S_DS_GEN + cmd_append_size)); if (adapter->adhoc_start_band == BAND_B) tmp_cap &= ~WLAN_CAPABILITY_SHORT_SLOT_TIME; @@ -1005,10 +1006,10 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, curr_pkt_filter | HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON; if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, - HostCmd_ACT_GEN_SET, 0, - &curr_pkt_filter)) { + HostCmd_ACT_GEN_SET, 0, + &curr_pkt_filter)) { dev_err(priv->adapter->dev, - "ADHOC_J_CMD: G Protection config failed\n"); + "ADHOC_J_CMD: G Protection config failed\n"); return -1; } } @@ -1039,13 +1040,14 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, tmp_cap &= CAPINFO_MASK; - dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: tmp_cap=%4X" - " CAPINFO_MASK=%4lX\n", tmp_cap, CAPINFO_MASK); + dev_dbg(priv->adapter->dev, + "info: ADHOC_J_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n", + tmp_cap, CAPINFO_MASK); /* Information on BSSID descriptor passed to FW */ - dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: BSSID = %pM, SSID = %s\n", - adhoc_join->bss_descriptor.bssid, - adhoc_join->bss_descriptor.ssid); + dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: BSSID=%pM, SSID='%s'\n", + adhoc_join->bss_descriptor.bssid, + adhoc_join->bss_descriptor.ssid); for (i = 0; bss_desc->supported_rates[i] && i < MWIFIEX_SUPPORTED_RATES; @@ -1082,18 +1084,18 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, sizeof(struct mwifiex_chan_scan_param_set)); chan_tlv->chan_scan_param[0].chan_number = (bss_desc->phy_param_set.ds_param_set.current_chan); - dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: TLV Chan = %d\n", - chan_tlv->chan_scan_param[0].chan_number); + dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: TLV Chan=%d\n", + chan_tlv->chan_scan_param[0].chan_number); chan_tlv->chan_scan_param[0].radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band); - dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: TLV Band = %d\n", - chan_tlv->chan_scan_param[0].radio_type); + dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: TLV Band=%d\n", + chan_tlv->chan_scan_param[0].radio_type); pos += sizeof(chan_tlv->header) + - sizeof(struct mwifiex_chan_scan_param_set); + sizeof(struct mwifiex_chan_scan_param_set); cmd_append_size += sizeof(chan_tlv->header) + - sizeof(struct mwifiex_chan_scan_param_set); + sizeof(struct mwifiex_chan_scan_param_set); } if (priv->sec_info.wpa_enabled) @@ -1110,9 +1112,9 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, cmd_append_size += mwifiex_cmd_append_vsie_tlv(priv, MWIFIEX_VSIE_MASK_ADHOC, &pos); - cmd->size = cpu_to_le16((u16) - (sizeof(struct host_cmd_ds_802_11_ad_hoc_join) - + S_DS_GEN + cmd_append_size)); + cmd->size = cpu_to_le16 + ((u16) (sizeof(struct host_cmd_ds_802_11_ad_hoc_join) + + S_DS_GEN + cmd_append_size)); adhoc_join->bss_descriptor.cap_info_bitmap = cpu_to_le16(tmp_cap); @@ -1157,7 +1159,7 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, if (le16_to_cpu(resp->command) == HostCmd_CMD_802_11_AD_HOC_START) { dev_dbg(priv->adapter->dev, "info: ADHOC_S_RESP %s\n", - bss_desc->ssid.ssid); + bss_desc->ssid.ssid); /* Update the created network descriptor with the new BSSID */ memcpy(bss_desc->mac_address, @@ -1170,7 +1172,7 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, * If BSSID has changed use SSID to compare instead of BSSID */ dev_dbg(priv->adapter->dev, "info: ADHOC_J_RESP %s\n", - bss_desc->ssid.ssid); + bss_desc->ssid.ssid); /* * Make a copy of current BSSID descriptor, only needed for @@ -1184,9 +1186,9 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, } dev_dbg(priv->adapter->dev, "info: ADHOC_RESP: channel = %d\n", - priv->adhoc_channel); + priv->adhoc_channel); dev_dbg(priv->adapter->dev, "info: ADHOC_RESP: BSSID = %pM\n", - priv->curr_bss_params.bss_descriptor.mac_address); + priv->curr_bss_params.bss_descriptor.mac_address); if (!netif_carrier_ok(priv->netdev)) netif_carrier_on(priv->netdev); @@ -1249,9 +1251,9 @@ mwifiex_adhoc_start(struct mwifiex_private *priv, dev_dbg(priv->adapter->dev, "info: Adhoc Channel = %d\n", priv->adhoc_channel); dev_dbg(priv->adapter->dev, "info: curr_bss_params.channel = %d\n", - priv->curr_bss_params.bss_descriptor.channel); + priv->curr_bss_params.bss_descriptor.channel); dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %d\n", - priv->curr_bss_params.band); + priv->curr_bss_params.band); return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_AD_HOC_START, HostCmd_ACT_GEN_SET, 0, adhoc_ssid); @@ -1267,13 +1269,13 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc) { dev_dbg(priv->adapter->dev, "info: adhoc join: curr_bss ssid =%s\n", - priv->curr_bss_params.bss_descriptor.ssid.ssid); + priv->curr_bss_params.bss_descriptor.ssid.ssid); dev_dbg(priv->adapter->dev, "info: adhoc join: curr_bss ssid_len =%u\n", - priv->curr_bss_params.bss_descriptor.ssid.ssid_len); + priv->curr_bss_params.bss_descriptor.ssid.ssid_len); dev_dbg(priv->adapter->dev, "info: adhoc join: ssid =%s\n", bss_desc->ssid.ssid); dev_dbg(priv->adapter->dev, "info: adhoc join: ssid_len =%u\n", - bss_desc->ssid.ssid_len); + bss_desc->ssid.ssid_len); /* Check if the requested SSID is already joined */ if (priv->curr_bss_params.bss_descriptor.ssid.ssid_len && @@ -1287,9 +1289,9 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv, } dev_dbg(priv->adapter->dev, "info: curr_bss_params.channel = %d\n", - priv->curr_bss_params.bss_descriptor.channel); + priv->curr_bss_params.bss_descriptor.channel); dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %c\n", - priv->curr_bss_params.band); + priv->curr_bss_params.band); return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_AD_HOC_JOIN, HostCmd_ACT_GEN_SET, 0, bss_desc); -- GitLab From f57c1edc1e0622d2cf883850f37978827bcef573 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:37 -0700 Subject: [PATCH 1736/1846] mwifiex: fix checkpatch --strict warnings/errors Part 4 For files main.c, main.h and pcie.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/main.c | 49 ++-- drivers/net/wireless/mwifiex/main.h | 4 +- drivers/net/wireless/mwifiex/pcie.c | 384 +++++++++++++++------------- 3 files changed, 226 insertions(+), 211 deletions(-) diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index 790a3796483c..9d1b3ca6334b 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c @@ -64,11 +64,10 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, adapter->priv_num = 0; /* Allocate memory for private structure */ - adapter->priv[0] = kzalloc(sizeof(struct mwifiex_private), - GFP_KERNEL); + adapter->priv[0] = kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL); if (!adapter->priv[0]) { - dev_err(adapter->dev, "%s: failed to alloc priv[0]\n", - __func__); + dev_err(adapter->dev, + "%s: failed to alloc priv[0]\n", __func__); goto error; } @@ -169,8 +168,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) if ((adapter->ps_state == PS_STATE_SLEEP) && (adapter->pm_wakeup_card_req && !adapter->pm_wakeup_fw_try) && - (is_command_pending(adapter) - || !mwifiex_wmm_lists_empty(adapter))) { + (is_command_pending(adapter) || + !mwifiex_wmm_lists_empty(adapter))) { adapter->pm_wakeup_fw_try = true; adapter->if_ops.wakeup(adapter); continue; @@ -187,10 +186,10 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) adapter->tx_lock_flag) break; - if (adapter->scan_processing || adapter->data_sent - || mwifiex_wmm_lists_empty(adapter)) { - if (adapter->cmd_sent || adapter->curr_cmd - || (!is_command_pending(adapter))) + if (adapter->scan_processing || adapter->data_sent || + mwifiex_wmm_lists_empty(adapter)) { + if (adapter->cmd_sent || adapter->curr_cmd || + (!is_command_pending(adapter))) break; } } @@ -223,10 +222,10 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) /* * The ps_state may have been changed during processing of * Sleep Request event. */ - if ((adapter->ps_state == PS_STATE_SLEEP) - || (adapter->ps_state == PS_STATE_PRE_SLEEP) - || (adapter->ps_state == PS_STATE_SLEEP_CFM) - || adapter->tx_lock_flag) + if ((adapter->ps_state == PS_STATE_SLEEP) || + (adapter->ps_state == PS_STATE_PRE_SLEEP) || + (adapter->ps_state == PS_STATE_SLEEP_CFM) || + adapter->tx_lock_flag) continue; if (!adapter->cmd_sent && !adapter->curr_cmd) { @@ -249,8 +248,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) } if (adapter->delay_null_pkt && !adapter->cmd_sent && - !adapter->curr_cmd && !is_command_pending(adapter) - && mwifiex_wmm_lists_empty(adapter)) { + !adapter->curr_cmd && !is_command_pending(adapter) && + mwifiex_wmm_lists_empty(adapter)) { if (!mwifiex_send_null_packet (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET | @@ -371,7 +370,7 @@ mwifiex_fill_buffer(struct sk_buff *skb) iph = ip_hdr(skb); tid = IPTOS_PREC(iph->tos); pr_debug("data: packet type ETH_P_IP: %04x, tid=%#x prio=%#x\n", - eth->h_proto, tid, skb->priority); + eth->h_proto, tid, skb->priority); break; case __constant_htons(ETH_P_ARP): pr_debug("data: ARP packet: %04x\n", eth->h_proto); @@ -425,7 +424,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) struct mwifiex_txinfo *tx_info; dev_dbg(priv->adapter->dev, "data: %lu BSS(%d-%d): Data <= kernel\n", - jiffies, priv->bss_type, priv->bss_num); + jiffies, priv->bss_type, priv->bss_num); if (priv->adapter->surprise_removed) { kfree_skb(skb); @@ -441,7 +440,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN) { dev_dbg(priv->adapter->dev, "data: Tx: insufficient skb headroom %d\n", - skb_headroom(skb)); + skb_headroom(skb)); /* Insufficient skb headroom - allocate a new skb */ new_skb = skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN); @@ -454,7 +453,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) kfree_skb(skb); skb = new_skb; dev_dbg(priv->adapter->dev, "info: new skb headroomd %d\n", - skb_headroom(skb)); + skb_headroom(skb)); } tx_info = MWIFIEX_SKB_TXCB(skb); @@ -494,8 +493,8 @@ mwifiex_set_mac_address(struct net_device *dev, void *addr) if (!ret) memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN); else - dev_err(priv->adapter->dev, "set mac address failed: ret=%d" - "\n", ret); + dev_err(priv->adapter->dev, + "set mac address failed: ret=%d\n", ret); memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN); @@ -533,7 +532,7 @@ mwifiex_tx_timeout(struct net_device *dev) struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_type-num = %d-%d\n", - jiffies, priv->bss_type, priv->bss_num); + jiffies, priv->bss_type, priv->bss_num); mwifiex_set_trans_start(dev); priv->num_tx_timeout++; } @@ -704,7 +703,7 @@ mwifiex_add_card(void *card, struct semaphore *sem, rtnl_lock(); /* Create station interface by default */ if (!mwifiex_add_virtual_intf(priv->wdev->wiphy, "mlan%d", - NL80211_IFTYPE_STATION, NULL, NULL)) { + NL80211_IFTYPE_STATION, NULL, NULL)) { rtnl_unlock(); dev_err(adapter->dev, "cannot create default station" " interface\n"); @@ -781,7 +780,7 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem) if (priv && priv->netdev) { if (!netif_queue_stopped(priv->netdev)) mwifiex_stop_net_dev_queue(priv->netdev, - adapter); + 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 c0df48f63e11..35225e9b1080 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -841,8 +841,8 @@ mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter, for (i = 0; i < adapter->priv_num; i++) { if (adapter->priv[i]) { - if ((adapter->priv[i]->bss_num == bss_num) - && (adapter->priv[i]->bss_type == bss_type)) + if ((adapter->priv[i]->bss_num == bss_num) && + (adapter->priv[i]->bss_type == bss_type)) break; } } diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 1033f00a775f..e1f45ecf39a5 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -83,7 +83,7 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev, struct pcie_service_card *card; pr_debug("info: vendor=0x%4.04X device=0x%4.04X rev=%d\n", - pdev->vendor, pdev->device, pdev->revision); + pdev->vendor, pdev->device, pdev->revision); card = kzalloc(sizeof(struct pcie_service_card), GFP_KERNEL); if (!card) { @@ -110,6 +110,7 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) { struct pcie_service_card *card; struct mwifiex_adapter *adapter; + struct mwifiex_private *priv; int i; card = pci_get_drvdata(pdev); @@ -128,16 +129,15 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) for (i = 0; i < adapter->priv_num; i++) if ((GET_BSS_ROLE(adapter->priv[i]) == - MWIFIEX_BSS_ROLE_STA) && - adapter->priv[i]->media_connected) + MWIFIEX_BSS_ROLE_STA) && + adapter->priv[i]->media_connected) mwifiex_deauthenticate(adapter->priv[i], NULL); - mwifiex_disable_auto_ds(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY)); + priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); - mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY), - MWIFIEX_FUNC_SHUTDOWN); + mwifiex_disable_auto_ds(priv); + + mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN); } mwifiex_remove_card(card->adapter, &add_remove_card_sem); @@ -221,7 +221,7 @@ static int mwifiex_pcie_resume(struct pci_dev *pdev) netif_carrier_on(adapter->priv[i]->netdev); mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), - MWIFIEX_ASYNC_CMD); + MWIFIEX_ASYNC_CMD); return 0; } @@ -380,26 +380,26 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) /* allocate shared memory for the BD ring and divide the same in to several descriptors */ card->txbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * - MWIFIEX_MAX_TXRX_BD; + MWIFIEX_MAX_TXRX_BD; dev_dbg(adapter->dev, "info: txbd_ring: Allocating %d bytes\n", - card->txbd_ring_size); + card->txbd_ring_size); 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"); + dev_err(adapter->dev, "Unable to alloc buffer for txbd ring\n"); return -ENOMEM; } card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); - dev_dbg(adapter->dev, "info: txbd_ring - base: %p, pbase: %#x:%x," - "len: %x\n", card->txbd_ring_vbase, - (u32)card->txbd_ring_pbase, - (u32)((u64)card->txbd_ring_pbase >> 32), - card->txbd_ring_size); + dev_dbg(adapter->dev, + "info: txbd_ring - base: %p, pbase: %#x:%x, len: %x\n", + card->txbd_ring_vbase, (u32)card->txbd_ring_pbase, + (u32)((u64)card->txbd_ring_pbase >> 32), card->txbd_ring_size); for (i = 0; i < MWIFIEX_MAX_TXRX_BD; i++) { card->txbd_ring[i] = (struct mwifiex_pcie_buf_desc *) - (card->txbd_ring_vbase + - (sizeof(struct mwifiex_pcie_buf_desc) * i)); + (card->txbd_ring_vbase + + (sizeof(struct mwifiex_pcie_buf_desc) + * i)); /* Allocate buffer here so that firmware can DMA data from it */ skb = dev_alloc_skb(MWIFIEX_RX_DATA_BUF_SIZE); @@ -412,10 +412,9 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) skb_put(skb, MWIFIEX_RX_DATA_BUF_SIZE); dev_dbg(adapter->dev, "info: TX ring: add new skb base: %p, " - "buf_base: %p, buf_pbase: %#x:%x, " - "buf_len: %#x\n", skb, skb->data, - (u32)*buf_pa, (u32)(((u64)*buf_pa >> 32)), - skb->len); + "buf_base: %p, buf_pbase: %#x:%x, buf_len: %#x\n", + skb, skb->data, (u32)*buf_pa, + (u32)(((u64)*buf_pa >> 32)), skb->len); card->tx_buf_list[i] = skb; card->txbd_ring[i]->paddr = *buf_pa; @@ -469,9 +468,9 @@ static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) card->rxbd_rdptr |= MWIFIEX_BD_FLAG_ROLLOVER_IND; card->rxbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * - MWIFIEX_MAX_TXRX_BD; + MWIFIEX_MAX_TXRX_BD; dev_dbg(adapter->dev, "info: rxbd_ring: Allocating %d bytes\n", - card->rxbd_ring_size); + card->rxbd_ring_size); card->rxbd_ring_vbase = kzalloc(card->rxbd_ring_size, GFP_KERNEL); if (!card->rxbd_ring_vbase) { dev_err(adapter->dev, "Unable to allocate buffer for " @@ -480,21 +479,23 @@ static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) } card->rxbd_ring_pbase = virt_to_phys(card->rxbd_ring_vbase); - dev_dbg(adapter->dev, "info: rxbd_ring - base: %p, pbase: %#x:%x," - "len: %#x\n", card->rxbd_ring_vbase, - (u32)card->rxbd_ring_pbase, - (u32)((u64)card->rxbd_ring_pbase >> 32), - card->rxbd_ring_size); + dev_dbg(adapter->dev, + "info: rxbd_ring - base: %p, pbase: %#x:%x, len: %#x\n", + card->rxbd_ring_vbase, (u32)card->rxbd_ring_pbase, + (u32)((u64)card->rxbd_ring_pbase >> 32), + card->rxbd_ring_size); for (i = 0; i < MWIFIEX_MAX_TXRX_BD; i++) { card->rxbd_ring[i] = (struct mwifiex_pcie_buf_desc *) - (card->rxbd_ring_vbase + - (sizeof(struct mwifiex_pcie_buf_desc) * i)); + (card->rxbd_ring_vbase + + (sizeof(struct mwifiex_pcie_buf_desc) + * i)); /* Allocate skb here so that firmware can DMA data from it */ skb = dev_alloc_skb(MWIFIEX_RX_DATA_BUF_SIZE); if (!skb) { - dev_err(adapter->dev, "Unable to allocate skb for RX ring.\n"); + dev_err(adapter->dev, + "Unable to allocate skb for RX ring.\n"); kfree(card->rxbd_ring_vbase); return -ENOMEM; } @@ -502,10 +503,9 @@ static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) skb_put(skb, MWIFIEX_RX_DATA_BUF_SIZE); dev_dbg(adapter->dev, "info: RX ring: add new skb base: %p, " - "buf_base: %p, buf_pbase: %#x:%x, " - "buf_len: %#x\n", skb, skb->data, - (u32)*buf_pa, (u32)((u64)*buf_pa >> 32), - skb->len); + "buf_base: %p, buf_pbase: %#x:%x, buf_len: %#x\n", + skb, skb->data, (u32)*buf_pa, (u32)((u64)*buf_pa >> 32), + skb->len); card->rx_buf_list[i] = skb; card->rxbd_ring[i]->paddr = *buf_pa; @@ -562,32 +562,34 @@ static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) card->evtbd_rdptr |= MWIFIEX_BD_FLAG_ROLLOVER_IND; card->evtbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * - MWIFIEX_MAX_EVT_BD; + MWIFIEX_MAX_EVT_BD; dev_dbg(adapter->dev, "info: evtbd_ring: Allocating %d bytes\n", - card->evtbd_ring_size); + card->evtbd_ring_size); card->evtbd_ring_vbase = kzalloc(card->evtbd_ring_size, GFP_KERNEL); if (!card->evtbd_ring_vbase) { - dev_err(adapter->dev, "Unable to allocate buffer. " - "Terminating download\n"); + dev_err(adapter->dev, + "Unable to allocate buffer. Terminating download\n"); return -ENOMEM; } card->evtbd_ring_pbase = virt_to_phys(card->evtbd_ring_vbase); - dev_dbg(adapter->dev, "info: CMDRSP/EVT bd_ring - base: %p, " - "pbase: %#x:%x, len: %#x\n", card->evtbd_ring_vbase, - (u32)card->evtbd_ring_pbase, - (u32)((u64)card->evtbd_ring_pbase >> 32), - card->evtbd_ring_size); + dev_dbg(adapter->dev, + "info: CMDRSP/EVT bd_ring - base: %p pbase: %#x:%x len: %#x\n", + card->evtbd_ring_vbase, (u32)card->evtbd_ring_pbase, + (u32)((u64)card->evtbd_ring_pbase >> 32), + card->evtbd_ring_size); for (i = 0; i < MWIFIEX_MAX_EVT_BD; i++) { card->evtbd_ring[i] = (struct mwifiex_pcie_buf_desc *) - (card->evtbd_ring_vbase + - (sizeof(struct mwifiex_pcie_buf_desc) * i)); + (card->evtbd_ring_vbase + + (sizeof(struct mwifiex_pcie_buf_desc) + * i)); /* Allocate skb here so that firmware can DMA data from it */ skb = dev_alloc_skb(MAX_EVENT_SIZE); if (!skb) { - dev_err(adapter->dev, "Unable to allocate skb for EVENT buf.\n"); + dev_err(adapter->dev, + "Unable to allocate skb for EVENT buf.\n"); kfree(card->evtbd_ring_vbase); return -ENOMEM; } @@ -595,10 +597,9 @@ static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) skb_put(skb, MAX_EVENT_SIZE); dev_dbg(adapter->dev, "info: Evt ring: add new skb. base: %p, " - "buf_base: %p, buf_pbase: %#x:%x, " - "buf_len: %#x\n", skb, skb->data, - (u32)*buf_pa, (u32)((u64)*buf_pa >> 32), - skb->len); + "buf_base: %p, buf_pbase: %#x:%x, buf_len: %#x\n", + skb, skb->data, (u32)*buf_pa, (u32)((u64)*buf_pa >> 32), + skb->len); card->evt_buf_list[i] = skb; card->evtbd_ring[i]->paddr = *buf_pa; @@ -647,8 +648,8 @@ static int mwifiex_pcie_alloc_cmdrsp_buf(struct mwifiex_adapter *adapter) /* Allocate memory for receiving command response data */ skb = dev_alloc_skb(MWIFIEX_UPLD_SIZE); if (!skb) { - dev_err(adapter->dev, "Unable to allocate skb for command " - "response data.\n"); + dev_err(adapter->dev, + "Unable to allocate skb for command response data.\n"); return -ENOMEM; } mwifiex_update_sk_buff_pa(skb); @@ -659,8 +660,8 @@ static int mwifiex_pcie_alloc_cmdrsp_buf(struct mwifiex_adapter *adapter) /* Allocate memory for sending command to firmware */ skb = dev_alloc_skb(MWIFIEX_SIZE_OF_CMD_BUFFER); if (!skb) { - dev_err(adapter->dev, "Unable to allocate skb for command " - "data.\n"); + dev_err(adapter->dev, + "Unable to allocate skb for command data.\n"); return -ENOMEM; } mwifiex_update_sk_buff_pa(skb); @@ -702,8 +703,8 @@ static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter) /* Allocate memory for sleep cookie */ skb = dev_alloc_skb(sizeof(u32)); if (!skb) { - dev_err(adapter->dev, "Unable to allocate skb for sleep " - "cookie!\n"); + dev_err(adapter->dev, + "Unable to allocate skb for sleep cookie!\n"); return -ENOMEM; } mwifiex_update_sk_buff_pa(skb); @@ -713,7 +714,7 @@ static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter) *(u32 *)skb->data = FW_AWAKE_COOKIE; dev_dbg(adapter->dev, "alloc_scook: sleep cookie=0x%x\n", - *((u32 *)skb->data)); + *((u32 *)skb->data)); /* Save the sleep cookie */ card->sleep_cookie = skb; @@ -757,15 +758,15 @@ mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb) /* Read the TX ring read pointer set by firmware */ if (mwifiex_read_reg(adapter, REG_TXBD_RDPTR, &rdptr)) { - dev_err(adapter->dev, "SEND DATA: failed to read " - "REG_TXBD_RDPTR\n"); + dev_err(adapter->dev, + "SEND DATA: failed to read REG_TXBD_RDPTR\n"); return -1; } wrindx = card->txbd_wrptr & MWIFIEX_TXBD_MASK; dev_dbg(adapter->dev, "info: SEND DATA: \n", rdptr, - card->txbd_wrptr); + card->txbd_wrptr); if (((card->txbd_wrptr & MWIFIEX_TXBD_MASK) != (rdptr & MWIFIEX_TXBD_MASK)) || ((card->txbd_wrptr & MWIFIEX_BD_FLAG_ROLLOVER_IND) != @@ -797,32 +798,31 @@ mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb) /* Write the TX ring write pointer in to REG_TXBD_WRPTR */ if (mwifiex_write_reg(adapter, REG_TXBD_WRPTR, - card->txbd_wrptr)) { - dev_err(adapter->dev, "SEND DATA: failed to write " - "REG_TXBD_WRPTR\n"); + card->txbd_wrptr)) { + dev_err(adapter->dev, + "SEND DATA: failed to write REG_TXBD_WRPTR\n"); return 0; } /* Send the TX ready interrupt */ if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, CPU_INTR_DNLD_RDY)) { - dev_err(adapter->dev, "SEND DATA: failed to assert " - "door-bell interrupt.\n"); + dev_err(adapter->dev, + "SEND DATA: failed to assert door-bell intr\n"); return -1; } dev_dbg(adapter->dev, "info: SEND DATA: Updated and sent packet to firmware " - "successfully\n", rdptr, - card->txbd_wrptr); + "%#x> and sent packet to firmware successfully\n", + rdptr, card->txbd_wrptr); } else { - dev_dbg(adapter->dev, "info: TX Ring full, can't send anymore " - "packets to firmware\n"); + dev_dbg(adapter->dev, + "info: TX Ring full, can't send packets to fw\n"); adapter->data_sent = true; /* Send the TX ready interrupt */ if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, CPU_INTR_DNLD_RDY)) - dev_err(adapter->dev, "SEND DATA: failed to assert " - "door-bell interrupt\n"); + dev_err(adapter->dev, + "SEND DATA: failed to assert door-bell intr\n"); return -EBUSY; } @@ -842,8 +842,8 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) /* Read the RX ring Write pointer set by firmware */ if (mwifiex_read_reg(adapter, REG_RXBD_WRPTR, &wrptr)) { - dev_err(adapter->dev, "RECV DATA: failed to read " - "REG_TXBD_RDPTR\n"); + dev_err(adapter->dev, + "RECV DATA: failed to read REG_TXBD_RDPTR\n"); ret = -1; goto done; } @@ -861,12 +861,13 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) /* Get data length from interface header - first byte is len, second byte is type */ rx_len = *((u16 *)skb_data->data); - dev_dbg(adapter->dev, "info: RECV DATA: Rd=%#x, Wr=%#x, " - "Len=%d\n", card->rxbd_rdptr, wrptr, rx_len); + dev_dbg(adapter->dev, + "info: RECV DATA: Rd=%#x, Wr=%#x, Len=%d\n", + card->rxbd_rdptr, wrptr, rx_len); skb_tmp = dev_alloc_skb(rx_len); if (!skb_tmp) { - dev_dbg(adapter->dev, "info: Failed to alloc skb " - "for RX\n"); + dev_dbg(adapter->dev, + "info: Failed to alloc skb for RX\n"); ret = -EBUSY; goto done; } @@ -881,26 +882,26 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) MWIFIEX_BD_FLAG_ROLLOVER_IND); } dev_dbg(adapter->dev, "info: RECV DATA: \n", - card->rxbd_rdptr, wrptr); + card->rxbd_rdptr, wrptr); /* Write the RX ring read pointer in to REG_RXBD_RDPTR */ if (mwifiex_write_reg(adapter, REG_RXBD_RDPTR, card->rxbd_rdptr)) { - dev_err(adapter->dev, "RECV DATA: failed to " - "write REG_RXBD_RDPTR\n"); + dev_err(adapter->dev, + "RECV DATA: failed to write REG_RXBD_RDPTR\n"); ret = -1; goto done; } /* Read the RX ring Write pointer set by firmware */ if (mwifiex_read_reg(adapter, REG_RXBD_WRPTR, &wrptr)) { - dev_err(adapter->dev, "RECV DATA: failed to read " - "REG_TXBD_RDPTR\n"); + dev_err(adapter->dev, + "RECV DATA: failed to read REG_TXBD_RDPTR\n"); ret = -1; goto done; } - dev_dbg(adapter->dev, "info: RECV DATA: Received packet from " - "firmware successfully\n"); + dev_dbg(adapter->dev, + "info: RECV DATA: Rcvd packet from fw successfully\n"); mwifiex_handle_rx_packet(adapter, skb_tmp); } @@ -919,17 +920,19 @@ mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) phys_addr_t *buf_pa = MWIFIEX_SKB_PACB(skb); if (!(skb->data && skb->len && *buf_pa)) { - dev_err(adapter->dev, "Invalid parameter in %s <%p, %#x:%x, " - "%x>\n", __func__, skb->data, skb->len, - (u32)*buf_pa, (u32)((u64)*buf_pa >> 32)); + dev_err(adapter->dev, + "Invalid parameter in %s <%p, %#x:%x, %x>\n", + __func__, skb->data, skb->len, + (u32)*buf_pa, (u32)((u64)*buf_pa >> 32)); return -1; } /* Write the lower 32bits of the physical address to scratch * register 0 */ if (mwifiex_write_reg(adapter, PCIE_SCRATCH_0_REG, (u32)*buf_pa)) { - dev_err(adapter->dev, "%s: failed to write download command " - "to boot code.\n", __func__); + dev_err(adapter->dev, + "%s: failed to write download command to boot code.\n", + __func__); return -1; } @@ -937,23 +940,25 @@ mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) * register 1 */ if (mwifiex_write_reg(adapter, PCIE_SCRATCH_1_REG, (u32)((u64)*buf_pa >> 32))) { - dev_err(adapter->dev, "%s: failed to write download command " - "to boot code.\n", __func__); + dev_err(adapter->dev, + "%s: failed to write download command to boot code.\n", + __func__); return -1; } /* Write the command length to scratch register 2 */ if (mwifiex_write_reg(adapter, PCIE_SCRATCH_2_REG, skb->len)) { - dev_err(adapter->dev, "%s: failed to write command length to " - "scratch register 2\n", __func__); + dev_err(adapter->dev, + "%s: failed to write command len to scratch reg 2\n", + __func__); return -1; } /* Ring the door bell */ if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, CPU_INTR_DOOR_BELL)) { - dev_err(adapter->dev, "%s: failed to assert door-bell " - "interrupt.\n", __func__); + dev_err(adapter->dev, + "%s: failed to assert door-bell intr\n", __func__); return -1; } @@ -973,14 +978,14 @@ mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) if (!(skb->data && skb->len)) { dev_err(adapter->dev, "Invalid parameter in %s <%p, %#x>\n", - __func__, skb->data, skb->len); + __func__, skb->data, skb->len); return -1; } /* Make sure a command response buffer is available */ if (!card->cmdrsp_buf) { - dev_err(adapter->dev, "No response buffer available, send " - "command failed\n"); + dev_err(adapter->dev, + "No response buffer available, send command failed\n"); return -EBUSY; } @@ -1011,17 +1016,18 @@ mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) /* Write the lower 32bits of the cmdrsp buffer physical address */ if (mwifiex_write_reg(adapter, REG_CMDRSP_ADDR_LO, - (u32)*cmdrsp_buf_pa)) { - dev_err(adapter->dev, "Failed to write download command to boot code.\n"); + (u32)*cmdrsp_buf_pa)) { + dev_err(adapter->dev, + "Failed to write download cmd to boot code.\n"); ret = -1; goto done; } /* Write the upper 32bits of the cmdrsp buffer physical address */ if (mwifiex_write_reg(adapter, REG_CMDRSP_ADDR_HI, - (u32)((u64)*cmdrsp_buf_pa >> 32))) { - dev_err(adapter->dev, "Failed to write download command" - " to boot code.\n"); + (u32)((u64)*cmdrsp_buf_pa >> 32))) { + dev_err(adapter->dev, + "Failed to write download cmd to boot code.\n"); ret = -1; goto done; } @@ -1029,27 +1035,25 @@ mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) cmd_buf_pa = MWIFIEX_SKB_PACB(card->cmd_buf); /* Write the lower 32bits of the physical address to REG_CMD_ADDR_LO */ - if (mwifiex_write_reg(adapter, REG_CMD_ADDR_LO, - (u32)*cmd_buf_pa)) { - dev_err(adapter->dev, "Failed to write download command " - "to boot code.\n"); + if (mwifiex_write_reg(adapter, REG_CMD_ADDR_LO, (u32)*cmd_buf_pa)) { + dev_err(adapter->dev, + "Failed to write download cmd to boot code.\n"); ret = -1; goto done; } /* Write the upper 32bits of the physical address to REG_CMD_ADDR_HI */ if (mwifiex_write_reg(adapter, REG_CMD_ADDR_HI, - (u32)((u64)*cmd_buf_pa >> 32))) { - dev_err(adapter->dev, "Failed to write download command " - "to boot code.\n"); + (u32)((u64)*cmd_buf_pa >> 32))) { + dev_err(adapter->dev, + "Failed to write download cmd to boot code.\n"); ret = -1; goto done; } /* Write the command length to REG_CMD_SIZE */ - if (mwifiex_write_reg(adapter, REG_CMD_SIZE, - card->cmd_buf->len)) { - dev_err(adapter->dev, "Failed to write command length to " - "REG_CMD_SIZE\n"); + if (mwifiex_write_reg(adapter, REG_CMD_SIZE, card->cmd_buf->len)) { + dev_err(adapter->dev, + "Failed to write cmd len to REG_CMD_SIZE\n"); ret = -1; goto done; } @@ -1057,8 +1061,8 @@ mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) /* Ring the door bell */ if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, CPU_INTR_DOOR_BELL)) { - dev_err(adapter->dev, "Failed to assert door-bell " - "interrupt.\n"); + dev_err(adapter->dev, + "Failed to assert door-bell intr\n"); ret = -1; goto done; } @@ -1076,30 +1080,29 @@ mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) { struct pcie_service_card *card = adapter->card; + struct sk_buff *skb = card->cmdrsp_buf; int count = 0; dev_dbg(adapter->dev, "info: Rx CMD Response\n"); if (!adapter->curr_cmd) { - skb_pull(card->cmdrsp_buf, INTF_HEADER_LEN); + skb_pull(skb, INTF_HEADER_LEN); if (adapter->ps_state == PS_STATE_SLEEP_CFM) { - mwifiex_process_sleep_confirm_resp(adapter, - card->cmdrsp_buf->data, - card->cmdrsp_buf->len); + mwifiex_process_sleep_confirm_resp(adapter, skb->data, + skb->len); while (mwifiex_pcie_ok_to_access_hw(adapter) && (count++ < 10)) usleep_range(50, 60); } else { - dev_err(adapter->dev, "There is no command but " - "got cmdrsp\n"); + dev_err(adapter->dev, + "There is no command but got cmdrsp\n"); } - memcpy(adapter->upld_buf, card->cmdrsp_buf->data, - min_t(u32, MWIFIEX_SIZE_OF_CMD_BUFFER, - card->cmdrsp_buf->len)); - skb_push(card->cmdrsp_buf, INTF_HEADER_LEN); + memcpy(adapter->upld_buf, skb->data, + min_t(u32, MWIFIEX_SIZE_OF_CMD_BUFFER, skb->len)); + skb_push(skb, INTF_HEADER_LEN); } else if (mwifiex_pcie_ok_to_access_hw(adapter)) { - skb_pull(card->cmdrsp_buf, INTF_HEADER_LEN); - adapter->curr_cmd->resp_skb = card->cmdrsp_buf; + skb_pull(skb, INTF_HEADER_LEN); + adapter->curr_cmd->resp_skb = skb; adapter->cmd_resp_received = true; /* Take the pointer and set it to CMD node and will return in the response complete callback */ @@ -1109,15 +1112,15 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) will prevent firmware from writing to the same response buffer again. */ if (mwifiex_write_reg(adapter, REG_CMDRSP_ADDR_LO, 0)) { - dev_err(adapter->dev, "cmd_done: failed to clear " - "cmd_rsp address.\n"); + dev_err(adapter->dev, + "cmd_done: failed to clear cmd_rsp_addr_lo\n"); return -1; } /* Write the upper 32bits of the cmdrsp buffer physical address */ if (mwifiex_write_reg(adapter, REG_CMDRSP_ADDR_HI, 0)) { - dev_err(adapter->dev, "cmd_done: failed to clear " - "cmd_rsp address.\n"); + dev_err(adapter->dev, + "cmd_done: failed to clear cmd_rsp_addr_hi\n"); return -1; } } @@ -1151,8 +1154,8 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) u32 wrptr, event; if (adapter->event_received) { - dev_dbg(adapter->dev, "info: Event being processed, "\ - "do not process this interrupt just yet\n"); + dev_dbg(adapter->dev, "info: Event being processed, " + "do not process this interrupt just yet\n"); return 0; } @@ -1163,14 +1166,15 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) /* Read the event ring write pointer set by firmware */ if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { - dev_err(adapter->dev, "EventReady: failed to read REG_EVTBD_WRPTR\n"); + dev_err(adapter->dev, + "EventReady: failed to read REG_EVTBD_WRPTR\n"); return -1; } dev_dbg(adapter->dev, "info: EventReady: Initial ", - card->evtbd_rdptr, wrptr); - if (((wrptr & MWIFIEX_EVTBD_MASK) != - (card->evtbd_rdptr & MWIFIEX_EVTBD_MASK)) || + card->evtbd_rdptr, wrptr); + if (((wrptr & MWIFIEX_EVTBD_MASK) != (card->evtbd_rdptr + & MWIFIEX_EVTBD_MASK)) || ((wrptr & MWIFIEX_BD_FLAG_ROLLOVER_IND) == (card->evtbd_rdptr & MWIFIEX_BD_FLAG_ROLLOVER_IND))) { struct sk_buff *skb_cmd; @@ -1230,13 +1234,14 @@ 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); + rdptr); 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"); + dev_err(adapter->dev, + "event_complete: failed to read REG_EVTBD_WRPTR\n"); return -1; } @@ -1249,9 +1254,9 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, card->evtbd_ring[rdptr]->flags = 0; skb = NULL; } else { - dev_dbg(adapter->dev, "info: ERROR: Buffer is still valid at " - "index %d, <%p, %p>\n", rdptr, - card->evt_buf_list[rdptr], skb); + dev_dbg(adapter->dev, + "info: ERROR: buf still valid at index %d, <%p, %p>\n", + rdptr, card->evt_buf_list[rdptr], skb); } if ((++card->evtbd_rdptr & MWIFIEX_EVTBD_MASK) == MWIFIEX_MAX_EVT_BD) { @@ -1261,11 +1266,12 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, } dev_dbg(adapter->dev, "info: Updated ", - card->evtbd_rdptr, wrptr); + card->evtbd_rdptr, wrptr); /* 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"); + dev_err(adapter->dev, + "event_complete: failed to read REG_EVTBD_RDPTR\n"); return -1; } @@ -1299,17 +1305,17 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, } if (!firmware || !firmware_len) { - dev_err(adapter->dev, "No firmware image found! " - "Terminating download\n"); + dev_err(adapter->dev, + "No firmware image found! Terminating download\n"); return -1; } dev_dbg(adapter->dev, "info: Downloading FW image (%d bytes)\n", - firmware_len); + firmware_len); if (mwifiex_pcie_disable_host_int(adapter)) { - dev_err(adapter->dev, "%s: Disabling interrupts" - " failed.\n", __func__); + dev_err(adapter->dev, + "%s: Disabling interrupts failed.\n", __func__); return -1; } @@ -1332,7 +1338,8 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, ret = mwifiex_read_reg(adapter, PCIE_SCRATCH_2_REG, &len); if (ret) { - dev_warn(adapter->dev, "Failed reading length from boot code\n"); + dev_warn(adapter->dev, + "Failed reading len from boot code\n"); goto done; } if (len) @@ -1344,7 +1351,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, break; } else if (len > MWIFIEX_UPLD_SIZE) { pr_err("FW download failure @ %d, invalid length %d\n", - offset, len); + offset, len); ret = -1; goto done; } @@ -1360,8 +1367,8 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, goto done; } dev_err(adapter->dev, "FW CRC error indicated by the " - "helper: len = 0x%04X, txlen = " - "%d\n", len, txlen); + "helper: len = 0x%04X, txlen = %d\n", + len, txlen); len &= ~BIT(0); /* Setting this to 0 to resend from same offset */ txlen = 0; @@ -1374,9 +1381,9 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, dev_dbg(adapter->dev, "."); - tx_blocks = - (txlen + MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD - 1) / - MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD; + tx_blocks = (txlen + + MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD - 1) / + MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD; /* Copy payload to buffer */ memmove(skb->data, &firmware[offset], txlen); @@ -1387,7 +1394,8 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, /* Send the boot command to device */ if (mwifiex_pcie_send_boot_cmd(adapter, skb)) { - dev_err(adapter->dev, "Failed to send firmware download command\n"); + dev_err(adapter->dev, + "Failed to send firmware download command\n"); ret = -1; goto done; } @@ -1396,8 +1404,8 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, if (mwifiex_read_reg(adapter, PCIE_CPU_INT_STATUS, &ireg_intr)) { dev_err(adapter->dev, "%s: Failed to read " - "interrupt status during " - "fw dnld.\n", __func__); + "interrupt status during fw dnld.\n", + __func__); ret = -1; goto done; } @@ -1407,7 +1415,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, } while (true); dev_dbg(adapter->dev, "info:\nFW download over, size %d bytes\n", - offset); + offset); ret = 0; @@ -1430,14 +1438,15 @@ mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) /* Mask spurios interrupts */ if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS_MASK, - HOST_INTR_MASK)) { + HOST_INTR_MASK)) { dev_warn(adapter->dev, "Write register failed\n"); return -1; } dev_dbg(adapter->dev, "Setting driver ready signature\n"); if (mwifiex_write_reg(adapter, REG_DRV_READY, FIRMWARE_READY_PCIE)) { - dev_err(adapter->dev, "Failed to write driver ready signature\n"); + dev_err(adapter->dev, + "Failed to write driver ready signature\n"); return -1; } @@ -1468,8 +1477,9 @@ mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) adapter->winner = 1; ret = -1; } else { - dev_err(adapter->dev, "PCI-E is not the winner <%#x, %d>, exit download\n", - ret, adapter->winner); + dev_err(adapter->dev, + "PCI-E is not the winner <%#x,%d>, exit dnld\n", + ret, adapter->winner); ret = 0; } } @@ -1512,10 +1522,11 @@ static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter) (adapter->ps_state == PS_STATE_SLEEP)) { mwifiex_pcie_enable_host_int(adapter); if (mwifiex_write_reg(adapter, - PCIE_CPU_INT_EVENT, - CPU_INTR_SLEEP_CFM_DONE)) { - dev_warn(adapter->dev, "Write register" - " failed\n"); + PCIE_CPU_INT_EVENT, + CPU_INTR_SLEEP_CFM_DONE) + ) { + dev_warn(adapter->dev, + "Write register failed\n"); return; } @@ -1551,7 +1562,7 @@ static irqreturn_t mwifiex_pcie_interrupt(int irq, void *context) card = (struct pcie_service_card *) pci_get_drvdata(pdev); if (!card || !card->adapter) { pr_debug("info: %s: card=%p adapter=%p\n", __func__, card, - card ? card->adapter : NULL); + card ? card->adapter : NULL); goto exit; } adapter = card->adapter; @@ -1594,7 +1605,7 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) if (adapter->int_status & HOST_INTR_DNLD_DONE) { adapter->int_status &= ~HOST_INTR_DNLD_DONE; if (adapter->data_sent) { - dev_dbg(adapter->dev, "info: DATA sent Interrupt\n"); + dev_dbg(adapter->dev, "info: DATA sent intr\n"); adapter->data_sent = false; } } @@ -1616,7 +1627,8 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) if (adapter->int_status & HOST_INTR_CMD_DONE) { adapter->int_status &= ~HOST_INTR_CMD_DONE; if (adapter->cmd_sent) { - dev_dbg(adapter->dev, "info: CMD sent Interrupt\n"); + dev_dbg(adapter->dev, + "info: CMD sent Interrupt\n"); adapter->cmd_sent = false; } /* Handle command response */ @@ -1628,15 +1640,17 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) if (mwifiex_pcie_ok_to_access_hw(adapter)) { if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, &pcie_ireg)) { - dev_warn(adapter->dev, "Read register failed\n"); + dev_warn(adapter->dev, + "Read register failed\n"); return -1; } if ((pcie_ireg != 0xFFFFFFFF) && (pcie_ireg)) { if (mwifiex_write_reg(adapter, - PCIE_HOST_INT_STATUS, ~pcie_ireg)) { - dev_warn(adapter->dev, "Write register" - " failed\n"); + PCIE_HOST_INT_STATUS, + ~pcie_ireg)) { + dev_warn(adapter->dev, + "Write register failed\n"); return -1; } adapter->int_status |= pcie_ireg; @@ -1646,7 +1660,7 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) } } dev_dbg(adapter->dev, "info: cmd_sent=%d data_sent=%d\n", - adapter->cmd_sent, adapter->data_sent); + adapter->cmd_sent, adapter->data_sent); mwifiex_pcie_enable_host_int(adapter); return 0; @@ -1737,8 +1751,9 @@ static int mwifiex_pcie_init(struct mwifiex_adapter *adapter) goto err_iomap2; } - dev_dbg(adapter->dev, "PCI memory map Virt0: %p PCI memory map Virt2: " - "%p\n", card->pci_mmap, card->pci_mmap1); + dev_dbg(adapter->dev, + "PCI memory map Virt0: %p PCI memory map Virt2: %p\n", + card->pci_mmap, card->pci_mmap1); card->cmdrsp_buf = NULL; ret = mwifiex_pcie_create_txbd_ring(adapter); @@ -1808,7 +1823,8 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) dev_dbg(adapter->dev, "Clearing driver ready signature\n"); if (user_rmmod) { if (mwifiex_write_reg(adapter, REG_DRV_READY, 0x00000000)) - dev_err(adapter->dev, "Failed to write driver not-ready signature\n"); + dev_err(adapter->dev, + "Failed to write driver not-ready signature\n"); } if (pdev) { -- GitLab From cff23cec822cd6bd0878c2a6afe6140f04c17dcf Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:38 -0700 Subject: [PATCH 1737/1846] mwifiex: fix checkpatch --strict warnings/errors Part 5 For file scan.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/scan.c | 343 ++++++++++++++-------------- 1 file changed, 170 insertions(+), 173 deletions(-) diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 0a0c2890adfa..aff9cd763f2b 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -125,7 +125,7 @@ mwifiex_is_rsn_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) ieee_hdr.element_id == WLAN_EID_RSN))) { iebody = (struct ie_body *) (((u8 *) bss_desc->bcn_rsn_ie->data) + - RSN_GTK_OUI_OFFSET); + RSN_GTK_OUI_OFFSET); oui = &mwifiex_rsn_oui[cipher][0]; ret = mwifiex_search_oui_in_ie(iebody, oui); if (ret) @@ -148,8 +148,9 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) struct ie_body *iebody; u8 ret = MWIFIEX_OUI_NOT_PRESENT; - if (((bss_desc->bcn_wpa_ie) && ((*(bss_desc->bcn_wpa_ie)). - vend_hdr.element_id == WLAN_EID_WPA))) { + if (((bss_desc->bcn_wpa_ie) && + ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id == + WLAN_EID_WPA))) { iebody = (struct ie_body *) bss_desc->bcn_wpa_ie->data; oui = &mwifiex_wpa_oui[cipher][0]; ret = mwifiex_search_oui_in_ie(iebody, oui); @@ -175,8 +176,8 @@ mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2) * compatible with it. */ static bool -mwifiex_is_network_compatible_for_wapi(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_wapi(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { if (priv->sec_info.wapi_enabled && (bss_desc->bcn_wapi_ie && @@ -192,18 +193,17 @@ mwifiex_is_network_compatible_for_wapi(struct mwifiex_private *priv, * scanned network is compatible with it. */ static bool -mwifiex_is_network_compatible_for_no_sec(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_no_sec(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != - WLAN_EID_WPA)) - && ((!bss_desc->bcn_rsn_ie) || + WLAN_EID_WPA)) && + ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != - WLAN_EID_RSN)) - && !priv->sec_info.encryption_mode - && !bss_desc->privacy) { + WLAN_EID_RSN)) && + !priv->sec_info.encryption_mode && !bss_desc->privacy) { return true; } return false; @@ -214,8 +214,8 @@ mwifiex_is_network_compatible_for_no_sec(struct mwifiex_private *priv, * is compatible with it. */ static bool -mwifiex_is_network_compatible_for_static_wep(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_static_wep(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { if (priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled && bss_desc->privacy) { @@ -229,8 +229,8 @@ mwifiex_is_network_compatible_for_static_wep(struct mwifiex_private *priv, * compatible with it. */ static bool -mwifiex_is_network_compatible_for_wpa(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_wpa(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled && !priv->sec_info.wpa2_enabled && ((bss_desc->bcn_wpa_ie) && @@ -264,17 +264,18 @@ mwifiex_is_network_compatible_for_wpa(struct mwifiex_private *priv, * compatible with it. */ static bool -mwifiex_is_network_compatible_for_wpa2(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_wpa2(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { - if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && - priv->sec_info.wpa2_enabled && ((bss_desc->bcn_rsn_ie) && - ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id == WLAN_EID_RSN)) - /* - * Privacy bit may NOT be set in some APs like - * LinkSys WRT54G && bss_desc->privacy - */ - ) { + if (!priv->sec_info.wep_enabled && + !priv->sec_info.wpa_enabled && + priv->sec_info.wpa2_enabled && + ((bss_desc->bcn_rsn_ie) && + ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id == WLAN_EID_RSN))) { + /* + * Privacy bit may NOT be set in some APs like + * LinkSys WRT54G && bss_desc->privacy + */ dev_dbg(priv->adapter->dev, "info: %s: WPA2: " " wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s " "EncMode=%#x privacy=%#x\n", __func__, @@ -299,16 +300,16 @@ mwifiex_is_network_compatible_for_wpa2(struct mwifiex_private *priv, * compatible with it. */ static bool -mwifiex_is_network_compatible_for_adhoc_aes(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_adhoc_aes(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && - !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || - ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) - && ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr. - element_id != WLAN_EID_RSN)) - && !priv->sec_info.encryption_mode - && bss_desc->privacy) { + !priv->sec_info.wpa2_enabled && + ((!bss_desc->bcn_wpa_ie) || + ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) && + ((!bss_desc->bcn_rsn_ie) || + ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != WLAN_EID_RSN)) && + !priv->sec_info.encryption_mode && bss_desc->privacy) { return true; } return false; @@ -319,16 +320,16 @@ mwifiex_is_network_compatible_for_adhoc_aes(struct mwifiex_private *priv, * is compatible with it. */ static bool -mwifiex_is_network_compatible_for_dynamic_wep(struct mwifiex_private *priv, - struct mwifiex_bssdescriptor *bss_desc) +mwifiex_is_bss_dynamic_wep(struct mwifiex_private *priv, + struct mwifiex_bssdescriptor *bss_desc) { if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled && - !priv->sec_info.wpa2_enabled && ((!bss_desc->bcn_wpa_ie) || - ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) - && ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr. - element_id != WLAN_EID_RSN)) - && priv->sec_info.encryption_mode - && bss_desc->privacy) { + !priv->sec_info.wpa2_enabled && + ((!bss_desc->bcn_wpa_ie) || + ((*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id != WLAN_EID_WPA)) && + ((!bss_desc->bcn_rsn_ie) || + ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id != WLAN_EID_RSN)) && + priv->sec_info.encryption_mode && bss_desc->privacy) { dev_dbg(priv->adapter->dev, "info: %s: dynamic " "WEP: wpa_ie=%#x wpa2_ie=%#x " "EncMode=%#x privacy=%#x\n", @@ -373,8 +374,9 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, bss_desc->disable_11n = false; /* Don't check for compatibility if roaming */ - if (priv->media_connected && (priv->bss_mode == NL80211_IFTYPE_STATION) - && (bss_desc->bss_mode == NL80211_IFTYPE_STATION)) + if (priv->media_connected && + (priv->bss_mode == NL80211_IFTYPE_STATION) && + (bss_desc->bss_mode == NL80211_IFTYPE_STATION)) return 0; if (priv->wps.session_enable) { @@ -383,32 +385,30 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, return 0; } - if (mwifiex_is_network_compatible_for_wapi(priv, bss_desc)) { + if (mwifiex_is_bss_wapi(priv, bss_desc)) { dev_dbg(adapter->dev, "info: return success for WAPI AP\n"); return 0; } if (bss_desc->bss_mode == mode) { - if (mwifiex_is_network_compatible_for_no_sec(priv, bss_desc)) { + if (mwifiex_is_bss_no_sec(priv, bss_desc)) { /* No security */ return 0; - } else if (mwifiex_is_network_compatible_for_static_wep(priv, - bss_desc)) { + } else if (mwifiex_is_bss_static_wep(priv, bss_desc)) { /* Static WEP enabled */ dev_dbg(adapter->dev, "info: Disable 11n in WEP mode.\n"); bss_desc->disable_11n = true; return 0; - } else if (mwifiex_is_network_compatible_for_wpa(priv, - bss_desc)) { + } else if (mwifiex_is_bss_wpa(priv, bss_desc)) { /* WPA enabled */ - if (((priv->adapter->config_bands & BAND_GN - || priv->adapter->config_bands & BAND_AN) - && bss_desc->bcn_ht_cap) - && !mwifiex_is_wpa_oui_present(bss_desc, - CIPHER_SUITE_CCMP)) { - - if (mwifiex_is_wpa_oui_present(bss_desc, - CIPHER_SUITE_TKIP)) { + if (((priv->adapter->config_bands & BAND_GN || + priv->adapter->config_bands & BAND_AN) && + bss_desc->bcn_ht_cap) && + !mwifiex_is_wpa_oui_present(bss_desc, + CIPHER_SUITE_CCMP)) { + + if (mwifiex_is_wpa_oui_present + (bss_desc, CIPHER_SUITE_TKIP)) { dev_dbg(adapter->dev, "info: Disable 11n if AES " "is not supported by AP\n"); @@ -418,17 +418,16 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, } } return 0; - } else if (mwifiex_is_network_compatible_for_wpa2(priv, - bss_desc)) { + } else if (mwifiex_is_bss_wpa2(priv, bss_desc)) { /* WPA2 enabled */ - if (((priv->adapter->config_bands & BAND_GN - || priv->adapter->config_bands & BAND_AN) - && bss_desc->bcn_ht_cap) - && !mwifiex_is_rsn_oui_present(bss_desc, - CIPHER_SUITE_CCMP)) { - - if (mwifiex_is_rsn_oui_present(bss_desc, - CIPHER_SUITE_TKIP)) { + if (((priv->adapter->config_bands & BAND_GN || + priv->adapter->config_bands & BAND_AN) && + bss_desc->bcn_ht_cap) && + !mwifiex_is_rsn_oui_present(bss_desc, + CIPHER_SUITE_CCMP)) { + + if (mwifiex_is_rsn_oui_present + (bss_desc, CIPHER_SUITE_TKIP)) { dev_dbg(adapter->dev, "info: Disable 11n if AES " "is not supported by AP\n"); @@ -438,31 +437,26 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, } } return 0; - } else if (mwifiex_is_network_compatible_for_adhoc_aes(priv, - bss_desc)) { + } else if (mwifiex_is_bss_adhoc_aes(priv, bss_desc)) { /* Ad-hoc AES enabled */ return 0; - } else if (mwifiex_is_network_compatible_for_dynamic_wep(priv, - bss_desc)) { + } else if (mwifiex_is_bss_dynamic_wep(priv, bss_desc)) { /* Dynamic WEP enabled */ return 0; } /* Security doesn't match */ - dev_dbg(adapter->dev, "info: %s: failed: " - "wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s EncMode" - "=%#x privacy=%#x\n", - __func__, - (bss_desc->bcn_wpa_ie) ? - (*(bss_desc->bcn_wpa_ie)).vend_hdr. - element_id : 0, - (bss_desc->bcn_rsn_ie) ? - (*(bss_desc->bcn_rsn_ie)).ieee_hdr. - element_id : 0, - (priv->sec_info.wep_enabled) ? "e" : "d", - (priv->sec_info.wpa_enabled) ? "e" : "d", - (priv->sec_info.wpa2_enabled) ? "e" : "d", - priv->sec_info.encryption_mode, bss_desc->privacy); + dev_dbg(adapter->dev, + "info: %s: failed: wpa_ie=%#x wpa2_ie=%#x WEP=%s " + "WPA=%s WPA2=%s EncMode=%#x privacy=%#x\n", __func__, + (bss_desc->bcn_wpa_ie) ? + (*(bss_desc->bcn_wpa_ie)).vend_hdr.element_id : 0, + (bss_desc->bcn_rsn_ie) ? + (*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id : 0, + (priv->sec_info.wep_enabled) ? "e" : "d", + (priv->sec_info.wpa_enabled) ? "e" : "d", + (priv->sec_info.wpa2_enabled) ? "e" : "d", + priv->sec_info.encryption_mode, bss_desc->privacy); return -1; } @@ -479,11 +473,11 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv, */ static void mwifiex_scan_create_channel_list(struct mwifiex_private *priv, - const struct mwifiex_user_scan_cfg - *user_scan_in, - struct mwifiex_chan_scan_param_set - *scan_chan_list, - u8 filtered_scan) + const struct mwifiex_user_scan_cfg + *user_scan_in, + struct mwifiex_chan_scan_param_set + *scan_chan_list, + u8 filtered_scan) { enum ieee80211_band band; struct ieee80211_supported_band *sband; @@ -505,7 +499,7 @@ mwifiex_scan_create_channel_list(struct mwifiex_private *priv, scan_chan_list[chan_idx].radio_type = band; if (user_scan_in && - user_scan_in->chan_list[0].scan_time) + user_scan_in->chan_list[0].scan_time) scan_chan_list[chan_idx].max_scan_time = cpu_to_le16((u16) user_scan_in-> chan_list[0].scan_time); @@ -594,19 +588,19 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, * - done_early is set (controlling individual scanning of * 1,6,11) */ - while (tlv_idx < max_chan_per_scan - && tmp_chan_list->chan_number && !done_early) { + while (tlv_idx < max_chan_per_scan && + tmp_chan_list->chan_number && !done_early) { dev_dbg(priv->adapter->dev, "info: Scan: Chan(%3d), Radio(%d)," " Mode(%d, %d), Dur(%d)\n", - tmp_chan_list->chan_number, - tmp_chan_list->radio_type, - tmp_chan_list->chan_scan_mode_bitmap - & MWIFIEX_PASSIVE_SCAN, - (tmp_chan_list->chan_scan_mode_bitmap - & MWIFIEX_DISABLE_CHAN_FILT) >> 1, - le16_to_cpu(tmp_chan_list->max_scan_time)); + tmp_chan_list->chan_number, + tmp_chan_list->radio_type, + tmp_chan_list->chan_scan_mode_bitmap + & MWIFIEX_PASSIVE_SCAN, + (tmp_chan_list->chan_scan_mode_bitmap + & MWIFIEX_DISABLE_CHAN_FILT) >> 1, + le16_to_cpu(tmp_chan_list->max_scan_time)); /* Copy the current channel TLV to the command being prepared */ @@ -648,9 +642,10 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, /* Stop the loop if the *current* channel is in the 1,6,11 set and we are not filtering on a BSSID or SSID. */ - if (!filtered_scan && (tmp_chan_list->chan_number == 1 - || tmp_chan_list->chan_number == 6 - || tmp_chan_list->chan_number == 11)) + if (!filtered_scan && + (tmp_chan_list->chan_number == 1 || + tmp_chan_list->chan_number == 6 || + tmp_chan_list->chan_number == 11)) done_early = true; /* Increment the tmp pointer to the next channel to @@ -660,9 +655,10 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, /* Stop the loop if the *next* channel is in the 1,6,11 set. This will cause it to be the only channel scanned on the next interation */ - if (!filtered_scan && (tmp_chan_list->chan_number == 1 - || tmp_chan_list->chan_number == 6 - || tmp_chan_list->chan_number == 11)) + if (!filtered_scan && + (tmp_chan_list->chan_number == 1 || + tmp_chan_list->chan_number == 6 || + tmp_chan_list->chan_number == 11)) done_early = true; } @@ -714,15 +710,13 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, * If the number of probes is not set, adapter default setting is used. */ static void -mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, - const struct mwifiex_user_scan_cfg *user_scan_in, - struct mwifiex_scan_cmd_config *scan_cfg_out, - struct mwifiex_ie_types_chan_list_param_set - **chan_list_out, - struct mwifiex_chan_scan_param_set - *scan_chan_list, - u8 *max_chan_per_scan, u8 *filtered_scan, - u8 *scan_current_only) +mwifiex_config_scan(struct mwifiex_private *priv, + const struct mwifiex_user_scan_cfg *user_scan_in, + struct mwifiex_scan_cmd_config *scan_cfg_out, + struct mwifiex_ie_types_chan_list_param_set **chan_list_out, + struct mwifiex_chan_scan_param_set *scan_chan_list, + u8 *max_chan_per_scan, u8 *filtered_scan, + u8 *scan_current_only) { struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_ie_types_num_probes *num_probes_tlv; @@ -840,9 +834,9 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, * truncate scan results. That is not an issue with an SSID * or BSSID filter applied to the scan results in the firmware. */ - if ((i && ssid_filter) - || memcmp(scan_cfg_out->specific_bssid, &zero_mac, - sizeof(zero_mac))) + if ((i && ssid_filter) || + memcmp(scan_cfg_out->specific_bssid, &zero_mac, + sizeof(zero_mac))) *filtered_scan = true; } else { scan_cfg_out->bss_mode = (u8) adapter->scan_mode; @@ -863,7 +857,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, if (num_probes) { dev_dbg(adapter->dev, "info: scan: num_probes = %d\n", - num_probes); + num_probes); num_probes_tlv = (struct mwifiex_ie_types_num_probes *) tlv_pos; num_probes_tlv->header.type = cpu_to_le16(TLV_TYPE_NUMPROBES); @@ -889,9 +883,9 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, dev_dbg(adapter->dev, "info: SCAN_CMD: Rates size = %d\n", rates_size); - if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) - && (priv->adapter->config_bands & BAND_GN - || priv->adapter->config_bands & BAND_AN)) { + if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && + (priv->adapter->config_bands & BAND_GN || + priv->adapter->config_bands & BAND_AN)) { ht_cap = (struct mwifiex_ie_types_htcap *) tlv_pos; memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); @@ -920,8 +914,8 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, dev_dbg(adapter->dev, "info: Scan: Using supplied channel list\n"); for (chan_idx = 0; - chan_idx < MWIFIEX_USER_SCAN_CHAN_MAX - && user_scan_in->chan_list[chan_idx].chan_number; + chan_idx < MWIFIEX_USER_SCAN_CHAN_MAX && + user_scan_in->chan_list[chan_idx].chan_number; chan_idx++) { channel = user_scan_in->chan_list[chan_idx].chan_number; @@ -961,9 +955,9 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, } /* Check if we are only scanning the current channel */ - if ((chan_idx == 1) - && (user_scan_in->chan_list[0].chan_number - == priv->curr_bss_params.bss_descriptor.channel)) { + if ((chan_idx == 1) && + (user_scan_in->chan_list[0].chan_number == + priv->curr_bss_params.bss_descriptor.channel)) { *scan_current_only = true; dev_dbg(adapter->dev, "info: Scan: Scanning current channel only\n"); @@ -971,7 +965,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, } else { dev_dbg(adapter->dev, - "info: Scan: Creating full region channel list\n"); + "info: Scan: Creating full region channel list\n"); mwifiex_scan_create_channel_list(priv, user_scan_in, scan_chan_list, *filtered_scan); @@ -1003,7 +997,7 @@ mwifiex_ret_802_11_scan_get_tlv_ptrs(struct mwifiex_adapter *adapter, *tlv_data = NULL; dev_dbg(adapter->dev, "info: SCAN_RESP: tlv_buf_size = %d\n", - tlv_buf_size); + tlv_buf_size); while (tlv_buf_left >= sizeof(struct mwifiex_ie_types_header)) { @@ -1100,8 +1094,9 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, bss_entry->ssid.ssid_len = element_len; memcpy(bss_entry->ssid.ssid, (current_ptr + 2), element_len); - dev_dbg(adapter->dev, "info: InterpretIE: ssid: " - "%-32s\n", bss_entry->ssid.ssid); + dev_dbg(adapter->dev, + "info: InterpretIE: ssid: %-32s\n", + bss_entry->ssid.ssid); break; case WLAN_EID_SUPP_RATES: @@ -1189,13 +1184,13 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, bss_entry->bcn_wpa_ie = (struct ieee_types_vendor_specific *) current_ptr; - bss_entry->wpa_offset = (u16) (current_ptr - - bss_entry->beacon_buf); + bss_entry->wpa_offset = (u16) + (current_ptr - bss_entry->beacon_buf); } else if (!memcmp(vendor_ie->vend_hdr.oui, wmm_oui, sizeof(wmm_oui))) { if (total_ie_len == - sizeof(struct ieee_types_wmm_parameter) - || total_ie_len == + sizeof(struct ieee_types_wmm_parameter) || + total_ie_len == sizeof(struct ieee_types_wmm_info)) /* * Only accept and copy the WMM IE if @@ -1316,14 +1311,14 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv, } scan_cfg_out = kzalloc(sizeof(union mwifiex_scan_cmd_config_tlv), - GFP_KERNEL); + GFP_KERNEL); if (!scan_cfg_out) { dev_err(adapter->dev, "failed to alloc scan_cfg_out\n"); return -ENOMEM; } buf_size = sizeof(struct mwifiex_chan_scan_param_set) * - MWIFIEX_USER_SCAN_CHAN_MAX; + MWIFIEX_USER_SCAN_CHAN_MAX; scan_chan_list = kzalloc(buf_size, GFP_KERNEL); if (!scan_chan_list) { dev_err(adapter->dev, "failed to alloc scan_chan_list\n"); @@ -1331,10 +1326,9 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv, return -ENOMEM; } - mwifiex_scan_setup_scan_config(priv, user_scan_in, - &scan_cfg_out->config, &chan_list_out, - scan_chan_list, &max_chan_per_scan, - &filtered_scan, &scan_current_chan_only); + mwifiex_config_scan(priv, user_scan_in, &scan_cfg_out->config, + &chan_list_out, scan_chan_list, &max_chan_per_scan, + &filtered_scan, &scan_current_chan_only); ret = mwifiex_scan_channel_list(priv, max_chan_per_scan, filtered_scan, &scan_cfg_out->config, chan_list_out, @@ -1345,10 +1339,10 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv, spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); if (!list_empty(&adapter->scan_pending_q)) { cmd_node = list_first_entry(&adapter->scan_pending_q, - struct cmd_ctrl_node, list); + struct cmd_ctrl_node, list); list_del(&cmd_node->list); spin_unlock_irqrestore(&adapter->scan_pending_q_lock, - flags); + flags); adapter->cmd_queued = cmd_node; mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, true); @@ -1514,7 +1508,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, /* Make a copy of current BSSID descriptor */ memcpy(&priv->curr_bss_params.bss_descriptor, bss_desc, - sizeof(priv->curr_bss_params.bss_descriptor)); + sizeof(priv->curr_bss_params.bss_descriptor)); mwifiex_save_curr_bcn(priv); spin_unlock_irqrestore(&priv->curr_bcn_buf_lock, flags); @@ -1565,7 +1559,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, struct cfg80211_bss *bss; is_bgscan_resp = (le16_to_cpu(resp->command) - == HostCmd_CMD_802_11_BG_SCAN_QUERY); + == HostCmd_CMD_802_11_BG_SCAN_QUERY); if (is_bgscan_resp) scan_rsp = &resp->params.bg_scan_query_resp.scan_resp; else @@ -1574,20 +1568,20 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, if (scan_rsp->number_of_sets > MWIFIEX_MAX_AP) { dev_err(adapter->dev, "SCAN_RESP: too many AP returned (%d)\n", - scan_rsp->number_of_sets); + scan_rsp->number_of_sets); ret = -1; goto done; } bytes_left = le16_to_cpu(scan_rsp->bss_descript_size); dev_dbg(adapter->dev, "info: SCAN_RESP: bss_descript_size %d\n", - bytes_left); + bytes_left); scan_resp_size = le16_to_cpu(resp->size); dev_dbg(adapter->dev, "info: SCAN_RESP: returned %d APs before parsing\n", - scan_rsp->number_of_sets); + scan_rsp->number_of_sets); bss_info = scan_rsp->bss_desc_and_tlv_buffer; @@ -1663,7 +1657,8 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, * and capability information */ if (curr_bcn_bytes < sizeof(struct mwifiex_bcn_param)) { - dev_err(adapter->dev, "InterpretIE: not enough bytes left\n"); + dev_err(adapter->dev, + "InterpretIE: not enough bytes left\n"); continue; } bcn_param = (struct mwifiex_bcn_param *)current_ptr; @@ -1673,20 +1668,20 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, memcpy(bssid, bcn_param->bssid, ETH_ALEN); rssi = (s32) (bcn_param->rssi); - dev_dbg(adapter->dev, "info: InterpretIE: RSSI=%02X\n", - rssi); + dev_dbg(adapter->dev, "info: InterpretIE: RSSI=%02X\n", rssi); beacon_period = le16_to_cpu(bcn_param->beacon_period); cap_info_bitmap = le16_to_cpu(bcn_param->cap_info_bitmap); dev_dbg(adapter->dev, "info: InterpretIE: capabilities=0x%X\n", - cap_info_bitmap); + cap_info_bitmap); /* Rest of the current buffer are IE's */ ie_buf = current_ptr; ie_len = curr_bcn_bytes; - dev_dbg(adapter->dev, "info: InterpretIE: IELength for this AP" - " = %d\n", curr_bcn_bytes); + dev_dbg(adapter->dev, + "info: InterpretIE: IELength for this AP = %d\n", + curr_bcn_bytes); while (curr_bcn_bytes >= sizeof(struct ieee_types_header)) { u8 element_id, element_len; @@ -1695,8 +1690,8 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, element_len = *(current_ptr + 1); if (curr_bcn_bytes < element_len + sizeof(struct ieee_types_header)) { - dev_err(priv->adapter->dev, "%s: in processing" - " IE, bytes left < IE length\n", + dev_err(priv->adapter->dev, + "%s: bytes left < IE length\n", __func__); goto done; } @@ -1720,8 +1715,8 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, */ if (tsf_tlv) memcpy(&network_tsf, - &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE], - sizeof(network_tsf)); + &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE], + sizeof(network_tsf)); if (channel) { struct ieee80211_channel *chan; @@ -1750,13 +1745,15 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, *(u8 *)bss->priv = band; cfg80211_put_bss(bss); - if (priv->media_connected && !memcmp(bssid, - priv->curr_bss_params.bss_descriptor - .mac_address, ETH_ALEN)) - mwifiex_update_curr_bss_params(priv, - bssid, rssi, ie_buf, - ie_len, beacon_period, - cap_info_bitmap, band); + if (priv->media_connected && + !memcmp(bssid, + priv->curr_bss_params.bss_descriptor + .mac_address, ETH_ALEN)) + mwifiex_update_curr_bss_params + (priv, bssid, rssi, + ie_buf, ie_len, + beacon_period, + cap_info_bitmap, band); } } else { dev_dbg(adapter->dev, "missing BSS channel IE\n"); @@ -1783,8 +1780,8 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, } if (priv->user_scan_cfg) { - dev_dbg(priv->adapter->dev, "info: %s: sending scan " - "results\n", __func__); + 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); @@ -1900,7 +1897,7 @@ int mwifiex_request_scan(struct mwifiex_private *priv, if (down_interruptible(&priv->async_sem)) { dev_err(priv->adapter->dev, "%s: acquire semaphore\n", - __func__); + __func__); return -1; } priv->scan_pending_on_block = true; @@ -1985,21 +1982,21 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv) /* allocate beacon buffer at 1st time; or if it's size has changed */ if (!priv->curr_bcn_buf || - priv->curr_bcn_size != curr_bss->beacon_buf_size) { + priv->curr_bcn_size != curr_bss->beacon_buf_size) { priv->curr_bcn_size = curr_bss->beacon_buf_size; kfree(priv->curr_bcn_buf); priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size, - GFP_ATOMIC); + GFP_ATOMIC); if (!priv->curr_bcn_buf) { dev_err(priv->adapter->dev, - "failed to alloc curr_bcn_buf\n"); + "failed to alloc curr_bcn_buf\n"); return; } } memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf, - curr_bss->beacon_buf_size); + curr_bss->beacon_buf_size); dev_dbg(priv->adapter->dev, "info: current beacon saved %d\n", priv->curr_bcn_size); -- GitLab From 5dbd326ca7acc54320c38bdc474600c811f8ad6b Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:39 -0700 Subject: [PATCH 1738/1846] mwifiex: fix checkpatch --strict warnings/errors Part 6 For file sdio.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sdio.c | 188 ++++++++++++++-------------- 1 file changed, 96 insertions(+), 92 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index fe6fbc123b2e..3f597f4a3f5e 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -67,7 +67,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) struct sdio_mmc_card *card = NULL; pr_debug("info: vendor=0x%4.04X device=0x%4.04X class=%d function=%d\n", - func->vendor, func->device, func->class, func->num); + func->vendor, func->device, func->class, func->num); card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL); if (!card) { @@ -112,6 +112,7 @@ mwifiex_sdio_remove(struct sdio_func *func) { struct sdio_mmc_card *card; struct mwifiex_adapter *adapter; + struct mwifiex_private *priv; int i; pr_debug("info: SDIO func num=%d\n", func->num); @@ -131,15 +132,12 @@ mwifiex_sdio_remove(struct sdio_func *func) for (i = 0; i < adapter->priv_num; i++) if ((GET_BSS_ROLE(adapter->priv[i]) == MWIFIEX_BSS_ROLE_STA) && - adapter->priv[i]->media_connected) + adapter->priv[i]->media_connected) mwifiex_deauthenticate(adapter->priv[i], NULL); - mwifiex_disable_auto_ds(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY)); - - mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY), - MWIFIEX_FUNC_SHUTDOWN); + priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); + mwifiex_disable_auto_ds(priv); + mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN); } mwifiex_remove_card(card->adapter, &add_remove_card_sem); @@ -169,7 +167,7 @@ static int mwifiex_sdio_suspend(struct device *dev) if (func) { pm_flag = sdio_get_host_pm_caps(func); pr_debug("cmd: %s: suspend: PM flag = 0x%x\n", - sdio_func_id(func), pm_flag); + sdio_func_id(func), pm_flag); if (!(pm_flag & MMC_PM_KEEP_POWER)) { pr_err("%s: cannot remain alive while host is" " suspended\n", sdio_func_id(func)); @@ -363,12 +361,11 @@ static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *buffer, { struct sdio_mmc_card *card = adapter->card; int ret = -1; - u8 blk_mode = - (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE; + u8 blk_mode = (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE + : BLOCK_MODE; u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1; - u32 blk_cnt = - (blk_mode == - BLOCK_MODE) ? (len / MWIFIEX_SDIO_BLOCK_SIZE) : len; + u32 blk_cnt = (blk_mode == BLOCK_MODE) ? (len / MWIFIEX_SDIO_BLOCK_SIZE) + : len; u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK); if (claim) @@ -472,8 +469,7 @@ static int mwifiex_write_data_to_card(struct mwifiex_adapter *adapter, i++; dev_err(adapter->dev, "host_to_card, write iomem" " (%d) failed: %d\n", i, ret); - if (mwifiex_write_reg(adapter, - CONFIGURATION_REG, 0x04)) + if (mwifiex_write_reg(adapter, CONFIGURATION_REG, 0x04)) dev_err(adapter->dev, "write CFG reg failed\n"); ret = -1; @@ -507,11 +503,11 @@ static int mwifiex_get_rd_port(struct mwifiex_adapter *adapter, u8 *port) card->mp_rd_bitmap &= (u16) (~CTRL_PORT_MASK); *port = CTRL_PORT; dev_dbg(adapter->dev, "data: port=%d mp_rd_bitmap=0x%04x\n", - *port, card->mp_rd_bitmap); + *port, card->mp_rd_bitmap); } else { if (card->mp_rd_bitmap & (1 << card->curr_rd_port)) { - card->mp_rd_bitmap &= - (u16) (~(1 << card->curr_rd_port)); + card->mp_rd_bitmap &= (u16) + (~(1 << card->curr_rd_port)); *port = card->curr_rd_port; if (++card->curr_rd_port == MAX_PORT) @@ -522,7 +518,7 @@ static int mwifiex_get_rd_port(struct mwifiex_adapter *adapter, u8 *port) dev_dbg(adapter->dev, "data: port=%d mp_rd_bitmap=0x%04x -> 0x%04x\n", - *port, rd_bitmap, card->mp_rd_bitmap); + *port, rd_bitmap, card->mp_rd_bitmap); } return 0; } @@ -556,14 +552,14 @@ static int mwifiex_get_wr_port_data(struct mwifiex_adapter *adapter, u8 *port) if (*port == CTRL_PORT) { dev_err(adapter->dev, "invalid data port=%d cur port=%d" - " mp_wr_bitmap=0x%04x -> 0x%04x\n", - *port, card->curr_wr_port, wr_bitmap, - card->mp_wr_bitmap); + " mp_wr_bitmap=0x%04x -> 0x%04x\n", + *port, card->curr_wr_port, wr_bitmap, + card->mp_wr_bitmap); return -1; } dev_dbg(adapter->dev, "data: port=%d mp_wr_bitmap=0x%04x -> 0x%04x\n", - *port, wr_bitmap, card->mp_wr_bitmap); + *port, wr_bitmap, card->mp_wr_bitmap); return 0; } @@ -586,8 +582,8 @@ mwifiex_sdio_poll_card_status(struct mwifiex_adapter *adapter, u8 bits) usleep_range(10, 20); } - dev_err(adapter->dev, "poll card status failed, tries = %d\n", - tries); + dev_err(adapter->dev, "poll card status failed, tries = %d\n", tries); + return -1; } @@ -670,14 +666,14 @@ static int mwifiex_sdio_card_to_host(struct mwifiex_adapter *adapter, if (ret) { dev_err(adapter->dev, "%s: read iomem failed: %d\n", __func__, - ret); + ret); return -1; } nb = le16_to_cpu(*(__le16 *) (buffer)); if (nb > npayload) { - dev_err(adapter->dev, "%s: invalid packet, nb=%d, npayload=%d\n", - __func__, nb, npayload); + dev_err(adapter->dev, "%s: invalid packet, nb=%d npayload=%d\n", + __func__, nb, npayload); return -1; } @@ -707,19 +703,19 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, u32 i = 0; if (!firmware_len) { - dev_err(adapter->dev, "firmware image not found!" - " Terminating download\n"); + dev_err(adapter->dev, + "firmware image not found! Terminating download\n"); return -1; } dev_dbg(adapter->dev, "info: downloading FW image (%d bytes)\n", - firmware_len); + firmware_len); /* Assume that the allocated buffer is 8-byte aligned */ fwbuf = kzalloc(MWIFIEX_UPLD_SIZE, GFP_KERNEL); if (!fwbuf) { - dev_err(adapter->dev, "unable to alloc buffer for firmware." - " Terminating download\n"); + dev_err(adapter->dev, + "unable to alloc buffer for FW. Terminating dnld\n"); return -ENOMEM; } @@ -731,7 +727,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, DN_LD_CARD_RDY); if (ret) { dev_err(adapter->dev, "FW download with helper:" - " poll status timeout @ %d\n", offset); + " poll status timeout @ %d\n", offset); goto done; } @@ -743,17 +739,19 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, ret = mwifiex_read_reg(adapter, HOST_F1_RD_BASE_0, &base0); if (ret) { - dev_err(adapter->dev, "dev BASE0 register read" - " failed: base0=0x%04X(%d). Terminating " - "download\n", base0, base0); + dev_err(adapter->dev, + "dev BASE0 register read failed: " + "base0=%#04X(%d). Terminating dnld\n", + base0, base0); goto done; } ret = mwifiex_read_reg(adapter, HOST_F1_RD_BASE_1, &base1); if (ret) { - dev_err(adapter->dev, "dev BASE1 register read" - " failed: base1=0x%04X(%d). Terminating " - "download\n", base1, base1); + dev_err(adapter->dev, + "dev BASE1 register read failed: " + "base1=%#04X(%d). Terminating dnld\n", + base1, base1); goto done; } len = (u16) (((base1 & 0xff) << 8) | (base0 & 0xff)); @@ -767,8 +765,9 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, if (!len) { break; } else if (len > MWIFIEX_UPLD_SIZE) { - dev_err(adapter->dev, "FW download failed @ %d," - " invalid length %d\n", offset, len); + dev_err(adapter->dev, + "FW dnld failed @ %d, invalid length %d\n", + offset, len); ret = -1; goto done; } @@ -778,13 +777,14 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, if (len & BIT(0)) { i++; if (i > MAX_WRITE_IOMEM_RETRY) { - dev_err(adapter->dev, "FW download failed @" - " %d, over max retry count\n", offset); + dev_err(adapter->dev, + "FW dnld failed @ %d, over max retry\n", + offset); ret = -1; goto done; } dev_err(adapter->dev, "CRC indicated by the helper:" - " len = 0x%04X, txlen = %d\n", len, txlen); + " len = 0x%04X, txlen = %d\n", len, txlen); len &= ~BIT(0); /* Setting this to 0 to resend from same offset */ txlen = 0; @@ -796,8 +796,8 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, if (firmware_len - offset < txlen) txlen = firmware_len - offset; - tx_blocks = (txlen + MWIFIEX_SDIO_BLOCK_SIZE - - 1) / MWIFIEX_SDIO_BLOCK_SIZE; + tx_blocks = (txlen + MWIFIEX_SDIO_BLOCK_SIZE - 1) + / MWIFIEX_SDIO_BLOCK_SIZE; /* Copy payload to buffer */ memmove(fwbuf, &firmware[offset], txlen); @@ -807,8 +807,9 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, MWIFIEX_SDIO_BLOCK_SIZE, adapter->ioport); if (ret) { - dev_err(adapter->dev, "FW download, write iomem (%d)" - " failed @ %d\n", i, offset); + dev_err(adapter->dev, + "FW download, write iomem (%d) failed @ %d\n", + i, offset); if (mwifiex_write_reg(adapter, CONFIGURATION_REG, 0x04)) dev_err(adapter->dev, "write CFG reg failed\n"); @@ -820,7 +821,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, } while (true); dev_dbg(adapter->dev, "info: FW download over, size %d bytes\n", - offset); + offset); ret = 0; done: @@ -912,7 +913,7 @@ mwifiex_sdio_interrupt(struct sdio_func *func) card = sdio_get_drvdata(func); if (!card || !card->adapter) { pr_debug("int: func=%p card=%p adapter=%p\n", - func, card, card ? card->adapter : NULL); + func, card, card ? card->adapter : NULL); return; } adapter = card->adapter; @@ -955,10 +956,12 @@ static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter, if (adapter->ps_state == PS_STATE_SLEEP_CFM) mwifiex_process_sleep_confirm_resp(adapter, - skb->data, skb->len); + skb->data, + skb->len); - memcpy(cmd_buf, skb->data, min_t(u32, - MWIFIEX_SIZE_OF_CMD_BUFFER, skb->len)); + memcpy(cmd_buf, skb->data, + min_t(u32, MWIFIEX_SIZE_OF_CMD_BUFFER, + skb->len)); dev_kfree_skb_any(skb); } else { @@ -1016,7 +1019,7 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter, if (port == CTRL_PORT) { /* Read the command Resp without aggr */ dev_dbg(adapter->dev, "info: %s: no aggregation for cmd " - "response\n", __func__); + "response\n", __func__); f_do_rx_cur = 1; goto rx_curr_single; @@ -1024,7 +1027,7 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter, if (!card->mpa_rx.enabled) { dev_dbg(adapter->dev, "info: %s: rx aggregation disabled\n", - __func__); + __func__); f_do_rx_cur = 1; goto rx_curr_single; @@ -1071,7 +1074,7 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter, if (MP_RX_AGGR_PKT_LIMIT_REACHED(card) || MP_RX_AGGR_PORT_LIMIT_REACHED(card)) { dev_dbg(adapter->dev, "info: %s: aggregated packet " - "limit reached\n", __func__); + "limit reached\n", __func__); /* No more pkts allowed in Aggr buf, rx it */ f_do_rx_aggr = 1; } @@ -1080,7 +1083,7 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter, if (f_do_rx_aggr) { /* do aggr RX now */ dev_dbg(adapter->dev, "info: do_rx_aggr: num of packets: %d\n", - card->mpa_rx.pkt_cnt); + card->mpa_rx.pkt_cnt); if (mwifiex_read_data_sync(adapter, card->mpa_rx.buf, card->mpa_rx.buf_len, @@ -1194,7 +1197,7 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) card->mp_wr_bitmap = ((u16) card->mp_regs[WR_BITMAP_U]) << 8; card->mp_wr_bitmap |= (u16) card->mp_regs[WR_BITMAP_L]; dev_dbg(adapter->dev, "int: DNLD: wr_bitmap=0x%04x\n", - card->mp_wr_bitmap); + card->mp_wr_bitmap); if (adapter->data_sent && (card->mp_wr_bitmap & card->mp_data_port_mask)) { dev_dbg(adapter->dev, @@ -1216,12 +1219,12 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) } dev_dbg(adapter->dev, "info: cmd_sent=%d data_sent=%d\n", - adapter->cmd_sent, adapter->data_sent); + adapter->cmd_sent, adapter->data_sent); if (sdio_ireg & UP_LD_HOST_INT_STATUS) { card->mp_rd_bitmap = ((u16) card->mp_regs[RD_BITMAP_U]) << 8; card->mp_rd_bitmap |= (u16) card->mp_regs[RD_BITMAP_L]; dev_dbg(adapter->dev, "int: UPLD: rd_bitmap=0x%04x\n", - card->mp_rd_bitmap); + card->mp_rd_bitmap); while (true) { ret = mwifiex_get_rd_port(adapter, &port); @@ -1235,15 +1238,15 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) rx_len = ((u16) card->mp_regs[len_reg_u]) << 8; rx_len |= (u16) card->mp_regs[len_reg_l]; dev_dbg(adapter->dev, "info: RX: port=%d rx_len=%u\n", - port, rx_len); + port, rx_len); rx_blocks = (rx_len + MWIFIEX_SDIO_BLOCK_SIZE - 1) / MWIFIEX_SDIO_BLOCK_SIZE; - if (rx_len <= INTF_HEADER_LEN - || (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE) > - MWIFIEX_RX_DATA_BUF_SIZE) { + if (rx_len <= INTF_HEADER_LEN || + (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE) > + MWIFIEX_RX_DATA_BUF_SIZE) { dev_err(adapter->dev, "invalid rx_len=%d\n", - rx_len); + rx_len); return -1; } rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE); @@ -1252,42 +1255,42 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) if (!skb) { dev_err(adapter->dev, "%s: failed to alloc skb", - __func__); + __func__); return -1; } skb_put(skb, rx_len); dev_dbg(adapter->dev, "info: rx_len = %d skb->len = %d\n", - rx_len, skb->len); + rx_len, skb->len); if (mwifiex_sdio_card_to_host_mp_aggr(adapter, skb, port)) { u32 cr = 0; dev_err(adapter->dev, "card_to_host_mpa failed:" - " int status=%#x\n", sdio_ireg); + " int status=%#x\n", sdio_ireg); if (mwifiex_read_reg(adapter, CONFIGURATION_REG, &cr)) dev_err(adapter->dev, - "read CFG reg failed\n"); + "read CFG reg failed\n"); dev_dbg(adapter->dev, - "info: CFG reg val = %d\n", cr); + "info: CFG reg val = %d\n", cr); if (mwifiex_write_reg(adapter, CONFIGURATION_REG, (cr | 0x04))) dev_err(adapter->dev, - "write CFG reg failed\n"); + "write CFG reg failed\n"); dev_dbg(adapter->dev, "info: write success\n"); if (mwifiex_read_reg(adapter, CONFIGURATION_REG, &cr)) dev_err(adapter->dev, - "read CFG reg failed\n"); + "read CFG reg failed\n"); dev_dbg(adapter->dev, - "info: CFG reg val =%x\n", cr); + "info: CFG reg val =%x\n", cr); return -1; } } @@ -1323,7 +1326,7 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, if ((!card->mpa_tx.enabled) || (port == CTRL_PORT)) { dev_dbg(adapter->dev, "info: %s: tx aggregation disabled\n", - __func__); + __func__); f_send_cur_buf = 1; goto tx_curr_single; @@ -1332,7 +1335,7 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, if (next_pkt_len) { /* More pkt in TX queue */ dev_dbg(adapter->dev, "info: %s: more packets in queue.\n", - __func__); + __func__); if (MP_TX_AGGR_IN_PROGRESS(card)) { if (!MP_TX_AGGR_PORT_LIMIT_REACHED(card) && @@ -1340,9 +1343,9 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, f_precopy_cur_buf = 1; if (!(card->mp_wr_bitmap & - (1 << card->curr_wr_port)) - || !MP_TX_AGGR_BUF_HAS_ROOM( - card, pkt_len + next_pkt_len)) + (1 << card->curr_wr_port)) || + !MP_TX_AGGR_BUF_HAS_ROOM( + card, pkt_len + next_pkt_len)) f_send_aggr_buf = 1; } else { /* No room in Aggr buf, send it */ @@ -1356,8 +1359,8 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, f_postcopy_cur_buf = 1; } } else { - if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len) - && (card->mp_wr_bitmap & (1 << card->curr_wr_port))) + if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len) && + (card->mp_wr_bitmap & (1 << card->curr_wr_port))) f_precopy_cur_buf = 1; else f_send_cur_buf = 1; @@ -1365,7 +1368,7 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, } else { /* Last pkt in TX queue */ dev_dbg(adapter->dev, "info: %s: Last packet in Tx Queue.\n", - __func__); + __func__); if (MP_TX_AGGR_IN_PROGRESS(card)) { /* some packs in Aggr buf already */ @@ -1383,7 +1386,7 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, if (f_precopy_cur_buf) { dev_dbg(adapter->dev, "data: %s: precopy current buffer\n", - __func__); + __func__); MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port); if (MP_TX_AGGR_PKT_LIMIT_REACHED(card) || @@ -1394,7 +1397,7 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, if (f_send_aggr_buf) { dev_dbg(adapter->dev, "data: %s: send aggr buffer: %d %d\n", - __func__, + __func__, card->mpa_tx.start_port, card->mpa_tx.ports); ret = mwifiex_write_data_to_card(adapter, card->mpa_tx.buf, card->mpa_tx.buf_len, @@ -1408,14 +1411,14 @@ static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter, tx_curr_single: if (f_send_cur_buf) { dev_dbg(adapter->dev, "data: %s: send current buffer %d\n", - __func__, port); + __func__, port); ret = mwifiex_write_data_to_card(adapter, payload, pkt_len, adapter->ioport + port); } if (f_postcopy_cur_buf) { dev_dbg(adapter->dev, "data: %s: postcopy current buffer\n", - __func__); + __func__); MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port); } @@ -1460,7 +1463,7 @@ static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter, ret = mwifiex_get_wr_port_data(adapter, &port); if (ret) { dev_err(adapter->dev, "%s: no wr_port available\n", - __func__); + __func__); return ret; } } else { @@ -1470,7 +1473,7 @@ static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter, if (pkt_len <= INTF_HEADER_LEN || pkt_len > MWIFIEX_UPLD_SIZE) dev_err(adapter->dev, "%s: payload=%p, nb=%d\n", - __func__, payload, pkt_len); + __func__, payload, pkt_len); } /* Transfer data to card */ @@ -1478,10 +1481,11 @@ static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter, if (tx_param) ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len, - port, tx_param->next_pkt_len); + port, tx_param->next_pkt_len + ); else ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len, - port, 0); + port, 0); if (ret) { if (type == MWIFIEX_TYPE_CMD) @@ -1734,7 +1738,7 @@ mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port) card->curr_wr_port = 1; dev_dbg(adapter->dev, "cmd: mp_end_port %d, data port mask 0x%x\n", - port, card->mp_data_port_mask); + port, card->mp_data_port_mask); } static struct mwifiex_if_ops sdio_ops = { -- GitLab From 9c05fd72042bafdf86c6273e3b63bb8571f66177 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:40 -0700 Subject: [PATCH 1739/1846] mwifiex: fix checkpatch --strict warnings/errors Part 7 For sta_cmd.c and sta_cmdresp.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sta_cmd.c | 175 ++++++++++----------- drivers/net/wireless/mwifiex/sta_cmdresp.c | 60 ++++--- 2 files changed, 114 insertions(+), 121 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c index 324c651527cb..6c8e4594b48b 100644 --- a/drivers/net/wireless/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/mwifiex/sta_cmd.c @@ -110,7 +110,7 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB); cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib) - - 1 + S_DS_GEN); + - 1 + S_DS_GEN); snmp_mib->oid = cpu_to_le16((u16)cmd_oid); if (cmd_action == HostCmd_ACT_GEN_GET) { @@ -127,8 +127,8 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x," " Value=0x%x\n", - cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size), - le16_to_cpu(*(__le16 *) snmp_mib->value)); + cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size), + le16_to_cpu(*(__le16 *) snmp_mib->value)); return 0; } @@ -174,8 +174,8 @@ static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, rate_scope = (struct mwifiex_rate_scope *) ((u8 *) rate_cfg + sizeof(struct host_cmd_ds_tx_rate_cfg)); rate_scope->type = cpu_to_le16(TLV_TYPE_RATE_SCOPE); - rate_scope->length = cpu_to_le16(sizeof(struct mwifiex_rate_scope) - - sizeof(struct mwifiex_ie_types_header)); + rate_scope->length = cpu_to_le16 + (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header)); if (pbitmap_rates != NULL) { rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]); rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]); @@ -197,7 +197,7 @@ static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, } rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope + - sizeof(struct mwifiex_rate_scope)); + sizeof(struct mwifiex_rate_scope)); rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL); rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode)); rate_drop->rate_drop_mode = 0; @@ -284,22 +284,22 @@ mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH); if (!hs_activate && - (hscfg_param->conditions - != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) - && ((adapter->arp_filter_size > 0) - && (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) { + (hscfg_param->conditions != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) && + ((adapter->arp_filter_size > 0) && + (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) { dev_dbg(adapter->dev, "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n", - adapter->arp_filter_size); + adapter->arp_filter_size); memcpy(((u8 *) hs_cfg) + sizeof(struct host_cmd_ds_802_11_hs_cfg_enh), adapter->arp_filter, adapter->arp_filter_size); - cmd->size = cpu_to_le16(adapter->arp_filter_size + - sizeof(struct host_cmd_ds_802_11_hs_cfg_enh) - + S_DS_GEN); + cmd->size = cpu_to_le16 + (adapter->arp_filter_size + + sizeof(struct host_cmd_ds_802_11_hs_cfg_enh) + + S_DS_GEN); } else { cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct - host_cmd_ds_802_11_hs_cfg_enh)); + host_cmd_ds_802_11_hs_cfg_enh)); } if (hs_activate) { hs_cfg->action = cpu_to_le16(HS_ACTIVATE); @@ -467,7 +467,7 @@ mwifiex_set_keyparamset_wep(struct mwifiex_private *priv, key_param_set = (struct mwifiex_ie_type_key_param_set *) ((u8 *)key_param_set + - cur_key_param_len); + cur_key_param_len); } else if (!priv->wep_key[i].key_length) { continue; } else { @@ -527,13 +527,13 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, if (enc_key->is_wapi_key) { dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n"); key_material->key_param_set.key_type_id = - cpu_to_le16(KEY_TYPE_ID_WAPI); + cpu_to_le16(KEY_TYPE_ID_WAPI); if (cmd_oid == KEY_INFO_ENABLED) key_material->key_param_set.key_info = - cpu_to_le16(KEY_ENABLED); + cpu_to_le16(KEY_ENABLED); else key_material->key_param_set.key_info = - cpu_to_le16(!KEY_ENABLED); + cpu_to_le16(!KEY_ENABLED); key_material->key_param_set.key[0] = enc_key->key_index; if (!priv->sec_info.wapi_key_on) @@ -553,9 +553,9 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, } key_material->key_param_set.type = - cpu_to_le16(TLV_TYPE_KEY_MATERIAL); + cpu_to_le16(TLV_TYPE_KEY_MATERIAL); key_material->key_param_set.key_len = - cpu_to_le16(WAPI_KEY_LEN); + cpu_to_le16(WAPI_KEY_LEN); memcpy(&key_material->key_param_set.key[2], enc_key->key_material, enc_key->key_len); memcpy(&key_material->key_param_set.key[2 + enc_key->key_len], @@ -565,49 +565,49 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) + sizeof(struct mwifiex_ie_types_header); - cmd->size = cpu_to_le16(key_param_len + - sizeof(key_material->action) + S_DS_GEN); + cmd->size = cpu_to_le16(sizeof(key_material->action) + + S_DS_GEN + key_param_len); return ret; } if (enc_key->key_len == WLAN_KEY_LEN_CCMP) { dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n"); key_material->key_param_set.key_type_id = - cpu_to_le16(KEY_TYPE_ID_AES); + cpu_to_le16(KEY_TYPE_ID_AES); if (cmd_oid == KEY_INFO_ENABLED) key_material->key_param_set.key_info = - cpu_to_le16(KEY_ENABLED); + cpu_to_le16(KEY_ENABLED); else key_material->key_param_set.key_info = - cpu_to_le16(!KEY_ENABLED); + cpu_to_le16(!KEY_ENABLED); if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) /* AES pairwise key: unicast */ key_material->key_param_set.key_info |= - cpu_to_le16(KEY_UNICAST); + cpu_to_le16(KEY_UNICAST); else /* AES group key: multicast */ key_material->key_param_set.key_info |= - cpu_to_le16(KEY_MCAST); + cpu_to_le16(KEY_MCAST); } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) { dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n"); key_material->key_param_set.key_type_id = - cpu_to_le16(KEY_TYPE_ID_TKIP); + cpu_to_le16(KEY_TYPE_ID_TKIP); key_material->key_param_set.key_info = - cpu_to_le16(KEY_ENABLED); + cpu_to_le16(KEY_ENABLED); if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) /* TKIP pairwise key: unicast */ key_material->key_param_set.key_info |= - cpu_to_le16(KEY_UNICAST); + cpu_to_le16(KEY_UNICAST); else /* TKIP group key: multicast */ key_material->key_param_set.key_info |= - cpu_to_le16(KEY_MCAST); + cpu_to_le16(KEY_MCAST); } if (key_material->key_param_set.key_type_id) { key_material->key_param_set.type = - cpu_to_le16(TLV_TYPE_KEY_MATERIAL); + cpu_to_le16(TLV_TYPE_KEY_MATERIAL); key_material->key_param_set.key_len = - cpu_to_le16((u16) enc_key->key_len); + cpu_to_le16((u16) enc_key->key_len); memcpy(key_material->key_param_set.key, enc_key->key_material, enc_key->key_len); key_material->key_param_set.length = @@ -615,10 +615,10 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, KEYPARAMSET_FIXED_LEN); key_param_len = (u16) (enc_key->key_len + KEYPARAMSET_FIXED_LEN) - + sizeof(struct mwifiex_ie_types_header); + + sizeof(struct mwifiex_ie_types_header); - cmd->size = cpu_to_le16(key_param_len + - sizeof(key_material->action) + S_DS_GEN); + cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN + + key_param_len); } return ret; @@ -655,21 +655,22 @@ static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv, /* Set domain info fields */ domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY); memcpy(domain->country_code, adapter->domain_reg.country_code, - sizeof(domain->country_code)); + sizeof(domain->country_code)); - domain->header.len = cpu_to_le16((no_of_triplet * - sizeof(struct ieee80211_country_ie_triplet)) + - sizeof(domain->country_code)); + domain->header.len = + cpu_to_le16((no_of_triplet * + sizeof(struct ieee80211_country_ie_triplet)) + + sizeof(domain->country_code)); if (no_of_triplet) { memcpy(domain->triplet, adapter->domain_reg.triplet, - no_of_triplet * - sizeof(struct ieee80211_country_ie_triplet)); + no_of_triplet * sizeof(struct + ieee80211_country_ie_triplet)); cmd->size = cpu_to_le16(sizeof(domain_info->action) + - le16_to_cpu(domain->header.len) + - sizeof(struct mwifiex_ie_types_header) - + S_DS_GEN); + le16_to_cpu(domain->header.len) + + sizeof(struct mwifiex_ie_types_header) + + S_DS_GEN); } else { cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); } @@ -698,8 +699,8 @@ static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv, + S_DS_GEN); if (cmd_action == HostCmd_ACT_GEN_SET) { - if ((priv->adapter->adhoc_start_band & BAND_A) - || (priv->adapter->adhoc_start_band & BAND_AN)) + if ((priv->adapter->adhoc_start_band & BAND_A) || + (priv->adapter->adhoc_start_band & BAND_AN)) rf_chan->rf_type = cpu_to_le16(HostCmd_SCAN_RADIO_TYPE_A); @@ -777,7 +778,7 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN); mac_reg = (struct host_cmd_ds_mac_reg_access *) &cmd-> - params.mac_reg; + params.mac_reg; mac_reg->action = cpu_to_le16(cmd_action); mac_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); @@ -789,8 +790,8 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, struct host_cmd_ds_bbp_reg_access *bbp_reg; cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN); - bbp_reg = (struct host_cmd_ds_bbp_reg_access *) &cmd-> - params.bbp_reg; + bbp_reg = (struct host_cmd_ds_bbp_reg_access *) + &cmd->params.bbp_reg; bbp_reg->action = cpu_to_le16(cmd_action); bbp_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); @@ -802,11 +803,10 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, struct host_cmd_ds_rf_reg_access *rf_reg; cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN); - rf_reg = (struct host_cmd_ds_rf_reg_access *) &cmd-> - params.rf_reg; + rf_reg = (struct host_cmd_ds_rf_reg_access *) + &cmd->params.rf_reg; rf_reg->action = cpu_to_le16(cmd_action); - rf_reg->offset = - cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); + rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); rf_reg->value = (u8) le32_to_cpu(reg_rw->value); break; } @@ -819,7 +819,7 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, params.pmic_reg; pmic_reg->action = cpu_to_le16(cmd_action); pmic_reg->offset = - cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); + cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); pmic_reg->value = (u8) le32_to_cpu(reg_rw->value); break; } @@ -828,11 +828,11 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, struct host_cmd_ds_rf_reg_access *cau_reg; cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN); - cau_reg = (struct host_cmd_ds_rf_reg_access *) &cmd-> - params.rf_reg; + cau_reg = (struct host_cmd_ds_rf_reg_access *) + &cmd->params.rf_reg; cau_reg->action = cpu_to_le16(cmd_action); cau_reg->offset = - cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); + cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); cau_reg->value = (u8) le32_to_cpu(reg_rw->value); break; } @@ -868,7 +868,7 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, */ static int mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, u16 action) + struct host_cmd_ds_command *cmd, u16 action) { struct host_cmd_ds_pcie_details *host_spec = &cmd->params.pcie_host_spec; @@ -882,29 +882,25 @@ mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv, memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details)); - if (action == HostCmd_ACT_GEN_SET) { - /* Send the ring base addresses and count to firmware */ - host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase); - host_spec->txbd_addr_hi = - (u32)(((u64)card->txbd_ring_pbase)>>32); - host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD; - host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase); - host_spec->rxbd_addr_hi = - (u32)(((u64)card->rxbd_ring_pbase)>>32); - host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD; - host_spec->evtbd_addr_lo = - (u32)(card->evtbd_ring_pbase); - host_spec->evtbd_addr_hi = - (u32)(((u64)card->evtbd_ring_pbase)>>32); - host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD; - if (card->sleep_cookie) { - buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie); - host_spec->sleep_cookie_addr_lo = (u32) *buf_pa; - host_spec->sleep_cookie_addr_hi = - (u32) (((u64)*buf_pa) >> 32); - dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: " - "0x%x\n", host_spec->sleep_cookie_addr_lo); - } + if (action != HostCmd_ACT_GEN_SET) + return 0; + + /* Send the ring base addresses and count to firmware */ + host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase); + host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32); + host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD; + host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase); + host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32); + host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD; + host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase); + host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32); + host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD; + if (card->sleep_cookie) { + buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie); + host_spec->sleep_cookie_addr_lo = (u32) *buf_pa; + host_spec->sleep_cookie_addr_hi = (u32) (((u64)*buf_pa) >> 32); + dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n", + host_spec->sleep_cookie_addr_lo); } return 0; @@ -1036,12 +1032,12 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, break; case HostCmd_CMD_802_11_KEY_MATERIAL: ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr, - cmd_action, cmd_oid, - data_buf); + cmd_action, cmd_oid, + data_buf); break; case HostCmd_CMD_802_11D_DOMAIN_INFO: ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr, - cmd_action); + cmd_action); break; case HostCmd_CMD_RECONFIGURE_TX_BUFF: ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action, @@ -1052,8 +1048,7 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, data_buf); break; case HostCmd_CMD_11N_CFG: - ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, - data_buf); + ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, data_buf); break; case HostCmd_CMD_WMM_GET_STATUS: dev_dbg(priv->adapter->dev, @@ -1131,8 +1126,8 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) if (first_sta) { if (priv->adapter->iface_type == MWIFIEX_PCIE) { ret = mwifiex_send_cmd_async(priv, - HostCmd_CMD_PCIE_DESC_DETAILS, - HostCmd_ACT_GEN_SET, 0, NULL); + HostCmd_CMD_PCIE_DESC_DETAILS, + HostCmd_ACT_GEN_SET, 0, NULL); if (ret) return -1; } diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c index a2a9c513e26b..4da19ed0f078 100644 --- a/drivers/net/wireless/mwifiex/sta_cmdresp.c +++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c @@ -49,7 +49,7 @@ mwifiex_process_cmdresp_error(struct mwifiex_private *priv, unsigned long flags; dev_err(adapter->dev, "CMD_RESP: cmd %#x error, result=%#x\n", - resp->command, resp->result); + resp->command, resp->result); if (adapter->curr_cmd->wait_q_enabled) adapter->cmd_wait_q.status = -1; @@ -57,13 +57,13 @@ mwifiex_process_cmdresp_error(struct mwifiex_private *priv, switch (le16_to_cpu(resp->command)) { case HostCmd_CMD_802_11_PS_MODE_ENH: pm = &resp->params.psmode_enh; - dev_err(adapter->dev, "PS_MODE_ENH cmd failed: " - "result=0x%x action=0x%X\n", - resp->result, le16_to_cpu(pm->action)); + dev_err(adapter->dev, + "PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n", + resp->result, le16_to_cpu(pm->action)); /* We do not re-try enter-ps command in ad-hoc mode. */ if (le16_to_cpu(pm->action) == EN_AUTO_PS && - (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) && - priv->bss_mode == NL80211_IFTYPE_ADHOC) + (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) && + priv->bss_mode == NL80211_IFTYPE_ADHOC) adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM; break; @@ -123,7 +123,7 @@ static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv, struct mwifiex_ds_get_signal *signal) { struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp = - &resp->params.rssi_info_rsp; + &resp->params.rssi_info_rsp; priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last); priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last); @@ -191,8 +191,8 @@ static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, u32 ul_temp; dev_dbg(priv->adapter->dev, "info: SNMP_RESP: oid value = %#x," - " query_type = %#x, buf size = %#x\n", - oid, query_type, le16_to_cpu(smib->buf_size)); + " query_type = %#x, buf size = %#x\n", + oid, query_type, le16_to_cpu(smib->buf_size)); if (query_type == HostCmd_ACT_GEN_GET) { ul_temp = le16_to_cpu(*((__le16 *) (smib->value))); if (data_buf) @@ -444,7 +444,7 @@ static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv, break; default: dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n", - action); + action); return 0; } dev_dbg(adapter->dev, @@ -464,7 +464,7 @@ static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) { struct host_cmd_ds_802_11_mac_address *cmd_mac_addr = - &resp->params.mac_addr; + &resp->params.mac_addr; memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN); @@ -549,7 +549,7 @@ static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) { struct host_cmd_ds_802_11_key_material *key = - &resp->params.key_material; + &resp->params.key_material; if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) { if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) { @@ -580,17 +580,18 @@ static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv, u16 action = le16_to_cpu(domain_info->action); u8 no_of_triplet; - no_of_triplet = (u8) ((le16_to_cpu(domain->header.len) - - IEEE80211_COUNTRY_STRING_LEN) / - sizeof(struct ieee80211_country_ie_triplet)); + no_of_triplet = (u8) ((le16_to_cpu(domain->header.len) + - IEEE80211_COUNTRY_STRING_LEN) + / sizeof(struct ieee80211_country_ie_triplet)); - dev_dbg(priv->adapter->dev, "info: 11D Domain Info Resp:" - " no_of_triplet=%d\n", no_of_triplet); + dev_dbg(priv->adapter->dev, + "info: 11D Domain Info Resp: no_of_triplet=%d\n", + no_of_triplet); if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) { dev_warn(priv->adapter->dev, - "11D: invalid number of triplets %d " - "returned!!\n", no_of_triplet); + "11D: invalid number of triplets %d returned\n", + no_of_triplet); return -1; } @@ -624,8 +625,8 @@ static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv, if (priv->curr_bss_params.bss_descriptor.channel != new_channel) { dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n", - priv->curr_bss_params.bss_descriptor.channel, - new_channel); + priv->curr_bss_params.bss_descriptor.channel, + new_channel); /* Update the channel again */ priv->curr_bss_params.bss_descriptor.channel = new_channel; } @@ -747,7 +748,7 @@ static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv, struct host_cmd_ds_command *resp) { struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp = - &(resp->params.ibss_coalescing); + &(resp->params.ibss_coalescing); u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET) @@ -887,20 +888,17 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, case HostCmd_CMD_RECONFIGURE_TX_BUFF: adapter->tx_buf_size = (u16) le16_to_cpu(resp->params. tx_buf.buff_size); - adapter->tx_buf_size = (adapter->tx_buf_size / - MWIFIEX_SDIO_BLOCK_SIZE) * - MWIFIEX_SDIO_BLOCK_SIZE; + adapter->tx_buf_size = (adapter->tx_buf_size + / MWIFIEX_SDIO_BLOCK_SIZE) + * MWIFIEX_SDIO_BLOCK_SIZE; adapter->curr_tx_buf_size = adapter->tx_buf_size; dev_dbg(adapter->dev, "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n", - adapter->max_tx_buf_size, adapter->tx_buf_size); + adapter->max_tx_buf_size, adapter->tx_buf_size); if (adapter->if_ops.update_mp_end_port) adapter->if_ops.update_mp_end_port(adapter, - le16_to_cpu(resp-> - params. - tx_buf. - mp_end_port)); + le16_to_cpu(resp->params.tx_buf.mp_end_port)); break; case HostCmd_CMD_AMSDU_AGGR_CTRL: ret = mwifiex_ret_amsdu_aggr_ctrl(resp, data_buf); @@ -928,7 +926,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, break; default: dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n", - resp->command); + resp->command); break; } -- GitLab From 500f747c73ec9bff7692db0031a3fb726166f4d5 Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:41 -0700 Subject: [PATCH 1740/1846] mwifiex: fix checkpatch --strict warnings/errors Part 8 For files sta_event.c and sta_ioctl.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sta_event.c | 41 ++++----- drivers/net/wireless/mwifiex/sta_ioctl.c | 102 +++++++++++------------ 2 files changed, 73 insertions(+), 70 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c index b9b59db60454..cc531b536a56 100644 --- a/drivers/net/wireless/mwifiex/sta_event.c +++ b/drivers/net/wireless/mwifiex/sta_event.c @@ -93,11 +93,11 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) */ dev_dbg(adapter->dev, "info: previous SSID=%s, SSID len=%u\n", - priv->prev_ssid.ssid, priv->prev_ssid.ssid_len); + priv->prev_ssid.ssid, priv->prev_ssid.ssid_len); dev_dbg(adapter->dev, "info: current SSID=%s, SSID len=%u\n", - priv->curr_bss_params.bss_descriptor.ssid.ssid, - priv->curr_bss_params.bss_descriptor.ssid.ssid_len); + priv->curr_bss_params.bss_descriptor.ssid.ssid, + priv->curr_bss_params.bss_descriptor.ssid.ssid_len); memcpy(&priv->prev_ssid, &priv->curr_bss_params.bss_descriptor.ssid, @@ -115,9 +115,9 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) if (adapter->num_cmd_timeout && adapter->curr_cmd) return; priv->media_connected = false; - dev_dbg(adapter->dev, "info: successfully disconnected from" - " %pM: reason code %d\n", priv->cfg_bssid, - WLAN_REASON_DEAUTH_LEAVING); + 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); @@ -192,8 +192,8 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) switch (eventcause) { case EVENT_DUMMY_HOST_WAKEUP_SIGNAL: - dev_err(adapter->dev, "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL," - " ignoring it\n"); + dev_err(adapter->dev, + "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n"); break; case EVENT_LINK_SENSED: dev_dbg(adapter->dev, "event: LINK_SENSED\n"); @@ -235,8 +235,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) case EVENT_PS_AWAKE: dev_dbg(adapter->dev, "info: EVENT: AWAKE\n"); if (!adapter->pps_uapsd_mode && - priv->media_connected && - adapter->sleep_period.period) { + priv->media_connected && adapter->sleep_period.period) { adapter->pps_uapsd_mode = true; dev_dbg(adapter->dev, "event: PPS/UAPSD mode activated\n"); @@ -244,15 +243,19 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) adapter->tx_lock_flag = false; if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) { if (mwifiex_check_last_packet_indication(priv)) { - if (!adapter->data_sent) { - if (!mwifiex_send_null_packet(priv, - MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET - | - MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) + if (adapter->data_sent) { + adapter->ps_state = PS_STATE_AWAKE; + adapter->pm_wakeup_card_req = false; + adapter->pm_wakeup_fw_try = false; + break; + } + if (!mwifiex_send_null_packet + (priv, + MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET | + MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) adapter->ps_state = PS_STATE_SLEEP; return 0; - } } } adapter->ps_state = PS_STATE_AWAKE; @@ -371,12 +374,12 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) break; case EVENT_AMSDU_AGGR_CTRL: dev_dbg(adapter->dev, "event: AMSDU_AGGR_CTRL %d\n", - *(u16 *) adapter->event_body); + *(u16 *) adapter->event_body); adapter->tx_buf_size = min(adapter->curr_tx_buf_size, le16_to_cpu(*(__le16 *) adapter->event_body)); dev_dbg(adapter->dev, "event: tx_buf_size %d\n", - adapter->tx_buf_size); + adapter->tx_buf_size); break; case EVENT_WEP_ICV_ERR: @@ -392,7 +395,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) break; default: dev_dbg(adapter->dev, "event: unknown event id: %#x\n", - eventcause); + eventcause); break; } diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index a3d79f4a6192..64e0b1010850 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -71,7 +71,7 @@ int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter) /* Wait for completion */ wait_event_interruptible(adapter->cmd_wait_q.wait, - *(cmd_queued->condition)); + *(cmd_queued->condition)); if (!*(cmd_queued->condition)) cancel_flag = true; @@ -266,9 +266,8 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, /* Adhoc mode */ /* If the requested SSID matches current SSID, return */ if (bss_desc && bss_desc->ssid.ssid_len && - (!mwifiex_ssid_cmp - (&priv->curr_bss_params.bss_descriptor.ssid, - &bss_desc->ssid))) { + (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. + ssid, &bss_desc->ssid))) { kfree(bss_desc); kfree(beacon_ie); return 0; @@ -350,9 +349,8 @@ static int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action, adapter->hs_cfg.gpio = (u8)hs_cfg->gpio; if (hs_cfg->gap) adapter->hs_cfg.gap = (u8)hs_cfg->gap; - } else if (adapter->hs_cfg.conditions == - cpu_to_le32( - HOST_SLEEP_CFG_CANCEL)) { + } else if (adapter->hs_cfg.conditions + == cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) { /* Return failure if no parameters for HS enable */ status = -1; @@ -374,7 +372,7 @@ static int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action, cpu_to_le32(prev_cond); } else { adapter->hs_cfg.conditions = - cpu_to_le32(hs_cfg->conditions); + cpu_to_le32(hs_cfg->conditions); adapter->hs_cfg.gpio = (u8)hs_cfg->gpio; adapter->hs_cfg.gap = (u8)hs_cfg->gap; } @@ -431,7 +429,7 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter) hscfg.is_invoke_hostcmd = true; if (mwifiex_set_hs_params(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_STA), + MWIFIEX_BSS_ROLE_STA), HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD, &hscfg)) { dev_err(adapter->dev, "IOCTL request HS enable failed\n"); @@ -439,7 +437,7 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter) } wait_event_interruptible(adapter->hs_activate_wait_q, - adapter->hs_activate_wait_q_woken); + adapter->hs_activate_wait_q_woken); return true; } @@ -536,7 +534,7 @@ int mwifiex_bss_set_channel(struct mwifiex_private *priv, if (cfp) { if (adapter->adhoc_11n_enabled) adapter->adhoc_start_band = BAND_A - | BAND_AN; + | BAND_AN; else adapter->adhoc_start_band = BAND_A; } @@ -549,7 +547,7 @@ int mwifiex_bss_set_channel(struct mwifiex_private *priv, if (cfp) { if (adapter->adhoc_11n_enabled) adapter->adhoc_start_band = BAND_A - | BAND_AN; + | BAND_AN; else adapter->adhoc_start_band = BAND_A; } @@ -585,7 +583,7 @@ static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv, } return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL, - action, 0, channel); + action, 0, channel); } /* @@ -631,7 +629,7 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel) goto done; } dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n", - curr_chan, channel); + curr_chan, channel); if (!bss_info.media_connected) { ret = 0; @@ -653,7 +651,8 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel) band = mwifiex_band_to_radio_type(priv->curr_bss_params.band); chan = __ieee80211_get_channel(priv->wdev->wiphy, - ieee80211_channel_to_frequency(channel, band)); + ieee80211_channel_to_frequency(channel, + band)); /* Find the BSS we want using available scan results */ bss = cfg80211_get_bss(priv->wdev->wiphy, chan, bss_info.bssid, @@ -661,7 +660,7 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel) WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); if (!bss) wiphy_warn(priv->wdev->wiphy, "assoc: bss %pM not in scan results\n", - bss_info.bssid); + bss_info.bssid); ret = mwifiex_bss_start(priv, bss, &bss_info.ssid); done: @@ -790,7 +789,9 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, if (!ret) { if (rate->is_rate_auto) rate->rate = mwifiex_index_to_data_rate(priv, - priv->tx_rate, priv->tx_htinfo); + priv->tx_rate, + priv->tx_htinfo + ); else rate->rate = priv->data_rate; } else { @@ -827,16 +828,16 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, if ((dbm < priv->min_tx_power_level) || (dbm > priv->max_tx_power_level)) { dev_err(priv->adapter->dev, "txpower value %d dBm" - " is out of range (%d dBm-%d dBm)\n", - dbm, priv->min_tx_power_level, - priv->max_tx_power_level); + " is out of range (%d dBm-%d dBm)\n", + dbm, priv->min_tx_power_level, + priv->max_tx_power_level); return -1; } } buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL); if (!buf) { dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n", - __func__); + __func__); return -ENOMEM; } @@ -844,13 +845,13 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET); if (!power_cfg->is_power_auto) { txp_cfg->mode = cpu_to_le32(1); - pg_tlv = (struct mwifiex_types_power_group *) (buf + - sizeof(struct host_cmd_ds_txpwr_cfg)); + pg_tlv = (struct mwifiex_types_power_group *) + (buf + sizeof(struct host_cmd_ds_txpwr_cfg)); pg_tlv->type = TLV_TYPE_POWER_GROUP; pg_tlv->length = 4 * sizeof(struct mwifiex_power_group); - pg = (struct mwifiex_power_group *) (buf + - sizeof(struct host_cmd_ds_txpwr_cfg) + - sizeof(struct mwifiex_types_power_group)); + pg = (struct mwifiex_power_group *) + (buf + sizeof(struct host_cmd_ds_txpwr_cfg) + + sizeof(struct mwifiex_types_power_group)); /* Power group for modulation class HR/DSSS */ pg->first_rate_code = 0x00; pg->last_rate_code = 0x03; @@ -913,8 +914,8 @@ int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode) sub_cmd, BITMAP_STA_PS, NULL); if ((!ret) && (sub_cmd == DIS_AUTO_PS)) ret = mwifiex_send_cmd_async(priv, - HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS, - 0, NULL); + HostCmd_CMD_802_11_PS_MODE_ENH, + GET_PS, 0, NULL); return ret; } @@ -938,7 +939,7 @@ static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv, memcpy(priv->wpa_ie, ie_data_ptr, ie_len); priv->wpa_ie_len = (u8) ie_len; dev_dbg(priv->adapter->dev, "cmd: Set Wpa_ie_len=%d IE=%#x\n", - priv->wpa_ie_len, priv->wpa_ie[0]); + priv->wpa_ie_len, priv->wpa_ie[0]); if (priv->wpa_ie[0] == WLAN_EID_WPA) { priv->sec_info.wpa_enabled = true; @@ -979,7 +980,7 @@ static int mwifiex_set_wapi_ie(struct mwifiex_private *priv, memcpy(priv->wapi_ie, ie_data_ptr, ie_len); priv->wapi_ie_len = ie_len; dev_dbg(priv->adapter->dev, "cmd: Set wapi_ie_len=%d IE=%#x\n", - priv->wapi_ie_len, priv->wapi_ie[0]); + priv->wapi_ie_len, priv->wapi_ie[0]); if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY) priv->sec_info.wapi_enabled = true; @@ -1005,8 +1006,8 @@ static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv, { return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL, - HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, - encrypt_key); + HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, + encrypt_key); } /* @@ -1100,9 +1101,9 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv, /* Send the key as PTK to firmware */ encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST; ret = mwifiex_send_cmd_async(priv, - HostCmd_CMD_802_11_KEY_MATERIAL, - HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, - encrypt_key); + HostCmd_CMD_802_11_KEY_MATERIAL, + HostCmd_ACT_GEN_SET, + KEY_INFO_ENABLED, encrypt_key); if (ret) return ret; @@ -1127,14 +1128,14 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv, if (remove_key) ret = mwifiex_send_cmd_sync(priv, - HostCmd_CMD_802_11_KEY_MATERIAL, - HostCmd_ACT_GEN_SET, !(KEY_INFO_ENABLED), - encrypt_key); + HostCmd_CMD_802_11_KEY_MATERIAL, + HostCmd_ACT_GEN_SET, + !KEY_INFO_ENABLED, encrypt_key); else ret = mwifiex_send_cmd_sync(priv, - HostCmd_CMD_802_11_KEY_MATERIAL, - HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, - encrypt_key); + HostCmd_CMD_802_11_KEY_MATERIAL, + HostCmd_ACT_GEN_SET, + KEY_INFO_ENABLED, encrypt_key); return ret; } @@ -1253,7 +1254,7 @@ mwifiex_get_ver_ext(struct mwifiex_private *priv) memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext)); if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT, - HostCmd_ACT_GEN_GET, 0, &ver_ext)) + HostCmd_ACT_GEN_GET, 0, &ver_ext)) return -1; return 0; @@ -1270,7 +1271,7 @@ mwifiex_get_stats_info(struct mwifiex_private *priv, struct mwifiex_ds_get_stats *log) { return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG, - HostCmd_ACT_GEN_GET, 0, log); + HostCmd_ACT_GEN_GET, 0, log); } /* @@ -1410,9 +1411,9 @@ mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr, } pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr; /* Test to see if it is a WPA IE, if not, then it is a gen IE */ - if (((pvendor_ie->element_id == WLAN_EID_WPA) - && (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui)))) - || (pvendor_ie->element_id == WLAN_EID_RSN)) { + if (((pvendor_ie->element_id == WLAN_EID_WPA) && + (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui)))) || + (pvendor_ie->element_id == WLAN_EID_RSN)) { /* IE is a WPA/WPA2 IE so call set_wpa function */ ret = mwifiex_set_wpa_ie_helper(priv, ie_data_ptr, ie_len); @@ -1435,9 +1436,8 @@ mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr, * wps session flag */ pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr; - if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) - && (!memcmp(pvendor_ie->oui, wps_oui, - sizeof(wps_oui)))) { + if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) && + (!memcmp(pvendor_ie->oui, wps_oui, sizeof(wps_oui)))) { priv->wps.session_enable = true; dev_dbg(priv->adapter->dev, "info: WPS Session Enabled.\n"); @@ -1446,7 +1446,7 @@ mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr, /* Append the passed data to the end of the genIeBuffer */ memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr, - ie_len); + ie_len); /* Increment the stored buffer length by the size passed */ priv->gen_ie_buf_len += ie_len; @@ -1490,7 +1490,7 @@ static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv, return -1; } else { memcpy(adapter->arp_filter, gen_ie->ie_data, - gen_ie->len); + gen_ie->len); adapter->arp_filter_size = gen_ie->len; } break; -- GitLab From c65a30f35f938b421ac67c34a9e70b0e49e6019a Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Mar 2012 19:22:42 -0700 Subject: [PATCH 1741/1846] mwifiex: fix checkpatch --strict warnings/errors Part 9 For files sta_rx.c, sta_tx.c, txrx.c, util.c and wmm.c Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sta_rx.c | 12 +-- drivers/net/wireless/mwifiex/sta_tx.c | 22 ++--- drivers/net/wireless/mwifiex/txrx.c | 13 ++- drivers/net/wireless/mwifiex/util.c | 20 ++--- drivers/net/wireless/mwifiex/wmm.c | 122 +++++++++++++------------- 5 files changed, 94 insertions(+), 95 deletions(-) diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c index d7a5d7616f22..750b695aca12 100644 --- a/drivers/net/wireless/mwifiex/sta_rx.c +++ b/drivers/net/wireless/mwifiex/sta_rx.c @@ -43,8 +43,9 @@ int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter, { int ret; struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb); - struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter, - rx_info->bss_num, rx_info->bss_type); + struct mwifiex_private *priv = + mwifiex_get_priv_by_id(adapter, rx_info->bss_num, + rx_info->bss_type); struct rx_packet_hdr *rx_pkt_hdr; struct rxpd *local_rx_pd; int hdr_chop; @@ -125,8 +126,9 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, struct rx_packet_hdr *rx_pkt_hdr; u8 ta[ETH_ALEN]; u16 rx_pkt_type; - struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter, - rx_info->bss_num, rx_info->bss_type); + struct mwifiex_private *priv = + mwifiex_get_priv_by_id(adapter, rx_info->bss_num, + rx_info->bss_type); if (!priv) return -1; @@ -157,7 +159,7 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, skb_trim(skb, local_rx_pd->rx_pkt_length); ieee80211_amsdu_to_8023s(skb, &list, priv->curr_addr, - priv->wdev->iftype, 0, false); + priv->wdev->iftype, 0, false); while (!skb_queue_empty(&list)) { rx_skb = __skb_dequeue(&list); diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c index 94d31a94620a..7af534feb420 100644 --- a/drivers/net/wireless/mwifiex/sta_tx.c +++ b/drivers/net/wireless/mwifiex/sta_tx.c @@ -50,8 +50,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv, u8 pad; if (!skb->len) { - dev_err(adapter->dev, "Tx: bad packet length: %d\n", - skb->len); + dev_err(adapter->dev, "Tx: bad packet length: %d\n", skb->len); tx_info->status_code = -1; return skb->data; } @@ -60,19 +59,20 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv, pad = (4 - (((void *)skb->data - NULL) & 0x3)) % 4; BUG_ON(skb_headroom(skb) < (sizeof(*local_tx_pd) + INTF_HEADER_LEN - + pad)); + + pad)); skb_push(skb, sizeof(*local_tx_pd) + pad); local_tx_pd = (struct txpd *) skb->data; memset(local_tx_pd, 0, sizeof(struct txpd)); local_tx_pd->bss_num = priv->bss_num; local_tx_pd->bss_type = priv->bss_type; - local_tx_pd->tx_pkt_length = cpu_to_le16((u16) (skb->len - - (sizeof(struct txpd) + pad))); + local_tx_pd->tx_pkt_length = cpu_to_le16((u16)(skb->len - + (sizeof(struct txpd) + + pad))); local_tx_pd->priority = (u8) skb->priority; local_tx_pd->pkt_delay_2ms = - mwifiex_wmm_compute_drv_pkt_delay(priv, skb); + mwifiex_wmm_compute_drv_pkt_delay(priv, skb); if (local_tx_pd->priority < ARRAY_SIZE(priv->wmm.user_pri_pkt_tx_ctrl)) @@ -82,7 +82,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv, */ local_tx_pd->tx_control = cpu_to_le32(priv->wmm.user_pri_pkt_tx_ctrl[local_tx_pd-> - priority]); + priority]); if (adapter->pps_uapsd_mode) { if (mwifiex_check_last_packet_indication(priv)) { @@ -160,13 +160,13 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags) case -1: dev_kfree_skb_any(skb); dev_err(adapter->dev, "%s: host_to_card failed: ret=%d\n", - __func__, ret); + __func__, ret); adapter->dbg.num_tx_host_to_card_failure++; break; case 0: dev_kfree_skb_any(skb); dev_dbg(adapter->dev, "data: %s: host_to_card succeeded\n", - __func__); + __func__); adapter->tx_lock_flag = true; break; case -EINPROGRESS: @@ -192,8 +192,8 @@ mwifiex_check_last_packet_indication(struct mwifiex_private *priv) if (mwifiex_wmm_lists_empty(adapter)) ret = true; - if (ret && !adapter->cmd_sent && !adapter->curr_cmd - && !is_command_pending(adapter)) { + if (ret && !adapter->cmd_sent && !adapter->curr_cmd && + !is_command_pending(adapter)) { adapter->delay_null_pkt = false; ret = true; } else { diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c index 9a6eacc9d6f9..d2af8cb98541 100644 --- a/drivers/net/wireless/mwifiex/txrx.c +++ b/drivers/net/wireless/mwifiex/txrx.c @@ -85,8 +85,7 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb, switch (ret) { case -EBUSY: if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && - (adapter->pps_uapsd_mode) && - (adapter->tx_lock_flag)) { + (adapter->pps_uapsd_mode) && (adapter->tx_lock_flag)) { priv->adapter->tx_lock_flag = false; if (local_tx_pd) local_tx_pd->flags = 0; @@ -96,7 +95,7 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb, case -1: adapter->data_sent = false; dev_err(adapter->dev, "mwifiex_write_data_async failed: 0x%X\n", - ret); + ret); adapter->dbg.num_tx_host_to_card_failure++; mwifiex_write_data_complete(adapter, skb, ret); break; @@ -132,7 +131,7 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, tx_info = MWIFIEX_SKB_TXCB(skb); priv = mwifiex_get_priv_by_id(adapter, tx_info->bss_num, - tx_info->bss_type); + tx_info->bss_type); if (!priv) goto done; @@ -151,11 +150,11 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, tpriv = adapter->priv[i]; - if ((GET_BSS_ROLE(tpriv) == MWIFIEX_BSS_ROLE_STA) - && (tpriv->media_connected)) { + if ((GET_BSS_ROLE(tpriv) == MWIFIEX_BSS_ROLE_STA) && + (tpriv->media_connected)) { if (netif_queue_stopped(tpriv->netdev)) mwifiex_wake_up_net_dev_queue(tpriv->netdev, - adapter); + adapter); } } done: diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c index 9c48f37069f7..6b399976d6c8 100644 --- a/drivers/net/wireless/mwifiex/util.c +++ b/drivers/net/wireless/mwifiex/util.c @@ -93,10 +93,10 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv, sizeof(priv->wmm.packets_out)); info->max_tx_buf_size = (u32) adapter->max_tx_buf_size; info->tx_buf_size = (u32) adapter->tx_buf_size; - info->rx_tbl_num = mwifiex_get_rx_reorder_tbl( - priv, info->rx_tbl); - info->tx_tbl_num = mwifiex_get_tx_ba_stream_tbl( - priv, info->tx_tbl); + info->rx_tbl_num = mwifiex_get_rx_reorder_tbl(priv, + info->rx_tbl); + info->tx_tbl_num = mwifiex_get_tx_ba_stream_tbl(priv, + info->tx_tbl); info->ps_mode = adapter->ps_mode; info->ps_state = adapter->ps_state; info->is_deep_sleep = adapter->is_deep_sleep; @@ -105,19 +105,19 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv, info->is_hs_configured = adapter->is_hs_configured; info->hs_activated = adapter->hs_activated; info->num_cmd_host_to_card_failure - = adapter->dbg.num_cmd_host_to_card_failure; + = adapter->dbg.num_cmd_host_to_card_failure; info->num_cmd_sleep_cfm_host_to_card_failure = adapter->dbg.num_cmd_sleep_cfm_host_to_card_failure; info->num_tx_host_to_card_failure - = adapter->dbg.num_tx_host_to_card_failure; + = adapter->dbg.num_tx_host_to_card_failure; info->num_event_deauth = adapter->dbg.num_event_deauth; info->num_event_disassoc = adapter->dbg.num_event_disassoc; info->num_event_link_lost = adapter->dbg.num_event_link_lost; info->num_cmd_deauth = adapter->dbg.num_cmd_deauth; info->num_cmd_assoc_success = - adapter->dbg.num_cmd_assoc_success; + adapter->dbg.num_cmd_assoc_success; info->num_cmd_assoc_failure = - adapter->dbg.num_cmd_assoc_failure; + adapter->dbg.num_cmd_assoc_failure; info->num_tx_timeout = adapter->dbg.num_tx_timeout; info->num_cmd_timeout = adapter->dbg.num_cmd_timeout; info->timeout_cmd_id = adapter->dbg.timeout_cmd_id; @@ -160,7 +160,7 @@ int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb) rx_info = MWIFIEX_SKB_RXCB(skb); priv = mwifiex_get_priv_by_id(adapter, rx_info->bss_num, - rx_info->bss_type); + rx_info->bss_type); if (!priv) return -1; @@ -191,7 +191,7 @@ int mwifiex_complete_cmd(struct mwifiex_adapter *adapter, { atomic_dec(&adapter->cmd_pending); dev_dbg(adapter->dev, "cmd completed: status=%d\n", - adapter->cmd_wait_q.status); + adapter->cmd_wait_q.status); *(cmd_node->condition) = true; diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index 6f0cc210f79a..5a7316c6f125 100644 --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c @@ -87,15 +87,15 @@ mwifiex_wmm_ac_debug_print(const struct ieee_types_wmm_ac_parameters *ac_param) const char *ac_str[] = { "BK", "BE", "VI", "VO" }; pr_debug("info: WMM AC_%s: ACI=%d, ACM=%d, Aifsn=%d, " - "EcwMin=%d, EcwMax=%d, TxopLimit=%d\n", - ac_str[wmm_aci_to_qidx_map[(ac_param->aci_aifsn_bitmap - & MWIFIEX_ACI) >> 5]], - (ac_param->aci_aifsn_bitmap & MWIFIEX_ACI) >> 5, - (ac_param->aci_aifsn_bitmap & MWIFIEX_ACM) >> 4, - ac_param->aci_aifsn_bitmap & MWIFIEX_AIFSN, - ac_param->ecw_bitmap & MWIFIEX_ECW_MIN, - (ac_param->ecw_bitmap & MWIFIEX_ECW_MAX) >> 4, - le16_to_cpu(ac_param->tx_op_limit)); + "EcwMin=%d, EcwMax=%d, TxopLimit=%d\n", + ac_str[wmm_aci_to_qidx_map[(ac_param->aci_aifsn_bitmap + & MWIFIEX_ACI) >> 5]], + (ac_param->aci_aifsn_bitmap & MWIFIEX_ACI) >> 5, + (ac_param->aci_aifsn_bitmap & MWIFIEX_ACM) >> 4, + ac_param->aci_aifsn_bitmap & MWIFIEX_AIFSN, + ac_param->ecw_bitmap & MWIFIEX_ECW_MIN, + (ac_param->ecw_bitmap & MWIFIEX_ECW_MAX) >> 4, + le16_to_cpu(ac_param->tx_op_limit)); } /* @@ -112,7 +112,7 @@ mwifiex_wmm_allocate_ralist_node(struct mwifiex_adapter *adapter, u8 *ra) if (!ra_list) { dev_err(adapter->dev, "%s: failed to alloc ra_list\n", - __func__); + __func__); return NULL; } INIT_LIST_HEAD(&ra_list->list); @@ -154,7 +154,7 @@ mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra) ra_list, ra_list->is_11n_enabled); list_add_tail(&ra_list->list, - &priv->wmm.tid_tbl_ptr[i].ra_list); + &priv->wmm.tid_tbl_ptr[i].ra_list); if (!priv->wmm.tid_tbl_ptr[i].ra_list_curr) priv->wmm.tid_tbl_ptr[i].ra_list_curr = ra_list; @@ -217,22 +217,19 @@ mwifiex_wmm_setup_queue_priorities(struct mwifiex_private *priv, wmm_ie->reserved); for (num_ac = 0; num_ac < ARRAY_SIZE(wmm_ie->ac_params); num_ac++) { - cw_min = (1 << (wmm_ie->ac_params[num_ac].ecw_bitmap & - MWIFIEX_ECW_MIN)) - 1; - avg_back_off = (cw_min >> 1) + - (wmm_ie->ac_params[num_ac].aci_aifsn_bitmap & - MWIFIEX_AIFSN); - - ac_idx = wmm_aci_to_qidx_map[(wmm_ie->ac_params[num_ac]. - aci_aifsn_bitmap & - MWIFIEX_ACI) >> 5]; + u8 ecw = wmm_ie->ac_params[num_ac].ecw_bitmap; + u8 aci_aifsn = wmm_ie->ac_params[num_ac].aci_aifsn_bitmap; + cw_min = (1 << (ecw & MWIFIEX_ECW_MIN)) - 1; + avg_back_off = (cw_min >> 1) + (aci_aifsn & MWIFIEX_AIFSN); + + ac_idx = wmm_aci_to_qidx_map[(aci_aifsn & MWIFIEX_ACI) >> 5]; priv->wmm.queue_priority[ac_idx] = ac_idx; tmp[ac_idx] = avg_back_off; - dev_dbg(priv->adapter->dev, "info: WMM: CWmax=%d CWmin=%d Avg Back-off=%d\n", - (1 << ((wmm_ie->ac_params[num_ac].ecw_bitmap & - MWIFIEX_ECW_MAX) >> 4)) - 1, - cw_min, avg_back_off); + dev_dbg(priv->adapter->dev, + "info: WMM: CWmax=%d CWmin=%d Avg Back-off=%d\n", + (1 << ((ecw & MWIFIEX_ECW_MAX) >> 4)) - 1, + cw_min, avg_back_off); mwifiex_wmm_ac_debug_print(&wmm_ie->ac_params[num_ac]); } @@ -312,13 +309,14 @@ mwifiex_wmm_setup_ac_downgrade(struct mwifiex_private *priv) /* WMM is not enabled, default priorities */ for (ac_val = WMM_AC_BK; ac_val <= WMM_AC_VO; ac_val++) priv->wmm.ac_down_graded_vals[ac_val] = - (enum mwifiex_wmm_ac_e) ac_val; + (enum mwifiex_wmm_ac_e) ac_val; } else { for (ac_val = WMM_AC_BK; ac_val <= WMM_AC_VO; ac_val++) { priv->wmm.ac_down_graded_vals[ac_val] = mwifiex_wmm_eval_downgrade_ac(priv, (enum mwifiex_wmm_ac_e) ac_val); - dev_dbg(priv->adapter->dev, "info: WMM: AC PRIO %d maps to %d\n", + dev_dbg(priv->adapter->dev, + "info: WMM: AC PRIO %d maps to %d\n", ac_val, priv->wmm.ac_down_graded_vals[ac_val]); } } @@ -394,13 +392,13 @@ mwifiex_wmm_init(struct mwifiex_adapter *adapter) } priv->aggr_prio_tbl[6].amsdu - = priv->aggr_prio_tbl[6].ampdu_ap - = priv->aggr_prio_tbl[6].ampdu_user - = BA_STREAM_NOT_ALLOWED; + = priv->aggr_prio_tbl[6].ampdu_ap + = priv->aggr_prio_tbl[6].ampdu_user + = BA_STREAM_NOT_ALLOWED; priv->aggr_prio_tbl[7].amsdu = priv->aggr_prio_tbl[7].ampdu_ap - = priv->aggr_prio_tbl[7].ampdu_user - = BA_STREAM_NOT_ALLOWED; + = priv->aggr_prio_tbl[7].ampdu_user + = BA_STREAM_NOT_ALLOWED; priv->add_ba_param.timeout = MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT; priv->add_ba_param.tx_win_size = MWIFIEX_AMPDU_DEF_TXWINSIZE; @@ -472,7 +470,7 @@ static void mwifiex_wmm_cleanup_queues(struct mwifiex_private *priv) for (i = 0; i < MAX_NUM_TID; i++) mwifiex_wmm_del_pkts_in_ralist(priv, &priv->wmm.tid_tbl_ptr[i]. - ra_list); + ra_list); atomic_set(&priv->wmm.tx_pkts_queued, 0); atomic_set(&priv->wmm.highest_queued_prio, HIGH_PRIO_TID); @@ -488,9 +486,10 @@ static void mwifiex_wmm_delete_all_ralist(struct mwifiex_private *priv) for (i = 0; i < MAX_NUM_TID; ++i) { dev_dbg(priv->adapter->dev, - "info: ra_list: freeing buf for tid %d\n", i); + "info: ra_list: freeing buf for tid %d\n", i); list_for_each_entry_safe(ra_list, tmp_node, - &priv->wmm.tid_tbl_ptr[i].ra_list, list) { + &priv->wmm.tid_tbl_ptr[i].ra_list, + list) { list_del(&ra_list->list); kfree(ra_list); } @@ -652,7 +651,7 @@ mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv, if (atomic_read(&priv->wmm.highest_queued_prio) < tos_to_tid_inv[tid_down]) atomic_set(&priv->wmm.highest_queued_prio, - tos_to_tid_inv[tid_down]); + tos_to_tid_inv[tid_down]); spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); } @@ -681,7 +680,7 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv, struct mwifiex_wmm_ac_status *ac_status; dev_dbg(priv->adapter->dev, "info: WMM: WMM_GET_STATUS cmdresp received: %d\n", - resp_len); + resp_len); while ((resp_len >= sizeof(tlv_hdr->header)) && valid) { tlv_hdr = (struct mwifiex_ie_types_data *) curr; @@ -695,15 +694,15 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv, dev_dbg(priv->adapter->dev, "info: CMD_RESP: WMM_GET_STATUS:" " QSTATUS TLV: %d, %d, %d\n", - tlv_wmm_qstatus->queue_index, - tlv_wmm_qstatus->flow_required, - tlv_wmm_qstatus->disabled); + tlv_wmm_qstatus->queue_index, + tlv_wmm_qstatus->flow_required, + tlv_wmm_qstatus->disabled); ac_status = &priv->wmm.ac_status[tlv_wmm_qstatus-> queue_index]; ac_status->disabled = tlv_wmm_qstatus->disabled; ac_status->flow_required = - tlv_wmm_qstatus->flow_required; + tlv_wmm_qstatus->flow_required; ac_status->flow_created = tlv_wmm_qstatus->flow_created; break; @@ -772,29 +771,27 @@ mwifiex_wmm_process_association_req(struct mwifiex_private *priv, if (!wmm_ie) return 0; - dev_dbg(priv->adapter->dev, "info: WMM: process assoc req:" - "bss->wmmIe=0x%x\n", - wmm_ie->vend_hdr.element_id); + dev_dbg(priv->adapter->dev, + "info: WMM: process assoc req: bss->wmm_ie=%#x\n", + wmm_ie->vend_hdr.element_id); - if ((priv->wmm_required - || (ht_cap && (priv->adapter->config_bands & BAND_GN - || priv->adapter->config_bands & BAND_AN)) - ) - && wmm_ie->vend_hdr.element_id == WLAN_EID_VENDOR_SPECIFIC) { + if ((priv->wmm_required || + (ht_cap && (priv->adapter->config_bands & BAND_GN || + priv->adapter->config_bands & BAND_AN))) && + wmm_ie->vend_hdr.element_id == WLAN_EID_VENDOR_SPECIFIC) { wmm_tlv = (struct mwifiex_ie_types_wmm_param_set *) *assoc_buf; wmm_tlv->header.type = cpu_to_le16((u16) wmm_info_ie[0]); wmm_tlv->header.len = cpu_to_le16((u16) wmm_info_ie[1]); memcpy(wmm_tlv->wmm_ie, &wmm_info_ie[2], - le16_to_cpu(wmm_tlv->header.len)); + le16_to_cpu(wmm_tlv->header.len)); if (wmm_ie->qos_info_bitmap & IEEE80211_WMM_IE_AP_QOSINFO_UAPSD) memcpy((u8 *) (wmm_tlv->wmm_ie - + le16_to_cpu(wmm_tlv->header.len) - - sizeof(priv->wmm_qosinfo)), - &priv->wmm_qosinfo, - sizeof(priv->wmm_qosinfo)); + + le16_to_cpu(wmm_tlv->header.len) + - sizeof(priv->wmm_qosinfo)), + &priv->wmm_qosinfo, sizeof(priv->wmm_qosinfo)); ret_len = sizeof(wmm_tlv->header) - + le16_to_cpu(wmm_tlv->header.len); + + le16_to_cpu(wmm_tlv->header.len); *assoc_buf += ret_len; } @@ -813,7 +810,7 @@ mwifiex_wmm_process_association_req(struct mwifiex_private *priv, */ u8 mwifiex_wmm_compute_drv_pkt_delay(struct mwifiex_private *priv, - const struct sk_buff *skb) + const struct sk_buff *skb) { u8 ret_val; struct timeval out_tstamp, in_tstamp; @@ -857,11 +854,11 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter, for (j = adapter->priv_num - 1; j >= 0; --j) { spin_lock_irqsave(&adapter->bss_prio_tbl[j].bss_prio_lock, - flags); + flags); is_list_empty = list_empty(&adapter->bss_prio_tbl[j] - .bss_prio_head); + .bss_prio_head); spin_unlock_irqrestore(&adapter->bss_prio_tbl[j].bss_prio_lock, - flags); + flags); if (is_list_empty) continue; @@ -1210,10 +1207,11 @@ mwifiex_dequeue_tx_packet(struct mwifiex_adapter *adapter) return 0; } - if (!ptr->is_11n_enabled || mwifiex_is_ba_stream_setup(priv, ptr, tid) - || ((priv->sec_info.wpa_enabled - || priv->sec_info.wpa2_enabled) && !priv->wpa_is_gtk_set) - ) { + if (!ptr->is_11n_enabled || + mwifiex_is_ba_stream_setup(priv, ptr, tid) || + ((priv->sec_info.wpa_enabled || + priv->sec_info.wpa2_enabled) && + !priv->wpa_is_gtk_set)) { mwifiex_send_single_packet(priv, ptr, ptr_index, flags); /* ra_list_spinlock has been freed in mwifiex_send_single_packet() */ -- GitLab From b093863edd20b64fa444b770a8701ddcbe9faea1 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Tue, 13 Mar 2012 19:36:49 -0700 Subject: [PATCH 1742/1846] mwifiex: correction in structure name passed to sizeof() "hscfg" is declared as struct mwifiex_ds_hs_cfg. Use same structure name for calculating it's size. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sta_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 64e0b1010850..d7b11defafe0 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -425,7 +425,7 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter) adapter->hs_activate_wait_q_woken = false; - memset(&hscfg, 0, sizeof(struct mwifiex_hs_config_param)); + memset(&hscfg, 0, sizeof(struct mwifiex_ds_hs_cfg)); hscfg.is_invoke_hostcmd = true; if (mwifiex_set_hs_params(mwifiex_get_priv(adapter, -- GitLab From 9d4f09b80fb69985eca86aaf4df195b80e3d02a8 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Wed, 14 Mar 2012 08:56:47 +0100 Subject: [PATCH 1743/1846] rt2x00: Set IEEE80211_HW_REPORTS_TX_ACK_STATUS in rt2800 rt2800 already reports the tx ack status of each frame back to mac80211. Advertise this by setting IEEE80211_HW_REPORTS_TX_ACK_STATUS for rt2800. This allows some mac80211 features like frame loss notifications to work with rt2800. Signed-off-by: Helmut Schaa Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 474b5b9e6238..6c0a12ea6a15 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -4500,7 +4500,9 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_PS_NULLFUNC_STACK | - IEEE80211_HW_AMPDU_AGGREGATION; + IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_REPORTS_TX_ACK_STATUS; + /* * Don't set IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING for USB devices * unless we are capable of sending the buffered frames out after the -- GitLab From bf106e14735d5e82e995c5c03bf07bce54e5d530 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 14 Mar 2012 14:40:20 +0530 Subject: [PATCH 1744/1846] ath9k: Remove unnecessary initialization There is no need to mask out SWBA/BMISS from the interrupt mask in start(). Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 4a9901090811..db38a4e5a6e3 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1049,9 +1049,6 @@ static int ath9k_start(struct ieee80211_hw *hw) sc->sc_flags &= ~SC_OP_INVALID; sc->sc_ah->is_monitoring = false; - /* Disable BMISS interrupt when we're not associated */ - ah->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS); - if (!ath_complete_reset(sc, false)) { r = -EIO; spin_unlock_bh(&sc->sc_pcu_lock); -- GitLab From 62450b88032287db805ba54de142e58052a98090 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 14 Mar 2012 14:40:31 +0530 Subject: [PATCH 1745/1846] ath9k: Remove unused variables Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 2 -- drivers/net/wireless/ath/ath9k/main.c | 4 ---- 2 files changed, 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 3d8e51cd5d8f..fa5eb3080e24 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -624,8 +624,6 @@ struct ath_softc { struct ieee80211_hw *hw; struct device *dev; - int chan_idx; - int chan_is_ht; struct survey_info *cur_survey; struct survey_info survey[ATH9K_NUM_CHANNELS]; diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index db38a4e5a6e3..fe1d7961eefd 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -995,12 +995,8 @@ static int ath9k_start(struct ieee80211_hw *hw) curchan->center_freq); ath9k_ps_wakeup(sc); - mutex_lock(&sc->mutex); - /* setup initial channel */ - sc->chan_idx = curchan->hw_value; - init_channel = ath9k_cmn_get_curchannel(hw, ah); /* Reset SERDES registers */ -- GitLab From bcf6f96e192d71864685ba7253c94c2002615875 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 14 Mar 2012 14:40:38 +0530 Subject: [PATCH 1746/1846] ath9k: Remove 'other' VIF count It is not needed and will not be used anyway since unsupported interfaces are not allowed to be created. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 1 - drivers/net/wireless/ath/ath9k/debug.c | 4 ++-- drivers/net/wireless/ath/ath9k/main.c | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index fa5eb3080e24..419bf4e4dc73 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -617,7 +617,6 @@ struct ath9k_vif_iter_data { int nstations; /* number of station vifs */ int nwds; /* number of WDS vifs */ int nadhocs; /* number of adhoc vifs */ - int nothers; /* number of vifs not specified above. */ }; struct ath_softc { diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index c2edf688da49..35d1c8e91d1c 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -738,9 +738,9 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf, len += snprintf(buf + len, sizeof(buf) - len, "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" - " ADHOC: %i OTHER: %i TOTAL: %hi BEACON-VIF: %hi\n", + " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", iter_data.naps, iter_data.nstations, iter_data.nmeshes, - iter_data.nwds, iter_data.nadhocs, iter_data.nothers, + iter_data.nwds, iter_data.nadhocs, sc->nvifs, sc->nbcnvifs); if (len > sizeof(buf)) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index fe1d7961eefd..77c61bcd34ea 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1272,7 +1272,6 @@ static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) iter_data->nwds++; break; default: - iter_data->nothers++; break; } } -- GitLab From caed6579c2f9756d3f5a95e8186fa4c04d64cae2 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 14 Mar 2012 14:40:46 +0530 Subject: [PATCH 1747/1846] ath9k_hw: Cleanup FastChannelChange The logic to determine whether to use FCC is a bit convoluted. Use a small helper function to decide whether FCC is to be used. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 104 ++++++++++++++++++-------- drivers/net/wireless/ath/ath9k/hw.h | 2 +- drivers/net/wireless/ath/ath9k/main.c | 4 - 3 files changed, 74 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 02cc1ce3dd6a..780ecd8aff6e 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1521,17 +1521,81 @@ bool ath9k_hw_check_alive(struct ath_hw *ah) } EXPORT_SYMBOL(ath9k_hw_check_alive); +/* + * Fast channel change: + * (Change synthesizer based on channel freq without resetting chip) + * + * Don't do FCC when + * - Flag is not set + * - Chip is just coming out of full sleep + * - Channel to be set is same as current channel + * - Channel flags are different, (eg.,moving from 2GHz to 5GHz channel) + */ +static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan) +{ + struct ath_common *common = ath9k_hw_common(ah); + int ret; + + if (AR_SREV_9280(ah) && common->bus_ops->ath_bus_type == ATH_PCI) + goto fail; + + if (ah->chip_fullsleep) + goto fail; + + if (!ah->curchan) + goto fail; + + if (chan->channel == ah->curchan->channel) + goto fail; + + if ((chan->channelFlags & CHANNEL_ALL) != + (ah->curchan->channelFlags & CHANNEL_ALL)) + goto fail; + + if (!ath9k_hw_check_alive(ah)) + goto fail; + + /* + * For AR9462, make sure that calibration data for + * re-using are present. + */ + if (AR_SREV_9462(ah) && (!ah->caldata || + !ah->caldata->done_txiqcal_once || + !ah->caldata->done_txclcal_once || + !ah->caldata->rtt_hist.num_readings)) + goto fail; + + ath_dbg(common, RESET, "FastChannelChange for %d -> %d\n", + ah->curchan->channel, chan->channel); + + ret = ath9k_hw_channel_change(ah, chan); + if (!ret) + goto fail; + + ath9k_hw_loadnf(ah, ah->curchan); + ath9k_hw_start_nfcal(ah, true); + + if ((ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && ar9003_mci_is_ready(ah)) + ar9003_mci_2g5g_switch(ah, true); + + if (AR_SREV_9271(ah)) + ar9002_hw_load_ani_reg(ah, chan); + + return 0; +fail: + return -EINVAL; +} + int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, - struct ath9k_hw_cal_data *caldata, bool bChannelChange) + struct ath9k_hw_cal_data *caldata, bool fastcc) { struct ath_common *common = ath9k_hw_common(ah); u32 saveLedState; - struct ath9k_channel *curchan = ah->curchan; u32 saveDefAntenna; u32 macStaId1; u64 tsf = 0; int i, r; - bool allow_fbs = false, start_mci_reset = false; + bool start_mci_reset = false; bool mci = !!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI); bool save_fullsleep = ah->chip_fullsleep; @@ -1544,8 +1608,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) return -EIO; - if (curchan && !ah->chip_fullsleep) - ath9k_hw_getnf(ah, curchan); + if (ah->curchan && !ah->chip_fullsleep) + ath9k_hw_getnf(ah, ah->curchan); ah->caldata = caldata; if (caldata && @@ -1558,32 +1622,10 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, } ah->noise = ath9k_hw_getchan_noise(ah, chan); - if (AR_SREV_9280(ah) && common->bus_ops->ath_bus_type == ATH_PCI) - bChannelChange = false; - - if (caldata && - caldata->done_txiqcal_once && - caldata->done_txclcal_once && - caldata->rtt_hist.num_readings) - allow_fbs = true; - - if (bChannelChange && - (ah->chip_fullsleep != true) && - (ah->curchan != NULL) && - (chan->channel != ah->curchan->channel) && - (allow_fbs || - ((chan->channelFlags & CHANNEL_ALL) == - (ah->curchan->channelFlags & CHANNEL_ALL)))) { - if (ath9k_hw_channel_change(ah, chan)) { - ath9k_hw_loadnf(ah, ah->curchan); - ath9k_hw_start_nfcal(ah, true); - if (mci && ar9003_mci_is_ready(ah)) - ar9003_mci_2g5g_switch(ah, true); - - if (AR_SREV_9271(ah)) - ar9002_hw_load_ani_reg(ah, chan); - return 0; - } + if (fastcc) { + r = ath9k_hw_do_fastcc(ah, chan); + if (!r) + return r; } if (mci) diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 1707137e0a30..23c8dfae29f7 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -924,7 +924,7 @@ const char *ath9k_hw_probe(u16 vendorid, u16 devid); void ath9k_hw_deinit(struct ath_hw *ah); int ath9k_hw_init(struct ath_hw *ah); int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, - struct ath9k_hw_cal_data *caldata, bool bChannelChange); + struct ath9k_hw_cal_data *caldata, bool fastcc); int ath9k_hw_fill_cap_info(struct ath_hw *ah); u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 77c61bcd34ea..a07565c730b7 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -334,10 +334,6 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan, hchan = ah->curchan; } - if (fastcc && (ah->chip_fullsleep || - !ath9k_hw_check_alive(ah))) - fastcc = false; - if (!ath_prepare_reset(sc, retry_tx, flush)) fastcc = false; -- GitLab From 3d4e20f2d1e720c63887aee6a985e7870baf4ba1 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 14 Mar 2012 14:40:58 +0530 Subject: [PATCH 1748/1846] ath9k: Remove aggregation flags SC_OP_TXAGGR and SC_OP_RXAGGR are not really needed. The HT capabilities of the station and HW can be used instead. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 24 +++++++++++------------- drivers/net/wireless/ath/ath9k/init.c | 9 +-------- drivers/net/wireless/ath/ath9k/main.c | 12 ++++-------- drivers/net/wireless/ath/ath9k/rc.c | 9 ++++----- drivers/net/wireless/ath/ath9k/xmit.c | 21 +++++++++------------ 5 files changed, 29 insertions(+), 46 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 419bf4e4dc73..5ecec83117d6 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -583,19 +583,17 @@ struct ath_ant_comb { #define SC_OP_INVALID BIT(0) #define SC_OP_BEACONS BIT(1) -#define SC_OP_RXAGGR BIT(2) -#define SC_OP_TXAGGR BIT(3) -#define SC_OP_OFFCHANNEL BIT(4) -#define SC_OP_PREAMBLE_SHORT BIT(5) -#define SC_OP_PROTECT_ENABLE BIT(6) -#define SC_OP_RXFLUSH BIT(7) -#define SC_OP_LED_ASSOCIATED BIT(8) -#define SC_OP_LED_ON BIT(9) -#define SC_OP_TSF_RESET BIT(11) -#define SC_OP_BT_PRIORITY_DETECTED BIT(12) -#define SC_OP_BT_SCAN BIT(13) -#define SC_OP_ANI_RUN BIT(14) -#define SC_OP_PRIM_STA_VIF BIT(15) +#define SC_OP_OFFCHANNEL BIT(2) +#define SC_OP_PREAMBLE_SHORT BIT(3) +#define SC_OP_PROTECT_ENABLE BIT(4) +#define SC_OP_RXFLUSH BIT(5) +#define SC_OP_LED_ASSOCIATED BIT(6) +#define SC_OP_LED_ON BIT(7) +#define SC_OP_TSF_RESET BIT(8) +#define SC_OP_BT_PRIORITY_DETECTED BIT(9) +#define SC_OP_BT_SCAN BIT(10) +#define SC_OP_ANI_RUN BIT(11) +#define SC_OP_PRIM_STA_VIF BIT(12) /* Powersave flags */ #define PS_WAIT_FOR_BEACON BIT(0) diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 944e9b518f19..2708d1fc2c10 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -484,19 +484,12 @@ static void ath9k_init_misc(struct ath_softc *sc) { struct ath_common *common = ath9k_hw_common(sc->sc_ah); int i = 0; + setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc); sc->config.txpowlimit = ATH_TXPOWER_MAX; - - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { - sc->sc_flags |= SC_OP_TXAGGR; - sc->sc_flags |= SC_OP_RXAGGR; - } - sc->rx.defant = ath9k_hw_getdefantenna(sc->sc_ah); - memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); - sc->beacon.slottime = ATH9K_SLOT_TIME_9; for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index a07565c730b7..3f00daa0ea06 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -639,7 +639,8 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, #endif an->sta = sta; an->vif = vif; - if (sc->sc_flags & SC_OP_TXAGGR) { + + if (sta->ht_cap.ht_supported) { ath_tx_node_init(sc, an); an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + sta->ht_cap.ampdu_factor); @@ -658,7 +659,7 @@ static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta) an->sta = NULL; #endif - if (sc->sc_flags & SC_OP_TXAGGR) + if (sta->ht_cap.ht_supported) ath_tx_node_cleanup(sc, an); } @@ -1751,7 +1752,7 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw, struct ath_softc *sc = hw->priv; struct ath_node *an = (struct ath_node *) sta->drv_priv; - if (!(sc->sc_flags & SC_OP_TXAGGR)) + if (!sta->ht_cap.ht_supported) return; switch (cmd) { @@ -2119,15 +2120,10 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw, switch (action) { case IEEE80211_AMPDU_RX_START: - if (!(sc->sc_flags & SC_OP_RXAGGR)) - ret = -ENOTSUPP; break; case IEEE80211_AMPDU_RX_STOP: break; case IEEE80211_AMPDU_TX_START: - if (!(sc->sc_flags & SC_OP_TXAGGR)) - return -EOPNOTSUPP; - ath9k_ps_wakeup(sc); ret = ath_tx_aggr_start(sc, sta, tid, ssn); if (!ret) diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index 6407af22f7b9..f26e9847bb2e 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -1298,12 +1298,13 @@ static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta, return caps; } -static bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, +static bool ath_tx_aggr_check(struct ath_softc *sc, struct ieee80211_sta *sta, u8 tidno) { + struct ath_node *an = (struct ath_node *)sta->drv_priv; struct ath_atx_tid *txtid; - if (!(sc->sc_flags & SC_OP_TXAGGR)) + if (!sta->ht_cap.ht_supported) return false; txtid = ATH_AN_2_TID(an, tidno); @@ -1374,13 +1375,11 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, if (ieee80211_is_data_qos(fc) && skb_get_queue_mapping(skb) != IEEE80211_AC_VO) { u8 *qc, tid; - struct ath_node *an; qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; - an = (struct ath_node *)sta->drv_priv; - if(ath_tx_aggr_check(sc, an, tid)) + if(ath_tx_aggr_check(sc, sta, tid)) ieee80211_start_tx_ba_session(sta, tid, 0); } } diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 9f785015a7dc..d2c635d84fbc 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1290,14 +1290,11 @@ void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid an = (struct ath_node *)sta->drv_priv; - if (sc->sc_flags & SC_OP_TXAGGR) { - txtid = ATH_AN_2_TID(an, tid); - txtid->baw_size = - IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; - txtid->state |= AGGR_ADDBA_COMPLETE; - txtid->state &= ~AGGR_ADDBA_PROGRESS; - ath_tx_resume_tid(sc, txtid); - } + txtid = ATH_AN_2_TID(an, tid); + txtid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; + txtid->state |= AGGR_ADDBA_COMPLETE; + txtid->state &= ~AGGR_ADDBA_PROGRESS; + ath_tx_resume_tid(sc, txtid); } /********************/ @@ -1523,7 +1520,7 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx) ath_drain_txq_list(sc, txq, &txq->axq_q, retry_tx); /* flush any pending frames if aggregation is enabled */ - if ((sc->sc_flags & SC_OP_TXAGGR) && !retry_tx) + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !retry_tx) ath_txq_drain_pending_buffers(sc, txq); ath_txq_unlock_complete(sc, txq); @@ -1871,7 +1868,7 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb, struct ath_buf *bf; u8 tidno; - if ((sc->sc_flags & SC_OP_TXAGGR) && txctl->an && + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && txctl->an && ieee80211_is_data_qos(hdr->frame_control)) { tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK; @@ -2141,7 +2138,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, } else ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok, true); - if (sc->sc_flags & SC_OP_TXAGGR) + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) ath_txq_schedule(sc, txq); } @@ -2166,7 +2163,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) if (list_empty(&txq->axq_q)) { txq->axq_link = NULL; - if (sc->sc_flags & SC_OP_TXAGGR) + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) ath_txq_schedule(sc, txq); break; } -- GitLab From d47a61aa228709fe1704e18a2f444661c10b81c0 Mon Sep 17 00:00:00 2001 From: Sujith Manoharan Date: Wed, 14 Mar 2012 14:41:05 +0530 Subject: [PATCH 1749/1846] ath9k: Fix multi-VIF BSS handling mac80211 provides short preamble information and ERP protection information on a per-BSS basis, which can be used. Remove flags stored in the driver, which was incorrect since they were being used in a global manner. Signed-off-by: Sujith Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 16 ++++++---------- drivers/net/wireless/ath/ath9k/beacon.c | 6 +++--- drivers/net/wireless/ath/ath9k/main.c | 19 ------------------- drivers/net/wireless/ath/ath9k/rc.c | 3 ++- drivers/net/wireless/ath/ath9k/xmit.c | 4 +++- 5 files changed, 14 insertions(+), 34 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 5ecec83117d6..8c84049682ab 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -584,16 +584,12 @@ struct ath_ant_comb { #define SC_OP_INVALID BIT(0) #define SC_OP_BEACONS BIT(1) #define SC_OP_OFFCHANNEL BIT(2) -#define SC_OP_PREAMBLE_SHORT BIT(3) -#define SC_OP_PROTECT_ENABLE BIT(4) -#define SC_OP_RXFLUSH BIT(5) -#define SC_OP_LED_ASSOCIATED BIT(6) -#define SC_OP_LED_ON BIT(7) -#define SC_OP_TSF_RESET BIT(8) -#define SC_OP_BT_PRIORITY_DETECTED BIT(9) -#define SC_OP_BT_SCAN BIT(10) -#define SC_OP_ANI_RUN BIT(11) -#define SC_OP_PRIM_STA_VIF BIT(12) +#define SC_OP_RXFLUSH BIT(3) +#define SC_OP_TSF_RESET BIT(4) +#define SC_OP_BT_PRIORITY_DETECTED BIT(5) +#define SC_OP_BT_SCAN BIT(6) +#define SC_OP_ANI_RUN BIT(7) +#define SC_OP_PRIM_STA_VIF BIT(8) /* Powersave flags */ #define PS_WAIT_FOR_BEACON BIT(0) diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 43882f9e25c4..626418222c85 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c @@ -67,7 +67,7 @@ int ath_beaconq_config(struct ath_softc *sc) * up rate codes, and channel flags. Beacons are always sent out at the * lowest rate, and are not retried. */ -static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp, +static void ath_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif, struct ath_buf *bf, int rateidx) { struct sk_buff *skb = bf->bf_mpdu; @@ -82,7 +82,7 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp, sband = &sc->sbands[common->hw->conf.channel->band]; rate = sband->bitrates[rateidx].hw_value; - if (sc->sc_flags & SC_OP_PREAMBLE_SHORT) + if (vif->bss_conf.use_short_preamble) rate |= sband->bitrates[rateidx].hw_value_short; memset(&info, 0, sizeof(info)); @@ -209,7 +209,7 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw, } } - ath_beacon_setup(sc, avp, bf, info->control.rates[0].idx); + ath_beacon_setup(sc, vif, bf, info->control.rates[0].idx); while (skb) { ath_tx_cabq(hw, skb); diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 3f00daa0ea06..38794850f005 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -2044,25 +2044,6 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, ath_beacon_config(sc, vif); } - if (changed & BSS_CHANGED_ERP_PREAMBLE) { - ath_dbg(common, CONFIG, "BSS Changed PREAMBLE %d\n", - bss_conf->use_short_preamble); - if (bss_conf->use_short_preamble) - sc->sc_flags |= SC_OP_PREAMBLE_SHORT; - else - sc->sc_flags &= ~SC_OP_PREAMBLE_SHORT; - } - - if (changed & BSS_CHANGED_ERP_CTS_PROT) { - ath_dbg(common, CONFIG, "BSS Changed CTS PROT %d\n", - bss_conf->use_cts_prot); - if (bss_conf->use_cts_prot && - hw->conf.channel->band != IEEE80211_BAND_5GHZ) - sc->sc_flags |= SC_OP_PROTECT_ENABLE; - else - sc->sc_flags &= ~SC_OP_PROTECT_ENABLE; - } - mutex_unlock(&sc->mutex); ath9k_ps_restore(sc); } diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index f26e9847bb2e..4f848493fece 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -748,7 +748,8 @@ static void ath_rc_rate_set_rtscts(struct ath_softc *sc, * If 802.11g protection is enabled, determine whether to use RTS/CTS or * just CTS. Note that this is only done for OFDM/HT unicast frames. */ - if ((sc->sc_flags & SC_OP_PROTECT_ENABLE) && + if ((tx_info->control.vif && + tx_info->control.vif->bss_conf.use_cts_prot) && (rate_table->info[rix].phy == WLAN_RC_PHY_OFDM || WLAN_RC_PHY_HT(rate_table->info[rix].phy))) { rates[0].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT; diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index d2c635d84fbc..5faec1e04d65 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -955,7 +955,9 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, */ rate = ieee80211_get_rts_cts_rate(sc->hw, tx_info); info->rtscts_rate = rate->hw_value; - if (sc->sc_flags & SC_OP_PREAMBLE_SHORT) + + if (tx_info->control.vif && + tx_info->control.vif->bss_conf.use_short_preamble) info->rtscts_rate |= rate->hw_value_short; for (i = 0; i < 4; i++) { -- GitLab From 627fdaf763f80a4db41289c4af7dc279dcba7363 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 14 Mar 2012 11:16:17 +0100 Subject: [PATCH 1750/1846] rt2x00: rt2800usb: move additional txdone into new function Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 2c11137c1eb0..8e1855a478be 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -528,15 +528,11 @@ static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev) } } -static void rt2800usb_work_txdone(struct work_struct *work) +static void rt2800usb_txdone_nostatus(struct rt2x00_dev *rt2x00dev) { - struct rt2x00_dev *rt2x00dev = - container_of(work, struct rt2x00_dev, txdone_work); struct data_queue *queue; struct queue_entry *entry; - rt2800usb_txdone(rt2x00dev); - /* * Process any trailing TX status reports for IO failures, * we loop until we find the first non-IO error entry. This @@ -560,6 +556,16 @@ static void rt2800usb_work_txdone(struct work_struct *work) break; } } +} + +static void rt2800usb_work_txdone(struct work_struct *work) +{ + struct rt2x00_dev *rt2x00dev = + container_of(work, struct rt2x00_dev, txdone_work); + + rt2800usb_txdone(rt2x00dev); + + rt2800usb_txdone_nostatus(rt2x00dev); /* * The hw may delay sending the packet after DMA complete -- GitLab From ed61e2b02027935520d1be884fac0b2ffce8379a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 14 Mar 2012 11:16:18 +0100 Subject: [PATCH 1751/1846] rt2x00: rt2800usb: rework txdone code Patch change txdone code to make it similar like txdone in rt2800pci, process only one entry from queue matching tx status. Before we processed all pending entries from queue until PACKEDID match, that caused that we do not report tx statuses correctly. Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 72 +++++++++++-------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 8e1855a478be..4eaa6280f367 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -438,35 +438,25 @@ static int rt2800usb_get_tx_data_len(struct queue_entry *entry) /* * TX control handlers */ -static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) +static enum txdone_entry_desc_flags +rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) { __le32 *txwi; u32 word; int wcid, ack, pid; int tx_wcid, tx_ack, tx_pid; - if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || - !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) { - WARNING(entry->queue->rt2x00dev, - "Data pending for entry %u in queue %u\n", - entry->entry_idx, entry->queue->qid); - cond_resched(); - return false; - } - - wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); - ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); - pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); - /* * This frames has returned with an IO error, * so the status report is not intended for this * frame. */ - if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) { - rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); - return false; - } + if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) + return TXDONE_FAILURE; + + wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); + ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); + pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); /* * Validate if this TX status report is intended for @@ -482,12 +472,11 @@ static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) if ((wcid != tx_wcid) || (ack != tx_ack) || (pid != tx_pid)) { WARNING(entry->queue->rt2x00dev, "TX status report missed for queue %d entry %d\n", - entry->queue->qid, entry->entry_idx); - rt2x00lib_txdone_noinfo(entry, TXDONE_UNKNOWN); - return false; + entry->queue->qid, entry->entry_idx); + return TXDONE_UNKNOWN; } - return true; + return TXDONE_SUCCESS; } static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev) @@ -496,35 +485,36 @@ static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev) struct queue_entry *entry; u32 reg; u8 qid; + enum txdone_entry_desc_flags done_status; while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { - - /* TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus - * qid is guaranteed to be one of the TX QIDs + /* + * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is + * guaranteed to be one of the TX QIDs . */ qid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE); queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); - if (unlikely(!queue)) { - WARNING(rt2x00dev, "Got TX status for an unavailable " + + if (unlikely(rt2x00queue_empty(queue))) { + WARNING(rt2x00dev, "Got TX status for an empty " "queue %u, dropping\n", qid); - continue; + break; } - /* - * Inside each queue, we process each entry in a chronological - * order. We first check that the queue is not empty. - */ - entry = NULL; - while (!rt2x00queue_empty(queue)) { - entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); - if (rt2800usb_txdone_entry_check(entry, reg)) - break; - entry = NULL; + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); + + if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || + !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { + WARNING(rt2x00dev, "Data pending for entry %u " + "in queue %u\n", entry->entry_idx, qid); + break; } - if (entry) - rt2800_txdone_entry(entry, reg, - rt2800usb_get_txwi(entry)); + done_status = rt2800usb_txdone_entry_check(entry, reg); + if (likely(done_status == TXDONE_SUCCESS)) + rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry)); + else + rt2x00lib_txdone_noinfo(entry, done_status); } } -- GitLab From f421111b5e69020c047eb3ff057e50f446c3c7a2 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 14 Mar 2012 11:16:19 +0100 Subject: [PATCH 1752/1846] rt2x00: rt2800usb: rework txstatus code Currently we read tx status register after each urb data transfer. As callback procedure also trigger reading, that causing we have many "threads" of reading status. To prevent that introduce TX_STATUS_READING flags, and check if we are already in process of sequential reading TX_STA_FIFO, before requesting new reads. Change timer to hrtimer, that make TX_STA_FIFO overruns less possible. Use 200 us for initial timeout, and then reschedule in 100 us period, this values probably have to be tuned. Make changes on txdone work. Schedule it from rt2800usb_tx_sta_fifo_read_completed() callback when first valid status show up. Check in callback if tx status timeout happens, and schedule work on that condition too. That make possible to remove tx status timeout from generic watchdog. I moved that to rt2800usb. Loop in txdone work, that should prevent situation when we queue work, which is already processed, and after finish work is not rescheduled again. Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 120 ++++++++++++++++------ drivers/net/wireless/rt2x00/rt2x00.h | 10 +- drivers/net/wireless/rt2x00/rt2x00dev.c | 2 +- drivers/net/wireless/rt2x00/rt2x00queue.h | 12 --- drivers/net/wireless/rt2x00/rt2x00usb.c | 21 +--- 5 files changed, 101 insertions(+), 64 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 4eaa6280f367..eacf94b2f382 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -114,45 +114,103 @@ static bool rt2800usb_txstatus_pending(struct rt2x00_dev *rt2x00dev) return false; } +static inline bool rt2800usb_entry_txstatus_timeout(struct queue_entry *entry) +{ + bool tout; + + if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) + return false; + + tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(100)); + if (unlikely(tout)) + WARNING(entry->queue->rt2x00dev, + "TX status timeout for entry %d in queue %d\n", + entry->entry_idx, entry->queue->qid); + return tout; + +} + +static bool rt2800usb_txstatus_timeout(struct rt2x00_dev *rt2x00dev) +{ + struct data_queue *queue; + struct queue_entry *entry; + + tx_queue_for_each(rt2x00dev, queue) { + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); + if (rt2800usb_entry_txstatus_timeout(entry)) + return true; + } + return false; +} + static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev, int urb_status, u32 tx_status) { + bool valid; + if (urb_status) { - WARNING(rt2x00dev, "rt2x00usb_register_read_async failed: %d\n", urb_status); - return false; + WARNING(rt2x00dev, "TX status read failed %d\n", urb_status); + + goto stop_reading; } - /* try to read all TX_STA_FIFO entries before scheduling txdone_work */ - if (rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID)) { - if (!kfifo_put(&rt2x00dev->txstatus_fifo, &tx_status)) { - WARNING(rt2x00dev, "TX status FIFO overrun, " - "drop tx status report.\n"); - queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); - } else - return true; - } else if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo)) { + valid = rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID); + if (valid) { + if (!kfifo_put(&rt2x00dev->txstatus_fifo, &tx_status)) + WARNING(rt2x00dev, "TX status FIFO overrun\n"); + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); + + /* Reschedule urb to read TX status again instantly */ + return true; } else if (rt2800usb_txstatus_pending(rt2x00dev)) { - mod_timer(&rt2x00dev->txstatus_timer, jiffies + msecs_to_jiffies(2)); + /* Read register after 250 us */ + hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 250000), + HRTIMER_MODE_REL); + return false; } - return false; +stop_reading: + clear_bit(TX_STATUS_READING, &rt2x00dev->flags); + /* + * There is small race window above, between txstatus pending check and + * clear_bit someone could do rt2x00usb_interrupt_txdone, so recheck + * here again if status reading is needed. + */ + if (rt2800usb_txstatus_pending(rt2x00dev) && + test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags)) + return true; + else + return false; +} + +static void rt2800usb_async_read_tx_status(struct rt2x00_dev *rt2x00dev) +{ + + if (test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags)) + return; + + /* Read TX_STA_FIFO register after 500 us */ + hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 500000), + HRTIMER_MODE_REL); } static void rt2800usb_tx_dma_done(struct queue_entry *entry) { struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; - rt2x00usb_register_read_async(rt2x00dev, TX_STA_FIFO, - rt2800usb_tx_sta_fifo_read_completed); + rt2800usb_async_read_tx_status(rt2x00dev); } -static void rt2800usb_tx_sta_fifo_timeout(unsigned long data) +static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *timer) { - struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; + struct rt2x00_dev *rt2x00dev = + container_of(timer, struct rt2x00_dev, txstatus_timer); rt2x00usb_register_read_async(rt2x00dev, TX_STA_FIFO, rt2800usb_tx_sta_fifo_read_completed); + + return HRTIMER_NORESTART; } /* @@ -540,7 +598,7 @@ static void rt2800usb_txdone_nostatus(struct rt2x00_dev *rt2x00dev) if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); - else if (rt2x00queue_status_timeout(entry)) + else if (rt2800usb_entry_txstatus_timeout(entry)) rt2x00lib_txdone_noinfo(entry, TXDONE_UNKNOWN); else break; @@ -553,17 +611,21 @@ static void rt2800usb_work_txdone(struct work_struct *work) struct rt2x00_dev *rt2x00dev = container_of(work, struct rt2x00_dev, txdone_work); - rt2800usb_txdone(rt2x00dev); + while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || + rt2800usb_txstatus_timeout(rt2x00dev)) { - rt2800usb_txdone_nostatus(rt2x00dev); + rt2800usb_txdone(rt2x00dev); - /* - * The hw may delay sending the packet after DMA complete - * if the medium is busy, thus the TX_STA_FIFO entry is - * also delayed -> use a timer to retrieve it. - */ - if (rt2800usb_txstatus_pending(rt2x00dev)) - mod_timer(&rt2x00dev->txstatus_timer, jiffies + msecs_to_jiffies(2)); + rt2800usb_txdone_nostatus(rt2x00dev); + + /* + * The hw may delay sending the packet after DMA complete + * if the medium is busy, thus the TX_STA_FIFO entry is + * also delayed -> use a timer to retrieve it. + */ + if (rt2800usb_txstatus_pending(rt2x00dev)) + rt2800usb_async_read_tx_status(rt2x00dev); + } } /* @@ -705,9 +767,7 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags); __set_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags); - setup_timer(&rt2x00dev->txstatus_timer, - rt2800usb_tx_sta_fifo_timeout, - (unsigned long) rt2x00dev); + rt2x00dev->txstatus_timer.function = rt2800usb_tx_sta_fifo_timeout, /* * Set the rssi offset. diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 65275efcf279..471f87cab4ab 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include @@ -692,6 +692,12 @@ enum rt2x00_state_flags { */ CONFIG_CHANNEL_HT40, CONFIG_POWERSAVING, + + /* + * Mark we currently are sequentially reading TX_STA_FIFO register + * FIXME: this is for only rt2800usb, should go to private data + */ + TX_STATUS_READING, }; /* @@ -974,7 +980,7 @@ struct rt2x00_dev { /* * Timer to ensure tx status reports are read (rt2800usb). */ - struct timer_list txstatus_timer; + struct hrtimer txstatus_timer; /* * Tasklet for processing tx status reports (rt2800pci). diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 49a51b4195ef..cffcf2ec990f 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -1232,7 +1232,7 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) cancel_delayed_work_sync(&rt2x00dev->autowakeup_work); cancel_work_sync(&rt2x00dev->sleep_work); if (rt2x00_is_usb(rt2x00dev)) { - del_timer_sync(&rt2x00dev->txstatus_timer); + hrtimer_cancel(&rt2x00dev->txstatus_timer); cancel_work_sync(&rt2x00dev->rxdone_work); cancel_work_sync(&rt2x00dev->txdone_work); } diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h index 349008d1fb28..5f1392c72673 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.h +++ b/drivers/net/wireless/rt2x00/rt2x00queue.h @@ -636,18 +636,6 @@ static inline int rt2x00queue_threshold(struct data_queue *queue) { return rt2x00queue_available(queue) < queue->threshold; } - -/** - * rt2x00queue_status_timeout - Check if a timeout occurred for STATUS reports - * @entry: Queue entry to check. - */ -static inline int rt2x00queue_status_timeout(struct queue_entry *entry) -{ - if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) - return false; - return time_after(jiffies, entry->last_action + msecs_to_jiffies(100)); -} - /** * rt2x00queue_dma_timeout - Check if a timeout occurred for DMA transfers * @entry: Queue entry to check. diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 2eea3866504d..66094eb21b61 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c @@ -526,22 +526,6 @@ static void rt2x00usb_watchdog_tx_dma(struct data_queue *queue) rt2x00queue_flush_queue(queue, true); } -static void rt2x00usb_watchdog_tx_status(struct data_queue *queue) -{ - WARNING(queue->rt2x00dev, "TX queue %d status timed out," - " invoke forced tx handler\n", queue->qid); - - queue_work(queue->rt2x00dev->workqueue, &queue->rt2x00dev->txdone_work); -} - -static int rt2x00usb_status_timeout(struct data_queue *queue) -{ - struct queue_entry *entry; - - entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); - return rt2x00queue_status_timeout(entry); -} - static int rt2x00usb_dma_timeout(struct data_queue *queue) { struct queue_entry *entry; @@ -558,8 +542,6 @@ void rt2x00usb_watchdog(struct rt2x00_dev *rt2x00dev) if (!rt2x00queue_empty(queue)) { if (rt2x00usb_dma_timeout(queue)) rt2x00usb_watchdog_tx_dma(queue); - if (rt2x00usb_status_timeout(queue)) - rt2x00usb_watchdog_tx_status(queue); } } } @@ -829,7 +811,8 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, INIT_WORK(&rt2x00dev->rxdone_work, rt2x00usb_work_rxdone); INIT_WORK(&rt2x00dev->txdone_work, rt2x00usb_work_txdone); - init_timer(&rt2x00dev->txstatus_timer); + hrtimer_init(&rt2x00dev->txstatus_timer, CLOCK_MONOTONIC, + HRTIMER_MODE_REL); retval = rt2x00usb_alloc_reg(rt2x00dev); if (retval) -- GitLab From 5f8f718ae1e1a6b4e16e67e9e67aff1864419f2e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 14 Mar 2012 11:16:20 +0100 Subject: [PATCH 1753/1846] rt2x00: rt2800usb: do not check packedid for aggregated frames Tx statuses of aggregated subframes contain packetid of first subframe in the AMPDU. We can not identify AMPDU subframes based on packedid, so simply assume that status match first pending frame in the queue. Thats mostly the same what 2800pci do. Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Acked-by: Helmut Schaa Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index eacf94b2f382..8c1d2c0df854 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -502,7 +502,7 @@ rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) __le32 *txwi; u32 word; int wcid, ack, pid; - int tx_wcid, tx_ack, tx_pid; + int tx_wcid, tx_ack, tx_pid, is_agg; /* * This frames has returned with an IO error, @@ -515,6 +515,7 @@ rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); + is_agg = rt2x00_get_field32(reg, TX_STA_FIFO_TX_AGGRE); /* * Validate if this TX status report is intended for @@ -527,7 +528,7 @@ rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK); tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID); - if ((wcid != tx_wcid) || (ack != tx_ack) || (pid != tx_pid)) { + if (wcid != tx_wcid || ack != tx_ack || (!is_agg && pid != tx_pid)) { WARNING(entry->queue->rt2x00dev, "TX status report missed for queue %d entry %d\n", entry->queue->qid, entry->entry_idx); -- GitLab From 0d9be8a4b7da71ef3b4ac8f6aa4fa225c1cb8e98 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 14 Mar 2012 11:16:21 +0100 Subject: [PATCH 1754/1846] rt2x00: rt2800usb: limit tx queues length TX status fifo is limited to 16 elements. When we send more frames than that, we can easily loose status, what is not good for rate scaling algorithm. On my testing the change does not degrade performance, actually make is slightly better. Additionally with the patch I can see much less various rt2x00 warnings in dmesg. Signed-off-by: Stanislaw Gruszka Acked-by: Gertjan van Wingerde Acked-by: Helmut Schaa Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 8c1d2c0df854..cd490abced91 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -870,7 +870,7 @@ static const struct data_queue_desc rt2800usb_queue_rx = { }; static const struct data_queue_desc rt2800usb_queue_tx = { - .entry_num = 64, + .entry_num = 16, .data_size = AGGREGATION_SIZE, .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, .priv_size = sizeof(struct queue_entry_priv_usb), -- GitLab From ba6fa29c6dd51a1245a109f4b460092b51cad0f0 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Wed, 14 Mar 2012 13:31:11 +0100 Subject: [PATCH 1755/1846] mac80211: Don't sample max throughput rate in minstrel_ht The current max throughput rate is known to be good as otherwise it wouldn't be the max throughput rate. Since rate sampling can introduce some overhead (by adding RTS for example or due to not aggregating the frame) don't sample the max throughput rate. Signed-off-by: Helmut Schaa Acked-by: Felix Fietkau Signed-off-by: John W. Linville --- net/mac80211/rc80211_minstrel_ht.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index 2b42564d6e29..16e0b277b9a8 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -567,6 +567,13 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) sample_idx += mi->sample_group * MCS_GROUP_RATES; minstrel_next_sample_idx(mi); + /* + * Sampling might add some overhead (RTS, no aggregation) + * to the frame. Hence, don't use sampling for the currently + * used max TP rate. + */ + if (sample_idx == mi->max_tp_rate) + return -1; /* * When not using MRR, do not sample if the probability is already * higher than 95% to avoid wasting airtime -- GitLab From ada577c12f7cd8851c999a9f19f62df06df7c39a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 14 Mar 2012 16:15:02 +0200 Subject: [PATCH 1756/1846] mac80211: add NULL terminator to debugfs_netdev write buf Some debugfs write functions call kstrto* functions, which assume the string is null-terminated. Make it valid by changing ieee80211_if_write() to use static buffer instead of allocating one, and set the last char to NULL. (The write functions try to parse some integer/mac address, so 64 bytes buffer should be enough) Signed-off-by: Eliad Peller Signed-off-by: John W. Linville --- net/mac80211/debugfs_netdev.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index f6de8a65f402..ef5cf2685657 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -49,16 +49,15 @@ static ssize_t ieee80211_if_write( size_t count, loff_t *ppos, ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int)) { - u8 *buf; + char buf[64]; ssize_t ret; - buf = kmalloc(count, GFP_KERNEL); - if (!buf) - return -ENOMEM; + if (count >= sizeof(buf)) + return -E2BIG; - ret = -EFAULT; if (copy_from_user(buf, userbuf, count)) - goto freebuf; + return -EFAULT; + buf[count] = '\0'; ret = -ENODEV; rtnl_lock(); @@ -66,8 +65,6 @@ static ssize_t ieee80211_if_write( ret = (*write)(sdata, buf, count); rtnl_unlock(); -freebuf: - kfree(buf); return ret; } -- GitLab From dc41e4d474bb18e60bc6678e58adc52ed227f105 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 14 Mar 2012 16:15:03 +0200 Subject: [PATCH 1757/1846] mac80211: make uapsd_* keys per-vif uapsd_queues and uapsd_max_sp_len are relevant only for managed interfaces, and can be configured differently for each vif. Move them from the local struct to sdata->u.mgd, and update the debugfs functions accordingly. Signed-off-by: Eliad Peller Signed-off-by: John W. Linville --- net/mac80211/debugfs.c | 81 ----------------------------------- net/mac80211/debugfs_netdev.c | 58 +++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 28 ++++++------ net/mac80211/main.c | 2 - net/mac80211/mlme.c | 8 ++-- net/mac80211/tx.c | 4 +- 6 files changed, 79 insertions(+), 102 deletions(-) diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 483e96ed95c1..cc5b7a6e7e0b 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -97,85 +97,6 @@ static const struct file_operations reset_ops = { .llseek = noop_llseek, }; -static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct ieee80211_local *local = file->private_data; - return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", - local->uapsd_queues); -} - -static ssize_t uapsd_queues_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct ieee80211_local *local = file->private_data; - u8 val; - int ret; - - ret = kstrtou8_from_user(user_buf, count, 0, &val); - if (ret) - return ret; - - if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) - return -ERANGE; - - local->uapsd_queues = val; - - return count; -} - -static const struct file_operations uapsd_queues_ops = { - .read = uapsd_queues_read, - .write = uapsd_queues_write, - .open = mac80211_open_file_generic, - .llseek = default_llseek, -}; - -static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct ieee80211_local *local = file->private_data; - - return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", - local->uapsd_max_sp_len); -} - -static ssize_t uapsd_max_sp_len_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct ieee80211_local *local = file->private_data; - unsigned long val; - char buf[10]; - size_t len; - int ret; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - buf[len] = '\0'; - - ret = kstrtoul(buf, 0, &val); - - if (ret) - return -EINVAL; - - if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) - return -ERANGE; - - local->uapsd_max_sp_len = val; - - return count; -} - -static const struct file_operations uapsd_max_sp_len_ops = { - .read = uapsd_max_sp_len_read, - .write = uapsd_max_sp_len_write, - .open = mac80211_open_file_generic, - .llseek = default_llseek, -}; - static ssize_t channel_type_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -362,8 +283,6 @@ void debugfs_hw_add(struct ieee80211_local *local) DEBUGFS_ADD(wep_iv); DEBUGFS_ADD(queues); DEBUGFS_ADD_MODE(reset, 0200); - DEBUGFS_ADD(uapsd_queues); - DEBUGFS_ADD(uapsd_max_sp_len); DEBUGFS_ADD(channel_type); DEBUGFS_ADD(hwflags); DEBUGFS_ADD(user_power); diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index ef5cf2685657..a32eeda04aa3 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c @@ -337,6 +337,62 @@ static ssize_t ieee80211_if_parse_tkip_mic_test( __IEEE80211_IF_FILE_W(tkip_mic_test); +static ssize_t ieee80211_if_fmt_uapsd_queues( + const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) +{ + const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + + return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_queues); +} + +static ssize_t ieee80211_if_parse_uapsd_queues( + struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) +{ + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + u8 val; + int ret; + + ret = kstrtou8(buf, 0, &val); + if (ret) + return ret; + + if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) + return -ERANGE; + + ifmgd->uapsd_queues = val; + + return buflen; +} +__IEEE80211_IF_FILE_W(uapsd_queues); + +static ssize_t ieee80211_if_fmt_uapsd_max_sp_len( + const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) +{ + const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + + return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_max_sp_len); +} + +static ssize_t ieee80211_if_parse_uapsd_max_sp_len( + struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) +{ + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + unsigned long val; + int ret; + + ret = kstrtoul(buf, 0, &val); + if (ret) + return -EINVAL; + + if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) + return -ERANGE; + + ifmgd->uapsd_max_sp_len = val; + + return buflen; +} +__IEEE80211_IF_FILE_W(uapsd_max_sp_len); + /* AP attributes */ IEEE80211_IF_FILE(num_sta_authorized, u.ap.num_sta_authorized, ATOMIC); IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); @@ -469,6 +525,8 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata) DEBUGFS_ADD(ave_beacon); DEBUGFS_ADD_MODE(smps, 0600); DEBUGFS_ADD_MODE(tkip_mic_test, 0200); + DEBUGFS_ADD_MODE(uapsd_queues, 0600); + DEBUGFS_ADD_MODE(uapsd_max_sp_len, 0600); } static void add_ap_files(struct ieee80211_sub_if_data *sdata) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 63fb0eb79d8e..d9798a307f20 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -459,6 +459,20 @@ struct ieee80211_if_managed { IEEE80211_MFP_REQUIRED } mfp; /* management frame protection */ + /* + * Bitmask of enabled u-apsd queues, + * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association + * to take effect. + */ + unsigned int uapsd_queues; + + /* + * Maximum number of buffered frames AP can deliver during a + * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar. + * Needs a new association to take effect. + */ + unsigned int uapsd_max_sp_len; + int wmm_last_param_set; u8 use_4addr; @@ -1017,20 +1031,6 @@ struct ieee80211_local { */ unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */ - /* - * Bitmask of enabled u-apsd queues, - * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association - * to take effect. - */ - unsigned int uapsd_queues; - - /* - * Maximum number of buffered frames AP can deliver during a - * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar. - * Needs a new association to take effect. - */ - unsigned int uapsd_max_sp_len; - bool pspolling; bool offchannel_ps_enabled; /* diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 36fa8051296c..b581a24fa15c 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -595,8 +595,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; local->user_power_level = -1; - local->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; - local->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; INIT_LIST_HEAD(&local->interfaces); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 0df22372af8d..576fb25456dd 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -572,8 +572,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) if (assoc_data->wmm) { if (assoc_data->uapsd) { - qos_info = local->uapsd_queues; - qos_info |= (local->uapsd_max_sp_len << + qos_info = ifmgd->uapsd_queues; + qos_info |= (ifmgd->uapsd_max_sp_len << IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); } else { qos_info = 0; @@ -1192,7 +1192,7 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local, return; if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) - uapsd_queues = local->uapsd_queues; + uapsd_queues = ifmgd->uapsd_queues; count = wmm_param[6] & 0x0f; if (count == ifmgd->wmm_last_param_set) @@ -3013,6 +3013,8 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) ifmgd->flags = 0; ifmgd->powersave = sdata->wdev.ps; + ifmgd->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; + ifmgd->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; mutex_init(&ifmgd->mtx); diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index d9e791d2b543..782a60198df4 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -226,12 +226,12 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) * have correct qos tag for some reason, due the network or the * peer application. * - * Note: local->uapsd_queues access is racy here. If the value is + * Note: ifmgd->uapsd_queues access is racy here. If the value is * changed via debugfs, user needs to reassociate manually to have * everything in sync. */ if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) - && (local->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) + && (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) && skb_get_queue_mapping(tx->skb) == 0) return TX_CONTINUE; -- GitLab From 7e03072edd6a915812c418e5662204f83bbb0c84 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:21 +0100 Subject: [PATCH 1758/1846] ath9k_hw: simplify tx queue interrupt mask handling Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mac.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index 5f4ae6c9a93c..13b6afd67826 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -340,6 +340,15 @@ int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type, } EXPORT_SYMBOL(ath9k_hw_setuptxqueue); +static void ath9k_hw_clear_queue_interrupts(struct ath_hw *ah, u32 q) +{ + ah->txok_interrupt_mask &= ~(1 << q); + ah->txerr_interrupt_mask &= ~(1 << q); + ah->txdesc_interrupt_mask &= ~(1 << q); + ah->txeol_interrupt_mask &= ~(1 << q); + ah->txurn_interrupt_mask &= ~(1 << q); +} + bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q) { struct ath_common *common = ath9k_hw_common(ah); @@ -354,11 +363,7 @@ bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q) ath_dbg(common, QUEUE, "Release TX queue: %u\n", q); qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE; - ah->txok_interrupt_mask &= ~(1 << q); - ah->txerr_interrupt_mask &= ~(1 << q); - ah->txdesc_interrupt_mask &= ~(1 << q); - ah->txeol_interrupt_mask &= ~(1 << q); - ah->txurn_interrupt_mask &= ~(1 << q); + ath9k_hw_clear_queue_interrupts(ah, q); ath9k_hw_set_txq_interrupts(ah, qi); return true; @@ -510,26 +515,17 @@ bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q) if (AR_SREV_9300_20_OR_LATER(ah)) REG_WRITE(ah, AR_Q_DESC_CRCCHK, AR_Q_DESC_CRCCHK_EN); + ath9k_hw_clear_queue_interrupts(ah, q); if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE) ah->txok_interrupt_mask |= 1 << q; - else - ah->txok_interrupt_mask &= ~(1 << q); if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE) ah->txerr_interrupt_mask |= 1 << q; - else - ah->txerr_interrupt_mask &= ~(1 << q); if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE) ah->txdesc_interrupt_mask |= 1 << q; - else - ah->txdesc_interrupt_mask &= ~(1 << q); if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE) ah->txeol_interrupt_mask |= 1 << q; - else - ah->txeol_interrupt_mask &= ~(1 << q); if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE) ah->txurn_interrupt_mask |= 1 << q; - else - ah->txurn_interrupt_mask &= ~(1 << q); ath9k_hw_set_txq_interrupts(ah, qi); return true; -- GitLab From ce8fdf6ef6bc2e299d2e1572c55325e0dca7e85f Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:22 +0100 Subject: [PATCH 1759/1846] ath9k_hw: clean up tx completion interrupt handling TXQ_FLAG_TXOKINT_ENABLE and TXQ_FLAG_TXERRINT_ENABLE are always set and used together, and they share the same bitmask in enum ath9k_tx_queue_flags. Simplify the code that tests for these flags. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mac.c | 7 +++---- drivers/net/wireless/ath/ath9k/mac.h | 3 +-- drivers/net/wireless/ath/ath9k/xmit.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index 13b6afd67826..bfb95e5d263c 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -516,10 +516,10 @@ bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q) REG_WRITE(ah, AR_Q_DESC_CRCCHK, AR_Q_DESC_CRCCHK_EN); ath9k_hw_clear_queue_interrupts(ah, q); - if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE) + if (qi->tqi_qflags & TXQ_FLAG_TXINT_ENABLE) { ah->txok_interrupt_mask |= 1 << q; - if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE) ah->txerr_interrupt_mask |= 1 << q; + } if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE) ah->txdesc_interrupt_mask |= 1 << q; if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE) @@ -743,8 +743,7 @@ int ath9k_hw_beaconq_setup(struct ath_hw *ah) qi.tqi_cwmax = 0; if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) - qi.tqi_qflags = TXQ_FLAG_TXOKINT_ENABLE | - TXQ_FLAG_TXERRINT_ENABLE; + qi.tqi_qflags = TXQ_FLAG_TXINT_ENABLE; return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi); } diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h index 11dbd1473a13..6476d9073202 100644 --- a/drivers/net/wireless/ath/ath9k/mac.h +++ b/drivers/net/wireless/ath/ath9k/mac.h @@ -583,8 +583,7 @@ enum ath9k_tx_queue { #define ATH9K_WME_UPSD 4 enum ath9k_tx_queue_flags { - TXQ_FLAG_TXOKINT_ENABLE = 0x0001, - TXQ_FLAG_TXERRINT_ENABLE = 0x0001, + TXQ_FLAG_TXINT_ENABLE = 0x0001, TXQ_FLAG_TXDESCINT_ENABLE = 0x0002, TXQ_FLAG_TXEOLINT_ENABLE = 0x0004, TXQ_FLAG_TXURNINT_ENABLE = 0x0008, diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 5faec1e04d65..c6b93f619843 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1355,8 +1355,7 @@ struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) * based intr on the EOSP frames. */ if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { - qi.tqi_qflags = TXQ_FLAG_TXOKINT_ENABLE | - TXQ_FLAG_TXERRINT_ENABLE; + qi.tqi_qflags = TXQ_FLAG_TXINT_ENABLE; } else { if (qtype == ATH9K_TX_QUEUE_UAPSD) qi.tqi_qflags = TXQ_FLAG_TXDESCINT_ENABLE; -- GitLab From 8efa7a813233affeafd9fd7770709e9bda6855b6 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:23 +0100 Subject: [PATCH 1760/1846] ath9k_hw: remove ath9k_hw_htc_resetinit Automatically set the ah->htc_reset_init on init and after PHY disable. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 1 - drivers/net/wireless/ath/ath9k/hw.c | 8 ++------ drivers/net/wireless/ath/ath9k/hw.h | 3 --- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c index 2a29a7cdef18..2b8f61c210e1 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c @@ -919,7 +919,6 @@ static int ath9k_htc_start(struct ieee80211_hw *hw) /* setup initial channel */ init_channel = ath9k_cmn_get_curchannel(hw, ah); - ath9k_hw_htc_resetinit(ah); ret = ath9k_hw_reset(ah, init_channel, ah->caldata, false); if (ret) { ath_err(common, diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 780ecd8aff6e..d3df943ac124 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -449,6 +449,7 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah) ah->slottime = ATH9K_SLOT_TIME_9; ah->globaltxtimeout = (u32) -1; ah->power_mode = ATH9K_PM_UNDEFINED; + ah->htc_reset_init = true; } static int ath9k_hw_init_macaddr(struct ath_hw *ah) @@ -2631,6 +2632,7 @@ bool ath9k_hw_phy_disable(struct ath_hw *ah) return false; ath9k_hw_init_pll(ah, NULL); + ah->htc_reset_init = true; return true; } EXPORT_SYMBOL(ath9k_hw_phy_disable); @@ -2991,12 +2993,6 @@ EXPORT_SYMBOL(ath_gen_timer_isr); /* HTC */ /********/ -void ath9k_hw_htc_resetinit(struct ath_hw *ah) -{ - ah->htc_reset_init = true; -} -EXPORT_SYMBOL(ath9k_hw_htc_resetinit); - static struct { u32 version; const char * name; diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 23c8dfae29f7..7ce60fb1d91e 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -988,9 +988,6 @@ void ath_gen_timer_isr(struct ath_hw *hw); void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len); -/* HTC */ -void ath9k_hw_htc_resetinit(struct ath_hw *ah); - /* PHY */ void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled, u32 *coef_mantissa, u32 *coef_exponent); -- GitLab From 99ac8cd6ff44e733acdff0d36475dce2d3fe6a6b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:24 +0100 Subject: [PATCH 1761/1846] ath9k_hw: remove ath9k_hw_getdefantenna The default antenna (as programmed by the INI file) is always 0 anyway. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 6 ------ drivers/net/wireless/ath/ath9k/hw.h | 1 - drivers/net/wireless/ath/ath9k/init.c | 1 - 3 files changed, 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index d3df943ac124..b92cf01cfd19 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2569,12 +2569,6 @@ void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) } EXPORT_SYMBOL(ath9k_hw_set_gpio); -u32 ath9k_hw_getdefantenna(struct ath_hw *ah) -{ - return REG_READ(ah, AR_DEF_ANTENNA) & 0x7; -} -EXPORT_SYMBOL(ath9k_hw_getdefantenna); - void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna) { REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7)); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 7ce60fb1d91e..5036f95c48c1 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -934,7 +934,6 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio); void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, u32 ah_signal_type); void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); -u32 ath9k_hw_getdefantenna(struct ath_hw *ah); void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); /* General Operation */ diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 2708d1fc2c10..8cb37429b216 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -488,7 +488,6 @@ static void ath9k_init_misc(struct ath_softc *sc) setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc); sc->config.txpowlimit = ATH_TXPOWER_MAX; - sc->rx.defant = ath9k_hw_getdefantenna(sc->sc_ah); memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); sc->beacon.slottime = ATH9K_SLOT_TIME_9; -- GitLab From f3eef64521f82330b4b173584d776b8a04b3e795 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:25 +0100 Subject: [PATCH 1762/1846] ath9k: optimize register access functions By checking for NR_CPUS, the compiler can optimize out register access serialization code on non-SMP kernels Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 2 +- drivers/net/wireless/ath/ath9k/init.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index b92cf01cfd19..ce9577ebaf2b 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -556,7 +556,7 @@ static int __ath9k_hw_init(struct ath_hw *ah) return -EIO; } - if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) { + if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_AUTO) { if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI || ((AR_SREV_9160(ah) || AR_SREV_9280(ah)) && !ah->is_pciexpress)) { diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 8cb37429b216..60159f4ee532 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -172,7 +172,7 @@ static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset) struct ath_common *common = ath9k_hw_common(ah); struct ath_softc *sc = (struct ath_softc *) common->priv; - if (ah->config.serialize_regmode == SER_REG_MODE_ON) { + if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { unsigned long flags; spin_lock_irqsave(&sc->sc_serial_rw, flags); iowrite32(val, sc->mem + reg_offset); @@ -188,7 +188,7 @@ static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset) struct ath_softc *sc = (struct ath_softc *) common->priv; u32 val; - if (ah->config.serialize_regmode == SER_REG_MODE_ON) { + if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { unsigned long flags; spin_lock_irqsave(&sc->sc_serial_rw, flags); val = ioread32(sc->mem + reg_offset); @@ -219,7 +219,7 @@ static unsigned int ath9k_reg_rmw(void *hw_priv, u32 reg_offset, u32 set, u32 cl unsigned long uninitialized_var(flags); u32 val; - if (ah->config.serialize_regmode == SER_REG_MODE_ON) { + if (NR_CPUS > 1 && ah->config.serialize_regmode == SER_REG_MODE_ON) { spin_lock_irqsave(&sc->sc_serial_rw, flags); val = __ath9k_reg_rmw(sc, reg_offset, set, clr); spin_unlock_irqrestore(&sc->sc_serial_rw, flags); -- GitLab From 239c795d6ba9ada0811cdb4f87304552de29e81b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:26 +0100 Subject: [PATCH 1763/1846] ath9k_hw: remove ath9k_hw_gettxintrtxqs The driver can just check the mask directly Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mac.c | 7 ------- drivers/net/wireless/ath/ath9k/mac.h | 1 - drivers/net/wireless/ath/ath9k/xmit.c | 5 ++--- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index bfb95e5d263c..f7bd2532269c 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -185,13 +185,6 @@ bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q) } EXPORT_SYMBOL(ath9k_hw_stop_dma_queue); -void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs) -{ - *txqs &= ah->intr_txqs; - ah->intr_txqs &= ~(*txqs); -} -EXPORT_SYMBOL(ath9k_hw_gettxintrtxqs); - bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q, const struct ath9k_tx_queue_info *qinfo) { diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h index 6476d9073202..21c955609e6c 100644 --- a/drivers/net/wireless/ath/ath9k/mac.h +++ b/drivers/net/wireless/ath/ath9k/mac.h @@ -713,7 +713,6 @@ u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q); bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel); bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q); void ath9k_hw_abort_tx_dma(struct ath_hw *ah); -void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs); bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q, const struct ath9k_tx_queue_info *qinfo); bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q, diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index c6b93f619843..834e6bc45e8b 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -2261,10 +2261,9 @@ static void ath_tx_complete_poll_work(struct work_struct *work) void ath_tx_tasklet(struct ath_softc *sc) { + struct ath_hw *ah = sc->sc_ah; + u32 qcumask = ((1 << ATH9K_NUM_TX_QUEUES) - 1) & ah->intr_txqs; int i; - u32 qcumask = ((1 << ATH9K_NUM_TX_QUEUES) - 1); - - ath9k_hw_gettxintrtxqs(sc->sc_ah, &qcumask); for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { if (ATH_TXQ_SETUP(sc, i) && (qcumask & (1 << i))) -- GitLab From aebc0a88ddf514ef2b3cdba0b3f14883b8b0e339 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:27 +0100 Subject: [PATCH 1764/1846] ath9k_hw: clean up ath9k_hw_setuprxdesc The ATH9K_HW_CAP_AUTOSLEEP check is bogus, the rx status area needs to be cleared on all non-EDMA PCI/AHB based chipsets anyway. Limit the memset to the rx status area to improve performance. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9002_mac.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c index 7b6417b5212e..aa2abaf31cba 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c @@ -347,15 +347,12 @@ void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds, u32 size, u32 flags) { struct ar5416_desc *ads = AR5416DESC(ds); - struct ath9k_hw_capabilities *pCap = &ah->caps; ads->ds_ctl1 = size & AR_BufLen; if (flags & ATH9K_RXDESC_INTREQ) ads->ds_ctl1 |= AR_RxIntrReq; - ads->ds_rxstatus8 &= ~AR_RxDone; - if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) - memset(&(ads->u), 0, sizeof(ads->u)); + memset(&ads->u.rx, 0, sizeof(ads->u.rx)); } EXPORT_SYMBOL(ath9k_hw_setuprxdesc); -- GitLab From bbf2b30c0ee0860ab10af856f7d8570c8652d9fd Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:28 +0100 Subject: [PATCH 1765/1846] ath9k_hw: remove iniCommon_*_cck_fir_coeff_9271 These arrays are unused Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 6 ------ drivers/net/wireless/ath/ath9k/hw.h | 2 -- 2 files changed, 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index e3f268900763..2829c8c75e86 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -34,12 +34,6 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar9271Modes_9271), 5); INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, ARRAY_SIZE(ar9271Common_9271), 2); - INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271, - ar9287Common_normal_cck_fir_coeff_9287_1_1, - ARRAY_SIZE(ar9287Common_normal_cck_fir_coeff_9287_1_1), 2); - INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271, - ar9287Common_japan_2484_cck_fir_coeff_9287_1_1, - ARRAY_SIZE(ar9287Common_japan_2484_cck_fir_coeff_9287_1_1), 2); INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, ar9271Modes_9271_1_0_only, ARRAY_SIZE(ar9271Modes_9271_1_0_only), 5); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 5036f95c48c1..043df3cf54fe 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -835,8 +835,6 @@ struct ath_hw { struct ar5416IniArray iniCckfirNormal; struct ar5416IniArray iniCckfirJapan2484; struct ar5416IniArray ini_japan2484; - struct ar5416IniArray iniCommon_normal_cck_fir_coeff_9271; - struct ar5416IniArray iniCommon_japan_2484_cck_fir_coeff_9271; struct ar5416IniArray iniModes_9271_ANI_reg; struct ar5416IniArray iniModes_high_power_tx_gain_9271; struct ar5416IniArray iniModes_normal_power_tx_gain_9271; -- GitLab From c8664d13a58f7cccc673c0840efcc698f7872172 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:29 +0100 Subject: [PATCH 1766/1846] ath9k_hw: fold ar9002_hw_cck_chan14_spread into mode regs initialization Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 5 ----- drivers/net/wireless/ath/ath9k/hw.c | 3 --- drivers/net/wireless/ath/ath9k/hw.h | 1 - 3 files changed, 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 2829c8c75e86..1d06dab27030 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -154,11 +154,6 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) INI_RA(addac, 31,1) = 0; } } -} - -/* Support for Japan ch.14 (2484) spread */ -void ar9002_hw_cck_chan14_spread(struct ath_hw *ah) -{ if (AR_SREV_9287_11_OR_LATER(ah)) { INIT_INI_ARRAY(&ah->iniCckfirNormal, ar9287Common_normal_cck_fir_coeff_9287_1_1, diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index ce9577ebaf2b..3022c4e4d103 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -620,9 +620,6 @@ static int __ath9k_hw_init(struct ath_hw *ah) if (!ah->is_pciexpress) ath9k_hw_disablepcie(ah); - if (!AR_SREV_9300_20_OR_LATER(ah)) - ar9002_hw_cck_chan14_spread(ah); - r = ath9k_hw_post_init(ah); if (r) return r; diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 043df3cf54fe..4bd2c89654d4 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -994,7 +994,6 @@ void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan); * Code Specific to AR5008, AR9001 or AR9002, * we stuff these here to avoid callbacks for AR9003. */ -void ar9002_hw_cck_chan14_spread(struct ath_hw *ah); int ar9002_hw_rf_claim(struct ath_hw *ah); void ar9002_hw_enable_async_fifo(struct ath_hw *ah); -- GitLab From 9951c4d042dbc325b147cce5bd6f6436adb2c7fc Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:30 +0100 Subject: [PATCH 1767/1846] ath9k_hw: fix AR9380 register settings for channel 14 Program the ah->ini_japan2484 INI values which were left out by accident Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index 70e27d2a5e43..99b64f27bb22 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c @@ -691,6 +691,9 @@ static int ar9003_hw_process_ini(struct ath_hw *ah, if (AR_SREV_9462(ah)) ar9003_hw_prog_ini(ah, &ah->ini_BTCOEX_MAX_TXPWR, 1); + if (chan->channel == 2484) + ar9003_hw_prog_ini(ah, &ah->ini_japan2484, 1); + ah->modes_index = modesIndex; ar9003_hw_override_ini(ah); ar9003_hw_set_channel_regs(ah, chan); -- GitLab From c7d36f9fe73ed29760042276295ac42c17849f32 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:31 +0100 Subject: [PATCH 1768/1846] ath9k_hw: clean up iniModesAdditional use iniModesFastClock for 5 ghz fast clock specific settings, and iniAdditional for clock/chip specific initval overrides Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 5 ++--- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 2 +- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 25 +++++++++++---------- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 16 ++++--------- drivers/net/wireless/ath/ath9k/hw.h | 4 ++-- 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c index 86a891f93fc9..5d34e57ce50b 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c @@ -869,10 +869,9 @@ static int ar5008_hw_process_ini(struct ath_hw *ah, REG_WRITE_ARRAY(&ah->iniBB_RfGain, freqIndex, regWrites); - if (IS_CHAN_A_FAST_CLOCK(ah, chan)) { - REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, + if (IS_CHAN_A_FAST_CLOCK(ah, chan)) + REG_WRITE_ARRAY(&ah->iniModesFastClock, modesIndex, regWrites); - } ar5008_hw_override_ini(ah, chan); ar5008_hw_set_channel_regs(ah, chan); diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 1d06dab27030..7098cd8eee60 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -73,7 +73,7 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) INIT_INI_ARRAY(&ah->iniCommon, ar9280Common_9280_2, ARRAY_SIZE(ar9280Common_9280_2), 2); - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniModesFastClock, ar9280Modes_fast_clock_9280_2, ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3); } else if (AR_SREV_9160_10_OR_LATER(ah)) { diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c index 7b4aa000cc2e..0f56e322dd3b 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c @@ -87,11 +87,11 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) /* additional clock settings */ if (ah->is_clk_25mhz) - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniAdditional, ar9331_1p1_xtal_25M, ARRAY_SIZE(ar9331_1p1_xtal_25M), 2); else - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniAdditional, ar9331_1p1_xtal_40M, ARRAY_SIZE(ar9331_1p1_xtal_40M), 2); } else if (AR_SREV_9330_12(ah)) { @@ -140,11 +140,11 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) /* additional clock settings */ if (ah->is_clk_25mhz) - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniAdditional, ar9331_1p2_xtal_25M, ARRAY_SIZE(ar9331_1p2_xtal_25M), 2); else - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniAdditional, ar9331_1p2_xtal_40M, ARRAY_SIZE(ar9331_1p2_xtal_40M), 2); } else if (AR_SREV_9340(ah)) { @@ -194,15 +194,16 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar9340Modes_high_ob_db_tx_gain_table_1p0), 5); - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniModesFastClock, ar9340Modes_fast_clock_1p0, ARRAY_SIZE(ar9340Modes_fast_clock_1p0), 3); - INIT_INI_ARRAY(&ah->iniModesAdditional_40M, - ar9340_1p0_radio_core_40M, - ARRAY_SIZE(ar9340_1p0_radio_core_40M), - 2); + if (!ah->is_clk_25mhz) + INIT_INI_ARRAY(&ah->iniAdditional, + ar9340_1p0_radio_core_40M, + ARRAY_SIZE(ar9340_1p0_radio_core_40M), + 2); } else if (AR_SREV_9485_11(ah)) { /* mac */ INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); @@ -321,7 +322,7 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) 2); /* Fast clock modal settings */ - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniModesFastClock, ar9462_modes_fast_clock_2p0, ARRAY_SIZE(ar9462_modes_fast_clock_2p0), 3); @@ -378,7 +379,7 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar9580_1p0_low_ob_db_tx_gain_table), 5); - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniModesFastClock, ar9580_1p0_modes_fast_clock, ARRAY_SIZE(ar9580_1p0_modes_fast_clock), 3); @@ -445,7 +446,7 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) 2); /* Fast clock modal settings */ - INIT_INI_ARRAY(&ah->iniModesAdditional, + INIT_INI_ARRAY(&ah->iniModesFastClock, ar9300Modes_fast_clock_2p2, ARRAY_SIZE(ar9300Modes_fast_clock_2p2), 3); diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index 99b64f27bb22..bc992b237ae5 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c @@ -679,14 +679,10 @@ static int ar9003_hw_process_ini(struct ath_hw *ah, * different modal values. */ if (IS_CHAN_A_FAST_CLOCK(ah, chan)) - REG_WRITE_ARRAY(&ah->iniModesAdditional, + REG_WRITE_ARRAY(&ah->iniModesFastClock, modesIndex, regWrites); - if (AR_SREV_9330(ah)) - REG_WRITE_ARRAY(&ah->iniModesAdditional, 1, regWrites); - - if (AR_SREV_9340(ah) && !ah->is_clk_25mhz) - REG_WRITE_ARRAY(&ah->iniModesAdditional_40M, 1, regWrites); + REG_WRITE_ARRAY(&ah->iniAdditional, 1, regWrites); if (AR_SREV_9462(ah)) ar9003_hw_prog_ini(ah, &ah->ini_BTCOEX_MAX_TXPWR, 1); @@ -1323,13 +1319,9 @@ static int ar9003_hw_fast_chan_change(struct ath_hw *ah, * different modal values. */ if (IS_CHAN_A_FAST_CLOCK(ah, chan)) - REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, regWrites); - - if (AR_SREV_9330(ah)) - REG_WRITE_ARRAY(&ah->iniModesAdditional, 1, regWrites); + REG_WRITE_ARRAY(&ah->iniModesFastClock, modesIndex, regWrites); - if (AR_SREV_9340(ah) && !ah->is_clk_25mhz) - REG_WRITE_ARRAY(&ah->iniModesAdditional_40M, 1, regWrites); + REG_WRITE_ARRAY(&ah->iniAdditional, 1, regWrites); ah->modes_index = modesIndex; *ini_reloaded = true; diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 4bd2c89654d4..7822d5ecbf8b 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -827,8 +827,8 @@ struct ath_hw { struct ar5416IniArray iniAddac; struct ar5416IniArray iniPcieSerdes; struct ar5416IniArray iniPcieSerdesLowPower; - struct ar5416IniArray iniModesAdditional; - struct ar5416IniArray iniModesAdditional_40M; + struct ar5416IniArray iniModesFastClock; + struct ar5416IniArray iniAdditional; struct ar5416IniArray iniModesRxGain; struct ar5416IniArray iniModesTxGain; struct ar5416IniArray iniModes_9271_1_0_only; -- GitLab From aa0e5786b6e0cf2adaa26d72770cb5a0ad263026 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:32 +0100 Subject: [PATCH 1769/1846] ath9k_hw: remove iniModes_*_tx_gain_9271 Program tx gain through iniModesTxGain like on AR9287 Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 9 ------ drivers/net/wireless/ath/ath9k/ar9002_hw.c | 34 ++++++++++++--------- drivers/net/wireless/ath/ath9k/hw.h | 2 -- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c index 5d34e57ce50b..3e108c8b1d32 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c @@ -858,15 +858,6 @@ static int ar5008_hw_process_ini(struct ath_hw *ah, REGWRITE_BUFFER_FLUSH(ah); - if (AR_SREV_9271(ah)) { - if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1) - REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271, - modesIndex, regWrites); - else - REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271, - modesIndex, regWrites); - } - REG_WRITE_ARRAY(&ah->iniBB_RfGain, freqIndex, regWrites); if (IS_CHAN_A_FAST_CLOCK(ah, chan)) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 7098cd8eee60..99d2dd979d1c 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -39,12 +39,6 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar9271Modes_9271_1_0_only), 5); INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg, ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 5); - INIT_INI_ARRAY(&ah->iniModes_high_power_tx_gain_9271, - ar9271Modes_high_power_tx_gain_9271, - ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 5); - INIT_INI_ARRAY(&ah->iniModes_normal_power_tx_gain_9271, - ar9271Modes_normal_power_tx_gain_9271, - ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 5); return; } @@ -193,14 +187,10 @@ static void ar9280_20_hw_init_rxgain_ini(struct ath_hw *ah) } } -static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah) +static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah, u32 txgain_type) { - u32 txgain_type; - if (ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) >= AR5416_EEP_MINOR_VER_19) { - txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); - if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9280Modes_high_power_tx_gain_9280_2, @@ -216,8 +206,22 @@ static void ar9280_20_hw_init_txgain_ini(struct ath_hw *ah) } } +static void ar9271_hw_init_txgain_ini(struct ath_hw *ah, u32 txgain_type) +{ + if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) + INIT_INI_ARRAY(&ah->iniModesTxGain, + ar9271Modes_high_power_tx_gain_9271, + ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 5); + else + INIT_INI_ARRAY(&ah->iniModesTxGain, + ar9271Modes_normal_power_tx_gain_9271, + ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 5); +} + static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah) { + u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); + if (AR_SREV_9287_11_OR_LATER(ah)) INIT_INI_ARRAY(&ah->iniModesRxGain, ar9287Modes_rx_gain_9287_1_1, @@ -225,15 +229,15 @@ static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah) else if (AR_SREV_9280_20(ah)) ar9280_20_hw_init_rxgain_ini(ah); - if (AR_SREV_9287_11_OR_LATER(ah)) { + if (AR_SREV_9271(ah)) { + ar9271_hw_init_txgain_ini(ah, txgain_type); + } else if (AR_SREV_9287_11_OR_LATER(ah)) { INIT_INI_ARRAY(&ah->iniModesTxGain, ar9287Modes_tx_gain_9287_1_1, ARRAY_SIZE(ar9287Modes_tx_gain_9287_1_1), 5); } else if (AR_SREV_9280_20(ah)) { - ar9280_20_hw_init_txgain_ini(ah); + ar9280_20_hw_init_txgain_ini(ah, txgain_type); } else if (AR_SREV_9285_12_OR_LATER(ah)) { - u32 txgain_type = ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE); - /* txgain table */ if (txgain_type == AR5416_EEP_TXGAIN_HIGH_POWER) { if (AR_SREV_9285E_20(ah)) { diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 7822d5ecbf8b..ca673a8757d6 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -836,8 +836,6 @@ struct ath_hw { struct ar5416IniArray iniCckfirJapan2484; struct ar5416IniArray ini_japan2484; struct ar5416IniArray iniModes_9271_ANI_reg; - struct ar5416IniArray iniModes_high_power_tx_gain_9271; - struct ar5416IniArray iniModes_normal_power_tx_gain_9271; struct ar5416IniArray ini_radio_post_sys2ant; struct ar5416IniArray ini_BTCOEX_MAX_TXPWR; -- GitLab From c7effd35932b948c2a18159e96a07e1686703e62 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:33 +0100 Subject: [PATCH 1770/1846] ath9k: inline AR9271 1.0 INI overrides Makes them more readable and reduces code size Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 7 ++++--- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 3 --- drivers/net/wireless/ath/ath9k/ar9002_initvals.h | 6 ------ drivers/net/wireless/ath/ath9k/ar9002_phy.h | 2 ++ drivers/net/wireless/ath/ath9k/hw.h | 1 - 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c index 3e108c8b1d32..d7d8e9199140 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c @@ -834,9 +834,10 @@ static int ar5008_hw_process_ini(struct ath_hw *ah, AR_SREV_9287_11_OR_LATER(ah)) REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); - if (AR_SREV_9271_10(ah)) - REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only, - modesIndex, regWrites); + if (AR_SREV_9271_10(ah)) { + REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENA); + REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_ADC_ON, 0xa); + } ENABLE_REGWRITE_BUFFER(ah); diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 99d2dd979d1c..d9a69fc470cd 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -34,9 +34,6 @@ static void ar9002_hw_init_mode_regs(struct ath_hw *ah) ARRAY_SIZE(ar9271Modes_9271), 5); INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, ARRAY_SIZE(ar9271Common_9271), 2); - INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, - ar9271Modes_9271_1_0_only, - ARRAY_SIZE(ar9271Modes_9271_1_0_only), 5); INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg, ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 5); return; diff --git a/drivers/net/wireless/ath/ath9k/ar9002_initvals.h b/drivers/net/wireless/ath/ath9k/ar9002_initvals.h index d571c329ee59..4d18c66a6790 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9002_initvals.h @@ -3092,12 +3092,6 @@ static const u32 ar9271Common_9271[][2] = { {0x0000d384, 0xf3307ff0}, }; -static const u32 ar9271Modes_9271_1_0_only[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009910, 0x30002311, 0x30002311, 0x30002311, 0x30002311}, - {0x00009828, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001}, -}; - static const u32 ar9271Modes_9271_ANI_reg[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00009850, 0x6d4000e2, 0x6d4000e2, 0x6d4000e2, 0x6d4000e2}, diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.h b/drivers/net/wireless/ath/ath9k/ar9002_phy.h index 453af6dc514b..f9eb2c357169 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h @@ -60,6 +60,8 @@ #define AR_PHY_RF_CTL3 0x9828 #define AR_PHY_TX_END_TO_A2_RX_ON 0x00FF0000 #define AR_PHY_TX_END_TO_A2_RX_ON_S 16 +#define AR_PHY_TX_END_TO_ADC_ON 0xFF000000 +#define AR_PHY_TX_END_TO_ADC_ON_S 24 #define AR_PHY_ADC_CTL 0x982C #define AR_PHY_ADC_CTL_OFF_INBUFGAIN 0x00000003 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index ca673a8757d6..aa1680a0c7fd 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -831,7 +831,6 @@ struct ath_hw { struct ar5416IniArray iniAdditional; struct ar5416IniArray iniModesRxGain; struct ar5416IniArray iniModesTxGain; - struct ar5416IniArray iniModes_9271_1_0_only; struct ar5416IniArray iniCckfirNormal; struct ar5416IniArray iniCckfirJapan2484; struct ar5416IniArray ini_japan2484; -- GitLab From 783b732ac61dd6c653cc2367f389a6234db8cc16 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Mar 2012 16:40:34 +0100 Subject: [PATCH 1771/1846] ath9k_hw: remove unused initvals Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- .../wireless/ath/ath9k/ar9003_2p2_initvals.h | 302 ------------------ 1 file changed, 302 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h index 026f9de15d15..46c79a3d4737 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h @@ -295,266 +295,6 @@ static const u32 ar9300_2p2_radio_core[][2] = { {0x00016bd4, 0x00000000}, }; -static const u32 ar9300Common_rx_gain_table_merlin_2p2[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x02000101}, - {0x0000a004, 0x02000102}, - {0x0000a008, 0x02000103}, - {0x0000a00c, 0x02000104}, - {0x0000a010, 0x02000200}, - {0x0000a014, 0x02000201}, - {0x0000a018, 0x02000202}, - {0x0000a01c, 0x02000203}, - {0x0000a020, 0x02000204}, - {0x0000a024, 0x02000205}, - {0x0000a028, 0x02000208}, - {0x0000a02c, 0x02000302}, - {0x0000a030, 0x02000303}, - {0x0000a034, 0x02000304}, - {0x0000a038, 0x02000400}, - {0x0000a03c, 0x02010300}, - {0x0000a040, 0x02010301}, - {0x0000a044, 0x02010302}, - {0x0000a048, 0x02000500}, - {0x0000a04c, 0x02010400}, - {0x0000a050, 0x02020300}, - {0x0000a054, 0x02020301}, - {0x0000a058, 0x02020302}, - {0x0000a05c, 0x02020303}, - {0x0000a060, 0x02020400}, - {0x0000a064, 0x02030300}, - {0x0000a068, 0x02030301}, - {0x0000a06c, 0x02030302}, - {0x0000a070, 0x02030303}, - {0x0000a074, 0x02030400}, - {0x0000a078, 0x02040300}, - {0x0000a07c, 0x02040301}, - {0x0000a080, 0x02040302}, - {0x0000a084, 0x02040303}, - {0x0000a088, 0x02030500}, - {0x0000a08c, 0x02040400}, - {0x0000a090, 0x02050203}, - {0x0000a094, 0x02050204}, - {0x0000a098, 0x02050205}, - {0x0000a09c, 0x02040500}, - {0x0000a0a0, 0x02050301}, - {0x0000a0a4, 0x02050302}, - {0x0000a0a8, 0x02050303}, - {0x0000a0ac, 0x02050400}, - {0x0000a0b0, 0x02050401}, - {0x0000a0b4, 0x02050402}, - {0x0000a0b8, 0x02050403}, - {0x0000a0bc, 0x02050500}, - {0x0000a0c0, 0x02050501}, - {0x0000a0c4, 0x02050502}, - {0x0000a0c8, 0x02050503}, - {0x0000a0cc, 0x02050504}, - {0x0000a0d0, 0x02050600}, - {0x0000a0d4, 0x02050601}, - {0x0000a0d8, 0x02050602}, - {0x0000a0dc, 0x02050603}, - {0x0000a0e0, 0x02050604}, - {0x0000a0e4, 0x02050700}, - {0x0000a0e8, 0x02050701}, - {0x0000a0ec, 0x02050702}, - {0x0000a0f0, 0x02050703}, - {0x0000a0f4, 0x02050704}, - {0x0000a0f8, 0x02050705}, - {0x0000a0fc, 0x02050708}, - {0x0000a100, 0x02050709}, - {0x0000a104, 0x0205070a}, - {0x0000a108, 0x0205070b}, - {0x0000a10c, 0x0205070c}, - {0x0000a110, 0x0205070d}, - {0x0000a114, 0x02050710}, - {0x0000a118, 0x02050711}, - {0x0000a11c, 0x02050712}, - {0x0000a120, 0x02050713}, - {0x0000a124, 0x02050714}, - {0x0000a128, 0x02050715}, - {0x0000a12c, 0x02050730}, - {0x0000a130, 0x02050731}, - {0x0000a134, 0x02050732}, - {0x0000a138, 0x02050733}, - {0x0000a13c, 0x02050734}, - {0x0000a140, 0x02050735}, - {0x0000a144, 0x02050750}, - {0x0000a148, 0x02050751}, - {0x0000a14c, 0x02050752}, - {0x0000a150, 0x02050753}, - {0x0000a154, 0x02050754}, - {0x0000a158, 0x02050755}, - {0x0000a15c, 0x02050770}, - {0x0000a160, 0x02050771}, - {0x0000a164, 0x02050772}, - {0x0000a168, 0x02050773}, - {0x0000a16c, 0x02050774}, - {0x0000a170, 0x02050775}, - {0x0000a174, 0x00000776}, - {0x0000a178, 0x00000776}, - {0x0000a17c, 0x00000776}, - {0x0000a180, 0x00000776}, - {0x0000a184, 0x00000776}, - {0x0000a188, 0x00000776}, - {0x0000a18c, 0x00000776}, - {0x0000a190, 0x00000776}, - {0x0000a194, 0x00000776}, - {0x0000a198, 0x00000776}, - {0x0000a19c, 0x00000776}, - {0x0000a1a0, 0x00000776}, - {0x0000a1a4, 0x00000776}, - {0x0000a1a8, 0x00000776}, - {0x0000a1ac, 0x00000776}, - {0x0000a1b0, 0x00000776}, - {0x0000a1b4, 0x00000776}, - {0x0000a1b8, 0x00000776}, - {0x0000a1bc, 0x00000776}, - {0x0000a1c0, 0x00000776}, - {0x0000a1c4, 0x00000776}, - {0x0000a1c8, 0x00000776}, - {0x0000a1cc, 0x00000776}, - {0x0000a1d0, 0x00000776}, - {0x0000a1d4, 0x00000776}, - {0x0000a1d8, 0x00000776}, - {0x0000a1dc, 0x00000776}, - {0x0000a1e0, 0x00000776}, - {0x0000a1e4, 0x00000776}, - {0x0000a1e8, 0x00000776}, - {0x0000a1ec, 0x00000776}, - {0x0000a1f0, 0x00000776}, - {0x0000a1f4, 0x00000776}, - {0x0000a1f8, 0x00000776}, - {0x0000a1fc, 0x00000776}, - {0x0000b000, 0x02000101}, - {0x0000b004, 0x02000102}, - {0x0000b008, 0x02000103}, - {0x0000b00c, 0x02000104}, - {0x0000b010, 0x02000200}, - {0x0000b014, 0x02000201}, - {0x0000b018, 0x02000202}, - {0x0000b01c, 0x02000203}, - {0x0000b020, 0x02000204}, - {0x0000b024, 0x02000205}, - {0x0000b028, 0x02000208}, - {0x0000b02c, 0x02000302}, - {0x0000b030, 0x02000303}, - {0x0000b034, 0x02000304}, - {0x0000b038, 0x02000400}, - {0x0000b03c, 0x02010300}, - {0x0000b040, 0x02010301}, - {0x0000b044, 0x02010302}, - {0x0000b048, 0x02000500}, - {0x0000b04c, 0x02010400}, - {0x0000b050, 0x02020300}, - {0x0000b054, 0x02020301}, - {0x0000b058, 0x02020302}, - {0x0000b05c, 0x02020303}, - {0x0000b060, 0x02020400}, - {0x0000b064, 0x02030300}, - {0x0000b068, 0x02030301}, - {0x0000b06c, 0x02030302}, - {0x0000b070, 0x02030303}, - {0x0000b074, 0x02030400}, - {0x0000b078, 0x02040300}, - {0x0000b07c, 0x02040301}, - {0x0000b080, 0x02040302}, - {0x0000b084, 0x02040303}, - {0x0000b088, 0x02030500}, - {0x0000b08c, 0x02040400}, - {0x0000b090, 0x02050203}, - {0x0000b094, 0x02050204}, - {0x0000b098, 0x02050205}, - {0x0000b09c, 0x02040500}, - {0x0000b0a0, 0x02050301}, - {0x0000b0a4, 0x02050302}, - {0x0000b0a8, 0x02050303}, - {0x0000b0ac, 0x02050400}, - {0x0000b0b0, 0x02050401}, - {0x0000b0b4, 0x02050402}, - {0x0000b0b8, 0x02050403}, - {0x0000b0bc, 0x02050500}, - {0x0000b0c0, 0x02050501}, - {0x0000b0c4, 0x02050502}, - {0x0000b0c8, 0x02050503}, - {0x0000b0cc, 0x02050504}, - {0x0000b0d0, 0x02050600}, - {0x0000b0d4, 0x02050601}, - {0x0000b0d8, 0x02050602}, - {0x0000b0dc, 0x02050603}, - {0x0000b0e0, 0x02050604}, - {0x0000b0e4, 0x02050700}, - {0x0000b0e8, 0x02050701}, - {0x0000b0ec, 0x02050702}, - {0x0000b0f0, 0x02050703}, - {0x0000b0f4, 0x02050704}, - {0x0000b0f8, 0x02050705}, - {0x0000b0fc, 0x02050708}, - {0x0000b100, 0x02050709}, - {0x0000b104, 0x0205070a}, - {0x0000b108, 0x0205070b}, - {0x0000b10c, 0x0205070c}, - {0x0000b110, 0x0205070d}, - {0x0000b114, 0x02050710}, - {0x0000b118, 0x02050711}, - {0x0000b11c, 0x02050712}, - {0x0000b120, 0x02050713}, - {0x0000b124, 0x02050714}, - {0x0000b128, 0x02050715}, - {0x0000b12c, 0x02050730}, - {0x0000b130, 0x02050731}, - {0x0000b134, 0x02050732}, - {0x0000b138, 0x02050733}, - {0x0000b13c, 0x02050734}, - {0x0000b140, 0x02050735}, - {0x0000b144, 0x02050750}, - {0x0000b148, 0x02050751}, - {0x0000b14c, 0x02050752}, - {0x0000b150, 0x02050753}, - {0x0000b154, 0x02050754}, - {0x0000b158, 0x02050755}, - {0x0000b15c, 0x02050770}, - {0x0000b160, 0x02050771}, - {0x0000b164, 0x02050772}, - {0x0000b168, 0x02050773}, - {0x0000b16c, 0x02050774}, - {0x0000b170, 0x02050775}, - {0x0000b174, 0x00000776}, - {0x0000b178, 0x00000776}, - {0x0000b17c, 0x00000776}, - {0x0000b180, 0x00000776}, - {0x0000b184, 0x00000776}, - {0x0000b188, 0x00000776}, - {0x0000b18c, 0x00000776}, - {0x0000b190, 0x00000776}, - {0x0000b194, 0x00000776}, - {0x0000b198, 0x00000776}, - {0x0000b19c, 0x00000776}, - {0x0000b1a0, 0x00000776}, - {0x0000b1a4, 0x00000776}, - {0x0000b1a8, 0x00000776}, - {0x0000b1ac, 0x00000776}, - {0x0000b1b0, 0x00000776}, - {0x0000b1b4, 0x00000776}, - {0x0000b1b8, 0x00000776}, - {0x0000b1bc, 0x00000776}, - {0x0000b1c0, 0x00000776}, - {0x0000b1c4, 0x00000776}, - {0x0000b1c8, 0x00000776}, - {0x0000b1cc, 0x00000776}, - {0x0000b1d0, 0x00000776}, - {0x0000b1d4, 0x00000776}, - {0x0000b1d8, 0x00000776}, - {0x0000b1dc, 0x00000776}, - {0x0000b1e0, 0x00000776}, - {0x0000b1e4, 0x00000776}, - {0x0000b1e8, 0x00000776}, - {0x0000b1ec, 0x00000776}, - {0x0000b1f0, 0x00000776}, - {0x0000b1f4, 0x00000776}, - {0x0000b1f8, 0x00000776}, - {0x0000b1fc, 0x00000776}, -}; - static const u32 ar9300_2p2_mac_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160}, @@ -572,48 +312,6 @@ static const u32 ar9300_2p2_soc_postamble[][5] = { {0x00007010, 0x00000023, 0x00000023, 0x00000023, 0x00000023}, }; -static const u32 ar9200_merlin_2p2_radio_core[][2] = { - /* Addr allmodes */ - {0x00007800, 0x00040000}, - {0x00007804, 0xdb005012}, - {0x00007808, 0x04924914}, - {0x0000780c, 0x21084210}, - {0x00007810, 0x6d801300}, - {0x00007814, 0x0019beff}, - {0x00007818, 0x07e41000}, - {0x0000781c, 0x00392000}, - {0x00007820, 0x92592480}, - {0x00007824, 0x00040000}, - {0x00007828, 0xdb005012}, - {0x0000782c, 0x04924914}, - {0x00007830, 0x21084210}, - {0x00007834, 0x6d801300}, - {0x00007838, 0x0019beff}, - {0x0000783c, 0x07e40000}, - {0x00007840, 0x00392000}, - {0x00007844, 0x92592480}, - {0x00007848, 0x00100000}, - {0x0000784c, 0x773f0567}, - {0x00007850, 0x54214514}, - {0x00007854, 0x12035828}, - {0x00007858, 0x92592692}, - {0x0000785c, 0x00000000}, - {0x00007860, 0x56400000}, - {0x00007864, 0x0a8e370e}, - {0x00007868, 0xc0102850}, - {0x0000786c, 0x812d4000}, - {0x00007870, 0x807ec400}, - {0x00007874, 0x001b6db0}, - {0x00007878, 0x00376b63}, - {0x0000787c, 0x06db6db6}, - {0x00007880, 0x006d8000}, - {0x00007884, 0xffeffffe}, - {0x00007888, 0xffeffffe}, - {0x0000788c, 0x00010000}, - {0x00007890, 0x02060aeb}, - {0x00007894, 0x5a108000}, -}; - static const u32 ar9300_2p2_baseband_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, -- GitLab From 377526578f2c343ea281a918b18ece1fca65005c Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 14 Mar 2012 22:34:33 +0000 Subject: [PATCH 1772/1846] libertas: remove dump_survey implementation libertas provides a dump_survey implementation based on reading of a RSSI value. However, this RSSI value is calculated based on the last received beacon from the associated AP - it is not a good way of surveying a channel in general, and even causes an error if the card is not associated to a network. As this is not appropriate as a survey, remove it. This fixes an issue where something in userspace is repeatedly calling site-survey during boot, resulting in many repeated errors as the RSSI value cannot be read before associating. Signed-off-by: Daniel Drake Signed-off-by: John W. Linville --- drivers/net/wireless/libertas/cfg.c | 37 ----------------------------- 1 file changed, 37 deletions(-) diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index a7cd311cb1b7..3fa1ecebadfd 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c @@ -1630,42 +1630,6 @@ static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev, -/* - * "Site survey", here just current channel and noise level - */ - -static int lbs_get_survey(struct wiphy *wiphy, struct net_device *dev, - int idx, struct survey_info *survey) -{ - struct lbs_private *priv = wiphy_priv(wiphy); - s8 signal, noise; - int ret; - - if (dev == priv->mesh_dev) - return -EOPNOTSUPP; - - if (idx != 0) - ret = -ENOENT; - - lbs_deb_enter(LBS_DEB_CFG80211); - - survey->channel = ieee80211_get_channel(wiphy, - ieee80211_channel_to_frequency(priv->channel, - IEEE80211_BAND_2GHZ)); - - ret = lbs_get_rssi(priv, &signal, &noise); - if (ret == 0) { - survey->filled = SURVEY_INFO_NOISE_DBM; - survey->noise = noise; - } - - lbs_deb_leave_args(LBS_DEB_CFG80211, "ret %d", ret); - return ret; -} - - - - /* * Change interface */ @@ -2068,7 +2032,6 @@ static struct cfg80211_ops lbs_cfg80211_ops = { .del_key = lbs_cfg_del_key, .set_default_key = lbs_cfg_set_default_key, .get_station = lbs_cfg_get_station, - .dump_survey = lbs_get_survey, .change_virtual_intf = lbs_change_intf, .join_ibss = lbs_join_ibss, .leave_ibss = lbs_leave_ibss, -- GitLab From d8a0f1b0af67679bba886784de10d8c21acc4e0e Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Fri, 6 Jan 2012 13:51:03 -0500 Subject: [PATCH 1773/1846] gianfar: Add support for byte queue limits. Add support for byte queue limits (BQL), based on the similar modifications made to intel/igb/igb_main.c from Eric Dumazet in commit bdbc063129e811264cd6c311d8c2d9b95de01231 "igb: Add support for byte queue limits." A local variable for tx_queue->qindex was introduced in gfar_clean_tx_ring, since it is now used often enough to warrant it, and it cleans up the readability somewhat as well. Signed-off-by: Paul Gortmaker --- drivers/net/ethernet/freescale/gianfar.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index adb0ae4e4195..a4c934bbea17 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -1755,9 +1755,12 @@ static void free_skb_resources(struct gfar_private *priv) /* Go through all the buffer descriptors and free their data buffers */ for (i = 0; i < priv->num_tx_queues; i++) { + struct netdev_queue *txq; tx_queue = priv->tx_queue[i]; + txq = netdev_get_tx_queue(tx_queue->dev, tx_queue->qindex); if(tx_queue->tx_skbuff) free_skb_tx_queue(tx_queue); + netdev_tx_reset_queue(txq); } for (i = 0; i < priv->num_rx_queues; i++) { @@ -2217,6 +2220,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb); } + netdev_tx_sent_queue(txq, skb->len); + /* * We can work in parallel with gfar_clean_tx_ring(), except * when modifying num_txbdfree. Note that we didn't grab the lock @@ -2460,6 +2465,7 @@ static void gfar_align_skb(struct sk_buff *skb) static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) { struct net_device *dev = tx_queue->dev; + struct netdev_queue *txq; struct gfar_private *priv = netdev_priv(dev); struct gfar_priv_rx_q *rx_queue = NULL; struct txbd8 *bdp, *next = NULL; @@ -2471,10 +2477,13 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) int frags = 0, nr_txbds = 0; int i; int howmany = 0; + int tqi = tx_queue->qindex; + unsigned int bytes_sent = 0; u32 lstatus; size_t buflen; - rx_queue = priv->rx_queue[tx_queue->qindex]; + rx_queue = priv->rx_queue[tqi]; + txq = netdev_get_tx_queue(dev, tqi); bdp = tx_queue->dirty_tx; skb_dirtytx = tx_queue->skb_dirtytx; @@ -2533,6 +2542,8 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) bdp = next_txbd(bdp, base, tx_ring_size); } + bytes_sent += skb->len; + /* * If there's room in the queue (limit it to rx_buffer_size) * we add this skb back into the pool, if it's the right size @@ -2557,13 +2568,15 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) } /* If we freed a buffer, we can restart transmission, if necessary */ - if (__netif_subqueue_stopped(dev, tx_queue->qindex) && tx_queue->num_txbdfree) - netif_wake_subqueue(dev, tx_queue->qindex); + if (__netif_subqueue_stopped(dev, tqi) && tx_queue->num_txbdfree) + netif_wake_subqueue(dev, tqi); /* Update dirty indicators */ tx_queue->skb_dirtytx = skb_dirtytx; tx_queue->dirty_tx = bdp; + netdev_tx_completed_queue(txq, howmany, bytes_sent); + return howmany; } -- GitLab From 30f7e310668b432952bedbc2d0df8edeb32f2e9f Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 8 Jan 2012 13:21:57 -0500 Subject: [PATCH 1774/1846] gianfar: constify giant block of status descriptor strings Signed-off-by: Paul Gortmaker --- drivers/net/ethernet/freescale/gianfar_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c index 5a78d55f46e7..8d74efd04bb9 100644 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c @@ -58,7 +58,7 @@ static void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rv static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals); static void gfar_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo); -static char stat_gstrings[][ETH_GSTRING_LEN] = { +static const char stat_gstrings[][ETH_GSTRING_LEN] = { "rx-dropped-by-kernel", "rx-large-frame-errors", "rx-short-frame-errors", -- GitLab From 1571df8f2d470a2b0cb3d48ffdffbc83c5924ef5 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 8 Jan 2012 14:23:10 -0500 Subject: [PATCH 1775/1846] gianfar: delete orphaned version strings and dead macros There were two version strings, and neither one was being used. Also in the same proximity were some unused #define that were left over from the past. Delete them all. Signed-off-by: Paul Gortmaker --- drivers/net/ethernet/freescale/gianfar.c | 3 --- drivers/net/ethernet/freescale/gianfar.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index a4c934bbea17..6e66cc35c970 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -104,10 +104,7 @@ #include "fsl_pq_mdio.h" #define TX_TIMEOUT (1*HZ) -#undef BRIEF_GFAR_ERRORS -#undef VERBOSE_GFAR_ERRORS -const char gfar_driver_name[] = "Gianfar Ethernet"; const char gfar_driver_version[] = "1.3"; static int gfar_enet_open(struct net_device *dev); diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h index 4fe0f342acec..fc2488adca36 100644 --- a/drivers/net/ethernet/freescale/gianfar.h +++ b/drivers/net/ethernet/freescale/gianfar.h @@ -78,11 +78,8 @@ struct ethtool_rx_list { #define INCREMENTAL_BUFFER_SIZE 512 #define PHY_INIT_TIMEOUT 100000 -#define GFAR_PHY_CHANGE_TIME 2 -#define DEVICE_NAME "%s: Gianfar Ethernet Controller Version 1.2, " #define DRV_NAME "gfar-enet" -extern const char gfar_driver_name[]; extern const char gfar_driver_version[]; /* MAXIMUM NUMBER OF QUEUES SUPPORTED */ -- GitLab From a9e0aca4b37885b5599e52211f098bd7f565e749 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 14 Mar 2012 20:18:32 +0000 Subject: [PATCH 1776/1846] asix: asix_rx_fixup surgery to reduce skb truesizes asix_rx_fixup() is complex, and does some unnecessary memory copies (at least on x86 where NET_IP_ALIGN is 0) Also, it tends to provide skbs with a big truesize (4096+256 with MTU=1500) to upper stack, so incoming trafic consume a lot of memory and I noticed early packet drops because we hit socket rcvbuf too fast. Switch to a different strategy, using copybreak so that we provide nice skbs to upper stack (including the NET_SKB_PAD to avoid future head reallocations in some paths) With this patch, I no longer see packets drops or tcp collapses on various tcp workload with a AX88772 adapter. Signed-off-by: Eric Dumazet Cc: Aurelien Jacobs Cc: Greg Kroah-Hartman Cc: Trond Wuellner Cc: Grant Grundler Cc: Paul Stewart Reviewed-by: Grant Grundler Reviewed-by: Grant Grundler Signed-off-by: David S. Miller --- drivers/net/usb/asix.c | 88 ++++++++++-------------------------------- 1 file changed, 20 insertions(+), 68 deletions(-) diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index 8e84f5bdd6ca..25fe1838d886 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c @@ -305,88 +305,40 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { - u8 *head; - u32 header; - char *packet; - struct sk_buff *ax_skb; - u16 size; + int offset = 0; - head = (u8 *) skb->data; - memcpy(&header, head, sizeof(header)); - le32_to_cpus(&header); - packet = head + sizeof(header); + while (offset + sizeof(u32) < skb->len) { + struct sk_buff *ax_skb; + u16 size; + u32 header = get_unaligned_le32(skb->data + offset); - skb_pull(skb, 4); - - while (skb->len > 0) { - if ((header & 0x07ff) != ((~header >> 16) & 0x07ff)) - netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n"); + offset += sizeof(u32); /* get the packet length */ - size = (u16) (header & 0x000007ff); - - if ((skb->len) - ((size + 1) & 0xfffe) == 0) { - u8 alignment = (unsigned long)skb->data & 0x3; - if (alignment != 0x2) { - /* - * not 16bit aligned so use the room provided by - * the 32 bit header to align the data - * - * note we want 16bit alignment as MAC header is - * 14bytes thus ip header will be aligned on - * 32bit boundary so accessing ipheader elements - * using a cast to struct ip header wont cause - * an unaligned accesses. - */ - u8 realignment = (alignment + 2) & 0x3; - memmove(skb->data - realignment, - skb->data, - size); - skb->data -= realignment; - skb_set_tail_pointer(skb, size); - } - return 2; + size = (u16) (header & 0x7ff); + if (size != ((~header >> 16) & 0x07ff)) { + netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n"); + return 0; } - if (size > dev->net->mtu + ETH_HLEN) { + if ((size > dev->net->mtu + ETH_HLEN) || + (size + offset > skb->len)) { netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", size); return 0; } - ax_skb = skb_clone(skb, GFP_ATOMIC); - if (ax_skb) { - u8 alignment = (unsigned long)packet & 0x3; - ax_skb->len = size; - - if (alignment != 0x2) { - /* - * not 16bit aligned use the room provided by - * the 32 bit header to align the data - */ - u8 realignment = (alignment + 2) & 0x3; - memmove(packet - realignment, packet, size); - packet -= realignment; - } - ax_skb->data = packet; - skb_set_tail_pointer(ax_skb, size); - usbnet_skb_return(dev, ax_skb); - } else { + ax_skb = netdev_alloc_skb_ip_align(dev->net, size); + if (!ax_skb) return 0; - } - - skb_pull(skb, (size + 1) & 0xfffe); - if (skb->len < sizeof(header)) - break; + skb_put(ax_skb, size); + memcpy(ax_skb->data, skb->data + offset, size); + usbnet_skb_return(dev, ax_skb); - head = (u8 *) skb->data; - memcpy(&header, head, sizeof(header)); - le32_to_cpus(&header); - packet = head + sizeof(header); - skb_pull(skb, 4); + offset += (size + 1) & 0xfffe; } - if (skb->len < 0) { + if (skb->len != offset) { netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d\n", skb->len); return 0; @@ -1541,7 +1493,7 @@ static const struct driver_info ax88772_info = { .status = asix_status, .link_reset = ax88772_link_reset, .reset = ax88772_reset, - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET, .rx_fixup = asix_rx_fixup, .tx_fixup = asix_tx_fixup, }; -- GitLab From c84ff1d6dff38058a5bd20cb633d13a0f685788a Mon Sep 17 00:00:00 2001 From: Alexey Orishko Date: Wed, 14 Mar 2012 11:26:10 +0000 Subject: [PATCH 1777/1846] cdc_ncm: reduce driver latency in the data path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - use high resolution timer latency became approx. 10-15 times less than before - use taklet for sending remaining data in tx path Tested on Intel/ARM. Reviewed-by: Sjur Brændeland Tested-by: Dmitry Tarnyagin Signed-off-by: Alexey Orishko Signed-off-by: David S. Miller --- drivers/net/usb/cdc_ncm.c | 94 +++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 81f86b8ea551..a8e2a62c2958 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -1,7 +1,7 @@ /* * cdc_ncm.c * - * Copyright (C) ST-Ericsson 2010-2011 + * Copyright (C) ST-Ericsson 2010-2012 * Contact: Alexey Orishko * Original author: Hans Petter Selasky * @@ -47,13 +47,12 @@ #include #include #include -#include -#include +#include #include #include #include -#define DRIVER_VERSION "04-Aug-2011" +#define DRIVER_VERSION "14-Mar-2012" /* CDC NCM subclass 3.2.1 */ #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 @@ -81,6 +80,8 @@ /* Restart the timer, if amount of datagrams is less than given value */ #define CDC_NCM_RESTART_TIMER_DATAGRAM_CNT 3 +#define CDC_NCM_TIMER_PENDING_CNT 2 +#define CDC_NCM_TIMER_INTERVAL (400UL * NSEC_PER_USEC) /* The following macro defines the minimum header space */ #define CDC_NCM_MIN_HDR_SIZE \ @@ -97,7 +98,8 @@ struct cdc_ncm_ctx { struct cdc_ncm_data rx_ncm; struct cdc_ncm_data tx_ncm; struct usb_cdc_ncm_ntb_parameters ncm_parm; - struct timer_list tx_timer; + struct hrtimer tx_timer; + struct tasklet_struct bh; const struct usb_cdc_ncm_desc *func_desc; const struct usb_cdc_header_desc *header_desc; @@ -117,6 +119,7 @@ struct cdc_ncm_ctx { struct sk_buff *tx_rem_skb; spinlock_t mtx; + atomic_t stop; u32 tx_timer_pending; u32 tx_curr_offset; @@ -135,7 +138,9 @@ struct cdc_ncm_ctx { u16 connected; }; -static void cdc_ncm_tx_timeout(unsigned long arg); +static void cdc_ncm_txpath_bh(unsigned long param); +static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx); +static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer); static const struct driver_info cdc_ncm_info; static struct usb_driver cdc_ncm_driver; static const struct ethtool_ops cdc_ncm_ethtool_ops; @@ -441,8 +446,6 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) if (ctx == NULL) return; - del_timer_sync(&ctx->tx_timer); - if (ctx->tx_rem_skb != NULL) { dev_kfree_skb_any(ctx->tx_rem_skb); ctx->tx_rem_skb = NULL; @@ -469,7 +472,11 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf) if (ctx == NULL) return -ENODEV; - init_timer(&ctx->tx_timer); + hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + ctx->tx_timer.function = &cdc_ncm_tx_timer_cb; + ctx->bh.data = (unsigned long)ctx; + ctx->bh.func = cdc_ncm_txpath_bh; + atomic_set(&ctx->stop, 0); spin_lock_init(&ctx->mtx); ctx->netdev = dev->net; @@ -617,6 +624,13 @@ static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf) if (ctx == NULL) return; /* no setup */ + atomic_set(&ctx->stop, 1); + + if (hrtimer_active(&ctx->tx_timer)) + hrtimer_cancel(&ctx->tx_timer); + + tasklet_kill(&ctx->bh); + /* disconnect master --> disconnect slave */ if (intf == ctx->control && ctx->data) { usb_set_intfdata(ctx->data, NULL); @@ -787,7 +801,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb) ctx->tx_curr_last_offset = last_offset; /* set the pending count */ if (n < CDC_NCM_RESTART_TIMER_DATAGRAM_CNT) - ctx->tx_timer_pending = 2; + ctx->tx_timer_pending = CDC_NCM_TIMER_PENDING_CNT; goto exit_no_skb; } else { @@ -867,44 +881,49 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb) /* return skb */ ctx->tx_curr_skb = NULL; + ctx->netdev->stats.tx_packets += ctx->tx_curr_frame_num; return skb_out; exit_no_skb: + /* Start timer, if there is a remaining skb */ + if (ctx->tx_curr_skb != NULL) + cdc_ncm_tx_timeout_start(ctx); return NULL; } static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx) { /* start timer, if not already started */ - if (timer_pending(&ctx->tx_timer) == 0) { - ctx->tx_timer.function = &cdc_ncm_tx_timeout; - ctx->tx_timer.data = (unsigned long)ctx; - ctx->tx_timer.expires = jiffies + ((HZ + 999) / 1000); - add_timer(&ctx->tx_timer); - } + if (!(hrtimer_active(&ctx->tx_timer) || atomic_read(&ctx->stop))) + hrtimer_start(&ctx->tx_timer, + ktime_set(0, CDC_NCM_TIMER_INTERVAL), + HRTIMER_MODE_REL); } -static void cdc_ncm_tx_timeout(unsigned long arg) +static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer) { - struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)arg; - u8 restart; + struct cdc_ncm_ctx *ctx = + container_of(timer, struct cdc_ncm_ctx, tx_timer); - spin_lock(&ctx->mtx); - if (ctx->tx_timer_pending != 0) { - ctx->tx_timer_pending--; - restart = 1; - } else { - restart = 0; - } + if (!atomic_read(&ctx->stop)) + tasklet_schedule(&ctx->bh); + return HRTIMER_NORESTART; +} - spin_unlock(&ctx->mtx); +static void cdc_ncm_txpath_bh(unsigned long param) +{ + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)param; - if (restart) { - spin_lock(&ctx->mtx); + spin_lock_bh(&ctx->mtx); + if (ctx->tx_timer_pending != 0) { + ctx->tx_timer_pending--; cdc_ncm_tx_timeout_start(ctx); - spin_unlock(&ctx->mtx); + spin_unlock_bh(&ctx->mtx); } else if (ctx->netdev != NULL) { + spin_unlock_bh(&ctx->mtx); + netif_tx_lock_bh(ctx->netdev); usbnet_start_xmit(NULL, ctx->netdev); + netif_tx_unlock_bh(ctx->netdev); } } @@ -913,7 +932,6 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) { struct sk_buff *skb_out; struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; - u8 need_timer = 0; /* * The Ethernet API we are using does not support transmitting @@ -925,19 +943,9 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) if (ctx == NULL) goto error; - spin_lock(&ctx->mtx); + spin_lock_bh(&ctx->mtx); skb_out = cdc_ncm_fill_tx_frame(ctx, skb); - if (ctx->tx_curr_skb != NULL) - need_timer = 1; - - /* Start timer, if there is a remaining skb */ - if (need_timer) - cdc_ncm_tx_timeout_start(ctx); - - if (skb_out) - dev->net->stats.tx_packets += ctx->tx_curr_frame_num; - - spin_unlock(&ctx->mtx); + spin_unlock_bh(&ctx->mtx); return skb_out; error: -- GitLab From 3f658cde9401bd45429ee720cf2c69f0bc5547b9 Mon Sep 17 00:00:00 2001 From: Alexey Orishko Date: Wed, 14 Mar 2012 11:26:11 +0000 Subject: [PATCH 1778/1846] cdc_ncm: fix MTU and max_datagram_size handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes/fixes: - inform device if max_datagram_size was changed by host - max_datagram_size can't be bigger MTU in ETH func descr - fix constants definitions to enable running CAIF service over NCM Tested on Intel/ARM. Reviewed-by: Sjur Brændeland Tested-by: Dmitry Tarnyagin Signed-off-by: Alexey Orishko Signed-off-by: David S. Miller --- drivers/net/usb/cdc_ncm.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index a8e2a62c2958..f8f194658412 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -58,8 +58,8 @@ #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 /* Maximum NTB length */ -#define CDC_NCM_NTB_MAX_SIZE_TX 16384 /* bytes */ -#define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */ +#define CDC_NCM_NTB_MAX_SIZE_TX 32768 /* bytes */ +#define CDC_NCM_NTB_MAX_SIZE_RX 32768 /* bytes */ /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ #define CDC_NCM_MIN_DATAGRAM_SIZE 1514 /* bytes */ @@ -67,13 +67,13 @@ #define CDC_NCM_MIN_TX_PKT 512 /* bytes */ /* Default value for MaxDatagramSize */ -#define CDC_NCM_MAX_DATAGRAM_SIZE 2048 /* bytes */ +#define CDC_NCM_MAX_DATAGRAM_SIZE 8192 /* bytes */ /* * Maximum amount of datagrams in NCM Datagram Pointer Table, not counting * the last NULL entry. Any additional datagrams in NTB would be discarded. */ -#define CDC_NCM_DPT_DATAGRAMS_MAX 32 +#define CDC_NCM_DPT_DATAGRAMS_MAX 40 /* Maximum amount of IN datagrams in NTB */ #define CDC_NCM_DPT_DATAGRAMS_IN_MAX 0 /* unlimited */ @@ -366,27 +366,25 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx) if (err < 0) { pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n", CDC_NCM_MIN_DATAGRAM_SIZE); - kfree(max_datagram_size); } else { ctx->max_datagram_size = le16_to_cpu(*max_datagram_size); /* Check Eth descriptor value */ - if (eth_max_sz < CDC_NCM_MAX_DATAGRAM_SIZE) { - if (ctx->max_datagram_size > eth_max_sz) + if (ctx->max_datagram_size > eth_max_sz) ctx->max_datagram_size = eth_max_sz; - } else { - if (ctx->max_datagram_size > - CDC_NCM_MAX_DATAGRAM_SIZE) - ctx->max_datagram_size = + + if (ctx->max_datagram_size > CDC_NCM_MAX_DATAGRAM_SIZE) + ctx->max_datagram_size = CDC_NCM_MAX_DATAGRAM_SIZE; - } if (ctx->max_datagram_size < CDC_NCM_MIN_DATAGRAM_SIZE) ctx->max_datagram_size = CDC_NCM_MIN_DATAGRAM_SIZE; /* if value changed, update device */ - err = usb_control_msg(ctx->udev, + if (ctx->max_datagram_size != + le16_to_cpu(*max_datagram_size)) { + err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0), USB_CDC_SET_MAX_DATAGRAM_SIZE, USB_TYPE_CLASS | USB_DIR_OUT @@ -394,14 +392,14 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx) 0, iface_no, max_datagram_size, 2, 1000); - kfree(max_datagram_size); -max_dgram_err: - if (err < 0) - pr_debug("SET_MAX_DATAGRAM_SIZE failed\n"); + if (err < 0) + pr_debug("SET_MAX_DGRAM_SIZE failed\n"); + } } - + kfree(max_datagram_size); } +max_dgram_err: if (ctx->netdev->mtu != (ctx->max_datagram_size - ETH_HLEN)) ctx->netdev->mtu = ctx->max_datagram_size - ETH_HLEN; -- GitLab From d5ddb4a59ed43b4c569b4efa8b508d50ef140cc6 Mon Sep 17 00:00:00 2001 From: Alexey Orishko Date: Wed, 14 Mar 2012 11:26:12 +0000 Subject: [PATCH 1779/1846] cdc_ncm: avoid discarding datagrams in rx path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - removed a limit for amount of datagrams for IN NTB - using pointer to traverse NTB in rx_fixup() - renamed "temp" to "len" in rx_fixup() - do NTB sequence number check in rx path Tested on Intel/ARM. Reviewed-by: Sjur Brændeland Tested-by: Dmitry Tarnyagin Signed-off-by: Alexey Orishko Signed-off-by: David S. Miller --- drivers/net/usb/cdc_ncm.c | 102 ++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index f8f194658412..7adc9f6b0ea1 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -71,13 +71,10 @@ /* * Maximum amount of datagrams in NCM Datagram Pointer Table, not counting - * the last NULL entry. Any additional datagrams in NTB would be discarded. + * the last NULL entry. */ #define CDC_NCM_DPT_DATAGRAMS_MAX 40 -/* Maximum amount of IN datagrams in NTB */ -#define CDC_NCM_DPT_DATAGRAMS_IN_MAX 0 /* unlimited */ - /* Restart the timer, if amount of datagrams is less than given value */ #define CDC_NCM_RESTART_TIMER_DATAGRAM_CNT 3 #define CDC_NCM_TIMER_PENDING_CNT 2 @@ -95,7 +92,6 @@ struct cdc_ncm_data { }; struct cdc_ncm_ctx { - struct cdc_ncm_data rx_ncm; struct cdc_ncm_data tx_ncm; struct usb_cdc_ncm_ntb_parameters ncm_parm; struct hrtimer tx_timer; @@ -135,6 +131,7 @@ struct cdc_ncm_ctx { u16 tx_modulus; u16 tx_ndp_modulus; u16 tx_seq; + u16 rx_seq; u16 connected; }; @@ -956,108 +953,103 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in) { struct sk_buff *skb; - struct cdc_ncm_ctx *ctx; - int sumlen; - int actlen; - int temp; + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; + int len; int nframes; int x; int offset; + struct usb_cdc_ncm_nth16 *nth16; + struct usb_cdc_ncm_ndp16 *ndp16; + struct usb_cdc_ncm_dpe16 *dpe16; - ctx = (struct cdc_ncm_ctx *)dev->data[0]; if (ctx == NULL) goto error; - actlen = skb_in->len; - sumlen = CDC_NCM_NTB_MAX_SIZE_RX; - - if (actlen < (sizeof(ctx->rx_ncm.nth16) + sizeof(ctx->rx_ncm.ndp16))) { + if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) + + sizeof(struct usb_cdc_ncm_ndp16))) { pr_debug("frame too short\n"); goto error; } - memcpy(&(ctx->rx_ncm.nth16), ((u8 *)skb_in->data), - sizeof(ctx->rx_ncm.nth16)); + nth16 = (struct usb_cdc_ncm_nth16 *)skb_in->data; - if (le32_to_cpu(ctx->rx_ncm.nth16.dwSignature) != - USB_CDC_NCM_NTH16_SIGN) { + if (le32_to_cpu(nth16->dwSignature) != USB_CDC_NCM_NTH16_SIGN) { pr_debug("invalid NTH16 signature <%u>\n", - le32_to_cpu(ctx->rx_ncm.nth16.dwSignature)); + le32_to_cpu(nth16->dwSignature)); goto error; } - temp = le16_to_cpu(ctx->rx_ncm.nth16.wBlockLength); - if (temp > sumlen) { - pr_debug("unsupported NTB block length %u/%u\n", temp, sumlen); + len = le16_to_cpu(nth16->wBlockLength); + if (len > ctx->rx_max) { + pr_debug("unsupported NTB block length %u/%u\n", len, + ctx->rx_max); goto error; } - temp = le16_to_cpu(ctx->rx_ncm.nth16.wNdpIndex); - if ((temp + sizeof(ctx->rx_ncm.ndp16)) > actlen) { - pr_debug("invalid DPT16 index\n"); + if ((ctx->rx_seq + 1) != le16_to_cpu(nth16->wSequence) && + (ctx->rx_seq || le16_to_cpu(nth16->wSequence)) && + !((ctx->rx_seq == 0xffff) && !le16_to_cpu(nth16->wSequence))) { + pr_debug("sequence number glitch prev=%d curr=%d\n", + ctx->rx_seq, le16_to_cpu(nth16->wSequence)); + } + ctx->rx_seq = le16_to_cpu(nth16->wSequence); + + len = le16_to_cpu(nth16->wNdpIndex); + if ((len + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) { + pr_debug("invalid DPT16 index <%u>\n", + le16_to_cpu(nth16->wNdpIndex)); goto error; } - memcpy(&(ctx->rx_ncm.ndp16), ((u8 *)skb_in->data) + temp, - sizeof(ctx->rx_ncm.ndp16)); + ndp16 = (struct usb_cdc_ncm_ndp16 *)(((u8 *)skb_in->data) + len); - if (le32_to_cpu(ctx->rx_ncm.ndp16.dwSignature) != - USB_CDC_NCM_NDP16_NOCRC_SIGN) { + if (le32_to_cpu(ndp16->dwSignature) != USB_CDC_NCM_NDP16_NOCRC_SIGN) { pr_debug("invalid DPT16 signature <%u>\n", - le32_to_cpu(ctx->rx_ncm.ndp16.dwSignature)); + le32_to_cpu(ndp16->dwSignature)); goto error; } - if (le16_to_cpu(ctx->rx_ncm.ndp16.wLength) < - USB_CDC_NCM_NDP16_LENGTH_MIN) { + if (le16_to_cpu(ndp16->wLength) < USB_CDC_NCM_NDP16_LENGTH_MIN) { pr_debug("invalid DPT16 length <%u>\n", - le32_to_cpu(ctx->rx_ncm.ndp16.dwSignature)); + le32_to_cpu(ndp16->dwSignature)); goto error; } - nframes = ((le16_to_cpu(ctx->rx_ncm.ndp16.wLength) - + nframes = ((le16_to_cpu(ndp16->wLength) - sizeof(struct usb_cdc_ncm_ndp16)) / sizeof(struct usb_cdc_ncm_dpe16)); nframes--; /* we process NDP entries except for the last one */ - pr_debug("nframes = %u\n", nframes); + len += sizeof(struct usb_cdc_ncm_ndp16); - temp += sizeof(ctx->rx_ncm.ndp16); - - if ((temp + nframes * (sizeof(struct usb_cdc_ncm_dpe16))) > actlen) { + if ((len + nframes * (sizeof(struct usb_cdc_ncm_dpe16))) > + skb_in->len) { pr_debug("Invalid nframes = %d\n", nframes); goto error; } - if (nframes > CDC_NCM_DPT_DATAGRAMS_MAX) { - pr_debug("Truncating number of frames from %u to %u\n", - nframes, CDC_NCM_DPT_DATAGRAMS_MAX); - nframes = CDC_NCM_DPT_DATAGRAMS_MAX; - } - - memcpy(&(ctx->rx_ncm.dpe16), ((u8 *)skb_in->data) + temp, - nframes * (sizeof(struct usb_cdc_ncm_dpe16))); + dpe16 = (struct usb_cdc_ncm_dpe16 *)(((u8 *)skb_in->data) + len); - for (x = 0; x < nframes; x++) { - offset = le16_to_cpu(ctx->rx_ncm.dpe16[x].wDatagramIndex); - temp = le16_to_cpu(ctx->rx_ncm.dpe16[x].wDatagramLength); + for (x = 0; x < nframes; x++, dpe16++) { + offset = le16_to_cpu(dpe16->wDatagramIndex); + len = le16_to_cpu(dpe16->wDatagramLength); /* * CDC NCM ch. 3.7 * All entries after first NULL entry are to be ignored */ - if ((offset == 0) || (temp == 0)) { + if ((offset == 0) || (len == 0)) { if (!x) goto error; /* empty NTB */ break; } /* sanity checking */ - if (((offset + temp) > actlen) || - (temp > CDC_NCM_MAX_DATAGRAM_SIZE) || (temp < ETH_HLEN)) { + if (((offset + len) > skb_in->len) || + (len > ctx->rx_max) || (len < ETH_HLEN)) { pr_debug("invalid frame detected (ignored)" "offset[%u]=%u, length=%u, skb=%p\n", - x, offset, temp, skb_in); + x, offset, len, skb_in); if (!x) goto error; break; @@ -1066,9 +1058,9 @@ static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in) skb = skb_clone(skb_in, GFP_ATOMIC); if (!skb) goto error; - skb->len = temp; + skb->len = len; skb->data = ((u8 *)skb_in->data) + offset; - skb_set_tail_pointer(skb, temp); + skb_set_tail_pointer(skb, len); usbnet_skb_return(dev, skb); } } -- GitLab From 50cdc8fc4007cf773cad710186d253612b83cc72 Mon Sep 17 00:00:00 2001 From: Rami Rosen Date: Fri, 16 Mar 2012 05:19:36 +0000 Subject: [PATCH 1780/1846] pxa168: remove unused stats member. The patch removes unused stats member in pxa168 network driver. Signed-off-by: Rami Rosen Signed-off-by: David S. Miller --- drivers/net/ethernet/marvell/pxa168_eth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 3a7df0593c68..45a6333588e6 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -220,7 +220,6 @@ struct pxa168_eth_private { u8 work_todo; int skb_size; - struct net_device_stats stats; /* Size of Tx Ring per queue */ int tx_ring_size; /* Number of tx descriptors in use */ -- GitLab From 06d6c1087605b38342eb20e74b0cacb8b71f5086 Mon Sep 17 00:00:00 2001 From: Santosh Nayak Date: Mon, 12 Mar 2012 22:58:24 +0000 Subject: [PATCH 1781/1846] netxen: qlogic ethernet : Fix endian bug. Change the datatype of "ip_addr" to __be32 as 'ip' should be in big endian format. Adapter needs "ip address" in big endian format stored at lower 32bit of req.word[1]. netxen_config_ipaddr() now receives 'ip' in big endian format. To satisfy adapter's need, use memcpy() to copy byte by byte of 'ip' into lower 32bit of req.word[1]. Mac address and serial number of adapter need to be in little endian format. Change the data type of the related variables to __le32 / __le64 or cast it explicitly to __le32 / __le64 depending upon the requirement. Signed-off-by: Santosh Nayak Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/netxen/netxen_nic.h | 4 ++-- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 10 +++++----- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h index 2eeac32f7fdd..b5de8a7b90f1 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h @@ -954,7 +954,7 @@ typedef struct nx_mac_list_s { struct nx_vlan_ip_list { struct list_head list; - u32 ip_addr; + __be32 ip_addr; }; /* @@ -1780,7 +1780,7 @@ int netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max); void netxen_p3_free_mac_list(struct netxen_adapter *adapter); int netxen_config_intr_coalesce(struct netxen_adapter *adapter); int netxen_config_rss(struct netxen_adapter *adapter, int enable); -int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd); +int netxen_config_ipaddr(struct netxen_adapter *adapter, __be32 ip, int cmd); int netxen_linkevent_request(struct netxen_adapter *adapter, int enable); void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup); void netxen_pci_camqm_read_2M(struct netxen_adapter *, u64, u64 *); diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c index 6f37470750f3..de96a948bb7f 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c @@ -909,7 +909,7 @@ int netxen_config_rss(struct netxen_adapter *adapter, int enable) return rv; } -int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd) +int netxen_config_ipaddr(struct netxen_adapter *adapter, __be32 ip, int cmd) { nx_nic_req_t req; u64 word; @@ -922,7 +922,7 @@ int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd) req.req_hdr = cpu_to_le64(word); req.words[0] = cpu_to_le64(cmd); - req.words[1] = cpu_to_le64(ip); + memcpy(&req.words[1], &ip, sizeof(u32)); rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); if (rv != 0) { @@ -1050,7 +1050,7 @@ int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 *mac) if (netxen_get_flash_block(adapter, offset, sizeof(u64), pmac) == -1) return -1; - if (*mac == cpu_to_le64(~0ULL)) { + if (*mac == ~0ULL) { offset = NX_OLD_MAC_ADDR_OFFSET + (adapter->portnum * sizeof(u64)); @@ -1059,7 +1059,7 @@ int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 *mac) offset, sizeof(u64), pmac) == -1) return -1; - if (*mac == cpu_to_le64(~0ULL)) + if (*mac == ~0ULL) return -1; } return 0; @@ -2155,7 +2155,7 @@ static u32 netxen_md_rd_crb(struct netxen_adapter *adapter, static u32 netxen_md_rdrom(struct netxen_adapter *adapter, struct netxen_minidump_entry_rdrom - *romEntry, u32 *data_buff) + *romEntry, __le32 *data_buff) { int i, count = 0; u32 size, lck_val; diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 7648995ea720..65a718f9ccd3 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -805,12 +805,12 @@ netxen_check_options(struct netxen_adapter *adapter) char brd_name[NETXEN_MAX_SHORT_NAME]; char serial_num[32]; int i, offset, val, err; - int *ptr32; + __le32 *ptr32; struct pci_dev *pdev = adapter->pdev; adapter->driver_mismatch = 0; - ptr32 = (int *)&serial_num; + ptr32 = (__le32 *)&serial_num; offset = NX_FW_SERIAL_NUM_OFFSET; for (i = 0; i < 8; i++) { if (netxen_rom_fast_read(adapter, offset, &val) == -1) { -- GitLab From 6a228452d11eaf1f1577261540ec0903a2af7f61 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 13 Mar 2012 04:56:37 +0000 Subject: [PATCH 1782/1846] stmmac: Add device-tree support This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data. Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms. Signed-off-by: Stefan Roese Cc: Giuseppe Cavallaro Signed-off-by: David S. Miller --- .../devicetree/bindings/net/stmmac.txt | 28 +++++++ .../ethernet/stmicro/stmmac/stmmac_platform.c | 74 ++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644 index 000000000000..1f62623f8c3f --- /dev/null +++ b/Documentation/devicetree/bindings/net/stmmac.txt @@ -0,0 +1,28 @@ +* STMicroelectronics 10/100/1000 Ethernet driver (GMAC) + +Required properties: +- compatible: Should be "st,spear600-gmac" +- reg: Address and length of the register set for the device +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device +- interrupts: Should contain the STMMAC interrupts +- interrupt-names: Should contain the interrupt names "macirq" + "eth_wake_irq" if this interrupt is supported in the "interrupts" + property +- phy-mode: String, operation mode of the PHY interface. + Supported values are: "mii", "rmii", "gmii", "rgmii". + +Optional properties: +- mac-address: 6 bytes, mac address + +Examples: + + gmac0: ethernet@e0800000 { + compatible = "st,spear600-gmac"; + reg = <0xe0800000 0x8000>; + interrupt-parent = <&vic1>; + interrupts = <24 23>; + interrupt-names = "macirq", "eth_wake_irq"; + mac-address = [000000000000]; /* Filled in by U-Boot */ + phy-mode = "gmii"; + }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 3aad9810237c..116529a366b2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -24,8 +24,48 @@ #include #include +#include +#include #include "stmmac.h" +#ifdef CONFIG_OF +static int __devinit stmmac_probe_config_dt(struct platform_device *pdev, + struct plat_stmmacenet_data *plat, + const char **mac) +{ + struct device_node *np = pdev->dev.of_node; + + if (!np) + return -ENODEV; + + *mac = of_get_mac_address(np); + plat->interface = of_get_phy_mode(np); + plat->mdio_bus_data = devm_kzalloc(&pdev->dev, + sizeof(struct stmmac_mdio_bus_data), + GFP_KERNEL); + + /* + * Currently only the properties needed on SPEAr600 + * are provided. All other properties should be added + * once needed on other platforms. + */ + if (of_device_is_compatible(np, "st,spear600-gmac")) { + plat->pbl = 8; + plat->has_gmac = 1; + plat->pmt = 1; + } + + return 0; +} +#else +static int __devinit stmmac_probe_config_dt(struct platform_device *pdev, + struct plat_stmmacenet_data *plat, + const char **mac) +{ + return -ENOSYS; +} +#endif /* CONFIG_OF */ + /** * stmmac_pltfr_probe * @pdev: platform device pointer @@ -39,7 +79,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) struct resource *res; void __iomem *addr = NULL; struct stmmac_priv *priv = NULL; - struct plat_stmmacenet_data *plat_dat; + struct plat_stmmacenet_data *plat_dat = NULL; + const char *mac = NULL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) @@ -58,7 +99,25 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) ret = -ENOMEM; goto out_release_region; } - plat_dat = pdev->dev.platform_data; + + if (pdev->dev.of_node) { + plat_dat = devm_kzalloc(&pdev->dev, + sizeof(struct plat_stmmacenet_data), + GFP_KERNEL); + if (!plat_dat) { + pr_err("%s: ERROR: no memory", __func__); + ret = -ENOMEM; + goto out_unmap; + } + + ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); + if (ret) { + pr_err("%s: main dt probe failed", __func__); + goto out_unmap; + } + } else { + plat_dat = pdev->dev.platform_data; + } /* Custom initialisation (if needed)*/ if (plat_dat->init) { @@ -73,6 +132,10 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) goto out_unmap; } + /* Get MAC address if available (DT) */ + if (mac) + memcpy(priv->dev->dev_addr, mac, ETH_ALEN); + /* Get the MAC information */ priv->dev->irq = platform_get_irq_byname(pdev, "macirq"); if (priv->dev->irq == -ENXIO) { @@ -178,6 +241,12 @@ static const struct dev_pm_ops stmmac_pltfr_pm_ops = { static const struct dev_pm_ops stmmac_pltfr_pm_ops; #endif /* CONFIG_PM */ +static const struct of_device_id stmmac_dt_ids[] = { + { .compatible = "st,spear600-gmac", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, stmmac_dt_ids); + static struct platform_driver stmmac_driver = { .probe = stmmac_pltfr_probe, .remove = stmmac_pltfr_remove, @@ -185,6 +254,7 @@ static struct platform_driver stmmac_driver = { .name = STMMAC_RESOURCE_NAME, .owner = THIS_MODULE, .pm = &stmmac_pltfr_pm_ops, + .of_match_table = of_match_ptr(stmmac_dt_ids), }, }; -- GitLab From 1aa9bc5b2f4cf8c48944fb9a607bf1dd674e2c10 Mon Sep 17 00:00:00 2001 From: Alexey Orishko Date: Wed, 14 Mar 2012 04:00:24 +0000 Subject: [PATCH 1783/1846] usbnet: use netif_tx_wake_queue instead of netif_start_queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If host is going to autosuspend function with two interfaces and if IP packet has arrived in-between of two usbnet_suspend() callbacks, i.e usbnet_resume() is called in-between, tx data flow is stopped. When autosuspend timer expires and device is put to autosuspend again, tx queue is waked up and data can be sent again. This behavior might be repeated several times in a row. Tested on Intel/ARM. Reviewed-by: Sjur Brændeland Tested-by: Dmitry Tarnyagin Signed-off-by: Alexey Orishko Acked-by: Oliver Neukum Signed-off-by: David S. Miller --- drivers/net/usb/usbnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 83dcc530618e..5394b4eb00b0 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1535,7 +1535,7 @@ int usbnet_resume (struct usb_interface *intf) if (test_bit(EVENT_DEV_OPEN, &dev->flags)) { if (!(dev->txq.qlen >= TX_QLEN(dev))) - netif_start_queue(dev->net); + netif_tx_wake_all_queues(dev->net); tasklet_schedule (&dev->bh); } } -- GitLab From 124d37e9f088a8f56494b0264d63d22555f53fef Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Thu, 15 Mar 2012 05:25:58 +0000 Subject: [PATCH 1784/1846] arp: allow arp processing to honor per interface arp_accept sysctl I found recently that the arp_process function which handles all of our received arp frames, is using IPV4_DEVCONF_ALL macro to check the state of the arp_process flag. This seems wrong, as it implies that either none or all of the network interfaces accept gratuitous arps. This patch corrects that, allowing per-interface arp_accept configuration to deviate from the all setting. Note this also brings us into line with the way the arp_filter setting is handled during arp_process execution. Tested this myself on my home network, and confirmed it works as expected. Signed-off-by: Neil Horman CC: "David S. Miller" Signed-off-by: David S. Miller --- include/linux/inetdevice.h | 1 + net/ipv4/arp.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index 5f8146695b7f..597f4a9f3240 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -139,6 +139,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev) IN_DEV_ORCONF((in_dev), ACCEPT_REDIRECTS))) #define IN_DEV_ARPFILTER(in_dev) IN_DEV_ORCONF((in_dev), ARPFILTER) +#define IN_DEV_ARP_ACCEPT(in_dev) IN_DEV_ORCONF((in_dev), ARP_ACCEPT) #define IN_DEV_ARP_ANNOUNCE(in_dev) IN_DEV_MAXCONF((in_dev), ARP_ANNOUNCE) #define IN_DEV_ARP_IGNORE(in_dev) IN_DEV_MAXCONF((in_dev), ARP_IGNORE) #define IN_DEV_ARP_NOTIFY(in_dev) IN_DEV_MAXCONF((in_dev), ARP_NOTIFY) diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 63e49890ad31..73f46d691abc 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -889,7 +889,7 @@ static int arp_process(struct sk_buff *skb) n = __neigh_lookup(&arp_tbl, &sip, dev, 0); - if (IPV4_DEVCONF_ALL(dev_net(dev), ARP_ACCEPT)) { + if (IN_DEV_ARP_ACCEPT(in_dev)) { /* Unsolicited ARP is not accepted by default. It is possible, that this option should be enabled for some devices (strip is candidate) -- GitLab From 4823cd388dd68015e254d1449bd63ffe47d83fa7 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 15 Mar 2012 08:19:29 +0000 Subject: [PATCH 1785/1846] net/irda: add clk_prepare/clk_unprepare to pxaficp_ir This patch adds clk_prepare/clk_unprepare calls to the pxaficp_ir driver by using the helper functions clk_prepare_enable and clk_disable_unprepare. Signed-off-by: Philipp Zabel Cc: Eric Miao Cc: Haojian Zhuang Cc: Samuel Ortiz Signed-off-by: David S. Miller --- drivers/net/irda/pxaficp_ir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c index 81d5275a15e2..ff16daf33ae1 100644 --- a/drivers/net/irda/pxaficp_ir.c +++ b/drivers/net/irda/pxaficp_ir.c @@ -128,20 +128,20 @@ struct pxa_irda { static inline void pxa_irda_disable_clk(struct pxa_irda *si) { if (si->cur_clk) - clk_disable(si->cur_clk); + clk_disable_unprepare(si->cur_clk); si->cur_clk = NULL; } static inline void pxa_irda_enable_firclk(struct pxa_irda *si) { si->cur_clk = si->fir_clk; - clk_enable(si->fir_clk); + clk_prepare_enable(si->fir_clk); } static inline void pxa_irda_enable_sirclk(struct pxa_irda *si) { si->cur_clk = si->sir_clk; - clk_enable(si->sir_clk); + clk_prepare_enable(si->sir_clk); } -- GitLab From 126a3fd251b244eabd9ab9dcb32b8b6f999c1b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fran=C3=A7ois=20romieu?= Date: Fri, 16 Mar 2012 01:52:04 +0000 Subject: [PATCH 1786/1846] eni: fix driver remove function and driver probe error path. - add eni_do_release() to balance eni_do_init - turn the zeroes DMA area into a per device data Signed-off-by: Francois Romieu Signed-off-by: David S. Miller --- drivers/atm/eni.c | 98 ++++++++++++++++++++++++++++++----------------- drivers/atm/eni.h | 5 +++ 2 files changed, 68 insertions(+), 35 deletions(-) diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c index 485a11a6de96..6ff612d099c3 100644 --- a/drivers/atm/eni.c +++ b/drivers/atm/eni.c @@ -156,9 +156,6 @@ static int tx_complete = 0,dma_complete = 0,queued = 0,requeued = 0, static struct atm_dev *eni_boards = NULL; -static u32 *cpu_zeroes = NULL; /* aligned "magic" zeroes */ -static dma_addr_t zeroes; - /* Read/write registers on card */ #define eni_in(r) readl(eni_dev->reg+(r)*4) #define eni_out(v,r) writel((v),eni_dev->reg+(r)*4) @@ -1138,8 +1135,10 @@ DPRINTK("doing direct send\n"); /* @@@ well, this doesn't work anyway */ skb_shinfo(skb)->frags[i].page_offset, skb_frag_size(&skb_shinfo(skb)->frags[i])); } - if (skb->len & 3) - put_dma(tx->index,eni_dev->dma,&j,zeroes,4-(skb->len & 3)); + if (skb->len & 3) { + put_dma(tx->index, eni_dev->dma, &j, eni_dev->zero.dma, + 4 - (skb->len & 3)); + } /* JK for AAL5 trailer - AAL0 doesn't need it, but who cares ... */ eni_dev->dma[j++] = (((tx->tx_pos+size) & (tx->words-1)) << MID_DMA_COUNT_SHIFT) | (tx->index << MID_DMA_CHAN_SHIFT) | @@ -1728,6 +1727,7 @@ static int __devinit eni_do_init(struct atm_dev *dev) "mapping\n",dev->number); return error; } + eni_dev->ioaddr = base; eni_dev->base_diff = real_base - (unsigned long) base; /* id may not be present in ASIC Tonga boards - check this @@@ */ if (!eni_dev->asic) { @@ -1789,6 +1789,14 @@ static int __devinit eni_do_init(struct atm_dev *dev) goto out; } +static void eni_do_release(struct atm_dev *dev) +{ + struct eni_dev *ed = ENI_DEV(dev); + + dev->phy->stop(dev); + dev->phy = NULL; + iounmap(ed->ioaddr); +} static int __devinit eni_start(struct atm_dev *dev) { @@ -2220,48 +2228,60 @@ static const struct atmdev_ops ops = { static int __devinit eni_init_one(struct pci_dev *pci_dev, - const struct pci_device_id *ent) + const struct pci_device_id *ent) { struct atm_dev *dev; struct eni_dev *eni_dev; - int error = -ENOMEM; + struct eni_zero *zero; + int rc; + + rc = pci_enable_device(pci_dev); + if (rc < 0) + goto out; - DPRINTK("eni_init_one\n"); + rc = -ENOMEM; + eni_dev = kmalloc(sizeof(struct eni_dev), GFP_KERNEL); + if (!eni_dev) + goto err_disable; - if (pci_enable_device(pci_dev)) { - error = -EIO; - goto out0; - } + zero = &eni_dev->zero; + zero->addr = pci_alloc_consistent(pci_dev, ENI_ZEROES_SIZE, &zero->dma); + if (!zero->addr) + goto err_kfree; - eni_dev = kmalloc(sizeof(struct eni_dev),GFP_KERNEL); - if (!eni_dev) goto out0; - if (!cpu_zeroes) { - cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE, - &zeroes); - if (!cpu_zeroes) goto out1; - } dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &ops, -1, NULL); - if (!dev) goto out2; + if (!dev) + goto err_free_consistent; + + dev->dev_data = eni_dev; pci_set_drvdata(pci_dev, dev); eni_dev->pci_dev = pci_dev; - dev->dev_data = eni_dev; eni_dev->asic = ent->driver_data; - error = eni_do_init(dev); - if (error) goto out3; - error = eni_start(dev); - if (error) goto out3; + + rc = eni_do_init(dev); + if (rc < 0) + goto err_unregister; + + rc = eni_start(dev); + if (rc < 0) + goto err_eni_release; + eni_dev->more = eni_boards; eni_boards = dev; - return 0; -out3: +out: + return rc; + +err_eni_release: + eni_do_release(dev); +err_unregister: atm_dev_deregister(dev); -out2: - pci_free_consistent(eni_dev->pci_dev,ENI_ZEROES_SIZE,cpu_zeroes,zeroes); - cpu_zeroes = NULL; -out1: +err_free_consistent: + pci_free_consistent(pci_dev, ENI_ZEROES_SIZE, zero->addr, zero->dma); +err_kfree: kfree(eni_dev); -out0: - return error; +err_disable: + pci_disable_device(pci_dev); + goto out; } @@ -2273,9 +2293,17 @@ static struct pci_device_id eni_pci_tbl[] = { MODULE_DEVICE_TABLE(pci,eni_pci_tbl); -static void __devexit eni_remove_one(struct pci_dev *pci_dev) +static void __devexit eni_remove_one(struct pci_dev *pdev) { - /* grrr */ + struct atm_dev *dev = pci_get_drvdata(pdev); + struct eni_dev *ed = ENI_DEV(dev); + struct eni_zero *zero = &ed->zero; + + eni_do_release(dev); + atm_dev_deregister(dev); + pci_free_consistent(pdev, ENI_ZEROES_SIZE, zero->addr, zero->dma); + kfree(ed); + pci_disable_device(pdev); } diff --git a/drivers/atm/eni.h b/drivers/atm/eni.h index dc9a62cc2605..565e53a5cb78 100644 --- a/drivers/atm/eni.h +++ b/drivers/atm/eni.h @@ -72,6 +72,7 @@ struct eni_dev { u32 events; /* pending events */ /*-------------------------------- base pointers into Midway address space */ + void __iomem *ioaddr; void __iomem *phy; /* PHY interface chip registers */ void __iomem *reg; /* register base */ void __iomem *ram; /* RAM base */ @@ -86,6 +87,10 @@ struct eni_dev { wait_queue_head_t tx_wait; /* for close */ int tx_bw; /* remaining bandwidth */ u32 dma[TX_DMA_BUF*2]; /* DMA request scratch area */ + struct eni_zero { /* aligned "magic" zeroes */ + u32 *addr; + dma_addr_t dma; + } zero; int tx_mult; /* buffer size multiplier (percent) */ /*-------------------------------- RX part */ u32 serv_read; /* host service read index */ -- GitLab From 6b8f092284672c6504ed215052bfee6b7171411e Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Tue, 6 Mar 2012 09:41:53 +0000 Subject: [PATCH 1787/1846] igb: Support sending custom Ethernet FCS. Including bad FCS, used generate frames with bad FCS to test other system's handling of RX of bad packets. Signed-off-by: Ben Greear Tested-by: Jeff Pieper Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/igb/igb_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index e96cef89f121..99364edf0314 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -1964,6 +1964,8 @@ static int __devinit igb_probe(struct pci_dev *pdev, NETIF_F_IPV6_CSUM | NETIF_F_SG; + netdev->priv_flags |= IFF_SUPP_NOFCS; + if (pci_using_dac) { netdev->features |= NETIF_F_HIGHDMA; netdev->vlan_features |= NETIF_F_HIGHDMA; @@ -4293,6 +4295,8 @@ static void igb_tx_map(struct igb_ring *tx_ring, /* write last descriptor with RS and EOP bits */ cmd_type |= cpu_to_le32(size) | cpu_to_le32(IGB_TXD_DCMD); + if (unlikely(skb->no_fcs)) + cmd_type &= ~(cpu_to_le32(E1000_ADVTXD_DCMD_IFCS)); tx_desc->read.cmd_type_len = cmd_type; /* set the timestamp */ -- GitLab From 89eaefb61dc9170237d95b844dd357338fc7225d Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Tue, 6 Mar 2012 09:41:58 +0000 Subject: [PATCH 1788/1846] igb: Support RX-ALL feature flag. This allows the NIC to receive all frames available, including those with bad FCS, un-matched vlans, ethernet control frames, and more. Tested by sending frames with bad FCS. Signed-off-by: Ben Greear Tested-by: Jeff Pieper Signed-off-by: Jeff Kirsher --- .../net/ethernet/intel/igb/e1000_defines.h | 2 ++ drivers/net/ethernet/intel/igb/igb_main.c | 33 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h index aed217449f0d..89eb1f85b9fa 100644 --- a/drivers/net/ethernet/intel/igb/e1000_defines.h +++ b/drivers/net/ethernet/intel/igb/e1000_defines.h @@ -134,6 +134,8 @@ #define E1000_RCTL_SZ_256 0x00030000 /* rx buffer size 256 */ #define E1000_RCTL_VFE 0x00040000 /* vlan filter enable */ #define E1000_RCTL_CFIEN 0x00080000 /* canonical form enable */ +#define E1000_RCTL_DPF 0x00400000 /* Discard Pause Frames */ +#define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */ #define E1000_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */ /* diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 99364edf0314..c4902411d749 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -1769,10 +1769,21 @@ static int igb_set_features(struct net_device *netdev, netdev_features_t features) { netdev_features_t changed = netdev->features ^ features; + struct igb_adapter *adapter = netdev_priv(netdev); if (changed & NETIF_F_HW_VLAN_RX) igb_vlan_mode(netdev, features); + if (!(changed & NETIF_F_RXALL)) + return 0; + + netdev->features = features; + + if (netif_running(netdev)) + igb_reinit_locked(adapter); + else + igb_reset(adapter); + return 0; } @@ -1954,6 +1965,7 @@ static int __devinit igb_probe(struct pci_dev *pdev, /* copy netdev features into list of user selectable features */ netdev->hw_features |= netdev->features; + netdev->hw_features |= NETIF_F_RXALL; /* set this bit last since it cannot be part of hw_features */ netdev->features |= NETIF_F_HW_VLAN_FILTER; @@ -3005,6 +3017,22 @@ void igb_setup_rctl(struct igb_adapter *adapter) wr32(E1000_QDE, ALL_QUEUES); } + /* This is useful for sniffing bad packets. */ + if (adapter->netdev->features & NETIF_F_RXALL) { + /* UPE and MPE will be handled by normal PROMISC logic + * in e1000e_set_rx_mode */ + rctl |= (E1000_RCTL_SBP | /* Receive bad packets */ + E1000_RCTL_BAM | /* RX All Bcast Pkts */ + E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */ + + rctl &= ~(E1000_RCTL_VFE | /* Disable VLAN filter */ + E1000_RCTL_DPF | /* Allow filtered pause */ + E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */ + /* Do not mess with E1000_CTRL_VME, it affects transmit as well, + * and that breaks VLANs. + */ + } + wr32(E1000_RCTL, rctl); } @@ -6102,8 +6130,9 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget) goto next_desc; } - if (igb_test_staterr(rx_desc, - E1000_RXDEXT_ERR_FRAME_ERR_MASK)) { + if (unlikely((igb_test_staterr(rx_desc, + E1000_RXDEXT_ERR_FRAME_ERR_MASK)) + && !(rx_ring->netdev->features & NETIF_F_RXALL))) { dev_kfree_skb_any(skb); goto next_desc; } -- GitLab From f43f313eb7c5f189ff4e27da6cc96ad2e613e333 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Tue, 6 Mar 2012 09:42:04 +0000 Subject: [PATCH 1789/1846] ixgbe: Support sending custom Ethernet FCS. Including bad FCS, used generate frames with bad FCS to test other system's handling of RX of bad packets. Signed-off-by: Ben Greear Tested-by: Jeff Pieper Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 167e898fbba6..986897bf2b83 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6768,6 +6768,8 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, tx_buffer_info->dma = dma; tx_desc->read.buffer_addr = cpu_to_le64(dma + offset); + if (unlikely(skb->no_fcs)) + cmd_type &= ~(cpu_to_le32(IXGBE_ADVTXD_DCMD_IFCS)); tx_desc->read.cmd_type_len = cmd_type | cpu_to_le32(size); tx_desc->read.olinfo_status = olinfo_status; @@ -7778,6 +7780,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, netdev->vlan_features |= NETIF_F_SG; netdev->priv_flags |= IFF_UNICAST_FLT; + netdev->priv_flags |= IFF_SUPP_NOFCS; if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) adapter->flags &= ~(IXGBE_FLAG_RSS_ENABLED | -- GitLab From 3f2d1c0f57c6bfad7aacc249fca3514e98a94137 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 8 Mar 2012 08:28:41 +0000 Subject: [PATCH 1790/1846] ixgbe: Support RX-ALL feature flag. This allows the NIC to receive all frames available, including those with bad FCS, ethernet control frames, and more. Tested by sending frames with bad FCS. Signed-off-by: Ben Greear Tested-by: Jeff Pieper Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 986897bf2b83..cae763c57dc7 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1482,8 +1482,8 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, struct sk_buff *skb; unsigned int total_rx_bytes = 0, total_rx_packets = 0; const int current_node = numa_node_id(); -#ifdef IXGBE_FCOE struct ixgbe_adapter *adapter = q_vector->adapter; +#ifdef IXGBE_FCOE int ddp_bytes = 0; #endif /* IXGBE_FCOE */ u16 i; @@ -1612,7 +1612,8 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, /* ERR_MASK will only have valid bits if EOP set */ if (unlikely(ixgbe_test_staterr(rx_desc, - IXGBE_RXDADV_ERR_FRAME_ERR_MASK))) { + IXGBE_RXDADV_ERR_FRAME_ERR_MASK) && + !(adapter->netdev->features & NETIF_F_RXALL))) { dev_kfree_skb_any(skb); goto next_desc; } @@ -3342,6 +3343,7 @@ void ixgbe_set_rx_mode(struct net_device *netdev) fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); /* set all bits that we expect to always be set */ + fctrl &= ~IXGBE_FCTRL_SBP; /* disable store-bad-packets */ fctrl |= IXGBE_FCTRL_BAM; fctrl |= IXGBE_FCTRL_DPF; /* discard pause frames when FC enabled */ fctrl |= IXGBE_FCTRL_PMCF; @@ -3390,6 +3392,18 @@ void ixgbe_set_rx_mode(struct net_device *netdev) IXGBE_WRITE_REG(hw, IXGBE_VMOLR(adapter->num_vfs), vmolr); } + /* This is useful for sniffing bad packets. */ + if (adapter->netdev->features & NETIF_F_RXALL) { + /* UPE and MPE will be handled by normal PROMISC logic + * in e1000e_set_rx_mode */ + fctrl |= (IXGBE_FCTRL_SBP | /* Receive bad packets */ + IXGBE_FCTRL_BAM | /* RX All Bcast Pkts */ + IXGBE_FCTRL_PMCF); /* RX All MAC Ctrl Pkts */ + + fctrl &= ~(IXGBE_FCTRL_DPF); + /* NOTE: VLAN filtering is disabled by setting PROMISC */ + } + IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl); if (netdev->features & NETIF_F_HW_VLAN_RX) @@ -7459,6 +7473,7 @@ static int ixgbe_set_features(struct net_device *netdev, netdev_features_t data) { struct ixgbe_adapter *adapter = netdev_priv(netdev); + netdev_features_t changed = netdev->features ^ data; bool need_reset = false; /* Make sure RSC matches LRO, reset if change */ @@ -7495,6 +7510,10 @@ static int ixgbe_set_features(struct net_device *netdev, need_reset = true; } + if (changed & NETIF_F_RXALL) + need_reset = true; + + netdev->features = data; if (need_reset) ixgbe_do_reset(netdev); @@ -7773,6 +7792,8 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, break; } + netdev->hw_features |= NETIF_F_RXALL; + netdev->vlan_features |= NETIF_F_TSO; netdev->vlan_features |= NETIF_F_TSO6; netdev->vlan_features |= NETIF_F_IP_CSUM; -- GitLab From f800326dca7bc158f4c886aa92f222de37993c80 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Sat, 3 Mar 2012 02:35:52 +0000 Subject: [PATCH 1791/1846] ixgbe: Replace standard receive path with a page based receive This patch replaces the existing Rx hot-path in the ixgbe driver with a new implementation that is based on performing a double buffered receive. The ixgbe driver already had something similar in place for its' packet split path, however in that case we were still receiving the header for the packet into the sk_buff. The big change here is the entire receive path will receive into pages only, and then pull the header out of the page and copy it into the sk_buff data. There are several motivations behind this approach. First, this allows us to avoid several cache misses as we were taking a set of cache misses for allocating the sk_buff and then another set for receiving data into the sk_buff. We are able to avoid these misses on receive now as we allocate the sk_buff when data is available. Second we are able to see a considerable performance gain when an IOMMU is enabled because we are no longer unmapping every buffer on receive. Instead we can delay the unmap until we are unable to use the page, and instead we can simply call sync_single_range on the half of the page that contains new data. Finally we are able to drop a considerable amount of code from the driver as we no longer have to support 2 different receive modes, packet split and one buffer. This allows us to optimize the Rx path further since less branching is required. Signed-off-by: Alexander Duyck Tested-by: Ross Brattain Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 45 +- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 23 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 819 +++++++++--------- 3 files changed, 457 insertions(+), 430 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index f069c1b10753..b1e3baf8d450 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -72,12 +72,6 @@ /* Supported Rx Buffer Sizes */ #define IXGBE_RXBUFFER_512 512 /* Used for packet split */ -#define IXGBE_RXBUFFER_2K 2048 -#define IXGBE_RXBUFFER_3K 3072 -#define IXGBE_RXBUFFER_4K 4096 -#define IXGBE_RXBUFFER_7K 7168 -#define IXGBE_RXBUFFER_8K 8192 -#define IXGBE_RXBUFFER_15K 15360 #define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */ /* @@ -168,7 +162,6 @@ struct ixgbe_rx_buffer { struct sk_buff *skb; dma_addr_t dma; struct page *page; - dma_addr_t page_dma; unsigned int page_offset; }; @@ -193,21 +186,15 @@ struct ixgbe_rx_queue_stats { u64 csum_err; }; -enum ixbge_ring_state_t { +enum ixgbe_ring_state_t { __IXGBE_TX_FDIR_INIT_DONE, __IXGBE_TX_DETECT_HANG, __IXGBE_HANG_CHECK_ARMED, - __IXGBE_RX_PS_ENABLED, __IXGBE_RX_RSC_ENABLED, __IXGBE_RX_CSUM_UDP_ZERO_ERR, + __IXGBE_RX_FCOE_BUFSZ, }; -#define ring_is_ps_enabled(ring) \ - test_bit(__IXGBE_RX_PS_ENABLED, &(ring)->state) -#define set_ring_ps_enabled(ring) \ - set_bit(__IXGBE_RX_PS_ENABLED, &(ring)->state) -#define clear_ring_ps_enabled(ring) \ - clear_bit(__IXGBE_RX_PS_ENABLED, &(ring)->state) #define check_for_tx_hang(ring) \ test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state) #define set_check_for_tx_hang(ring) \ @@ -233,7 +220,6 @@ struct ixgbe_ring { u8 __iomem *tail; u16 count; /* amount of descriptors */ - u16 rx_buf_len; u8 queue_index; /* needed for multiqueue queue management */ u8 reg_idx; /* holds the special value that gets @@ -241,8 +227,13 @@ struct ixgbe_ring { * associated with this ring, which is * different for DCB and RSS modes */ - u8 atr_sample_rate; - u8 atr_count; + union { + struct { + u8 atr_sample_rate; + u8 atr_count; + }; + u16 next_to_alloc; + }; u16 next_to_use; u16 next_to_clean; @@ -287,6 +278,22 @@ struct ixgbe_ring_feature { int mask; } ____cacheline_internodealigned_in_smp; +/* + * FCoE requires that all Rx buffers be over 2200 bytes in length. Since + * this is twice the size of a half page we need to double the page order + * for FCoE enabled Rx queues. + */ +#if defined(IXGBE_FCOE) && (PAGE_SIZE < 8192) +static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring) +{ + return test_bit(__IXGBE_RX_FCOE_BUFSZ, &ring->state) ? 1 : 0; +} +#else +#define ixgbe_rx_pg_order(_ring) 0 +#endif +#define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring)) +#define ixgbe_rx_bufsz(_ring) ((PAGE_SIZE / 2) << ixgbe_rx_pg_order(_ring)) + struct ixgbe_ring_container { struct ixgbe_ring *ring; /* pointer to linked list of rings */ unsigned int total_bytes; /* total bytes processed this int */ @@ -554,7 +561,7 @@ struct ixgbe_cb { }; dma_addr_t dma; u16 append_cnt; - bool delay_unmap; + bool page_released; }; #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 24f7291dbe57..b09e67cc9d6e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "ixgbe.h" @@ -1615,7 +1616,6 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter) rx_ring->dev = &adapter->pdev->dev; rx_ring->netdev = adapter->netdev; rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx; - rx_ring->rx_buf_len = IXGBE_RXBUFFER_2K; err = ixgbe_setup_rx_resources(rx_ring); if (err) { @@ -1718,13 +1718,15 @@ static bool ixgbe_check_lbtest_frame(struct ixgbe_rx_buffer *rx_buffer, frame_size >>= 1; - data = rx_buffer->skb->data; + data = kmap(rx_buffer->page) + rx_buffer->page_offset; if (data[3] != 0xFF || data[frame_size + 10] != 0xBE || data[frame_size + 12] != 0xAF) match = false; + kunmap(rx_buffer->page); + return match; } @@ -1746,17 +1748,22 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring, /* check Rx buffer */ rx_buffer = &rx_ring->rx_buffer_info[rx_ntc]; - /* unmap Rx buffer, will be remapped by alloc_rx_buffers */ - dma_unmap_single(rx_ring->dev, - rx_buffer->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - rx_buffer->dma = 0; + /* sync Rx buffer for CPU read */ + dma_sync_single_for_cpu(rx_ring->dev, + rx_buffer->dma, + ixgbe_rx_bufsz(rx_ring), + DMA_FROM_DEVICE); /* verify contents of skb */ if (ixgbe_check_lbtest_frame(rx_buffer, size)) count++; + /* sync Rx buffer for device write */ + dma_sync_single_for_device(rx_ring->dev, + rx_buffer->dma, + ixgbe_rx_bufsz(rx_ring), + DMA_FROM_DEVICE); + /* unmap buffer on Tx side */ tx_buffer = &tx_ring->tx_buffer_info[tx_ntc]; ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index cae763c57dc7..e97ef4591ade 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -469,17 +469,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 1, phys_to_virt(rx_buffer_info->dma), - rx_ring->rx_buf_len, true); - - if (rx_ring->rx_buf_len - < IXGBE_RXBUFFER_2K) - print_hex_dump(KERN_INFO, "", - DUMP_PREFIX_ADDRESS, 16, 1, - phys_to_virt( - rx_buffer_info->page_dma + - rx_buffer_info->page_offset - ), - PAGE_SIZE/2, true); + ixgbe_rx_bufsz(rx_ring), true); } } @@ -1006,6 +996,7 @@ static inline void ixgbe_rx_hash(struct ixgbe_ring *ring, skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); } +#ifdef IXGBE_FCOE /** * ixgbe_rx_is_fcoe - check the rx desc for incoming pkt type * @adapter: address of board private structure @@ -1024,6 +1015,7 @@ static inline bool ixgbe_rx_is_fcoe(struct ixgbe_adapter *adapter, IXGBE_RXDADV_PKTTYPE_ETQF_SHIFT))); } +#endif /* IXGBE_FCOE */ /** * ixgbe_rx_checksum - indicate in skb if hw indicated a good cksum * @ring: structure containing ring specific data @@ -1051,7 +1043,7 @@ static inline void ixgbe_rx_checksum(struct ixgbe_ring *ring, return; if (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_ERR_TCPE)) { - u16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; + __le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; /* * 82599 errata, UDP frames with a 0 checksum can be marked as @@ -1072,6 +1064,9 @@ static inline void ixgbe_rx_checksum(struct ixgbe_ring *ring, static inline void ixgbe_release_rx_desc(struct ixgbe_ring *rx_ring, u32 val) { rx_ring->next_to_use = val; + + /* update next to alloc since we have filled the ring */ + rx_ring->next_to_alloc = val; /* * Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only @@ -1082,67 +1077,46 @@ static inline void ixgbe_release_rx_desc(struct ixgbe_ring *rx_ring, u32 val) writel(val, rx_ring->tail); } -static bool ixgbe_alloc_mapped_skb(struct ixgbe_ring *rx_ring, - struct ixgbe_rx_buffer *bi) -{ - struct sk_buff *skb = bi->skb; - dma_addr_t dma = bi->dma; - - if (dma) - return true; - - if (likely(!skb)) { - skb = netdev_alloc_skb_ip_align(rx_ring->netdev, - rx_ring->rx_buf_len); - bi->skb = skb; - if (!skb) { - rx_ring->rx_stats.alloc_rx_buff_failed++; - return false; - } - } - - dma = dma_map_single(rx_ring->dev, skb->data, - rx_ring->rx_buf_len, DMA_FROM_DEVICE); - - if (dma_mapping_error(rx_ring->dev, dma)) { - rx_ring->rx_stats.alloc_rx_buff_failed++; - return false; - } - - bi->dma = dma; - return true; -} - static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring, struct ixgbe_rx_buffer *bi) { struct page *page = bi->page; - dma_addr_t page_dma = bi->page_dma; - unsigned int page_offset = bi->page_offset ^ (PAGE_SIZE / 2); + dma_addr_t dma = bi->dma; - if (page_dma) + /* since we are recycling buffers we should seldom need to alloc */ + if (likely(dma)) return true; - if (!page) { - page = alloc_page(GFP_ATOMIC | __GFP_COLD); - bi->page = page; + /* alloc new page for storage */ + if (likely(!page)) { + page = alloc_pages(GFP_ATOMIC | __GFP_COLD, + ixgbe_rx_pg_order(rx_ring)); if (unlikely(!page)) { rx_ring->rx_stats.alloc_rx_page_failed++; return false; } + bi->page = page; } - page_dma = dma_map_page(rx_ring->dev, page, - page_offset, PAGE_SIZE / 2, - DMA_FROM_DEVICE); + /* map page for use */ + dma = dma_map_page(rx_ring->dev, page, 0, + ixgbe_rx_pg_size(rx_ring), DMA_FROM_DEVICE); + + /* + * if mapping failed free memory back to system since + * there isn't much point in holding memory we can't use + */ + if (dma_mapping_error(rx_ring->dev, dma)) { + put_page(page); + bi->page = NULL; - if (dma_mapping_error(rx_ring->dev, page_dma)) { rx_ring->rx_stats.alloc_rx_page_failed++; return false; } - bi->page_dma = page_dma; - bi->page_offset = page_offset; + bi->dma = dma; + bi->page_offset ^= ixgbe_rx_bufsz(rx_ring); + return true; } @@ -1157,30 +1131,23 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) struct ixgbe_rx_buffer *bi; u16 i = rx_ring->next_to_use; - /* nothing to do or no valid netdev defined */ - if (!cleaned_count || !rx_ring->netdev) + /* nothing to do */ + if (!cleaned_count) return; rx_desc = IXGBE_RX_DESC(rx_ring, i); bi = &rx_ring->rx_buffer_info[i]; i -= rx_ring->count; - while (cleaned_count--) { - if (!ixgbe_alloc_mapped_skb(rx_ring, bi)) + do { + if (!ixgbe_alloc_mapped_page(rx_ring, bi)) break; - /* Refresh the desc even if buffer_addrs didn't change - * because each write-back erases this info. */ - if (ring_is_ps_enabled(rx_ring)) { - rx_desc->read.hdr_addr = cpu_to_le64(bi->dma); - - if (!ixgbe_alloc_mapped_page(rx_ring, bi)) - break; - - rx_desc->read.pkt_addr = cpu_to_le64(bi->page_dma); - } else { - rx_desc->read.pkt_addr = cpu_to_le64(bi->dma); - } + /* + * Refresh the desc even if buffer_addrs didn't change + * because each write-back erases this info. + */ + rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset); rx_desc++; bi++; @@ -1193,7 +1160,9 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) /* clear the hdr_addr for the next_to_use descriptor */ rx_desc->read.hdr_addr = 0; - } + + cleaned_count--; + } while (cleaned_count); i += rx_ring->count; @@ -1201,90 +1170,6 @@ void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count) ixgbe_release_rx_desc(rx_ring, i); } -static inline u16 ixgbe_get_hlen(union ixgbe_adv_rx_desc *rx_desc) -{ - /* HW will not DMA in data larger than the given buffer, even if it - * parses the (NFS, of course) header to be larger. In that case, it - * fills the header buffer and spills the rest into the page. - */ - u16 hdr_info = le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.hdr_info); - u16 hlen = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >> - IXGBE_RXDADV_HDRBUFLEN_SHIFT; - if (hlen > IXGBE_RX_HDR_SIZE) - hlen = IXGBE_RX_HDR_SIZE; - return hlen; -} - -/** - * ixgbe_merge_active_tail - merge active tail into lro skb - * @tail: pointer to active tail in frag_list - * - * This function merges the length and data of an active tail into the - * skb containing the frag_list. It resets the tail's pointer to the head, - * but it leaves the heads pointer to tail intact. - **/ -static inline struct sk_buff *ixgbe_merge_active_tail(struct sk_buff *tail) -{ - struct sk_buff *head = IXGBE_CB(tail)->head; - - if (!head) - return tail; - - head->len += tail->len; - head->data_len += tail->len; - head->truesize += tail->len; - - IXGBE_CB(tail)->head = NULL; - - return head; -} - -/** - * ixgbe_add_active_tail - adds an active tail into the skb frag_list - * @head: pointer to the start of the skb - * @tail: pointer to active tail to add to frag_list - * - * This function adds an active tail to the end of the frag list. This tail - * will still be receiving data so we cannot yet ad it's stats to the main - * skb. That is done via ixgbe_merge_active_tail. - **/ -static inline void ixgbe_add_active_tail(struct sk_buff *head, - struct sk_buff *tail) -{ - struct sk_buff *old_tail = IXGBE_CB(head)->tail; - - if (old_tail) { - ixgbe_merge_active_tail(old_tail); - old_tail->next = tail; - } else { - skb_shinfo(head)->frag_list = tail; - } - - IXGBE_CB(tail)->head = head; - IXGBE_CB(head)->tail = tail; -} - -/** - * ixgbe_close_active_frag_list - cleanup pointers on a frag_list skb - * @head: pointer to head of an active frag list - * - * This function will clear the frag_tail_tracker pointer on an active - * frag_list and returns true if the pointer was actually set - **/ -static inline bool ixgbe_close_active_frag_list(struct sk_buff *head) -{ - struct sk_buff *tail = IXGBE_CB(head)->tail; - - if (!tail) - return false; - - ixgbe_merge_active_tail(tail); - - IXGBE_CB(head)->tail = NULL; - - return true; -} - /** * ixgbe_get_headlen - determine size of header for RSC/LRO/GRO/FCOE * @data: pointer to the start of the headers @@ -1346,7 +1231,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data, /* record next protocol */ nexthdr = hdr.ipv4->protocol; hdr.network += hlen; -#ifdef CONFIG_FCOE +#ifdef IXGBE_FCOE } else if (protocol == __constant_htons(ETH_P_FCOE)) { if ((hdr.network - data) > (max_len - FCOE_HEADER_LEN)) return max_len; @@ -1409,7 +1294,7 @@ static void ixgbe_get_rsc_cnt(struct ixgbe_ring *rx_ring, static void ixgbe_set_rsc_gso_size(struct ixgbe_ring *ring, struct sk_buff *skb) { - u16 hdr_len = ixgbe_get_headlen(skb->data, skb_headlen(skb)); + u16 hdr_len = skb_headlen(skb); /* set gso_size to avoid messing up TCP MSS */ skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->len - hdr_len), @@ -1473,150 +1358,346 @@ static void ixgbe_rx_skb(struct ixgbe_q_vector *q_vector, netif_rx(skb); } +/** + * ixgbe_is_non_eop - process handling of non-EOP buffers + * @rx_ring: Rx ring being processed + * @rx_desc: Rx descriptor for current buffer + * @skb: Current socket buffer containing buffer in progress + * + * This function updates next to clean. If the buffer is an EOP buffer + * this function exits returning false, otherwise it will place the + * sk_buff in the next buffer to be chained and return true indicating + * that this is in fact a non-EOP buffer. + **/ +static bool ixgbe_is_non_eop(struct ixgbe_ring *rx_ring, + union ixgbe_adv_rx_desc *rx_desc, + struct sk_buff *skb) +{ + u32 ntc = rx_ring->next_to_clean + 1; + + /* fetch, update, and store next to clean */ + ntc = (ntc < rx_ring->count) ? ntc : 0; + rx_ring->next_to_clean = ntc; + + prefetch(IXGBE_RX_DESC(rx_ring, ntc)); + + if (likely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_EOP))) + return false; + + /* append_cnt indicates packet is RSC, if so fetch nextp */ + if (IXGBE_CB(skb)->append_cnt) { + ntc = le32_to_cpu(rx_desc->wb.upper.status_error); + ntc &= IXGBE_RXDADV_NEXTP_MASK; + ntc >>= IXGBE_RXDADV_NEXTP_SHIFT; + } + + /* place skb in next buffer to be received */ + rx_ring->rx_buffer_info[ntc].skb = skb; + rx_ring->rx_stats.non_eop_descs++; + + return true; +} + +/** + * ixgbe_cleanup_headers - Correct corrupted or empty headers + * @rx_ring: rx descriptor ring packet is being transacted on + * @rx_desc: pointer to the EOP Rx descriptor + * @skb: pointer to current skb being fixed + * + * Check for corrupted packet headers caused by senders on the local L2 + * embedded NIC switch not setting up their Tx Descriptors right. These + * should be very rare. + * + * Also address the case where we are pulling data in on pages only + * and as such no data is present in the skb header. + * + * In addition if skb is not at least 60 bytes we need to pad it so that + * it is large enough to qualify as a valid Ethernet frame. + * + * Returns true if an error was encountered and skb was freed. + **/ +static bool ixgbe_cleanup_headers(struct ixgbe_ring *rx_ring, + union ixgbe_adv_rx_desc *rx_desc, + struct sk_buff *skb) +{ + struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[0]; + struct net_device *netdev = rx_ring->netdev; + unsigned char *va; + unsigned int pull_len; + + /* if the page was released unmap it, else just sync our portion */ + if (unlikely(IXGBE_CB(skb)->page_released)) { + dma_unmap_page(rx_ring->dev, IXGBE_CB(skb)->dma, + ixgbe_rx_pg_size(rx_ring), DMA_FROM_DEVICE); + IXGBE_CB(skb)->page_released = false; + } else { + dma_sync_single_range_for_cpu(rx_ring->dev, + IXGBE_CB(skb)->dma, + frag->page_offset, + ixgbe_rx_bufsz(rx_ring), + DMA_FROM_DEVICE); + } + IXGBE_CB(skb)->dma = 0; + + /* verify that the packet does not have any known errors */ + if (unlikely(ixgbe_test_staterr(rx_desc, + IXGBE_RXDADV_ERR_FRAME_ERR_MASK) && + !(netdev->features & NETIF_F_RXALL))) { + dev_kfree_skb_any(skb); + return true; + } + + /* + * it is valid to use page_address instead of kmap since we are + * working with pages allocated out of the lomem pool per + * alloc_page(GFP_ATOMIC) + */ + va = skb_frag_address(frag); + + /* + * we need the header to contain the greater of either ETH_HLEN or + * 60 bytes if the skb->len is less than 60 for skb_pad. + */ + pull_len = skb_frag_size(frag); + if (pull_len > 256) + pull_len = ixgbe_get_headlen(va, pull_len); + + /* align pull length to size of long to optimize memcpy performance */ + skb_copy_to_linear_data(skb, va, ALIGN(pull_len, sizeof(long))); + + /* update all of the pointers */ + skb_frag_size_sub(frag, pull_len); + frag->page_offset += pull_len; + skb->data_len -= pull_len; + skb->tail += pull_len; + + /* + * if we sucked the frag empty then we should free it, + * if there are other frags here something is screwed up in hardware + */ + if (skb_frag_size(frag) == 0) { + BUG_ON(skb_shinfo(skb)->nr_frags != 1); + skb_shinfo(skb)->nr_frags = 0; + __skb_frag_unref(frag); + skb->truesize -= ixgbe_rx_bufsz(rx_ring); + } + + /* if skb_pad returns an error the skb was freed */ + if (unlikely(skb->len < 60)) { + int pad_len = 60 - skb->len; + + if (skb_pad(skb, pad_len)) + return true; + __skb_put(skb, pad_len); + } + + return false; +} + +/** + * ixgbe_can_reuse_page - determine if we can reuse a page + * @rx_buffer: pointer to rx_buffer containing the page we want to reuse + * + * Returns true if page can be reused in another Rx buffer + **/ +static inline bool ixgbe_can_reuse_page(struct ixgbe_rx_buffer *rx_buffer) +{ + struct page *page = rx_buffer->page; + + /* if we are only owner of page and it is local we can reuse it */ + return likely(page_count(page) == 1) && + likely(page_to_nid(page) == numa_node_id()); +} + +/** + * ixgbe_reuse_rx_page - page flip buffer and store it back on the ring + * @rx_ring: rx descriptor ring to store buffers on + * @old_buff: donor buffer to have page reused + * + * Syncronizes page for reuse by the adapter + **/ +static void ixgbe_reuse_rx_page(struct ixgbe_ring *rx_ring, + struct ixgbe_rx_buffer *old_buff) +{ + struct ixgbe_rx_buffer *new_buff; + u16 nta = rx_ring->next_to_alloc; + u16 bufsz = ixgbe_rx_bufsz(rx_ring); + + new_buff = &rx_ring->rx_buffer_info[nta]; + + /* update, and store next to alloc */ + nta++; + rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0; + + /* transfer page from old buffer to new buffer */ + new_buff->page = old_buff->page; + new_buff->dma = old_buff->dma; + + /* flip page offset to other buffer and store to new_buff */ + new_buff->page_offset = old_buff->page_offset ^ bufsz; + + /* sync the buffer for use by the device */ + dma_sync_single_range_for_device(rx_ring->dev, new_buff->dma, + new_buff->page_offset, bufsz, + DMA_FROM_DEVICE); + + /* bump ref count on page before it is given to the stack */ + get_page(new_buff->page); +} + +/** + * ixgbe_add_rx_frag - Add contents of Rx buffer to sk_buff + * @rx_ring: rx descriptor ring to transact packets on + * @rx_buffer: buffer containing page to add + * @rx_desc: descriptor containing length of buffer written by hardware + * @skb: sk_buff to place the data into + * + * This function is based on skb_add_rx_frag. I would have used that + * function however it doesn't handle the truesize case correctly since we + * are allocating more memory than might be used for a single receive. + **/ +static void ixgbe_add_rx_frag(struct ixgbe_ring *rx_ring, + struct ixgbe_rx_buffer *rx_buffer, + struct sk_buff *skb, int size) +{ + skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, + rx_buffer->page, rx_buffer->page_offset, + size); + skb->len += size; + skb->data_len += size; + skb->truesize += ixgbe_rx_bufsz(rx_ring); +} + +/** + * ixgbe_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf + * @q_vector: structure containing interrupt and ring information + * @rx_ring: rx descriptor ring to transact packets on + * @budget: Total limit on number of packets to process + * + * This function provides a "bounce buffer" approach to Rx interrupt + * processing. The advantage to this is that on systems that have + * expensive overhead for IOMMU access this provides a means of avoiding + * it by maintaining the mapping of the page to the syste. + * + * Returns true if all work is completed without reaching budget + **/ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, struct ixgbe_ring *rx_ring, int budget) { - union ixgbe_adv_rx_desc *rx_desc, *next_rxd; - struct ixgbe_rx_buffer *rx_buffer_info; - struct sk_buff *skb; unsigned int total_rx_bytes = 0, total_rx_packets = 0; - const int current_node = numa_node_id(); - struct ixgbe_adapter *adapter = q_vector->adapter; #ifdef IXGBE_FCOE + struct ixgbe_adapter *adapter = q_vector->adapter; int ddp_bytes = 0; #endif /* IXGBE_FCOE */ - u16 i; - u16 cleaned_count = 0; + u16 cleaned_count = ixgbe_desc_unused(rx_ring); - i = rx_ring->next_to_clean; - rx_desc = IXGBE_RX_DESC(rx_ring, i); + do { + struct ixgbe_rx_buffer *rx_buffer; + union ixgbe_adv_rx_desc *rx_desc; + struct sk_buff *skb; + struct page *page; + u16 ntc; - while (ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) { - u32 upper_len = 0; + /* return some buffers to hardware, one at a time is too slow */ + if (cleaned_count >= IXGBE_RX_BUFFER_WRITE) { + ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); + cleaned_count = 0; + } - rmb(); /* read descriptor and rx_buffer_info after status DD */ + ntc = rx_ring->next_to_clean; + rx_desc = IXGBE_RX_DESC(rx_ring, ntc); + rx_buffer = &rx_ring->rx_buffer_info[ntc]; - rx_buffer_info = &rx_ring->rx_buffer_info[i]; + if (!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) + break; - skb = rx_buffer_info->skb; - rx_buffer_info->skb = NULL; - prefetch(skb->data); + /* + * This memory barrier is needed to keep us from reading + * any other fields out of the rx_desc until we know the + * RXD_STAT_DD bit is set + */ + rmb(); - /* linear means we are building an skb from multiple pages */ - if (!skb_is_nonlinear(skb)) { - u16 hlen; - if (ring_is_ps_enabled(rx_ring)) { - hlen = ixgbe_get_hlen(rx_desc); - upper_len = le16_to_cpu(rx_desc->wb.upper.length); - } else { - hlen = le16_to_cpu(rx_desc->wb.upper.length); + page = rx_buffer->page; + prefetchw(page); + + skb = rx_buffer->skb; + + if (likely(!skb)) { + void *page_addr = page_address(page) + + rx_buffer->page_offset; + + /* prefetch first cache line of first page */ + prefetch(page_addr); +#if L1_CACHE_BYTES < 128 + prefetch(page_addr + L1_CACHE_BYTES); +#endif + + /* allocate a skb to store the frags */ + skb = netdev_alloc_skb_ip_align(rx_ring->netdev, + IXGBE_RX_HDR_SIZE); + if (unlikely(!skb)) { + rx_ring->rx_stats.alloc_rx_buff_failed++; + break; } - skb_put(skb, hlen); + /* + * we will be copying header into skb->data in + * pskb_may_pull so it is in our interest to prefetch + * it now to avoid a possible cache miss + */ + prefetchw(skb->data); /* * Delay unmapping of the first packet. It carries the * header information, HW may still access the header - * after writeback. Only unmap it when EOP is reached + * after the writeback. Only unmap it when EOP is + * reached */ - if (!IXGBE_CB(skb)->head) { - IXGBE_CB(skb)->delay_unmap = true; - IXGBE_CB(skb)->dma = rx_buffer_info->dma; - } else { - skb = ixgbe_merge_active_tail(skb); - dma_unmap_single(rx_ring->dev, - rx_buffer_info->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - } - rx_buffer_info->dma = 0; + IXGBE_CB(skb)->dma = rx_buffer->dma; } else { - /* assume packet split since header is unmapped */ - upper_len = le16_to_cpu(rx_desc->wb.upper.length); + /* we are reusing so sync this buffer for CPU use */ + dma_sync_single_range_for_cpu(rx_ring->dev, + rx_buffer->dma, + rx_buffer->page_offset, + ixgbe_rx_bufsz(rx_ring), + DMA_FROM_DEVICE); } - if (upper_len) { - dma_unmap_page(rx_ring->dev, - rx_buffer_info->page_dma, - PAGE_SIZE / 2, - DMA_FROM_DEVICE); - rx_buffer_info->page_dma = 0; - skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, - rx_buffer_info->page, - rx_buffer_info->page_offset, - upper_len); - - if ((page_count(rx_buffer_info->page) == 1) && - (page_to_nid(rx_buffer_info->page) == current_node)) - get_page(rx_buffer_info->page); - else - rx_buffer_info->page = NULL; + /* pull page into skb */ + ixgbe_add_rx_frag(rx_ring, rx_buffer, skb, + le16_to_cpu(rx_desc->wb.upper.length)); - skb->len += upper_len; - skb->data_len += upper_len; - skb->truesize += PAGE_SIZE / 2; + if (ixgbe_can_reuse_page(rx_buffer)) { + /* hand second half of page back to the ring */ + ixgbe_reuse_rx_page(rx_ring, rx_buffer); + } else if (IXGBE_CB(skb)->dma == rx_buffer->dma) { + /* the page has been released from the ring */ + IXGBE_CB(skb)->page_released = true; + } else { + /* we are not reusing the buffer so unmap it */ + dma_unmap_page(rx_ring->dev, rx_buffer->dma, + ixgbe_rx_pg_size(rx_ring), + DMA_FROM_DEVICE); } - ixgbe_get_rsc_cnt(rx_ring, rx_desc, skb); + /* clear contents of buffer_info */ + rx_buffer->skb = NULL; + rx_buffer->dma = 0; + rx_buffer->page = NULL; - i++; - if (i == rx_ring->count) - i = 0; + ixgbe_get_rsc_cnt(rx_ring, rx_desc, skb); - next_rxd = IXGBE_RX_DESC(rx_ring, i); - prefetch(next_rxd); cleaned_count++; - if ((!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_EOP))) { - struct ixgbe_rx_buffer *next_buffer; - u32 nextp; - - if (IXGBE_CB(skb)->append_cnt) { - nextp = le32_to_cpu( - rx_desc->wb.upper.status_error); - nextp >>= IXGBE_RXDADV_NEXTP_SHIFT; - } else { - nextp = i; - } - - next_buffer = &rx_ring->rx_buffer_info[nextp]; - - if (ring_is_ps_enabled(rx_ring)) { - rx_buffer_info->skb = next_buffer->skb; - rx_buffer_info->dma = next_buffer->dma; - next_buffer->skb = skb; - next_buffer->dma = 0; - } else { - struct sk_buff *next_skb = next_buffer->skb; - ixgbe_add_active_tail(skb, next_skb); - IXGBE_CB(next_skb)->head = skb; - } - rx_ring->rx_stats.non_eop_descs++; - goto next_desc; - } - - dma_unmap_single(rx_ring->dev, - IXGBE_CB(skb)->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - IXGBE_CB(skb)->dma = 0; - IXGBE_CB(skb)->delay_unmap = false; - - if (ixgbe_close_active_frag_list(skb) && - !IXGBE_CB(skb)->append_cnt) { - /* if we got here without RSC the packet is invalid */ - dev_kfree_skb_any(skb); - goto next_desc; - } + /* place incomplete frames back on ring for completion */ + if (ixgbe_is_non_eop(rx_ring, rx_desc, skb)) + continue; - /* ERR_MASK will only have valid bits if EOP set */ - if (unlikely(ixgbe_test_staterr(rx_desc, - IXGBE_RXDADV_ERR_FRAME_ERR_MASK) && - !(adapter->netdev->features & NETIF_F_RXALL))) { - dev_kfree_skb_any(skb); - goto next_desc; - } + /* verify the packet layout is correct */ + if (ixgbe_cleanup_headers(rx_ring, rx_desc, skb)) + continue; /* probably a little skewed due to removing CRC */ total_rx_bytes += skb->len; @@ -1631,32 +1712,16 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, ddp_bytes = ixgbe_fcoe_ddp(adapter, rx_desc, skb); if (!ddp_bytes) { dev_kfree_skb_any(skb); - goto next_desc; + continue; } } + #endif /* IXGBE_FCOE */ ixgbe_rx_skb(q_vector, skb); + /* update budget accounting */ budget--; -next_desc: - if (!budget) - break; - - /* return some buffers to hardware, one at a time is too slow */ - if (cleaned_count >= IXGBE_RX_BUFFER_WRITE) { - ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); - cleaned_count = 0; - } - - /* use prefetched values */ - rx_desc = next_rxd; - } - - rx_ring->next_to_clean = i; - cleaned_count = ixgbe_desc_unused(rx_ring); - - if (cleaned_count) - ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); + } while (likely(budget)); #ifdef IXGBE_FCOE /* include DDPed FCoE data */ @@ -1671,8 +1736,8 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, total_rx_bytes += ddp_bytes; total_rx_packets += DIV_ROUND_UP(ddp_bytes, mss); } -#endif /* IXGBE_FCOE */ +#endif /* IXGBE_FCOE */ u64_stats_update_begin(&rx_ring->syncp); rx_ring->stats.packets += total_rx_packets; rx_ring->stats.bytes += total_rx_bytes; @@ -1680,6 +1745,9 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, q_vector->rx.total_packets += total_rx_packets; q_vector->rx.total_bytes += total_rx_bytes; + if (cleaned_count) + ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); + return !!budget; } @@ -2635,18 +2703,12 @@ static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter, srrctl |= (IXGBE_RX_HDR_SIZE << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) & IXGBE_SRRCTL_BSIZEHDR_MASK; - if (ring_is_ps_enabled(rx_ring)) { -#if (PAGE_SIZE / 2) > IXGBE_MAX_RXBUFFER - srrctl |= IXGBE_MAX_RXBUFFER >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; +#if PAGE_SIZE > IXGBE_MAX_RXBUFFER + srrctl |= IXGBE_MAX_RXBUFFER >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; #else - srrctl |= (PAGE_SIZE / 2) >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; + srrctl |= ixgbe_rx_bufsz(rx_ring) >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; #endif - srrctl |= IXGBE_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS; - } else { - srrctl |= ALIGN(rx_ring->rx_buf_len, 1024) >> - IXGBE_SRRCTL_BSIZEPKT_SHIFT; - srrctl |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF; - } + srrctl |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF; IXGBE_WRITE_REG(&adapter->hw, IXGBE_SRRCTL(reg_idx), srrctl); } @@ -2729,13 +2791,11 @@ static void ixgbe_configure_rscctl(struct ixgbe_adapter *adapter, { struct ixgbe_hw *hw = &adapter->hw; u32 rscctrl; - int rx_buf_len; u8 reg_idx = ring->reg_idx; if (!ring_is_rsc_enabled(ring)) return; - rx_buf_len = ring->rx_buf_len; rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(reg_idx)); rscctrl |= IXGBE_RSCCTL_RSCEN; /* @@ -2743,24 +2803,13 @@ static void ixgbe_configure_rscctl(struct ixgbe_adapter *adapter, * total size of max desc * buf_len is not greater * than 65536 */ - if (ring_is_ps_enabled(ring)) { -#if (PAGE_SIZE < 8192) - rscctrl |= IXGBE_RSCCTL_MAXDESC_16; -#elif (PAGE_SIZE < 16384) - rscctrl |= IXGBE_RSCCTL_MAXDESC_8; -#elif (PAGE_SIZE < 32768) - rscctrl |= IXGBE_RSCCTL_MAXDESC_4; +#if (PAGE_SIZE <= 8192) + rscctrl |= IXGBE_RSCCTL_MAXDESC_16; +#elif (PAGE_SIZE <= 16384) + rscctrl |= IXGBE_RSCCTL_MAXDESC_8; #else - rscctrl |= IXGBE_RSCCTL_MAXDESC_1; + rscctrl |= IXGBE_RSCCTL_MAXDESC_4; #endif - } else { - if (rx_buf_len <= IXGBE_RXBUFFER_4K) - rscctrl |= IXGBE_RSCCTL_MAXDESC_16; - else if (rx_buf_len <= IXGBE_RXBUFFER_8K) - rscctrl |= IXGBE_RSCCTL_MAXDESC_8; - else - rscctrl |= IXGBE_RSCCTL_MAXDESC_4; - } IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(reg_idx), rscctrl); } @@ -2977,23 +3026,10 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) struct ixgbe_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; - int rx_buf_len; struct ixgbe_ring *rx_ring; int i; u32 mhadd, hlreg0; - /* Decide whether to use packet split mode or not */ - /* On by default */ - adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED; - - /* Do not use packet split if we're in SR-IOV Mode */ - if (adapter->num_vfs) - adapter->flags &= ~IXGBE_FLAG_RX_PS_ENABLED; - - /* Disable packet split due to 82599 erratum #45 */ - if (hw->mac.type == ixgbe_mac_82599EB) - adapter->flags &= ~IXGBE_FLAG_RX_PS_ENABLED; - #ifdef IXGBE_FCOE /* adjust max frame to be able to do baby jumbo for FCoE */ if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) && @@ -3012,27 +3048,6 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) /* MHADD will allow an extra 4 bytes past for vlan tagged frames */ max_frame += VLAN_HLEN; - /* Set the RX buffer length according to the mode */ - if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { - rx_buf_len = IXGBE_RX_HDR_SIZE; - } else { - if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) && - (netdev->mtu <= ETH_DATA_LEN)) - rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE; - /* - * Make best use of allocation by using all but 1K of a - * power of 2 allocation that will be used for skb->head. - */ - else if (max_frame <= IXGBE_RXBUFFER_3K) - rx_buf_len = IXGBE_RXBUFFER_3K; - else if (max_frame <= IXGBE_RXBUFFER_7K) - rx_buf_len = IXGBE_RXBUFFER_7K; - else if (max_frame <= IXGBE_RXBUFFER_15K) - rx_buf_len = IXGBE_RXBUFFER_15K; - else - rx_buf_len = IXGBE_MAX_RXBUFFER; - } - hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); /* set jumbo enable since MHADD.MFS is keeping size locked at max_frame */ hlreg0 |= IXGBE_HLREG0_JUMBOEN; @@ -3044,32 +3059,16 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) */ for (i = 0; i < adapter->num_rx_queues; i++) { rx_ring = adapter->rx_ring[i]; - rx_ring->rx_buf_len = rx_buf_len; - - if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) - set_ring_ps_enabled(rx_ring); - else - clear_ring_ps_enabled(rx_ring); - if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) set_ring_rsc_enabled(rx_ring); else clear_ring_rsc_enabled(rx_ring); - #ifdef IXGBE_FCOE if (netdev->features & NETIF_F_FCOE_MTU) { struct ixgbe_ring_feature *f; f = &adapter->ring_feature[RING_F_FCOE]; - if ((i >= f->mask) && (i < f->mask + f->indices)) { - clear_ring_ps_enabled(rx_ring); - if (rx_buf_len < IXGBE_FCOE_JUMBO_FRAME_SIZE) - rx_ring->rx_buf_len = - IXGBE_FCOE_JUMBO_FRAME_SIZE; - } else if (!ring_is_rsc_enabled(rx_ring) && - !ring_is_ps_enabled(rx_ring)) { - rx_ring->rx_buf_len = - IXGBE_FCOE_JUMBO_FRAME_SIZE; - } + if ((i >= f->mask) && (i < f->mask + f->indices)) + set_bit(__IXGBE_RX_FCOE_BUFSZ, &rx_ring->state); } #endif /* IXGBE_FCOE */ } @@ -3990,6 +3989,27 @@ void ixgbe_reset(struct ixgbe_adapter *adapter) IXGBE_RAH_AV); } +/** + * ixgbe_init_rx_page_offset - initialize page offset values for Rx buffers + * @rx_ring: ring to setup + * + * On many IA platforms the L1 cache has a critical stride of 4K, this + * results in each receive buffer starting in the same cache set. To help + * reduce the pressure on this cache set we can interleave the offsets so + * that only every other buffer will be in the same cache set. + **/ +static void ixgbe_init_rx_page_offset(struct ixgbe_ring *rx_ring) +{ + struct ixgbe_rx_buffer *rx_buffer = rx_ring->rx_buffer_info; + u16 i; + + for (i = 0; i < rx_ring->count; i += 2) { + rx_buffer[0].page_offset = 0; + rx_buffer[1].page_offset = ixgbe_rx_bufsz(rx_ring); + rx_buffer = &rx_buffer[2]; + } +} + /** * ixgbe_clean_rx_ring - Free Rx Buffers per Queue * @rx_ring: ring to free buffers from @@ -4006,49 +4026,40 @@ static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring) /* Free all the Rx ring sk_buffs */ for (i = 0; i < rx_ring->count; i++) { - struct ixgbe_rx_buffer *rx_buffer_info; - - rx_buffer_info = &rx_ring->rx_buffer_info[i]; - if (rx_buffer_info->dma) { - dma_unmap_single(rx_ring->dev, rx_buffer_info->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - rx_buffer_info->dma = 0; - } - if (rx_buffer_info->skb) { - struct sk_buff *skb = rx_buffer_info->skb; - rx_buffer_info->skb = NULL; - /* We need to clean up RSC frag lists */ - skb = ixgbe_merge_active_tail(skb); - ixgbe_close_active_frag_list(skb); - if (IXGBE_CB(skb)->delay_unmap) { - dma_unmap_single(dev, - IXGBE_CB(skb)->dma, - rx_ring->rx_buf_len, - DMA_FROM_DEVICE); - IXGBE_CB(skb)->dma = 0; - IXGBE_CB(skb)->delay_unmap = false; + struct ixgbe_rx_buffer *rx_buffer; + + rx_buffer = &rx_ring->rx_buffer_info[i]; + if (rx_buffer->skb) { + struct sk_buff *skb = rx_buffer->skb; + if (IXGBE_CB(skb)->page_released) { + dma_unmap_page(dev, + IXGBE_CB(skb)->dma, + ixgbe_rx_bufsz(rx_ring), + DMA_FROM_DEVICE); + IXGBE_CB(skb)->page_released = false; } dev_kfree_skb(skb); } - if (!rx_buffer_info->page) - continue; - if (rx_buffer_info->page_dma) { - dma_unmap_page(dev, rx_buffer_info->page_dma, - PAGE_SIZE / 2, DMA_FROM_DEVICE); - rx_buffer_info->page_dma = 0; - } - put_page(rx_buffer_info->page); - rx_buffer_info->page = NULL; - rx_buffer_info->page_offset = 0; + rx_buffer->skb = NULL; + if (rx_buffer->dma) + dma_unmap_page(dev, rx_buffer->dma, + ixgbe_rx_pg_size(rx_ring), + DMA_FROM_DEVICE); + rx_buffer->dma = 0; + if (rx_buffer->page) + put_page(rx_buffer->page); + rx_buffer->page = NULL; } size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; memset(rx_ring->rx_buffer_info, 0, size); + ixgbe_init_rx_page_offset(rx_ring); + /* Zero out the descriptor ring */ memset(rx_ring->desc, 0, rx_ring->size); + rx_ring->next_to_alloc = 0; rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; } @@ -5412,6 +5423,8 @@ int ixgbe_setup_rx_resources(struct ixgbe_ring *rx_ring) rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; + ixgbe_init_rx_page_offset(rx_ring); + return 0; err: vfree(rx_ring->rx_buffer_info); -- GitLab From 655309e944fd482e59850d55186571c1b2a91e55 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:35 +0000 Subject: [PATCH 1792/1846] ixgbe: cleanup logic in ixgbe_change_mtu This change is meant to just cleanup the logic in ixgbe_change_mtu since we are making it unnecessarily complex due to a workaround required for 82599 when SR-IOV is enabled. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index e97ef4591ade..db1f17c3ed47 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -5544,20 +5544,24 @@ static void ixgbe_free_all_rx_resources(struct ixgbe_adapter *adapter) static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu) { struct ixgbe_adapter *adapter = netdev_priv(netdev); - struct ixgbe_hw *hw = &adapter->hw; int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; /* MTU < 68 is an error and causes problems on some kernels */ - if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED && - hw->mac.type != ixgbe_mac_X540) { - if ((new_mtu < 68) || (max_frame > MAXIMUM_ETHERNET_VLAN_SIZE)) - return -EINVAL; - } else { - if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE)) + if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE)) + return -EINVAL; + + /* + * For 82599EB we cannot allow PF to change MTU greater than 1500 + * in SR-IOV mode as it may cause buffer overruns in guest VFs that + * don't allocate and chain buffers correctly. + */ + if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) && + (adapter->hw.mac.type == ixgbe_mac_82599EB) && + (max_frame > MAXIMUM_ETHERNET_VLAN_SIZE)) return -EINVAL; - } e_info(probe, "changing MTU from %d to %d\n", netdev->mtu, new_mtu); + /* must set new MTU before calling down or up */ netdev->mtu = new_mtu; -- GitLab From a50c29dd09ed14f8489677813a4b1c8b62dcf19d Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:40 +0000 Subject: [PATCH 1793/1846] ixgbe: Make certain that all frames fit minimum size requirements This change makes certain that any packet we attempt to transmit will meet minimum size requirements for the hardware. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index db1f17c3ed47..bf6d122e6f99 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -7162,11 +7162,27 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, return NETDEV_TX_OK; } -static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev) +static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb, + struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_ring *tx_ring; + if (skb->len <= 0) { + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + + /* + * The minimum packet size for olinfo paylen is 17 so pad the skb + * in order to meet this minimum size requirement. + */ + if (skb->len < 17) { + if (skb_padto(skb, 17)) + return NETDEV_TX_OK; + skb->len = 17; + } + tx_ring = adapter->tx_ring[skb->queue_mapping]; return ixgbe_xmit_frame_ring(skb, adapter, tx_ring); } -- GitLab From 93f5b3c1f148f2cca247a2c5afdd3ba7a123a6f1 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:45 +0000 Subject: [PATCH 1794/1846] ixgbe: Modify setup of descriptor flags to avoid conditional jumps This change makes it more likely that the descriptor flags setup will use cmov instructions instead of conditional jumps when setting up the flags. The advantage to this is that the code should just flow a bit more smoothly. To do this it is necessary to set the TX_FLAGS_CSUM bit in tx_flags when doing TSO so that we also do the checksum in addition to the segmentation offload. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index bf6d122e6f99..efce423586d4 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6689,7 +6689,7 @@ static __le32 ixgbe_tx_cmd_type(u32 tx_flags) /* set segmentation enable bits for TSO/FSO */ #ifdef IXGBE_FCOE - if ((tx_flags & IXGBE_TX_FLAGS_TSO) || (tx_flags & IXGBE_TX_FLAGS_FSO)) + if (tx_flags & (IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_FSO)) #else if (tx_flags & IXGBE_TX_FLAGS_TSO) #endif @@ -6700,33 +6700,33 @@ static __le32 ixgbe_tx_cmd_type(u32 tx_flags) static __le32 ixgbe_tx_olinfo_status(u32 tx_flags, unsigned int paylen) { - __le32 olinfo_status = - cpu_to_le32(paylen << IXGBE_ADVTXD_PAYLEN_SHIFT); - - if (tx_flags & IXGBE_TX_FLAGS_TSO) { - olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_POPTS_TXSM | - (1 << IXGBE_ADVTXD_IDX_SHIFT)); - /* enble IPv4 checksum for TSO */ - if (tx_flags & IXGBE_TX_FLAGS_IPV4) - olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_POPTS_IXSM); - } + __le32 olinfo_status = cpu_to_le32(paylen << IXGBE_ADVTXD_PAYLEN_SHIFT); /* enable L4 checksum for TSO and TX checksum offload */ if (tx_flags & IXGBE_TX_FLAGS_CSUM) olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_POPTS_TXSM); -#ifdef IXGBE_FCOE - /* use index 1 context for FCOE/FSO */ - if (tx_flags & IXGBE_TX_FLAGS_FCOE) - olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_CC | - (1 << IXGBE_ADVTXD_IDX_SHIFT)); + /* enble IPv4 checksum for TSO */ + if (tx_flags & IXGBE_TX_FLAGS_IPV4) + olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_POPTS_IXSM); + /* use index 1 context for TSO/FSO/FCOE */ +#ifdef IXGBE_FCOE + if (tx_flags & (IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_FCOE)) +#else + if (tx_flags & IXGBE_TX_FLAGS_TSO) #endif + olinfo_status |= cpu_to_le32(1 << IXGBE_ADVTXD_IDX_SHIFT); + /* * Check Context must be set if Tx switch is enabled, which it * always is for case where virtual functions are running */ +#ifdef IXGBE_FCOE + if (tx_flags & (IXGBE_TX_FLAGS_TXSW | IXGBE_TX_FLAGS_FCOE)) +#else if (tx_flags & IXGBE_TX_FLAGS_TXSW) +#endif olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_CC); return olinfo_status; @@ -7140,7 +7140,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, if (tso < 0) goto out_drop; else if (tso) - tx_flags |= IXGBE_TX_FLAGS_TSO; + tx_flags |= IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_CSUM; else if (ixgbe_tx_csum(tx_ring, skb, tx_flags, protocol)) tx_flags |= IXGBE_TX_FLAGS_CSUM; -- GitLab From 7d7ce682f8437ff91c964c478b8845ed98a3207d Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:51 +0000 Subject: [PATCH 1795/1846] ixgbe: Use packets to track Tx completions instead of a seperate value A separate value was added to track Tx completions in order to determine if the Tx unit was hung. However we can do the same thing using the number of packets completed without having to add another stat to the Tx ring. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 1 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index b1e3baf8d450..6d4ef1a30890 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -173,7 +173,6 @@ struct ixgbe_queue_stats { struct ixgbe_tx_queue_stats { u64 restart_queue; u64 tx_busy; - u64 completed; u64 tx_done_old; }; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index efce423586d4..832a9fc3ad57 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -661,7 +661,7 @@ static void ixgbe_update_xoff_received(struct ixgbe_adapter *adapter) static u64 ixgbe_get_tx_completed(struct ixgbe_ring *ring) { - return ring->tx_stats.completed; + return ring->stats.packets; } static u64 ixgbe_get_tx_pending(struct ixgbe_ring *ring) @@ -760,9 +760,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD))) break; - /* count the packet as being completed */ - tx_ring->tx_stats.completed++; - /* clear next_to_watch to prevent false hangs */ tx_buffer->next_to_watch = NULL; -- GitLab From fd0db0ed02a6abce5427e90d1e8522322107d62b Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:50:56 +0000 Subject: [PATCH 1796/1846] ixgbe: Place skb on first buffer_info structure to avoid using stack space Instead of keeping a local copy of the skb on the stack for as long as long as we do it makes sense to instead just place it on the first tx_buffer structure so that we can save space on the stack and avoid unnecessary read/write operations copying the pointer out of the stack and onto the ring later. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 11 ++-- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 6 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 52 +++++++++++-------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 6d4ef1a30890..55f31fe58e41 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -150,12 +150,12 @@ struct vf_macvlans { struct ixgbe_tx_buffer { union ixgbe_adv_tx_desc *next_to_watch; unsigned long time_stamp; + struct sk_buff *skb; + unsigned int bytecount; + unsigned short gso_segs; dma_addr_t dma; - u32 length; + unsigned int length; u32 tx_flags; - struct sk_buff *skb; - u32 bytecount; - u16 gso_segs; }; struct ixgbe_rx_buffer { @@ -631,7 +631,8 @@ extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); extern void ixgbe_do_reset(struct net_device *netdev); #ifdef IXGBE_FCOE extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); -extern int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, +extern int ixgbe_fso(struct ixgbe_ring *tx_ring, + struct ixgbe_tx_buffer *first, u32 tx_flags, u8 *hdr_len); extern void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter); extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index da7da752b6b4..910847a901ef 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -447,7 +447,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, /** * ixgbe_fso - ixgbe FCoE Sequence Offload (FSO) * @tx_ring: tx desc ring - * @skb: associated skb + * @first: first tx_buffer structure containing skb, tx_flags, and protocol * @tx_flags: tx flags * @hdr_len: hdr_len to be returned * @@ -455,9 +455,11 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, * * Returns : 0 indicates no FSO, > 0 for FSO, < 0 for error */ -int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, +int ixgbe_fso(struct ixgbe_ring *tx_ring, + struct ixgbe_tx_buffer *first, u32 tx_flags, u8 *hdr_len) { + struct sk_buff *skb = first->skb; struct fc_frame_header *fh; u32 vlan_macip_lens; u32 fcoe_sof_eof = 0; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 832a9fc3ad57..c05d560c004f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -763,12 +763,16 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, /* clear next_to_watch to prevent false hangs */ tx_buffer->next_to_watch = NULL; + /* free the skb */ + dev_kfree_skb_any(tx_buffer->skb); + + /* clear tx_buffer data */ + tx_buffer->skb = NULL; + do { ixgbe_unmap_tx_resource(tx_ring, tx_buffer); if (likely(tx_desc == eop_desc)) { eop_desc = NULL; - dev_kfree_skb_any(tx_buffer->skb); - tx_buffer->skb = NULL; total_bytes += tx_buffer->bytecount; total_packets += tx_buffer->gso_segs; @@ -6551,9 +6555,11 @@ void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens, context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); } -static int ixgbe_tso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, +static int ixgbe_tso(struct ixgbe_ring *tx_ring, + struct ixgbe_tx_buffer *first, u32 tx_flags, __be16 protocol, u8 *hdr_len) { + struct sk_buff *skb = first->skb; int err; u32 vlan_macip_lens, type_tucmd; u32 mss_l4len_idx, l4len; @@ -6607,9 +6613,10 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, } static bool ixgbe_tx_csum(struct ixgbe_ring *tx_ring, - struct sk_buff *skb, u32 tx_flags, - __be16 protocol) + struct ixgbe_tx_buffer *first, + u32 tx_flags, __be16 protocol) { + struct sk_buff *skb = first->skb; u32 vlan_macip_lens = 0; u32 mss_l4len_idx = 0; u32 type_tucmd = 0; @@ -6733,11 +6740,11 @@ static __le32 ixgbe_tx_olinfo_status(u32 tx_flags, unsigned int paylen) IXGBE_TXD_CMD_RS) static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, - struct sk_buff *skb, struct ixgbe_tx_buffer *first, u32 tx_flags, const u8 hdr_len) { + struct sk_buff *skb = first->skb; struct device *dev = tx_ring->dev; struct ixgbe_tx_buffer *tx_buffer_info; union ixgbe_adv_tx_desc *tx_desc; @@ -6850,7 +6857,6 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, /* multiply data chunks by size of headers */ tx_buffer_info->bytecount = paylen + (gso_segs * hdr_len); tx_buffer_info->gso_segs = gso_segs; - tx_buffer_info->skb = skb; netdev_tx_sent_queue(txring_txq(tx_ring), tx_buffer_info->bytecount); @@ -6878,7 +6884,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, /* clear dma mappings for failed tx_buffer_info map */ for (;;) { tx_buffer_info = &tx_ring->tx_buffer_info[i]; - ixgbe_unmap_tx_resource(tx_ring, tx_buffer_info); + ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer_info); if (tx_buffer_info == first) break; if (i == 0) @@ -6886,12 +6892,11 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, i--; } - dev_kfree_skb_any(skb); - tx_ring->next_to_use = i; } -static void ixgbe_atr(struct ixgbe_ring *ring, struct sk_buff *skb, +static void ixgbe_atr(struct ixgbe_ring *ring, + struct ixgbe_tx_buffer *first, u32 tx_flags, __be16 protocol) { struct ixgbe_q_vector *q_vector = ring->q_vector; @@ -6916,7 +6921,7 @@ static void ixgbe_atr(struct ixgbe_ring *ring, struct sk_buff *skb, ring->atr_count++; /* snag network header to get L4 type and address */ - hdr.network = skb_network_header(skb); + hdr.network = skb_network_header(first->skb); /* Currently only IPv4/IPv6 with TCP is supported */ if ((protocol != __constant_htons(ETH_P_IPV6) || @@ -6925,7 +6930,7 @@ static void ixgbe_atr(struct ixgbe_ring *ring, struct sk_buff *skb, hdr.ipv4->protocol != IPPROTO_TCP)) return; - th = tcp_hdr(skb); + th = tcp_hdr(first->skb); /* skip this packet since it is invalid or the socket is closing */ if (!th || th->fin) @@ -7063,6 +7068,10 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, return NETDEV_TX_BUSY; } + /* record the location of the first descriptor for this packet */ + first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; + first->skb = skb; + /* if we have a HW VLAN tag being added default to the HW one */ if (vlan_tx_tag_present(skb)) { tx_flags |= vlan_tx_tag_get(skb) << IXGBE_TX_FLAGS_VLAN_SHIFT; @@ -7109,14 +7118,11 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, } } - /* record the location of the first descriptor for this packet */ - first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; - #ifdef IXGBE_FCOE /* setup tx offload for FCoE */ if ((protocol == __constant_htons(ETH_P_FCOE)) && (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) { - tso = ixgbe_fso(tx_ring, skb, tx_flags, &hdr_len); + tso = ixgbe_fso(tx_ring, first, tx_flags, &hdr_len); if (tso < 0) goto out_drop; else if (tso) @@ -7133,29 +7139,31 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, if (protocol == __constant_htons(ETH_P_IP)) tx_flags |= IXGBE_TX_FLAGS_IPV4; - tso = ixgbe_tso(tx_ring, skb, tx_flags, protocol, &hdr_len); + tso = ixgbe_tso(tx_ring, first, tx_flags, protocol, &hdr_len); if (tso < 0) goto out_drop; else if (tso) tx_flags |= IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_CSUM; - else if (ixgbe_tx_csum(tx_ring, skb, tx_flags, protocol)) + else if (ixgbe_tx_csum(tx_ring, first, tx_flags, protocol)) tx_flags |= IXGBE_TX_FLAGS_CSUM; /* add the ATR filter if ATR is on */ if (test_bit(__IXGBE_TX_FDIR_INIT_DONE, &tx_ring->state)) - ixgbe_atr(tx_ring, skb, tx_flags, protocol); + ixgbe_atr(tx_ring, first, tx_flags, protocol); #ifdef IXGBE_FCOE xmit_fcoe: #endif /* IXGBE_FCOE */ - ixgbe_tx_map(tx_ring, skb, first, tx_flags, hdr_len); + ixgbe_tx_map(tx_ring, first, tx_flags, hdr_len); ixgbe_maybe_stop_tx(tx_ring, DESC_NEEDED); return NETDEV_TX_OK; out_drop: - dev_kfree_skb_any(skb); + dev_kfree_skb_any(first->skb); + first->skb = NULL; + return NETDEV_TX_OK; } -- GitLab From 091a6246869cec2ac66e897b436f7fd59ec4d316 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:01 +0000 Subject: [PATCH 1797/1846] ixgbe: Write gso_segs and bytcount to the ring sooner This change makes it so that gso_segs and bytecount are written to the ring sooner. This helps to simplify the logic for the two since segmentation offloads can now update them within their own function. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 11 ++++-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 35 +++++++------------ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 910847a901ef..5f943d3f85c4 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -532,9 +532,14 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, *hdr_len = sizeof(struct fcoe_crc_eof); /* hdr_len includes fc_hdr if FCoE LSO is enabled */ - if (skb_is_gso(skb)) - *hdr_len += (skb_transport_offset(skb) + - sizeof(struct fc_frame_header)); + if (skb_is_gso(skb)) { + *hdr_len += skb_transport_offset(skb) + + sizeof(struct fc_frame_header); + /* update gso_segs and bytecount */ + first->gso_segs = DIV_ROUND_UP(skb->len - *hdr_len, + skb_shinfo(skb)->gso_size); + first->bytecount += (first->gso_segs - 1) * *hdr_len; + } /* mss_l4len_id: use 1 for FSO as TSO, no need for L4LEN */ mss_l4len_idx = skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index c05d560c004f..40d729eb1443 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -763,6 +763,10 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, /* clear next_to_watch to prevent false hangs */ tx_buffer->next_to_watch = NULL; + /* update the statistics for this packet */ + total_bytes += tx_buffer->bytecount; + total_packets += tx_buffer->gso_segs; + /* free the skb */ dev_kfree_skb_any(tx_buffer->skb); @@ -771,13 +775,9 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, do { ixgbe_unmap_tx_resource(tx_ring, tx_buffer); - if (likely(tx_desc == eop_desc)) { + if (likely(tx_desc == eop_desc)) eop_desc = NULL; - total_bytes += tx_buffer->bytecount; - total_packets += tx_buffer->gso_segs; - } - tx_buffer++; tx_desc++; i++; @@ -6593,9 +6593,14 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, 0, IPPROTO_TCP, 0); } + /* compute header lengths */ l4len = tcp_hdrlen(skb); *hdr_len = skb_transport_offset(skb) + l4len; + /* update gso size and bytecount with header size */ + first->gso_segs = skb_shinfo(skb)->gso_segs; + first->bytecount += (first->gso_segs - 1) * *hdr_len; + /* mss_l4len_id: use 1 as index for TSO */ mss_l4len_idx = l4len << IXGBE_ADVTXD_L4LEN_SHIFT; mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; @@ -6757,7 +6762,6 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, u32 offset = 0; u32 paylen = skb->len - hdr_len; u16 i = tx_ring->next_to_use; - u16 gso_segs; #ifdef IXGBE_FCOE if (tx_flags & IXGBE_TX_FLAGS_FCOE) { @@ -6843,22 +6847,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, tx_ring->next_to_use = i; - if (tx_flags & IXGBE_TX_FLAGS_TSO) - gso_segs = skb_shinfo(skb)->gso_segs; -#ifdef IXGBE_FCOE - /* adjust for FCoE Sequence Offload */ - else if (tx_flags & IXGBE_TX_FLAGS_FSO) - gso_segs = DIV_ROUND_UP(skb->len - hdr_len, - skb_shinfo(skb)->gso_size); -#endif /* IXGBE_FCOE */ - else - gso_segs = 1; - - /* multiply data chunks by size of headers */ - tx_buffer_info->bytecount = paylen + (gso_segs * hdr_len); - tx_buffer_info->gso_segs = gso_segs; - - netdev_tx_sent_queue(txring_txq(tx_ring), tx_buffer_info->bytecount); + netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); /* set the timestamp */ first->time_stamp = jiffies; @@ -7071,6 +7060,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, /* record the location of the first descriptor for this packet */ first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; first->skb = skb; + first->bytecount = skb->len; + first->gso_segs = 1; /* if we have a HW VLAN tag being added default to the HW one */ if (vlan_tx_tag_present(skb)) { -- GitLab From c2ec3ff6b8712f5d951927d7774c805fe3270caa Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Fri, 16 Mar 2012 22:39:29 +0000 Subject: [PATCH 1798/1846] phc: Update author's email address. This commit brings the author email address macros up to date for four modules in the PTP Hardware Clock subsystem. Signed-off-by: Richard Cochran Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/gianfar_ptp.c | 2 +- drivers/net/phy/dp83640.c | 2 +- drivers/ptp/ptp_clock.c | 2 +- drivers/ptp/ptp_ixp46x.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c index 83e0ed757e33..5fd620bec15c 100644 --- a/drivers/net/ethernet/freescale/gianfar_ptp.c +++ b/drivers/net/ethernet/freescale/gianfar_ptp.c @@ -564,6 +564,6 @@ static struct platform_driver gianfar_ptp_driver = { module_platform_driver(gianfar_ptp_driver); -MODULE_AUTHOR("Richard Cochran "); +MODULE_AUTHOR("Richard Cochran "); MODULE_DESCRIPTION("PTP clock using the eTSEC"); MODULE_LICENSE("GPL"); diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index ba3c59147aa7..dd7ae19579d1 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -1243,7 +1243,7 @@ static void __exit dp83640_exit(void) } MODULE_DESCRIPTION("National Semiconductor DP83640 PHY driver"); -MODULE_AUTHOR("Richard Cochran "); +MODULE_AUTHOR("Richard Cochran "); MODULE_LICENSE("GPL"); module_init(dp83640_init); diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index 10451a15e828..f519a131238d 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -340,6 +340,6 @@ static int __init ptp_init(void) subsys_initcall(ptp_init); module_exit(ptp_exit); -MODULE_AUTHOR("Richard Cochran "); +MODULE_AUTHOR("Richard Cochran "); MODULE_DESCRIPTION("PTP clocks support"); MODULE_LICENSE("GPL"); diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/ptp/ptp_ixp46x.c index 803d665b15ef..6f2782bb5f41 100644 --- a/drivers/ptp/ptp_ixp46x.c +++ b/drivers/ptp/ptp_ixp46x.c @@ -327,6 +327,6 @@ static int __init ptp_ixp_init(void) module_init(ptp_ixp_init); module_exit(ptp_ixp_exit); -MODULE_AUTHOR("Richard Cochran "); +MODULE_AUTHOR("Richard Cochran "); MODULE_DESCRIPTION("PTP clock using the IXP46X timer"); MODULE_LICENSE("GPL"); -- GitLab From 729739b754affa482e92fa7836e4066096089d11 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:06 +0000 Subject: [PATCH 1799/1846] ixgbe: always write DMA for single_mapped value with skb This change makes it so that we always write the DMA address for the skb itself on the same tx_buffer struct that the skb is written on. This way we don't need the MAPPED_AS_PAGE flag and we always know it will be the first DMA value that we will have to unmap. In addition I have found an issue in which we were leaking a DMA mapping if the value happened to be 0 which is possible on some platforms. In order to resolve that I have updated the transmit path to use the length instead of the DMA mapping in order to determine if a mapping is actually present. One other tweak in this patch is that it only writes the olinfo information on the first descriptor. As it turns out it isn't necessary to write it for anything but the first descriptor so there is no need to carry it forward. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 5 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 266 ++++++++++-------- 2 files changed, 153 insertions(+), 118 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 55f31fe58e41..e0d809d0ed75 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -96,7 +96,6 @@ #define IXGBE_TX_FLAGS_FCOE (u32)(1 << 5) #define IXGBE_TX_FLAGS_FSO (u32)(1 << 6) #define IXGBE_TX_FLAGS_TXSW (u32)(1 << 7) -#define IXGBE_TX_FLAGS_MAPPED_AS_PAGE (u32)(1 << 8) #define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000 #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0xe0000000 #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT 29 @@ -153,8 +152,8 @@ struct ixgbe_tx_buffer { struct sk_buff *skb; unsigned int bytecount; unsigned short gso_segs; - dma_addr_t dma; - unsigned int length; + DEFINE_DMA_UNMAP_ADDR(dma); + DEFINE_DMA_UNMAP_LEN(len); u32 tx_flags; }; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 40d729eb1443..1d8f9f83f8ed 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -289,7 +289,7 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) struct ixgbe_reg_info *reginfo; int n = 0; struct ixgbe_ring *tx_ring; - struct ixgbe_tx_buffer *tx_buffer_info; + struct ixgbe_tx_buffer *tx_buffer; union ixgbe_adv_tx_desc *tx_desc; struct my_u0 { u64 a; u64 b; } *u0; struct ixgbe_ring *rx_ring; @@ -329,14 +329,13 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n"); for (n = 0; n < adapter->num_tx_queues; n++) { tx_ring = adapter->tx_ring[n]; - tx_buffer_info = - &tx_ring->tx_buffer_info[tx_ring->next_to_clean]; + tx_buffer = &tx_ring->tx_buffer_info[tx_ring->next_to_clean]; pr_info(" %5d %5X %5X %016llX %04X %p %016llX\n", n, tx_ring->next_to_use, tx_ring->next_to_clean, - (u64)tx_buffer_info->dma, - tx_buffer_info->length, - tx_buffer_info->next_to_watch, - (u64)tx_buffer_info->time_stamp); + (u64)dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + tx_buffer->next_to_watch, + (u64)tx_buffer->time_stamp); } /* Print TX Rings */ @@ -367,17 +366,17 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { tx_desc = IXGBE_TX_DESC(tx_ring, i); - tx_buffer_info = &tx_ring->tx_buffer_info[i]; + tx_buffer = &tx_ring->tx_buffer_info[i]; u0 = (struct my_u0 *)tx_desc; pr_info("T [0x%03X] %016llX %016llX %016llX" " %04X %p %016llX %p", i, le64_to_cpu(u0->a), le64_to_cpu(u0->b), - (u64)tx_buffer_info->dma, - tx_buffer_info->length, - tx_buffer_info->next_to_watch, - (u64)tx_buffer_info->time_stamp, - tx_buffer_info->skb); + (u64)dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + tx_buffer->next_to_watch, + (u64)tx_buffer->time_stamp, + tx_buffer->skb); if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean) pr_cont(" NTC/U\n"); @@ -389,11 +388,13 @@ static void ixgbe_dump(struct ixgbe_adapter *adapter) pr_cont("\n"); if (netif_msg_pktdata(adapter) && - tx_buffer_info->dma != 0) + dma_unmap_len(tx_buffer, len) != 0) print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 1, - phys_to_virt(tx_buffer_info->dma), - tx_buffer_info->length, true); + phys_to_virt(dma_unmap_addr(tx_buffer, + dma)), + dma_unmap_len(tx_buffer, len), + true); } } @@ -579,32 +580,26 @@ static inline void ixgbe_irq_rearm_queues(struct ixgbe_adapter *adapter, } } -static inline void ixgbe_unmap_tx_resource(struct ixgbe_ring *ring, - struct ixgbe_tx_buffer *tx_buffer) +void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *ring, + struct ixgbe_tx_buffer *tx_buffer) { - if (tx_buffer->dma) { - if (tx_buffer->tx_flags & IXGBE_TX_FLAGS_MAPPED_AS_PAGE) - dma_unmap_page(ring->dev, - tx_buffer->dma, - tx_buffer->length, - DMA_TO_DEVICE); - else + if (tx_buffer->skb) { + dev_kfree_skb_any(tx_buffer->skb); + if (dma_unmap_len(tx_buffer, len)) dma_unmap_single(ring->dev, - tx_buffer->dma, - tx_buffer->length, - DMA_TO_DEVICE); + dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + DMA_TO_DEVICE); + } else if (dma_unmap_len(tx_buffer, len)) { + dma_unmap_page(ring->dev, + dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + DMA_TO_DEVICE); } - tx_buffer->dma = 0; -} - -void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *tx_ring, - struct ixgbe_tx_buffer *tx_buffer_info) -{ - ixgbe_unmap_tx_resource(tx_ring, tx_buffer_info); - if (tx_buffer_info->skb) - dev_kfree_skb_any(tx_buffer_info->skb); - tx_buffer_info->skb = NULL; - /* tx_buffer_info must be completely set up in the transmit path */ + tx_buffer->next_to_watch = NULL; + tx_buffer->skb = NULL; + dma_unmap_len_set(tx_buffer, len, 0); + /* tx_buffer must be completely set up in the transmit path */ } static void ixgbe_update_xoff_received(struct ixgbe_adapter *adapter) @@ -741,12 +736,16 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, union ixgbe_adv_tx_desc *tx_desc; unsigned int total_bytes = 0, total_packets = 0; unsigned int budget = q_vector->tx.work_limit; - u16 i = tx_ring->next_to_clean; + unsigned int i = tx_ring->next_to_clean; + + if (test_bit(__IXGBE_DOWN, &adapter->state)) + return true; tx_buffer = &tx_ring->tx_buffer_info[i]; tx_desc = IXGBE_TX_DESC(tx_ring, i); + i -= tx_ring->count; - for (; budget; budget--) { + do { union ixgbe_adv_tx_desc *eop_desc = tx_buffer->next_to_watch; /* if next_to_watch is not set then there is no work pending */ @@ -770,27 +769,55 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, /* free the skb */ dev_kfree_skb_any(tx_buffer->skb); + /* unmap skb header data */ + dma_unmap_single(tx_ring->dev, + dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + DMA_TO_DEVICE); + /* clear tx_buffer data */ tx_buffer->skb = NULL; + dma_unmap_len_set(tx_buffer, len, 0); - do { - ixgbe_unmap_tx_resource(tx_ring, tx_buffer); - if (likely(tx_desc == eop_desc)) - eop_desc = NULL; - + /* unmap remaining buffers */ + while (tx_desc != eop_desc) { tx_buffer++; tx_desc++; i++; - if (unlikely(i == tx_ring->count)) { - i = 0; - + if (unlikely(!i)) { + i -= tx_ring->count; tx_buffer = tx_ring->tx_buffer_info; tx_desc = IXGBE_TX_DESC(tx_ring, 0); } - } while (eop_desc); - } + /* unmap any remaining paged data */ + if (dma_unmap_len(tx_buffer, len)) { + dma_unmap_page(tx_ring->dev, + dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + DMA_TO_DEVICE); + dma_unmap_len_set(tx_buffer, len, 0); + } + } + + /* move us one more past the eop_desc for start of next pkt */ + tx_buffer++; + tx_desc++; + i++; + if (unlikely(!i)) { + i -= tx_ring->count; + tx_buffer = tx_ring->tx_buffer_info; + tx_desc = IXGBE_TX_DESC(tx_ring, 0); + } + + /* issue prefetch for next Tx descriptor */ + prefetch(tx_desc); + /* update budget accounting */ + budget--; + } while (likely(budget)); + + i += tx_ring->count; tx_ring->next_to_clean = i; u64_stats_update_begin(&tx_ring->syncp); tx_ring->stats.bytes += total_bytes; @@ -802,7 +829,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, if (check_for_tx_hang(tx_ring) && ixgbe_check_tx_hang(tx_ring)) { /* schedule immediate reset if we believe we hung */ struct ixgbe_hw *hw = &adapter->hw; - tx_desc = IXGBE_TX_DESC(tx_ring, i); e_err(drv, "Detected Tx Unit Hang\n" " Tx Queue <%d>\n" " TDH, TDT <%x>, <%x>\n" @@ -840,9 +866,11 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, * sees the new next_to_clean. */ smp_mb(); - if (__netif_subqueue_stopped(tx_ring->netdev, tx_ring->queue_index) && - !test_bit(__IXGBE_DOWN, &adapter->state)) { - netif_wake_subqueue(tx_ring->netdev, tx_ring->queue_index); + if (__netif_subqueue_stopped(tx_ring->netdev, + tx_ring->queue_index) + && !test_bit(__IXGBE_DOWN, &adapter->state)) { + netif_wake_subqueue(tx_ring->netdev, + tx_ring->queue_index); ++tx_ring->tx_stats.restart_queue; } } @@ -6707,7 +6735,8 @@ static __le32 ixgbe_tx_cmd_type(u32 tx_flags) return cmd_type; } -static __le32 ixgbe_tx_olinfo_status(u32 tx_flags, unsigned int paylen) +static void ixgbe_tx_olinfo_status(union ixgbe_adv_tx_desc *tx_desc, + u32 tx_flags, unsigned int paylen) { __le32 olinfo_status = cpu_to_le32(paylen << IXGBE_ADVTXD_PAYLEN_SHIFT); @@ -6738,7 +6767,7 @@ static __le32 ixgbe_tx_olinfo_status(u32 tx_flags, unsigned int paylen) #endif olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_CC); - return olinfo_status; + tx_desc->read.olinfo_status = olinfo_status; } #define IXGBE_TXD_CMD (IXGBE_TXD_CMD_EOP | \ @@ -6749,103 +6778,102 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, u32 tx_flags, const u8 hdr_len) { + dma_addr_t dma; struct sk_buff *skb = first->skb; - struct device *dev = tx_ring->dev; - struct ixgbe_tx_buffer *tx_buffer_info; + struct ixgbe_tx_buffer *tx_buffer; union ixgbe_adv_tx_desc *tx_desc; - dma_addr_t dma; - __le32 cmd_type, olinfo_status; - struct skb_frag_struct *frag; - unsigned int f = 0; + struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[0]; unsigned int data_len = skb->data_len; unsigned int size = skb_headlen(skb); - u32 offset = 0; - u32 paylen = skb->len - hdr_len; + unsigned int paylen = skb->len - hdr_len; + __le32 cmd_type; u16 i = tx_ring->next_to_use; + tx_desc = IXGBE_TX_DESC(tx_ring, i); + + ixgbe_tx_olinfo_status(tx_desc, tx_flags, paylen); + cmd_type = ixgbe_tx_cmd_type(tx_flags); + #ifdef IXGBE_FCOE if (tx_flags & IXGBE_TX_FLAGS_FCOE) { - if (data_len >= sizeof(struct fcoe_crc_eof)) { - data_len -= sizeof(struct fcoe_crc_eof); - } else { + if (data_len < sizeof(struct fcoe_crc_eof)) { size -= sizeof(struct fcoe_crc_eof) - data_len; data_len = 0; + } else { + data_len -= sizeof(struct fcoe_crc_eof); } } #endif - dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE); - if (dma_mapping_error(dev, dma)) + dma = dma_map_single(tx_ring->dev, skb->data, size, DMA_TO_DEVICE); + if (dma_mapping_error(tx_ring->dev, dma)) goto dma_error; - cmd_type = ixgbe_tx_cmd_type(tx_flags); - olinfo_status = ixgbe_tx_olinfo_status(tx_flags, paylen); + /* record length, and DMA address */ + dma_unmap_len_set(first, len, size); + dma_unmap_addr_set(first, dma, dma); + first->tx_flags = tx_flags; - tx_desc = IXGBE_TX_DESC(tx_ring, i); + tx_desc->read.buffer_addr = cpu_to_le64(dma); for (;;) { - while (size > IXGBE_MAX_DATA_PER_TXD) { - tx_desc->read.buffer_addr = cpu_to_le64(dma + offset); + while (unlikely(size > IXGBE_MAX_DATA_PER_TXD)) { tx_desc->read.cmd_type_len = cmd_type | cpu_to_le32(IXGBE_MAX_DATA_PER_TXD); - tx_desc->read.olinfo_status = olinfo_status; - - offset += IXGBE_MAX_DATA_PER_TXD; - size -= IXGBE_MAX_DATA_PER_TXD; - tx_desc++; i++; + tx_desc++; if (i == tx_ring->count) { tx_desc = IXGBE_TX_DESC(tx_ring, 0); i = 0; } + + dma += IXGBE_MAX_DATA_PER_TXD; + size -= IXGBE_MAX_DATA_PER_TXD; + + tx_desc->read.buffer_addr = cpu_to_le64(dma); + tx_desc->read.olinfo_status = 0; } - tx_buffer_info = &tx_ring->tx_buffer_info[i]; - tx_buffer_info->length = offset + size; - tx_buffer_info->tx_flags = tx_flags; - tx_buffer_info->dma = dma; + if (likely(!data_len)) + break; - tx_desc->read.buffer_addr = cpu_to_le64(dma + offset); if (unlikely(skb->no_fcs)) cmd_type &= ~(cpu_to_le32(IXGBE_ADVTXD_DCMD_IFCS)); tx_desc->read.cmd_type_len = cmd_type | cpu_to_le32(size); - tx_desc->read.olinfo_status = olinfo_status; - if (!data_len) - break; + i++; + tx_desc++; + if (i == tx_ring->count) { + tx_desc = IXGBE_TX_DESC(tx_ring, 0); + i = 0; + } - frag = &skb_shinfo(skb)->frags[f]; #ifdef IXGBE_FCOE size = min_t(unsigned int, data_len, skb_frag_size(frag)); #else size = skb_frag_size(frag); #endif data_len -= size; - f++; - offset = 0; - tx_flags |= IXGBE_TX_FLAGS_MAPPED_AS_PAGE; - - dma = skb_frag_dma_map(dev, frag, 0, size, DMA_TO_DEVICE); - if (dma_mapping_error(dev, dma)) + dma = skb_frag_dma_map(tx_ring->dev, frag, 0, size, + DMA_TO_DEVICE); + if (dma_mapping_error(tx_ring->dev, dma)) goto dma_error; - tx_desc++; - i++; - if (i == tx_ring->count) { - tx_desc = IXGBE_TX_DESC(tx_ring, 0); - i = 0; - } - } + tx_buffer = &tx_ring->tx_buffer_info[i]; + dma_unmap_len_set(tx_buffer, len, size); + dma_unmap_addr_set(tx_buffer, dma, dma); - tx_desc->read.cmd_type_len |= cpu_to_le32(IXGBE_TXD_CMD); + tx_desc->read.buffer_addr = cpu_to_le64(dma); + tx_desc->read.olinfo_status = 0; - i++; - if (i == tx_ring->count) - i = 0; + frag++; + } - tx_ring->next_to_use = i; + /* write last descriptor with RS and EOP bits */ + cmd_type |= cpu_to_le32(size) | cpu_to_le32(IXGBE_TXD_CMD); + tx_desc->read.cmd_type_len = cmd_type; netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); @@ -6853,28 +6881,36 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, first->time_stamp = jiffies; /* - * Force memory writes to complete before letting h/w - * know there are new descriptors to fetch. (Only - * applicable for weak-ordered memory model archs, - * such as IA-64). + * Force memory writes to complete before letting h/w know there + * are new descriptors to fetch. (Only applicable for weak-ordered + * memory model archs, such as IA-64). + * + * We also need this memory barrier to make certain all of the + * status bits have been updated before next_to_watch is written. */ wmb(); /* set next_to_watch value indicating a packet is present */ first->next_to_watch = tx_desc; + i++; + if (i == tx_ring->count) + i = 0; + + tx_ring->next_to_use = i; + /* notify HW of packet */ writel(i, tx_ring->tail); return; dma_error: - dev_err(dev, "TX DMA map failed\n"); + dev_err(tx_ring->dev, "TX DMA map failed\n"); /* clear dma mappings for failed tx_buffer_info map */ for (;;) { - tx_buffer_info = &tx_ring->tx_buffer_info[i]; - ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer_info); - if (tx_buffer_info == first) + tx_buffer = &tx_ring->tx_buffer_info[i]; + ixgbe_unmap_and_free_tx_resource(tx_ring, tx_buffer); + if (tx_buffer == first) break; if (i == 0) i = tx_ring->count; -- GitLab From 5407b14c6792d6ff122ecb1a2a6acffad60ef389 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 18 Mar 2012 17:11:22 -0400 Subject: [PATCH 1800/1846] gianfar: use netif_tx_queue_stopped instead of __netif_subqueue_stopped The __netif_subqueue_stopped() just does the following: struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index); return netif_tx_queue_stopped(txq); and since we already have the txq in scope, we can just call that directly in this case. Suggested-by: Eric Dumazet Signed-off-by: Paul Gortmaker --- drivers/net/ethernet/freescale/gianfar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 6e66cc35c970..d9428f0e738a 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -2565,7 +2565,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) } /* If we freed a buffer, we can restart transmission, if necessary */ - if (__netif_subqueue_stopped(dev, tqi) && tx_queue->num_txbdfree) + if (netif_tx_queue_stopped(txq) && tx_queue->num_txbdfree) netif_wake_subqueue(dev, tqi); /* Update dirty indicators */ -- GitLab From 244e27ad4d9e561c688c4da3383fec890be832d0 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:11 +0000 Subject: [PATCH 1801/1846] ixgbe: Store Tx flags and protocol information to tx_buffer sooner This change makes it so that we store the tx_flags and protocol information to the tx_buffer_info structure sooner. This allows us to avoid unnecessary read/write transactions since we are placing the data in the final location earlier. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 +- drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 13 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 86 +++++++++---------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index e0d809d0ed75..468cb9048dc8 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -152,6 +152,7 @@ struct ixgbe_tx_buffer { struct sk_buff *skb; unsigned int bytecount; unsigned short gso_segs; + __be16 protocol; DEFINE_DMA_UNMAP_ADDR(dma); DEFINE_DMA_UNMAP_LEN(len); u32 tx_flags; @@ -632,7 +633,7 @@ extern void ixgbe_do_reset(struct net_device *netdev); extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); extern int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, - u32 tx_flags, u8 *hdr_len); + u8 *hdr_len); extern void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter); extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, union ixgbe_adv_rx_desc *rx_desc, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 5f943d3f85c4..77ea4b716535 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -448,16 +448,15 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, * ixgbe_fso - ixgbe FCoE Sequence Offload (FSO) * @tx_ring: tx desc ring * @first: first tx_buffer structure containing skb, tx_flags, and protocol - * @tx_flags: tx flags * @hdr_len: hdr_len to be returned * * This sets up large send offload for FCoE * - * Returns : 0 indicates no FSO, > 0 for FSO, < 0 for error + * Returns : 0 indicates success, < 0 for error */ int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, - u32 tx_flags, u8 *hdr_len) + u8 *hdr_len) { struct sk_buff *skb = first->skb; struct fc_frame_header *fh; @@ -539,8 +538,12 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, first->gso_segs = DIV_ROUND_UP(skb->len - *hdr_len, skb_shinfo(skb)->gso_size); first->bytecount += (first->gso_segs - 1) * *hdr_len; + first->tx_flags |= IXGBE_TX_FLAGS_FSO; } + /* set flag indicating FCOE to ixgbe_tx_map call */ + first->tx_flags |= IXGBE_TX_FLAGS_FCOE; + /* mss_l4len_id: use 1 for FSO as TSO, no need for L4LEN */ mss_l4len_idx = skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; mss_l4len_idx |= 1 << IXGBE_ADVTXD_IDX_SHIFT; @@ -550,13 +553,13 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, sizeof(struct fc_frame_header); vlan_macip_lens |= (skb_transport_offset(skb) - 4) << IXGBE_ADVTXD_MACLEN_SHIFT; - vlan_macip_lens |= tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; + vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; /* write context desc */ ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, fcoe_sof_eof, IXGBE_ADVTXT_TUCMD_FCOE, mss_l4len_idx); - return skb_is_gso(skb); + return 0; } static void ixgbe_fcoe_ddp_pools_free(struct ixgbe_fcoe *fcoe) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 1d8f9f83f8ed..7817f0473032 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6585,10 +6585,9 @@ void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens, static int ixgbe_tso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, - u32 tx_flags, __be16 protocol, u8 *hdr_len) + u8 *hdr_len) { struct sk_buff *skb = first->skb; - int err; u32 vlan_macip_lens, type_tucmd; u32 mss_l4len_idx, l4len; @@ -6596,7 +6595,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, return 0; if (skb_header_cloned(skb)) { - err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); + int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); if (err) return err; } @@ -6604,7 +6603,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP; - if (protocol == __constant_htons(ETH_P_IP)) { + if (first->protocol == __constant_htons(ETH_P_IP)) { struct iphdr *iph = ip_hdr(skb); iph->tot_len = 0; iph->check = 0; @@ -6613,12 +6612,17 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, IPPROTO_TCP, 0); type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; + first->tx_flags |= IXGBE_TX_FLAGS_TSO | + IXGBE_TX_FLAGS_CSUM | + IXGBE_TX_FLAGS_IPV4; } else if (skb_is_gso_v6(skb)) { ipv6_hdr(skb)->payload_len = 0; tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0); + first->tx_flags |= IXGBE_TX_FLAGS_TSO | + IXGBE_TX_FLAGS_CSUM; } /* compute header lengths */ @@ -6637,17 +6641,16 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring, /* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */ vlan_macip_lens = skb_network_header_len(skb); vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT; - vlan_macip_lens |= tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; + vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, type_tucmd, - mss_l4len_idx); + mss_l4len_idx); return 1; } -static bool ixgbe_tx_csum(struct ixgbe_ring *tx_ring, - struct ixgbe_tx_buffer *first, - u32 tx_flags, __be16 protocol) +static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring, + struct ixgbe_tx_buffer *first) { struct sk_buff *skb = first->skb; u32 vlan_macip_lens = 0; @@ -6655,12 +6658,12 @@ static bool ixgbe_tx_csum(struct ixgbe_ring *tx_ring, u32 type_tucmd = 0; if (skb->ip_summed != CHECKSUM_PARTIAL) { - if (!(tx_flags & IXGBE_TX_FLAGS_HW_VLAN) && - !(tx_flags & IXGBE_TX_FLAGS_TXSW)) - return false; + if (!(first->tx_flags & IXGBE_TX_FLAGS_HW_VLAN) && + !(first->tx_flags & IXGBE_TX_FLAGS_TXSW)) + return; } else { u8 l4_hdr = 0; - switch (protocol) { + switch (first->protocol) { case __constant_htons(ETH_P_IP): vlan_macip_lens |= skb_network_header_len(skb); type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; @@ -6674,7 +6677,7 @@ static bool ixgbe_tx_csum(struct ixgbe_ring *tx_ring, if (unlikely(net_ratelimit())) { dev_warn(tx_ring->dev, "partial checksum but proto=%x!\n", - skb->protocol); + first->protocol); } break; } @@ -6698,19 +6701,21 @@ static bool ixgbe_tx_csum(struct ixgbe_ring *tx_ring, if (unlikely(net_ratelimit())) { dev_warn(tx_ring->dev, "partial checksum but l4 proto=%x!\n", - skb->protocol); + l4_hdr); } break; } + + /* update TX checksum flag */ + first->tx_flags |= IXGBE_TX_FLAGS_CSUM; } + /* vlan_macip_lens: MACLEN, VLAN tag */ vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT; - vlan_macip_lens |= tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; + vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, type_tucmd, mss_l4len_idx); - - return (skb->ip_summed == CHECKSUM_PARTIAL); } static __le32 ixgbe_tx_cmd_type(u32 tx_flags) @@ -6775,7 +6780,6 @@ static void ixgbe_tx_olinfo_status(union ixgbe_adv_tx_desc *tx_desc, static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, - u32 tx_flags, const u8 hdr_len) { dma_addr_t dma; @@ -6786,6 +6790,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, unsigned int data_len = skb->data_len; unsigned int size = skb_headlen(skb); unsigned int paylen = skb->len - hdr_len; + u32 tx_flags = first->tx_flags; __le32 cmd_type; u16 i = tx_ring->next_to_use; @@ -6812,7 +6817,6 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, /* record length, and DMA address */ dma_unmap_len_set(first, len, size); dma_unmap_addr_set(first, dma, dma); - first->tx_flags = tx_flags; tx_desc->read.buffer_addr = cpu_to_le64(dma); @@ -6921,8 +6925,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring, } static void ixgbe_atr(struct ixgbe_ring *ring, - struct ixgbe_tx_buffer *first, - u32 tx_flags, __be16 protocol) + struct ixgbe_tx_buffer *first) { struct ixgbe_q_vector *q_vector = ring->q_vector; union ixgbe_atr_hash_dword input = { .dword = 0 }; @@ -6949,9 +6952,9 @@ static void ixgbe_atr(struct ixgbe_ring *ring, hdr.network = skb_network_header(first->skb); /* Currently only IPv4/IPv6 with TCP is supported */ - if ((protocol != __constant_htons(ETH_P_IPV6) || + if ((first->protocol != __constant_htons(ETH_P_IPV6) || hdr.ipv6->nexthdr != IPPROTO_TCP) && - (protocol != __constant_htons(ETH_P_IP) || + (first->protocol != __constant_htons(ETH_P_IP) || hdr.ipv4->protocol != IPPROTO_TCP)) return; @@ -6968,7 +6971,7 @@ static void ixgbe_atr(struct ixgbe_ring *ring, /* reset sample count */ ring->atr_count = 0; - vlan_id = htons(tx_flags >> IXGBE_TX_FLAGS_VLAN_SHIFT); + vlan_id = htons(first->tx_flags >> IXGBE_TX_FLAGS_VLAN_SHIFT); /* * src and dst are inverted, think how the receiver sees them @@ -6983,13 +6986,13 @@ static void ixgbe_atr(struct ixgbe_ring *ring, * since src port and flex bytes occupy the same word XOR them together * and write the value to source port portion of compressed dword */ - if (tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN)) + if (first->tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN)) common.port.src ^= th->dest ^ __constant_htons(ETH_P_8021Q); else - common.port.src ^= th->dest ^ protocol; + common.port.src ^= th->dest ^ first->protocol; common.port.dst ^= th->source; - if (protocol == __constant_htons(ETH_P_IP)) { + if (first->protocol == __constant_htons(ETH_P_IP)) { input.formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV4; common.ip ^= hdr.ipv4->saddr ^ hdr.ipv4->daddr; } else { @@ -7145,43 +7148,36 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, } } + /* record initial flags and protocol */ + first->tx_flags = tx_flags; + first->protocol = protocol; + #ifdef IXGBE_FCOE /* setup tx offload for FCoE */ if ((protocol == __constant_htons(ETH_P_FCOE)) && (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) { - tso = ixgbe_fso(tx_ring, first, tx_flags, &hdr_len); + tso = ixgbe_fso(tx_ring, first, &hdr_len); if (tso < 0) goto out_drop; - else if (tso) - tx_flags |= IXGBE_TX_FLAGS_FSO | - IXGBE_TX_FLAGS_FCOE; - else - tx_flags |= IXGBE_TX_FLAGS_FCOE; goto xmit_fcoe; } #endif /* IXGBE_FCOE */ - /* setup IPv4/IPv6 offloads */ - if (protocol == __constant_htons(ETH_P_IP)) - tx_flags |= IXGBE_TX_FLAGS_IPV4; - - tso = ixgbe_tso(tx_ring, first, tx_flags, protocol, &hdr_len); + tso = ixgbe_tso(tx_ring, first, &hdr_len); if (tso < 0) goto out_drop; - else if (tso) - tx_flags |= IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_CSUM; - else if (ixgbe_tx_csum(tx_ring, first, tx_flags, protocol)) - tx_flags |= IXGBE_TX_FLAGS_CSUM; + else if (!tso) + ixgbe_tx_csum(tx_ring, first); /* add the ATR filter if ATR is on */ if (test_bit(__IXGBE_TX_FDIR_INIT_DONE, &tx_ring->state)) - ixgbe_atr(tx_ring, first, tx_flags, protocol); + ixgbe_atr(tx_ring, first); #ifdef IXGBE_FCOE xmit_fcoe: #endif /* IXGBE_FCOE */ - ixgbe_tx_map(tx_ring, first, tx_flags, hdr_len); + ixgbe_tx_map(tx_ring, first, hdr_len); ixgbe_maybe_stop_tx(tx_ring, DESC_NEEDED); -- GitLab From d3ee42944393895374e2f321f54e9a701e9f965c Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:16 +0000 Subject: [PATCH 1802/1846] ixgbe: Update layout of ixgbe_ring structure to improve cache performance This change makes it so that only the 2nd cache line in the ring structure should see frequent updates. The advantage to this is that it should reduce the amount of cross CPU cache bouncing since only the 2nd cache line will be changing between most network transactions. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 468cb9048dc8..862041419635 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -208,15 +208,18 @@ enum ixgbe_ring_state_t { clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state) struct ixgbe_ring { struct ixgbe_ring *next; /* pointer to next ring in q_vector */ + struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */ + struct net_device *netdev; /* netdev ring belongs to */ + struct device *dev; /* device for DMA mapping */ void *desc; /* descriptor ring memory */ - struct device *dev; /* device for DMA mapping */ - struct net_device *netdev; /* netdev ring belongs to */ union { struct ixgbe_tx_buffer *tx_buffer_info; struct ixgbe_rx_buffer *rx_buffer_info; }; unsigned long state; u8 __iomem *tail; + dma_addr_t dma; /* phys. address of descriptor ring */ + unsigned int size; /* length in bytes */ u16 count; /* amount of descriptors */ @@ -226,17 +229,17 @@ struct ixgbe_ring { * associated with this ring, which is * different for DCB and RSS modes */ + u16 next_to_use; + u16 next_to_clean; + union { + u16 next_to_alloc; struct { u8 atr_sample_rate; u8 atr_count; }; - u16 next_to_alloc; }; - u16 next_to_use; - u16 next_to_clean; - u8 dcb_tc; struct ixgbe_queue_stats stats; struct u64_stats_sync syncp; @@ -244,9 +247,6 @@ struct ixgbe_ring { struct ixgbe_tx_queue_stats tx_stats; struct ixgbe_rx_queue_stats rx_stats; }; - unsigned int size; /* length in bytes */ - dma_addr_t dma; /* phys. address of descriptor ring */ - struct ixgbe_q_vector *q_vector; /* back-pointer to host q_vector */ } ____cacheline_internodealigned_in_smp; enum ixgbe_ring_f_enum { -- GitLab From 6bb78cfb50bfbaf90646a80448ee8de2372e292a Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:22 +0000 Subject: [PATCH 1803/1846] ixgbe: cleanup logic for the service timer and VF hang detection This change just cleans up some of the logic in the service_timer function so that we can avoid unnecessary swapping of the ready value between true to false and back to true. Signed-off-by: Alexander Duyck Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 7817f0473032..6453e3a589ec 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6480,41 +6480,32 @@ static void ixgbe_service_timer(unsigned long data) unsigned long next_event_offset; bool ready = true; -#ifdef CONFIG_PCI_IOV - ready = false; + /* poll faster when waiting for link */ + if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) + next_event_offset = HZ / 10; + else + next_event_offset = HZ * 2; +#ifdef CONFIG_PCI_IOV /* * don't bother with SR-IOV VF DMA hang check if there are * no VFs or the link is down */ if (!adapter->num_vfs || - (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE)) { - ready = true; + (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE)) goto normal_timer_service; - } /* If we have VFs allocated then we must check for DMA hangs */ ixgbe_check_for_bad_vf(adapter); next_event_offset = HZ / 50; adapter->timer_event_accumulator++; - if (adapter->timer_event_accumulator >= 100) { - ready = true; + if (adapter->timer_event_accumulator >= 100) adapter->timer_event_accumulator = 0; - } - - goto schedule_event; - -normal_timer_service: -#endif - /* poll faster when waiting for link */ - if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) - next_event_offset = HZ / 10; else - next_event_offset = HZ * 2; + ready = false; -#ifdef CONFIG_PCI_IOV -schedule_event: +normal_timer_service: #endif /* Reset the timer */ mod_timer(&adapter->service_timer, next_event_offset + jiffies); -- GitLab From eb01b9759e733c0ede11d35e3cde5b3c24ab32c9 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:27 +0000 Subject: [PATCH 1804/1846] ixgbe: Move poll routine in order to improve readability This change relocates the ixgbe_poll routine so it is right next to the interrupt routine that schedules and calls it. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 6453e3a589ec..73bba8b41831 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2307,6 +2307,55 @@ static irqreturn_t ixgbe_msix_clean_rings(int irq, void *data) return IRQ_HANDLED; } +/** + * ixgbe_poll - NAPI Rx polling callback + * @napi: structure for representing this polling device + * @budget: how many packets driver is allowed to clean + * + * This function is used for legacy and MSI, NAPI mode + **/ +static int ixgbe_poll(struct napi_struct *napi, int budget) +{ + struct ixgbe_q_vector *q_vector = + container_of(napi, struct ixgbe_q_vector, napi); + struct ixgbe_adapter *adapter = q_vector->adapter; + struct ixgbe_ring *ring; + int per_ring_budget; + bool clean_complete = true; + +#ifdef CONFIG_IXGBE_DCA + if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) + ixgbe_update_dca(q_vector); +#endif + + ixgbe_for_each_ring(ring, q_vector->tx) + clean_complete &= !!ixgbe_clean_tx_irq(q_vector, ring); + + /* attempt to distribute budget to each queue fairly, but don't allow + * the budget to go below 1 because we'll exit polling */ + if (q_vector->rx.count > 1) + per_ring_budget = max(budget/q_vector->rx.count, 1); + else + per_ring_budget = budget; + + ixgbe_for_each_ring(ring, q_vector->rx) + clean_complete &= ixgbe_clean_rx_irq(q_vector, ring, + per_ring_budget); + + /* If all work not completed, return budget and keep polling */ + if (!clean_complete) + return budget; + + /* all work done, exit the polling mode */ + napi_complete(napi); + if (adapter->rx_itr_setting & 1) + ixgbe_set_itr(q_vector); + if (!test_bit(__IXGBE_DOWN, &adapter->state)) + ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); + + return 0; +} + /** * ixgbe_request_msix_irqs - Initialize MSI-X interrupts * @adapter: board private structure @@ -4253,55 +4302,6 @@ void ixgbe_down(struct ixgbe_adapter *adapter) #endif } -/** - * ixgbe_poll - NAPI Rx polling callback - * @napi: structure for representing this polling device - * @budget: how many packets driver is allowed to clean - * - * This function is used for legacy and MSI, NAPI mode - **/ -static int ixgbe_poll(struct napi_struct *napi, int budget) -{ - struct ixgbe_q_vector *q_vector = - container_of(napi, struct ixgbe_q_vector, napi); - struct ixgbe_adapter *adapter = q_vector->adapter; - struct ixgbe_ring *ring; - int per_ring_budget; - bool clean_complete = true; - -#ifdef CONFIG_IXGBE_DCA - if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) - ixgbe_update_dca(q_vector); -#endif - - ixgbe_for_each_ring(ring, q_vector->tx) - clean_complete &= !!ixgbe_clean_tx_irq(q_vector, ring); - - /* attempt to distribute budget to each queue fairly, but don't allow - * the budget to go below 1 because we'll exit polling */ - if (q_vector->rx.count > 1) - per_ring_budget = max(budget/q_vector->rx.count, 1); - else - per_ring_budget = budget; - - ixgbe_for_each_ring(ring, q_vector->rx) - clean_complete &= ixgbe_clean_rx_irq(q_vector, ring, - per_ring_budget); - - /* If all work not completed, return budget and keep polling */ - if (!clean_complete) - return budget; - - /* all work done, exit the polling mode */ - napi_complete(napi); - if (adapter->rx_itr_setting & 1) - ixgbe_set_itr(q_vector); - if (!test_bit(__IXGBE_DOWN, &adapter->state)) - ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); - - return 0; -} - /** * ixgbe_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure -- GitLab From 35937c055a691a125cf52343cd671f6190ae5b3b Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:37 +0000 Subject: [PATCH 1805/1846] ixgbe: drop err_eeprom tag which is at same location as err_sw_init The err_eeprom and err_sw_init tags both go to the same location. So instead of maintaining two tags this patch combines them so we only use err_sw_init. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 73bba8b41831..6259619ec7e7 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -7891,7 +7891,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, if (hw->eeprom.ops.validate_checksum(hw, NULL) < 0) { e_dev_err("The EEPROM Checksum Is Not Valid\n"); err = -EIO; - goto err_eeprom; + goto err_sw_init; } memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len); @@ -7900,7 +7900,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, if (ixgbe_validate_mac_addr(netdev->perm_addr)) { e_dev_err("invalid MAC address\n"); err = -EIO; - goto err_eeprom; + goto err_sw_init; } setup_timer(&adapter->service_timer, &ixgbe_service_timer, @@ -8047,7 +8047,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, ixgbe_release_hw_control(adapter); ixgbe_clear_interrupt_scheme(adapter); err_sw_init: -err_eeprom: if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) ixgbe_disable_sriov(adapter); adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; -- GitLab From 6ca435078822d9728318dee49ba4f2ff8a2ead24 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:42 +0000 Subject: [PATCH 1806/1846] ixgbe: Two minor fixes for RSS and FDIR set queues functions This change fixes two minor issues. The first was the fact that we were setting the return value to false twice in the set_rss_queues function. The second is the fact that we should have been using "min_t(int," instead of "min((int)" in set_fdir_queues. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 6259619ec7e7..eb58f13773ad 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -4332,8 +4332,6 @@ static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter) adapter->num_rx_queues = f->indices; adapter->num_tx_queues = f->indices; ret = true; - } else { - ret = false; } return ret; @@ -4354,7 +4352,7 @@ static inline bool ixgbe_set_fdir_queues(struct ixgbe_adapter *adapter) bool ret = false; struct ixgbe_ring_feature *f_fdir = &adapter->ring_feature[RING_F_FDIR]; - f_fdir->indices = min((int)num_online_cpus(), f_fdir->indices); + f_fdir->indices = min_t(int, num_online_cpus(), f_fdir->indices); f_fdir->mask = 0; /* -- GitLab From 581330ba7b219fec0587452bd72fe5635c30c4ae Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:47 +0000 Subject: [PATCH 1807/1846] ixgbe: Whitespace cleanups This patch contains several fixes for formatting in regards to whitespace. Signed-off-by: Alexander Duyck Tested-by: Phil Schmitt Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index eb58f13773ad..1d22c9f0e9fe 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -6233,7 +6233,7 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter) * print link down message * @adapter - pointer to the adapter structure **/ -static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter* adapter) +static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter *adapter) { struct net_device *netdev = adapter->netdev; struct ixgbe_hw *hw = &adapter->hw; @@ -7332,8 +7332,8 @@ static void ixgbe_netpoll(struct net_device *netdev) } adapter->flags &= ~IXGBE_FLAG_IN_NETPOLL; } -#endif +#endif static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { @@ -7418,7 +7418,6 @@ static void ixgbe_validate_rtr(struct ixgbe_adapter *adapter, u8 tc) return; } - /* ixgbe_setup_tc - routine to configure net_device for multiple traffic * classes. * @@ -7438,7 +7437,8 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) /* Hardware supports up to 8 traffic classes */ if (tc > adapter->dcb_cfg.num_tcs.pg_tcs || - (hw->mac.type == ixgbe_mac_82598EB && tc < MAX_TRAFFIC_CLASS)) + (hw->mac.type == ixgbe_mac_82598EB && + tc < MAX_TRAFFIC_CLASS)) return -EINVAL; /* Hardware has to reinitialize queues and interrupts to @@ -7452,7 +7452,6 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) if (tc) { netdev_set_num_tc(dev, tc); adapter->last_lfc_mode = adapter->hw.fc.current_mode; - adapter->flags |= IXGBE_FLAG_DCB_ENABLED; adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; @@ -7460,7 +7459,6 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) adapter->hw.fc.requested_mode = ixgbe_fc_none; } else { netdev_reset_tc(dev); - adapter->hw.fc.requested_mode = adapter->last_lfc_mode; adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; @@ -7576,7 +7574,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_stop = ixgbe_close, .ndo_start_xmit = ixgbe_xmit_frame, .ndo_select_queue = ixgbe_select_queue, - .ndo_set_rx_mode = ixgbe_set_rx_mode, + .ndo_set_rx_mode = ixgbe_set_rx_mode, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = ixgbe_set_mac, .ndo_change_mtu = ixgbe_change_mtu, @@ -7587,7 +7585,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_set_vf_mac = ixgbe_ndo_set_vf_mac, .ndo_set_vf_vlan = ixgbe_ndo_set_vf_vlan, .ndo_set_vf_tx_rate = ixgbe_ndo_set_vf_bw, - .ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk, + .ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk, .ndo_get_vf_config = ixgbe_ndo_get_vf_config, .ndo_get_stats64 = ixgbe_get_stats64, .ndo_setup_tc = ixgbe_setup_tc, @@ -7902,7 +7900,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, } setup_timer(&adapter->service_timer, &ixgbe_service_timer, - (unsigned long) adapter); + (unsigned long) adapter); INIT_WORK(&adapter->service_task, ixgbe_service_task); clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); @@ -7990,7 +7988,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, /* reset the hardware with the new settings */ err = hw->mac.ops.start_hw(hw); - if (err == IXGBE_ERR_EEPROM_VERSION) { /* We are running on a pre-production device, log a warning */ e_dev_warn("This device is a pre-production adapter/LOM. " -- GitLab From ef6afc0caceebb3b49cd384f8c634f89f5089997 Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Wed, 8 Feb 2012 07:51:53 +0000 Subject: [PATCH 1808/1846] ixgbe: Add support for enabling UDP RSS via the ethtool rx-flow-hash command This patch adds support for enabling or disabling UDP RSS via the ethtool -N rx-flow-hash command. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 +- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 153 ++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 + 3 files changed, 160 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 862041419635..4ceac3a09d09 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -438,7 +438,8 @@ struct ixgbe_adapter { #define IXGBE_FLAG2_SFP_NEEDS_RESET (u32)(1 << 5) #define IXGBE_FLAG2_RESET_REQUESTED (u32)(1 << 6) #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT (u32)(1 << 7) - +#define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP (u32)(1 << 8) +#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9) /* Tx fast path data */ int num_tx_queues; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index b09e67cc9d6e..b64d8a2adb42 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -2328,6 +2328,48 @@ static int ixgbe_get_ethtool_fdir_all(struct ixgbe_adapter *adapter, return 0; } +static int ixgbe_get_rss_hash_opts(struct ixgbe_adapter *adapter, + struct ethtool_rxnfc *cmd) +{ + cmd->data = 0; + + /* if RSS is disabled then report no hashing */ + if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) + return 0; + + /* Report default options for RSS on ixgbe */ + switch (cmd->flow_type) { + case TCP_V4_FLOW: + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + case UDP_V4_FLOW: + if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV4_UDP) + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + case SCTP_V4_FLOW: + case AH_ESP_V4_FLOW: + case AH_V4_FLOW: + case ESP_V4_FLOW: + case IPV4_FLOW: + cmd->data |= RXH_IP_SRC | RXH_IP_DST; + break; + case TCP_V6_FLOW: + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + case UDP_V6_FLOW: + if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP) + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + case SCTP_V6_FLOW: + case AH_ESP_V6_FLOW: + case AH_V6_FLOW: + case ESP_V6_FLOW: + case IPV6_FLOW: + cmd->data |= RXH_IP_SRC | RXH_IP_DST; + break; + default: + return -EINVAL; + } + + return 0; +} + static int ixgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, u32 *rule_locs) { @@ -2349,6 +2391,9 @@ static int ixgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, case ETHTOOL_GRXCLSRLALL: ret = ixgbe_get_ethtool_fdir_all(adapter, cmd, rule_locs); break; + case ETHTOOL_GRXFH: + ret = ixgbe_get_rss_hash_opts(adapter, cmd); + break; default: break; } @@ -2583,6 +2628,111 @@ static int ixgbe_del_ethtool_fdir_entry(struct ixgbe_adapter *adapter, return err; } +#define UDP_RSS_FLAGS (IXGBE_FLAG2_RSS_FIELD_IPV4_UDP | \ + IXGBE_FLAG2_RSS_FIELD_IPV6_UDP) +static int ixgbe_set_rss_hash_opt(struct ixgbe_adapter *adapter, + struct ethtool_rxnfc *nfc) +{ + u32 flags2 = adapter->flags2; + + /* + * RSS does not support anything other than hashing + * to queues on src and dst IPs and ports + */ + if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | + RXH_L4_B_0_1 | RXH_L4_B_2_3)) + return -EINVAL; + + switch (nfc->flow_type) { + case TCP_V4_FLOW: + case TCP_V6_FLOW: + if (!(nfc->data & RXH_IP_SRC) || + !(nfc->data & RXH_IP_DST) || + !(nfc->data & RXH_L4_B_0_1) || + !(nfc->data & RXH_L4_B_2_3)) + return -EINVAL; + break; + case UDP_V4_FLOW: + if (!(nfc->data & RXH_IP_SRC) || + !(nfc->data & RXH_IP_DST)) + return -EINVAL; + switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { + case 0: + flags2 &= ~IXGBE_FLAG2_RSS_FIELD_IPV4_UDP; + break; + case (RXH_L4_B_0_1 | RXH_L4_B_2_3): + flags2 |= IXGBE_FLAG2_RSS_FIELD_IPV4_UDP; + break; + default: + return -EINVAL; + } + break; + case UDP_V6_FLOW: + if (!(nfc->data & RXH_IP_SRC) || + !(nfc->data & RXH_IP_DST)) + return -EINVAL; + switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { + case 0: + flags2 &= ~IXGBE_FLAG2_RSS_FIELD_IPV6_UDP; + break; + case (RXH_L4_B_0_1 | RXH_L4_B_2_3): + flags2 |= IXGBE_FLAG2_RSS_FIELD_IPV6_UDP; + break; + default: + return -EINVAL; + } + break; + case AH_ESP_V4_FLOW: + case AH_V4_FLOW: + case ESP_V4_FLOW: + case SCTP_V4_FLOW: + case AH_ESP_V6_FLOW: + case AH_V6_FLOW: + case ESP_V6_FLOW: + case SCTP_V6_FLOW: + if (!(nfc->data & RXH_IP_SRC) || + !(nfc->data & RXH_IP_DST) || + (nfc->data & RXH_L4_B_0_1) || + (nfc->data & RXH_L4_B_2_3)) + return -EINVAL; + break; + default: + return -EINVAL; + } + + /* if we changed something we need to update flags */ + if (flags2 != adapter->flags2) { + struct ixgbe_hw *hw = &adapter->hw; + u32 mrqc = IXGBE_READ_REG(hw, IXGBE_MRQC); + + if ((flags2 & UDP_RSS_FLAGS) && + !(adapter->flags2 & UDP_RSS_FLAGS)) + e_warn(drv, "enabling UDP RSS: fragmented packets" + " may arrive out of order to the stack above\n"); + + adapter->flags2 = flags2; + + /* Perform hash on these packet types */ + mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4 + | IXGBE_MRQC_RSS_FIELD_IPV4_TCP + | IXGBE_MRQC_RSS_FIELD_IPV6 + | IXGBE_MRQC_RSS_FIELD_IPV6_TCP; + + mrqc &= ~(IXGBE_MRQC_RSS_FIELD_IPV4_UDP | + IXGBE_MRQC_RSS_FIELD_IPV6_UDP); + + if (flags2 & IXGBE_FLAG2_RSS_FIELD_IPV4_UDP) + mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP; + + if (flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP) + mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP; + + IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc); + } + + return 0; +} + static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) { struct ixgbe_adapter *adapter = netdev_priv(dev); @@ -2595,6 +2745,9 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) case ETHTOOL_SRXCLSRLDEL: ret = ixgbe_del_ethtool_fdir_entry(adapter, cmd); break; + case ETHTOOL_SRXFH: + ret = ixgbe_set_rss_hash_opt(adapter, cmd); + break; default: break; } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 1d22c9f0e9fe..5c7e7d83d394 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2856,6 +2856,11 @@ static void ixgbe_setup_mrqc(struct ixgbe_adapter *adapter) | IXGBE_MRQC_RSS_FIELD_IPV6 | IXGBE_MRQC_RSS_FIELD_IPV6_TCP; + if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV4_UDP) + mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP; + if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP) + mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP; + IXGBE_WRITE_REG(hw, IXGBE_MRQC, mrqc); } -- GitLab From 567d2de291b5ddb83654c5e87c14b4c6fa7216ed Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Sat, 11 Feb 2012 07:18:57 +0000 Subject: [PATCH 1809/1846] ixgbe: Correct flag values set by ixgbe_fix_features This patch replaces the variable name data with the variable name features for ixgbe_fix_features and ixgbe_set_features. This helps to make some issues more obvious such as the fact that we were disabling Rx VLAN tag stripping when we should have been forcing it to be enabled when DCB is enabled. In addition there was deprecated code present that was disabling the LRO flag if we had the itr value set too low. I have updated this logic so that we will now allow the LRO flag to be set, but will not enable RSC until the rx-usecs value is high enough to allow enough time for Rx packet coalescing. Signed-off-by: Alexander Duyck Tested-by: Stephen Ko Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 - .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 38 +++++----- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 75 +++++++++---------- 3 files changed, 54 insertions(+), 61 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 4ceac3a09d09..e0cc3118234e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -101,8 +101,6 @@ #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT 29 #define IXGBE_TX_FLAGS_VLAN_SHIFT 16 -#define IXGBE_MAX_RSC_INT_RATE 162760 - #define IXGBE_MAX_VF_MC_ENTRIES 30 #define IXGBE_MAX_VF_FUNCTIONS 64 #define IXGBE_MAX_VFTA_ENTRIES 128 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index b64d8a2adb42..31a2bf76a346 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -2137,31 +2137,29 @@ static int ixgbe_get_coalesce(struct net_device *netdev, * this function must be called before setting the new value of * rx_itr_setting */ -static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter, - struct ethtool_coalesce *ec) +static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter) { struct net_device *netdev = adapter->netdev; - if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) + /* nothing to do if LRO or RSC are not enabled */ + if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) || + !(netdev->features & NETIF_F_LRO)) return false; - /* if interrupt rate is too high then disable RSC */ - if (ec->rx_coalesce_usecs != 1 && - ec->rx_coalesce_usecs <= (IXGBE_MIN_RSC_ITR >> 2)) { - if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { - e_info(probe, "rx-usecs set too low, disabling RSC\n"); - adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; - return true; - } - } else { - /* check the feature flag value and enable RSC if necessary */ - if ((netdev->features & NETIF_F_LRO) && - !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { - e_info(probe, "rx-usecs set to %d, re-enabling RSC\n", - ec->rx_coalesce_usecs); + /* check the feature flag value and enable RSC if necessary */ + if (adapter->rx_itr_setting == 1 || + adapter->rx_itr_setting > IXGBE_MIN_RSC_ITR) { + if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; + e_info(probe, "rx-usecs value high enough " + "to re-enable RSC\n"); return true; } + /* if interrupt rate is too high then disable RSC */ + } else if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { + adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; + e_info(probe, "rx-usecs set too low, disabling RSC\n"); + return true; } return false; } @@ -2185,9 +2183,6 @@ static int ixgbe_set_coalesce(struct net_device *netdev, (ec->tx_coalesce_usecs > (IXGBE_MAX_EITR >> 2))) return -EINVAL; - /* check the old value and enable RSC if necessary */ - need_reset = ixgbe_update_rsc(adapter, ec); - if (ec->rx_coalesce_usecs > 1) adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2; else @@ -2208,6 +2203,9 @@ static int ixgbe_set_coalesce(struct net_device *netdev, else tx_itr_param = adapter->tx_itr_setting; + /* check the old value and enable RSC if necessary */ + need_reset = ixgbe_update_rsc(adapter); + if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) num_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; else diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 5c7e7d83d394..e9d9fca084a9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -7492,54 +7492,52 @@ void ixgbe_do_reset(struct net_device *netdev) } static netdev_features_t ixgbe_fix_features(struct net_device *netdev, - netdev_features_t data) + netdev_features_t features) { struct ixgbe_adapter *adapter = netdev_priv(netdev); #ifdef CONFIG_DCB if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) - data &= ~NETIF_F_HW_VLAN_RX; + features &= ~NETIF_F_HW_VLAN_RX; #endif /* return error if RXHASH is being enabled when RSS is not supported */ if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) - data &= ~NETIF_F_RXHASH; + features &= ~NETIF_F_RXHASH; /* If Rx checksum is disabled, then RSC/LRO should also be disabled */ - if (!(data & NETIF_F_RXCSUM)) - data &= ~NETIF_F_LRO; + if (!(features & NETIF_F_RXCSUM)) + features &= ~NETIF_F_LRO; - /* Turn off LRO if not RSC capable or invalid ITR settings */ - if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) { - data &= ~NETIF_F_LRO; - } else if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) && - (adapter->rx_itr_setting != 1 && - adapter->rx_itr_setting > IXGBE_MAX_RSC_INT_RATE)) { - data &= ~NETIF_F_LRO; - e_info(probe, "rx-usecs set too low, not enabling RSC\n"); - } + /* Turn off LRO if not RSC capable */ + if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) + features &= ~NETIF_F_LRO; + - return data; + return features; } static int ixgbe_set_features(struct net_device *netdev, - netdev_features_t data) + netdev_features_t features) { struct ixgbe_adapter *adapter = netdev_priv(netdev); - netdev_features_t changed = netdev->features ^ data; + netdev_features_t changed = netdev->features ^ features; bool need_reset = false; /* Make sure RSC matches LRO, reset if change */ - if (!!(data & NETIF_F_LRO) != - !!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { - adapter->flags2 ^= IXGBE_FLAG2_RSC_ENABLED; - switch (adapter->hw.mac.type) { - case ixgbe_mac_X540: - case ixgbe_mac_82599EB: + if (!(features & NETIF_F_LRO)) { + if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) need_reset = true; - break; - default: - break; + adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; + } else if ((adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) && + !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { + if (adapter->rx_itr_setting == 1 || + adapter->rx_itr_setting > IXGBE_MIN_RSC_ITR) { + adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; + need_reset = true; + } else if ((changed ^ features) & NETIF_F_LRO) { + e_info(probe, "rx-usecs set too low, " + "disabling RSC\n"); } } @@ -7547,31 +7545,30 @@ static int ixgbe_set_features(struct net_device *netdev, * Check if Flow Director n-tuple support was enabled or disabled. If * the state changed, we need to reset. */ - if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) { - /* turn off ATR, enable perfect filters and reset */ - if (data & NETIF_F_NTUPLE) { - adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; - adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE; + if (!(features & NETIF_F_NTUPLE)) { + if (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) { + /* turn off Flow Director, set ATR and reset */ + if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && + !(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) + adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; need_reset = true; } - } else if (!(data & NETIF_F_NTUPLE)) { - /* turn off Flow Director, set ATR and reset */ adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE; - if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && - !(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) - adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; + } else if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) { + /* turn off ATR, enable perfect filters and reset */ + adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; + adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE; need_reset = true; } if (changed & NETIF_F_RXALL) need_reset = true; - netdev->features = data; + netdev->features = features; if (need_reset) ixgbe_do_reset(netdev); return 0; - } static const struct net_device_ops ixgbe_netdev_ops = { @@ -7611,7 +7608,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { }; static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter, - const struct ixgbe_info *ii) + const struct ixgbe_info *ii) { #ifdef CONFIG_PCI_IOV struct ixgbe_hw *hw = &adapter->hw; -- GitLab From 4762f6cec4455f3bbe4ca82c100fe5d85d3c02a2 Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Sun, 18 Mar 2012 06:23:11 +0000 Subject: [PATCH 1810/1846] be2net: enable WOL by default if h/w supports it Signed-off-by: Ajit Khaparde Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 26 ++++++++- drivers/net/ethernet/emulex/benet/be_cmds.c | 55 +++++++++++++++++++ drivers/net/ethernet/emulex/benet/be_cmds.h | 28 ++++++++++ .../net/ethernet/emulex/benet/be_ethtool.c | 27 ++++----- drivers/net/ethernet/emulex/benet/be_main.c | 17 ++++++ 5 files changed, 136 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index ab24e4600695..cabe1b892722 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -52,6 +52,10 @@ #define OC_DEVICE_ID3 0xe220 /* Device id for Lancer cards */ #define OC_DEVICE_ID4 0xe228 /* Device id for VF in Lancer */ #define OC_DEVICE_ID5 0x720 /* Device Id for Skyhawk cards */ +#define OC_SUBSYS_DEVICE_ID1 0xE602 +#define OC_SUBSYS_DEVICE_ID2 0xE642 +#define OC_SUBSYS_DEVICE_ID3 0xE612 +#define OC_SUBSYS_DEVICE_ID4 0xE652 static inline char *nic_name(struct pci_dev *pdev) { @@ -365,7 +369,6 @@ struct be_adapter { bool fw_timeout; u32 port_num; bool promiscuous; - bool wol; u32 function_mode; u32 function_caps; u32 rx_fc; /* Rx flow control */ @@ -386,6 +389,8 @@ struct be_adapter { u32 sli_family; u8 hba_port_num; u16 pvid; + u8 wol_cap; + bool wol; }; #define be_physfn(adapter) (!adapter->is_virtfn) @@ -549,9 +554,28 @@ static inline bool be_error(struct be_adapter *adapter) return adapter->eeh_err || adapter->ue_detected || adapter->fw_timeout; } +static inline bool be_is_wol_excluded(struct be_adapter *adapter) +{ + struct pci_dev *pdev = adapter->pdev; + + if (!be_physfn(adapter)) + return true; + + switch (pdev->subsystem_device) { + case OC_SUBSYS_DEVICE_ID1: + case OC_SUBSYS_DEVICE_ID2: + case OC_SUBSYS_DEVICE_ID3: + case OC_SUBSYS_DEVICE_ID4: + return true; + default: + return false; + } +} + extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped); extern void be_link_status_update(struct be_adapter *adapter, u8 link_status); extern void be_parse_stats(struct be_adapter *adapter); extern int be_load_fw(struct be_adapter *adapter, u8 *func); +extern bool be_is_wol_supported(struct be_adapter *adapter); #endif /* BE_H */ diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 398fb5ca0fe2..d72c2b46963c 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -2418,3 +2418,58 @@ int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, spin_unlock_bh(&adapter->mcc_lock); return status; } + +int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) +{ + struct be_mcc_wrb *wrb; + struct be_cmd_req_acpi_wol_magic_config_v1 *req; + int status; + int payload_len = sizeof(*req); + struct be_dma_mem cmd; + + memset(&cmd, 0, sizeof(struct be_dma_mem)); + cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1); + cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, + &cmd.dma); + if (!cmd.va) { + dev_err(&adapter->pdev->dev, + "Memory allocation failure\n"); + return -ENOMEM; + } + + if (mutex_lock_interruptible(&adapter->mbox_lock)) + return -1; + + wrb = wrb_from_mbox(adapter); + if (!wrb) { + status = -EBUSY; + goto err; + } + + req = cmd.va; + + be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, + OPCODE_ETH_ACPI_WOL_MAGIC_CONFIG, + payload_len, wrb, &cmd); + + req->hdr.version = 1; + req->query_options = BE_GET_WOL_CAP; + + status = be_mbox_notify_wait(adapter); + if (!status) { + struct be_cmd_resp_acpi_wol_magic_config_v1 *resp; + resp = (struct be_cmd_resp_acpi_wol_magic_config_v1 *) cmd.va; + + /* the command could succeed misleadingly on old f/w + * which is not aware of the V1 version. fake an error. */ + if (resp->hdr.response_length < payload_len) { + status = -1; + goto err; + } + adapter->wol_cap = resp->wol_settings; + } +err: + mutex_unlock(&adapter->mbox_lock); + pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); + return status; +} diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index 687c42071411..345d49eeadc8 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -1206,6 +1206,33 @@ struct be_cmd_req_acpi_wol_magic_config{ u8 rsvd2[2]; } __packed; +struct be_cmd_req_acpi_wol_magic_config_v1 { + struct be_cmd_req_hdr hdr; + u8 rsvd0[2]; + u8 query_options; + u8 rsvd1[5]; + u32 rsvd2[288]; + u8 magic_mac[6]; + u8 rsvd3[22]; +} __packed; + +struct be_cmd_resp_acpi_wol_magic_config_v1 { + struct be_cmd_resp_hdr hdr; + u8 rsvd0[2]; + u8 wol_settings; + u8 rsvd1[5]; + u32 rsvd2[295]; +} __packed; + +#define BE_GET_WOL_CAP 2 + +#define BE_WOL_CAP 0x1 +#define BE_PME_D0_CAP 0x8 +#define BE_PME_D1_CAP 0x10 +#define BE_PME_D2_CAP 0x20 +#define BE_PME_D3HOT_CAP 0x40 +#define BE_PME_D3COLD_CAP 0x80 + /********************** LoopBack test *********************/ struct be_cmd_req_loopback_test { struct be_cmd_req_hdr hdr; @@ -1590,4 +1617,5 @@ extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, bool *pmac_id_active, u32 *pmac_id, u8 *mac); extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, u8 mac_count, u32 domain); +extern int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter); diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index 30ce17806916..c1ff73cb0e62 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -600,26 +600,16 @@ be_set_phys_id(struct net_device *netdev, return 0; } -static bool -be_is_wol_supported(struct be_adapter *adapter) -{ - if (!be_physfn(adapter)) - return false; - else - return true; -} static void be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct be_adapter *adapter = netdev_priv(netdev); - if (be_is_wol_supported(adapter)) - wol->supported = WAKE_MAGIC; - - if (adapter->wol) - wol->wolopts = WAKE_MAGIC; - else + if (be_is_wol_supported(adapter)) { + wol->supported |= WAKE_MAGIC; + wol->wolopts |= WAKE_MAGIC; + } else wol->wolopts = 0; memset(&wol->sopass, 0, sizeof(wol->sopass)); } @@ -630,9 +620,14 @@ be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) struct be_adapter *adapter = netdev_priv(netdev); if (wol->wolopts & ~WAKE_MAGIC) - return -EINVAL; + return -EOPNOTSUPP; + + if (!be_is_wol_supported(adapter)) { + dev_warn(&adapter->pdev->dev, "WOL not supported\n"); + return -EOPNOTSUPP; + } - if ((wol->wolopts & WAKE_MAGIC) && be_is_wol_supported(adapter)) + if (wol->wolopts & WAKE_MAGIC) adapter->wol = true; else adapter->wol = false; diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index e3822788f532..050e3ebd4fb3 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -3244,6 +3244,12 @@ static void __devexit be_remove(struct pci_dev *pdev) free_netdev(adapter->netdev); } +bool be_is_wol_supported(struct be_adapter *adapter) +{ + return ((adapter->wol_cap & BE_WOL_CAP) && + !be_is_wol_excluded(adapter)) ? true : false; +} + static int be_get_config(struct be_adapter *adapter) { int status; @@ -3262,6 +3268,17 @@ static int be_get_config(struct be_adapter *adapter) if (status) return status; + status = be_cmd_get_acpi_wol_cap(adapter); + if (status) { + /* in case of a failure to get wol capabillities + * check the exclusion list to determine WOL capability */ + if (!be_is_wol_excluded(adapter)) + adapter->wol_cap |= BE_WOL_CAP; + } + + if (be_is_wol_supported(adapter)) + adapter->wol = true; + return 0; } -- GitLab From fbc13f018c0043146f8eccc7d6a6c0e66339e2d5 Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Sun, 18 Mar 2012 06:23:21 +0000 Subject: [PATCH 1811/1846] be2net: Program secondary UC MAC address into MAC filter Signed-off-by: Ajit Khaparde Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 6 ++- drivers/net/ethernet/emulex/benet/be_main.c | 53 +++++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index cabe1b892722..03fc3dbe3872 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -309,6 +309,8 @@ struct be_vf_cfg { #define BE_FLAGS_LINK_STATUS_INIT 1 #define BE_FLAGS_WORKER_SCHEDULED (1 << 3) +#define BE_UC_PMAC_COUNT 30 +#define BE_VF_UC_PMAC_COUNT 2 struct be_adapter { struct pci_dev *pdev; @@ -361,7 +363,7 @@ struct be_adapter { /* Ethtool knobs and info */ char fw_ver[FW_VER_LEN]; int if_handle; /* Used to configure filtering */ - u32 pmac_id; /* MAC addr handle used by BE card */ + u32 *pmac_id; /* MAC addr handle used by BE card */ u32 beacon_state; /* for set_phys_id */ bool eeh_err; @@ -391,6 +393,8 @@ struct be_adapter { u16 pvid; u8 wol_cap; bool wol; + u32 max_pmac_cnt; /* Max secondary UC MACs programmable */ + u32 uc_macs; /* Count of secondary UC MAC programmed */ }; #define be_physfn(adapter) (!adapter->is_virtfn) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 050e3ebd4fb3..b4348b8ee529 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -235,7 +235,7 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) struct sockaddr *addr = p; int status = 0; u8 current_mac[ETH_ALEN]; - u32 pmac_id = adapter->pmac_id; + u32 pmac_id = adapter->pmac_id[0]; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; @@ -248,7 +248,7 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) if (memcmp(addr->sa_data, current_mac, ETH_ALEN)) { status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data, - adapter->if_handle, &adapter->pmac_id, 0); + adapter->if_handle, &adapter->pmac_id[0], 0); if (status) goto err; @@ -885,6 +885,29 @@ static void be_set_rx_mode(struct net_device *netdev) goto done; } + if (netdev_uc_count(netdev) != adapter->uc_macs) { + struct netdev_hw_addr *ha; + int i = 1; /* First slot is claimed by the Primary MAC */ + + for (; adapter->uc_macs > 0; adapter->uc_macs--, i++) { + be_cmd_pmac_del(adapter, adapter->if_handle, + adapter->pmac_id[i], 0); + } + + if (netdev_uc_count(netdev) > adapter->max_pmac_cnt) { + be_cmd_rx_filter(adapter, IFF_PROMISC, ON); + adapter->promiscuous = true; + goto done; + } + + netdev_for_each_uc_addr(ha, adapter->netdev) { + adapter->uc_macs++; /* First slot is for Primary MAC */ + be_cmd_pmac_add(adapter, (u8 *)ha->addr, + adapter->if_handle, + &adapter->pmac_id[adapter->uc_macs], 0); + } + } + be_cmd_rx_filter(adapter, IFF_MULTICAST, ON); done: return; @@ -2458,6 +2481,8 @@ static void be_vf_clear(struct be_adapter *adapter) static int be_clear(struct be_adapter *adapter) { + int i = 1; + if (adapter->flags & BE_FLAGS_WORKER_SCHEDULED) { cancel_delayed_work_sync(&adapter->work); adapter->flags &= ~BE_FLAGS_WORKER_SCHEDULED; @@ -2466,6 +2491,10 @@ static int be_clear(struct be_adapter *adapter) if (sriov_enabled(adapter)) be_vf_clear(adapter); + for (; adapter->uc_macs > 0; adapter->uc_macs--, i++) + be_cmd_pmac_del(adapter, adapter->if_handle, + adapter->pmac_id[i], 0); + be_cmd_if_destroy(adapter, adapter->if_handle, 0); be_mcc_queues_destroy(adapter); @@ -2477,6 +2506,7 @@ static int be_clear(struct be_adapter *adapter) be_cmd_fw_clean(adapter); be_msix_disable(adapter); + kfree(adapter->pmac_id); return 0; } @@ -2552,10 +2582,10 @@ static int be_add_mac_from_list(struct be_adapter *adapter, u8 *mac) false, adapter->if_handle, pmac_id); if (!status) - adapter->pmac_id = pmac_id; + adapter->pmac_id[0] = pmac_id; } else { status = be_cmd_pmac_add(adapter, mac, - adapter->if_handle, &adapter->pmac_id, 0); + adapter->if_handle, &adapter->pmac_id[0], 0); } do_none: return status; @@ -2610,7 +2640,7 @@ static int be_setup(struct be_adapter *adapter) } status = be_cmd_if_create(adapter, cap_flags, en_flags, netdev->dev_addr, &adapter->if_handle, - &adapter->pmac_id, 0); + &adapter->pmac_id[0], 0); if (status != 0) goto err; @@ -3059,6 +3089,8 @@ static void be_netdev_init(struct net_device *netdev) netdev->vlan_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; + netdev->priv_flags |= IFF_UNICAST_FLT; + netdev->flags |= IFF_MULTICAST; netif_set_gso_max_size(netdev, 65535); @@ -3264,6 +3296,17 @@ static int be_get_config(struct be_adapter *adapter) else adapter->max_vlans = BE_NUM_VLANS_SUPPORTED; + if (be_physfn(adapter)) + adapter->max_pmac_cnt = BE_UC_PMAC_COUNT; + else + adapter->max_pmac_cnt = BE_VF_UC_PMAC_COUNT; + + /* primary mac needs 1 pmac entry */ + adapter->pmac_id = kcalloc(adapter->max_pmac_cnt + 1, + sizeof(u32), GFP_KERNEL); + if (!adapter->pmac_id) + return -ENOMEM; + status = be_cmd_get_cntl_attributes(adapter); if (status) return status; -- GitLab From 456d9c962bb5824423fa93277c8f7f5b2e3d5e1c Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Sun, 18 Mar 2012 06:23:31 +0000 Subject: [PATCH 1812/1846] be2net: Fix number of vlan slots in flex mode In flex10 mode the number of vlan slots supported is halved. Signed-off-by: Ajit Khaparde Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index b4348b8ee529..1c84bc81b8f1 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -3292,7 +3292,7 @@ static int be_get_config(struct be_adapter *adapter) return status; if (adapter->function_mode & FLEX10_MODE) - adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4; + adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/8; else adapter->max_vlans = BE_NUM_VLANS_SUPPORTED; -- GitLab From f1f3ee1bcc996e21f122442fd8c34de51622c76a Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Sun, 18 Mar 2012 06:23:41 +0000 Subject: [PATCH 1813/1846] be2net: fix programming of VLAN tags for VF Signed-off-by: Ajit Khaparde Signed-off-by: David S. Miller --- drivers/net/ethernet/emulex/benet/be.h | 1 + drivers/net/ethernet/emulex/benet/be_cmds.c | 83 +++++++++++++++++++++ drivers/net/ethernet/emulex/benet/be_cmds.h | 55 ++++++++++++++ drivers/net/ethernet/emulex/benet/be_main.c | 23 ++++-- 4 files changed, 157 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 03fc3dbe3872..9576ac002c23 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h @@ -303,6 +303,7 @@ struct be_vf_cfg { unsigned char mac_addr[ETH_ALEN]; int if_handle; int pmac_id; + u16 def_vid; u16 vlan_tag; u32 tx_rate; }; diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index d72c2b46963c..67b030d72df1 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -2419,6 +2419,89 @@ int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, return status; } +int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid, + u32 domain, u16 intf_id) +{ + struct be_mcc_wrb *wrb; + struct be_cmd_req_set_hsw_config *req; + void *ctxt; + int status; + + spin_lock_bh(&adapter->mcc_lock); + + wrb = wrb_from_mccq(adapter); + if (!wrb) { + status = -EBUSY; + goto err; + } + + req = embedded_payload(wrb); + ctxt = &req->context; + + be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, + OPCODE_COMMON_SET_HSW_CONFIG, sizeof(*req), wrb, NULL); + + req->hdr.domain = domain; + AMAP_SET_BITS(struct amap_set_hsw_context, interface_id, ctxt, intf_id); + if (pvid) { + AMAP_SET_BITS(struct amap_set_hsw_context, pvid_valid, ctxt, 1); + AMAP_SET_BITS(struct amap_set_hsw_context, pvid, ctxt, pvid); + } + + be_dws_cpu_to_le(req->context, sizeof(req->context)); + status = be_mcc_notify_wait(adapter); + +err: + spin_unlock_bh(&adapter->mcc_lock); + return status; +} + +/* Get Hyper switch config */ +int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid, + u32 domain, u16 intf_id) +{ + struct be_mcc_wrb *wrb; + struct be_cmd_req_get_hsw_config *req; + void *ctxt; + int status; + u16 vid; + + spin_lock_bh(&adapter->mcc_lock); + + wrb = wrb_from_mccq(adapter); + if (!wrb) { + status = -EBUSY; + goto err; + } + + req = embedded_payload(wrb); + ctxt = &req->context; + + be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, + OPCODE_COMMON_GET_HSW_CONFIG, sizeof(*req), wrb, NULL); + + req->hdr.domain = domain; + AMAP_SET_BITS(struct amap_get_hsw_req_context, interface_id, ctxt, + intf_id); + AMAP_SET_BITS(struct amap_get_hsw_req_context, pvid_valid, ctxt, 1); + be_dws_cpu_to_le(req->context, sizeof(req->context)); + + status = be_mcc_notify_wait(adapter); + if (!status) { + struct be_cmd_resp_get_hsw_config *resp = + embedded_payload(wrb); + be_dws_le_to_cpu(&resp->context, + sizeof(resp->context)); + vid = AMAP_GET_BITS(struct amap_get_hsw_resp_context, + pvid, &resp->context); + *pvid = le16_to_cpu(vid); + } + +err: + spin_unlock_bh(&adapter->mcc_lock); + return status; +} + int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) { struct be_mcc_wrb *wrb; diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index 345d49eeadc8..d5b680c56af0 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h @@ -191,6 +191,8 @@ struct be_mcc_mailbox { #define OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES 121 #define OPCODE_COMMON_GET_MAC_LIST 147 #define OPCODE_COMMON_SET_MAC_LIST 148 +#define OPCODE_COMMON_GET_HSW_CONFIG 152 +#define OPCODE_COMMON_SET_HSW_CONFIG 153 #define OPCODE_COMMON_READ_OBJECT 171 #define OPCODE_COMMON_WRITE_OBJECT 172 @@ -1413,6 +1415,55 @@ struct be_cmd_req_set_mac_list { struct macaddr mac[BE_MAX_MAC]; } __packed; +/*********************** HSW Config ***********************/ +struct amap_set_hsw_context { + u8 interface_id[16]; + u8 rsvd0[14]; + u8 pvid_valid; + u8 rsvd1; + u8 rsvd2[16]; + u8 pvid[16]; + u8 rsvd3[32]; + u8 rsvd4[32]; + u8 rsvd5[32]; +} __packed; + +struct be_cmd_req_set_hsw_config { + struct be_cmd_req_hdr hdr; + u8 context[sizeof(struct amap_set_hsw_context) / 8]; +} __packed; + +struct be_cmd_resp_set_hsw_config { + struct be_cmd_resp_hdr hdr; + u32 rsvd; +}; + +struct amap_get_hsw_req_context { + u8 interface_id[16]; + u8 rsvd0[14]; + u8 pvid_valid; + u8 pport; +} __packed; + +struct amap_get_hsw_resp_context { + u8 rsvd1[16]; + u8 pvid[16]; + u8 rsvd2[32]; + u8 rsvd3[32]; + u8 rsvd4[32]; +} __packed; + +struct be_cmd_req_get_hsw_config { + struct be_cmd_req_hdr hdr; + u8 context[sizeof(struct amap_get_hsw_req_context) / 8]; +} __packed; + +struct be_cmd_resp_get_hsw_config { + struct be_cmd_resp_hdr hdr; + u8 context[sizeof(struct amap_get_hsw_resp_context) / 8]; + u32 rsvd; +}; + /*************** HW Stats Get v1 **********************************/ #define BE_TXP_SW_SZ 48 struct be_port_rxf_stats_v1 { @@ -1617,5 +1668,9 @@ extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, bool *pmac_id_active, u32 *pmac_id, u8 *mac); extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, u8 mac_count, u32 domain); +extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid, + u32 domain, u16 intf_id); +extern int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid, + u32 domain, u16 intf_id); extern int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter); diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 1c84bc81b8f1..528a886bc2cd 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -978,14 +978,21 @@ static int be_set_vf_vlan(struct net_device *netdev, return -EINVAL; if (vlan) { - adapter->vf_cfg[vf].vlan_tag = vlan; - adapter->vlans_added++; + if (adapter->vf_cfg[vf].vlan_tag != vlan) { + /* If this is new value, program it. Else skip. */ + adapter->vf_cfg[vf].vlan_tag = vlan; + + status = be_cmd_set_hsw_config(adapter, vlan, + vf + 1, adapter->vf_cfg[vf].if_handle); + } } else { + /* Reset Transparent Vlan Tagging. */ adapter->vf_cfg[vf].vlan_tag = 0; - adapter->vlans_added--; + vlan = adapter->vf_cfg[vf].def_vid; + status = be_cmd_set_hsw_config(adapter, vlan, vf + 1, + adapter->vf_cfg[vf].if_handle); } - status = be_vid_config(adapter, true, vf); if (status) dev_info(&adapter->pdev->dev, @@ -2525,7 +2532,7 @@ static int be_vf_setup(struct be_adapter *adapter) { struct be_vf_cfg *vf_cfg; u32 cap_flags, en_flags, vf; - u16 lnk_speed; + u16 def_vlan, lnk_speed; int status; be_vf_setup_init(adapter); @@ -2549,6 +2556,12 @@ static int be_vf_setup(struct be_adapter *adapter) if (status) goto err; vf_cfg->tx_rate = lnk_speed * 10; + + status = be_cmd_get_hsw_config(adapter, &def_vlan, + vf + 1, vf_cfg->if_handle); + if (status) + goto err; + vf_cfg->def_vid = def_vlan; } return 0; err: -- GitLab From d8290ae54c88cab9f199a84125bd5fda9f48b032 Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Sun, 18 Mar 2012 10:33:37 +0000 Subject: [PATCH 1814/1846] bnx2x: added 'likely' to fast-path skb existence Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index b814f4eaed19..d888228d0787 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -120,10 +120,11 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, /* release skb */ WARN_ON(!skb); - if (skb) { + if (likely(skb)) { (*pkts_compl)++; (*bytes_compl) += skb->len; } + dev_kfree_skb_any(skb); tx_buf->first_bd = 0; tx_buf->skb = NULL; -- GitLab From 51c1a580b1e07d58eb063f9f4a70aea8ad32fe23 Mon Sep 17 00:00:00 2001 From: Merav Sicron Date: Sun, 18 Mar 2012 10:33:38 +0000 Subject: [PATCH 1815/1846] bnx2x: revised driver prints We've revised driver prints, changing the mask of existing prints to allow better control over the debug messages, added prints to error scenarios, removed unnecessary prints and corrected some spelling. Please note that this patch contains lines with over 80 characters, as string messages were kept in a single line. Signed-off-by: Merav Sicron Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 26 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 197 +++---- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 38 +- .../net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 221 ++++---- .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 189 ++++--- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 528 ++++++++---------- .../net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 150 ++--- .../net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 9 +- .../net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 63 +-- 9 files changed, 694 insertions(+), 727 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index c0cf313e6519..f534bf132373 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -58,18 +58,22 @@ #define DRV_MODULE_NAME "bnx2x" /* for messages that are currently off */ -#define BNX2X_MSG_OFF 0 -#define BNX2X_MSG_MCP 0x010000 /* was: NETIF_MSG_HW */ -#define BNX2X_MSG_STATS 0x020000 /* was: NETIF_MSG_TIMER */ -#define BNX2X_MSG_NVM 0x040000 /* was: NETIF_MSG_HW */ -#define BNX2X_MSG_DMAE 0x080000 /* was: NETIF_MSG_HW */ -#define BNX2X_MSG_SP 0x100000 /* was: NETIF_MSG_INTR */ -#define BNX2X_MSG_FP 0x200000 /* was: NETIF_MSG_INTR */ +#define BNX2X_MSG_OFF 0x0 +#define BNX2X_MSG_MCP 0x0010000 /* was: NETIF_MSG_HW */ +#define BNX2X_MSG_STATS 0x0020000 /* was: NETIF_MSG_TIMER */ +#define BNX2X_MSG_NVM 0x0040000 /* was: NETIF_MSG_HW */ +#define BNX2X_MSG_DMAE 0x0080000 /* was: NETIF_MSG_HW */ +#define BNX2X_MSG_SP 0x0100000 /* was: NETIF_MSG_INTR */ +#define BNX2X_MSG_FP 0x0200000 /* was: NETIF_MSG_INTR */ +#define BNX2X_MSG_IOV 0x0800000 +#define BNX2X_MSG_IDLE 0x2000000 /* used for idle check*/ +#define BNX2X_MSG_ETHTOOL 0x4000000 +#define BNX2X_MSG_DCB 0x8000000 /* regular debug print */ #define DP(__mask, fmt, ...) \ do { \ - if (bp->msg_enable & (__mask)) \ + if (unlikely(bp->msg_enable & (__mask))) \ pr_notice("[%s:%d(%s)]" fmt, \ __func__, __LINE__, \ bp->dev ? (bp->dev->name) : "?", \ @@ -78,14 +82,14 @@ do { \ #define DP_CONT(__mask, fmt, ...) \ do { \ - if (bp->msg_enable & (__mask)) \ + if (unlikely(bp->msg_enable & (__mask))) \ pr_cont(fmt, ##__VA_ARGS__); \ } while (0) /* errors debug print */ #define BNX2X_DBG_ERR(fmt, ...) \ do { \ - if (netif_msg_probe(bp)) \ + if (unlikely(netif_msg_probe(bp))) \ pr_err("[%s:%d(%s)]" fmt, \ __func__, __LINE__, \ bp->dev ? (bp->dev->name) : "?", \ @@ -108,7 +112,7 @@ do { \ /* before we have a dev->name use dev_info() */ #define BNX2X_DEV_INFO(fmt, ...) \ do { \ - if (netif_msg_probe(bp)) \ + if (unlikely(netif_msg_probe(bp))) \ dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__); \ } while (0) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index d888228d0787..d2fb7ba38143 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -75,11 +75,10 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, /* prefetch skb end pointer to speedup dev_kfree_skb() */ prefetch(&skb->end); - DP(BNX2X_MSG_FP, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n", + DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d buff @(%p)->skb %p\n", txdata->txq_index, idx, tx_buf, skb); /* unmap first bd */ - DP(BNX2X_MSG_OFF, "free bd_idx %d\n", bd_idx); tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd; dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd), BD_UNMAP_LEN(tx_start_bd), DMA_TO_DEVICE); @@ -110,7 +109,6 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, /* now free frags */ while (nbd > 0) { - DP(BNX2X_MSG_OFF, "free frag bd_idx %d\n", bd_idx); tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd; dma_unmap_page(&bp->pdev->dev, BD_UNMAP_ADDR(tx_data_bd), BD_UNMAP_LEN(tx_data_bd), DMA_TO_DEVICE); @@ -152,8 +150,8 @@ int bnx2x_tx_int(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata) pkt_cons = TX_BD(sw_cons); - DP(NETIF_MSG_TX_DONE, "queue[%d]: hw_cons %u sw_cons %u " - " pkt_cons %u\n", + DP(NETIF_MSG_TX_DONE, + "queue[%d]: hw_cons %u sw_cons %u pkt_cons %u\n", txdata->txq_index, hw_cons, sw_cons, pkt_cons); bd_cons = bnx2x_free_tx_pkt(bp, txdata, pkt_cons, @@ -531,8 +529,7 @@ static inline void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, if (likely(skb)) { #ifdef BNX2X_STOP_ON_ERROR if (pad + len > fp->rx_buf_size) { - BNX2X_ERR("skb_put is about to fail... " - "pad %d len %d rx_buf_size %d\n", + BNX2X_ERR("skb_put is about to fail... pad %d len %d rx_buf_size %d\n", pad, len, fp->rx_buf_size); bnx2x_panic(); return; @@ -552,8 +549,8 @@ static inline void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, __vlan_hwaccel_put_tag(skb, tpa_info->vlan_tag); napi_gro_receive(&fp->napi, skb); } else { - DP(NETIF_MSG_RX_STATUS, "Failed to allocate new pages" - " - dropping packet!\n"); + DP(NETIF_MSG_RX_STATUS, + "Failed to allocate new pages - dropping packet!\n"); dev_kfree_skb_any(skb); } @@ -629,8 +626,9 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) cqe_fp_flags = cqe_fp->type_error_flags; cqe_fp_type = cqe_fp_flags & ETH_FAST_PATH_RX_CQE_TYPE; - DP(NETIF_MSG_RX_STATUS, "CQE type %x err %x status %x" - " queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags), + DP(NETIF_MSG_RX_STATUS, + "CQE type %x err %x status %x queue %x vlan %x len %u\n", + CQE_TYPE(cqe_fp_flags), cqe_fp_flags, cqe_fp->status_flags, le32_to_cpu(cqe_fp->rss_hash_result), le16_to_cpu(cqe_fp->vlan_tag), @@ -653,8 +651,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) if (fp->disable_tpa && (CQE_TYPE_START(cqe_fp_type) || CQE_TYPE_STOP(cqe_fp_type))) - BNX2X_ERR("START/STOP packet while " - "disable_tpa type %x\n", + BNX2X_ERR("START/STOP packet while disable_tpa type %x\n", CQE_TYPE(cqe_fp_type)); #endif @@ -708,7 +705,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) prefetch(data + pad); /* speedup eth_type_trans() */ /* is this an error packet? */ if (unlikely(cqe_fp_flags & ETH_RX_ERROR_FALGS)) { - DP(NETIF_MSG_RX_ERR, + DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS, "ERROR flags %x rx packet %u\n", cqe_fp_flags, sw_comp_cons); fp->eth_q_stats.rx_err_discard_pkt++; @@ -722,7 +719,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) (len <= RX_COPY_THRESH)) { skb = netdev_alloc_skb_ip_align(bp->dev, len); if (skb == NULL) { - DP(NETIF_MSG_RX_ERR, + DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS, "ERROR packet dropped because of alloc failure\n"); fp->eth_q_stats.rx_skb_alloc_failed++; goto reuse_rx; @@ -743,9 +740,8 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) } skb_reserve(skb, pad); } else { - DP(NETIF_MSG_RX_ERR, - "ERROR packet dropped because " - "of alloc failure\n"); + DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS, + "ERROR packet dropped because of alloc failure\n"); fp->eth_q_stats.rx_skb_alloc_failed++; reuse_rx: bnx2x_reuse_rx_data(fp, bd_cons, bd_prod); @@ -814,8 +810,8 @@ static irqreturn_t bnx2x_msix_fp_int(int irq, void *fp_cookie) struct bnx2x *bp = fp->bp; u8 cos; - DP(BNX2X_MSG_FP, "got an MSI-X interrupt on IDX:SB " - "[fp %d fw_sd %d igusb %d]\n", + DP(NETIF_MSG_INTR, + "got an MSI-X interrupt on IDX:SB [fp %d fw_sd %d igusb %d]\n", fp->index, fp->fw_sb_id, fp->igu_sb_id); bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, 0, IGU_INT_DISABLE, 0); @@ -1028,10 +1024,8 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) first_buf->data = kmalloc(fp->rx_buf_size + NET_SKB_PAD, GFP_ATOMIC); if (!first_buf->data) { - BNX2X_ERR("Failed to allocate TPA " - "skb pool for queue[%d] - " - "disabling TPA on this " - "queue!\n", j); + BNX2X_ERR("Failed to allocate TPA skb pool for queue[%d] - disabling TPA on this queue!\n", + j); bnx2x_free_tpa_pool(bp, fp, i); fp->disable_tpa = 1; break; @@ -1051,10 +1045,10 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) i < MAX_RX_SGE_CNT*NUM_RX_SGE_PAGES; i++) { if (bnx2x_alloc_rx_sge(bp, fp, ring_prod) < 0) { - BNX2X_ERR("was only able to allocate " - "%d rx sges\n", i); - BNX2X_ERR("disabling TPA for " - "queue[%d]\n", j); + BNX2X_ERR("was only able to allocate %d rx sges\n", + i); + BNX2X_ERR("disabling TPA for queue[%d]\n", + j); /* Cleanup already allocated elements */ bnx2x_free_rx_sge_range(bp, fp, ring_prod); @@ -1209,8 +1203,8 @@ static void bnx2x_free_msix_irqs(struct bnx2x *bp, int nvecs) for_each_eth_queue(bp, i) { if (nvecs == offset) return; - DP(NETIF_MSG_IFDOWN, "about to release fp #%d->%d " - "irq\n", i, bp->msix_table[offset].vector); + DP(NETIF_MSG_IFDOWN, "about to release fp #%d->%d irq\n", + i, bp->msix_table[offset].vector); free_irq(bp->msix_table[offset++].vector, &bp->fp[i]); } @@ -1232,21 +1226,21 @@ int bnx2x_enable_msix(struct bnx2x *bp) int msix_vec = 0, i, rc, req_cnt; bp->msix_table[msix_vec].entry = msix_vec; - DP(NETIF_MSG_IFUP, "msix_table[0].entry = %d (slowpath)\n", + BNX2X_DEV_INFO("msix_table[0].entry = %d (slowpath)\n", bp->msix_table[0].entry); msix_vec++; #ifdef BCM_CNIC bp->msix_table[msix_vec].entry = msix_vec; - DP(NETIF_MSG_IFUP, "msix_table[%d].entry = %d (CNIC)\n", + BNX2X_DEV_INFO("msix_table[%d].entry = %d (CNIC)\n", bp->msix_table[msix_vec].entry, bp->msix_table[msix_vec].entry); msix_vec++; #endif /* We need separate vectors for ETH queues only (not FCoE) */ for_each_eth_queue(bp, i) { bp->msix_table[msix_vec].entry = msix_vec; - DP(NETIF_MSG_IFUP, "msix_table[%d].entry = %d " - "(fastpath #%u)\n", msix_vec, msix_vec, i); + BNX2X_DEV_INFO("msix_table[%d].entry = %d (fastpath #%u)\n", + msix_vec, msix_vec, i); msix_vec++; } @@ -1262,14 +1256,12 @@ int bnx2x_enable_msix(struct bnx2x *bp) /* how less vectors we will have? */ int diff = req_cnt - rc; - DP(NETIF_MSG_IFUP, - "Trying to use less MSI-X vectors: %d\n", rc); + BNX2X_DEV_INFO("Trying to use less MSI-X vectors: %d\n", rc); rc = pci_enable_msix(bp->pdev, &bp->msix_table[0], rc); if (rc) { - DP(NETIF_MSG_IFUP, - "MSI-X is not attainable rc %d\n", rc); + BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc); return rc; } /* @@ -1277,13 +1269,13 @@ int bnx2x_enable_msix(struct bnx2x *bp) */ bp->num_queues -= diff; - DP(NETIF_MSG_IFUP, "New queue configuration set: %d\n", + BNX2X_DEV_INFO("New queue configuration set: %d\n", bp->num_queues); } else if (rc) { /* fall to INTx if not enough memory */ if (rc == -ENOMEM) bp->flags |= DISABLE_MSI_FLAG; - DP(NETIF_MSG_IFUP, "MSI-X is not attainable rc %d\n", rc); + BNX2X_DEV_INFO("MSI-X is not attainable rc %d\n", rc); return rc; } @@ -1326,8 +1318,7 @@ static int bnx2x_req_msix_irqs(struct bnx2x *bp) i = BNX2X_NUM_ETH_QUEUES(bp); offset = 1 + CNIC_PRESENT; - netdev_info(bp->dev, "using MSI-X IRQs: sp %d fp[%d] %d" - " ... fp[%d] %d\n", + netdev_info(bp->dev, "using MSI-X IRQs: sp %d fp[%d] %d ... fp[%d] %d\n", bp->msix_table[0].vector, 0, bp->msix_table[offset].vector, i - 1, bp->msix_table[offset + i - 1].vector); @@ -1341,7 +1332,7 @@ int bnx2x_enable_msi(struct bnx2x *bp) rc = pci_enable_msi(bp->pdev); if (rc) { - DP(NETIF_MSG_IFUP, "MSI is not attainable\n"); + BNX2X_DEV_INFO("MSI is not attainable\n"); return -1; } bp->flags |= USING_MSI_FLAG; @@ -1518,7 +1509,7 @@ static inline int bnx2x_set_real_num_queues(struct bnx2x *bp) return rc; } - DP(NETIF_MSG_DRV, "Setting real num queues to (tx, rx) (%d, %d)\n", + DP(NETIF_MSG_IFUP, "Setting real num queues to (tx, rx) (%d, %d)\n", tx, rx); return rc; @@ -1699,8 +1690,8 @@ static void bnx2x_squeeze_objects(struct bnx2x *bp) /* Add a DEL command... */ rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_DEL); if (rc < 0) - BNX2X_ERR("Failed to add a new DEL command to a multi-cast " - "object: %d\n", rc); + BNX2X_ERR("Failed to add a new DEL command to a multi-cast object: %d\n", + rc); /* ...and wait until all pending commands are cleared */ rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_CONT); @@ -1738,8 +1729,10 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) int i, rc; #ifdef BNX2X_STOP_ON_ERROR - if (unlikely(bp->panic)) + if (unlikely(bp->panic)) { + BNX2X_ERR("Can't load NIC when there is panic\n"); return -EPERM; + } #endif bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD; @@ -1759,6 +1752,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) * allocated only once, fp index, max_cos, bp pointer. * Also set fp->disable_tpa. */ + DP(NETIF_MSG_IFUP, "num queues: %d", bp->num_queues); for_each_queue(bp, i) bnx2x_bz_fp(bp, i); @@ -1815,6 +1809,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) LOAD_ERROR_EXIT(bp, load_error1); } if (load_code == FW_MSG_CODE_DRV_LOAD_REFUSED) { + BNX2X_ERR("Driver load refused\n"); rc = -EBUSY; /* other port in diagnostic mode */ LOAD_ERROR_EXIT(bp, load_error1); } @@ -1875,7 +1870,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) } else bp->port.pmf = 0; - DP(NETIF_MSG_LINK, "pmf %d\n", bp->port.pmf); + DP(NETIF_MSG_IFUP, "pmf %d\n", bp->port.pmf); /* Init Function state controlling object */ bnx2x__init_func_obj(bp); @@ -1891,6 +1886,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) /* Connect to IRQs */ rc = bnx2x_setup_irqs(bp); if (rc) { + BNX2X_ERR("IRQs setup failed\n"); bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE, 0); LOAD_ERROR_EXIT(bp, load_error2); } @@ -1941,21 +1937,27 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) for_each_nondefault_queue(bp, i) { rc = bnx2x_setup_queue(bp, &bp->fp[i], 0); - if (rc) + if (rc) { + BNX2X_ERR("Queue setup failed\n"); LOAD_ERROR_EXIT(bp, load_error4); + } } rc = bnx2x_init_rss_pf(bp); - if (rc) + if (rc) { + BNX2X_ERR("PF RSS init failed\n"); LOAD_ERROR_EXIT(bp, load_error4); + } /* Now when Clients are configured we are ready to work */ bp->state = BNX2X_STATE_OPEN; /* Configure a ucast MAC */ rc = bnx2x_set_eth_mac(bp, true); - if (rc) + if (rc) { + BNX2X_ERR("Setting Ethernet MAC failed\n"); LOAD_ERROR_EXIT(bp, load_error4); + } if (bp->pending_max) { bnx2x_update_max_mf_config(bp, bp->pending_max); @@ -2092,8 +2094,8 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) bnx2x_release_leader_lock(bp); smp_mb(); - DP(NETIF_MSG_HW, "Releasing a leadership...\n"); - + DP(NETIF_MSG_IFDOWN, "Releasing a leadership...\n"); + BNX2X_ERR("Can't unload in closed or error state\n"); return -EINVAL; } @@ -2198,7 +2200,7 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state) /* If there is no power capability, silently succeed */ if (!bp->pm_cap) { - DP(NETIF_MSG_HW, "No power capability. Breaking.\n"); + BNX2X_DEV_INFO("No power capability. Breaking.\n"); return 0; } @@ -2239,6 +2241,7 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state) break; default: + dev_err(&bp->pdev->dev, "Can't support state = %d\n", state); return -EINVAL; } return 0; @@ -2308,7 +2311,7 @@ int bnx2x_poll(struct napi_struct *napi, int budget) if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) { napi_complete(napi); /* Re-enable interrupts */ - DP(NETIF_MSG_HW, + DP(NETIF_MSG_RX_STATUS, "Update index to %d\n", fp->fp_hc_idx); bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, le16_to_cpu(fp->fp_hc_idx), @@ -2342,9 +2345,8 @@ static noinline u16 bnx2x_tx_split(struct bnx2x *bp, h_tx_bd->nbd = cpu_to_le16(nbd); h_tx_bd->nbytes = cpu_to_le16(hlen); - DP(NETIF_MSG_TX_QUEUED, "TSO split header size is %d " - "(%x:%x) nbd %d\n", h_tx_bd->nbytes, h_tx_bd->addr_hi, - h_tx_bd->addr_lo, h_tx_bd->nbd); + DP(NETIF_MSG_TX_QUEUED, "TSO split header size is %d (%x:%x) nbd %d\n", + h_tx_bd->nbytes, h_tx_bd->addr_hi, h_tx_bd->addr_lo, h_tx_bd->nbd); /* now get a new data BD * (after the pbd) and fill it */ @@ -2484,8 +2486,7 @@ static int bnx2x_pkt_req_lin(struct bnx2x *bp, struct sk_buff *skb, exit_lbl: if (unlikely(to_copy)) DP(NETIF_MSG_TX_QUEUED, - "Linearization IS REQUIRED for %s packet. " - "num_frags %d hlen %d first_bd_sz %d\n", + "Linearization IS REQUIRED for %s packet. num_frags %d hlen %d first_bd_sz %d\n", (xmit_type & XMIT_GSO) ? "LSO" : "non-LSO", skb_shinfo(skb)->nr_frags, hlen, first_bd_sz); @@ -2693,7 +2694,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) #endif /* enable this debug print to view the transmission queue being used - DP(BNX2X_MSG_FP, "indices: txq %d, fp %d, txdata %d\n", + DP(NETIF_MSG_TX_QUEUED, "indices: txq %d, fp %d, txdata %d\n", txq_index, fp_index, txdata_index); */ /* locate the fastpath and the txdata */ @@ -2701,8 +2702,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) txdata = &fp->txdata[txdata_index]; /* enable this debug print to view the tranmission details - DP(BNX2X_MSG_FP,"transmitting packet cid %d fp index %d txdata_index %d" - " tx_data ptr %p fp pointer %p\n", + DP(NETIF_MSG_TX_QUEUED, + "transmitting packet cid %d fp index %d txdata_index %d tx_data ptr %p fp pointer %p\n", txdata->cid, fp_index, txdata_index, txdata, fp); */ if (unlikely(bnx2x_tx_avail(bp, txdata) < @@ -2713,8 +2714,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_BUSY; } - DP(NETIF_MSG_TX_QUEUED, "queue[%d]: SKB: summed %x protocol %x " - "protocol(%x,%x) gso type %x xmit_type %x\n", + DP(NETIF_MSG_TX_QUEUED, + "queue[%d]: SKB: summed %x protocol %x protocol(%x,%x) gso type %x xmit_type %x\n", txq_index, skb->ip_summed, skb->protocol, ipv6_hdr(skb)->nexthdr, ip_hdr(skb)->protocol, skb_shinfo(skb)->gso_type, xmit_type); @@ -2736,8 +2737,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) /* Statistics of linearization */ bp->lin_cnt++; if (skb_linearize(skb) != 0) { - DP(NETIF_MSG_TX_QUEUED, "SKB linearization failed - " - "silently dropping this SKB\n"); + DP(NETIF_MSG_TX_QUEUED, + "SKB linearization failed - silently dropping this SKB\n"); dev_kfree_skb_any(skb); return NETDEV_TX_OK; } @@ -2747,8 +2748,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) mapping = dma_map_single(&bp->pdev->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { - DP(NETIF_MSG_TX_QUEUED, "SKB mapping failed - " - "silently dropping this SKB\n"); + DP(NETIF_MSG_TX_QUEUED, + "SKB mapping failed - silently dropping this SKB\n"); dev_kfree_skb_any(skb); return NETDEV_TX_OK; } @@ -2843,8 +2844,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) tx_start_bd->nbytes = cpu_to_le16(skb_headlen(skb)); pkt_size = tx_start_bd->nbytes; - DP(NETIF_MSG_TX_QUEUED, "first bd @%p addr (%x:%x) nbd %d" - " nbytes %d flags %x vlan %x\n", + DP(NETIF_MSG_TX_QUEUED, + "first bd @%p addr (%x:%x) nbd %d nbytes %d flags %x vlan %x\n", tx_start_bd, tx_start_bd->addr_hi, tx_start_bd->addr_lo, le16_to_cpu(tx_start_bd->nbd), le16_to_cpu(tx_start_bd->nbytes), tx_start_bd->bd_flags.as_bitfield, @@ -2887,8 +2888,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { unsigned int pkts_compl = 0, bytes_compl = 0; - DP(NETIF_MSG_TX_QUEUED, "Unable to map page - " - "dropping packet...\n"); + DP(NETIF_MSG_TX_QUEUED, + "Unable to map page - dropping packet...\n"); /* we need unmap all buffers already mapped * for this SKB; @@ -2944,8 +2945,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) if (pbd_e1x) DP(NETIF_MSG_TX_QUEUED, - "PBD (E1X) @%p ip_data %x ip_hlen %u ip_id %u lso_mss %u" - " tcp_flags %x xsum %x seq %u hlen %u\n", + "PBD (E1X) @%p ip_data %x ip_hlen %u ip_id %u lso_mss %u tcp_flags %x xsum %x seq %u hlen %u\n", pbd_e1x, pbd_e1x->global_data, pbd_e1x->ip_hlen_w, pbd_e1x->ip_id, pbd_e1x->lso_mss, pbd_e1x->tcp_flags, pbd_e1x->tcp_pseudo_csum, pbd_e1x->tcp_send_seq, @@ -3021,23 +3021,22 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc) /* requested to support too many traffic classes */ if (num_tc > bp->max_cos) { - DP(NETIF_MSG_TX_ERR, "support for too many traffic classes" - " requested: %d. max supported is %d\n", - num_tc, bp->max_cos); + BNX2X_ERR("support for too many traffic classes requested: %d. max supported is %d\n", + num_tc, bp->max_cos); return -EINVAL; } /* declare amount of supported traffic classes */ if (netdev_set_num_tc(dev, num_tc)) { - DP(NETIF_MSG_TX_ERR, "failed to declare %d traffic classes\n", - num_tc); + BNX2X_ERR("failed to declare %d traffic classes\n", num_tc); return -EINVAL; } /* configure priority to traffic class mapping */ for (prio = 0; prio < BNX2X_MAX_PRIORITY; prio++) { netdev_set_prio_tc_map(dev, prio, bp->prio_to_cos[prio]); - DP(BNX2X_MSG_SP, "mapping priority %d to tc %d\n", + DP(BNX2X_MSG_SP | NETIF_MSG_IFUP, + "mapping priority %d to tc %d\n", prio, bp->prio_to_cos[prio]); } @@ -3057,7 +3056,8 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc) count = BNX2X_NUM_ETH_QUEUES(bp); offset = cos * MAX_TXQS_PER_COS; netdev_set_tc_queue(dev, cos, count, offset); - DP(BNX2X_MSG_SP, "mapping tc %d to offset %d count %d\n", + DP(BNX2X_MSG_SP | NETIF_MSG_IFUP, + "mapping tc %d to offset %d count %d\n", cos, offset, count); } @@ -3071,12 +3071,16 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p) struct bnx2x *bp = netdev_priv(dev); int rc = 0; - if (!bnx2x_is_valid_ether_addr(bp, addr->sa_data)) + if (!bnx2x_is_valid_ether_addr(bp, addr->sa_data)) { + BNX2X_ERR("Requested MAC address is not valid\n"); return -EINVAL; + } #ifdef BCM_CNIC - if (IS_MF_ISCSI_SD(bp) && !is_zero_ether_addr(addr->sa_data)) + if (IS_MF_ISCSI_SD(bp) && !is_zero_ether_addr(addr->sa_data)) { + BNX2X_ERR("Can't configure non-zero address on iSCSI or FCoE functions in MF-SD mode\n"); return -EINVAL; + } #endif if (netif_running(dev)) { @@ -3150,7 +3154,7 @@ static void bnx2x_free_fp_mem_at(struct bnx2x *bp, int fp_index) for_each_cos_in_tx_queue(fp, cos) { struct bnx2x_fp_txdata *txdata = &fp->txdata[cos]; - DP(BNX2X_MSG_SP, + DP(NETIF_MSG_IFDOWN, "freeing tx memory of fp %d cos %d cid %d\n", fp_index, cos, txdata->cid); @@ -3249,8 +3253,8 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index) for_each_cos_in_tx_queue(fp, cos) { struct bnx2x_fp_txdata *txdata = &fp->txdata[cos]; - DP(BNX2X_MSG_SP, "allocating tx memory of " - "fp %d cos %d\n", + DP(NETIF_MSG_IFUP, + "allocating tx memory of fp %d cos %d\n", index, cos); BNX2X_ALLOC(txdata->tx_buf_ring, @@ -3487,6 +3491,7 @@ int bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type) cp->fcoe_wwn_port_name_lo); break; default: + BNX2X_ERR("Wrong WWN type requested - %d\n", type); return -EINVAL; } @@ -3500,13 +3505,15 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu) struct bnx2x *bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - netdev_err(dev, "Handling parity error recovery. Try again later\n"); + BNX2X_ERR("Can't perform change MTU during parity recovery\n"); return -EAGAIN; } if ((new_mtu > ETH_MAX_JUMBO_PACKET_SIZE) || - ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) + ((new_mtu + ETH_HLEN) < ETH_MIN_PACKET_SIZE)) { + BNX2X_ERR("Can't support requested MTU size\n"); return -EINVAL; + } /* This does not race with packet allocation * because the actual alloc size is @@ -3636,7 +3643,7 @@ int bnx2x_resume(struct pci_dev *pdev) bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - netdev_err(dev, "Handling parity error recovery. Try again later\n"); + BNX2X_ERR("Handling parity error recovery. Try again later\n"); return -EAGAIN; } @@ -3681,8 +3688,9 @@ static inline void storm_memset_hc_timeout(struct bnx2x *bp, u8 port, u32 addr = BAR_CSTRORM_INTMEM + CSTORM_STATUS_BLOCK_DATA_TIMEOUT_OFFSET(fw_sb_id, sb_index); REG_WR8(bp, addr, ticks); - DP(NETIF_MSG_HW, "port %x fw_sb_id %d sb_index %d ticks %d\n", - port, fw_sb_id, sb_index, ticks); + DP(NETIF_MSG_IFUP, + "port %x fw_sb_id %d sb_index %d ticks %d\n", + port, fw_sb_id, sb_index, ticks); } static inline void storm_memset_hc_disable(struct bnx2x *bp, u8 port, @@ -3697,8 +3705,9 @@ static inline void storm_memset_hc_disable(struct bnx2x *bp, u8 port, flags &= ~HC_INDEX_DATA_HC_ENABLED; flags |= enable_flag; REG_WR16(bp, addr, flags); - DP(NETIF_MSG_HW, "port %x fw_sb_id %d sb_index %d disable %d\n", - port, fw_sb_id, sb_index, disable); + DP(NETIF_MSG_IFUP, + "port %x fw_sb_id %d sb_index %d disable %d\n", + port, fw_sb_id, sb_index, disable); } void bnx2x_update_coalesce_sb_index(struct bnx2x *bp, u8 fw_sb_id, diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 5904b1b1dad4..bba47fb8755c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -598,7 +598,7 @@ static inline void bnx2x_igu_ack_sb_gen(struct bnx2x *bp, u8 igu_sb_id, (update << IGU_REGULAR_BUPDATE_SHIFT) | (op << IGU_REGULAR_ENABLE_INT_SHIFT)); - DP(NETIF_MSG_HW, "write 0x%08x to IGU addr 0x%x\n", + DP(NETIF_MSG_INTR, "write 0x%08x to IGU addr 0x%x\n", cmd_data.sb_id_and_flags, igu_addr); REG_WR(bp, igu_addr, cmd_data.sb_id_and_flags); @@ -648,8 +648,8 @@ static inline void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, if (!(REG_RD(bp, igu_addr_ack) & sb_bit)) { - DP(NETIF_MSG_HW, "Unable to finish IGU cleanup: " - "idu_sb_id %d offset %d bit %d (cnt %d)\n", + DP(NETIF_MSG_HW, + "Unable to finish IGU cleanup: idu_sb_id %d offset %d bit %d (cnt %d)\n", idu_sb_id, idu_sb_id/32, idu_sb_id%32, cnt); } } @@ -668,8 +668,6 @@ static inline void bnx2x_hc_ack_sb(struct bnx2x *bp, u8 sb_id, (update << IGU_ACK_REGISTER_UPDATE_INDEX_SHIFT) | (op << IGU_ACK_REGISTER_INTERRUPT_MODE_SHIFT)); - DP(BNX2X_MSG_OFF, "write 0x%08x to HC addr 0x%x\n", - (*(u32 *)&igu_ack), hc_addr); REG_WR(bp, hc_addr, (*(u32 *)&igu_ack)); /* Make sure that ACK is written */ @@ -703,9 +701,6 @@ static inline u16 bnx2x_hc_ack_int(struct bnx2x *bp) COMMAND_REG_SIMD_MASK); u32 result = REG_RD(bp, hc_addr); - DP(BNX2X_MSG_OFF, "read 0x%08x from HC addr 0x%x\n", - result, hc_addr); - barrier(); return result; } @@ -715,7 +710,7 @@ static inline u16 bnx2x_igu_ack_int(struct bnx2x *bp) u32 igu_addr = (BAR_IGU_INTMEM + IGU_REG_SISR_MDPC_WMASK_LSB_UPPER*8); u32 result = REG_RD(bp, igu_addr); - DP(NETIF_MSG_HW, "read 0x%08x from IGU addr 0x%x\n", + DP(NETIF_MSG_INTR, "read 0x%08x from IGU addr 0x%x\n", result, igu_addr); barrier(); @@ -893,13 +888,16 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct eth_rx_sge *sge = &fp->rx_sge_ring[index]; dma_addr_t mapping; - if (unlikely(page == NULL)) + if (unlikely(page == NULL)) { + BNX2X_ERR("Can't alloc sge\n"); return -ENOMEM; + } mapping = dma_map_page(&bp->pdev->dev, page, 0, SGE_PAGE_SIZE*PAGES_PER_SGE, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { __free_pages(page, PAGES_PER_SGE_SHIFT); + BNX2X_ERR("Can't map sge\n"); return -ENOMEM; } @@ -929,6 +927,7 @@ static inline int bnx2x_alloc_rx_data(struct bnx2x *bp, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { kfree(data); + BNX2X_ERR("Can't map rx data\n"); return -ENOMEM; } @@ -1299,7 +1298,7 @@ static inline void bnx2x_init_txdata(struct bnx2x *bp, txdata->txq_index = txq_index; txdata->tx_cons_sb = tx_cons_sb; - DP(BNX2X_MSG_SP, "created tx data cid %d, txq %d\n", + DP(NETIF_MSG_IFUP, "created tx data cid %d, txq %d\n", txdata->cid, txdata->txq_index); } @@ -1344,7 +1343,7 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp) bnx2x_init_txdata(bp, &bnx2x_fcoe(bp, txdata[0]), fp->cid, FCOE_TXQ_IDX(bp), BNX2X_FCOE_L2_TX_INDEX); - DP(BNX2X_MSG_SP, "created fcoe tx data (fp index %d)\n", fp->index); + DP(NETIF_MSG_IFUP, "created fcoe tx data (fp index %d)\n", fp->index); /* qZone id equals to FW (per path) client id */ bnx2x_fcoe(bp, cl_qzone_id) = bnx2x_fp_qzone_id(fp); @@ -1363,8 +1362,8 @@ static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp) BP_FUNC(bp), bnx2x_sp(bp, q_rdata), bnx2x_sp_mapping(bp, q_rdata), q_type); - DP(NETIF_MSG_IFUP, "queue[%d]: bnx2x_init_sb(%p,%p) cl_id %d fw_sb %d " - "igu_sb %d\n", + DP(NETIF_MSG_IFUP, + "queue[%d]: bnx2x_init_sb(%p,%p) cl_id %d fw_sb %d igu_sb %d\n", fp->index, bp, fp->status_blk.e2_sb, fp->cl_id, fp->fw_sb_id, fp->igu_sb_id); } @@ -1377,8 +1376,7 @@ static inline int bnx2x_clean_tx_queue(struct bnx2x *bp, while (bnx2x_has_tx_work_unload(txdata)) { if (!cnt) { - BNX2X_ERR("timeout waiting for queue[%d]: " - "txdata->tx_pkt_prod(%d) != txdata->tx_pkt_cons(%d)\n", + BNX2X_ERR("timeout waiting for queue[%d]: txdata->tx_pkt_prod(%d) != txdata->tx_pkt_cons(%d)\n", txdata->txq_index, txdata->tx_pkt_prod, txdata->tx_pkt_cons); #ifdef BNX2X_STOP_ON_ERROR @@ -1455,8 +1453,8 @@ static inline bool bnx2x_wait_sp_comp(struct bnx2x *bp, unsigned long mask) netif_addr_lock_bh(bp->dev); if (bp->sp_state & mask) { - BNX2X_ERR("Filtering completion timed out. sp_state 0x%lx, " - "mask 0x%lx\n", bp->sp_state, mask); + BNX2X_ERR("Filtering completion timed out. sp_state 0x%lx, mask 0x%lx\n", + bp->sp_state, mask); netif_addr_unlock_bh(bp->dev); return false; } @@ -1492,7 +1490,7 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg) u16 max_cfg = (mf_cfg & FUNC_MF_CFG_MAX_BW_MASK) >> FUNC_MF_CFG_MAX_BW_SHIFT; if (!max_cfg) { - DP(NETIF_MSG_LINK, + DP(NETIF_MSG_IFUP | BNX2X_MSG_ETHTOOL, "Max BW configured to 0 - using 100 instead\n"); max_cfg = 100; } @@ -1655,7 +1653,7 @@ static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set) RESET_FLAGS(drv_flags, flags); SHMEM2_WR(bp, drv_flags, drv_flags); - DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); + DP(NETIF_MSG_IFUP, "drv_flags 0x%08x\n", drv_flags); bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS); } } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 4446a42e8bdc..b19669ab993b 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -167,27 +167,27 @@ static void bnx2x_dump_dcbx_drv_param(struct bnx2x *bp, DCBX_PRI_PG_GET(features->ets.pri_pg_tbl, i)); /* pfc */ - DP(NETIF_MSG_LINK, "dcbx_features.pfc.pri_en_bitmap %x\n", + DP(BNX2X_MSG_DCB, "dcbx_features.pfc.pri_en_bitmap %x\n", features->pfc.pri_en_bitmap); - DP(NETIF_MSG_LINK, "dcbx_features.pfc.pfc_caps %x\n", + DP(BNX2X_MSG_DCB, "dcbx_features.pfc.pfc_caps %x\n", features->pfc.pfc_caps); - DP(NETIF_MSG_LINK, "dcbx_features.pfc.enabled %x\n", + DP(BNX2X_MSG_DCB, "dcbx_features.pfc.enabled %x\n", features->pfc.enabled); - DP(NETIF_MSG_LINK, "dcbx_features.app.default_pri %x\n", + DP(BNX2X_MSG_DCB, "dcbx_features.app.default_pri %x\n", features->app.default_pri); - DP(NETIF_MSG_LINK, "dcbx_features.app.tc_supported %x\n", + DP(BNX2X_MSG_DCB, "dcbx_features.app.tc_supported %x\n", features->app.tc_supported); - DP(NETIF_MSG_LINK, "dcbx_features.app.enabled %x\n", + DP(BNX2X_MSG_DCB, "dcbx_features.app.enabled %x\n", features->app.enabled); for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "dcbx_features.app.app_pri_tbl[%x].app_id %x\n", i, features->app.app_pri_tbl[i].app_id); - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "dcbx_features.app.app_pri_tbl[%x].pri_bitmap %x\n", i, features->app.app_pri_tbl[i].pri_bitmap); - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "dcbx_features.app.app_pri_tbl[%x].appBitfield %x\n", i, features->app.app_pri_tbl[i].appBitfield); } @@ -221,10 +221,10 @@ static void bnx2x_dcbx_get_ap_feature(struct bnx2x *bp, u32 *ttp = bp->dcbx_port_params.app.traffic_type_priority; if (GET_FLAGS(error, DCBX_LOCAL_APP_ERROR)) - DP(NETIF_MSG_LINK, "DCBX_LOCAL_APP_ERROR\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_ERROR\n"); if (GET_FLAGS(error, DCBX_LOCAL_APP_MISMATCH)) - DP(NETIF_MSG_LINK, "DCBX_LOCAL_APP_MISMATCH\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_MISMATCH\n"); if (app->enabled && !GET_FLAGS(error, DCBX_LOCAL_APP_ERROR | DCBX_LOCAL_APP_MISMATCH)) { @@ -256,7 +256,7 @@ static void bnx2x_dcbx_get_ap_feature(struct bnx2x *bp, LLFC_TRAFFIC_TYPE_ISCSI); } } else { - DP(NETIF_MSG_LINK, "DCBX_LOCAL_APP_DISABLED\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_DISABLED\n"); bp->dcbx_port_params.app.enabled = false; for (index = 0 ; index < LLFC_DRIVER_TRAFFIC_TYPE_MAX; index++) ttp[index] = INVALID_TRAFFIC_TYPE_PRIORITY; @@ -276,7 +276,7 @@ static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp, if (GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR)) - DP(NETIF_MSG_LINK, "DCBX_LOCAL_ETS_ERROR\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_ERROR\n"); /* Clean up old settings of ets on COS */ @@ -290,7 +290,7 @@ static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp, if (bp->dcbx_port_params.app.enabled && !GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR) && ets->enabled) { - DP(NETIF_MSG_LINK, "DCBX_LOCAL_ETS_ENABLE\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_ENABLE\n"); bp->dcbx_port_params.ets.enabled = true; bnx2x_dcbx_get_ets_pri_pg_tbl(bp, @@ -305,7 +305,7 @@ static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp, ets, pg_pri_orginal_spread); } else { - DP(NETIF_MSG_LINK, "DCBX_LOCAL_ETS_DISABLED\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_DISABLED\n"); bp->dcbx_port_params.ets.enabled = false; ets->pri_pg_tbl[0] = 0; @@ -319,7 +319,7 @@ static void bnx2x_dcbx_get_pfc_feature(struct bnx2x *bp, { if (GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR)) - DP(NETIF_MSG_LINK, "DCBX_LOCAL_PFC_ERROR\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_PFC_ERROR\n"); if (bp->dcbx_port_params.app.enabled && !GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR | DCBX_LOCAL_PFC_MISMATCH) && @@ -328,7 +328,7 @@ static void bnx2x_dcbx_get_pfc_feature(struct bnx2x *bp, bp->dcbx_port_params.pfc.priority_non_pauseable_mask = ~(pfc->pri_en_bitmap); } else { - DP(NETIF_MSG_LINK, "DCBX_LOCAL_PFC_DISABLED\n"); + DP(BNX2X_MSG_DCB, "DCBX_LOCAL_PFC_DISABLED\n"); bp->dcbx_port_params.pfc.enabled = false; bp->dcbx_port_params.pfc.priority_non_pauseable_mask = 0; } @@ -352,7 +352,7 @@ static void bnx2x_dcbx_map_nw(struct bnx2x *bp) for (i = 0; i < ARRAY_SIZE(bp->dcbx_port_params.ets.cos_params); i++) { if (cos_params[i].pri_bitmask & nw_prio) { /* extend the bitmask with unmapped */ - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "cos %d extended with 0x%08x\n", i, unmapped); cos_params[i].pri_bitmask |= unmapped; break; @@ -448,7 +448,7 @@ static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp) func_params.f_obj = &bp->func_obj; func_params.cmd = BNX2X_F_CMD_TX_STOP; - DP(NETIF_MSG_LINK, "STOP TRAFFIC\n"); + DP(BNX2X_MSG_DCB, "STOP TRAFFIC\n"); return bnx2x_func_state_change(bp, &func_params); } @@ -463,7 +463,7 @@ static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp) bnx2x_dcbx_fw_struct(bp, tx_params); - DP(NETIF_MSG_LINK, "START TRAFFIC\n"); + DP(BNX2X_MSG_DCB, "START TRAFFIC\n"); return bnx2x_func_state_change(bp, &func_params); } @@ -588,7 +588,7 @@ static int bnx2x_dcbx_read_shmem_remote_mib(struct bnx2x *bp) u32 dcbx_remote_mib_offset = SHMEM2_RD(bp, dcbx_remote_mib_offset); int rc; - DP(NETIF_MSG_LINK, "dcbx_remote_mib_offset 0x%x\n", + DP(BNX2X_MSG_DCB, "dcbx_remote_mib_offset 0x%x\n", dcbx_remote_mib_offset); if (SHMEM_DCBX_REMOTE_MIB_NONE == dcbx_remote_mib_offset) { @@ -617,7 +617,7 @@ static int bnx2x_dcbx_read_shmem_neg_results(struct bnx2x *bp) u32 dcbx_neg_res_offset = SHMEM2_RD(bp, dcbx_neg_res_offset); int rc; - DP(NETIF_MSG_LINK, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset); + DP(BNX2X_MSG_DCB, "dcbx_neg_res_offset 0x%x\n", dcbx_neg_res_offset); if (SHMEM_DCBX_NEG_RES_NONE == dcbx_neg_res_offset) { BNX2X_ERR("FW doesn't support dcbx_neg_res_offset\n"); @@ -693,7 +693,7 @@ static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp) if (bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask & (1 << prio)) { bp->prio_to_cos[prio] = cos; - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "tx_mapping %d --> %d\n", prio, cos); } } @@ -712,7 +712,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) switch (state) { case BNX2X_DCBX_STATE_NEG_RECEIVED: { - DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_NEG_RECEIVED\n"); + DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_NEG_RECEIVED\n"); #ifdef BCM_DCBNL /** * Delete app tlvs from dcbnl before reading new @@ -762,7 +762,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) return; } case BNX2X_DCBX_STATE_TX_PAUSED: - DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_PAUSED\n"); + DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_TX_PAUSED\n"); bnx2x_pfc_set_pfc(bp); bnx2x_dcbx_update_ets_params(bp); @@ -770,7 +770,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) return; case BNX2X_DCBX_STATE_TX_RELEASED: - DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); + DP(BNX2X_MSG_DCB, "BNX2X_DCBX_STATE_TX_RELEASED\n"); bnx2x_fw_command(bp, DRV_MSG_CODE_DCBX_PMF_DRV_OK, 0); #ifdef BCM_DCBNL /* @@ -861,7 +861,7 @@ static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, DCBX_PG_BW_SET(af->ets.pg_bw_tbl, i, (u8)dp->admin_configuration_bw_precentage[i]); - DP(NETIF_MSG_LINK, "pg_bw_tbl[%d] = %02x\n", + DP(BNX2X_MSG_DCB, "pg_bw_tbl[%d] = %02x\n", i, DCBX_PG_BW_GET(af->ets.pg_bw_tbl, i)); } @@ -869,7 +869,7 @@ static void bnx2x_dcbx_admin_mib_updated_params(struct bnx2x *bp, DCBX_PRI_PG_SET(af->ets.pri_pg_tbl, i, (u8)dp->admin_configuration_ets_pg[i]); - DP(NETIF_MSG_LINK, "pri_pg_tbl[%d] = %02x\n", + DP(BNX2X_MSG_DCB, "pri_pg_tbl[%d] = %02x\n", i, DCBX_PRI_PG_GET(af->ets.pri_pg_tbl, i)); } @@ -923,7 +923,7 @@ void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled) bp->dcb_state = false; bp->dcbx_enabled = BNX2X_DCBX_ENABLED_INVALID; } - DP(NETIF_MSG_LINK, "DCB state [%s:%s]\n", + DP(BNX2X_MSG_DCB, "DCB state [%s:%s]\n", dcb_on ? "ON" : "OFF", dcbx_enabled == BNX2X_DCBX_ENABLED_OFF ? "user-mode" : dcbx_enabled == BNX2X_DCBX_ENABLED_ON_NEG_OFF ? "on-chip static" : @@ -1011,7 +1011,7 @@ void bnx2x_dcbx_init(struct bnx2x *bp) * the function is pmf * shmem2 contains DCBX support fields */ - DP(NETIF_MSG_LINK, "dcb_state %d bp->port.pmf %d\n", + DP(BNX2X_MSG_DCB, "dcb_state %d bp->port.pmf %d\n", bp->dcb_state, bp->port.pmf); if (bp->dcb_state == BNX2X_DCB_STATE_ON && bp->port.pmf && @@ -1019,7 +1019,7 @@ void bnx2x_dcbx_init(struct bnx2x *bp) dcbx_lldp_params_offset = SHMEM2_RD(bp, dcbx_lldp_params_offset); - DP(NETIF_MSG_LINK, "dcbx_lldp_params_offset 0x%x\n", + DP(BNX2X_MSG_DCB, "dcbx_lldp_params_offset 0x%x\n", dcbx_lldp_params_offset); bnx2x_update_drv_flags(bp, 1 << DRV_FLAGS_DCB_CONFIGURED, 0); @@ -1041,38 +1041,36 @@ bnx2x_dcbx_print_cos_params(struct bnx2x *bp, u8 pri = 0; u8 cos = 0; - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "pfc_fw_cfg->dcb_version %x\n", pfc_fw_cfg->dcb_version); - DP(NETIF_MSG_LINK, - "pdev->params.dcbx_port_params.pfc." - "priority_non_pauseable_mask %x\n", + DP(BNX2X_MSG_DCB, + "pdev->params.dcbx_port_params.pfc.priority_non_pauseable_mask %x\n", bp->dcbx_port_params.pfc.priority_non_pauseable_mask); for (cos = 0 ; cos < bp->dcbx_port_params.ets.num_of_cos ; cos++) { - DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." - "cos_params[%d].pri_bitmask %x\n", cos, - bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask); + DP(BNX2X_MSG_DCB, + "pdev->params.dcbx_port_params.ets.cos_params[%d].pri_bitmask %x\n", + cos, bp->dcbx_port_params.ets.cos_params[cos].pri_bitmask); - DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." - "cos_params[%d].bw_tbl %x\n", cos, - bp->dcbx_port_params.ets.cos_params[cos].bw_tbl); + DP(BNX2X_MSG_DCB, + "pdev->params.dcbx_port_params.ets.cos_params[%d].bw_tbl %x\n", + cos, bp->dcbx_port_params.ets.cos_params[cos].bw_tbl); - DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." - "cos_params[%d].strict %x\n", cos, - bp->dcbx_port_params.ets.cos_params[cos].strict); + DP(BNX2X_MSG_DCB, + "pdev->params.dcbx_port_params.ets.cos_params[%d].strict %x\n", + cos, bp->dcbx_port_params.ets.cos_params[cos].strict); - DP(NETIF_MSG_LINK, "pdev->params.dcbx_port_params.ets." - "cos_params[%d].pauseable %x\n", cos, - bp->dcbx_port_params.ets.cos_params[cos].pauseable); + DP(BNX2X_MSG_DCB, + "pdev->params.dcbx_port_params.ets.cos_params[%d].pauseable %x\n", + cos, bp->dcbx_port_params.ets.cos_params[cos].pauseable); } for (pri = 0; pri < LLFC_DRIVER_TRAFFIC_TYPE_MAX; pri++) { - DP(NETIF_MSG_LINK, - "pfc_fw_cfg->traffic_type_to_priority_cos[%d]." - "priority %x\n", pri, - pfc_fw_cfg->traffic_type_to_priority_cos[pri].priority); + DP(BNX2X_MSG_DCB, + "pfc_fw_cfg->traffic_type_to_priority_cos[%d].priority %x\n", + pri, pfc_fw_cfg->traffic_type_to_priority_cos[pri].priority); - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "pfc_fw_cfg->traffic_type_to_priority_cos[%d].cos %x\n", pri, pfc_fw_cfg->traffic_type_to_priority_cos[pri].cos); } @@ -1119,7 +1117,7 @@ static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x *bp, help_data->num_of_pg++; } } - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_DCB, "add_traf_type %d pg_found %s num_of_pg %d\n", add_traf_type, (false == pg_found) ? "NO" : "YES", help_data->num_of_pg); @@ -1312,8 +1310,7 @@ static void bnx2x_dcbx_2cos_limit_cee_single_pg_to_cos_params(struct bnx2x *bp, } if (i == LLFC_DRIVER_TRAFFIC_TYPE_MAX) - BNX2X_ERR("Invalid value for pri_join_mask -" - " could not find a priority\n"); + BNX2X_ERR("Invalid value for pri_join_mask - could not find a priority\n"); cos_data->data[0].pri_join_mask = pri_mask_without_pri; cos_data->data[1].pri_join_mask = pri_tested; @@ -1626,8 +1623,10 @@ static int bnx2x_dcbx_spread_strict_pri(struct bnx2x *bp, num_of_app_pri--; } - if (num_spread_of_entries) + if (num_spread_of_entries) { + BNX2X_ERR("Didn't succeed to spread strict priorities\n"); return -EINVAL; + } return 0; } @@ -1675,8 +1674,7 @@ static void bnx2x_dcbx_cee_fill_cos_params(struct bnx2x *bp, if (help_data->num_of_pg > DCBX_COS_MAX_NUM_E3B0) { if (bnx2x_dcbx_join_pgs(bp, ets, help_data, DCBX_COS_MAX_NUM_E3B0)) { - BNX2X_ERR("Unable to reduce the number of PGs -" - "we will disables ETS\n"); + BNX2X_ERR("Unable to reduce the number of PGs - we will disables ETS\n"); bnx2x_dcbx_ets_disabled_entry_data(bp, cos_data, pri_join_mask); return; @@ -1776,24 +1774,24 @@ static void bnx2x_dcbx_fill_cos_params(struct bnx2x *bp, if (p->pauseable && DCBX_PFC_PRI_GET_NON_PAUSE(bp, p->pri_bitmask) != 0) - BNX2X_ERR("Inconsistent config for " - "pausable COS %d\n", i); + BNX2X_ERR("Inconsistent config for pausable COS %d\n", + i); if (!p->pauseable && DCBX_PFC_PRI_GET_PAUSE(bp, p->pri_bitmask) != 0) - BNX2X_ERR("Inconsistent config for " - "nonpausable COS %d\n", i); + BNX2X_ERR("Inconsistent config for nonpausable COS %d\n", + i); } } if (p->pauseable) - DP(NETIF_MSG_LINK, "COS %d PAUSABLE prijoinmask 0x%x\n", + DP(BNX2X_MSG_DCB, "COS %d PAUSABLE prijoinmask 0x%x\n", i, cos_data.data[i].pri_join_mask); else - DP(NETIF_MSG_LINK, "COS %d NONPAUSABLE prijoinmask " - "0x%x\n", - i, cos_data.data[i].pri_join_mask); + DP(BNX2X_MSG_DCB, + "COS %d NONPAUSABLE prijoinmask 0x%x\n", + i, cos_data.data[i].pri_join_mask); } bp->dcbx_port_params.ets.num_of_cos = cos_data.num_of_cos ; @@ -1808,7 +1806,7 @@ static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp, for (i = 0; i < DCBX_MAX_NUM_PRI_PG_ENTRIES; i++) { set_configuration_ets_pg[i] = DCBX_PRI_PG_GET(pri_pg_tbl, i); - DP(NETIF_MSG_LINK, "set_configuration_ets_pg[%d] = 0x%x\n", + DP(BNX2X_MSG_DCB, "set_configuration_ets_pg[%d] = 0x%x\n", i, set_configuration_ets_pg[i]); } } @@ -1904,14 +1902,14 @@ static inline bool bnx2x_dcbnl_set_valid(struct bnx2x *bp) static u8 bnx2x_dcbnl_get_state(struct net_device *netdev) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "state = %d\n", bp->dcb_state); + DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcb_state); return bp->dcb_state; } static u8 bnx2x_dcbnl_set_state(struct net_device *netdev, u8 state) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "state = %s\n", state ? "on" : "off"); + DP(BNX2X_MSG_DCB, "state = %s\n", state ? "on" : "off"); bnx2x_dcbx_set_state(bp, (state ? true : false), bp->dcbx_enabled); return 0; @@ -1921,7 +1919,7 @@ static void bnx2x_dcbnl_get_perm_hw_addr(struct net_device *netdev, u8 *perm_addr) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "GET-PERM-ADDR\n"); + DP(BNX2X_MSG_DCB, "GET-PERM-ADDR\n"); /* first the HW mac address */ memcpy(perm_addr, netdev->dev_addr, netdev->addr_len); @@ -1938,7 +1936,7 @@ static void bnx2x_dcbnl_set_pg_tccfg_tx(struct net_device *netdev, int prio, { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "prio[%d] = %d\n", prio, pgid); + DP(BNX2X_MSG_DCB, "prio[%d] = %d\n", prio, pgid); if (!bnx2x_dcbnl_set_valid(bp) || prio >= DCBX_MAX_NUM_PRI_PG_ENTRIES) return; @@ -1963,7 +1961,7 @@ static void bnx2x_dcbnl_set_pg_bwgcfg_tx(struct net_device *netdev, int pgid, u8 bw_pct) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "pgid[%d] = %d\n", pgid, bw_pct); + DP(BNX2X_MSG_DCB, "pgid[%d] = %d\n", pgid, bw_pct); if (!bnx2x_dcbnl_set_valid(bp) || pgid >= DCBX_MAX_NUM_PG_BW_ENTRIES) return; @@ -1977,14 +1975,14 @@ static void bnx2x_dcbnl_set_pg_tccfg_rx(struct net_device *netdev, int prio, u8 up_map) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "Nothing to set; No RX support\n"); + DP(BNX2X_MSG_DCB, "Nothing to set; No RX support\n"); } static void bnx2x_dcbnl_set_pg_bwgcfg_rx(struct net_device *netdev, int pgid, u8 bw_pct) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "Nothing to set; No RX support\n"); + DP(BNX2X_MSG_DCB, "Nothing to set; No RX support\n"); } static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device *netdev, int prio, @@ -1992,7 +1990,7 @@ static void bnx2x_dcbnl_get_pg_tccfg_tx(struct net_device *netdev, int prio, u8 *up_map) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "prio = %d\n", prio); + DP(BNX2X_MSG_DCB, "prio = %d\n", prio); /** * bw_pct ingnored - band-width percentage devision between user @@ -2018,7 +2016,7 @@ static void bnx2x_dcbnl_get_pg_bwgcfg_tx(struct net_device *netdev, int pgid, u8 *bw_pct) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "pgid = %d\n", pgid); + DP(BNX2X_MSG_DCB, "pgid = %d\n", pgid); *bw_pct = 0; @@ -2033,7 +2031,7 @@ static void bnx2x_dcbnl_get_pg_tccfg_rx(struct net_device *netdev, int prio, u8 *up_map) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "Nothing to get; No RX support\n"); + DP(BNX2X_MSG_DCB, "Nothing to get; No RX support\n"); *prio_type = *pgid = *bw_pct = *up_map = 0; } @@ -2042,7 +2040,7 @@ static void bnx2x_dcbnl_get_pg_bwgcfg_rx(struct net_device *netdev, int pgid, u8 *bw_pct) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "Nothing to get; No RX support\n"); + DP(BNX2X_MSG_DCB, "Nothing to get; No RX support\n"); *bw_pct = 0; } @@ -2051,7 +2049,7 @@ static void bnx2x_dcbnl_set_pfc_cfg(struct net_device *netdev, int prio, u8 setting) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "prio[%d] = %d\n", prio, setting); + DP(BNX2X_MSG_DCB, "prio[%d] = %d\n", prio, setting); if (!bnx2x_dcbnl_set_valid(bp) || prio >= MAX_PFC_PRIORITIES) return; @@ -2066,7 +2064,7 @@ static void bnx2x_dcbnl_get_pfc_cfg(struct net_device *netdev, int prio, u8 *setting) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "prio = %d\n", prio); + DP(BNX2X_MSG_DCB, "prio = %d\n", prio); *setting = 0; @@ -2081,21 +2079,21 @@ static u8 bnx2x_dcbnl_set_all(struct net_device *netdev) struct bnx2x *bp = netdev_priv(netdev); int rc = 0; - DP(NETIF_MSG_LINK, "SET-ALL\n"); + DP(BNX2X_MSG_DCB, "SET-ALL\n"); if (!bnx2x_dcbnl_set_valid(bp)) return 1; if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - netdev_err(bp->dev, "Handling parity error recovery. " - "Try again later\n"); + netdev_err(bp->dev, + "Handling parity error recovery. Try again later\n"); return 1; } if (netif_running(bp->dev)) { bnx2x_nic_unload(bp, UNLOAD_NORMAL); rc = bnx2x_nic_load(bp, LOAD_NORMAL); } - DP(NETIF_MSG_LINK, "set_dcbx_params done (%d)\n", rc); + DP(BNX2X_MSG_DCB, "set_dcbx_params done (%d)\n", rc); if (rc) return 1; @@ -2134,13 +2132,16 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap) *cap = BNX2X_DCBX_CAPS; break; default: + BNX2X_ERR("Non valid capability ID\n"); rval = -EINVAL; break; } - } else + } else { + DP(BNX2X_MSG_DCB, "DCB disabled\n"); rval = -EINVAL; + } - DP(NETIF_MSG_LINK, "capid %d:%x\n", capid, *cap); + DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap); return rval; } @@ -2149,7 +2150,7 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num) struct bnx2x *bp = netdev_priv(netdev); u8 rval = 0; - DP(NETIF_MSG_LINK, "tcid %d\n", tcid); + DP(BNX2X_MSG_DCB, "tcid %d\n", tcid); if (bp->dcb_state) { switch (tcid) { @@ -2162,11 +2163,14 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num) DCBX_COS_MAX_NUM_E2; break; default: + BNX2X_ERR("Non valid TC-ID\n"); rval = -EINVAL; break; } - } else + } else { + DP(BNX2X_MSG_DCB, "DCB disabled\n"); rval = -EINVAL; + } return rval; } @@ -2174,14 +2178,14 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num) static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "num tcs = %d; Not supported\n", num); + DP(BNX2X_MSG_DCB, "num tcs = %d; Not supported\n", num); return -EINVAL; } static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "state = %d\n", bp->dcbx_local_feat.pfc.enabled); + DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled); if (!bp->dcb_state) return 0; @@ -2192,7 +2196,7 @@ static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev) static void bnx2x_dcbnl_set_pfc_state(struct net_device *netdev, u8 state) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "state = %s\n", state ? "on" : "off"); + DP(BNX2X_MSG_DCB, "state = %s\n", state ? "on" : "off"); if (!bnx2x_dcbnl_set_valid(bp)) return; @@ -2269,9 +2273,11 @@ static int bnx2x_set_admin_app_up(struct bnx2x *bp, u8 idtype, u16 idval, u8 up) bnx2x_admin_app_set_ent( &bp->dcbx_config_params.admin_priority_app_table[ff], idtype, idval, up); - else + else { /* app table is full */ + BNX2X_ERR("Application table is too large\n"); return -EBUSY; + } /* up configured, if not 0 make sure feature is enabled */ if (up) @@ -2285,11 +2291,13 @@ static u8 bnx2x_dcbnl_set_app_up(struct net_device *netdev, u8 idtype, { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "app_type %d, app_id %x, prio bitmap %d\n", + DP(BNX2X_MSG_DCB, "app_type %d, app_id %x, prio bitmap %d\n", idtype, idval, up); - if (!bnx2x_dcbnl_set_valid(bp)) + if (!bnx2x_dcbnl_set_valid(bp)) { + DP(BNX2X_MSG_DCB, "dcbnl call not valid\n"); return -EINVAL; + } /* verify idtype */ switch (idtype) { @@ -2297,6 +2305,7 @@ static u8 bnx2x_dcbnl_set_app_up(struct net_device *netdev, u8 idtype, case DCB_APP_IDTYPE_PORTNUM: break; default: + DP(BNX2X_MSG_DCB, "Wrong ID type\n"); return -EINVAL; } return bnx2x_set_admin_app_up(bp, idtype, idval, up); @@ -2318,13 +2327,13 @@ static u8 bnx2x_dcbnl_get_dcbx(struct net_device *netdev) static u8 bnx2x_dcbnl_set_dcbx(struct net_device *netdev, u8 state) { struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "state = %02x\n", state); + DP(BNX2X_MSG_DCB, "state = %02x\n", state); /* set dcbx mode */ if ((state & BNX2X_DCBX_CAPS) != state) { - BNX2X_ERR("Requested DCBX mode %x is beyond advertised " - "capabilities\n", state); + BNX2X_ERR("Requested DCBX mode %x is beyond advertised capabilities\n", + state); return 1; } @@ -2348,7 +2357,7 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid, struct bnx2x *bp = netdev_priv(netdev); u8 rval = 0; - DP(NETIF_MSG_LINK, "featid %d\n", featid); + DP(BNX2X_MSG_DCB, "featid %d\n", featid); if (bp->dcb_state) { *flags = 0; @@ -2374,11 +2383,14 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid, *flags |= DCB_FEATCFG_ERROR; break; default: + BNX2X_ERR("Non valid featrue-ID\n"); rval = -EINVAL; break; } - } else + } else { + DP(BNX2X_MSG_DCB, "DCB disabled\n"); rval = -EINVAL; + } return rval; } @@ -2389,7 +2401,7 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid, struct bnx2x *bp = netdev_priv(netdev); u8 rval = 0; - DP(NETIF_MSG_LINK, "featid = %d flags = %02x\n", featid, flags); + DP(BNX2X_MSG_DCB, "featid = %d flags = %02x\n", featid, flags); /* ignore the 'advertise' flag */ if (bnx2x_dcbnl_set_valid(bp)) { @@ -2412,11 +2424,14 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid, flags & DCB_FEATCFG_WILLING ? 1 : 0; break; default: + BNX2X_ERR("Non valid featrue-ID\n"); rval = -EINVAL; break; } - } else + } else { + DP(BNX2X_MSG_DCB, "dcbnl call not valid\n"); rval = -EINVAL; + } return rval; } @@ -2427,7 +2442,7 @@ static int bnx2x_peer_appinfo(struct net_device *netdev, int i; struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "APP-INFO\n"); + DP(BNX2X_MSG_DCB, "APP-INFO\n"); info->willing = (bp->dcbx_remote_flags & DCBX_APP_REM_WILLING) ?: 0; info->error = (bp->dcbx_remote_flags & DCBX_APP_RX_ERROR) ?: 0; @@ -2446,7 +2461,7 @@ static int bnx2x_peer_apptable(struct net_device *netdev, int i, j; struct bnx2x *bp = netdev_priv(netdev); - DP(NETIF_MSG_LINK, "APP-TABLE\n"); + DP(BNX2X_MSG_DCB, "APP-TABLE\n"); for (i = 0, j = 0; i < DCBX_MAX_APP_PROTOCOL; i++) { struct dcbx_app_priority_entry *ent = diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 858d1b5433de..3618a00a8144 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -280,7 +280,7 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) cmd->maxtxpkt = 0; cmd->maxrxpkt = 0; - DP(NETIF_MSG_LINK, "ethtool_cmd: cmd %d\n" + DP(BNX2X_MSG_ETHTOOL, "ethtool_cmd: cmd %d\n" " supported 0x%x advertising 0x%x speed %u\n" " duplex %d port %d phy_address %d transceiver %d\n" " autoneg %d maxtxpkt %d maxrxpkt %d\n", @@ -301,7 +301,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (IS_MF_SD(bp)) return 0; - DP(NETIF_MSG_LINK, "ethtool_cmd: cmd %d\n" + DP(BNX2X_MSG_ETHTOOL, "ethtool_cmd: cmd %d\n" " supported 0x%x advertising 0x%x speed %u\n" " duplex %d port %d phy_address %d transceiver %d\n" " autoneg %d maxtxpkt %d maxrxpkt %d\n", @@ -325,18 +325,17 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) line_speed = 10000; if (bp->common.bc_ver < REQ_BC_VER_4_SET_MF_BW) { - BNX2X_DEV_INFO("To set speed BC %X or higher " - "is required, please upgrade BC\n", - REQ_BC_VER_4_SET_MF_BW); + DP(BNX2X_MSG_ETHTOOL, + "To set speed BC %X or higher is required, please upgrade BC\n", + REQ_BC_VER_4_SET_MF_BW); return -EINVAL; } part = (speed * 100) / line_speed; if (line_speed < speed || !part) { - BNX2X_DEV_INFO("Speed setting should be in a range " - "from 1%% to 100%% " - "of actual line speed\n"); + DP(BNX2X_MSG_ETHTOOL, + "Speed setting should be in a range from 1%% to 100%% of actual line speed\n"); return -EINVAL; } @@ -358,7 +357,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (!(bp->port.supported[0] & SUPPORTED_TP || bp->port.supported[1] & SUPPORTED_TP)) { - DP(NETIF_MSG_LINK, "Unsupported port type\n"); + DP(BNX2X_MSG_ETHTOOL, "Unsupported port type\n"); return -EINVAL; } bp->link_params.multi_phy_config &= @@ -378,7 +377,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (!(bp->port.supported[0] & SUPPORTED_FIBRE || bp->port.supported[1] & SUPPORTED_FIBRE)) { - DP(NETIF_MSG_LINK, "Unsupported port type\n"); + DP(BNX2X_MSG_ETHTOOL, "Unsupported port type\n"); return -EINVAL; } bp->link_params.multi_phy_config &= @@ -392,7 +391,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) PORT_HW_CFG_PHY_SELECTION_SECOND_PHY; break; default: - DP(NETIF_MSG_LINK, "Unsupported port type\n"); + DP(BNX2X_MSG_ETHTOOL, "Unsupported port type\n"); return -EINVAL; } /* Save new config in case command complete successully */ @@ -401,7 +400,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) cfg_idx = bnx2x_get_link_cfg_idx(bp); /* Restore old config in case command failed */ bp->link_params.multi_phy_config = old_multi_phy_config; - DP(NETIF_MSG_LINK, "cfg_idx = %x\n", cfg_idx); + DP(BNX2X_MSG_ETHTOOL, "cfg_idx = %x\n", cfg_idx); if (cmd->autoneg == AUTONEG_ENABLE) { u32 an_supported_speed = bp->port.supported[cfg_idx]; @@ -410,14 +409,14 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) an_supported_speed |= (SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full); if (!(bp->port.supported[cfg_idx] & SUPPORTED_Autoneg)) { - DP(NETIF_MSG_LINK, "Autoneg not supported\n"); + DP(BNX2X_MSG_ETHTOOL, "Autoneg not supported\n"); return -EINVAL; } /* advertise the requested speed and duplex if supported */ if (cmd->advertising & ~an_supported_speed) { - DP(NETIF_MSG_LINK, "Advertisement parameters " - "are not supported\n"); + DP(BNX2X_MSG_ETHTOOL, + "Advertisement parameters are not supported\n"); return -EINVAL; } @@ -466,7 +465,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (cmd->duplex == DUPLEX_FULL) { if (!(bp->port.supported[cfg_idx] & SUPPORTED_10baseT_Full)) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "10M full not supported\n"); return -EINVAL; } @@ -476,7 +475,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) } else { if (!(bp->port.supported[cfg_idx] & SUPPORTED_10baseT_Half)) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "10M half not supported\n"); return -EINVAL; } @@ -490,7 +489,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) if (cmd->duplex == DUPLEX_FULL) { if (!(bp->port.supported[cfg_idx] & SUPPORTED_100baseT_Full)) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "100M full not supported\n"); return -EINVAL; } @@ -500,7 +499,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) } else { if (!(bp->port.supported[cfg_idx] & SUPPORTED_100baseT_Half)) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "100M half not supported\n"); return -EINVAL; } @@ -512,13 +511,15 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) case SPEED_1000: if (cmd->duplex != DUPLEX_FULL) { - DP(NETIF_MSG_LINK, "1G half not supported\n"); + DP(BNX2X_MSG_ETHTOOL, + "1G half not supported\n"); return -EINVAL; } if (!(bp->port.supported[cfg_idx] & SUPPORTED_1000baseT_Full)) { - DP(NETIF_MSG_LINK, "1G full not supported\n"); + DP(BNX2X_MSG_ETHTOOL, + "1G full not supported\n"); return -EINVAL; } @@ -528,14 +529,14 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) case SPEED_2500: if (cmd->duplex != DUPLEX_FULL) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "2.5G half not supported\n"); return -EINVAL; } if (!(bp->port.supported[cfg_idx] & SUPPORTED_2500baseX_Full)) { - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "2.5G full not supported\n"); return -EINVAL; } @@ -546,13 +547,15 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) case SPEED_10000: if (cmd->duplex != DUPLEX_FULL) { - DP(NETIF_MSG_LINK, "10G half not supported\n"); + DP(BNX2X_MSG_ETHTOOL, + "10G half not supported\n"); return -EINVAL; } if (!(bp->port.supported[cfg_idx] & SUPPORTED_10000baseT_Full)) { - DP(NETIF_MSG_LINK, "10G full not supported\n"); + DP(BNX2X_MSG_ETHTOOL, + "10G full not supported\n"); return -EINVAL; } @@ -561,7 +564,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) break; default: - DP(NETIF_MSG_LINK, "Unsupported speed %u\n", speed); + DP(BNX2X_MSG_ETHTOOL, "Unsupported speed %u\n", speed); return -EINVAL; } @@ -570,7 +573,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) bp->port.advertising[cfg_idx] = advertising; } - DP(NETIF_MSG_LINK, "req_line_speed %d\n" + DP(BNX2X_MSG_ETHTOOL, "req_line_speed %d\n" " req_duplex %d advertising 0x%x\n", bp->link_params.req_line_speed[cfg_idx], bp->link_params.req_duplex[cfg_idx], @@ -850,13 +853,16 @@ static int bnx2x_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct bnx2x *bp = netdev_priv(dev); - if (wol->wolopts & ~WAKE_MAGIC) + if (wol->wolopts & ~WAKE_MAGIC) { + DP(BNX2X_MSG_ETHTOOL, "WOL not supproted\n"); return -EINVAL; + } if (wol->wolopts & WAKE_MAGIC) { - if (bp->flags & NO_WOL_FLAG) + if (bp->flags & NO_WOL_FLAG) { + DP(BNX2X_MSG_ETHTOOL, "WOL not supproted\n"); return -EINVAL; - + } bp->wol = 1; } else bp->wol = 0; @@ -955,7 +961,8 @@ static int bnx2x_acquire_nvram_lock(struct bnx2x *bp) } if (!(val & (MCPR_NVM_SW_ARB_ARB_ARB1 << port))) { - DP(BNX2X_MSG_NVM, "cannot get access to nvram interface\n"); + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot get access to nvram interface\n"); return -EBUSY; } @@ -986,7 +993,8 @@ static int bnx2x_release_nvram_lock(struct bnx2x *bp) } if (val & (MCPR_NVM_SW_ARB_ARB_ARB1 << port)) { - DP(BNX2X_MSG_NVM, "cannot free access to nvram interface\n"); + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot free access to nvram interface\n"); return -EBUSY; } @@ -1060,7 +1068,9 @@ static int bnx2x_nvram_read_dword(struct bnx2x *bp, u32 offset, __be32 *ret_val, break; } } - + if (rc == -EBUSY) + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "nvram read timeout expired\n"); return rc; } @@ -1072,15 +1082,15 @@ static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf, __be32 val; if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) { - DP(BNX2X_MSG_NVM, + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, "Invalid parameter: offset 0x%x buf_size 0x%x\n", offset, buf_size); return -EINVAL; } if (offset + buf_size > bp->common.flash_size) { - DP(BNX2X_MSG_NVM, "Invalid parameter: offset (0x%x) +" - " buf_size (0x%x) > flash_size (0x%x)\n", + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "Invalid parameter: offset (0x%x) + buf_size (0x%x) > flash_size (0x%x)\n", offset, buf_size, bp->common.flash_size); return -EINVAL; } @@ -1125,10 +1135,13 @@ static int bnx2x_get_eeprom(struct net_device *dev, struct bnx2x *bp = netdev_priv(dev); int rc; - if (!netif_running(dev)) + if (!netif_running(dev)) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot access eeprom when the interface is down\n"); return -EAGAIN; + } - DP(BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n" + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n" " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n", eeprom->cmd, eeprom->magic, eeprom->offset, eeprom->offset, eeprom->len, eeprom->len); @@ -1177,6 +1190,9 @@ static int bnx2x_nvram_write_dword(struct bnx2x *bp, u32 offset, u32 val, } } + if (rc == -EBUSY) + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "nvram write timeout expired\n"); return rc; } @@ -1191,8 +1207,8 @@ static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, __be32 val; if (offset + buf_size > bp->common.flash_size) { - DP(BNX2X_MSG_NVM, "Invalid parameter: offset (0x%x) +" - " buf_size (0x%x) > flash_size (0x%x)\n", + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "Invalid parameter: offset (0x%x) + buf_size (0x%x) > flash_size (0x%x)\n", offset, buf_size, bp->common.flash_size); return -EINVAL; } @@ -1240,15 +1256,15 @@ static int bnx2x_nvram_write(struct bnx2x *bp, u32 offset, u8 *data_buf, return bnx2x_nvram_write1(bp, offset, data_buf, buf_size); if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) { - DP(BNX2X_MSG_NVM, + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, "Invalid parameter: offset 0x%x buf_size 0x%x\n", offset, buf_size); return -EINVAL; } if (offset + buf_size > bp->common.flash_size) { - DP(BNX2X_MSG_NVM, "Invalid parameter: offset (0x%x) +" - " buf_size (0x%x) > flash_size (0x%x)\n", + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "Invalid parameter: offset (0x%x) + buf_size (0x%x) > flash_size (0x%x)\n", offset, buf_size, bp->common.flash_size); return -EINVAL; } @@ -1296,10 +1312,13 @@ static int bnx2x_set_eeprom(struct net_device *dev, int port = BP_PORT(bp); int rc = 0; u32 ext_phy_config; - if (!netif_running(dev)) + if (!netif_running(dev)) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot access eeprom when the interface is down\n"); return -EAGAIN; + } - DP(BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n" + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n" " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n", eeprom->cmd, eeprom->magic, eeprom->offset, eeprom->offset, eeprom->len, eeprom->len); @@ -1308,8 +1327,11 @@ static int bnx2x_set_eeprom(struct net_device *dev, /* PHY eeprom can be accessed only by the PMF */ if ((eeprom->magic >= 0x50485900) && (eeprom->magic <= 0x504859FF) && - !bp->port.pmf) + !bp->port.pmf) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "wrong magic or interface is not pmf\n"); return -EINVAL; + } ext_phy_config = SHMEM_RD(bp, @@ -1421,8 +1443,8 @@ static int bnx2x_set_ringparam(struct net_device *dev, struct bnx2x *bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - netdev_err(dev, "Handling parity error recovery. " - "Try again later\n"); + DP(BNX2X_MSG_ETHTOOL, + "Handling parity error recovery. Try again later\n"); return -EAGAIN; } @@ -1430,8 +1452,10 @@ static int bnx2x_set_ringparam(struct net_device *dev, (ering->rx_pending < (bp->disable_tpa ? MIN_RX_SIZE_NONTPA : MIN_RX_SIZE_TPA)) || (ering->tx_pending > MAX_TX_AVAIL) || - (ering->tx_pending <= MAX_SKB_FRAGS + 4)) + (ering->tx_pending <= MAX_SKB_FRAGS + 4)) { + DP(BNX2X_MSG_ETHTOOL, "Command parameters not supported\n"); return -EINVAL; + } bp->rx_ring_size = ering->rx_pending; bp->tx_ring_size = ering->tx_pending; @@ -1459,7 +1483,7 @@ static void bnx2x_get_pauseparam(struct net_device *dev, epause->tx_pause = ((cfg_reg & BNX2X_FLOW_CTRL_TX) == BNX2X_FLOW_CTRL_TX); - DP(NETIF_MSG_LINK, "ethtool_pauseparam: cmd %d\n" + DP(BNX2X_MSG_ETHTOOL, "ethtool_pauseparam: cmd %d\n" " autoneg %d rx_pause %d tx_pause %d\n", epause->cmd, epause->autoneg, epause->rx_pause, epause->tx_pause); } @@ -1472,7 +1496,7 @@ static int bnx2x_set_pauseparam(struct net_device *dev, if (IS_MF(bp)) return 0; - DP(NETIF_MSG_LINK, "ethtool_pauseparam: cmd %d\n" + DP(BNX2X_MSG_ETHTOOL, "ethtool_pauseparam: cmd %d\n" " autoneg %d rx_pause %d tx_pause %d\n", epause->cmd, epause->autoneg, epause->rx_pause, epause->tx_pause); @@ -1489,7 +1513,7 @@ static int bnx2x_set_pauseparam(struct net_device *dev, if (epause->autoneg) { if (!(bp->port.supported[cfg_idx] & SUPPORTED_Autoneg)) { - DP(NETIF_MSG_LINK, "autoneg not supported\n"); + DP(BNX2X_MSG_ETHTOOL, "autoneg not supported\n"); return -EINVAL; } @@ -1499,7 +1523,7 @@ static int bnx2x_set_pauseparam(struct net_device *dev, } } - DP(NETIF_MSG_LINK, + DP(BNX2X_MSG_ETHTOOL, "req_flow_ctrl 0x%x\n", bp->link_params.req_flow_ctrl[cfg_idx]); if (netif_running(dev)) { @@ -1631,8 +1655,11 @@ static int bnx2x_test_registers(struct bnx2x *bp) { BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 } }; - if (!netif_running(bp->dev)) + if (!netif_running(bp->dev)) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot access eeprom when the interface is down\n"); return rc; + } if (CHIP_IS_E1(bp)) hw = BNX2X_CHIP_MASK_E1; @@ -1677,7 +1704,7 @@ static int bnx2x_test_registers(struct bnx2x *bp) /* verify value is as expected */ if ((val & mask) != (wr_val & mask)) { - DP(NETIF_MSG_HW, + DP(BNX2X_MSG_ETHTOOL, "offset 0x%x: val 0x%x != 0x%x mask 0x%x\n", offset, val, wr_val, mask); goto test_reg_exit; @@ -1731,8 +1758,11 @@ static int bnx2x_test_memory(struct bnx2x *bp) { NULL, 0xffffffff, {0, 0, 0, 0} } }; - if (!netif_running(bp->dev)) + if (!netif_running(bp->dev)) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot access eeprom when the interface is down\n"); return rc; + } if (CHIP_IS_E1(bp)) index = BNX2X_CHIP_E1_OFST; @@ -1747,7 +1777,7 @@ static int bnx2x_test_memory(struct bnx2x *bp) for (i = 0; prty_tbl[i].offset != 0xffffffff; i++) { val = REG_RD(bp, prty_tbl[i].offset); if (val & ~(prty_tbl[i].hw_mask[index])) { - DP(NETIF_MSG_HW, + DP(BNX2X_MSG_ETHTOOL, "%s is 0x%x\n", prty_tbl[i].name, val); goto test_mem_exit; } @@ -1762,7 +1792,7 @@ static int bnx2x_test_memory(struct bnx2x *bp) for (i = 0; prty_tbl[i].offset != 0xffffffff; i++) { val = REG_RD(bp, prty_tbl[i].offset); if (val & ~(prty_tbl[i].hw_mask[index])) { - DP(NETIF_MSG_HW, + DP(BNX2X_MSG_ETHTOOL, "%s is 0x%x\n", prty_tbl[i].name, val); goto test_mem_exit; } @@ -1783,7 +1813,7 @@ static void bnx2x_wait_for_link(struct bnx2x *bp, u8 link_up, u8 is_serdes) msleep(20); if (cnt <= 0 && bnx2x_link_test(bp, is_serdes)) - DP(NETIF_MSG_LINK, "Timeout waiting for link up\n"); + DP(BNX2X_MSG_ETHTOOL, "Timeout waiting for link up\n"); } } @@ -1833,6 +1863,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) bnx2x_phy_init(&bp->link_params, &bp->link_vars); break; default: + DP(BNX2X_MSG_ETHTOOL, "Command parameters not supported\n"); return -EINVAL; } @@ -1841,6 +1872,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) bp->dev->mtu : ETH_MAX_PACKET_SIZE) + ETH_HLEN); skb = netdev_alloc_skb(bp->dev, fp_rx->rx_buf_size); if (!skb) { + DP(BNX2X_MSG_ETHTOOL, "Can't allocate skb\n"); rc = -ENOMEM; goto test_loopback_exit; } @@ -1855,7 +1887,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode) if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { rc = -ENOMEM; dev_kfree_skb(skb); - BNX2X_ERR("Unable to map SKB\n"); + DP(BNX2X_MSG_ETHTOOL, "Unable to map SKB\n"); goto test_loopback_exit; } @@ -1985,13 +2017,13 @@ static int bnx2x_test_loopback(struct bnx2x *bp) res = bnx2x_run_loopback(bp, BNX2X_PHY_LOOPBACK); if (res) { - DP(NETIF_MSG_PROBE, " PHY loopback failed (res %d)\n", res); + DP(BNX2X_MSG_ETHTOOL, " PHY loopback failed (res %d)\n", res); rc |= BNX2X_PHY_LOOPBACK_FAILED; } res = bnx2x_run_loopback(bp, BNX2X_MAC_LOOPBACK); if (res) { - DP(NETIF_MSG_PROBE, " MAC loopback failed (res %d)\n", res); + DP(BNX2X_MSG_ETHTOOL, " MAC loopback failed (res %d)\n", res); rc |= BNX2X_MAC_LOOPBACK_FAILED; } @@ -2027,7 +2059,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) buf = kmalloc(0x350, GFP_KERNEL); if (!buf) { - DP(NETIF_MSG_PROBE, "kmalloc failed\n"); + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, "kmalloc failed\n"); rc = -ENOMEM; goto test_nvram_exit; } @@ -2035,13 +2067,15 @@ static int bnx2x_test_nvram(struct bnx2x *bp) rc = bnx2x_nvram_read(bp, 0, data, 4); if (rc) { - DP(NETIF_MSG_PROBE, "magic value read (rc %d)\n", rc); + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "magic value read (rc %d)\n", rc); goto test_nvram_exit; } magic = be32_to_cpu(buf[0]); if (magic != 0x669955aa) { - DP(NETIF_MSG_PROBE, "magic value (0x%08x)\n", magic); + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "wrong magic value (0x%08x)\n", magic); rc = -ENODEV; goto test_nvram_exit; } @@ -2051,15 +2085,15 @@ static int bnx2x_test_nvram(struct bnx2x *bp) rc = bnx2x_nvram_read(bp, nvram_tbl[i].offset, data, nvram_tbl[i].size); if (rc) { - DP(NETIF_MSG_PROBE, + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, "nvram_tbl[%d] read data (rc %d)\n", i, rc); goto test_nvram_exit; } crc = ether_crc_le(nvram_tbl[i].size, data); if (crc != CRC32_RESIDUAL) { - DP(NETIF_MSG_PROBE, - "nvram_tbl[%d] crc value (0x%08x)\n", i, crc); + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "nvram_tbl[%d] wrong crc value (0x%08x)\n", i, crc); rc = -ENODEV; goto test_nvram_exit; } @@ -2075,8 +2109,11 @@ static int bnx2x_test_intr(struct bnx2x *bp) { struct bnx2x_queue_state_params params = {0}; - if (!netif_running(bp->dev)) + if (!netif_running(bp->dev)) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot access eeprom when the interface is down\n"); return -ENODEV; + } params.q_obj = &bp->fp->q_obj; params.cmd = BNX2X_Q_CMD_EMPTY; @@ -2092,8 +2129,8 @@ static void bnx2x_self_test(struct net_device *dev, struct bnx2x *bp = netdev_priv(dev); u8 is_serdes; if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - netdev_err(bp->dev, "Handling parity error recovery. " - "Try again later\n"); + netdev_err(bp->dev, + "Handling parity error recovery. Try again later\n"); etest->flags |= ETH_TEST_FL_FAILED; return; } @@ -2306,11 +2343,16 @@ static int bnx2x_set_phys_id(struct net_device *dev, { struct bnx2x *bp = netdev_priv(dev); - if (!netif_running(dev)) + if (!netif_running(dev)) { + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, + "cannot access eeprom when the interface is down\n"); return -EAGAIN; + } - if (!bp->port.pmf) + if (!bp->port.pmf) { + DP(BNX2X_MSG_ETHTOOL, "Interface is not pmf\n"); return -EOPNOTSUPP; + } switch (state) { case ETHTOOL_ID_ACTIVE: @@ -2347,6 +2389,7 @@ static int bnx2x_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, return 0; default: + DP(BNX2X_MSG_ETHTOOL, "Command parameters not supported\n"); return -EOPNOTSUPP; } } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index a743a5fcb22c..5e5367aa5b4d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -375,9 +375,6 @@ void bnx2x_post_dmae(struct bnx2x *bp, struct dmae_command *dmae, int idx) cmd_offset = (DMAE_REG_CMD_MEM + sizeof(struct dmae_command) * idx); for (i = 0; i < (sizeof(struct dmae_command)/4); i++) { REG_WR(bp, cmd_offset + i*4, *(((u32 *)dmae) + i)); - - DP(BNX2X_MSG_OFF, "DMAE cmd[%d].%d (0x%08x) : 0x%08x\n", - idx, i, cmd_offset + i*4, *(((u32 *)dmae) + i)); } REG_WR(bp, dmae_reg_go_c[idx], 1); } @@ -442,10 +439,6 @@ static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, int cnt = CHIP_REV_IS_SLOW(bp) ? (400000) : 4000; int rc = 0; - DP(BNX2X_MSG_OFF, "data before [0x%08x 0x%08x 0x%08x 0x%08x]\n", - bp->slowpath->wb_data[0], bp->slowpath->wb_data[1], - bp->slowpath->wb_data[2], bp->slowpath->wb_data[3]); - /* * Lock the dmae channel. Disable BHs to prevent a dead-lock * as long as this code is called both from syscall context and @@ -462,7 +455,6 @@ static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, /* wait for completion */ udelay(5); while ((*wb_comp & ~DMAE_PCI_ERR_FLAG) != DMAE_COMP_VAL) { - DP(BNX2X_MSG_OFF, "wb_comp 0x%08x\n", *wb_comp); if (!cnt || (bp->recovery_state != BNX2X_RECOVERY_DONE && @@ -479,10 +471,6 @@ static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp, rc = DMAE_PCI_ERROR; } - DP(BNX2X_MSG_OFF, "data after [0x%08x 0x%08x 0x%08x 0x%08x]\n", - bp->slowpath->wb_data[0], bp->slowpath->wb_data[1], - bp->slowpath->wb_data[2], bp->slowpath->wb_data[3]); - unlock: spin_unlock_bh(&bp->dmae_lock); return rc; @@ -496,9 +484,6 @@ void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr, if (!bp->dmae_ready) { u32 *data = bnx2x_sp(bp, wb_data[0]); - DP(BNX2X_MSG_OFF, - "DMAE is not ready (dst_addr %08x len32 %d) using indirect\n", - dst_addr, len32); if (CHIP_IS_E1(bp)) bnx2x_init_ind_wr(bp, dst_addr, data, len32); else @@ -530,13 +515,10 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32) u32 *data = bnx2x_sp(bp, wb_data[0]); int i; - if (CHIP_IS_E1(bp)) { - DP(BNX2X_MSG_OFF, - "DMAE is not ready (src_addr %08x len32 %d) using indirect\n", - src_addr, len32); + if (CHIP_IS_E1(bp)) for (i = 0; i < len32; i++) data[i] = bnx2x_reg_rd_ind(bp, src_addr + i*4); - } else + else for (i = 0; i < len32; i++) data[i] = REG_RD(bp, src_addr + i*4); @@ -621,8 +603,7 @@ static int bnx2x_mc_assert(struct bnx2x *bp) XSTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { - BNX2X_ERR("XSTORM_ASSERT_INDEX 0x%x = 0x%08x" - " 0x%08x 0x%08x 0x%08x\n", + BNX2X_ERR("XSTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { @@ -649,8 +630,7 @@ static int bnx2x_mc_assert(struct bnx2x *bp) TSTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { - BNX2X_ERR("TSTORM_ASSERT_INDEX 0x%x = 0x%08x" - " 0x%08x 0x%08x 0x%08x\n", + BNX2X_ERR("TSTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { @@ -677,8 +657,7 @@ static int bnx2x_mc_assert(struct bnx2x *bp) CSTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { - BNX2X_ERR("CSTORM_ASSERT_INDEX 0x%x = 0x%08x" - " 0x%08x 0x%08x 0x%08x\n", + BNX2X_ERR("CSTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { @@ -705,8 +684,7 @@ static int bnx2x_mc_assert(struct bnx2x *bp) USTORM_ASSERT_LIST_OFFSET(i) + 12); if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { - BNX2X_ERR("USTORM_ASSERT_INDEX 0x%x = 0x%08x" - " 0x%08x 0x%08x 0x%08x\n", + BNX2X_ERR("USTORM_ASSERT_INDEX 0x%x = 0x%08x 0x%08x 0x%08x 0x%08x\n", i, row3, row2, row1, row0); rc++; } else { @@ -735,7 +713,7 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl) val = REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER); if (val == REG_RD(bp, MCP_REG_MCPR_CPU_PROGRAM_COUNTER)) - printk("%s" "MCP PC at 0x%x\n", lvl, val); + BNX2X_ERR("%s" "MCP PC at 0x%x\n", lvl, val); if (BP_PATH(bp) == 0) trace_shmem_base = bp->common.shmem_base; @@ -787,8 +765,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) /* Indices */ /* Common */ - BNX2X_ERR("def_idx(0x%x) def_att_idx(0x%x) attn_state(0x%x)" - " spq_prod_idx(0x%x) next_stats_cnt(0x%x)\n", + BNX2X_ERR("def_idx(0x%x) def_att_idx(0x%x) attn_state(0x%x) spq_prod_idx(0x%x) next_stats_cnt(0x%x)\n", bp->def_idx, bp->def_att_idx, bp->attn_state, bp->spq_prod_idx, bp->stats_counter); BNX2X_ERR("DSB: attn bits(0x%x) ack(0x%x) id(0x%x) idx(0x%x)\n", @@ -835,14 +812,11 @@ void bnx2x_panic_dump(struct bnx2x *bp) struct bnx2x_fp_txdata txdata; /* Rx */ - BNX2X_ERR("fp%d: rx_bd_prod(0x%x) rx_bd_cons(0x%x)" - " rx_comp_prod(0x%x)" - " rx_comp_cons(0x%x) *rx_cons_sb(0x%x)\n", + BNX2X_ERR("fp%d: rx_bd_prod(0x%x) rx_bd_cons(0x%x) rx_comp_prod(0x%x) rx_comp_cons(0x%x) *rx_cons_sb(0x%x)\n", i, fp->rx_bd_prod, fp->rx_bd_cons, fp->rx_comp_prod, fp->rx_comp_cons, le16_to_cpu(*fp->rx_cons_sb)); - BNX2X_ERR(" rx_sge_prod(0x%x) last_max_sge(0x%x)" - " fp_hc_idx(0x%x)\n", + BNX2X_ERR(" rx_sge_prod(0x%x) last_max_sge(0x%x) fp_hc_idx(0x%x)\n", fp->rx_sge_prod, fp->last_max_sge, le16_to_cpu(fp->fp_hc_idx)); @@ -850,9 +824,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) for_each_cos_in_tx_queue(fp, cos) { txdata = fp->txdata[cos]; - BNX2X_ERR("fp%d: tx_pkt_prod(0x%x) tx_pkt_cons(0x%x)" - " tx_bd_prod(0x%x) tx_bd_cons(0x%x)" - " *tx_cons_sb(0x%x)\n", + BNX2X_ERR("fp%d: tx_pkt_prod(0x%x) tx_pkt_cons(0x%x) tx_bd_prod(0x%x) tx_bd_cons(0x%x) *tx_cons_sb(0x%x)\n", i, txdata.tx_pkt_prod, txdata.tx_pkt_cons, txdata.tx_bd_prod, txdata.tx_bd_cons, @@ -894,9 +866,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) j * sizeof(u32)); if (!CHIP_IS_E1x(bp)) { - pr_cont("pf_id(0x%x) vf_id(0x%x) vf_valid(0x%x) " - "vnic_id(0x%x) same_igu_sb_1b(0x%x) " - "state(0x%x)\n", + pr_cont("pf_id(0x%x) vf_id(0x%x) vf_valid(0x%x) vnic_id(0x%x) same_igu_sb_1b(0x%x) state(0x%x)\n", sb_data_e2.common.p_func.pf_id, sb_data_e2.common.p_func.vf_id, sb_data_e2.common.p_func.vf_valid, @@ -904,9 +874,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) sb_data_e2.common.same_igu_sb_1b, sb_data_e2.common.state); } else { - pr_cont("pf_id(0x%x) vf_id(0x%x) vf_valid(0x%x) " - "vnic_id(0x%x) same_igu_sb_1b(0x%x) " - "state(0x%x)\n", + pr_cont("pf_id(0x%x) vf_id(0x%x) vf_valid(0x%x) vnic_id(0x%x) same_igu_sb_1b(0x%x) state(0x%x)\n", sb_data_e1x.common.p_func.pf_id, sb_data_e1x.common.p_func.vf_id, sb_data_e1x.common.p_func.vf_valid, @@ -917,21 +885,17 @@ void bnx2x_panic_dump(struct bnx2x *bp) /* SB_SMs data */ for (j = 0; j < HC_SB_MAX_SM; j++) { - pr_cont("SM[%d] __flags (0x%x) " - "igu_sb_id (0x%x) igu_seg_id(0x%x) " - "time_to_expire (0x%x) " - "timer_value(0x%x)\n", j, - hc_sm_p[j].__flags, - hc_sm_p[j].igu_sb_id, - hc_sm_p[j].igu_seg_id, - hc_sm_p[j].time_to_expire, - hc_sm_p[j].timer_value); + pr_cont("SM[%d] __flags (0x%x) igu_sb_id (0x%x) igu_seg_id(0x%x) time_to_expire (0x%x) timer_value(0x%x)\n", + j, hc_sm_p[j].__flags, + hc_sm_p[j].igu_sb_id, + hc_sm_p[j].igu_seg_id, + hc_sm_p[j].time_to_expire, + hc_sm_p[j].timer_value); } /* Indecies data */ for (j = 0; j < loop; j++) { - pr_cont("INDEX[%d] flags (0x%x) " - "timeout (0x%x)\n", j, + pr_cont("INDEX[%d] flags (0x%x) timeout (0x%x)\n", j, hc_index_p[j].flags, hc_index_p[j].timeout); } @@ -985,8 +949,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) struct sw_tx_bd *sw_bd = &txdata->tx_buf_ring[j]; - BNX2X_ERR("fp%d: txdata %d, " - "packet[%x]=[%p,%x]\n", + BNX2X_ERR("fp%d: txdata %d, packet[%x]=[%p,%x]\n", i, cos, j, sw_bd->skb, sw_bd->first_bd); } @@ -996,8 +959,7 @@ void bnx2x_panic_dump(struct bnx2x *bp) for (j = start; j != end; j = TX_BD(j + 1)) { u32 *tx_bd = (u32 *)&txdata->tx_desc_ring[j]; - BNX2X_ERR("fp%d: txdata %d, tx_bd[%x]=" - "[%x:%x:%x:%x]\n", + BNX2X_ERR("fp%d: txdata %d, tx_bd[%x]=[%x:%x:%x:%x]\n", i, cos, j, tx_bd[0], tx_bd[1], tx_bd[2], tx_bd[3]); } @@ -1233,6 +1195,8 @@ static inline int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func, if (bnx2x_flr_clnup_reg_poll(bp, comp_addr, 1, poll_cnt) != 1) { BNX2X_ERR("FW final cleanup did not succeed\n"); + DP(BNX2X_MSG_SP, "At timeout completion address contained %x\n", + (REG_RD(bp, comp_addr))); ret = 1; } /* Zero completion for nxt FLR */ @@ -1402,8 +1366,8 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp) HC_CONFIG_0_REG_ATTN_BIT_EN_0); if (!CHIP_IS_E1(bp)) { - DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", - val, port, addr); + DP(NETIF_MSG_IFUP, + "write %x to HC %d (addr 0x%x)\n", val, port, addr); REG_WR(bp, addr, val); @@ -1414,8 +1378,9 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp) if (CHIP_IS_E1(bp)) REG_WR(bp, HC_REG_INT_MASK + port*4, 0x1FFFF); - DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) mode %s\n", - val, port, addr, (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); + DP(NETIF_MSG_IFUP, + "write %x to HC %d (addr 0x%x) mode %s\n", val, port, addr, + (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); REG_WR(bp, addr, val); /* @@ -1470,7 +1435,7 @@ static void bnx2x_igu_int_enable(struct bnx2x *bp) IGU_PF_CONF_SINGLE_ISR_EN); } - DP(NETIF_MSG_INTR, "write 0x%x to IGU mode %s\n", + DP(NETIF_MSG_IFUP, "write 0x%x to IGU mode %s\n", val, (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); REG_WR(bp, IGU_REG_PF_CONFIGURATION, val); @@ -1528,7 +1493,8 @@ static void bnx2x_hc_int_disable(struct bnx2x *bp) HC_CONFIG_0_REG_INT_LINE_EN_0 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); - DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", + DP(NETIF_MSG_IFDOWN, + "write %x to HC %d (addr 0x%x)\n", val, port, addr); /* flush all outstanding writes */ @@ -1547,7 +1513,7 @@ static void bnx2x_igu_int_disable(struct bnx2x *bp) IGU_PF_CONF_INT_LINE_EN | IGU_PF_CONF_ATTN_BIT_EN); - DP(NETIF_MSG_INTR, "write %x to IGU\n", val); + DP(NETIF_MSG_IFDOWN, "write %x to IGU\n", val); /* flush all outstanding writes */ mmiowb(); @@ -1606,11 +1572,12 @@ static bool bnx2x_trylock_hw_lock(struct bnx2x *bp, u32 resource) int func = BP_FUNC(bp); u32 hw_lock_control_reg; - DP(NETIF_MSG_HW, "Trying to take a lock on resource %d\n", resource); + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, + "Trying to take a lock on resource %d\n", resource); /* Validating that the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { - DP(NETIF_MSG_HW, + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", resource, HW_LOCK_MAX_RESOURCE_VALUE); return false; @@ -1628,7 +1595,8 @@ static bool bnx2x_trylock_hw_lock(struct bnx2x *bp, u32 resource) if (lock_status & resource_bit) return true; - DP(NETIF_MSG_HW, "Failed to get a lock on resource %d\n", resource); + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, + "Failed to get a lock on resource %d\n", resource); return false; } @@ -1689,7 +1657,7 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe) break; case (RAMROD_CMD_ID_ETH_TX_QUEUE_SETUP): - DP(NETIF_MSG_IFUP, "got MULTI[%d] tx-only setup ramrod\n", cid); + DP(BNX2X_MSG_SP, "got MULTI[%d] tx-only setup ramrod\n", cid); drv_cmd = BNX2X_Q_CMD_SETUP_TX_ONLY; break; @@ -1831,8 +1799,7 @@ int bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource) /* Validating that the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { - DP(NETIF_MSG_HW, - "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", + BNX2X_ERR("resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", resource, HW_LOCK_MAX_RESOURCE_VALUE); return -EINVAL; } @@ -1847,7 +1814,7 @@ int bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource) /* Validating that the resource is not already taken */ lock_status = REG_RD(bp, hw_lock_control_reg); if (lock_status & resource_bit) { - DP(NETIF_MSG_HW, "lock_status 0x%x resource_bit 0x%x\n", + BNX2X_ERR("lock_status 0x%x resource_bit 0x%x\n", lock_status, resource_bit); return -EEXIST; } @@ -1862,7 +1829,7 @@ int bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource) msleep(5); } - DP(NETIF_MSG_HW, "Timeout\n"); + BNX2X_ERR("Timeout\n"); return -EAGAIN; } @@ -1878,12 +1845,9 @@ int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource) int func = BP_FUNC(bp); u32 hw_lock_control_reg; - DP(NETIF_MSG_HW, "Releasing a lock on resource %d\n", resource); - /* Validating that the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { - DP(NETIF_MSG_HW, - "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", + BNX2X_ERR("resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n", resource, HW_LOCK_MAX_RESOURCE_VALUE); return -EINVAL; } @@ -1898,7 +1862,7 @@ int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource) /* Validating that the resource is currently taken */ lock_status = REG_RD(bp, hw_lock_control_reg); if (!(lock_status & resource_bit)) { - DP(NETIF_MSG_HW, "lock_status 0x%x resource_bit 0x%x\n", + BNX2X_ERR("lock_status 0x%x resource_bit 0x%x. unlock was called but lock wasn't taken!\n", lock_status, resource_bit); return -EFAULT; } @@ -1959,7 +1923,8 @@ int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port) switch (mode) { case MISC_REGISTERS_GPIO_OUTPUT_LOW: - DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> output low\n", + DP(NETIF_MSG_LINK, + "Set GPIO %d (shift %d) -> output low\n", gpio_num, gpio_shift); /* clear FLOAT and set CLR */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS); @@ -1967,7 +1932,8 @@ int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port) break; case MISC_REGISTERS_GPIO_OUTPUT_HIGH: - DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> output high\n", + DP(NETIF_MSG_LINK, + "Set GPIO %d (shift %d) -> output high\n", gpio_num, gpio_shift); /* clear FLOAT and set SET */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS); @@ -1975,7 +1941,8 @@ int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port) break; case MISC_REGISTERS_GPIO_INPUT_HI_Z: - DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> input\n", + DP(NETIF_MSG_LINK, + "Set GPIO %d (shift %d) -> input\n", gpio_num, gpio_shift); /* set FLOAT */ gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS); @@ -2059,16 +2026,18 @@ int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port) switch (mode) { case MISC_REGISTERS_GPIO_INT_OUTPUT_CLR: - DP(NETIF_MSG_LINK, "Clear GPIO INT %d (shift %d) -> " - "output low\n", gpio_num, gpio_shift); + DP(NETIF_MSG_LINK, + "Clear GPIO INT %d (shift %d) -> output low\n", + gpio_num, gpio_shift); /* clear SET and set CLR */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_INT_SET_POS); gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_INT_CLR_POS); break; case MISC_REGISTERS_GPIO_INT_OUTPUT_SET: - DP(NETIF_MSG_LINK, "Set GPIO INT %d (shift %d) -> " - "output high\n", gpio_num, gpio_shift); + DP(NETIF_MSG_LINK, + "Set GPIO INT %d (shift %d) -> output high\n", + gpio_num, gpio_shift); /* clear CLR and set SET */ gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_INT_CLR_POS); gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_INT_SET_POS); @@ -2101,21 +2070,21 @@ static int bnx2x_set_spio(struct bnx2x *bp, int spio_num, u32 mode) switch (mode) { case MISC_REGISTERS_SPIO_OUTPUT_LOW: - DP(NETIF_MSG_LINK, "Set SPIO %d -> output low\n", spio_num); + DP(NETIF_MSG_HW, "Set SPIO %d -> output low\n", spio_num); /* clear FLOAT and set CLR */ spio_reg &= ~(spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS); spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_CLR_POS); break; case MISC_REGISTERS_SPIO_OUTPUT_HIGH: - DP(NETIF_MSG_LINK, "Set SPIO %d -> output high\n", spio_num); + DP(NETIF_MSG_HW, "Set SPIO %d -> output high\n", spio_num); /* clear FLOAT and set SET */ spio_reg &= ~(spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS); spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_SET_POS); break; case MISC_REGISTERS_SPIO_INPUT_HI_Z: - DP(NETIF_MSG_LINK, "Set SPIO %d -> input\n", spio_num); + DP(NETIF_MSG_HW, "Set SPIO %d -> input\n", spio_num); /* set FLOAT */ spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS); break; @@ -2557,7 +2526,7 @@ static void bnx2x_pmf_update(struct bnx2x *bp) u32 val; bp->port.pmf = 1; - DP(NETIF_MSG_LINK, "pmf %d\n", bp->port.pmf); + DP(BNX2X_MSG_MCP, "pmf %d\n", bp->port.pmf); /* * We need the mb() to ensure the ordering between the writing to @@ -3138,12 +3107,12 @@ static void bnx2x_dcc_event(struct bnx2x *bp, u32 dcc_event) * locks */ if (bp->mf_config[BP_VN(bp)] & FUNC_MF_CFG_FUNC_DISABLED) { - DP(NETIF_MSG_IFDOWN, "mf_cfg function disabled\n"); + DP(BNX2X_MSG_MCP, "mf_cfg function disabled\n"); bp->flags |= MF_FUNC_DIS; bnx2x_e1h_disable(bp); } else { - DP(NETIF_MSG_IFUP, "mf_cfg function enabled\n"); + DP(BNX2X_MSG_MCP, "mf_cfg function enabled\n"); bp->flags &= ~MF_FUNC_DIS; bnx2x_e1h_enable(bp); @@ -3170,7 +3139,7 @@ static inline struct eth_spe *bnx2x_sp_get_next(struct bnx2x *bp) if (bp->spq_prod_bd == bp->spq_last_bd) { bp->spq_prod_bd = bp->spq; bp->spq_prod_idx = 0; - DP(NETIF_MSG_TIMER, "end of spq\n"); + DP(BNX2X_MSG_SP, "end of spq\n"); } else { bp->spq_prod_bd++; bp->spq_prod_idx++; @@ -3239,8 +3208,10 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid, bool common = bnx2x_is_contextless_ramrod(command, cmd_type); #ifdef BNX2X_STOP_ON_ERROR - if (unlikely(bp->panic)) + if (unlikely(bp->panic)) { + BNX2X_ERR("Can't post SP when there is panic\n"); return -EIO; + } #endif spin_lock_bh(&bp->spq_lock); @@ -3287,9 +3258,8 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid, atomic_dec(&bp->cq_spq_left); - DP(BNX2X_MSG_SP/*NETIF_MSG_TIMER*/, - "SPQE[%x] (%x:%x) (cmd, common?) (%d,%d) hw_cid %x data (%x:%x) " - "type(0x%x) left (CQ, EQ) (%x,%x)\n", + DP(BNX2X_MSG_SP, + "SPQE[%x] (%x:%x) (cmd, common?) (%d,%d) hw_cid %x data (%x:%x) type(0x%x) left (CQ, EQ) (%x,%x)\n", bp->spq_prod_idx, (u32)U64_HI(bp->spq_mapping), (u32)(U64_LO(bp->spq_mapping) + (void *)bp->spq_prod_bd - (void *)bp->spq), command, common, @@ -3481,9 +3451,8 @@ static inline void bnx2x_fan_failure(struct bnx2x *bp) ext_phy_config); /* log the failure */ - netdev_err(bp->dev, "Fan Failure on Network Controller has caused" - " the driver to shutdown the card to prevent permanent" - " damage. Please contact OEM Support for assistance\n"); + netdev_err(bp->dev, "Fan Failure on Network Controller has caused the driver to shutdown the card to prevent permanent damage.\n" + "Please contact OEM Support for assistance\n"); /* * Scheudle device reset (unload) @@ -3829,7 +3798,7 @@ void bnx2x_set_pf_load(struct bnx2x *bp) bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); - DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); + DP(NETIF_MSG_IFUP, "Old GEN_REG_VAL=0x%08x\n", val); /* get the current counter value */ val1 = (val & mask) >> shift; @@ -3866,7 +3835,7 @@ bool bnx2x_clear_pf_load(struct bnx2x *bp) bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG); val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); - DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); + DP(NETIF_MSG_IFDOWN, "Old GEN_REG_VAL=0x%08x\n", val); /* get the current counter value */ val1 = (val & mask) >> shift; @@ -3898,11 +3867,12 @@ static inline bool bnx2x_get_load_status(struct bnx2x *bp, int engine) BNX2X_PATH0_LOAD_CNT_SHIFT); u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); - DP(NETIF_MSG_HW, "GLOB_REG=0x%08x\n", val); + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, "GLOB_REG=0x%08x\n", val); val = (val & mask) >> shift; - DP(NETIF_MSG_HW, "load mask for engine %d = 0x%x\n", engine, val); + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, "load mask for engine %d = 0x%x\n", + engine, val); return val != 0; } @@ -4190,9 +4160,8 @@ static inline bool bnx2x_parity_attn(struct bnx2x *bp, bool *global, bool print, (sig[3] & HW_PRTY_ASSERT_SET_3) || (sig[4] & HW_PRTY_ASSERT_SET_4)) { int par_num = 0; - DP(NETIF_MSG_HW, "Was parity error: HW block parity attention: " - "[0]:0x%08x [1]:0x%08x [2]:0x%08x [3]:0x%08x " - "[4]:0x%08x\n", + DP(NETIF_MSG_HW, "Was parity error: HW block parity attention:\n" + "[0]:0x%08x [1]:0x%08x [2]:0x%08x [3]:0x%08x [4]:0x%08x\n", sig[0] & HW_PRTY_ASSERT_SET_0, sig[1] & HW_PRTY_ASSERT_SET_1, sig[2] & HW_PRTY_ASSERT_SET_2, @@ -4262,34 +4231,25 @@ static inline void bnx2x_attn_int_deasserted4(struct bnx2x *bp, u32 attn) val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS_CLR); BNX2X_ERR("PGLUE hw attention 0x%x\n", val); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "ADDRESS_ERROR\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "INCORRECT_RCV_BEHAVIOR\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "WAS_ERROR_ATTN\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "VF_LENGTH_VIOLATION_ATTN\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_GRC_SPACE_VIOLATION_ATTN) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "VF_GRC_SPACE_VIOLATION_ATTN\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_VF_GRC_SPACE_VIOLATION_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_MSIX_BAR_VIOLATION_ATTN) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "VF_MSIX_BAR_VIOLATION_ATTN\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_VF_MSIX_BAR_VIOLATION_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_ERROR_ATTN) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "TCPL_ERROR_ATTN\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_ERROR_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "TCPL_IN_TWO_RCBS_ATTN\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN\n"); if (val & PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW) - BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_" - "CSSNOOP_FIFO_OVERFLOW\n"); + BNX2X_ERR("PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW\n"); } if (attn & AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT) { val = REG_RD(bp, ATC_REG_ATC_INT_STS_CLR); @@ -4297,19 +4257,15 @@ static inline void bnx2x_attn_int_deasserted4(struct bnx2x *bp, u32 attn) if (val & ATC_ATC_INT_STS_REG_ADDRESS_ERROR) BNX2X_ERR("ATC_ATC_INT_STS_REG_ADDRESS_ERROR\n"); if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND) - BNX2X_ERR("ATC_ATC_INT_STS_REG" - "_ATC_TCPL_TO_NOT_PEND\n"); + BNX2X_ERR("ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND\n"); if (val & ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS) - BNX2X_ERR("ATC_ATC_INT_STS_REG_" - "ATC_GPA_MULTIPLE_HITS\n"); + BNX2X_ERR("ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS\n"); if (val & ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT) - BNX2X_ERR("ATC_ATC_INT_STS_REG_" - "ATC_RCPL_TO_EMPTY_CNT\n"); + BNX2X_ERR("ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT\n"); if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR) BNX2X_ERR("ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR\n"); if (val & ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU) - BNX2X_ERR("ATC_ATC_INT_STS_REG_" - "ATC_IREQ_LESS_THAN_STU\n"); + BNX2X_ERR("ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU\n"); } if (attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR | @@ -4368,8 +4324,7 @@ static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted) if (deasserted & (1 << index)) { group_mask = &bp->attn_group[index]; - DP(NETIF_MSG_HW, "group[%d]: %08x %08x " - "%08x %08x %08x\n", + DP(NETIF_MSG_HW, "group[%d]: %08x %08x %08x %08x %08x\n", index, group_mask->sig[0], group_mask->sig[1], group_mask->sig[2], group_mask->sig[3], @@ -4529,6 +4484,7 @@ static inline void bnx2x_handle_classification_eqe(struct bnx2x *bp, switch (elem->message.data.eth_event.echo >> BNX2X_SWCID_SHIFT) { case BNX2X_FILTER_MAC_PENDING: + DP(BNX2X_MSG_SP, "Got SETUP_MAC completions\n"); #ifdef BCM_CNIC if (cid == BNX2X_ISCSI_ETH_CID) vlan_mac_obj = &bp->iscsi_l2_mac_obj; @@ -4538,6 +4494,7 @@ static inline void bnx2x_handle_classification_eqe(struct bnx2x *bp, break; case BNX2X_FILTER_MCAST_PENDING: + DP(BNX2X_MSG_SP, "Got SETUP_MCAST completions\n"); /* This is only relevant for 57710 where multicast MACs are * configured as unicast MACs using the same ramrod. */ @@ -4639,7 +4596,8 @@ static void bnx2x_eq_int(struct bnx2x *bp) /* handle eq element */ switch (opcode) { case EVENT_RING_OPCODE_STAT_QUERY: - DP(NETIF_MSG_TIMER, "got statistics comp event %d\n", + DP(BNX2X_MSG_SP | BNX2X_MSG_STATS, + "got statistics comp event %d\n", bp->stats_comp++); /* nothing to do with stats comp */ goto next_spqe; @@ -4666,7 +4624,7 @@ static void bnx2x_eq_int(struct bnx2x *bp) goto next_spqe; case EVENT_RING_OPCODE_STOP_TRAFFIC: - DP(BNX2X_MSG_SP, "got STOP TRAFFIC\n"); + DP(BNX2X_MSG_SP | BNX2X_MSG_DCB, "got STOP TRAFFIC\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_TX_STOP)) break; @@ -4674,21 +4632,23 @@ static void bnx2x_eq_int(struct bnx2x *bp) goto next_spqe; case EVENT_RING_OPCODE_START_TRAFFIC: - DP(BNX2X_MSG_SP, "got START TRAFFIC\n"); + DP(BNX2X_MSG_SP | BNX2X_MSG_DCB, "got START TRAFFIC\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_TX_START)) break; bnx2x_dcbx_set_params(bp, BNX2X_DCBX_STATE_TX_RELEASED); goto next_spqe; case EVENT_RING_OPCODE_FUNCTION_START: - DP(BNX2X_MSG_SP, "got FUNC_START ramrod\n"); + DP(BNX2X_MSG_SP | NETIF_MSG_IFUP, + "got FUNC_START ramrod\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_START)) break; goto next_spqe; case EVENT_RING_OPCODE_FUNCTION_STOP: - DP(BNX2X_MSG_SP, "got FUNC_STOP ramrod\n"); + DP(BNX2X_MSG_SP | NETIF_MSG_IFUP, + "got FUNC_STOP ramrod\n"); if (f_obj->complete_cmd(bp, f_obj, BNX2X_F_CMD_STOP)) break; @@ -4770,7 +4730,7 @@ static void bnx2x_sp_task(struct work_struct *work) /* if (status == 0) */ /* BNX2X_ERR("spurious slowpath interrupt!\n"); */ - DP(NETIF_MSG_INTR, "got a slowpath interrupt (status 0x%x)\n", status); + DP(BNX2X_MSG_SP, "got a slowpath interrupt (status 0x%x)\n", status); /* HW attentions */ if (status & BNX2X_DEF_SB_ATT_IDX) { @@ -4804,7 +4764,7 @@ static void bnx2x_sp_task(struct work_struct *work) } if (unlikely(status)) - DP(NETIF_MSG_INTR, "got an unknown interrupt! (status 0x%x)\n", + DP(BNX2X_MSG_SP, "got an unknown interrupt! (status 0x%x)\n", status); bnx2x_ack_sb(bp, bp->igu_dsb_id, ATTENTION_ID, @@ -5082,7 +5042,7 @@ static void bnx2x_init_sb(struct bnx2x *bp, dma_addr_t mapping, int vfid, bnx2x_setup_ndsb_state_machine(&hc_sm_p[SM_TX_ID], igu_sb_id, igu_seg_id); - DP(NETIF_MSG_HW, "Init FW SB %d\n", fw_sb_id); + DP(NETIF_MSG_IFUP, "Init FW SB %d\n", fw_sb_id); /* write indecies to HW */ bnx2x_wr_fp_sb_data(bp, fw_sb_id, sb_data_p, data_size); @@ -5460,8 +5420,7 @@ static void bnx2x_init_eth_fp(struct bnx2x *bp, int fp_idx) */ bnx2x_init_vlan_mac_fp_objs(fp, BNX2X_OBJ_TYPE_RX_TX); - DP(NETIF_MSG_IFUP, "queue[%d]: bnx2x_init_sb(%p,%p) " - "cl_id %d fw_sb %d igu_sb %d\n", + DP(NETIF_MSG_IFUP, "queue[%d]: bnx2x_init_sb(%p,%p) cl_id %d fw_sb %d igu_sb %d\n", fp_idx, bp, fp->status_blk.e2_sb, fp->cl_id, fp->fw_sb_id, fp->igu_sb_id); bnx2x_init_sb(bp, fp->status_blk_mapping, BNX2X_VF_ID_INVALID, false, @@ -5548,8 +5507,7 @@ static int bnx2x_gunzip_init(struct bnx2x *bp) bp->gunzip_buf = NULL; gunzip_nomem1: - netdev_err(bp->dev, "Cannot allocate firmware buffer for" - " un-compression\n"); + BNX2X_ERR("Cannot allocate firmware buffer for un-compression\n"); return -ENOMEM; } @@ -5601,8 +5559,8 @@ static int bnx2x_gunzip(struct bnx2x *bp, const u8 *zbuf, int len) bp->gunzip_outlen = (FW_BUF_SIZE - bp->strm->avail_out); if (bp->gunzip_outlen & 0x3) - netdev_err(bp->dev, "Firmware decompression error:" - " gunzip_outlen (%d) not aligned\n", + netdev_err(bp->dev, + "Firmware decompression error: gunzip_outlen (%d) not aligned\n", bp->gunzip_outlen); bp->gunzip_outlen >>= 2; @@ -6021,7 +5979,7 @@ static int bnx2x_init_hw_common(struct bnx2x *bp) { u32 val; - DP(BNX2X_MSG_MCP, "starting common init func %d\n", BP_ABS_FUNC(bp)); + DP(NETIF_MSG_HW, "starting common init func %d\n", BP_ABS_FUNC(bp)); /* * take the UNDI lock to protect undi_unload flow from accessing @@ -6345,9 +6303,9 @@ static int bnx2x_init_hw_common(struct bnx2x *bp) if (sizeof(union cdu_context) != 1024) /* we currently assume that a context is 1024 bytes */ - dev_alert(&bp->pdev->dev, "please adjust the size " - "of cdu_context(%ld)\n", - (long)sizeof(union cdu_context)); + dev_alert(&bp->pdev->dev, + "please adjust the size of cdu_context(%ld)\n", + (long)sizeof(union cdu_context)); bnx2x_init_block(bp, BLOCK_CDU, PHASE_COMMON); val = (4 << 24) + (0 << 12) + 1024; @@ -6476,7 +6434,7 @@ static int bnx2x_init_hw_port(struct bnx2x *bp) bnx2x__link_reset(bp); - DP(BNX2X_MSG_MCP, "starting port init port %d\n", port); + DP(NETIF_MSG_HW, "starting port init port %d\n", port); REG_WR(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 0); @@ -6699,7 +6657,7 @@ static int bnx2x_init_hw_func(struct bnx2x *bp) u32 main_mem_base, main_mem_size, main_mem_prty_clr; int i, main_mem_width, rc; - DP(BNX2X_MSG_MCP, "starting func init func %d\n", func); + DP(NETIF_MSG_HW, "starting func init func %d\n", func); /* FLR cleanup - hmmm */ if (!CHIP_IS_E1x(bp)) { @@ -6959,9 +6917,9 @@ static int bnx2x_init_hw_func(struct bnx2x *bp) val = REG_RD(bp, main_mem_prty_clr); if (val) - DP(BNX2X_MSG_MCP, "Hmmm... Parity errors in HC " - "block during " - "function init (0x%x)!\n", val); + DP(NETIF_MSG_HW, + "Hmmm... Parity errors in HC block during function init (0x%x)!\n", + val); /* Clear "false" parity errors in MSI-X table */ for (i = main_mem_base; @@ -7089,6 +7047,7 @@ static inline int bnx2x_alloc_fw_stats_mem(struct bnx2x *bp) alloc_mem_err: BNX2X_PCI_FREE(bp->fw_stats, bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); + BNX2X_ERR("Can't allocate memory\n"); return -ENOMEM; } @@ -7152,6 +7111,7 @@ int bnx2x_alloc_mem(struct bnx2x *bp) alloc_mem_err: bnx2x_free_mem(bp); + BNX2X_ERR("Can't allocate memory\n"); return -ENOMEM; } @@ -7218,7 +7178,8 @@ int bnx2x_set_eth_mac(struct bnx2x *bp, bool set) #ifdef BCM_CNIC if (is_zero_ether_addr(bp->dev->dev_addr) && IS_MF_ISCSI_SD(bp)) { - DP(NETIF_MSG_IFUP, "Ignoring Zero MAC for iSCSI SD mode\n"); + DP(NETIF_MSG_IFUP | NETIF_MSG_IFDOWN, + "Ignoring Zero MAC for STORAGE SD mode\n"); return 0; } #endif @@ -7251,14 +7212,13 @@ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp) /* falling through... */ case INT_MODE_INTx: bp->num_queues = 1 + NON_ETH_CONTEXT_USE; - DP(NETIF_MSG_IFUP, "set number of queues to 1\n"); + BNX2X_DEV_INFO("set number of queues to 1\n"); break; default: /* Set number of queues according to bp->multi_mode value */ bnx2x_set_num_queues(bp); - DP(NETIF_MSG_IFUP, "set number of queues to %d\n", - bp->num_queues); + BNX2X_DEV_INFO("set number of queues to %d\n", bp->num_queues); /* if we can't use MSI-X we only need one fp, * so try to enable MSI-X with the requested number of fp's @@ -7266,13 +7226,9 @@ static void __devinit bnx2x_set_int_mode(struct bnx2x *bp) */ if (bnx2x_enable_msix(bp)) { /* failed to enable MSI-X */ - if (bp->multi_mode) - DP(NETIF_MSG_IFUP, - "Multi requested but failed to " - "enable MSI-X (%d), " - "set number of queues to %d\n", - bp->num_queues, - 1 + NON_ETH_CONTEXT_USE); + BNX2X_DEV_INFO("Failed to enable MSI-X (%d), set number of queues to %d\n", + bp->num_queues, 1 + NON_ETH_CONTEXT_USE); + bp->num_queues = 1 + NON_ETH_CONTEXT_USE; /* Try to enable MSI */ @@ -7310,8 +7266,7 @@ void bnx2x_ilt_set_info(struct bnx2x *bp) #endif ilt_client->end = line - 1; - DP(BNX2X_MSG_SP, "ilt client[CDU]: start %d, end %d, psz 0x%x, " - "flags 0x%x, hw psz %d\n", + DP(NETIF_MSG_IFUP, "ilt client[CDU]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, @@ -7332,8 +7287,8 @@ void bnx2x_ilt_set_info(struct bnx2x *bp) ilt_client->end = line - 1; - DP(BNX2X_MSG_SP, "ilt client[QM]: start %d, end %d, psz 0x%x, " - "flags 0x%x, hw psz %d\n", + DP(NETIF_MSG_IFUP, + "ilt client[QM]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, @@ -7351,8 +7306,8 @@ void bnx2x_ilt_set_info(struct bnx2x *bp) line += SRC_ILT_LINES; ilt_client->end = line - 1; - DP(BNX2X_MSG_SP, "ilt client[SRC]: start %d, end %d, psz 0x%x, " - "flags 0x%x, hw psz %d\n", + DP(NETIF_MSG_IFUP, + "ilt client[SRC]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, @@ -7373,8 +7328,8 @@ void bnx2x_ilt_set_info(struct bnx2x *bp) line += TM_ILT_LINES; ilt_client->end = line - 1; - DP(BNX2X_MSG_SP, "ilt client[TM]: start %d, end %d, psz 0x%x, " - "flags 0x%x, hw psz %d\n", + DP(NETIF_MSG_IFUP, + "ilt client[TM]: start %d, end %d, psz 0x%x, flags 0x%x, hw psz %d\n", ilt_client->start, ilt_client->end, ilt_client->page_size, @@ -7435,7 +7390,7 @@ static inline void bnx2x_pf_q_prep_init(struct bnx2x *bp, /* set maximum number of COSs supported by this queue */ init_params->max_cos = fp->max_cos; - DP(BNX2X_MSG_SP, "fp: %d setting queue params max cos to: %d\n", + DP(NETIF_MSG_IFUP, "fp: %d setting queue params max cos to: %d\n", fp->index, init_params->max_cos); /* set the context pointers queue object */ @@ -7466,9 +7421,8 @@ int bnx2x_setup_tx_only(struct bnx2x *bp, struct bnx2x_fastpath *fp, /* Set Tx TX_ONLY_SETUP parameters */ bnx2x_pf_tx_q_prep(bp, fp, &tx_only_params->txq_params, tx_index); - DP(BNX2X_MSG_SP, "preparing to send tx-only ramrod for connection:" - "cos %d, primary cid %d, cid %d, " - "client id %d, sp-client id %d, flags %lx\n", + DP(NETIF_MSG_IFUP, + "preparing to send tx-only ramrod for connection: cos %d, primary cid %d, cid %d, client id %d, sp-client id %d, flags %lx\n", tx_index, q_params->q_obj->cids[FIRST_TX_COS_INDEX], q_params->q_obj->cids[tx_index], q_params->q_obj->cl_id, tx_only_params->gen_params.spcl_id, tx_only_params->flags); @@ -7500,7 +7454,7 @@ int bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp, int rc; u8 tx_index; - DP(BNX2X_MSG_SP, "setting up queue %d\n", fp->index); + DP(NETIF_MSG_IFUP, "setting up queue %d\n", fp->index); /* reset IGU state skip FCoE L2 queue */ if (!IS_FCOE_FP(fp)) @@ -7524,7 +7478,7 @@ int bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp, return rc; } - DP(BNX2X_MSG_SP, "init complete\n"); + DP(NETIF_MSG_IFUP, "init complete\n"); /* Now move the Queue to the SETUP state... */ @@ -7578,7 +7532,7 @@ static int bnx2x_stop_queue(struct bnx2x *bp, int index) struct bnx2x_queue_state_params q_params = {0}; int rc, tx_index; - DP(BNX2X_MSG_SP, "stopping queue %d cid %d\n", index, fp->cid); + DP(NETIF_MSG_IFDOWN, "stopping queue %d cid %d\n", index, fp->cid); q_params.q_obj = &fp->q_obj; /* We want to wait for completion in this context */ @@ -7593,7 +7547,7 @@ static int bnx2x_stop_queue(struct bnx2x *bp, int index) /* ascertain this is a normal queue*/ txdata = &fp->txdata[tx_index]; - DP(BNX2X_MSG_SP, "stopping tx-only queue %d\n", + DP(NETIF_MSG_IFDOWN, "stopping tx-only queue %d\n", txdata->txq_index); /* send halt terminate on tx-only connection */ @@ -7785,8 +7739,7 @@ static inline int bnx2x_func_stop(struct bnx2x *bp) #ifdef BNX2X_STOP_ON_ERROR return rc; #else - BNX2X_ERR("FUNC_STOP ramrod failed. Running a dry " - "transaction\n"); + BNX2X_ERR("FUNC_STOP ramrod failed. Running a dry transaction\n"); __set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags); return bnx2x_func_state_change(bp, &func_params); #endif @@ -7849,14 +7802,12 @@ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode) else { int path = BP_PATH(bp); - DP(NETIF_MSG_IFDOWN, "NO MCP - load counts[%d] " - "%d, %d, %d\n", + DP(NETIF_MSG_IFDOWN, "NO MCP - load counts[%d] %d, %d, %d\n", path, load_count[path][0], load_count[path][1], load_count[path][2]); load_count[path][0]--; load_count[path][1 + port]--; - DP(NETIF_MSG_IFDOWN, "NO MCP - new load counts[%d] " - "%d, %d, %d\n", + DP(NETIF_MSG_IFDOWN, "NO MCP - new load counts[%d] %d, %d, %d\n", path, load_count[path][0], load_count[path][1], load_count[path][2]); if (load_count[path][0] == 0) @@ -7919,6 +7870,7 @@ static inline int bnx2x_func_wait_started(struct bnx2x *bp) if (bnx2x_func_get_state(bp, &bp->func_obj) != BNX2X_F_STATE_STARTED) { #ifdef BNX2X_STOP_ON_ERROR + BNX2X_ERR("Wrong function state\n"); return -EBUSY; #else /* @@ -7927,8 +7879,8 @@ static inline int bnx2x_func_wait_started(struct bnx2x *bp) */ struct bnx2x_func_state_params func_params = {0}; - DP(BNX2X_MSG_SP, "Hmmm... unexpected function state! " - "Forcing STARTED-->TX_ST0PPED-->STARTED\n"); + DP(NETIF_MSG_IFDOWN, + "Hmmm... unexpected function state! Forcing STARTED-->TX_ST0PPED-->STARTED\n"); func_params.f_obj = &bp->func_obj; __set_bit(RAMROD_DRV_CLR_ONLY, @@ -7979,8 +7931,8 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode) rc = bnx2x_del_all_macs(bp, &bp->fp[0].mac_obj, BNX2X_UC_LIST_MAC, true); if (rc < 0) - BNX2X_ERR("Failed to schedule DEL commands for UC MACs list: " - "%d\n", rc); + BNX2X_ERR("Failed to schedule DEL commands for UC MACs list: %d\n", + rc); /* Disable LLH */ if (!CHIP_IS_E1(bp)) @@ -8073,7 +8025,7 @@ void bnx2x_disable_close_the_gate(struct bnx2x *bp) { u32 val; - DP(NETIF_MSG_HW, "Disabling \"close the gates\"\n"); + DP(NETIF_MSG_IFDOWN, "Disabling \"close the gates\"\n"); if (CHIP_IS_E1(bp)) { int port = BP_PORT(bp); @@ -8126,7 +8078,7 @@ static void bnx2x_set_234_gates(struct bnx2x *bp, bool close) (val & ~(u32)IGU_BLOCK_CONFIGURATION_REG_BLOCK_ENABLE)); } - DP(NETIF_MSG_HW, "%s gates #2, #3 and #4\n", + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, "%s gates #2, #3 and #4\n", close ? "closing" : "opening"); mmiowb(); } @@ -8168,7 +8120,7 @@ static void bnx2x_reset_mcp_prep(struct bnx2x *bp, u32 *magic_val) u32 shmem; u32 validity_offset; - DP(NETIF_MSG_HW, "Starting\n"); + DP(NETIF_MSG_HW | NETIF_MSG_IFUP, "Starting\n"); /* Set `magic' bit in order to save MF config */ if (!CHIP_IS_E1(bp)) @@ -8405,12 +8357,8 @@ static int bnx2x_process_kill(struct bnx2x *bp, bool global) } while (cnt-- > 0); if (cnt <= 0) { - DP(NETIF_MSG_HW, "Tetris buffer didn't get empty or there" - " are still" - " outstanding read requests after 1s!\n"); - DP(NETIF_MSG_HW, "sr_cnt=0x%08x, blk_cnt=0x%08x," - " port_is_idle_0=0x%08x," - " port_is_idle_1=0x%08x, pgl_exp_rom2=0x%08x\n", + BNX2X_ERR("Tetris buffer didn't get empty or there are still outstanding read requests after 1s!\n"); + BNX2X_ERR("sr_cnt=0x%08x, blk_cnt=0x%08x, port_is_idle_0=0x%08x, port_is_idle_1=0x%08x, pgl_exp_rom2=0x%08x\n", sr_cnt, blk_cnt, port_is_idle_0, port_is_idle_1, pgl_exp_rom2); return -EAGAIN; @@ -8504,8 +8452,8 @@ int bnx2x_leader_reset(struct bnx2x *bp) /* Try to recover after the failure */ if (bnx2x_process_kill(bp, global)) { - netdev_err(bp->dev, "Something bad had happen on engine %d! " - "Aii!\n", BP_PATH(bp)); + BNX2X_ERR("Something bad had happen on engine %d! Aii!\n", + BP_PATH(bp)); rc = -EAGAIN; goto exit_leader_reset2; } @@ -8685,9 +8633,7 @@ static void bnx2x_parity_recover(struct bnx2x *bp) if (bnx2x_nic_load(bp, LOAD_NORMAL)) { error_unrecovered++; netdev_err(bp->dev, - "Recovery failed. " - "Power cycle " - "needed\n"); + "Recovery failed. Power cycle needed\n"); /* Disconnect this device */ netif_device_detach(bp->dev); /* Shut down the power */ @@ -8730,8 +8676,7 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work) /* if stop on error is defined no recovery flows should be executed */ #ifdef BNX2X_STOP_ON_ERROR - BNX2X_ERR("recovery flow called but STOP_ON_ERROR defined " - "so reset not done to allow debug dump,\n" + BNX2X_ERR("recovery flow called but STOP_ON_ERROR defined so reset not done to allow debug dump,\n" "you will need to reboot when done\n"); goto sp_rtnl_not_reset; #endif @@ -8774,7 +8719,7 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work) * damage */ if (test_and_clear_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state)) { - DP(BNX2X_MSG_SP, "fan failure detected. Unloading driver\n"); + DP(NETIF_MSG_HW, "fan failure detected. Unloading driver\n"); netif_device_detach(bp->dev); bnx2x_close(bp->dev); } @@ -9002,6 +8947,8 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) bp->pfid = bp->pf_num; /* 0..7 */ } + BNX2X_DEV_INFO("pf_id: %x", bp->pfid); + bp->link_params.chip_id = bp->common.chip_id; BNX2X_DEV_INFO("chip ID is 0x%x\n", id); @@ -9059,8 +9006,8 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) if (val < BNX2X_BC_VER) { /* for now only warn * later we might need to enforce this */ - BNX2X_ERR("This driver needs bc_ver %X but found %X, " - "please upgrade BC\n", BNX2X_BC_VER, val); + BNX2X_ERR("This driver needs bc_ver %X but found %X, please upgrade BC\n", + BNX2X_BC_VER, val); } bp->link_params.feature_config_flags |= (val >= REQ_BC_VER_4_VRFY_FIRST_PHY_OPT_MDL) ? @@ -9201,8 +9148,7 @@ static void __devinit bnx2x_link_settings_supported(struct bnx2x *bp, } if (!(bp->port.supported[0] || bp->port.supported[1])) { - BNX2X_ERR("NVRAM config error. BAD phy config." - "PHY1 config 0x%x, PHY2 config 0x%x\n", + BNX2X_ERR("NVRAM config error. BAD phy config. PHY1 config 0x%x, PHY2 config 0x%x\n", SHMEM_RD(bp, dev_info.port_hw_config[port].external_phy_config), SHMEM_RD(bp, @@ -9314,9 +9260,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_10baseT_Full | ADVERTISED_TP); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9333,9 +9277,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_10baseT_Half | ADVERTISED_TP); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9351,9 +9293,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_100baseT_Full | ADVERTISED_TP); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9371,9 +9311,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_100baseT_Half | ADVERTISED_TP); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9389,9 +9327,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_1000baseT_Full | ADVERTISED_TP); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9407,9 +9343,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_2500baseX_Full | ADVERTISED_TP); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9425,9 +9359,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); } else { - BNX2X_ERR("NVRAM config error. " - "Invalid link_config 0x%x" - " speed_cap_mask 0x%x\n", + BNX2X_ERR("NVRAM config error. Invalid link_config 0x%x speed_cap_mask 0x%x\n", link_config, bp->link_params.speed_cap_mask[idx]); return; @@ -9438,8 +9370,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) break; default: - BNX2X_ERR("NVRAM config error. " - "BAD link speed link_config 0x%x\n", + BNX2X_ERR("NVRAM config error. BAD link speed link_config 0x%x\n", link_config); bp->link_params.req_line_speed[idx] = SPEED_AUTO_NEG; @@ -9457,8 +9388,7 @@ static void __devinit bnx2x_link_settings_requested(struct bnx2x *bp) BNX2X_FLOW_CTRL_NONE; } - BNX2X_DEV_INFO("req_line_speed %d req_duplex %d req_flow_ctrl" - " 0x%x advertising 0x%x\n", + BNX2X_DEV_INFO("req_line_speed %d req_duplex %d req_flow_ctrl 0x%x advertising 0x%x\n", bp->link_params.req_line_speed[idx], bp->link_params.req_duplex[idx], bp->link_params.req_flow_ctrl[idx], @@ -9507,8 +9437,7 @@ static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp) bp->wol = (!(bp->flags & NO_WOL_FLAG) && (config & PORT_FEATURE_WOL_ENABLED)); - BNX2X_DEV_INFO("lane_config 0x%08x " - "speed_cap_mask0 0x%08x link_config0 0x%08x\n", + BNX2X_DEV_INFO("lane_config 0x%08x speed_cap_mask0 0x%08x link_config0 0x%08x\n", bp->link_params.lane_config, bp->link_params.speed_cap_mask[0], bp->port.link_config[0]); @@ -9773,10 +9702,11 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) if (!bnx2x_is_valid_ether_addr(bp, bp->dev->dev_addr)) dev_err(&bp->pdev->dev, - "bad Ethernet MAC address configuration: " - "%pM, change it manually before bringing up " - "the appropriate network interface\n", + "bad Ethernet MAC address configuration: %pM\n" + "change it manually before bringing up the appropriate network interface\n", bp->dev->dev_addr); + + } static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) @@ -9897,8 +9827,7 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) bp->mf_config[vn] = MF_CFG_RD(bp, func_mf_config[func].config); } else - BNX2X_DEV_INFO("illegal MAC address " - "for SI\n"); + BNX2X_DEV_INFO("illegal MAC address for SI\n"); break; case SHARED_FEAT_CFG_FORCE_SF_MODE_MF_ALLOWED: /* get OV configuration */ @@ -9916,7 +9845,7 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) default: /* Unknown configuration: reset mf_config */ bp->mf_config[vn] = 0; - BNX2X_DEV_INFO("unkown MF mode 0x%x\n", val); + BNX2X_DEV_INFO("unknown MF mode 0x%x\n", val); } } @@ -9931,25 +9860,24 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp) bp->mf_ov = val; bp->path_has_ovlan = true; - BNX2X_DEV_INFO("MF OV for func %d is %d " - "(0x%04x)\n", func, bp->mf_ov, - bp->mf_ov); + BNX2X_DEV_INFO("MF OV for func %d is %d (0x%04x)\n", + func, bp->mf_ov, bp->mf_ov); } else { dev_err(&bp->pdev->dev, - "No valid MF OV for func %d, " - "aborting\n", func); + "No valid MF OV for func %d, aborting\n", + func); return -EPERM; } break; case MULTI_FUNCTION_SI: - BNX2X_DEV_INFO("func %d is in MF " - "switch-independent mode\n", func); + BNX2X_DEV_INFO("func %d is in MF switch-independent mode\n", + func); break; default: if (vn) { dev_err(&bp->pdev->dev, - "VN %d is in a single function mode, " - "aborting\n", vn); + "VN %d is in a single function mode, aborting\n", + vn); return -EPERM; } break; @@ -10157,8 +10085,7 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp) dev_err(&bp->pdev->dev, "FPGA detected\n"); if (BP_NOMCP(bp) && (func == 0)) - dev_err(&bp->pdev->dev, "MCP disabled, " - "must load devices in order!\n"); + dev_err(&bp->pdev->dev, "MCP disabled, must load devices in order!\n"); bp->multi_mode = multi_mode; @@ -10282,10 +10209,8 @@ static int bnx2x_open(struct net_device *dev) bnx2x_set_power_state(bp, PCI_D3hot); bp->recovery_state = BNX2X_RECOVERY_FAILED; - netdev_err(bp->dev, "Recovery flow hasn't been properly" - " completed yet. Try again later. If u still see this" - " message after a few retries then power cycle is" - " required.\n"); + BNX2X_ERR("Recovery flow hasn't been properly completed yet. Try again later.\n" + "If you still see this message after a few retries then power cycle is required.\n"); return -EAGAIN; } while (0); @@ -10392,8 +10317,7 @@ static inline int bnx2x_set_mc_list(struct bnx2x *bp) /* first, clear all configured multicast MACs */ rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_DEL); if (rc < 0) { - BNX2X_ERR("Failed to clear multicast " - "configuration: %d\n", rc); + BNX2X_ERR("Failed to clear multicast configuration: %d\n", rc); return rc; } @@ -10401,8 +10325,8 @@ static inline int bnx2x_set_mc_list(struct bnx2x *bp) if (netdev_mc_count(dev)) { rc = bnx2x_init_mcast_macs_list(bp, &rparam); if (rc) { - BNX2X_ERR("Failed to create multicast MACs " - "list: %d\n", rc); + BNX2X_ERR("Failed to create multicast MACs list: %d\n", + rc); return rc; } @@ -10410,8 +10334,8 @@ static inline int bnx2x_set_mc_list(struct bnx2x *bp) rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_ADD); if (rc < 0) - BNX2X_ERR("Failed to set a new multicast " - "configuration: %d\n", rc); + BNX2X_ERR("Failed to set a new multicast configuration: %d\n", + rc); bnx2x_free_mcast_macs_list(&rparam); } @@ -10495,8 +10419,9 @@ static int bnx2x_mdio_write(struct net_device *netdev, int prtad, int devad, struct bnx2x *bp = netdev_priv(netdev); int rc; - DP(NETIF_MSG_LINK, "mdio_write: prtad 0x%x, devad 0x%x, addr 0x%x," - " value 0x%x\n", prtad, devad, addr, value); + DP(NETIF_MSG_LINK, + "mdio_write: prtad 0x%x, devad 0x%x, addr 0x%x, value 0x%x\n", + prtad, devad, addr, value); /* The HW expects different devad if CL22 is used */ devad = (devad == MDIO_DEVAD_NONE) ? DEFAULT_PHY_DEV_ADDR : devad; @@ -10537,8 +10462,10 @@ static int bnx2x_validate_addr(struct net_device *dev) { struct bnx2x *bp = netdev_priv(dev); - if (!bnx2x_is_valid_ether_addr(bp, dev->dev_addr)) + if (!bnx2x_is_valid_ether_addr(bp, dev->dev_addr)) { + BNX2X_ERR("Non-valid Ethernet address\n"); return -EADDRNOTAVAIL; + } return 0; } @@ -10572,8 +10499,7 @@ static inline int bnx2x_set_coherency_mask(struct bnx2x *bp) if (dma_set_mask(dev, DMA_BIT_MASK(64)) == 0) { bp->flags |= USING_DAC_FLAG; if (dma_set_coherent_mask(dev, DMA_BIT_MASK(64)) != 0) { - dev_err(dev, "dma_set_coherent_mask failed, " - "aborting\n"); + dev_err(dev, "dma_set_coherent_mask failed, aborting\n"); return -EIO; } } else if (dma_set_mask(dev, DMA_BIT_MASK(32)) != 0) { @@ -10644,7 +10570,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, } if (!pci_is_pcie(pdev)) { - dev_err(&bp->pdev->dev, "Not PCI Express, aborting\n"); + dev_err(&bp->pdev->dev, "Not PCI Express, aborting\n"); rc = -EIO; goto err_out_release; } @@ -10680,7 +10606,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, bp->pf_num = (u8)((pci_cfg_dword & ME_REG_ABS_PF_NUM) >> ME_REG_ABS_PF_NUM_SHIFT); } - DP(BNX2X_MSG_SP, "me reg PF num: %d\n", bp->pf_num); + BNX2X_DEV_INFO("me reg PF num: %d\n", bp->pf_num); bnx2x_set_power_state(bp, PCI_D0); @@ -10782,8 +10708,10 @@ static int bnx2x_check_firmware(struct bnx2x *bp) int i; const u8 *fw_ver; - if (firmware->size < sizeof(struct bnx2x_fw_file_hdr)) + if (firmware->size < sizeof(struct bnx2x_fw_file_hdr)) { + BNX2X_ERR("Wrong FW size\n"); return -EINVAL; + } fw_hdr = (struct bnx2x_fw_file_hdr *)firmware->data; sections = (struct bnx2x_fw_file_section *)fw_hdr; @@ -10794,8 +10722,7 @@ static int bnx2x_check_firmware(struct bnx2x *bp) offset = be32_to_cpu(sections[i].offset); len = be32_to_cpu(sections[i].len); if (offset + len > firmware->size) { - dev_err(&bp->pdev->dev, - "Section %d length is out of bounds\n", i); + BNX2X_ERR("Section %d length is out of bounds\n", i); return -EINVAL; } } @@ -10807,8 +10734,7 @@ static int bnx2x_check_firmware(struct bnx2x *bp) for (i = 0; i < be32_to_cpu(fw_hdr->init_ops_offsets.len) / 2; i++) { if (be16_to_cpu(ops_offsets[i]) > num_ops) { - dev_err(&bp->pdev->dev, - "Section offset %d is out of bounds\n", i); + BNX2X_ERR("Section offset %d is out of bounds\n", i); return -EINVAL; } } @@ -10820,10 +10746,9 @@ static int bnx2x_check_firmware(struct bnx2x *bp) (fw_ver[1] != BCM_5710_FW_MINOR_VERSION) || (fw_ver[2] != BCM_5710_FW_REVISION_VERSION) || (fw_ver[3] != BCM_5710_FW_ENGINEERING_VERSION)) { - dev_err(&bp->pdev->dev, - "Bad FW version:%d.%d.%d.%d. Should be %d.%d.%d.%d\n", - fw_ver[0], fw_ver[1], fw_ver[2], - fw_ver[3], BCM_5710_FW_MAJOR_VERSION, + BNX2X_ERR("Bad FW version:%d.%d.%d.%d. Should be %d.%d.%d.%d\n", + fw_ver[0], fw_ver[1], fw_ver[2], fw_ver[3], + BCM_5710_FW_MAJOR_VERSION, BCM_5710_FW_MINOR_VERSION, BCM_5710_FW_REVISION_VERSION, BCM_5710_FW_ENGINEERING_VERSION); @@ -11142,7 +11067,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, bp = netdev_priv(dev); - DP(NETIF_MSG_DRV, "Allocated netdev with %d tx and %d rx queues\n", + BNX2X_DEV_INFO("Allocated netdev with %d tx and %d rx queues\n", tx_count, rx_count); bp->igu_sb_cnt = max_non_def_sbs; @@ -11155,7 +11080,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, return rc; } - DP(NETIF_MSG_DRV, "max_non_def_sbs %d\n", max_non_def_sbs); + BNX2X_DEV_INFO("max_non_def_sbs %d\n", max_non_def_sbs); rc = bnx2x_init_bp(bp); if (rc) @@ -11210,7 +11135,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev, bnx2x_get_pcie_width_speed(bp, &pcie_width, &pcie_speed); - netdev_info(dev, "%s (%c%d) PCI-E x%d %s found at mem %lx, IRQ %d, node addr %pM\n", + BNX2X_DEV_INFO( + "%s (%c%d) PCI-E x%d %s found at mem %lx, IRQ %d, node addr %pM\n", board_info[ent->driver_data].name, (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4), pcie_width, @@ -11429,8 +11355,7 @@ static void bnx2x_io_resume(struct pci_dev *pdev) struct bnx2x *bp = netdev_priv(dev); if (bp->recovery_state != BNX2X_RECOVERY_DONE) { - netdev_err(bp->dev, "Handling parity error recovery. " - "Try again later\n"); + netdev_err(bp->dev, "Handling parity error recovery. Try again later\n"); return; } @@ -11581,7 +11506,7 @@ static void bnx2x_cnic_sp_post(struct bnx2x *bp, int count) spe = bnx2x_sp_get_next(bp); *spe = *bp->cnic_kwq_cons; - DP(NETIF_MSG_TIMER, "pending on SPQ %d, on KWQ %d count %d\n", + DP(BNX2X_MSG_SP, "pending on SPQ %d, on KWQ %d count %d\n", bp->cnic_spq_pending, bp->cnic_kwq_pending, count); if (bp->cnic_kwq_cons == bp->cnic_kwq_last) @@ -11600,14 +11525,15 @@ static int bnx2x_cnic_sp_queue(struct net_device *dev, int i; #ifdef BNX2X_STOP_ON_ERROR - if (unlikely(bp->panic)) + if (unlikely(bp->panic)) { + BNX2X_ERR("Can't post to SP queue while panic\n"); return -EIO; + } #endif if ((bp->recovery_state != BNX2X_RECOVERY_DONE) && (bp->recovery_state != BNX2X_RECOVERY_NIC_LOADING)) { - netdev_err(dev, "Handling parity error recovery. Try again " - "later\n"); + BNX2X_ERR("Handling parity error recovery. Try again later\n"); return -EAGAIN; } @@ -11623,7 +11549,7 @@ static int bnx2x_cnic_sp_queue(struct net_device *dev, bp->cnic_kwq_pending++; - DP(NETIF_MSG_TIMER, "L5 SPQE %x %x %x:%x pos %d\n", + DP(BNX2X_MSG_SP, "L5 SPQE %x %x %x:%x pos %d\n", spe->hdr.conn_and_cmd_data, spe->hdr.type, spe->data.update_data_addr.hi, spe->data.update_data_addr.lo, @@ -11904,8 +11830,10 @@ static int bnx2x_register_cnic(struct net_device *dev, struct cnic_ops *ops, struct bnx2x *bp = netdev_priv(dev); struct cnic_eth_dev *cp = &bp->cnic_eth_dev; - if (ops == NULL) + if (ops == NULL) { + BNX2X_ERR("NULL ops received\n"); return -EINVAL; + } bp->cnic_kwq = kzalloc(PAGE_SIZE, GFP_KERNEL); if (!bp->cnic_kwq) @@ -11988,8 +11916,8 @@ struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev) if (NO_FCOE(bp)) cp->drv_state |= CNIC_DRV_STATE_NO_FCOE; - DP(BNX2X_MSG_SP, "page_size %d, tbl_offset %d, tbl_lines %d, " - "starting cid %d\n", + BNX2X_DEV_INFO( + "page_size %d, tbl_offset %d, tbl_lines %d, starting cid %d\n", cp->ctx_blk_size, cp->ctx_tbl_offset, cp->ctx_tbl_len, diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 484498f6bf1e..3f52fadee3ed 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -72,8 +72,8 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp, o->execute = exec; o->get = get; - DP(BNX2X_MSG_SP, "Setup the execution queue with the chunk " - "length of %d\n", exe_len); + DP(BNX2X_MSG_SP, "Setup the execution queue with the chunk length of %d\n", + exe_len); } static inline void bnx2x_exe_queue_free_elem(struct bnx2x *bp, @@ -203,8 +203,7 @@ static inline int bnx2x_exe_queue_step(struct bnx2x *bp, */ if (!list_empty(&o->pending_comp)) { if (test_bit(RAMROD_DRV_CLR_ONLY, ramrod_flags)) { - DP(BNX2X_MSG_SP, "RAMROD_DRV_CLR_ONLY requested: " - "resetting pending_comp\n"); + DP(BNX2X_MSG_SP, "RAMROD_DRV_CLR_ONLY requested: resetting a pending_comp list\n"); __bnx2x_exe_queue_reset_pending(bp, o); } else { spin_unlock_bh(&o->lock); @@ -476,11 +475,14 @@ static int bnx2x_get_n_elements(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o, } /* check_add() callbacks */ -static int bnx2x_check_mac_add(struct bnx2x_vlan_mac_obj *o, +static int bnx2x_check_mac_add(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data) { struct bnx2x_vlan_mac_registry_elem *pos; + DP(BNX2X_MSG_SP, "Checking MAC %pM for ADD command\n", data->mac.mac); + if (!is_valid_ether_addr(data->mac.mac)) return -EINVAL; @@ -492,11 +494,14 @@ static int bnx2x_check_mac_add(struct bnx2x_vlan_mac_obj *o, return 0; } -static int bnx2x_check_vlan_add(struct bnx2x_vlan_mac_obj *o, +static int bnx2x_check_vlan_add(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data) { struct bnx2x_vlan_mac_registry_elem *pos; + DP(BNX2X_MSG_SP, "Checking VLAN %d for ADD command\n", data->vlan.vlan); + list_for_each_entry(pos, &o->head, link) if (data->vlan.vlan == pos->u.vlan.vlan) return -EEXIST; @@ -504,11 +509,15 @@ static int bnx2x_check_vlan_add(struct bnx2x_vlan_mac_obj *o, return 0; } -static int bnx2x_check_vlan_mac_add(struct bnx2x_vlan_mac_obj *o, +static int bnx2x_check_vlan_mac_add(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data) { struct bnx2x_vlan_mac_registry_elem *pos; + DP(BNX2X_MSG_SP, "Checking VLAN_MAC (%pM, %d) for ADD command\n", + data->vlan_mac.mac, data->vlan_mac.vlan); + list_for_each_entry(pos, &o->head, link) if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) && (!memcmp(data->vlan_mac.mac, pos->u.vlan_mac.mac, @@ -521,11 +530,14 @@ static int bnx2x_check_vlan_mac_add(struct bnx2x_vlan_mac_obj *o, /* check_del() callbacks */ static struct bnx2x_vlan_mac_registry_elem * - bnx2x_check_mac_del(struct bnx2x_vlan_mac_obj *o, + bnx2x_check_mac_del(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data) { struct bnx2x_vlan_mac_registry_elem *pos; + DP(BNX2X_MSG_SP, "Checking MAC %pM for DEL command\n", data->mac.mac); + list_for_each_entry(pos, &o->head, link) if (!memcmp(data->mac.mac, pos->u.mac.mac, ETH_ALEN)) return pos; @@ -534,11 +546,14 @@ static struct bnx2x_vlan_mac_registry_elem * } static struct bnx2x_vlan_mac_registry_elem * - bnx2x_check_vlan_del(struct bnx2x_vlan_mac_obj *o, + bnx2x_check_vlan_del(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data) { struct bnx2x_vlan_mac_registry_elem *pos; + DP(BNX2X_MSG_SP, "Checking VLAN %d for DEL command\n", data->vlan.vlan); + list_for_each_entry(pos, &o->head, link) if (data->vlan.vlan == pos->u.vlan.vlan) return pos; @@ -547,11 +562,15 @@ static struct bnx2x_vlan_mac_registry_elem * } static struct bnx2x_vlan_mac_registry_elem * - bnx2x_check_vlan_mac_del(struct bnx2x_vlan_mac_obj *o, + bnx2x_check_vlan_mac_del(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data) { struct bnx2x_vlan_mac_registry_elem *pos; + DP(BNX2X_MSG_SP, "Checking VLAN_MAC (%pM, %d) for DEL command\n", + data->vlan_mac.mac, data->vlan_mac.vlan); + list_for_each_entry(pos, &o->head, link) if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) && (!memcmp(data->vlan_mac.mac, pos->u.vlan_mac.mac, @@ -562,7 +581,8 @@ static struct bnx2x_vlan_mac_registry_elem * } /* check_move() callback */ -static bool bnx2x_check_move(struct bnx2x_vlan_mac_obj *src_o, +static bool bnx2x_check_move(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *src_o, struct bnx2x_vlan_mac_obj *dst_o, union bnx2x_classification_ramrod_data *data) { @@ -572,10 +592,10 @@ static bool bnx2x_check_move(struct bnx2x_vlan_mac_obj *src_o, /* Check if we can delete the requested configuration from the first * object. */ - pos = src_o->check_del(src_o, data); + pos = src_o->check_del(bp, src_o, data); /* check if configuration can be added */ - rc = dst_o->check_add(dst_o, data); + rc = dst_o->check_add(bp, dst_o, data); /* If this classification can not be added (is already set) * or can't be deleted - return an error. @@ -587,6 +607,7 @@ static bool bnx2x_check_move(struct bnx2x_vlan_mac_obj *src_o, } static bool bnx2x_check_move_always_err( + struct bnx2x *bp, struct bnx2x_vlan_mac_obj *src_o, struct bnx2x_vlan_mac_obj *dst_o, union bnx2x_classification_ramrod_data *data) @@ -740,7 +761,7 @@ static void bnx2x_set_one_mac_e2(struct bnx2x *bp, &rule_entry->mac.header); DP(BNX2X_MSG_SP, "About to %s MAC %pM for Queue %d\n", - add ? "add" : "delete", mac, raw->cl_id); + (add ? "add" : "delete"), mac, raw->cl_id); /* Set a MAC itself */ bnx2x_set_fw_mac_addr(&rule_entry->mac.mac_msb, @@ -833,7 +854,7 @@ static inline void bnx2x_vlan_mac_set_rdata_e1x(struct bnx2x *bp, cfg_entry); DP(BNX2X_MSG_SP, "%s MAC %pM CLID %d CAM offset %d\n", - add ? "setting" : "clearing", + (add ? "setting" : "clearing"), mac, raw->cl_id, cam_offset); } @@ -1152,10 +1173,9 @@ static inline int bnx2x_validate_vlan_mac_add(struct bnx2x *bp, int rc; /* Check the registry */ - rc = o->check_add(o, &elem->cmd_data.vlan_mac.u); + rc = o->check_add(bp, o, &elem->cmd_data.vlan_mac.u); if (rc) { - DP(BNX2X_MSG_SP, "ADD command is not allowed considering " - "current registry state\n"); + DP(BNX2X_MSG_SP, "ADD command is not allowed considering current registry state.\n"); return rc; } @@ -1206,10 +1226,9 @@ static inline int bnx2x_validate_vlan_mac_del(struct bnx2x *bp, /* If this classification can not be deleted (doesn't exist) * - return a BNX2X_EXIST. */ - pos = o->check_del(o, &elem->cmd_data.vlan_mac.u); + pos = o->check_del(bp, o, &elem->cmd_data.vlan_mac.u); if (!pos) { - DP(BNX2X_MSG_SP, "DEL command is not allowed considering " - "current registry state\n"); + DP(BNX2X_MSG_SP, "DEL command is not allowed considering current registry state\n"); return -EEXIST; } @@ -1269,9 +1288,9 @@ static inline int bnx2x_validate_vlan_mac_move(struct bnx2x *bp, * Check if we can perform this operation based on the current registry * state. */ - if (!src_o->check_move(src_o, dest_o, &elem->cmd_data.vlan_mac.u)) { - DP(BNX2X_MSG_SP, "MOVE command is not allowed considering " - "current registry state\n"); + if (!src_o->check_move(bp, src_o, dest_o, + &elem->cmd_data.vlan_mac.u)) { + DP(BNX2X_MSG_SP, "MOVE command is not allowed considering current registry state\n"); return -EINVAL; } @@ -1285,8 +1304,7 @@ static inline int bnx2x_validate_vlan_mac_move(struct bnx2x *bp, /* Check DEL on source */ query_elem.cmd_data.vlan_mac.cmd = BNX2X_VLAN_MAC_DEL; if (src_exeq->get(src_exeq, &query_elem)) { - BNX2X_ERR("There is a pending DEL command on the source " - "queue already\n"); + BNX2X_ERR("There is a pending DEL command on the source queue already\n"); return -EINVAL; } @@ -1299,8 +1317,7 @@ static inline int bnx2x_validate_vlan_mac_move(struct bnx2x *bp, /* Check ADD on destination */ query_elem.cmd_data.vlan_mac.cmd = BNX2X_VLAN_MAC_ADD; if (dest_exeq->get(dest_exeq, &query_elem)) { - BNX2X_ERR("There is a pending ADD command on the " - "destination queue already\n"); + BNX2X_ERR("There is a pending ADD command on the destination queue already\n"); return -EINVAL; } @@ -1475,12 +1492,10 @@ static int bnx2x_optimize_vlan_mac(struct bnx2x *bp, &pos->cmd_data.vlan_mac.vlan_mac_flags)) { if ((query.cmd_data.vlan_mac.cmd == BNX2X_VLAN_MAC_ADD) && !o->put_credit(o)) { - BNX2X_ERR("Failed to return the credit for the " - "optimized ADD command\n"); + BNX2X_ERR("Failed to return the credit for the optimized ADD command\n"); return -EINVAL; } else if (!o->get_credit(o)) { /* VLAN_MAC_DEL */ - BNX2X_ERR("Failed to recover the credit from " - "the optimized DEL command\n"); + BNX2X_ERR("Failed to recover the credit from the optimized DEL command\n"); return -EINVAL; } } @@ -1546,7 +1561,7 @@ static inline int bnx2x_vlan_mac_get_registry_elem( reg_elem->vlan_mac_flags = elem->cmd_data.vlan_mac.vlan_mac_flags; } else /* DEL, RESTORE */ - reg_elem = o->check_del(o, &elem->cmd_data.vlan_mac.u); + reg_elem = o->check_del(bp, o, &elem->cmd_data.vlan_mac.u); *re = reg_elem; return 0; @@ -1644,7 +1659,8 @@ static int bnx2x_execute_vlan_mac(struct bnx2x *bp, cmd = elem->cmd_data.vlan_mac.cmd; if ((cmd == BNX2X_VLAN_MAC_DEL) || (cmd == BNX2X_VLAN_MAC_MOVE)) { - reg_elem = o->check_del(o, &elem->cmd_data.vlan_mac.u); + reg_elem = o->check_del(bp, o, + &elem->cmd_data.vlan_mac.u); WARN_ON(!reg_elem); @@ -1675,7 +1691,7 @@ static int bnx2x_execute_vlan_mac(struct bnx2x *bp, if (!restore && ((cmd == BNX2X_VLAN_MAC_ADD) || (cmd == BNX2X_VLAN_MAC_MOVE))) { - reg_elem = o->check_del(cam_obj, + reg_elem = o->check_del(bp, cam_obj, &elem->cmd_data.vlan_mac.u); if (reg_elem) { list_del(®_elem->link); @@ -1750,8 +1766,7 @@ int bnx2x_config_vlan_mac( rc = 1; if (test_bit(RAMROD_DRV_CLR_ONLY, ramrod_flags)) { - DP(BNX2X_MSG_SP, "RAMROD_DRV_CLR_ONLY requested: " - "clearing a pending bit.\n"); + DP(BNX2X_MSG_SP, "RAMROD_DRV_CLR_ONLY requested: clearing a pending bit.\n"); raw->clear_pending(raw); } @@ -2149,12 +2164,10 @@ static int bnx2x_set_rx_mode_e1x(struct bnx2x *bp, mac_filters->unmatched_unicast & ~mask; DP(BNX2X_MSG_SP, "drop_ucast 0x%x\ndrop_mcast 0x%x\n accp_ucast 0x%x\n" - "accp_mcast 0x%x\naccp_bcast 0x%x\n", - mac_filters->ucast_drop_all, - mac_filters->mcast_drop_all, - mac_filters->ucast_accept_all, - mac_filters->mcast_accept_all, - mac_filters->bcast_accept_all); + "accp_mcast 0x%x\naccp_bcast 0x%x\n", + mac_filters->ucast_drop_all, mac_filters->mcast_drop_all, + mac_filters->ucast_accept_all, mac_filters->mcast_accept_all, + mac_filters->bcast_accept_all); /* write the MAC filter structure*/ __storm_memset_mac_filters(bp, mac_filters, p->func_id); @@ -2303,8 +2316,7 @@ static int bnx2x_set_rx_mode_e2(struct bnx2x *bp, */ bnx2x_rx_mode_set_rdata_hdr_e2(p->cid, &data->header, rule_idx); - DP(BNX2X_MSG_SP, "About to configure %d rules, rx_accept_flags 0x%lx, " - "tx_accept_flags 0x%lx\n", + DP(BNX2X_MSG_SP, "About to configure %d rules, rx_accept_flags 0x%lx, tx_accept_flags 0x%lx\n", data->header.rule_cnt, p->rx_accept_flags, p->tx_accept_flags); @@ -2437,8 +2449,8 @@ static int bnx2x_mcast_enqueue_cmd(struct bnx2x *bp, if (!new_cmd) return -ENOMEM; - DP(BNX2X_MSG_SP, "About to enqueue a new %d command. " - "macs_list_len=%d\n", cmd, macs_list_len); + DP(BNX2X_MSG_SP, "About to enqueue a new %d command. macs_list_len=%d\n", + cmd, macs_list_len); INIT_LIST_HEAD(&new_cmd->data.macs_head); @@ -2653,7 +2665,7 @@ static inline void bnx2x_mcast_hdl_pending_add_e2(struct bnx2x *bp, cnt++; DP(BNX2X_MSG_SP, "About to configure %pM mcast MAC\n", - pmac_pos->mac); + pmac_pos->mac); list_del(&pmac_pos->link); @@ -3177,8 +3189,8 @@ static int bnx2x_mcast_validate_e1(struct bnx2x *bp, * matter. */ if (p->mcast_list_len > o->max_cmd_len) { - BNX2X_ERR("Can't configure more than %d multicast MACs" - "on 57710\n", o->max_cmd_len); + BNX2X_ERR("Can't configure more than %d multicast MACs on 57710\n", + o->max_cmd_len); return -EINVAL; } /* Every configured MAC should be cleared if DEL command is @@ -3426,7 +3438,7 @@ static inline int bnx2x_mcast_refresh_registry_e1(struct bnx2x *bp, &data->config_table[i].lsb_mac_addr, elem->mac); DP(BNX2X_MSG_SP, "Adding registry entry for [%pM]\n", - elem->mac); + elem->mac); list_add_tail(&elem->link, &o->registry.exact_match.macs); } @@ -3567,9 +3579,8 @@ int bnx2x_config_mcast(struct bnx2x *bp, if ((!p->mcast_list_len) && (!o->check_sched(o))) return 0; - DP(BNX2X_MSG_SP, "o->total_pending_num=%d p->mcast_list_len=%d " - "o->max_cmd_len=%d\n", o->total_pending_num, - p->mcast_list_len, o->max_cmd_len); + DP(BNX2X_MSG_SP, "o->total_pending_num=%d p->mcast_list_len=%d o->max_cmd_len=%d\n", + o->total_pending_num, p->mcast_list_len, o->max_cmd_len); /* Enqueue the current command to the pending list if we can't complete * it in the current iteration @@ -4294,9 +4305,8 @@ static int bnx2x_queue_comp_cmd(struct bnx2x *bp, unsigned long cur_pending = o->pending; if (!test_and_clear_bit(cmd, &cur_pending)) { - BNX2X_ERR("Bad MC reply %d for queue %d in state %d " - "pending 0x%lx, next_state %d\n", cmd, - o->cids[BNX2X_PRIMARY_CID_INDEX], + BNX2X_ERR("Bad MC reply %d for queue %d in state %d pending 0x%lx, next_state %d\n", + cmd, o->cids[BNX2X_PRIMARY_CID_INDEX], o->state, cur_pending, o->next_state); return -EINVAL; } @@ -4308,13 +4318,13 @@ static int bnx2x_queue_comp_cmd(struct bnx2x *bp, BNX2X_ERR("illegal value for next tx_only: %d. max cos was %d", o->next_tx_only, o->max_cos); - DP(BNX2X_MSG_SP, "Completing command %d for queue %d, " - "setting state to %d\n", cmd, - o->cids[BNX2X_PRIMARY_CID_INDEX], o->next_state); + DP(BNX2X_MSG_SP, + "Completing command %d for queue %d, setting state to %d\n", + cmd, o->cids[BNX2X_PRIMARY_CID_INDEX], o->next_state); if (o->next_tx_only) /* print num tx-only if any exist */ DP(BNX2X_MSG_SP, "primary cid %d: num tx-only cons %d\n", - o->cids[BNX2X_PRIMARY_CID_INDEX], o->next_tx_only); + o->cids[BNX2X_PRIMARY_CID_INDEX], o->next_tx_only); o->state = o->next_state; o->num_tx_only = o->next_tx_only; @@ -4529,8 +4539,10 @@ static void bnx2x_q_fill_setup_tx_only(struct bnx2x *bp, &data->tx, &cmd_params->params.tx_only.flags); - DP(BNX2X_MSG_SP, "cid %d, tx bd page lo %x hi %x\n",cmd_params->q_obj->cids[0], - data->tx.tx_bd_page_base.lo, data->tx.tx_bd_page_base.hi); + DP(BNX2X_MSG_SP, "cid %d, tx bd page lo %x hi %x", + cmd_params->q_obj->cids[0], + data->tx.tx_bd_page_base.lo, + data->tx.tx_bd_page_base.hi); } /** @@ -4677,10 +4689,8 @@ static inline int bnx2x_q_send_setup_tx_only(struct bnx2x *bp, /* Fill the ramrod data */ bnx2x_q_fill_setup_tx_only(bp, params, rdata); - DP(BNX2X_MSG_SP, "sending tx-only ramrod: cid %d, client-id %d," - "sp-client id %d, cos %d\n", - o->cids[cid_index], - rdata->general.client_id, + DP(BNX2X_MSG_SP, "sending tx-only ramrod: cid %d, client-id %d, sp-client id %d, cos %d\n", + o->cids[cid_index], rdata->general.client_id, rdata->general.sp_client_id, rdata->general.cos); /* @@ -5222,9 +5232,9 @@ static inline int bnx2x_func_state_change_comp(struct bnx2x *bp, unsigned long cur_pending = o->pending; if (!test_and_clear_bit(cmd, &cur_pending)) { - BNX2X_ERR("Bad MC reply %d for func %d in state %d " - "pending 0x%lx, next_state %d\n", cmd, BP_FUNC(bp), - o->state, cur_pending, o->next_state); + BNX2X_ERR("Bad MC reply %d for func %d in state %d pending 0x%lx, next_state %d\n", + cmd, BP_FUNC(bp), o->state, + cur_pending, o->next_state); return -EINVAL; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h index 4ce351b4d517..61a7670adfcd 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h @@ -315,7 +315,8 @@ struct bnx2x_vlan_mac_obj { * @return zero if the element may be added */ - int (*check_add)(struct bnx2x_vlan_mac_obj *o, + int (*check_add)(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data); /** @@ -324,7 +325,8 @@ struct bnx2x_vlan_mac_obj { * @return true if the element may be deleted */ struct bnx2x_vlan_mac_registry_elem * - (*check_del)(struct bnx2x_vlan_mac_obj *o, + (*check_del)(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *o, union bnx2x_classification_ramrod_data *data); /** @@ -332,7 +334,8 @@ struct bnx2x_vlan_mac_obj { * * @return true if the element may be deleted */ - bool (*check_move)(struct bnx2x_vlan_mac_obj *src_o, + bool (*check_move)(struct bnx2x *bp, + struct bnx2x_vlan_mac_obj *src_o, struct bnx2x_vlan_mac_obj *dst_o, union bnx2x_classification_ramrod_data *data); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index 4cd4f127fe79..ca1effceff6f 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c @@ -75,7 +75,7 @@ static void bnx2x_storm_stats_post(struct bnx2x *bp) bp->fw_stats_req->hdr.drv_stats_counter = cpu_to_le16(bp->stats_counter++); - DP(NETIF_MSG_TIMER, "Sending statistics ramrod %d\n", + DP(BNX2X_MSG_STATS, "Sending statistics ramrod %d\n", bp->fw_stats_req->hdr.drv_stats_counter); @@ -818,29 +818,29 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) /* are storm stats valid? */ if (le16_to_cpu(counters->xstats_counter) != cur_stats_counter) { - DP(BNX2X_MSG_STATS, "stats not updated by xstorm" - " xstorm counter (0x%x) != stats_counter (0x%x)\n", + DP(BNX2X_MSG_STATS, + "stats not updated by xstorm xstorm counter (0x%x) != stats_counter (0x%x)\n", le16_to_cpu(counters->xstats_counter), bp->stats_counter); return -EAGAIN; } if (le16_to_cpu(counters->ustats_counter) != cur_stats_counter) { - DP(BNX2X_MSG_STATS, "stats not updated by ustorm" - " ustorm counter (0x%x) != stats_counter (0x%x)\n", + DP(BNX2X_MSG_STATS, + "stats not updated by ustorm ustorm counter (0x%x) != stats_counter (0x%x)\n", le16_to_cpu(counters->ustats_counter), bp->stats_counter); return -EAGAIN; } if (le16_to_cpu(counters->cstats_counter) != cur_stats_counter) { - DP(BNX2X_MSG_STATS, "stats not updated by cstorm" - " cstorm counter (0x%x) != stats_counter (0x%x)\n", + DP(BNX2X_MSG_STATS, + "stats not updated by cstorm cstorm counter (0x%x) != stats_counter (0x%x)\n", le16_to_cpu(counters->cstats_counter), bp->stats_counter); return -EAGAIN; } if (le16_to_cpu(counters->tstats_counter) != cur_stats_counter) { - DP(BNX2X_MSG_STATS, "stats not updated by tstorm" - " tstorm counter (0x%x) != stats_counter (0x%x)\n", + DP(BNX2X_MSG_STATS, + "stats not updated by tstorm tstorm counter (0x%x) != stats_counter (0x%x)\n", le16_to_cpu(counters->tstats_counter), bp->stats_counter); return -EAGAIN; } @@ -867,8 +867,7 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) u32 diff; - DP(BNX2X_MSG_STATS, "queue[%d]: ucast_sent 0x%x, " - "bcast_sent 0x%x mcast_sent 0x%x\n", + DP(BNX2X_MSG_STATS, "queue[%d]: ucast_sent 0x%x, bcast_sent 0x%x mcast_sent 0x%x\n", i, xclient->ucast_pkts_sent, xclient->bcast_pkts_sent, xclient->mcast_pkts_sent); @@ -1147,51 +1146,9 @@ static void bnx2x_stats_update(struct bnx2x *bp) if (netif_msg_timer(bp)) { struct bnx2x_eth_stats *estats = &bp->eth_stats; - int i, cos; netdev_dbg(bp->dev, "brb drops %u brb truncate %u\n", estats->brb_drop_lo, estats->brb_truncate_lo); - - for_each_eth_queue(bp, i) { - struct bnx2x_fastpath *fp = &bp->fp[i]; - struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats; - - pr_debug("%s: rx usage(%4u) *rx_cons_sb(%u) rx pkt(%lu) rx calls(%lu %lu)\n", - fp->name, (le16_to_cpu(*fp->rx_cons_sb) - - fp->rx_comp_cons), - le16_to_cpu(*fp->rx_cons_sb), - bnx2x_hilo(&qstats-> - total_unicast_packets_received_hi), - fp->rx_calls, fp->rx_pkt); - } - - for_each_eth_queue(bp, i) { - struct bnx2x_fastpath *fp = &bp->fp[i]; - struct bnx2x_fp_txdata *txdata; - struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats; - struct netdev_queue *txq; - - pr_debug("%s: tx pkt(%lu) (Xoff events %u)", - fp->name, - bnx2x_hilo( - &qstats->total_unicast_packets_transmitted_hi), - qstats->driver_xoff); - - for_each_cos_in_tx_queue(fp, cos) { - txdata = &fp->txdata[cos]; - txq = netdev_get_tx_queue(bp->dev, - FP_COS_TO_TXQ(fp, cos)); - - pr_debug("%d: tx avail(%4u) *tx_cons_sb(%u) tx calls (%lu) %s\n", - cos, - bnx2x_tx_avail(bp, txdata), - le16_to_cpu(*txdata->tx_cons_sb), - txdata->tx_pkt, - (netif_tx_queue_stopped(txq) ? - "Xoff" : "Xon") - ); - } - } } bnx2x_hw_stats_post(bp); -- GitLab From 3b60306690569927951be09160e80a8af9c94db4 Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Sun, 18 Mar 2012 10:33:39 +0000 Subject: [PATCH 1816/1846] bnx2x: reduced sparse warnings This patch reduces sparse warnings in the bnx2x code, mostly by changing functions into static and changing initialization of structures. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 6 +++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 5 +++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 6 +++--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h | 12 ------------ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 16 ++++++++-------- 6 files changed, 18 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index d2fb7ba38143..673bd83b5a26 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1574,7 +1574,7 @@ static inline int bnx2x_init_rss_pf(struct bnx2x *bp) int bnx2x_config_rss_pf(struct bnx2x *bp, u8 *ind_table, bool config_hash) { - struct bnx2x_config_rss_params params = {0}; + struct bnx2x_config_rss_params params = {NULL}; int i; /* Although RSS is meaningless when there is a single HW queue we @@ -1637,7 +1637,7 @@ int bnx2x_config_rss_pf(struct bnx2x *bp, u8 *ind_table, bool config_hash) static inline int bnx2x_init_hw(struct bnx2x *bp, u32 load_code) { - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; /* Prepare parameters for function state transitions */ __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags); @@ -1658,7 +1658,7 @@ static void bnx2x_squeeze_objects(struct bnx2x *bp) { int rc; unsigned long ramrod_flags = 0, vlan_mac_flags = 0; - struct bnx2x_mcast_ramrod_params rparam = {0}; + struct bnx2x_mcast_ramrod_params rparam = {NULL}; struct bnx2x_vlan_mac_obj *mac_obj = &bp->fp->mac_obj; /***************** Cleanup MACs' object first *************************/ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index bba47fb8755c..04d78c02c8cc 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -970,7 +970,7 @@ static inline void bnx2x_reuse_rx_data(struct bnx2x_fastpath *fp, */ static inline int bnx2x_func_start(struct bnx2x *bp) { - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; struct bnx2x_func_start_params *start_params = &func_params.params.start; @@ -1596,6 +1596,7 @@ static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) #endif } +#ifdef BCM_CNIC /** * bnx2x_get_iscsi_info - update iSCSI params according to licensing info. * @@ -1603,7 +1604,7 @@ static inline void bnx2x_bz_fp(struct bnx2x *bp, int index) * */ void bnx2x_get_iscsi_info(struct bnx2x *bp); - +#endif /* returns func by VN for current port */ static inline int func_by_vn(struct bnx2x *bp, int vn) { diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index b19669ab993b..2b806090fa4a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -443,7 +443,7 @@ static void bnx2x_pfc_set_pfc(struct bnx2x *bp) static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp) { - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; func_params.f_obj = &bp->func_obj; func_params.cmd = BNX2X_F_CMD_TX_STOP; @@ -454,7 +454,7 @@ static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp) static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp) { - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; struct bnx2x_func_tx_start_params *tx_params = &func_params.params.tx_start; @@ -529,7 +529,7 @@ static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x *bp) /* * In E3B0 the configuration may have more than 2 COS. */ -void bnx2x_dcbx_update_ets_config(struct bnx2x *bp) +static void bnx2x_dcbx_update_ets_config(struct bnx2x *bp) { struct bnx2x_dcbx_pg_params *ets = &(bp->dcbx_port_params.ets); struct bnx2x_ets_params ets_params = { 0 }; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 3618a00a8144..2cc0a1703970 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -2107,7 +2107,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) /* Send an EMPTY ramrod on the first queue */ static int bnx2x_test_intr(struct bnx2x *bp) { - struct bnx2x_queue_state_params params = {0}; + struct bnx2x_queue_state_params params = {NULL}; if (!netif_running(bp->dev)) { DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h index e5c5982ae06d..cd6dfa9eaa3a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h @@ -243,18 +243,6 @@ (IRO[48].base + ((funcId) * IRO[48].m1)) #define COMMON_ASM_INVALID_ASSERT_OPCODE 0x0 -/** -* This file defines HSI constants for the ETH flow -*/ -#ifdef _EVEREST_MICROCODE -#include "Microcode\Generated\DataTypes\eth_rx_bd.h" -#include "Microcode\Generated\DataTypes\eth_tx_bd.h" -#include "Microcode\Generated\DataTypes\eth_rx_cqe.h" -#include "Microcode\Generated\DataTypes\eth_rx_sge.h" -#include "Microcode\Generated\DataTypes\eth_rx_cqe_next_page.h" -#endif - - /* Ethernet Ring parameters */ #define X_ETH_LOCAL_RING_SIZE 13 #define FIRST_BD_IN_PKT 0 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 5e5367aa5b4d..a626fe87b2a4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -7446,7 +7446,7 @@ int bnx2x_setup_tx_only(struct bnx2x *bp, struct bnx2x_fastpath *fp, int bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp, bool leading) { - struct bnx2x_queue_state_params q_params = {0}; + struct bnx2x_queue_state_params q_params = {NULL}; struct bnx2x_queue_setup_params *setup_params = &q_params.params.setup; struct bnx2x_queue_setup_tx_only_params *tx_only_params = @@ -7529,7 +7529,7 @@ static int bnx2x_stop_queue(struct bnx2x *bp, int index) { struct bnx2x_fastpath *fp = &bp->fp[index]; struct bnx2x_fp_txdata *txdata; - struct bnx2x_queue_state_params q_params = {0}; + struct bnx2x_queue_state_params q_params = {NULL}; int rc, tx_index; DP(NETIF_MSG_IFDOWN, "stopping queue %d cid %d\n", index, fp->cid); @@ -7705,7 +7705,7 @@ static void bnx2x_reset_port(struct bnx2x *bp) static inline int bnx2x_reset_hw(struct bnx2x *bp, u32 load_code) { - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; /* Prepare parameters for function state transitions */ __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags); @@ -7720,7 +7720,7 @@ static inline int bnx2x_reset_hw(struct bnx2x *bp, u32 load_code) static inline int bnx2x_func_stop(struct bnx2x *bp) { - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; int rc; /* Prepare parameters for function state transitions */ @@ -7877,7 +7877,7 @@ static inline int bnx2x_func_wait_started(struct bnx2x *bp) * Failed to complete the transaction in a "good way" * Force both transactions with CLR bit */ - struct bnx2x_func_state_params func_params = {0}; + struct bnx2x_func_state_params func_params = {NULL}; DP(NETIF_MSG_IFDOWN, "Hmmm... unexpected function state! Forcing STARTED-->TX_ST0PPED-->STARTED\n"); @@ -7904,7 +7904,7 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode) int port = BP_PORT(bp); int i, rc = 0; u8 cos; - struct bnx2x_mcast_ramrod_params rparam = {0}; + struct bnx2x_mcast_ramrod_params rparam = {NULL}; u32 reset_code; /* Wait until tx fastpath tasks complete */ @@ -10309,7 +10309,7 @@ static inline int bnx2x_set_uc_list(struct bnx2x *bp) static inline int bnx2x_set_mc_list(struct bnx2x *bp) { struct net_device *dev = bp->dev; - struct bnx2x_mcast_ramrod_params rparam = {0}; + struct bnx2x_mcast_ramrod_params rparam = {NULL}; int rc = 0; rparam.mcast_obj = &bp->mcast_obj; @@ -10830,7 +10830,7 @@ do { \ (u8 *)bp->arr, len); \ } while (0) -int bnx2x_init_firmware(struct bnx2x *bp) +static int bnx2x_init_firmware(struct bnx2x *bp) { const char *fw_file_name; struct bnx2x_fw_file_hdr *fw_hdr; -- GitLab From c315a4ef55b9afa0373fbb10f8567d59f81247c9 Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Sun, 18 Mar 2012 10:33:40 +0000 Subject: [PATCH 1817/1846] bnx2x: removed dcb unused code Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index 2b806090fa4a..e2d68e2239b9 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -121,26 +121,6 @@ static void bnx2x_pfc_clear(struct bnx2x *bp) { struct bnx2x_nig_brb_pfc_port_params nig_params = {0}; nig_params.pause_enable = 1; -#ifdef BNX2X_SAFC - if (bp->flags & SAFC_TX_FLAG) { - u32 high = 0, low = 0; - int i; - - for (i = 0; i < BNX2X_MAX_PRIORITY; i++) { - if (bp->pri_map[i] == 1) - high |= (1 << i); - if (bp->pri_map[i] == 0) - low |= (1 << i); - } - - nig_params.llfc_low_priority_classes = high; - nig_params.llfc_low_priority_classes = low; - - nig_params.pause_enable = 0; - nig_params.llfc_enable = 1; - nig_params.llfc_out_en = 1; - } -#endif /* BNX2X_SAFC */ bnx2x_acquire_phy_lock(bp); bp->link_params.feature_config_flags &= ~FEATURE_CONFIG_PFC_ENABLED; bnx2x_update_pfc(&bp->link_params, &bp->link_vars, &nig_params); -- GitLab From 9d4884f9d470cd696d7a7cd7a6d7099d13909dd9 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 18 Mar 2012 10:33:41 +0000 Subject: [PATCH 1818/1846] bnx2x: changed initial dcb configuration The changes were mostly made to enable back-to-back data flow with dcb. Other changes were simply deemed as a better 'clean' initial configuration. Signed-off-by: Dmitry Kravkov Signed-off-by: Yuval Mintz Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index e2d68e2239b9..fce47a6f88d7 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -925,30 +925,30 @@ void bnx2x_dcbx_init_params(struct bnx2x *bp) bp->dcbx_config_params.admin_application_priority_tx_enable = 1; bp->dcbx_config_params.admin_ets_reco_valid = 1; bp->dcbx_config_params.admin_app_priority_willing = 1; - bp->dcbx_config_params.admin_configuration_bw_precentage[0] = 00; - bp->dcbx_config_params.admin_configuration_bw_precentage[1] = 50; - bp->dcbx_config_params.admin_configuration_bw_precentage[2] = 50; + bp->dcbx_config_params.admin_configuration_bw_precentage[0] = 100; + bp->dcbx_config_params.admin_configuration_bw_precentage[1] = 0; + bp->dcbx_config_params.admin_configuration_bw_precentage[2] = 0; bp->dcbx_config_params.admin_configuration_bw_precentage[3] = 0; bp->dcbx_config_params.admin_configuration_bw_precentage[4] = 0; bp->dcbx_config_params.admin_configuration_bw_precentage[5] = 0; bp->dcbx_config_params.admin_configuration_bw_precentage[6] = 0; bp->dcbx_config_params.admin_configuration_bw_precentage[7] = 0; - bp->dcbx_config_params.admin_configuration_ets_pg[0] = 1; + bp->dcbx_config_params.admin_configuration_ets_pg[0] = 0; bp->dcbx_config_params.admin_configuration_ets_pg[1] = 0; bp->dcbx_config_params.admin_configuration_ets_pg[2] = 0; - bp->dcbx_config_params.admin_configuration_ets_pg[3] = 2; + bp->dcbx_config_params.admin_configuration_ets_pg[3] = 0; bp->dcbx_config_params.admin_configuration_ets_pg[4] = 0; bp->dcbx_config_params.admin_configuration_ets_pg[5] = 0; bp->dcbx_config_params.admin_configuration_ets_pg[6] = 0; bp->dcbx_config_params.admin_configuration_ets_pg[7] = 0; - bp->dcbx_config_params.admin_recommendation_bw_precentage[0] = 0; - bp->dcbx_config_params.admin_recommendation_bw_precentage[1] = 1; - bp->dcbx_config_params.admin_recommendation_bw_precentage[2] = 2; + bp->dcbx_config_params.admin_recommendation_bw_precentage[0] = 100; + bp->dcbx_config_params.admin_recommendation_bw_precentage[1] = 0; + bp->dcbx_config_params.admin_recommendation_bw_precentage[2] = 0; bp->dcbx_config_params.admin_recommendation_bw_precentage[3] = 0; - bp->dcbx_config_params.admin_recommendation_bw_precentage[4] = 7; - bp->dcbx_config_params.admin_recommendation_bw_precentage[5] = 5; - bp->dcbx_config_params.admin_recommendation_bw_precentage[6] = 6; - bp->dcbx_config_params.admin_recommendation_bw_precentage[7] = 7; + bp->dcbx_config_params.admin_recommendation_bw_precentage[4] = 0; + bp->dcbx_config_params.admin_recommendation_bw_precentage[5] = 0; + bp->dcbx_config_params.admin_recommendation_bw_precentage[6] = 0; + bp->dcbx_config_params.admin_recommendation_bw_precentage[7] = 0; bp->dcbx_config_params.admin_recommendation_ets_pg[0] = 0; bp->dcbx_config_params.admin_recommendation_ets_pg[1] = 1; bp->dcbx_config_params.admin_recommendation_ets_pg[2] = 2; @@ -957,25 +957,12 @@ void bnx2x_dcbx_init_params(struct bnx2x *bp) bp->dcbx_config_params.admin_recommendation_ets_pg[5] = 5; bp->dcbx_config_params.admin_recommendation_ets_pg[6] = 6; bp->dcbx_config_params.admin_recommendation_ets_pg[7] = 7; - bp->dcbx_config_params.admin_pfc_bitmap = 0x8; /* FCoE(3) enable */ - bp->dcbx_config_params.admin_priority_app_table[0].valid = 1; - bp->dcbx_config_params.admin_priority_app_table[1].valid = 1; + bp->dcbx_config_params.admin_pfc_bitmap = 0x0; + bp->dcbx_config_params.admin_priority_app_table[0].valid = 0; + bp->dcbx_config_params.admin_priority_app_table[1].valid = 0; bp->dcbx_config_params.admin_priority_app_table[2].valid = 0; bp->dcbx_config_params.admin_priority_app_table[3].valid = 0; - bp->dcbx_config_params.admin_priority_app_table[0].priority = 3; - bp->dcbx_config_params.admin_priority_app_table[1].priority = 0; - bp->dcbx_config_params.admin_priority_app_table[2].priority = 0; - bp->dcbx_config_params.admin_priority_app_table[3].priority = 0; - bp->dcbx_config_params.admin_priority_app_table[0].traffic_type = 0; - bp->dcbx_config_params.admin_priority_app_table[1].traffic_type = 1; - bp->dcbx_config_params.admin_priority_app_table[2].traffic_type = 0; - bp->dcbx_config_params.admin_priority_app_table[3].traffic_type = 0; - bp->dcbx_config_params.admin_priority_app_table[0].app_id = 0x8906; - bp->dcbx_config_params.admin_priority_app_table[1].app_id = 3260; - bp->dcbx_config_params.admin_priority_app_table[2].app_id = 0; - bp->dcbx_config_params.admin_priority_app_table[3].app_id = 0; - bp->dcbx_config_params.admin_default_priority = - bp->dcbx_config_params.admin_priority_app_table[1].priority; + bp->dcbx_config_params.admin_default_priority = 0; } void bnx2x_dcbx_init(struct bnx2x *bp) -- GitLab From 910b220290a4568ebf7ecc368bd3d1d8236d2335 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 18 Mar 2012 10:33:42 +0000 Subject: [PATCH 1819/1846] bnx2x: added TLV_NOT_FOUND flags to the dcb The new error flags are supported by the bnx2x FW. Signed-off-by: Dmitry Kravkov Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- .../net/ethernet/broadcom/bnx2x/bnx2x_dcb.c | 21 ++++++++++++------- .../net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 3 +++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c index fce47a6f88d7..4f9244bd7530 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c @@ -206,8 +206,11 @@ static void bnx2x_dcbx_get_ap_feature(struct bnx2x *bp, if (GET_FLAGS(error, DCBX_LOCAL_APP_MISMATCH)) DP(BNX2X_MSG_DCB, "DCBX_LOCAL_APP_MISMATCH\n"); + if (GET_FLAGS(error, DCBX_REMOTE_APP_TLV_NOT_FOUND)) + DP(BNX2X_MSG_DCB, "DCBX_REMOTE_APP_TLV_NOT_FOUND\n"); if (app->enabled && - !GET_FLAGS(error, DCBX_LOCAL_APP_ERROR | DCBX_LOCAL_APP_MISMATCH)) { + !GET_FLAGS(error, DCBX_LOCAL_APP_ERROR | DCBX_LOCAL_APP_MISMATCH | + DCBX_REMOTE_APP_TLV_NOT_FOUND)) { bp->dcbx_port_params.app.enabled = true; @@ -258,6 +261,8 @@ static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp, if (GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR)) DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_ERROR\n"); + if (GET_FLAGS(error, DCBX_REMOTE_ETS_TLV_NOT_FOUND)) + DP(BNX2X_MSG_DCB, "DCBX_REMOTE_ETS_TLV_NOT_FOUND\n"); /* Clean up old settings of ets on COS */ for (i = 0; i < ARRAY_SIZE(bp->dcbx_port_params.ets.cos_params) ; i++) { @@ -267,9 +272,9 @@ static void bnx2x_dcbx_get_ets_feature(struct bnx2x *bp, cos_params[i].pri_bitmask = 0; } - if (bp->dcbx_port_params.app.enabled && - !GET_FLAGS(error, DCBX_LOCAL_ETS_ERROR) && - ets->enabled) { + if (bp->dcbx_port_params.app.enabled && ets->enabled && + !GET_FLAGS(error, + DCBX_LOCAL_ETS_ERROR | DCBX_REMOTE_ETS_TLV_NOT_FOUND)) { DP(BNX2X_MSG_DCB, "DCBX_LOCAL_ETS_ENABLE\n"); bp->dcbx_port_params.ets.enabled = true; @@ -301,9 +306,11 @@ static void bnx2x_dcbx_get_pfc_feature(struct bnx2x *bp, if (GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR)) DP(BNX2X_MSG_DCB, "DCBX_LOCAL_PFC_ERROR\n"); - if (bp->dcbx_port_params.app.enabled && - !GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR | DCBX_LOCAL_PFC_MISMATCH) && - pfc->enabled) { + if (GET_FLAGS(error, DCBX_REMOTE_PFC_TLV_NOT_FOUND)) + DP(BNX2X_MSG_DCB, "DCBX_REMOTE_PFC_TLV_NOT_FOUND\n"); + if (bp->dcbx_port_params.app.enabled && pfc->enabled && + !GET_FLAGS(error, DCBX_LOCAL_PFC_ERROR | DCBX_LOCAL_PFC_MISMATCH | + DCBX_REMOTE_PFC_TLV_NOT_FOUND)) { bp->dcbx_port_params.pfc.enabled = true; bp->dcbx_port_params.pfc.priority_non_pauseable_mask = ~(pfc->pri_en_bitmap); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h index a1413ad7757d..0c5f1211559a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h @@ -1833,6 +1833,9 @@ struct lldp_local_mib { #define DCBX_LOCAL_PFC_MISMATCH 0x00000010 #define DCBX_LOCAL_APP_MISMATCH 0x00000020 #define DCBX_REMOTE_MIB_ERROR 0x00000040 + #define DCBX_REMOTE_ETS_TLV_NOT_FOUND 0x00000080 + #define DCBX_REMOTE_PFC_TLV_NOT_FOUND 0x00000100 + #define DCBX_REMOTE_APP_TLV_NOT_FOUND 0x00000200 struct dcbx_features features; u32 suffix_seq_num; }; -- GitLab From 9e62e912e56742af7eb7e0eeba3c7af4bb2f8537 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 18 Mar 2012 10:33:43 +0000 Subject: [PATCH 1820/1846] bnx2x: changed iscsi/fcoe mac init and macros This includes changes in macros to better distinguish between the two protocols, and slightly changed the way their macs are set. Notice this file contains string print lines with more than 80 characters, as to not break prints. Signed-off-by: Dmitry Kravkov Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 16 +++- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 8 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 82 +++++++++++-------- 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index f534bf132373..562cec34932d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -2117,14 +2117,22 @@ void bnx2x_set_ethtool_ops(struct net_device *netdev); void bnx2x_notify_link_changed(struct bnx2x *bp); -#define BNX2X_MF_PROTOCOL(bp) \ +#define BNX2X_MF_SD_PROTOCOL(bp) \ ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK) #ifdef BCM_CNIC -#define BNX2X_IS_MF_PROTOCOL_ISCSI(bp) \ - (BNX2X_MF_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI) +#define BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) \ + (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI) -#define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_PROTOCOL_ISCSI(bp)) +#define BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp) \ + (BNX2X_MF_SD_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_FCOE) + +#define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp)) +#define IS_MF_FCOE_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)) + +#define IS_MF_STORAGE_SD(bp) (IS_MF_SD(bp) && \ + (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp) || \ + BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp))) #endif #endif /* bnx2x.h */ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 673bd83b5a26..f1f3ca65667a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -1453,8 +1453,8 @@ void bnx2x_set_num_queues(struct bnx2x *bp) } #ifdef BCM_CNIC - /* override in ISCSI SD mod */ - if (IS_MF_ISCSI_SD(bp)) + /* override in STORAGE SD mode */ + if (IS_MF_STORAGE_SD(bp)) bp->num_queues = 1; #endif /* Add special queues */ @@ -3077,7 +3077,7 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p) } #ifdef BCM_CNIC - if (IS_MF_ISCSI_SD(bp) && !is_zero_ether_addr(addr->sa_data)) { + if (IS_MF_STORAGE_SD(bp) && !is_zero_ether_addr(addr->sa_data)) { BNX2X_ERR("Can't configure non-zero address on iSCSI or FCoE functions in MF-SD mode\n"); return -EINVAL; } @@ -3199,7 +3199,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index) int rx_ring_size = 0; #ifdef BCM_CNIC - if (!bp->rx_ring_size && IS_MF_ISCSI_SD(bp)) { + if (!bp->rx_ring_size && IS_MF_STORAGE_SD(bp)) { rx_ring_size = MIN_RX_SIZE_NONTPA; bp->rx_ring_size = rx_ring_size; } else diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h index 04d78c02c8cc..8b163388659a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h @@ -1664,7 +1664,7 @@ static inline bool bnx2x_is_valid_ether_addr(struct bnx2x *bp, u8 *addr) if (is_valid_ether_addr(addr)) return true; #ifdef BCM_CNIC - if (is_zero_ether_addr(addr) && IS_MF_ISCSI_SD(bp)) + if (is_zero_ether_addr(addr) && IS_MF_STORAGE_SD(bp)) return true; #endif return false; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index a626fe87b2a4..df350708022e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -7177,7 +7177,7 @@ int bnx2x_set_eth_mac(struct bnx2x *bp, bool set) unsigned long ramrod_flags = 0; #ifdef BCM_CNIC - if (is_zero_ether_addr(bp->dev->dev_addr) && IS_MF_ISCSI_SD(bp)) { + if (is_zero_ether_addr(bp->dev->dev_addr) && IS_MF_STORAGE_SD(bp)) { DP(NETIF_MSG_IFUP | NETIF_MSG_IFDOWN, "Ignoring Zero MAC for STORAGE SD mode\n"); return 0; @@ -9479,6 +9479,7 @@ static void __devinit bnx2x_get_port_hwinfo(struct bnx2x *bp) void bnx2x_get_iscsi_info(struct bnx2x *bp) { + u32 no_flags = NO_ISCSI_FLAG; #ifdef BCM_CNIC int port = BP_PORT(bp); @@ -9498,12 +9499,28 @@ void bnx2x_get_iscsi_info(struct bnx2x *bp) * disable the feature. */ if (!bp->cnic_eth_dev.max_iscsi_conn) - bp->flags |= NO_ISCSI_FLAG; + bp->flags |= no_flags; #else - bp->flags |= NO_ISCSI_FLAG; + bp->flags |= no_flags; #endif } +#ifdef BCM_CNIC +static void __devinit bnx2x_get_ext_wwn_info(struct bnx2x *bp, int func) +{ + /* Port info */ + bp->cnic_eth_dev.fcoe_wwn_port_name_hi = + MF_CFG_RD(bp, func_ext_config[func].fcoe_wwn_port_name_upper); + bp->cnic_eth_dev.fcoe_wwn_port_name_lo = + MF_CFG_RD(bp, func_ext_config[func].fcoe_wwn_port_name_lower); + + /* Node info */ + bp->cnic_eth_dev.fcoe_wwn_node_name_hi = + MF_CFG_RD(bp, func_ext_config[func].fcoe_wwn_node_name_upper); + bp->cnic_eth_dev.fcoe_wwn_node_name_lo = + MF_CFG_RD(bp, func_ext_config[func].fcoe_wwn_node_name_lower); +} +#endif static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp) { #ifdef BCM_CNIC @@ -9546,24 +9563,11 @@ static void __devinit bnx2x_get_fcoe_info(struct bnx2x *bp) * Read the WWN info only if the FCoE feature is enabled for * this function. */ - if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) { - /* Port info */ - bp->cnic_eth_dev.fcoe_wwn_port_name_hi = - MF_CFG_RD(bp, func_ext_config[func]. - fcoe_wwn_port_name_upper); - bp->cnic_eth_dev.fcoe_wwn_port_name_lo = - MF_CFG_RD(bp, func_ext_config[func]. - fcoe_wwn_port_name_lower); - - /* Node info */ - bp->cnic_eth_dev.fcoe_wwn_node_name_hi = - MF_CFG_RD(bp, func_ext_config[func]. - fcoe_wwn_node_name_upper); - bp->cnic_eth_dev.fcoe_wwn_node_name_lo = - MF_CFG_RD(bp, func_ext_config[func]. - fcoe_wwn_node_name_lower); - } - } + if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) + bnx2x_get_ext_wwn_info(bp, func); + + } else if (IS_MF_FCOE_SD(bp)) + bnx2x_get_ext_wwn_info(bp, func); BNX2X_DEV_INFO("max_fcoe_conn 0x%x\n", bp->cnic_eth_dev.max_fcoe_conn); @@ -9616,8 +9620,11 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) /* * iSCSI and FCoE NPAR MACs: if there is no either iSCSI or * FCoE MAC then the appropriate feature should be disabled. + * + * In non SD mode features configuration comes from + * struct func_ext_config. */ - if (IS_MF_SI(bp)) { + if (!IS_MF_SD(bp)) { u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg); if (cfg & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD) { val2 = MF_CFG_RD(bp, func_ext_config[func]. @@ -9641,16 +9648,25 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) } else bp->flags |= NO_FCOE_FLAG; - } else { /* SD mode */ - if (BNX2X_IS_MF_PROTOCOL_ISCSI(bp)) { - /* use primary mac as iscsi mac */ - memcpy(iscsi_mac, bp->dev->dev_addr, ETH_ALEN); + } else { /* SD MODE */ + if (IS_MF_STORAGE_SD(bp)) { + if (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp)) { + /* use primary mac as iscsi mac */ + memcpy(iscsi_mac, bp->dev->dev_addr, + ETH_ALEN); + + BNX2X_DEV_INFO("SD ISCSI MODE\n"); + BNX2X_DEV_INFO("Read iSCSI MAC: %pM\n", + iscsi_mac); + } else { /* FCoE */ + memcpy(fip_mac, bp->dev->dev_addr, + ETH_ALEN); + BNX2X_DEV_INFO("SD FCoE MODE\n"); + BNX2X_DEV_INFO("Read FIP MAC: %pM\n", + fip_mac); + } /* Zero primary MAC configuration */ memset(bp->dev->dev_addr, 0, ETH_ALEN); - - BNX2X_DEV_INFO("SD ISCSI MODE\n"); - BNX2X_DEV_INFO("Read iSCSI MAC: %pM\n", - iscsi_mac); } } #endif @@ -9679,10 +9695,6 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp) memcpy(bp->dev->perm_addr, bp->dev->dev_addr, ETH_ALEN); #ifdef BCM_CNIC - /* Set the FCoE MAC in MF_SD mode */ - if (!CHIP_IS_E1x(bp) && IS_MF_SD(bp)) - memcpy(fip_mac, bp->dev->dev_addr, ETH_ALEN); - /* Disable iSCSI if MAC configuration is * invalid. */ @@ -10092,7 +10104,7 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp) bp->disable_tpa = disable_tpa; #ifdef BCM_CNIC - bp->disable_tpa |= IS_MF_ISCSI_SD(bp); + bp->disable_tpa |= IS_MF_STORAGE_SD(bp); #endif /* Set TPA flags */ -- GitLab From cb4dca277694f6c53bf6daf0f5c609dda32e4656 Mon Sep 17 00:00:00 2001 From: Yuval Mintz Date: Sun, 18 Mar 2012 10:33:44 +0000 Subject: [PATCH 1821/1846] bnx2x: consistent statistics for old FW Previously applied patch making the bnx2x statistics consistent did not apply to old FWs. This remedies it, extending the consistent behaviour to all drivers. Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Reported-by: Michal Schmidt Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 1 + .../net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 39 ++----------------- .../net/ethernet/broadcom/bnx2x/bnx2x_stats.h | 7 +--- 3 files changed, 6 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 562cec34932d..e37161f19250 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h @@ -1482,6 +1482,7 @@ struct bnx2x { u16 stats_counter; struct bnx2x_eth_stats eth_stats; + struct host_func_stats func_stats; struct bnx2x_eth_stats_old eth_stats_old; struct bnx2x_net_stats_old net_stats_old; struct bnx2x_fw_port_stats_old fw_stats_old; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index ca1effceff6f..e1c9310fb07c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c @@ -128,6 +128,8 @@ static void bnx2x_hw_stats_post(struct bnx2x *bp) } else if (bp->func_stx) { *stats_comp = 0; + memcpy(bnx2x_sp(bp, func_stats), &bp->func_stats, + sizeof(bp->func_stats)); bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp)); } } @@ -802,7 +804,7 @@ static int bnx2x_storm_stats_update(struct bnx2x *bp) &bp->fw_stats_data->port.tstorm_port_statistics; struct tstorm_per_pf_stats *tfunc = &bp->fw_stats_data->pf.tstorm_pf_statistics; - struct host_func_stats *fstats = bnx2x_sp(bp, func_stats); + struct host_func_stats *fstats = &bp->func_stats; struct bnx2x_eth_stats *estats = &bp->eth_stats; struct bnx2x_eth_stats_old *estats_old = &bp->eth_stats_old; struct stats_counter *counters = &bp->fw_stats_data->storm_counters; @@ -1307,36 +1309,6 @@ static void bnx2x_port_stats_base_init(struct bnx2x *bp) bnx2x_stats_comp(bp); } -static void bnx2x_func_stats_base_update(struct bnx2x *bp) -{ - struct dmae_command *dmae = &bp->stats_dmae; - u32 *stats_comp = bnx2x_sp(bp, stats_comp); - - /* sanity */ - if (!bp->func_stx) { - BNX2X_ERR("BUG!\n"); - return; - } - - bp->executer_idx = 0; - memset(dmae, 0, sizeof(struct dmae_command)); - - dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, - true, DMAE_COMP_PCI); - dmae->src_addr_lo = bp->func_stx >> 2; - dmae->src_addr_hi = 0; - dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); - dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); - dmae->len = sizeof(struct host_func_stats) >> 2; - dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); - dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); - dmae->comp_val = DMAE_COMP_VAL; - - *stats_comp = 0; - bnx2x_hw_stats_post(bp); - bnx2x_stats_comp(bp); -} - /** * This function will prepare the statistics ramrod data the way * we will only have to increment the statistics counter and @@ -1528,6 +1500,7 @@ void bnx2x_stats_init(struct bnx2x *bp) memset(&bp->fw_stats_old, 0, sizeof(bp->fw_stats_old)); memset(&bp->eth_stats_old, 0, sizeof(bp->eth_stats_old)); memset(&bp->eth_stats, 0, sizeof(bp->eth_stats)); + memset(&bp->func_stats, 0, sizeof(bp->func_stats)); /* Clean SP from previous statistics */ if (bp->func_stx) { @@ -1544,10 +1517,6 @@ void bnx2x_stats_init(struct bnx2x *bp) if (bp->port.pmf && bp->port.port_stx) bnx2x_port_stats_base_init(bp); - /* On a non-init, retrieve previous statistics from SP */ - if (!bp->stats_init && bp->func_stx) - bnx2x_func_stats_base_update(bp); - /* mark the end of statistics initializiation */ bp->stats_init = false; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h index 39ffd6dcdf1a..2b46e1eb7fd1 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h @@ -421,12 +421,7 @@ struct bnx2x_fw_port_stats_old { do { \ diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \ old_uclient->s = uclient->s; \ - } while (0) - -#define UPDATE_EXTEND_E_USTAT(s, t) \ - do { \ - UPDATE_EXTEND_USTAT(s, t); \ - ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \ + ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ } while (0) #define UPDATE_EXTEND_E_USTAT(s, t) \ -- GitLab From de1288041d01120559d53ebd98e0f92476ee56d3 Mon Sep 17 00:00:00 2001 From: Dmitry Kravkov Date: Sun, 18 Mar 2012 10:33:45 +0000 Subject: [PATCH 1822/1846] bnx2x: validate FW trace prior to its printing Signed-off-by: Dmitry Kravkov Signed-off-by: Yuval Mintz Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 2 ++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h index 0c5f1211559a..5d71b7d43237 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h @@ -1129,6 +1129,8 @@ struct shm_dev_info { /* size */ #define FW_ACK_NUM_OF_POLL (FW_ACK_TIME_OUT_MS/FW_ACK_POLL_TIME_MS) +#define MFW_TRACE_SIGNATURE 0x54524342 + /**************************************************************************** * Driver <-> FW Mailbox * ****************************************************************************/ diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index df350708022e..f7f9aa807264 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -719,7 +719,17 @@ void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl) trace_shmem_base = bp->common.shmem_base; else trace_shmem_base = SHMEM2_RD(bp, other_shmem_base_addr); - addr = trace_shmem_base - 0x0800 + 4; + addr = trace_shmem_base - 0x800; + + /* validate TRCB signature */ + mark = REG_RD(bp, addr); + if (mark != MFW_TRACE_SIGNATURE) { + BNX2X_ERR("Trace buffer signature is missing."); + return ; + } + + /* read cyclic buffer pointer */ + addr += 4; mark = REG_RD(bp, addr); mark = (CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH) + ((mark + 0x3) & ~0x3) - 0x08000000; -- GitLab From e86b291962cbf477e35d983d312428cf737bc0f8 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Sun, 18 Mar 2012 11:06:44 +0000 Subject: [PATCH 1823/1846] tcp: introduce tcp_data_queue_ofo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split tcp_data_queue() in two parts for better readability. tcp_data_queue_ofo() is responsible for queueing incoming skb into out of order queue. Change code layout so that the skb_set_owner_r() is performed only if skb is not dropped. This is a preliminary patch before "reduce out_of_order memory use" following patch. Signed-off-by: Eric Dumazet Cc: Neal Cardwell Cc: Yuchung Cheng Cc: H.K. Jerry Chu Cc: Tom Herbert Cc: Ilpo Järvinen Acked-by: Neal Cardwell Signed-off-by: David S. Miller --- net/ipv4/tcp_input.c | 214 +++++++++++++++++++++++-------------------- 1 file changed, 115 insertions(+), 99 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 68d4057cba00..fa7de12c4a52 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4446,6 +4446,120 @@ static inline int tcp_try_rmem_schedule(struct sock *sk, unsigned int size) return 0; } +static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) +{ + struct tcp_sock *tp = tcp_sk(sk); + struct sk_buff *skb1; + u32 seq, end_seq; + + TCP_ECN_check_ce(tp, skb); + + if (tcp_try_rmem_schedule(sk, skb->truesize)) { + /* TODO: should increment a counter */ + __kfree_skb(skb); + return; + } + + /* Disable header prediction. */ + tp->pred_flags = 0; + inet_csk_schedule_ack(sk); + + SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n", + tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); + + skb1 = skb_peek_tail(&tp->out_of_order_queue); + if (!skb1) { + /* Initial out of order segment, build 1 SACK. */ + if (tcp_is_sack(tp)) { + tp->rx_opt.num_sacks = 1; + tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq; + tp->selective_acks[0].end_seq = + TCP_SKB_CB(skb)->end_seq; + } + __skb_queue_head(&tp->out_of_order_queue, skb); + goto end; + } + + seq = TCP_SKB_CB(skb)->seq; + end_seq = TCP_SKB_CB(skb)->end_seq; + + if (seq == TCP_SKB_CB(skb1)->end_seq) { + __skb_queue_after(&tp->out_of_order_queue, skb1, skb); + + if (!tp->rx_opt.num_sacks || + tp->selective_acks[0].end_seq != seq) + goto add_sack; + + /* Common case: data arrive in order after hole. */ + tp->selective_acks[0].end_seq = end_seq; + goto end; + } + + /* Find place to insert this segment. */ + while (1) { + if (!after(TCP_SKB_CB(skb1)->seq, seq)) + break; + if (skb_queue_is_first(&tp->out_of_order_queue, skb1)) { + skb1 = NULL; + break; + } + skb1 = skb_queue_prev(&tp->out_of_order_queue, skb1); + } + + /* Do skb overlap to previous one? */ + if (skb1 && before(seq, TCP_SKB_CB(skb1)->end_seq)) { + if (!after(end_seq, TCP_SKB_CB(skb1)->end_seq)) { + /* All the bits are present. Drop. */ + __kfree_skb(skb); + skb = NULL; + tcp_dsack_set(sk, seq, end_seq); + goto add_sack; + } + if (after(seq, TCP_SKB_CB(skb1)->seq)) { + /* Partial overlap. */ + tcp_dsack_set(sk, seq, + TCP_SKB_CB(skb1)->end_seq); + } else { + if (skb_queue_is_first(&tp->out_of_order_queue, + skb1)) + skb1 = NULL; + else + skb1 = skb_queue_prev( + &tp->out_of_order_queue, + skb1); + } + } + if (!skb1) + __skb_queue_head(&tp->out_of_order_queue, skb); + else + __skb_queue_after(&tp->out_of_order_queue, skb1, skb); + + /* And clean segments covered by new one as whole. */ + while (!skb_queue_is_last(&tp->out_of_order_queue, skb)) { + skb1 = skb_queue_next(&tp->out_of_order_queue, skb); + + if (!after(end_seq, TCP_SKB_CB(skb1)->seq)) + break; + if (before(end_seq, TCP_SKB_CB(skb1)->end_seq)) { + tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq, + end_seq); + break; + } + __skb_unlink(skb1, &tp->out_of_order_queue); + tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq, + TCP_SKB_CB(skb1)->end_seq); + __kfree_skb(skb1); + } + +add_sack: + if (tcp_is_sack(tp)) + tcp_sack_new_ofo_skb(sk, seq, end_seq); +end: + if (skb) + skb_set_owner_r(skb, sk); +} + + static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) { const struct tcphdr *th = tcp_hdr(skb); @@ -4561,105 +4675,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) goto queue_and_out; } - TCP_ECN_check_ce(tp, skb); - - if (tcp_try_rmem_schedule(sk, skb->truesize)) - goto drop; - - /* Disable header prediction. */ - tp->pred_flags = 0; - inet_csk_schedule_ack(sk); - - SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n", - tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); - - skb_set_owner_r(skb, sk); - - if (!skb_peek(&tp->out_of_order_queue)) { - /* Initial out of order segment, build 1 SACK. */ - if (tcp_is_sack(tp)) { - tp->rx_opt.num_sacks = 1; - tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq; - tp->selective_acks[0].end_seq = - TCP_SKB_CB(skb)->end_seq; - } - __skb_queue_head(&tp->out_of_order_queue, skb); - } else { - struct sk_buff *skb1 = skb_peek_tail(&tp->out_of_order_queue); - u32 seq = TCP_SKB_CB(skb)->seq; - u32 end_seq = TCP_SKB_CB(skb)->end_seq; - - if (seq == TCP_SKB_CB(skb1)->end_seq) { - __skb_queue_after(&tp->out_of_order_queue, skb1, skb); - - if (!tp->rx_opt.num_sacks || - tp->selective_acks[0].end_seq != seq) - goto add_sack; - - /* Common case: data arrive in order after hole. */ - tp->selective_acks[0].end_seq = end_seq; - return; - } - - /* Find place to insert this segment. */ - while (1) { - if (!after(TCP_SKB_CB(skb1)->seq, seq)) - break; - if (skb_queue_is_first(&tp->out_of_order_queue, skb1)) { - skb1 = NULL; - break; - } - skb1 = skb_queue_prev(&tp->out_of_order_queue, skb1); - } - - /* Do skb overlap to previous one? */ - if (skb1 && before(seq, TCP_SKB_CB(skb1)->end_seq)) { - if (!after(end_seq, TCP_SKB_CB(skb1)->end_seq)) { - /* All the bits are present. Drop. */ - __kfree_skb(skb); - tcp_dsack_set(sk, seq, end_seq); - goto add_sack; - } - if (after(seq, TCP_SKB_CB(skb1)->seq)) { - /* Partial overlap. */ - tcp_dsack_set(sk, seq, - TCP_SKB_CB(skb1)->end_seq); - } else { - if (skb_queue_is_first(&tp->out_of_order_queue, - skb1)) - skb1 = NULL; - else - skb1 = skb_queue_prev( - &tp->out_of_order_queue, - skb1); - } - } - if (!skb1) - __skb_queue_head(&tp->out_of_order_queue, skb); - else - __skb_queue_after(&tp->out_of_order_queue, skb1, skb); - - /* And clean segments covered by new one as whole. */ - while (!skb_queue_is_last(&tp->out_of_order_queue, skb)) { - skb1 = skb_queue_next(&tp->out_of_order_queue, skb); - - if (!after(end_seq, TCP_SKB_CB(skb1)->seq)) - break; - if (before(end_seq, TCP_SKB_CB(skb1)->end_seq)) { - tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq, - end_seq); - break; - } - __skb_unlink(skb1, &tp->out_of_order_queue); - tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq, - TCP_SKB_CB(skb1)->end_seq); - __kfree_skb(skb1); - } - -add_sack: - if (tcp_is_sack(tp)) - tcp_sack_new_ofo_skb(sk, seq, end_seq); - } + tcp_data_queue_ofo(sk, skb); } static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb, -- GitLab From c8628155ece363487b57d33441ea0359018c0fa7 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Sun, 18 Mar 2012 11:07:47 +0000 Subject: [PATCH 1824/1846] tcp: reduce out_of_order memory use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With increasing receive window sizes, but speed of light not improved that much, out of order queue can contain a huge number of skbs, waiting to be moved to receive_queue when missing packets can fill the holes. Some devices happen to use fat skbs (truesize of 4096 + sizeof(struct sk_buff)) to store regular (MTU <= 1500) frames. This makes highly probable sk_rmem_alloc hits sk_rcvbuf limit, which can be 4Mbytes in many cases. When limit is hit, tcp stack calls tcp_collapse_ofo_queue(), a true latency killer and cpu cache blower. Doing the coalescing attempt each time we add a frame in ofo queue permits to keep memory use tight and in many cases avoid the tcp_collapse() thing later. Tested on various wireless setups (b43, ath9k, ...) known to use big skb truesize, this patch removed the "packets collapsed in receive queue due to low socket buffer" I had before. This also reduced average memory used by tcp sockets. With help from Neal Cardwell. Signed-off-by: Eric Dumazet Cc: Neal Cardwell Cc: Yuchung Cheng Cc: H.K. Jerry Chu Cc: Tom Herbert Cc: Ilpo Järvinen Acked-by: Neal Cardwell Signed-off-by: David S. Miller --- include/linux/snmp.h | 1 + net/ipv4/proc.c | 1 + net/ipv4/tcp_input.c | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/linux/snmp.h b/include/linux/snmp.h index 8ee8af4e6da9..2e68f5ba0389 100644 --- a/include/linux/snmp.h +++ b/include/linux/snmp.h @@ -233,6 +233,7 @@ enum LINUX_MIB_TCPREQQFULLDOCOOKIES, /* TCPReqQFullDoCookies */ LINUX_MIB_TCPREQQFULLDROP, /* TCPReqQFullDrop */ LINUX_MIB_TCPRETRANSFAIL, /* TCPRetransFail */ + LINUX_MIB_TCPRCVCOALESCE, /* TCPRcvCoalesce */ __LINUX_MIB_MAX }; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 02d61079f08b..8af0d44e4e22 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -257,6 +257,7 @@ static const struct snmp_mib snmp4_net_list[] = { SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES), SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP), SNMP_MIB_ITEM("TCPRetransFail", LINUX_MIB_TCPRETRANSFAIL), + SNMP_MIB_ITEM("TCPRcvCoalesce", LINUX_MIB_TCPRCVCOALESCE), SNMP_MIB_SENTINEL }; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index fa7de12c4a52..e886e2f7fa8d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4484,7 +4484,24 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) end_seq = TCP_SKB_CB(skb)->end_seq; if (seq == TCP_SKB_CB(skb1)->end_seq) { - __skb_queue_after(&tp->out_of_order_queue, skb1, skb); + /* Packets in ofo can stay in queue a long time. + * Better try to coalesce them right now + * to avoid future tcp_collapse_ofo_queue(), + * probably the most expensive function in tcp stack. + */ + if (skb->len <= skb_tailroom(skb1) && !tcp_hdr(skb)->fin) { + NET_INC_STATS_BH(sock_net(sk), + LINUX_MIB_TCPRCVCOALESCE); + BUG_ON(skb_copy_bits(skb, 0, + skb_put(skb1, skb->len), + skb->len)); + TCP_SKB_CB(skb1)->end_seq = end_seq; + TCP_SKB_CB(skb1)->ack_seq = TCP_SKB_CB(skb)->ack_seq; + __kfree_skb(skb); + skb = NULL; + } else { + __skb_queue_after(&tp->out_of_order_queue, skb1, skb); + } if (!tp->rx_opt.num_sacks || tp->selective_acks[0].end_seq != seq) -- GitLab From a3f671b3152919e72af261333402c0f1272bdf59 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 18 Mar 2012 17:37:56 +0000 Subject: [PATCH 1825/1846] if_vlan: Remove VLAN_ETH_ALEN define and the 1 use of it Just use ETH_ALEN. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- include/linux/if_vlan.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 13aff1e2183b..33a6e1951d4d 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -18,10 +18,9 @@ #include #include -#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header) - * that VLAN requires. +#define VLAN_HLEN 4 /* The additional bytes required by VLAN + * (in addition to the Ethernet header) */ -#define VLAN_ETH_ALEN 6 /* Octets in one ethernet addr */ #define VLAN_ETH_HLEN 18 /* Total octets in header. */ #define VLAN_ETH_ZLEN 64 /* Min. octets in frame sans FCS */ @@ -177,7 +176,7 @@ static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci) veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN); /* Move the mac addresses to the beginning of the new header. */ - memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN); + memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN); skb->mac_header -= VLAN_HLEN; /* first, the ethernet type */ -- GitLab From c81f212450e4d85ed1ed3777316e8355caeb3848 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 18 Mar 2012 17:37:57 +0000 Subject: [PATCH 1826/1846] atlx: Use ETH_ALEN No need for yet another #define for this. Convert NODE_ADDRESS_SIZE use to ETH_ALEN and remove #define. Use memcpy instead of a loop to copy an address. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/ethernet/atheros/atlx/atl2.c | 13 +++++-------- drivers/net/ethernet/atheros/atlx/atl2.h | 5 ++--- drivers/net/ethernet/atheros/atlx/atlx.h | 1 - 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index 071f4c858969..6762dc406b25 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c @@ -2258,7 +2258,7 @@ static int get_permanent_address(struct atl2_hw *hw) u32 Addr[2]; u32 i, Control; u16 Register; - u8 EthAddr[NODE_ADDRESS_SIZE]; + u8 EthAddr[ETH_ALEN]; bool KeyValid; if (is_valid_ether_addr(hw->perm_mac_addr)) @@ -2299,7 +2299,7 @@ static int get_permanent_address(struct atl2_hw *hw) *(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *) &Addr[1]); if (is_valid_ether_addr(EthAddr)) { - memcpy(hw->perm_mac_addr, EthAddr, NODE_ADDRESS_SIZE); + memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN); return 0; } return 1; @@ -2334,7 +2334,7 @@ static int get_permanent_address(struct atl2_hw *hw) *(u32 *) &EthAddr[2] = LONGSWAP(Addr[0]); *(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *)&Addr[1]); if (is_valid_ether_addr(EthAddr)) { - memcpy(hw->perm_mac_addr, EthAddr, NODE_ADDRESS_SIZE); + memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN); return 0; } /* maybe MAC-address is from BIOS */ @@ -2344,7 +2344,7 @@ static int get_permanent_address(struct atl2_hw *hw) *(u16 *) &EthAddr[0] = SHORTSWAP(*(u16 *) &Addr[1]); if (is_valid_ether_addr(EthAddr)) { - memcpy(hw->perm_mac_addr, EthAddr, NODE_ADDRESS_SIZE); + memcpy(hw->perm_mac_addr, EthAddr, ETH_ALEN); return 0; } @@ -2358,8 +2358,6 @@ static int get_permanent_address(struct atl2_hw *hw) */ static s32 atl2_read_mac_addr(struct atl2_hw *hw) { - u16 i; - if (get_permanent_address(hw)) { /* for test */ /* FIXME: shouldn't we use random_ether_addr() here? */ @@ -2371,8 +2369,7 @@ static s32 atl2_read_mac_addr(struct atl2_hw *hw) hw->perm_mac_addr[5] = 0x38; } - for (i = 0; i < NODE_ADDRESS_SIZE; i++) - hw->mac_addr[i] = hw->perm_mac_addr[i]; + memcpy(hw->mac_addr, hw->perm_mac_addr, ETH_ALEN); return 0; } diff --git a/drivers/net/ethernet/atheros/atlx/atl2.h b/drivers/net/ethernet/atheros/atlx/atl2.h index bf9016ebdd9b..3ebe19f7242b 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.h +++ b/drivers/net/ethernet/atheros/atlx/atl2.h @@ -47,7 +47,6 @@ extern int ethtool_ioctl(struct ifreq *ifr); #define PCI_COMMAND_REGISTER PCI_COMMAND #define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE -#define ETH_ADDR_LEN ETH_ALEN #define ATL2_WRITE_REG(a, reg, value) (iowrite32((value), \ ((a)->hw_addr + (reg)))) @@ -429,8 +428,8 @@ struct atl2_hw { u8 flash_vendor; u8 dma_fairness; - u8 mac_addr[NODE_ADDRESS_SIZE]; - u8 perm_mac_addr[NODE_ADDRESS_SIZE]; + u8 mac_addr[ETH_ALEN]; + u8 perm_mac_addr[ETH_ALEN]; /* FIXME */ /* bool phy_preamble_sup; */ diff --git a/drivers/net/ethernet/atheros/atlx/atlx.h b/drivers/net/ethernet/atheros/atlx/atlx.h index 14054b75aa62..448f5dcc02e6 100644 --- a/drivers/net/ethernet/atheros/atlx/atlx.h +++ b/drivers/net/ethernet/atheros/atlx/atlx.h @@ -484,7 +484,6 @@ /* For checksumming, the sum of all words in the EEPROM should equal 0xBABA */ #define EEPROM_SUM 0xBABA -#define NODE_ADDRESS_SIZE 6 struct atlx_spi_flash_dev { const char *manu_name; /* manufacturer id */ -- GitLab From 449e39d9d7a889f4467ca7c590390e4a0f610b70 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 18 Mar 2012 17:37:58 +0000 Subject: [PATCH 1827/1846] igbvf: Use ETH_ALEN Remove an unnecessary #define and use memcpy instead of a loop to copy an ethernet address. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/igbvf/defines.h | 4 ---- drivers/net/ethernet/intel/igbvf/vf.c | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/igbvf/defines.h b/drivers/net/ethernet/intel/igbvf/defines.h index 33f40d3474ae..3e18045d8f89 100644 --- a/drivers/net/ethernet/intel/igbvf/defines.h +++ b/drivers/net/ethernet/intel/igbvf/defines.h @@ -97,10 +97,6 @@ #define E1000_ERR_MAC_INIT 5 #define E1000_ERR_MBX 15 -#ifndef ETH_ADDR_LEN -#define ETH_ADDR_LEN 6 -#endif - /* SRRCTL bit definitions */ #define E1000_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */ #define E1000_SRRCTL_BSIZEHDRSIZE_MASK 0x00000F00 diff --git a/drivers/net/ethernet/intel/igbvf/vf.c b/drivers/net/ethernet/intel/igbvf/vf.c index 19551977b352..30a6cc426037 100644 --- a/drivers/net/ethernet/intel/igbvf/vf.c +++ b/drivers/net/ethernet/intel/igbvf/vf.c @@ -246,7 +246,7 @@ static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, for (i = 0; i < cnt; i++) { hash_value = e1000_hash_mc_addr_vf(hw, mc_addr_list); hash_list[i] = hash_value & 0x0FFFF; - mc_addr_list += ETH_ADDR_LEN; + mc_addr_list += ETH_ALEN; } mbx->ops.write_posted(hw, msgbuf, E1000_VFMAILBOX_SIZE); @@ -333,10 +333,7 @@ static void e1000_rar_set_vf(struct e1000_hw *hw, u8 * addr, u32 index) **/ static s32 e1000_read_mac_addr_vf(struct e1000_hw *hw) { - int i; - - for (i = 0; i < ETH_ADDR_LEN; i++) - hw->mac.addr[i] = hw->mac.perm_addr[i]; + memcpy(hw->mac.addr, hw->mac.perm_addr, ETH_ALEN); return E1000_SUCCESS; } -- GitLab From fb04121417b32329f92a260b490da8434d704e3d Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 18 Mar 2012 17:37:59 +0000 Subject: [PATCH 1828/1846] rtlwifi: Remove unused ETH_ADDR_LEN defines Just neatening. Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/net/wireless/rtlwifi/rtl8192ce/reg.h | 1 - drivers/net/wireless/rtlwifi/rtl8192de/reg.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h index 43806d9d1e13..e4d738f6166d 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h @@ -1190,7 +1190,6 @@ #define USB_AGG_EN BIT(3) -#define MAC_ADDR_LEN 6 #define LAST_ENTRY_OF_TX_PKT_BUFFER 255 #define POLLING_LLT_THRESHOLD 20 diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/reg.h b/drivers/net/wireless/rtlwifi/rtl8192de/reg.h index 9bc462331078..ebb1d5f5e7b5 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/reg.h +++ b/drivers/net/wireless/rtlwifi/rtl8192de/reg.h @@ -998,7 +998,6 @@ #define SCR_RXBCUSEDK BIT(7) /* General definitions */ -#define MAC_ADDR_LEN 6 #define LAST_ENTRY_OF_TX_PKT_BUFFER 255 #define LAST_ENTRY_OF_TX_PKT_BUFFER_DUAL_MAC 127 -- GitLab From 8af3c33f4dab8c20c0a0eb1a7e00d2303d7f47eb Mon Sep 17 00:00:00 2001 From: Jeff Kirsher Date: Sat, 18 Feb 2012 07:08:14 +0000 Subject: [PATCH 1829/1846] ixgbe: fix namespace issues when FCoE/DCB is not enabled Resolve namespace issues when FCoE or DCB is not enabled. The issue is with certain configurations we end up with namespace problems. A simple example: ixgbe_main.c - defines func A() - uses func A() ixgbe_fcoe.c - uses func A() ixgbe.h - has prototype for func A() For default (FCoE included) all is good. But when it isn't the namespace checker complains about how func A() could be static. To resolve this, created a ixgbe_lib file to contain functions used by DCB/FCoE and their helper functions so that they are always in namespace whether or not DCB/FCoE is enabled. Signed-off-by: Jeff Kirsher Tested-by: Phil Schmitt --- drivers/net/ethernet/intel/ixgbe/Makefile | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 5 + drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 929 ++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 911 +---------------- 4 files changed, 945 insertions(+), 902 deletions(-) create mode 100644 drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile index 7a16177a12a5..8be1d1b2132e 100644 --- a/drivers/net/ethernet/intel/ixgbe/Makefile +++ b/drivers/net/ethernet/intel/ixgbe/Makefile @@ -34,7 +34,7 @@ obj-$(CONFIG_IXGBE) += ixgbe.o ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \ ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \ - ixgbe_mbx.o ixgbe_x540.o + ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \ ixgbe_dcb_82599.o ixgbe_dcb_nl.o diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index e0cc3118234e..80e26ff30ebf 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -581,7 +581,9 @@ extern int ixgbe_copy_dcb_cfg(struct ixgbe_dcb_config *src_dcb_cfg, extern char ixgbe_driver_name[]; extern const char ixgbe_driver_version[]; +#ifdef IXGBE_FCOE extern char ixgbe_default_device_descr[]; +#endif /* IXGBE_FCOE */ extern void ixgbe_up(struct ixgbe_adapter *adapter); extern void ixgbe_down(struct ixgbe_adapter *adapter); @@ -606,6 +608,7 @@ extern void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *, struct ixgbe_tx_buffer *); extern void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16); extern void ixgbe_write_eitr(struct ixgbe_q_vector *); +extern int ixgbe_poll(struct napi_struct *napi, int budget); extern int ethtool_ioctl(struct ifreq *ifr); extern s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw); extern s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl); @@ -625,7 +628,9 @@ extern s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw, extern void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input, union ixgbe_atr_input *mask); extern void ixgbe_set_rx_mode(struct net_device *netdev); +#ifdef CONFIG_IXGBE_DCB extern int ixgbe_setup_tc(struct net_device *dev, u8 tc); +#endif extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); extern void ixgbe_do_reset(struct net_device *netdev); #ifdef IXGBE_FCOE diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c new file mode 100644 index 000000000000..027d7a75be39 --- /dev/null +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c @@ -0,0 +1,929 @@ +/******************************************************************************* + + Intel 10 Gigabit PCI Express Linux driver + Copyright(c) 1999 - 2012 Intel Corporation. + + This program is free software; you can redistribute it and/or modify it + under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + + This program is distributed in the hope 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. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". + + Contact Information: + e1000-devel Mailing List + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#include "ixgbe.h" +#include "ixgbe_sriov.h" + +/** + * ixgbe_cache_ring_rss - Descriptor ring to register mapping for RSS + * @adapter: board private structure to initialize + * + * Cache the descriptor ring offsets for RSS to the assigned rings. + * + **/ +static inline bool ixgbe_cache_ring_rss(struct ixgbe_adapter *adapter) +{ + int i; + + if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) + return false; + + for (i = 0; i < adapter->num_rx_queues; i++) + adapter->rx_ring[i]->reg_idx = i; + for (i = 0; i < adapter->num_tx_queues; i++) + adapter->tx_ring[i]->reg_idx = i; + + return true; +} +#ifdef CONFIG_IXGBE_DCB + +/* ixgbe_get_first_reg_idx - Return first register index associated with ring */ +static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc, + unsigned int *tx, unsigned int *rx) +{ + struct net_device *dev = adapter->netdev; + struct ixgbe_hw *hw = &adapter->hw; + u8 num_tcs = netdev_get_num_tc(dev); + + *tx = 0; + *rx = 0; + + switch (hw->mac.type) { + case ixgbe_mac_82598EB: + *tx = tc << 2; + *rx = tc << 3; + break; + case ixgbe_mac_82599EB: + case ixgbe_mac_X540: + if (num_tcs > 4) { + if (tc < 3) { + *tx = tc << 5; + *rx = tc << 4; + } else if (tc < 5) { + *tx = ((tc + 2) << 4); + *rx = tc << 4; + } else if (tc < num_tcs) { + *tx = ((tc + 8) << 3); + *rx = tc << 4; + } + } else { + *rx = tc << 5; + switch (tc) { + case 0: + *tx = 0; + break; + case 1: + *tx = 64; + break; + case 2: + *tx = 96; + break; + case 3: + *tx = 112; + break; + default: + break; + } + } + break; + default: + break; + } +} + +/** + * ixgbe_cache_ring_dcb - Descriptor ring to register mapping for DCB + * @adapter: board private structure to initialize + * + * Cache the descriptor ring offsets for DCB to the assigned rings. + * + **/ +static inline bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter) +{ + struct net_device *dev = adapter->netdev; + int i, j, k; + u8 num_tcs = netdev_get_num_tc(dev); + + if (!num_tcs) + return false; + + for (i = 0, k = 0; i < num_tcs; i++) { + unsigned int tx_s, rx_s; + u16 count = dev->tc_to_txq[i].count; + + ixgbe_get_first_reg_idx(adapter, i, &tx_s, &rx_s); + for (j = 0; j < count; j++, k++) { + adapter->tx_ring[k]->reg_idx = tx_s + j; + adapter->rx_ring[k]->reg_idx = rx_s + j; + adapter->tx_ring[k]->dcb_tc = i; + adapter->rx_ring[k]->dcb_tc = i; + } + } + + return true; +} +#endif + +/** + * ixgbe_cache_ring_fdir - Descriptor ring to register mapping for Flow Director + * @adapter: board private structure to initialize + * + * Cache the descriptor ring offsets for Flow Director to the assigned rings. + * + **/ +static inline bool ixgbe_cache_ring_fdir(struct ixgbe_adapter *adapter) +{ + int i; + bool ret = false; + + if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && + (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) { + for (i = 0; i < adapter->num_rx_queues; i++) + adapter->rx_ring[i]->reg_idx = i; + for (i = 0; i < adapter->num_tx_queues; i++) + adapter->tx_ring[i]->reg_idx = i; + ret = true; + } + + return ret; +} + +#ifdef IXGBE_FCOE +/** + * ixgbe_cache_ring_fcoe - Descriptor ring to register mapping for the FCoE + * @adapter: board private structure to initialize + * + * Cache the descriptor ring offsets for FCoE mode to the assigned rings. + * + */ +static inline bool ixgbe_cache_ring_fcoe(struct ixgbe_adapter *adapter) +{ + struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; + int i; + u8 fcoe_rx_i = 0, fcoe_tx_i = 0; + + if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) + return false; + + if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) + ixgbe_cache_ring_fdir(adapter); + else + ixgbe_cache_ring_rss(adapter); + + fcoe_rx_i = f->mask; + fcoe_tx_i = f->mask; + } + for (i = 0; i < f->indices; i++, fcoe_rx_i++, fcoe_tx_i++) { + adapter->rx_ring[f->mask + i]->reg_idx = fcoe_rx_i; + adapter->tx_ring[f->mask + i]->reg_idx = fcoe_tx_i; + } + return true; +} + +#endif /* IXGBE_FCOE */ +/** + * ixgbe_cache_ring_sriov - Descriptor ring to register mapping for sriov + * @adapter: board private structure to initialize + * + * SR-IOV doesn't use any descriptor rings but changes the default if + * no other mapping is used. + * + */ +static inline bool ixgbe_cache_ring_sriov(struct ixgbe_adapter *adapter) +{ + adapter->rx_ring[0]->reg_idx = adapter->num_vfs * 2; + adapter->tx_ring[0]->reg_idx = adapter->num_vfs * 2; + if (adapter->num_vfs) + return true; + else + return false; +} + +/** + * ixgbe_cache_ring_register - Descriptor ring to register mapping + * @adapter: board private structure to initialize + * + * Once we know the feature-set enabled for the device, we'll cache + * the register offset the descriptor ring is assigned to. + * + * Note, the order the various feature calls is important. It must start with + * the "most" features enabled at the same time, then trickle down to the + * least amount of features turned on at once. + **/ +static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter) +{ + /* start with default case */ + adapter->rx_ring[0]->reg_idx = 0; + adapter->tx_ring[0]->reg_idx = 0; + + if (ixgbe_cache_ring_sriov(adapter)) + return; + +#ifdef CONFIG_IXGBE_DCB + if (ixgbe_cache_ring_dcb(adapter)) + return; +#endif + +#ifdef IXGBE_FCOE + if (ixgbe_cache_ring_fcoe(adapter)) + return; +#endif /* IXGBE_FCOE */ + + if (ixgbe_cache_ring_fdir(adapter)) + return; + + if (ixgbe_cache_ring_rss(adapter)) + return; +} + +/** + * ixgbe_set_sriov_queues: Allocate queues for IOV use + * @adapter: board private structure to initialize + * + * IOV doesn't actually use anything, so just NAK the + * request for now and let the other queue routines + * figure out what to do. + */ +static inline bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter) +{ + return false; +} + +/** + * ixgbe_set_rss_queues: Allocate queues for RSS + * @adapter: board private structure to initialize + * + * This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try + * to allocate one Rx queue per CPU, and if available, one Tx queue per CPU. + * + **/ +static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter) +{ + bool ret = false; + struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_RSS]; + + if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { + f->mask = 0xF; + adapter->num_rx_queues = f->indices; + adapter->num_tx_queues = f->indices; + ret = true; + } + + return ret; +} + +/** + * ixgbe_set_fdir_queues: Allocate queues for Flow Director + * @adapter: board private structure to initialize + * + * Flow Director is an advanced Rx filter, attempting to get Rx flows back + * to the original CPU that initiated the Tx session. This runs in addition + * to RSS, so if a packet doesn't match an FDIR filter, we can still spread the + * Rx load across CPUs using RSS. + * + **/ +static inline bool ixgbe_set_fdir_queues(struct ixgbe_adapter *adapter) +{ + bool ret = false; + struct ixgbe_ring_feature *f_fdir = &adapter->ring_feature[RING_F_FDIR]; + + f_fdir->indices = min_t(int, num_online_cpus(), f_fdir->indices); + f_fdir->mask = 0; + + /* + * Use RSS in addition to Flow Director to ensure the best + * distribution of flows across cores, even when an FDIR flow + * isn't matched. + */ + if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && + (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) { + adapter->num_tx_queues = f_fdir->indices; + adapter->num_rx_queues = f_fdir->indices; + ret = true; + } else { + adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; + } + return ret; +} + +#ifdef IXGBE_FCOE +/** + * ixgbe_set_fcoe_queues: Allocate queues for Fiber Channel over Ethernet (FCoE) + * @adapter: board private structure to initialize + * + * FCoE RX FCRETA can use up to 8 rx queues for up to 8 different exchanges. + * The ring feature mask is not used as a mask for FCoE, as it can take any 8 + * rx queues out of the max number of rx queues, instead, it is used as the + * index of the first rx queue used by FCoE. + * + **/ +static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter) +{ + struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; + + if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) + return false; + + f->indices = min_t(int, num_online_cpus(), f->indices); + + adapter->num_rx_queues = 1; + adapter->num_tx_queues = 1; + + if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { + e_info(probe, "FCoE enabled with RSS\n"); + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) + ixgbe_set_fdir_queues(adapter); + else + ixgbe_set_rss_queues(adapter); + } + + /* adding FCoE rx rings to the end */ + f->mask = adapter->num_rx_queues; + adapter->num_rx_queues += f->indices; + adapter->num_tx_queues += f->indices; + + return true; +} +#endif /* IXGBE_FCOE */ + +/* Artificial max queue cap per traffic class in DCB mode */ +#define DCB_QUEUE_CAP 8 + +#ifdef CONFIG_IXGBE_DCB +static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter) +{ + int per_tc_q, q, i, offset = 0; + struct net_device *dev = adapter->netdev; + int tcs = netdev_get_num_tc(dev); + + if (!tcs) + return false; + + /* Map queue offset and counts onto allocated tx queues */ + per_tc_q = min_t(unsigned int, dev->num_tx_queues / tcs, DCB_QUEUE_CAP); + q = min_t(int, num_online_cpus(), per_tc_q); + + for (i = 0; i < tcs; i++) { + netdev_set_tc_queue(dev, i, q, offset); + offset += q; + } + + adapter->num_tx_queues = q * tcs; + adapter->num_rx_queues = q * tcs; + +#ifdef IXGBE_FCOE + /* FCoE enabled queues require special configuration indexed + * by feature specific indices and mask. Here we map FCoE + * indices onto the DCB queue pairs allowing FCoE to own + * configuration later. + */ + if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { + u8 prio_tc[MAX_USER_PRIORITY] = {0}; + int tc; + struct ixgbe_ring_feature *f = + &adapter->ring_feature[RING_F_FCOE]; + + ixgbe_dcb_unpack_map(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_tc); + tc = prio_tc[adapter->fcoe.up]; + f->indices = dev->tc_to_txq[tc].count; + f->mask = dev->tc_to_txq[tc].offset; + } +#endif + + return true; +} +#endif + +/** + * ixgbe_set_num_queues: Allocate queues for device, feature dependent + * @adapter: board private structure to initialize + * + * This is the top level queue allocation routine. The order here is very + * important, starting with the "most" number of features turned on at once, + * and ending with the smallest set of features. This way large combinations + * can be allocated if they're turned on, and smaller combinations are the + * fallthrough conditions. + * + **/ +static int ixgbe_set_num_queues(struct ixgbe_adapter *adapter) +{ + /* Start with base case */ + adapter->num_rx_queues = 1; + adapter->num_tx_queues = 1; + adapter->num_rx_pools = adapter->num_rx_queues; + adapter->num_rx_queues_per_pool = 1; + + if (ixgbe_set_sriov_queues(adapter)) + goto done; + +#ifdef CONFIG_IXGBE_DCB + if (ixgbe_set_dcb_queues(adapter)) + goto done; + +#endif +#ifdef IXGBE_FCOE + if (ixgbe_set_fcoe_queues(adapter)) + goto done; + +#endif /* IXGBE_FCOE */ + if (ixgbe_set_fdir_queues(adapter)) + goto done; + + if (ixgbe_set_rss_queues(adapter)) + goto done; + + /* fallback to base case */ + adapter->num_rx_queues = 1; + adapter->num_tx_queues = 1; + +done: + if ((adapter->netdev->reg_state == NETREG_UNREGISTERED) || + (adapter->netdev->reg_state == NETREG_UNREGISTERING)) + return 0; + + /* Notify the stack of the (possibly) reduced queue counts. */ + netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues); + return netif_set_real_num_rx_queues(adapter->netdev, + adapter->num_rx_queues); +} + +static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, + int vectors) +{ + int err, vector_threshold; + + /* We'll want at least 2 (vector_threshold): + * 1) TxQ[0] + RxQ[0] handler + * 2) Other (Link Status Change, etc.) + */ + vector_threshold = MIN_MSIX_COUNT; + + /* + * The more we get, the more we will assign to Tx/Rx Cleanup + * for the separate queues...where Rx Cleanup >= Tx Cleanup. + * Right now, we simply care about how many we'll get; we'll + * set them up later while requesting irq's. + */ + while (vectors >= vector_threshold) { + err = pci_enable_msix(adapter->pdev, adapter->msix_entries, + vectors); + if (!err) /* Success in acquiring all requested vectors. */ + break; + else if (err < 0) + vectors = 0; /* Nasty failure, quit now */ + else /* err == number of vectors we should try again with */ + vectors = err; + } + + if (vectors < vector_threshold) { + /* Can't allocate enough MSI-X interrupts? Oh well. + * This just means we'll go with either a single MSI + * vector or fall back to legacy interrupts. + */ + netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev, + "Unable to allocate MSI-X interrupts\n"); + adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; + kfree(adapter->msix_entries); + adapter->msix_entries = NULL; + } else { + adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */ + /* + * Adjust for only the vectors we'll use, which is minimum + * of max_msix_q_vectors + NON_Q_VECTORS, or the number of + * vectors we were allocated. + */ + adapter->num_msix_vectors = min(vectors, + adapter->max_msix_q_vectors + NON_Q_VECTORS); + } +} + +static void ixgbe_add_ring(struct ixgbe_ring *ring, + struct ixgbe_ring_container *head) +{ + ring->next = head->ring; + head->ring = ring; + head->count++; +} + +/** + * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector + * @adapter: board private structure to initialize + * @v_idx: index of vector in adapter struct + * + * We allocate one q_vector. If allocation fails we return -ENOMEM. + **/ +static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter, int v_idx, + int txr_count, int txr_idx, + int rxr_count, int rxr_idx) +{ + struct ixgbe_q_vector *q_vector; + struct ixgbe_ring *ring; + int node = -1; + int cpu = -1; + int ring_count, size; + + ring_count = txr_count + rxr_count; + size = sizeof(struct ixgbe_q_vector) + + (sizeof(struct ixgbe_ring) * ring_count); + + /* customize cpu for Flow Director mapping */ + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { + if (cpu_online(v_idx)) { + cpu = v_idx; + node = cpu_to_node(cpu); + } + } + + /* allocate q_vector and rings */ + q_vector = kzalloc_node(size, GFP_KERNEL, node); + if (!q_vector) + q_vector = kzalloc(size, GFP_KERNEL); + if (!q_vector) + return -ENOMEM; + + /* setup affinity mask and node */ + if (cpu != -1) + cpumask_set_cpu(cpu, &q_vector->affinity_mask); + else + cpumask_copy(&q_vector->affinity_mask, cpu_online_mask); + q_vector->numa_node = node; + + /* initialize NAPI */ + netif_napi_add(adapter->netdev, &q_vector->napi, + ixgbe_poll, 64); + + /* tie q_vector and adapter together */ + adapter->q_vector[v_idx] = q_vector; + q_vector->adapter = adapter; + q_vector->v_idx = v_idx; + + /* initialize work limits */ + q_vector->tx.work_limit = adapter->tx_work_limit; + + /* initialize pointer to rings */ + ring = q_vector->ring; + + while (txr_count) { + /* assign generic ring traits */ + ring->dev = &adapter->pdev->dev; + ring->netdev = adapter->netdev; + + /* configure backlink on ring */ + ring->q_vector = q_vector; + + /* update q_vector Tx values */ + ixgbe_add_ring(ring, &q_vector->tx); + + /* apply Tx specific ring traits */ + ring->count = adapter->tx_ring_count; + ring->queue_index = txr_idx; + + /* assign ring to adapter */ + adapter->tx_ring[txr_idx] = ring; + + /* update count and index */ + txr_count--; + txr_idx++; + + /* push pointer to next ring */ + ring++; + } + + while (rxr_count) { + /* assign generic ring traits */ + ring->dev = &adapter->pdev->dev; + ring->netdev = adapter->netdev; + + /* configure backlink on ring */ + ring->q_vector = q_vector; + + /* update q_vector Rx values */ + ixgbe_add_ring(ring, &q_vector->rx); + + /* + * 82599 errata, UDP frames with a 0 checksum + * can be marked as checksum errors. + */ + if (adapter->hw.mac.type == ixgbe_mac_82599EB) + set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); + + /* apply Rx specific ring traits */ + ring->count = adapter->rx_ring_count; + ring->queue_index = rxr_idx; + + /* assign ring to adapter */ + adapter->rx_ring[rxr_idx] = ring; + + /* update count and index */ + rxr_count--; + rxr_idx++; + + /* push pointer to next ring */ + ring++; + } + + return 0; +} + +/** + * ixgbe_free_q_vector - Free memory allocated for specific interrupt vector + * @adapter: board private structure to initialize + * @v_idx: Index of vector to be freed + * + * This function frees the memory allocated to the q_vector. In addition if + * NAPI is enabled it will delete any references to the NAPI struct prior + * to freeing the q_vector. + **/ +static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx) +{ + struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx]; + struct ixgbe_ring *ring; + + ixgbe_for_each_ring(ring, q_vector->tx) + adapter->tx_ring[ring->queue_index] = NULL; + + ixgbe_for_each_ring(ring, q_vector->rx) + adapter->rx_ring[ring->queue_index] = NULL; + + adapter->q_vector[v_idx] = NULL; + netif_napi_del(&q_vector->napi); + + /* + * ixgbe_get_stats64() might access the rings on this vector, + * we must wait a grace period before freeing it. + */ + kfree_rcu(q_vector, rcu); +} + +/** + * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors + * @adapter: board private structure to initialize + * + * We allocate one q_vector per queue interrupt. If allocation fails we + * return -ENOMEM. + **/ +static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) +{ + int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; + int rxr_remaining = adapter->num_rx_queues; + int txr_remaining = adapter->num_tx_queues; + int rxr_idx = 0, txr_idx = 0, v_idx = 0; + int err; + + /* only one q_vector if MSI-X is disabled. */ + if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) + q_vectors = 1; + + if (q_vectors >= (rxr_remaining + txr_remaining)) { + for (; rxr_remaining; v_idx++, q_vectors--) { + int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors); + err = ixgbe_alloc_q_vector(adapter, v_idx, + 0, 0, rqpv, rxr_idx); + + if (err) + goto err_out; + + /* update counts and index */ + rxr_remaining -= rqpv; + rxr_idx += rqpv; + } + } + + for (; q_vectors; v_idx++, q_vectors--) { + int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors); + int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors); + err = ixgbe_alloc_q_vector(adapter, v_idx, + tqpv, txr_idx, + rqpv, rxr_idx); + + if (err) + goto err_out; + + /* update counts and index */ + rxr_remaining -= rqpv; + rxr_idx += rqpv; + txr_remaining -= tqpv; + txr_idx += tqpv; + } + + return 0; + +err_out: + while (v_idx) { + v_idx--; + ixgbe_free_q_vector(adapter, v_idx); + } + + return -ENOMEM; +} + +/** + * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors + * @adapter: board private structure to initialize + * + * This function frees the memory allocated to the q_vectors. In addition if + * NAPI is enabled it will delete any references to the NAPI struct prior + * to freeing the q_vector. + **/ +static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter) +{ + int v_idx, q_vectors; + + if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) + q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; + else + q_vectors = 1; + + for (v_idx = 0; v_idx < q_vectors; v_idx++) + ixgbe_free_q_vector(adapter, v_idx); +} + +static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter) +{ + if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { + adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; + pci_disable_msix(adapter->pdev); + kfree(adapter->msix_entries); + adapter->msix_entries = NULL; + } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) { + adapter->flags &= ~IXGBE_FLAG_MSI_ENABLED; + pci_disable_msi(adapter->pdev); + } +} + +/** + * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported + * @adapter: board private structure to initialize + * + * Attempt to configure the interrupts using the best available + * capabilities of the hardware and the kernel. + **/ +static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) +{ + struct ixgbe_hw *hw = &adapter->hw; + int err = 0; + int vector, v_budget; + + /* + * It's easy to be greedy for MSI-X vectors, but it really + * doesn't do us much good if we have a lot more vectors + * than CPU's. So let's be conservative and only ask for + * (roughly) the same number of vectors as there are CPU's. + * The default is to use pairs of vectors. + */ + v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues); + v_budget = min_t(int, v_budget, num_online_cpus()); + v_budget += NON_Q_VECTORS; + + /* + * At the same time, hardware can only support a maximum of + * hw.mac->max_msix_vectors vectors. With features + * such as RSS and VMDq, we can easily surpass the number of Rx and Tx + * descriptor queues supported by our device. Thus, we cap it off in + * those rare cases where the cpu count also exceeds our vector limit. + */ + v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors); + + /* A failure in MSI-X entry allocation isn't fatal, but it does + * mean we disable MSI-X capabilities of the adapter. */ + adapter->msix_entries = kcalloc(v_budget, + sizeof(struct msix_entry), GFP_KERNEL); + if (adapter->msix_entries) { + for (vector = 0; vector < v_budget; vector++) + adapter->msix_entries[vector].entry = vector; + + ixgbe_acquire_msix_vectors(adapter, v_budget); + + if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) + goto out; + } + + adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; + adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED; + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { + e_err(probe, + "ATR is not supported while multiple " + "queues are disabled. Disabling Flow Director\n"); + } + adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; + adapter->atr_sample_rate = 0; + if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) + ixgbe_disable_sriov(adapter); + + err = ixgbe_set_num_queues(adapter); + if (err) + return err; + + err = pci_enable_msi(adapter->pdev); + if (!err) { + adapter->flags |= IXGBE_FLAG_MSI_ENABLED; + } else { + netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev, + "Unable to allocate MSI interrupt, " + "falling back to legacy. Error: %d\n", err); + /* reset err */ + err = 0; + } + +out: + return err; +} + +/** + * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme + * @adapter: board private structure to initialize + * + * We determine which interrupt scheme to use based on... + * - Kernel support (MSI, MSI-X) + * - which can be user-defined (via MODULE_PARAM) + * - Hardware queue count (num_*_queues) + * - defined by miscellaneous hardware support/features (RSS, etc.) + **/ +int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) +{ + int err; + + /* Number of supported queues */ + err = ixgbe_set_num_queues(adapter); + if (err) + return err; + + err = ixgbe_set_interrupt_capability(adapter); + if (err) { + e_dev_err("Unable to setup interrupt capabilities\n"); + goto err_set_interrupt; + } + + err = ixgbe_alloc_q_vectors(adapter); + if (err) { + e_dev_err("Unable to allocate memory for queue vectors\n"); + goto err_alloc_q_vectors; + } + + ixgbe_cache_ring_register(adapter); + + e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n", + (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled", + adapter->num_rx_queues, adapter->num_tx_queues); + + set_bit(__IXGBE_DOWN, &adapter->state); + + return 0; + +err_alloc_q_vectors: + ixgbe_reset_interrupt_capability(adapter); +err_set_interrupt: + return err; +} + +/** + * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings + * @adapter: board private structure to clear interrupt scheme on + * + * We go through and clear interrupt specific resources and reset the structure + * to pre-load conditions + **/ +void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter) +{ + adapter->num_tx_queues = 0; + adapter->num_rx_queues = 0; + + ixgbe_free_q_vectors(adapter); + ixgbe_reset_interrupt_capability(adapter); +} + +void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens, + u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx) +{ + struct ixgbe_adv_tx_context_desc *context_desc; + u16 i = tx_ring->next_to_use; + + context_desc = IXGBE_TX_CTXTDESC(tx_ring, i); + + i++; + tx_ring->next_to_use = (i < tx_ring->count) ? i : 0; + + /* set bits to identify this as an advanced context descriptor */ + type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT; + + context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); + context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof); + context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd); + context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); +} + diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index e9d9fca084a9..398fc223cab9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -55,8 +55,13 @@ char ixgbe_driver_name[] = "ixgbe"; static const char ixgbe_driver_string[] = "Intel(R) 10 Gigabit PCI Express Network Driver"; +#ifdef IXGBE_FCOE char ixgbe_default_device_descr[] = "Intel(R) 10 Gigabit Network Connection"; +#else +static char ixgbe_default_device_descr[] = + "Intel(R) 10 Gigabit Network Connection"; +#endif #define MAJ 3 #define MIN 6 #define BUILD 7 @@ -2314,7 +2319,7 @@ static irqreturn_t ixgbe_msix_clean_rings(int irq, void *data) * * This function is used for legacy and MSI, NAPI mode **/ -static int ixgbe_poll(struct napi_struct *napi, int budget) +int ixgbe_poll(struct napi_struct *napi, int budget) { struct ixgbe_q_vector *q_vector = container_of(napi, struct ixgbe_q_vector, napi); @@ -4319,886 +4324,6 @@ static void ixgbe_tx_timeout(struct net_device *netdev) ixgbe_tx_timeout_reset(adapter); } -/** - * ixgbe_set_rss_queues: Allocate queues for RSS - * @adapter: board private structure to initialize - * - * This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try - * to allocate one Rx queue per CPU, and if available, one Tx queue per CPU. - * - **/ -static inline bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter) -{ - bool ret = false; - struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_RSS]; - - if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { - f->mask = 0xF; - adapter->num_rx_queues = f->indices; - adapter->num_tx_queues = f->indices; - ret = true; - } - - return ret; -} - -/** - * ixgbe_set_fdir_queues: Allocate queues for Flow Director - * @adapter: board private structure to initialize - * - * Flow Director is an advanced Rx filter, attempting to get Rx flows back - * to the original CPU that initiated the Tx session. This runs in addition - * to RSS, so if a packet doesn't match an FDIR filter, we can still spread the - * Rx load across CPUs using RSS. - * - **/ -static inline bool ixgbe_set_fdir_queues(struct ixgbe_adapter *adapter) -{ - bool ret = false; - struct ixgbe_ring_feature *f_fdir = &adapter->ring_feature[RING_F_FDIR]; - - f_fdir->indices = min_t(int, num_online_cpus(), f_fdir->indices); - f_fdir->mask = 0; - - /* - * Use RSS in addition to Flow Director to ensure the best - * distribution of flows across cores, even when an FDIR flow - * isn't matched. - */ - if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && - (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) { - adapter->num_tx_queues = f_fdir->indices; - adapter->num_rx_queues = f_fdir->indices; - ret = true; - } else { - adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; - } - return ret; -} - -#ifdef IXGBE_FCOE -/** - * ixgbe_set_fcoe_queues: Allocate queues for Fiber Channel over Ethernet (FCoE) - * @adapter: board private structure to initialize - * - * FCoE RX FCRETA can use up to 8 rx queues for up to 8 different exchanges. - * The ring feature mask is not used as a mask for FCoE, as it can take any 8 - * rx queues out of the max number of rx queues, instead, it is used as the - * index of the first rx queue used by FCoE. - * - **/ -static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter) -{ - struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; - - if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) - return false; - - f->indices = min_t(int, num_online_cpus(), f->indices); - - adapter->num_rx_queues = 1; - adapter->num_tx_queues = 1; - - if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { - e_info(probe, "FCoE enabled with RSS\n"); - if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) - ixgbe_set_fdir_queues(adapter); - else - ixgbe_set_rss_queues(adapter); - } - - /* adding FCoE rx rings to the end */ - f->mask = adapter->num_rx_queues; - adapter->num_rx_queues += f->indices; - adapter->num_tx_queues += f->indices; - - return true; -} -#endif /* IXGBE_FCOE */ - -/* Artificial max queue cap per traffic class in DCB mode */ -#define DCB_QUEUE_CAP 8 - -#ifdef CONFIG_IXGBE_DCB -static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter) -{ - int per_tc_q, q, i, offset = 0; - struct net_device *dev = adapter->netdev; - int tcs = netdev_get_num_tc(dev); - - if (!tcs) - return false; - - /* Map queue offset and counts onto allocated tx queues */ - per_tc_q = min_t(unsigned int, dev->num_tx_queues / tcs, DCB_QUEUE_CAP); - q = min_t(int, num_online_cpus(), per_tc_q); - - for (i = 0; i < tcs; i++) { - netdev_set_tc_queue(dev, i, q, offset); - offset += q; - } - - adapter->num_tx_queues = q * tcs; - adapter->num_rx_queues = q * tcs; - -#ifdef IXGBE_FCOE - /* FCoE enabled queues require special configuration indexed - * by feature specific indices and mask. Here we map FCoE - * indices onto the DCB queue pairs allowing FCoE to own - * configuration later. - */ - if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { - u8 prio_tc[MAX_USER_PRIORITY] = {0}; - int tc; - struct ixgbe_ring_feature *f = - &adapter->ring_feature[RING_F_FCOE]; - - ixgbe_dcb_unpack_map(&adapter->dcb_cfg, DCB_TX_CONFIG, prio_tc); - tc = prio_tc[adapter->fcoe.up]; - f->indices = dev->tc_to_txq[tc].count; - f->mask = dev->tc_to_txq[tc].offset; - } -#endif - - return true; -} -#endif - -/** - * ixgbe_set_sriov_queues: Allocate queues for IOV use - * @adapter: board private structure to initialize - * - * IOV doesn't actually use anything, so just NAK the - * request for now and let the other queue routines - * figure out what to do. - */ -static inline bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter) -{ - return false; -} - -/* - * ixgbe_set_num_queues: Allocate queues for device, feature dependent - * @adapter: board private structure to initialize - * - * This is the top level queue allocation routine. The order here is very - * important, starting with the "most" number of features turned on at once, - * and ending with the smallest set of features. This way large combinations - * can be allocated if they're turned on, and smaller combinations are the - * fallthrough conditions. - * - **/ -static int ixgbe_set_num_queues(struct ixgbe_adapter *adapter) -{ - /* Start with base case */ - adapter->num_rx_queues = 1; - adapter->num_tx_queues = 1; - adapter->num_rx_pools = adapter->num_rx_queues; - adapter->num_rx_queues_per_pool = 1; - - if (ixgbe_set_sriov_queues(adapter)) - goto done; - -#ifdef CONFIG_IXGBE_DCB - if (ixgbe_set_dcb_queues(adapter)) - goto done; - -#endif -#ifdef IXGBE_FCOE - if (ixgbe_set_fcoe_queues(adapter)) - goto done; - -#endif /* IXGBE_FCOE */ - if (ixgbe_set_fdir_queues(adapter)) - goto done; - - if (ixgbe_set_rss_queues(adapter)) - goto done; - - /* fallback to base case */ - adapter->num_rx_queues = 1; - adapter->num_tx_queues = 1; - -done: - if ((adapter->netdev->reg_state == NETREG_UNREGISTERED) || - (adapter->netdev->reg_state == NETREG_UNREGISTERING)) - return 0; - - /* Notify the stack of the (possibly) reduced queue counts. */ - netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues); - return netif_set_real_num_rx_queues(adapter->netdev, - adapter->num_rx_queues); -} - -static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, - int vectors) -{ - int err, vector_threshold; - - /* We'll want at least 2 (vector_threshold): - * 1) TxQ[0] + RxQ[0] handler - * 2) Other (Link Status Change, etc.) - */ - vector_threshold = MIN_MSIX_COUNT; - - /* - * The more we get, the more we will assign to Tx/Rx Cleanup - * for the separate queues...where Rx Cleanup >= Tx Cleanup. - * Right now, we simply care about how many we'll get; we'll - * set them up later while requesting irq's. - */ - while (vectors >= vector_threshold) { - err = pci_enable_msix(adapter->pdev, adapter->msix_entries, - vectors); - if (!err) /* Success in acquiring all requested vectors. */ - break; - else if (err < 0) - vectors = 0; /* Nasty failure, quit now */ - else /* err == number of vectors we should try again with */ - vectors = err; - } - - if (vectors < vector_threshold) { - /* Can't allocate enough MSI-X interrupts? Oh well. - * This just means we'll go with either a single MSI - * vector or fall back to legacy interrupts. - */ - netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev, - "Unable to allocate MSI-X interrupts\n"); - adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; - kfree(adapter->msix_entries); - adapter->msix_entries = NULL; - } else { - adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */ - /* - * Adjust for only the vectors we'll use, which is minimum - * of max_msix_q_vectors + NON_Q_VECTORS, or the number of - * vectors we were allocated. - */ - adapter->num_msix_vectors = min(vectors, - adapter->max_msix_q_vectors + NON_Q_VECTORS); - } -} - -/** - * ixgbe_cache_ring_rss - Descriptor ring to register mapping for RSS - * @adapter: board private structure to initialize - * - * Cache the descriptor ring offsets for RSS to the assigned rings. - * - **/ -static inline bool ixgbe_cache_ring_rss(struct ixgbe_adapter *adapter) -{ - int i; - - if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) - return false; - - for (i = 0; i < adapter->num_rx_queues; i++) - adapter->rx_ring[i]->reg_idx = i; - for (i = 0; i < adapter->num_tx_queues; i++) - adapter->tx_ring[i]->reg_idx = i; - - return true; -} - -#ifdef CONFIG_IXGBE_DCB - -/* ixgbe_get_first_reg_idx - Return first register index associated with ring */ -static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc, - unsigned int *tx, unsigned int *rx) -{ - struct net_device *dev = adapter->netdev; - struct ixgbe_hw *hw = &adapter->hw; - u8 num_tcs = netdev_get_num_tc(dev); - - *tx = 0; - *rx = 0; - - switch (hw->mac.type) { - case ixgbe_mac_82598EB: - *tx = tc << 2; - *rx = tc << 3; - break; - case ixgbe_mac_82599EB: - case ixgbe_mac_X540: - if (num_tcs > 4) { - if (tc < 3) { - *tx = tc << 5; - *rx = tc << 4; - } else if (tc < 5) { - *tx = ((tc + 2) << 4); - *rx = tc << 4; - } else if (tc < num_tcs) { - *tx = ((tc + 8) << 3); - *rx = tc << 4; - } - } else { - *rx = tc << 5; - switch (tc) { - case 0: - *tx = 0; - break; - case 1: - *tx = 64; - break; - case 2: - *tx = 96; - break; - case 3: - *tx = 112; - break; - default: - break; - } - } - break; - default: - break; - } -} - -/** - * ixgbe_cache_ring_dcb - Descriptor ring to register mapping for DCB - * @adapter: board private structure to initialize - * - * Cache the descriptor ring offsets for DCB to the assigned rings. - * - **/ -static inline bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter) -{ - struct net_device *dev = adapter->netdev; - int i, j, k; - u8 num_tcs = netdev_get_num_tc(dev); - - if (!num_tcs) - return false; - - for (i = 0, k = 0; i < num_tcs; i++) { - unsigned int tx_s, rx_s; - u16 count = dev->tc_to_txq[i].count; - - ixgbe_get_first_reg_idx(adapter, i, &tx_s, &rx_s); - for (j = 0; j < count; j++, k++) { - adapter->tx_ring[k]->reg_idx = tx_s + j; - adapter->rx_ring[k]->reg_idx = rx_s + j; - adapter->tx_ring[k]->dcb_tc = i; - adapter->rx_ring[k]->dcb_tc = i; - } - } - - return true; -} -#endif - -/** - * ixgbe_cache_ring_fdir - Descriptor ring to register mapping for Flow Director - * @adapter: board private structure to initialize - * - * Cache the descriptor ring offsets for Flow Director to the assigned rings. - * - **/ -static inline bool ixgbe_cache_ring_fdir(struct ixgbe_adapter *adapter) -{ - int i; - bool ret = false; - - if ((adapter->flags & IXGBE_FLAG_RSS_ENABLED) && - (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) { - for (i = 0; i < adapter->num_rx_queues; i++) - adapter->rx_ring[i]->reg_idx = i; - for (i = 0; i < adapter->num_tx_queues; i++) - adapter->tx_ring[i]->reg_idx = i; - ret = true; - } - - return ret; -} - -#ifdef IXGBE_FCOE -/** - * ixgbe_cache_ring_fcoe - Descriptor ring to register mapping for the FCoE - * @adapter: board private structure to initialize - * - * Cache the descriptor ring offsets for FCoE mode to the assigned rings. - * - */ -static inline bool ixgbe_cache_ring_fcoe(struct ixgbe_adapter *adapter) -{ - struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; - int i; - u8 fcoe_rx_i = 0, fcoe_tx_i = 0; - - if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) - return false; - - if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { - if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) - ixgbe_cache_ring_fdir(adapter); - else - ixgbe_cache_ring_rss(adapter); - - fcoe_rx_i = f->mask; - fcoe_tx_i = f->mask; - } - for (i = 0; i < f->indices; i++, fcoe_rx_i++, fcoe_tx_i++) { - adapter->rx_ring[f->mask + i]->reg_idx = fcoe_rx_i; - adapter->tx_ring[f->mask + i]->reg_idx = fcoe_tx_i; - } - return true; -} - -#endif /* IXGBE_FCOE */ -/** - * ixgbe_cache_ring_sriov - Descriptor ring to register mapping for sriov - * @adapter: board private structure to initialize - * - * SR-IOV doesn't use any descriptor rings but changes the default if - * no other mapping is used. - * - */ -static inline bool ixgbe_cache_ring_sriov(struct ixgbe_adapter *adapter) -{ - adapter->rx_ring[0]->reg_idx = adapter->num_vfs * 2; - adapter->tx_ring[0]->reg_idx = adapter->num_vfs * 2; - if (adapter->num_vfs) - return true; - else - return false; -} - -/** - * ixgbe_cache_ring_register - Descriptor ring to register mapping - * @adapter: board private structure to initialize - * - * Once we know the feature-set enabled for the device, we'll cache - * the register offset the descriptor ring is assigned to. - * - * Note, the order the various feature calls is important. It must start with - * the "most" features enabled at the same time, then trickle down to the - * least amount of features turned on at once. - **/ -static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter) -{ - /* start with default case */ - adapter->rx_ring[0]->reg_idx = 0; - adapter->tx_ring[0]->reg_idx = 0; - - if (ixgbe_cache_ring_sriov(adapter)) - return; - -#ifdef CONFIG_IXGBE_DCB - if (ixgbe_cache_ring_dcb(adapter)) - return; -#endif - -#ifdef IXGBE_FCOE - if (ixgbe_cache_ring_fcoe(adapter)) - return; -#endif /* IXGBE_FCOE */ - - if (ixgbe_cache_ring_fdir(adapter)) - return; - - if (ixgbe_cache_ring_rss(adapter)) - return; -} - -/** - * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported - * @adapter: board private structure to initialize - * - * Attempt to configure the interrupts using the best available - * capabilities of the hardware and the kernel. - **/ -static int ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) -{ - struct ixgbe_hw *hw = &adapter->hw; - int err = 0; - int vector, v_budget; - - /* - * It's easy to be greedy for MSI-X vectors, but it really - * doesn't do us much good if we have a lot more vectors - * than CPU's. So let's be conservative and only ask for - * (roughly) the same number of vectors as there are CPU's. - * The default is to use pairs of vectors. - */ - v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues); - v_budget = min_t(int, v_budget, num_online_cpus()); - v_budget += NON_Q_VECTORS; - - /* - * At the same time, hardware can only support a maximum of - * hw.mac->max_msix_vectors vectors. With features - * such as RSS and VMDq, we can easily surpass the number of Rx and Tx - * descriptor queues supported by our device. Thus, we cap it off in - * those rare cases where the cpu count also exceeds our vector limit. - */ - v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors); - - /* A failure in MSI-X entry allocation isn't fatal, but it does - * mean we disable MSI-X capabilities of the adapter. */ - adapter->msix_entries = kcalloc(v_budget, - sizeof(struct msix_entry), GFP_KERNEL); - if (adapter->msix_entries) { - for (vector = 0; vector < v_budget; vector++) - adapter->msix_entries[vector].entry = vector; - - ixgbe_acquire_msix_vectors(adapter, v_budget); - - if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) - goto out; - } - - adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; - adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED; - if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { - e_err(probe, - "ATR is not supported while multiple " - "queues are disabled. Disabling Flow Director\n"); - } - adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; - adapter->atr_sample_rate = 0; - if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) - ixgbe_disable_sriov(adapter); - - err = ixgbe_set_num_queues(adapter); - if (err) - return err; - - err = pci_enable_msi(adapter->pdev); - if (!err) { - adapter->flags |= IXGBE_FLAG_MSI_ENABLED; - } else { - netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev, - "Unable to allocate MSI interrupt, " - "falling back to legacy. Error: %d\n", err); - /* reset err */ - err = 0; - } - -out: - return err; -} - -static void ixgbe_add_ring(struct ixgbe_ring *ring, - struct ixgbe_ring_container *head) -{ - ring->next = head->ring; - head->ring = ring; - head->count++; -} - -/** - * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector - * @adapter: board private structure to initialize - * @v_idx: index of vector in adapter struct - * - * We allocate one q_vector. If allocation fails we return -ENOMEM. - **/ -static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter, int v_idx, - int txr_count, int txr_idx, - int rxr_count, int rxr_idx) -{ - struct ixgbe_q_vector *q_vector; - struct ixgbe_ring *ring; - int node = -1; - int cpu = -1; - int ring_count, size; - - ring_count = txr_count + rxr_count; - size = sizeof(struct ixgbe_q_vector) + - (sizeof(struct ixgbe_ring) * ring_count); - - /* customize cpu for Flow Director mapping */ - if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { - if (cpu_online(v_idx)) { - cpu = v_idx; - node = cpu_to_node(cpu); - } - } - - /* allocate q_vector and rings */ - q_vector = kzalloc_node(size, GFP_KERNEL, node); - if (!q_vector) - q_vector = kzalloc(size, GFP_KERNEL); - if (!q_vector) - return -ENOMEM; - - /* setup affinity mask and node */ - if (cpu != -1) - cpumask_set_cpu(cpu, &q_vector->affinity_mask); - else - cpumask_copy(&q_vector->affinity_mask, cpu_online_mask); - q_vector->numa_node = node; - - /* initialize NAPI */ - netif_napi_add(adapter->netdev, &q_vector->napi, - ixgbe_poll, 64); - - /* tie q_vector and adapter together */ - adapter->q_vector[v_idx] = q_vector; - q_vector->adapter = adapter; - q_vector->v_idx = v_idx; - - /* initialize work limits */ - q_vector->tx.work_limit = adapter->tx_work_limit; - - /* initialize pointer to rings */ - ring = q_vector->ring; - - while (txr_count) { - /* assign generic ring traits */ - ring->dev = &adapter->pdev->dev; - ring->netdev = adapter->netdev; - - /* configure backlink on ring */ - ring->q_vector = q_vector; - - /* update q_vector Tx values */ - ixgbe_add_ring(ring, &q_vector->tx); - - /* apply Tx specific ring traits */ - ring->count = adapter->tx_ring_count; - ring->queue_index = txr_idx; - - /* assign ring to adapter */ - adapter->tx_ring[txr_idx] = ring; - - /* update count and index */ - txr_count--; - txr_idx++; - - /* push pointer to next ring */ - ring++; - } - - while (rxr_count) { - /* assign generic ring traits */ - ring->dev = &adapter->pdev->dev; - ring->netdev = adapter->netdev; - - /* configure backlink on ring */ - ring->q_vector = q_vector; - - /* update q_vector Rx values */ - ixgbe_add_ring(ring, &q_vector->rx); - - /* - * 82599 errata, UDP frames with a 0 checksum - * can be marked as checksum errors. - */ - if (adapter->hw.mac.type == ixgbe_mac_82599EB) - set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state); - - /* apply Rx specific ring traits */ - ring->count = adapter->rx_ring_count; - ring->queue_index = rxr_idx; - - /* assign ring to adapter */ - adapter->rx_ring[rxr_idx] = ring; - - /* update count and index */ - rxr_count--; - rxr_idx++; - - /* push pointer to next ring */ - ring++; - } - - return 0; -} - -/** - * ixgbe_free_q_vector - Free memory allocated for specific interrupt vector - * @adapter: board private structure to initialize - * @v_idx: Index of vector to be freed - * - * This function frees the memory allocated to the q_vector. In addition if - * NAPI is enabled it will delete any references to the NAPI struct prior - * to freeing the q_vector. - **/ -static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx) -{ - struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx]; - struct ixgbe_ring *ring; - - ixgbe_for_each_ring(ring, q_vector->tx) - adapter->tx_ring[ring->queue_index] = NULL; - - ixgbe_for_each_ring(ring, q_vector->rx) - adapter->rx_ring[ring->queue_index] = NULL; - - adapter->q_vector[v_idx] = NULL; - netif_napi_del(&q_vector->napi); - - /* - * ixgbe_get_stats64() might access the rings on this vector, - * we must wait a grace period before freeing it. - */ - kfree_rcu(q_vector, rcu); -} - -/** - * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors - * @adapter: board private structure to initialize - * - * We allocate one q_vector per queue interrupt. If allocation fails we - * return -ENOMEM. - **/ -static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) -{ - int q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; - int rxr_remaining = adapter->num_rx_queues; - int txr_remaining = adapter->num_tx_queues; - int rxr_idx = 0, txr_idx = 0, v_idx = 0; - int err; - - /* only one q_vector if MSI-X is disabled. */ - if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) - q_vectors = 1; - - if (q_vectors >= (rxr_remaining + txr_remaining)) { - for (; rxr_remaining; v_idx++, q_vectors--) { - int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors); - err = ixgbe_alloc_q_vector(adapter, v_idx, - 0, 0, rqpv, rxr_idx); - - if (err) - goto err_out; - - /* update counts and index */ - rxr_remaining -= rqpv; - rxr_idx += rqpv; - } - } - - for (; q_vectors; v_idx++, q_vectors--) { - int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors); - int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors); - err = ixgbe_alloc_q_vector(adapter, v_idx, - tqpv, txr_idx, - rqpv, rxr_idx); - - if (err) - goto err_out; - - /* update counts and index */ - rxr_remaining -= rqpv; - rxr_idx += rqpv; - txr_remaining -= tqpv; - txr_idx += tqpv; - } - - return 0; - -err_out: - while (v_idx) { - v_idx--; - ixgbe_free_q_vector(adapter, v_idx); - } - - return -ENOMEM; -} - -/** - * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors - * @adapter: board private structure to initialize - * - * This function frees the memory allocated to the q_vectors. In addition if - * NAPI is enabled it will delete any references to the NAPI struct prior - * to freeing the q_vector. - **/ -static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter) -{ - int v_idx, q_vectors; - - if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) - q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; - else - q_vectors = 1; - - for (v_idx = 0; v_idx < q_vectors; v_idx++) - ixgbe_free_q_vector(adapter, v_idx); -} - -static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter) -{ - if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { - adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; - pci_disable_msix(adapter->pdev); - kfree(adapter->msix_entries); - adapter->msix_entries = NULL; - } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) { - adapter->flags &= ~IXGBE_FLAG_MSI_ENABLED; - pci_disable_msi(adapter->pdev); - } -} - -/** - * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme - * @adapter: board private structure to initialize - * - * We determine which interrupt scheme to use based on... - * - Kernel support (MSI, MSI-X) - * - which can be user-defined (via MODULE_PARAM) - * - Hardware queue count (num_*_queues) - * - defined by miscellaneous hardware support/features (RSS, etc.) - **/ -int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter) -{ - int err; - - /* Number of supported queues */ - err = ixgbe_set_num_queues(adapter); - if (err) - return err; - - err = ixgbe_set_interrupt_capability(adapter); - if (err) { - e_dev_err("Unable to setup interrupt capabilities\n"); - goto err_set_interrupt; - } - - err = ixgbe_alloc_q_vectors(adapter); - if (err) { - e_dev_err("Unable to allocate memory for queue vectors\n"); - goto err_alloc_q_vectors; - } - - ixgbe_cache_ring_register(adapter); - - e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n", - (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled", - adapter->num_rx_queues, adapter->num_tx_queues); - - set_bit(__IXGBE_DOWN, &adapter->state); - - return 0; - -err_alloc_q_vectors: - ixgbe_reset_interrupt_capability(adapter); -err_set_interrupt: - return err; -} - -/** - * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings - * @adapter: board private structure to clear interrupt scheme on - * - * We go through and clear interrupt specific resources and reset the structure - * to pre-load conditions - **/ -void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter) -{ - adapter->num_tx_queues = 0; - adapter->num_rx_queues = 0; - - ixgbe_free_q_vectors(adapter); - ixgbe_reset_interrupt_capability(adapter); -} - /** * ixgbe_sw_init - Initialize general software structures (struct ixgbe_adapter) * @adapter: board private structure to initialize @@ -6557,26 +5682,6 @@ static void ixgbe_service_task(struct work_struct *work) ixgbe_service_event_complete(adapter); } -void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens, - u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx) -{ - struct ixgbe_adv_tx_context_desc *context_desc; - u16 i = tx_ring->next_to_use; - - context_desc = IXGBE_TX_CTXTDESC(tx_ring, i); - - i++; - tx_ring->next_to_use = (i < tx_ring->count) ? i : 0; - - /* set bits to identify this as an advanced context descriptor */ - type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT; - - context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); - context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof); - context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd); - context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); -} - static int ixgbe_tso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, u8 *hdr_len) @@ -7387,6 +6492,7 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev, return stats; } +#ifdef CONFIG_IXGBE_DCB /* ixgbe_validate_rtr - verify 802.1Qp to Rx packet buffer mapping is valid. * #adapter: pointer to ixgbe_adapter * @tc: number of traffic classes currently enabled @@ -7481,6 +6587,7 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) return 0; } +#endif /* CONFIG_IXGBE_DCB */ void ixgbe_do_reset(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -7590,7 +6697,9 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk, .ndo_get_vf_config = ixgbe_ndo_get_vf_config, .ndo_get_stats64 = ixgbe_get_stats64, +#ifdef CONFIG_IXGBE_DCB .ndo_setup_tc = ixgbe_setup_tc, +#endif #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = ixgbe_netpoll, #endif -- GitLab From da24e906cbfc08171d24a2b7cf66fad565fdd121 Mon Sep 17 00:00:00 2001 From: Haiyang Zhang Date: Mon, 19 Mar 2012 17:27:06 -0400 Subject: [PATCH 1830/1846] net/hyperv: Fix the code handling tx busy Instead of dropping the packet, we keep the skb buffer, and return NETDEV_TX_BUSY to let upper layer retry send. This will not cause endless loop, because the host is taking data away from ring buffer, and we have called the stop_queue before returning NETDEV_TX_BUSY. The stop_queue was called in the function netvsc_send() in file netvsc.c, then it returns to rndis_filter_send(), which returns to netvsc_start_xmit() in file netvsc_drv.c. So the NETDEV_TX_BUSY is indeed returned AFTER queue is stopped. Signed-off-by: Haiyang Zhang Reviewed-by: K. Y. Srinivasan Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc_drv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 2517d209d602..dd294783b5c5 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -223,13 +223,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) net->stats.tx_bytes += skb->len; net->stats.tx_packets++; } else { - /* we are shutting down or bus overloaded, just drop packet */ - net->stats.tx_dropped++; kfree(packet); - dev_kfree_skb_any(skb); } - return NETDEV_TX_OK; + return ret ? NETDEV_TX_BUSY : NETDEV_TX_OK; } /* -- GitLab From 8f4a0a3d9f9706da5a9d053fe39854c160250ddc Mon Sep 17 00:00:00 2001 From: Alexander Duyck Date: Fri, 16 Mar 2012 23:07:34 +0000 Subject: [PATCH 1831/1846] ixgbe: Fix issues with SR-IOV loopback when flow control is disabled This patch allows us to avoid a Tx hang when SR-IOV is enabled. This hang can be triggered by sending small packets at a rate that was triggering Rx missed errors from the adapter while the internal Tx switch and at least one VF are enabled. This was all due to the fact that under heavy stress the Rx FIFO never drained below the flow control high water mark. This resulted in the Tx FIFO being head of line blocked due to the fact that it relies on the flow control high water mark to determine when it is acceptable for the Tx to place a packet in the Rx FIFO. The resolution for this is to set the FCRTH value to the RXPBSIZE - 32 so that even if the ring is almost completely full we can still place Tx packets on the Rx ring and drop incoming Rx traffic if we do not have sufficient space available in the Rx FIFO. Signed-off-by: Alexander Duyck Tested-by: Sibai Li Signed-off-by: Jeff Kirsher Signed-off-by: David S. Miller --- drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 6117bfd924cc..49aa41fe7b84 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -2011,13 +2011,20 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num) IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg); IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg); - fcrth = hw->fc.high_water[packetbuf_num] << 10; fcrtl = hw->fc.low_water << 10; if (hw->fc.current_mode & ixgbe_fc_tx_pause) { + fcrth = hw->fc.high_water[packetbuf_num] << 10; fcrth |= IXGBE_FCRTH_FCEN; if (hw->fc.send_xon) fcrtl |= IXGBE_FCRTL_XONE; + } else { + /* + * If Tx flow control is disabled, set our high water mark + * to Rx FIFO size minus 32 in order prevent Tx switch + * loopback from stalling on DMA. + */ + fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(packetbuf_num)) - 32; } IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(packetbuf_num), fcrth); -- GitLab From cdbee74ce74cd66de42a6f6d0edfa74fa9a66f2a Mon Sep 17 00:00:00 2001 From: Yi Zou Date: Fri, 16 Mar 2012 23:08:11 +0000 Subject: [PATCH 1832/1846] net: do not do gso for CHECKSUM_UNNECESSARY in netif_needs_gso This is related to fixing the bug of dropping FCoE frames when disabling tx ip checksum by 'ethtool -K ethx tx off'. The FCoE protocol stack driver would use CHECKSUM_UNNECESSARY on tx path instead of CHECKSUM_PARTIAL (as indicated in the 2/2 of this series). To do so, netif_needs_gso() has to be changed here to not do gso for both CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY. Ref. to original discussion thread: http://patchwork.ozlabs.org/patch/146567/ Signed-off-by: Yi Zou Tested-by: Ross Brattain Signed-off-by: Jeff Kirsher Signed-off-by: David S. Miller --- include/linux/netdevice.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 4535a4ea9760..261067b94559 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2657,7 +2657,8 @@ static inline bool netif_needs_gso(struct sk_buff *skb, netdev_features_t features) { return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || - unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); + unlikely((skb->ip_summed != CHECKSUM_PARTIAL) && + (skb->ip_summed != CHECKSUM_UNNECESSARY))); } static inline void netif_set_gso_max_size(struct net_device *dev, -- GitLab From cf64bc8f093581d0697b65ea8dd04bdd27a676b0 Mon Sep 17 00:00:00 2001 From: Yi Zou Date: Fri, 16 Mar 2012 23:08:12 +0000 Subject: [PATCH 1833/1846] fcoe: use CHECKSUM_UNNECESSARY instead of CHECKSUM_PARTIAL on tx Fix a bug when using 'ethtool -K ethx tx off' to turn off tx ip checksum, FCoE CRC offload should not be impacte. The skb_checksum_help() is needed only if it's not FCoE traffic for ip checksum, regardless of ethtool toggling the tx ip checksum on or off. Instead of using CHECKSUM_PARTIAL, we will use CHECKSUM_UNNECESSARY as a proper indication to avoid sw ip checksum on FCoE frames. Ref. to original discussion thread: http://patchwork.ozlabs.org/patch/146567/ CC: "James E.J. Bottomley" CC: Robert Love Signed-off-by: Yi Zou Tested-by: Ross Brattain Signed-off-by: Jeff Kirsher Signed-off-by: David S. Miller --- drivers/scsi/fcoe/fcoe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index e9599600aa23..c164890224d2 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1498,7 +1498,7 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) /* crc offload */ if (likely(lport->crc_offload)) { - skb->ip_summed = CHECKSUM_PARTIAL; + skb->ip_summed = CHECKSUM_UNNECESSARY; skb->csum_start = skb_headroom(skb); skb->csum_offset = skb->len; crc = 0; -- GitLab From 3af79302b400e05b45e377993a8870869500466b Mon Sep 17 00:00:00 2001 From: Yi Zou Date: Mon, 19 Mar 2012 11:12:41 +0000 Subject: [PATCH 1834/1846] net: update the usage of CHECKSUM_UNNECESSARY As suggested by Ben, this adds the clarification on the usage of CHECKSUM_UNNECESSARY on the outgoing patch. Also add the usage description of NETIF_F_FCOE_CRC and CHECKSUM_UNNECESSARY for the kernel FCoE protocol driver. This is a follow-up to the following: http://patchwork.ozlabs.org/patch/147315/ Signed-off-by: Yi Zou Cc: Ben Hutchings Cc: Jeff Kirsher Cc: www.Open-FCoE.org Signed-off-by: David S. Miller --- include/linux/skbuff.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8dc8257eab8b..a2b9953b582d 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -94,6 +94,13 @@ * about CHECKSUM_UNNECESSARY. 8) * NETIF_F_IPV6_CSUM about as dumb as the last one but does IPv6 instead. * + * UNNECESSARY: device will do per protocol specific csum. Protocol drivers + * that do not want net to perform the checksum calculation should use + * this flag in their outgoing skbs. + * NETIF_F_FCOE_CRC this indicates the device can do FCoE FC CRC + * offload. Correspondingly, the FCoE protocol driver + * stack should use CHECKSUM_UNNECESSARY. + * * Any questions? No questions, good. --ANK */ -- GitLab From dc72d99dabb870ca5bd6d9fff674be853bb4a88d Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Sun, 18 Mar 2012 02:40:48 +0000 Subject: [PATCH 1835/1846] net: bpf_jit: fix BPF_S_LDX_B_MSH compilation Matt Evans spotted that x86 bpf_jit was incorrectly handling negative constant offsets in BPF_S_LDX_B_MSH instruction. We need to abort JIT compilation like we do in common_load so that filter uses the interpreter code and can call __load_pointer() Reference: http://lists.openwall.net/netdev/2011/07/19/11 Thanks to Indan Zupancic to bring back this issue. Reported-by: Matt Evans Reported-by: Indan Zupancic Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- arch/x86/net/bpf_jit_comp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 7c1b765ecc59..5671752f8d9c 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -475,8 +475,10 @@ void bpf_jit_compile(struct sk_filter *fp) case BPF_S_LD_W_ABS: func = sk_load_word; common_load: seen |= SEEN_DATAREF; - if ((int)K < 0) + if ((int)K < 0) { + /* Abort the JIT because __load_pointer() is needed. */ goto out; + } t_offset = func - (image + addrs[i]); EMIT1_off32(0xbe, K); /* mov imm32,%esi */ EMIT1_off32(0xe8, t_offset); /* call */ @@ -489,14 +491,8 @@ common_load: seen |= SEEN_DATAREF; goto common_load; case BPF_S_LDX_B_MSH: if ((int)K < 0) { - if (pc_ret0 > 0) { - /* addrs[pc_ret0 - 1] is the start address */ - EMIT_JMP(addrs[pc_ret0 - 1] - addrs[i]); - break; - } - CLEAR_A(); - EMIT_JMP(cleanup_addr - addrs[i]); - break; + /* Abort the JIT because __load_pointer() is needed. */ + goto out; } seen |= SEEN_DATAREF | SEEN_XREG; t_offset = sk_load_byte_msh - (image + addrs[i]); -- GitLab From ba568335b089e0a27829e3a6117a7e1bf957ad07 Mon Sep 17 00:00:00 2001 From: Vladimir Ermakov Date: Sat, 17 Mar 2012 13:10:50 +0000 Subject: [PATCH 1836/1846] fs_enet: Add MPC5125 FEC support and PHY interface selection Add compatible string for MPC5125 FEC. The FEC on MPC5125 additionally supports RMII PHY interface. Configure controller/PHY interface type according to the optional phy-connection-type property in the ethernet node. This property should be either "rmii" or "mii". Signed-off-by: Vladimir Ermakov Signed-off-by: Anatolij Gustschin Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/fs_enet/fec.h | 6 ++++-- .../ethernet/freescale/fs_enet/fs_enet-main.c | 20 +++++++++++++++++-- .../net/ethernet/freescale/fs_enet/mac-fec.c | 9 ++++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/freescale/fs_enet/fec.h b/drivers/net/ethernet/freescale/fs_enet/fec.h index e980527e2b99..b9fe5bde432a 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fec.h +++ b/drivers/net/ethernet/freescale/fs_enet/fec.h @@ -23,6 +23,10 @@ #define FEC_ECNTRL_ETHER_EN 0x00000002 #define FEC_ECNTRL_RESET 0x00000001 +/* RMII mode enabled only when MII_MODE bit is set too. */ +#define FEC_RCNTRL_RMII_MODE (0x00000100 | \ + FEC_RCNTRL_MII_MODE | FEC_RCNTRL_FCE) +#define FEC_RCNTRL_FCE 0x00000020 #define FEC_RCNTRL_BC_REJ 0x00000010 #define FEC_RCNTRL_PROM 0x00000008 #define FEC_RCNTRL_MII_MODE 0x00000004 @@ -33,8 +37,6 @@ #define FEC_TCNTRL_HBC 0x00000002 #define FEC_TCNTRL_GTS 0x00000001 - - /* * Delay to wait for FEC reset command to complete (in us) */ diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c index 999638a7c851..e4e6cd2c5f82 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c @@ -790,16 +790,20 @@ static int fs_init_phy(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); struct phy_device *phydev; + phy_interface_t iface; fep->oldlink = 0; fep->oldspeed = 0; fep->oldduplex = -1; + iface = fep->fpi->use_rmii ? + PHY_INTERFACE_MODE_RMII : PHY_INTERFACE_MODE_MII; + phydev = of_phy_connect(dev, fep->fpi->phy_node, &fs_adjust_link, 0, - PHY_INTERFACE_MODE_MII); + iface); if (!phydev) { phydev = of_phy_connect_fixed_link(dev, &fs_adjust_link, - PHY_INTERFACE_MODE_MII); + iface); } if (!phydev) { dev_err(&dev->dev, "Could not attach to PHY\n"); @@ -1007,6 +1011,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev) struct fs_platform_info *fpi; const u32 *data; const u8 *mac_addr; + const char *phy_connection_type; int privsize, len, ret = -ENODEV; match = of_match_device(fs_enet_match, &ofdev->dev); @@ -1035,6 +1040,13 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev) NULL))) goto out_free_fpi; + if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) { + phy_connection_type = of_get_property(ofdev->dev.of_node, + "phy-connection-type", NULL); + if (phy_connection_type && !strcmp("rmii", phy_connection_type)) + fpi->use_rmii = 1; + } + privsize = sizeof(*fep) + sizeof(struct sk_buff **) * (fpi->rx_ring + fpi->tx_ring); @@ -1150,6 +1162,10 @@ static struct of_device_id fs_enet_match[] = { .compatible = "fsl,mpc5121-fec", .data = (void *)&fs_fec_ops, }, + { + .compatible = "fsl,mpc5125-fec", + .data = (void *)&fs_fec_ops, + }, #else { .compatible = "fsl,pq1-fec-enet", diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c index b9fbc83d64a7..9ae6cdbcac2e 100644 --- a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c +++ b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c @@ -322,10 +322,11 @@ static void restart(struct net_device *dev) FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ #else /* - * Only set MII mode - do not touch maximum frame length + * Only set MII/RMII mode - do not touch maximum frame length * configured before. */ - FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); + FS(fecp, r_cntrl, fpi->use_rmii ? + FEC_RCNTRL_RMII_MODE : FEC_RCNTRL_MII_MODE); #endif /* * adjust to duplex mode @@ -381,7 +382,9 @@ static void stop(struct net_device *dev) /* shut down FEC1? that's where the mii bus is */ if (fpi->has_phy) { - FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ + FS(fecp, r_cntrl, fpi->use_rmii ? + FEC_RCNTRL_RMII_MODE : + FEC_RCNTRL_MII_MODE); /* MII/RMII enable */ FS(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); FW(fecp, ievent, FEC_ENET_MII); FW(fecp, mii_speed, feci->mii_speed); -- GitLab From 1c3ac4289a0e4d60cbd4787b4a91de4a0c785df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Pan=28=E6=BD=98=E5=8D=AB=E5=B9=B3=29?= Date: Sat, 17 Mar 2012 17:23:27 +0000 Subject: [PATCH 1837/1846] bonding: send igmp report for its master Liang Zheng(lzheng@redhat.com) found that in the following topo, bonding does not send igmp report when we trigger a fail-over of bonding. eth0-- |-- bond0 -- br0 eth1-- modprobe bonding mode=1 miimon=100 resend_igmp=10 ifconfig bond0 up ifenslave bond0 eth0 eth1 brctl addbr br0 ifconfig br0 192.168.100.2/24 up brctl addif br0 bond0 Add 192.168.100.2(br0) into a multicast group, like 224.10.10.10, then trigger a fali-over in bonding. You can see that parameter "resend_igmp" does not work. The reason is that when we add br0 into a multicast group, it does not propagate multicast knowledge down to its ports. If we choose to propagate multicast knowledge down to all ports for bridge, then we have to track every change that is done to bridge, and keep a backup for all ports. It is hard to track, I think. Instead I choose to modify bonding to send igmp report for its master. Changelog: V2: correct comments V3: move this check into bond_resend_igmp_join_requests() V4: only send igmp reports if bond is enslaved to a bridge Signed-off-by: Weiping Pan Signed-off-by: David S. Miller --- drivers/net/bonding/bond_main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 435984ad8b2f..0730203a19f2 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -766,18 +766,30 @@ static void __bond_resend_igmp_join_requests(struct net_device *dev) */ static void bond_resend_igmp_join_requests(struct bonding *bond) { - struct net_device *vlan_dev; + struct net_device *bond_dev, *vlan_dev, *master_dev; struct vlan_entry *vlan; read_lock(&bond->lock); + bond_dev = bond->dev; + /* rejoin all groups on bond device */ - __bond_resend_igmp_join_requests(bond->dev); + __bond_resend_igmp_join_requests(bond_dev); + + /* + * if bond is enslaved to a bridge, + * then rejoin all groups on its master + */ + master_dev = bond_dev->master; + if (master_dev) + if ((master_dev->priv_flags & IFF_EBRIDGE) + && (bond_dev->priv_flags & IFF_BRIDGE_PORT)) + __bond_resend_igmp_join_requests(master_dev); /* rejoin all groups on vlan devices */ list_for_each_entry(vlan, &bond->vlan_list, vlan_list) { rcu_read_lock(); - vlan_dev = __vlan_find_dev_deep(bond->dev, + vlan_dev = __vlan_find_dev_deep(bond_dev, vlan->vlan_id); rcu_read_unlock(); if (vlan_dev) -- GitLab From 58a3de0592454c216c68427fa3c31a34823f5115 Mon Sep 17 00:00:00 2001 From: Eugenia Emantayev Date: Sun, 18 Mar 2012 04:32:08 +0000 Subject: [PATCH 1838/1846] mlx4_core: fix race on comm channel Prevent race condition between commands on comm channel. Happened while unloading the driver when switching from event to polling mode. VF got completion on the last command before switching to polling mode, but toggle was not changed. After the fix - VF will not write the next command before toggle is updated. Signed-off-by: Eugenia Emantayev Signed-off-by: David S. Miller --- drivers/net/ethernet/mellanox/mlx4/cmd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 48d5c48d7ce8..773c70ea3f62 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -239,6 +239,7 @@ static int mlx4_comm_cmd_wait(struct mlx4_dev *dev, u8 op, { struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; struct mlx4_cmd_context *context; + unsigned long end; int err = 0; down(&cmd->event_sem); @@ -268,6 +269,14 @@ static int mlx4_comm_cmd_wait(struct mlx4_dev *dev, u8 op, } out: + /* wait for comm channel ready + * this is necessary for prevention the race + * when switching between event to polling mode + */ + end = msecs_to_jiffies(timeout) + jiffies; + while (comm_pending(dev) && time_before(jiffies, end)) + cond_resched(); + spin_lock(&cmd->context_lock); context->next = cmd->free_head; cmd->free_head = context - cmd->context; -- GitLab From 49099122a403b907dc12a5e66033678a07c68ba3 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Sun, 18 Mar 2012 11:03:05 +0000 Subject: [PATCH 1839/1846] phy: add am79c874 PHY support Signed-off-by: Heiko Schocher Signed-off-by: Anatolij Gustschin Signed-off-by: David S. Miller --- drivers/net/phy/Kconfig | 5 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/amd.c | 102 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 drivers/net/phy/amd.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index fbdcdf83cbfd..0e01f4e5cd64 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -15,6 +15,11 @@ if PHYLIB comment "MII PHY device drivers" +config AMD_PHY + tristate "Drivers for the AMD PHYs" + ---help--- + Currently supports the am79c874 + config MARVELL_PHY tristate "Drivers for Marvell PHYs" ---help--- diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index e15c83fecbe0..b7438b1b94b9 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -24,3 +24,4 @@ obj-$(CONFIG_STE10XP) += ste10Xp.o obj-$(CONFIG_MICREL_PHY) += micrel.o obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o +obj-$(CONFIG_AMD_PHY) += amd.o diff --git a/drivers/net/phy/amd.c b/drivers/net/phy/amd.c new file mode 100644 index 000000000000..cfabd5fe5372 --- /dev/null +++ b/drivers/net/phy/amd.c @@ -0,0 +1,102 @@ +/* + * Driver for AMD am79c PHYs + * + * Author: Heiko Schocher + * + * Copyright (c) 2011 DENX Software Engineering GmbH + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ +#include +#include +#include +#include +#include +#include + +#define PHY_ID_AM79C874 0x0022561b + +#define MII_AM79C_IR 17 /* Interrupt Status/Control Register */ +#define MII_AM79C_IR_EN_LINK 0x0400 /* IR enable Linkstate */ +#define MII_AM79C_IR_EN_ANEG 0x0100 /* IR enable Aneg Complete */ +#define MII_AM79C_IR_IMASK_INIT (MII_AM79C_IR_EN_LINK | MII_AM79C_IR_EN_ANEG) + +MODULE_DESCRIPTION("AMD PHY driver"); +MODULE_AUTHOR("Heiko Schocher "); +MODULE_LICENSE("GPL"); + +static int am79c_ack_interrupt(struct phy_device *phydev) +{ + int err; + + err = phy_read(phydev, MII_BMSR); + if (err < 0) + return err; + + err = phy_read(phydev, MII_AM79C_IR); + if (err < 0) + return err; + + return 0; +} + +static int am79c_config_init(struct phy_device *phydev) +{ + return 0; +} + +static int am79c_config_intr(struct phy_device *phydev) +{ + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + err = phy_write(phydev, MII_AM79C_IR, MII_AM79C_IR_IMASK_INIT); + else + err = phy_write(phydev, MII_AM79C_IR, 0); + + return err; +} + +static struct phy_driver am79c_driver = { + .phy_id = PHY_ID_AM79C874, + .name = "AM79C874", + .phy_id_mask = 0xfffffff0, + .features = PHY_BASIC_FEATURES, + .flags = PHY_HAS_INTERRUPT, + .config_init = am79c_config_init, + .config_aneg = genphy_config_aneg, + .read_status = genphy_read_status, + .ack_interrupt = am79c_ack_interrupt, + .config_intr = am79c_config_intr, + .driver = { .owner = THIS_MODULE,}, +}; + +static int __init am79c_init(void) +{ + int ret; + + ret = phy_driver_register(&am79c_driver); + if (ret) + return ret; + + return 0; +} + +static void __exit am79c_exit(void) +{ + phy_driver_unregister(&am79c_driver); +} + +module_init(am79c_init); +module_exit(am79c_exit); + +static struct mdio_device_id __maybe_unused amd_tbl[] = { + { PHY_ID_AM79C874, 0xfffffff0 }, + { } +}; + +MODULE_DEVICE_TABLE(mdio, amd_tbl); -- GitLab From db82173f23c5289118142fc76111f99ff809df89 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Sun, 18 Mar 2012 20:17:53 +0000 Subject: [PATCH 1840/1846] netdev: driver: ethernet: add cpsw address lookup engine support TI CPSW ethernet switch has a built-in address lookup engine. This patch adds the code necessary for programming this module. Signed-off-by: Cyril Chemparathy Signed-off-by: Mugunthan V N Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/cpsw_ale.c | 641 +++++++++++++++++++++++++++++ drivers/net/ethernet/ti/cpsw_ale.h | 93 +++++ 2 files changed, 734 insertions(+) create mode 100644 drivers/net/ethernet/ti/cpsw_ale.c create mode 100644 drivers/net/ethernet/ti/cpsw_ale.h diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c new file mode 100644 index 000000000000..ca0d48a7e508 --- /dev/null +++ b/drivers/net/ethernet/ti/cpsw_ale.c @@ -0,0 +1,641 @@ +/* + * Texas Instruments 3-Port Ethernet Switch Address Lookup Engine + * + * Copyright (C) 2012 Texas Instruments + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cpsw_ale.h" + +#define BITMASK(bits) (BIT(bits) - 1) +#define ALE_ENTRY_BITS 68 +#define ALE_ENTRY_WORDS DIV_ROUND_UP(ALE_ENTRY_BITS, 32) + +#define ALE_VERSION_MAJOR(rev) ((rev >> 8) & 0xff) +#define ALE_VERSION_MINOR(rev) (rev & 0xff) + +/* ALE Registers */ +#define ALE_IDVER 0x00 +#define ALE_CONTROL 0x08 +#define ALE_PRESCALE 0x10 +#define ALE_UNKNOWNVLAN 0x18 +#define ALE_TABLE_CONTROL 0x20 +#define ALE_TABLE 0x34 +#define ALE_PORTCTL 0x40 + +#define ALE_TABLE_WRITE BIT(31) + +#define ALE_TYPE_FREE 0 +#define ALE_TYPE_ADDR 1 +#define ALE_TYPE_VLAN 2 +#define ALE_TYPE_VLAN_ADDR 3 + +#define ALE_UCAST_PERSISTANT 0 +#define ALE_UCAST_UNTOUCHED 1 +#define ALE_UCAST_OUI 2 +#define ALE_UCAST_TOUCHED 3 + +static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits) +{ + int idx; + + idx = start / 32; + start -= idx * 32; + idx = 2 - idx; /* flip */ + return (ale_entry[idx] >> start) & BITMASK(bits); +} + +static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits, + u32 value) +{ + int idx; + + value &= BITMASK(bits); + idx = start / 32; + start -= idx * 32; + idx = 2 - idx; /* flip */ + ale_entry[idx] &= ~(BITMASK(bits) << start); + ale_entry[idx] |= (value << start); +} + +#define DEFINE_ALE_FIELD(name, start, bits) \ +static inline int cpsw_ale_get_##name(u32 *ale_entry) \ +{ \ + return cpsw_ale_get_field(ale_entry, start, bits); \ +} \ +static inline void cpsw_ale_set_##name(u32 *ale_entry, u32 value) \ +{ \ + cpsw_ale_set_field(ale_entry, start, bits, value); \ +} + +DEFINE_ALE_FIELD(entry_type, 60, 2) +DEFINE_ALE_FIELD(vlan_id, 48, 12) +DEFINE_ALE_FIELD(mcast_state, 62, 2) +DEFINE_ALE_FIELD(port_mask, 66, 3) +DEFINE_ALE_FIELD(super, 65, 1) +DEFINE_ALE_FIELD(ucast_type, 62, 2) +DEFINE_ALE_FIELD(port_num, 66, 2) +DEFINE_ALE_FIELD(blocked, 65, 1) +DEFINE_ALE_FIELD(secure, 64, 1) +DEFINE_ALE_FIELD(vlan_untag_force, 24, 3) +DEFINE_ALE_FIELD(vlan_reg_mcast, 16, 3) +DEFINE_ALE_FIELD(vlan_unreg_mcast, 8, 3) +DEFINE_ALE_FIELD(vlan_member_list, 0, 3) +DEFINE_ALE_FIELD(mcast, 40, 1) + +/* The MAC address field in the ALE entry cannot be macroized as above */ +static inline void cpsw_ale_get_addr(u32 *ale_entry, u8 *addr) +{ + int i; + + for (i = 0; i < 6; i++) + addr[i] = cpsw_ale_get_field(ale_entry, 40 - 8*i, 8); +} + +static inline void cpsw_ale_set_addr(u32 *ale_entry, u8 *addr) +{ + int i; + + for (i = 0; i < 6; i++) + cpsw_ale_set_field(ale_entry, 40 - 8*i, 8, addr[i]); +} + +static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry) +{ + int i; + + WARN_ON(idx > ale->params.ale_entries); + + __raw_writel(idx, ale->params.ale_regs + ALE_TABLE_CONTROL); + + for (i = 0; i < ALE_ENTRY_WORDS; i++) + ale_entry[i] = __raw_readl(ale->params.ale_regs + + ALE_TABLE + 4 * i); + + return idx; +} + +static int cpsw_ale_write(struct cpsw_ale *ale, int idx, u32 *ale_entry) +{ + int i; + + WARN_ON(idx > ale->params.ale_entries); + + for (i = 0; i < ALE_ENTRY_WORDS; i++) + __raw_writel(ale_entry[i], ale->params.ale_regs + + ALE_TABLE + 4 * i); + + __raw_writel(idx | ALE_TABLE_WRITE, ale->params.ale_regs + + ALE_TABLE_CONTROL); + + return idx; +} + +static int cpsw_ale_match_addr(struct cpsw_ale *ale, u8 *addr) +{ + u32 ale_entry[ALE_ENTRY_WORDS]; + int type, idx; + + for (idx = 0; idx < ale->params.ale_entries; idx++) { + u8 entry_addr[6]; + + cpsw_ale_read(ale, idx, ale_entry); + type = cpsw_ale_get_entry_type(ale_entry); + if (type != ALE_TYPE_ADDR && type != ALE_TYPE_VLAN_ADDR) + continue; + cpsw_ale_get_addr(ale_entry, entry_addr); + if (memcmp(entry_addr, addr, 6) == 0) + return idx; + } + return -ENOENT; +} + +static int cpsw_ale_match_free(struct cpsw_ale *ale) +{ + u32 ale_entry[ALE_ENTRY_WORDS]; + int type, idx; + + for (idx = 0; idx < ale->params.ale_entries; idx++) { + cpsw_ale_read(ale, idx, ale_entry); + type = cpsw_ale_get_entry_type(ale_entry); + if (type == ALE_TYPE_FREE) + return idx; + } + return -ENOENT; +} + +static int cpsw_ale_find_ageable(struct cpsw_ale *ale) +{ + u32 ale_entry[ALE_ENTRY_WORDS]; + int type, idx; + + for (idx = 0; idx < ale->params.ale_entries; idx++) { + cpsw_ale_read(ale, idx, ale_entry); + type = cpsw_ale_get_entry_type(ale_entry); + if (type != ALE_TYPE_ADDR && type != ALE_TYPE_VLAN_ADDR) + continue; + if (cpsw_ale_get_mcast(ale_entry)) + continue; + type = cpsw_ale_get_ucast_type(ale_entry); + if (type != ALE_UCAST_PERSISTANT && + type != ALE_UCAST_OUI) + return idx; + } + return -ENOENT; +} + +static void cpsw_ale_flush_mcast(struct cpsw_ale *ale, u32 *ale_entry, + int port_mask) +{ + int mask; + + mask = cpsw_ale_get_port_mask(ale_entry); + if ((mask & port_mask) == 0) + return; /* ports dont intersect, not interested */ + mask &= ~port_mask; + + /* free if only remaining port is host port */ + if (mask == BIT(ale->params.ale_ports)) + cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); + else + cpsw_ale_set_port_mask(ale_entry, mask); +} + +static void cpsw_ale_flush_ucast(struct cpsw_ale *ale, u32 *ale_entry, + int port_mask) +{ + int port; + + port = cpsw_ale_get_port_num(ale_entry); + if ((BIT(port) & port_mask) == 0) + return; /* ports dont intersect, not interested */ + cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); +} + +int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask) +{ + u32 ale_entry[ALE_ENTRY_WORDS]; + int ret, idx; + + for (idx = 0; idx < ale->params.ale_entries; idx++) { + cpsw_ale_read(ale, idx, ale_entry); + ret = cpsw_ale_get_entry_type(ale_entry); + if (ret != ALE_TYPE_ADDR && ret != ALE_TYPE_VLAN_ADDR) + continue; + + if (cpsw_ale_get_mcast(ale_entry)) + cpsw_ale_flush_mcast(ale, ale_entry, port_mask); + else + cpsw_ale_flush_ucast(ale, ale_entry, port_mask); + + cpsw_ale_write(ale, idx, ale_entry); + } + return 0; +} + +int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port, int flags) +{ + u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; + int idx; + + cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_ADDR); + cpsw_ale_set_addr(ale_entry, addr); + cpsw_ale_set_ucast_type(ale_entry, ALE_UCAST_PERSISTANT); + cpsw_ale_set_secure(ale_entry, (flags & ALE_SECURE) ? 1 : 0); + cpsw_ale_set_blocked(ale_entry, (flags & ALE_BLOCKED) ? 1 : 0); + cpsw_ale_set_port_num(ale_entry, port); + + idx = cpsw_ale_match_addr(ale, addr); + if (idx < 0) + idx = cpsw_ale_match_free(ale); + if (idx < 0) + idx = cpsw_ale_find_ageable(ale); + if (idx < 0) + return -ENOMEM; + + cpsw_ale_write(ale, idx, ale_entry); + return 0; +} + +int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port) +{ + u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; + int idx; + + idx = cpsw_ale_match_addr(ale, addr); + if (idx < 0) + return -ENOENT; + + cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); + cpsw_ale_write(ale, idx, ale_entry); + return 0; +} + +int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask, + int super, int mcast_state) +{ + u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; + int idx, mask; + + idx = cpsw_ale_match_addr(ale, addr); + if (idx >= 0) + cpsw_ale_read(ale, idx, ale_entry); + + cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_ADDR); + cpsw_ale_set_addr(ale_entry, addr); + cpsw_ale_set_super(ale_entry, super); + cpsw_ale_set_mcast_state(ale_entry, mcast_state); + + mask = cpsw_ale_get_port_mask(ale_entry); + port_mask |= mask; + cpsw_ale_set_port_mask(ale_entry, port_mask); + + if (idx < 0) + idx = cpsw_ale_match_free(ale); + if (idx < 0) + idx = cpsw_ale_find_ageable(ale); + if (idx < 0) + return -ENOMEM; + + cpsw_ale_write(ale, idx, ale_entry); + return 0; +} + +int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask) +{ + u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; + int idx; + + idx = cpsw_ale_match_addr(ale, addr); + if (idx < 0) + return -EINVAL; + + cpsw_ale_read(ale, idx, ale_entry); + + if (port_mask) + cpsw_ale_set_port_mask(ale_entry, port_mask); + else + cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); + + cpsw_ale_write(ale, idx, ale_entry); + return 0; +} + +struct ale_control_info { + const char *name; + int offset, port_offset; + int shift, port_shift; + int bits; +}; + +static const struct ale_control_info ale_controls[ALE_NUM_CONTROLS] = { + [ALE_ENABLE] = { + .name = "enable", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 31, + .port_shift = 0, + .bits = 1, + }, + [ALE_CLEAR] = { + .name = "clear", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 30, + .port_shift = 0, + .bits = 1, + }, + [ALE_AGEOUT] = { + .name = "ageout", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 29, + .port_shift = 0, + .bits = 1, + }, + [ALE_VLAN_NOLEARN] = { + .name = "vlan_nolearn", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 7, + .port_shift = 0, + .bits = 1, + }, + [ALE_NO_PORT_VLAN] = { + .name = "no_port_vlan", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 6, + .port_shift = 0, + .bits = 1, + }, + [ALE_OUI_DENY] = { + .name = "oui_deny", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 5, + .port_shift = 0, + .bits = 1, + }, + [ALE_BYPASS] = { + .name = "bypass", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 4, + .port_shift = 0, + .bits = 1, + }, + [ALE_RATE_LIMIT_TX] = { + .name = "rate_limit_tx", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 3, + .port_shift = 0, + .bits = 1, + }, + [ALE_VLAN_AWARE] = { + .name = "vlan_aware", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 2, + .port_shift = 0, + .bits = 1, + }, + [ALE_AUTH_ENABLE] = { + .name = "auth_enable", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 1, + .port_shift = 0, + .bits = 1, + }, + [ALE_RATE_LIMIT] = { + .name = "rate_limit", + .offset = ALE_CONTROL, + .port_offset = 0, + .shift = 0, + .port_shift = 0, + .bits = 1, + }, + [ALE_PORT_STATE] = { + .name = "port_state", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 0, + .port_shift = 0, + .bits = 2, + }, + [ALE_PORT_DROP_UNTAGGED] = { + .name = "drop_untagged", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 2, + .port_shift = 0, + .bits = 1, + }, + [ALE_PORT_DROP_UNKNOWN_VLAN] = { + .name = "drop_unknown", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 3, + .port_shift = 0, + .bits = 1, + }, + [ALE_PORT_NOLEARN] = { + .name = "nolearn", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 4, + .port_shift = 0, + .bits = 1, + }, + [ALE_PORT_MCAST_LIMIT] = { + .name = "mcast_limit", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 16, + .port_shift = 0, + .bits = 8, + }, + [ALE_PORT_BCAST_LIMIT] = { + .name = "bcast_limit", + .offset = ALE_PORTCTL, + .port_offset = 4, + .shift = 24, + .port_shift = 0, + .bits = 8, + }, + [ALE_PORT_UNKNOWN_VLAN_MEMBER] = { + .name = "unknown_vlan_member", + .offset = ALE_UNKNOWNVLAN, + .port_offset = 0, + .shift = 0, + .port_shift = 0, + .bits = 6, + }, + [ALE_PORT_UNKNOWN_MCAST_FLOOD] = { + .name = "unknown_mcast_flood", + .offset = ALE_UNKNOWNVLAN, + .port_offset = 0, + .shift = 8, + .port_shift = 0, + .bits = 6, + }, + [ALE_PORT_UNKNOWN_REG_MCAST_FLOOD] = { + .name = "unknown_reg_flood", + .offset = ALE_UNKNOWNVLAN, + .port_offset = 0, + .shift = 16, + .port_shift = 0, + .bits = 6, + }, + [ALE_PORT_UNTAGGED_EGRESS] = { + .name = "untagged_egress", + .offset = ALE_UNKNOWNVLAN, + .port_offset = 0, + .shift = 24, + .port_shift = 0, + .bits = 6, + }, +}; + +int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control, + int value) +{ + const struct ale_control_info *info; + int offset, shift; + u32 tmp, mask; + + if (control < 0 || control >= ARRAY_SIZE(ale_controls)) + return -EINVAL; + + info = &ale_controls[control]; + if (info->port_offset == 0 && info->port_shift == 0) + port = 0; /* global, port is a dont care */ + + if (port < 0 || port > ale->params.ale_ports) + return -EINVAL; + + mask = BITMASK(info->bits); + if (value & ~mask) + return -EINVAL; + + offset = info->offset + (port * info->port_offset); + shift = info->shift + (port * info->port_shift); + + tmp = __raw_readl(ale->params.ale_regs + offset); + tmp = (tmp & ~(mask << shift)) | (value << shift); + __raw_writel(tmp, ale->params.ale_regs + offset); + + return 0; +} + +int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control) +{ + const struct ale_control_info *info; + int offset, shift; + u32 tmp; + + if (control < 0 || control >= ARRAY_SIZE(ale_controls)) + return -EINVAL; + + info = &ale_controls[control]; + if (info->port_offset == 0 && info->port_shift == 0) + port = 0; /* global, port is a dont care */ + + if (port < 0 || port > ale->params.ale_ports) + return -EINVAL; + + offset = info->offset + (port * info->port_offset); + shift = info->shift + (port * info->port_shift); + + tmp = __raw_readl(ale->params.ale_regs + offset) >> shift; + return tmp & BITMASK(info->bits); +} + +static void cpsw_ale_timer(unsigned long arg) +{ + struct cpsw_ale *ale = (struct cpsw_ale *)arg; + + cpsw_ale_control_set(ale, 0, ALE_AGEOUT, 1); + + if (ale->ageout) { + ale->timer.expires = jiffies + ale->ageout; + add_timer(&ale->timer); + } +} + +int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout) +{ + del_timer_sync(&ale->timer); + ale->ageout = ageout * HZ; + if (ale->ageout) { + ale->timer.expires = jiffies + ale->ageout; + add_timer(&ale->timer); + } + return 0; +} + +void cpsw_ale_start(struct cpsw_ale *ale) +{ + u32 rev; + + rev = __raw_readl(ale->params.ale_regs + ALE_IDVER); + dev_dbg(ale->params.dev, "initialized cpsw ale revision %d.%d\n", + ALE_VERSION_MAJOR(rev), ALE_VERSION_MINOR(rev)); + cpsw_ale_control_set(ale, 0, ALE_ENABLE, 1); + cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1); + + init_timer(&ale->timer); + ale->timer.data = (unsigned long)ale; + ale->timer.function = cpsw_ale_timer; + if (ale->ageout) { + ale->timer.expires = jiffies + ale->ageout; + add_timer(&ale->timer); + } +} + +void cpsw_ale_stop(struct cpsw_ale *ale) +{ + del_timer_sync(&ale->timer); +} + +struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params) +{ + struct cpsw_ale *ale; + + ale = kzalloc(sizeof(*ale), GFP_KERNEL); + if (!ale) + return NULL; + + ale->params = *params; + ale->ageout = ale->params.ale_ageout * HZ; + + return ale; +} + +int cpsw_ale_destroy(struct cpsw_ale *ale) +{ + if (!ale) + return -EINVAL; + cpsw_ale_stop(ale); + cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0); + kfree(ale); + return 0; +} diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h new file mode 100644 index 000000000000..a95b37beb02d --- /dev/null +++ b/drivers/net/ethernet/ti/cpsw_ale.h @@ -0,0 +1,93 @@ +/* + * Texas Instruments 3-Port Ethernet Switch Address Lookup Engine APIs + * + * Copyright (C) 2012 Texas Instruments + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __TI_CPSW_ALE_H__ +#define __TI_CPSW_ALE_H__ + +struct cpsw_ale_params { + struct device *dev; + void __iomem *ale_regs; + unsigned long ale_ageout; /* in secs */ + unsigned long ale_entries; + unsigned long ale_ports; +}; + +struct cpsw_ale { + struct cpsw_ale_params params; + struct timer_list timer; + unsigned long ageout; +}; + +enum cpsw_ale_control { + /* global */ + ALE_ENABLE, + ALE_CLEAR, + ALE_AGEOUT, + ALE_VLAN_NOLEARN, + ALE_NO_PORT_VLAN, + ALE_OUI_DENY, + ALE_BYPASS, + ALE_RATE_LIMIT_TX, + ALE_VLAN_AWARE, + ALE_AUTH_ENABLE, + ALE_RATE_LIMIT, + /* port controls */ + ALE_PORT_STATE, + ALE_PORT_DROP_UNTAGGED, + ALE_PORT_DROP_UNKNOWN_VLAN, + ALE_PORT_NOLEARN, + ALE_PORT_UNKNOWN_VLAN_MEMBER, + ALE_PORT_UNKNOWN_MCAST_FLOOD, + ALE_PORT_UNKNOWN_REG_MCAST_FLOOD, + ALE_PORT_UNTAGGED_EGRESS, + ALE_PORT_BCAST_LIMIT, + ALE_PORT_MCAST_LIMIT, + ALE_NUM_CONTROLS, +}; + +enum cpsw_ale_port_state { + ALE_PORT_STATE_DISABLE = 0x00, + ALE_PORT_STATE_BLOCK = 0x01, + ALE_PORT_STATE_LEARN = 0x02, + ALE_PORT_STATE_FORWARD = 0x03, +}; + +/* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */ +#define ALE_SECURE 1 +#define ALE_BLOCKED 2 + +#define ALE_MCAST_FWD 0 +#define ALE_MCAST_BLOCK_LEARN_FWD 1 +#define ALE_MCAST_FWD_LEARN 2 +#define ALE_MCAST_FWD_2 3 + +struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params); +int cpsw_ale_destroy(struct cpsw_ale *ale); + +void cpsw_ale_start(struct cpsw_ale *ale); +void cpsw_ale_stop(struct cpsw_ale *ale); + +int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout); +int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask); +int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port, int flags); +int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port); +int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask, + int super, int mcast_state); +int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask); + +int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control); +int cpsw_ale_control_set(struct cpsw_ale *ale, int port, + int control, int value); + +#endif -- GitLab From df828598a755732e717b0adca82f884e44d37576 Mon Sep 17 00:00:00 2001 From: Mugunthan V N Date: Sun, 18 Mar 2012 20:17:54 +0000 Subject: [PATCH 1841/1846] netdev: driver: ethernet: Add TI CPSW driver This patch adds support for TI's CPSW driver. The three port switch gigabit ethernet subsystem provides ethernet packet communication and can be configured as an ethernet switch. Supports 10/100/1000 Mbps. Signed-off-by: Cyril Chemparathy Signed-off-by: Sriramakrishnan A G Signed-off-by: Mugunthan V N Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/Kconfig | 11 + drivers/net/ethernet/ti/Makefile | 2 + drivers/net/ethernet/ti/cpsw.c | 1018 ++++++++++++++++++++++++++++ include/linux/platform_data/cpsw.h | 55 ++ 4 files changed, 1086 insertions(+) create mode 100644 drivers/net/ethernet/ti/cpsw.c create mode 100644 include/linux/platform_data/cpsw.h diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig index de76c70ec8fb..b42252c4bec8 100644 --- a/drivers/net/ethernet/ti/Kconfig +++ b/drivers/net/ethernet/ti/Kconfig @@ -49,6 +49,17 @@ config TI_DAVINCI_CPDMA To compile this driver as a module, choose M here: the module will be called davinci_cpdma. This is recommended. +config TI_CPSW + tristate "TI CPSW Switch Support" + depends on ARM && (ARCH_DAVINCI || SOC_OMAPAM33XX) + select TI_DAVINCI_CPDMA + select TI_DAVINCI_MDIO + ---help--- + This driver supports TI's CPSW Ethernet Switch. + + To compile this driver as a module, choose M here: the module + will be called cpsw. + config TLAN tristate "TI ThunderLAN support" depends on (PCI || EISA) diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile index aedb3af74e5a..91bd8bba78ff 100644 --- a/drivers/net/ethernet/ti/Makefile +++ b/drivers/net/ethernet/ti/Makefile @@ -7,3 +7,5 @@ obj-$(CONFIG_CPMAC) += cpmac.o obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o obj-$(CONFIG_TI_DAVINCI_CPDMA) += davinci_cpdma.o +obj-$(CONFIG_TI_CPSW) += ti_cpsw.o +ti_cpsw-y := cpsw_ale.o cpsw.o diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c new file mode 100644 index 000000000000..c68c9d96312e --- /dev/null +++ b/drivers/net/ethernet/ti/cpsw.c @@ -0,0 +1,1018 @@ +/* + * Texas Instruments Ethernet Switch Driver + * + * Copyright (C) 2012 Texas Instruments + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "cpsw_ale.h" +#include "davinci_cpdma.h" + +#define CPSW_DEBUG (NETIF_MSG_HW | NETIF_MSG_WOL | \ + NETIF_MSG_DRV | NETIF_MSG_LINK | \ + NETIF_MSG_IFUP | NETIF_MSG_INTR | \ + NETIF_MSG_PROBE | NETIF_MSG_TIMER | \ + NETIF_MSG_IFDOWN | NETIF_MSG_RX_ERR | \ + NETIF_MSG_TX_ERR | NETIF_MSG_TX_DONE | \ + NETIF_MSG_PKTDATA | NETIF_MSG_TX_QUEUED | \ + NETIF_MSG_RX_STATUS) + +#define cpsw_info(priv, type, format, ...) \ +do { \ + if (netif_msg_##type(priv) && net_ratelimit()) \ + dev_info(priv->dev, format, ## __VA_ARGS__); \ +} while (0) + +#define cpsw_err(priv, type, format, ...) \ +do { \ + if (netif_msg_##type(priv) && net_ratelimit()) \ + dev_err(priv->dev, format, ## __VA_ARGS__); \ +} while (0) + +#define cpsw_dbg(priv, type, format, ...) \ +do { \ + if (netif_msg_##type(priv) && net_ratelimit()) \ + dev_dbg(priv->dev, format, ## __VA_ARGS__); \ +} while (0) + +#define cpsw_notice(priv, type, format, ...) \ +do { \ + if (netif_msg_##type(priv) && net_ratelimit()) \ + dev_notice(priv->dev, format, ## __VA_ARGS__); \ +} while (0) + +#define CPSW_MAJOR_VERSION(reg) (reg >> 8 & 0x7) +#define CPSW_MINOR_VERSION(reg) (reg & 0xff) +#define CPSW_RTL_VERSION(reg) ((reg >> 11) & 0x1f) + +#define CPDMA_RXTHRESH 0x0c0 +#define CPDMA_RXFREE 0x0e0 +#define CPDMA_TXHDP 0x00 +#define CPDMA_RXHDP 0x20 +#define CPDMA_TXCP 0x40 +#define CPDMA_RXCP 0x60 + +#define cpsw_dma_regs(base, offset) \ + (void __iomem *)((base) + (offset)) +#define cpsw_dma_rxthresh(base, offset) \ + (void __iomem *)((base) + (offset) + CPDMA_RXTHRESH) +#define cpsw_dma_rxfree(base, offset) \ + (void __iomem *)((base) + (offset) + CPDMA_RXFREE) +#define cpsw_dma_txhdp(base, offset) \ + (void __iomem *)((base) + (offset) + CPDMA_TXHDP) +#define cpsw_dma_rxhdp(base, offset) \ + (void __iomem *)((base) + (offset) + CPDMA_RXHDP) +#define cpsw_dma_txcp(base, offset) \ + (void __iomem *)((base) + (offset) + CPDMA_TXCP) +#define cpsw_dma_rxcp(base, offset) \ + (void __iomem *)((base) + (offset) + CPDMA_RXCP) + +#define CPSW_POLL_WEIGHT 64 +#define CPSW_MIN_PACKET_SIZE 60 +#define CPSW_MAX_PACKET_SIZE (1500 + 14 + 4 + 4) + +#define RX_PRIORITY_MAPPING 0x76543210 +#define TX_PRIORITY_MAPPING 0x33221100 +#define CPDMA_TX_PRIORITY_MAP 0x76543210 + +#define cpsw_enable_irq(priv) \ + do { \ + u32 i; \ + for (i = 0; i < priv->num_irqs; i++) \ + enable_irq(priv->irqs_table[i]); \ + } while (0); +#define cpsw_disable_irq(priv) \ + do { \ + u32 i; \ + for (i = 0; i < priv->num_irqs; i++) \ + disable_irq_nosync(priv->irqs_table[i]); \ + } while (0); + +static int debug_level; +module_param(debug_level, int, 0); +MODULE_PARM_DESC(debug_level, "cpsw debug level (NETIF_MSG bits)"); + +static int ale_ageout = 10; +module_param(ale_ageout, int, 0); +MODULE_PARM_DESC(ale_ageout, "cpsw ale ageout interval (seconds)"); + +static int rx_packet_max = CPSW_MAX_PACKET_SIZE; +module_param(rx_packet_max, int, 0); +MODULE_PARM_DESC(rx_packet_max, "maximum receive packet size (bytes)"); + +struct cpsw_ss_regs { + u32 id_ver; + u32 soft_reset; + u32 control; + u32 int_control; + u32 rx_thresh_en; + u32 rx_en; + u32 tx_en; + u32 misc_en; +}; + +struct cpsw_regs { + u32 id_ver; + u32 control; + u32 soft_reset; + u32 stat_port_en; + u32 ptype; +}; + +struct cpsw_slave_regs { + u32 max_blks; + u32 blk_cnt; + u32 flow_thresh; + u32 port_vlan; + u32 tx_pri_map; + u32 ts_ctl; + u32 ts_seq_ltype; + u32 ts_vlan; + u32 sa_lo; + u32 sa_hi; +}; + +struct cpsw_host_regs { + u32 max_blks; + u32 blk_cnt; + u32 flow_thresh; + u32 port_vlan; + u32 tx_pri_map; + u32 cpdma_tx_pri_map; + u32 cpdma_rx_chan_map; +}; + +struct cpsw_sliver_regs { + u32 id_ver; + u32 mac_control; + u32 mac_status; + u32 soft_reset; + u32 rx_maxlen; + u32 __reserved_0; + u32 rx_pause; + u32 tx_pause; + u32 __reserved_1; + u32 rx_pri_map; +}; + +struct cpsw_slave { + struct cpsw_slave_regs __iomem *regs; + struct cpsw_sliver_regs __iomem *sliver; + int slave_num; + u32 mac_control; + struct cpsw_slave_data *data; + struct phy_device *phy; +}; + +struct cpsw_priv { + spinlock_t lock; + struct platform_device *pdev; + struct net_device *ndev; + struct resource *cpsw_res; + struct resource *cpsw_ss_res; + struct napi_struct napi; + struct device *dev; + struct cpsw_platform_data data; + struct cpsw_regs __iomem *regs; + struct cpsw_ss_regs __iomem *ss_regs; + struct cpsw_host_regs __iomem *host_port_regs; + u32 msg_enable; + struct net_device_stats stats; + int rx_packet_max; + int host_port; + struct clk *clk; + u8 mac_addr[ETH_ALEN]; + struct cpsw_slave *slaves; + struct cpdma_ctlr *dma; + struct cpdma_chan *txch, *rxch; + struct cpsw_ale *ale; + /* snapshot of IRQ numbers */ + u32 irqs_table[4]; + u32 num_irqs; +}; + +#define napi_to_priv(napi) container_of(napi, struct cpsw_priv, napi) +#define for_each_slave(priv, func, arg...) \ + do { \ + int idx; \ + for (idx = 0; idx < (priv)->data.slaves; idx++) \ + (func)((priv)->slaves + idx, ##arg); \ + } while (0) + +static void cpsw_intr_enable(struct cpsw_priv *priv) +{ + __raw_writel(0xFF, &priv->ss_regs->tx_en); + __raw_writel(0xFF, &priv->ss_regs->rx_en); + + cpdma_ctlr_int_ctrl(priv->dma, true); + return; +} + +static void cpsw_intr_disable(struct cpsw_priv *priv) +{ + __raw_writel(0, &priv->ss_regs->tx_en); + __raw_writel(0, &priv->ss_regs->rx_en); + + cpdma_ctlr_int_ctrl(priv->dma, false); + return; +} + +void cpsw_tx_handler(void *token, int len, int status) +{ + struct sk_buff *skb = token; + struct net_device *ndev = skb->dev; + struct cpsw_priv *priv = netdev_priv(ndev); + + if (unlikely(netif_queue_stopped(ndev))) + netif_start_queue(ndev); + priv->stats.tx_packets++; + priv->stats.tx_bytes += len; + dev_kfree_skb_any(skb); +} + +void cpsw_rx_handler(void *token, int len, int status) +{ + struct sk_buff *skb = token; + struct net_device *ndev = skb->dev; + struct cpsw_priv *priv = netdev_priv(ndev); + int ret = 0; + + /* free and bail if we are shutting down */ + if (unlikely(!netif_running(ndev)) || + unlikely(!netif_carrier_ok(ndev))) { + dev_kfree_skb_any(skb); + return; + } + if (likely(status >= 0)) { + skb_put(skb, len); + skb->protocol = eth_type_trans(skb, ndev); + netif_receive_skb(skb); + priv->stats.rx_bytes += len; + priv->stats.rx_packets++; + skb = NULL; + } + + if (unlikely(!netif_running(ndev))) { + if (skb) + dev_kfree_skb_any(skb); + return; + } + + if (likely(!skb)) { + skb = netdev_alloc_skb_ip_align(ndev, priv->rx_packet_max); + if (WARN_ON(!skb)) + return; + + ret = cpdma_chan_submit(priv->rxch, skb, skb->data, + skb_tailroom(skb), GFP_KERNEL); + } + WARN_ON(ret < 0); +} + +static irqreturn_t cpsw_interrupt(int irq, void *dev_id) +{ + struct cpsw_priv *priv = dev_id; + + if (likely(netif_running(priv->ndev))) { + cpsw_intr_disable(priv); + cpsw_disable_irq(priv); + napi_schedule(&priv->napi); + } + return IRQ_HANDLED; +} + +static inline int cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num) +{ + if (priv->host_port == 0) + return slave_num + 1; + else + return slave_num; +} + +static int cpsw_poll(struct napi_struct *napi, int budget) +{ + struct cpsw_priv *priv = napi_to_priv(napi); + int num_tx, num_rx; + + num_tx = cpdma_chan_process(priv->txch, 128); + num_rx = cpdma_chan_process(priv->rxch, budget); + + if (num_rx || num_tx) + cpsw_dbg(priv, intr, "poll %d rx, %d tx pkts\n", + num_rx, num_tx); + + if (num_rx < budget) { + napi_complete(napi); + cpsw_intr_enable(priv); + cpdma_ctlr_eoi(priv->dma); + cpsw_enable_irq(priv); + } + + return num_rx; +} + +static inline void soft_reset(const char *module, void __iomem *reg) +{ + unsigned long timeout = jiffies + HZ; + + __raw_writel(1, reg); + do { + cpu_relax(); + } while ((__raw_readl(reg) & 1) && time_after(timeout, jiffies)); + + WARN(__raw_readl(reg) & 1, "failed to soft-reset %s\n", module); +} + +#define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \ + ((mac)[2] << 16) | ((mac)[3] << 24)) +#define mac_lo(mac) (((mac)[4] << 0) | ((mac)[5] << 8)) + +static void cpsw_set_slave_mac(struct cpsw_slave *slave, + struct cpsw_priv *priv) +{ + __raw_writel(mac_hi(priv->mac_addr), &slave->regs->sa_hi); + __raw_writel(mac_lo(priv->mac_addr), &slave->regs->sa_lo); +} + +static void _cpsw_adjust_link(struct cpsw_slave *slave, + struct cpsw_priv *priv, bool *link) +{ + struct phy_device *phy = slave->phy; + u32 mac_control = 0; + u32 slave_port; + + if (!phy) + return; + + slave_port = cpsw_get_slave_port(priv, slave->slave_num); + + if (phy->link) { + mac_control = priv->data.mac_control; + + /* enable forwarding */ + cpsw_ale_control_set(priv->ale, slave_port, + ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); + + if (phy->speed == 1000) + mac_control |= BIT(7); /* GIGABITEN */ + if (phy->duplex) + mac_control |= BIT(0); /* FULLDUPLEXEN */ + *link = true; + } else { + mac_control = 0; + /* disable forwarding */ + cpsw_ale_control_set(priv->ale, slave_port, + ALE_PORT_STATE, ALE_PORT_STATE_DISABLE); + } + + if (mac_control != slave->mac_control) { + phy_print_status(phy); + __raw_writel(mac_control, &slave->sliver->mac_control); + } + + slave->mac_control = mac_control; +} + +static void cpsw_adjust_link(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + bool link = false; + + for_each_slave(priv, _cpsw_adjust_link, priv, &link); + + if (link) { + netif_carrier_on(ndev); + if (netif_running(ndev)) + netif_wake_queue(ndev); + } else { + netif_carrier_off(ndev); + netif_stop_queue(ndev); + } +} + +static inline int __show_stat(char *buf, int maxlen, const char *name, u32 val) +{ + static char *leader = "........................................"; + + if (!val) + return 0; + else + return snprintf(buf, maxlen, "%s %s %10d\n", name, + leader + strlen(name), val); +} + +static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) +{ + char name[32]; + u32 slave_port; + + sprintf(name, "slave-%d", slave->slave_num); + + soft_reset(name, &slave->sliver->soft_reset); + + /* setup priority mapping */ + __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map); + __raw_writel(TX_PRIORITY_MAPPING, &slave->regs->tx_pri_map); + + /* setup max packet size, and mac address */ + __raw_writel(priv->rx_packet_max, &slave->sliver->rx_maxlen); + cpsw_set_slave_mac(slave, priv); + + slave->mac_control = 0; /* no link yet */ + + slave_port = cpsw_get_slave_port(priv, slave->slave_num); + + cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, + 1 << slave_port, 0, ALE_MCAST_FWD_2); + + slave->phy = phy_connect(priv->ndev, slave->data->phy_id, + &cpsw_adjust_link, 0, slave->data->phy_if); + if (IS_ERR(slave->phy)) { + dev_err(priv->dev, "phy %s not found on slave %d\n", + slave->data->phy_id, slave->slave_num); + slave->phy = NULL; + } else { + dev_info(priv->dev, "phy found : id is : 0x%x\n", + slave->phy->phy_id); + phy_start(slave->phy); + } +} + +static void cpsw_init_host_port(struct cpsw_priv *priv) +{ + /* soft reset the controller and initialize ale */ + soft_reset("cpsw", &priv->regs->soft_reset); + cpsw_ale_start(priv->ale); + + /* switch to vlan unaware mode */ + cpsw_ale_control_set(priv->ale, 0, ALE_VLAN_AWARE, 0); + + /* setup host port priority mapping */ + __raw_writel(CPDMA_TX_PRIORITY_MAP, + &priv->host_port_regs->cpdma_tx_pri_map); + __raw_writel(0, &priv->host_port_regs->cpdma_rx_chan_map); + + cpsw_ale_control_set(priv->ale, priv->host_port, + ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); + + cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, 0); + cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, + 1 << priv->host_port, 0, ALE_MCAST_FWD_2); +} + +static int cpsw_ndo_open(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + int i, ret; + u32 reg; + + cpsw_intr_disable(priv); + netif_carrier_off(ndev); + + ret = clk_enable(priv->clk); + if (ret < 0) { + dev_err(priv->dev, "unable to turn on device clock\n"); + return ret; + } + + reg = __raw_readl(&priv->regs->id_ver); + + dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n", + CPSW_MAJOR_VERSION(reg), CPSW_MINOR_VERSION(reg), + CPSW_RTL_VERSION(reg)); + + /* initialize host and slave ports */ + cpsw_init_host_port(priv); + for_each_slave(priv, cpsw_slave_open, priv); + + /* setup tx dma to fixed prio and zero offset */ + cpdma_control_set(priv->dma, CPDMA_TX_PRIO_FIXED, 1); + cpdma_control_set(priv->dma, CPDMA_RX_BUFFER_OFFSET, 0); + + /* disable priority elevation and enable statistics on all ports */ + __raw_writel(0, &priv->regs->ptype); + + /* enable statistics collection only on the host port */ + __raw_writel(0x7, &priv->regs->stat_port_en); + + if (WARN_ON(!priv->data.rx_descs)) + priv->data.rx_descs = 128; + + for (i = 0; i < priv->data.rx_descs; i++) { + struct sk_buff *skb; + + ret = -ENOMEM; + skb = netdev_alloc_skb_ip_align(priv->ndev, + priv->rx_packet_max); + if (!skb) + break; + ret = cpdma_chan_submit(priv->rxch, skb, skb->data, + skb_tailroom(skb), GFP_KERNEL); + if (WARN_ON(ret < 0)) + break; + } + /* continue even if we didn't manage to submit all receive descs */ + cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); + + cpdma_ctlr_start(priv->dma); + cpsw_intr_enable(priv); + napi_enable(&priv->napi); + cpdma_ctlr_eoi(priv->dma); + + return 0; +} + +static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv) +{ + if (!slave->phy) + return; + phy_stop(slave->phy); + phy_disconnect(slave->phy); + slave->phy = NULL; +} + +static int cpsw_ndo_stop(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + + cpsw_info(priv, ifdown, "shutting down cpsw device\n"); + cpsw_intr_disable(priv); + cpdma_ctlr_int_ctrl(priv->dma, false); + cpdma_ctlr_stop(priv->dma); + netif_stop_queue(priv->ndev); + napi_disable(&priv->napi); + netif_carrier_off(priv->ndev); + cpsw_ale_stop(priv->ale); + for_each_slave(priv, cpsw_slave_stop, priv); + clk_disable(priv->clk); + return 0; +} + +static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, + struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + int ret; + + ndev->trans_start = jiffies; + + if (skb_padto(skb, CPSW_MIN_PACKET_SIZE)) { + cpsw_err(priv, tx_err, "packet pad failed\n"); + priv->stats.tx_dropped++; + return NETDEV_TX_OK; + } + + ret = cpdma_chan_submit(priv->txch, skb, skb->data, + skb->len, GFP_KERNEL); + if (unlikely(ret != 0)) { + cpsw_err(priv, tx_err, "desc submit failed\n"); + goto fail; + } + + return NETDEV_TX_OK; +fail: + priv->stats.tx_dropped++; + netif_stop_queue(ndev); + return NETDEV_TX_BUSY; +} + +static void cpsw_ndo_change_rx_flags(struct net_device *ndev, int flags) +{ + /* + * The switch cannot operate in promiscuous mode without substantial + * headache. For promiscuous mode to work, we would need to put the + * ALE in bypass mode and route all traffic to the host port. + * Subsequently, the host will need to operate as a "bridge", learn, + * and flood as needed. For now, we simply complain here and + * do nothing about it :-) + */ + if ((flags & IFF_PROMISC) && (ndev->flags & IFF_PROMISC)) + dev_err(&ndev->dev, "promiscuity ignored!\n"); + + /* + * The switch cannot filter multicast traffic unless it is configured + * in "VLAN Aware" mode. Unfortunately, VLAN awareness requires a + * whole bunch of additional logic that this driver does not implement + * at present. + */ + if ((flags & IFF_ALLMULTI) && !(ndev->flags & IFF_ALLMULTI)) + dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n"); +} + +static void cpsw_ndo_tx_timeout(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + + cpsw_err(priv, tx_err, "transmit timeout, restarting dma\n"); + priv->stats.tx_errors++; + cpsw_intr_disable(priv); + cpdma_ctlr_int_ctrl(priv->dma, false); + cpdma_chan_stop(priv->txch); + cpdma_chan_start(priv->txch); + cpdma_ctlr_int_ctrl(priv->dma, true); + cpsw_intr_enable(priv); + cpdma_ctlr_eoi(priv->dma); +} + +static struct net_device_stats *cpsw_ndo_get_stats(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + return &priv->stats; +} + +#ifdef CONFIG_NET_POLL_CONTROLLER +static void cpsw_ndo_poll_controller(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + + cpsw_intr_disable(priv); + cpdma_ctlr_int_ctrl(priv->dma, false); + cpsw_interrupt(ndev->irq, priv); + cpdma_ctlr_int_ctrl(priv->dma, true); + cpsw_intr_enable(priv); + cpdma_ctlr_eoi(priv->dma); +} +#endif + +static const struct net_device_ops cpsw_netdev_ops = { + .ndo_open = cpsw_ndo_open, + .ndo_stop = cpsw_ndo_stop, + .ndo_start_xmit = cpsw_ndo_start_xmit, + .ndo_change_rx_flags = cpsw_ndo_change_rx_flags, + .ndo_validate_addr = eth_validate_addr, + .ndo_tx_timeout = cpsw_ndo_tx_timeout, + .ndo_get_stats = cpsw_ndo_get_stats, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = cpsw_ndo_poll_controller, +#endif +}; + +static void cpsw_get_drvinfo(struct net_device *ndev, + struct ethtool_drvinfo *info) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + strcpy(info->driver, "TI CPSW Driver v1.0"); + strcpy(info->version, "1.0"); + strcpy(info->bus_info, priv->pdev->name); +} + +static u32 cpsw_get_msglevel(struct net_device *ndev) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + return priv->msg_enable; +} + +static void cpsw_set_msglevel(struct net_device *ndev, u32 value) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + priv->msg_enable = value; +} + +static const struct ethtool_ops cpsw_ethtool_ops = { + .get_drvinfo = cpsw_get_drvinfo, + .get_msglevel = cpsw_get_msglevel, + .set_msglevel = cpsw_set_msglevel, + .get_link = ethtool_op_get_link, +}; + +static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv) +{ + void __iomem *regs = priv->regs; + int slave_num = slave->slave_num; + struct cpsw_slave_data *data = priv->data.slave_data + slave_num; + + slave->data = data; + slave->regs = regs + data->slave_reg_ofs; + slave->sliver = regs + data->sliver_reg_ofs; +} + +static int __devinit cpsw_probe(struct platform_device *pdev) +{ + struct cpsw_platform_data *data = pdev->dev.platform_data; + struct net_device *ndev; + struct cpsw_priv *priv; + struct cpdma_params dma_params; + struct cpsw_ale_params ale_params; + void __iomem *regs; + struct resource *res; + int ret = 0, i, k = 0; + + if (!data) { + pr_err("platform data missing\n"); + return -ENODEV; + } + + ndev = alloc_etherdev(sizeof(struct cpsw_priv)); + if (!ndev) { + pr_err("error allocating net_device\n"); + return -ENOMEM; + } + + platform_set_drvdata(pdev, ndev); + priv = netdev_priv(ndev); + spin_lock_init(&priv->lock); + priv->data = *data; + priv->pdev = pdev; + priv->ndev = ndev; + priv->dev = &ndev->dev; + priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG); + priv->rx_packet_max = max(rx_packet_max, 128); + + if (is_valid_ether_addr(data->slave_data[0].mac_addr)) { + memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN); + pr_info("Detected MACID = %pM", priv->mac_addr); + } else { + random_ether_addr(priv->mac_addr); + pr_info("Random MACID = %pM", priv->mac_addr); + } + + memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); + + priv->slaves = kzalloc(sizeof(struct cpsw_slave) * data->slaves, + GFP_KERNEL); + if (!priv->slaves) { + ret = -EBUSY; + goto clean_ndev_ret; + } + for (i = 0; i < data->slaves; i++) + priv->slaves[i].slave_num = i; + + priv->clk = clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) { + dev_err(priv->dev, "failed to get device clock)\n"); + ret = -EBUSY; + } + + priv->cpsw_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!priv->cpsw_res) { + dev_err(priv->dev, "error getting i/o resource\n"); + ret = -ENOENT; + goto clean_clk_ret; + } + + if (!request_mem_region(priv->cpsw_res->start, + resource_size(priv->cpsw_res), ndev->name)) { + dev_err(priv->dev, "failed request i/o region\n"); + ret = -ENXIO; + goto clean_clk_ret; + } + + regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res)); + if (!regs) { + dev_err(priv->dev, "unable to map i/o region\n"); + goto clean_cpsw_iores_ret; + } + priv->regs = regs; + priv->host_port = data->host_port_num; + priv->host_port_regs = regs + data->host_port_reg_ofs; + + priv->cpsw_ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!priv->cpsw_ss_res) { + dev_err(priv->dev, "error getting i/o resource\n"); + ret = -ENOENT; + goto clean_clk_ret; + } + + if (!request_mem_region(priv->cpsw_ss_res->start, + resource_size(priv->cpsw_ss_res), ndev->name)) { + dev_err(priv->dev, "failed request i/o region\n"); + ret = -ENXIO; + goto clean_clk_ret; + } + + regs = ioremap(priv->cpsw_ss_res->start, + resource_size(priv->cpsw_ss_res)); + if (!regs) { + dev_err(priv->dev, "unable to map i/o region\n"); + goto clean_cpsw_ss_iores_ret; + } + priv->ss_regs = regs; + + for_each_slave(priv, cpsw_slave_init, priv); + + memset(&dma_params, 0, sizeof(dma_params)); + dma_params.dev = &pdev->dev; + dma_params.dmaregs = cpsw_dma_regs((u32)priv->regs, + data->cpdma_reg_ofs); + dma_params.rxthresh = cpsw_dma_rxthresh((u32)priv->regs, + data->cpdma_reg_ofs); + dma_params.rxfree = cpsw_dma_rxfree((u32)priv->regs, + data->cpdma_reg_ofs); + dma_params.txhdp = cpsw_dma_txhdp((u32)priv->regs, + data->cpdma_sram_ofs); + dma_params.rxhdp = cpsw_dma_rxhdp((u32)priv->regs, + data->cpdma_sram_ofs); + dma_params.txcp = cpsw_dma_txcp((u32)priv->regs, + data->cpdma_sram_ofs); + dma_params.rxcp = cpsw_dma_rxcp((u32)priv->regs, + data->cpdma_sram_ofs); + + dma_params.num_chan = data->channels; + dma_params.has_soft_reset = true; + dma_params.min_packet_size = CPSW_MIN_PACKET_SIZE; + dma_params.desc_mem_size = data->bd_ram_size; + dma_params.desc_align = 16; + dma_params.has_ext_regs = true; + dma_params.desc_mem_phys = data->no_bd_ram ? 0 : + (u32 __force)priv->cpsw_res->start + data->bd_ram_ofs; + dma_params.desc_hw_addr = data->hw_ram_addr ? + data->hw_ram_addr : dma_params.desc_mem_phys ; + + priv->dma = cpdma_ctlr_create(&dma_params); + if (!priv->dma) { + dev_err(priv->dev, "error initializing dma\n"); + ret = -ENOMEM; + goto clean_iomap_ret; + } + + priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0), + cpsw_tx_handler); + priv->rxch = cpdma_chan_create(priv->dma, rx_chan_num(0), + cpsw_rx_handler); + + if (WARN_ON(!priv->txch || !priv->rxch)) { + dev_err(priv->dev, "error initializing dma channels\n"); + ret = -ENOMEM; + goto clean_dma_ret; + } + + memset(&ale_params, 0, sizeof(ale_params)); + ale_params.dev = &ndev->dev; + ale_params.ale_regs = (void *)((u32)priv->regs) + + ((u32)data->ale_reg_ofs); + ale_params.ale_ageout = ale_ageout; + ale_params.ale_entries = data->ale_entries; + ale_params.ale_ports = data->slaves; + + priv->ale = cpsw_ale_create(&ale_params); + if (!priv->ale) { + dev_err(priv->dev, "error initializing ale engine\n"); + ret = -ENODEV; + goto clean_dma_ret; + } + + ndev->irq = platform_get_irq(pdev, 0); + if (ndev->irq < 0) { + dev_err(priv->dev, "error getting irq resource\n"); + ret = -ENOENT; + goto clean_ale_ret; + } + + while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) { + for (i = res->start; i <= res->end; i++) { + if (request_irq(i, cpsw_interrupt, IRQF_DISABLED, + dev_name(&pdev->dev), priv)) { + dev_err(priv->dev, "error attaching irq\n"); + goto clean_ale_ret; + } + priv->irqs_table[k] = i; + priv->num_irqs = k; + } + k++; + } + + ndev->flags |= IFF_ALLMULTI; /* see cpsw_ndo_change_rx_flags() */ + + ndev->netdev_ops = &cpsw_netdev_ops; + SET_ETHTOOL_OPS(ndev, &cpsw_ethtool_ops); + netif_napi_add(ndev, &priv->napi, cpsw_poll, CPSW_POLL_WEIGHT); + + /* register the network device */ + SET_NETDEV_DEV(ndev, &pdev->dev); + ret = register_netdev(ndev); + if (ret) { + dev_err(priv->dev, "error registering net device\n"); + ret = -ENODEV; + goto clean_irq_ret; + } + + cpsw_notice(priv, probe, "initialized device (regs %x, irq %d)\n", + priv->cpsw_res->start, ndev->irq); + + return 0; + +clean_irq_ret: + free_irq(ndev->irq, priv); +clean_ale_ret: + cpsw_ale_destroy(priv->ale); +clean_dma_ret: + cpdma_chan_destroy(priv->txch); + cpdma_chan_destroy(priv->rxch); + cpdma_ctlr_destroy(priv->dma); +clean_iomap_ret: + iounmap(priv->regs); +clean_cpsw_ss_iores_ret: + release_mem_region(priv->cpsw_ss_res->start, + resource_size(priv->cpsw_ss_res)); +clean_cpsw_iores_ret: + release_mem_region(priv->cpsw_res->start, + resource_size(priv->cpsw_res)); +clean_clk_ret: + clk_put(priv->clk); + kfree(priv->slaves); +clean_ndev_ret: + free_netdev(ndev); + return ret; +} + +static int __devexit cpsw_remove(struct platform_device *pdev) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct cpsw_priv *priv = netdev_priv(ndev); + + pr_info("removing device"); + platform_set_drvdata(pdev, NULL); + + free_irq(ndev->irq, priv); + cpsw_ale_destroy(priv->ale); + cpdma_chan_destroy(priv->txch); + cpdma_chan_destroy(priv->rxch); + cpdma_ctlr_destroy(priv->dma); + iounmap(priv->regs); + release_mem_region(priv->cpsw_res->start, + resource_size(priv->cpsw_res)); + release_mem_region(priv->cpsw_ss_res->start, + resource_size(priv->cpsw_ss_res)); + clk_put(priv->clk); + kfree(priv->slaves); + free_netdev(ndev); + + return 0; +} + +static int cpsw_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct net_device *ndev = platform_get_drvdata(pdev); + + if (netif_running(ndev)) + cpsw_ndo_stop(ndev); + return 0; +} + +static int cpsw_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct net_device *ndev = platform_get_drvdata(pdev); + + if (netif_running(ndev)) + cpsw_ndo_open(ndev); + return 0; +} + +static const struct dev_pm_ops cpsw_pm_ops = { + .suspend = cpsw_suspend, + .resume = cpsw_resume, +}; + +static struct platform_driver cpsw_driver = { + .driver = { + .name = "cpsw", + .owner = THIS_MODULE, + .pm = &cpsw_pm_ops, + }, + .probe = cpsw_probe, + .remove = __devexit_p(cpsw_remove), +}; + +static int __init cpsw_init(void) +{ + return platform_driver_register(&cpsw_driver); +} +late_initcall(cpsw_init); + +static void __exit cpsw_exit(void) +{ + platform_driver_unregister(&cpsw_driver); +} +module_exit(cpsw_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Cyril Chemparathy "); +MODULE_AUTHOR("Mugunthan V N "); +MODULE_DESCRIPTION("TI CPSW Ethernet driver"); diff --git a/include/linux/platform_data/cpsw.h b/include/linux/platform_data/cpsw.h new file mode 100644 index 000000000000..c4e23d029498 --- /dev/null +++ b/include/linux/platform_data/cpsw.h @@ -0,0 +1,55 @@ +/* + * Texas Instruments Ethernet Switch Driver + * + * Copyright (C) 2012 Texas Instruments + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef __CPSW_H__ +#define __CPSW_H__ + +#include + +struct cpsw_slave_data { + u32 slave_reg_ofs; + u32 sliver_reg_ofs; + const char *phy_id; + int phy_if; + u8 mac_addr[ETH_ALEN]; +}; + +struct cpsw_platform_data { + u32 ss_reg_ofs; /* Subsystem control register offset */ + u32 channels; /* number of cpdma channels (symmetric) */ + u32 cpdma_reg_ofs; /* cpdma register offset */ + u32 cpdma_sram_ofs; /* cpdma sram offset */ + + u32 slaves; /* number of slave cpgmac ports */ + struct cpsw_slave_data *slave_data; + + u32 ale_reg_ofs; /* address lookup engine reg offset */ + u32 ale_entries; /* ale table size */ + + u32 host_port_reg_ofs; /* cpsw cpdma host port registers */ + u32 host_port_num; /* The port number for the host port */ + + u32 hw_stats_reg_ofs; /* cpsw hardware statistics counters */ + + u32 bd_ram_ofs; /* embedded buffer descriptor RAM offset*/ + u32 bd_ram_size; /*buffer descriptor ram size */ + u32 hw_ram_addr; /*if the HW address for BD RAM is different */ + bool no_bd_ram; /* no embedded BD ram*/ + + u32 rx_descs; /* Number of Rx Descriptios */ + + u32 mac_control; /* Mac control register */ +}; + +#endif /* __CPSW_H__ */ -- GitLab From 74cba4a85e92650f29be0e2d2ba1c282002d1168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Mon, 19 Mar 2012 07:48:29 +0000 Subject: [PATCH 1842/1846] net: qmi_wwan: fix build error due to cdc-wdm dependecy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: drivers/built-in.o: In function `qmi_wwan_bind_shared': qmi_wwan.c:(.text+0x25b686): undefined reference to `usb_cdc_wdm_register' make[1]: *** [.tmp_vmlinux1] Error 1 Reported-by: Randy Dunlap Signed-off-by: Bjørn Mork Acked-by: Randy Dunlap Signed-off-by: David S. Miller --- drivers/net/usb/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 4bad899fb38f..833e32f8d63b 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig @@ -401,6 +401,7 @@ config USB_NET_KALMIA config USB_NET_QMI_WWAN tristate "QMI WWAN driver for Qualcomm MSM based 3G and LTE modems" depends on USB_USBNET + select USB_WDM help Support WWAN LTE/3G devices based on Qualcomm Mobile Data Modem (MDM) chipsets. Examples of such devices are -- GitLab From 5c473ed26dba609622c9a625f896f8f59d86066c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 20 Mar 2012 00:33:59 -0400 Subject: [PATCH 1843/1846] cpsw: Hook up default ndo_change_mtu. Reported-by: Eric Dumazet Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/cpsw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index c68c9d96312e..6685bbb5705a 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -665,6 +665,7 @@ static const struct net_device_ops cpsw_netdev_ops = { .ndo_start_xmit = cpsw_ndo_start_xmit, .ndo_change_rx_flags = cpsw_ndo_change_rx_flags, .ndo_validate_addr = eth_validate_addr, + .ndo_change_mtu = eth_change_mtu, .ndo_tx_timeout = cpsw_ndo_tx_timeout, .ndo_get_stats = cpsw_ndo_get_stats, #ifdef CONFIG_NET_POLL_CONTROLLER -- GitLab From 1f85851e17b64cabd089a8a8839dddebc627948c Mon Sep 17 00:00:00 2001 From: Gao feng Date: Mon, 19 Mar 2012 22:36:10 +0000 Subject: [PATCH 1844/1846] ipv6: fix incorrent ipv6 ipsec packet fragment Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem) In func ip6_append_data,after call skb_put(skb, fraglen + dst_exthdrlen) the skb->len contains dst_exthdrlen,and we don't reduce dst_exthdrlen at last This will make fraggap>0 in next "while cycle",and cause the size of skb incorrent Fix this by reserve headroom for dst_exthdrlen. Signed-off-by: Gao feng Acked-by: Steffen Klassert Signed-off-by: David S. Miller --- net/ipv6/ip6_output.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 7a98fc2a5d97..b7ca46161cb9 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1414,8 +1414,9 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, */ skb->ip_summed = csummode; skb->csum = 0; - /* reserve for fragmentation */ - skb_reserve(skb, hh_len+sizeof(struct frag_hdr)); + /* reserve for fragmentation and ipsec header */ + skb_reserve(skb, hh_len + sizeof(struct frag_hdr) + + dst_exthdrlen); if (sk->sk_type == SOCK_DGRAM) skb_shinfo(skb)->tx_flags = tx_flags; @@ -1423,9 +1424,9 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, /* * Find where to start putting bytes */ - data = skb_put(skb, fraglen + dst_exthdrlen); - skb_set_network_header(skb, exthdrlen + dst_exthdrlen); - data += fragheaderlen + dst_exthdrlen; + data = skb_put(skb, fraglen); + skb_set_network_header(skb, exthdrlen); + data += fragheaderlen; skb->transport_header = (skb->network_header + fragheaderlen); if (fraggap) { -- GitLab From a6506e1486181975d318344143aca722b2b91621 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Mon, 19 Mar 2012 13:01:07 +0000 Subject: [PATCH 1845/1846] Remove printk from rds_sendmsg no socket layer outputs a message for this error and neither should rds. Signed-off-by: Dave Jones Signed-off-by: David S. Miller --- net/rds/send.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/rds/send.c b/net/rds/send.c index e2d63c59e7c2..96531d4033a2 100644 --- a/net/rds/send.c +++ b/net/rds/send.c @@ -935,7 +935,6 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, /* Mirror Linux UDP mirror of BSD error message compatibility */ /* XXX: Perhaps MSG_MORE someday */ if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_CMSG_COMPAT)) { - printk(KERN_INFO "msg_flags 0x%08X\n", msg->msg_flags); ret = -EOPNOTSUPP; goto out; } -- GitLab From bbdb32cb5b73597386913d052165423b9d736145 Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Tue, 20 Mar 2012 03:57:54 +0000 Subject: [PATCH 1846/1846] Fix pppol2tp getsockname() While testing L2TP functionality, I came across a bug in getsockname(). The IP address returned within the pppol2tp_addr's addr memember was not being set to the IP address in use. This bug is caused by using inet_sk() on the wrong socket (the L2TP socket rather than the underlying UDP socket), and was likely introduced during the addition of L2TPv3 support. Signed-off-by: Benjamin LaHaise Signed-off-by: James Chapman Signed-off-by: David S. Miller --- net/l2tp/l2tp_ppp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 96bc7a67585a..9b071910b4ba 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -915,7 +915,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr, goto end_put_sess; } - inet = inet_sk(sk); + inet = inet_sk(tunnel->sock); if (tunnel->version == 2) { struct sockaddr_pppol2tp sp; len = sizeof(sp); -- GitLab